{"text": "import connected\n\nnoncomputable theory\n\nvariables {V : Type*} {G : quiver V} [inhabited V]\n\nlocal notation `root` := default V\n\ndef quiver.path.length {a} : Π {b : V} (p : quiver.path G a b), ℕ\n| _  quiver.path.nil       := 0\n| _ (quiver.path.cons p _) := p.length + 1\n\nvariables [directed_connected G] (G)\n\n/-- A path to `root` of minimal length. -/\ndef shortest_path (a : V) : G.path root a :=\nwell_founded.min (measure_wf $ λ p : G.path root a, p.length) set.univ set.univ_nonempty\n\n/-- The length of a path is at least the length of the shortest path -/\nlemma shortest_path_spec {a : V} (p : G.path root a) :\n  (shortest_path G a).length ≤ p.length :=\nbegin\n  have : ¬ (p.length < (shortest_path G a).length) :=\n    well_founded.not_lt_min (measure_wf _) set.univ _ trivial,\n  simpa using this,\nend\n\n/-- The geodesic subgraph. For each non-root vertex, there is an edge from a parent:\n    some vertex that is closer to `root`. -/\ndef geodesic_subgraph : subquiver G :=\nλ a b e, ∃ p : G.path root a, shortest_path G b = quiver.path.cons p e\n\n-- todo: write this idiomatically\nlemma paths_are_unique : ∀ {s : V} {p q : (¡geodesic_subgraph G).path root s}, p = q\n| _ (quiver.path.nil) := begin\n  rintro ( _ | _ ),\n  { refl },\n  exfalso,\n  rcases q_ᾰ_1 with ⟨_, _, h⟩,\n  have : (shortest_path G root).length ≤ 0 :=\n    shortest_path_spec G quiver.path.nil,\n  rw h at this,\n  change _ + 1 ≤ 0 at this,\n  simpa only [nonpos_iff_eq_zero] using this,\nend\n| t (quiver.path.cons p e) := begin\n  rcases e with ⟨_, _, h⟩,\n  rintro ( _ | _ ),\n  { have : (shortest_path G root).length ≤ 0 :=\n      shortest_path_spec G quiver.path.nil,\n    rw h at this,\n    change _ + 1 ≤ 0 at this,\n    simpa only [nonpos_iff_eq_zero] using this },\n  { rcases q_ᾰ_1 with ⟨_, _, hq⟩,\n    rw h at hq,\n    cases hq,\n    congr,\n    apply paths_are_unique }\nend\n\ndef geodesic_path : Π (gas : ℕ) (t : V), (shortest_path G t).length ≤ gas →\n      (¡geodesic_subgraph G).path root t :=\nbegin -- todo: write this idiomatically\n  intro gas,\n  induction gas with gas ih,\n  { intros t h,\n    have : ∃ p, p = shortest_path G t, \n    { refine ⟨_, rfl⟩ },\n    rcases (classical.indefinite_description _ this) with ⟨p, hp⟩,\n    cases p with s t p e,\n    { exact quiver.path.nil },\n    { exfalso, -- out of gas\n      rw ←hp at h,\n      simpa using h } },\n  { intros t h,\n    have : ∃ p, p = shortest_path G t, \n    { refine ⟨_, rfl⟩ },\n    rcases (classical.indefinite_description _ this) with ⟨p, hp⟩,\n    cases p with s t p e,\n    { exact quiver.path.nil },\n    { refine quiver.path.cons _ ⟨e, p, hp.symm⟩,\n      apply ih,\n      rw ←hp at h,\n      change _ + 1 ≤ _ + 1 at h,\n      rw add_le_add_iff_right at h,\n      exact le_trans (shortest_path_spec G p) h } }\nend\n\ninstance geodesic_tree : is_arbor ¡geodesic_subgraph G :=\n{ unique_path := λ b,\n  { default := geodesic_path G _ b (le_refl _),\n    uniq := λ _, paths_are_unique G } }", "meta": {"author": "dwarn", "repo": "nielsen-schreier-2", "sha": "e51a8c6511d374dc584698c7fa236a5be47e7dbe", "save_path": "github-repos/lean/dwarn-nielsen-schreier-2", "path": "github-repos/lean/dwarn-nielsen-schreier-2/nielsen-schreier-2-e51a8c6511d374dc584698c7fa236a5be47e7dbe/src/arborescence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.4999988529344828}}
{"text": "/-\nCopyright (c) 2020 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.natural_isomorphism\nimport Mathlib.PostPort\n\nuniverses v u l u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Quotient category\n\nConstructs the quotient of a category by an arbitrary family of relations on its hom-sets,\nby introducing a type synonym for the objects, and identifying homs as necessary.\n\nThis is analogous to 'the quotient of a group by the normal closure of a subset', rather\nthan 'the quotient of a group by a normal subgroup'.\n-/\n\nnamespace category_theory\n\n\n/-- A type synonom for `C`, thought of as the objects of the quotient category. -/\nstructure quotient {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) where\n  as : C\n\nprotected instance quotient.inhabited {C : Type u} [category C]\n    (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) [Inhabited C] : Inhabited (quotient r) :=\n  { default := quotient.mk Inhabited.default }\n\nnamespace quotient\n\n\n/-- Generates the closure of a family of relations w.r.t. composition from left and right. -/\ninductive comp_closure {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {s : C}\n    {t : C} : (s ⟶ t) → (s ⟶ t) → Prop\n    where\n| intro :\n    ∀ {a b : C} (f : s ⟶ a) (m₁ m₂ : a ⟶ b) (g : b ⟶ t),\n      r m₁ m₂ → comp_closure r (f ≫ m₁ ≫ g) (f ≫ m₂ ≫ g)\n\ntheorem comp_left {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : C}\n    {b : C} {c : C} (f : a ⟶ b) (g₁ : b ⟶ c) (g₂ : b ⟶ c) (h : comp_closure r g₁ g₂) :\n    comp_closure r (f ≫ g₁) (f ≫ g₂) :=\n  sorry\n\ntheorem comp_right {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : C}\n    {b : C} {c : C} (g : b ⟶ c) (f₁ : a ⟶ b) (f₂ : a ⟶ b) (h : comp_closure r f₁ f₂) :\n    comp_closure r (f₁ ≫ g) (f₂ ≫ g) :=\n  sorry\n\n/-- Hom-sets of the quotient category. -/\ndef hom {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) (s : quotient r)\n    (t : quotient r) :=\n  Quot (comp_closure r)\n\nprotected instance hom.inhabited {C : Type u} [category C]\n    (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) (a : quotient r) : Inhabited (hom r a a) :=\n  { default := Quot.mk (comp_closure r) 𝟙 }\n\n/-- Composition in the quotient category. -/\ndef comp {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : quotient r}\n    {b : quotient r} {c : quotient r} : hom r a b → hom r b c → hom r a c :=\n  fun (hf : hom r a b) (hg : hom r b c) =>\n    quot.lift_on hf\n      (fun (f : as a ⟶ as b) =>\n        quot.lift_on hg (fun (g : as b ⟶ as c) => Quot.mk (comp_closure r) (f ≫ g)) sorry)\n      sorry\n\n@[simp] theorem comp_mk {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop)\n    {a : quotient r} {b : quotient r} {c : quotient r} (f : as a ⟶ as b) (g : as b ⟶ as c) :\n    comp r (Quot.mk (comp_closure r) f) (Quot.mk (comp_closure r) g) =\n        Quot.mk (comp_closure r) (f ≫ g) :=\n  rfl\n\nprotected instance category {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) :\n    category (quotient r) :=\n  category.mk\n\n/-- The functor from a category to its quotient. -/\n@[simp] theorem functor_map {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop)\n    (_x : C) :\n    ∀ (_x_1 : C) (f : _x ⟶ _x_1), functor.map (functor r) f = Quot.mk (comp_closure r) f :=\n  fun (_x_1 : C) (f : _x ⟶ _x_1) => Eq.refl (functor.map (functor r) f)\n\nprotected theorem induction {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop)\n    {P : {a b : quotient r} → (a ⟶ b) → Prop}\n    (h : ∀ {x y : C} (f : x ⟶ y), P (functor.map (functor r) f)) {a : quotient r} {b : quotient r}\n    (f : a ⟶ b) : P f :=\n  sorry\n\nprotected theorem sound {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : C}\n    {b : C} {f₁ : a ⟶ b} {f₂ : a ⟶ b} (h : r f₁ f₂) :\n    functor.map (functor r) f₁ = functor.map (functor r) f₂ :=\n  sorry\n\n/-- The induced functor on the quotient category. -/\ndef lift {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1}\n    [category D] (F : C ⥤ D)\n    (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) :\n    quotient r ⥤ D :=\n  functor.mk (fun (a : quotient r) => functor.obj F (as a))\n    fun (a b : quotient r) (hf : a ⟶ b) =>\n      quot.lift_on hf (fun (f : as a ⟶ as b) => functor.map F f) sorry\n\n/-- The original functor factors through the induced functor. -/\ndef lift.is_lift {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1}\n    [category D] (F : C ⥤ D)\n    (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) :\n    functor r ⋙ lift r F H ≅ F :=\n  nat_iso.of_components (fun (X : C) => iso.refl (functor.obj (functor r ⋙ lift r F H) X)) sorry\n\n@[simp] theorem lift.is_lift_hom {C : Type u} [category C]\n    (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1} [category D] (F : C ⥤ D)\n    (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) (X : C) :\n    nat_trans.app (iso.hom (lift.is_lift r F H)) X = 𝟙 :=\n  rfl\n\n@[simp] theorem lift.is_lift_inv {C : Type u} [category C]\n    (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1} [category D] (F : C ⥤ D)\n    (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) (X : C) :\n    nat_trans.app (iso.inv (lift.is_lift r F H)) X = 𝟙 :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/quotient_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.4999988529344828}}
{"text": "/-\nCopyright (c) 2022 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.monoidal.linear\n! leanprover-community/mathlib commit 986c4d5761f938b2e1c43c01f001b6d9d88c2055\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Linear.LinearFunctor\nimport Mathbin.CategoryTheory.Monoidal.Preadditive\n\n/-!\n# Linear monoidal categories\n\nA monoidal category is `monoidal_linear R` if it is monoidal preadditive and\ntensor product of morphisms is `R`-linear in both factors.\n-/\n\n\nnamespace CategoryTheory\n\nopen CategoryTheory.Limits\n\nopen CategoryTheory.MonoidalCategory\n\nvariable (R : Type _) [Semiring R]\n\nvariable (C : Type _) [Category C] [Preadditive C] [Linear R C]\n\nvariable [MonoidalCategory C] [MonoidalPreadditive C]\n\n#print CategoryTheory.MonoidalLinear /-\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- A category is `monoidal_linear R` if tensoring is `R`-linear in both factors.\n-/\nclass MonoidalLinear : Prop where\n  tensor_smul' : ∀ {W X Y Z : C} (f : W ⟶ X) (r : R) (g : Y ⟶ Z), f ⊗ r • g = r • (f ⊗ g) := by\n    obviously\n  smul_tensor' : ∀ {W X Y Z : C} (r : R) (f : W ⟶ X) (g : Y ⟶ Z), r • f ⊗ g = r • (f ⊗ g) := by\n    obviously\n#align category_theory.monoidal_linear CategoryTheory.MonoidalLinear\n-/\n\nrestate_axiom monoidal_linear.tensor_smul'\n\nrestate_axiom monoidal_linear.smul_tensor'\n\nattribute [simp] monoidal_linear.tensor_smul monoidal_linear.smul_tensor\n\nvariable {C} [MonoidalLinear R C]\n\n#print CategoryTheory.tensorLeft_linear /-\ninstance tensorLeft_linear (X : C) : (tensorLeft X).Linear R where\n#align category_theory.tensor_left_linear CategoryTheory.tensorLeft_linear\n-/\n\n#print CategoryTheory.tensorRight_linear /-\ninstance tensorRight_linear (X : C) : (tensorRight X).Linear R where\n#align category_theory.tensor_right_linear CategoryTheory.tensorRight_linear\n-/\n\n/- warning: category_theory.tensoring_left_linear -> CategoryTheory.tensoringLeft_linear is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : Semiring.{u1} R] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u3, u2} C] [_inst_3 : CategoryTheory.Preadditive.{u3, u2} C _inst_2] [_inst_4 : CategoryTheory.Linear.{u1, u3, u2} R _inst_1 C _inst_2 _inst_3] [_inst_5 : CategoryTheory.MonoidalCategory.{u3, u2} C _inst_2] [_inst_6 : CategoryTheory.MonoidalPreadditive.{u2, u3} C _inst_2 _inst_3 _inst_5] [_inst_7 : CategoryTheory.MonoidalLinear.{u1, u2, u3} R _inst_1 C _inst_2 _inst_3 _inst_4 _inst_5 _inst_6] (X : C), CategoryTheory.Functor.Linear.{u1, u2, u2, u3, u3} R _inst_1 C C _inst_2 _inst_2 _inst_3 _inst_3 _inst_4 _inst_4 (CategoryTheory.Functor.obj.{u3, max u2 u3, u2, max u3 u2} C _inst_2 (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Functor.category.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.MonoidalCategory.tensoringLeft.{u3, u2} C _inst_2 _inst_5) X) (CategoryTheory.tensoringLeft_additive.{u2, u3} C _inst_2 _inst_3 _inst_5 _inst_6 X)\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : Semiring.{u1} R] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u3, u2} C] [_inst_3 : CategoryTheory.Preadditive.{u3, u2} C _inst_2] [_inst_4 : CategoryTheory.Linear.{u1, u3, u2} R _inst_1 C _inst_2 _inst_3] [_inst_5 : CategoryTheory.MonoidalCategory.{u3, u2} C _inst_2] [_inst_6 : CategoryTheory.MonoidalPreadditive.{u2, u3} C _inst_2 _inst_3 _inst_5] [_inst_7 : CategoryTheory.MonoidalLinear.{u1, u2, u3} R _inst_1 C _inst_2 _inst_3 _inst_4 _inst_5 _inst_6] (X : C), CategoryTheory.Functor.Linear.{u1, u2, u2, u3, u3} R _inst_1 C C _inst_2 _inst_2 _inst_3 _inst_3 _inst_4 _inst_4 (Prefunctor.obj.{succ u3, max (succ u2) (succ u3), u2, max u2 u3} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u2} C (CategoryTheory.Category.toCategoryStruct.{u3, u2} C _inst_2)) (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u3, max u2 u3} (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{max u2 u3, max u2 u3} (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Functor.category.{u3, u3, u2, u2} C _inst_2 C _inst_2))) (CategoryTheory.Functor.toPrefunctor.{u3, max u2 u3, u2, max u2 u3} C _inst_2 (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Functor.category.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.MonoidalCategory.tensoringLeft.{u3, u2} C _inst_2 _inst_5)) X) (CategoryTheory.tensoringLeft_additive.{u2, u3} C _inst_2 _inst_3 _inst_5 _inst_6 X)\nCase conversion may be inaccurate. Consider using '#align category_theory.tensoring_left_linear CategoryTheory.tensoringLeft_linearₓ'. -/\ninstance tensoringLeft_linear (X : C) : ((tensoringLeft C).obj X).Linear R where\n#align category_theory.tensoring_left_linear CategoryTheory.tensoringLeft_linear\n\n/- warning: category_theory.tensoring_right_linear -> CategoryTheory.tensoringRight_linear is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : Semiring.{u1} R] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u3, u2} C] [_inst_3 : CategoryTheory.Preadditive.{u3, u2} C _inst_2] [_inst_4 : CategoryTheory.Linear.{u1, u3, u2} R _inst_1 C _inst_2 _inst_3] [_inst_5 : CategoryTheory.MonoidalCategory.{u3, u2} C _inst_2] [_inst_6 : CategoryTheory.MonoidalPreadditive.{u2, u3} C _inst_2 _inst_3 _inst_5] [_inst_7 : CategoryTheory.MonoidalLinear.{u1, u2, u3} R _inst_1 C _inst_2 _inst_3 _inst_4 _inst_5 _inst_6] (X : C), CategoryTheory.Functor.Linear.{u1, u2, u2, u3, u3} R _inst_1 C C _inst_2 _inst_2 _inst_3 _inst_3 _inst_4 _inst_4 (CategoryTheory.Functor.obj.{u3, max u2 u3, u2, max u3 u2} C _inst_2 (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Functor.category.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.MonoidalCategory.tensoringRight.{u3, u2} C _inst_2 _inst_5) X) (CategoryTheory.tensoringRight_additive.{u2, u3} C _inst_2 _inst_3 _inst_5 _inst_6 X)\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : Semiring.{u1} R] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u3, u2} C] [_inst_3 : CategoryTheory.Preadditive.{u3, u2} C _inst_2] [_inst_4 : CategoryTheory.Linear.{u1, u3, u2} R _inst_1 C _inst_2 _inst_3] [_inst_5 : CategoryTheory.MonoidalCategory.{u3, u2} C _inst_2] [_inst_6 : CategoryTheory.MonoidalPreadditive.{u2, u3} C _inst_2 _inst_3 _inst_5] [_inst_7 : CategoryTheory.MonoidalLinear.{u1, u2, u3} R _inst_1 C _inst_2 _inst_3 _inst_4 _inst_5 _inst_6] (X : C), CategoryTheory.Functor.Linear.{u1, u2, u2, u3, u3} R _inst_1 C C _inst_2 _inst_2 _inst_3 _inst_3 _inst_4 _inst_4 (Prefunctor.obj.{succ u3, max (succ u2) (succ u3), u2, max u2 u3} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u2} C (CategoryTheory.Category.toCategoryStruct.{u3, u2} C _inst_2)) (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u3, max u2 u3} (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{max u2 u3, max u2 u3} (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Functor.category.{u3, u3, u2, u2} C _inst_2 C _inst_2))) (CategoryTheory.Functor.toPrefunctor.{u3, max u2 u3, u2, max u2 u3} C _inst_2 (CategoryTheory.Functor.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.Functor.category.{u3, u3, u2, u2} C _inst_2 C _inst_2) (CategoryTheory.MonoidalCategory.tensoringRight.{u3, u2} C _inst_2 _inst_5)) X) (CategoryTheory.tensoringRight_additive.{u2, u3} C _inst_2 _inst_3 _inst_5 _inst_6 X)\nCase conversion may be inaccurate. Consider using '#align category_theory.tensoring_right_linear CategoryTheory.tensoringRight_linearₓ'. -/\ninstance tensoringRight_linear (X : C) : ((tensoringRight C).obj X).Linear R where\n#align category_theory.tensoring_right_linear CategoryTheory.tensoringRight_linear\n\n/- warning: category_theory.monoidal_linear_of_faithful -> CategoryTheory.monoidalLinearOfFaithful is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : Semiring.{u1} R] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u3, u2} C] [_inst_3 : CategoryTheory.Preadditive.{u3, u2} C _inst_2] [_inst_4 : CategoryTheory.Linear.{u1, u3, u2} R _inst_1 C _inst_2 _inst_3] [_inst_5 : CategoryTheory.MonoidalCategory.{u3, u2} C _inst_2] [_inst_6 : CategoryTheory.MonoidalPreadditive.{u2, u3} C _inst_2 _inst_3 _inst_5] [_inst_7 : CategoryTheory.MonoidalLinear.{u1, u2, u3} R _inst_1 C _inst_2 _inst_3 _inst_4 _inst_5 _inst_6] {D : Type.{u4}} [_inst_8 : CategoryTheory.Category.{u5, u4} D] [_inst_9 : CategoryTheory.Preadditive.{u5, u4} D _inst_8] [_inst_10 : CategoryTheory.Linear.{u1, u5, u4} R _inst_1 D _inst_8 _inst_9] [_inst_11 : CategoryTheory.MonoidalCategory.{u5, u4} D _inst_8] [_inst_12 : CategoryTheory.MonoidalPreadditive.{u4, u5} D _inst_8 _inst_9 _inst_11] (F : CategoryTheory.MonoidalFunctor.{u5, u3, u4, u2} D _inst_8 _inst_11 C _inst_2 _inst_5) [_inst_13 : CategoryTheory.Faithful.{u5, u3, u4, u2} D _inst_8 C _inst_2 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u5, u3, u4, u2} D _inst_8 _inst_11 C _inst_2 _inst_5 (CategoryTheory.MonoidalFunctor.toLaxMonoidalFunctor.{u5, u3, u4, u2} D _inst_8 _inst_11 C _inst_2 _inst_5 F))] [_inst_14 : CategoryTheory.Functor.Additive.{u4, u2, u5, u3} D C _inst_8 _inst_2 _inst_9 _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u5, u3, u4, u2} D _inst_8 _inst_11 C _inst_2 _inst_5 (CategoryTheory.MonoidalFunctor.toLaxMonoidalFunctor.{u5, u3, u4, u2} D _inst_8 _inst_11 C _inst_2 _inst_5 F))] [_inst_15 : CategoryTheory.Functor.Linear.{u1, u4, u2, u5, u3} R _inst_1 D C _inst_8 _inst_2 _inst_9 _inst_3 _inst_10 _inst_4 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u5, u3, u4, u2} D _inst_8 _inst_11 C _inst_2 _inst_5 (CategoryTheory.MonoidalFunctor.toLaxMonoidalFunctor.{u5, u3, u4, u2} D _inst_8 _inst_11 C _inst_2 _inst_5 F)) _inst_14], CategoryTheory.MonoidalLinear.{u1, u4, u5} R _inst_1 D _inst_8 _inst_9 _inst_10 _inst_11 _inst_12\nbut is expected to have type\n  forall (R : Type.{u3}) [_inst_1 : Semiring.{u3} R] {C : Type.{u1}} [_inst_2 : CategoryTheory.Category.{u2, u1} C] [_inst_3 : CategoryTheory.Preadditive.{u2, u1} C _inst_2] [_inst_4 : CategoryTheory.Linear.{u3, u2, u1} R _inst_1 C _inst_2 _inst_3] [_inst_5 : CategoryTheory.MonoidalCategory.{u2, u1} C _inst_2] [_inst_6 : CategoryTheory.MonoidalPreadditive.{u1, u2} C _inst_2 _inst_3 _inst_5] [_inst_7 : CategoryTheory.MonoidalLinear.{u3, u1, u2} R _inst_1 C _inst_2 _inst_3 _inst_4 _inst_5 _inst_6] {D : Type.{u5}} [_inst_8 : CategoryTheory.Category.{u4, u5} D] [_inst_9 : CategoryTheory.Preadditive.{u4, u5} D _inst_8] [_inst_10 : CategoryTheory.Linear.{u3, u4, u5} R _inst_1 D _inst_8 _inst_9] [_inst_11 : CategoryTheory.MonoidalCategory.{u4, u5} D _inst_8] [_inst_12 : CategoryTheory.MonoidalPreadditive.{u5, u4} D _inst_8 _inst_9 _inst_11] (F : CategoryTheory.MonoidalFunctor.{u4, u2, u5, u1} D _inst_8 _inst_11 C _inst_2 _inst_5) [_inst_13 : CategoryTheory.Faithful.{u4, u2, u5, u1} D _inst_8 C _inst_2 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u4, u2, u5, u1} D _inst_8 _inst_11 C _inst_2 _inst_5 (CategoryTheory.MonoidalFunctor.toLaxMonoidalFunctor.{u4, u2, u5, u1} D _inst_8 _inst_11 C _inst_2 _inst_5 F))] [_inst_14 : CategoryTheory.Functor.Additive.{u5, u1, u4, u2} D C _inst_8 _inst_2 _inst_9 _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u4, u2, u5, u1} D _inst_8 _inst_11 C _inst_2 _inst_5 (CategoryTheory.MonoidalFunctor.toLaxMonoidalFunctor.{u4, u2, u5, u1} D _inst_8 _inst_11 C _inst_2 _inst_5 F))] [_inst_15 : CategoryTheory.Functor.Linear.{u3, u5, u1, u4, u2} R _inst_1 D C _inst_8 _inst_2 _inst_9 _inst_3 _inst_10 _inst_4 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u4, u2, u5, u1} D _inst_8 _inst_11 C _inst_2 _inst_5 (CategoryTheory.MonoidalFunctor.toLaxMonoidalFunctor.{u4, u2, u5, u1} D _inst_8 _inst_11 C _inst_2 _inst_5 F)) _inst_14], CategoryTheory.MonoidalLinear.{u3, u5, u4} R _inst_1 D _inst_8 _inst_9 _inst_10 _inst_11 _inst_12\nCase conversion may be inaccurate. Consider using '#align category_theory.monoidal_linear_of_faithful CategoryTheory.monoidalLinearOfFaithfulₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- A faithful linear monoidal functor to a linear monoidal category\nensures that the domain is linear monoidal. -/\ntheorem monoidalLinearOfFaithful {D : Type _} [Category D] [Preadditive D] [Linear R D]\n    [MonoidalCategory D] [MonoidalPreadditive D] (F : MonoidalFunctor D C) [Faithful F.toFunctor]\n    [F.toFunctor.Additive] [F.toFunctor.Linear R] : MonoidalLinear R D :=\n  { tensor_smul' := by\n      intros\n      apply F.to_functor.map_injective\n      simp only [F.to_functor.map_smul r (f ⊗ g), F.to_functor.map_smul r g, F.map_tensor,\n        monoidal_linear.tensor_smul, linear.smul_comp, linear.comp_smul]\n    smul_tensor' := by\n      intros\n      apply F.to_functor.map_injective\n      simp only [F.to_functor.map_smul r (f ⊗ g), F.to_functor.map_smul r f, F.map_tensor,\n        monoidal_linear.smul_tensor, linear.smul_comp, linear.comp_smul] }\n#align category_theory.monoidal_linear_of_faithful CategoryTheory.monoidalLinearOfFaithful\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Monoidal/Linear.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.49999884243807613}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.category.default\nimport Mathlib.data.equiv.functor\nimport Mathlib.PostPort\n\nuniverses u₀ u₁ l \n\nnamespace Mathlib\n\n/-!\n# Functions functorial with respect to equivalences\n\nAn `equiv_functor` is a function from `Type → Type` equipped with the additional data of\ncoherently mapping equivalences to equivalences.\n\nIn categorical language, it is an endofunctor of the \"core\" of the category `Type`.\n-/\n\n/--\nAn `equiv_functor` is only functorial with respect to equivalences.\n\nTo construct an `equiv_functor`, it suffices to supply just the function `f α → f β` from\nan equivalence `α ≃ β`, and then prove the functor laws. It's then a consequence that\nthis function is part of an equivalence, provided by `equiv_functor.map_equiv`.\n-/\nclass equiv_functor (f : Type u₀ → Type u₁) \nwhere\n  map : {α β : Type u₀} → α ≃ β → f α → f β\n  map_refl' : autoParam (∀ (α : Type u₀), map (equiv.refl α) = id)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  map_trans' : autoParam (∀ {α β γ : Type u₀} (k : α ≃ β) (h : β ≃ γ), map (equiv.trans k h) = map h ∘ map k)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n@[simp] theorem equiv_functor.map_refl {f : Type u₀ → Type u₁} [c : equiv_functor f] (α : Type u₀) : equiv_functor.map (equiv.refl α) = id := sorry\n\ntheorem equiv_functor.map_trans {f : Type u₀ → Type u₁} [c : equiv_functor f] {α : Type u₀} {β : Type u₀} {γ : Type u₀} (k : α ≃ β) (h : β ≃ γ) : equiv_functor.map (equiv.trans k h) = equiv_functor.map h ∘ equiv_functor.map k := sorry\n\nnamespace equiv_functor\n\n\n/-- An `equiv_functor` in fact takes every equiv to an equiv. -/\ndef map_equiv (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀} (e : α ≃ β) : f α ≃ f β :=\n  equiv.mk (map e) (map (equiv.symm e)) sorry sorry\n\n@[simp] theorem map_equiv_apply (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀} (e : α ≃ β) (x : f α) : coe_fn (map_equiv f e) x = map e x :=\n  rfl\n\ntheorem map_equiv_symm_apply (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀} (e : α ≃ β) (y : f β) : coe_fn (equiv.symm (map_equiv f e)) y = map (equiv.symm e) y :=\n  rfl\n\n@[simp] theorem map_equiv_refl (f : Type u₀ → Type u₁) [equiv_functor f] (α : Type u₀) : map_equiv f (equiv.refl α) = equiv.refl (f α) := sorry\n\n@[simp] theorem map_equiv_symm (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀} (e : α ≃ β) : equiv.symm (map_equiv f e) = map_equiv f (equiv.symm e) :=\n  equiv.ext (map_equiv_symm_apply f e)\n\n/--\nThe composition of `map_equiv`s is carried over the `equiv_functor`.\nFor plain `functor`s, this lemma is named `map_map` when applied\nor `map_comp_map` when not applied.\n-/\n@[simp] theorem map_equiv_trans (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀} {γ : Type u₀} (ab : α ≃ β) (bc : β ≃ γ) : equiv.trans (map_equiv f ab) (map_equiv f bc) = map_equiv f (equiv.trans ab bc) := sorry\n\nprotected instance of_is_lawful_functor (f : Type u₀ → Type u₁) [Functor f] [is_lawful_functor f] : equiv_functor f :=\n  mk fun (α β : Type u₀) (e : α ≃ β) => Functor.map ⇑e\n\ntheorem map_equiv.injective (f : Type u₀ → Type u₁) [Applicative f] [is_lawful_applicative f] {α : Type u₀} {β : Type u₀} (h : Type u₀ → function.injective pure) : function.injective (map_equiv f) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/control/equiv_functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6477982111525409, "lm_q1q2_score": 0.4999988371898726}}
{"text": "/-\nCopyright (c) 2018 Andreas Swerdlow. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andreas Swerdlow\n\n! This file was ported from Lean 3 source module deprecated.subfield\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Deprecated.Subring\n\n/-!\n# Unbundled subfields (deprecated)\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file is deprecated, and is no longer imported by anything in mathlib other than other\ndeprecated files, and test files. You should not need to import it.\n\nThis file defines predicates for unbundled subfields. Instead of using this file, please use\n`subfield`, defined in `field_theory.subfield`, for subfields of fields.\n\n## Main definitions\n\n`is_subfield (S : set F) : Prop` : the predicate that `S` is the underlying set of a subfield\nof the field `F`. The bundled variant `subfield F` should be used in preference to this.\n\n## Tags\n\nis_subfield\n-/\n\n\nvariable {F : Type _} [Field F] (S : Set F)\n\n#print IsSubfield /-\n/-- `is_subfield (S : set F)` is the predicate saying that a given subset of a field is\nthe set underlying a subfield. This structure is deprecated; use the bundled variant\n`subfield F` to model subfields of a field. -/\nstructure IsSubfield extends IsSubring S : Prop where\n  inv_mem : ∀ {x : F}, x ∈ S → x⁻¹ ∈ S\n#align is_subfield IsSubfield\n-/\n\n/- warning: is_subfield.div_mem -> IsSubfield.div_mem is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {S : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 S) -> (forall {x : F} {y : F}, (Membership.Mem.{u1, u1} F (Set.{u1} F) (Set.hasMem.{u1} F) x S) -> (Membership.Mem.{u1, u1} F (Set.{u1} F) (Set.hasMem.{u1} F) y S) -> (Membership.Mem.{u1, u1} F (Set.{u1} F) (Set.hasMem.{u1} F) (HDiv.hDiv.{u1, u1, u1} F F F (instHDiv.{u1} F (DivInvMonoid.toHasDiv.{u1} F (DivisionRing.toDivInvMonoid.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) x y) S))\nbut is expected to have type\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {S : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 S) -> (forall {x : F} {y : F}, (Membership.mem.{u1, u1} F (Set.{u1} F) (Set.instMembershipSet.{u1} F) x S) -> (Membership.mem.{u1, u1} F (Set.{u1} F) (Set.instMembershipSet.{u1} F) y S) -> (Membership.mem.{u1, u1} F (Set.{u1} F) (Set.instMembershipSet.{u1} F) (HDiv.hDiv.{u1, u1, u1} F F F (instHDiv.{u1} F (Field.toDiv.{u1} F _inst_1)) x y) S))\nCase conversion may be inaccurate. Consider using '#align is_subfield.div_mem IsSubfield.div_memₓ'. -/\ntheorem IsSubfield.div_mem {S : Set F} (hS : IsSubfield S) {x y : F} (hx : x ∈ S) (hy : y ∈ S) :\n    x / y ∈ S := by\n  rw [div_eq_mul_inv]\n  exact hS.to_is_subring.to_is_submonoid.mul_mem hx (hS.inv_mem hy)\n#align is_subfield.div_mem IsSubfield.div_mem\n\n#print IsSubfield.pow_mem /-\ntheorem IsSubfield.pow_mem {a : F} {n : ℤ} {s : Set F} (hs : IsSubfield s) (h : a ∈ s) :\n    a ^ n ∈ s := by\n  cases n\n  · rw [zpow_ofNat]\n    exact hs.to_is_subring.to_is_submonoid.pow_mem h\n  · rw [zpow_negSucc]\n    exact hs.inv_mem (hs.to_is_subring.to_is_submonoid.pow_mem h)\n#align is_subfield.pow_mem IsSubfield.pow_mem\n-/\n\n#print Univ.isSubfield /-\ntheorem Univ.isSubfield : IsSubfield (@Set.univ F) :=\n  { Univ.isSubmonoid, IsAddSubgroup.univ_addSubgroup with inv_mem := by intros <;> trivial }\n#align univ.is_subfield Univ.isSubfield\n-/\n\n/- warning: preimage.is_subfield -> Preimage.isSubfield is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {K : Type.{u2}} [_inst_2 : Field.{u2} K] (f : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) {s : Set.{u2} K}, (IsSubfield.{u2} K _inst_2 s) -> (IsSubfield.{u1} F _inst_1 (Set.preimage.{u1, u2} F K (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) (fun (_x : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) => F -> K) (RingHom.hasCoeToFun.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) f) s))\nbut is expected to have type\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {K : Type.{u2}} [_inst_2 : Field.{u2} K] (f : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) {s : Set.{u2} K}, (IsSubfield.{u2} K _inst_2 s) -> (IsSubfield.{u1} F _inst_1 (Set.preimage.{u1, u2} F K (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F (fun (_x : F) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : F) => K) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonUnitalNonAssocSemiring.toMul.{u1} F (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} F (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} K (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} F (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} K (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))))))) f) s))\nCase conversion may be inaccurate. Consider using '#align preimage.is_subfield Preimage.isSubfieldₓ'. -/\ntheorem Preimage.isSubfield {K : Type _} [Field K] (f : F →+* K) {s : Set K} (hs : IsSubfield s) :\n    IsSubfield (f ⁻¹' s) :=\n  { f.isSubring_preimage hs.to_isSubring with\n    inv_mem := fun a (ha : f a ∈ s) =>\n      show f a⁻¹ ∈ s by\n        rw [map_inv₀]\n        exact hs.inv_mem ha }\n#align preimage.is_subfield Preimage.isSubfield\n\n/- warning: image.is_subfield -> Image.isSubfield is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {K : Type.{u2}} [_inst_2 : Field.{u2} K] (f : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) {s : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 s) -> (IsSubfield.{u2} K _inst_2 (Set.image.{u1, u2} F K (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) (fun (_x : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) => F -> K) (RingHom.hasCoeToFun.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) f) s))\nbut is expected to have type\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {K : Type.{u2}} [_inst_2 : Field.{u2} K] (f : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) {s : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 s) -> (IsSubfield.{u2} K _inst_2 (Set.image.{u1, u2} F K (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F (fun (_x : F) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : F) => K) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonUnitalNonAssocSemiring.toMul.{u1} F (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} F (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} K (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} F (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} K (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))))))) f) s))\nCase conversion may be inaccurate. Consider using '#align image.is_subfield Image.isSubfieldₓ'. -/\ntheorem Image.isSubfield {K : Type _} [Field K] (f : F →+* K) {s : Set F} (hs : IsSubfield s) :\n    IsSubfield (f '' s) :=\n  { f.isSubring_image hs.to_isSubring with\n    inv_mem := fun a ⟨x, xmem, ha⟩ => ⟨x⁻¹, hs.inv_mem xmem, ha ▸ map_inv₀ f _⟩ }\n#align image.is_subfield Image.isSubfield\n\n/- warning: range.is_subfield -> Range.isSubfield is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {K : Type.{u2}} [_inst_2 : Field.{u2} K] (f : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))), IsSubfield.{u2} K _inst_2 (Set.range.{u2, succ u1} K F (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) (fun (_x : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) => F -> K) (RingHom.hasCoeToFun.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) f))\nbut is expected to have type\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {K : Type.{u2}} [_inst_2 : Field.{u2} K] (f : RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))), IsSubfield.{u2} K _inst_2 (Set.range.{u2, succ u1} K F (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F (fun (_x : F) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : F) => K) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonUnitalNonAssocSemiring.toMul.{u1} F (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} F (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} K (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} F (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} K (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2))))) F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} F K (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_2)))))))) f))\nCase conversion may be inaccurate. Consider using '#align range.is_subfield Range.isSubfieldₓ'. -/\ntheorem Range.isSubfield {K : Type _} [Field K] (f : F →+* K) : IsSubfield (Set.range f) :=\n  by\n  rw [← Set.image_univ]\n  apply Image.isSubfield _ Univ.isSubfield\n#align range.is_subfield Range.isSubfield\n\nnamespace Field\n\n#print Field.closure /-\n/-- `field.closure s` is the minimal subfield that includes `s`. -/\ndef closure : Set F :=\n  { x | ∃ y ∈ Ring.closure S, ∃ z ∈ Ring.closure S, y / z = x }\n#align field.closure Field.closure\n-/\n\nvariable {S}\n\n#print Field.ring_closure_subset /-\ntheorem ring_closure_subset : Ring.closure S ⊆ closure S := fun x hx =>\n  ⟨x, hx, 1, Ring.closure.isSubring.to_isSubmonoid.one_mem, div_one x⟩\n#align field.ring_closure_subset Field.ring_closure_subset\n-/\n\n/- warning: field.closure.is_submonoid -> Field.closure.isSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {S : Set.{u1} F}, IsSubmonoid.{u1} F (Ring.toMonoid.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_1))) (Field.closure.{u1} F _inst_1 S)\nbut is expected to have type\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {S : Set.{u1} F}, IsSubmonoid.{u1} F (MonoidWithZero.toMonoid.{u1} F (Semiring.toMonoidWithZero.{u1} F (DivisionSemiring.toSemiring.{u1} F (Semifield.toDivisionSemiring.{u1} F (Field.toSemifield.{u1} F _inst_1))))) (Field.closure.{u1} F _inst_1 S)\nCase conversion may be inaccurate. Consider using '#align field.closure.is_submonoid Field.closure.isSubmonoidₓ'. -/\ntheorem closure.isSubmonoid : IsSubmonoid (closure S) :=\n  { mul_mem := by\n      rintro _ _ ⟨p, hp, q, hq, hq0, rfl⟩ ⟨r, hr, s, hs, hs0, rfl⟩ <;>\n        exact\n          ⟨p * r, IsSubmonoid.mul_mem ring.closure.is_subring.to_is_submonoid hp hr, q * s,\n            IsSubmonoid.mul_mem ring.closure.is_subring.to_is_submonoid hq hs,\n            (div_mul_div_comm _ _ _ _).symm⟩\n    one_mem := ring_closure_subset <| IsSubmonoid.one_mem Ring.closure.isSubring.to_isSubmonoid }\n#align field.closure.is_submonoid Field.closure.isSubmonoid\n\n#print Field.closure.isSubfield /-\ntheorem closure.isSubfield : IsSubfield (closure S) :=\n  have h0 : (0 : F) ∈ closure S :=\n    ring_closure_subset <| Ring.closure.isSubring.to_isAddSubgroup.to_isAddSubmonoid.zero_mem\n  {\n    closure.isSubmonoid with\n    add_mem := by\n      intro a b ha hb\n      rcases id ha with ⟨p, hp, q, hq, rfl⟩\n      rcases id hb with ⟨r, hr, s, hs, rfl⟩\n      classical\n        by_cases hq0 : q = 0\n        · simp [hb, hq0]\n        by_cases hs0 : s = 0\n        · simp [ha, hs0]\n        exact\n          ⟨p * s + q * r,\n            IsAddSubmonoid.add_mem ring.closure.is_subring.to_is_add_subgroup.to_is_add_submonoid\n              (ring.closure.is_subring.to_is_submonoid.mul_mem hp hs)\n              (ring.closure.is_subring.to_is_submonoid.mul_mem hq hr),\n            q * s, ring.closure.is_subring.to_is_submonoid.mul_mem hq hs,\n            (div_add_div p r hq0 hs0).symm⟩\n    zero_mem := h0\n    neg_mem := by\n      rintro _ ⟨p, hp, q, hq, rfl⟩\n      exact ⟨-p, ring.closure.is_subring.to_is_add_subgroup.neg_mem hp, q, hq, neg_div q p⟩\n    inv_mem := by\n      rintro _ ⟨p, hp, q, hq, rfl⟩\n      exact ⟨q, hq, p, hp, (inv_div _ _).symm⟩ }\n#align field.closure.is_subfield Field.closure.isSubfield\n-/\n\n#print Field.mem_closure /-\ntheorem mem_closure {a : F} (ha : a ∈ S) : a ∈ closure S :=\n  ring_closure_subset <| Ring.mem_closure ha\n#align field.mem_closure Field.mem_closure\n-/\n\n#print Field.subset_closure /-\ntheorem subset_closure : S ⊆ closure S := fun _ => mem_closure\n#align field.subset_closure Field.subset_closure\n-/\n\n#print Field.closure_subset /-\ntheorem closure_subset {T : Set F} (hT : IsSubfield T) (H : S ⊆ T) : closure S ⊆ T := by\n  rintro _ ⟨p, hp, q, hq, hq0, rfl⟩ <;>\n    exact\n      hT.div_mem (Ring.closure_subset hT.to_is_subring H hp)\n        (Ring.closure_subset hT.to_is_subring H hq)\n#align field.closure_subset Field.closure_subset\n-/\n\n#print Field.closure_subset_iff /-\ntheorem closure_subset_iff {s t : Set F} (ht : IsSubfield t) : closure s ⊆ t ↔ s ⊆ t :=\n  ⟨Set.Subset.trans subset_closure, closure_subset ht⟩\n#align field.closure_subset_iff Field.closure_subset_iff\n-/\n\n#print Field.closure_mono /-\ntheorem closure_mono {s t : Set F} (H : s ⊆ t) : closure s ⊆ closure t :=\n  closure_subset closure.isSubfield <| Set.Subset.trans H subset_closure\n#align field.closure_mono Field.closure_mono\n-/\n\nend Field\n\n#print isSubfield_unionᵢ_of_directed /-\ntheorem isSubfield_unionᵢ_of_directed {ι : Type _} [hι : Nonempty ι] {s : ι → Set F}\n    (hs : ∀ i, IsSubfield (s i)) (directed : ∀ i j, ∃ k, s i ⊆ s k ∧ s j ⊆ s k) :\n    IsSubfield (⋃ i, s i) :=\n  { inv_mem := fun x hx =>\n      let ⟨i, hi⟩ := Set.mem_unionᵢ.1 hx\n      Set.mem_unionᵢ.2 ⟨i, (hs i).inv_mem hi⟩\n    to_isSubring := isSubring_unionᵢ_of_directed (fun i => (hs i).to_isSubring) Directed }\n#align is_subfield_Union_of_directed isSubfield_unionᵢ_of_directed\n-/\n\n/- warning: is_subfield.inter -> IsSubfield.inter is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {S₁ : Set.{u1} F} {S₂ : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 S₁) -> (IsSubfield.{u1} F _inst_1 S₂) -> (IsSubfield.{u1} F _inst_1 (Inter.inter.{u1} (Set.{u1} F) (Set.hasInter.{u1} F) S₁ S₂))\nbut is expected to have type\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {S₁ : Set.{u1} F} {S₂ : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 S₁) -> (IsSubfield.{u1} F _inst_1 S₂) -> (IsSubfield.{u1} F _inst_1 (Inter.inter.{u1} (Set.{u1} F) (Set.instInterSet.{u1} F) S₁ S₂))\nCase conversion may be inaccurate. Consider using '#align is_subfield.inter IsSubfield.interₓ'. -/\ntheorem IsSubfield.inter {S₁ S₂ : Set F} (hS₁ : IsSubfield S₁) (hS₂ : IsSubfield S₂) :\n    IsSubfield (S₁ ∩ S₂) :=\n  { IsSubring.inter hS₁.to_isSubring hS₂.to_isSubring with\n    inv_mem := fun x hx => ⟨hS₁.inv_mem hx.1, hS₂.inv_mem hx.2⟩ }\n#align is_subfield.inter IsSubfield.inter\n\n#print IsSubfield.interᵢ /-\ntheorem IsSubfield.interᵢ {ι : Sort _} {S : ι → Set F} (h : ∀ y : ι, IsSubfield (S y)) :\n    IsSubfield (Set.interᵢ S) :=\n  { IsSubring.interᵢ fun y => (h y).to_isSubring with\n    inv_mem := fun x hx => Set.mem_interᵢ.2 fun y => (h y).inv_mem <| Set.mem_interᵢ.1 hx y }\n#align is_subfield.Inter IsSubfield.interᵢ\n-/\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Deprecated/Subfield.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708698, "lm_q2_score": 0.615087862571909, "lm_q1q2_score": 0.49998481550645424}}
{"text": "import rigid_elements.preadditive_conditions\nimport mul_subgroup.adjoin\n\nvariables {K : Type*} [field K]\n\nopen rigid_pair\n\ndef mul_subgroup.exceptional (T : mul_subgroup K) :=\n(∀ x : K, ¬ (T.rigid x ∧ T.rigid (-x)) → x ∈ T ∨ -x ∈ T) ∧ \n((-1 : K) ∈ T ∨ ∀ (x y : K), x ∈ T → y ∈ T → x + y ∈ T)\n\ntheorem rigid_pair.preadditive_of_not_exceptional\n  {T H : mul_subgroup K}\n  (rp : rigid_pair T H)\n  (H : ¬ T.exceptional) : \n  rp.preadditive :=\nbegin\n  suffices : (∃ (a : K) (ha1 : a ≠ 0) (ha2 : a ∉ T), ¬ T.rigid (-a)),\n  { obtain ⟨a,ha1,ha2,hh⟩ := this,\n    exact rp.preadditive_of_nmem_of_neg_not_rigid a ha1 ha2 hh },\n  by_contra c, push_neg at c,\n  apply H,\n  split,\n  { intros x hx, rw not_and_distrib at hx, cases hx,\n    { have hxz : x ≠ 0, \n      { dsimp [mul_subgroup.rigid] at hx, push_neg at hx, \n        obtain ⟨a,b,ha,hb,hx1,hx2,hx3⟩ := hx,\n        assumption },\n      specialize c (-x) (by simpa), \n      rw neg_neg at c,\n      right, \n      by_contra cc, apply hx, apply c cc },\n    { have hxz : x ≠ 0, \n      { dsimp [mul_subgroup.rigid] at hx, push_neg at hx, \n        obtain ⟨a,b,ha,hb,hx1,hx2,hx3⟩ := hx,\n        simpa using hx1 },\n      specialize c x hxz,\n      left,\n      by_contra cc, apply hx, apply c cc } },\n  { by_cases hn : (-1 : K) ∈ T, { left, assumption },\n    right, \n    intros x y hx hy,\n    specialize c (-1) (by simp) hn, rw neg_neg at c,\n    specialize c x y hx hy (by simp),\n    cases c,\n    { simpa using c },\n    { simpa using c } }\nend\n\n-- Claim (*) on page 458\nlemma rigid_pair.exists_preadditive_aux\n  {T H : mul_subgroup K}\n  (rp : rigid_pair T H) :\n  ∀ (a b : K), a ∈ rp.OO_m → b ∈ rp.OO_m → (1 - a * b ∉ T) →\n  (-a)⁻¹ * (1 - a * b) ∈ T :=\nbegin\n  intros a b ha hb hh,\n  have haz : (-a) ≠ 0,\n  { intro c, apply hh, rw neg_eq_zero at c, simp [c, T.one_mem] },\n  have haz' : a ≠ 0, by simpa using haz, \n  have := rp.neg a ha.1 (1+a) (1+b) ha.2 hb.2 _,\n  swap, \n  { intro c, apply hh, rw neg_eq_zero at c, simp [c, T.one_mem] },\n  cases this,\n  { exfalso, apply hh, convert this, ring },\n  convert this, field_simp, left, ring,\nend\n\nlemma rigid_pair.exists_preadditive_aux'\n  {T H : mul_subgroup K}\n  (rp : rigid_pair T H) :\n  ∀ (a b : K), a ∈ rp.OO_m → b ∈ rp.OO_m → (1 - a * b ∉ T) →\n  a * b⁻¹ ∈ T :=\nbegin\n  intros a b ha hb hh,\n  have h1 := rp.exists_preadditive_aux a b ha hb hh,\n  have h2 := rp.exists_preadditive_aux b a hb ha (by rwa mul_comm),\n  convert T.mul_mem (T.inv_mem h1) h2 using 1,\n  have : b ≠ 0,\n  { intro c, apply T.ne_zero_of_mem h2, simp [c] },\n  have : a ≠ 0, \n  { intro c, apply T.ne_zero_of_mem h1, simp [c] },\n  have : 1 - a * b ≠ 0,\n  { intro c, apply T.ne_zero_of_mem h1, simp [c] }, \n  field_simp, ring,\nend\n\nlemma rigid_pair.OO_m_mono {T H H' : mul_subgroup K}\n  (rp : rigid_pair T H) (h : H ≤ H') : \n  (rp.of_le H' h).OO_m ≤ rp.OO_m := \nbegin\n  rintros x ⟨h1,h2⟩,\n  exact ⟨λ c, h1 (h c), h2⟩,\nend\n\ntheorem rigid_pair.exists_preadditive \n  {T H : mul_subgroup K}\n  (rp : rigid_pair T H) : \n  ∃ (x : K) (hx : x ≠ 0) (hxH : x * x ∈ H),\n  (rp.of_le _ (H.le_adjoin_ne_zero x hx)).preadditive := \nbegin\n  by_cases HH : rp.preadditive,\n  { use [1, one_ne_zero], split, { rw mul_one, exact H.one_mem }, \n    convert HH,\n    exact H.adjoin_ne_zero_eq_of_mem 1 one_ne_zero H.one_mem },\n  --have HT : T.exceptional,\n  --{ by_contra c, apply HH, apply rigid_pair.preadditive_of_not_exceptional _ c },\n  rw rp.preadditive_iff at HH,\n  push_neg at HH,\n  obtain ⟨a,b,ha,hb,HH⟩ := HH,\n  have haz : a ≠ 0, \n  { intro c, apply HH, simp [c, T.one_mem] },\n  use [a, haz],\n  let rp' := rp.of_le _ (H.le_adjoin_ne_zero a haz),\n  let H' := H.adjoin_ne_zero a haz,\n  change _ ∧ rp'.preadditive,\n  let t := (-a)⁻¹ * (1 - a * b),\n  have aux1 : t ∈ T := rp.exists_preadditive_aux a b ha hb HH,\n  have haz' : (-a) ≠ 0, { simpa },\n  have h1 : 1 - a * b = (-a) * t, by { dsimp [t], field_simp, ring },\n  have h2 : a * b = 1 + a * t, \n  { rw [neg_mul] at h1, apply_fun (λ e, -e) at h1, rw neg_neg at h1, rw ← h1, ring },\n  have h3 := rp.pos a ha.1 1 t T.one_mem aux1 haz,\n  rw ← h2 at h3,\n  cases h3,\n  swap, \n  { exfalso,  \n    apply hb.1, apply rp.le, dsimp [t] at h3,\n    convert h3, field_simp, ring },\n  have hbz : b ≠ 0,\n  { intro c, apply T.ne_zero_of_mem h3, simp [c] },\n  split,\n  { apply rp.le, \n    have := rp.exists_preadditive_aux' a b ha hb HH,\n    convert T.mul_mem h3 this using 1, field_simp, ring },\n  { apply rigid_pair.preadditive_of_exists_UU _ (-a),\n    swap, { intro c, apply ha.1, rw ← neg_neg a, apply rp.le_neg c, },\n    suffices : ∀ z : K, z ∈ rp'.OO_m → 1 - a * z ∈ T ∧ 1 - a⁻¹ * z ∈ T,\n    { split,\n      { split, \n        apply rp'.neg_mem_of_mem, exact H.mem_adjoin_ne_zero_self _ _,\n        intros y hy,\n        specialize this y hy,\n        split,\n        { intro c, \n          apply hy.1, rw (show y = (-a)⁻¹ * (-a * y), by field_simp; ring),\n          apply mul_subgroup.mul_mem,\n          apply mul_subgroup.inv_mem,\n          apply rp'.neg_mem_of_mem,\n          exact H.mem_adjoin_ne_zero_self _ _,\n          exact c },\n        { convert this.1, ring } },\n      { split,\n        apply mul_subgroup.inv_mem, apply rp'.neg_mem_of_mem, \n        exact H.mem_adjoin_ne_zero_self _ _,\n        intros y hy,\n        specialize this y hy,\n        split,\n        { intro c, \n          apply hy.1, rw (show y = (-a) * ((-a)⁻¹ * y), by field_simp; ring),\n          apply mul_subgroup.mul_mem,\n          apply rp'.neg_mem_of_mem, exact H.mem_adjoin_ne_zero_self _ _,\n          exact c },\n        { convert this.2, rw [inv_neg], ring } } },\n    intros z hz,\n    by_cases hzz : z = 0, { simp [hzz, T.one_mem] },\n    split,\n    { by_contra c,\n      have := rp.exists_preadditive_aux' a z ha (rp.OO_m_mono _ hz) c,\n      apply hz.1, replace this := rp'.le this,\n      convert H'.mul_mem (H.mem_adjoin_ne_zero_self a haz) (H'.inv_mem this),\n      field_simp, ring },\n    have hh : 1 - b * z ∈ T,\n    { by_contra c, \n      have := rp.exists_preadditive_aux' b z hb (rp.OO_m_mono _ hz) c,\n      apply hz.1, replace this := rp'.le this,\n      convert H'.mul_mem (_ : b ∈ H') (H'.inv_mem this),\n      field_simp, ring,\n      { suffices : a * b ∈ H',\n        { convert H'.mul_mem this (H'.inv_mem (H.mem_adjoin_ne_zero_self a haz)), \n          field_simp, ring }, \n        apply rp'.le, exact h3 } },\n    by_contra c, apply hz.1,\n    have c' : ((-a) * z⁻¹)⁻¹ ∉ rp'.OO_m, \n    { dsimp [rigid_pair.OO_m], push_neg, intro _, convert c, field_simp, ring },\n    rw ← rp'.OO_m_mem_iff_inv_nmem at c',\n    have e1 := rp.exists_preadditive_aux (-a * z⁻¹) (-b * z) (rp.OO_m_mono _ c') _ _,\n    have e2 := rp.exists_preadditive_aux a b ha hb HH,\n    rw ← inv_inv z, apply mul_subgroup.inv_mem,\n    apply rp'.mem_of_neg_mem, apply rp'.le,\n    have : 1 - -a * z⁻¹ * (-b * z) = (1 - a * b), by field_simp; ring, rw this at e1, clear this,\n    convert T.mul_mem e2 (T.inv_mem e1), \n    rw [mul_inv, mul_comm, mul_assoc, \n      mul_comm _ (1 - a * b), ← mul_assoc _ (1 - a * b), inv_mul_cancel], \n    field_simp, ring,\n    { intro c, apply T.ne_zero_of_mem e2, simp [c] },\n    { apply rp.OO_m_mono (H.le_adjoin_ne_zero a haz),\n      split, \n      { intro c, apply hz.1, \n        convert H'.mul_mem c (H'.inv_mem (_ : -b ∈ H')), \n        have : -b ≠ 0, by simpa,\n        field_simp, ring,\n        apply rp'.neg_mem_of_mem,\n        have : b * a⁻¹ ∈ H', \n        { apply rp'.le,\n          apply rp.exists_preadditive_aux' b a hb ha (by rwa mul_comm) },\n        convert H'.mul_mem this (H.mem_adjoin_ne_zero_self _ _), field_simp }, \n      { convert hh, ring } },\n    { convert HH using 2, field_simp, ring },\n    { simp only [ne.def, neg_eq_zero, mul_eq_zero, inv_eq_zero], push_neg, \n      exact ⟨haz, hzz⟩ },\n    { intro c, apply hz.1, \n      convert H'.mul_mem (H'.inv_mem c) (_ : (-a) ∈ H'), field_simp,\n      apply rp'.neg_mem_of_mem, exact H.mem_adjoin_ne_zero_self _ _ } }\nend", "meta": {"author": "adamtopaz", "repo": "lean-acl-pairs", "sha": "6ac31d86ca2739b6c18d3f05b7007e720f66299f", "save_path": "github-repos/lean/adamtopaz-lean-acl-pairs", "path": "github-repos/lean/adamtopaz-lean-acl-pairs/lean-acl-pairs-6ac31d86ca2739b6c18d3f05b7007e720f66299f/src/rigid_elements/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4999848153478098}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.metric_space.isometry\nimport Mathlib.PostPort\n\nuniverses u_6 u_7 u_8 l u_1 u_2 u_3 u_4 u_5 \n\nnamespace Mathlib\n\n/-!\n# Linear isometries\n\nIn this file we define `linear_isometry R E F` (notation: `E →ₗᵢ[R] F`) to be a linear isometric\nembedding of `E` into `F` and `linear_isometry_equiv` (notation: `E ≃ₗᵢ[R] F`) to be a linear\nisometric equivalence between `E` and `F`.\n\nWe also prove some trivial lemmas and provide convenience constructors.\n-/\n\n/-- An `R`-linear isometric embedding of one normed `R`-module into another. -/\nstructure linear_isometry (R : Type u_6) (E : Type u_7) (F : Type u_8) [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] \nextends linear_map R E F\nwhere\n  norm_map' : ∀ (x : E), norm (coe_fn _to_linear_map x) = norm x\n\nnamespace linear_isometry\n\n\nprotected instance has_coe_to_fun {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] : has_coe_to_fun (linear_isometry R E F) :=\n  has_coe_to_fun.mk (fun (f : linear_isometry R E F) => E → F)\n    fun (f : linear_isometry R E F) => linear_map.to_fun (to_linear_map f)\n\n@[simp] theorem coe_to_linear_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : ⇑(to_linear_map f) = ⇑f :=\n  rfl\n\ntheorem to_linear_map_injective {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] : function.injective to_linear_map := sorry\n\ntheorem coe_fn_injective {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] : function.injective fun (f : linear_isometry R E F) (x : E) => coe_fn f x :=\n  function.injective.comp linear_map.coe_injective to_linear_map_injective\n\ntheorem ext {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] {f : linear_isometry R E F} {g : linear_isometry R E F} (h : ∀ (x : E), coe_fn f x = coe_fn g x) : f = g :=\n  coe_fn_injective (funext h)\n\n@[simp] theorem map_zero {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : coe_fn f 0 = 0 :=\n  linear_map.map_zero (to_linear_map f)\n\n@[simp] theorem map_add {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (x : E) (y : E) : coe_fn f (x + y) = coe_fn f x + coe_fn f y :=\n  linear_map.map_add (to_linear_map f) x y\n\n@[simp] theorem map_sub {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (x : E) (y : E) : coe_fn f (x - y) = coe_fn f x - coe_fn f y :=\n  linear_map.map_sub (to_linear_map f) x y\n\n@[simp] theorem map_smul {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (c : R) (x : E) : coe_fn f (c • x) = c • coe_fn f x :=\n  linear_map.map_smul (to_linear_map f) c x\n\n@[simp] theorem norm_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (x : E) : norm (coe_fn f x) = norm x :=\n  norm_map' f x\n\n@[simp] theorem nnnorm_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (x : E) : nnnorm (coe_fn f x) = nnnorm x :=\n  nnreal.eq (norm_map f x)\n\nprotected theorem isometry {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : isometry ⇑f :=\n  add_monoid_hom.isometry_of_norm (linear_map.to_add_monoid_hom (to_linear_map f)) (norm_map f)\n\n@[simp] theorem dist_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (x : E) (y : E) : dist (coe_fn f x) (coe_fn f y) = dist x y :=\n  isometry.dist_eq (linear_isometry.isometry f) x y\n\n@[simp] theorem edist_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (x : E) (y : E) : edist (coe_fn f x) (coe_fn f y) = edist x y :=\n  isometry.edist_eq (linear_isometry.isometry f) x y\n\nprotected theorem injective {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : function.injective ⇑f :=\n  isometry.injective (linear_isometry.isometry f)\n\ntheorem map_eq_iff {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) {x : E} {y : E} : coe_fn f x = coe_fn f y ↔ x = y :=\n  function.injective.eq_iff (linear_isometry.injective f)\n\ntheorem map_ne {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) {x : E} {y : E} (h : x ≠ y) : coe_fn f x ≠ coe_fn f y :=\n  function.injective.ne (linear_isometry.injective f) h\n\nprotected theorem lipschitz {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : lipschitz_with 1 ⇑f :=\n  isometry.lipschitz (linear_isometry.isometry f)\n\nprotected theorem antilipschitz {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : antilipschitz_with 1 ⇑f :=\n  isometry.antilipschitz (linear_isometry.isometry f)\n\nprotected theorem continuous {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : continuous ⇑f :=\n  isometry.continuous (linear_isometry.isometry f)\n\ntheorem ediam_image {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (s : set E) : emetric.diam (⇑f '' s) = emetric.diam s :=\n  isometry.ediam_image (linear_isometry.isometry f) s\n\ntheorem ediam_range {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : emetric.diam (set.range ⇑f) = emetric.diam set.univ :=\n  isometry.ediam_range (linear_isometry.isometry f)\n\ntheorem diam_image {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) (s : set E) : metric.diam (⇑f '' s) = metric.diam s :=\n  isometry.diam_image (linear_isometry.isometry f) s\n\ntheorem diam_range {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : metric.diam (set.range ⇑f) = metric.diam set.univ :=\n  isometry.diam_range (linear_isometry.isometry f)\n\n/-- Interpret a linear isometry as a continuous linear map. -/\ndef to_continuous_linear_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : continuous_linear_map R E F :=\n  continuous_linear_map.mk (to_linear_map f)\n\n@[simp] theorem coe_to_continuous_linear_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : ⇑(to_continuous_linear_map f) = ⇑f :=\n  rfl\n\n@[simp] theorem comp_continuous_iff {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) {α : Type u_4} [topological_space α] {g : α → E} : continuous (⇑f ∘ g) ↔ continuous g := sorry\n\n/-- The identity linear isometry. -/\ndef id {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : linear_isometry R E E :=\n  mk linear_map.id sorry\n\n@[simp] theorem coe_id {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : ⇑id = ⇑id :=\n  rfl\n\nprotected instance inhabited {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : Inhabited (linear_isometry R E E) :=\n  { default := id }\n\n/-- Composition of linear isometries. -/\ndef comp {R : Type u_1} {E : Type u_2} {F : Type u_3} {G : Type u_4} [semiring R] [normed_group E] [normed_group F] [normed_group G] [semimodule R E] [semimodule R F] [semimodule R G] (g : linear_isometry R F G) (f : linear_isometry R E F) : linear_isometry R E G :=\n  mk (linear_map.comp (to_linear_map g) (to_linear_map f)) sorry\n\n@[simp] theorem coe_comp {R : Type u_1} {E : Type u_2} {F : Type u_3} {G : Type u_4} [semiring R] [normed_group E] [normed_group F] [normed_group G] [semimodule R E] [semimodule R F] [semimodule R G] (g : linear_isometry R F G) (f : linear_isometry R E F) : ⇑(comp g f) = ⇑g ∘ ⇑f :=\n  rfl\n\n@[simp] theorem id_comp {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : comp id f = f :=\n  ext fun (x : E) => rfl\n\n@[simp] theorem comp_id {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (f : linear_isometry R E F) : comp f id = f :=\n  ext fun (x : E) => rfl\n\ntheorem comp_assoc {R : Type u_1} {E : Type u_2} {F : Type u_3} {G : Type u_4} {G' : Type u_5} [semiring R] [normed_group E] [normed_group F] [normed_group G] [normed_group G'] [semimodule R E] [semimodule R F] [semimodule R G] [semimodule R G'] (f : linear_isometry R G G') (g : linear_isometry R F G) (h : linear_isometry R E F) : comp (comp f g) h = comp f (comp g h) :=\n  rfl\n\nprotected instance monoid {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : monoid (linear_isometry R E E) :=\n  monoid.mk comp comp_assoc id id_comp comp_id\n\n@[simp] theorem coe_one {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : ⇑1 = ⇑id :=\n  rfl\n\n@[simp] theorem coe_mul {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] (f : linear_isometry R E E) (g : linear_isometry R E E) : ⇑(f * g) = ⇑f ∘ ⇑g :=\n  rfl\n\nend linear_isometry\n\n\n/-- A linear isometric equivalence between two normed vector spaces. -/\nstructure linear_isometry_equiv (R : Type u_6) (E : Type u_7) (F : Type u_8) [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] \nextends linear_equiv R E F\nwhere\n  norm_map' : ∀ (x : E), norm (coe_fn _to_linear_equiv x) = norm x\n\nnamespace linear_isometry_equiv\n\n\nprotected instance has_coe_to_fun {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] : has_coe_to_fun (linear_isometry_equiv R E F) :=\n  has_coe_to_fun.mk (fun (f : linear_isometry_equiv R E F) => E → F)\n    fun (f : linear_isometry_equiv R E F) => linear_equiv.to_fun (to_linear_equiv f)\n\n@[simp] theorem coe_mk {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_equiv R E F) (he : ∀ (x : E), norm (coe_fn e x) = norm x) : ⇑(mk e he) = ⇑e :=\n  rfl\n\n@[simp] theorem coe_to_linear_equiv {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : ⇑(to_linear_equiv e) = ⇑e :=\n  rfl\n\ntheorem to_linear_equiv_injective {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] : function.injective to_linear_equiv := sorry\n\ntheorem ext {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] {e : linear_isometry_equiv R E F} {e' : linear_isometry_equiv R E F} (h : ∀ (x : E), coe_fn e x = coe_fn e' x) : e = e' :=\n  to_linear_equiv_injective (linear_equiv.ext h)\n\n/-- Construct a `linear_isometry_equiv` from a `linear_equiv` and two inequalities:\n`∀ x, ∥e x∥ ≤ ∥x∥` and `∀ y, ∥e.symm y∥ ≤ ∥y∥`. -/\ndef of_bounds {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_equiv R E F) (h₁ : ∀ (x : E), norm (coe_fn e x) ≤ norm x) (h₂ : ∀ (y : F), norm (coe_fn (linear_equiv.symm e) y) ≤ norm y) : linear_isometry_equiv R E F :=\n  mk e sorry\n\n@[simp] theorem norm_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : E) : norm (coe_fn e x) = norm x :=\n  norm_map' e x\n\n/-- Reinterpret a `linear_isometry_equiv` as a `linear_isometry`. -/\ndef to_linear_isometry {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : linear_isometry R E F :=\n  linear_isometry.mk (↑(to_linear_equiv e)) (norm_map' e)\n\nprotected theorem isometry {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : isometry ⇑e :=\n  linear_isometry.isometry (to_linear_isometry e)\n\n/-- Reinterpret a `linear_isometry_equiv` as an `isometric`. -/\ndef to_isometric {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : E ≃ᵢ F :=\n  isometric.mk (linear_equiv.to_equiv (to_linear_equiv e)) (linear_isometry_equiv.isometry e)\n\nprotected theorem continuous {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : continuous ⇑e :=\n  isometry.continuous (linear_isometry_equiv.isometry e)\n\n/-- Identity map as a `linear_isometry_equiv`. -/\ndef refl (R : Type u_1) (E : Type u_2) [semiring R] [normed_group E] [semimodule R E] : linear_isometry_equiv R E E :=\n  mk (linear_equiv.refl R E) sorry\n\nprotected instance inhabited {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : Inhabited (linear_isometry_equiv R E E) :=\n  { default := refl R E }\n\n@[simp] theorem coe_refl {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : ⇑(refl R E) = id :=\n  rfl\n\n/-- The inverse `linear_isometry_equiv`. -/\ndef symm {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : linear_isometry_equiv R F E :=\n  mk (linear_equiv.symm (to_linear_equiv e)) sorry\n\n@[simp] theorem apply_symm_apply {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : F) : coe_fn e (coe_fn (symm e) x) = x :=\n  linear_equiv.apply_symm_apply (to_linear_equiv e) x\n\n@[simp] theorem symm_apply_apply {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : E) : coe_fn (symm e) (coe_fn e x) = x :=\n  linear_equiv.symm_apply_apply (to_linear_equiv e) x\n\n@[simp] theorem map_eq_zero_iff {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) {x : E} : coe_fn e x = 0 ↔ x = 0 :=\n  linear_equiv.map_eq_zero_iff (to_linear_equiv e)\n\n@[simp] theorem symm_symm {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : symm (symm e) = e :=\n  ext fun (x : E) => rfl\n\n@[simp] theorem coe_symm_to_linear_equiv {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : ⇑(linear_equiv.symm (to_linear_equiv e)) = ⇑(symm e) :=\n  rfl\n\n/-- Composition of `linear_isometry_equiv`s as a `linear_isometry_equiv`. -/\ndef trans {R : Type u_1} {E : Type u_2} {F : Type u_3} {G : Type u_4} [semiring R] [normed_group E] [normed_group F] [normed_group G] [semimodule R E] [semimodule R F] [semimodule R G] (e : linear_isometry_equiv R E F) (e' : linear_isometry_equiv R F G) : linear_isometry_equiv R E G :=\n  mk (linear_equiv.trans (to_linear_equiv e) (to_linear_equiv e')) sorry\n\n@[simp] theorem coe_trans {R : Type u_1} {E : Type u_2} {F : Type u_3} {G : Type u_4} [semiring R] [normed_group E] [normed_group F] [normed_group G] [semimodule R E] [semimodule R F] [semimodule R G] (e₁ : linear_isometry_equiv R E F) (e₂ : linear_isometry_equiv R F G) : ⇑(trans e₁ e₂) = ⇑e₂ ∘ ⇑e₁ :=\n  rfl\n\n@[simp] theorem trans_refl {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : trans e (refl R F) = e :=\n  ext fun (x : E) => rfl\n\n@[simp] theorem refl_trans {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : trans (refl R E) e = e :=\n  ext fun (x : E) => rfl\n\n@[simp] theorem trans_symm {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : trans e (symm e) = refl R E :=\n  ext (symm_apply_apply e)\n\n@[simp] theorem symm_trans {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : trans (symm e) e = refl R F :=\n  ext (apply_symm_apply e)\n\n@[simp] theorem coe_symm_trans {R : Type u_1} {E : Type u_2} {F : Type u_3} {G : Type u_4} [semiring R] [normed_group E] [normed_group F] [normed_group G] [semimodule R E] [semimodule R F] [semimodule R G] (e₁ : linear_isometry_equiv R E F) (e₂ : linear_isometry_equiv R F G) : ⇑(symm (trans e₁ e₂)) = ⇑(symm e₁) ∘ ⇑(symm e₂) :=\n  rfl\n\ntheorem trans_assoc {R : Type u_1} {E : Type u_2} {F : Type u_3} {G : Type u_4} {G' : Type u_5} [semiring R] [normed_group E] [normed_group F] [normed_group G] [normed_group G'] [semimodule R E] [semimodule R F] [semimodule R G] [semimodule R G'] (eEF : linear_isometry_equiv R E F) (eFG : linear_isometry_equiv R F G) (eGG' : linear_isometry_equiv R G G') : trans eEF (trans eFG eGG') = trans (trans eEF eFG) eGG' :=\n  rfl\n\nprotected instance group {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : group (linear_isometry_equiv R E E) :=\n  group.mk (fun (e₁ e₂ : linear_isometry_equiv R E E) => trans e₂ e₁) sorry (refl R E) trans_refl refl_trans symm\n    (div_inv_monoid.div._default (fun (e₁ e₂ : linear_isometry_equiv R E E) => trans e₂ e₁) sorry (refl R E) trans_refl\n      refl_trans symm)\n    trans_symm\n\n@[simp] theorem coe_one {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] : ⇑1 = id :=\n  rfl\n\n@[simp] theorem coe_mul {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] (e : linear_isometry_equiv R E E) (e' : linear_isometry_equiv R E E) : ⇑(e * e') = ⇑e ∘ ⇑e' :=\n  rfl\n\n@[simp] theorem coe_inv {R : Type u_1} {E : Type u_2} [semiring R] [normed_group E] [semimodule R E] (e : linear_isometry_equiv R E E) : ⇑(e⁻¹) = ⇑(symm e) :=\n  rfl\n\n/-- Reinterpret a `linear_isometry_equiv` as a `continuous_linear_equiv`. -/\ndef to_continuous_linear_equiv {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : continuous_linear_equiv R E F :=\n  continuous_linear_equiv.mk (to_linear_equiv e)\n\n@[simp] theorem map_zero {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : coe_fn e 0 = 0 :=\n  linear_equiv.map_zero (to_linear_equiv e)\n\n@[simp] theorem map_add {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : E) (y : E) : coe_fn e (x + y) = coe_fn e x + coe_fn e y :=\n  linear_equiv.map_add (to_linear_equiv e) x y\n\n@[simp] theorem map_sub {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : E) (y : E) : coe_fn e (x - y) = coe_fn e x - coe_fn e y :=\n  linear_equiv.map_sub (to_linear_equiv e) x y\n\n@[simp] theorem map_smul {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (c : R) (x : E) : coe_fn e (c • x) = c • coe_fn e x :=\n  linear_equiv.map_smul (to_linear_equiv e) c x\n\n@[simp] theorem nnnorm_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : E) : nnnorm (coe_fn e x) = nnnorm x :=\n  linear_isometry.nnnorm_map (to_linear_isometry e) x\n\n@[simp] theorem dist_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : E) (y : E) : dist (coe_fn e x) (coe_fn e y) = dist x y :=\n  linear_isometry.dist_map (to_linear_isometry e) x y\n\n@[simp] theorem edist_map {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (x : E) (y : E) : edist (coe_fn e x) (coe_fn e y) = edist x y :=\n  linear_isometry.edist_map (to_linear_isometry e) x y\n\nprotected theorem bijective {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : function.bijective ⇑e :=\n  linear_equiv.bijective (to_linear_equiv e)\n\nprotected theorem injective {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : function.injective ⇑e :=\n  linear_equiv.injective (to_linear_equiv e)\n\nprotected theorem surjective {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : function.surjective ⇑e :=\n  linear_equiv.surjective (to_linear_equiv e)\n\ntheorem map_eq_iff {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) {x : E} {y : E} : coe_fn e x = coe_fn e y ↔ x = y :=\n  function.injective.eq_iff (linear_isometry_equiv.injective e)\n\ntheorem map_ne {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) {x : E} {y : E} (h : x ≠ y) : coe_fn e x ≠ coe_fn e y :=\n  function.injective.ne (linear_isometry_equiv.injective e) h\n\nprotected theorem lipschitz {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : lipschitz_with 1 ⇑e :=\n  isometry.lipschitz (linear_isometry_equiv.isometry e)\n\nprotected theorem antilipschitz {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) : antilipschitz_with 1 ⇑e :=\n  isometry.antilipschitz (linear_isometry_equiv.isometry e)\n\ntheorem ediam_image {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (s : set E) : emetric.diam (⇑e '' s) = emetric.diam s :=\n  isometry.ediam_image (linear_isometry_equiv.isometry e) s\n\ntheorem diam_image {R : Type u_1} {E : Type u_2} {F : Type u_3} [semiring R] [normed_group E] [normed_group F] [semimodule R E] [semimodule R F] (e : linear_isometry_equiv R E F) (s : set E) : metric.diam (⇑e '' s) = metric.diam s :=\n  isometry.diam_image (linear_isometry_equiv.isometry e) s\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/linear_isometry.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738057795402, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4999430299843809}}
{"text": "import data.int.interval\nimport data.finset.nat_antidiagonal\nimport laurent_measures.aux_lemmas\nimport laurent_measures.basic\nimport laurent_measures.theta\nimport linear_algebra.basic\nimport order.filter.at_top_bot tactic.linarith\nimport for_mathlib.nnreal\n\n/-!\nThis file introduces the maps\n* `θ`, which is the specialization of evaluation-at-ξ map `ϑ` from `laurent_measures.theta`\n  at `ξ=2⁻¹`.\n* `ϕ` which corresponds to multiplying a Laurent series in `ℒ S = (laurent_measures r S)`\n  for `r = 2^(1/p)` by `T⁻¹-2`.\n* `ψ` corresponds to dividing a Laurent series by `(T⁻¹-2)`. It is defined only on series\n  vanishing at `2⁻¹`, so that it again takes values in `ℒ S`\n* The maps `Θ`, `Φ` and `Ψ` are the \"measurifications\" of `θ`, `ϕ` and `ψ`,\n  so they are morphisms in the right category (**[FAE]** Not here any more!)\n\nThe main results are\n* `injective_ϕ` stating that `ϕ` is injective;\n* `θ_ϕ_complex` stating that `ϕ ∘ θ = 0`; and\n* `θ_ϕ_exact` stating that the kernel of `θ` coincides with the image of `ϕ`.\nTogether with `ϑ_surjective` from `laurent_measures.theta` (specialized at `ξ=2⁻¹`, so that `ϑ` is\n`θ`) this is the statement of Theorem 6.9 of `Analytic.pdf` of interest to us, although only \"on\nelements\" and not yet as a Short Exact Sequence in the right category.\n-/\n\nnoncomputable theory\n\nopen nnreal theta laurent_measures aux_thm69 finset\nopen_locale nnreal classical big_operators topological_space\n\nsection phi\n\nparameter {r : ℝ≥0}\n\nlocal notation `ℒ` := laurent_measures r\nvariables [fact (0 < r)]\nvariable {S : Fintype}\n\ndef ϕ : ℒ S → ℒ S :=\nλ F, shift (1) F - 2 • F\n\nlemma ϕ_apply (F : ℒ S) (s : S) (n : ℤ) : ϕ F s n = F s (n+1) - 2 * F s n :=\nby simp only [ϕ, sub_apply, nsmul_apply, shift_to_fun_to_fun, nsmul_eq_mul]; refl\n\nlemma ϕ_natural (S T : Fintype) (f : S ⟶ T) : --[fact (0 < p)] [fact ( p ≤ 1)] :\n  ϕ ∘ laurent_measures.map_hom f = laurent_measures.map_hom f ∘ ϕ :=\nbegin\n  ext F t n,\n  simp only [ϕ, sum_sub_distrib, mul_sum, function.comp_app, map_hom_to_fun, sub_apply,\n    nsmul_apply, shift_to_fun_to_fun,\n    map_apply, nsmul_eq_mul, mul_ite, mul_zero], -- squeezed for time\nend\n\n-- #check @ϕ\n\n-- lemma tsum_reindex (F : ℒ S) (N : ℤ) (s : S) : ∑' (l : ℕ), (F s (N + l) : ℝ) * (2 ^ l)⁻¹ =\n--  2 ^ N * ∑' (m : {m : ℤ // N ≤ m}), (F s m : ℝ) * (2 ^ m.1)⁻¹ :=\n-- begin\n--   have h_shift := int_tsum_shift (λ n, (F s n : ℝ) * (2 ^ (-n))) N,\n--   simp only at h_shift,\n--   simp_rw [subtype.val_eq_coe, ← zpow_neg],\n--   rw [← h_shift, ← _root_.tsum_mul_left, tsum_congr],\n--   intro n,\n--   rw [mul_comm (_ ^ N), mul_assoc, ← (zpow_add₀ (@two_ne_zero ℝ _ _)), neg_add_rev,\n--     neg_add_cancel_comm, zpow_neg, zpow_coe_nat, add_comm],\n-- end\n\nvariable [fact (r < 1)]\n\nlemma injective_ϕ (F : ℒ S) (H : ϕ F = 0) : F = 0 :=\nbegin\n  dsimp only [ϕ] at H, rw [sub_eq_zero] at H,\n  replace H : ∀ n : ℤ, ∀ s : S, 2 * F s (n - 1) = F s n,\n  { intros n s,\n    rw laurent_measures.ext_iff at H,\n    convert (H s (n-1)).symm using 1,\n    { rw [two_smul, two_mul], refl, },\n    { simp [shift] } },\n  ext s n,\n  apply int.induction_on' n (F.d - 1),\n  { refine lt_d_eq_zero _ _ (F.d - 1) _,\n    simp only [sub_lt_self_iff, zero_lt_one], },\n  { intros k h hk₀,\n    simp [← H (k + 1) s, add_sub_cancel, hk₀, mul_zero] },\n  { intros k h hk₀,\n    simpa only [hk₀, mul_eq_zero, bit0_eq_zero, one_ne_zero, false_or, zero_apply] using H k s }\nend\n\nlemma injective_ϕ' : function.injective (ϕ : ℒ S → ℒ S) :=\nbegin\n  let PHI : comphaus_filtered_pseudo_normed_group_hom (ℒ S) (ℒ S) :=\n    shift (1) - 2 • comphaus_filtered_pseudo_normed_group_hom.id,\n  apply (injective_iff_map_eq_zero (PHI.to_add_monoid_hom)).mpr,\n  exact injective_ϕ\nend\n\nend phi\n\nsection mem_exact\n\nparameter {p : ℝ≥0}\n\n/-- `r`, or `r(p)`, is `2⁻ᵖ`. -/\ndef r : ℝ≥0 := 2⁻¹ ^ (p : ℝ)\n\nlemma r_pos : 0 < r :=\nsuffices 0 < (2 : ℝ≥0)⁻¹ ^ (p : ℝ), by simpa [r],\nrpow_pos (nnreal.inv_pos.mpr zero_lt_two)\n\ninstance r_pos' : fact (0 < r) := ⟨r_pos⟩\n\nlemma r_coe : (2⁻¹ : ℝ) ^ (p : ℝ) = r :=\nbegin\n  have : (2⁻¹ : ℝ) = ((2⁻¹ : ℝ≥0) : ℝ),\n  simp only [one_div, nonneg.coe_inv, nnreal.coe_bit0, nonneg.coe_one],\n  rw [this, ← nnreal.coe_rpow, nnreal.coe_eq],\n  refl,\nend\n\nvariable [fact(0 < p)]\n\nlemma r_lt_one : r < 1 :=\nbegin\n  refine rpow_lt_one nnreal.two_inv_lt_one _,\n  rw nnreal.coe_pos,\n  exact fact.out _\nend\n\ninstance r_lt_one' : fact (r < 1) := ⟨r_lt_one⟩\n\nvariable {S : Fintype}\n\nlocal notation `ℒ` := laurent_measures r\nlocal notation `ℳ` := real_measures p\n\ntheorem nnreal.rpow_int_cast (x : nnreal) (n : ℤ) : x ^ (n : ℝ) = x ^ n :=\nbegin\n  apply subtype.ext,\n  simp,\nend\n\ndef θ : ℒ S → ℳ S := ϑ 2⁻¹ r p S\n\nlemma θ_natural [fact (0 < p)] [fact (p ≤ 1)] (S T : Fintype) (f : S ⟶ T) (F : ℒ S) (t : T) :\n  θ (map f F) t = real_measures.map f (θ F) t :=\nbegin\n  simp only [θ, ϑ, one_div, map_apply, int.cast_sum, inv_zpow', zpow_neg, real_measures.map_apply],\n  rw ← tsum_sum,\n  { congr', ext n, exact sum_mul, },\n  intros,\n  rw mem_filter at H,\n  rcases H with ⟨-, rfl⟩,\n  have := F.summable i,\n  refine summable.add_compl (_ : summable (_ ∘ (coe : {n : ℤ | 0 ≤ n} → ℤ))) _,\n  { have moo := summable.comp_injective this\n      (subtype.coe_injective : function.injective (coe : {n : ℤ | 0 ≤ n} → ℤ)),\n    refine summable_of_norm_bounded _ (moo) _, clear moo this,\n    rintro ⟨n, (hn : 0 ≤ n)⟩,\n    simp only [function.comp_app, subtype.coe_mk, norm_mul, norm_inv, norm_zpow, real.norm_two],\n    rw (F i n).norm_cast_real,\n    apply mul_le_mul_of_nonneg_left _ (norm_nonneg _),\n    delta r,\n    delta r,\n    rw (by push_cast : ((2 : ℝ) ^ n)⁻¹ = ((2 ^ n)⁻¹ : nnreal)),\n    norm_cast,\n    rw [← nnreal.rpow_int_cast, ← inv_rpow],\n    rw nnreal.rpow_int_cast,\n    set m := n.nat_abs with hm,\n    have hmn : n = m := by { rw hm, exact int.eq_nat_abs_of_zero_le hn },\n    rw hmn,\n    norm_cast,\n    apply pow_le_pow_of_le_left', clear hn hmn hm m n,\n    apply nnreal.le_self_rpow' (nnreal.two_inv_lt_one.le),\n    norm_cast,\n    exact fact.out _,\n  },\n  {\n    obtain ⟨d, hd⟩ := exists_bdd_filtration (r_pos) (r_lt_one) F,\n    apply summable_of_ne_finset_zero, -- missing finset\n    swap, exact (finset.subtype _ (finset.Ico d 0)),\n    rintros ⟨z, (hz : ¬ (0 ≤ z))⟩ hz2,\n    simp only [subtype.coe_mk, mul_eq_zero, int.cast_eq_zero, inv_eq_zero],\n    left,\n    apply hd,\n    simp only [mem_subtype, subtype.coe_mk, mem_Ico, not_and, not_le] at hz2,\n    by_contra h,\n    push_neg at h,\n    apply hz,\n    specialize hz2 h,\n    push_neg at hz2,\n    exact hz2 },\nend\n\nvariables [fact (p < 1)]\n\nlemma half_lt_r : 2⁻¹ < r :=\ncalc (2⁻¹:ℝ≥0)\n    = 2⁻¹ ^ (1:ℝ) : (rpow_one (2⁻¹:ℝ≥0)).symm\n... < r : rpow_lt_rpow_of_exponent_gt (begin rw nnreal.inv_pos, norm_num, end)\n  (begin apply nnreal.inv_lt_one, norm_num end) $\n(nnreal.coe_lt_coe.mpr (fact.out _)).trans_le (nnreal.coe_one).le\n\nlemma one_lt_two_r : 1 < 2 * r :=\nbegin\n  have := half_lt_r,\n  have this2 : (2⁻¹ : ℝ) < r,\n    assumption_mod_cast,\n  rw inv_pos_lt_iff_one_lt_mul' at this2, assumption_mod_cast,\n  norm_num,\nend\n\nlemma r_inv_lt_2 : r⁻¹ < 2 :=\nbegin\n  rw ← inv_inv (2 : ℝ≥0),\n  exact nnreal.inv_lt_inv (by norm_num) half_lt_r,\nend\n\nlemma laurent_measures.summable_half (F : ℒ S) (s : S) :\n  summable (λ n, ((F s n) : ℝ) * 2⁻¹ ^ n) :=\naux_thm69.summable_smaller_radius F.d (F.summable s) (λ n hn, lt_d_eq_zero _ _ _ hn) half_lt_r\n\nlemma θ_ϕ_complex (F : ℒ S) : (θ ∘ ϕ) F = 0 :=\nbegin\n  have t0 : (2 : ℝ)⁻¹ ≠ 0 := inv_ne_zero two_ne_zero,\n  funext s,\n  convert_to ∑' (n : ℤ), ((F s (n + 1) - 2 * F s n) : ℝ) * 2⁻¹ ^ n = 0,\n  { apply tsum_congr,\n    intro b,\n    field_simp [ϕ] },\n  simp_rw [sub_mul],\n  rw [tsum_sub, sub_eq_zero],\n  -- old proof was slicker :-(\n  { refine tsum_eq_tsum_of_ne_zero_bij (λ i, (i.val : ℤ) - 1) _ _ _,\n    { rintros ⟨x, _⟩ ⟨y, _⟩ h, dsimp at *, linarith },\n    { rintros x hx,\n      refine ⟨⟨x + 1, _⟩, _⟩,\n      { rw function.mem_support at ⊢ hx,\n        convert hx using 1,\n        simp [zpow_add₀],\n        ring },\n      { simp } },\n    { rintro ⟨i, hi⟩,\n      simp [zpow_sub₀],\n      ring } },\n  { rw ← (equiv.add_group_add (-1 : ℤ)).summable_iff,\n    simp only [function.comp, one_div, inv_zpow', equiv.add_group_add_apply,\n      neg_add_cancel_comm],\n    convert summable.mul_right 2 (F.summable_half s),\n    ext x,\n    simp [zpow_add₀], ring },\n  { simp_rw [mul_assoc],\n    convert (F.summable_half s).mul_left 2 },\nend\n.\n\n/-!\n\n### Definition of ψ\n\nThis involves dividing by T⁻¹ - 2 and we have to check that this process converges.\nThe proof below is pretty icky. It's \"do some trivial rearrangements and it boils\ndown to the fact that you can interchange the order of summation in a ℝ≥0-valued\nsum of sums\"\n\n-/\n\nlemma nnreal.summable_mul_left_iff {X : Type*} {f : X → ℝ≥0} {a : ℝ≥0} (ha : a ≠ 0) :\nsummable f ↔ summable (λ (x : X), a * f x) :=\nbegin\n  rw [← nnreal.summable_coe, ← nnreal.summable_coe],\n  rw summable_mul_left_iff (by exact_mod_cast ha : (a : ℝ) ≠ 0),\n  apply summable_congr,\n  intro b,\n  norm_cast,\nend\n\nlemma psi_def_summable {S : Fintype} (n : ℕ)\n  (F : ℒ S)\n  (s : S) :\n  summable\n    (λ (k : ℕ),\n       r ^ (F.d + ↑n) *\n         (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=\nbegin\n  have := F.summable_half s,\n  apply summable.mul_left,\n  have h : (2⁻¹ : ℝ≥0) ≠ 0 := by norm_num,\n  rw nnreal.summable_mul_left_iff (show ((2⁻¹ : ℝ≥0) ^ (F.d + n) ≠ 0), from zpow_ne_zero _ h),\n  simp only [← mul_assoc, ← zpow_add₀ h],\n  have this2 := lt_d_eq_zero F s,\n  rw ← summable_norm_iff at this,\n  simp_rw ← _root_.coe_nnnorm at this,\n  rw summable_coe at this,\n  rw nnreal.summable_iff_on_nat_less_shift F.d _ (F.d + n) at this,\n  { convert this,\n    ext1 k,\n    rw mul_comm,\n    simp only [inv_zpow', neg_add_rev, nnnorm_mul, nnnorm_zpow, real.nnnorm_two],\n    congr' },\n  { intros n hn,\n    simp [this2 n hn] },\nend\n\nlemma psi_def_summable2 {S : Fintype}\n  [fact (0 < p)]\n  [fact (p < 1)]\n  (F : ℒ S)\n  (s : ↥S) :\n  ∀ (k : ℕ),\n    summable\n      (λ (n : ℕ),\n         r ^ (F.d + ↑n) *\n           ((2⁻¹ : ℝ≥0) ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=\nbegin\n  intro k,\n  have hhalf : (2⁻¹ : ℝ≥0) ≠ 0, by norm_num,\n  have hhalf' : (2⁻¹ : ℝ≥0) ≠ 0, by norm_num,\n  have hr : r ≠ 0 := r_pos.ne.symm,\n  rw nnreal.summable_mul_left_iff\n    (show (2⁻¹ : ℝ≥0) ^ (-(k : ℤ)) * r ^ (k : ℤ) ≠ 0, from mul_ne_zero (zpow_ne_zero _ hhalf') (zpow_ne_zero _ hr)),\n  have : ∀ x : ℕ, 2⁻¹ ^ -(k : ℤ) * r ^ (k : ℤ) * (r ^ (F.d + ↑x) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑x + ↑k)∥₊))\n    = r ^ (F.d + x + k) * ∥F s (F.d + ↑x + ↑k)∥₊,\n  { intro x,\n    rw (show (2⁻¹ : ℝ≥0) ^ -(k : ℤ) * r ^ (k : ℤ) * (r ^ (F.d + ↑x) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑x + ↑k)∥₊))\n      = (2⁻¹ : ℝ≥0) ^ -(k : ℤ) * 2⁻¹ ^ (k : ℤ) * r ^ (k : ℤ) * r ^ (F.d + ↑x) *  ∥F s (F.d + ↑x + ↑k)∥₊, by ring),\n    simp only [zpow_add₀ hr, ← zpow_add₀ hhalf'],\n    simp,\n    left,\n    ring,\n    },\n  rw summable_congr this, clear this,\n  have := F.summable' s,\n  rw nnreal.summable_iff_on_nat_less_shift F.d _ (F.d + k) at this,\n  { convert this,\n    ext n,\n    rw [mul_comm, add_right_comm],\n    refl },\n  { intros n hn,\n    convert zero_mul _,\n    convert nnnorm_zero,\n    exact lt_d_eq_zero F s n hn },\nend\n\nlemma psi_def_summable3 {S : Fintype}\n  [fact (0 < p)]\n  [fact (p < 1)]\n  (F : ℒ S)\n  (s : ↥S) :\n  summable\n    (λ (k : ℕ),\n       ∑' (n : ℕ),\n         r ^ (F.d + ↑n) *\n           (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=\nbegin\n  -- take 2⁻¹^k out the tsum,\n  -- put r^k into the tsum,\n  -- bounded by sum of GP,\n  have bdd : ∀ k : ℕ, ∑' (n : ℕ),\n         r ^ (F.d + ↑n + k) * ∥F s (F.d + ↑n + ↑k)∥₊ ≤\n           ∑' (t : ℤ),\n         r ^ t * ∥F s t∥₊,\n  { intro k,\n    simp_rw add_right_comm,\n    have hinj : function.injective (λ (m : ℕ), F.d + k + m),\n    { rintros a b (h2 : F.d + k + a = F.d + k + b),\n      simpa using h2 },\n      refine tsum_le_tsum_of_inj _ hinj _ _ _ _,\n      { intros, apply zero_le' },\n      { intro, refl },\n      { rw ← @nnreal.summable_iff_on_nat_less_shift (λ (z : ℤ), r ^ z * ∥F s z∥₊) F.d _ (F.d + k),\n        { convert F.summable' s,\n          ext z,\n          rw mul_comm,\n          refl },\n        { intros n hn,\n          simp [lt_d_eq_zero F s n hn] } },\n      { convert F.summable' s,\n        ext z,\n        rw mul_comm,\n        refl } },\n  have : ∀ k : ℕ, ∑' (n : ℕ), r ^ (F.d + ↑n) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊) =\n   (∑' (n : ℕ), r ^ (F.d + ↑n + k) * (∥F s (F.d + ↑n + ↑k)∥₊)) * (2⁻¹ * r⁻¹) ^ (k : ℤ),\n  { intro k,\n    rw ← nnreal.tsum_mul_right,\n    apply tsum_congr,\n    intro n,\n    simp only [zpow_add₀ r_pos.ne.symm, zpow_coe_nat, one_div, inv_pow, div_zpow],\n    have foo : (2 * r) ^ k ≠ 0,\n    { apply pow_ne_zero, apply mul_ne_zero,\n      { norm_num },\n      { exact r_pos.ne.symm },\n\n    },\n    field_simp [foo],\n    rw mul_pow,\n    ring, },\n  rw summable_congr this, clear this,\n  suffices : summable (λ k : ℕ, (∑' (t : ℤ), r ^ t * ∥F s t∥₊) * (2⁻¹ * r⁻¹) ^ k),\n  { refine summable_of_le _ this,\n    intro k,\n    rw zpow_coe_nat,\n    apply nnreal.mul_le_mul_right (bdd k),\n  },\n  apply summable.mul_left,\n  apply summable_geometric,\n  exact div_lt_one_of_lt half_lt_r,\nend\n\n\n\nlemma psi_def_aux_4 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable\n  (λ (m : ℕ),\n     ∥(2 : ℝ) ^ (F.d + ↑m)∥₊ *\n       ((∑' (k : ℕ), ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k)) * r ^ (F.d + ↑m))) :=\nbegin\n  -- tidy up\n  simp_rw [nnnorm_zpow, real.nnnorm_two],\n  have : ∀ m : ℕ, (2 : ℝ≥0) ^ (F.d + ↑m) *\n  ((∑' (k : ℕ), ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k)) * r ^ (F.d + ↑m)) =\n  ∑' (k : ℕ), (2 : ℝ≥0) ^ (F.d + ↑m) * ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k) * r ^ (F.d + ↑m),\n  { intro m,\n    rw [← nnreal.tsum_mul_right, ← nnreal.tsum_mul_left],\n    apply tsum_congr,\n    intro b,\n    ring },\n  rw summable_congr this, clear this,\n  -- TODO : maybe now is the time to tidy up a bit (e.g. cancel the 2^x and 2⁻¹^x)\n  suffices : summable\n  (λ (m : ℕ), ∑' (k : ℕ),\n       ∥F s (F.d + ↑m + ↑k)∥₊ *\n       2⁻¹ ^ (k : ℤ) * r ^ (F.d + ↑m)),\n  { refine (summable_congr _).2 this,\n    intro m,\n    apply tsum_congr,\n    intro b,\n    rw [inv_zpow , inv_zpow],\n    rw [← zpow_neg, ←zpow_neg],\n    have h2 : (2 : ℝ≥0) ≠ 0 := two_ne_zero,\n    simp only [zpow_add₀, ne.def, bit0_eq_zero, one_ne_zero, not_false_iff, zpow_coe_nat, neg_add_rev, zpow_neg,\n  mul_eq_mul_right_iff],\n    field_simp [zpow_ne_zero _ h2], left,\n    ring,\n  },\n  simp_rw [mul_comm],\n  -- change order of summation\n  apply nnreal.summable_symm,\n  -- check various things are summable\n  have := F.summable_half s,\n  { intro n,\n    apply psi_def_summable },\n  { apply psi_def_summable2 },\n  -- sum is then bounded above by a GP.\n  { apply psi_def_summable3, },\nend\n\nlemma psi_def_aux_3 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable\n  (λ (n : ℤ),\n     ∥-(2 : ℝ) ^ (n - 1)∥₊ *\n       ite (F.d ≤ n) ((∑' (k : ℕ), ∥F s (n + ↑k)∥₊ * 2⁻¹ ^ (n + ↑k)) * r ^ n) 0) :=\nbegin\n  -- get rid of factor of -2⁻¹\n  simp_rw [_root_.nnnorm_neg, zpow_sub₀ (two_ne_zero : (2 : ℝ) ≠ 0), nnnorm_div, zpow_one,\n    div_eq_mul_inv _ ∥(2 : ℝ)∥₊, mul_comm _ ∥(2 : ℝ)∥₊⁻¹, mul_assoc],\n  apply summable.mul_left,\n  have hinj : function.injective (λ (m : ℕ), F.d + m),\n  { rintros a b (h2 : F.d + a = F.d + b),\n    simpa using h2 },\n  -- change outer sum to m : ℕ with n : ℤ = F.d + m\n  suffices : summable (λ (m : ℕ),\n     ∥(2 : ℝ) ^ (F.d + m)∥₊ *\n       ((∑' (k : ℕ), ∥F s (F.d + m + ↑k)∥₊ * 2⁻¹ ^ (F.d + m + ↑k)) * r ^ (F.d + m))),\n  refine nnreal.summable_of_comp_injective hinj _ _,\n  { intros a ha,\n    rw [if_neg], simp,\n    intro hda, apply ha,\n    use (a - F.d).to_nat,\n    simp, rw int.to_nat_of_nonneg, ring, linarith },\n  { refine (summable_congr _).1 this,\n    simp },\n  exact psi_def_aux_4 F s,\nend\n\nlemma psi_def_aux_2 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable\n  (λ (n : ℤ),\n     ite (F.d ≤ n) ∥-(2 : ℝ) ^ (n - 1) * ∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k) * r ^ n∥₊ 0) :=\nbegin\n  simp_rw [nnnorm_mul],\n  -- next : put norm inside inner tsum (a one way implication)\n  suffices : summable\n  (λ (n : ℤ), ∥-(2 : ℝ) ^ (n - 1)∥₊ *\n     ite (F.d ≤ n)\n     ((∑' (k : ℕ), ∥F s (n + ↑k)∥₊ * 2⁻¹ ^ (n + ↑k)) * r ^ n)\n       0),\n  refine summable_of_le _ this,\n  { intro n,\n    split_ifs,\n    { simp only [_root_.nnnorm_neg, nnnorm_zpow, real.nnnorm_two, one_div, inv_zpow', neg_add_rev],\n      refine mul_le_mul_of_nonneg_left _ _,\n      { refine le_trans (nnnorm_tsum_le _) _,\n        { clear this, have := F.summable_half s,\n          simp_rw nnnorm_mul,\n          apply summable.mul_right,\n          rw ← summable_norm_iff at this,\n          simp_rw ← _root_.coe_nnnorm at this,\n          rw nnreal.summable_coe at this,\n          have hinj : function.injective (λ (b : ℕ), n + b),\n          { rintros a b (h2 : n + a = n + b),\n            simpa using h2 },\n            convert summable_comp_injective this hinj,\n            ext1 k,\n            simp [← zpow_neg] },\n        { rw ← nnreal.tsum_mul_right,\n          apply le_of_eq,\n          apply tsum_congr,\n          { intro k,\n            simp only [nnnorm_mul, nnnorm_zpow, real.nnnorm_two, nnnorm_eq, mul_eq_mul_right_iff],\n            left, left,\n            congr } } },\n      { simp } },\n    { simp } },\n  exact psi_def_aux_3 _ _,\nend\n\nlemma psi_def_aux {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) :\n  summable (λ (n : ℤ), ∥ite (F.d ≤ n) (-(2 : ℝ) ^ (n - 1) *\n    ∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k)) 0∥₊ * r ^ n) :=\nbegin\n  suffices :  summable (λ (n : ℤ), ite (F.d ≤ n) ∥-(2 : ℝ) ^ (n - 1) *\n    ∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k) * r ^ n∥₊ 0),\n  refine summable_of_le _ this,\n  { intro n,\n    split_ifs,\n    { apply le_of_eq,\n      simp_rw _root_.tsum_mul_right,\n      rw [ ← mul_assoc, nnnorm_mul _ ((r : ℝ) ^ n)],\n      simp },\n    { simp } },\n  exact psi_def_aux_2 _ _,\nend\n\ndef ψ (F : ℒ S) (hF : θ F = 0) : ℒ S :=\n{ to_fun := λ s n, if F.d ≤ n then\n    ∑ l in range (n - F.d).nat_abs.succ, F s (n - 1 - l) * (2 ^ l)\n    else 0,\n  summable' := λ s, begin\n    -- make everything real\n    change summable (λ (n : ℤ),\n     ∥((ite (F.d ≤ n)\n       (∑ (l : ℕ) in range (n - F.d).nat_abs.succ, F s (n - 1 - ↑l) * 2 ^ l) 0 : ℤ) : ℝ)∥₊\n     * r ^ n),\n    push_cast,\n    -- hypothesis that infinite sum converges at r>2⁻¹\n    -- get hypothesis that infinite sum is 0 at 2⁻¹\n    simp only [θ, ϑ] at hF,\n    replace hF := congr_fun hF s, dsimp at hF,\n    -- change sum from ℤ to ℕ\n    --rw nnreal.summable_iff_on_nat_less F.d, swap,\n    --{ intros n hn, simp [if_neg hn.not_le] },\n    have h1 : ∀ (n : ℤ),\n      ite (F.d ≤ n) (∑ (l : ℕ) in range (n - F.d).nat_abs.succ, (F s (n - 1 - ↑l) : ℝ) * 2 ^ l) 0 =\n      ite (F.d ≤ n) (-(2 : ℝ)^(n-1)*∑' (k : ℕ), F s (n + k) * 2⁻¹ ^ (n + k)) 0,\n    { intro n,\n      split_ifs with hn, swap, refl,\n      rw [← inv_mul_eq_iff_eq_mul₀, ← neg_inv, neg_mul, mul_sum, neg_eq_iff_add_eq_zero, ← hF],\n        swap, exact neg_ne_zero.2 (zpow_ne_zero _ two_ne_zero),\n      convert @tsum_add_tsum_compl ℝ ℤ _ _ _ _ _ {x : ℤ | x < n}\n        (summable.subtype (F.summable_half s) _) (summable.subtype (F.summable_half s) _) using 2,\n      { simp_rw [← inv_zpow, mul_comm ((2⁻¹ : ℝ)^(n-1)), mul_assoc],\n        simp_rw (show ∀ (x : ℕ), (2 : ℝ)^x = 2⁻¹^(-(x : ℤ)), by {intros, simp}),\n        simp_rw [← zpow_add₀ (by norm_num : (2⁻¹ : ℝ) ≠ 0), add_comm, ← sub_eq_add_neg],\n        rw ← tsum_eq_sum,\n        convert @equiv.tsum_eq ℝ _ _ _ _ _\n          (⟨λ m, ⟨n - 1 - m, lt_of_le_of_lt (sub_le_self _ (int.coe_zero_le m)) (sub_one_lt n)⟩,\n           (λ z, (n - 1 - z.1).nat_abs), λ m, by simp, λ ⟨z, hz⟩, subtype.ext begin\n--             squeeze_simp,\n             change n - 1 - (n - 1 - z).nat_abs = z,\n             rw ← int.eq_nat_abs_of_zero_le (sub_nonneg_of_le (int.le_sub_one_of_lt hz)),\n             ring, end⟩ : ℕ ≃ {z : ℤ // z < n}) _,\n        { ext, refl },\n        { intros b hb,\n          rw mul_eq_zero, left,\n          norm_cast,\n          apply lt_d_eq_zero,\n          by_contra h, push_neg at h, apply hb,\n          rw [mem_range, nat.succ_eq_add_one, ← int.coe_nat_lt, int.coe_nat_add,\n            ← int.eq_nat_abs_of_zero_le]; linarith } },\n      { convert @equiv.tsum_eq ℝ _ _ _ _ _\n          (⟨λ x, ⟨n + x, (int.le.intro rfl).not_lt⟩, (λ z, (z.1 - n).nat_abs),\n            λ x, by simp, λ ⟨x, hx⟩, subtype.ext begin\n              change n + _ = x,\n              rw ← int.eq_nat_abs_of_zero_le (sub_nonneg.2 (le_of_not_lt hx)),\n              exact add_eq_of_eq_sub' rfl,\n            end⟩ : ℕ ≃ {z : ℤ // ¬ z < n}) _,\n        ext, refl },\n    },\n    suffices : summable (λ (n : ℤ),\n     ∥ite (F.d ≤ n) (-(2 : ℝ)^(n-1)*∑' (k : ℕ), ↑(F s (n + k)) * 2⁻¹ ^ (n + k)) 0∥₊ *\n       r ^ n),\n    { refine (summable_congr _).2 this,\n      intro n,\n      congr' 2,\n      apply h1 n,\n    }, clear h1,\n    clear hF,\n    exact psi_def_aux F s,\n  end }\n\ntheorem θ_ϕ_split_exact (F : ℒ S) (hF : θ F = 0) : ϕ (ψ F hF) = F :=\nbegin\n  ext s n,\n  simp only [ϕ, ψ, sub_apply, shift_to_fun_to_fun, laurent_measures.coe_mk, nsmul_apply,\n    nsmul_eq_mul, int.coe_nat_succ, int.coe_nat_zero, zero_add],\n  split_ifs with h1 h2,\n  { rw [sum_range_succ', (by norm_num : (1 : ℤ) + 1 = 2), mul_sum],\n    convert add_sub_cancel' _ _,\n    { rw [nat.succ_eq_add_one, (by ring : n + 1 - F.d = n - F.d + 1)],\n      obtain ⟨m, hm⟩ := (int.eq_coe_of_zero_le (sub_nonneg.mpr h2)),\n      rw hm,\n      norm_cast },\n    { ext,\n      push_cast,\n      ring_exp,\n      congr' 2,\n      ring },\n    { simp } },\n  { have hF : F.d = n + 1, linarith,\n    simp [hF] },\n  { linarith },\n  { exact (lt_d_eq_zero F s n (not_le.mp h)).symm },\nend\n\ntheorem θ_ϕ_exact (F : ℒ S) (hF : θ F = 0) : ∃ G, ϕ G = F :=\n⟨ψ F hF, θ_ϕ_split_exact F hF⟩\n\nend mem_exact\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/laurent_measures/thm69.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4999430241191714}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta, Edward Ayers, Thomas Read. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Edward Ayers, Thomas Read\n-/\n\nimport category_theory.limits.shapes.finite_products\nimport category_theory.limits.preserves.shapes.binary_products\nimport category_theory.closed.monoidal\nimport category_theory.monoidal.of_has_finite_products\nimport category_theory.adjunction\nimport category_theory.adjunction.mates\nimport category_theory.epi_mono\n\n/-!\n# Cartesian closed categories\n\nGiven a category with finite products, the cartesian monoidal structure is provided by the local\ninstance `monoidal_of_has_finite_products`.\n\nWe define exponentiable objects to be closed objects with respect to this monoidal structure,\ni.e. `(X × -)` is a left adjoint.\n\nWe say a category is cartesian closed if every object is exponentiable\n(equivalently, that the category equipped with the cartesian monoidal structure is closed monoidal).\n\nShow that exponential forms a difunctor and define the exponential comparison morphisms.\n\n## TODO\nSome of the results here are true more generally for closed objects and\nfor closed monoidal categories, and these could be generalised.\n-/\nuniverses v u u₂\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen category_theory category_theory.category category_theory.limits\n\nlocal attribute [instance] monoidal_of_has_finite_products\n\n/--\nAn object `X` is *exponentiable* if `(X × -)` is a left adjoint.\nWe define this as being `closed` in the cartesian monoidal structure.\n-/\nabbreviation exponentiable {C : Type u} [category.{v} C] [has_finite_products C] (X : C) :=\nclosed X\n\n/--\nIf `X` and `Y` are exponentiable then `X ⨯ Y` is.\nThis isn't an instance because it's not usually how we want to construct exponentials, we'll usually\nprove all objects are exponential uniformly.\n-/\ndef binary_product_exponentiable {C : Type u} [category.{v} C] [has_finite_products C] {X Y : C}\n  (hX : exponentiable X) (hY : exponentiable Y) : exponentiable (X ⨯ Y) :=\n{ is_adj :=\n  begin\n    haveI := hX.is_adj,\n    haveI := hY.is_adj,\n    exact adjunction.left_adjoint_of_nat_iso (monoidal_category.tensor_left_tensor _ _).symm\n  end }\n\n/--\nThe terminal object is always exponentiable.\nThis isn't an instance because most of the time we'll prove cartesian closed for all objects\nat once, rather than just for this one.\n-/\ndef terminal_exponentiable {C : Type u} [category.{v} C] [has_finite_products C] :\n  exponentiable ⊤_C :=\nunit_closed\n\n/--\nA category `C` is cartesian closed if it has finite products and every object is exponentiable.\nWe define this as `monoidal_closed` with respect to the cartesian monoidal structure.\n-/\nabbreviation cartesian_closed (C : Type u) [category.{v} C] [has_finite_products C] :=\nmonoidal_closed C\n\nvariables {C : Type u} [category.{v} C] (A B : C) {X X' Y Y' Z : C}\n\nsection exp\nvariables [has_finite_products C] [exponentiable A]\n\n/-- This is (-)^A. -/\ndef exp : C ⥤ C :=\n(@closed.is_adj _ _ _ A _).right\n\n/-- The adjunction between A ⨯ - and (-)^A. -/\ndef exp.adjunction : prod.functor.obj A ⊣ exp A :=\nclosed.is_adj.adj\n\n/-- The evaluation natural transformation. -/\ndef ev : exp A ⋙ prod.functor.obj A ⟶ 𝟭 C :=\n(exp.adjunction A).counit\n\n/-- The coevaluation natural transformation. -/\ndef coev : 𝟭 C ⟶ prod.functor.obj A ⋙ exp A :=\n(exp.adjunction A).unit\n\n@[simp] lemma exp_adjunction_counit : (exp.adjunction A).counit = ev A := rfl\n@[simp] lemma exp_adjunction_unit : (exp.adjunction A).unit = coev A := rfl\n\n@[simp, reassoc]\nlemma ev_naturality {X Y : C} (f : X ⟶ Y) :\n  limits.prod.map (𝟙 A) ((exp A).map f) ≫ (ev A).app Y = (ev A).app X ≫ f :=\n(ev A).naturality f\n\n@[simp, reassoc]\nlemma coev_naturality {X Y : C} (f : X ⟶ Y) :\n  f ≫ (coev A).app Y = (coev A).app X ≫ (exp A).map (limits.prod.map (𝟙 A) f) :=\n(coev A).naturality f\n\nnotation A ` ⟹ `:20 B:20 := (exp A).obj B\nnotation B ` ^^ `:30 A:30 := (exp A).obj B\n\n@[simp, reassoc] lemma ev_coev :\n  limits.prod.map (𝟙 A) ((coev A).app B) ≫ (ev A).app (A ⨯ B) = 𝟙 (A ⨯ B) :=\nadjunction.left_triangle_components (exp.adjunction A)\n\n@[simp, reassoc] lemma coev_ev : (coev A).app (A⟹B) ≫ (exp A).map ((ev A).app B) = 𝟙 (A⟹B) :=\nadjunction.right_triangle_components (exp.adjunction A)\n\ninstance : preserves_colimits (prod.functor.obj A) :=\n(exp.adjunction A).left_adjoint_preserves_colimits\n\nend exp\n\nvariables {A}\n\n-- Wrap these in a namespace so we don't clash with the core versions.\nnamespace cartesian_closed\n\nvariables [has_finite_products C] [exponentiable A]\n\n/-- Currying in a cartesian closed category. -/\ndef curry : (A ⨯ Y ⟶ X) → (Y ⟶ A ⟹ X) :=\n(exp.adjunction A).hom_equiv _ _\n/-- Uncurrying in a cartesian closed category. -/\ndef uncurry : (Y ⟶ A ⟹ X) → (A ⨯ Y ⟶ X) :=\n((exp.adjunction A).hom_equiv _ _).symm\n\n@[simp] lemma hom_equiv_apply_eq (f : A ⨯ Y ⟶ X) :\n  (exp.adjunction A).hom_equiv _ _ f = curry f := rfl\n@[simp] lemma hom_equiv_symm_apply_eq (f : Y ⟶ A ⟹ X) :\n  ((exp.adjunction A).hom_equiv _ _).symm f = uncurry f := rfl\n\nend cartesian_closed\n\nopen cartesian_closed\n\nvariables [has_finite_products C] [exponentiable A]\n\n@[reassoc]\nlemma curry_natural_left (f : X ⟶ X') (g : A ⨯ X' ⟶ Y) :\n  curry (limits.prod.map (𝟙 _) f ≫ g) = f ≫ curry g :=\nadjunction.hom_equiv_naturality_left _ _ _\n\n@[reassoc]\nlemma curry_natural_right (f : A ⨯ X ⟶ Y) (g : Y ⟶ Y') :\n  curry (f ≫ g) = curry f ≫ (exp _).map g :=\nadjunction.hom_equiv_naturality_right _ _ _\n\n@[reassoc]\nlemma uncurry_natural_right  (f : X ⟶ A⟹Y) (g : Y ⟶ Y') :\n  uncurry (f ≫ (exp _).map g) = uncurry f ≫ g :=\nadjunction.hom_equiv_naturality_right_symm _ _ _\n\n@[reassoc]\nlemma uncurry_natural_left  (f : X ⟶ X') (g : X' ⟶ A⟹Y) :\n  uncurry (f ≫ g) = limits.prod.map (𝟙 _) f ≫ uncurry g :=\nadjunction.hom_equiv_naturality_left_symm _ _ _\n\n@[simp]\nlemma uncurry_curry (f : A ⨯ X ⟶ Y) : uncurry (curry f) = f :=\n(closed.is_adj.adj.hom_equiv _ _).left_inv f\n\n@[simp]\nlemma curry_uncurry (f : X ⟶ A⟹Y) : curry (uncurry f) = f :=\n(closed.is_adj.adj.hom_equiv _ _).right_inv f\n\nlemma curry_eq_iff (f : A ⨯ Y ⟶ X) (g : Y ⟶ A ⟹ X) :\n  curry f = g ↔ f = uncurry g :=\nadjunction.hom_equiv_apply_eq _ f g\n\nlemma eq_curry_iff (f : A ⨯ Y ⟶ X) (g : Y ⟶ A ⟹ X) :\n  g = curry f ↔ uncurry g = f :=\nadjunction.eq_hom_equiv_apply _ f g\n\n-- I don't think these two should be simp.\nlemma uncurry_eq (g : Y ⟶ A ⟹ X) : uncurry g = limits.prod.map (𝟙 A) g ≫ (ev A).app X :=\nadjunction.hom_equiv_counit _\n\nlemma curry_eq (g : A ⨯ Y ⟶ X) : curry g = (coev A).app Y ≫ (exp A).map g :=\nadjunction.hom_equiv_unit _\n\nlemma uncurry_id_eq_ev (A X : C) [exponentiable A] : uncurry (𝟙 (A ⟹ X)) = (ev A).app X :=\nby rw [uncurry_eq, prod.map_id_id, id_comp]\n\nlemma curry_id_eq_coev (A X : C) [exponentiable A] : curry (𝟙 _) = (coev A).app X :=\nby { rw [curry_eq, (exp A).map_id (A ⨯ _)], apply comp_id }\n\nlemma curry_injective : function.injective (curry : (A ⨯ Y ⟶ X) → (Y ⟶ A ⟹ X)) :=\n(closed.is_adj.adj.hom_equiv _ _).injective\n\nlemma uncurry_injective : function.injective (uncurry : (Y ⟶ A ⟹ X) → (A ⨯ Y ⟶ X)) :=\n(closed.is_adj.adj.hom_equiv _ _).symm.injective\n\n/--\nShow that the exponential of the terminal object is isomorphic to itself, i.e. `X^1 ≅ X`.\n\nThe typeclass argument is explicit: any instance can be used.\n-/\ndef exp_terminal_iso_self [exponentiable ⊤_C] : (⊤_C ⟹ X) ≅ X :=\nyoneda.ext (⊤_ C ⟹ X) X\n  (λ Y f, (prod.left_unitor Y).inv ≫ uncurry f)\n  (λ Y f, curry ((prod.left_unitor Y).hom ≫ f))\n  (λ Z g, by rw [curry_eq_iff, iso.hom_inv_id_assoc] )\n  (λ Z g, by simp)\n  (λ Z W f g, by rw [uncurry_natural_left, prod.left_unitor_inv_naturality_assoc f] )\n\n/-- The internal element which points at the given morphism. -/\ndef internalize_hom (f : A ⟶ Y) : ⊤_C ⟶ (A ⟹ Y) :=\ncurry (limits.prod.fst ≫ f)\n\nsection pre\n\nvariables {B}\n\n/-- Pre-compose an internal hom with an external hom. -/\ndef pre (f : B ⟶ A) [exponentiable B] : exp A ⟶ exp B :=\ntransfer_nat_trans_self (exp.adjunction _) (exp.adjunction _) (prod.functor.map f)\n\nlemma prod_map_pre_app_comp_ev (f : B ⟶ A) [exponentiable B] (X : C) :\n  limits.prod.map (𝟙 B) ((pre f).app X) ≫ (ev B).app X =\n    limits.prod.map f (𝟙 (A ⟹ X)) ≫ (ev A).app X :=\ntransfer_nat_trans_self_counit _ _ (prod.functor.map f) X\n\nlemma uncurry_pre (f : B ⟶ A) [exponentiable B] (X : C) :\n  uncurry ((pre f).app X) = limits.prod.map f (𝟙 _) ≫ (ev A).app X :=\nbegin\n  rw [uncurry_eq, prod_map_pre_app_comp_ev]\nend\n\nlemma coev_app_comp_pre_app (f : B ⟶ A) [exponentiable B] :\n  (coev A).app X ≫ (pre f).app (A ⨯ X) = (coev B).app X ≫ (exp B).map (limits.prod.map f (𝟙 _)) :=\nunit_transfer_nat_trans_self _ _ (prod.functor.map f) X\n\n@[simp]\nlemma pre_id (A : C) [exponentiable A] : pre (𝟙 A) = 𝟙 _ :=\nby simp [pre]\n\n@[simp]\nlemma pre_map {A₁ A₂ A₃ : C} [exponentiable A₁] [exponentiable A₂] [exponentiable A₃]\n  (f : A₁ ⟶ A₂) (g : A₂ ⟶ A₃) :\n  pre (f ≫ g) = pre g ≫ pre f :=\nby rw [pre, pre, pre, transfer_nat_trans_self_comp, prod.functor.map_comp]\n\nend pre\n\n/-- The internal hom functor given by the cartesian closed structure. -/\ndef internal_hom [cartesian_closed C] : Cᵒᵖ ⥤ C ⥤ C :=\n{ obj := λ X, exp X.unop,\n  map := λ X Y f, pre f.unop }\n\n/-- If an initial object `I` exists in a CCC, then `A ⨯ I ≅ I`. -/\n@[simps]\ndef zero_mul {I : C} (t : is_initial I) : A ⨯ I ≅ I :=\n{ hom := limits.prod.snd,\n  inv := t.to _,\n  hom_inv_id' :=\n  begin\n    have: (limits.prod.snd : A ⨯ I ⟶ I) = uncurry (t.to _),\n      rw ← curry_eq_iff,\n      apply t.hom_ext,\n    rw [this, ← uncurry_natural_right, ← eq_curry_iff],\n    apply t.hom_ext,\n  end,\n  inv_hom_id' := t.hom_ext _ _ }\n\n/-- If an initial object `0` exists in a CCC, then `0 ⨯ A ≅ 0`. -/\ndef mul_zero {I : C} (t : is_initial I) : I ⨯ A ≅ I :=\nlimits.prod.braiding _ _ ≪≫ zero_mul t\n\n/-- If an initial object `0` exists in a CCC then `0^B ≅ 1` for any `B`. -/\ndef pow_zero {I : C} (t : is_initial I) [cartesian_closed C] : I ⟹ B ≅ ⊤_ C :=\n{ hom := default _,\n  inv := curry ((mul_zero t).hom ≫ t.to _),\n  hom_inv_id' :=\n  begin\n    rw [← curry_natural_left, curry_eq_iff, ← cancel_epi (mul_zero t).inv],\n    { apply t.hom_ext },\n    { apply_instance },\n    { apply_instance }\n  end }\n\n-- TODO: Generalise the below to its commutated variants.\n-- TODO: Define a distributive category, so that zero_mul and friends can be derived from this.\n/-- In a CCC with binary coproducts, the distribution morphism is an isomorphism. -/\ndef prod_coprod_distrib [has_binary_coproducts C] [cartesian_closed C] (X Y Z : C) :\n  (Z ⨯ X) ⨿ (Z ⨯ Y) ≅ Z ⨯ (X ⨿ Y) :=\n{ hom := coprod.desc (limits.prod.map (𝟙 _) coprod.inl) (limits.prod.map (𝟙 _) coprod.inr),\n  inv := uncurry (coprod.desc (curry coprod.inl) (curry coprod.inr)),\n  hom_inv_id' :=\n  begin\n    apply coprod.hom_ext,\n    rw [coprod.inl_desc_assoc, comp_id, ←uncurry_natural_left, coprod.inl_desc, uncurry_curry],\n    rw [coprod.inr_desc_assoc, comp_id, ←uncurry_natural_left, coprod.inr_desc, uncurry_curry],\n  end,\n  inv_hom_id' :=\n  begin\n    rw [← uncurry_natural_right, ←eq_curry_iff],\n    apply coprod.hom_ext,\n    rw [coprod.inl_desc_assoc, ←curry_natural_right, coprod.inl_desc, ←curry_natural_left, comp_id],\n    rw [coprod.inr_desc_assoc, ←curry_natural_right, coprod.inr_desc, ←curry_natural_left, comp_id],\n  end }\n\n/--\nIf an initial object `I` exists in a CCC then it is a strict initial object,\ni.e. any morphism to `I` is an iso.\nThis actually shows a slightly stronger version: any morphism to an initial object from an\nexponentiable object is an isomorphism.\n-/\nlemma strict_initial {I : C} (t : is_initial I) (f : A ⟶ I) : is_iso f :=\nbegin\n  haveI : mono (limits.prod.lift (𝟙 A) f ≫ (zero_mul t).hom) := mono_comp _ _,\n  rw [zero_mul_hom, prod.lift_snd] at _inst,\n  haveI: split_epi f := ⟨t.to _, t.hom_ext _ _⟩,\n  apply is_iso_of_mono_of_split_epi\nend\n\ninstance to_initial_is_iso [has_initial C] (f : A ⟶ ⊥_ C) : is_iso f :=\nstrict_initial initial_is_initial _\n\n/-- If an initial object `0` exists in a CCC then every morphism from it is monic. -/\nlemma initial_mono {I : C} (B : C) (t : is_initial I) [cartesian_closed C] : mono (t.to B) :=\n⟨λ B g h _,\nbegin\n  haveI := strict_initial t g,\n  haveI := strict_initial t h,\n  exact eq_of_inv_eq_inv (t.hom_ext _ _)\nend⟩\n\ninstance initial.mono_to [has_initial C] (B : C) [cartesian_closed C] : mono (initial.to B) :=\ninitial_mono B initial_is_initial\n\nvariables {D : Type u₂} [category.{v} D]\nsection functor\n\nvariables [has_finite_products D]\n\n/--\nTransport the property of being cartesian closed across an equivalence of categories.\n\nNote we didn't require any coherence between the choice of finite products here, since we transport\nalong the `prod_comparison` isomorphism.\n-/\ndef cartesian_closed_of_equiv (e : C ≌ D) [h : cartesian_closed C] : cartesian_closed D :=\n{ closed := λ X,\n  { is_adj :=\n    begin\n      haveI q : exponentiable (e.inverse.obj X) := infer_instance,\n      have : is_left_adjoint (prod.functor.obj (e.inverse.obj X)) := q.is_adj,\n      have : e.functor ⋙ prod.functor.obj X ⋙ e.inverse ≅ prod.functor.obj (e.inverse.obj X),\n      apply nat_iso.of_components _ _,\n      intro Y,\n      { apply as_iso (prod_comparison e.inverse X (e.functor.obj Y)) ≪≫ _,\n        apply prod.map_iso (iso.refl _) (e.unit_iso.app Y).symm },\n      { intros Y Z g,\n        dsimp [prod_comparison],\n        simp [prod.comp_lift, ← e.inverse.map_comp, ← e.inverse.map_comp_assoc],\n          -- I wonder if it would be a good idea to make `map_comp` a simp lemma the other way round\n        dsimp, simp -- See note [dsimp, simp]\n        },\n      { have : is_left_adjoint (e.functor ⋙ prod.functor.obj X ⋙ e.inverse) :=\n          by exactI adjunction.left_adjoint_of_nat_iso this.symm,\n        have : is_left_adjoint (e.inverse ⋙ e.functor ⋙ prod.functor.obj X ⋙ e.inverse) :=\n          by exactI adjunction.left_adjoint_of_comp e.inverse _,\n        have : (e.inverse ⋙ e.functor ⋙ prod.functor.obj X ⋙ e.inverse) ⋙ e.functor ≅\n          prod.functor.obj X,\n        { apply iso_whisker_right e.counit_iso (prod.functor.obj X ⋙ e.inverse ⋙ e.functor) ≪≫ _,\n          change prod.functor.obj X ⋙ e.inverse ⋙ e.functor ≅ prod.functor.obj X,\n          apply iso_whisker_left (prod.functor.obj X) e.counit_iso, },\n        resetI,\n        apply adjunction.left_adjoint_of_nat_iso this },\n    end } }\n\nend functor\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/closed/cartesian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.721743206297598, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.49990965030315504}}
{"text": "/-\nCopyright (c) 2021 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n\n! This file was ported from Lean 3 source module dynamics.minimal\n! leanprover-community/mathlib commit 4c19a16e4b705bf135cf9a80ac18fcc99c438514\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.GroupTheory.GroupAction.Basic\nimport Mathlib.Topology.Algebra.ConstMulAction\n\n/-!\n# Minimal action of a group\n\nIn this file we define an action of a monoid `M` on a topological space `α` to be *minimal* if the\n`M`-orbit of every point `x : α` is dense. We also provide an additive version of this definition\nand prove some basic facts about minimal actions.\n\n## TODO\n\n* Define a minimal set of an action.\n\n## Tags\n\ngroup action, minimal\n-/\n\n\nopen Pointwise\n\n/-- An action of an additive monoid `M` on a topological space is called *minimal* if the `M`-orbit\nof every point `x : α` is dense. -/\nclass AddAction.IsMinimal (M α : Type _) [AddMonoid M] [TopologicalSpace α] [AddAction M α] :\n    Prop where\n  dense_orbit : ∀ x : α, Dense (AddAction.orbit M x)\n#align add_action.is_minimal AddAction.IsMinimal\n\n/-- An action of a monoid `M` on a topological space is called *minimal* if the `M`-orbit of every\npoint `x : α` is dense. -/\n@[to_additive]\nclass MulAction.IsMinimal (M α : Type _) [Monoid M] [TopologicalSpace α] [MulAction M α] :\n    Prop where\n  dense_orbit : ∀ x : α, Dense (MulAction.orbit M x)\n#align mul_action.is_minimal MulAction.IsMinimal\n\nopen MulAction Set\n\nvariable (M G : Type _) {α : Type _} [Monoid M] [Group G] [TopologicalSpace α] [MulAction M α]\n  [MulAction G α]\n\n@[to_additive]\ntheorem MulAction.dense_orbit [IsMinimal M α] (x : α) : Dense (orbit M x) :=\n  MulAction.IsMinimal.dense_orbit x\n#align mul_action.dense_orbit MulAction.dense_orbit\n#align add_action.dense_orbit AddAction.dense_orbit\n\n@[to_additive]\ntheorem denseRange_smul [IsMinimal M α] (x : α) : DenseRange fun c : M ↦ c • x :=\n  MulAction.dense_orbit M x\n#align dense_range_smul denseRange_smul\n#align dense_range_vadd denseRange_vadd\n\n@[to_additive]\ninstance (priority := 100) MulAction.isMinimal_of_pretransitive [IsPretransitive M α] :\n    IsMinimal M α :=\n  ⟨fun x ↦ (surjective_smul M x).denseRange⟩\n#align mul_action.is_minimal_of_pretransitive MulAction.isMinimal_of_pretransitive\n#align add_action.is_minimal_of_pretransitive AddAction.isMinimal_of_pretransitive\n\n@[to_additive]\ntheorem IsOpen.exists_smul_mem [IsMinimal M α] (x : α) {U : Set α} (hUo : IsOpen U)\n    (hne : U.Nonempty) : ∃ c : M, c • x ∈ U :=\n  (denseRange_smul M x).exists_mem_open hUo hne\n#align is_open.exists_smul_mem IsOpen.exists_smul_mem\n#align is_open.exists_vadd_mem IsOpen.exists_vadd_mem\n\n@[to_additive]\ntheorem IsOpen.unionᵢ_preimage_smul [IsMinimal M α] {U : Set α} (hUo : IsOpen U)\n    (hne : U.Nonempty) : (⋃ c : M, (· • ·) c ⁻¹' U) = univ :=\n  unionᵢ_eq_univ_iff.2 fun x ↦ hUo.exists_smul_mem M x hne\n#align is_open.Union_preimage_smul IsOpen.unionᵢ_preimage_smul\n#align is_open.Union_preimage_vadd IsOpen.unionᵢ_preimage_vadd\n\n@[to_additive]\ntheorem IsOpen.unionᵢ_smul [IsMinimal G α] {U : Set α} (hUo : IsOpen U) (hne : U.Nonempty) :\n    (⋃ g : G, g • U) = univ :=\n  unionᵢ_eq_univ_iff.2 fun x ↦\n    let ⟨g, hg⟩ := hUo.exists_smul_mem G x hne\n    ⟨g⁻¹, _, hg, inv_smul_smul _ _⟩\n#align is_open.Union_smul IsOpen.unionᵢ_smul\n#align is_open.Union_vadd IsOpen.unionᵢ_vadd\n\n@[to_additive]\ntheorem IsCompact.exists_finite_cover_smul [IsMinimal G α] [ContinuousConstSMul G α]\n    {K U : Set α} (hK : IsCompact K) (hUo : IsOpen U) (hne : U.Nonempty) :\n    ∃ I : Finset G, K ⊆ ⋃ g ∈ I, g • U :=\n  (hK.elim_finite_subcover (fun g ↦ g • U) fun _ ↦ hUo.smul _) <| calc\n    K ⊆ univ := subset_univ K\n    _ = ⋃ g : G, g • U := (hUo.unionᵢ_smul G hne).symm\n#align is_compact.exists_finite_cover_smul IsCompact.exists_finite_cover_smul\n#align is_compact.exists_finite_cover_vadd IsCompact.exists_finite_cover_vadd\n\n@[to_additive]\ntheorem dense_of_nonempty_smul_invariant [IsMinimal M α] {s : Set α} (hne : s.Nonempty)\n    (hsmul : ∀ c : M, c • s ⊆ s) : Dense s :=\n  let ⟨x, hx⟩ := hne\n  (MulAction.dense_orbit M x).mono (range_subset_iff.2 fun c ↦ hsmul c ⟨x, hx, rfl⟩)\n#align dense_of_nonempty_smul_invariant dense_of_nonempty_smul_invariant\n#align dense_of_nonempty_vadd_invariant dense_of_nonempty_vadd_invariant\n\n@[to_additive]\ntheorem eq_empty_or_univ_of_smul_invariant_closed [IsMinimal M α] {s : Set α} (hs : IsClosed s)\n    (hsmul : ∀ c : M, c • s ⊆ s) : s = ∅ ∨ s = univ :=\n  s.eq_empty_or_nonempty.imp_right fun hne ↦\n    hs.closure_eq ▸ (dense_of_nonempty_smul_invariant M hne hsmul).closure_eq\n#align eq_empty_or_univ_of_smul_invariant_closed eq_empty_or_univ_of_smul_invariant_closed\n#align eq_empty_or_univ_of_vadd_invariant_closed eq_empty_or_univ_of_vadd_invariant_closed\n\n@[to_additive]\ntheorem isMinimal_iff_closed_smul_invariant [ContinuousConstSMul M α] :\n    IsMinimal M α ↔ ∀ s : Set α, IsClosed s → (∀ c : M, c • s ⊆ s) → s = ∅ ∨ s = univ := by\n  constructor\n  · intro _ _\n    exact eq_empty_or_univ_of_smul_invariant_closed M\n  refine' fun H ↦ ⟨fun _ ↦ dense_iff_closure_eq.2 <| (H _ _ _).resolve_left _⟩\n  exacts[isClosed_closure, fun _ ↦ smul_closure_orbit_subset _ _,\n    (orbit_nonempty _).closure.ne_empty]\n#align is_minimal_iff_closed_smul_invariant isMinimal_iff_closed_smul_invariant\n#align is_minimal_iff_closed_vadd_invariant isMinimal_iff_closed_vadd_invariant\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Dynamics/Minimal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.4999096457239912}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen\n\n! This file was ported from Lean 3 source module linear_algebra.matrix.reindex\n! leanprover-community/mathlib commit 1cfdf5f34e1044ecb65d10be753008baaf118edf\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.Matrix.Determinant\n\n/-!\n# Changing the index type of a matrix\n\nThis file concerns the map `matrix.reindex`, mapping a `m` by `n` matrix\nto an `m'` by `n'` matrix, as long as `m ≃ m'` and `n ≃ n'`.\n\n## Main definitions\n\n* `matrix.reindex_linear_equiv R A`: `matrix.reindex` is an `R`-linear equivalence between\n  `A`-matrices.\n* `matrix.reindex_alg_equiv R`: `matrix.reindex` is an `R`-algebra equivalence between `R`-matrices.\n\n## Tags\n\nmatrix, reindex\n\n-/\n\n\nnamespace Matrix\n\nopen Equiv\n\nopen Matrix\n\nvariable {l m n o : Type _} {l' m' n' o' : Type _} {m'' n'' : Type _}\n\nvariable (R A : Type _)\n\nsection AddCommMonoid\n\nvariable [Semiring R] [AddCommMonoid A] [Module R A]\n\n/-- The natural map that reindexes a matrix's rows and columns with equivalent types,\n`matrix.reindex`, is a linear equivalence. -/\ndef reindexLinearEquiv (eₘ : m ≃ m') (eₙ : n ≃ n') : Matrix m n A ≃ₗ[R] Matrix m' n' A :=\n  { reindex eₘ eₙ with\n    map_add' := fun _ _ => rfl\n    map_smul' := fun _ _ => rfl }\n#align matrix.reindex_linear_equiv Matrix.reindexLinearEquiv\n\n@[simp]\ntheorem reindexLinearEquiv_apply (eₘ : m ≃ m') (eₙ : n ≃ n') (M : Matrix m n A) :\n    reindexLinearEquiv R A eₘ eₙ M = reindex eₘ eₙ M :=\n  rfl\n#align matrix.reindex_linear_equiv_apply Matrix.reindexLinearEquiv_apply\n\n@[simp]\ntheorem reindexLinearEquiv_symm (eₘ : m ≃ m') (eₙ : n ≃ n') :\n    (reindexLinearEquiv R A eₘ eₙ).symm = reindexLinearEquiv R A eₘ.symm eₙ.symm :=\n  rfl\n#align matrix.reindex_linear_equiv_symm Matrix.reindexLinearEquiv_symm\n\n@[simp]\ntheorem reindexLinearEquiv_refl_refl :\n    reindexLinearEquiv R A (Equiv.refl m) (Equiv.refl n) = LinearEquiv.refl R _ :=\n  LinearEquiv.ext fun _ => rfl\n#align matrix.reindex_linear_equiv_refl_refl Matrix.reindexLinearEquiv_refl_refl\n\ntheorem reindexLinearEquiv_trans (e₁ : m ≃ m') (e₂ : n ≃ n') (e₁' : m' ≃ m'') (e₂' : n' ≃ n'') :\n    (reindexLinearEquiv R A e₁ e₂).trans (reindexLinearEquiv R A e₁' e₂') =\n      (reindexLinearEquiv R A (e₁.trans e₁') (e₂.trans e₂') : _ ≃ₗ[R] _) :=\n  by\n  ext\n  rfl\n#align matrix.reindex_linear_equiv_trans Matrix.reindexLinearEquiv_trans\n\ntheorem reindexLinearEquiv_comp (e₁ : m ≃ m') (e₂ : n ≃ n') (e₁' : m' ≃ m'') (e₂' : n' ≃ n'') :\n    reindexLinearEquiv R A e₁' e₂' ∘ reindexLinearEquiv R A e₁ e₂ =\n      reindexLinearEquiv R A (e₁.trans e₁') (e₂.trans e₂') :=\n  by\n  rw [← reindex_linear_equiv_trans]\n  rfl\n#align matrix.reindex_linear_equiv_comp Matrix.reindexLinearEquiv_comp\n\ntheorem reindexLinearEquiv_comp_apply (e₁ : m ≃ m') (e₂ : n ≃ n') (e₁' : m' ≃ m'') (e₂' : n' ≃ n'')\n    (M : Matrix m n A) :\n    (reindexLinearEquiv R A e₁' e₂') (reindexLinearEquiv R A e₁ e₂ M) =\n      reindexLinearEquiv R A (e₁.trans e₁') (e₂.trans e₂') M :=\n  submatrix_submatrix _ _ _ _ _\n#align matrix.reindex_linear_equiv_comp_apply Matrix.reindexLinearEquiv_comp_apply\n\ntheorem reindexLinearEquiv_one [DecidableEq m] [DecidableEq m'] [One A] (e : m ≃ m') :\n    reindexLinearEquiv R A e e (1 : Matrix m m A) = 1 :=\n  submatrix_one_equiv e.symm\n#align matrix.reindex_linear_equiv_one Matrix.reindexLinearEquiv_one\n\nend AddCommMonoid\n\nsection Semiring\n\nvariable [Semiring R] [Semiring A] [Module R A]\n\ntheorem reindexLinearEquiv_mul [Fintype n] [Fintype n'] (eₘ : m ≃ m') (eₙ : n ≃ n') (eₒ : o ≃ o')\n    (M : Matrix m n A) (N : Matrix n o A) :\n    reindexLinearEquiv R A eₘ eₙ M ⬝ reindexLinearEquiv R A eₙ eₒ N =\n      reindexLinearEquiv R A eₘ eₒ (M ⬝ N) :=\n  submatrix_mul_equiv M N _ _ _\n#align matrix.reindex_linear_equiv_mul Matrix.reindexLinearEquiv_mul\n\ntheorem mul_reindexLinearEquiv_one [Fintype n] [DecidableEq o] (e₁ : o ≃ n) (e₂ : o ≃ n')\n    (M : Matrix m n A) :\n    M.mul (reindexLinearEquiv R A e₁ e₂ 1) =\n      reindexLinearEquiv R A (Equiv.refl m) (e₁.symm.trans e₂) M :=\n  haveI := Fintype.ofEquiv _ e₁.symm\n  mul_submatrix_one _ _ _\n#align matrix.mul_reindex_linear_equiv_one Matrix.mul_reindexLinearEquiv_one\n\nend Semiring\n\nsection Algebra\n\nvariable [CommSemiring R] [Fintype n] [Fintype m] [DecidableEq m] [DecidableEq n]\n\n/-- For square matrices with coefficients in commutative semirings, the natural map that reindexes\na matrix's rows and columns with equivalent types, `matrix.reindex`, is an equivalence of algebras.\n-/\ndef reindexAlgEquiv (e : m ≃ n) : Matrix m m R ≃ₐ[R] Matrix n n R :=\n  { reindexLinearEquiv R R e e with\n    toFun := reindex e e\n    map_mul' := fun a b => (reindexLinearEquiv_mul R R e e e a b).symm\n    commutes' := fun r => by simp [algebraMap, Algebra.toRingHom, submatrix_smul] }\n#align matrix.reindex_alg_equiv Matrix.reindexAlgEquiv\n\n@[simp]\ntheorem reindexAlgEquiv_apply (e : m ≃ n) (M : Matrix m m R) :\n    reindexAlgEquiv R e M = reindex e e M :=\n  rfl\n#align matrix.reindex_alg_equiv_apply Matrix.reindexAlgEquiv_apply\n\n@[simp]\ntheorem reindexAlgEquiv_symm (e : m ≃ n) : (reindexAlgEquiv R e).symm = reindexAlgEquiv R e.symm :=\n  rfl\n#align matrix.reindex_alg_equiv_symm Matrix.reindexAlgEquiv_symm\n\n@[simp]\ntheorem reindexAlgEquiv_refl : reindexAlgEquiv R (Equiv.refl m) = AlgEquiv.refl :=\n  AlgEquiv.ext fun _ => rfl\n#align matrix.reindex_alg_equiv_refl Matrix.reindexAlgEquiv_refl\n\ntheorem reindexAlgEquiv_mul (e : m ≃ n) (M : Matrix m m R) (N : Matrix m m R) :\n    reindexAlgEquiv R e (M ⬝ N) = reindexAlgEquiv R e M ⬝ reindexAlgEquiv R e N :=\n  (reindexAlgEquiv R e).map_mul M N\n#align matrix.reindex_alg_equiv_mul Matrix.reindexAlgEquiv_mul\n\nend Algebra\n\n/-- Reindexing both indices along the same equivalence preserves the determinant.\n\nFor the `simp` version of this lemma, see `det_submatrix_equiv_self`.\n-/\ntheorem det_reindexLinearEquiv_self [CommRing R] [Fintype m] [DecidableEq m] [Fintype n]\n    [DecidableEq n] (e : m ≃ n) (M : Matrix m m R) : det (reindexLinearEquiv R R e e M) = det M :=\n  det_reindex_self e M\n#align matrix.det_reindex_linear_equiv_self Matrix.det_reindexLinearEquiv_self\n\n/-- Reindexing both indices along the same equivalence preserves the determinant.\n\nFor the `simp` version of this lemma, see `det_submatrix_equiv_self`.\n-/\ntheorem det_reindexAlgEquiv [CommRing R] [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n]\n    (e : m ≃ n) (A : Matrix m m R) : det (reindexAlgEquiv R e A) = det A :=\n  det_reindex_self e A\n#align matrix.det_reindex_alg_equiv Matrix.det_reindexAlgEquiv\n\nend Matrix\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/Matrix/Reindex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975978, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4999096411448274}}
{"text": "import data.int.basic\nimport data.rat\nimport galois.nat.div_lemmas\nimport data.nat.basic\nimport galois.sum\nimport init.data.ordering\nimport data.vector\n\nimport galois.nat\nimport .bool\n\nuniverse u\n\n@[simp]\ntheorem coe_bool_to_prop (b:bool) : coe b ↔ b = tt :=\nbegin\n  cases b; exact dec_trivial,\nend\n@[simp]\ntheorem to_bool_is_tt  (p : Prop) [inst:decidable p] : (to_bool p = tt) = p :=\nbegin\n  cases inst,\n  all_goals { unfold decidable.to_bool, simp [a], },\nend\n\n\nnamespace nat\n\nlemma lt.intro {n m k : ℕ} (h : n + succ k = m) : n < m :=\n  h ▸ nat.succ_le_succ (nat.le_add_right n k)\n\nend nat\n\nnamespace list\n\nsection\nparameter {α : Type u}\nparameter (n : ℕ)\nparameter (f : fin n → α)\n\nprotected\ndef generate_core : Π (i j : ℕ), i + j = n  → list α\n| i 0 pr := []\n| i (nat.succ j) pr :=\n  let qr : i < n := nat.lt.intro pr in\n  let rr : i+1 + j = n :=\n      begin\n        simp [nat.succ_add i j],\n        exact pr,\n      end in\n  f ⟨i, qr⟩ :: generate_core (i+1) j rr\n\nprotected\ndef generate : list α := generate_core 0 n (nat.zero_add n)\n\ntheorem length_generate_core (i j : ℕ)\n: Π (pr : i + j = n),\n  (generate_core i j pr).length = j :=\nbegin\n  revert i,\n  induction j,\n  case nat.zero {\n    intros,\n    exact dec_trivial,\n  },\n  case nat.succ j ind {\n    intros,\n    simp only [list.generate_core, length_cons],\n    apply congr_arg nat.succ,\n    apply ind,\n  },\nend\n\nprotected\ntheorem length_generate : generate.length = n :=\nbegin\n  apply length_generate_core,\nend\n\nend\n\nsection foldl₂\nparameter {α : Type _}\nparameter {β : Type _}\nparameter {C : Type _}\nparameter (f : C → α → β → C)\n\ndef foldl₂\n  : C → list α → list β → C\n| c [] _ := c\n| c _ [] := c\n| c (x::xr) (y::yr) := foldl₂ (f c x y) xr yr\n\nend foldl₂\n\nsection init\nparameter {α : Type _}\n\nprotected\ntheorem length_init (l : list α) : l.init.length = l.length - 1 :=\nbegin\n  induction l,\n  case nil {\n    simp [init],\n  },\n  case cons h r ind {\n    cases r,\n    { simp [init], },\n    case list.cons h2 r {\n      simp only [init, length_cons, ind, nat.succ_sub_succ],\n      trivial,\n    }\n  }\nend\n\n\nend init\nend list\n\nnamespace vector\n\ndef generate {α : Type u} (n : ℕ) (f : fin n → α) : vector α n :=\n  ⟨ list.generate n f, list.length_generate n f⟩\n\nsection foldl₂\nparameter {α : Type _}\nparameter {β : Type _}\nparameter {C : Type _}\nparameter (f : C → α → β → C)\nparameter {n:ℕ}\n\ndef foldl₂ (c:C) (x : vector α n) (y: vector β n) : C :=\n  list.foldl₂ f c x.to_list y.to_list\n\nend foldl₂\n\ndef dotprod {α: Type u} [semiring α] {n:ℕ} : vector α n → vector α n → α :=\n  foldl₂ (λc a b, c + a * b) 0\n\nnotation `⬝` := dotprod\n\ndef last {α:Type u} {n:ℕ} (v : vector α (n+1)) : α :=\n  v.to_list.last (list.ne_nil_of_length_eq_succ v.property)\n\n-- Return all but the last element in a vector.\ndef init {α:Type u} {n:ℕ} (v : vector α (n+1)) : vector α n :=\n  let pr : v.to_list.init.length = n :=\n      begin\n        simp only [list.length_init, to_list_length],\n        trivial,\n      end in\n  ⟨ v.to_list.init, pr⟩\n\ndef scale_mul {α:Type u} [has_mul α] {n:ℕ} (c:α) (v : vector α n)\n: vector α n :=\n  v.map (has_mul.mul c)\n\nend vector\n\n\n\nnamespace list\n\nprotected\ndef maximum {α:Type _} [decidable_linear_order α] : list α → option α\n| [] := option.none\n| (h::r) := option.some (r.foldl max h)\n\nprotected\ndef minimum {α:Type _} [decidable_linear_order α] : list α → option α\n| [] := option.none\n| (h::r) := option.some (r.foldl min h)\n\nend list\n\nnamespace rat\n\ndef to_string (q:ℚ) : string :=\n  if q.denom = 1 then\n    to_string (q.num)\n  else\n    to_string (q.num) ++ \"/\" ++ to_string q.denom\n\ninstance : has_to_string ℚ := ⟨ to_string ⟩\n\nend rat\n\n-----------------------------------------------------------------------\n-- bound\n\n-- Return true if either option is none, or both are defined and first is\n-- less than second.\ndef bound_le : option ℚ → option ℚ → Prop\n| none _ := true\n| (some l) (some u) := l ≤ u\n| (some _) none := true\n\ntheorem bound_le_maximum_minimum (ll ul : list ℚ)\n(pr : ∀ (l u : ℚ), l ∈ ll → u ∈ ul → l ≤ u)\n: bound_le (list.maximum ll) (list.minimum ul) := sorry\n\ndef le_bound (ol: option ℚ) (u : ℚ) : Prop :=\n  match ol with\n  | option.none := true\n  | (option.some l) := l ≤ u\n  end\n\ninstance le_bound.decidable (ol : option ℚ) (u:ℚ) : decidable (le_bound ol u) :=\n  begin cases ol; unfold le_bound; apply_instance end\n\ndef ge_bound (l:ℚ) (ou: option ℚ) : Prop :=\n  match ou with\n  | option.none := true\n  | (option.some u) := l ≤ u\n  end\n\ninstance ge_bound.decidable (l:ℚ) (ou : option ℚ) : decidable (ge_bound l ou) :=\n  begin cases ou; unfold ge_bound; apply_instance end\n\n\ndef choose_bound : option ℚ → option ℚ → ℚ\n| (some l) _ := l\n| none none := 0\n| none (some u) := u\n\ntheorem le_bound_choose_bound (l u : option ℚ) : le_bound l (choose_bound l u) :=\nbegin\n  cases l with l,\n  all_goals { simp [le_bound, choose_bound], },\nend\n\ntheorem ge_bound_choose_bound {l u : option ℚ} (pr : bound_le l u) : ge_bound (choose_bound l u) u :=\nbegin\n  cases u with u,\n  {\n    simp [ge_bound, choose_bound],\n  },\n  {\n    cases l with l,\n    { simp [ge_bound, choose_bound], },\n    { simp [bound_le] at pr,\n      simp [ge_bound, choose_bound, pr],\n    },\n  },\nend\n\n-----------------------------------------------------------------------\n-- assignment\n\n@[reducible]\ndef assignment (α:Type _) (n:ℕ) := vector α n\n\nnamespace assignment\n\nsection\nparameter {α:Type _}\n\n/-- The empty assignment. -/\ndef empty : assignment α 0 := vector.nil\n\ndef zero_assignment_is_empty (a:assignment α 0) : a = empty :=\nbegin\n  simp [empty],\n  apply vector.eq_nil,\nend\n\ndef concat {n:ℕ} (xs : assignment α n) (x : α) : assignment α (n+1) :=\n  vector.cons x xs\n\ndef shrink {n:ℕ} (a:assignment α n) (i : fin n) : assignment α i.val :=\nbegin\nhave H1 : i.val ≤ n,\napply le_of_lt, apply fin.is_lt,\nhave H := vector.take i.val a,\nunfold min at H,\nrw (if_pos H1) at H, apply H\nend\n\n-- def last_of_fin {n:ℕ} (a:assignment α n) (i : fin n) : α :=\n--   sorry\n\n-- def init {n:ℕ} (a:assignment α (n+1)) : assignment α n :=\n--   sorry\n\n-- def last {n:ℕ} (a:assignment α (n+1)) : α :=\n--   sorry\n\n@[simp]\ntheorem init_concat {n:ℕ} (a:assignment α n) (z:α) : vector.init (concat a z) = a := sorry\n\n@[simp]\ntheorem last_concat {n:ℕ} (a:assignment α n) (z:α) : vector.last (concat a z) = z := sorry\n\nend\nend assignment\n\n-- denotes the inequality coef <= bound\ninductive linear_expr : ℕ → Type\n| const : Π {n:ℕ}, ℚ → linear_expr n\n| add : Π {n:ℕ} (c:ℚ) (pr : c ≠ 0) (i : fin n), linear_expr i.val → linear_expr n\n\nlemma nat_ordering_char (x y : ℕ)\n  : (match nat.cmp x y with\n  | ordering.lt := x < y\n  | ordering.eq := x = y\n  | ordering.gt := x > y\n  end : Prop)\n:= begin\ndsimp [nat.cmp],\napply (if H : x < y then _ else _),\nrw (if_pos H), assumption,\nrw (if_neg H),\napply (if H' : x = y then _ else _),\nrw (if_pos H'), assumption,\nrw (if_neg H'), dsimp,\ndsimp [(>)],\nrw lt_iff_not_ge,\nintros contra, apply H', apply le_antisymm,\nassumption, apply le_of_not_gt, assumption,\nend\n\nnamespace fin\n\nlemma lt_char {n : ℕ}\n  (x y : fin n) : x < y ↔ x.val < y.val\n:= begin\ninduction x; induction y; reflexivity\nend\n\ndef extend_le {m n : ℕ} (H : m ≤ n) (x : fin m) : fin n\n:= begin\nconstructor, apply lt_of_lt_of_le, apply fin.is_lt, assumption,\nassumption,\nend\n\ndef restrict_lt {n : ℕ} (x y : fin n) (H : x < y)\n  : fin y.val\n:= ⟨ x.val, begin\nrw lt_char at H, assumption\nend ⟩\n\ndef ordering_elim {n : ℕ}\n  (C : Sort _)\n  (x y : fin n)\n  (Hlt : x < y → C)\n  (Heq : x = y → C)\n  (Hgt : x > y → C)\n  : C\n:= begin\nhave H := nat_ordering_char x.val y.val,\ncases (nat.cmp x.val y.val);\n  dsimp at H,\n{ apply Hlt, rw lt_char, assumption },\n{ induction x, induction y, dsimp at H,\n  apply Heq, subst H, },\n{ apply Hgt, unfold gt, rw fin.lt_char, assumption },\nend\n\nend fin\n\nnamespace linear_expr\n\ndef scale_mul (x : ℚ) (xne0 : x ≠ 0) : ∀ {n}, linear_expr n → linear_expr n\n| _ (const c) := const (x * c)\n| _ (add c cne0 i e) := add (x * c) (mul_ne_zero xne0 cne0) i (scale_mul e)\n\ndef add_constant (x : ℚ) : ∀ {n}, linear_expr n → linear_expr n\n| _ (const c) := const (x + c)\n| _ (add c cne0 i e) := add c cne0 i (add_constant e)\n\ndef extend {i n :ℕ} : linear_expr i → i ≤ n → linear_expr n\n| (const c) is_le := const c\n| (add c pr j e) is_le := add c pr ⟨j.val, lt_of_lt_of_le j.is_lt is_le⟩ e\n\ndef add_variable (x : ℚ) : ∀ {n}, fin n → linear_expr n → linear_expr n\n| _ i (const c) := if xne0 : x ≠ 0\n    then add x xne0 i (const c)\n    else const c\n| n i (add c cne0 i' e) := begin\n  apply (fin.ordering_elim (linear_expr n) i i');\n    intros,\n    { apply (add c cne0 i'),\n      apply add_variable,\n      apply fin.restrict_lt, assumption,\n      assumption,\n    },\n    { apply (if H : x + c ≠ 0 then _ else _),\n      { apply (add (x + c) H i' e), },\n      { apply e.extend, apply le_of_lt, apply fin.is_lt, }\n    },\n    { apply (if H : x ≠ 0 then _ else _),\n      { apply (add x H i),\n        apply (add c cne0), admit, admit },\n      { apply e.extend, apply le_of_lt, apply fin.is_lt, }\n    }\n   end\n\ndef sum : ∀ {n}, linear_expr n → linear_expr n → linear_expr n\n| _ (const c) e := add_constant c e\n| _ (add c cne0 i e) e' := sorry\n\ndef as_const : linear_expr 0 → ℚ\n| (const c) := c\n| (add _ _ i _) :=\n  begin\n    have is_lit := i.is_lt,\n    have h := nat.not_lt_zero i.val,\n    contradiction,\n  end\n\ndef prepend_sum : string → string → string\n| s \"\" := s\n| s t := s ++ \" + \" ++ t\n\n\ndef to_string_core  : Π {n:ℕ}, linear_expr n → string → string\n| _ (const c) s :=\n   if s = \"\" then\n     to_string c\n  else if c = 0 ∧ s ≠ \"\" then\n    s\n  else\n    s ++ \" + \" ++ to_string c\n| _  (add c _ i e) s :=\n  to_string_core e\n    (if c = 1 then\n       prepend_sum (\"v\" ++ to_string i) s\n     else\n       prepend_sum (to_string c ++\"×v\" ++ to_string i) s)\n\ndef to_string  {n:ℕ} (e:linear_expr n) : string := to_string_core e \"\"\n\ndef var {n:ℕ} (i : fin n) : linear_expr n := add 1 dec_trivial i (const 0)\n\n/-- Return the last coefficient of the linear_expression. -/\ndef last {n:ℕ} : linear_expr (n+1) → ℚ\n| (const c) := 0\n| (add c pr i e) := if i.val = n then c else 0\n\n/-- Return the expression with the last variable removed and the coefficient. -/\ndef drop_last {n:ℕ} : linear_expr (n+1) → linear_expr n\n| (const c) := const c\n| (add c pr i e) :=\n  if i_lt_n : i.val < n then\n    add c pr ⟨i.val, i_lt_n⟩ e\n  else\n    e.extend (nat.pred_le_pred i.is_lt)\n\nsection evaluate\nparameter {n:ℕ}\n\ndef evaluate_core : ℚ → Π{n:ℕ}, linear_expr n → assignment ℚ n → ℚ\n| r _ (const c) _ := c + r\n| r _ (add c pr i e) a := evaluate_core (r + c * a.nth i) e (a.shrink i)\n\ndef evaluate : Π{n:ℕ}, linear_expr n → assignment ℚ n → ℚ := @evaluate_core 0\n\nend evaluate\n\nend linear_expr\n\n-----------------------------------------------------------------------\n-- linear_expr_list\n\ndef linear_expr_list (n:ℕ) := list (linear_expr n)\n\nnamespace linear_expr_list\n\ndef to_list {n:ℕ} : linear_expr_list n → list (linear_expr n) := id\n\ninstance (n:ℕ) : has_mem (linear_expr n) (linear_expr_list n) :=\n  begin unfold linear_expr_list, apply_instance end\n\nsection\nparameter {n:ℕ}\n\ndef evaluate (l : linear_expr_list n) (a : assignment ℚ n) : list ℚ :=\n  l.map (λe, e.evaluate a)\n\ntheorem evaluate_cons (e : linear_expr n) (l : linear_expr_list n)\n  (a : assignment ℚ n)\n: evaluate (e :: l) a = e.evaluate a :: l.evaluate a := rfl\n\ntheorem mem_evaluate_implies {l: linear_expr_list n} {a:assignment ℚ n} {q : ℚ}\n(pr : q ∈ l.evaluate a)\n: ∃(e:linear_expr n), e ∈ l ∧ e.evaluate a = q\n:= begin\napply list.exists_of_mem_map pr,\nend\n\nend\nend linear_expr_list\n\n---------------------------------------------------------\n-- Inequalities\n\n-- denotes the inequality lhs <= 0\nstructure inequality (n:ℕ) :=\n(lhs : linear_expr n)\n\nnamespace inequality\n\nsection entails\n\nparameter {n:ℕ}\n\ndef from_pair : linear_expr n → linear_expr n → inequality n := sorry\n\ndef satisfies (θ:assignment ℚ n) (c:inequality n) : Prop := c.lhs.evaluate θ ≤ 0\n\ntheorem satisfies_from_pair (a:assignment ℚ n) (l u:linear_expr n)\n: satisfies a (from_pair l u) ↔ l.evaluate a ≤ u.evaluate a := sorry\n\ninstance (c:inequality n) (θ:assignment ℚ n)\n: decidable (satisfies θ c) :=\n  begin unfold satisfies, apply_instance end\n\nend entails\n\nnotation `⊧` := satisfies\n\nend inequality\n\n/-- A collection on inequalities -/\ndef ineqs (n:ℕ) := list (inequality n)\n\nnamespace ineqs\n\ninstance (n:ℕ) : has_append (ineqs n) := begin unfold ineqs, apply_instance end\ninstance (n:ℕ) : has_mem (inequality n) (ineqs n) := begin unfold ineqs, apply_instance end\n\nsection satisfies\n\nparameter {n:ℕ}\nparameter (a:assignment ℚ n)\n\n-- Returns true if assignment satisfies bound.\ndef satisfies (eqs:ineqs n) : Prop :=\n   eqs.all (λb, to_bool (inequality.satisfies a b))\n\ninstance (eqs:ineqs n) : decidable (satisfies eqs) :=\n  begin unfold satisfies, apply_instance end\n\n@[simp]\ntheorem satisfies_nil : satisfies [] :=\nbegin\n  simp [satisfies, list.all],\nend\n\n@[simp]\ntheorem satisfies_cons (h : inequality n) (r : ineqs n)\n: satisfies (h :: r) ↔ inequality.satisfies a h ∧ satisfies r :=\nbegin\n  simp [satisfies, list.all, list.foldr],\nend\n\n@[simp]\ntheorem satisfies_append (x y : ineqs n) :\n satisfies (x ++ y) = (satisfies x ∧ satisfies y) := sorry\n\nend satisfies\n\ntheorem satisfies_list_implies_mem_satisfies {n:ℕ}\n{e : inequality n}\n{l : ineqs n}\n{a:assignment ℚ n}\n(pr : satisfies a l)\n(in_list : e ∈ l)\n: inequality.satisfies a e := sorry\n\n\n/-- Denotes a solution to the equations. -/\ndef solution {n:ℕ} (eqs:ineqs n) := { a : assignment ℚ n // eqs.satisfies a }\n\n/-- A proof that the equations are unsatisfiable. -/\ndef unsat_proof {n:ℕ} (eqs:ineqs n) :=\n  ∀(a:assignment ℚ n), ¬ (satisfies a eqs)\n\nend ineqs\n\n-----------------------------------------------------------------------\n-- bound\n\ninductive bound (n:ℕ) : Type\n-- lower e denotes e <= x\n| lower : linear_expr n → bound\n-- upper e denotes x <= e\n| upper : linear_expr n → bound\n-- If variable had a zero in the expression.\n| independent  : inequality n → bound\n\nnamespace bound\n\n/-- Given an inequality infers the resulting bound on the last variable. -/\ndef from_ineq {n:ℕ} (le : inequality (n+1)) : bound n :=\n  let e := le.lhs in\n  let c := e.last in\n  let r  := e.drop_last in\n   if c > 0 then\n    -- \"l + c * v <= 0\" ~> \"v <= -l/c\"\n    let recip := 1/c in\n    bound.upper (linear_expr.scale_mul (-1/c) sorry r)\n    -- \"l + c * v <= 0\" ~> \"l/c <= v\"\n  else if c < 0 then\n    bound.lower (linear_expr.scale_mul (1/c) sorry r)\n  else\n    bound.independent ⟨ r ⟩\n\nsection\n\nparameter {n:ℕ}\n\n-- Returns true if assignment satisfies bound.\ndef satisfies (a:assignment ℚ (n+1)) : bound n → Prop\n| (lower e) := e.evaluate a.init ≤ a.last\n| (upper e) := a.last ≤ e.evaluate a.init\n| (independent le) := le.satisfies a.init\n\n@[simp]\ntheorem satisfies_from_ineq (a: assignment ℚ (n+1)) (le : inequality (n+1))\n: bound.satisfies a (bound.from_ineq le) = inequality.satisfies a le := sorry\n\nend\nend bound\n\n-----------------------------------------------------------------------\n-- bound_list\n\nstructure bound_list (n:ℕ) :=\n(lower : linear_expr_list n)\n(upper : linear_expr_list n)\n(independent : ineqs n)\n\nnamespace bound_list\n\ndef empty (n:ℕ) : bound_list n :=\n  { lower := [], upper := [], independent := []}\n\ndef lower_bound {n:ℕ} (b:bound_list n) (a:assignment ℚ n) : option ℚ :=\n  (b.lower.evaluate a).maximum\n\ndef upper_bound {n:ℕ} (b:bound_list n) (a:assignment ℚ n) : option ℚ :=\n  (b.upper.evaluate a).minimum\n\nsection satisfies\nparameter {n:ℕ}\nparameter (a:assignment ℚ (n+1))\n\n-- Returns true if assignment satisfies bound.\ndef satisfies (b:bound_list n) : Prop :=\n     le_bound (b.lower_bound a.init) a.last\n   ∧ ge_bound a.last (b.upper_bound a.init)\n   ∧ ineqs.satisfies a.init b.independent\n\ninstance (b:bound_list n) : decidable (satisfies b) :=\n  begin\n    unfold satisfies,\n    apply_instance,\n  end\n\nend satisfies\n\n@[simp]\ntheorem satisfies_empty (n:ℕ) (a:assignment ℚ (n+1))\n: satisfies a (empty n) :=\nbegin\n  simp [empty, satisfies, upper_bound, lower_bound,\n        linear_expr_list.evaluate, list.minimum,\n        ge_bound, le_bound],\nend\n\nsection from_ineqs\nparameter {n:ℕ}\n\ndef add_bound : bound n → bound_list n → bound_list n\n| (bound.lower e) b := { b with lower := e :: b.lower }\n| (bound.upper e) b := { b with upper := e :: b.upper }\n| (bound.independent e) b := { b with independent := e :: b.independent }\n\ntheorem satisfies_add_bound (a:assignment ℚ (n+1)) (b:bound n) (l: bound_list n)\n: satisfies a (bound_list.add_bound b l) ↔\n  (bound.satisfies a b ∧ satisfies a l) :=\nbegin\n  apply iff.intro,\n  { cases b,\n    case bound.lower e {\n      cases l,\n      simp [satisfies, add_bound, bound.satisfies, lower_bound, upper_bound],\n      intros ineq_sat, admit,\n    },\n    case bound.upper e {\n      admit,\n    },\n    case bound.independent ineq {\n      admit,\n    },\n  },\n  {\n    admit,\n  }\nend\n\n\n/-- Return bounds on last variable. -/\ndef from_ineqs (l:ineqs (n+1)) : bound_list n :=\n  l.foldr (λe, add_bound (bound.from_ineq e)) (empty n)\n\n@[simp]\ntheorem from_ineqs_nil : from_ineqs list.nil = empty n := rfl\n\n@[simp]\ntheorem from_ineqs_cons (e: inequality (n+1)) (l:ineqs (n+1))\n: from_ineqs (e::l) =\n   add_bound (bound.from_ineq e) (from_ineqs l) :=\nbegin\n  simp [from_ineqs],\nend\n\nend from_ineqs\n\nsection\nparameter {n:ℕ}\n\ndef to_ineqs (b:bound_list n) : ineqs n :=\n  b.independent ++ (do l ← b.lower.to_list, inequality.from_pair l <$> b.upper.to_list)\n\ntheorem lower_upper_in_to_ineqs {l u:linear_expr n} {b: bound_list n}\n(in_lower : l ∈ b.lower)\n(in_upper : u ∈ b.upper)\n: (inequality.from_pair l u ∈ to_ineqs b) := sorry\n\nend\n\ndef solution {n:ℕ} (eqs:bound_list n) := { a : assignment ℚ (n+1) // eqs.satisfies a }\n\n\ntheorem to_ineqs_preserve_sat {n:ℕ} {b: bound_list n} (a:assignment ℚ (n+1))\n(pr : bound_list.satisfies a b)\n: ineqs.satisfies a.init b.to_ineqs :=\nbegin\n  admit,\nend\n\ntheorem lower_le_upper {n:ℕ} {b: bound_list n} (a:assignment ℚ n)\n(pr : ineqs.satisfies a b.to_ineqs)\n: bound_le (b.lower_bound a) (b.upper_bound a) :=\nbegin\n  simp [lower_bound, upper_bound],\n  apply bound_le_maximum_minimum,\n  intros l u l_mem u_mem,\n  apply exists.elim (linear_expr_list.mem_evaluate_implies l_mem),\n  intros l_eq l_cond,\n  apply exists.elim (linear_expr_list.mem_evaluate_implies u_mem),\n  intros u_eq u_cond,\n  have in_list := lower_upper_in_to_ineqs l_cond.left u_cond.left,\n  have is_sat := ineqs.satisfies_list_implies_mem_satisfies pr in_list,\n  simp [inequality.satisfies_from_pair] at is_sat,\n  cc,\nend\n\nend bound_list\n\n-----------------------------------------------------------------------\n-- to_ineqs theorems\n\n\n\ntheorem bounded_list.satisfies_concat {n:ℕ} {b: bound_list n} (a:assignment ℚ n) {z : ℚ}\n(pr : ineqs.satisfies a b.to_ineqs)\n(sat_lower : le_bound (b.lower_bound a) z)\n(sat_upper : ge_bound z (b.upper_bound a))\n: bound_list.satisfies (a.concat z) b :=\nbegin\n  unfold bound_list.satisfies,\n  simp,\n  simp [bound_list.to_ineqs] at pr,\n  cc,\nend\n\n-----------------------------------------------------------------------\n-- from_ineqs theorems\n\ntheorem from_ineqs_preserve_sat {n:ℕ} {l: ineqs (n+1)} (a:assignment ℚ (n+1))\n: bound_list.satisfies a (bound_list.from_ineqs l) ↔ ineqs.satisfies a l :=\nbegin\n  induction l,\n  case list.nil { simp, },\n  case list.cons h r ind {\n    simp [bound_list.satisfies_add_bound],\n    cc,\n  },\nend\n\ndef ineqs.solution.to_bound_list {n:ℕ} {b : bound_list n}\n  : b.to_ineqs.solution → b.solution\n| ⟨ a, pr ⟩ :=\n  let z : ℚ := choose_bound (b.lower_bound a) (b.upper_bound a) in\n  let qr : b.satisfies (assignment.concat a z) :=\n        begin\n          apply bounded_list.satisfies_concat _ pr,\n          {\n            apply le_bound_choose_bound,\n          },\n          {\n            apply ge_bound_choose_bound,\n            apply bound_list.lower_le_upper,\n            apply pr,\n          }\n        end in\n  ⟨ (a.concat z : assignment ℚ (n+1)), qr ⟩\n\ndef bound_list.solution.to_ineqs {n:ℕ} {l : ineqs (n+1)}\n  : (bound_list.from_ineqs l).solution → l.solution\n  | ⟨ a, pr ⟩ :=\n    let qr : l.satisfies a := iff.mp (from_ineqs_preserve_sat _) pr in\n    ⟨ a, qr ⟩\n\ninductive sat_result {n:ℕ} (eqs:ineqs n)\n| unsat : eqs.unsat_proof → sat_result\n| sat : eqs.solution → sat_result\n\ndef solve_inequalities : Π {n:ℕ} (eqs:ineqs n), sat_result eqs\n| 0 l :=\n  if pr : l.satisfies assignment.empty then\n    sat_result.sat ⟨ assignment.empty, pr ⟩\n  else\n    sat_result.unsat\n    (begin\n      unfold ineqs.unsat_proof,\n      intros a,\n      rw [assignment.zero_assignment_is_empty a],\n      exact pr,\n    end)\n| (nat.succ n) l :=\n  match solve_inequalities (bound_list.from_ineqs l).to_ineqs with\n  | sat_result.sat a := sat_result.sat a.to_bound_list.to_ineqs\n  | sat_result.unsat pr := sat_result.unsat $\n     begin\n       unfold ineqs.unsat_proof,\n       intros a contra,\n       unfold ineqs.unsat_proof at pr,\n       apply pr a.init,\n       apply bound_list.to_ineqs_preserve_sat a,\n       apply iff.mpr (from_ineqs_preserve_sat a),\n       exact contra,\n     end\n  end\n\n\n-----------------------------------------------------------------------\n-----------------------------------------------------------------------\n-- Meta\n\nopen tactic\n\nnamespace linear\n\ninductive type : Type\n| nat : type\n| int : type\n| rat : type\n\nmeta def type.resolve : expr → string ⊕ type\n| `(nat) := pure type.nat\n| `(int) := pure type.int\n| `(rat) := pure type.rat\n| e := sum.inl (\"Unknown type:\" ++ to_string e)\n\nset_option pp.all true\n\nmeta inductive lexpr : type → Type\n| foreign : Π(tp:type), expr → lexpr tp\n| add : Π{tp:type}, lexpr tp → lexpr tp → lexpr tp\n| zero : Π(tp:type), lexpr tp\n| one : Π(tp:type), lexpr tp\n| bit0 : Π{tp:type}, lexpr tp → lexpr tp\n| bit1 : Π{tp:type}, lexpr tp → lexpr tp\n\nprotected\nmeta def lexpr.resolve : Π(tp:type), expr → lexpr tp\n| ltp `(@has_add.add %%tp %%inst %%x %%y) := lexpr.add (lexpr.resolve ltp x) (lexpr.resolve ltp y)\n| ltp `(@has_zero.zero %%tp %%inst) := lexpr.zero ltp\n| ltp `(@has_one.one %%tp %%inst)   := lexpr.one ltp\n| ltp `(@bit0 %%tp %%inst %%x)                := lexpr.bit0 (lexpr.resolve ltp x)\n| ltp `(@bit1 %%tp %%one_inst %%add_inst %%x) := lexpr.bit1 (lexpr.resolve ltp x)\n| ltp e := lexpr.foreign ltp e\n\nnamespace lexpr\n\nsection to_string\n\nprotected\nmeta def to_string : ∀ {tp:type}, lexpr tp → string\n| tp (foreign ._ x) := \"<\" ++ has_to_string.to_string x ++ \">\"\n| _ (add x y) := \"(add \" ++ to_string x ++ \" \" ++ to_string y ++ \")\"\n| tp (zero ._) := \"(zero)\"\n| tp (one ._) := \"(one)\"\n| _ (bit0 x) := \"(bit0 \" ++ to_string x ++ \")\"\n| _ (bit1 x) := \"(bit1 \" ++ to_string x ++ \")\"\n\nmeta instance {tp:type} : has_to_string (lexpr tp) := ⟨@lexpr.to_string tp⟩\n\nend to_string\n\n\nend lexpr\n\nmeta inductive prop : Type\n| eq : Π(tp:type), lexpr tp → lexpr tp → prop\n| ge : Π(tp:type), lexpr tp → lexpr tp → prop\n| gt : Π(tp:type), lexpr tp → lexpr tp → prop\n| le : Π(tp:type), lexpr tp → lexpr tp → prop\n| lt : Π(tp:type), lexpr tp → lexpr tp → prop\n\nset_option pp.all true\n\nmeta def prop.mk_bin (f : Π(tp:type), lexpr tp → lexpr tp → prop)\n   (resolve_tp : string ⊕ type) (l r : expr) : string ⊕ prop := do\n   tp ← resolve_tp,\n   pure (f tp (lexpr.resolve tp l) (lexpr.resolve tp r))\n\n/- Resovle an expression into a prop.\n\nN.B. This may do the wrong thing if the expression contains a\nnon-standard typeclass instance for a primitive type.\n-/\nmeta def prop.resolve : expr → string ⊕ prop\n| `(@eq.{1}    %%tp        %%l %%r) :=\n  prop.mk_bin prop.eq (type.resolve tp) l r\n| `(@ge        %%tp %%inst %%l %%r) := prop.mk_bin prop.ge (type.resolve tp) l r\n| `(@gt        %%tp %%inst %%l %%r) := prop.mk_bin prop.gt (type.resolve tp) l r\n| `(@has_le.le %%tp %%inst %%l %%r) := prop.mk_bin prop.ge (type.resolve tp) l r\n| `(@has_lt.lt %%tp %%inst %%l %%r) := prop.mk_bin prop.gt (type.resolve tp) l r\n| _ := sum.inl \"Unknown expr\"\n\nnamespace prop\n\nprotected\nmeta def to_string : prop → string\n| (eq tp l r) := \"eq \" ++ l.to_string ++ \" \" ++ r.to_string\n| (ge tp l r) := \"ge \" ++ l.to_string ++ \" \" ++ r.to_string\n| (gt tp l r) := \"gt \" ++ l.to_string ++ \" \" ++ r.to_string\n| (le tp l r) := \"le \" ++ l.to_string ++ \" \" ++ r.to_string\n| (lt tp l r) := \"lt \" ++ l.to_string ++ \" \" ++ r.to_string\n\nmeta instance : has_to_string prop := ⟨ prop.to_string ⟩\n\nend prop\n\n\nmeta def linear_solve : tactic unit := do\n  intros,\n  ctx ← local_context,\n  ctx_types ← ctx.mmap infer_type,\n  let pp (e : expr) : tactic unit := (do\n        match prop.resolve e with\n        | sum.inl msg :=\n           trace (msg ++ \"\\n\" ++ to_string e)\n        | (sum.inr p) := do\n          trace (to_string p)\n        end),\n  _ ← ctx_types.mmap pp,\n  t ← target,\n  match t with\n  | `(true) := do\n    trace (to_string (ctx.length)),\n    exact `(true.intro)\n  | _ := do\n    let i := ctx_types.index_of t,\n    if i < ctx.length then do\n      match ctx.nth i with\n      | (option.some pr) := exact pr\n      | option.none := fail \"ctx.nth failed\"\n      end\n    else trace \"nope\", pure ()\n  end\n\nexample (x y : ℕ) : x = 0 → x = 1 → y = 2 → y = 3 → x = 1 :=\nbegin\n  intro p,\n--  cc,\n\n  linear_solve,\n\nend\n\nend linear\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/arith.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.499909637432791}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\nSubtype of open subsets in a topological space.\n-/\nimport topology.bases topology.subset_properties topology.constructions\n\nopen filter lattice\nvariables {α : Type*} [topological_space α]\n\nnamespace topological_space\nvariable (α)\n/-- The type of open subsets of a topological space. -/\ndef opens := {s : set α // _root_.is_open s}\n\n/-- The type of closed subsets of a topological space. -/\ndef closeds := {s : set α // is_closed s}\n\n/-- The type of non-empty compact subsets of a topological space. The\nnon-emptiness will be useful in metric spaces, as we will be able to put\na distance (and not merely an edistance) on this space. -/\ndef nonempty_compacts := {s : set α // s ≠ ∅ ∧ compact s}\n\n\nsection nonempty_compacts\nopen topological_space set\nvariable {α}\n\ninstance nonempty_compacts.to_compact_space {p : nonempty_compacts α} : compact_space p.val :=\n⟨compact_iff_compact_univ.1 p.property.2⟩\n\ninstance nonempty_compacts.to_nonempty {p : nonempty_compacts α} : nonempty p.val :=\nnonempty_subtype.2 $ ne_empty_iff_exists_mem.1 p.property.1\n\n/-- Associate to a nonempty compact subset the corresponding closed subset -/\ndef nonempty_compacts.to_closeds [t2_space α] (s : nonempty_compacts α) : closeds α :=\n⟨s.val, closed_of_compact _ s.property.2⟩\n\nend nonempty_compacts\n\nvariable {α}\nnamespace opens\ninstance : has_coe (opens α) (set α) := { coe := subtype.val }\n\ninstance : has_subset (opens α) :=\n{ subset := λ U V, U.val ⊆ V.val }\n\ninstance : has_mem α (opens α) :=\n{ mem := λ a U, a ∈ U.val }\n\n\n@[extensionality] lemma ext {U V : opens α} (h : U.val = V.val) : U = V := subtype.ext.mpr h\n\ninstance : partial_order (opens α) := subtype.partial_order _\n\ndef interior (s : set α) : opens α := ⟨interior s, is_open_interior⟩\n\ndef gc : galois_connection (subtype.val : opens α → set α) interior :=\nλ U s, ⟨λ h, interior_maximal h U.property, λ h, le_trans h interior_subset⟩\n\ndef gi : @galois_insertion (order_dual (set α)) (order_dual (opens α)) _ _ interior (subtype.val) :=\n{ choice := λ s hs, ⟨s, interior_eq_iff_open.mp $ le_antisymm interior_subset hs⟩,\n  gc := gc.dual,\n  le_l_u := λ _, interior_subset,\n  choice_eq := λ s hs, le_antisymm interior_subset hs }\n\n@[simp] lemma gi_choice_val {s : order_dual (set α)} {hs} : (gi.choice s hs).val = s := rfl\n\ninstance : complete_lattice (opens α) :=\ncomplete_lattice.copy\n(@order_dual.lattice.complete_lattice _\n  (@galois_insertion.lift_complete_lattice\n    (order_dual (set α)) (order_dual (opens α)) _ interior (subtype.val : opens α → set α) _ gi))\n/- le  -/ (λ U V, U.1 ⊆ V.1) rfl\n/- top -/ ⟨set.univ, _root_.is_open_univ⟩ (subtype.ext.mpr interior_univ.symm)\n/- bot -/ ⟨∅, is_open_empty⟩ rfl\n/- sup -/ (λ U V, ⟨U.1 ∪ V.1, _root_.is_open_union U.2 V.2⟩) rfl\n/- inf -/ (λ U V, ⟨U.1 ∩ V.1, _root_.is_open_inter U.2 V.2⟩)\nbegin\n  funext,\n  apply subtype.ext.mpr,\n  symmetry,\n  apply interior_eq_of_open,\n  exact (_root_.is_open_inter U.2 V.2),\nend\n/- Sup -/ (λ Us, ⟨⋃₀ (subtype.val '' Us), _root_.is_open_sUnion $ λ U hU,\nby { rcases hU with ⟨⟨V, hV⟩, h, h'⟩, dsimp at h', subst h', exact hV}⟩)\nbegin\n  funext,\n  apply subtype.ext.mpr,\n  simp [Sup_range],\n  refl,\nend\n/- Inf -/ _ rfl\n\ninstance : has_inter (opens α) := ⟨λ U V, U ⊓ V⟩\ninstance : has_union (opens α) := ⟨λ U V, U ⊔ V⟩\ninstance : has_emptyc (opens α) := ⟨⊥⟩\n\n@[simp] lemma inter_eq (U V : opens α) : U ∩ V = U ⊓ V := rfl\n@[simp] lemma union_eq (U V : opens α) : U ∪ V = U ⊔ V := rfl\n@[simp] lemma empty_eq : (∅ : opens α) = ⊥ := rfl\n\n@[simp] lemma Sup_s {Us : set (opens α)} : (Sup Us).val = ⋃₀ (subtype.val '' Us) :=\nbegin\n  rw [@galois_connection.l_Sup (opens α) (set α) _ _ (subtype.val : opens α → set α) interior gc Us, set.sUnion_image],\n  congr\nend\n\ndef is_basis (B : set (opens α)) : Prop := is_topological_basis (subtype.val '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens α)} :\n  is_basis B ↔ ∀ {U : opens α} {x}, x ∈ U → ∃ U' ∈ B, x ∈ U' ∧ U' ⊆ U :=\nbegin\n  split; intro h,\n  { rintros ⟨sU, hU⟩ x hx,\n    rcases (mem_nhds_of_is_topological_basis h).mp (mem_nhds_sets hU hx) with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩,\n    refine ⟨V, H₁, _⟩,\n    cases V, dsimp at H₂, subst H₂, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU ⟨U, ⟨H₁, H₂⟩⟩, subst H₂, exact U.property },\n    { intros x sU hx hsU,\n      rcases @h (⟨sU, hsU⟩ : opens α) x hx with ⟨V, hV, H⟩,\n      exact ⟨V, ⟨V, hV, rfl⟩, H⟩ } }\nend\n\nlemma is_basis_iff_cover {B : set (opens α)} :\n  is_basis B ↔ ∀ U : opens α, ∃ Us ⊆ B, U = Sup Us :=\nbegin\n  split,\n  { intros hB U,\n    rcases sUnion_basis_of_is_open hB U.property with ⟨sUs, H, hU⟩,\n    existsi {U : opens α | U ∈ B ∧ U.val ∈ sUs},\n    split,\n    { intros U hU, exact hU.left },\n    { apply ext,\n      rw [Sup_s, hU],\n      congr,\n      ext s; split; intro hs,\n      { rcases H hs with ⟨V, hV⟩,\n        rw ← hV.right at hs,\n        refine ⟨V, ⟨⟨hV.left, hs⟩, hV.right⟩⟩ },\n      { rcases hs with ⟨V, ⟨⟨H₁, H₂⟩, H₃⟩⟩,\n        subst H₃, exact H₂ } } },\n  { intro h,\n    rw is_basis_iff_nbhd,\n    intros U x hx,\n    rcases h U with ⟨Us, hUs, H⟩,\n    replace H := congr_arg subtype.val H,\n    rw Sup_s at H,\n    change x ∈ U.val at hx,\n    rw H at hx,\n    rcases set.mem_sUnion.mp hx with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩,\n    refine ⟨V,hUs H₁,_⟩,\n    cases V with V hV,\n    dsimp at H₂, subst H₂,\n    refine ⟨hsV,_⟩,\n    change V ⊆ U.val, rw H,\n    exact set.subset_sUnion_of_mem ⟨⟨V, _⟩, ⟨H₁, rfl⟩⟩ }\nend\n\nend opens\n\nend topological_space\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/topology/opens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.49990963285362733}}
{"text": "import model4_c\nimport model_theory.satisfiability\n\nlemma not_iso_A_B : is_empty (first_order.language.equiv first_order.language.unary_preds (fin 3 × ℕ) (fin 2 × ℕ)) := \nbegin\n  rw is_empty_iff,\n  intro f,\n  induction f with fbij h₂ h₁,\n  simp at *,\n  have h₃ := h₁ (first_order.language.up₁),\n  specialize h₁ (first_order.language.up₂),\n\n  specialize h₃ ![(2, 1)],\n  specialize h₁ ![(2, 1)],\n  rw matrix.vec_single_eq_const at *,\n  simp at *,\n  rw ← function.const_def at *,\n  rw ← matrix.vec_single_eq_const at *,\n  rw ← matrix.vec_single_eq_const at *,\n  generalize eq₁ : (fbij (2, 1)) = x,\n  rw eq₁ at *,\n  induction x,\n  induction x_fst,\n  cases x_fst_val,\n  rw first_order.language.Structure.rel_map_apply₁ at *,\n  rw first_order.language.Structure.rel_map_apply₁ at *,\n  rw first_order.language.up₁ at *,\n  rw first_order.language.up₂ at *,\n  simp at *,\n  injections_and_clear,\n  norm_num at h_1,\n  cases x_fst_val,\n  rw first_order.language.Structure.rel_map_apply₁ at *,\n  rw first_order.language.Structure.rel_map_apply₁ at *,\n  rw first_order.language.up₁ at *,\n  rw first_order.language.up₂ at *,\n  simp at *,\n  injections_and_clear,\n  norm_num at *,\n  simp at *,\n  clear h₃ h₁ h₂,\n  rw nat.succ_lt_succ_iff at *,\n  rw nat.succ_lt_succ_iff at *,\n  linarith,\nend\n\nexample : ¬ (cardinal.categorical (cardinal.aleph_0) (first_order.language.Theory.disjoint_unary_preds)) := \nbegin\n  rw cardinal.categorical,\n  simp,\n  fconstructor,\n  use ModelA,\n  split,\n  rw ModelA,\n  simp,\n  exact modelAℵ₀,\n  use ModelB,\n  split,\n  exact modelBℵ₀,\n  exact not_iso_A_B,\nend", "meta": {"author": "koly777", "repo": "model4oxflean", "sha": "8a7c7eaff9cc4104ec7760e4d1668d4992635492", "save_path": "github-repos/lean/koly777-model4oxflean", "path": "github-repos/lean/koly777-model4oxflean/model4oxflean-8a7c7eaff9cc4104ec7760e4d1668d4992635492/model4_proofs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744584140003, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4998502857000484}}
{"text": "import tactic\nimport tactic.induction\n\nimport .base .bounded .lemma_2_1\n\nnoncomputable theory\nopen_locale classical\n\ndef A_trapped_in (pw : ℕ) (s : State) (N : ℕ) :=\n∀ (a : A pw) (d : D) (n : ℕ), ((init_game a d s).play n).s.board.A ∈ bounded N\n\ndef A_trapped (pw : ℕ) (s : State) :=\n∃ (N : ℕ), A_trapped_in pw s N\n\ndef can_entrap_in {pw : ℕ} (a : A pw) (d : D) (N : ℕ) :=\n∃ (n : ℕ), A_trapped_in pw (simulate a d n).s N\n\ndef D_nice_cond (pw : ℕ) (s : State) (n : ℕ) : Prop :=\nA_trapped_in pw s n ∧ ∃ (md : Valid_D_move s.board) (p : Point),\nmd.m = some p ∧ p ∈ bounded n\n\ndef D.nice (d : D) (pw : ℕ) :=\n∀ (s : State) (hs : s.act) (N : ℕ),\nif D_nice_cond pw s N\nthen ∃ (p : Point),\n  (d.f s hs).m = some p ∧\n  p ∈ bounded N\nelse ∀ (p : Point) (b : Board),\n  (d.f s hs).m = some p →\n  b ∈ s.history →\n  pw < dist p b.A\n\n-----\n\nlemma A_trapped_in_ge {pw n k : ℕ} {s : State}\n  (h₁ : A_trapped_in pw s k)\n  (h₂ : k ≤ n) :\n  A_trapped_in pw s n :=\nλ a d m, mem_bounded_ge (h₁ a d m) h₂\n\nlemma can_entrap_in_ge {pw n k : ℕ} {a : A pw} {d : D}\n  (h₁ : can_entrap_in a d k)\n  (h₂ : k ≤ n) :\n  can_entrap_in a d n :=\n⟨_, A_trapped_in_ge h₁.some_spec h₂⟩\n\nlemma D_nice_cond_ge {pw n k : ℕ} {s : State}\n  (h₁ : D_nice_cond pw s k)\n  (h₂ : k ≤ n) :\n  D_nice_cond pw s n :=\nbegin\n  obtain ⟨md, p, h₃, h₄⟩ := h₁.2,\n  exact ⟨A_trapped_in_ge h₁.1 h₂, _, _, h₃, mem_bounded_ge h₄ h₂⟩,\nend\n\nlemma mem_bounded_of_A_trapped_in {pw N : ℕ} {s : State}\n  (h : A_trapped_in pw s N) :\n  s.board.A ∈ bounded N :=\nh default default 0\n\nlemma mem_bounded_apply_D_move_of_A_trapped_in {pw N : ℕ}\n  {s : State} {md : D_move}\n  (h : A_trapped_in pw s N) :\n  (apply_D_move s md).board.A ∈ bounded N :=\nby { rw apply_D_move_A_eq, exact mem_bounded_of_A_trapped_in h }\n\nlemma mem_bounded_apply_A_move_of_A_trapped_in {pw N : ℕ}\n  {s s' : State} {ma : Valid_A_move pw s'.board} {md : Valid_D_move s.board}\n  (h₁ : A_trapped_in pw s N)\n  (h₂ : s' = apply_D_move s md.m) :\n  (apply_A_move s' ma.m).board.A ∈ bounded N :=\nbegin\n  specialize h₁ ((default : A pw).set_move s' ma) ((default : D).set_move s md) 1,\n  rw play_1 at h₁,\n  rw Game.play_move at h₁,\n  split_ifs at h₁ with h₃,\n  {\n    rw play_A_move_at at h₁,\n    rw dif_pos at h₁, swap,\n    {\n      clear h₁,\n      use h₃,\n      subst s',\n      use ma.m,\n      revert h₃,\n      simp,\n      intro h₃,\n      generalize_proofs,\n      sorry,\n      -- rw (_ : (init_game _ _ _).s = s),\n    },\n    sorry,\n  },\n  sorry,\nend\n\n#exit\n\nlemma squares_in_bounded_exc_A_lt_bounded_area_of_A_trapped_in\n  {pw N : ℕ} {s : State}\n  (h : A_trapped_in pw s N) :\n  squares_in_bounded_exc_A s.board N < bounded_area N :=\nbegin\n  have h₃ := mem_bounded_of_A_trapped_in h,\n  rw [squares_in_bounded_exc_A, bounded_area],\n  apply finset.card_lt_card, rw finset.ssubset_iff,\n  use s.board.A, fsplit,\n  { simp },\n  { rintro p hp, rw finset.mem_insert at hp,\n    rw set.mem_to_finset, cases hp,\n    { subst p, exact h₃ },\n    { rw [finset.mem_filter, set.mem_to_finset] at hp, exact hp.1 }},\nend\n\nlemma A_trapped_in_play_move {pw N : ℕ} {g : Game pw}\n  (h : A_trapped_in pw g.s N) :\n  A_trapped_in pw g.play_move.s N :=\nbegin\n  sorry\nend\n\nlemma nice_D_wins_upper_bound_of_A_trapped_in {pw N : ℕ}\n  {a : A pw} {d : D} {s₀ : State}\n  (h₀ : valid_state pw s₀)\n  (h₁ : d.nice pw)\n  (h₂ : A_trapped_in pw s₀ N) :\n  ¬((init_game a d s₀).play (bounded_area N)).act :=\nbegin\n  apply not_act_of_descend_play_move_valid\n    (λ (s : State), squares_in_bounded_exc_A s.board N)\n    (λ (s : State), A_trapped_in pw s N); try { dsimp },\n  sorry {\n    exact h₀,\n  },\n  sorry {\n    exact squares_in_bounded_exc_A_lt_bounded_area_of_A_trapped_in h₂,\n  },\n  sorry {\n    exact h₂,\n  },\n  sorry {\n    rintro s hv hs₁ h₃,\n    exact A_trapped_in_play_move h₃,\n  },\n  {\n    rintro s hv hs₁ h₃,\n    obtain ⟨s', hs, hs', hvm, h₄, h₅⟩ := play_move_state_eq_of_act_play_move hs₁,\n    rw h₅, clear h₅,\n    simp only [init_game_a_eq, init_game_d_eq, init_game_s_eq] at *,\n    rw (_ : squares_in_bounded_exc_A (apply_A_move _ _).board N =\n      squares_in_bounded_exc_A s'.board N), swap,\n    {\n      simp_rw squares_in_bounded_exc_A,\n      let ma : Valid_A_move pw s'.board := _,\n      change (a.f s' hs' hvm) with ma,\n      let t : finset Point := _,\n      change _ = t.card,\n      have hma₁ : ma.m ∈ bounded N,\n      {\n        sorry\n      },\n      have hma₂ : ma.m ∈ s'.board.squares,\n      sorry,\n      have hma₃ : ma.m ≠ s'.board.A,\n      sorry,\n      have h₅ : ma.m ∈ t,\n      sorry {\n        rw [finset.mem_filter, set.mem_to_finset],\n        exact ⟨hma₁, hma₂, hma₃⟩,\n      },\n      have h₆ : s'.board.A ∉ t,\n      sorry {\n        rw finset.mem_filter,\n        simp,\n      },\n      convert finset_card_insert_erase_eq h₅ h₆,\n      ext p,\n      simp_rw [finset.mem_filter, finset.mem_insert,\n        set.mem_to_finset, finset.mem_erase],\n      change (apply_A_move s' ma.m).board.A with ma.m,\n      change (apply_A_move s' ma.m).board.squares with s'.board.squares,\n      by_cases h₇ : p = ma.m,\n      sorry {\n        subst p,\n        simp,\n        exact ma.h.1,\n      },\n      {\n        simp only [true_and, and_true, set.mem_to_finset, ne.def, not_false_iff,\n          finset.mem_filter, h₇],\n        split; intro h₈,\n        sorry {\n          tauto,\n        },\n        {\n          change _ ≠ _ at h₇,\n          cases h₈,\n          {\n            clear h₇,\n            subst h₈,\n            fsplit,\n            sorry {\n              subst s',\n              exact mem_bounded_apply_D_move_of_A_trapped_in h₃,\n            },\n            {\n              sorry -- valid_state pw s\n            },\n          },\n          sorry {\n            tauto,\n          },\n        },\n      },\n    },\n    sorry -- because nice D eats one non-A square from `Bounded N`\n  },\nend\n\n#exit\n\nlemma nice_D_wins_of_can_entrap_in {pw N : ℕ} {a : A pw} {d : D}\n  (h₁ : d.nice pw)\n  (h₂ : can_entrap_in a d N) :\n  (init_game a d state₀).D_wins :=\nbegin\n  cases h₂ with n h₂, suffices h₃ : ∃ (k : ℕ), ¬(simulate a d (n + k)).act,\n  { exact ⟨_, h₃.some_spec⟩ },\n  simp_rw simulate_add,let g : Game pw := _,\n  change simulate a d n with g at h₂ ⊢, split,\n  rw (_ : g = init_game a d g.s), swap,\n  { ext,\n    { exact play_at_players_eq.1 },\n    { exact play_at_players_eq.2 },\n    { refl }},\n  exact nice_D_wins_upper_bound_of_A_trapped_in h₁ h₂,\nend\n\nlemma lem_2_3 {pw : ℕ}\n  (h : ∃ (N : ℕ) (d : D), d.nice pw ∧ ∀ (a : A pw), can_entrap_in a d N) :\n  ∃ (d : D), d.nice pw ∧ ∀ (a : A pw), (init_game a d state₀).D_wins :=\nbegin\n  rcases h with ⟨N, d, h₁, h₂⟩, use [d, h₁], intro a,\n  specialize h₂ a, exact nice_D_wins_of_can_entrap_in h₁ h₂,\nend\n\nlemma lem_2_3' {pw : ℕ}\n  (h : ∃ (a : A pw), ∀ (d : D) (N : ℕ), d.nice pw →\n  ¬A_trapped_in_for a d (bounded N)) :\n  ∃ (a : A pw), ∀ (d : D), d.nice pw → (init_game a d state₀).A_wins :=\nbegin\n  cases h with a h, use a, rintro d h₁, specialize h d,\n  replace h : ∀ (N : ℕ), ¬A_trapped_in_for a d (bounded N),\n  { intro n, exact h n h₁ },\n  intro n, contrapose! h, use n * pw, intro k, by_cases h₂ : k ≤ n,\n  { exact A_bounded_n_pw h₂ },\n  { change ¬(simulate a d n).act at h, have h₃ : ¬(simulate a d k).act,\n    { contrapose! h, push_neg at h₂, obtain ⟨k, rfl⟩ := nat.exists_eq_add_of_lt h₂,\n      rw add_assoc at h, rw [simulate, play_add] at h, apply act_of_act_play h },\n    have h₄ : simulate a d k = simulate a d n,\n    { exact play_eq_of_not_act h₃ h },\n    rw h₄, apply A_bounded_n_pw, refl },\nend", "meta": {"author": "user7230724", "repo": "lean-projects", "sha": "ab9a83874775efd18f8c5b867e480bae4d596b31", "save_path": "github-repos/lean/user7230724-lean-projects", "path": "github-repos/lean/user7230724-lean-projects/lean-projects-ab9a83874775efd18f8c5b867e480bae4d596b31/src/ap/nice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867825403177, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.4997640536296726}}
{"text": "import algebra.ring group_theory.submonoid ring_theory.ideal_operations linear_algebra.basic\nimport ring_theory.localization\n\nnamespace localization_alt\n\nuniverses u v w\nvariables {A : Type u} {B : Type v} {C : Type w} \nvariables [comm_ring A] [comm_ring B] [comm_ring C]\nvariables (S : set A) [is_submonoid S] (f : A → B) [is_ring_hom f]\n\n/- This is essentially the same logic as units.ext, but in more \n   convenient form.\n-/\nlemma comm_monoid.inv_unique {M : Type*} [comm_monoid M]\n  {a ai₁ ai₂ : M} (e₁ : a * ai₁ = 1) (e₂ : a * ai₂ = 1) : ai₁ = ai₂ :=\nby rw [← mul_one ai₁, ← e₂, ← mul_assoc, mul_comm ai₁, e₁, one_mul]\n\n/-- preserve definitional equality -/\ndef ideal.mk (I : set A) (J : ideal A) (H : I = J) : ideal A :=\n{ carrier := I,\n  zero := H.symm ▸ J.zero,\n  add := H.symm ▸ J.add,\n  smul := H.symm ▸ J.smul }\n\ndef ker : ideal A :=\nideal.mk {x | f x = 0} (ideal.comap f ⊥) $\nset.ext $ λ x, (submodule.mem_bot B).symm--(submodule.mem_bot _).symm\n\ndef inverts_data (S : set A) (f : A → B) : Type* :=\nΠ s : S, {si : B // (f s) * si = 1}\n\ndef inverts (S : set A) (f : A → B) : Prop := \n∀ s : S, ∃ si : B, (f s) * si = 1\n\nlemma inverts_subsingleton (S : set A) (f : A → B) :\n  subsingleton (inverts_data S f) :=\n⟨λ fi1 fi2, funext $ λ s, subtype.eq $ comm_monoid.inv_unique (fi1 s).2 (fi2 s).2⟩\n\ndef inverts_of_data (h : inverts_data S f) : inverts S f :=\nλ s, ⟨(h s).1,(h s).2⟩\n\nnoncomputable def inverts_some (h : inverts S f) : inverts_data S f :=\nλ s, classical.indefinite_description _ (h s)\n\ndef has_denom_data (S : set A) (f : A → B) :=\nΠ b : B, {sa : S × A // (f sa.1) * b = f sa.2 }\n\ndef has_denom (S : set A) (f : A → B) : Prop :=\n∀ b : B, ∃ (sa : S × A), (f sa.1) * b = (f sa.2)\n\ndef has_denom_of_data (h : has_denom_data S f) : has_denom S f :=\nλ b, subtype.exists_of_subtype (h b)\n\nnoncomputable def has_denom_some (h : has_denom S f) : has_denom_data S f := \nλ b, classical.indefinite_description _ (h b)\n\ndef ann_aux (S : set A) [is_submonoid S] : Type* :=\n{ as : A × S // as.1 * as.2 = 0 }\n\nnamespace ann_aux\n\ndef zero : ann_aux S := ⟨(0, 1), mul_one _⟩\n\ndef add (as bt : ann_aux S) : ann_aux S :=\n⟨(as.1.1 + bt.1.1, as.1.2 * bt.1.2), show (as.1.1 + bt.1.1) * (as.1.2 * bt.1.2) = 0,\nby rw [add_mul, ← mul_assoc, as.2, zero_mul, zero_add, mul_left_comm, bt.2, mul_zero]⟩\n\ndef smul (a : A) (bt : ann_aux S) : ann_aux S :=\n⟨(a * bt.1.1, bt.1.2), show (a * bt.1.1) * bt.1.2 = 0, by rw [mul_assoc, bt.2, mul_zero]⟩\n\nend ann_aux\n\ndef submonoid_ann (S : set A) [is_submonoid S] : ideal A :=\n{ carrier := set.range (λ as : ann_aux S, as.1.1),\n  zero := ⟨ann_aux.zero S, rfl⟩,\n  add := λ _ _ ⟨as,has⟩ ⟨bt,hbt⟩, ⟨ann_aux.add S as bt, has ▸ hbt ▸ rfl⟩,\n  smul := λ a _ ⟨bt,h⟩, ⟨ann_aux.smul S a bt, h ▸ rfl⟩ }\n\nlemma inverts_ker (hf : inverts S f) : submonoid_ann S ≤ ker f :=\nλ x ⟨⟨⟨a,s⟩,asz⟩,rfl⟩, let ⟨si,e1⟩ := hf s in show f x = 0,\nby rw [← mul_one (f x), ← e1, ← mul_assoc, ← is_ring_hom.map_mul f, asz, is_ring_hom.map_zero f, zero_mul]\n\nstructure is_localization_data :=\n(inverts : inverts_data S f)\n(has_denom : has_denom_data S f)\n(ker_le : ker f ≤ submonoid_ann S)\n\ndef is_localization : Prop :=\n(inverts S f) ∧ (has_denom S f) ∧ (ker f = submonoid_ann S)\n\nlemma localization_epi (hf : is_localization S f)\n  (g₁ g₂ : B → C) [is_ring_hom g₁] [is_ring_hom g₂] \n  (e : g₁ ∘ f = g₂ ∘ f) : g₁ = g₂ := \nbegin\n  have e' : ∀ x, g₁ (f x) = g₂ (f x) := λ x, by convert congr_fun e x,\n  ext b,\n  rcases hf.2.1 b with ⟨⟨s,a⟩,e1⟩,\n  rcases hf.1 s with ⟨si,e2⟩,\n  have e4 : g₁ (f s) * (g₁ si) = 1,\n  { rw [← is_ring_hom.map_mul g₁, e2, is_ring_hom.map_one g₁] },\n  have e5 : g₁ (f s) * (g₂ si) = 1,\n  { rw [e', ← is_ring_hom.map_mul g₂, e2, is_ring_hom.map_one g₂] },\n  rw [← mul_one b, ← e2, mul_left_comm, ← mul_assoc, e1],\n  rw [is_ring_hom.map_mul g₁, is_ring_hom.map_mul g₂, e', comm_monoid.inv_unique e4 e5]\nend\n\nsection localization_initial \nvariables (hf : is_localization_data S f) (g : A → C) [is_ring_hom g] (hg : inverts_data S g)\n\ndef is_localization_initial (hf : is_localization_data S f)\n  (g : A → C) [is_ring_hom g] (hg : inverts_data S g) : B → C :=\nλ b, g (hf.has_denom b).1.2 * hg (hf.has_denom b).1.1\n\nlemma useful (hf : is_localization_data S f) (g : A → C) [is_ring_hom g] (hg : inverts_data S g)\n  {a₁ a₂ : A} (H : f a₁ = f a₂) : g a₁ = g a₂ :=\nbegin\n  rw [← sub_eq_zero, ← is_ring_hom.map_sub f] at H,\n  rw [← sub_eq_zero, ← is_ring_hom.map_sub g],\n  generalize_hyp : a₁ - a₂ = a at H ⊢,\n  rcases hf.3 H with ⟨⟨as,h1⟩,h2⟩,\n  rw [← h2],\n  cases hg as.2 with c h3,\n  rw [← mul_one (g as.1), ← h3, ← mul_assoc, ← is_ring_hom.map_mul g, h1, is_ring_hom.map_zero g, zero_mul]\nend\n\nlemma useful2 {x y z w : A} (h : x * y = 1) : z * x = w * x ↔ z = w :=\n⟨λ H, have _ := congr_arg (* y) H, by rwa [mul_assoc, h, mul_one, mul_assoc, h, mul_one] at this,\nλ H, by rw H⟩\n\ninstance (hf : is_localization_data S f) (g : A → C) [is_ring_hom g] (hg : inverts_data S g) :\n  is_ring_hom (is_localization_initial S f hf g hg) :=\n{ map_one := begin\n    unfold is_localization_initial,\n    rcases hf.has_denom 1 with ⟨⟨s,a⟩,h⟩,\n    dsimp only at *,\n    rw mul_one at h, replace h := useful S f hf g hg h,\n    cases hg s with c hc,\n    rw ← h, exact hc\n  end,\n  map_mul := λ x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with ⟨⟨sx,ax⟩,h1⟩,\n    rcases hf.has_denom y with ⟨⟨sy,ay⟩,h2⟩,\n    rcases hf.has_denom (x*y) with ⟨⟨sxy,axy⟩,h3⟩,\n    cases hg sx with sigx h4,\n    cases hg sy with sigy h5,\n    cases hg sxy with sigxy h6,\n    cases hf.inverts sx with sifx h7,\n    cases hf.inverts sy with sify h8,\n    cases hf.inverts sxy with sifxy h9,\n    dsimp only [subtype.coe_mk] at *,\n    replace h1 : _ * _ = _ * _ := by convert congr_arg (* sifx) h1,\n    rw [mul_right_comm, h7, one_mul] at h1,\n    replace h2 : _ * _ = _ * _ := by convert congr_arg (* sify) h2,\n    rw [mul_right_comm, h8, one_mul] at h2,\n    rw [h1, h2] at h3,\n    rw [← useful2 h4, ← useful2 h5, ← useful2 h6],\n    have : g axy * sigxy * g ↑sx * g ↑sy * g ↑sxy = g axy * g ↑sx * g ↑sy * (g ↑sxy * sigxy),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h6, mul_one], clear this,\n    have : g ax * sigx * (g ay * sigy) * g ↑sx * g ↑sy * g ↑sxy = g ax * g ay * g ↑sxy * (g ↑sx * sigx) * (g ↑sy * sigy),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h4, h5, mul_one, mul_one], clear this,\n    iterate 4 { rw ← is_ring_hom.map_mul g }, apply useful S f hf g hg,\n    iterate 4 { rw is_ring_hom.map_mul f }, rw ← h3,\n    have : f ↑sxy * (f ax * sifx * (f ay * sify)) * f ↑sx * f ↑sy = f ax * f ay * f ↑sxy * (f ↑sx * sifx) * (f ↑sy * sify),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h7, h8, mul_one, mul_one]\n  end,\n  map_add := λ x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with ⟨⟨sx,ax⟩,h1⟩,\n    rcases hf.has_denom y with ⟨⟨sy,ay⟩,h2⟩,\n    rcases hf.has_denom (x+y) with ⟨⟨sxy,axy⟩,h3⟩,\n    cases hg sx with sigx h4,\n    cases hg sy with sigy h5,\n    cases hg sxy with sigxy h6,\n    cases hf.inverts sx with sifx h7,\n    cases hf.inverts sy with sify h8,\n    cases hf.inverts sxy with sifxy h9,\n    dsimp only [subtype.coe_mk] at *,\n    replace h1 : _ * _ = _ * _ := by convert congr_arg (* sifx) h1,\n    rw [mul_right_comm, h7, one_mul] at h1,\n    replace h2 : _ * _ = _ * _ := by convert congr_arg (* sify) h2,\n    rw [mul_right_comm, h8, one_mul] at h2,\n    rw [h1, h2] at h3,\n    rw [← useful2 h4, ← useful2 h5, ← useful2 h6],\n    have : g axy * sigxy * g ↑sx * g ↑sy * g ↑sxy = g axy * g ↑sx * g ↑sy * (g ↑sxy * sigxy),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h6, mul_one], clear this,\n    have : (g ax * sigx + g ay * sigy) * g ↑sx * g ↑sy * g ↑sxy =\n      g ax * g ↑sy * g ↑sxy * (g ↑sx * sigx) + g ay * g ↑sx * g ↑sxy * (g ↑sy * sigy),\n    { simp only [add_mul, mul_add, mul_assoc, mul_comm, mul_left_comm] }, rw [this, h4, h5, mul_one, mul_one], clear this,\n    iterate 6 { rw ← is_ring_hom.map_mul g }, rw ← is_ring_hom.map_add g, apply useful S f hf g hg,\n    rw is_ring_hom.map_add f, iterate 6 { rw is_ring_hom.map_mul f }, rw ← h3,\n    have : f ↑sxy * (f ax * sifx + f ay * sify) * f ↑sx * f ↑sy =\n      f ax * f ↑sy * f ↑sxy * (f ↑sx * sifx) + f ay * f ↑sx * f ↑sxy * (f ↑sy * sify),\n    { simp only [add_mul, mul_add, mul_assoc, mul_comm, mul_left_comm] }, rw [this, h7, h8, mul_one, mul_one]\n  end }\n\nlemma is_localization_initial_comp (hf : is_localization_data S f)\n  (g : A → C) [is_ring_hom g] (hg : inverts_data S g) (a : A) :\n  is_localization_initial S f hf g hg (f a) = g a :=\nbegin\n  unfold is_localization_initial,\n  rcases hf.has_denom (f a) with ⟨⟨s,x⟩,h1⟩,\n  cases hg s with si h2,\n  dsimp only [subtype.coe_mk] at *,\n  rw [← useful2 h2, mul_right_comm, mul_assoc, h2, mul_one, ← is_ring_hom.map_mul g],\n  apply useful S f hf g hg,\n  rw [← h1, is_ring_hom.map_mul f, mul_comm]\nend\n\nend localization_initial\n\nend localization_alt\n\n-- Now applications\n\n/- https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/cardinality.20of.20integers.20modulo.20n/near/155197619\n\nHere are some basic test cases:\n1. Can we identity A[a−1][b−1]A[a^{-1}][b^{-1}]A[a−1][b−1] with A[(ab)−1]A[(ab)^{-1}]A[(ab)−1]?\n2. If e2=ee^2=ee2=e, can we identify A[e−1]A[e^{-1}]A[e−1] with A/(1−e)A/(1-e)A/(1−e)?\n3. If we define Z(p)\\mathbb{Z}_{(p)}Z(p)​ as a subring of Q\\mathbb{Q}Q, can we produce the ring map Z(p)→Z/p\\mathbb{Z}_{(p)}\\to\\mathbb{Z}/pZ(p)​→Z/p?\nI think that all of the maps implicit in these examples should be computable under very mild assumptions.\n\n1) R[1/f][1/g]=R[1/fg]\n2) If e^2=e then is R[1/e]=R/(1-e)\n3) Z_{(p)} -> Z/pZ if Z_{(p)} is a sub of Q?\n\nReid said: \n\nThe test case would be to prove that a composition of is_localization maps is is_localization\n  19:32\n\nwhich should be easy with the universal property\n\n-/\n--lemma loc_loc (A : Type*) [comm_ring A] [f g : A] : \n\nlemma invert_powers_of_invert {A B : Type*} [comm_ring A] [comm_ring B]\n  {f : A → B} [is_ring_hom f] {a : A}\n{b : B} (hb : f a * b = 1) : localization_alt.inverts (powers a) f :=\nbegin\n rintro ⟨z,n,h⟩,\n use b ^ n,\n show f z * b ^ n = 1,\n rw [←h, is_semiring_hom.map_pow f, ←mul_pow, hb, one_pow],\nend\n\nexample {R : Type*} [comm_ring R] (e : R) (he : e * e = e) : localization_alt.is_localization (powers e) (ideal.quotient.mk (ideal.span {1-e})) :=\nbegin\n  have H1 : ideal.quotient.mk (ideal.span {1 - e}) e = 1,\n  { exact eq.symm (ideal.quotient.eq.2 $ ideal.subset_span $ or.inl rfl) },\n  have H2 : (1 - e) * e = 0,\n  { rw [sub_mul, he, one_mul, sub_self] },\n  refine ⟨_, _, _⟩,\n  { rintros ⟨_, n, rfl⟩, use 1,\n    change ideal.quotient.mk _ (e^n * 1) = _,\n    rw [mul_one, is_semiring_hom.map_pow (ideal.quotient.mk (ideal.span {1-e})) e n, H1, one_pow] },\n  { rintro ⟨x⟩, use (1,x), exact one_mul _ },\n  { ext x, split; intro hx,\n    { replace hx := ideal.quotient.eq_zero_iff_mem.1 hx,\n      replace hx := ideal.mem_span_singleton'.1 hx,\n      refine ⟨⟨(x, ⟨e, 1, pow_one e⟩), _⟩, rfl⟩,\n      cases hx with y hx, change x * e = 0, rw [← hx, mul_assoc, H2, mul_zero] },\n    { rcases hx with ⟨⟨⟨x, ⟨_, n, rfl⟩⟩, hx⟩, rfl⟩, change x * e^n = 0 at hx,\n      apply ideal.quotient.eq_zero_iff_mem.2,\n      apply ideal.mem_span_singleton'.2,\n      change ∃ a, a * (1-e) = x, induction n with n ih generalizing x,\n      { rw [pow_zero, mul_one] at hx, subst hx, use 0, rw zero_mul },\n      rw [pow_succ, ← mul_assoc] at hx, cases ih _ hx with y hy,\n      use x + y, rw [add_mul, hy, ← mul_add, sub_add_cancel, mul_one] } },\nend\n\ndef Z_loc_p {p : ℕ} (hp : nat.prime p) : Type := {q : ℚ // rat.denom q % p ≠ 0 }\n\nnamespace Z_loc_p\n\nprotected def zero {p : ℕ} (hp : nat.prime p) : Z_loc_p hp := ⟨(0 : ℚ),begin\n  show 1 % p ≠ 0,\n  rw nat.mod_eq_of_lt, simp,\n  exact hp.1,\nend⟩\n\nend Z_loc_p", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/canonical_isomorphism/localization_pred.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867873410141, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4997640454983952}}
{"text": "/-\nCopyright (c) 2017 Daniel Selsam. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Daniel Selsam\n\nMiscellaneous facts and theorems about tensors.\n\nWe view tensors as a field extended component-wise.  As such, they\nform an ordered (but not linearly-ordered) commutative ring.  They\nalso have division, except the precondition for cancellation is not `x\n≠ 0` but `|x| > 0`, which we simplify to `x > 0`.\n\nNote: the axioms are by no means minimal.\n-/\nimport .tensor .id .reference .env .dvec\n\n-- TODO(dhs): move these elsewhere once #1659 is resolved.\nattribute [congr] dif_ctx_simp_congr\nattribute [simp] dif_pos dif_neg\n\nnamespace certigrad\n\nnamespace T\nopen list\n\naxiom const_scalar : ∀ (α : ℝ), const α [] = α\nattribute [simp] const_scalar\n\naxiom const_mul {shape : S} : Π (α β : ℝ), const (α * β) shape = const α shape * const β shape\naxiom const_neg {shape : S} : Π (α : ℝ), const (- α) shape = - const α shape\naxiom const_inv {shape : S} : Π (α : ℝ), const α⁻¹ shape = (const α shape)⁻¹\n\naxiom const_zero {shape : S} : const 0 shape = 0\naxiom const_one {shape : S} : const 1 shape = 1\naxiom const_bit0 {shape : S} : Π (α : ℝ), const (bit0 α) shape = bit0 (const α shape)\naxiom const_bit1 {shape : S} : Π (α : ℝ), const (bit1 α) shape = bit1 (const α shape)\n\n--attribute [simp] const_mul const_neg const_inv const_zero const_one const_bit0 const_bit1\n\n-- Module structure\naxiom smul.def (α : ℝ) (shape : S) (x : T shape) : α ⬝ x = const α shape * x\naxiom smul_neg (α : ℝ) : ∀ {shape : S} (x : T shape), α ⬝ (- x) = - (α ⬝ x)\naxiom smul_addr (α : ℝ) : ∀ (shape : S) (x y : T shape), α ⬝ (x + y) = α ⬝ x + α ⬝ y\naxiom smul_addl (α β : ℝ) : ∀ (shape : S) (x : T shape), (α + β) ⬝ x = α ⬝ x + β ⬝ x\naxiom smul_group (α β : ℝ) : ∀ (shape : S) (x : T shape), (α * β) ⬝ x = α ⬝ (β ⬝ x)\naxiom smul_flip (α β : ℝ) : ∀ (shape : S) (x : T shape), α ⬝ (β ⬝ x) = β ⬝ (α ⬝ x)\naxiom one_smul : ∀ (shape : S) (x : T shape), (1 : ℝ) ⬝ x = x\n\naxiom smul_zero (α : ℝ) : ∀ (shape : S), α ⬝ (0 : T shape) = 0\naxiom zero_smul : ∀ (shape : S) (x : T shape), (0 : ℝ) ⬝ x = 0\naxiom smul_mul_scalar_right (α : ℝ) : ∀ (x y : ℝ), α ⬝ (x * y) = x ⬝ (α ⬝ y)\naxiom smul_mul₁ (α : ℝ) : ∀ {shape : S} (x y : T shape), y * (α ⬝ x) = α ⬝ (x * y)\naxiom smul_mul₂ (α : ℝ) : ∀ {shape : S} (x y : T shape), (α ⬝ x) * y = α ⬝ (x * y)\naxiom smul_comm (α β : ℝ) : α ⬝ β = β ⬝ α\naxiom smul_sum {shape : S} (α : ℝ) (x : T shape) : α ⬝ sum x = sum (α ⬝ x)\naxiom smul_div {shape : S} (α : ℝ) (x y : T shape) : α ⬝ (x / y) = (α ⬝ x) / y\naxiom smul_scale : ∀ (α : ℝ) (shape : S) (x : T shape), (α ⬝ 1) * x = α ⬝ x\naxiom smul_scalar : ∀ (α x : ℝ), (α ⬝ x) = α * x\n\n-- sum\naxiom sum_empty_vec (x : T [0]) : sum x = 0\naxiom sum_mat_no_cols {nrows : ℕ} (x : T [nrows, 0]) : sum x = 0\naxiom sum_zero : Π {shape : S}, sum (0 : T shape) = 0\naxiom sum_add {shape : S} (x y : T shape) : sum (x + y) = sum x + sum y\naxiom sum_neg {shape : S} (x : T shape) : sum (- x) = - (sum x)\naxiom sum_smul {shape : S} (α : ℝ) (x : T shape) : sum (α ⬝ x) = α * sum x\n\n-- Misc\naxiom sqrt_mul {shape : S} : ∀ (x y : T shape), sqrt (x * y) = sqrt x * sqrt y\naxiom sqrt_square {shape : S} : ∀ (x : T shape), sqrt (square x) = x\naxiom prod_mul {shape : S} : ∀ (x y : T shape), prod (x * y) = prod x * prod y\naxiom mul_inv_pos {shape : S} : ∀ {x y : T shape}, x > 0 → y > 0 → (x * y)⁻¹ = x⁻¹ * y⁻¹\naxiom inv_mul_cancel {shape : S} : ∀ {x : T shape}, x > 0 → (x⁻¹ * x) = 1\naxiom mul_inv_cancel {shape : S} : ∀ {x : T shape}, x > 0 → (x * x⁻¹) = 1\naxiom div_one {shape : S} : ∀ {x : T shape}, x / 1 = x\naxiom log_one {shape : S} : log (1 : T shape) = (0 : T shape)\naxiom log_const {shape : S} (α : ℝ) : log (const α shape) = const (log α) shape\naxiom exp_inv {shape : S} (x : T shape) : (exp x)⁻¹ = exp (- x)\naxiom neg_div : ∀ {shape : S} {x y : T shape}, -x / y = -(x / y)\naxiom log_prod : ∀ {shape : S} {x : T shape}, x > 0 → log (prod x) = sum (log x)\naxiom log_mul : ∀ {shape : S} {x y : T shape}, x > 0 → y > 0 → log (x * y) = log x + log y\naxiom log_exp : ∀ {shape : S} {x : T shape}, log (exp x) = x\naxiom log_sqrt : ∀ {shape : S} {x : T shape}, log (sqrt x) = 2⁻¹ * log x\naxiom log_inv : ∀ {shape : S} {x : T shape}, log (x⁻¹) = - log x\n\n-- Signs\naxiom nz_of_pos {shape : S} : ∀ {x : T shape}, x > 0 → x ≠ 0\naxiom nz_of_div {shape : S} : ∀ {x y : T  shape}, x ≠ 0 → y ≠ 0 → x / y ≠ 0\naxiom nz_iff {shape : S} : ∀ {x : T shape}, x ≠ 0 ↔ x > 0 ∨ x < 0\naxiom nneg_of_pos {shape : S} : ∀ {x : T shape}, x > 0 → x ≥ 0\naxiom sqrt_pos {shape : S} : ∀ {x : T shape}, x > 0 → sqrt x > 0\naxiom pos_of_sqrt_pos {shape : S} : ∀ {x : T shape}, sqrt x > 0 → x > 0\naxiom square_nneg {shape : S} : ∀ {x : T shape}, square x ≥ 0\naxiom square_pos_of_pos {shape : S} : ∀ {x : T shape}, 0 < x → 0 < square x\naxiom square_pos_of_neg {shape : S} : ∀ {x : T shape}, x < 0 → 0 < square x\naxiom exp_pos {shape : S} : ∀ {x : T shape}, exp x > 0\naxiom sigmoid_pos {shape : S} : ∀ {x : T shape}, sigmoid x > 0\naxiom sigmoid_lt1 {shape : S} : ∀ {x : T shape}, sigmoid x < 1\naxiom lt1_alt {shape : S} : ∀ {x : T shape}, x < 1 → 0 < 1 - x\naxiom one_plus_pos {shape : S} : ∀ {x : T shape}, x > 0 → 1 + x > 0\naxiom one_plus_pos_iff {shape : S} : ∀ {x : T shape}, 0 < 1 + x ↔ (- 1 < x)\naxiom plus_one_pos {shape : S} : ∀ {x : T shape}, x > 0 → x + 1 > 0\naxiom one_pos {shape : S} : (1 : T shape) > 0\naxiom neg_of_pos {shape : S} {x : T shape} : x > 0 → - x < 0\naxiom const_pos_of_pos {shape : S} {x : ℝ} : x > 0 → const x shape > 0\naxiom mul_pos_of_pos_pos {shape : S} {x y : T shape} : x > 0 → y > 0 → x * y > 0\naxiom eps_pos {shape : S} : eps shape > 0\naxiom pi_pos {shape : S} : pi shape > 0\naxiom inv_pos {shape : S} {x : T shape} : x > 0 → x⁻¹ > 0\naxiom div_pos_pos {shape : S} {x y : T shape} : x > 0 → y > 0 → x / y > 0\naxiom add_pos_of_pos_pos {shape : S} {x y : T shape} : x > 0 → y > 0 → x + y > 0\nlemma two_pos {shape : S} : (2 : T shape) > 0 := one_plus_pos one_pos\nlemma two_pi_pos {shape : S} : 2 * pi shape > 0 := mul_pos_of_pos_pos two_pos pi_pos\nlemma msigmoid_pos {shape : S} {x : T shape} : 0 < 1 - sigmoid x := lt1_alt sigmoid_lt1\n\n-- div\naxiom div_mul_cancel {shape : S} : ∀ {x y : T shape}, y > 0 → (x / y) * y = x\naxiom div_div_eq_div_mul {shape : S} : ∀ (x y z : T shape), (x / y) / z = x / (y * z)\naxiom div_mul_div {shape : S} : ∀ (x y z w : T shape), (x / y) * (z / w) = (x * z) / (y * w)\naxiom mul_div_mul {shape : S} : ∀ (x y z : T shape), x * (y / z) = (x / z) * y\naxiom mul_div_mul_alt {shape : S} : ∀ (x y z : T shape), x * (y / z) = (x * y / z)\naxiom one_div_inv {shape : S} : ∀ (x : T shape), 1 / x = x⁻¹\naxiom div_mul_inv {shape : S} : ∀ (x y : T shape), x / y = x * y⁻¹\naxiom div_self {shape : S} : ∀ {x : T shape}, x > 0 → x / x = 1\naxiom square_div {shape : S} : ∀ {x y : T shape}, square (x / y) = square x / square y\n\naxiom div_add_div_same {shape : S} (x y z : T shape) : x / z + y / z = (x + y) / z\nlemma div_add_div_same_symm {shape : S} (x y z : T shape) : (x + y) / z = x / z + y / z := by rw div_add_div_same\nlemma div_sub_div_same {shape : S} (x y z : T shape) : x / z - y / z = (x - y) / z := by simp [T.div_add_div_same_symm, neg_div]\nlemma div_sub_div_same_symm {shape : S} (x y z : T shape) : (x - y) / z = x / z - y / z := by rw div_sub_div_same\nlemma div_self_square {shape : S} {x : T shape} (H_pos : x > 0) : x / (x * x)= x⁻¹ :=\ncalc  x / (x * x)\n    = (x / x) / x : by rw -div_div_eq_div_mul\n... = 1 / x : by rw div_self H_pos\n... = x⁻¹ : by rw one_div_inv\n\n-- integrable\naxiom is_integrable_const : Π {shape₁ shape₂ : S} (c : T shape₂), is_integrable (λ (x : T shape₁), c)\n\nlemma is_integrable_zero {shape₁ shape₂ : S} : is_integrable (λ (x : T shape₁), (0 : T shape₂)) := is_integrable_const (0 : T shape₂)\n\naxiom is_integrable_scale : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (α : ℝ),\n  is_integrable f ↔ is_integrable (λ x, α ⬝ f x)\n\naxiom is_integrable_neg : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂),\n  is_integrable f ↔ is_integrable (λ x, - f x)\n\naxiom is_integrable_div : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (y : T shape₂) (Hy : y > 0),\n  is_integrable f ↔ is_integrable (λ x, (f x) / y)\n\naxiom is_integrable_add : Π {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂),\n  (is_integrable f ∧ is_integrable g) ↔ is_integrable (λ x, f x + g x)\n\naxiom is_integrable_tmulT {ishape oshape fshape : S} (M : T (ishape ++ oshape)) (f : T fshape → T oshape) :\n  is_integrable f ↔ is_integrable (λ x, tmulT M (f x))\n\naxiom is_integrable_sum : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂),\n  (is_integrable f) ↔ is_integrable (λ x, sum (f x))\n\naxiom is_integrable_fscale : Π {shape₁ shape₂ : S} (f : T shape₁ → ℝ) (y : T shape₂),\n  is_integrable f ↔ is_integrable (λ x, f x ⬝ y)\n\n-- (provable)\naxiom is_integrable_const_middle : Π {shape₁ shape₂ : S} (pdf : T shape₁ → ℝ) (c : T shape₂),\n  is_integrable (λ (x : T shape₁), pdf x) ↔ is_integrable (λ (x : T shape₁), pdf x ⬝ c)\n\naxiom is_integrable_add_middle : Π {shape₁ shape₂ : S} (pdf : T shape₁ → ℝ) (f g : T shape₁ → T shape₂),\n  (is_integrable (λ (x : T shape₁), pdf x ⬝ f x) ∧ is_integrable (λ (x : T shape₁), pdf x ⬝ g x)) ↔ is_integrable (λ (x : T shape₁), pdf x ⬝ (f x + g x))\n\n-- (provable)\naxiom is_integrable_tmulT_middle {ishape oshape fshape : S} (M : T (ishape ++ oshape)) (pdf : T fshape → ℝ) (f : T fshape → T oshape) :\n  is_integrable (λ (x : T fshape), pdf x ⬝ f x) ↔ is_integrable (λ (x : T fshape), pdf x ⬝ tmulT M (f x))\n\n-- uniformly integrable\naxiom is_uniformly_integrable_around_binary : Π {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₁ → T shape₂ → T shape₃) (θ : T shape₁),\n  (is_uniformly_integrable_around (λ θ₀ x, f θ₀ θ x) θ ∧ is_uniformly_integrable_around (λ θ₀ x, f θ θ₀ x) θ) ↔ is_uniformly_integrable_around (λ θ₀ x, f θ₀ θ₀ x) θ\n\nlemma uint_left {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₁ → T shape₂ → T shape₃) (θ : T shape₁) :\n  is_uniformly_integrable_around (λ θ₀ x, f θ₀ θ₀ x) θ → is_uniformly_integrable_around (λ θ₀ x, f θ₀ θ x) θ :=\nassume H_uint, (iff.mpr (is_uniformly_integrable_around_binary f θ) H_uint)^.left\n\nlemma uint_right {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₁ → T shape₂ → T shape₃) (θ : T shape₁) :\n  is_uniformly_integrable_around (λ θ₀ x, f θ₀ θ₀ x) θ → is_uniformly_integrable_around (λ θ₀ x, f θ θ₀ x) θ :=\nassume H_uint, (iff.mpr (is_uniformly_integrable_around_binary f θ) H_uint)^.right\n\n-- (provable)\naxiom is_uniformly_integrable_around_binary_grad : Π {shape₁ shape₂ : S} (f₁ f₂ : T shape₁ → T shape₂ → ℝ) (θ : T shape₁),\n  (∀ x, is_cdifferentiable (λ θ₀, f₁ θ₀ x) θ) → (∀ x, is_cdifferentiable (λ θ₀, f₂ θ₀ x) θ) →\n  (is_uniformly_integrable_around (λ θ₀ x, f₂ θ₀ x ⬝ ∇ (λ θ₁, f₁ θ₁ x) θ₀) θ ∧ is_uniformly_integrable_around (λ θ₀ x, f₁ θ₀ x ⬝ ∇ (λ θ₁, f₂ θ₁ x) θ₀) θ ↔\n   is_uniformly_integrable_around (λ θ₀ x, ∇ (λ θ₁, f₁ θ₁ x ⬝ f₂ θ₁ x) θ₀) θ)\n\nlemma uint_grad_left {shape₁ shape₂ : S} (f₁ f₂ : T shape₁ → T shape₂ → ℝ) (θ : T shape₁) :\n  (∀ x, is_cdifferentiable (λ θ₀, f₁ θ₀ x) θ) → (∀ x, is_cdifferentiable (λ θ₀, f₂ θ₀ x) θ) →\n   is_uniformly_integrable_around (λ θ₀ x, ∇ (λ θ₁, f₁ θ₁ x ⬝ f₂ θ₁ x) θ₀) θ → is_uniformly_integrable_around (λ θ₀ x, f₂ θ₀ x ⬝ ∇ (λ θ₁, f₁ θ₁ x) θ₀) θ :=\nassume H_cdiff₁ H_cdiff₂ H_uint_grad, (iff.mpr (is_uniformly_integrable_around_binary_grad f₁ f₂ θ H_cdiff₁ H_cdiff₂) H_uint_grad)^.left\n\nlemma uint_grad_right {shape₁ shape₂ : S} (f₁ f₂ : T shape₁ → T shape₂ → ℝ) (θ : T shape₁) :\n  (∀ x, is_cdifferentiable (λ θ₀, f₁ θ₀ x) θ) → (∀ x, is_cdifferentiable (λ θ₀, f₂ θ₀ x) θ) →\n   is_uniformly_integrable_around (λ θ₀ x, ∇ (λ θ₁, f₁ θ₁ x ⬝ f₂ θ₁ x) θ₀) θ → is_uniformly_integrable_around (λ θ₀ x, f₁ θ₀ x ⬝ ∇ (λ θ₁, f₂ θ₁ x) θ₀) θ :=\nassume H_cdiff₁ H_cdiff₂ H_uint_grad, (iff.mpr (is_uniformly_integrable_around_binary_grad f₁ f₂ θ H_cdiff₁ H_cdiff₂) H_uint_grad)^.right\n\n-- integrals\naxiom integral_scale : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (α : ℝ),\n  ∫ (λ x, α ⬝ f x) = α ⬝ ∫ (λ x, f x)\n\naxiom integral_neg : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂),\n  ∫ (λ x, - (f x)) = - ∫ (λ x, f x)\n\naxiom integral_div : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (y : T shape₂),\n  ∫ (λ x, (f x) / y) = ∫ (λ x, f x) / y\n\naxiom integral_add : Π {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂),\n  is_integrable f → is_integrable g → ∫ (λ x, f x + g x) = ∫ (λ x, f x) + ∫ (λ x, g x)\n\naxiom integral_fscale : Π {shape₁ shape₂ : S} (f : T shape₁ → ℝ) (y : T shape₂),\n  ∫ (λ x, f x ⬝ y) = ∫ (λ x, f x) ⬝ y\n\naxiom integral_pos : ∀ {shape₁ shape₂ : S} (f : T shape₁ → T shape₂), (∀ x, f x > 0) → ∫ (λ x, f x) > 0\naxiom integral_nneg : ∀ {shape₁ shape₂ : S} (f : T shape₁ → T shape₂), (∀ x, f x ≥ 0) → ∫ (λ x, f x) ≥ 0\n\nlemma integral_congr {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂) (H_fg : ∀ x, f x = g x) : ∫ f = ∫ g :=\n  show ∫ (λ x, f x) = ∫ (λ x, g x), by rw (funext H_fg)\n\naxiom integral_sum : Π {shape₁ shape₂ : S} (f : T shape₁ → T shape₂), is_integrable f → ∫ (λ x, sum (f x)) = sum (∫ (λ x, f x))\n\naxiom smul_tmulT {ishape oshape : S} (α : ℝ) (M : T (ishape ++ oshape)) (y : T oshape) :\n  α ⬝ (tmulT M y) = tmulT M (α ⬝ y)\n\naxiom integral_tmulT {ishape oshape fshape : S} (M : T (ishape ++ oshape)) (f : T fshape → T oshape) :\n  ∫ (λ x, tmulT M (f x)) = tmulT M (∫ f)\n\naxiom integral_continuous : ∀ {ishape tshape fshape : S} (f : T ishape → T tshape → T fshape) (θ : T tshape),\n  (∀ x, is_continuous (f x) θ) → is_continuous (λ θ₀, ∫ (λ x₀, f x₀ θ₀)) θ\n\n-- D\n\naxiom tmulT_scalar {shape : S} : ∀ (x : T (shape ++ [])) (y : ℝ), tmulT x y = y ⬝ (eq.rec_on (append_nil shape) x)\naxiom D_scalar {shape : S} (f : T shape → ℝ) (θ : T shape) : (eq.rec_on (append_nil shape) (D f θ) : T shape) = ∇ f θ\n\n-- dintegral\n\nlemma dintegral_pos {oshape : S} : Π {shapes : list S} {f : dvec T shapes → T oshape}, (∀ x, f x > 0) → dintegral (λ x, f x) > 0\n| [] f H := by apply H\n\n| (shape::shapes) f H :=\nbegin\ndunfold dintegral,\napply integral_pos,\nintro x,\napply dintegral_pos,\nintro xs,\napply H,\nend\n\nlemma dintegral_scale {shape : S} (α : ℝ) : Π {shapes : list S} (f : dvec T shapes → T shape),\n  dintegral (λ (xs : dvec T shapes), α ⬝ f xs) = α ⬝ dintegral (λ xs, f xs)\n| [] f := rfl\n\n| (ds::shapes) f :=\nbegin\ndunfold dintegral,\nsimp [λ x, @dintegral_scale shapes (λ v, f (x ::: v))],\nrw integral_scale,\nend\n\nlemma is_dintegrable_scale {oshape : S} : Π {shapes : list S} (f : dvec T shapes → T oshape) (α : ℝ),\n  is_dintegrable f ↔ is_dintegrable (λ x, α ⬝ f x)\n| [] f α := begin split, all_goals { intro, exact trivial } end\n| (shape::shapes) f α :=\nbegin\ndunfold dintegral is_dintegrable,\nsplit,\n{ intro Hf, split,\n  { simp only [dintegral_scale], exact iff.mp (is_integrable_scale _ α) Hf^.left },\n  { intro x, exact iff.mp (is_dintegrable_scale _ _) (Hf^.right x) } },\n{ intro Hαf, split,\n  { simp only [dintegral_scale] at Hαf, exact iff.mpr (is_integrable_scale _ α) Hαf^.left },\n  { intro x, exact iff.mpr (is_dintegrable_scale _ _) (Hαf^.right x) } }\nend\n\nlemma dintegral_add {shape : S} : Π {shapes : list S} (f g : dvec T shapes → T shape),\n  is_dintegrable f → is_dintegrable g →\n  dintegral (λ (xs : dvec T shapes), f xs + g xs) = dintegral (λ (xs : dvec T shapes), f xs) + dintegral (λ (xs : dvec T shapes), g xs)\n| [] f g Hf Hg := rfl\n\n| (ds::shapes) f g Hf Hg :=\nbegin\ndunfold dintegral,\nsimp [λ x, @dintegral_add shapes (λ v, f (x ::: v)) (λ v, g (x :::v)) (Hf^.right x) (Hg^.right x)],\nrw integral_add _ _ Hf^.left Hg^.left\nend\n\nlemma dintegral_div {shape : S} : Π {shapes : list S} (f : dvec T shapes → T shape) (y : T shape),\n  dintegral (λ (xs : dvec T shapes), (f xs) / y) = dintegral (λ (xs : dvec T shapes), f xs) / y\n| [] f y := rfl\n\n| (ds::shapes) f y :=\nbegin\ndunfold dintegral,\nsimp [λ x, @dintegral_div shapes (λ v, f (x ::: v)) y],\nrw integral_div\nend\n\nlemma dintegral_add_middle {shape : S} : Π {shapes : list S} (pdf : dvec T shapes → ℝ) (f g : dvec T shapes → T shape),\n  is_dintegrable (λ xs, pdf xs ⬝ f xs) → is_dintegrable (λ xs, pdf xs ⬝ g xs) →\n  dintegral (λ (xs : dvec T shapes), pdf xs ⬝ (f xs + g xs)) = dintegral (λ (xs : dvec T shapes), pdf xs ⬝ f xs) + dintegral (λ (xs : dvec T shapes), pdf xs ⬝ g xs)\n| [] pdf f g Hf Hg := begin dunfold dintegral, apply smul_addr end\n\n| (ds::shapes) pdf f g Hf Hg :=\nbegin\ndunfold dintegral,\nsimp [λ x, @dintegral_add_middle shapes (λ v, pdf (x ::: v)) (λ v, f (x ::: v)) (λ v, g (x :::v)) (Hf^.right x) (Hg^.right x)],\nrw integral_add _ _ Hf^.left Hg^.left\nend\n\nlemma dintegral_neg_middle {shape : S} : Π {shapes : list S} (pdf : dvec T shapes → ℝ) (f : dvec T shapes → T shape),\n  dintegral (λ (xs : dvec T shapes), pdf xs ⬝ - (f xs)) = - dintegral (λ (xs : dvec T shapes), pdf xs ⬝ f xs)\n| [] pdf f := begin dunfold dintegral, apply smul_neg end\n\n| (ds::shapes) pdf f :=\nbegin\ndunfold dintegral,\nsimp [λ x, @dintegral_neg_middle shapes (λ v, pdf (x ::: v)) (λ v, f (x ::: v))],\nrw integral_neg\nend\n\nlemma dintegral_mul (α : ℝ) : Π {shapes : list S} (f : dvec T shapes → ℝ),\n  dintegral (λ (xs : dvec T shapes), α * f xs) = α * dintegral (λ xs, f xs) :=\nbegin\nintros shapes f,\nrw -(const_scalar α),\nsimp [λ s x, eq.symm (smul.def α s x)],\nsimp [λ α f, eq.symm (smul_scalar α f)],\nexact (dintegral_scale α f)\nend\n\nlemma dintegral_scale_middle  {shape : S} (α : ℝ) : Π {shapes : list S} (f : dvec T shapes → ℝ) (g : dvec T shapes → T shape),\n  dintegral (λ (xs : dvec T shapes), f xs ⬝ (α ⬝ g xs)) = α ⬝ dintegral (λ xs, f xs ⬝ g xs)\n| [] f g :=\nbegin\ndunfold dintegral,\nsimp [T.smul.def, mul_comm],\nend\n\n| (ds::shapes) f g :=\nbegin\ndunfold dintegral,\nsimp [λ x, @dintegral_scale_middle shapes (λ v, f (x ::: v)) (λ v, g (x ::: v))],\nrw integral_scale,\nend\n\nlemma dintegral_mul_middle (α : ℝ) : Π {shapes : list S} (f : dvec T shapes → ℝ) (g : dvec T shapes → ℝ),\n  dintegral (λ (xs : dvec T shapes), f xs ⬝ (α * g xs)) = α * dintegral (λ xs, f xs ⬝ g xs) :=\nbegin\nintros shapes f g,\nrw -(const_scalar α),\nsimp [λ s x, eq.symm (smul.def α s x)],\nsimp [λ xs, eq.symm (smul_scalar α (g xs))],\nrw dintegral_scale_middle α f g,\nsimp [smul_scalar]\nend\n\nlemma dintegral_tmulT  {shape₁ shape₂ : S} (M : T (shape₁ ++ shape₂)) : Π {shapes : list S} (f : dvec T shapes → T shape₂),\n  dintegral (λ (xs : dvec T shapes), tmulT M (f xs)) = tmulT M (dintegral (λ xs, f xs))\n| []           f := rfl\n\n| (ds::shapes) f :=\nbegin\ndunfold dintegral,\nsimp [λ x, @dintegral_tmulT shapes (λ v, f (x ::: v))],\nrw integral_tmulT\nend\n\nlemma dintegral_tmulT_middle {shape₁ shape₂ : S} (M : T (shape₁ ++ shape₂)) : Π {shapes : list S} (f : dvec T shapes → ℝ) (g : dvec T shapes → T shape₂),\n  dintegral (λ (xs : dvec T shapes), f xs ⬝ (tmulT M (g xs))) = tmulT M (dintegral (λ xs, f xs ⬝ g xs)) :=\nbegin\nintros shapes f g,\nsimp [smul_tmulT, dintegral_tmulT]\nend\n\nlemma dintegral_const_middle {yshape : S} :\n  ∀ {shapes : list S} (pdf : dvec T shapes → ℝ) (H_pdf_pos : ∀ x, pdf x > 0) (H_pdf_int1 : dintegral pdf = 1) (y : T yshape),\n    dintegral (λ (xs : dvec T shapes), pdf xs ⬝ y) = y\n| [] pdf H_pdf_pos H_pdf_int1 y :=\nbegin\ndunfold dintegral,\ndunfold dintegral at H_pdf_int1,\nrw H_pdf_int1,\nrw one_smul\nend\n\n| (shape::shapes) pdf H_pdf_pos H_pdf_int1 y :=\nlet pdf' : T shape → dvec T shapes → ℝ := λ x (xs : dvec T shapes), pdf (x ::: xs) / dintegral (λ (xs : dvec T shapes), pdf (x ::: xs)) in\nhave H_dpos : ∀ (x : T shape), dintegral (λ (xs : dvec T shapes), pdf (x ::: xs)) > 0, from λ x, dintegral_pos (λ x, H_pdf_pos _),\nhave H_pdf'_pos : ∀ (x : T shape) (xs : dvec T shapes), pdf' x xs > 0, from\n  assume (x : T shape) (xs : dvec T shapes),\n  have H₁ : pdf (x ::: xs) > 0, by apply H_pdf_pos,\n  T.div_pos_pos H₁ (H_dpos x),\n\nhave H_pdf'_int1 : ∀ (x : T shape), dintegral (pdf' x) = 1, from\n  assume (x : T shape),\n  begin dsimp, rw T.dintegral_div, exact div_self (H_dpos x) end,\n\nhave H_inner₁ : ∀ (x : T shape), dintegral (λ (v : dvec T shapes), pdf (x ::: v) ⬝ y)\n                     = dintegral (λ (v : dvec T shapes), (pdf' x v * dintegral (λ (vs : dvec T shapes), pdf (x ::: vs))) ⬝ y), from\n  assume (x : T shape),\n  begin dsimp, apply congr_arg, apply funext, intro xs, rw (T.div_mul_cancel (H_dpos _)) end,\n\nhave H_inner₂ : ∀ x, dintegral (λ (v : dvec T shapes), (pdf' x v * dintegral (λ (vs : dvec T shapes), pdf (x ::: vs))) ⬝ y)\n                     = dintegral (λ (vs : dvec T shapes), pdf (x ::: vs)) ⬝ dintegral (λ (v : dvec T shapes), pdf' x v ⬝ y), from\n  assume (x : T shape),\n  begin dsimp, simp [smul_group, dintegral_scale] end,\nbegin\ndunfold dintegral,\nsimp [H_inner₁, H_inner₂, (λ x, @dintegral_const_middle shapes (pdf' x) (H_pdf'_pos x) (H_pdf'_int1 x)), integral_fscale],\nchange dintegral (λ (vs : dvec T (shape::shapes)), pdf vs) ⬝ y = y,\nrw [H_pdf_int1, one_smul]\nend\n\n-- btw axioms\n\naxiom is_btw_id {shape : S} : is_btw_exp₂ (λ (x : T shape), x)\naxiom is_btw_const {shape₁ shape₂ : S} (y : T shape₂) : is_btw_exp₂ (λ (x : T shape₁), y)\naxiom is_btw_sigmoid {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_btw_exp₂ (λ (x : T shape₁), sigmoid (f x))\naxiom is_btw_softplus {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ (λ (x : T shape₁), softplus (f x))\naxiom is_btw_sum {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ (λ (x : T shape₁), sum (f x))\naxiom is_btw_log_sigmoid {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (y : T shape₂) : y > 0 → is_btw_exp₂ f → \n  is_btw_exp₂ (λ (x : T shape₁), log (y + sigmoid (f x)))\naxiom is_btw_log_1msigmoid {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (y : T shape₂) : y > 0 → is_btw_exp₂ f → \n  is_btw_exp₂ (λ (x : T shape₁), log (y + (1 - sigmoid (f x))))\n\naxiom is_btw_gemm {shape : S} {m n p : ℕ} (f : T shape → T [m, n]) (g : T shape → T [n, p]) :\n  is_btw_exp₂ f → is_btw_exp₂ g → is_btw_exp₂ (λ x, gemm (f x) (g x))\n\naxiom is_btw_transpose {shape : S} {m n : ℕ} (f : T shape → T [m, n]) :\n  is_btw_exp₂ f → is_btw_exp₂ (λ x, transpose (f x))\n\naxiom is_btw_neg {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ (λ x, - (f x))\naxiom is_btw_inv {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ (λ x, (f x)⁻¹)\naxiom is_btw_add {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ g → is_btw_exp₂ (λ x, f x + g x)\naxiom is_btw_mul {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ g → is_btw_exp₂ (λ x, f x * g x)\naxiom is_btw_sub {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ g → is_btw_exp₂ (λ x, f x - g x)\naxiom is_btw_div {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂) : is_btw_exp₂ f → is_btw_exp₂ g → is_btw_exp₂ (λ x, f x / g x)\n\naxiom is_btw_exp {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_sub_quadratic f → is_btw_exp₂ (λ x, exp (f x))\n\n-- sub quadratic axioms\n\naxiom is_sub_quadratic_id {shape : S} : is_sub_quadratic (λ (x : T shape), x)\naxiom is_sub_quadratic_const {shape₁ shape₂ : S} (y : T shape₂) : is_sub_quadratic (λ (x : T shape₁), y)\n\naxiom is_sub_quadratic_gemm {shape : S} {m n p : ℕ} (f : T shape → T [m, n]) (g : T shape → T [n, p]) :\n  is_sub_quadratic f → is_sub_quadratic g → is_sub_quadratic (λ x, gemm (f x) (g x))\n\naxiom is_sub_quadratic_transpose {shape : S} {m n : ℕ} (f : T shape → T [m, n]) :\n  is_sub_quadratic f → is_sub_quadratic (λ x, transpose (f x))\n\naxiom is_sub_quadratic_softplus {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_sub_quadratic f → is_sub_quadratic (λ x, softplus (f x))\n\naxiom is_sub_quadratic_neg {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) : is_sub_quadratic f → is_sub_quadratic (λ x, - (f x))\naxiom is_sub_quadratic_mul₁ {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (y : T shape₂) : is_sub_quadratic f → is_sub_quadratic (λ x, y * f x)\naxiom is_sub_quadratic_mul₂ {shape₁ shape₂ : S} (f : T shape₁ → T shape₂) (y : T shape₂) : is_sub_quadratic f → is_sub_quadratic (λ x, f x * y)\n\naxiom is_sub_quadratic_add {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂) : is_sub_quadratic f → is_sub_quadratic g → is_sub_quadratic (λ x, f x + g x)\naxiom is_sub_quadratic_sub {shape₁ shape₂ : S} (f g : T shape₁ → T shape₂) : is_sub_quadratic f → is_sub_quadratic g → is_sub_quadratic (λ x, f x - g x)\n\n-- is_bounded_btw_exp₂_around {shape₁ shape₂ shape₃ : S} (f : Π (x : T shape₁) (θ : T shape₂), T shape₃) (θ : T shape₂) : Prop\n\naxiom is_bbtw_of_btw {shape₁ shape₂ shape₃ : S} (f : Π (x : T shape₁), T shape₃) (θ : T shape₂) :\n  is_btw_exp₂ f → is_bounded_btw_exp₂_around (λ x θ₀, f x) θ\n\naxiom is_bbtw_id {shape₁ shape₂ : S} (θ : T shape₂) : is_bounded_btw_exp₂_around (λ (x : T shape₁) (θ₀ : T shape₂), θ₀) θ\n\naxiom is_bbtw_softplus {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around (λ x θ₀, softplus (f x θ₀)) θ\n\naxiom is_bbtw_sum {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around (λ x θ₀, sum (f x θ₀)) θ\n\naxiom is_bbtw_log_sigmoid {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (y : T shape₃) (θ : T shape₂) : y > 0 →\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around (λ x θ₀, log (y + sigmoid (f x θ₀))) θ\n\naxiom is_bbtw_log_1msigmoid {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (y : T shape₃) (θ : T shape₂) : y > 0 →\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around (λ x θ₀, log (y + (1 - sigmoid (f x θ₀)))) θ\n\naxiom is_bbtw_gemm {shape₁ shape₂ : S} {m n p : ℕ} (f : T shape₁ → T shape₂ → T [m, n]) (g : T shape₁ → T shape₂ → T [n, p]) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around g θ → is_bounded_btw_exp₂_around (λ x θ₀, gemm (f x θ₀) (g x θ₀)) θ\n\naxiom is_bbtw_neg {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around (λ x θ₀, - f x θ₀) θ\n\naxiom is_bbtw_inv {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around (λ x θ₀, (f x θ₀)⁻¹) θ\n\naxiom is_bbtw_add {shape₁ shape₂ shape₃ : S} (f g : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around g θ → is_bounded_btw_exp₂_around (λ x θ₀, f x θ₀ + g x θ₀) θ\n\naxiom is_bbtw_sub {shape₁ shape₂ shape₃ : S} (f g : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around g θ → is_bounded_btw_exp₂_around (λ x θ₀, f x θ₀ - g x θ₀) θ\n\naxiom is_bbtw_mul {shape₁ shape₂ shape₃ : S} (f g : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around g θ → is_bounded_btw_exp₂_around (λ x θ₀, f x θ₀ * g x θ₀) θ\n\naxiom is_bbtw_exp {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n  is_sub_quadratic (λ x, f x θ) → (∀ x, is_sub_quadratic (f x)) → is_bounded_btw_exp₂_around (λ x θ₀, exp (f x θ₀)) θ\n\nlemma is_bbtw_bernoulli_neglogpdf {shape₁ shape₂ shape₃ : S} (f : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) (p : T shape₃) :\n  is_bounded_btw_exp₂_around f θ → is_bounded_btw_exp₂_around (λ x θ₀, bernoulli_neglogpdf (sigmoid (f x θ₀)) p) θ :=\nbegin\nintro H,\ndunfold bernoulli_neglogpdf,\napply is_bbtw_neg, apply is_bbtw_sum, apply is_bbtw_add,\napply is_bbtw_mul, apply is_bbtw_of_btw, apply is_btw_const, apply is_bbtw_log_sigmoid, exact eps_pos, exact H,\napply is_bbtw_mul, apply is_bbtw_of_btw, apply is_btw_const, apply is_bbtw_log_1msigmoid, exact eps_pos, exact H\nend\n\n-- misc\naxiom integral_scale_shift_var {shape fshape : S} (f : T shape → T fshape) (α β : T shape) : ∫ (λ x, f (α * x + β)) = ∫ (λ x, prod α⁻¹ ⬝ f x)\n\n@[simp]\nlemma force_ok {shape : S} (x : T shape) : force x shape = x := by { dunfold force, simp }\n\nend T\n\n-- helper tactic\nsection tactic\nopen tactic list\nmeta def prove_preconditions_core : tactic unit :=\nfirst (assumption :: map applyc [`certigrad.T.sqrt_pos, `certigrad.T.square_pos_of_pos, `certigrad.T.exp_pos,\n                                 `certigrad.T.sigmoid_pos, `certigrad.T.sigmoid_lt1, `certigrad.T.lt1_alt, `certigrad.T.one_plus_pos,\n                                 `certigrad.T.plus_one_pos, `certigrad.T.one_pos, `certigrad.T.neg_of_pos, `certigrad.T.const_pos_of_pos,\n                                 `certigrad.T.mul_pos_of_pos_pos, `certigrad.T.add_pos_of_pos_pos,\n                                 `certigrad.T.pi_pos, `certigrad.T.eps_pos,\n                                 `certigrad.T.inv_pos, `certigrad.T.div_pos_pos, `certigrad.T.two_pos, `certigrad.T.two_pi_pos])\n\nmeta def prove_preconditions : tactic unit := repeat prove_preconditions_core\nend tactic\n\n\nend certigrad\n", "meta": {"author": "dselsam", "repo": "certigrad", "sha": "c9a06e93f1ec58196d6d3b8563b29868d916727f", "save_path": "github-repos/lean/dselsam-certigrad", "path": "github-repos/lean/dselsam-certigrad/certigrad-c9a06e93f1ec58196d6d3b8563b29868d916727f/src/certigrad/tfacts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186768138228, "lm_q2_score": 0.6261241702517976, "lm_q1q2_score": 0.4997640279065119}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen\n\n! This file was ported from Lean 3 source module linear_algebra.determinant\n! leanprover-community/mathlib commit ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.GeneralLinearGroup\nimport Mathbin.LinearAlgebra.Matrix.Reindex\nimport Mathbin.Tactic.FieldSimp\nimport Mathbin.LinearAlgebra.Matrix.NonsingularInverse\nimport Mathbin.LinearAlgebra.Matrix.Basis\n\n/-!\n# Determinant of families of vectors\n\nThis file defines the determinant of an endomorphism, and of a family of vectors\nwith respect to some basis. For the determinant of a matrix, see the file\n`linear_algebra.matrix.determinant`.\n\n## Main definitions\n\nIn the list below, and in all this file, `R` is a commutative ring (semiring\nis sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite\ntypes used for indexing.\n\n * `basis.det`: the determinant of a family of vectors with respect to a basis,\n   as a multilinear map\n * `linear_map.det`: the determinant of an endomorphism `f : End R M` as a\n   multiplicative homomorphism (if `M` does not have a finite `R`-basis, the\n   result is `1` instead)\n * `linear_equiv.det`: the determinant of an isomorphism `f : M ≃ₗ[R] M` as a\n   multiplicative homomorphism (if `M` does not have a finite `R`-basis, the\n   result is `1` instead)\n\n## Tags\n\nbasis, det, determinant\n-/\n\n\nnoncomputable section\n\nopen BigOperators\n\nopen Matrix\n\nopen LinearMap\n\nopen Submodule\n\nuniverse u v w\n\nopen LinearMap Matrix Set Function\n\nvariable {R : Type _} [CommRing R]\n\nvariable {M : Type _} [AddCommGroup M] [Module R M]\n\nvariable {M' : Type _} [AddCommGroup M'] [Module R M']\n\nvariable {ι : Type _} [DecidableEq ι] [Fintype ι]\n\nvariable (e : Basis ι R M)\n\nsection Conjugate\n\nvariable {A : Type _} [CommRing A]\n\nvariable {m n : Type _} [Fintype m] [Fintype n]\n\n/-- If `R^m` and `R^n` are linearly equivalent, then `m` and `n` are also equivalent. -/\ndef equivOfPiLequivPi {R : Type _} [CommRing R] [Nontrivial R] (e : (m → R) ≃ₗ[R] n → R) : m ≃ n :=\n  Basis.indexEquiv (Basis.ofEquivFun e.symm) (Pi.basisFun _ _)\n#align equiv_of_pi_lequiv_pi equivOfPiLequivPi\n\nnamespace Matrix\n\n/-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to\nequivalence of types. -/\ndef indexEquivOfInv [Nontrivial A] [DecidableEq m] [DecidableEq n] {M : Matrix m n A}\n    {M' : Matrix n m A} (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) : m ≃ n :=\n  equivOfPiLequivPi (toLin'OfInv hMM' hM'M)\n#align matrix.index_equiv_of_inv Matrix.indexEquivOfInv\n\ntheorem det_comm [DecidableEq n] (M N : Matrix n n A) : det (M ⬝ N) = det (N ⬝ M) := by\n  rw [det_mul, det_mul, mul_comm]\n#align matrix.det_comm Matrix.det_comm\n\n/-- If there exists a two-sided inverse `M'` for `M` (indexed differently),\nthen `det (N ⬝ M) = det (M ⬝ N)`. -/\ntheorem det_comm' [DecidableEq m] [DecidableEq n] {M : Matrix n m A} {N : Matrix m n A}\n    {M' : Matrix m n A} (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) : det (M ⬝ N) = det (N ⬝ M) :=\n  by\n  nontriviality A\n  -- Although `m` and `n` are different a priori, we will show they have the same cardinality.\n  -- This turns the problem into one for square matrices, which is easy.\n  let e := index_equiv_of_inv hMM' hM'M\n  rw [← det_submatrix_equiv_self e, ← submatrix_mul_equiv _ _ _ (Equiv.refl n) _, det_comm,\n    submatrix_mul_equiv, Equiv.coe_refl, submatrix_id_id]\n#align matrix.det_comm' Matrix.det_comm'\n\n/-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M ⬝ N ⬝ M') = det N`.\n\nSee `matrix.det_conj` and `matrix.det_conj'` for the case when `M' = M⁻¹` or vice versa. -/\ntheorem det_conj_of_mul_eq_one [DecidableEq m] [DecidableEq n] {M : Matrix m n A}\n    {M' : Matrix n m A} {N : Matrix n n A} (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :\n    det (M ⬝ N ⬝ M') = det N := by\n  rw [← det_comm' hM'M hMM', ← Matrix.mul_assoc, hM'M, Matrix.one_mul]\n#align matrix.det_conj_of_mul_eq_one Matrix.det_conj_of_mul_eq_one\n\nend Matrix\n\nend Conjugate\n\nnamespace LinearMap\n\n/-! ### Determinant of a linear map -/\n\n\nvariable {A : Type _} [CommRing A] [Module A M]\n\nvariable {κ : Type _} [Fintype κ]\n\n/-- The determinant of `linear_map.to_matrix` does not depend on the choice of basis. -/\ntheorem det_toMatrix_eq_det_toMatrix [DecidableEq κ] (b : Basis ι A M) (c : Basis κ A M)\n    (f : M →ₗ[A] M) : det (LinearMap.toMatrix b b f) = det (LinearMap.toMatrix c c f) := by\n  rw [← linearMap_toMatrix_mul_basis_toMatrix c b c, ← basis_toMatrix_mul_linearMap_toMatrix b c b,\n      Matrix.det_conj_of_mul_eq_one] <;>\n    rw [Basis.toMatrix_mul_toMatrix, Basis.toMatrix_self]\n#align linear_map.det_to_matrix_eq_det_to_matrix LinearMap.det_toMatrix_eq_det_toMatrix\n\n/-- The determinant of an endomorphism given a basis.\n\nSee `linear_map.det` for a version that populates the basis non-computably.\n\nAlthough the `trunc (basis ι A M)` parameter makes it slightly more convenient to switch bases,\nthere is no good way to generalize over universe parameters, so we can't fully state in `det_aux`'s\ntype that it does not depend on the choice of basis. Instead you can use the `det_aux_def'` lemma,\nor avoid mentioning a basis at all using `linear_map.det`.\n-/\nirreducible_def detAux : Trunc (Basis ι A M) → (M →ₗ[A] M) →* A :=\n  Trunc.lift\n    (fun b : Basis ι A M => detMonoidHom.comp (toMatrixAlgEquiv b : (M →ₗ[A] M) →* Matrix ι ι A))\n    fun b c => MonoidHom.ext <| det_toMatrix_eq_det_toMatrix b c\n#align linear_map.det_aux LinearMap.detAux\n\n/-- Unfold lemma for `det_aux`.\n\nSee also `det_aux_def'` which allows you to vary the basis.\n-/\ntheorem detAux_def (b : Basis ι A M) (f : M →ₗ[A] M) :\n    LinearMap.detAux (Trunc.mk b) f = Matrix.det (LinearMap.toMatrix b b f) :=\n  by\n  rw [det_aux]\n  rfl\n#align linear_map.det_aux_def LinearMap.detAux_def\n\ntheorem detAux_def' {ι' : Type _} [Fintype ι'] [DecidableEq ι'] (tb : Trunc <| Basis ι A M)\n    (b' : Basis ι' A M) (f : M →ₗ[A] M) :\n    LinearMap.detAux tb f = Matrix.det (LinearMap.toMatrix b' b' f) :=\n  by\n  apply Trunc.induction_on tb\n  intro b\n  rw [det_aux_def, det_to_matrix_eq_det_to_matrix b b']\n#align linear_map.det_aux_def' LinearMap.detAux_def'\n\n@[simp]\ntheorem detAux_id (b : Trunc <| Basis ι A M) : LinearMap.detAux b LinearMap.id = 1 :=\n  (LinearMap.detAux b).map_one\n#align linear_map.det_aux_id LinearMap.detAux_id\n\n@[simp]\ntheorem detAux_comp (b : Trunc <| Basis ι A M) (f g : M →ₗ[A] M) :\n    LinearMap.detAux b (f.comp g) = LinearMap.detAux b f * LinearMap.detAux b g :=\n  (LinearMap.detAux b).map_mul f g\n#align linear_map.det_aux_comp LinearMap.detAux_comp\n\nsection\n\nopen Classical\n\n-- Discourage the elaborator from unfolding `det` and producing a huge term by marking it\n-- as irreducible.\n/-- The determinant of an endomorphism independent of basis.\n\nIf there is no finite basis on `M`, the result is `1` instead.\n-/\nprotected irreducible_def det : (M →ₗ[A] M) →* A :=\n  if H : ∃ s : Finset M, Nonempty (Basis s A M) then LinearMap.detAux (Trunc.mk H.choose_spec.some)\n  else 1\n#align linear_map.det LinearMap.det\n\ntheorem coe_det [DecidableEq M] :\n    ⇑(LinearMap.det : (M →ₗ[A] M) →* A) =\n      if H : ∃ s : Finset M, Nonempty (Basis s A M) then\n        LinearMap.detAux (Trunc.mk H.choose_spec.some)\n      else 1 :=\n  by\n  ext\n  unfold LinearMap.det\n  split_ifs\n  · congr\n  -- use the correct `decidable_eq` instance\n  rfl\n#align linear_map.coe_det LinearMap.coe_det\n\nend\n\n-- Auxiliary lemma, the `simp` normal form goes in the other direction\n-- (using `linear_map.det_to_matrix`)\ntheorem det_eq_det_toMatrix_of_finset [DecidableEq M] {s : Finset M} (b : Basis s A M)\n    (f : M →ₗ[A] M) : f.det = Matrix.det (LinearMap.toMatrix b b f) :=\n  by\n  have : ∃ s : Finset M, Nonempty (Basis s A M) := ⟨s, ⟨b⟩⟩\n  rw [LinearMap.coe_det, dif_pos, det_aux_def' _ b] <;> assumption\n#align linear_map.det_eq_det_to_matrix_of_finset LinearMap.det_eq_det_toMatrix_of_finset\n\n@[simp]\ntheorem det_toMatrix (b : Basis ι A M) (f : M →ₗ[A] M) : Matrix.det (toMatrix b b f) = f.det :=\n  by\n  haveI := Classical.decEq M\n  rw [det_eq_det_to_matrix_of_finset b.reindex_finset_range, det_to_matrix_eq_det_to_matrix b]\n#align linear_map.det_to_matrix LinearMap.det_toMatrix\n\n@[simp]\ntheorem det_toMatrix' {ι : Type _} [Fintype ι] [DecidableEq ι] (f : (ι → A) →ₗ[A] ι → A) :\n    det f.toMatrix' = f.det := by simp [← to_matrix_eq_to_matrix']\n#align linear_map.det_to_matrix' LinearMap.det_toMatrix'\n\n@[simp]\ntheorem det_toLin (b : Basis ι R M) (f : Matrix ι ι R) :\n    LinearMap.det (Matrix.toLin b b f) = f.det := by\n  rw [← LinearMap.det_toMatrix b, LinearMap.toMatrix_toLin]\n#align linear_map.det_to_lin LinearMap.det_toLin\n\n@[simp]\ntheorem det_toLin' (f : Matrix ι ι R) : LinearMap.det f.toLin' = f.det := by\n  simp only [← to_lin_eq_to_lin', det_to_lin]\n#align linear_map.det_to_lin' LinearMap.det_toLin'\n\n/-- To show `P f.det` it suffices to consider `P (to_matrix _ _ f).det` and `P 1`. -/\n@[elab_as_elim]\ntheorem det_cases [DecidableEq M] {P : A → Prop} (f : M →ₗ[A] M)\n    (hb : ∀ (s : Finset M) (b : Basis s A M), P (toMatrix b b f).det) (h1 : P 1) : P f.det :=\n  by\n  unfold LinearMap.det\n  split_ifs with h\n  · convert hb _ h.some_spec.some\n    apply det_aux_def'\n  · exact h1\n#align linear_map.det_cases LinearMap.det_cases\n\n@[simp]\ntheorem det_comp (f g : M →ₗ[A] M) : (f.comp g).det = f.det * g.det :=\n  LinearMap.det.map_mul f g\n#align linear_map.det_comp LinearMap.det_comp\n\n@[simp]\ntheorem det_id : (LinearMap.id : M →ₗ[A] M).det = 1 :=\n  LinearMap.det.map_one\n#align linear_map.det_id LinearMap.det_id\n\n/-- Multiplying a map by a scalar `c` multiplies its determinant by `c ^ dim M`. -/\n@[simp]\ntheorem det_smul {𝕜 : Type _} [Field 𝕜] {M : Type _} [AddCommGroup M] [Module 𝕜 M] (c : 𝕜)\n    (f : M →ₗ[𝕜] M) : LinearMap.det (c • f) = c ^ FiniteDimensional.finrank 𝕜 M * LinearMap.det f :=\n  by\n  by_cases H : ∃ s : Finset M, Nonempty (Basis s 𝕜 M)\n  · have : FiniteDimensional 𝕜 M := by\n      rcases H with ⟨s, ⟨hs⟩⟩\n      exact FiniteDimensional.of_fintype_basis hs\n    simp only [← det_to_matrix (FiniteDimensional.finBasis 𝕜 M), LinearEquiv.map_smul,\n      Fintype.card_fin, det_smul]\n  ·\n    classical\n      have : FiniteDimensional.finrank 𝕜 M = 0 := finrank_eq_zero_of_not_exists_basis H\n      simp [coe_det, H, this]\n#align linear_map.det_smul LinearMap.det_smul\n\ntheorem det_zero' {ι : Type _} [Finite ι] [Nonempty ι] (b : Basis ι A M) :\n    LinearMap.det (0 : M →ₗ[A] M) = 0 :=\n  by\n  haveI := Classical.decEq ι\n  cases nonempty_fintype ι\n  rwa [← det_to_matrix b, LinearEquiv.map_zero, det_zero]\n#align linear_map.det_zero' LinearMap.det_zero'\n\n/-- In a finite-dimensional vector space, the zero map has determinant `1` in dimension `0`,\nand `0` otherwise. We give a formula that also works in infinite dimension, where we define\nthe determinant to be `1`. -/\n@[simp]\ntheorem det_zero {𝕜 : Type _} [Field 𝕜] {M : Type _} [AddCommGroup M] [Module 𝕜 M] :\n    LinearMap.det (0 : M →ₗ[𝕜] M) = (0 : 𝕜) ^ FiniteDimensional.finrank 𝕜 M := by\n  simp only [← zero_smul 𝕜 (1 : M →ₗ[𝕜] M), det_smul, mul_one, MonoidHom.map_one]\n#align linear_map.det_zero LinearMap.det_zero\n\ntheorem det_eq_one_of_subsingleton [Subsingleton M] (f : M →ₗ[R] M) : (f : M →ₗ[R] M).det = 1 :=\n  by\n  have b : Basis (Fin 0) R M := Basis.empty M\n  rw [← f.det_to_matrix b]\n  exact Matrix.det_isEmpty\n#align linear_map.det_eq_one_of_subsingleton LinearMap.det_eq_one_of_subsingleton\n\ntheorem det_eq_one_of_finrank_eq_zero {𝕜 : Type _} [Field 𝕜] {M : Type _} [AddCommGroup M]\n    [Module 𝕜 M] (h : FiniteDimensional.finrank 𝕜 M = 0) (f : M →ₗ[𝕜] M) :\n    (f : M →ₗ[𝕜] M).det = 1 := by\n  classical\n    refine' @LinearMap.det_cases M _ 𝕜 _ _ _ (fun t => t = 1) f _ rfl\n    intro s b\n    have : IsEmpty s := by\n      rw [← Fintype.card_eq_zero_iff]\n      exact (FiniteDimensional.finrank_eq_card_basis b).symm.trans h\n    exact Matrix.det_isEmpty\n#align linear_map.det_eq_one_of_finrank_eq_zero LinearMap.det_eq_one_of_finrank_eq_zero\n\n/-- Conjugating a linear map by a linear equiv does not change its determinant. -/\n@[simp]\ntheorem det_conj {N : Type _} [AddCommGroup N] [Module A N] (f : M →ₗ[A] M) (e : M ≃ₗ[A] N) :\n    LinearMap.det ((e : M →ₗ[A] N) ∘ₗ f ∘ₗ (e.symm : N →ₗ[A] M)) = LinearMap.det f := by\n  classical\n    by_cases H : ∃ s : Finset M, Nonempty (Basis s A M)\n    · rcases H with ⟨s, ⟨b⟩⟩\n      rw [← det_to_matrix b f, ← det_to_matrix (b.map e), to_matrix_comp (b.map e) b (b.map e),\n        to_matrix_comp (b.map e) b b, ← Matrix.mul_assoc, Matrix.det_conj_of_mul_eq_one]\n      ·\n        rw [← to_matrix_comp, LinearEquiv.comp_coe, e.symm_trans_self, LinearEquiv.refl_toLinearMap,\n          to_matrix_id]\n      ·\n        rw [← to_matrix_comp, LinearEquiv.comp_coe, e.self_trans_symm, LinearEquiv.refl_toLinearMap,\n          to_matrix_id]\n    · have H' : ¬∃ t : Finset N, Nonempty (Basis t A N) :=\n        by\n        contrapose! H\n        rcases H with ⟨s, ⟨b⟩⟩\n        exact ⟨_, ⟨(b.map e.symm).reindexFinsetRange⟩⟩\n      simp only [coe_det, H, H', Pi.one_apply, dif_neg, not_false_iff]\n#align linear_map.det_conj LinearMap.det_conj\n\n/-- If a linear map is invertible, so is its determinant. -/\ntheorem isUnit_det {A : Type _} [CommRing A] [Module A M] (f : M →ₗ[A] M) (hf : IsUnit f) :\n    IsUnit f.det := by\n  obtain ⟨g, hg⟩ : ∃ g, f.comp g = 1 := hf.exists_right_inv\n  have : LinearMap.det f * LinearMap.det g = 1 := by\n    simp only [← LinearMap.det_comp, hg, MonoidHom.map_one]\n  exact isUnit_of_mul_eq_one _ _ this\n#align linear_map.is_unit_det LinearMap.isUnit_det\n\n/-- If a linear map has determinant different from `1`, then the space is finite-dimensional. -/\ntheorem finiteDimensional_of_det_ne_one {𝕜 : Type _} [Field 𝕜] [Module 𝕜 M] (f : M →ₗ[𝕜] M)\n    (hf : f.det ≠ 1) : FiniteDimensional 𝕜 M :=\n  by\n  by_cases H : ∃ s : Finset M, Nonempty (Basis s 𝕜 M)\n  · rcases H with ⟨s, ⟨hs⟩⟩\n    exact FiniteDimensional.of_fintype_basis hs\n  ·\n    classical\n      simp [LinearMap.coe_det, H] at hf\n      exact hf.elim\n#align linear_map.finite_dimensional_of_det_ne_one LinearMap.finiteDimensional_of_det_ne_one\n\n/-- If the determinant of a map vanishes, then the map is not onto. -/\ntheorem range_lt_top_of_det_eq_zero {𝕜 : Type _} [Field 𝕜] [Module 𝕜 M] {f : M →ₗ[𝕜] M}\n    (hf : f.det = 0) : f.range < ⊤ :=\n  by\n  have : FiniteDimensional 𝕜 M := by simp [f.finite_dimensional_of_det_ne_one, hf]\n  contrapose hf\n  simp only [lt_top_iff_ne_top, Classical.not_not, ← is_unit_iff_range_eq_top] at hf\n  exact isUnit_iff_ne_zero.1 (f.is_unit_det hf)\n#align linear_map.range_lt_top_of_det_eq_zero LinearMap.range_lt_top_of_det_eq_zero\n\n/-- If the determinant of a map vanishes, then the map is not injective. -/\ntheorem bot_lt_ker_of_det_eq_zero {𝕜 : Type _} [Field 𝕜] [Module 𝕜 M] {f : M →ₗ[𝕜] M}\n    (hf : f.det = 0) : ⊥ < f.ker :=\n  by\n  have : FiniteDimensional 𝕜 M := by simp [f.finite_dimensional_of_det_ne_one, hf]\n  contrapose hf\n  simp only [bot_lt_iff_ne_bot, Classical.not_not, ← is_unit_iff_ker_eq_bot] at hf\n  exact isUnit_iff_ne_zero.1 (f.is_unit_det hf)\n#align linear_map.bot_lt_ker_of_det_eq_zero LinearMap.bot_lt_ker_of_det_eq_zero\n\nend LinearMap\n\nnamespace LinearEquiv\n\n/-- On a `linear_equiv`, the domain of `linear_map.det` can be promoted to `Rˣ`. -/\nprotected def det : (M ≃ₗ[R] M) →* Rˣ :=\n  (Units.map (LinearMap.det : (M →ₗ[R] M) →* R)).comp\n    (LinearMap.GeneralLinearGroup.generalLinearEquiv R M).symm.toMonoidHom\n#align linear_equiv.det LinearEquiv.det\n\n@[simp]\ntheorem coe_det (f : M ≃ₗ[R] M) : ↑f.det = LinearMap.det (f : M →ₗ[R] M) :=\n  rfl\n#align linear_equiv.coe_det LinearEquiv.coe_det\n\n@[simp]\ntheorem coe_inv_det (f : M ≃ₗ[R] M) : ↑f.det⁻¹ = LinearMap.det (f.symm : M →ₗ[R] M) :=\n  rfl\n#align linear_equiv.coe_inv_det LinearEquiv.coe_inv_det\n\n@[simp]\ntheorem det_refl : (LinearEquiv.refl R M).det = 1 :=\n  Units.ext <| LinearMap.det_id\n#align linear_equiv.det_refl LinearEquiv.det_refl\n\n@[simp]\ntheorem det_trans (f g : M ≃ₗ[R] M) : (f.trans g).det = g.det * f.det :=\n  map_mul _ g f\n#align linear_equiv.det_trans LinearEquiv.det_trans\n\n@[simp]\ntheorem det_symm (f : M ≃ₗ[R] M) : f.symm.det = f.det⁻¹ :=\n  map_inv _ f\n#align linear_equiv.det_symm LinearEquiv.det_symm\n\n/-- Conjugating a linear equiv by a linear equiv does not change its determinant. -/\n@[simp]\ntheorem det_conj (f : M ≃ₗ[R] M) (e : M ≃ₗ[R] M') : ((e.symm.trans f).trans e).det = f.det := by\n  rw [← Units.eq_iff, coe_det, coe_det, ← comp_coe, ← comp_coe, LinearMap.det_conj]\n#align linear_equiv.det_conj LinearEquiv.det_conj\n\nend LinearEquiv\n\n/-- The determinants of a `linear_equiv` and its inverse multiply to 1. -/\n@[simp]\ntheorem LinearEquiv.det_mul_det_symm {A : Type _} [CommRing A] [Module A M] (f : M ≃ₗ[A] M) :\n    (f : M →ₗ[A] M).det * (f.symm : M →ₗ[A] M).det = 1 := by simp [← LinearMap.det_comp]\n#align linear_equiv.det_mul_det_symm LinearEquiv.det_mul_det_symm\n\n/-- The determinants of a `linear_equiv` and its inverse multiply to 1. -/\n@[simp]\ntheorem LinearEquiv.det_symm_mul_det {A : Type _} [CommRing A] [Module A M] (f : M ≃ₗ[A] M) :\n    (f.symm : M →ₗ[A] M).det * (f : M →ₗ[A] M).det = 1 := by simp [← LinearMap.det_comp]\n#align linear_equiv.det_symm_mul_det LinearEquiv.det_symm_mul_det\n\n-- Cannot be stated using `linear_map.det` because `f` is not an endomorphism.\ntheorem LinearEquiv.isUnit_det (f : M ≃ₗ[R] M') (v : Basis ι R M) (v' : Basis ι R M') :\n    IsUnit (LinearMap.toMatrix v v' f).det :=\n  by\n  apply is_unit_det_of_left_inverse\n  simpa using (LinearMap.toMatrix_comp v v' v f.symm f).symm\n#align linear_equiv.is_unit_det LinearEquiv.isUnit_det\n\n/-- Specialization of `linear_equiv.is_unit_det` -/\ntheorem LinearEquiv.isUnit_det' {A : Type _} [CommRing A] [Module A M] (f : M ≃ₗ[A] M) :\n    IsUnit (LinearMap.det (f : M →ₗ[A] M)) :=\n  isUnit_of_mul_eq_one _ _ f.det_mul_det_symm\n#align linear_equiv.is_unit_det' LinearEquiv.isUnit_det'\n\n/-- The determinant of `f.symm` is the inverse of that of `f` when `f` is a linear equiv. -/\ntheorem LinearEquiv.det_coe_symm {𝕜 : Type _} [Field 𝕜] [Module 𝕜 M] (f : M ≃ₗ[𝕜] M) :\n    (f.symm : M →ₗ[𝕜] M).det = (f : M →ₗ[𝕜] M).det⁻¹ := by\n  field_simp [IsUnit.ne_zero f.is_unit_det']\n#align linear_equiv.det_coe_symm LinearEquiv.det_coe_symm\n\n/-- Builds a linear equivalence from a linear map whose determinant in some bases is a unit. -/\n@[simps]\ndef LinearEquiv.ofIsUnitDet {f : M →ₗ[R] M'} {v : Basis ι R M} {v' : Basis ι R M'}\n    (h : IsUnit (LinearMap.toMatrix v v' f).det) : M ≃ₗ[R] M'\n    where\n  toFun := f\n  map_add' := f.map_add\n  map_smul' := f.map_smul\n  invFun := toLin v' v (toMatrix v v' f)⁻¹\n  left_inv x :=\n    calc\n      toLin v' v (toMatrix v v' f)⁻¹ (f x) = toLin v v ((toMatrix v v' f)⁻¹ ⬝ toMatrix v v' f) x :=\n        by rw [to_lin_mul v v' v, to_lin_to_matrix, LinearMap.comp_apply]\n      _ = x := by simp [h]\n      \n  right_inv x :=\n    calc\n      f (toLin v' v (toMatrix v v' f)⁻¹ x) =\n          toLin v' v' (toMatrix v v' f ⬝ (toMatrix v v' f)⁻¹) x :=\n        by rw [to_lin_mul v' v v', LinearMap.comp_apply, to_lin_to_matrix v v']\n      _ = x := by simp [h]\n      \n#align linear_equiv.of_is_unit_det LinearEquiv.ofIsUnitDet\n\n@[simp]\ntheorem LinearEquiv.coe_ofIsUnitDet {f : M →ₗ[R] M'} {v : Basis ι R M} {v' : Basis ι R M'}\n    (h : IsUnit (LinearMap.toMatrix v v' f).det) : (LinearEquiv.ofIsUnitDet h : M →ₗ[R] M') = f :=\n  by\n  ext x\n  rfl\n#align linear_equiv.coe_of_is_unit_det LinearEquiv.coe_ofIsUnitDet\n\n/-- Builds a linear equivalence from a linear map on a finite-dimensional vector space whose\ndeterminant is nonzero. -/\n@[reducible]\ndef LinearMap.equivOfDetNeZero {𝕜 : Type _} [Field 𝕜] {M : Type _} [AddCommGroup M] [Module 𝕜 M]\n    [FiniteDimensional 𝕜 M] (f : M →ₗ[𝕜] M) (hf : LinearMap.det f ≠ 0) : M ≃ₗ[𝕜] M :=\n  have :\n    IsUnit\n      (LinearMap.toMatrix (FiniteDimensional.finBasis 𝕜 M) (FiniteDimensional.finBasis 𝕜 M)\n          f).det :=\n    by simp only [LinearMap.det_toMatrix, isUnit_iff_ne_zero.2 hf]\n  LinearEquiv.ofIsUnitDet this\n#align linear_map.equiv_of_det_ne_zero LinearMap.equivOfDetNeZero\n\ntheorem LinearMap.associated_det_of_eq_comp (e : M ≃ₗ[R] M) (f f' : M →ₗ[R] M)\n    (h : ∀ x, f x = f' (e x)) : Associated f.det f'.det :=\n  by\n  suffices Associated (f' ∘ₗ ↑e).det f'.det\n    by\n    convert this using 2\n    ext x\n    exact h x\n  rw [← mul_one f'.det, LinearMap.det_comp]\n  exact Associated.mul_left _ (associated_one_iff_is_unit.mpr e.is_unit_det')\n#align linear_map.associated_det_of_eq_comp LinearMap.associated_det_of_eq_comp\n\ntheorem LinearMap.associated_det_comp_equiv {N : Type _} [AddCommGroup N] [Module R N]\n    (f : N →ₗ[R] M) (e e' : M ≃ₗ[R] N) : Associated (f ∘ₗ ↑e).det (f ∘ₗ ↑e').det :=\n  by\n  refine' LinearMap.associated_det_of_eq_comp (e.trans e'.symm) _ _ _\n  intro x\n  simp only [LinearMap.comp_apply, LinearEquiv.coe_coe, LinearEquiv.trans_apply,\n    LinearEquiv.apply_symm_apply]\n#align linear_map.associated_det_comp_equiv LinearMap.associated_det_comp_equiv\n\n/-- The determinant of a family of vectors with respect to some basis, as an alternating\nmultilinear map. -/\ndef Basis.det : AlternatingMap R M R ι\n    where\n  toFun v := det (e.toMatrix v)\n  map_add' := by\n    intro inst v i x y\n    cases Subsingleton.elim inst ‹_›\n    simp only [e.to_matrix_update, LinearEquiv.map_add, Finsupp.coe_add]\n    exact det_update_column_add _ _ _ _\n  map_smul' := by\n    intro inst u i c x\n    cases Subsingleton.elim inst ‹_›\n    simp only [e.to_matrix_update, Algebra.id.smul_eq_mul, LinearEquiv.map_smul]\n    apply det_update_column_smul\n  map_eq_zero_of_eq' := by\n    intro v i j h hij\n    rw [← Function.update_eq_self i v, h, ← det_transpose, e.to_matrix_update, ←\n      update_row_transpose, ← e.to_matrix_transpose_apply]\n    apply det_zero_of_row_eq hij\n    rw [update_row_ne hij.symm, update_row_self]\n#align basis.det Basis.det\n\ntheorem Basis.det_apply (v : ι → M) : e.det v = det (e.toMatrix v) :=\n  rfl\n#align basis.det_apply Basis.det_apply\n\ntheorem Basis.det_self : e.det e = 1 := by simp [e.det_apply]\n#align basis.det_self Basis.det_self\n\n@[simp]\ntheorem Basis.det_isEmpty [IsEmpty ι] : e.det = AlternatingMap.constOfIsEmpty R M 1 :=\n  by\n  ext v\n  exact Matrix.det_isEmpty\n#align basis.det_is_empty Basis.det_isEmpty\n\n/-- `basis.det` is not the zero map. -/\ntheorem Basis.det_ne_zero [Nontrivial R] : e.det ≠ 0 := fun h => by simpa [h] using e.det_self\n#align basis.det_ne_zero Basis.det_ne_zero\n\ntheorem is_basis_iff_det {v : ι → M} :\n    LinearIndependent R v ∧ span R (Set.range v) = ⊤ ↔ IsUnit (e.det v) :=\n  by\n  constructor\n  · rintro ⟨hli, hspan⟩\n    set v' := Basis.mk hli hspan.ge with v'_eq\n    rw [e.det_apply]\n    convert LinearEquiv.isUnit_det (LinearEquiv.refl _ _) v' e using 2\n    ext (i j)\n    simp\n  · intro h\n    rw [Basis.det_apply, Basis.toMatrix_eq_toMatrix_constr] at h\n    set v' := Basis.map e (LinearEquiv.ofIsUnitDet h) with v'_def\n    have : ⇑v' = v := by\n      ext i\n      rw [v'_def, Basis.map_apply, LinearEquiv.ofIsUnitDet_apply, e.constr_basis]\n    rw [← this]\n    exact ⟨v'.linear_independent, v'.span_eq⟩\n#align is_basis_iff_det is_basis_iff_det\n\ntheorem Basis.isUnit_det (e' : Basis ι R M) : IsUnit (e.det e') :=\n  (is_basis_iff_det e).mp ⟨e'.LinearIndependent, e'.span_eq⟩\n#align basis.is_unit_det Basis.isUnit_det\n\n/-- Any alternating map to `R` where `ι` has the cardinality of a basis equals the determinant\nmap with respect to that basis, multiplied by the value of that alternating map on that basis. -/\ntheorem AlternatingMap.eq_smul_basis_det (f : AlternatingMap R M R ι) : f = f e • e.det :=\n  by\n  refine' Basis.ext_alternating e fun i h => _\n  let σ : Equiv.Perm ι := Equiv.ofBijective i (Finite.injective_iff_bijective.1 h)\n  change f (e ∘ σ) = (f e • e.det) (e ∘ σ)\n  simp [AlternatingMap.map_perm, Basis.det_self]\n#align alternating_map.eq_smul_basis_det AlternatingMap.eq_smul_basis_det\n\n@[simp]\ntheorem AlternatingMap.map_basis_eq_zero_iff {ι : Type _} [Finite ι] (e : Basis ι R M)\n    (f : AlternatingMap R M R ι) : f e = 0 ↔ f = 0 :=\n  ⟨fun h => by\n    cases nonempty_fintype ι\n    letI := Classical.decEq ι\n    simpa [h] using f.eq_smul_basis_det e, fun h => h.symm ▸ AlternatingMap.zero_apply _⟩\n#align alternating_map.map_basis_eq_zero_iff AlternatingMap.map_basis_eq_zero_iff\n\ntheorem AlternatingMap.map_basis_ne_zero_iff {ι : Type _} [Finite ι] (e : Basis ι R M)\n    (f : AlternatingMap R M R ι) : f e ≠ 0 ↔ f ≠ 0 :=\n  not_congr <| f.map_basis_eq_zero_iff e\n#align alternating_map.map_basis_ne_zero_iff AlternatingMap.map_basis_ne_zero_iff\n\nvariable {A : Type _} [CommRing A] [Module A M]\n\n@[simp]\ntheorem Basis.det_comp (e : Basis ι A M) (f : M →ₗ[A] M) (v : ι → M) :\n    e.det (f ∘ v) = f.det * e.det v := by\n  rw [Basis.det_apply, Basis.det_apply, ← f.det_to_matrix e, ← Matrix.det_mul,\n    e.to_matrix_eq_to_matrix_constr (f ∘ v), e.to_matrix_eq_to_matrix_constr v, ← to_matrix_comp,\n    e.constr_comp]\n#align basis.det_comp Basis.det_comp\n\n@[simp]\ntheorem Basis.det_comp_basis [Module A M'] (b : Basis ι A M) (b' : Basis ι A M') (f : M →ₗ[A] M') :\n    b'.det (f ∘ b) = LinearMap.det (f ∘ₗ (b'.Equiv b (Equiv.refl ι) : M' →ₗ[A] M)) :=\n  by\n  rw [Basis.det_apply, ← LinearMap.det_toMatrix b', LinearMap.toMatrix_comp _ b, Matrix.det_mul,\n    LinearMap.toMatrix_basis_equiv, Matrix.det_one, mul_one]\n  congr 1; ext (i j)\n  rw [Basis.toMatrix_apply, LinearMap.toMatrix_apply]\n#align basis.det_comp_basis Basis.det_comp_basis\n\ntheorem Basis.det_reindex {ι' : Type _} [Fintype ι'] [DecidableEq ι'] (b : Basis ι R M) (v : ι' → M)\n    (e : ι ≃ ι') : (b.reindex e).det v = b.det (v ∘ e) := by\n  rw [Basis.det_apply, Basis.toMatrix_reindex', det_reindex_alg_equiv, Basis.det_apply]\n#align basis.det_reindex Basis.det_reindex\n\ntheorem Basis.det_reindex_symm {ι' : Type _} [Fintype ι'] [DecidableEq ι'] (b : Basis ι R M)\n    (v : ι → M) (e : ι' ≃ ι) : (b.reindex e.symm).det (v ∘ e) = b.det v := by\n  rw [Basis.det_reindex, Function.comp.assoc, e.self_comp_symm, Function.comp.right_id]\n#align basis.det_reindex_symm Basis.det_reindex_symm\n\n@[simp]\ntheorem Basis.det_map (b : Basis ι R M) (f : M ≃ₗ[R] M') (v : ι → M') :\n    (b.map f).det v = b.det (f.symm ∘ v) := by\n  rw [Basis.det_apply, Basis.toMatrix_map, Basis.det_apply]\n#align basis.det_map Basis.det_map\n\ntheorem Basis.det_map' (b : Basis ι R M) (f : M ≃ₗ[R] M') :\n    (b.map f).det = b.det.compLinearMap f.symm :=\n  AlternatingMap.ext <| b.det_map f\n#align basis.det_map' Basis.det_map'\n\n@[simp]\ntheorem Pi.basisFun_det : (Pi.basisFun R ι).det = Matrix.detRowAlternating :=\n  by\n  ext M\n  rw [Basis.det_apply, Basis.CoePiBasisFun.toMatrix_eq_transpose, det_transpose]\n#align pi.basis_fun_det Pi.basisFun_det\n\n/-- If we fix a background basis `e`, then for any other basis `v`, we can characterise the\ncoordinates provided by `v` in terms of determinants relative to `e`. -/\ntheorem Basis.det_smul_mk_coord_eq_det_update {v : ι → M} (hli : LinearIndependent R v)\n    (hsp : ⊤ ≤ span R (range v)) (i : ι) :\n    e.det v • (Basis.mk hli hsp).Coord i = e.det.toMultilinearMap.toLinearMap v i :=\n  by\n  apply (Basis.mk hli hsp).ext\n  intro k\n  rcases eq_or_ne k i with (rfl | hik) <;>\n    simp only [Algebra.id.smul_eq_mul, Basis.coe_mk, LinearMap.smul_apply, LinearMap.coe_mk,\n      MultilinearMap.toLinearMap_apply]\n  · rw [Basis.mk_coord_apply_eq, mul_one, update_eq_self]\n    congr\n  · rw [Basis.mk_coord_apply_ne hik, MulZeroClass.mul_zero, eq_comm]\n    exact e.det.map_eq_zero_of_eq _ (by simp [hik, Function.update_apply]) hik\n#align basis.det_smul_mk_coord_eq_det_update Basis.det_smul_mk_coord_eq_det_update\n\n/-- If a basis is multiplied columnwise by scalars `w : ι → Rˣ`, then the determinant with respect\nto this basis is multiplied by the product of the inverse of these scalars. -/\ntheorem Basis.det_unitsSmul (e : Basis ι R M) (w : ι → Rˣ) :\n    (e.units_smul w).det = (↑(∏ i, w i)⁻¹ : R) • e.det :=\n  by\n  ext f\n  change\n    (Matrix.det fun i j => (e.units_smul w).repr (f j) i) =\n      (↑(∏ i, w i)⁻¹ : R) • Matrix.det fun i j => e.repr (f j) i\n  simp only [e.repr_units_smul]\n  convert Matrix.det_mul_column (fun i => (↑(w i)⁻¹ : R)) fun i j => e.repr (f j) i\n  simp [← Finset.prod_inv_distrib]\n#align basis.det_units_smul Basis.det_unitsSmul\n\n/-- The determinant of a basis constructed by `units_smul` is the product of the given units. -/\n@[simp]\ntheorem Basis.det_unitsSmul_self (w : ι → Rˣ) : e.det (e.units_smul w) = ∏ i, w i := by\n  simp [Basis.det_apply]\n#align basis.det_units_smul_self Basis.det_unitsSmul_self\n\n/-- The determinant of a basis constructed by `is_unit_smul` is the product of the given units. -/\n@[simp]\ntheorem Basis.det_isUnitSmul {w : ι → R} (hw : ∀ i, IsUnit (w i)) :\n    e.det (e.isUnitSmul hw) = ∏ i, w i :=\n  e.det_unitsSmul_self _\n#align basis.det_is_unit_smul Basis.det_isUnitSmul\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/Determinant.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.49969549409500735}}
{"text": "opaque f : Nat → Nat\n@[simp] axiom fEq (x : Nat) (h : x ≠ 0) : f x = x\n\nexample (x : Nat) (h : x ≠ 0) : f x = x + 0 := by\n  simp (discharger := trace_state; exact (fun h' => h') h)\n\nexample (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by\n  simp (discharger := trace_state; assumption)\n  assumption\n\nexample (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by\n  simp (discharger := assumption)\n  assumption\n\nexample (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by\n  simp (disch := assumption)\n  assumption\n\nexample (x y : Nat) (h1 : x ≠ 0) (h2 : y ≠ 0) (h3 : x = y) : f x = f y + 0 := by\n  conv => lhs; simp (disch := assumption)\n  trace_state\n  conv => rhs; simp (disch := assumption)\n  trace_state\n  assumption\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/simpDisch.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.4996954940950073}}
{"text": "/-\nCopyright (c) 2014 Parikshit Khanna. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro\n-/\n--import algebra.order_functions\n--import control.monad.basic\n--import data.nat.choose.basic\n--import order.rel_classes\n\nimport mathlib4_experiments.CoreExt\n\n/-!\n# Basic properties of lists\n-/\n\nopen Function Nat\n\nnamespace List\n\n#check Nat\n#exit\ntheorem mem_split {a : α} {l : List α} (h : a ∈ l) : ∃ s t : list α, l = s ++ a :: t :=\nby\n  induction l with b l ih, {cases h}, rcases h with rfl | h,\n  { exact ⟨[], l, rfl⟩ },\n  { rcases ih h with ⟨s, t, rfl⟩,\n    exact ⟨b::s, t, rfl⟩ }\n\nend List\n\n/-\n\nTO BE PORTED\n\n\nuniverses u v w x\nvariables {α : Type u} {β : Type v} {γ : Type w} {δ : Type x}\n\n\ninstance : is_left_id (list α) has_append.append [] :=\n⟨ nil_append ⟩\n\ninstance : is_right_id (list α) has_append.append [] :=\n⟨ append_nil ⟩\n\ninstance : is_associative (list α) has_append.append :=\n⟨ append_assoc ⟩\n\ntheorem cons_ne_nil (a : α) (l : list α) : a::l ≠ [].\n\ntheorem cons_ne_self (a : α) (l : list α) : a::l ≠ l :=\nmt (congr_arg length) (nat.succ_ne_self _)\n\ntheorem head_eq_of_cons_eq {h₁ h₂ : α} {t₁ t₂ : list α} :\n      (h₁::t₁) = (h₂::t₂) → h₁ = h₂ :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pheq)\n\ntheorem tail_eq_of_cons_eq {h₁ h₂ : α} {t₁ t₂ : list α} :\n      (h₁::t₁) = (h₂::t₂) → t₁ = t₂ :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pteq)\n\n@[simp] theorem cons_injective {a : α} : injective (cons a) :=\nassume l₁ l₂, assume Pe, tail_eq_of_cons_eq Pe\n\ntheorem cons_inj (a : α) {l l' : list α} : a::l = a::l' ↔ l = l' :=\ncons_injective.eq_iff\n\ntheorem exists_cons_of_ne_nil {l : list α} (h : l ≠ nil) : ∃ b L, l = b :: L :=\nby { induction l with c l',  contradiction,  use [c,l'], }\n\n/-! ### mem -/\n\ntheorem mem_singleton_self (a : α) : a ∈ [a] := mem_cons_self _ _\n\ntheorem eq_of_mem_singleton {a b : α} : a ∈ [b] → a = b :=\nassume : a ∈ [b], or.elim (eq_or_mem_of_mem_cons this)\n  (assume : a = b, this)\n  (assume : a ∈ [], absurd this (not_mem_nil a))\n\n@[simp] theorem mem_singleton {a b : α} : a ∈ [b] ↔ a = b :=\n⟨eq_of_mem_singleton, or.inl⟩\n\ntheorem mem_of_mem_cons_of_mem {a b : α} {l : list α} : a ∈ b::l → b ∈ l → a ∈ l :=\nassume ainbl binl, or.elim (eq_or_mem_of_mem_cons ainbl)\n  (assume : a = b, begin subst a, exact binl end)\n  (assume : a ∈ l, this)\n\ntheorem eq_or_ne_mem_of_mem {a b : α} {l : list α} (h : a ∈ b :: l) : a = b ∨ (a ≠ b ∧ a ∈ l) :=\nclassical.by_cases or.inl $ assume : a ≠ b, h.elim or.inl $ assume h, or.inr ⟨this, h⟩\n\ntheorem not_mem_append {a : α} {s t : list α} (h₁ : a ∉ s) (h₂ : a ∉ t) : a ∉ s ++ t :=\nmt mem_append.1 $ not_or_distrib.2 ⟨h₁, h₂⟩\n\ntheorem ne_nil_of_mem {a : α} {l : list α} (h : a ∈ l) : l ≠ [] :=\nby intro e; rw e at h; cases h\n\n-- kmb ported mem_split\n\n\n\ntheorem mem_of_ne_of_mem {a y : α} {l : list α} (h₁ : a ≠ y) (h₂ : a ∈ y :: l) : a ∈ l :=\nor.elim (eq_or_mem_of_mem_cons h₂) (λe, absurd e h₁) (λr, r)\n\ntheorem ne_of_not_mem_cons {a b : α} {l : list α} : a ∉ b::l → a ≠ b :=\nassume nin aeqb, absurd (or.inl aeqb) nin\n\ntheorem not_mem_of_not_mem_cons {a b : α} {l : list α} : a ∉ b::l → a ∉ l :=\nassume nin nainl, absurd (or.inr nainl) nin\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : α} {l : list α} : a ≠ y → a ∉ l → a ∉ y::l :=\nassume p1 p2, not.intro (assume Pain, absurd (eq_or_mem_of_mem_cons Pain) (not_or p1 p2))\n\ntheorem ne_and_not_mem_of_not_mem_cons {a y : α} {l : list α} : a ∉ y::l → a ≠ y ∧ a ∉ l :=\nassume p, and.intro (ne_of_not_mem_cons p) (not_mem_of_not_mem_cons p)\n\ntheorem mem_map_of_mem (f : α → β) {a : α} {l : list α} (h : a ∈ l) : f a ∈ map f l :=\nbegin\n  induction l with b l' ih,\n  {cases h},\n  {rcases h with rfl | h,\n    {exact or.inl rfl},\n    {exact or.inr (ih h)}}\nend\n\ntheorem exists_of_mem_map {f : α → β} {b : β} {l : list α} (h : b ∈ map f l) :\n  ∃ a, a ∈ l ∧ f a = b :=\nbegin\n  induction l with c l' ih,\n  {cases h},\n  {cases (eq_or_mem_of_mem_cons h) with h h,\n    {exact ⟨c, mem_cons_self _ _, h.symm⟩},\n    {rcases ih h with ⟨a, ha₁, ha₂⟩,\n      exact ⟨a, mem_cons_of_mem _ ha₁, ha₂⟩ }}\nend\n\n@[simp] theorem mem_map {f : α → β} {b : β} {l : list α} : b ∈ map f l ↔ ∃ a, a ∈ l ∧ f a = b :=\n⟨exists_of_mem_map, λ ⟨a, la, h⟩, by rw [← h]; exact mem_map_of_mem f la⟩\n\ntheorem mem_map_of_injective {f : α → β} (H : injective f) {a : α} {l : list α} :\n  f a ∈ map f l ↔ a ∈ l :=\n⟨λ m, let ⟨a', m', e⟩ := exists_of_mem_map m in H e ▸ m', mem_map_of_mem _⟩\n\nlemma forall_mem_map_iff {f : α → β} {l : list α} {P : β → Prop} :\n  (∀ i ∈ l.map f, P i) ↔ ∀ j ∈ l, P (f j) :=\nbegin\n  split,\n  { assume H j hj,\n    exact H (f j) (mem_map_of_mem f hj) },\n  { assume H i hi,\n    rcases mem_map.1 hi with ⟨j, hj, ji⟩,\n    rw ← ji,\n    exact H j hj }\nend\n\n@[simp] lemma map_eq_nil {f : α → β} {l : list α} : list.map f l = [] ↔ l = [] :=\n⟨by cases l; simp only [forall_prop_of_true, map, forall_prop_of_false, not_false_iff],\n  λ h, h.symm ▸ rfl⟩\n\n@[simp] theorem mem_join {a : α} : ∀ {L : list (list α)}, a ∈ join L ↔ ∃ l, l ∈ L ∧ a ∈ l\n| []       := ⟨false.elim, λ⟨_, h, _⟩, false.elim h⟩\n| (c :: L) := by simp only [join, mem_append, @mem_join L, mem_cons_iff, or_and_distrib_right,\n  exists_or_distrib, exists_eq_left]\n\ntheorem exists_of_mem_join {a : α} {L : list (list α)} : a ∈ join L → ∃ l, l ∈ L ∧ a ∈ l :=\nmem_join.1\n\ntheorem mem_join_of_mem {a : α} {L : list (list α)} {l} (lL : l ∈ L) (al : a ∈ l) : a ∈ join L :=\nmem_join.2 ⟨l, lL, al⟩\n\n@[simp]\ntheorem mem_bind {b : β} {l : list α} {f : α → list β} : b ∈ list.bind l f ↔ ∃ a ∈ l, b ∈ f a :=\niff.trans mem_join\n  ⟨λ ⟨l', h1, h2⟩, let ⟨a, al, fa⟩ := exists_of_mem_map h1 in ⟨a, al, fa.symm ▸ h2⟩,\n  λ ⟨a, al, bfa⟩, ⟨f a, mem_map_of_mem _ al, bfa⟩⟩\n\ntheorem exists_of_mem_bind {b : β} {l : list α} {f : α → list β} :\n  b ∈ list.bind l f → ∃ a ∈ l, b ∈ f a :=\nmem_bind.1\n\ntheorem mem_bind_of_mem {b : β} {l : list α} {f : α → list β} {a} (al : a ∈ l) (h : b ∈ f a) :\n  b ∈ list.bind l f :=\nmem_bind.2 ⟨a, al, h⟩\n\nlemma bind_map {g : α → list β} {f : β → γ} :\n  ∀(l : list α), list.map f (l.bind g) = l.bind (λa, (g a).map f)\n| [] := rfl\n| (a::l) := by simp only [cons_bind, map_append, bind_map l]\n\n/-! ### length -/\n\ntheorem length_eq_zero {l : list α} : length l = 0 ↔ l = [] :=\n⟨eq_nil_of_length_eq_zero, λ h, h.symm ▸ rfl⟩\n\n@[simp] lemma length_singleton (a : α) : length [a] = 1 := rfl\n\ntheorem length_pos_of_mem {a : α} : ∀ {l : list α}, a ∈ l → 0 < length l\n| (b::l) _ := zero_lt_succ _\n\ntheorem exists_mem_of_length_pos : ∀ {l : list α}, 0 < length l → ∃ a, a ∈ l\n| (b::l) _ := ⟨b, mem_cons_self _ _⟩\n\ntheorem length_pos_iff_exists_mem {l : list α} : 0 < length l ↔ ∃ a, a ∈ l :=\n⟨exists_mem_of_length_pos, λ ⟨a, h⟩, length_pos_of_mem h⟩\n\ntheorem ne_nil_of_length_pos {l : list α} : 0 < length l → l ≠ [] :=\nλ h1 h2, lt_irrefl 0 ((length_eq_zero.2 h2).subst h1)\n\ntheorem length_pos_of_ne_nil {l : list α} : l ≠ [] → 0 < length l :=\nλ h, pos_iff_ne_zero.2 $ λ h0, h $ length_eq_zero.1 h0\n\ntheorem length_pos_iff_ne_nil {l : list α} : 0 < length l ↔ l ≠ [] :=\n⟨ne_nil_of_length_pos, length_pos_of_ne_nil⟩\n\nlemma exists_mem_of_ne_nil (l : list α) (h : l ≠ []) : ∃ x, x ∈ l :=\nexists_mem_of_length_pos (length_pos_of_ne_nil h)\n\ntheorem length_eq_one {l : list α} : length l = 1 ↔ ∃ a, l = [a] :=\n⟨match l with [a], _ := ⟨a, rfl⟩ end, λ ⟨a, e⟩, e.symm ▸ rfl⟩\n\nlemma exists_of_length_succ {n} :\n  ∀ l : list α, l.length = n + 1 → ∃ h t, l = h :: t\n| [] H := absurd H.symm $ succ_ne_zero n\n| (h :: t) H := ⟨h, t, rfl⟩\n\n@[simp] lemma length_injective_iff : injective (list.length : list α → ℕ) ↔ subsingleton α :=\nbegin\n  split,\n  { intro h, refine ⟨λ x y, _⟩, suffices : [x] = [y], { simpa using this }, apply h, refl },\n  { intros hα l1 l2 hl, induction l1 generalizing l2; cases l2,\n    { refl }, { cases hl }, { cases hl },\n    congr, exactI subsingleton.elim _ _, apply l1_ih, simpa using hl }\nend\n\n@[simp] lemma length_injective [subsingleton α] : injective (length : list α → ℕ) :=\nlength_injective_iff.mpr $ by apply_instance\n\n/-! ### set-theoretic notation of lists -/\n\nlemma empty_eq : (∅ : list α) = [] := by refl\nlemma singleton_eq (x : α) : ({x} : list α) = [x] := rfl\nlemma insert_neg [decidable_eq α] {x : α} {l : list α} (h : x ∉ l) :\n  has_insert.insert x l = x :: l :=\nif_neg h\nlemma insert_pos [decidable_eq α] {x : α} {l : list α} (h : x ∈ l) :\n  has_insert.insert x l = l :=\nif_pos h\nlemma doubleton_eq [decidable_eq α] {x y : α} (h : x ≠ y) : ({x, y} : list α) = [x, y] :=\nby { rw [insert_neg, singleton_eq], rwa [singleton_eq, mem_singleton] }\n\n/-! ### bounded quantifiers over lists -/\n\ntheorem forall_mem_nil (p : α → Prop) : ∀ x ∈ @nil α, p x.\n\ntheorem forall_mem_cons : ∀ {p : α → Prop} {a : α} {l : list α},\n  (∀ x ∈ a :: l, p x) ↔ p a ∧ ∀ x ∈ l, p x :=\nball_cons\n\ntheorem forall_mem_of_forall_mem_cons {p : α → Prop} {a : α} {l : list α}\n    (h : ∀ x ∈ a :: l, p x) :\n  ∀ x ∈ l, p x :=\n(forall_mem_cons.1 h).2\n\ntheorem forall_mem_singleton {p : α → Prop} {a : α} : (∀ x ∈ [a], p x) ↔ p a :=\nby simp only [mem_singleton, forall_eq]\n\ntheorem forall_mem_append {p : α → Prop} {l₁ l₂ : list α} :\n  (∀ x ∈ l₁ ++ l₂, p x) ↔ (∀ x ∈ l₁, p x) ∧ (∀ x ∈ l₂, p x) :=\nby simp only [mem_append, or_imp_distrib, forall_and_distrib]\n\ntheorem not_exists_mem_nil (p : α → Prop) : ¬ ∃ x ∈ @nil α, p x.\n\ntheorem exists_mem_cons_of {p : α → Prop} {a : α} (l : list α) (h : p a) :\n  ∃ x ∈ a :: l, p x :=\nbex.intro a (mem_cons_self _ _) h\n\ntheorem exists_mem_cons_of_exists {p : α → Prop} {a : α} {l : list α} (h : ∃ x ∈ l, p x) :\n  ∃ x ∈ a :: l, p x :=\nbex.elim h (λ x xl px, bex.intro x (mem_cons_of_mem _ xl) px)\n\ntheorem or_exists_of_exists_mem_cons {p : α → Prop} {a : α} {l : list α} (h : ∃ x ∈ a :: l, p x) :\n  p a ∨ ∃ x ∈ l, p x :=\nbex.elim h (λ x xal px,\n  or.elim (eq_or_mem_of_mem_cons xal)\n    (assume : x = a, begin rw ←this, left, exact px end)\n    (assume : x ∈ l, or.inr (bex.intro x this px)))\n\ntheorem exists_mem_cons_iff (p : α → Prop) (a : α) (l : list α) :\n  (∃ x ∈ a :: l, p x) ↔ p a ∨ ∃ x ∈ l, p x :=\niff.intro or_exists_of_exists_mem_cons\n  (assume h, or.elim h (exists_mem_cons_of l) exists_mem_cons_of_exists)\n\n/-! ### list subset -/\n\ntheorem subset_def {l₁ l₂ : list α} : l₁ ⊆ l₂ ↔ ∀ ⦃a : α⦄, a ∈ l₁ → a ∈ l₂ := iff.rfl\n\ntheorem subset_append_of_subset_left (l l₁ l₂ : list α) : l ⊆ l₁ → l ⊆ l₁++l₂ :=\nλ s, subset.trans s $ subset_append_left _ _\n\ntheorem subset_append_of_subset_right (l l₁ l₂ : list α) : l ⊆ l₂ → l ⊆ l₁++l₂ :=\nλ s, subset.trans s $ subset_append_right _ _\n\n@[simp] theorem cons_subset {a : α} {l m : list α} :\n  a::l ⊆ m ↔ a ∈ m ∧ l ⊆ m :=\nby simp only [subset_def, mem_cons_iff, or_imp_distrib, forall_and_distrib, forall_eq]\n\ntheorem cons_subset_of_subset_of_mem {a : α} {l m : list α}\n  (ainm : a ∈ m) (lsubm : l ⊆ m) : a::l ⊆ m :=\ncons_subset.2 ⟨ainm, lsubm⟩\n\ntheorem append_subset_of_subset_of_subset {l₁ l₂ l : list α} (l₁subl : l₁ ⊆ l) (l₂subl : l₂ ⊆ l) :\n  l₁ ++ l₂ ⊆ l :=\nλ a h, (mem_append.1 h).elim (@l₁subl _) (@l₂subl _)\n\n@[simp] theorem append_subset_iff {l₁ l₂ l : list α} :\n  l₁ ++ l₂ ⊆ l ↔ l₁ ⊆ l ∧ l₂ ⊆ l :=\nbegin\n  split,\n  { intro h, simp only [subset_def] at *, split; intros; simp* },\n  { rintro ⟨h1, h2⟩, apply append_subset_of_subset_of_subset h1 h2 }\nend\n\ntheorem eq_nil_of_subset_nil : ∀ {l : list α}, l ⊆ [] → l = []\n| []     s := rfl\n| (a::l) s := false.elim $ s $ mem_cons_self a l\n\ntheorem eq_nil_iff_forall_not_mem {l : list α} : l = [] ↔ ∀ a, a ∉ l :=\nshow l = [] ↔ l ⊆ [], from ⟨λ e, e ▸ subset.refl _, eq_nil_of_subset_nil⟩\n\ntheorem map_subset {l₁ l₂ : list α} (f : α → β) (H : l₁ ⊆ l₂) : map f l₁ ⊆ map f l₂ :=\nλ x, by simp only [mem_map, not_and, exists_imp_distrib, and_imp]; exact λ a h e, ⟨a, H h, e⟩\n\ntheorem map_subset_iff {l₁ l₂ : list α} (f : α → β) (h : injective f) :\n  map f l₁ ⊆ map f l₂ ↔ l₁ ⊆ l₂ :=\nbegin\n  refine ⟨_, map_subset f⟩, intros h2 x hx,\n  rcases mem_map.1 (h2 (mem_map_of_mem f hx)) with ⟨x', hx', hxx'⟩,\n  cases h hxx', exact hx'\nend\n\n/-! ### append -/\n\nlemma append_eq_has_append {L₁ L₂ : list α} : list.append L₁ L₂ = L₁ ++ L₂ := rfl\n\n@[simp] lemma singleton_append {x : α} {l : list α} : [x] ++ l = x :: l := rfl\n\ntheorem append_ne_nil_of_ne_nil_left (s t : list α) : s ≠ [] → s ++ t ≠ [] :=\nby induction s; intros; contradiction\n\ntheorem append_ne_nil_of_ne_nil_right (s t : list α) : t ≠ [] → s ++ t ≠ [] :=\nby induction s; intros; contradiction\n\n@[simp] lemma append_eq_nil {p q : list α} : (p ++ q) = [] ↔ p = [] ∧ q = [] :=\nby cases p; simp only [nil_append, cons_append, eq_self_iff_true, true_and, false_and]\n\n@[simp] lemma nil_eq_append_iff {a b : list α} : [] = a ++ b ↔ a = [] ∧ b = [] :=\nby rw [eq_comm, append_eq_nil]\n\nlemma append_eq_cons_iff {a b c : list α} {x : α} :\n  a ++ b = x :: c ↔ (a = [] ∧ b = x :: c) ∨ (∃a', a = x :: a' ∧ c = a' ++ b) :=\nby cases a; simp only [and_assoc, @eq_comm _ c, nil_append, cons_append, eq_self_iff_true,\n  true_and, false_and, exists_false, false_or, or_false, exists_and_distrib_left, exists_eq_left']\n\nlemma cons_eq_append_iff {a b c : list α} {x : α} :\n  (x :: c : list α) = a ++ b ↔ (a = [] ∧ b = x :: c) ∨ (∃a', a = x :: a' ∧ c = a' ++ b) :=\nby rw [eq_comm, append_eq_cons_iff]\n\nlemma append_eq_append_iff {a b c d : list α} :\n  a ++ b = c ++ d ↔ (∃a', c = a ++ a' ∧ b = a' ++ d) ∨ (∃c', a = c ++ c' ∧ d = c' ++ b) :=\nbegin\n  induction a generalizing c,\n  case nil { rw nil_append, split,\n    { rintro rfl, left, exact ⟨_, rfl, rfl⟩ },\n    { rintro (⟨a', rfl, rfl⟩ | ⟨a', H, rfl⟩), {refl}, {rw [← append_assoc, ← H], refl} } },\n  case cons : a as ih {\n    cases c,\n    { simp only [cons_append, nil_append, false_and, exists_false, false_or, exists_eq_left'],\n      exact eq_comm },\n    { simp only [cons_append, @eq_comm _ a, ih, and_assoc, and_or_distrib_left,\n        exists_and_distrib_left] } }\nend\n\n@[simp] theorem split_at_eq_take_drop : ∀ (n : ℕ) (l : list α), split_at n l = (take n l, drop n l)\n| 0        a         := rfl\n| (succ n) []        := rfl\n| (succ n) (x :: xs) := by simp only [split_at, split_at_eq_take_drop n xs, take, drop]\n\n@[simp] theorem take_append_drop : ∀ (n : ℕ) (l : list α), take n l ++ drop n l = l\n| 0        a         := rfl\n| (succ n) []        := rfl\n| (succ n) (x :: xs) := congr_arg (cons x) $ take_append_drop n xs\n\n-- TODO(Leo): cleanup proof after arith dec proc\ntheorem append_inj :\n  ∀ {s₁ s₂ t₁ t₂ : list α}, s₁ ++ t₁ = s₂ ++ t₂ → length s₁ = length s₂ → s₁ = s₂ ∧ t₁ = t₂\n| []      []      t₁ t₂ h hl := ⟨rfl, h⟩\n| (a::s₁) []      t₁ t₂ h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl\n| []      (b::s₂) t₁ t₂ h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl.symm\n| (a::s₁) (b::s₂) t₁ t₂ h hl := list.no_confusion h $ λab hap,\n  let ⟨e1, e2⟩ := @append_inj s₁ s₂ t₁ t₂ hap (succ.inj hl) in\n  by rw [ab, e1, e2]; exact ⟨rfl, rfl⟩\n\ntheorem append_inj_right {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n  (hl : length s₁ = length s₂) : t₁ = t₂ :=\n(append_inj h hl).right\n\ntheorem append_inj_left {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n  (hl : length s₁ = length s₂) : s₁ = s₂ :=\n(append_inj h hl).left\n\ntheorem append_inj' {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂) (hl : length t₁ = length t₂) :\n  s₁ = s₂ ∧ t₁ = t₂ :=\nappend_inj h $ @nat.add_right_cancel _ (length t₁) _ $\nlet hap := congr_arg length h in by simp only [length_append] at hap; rwa [← hl] at hap\n\ntheorem append_inj_right' {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n  (hl : length t₁ = length t₂) : t₁ = t₂ :=\n(append_inj' h hl).right\n\ntheorem append_inj_left' {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n  (hl : length t₁ = length t₂) : s₁ = s₂ :=\n(append_inj' h hl).left\n\ntheorem append_left_cancel {s t₁ t₂ : list α} (h : s ++ t₁ = s ++ t₂) : t₁ = t₂ :=\nappend_inj_right h rfl\n\ntheorem append_right_cancel {s₁ s₂ t : list α} (h : s₁ ++ t = s₂ ++ t) : s₁ = s₂ :=\nappend_inj_left' h rfl\n\ntheorem append_right_injective (s : list α) : function.injective (λ t, s ++ t) :=\nλ t₁ t₂, append_left_cancel\n\ntheorem append_right_inj {t₁ t₂ : list α} (s) : s ++ t₁ = s ++ t₂ ↔ t₁ = t₂ :=\n(append_right_injective s).eq_iff\n\ntheorem append_left_injective (t : list α) : function.injective (λ s, s ++ t) :=\nλ s₁ s₂, append_right_cancel\n\ntheorem append_left_inj {s₁ s₂ : list α} (t) : s₁ ++ t = s₂ ++ t ↔ s₁ = s₂ :=\n(append_left_injective t).eq_iff\n\ntheorem map_eq_append_split {f : α → β} {l : list α} {s₁ s₂ : list β}\n  (h : map f l = s₁ ++ s₂) : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ map f l₁ = s₁ ∧ map f l₂ = s₂ :=\nbegin\n  have := h, rw [← take_append_drop (length s₁) l] at this ⊢,\n  rw map_append at this,\n  refine ⟨_, _, rfl, append_inj this _⟩,\n  rw [length_map, length_take, min_eq_left],\n  rw [← length_map f l, h, length_append],\n  apply nat.le_add_right\nend\n\n/-! ### repeat -/\n\n@[simp] theorem repeat_succ (a : α) (n) : repeat a (n + 1) = a :: repeat a n := rfl\n\ntheorem mem_repeat {a b : α} : ∀ {n}, b ∈ repeat a n ↔ n ≠ 0 ∧ b = a\n| 0 := by simp\n| (n + 1) := by simp [mem_repeat]\n\ntheorem eq_of_mem_repeat {a b : α} {n} (h :  b ∈ repeat a n) : b = a :=\n(mem_repeat.1 h).2\n\ntheorem eq_repeat_of_mem {a : α} : ∀ {l : list α}, (∀ b ∈ l, b = a) → l = repeat a l.length\n| []     H := rfl\n| (b::l) H := by cases forall_mem_cons.1 H with H₁ H₂;\n  unfold length repeat; congr; [exact H₁, exact eq_repeat_of_mem H₂]\n\ntheorem eq_repeat' {a : α} {l : list α} : l = repeat a l.length ↔ ∀ b ∈ l, b = a :=\n⟨λ h, h.symm ▸ λ b, eq_of_mem_repeat, eq_repeat_of_mem⟩\n\ntheorem eq_repeat {a : α} {n} {l : list α} : l = repeat a n ↔ length l = n ∧ ∀ b ∈ l, b = a :=\n⟨λ h, h.symm ▸ ⟨length_repeat _ _, λ b, eq_of_mem_repeat⟩,\n λ ⟨e, al⟩, e ▸ eq_repeat_of_mem al⟩\n\ntheorem repeat_add (a : α) (m n) : repeat a (m + n) = repeat a m ++ repeat a n :=\nby induction m; simp only [*, zero_add, succ_add, repeat]; split; refl\n\ntheorem repeat_subset_singleton (a : α) (n) : repeat a n ⊆ [a] :=\nλ b h, mem_singleton.2 (eq_of_mem_repeat h)\n\n@[simp] theorem map_const (l : list α) (b : β) : map (function.const α b) l = repeat b l.length :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\ntheorem eq_of_mem_map_const {b₁ b₂ : β} {l : list α} (h : b₁ ∈ map (function.const α b₂) l) :\n  b₁ = b₂ :=\nby rw map_const at h; exact eq_of_mem_repeat h\n\n@[simp] theorem map_repeat (f : α → β) (a : α) (n) : map f (repeat a n) = repeat (f a) n :=\nby induction n; [refl, simp only [*, repeat, map]]; split; refl\n\n@[simp] theorem tail_repeat (a : α) (n) : tail (repeat a n) = repeat a n.pred :=\nby cases n; refl\n\n@[simp] theorem join_repeat_nil (n : ℕ) : join (repeat [] n) = @nil α :=\nby induction n; [refl, simp only [*, repeat, join, append_nil]]\n\nlemma repeat_left_injective {n : ℕ} (hn : n ≠ 0) :\n  function.injective (λ a : α, repeat a n) :=\nλ a b h, (eq_repeat.1 h).2 _ $ mem_repeat.2 ⟨hn, rfl⟩\n\nlemma repeat_left_inj {a b : α} {n : ℕ} (hn : n ≠ 0) :\n  repeat a n = repeat b n ↔ a = b :=\n(repeat_left_injective hn).eq_iff\n\n@[simp] lemma repeat_left_inj' {a b : α} :\n  ∀ {n}, repeat a n = repeat b n ↔ n = 0 ∨ a = b\n| 0 := by simp\n| (n + 1) := (repeat_left_inj n.succ_ne_zero).trans $ by simp only [n.succ_ne_zero, false_or]\n\nlemma repeat_right_injective (a : α) : function.injective (repeat a) :=\nfunction.left_inverse.injective (length_repeat a)\n\n@[simp] lemma repeat_right_inj {a : α} {n m : ℕ} :\n  repeat a n = repeat a m ↔ n = m :=\n(repeat_right_injective a).eq_iff\n\n/-! ### pure -/\n\n@[simp] theorem mem_pure {α} (x y : α) :\n  x ∈ (pure y : list α) ↔ x = y := by simp! [pure,list.ret]\n\n/-! ### bind -/\n\n@[simp] theorem bind_eq_bind {α β} (f : α → list β) (l : list α) :\n  l >>= f = l.bind f := rfl\n\n-- TODO: duplicate of a lemma in core\ntheorem bind_append (f : α → list β) (l₁ l₂ : list α) :\n  (l₁ ++ l₂).bind f = l₁.bind f ++ l₂.bind f :=\nappend_bind _ _ _\n\n@[simp] theorem bind_singleton (f : α → list β) (x : α) : [x].bind f = f x :=\nappend_nil (f x)\n\n/-! ### concat -/\n\ntheorem concat_nil (a : α) : concat [] a = [a] := rfl\n\ntheorem concat_cons (a b : α) (l : list α) : concat (a :: l) b = a :: concat l b := rfl\n\n@[simp] theorem concat_eq_append (a : α) (l : list α) : concat l a = l ++ [a] :=\nby induction l; simp only [*, concat]; split; refl\n\ntheorem init_eq_of_concat_eq {a : α} {l₁ l₂ : list α} : concat l₁ a = concat l₂ a → l₁ = l₂ :=\nbegin\n  intro h,\n  rw [concat_eq_append, concat_eq_append] at h,\n  exact append_right_cancel h\nend\n\ntheorem last_eq_of_concat_eq {a b : α} {l : list α} : concat l a = concat l b → a = b :=\nbegin\n  intro h,\n  rw [concat_eq_append, concat_eq_append] at h,\n  exact head_eq_of_cons_eq (append_left_cancel h)\nend\n\ntheorem concat_ne_nil (a : α) (l : list α) : concat l a ≠ [] :=\nby simp\n\ntheorem concat_append (a : α) (l₁ l₂ : list α) : concat l₁ a ++ l₂ = l₁ ++ a :: l₂ :=\nby simp\n\ntheorem length_concat (a : α) (l : list α) : length (concat l a) = succ (length l) :=\nby simp only [concat_eq_append, length_append, length]\n\ntheorem append_concat (a : α) (l₁ l₂ : list α) : l₁ ++ concat l₂ a = concat (l₁ ++ l₂) a :=\nby simp\n\n/-! ### reverse -/\n\n@[simp] theorem reverse_nil : reverse (@nil α) = [] := rfl\n\nlocal attribute [simp] reverse_core\n\n@[simp] theorem reverse_cons (a : α) (l : list α) : reverse (a::l) = reverse l ++ [a] :=\nhave aux : ∀ l₁ l₂, reverse_core l₁ l₂ ++ [a] = reverse_core l₁ (l₂ ++ [a]),\nby intro l₁; induction l₁; intros; [refl, simp only [*, reverse_core, cons_append]],\n(aux l nil).symm\n\ntheorem reverse_core_eq (l₁ l₂ : list α) : reverse_core l₁ l₂ = reverse l₁ ++ l₂ :=\nby induction l₁ generalizing l₂; [refl, simp only [*, reverse_core, reverse_cons, append_assoc]];\n  refl\n\ntheorem reverse_cons' (a : α) (l : list α) : reverse (a::l) = concat (reverse l) a :=\nby simp only [reverse_cons, concat_eq_append]\n\n@[simp] theorem reverse_singleton (a : α) : reverse [a] = [a] := rfl\n\n@[simp] theorem reverse_append (s t : list α) : reverse (s ++ t) = (reverse t) ++ (reverse s) :=\nby induction s; [rw [nil_append, reverse_nil, append_nil],\nsimp only [*, cons_append, reverse_cons, append_assoc]]\n\ntheorem reverse_concat (l : list α) (a : α) : reverse (concat l a) = a :: reverse l :=\nby rw [concat_eq_append, reverse_append, reverse_singleton, singleton_append]\n\n@[simp] theorem reverse_reverse (l : list α) : reverse (reverse l) = l :=\nby induction l; [refl, simp only [*, reverse_cons, reverse_append]]; refl\n\n@[simp] theorem reverse_involutive : involutive (@reverse α) :=\nλ l, reverse_reverse l\n\n@[simp] theorem reverse_injective : injective (@reverse α) :=\nreverse_involutive.injective\n\n@[simp] theorem reverse_inj {l₁ l₂ : list α} : reverse l₁ = reverse l₂ ↔ l₁ = l₂ :=\nreverse_injective.eq_iff\n\nlemma reverse_eq_iff {l l' : list α} :\n  l.reverse = l' ↔ l = l'.reverse :=\nreverse_involutive.eq_iff\n\n@[simp] theorem reverse_eq_nil {l : list α} : reverse l = [] ↔ l = [] :=\n@reverse_inj _ l []\n\ntheorem concat_eq_reverse_cons (a : α) (l : list α) : concat l a = reverse (a :: reverse l) :=\nby simp only [concat_eq_append, reverse_cons, reverse_reverse]\n\n@[simp] theorem length_reverse (l : list α) : length (reverse l) = length l :=\nby induction l; [refl, simp only [*, reverse_cons, length_append, length]]\n\n@[simp] theorem map_reverse (f : α → β) (l : list α) : map f (reverse l) = reverse (map f l) :=\nby induction l; [refl, simp only [*, map, reverse_cons, map_append]]\n\ntheorem map_reverse_core (f : α → β) (l₁ l₂ : list α) :\n  map f (reverse_core l₁ l₂) = reverse_core (map f l₁) (map f l₂) :=\nby simp only [reverse_core_eq, map_append, map_reverse]\n\n@[simp] theorem mem_reverse {a : α} {l : list α} : a ∈ reverse l ↔ a ∈ l :=\nby induction l; [refl, simp only [*, reverse_cons, mem_append, mem_singleton, mem_cons_iff,\n  not_mem_nil, false_or, or_false, or_comm]]\n\n@[simp] theorem reverse_repeat (a : α) (n) : reverse (repeat a n) = repeat a n :=\neq_repeat.2 ⟨by simp only [length_reverse, length_repeat],\n  λ b h, eq_of_mem_repeat (mem_reverse.1 h)⟩\n\n/-! ### empty -/\n\nattribute [simp] list.empty\n\nlemma empty_iff_eq_nil {l : list α} : l.empty ↔ l = [] :=\nlist.cases_on l (by simp) (by simp)\n\n/-! ### init -/\n\n@[simp] theorem length_init : ∀ (l : list α), length (init l) = length l - 1\n| [] := rfl\n| [a] := rfl\n| (a :: b :: l) :=\nbegin\n  rw init,\n  simp only [add_left_inj, length, succ_add_sub_one],\n  exact length_init (b :: l)\nend\n\n/-! ### last -/\n\n@[simp] theorem last_cons {a : α} {l : list α} :\n  ∀ (h₁ : a :: l ≠ nil) (h₂ : l ≠ nil), last (a :: l) h₁ = last l h₂ :=\nby {induction l; intros, contradiction, reflexivity}\n\n@[simp] theorem last_append {a : α} (l : list α) (h : l ++ [a] ≠ []) : last (l ++ [a]) h = a :=\nby induction l;\n  [refl, simp only [cons_append, last_cons _ (λ H, cons_ne_nil _ _ (append_eq_nil.1 H).2), *]]\n\ntheorem last_concat {a : α} (l : list α) (h : concat l a ≠ []) : last (concat l a) h = a :=\nby simp only [concat_eq_append, last_append]\n\n@[simp] theorem last_singleton (a : α) (h : [a] ≠ []) : last [a] h = a := rfl\n\n@[simp] theorem last_cons_cons (a₁ a₂ : α) (l : list α) (h : a₁::a₂::l ≠ []) :\n  last (a₁::a₂::l) h = last (a₂::l) (cons_ne_nil a₂ l) := rfl\n\ntheorem init_append_last : ∀ {l : list α} (h : l ≠ []), init l ++ [last l h] = l\n| [] h := absurd rfl h\n| [a] h := rfl\n| (a::b::l) h :=\nbegin\n  rw [init, cons_append, last_cons (cons_ne_nil _ _) (cons_ne_nil _ _)],\n  congr,\n  exact init_append_last (cons_ne_nil b l)\nend\n\ntheorem last_congr {l₁ l₂ : list α} (h₁ : l₁ ≠ []) (h₂ : l₂ ≠ []) (h₃ : l₁ = l₂) :\n  last l₁ h₁ = last l₂ h₂ :=\nby subst l₁\n\ntheorem last_mem : ∀ {l : list α} (h : l ≠ []), last l h ∈ l\n| [] h := absurd rfl h\n| [a] h := or.inl rfl\n| (a::b::l) h := or.inr $ by { rw [last_cons_cons], exact last_mem (cons_ne_nil b l) }\n\nlemma last_repeat_succ (a m : ℕ) :\n  (repeat a m.succ).last (ne_nil_of_length_eq_succ\n  (show (repeat a m.succ).length = m.succ, by rw length_repeat)) = a :=\nbegin\n  induction m with k IH,\n  { simp },\n  { simpa only [repeat_succ, last] }\nend\n\n/-! ### last' -/\n\n@[simp] theorem last'_is_none :\n  ∀ {l : list α}, (last' l).is_none ↔ l = []\n| [] := by simp\n| [a] := by simp\n| (a::b::l) := by simp [@last'_is_none (b::l)]\n\n@[simp] theorem last'_is_some : ∀ {l : list α}, l.last'.is_some ↔ l ≠ []\n| [] := by simp\n| [a] := by simp\n| (a::b::l) := by simp [@last'_is_some (b::l)]\n\ntheorem mem_last'_eq_last : ∀ {l : list α} {x : α}, x ∈ l.last' → ∃ h, x = last l h\n| [] x hx := false.elim $ by simpa using hx\n| [a] x hx := have a = x, by simpa using hx, this ▸ ⟨cons_ne_nil a [], rfl⟩\n| (a::b::l) x hx :=\n  begin\n    rw last' at hx,\n    rcases mem_last'_eq_last hx with ⟨h₁, h₂⟩,\n    use cons_ne_nil _ _,\n    rwa [last_cons]\n  end\n\ntheorem mem_of_mem_last' {l : list α} {a : α} (ha : a ∈ l.last') : a ∈ l :=\nlet ⟨h₁, h₂⟩ := mem_last'_eq_last ha in h₂.symm ▸ last_mem _\n\ntheorem init_append_last' : ∀ {l : list α} (a ∈ l.last'), init l ++ [a] = l\n| [] a ha := (option.not_mem_none a ha).elim\n| [a] _ rfl := rfl\n| (a :: b :: l) c hc := by { rw [last'] at hc, rw [init, cons_append, init_append_last' _ hc] }\n\ntheorem ilast_eq_last' [inhabited α] : ∀ l : list α, l.ilast = l.last'.iget\n| [] := by simp [ilast, arbitrary]\n| [a] := rfl\n| [a, b] := rfl\n| [a, b, c] := rfl\n| (a :: b :: c :: l) := by simp [ilast, ilast_eq_last' (c :: l)]\n\n@[simp] theorem last'_append_cons : ∀ (l₁ : list α) (a : α) (l₂ : list α),\n  last' (l₁ ++ a :: l₂) = last' (a :: l₂)\n| [] a l₂ := rfl\n| [b] a l₂ := rfl\n| (b::c::l₁) a l₂ := by rw [cons_append, cons_append, last', ← cons_append, last'_append_cons]\n\ntheorem last'_append_of_ne_nil (l₁ : list α) : ∀ {l₂ : list α} (hl₂ : l₂ ≠ []),\n  last' (l₁ ++ l₂) = last' l₂\n| [] hl₂ := by contradiction\n| (b::l₂) _ := last'_append_cons l₁ b l₂\n\n/-! ### head(') and tail -/\n\ntheorem head_eq_head' [inhabited α] (l : list α) : head l = (head' l).iget :=\nby cases l; refl\n\ntheorem mem_of_mem_head' {x : α} : ∀ {l : list α}, x ∈ l.head' → x ∈ l\n| [] h := (option.not_mem_none _ h).elim\n| (a::l) h := by { simp only [head', option.mem_def] at h, exact h ▸ or.inl rfl }\n\n@[simp] theorem head_cons [inhabited α] (a : α) (l : list α) : head (a::l) = a := rfl\n\n@[simp] theorem tail_nil : tail (@nil α) = [] := rfl\n\n@[simp] theorem tail_cons (a : α) (l : list α) : tail (a::l) = l := rfl\n\n@[simp] theorem head_append [inhabited α] (t : list α) {s : list α} (h : s ≠ []) :\n  head (s ++ t) = head s :=\nby {induction s, contradiction, refl}\n\ntheorem tail_append_singleton_of_ne_nil {a : α} {l : list α} (h : l ≠ nil) :\n  tail (l ++ [a]) = tail l ++ [a] :=\nby { induction l,  contradiction, rw [tail,cons_append,tail], }\n\ntheorem cons_head'_tail : ∀ {l : list α} {a : α} (h : a ∈ head' l), a :: tail l = l\n| [] a h := by contradiction\n| (b::l) a h := by { simp at h, simp [h] }\n\ntheorem head_mem_head' [inhabited α] : ∀ {l : list α} (h : l ≠ []), head l ∈ head' l\n| [] h := by contradiction\n| (a::l) h := rfl\n\ntheorem cons_head_tail [inhabited α] {l : list α} (h : l ≠ []) : (head l)::(tail l) = l :=\ncons_head'_tail (head_mem_head' h)\n\nlemma head_mem_self [inhabited α] {l : list α} (h : l ≠ nil) : l.head ∈ l :=\nbegin\n  have h' := mem_cons_self l.head l.tail,\n  rwa cons_head_tail h at h',\nend\n\n@[simp] theorem head'_map (f : α → β) (l) : head' (map f l) = (head' l).map f := by cases l; refl\n\nlemma tail_append_of_ne_nil (l l' : list α) (h : l ≠ []) :\n  (l ++ l').tail = l.tail ++ l' :=\nbegin\n  cases l,\n  { contradiction },\n  { simp }\nend\n\n/-! ### Induction from the right -/\n\n/-- Induction principle from the right for lists: if a property holds for the empty list, and\nfor `l ++ [a]` if it holds for `l`, then it holds for all lists. The principle is given for\na `Sort`-valued predicate, i.e., it can also be used to construct data. -/\n@[elab_as_eliminator] def reverse_rec_on {C : list α → Sort*}\n  (l : list α) (H0 : C [])\n  (H1 : ∀ (l : list α) (a : α), C l → C (l ++ [a])) : C l :=\nbegin\n  rw ← reverse_reverse l,\n  induction reverse l,\n  { exact H0 },\n  { rw reverse_cons, exact H1 _ _ ih }\nend\n\n/-- Bidirectional induction principle for lists: if a property holds for the empty list, the\nsingleton list, and `a :: (l ++ [b])` from `l`, then it holds for all lists. This can be used to\nprove statements about palindromes. The principle is given for a `Sort`-valued predicate, i.e., it\ncan also be used to construct data. -/\ndef bidirectional_rec {C : list α → Sort*}\n    (H0 : C []) (H1 : ∀ (a : α), C [a])\n    (Hn : ∀ (a : α) (l : list α) (b : α), C l → C (a :: (l ++ [b]))) : ∀ l, C l\n| [] := H0\n| [a] := H1 a\n| (a :: b :: l) :=\nlet l' := init (b :: l), b' := last (b :: l) (cons_ne_nil _ _) in\nhave length l' < length (a :: b :: l), by { change _ < length l + 2, simp },\nbegin\n  rw ←init_append_last (cons_ne_nil b l),\n  have : C l', from bidirectional_rec l',\n  exact Hn a l' b' ‹C l'›\nend\nusing_well_founded { rel_tac := λ _ _, `[exact ⟨_, measure_wf list.length⟩] }\n\n/-- Like `bidirectional_rec`, but with the list parameter placed first. -/\n@[elab_as_eliminator] def bidirectional_rec_on {C : list α → Sort*}\n    (l : list α) (H0 : C []) (H1 : ∀ (a : α), C [a])\n    (Hn : ∀ (a : α) (l : list α) (b : α), C l → C (a :: (l ++ [b]))) : C l :=\nbidirectional_rec H0 H1 Hn l\n\n/-! ### sublists -/\n\n@[simp] theorem nil_sublist : Π (l : list α), [] <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons _ _ a (nil_sublist l)\n\n@[refl, simp] theorem sublist.refl : Π (l : list α), l <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons2 _ _ a (sublist.refl l)\n\n@[trans] theorem sublist.trans {l₁ l₂ l₃ : list α} (h₁ : l₁ <+ l₂) (h₂ : l₂ <+ l₃) : l₁ <+ l₃ :=\nsublist.rec_on h₂ (λ_ s, s)\n  (λl₂ l₃ a h₂ IH l₁ h₁, sublist.cons _ _ _ (IH l₁ h₁))\n  (λl₂ l₃ a h₂ IH l₁ h₁, @sublist.cases_on _ (λl₁ l₂', l₂' = a :: l₂ → l₁ <+ a :: l₃) _ _ h₁\n    (λ_, nil_sublist _)\n    (λl₁ l₂' a' h₁' e, match a', l₂', e, h₁' with ._, ._, rfl, h₁ :=\n      sublist.cons _ _ _ (IH _ h₁) end)\n    (λl₁ l₂' a' h₁' e, match a', l₂', e, h₁' with ._, ._, rfl, h₁ :=\n      sublist.cons2 _ _ _ (IH _ h₁) end) rfl)\n  l₁ h₁\n\n@[simp] theorem sublist_cons (a : α) (l : list α) : l <+ a::l :=\nsublist.cons _ _ _ (sublist.refl l)\n\ntheorem sublist_of_cons_sublist {a : α} {l₁ l₂ : list α} : a::l₁ <+ l₂ → l₁ <+ l₂ :=\nsublist.trans (sublist_cons a l₁)\n\ntheorem cons_sublist_cons {l₁ l₂ : list α} (a : α) (s : l₁ <+ l₂) : a::l₁ <+ a::l₂ :=\nsublist.cons2 _ _ _ s\n\n@[simp] theorem sublist_append_left : Π (l₁ l₂ : list α), l₁ <+ l₁++l₂\n| []      l₂ := nil_sublist _\n| (a::l₁) l₂ := cons_sublist_cons _ (sublist_append_left l₁ l₂)\n\n@[simp] theorem sublist_append_right : Π (l₁ l₂ : list α), l₂ <+ l₁++l₂\n| []      l₂ := sublist.refl _\n| (a::l₁) l₂ := sublist.cons _ _ _ (sublist_append_right l₁ l₂)\n\ntheorem sublist_cons_of_sublist (a : α) {l₁ l₂ : list α} : l₁ <+ l₂ → l₁ <+ a::l₂ :=\nsublist.cons _ _ _\n\ntheorem sublist_append_of_sublist_left {l l₁ l₂ : list α} (s : l <+ l₁) : l <+ l₁++l₂ :=\ns.trans $ sublist_append_left _ _\n\ntheorem sublist_append_of_sublist_right {l l₁ l₂ : list α} (s : l <+ l₂) : l <+ l₁++l₂ :=\ns.trans $ sublist_append_right _ _\n\ntheorem sublist_of_cons_sublist_cons {l₁ l₂ : list α} : ∀ {a : α}, a::l₁ <+ a::l₂ → l₁ <+ l₂\n| ._ (sublist.cons  ._ ._ a s) := sublist_of_cons_sublist s\n| ._ (sublist.cons2 ._ ._ a s) := s\n\ntheorem cons_sublist_cons_iff {l₁ l₂ : list α} {a : α} : a::l₁ <+ a::l₂ ↔ l₁ <+ l₂ :=\n⟨sublist_of_cons_sublist_cons, cons_sublist_cons _⟩\n\n@[simp] theorem append_sublist_append_left {l₁ l₂ : list α} : ∀ l, l++l₁ <+ l++l₂ ↔ l₁ <+ l₂\n| []     := iff.rfl\n| (a::l) := cons_sublist_cons_iff.trans (append_sublist_append_left l)\n\ntheorem sublist.append_right {l₁ l₂ : list α} (h : l₁ <+ l₂) (l) : l₁++l <+ l₂++l :=\nbegin\n  induction h with _ _ a _ ih _ _ a _ ih,\n  { refl },\n  { apply sublist_cons_of_sublist a ih },\n  { apply cons_sublist_cons a ih }\nend\n\ntheorem sublist_or_mem_of_sublist {l l₁ l₂ : list α} {a : α} (h : l <+ l₁ ++ a::l₂) :\n  l <+ l₁ ++ l₂ ∨ a ∈ l :=\nbegin\n  induction l₁ with b l₁ IH generalizing l,\n  { cases h, { left, exact ‹l <+ l₂› }, { right, apply mem_cons_self } },\n  { cases h with _ _ _ h _ _ _ h,\n    { exact or.imp_left (sublist_cons_of_sublist _) (IH h) },\n    { exact (IH h).imp (cons_sublist_cons _) (mem_cons_of_mem _) } }\nend\n\ntheorem sublist.reverse {l₁ l₂ : list α} (h : l₁ <+ l₂) : l₁.reverse <+ l₂.reverse :=\nbegin\n  induction h with _ _ _ _ ih _ _ a _ ih, {refl},\n  { rw reverse_cons, exact sublist_append_of_sublist_left ih },\n  { rw [reverse_cons, reverse_cons], exact ih.append_right [a] }\nend\n\n@[simp] theorem reverse_sublist_iff {l₁ l₂ : list α} : l₁.reverse <+ l₂.reverse ↔ l₁ <+ l₂ :=\n⟨λ h, l₁.reverse_reverse ▸ l₂.reverse_reverse ▸ h.reverse, sublist.reverse⟩\n\n@[simp] theorem append_sublist_append_right {l₁ l₂ : list α} (l) : l₁++l <+ l₂++l ↔ l₁ <+ l₂ :=\n⟨λ h, by simpa only [reverse_append, append_sublist_append_left, reverse_sublist_iff]\n  using h.reverse,\n λ h, h.append_right l⟩\n\ntheorem sublist.append {l₁ l₂ r₁ r₂ : list α}\n  (hl : l₁ <+ l₂) (hr : r₁ <+ r₂) : l₁ ++ r₁ <+ l₂ ++ r₂ :=\n(hl.append_right _).trans ((append_sublist_append_left _).2 hr)\n\ntheorem sublist.subset : Π {l₁ l₂ : list α}, l₁ <+ l₂ → l₁ ⊆ l₂\n| ._ ._ sublist.slnil             b h := h\n| ._ ._ (sublist.cons  l₁ l₂ a s) b h := mem_cons_of_mem _ (sublist.subset s h)\n| ._ ._ (sublist.cons2 l₁ l₂ a s) b h :=\n  match eq_or_mem_of_mem_cons h with\n  | or.inl h := h ▸ mem_cons_self _ _\n  | or.inr h := mem_cons_of_mem _ (sublist.subset s h)\n  end\n\ntheorem singleton_sublist {a : α} {l} : [a] <+ l ↔ a ∈ l :=\n⟨λ h, h.subset (mem_singleton_self _), λ h,\nlet ⟨s, t, e⟩ := mem_split h in e.symm ▸\n  (cons_sublist_cons _ (nil_sublist _)).trans (sublist_append_right _ _)⟩\n\ntheorem eq_nil_of_sublist_nil {l : list α} (s : l <+ []) : l = [] :=\neq_nil_of_subset_nil $ s.subset\n\ntheorem repeat_sublist_repeat (a : α) {m n} : repeat a m <+ repeat a n ↔ m ≤ n :=\n⟨λ h, by simpa only [length_repeat] using length_le_of_sublist h,\n λ h, by induction h; [refl, simp only [*, repeat_succ, sublist.cons]] ⟩\n\ntheorem eq_of_sublist_of_length_eq : ∀ {l₁ l₂ : list α}, l₁ <+ l₂ → length l₁ = length l₂ → l₁ = l₂\n| ._ ._ sublist.slnil             h := rfl\n| ._ ._ (sublist.cons  l₁ l₂ a s) h :=\n  absurd (length_le_of_sublist s) $ not_le_of_gt $ by rw h; apply lt_succ_self\n| ._ ._ (sublist.cons2 l₁ l₂ a s) h :=\n  by rw [length, length] at h; injection h with h; rw eq_of_sublist_of_length_eq s h\n\ntheorem eq_of_sublist_of_length_le {l₁ l₂ : list α} (s : l₁ <+ l₂) (h : length l₂ ≤ length l₁) :\n  l₁ = l₂ :=\neq_of_sublist_of_length_eq s (le_antisymm (length_le_of_sublist s) h)\n\ntheorem sublist.antisymm {l₁ l₂ : list α} (s₁ : l₁ <+ l₂) (s₂ : l₂ <+ l₁) : l₁ = l₂ :=\neq_of_sublist_of_length_le s₁ (length_le_of_sublist s₂)\n\ninstance decidable_sublist [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <+ l₂)\n| []      l₂      := is_true $ nil_sublist _\n| (a::l₁) []      := is_false $ λh, list.no_confusion $ eq_nil_of_sublist_nil h\n| (a::l₁) (b::l₂) :=\n  if h : a = b then\n    decidable_of_decidable_of_iff (decidable_sublist l₁ l₂) $\n      by rw [← h]; exact ⟨cons_sublist_cons _, sublist_of_cons_sublist_cons⟩\n  else decidable_of_decidable_of_iff (decidable_sublist (a::l₁) l₂)\n    ⟨sublist_cons_of_sublist _, λs, match a, l₁, s, h with\n    | a, l₁, sublist.cons ._ ._ ._ s', h := s'\n    | ._, ._, sublist.cons2 t ._ ._ s', h := absurd rfl h\n    end⟩\n\n/-! ### index_of -/\n\nsection index_of\nvariable [decidable_eq α]\n\n@[simp] theorem index_of_nil (a : α) : index_of a [] = 0 := rfl\n\ntheorem index_of_cons (a b : α) (l : list α) :\n  index_of a (b::l) = if a = b then 0 else succ (index_of a l) := rfl\n\ntheorem index_of_cons_eq {a b : α} (l : list α) : a = b → index_of a (b::l) = 0 :=\nassume e, if_pos e\n\n@[simp] theorem index_of_cons_self (a : α) (l : list α) : index_of a (a::l) = 0 :=\nindex_of_cons_eq _ rfl\n\n@[simp, priority 990]\ntheorem index_of_cons_ne {a b : α} (l : list α) : a ≠ b → index_of a (b::l) = succ (index_of a l) :=\nassume n, if_neg n\n\ntheorem index_of_eq_length {a : α} {l : list α} : index_of a l = length l ↔ a ∉ l :=\nbegin\n  induction l with b l ih,\n  { exact iff_of_true rfl (not_mem_nil _) },\n  simp only [length, mem_cons_iff, index_of_cons], split_ifs,\n  { exact iff_of_false (by rintro ⟨⟩) (λ H, H $ or.inl h) },\n  { simp only [h, false_or], rw ← ih, exact succ_inj' }\nend\n\n@[simp, priority 980]\ntheorem index_of_of_not_mem {l : list α} {a : α} : a ∉ l → index_of a l = length l :=\nindex_of_eq_length.2\n\ntheorem index_of_le_length {a : α} {l : list α} : index_of a l ≤ length l :=\nbegin\n  induction l with b l ih, {refl},\n  simp only [length, index_of_cons],\n  by_cases h : a = b, {rw if_pos h, exact nat.zero_le _},\n  rw if_neg h, exact succ_le_succ ih\nend\n\ntheorem index_of_lt_length {a} {l : list α} : index_of a l < length l ↔ a ∈ l :=\n⟨λh, decidable.by_contradiction $ λ al, ne_of_lt h $ index_of_eq_length.2 al,\nλal, lt_of_le_of_ne index_of_le_length $ λ h, index_of_eq_length.1 h al⟩\n\nend index_of\n\n/-! ### nth element -/\n\ntheorem nth_le_of_mem : ∀ {a} {l : list α}, a ∈ l → ∃ n h, nth_le l n h = a\n| a (_ :: l) (or.inl rfl) := ⟨0, succ_pos _, rfl⟩\n| a (b :: l) (or.inr m)   :=\n  let ⟨n, h, e⟩ := nth_le_of_mem m in ⟨n+1, succ_lt_succ h, e⟩\n\ntheorem nth_le_nth : ∀ {l : list α} {n} h, nth l n = some (nth_le l n h)\n| (a :: l) 0     h := rfl\n| (a :: l) (n+1) h := @nth_le_nth l n _\n\ntheorem nth_len_le : ∀ {l : list α} {n}, length l ≤ n → nth l n = none\n| []       n     h := rfl\n| (a :: l) (n+1) h := nth_len_le (le_of_succ_le_succ h)\n\ntheorem nth_eq_some {l : list α} {n a} : nth l n = some a ↔ ∃ h, nth_le l n h = a :=\n⟨λ e,\n  have h : n < length l, from lt_of_not_ge $ λ hn,\n    by rw nth_len_le hn at e; contradiction,\n  ⟨h, by rw nth_le_nth h at e;\n    injection e with e; apply nth_le_mem⟩,\nλ ⟨h, e⟩, e ▸ nth_le_nth _⟩\n\n@[simp]\ntheorem nth_eq_none_iff : ∀ {l : list α} {n}, nth l n = none ↔ length l ≤ n :=\nbegin\n  intros, split,\n  { intro h, by_contradiction h',\n    have h₂ : ∃ h, l.nth_le n h = l.nth_le n (lt_of_not_ge h') := ⟨lt_of_not_ge h', rfl⟩,\n    rw [← nth_eq_some, h] at h₂, cases h₂ },\n  { solve_by_elim [nth_len_le] },\nend\n\ntheorem nth_of_mem {a} {l : list α} (h : a ∈ l) : ∃ n, nth l n = some a :=\nlet ⟨n, h, e⟩ := nth_le_of_mem h in ⟨n, by rw [nth_le_nth, e]⟩\n\ntheorem nth_le_mem : ∀ (l : list α) n h, nth_le l n h ∈ l\n| (a :: l) 0     h := mem_cons_self _ _\n| (a :: l) (n+1) h := mem_cons_of_mem _ (nth_le_mem l _ _)\n\ntheorem nth_mem {l : list α} {n a} (e : nth l n = some a) : a ∈ l :=\nlet ⟨h, e⟩ := nth_eq_some.1 e in e ▸ nth_le_mem _ _ _\n\ntheorem mem_iff_nth_le {a} {l : list α} : a ∈ l ↔ ∃ n h, nth_le l n h = a :=\n⟨nth_le_of_mem, λ ⟨n, h, e⟩, e ▸ nth_le_mem _ _ _⟩\n\ntheorem mem_iff_nth {a} {l : list α} : a ∈ l ↔ ∃ n, nth l n = some a :=\nmem_iff_nth_le.trans $ exists_congr $ λ n, nth_eq_some.symm\n\nlemma nth_zero (l : list α) : l.nth 0 = l.head' := by cases l; refl\n\nlemma nth_injective {α : Type u} {xs : list α} {i j : ℕ}\n  (h₀ : i < xs.length)\n  (h₁ : nodup xs)\n  (h₂ : xs.nth i = xs.nth j) : i = j :=\nbegin\n  induction xs with x xs generalizing i j,\n  { cases h₀ },\n  { cases i; cases j,\n    case nat.zero nat.zero\n    { refl },\n    case nat.succ nat.succ\n    { congr, cases h₁,\n      apply xs_ih;\n      solve_by_elim [lt_of_succ_lt_succ] },\n    iterate 2\n    { dsimp at h₂,\n      cases h₁ with _ _ h h',\n      cases h x _ rfl,\n      rw mem_iff_nth,\n      exact ⟨_, h₂.symm⟩ <|>\n        exact ⟨_, h₂⟩ } },\nend\n\n@[simp] theorem nth_map (f : α → β) : ∀ l n, nth (map f l) n = (nth l n).map f\n| []       n     := rfl\n| (a :: l) 0     := rfl\n| (a :: l) (n+1) := nth_map l n\n\ntheorem nth_le_map (f : α → β) {l n} (H1 H2) : nth_le (map f l) n H1 = f (nth_le l n H2) :=\noption.some.inj $ by rw [← nth_le_nth, nth_map, nth_le_nth]; refl\n\n/-- A version of `nth_le_map` that can be used for rewriting. -/\ntheorem nth_le_map_rev (f : α → β) {l n} (H) :\n  f (nth_le l n H) = nth_le (map f l) n ((length_map f l).symm ▸ H) :=\n(nth_le_map f _ _).symm\n\n@[simp] theorem nth_le_map' (f : α → β) {l n} (H) :\n  nth_le (map f l) n H = f (nth_le l n (length_map f l ▸ H)) :=\nnth_le_map f _ _\n\n/-- If one has `nth_le L i hi` in a formula and `h : L = L'`, one can not `rw h` in the formula as\n`hi` gives `i < L.length` and not `i < L'.length`. The lemma `nth_le_of_eq` can be used to make\nsuch a rewrite, with `rw (nth_le_of_eq h)`. -/\nlemma nth_le_of_eq {L L' : list α} (h : L = L') {i : ℕ} (hi : i < L.length) :\n  nth_le L i hi = nth_le L' i (h ▸ hi) :=\nby { congr, exact h}\n\n@[simp] lemma nth_le_singleton (a : α) {n : ℕ} (hn : n < 1) :\n  nth_le [a] n hn = a :=\nhave hn0 : n = 0 := le_zero_iff.1 (le_of_lt_succ hn),\nby subst hn0; refl\n\nlemma nth_le_zero [inhabited α] {L : list α} (h : 0 < L.length) :\n  L.nth_le 0 h = L.head :=\nby { cases L, cases h, simp, }\n\nlemma nth_le_append : ∀ {l₁ l₂ : list α} {n : ℕ} (hn₁) (hn₂),\n  (l₁ ++ l₂).nth_le n hn₁ = l₁.nth_le n hn₂\n| []     _ n     hn₁ hn₂  := (not_lt_zero _ hn₂).elim\n| (a::l) _ 0     hn₁ hn₂ := rfl\n| (a::l) _ (n+1) hn₁ hn₂ := by simp only [nth_le, cons_append];\n                         exact nth_le_append _ _\n\nlemma nth_le_append_right_aux {l₁ l₂ : list α} {n : ℕ}\n  (h₁ : l₁.length ≤ n) (h₂ : n < (l₁ ++ l₂).length) : n - l₁.length < l₂.length :=\nbegin\n  rw list.length_append at h₂,\n  convert (nat.sub_lt_sub_right_iff h₁).mpr h₂,\n  simp,\nend\n\nlemma nth_le_append_right : ∀ {l₁ l₂ : list α} {n : ℕ} (h₁ : l₁.length ≤ n) (h₂),\n  (l₁ ++ l₂).nth_le n h₂ = l₂.nth_le (n - l₁.length) (nth_le_append_right_aux h₁ h₂)\n| []       _ n     h₁ h₂ := rfl\n| (a :: l) _ (n+1) h₁ h₂ :=\n  begin\n    dsimp,\n    conv { to_rhs, congr, skip, rw [←nat.sub_sub, nat.sub.right_comm, nat.add_sub_cancel], },\n    rw nth_le_append_right (nat.lt_succ_iff.mp h₁),\n  end\n\n@[simp] lemma nth_le_repeat (a : α) {n m : ℕ} (h : m < (list.repeat a n).length) :\n  (list.repeat a n).nth_le m h = a :=\neq_of_mem_repeat (nth_le_mem _ _ _)\n\nlemma nth_append {l₁ l₂ : list α} {n : ℕ} (hn : n < l₁.length) :\n  (l₁ ++ l₂).nth n = l₁.nth n :=\nhave hn' : n < (l₁ ++ l₂).length := lt_of_lt_of_le hn\n  (by rw length_append; exact le_add_right _ _),\nby rw [nth_le_nth hn, nth_le_nth hn', nth_le_append]\n\nlemma nth_append_right {l₁ l₂ : list α} {n : ℕ} (hn : l₁.length ≤ n) :\n  (l₁ ++ l₂).nth n = l₂.nth (n - l₁.length) :=\nbegin\n  by_cases hl : n < (l₁ ++ l₂).length,\n  { rw [nth_le_nth hl, nth_le_nth, nth_le_append_right hn] },\n  { rw [nth_len_le (le_of_not_lt hl), nth_len_le],\n    rw [not_lt, length_append] at hl,\n    exact nat.le_sub_left_of_add_le hl }\nend\n\nlemma last_eq_nth_le : ∀ (l : list α) (h : l ≠ []),\n  last l h = l.nth_le (l.length - 1) (sub_lt (length_pos_of_ne_nil h) one_pos)\n| [] h := rfl\n| [a] h := by rw [last_singleton, nth_le_singleton]\n| (a :: b :: l) h := by { rw [last_cons, last_eq_nth_le (b :: l)],\n                          refl, exact cons_ne_nil b l }\n\n@[simp] lemma nth_concat_length : ∀ (l : list α) (a : α), (l ++ [a]).nth l.length = some a\n| []     a := rfl\n| (b::l) a := by rw [cons_append, length_cons, nth, nth_concat_length]\n\nlemma nth_le_cons_length (x : α) (xs : list α) (n : ℕ) (h : n = xs.length) :\n  (x :: xs).nth_le n (by simp [h]) = (x :: xs).last (cons_ne_nil x xs) :=\nbegin\n  rw last_eq_nth_le,\n  congr,\n  simp [h]\nend\n\n@[ext]\ntheorem ext : ∀ {l₁ l₂ : list α}, (∀n, nth l₁ n = nth l₂ n) → l₁ = l₂\n| []      []       h := rfl\n| (a::l₁) []       h := by have h0 := h 0; contradiction\n| []      (a'::l₂) h := by have h0 := h 0; contradiction\n| (a::l₁) (a'::l₂) h := by have h0 : some a = some a' := h 0; injection h0 with aa;\n    simp only [aa, ext (λn, h (n+1))]; split; refl\n\ntheorem ext_le {l₁ l₂ : list α} (hl : length l₁ = length l₂)\n  (h : ∀n h₁ h₂, nth_le l₁ n h₁ = nth_le l₂ n h₂) : l₁ = l₂ :=\next $ λn, if h₁ : n < length l₁\n  then by rw [nth_le_nth, nth_le_nth, h n h₁ (by rwa [← hl])]\n  else let h₁ := le_of_not_gt h₁ in by { rw [nth_len_le h₁, nth_len_le], rwa [←hl], }\n\n@[simp] theorem index_of_nth_le [decidable_eq α] {a : α} :\n  ∀ {l : list α} h, nth_le l (index_of a l) h = a\n| (b::l) h := by by_cases h' : a = b;\n  simp only [h', if_pos, if_false, index_of_cons, nth_le, @index_of_nth_le l]\n\n@[simp] theorem index_of_nth [decidable_eq α] {a : α} {l : list α} (h : a ∈ l) :\n  nth l (index_of a l) = some a :=\nby rw [nth_le_nth, index_of_nth_le (index_of_lt_length.2 h)]\n\ntheorem nth_le_reverse_aux1 :\n  ∀ (l r : list α) (i h1 h2), nth_le (reverse_core l r) (i + length l) h1 = nth_le r i h2\n| []       r i := λh1 h2, rfl\n| (a :: l) r i :=\n  by rw (show i + length (a :: l) = i + 1 + length l, from add_right_comm i (length l) 1);\n    exact λh1 h2, nth_le_reverse_aux1 l (a :: r) (i+1) h1 (succ_lt_succ h2)\n\nlemma index_of_inj [decidable_eq α] {l : list α} {x y : α}\n  (hx : x ∈ l) (hy : y ∈ l) : index_of x l = index_of y l ↔ x = y :=\n⟨λ h, have nth_le l (index_of x l) (index_of_lt_length.2 hx) =\n        nth_le l (index_of y l) (index_of_lt_length.2 hy),\n      by simp only [h],\n    by simpa only [index_of_nth_le],\n  λ h, by subst h⟩\n\ntheorem nth_le_reverse_aux2 : ∀ (l r : list α) (i : nat) (h1) (h2),\n  nth_le (reverse_core l r) (length l - 1 - i) h1 = nth_le l i h2\n| []       r i     h1 h2 := absurd h2 (not_lt_zero _)\n| (a :: l) r 0     h1 h2 := begin\n    have aux := nth_le_reverse_aux1 l (a :: r) 0,\n    rw zero_add at aux,\n    exact aux _ (zero_lt_succ _)\n  end\n| (a :: l) r (i+1) h1 h2 := begin\n    have aux := nth_le_reverse_aux2 l (a :: r) i,\n    have heq := calc length (a :: l) - 1 - (i + 1)\n          = length l - (1 + i) : by rw add_comm; refl\n      ... = length l - 1 - i   : by rw nat.sub_sub,\n    rw [← heq] at aux,\n    apply aux\n  end\n\n@[simp] theorem nth_le_reverse (l : list α) (i : nat) (h1 h2) :\n  nth_le (reverse l) (length l - 1 - i) h1 = nth_le l i h2 :=\nnth_le_reverse_aux2 _ _ _ _ _\n\nlemma nth_le_reverse' (l : list α) (n : ℕ) (hn : n < l.reverse.length) (hn') :\n  l.reverse.nth_le n hn = l.nth_le (l.length - 1 - n) hn' :=\nbegin\n  rw eq_comm,\n  convert nth_le_reverse l.reverse _ _ _ using 1,\n  { simp },\n  { simpa }\nend\n\nlemma eq_cons_of_length_one {l : list α} (h : l.length = 1) :\n  l = [l.nth_le 0 (h.symm ▸ zero_lt_one)] :=\nbegin\n  refine ext_le (by convert h) (λ n h₁ h₂, _),\n  simp only [nth_le_singleton],\n  congr,\n  exact eq_bot_iff.mpr (nat.lt_succ_iff.mp h₂)\nend\n\nlemma modify_nth_tail_modify_nth_tail {f g : list α → list α} (m : ℕ) :\n  ∀n (l:list α), (l.modify_nth_tail f n).modify_nth_tail g (m + n) =\n    l.modify_nth_tail (λl, (f l).modify_nth_tail g m) n\n| 0     l      := rfl\n| (n+1) []     := rfl\n| (n+1) (a::l) := congr_arg (list.cons a) (modify_nth_tail_modify_nth_tail n l)\n\nlemma modify_nth_tail_modify_nth_tail_le\n  {f g : list α → list α} (m n : ℕ) (l : list α) (h : n ≤ m) :\n  (l.modify_nth_tail f n).modify_nth_tail g m =\n    l.modify_nth_tail (λl, (f l).modify_nth_tail g (m - n)) n :=\nbegin\n  rcases le_iff_exists_add.1 h with ⟨m, rfl⟩,\n  rw [nat.add_sub_cancel_left, add_comm, modify_nth_tail_modify_nth_tail]\nend\n\nlemma modify_nth_tail_modify_nth_tail_same {f g : list α → list α} (n : ℕ) (l:list α) :\n  (l.modify_nth_tail f n).modify_nth_tail g n = l.modify_nth_tail (g ∘ f) n :=\nby rw [modify_nth_tail_modify_nth_tail_le n n l (le_refl n), nat.sub_self]; refl\n\nlemma modify_nth_tail_id :\n  ∀n (l:list α), l.modify_nth_tail id n = l\n| 0     l      := rfl\n| (n+1) []     := rfl\n| (n+1) (a::l) := congr_arg (list.cons a) (modify_nth_tail_id n l)\n\ntheorem remove_nth_eq_nth_tail : ∀ n (l : list α), remove_nth l n = modify_nth_tail tail n l\n| 0     l      := by cases l; refl\n| (n+1) []     := rfl\n| (n+1) (a::l) := congr_arg (cons _) (remove_nth_eq_nth_tail _ _)\n\ntheorem update_nth_eq_modify_nth (a : α) : ∀ n (l : list α),\n  update_nth l n a = modify_nth (λ _, a) n l\n| 0     l      := by cases l; refl\n| (n+1) []     := rfl\n| (n+1) (b::l) := congr_arg (cons _) (update_nth_eq_modify_nth _ _)\n\ntheorem modify_nth_eq_update_nth (f : α → α) : ∀ n (l : list α),\n  modify_nth f n l = ((λ a, update_nth l n (f a)) <$> nth l n).get_or_else l\n| 0     l      := by cases l; refl\n| (n+1) []     := rfl\n| (n+1) (b::l) := (congr_arg (cons b)\n  (modify_nth_eq_update_nth n l)).trans $ by cases nth l n; refl\n\ntheorem nth_modify_nth (f : α → α) : ∀ n (l : list α) m,\n  nth (modify_nth f n l) m = (λ a, if n = m then f a else a) <$> nth l m\n| n     l      0     := by cases l; cases n; refl\n| n     []     (m+1) := by cases n; refl\n| 0     (a::l) (m+1) := by cases nth l m; refl\n| (n+1) (a::l) (m+1) := (nth_modify_nth n l m).trans $\n  by cases nth l m with b; by_cases n = m;\n  simp only [h, if_pos, if_true, if_false, option.map_none, option.map_some, mt succ.inj,\n    not_false_iff]\n\ntheorem modify_nth_tail_length (f : list α → list α) (H : ∀ l, length (f l) = length l) :\n  ∀ n l, length (modify_nth_tail f n l) = length l\n| 0     l      := H _\n| (n+1) []     := rfl\n| (n+1) (a::l) := @congr_arg _ _ _ _ (+1) (modify_nth_tail_length _ _)\n\n@[simp] theorem modify_nth_length (f : α → α) :\n  ∀ n l, length (modify_nth f n l) = length l :=\nmodify_nth_tail_length _ (λ l, by cases l; refl)\n\n@[simp] theorem update_nth_length (l : list α) (n) (a : α) :\n  length (update_nth l n a) = length l :=\nby simp only [update_nth_eq_modify_nth, modify_nth_length]\n\n@[simp] theorem nth_modify_nth_eq (f : α → α) (n) (l : list α) :\n  nth (modify_nth f n l) n = f <$> nth l n :=\nby simp only [nth_modify_nth, if_pos]\n\n@[simp] theorem nth_modify_nth_ne (f : α → α) {m n} (l : list α) (h : m ≠ n) :\n  nth (modify_nth f m l) n = nth l n :=\nby simp only [nth_modify_nth, if_neg h, id_map']\n\ntheorem nth_update_nth_eq (a : α) (n) (l : list α) :\n  nth (update_nth l n a) n = (λ _, a) <$> nth l n :=\nby simp only [update_nth_eq_modify_nth, nth_modify_nth_eq]\n\ntheorem nth_update_nth_of_lt (a : α) {n} {l : list α} (h : n < length l) :\n  nth (update_nth l n a) n = some a :=\nby rw [nth_update_nth_eq, nth_le_nth h]; refl\n\ntheorem nth_update_nth_ne (a : α) {m n} (l : list α) (h : m ≠ n) :\n  nth (update_nth l m a) n = nth l n :=\nby simp only [update_nth_eq_modify_nth, nth_modify_nth_ne _ _ h]\n\n@[simp] lemma update_nth_nil (n : ℕ) (a : α) : [].update_nth n a = [] := rfl\n\n@[simp] lemma update_nth_succ (x : α) (xs : list α) (n : ℕ) (a : α) :\n  (x :: xs).update_nth n.succ a = x :: xs.update_nth n a := rfl\n\nlemma update_nth_comm (a b : α) : Π {n m : ℕ} (l : list α) (h : n ≠ m),\n  (l.update_nth n a).update_nth m b = (l.update_nth m b).update_nth n a\n| _ _ [] _ := by simp\n| 0 0 (x :: t) h := absurd rfl h\n| (n + 1) 0 (x :: t) h := by simp [list.update_nth]\n| 0 (m + 1) (x :: t) h := by simp [list.update_nth]\n| (n + 1) (m + 1) (x :: t) h := by { simp only [update_nth, true_and, eq_self_iff_true],\n  exact update_nth_comm t (λ h', h $ nat.succ_inj'.mpr h'), }\n\n@[simp] lemma nth_le_update_nth_eq (l : list α) (i : ℕ) (a : α)\n  (h : i < (l.update_nth i a).length) : (l.update_nth i a).nth_le i h = a :=\nby rw [← option.some_inj, ← nth_le_nth, nth_update_nth_eq, nth_le_nth]; simp * at *\n\n@[simp] lemma nth_le_update_nth_of_ne {l : list α} {i j : ℕ} (h : i ≠ j) (a : α)\n  (hj : j < (l.update_nth i a).length) :\n  (l.update_nth i a).nth_le j hj = l.nth_le j (by simpa using hj) :=\nby rw [← option.some_inj, ← list.nth_le_nth, list.nth_update_nth_ne _ _ h, list.nth_le_nth]\n\nlemma mem_or_eq_of_mem_update_nth : ∀ {l : list α} {n : ℕ} {a b : α}\n  (h : a ∈ l.update_nth n b), a ∈ l ∨ a = b\n| []     n     a b h := false.elim h\n| (c::l) 0     a b h := ((mem_cons_iff _ _ _).1 h).elim\n  or.inr (or.inl ∘ mem_cons_of_mem _)\n| (c::l) (n+1) a b h := ((mem_cons_iff _ _ _).1 h).elim\n  (λ h, h ▸ or.inl (mem_cons_self _ _))\n  (λ h, (mem_or_eq_of_mem_update_nth h).elim\n    (or.inl ∘ mem_cons_of_mem _) or.inr)\n\nsection insert_nth\nvariable {a : α}\n\n@[simp] lemma insert_nth_nil (a : α) : insert_nth 0 a [] = [a] := rfl\n\n@[simp] lemma insert_nth_succ_nil (n : ℕ) (a : α) : insert_nth (n + 1) a [] = [] := rfl\n\nlemma length_insert_nth : ∀n as, n ≤ length as → length (insert_nth n a as) = length as + 1\n| 0     as       h := rfl\n| (n+1) []       h := (nat.not_succ_le_zero _ h).elim\n| (n+1) (a'::as) h := congr_arg nat.succ $ length_insert_nth n as (nat.le_of_succ_le_succ h)\n\nlemma remove_nth_insert_nth (n:ℕ) (l : list α) : (l.insert_nth n a).remove_nth n = l :=\nby rw [remove_nth_eq_nth_tail, insert_nth, modify_nth_tail_modify_nth_tail_same];\nfrom modify_nth_tail_id _ _\n\nlemma insert_nth_remove_nth_of_ge : ∀n m as, n < length as → n ≤ m →\n  insert_nth m a (as.remove_nth n) = (as.insert_nth (m + 1) a).remove_nth n\n| 0     0     []      has _   := (lt_irrefl _ has).elim\n| 0     0     (a::as) has hmn := by simp [remove_nth, insert_nth]\n| 0     (m+1) (a::as) has hmn := rfl\n| (n+1) (m+1) (a::as) has hmn :=\n  congr_arg (cons a) $\n    insert_nth_remove_nth_of_ge n m as (nat.lt_of_succ_lt_succ has) (nat.le_of_succ_le_succ hmn)\n\nlemma insert_nth_remove_nth_of_le : ∀n m as, n < length as → m ≤ n →\n  insert_nth m a (as.remove_nth n) = (as.insert_nth m a).remove_nth (n + 1)\n| n       0       (a :: as) has hmn := rfl\n| (n + 1) (m + 1) (a :: as) has hmn :=\n  congr_arg (cons a) $\n    insert_nth_remove_nth_of_le n m as (nat.lt_of_succ_lt_succ has) (nat.le_of_succ_le_succ hmn)\n\nlemma insert_nth_comm (a b : α) :\n  ∀(i j : ℕ) (l : list α) (h : i ≤ j) (hj : j ≤ length l),\n    (l.insert_nth i a).insert_nth (j + 1) b = (l.insert_nth j b).insert_nth i a\n| 0       j     l      := by simp [insert_nth]\n| (i + 1) 0     l      := assume h, (nat.not_lt_zero _ h).elim\n| (i + 1) (j+1) []     := by simp\n| (i + 1) (j+1) (c::l) :=\n  assume h₀ h₁,\n  by simp [insert_nth];\n    exact insert_nth_comm i j l (nat.le_of_succ_le_succ h₀) (nat.le_of_succ_le_succ h₁)\n\nlemma mem_insert_nth {a b : α} : ∀ {n : ℕ} {l : list α} (hi : n ≤ l.length),\n  a ∈ l.insert_nth n b ↔ a = b ∨ a ∈ l\n| 0     as       h := iff.rfl\n| (n+1) []       h := (nat.not_succ_le_zero _ h).elim\n| (n+1) (a'::as) h := begin\n  dsimp [list.insert_nth],\n  erw [list.mem_cons_iff, mem_insert_nth (nat.le_of_succ_le_succ h), list.mem_cons_iff,\n    ← or.assoc, or_comm (a = a'), or.assoc]\nend\n\nend insert_nth\n\n/-! ### map -/\n\n@[simp] lemma map_nil (f : α → β) : map f [] = [] := rfl\n\ntheorem map_eq_foldr (f : α → β) (l : list α) :\n  map f l = foldr (λ a bs, f a :: bs) [] l :=\nby induction l; simp *\n\nlemma map_congr {f g : α → β} : ∀ {l : list α}, (∀ x ∈ l, f x = g x) → map f l = map g l\n| []     _ := rfl\n| (a::l) h := let ⟨h₁, h₂⟩ := forall_mem_cons.1 h in\n  by rw [map, map, h₁, map_congr h₂]\n\nlemma map_eq_map_iff {f g : α → β} {l : list α} : map f l = map g l ↔ (∀ x ∈ l, f x = g x) :=\nbegin\n  refine ⟨_, map_congr⟩, intros h x hx,\n  rw [mem_iff_nth_le] at hx, rcases hx with ⟨n, hn, rfl⟩,\n  rw [nth_le_map_rev f, nth_le_map_rev g], congr, exact h\nend\n\ntheorem map_concat (f : α → β) (a : α) (l : list α) : map f (concat l a) = concat (map f l) (f a) :=\nby induction l; [refl, simp only [*, concat_eq_append, cons_append, map, map_append]]; split; refl\n\ntheorem map_id' {f : α → α} (h : ∀ x, f x = x) (l : list α) : map f l = l :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\ntheorem eq_nil_of_map_eq_nil {f : α → β} {l : list α} (h : map f l = nil) : l = nil :=\neq_nil_of_length_eq_zero $ by rw [← length_map f l, h]; refl\n\n@[simp] theorem map_join (f : α → β) (L : list (list α)) :\n  map f (join L) = join (map (map f) L) :=\nby induction L; [refl, simp only [*, join, map, map_append]]\n\ntheorem bind_ret_eq_map (f : α → β) (l : list α) :\n  l.bind (list.ret ∘ f) = map f l :=\nby unfold list.bind; induction l; simp only [map, join, list.ret, cons_append, nil_append, *];\n  split; refl\n\n@[simp] theorem map_eq_map {α β} (f : α → β) (l : list α) : f <$> l = map f l := rfl\n\n@[simp] theorem map_tail (f : α → β) (l) : map f (tail l) = tail (map f l) :=\nby cases l; refl\n\n@[simp] theorem map_injective_iff {f : α → β} : injective (map f) ↔ injective f :=\nbegin\n  split; intros h x y hxy,\n  { suffices : [x] = [y], { simpa using this }, apply h, simp [hxy] },\n  { induction y generalizing x, simpa using hxy,\n    cases x, simpa using hxy, simp at hxy, simp [y_ih hxy.2, h hxy.1] }\nend\n\n/--\nA single `list.map` of a composition of functions is equal to\ncomposing a `list.map` with another `list.map`, fully applied.\nThis is the reverse direction of `list.map_map`.\n-/\nlemma comp_map (h : β → γ) (g : α → β) (l : list α) :\n  map (h ∘ g) l = map h (map g l) := (map_map _ _ _).symm\n\n/--\nComposing a `list.map` with another `list.map` is equal to\na single `list.map` of composed functions.\n-/\n@[simp] lemma map_comp_map (g : β → γ) (f : α → β) :\n  map g ∘ map f = map (g ∘ f) :=\nby { ext l, rw comp_map }\n\ntheorem map_filter_eq_foldr (f : α → β) (p : α → Prop) [decidable_pred p] (as : list α) :\n  map f (filter p as) = foldr (λ a bs, if p a then f a :: bs else bs) [] as :=\nby { induction as, { refl }, { simp! [*, apply_ite (map f)] } }\n\nlemma last_map (f : α → β) {l : list α} (hl : l ≠ []) :\n  (l.map f).last (mt eq_nil_of_map_eq_nil hl) = f (l.last hl) :=\nbegin\n  induction l with l_ih l_tl l_ih,\n  { apply (hl rfl).elim },\n  { cases l_tl,\n    { simp },\n    { simpa using l_ih } }\nend\n\n/-! ### map₂ -/\n\ntheorem nil_map₂ (f : α → β → γ) (l : list β) : map₂ f [] l = [] :=\nby cases l; refl\n\ntheorem map₂_nil (f : α → β → γ) (l : list α) : map₂ f l [] = [] :=\nby cases l; refl\n\n@[simp] theorem map₂_flip (f : α → β → γ) :\n  ∀ as bs, map₂ (flip f) bs as = map₂ f as bs\n| [] [] := rfl\n| [] (b :: bs) := rfl\n| (a :: as) [] := rfl\n| (a :: as) (b :: bs) := by { simp! [map₂_flip], refl }\n\n/-! ### take, drop -/\n@[simp] theorem take_zero (l : list α) : take 0 l = [] := rfl\n\n@[simp] theorem take_nil : ∀ n, take n [] = ([] : list α)\n| 0     := rfl\n| (n+1) := rfl\n\ntheorem take_cons (n) (a : α) (l : list α) : take (succ n) (a::l) = a :: take n l := rfl\n\n@[simp] theorem take_length : ∀ (l : list α), take (length l) l = l\n| []     := rfl\n| (a::l) := begin change a :: (take (length l) l) = a :: l, rw take_length end\n\ntheorem take_all_of_le : ∀ {n} {l : list α}, length l ≤ n → take n l = l\n| 0     []     h := rfl\n| 0     (a::l) h := absurd h (not_le_of_gt (zero_lt_succ _))\n| (n+1) []     h := rfl\n| (n+1) (a::l) h :=\n  begin\n    change a :: take n l = a :: l,\n    rw [take_all_of_le (le_of_succ_le_succ h)]\n  end\n\n@[simp] theorem take_left : ∀ l₁ l₂ : list α, take (length l₁) (l₁ ++ l₂) = l₁\n| []      l₂ := rfl\n| (a::l₁) l₂ := congr_arg (cons a) (take_left l₁ l₂)\n\ntheorem take_left' {l₁ l₂ : list α} {n} (h : length l₁ = n) :\n  take n (l₁ ++ l₂) = l₁ :=\nby rw ← h; apply take_left\n\ntheorem take_take : ∀ (n m) (l : list α), take n (take m l) = take (min n m) l\n| n         0        l      := by rw [min_zero, take_zero, take_nil]\n| 0         m        l      := by rw [zero_min, take_zero, take_zero]\n| (succ n)  (succ m) nil    := by simp only [take_nil]\n| (succ n)  (succ m) (a::l) := by simp only [take, min_succ_succ, take_take n m l]; split; refl\n\ntheorem take_repeat (a : α) : ∀ (n m : ℕ), take n (repeat a m) = repeat a (min n m)\n| n        0        := by simp\n| 0        m        := by simp\n| (succ n) (succ m) := by simp [min_succ_succ, take_repeat]\n\nlemma map_take {α β : Type*} (f : α → β) :\n  ∀ (L : list α) (i : ℕ), (L.take i).map f = (L.map f).take i\n| [] i := by simp\n| L 0 := by simp\n| (h :: t) (n+1) := by { dsimp, rw [map_take], }\n\nlemma take_append_of_le_length : ∀ {l₁ l₂ : list α} {n : ℕ},\n  n ≤ l₁.length → (l₁ ++ l₂).take n = l₁.take n\n| l₁      l₂ 0     hn := by simp\n| []      l₂ (n+1) hn := absurd hn dec_trivial\n| (a::l₁) l₂ (n+1) hn :=\nby rw [list.take, list.cons_append, list.take, take_append_of_le_length (le_of_succ_le_succ hn)]\n\n/-- Taking the first `l₁.length + i` elements in `l₁ ++ l₂` is the same as appending the first\n`i` elements of `l₂` to `l₁`. -/\nlemma take_append {l₁ l₂ : list α} (i : ℕ) :\n  take (l₁.length + i) (l₁ ++ l₂) = l₁ ++ (take i l₂) :=\nbegin\n  induction l₁, { simp },\n  have : length l₁_tl + 1 + i = (length l₁_tl + i).succ,\n    by { rw nat.succ_eq_add_one, exact succ_add _ _ },\n  simp only [cons_append, length, this, take_cons, l₁_ih, eq_self_iff_true, and_self]\nend\n\n/-- The `i`-th element of a list coincides with the `i`-th element of any of its prefixes of\nlength `> i`. Version designed to rewrite from the big list to the small list. -/\nlemma nth_le_take (L : list α) {i j : ℕ} (hi : i < L.length) (hj : i < j) :\n  nth_le L i hi = nth_le (L.take j) i (by { rw length_take, exact lt_min hj hi }) :=\nby { rw nth_le_of_eq (take_append_drop j L).symm hi, exact nth_le_append _ _ }\n\n/-- The `i`-th element of a list coincides with the `i`-th element of any of its prefixes of\nlength `> i`. Version designed to rewrite from the small list to the big list. -/\nlemma nth_le_take' (L : list α) {i j : ℕ} (hi : i < (L.take j).length) :\n  nth_le (L.take j) i hi = nth_le L i (lt_of_lt_of_le hi (by simp [le_refl])) :=\nby { simp at hi, rw nth_le_take L _ hi.1 }\n\nlemma nth_take {l : list α} {n m : ℕ} (h : m < n) :\n  (l.take n).nth m = l.nth m :=\nbegin\n  induction n with n hn generalizing l m,\n  { simp only [nat.nat_zero_eq_zero] at h,\n    exact absurd h (not_lt_of_le m.zero_le) },\n  { cases l with hd tl,\n    { simp only [take_nil] },\n    { cases m,\n      { simp only [nth, take] },\n      { simpa only using hn (nat.lt_of_succ_lt_succ h) } } },\nend\n\n@[simp] lemma nth_take_of_succ {l : list α} {n : ℕ} :\n  (l.take (n + 1)).nth n = l.nth n :=\nnth_take (nat.lt_succ_self n)\n\nlemma take_succ {l : list α} {n : ℕ} :\n  l.take (n + 1) = l.take n ++ (l.nth n).to_list :=\nbegin\n  induction l with hd tl hl generalizing n,\n  { simp only [option.to_list, nth, take_nil, append_nil]},\n  { cases n,\n    { simp only [option.to_list, nth, eq_self_iff_true, and_self, take, nil_append] },\n    { simp only [hl, cons_append, nth, eq_self_iff_true, and_self, take] } }\nend\n\n@[simp] lemma take_eq_nil_iff {l : list α} {k : ℕ} :\n  l.take k = [] ↔ l = [] ∨ k = 0 :=\nby { cases l; cases k; simp [nat.succ_ne_zero] }\n\nlemma init_eq_take (l : list α) : l.init = l.take l.length.pred :=\nbegin\n  cases l with x l,\n  { simp [init] },\n  { induction l with hd tl hl generalizing x,\n    { simp [init], },\n    { simp [init, hl] } }\nend\n\nlemma init_take {n : ℕ} {l : list α} (h : n < l.length) :\n  (l.take n).init = l.take n.pred :=\nby simp [init_eq_take, min_eq_left_of_lt h, take_take, pred_le]\n\n@[simp] lemma drop_eq_nil_of_le {l : list α} {k : ℕ} (h : l.length ≤ k) :\n  l.drop k = [] :=\nby simpa [←length_eq_zero] using nat.sub_eq_zero_of_le h\n\nlemma drop_eq_nil_iff_le {l : list α} {k : ℕ} :\n  l.drop k = [] ↔ l.length ≤ k :=\nbegin\n  refine ⟨λ h, _, drop_eq_nil_of_le⟩,\n  induction k with k hk generalizing l,\n  { simp only [drop] at h,\n    simp [h] },\n  { cases l,\n    { simp },\n    { simp only [drop] at h,\n      simpa [nat.succ_le_succ_iff] using hk h } }\nend\n\nlemma tail_drop (l : list α) (n : ℕ) : (l.drop n).tail = l.drop (n + 1) :=\nbegin\n  induction l with hd tl hl generalizing n,\n  { simp },\n  { cases n,\n    { simp },\n    { simp [hl] } }\nend\n\nlemma cons_nth_le_drop_succ {l : list α} {n : ℕ} (hn : n < l.length) :\n  l.nth_le n hn :: l.drop (n + 1) = l.drop n :=\nbegin\n  induction l with hd tl hl generalizing n,\n  { exact absurd n.zero_le (not_le_of_lt (by simpa using hn)) },\n  { cases n,\n    { simp },\n    { simp only [nat.succ_lt_succ_iff, list.length] at hn,\n      simpa [list.nth_le, list.drop] using hl hn } }\nend\n\ntheorem drop_nil : ∀ n, drop n [] = ([] : list α) :=\nλ _, drop_eq_nil_of_le (nat.zero_le _)\n\nlemma mem_of_mem_drop {α} {n : ℕ} {l : list α} {x : α}\n  (h : x ∈ l.drop n) :\n  x ∈ l :=\nbegin\n  induction l generalizing n,\n  case list.nil : n h\n  { simpa using h },\n  case list.cons : l_hd l_tl l_ih n h\n  { cases n; simp only [mem_cons_iff, drop] at h ⊢,\n    { exact h },\n    right, apply l_ih h },\nend\n\n@[simp] theorem drop_one : ∀ l : list α, drop 1 l = tail l\n| []       := rfl\n| (a :: l) := rfl\n\ntheorem drop_add : ∀ m n (l : list α), drop (m + n) l = drop m (drop n l)\n| m 0     l      := rfl\n| m (n+1) []     := (drop_nil _).symm\n| m (n+1) (a::l) := drop_add m n _\n\n@[simp] theorem drop_left : ∀ l₁ l₂ : list α, drop (length l₁) (l₁ ++ l₂) = l₂\n| []      l₂ := rfl\n| (a::l₁) l₂ := drop_left l₁ l₂\n\ntheorem drop_left' {l₁ l₂ : list α} {n} (h : length l₁ = n) :\n  drop n (l₁ ++ l₂) = l₂ :=\nby rw ← h; apply drop_left\n\ntheorem drop_eq_nth_le_cons : ∀ {n} {l : list α} h,\n  drop n l = nth_le l n h :: drop (n+1) l\n| 0     (a::l) h := rfl\n| (n+1) (a::l) h := @drop_eq_nth_le_cons n _ _\n\n@[simp] lemma drop_length (l : list α) : l.drop l.length = [] :=\ncalc l.drop l.length = (l ++ []).drop l.length : by simp\n                 ... = [] : drop_left _ _\n\nlemma drop_append_of_le_length : ∀ {l₁ l₂ : list α} {n : ℕ}, n ≤ l₁.length →\n  (l₁ ++ l₂).drop n = l₁.drop n ++ l₂\n| l₁      l₂ 0     hn := by simp\n| []      l₂ (n+1) hn := absurd hn dec_trivial\n| (a::l₁) l₂ (n+1) hn :=\nby rw [drop, cons_append, drop, drop_append_of_le_length (le_of_succ_le_succ hn)]\n\n/-- Dropping the elements up to `l₁.length + i` in `l₁ + l₂` is the same as dropping the elements\nup to `i` in `l₂`. -/\nlemma drop_append {l₁ l₂ : list α} (i : ℕ) :\n  drop (l₁.length + i) (l₁ ++ l₂) = drop i l₂ :=\nbegin\n  induction l₁, { simp },\n  have : length l₁_tl + 1 + i = (length l₁_tl + i).succ,\n    by { rw nat.succ_eq_add_one, exact succ_add _ _ },\n  simp only [cons_append, length, this, drop, l₁_ih]\nend\n\n/-- The `i + j`-th element of a list coincides with the `j`-th element of the list obtained by\ndropping the first `i` elements. Version designed to rewrite from the big list to the small list. -/\nlemma nth_le_drop (L : list α) {i j : ℕ} (h : i + j < L.length) :\n  nth_le L (i + j) h = nth_le (L.drop i) j\nbegin\n  have A : i < L.length := lt_of_le_of_lt (nat.le.intro rfl) h,\n  rw (take_append_drop i L).symm at h,\n  simpa only [le_of_lt A, min_eq_left, add_lt_add_iff_left, length_take, length_append] using h\nend :=\nbegin\n  have A : length (take i L) = i, by simp [le_of_lt (lt_of_le_of_lt (nat.le.intro rfl) h)],\n  rw [nth_le_of_eq (take_append_drop i L).symm h, nth_le_append_right];\n  simp [A]\nend\n\n/--  The `i + j`-th element of a list coincides with the `j`-th element of the list obtained by\ndropping the first `i` elements. Version designed to rewrite from the small list to the big list. -/\nlemma nth_le_drop' (L : list α) {i j : ℕ} (h : j < (L.drop i).length) :\n  nth_le (L.drop i) j h = nth_le L (i + j) (nat.add_lt_of_lt_sub_left ((length_drop i L) ▸ h)) :=\nby rw nth_le_drop\n\nlemma nth_drop (L : list α) (i j : ℕ) :\n  nth (L.drop i) j = nth L (i + j) :=\nbegin\n  ext,\n  simp only [nth_eq_some, nth_le_drop', option.mem_def],\n  split;\n  exact λ ⟨h, ha⟩, ⟨by simpa [nat.lt_sub_left_iff_add_lt] using h, ha⟩\nend\n\n@[simp] theorem drop_drop (n : ℕ) : ∀ (m) (l : list α), drop n (drop m l) = drop (n + m) l\n| m     []     := by simp\n| 0     l      := by simp\n| (m+1) (a::l) :=\n  calc drop n (drop (m + 1) (a :: l)) = drop n (drop m l) : rfl\n    ... = drop (n + m) l : drop_drop m l\n    ... = drop (n + (m + 1)) (a :: l) : rfl\n\ntheorem drop_take : ∀ (m : ℕ) (n : ℕ) (l : list α),\n  drop m (take (m + n) l) = take n (drop m l)\n| 0     n _      := by simp\n| (m+1) n nil    := by simp\n| (m+1) n (_::l) :=\n  have h: m + 1 + n = (m+n) + 1, by ac_refl,\n  by simpa [take_cons, h] using drop_take m n l\n\nlemma map_drop {α β : Type*} (f : α → β) :\n  ∀ (L : list α) (i : ℕ), (L.drop i).map f = (L.map f).drop i\n| [] i := by simp\n| L 0 := by simp\n| (h :: t) (n+1) := by { dsimp, rw [map_drop], }\n\ntheorem modify_nth_tail_eq_take_drop (f : list α → list α) (H : f [] = []) :\n  ∀ n l, modify_nth_tail f n l = take n l ++ f (drop n l)\n| 0     l      := rfl\n| (n+1) []     := H.symm\n| (n+1) (b::l) := congr_arg (cons b) (modify_nth_tail_eq_take_drop n l)\n\ntheorem modify_nth_eq_take_drop (f : α → α) :\n  ∀ n l, modify_nth f n l = take n l ++ modify_head f (drop n l) :=\nmodify_nth_tail_eq_take_drop _ rfl\n\ntheorem modify_nth_eq_take_cons_drop (f : α → α) {n l} (h) :\n  modify_nth f n l = take n l ++ f (nth_le l n h) :: drop (n+1) l :=\nby rw [modify_nth_eq_take_drop, drop_eq_nth_le_cons h]; refl\n\ntheorem update_nth_eq_take_cons_drop (a : α) {n l} (h : n < length l) :\n  update_nth l n a = take n l ++ a :: drop (n+1) l :=\nby rw [update_nth_eq_modify_nth, modify_nth_eq_take_cons_drop _ h]\n\nlemma reverse_take {α} {xs : list α} (n : ℕ)\n  (h : n ≤ xs.length) :\n  xs.reverse.take n = (xs.drop (xs.length - n)).reverse :=\nbegin\n  induction xs generalizing n;\n    simp only [reverse_cons, drop, reverse_nil, nat.zero_sub, length, take_nil],\n  cases decidable.lt_or_eq_of_le h with h' h',\n  { replace h' := le_of_succ_le_succ h',\n    rwa [take_append_of_le_length, xs_ih _ h'],\n    rw [show xs_tl.length + 1 - n = succ (xs_tl.length - n), from _, drop],\n    { rwa [succ_eq_add_one, nat.sub_add_comm] },\n    { rwa length_reverse } },\n  { subst h', rw [length, nat.sub_self, drop],\n    suffices : xs_tl.length + 1 = (xs_tl.reverse ++ [xs_hd]).length,\n      by rw [this, take_length, reverse_cons],\n    rw [length_append, length_reverse], refl }\nend\n\n@[simp] lemma update_nth_eq_nil (l : list α) (n : ℕ) (a : α) : l.update_nth n a = [] ↔ l = [] :=\nby cases l; cases n; simp only [update_nth]\n\nsection take'\nvariable [inhabited α]\n\n@[simp] theorem take'_length : ∀ n l, length (@take' α _ n l) = n\n| 0     l := rfl\n| (n+1) l := congr_arg succ (take'_length _ _)\n\n@[simp] theorem take'_nil : ∀ n, take' n (@nil α) = repeat (default _) n\n| 0     := rfl\n| (n+1) := congr_arg (cons _) (take'_nil _)\n\ntheorem take'_eq_take : ∀ {n} {l : list α},\n  n ≤ length l → take' n l = take n l\n| 0     l      h := rfl\n| (n+1) (a::l) h := congr_arg (cons _) $\n  take'_eq_take $ le_of_succ_le_succ h\n\n@[simp] theorem take'_left (l₁ l₂ : list α) : take' (length l₁) (l₁ ++ l₂) = l₁ :=\n(take'_eq_take (by simp only [length_append, nat.le_add_right])).trans (take_left _ _)\n\ntheorem take'_left' {l₁ l₂ : list α} {n} (h : length l₁ = n) :\n  take' n (l₁ ++ l₂) = l₁ :=\nby rw ← h; apply take'_left\n\nend take'\n\n/-! ### foldl, foldr -/\n\nlemma foldl_ext (f g : α → β → α) (a : α)\n  {l : list β} (H : ∀ a : α, ∀ b ∈ l, f a b = g a b) :\n  foldl f a l = foldl g a l :=\nbegin\n  induction l with hd tl ih generalizing a, {refl},\n  unfold foldl,\n  rw [ih (λ a b bin, H a b $ mem_cons_of_mem _ bin), H a hd (mem_cons_self _ _)]\nend\n\nlemma foldr_ext (f g : α → β → β) (b : β)\n  {l : list α} (H : ∀ a ∈ l, ∀ b : β, f a b = g a b) :\n  foldr f b l = foldr g b l :=\nbegin\n  induction l with hd tl ih, {refl},\n  simp only [mem_cons_iff, or_imp_distrib, forall_and_distrib, forall_eq] at H,\n  simp only [foldr, ih H.2, H.1]\nend\n\n@[simp] theorem foldl_nil (f : α → β → α) (a : α) : foldl f a [] = a := rfl\n\n@[simp] theorem foldl_cons (f : α → β → α) (a : α) (b : β) (l : list β) :\n  foldl f a (b::l) = foldl f (f a b) l := rfl\n\n@[simp] theorem foldr_nil (f : α → β → β) (b : β) : foldr f b [] = b := rfl\n\n@[simp] theorem foldr_cons (f : α → β → β) (b : β) (a : α) (l : list α) :\n  foldr f b (a::l) = f a (foldr f b l) := rfl\n\n@[simp] theorem foldl_append (f : α → β → α) :\n  ∀ (a : α) (l₁ l₂ : list β), foldl f a (l₁++l₂) = foldl f (foldl f a l₁) l₂\n| a []      l₂ := rfl\n| a (b::l₁) l₂ := by simp only [cons_append, foldl_cons, foldl_append (f a b) l₁ l₂]\n\n@[simp] theorem foldr_append (f : α → β → β) :\n  ∀ (b : β) (l₁ l₂ : list α), foldr f b (l₁++l₂) = foldr f (foldr f b l₂) l₁\n| b []      l₂ := rfl\n| b (a::l₁) l₂ := by simp only [cons_append, foldr_cons, foldr_append b l₁ l₂]\n\n@[simp] theorem foldl_join (f : α → β → α) :\n  ∀ (a : α) (L : list (list β)), foldl f a (join L) = foldl (foldl f) a L\n| a []     := rfl\n| a (l::L) := by simp only [join, foldl_append, foldl_cons, foldl_join (foldl f a l) L]\n\n@[simp] theorem foldr_join (f : α → β → β) :\n  ∀ (b : β) (L : list (list α)), foldr f b (join L) = foldr (λ l b, foldr f b l) b L\n| a []     := rfl\n| a (l::L) := by simp only [join, foldr_append, foldr_join a L, foldr_cons]\n\ntheorem foldl_reverse (f : α → β → α) (a : α) (l : list β) :\n  foldl f a (reverse l) = foldr (λx y, f y x) a l :=\nby induction l; [refl, simp only [*, reverse_cons, foldl_append, foldl_cons, foldl_nil, foldr]]\n\ntheorem foldr_reverse (f : α → β → β) (a : β) (l : list α) :\n  foldr f a (reverse l) = foldl (λx y, f y x) a l :=\nlet t := foldl_reverse (λx y, f y x) a (reverse l) in\nby rw reverse_reverse l at t; rwa t\n\n@[simp] theorem foldr_eta : ∀ (l : list α), foldr cons [] l = l\n| []     := rfl\n| (x::l) := by simp only [foldr_cons, foldr_eta l]; split; refl\n\n@[simp] theorem reverse_foldl {l : list α} : reverse (foldl (λ t h, h :: t) [] l) = l :=\nby rw ←foldr_reverse; simp\n\n@[simp] theorem foldl_map (g : β → γ) (f : α → γ → α) (a : α) (l : list β) :\n  foldl f a (map g l) = foldl (λx y, f x (g y)) a l :=\nby revert a; induction l; intros; [refl, simp only [*, map, foldl]]\n\n@[simp] theorem foldr_map (g : β → γ) (f : γ → α → α) (a : α) (l : list β) :\n  foldr f a (map g l) = foldr (f ∘ g) a l :=\nby revert a; induction l; intros; [refl, simp only [*, map, foldr]]\n\ntheorem foldl_map' {α β: Type u} (g : α → β) (f : α → α → α) (f' : β → β → β)\n  (a : α) (l : list α) (h : ∀ x y, f' (g x) (g y) = g (f x y)) :\n  list.foldl f' (g a) (l.map g) = g (list.foldl f a l) :=\nbegin\n  induction l generalizing a,\n  { simp }, { simp [l_ih, h] }\nend\n\ntheorem foldr_map' {α β: Type u} (g : α → β) (f : α → α → α) (f' : β → β → β)\n  (a : α) (l : list α) (h : ∀ x y, f' (g x) (g y) = g (f x y)) :\n  list.foldr f' (g a) (l.map g) = g (list.foldr f a l) :=\nbegin\n  induction l generalizing a,\n  { simp }, { simp [l_ih, h] }\nend\n\ntheorem foldl_hom (l : list γ) (f : α → β) (op : α → γ → α) (op' : β → γ → β) (a : α)\n  (h : ∀a x, f (op a x) = op' (f a) x) : foldl op' (f a) l = f (foldl op a l) :=\neq.symm $ by { revert a, induction l; intros; [refl, simp only [*, foldl]] }\n\ntheorem foldr_hom (l : list γ) (f : α → β) (op : γ → α → α) (op' : γ → β → β) (a : α)\n  (h : ∀x a, f (op x a) = op' x (f a)) : foldr op' (f a) l = f (foldr op a l) :=\nby { revert a, induction l; intros; [refl, simp only [*, foldr]] }\n\nlemma injective_foldl_comp {α : Type*} {l : list (α → α)} {f : α → α}\n  (hl : ∀ f ∈ l, function.injective f) (hf : function.injective f):\n  function.injective (@list.foldl (α → α) (α → α) function.comp f l) :=\nbegin\n  induction l generalizing f,\n  { exact hf },\n  { apply l_ih (λ _ h, hl _ (list.mem_cons_of_mem _ h)),\n    apply function.injective.comp hf,\n    apply hl _ (list.mem_cons_self _ _) }\nend\n\n/-- Induction principle for values produced by a `foldr`: if a property holds\nfor the seed element `b : β` and for all incremental `op : α → β → β`\nperformed on the elements `(a : α) ∈ l`. The principle is given for\na `Sort`-valued predicate, i.e., it can also be used to construct data. -/\ndef foldr_rec_on {C : β → Sort*} (l : list α) (op : α → β → β) (b : β) (hb : C b)\n  (hl : ∀ (b : β) (hb : C b) (a : α) (ha : a ∈ l), C (op a b)) :\n  C (foldr op b l) :=\nbegin\n  induction l with hd tl IH,\n  { exact hb },\n  { refine hl _ _ hd (mem_cons_self hd tl),\n    refine IH _,\n    intros y hy x hx,\n    exact hl y hy x (mem_cons_of_mem hd hx) }\nend\n\n/-- Induction principle for values produced by a `foldl`: if a property holds\nfor the seed element `b : β` and for all incremental `op : β → α → β`\nperformed on the elements `(a : α) ∈ l`. The principle is given for\na `Sort`-valued predicate, i.e., it can also be used to construct data. -/\ndef foldl_rec_on {C : β → Sort*} (l : list α) (op : β → α → β) (b : β) (hb : C b)\n  (hl : ∀ (b : β) (hb : C b) (a : α) (ha : a ∈ l), C (op b a)) :\n  C (foldl op b l) :=\nbegin\n  induction l with hd tl IH generalizing b,\n  { exact hb },\n  { refine IH _ _ _,\n    { intros y hy x hx,\n      exact hl y hy x (mem_cons_of_mem hd hx) },\n    { exact hl b hb hd (mem_cons_self hd tl) } }\nend\n\n@[simp] lemma foldr_rec_on_nil {C : β → Sort*} (op : α → β → β) (b) (hb : C b) (hl) :\n  foldr_rec_on [] op b hb hl = hb := rfl\n\n@[simp] lemma foldr_rec_on_cons {C : β → Sort*} (x : α) (l : list α)\n  (op : α → β → β) (b) (hb : C b)\n  (hl : ∀ (b : β) (hb : C b) (a : α) (ha : a ∈ (x :: l)), C (op a b)) :\n  foldr_rec_on (x :: l) op b hb hl = hl _ (foldr_rec_on l op b hb\n    (λ b hb a ha, hl b hb a (mem_cons_of_mem _ ha))) x (mem_cons_self _ _) := rfl\n\n@[simp] lemma foldl_rec_on_nil {C : β → Sort*} (op : β → α → β) (b) (hb : C b) (hl) :\n  foldl_rec_on [] op b hb hl = hb := rfl\n\n/- scanl -/\n\nsection scanl\n\nvariables {f : β → α → β} {b : β} {a : α} {l : list α}\n\nlemma length_scanl :\n  ∀ a l, length (scanl f a l) = l.length + 1\n| a [] := rfl\n| a (x :: l) := by erw [length_cons, length_cons, length_scanl]\n\n@[simp] lemma scanl_nil (b : β) : scanl f b nil = [b] := rfl\n\n@[simp] lemma scanl_cons :\n  scanl f b (a :: l) = [b] ++ scanl f (f b a) l :=\nby simp only [scanl, eq_self_iff_true, singleton_append, and_self]\n\n@[simp] lemma nth_zero_scanl : (scanl f b l).nth 0 = some b :=\nbegin\n  cases l,\n  { simp only [nth, scanl_nil] },\n  { simp only [nth, scanl_cons, singleton_append] }\nend\n\n@[simp] lemma nth_le_zero_scanl {h : 0 < (scanl f b l).length} :\n  (scanl f b l).nth_le 0 h = b :=\nbegin\n  cases l,\n  { simp only [nth_le, scanl_nil] },\n  { simp only [nth_le, scanl_cons, singleton_append] }\nend\n\nlemma nth_succ_scanl {i : ℕ} :\n  (scanl f b l).nth (i + 1) = ((scanl f b l).nth i).bind (λ x, (l.nth i).map (λ y, f x y)) :=\nbegin\n  induction l with hd tl hl generalizing b i,\n  { symmetry,\n    simp only [option.bind_eq_none', nth, forall_2_true_iff, not_false_iff, option.map_none',\n               scanl_nil, option.not_mem_none, forall_true_iff] },\n  { simp only [nth, scanl_cons, singleton_append],\n    cases i,\n    { simp only [option.map_some', nth_zero_scanl, nth, option.some_bind'] },\n    { simp only [hl, nth] } }\nend\n\nlemma nth_le_succ_scanl {i : ℕ} {h : i + 1 < (scanl f b l).length} :\n  (scanl f b l).nth_le (i + 1) h =\n  f ((scanl f b l).nth_le i (nat.lt_of_succ_lt h))\n    (l.nth_le i (nat.lt_of_succ_lt_succ (lt_of_lt_of_le h (le_of_eq (length_scanl b l))))) :=\nbegin\n  induction i with i hi generalizing b l,\n  { cases l,\n    { simp only [length, zero_add, scanl_nil] at h,\n      exact absurd h (lt_irrefl 1) },\n    { simp only [scanl_cons, singleton_append, nth_le_zero_scanl, nth_le] } },\n  { cases l,\n    { simp only [length, add_lt_iff_neg_right, scanl_nil] at h,\n      exact absurd h (not_lt_of_lt nat.succ_pos') },\n    { simp_rw scanl_cons,\n      rw nth_le_append_right _,\n      { simpa only [hi, length, succ_add_sub_one] },\n      { simp only [length, nat.zero_le, le_add_iff_nonneg_left] } } }\nend\n\nend scanl\n\n/- scanr -/\n\n@[simp] theorem scanr_nil (f : α → β → β) (b : β) : scanr f b [] = [b] := rfl\n\n@[simp] theorem scanr_aux_cons (f : α → β → β) (b : β) : ∀ (a : α) (l : list α),\n  scanr_aux f b (a::l) = (foldr f b (a::l), scanr f b l)\n| a []     := rfl\n| a (x::l) := let t := scanr_aux_cons x l in\n  by simp only [scanr, scanr_aux, t, foldr_cons]\n\n@[simp] theorem scanr_cons (f : α → β → β) (b : β) (a : α) (l : list α) :\n  scanr f b (a::l) = foldr f b (a::l) :: scanr f b l :=\nby simp only [scanr, scanr_aux_cons, foldr_cons]; split; refl\n\nsection foldl_eq_foldr\n-- foldl and foldr coincide when f is commutative and associative\nvariables {f : α → α → α} (hcomm : commutative f) (hassoc : associative f)\n\ninclude hassoc\ntheorem foldl1_eq_foldr1 : ∀ a b l, foldl f a (l++[b]) = foldr f b (a::l)\n| a b nil      := rfl\n| a b (c :: l) :=\n  by simp only [cons_append, foldl_cons, foldr_cons, foldl1_eq_foldr1 _ _ l]; rw hassoc\n\ninclude hcomm\ntheorem foldl_eq_of_comm_of_assoc : ∀ a b l, foldl f a (b::l) = f b (foldl f a l)\n| a b  nil    := hcomm a b\n| a b  (c::l) := by simp only [foldl_cons];\n  rw [← foldl_eq_of_comm_of_assoc, right_comm _ hcomm hassoc]; refl\n\ntheorem foldl_eq_foldr : ∀ a l, foldl f a l = foldr f a l\n| a nil      := rfl\n| a (b :: l) :=\n  by simp only [foldr_cons, foldl_eq_of_comm_of_assoc hcomm hassoc]; rw (foldl_eq_foldr a l)\n\nend foldl_eq_foldr\n\nsection foldl_eq_foldlr'\n\nvariables {f : α → β → α}\nvariables hf : ∀ a b c, f (f a b) c = f (f a c) b\ninclude hf\n\ntheorem foldl_eq_of_comm' : ∀ a b l, foldl f a (b::l) = f (foldl f a l) b\n| a b [] := rfl\n| a b (c :: l) := by rw [foldl,foldl,foldl,← foldl_eq_of_comm',foldl,hf]\n\ntheorem foldl_eq_foldr' : ∀ a l, foldl f a l = foldr (flip f) a l\n| a [] := rfl\n| a (b :: l) := by rw [foldl_eq_of_comm' hf,foldr,foldl_eq_foldr']; refl\n\nend foldl_eq_foldlr'\n\nsection foldl_eq_foldlr'\n\nvariables {f : α → β → β}\nvariables hf : ∀ a b c, f a (f b c) = f b (f a c)\ninclude hf\n\ntheorem foldr_eq_of_comm' : ∀ a b l, foldr f a (b::l) = foldr f (f b a) l\n| a b [] := rfl\n| a b (c :: l) := by rw [foldr,foldr,foldr,hf,← foldr_eq_of_comm']; refl\n\nend foldl_eq_foldlr'\n\nsection\nvariables {op : α → α → α} [ha : is_associative α op] [hc : is_commutative α op]\nlocal notation a * b := op a b\nlocal notation l <*> a := foldl op a l\n\ninclude ha\n\nlemma foldl_assoc : ∀ {l : list α} {a₁ a₂}, l <*> (a₁ * a₂) = a₁ * (l <*> a₂)\n| [] a₁ a₂ := rfl\n| (a :: l) a₁ a₂ :=\n  calc a::l <*> (a₁ * a₂) = l <*> (a₁ * (a₂ * a)) : by simp only [foldl_cons, ha.assoc]\n    ... = a₁ * (a::l <*> a₂) : by rw [foldl_assoc, foldl_cons]\n\nlemma foldl_op_eq_op_foldr_assoc : ∀{l : list α} {a₁ a₂}, (l <*> a₁) * a₂ = a₁ * l.foldr (*) a₂\n| [] a₁ a₂ := rfl\n| (a :: l) a₁ a₂ := by simp only [foldl_cons, foldr_cons, foldl_assoc, ha.assoc];\n  rw [foldl_op_eq_op_foldr_assoc]\n\ninclude hc\n\nlemma foldl_assoc_comm_cons {l : list α} {a₁ a₂} : (a₁ :: l) <*> a₂ = a₁ * (l <*> a₂) :=\nby rw [foldl_cons, hc.comm, foldl_assoc]\n\nend\n\n/-! ### mfoldl, mfoldr, mmap -/\n\nsection mfoldl_mfoldr\nvariables {m : Type v → Type w} [monad m]\n\n@[simp] theorem mfoldl_nil (f : β → α → m β) {b} : mfoldl f b [] = pure b := rfl\n\n@[simp] theorem mfoldr_nil (f : α → β → m β) {b} : mfoldr f b [] = pure b := rfl\n\n@[simp] theorem mfoldl_cons {f : β → α → m β} {b a l} :\n  mfoldl f b (a :: l) = f b a >>= λ b', mfoldl f b' l := rfl\n\n@[simp] theorem mfoldr_cons {f : α → β → m β} {b a l} :\n  mfoldr f b (a :: l) = mfoldr f b l >>= f a := rfl\n\ntheorem mfoldr_eq_foldr (f : α → β → m β) (b l) :\n  mfoldr f b l = foldr (λ a mb, mb >>= f a) (pure b) l :=\nby induction l; simp *\n\nattribute [simp] mmap mmap'\n\nvariables [is_lawful_monad m]\n\ntheorem mfoldl_eq_foldl (f : β → α → m β) (b l) :\n  mfoldl f b l = foldl (λ mb a, mb >>= λ b, f b a) (pure b) l :=\nbegin\n  suffices h : ∀ (mb : m β),\n    (mb >>= λ b, mfoldl f b l) = foldl (λ mb a, mb >>= λ b, f b a) mb l,\n  by simp [←h (pure b)],\n  induction l; intro,\n  { simp },\n  { simp only [mfoldl, foldl, ←l_ih] with monad_norm }\nend\n\n@[simp] theorem mfoldl_append {f : β → α → m β} : ∀ {b l₁ l₂},\n  mfoldl f b (l₁ ++ l₂) = mfoldl f b l₁ >>= λ x, mfoldl f x l₂\n| _ []     _ := by simp only [nil_append, mfoldl_nil, pure_bind]\n| _ (_::_) _ := by simp only [cons_append, mfoldl_cons, mfoldl_append, bind_assoc]\n\n@[simp] theorem mfoldr_append {f : α → β → m β} : ∀ {b l₁ l₂},\n  mfoldr f b (l₁ ++ l₂) = mfoldr f b l₂ >>= λ x, mfoldr f x l₁\n| _ []     _ := by simp only [nil_append, mfoldr_nil, bind_pure]\n| _ (_::_) _ := by simp only [mfoldr_cons, cons_append, mfoldr_append, bind_assoc]\n\nend mfoldl_mfoldr\n\n/-! ### prod and sum -/\n\n-- list.sum was already defined in defs.lean, but we couldn't tag it with `to_additive` yet.\nattribute [to_additive] list.prod\n\nsection monoid\nvariables [monoid α] {l l₁ l₂ : list α} {a : α}\n\n@[simp, to_additive]\ntheorem prod_nil : ([] : list α).prod = 1 := rfl\n\n@[to_additive]\ntheorem prod_singleton : [a].prod = a := one_mul a\n\n@[simp, to_additive]\ntheorem prod_cons : (a::l).prod = a * l.prod :=\ncalc (a::l).prod = foldl (*) (a * 1) l : by simp only [list.prod, foldl_cons, one_mul, mul_one]\n  ... = _ : foldl_assoc\n\n@[simp, to_additive]\ntheorem prod_append : (l₁ ++ l₂).prod = l₁.prod * l₂.prod :=\ncalc (l₁ ++ l₂).prod = foldl (*) (foldl (*) 1 l₁ * 1) l₂ : by simp [list.prod]\n  ... = l₁.prod * l₂.prod : foldl_assoc\n\n@[simp, to_additive]\ntheorem prod_join {l : list (list α)} : l.join.prod = (l.map list.prod).prod :=\nby induction l; [refl, simp only [*, list.join, map, prod_append, prod_cons]]\n\n/-- If zero is an element of a list `L`, then `list.prod L = 0`. If the domain is a nontrivial\nmonoid with zero with no divisors, then this implication becomes an `iff`, see\n`list.prod_eq_zero_iff`. -/\ntheorem prod_eq_zero {M₀ : Type*} [monoid_with_zero M₀] {L : list M₀} (h : (0 : M₀) ∈ L) :\n  L.prod = 0 :=\nbegin\n  induction L with a L ihL,\n  { exact absurd h (not_mem_nil _) },\n  { rw prod_cons,\n    cases (mem_cons_iff _ _ _).1 h with ha hL,\n    exacts [mul_eq_zero_of_left ha.symm _, mul_eq_zero_of_right _ (ihL hL)] }\nend\n\n/-- Product of elements of a list `L` equals zero if and only if `0 ∈ L`. See also\n`list.prod_eq_zero` for an implication that needs weaker typeclass assumptions. -/\n@[simp] theorem prod_eq_zero_iff {M₀ : Type*} [monoid_with_zero M₀] [nontrivial M₀]\n  [no_zero_divisors M₀] {L : list M₀} :\n  L.prod = 0 ↔ (0 : M₀) ∈ L :=\nbegin\n  induction L with a L ihL,\n  { simp },\n  { rw [prod_cons, mul_eq_zero, ihL, mem_cons_iff, eq_comm] }\nend\n\ntheorem prod_ne_zero {M₀ : Type*} [monoid_with_zero M₀] [nontrivial M₀] [no_zero_divisors M₀]\n  {L : list M₀} (hL : (0 : M₀) ∉ L) : L.prod ≠ 0 :=\nmt prod_eq_zero_iff.1 hL\n\n@[to_additive]\ntheorem prod_eq_foldr : l.prod = foldr (*) 1 l :=\nlist.rec_on l rfl $ λ a l ihl, by rw [prod_cons, foldr_cons, ihl]\n\n@[to_additive]\ntheorem prod_hom_rel {α β γ : Type*} [monoid β] [monoid γ] (l : list α) {r : β → γ → Prop}\n  {f : α → β} {g : α → γ} (h₁ : r 1 1) (h₂ : ∀⦃a b c⦄, r b c → r (f a * b) (g a * c)) :\n  r (l.map f).prod (l.map g).prod :=\nlist.rec_on l h₁ (λ a l hl, by simp only [map_cons, prod_cons, h₂ hl])\n\n@[to_additive]\ntheorem prod_hom [monoid β] (l : list α) (f : α →* β) :\n  (l.map f).prod = f l.prod :=\nby { simp only [prod, foldl_map, f.map_one.symm],\n  exact l.foldl_hom _ _ _ 1 f.map_mul }\n\n@[to_additive]\nlemma prod_is_unit [monoid β] : Π {L : list β} (u : ∀ m ∈ L, is_unit m), is_unit L.prod\n| [] _ := by simp\n| (h :: t) u :=\nbegin\n  simp only [list.prod_cons],\n  exact is_unit.mul (u h (mem_cons_self h t)) (prod_is_unit (λ m mt, u m (mem_cons_of_mem h mt)))\nend\n\n-- `to_additive` chokes on the next few lemmas, so we do them by hand below\n@[simp]\nlemma prod_take_mul_prod_drop :\n  ∀ (L : list α) (i : ℕ), (L.take i).prod * (L.drop i).prod = L.prod\n| [] i := by simp\n| L 0 := by simp\n| (h :: t) (n+1) := by { dsimp, rw [prod_cons, prod_cons, mul_assoc, prod_take_mul_prod_drop], }\n\n@[simp]\nlemma prod_take_succ :\n  ∀ (L : list α) (i : ℕ) (p), (L.take (i + 1)).prod = (L.take i).prod * L.nth_le i p\n| [] i p := by cases p\n| (h :: t) 0 _ := by simp\n| (h :: t) (n+1) _ := by { dsimp, rw [prod_cons, prod_cons, prod_take_succ, mul_assoc], }\n\n/-- A list with product not one must have positive length. -/\nlemma length_pos_of_prod_ne_one (L : list α) (h : L.prod ≠ 1) : 0 < L.length :=\nby { cases L, { simp at h, cases h, }, { simp, }, }\n\nlemma prod_update_nth : ∀ (L : list α) (n : ℕ) (a : α),\n  (L.update_nth n a).prod =\n    (L.take n).prod * (if n < L.length then a else 1) * (L.drop (n + 1)).prod\n| (x::xs) 0     a := by simp [update_nth]\n| (x::xs) (i+1) a := by simp [update_nth, prod_update_nth xs i a, mul_assoc]\n| []      _     _ := by simp [update_nth, (nat.zero_le _).not_lt]\n\nend monoid\n\nsection group\nvariables [group α]\n\n/-- This is the `list.prod` version of `mul_inv_rev` -/\n@[to_additive \"This is the `list.sum` version of `add_neg_rev`\"]\nlemma prod_inv_reverse : ∀ (L : list α), L.prod⁻¹ = (L.map (λ x, x⁻¹)).reverse.prod\n| [] := by simp\n| (x :: xs) := by simp [prod_inv_reverse xs]\n\n/-- A non-commutative variant of `list.prod_reverse` -/\n@[to_additive \"A non-commutative variant of `list.sum_reverse`\"]\nlemma prod_reverse_noncomm : ∀ (L : list α), L.reverse.prod = (L.map (λ x, x⁻¹)).prod⁻¹ :=\nby simp [prod_inv_reverse]\n\nend group\n\nsection comm_group\nvariables [comm_group α]\n\n/-- This is the `list.prod` version of `mul_inv` -/\n@[to_additive \"This is the `list.sum` version of `add_neg`\"]\nlemma prod_inv : ∀ (L : list α), L.prod⁻¹ = (L.map (λ x, x⁻¹)).prod\n| [] := by simp\n| (x :: xs) := by simp [mul_comm, prod_inv xs]\n\nend comm_group\n\n@[simp]\nlemma sum_take_add_sum_drop [add_monoid α] :\n  ∀ (L : list α) (i : ℕ), (L.take i).sum + (L.drop i).sum = L.sum\n| [] i := by simp\n| L 0 := by simp\n| (h :: t) (n+1) := by { dsimp, rw [sum_cons, sum_cons, add_assoc, sum_take_add_sum_drop], }\n\n@[simp]\nlemma sum_take_succ [add_monoid α] :\n  ∀ (L : list α) (i : ℕ) (p), (L.take (i + 1)).sum = (L.take i).sum + L.nth_le i p\n| [] i p := by cases p\n| (h :: t) 0 _ := by simp\n| (h :: t) (n+1) _ := by { dsimp, rw [sum_cons, sum_cons, sum_take_succ, add_assoc], }\n\nlemma eq_of_sum_take_eq [add_left_cancel_monoid α] {L L' : list α} (h : L.length = L'.length)\n  (h' : ∀ i ≤ L.length, (L.take i).sum = (L'.take i).sum) : L = L' :=\nbegin\n  apply ext_le h (λ i h₁ h₂, _),\n  have : (L.take (i + 1)).sum = (L'.take (i + 1)).sum := h' _ (nat.succ_le_of_lt h₁),\n  rw [sum_take_succ L i h₁, sum_take_succ L' i h₂, h' i (le_of_lt h₁)] at this,\n  exact add_left_cancel this\nend\n\nlemma monotone_sum_take [canonically_ordered_add_monoid α] (L : list α) :\n  monotone (λ i, (L.take i).sum) :=\nbegin\n  apply monotone_of_monotone_nat (λ n, _),\n  by_cases h : n < L.length,\n  { rw sum_take_succ _ _ h,\n    exact le_add_right (le_refl _) },\n  { push_neg at h,\n    simp [take_all_of_le h, take_all_of_le (le_trans h (nat.le_succ _))] }\nend\n\n@[to_additive sum_nonneg]\nlemma one_le_prod_of_one_le [ordered_comm_monoid α] {l : list α} (hl₁ : ∀ x ∈ l, (1 : α) ≤ x) :\n  1 ≤ l.prod :=\nbegin\n  induction l with hd tl ih,\n  { simp },\n  rw prod_cons,\n  exact one_le_mul (hl₁ hd (mem_cons_self hd tl)) (ih (λ x h, hl₁ x (mem_cons_of_mem hd h))),\nend\n\n@[to_additive]\nlemma single_le_prod [ordered_comm_monoid α] {l : list α} (hl₁ : ∀ x ∈ l, (1 : α) ≤ x) :\n  ∀ x ∈ l, x ≤ l.prod :=\nbegin\n  induction l,\n  { simp },\n  simp_rw [prod_cons, forall_mem_cons] at ⊢ hl₁,\n  split,\n  { exact le_mul_of_one_le_right' (one_le_prod_of_one_le hl₁.2) },\n  { exact λ x H, le_mul_of_one_le_of_le hl₁.1 (l_ih hl₁.right x H) },\nend\n\n@[to_additive all_zero_of_le_zero_le_of_sum_eq_zero]\nlemma all_one_of_le_one_le_of_prod_eq_one [ordered_comm_monoid α]\n  {l : list α} (hl₁ : ∀ x ∈ l, (1 : α) ≤ x) (hl₂ : l.prod = 1) :\n  ∀ x ∈ l, x = (1 : α) :=\nλ x hx, le_antisymm (hl₂ ▸ single_le_prod hl₁ _ hx) (hl₁ x hx)\n\nlemma sum_eq_zero_iff [canonically_ordered_add_monoid α] (l : list α) :\n  l.sum = 0 ↔ ∀ x ∈ l, x = (0 : α) :=\n⟨all_zero_of_le_zero_le_of_sum_eq_zero (λ _ _, zero_le _),\nbegin\n  induction l,\n  { simp },\n  { intro h,\n    rw [sum_cons, add_eq_zero_iff],\n    rw forall_mem_cons at h,\n    exact ⟨h.1, l_ih h.2⟩ },\nend⟩\n\n/-- A list with sum not zero must have positive length. -/\nlemma length_pos_of_sum_ne_zero [add_monoid α] (L : list α) (h : L.sum ≠ 0) : 0 < L.length :=\nby { cases L, { simp at h, cases h, }, { simp, }, }\n\n/-- If all elements in a list are bounded below by `1`, then the length of the list is bounded\nby the sum of the elements. -/\nlemma length_le_sum_of_one_le (L : list ℕ) (h : ∀ i ∈ L, 1 ≤ i) : L.length ≤ L.sum :=\nbegin\n  induction L with j L IH h, { simp },\n  rw [sum_cons, length, add_comm],\n  exact add_le_add (h _ (set.mem_insert _ _)) (IH (λ i hi, h i (set.mem_union_right _ hi)))\nend\n\n-- Now we tie those lemmas back to their multiplicative versions.\nattribute [to_additive] prod_take_mul_prod_drop prod_take_succ length_pos_of_prod_ne_one\n\n/-- A list with positive sum must have positive length. -/\n-- This is an easy consequence of `length_pos_of_sum_ne_zero`, but often useful in applications.\nlemma length_pos_of_sum_pos [ordered_cancel_add_comm_monoid α] (L : list α) (h : 0 < L.sum) :\n  0 < L.length :=\nlength_pos_of_sum_ne_zero L (ne_of_gt h)\n\n@[simp, to_additive]\ntheorem prod_erase [decidable_eq α] [comm_monoid α] {a} :\n  Π {l : list α}, a ∈ l → a * (l.erase a).prod = l.prod\n| (b::l) h :=\n  begin\n    rcases eq_or_ne_mem_of_mem h with rfl | ⟨ne, h⟩,\n    { simp only [list.erase, if_pos, prod_cons] },\n    { simp only [list.erase, if_neg (mt eq.symm ne), prod_cons, prod_erase h, mul_left_comm a b] }\n  end\n\nlemma dvd_prod [comm_monoid α] {a} {l : list α} (ha : a ∈ l) : a ∣ l.prod :=\nlet ⟨s, t, h⟩ := mem_split ha in\nby rw [h, prod_append, prod_cons, mul_left_comm]; exact dvd_mul_right _ _\n\n@[simp] theorem sum_const_nat (m n : ℕ) : sum (list.repeat m n) = m * n :=\nby induction n; [refl, simp only [*, repeat_succ, sum_cons, nat.mul_succ, add_comm]]\n\ntheorem dvd_sum [comm_semiring α] {a} {l : list α} (h : ∀ x ∈ l, a ∣ x) : a ∣ l.sum :=\nbegin\n  induction l with x l ih,\n  { exact dvd_zero _ },\n  { rw [list.sum_cons],\n    exact dvd_add (h _ (mem_cons_self _ _)) (ih (λ x hx, h x (mem_cons_of_mem _ hx))) }\nend\n\n@[simp] theorem length_join (L : list (list α)) : length (join L) = sum (map length L) :=\nby induction L; [refl, simp only [*, join, map, sum_cons, length_append]]\n\n@[simp] theorem length_bind (l : list α) (f : α → list β) :\n  length (list.bind l f) = sum (map (length ∘ f) l) :=\nby rw [list.bind, length_join, map_map]\n\nlemma exists_lt_of_sum_lt [linear_ordered_cancel_add_comm_monoid β] {l : list α}\n  (f g : α → β) (h : (l.map f).sum < (l.map g).sum) : ∃ x ∈ l, f x < g x :=\nbegin\n  induction l with x l,\n  { exfalso, exact lt_irrefl _ h },\n  { by_cases h' : f x < g x, exact ⟨x, mem_cons_self _ _, h'⟩,\n    rcases l_ih _ with ⟨y, h1y, h2y⟩, refine ⟨y, mem_cons_of_mem x h1y, h2y⟩, simp at h,\n    exact lt_of_add_lt_add_left (lt_of_lt_of_le h $ add_le_add_right (le_of_not_gt h') _) }\nend\n\nlemma exists_le_of_sum_le [linear_ordered_cancel_add_comm_monoid β] {l : list α}\n  (hl : l ≠ []) (f g : α → β) (h : (l.map f).sum ≤ (l.map g).sum) : ∃ x ∈ l, f x ≤ g x :=\nbegin\n  cases l with x l,\n  { contradiction },\n  { by_cases h' : f x ≤ g x, exact ⟨x, mem_cons_self _ _, h'⟩,\n    rcases exists_lt_of_sum_lt f g _ with ⟨y, h1y, h2y⟩,\n    exact ⟨y, mem_cons_of_mem x h1y, le_of_lt h2y⟩, simp at h,\n    exact lt_of_add_lt_add_left (lt_of_le_of_lt h $ add_lt_add_right (lt_of_not_ge h') _) }\nend\n\n-- Several lemmas about sum/head/tail for `list ℕ`.\n-- These are hard to generalize well, as they rely on the fact that `default ℕ = 0`.\n\n-- We'd like to state this as `L.head * L.tail.prod = L.prod`,\n-- but because `L.head` relies on an inhabited instances and\n-- returns a garbage value for the empty list, this is not possible.\n-- Instead we write the statement in terms of `(L.nth 0).get_or_else 1`,\n-- and below, restate the lemma just for `ℕ`.\n@[to_additive]\nlemma head_mul_tail_prod' [monoid α] (L : list α) :\n  (L.nth 0).get_or_else 1 * L.tail.prod = L.prod :=\nby { cases L, { simp, refl, }, { simp, }, }\n\nlemma head_add_tail_sum (L : list ℕ) : L.head + L.tail.sum = L.sum :=\nby { cases L, { simp, refl, }, { simp, }, }\n\nlemma head_le_sum (L : list ℕ) : L.head ≤ L.sum :=\nnat.le.intro (head_add_tail_sum L)\n\nlemma tail_sum (L : list ℕ) : L.tail.sum = L.sum - L.head :=\nby rw [← head_add_tail_sum L, add_comm, nat.add_sub_cancel]\n\nsection\nvariables {G : Type*} [comm_group G]\n\nattribute [to_additive] alternating_prod\n\n@[simp, to_additive] lemma alternating_prod_nil :\n  alternating_prod ([] : list G) = 1 := rfl\n\n@[simp, to_additive] lemma alternating_prod_singleton (g : G) :\n  alternating_prod [g] = g := rfl\n\n@[simp, to_additive alternating_sum_cons_cons']\nlemma alternating_prod_cons_cons (g h : G) (l : list G) :\n  alternating_prod (g :: h :: l) = g * h⁻¹ * alternating_prod l := rfl\n\nlemma alternating_sum_cons_cons {G : Type*} [add_comm_group G] (g h : G) (l : list G) :\n  alternating_sum (g :: h :: l) = g - h + alternating_sum l :=\nby rw [sub_eq_add_neg, alternating_sum]\n\nend\n\n/-! ### join -/\n\nattribute [simp] join\n\n@[simp] theorem join_eq_nil : ∀ {L : list (list α)}, join L = [] ↔ ∀ l ∈ L, l = []\n| []     := iff_of_true rfl (forall_mem_nil _)\n| (l::L) := by simp only [join, append_eq_nil, join_eq_nil, forall_mem_cons]\n\n@[simp] theorem join_append (L₁ L₂ : list (list α)) : join (L₁ ++ L₂) = join L₁ ++ join L₂ :=\nby induction L₁; [refl, simp only [*, join, cons_append, append_assoc]]\n\n@[simp] theorem join_filter_empty_eq_ff [decidable_pred (λ l : list α, l.empty = ff)] :\n  ∀ {L : list (list α)}, join (L.filter (λ l, l.empty = ff)) = L.join\n| [] := rfl\n| ([]::L) := by simp [@join_filter_empty_eq_ff L]\n| ((a::l)::L) := by simp [@join_filter_empty_eq_ff L]\n\n@[simp] theorem join_filter_ne_nil [decidable_pred (λ l : list α, l ≠ [])] {L : list (list α)} :\n  join (L.filter (λ l, l ≠ [])) = L.join :=\nby simp [join_filter_empty_eq_ff, ← empty_iff_eq_nil]\n\nlemma join_join (l : list (list (list α))) : l.join.join = (l.map join).join :=\nby { induction l, simp, simp [l_ih] }\n\n/-- In a join, taking the first elements up to an index which is the sum of the lengths of the\nfirst `i` sublists, is the same as taking the join of the first `i` sublists. -/\nlemma take_sum_join (L : list (list α)) (i : ℕ) :\n  L.join.take ((L.map length).take i).sum = (L.take i).join :=\nbegin\n  induction L generalizing i, { simp },\n  cases i, { simp },\n  simp [take_append, L_ih]\nend\n\n/-- In a join, dropping all the elements up to an index which is the sum of the lengths of the\nfirst `i` sublists, is the same as taking the join after dropping the first `i` sublists. -/\nlemma drop_sum_join (L : list (list α)) (i : ℕ) :\n  L.join.drop ((L.map length).take i).sum = (L.drop i).join :=\nbegin\n  induction L generalizing i, { simp },\n  cases i, { simp },\n  simp [drop_append, L_ih],\nend\n\n/-- Taking only the first `i+1` elements in a list, and then dropping the first `i` ones, one is\nleft with a list of length `1` made of the `i`-th element of the original list. -/\nlemma drop_take_succ_eq_cons_nth_le (L : list α) {i : ℕ} (hi : i < L.length) :\n  (L.take (i+1)).drop i = [nth_le L i hi] :=\nbegin\n  induction L generalizing i,\n  { simp only [length] at hi, exact (nat.not_succ_le_zero i hi).elim },\n  cases i, { simp },\n  have : i < L_tl.length,\n  { simp at hi,\n    exact nat.lt_of_succ_lt_succ hi },\n  simp [L_ih this],\n  refl\nend\n\n/-- In a join of sublists, taking the slice between the indices `A` and `B - 1` gives back the\noriginal sublist of index `i` if `A` is the sum of the lenghts of sublists of index `< i`, and\n`B` is the sum of the lengths of sublists of index `≤ i`. -/\nlemma drop_take_succ_join_eq_nth_le (L : list (list α)) {i : ℕ} (hi : i < L.length) :\n  (L.join.take ((L.map length).take (i+1)).sum).drop ((L.map length).take i).sum = nth_le L i hi :=\nbegin\n  have : (L.map length).take i = ((L.take (i+1)).map length).take i, by simp [map_take, take_take],\n  simp [take_sum_join, this, drop_sum_join, drop_take_succ_eq_cons_nth_le _ hi]\nend\n\n/-- Auxiliary lemma to control elements in a join. -/\nlemma sum_take_map_length_lt1 (L : list (list α)) {i j : ℕ}\n  (hi : i < L.length) (hj : j < (nth_le L i hi).length) :\n  ((L.map length).take i).sum + j < ((L.map length).take (i+1)).sum :=\nby simp [hi, sum_take_succ, hj]\n\n/-- Auxiliary lemma to control elements in a join. -/\nlemma sum_take_map_length_lt2 (L : list (list α)) {i j : ℕ}\n  (hi : i < L.length) (hj : j < (nth_le L i hi).length) :\n  ((L.map length).take i).sum + j < L.join.length :=\nbegin\n  convert lt_of_lt_of_le (sum_take_map_length_lt1 L hi hj) (monotone_sum_take _ hi),\n  have : L.length = (L.map length).length, by simp,\n  simp [this, -length_map]\nend\n\n/-- The `n`-th element in a join of sublists is the `j`-th element of the `i`th sublist,\nwhere `n` can be obtained in terms of `i` and `j` by adding the lengths of all the sublists\nof index `< i`, and adding `j`. -/\nlemma nth_le_join (L : list (list α)) {i j : ℕ}\n  (hi : i < L.length) (hj : j < (nth_le L i hi).length) :\n  nth_le L.join (((L.map length).take i).sum + j) (sum_take_map_length_lt2 L hi hj) =\n  nth_le (nth_le L i hi) j hj :=\nby rw [nth_le_take L.join (sum_take_map_length_lt2 L hi hj) (sum_take_map_length_lt1 L hi hj),\n  nth_le_drop, nth_le_of_eq (drop_take_succ_join_eq_nth_le L hi)]\n\n/-- Two lists of sublists are equal iff their joins coincide, as well as the lengths of the\nsublists. -/\ntheorem eq_iff_join_eq (L L' : list (list α)) :\n  L = L' ↔ L.join = L'.join ∧ map length L = map length L' :=\nbegin\n  refine ⟨λ H, by simp [H], _⟩,\n  rintros ⟨join_eq, length_eq⟩,\n  apply ext_le,\n  { have : length (map length L) = length (map length L'), by rw length_eq,\n    simpa using this },\n  { assume n h₁ h₂,\n    rw [← drop_take_succ_join_eq_nth_le, ← drop_take_succ_join_eq_nth_le, join_eq, length_eq] }\nend\n\n/-! ### lexicographic ordering -/\n\n/-- Given a strict order `<` on `α`, the lexicographic strict order on `list α`, for which\n`[a0, ..., an] < [b0, ..., b_k]` if `a0 < b0` or `a0 = b0` and `[a1, ..., an] < [b1, ..., bk]`.\nThe definition is given for any relation `r`, not only strict orders. -/\ninductive lex (r : α → α → Prop) : list α → list α → Prop\n| nil {a l} : lex [] (a :: l)\n| cons {a l₁ l₂} (h : lex l₁ l₂) : lex (a :: l₁) (a :: l₂)\n| rel {a₁ l₁ a₂ l₂} (h : r a₁ a₂) : lex (a₁ :: l₁) (a₂ :: l₂)\n\nnamespace lex\ntheorem cons_iff {r : α → α → Prop} [is_irrefl α r] {a l₁ l₂} :\n  lex r (a :: l₁) (a :: l₂) ↔ lex r l₁ l₂ :=\n⟨λ h, by cases h with _ _ _ _ _ h _ _ _ _ h;\n  [exact h, exact (irrefl_of r a h).elim], lex.cons⟩\n\n@[simp] theorem not_nil_right (r : α → α → Prop) (l : list α) : ¬ lex r l [].\n\ninstance is_order_connected (r : α → α → Prop)\n  [is_order_connected α r] [is_trichotomous α r] :\n  is_order_connected (list α) (lex r) :=\n⟨λ l₁, match l₁ with\n| _,     [],    c::l₃, nil    := or.inr nil\n| _,     [],    c::l₃, rel _ := or.inr nil\n| _,     [],    c::l₃, cons _ := or.inr nil\n| _,     b::l₂, c::l₃, nil := or.inl nil\n| a::l₁, b::l₂, c::l₃, rel h :=\n  (is_order_connected.conn _ b _ h).imp rel rel\n| a::l₁, b::l₂, _::l₃, cons h := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match _ l₂ _ h).imp cons cons },\n    { exact or.inr (rel ab) }\n  end\nend⟩\n\ninstance is_trichotomous (r : α → α → Prop) [is_trichotomous α r] :\n  is_trichotomous (list α) (lex r) :=\n⟨λ l₁, match l₁ with\n| [], [] := or.inr (or.inl rfl)\n| [], b::l₂ := or.inl nil\n| a::l₁, [] := or.inr (or.inr nil)\n| a::l₁, b::l₂ := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match l₁ l₂).imp cons\n      (or.imp (congr_arg _) cons) },\n    { exact or.inr (or.inr (rel ab)) }\n  end\nend⟩\n\ninstance is_asymm (r : α → α → Prop)\n  [is_asymm α r] : is_asymm (list α) (lex r) :=\n⟨λ l₁, match l₁ with\n| a::l₁, b::l₂, lex.rel h₁, lex.rel h₂ := asymm h₁ h₂\n| a::l₁, b::l₂, lex.rel h₁, lex.cons h₂ := asymm h₁ h₁\n| a::l₁, b::l₂, lex.cons h₁, lex.rel h₂ := asymm h₂ h₂\n| a::l₁, b::l₂, lex.cons h₁, lex.cons h₂ :=\n  by exact _match _ _ h₁ h₂\nend⟩\n\ninstance is_strict_total_order (r : α → α → Prop)\n  [is_strict_total_order' α r] : is_strict_total_order' (list α) (lex r) :=\n{..is_strict_weak_order_of_is_order_connected}\n\ninstance decidable_rel [decidable_eq α] (r : α → α → Prop)\n  [decidable_rel r] : decidable_rel (lex r)\n| l₁ [] := is_false $ λ h, by cases h\n| [] (b::l₂) := is_true lex.nil\n| (a::l₁) (b::l₂) := begin\n  haveI := decidable_rel l₁ l₂,\n  refine decidable_of_iff (r a b ∨ a = b ∧ lex r l₁ l₂) ⟨λ h, _, λ h, _⟩,\n  { rcases h with h | ⟨rfl, h⟩,\n    { exact lex.rel h },\n    { exact lex.cons h } },\n  { rcases h with _|⟨_,_,_,h⟩|⟨_,_,_,_,h⟩,\n    { exact or.inr ⟨rfl, h⟩ },\n    { exact or.inl h } }\nend\n\ntheorem append_right (r : α → α → Prop) :\n  ∀ {s₁ s₂} t, lex r s₁ s₂ → lex r s₁ (s₂ ++ t)\n| _ _ t nil      := nil\n| _ _ t (cons h) := cons (append_right _ h)\n| _ _ t (rel r)  := rel r\n\ntheorem append_left (R : α → α → Prop) {t₁ t₂} (h : lex R t₁ t₂) :\n  ∀ s, lex R (s ++ t₁) (s ++ t₂)\n| []      := h\n| (a::l) := cons (append_left l)\n\ntheorem imp {r s : α → α → Prop} (H : ∀ a b, r a b → s a b) :\n  ∀ l₁ l₂, lex r l₁ l₂ → lex s l₁ l₂\n| _ _ nil      := nil\n| _ _ (cons h) := cons (imp _ _ h)\n| _ _ (rel r)  := rel (H _ _ r)\n\ntheorem to_ne : ∀ {l₁ l₂ : list α}, lex (≠) l₁ l₂ → l₁ ≠ l₂\n| _ _ (cons h) e := to_ne h (list.cons.inj e).2\n| _ _ (rel r)  e := r (list.cons.inj e).1\n\ntheorem ne_iff {l₁ l₂ : list α} (H : length l₁ ≤ length l₂) :\n  lex (≠) l₁ l₂ ↔ l₁ ≠ l₂ :=\n⟨to_ne, λ h, begin\n  induction l₁ with a l₁ IH generalizing l₂; cases l₂ with b l₂,\n  { contradiction },\n  { apply nil },\n  { exact (not_lt_of_ge H).elim (succ_pos _) },\n  { cases classical.em (a = b) with ab ab,\n    { subst b, apply cons,\n      exact IH (le_of_succ_le_succ H) (mt (congr_arg _) h) },\n    { exact rel ab } }\nend⟩\n\nend lex\n\n--Note: this overrides an instance in core lean\ninstance has_lt' [has_lt α] : has_lt (list α) := ⟨lex (<)⟩\n\ntheorem nil_lt_cons [has_lt α] (a : α) (l : list α) : [] < a :: l :=\nlex.nil\n\ninstance [linear_order α] : linear_order (list α) :=\nlinear_order_of_STO' (lex (<))\n\n--Note: this overrides an instance in core lean\ninstance has_le' [linear_order α] : has_le (list α) :=\npreorder.to_has_le _\n\n/-! ### all & any -/\n\n@[simp] theorem all_nil (p : α → bool) : all [] p = tt := rfl\n\n@[simp] theorem all_cons (p : α → bool) (a : α) (l : list α) :\n  all (a::l) p = (p a && all l p) := rfl\n\ntheorem all_iff_forall {p : α → bool} {l : list α} : all l p ↔ ∀ a ∈ l, p a :=\nbegin\n  induction l with a l ih,\n  { exact iff_of_true rfl (forall_mem_nil _) },\n  simp only [all_cons, band_coe_iff, ih, forall_mem_cons]\nend\n\ntheorem all_iff_forall_prop {p : α → Prop} [decidable_pred p]\n  {l : list α} : all l (λ a, p a) ↔ ∀ a ∈ l, p a :=\nby simp only [all_iff_forall, bool.of_to_bool_iff]\n\n@[simp] theorem any_nil (p : α → bool) : any [] p = ff := rfl\n\n@[simp] theorem any_cons (p : α → bool) (a : α) (l : list α) :\n  any (a::l) p = (p a || any l p) := rfl\n\ntheorem any_iff_exists {p : α → bool} {l : list α} : any l p ↔ ∃ a ∈ l, p a :=\nbegin\n  induction l with a l ih,\n  { exact iff_of_false bool.not_ff (not_exists_mem_nil _) },\n  simp only [any_cons, bor_coe_iff, ih, exists_mem_cons_iff]\nend\n\ntheorem any_iff_exists_prop {p : α → Prop} [decidable_pred p]\n  {l : list α} : any l (λ a, p a) ↔ ∃ a ∈ l, p a :=\nby simp [any_iff_exists]\n\ntheorem any_of_mem {p : α → bool} {a : α} {l : list α} (h₁ : a ∈ l) (h₂ : p a) : any l p :=\nany_iff_exists.2 ⟨_, h₁, h₂⟩\n\n@[priority 500] instance decidable_forall_mem {p : α → Prop} [decidable_pred p] (l : list α) :\n  decidable (∀ x ∈ l, p x) :=\ndecidable_of_iff _ all_iff_forall_prop\n\ninstance decidable_exists_mem {p : α → Prop} [decidable_pred p] (l : list α) :\n  decidable (∃ x ∈ l, p x) :=\ndecidable_of_iff _ any_iff_exists_prop\n\n/-! ### map for partial functions -/\n\n/-- Partial map. If `f : Π a, p a → β` is a partial function defined on\n  `a : α` satisfying `p`, then `pmap f l h` is essentially the same as `map f l`\n  but is defined only when all members of `l` satisfy `p`, using the proof\n  to apply `f`. -/\n@[simp] def pmap {p : α → Prop} (f : Π a, p a → β) : Π l : list α, (∀ a ∈ l, p a) → list β\n| []     H := []\n| (a::l) H := f a (forall_mem_cons.1 H).1 :: pmap l (forall_mem_cons.1 H).2\n\n/-- \"Attach\" the proof that the elements of `l` are in `l` to produce a new list\n  with the same elements but in the type `{x // x ∈ l}`. -/\ndef attach (l : list α) : list {x // x ∈ l} := pmap subtype.mk l (λ a, id)\n\ntheorem sizeof_lt_sizeof_of_mem [has_sizeof α] {x : α} {l : list α} (hx : x ∈ l) :\n  sizeof x < sizeof l :=\nbegin\n  induction l with h t ih; cases hx,\n  { rw hx, exact lt_add_of_lt_of_nonneg (lt_one_add _) (nat.zero_le _) },\n  { exact lt_add_of_pos_of_le (zero_lt_one_add _) (le_of_lt (ih hx)) }\nend\n\ntheorem pmap_eq_map (p : α → Prop) (f : α → β) (l : list α) (H) :\n  @pmap _ _ p (λ a _, f a) l H = map f l :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_congr {p q : α → Prop} {f : Π a, p a → β} {g : Π a, q a → β}\n  (l : list α) {H₁ H₂} (h : ∀ a h₁ h₂, f a h₁ = g a h₂) :\n  pmap f l H₁ = pmap g l H₂ :=\nby induction l with _ _ ih; [refl, rw [pmap, pmap, h, ih]]\n\ntheorem map_pmap {p : α → Prop} (g : β → γ) (f : Π a, p a → β)\n  (l H) : map g (pmap f l H) = pmap (λ a h, g (f a h)) l H :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_map {p : β → Prop} (g : ∀ b, p b → γ) (f : α → β)\n  (l H) : pmap g (map f l) H = pmap (λ a h, g (f a) h) l (λ a h, H _ (mem_map_of_mem _ h)) :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_eq_map_attach {p : α → Prop} (f : Π a, p a → β)\n  (l H) : pmap f l H = l.attach.map (λ x, f x.1 (H _ x.2)) :=\nby rw [attach, map_pmap]; exact pmap_congr l (λ a h₁ h₂, rfl)\n\ntheorem attach_map_val (l : list α) : l.attach.map subtype.val = l :=\nby rw [attach, map_pmap]; exact (pmap_eq_map _ _ _ _).trans (map_id l)\n\n@[simp] theorem mem_attach (l : list α) : ∀ x, x ∈ l.attach | ⟨a, h⟩ :=\nby have := mem_map.1 (by rw [attach_map_val]; exact h);\n   { rcases this with ⟨⟨_, _⟩, m, rfl⟩, exact m }\n\n@[simp] theorem mem_pmap {p : α → Prop} {f : Π a, p a → β}\n  {l H b} : b ∈ pmap f l H ↔ ∃ a (h : a ∈ l), f a (H a h) = b :=\nby simp only [pmap_eq_map_attach, mem_map, mem_attach, true_and, subtype.exists]\n\n@[simp] theorem length_pmap {p : α → Prop} {f : Π a, p a → β}\n  {l H} : length (pmap f l H) = length l :=\nby induction l; [refl, simp only [*, pmap, length]]\n\n@[simp] lemma length_attach (L : list α) : L.attach.length = L.length := length_pmap\n\n@[simp] lemma pmap_eq_nil {p : α → Prop} {f : Π a, p a → β}\n  {l H} : pmap f l H = [] ↔ l = [] :=\nby rw [← length_eq_zero, length_pmap, length_eq_zero]\n\n@[simp] lemma attach_eq_nil (l : list α) : l.attach = [] ↔ l = [] := pmap_eq_nil\n\nlemma last_pmap {α β : Type*} (p : α → Prop) (f : Π a, p a → β)\n  (l : list α) (hl₁ : ∀ a ∈ l, p a) (hl₂ : l ≠ []) :\n  (l.pmap f hl₁).last (mt list.pmap_eq_nil.1 hl₂) = f (l.last hl₂) (hl₁ _ (list.last_mem hl₂)) :=\nbegin\n  induction l with l_hd l_tl l_ih,\n  { apply (hl₂ rfl).elim },\n  { cases l_tl,\n    { simp },\n    { apply l_ih } }\nend\n\nlemma nth_pmap {p : α → Prop} (f : Π a, p a → β) {l : list α} (h : ∀ a ∈ l, p a) (n : ℕ) :\n  nth (pmap f l h) n = option.pmap f (nth l n) (λ x H, h x (nth_mem H)) :=\nbegin\n  induction l with hd tl hl generalizing n,\n  { simp },\n  { cases n; simp [hl] }\nend\n\nlemma nth_le_pmap {p : α → Prop} (f : Π a, p a → β) {l : list α} (h : ∀ a ∈ l, p a) {n : ℕ}\n  (hn : n < (pmap f l h).length) :\n  nth_le (pmap f l h) n hn = f (nth_le l n (@length_pmap _ _ p f l h ▸ hn))\n    (h _ (nth_le_mem l n (@length_pmap _ _ p f l h ▸ hn))) :=\nbegin\n  induction l with hd tl hl generalizing n,\n  { simp only [length, pmap] at hn,\n    exact absurd hn (not_lt_of_le n.zero_le) },\n  { cases n,\n    { simp },\n    { simpa [hl] } }\nend\n\n/-! ### find -/\n\nsection find\nvariables {p : α → Prop} [decidable_pred p] {l : list α} {a : α}\n\n@[simp] theorem find_nil (p : α → Prop) [decidable_pred p] : find p [] = none :=\nrfl\n\n@[simp] theorem find_cons_of_pos (l) (h : p a) : find p (a::l) = some a :=\nif_pos h\n\n@[simp] theorem find_cons_of_neg (l) (h : ¬ p a) : find p (a::l) = find p l :=\nif_neg h\n\n@[simp] theorem find_eq_none : find p l = none ↔ ∀ x ∈ l, ¬ p x :=\nbegin\n  induction l with a l IH,\n  { exact iff_of_true rfl (forall_mem_nil _) },\n  rw forall_mem_cons, by_cases h : p a,\n  { simp only [find_cons_of_pos _ h, h, not_true, false_and] },\n  { rwa [find_cons_of_neg _ h, iff_true_intro h, true_and] }\nend\n\ntheorem find_some (H : find p l = some a) : p a :=\nbegin\n  induction l with b l IH, {contradiction},\n  by_cases h : p b,\n  { rw find_cons_of_pos _ h at H, cases H, exact h },\n  { rw find_cons_of_neg _ h at H, exact IH H }\nend\n\n@[simp] theorem find_mem (H : find p l = some a) : a ∈ l :=\nbegin\n  induction l with b l IH, {contradiction},\n  by_cases h : p b,\n  { rw find_cons_of_pos _ h at H, cases H, apply mem_cons_self },\n  { rw find_cons_of_neg _ h at H, exact mem_cons_of_mem _ (IH H) }\nend\n\nend find\n\n/-! ### lookmap -/\nsection lookmap\nvariables (f : α → option α)\n\n@[simp] theorem lookmap_nil : [].lookmap f = [] := rfl\n\n@[simp] theorem lookmap_cons_none {a : α} (l : list α) (h : f a = none) :\n  (a :: l).lookmap f = a :: l.lookmap f :=\nby simp [lookmap, h]\n\n@[simp] theorem lookmap_cons_some {a b : α} (l : list α) (h : f a = some b) :\n  (a :: l).lookmap f = b :: l :=\nby simp [lookmap, h]\n\ntheorem lookmap_some : ∀ l : list α, l.lookmap some = l\n| []     := rfl\n| (a::l) := rfl\n\ntheorem lookmap_none : ∀ l : list α, l.lookmap (λ _, none) = l\n| []     := rfl\n| (a::l) := congr_arg (cons a) (lookmap_none l)\n\ntheorem lookmap_congr {f g : α → option α} :\n  ∀ {l : list α}, (∀ a ∈ l, f a = g a) → l.lookmap f = l.lookmap g\n| []     H := rfl\n| (a::l) H := begin\n  cases forall_mem_cons.1 H with H₁ H₂,\n  cases h : g a with b,\n  { simp [h, H₁.trans h, lookmap_congr H₂] },\n  { simp [lookmap_cons_some _ _ h, lookmap_cons_some _ _ (H₁.trans h)] }\nend\n\ntheorem lookmap_of_forall_not {l : list α} (H : ∀ a ∈ l, f a = none) : l.lookmap f = l :=\n(lookmap_congr H).trans (lookmap_none l)\n\ntheorem lookmap_map_eq (g : α → β) (h : ∀ a (b ∈ f a), g a = g b) :\n  ∀ l : list α, map g (l.lookmap f) = map g l\n| []     := rfl\n| (a::l) := begin\n  cases h' : f a with b,\n  { simp [h', lookmap_map_eq] },\n  { simp [lookmap_cons_some _ _ h', h _ _ h'] }\nend\n\ntheorem lookmap_id' (h : ∀ a (b ∈ f a), a = b) (l : list α) : l.lookmap f = l :=\nby rw [← map_id (l.lookmap f), lookmap_map_eq, map_id]; exact h\n\ntheorem length_lookmap (l : list α) : length (l.lookmap f) = length l :=\nby rw [← length_map, lookmap_map_eq _ (λ _, ()), length_map]; simp\n\nend lookmap\n\n/-! ### filter_map -/\n\n@[simp] theorem filter_map_nil (f : α → option β) : filter_map f [] = [] := rfl\n\n@[simp] theorem filter_map_cons_none {f : α → option β} (a : α) (l : list α) (h : f a = none) :\n  filter_map f (a :: l) = filter_map f l :=\nby simp only [filter_map, h]\n\n@[simp] theorem filter_map_cons_some (f : α → option β)\n  (a : α) (l : list α) {b : β} (h : f a = some b) :\n  filter_map f (a :: l) = b :: filter_map f l :=\nby simp only [filter_map, h]; split; refl\n\nlemma filter_map_append {α β : Type*} (l l' : list α) (f : α → option β) :\n  filter_map f (l ++ l') = filter_map f l ++ filter_map f l' :=\nbegin\n  induction l with hd tl hl generalizing l',\n  { simp },\n  { rw [cons_append, filter_map, filter_map],\n    cases f hd;\n    simp only [filter_map, hl, cons_append, eq_self_iff_true, and_self] }\nend\n\ntheorem filter_map_eq_map (f : α → β) : filter_map (some ∘ f) = map f :=\nbegin\n  funext l,\n  induction l with a l IH, {refl},\n  simp only [filter_map_cons_some (some ∘ f) _ _ rfl, IH, map_cons], split; refl\nend\n\ntheorem filter_map_eq_filter (p : α → Prop) [decidable_pred p] :\n  filter_map (option.guard p) = filter p :=\nbegin\n  funext l,\n  induction l with a l IH, {refl},\n  by_cases pa : p a,\n  { simp only [filter_map, option.guard, IH, if_pos pa, filter_cons_of_pos _ pa], split; refl },\n  { simp only [filter_map, option.guard, IH, if_neg pa, filter_cons_of_neg _ pa] }\nend\n\ntheorem filter_map_filter_map (f : α → option β) (g : β → option γ) (l : list α) :\n  filter_map g (filter_map f l) = filter_map (λ x, (f x).bind g) l :=\nbegin\n  induction l with a l IH, {refl},\n  cases h : f a with b,\n  { rw [filter_map_cons_none _ _ h, filter_map_cons_none, IH],\n    simp only [h, option.none_bind'] },\n  rw filter_map_cons_some _ _ _ h,\n  cases h' : g b with c;\n  [ rw [filter_map_cons_none _ _ h', filter_map_cons_none, IH],\n    rw [filter_map_cons_some _ _ _ h', filter_map_cons_some, IH] ];\n  simp only [h, h', option.some_bind']\nend\n\ntheorem map_filter_map (f : α → option β) (g : β → γ) (l : list α) :\n  map g (filter_map f l) = filter_map (λ x, (f x).map g) l :=\nby rw [← filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_map_map (f : α → β) (g : β → option γ) (l : list α) :\n  filter_map g (map f l) = filter_map (g ∘ f) l :=\nby rw [← filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_filter_map (f : α → option β) (p : β → Prop) [decidable_pred p] (l : list α) :\n  filter p (filter_map f l) = filter_map (λ x, (f x).filter p) l :=\nby rw [← filter_map_eq_filter, filter_map_filter_map]; refl\n\ntheorem filter_map_filter (p : α → Prop) [decidable_pred p] (f : α → option β) (l : list α) :\n  filter_map f (filter p l) = filter_map (λ x, if p x then f x else none) l :=\nbegin\n  rw [← filter_map_eq_filter, filter_map_filter_map], congr,\n  funext x,\n  show (option.guard p x).bind f = ite (p x) (f x) none,\n  by_cases h : p x,\n  { simp only [option.guard, if_pos h, option.some_bind'] },\n  { simp only [option.guard, if_neg h, option.none_bind'] }\nend\n\n@[simp] theorem filter_map_some (l : list α) : filter_map some l = l :=\nby rw filter_map_eq_map; apply map_id\n\n@[simp] theorem mem_filter_map (f : α → option β) (l : list α) {b : β} :\n  b ∈ filter_map f l ↔ ∃ a, a ∈ l ∧ f a = some b :=\nbegin\n  induction l with a l IH,\n  { split, { intro H, cases H }, { rintro ⟨_, H, _⟩, cases H } },\n  cases h : f a with b',\n  { have : f a ≠ some b, {rw h, intro, contradiction},\n    simp only [filter_map_cons_none _ _ h, IH, mem_cons_iff,\n      or_and_distrib_right, exists_or_distrib, exists_eq_left, this, false_or] },\n  { have : f a = some b ↔ b = b',\n    { split; intro t, {rw t at h; injection h}, {exact t.symm ▸ h} },\n      simp only [filter_map_cons_some _ _ _ h, IH, mem_cons_iff,\n        or_and_distrib_right, exists_or_distrib, this, exists_eq_left] }\nend\n\ntheorem map_filter_map_of_inv (f : α → option β) (g : β → α)\n  (H : ∀ x : α, (f x).map g = some x) (l : list α) :\n  map g (filter_map f l) = l :=\nby simp only [map_filter_map, H, filter_map_some]\n\ntheorem sublist.filter_map (f : α → option β) {l₁ l₂ : list α}\n  (s : l₁ <+ l₂) : filter_map f l₁ <+ filter_map f l₂ :=\nby induction s with l₁ l₂ a s IH l₁ l₂ a s IH;\n   simp only [filter_map]; cases f a with b;\n   simp only [filter_map, IH, sublist.cons, sublist.cons2]\n\ntheorem sublist.map (f : α → β) {l₁ l₂ : list α}\n  (s : l₁ <+ l₂) : map f l₁ <+ map f l₂ :=\nfilter_map_eq_map f ▸ s.filter_map _\n\n/-! ### reduce_option -/\n\n@[simp] lemma reduce_option_cons_of_some (x : α) (l : list (option α)) :\n  reduce_option (some x :: l) = x :: l.reduce_option :=\nby simp only [reduce_option, filter_map, id.def, eq_self_iff_true, and_self]\n\n@[simp] lemma reduce_option_cons_of_none (l : list (option α)) :\n  reduce_option (none :: l) = l.reduce_option :=\nby simp only [reduce_option, filter_map, id.def]\n\n@[simp] lemma reduce_option_nil : @reduce_option α [] = [] := rfl\n\n@[simp] lemma reduce_option_map {l : list (option α)} {f : α → β} :\n  reduce_option (map (option.map f) l) = map f (reduce_option l) :=\nbegin\n  induction l with hd tl hl,\n  { simp only [reduce_option_nil, map_nil] },\n  { cases hd;\n    simpa only [true_and, option.map_some', map, eq_self_iff_true,\n                reduce_option_cons_of_some] using hl },\nend\n\nlemma reduce_option_append (l l' : list (option α)) :\n  (l ++ l').reduce_option = l.reduce_option ++ l'.reduce_option :=\nfilter_map_append l l' id\n\nlemma reduce_option_length_le (l : list (option α)) :\n  l.reduce_option.length ≤ l.length :=\nbegin\n  induction l with hd tl hl,\n  { simp only [reduce_option_nil, length] },\n  { cases hd,\n    { exact nat.le_succ_of_le hl },\n    { simpa only [length, add_le_add_iff_right, reduce_option_cons_of_some] using hl} }\nend\n\nlemma reduce_option_length_eq_iff {l : list (option α)} :\n  l.reduce_option.length = l.length ↔ ∀ x ∈ l, option.is_some x :=\nbegin\n  induction l with hd tl hl,\n  { simp only [forall_const, reduce_option_nil, not_mem_nil,\n               forall_prop_of_false, eq_self_iff_true, length, not_false_iff] },\n  { cases hd,\n    { simp only [mem_cons_iff, forall_eq_or_imp, bool.coe_sort_ff, false_and,\n                 reduce_option_cons_of_none, length, option.is_some_none, iff_false],\n      intro H,\n      have := reduce_option_length_le tl,\n      rw H at this,\n      exact absurd (nat.lt_succ_self _) (not_lt_of_le this) },\n    { simp only [hl, true_and, mem_cons_iff, forall_eq_or_imp, add_left_inj,\n                 bool.coe_sort_tt, length, option.is_some_some, reduce_option_cons_of_some] } }\nend\n\nlemma reduce_option_length_lt_iff {l : list (option α)} :\n  l.reduce_option.length < l.length ↔ none ∈ l :=\nbegin\n  convert not_iff_not.mpr reduce_option_length_eq_iff;\n  simp [lt_iff_le_and_ne, reduce_option_length_le l, option.is_none_iff_eq_none]\nend\n\nlemma reduce_option_singleton (x : option α) :\n  [x].reduce_option = x.to_list :=\nby cases x; refl\n\nlemma reduce_option_concat (l : list (option α)) (x : option α) :\n  (l.concat x).reduce_option = l.reduce_option ++ x.to_list :=\nbegin\n  induction l with hd tl hl generalizing x,\n  { cases x;\n    simp [option.to_list] },\n  { simp only [concat_eq_append, reduce_option_append] at hl,\n    cases hd;\n    simp [hl, reduce_option_append] }\nend\n\nlemma reduce_option_concat_of_some (l : list (option α)) (x : α) :\n  (l.concat (some x)).reduce_option = l.reduce_option.concat x :=\nby simp only [reduce_option_nil, concat_eq_append, reduce_option_append, reduce_option_cons_of_some]\n\nlemma reduce_option_mem_iff {l : list (option α)} {x : α} :\n  x ∈ l.reduce_option ↔ (some x) ∈ l :=\nby simp only [reduce_option, id.def, mem_filter_map, exists_eq_right]\n\n\nlemma reduce_option_nth_iff {l : list (option α)} {x : α} :\n  (∃ i, l.nth i = some (some x)) ↔ ∃ i, l.reduce_option.nth i = some x :=\nby rw [←mem_iff_nth, ←mem_iff_nth, reduce_option_mem_iff]\n\n/-! ### filter -/\n\nsection filter\nvariables {p : α → Prop} [decidable_pred p]\n\ntheorem filter_eq_foldr (p : α → Prop) [decidable_pred p] (l : list α) :\n  filter p l = foldr (λ a out, if p a then a :: out else out) [] l :=\nby induction l; simp [*, filter]\n\nlemma filter_congr {p q : α → Prop} [decidable_pred p] [decidable_pred q]\n  : ∀ {l : list α}, (∀ x ∈ l, p x ↔ q x) → filter p l = filter q l\n| [] _     := rfl\n| (a::l) h := by rw forall_mem_cons at h; by_cases pa : p a;\n  [simp only [filter_cons_of_pos _ pa, filter_cons_of_pos _ (h.1.1 pa), filter_congr h.2],\n   simp only [filter_cons_of_neg _ pa, filter_cons_of_neg _ (mt h.1.2 pa), filter_congr h.2]];\n     split; refl\n\n@[simp] theorem filter_subset (l : list α) : filter p l ⊆ l :=\n(filter_sublist l).subset\n\ntheorem of_mem_filter {a : α} : ∀ {l}, a ∈ filter p l → p a\n| (b::l) ain :=\n  if pb : p b then\n    have a ∈ b :: filter p l, by simpa only [filter_cons_of_pos _ pb] using ain,\n    or.elim (eq_or_mem_of_mem_cons this)\n      (assume : a = b, begin rw [← this] at pb, exact pb end)\n      (assume : a ∈ filter p l, of_mem_filter this)\n  else\n    begin simp only [filter_cons_of_neg _ pb] at ain, exact (of_mem_filter ain) end\n\ntheorem mem_of_mem_filter {a : α} {l} (h : a ∈ filter p l) : a ∈ l :=\nfilter_subset l h\n\ntheorem mem_filter_of_mem {a : α} : ∀ {l}, a ∈ l → p a → a ∈ filter p l\n| (_::l) (or.inl rfl) pa := by rw filter_cons_of_pos _ pa; apply mem_cons_self\n| (b::l) (or.inr ain) pa := if pb : p b\n    then by rw [filter_cons_of_pos _ pb]; apply mem_cons_of_mem; apply mem_filter_of_mem ain pa\n    else by rw [filter_cons_of_neg _ pb]; apply mem_filter_of_mem ain pa\n\n@[simp] theorem mem_filter {a : α} {l} : a ∈ filter p l ↔ a ∈ l ∧ p a :=\n⟨λ h, ⟨mem_of_mem_filter h, of_mem_filter h⟩, λ ⟨h₁, h₂⟩, mem_filter_of_mem h₁ h₂⟩\n\ntheorem filter_eq_self {l} : filter p l = l ↔ ∀ a ∈ l, p a :=\nbegin\n  induction l with a l ih,\n  { exact iff_of_true rfl (forall_mem_nil _) },\n  rw forall_mem_cons, by_cases p a,\n  { rw [filter_cons_of_pos _ h, cons_inj, ih, and_iff_right h] },\n  { rw [filter_cons_of_neg _ h],\n    refine iff_of_false _ (mt and.left h), intro e,\n    have := filter_sublist l, rw e at this,\n    exact not_lt_of_ge (length_le_of_sublist this) (lt_succ_self _) }\nend\n\ntheorem filter_eq_nil {l} : filter p l = [] ↔ ∀ a ∈ l, ¬p a :=\nby simp only [eq_nil_iff_forall_not_mem, mem_filter, not_and]\n\nvariable (p)\ntheorem filter_sublist_filter {l₁ l₂} (s : l₁ <+ l₂) : filter p l₁ <+ filter p l₂ :=\nfilter_map_eq_filter p ▸ s.filter_map _\n\ntheorem map_filter (f : β → α) (l : list β) :\n  filter p (map f l) = map f (filter (p ∘ f) l) :=\nby rw [← filter_map_eq_map, filter_filter_map, filter_map_filter]; refl\n\n@[simp] theorem filter_filter (q) [decidable_pred q] : ∀ l,\n  filter p (filter q l) = filter (λ a, p a ∧ q a) l\n| [] := rfl\n| (a :: l) := by by_cases hp : p a; by_cases hq : q a; simp only [hp, hq, filter, if_true, if_false,\n    true_and, false_and, filter_filter l, eq_self_iff_true]\n\n@[simp] lemma filter_true {h : decidable_pred (λ a : α, true)} (l : list α) :\n  @filter α (λ _, true) h l = l :=\nby convert filter_eq_self.2 (λ _ _, trivial)\n\n@[simp] lemma filter_false {h : decidable_pred (λ a : α, false)} (l : list α) :\n  @filter α (λ _, false) h l = [] :=\nby convert filter_eq_nil.2 (λ _ _, id)\n\n@[simp] theorem span_eq_take_drop : ∀ (l : list α), span p l = (take_while p l, drop_while p l)\n| []     := rfl\n| (a::l) :=\n    if pa : p a then by simp only [span, if_pos pa, span_eq_take_drop l, take_while, drop_while]\n    else by simp only [span, take_while, drop_while, if_neg pa]\n\n@[simp] theorem take_while_append_drop : ∀ (l : list α), take_while p l ++ drop_while p l = l\n| []     := rfl\n| (a::l) := if pa : p a then by rw [take_while, drop_while, if_pos pa, if_pos pa, cons_append,\n      take_while_append_drop l]\n    else by rw [take_while, drop_while, if_neg pa, if_neg pa, nil_append]\n\n@[simp] theorem countp_nil : countp p [] = 0 := rfl\n\n@[simp] theorem countp_cons_of_pos {a : α} (l) (pa : p a) : countp p (a::l) = countp p l + 1 :=\nif_pos pa\n\n@[simp] theorem countp_cons_of_neg {a : α} (l) (pa : ¬ p a) : countp p (a::l) = countp p l :=\nif_neg pa\n\ntheorem countp_eq_length_filter (l) : countp p l = length (filter p l) :=\nby induction l with x l ih; [refl, by_cases (p x)];\n  [simp only [filter_cons_of_pos _ h, countp, ih, if_pos h],\n   simp only [countp_cons_of_neg _ _ h, ih, filter_cons_of_neg _ h]]; refl\n\nlocal attribute [simp] countp_eq_length_filter\n\n@[simp] theorem countp_append (l₁ l₂) : countp p (l₁ ++ l₂) = countp p l₁ + countp p l₂ :=\nby simp only [countp_eq_length_filter, filter_append, length_append]\n\ntheorem countp_pos {l} : 0 < countp p l ↔ ∃ a ∈ l, p a :=\nby simp only [countp_eq_length_filter, length_pos_iff_exists_mem, mem_filter, exists_prop]\n\ntheorem countp_le_of_sublist {l₁ l₂} (s : l₁ <+ l₂) : countp p l₁ ≤ countp p l₂ :=\nby simpa only [countp_eq_length_filter] using length_le_of_sublist (filter_sublist_filter p s)\n\n@[simp] theorem countp_filter {q} [decidable_pred q] (l : list α) :\n  countp p (filter q l) = countp (λ a, p a ∧ q a) l :=\nby simp only [countp_eq_length_filter, filter_filter]\n\nend filter\n\n/-! ### count -/\n\nsection count\nvariable [decidable_eq α]\n\n@[simp] theorem count_nil (a : α) : count a [] = 0 := rfl\n\ntheorem count_cons (a b : α) (l : list α) :\n  count a (b :: l) = if a = b then succ (count a l) else count a l := rfl\n\ntheorem count_cons' (a b : α) (l : list α) :\n  count a (b :: l) = count a l + (if a = b then 1 else 0) :=\nbegin rw count_cons, split_ifs; refl end\n\n@[simp] theorem count_cons_self (a : α) (l : list α) : count a (a::l) = succ (count a l) :=\nif_pos rfl\n\n@[simp, priority 990]\ntheorem count_cons_of_ne {a b : α} (h : a ≠ b) (l : list α) : count a (b::l) = count a l :=\nif_neg h\n\ntheorem count_tail : Π (l : list α) (a : α) (h : 0 < l.length),\n  l.tail.count a = l.count a - ite (a = list.nth_le l 0 h) 1 0\n| (_ :: _) a h := by { rw [count_cons], split_ifs; simp }\n\ntheorem count_le_of_sublist (a : α) {l₁ l₂} : l₁ <+ l₂ → count a l₁ ≤ count a l₂ :=\ncountp_le_of_sublist _\n\ntheorem count_le_count_cons (a b : α) (l : list α) : count a l ≤ count a (b :: l) :=\ncount_le_of_sublist _ (sublist_cons _ _)\n\ntheorem count_singleton (a : α) : count a [a] = 1 := if_pos rfl\n\n@[simp] theorem count_append (a : α) : ∀ l₁ l₂, count a (l₁ ++ l₂) = count a l₁ + count a l₂ :=\ncountp_append _\n\ntheorem count_concat (a : α) (l : list α) : count a (concat l a) = succ (count a l) :=\nby simp [-add_comm]\n\ntheorem count_pos {a : α} {l : list α} : 0 < count a l ↔ a ∈ l :=\nby simp only [count, countp_pos, exists_prop, exists_eq_right']\n\n@[simp, priority 980]\ntheorem count_eq_zero_of_not_mem {a : α} {l : list α} (h : a ∉ l) : count a l = 0 :=\ndecidable.by_contradiction $ λ h', h $ count_pos.1 (nat.pos_of_ne_zero h')\n\ntheorem not_mem_of_count_eq_zero {a : α} {l : list α} (h : count a l = 0) : a ∉ l :=\nλ h', ne_of_gt (count_pos.2 h') h\n\n@[simp] theorem count_repeat (a : α) (n : ℕ) : count a (repeat a n) = n :=\nby rw [count, countp_eq_length_filter, filter_eq_self.2, length_repeat];\n   exact λ b m, (eq_of_mem_repeat m).symm\n\ntheorem le_count_iff_repeat_sublist {a : α} {l : list α} {n : ℕ} :\n  n ≤ count a l ↔ repeat a n <+ l :=\n⟨λ h, ((repeat_sublist_repeat a).2 h).trans $\n  have filter (eq a) l = repeat a (count a l), from eq_repeat.2\n    ⟨by simp only [count, countp_eq_length_filter], λ b m, (of_mem_filter m).symm⟩,\n  by rw ← this; apply filter_sublist,\n λ h, by simpa only [count_repeat] using count_le_of_sublist a h⟩\n\ntheorem repeat_count_eq_of_count_eq_length  {a : α} {l : list α} (h : count a l = length l)  :\n  repeat a (count a l) = l :=\neq_of_sublist_of_length_eq (le_count_iff_repeat_sublist.mp (le_refl (count a l)))\n    (eq.trans (length_repeat a (count a l)) h)\n\n@[simp] theorem count_filter {p} [decidable_pred p]\n  {a} {l : list α} (h : p a) : count a (filter p l) = count a l :=\nby simp only [count, countp_filter]; congr; exact\nset.ext (λ b, and_iff_left_of_imp (λ e, e ▸ h))\n\nend count\n\n/-! ### prefix, suffix, infix -/\n\n@[simp] theorem prefix_append (l₁ l₂ : list α) : l₁ <+: l₁ ++ l₂ := ⟨l₂, rfl⟩\n\n@[simp] theorem suffix_append (l₁ l₂ : list α) : l₂ <:+ l₁ ++ l₂ := ⟨l₁, rfl⟩\n\ntheorem infix_append (l₁ l₂ l₃ : list α) : l₂ <:+: l₁ ++ l₂ ++ l₃ := ⟨l₁, l₃, rfl⟩\n\n@[simp] theorem infix_append' (l₁ l₂ l₃ : list α) : l₂ <:+: l₁ ++ (l₂ ++ l₃) :=\nby rw ← list.append_assoc; apply infix_append\n\ntheorem nil_prefix (l : list α) : [] <+: l := ⟨l, rfl⟩\n\ntheorem nil_suffix (l : list α) : [] <:+ l := ⟨l, append_nil _⟩\n\n@[refl] theorem prefix_refl (l : list α) : l <+: l := ⟨[], append_nil _⟩\n\n@[refl] theorem suffix_refl (l : list α) : l <:+ l := ⟨[], rfl⟩\n\n@[simp] theorem suffix_cons (a : α) : ∀ l, l <:+ a :: l := suffix_append [a]\n\ntheorem prefix_concat (a : α) (l) : l <+: concat l a := by simp\n\ntheorem infix_of_prefix {l₁ l₂ : list α} : l₁ <+: l₂ → l₁ <:+: l₂ :=\nλ⟨t, h⟩, ⟨[], t, h⟩\n\ntheorem infix_of_suffix {l₁ l₂ : list α} : l₁ <:+ l₂ → l₁ <:+: l₂ :=\nλ⟨t, h⟩, ⟨t, [], by simp only [h, append_nil]⟩\n\n@[refl] theorem infix_refl (l : list α) : l <:+: l := infix_of_prefix $ prefix_refl l\n\ntheorem nil_infix (l : list α) : [] <:+: l := infix_of_prefix $ nil_prefix l\n\ntheorem infix_cons {L₁ L₂ : list α} {x : α} : L₁ <:+: L₂ → L₁ <:+: x :: L₂ :=\nλ⟨LP, LS, H⟩, ⟨x :: LP, LS, H ▸ rfl⟩\n\n@[trans] theorem is_prefix.trans : ∀ {l₁ l₂ l₃ : list α}, l₁ <+: l₂ → l₂ <+: l₃ → l₁ <+: l₃\n| l ._ ._ ⟨r₁, rfl⟩ ⟨r₂, rfl⟩ := ⟨r₁ ++ r₂, (append_assoc _ _ _).symm⟩\n\n@[trans] theorem is_suffix.trans : ∀ {l₁ l₂ l₃ : list α}, l₁ <:+ l₂ → l₂ <:+ l₃ → l₁ <:+ l₃\n| l ._ ._ ⟨l₁, rfl⟩ ⟨l₂, rfl⟩ := ⟨l₂ ++ l₁, append_assoc _ _ _⟩\n\n@[trans] theorem is_infix.trans : ∀ {l₁ l₂ l₃ : list α}, l₁ <:+: l₂ → l₂ <:+: l₃ → l₁ <:+: l₃\n| l ._ ._ ⟨l₁, r₁, rfl⟩ ⟨l₂, r₂, rfl⟩ := ⟨l₂ ++ l₁, r₁ ++ r₂, by simp only [append_assoc]⟩\n\ntheorem sublist_of_infix {l₁ l₂ : list α} : l₁ <:+: l₂ → l₁ <+ l₂ :=\nλ⟨s, t, h⟩, by rw [← h]; exact (sublist_append_right _ _).trans (sublist_append_left _ _)\n\ntheorem sublist_of_prefix {l₁ l₂ : list α} : l₁ <+: l₂ → l₁ <+ l₂ :=\nsublist_of_infix ∘ infix_of_prefix\n\ntheorem sublist_of_suffix {l₁ l₂ : list α} : l₁ <:+ l₂ → l₁ <+ l₂ :=\nsublist_of_infix ∘ infix_of_suffix\n\ntheorem reverse_suffix {l₁ l₂ : list α} : reverse l₁ <:+ reverse l₂ ↔ l₁ <+: l₂ :=\n⟨λ ⟨r, e⟩, ⟨reverse r,\n  by rw [← reverse_reverse l₁, ← reverse_append, e, reverse_reverse]⟩,\n λ ⟨r, e⟩, ⟨reverse r, by rw [← reverse_append, e]⟩⟩\n\ntheorem reverse_prefix {l₁ l₂ : list α} : reverse l₁ <+: reverse l₂ ↔ l₁ <:+ l₂ :=\nby rw ← reverse_suffix; simp only [reverse_reverse]\n\ntheorem length_le_of_infix {l₁ l₂ : list α} (s : l₁ <:+: l₂) : length l₁ ≤ length l₂ :=\nlength_le_of_sublist $ sublist_of_infix s\n\ntheorem eq_nil_of_infix_nil {l : list α} (s : l <:+: []) : l = [] :=\neq_nil_of_sublist_nil $ sublist_of_infix s\n\n@[simp] theorem eq_nil_iff_infix_nil {l : list α} : l <:+: [] ↔ l = [] :=\n⟨eq_nil_of_infix_nil, λ h, h ▸ infix_refl _⟩\n\ntheorem eq_nil_of_prefix_nil {l : list α} (s : l <+: []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_prefix s\n\n@[simp] theorem eq_nil_iff_prefix_nil {l : list α} : l <+: [] ↔ l = [] :=\n⟨eq_nil_of_prefix_nil, λ h, h ▸ prefix_refl _⟩\n\ntheorem eq_nil_of_suffix_nil {l : list α} (s : l <:+ []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_suffix s\n\n@[simp] theorem eq_nil_iff_suffix_nil {l : list α} : l <:+ [] ↔ l = [] :=\n⟨eq_nil_of_suffix_nil, λ h, h ▸ suffix_refl _⟩\n\ntheorem infix_iff_prefix_suffix (l₁ l₂ : list α) : l₁ <:+: l₂ ↔ ∃ t, l₁ <+: t ∧ t <:+ l₂ :=\n⟨λ⟨s, t, e⟩, ⟨l₁ ++ t, ⟨_, rfl⟩, by rw [← e, append_assoc]; exact ⟨_, rfl⟩⟩,\nλ⟨._, ⟨t, rfl⟩, ⟨s, e⟩⟩, ⟨s, t, by rw append_assoc; exact e⟩⟩\n\ntheorem eq_of_infix_of_length_eq {l₁ l₂ : list α} (s : l₁ <:+: l₂) :\n  length l₁ = length l₂ → l₁ = l₂ :=\neq_of_sublist_of_length_eq $ sublist_of_infix s\n\ntheorem eq_of_prefix_of_length_eq {l₁ l₂ : list α} (s : l₁ <+: l₂) :\n  length l₁ = length l₂ → l₁ = l₂ :=\neq_of_sublist_of_length_eq $ sublist_of_prefix s\n\ntheorem eq_of_suffix_of_length_eq {l₁ l₂ : list α} (s : l₁ <:+ l₂) :\n  length l₁ = length l₂ → l₁ = l₂ :=\neq_of_sublist_of_length_eq $ sublist_of_suffix s\n\ntheorem prefix_of_prefix_length_le : ∀ {l₁ l₂ l₃ : list α},\n l₁ <+: l₃ → l₂ <+: l₃ → length l₁ ≤ length l₂ → l₁ <+: l₂\n| []      l₂ l₃ h₁ h₂ _ := nil_prefix _\n| (a::l₁) (b::l₂) _ ⟨r₁, rfl⟩ ⟨r₂, e⟩ ll := begin\n  injection e with _ e', subst b,\n  rcases prefix_of_prefix_length_le ⟨_, rfl⟩ ⟨_, e'⟩\n    (le_of_succ_le_succ ll) with ⟨r₃, rfl⟩,\n  exact ⟨r₃, rfl⟩\nend\n\ntheorem prefix_or_prefix_of_prefix {l₁ l₂ l₃ : list α}\n (h₁ : l₁ <+: l₃) (h₂ : l₂ <+: l₃) : l₁ <+: l₂ ∨ l₂ <+: l₁ :=\n(le_total (length l₁) (length l₂)).imp\n  (prefix_of_prefix_length_le h₁ h₂)\n  (prefix_of_prefix_length_le h₂ h₁)\n\ntheorem suffix_of_suffix_length_le {l₁ l₂ l₃ : list α}\n (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) (ll : length l₁ ≤ length l₂) : l₁ <:+ l₂ :=\nreverse_prefix.1 $ prefix_of_prefix_length_le\n  (reverse_prefix.2 h₁) (reverse_prefix.2 h₂) (by simp [ll])\n\ntheorem suffix_or_suffix_of_suffix {l₁ l₂ l₃ : list α}\n (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) : l₁ <:+ l₂ ∨ l₂ <:+ l₁ :=\n(prefix_or_prefix_of_prefix (reverse_prefix.2 h₁) (reverse_prefix.2 h₂)).imp\n  reverse_prefix.1 reverse_prefix.1\n\ntheorem suffix_cons_iff {x : α} {l₁ l₂ : list α} :\n  l₁ <:+ x :: l₂ ↔ l₁ = x :: l₂ ∨ l₁ <:+ l₂ :=\nbegin\n  split,\n  { rintro ⟨⟨hd, tl⟩, hl₃⟩,\n    { exact or.inl hl₃ },\n    { simp only [cons_append] at hl₃,\n      exact or.inr ⟨_, hl₃.2⟩ } },\n  { rintro (rfl | hl₁),\n    { exact (x :: l₂).suffix_refl },\n    { exact hl₁.trans (l₂.suffix_cons _) } }\nend\n\ntheorem infix_of_mem_join : ∀ {L : list (list α)} {l}, l ∈ L → l <:+: join L\n| (_  :: L) l (or.inl rfl) := infix_append [] _ _\n| (l' :: L) l (or.inr h)   :=\n  is_infix.trans (infix_of_mem_join h) $ infix_of_suffix $ suffix_append _ _\n\ntheorem prefix_append_right_inj {l₁ l₂ : list α} (l) : l ++ l₁ <+: l ++ l₂ ↔ l₁ <+: l₂ :=\nexists_congr $ λ r, by rw [append_assoc, append_right_inj]\n\ntheorem prefix_cons_inj {l₁ l₂ : list α} (a) : a :: l₁ <+: a :: l₂ ↔ l₁ <+: l₂ :=\nprefix_append_right_inj [a]\n\ntheorem take_prefix (n) (l : list α) : take n l <+: l := ⟨_, take_append_drop _ _⟩\n\ntheorem drop_suffix (n) (l : list α) : drop n l <:+ l := ⟨_, take_append_drop _ _⟩\n\ntheorem tail_suffix (l : list α) : tail l <:+ l := by rw ← drop_one; apply drop_suffix\n\nlemma tail_sublist (l : list α) : l.tail <+ l := sublist_of_suffix (tail_suffix l)\n\ntheorem tail_subset (l : list α) : tail l ⊆ l := (tail_sublist l).subset\n\ntheorem prefix_iff_eq_append {l₁ l₂ : list α} : l₁ <+: l₂ ↔ l₁ ++ drop (length l₁) l₂ = l₂ :=\n⟨by rintros ⟨r, rfl⟩; rw drop_left, λ e, ⟨_, e⟩⟩\n\ntheorem suffix_iff_eq_append {l₁ l₂ : list α} :\n  l₁ <:+ l₂ ↔ take (length l₂ - length l₁) l₂ ++ l₁ = l₂ :=\n⟨by rintros ⟨r, rfl⟩; simp only [length_append, nat.add_sub_cancel, take_left], λ e, ⟨_, e⟩⟩\n\ntheorem prefix_iff_eq_take {l₁ l₂ : list α} : l₁ <+: l₂ ↔ l₁ = take (length l₁) l₂ :=\n⟨λ h, append_right_cancel $\n  (prefix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n λ e, e.symm ▸ take_prefix _ _⟩\n\ntheorem suffix_iff_eq_drop {l₁ l₂ : list α} : l₁ <:+ l₂ ↔ l₁ = drop (length l₂ - length l₁) l₂ :=\n⟨λ h, append_left_cancel $\n  (suffix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n λ e, e.symm ▸ drop_suffix _ _⟩\n\ninstance decidable_prefix [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <+: l₂)\n| []      l₂ := is_true ⟨l₂, rfl⟩\n| (a::l₁) [] := is_false $ λ ⟨t, te⟩, list.no_confusion te\n| (a::l₁) (b::l₂) :=\n  if h : a = b then\n    @decidable_of_iff _ _ (by rw [← h, prefix_cons_inj])\n      (decidable_prefix l₁ l₂)\n  else\n    is_false $ λ ⟨t, te⟩, h $ by injection te\n\n-- Alternatively, use mem_tails\ninstance decidable_suffix [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <:+ l₂)\n| []      l₂ := is_true ⟨l₂, append_nil _⟩\n| (a::l₁) [] := is_false $ mt (length_le_of_sublist ∘ sublist_of_suffix) dec_trivial\n| l₁      l₂ := let len1 := length l₁, len2 := length l₂ in\n  if hl : len1 ≤ len2 then\n    decidable_of_iff' (l₁ = drop (len2-len1) l₂) suffix_iff_eq_drop\n  else is_false $ λ h, hl $ length_le_of_sublist $ sublist_of_suffix h\n\nlemma prefix_take_le_iff {L : list (list (option α))} {m n : ℕ} (hm : m < L.length) :\n  (take m L) <+: (take n L) ↔ m ≤ n :=\nbegin\n  simp only [prefix_iff_eq_take, length_take],\n  induction m with m IH generalizing L n,\n  { simp only [min_eq_left, eq_self_iff_true, nat.zero_le, take] },\n  { cases n,\n    { simp only [nat.nat_zero_eq_zero, nonpos_iff_eq_zero, take, take_nil],\n      split,\n      { cases L,\n        { exact absurd hm (not_lt_of_le m.succ.zero_le) },\n        { simp only [forall_prop_of_false, not_false_iff, take] } },\n      { intro h,\n        contradiction } },\n    { cases L with l ls,\n      { exact absurd hm (not_lt_of_le m.succ.zero_le) },\n      { simp only [length] at hm,\n        specialize @IH ls n (nat.lt_of_succ_lt_succ hm),\n        simp only [le_of_lt (nat.lt_of_succ_lt_succ hm), min_eq_left] at IH,\n        simp only [le_of_lt hm, IH, true_and, min_eq_left, eq_self_iff_true, length, take],\n        exact ⟨nat.succ_le_succ, nat.le_of_succ_le_succ⟩ } } },\nend\n\nlemma cons_prefix_iff {l l' : list α} {x y : α} :\n  x :: l <+: y :: l' ↔ x = y ∧ l <+: l' :=\nbegin\n  split,\n  { rintro ⟨L, hL⟩,\n    simp only [cons_append] at hL,\n    exact ⟨hL.left, ⟨L, hL.right⟩⟩ },\n  { rintro ⟨rfl, h⟩,\n    rwa [prefix_cons_inj] },\nend\n\nlemma map_prefix {l l' : list α} (f : α → β) (h : l <+: l') :\n  l.map f <+: l'.map f :=\nbegin\n  induction l with hd tl hl generalizing l',\n  { simp only [nil_prefix, map_nil] },\n  { cases l' with hd' tl',\n    { simpa only using eq_nil_of_prefix_nil h },\n    { rw cons_prefix_iff at h,\n      simp only [h, prefix_cons_inj, hl, map] } },\nend\n\nlemma is_prefix.filter_map {l l' : list α} (h : l <+: l') (f : α → option β) :\n  l.filter_map f <+: l'.filter_map f :=\nbegin\n  induction l with hd tl hl generalizing l',\n  { simp only [nil_prefix, filter_map_nil] },\n  { cases l' with hd' tl',\n    { simpa only using eq_nil_of_prefix_nil h },\n    { rw cons_prefix_iff at h,\n      rw [←@singleton_append _ hd _, ←@singleton_append _ hd' _, filter_map_append,\n         filter_map_append, h.left, prefix_append_right_inj],\n      exact hl h.right } },\nend\n\nlemma is_prefix.reduce_option {l l' : list (option α)} (h : l <+: l') :\n  l.reduce_option <+: l'.reduce_option :=\nh.filter_map id\n\n@[simp] theorem mem_inits : ∀ (s t : list α), s ∈ inits t ↔ s <+: t\n| s []     := suffices s = nil ↔ s <+: nil, by simpa only [inits, mem_singleton],\n  ⟨λh, h.symm ▸ prefix_refl [], eq_nil_of_prefix_nil⟩\n| s (a::t) :=\n  suffices (s = nil ∨ ∃ l ∈ inits t, a :: l = s) ↔ s <+: a :: t, by simpa,\n  ⟨λo, match s, o with\n  | ._, or.inl rfl := ⟨_, rfl⟩\n  | s, or.inr ⟨r, hr, hs⟩ := let ⟨s, ht⟩ := (mem_inits _ _).1 hr in\n    by rw [← hs, ← ht]; exact ⟨s, rfl⟩\n  end, λmi, match s, mi with\n  | [], ⟨._, rfl⟩ := or.inl rfl\n  | (b::s), ⟨r, hr⟩ := list.no_confusion hr $ λba (st : s++r = t), or.inr $\n    by rw ba; exact ⟨_, (mem_inits _ _).2 ⟨_, st⟩, rfl⟩\n  end⟩\n\n@[simp] theorem mem_tails : ∀ (s t : list α), s ∈ tails t ↔ s <:+ t\n| s []     := by simp only [tails, mem_singleton];\n  exact ⟨λh, by rw h; exact suffix_refl [], eq_nil_of_suffix_nil⟩\n| s (a::t) := by simp only [tails, mem_cons_iff, mem_tails s t];\n  exact show s = a :: t ∨ s <:+ t ↔ s <:+ a :: t, from\n  ⟨λo, match s, t, o with\n  | ._, t, or.inl rfl := suffix_refl _\n  | s, ._, or.inr ⟨l, rfl⟩ := ⟨a::l, rfl⟩\n  end, λe, match s, t, e with\n  | ._, t, ⟨[], rfl⟩ := or.inl rfl\n  | s, t, ⟨b::l, he⟩ := list.no_confusion he (λab lt, or.inr ⟨l, lt⟩)\n  end⟩\n\nlemma inits_cons (a : α) (l : list α) : inits (a :: l) = [] :: l.inits.map (λ t, a :: t) :=\nby simp\n\nlemma tails_cons (a : α) (l : list α) : tails (a :: l) = (a :: l) :: l.tails :=\nby simp\n\n@[simp]\nlemma inits_append : ∀ (s t : list α), inits (s ++ t) = s.inits ++ t.inits.tail.map (λ l, s ++ l)\n| [] [] := by simp\n| [] (a::t) := by simp\n| (a::s) t := by simp [inits_append s t]\n\n@[simp]\nlemma tails_append : ∀ (s t : list α), tails (s ++ t) = s.tails.map (λ l, l ++ t) ++ t.tails.tail\n| [] [] := by simp\n| [] (a::t) := by simp\n| (a::s) t := by simp [tails_append s t]\n\n-- the lemma names `inits_eq_tails` and `tails_eq_inits` are like `sublists_eq_sublists'`\nlemma inits_eq_tails :\n  ∀ (l : list α), l.inits = (reverse $ map reverse $ tails $ reverse l)\n| [] := by simp\n| (a :: l) := by simp [inits_eq_tails l, map_eq_map_iff]\n\nlemma tails_eq_inits :\n  ∀ (l : list α), l.tails = (reverse $ map reverse $ inits $ reverse l)\n| [] := by simp\n| (a :: l) := by simp [tails_eq_inits l, append_left_inj]\n\nlemma inits_reverse (l : list α) : inits (reverse l) = reverse (map reverse l.tails) :=\nby { rw tails_eq_inits l, simp [reverse_involutive.comp_self], }\n\nlemma tails_reverse (l : list α) : tails (reverse l) = reverse (map reverse l.inits) :=\nby { rw inits_eq_tails l, simp [reverse_involutive.comp_self], }\n\nlemma map_reverse_inits (l : list α) : map reverse l.inits = (reverse $ tails $ reverse l) :=\nby { rw inits_eq_tails l, simp [reverse_involutive.comp_self], }\n\nlemma map_reverse_tails (l : list α) : map reverse l.tails = (reverse $ inits $ reverse l) :=\nby { rw tails_eq_inits l, simp [reverse_involutive.comp_self], }\n\ninstance decidable_infix [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <:+: l₂)\n| []      l₂ := is_true ⟨[], l₂, rfl⟩\n| (a::l₁) [] := is_false $ λ⟨s, t, te⟩, absurd te $ append_ne_nil_of_ne_nil_left _ _ $\n                append_ne_nil_of_ne_nil_right _ _ $ λh, list.no_confusion h\n| l₁      l₂ := decidable_of_decidable_of_iff (list.decidable_bex (λt, l₁ <+: t) (tails l₂)) $\n  by refine (exists_congr (λt, _)).trans (infix_iff_prefix_suffix _ _).symm;\n     exact ⟨λ⟨h1, h2⟩, ⟨h2, (mem_tails _ _).1 h1⟩, λ⟨h2, h1⟩, ⟨(mem_tails _ _).2 h1, h2⟩⟩\n\n/-! ### sublists -/\n\n@[simp] theorem sublists'_nil : sublists' (@nil α) = [[]] := rfl\n\n@[simp, priority 1100] theorem sublists'_singleton (a : α) : sublists' [a] = [[], [a]] := rfl\n\ntheorem map_sublists'_aux (g : list β → list γ) (l : list α) (f r) :\n  map g (sublists'_aux l f r) = sublists'_aux l (g ∘ f) (map g r) :=\nby induction l generalizing f r; [refl, simp only [*, sublists'_aux]]\n\ntheorem sublists'_aux_append (r' : list (list β)) (l : list α) (f r) :\n  sublists'_aux l f (r ++ r') = sublists'_aux l f r ++ r' :=\nby induction l generalizing f r; [refl, simp only [*, sublists'_aux]]\n\ntheorem sublists'_aux_eq_sublists' (l f r) :\n  @sublists'_aux α β l f r = map f (sublists' l) ++ r :=\nby rw [sublists', map_sublists'_aux, ← sublists'_aux_append]; refl\n\n@[simp] theorem sublists'_cons (a : α) (l : list α) :\n  sublists' (a :: l) = sublists' l ++ map (cons a) (sublists' l) :=\nby rw [sublists', sublists'_aux]; simp only [sublists'_aux_eq_sublists', map_id, append_nil]; refl\n\n@[simp] theorem mem_sublists' {s t : list α} : s ∈ sublists' t ↔ s <+ t :=\nbegin\n  induction t with a t IH generalizing s,\n  { simp only [sublists'_nil, mem_singleton],\n    exact ⟨λ h, by rw h, eq_nil_of_sublist_nil⟩ },\n  simp only [sublists'_cons, mem_append, IH, mem_map],\n  split; intro h, rcases h with h | ⟨s, h, rfl⟩,\n  { exact sublist_cons_of_sublist _ h },\n  { exact cons_sublist_cons _ h },\n  { cases h with _ _ _ h s _ _ h,\n    { exact or.inl h },\n    { exact or.inr ⟨s, h, rfl⟩ } }\nend\n\n@[simp] theorem length_sublists' : ∀ l : list α, length (sublists' l) = 2 ^ length l\n| []     := rfl\n| (a::l) := by simp only [sublists'_cons, length_append, length_sublists' l, length_map,\n    length, pow_succ', mul_succ, mul_zero, zero_add]\n\n@[simp] theorem sublists_nil : sublists (@nil α) = [[]] := rfl\n\n@[simp] theorem sublists_singleton (a : α) : sublists [a] = [[], [a]] := rfl\n\ntheorem sublists_aux₁_eq_sublists_aux : ∀ l (f : list α → list β),\n  sublists_aux₁ l f = sublists_aux l (λ ys r, f ys ++ r)\n| []     f := rfl\n| (a::l) f := by rw [sublists_aux₁, sublists_aux]; simp only [*, append_assoc]\n\ntheorem sublists_aux_cons_eq_sublists_aux₁ (l : list α) :\n  sublists_aux l cons = sublists_aux₁ l (λ x, [x]) :=\nby rw [sublists_aux₁_eq_sublists_aux]; refl\n\ntheorem sublists_aux_eq_foldr.aux {a : α} {l : list α}\n  (IH₁ : ∀ (f : list α → list β → list β), sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (IH₂ : ∀ (f : list α → list (list α) → list (list α)),\n      sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (f : list α → list β → list β) : sublists_aux (a::l) f = foldr f [] (sublists_aux (a::l) cons) :=\nbegin\n  simp only [sublists_aux, foldr_cons], rw [IH₂, IH₁], congr' 1,\n  induction sublists_aux l cons with _ _ ih, {refl},\n  simp only [ih, foldr_cons]\nend\n\ntheorem sublists_aux_eq_foldr (l : list α) : ∀ (f : list α → list β → list β),\n  sublists_aux l f = foldr f [] (sublists_aux l cons) :=\nsuffices _ ∧ ∀ f : list α → list (list α) → list (list α),\n    sublists_aux l f = foldr f [] (sublists_aux l cons),\n  from this.1,\nbegin\n  induction l with a l IH, {split; intro; refl},\n  exact ⟨sublists_aux_eq_foldr.aux IH.1 IH.2,\n         sublists_aux_eq_foldr.aux IH.2 IH.2⟩\nend\n\ntheorem sublists_aux_cons_cons (l : list α) (a : α) :\n  sublists_aux (a::l) cons = [a] :: foldr (λys r, ys :: (a :: ys) :: r) [] (sublists_aux l cons) :=\nby rw [← sublists_aux_eq_foldr]; refl\n\ntheorem sublists_aux₁_append : ∀ (l₁ l₂ : list α) (f : list α → list β),\n  sublists_aux₁ (l₁ ++ l₂) f = sublists_aux₁ l₁ f ++\n    sublists_aux₁ l₂ (λ x, f x ++ sublists_aux₁ l₁ (f ∘ (++ x)))\n| []      l₂ f := by simp only [sublists_aux₁, nil_append, append_nil]\n| (a::l₁) l₂ f := by simp only [sublists_aux₁, cons_append, sublists_aux₁_append l₁, append_assoc];\n  refl\n\ntheorem sublists_aux₁_concat (l : list α) (a : α) (f : list α → list β) :\n  sublists_aux₁ (l ++ [a]) f = sublists_aux₁ l f ++\n    f [a] ++ sublists_aux₁ l (λ x, f (x ++ [a])) :=\nby simp only [sublists_aux₁_append, sublists_aux₁, append_assoc, append_nil]\n\ntheorem sublists_aux₁_bind : ∀ (l : list α)\n  (f : list α → list β) (g : β → list γ),\n  (sublists_aux₁ l f).bind g = sublists_aux₁ l (λ x, (f x).bind g)\n| []     f g := rfl\n| (a::l) f g := by simp only [sublists_aux₁, bind_append, sublists_aux₁_bind l]\n\ntheorem sublists_aux_cons_append (l₁ l₂ : list α) :\n  sublists_aux (l₁ ++ l₂) cons = sublists_aux l₁ cons ++\n    (do x ← sublists_aux l₂ cons, (++ x) <$> sublists l₁) :=\nbegin\n  simp only [sublists, sublists_aux_cons_eq_sublists_aux₁, sublists_aux₁_append, bind_eq_bind,\n    sublists_aux₁_bind],\n  congr, funext x, apply congr_arg _,\n  rw [← bind_ret_eq_map, sublists_aux₁_bind], exact (append_nil _).symm\nend\n\ntheorem sublists_append (l₁ l₂ : list α) :\n  sublists (l₁ ++ l₂) = (do x ← sublists l₂, (++ x) <$> sublists l₁) :=\nby simp only [map, sublists, sublists_aux_cons_append, map_eq_map, bind_eq_bind,\n  cons_bind, map_id', append_nil, cons_append, map_id' (λ _, rfl)]; split; refl\n\n@[simp] theorem sublists_concat (l : list α) (a : α) :\n  sublists (l ++ [a]) = sublists l ++ map (λ x, x ++ [a]) (sublists l) :=\nby rw [sublists_append, sublists_singleton, bind_eq_bind, cons_bind, cons_bind, nil_bind,\n  map_eq_map, map_eq_map, map_id' (append_nil), append_nil]\n\ntheorem sublists_reverse (l : list α) : sublists (reverse l) = map reverse (sublists' l) :=\nby induction l with hd tl ih; [refl,\nsimp only [reverse_cons, sublists_append, sublists'_cons, map_append, ih, sublists_singleton,\n  map_eq_map, bind_eq_bind, map_map, cons_bind, append_nil, nil_bind, (∘)]]\n\ntheorem sublists_eq_sublists' (l : list α) : sublists l = map reverse (sublists' (reverse l)) :=\nby rw [← sublists_reverse, reverse_reverse]\n\ntheorem sublists'_reverse (l : list α) : sublists' (reverse l) = map reverse (sublists l) :=\nby simp only [sublists_eq_sublists', map_map, map_id' (reverse_reverse)]\n\ntheorem sublists'_eq_sublists (l : list α) : sublists' l = map reverse (sublists (reverse l)) :=\nby rw [← sublists'_reverse, reverse_reverse]\n\ntheorem sublists_aux_ne_nil : ∀ (l : list α), [] ∉ sublists_aux l cons\n| [] := id\n| (a::l) := begin\n  rw [sublists_aux_cons_cons],\n  refine not_mem_cons_of_ne_of_not_mem (cons_ne_nil _ _).symm _,\n  have := sublists_aux_ne_nil l, revert this,\n  induction sublists_aux l cons; intro, {rwa foldr},\n  simp only [foldr, mem_cons_iff, false_or, not_or_distrib],\n  exact ⟨ne_of_not_mem_cons this, ih (not_mem_of_not_mem_cons this)⟩\nend\n\n@[simp] theorem mem_sublists {s t : list α} : s ∈ sublists t ↔ s <+ t :=\nby rw [← reverse_sublist_iff, ← mem_sublists',\n       sublists'_reverse, mem_map_of_injective reverse_injective]\n\n@[simp] theorem length_sublists (l : list α) : length (sublists l) = 2 ^ length l :=\nby simp only [sublists_eq_sublists', length_map, length_sublists', length_reverse]\n\ntheorem map_ret_sublist_sublists (l : list α) : map list.ret l <+ sublists l :=\nreverse_rec_on l (nil_sublist _) $\nλ l a IH, by simp only [map, map_append, sublists_concat]; exact\n((append_sublist_append_left _).2 $ singleton_sublist.2 $\n  mem_map.2 ⟨[], mem_sublists.2 (nil_sublist _), by refl⟩).trans\n((append_sublist_append_right _).2 IH)\n\n/-! ### sublists_len -/\n\n/-- Auxiliary function to construct the list of all sublists of a given length. Given an\ninteger `n`, a list `l`, a function `f` and an auxiliary list `L`, it returns the list made of\nof `f` applied to all sublists of `l` of length `n`, concatenated with `L`. -/\ndef sublists_len_aux {α β : Type*} : ℕ → list α → (list α → β) → list β → list β\n| 0     l      f r := f [] :: r\n| (n+1) []     f r := r\n| (n+1) (a::l) f r := sublists_len_aux (n + 1) l f\n  (sublists_len_aux n l (f ∘ list.cons a) r)\n\n/-- The list of all sublists of a list `l` that are of length `n`. For instance, for\n`l = [0, 1, 2, 3]` and `n = 2`, one gets\n`[[2, 3], [1, 3], [1, 2], [0, 3], [0, 2], [0, 1]]`. -/\ndef sublists_len {α : Type*} (n : ℕ) (l : list α) : list (list α) :=\nsublists_len_aux n l id []\n\nlemma sublists_len_aux_append {α β γ : Type*} :\n  ∀ (n : ℕ) (l : list α) (f : list α → β) (g : β → γ) (r : list β) (s : list γ),\n  sublists_len_aux n l (g ∘ f) (r.map g ++ s) =\n  (sublists_len_aux n l f r).map g ++ s\n| 0     l      f g r s := rfl\n| (n+1) []     f g r s := rfl\n| (n+1) (a::l) f g r s := begin\n  unfold sublists_len_aux,\n  rw [show ((g ∘ f) ∘ list.cons a) = (g ∘ f ∘ list.cons a), by refl,\n    sublists_len_aux_append, sublists_len_aux_append]\nend\n\nlemma sublists_len_aux_eq {α β : Type*} (l : list α) (n) (f : list α → β) (r) :\n  sublists_len_aux n l f r = (sublists_len n l).map f ++ r :=\nby rw [sublists_len, ← sublists_len_aux_append]; refl\n\nlemma sublists_len_aux_zero {α : Type*} (l : list α) (f : list α → β) (r) :\n  sublists_len_aux 0 l f r = f [] :: r := by cases l; refl\n\n@[simp] lemma sublists_len_zero {α : Type*} (l : list α) :\n  sublists_len 0 l = [[]] := sublists_len_aux_zero _ _ _\n\n@[simp] lemma sublists_len_succ_nil {α : Type*} (n) :\n  sublists_len (n+1) (@nil α) = [] := rfl\n\n@[simp] lemma sublists_len_succ_cons {α : Type*} (n) (a : α) (l) :\n  sublists_len (n + 1) (a::l) =\n  sublists_len (n + 1) l ++ (sublists_len n l).map (cons a) :=\nby rw [sublists_len, sublists_len_aux, sublists_len_aux_eq,\n  sublists_len_aux_eq, map_id, append_nil]; refl\n\n@[simp] lemma length_sublists_len {α : Type*} : ∀ n (l : list α),\n  length (sublists_len n l) = nat.choose (length l) n\n| 0     l      := by simp\n| (n+1) []     := by simp\n| (n+1) (a::l) := by simp [-add_comm, nat.choose, *]; apply add_comm\n\nlemma sublists_len_sublist_sublists' {α : Type*} : ∀ n (l : list α),\n  sublists_len n l <+ sublists' l\n| 0     l      := singleton_sublist.2 (mem_sublists'.2 (nil_sublist _))\n| (n+1) []     := nil_sublist _\n| (n+1) (a::l) := begin\n  rw [sublists_len_succ_cons, sublists'_cons],\n  exact (sublists_len_sublist_sublists' _ _).append\n    ((sublists_len_sublist_sublists' _ _).map _)\nend\n\nlemma sublists_len_sublist_of_sublist\n  {α : Type*} (n) {l₁ l₂ : list α} (h : l₁ <+ l₂) : sublists_len n l₁ <+ sublists_len n l₂ :=\nbegin\n  induction n with n IHn generalizing l₁ l₂, {simp},\n  induction h with l₁ l₂ a s IH l₁ l₂ a s IH, {refl},\n  { refine IH.trans _,\n    rw sublists_len_succ_cons,\n    apply sublist_append_left },\n  { simp [sublists_len_succ_cons],\n    exact IH.append ((IHn s).map _) }\nend\n\nlemma length_of_sublists_len {α : Type*} : ∀ {n} {l l' : list α},\n  l' ∈ sublists_len n l → length l' = n\n| 0     l      l' (or.inl rfl) := rfl\n| (n+1) (a::l) l' h := begin\n  rw [sublists_len_succ_cons, mem_append, mem_map] at h,\n  rcases h with h | ⟨l', h, rfl⟩,\n  { exact length_of_sublists_len h },\n  { exact congr_arg (+1) (length_of_sublists_len h) },\nend\n\nlemma mem_sublists_len_self {α : Type*} {l l' : list α}\n  (h : l' <+ l) : l' ∈ sublists_len (length l') l :=\nbegin\n  induction h with l₁ l₂ a s IH l₁ l₂ a s IH,\n  { exact or.inl rfl },\n  { cases l₁ with b l₁,\n    { exact or.inl rfl },\n    { rw [length, sublists_len_succ_cons],\n      exact mem_append_left _ IH } },\n  { rw [length, sublists_len_succ_cons],\n    exact mem_append_right _ (mem_map.2 ⟨_, IH, rfl⟩) }\nend\n\n@[simp] lemma mem_sublists_len {α : Type*} {n} {l l' : list α} :\n  l' ∈ sublists_len n l ↔ l' <+ l ∧ length l' = n :=\n⟨λ h, ⟨mem_sublists'.1\n    ((sublists_len_sublist_sublists' _ _).subset h),\n  length_of_sublists_len h⟩,\nλ ⟨h₁, h₂⟩, h₂ ▸ mem_sublists_len_self h₁⟩\n\n/-! ### permutations -/\n\nsection permutations\n\n@[simp] theorem permutations_aux_nil (is : list α) : permutations_aux [] is = [] :=\nby rw [permutations_aux, permutations_aux.rec]\n\n@[simp] theorem permutations_aux_cons (t : α) (ts is : list α) :\n  permutations_aux (t :: ts) is = foldr (λy r, (permutations_aux2 t ts r y id).2)\n    (permutations_aux ts (t::is)) (permutations is) :=\nby rw [permutations_aux, permutations_aux.rec]; refl\n\nend permutations\n\n/-! ### insert -/\nsection insert\nvariable [decidable_eq α]\n\n@[simp] theorem insert_nil (a : α) : insert a nil = [a] := rfl\n\ntheorem insert.def (a : α) (l : list α) : insert a l = if a ∈ l then l else a :: l := rfl\n\n@[simp, priority 980]\ntheorem insert_of_mem {a : α} {l : list α} (h : a ∈ l) : insert a l = l :=\nby simp only [insert.def, if_pos h]\n\n@[simp, priority 970]\ntheorem insert_of_not_mem {a : α} {l : list α} (h : a ∉ l) : insert a l = a :: l :=\nby simp only [insert.def, if_neg h]; split; refl\n\n@[simp] theorem mem_insert_iff {a b : α} {l : list α} : a ∈ insert b l ↔ a = b ∨ a ∈ l :=\nbegin\n  by_cases h' : b ∈ l,\n  { simp only [insert_of_mem h'],\n    apply (or_iff_right_of_imp _).symm,\n    exact λ e, e.symm ▸ h' },\n  simp only [insert_of_not_mem h', mem_cons_iff]\nend\n\n@[simp] theorem suffix_insert (a : α) (l : list α) : l <:+ insert a l :=\nby by_cases a ∈ l; [simp only [insert_of_mem h], simp only [insert_of_not_mem h, suffix_cons]]\n\n@[simp] theorem mem_insert_self (a : α) (l : list α) : a ∈ insert a l :=\nmem_insert_iff.2 (or.inl rfl)\n\ntheorem mem_insert_of_mem {a b : α} {l : list α} (h : a ∈ l) : a ∈ insert b l :=\nmem_insert_iff.2 (or.inr h)\n\ntheorem eq_or_mem_of_mem_insert {a b : α} {l : list α} (h : a ∈ insert b l) : a = b ∨ a ∈ l :=\nmem_insert_iff.1 h\n\n@[simp] theorem length_insert_of_mem {a : α} {l : list α} (h : a ∈ l) :\n  length (insert a l) = length l :=\nby rw insert_of_mem h\n\n@[simp] theorem length_insert_of_not_mem {a : α} {l : list α} (h : a ∉ l) :\n  length (insert a l) = length l + 1 :=\nby rw insert_of_not_mem h; refl\n\nend insert\n\n/-! ### erasep -/\nsection erasep\nvariables {p : α → Prop} [decidable_pred p]\n\n@[simp] theorem erasep_nil : [].erasep p = [] := rfl\n\ntheorem erasep_cons (a : α) (l : list α) :\n  (a :: l).erasep p = if p a then l else a :: l.erasep p := rfl\n\n@[simp] theorem erasep_cons_of_pos {a : α} {l : list α} (h : p a) : (a :: l).erasep p = l :=\nby simp [erasep_cons, h]\n\n@[simp] theorem erasep_cons_of_neg {a : α} {l : list α} (h : ¬ p a) :\n  (a::l).erasep p = a :: l.erasep p :=\nby simp [erasep_cons, h]\n\ntheorem erasep_of_forall_not {l : list α}\n  (h : ∀ a ∈ l, ¬ p a) : l.erasep p = l :=\nby induction l with _ _ ih; [refl,\n  simp [h _ (or.inl rfl), ih (forall_mem_of_forall_mem_cons h)]]\n\ntheorem exists_of_erasep {l : list α} {a} (al : a ∈ l) (pa : p a) :\n  ∃ a l₁ l₂, (∀ b ∈ l₁, ¬ p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.erasep p = l₁ ++ l₂ :=\nbegin\n  induction l with b l IH, {cases al},\n  by_cases pb : p b,\n  { exact ⟨b, [], l, forall_mem_nil _, pb, by simp [pb]⟩ },\n  { rcases al with rfl | al, {exact pb.elim pa},\n    rcases IH al with ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩,\n    exact ⟨c, b::l₁, l₂, forall_mem_cons.2 ⟨pb, h₁⟩,\n      h₂, by rw h₃; refl, by simp [pb, h₄]⟩ }\nend\n\ntheorem exists_or_eq_self_of_erasep (p : α → Prop) [decidable_pred p] (l : list α) :\n  l.erasep p = l ∨ ∃ a l₁ l₂, (∀ b ∈ l₁, ¬ p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.erasep p = l₁ ++ l₂ :=\nbegin\n  by_cases h : ∃ a ∈ l, p a,\n  { rcases h with ⟨a, ha, pa⟩,\n    exact or.inr (exists_of_erasep ha pa) },\n  { simp at h, exact or.inl (erasep_of_forall_not h) }\nend\n\n@[simp] theorem length_erasep_of_mem {l : list α} {a} (al : a ∈ l) (pa : p a) :\n length (l.erasep p) = pred (length l) :=\nby rcases exists_of_erasep al pa with ⟨_, l₁, l₂, _, _, e₁, e₂⟩;\n   rw e₂; simp [-add_comm, e₁]; refl\n\ntheorem erasep_append_left {a : α} (pa : p a) :\n  ∀ {l₁ : list α} (l₂), a ∈ l₁ → (l₁++l₂).erasep p = l₁.erasep p ++ l₂\n| (x::xs) l₂ h := begin\n  by_cases h' : p x; simp [h'],\n  rw erasep_append_left l₂ (mem_of_ne_of_mem (mt _ h') h),\n  rintro rfl, exact pa\nend\n\ntheorem erasep_append_right :\n  ∀ {l₁ : list α} (l₂), (∀ b ∈ l₁, ¬ p b) → (l₁++l₂).erasep p = l₁ ++ l₂.erasep p\n| []      l₂ h := rfl\n| (x::xs) l₂ h := by simp [(forall_mem_cons.1 h).1,\n  erasep_append_right _ (forall_mem_cons.1 h).2]\n\ntheorem erasep_sublist (l : list α) : l.erasep p <+ l :=\nby rcases exists_or_eq_self_of_erasep p l with h | ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩;\n   [rw h, {rw [h₄, h₃], simp}]\n\ntheorem erasep_subset (l : list α) : l.erasep p ⊆ l :=\n(erasep_sublist l).subset\n\ntheorem sublist.erasep {l₁ l₂ : list α} (s : l₁ <+ l₂) : l₁.erasep p <+ l₂.erasep p :=\nbegin\n  induction s,\n  case list.sublist.slnil { refl },\n  case list.sublist.cons : l₁ l₂ a s IH {\n    by_cases h : p a; simp [h],\n    exacts [IH.trans (erasep_sublist _), IH.cons _ _ _] },\n  case list.sublist.cons2 : l₁ l₂ a s IH {\n    by_cases h : p a; simp [h],\n    exacts [s, IH.cons2 _ _ _] }\nend\n\ntheorem mem_of_mem_erasep {a : α} {l : list α} : a ∈ l.erasep p → a ∈ l :=\n@erasep_subset _ _ _ _ _\n\n@[simp] theorem mem_erasep_of_neg {a : α} {l : list α} (pa : ¬ p a) : a ∈ l.erasep p ↔ a ∈ l :=\n⟨mem_of_mem_erasep, λ al, begin\n  rcases exists_or_eq_self_of_erasep p l with h | ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩,\n  { rwa h },\n  { rw h₄, rw h₃ at al,\n    have : a ≠ c, {rintro rfl, exact pa.elim h₂},\n    simpa [this] using al }\nend⟩\n\ntheorem erasep_map (f : β → α) :\n  ∀ (l : list β), (map f l).erasep p = map f (l.erasep (p ∘ f))\n| []     := rfl\n| (b::l) := by by_cases p (f b); simp [h, erasep_map l]\n\n@[simp] theorem extractp_eq_find_erasep :\n  ∀ l : list α, extractp p l = (find p l, erasep p l)\n| []     := rfl\n| (a::l) := by by_cases pa : p a; simp [extractp, pa, extractp_eq_find_erasep l]\n\nend erasep\n\n/-! ### erase -/\nsection erase\nvariable [decidable_eq α]\n\n@[simp] theorem erase_nil (a : α) : [].erase a = [] := rfl\n\ntheorem erase_cons (a b : α) (l : list α) :\n  (b :: l).erase a = if b = a then l else b :: l.erase a := rfl\n\n@[simp] theorem erase_cons_head (a : α) (l : list α) : (a :: l).erase a = l :=\nby simp only [erase_cons, if_pos rfl]\n\n@[simp] theorem erase_cons_tail {a b : α} (l : list α) (h : b ≠ a) :\n  (b::l).erase a = b :: l.erase a :=\nby simp only [erase_cons, if_neg h]; split; refl\n\ntheorem erase_eq_erasep (a : α) (l : list α) : l.erase a = l.erasep (eq a) :=\nby { induction l with b l, {refl},\n  by_cases a = b; [simp [h], simp [h, ne.symm h, *]] }\n\n@[simp, priority 980]\ntheorem erase_of_not_mem {a : α} {l : list α} (h : a ∉ l) : l.erase a = l :=\nby rw [erase_eq_erasep, erasep_of_forall_not]; rintro b h' rfl; exact h h'\n\ntheorem exists_erase_eq {a : α} {l : list α} (h : a ∈ l) :\n  ∃ l₁ l₂, a ∉ l₁ ∧ l = l₁ ++ a :: l₂ ∧ l.erase a = l₁ ++ l₂ :=\nby rcases exists_of_erasep h rfl with ⟨_, l₁, l₂, h₁, rfl, h₂, h₃⟩;\n   rw erase_eq_erasep; exact ⟨l₁, l₂, λ h, h₁ _ h rfl, h₂, h₃⟩\n\n@[simp] theorem length_erase_of_mem {a : α} {l : list α} (h : a ∈ l) :\n  length (l.erase a) = pred (length l) :=\nby rw erase_eq_erasep; exact length_erasep_of_mem h rfl\n\ntheorem erase_append_left {a : α} {l₁ : list α} (l₂) (h : a ∈ l₁) :\n  (l₁++l₂).erase a = l₁.erase a ++ l₂ :=\nby simp [erase_eq_erasep]; exact erasep_append_left (by refl) l₂ h\n\ntheorem erase_append_right {a : α} {l₁ : list α} (l₂) (h : a ∉ l₁) :\n  (l₁++l₂).erase a = l₁ ++ l₂.erase a :=\nby rw [erase_eq_erasep, erase_eq_erasep, erasep_append_right];\n   rintro b h' rfl; exact h h'\n\ntheorem erase_sublist (a : α) (l : list α) : l.erase a <+ l :=\nby rw erase_eq_erasep; apply erasep_sublist\n\ntheorem erase_subset (a : α) (l : list α) : l.erase a ⊆ l :=\n(erase_sublist a l).subset\n\ntheorem sublist.erase (a : α) {l₁ l₂ : list α} (h : l₁ <+ l₂) : l₁.erase a <+ l₂.erase a :=\nby simp [erase_eq_erasep]; exact sublist.erasep h\n\ntheorem mem_of_mem_erase {a b : α} {l : list α} : a ∈ l.erase b → a ∈ l :=\n@erase_subset _ _ _ _ _\n\n@[simp] theorem mem_erase_of_ne {a b : α} {l : list α} (ab : a ≠ b) : a ∈ l.erase b ↔ a ∈ l :=\nby rw erase_eq_erasep; exact mem_erasep_of_neg ab.symm\n\ntheorem erase_comm (a b : α) (l : list α) : (l.erase a).erase b = (l.erase b).erase a :=\nif ab : a = b then by rw ab else\nif ha : a ∈ l then\nif hb : b ∈ l then match l, l.erase a, exists_erase_eq ha, hb with\n| ._, ._, ⟨l₁, l₂, ha', rfl, rfl⟩, hb :=\n  if h₁ : b ∈ l₁ then\n    by rw [erase_append_left _ h₁, erase_append_left _ h₁,\n           erase_append_right _ (mt mem_of_mem_erase ha'), erase_cons_head]\n  else\n    by rw [erase_append_right _ h₁, erase_append_right _ h₁, erase_append_right _ ha',\n           erase_cons_tail _ ab, erase_cons_head]\nend\nelse by simp only [erase_of_not_mem hb, erase_of_not_mem (mt mem_of_mem_erase hb)]\nelse by simp only [erase_of_not_mem ha, erase_of_not_mem (mt mem_of_mem_erase ha)]\n\ntheorem map_erase [decidable_eq β] {f : α → β} (finj : injective f) {a : α}\n  (l : list α) : map f (l.erase a) = (map f l).erase (f a) :=\nby rw [erase_eq_erasep, erase_eq_erasep, erasep_map]; congr;\n   ext b; simp [finj.eq_iff]\n\ntheorem map_foldl_erase [decidable_eq β] {f : α → β} (finj : injective f) {l₁ l₂ : list α} :\n  map f (foldl list.erase l₁ l₂) = foldl (λ l a, l.erase (f a)) (map f l₁) l₂ :=\nby induction l₂ generalizing l₁; [refl,\nsimp only [foldl_cons, map_erase finj, *]]\n\n@[simp] theorem count_erase_self (a : α) :\n  ∀ (s : list α), count a (list.erase s a) = pred (count a s)\n| [] := by simp\n| (h :: t) :=\nbegin\n  rw erase_cons,\n  by_cases p : h = a,\n  { rw [if_pos p, count_cons', if_pos p.symm], simp },\n  { rw [if_neg p, count_cons', count_cons', if_neg (λ x : a = h, p x.symm), count_erase_self],\n    simp, }\nend\n\n@[simp] theorem count_erase_of_ne {a b : α} (ab : a ≠ b) :\n  ∀ (s : list α), count a (list.erase s b) = count a s\n| [] := by simp\n| (x :: xs) :=\nbegin\n  rw erase_cons,\n  split_ifs with h,\n  { rw [count_cons', h, if_neg ab], simp },\n  { rw [count_cons', count_cons', count_erase_of_ne] }\nend\n\nend erase\n\n/-! ### diff -/\nsection diff\nvariable [decidable_eq α]\n\n@[simp] theorem diff_nil (l : list α) : l.diff [] = l := rfl\n\n@[simp] theorem diff_cons (l₁ l₂ : list α) (a : α) : l₁.diff (a::l₂) = (l₁.erase a).diff l₂ :=\nif h : a ∈ l₁ then by simp only [list.diff, if_pos h]\nelse by simp only [list.diff, if_neg h, erase_of_not_mem h]\n\nlemma diff_cons_right (l₁ l₂ : list α) (a : α) : l₁.diff (a::l₂) = (l₁.diff l₂).erase a :=\nbegin\n  induction l₂ with b l₂ ih generalizing l₁ a,\n  { simp_rw [diff_cons, diff_nil] },\n  { rw [diff_cons, diff_cons, erase_comm, ← diff_cons, ih, ← diff_cons] }\nend\n\nlemma diff_erase (l₁ l₂ : list α) (a : α) : (l₁.diff l₂).erase a = (l₁.erase a).diff l₂ :=\nby rw [← diff_cons_right, diff_cons]\n\n@[simp] theorem nil_diff (l : list α) : [].diff l = [] :=\nby induction l; [refl, simp only [*, diff_cons, erase_of_not_mem (not_mem_nil _)]]\n\ntheorem diff_eq_foldl : ∀ (l₁ l₂ : list α), l₁.diff l₂ = foldl list.erase l₁ l₂\n| l₁ []      := rfl\n| l₁ (a::l₂) := (diff_cons l₁ l₂ a).trans (diff_eq_foldl _ _)\n\n@[simp] theorem diff_append (l₁ l₂ l₃ : list α) : l₁.diff (l₂ ++ l₃) = (l₁.diff l₂).diff l₃ :=\nby simp only [diff_eq_foldl, foldl_append]\n\n@[simp] theorem map_diff [decidable_eq β] {f : α → β} (finj : injective f) {l₁ l₂ : list α} :\n  map f (l₁.diff l₂) = (map f l₁).diff (map f l₂) :=\nby simp only [diff_eq_foldl, foldl_map, map_foldl_erase finj]\n\ntheorem diff_sublist : ∀ l₁ l₂ : list α, l₁.diff l₂ <+ l₁\n| l₁ []      := sublist.refl _\n| l₁ (a::l₂) := calc l₁.diff (a :: l₂) = (l₁.erase a).diff l₂ : diff_cons _ _ _\n  ... <+ l₁.erase a : diff_sublist _ _\n  ... <+ l₁ : list.erase_sublist _ _\n\ntheorem diff_subset (l₁ l₂ : list α) : l₁.diff l₂ ⊆ l₁ :=\n(diff_sublist _ _).subset\n\ntheorem mem_diff_of_mem {a : α} : ∀ {l₁ l₂ : list α}, a ∈ l₁ → a ∉ l₂ → a ∈ l₁.diff l₂\n| l₁ []      h₁ h₂ := h₁\n| l₁ (b::l₂) h₁ h₂ := by rw diff_cons; exact\n  mem_diff_of_mem ((mem_erase_of_ne (ne_of_not_mem_cons h₂)).2 h₁) (not_mem_of_not_mem_cons h₂)\n\ntheorem sublist.diff_right : ∀ {l₁ l₂ l₃: list α}, l₁ <+ l₂ → l₁.diff l₃ <+ l₂.diff l₃\n| l₁ l₂ [] h      := h\n| l₁ l₂ (a::l₃) h := by simp only\n  [diff_cons, (h.erase _).diff_right]\n\ntheorem erase_diff_erase_sublist_of_sublist {a : α} : ∀ {l₁ l₂ : list α},\n  l₁ <+ l₂ → (l₂.erase a).diff (l₁.erase a) <+ l₂.diff l₁\n| []      l₂ h := erase_sublist _ _\n| (b::l₁) l₂ h := if heq : b = a then by simp only [heq, erase_cons_head, diff_cons]\n                  else by simpa only [erase_cons_head, erase_cons_tail _ heq, diff_cons,\n                    erase_comm a b l₂]\n                  using erase_diff_erase_sublist_of_sublist (h.erase b)\n\nend diff\n\n/-! ### enum -/\n\ntheorem length_enum_from : ∀ n (l : list α), length (enum_from n l) = length l\n| n []     := rfl\n| n (a::l) := congr_arg nat.succ (length_enum_from _ _)\n\ntheorem length_enum : ∀ (l : list α), length (enum l) = length l := length_enum_from _\n\n@[simp] theorem enum_from_nth : ∀ n (l : list α) m,\n  nth (enum_from n l) m = (λ a, (n + m, a)) <$> nth l m\n| n []       m     := rfl\n| n (a :: l) 0     := rfl\n| n (a :: l) (m+1) := (enum_from_nth (n+1) l m).trans $\n  by rw [add_right_comm]; refl\n\n@[simp] theorem enum_nth : ∀ (l : list α) n,\n  nth (enum l) n = (λ a, (n, a)) <$> nth l n :=\nby simp only [enum, enum_from_nth, zero_add]; intros; refl\n\n@[simp] theorem enum_from_map_snd : ∀ n (l : list α),\n  map prod.snd (enum_from n l) = l\n| n []       := rfl\n| n (a :: l) := congr_arg (cons _) (enum_from_map_snd _ _)\n\n@[simp] theorem enum_map_snd : ∀ (l : list α),\n  map prod.snd (enum l) = l := enum_from_map_snd _\n\ntheorem mem_enum_from {x : α} {i : ℕ} :\n   ∀ {j : ℕ} (xs : list α), (i, x) ∈ xs.enum_from j → j ≤ i ∧ i < j + xs.length ∧ x ∈ xs\n| j [] := by simp [enum_from]\n| j (y :: ys) :=\nsuffices i = j ∧ x = y ∨ (i, x) ∈ enum_from (j + 1) ys →\n    j ≤ i ∧ i < j + (length ys + 1) ∧ (x = y ∨ x ∈ ys),\n  by simpa [enum_from, mem_enum_from ys],\nbegin\n  rintro (h|h),\n  { refine ⟨le_of_eq h.1.symm,h.1 ▸ _,or.inl h.2⟩,\n    apply nat.lt_add_of_pos_right; simp },\n  { obtain ⟨hji, hijlen, hmem⟩ := mem_enum_from _ h,\n    refine ⟨_, _, _⟩,\n    { exact le_trans (nat.le_succ _) hji },\n    { convert hijlen using 1, ac_refl },\n    { simp [hmem] } }\nend\n\n/-! ### product -/\n\n@[simp] theorem nil_product (l : list β) : product (@nil α) l = [] := rfl\n\n@[simp] theorem product_cons (a : α) (l₁ : list α) (l₂ : list β)\n        : product (a::l₁) l₂ = map (λ b, (a, b)) l₂ ++ product l₁ l₂ := rfl\n\n@[simp] theorem product_nil : ∀ (l : list α), product l (@nil β) = []\n| []     := rfl\n| (a::l) := by rw [product_cons, product_nil]; refl\n\n@[simp] theorem mem_product {l₁ : list α} {l₂ : list β} {a : α} {b : β} :\n  (a, b) ∈ product l₁ l₂ ↔ a ∈ l₁ ∧ b ∈ l₂ :=\nby simp only [product, mem_bind, mem_map, prod.ext_iff, exists_prop,\n  and.left_comm, exists_and_distrib_left, exists_eq_left, exists_eq_right]\n\ntheorem length_product (l₁ : list α) (l₂ : list β) :\n  length (product l₁ l₂) = length l₁ * length l₂ :=\nby induction l₁ with x l₁ IH; [exact (zero_mul _).symm,\n  simp only [length, product_cons, length_append, IH,\n    right_distrib, one_mul, length_map, add_comm]]\n\n\n/-! ### sigma -/\nsection\nvariable {σ : α → Type*}\n\n@[simp] theorem nil_sigma (l : Π a, list (σ a)) : (@nil α).sigma l = [] := rfl\n\n@[simp] theorem sigma_cons (a : α) (l₁ : list α) (l₂ : Π a, list (σ a))\n        : (a::l₁).sigma l₂ = map (sigma.mk a) (l₂ a) ++ l₁.sigma l₂ := rfl\n\n@[simp] theorem sigma_nil : ∀ (l : list α), l.sigma (λ a, @nil (σ a)) = []\n| []     := rfl\n| (a::l) := by rw [sigma_cons, sigma_nil]; refl\n\n@[simp] theorem mem_sigma {l₁ : list α} {l₂ : Π a, list (σ a)} {a : α} {b : σ a} :\n  sigma.mk a b ∈ l₁.sigma l₂ ↔ a ∈ l₁ ∧ b ∈ l₂ a :=\nby simp only [list.sigma, mem_bind, mem_map, exists_prop, exists_and_distrib_left,\n  and.left_comm, exists_eq_left, heq_iff_eq, exists_eq_right]\n\ntheorem length_sigma (l₁ : list α) (l₂ : Π a, list (σ a)) :\n  length (l₁.sigma l₂) = (l₁.map (λ a, length (l₂ a))).sum :=\nby induction l₁ with x l₁ IH; [refl,\nsimp only [map, sigma_cons, length_append, length_map, IH, sum_cons]]\nend\n\n/-! ### disjoint -/\nsection disjoint\n\ntheorem disjoint.symm {l₁ l₂ : list α} (d : disjoint l₁ l₂) : disjoint l₂ l₁\n| a i₂ i₁ := d i₁ i₂\n\ntheorem disjoint_comm {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ disjoint l₂ l₁ :=\n⟨disjoint.symm, disjoint.symm⟩\n\ntheorem disjoint_left {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ ∀ {a}, a ∈ l₁ → a ∉ l₂ := iff.rfl\n\ntheorem disjoint_right {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ ∀ {a}, a ∈ l₂ → a ∉ l₁ :=\ndisjoint_comm\n\ntheorem disjoint_iff_ne {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ ∀ a ∈ l₁, ∀ b ∈ l₂, a ≠ b :=\nby simp only [disjoint_left, imp_not_comm, forall_eq']\n\ntheorem disjoint_of_subset_left {l₁ l₂ l : list α} (ss : l₁ ⊆ l) (d : disjoint l l₂) :\n  disjoint l₁ l₂\n| x m₁ := d (ss m₁)\n\ntheorem disjoint_of_subset_right {l₁ l₂ l : list α} (ss : l₂ ⊆ l) (d : disjoint l₁ l) :\n  disjoint l₁ l₂\n| x m m₁ := d m (ss m₁)\n\ntheorem disjoint_of_disjoint_cons_left {a : α} {l₁ l₂} : disjoint (a::l₁) l₂ → disjoint l₁ l₂ :=\ndisjoint_of_subset_left (list.subset_cons _ _)\n\ntheorem disjoint_of_disjoint_cons_right {a : α} {l₁ l₂} : disjoint l₁ (a::l₂) → disjoint l₁ l₂ :=\ndisjoint_of_subset_right (list.subset_cons _ _)\n\n@[simp] theorem disjoint_nil_left (l : list α) : disjoint [] l\n| a := (not_mem_nil a).elim\n\n@[simp] theorem disjoint_nil_right (l : list α) : disjoint l [] :=\nby rw disjoint_comm; exact disjoint_nil_left _\n\n@[simp, priority 1100] theorem singleton_disjoint {l : list α} {a : α} : disjoint [a] l ↔ a ∉ l :=\nby simp only [disjoint, mem_singleton, forall_eq]; refl\n\n@[simp, priority 1100] theorem disjoint_singleton {l : list α} {a : α} : disjoint l [a] ↔ a ∉ l :=\nby rw disjoint_comm; simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_append_left {l₁ l₂ l : list α} :\n  disjoint (l₁++l₂) l ↔ disjoint l₁ l ∧ disjoint l₂ l :=\nby simp only [disjoint, mem_append, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_append_right {l₁ l₂ l : list α} :\n  disjoint l (l₁++l₂) ↔ disjoint l l₁ ∧ disjoint l l₂ :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_append_left]\n\n@[simp] theorem disjoint_cons_left {a : α} {l₁ l₂ : list α} :\n  disjoint (a::l₁) l₂ ↔ a ∉ l₂ ∧ disjoint l₁ l₂ :=\n(@disjoint_append_left _ [a] l₁ l₂).trans $ by simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_cons_right {a : α} {l₁ l₂ : list α} :\n  disjoint l₁ (a::l₂) ↔ a ∉ l₁ ∧ disjoint l₁ l₂ :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_cons_left]\n\ntheorem disjoint_of_disjoint_append_left_left {l₁ l₂ l : list α} (d : disjoint (l₁++l₂) l) :\n  disjoint l₁ l :=\n(disjoint_append_left.1 d).1\n\ntheorem disjoint_of_disjoint_append_left_right {l₁ l₂ l : list α} (d : disjoint (l₁++l₂) l) :\n  disjoint l₂ l :=\n(disjoint_append_left.1 d).2\n\ntheorem disjoint_of_disjoint_append_right_left {l₁ l₂ l : list α} (d : disjoint l (l₁++l₂)) :\n  disjoint l l₁ :=\n(disjoint_append_right.1 d).1\n\ntheorem disjoint_of_disjoint_append_right_right {l₁ l₂ l : list α} (d : disjoint l (l₁++l₂)) :\n  disjoint l l₂ :=\n(disjoint_append_right.1 d).2\n\ntheorem disjoint_take_drop {l : list α} {m n : ℕ} (hl : l.nodup) (h : m ≤ n) :\n  disjoint (l.take m) (l.drop n) :=\nbegin\n  induction l generalizing m n,\n  case list.nil : m n\n  { simp },\n  case list.cons : x xs xs_ih m n\n  { cases m; cases n; simp only [disjoint_cons_left, mem_cons_iff, disjoint_cons_right, drop,\n                                 true_or, eq_self_iff_true, not_true, false_and,\n                                 disjoint_nil_left, take],\n    { cases h },\n    cases hl with _ _ h₀ h₁, split,\n    { intro h, exact h₀ _ (mem_of_mem_drop h) rfl, },\n    solve_by_elim [le_of_succ_le_succ] { max_depth := 4 } },\nend\n\nend disjoint\n\n/-! ### union -/\nsection union\nvariable [decidable_eq α]\n\n@[simp] theorem nil_union (l : list α) : [] ∪ l = l := rfl\n\n@[simp] theorem cons_union (l₁ l₂ : list α) (a : α) : a :: l₁ ∪ l₂ = insert a (l₁ ∪ l₂) := rfl\n\n@[simp] theorem mem_union {l₁ l₂ : list α} {a : α} : a ∈ l₁ ∪ l₂ ↔ a ∈ l₁ ∨ a ∈ l₂ :=\nby induction l₁; simp only [nil_union, not_mem_nil, false_or, cons_union, mem_insert_iff,\n  mem_cons_iff, or_assoc, *]\n\ntheorem mem_union_left {a : α} {l₁ : list α} (h : a ∈ l₁) (l₂ : list α) : a ∈ l₁ ∪ l₂ :=\nmem_union.2 (or.inl h)\n\ntheorem mem_union_right {a : α} (l₁ : list α) {l₂ : list α} (h : a ∈ l₂) : a ∈ l₁ ∪ l₂ :=\nmem_union.2 (or.inr h)\n\ntheorem sublist_suffix_of_union : ∀ l₁ l₂ : list α, ∃ t, t <+ l₁ ∧ t ++ l₂ = l₁ ∪ l₂\n| [] l₂ := ⟨[], by refl, rfl⟩\n| (a::l₁) l₂ := let ⟨t, s, e⟩ := sublist_suffix_of_union l₁ l₂ in\n  if h : a ∈ l₁ ∪ l₂\n  then ⟨t, sublist_cons_of_sublist _ s, by simp only [e, cons_union, insert_of_mem h]⟩\n  else ⟨a::t, cons_sublist_cons _ s, by simp only [cons_append, cons_union, e, insert_of_not_mem h];\n    split; refl⟩\n\ntheorem suffix_union_right (l₁ l₂ : list α) : l₂ <:+ l₁ ∪ l₂ :=\n(sublist_suffix_of_union l₁ l₂).imp (λ a, and.right)\n\ntheorem union_sublist_append (l₁ l₂ : list α) : l₁ ∪ l₂ <+ l₁ ++ l₂ :=\nlet ⟨t, s, e⟩ := sublist_suffix_of_union l₁ l₂ in\ne ▸ (append_sublist_append_right _).2 s\n\ntheorem forall_mem_union {p : α → Prop} {l₁ l₂ : list α} :\n  (∀ x ∈ l₁ ∪ l₂, p x) ↔ (∀ x ∈ l₁, p x) ∧ (∀ x ∈ l₂, p x) :=\nby simp only [mem_union, or_imp_distrib, forall_and_distrib]\n\ntheorem forall_mem_of_forall_mem_union_left {p : α → Prop} {l₁ l₂ : list α}\n   (h : ∀ x ∈ l₁ ∪ l₂, p x) : ∀ x ∈ l₁, p x :=\n(forall_mem_union.1 h).1\n\ntheorem forall_mem_of_forall_mem_union_right {p : α → Prop} {l₁ l₂ : list α}\n   (h : ∀ x ∈ l₁ ∪ l₂, p x) : ∀ x ∈ l₂, p x :=\n(forall_mem_union.1 h).2\n\nend union\n\n/-! ### inter -/\nsection inter\nvariable [decidable_eq α]\n\n@[simp] theorem inter_nil (l : list α) : [] ∩ l = [] := rfl\n\n@[simp] theorem inter_cons_of_mem {a : α} (l₁ : list α) {l₂ : list α} (h : a ∈ l₂) :\n  (a::l₁) ∩ l₂ = a :: (l₁ ∩ l₂) :=\nif_pos h\n\n@[simp] theorem inter_cons_of_not_mem {a : α} (l₁ : list α) {l₂ : list α} (h : a ∉ l₂) :\n  (a::l₁) ∩ l₂ = l₁ ∩ l₂ :=\nif_neg h\n\ntheorem mem_of_mem_inter_left {l₁ l₂ : list α} {a : α} : a ∈ l₁ ∩ l₂ → a ∈ l₁ :=\nmem_of_mem_filter\n\ntheorem mem_of_mem_inter_right {l₁ l₂ : list α} {a : α} : a ∈ l₁ ∩ l₂ → a ∈ l₂ :=\nof_mem_filter\n\ntheorem mem_inter_of_mem_of_mem {l₁ l₂ : list α} {a : α} : a ∈ l₁ → a ∈ l₂ → a ∈ l₁ ∩ l₂ :=\nmem_filter_of_mem\n\n@[simp] theorem mem_inter {a : α} {l₁ l₂ : list α} : a ∈ l₁ ∩ l₂ ↔ a ∈ l₁ ∧ a ∈ l₂ :=\nmem_filter\n\ntheorem inter_subset_left (l₁ l₂ : list α) : l₁ ∩ l₂ ⊆ l₁ :=\nfilter_subset _\n\ntheorem inter_subset_right (l₁ l₂ : list α) : l₁ ∩ l₂ ⊆ l₂ :=\nλ a, mem_of_mem_inter_right\n\ntheorem subset_inter {l l₁ l₂ : list α} (h₁ : l ⊆ l₁) (h₂ : l ⊆ l₂) : l ⊆ l₁ ∩ l₂ :=\nλ a h, mem_inter.2 ⟨h₁ h, h₂ h⟩\n\ntheorem inter_eq_nil_iff_disjoint {l₁ l₂ : list α} : l₁ ∩ l₂ = [] ↔ disjoint l₁ l₂ :=\nby simp only [eq_nil_iff_forall_not_mem, mem_inter, not_and]; refl\n\ntheorem forall_mem_inter_of_forall_left {p : α → Prop} {l₁ : list α} (h : ∀ x ∈ l₁, p x)\n     (l₂ : list α) :\n  ∀ x, x ∈ l₁ ∩ l₂ → p x :=\nball.imp_left (λ x, mem_of_mem_inter_left) h\n\ntheorem forall_mem_inter_of_forall_right {p : α → Prop} (l₁ : list α) {l₂ : list α}\n    (h : ∀ x ∈ l₂, p x) :\n  ∀ x, x ∈ l₁ ∩ l₂ → p x :=\nball.imp_left (λ x, mem_of_mem_inter_right) h\n\n@[simp] lemma inter_reverse {xs ys : list α} :\n  xs.inter ys.reverse = xs.inter ys :=\nby simp only [list.inter, mem_reverse]; congr\n\nend inter\n\nsection choose\nvariables (p : α → Prop) [decidable_pred p] (l : list α)\n\nlemma choose_spec (hp : ∃ a, a ∈ l ∧ p a) : choose p l hp ∈ l ∧ p (choose p l hp) :=\n(choose_x p l hp).property\n\nlemma choose_mem (hp : ∃ a, a ∈ l ∧ p a) : choose p l hp ∈ l := (choose_spec _ _ _).1\n\nlemma choose_property (hp : ∃ a, a ∈ l ∧ p a) : p (choose p l hp) := (choose_spec _ _ _).2\n\nend choose\n\n/-! ### map₂_left' -/\n\nsection map₂_left'\n\n-- The definitional equalities for `map₂_left'` can already be used by the\n-- simplifie because `map₂_left'` is marked `@[simp]`.\n\n@[simp] theorem map₂_left'_nil_right (f : α → option β → γ) (as) :\n  map₂_left' f as [] = (as.map (λ a, f a none), []) :=\nby cases as; refl\n\nend map₂_left'\n\n/-! ### map₂_right' -/\n\nsection map₂_right'\n\nvariables (f : option α → β → γ) (a : α) (as : list α) (b : β) (bs : list β)\n\n@[simp] theorem map₂_right'_nil_left :\n  map₂_right' f [] bs = (bs.map (f none), []) :=\nby cases bs; refl\n\n@[simp] theorem map₂_right'_nil_right  :\n  map₂_right' f as [] = ([], as) :=\nrfl\n\n@[simp] theorem map₂_right'_nil_cons :\n  map₂_right' f [] (b :: bs) = (f none b :: bs.map (f none), []) :=\nrfl\n\n@[simp] theorem map₂_right'_cons_cons :\n  map₂_right' f (a :: as) (b :: bs) =\n    let rec := map₂_right' f as bs in\n    (f (some a) b :: rec.fst, rec.snd) :=\nrfl\n\nend map₂_right'\n\n/-! ### zip_left' -/\n\nsection zip_left'\n\nvariables (a : α) (as : list α) (b : β) (bs : list β)\n\n@[simp] theorem zip_left'_nil_right :\n  zip_left' as ([] : list β) = (as.map (λ a, (a, none)), []) :=\nby cases as; refl\n\n@[simp] theorem zip_left'_nil_left :\n  zip_left' ([] : list α) bs = ([], bs) :=\nrfl\n\n@[simp] theorem zip_left'_cons_nil :\n  zip_left' (a :: as) ([] : list β) = ((a, none) :: as.map (λ a, (a, none)), []) :=\nrfl\n\n@[simp] theorem zip_left'_cons_cons :\n  zip_left' (a :: as) (b :: bs) =\n    let rec := zip_left' as bs in\n    ((a, some b) :: rec.fst, rec.snd) :=\nrfl\n\nend zip_left'\n\n/-! ### zip_right' -/\n\nsection zip_right'\n\nvariables (a : α) (as : list α) (b : β) (bs : list β)\n\n@[simp] theorem zip_right'_nil_left :\n  zip_right' ([] : list α) bs = (bs.map (λ b, (none, b)), []) :=\nby cases bs; refl\n\n@[simp] theorem zip_right'_nil_right :\n  zip_right' as ([] : list β) = ([], as) :=\nrfl\n\n@[simp] theorem zip_right'_nil_cons :\n  zip_right' ([] : list α) (b :: bs) = ((none, b) :: bs.map (λ b, (none, b)), []) :=\nrfl\n\n@[simp] theorem zip_right'_cons_cons :\n  zip_right' (a :: as) (b :: bs) =\n    let rec := zip_right' as bs in\n    ((some a, b) :: rec.fst, rec.snd) :=\nrfl\n\nend zip_right'\n\n/-! ### map₂_left -/\n\nsection map₂_left\n\nvariables (f : α → option β → γ) (as : list α)\n\n-- The definitional equalities for `map₂_left` can already be used by the\n-- simplifier because `map₂_left` is marked `@[simp]`.\n\n@[simp] theorem map₂_left_nil_right :\n  map₂_left f as [] = as.map (λ a, f a none) :=\nby cases as; refl\n\ntheorem map₂_left_eq_map₂_left' : ∀ as bs,\n  map₂_left f as bs = (map₂_left' f as bs).fst\n| [] bs := by simp!\n| (a :: as) [] := by simp!\n| (a :: as) (b :: bs) := by simp! [*]\n\ntheorem map₂_left_eq_map₂ : ∀ as bs,\n  length as ≤ length bs →\n  map₂_left f as bs = map₂ (λ a b, f a (some b)) as bs\n| [] [] h := by simp!\n| [] (b :: bs) h := by simp!\n| (a :: as) [] h := by { simp at h, contradiction }\n| (a :: as) (b :: bs) h := by { simp at h, simp! [*] }\n\nend map₂_left\n\n/-! ### map₂_right -/\n\nsection map₂_right\n\nvariables (f : option α → β → γ) (a : α) (as : list α) (b : β) (bs : list β)\n\n@[simp] theorem map₂_right_nil_left :\n  map₂_right f [] bs = bs.map (f none) :=\nby cases bs; refl\n\n@[simp] theorem map₂_right_nil_right :\n  map₂_right f as [] = [] :=\nrfl\n\n@[simp] theorem map₂_right_nil_cons :\n  map₂_right f [] (b :: bs) = f none b :: bs.map (f none) :=\nrfl\n\n@[simp] theorem map₂_right_cons_cons :\n  map₂_right f (a :: as) (b :: bs) = f (some a) b :: map₂_right f as bs :=\nrfl\n\ntheorem map₂_right_eq_map₂_right' :\n  map₂_right f as bs = (map₂_right' f as bs).fst :=\nby simp only [map₂_right, map₂_right', map₂_left_eq_map₂_left']\n\ntheorem map₂_right_eq_map₂ (h : length bs ≤ length as) :\n  map₂_right f as bs = map₂ (λ a b, f (some a) b) as bs :=\nbegin\n  have : (λ a b, flip f a (some b)) = (flip (λ a b, f (some a) b)) := rfl,\n  simp only [map₂_right, map₂_left_eq_map₂, map₂_flip, *]\nend\n\nend map₂_right\n\n/-! ### zip_left -/\n\nsection zip_left\n\nvariables (a : α) (as : list α) (b : β) (bs : list β)\n\n@[simp] theorem zip_left_nil_right :\n  zip_left as ([] : list β) = as.map (λ a, (a, none)) :=\nby cases as; refl\n\n@[simp] theorem zip_left_nil_left :\n  zip_left ([] : list α) bs = [] :=\nrfl\n\n@[simp] theorem zip_left_cons_nil :\n  zip_left (a :: as) ([] : list β) = (a, none) :: as.map (λ a, (a, none)) :=\nrfl\n\n@[simp] theorem zip_left_cons_cons :\n  zip_left (a :: as) (b :: bs) = (a, some b) :: zip_left as bs :=\nrfl\n\ntheorem zip_left_eq_zip_left' :\n  zip_left as bs = (zip_left' as bs).fst :=\nby simp only [zip_left, zip_left', map₂_left_eq_map₂_left']\n\nend zip_left\n\n/-! ### zip_right -/\n\nsection zip_right\n\nvariables (a : α) (as : list α) (b : β) (bs : list β)\n\n@[simp] theorem zip_right_nil_left :\n  zip_right ([] : list α) bs = bs.map (λ b, (none, b)) :=\nby cases bs; refl\n\n@[simp] theorem zip_right_nil_right :\n  zip_right as ([] : list β) = [] :=\nrfl\n\n@[simp] theorem zip_right_nil_cons :\n  zip_right ([] : list α) (b :: bs) = (none, b) :: bs.map (λ b, (none, b)) :=\nrfl\n\n@[simp] theorem zip_right_cons_cons :\n  zip_right (a :: as) (b :: bs) = (some a, b) :: zip_right as bs :=\nrfl\n\ntheorem zip_right_eq_zip_right' :\n  zip_right as bs = (zip_right' as bs).fst :=\nby simp only [zip_right, zip_right', map₂_right_eq_map₂_right']\n\nend zip_right\n\n/-! ### Miscellaneous lemmas -/\n\ntheorem ilast'_mem : ∀ a l, @ilast' α a l ∈ a :: l\n| a []     := or.inl rfl\n| a (b::l) := or.inr (ilast'_mem b l)\n\n@[simp] lemma nth_le_attach (L : list α) (i) (H : i < L.attach.length) :\n  (L.attach.nth_le i H).1 = L.nth_le i (length_attach L ▸ H) :=\ncalc  (L.attach.nth_le i H).1\n    = (L.attach.map subtype.val).nth_le i (by simpa using H) : by rw nth_le_map'\n... = L.nth_le i _ : by congr; apply attach_map_val\n\nend list\n\n@[to_additive]\ntheorem monoid_hom.map_list_prod {α β : Type*} [monoid α] [monoid β] (f : α →* β) (l : list α) :\n  f l.prod = (l.map f).prod :=\n(l.prod_hom f).symm\n\nnamespace list\n\n@[to_additive]\ntheorem prod_map_hom {α β γ : Type*} [monoid β] [monoid γ] (L : list α) (f : α → β) (g : β →* γ) :\n  (L.map (g ∘ f)).prod = g ((L.map f).prod) :=\nby {rw g.map_list_prod, exact congr_arg _ (map_map _ _ _).symm}\n\ntheorem sum_map_mul_left {α : Type*} [semiring α] {β : Type*} (L : list β)\n  (f : β → α) (r : α) :\n  (L.map (λ b, r * f b)).sum = r * (L.map f).sum :=\nsum_map_hom L f $ add_monoid_hom.mul_left r\n\ntheorem sum_map_mul_right {α : Type*} [semiring α] {β : Type*} (L : list β)\n  (f : β → α) (r : α) :\n  (L.map (λ b, f b * r)).sum = (L.map f).sum * r :=\nsum_map_hom L f $ add_monoid_hom.mul_right r\n\nuniverses u v\n\n@[simp]\ntheorem mem_map_swap {α : Type u} {β : Type v} (x : α) (y : β) (xs : list (α × β)) :\n  (y, x) ∈ map prod.swap xs ↔ (x, y) ∈ xs :=\nbegin\n  induction xs with x xs,\n  { simp only [not_mem_nil, map_nil] },\n  { cases x with a b,\n    simp only [mem_cons_iff, prod.mk.inj_iff, map, prod.swap_prod_mk, prod.exists, xs_ih],\n    tauto! },\nend\n\nlemma slice_eq {α} (xs : list α) (n m : ℕ) :\n  slice n m xs = xs.take n ++ xs.drop (n+m) :=\nbegin\n  induction n generalizing xs,\n  { simp [slice] },\n  { cases xs; simp [slice, *, nat.succ_add], }\nend\n\nlemma sizeof_slice_lt {α} [has_sizeof α] (i j : ℕ) (hj : 0 < j) (xs : list α) (hi : i < xs.length) :\n  sizeof (list.slice i j xs) < sizeof xs :=\nbegin\n  induction xs generalizing i j,\n  case list.nil : i j h\n  { cases hi },\n  case list.cons : x xs xs_ih i j h\n  { cases i; simp only [-slice_eq, list.slice],\n    { cases j, cases h,\n      dsimp only [drop], unfold_wf,\n      apply @lt_of_le_of_lt _ _ _ xs.sizeof,\n      { clear_except,\n        induction xs generalizing j; unfold_wf,\n        case list.nil : j\n        { refl },\n        case list.cons : xs_hd xs_tl xs_ih j\n        { cases j; unfold_wf, refl,\n          transitivity, apply xs_ih,\n          simp }, },\n      unfold_wf, apply zero_lt_one_add, },\n    { unfold_wf, apply xs_ih _ _ h,\n      apply lt_of_succ_lt_succ hi, } },\nend\n\nend list\n-/", "meta": {"author": "kbuzzard", "repo": "mathlib4_experiments", "sha": "87cb879b4d602c8ecfd9283b7c0b06015abdbab1", "save_path": "github-repos/lean/kbuzzard-mathlib4_experiments", "path": "github-repos/lean/kbuzzard-mathlib4_experiments/mathlib4_experiments-87cb879b4d602c8ecfd9283b7c0b06015abdbab1/mathlib4_experiments/Data/List/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499941, "lm_q2_score": 0.7549149758396752, "lm_q1q2_score": 0.4996954918300266}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.algebra_tower\nimport Mathlib.ring_theory.polynomial.scale_roots\nimport Mathlib.PostPort\n\nuniverses u_1 u_3 u_2 u_4 u_5 \n\nnamespace Mathlib\n\n/-!\n# Integral closure of a subring.\n\nIf A is an R-algebra then `a : A` is integral over R if it is a root of a monic polynomial\nwith coefficients in R. Enough theory is developed to prove that integral elements\nform a sub-R-algebra of A.\n\n## Main definitions\n\nLet `R` be a `comm_ring` and let `A` be an R-algebra.\n\n* `ring_hom.is_integral_elem (f : R →+* A) (x : A)` : `x` is integral with respect to the map `f`,\n\n* `is_integral (x : A)`  : `x` is integral over `R`, i.e., is a root of a monic polynomial with\n                           coefficients in `R`.\n* `integral_closure R A` : the integral closure of `R` in `A`, regarded as a sub-`R`-algebra of `A`.\n-/\n\n/-- An element `x` of `A` is said to be integral over `R` with respect to `f`\nif it is a root of a monic polynomial `p : polynomial R` evaluated under `f` -/\ndef ring_hom.is_integral_elem {R : Type u_1} {A : Type u_3} [comm_ring R] [ring A] (f : R →+* A) (x : A) :=\n  ∃ (p : polynomial R), polynomial.monic p ∧ polynomial.eval₂ f x p = 0\n\n/-- A ring homomorphism `f : R →+* A` is said to be integral\nif every element `A` is integral with respect to the map `f` -/\ndef ring_hom.is_integral {R : Type u_1} {A : Type u_3} [comm_ring R] [ring A] (f : R →+* A) :=\n  ∀ (x : A), ring_hom.is_integral_elem f x\n\n/-- An element `x` of an algebra `A` over a commutative ring `R` is said to be *integral*,\nif it is a root of some monic polynomial `p : polynomial R`.\nEquivalently, the element is integral over `R` with respect to the induced `algebra_map` -/\ndef is_integral (R : Type u_1) {A : Type u_3} [comm_ring R] [ring A] [algebra R A] (x : A) :=\n  ring_hom.is_integral_elem (algebra_map R A) x\n\n/-- An algebra is integral if every element of the extension is integral over the base ring -/\ndef algebra.is_integral (R : Type u_1) (A : Type u_3) [comm_ring R] [ring A] [algebra R A] :=\n  ring_hom.is_integral (algebra_map R A)\n\ntheorem ring_hom.is_integral_map {R : Type u_1} {S : Type u_2} [comm_ring R] [ring S] (f : R →+* S) {x : R} : ring_hom.is_integral_elem f (coe_fn f x) := sorry\n\ntheorem is_integral_algebra_map {R : Type u_1} {A : Type u_3} [comm_ring R] [ring A] [algebra R A] {x : R} : is_integral R (coe_fn (algebra_map R A) x) :=\n  ring_hom.is_integral_map (algebra_map R A)\n\ntheorem is_integral_of_noetherian {R : Type u_1} {A : Type u_3} [comm_ring R] [ring A] [algebra R A] (H : is_noetherian R A) (x : A) : is_integral R x := sorry\n\ntheorem is_integral_of_submodule_noetherian {R : Type u_1} {A : Type u_3} [comm_ring R] [ring A] [algebra R A] (S : subalgebra R A) (H : is_noetherian R ↥↑S) (x : A) (hx : x ∈ S) : is_integral R x := sorry\n\ntheorem is_integral_alg_hom {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra R A] [algebra R B] (f : alg_hom R A B) {x : A} (hx : is_integral R x) : is_integral R (coe_fn f x) := sorry\n\ntheorem is_integral_of_is_scalar_tower {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra R A] [algebra R B] [algebra A B] [is_scalar_tower R A B] (x : B) (hx : is_integral R x) : is_integral A x := sorry\n\ntheorem is_integral_of_subring {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {x : A} (T : set R) [is_subring T] (hx : is_integral (↥T) x) : is_integral R x :=\n  is_integral_of_is_scalar_tower x hx\n\ntheorem is_integral_algebra_map_iff {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra R A] [algebra R B] [algebra A B] [is_scalar_tower R A B] {x : A} (hAB : function.injective ⇑(algebra_map A B)) : is_integral R (coe_fn (algebra_map A B) x) ↔ is_integral R x := sorry\n\ntheorem is_integral_iff_is_integral_closure_finite {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {r : A} : is_integral R r ↔ ∃ (s : set R), set.finite s ∧ is_integral (↥(ring.closure s)) r := sorry\n\ntheorem fg_adjoin_singleton_of_integral {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] (x : A) (hx : is_integral R x) : submodule.fg ↑(algebra.adjoin R (singleton x)) := sorry\n\ntheorem fg_adjoin_of_finite {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {s : set A} (hfs : set.finite s) (his : ∀ (x : A), x ∈ s → is_integral R x) : submodule.fg ↑(algebra.adjoin R s) := sorry\n\ntheorem is_integral_of_mem_of_fg {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] (S : subalgebra R A) (HS : submodule.fg ↑S) (x : A) (hx : x ∈ S) : is_integral R x := sorry\n\ntheorem ring_hom.is_integral_of_mem_closure {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) {x : S} {y : S} {z : S} (hx : ring_hom.is_integral_elem f x) (hy : ring_hom.is_integral_elem f y) (hz : z ∈ ring.closure (insert x (singleton y))) : ring_hom.is_integral_elem f z := sorry\n\ntheorem is_integral_of_mem_closure {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {x : A} {y : A} {z : A} (hx : is_integral R x) (hy : is_integral R y) (hz : z ∈ ring.closure (insert x (singleton y))) : is_integral R z :=\n  ring_hom.is_integral_of_mem_closure (algebra_map R A) hx hy hz\n\ntheorem ring_hom.is_integral_zero {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) : ring_hom.is_integral_elem f 0 :=\n  ring_hom.map_zero f ▸ ring_hom.is_integral_map f\n\ntheorem is_integral_zero {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] : is_integral R 0 :=\n  ring_hom.is_integral_zero (algebra_map R A)\n\ntheorem ring_hom.is_integral_one {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) : ring_hom.is_integral_elem f 1 :=\n  ring_hom.map_one f ▸ ring_hom.is_integral_map f\n\ntheorem is_integral_one {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] : is_integral R 1 :=\n  ring_hom.is_integral_one (algebra_map R A)\n\ntheorem ring_hom.is_integral_add {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) {x : S} {y : S} (hx : ring_hom.is_integral_elem f x) (hy : ring_hom.is_integral_elem f y) : ring_hom.is_integral_elem f (x + y) :=\n  ring_hom.is_integral_of_mem_closure f hx hy\n    (is_add_submonoid.add_mem (ring.subset_closure (Or.inl rfl)) (ring.subset_closure (Or.inr rfl)))\n\ntheorem is_integral_add {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {x : A} {y : A} (hx : is_integral R x) (hy : is_integral R y) : is_integral R (x + y) :=\n  ring_hom.is_integral_add (algebra_map R A) hx hy\n\ntheorem ring_hom.is_integral_neg {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) {x : S} (hx : ring_hom.is_integral_elem f x) : ring_hom.is_integral_elem f (-x) :=\n  ring_hom.is_integral_of_mem_closure f hx hx (is_add_subgroup.neg_mem (ring.subset_closure (Or.inl rfl)))\n\ntheorem is_integral_neg {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {x : A} (hx : is_integral R x) : is_integral R (-x) :=\n  ring_hom.is_integral_neg (algebra_map R A) hx\n\ntheorem ring_hom.is_integral_sub {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) {x : S} {y : S} (hx : ring_hom.is_integral_elem f x) (hy : ring_hom.is_integral_elem f y) : ring_hom.is_integral_elem f (x - y) := sorry\n\ntheorem is_integral_sub {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {x : A} {y : A} (hx : is_integral R x) (hy : is_integral R y) : is_integral R (x - y) :=\n  ring_hom.is_integral_sub (algebra_map R A) hx hy\n\ntheorem ring_hom.is_integral_mul {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) {x : S} {y : S} (hx : ring_hom.is_integral_elem f x) (hy : ring_hom.is_integral_elem f y) : ring_hom.is_integral_elem f (x * y) :=\n  ring_hom.is_integral_of_mem_closure f hx hy\n    (is_submonoid.mul_mem (ring.subset_closure (Or.inl rfl)) (ring.subset_closure (Or.inr rfl)))\n\ntheorem is_integral_mul {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {x : A} {y : A} (hx : is_integral R x) (hy : is_integral R y) : is_integral R (x * y) :=\n  ring_hom.is_integral_mul (algebra_map R A) hx hy\n\n/-- The integral closure of R in an R-algebra A. -/\ndef integral_closure (R : Type u_1) (A : Type u_2) [comm_ring R] [comm_ring A] [algebra R A] : subalgebra R A :=\n  subalgebra.mk (set_of fun (r : A) => is_integral R r) is_integral_one sorry is_integral_zero sorry sorry\n\ntheorem mem_integral_closure_iff_mem_fg (R : Type u_1) (A : Type u_2) [comm_ring R] [comm_ring A] [algebra R A] {r : A} : r ∈ integral_closure R A ↔ ∃ (M : subalgebra R A), submodule.fg ↑M ∧ r ∈ M := sorry\n\n/-- Mapping an integral closure along an `alg_equiv` gives the integral closure. -/\ntheorem integral_closure_map_alg_equiv {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra R A] [algebra R B] (f : alg_equiv R A B) : subalgebra.map (integral_closure R A) ↑f = integral_closure R B := sorry\n\ntheorem integral_closure.is_integral {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] (x : ↥(integral_closure R A)) : is_integral R x := sorry\n\ntheorem ring_hom.is_integral_of_is_integral_mul_unit {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) (x : S) (y : S) (r : R) (hr : coe_fn f r * y = 1) (hx : ring_hom.is_integral_elem f (x * y)) : ring_hom.is_integral_elem f x := sorry\n\ntheorem is_integral_of_is_integral_mul_unit {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {x : A} {y : A} {r : R} (hr : coe_fn (algebra_map R A) r * y = 1) (hx : is_integral R (x * y)) : is_integral R x :=\n  ring_hom.is_integral_of_is_integral_mul_unit (algebra_map R A) x y r hr hx\n\n/-- Generalization of `is_integral_of_mem_closure` bootstrapped up from that lemma -/\ntheorem is_integral_of_mem_closure' {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] (G : set A) (hG : ∀ (x : A), x ∈ G → is_integral R x) (x : A) (H : x ∈ subring.closure G) : is_integral R x :=\n  subring.closure_induction hx hG is_integral_zero is_integral_one (fun (_x _x_1 : A) => is_integral_add)\n    (fun (_x : A) => is_integral_neg) fun (_x _x_1 : A) => is_integral_mul\n\ntheorem is_integral_of_mem_closure'' {R : Type u_1} [comm_ring R] {S : Type u_2} [comm_ring S] {f : R →+* S} (G : set S) (hG : ∀ (x : S), x ∈ G → ring_hom.is_integral_elem f x) (x : S) (H : x ∈ subring.closure G) : ring_hom.is_integral_elem f x :=\n  is_integral_of_mem_closure' G hG x hx\n\ntheorem is_integral_trans_aux {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra A B] [algebra R B] (x : B) {p : polynomial A} (pmonic : polynomial.monic p) (hp : coe_fn (polynomial.aeval x) p = 0) : is_integral (↥(algebra.adjoin R ↑(finsupp.frange (polynomial.map (algebra_map A B) p)))) x := sorry\n\n/-- If A is an R-algebra all of whose elements are integral over R,\nand x is an element of an A-algebra that is integral over A, then x is integral over R.-/\ntheorem is_integral_trans {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra A B] [algebra R B] [algebra R A] [is_scalar_tower R A B] (A_int : algebra.is_integral R A) (x : B) (hx : is_integral A x) : is_integral R x := sorry\n\n/-- If A is an R-algebra all of whose elements are integral over R,\nand B is an A-algebra all of whose elements are integral over A,\nthen all elements of B are integral over R.-/\ntheorem algebra.is_integral_trans {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra A B] [algebra R B] [algebra R A] [is_scalar_tower R A B] (hA : algebra.is_integral R A) (hB : algebra.is_integral A B) : algebra.is_integral R B :=\n  fun (x : B) => is_integral_trans hA x (hB x)\n\ntheorem ring_hom.is_integral_trans {R : Type u_1} {S : Type u_4} {T : Type u_5} [comm_ring R] [comm_ring S] [comm_ring T] (f : R →+* S) (g : S →+* T) (hf : ring_hom.is_integral f) (hg : ring_hom.is_integral g) : ring_hom.is_integral (ring_hom.comp g f) :=\n  algebra.is_integral_trans hf hg\n\ntheorem ring_hom.is_integral_of_surjective {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) (hf : function.surjective ⇑f) : ring_hom.is_integral f :=\n  fun (x : S) => Exists.rec_on (hf x) fun (y : R) (hy : coe_fn f y = x) => hy ▸ ring_hom.is_integral_map f\n\ntheorem is_integral_of_surjective {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] (h : function.surjective ⇑(algebra_map R A)) : algebra.is_integral R A :=\n  ring_hom.is_integral_of_surjective (algebra_map R A) h\n\n/-- If `R → A → B` is an algebra tower with `A → B` injective,\nthen if the entire tower is an integral extension so is `R → A` -/\ntheorem is_integral_tower_bot_of_is_integral {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra A B] [algebra R B] [algebra R A] [is_scalar_tower R A B] (H : function.injective ⇑(algebra_map A B)) {x : A} (h : is_integral R (coe_fn (algebra_map A B) x)) : is_integral R x := sorry\n\ntheorem ring_hom.is_integral_tower_bot_of_is_integral {R : Type u_1} {S : Type u_4} {T : Type u_5} [comm_ring R] [comm_ring S] [comm_ring T] (f : R →+* S) (g : S →+* T) (hg : function.injective ⇑g) (hfg : ring_hom.is_integral (ring_hom.comp g f)) : ring_hom.is_integral f :=\n  fun (x : S) => is_integral_tower_bot_of_is_integral hg (hfg (coe_fn g x))\n\ntheorem is_integral_tower_bot_of_is_integral_field {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [field A] [comm_ring B] [nontrivial B] [algebra R A] [algebra A B] [algebra R B] [is_scalar_tower R A B] {x : A} (h : is_integral R (coe_fn (algebra_map A B) x)) : is_integral R x :=\n  is_integral_tower_bot_of_is_integral (ring_hom.injective (algebra_map A B)) h\n\ntheorem ring_hom.is_integral_elem_of_is_integral_elem_comp {R : Type u_1} {S : Type u_4} {T : Type u_5} [comm_ring R] [comm_ring S] [comm_ring T] (f : R →+* S) (g : S →+* T) {x : T} (h : ring_hom.is_integral_elem (ring_hom.comp g f) x) : ring_hom.is_integral_elem g x := sorry\n\ntheorem ring_hom.is_integral_tower_top_of_is_integral {R : Type u_1} {S : Type u_4} {T : Type u_5} [comm_ring R] [comm_ring S] [comm_ring T] (f : R →+* S) (g : S →+* T) (h : ring_hom.is_integral (ring_hom.comp g f)) : ring_hom.is_integral g :=\n  fun (x : T) => ring_hom.is_integral_elem_of_is_integral_elem_comp f g (h x)\n\n/-- If `R → A → B` is an algebra tower,\nthen if the entire tower is an integral extension so is `A → B`. -/\ntheorem is_integral_tower_top_of_is_integral {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R] [comm_ring A] [comm_ring B] [algebra A B] [algebra R B] [algebra R A] [is_scalar_tower R A B] {x : B} (h : is_integral R x) : is_integral A x := sorry\n\ntheorem ring_hom.is_integral_quotient_of_is_integral {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) {I : ideal S} (hf : ring_hom.is_integral f) : ring_hom.is_integral (ideal.quotient_map I f le_rfl) := sorry\n\ntheorem is_integral_quotient_of_is_integral {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] {I : ideal A} (hRA : algebra.is_integral R A) : algebra.is_integral (ideal.quotient (ideal.comap (algebra_map R A) I)) (ideal.quotient I) :=\n  ring_hom.is_integral_quotient_of_is_integral (algebra_map R A) hRA\n\ntheorem is_integral_quotient_map_iff {R : Type u_1} {S : Type u_4} [comm_ring R] [comm_ring S] (f : R →+* S) {I : ideal S} : ring_hom.is_integral (ideal.quotient_map I f le_rfl) ↔ ring_hom.is_integral (ring_hom.comp (ideal.quotient.mk I) f) := sorry\n\n/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/\ntheorem is_field_of_is_integral_of_is_field {R : Type u_1} {S : Type u_2} [integral_domain R] [integral_domain S] [algebra R S] (H : algebra.is_integral R S) (hRS : function.injective ⇑(algebra_map R S)) (hS : is_field S) : is_field R := sorry\n\ntheorem integral_closure_idem {R : Type u_1} {A : Type u_2} [comm_ring R] [comm_ring A] [algebra R A] : integral_closure (↥↑(integral_closure R A)) A = ⊥ := sorry\n\nprotected instance integral_closure.integral_domain {R : Type u_1} {S : Type u_2} [comm_ring R] [integral_domain S] [algebra R S] : integral_domain ↥(integral_closure R S) :=\n  integral_domain.mk comm_ring.add sorry comm_ring.zero sorry sorry comm_ring.neg comm_ring.sub sorry sorry comm_ring.mul\n    sorry comm_ring.one sorry sorry sorry sorry sorry sorry sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/integral_closure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.49965715280950285}}
{"text": "/-\nCopyright (c) 2022 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Sébastien Gouëzel, Zhouhang Zhou, Reid Barton,\nAnatole Dedecker\n-/\nimport topology.homeomorph\nimport topology.uniform_space.uniform_embedding\nimport topology.uniform_space.pi\n\n/-!\n# Uniform isomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines uniform isomorphisms between two uniform spaces. They are bijections with both\ndirections uniformly continuous. We denote uniform isomorphisms with the notation `≃ᵤ`.\n\n# Main definitions\n\n* `uniform_equiv α β`: The type of uniform isomorphisms from `α` to `β`.\n  This type can be denoted using the following notation: `α ≃ᵤ β`.\n\n-/\n\nopen set filter\nopen_locale\n\nuniverses u v\nvariables {α : Type u} {β : Type*} {γ : Type*} {δ : Type*}\n\n/-- Uniform isomorphism between `α` and `β` -/\n@[nolint has_nonempty_instance] -- not all spaces are homeomorphic to each other\nstructure uniform_equiv (α : Type*) (β : Type*) [uniform_space α] [uniform_space β]\n  extends α ≃ β :=\n(uniform_continuous_to_fun  : uniform_continuous to_fun)\n(uniform_continuous_inv_fun : uniform_continuous inv_fun)\n\ninfix ` ≃ᵤ `:25 := uniform_equiv\n\nnamespace uniform_equiv\nvariables [uniform_space α] [uniform_space β] [uniform_space γ] [uniform_space δ]\n\ninstance : has_coe_to_fun (α ≃ᵤ β) (λ _, α → β) := ⟨λe, e.to_equiv⟩\n\n@[simp] lemma uniform_equiv_mk_coe (a : equiv α β) (b c) :\n  ((uniform_equiv.mk a b c) : α → β) = a :=\nrfl\n\n/-- Inverse of a uniform isomorphism. -/\nprotected def symm (h : α ≃ᵤ β) : β ≃ᵤ α :=\n{ uniform_continuous_to_fun  := h.uniform_continuous_inv_fun,\n  uniform_continuous_inv_fun := h.uniform_continuous_to_fun,\n  to_equiv := h.to_equiv.symm }\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : α ≃ᵤ β) : α → β := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : α ≃ᵤ β) : β → α := h.symm\n\ninitialize_simps_projections uniform_equiv\n  (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply, -to_equiv)\n\n@[simp] lemma coe_to_equiv (h : α ≃ᵤ β) : ⇑h.to_equiv = h := rfl\n@[simp] lemma coe_symm_to_equiv (h : α ≃ᵤ β) : ⇑h.to_equiv.symm = h.symm := rfl\n\nlemma to_equiv_injective : function.injective (to_equiv : α ≃ᵤ β → α ≃ β)\n| ⟨e, h₁, h₂⟩ ⟨e', h₁', h₂'⟩ rfl := rfl\n\n@[ext] lemma ext {h h' : α ≃ᵤ β} (H : ∀ x, h x = h' x) : h = h' :=\nto_equiv_injective $ equiv.ext H\n\n/-- Identity map as a uniform isomorphism. -/\n@[simps apply {fully_applied := ff}]\nprotected def refl (α : Type*) [uniform_space α] : α ≃ᵤ α :=\n{ uniform_continuous_to_fun := uniform_continuous_id,\n  uniform_continuous_inv_fun := uniform_continuous_id,\n  to_equiv := equiv.refl α }\n\n/-- Composition of two uniform isomorphisms. -/\nprotected def trans (h₁ : α ≃ᵤ β) (h₂ : β ≃ᵤ γ) : α ≃ᵤ γ :=\n{ uniform_continuous_to_fun  := h₂.uniform_continuous_to_fun.comp h₁.uniform_continuous_to_fun,\n  uniform_continuous_inv_fun := h₁.uniform_continuous_inv_fun.comp h₂.uniform_continuous_inv_fun,\n  to_equiv := equiv.trans h₁.to_equiv h₂.to_equiv }\n\n@[simp] lemma trans_apply (h₁ : α ≃ᵤ β) (h₂ : β ≃ᵤ γ) (a : α) : h₁.trans h₂ a = h₂ (h₁ a) := rfl\n\n@[simp] lemma uniform_equiv_mk_coe_symm (a : equiv α β) (b c) :\n  ((uniform_equiv.mk a b c).symm : β → α) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (uniform_equiv.refl α).symm = uniform_equiv.refl α := rfl\n\nprotected lemma uniform_continuous (h : α ≃ᵤ β) : uniform_continuous h :=\nh.uniform_continuous_to_fun\n\n@[continuity]\nprotected lemma continuous (h : α ≃ᵤ β) : continuous h :=\nh.uniform_continuous.continuous\n\nprotected lemma uniform_continuous_symm (h : α ≃ᵤ β) : uniform_continuous (h.symm) :=\nh.uniform_continuous_inv_fun\n\n@[continuity] -- otherwise `by continuity` can't prove continuity of `h.to_equiv.symm`\nprotected lemma continuous_symm (h : α ≃ᵤ β) : continuous (h.symm) :=\nh.uniform_continuous_symm.continuous\n\n/-- A uniform isomorphism as a homeomorphism. -/\n@[simps]\nprotected def to_homeomorph (e : α ≃ᵤ β) : α ≃ₜ β :=\n{ continuous_to_fun := e.continuous,\n  continuous_inv_fun := e.continuous_symm,\n  .. e.to_equiv }\n\n@[simp] lemma apply_symm_apply (h : α ≃ᵤ β) (x : β) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : α ≃ᵤ β) (x : α) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : α ≃ᵤ β) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : α ≃ᵤ β) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : α ≃ᵤ β) : function.surjective h := h.to_equiv.surjective\n\n/-- Change the uniform equiv `f` to make the inverse function definitionally equal to `g`. -/\ndef change_inv (f : α ≃ᵤ β) (g : β → α) (hg : function.right_inverse g f) : α ≃ᵤ β :=\nhave g = f.symm, from funext (λ x, calc g x = f.symm (f (g x)) : (f.left_inv (g x)).symm\n                                        ... = f.symm x : by rw hg x),\n{ to_fun := f,\n  inv_fun := g,\n  left_inv := by convert f.left_inv,\n  right_inv := by convert f.right_inv,\n  uniform_continuous_to_fun := f.uniform_continuous,\n  uniform_continuous_inv_fun := by convert f.symm.uniform_continuous }\n\n@[simp] lemma symm_comp_self (h : α ≃ᵤ β) : ⇑h.symm ∘ ⇑h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : α ≃ᵤ β) : ⇑h ∘ ⇑h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : α ≃ᵤ β) : range h = univ :=\nh.surjective.range_eq\n\n\n\nlemma preimage_symm (h : α ≃ᵤ β) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : α ≃ᵤ β) (s : set β) : h '' (h ⁻¹' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : α ≃ᵤ β) (s : set α) : h ⁻¹' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma uniform_inducing (h : α ≃ᵤ β) : uniform_inducing h :=\nuniform_inducing_of_compose h.uniform_continuous h.symm.uniform_continuous $\n  by simp only [symm_comp_self, uniform_inducing_id]\n\nlemma comap_eq (h : α ≃ᵤ β) : uniform_space.comap h ‹_› = ‹_› :=\nby ext : 1; exact h.uniform_inducing.comap_uniformity\n\nprotected lemma uniform_embedding (h : α ≃ᵤ β) : uniform_embedding h :=\n⟨h.uniform_inducing, h.injective⟩\n\n/-- Uniform equiv given a uniform embedding. -/\nnoncomputable def of_uniform_embedding (f : α → β) (hf : uniform_embedding f) :\n  α ≃ᵤ (set.range f) :=\n{ uniform_continuous_to_fun := hf.to_uniform_inducing.uniform_continuous.subtype_mk _,\n  uniform_continuous_inv_fun :=\n    by simp [hf.to_uniform_inducing.uniform_continuous_iff, uniform_continuous_subtype_coe],\n  to_equiv := equiv.of_injective f hf.inj }\n\n/-- If two sets are equal, then they are uniformly equivalent. -/\ndef set_congr {s t : set α} (h : s = t) : s ≃ᵤ t :=\n{ uniform_continuous_to_fun := uniform_continuous_subtype_val.subtype_mk _,\n  uniform_continuous_inv_fun := uniform_continuous_subtype_val.subtype_mk _,\n  to_equiv := equiv.set_congr h }\n\n/-- Product of two uniform isomorphisms. -/\ndef prod_congr (h₁ : α ≃ᵤ β) (h₂ : γ ≃ᵤ δ) : α × γ ≃ᵤ β × δ :=\n{ uniform_continuous_to_fun  := (h₁.uniform_continuous.comp uniform_continuous_fst).prod_mk\n    (h₂.uniform_continuous.comp uniform_continuous_snd),\n  uniform_continuous_inv_fun := (h₁.symm.uniform_continuous.comp uniform_continuous_fst).prod_mk\n    (h₂.symm.uniform_continuous.comp uniform_continuous_snd),\n  to_equiv := h₁.to_equiv.prod_congr h₂.to_equiv }\n\n@[simp] lemma prod_congr_symm (h₁ : α ≃ᵤ β) (h₂ : γ ≃ᵤ δ) :\n  (h₁.prod_congr h₂).symm = h₁.symm.prod_congr h₂.symm := rfl\n\n@[simp] lemma coe_prod_congr (h₁ : α ≃ᵤ β) (h₂ : γ ≃ᵤ δ) :\n  ⇑(h₁.prod_congr h₂) = prod.map h₁ h₂ := rfl\n\nsection\nvariables (α β γ)\n\n/-- `α × β` is uniformly isomorphic to `β × α`. -/\ndef prod_comm : α × β ≃ᵤ β × α :=\n{ uniform_continuous_to_fun  := uniform_continuous_snd.prod_mk uniform_continuous_fst,\n  uniform_continuous_inv_fun := uniform_continuous_snd.prod_mk uniform_continuous_fst,\n  to_equiv := equiv.prod_comm α β }\n\n@[simp] lemma prod_comm_symm : (prod_comm α β).symm = prod_comm β α := rfl\n@[simp] lemma coe_prod_comm : ⇑(prod_comm α β) = prod.swap := rfl\n\n/-- `(α × β) × γ` is uniformly isomorphic to `α × (β × γ)`. -/\ndef prod_assoc : (α × β) × γ ≃ᵤ α × (β × γ) :=\n{ uniform_continuous_to_fun  := (uniform_continuous_fst.comp uniform_continuous_fst).prod_mk\n    ((uniform_continuous_snd.comp uniform_continuous_fst).prod_mk uniform_continuous_snd),\n  uniform_continuous_inv_fun := (uniform_continuous_fst.prod_mk\n    (uniform_continuous_fst.comp uniform_continuous_snd)).prod_mk\n    (uniform_continuous_snd.comp uniform_continuous_snd),\n  to_equiv := equiv.prod_assoc α β γ }\n\n/-- `α × {*}` is uniformly isomorphic to `α`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : α × punit ≃ᵤ α :=\n{ to_equiv := equiv.prod_punit α,\n  uniform_continuous_to_fun := uniform_continuous_fst,\n  uniform_continuous_inv_fun := uniform_continuous_id.prod_mk uniform_continuous_const }\n\n/-- `{*} × α` is uniformly isomorphic to `α`. -/\ndef punit_prod : punit × α ≃ᵤ α :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : ⇑(punit_prod α) = prod.snd := rfl\n\n/-- Uniform equivalence between `ulift α` and `α`. -/\ndef ulift : ulift.{v u} α ≃ᵤ α :=\n{ uniform_continuous_to_fun := uniform_continuous_comap,\n  uniform_continuous_inv_fun := begin\n    have hf : uniform_inducing (@equiv.ulift.{v u} α).to_fun, from ⟨rfl⟩,\n    simp_rw [hf.uniform_continuous_iff],\n    exact uniform_continuous_id,\n  end,\n  .. equiv.ulift }\n\nend\n\n/-- If `ι` has a unique element, then `ι → α` is homeomorphic to `α`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (ι α : Type*) [unique ι] [uniform_space α] : (ι → α) ≃ᵤ α :=\n{ to_equiv := equiv.fun_unique ι α,\n  uniform_continuous_to_fun := Pi.uniform_continuous_proj _ _,\n  uniform_continuous_inv_fun := uniform_continuous_pi.mpr (λ _, uniform_continuous_id) }\n\n/-- Uniform isomorphism between dependent functions `Π i : fin 2, α i` and `α 0 × α 1`. -/\n@[simps { fully_applied := ff }]\ndef pi_fin_two (α : fin 2 → Type u) [Π i, uniform_space (α i)] : (Π i, α i) ≃ᵤ α 0 × α 1 :=\n{ to_equiv := pi_fin_two_equiv α,\n  uniform_continuous_to_fun :=\n    (Pi.uniform_continuous_proj _ 0).prod_mk (Pi.uniform_continuous_proj _ 1),\n  uniform_continuous_inv_fun := uniform_continuous_pi.mpr $\n    fin.forall_fin_two.2 ⟨uniform_continuous_fst, uniform_continuous_snd⟩ }\n\n/-- Uniform isomorphism between `α² = fin 2 → α` and `α × α`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 → α) ≃ᵤ α × α :=\n{ to_equiv := fin_two_arrow_equiv α, .. pi_fin_two (λ _, α) }\n\n/--\nA subset of a uniform space is uniformly isomorphic to its image under a uniform isomorphism.\n-/\ndef image (e : α ≃ᵤ β) (s : set α) : s ≃ᵤ e '' s :=\n{ uniform_continuous_to_fun :=\n    (e.uniform_continuous.comp uniform_continuous_subtype_val).subtype_mk _,\n  uniform_continuous_inv_fun :=\n    (e.symm.uniform_continuous.comp uniform_continuous_subtype_val).subtype_mk _,\n  to_equiv := e.to_equiv.image s }\n\nend uniform_equiv\n\n/-- A uniform inducing equiv between uniform spaces is a uniform isomorphism. -/\n@[simps] def equiv.to_uniform_equiv_of_uniform_inducing [uniform_space α] [uniform_space β]\n  (f : α ≃ β) (hf : uniform_inducing f) :\n  α ≃ᵤ β :=\n{ uniform_continuous_to_fun := hf.uniform_continuous,\n  uniform_continuous_inv_fun := hf.uniform_continuous_iff.2 $ by simpa using uniform_continuous_id,\n  .. f }\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/uniform_space/equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.72487026428967, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.49965714924215276}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport meta.univs\nimport tactic.lint\nimport tactic.ext\n\n/-!\n# Sigma types\n\nThis file proves basic results about sigma types.\n\nA sigma type is a dependent pair type. Like `α × β` but where the type of the second component\ndepends on the first component. This can be seen as a generalization of the sum type `α ⊕ β`:\n* `α ⊕ β` is made of stuff which is either of type `α` or `β`.\n* Given `α : ι → Type*`, `sigma α` is made of stuff which is of type `α i` for some `i : ι`. One\n  effectively recovers a type isomorphic to `α ⊕ β` by taking a `ι` with exactly two elements. See\n  `equiv.sum_equiv_sigma_bool`.\n\n`Σ x, A x` is notation for `sigma A` (note the difference with the big operator `∑`).\n`Σ x y z ..., A x y z ...` is notation for `Σ x, Σ y, Σ z, ..., A x y z ...`. Here we have\n`α : Type*`, `β : α → Type*`, `γ : Π a : α, β a → Type*`, ...,\n`A : Π (a : α) (b : β a) (c : γ a b) ..., Type*`  with `x : α` `y : β x`, `z : γ x y`, ...\n\n## Notes\n\nThe definition of `sigma` takes values in `Type*`. This effectively forbids `Prop`- valued sigma\ntypes. To that effect, we have `psigma`, which takes value in `Sort*` and carries a more complicated\nuniverse signature in consequence.\n-/\n\nsection sigma\nvariables {α α₁ α₂ : Type*} {β : α → Type*} {β₁ : α₁ → Type*} {β₂ : α₂ → Type*}\n\nnamespace sigma\n\ninstance [inhabited α] [inhabited (β default)] : inhabited (sigma β) :=\n⟨⟨default, default⟩⟩\n\ninstance [h₁ : decidable_eq α] [h₂ : ∀a, decidable_eq (β a)] : decidable_eq (sigma β)\n| ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ := match a₁, b₁, a₂, b₂, h₁ a₁ a₂ with\n  | _, b₁, _, b₂, is_true (eq.refl a) :=\n    match b₁, b₂, h₂ a b₁ b₂ with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b₁, b₂, is_false n := is_false (assume h, sigma.no_confusion h (λe₁ e₂, n $ eq_of_heq e₂))\n    end\n  | a₁, _, a₂, _, is_false n := is_false (assume h, sigma.no_confusion h (λe₁ e₂, n e₁))\n  end\n\n@[simp, nolint simp_nf] -- sometimes the built-in injectivity support does not work\ntheorem mk.inj_iff {a₁ a₂ : α} {b₁ : β a₁} {b₂ : β a₂} :\n  sigma.mk a₁ b₁ = ⟨a₂, b₂⟩ ↔ (a₁ = a₂ ∧ b₁ == b₂) :=\nby simp\n\n@[simp] theorem eta : ∀ x : Σ a, β a, sigma.mk x.1 x.2 = x\n| ⟨i, x⟩ := rfl\n\n@[ext]\nlemma ext {x₀ x₁ : sigma β} (h₀ : x₀.1 = x₁.1) (h₁ : x₀.2 == x₁.2) : x₀ = x₁ :=\nby { cases x₀, cases x₁, cases h₀, cases h₁, refl }\n\nlemma ext_iff {x₀ x₁ : sigma β} : x₀ = x₁ ↔ x₀.1 = x₁.1 ∧ x₀.2 == x₁.2 :=\nby { cases x₀, cases x₁, exact sigma.mk.inj_iff }\n\n/-- A specialized ext lemma for equality of sigma types over an indexed subtype. -/\n@[ext]\nlemma subtype_ext {β : Type*} {p : α → β → Prop} :\n  ∀ {x₀ x₁ : Σ a, subtype (p a)}, x₀.fst = x₁.fst → (x₀.snd : β) = x₁.snd → x₀ = x₁\n| ⟨a₀, b₀, hb₀⟩ ⟨a₁, b₁, hb₁⟩ rfl rfl := rfl\n\nlemma subtype_ext_iff {β : Type*} {p : α → β → Prop} {x₀ x₁ : Σ a, subtype (p a)} :\n  x₀ = x₁ ↔ x₀.fst = x₁.fst ∧ (x₀.snd : β) = x₁.snd :=\n⟨λ h, h ▸ ⟨rfl, rfl⟩, λ ⟨h₁, h₂⟩, subtype_ext h₁ h₂⟩\n\n@[simp] theorem «forall» {p : (Σ a, β a) → Prop} :\n  (∀ x, p x) ↔ (∀ a b, p ⟨a, b⟩) :=\n⟨assume h a b, h ⟨a, b⟩, assume h ⟨a, b⟩, h a b⟩\n\n@[simp] theorem «exists» {p : (Σ a, β a) → Prop} :\n  (∃ x, p x) ↔ (∃ a b, p ⟨a, b⟩) :=\n⟨assume ⟨⟨a, b⟩, h⟩, ⟨a, b, h⟩, assume ⟨a, b, h⟩, ⟨⟨a, b⟩, h⟩⟩\n\n/-- Map the left and right components of a sigma -/\ndef map (f₁ : α₁ → α₂) (f₂ : Πa, β₁ a → β₂ (f₁ a)) (x : sigma β₁) : sigma β₂ :=\n⟨f₁ x.1, f₂ x.1 x.2⟩\n\nend sigma\n\nlemma sigma_mk_injective {i : α} : function.injective (@sigma.mk α β i)\n| _ _ rfl := rfl\n\nlemma function.injective.sigma_map {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a → β₂ (f₁ a)}\n  (h₁ : function.injective f₁) (h₂ : ∀ a, function.injective (f₂ a)) :\n  function.injective (sigma.map f₁ f₂)\n| ⟨i, x⟩ ⟨j, y⟩ h :=\nbegin\n  obtain rfl : i = j, from h₁ (sigma.mk.inj_iff.mp h).1,\n  obtain rfl : x = y, from h₂ i (eq_of_heq (sigma.mk.inj_iff.mp h).2),\n  refl\nend\n\nlemma function.surjective.sigma_map {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a → β₂ (f₁ a)}\n  (h₁ : function.surjective f₁) (h₂ : ∀ a, function.surjective (f₂ a)) :\n  function.surjective (sigma.map f₁ f₂) :=\nbegin\n  intros y,\n  cases y with j y,\n  cases h₁ j with i hi,\n  subst j,\n  cases h₂ i y with x hx,\n  subst y,\n  exact ⟨⟨i, x⟩, rfl⟩\nend\n\n/-- Interpret a function on `Σ x : α, β x` as a dependent function with two arguments.\n\nThis also exists as an `equiv` as `equiv.Pi_curry γ`. -/\ndef sigma.curry {γ : Π a, β a → Type*} (f : Π x : sigma β, γ x.1 x.2) (x : α) (y : β x) : γ x y :=\nf ⟨x,y⟩\n\n/-- Interpret a dependent function with two arguments as a function on `Σ x : α, β x`.\n\nThis also exists as an `equiv` as `(equiv.Pi_curry γ).symm`. -/\ndef sigma.uncurry {γ : Π a, β a → Type*} (f : Π x (y : β x), γ x y) (x : sigma β) : γ x.1 x.2 :=\nf x.1 x.2\n\n@[simp]\nlemma sigma.uncurry_curry {γ : Π a, β a → Type*} (f : Π x : sigma β, γ x.1 x.2) :\n  sigma.uncurry (sigma.curry f) = f :=\nfunext $ λ ⟨i, j⟩, rfl\n\n@[simp]\nlemma sigma.curry_uncurry {γ : Π a, β a → Type*} (f : Π x (y : β x), γ x y) :\n  sigma.curry (sigma.uncurry f) = f :=\nrfl\n\n/-- Convert a product type to a Σ-type. -/\n@[simp]\ndef prod.to_sigma {α β} : α × β → Σ _ : α, β\n| ⟨x,y⟩ := ⟨x,y⟩\n\n@[simp]\nlemma prod.fst_to_sigma {α β} (x : α × β) : (prod.to_sigma x).fst = x.fst :=\nby cases x; refl\n\n@[simp]\nlemma prod.snd_to_sigma {α β} (x : α × β) : (prod.to_sigma x).snd = x.snd :=\nby cases x; refl\n\n-- we generate this manually as `@[derive has_reflect]` fails\n@[instance]\nprotected meta def {u v} sigma.reflect [reflected_univ.{u}] [reflected_univ.{v}]\n  {α : Type u} (β : α → Type v)\n  [reflected _ α] [reflected _ β] [hα : has_reflect α] [hβ : Π i, has_reflect (β i)] :\n  has_reflect (Σ a, β a) :=\nλ ⟨a, b⟩, (by reflect_name : reflected _ @sigma.mk.{u v}).subst₄ `(α) `(β) `(a) `(b)\n\nend sigma\n\nsection psigma\nvariables {α : Sort*} {β : α → Sort*}\n\nnamespace psigma\n\n/-- Nondependent eliminator for `psigma`. -/\ndef elim {γ} (f : ∀ a, β a → γ) (a : psigma β) : γ :=\npsigma.cases_on a f\n\n@[simp] theorem elim_val {γ} (f : ∀ a, β a → γ) (a b) : psigma.elim f ⟨a, b⟩ = f a b := rfl\n\ninstance [inhabited α] [inhabited (β default)] : inhabited (psigma β) :=\n⟨⟨default, default⟩⟩\n\ninstance [h₁ : decidable_eq α] [h₂ : ∀a, decidable_eq (β a)] : decidable_eq (psigma β)\n| ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ := match a₁, b₁, a₂, b₂, h₁ a₁ a₂ with\n  | _, b₁, _, b₂, is_true (eq.refl a) :=\n    match b₁, b₂, h₂ a b₁ b₂ with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b₁, b₂, is_false n := is_false (assume h, psigma.no_confusion h (λe₁ e₂, n $ eq_of_heq e₂))\n    end\n  | a₁, _, a₂, _, is_false n := is_false (assume h, psigma.no_confusion h (λe₁ e₂, n e₁))\n  end\n\ntheorem mk.inj_iff {a₁ a₂ : α} {b₁ : β a₁} {b₂ : β a₂} :\n  @psigma.mk α β a₁ b₁ = @psigma.mk α β a₂ b₂ ↔ (a₁ = a₂ ∧ b₁ == b₂) :=\niff.intro psigma.mk.inj $\n  assume ⟨h₁, h₂⟩, match a₁, a₂, b₁, b₂, h₁, h₂ with _, _, _, _, eq.refl a, heq.refl b := rfl end\n\n@[ext]\nlemma ext {x₀ x₁ : psigma β} (h₀ : x₀.1 = x₁.1) (h₁ : x₀.2 == x₁.2) : x₀ = x₁ :=\nby { cases x₀, cases x₁, cases h₀, cases h₁, refl }\n\nlemma ext_iff {x₀ x₁ : psigma β} : x₀ = x₁ ↔ x₀.1 = x₁.1 ∧ x₀.2 == x₁.2 :=\nby { cases x₀, cases x₁, exact psigma.mk.inj_iff }\n\n@[simp] theorem «forall» {p : (Σ' a, β a) → Prop} :\n  (∀ x, p x) ↔ (∀ a b, p ⟨a, b⟩) :=\n⟨assume h a b, h ⟨a, b⟩, assume h ⟨a, b⟩, h a b⟩\n\n@[simp] theorem «exists» {p : (Σ' a, β a) → Prop} :\n  (∃ x, p x) ↔ (∃ a b, p ⟨a, b⟩) :=\n⟨assume ⟨⟨a, b⟩, h⟩, ⟨a, b, h⟩, assume ⟨a, b, h⟩, ⟨⟨a, b⟩, h⟩⟩\n\n/-- A specialized ext lemma for equality of psigma types over an indexed subtype. -/\n@[ext]\nlemma subtype_ext {β : Sort*} {p : α → β → Prop} :\n  ∀ {x₀ x₁ : Σ' a, subtype (p a)}, x₀.fst = x₁.fst → (x₀.snd : β) = x₁.snd → x₀ = x₁\n| ⟨a₀, b₀, hb₀⟩ ⟨a₁, b₁, hb₁⟩ rfl rfl := rfl\n\nlemma subtype_ext_iff {β : Sort*} {p : α → β → Prop} {x₀ x₁ : Σ' a, subtype (p a)} :\n  x₀ = x₁ ↔ x₀.fst = x₁.fst ∧ (x₀.snd : β) = x₁.snd :=\n⟨λ h, h ▸ ⟨rfl, rfl⟩, λ ⟨h₁, h₂⟩, subtype_ext h₁ h₂⟩\n\nvariables {α₁ : Sort*} {α₂ : Sort*} {β₁ : α₁ → Sort*} {β₂ : α₂ → Sort*}\n\n/-- Map the left and right components of a sigma -/\ndef map (f₁ : α₁ → α₂) (f₂ : Πa, β₁ a → β₂ (f₁ a)) : psigma β₁ → psigma β₂\n| ⟨a, b⟩ := ⟨f₁ a, f₂ a b⟩\n\nend psigma\n\nend psigma\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/data/sigma/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.4996571487125616}}
{"text": "-- Copyright (c) 2017 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Stephen Morgan, Scott Morrison\n\nimport .cones\n\nopen category_theory\nopen category_theory.initial\n\nnamespace category_theory.universal\n\n/-\nWe give \"explicit\" definitions of (co)equalizers, and (finite) (co)products. Of course these are special cases of (co)limits,\nbut they are used so pervasively that they need a convenient interface.\n\nTODO: pullbacks and pushouts should be here too.\n-/\n\nuniverses u v w\nvariables {C : Type u} [𝒞 : category.{u v} C]\ninclude 𝒞\nvariables {X Y : C}\n\nstructure Equalizer (f g : X ⟶ Y) :=\n(equalizer     : C)\n(inclusion     : equalizer ⟶ X)\n(map           : ∀ {Z : C} (k : Z ⟶ X) (w : k ≫ f = k ≫ g), Z ⟶ equalizer)\n(witness       : inclusion ≫ f = inclusion ≫ g . obviously)\n(factorisation : ∀ {Z : C} (k : Z ⟶ X) (w : k ≫ f = k ≫ g), (map k w) ≫ inclusion = k . obviously)\n(uniqueness    : ∀ {Z : C} (a b : Z ⟶ equalizer) (witness : a ≫ inclusion = b ≫ inclusion), a = b . obviously)\n\nrestate_axiom Equalizer.witness\nrestate_axiom Equalizer.factorisation\nrestate_axiom Equalizer.uniqueness\nattribute [simp,ematch] Equalizer.factorisation_lemma\nattribute [back] Equalizer.inclusion Equalizer.map\nattribute [back] Equalizer.uniqueness_lemma\n\nstructure BinaryProduct (X Y : C) :=\n(product             : C)\n(left_projection     : product ⟶ X)\n(right_projection    : product ⟶ Y)\n(map                 : ∀ {Z : C} (f : Z ⟶ X) (g : Z ⟶ Y), Z ⟶ product)\n(left_factorisation  : ∀ {Z : C} (f : Z ⟶ X) (g : Z ⟶ Y), (map f g) ≫ left_projection  = f . obviously) \n(right_factorisation : ∀ {Z : C} (f : Z ⟶ X) (g : Z ⟶ Y), (map f g) ≫ right_projection = g . obviously) \n(uniqueness          : ∀ {Z : C} (f g : Z ⟶ product)\n                          (left_witness  : f ≫ left_projection  = g ≫ left_projection )\n                          (right_witness : f ≫ right_projection = g ≫ right_projection), f = g . obviously)\n\nrestate_axiom BinaryProduct.left_factorisation\nrestate_axiom BinaryProduct.right_factorisation\nrestate_axiom BinaryProduct.uniqueness\nattribute [simp,ematch] BinaryProduct.left_factorisation_lemma BinaryProduct.right_factorisation_lemma\nattribute [back] BinaryProduct.left_projection BinaryProduct.right_projection BinaryProduct.map\nattribute [back] BinaryProduct.uniqueness_lemma\n\nstructure Product {I : Type w} (F : I → C) :=\n(product       : C)\n(projection    : Π i : I, product ⟶ (F i))\n(map           : ∀ {Z : C} (f : Π i : I, Z ⟶ (F i)), Z ⟶ product)\n(factorisation : ∀ {Z : C} (f : Π i : I, Z ⟶ (F i)) (i : I), (map f) ≫ (projection i) = f i . obviously)\n(uniqueness    : ∀ {Z : C} (f g : Z ⟶ product) (witness : ∀ i : I, f ≫ (projection i) = g ≫ (projection i)), f = g . obviously)\n\nrestate_axiom Product.factorisation\nrestate_axiom Product.uniqueness\nattribute [simp,ematch] Product.factorisation_lemma\nattribute [back] Product.projection Product.map\nattribute [back] Product.uniqueness_lemma\n\nstructure Coequalizer (f g : X ⟶ Y) :=\n(coequalizer   : C)\n(projection    : Y ⟶ coequalizer)\n(map           : ∀ {Z : C} (k : Y ⟶ Z) (w : f ≫ k = g ≫ k), coequalizer ⟶ Z)\n(witness       : f ≫ projection = g ≫ projection . obviously)\n(factorisation : ∀ {Z : C} (k : Y ⟶ Z) (w : f ≫ k = g ≫ k), projection ≫ (map k w) = k . obviously)\n(uniqueness    : ∀ {Z : C} (a b : coequalizer ⟶ Z) (witness : projection ≫ a = projection ≫ b), a = b . obviously)\n\nrestate_axiom Coequalizer.witness\nrestate_axiom Coequalizer.factorisation\nrestate_axiom Coequalizer.uniqueness\nattribute [simp,ematch] Coequalizer.factorisation_lemma\nattribute [back] Coequalizer.projection Coequalizer.map\nattribute [back] Coequalizer.uniqueness_lemma\n\nstructure BinaryCoproduct (X Y : C) :=\n(coproduct           : C)\n(left_inclusion      : X ⟶ coproduct)\n(right_inclusion     : Y ⟶ coproduct)\n(map                 : ∀ {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z), coproduct ⟶ Z)\n(left_factorisation  : ∀ {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z), left_inclusion ≫ (map f g)  = f . obviously) \n(right_factorisation : ∀ {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z), right_inclusion ≫ (map f g) = g . obviously) \n(uniqueness          : ∀ {Z : C} (f g : coproduct ⟶ Z)\n                          (left_witness  : left_inclusion ≫ f = left_inclusion ≫ g)\n                          (right_witness : right_inclusion ≫ f = right_inclusion ≫ g), f = g . obviously)\n\nrestate_axiom BinaryCoproduct.left_factorisation\nrestate_axiom BinaryCoproduct.right_factorisation\nrestate_axiom BinaryCoproduct.uniqueness\nattribute [simp,ematch] BinaryCoproduct.left_factorisation_lemma BinaryCoproduct.right_factorisation_lemma\nattribute [back] BinaryCoproduct.left_inclusion BinaryCoproduct.right_inclusion BinaryCoproduct.map\nattribute [back] BinaryCoproduct.uniqueness_lemma\n\nstructure Coproduct {I : Type w} (X : I → C) :=\n(coproduct     : C)\n(inclusion     : Π i : I, (X i) ⟶ coproduct)\n(map           : ∀ {Z : C} (f : Π i : I, (X i) ⟶ Z), coproduct ⟶ Z)\n(factorisation : ∀ {Z : C} (f : Π i : I, (X i) ⟶ Z) (i : I), (inclusion i) ≫ (map f) = f i . obviously)\n(uniqueness    : ∀ {Z : C} (f g : coproduct ⟶ Z) (witness : ∀ i : I, (inclusion i) ≫ f = (inclusion i) ≫ g), f = g . obviously)\n\nrestate_axiom Coproduct.factorisation\nrestate_axiom Coproduct.uniqueness\nattribute [simp,ematch] Coproduct.factorisation_lemma\nattribute [back] Coproduct.inclusion Coproduct.map\nattribute [back] Coproduct.uniqueness_lemma\n\nstructure Pullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :=\n(pullback : C)\n(h : pullback ⟶ X)\n(k : pullback ⟶ Y)\n(commutativity : h ≫ f = k ≫ g)\n(map : ∀ {P} {h' : P ⟶ X} {k' : P ⟶ Y} (w : h' ≫ f = k' ≫ g), P ⟶ pullback)\n(factorisation : ∀ {P} {h' : P ⟶ X} {k' : P ⟶ Y} (w : h' ≫ f = k' ≫ g), (map w ≫ h) = h' ∧ (map w ≫ k) = k')\n(uniqueness : ∀ {P} {h' : P ⟶ X} {k' : P ⟶ Y} (w : h' ≫ f = k' ≫ g) (m n : P ⟶ pullback) (w' : (m ≫ h) = h' ∧ (m ≫ k) = k' ∧ (n ≫ h) = h' ∧ (n ≫ k) = k'), m = n)\n\n\n-- Coming in later PRs: all these things special cases of (co)limits, and hence are unique up to unique isomorphism.\n\nend category_theory.universal\n\n", "meta": {"author": "semorrison", "repo": "lean-category-theory-pr", "sha": "7adc8d91835e883db0fe75aa33661bc1480dbe55", "save_path": "github-repos/lean/semorrison-lean-category-theory-pr", "path": "github-repos/lean/semorrison-lean-category-theory-pr/lean-category-theory-pr-7adc8d91835e883db0fe75aa33661bc1480dbe55/src/categories/universal/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4996571481829703}}
{"text": "/-\nCopyright (c) 2022 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n\n! This file was ported from Lean 3 source module analysis.complex.abs_max\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.Complex.CauchyIntegral\nimport Mathbin.Analysis.NormedSpace.Completion\nimport Mathbin.Analysis.NormedSpace.Extr\nimport Mathbin.Topology.Algebra.Order.ExtrClosure\n\n/-!\n# Maximum modulus principle\n\nIn this file we prove several versions of the maximum modulus principle. There are several\nstatements that can be called \"the maximum modulus principle\" for maps between normed complex\nspaces. They differ by assumptions on the domain (any space, a nontrivial space, a finite\ndimensional space), assumptions on the codomain (any space, a strictly convex space), and by\nconclusion (either equality of norms or of the values of the function).\n\n## Main results\n\n### Theorems for any codomain\n\nConsider a function `f : E → F` that is complex differentiable on a set `s`, is continuous on its\nclosure, and `‖f x‖` has a maximum on `s` at `c`. We prove the following theorems.\n\n- `complex.norm_eq_on_closed_ball_of_is_max_on`: if `s = metric.ball c r`, then `‖f x‖ = ‖f c‖` for\n  any `x` from the corresponding closed ball;\n\n- `complex.norm_eq_norm_of_is_max_on_of_ball_subset`: if `metric.ball c (dist w c) ⊆ s`, then\n  `‖f w‖ = ‖f c‖`;\n\n- `complex.norm_eq_on_of_is_preconnected_of_is_max_on`: if `U` is an open (pre)connected set, `f` is\n  complex differentiable on `U`, and `‖f x‖` has a maximum on `U` at `c ∈ U`, then `‖f x‖ = ‖f c‖`\n  for all `x ∈ U`;\n\n- `complex.norm_eq_on_closure_of_is_preconnected_of_is_max_on`: if `s` is open and (pre)connected\n  and `c ∈ s`, then `‖f x‖ = ‖f c‖` for all `x ∈ closure s`;\n\n- `complex.norm_eventually_eq_of_is_local_max`: if `f` is complex differentiable in a neighborhood\n  of `c` and `‖f x‖` has a local maximum at `c`, then `‖f x‖` is locally a constant in a\n  neighborhood of `c`.\n\n### Theorems for a strictly convex codomain\n\nIf the codomain `F` is a strictly convex space, then in the lemmas from the previous section we can\nprove `f w = f c` instead of `‖f w‖ = ‖f c‖`, see\n`complex.eq_on_of_is_preconnected_of_is_max_on_norm`,\n`complex.eq_on_closure_of_is_preconnected_of_is_max_on_norm`,\n`complex.eq_of_is_max_on_of_ball_subset`, `complex.eq_on_closed_ball_of_is_max_on_norm`, and\n`complex.eventually_eq_of_is_local_max_norm`.\n\n### Values on the frontier\n\nFinally, we prove some corollaries that relate the (norm of the) values of a function on a set to\nits values on the frontier of the set. All these lemmas assume that `E` is a nontrivial space.  In\nthis section `f g : E → F` are functions that are complex differentiable on a bounded set `s` and\nare continuous on its closure. We prove the following theorems.\n\n- `complex.exists_mem_frontier_is_max_on_norm`: If `E` is a finite dimensional space and `s` is a\n  nonempty bounded set, then there exists a point `z ∈ frontier s` such that `λ z, ‖f z‖` takes it\n  maximum value on `closure s` at `z`.\n\n- `complex.norm_le_of_forall_mem_frontier_norm_le`: if `‖f z‖ ≤ C` for all `z ∈ frontier s`, then\n  `‖f z‖ ≤ C` for all `z ∈ s`; note that this theorem does not require `E` to be a finite\n  dimensional space.\n\n- `complex.eq_on_closure_of_eq_on_frontier`: if `f x = g x` on the frontier of `s`, then `f x = g x`\n  on `closure s`;\n\n- `complex.eq_on_of_eq_on_frontier`: if `f x = g x` on the frontier of `s`, then `f x = g x`\n  on `s`.\n\n## Tags\n\nmaximum modulus principle, complex analysis\n-/\n\n\nopen TopologicalSpace Metric Set Filter Asymptotics Function MeasureTheory AffineMap\n\nopen Topology Filter NNReal Real\n\nuniverse u v w\n\nvariable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] {F : Type v} [NormedAddCommGroup F]\n  [NormedSpace ℂ F]\n\n-- mathport name: «expr ̂»\nlocal postfix:100 \"̂\" => UniformSpace.Completion\n\nnamespace Complex\n\n/-!\n### Auxiliary lemmas\n\nWe split the proof into a series of lemmas. First we prove the principle for a function `f : ℂ → F`\nwith an additional assumption that `F` is a complete space, then drop unneeded assumptions one by\none.\n\nThe lemmas with names `*_auxₙ` are considered to be private and should not be used outside of this\nfile.\n-/\n\n\ntheorem norm_max_aux₁ [CompleteSpace F] {f : ℂ → F} {z w : ℂ}\n    (hd : DiffContOnCl ℂ f (ball z (dist w z)))\n    (hz : IsMaxOn (norm ∘ f) (closedBall z (dist w z)) z) : ‖f w‖ = ‖f z‖ :=\n  by\n  -- Consider a circle of radius `r = dist w z`.\n  set r : ℝ := dist w z\n  have hw : w ∈ closed_ball z r := mem_closed_ball.2 le_rfl\n  -- Assume the converse. Since `‖f w‖ ≤ ‖f z‖`, we have `‖f w‖ < ‖f z‖`.\n  refine' (isMaxOn_iff.1 hz _ hw).antisymm (not_lt.1 _)\n  rintro hw_lt : ‖f w‖ < ‖f z‖\n  have hr : 0 < r := dist_pos.2 (ne_of_apply_ne (norm ∘ f) hw_lt.ne)\n  -- Due to Cauchy integral formula, it suffices to prove the following inequality.\n  suffices ‖∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ‖ < 2 * π * ‖f z‖\n    by\n    refine' this.ne _\n    have A : (∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ) = (2 * π * I : ℂ) • f z :=\n      hd.circle_integral_sub_inv_smul (mem_ball_self hr)\n    simp [A, norm_smul, real.pi_pos.le]\n  suffices ‖∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ‖ < 2 * π * r * (‖f z‖ / r) by\n    rwa [mul_assoc, mul_div_cancel' _ hr.ne'] at this\n  /- This inequality is true because `‖(ζ - z)⁻¹ • f ζ‖ ≤ ‖f z‖ / r` for all `ζ` on the circle and\n    this inequality is strict at `ζ = w`. -/\n  have hsub : sphere z r ⊆ closed_ball z r := sphere_subset_closed_ball\n  refine' circleIntegral.norm_integral_lt_of_norm_le_const_of_lt hr _ _ ⟨w, rfl, _⟩\n  show ContinuousOn (fun ζ : ℂ => (ζ - z)⁻¹ • f ζ) (sphere z r)\n  · refine'\n      ((continuous_on_id.sub continuousOn_const).inv₀ _).smul (hd.continuous_on_ball.mono hsub)\n    exact fun ζ hζ => sub_ne_zero.2 (ne_of_mem_sphere hζ hr.ne')\n  show ∀ ζ ∈ sphere z r, ‖(ζ - z)⁻¹ • f ζ‖ ≤ ‖f z‖ / r\n  · rintro ζ (hζ : abs (ζ - z) = r)\n    rw [le_div_iff hr, norm_smul, norm_inv, norm_eq_abs, hζ, mul_comm, mul_inv_cancel_left₀ hr.ne']\n    exact hz (hsub hζ)\n  show ‖(w - z)⁻¹ • f w‖ < ‖f z‖ / r\n  · rw [norm_smul, norm_inv, norm_eq_abs, ← div_eq_inv_mul]\n    exact (div_lt_div_right hr).2 hw_lt\n#align complex.norm_max_aux₁ Complex.norm_max_aux₁\n\n/-!\nNow we drop the assumption `complete_space F` by embedding `F` into its completion.\n-/\n\n\ntheorem norm_max_aux₂ {f : ℂ → F} {z w : ℂ} (hd : DiffContOnCl ℂ f (ball z (dist w z)))\n    (hz : IsMaxOn (norm ∘ f) (closedBall z (dist w z)) z) : ‖f w‖ = ‖f z‖ :=\n  by\n  set e : F →L[ℂ] F̂ := UniformSpace.Completion.toComplL\n  have he : ∀ x, ‖e x‖ = ‖x‖ := UniformSpace.Completion.norm_coe\n  replace hz : IsMaxOn (norm ∘ e ∘ f) (closed_ball z (dist w z)) z\n  · simpa only [IsMaxOn, (· ∘ ·), he] using hz\n  simpa only [he] using norm_max_aux₁ (e.differentiable.comp_diff_cont_on_cl hd) hz\n#align complex.norm_max_aux₂ Complex.norm_max_aux₂\n\n/-!\nThen we replace the assumption `is_max_on (norm ∘ f) (closed_ball z r) z` with a seemingly weaker\nassumption `is_max_on (norm ∘ f) (ball z r) z`.\n-/\n\n\ntheorem norm_max_aux₃ {f : ℂ → F} {z w : ℂ} {r : ℝ} (hr : dist w z = r)\n    (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) : ‖f w‖ = ‖f z‖ :=\n  by\n  subst r\n  rcases eq_or_ne w z with (rfl | hne); · rfl\n  rw [← dist_ne_zero] at hne\n  exact norm_max_aux₂ hd (closure_ball z hne ▸ hz.closure hd.continuous_on.norm)\n#align complex.norm_max_aux₃ Complex.norm_max_aux₃\n\n/-!\n### Maximum modulus principle for any codomain\n\nIf we do not assume that the codomain is a strictly convex space, then we can only claim that the\n**norm** `‖f x‖` is locally constant.\n-/\n\n\n/-!\nFinally, we generalize the theorem from a disk in `ℂ` to a closed ball in any normed space.\n-/\n\n\n/-- **Maximum modulus principle** on a closed ball: if `f : E → F` is continuous on a closed ball,\nis complex differentiable on the corresponding open ball, and the norm `‖f w‖` takes its maximum\nvalue on the open ball at its center, then the norm `‖f w‖` is constant on the closed ball.  -/\ntheorem norm_eqOn_closedBall_of_isMaxOn {f : E → F} {z : E} {r : ℝ}\n    (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) :\n    EqOn (norm ∘ f) (const E ‖f z‖) (closedBall z r) :=\n  by\n  intro w hw\n  rw [mem_closed_ball, dist_comm] at hw\n  rcases eq_or_ne z w with (rfl | hne)\n  · rfl\n  set e : ℂ → E := line_map z w\n  have hde : Differentiable ℂ e := (differentiable_id.smul_const (w - z)).AddConst z\n  suffices ‖(f ∘ e) (1 : ℂ)‖ = ‖(f ∘ e) (0 : ℂ)‖ by simpa [e]\n  have hr : dist (1 : ℂ) 0 = 1 := by simp\n  have hball : maps_to e (ball 0 1) (ball z r) :=\n    by\n    refine'\n      ((lipschitzWith_lineMap z w).mapsTo_ball (mt nndist_eq_zero.1 hne) 0 1).mono subset.rfl _\n    simpa only [line_map_apply_zero, mul_one, coe_nndist] using ball_subset_ball hw\n  exact\n    norm_max_aux₃ hr (hd.comp hde.diff_cont_on_cl hball)\n      (hz.comp_maps_to hball (line_map_apply_zero z w))\n#align complex.norm_eq_on_closed_ball_of_is_max_on Complex.norm_eqOn_closedBall_of_isMaxOn\n\n/-- **Maximum modulus principle**: if `f : E → F` is complex differentiable on a set `s`, the norm\nof `f` takes it maximum on `s` at `z`, and `w` is a point such that the closed ball with center `z`\nand radius `dist w z` is included in `s`, then `‖f w‖ = ‖f z‖`. -/\ntheorem norm_eq_norm_of_isMaxOn_of_ball_subset {f : E → F} {s : Set E} {z w : E}\n    (hd : DiffContOnCl ℂ f s) (hz : IsMaxOn (norm ∘ f) s z) (hsub : ball z (dist w z) ⊆ s) :\n    ‖f w‖ = ‖f z‖ :=\n  norm_eqOn_closedBall_of_isMaxOn (hd.mono hsub) (hz.on_subset hsub) (mem_closedBall.2 le_rfl)\n#align complex.norm_eq_norm_of_is_max_on_of_ball_subset Complex.norm_eq_norm_of_isMaxOn_of_ball_subset\n\n/-- **Maximum modulus principle**: if `f : E → F` is complex differentiable in a neighborhood of `c`\nand the norm `‖f z‖` has a local maximum at `c`, then `‖f z‖` is locally constant in a neighborhood\nof `c`. -/\ntheorem norm_eventually_eq_of_isLocalMax {f : E → F} {c : E}\n    (hd : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f z) (hc : IsLocalMax (norm ∘ f) c) :\n    ∀ᶠ y in 𝓝 c, ‖f y‖ = ‖f c‖ :=\n  by\n  rcases nhds_basis_closed_ball.eventually_iff.1 (hd.and hc) with ⟨r, hr₀, hr⟩\n  exact\n    nhds_basis_closed_ball.eventually_iff.2\n      ⟨r, hr₀,\n        norm_eq_on_closed_ball_of_is_max_on\n          (DifferentiableOn.diffContOnCl fun x hx =>\n            (hr <| closure_ball_subset_closed_ball hx).1.DifferentiableWithinAt)\n          fun x hx => (hr <| ball_subset_closed_ball hx).2⟩\n#align complex.norm_eventually_eq_of_is_local_max Complex.norm_eventually_eq_of_isLocalMax\n\ntheorem isOpen_setOf_mem_nhds_and_isMaxOn_norm {f : E → F} {s : Set E}\n    (hd : DifferentiableOn ℂ f s) : IsOpen { z | s ∈ 𝓝 z ∧ IsMaxOn (norm ∘ f) s z } :=\n  by\n  refine' isOpen_iff_mem_nhds.2 fun z hz => (eventually_eventually_nhds.2 hz.1).And _\n  replace hd : ∀ᶠ w in 𝓝 z, DifferentiableAt ℂ f w; exact hd.eventually_differentiable_at hz.1\n  exact\n    (norm_eventually_eq_of_is_local_max hd <| hz.2.IsLocalMax hz.1).mono fun x hx y hy =>\n      le_trans (hz.2 hy) hx.ge\n#align complex.is_open_set_of_mem_nhds_and_is_max_on_norm Complex.isOpen_setOf_mem_nhds_and_isMaxOn_norm\n\n/-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a\ncomplex normed space. Let `f : E → F` be a function that is complex differentiable on `U`. Suppose\nthat `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then `‖f x‖ = ‖f c‖` for all `x ∈ U`. -/\ntheorem norm_eqOn_of_isPreconnected_of_isMaxOn {f : E → F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DifferentiableOn ℂ f U) (hcU : c ∈ U)\n    (hm : IsMaxOn (norm ∘ f) U c) : EqOn (norm ∘ f) (const E ‖f c‖) U :=\n  by\n  set V := U ∩ { z | IsMaxOn (norm ∘ f) U z }\n  have hV : ∀ x ∈ V, ‖f x‖ = ‖f c‖ := fun x hx => le_antisymm (hm hx.1) (hx.2 hcU)\n  suffices : U ⊆ V\n  exact fun x hx => hV x (this hx)\n  have hVo : IsOpen V := by\n    simpa only [ho.mem_nhds_iff, set_of_and, set_of_mem_eq] using\n      is_open_set_of_mem_nhds_and_is_max_on_norm hd\n  have hVne : (U ∩ V).Nonempty := ⟨c, hcU, hcU, hm⟩\n  set W := U ∩ { z | ‖f z‖ ≠ ‖f c‖ }\n  have hWo : IsOpen W := hd.continuous_on.norm.preimage_open_of_open ho isOpen_ne\n  have hdVW : Disjoint V W := disjoint_left.mpr fun x hxV hxW => hxW.2 (hV x hxV)\n  have hUVW : U ⊆ V ∪ W := fun x hx =>\n    (eq_or_ne ‖f x‖ ‖f c‖).imp (fun h => ⟨hx, fun y hy => (hm hy).out.trans_eq h.symm⟩)\n      (And.intro hx)\n  exact hc.subset_left_of_subset_union hVo hWo hdVW hUVW hVne\n#align complex.norm_eq_on_of_is_preconnected_of_is_max_on Complex.norm_eqOn_of_isPreconnected_of_isMaxOn\n\n/-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a\ncomplex normed space.  Let `f : E → F` be a function that is complex differentiable on `U` and is\ncontinuous on its closure. Suppose that `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then\n`‖f x‖ = ‖f c‖` for all `x ∈ closure U`. -/\ntheorem norm_eqOn_closure_of_isPreconnected_of_isMaxOn {f : E → F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DiffContOnCl ℂ f U) (hcU : c ∈ U)\n    (hm : IsMaxOn (norm ∘ f) U c) : EqOn (norm ∘ f) (const E ‖f c‖) (closure U) :=\n  (norm_eqOn_of_isPreconnected_of_isMaxOn hc ho hd.DifferentiableOn hcU hm).of_subset_closure\n    hd.ContinuousOn.norm continuousOn_const subset_closure Subset.rfl\n#align complex.norm_eq_on_closure_of_is_preconnected_of_is_max_on Complex.norm_eqOn_closure_of_isPreconnected_of_isMaxOn\n\nsection StrictConvex\n\n/-!\n### The case of a strictly convex codomain\n\nIf the codomain `F` is a strictly convex space, then we can claim equalities like `f w = f z`\ninstead of `‖f w‖ = ‖f z‖`.\n\nInstead of repeating the proof starting with lemmas about integrals, we apply a corresponding lemma\nabove twice: for `f` and for `λ x, f x + f c`.  Then we have `‖f w‖ = ‖f z‖` and\n`‖f w + f z‖ = ‖f z + f z‖`, thus `‖f w + f z‖ = ‖f w‖ + ‖f z‖`. This is only possible if\n`f w = f z`, see `eq_of_norm_eq_of_norm_add_eq`.\n-/\n\n\nvariable [StrictConvexSpace ℝ F]\n\n/-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a\ncomplex normed space.  Let `f : E → F` be a function that is complex differentiable on `U`. Suppose\nthat `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then `f x = f c` for all `x ∈ U`.\n\nTODO: change assumption from `is_max_on` to `is_local_max`. -/\ntheorem eqOn_of_isPreconnected_of_isMaxOn_norm {f : E → F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DifferentiableOn ℂ f U) (hcU : c ∈ U)\n    (hm : IsMaxOn (norm ∘ f) U c) : EqOn f (const E (f c)) U := fun x hx =>\n  have H₁ : ‖f x‖ = ‖f c‖ := norm_eqOn_of_isPreconnected_of_isMaxOn hc ho hd hcU hm hx\n  have H₂ : ‖f x + f c‖ = ‖f c + f c‖ :=\n    norm_eqOn_of_isPreconnected_of_isMaxOn hc ho (hd.AddConst _) hcU hm.norm_add_self hx\n  eq_of_norm_eq_of_norm_add_eq H₁ <| by simp only [H₂, same_ray.rfl.norm_add, H₁]\n#align complex.eq_on_of_is_preconnected_of_is_max_on_norm Complex.eqOn_of_isPreconnected_of_isMaxOn_norm\n\n/-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a\ncomplex normed space.  Let `f : E → F` be a function that is complex differentiable on `U` and is\ncontinuous on its closure. Suppose that `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then\n`f x = f c` for all `x ∈ closure U`. -/\ntheorem eqOn_closure_of_isPreconnected_of_isMaxOn_norm {f : E → F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DiffContOnCl ℂ f U) (hcU : c ∈ U)\n    (hm : IsMaxOn (norm ∘ f) U c) : EqOn f (const E (f c)) (closure U) :=\n  (eqOn_of_isPreconnected_of_isMaxOn_norm hc ho hd.DifferentiableOn hcU hm).of_subset_closure\n    hd.ContinuousOn continuousOn_const subset_closure Subset.rfl\n#align complex.eq_on_closure_of_is_preconnected_of_is_max_on_norm Complex.eqOn_closure_of_isPreconnected_of_isMaxOn_norm\n\n/-- **Maximum modulus principle**. Let `f : E → F` be a function between complex normed spaces.\nSuppose that the codomain `F` is a strictly convex space, `f` is complex differentiable on a set\n`s`, `f` is continuous on the closure of `s`, the norm of `f` takes it maximum on `s` at `z`, and\n`w` is a point such that the closed ball with center `z` and radius `dist w z` is included in `s`,\nthen `f w = f z`. -/\ntheorem eq_of_isMaxOn_of_ball_subset {f : E → F} {s : Set E} {z w : E} (hd : DiffContOnCl ℂ f s)\n    (hz : IsMaxOn (norm ∘ f) s z) (hsub : ball z (dist w z) ⊆ s) : f w = f z :=\n  have H₁ : ‖f w‖ = ‖f z‖ := norm_eq_norm_of_isMaxOn_of_ball_subset hd hz hsub\n  have H₂ : ‖f w + f z‖ = ‖f z + f z‖ :=\n    norm_eq_norm_of_isMaxOn_of_ball_subset (hd.AddConst _) hz.norm_add_self hsub\n  eq_of_norm_eq_of_norm_add_eq H₁ <| by simp only [H₂, same_ray.rfl.norm_add, H₁]\n#align complex.eq_of_is_max_on_of_ball_subset Complex.eq_of_isMaxOn_of_ball_subset\n\n/-- **Maximum modulus principle** on a closed ball. Suppose that a function `f : E → F` from a\nnormed complex space to a strictly convex normed complex space has the following properties:\n\n- it is continuous on a closed ball `metric.closed_ball z r`,\n- it is complex differentiable on the corresponding open ball;\n- the norm `‖f w‖` takes its maximum value on the open ball at its center.\n\nThen `f` is a constant on the closed ball.  -/\ntheorem eqOn_closedBall_of_isMaxOn_norm {f : E → F} {z : E} {r : ℝ}\n    (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) :\n    EqOn f (const E (f z)) (closedBall z r) := fun x hx =>\n  eq_of_isMaxOn_of_ball_subset hd hz <| ball_subset_ball hx\n#align complex.eq_on_closed_ball_of_is_max_on_norm Complex.eqOn_closedBall_of_isMaxOn_norm\n\n/-- **Maximum modulus principle**: if `f : E → F` is complex differentiable in a neighborhood of `c`\nand the norm `‖f z‖` has a local maximum at `c`, then `f` is locally constant in a neighborhood\nof `c`. -/\ntheorem eventually_eq_of_isLocalMax_norm {f : E → F} {c : E}\n    (hd : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f z) (hc : IsLocalMax (norm ∘ f) c) :\n    ∀ᶠ y in 𝓝 c, f y = f c :=\n  by\n  rcases nhds_basis_closed_ball.eventually_iff.1 (hd.and hc) with ⟨r, hr₀, hr⟩\n  exact\n    nhds_basis_closed_ball.eventually_iff.2\n      ⟨r, hr₀,\n        eq_on_closed_ball_of_is_max_on_norm\n          (DifferentiableOn.diffContOnCl fun x hx =>\n            (hr <| closure_ball_subset_closed_ball hx).1.DifferentiableWithinAt)\n          fun x hx => (hr <| ball_subset_closed_ball hx).2⟩\n#align complex.eventually_eq_of_is_local_max_norm Complex.eventually_eq_of_isLocalMax_norm\n\ntheorem eventually_eq_or_eq_zero_of_isLocalMin_norm {f : E → ℂ} {c : E}\n    (hf : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f z) (hc : IsLocalMin (norm ∘ f) c) :\n    (∀ᶠ z in 𝓝 c, f z = f c) ∨ f c = 0 :=\n  by\n  refine' or_iff_not_imp_right.mpr fun h => _\n  have h1 : ∀ᶠ z in 𝓝 c, f z ≠ 0 := hf.self_of_nhds.continuous_at.eventually_ne h\n  have h2 : IsLocalMax (norm ∘ f)⁻¹ c := hc.inv (h1.mono fun z => norm_pos_iff.mpr)\n  have h3 : IsLocalMax (norm ∘ f⁻¹) c := by refine' h2.congr (eventually_of_forall _) <;> simp\n  have h4 : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f⁻¹ z := by filter_upwards [hf, h1]with z h using h.inv\n  filter_upwards [eventually_eq_of_is_local_max_norm h4 h3]with z using inv_inj.mp\n#align complex.eventually_eq_or_eq_zero_of_is_local_min_norm Complex.eventually_eq_or_eq_zero_of_isLocalMin_norm\n\nend StrictConvex\n\n/-!\n### Maximum on a set vs maximum on its frontier\n\nIn this section we prove corollaries of the maximum modulus principle that relate the values of a\nfunction on a set to its values on the frontier of this set.\n-/\n\n\nvariable [Nontrivial E]\n\n/-- **Maximum modulus principle**: if `f : E → F` is complex differentiable on a nonempty bounded\nset `U` and is continuous on its closure, then there exists a point `z ∈ frontier U` such that\n`λ z, ‖f z‖` takes it maximum value on `closure U` at `z`. -/\ntheorem exists_mem_frontier_isMaxOn_norm [FiniteDimensional ℂ E] {f : E → F} {U : Set E}\n    (hb : Bounded U) (hne : U.Nonempty) (hd : DiffContOnCl ℂ f U) :\n    ∃ z ∈ frontier U, IsMaxOn (norm ∘ f) (closure U) z :=\n  by\n  have hc : IsCompact (closure U) := hb.is_compact_closure\n  obtain ⟨w, hwU, hle⟩ : ∃ w ∈ closure U, IsMaxOn (norm ∘ f) (closure U) w\n  exact hc.exists_forall_ge hne.closure hd.continuous_on.norm\n  rw [closure_eq_interior_union_frontier, mem_union] at hwU\n  cases hwU\n  rotate_left\n  · exact ⟨w, hwU, hle⟩\n  have : interior U ≠ univ := ne_top_of_le_ne_top hc.ne_univ interior_subset_closure\n  rcases exists_mem_frontier_infDist_compl_eq_dist hwU this with ⟨z, hzU, hzw⟩\n  refine' ⟨z, frontier_interior_subset hzU, fun x hx => (mem_set_of_eq.mp <| hle hx).trans_eq _⟩\n  refine' (norm_eq_norm_of_is_max_on_of_ball_subset hd (hle.on_subset subset_closure) _).symm\n  rw [dist_comm, ← hzw]\n  exact ball_inf_dist_compl_subset.trans interior_subset\n#align complex.exists_mem_frontier_is_max_on_norm Complex.exists_mem_frontier_isMaxOn_norm\n\n/-- **Maximum modulus principle**: if `f : E → F` is complex differentiable on a bounded set `U` and\n`‖f z‖ ≤ C` for any `z ∈ frontier U`, then the same is true for any `z ∈ closure U`. -/\ntheorem norm_le_of_forall_mem_frontier_norm_le {f : E → F} {U : Set E} (hU : Bounded U)\n    (hd : DiffContOnCl ℂ f U) {C : ℝ} (hC : ∀ z ∈ frontier U, ‖f z‖ ≤ C) {z : E}\n    (hz : z ∈ closure U) : ‖f z‖ ≤ C :=\n  by\n  rw [closure_eq_self_union_frontier, union_comm, mem_union] at hz\n  cases hz\n  · exact hC z hz\n  /- In case of a finite dimensional domain, one can just apply\n    `complex.exists_mem_frontier_is_max_on_norm`. To make it work in any Banach space, we restrict\n    the function to a line first. -/\n  rcases exists_ne z with ⟨w, hne⟩\n  set e : ℂ → E := line_map z w\n  have hde : Differentiable ℂ e := (differentiable_id.smul_const (w - z)).AddConst z\n  have hL : AntilipschitzWith (nndist z w)⁻¹ e := antilipschitzWith_lineMap hne.symm\n  replace hd : DiffContOnCl ℂ (f ∘ e) (e ⁻¹' U)\n  exact hd.comp hde.diff_cont_on_cl (maps_to_preimage _ _)\n  have h₀ : (0 : ℂ) ∈ e ⁻¹' U := by simpa only [e, mem_preimage, line_map_apply_zero]\n  rcases exists_mem_frontier_is_max_on_norm (hL.bounded_preimage hU) ⟨0, h₀⟩ hd with ⟨ζ, hζU, hζ⟩\n  calc\n    ‖f z‖ = ‖f (e 0)‖ := by simp only [e, line_map_apply_zero]\n    _ ≤ ‖f (e ζ)‖ := (hζ (subset_closure h₀))\n    _ ≤ C := hC _ (hde.continuous.frontier_preimage_subset _ hζU)\n    \n#align complex.norm_le_of_forall_mem_frontier_norm_le Complex.norm_le_of_forall_mem_frontier_norm_le\n\n/-- If two complex differentiable functions `f g : E → F` are equal on the boundary of a bounded set\n`U`, then they are equal on `closure U`. -/\ntheorem eqOn_closure_of_eqOn_frontier {f g : E → F} {U : Set E} (hU : Bounded U)\n    (hf : DiffContOnCl ℂ f U) (hg : DiffContOnCl ℂ g U) (hfg : EqOn f g (frontier U)) :\n    EqOn f g (closure U) :=\n  by\n  suffices H : ∀ z ∈ closure U, ‖(f - g) z‖ ≤ 0; · simpa [sub_eq_zero] using H\n  refine' fun z hz => norm_le_of_forall_mem_frontier_norm_le hU (hf.sub hg) (fun w hw => _) hz\n  simp [hfg hw]\n#align complex.eq_on_closure_of_eq_on_frontier Complex.eqOn_closure_of_eqOn_frontier\n\n/-- If two complex differentiable functions `f g : E → F` are equal on the boundary of a bounded set\n`U`, then they are equal on `U`. -/\ntheorem eqOn_of_eqOn_frontier {f g : E → F} {U : Set E} (hU : Bounded U) (hf : DiffContOnCl ℂ f U)\n    (hg : DiffContOnCl ℂ g U) (hfg : EqOn f g (frontier U)) : EqOn f g U :=\n  (eqOn_closure_of_eqOn_frontier hU hf hg hfg).mono subset_closure\n#align complex.eq_on_of_eq_on_frontier Complex.eqOn_of_eqOn_frontier\n\nend Complex\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Analysis/Complex/AbsMax.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4996571481829703}}
{"text": "/-\nCopyright (c) 2020 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Aaron Anderson\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.finset.fold\nimport Mathlib.data.multiset.gcd\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# GCD and LCM operations on finsets\n\n## Main definitions\n\n- `finset.gcd` - the greatest common denominator of a `finset` of elements of a `gcd_monoid`\n- `finset.lcm` - the least common multiple of a `finset` of elements of a `gcd_monoid`\n\n## Implementation notes\n\nMany of the proofs use the lemmas `gcd.def` and `lcm.def`, which relate `finset.gcd`\nand `finset.lcm` to `multiset.gcd` and `multiset.lcm`.\n\nTODO: simplify with a tactic and `data.finset.lattice`\n\n## Tags\n\nfinset, gcd\n-/\n\nnamespace finset\n\n\n/-! ### lcm -/\n\n/-- Least common multiple of a finite set -/\ndef lcm {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (s : finset β) (f : β → α) : α :=\n  fold lcm 1 f s\n\ntheorem lcm_def {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} : lcm s f = multiset.lcm (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem lcm_empty {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {f : β → α} : lcm ∅ f = 1 :=\n  fold_empty\n\n@[simp] theorem lcm_dvd_iff {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {a : α} : lcm s f ∣ a ↔ ∀ (b : β), b ∈ s → f b ∣ a := sorry\n\ntheorem lcm_dvd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {a : α} : (∀ (b : β), b ∈ s → f b ∣ a) → lcm s f ∣ a :=\n  iff.mpr lcm_dvd_iff\n\ntheorem dvd_lcm {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {b : β} (hb : b ∈ s) : f b ∣ lcm s f :=\n  iff.mp lcm_dvd_iff (dvd_refl (lcm s f)) b hb\n\n@[simp] theorem lcm_insert {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} [DecidableEq β] {b : β} : lcm (insert b s) f = lcm (f b) (lcm s f) := sorry\n\n@[simp] theorem lcm_singleton {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {f : β → α} {b : β} : lcm (singleton b) f = coe_fn normalize (f b) :=\n  multiset.lcm_singleton\n\n@[simp] theorem normalize_lcm {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} : coe_fn normalize (lcm s f) = lcm s f := sorry\n\ntheorem lcm_union {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} [DecidableEq β] : lcm (s₁ ∪ s₂) f = lcm (lcm s₁ f) (lcm s₂ f) := sorry\n\ntheorem lcm_congr {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} {g : β → α} (hs : s₁ = s₂) (hfg : ∀ (a : β), a ∈ s₂ → f a = g a) : lcm s₁ f = lcm s₂ g :=\n  Eq._oldrec (fun (hfg : ∀ (a : β), a ∈ s₁ → f a = g a) => fold_congr hfg) hs hfg\n\ntheorem lcm_mono_fun {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {g : β → α} (h : ∀ (b : β), b ∈ s → f b ∣ g b) : lcm s f ∣ lcm s g :=\n  lcm_dvd fun (b : β) (hb : b ∈ s) => dvd_trans (h b hb) (dvd_lcm hb)\n\ntheorem lcm_mono {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} (h : s₁ ⊆ s₂) : lcm s₁ f ∣ lcm s₂ f :=\n  lcm_dvd fun (b : β) (hb : b ∈ s₁) => dvd_lcm (h hb)\n\n/-! ### gcd -/\n\n/-- Greatest common divisor of a finite set -/\ndef gcd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] (s : finset β) (f : β → α) : α :=\n  fold gcd 0 f s\n\ntheorem gcd_def {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} : gcd s f = multiset.gcd (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem gcd_empty {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {f : β → α} : gcd ∅ f = 0 :=\n  fold_empty\n\ntheorem dvd_gcd_iff {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {a : α} : a ∣ gcd s f ↔ ∀ (b : β), b ∈ s → a ∣ f b := sorry\n\ntheorem gcd_dvd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {b : β} (hb : b ∈ s) : gcd s f ∣ f b :=\n  iff.mp dvd_gcd_iff (dvd_refl (gcd s f)) b hb\n\ntheorem dvd_gcd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {a : α} : (∀ (b : β), b ∈ s → a ∣ f b) → a ∣ gcd s f :=\n  iff.mpr dvd_gcd_iff\n\n@[simp] theorem gcd_insert {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} [DecidableEq β] {b : β} : gcd (insert b s) f = gcd (f b) (gcd s f) := sorry\n\n@[simp] theorem gcd_singleton {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {f : β → α} {b : β} : gcd (singleton b) f = coe_fn normalize (f b) :=\n  multiset.gcd_singleton\n\n@[simp] theorem normalize_gcd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} : coe_fn normalize (gcd s f) = gcd s f := sorry\n\ntheorem gcd_union {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} [DecidableEq β] : gcd (s₁ ∪ s₂) f = gcd (gcd s₁ f) (gcd s₂ f) := sorry\n\ntheorem gcd_congr {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} {g : β → α} (hs : s₁ = s₂) (hfg : ∀ (a : β), a ∈ s₂ → f a = g a) : gcd s₁ f = gcd s₂ g :=\n  Eq._oldrec (fun (hfg : ∀ (a : β), a ∈ s₁ → f a = g a) => fold_congr hfg) hs hfg\n\ntheorem gcd_mono_fun {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {g : β → α} (h : ∀ (b : β), b ∈ s → f b ∣ g b) : gcd s f ∣ gcd s g :=\n  dvd_gcd fun (b : β) (hb : b ∈ s) => dvd_trans (gcd_dvd hb) (h b hb)\n\ntheorem gcd_mono {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} (h : s₁ ⊆ s₂) : gcd s₂ f ∣ gcd s₁ f :=\n  dvd_gcd fun (b : β) (hb : b ∈ s₁) => gcd_dvd (h hb)\n\ntheorem gcd_eq_zero_iff {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} : gcd s f = 0 ↔ ∀ (x : β), x ∈ s → f x = 0 := sorry\n\ntheorem gcd_eq_gcd_filter_ne_zero {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} [decidable_pred fun (x : β) => f x = 0] : gcd s f = gcd (filter (fun (x : β) => f x ≠ 0) s) f := sorry\n\ntheorem gcd_mul_left {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {a : α} : (gcd s fun (x : β) => a * f x) = coe_fn normalize a * gcd s f := sorry\n\ntheorem gcd_mul_right {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {a : α} : (gcd s fun (x : β) => f x * a) = gcd s f * coe_fn normalize a := sorry\n\nend finset\n\n\nnamespace finset\n\n\ntheorem gcd_eq_of_dvd_sub {α : Type u_1} {β : Type u_2} [nontrivial β] [integral_domain α] [gcd_monoid α] {s : finset β} {f : β → α} {g : β → α} {a : α} (h : ∀ (x : β), x ∈ s → a ∣ f x - g x) : gcd a (gcd s f) = gcd a (gcd s g) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/finset/gcd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.4996571481829702}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.groupoid\nimport Mathlib.control.equiv_functor\nimport Mathlib.category_theory.types\nimport Mathlib.PostPort\n\nuniverses u₁ v₁ u₂ v₂ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/-- The core of a category C is the groupoid whose morphisms are all the\nisomorphisms of C. -/\ndef core (C : Type u₁) := C\n\nprotected instance core_category {C : Type u₁} [category C] : groupoid (core C) :=\n  groupoid.mk fun (X Y : core C) (f : X ⟶ Y) => iso.symm f\n\nnamespace core\n\n\n@[simp] theorem id_hom {C : Type u₁} [category C] (X : core C) : iso.hom 𝟙 = 𝟙 := rfl\n\n@[simp] theorem comp_hom {C : Type u₁} [category C] {X : core C} {Y : core C} {Z : core C}\n    (f : X ⟶ Y) (g : Y ⟶ Z) : iso.hom (f ≫ g) = iso.hom f ≫ iso.hom g :=\n  rfl\n\n/-- The core of a category is naturally included in the category. -/\ndef inclusion {C : Type u₁} [category C] : core C ⥤ C :=\n  functor.mk id fun (X Y : core C) (f : X ⟶ Y) => iso.hom f\n\n/-- A functor from a groupoid to a category C factors through the core of C. -/\n-- Note that this function is not functorial\n\n-- (consider the two functors from [0] to [1], and the natural transformation between them).\n\ndef functor_to_core {C : Type u₁} [category C] {G : Type u₂} [groupoid G] (F : G ⥤ C) :\n    G ⥤ core C :=\n  functor.mk (fun (X : G) => functor.obj F X)\n    fun (X Y : G) (f : X ⟶ Y) => iso.mk (functor.map F f) (functor.map F (inv f))\n\n/--\nWe can functorially associate to any functor from a groupoid to the core of a category `C`,\na functor from the groupoid to `C`, simply by composing with the embedding `core C ⥤ C`.\n-/\nend core\n\n\ndef core.forget_functor_to_core {C : Type u₁} [category C] {G : Type u₂} [groupoid G] :\n    (G ⥤ core C) ⥤ G ⥤ C :=\n  functor.obj (whiskering_right G (core C) C) core.inclusion\n\n/--\n`of_equiv_functor m` lifts a type-level `equiv_functor`\nto a categorical functor `core (Type u₁) ⥤ core (Type u₂)`.\n-/\ndef of_equiv_functor (m : Type u₁ → Type u₂) [equiv_functor m] : core (Type u₁) ⥤ core (Type u₂) :=\n  functor.mk m\n    fun (α β : core (Type u₁)) (f : α ⟶ β) =>\n      equiv.to_iso (equiv_functor.map_equiv m (iso.to_equiv f))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/core_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.49965713998908795}}
{"text": "import .replace_free\nimport .misc_list\n\nimport data.finset\n\n\nset_option pp.parens true\n\n\nopen formula\n\n\ndef simult_replace_free_aux (σ : variable_ → variable_) : finset variable_ → formula → formula\n| _ true_ := true_\n| binders (pred_ name args) :=\n    pred_\n    name\n    (args.map (fun (x : variable_), if x ∈ binders then x else σ x))\n| binders (eq_ x y) :=\n    eq_\n    (if x ∈ binders then x else σ x)\n    (if y ∈ binders then y else σ y)\n| binders (not_ P) := not_ (simult_replace_free_aux binders P)\n| binders (imp_ P Q) :=\n    imp_\n    (simult_replace_free_aux binders P)\n    (simult_replace_free_aux binders Q)\n| binders (forall_ x P) :=\n    forall_ x (simult_replace_free_aux (binders ∪ {x}) P)\n\n\ndef simult_replace_free (σ : variable_ → variable_) (P : formula) : formula := simult_replace_free_aux σ ∅ P\n\n\n/--\n  Specialized version of function.update.\n-/\ndef function.update_ite\n  {α β : Type}\n  [decidable_eq α]\n  (f : α → β)\n  (a' : α) (b : β) (a : α) :=\n  if a = a' then b else f a\n\n/--\n  fast_simult_replace_free σ P := The simultaneous replacement of each free occurence of any variable v in the formula P by σ v.\n-/\ndef fast_simult_replace_free : (variable_ → variable_) → formula → formula\n| _ true_ := true_\n| σ (pred_ name args) := pred_ name (args.map σ)\n| σ (eq_ x y) := eq_ (σ x) (σ y)\n| σ (not_ P) := not_ (fast_simult_replace_free σ P)\n| σ (imp_ P Q) := imp_ (fast_simult_replace_free σ P) (fast_simult_replace_free σ Q)\n| σ (forall_ x P) := forall_ x (fast_simult_replace_free (function.update_ite σ x x) P)\n\n\n@[simp]\nlemma function.update_ite_idem\n  {α β : Type}\n  [decidable_eq α]\n  (f : α → β)\n  (a : α)\n  (x y : β)  :\n  function.update_ite (function.update_ite f a x) a y =\n    function.update_ite f a y :=\nbegin\n  funext,\n  unfold function.update_ite,\n  split_ifs,\n  {\n    refl,\n  },\n  {\n    refl,\n  }\nend\n\n\nlemma function.update_ite_id\n  {α : Type}\n  [decidable_eq α]\n  (x : α) :\n  function.update_ite (id : α → α) x x = id :=\nbegin\n  funext,\n  unfold function.update_ite,\n  split_ifs,\n  {\n    subst h,\n    simp only [id.def],\n  },\n  {\n    refl,\n  }\nend\n\n\nlemma fast_simult_replace_free_id\n  (P : formula) :\n  fast_simult_replace_free id P = P :=\nbegin\n  induction P,\n  case formula.true_\n  {\n    refl,\n  },\n  case formula.pred_ : name args\n  {\n    unfold fast_simult_replace_free,\n    simp only [list.map_id, eq_self_iff_true, and_self],\n  },\n  case formula.eq_ : x y\n  {\n    refl,\n  },\n  case formula.not_ : P P_ih\n  {\n    solve_by_elim,\n  },\n  case formula.imp_ : P Q P_ih Q_ih\n  {\n    unfold fast_simult_replace_free,\n    congr,\n    {\n      exact P_ih,\n    },\n    {\n      exact Q_ih,\n    }\n  },\n  case formula.forall_ : x P P_ih\n  {\n    unfold fast_simult_replace_free,\n    simp only [eq_self_iff_true, true_and],\n    simp only [function.update_ite_id],\n    exact P_ih,\n  },\nend\n\n\nexample\n  (P : formula)\n  (v t : variable_) :\n  fast_simult_replace_free (function.update_ite id v t) P = fast_replace_free v t P :=\nbegin\n  induction P,\n  case formula.true_\n  {\n    refl,\n  },\n  case formula.pred_ : name args\n  {\n    refl,\n  },\n  case formula.eq_ : x y\n  {\n    refl,\n  },\n  case formula.not_ : P P_ih\n  {\n    unfold fast_simult_replace_free,\n    unfold fast_replace_free,\n    congr,\n    exact P_ih,\n  },\n  case formula.imp_ : P Q P_ih Q_ih\n  {\n    unfold fast_simult_replace_free,\n    unfold fast_replace_free,\n    congr,\n    {\n      exact P_ih,\n    },\n    {\n      exact Q_ih,\n    }\n  },\n  case formula.forall_ : x P P_ih\n  {\n    unfold fast_simult_replace_free,\n    unfold fast_replace_free,\n    split_ifs,\n    {\n      subst h,\n      simp only [eq_self_iff_true, function.update_ite_idem, true_and],\n\n      simp only [function.update_ite_id],\n      apply fast_simult_replace_free_id,\n    },\n    {\n      have s1 : (function.update_ite (function.update_ite (id : variable_ → variable_) v t) x x) = function.update_ite id v t,\n      funext,\n      unfold function.update_ite,\n      split_ifs,\n      {\n        subst h_1,\n        tauto,\n      },\n      {\n        subst h_1,\n        simp only [id.def],\n      },\n      {\n        refl,\n      },\n      {\n        refl,\n      },\n\n      simp only [eq_self_iff_true, true_and],\n      simp only [s1],\n      exact P_ih,\n    }\n  },\nend\n\n\nlemma huh\n  (P : formula)\n  (σ σ' : variable_ → variable_)\n  (binders : finset variable_)\n  (h1 : ∀ (v : variable_), v ∉ binders → σ v = σ' v) :\n  simult_replace_free_aux σ binders P =\n    simult_replace_free_aux σ' binders P :=\nbegin\n  induction P generalizing binders,\n  case formula.true_ : binders h1\n  { admit },\n  case formula.pred_ : name args binders h1\n  {\n    unfold simult_replace_free_aux,\n    congr' 1,\n    simp only [list.map_eq_map_iff],\n    intros x a1,\n    split_ifs,\n    refl,\n    exact h1 x h,\n  },\n  case formula.eq_ : P_ᾰ P_ᾰ_1 binders h1\n  { admit },\n  case formula.not_ : P_ᾰ P_ih binders h1\n  { admit },\n  case formula.imp_ : P_ᾰ P_ᾰ_1 P_ih_ᾰ P_ih_ᾰ_1 binders h1\n  { admit },\n  case formula.forall_ : x P P_ih binders h1\n  {\n    unfold simult_replace_free_aux,\n    congr' 1,\n    apply P_ih,\n    intros v a1,\n    simp only [finset.mem_union, finset.mem_singleton] at a1,\n    push_neg at a1,\n    cases a1,\n    apply h1 v a1_left,\n  },\nend\n\n\nexample\n  (P : formula)\n  (σ : variable_ → variable_)\n  (binders : finset variable_)\n  (h1 : ∀ (v : variable_), v ∈ binders → v = σ v) :\n  simult_replace_free_aux σ binders P =\n    fast_simult_replace_free σ P :=\nbegin\n  induction P generalizing binders σ,\n  case formula.true_ : binders h1\n  { admit },\n  case formula.pred_ : name args binders σ h1\n  {\n    unfold fast_simult_replace_free,\n    unfold simult_replace_free_aux,\n    congr' 1,\n    simp only [list.map_eq_map_iff],\n    intros x a1,\n    split_ifs,\n    exact h1 x h,\n    refl,\n  },\n  case formula.eq_ : P_ᾰ P_ᾰ_1 binders σ h1\n  { admit },\n  case formula.not_ : P_ᾰ P_ih binders σ h1\n  { admit },\n  case formula.imp_ : P_ᾰ P_ᾰ_1 P_ih_ᾰ P_ih_ᾰ_1 binders σ h1\n  { admit },\n  case formula.forall_ : x P P_ih binders σ h1\n  {\n    unfold fast_simult_replace_free,\n    unfold simult_replace_free_aux,\n    congr,\n\n    rewrite huh P σ (function.update_ite σ x x),\n    apply P_ih,\n    {\n      intros v a1,\n      unfold function.update_ite,\n      split_ifs,\n      {\n        exact h,\n      },\n      {\n        simp only [finset.mem_union, finset.mem_singleton] at a1,\n        tauto,\n      },\n    },\n    {\n      simp only [finset.mem_union, finset.mem_singleton, eq_self_iff_true, or_true],\n      push_neg,\n      intros v a1,\n      cases a1,\n      unfold function.update_ite,\n      split_ifs,\n      contradiction,\n      refl,\n    }\n  },\nend\n", "meta": {"author": "pthomas505", "repo": "lean3", "sha": "eb449be2b9a92becda4be38aac76e080194e3f7c", "save_path": "github-repos/lean/pthomas505-lean3", "path": "github-repos/lean/pthomas505-lean3/lean3-eb449be2b9a92becda4be38aac76e080194e3f7c/src/metalogic/fol/sandbox/simult_replace_free.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.49965542741357677}}
{"text": "import loops.reparametrization\nimport to_mathlib.analysis.cut_off\nimport to_mathlib.topology.hausdorff_distance\n\nnoncomputable theory\n\nopen set function finite_dimensional prod int topological_space metric filter\nopen measure_theory measure_theory.measure real\nopen_locale topology unit_interval\n\nvariables {E : Type*} [normed_add_comm_group E] [normed_space ℝ E]\n          {F : Type*} [normed_add_comm_group F]\n          {g b : E → F} {Ω : set (E × F)} {U K C : set E}\nvariables [normed_space ℝ F] [finite_dimensional ℝ F]\n\nlemma exist_loops_aux1\n  (hK : is_compact K)\n  (hΩ_op : is_open Ω)\n  (hb : 𝒞 ∞ b)\n  (hgK : ∀ᶠ x near K, g x = b x)\n  (hconv : ∀ x, g x ∈ hull (connected_component_in (prod.mk x ⁻¹' Ω) $ b x)) :\n  ∃ (γ : E → ℝ → loop F) (V ∈ 𝓝ˢ K) (ε > 0), surrounding_family_in g b γ V Ω ∧\n  (∀ (x ∈ V), ball (x, b x) (ε + ε) ⊆ Ω) ∧\n  ∀ (x ∈ V) t s, dist (γ x t s) (b x) < ε :=\nbegin\n  have b_in : ∀ x, (x, b x) ∈ Ω :=\n    λ x, (connected_component_in_nonempty_iff.mp (convex_hull_nonempty_iff.mp ⟨g x, hconv x⟩) : _),\n  have h2Ω : is_open (Ω ∩ fst ⁻¹' univ), { rwa [preimage_univ, inter_univ] },\n\n  -- we could probably get away with something simpler to get γ₀.\n  obtain ⟨γ₀, hγ₀_cont, hγ₀, h2γ₀, h3γ₀, -, hγ₀_surr⟩ := -- γ₀ is γ* in notes\n    surrounding_loop_of_convex_hull is_open_univ is_connected_univ\n    (by { rw [convex_hull_univ], exact mem_univ 0 }) (mem_univ (0 : F)),\n  obtain ⟨ε₀, hε₀, V, hV, hεΩ⟩ :=\n    hK.exists_thickening_image hΩ_op (continuous_id.prod_mk hb.continuous) (λ x _, b_in x),\n  let range_γ₀ := (λ i : ℝ × ℝ, ‖γ₀ i.1 i.2‖) '' (I ×ˢ I),\n  have h4γ₀ : bdd_above range_γ₀ :=\n  (is_compact_Icc.prod is_compact_Icc).bdd_above_image (hγ₀_cont.norm.continuous_on),\n  have h0 : 0 < 1 + Sup range_γ₀ := add_pos_of_pos_of_nonneg zero_lt_one (le_cSup_of_le h4γ₀\n    (mem_image_of_mem _ $ mk_mem_prod unit_interval.zero_mem unit_interval.zero_mem) $\n    norm_nonneg _),\n  generalize' h0ε₁ : ε₀ / 2 = ε₁,\n  have hε₁ : 0 < ε₁ := h0ε₁ ▸ div_pos hε₀ two_pos,\n  let ε := ε₁ / (1 + Sup range_γ₀),\n  have hε : 0 < ε := div_pos hε₁ h0,\n  have h2ε : ∀ t s : ℝ, ‖ε • γ₀ t s‖ < ε₁,\n  { intros t s, simp [norm_smul, mul_comm_div, real.norm_eq_abs, abs_eq_self.mpr, hε.le],\n    refine lt_of_lt_of_le _ (mul_one _).le,\n    rw [mul_lt_mul_left hε₁, div_lt_one h0],\n    refine (zero_add _).symm.le.trans_lt _,\n    refine add_lt_add_of_lt_of_le zero_lt_one (le_cSup h4γ₀ _),\n    rw [← loop.fract_eq, ← h3γ₀],\n    refine mem_image_of_mem _ (mk_mem_prod proj_I_mem_Icc $ unit_interval.fract_mem _) },\n  let γ₁ : E → ℝ → loop F := λ x t, (γ₀ t).transform (λ y, b x + ε • y), -- `γ₁ x` is `γₓ` in notes\n  refine ⟨γ₁, _⟩,\n  have hbV : ∀ᶠ x near K, x ∈ V := hV,\n  have h1 : ∀ (x ∈ V) (t s : ℝ), ball (x, b x) (ε₁ + ε₁) ⊆ Ω,\n  { intros x hx t s,\n    simp [← h0ε₁],\n    refine (ball_subset_thickening (mem_image_of_mem _ hx) _).trans hεΩ },\n  refine ⟨_, hgK.and hbV, ε₁, hε₁, ⟨⟨by simp [γ₁, hγ₀], by simp [γ₁, h2γ₀], _, _, _⟩, _⟩, _, _⟩,\n  { intros x t s, simp [γ₁, h3γ₀] },\n  { rintro x ⟨hx, -⟩, simp_rw [hx, γ₁],\n    exact (hγ₀_surr.smul0 hε.ne').vadd0 },\n  { refine hb.continuous.fst'.add (continuous_const.smul $ hγ₀_cont.snd') },\n  { rintro x ⟨-, hx⟩ t ht s hs,\n    have : ‖ε • γ₀ t s‖ < ε₀ := (h2ε t s).trans (h0ε₁ ▸ half_lt_self hε₀),\n    refine h1 x hx t s (by simp [← h0ε₁, this]) },\n  { intros x hx,\n    rw [← h0ε₁, add_halves'],\n    refine (ball_subset_thickening (mem_image_of_mem _ hx.2) _).trans hεΩ },\n  { rintro x ⟨-, hx⟩ t s, simp [h2ε] }\nend\n\n/- Some remarks about `exist_loops_aux2`:\n  `δ`: loop after smoothing\n  `γ`: loop before smoothing (defined on all of `E`)\n  Requirements:\n  (0) `δ x t` is a loop\n  (1) `δ` lands in `Ω`\n  (2) `δ` has the correct values: for `s = 0` and `t = 0` it should be `b`\n  (3) `δ` should be constant on `t ≤ 0` and for `t ≥ 1`.\n  (4) `δ x 1` surrounds `g x`.\n  (5) Near `K`, the line connecting `b` and `δ` lies in `Ω`\n\n  Strategy:\n  (a) We need `ε₁` satisfying the following conditions:\n  (a1) We need to ensure that an `ε₁ x`-ball around `(x, δ x s t)` lies in `Ω` for some\n    continuous `ε₁`.\n  (a4) Furthermore, `ε₁` should be small enough so that any function with that\n    distance from `γ` still surrounds `g`, using `surrounding_family.surrounds_of_close`.\n  (a5): `ε₁ x < ε₀` (obtained from `exist_loops_aux1`)\n  (b) Replace `γ x t s` by `γ x (linear_reparam t) (linear_reparam s)`.\n  (e) Let `δ' x` be a family of loops that is at most `ε₁` away from `γ` using\n    `exists_smooth_and_eq_on`. Since `γ` is smooth near `s ∈ ℤ` and `t ≤ 0` we can also\n    ensure that `δ' = γ` for those values (*).\n    Now let `δ x t s = δ' x (smooth_transition t) (fract s)`\n    We immediately get (0) and (3). We get (2) by (*).\n    This is still smooth, since `δ'` is doesn't depend on `s` near `s ∈ ℤ`.\n  (f) (a1) gives (1), (a4) gives (4) and (a5) gives (5).\n\n  Note: to ensure (2) the reparamerization strategy that was originally in the blueprint\n  (ensuring that `γ` is locally constant in the `t` and `s` directions)\n  didn't work. Indeed it needed to take the convolution in the `x`-direction,\n  meaning that the value won't stay the same, since `γ` is not constant in the `x`-direction.\n\n  -/\n\nlemma exist_loops_aux2 [finite_dimensional ℝ E]\n  (hK : is_compact K)\n  (hΩ_op : is_open Ω)\n  (hg : 𝒞 ∞ g) (hb : 𝒞 ∞ b)\n  (hgK : ∀ᶠ x near K, g x = b x)\n  (hconv : ∀ x, g x ∈ hull (connected_component_in (prod.mk x ⁻¹' Ω) $ b x)) :\n  ∃ (γ : E → ℝ → loop F), surrounding_family_in g b γ univ Ω ∧ 𝒞 ∞ ↿γ ∧\n  ∀ᶠ x near K, ∀ t s, closed_ball (x, b x) (dist (γ x t s) (b x)) ⊆ Ω :=\nbegin\n  obtain ⟨γ₁, V, hV, ε₀, hε₀, hγ₁, hΩ, h2γ₁⟩ := exist_loops_aux1 hK hΩ_op hb hgK hconv,\n  obtain ⟨γ₂, hγ₂, hγ₂₁⟩ :=\n    exists_surrounding_loops hK.is_closed hΩ_op\n    (λ x, hg.continuous.continuous_at) hb.continuous (λ x, hconv x) ⟨V, hV, hγ₁⟩,\n  let γ₃ : E → ℝ → loop F := λ x t, (γ₂ x (linear_reparam t)).reparam linear_reparam,\n  have hγ₃ : surrounding_family_in g b γ₃ univ Ω := hγ₂.reparam,\n  obtain ⟨ε₁, hε₁, hcε₁, hγε₁⟩ := hγ₃.to_sf.surrounds_of_close_univ hg.continuous,\n  classical,\n  let f : E → ℝ × ℝ → ℝ := λ x y, if Ωᶜ.nonempty then inf_dist (x, γ₃ x y.1 y.2) Ωᶜ else 1,\n  have hI : is_compact (I ×ˢ I) := is_compact_Icc.prod is_compact_Icc,\n  have h1f : continuous ↿f :=\n    (continuous_fst.prod_mk hγ₃.cont).inf_dist.if_const _ continuous_const,\n  have h2f : ∀ x : E, continuous (f x) :=\n    λ x, h1f.comp₂ continuous_const continuous_id,\n  have h3f : ∀ {x y}, 0 < f x y,\n  { intros x y, by_cases hΩ : Ωᶜ.nonempty,\n    { simp_rw [f, if_pos hΩ, ← hΩ_op.is_closed_compl.not_mem_iff_inf_dist_pos hΩ, not_mem_compl_iff,\n      hγ₃.val_in (mem_univ _)] },\n    { simp_rw [f, if_neg hΩ, zero_lt_one] }},\n  let ε₂ : E → ℝ := λ x, min (min ε₀ (ε₁ x)) (Inf (f x '' (I ×ˢ I))),\n  have hcε₂ : continuous ε₂ :=\n    (continuous_const.min hcε₁).min (hI.continuous_Inf h1f),\n  have hε₂ : ∀ {x}, 0 < ε₂ x := λ x, lt_min (lt_min hε₀ (hε₁ x))\n    ((hI.lt_Inf_iff_of_continuous\n      ((nonempty_Icc.mpr zero_le_one).prod (nonempty_Icc.mpr zero_le_one))\n      (h2f x).continuous_on _).mpr $ λ x hx, h3f),\n  let γ₄ := ↿γ₃,\n  have h0γ₄ : ∀ x t s, γ₄ (x, t, s) = γ₃ x t s := λ x t s, rfl,\n  have hγ₄ : continuous γ₄ := hγ₃.cont,\n  let C₁ : set ℝ := Iic (5⁻¹  : ℝ) ∪ Ici (4 / 5),\n  have h0C₁ : (0 : ℝ) ∈ C₁ := or.inl (by { rw [mem_Iic], norm_num1 }),\n  have h1C₁ : (1 : ℝ) ∈ C₁ := or.inr (by { rw [mem_Ici], norm_num1 }),\n  have h2C₁ : ∀ (s : ℝ) (hs : fract s = 0), fract ⁻¹' C₁ ∈ 𝓝 s,\n  { intros s hs,\n    refine fract_preimage_mem_nhds _ (λ _, _),\n    { rw [hs], refine mem_of_superset (Iic_mem_nhds $ by norm_num) (subset_union_left _ _) },\n    { refine mem_of_superset (Ici_mem_nhds $ by norm_num) (subset_union_right _ _) } },\n  let C : set (E × ℝ × ℝ) := (λ x, x.2.1) ⁻¹' Iic (5⁻¹ : ℝ) ∪ (λ x, fract x.2.2) ⁻¹' C₁,\n  have hC : is_closed C,\n  { refine (is_closed_Iic.preimage continuous_snd.fst).union _,\n    refine ((is_closed_Iic.union is_closed_Ici).preimage_fract _).preimage continuous_snd.snd,\n    exact λ x, or.inl (show (0 : ℝ) ≤ 5⁻¹, by norm_num) },\n  let U₁ : set ℝ := Iio (4⁻¹ : ℝ) ∪ Ioi (3 / 4),\n  let U : set (E × ℝ × ℝ) := (λ x, x.2.1) ⁻¹' Iio (4⁻¹ : ℝ) ∪ (λ x, fract x.2.2) ⁻¹' U₁,\n  have hUC : U ∈ 𝓝ˢ C,\n  { have hU : is_open U,\n    { refine (is_open_Iio.preimage continuous_snd.fst).union _,\n      refine ((is_open_Iio.union is_open_Ioi).preimage_fract _).preimage continuous_snd.snd,\n      exact λ x, or.inr (show (3/4 : ℝ) < 1, by norm_num) },\n    exact hU.mem_nhds_set.mpr (union_subset_union (λ x hx, lt_of_le_of_lt hx (by norm_num)) $\n      union_subset_union (λ x hx, lt_of_le_of_lt hx (by norm_num))\n      (λ x hx, lt_of_lt_of_le (by norm_num) hx)) },\n  have h2γ₄ : eq_on γ₄ (λ x, b x.1) U,\n  { rintro ⟨x, t, s⟩ hxts,\n    simp_rw [h0γ₄, γ₃, loop.reparam_apply],\n    cases hxts with ht hs,\n    { refine hγ₂.to_sf.t_le_zero_eq_b x (linear_reparam s) (linear_reparam_nonpos (le_of_lt ht)) },\n    { rw [← loop.fract_eq, fract_linear_reparam_eq_zero, hγ₂.base],\n      exact or.imp le_of_lt le_of_lt hs } },\n  have h3γ₄ : smooth_on γ₄ U := hb.fst'.cont_diff_on.congr h2γ₄,\n  obtain ⟨γ₅, hγ₅, hγ₅₄, hγ₅C⟩ :=\n    exists_smooth_and_eq_on hγ₄ hcε₂.fst' (λ x, hε₂) hC ⟨U, hUC, h3γ₄⟩,\n  let γ : E → ℝ → loop F := λ x t, ⟨λ s, γ₅ (x, smooth_transition t, fract s),\n    λ s, by rw [fract_add_one s]⟩,\n  have hγ : 𝒞 ∞ ↿γ,\n  { rw [cont_diff_iff_cont_diff_at],\n    rintro ⟨x, t, s⟩, by_cases hs : fract s = 0,\n    { have : (λ x, γ x.1 x.2.1 x.2.2) =ᶠ[𝓝 (x, t, s)] λ x, b x.1,\n      { have : (λ x : E × ℝ × ℝ, (x.1, smooth_transition x.2.1, fract x.2.2)) ⁻¹' C ∈ 𝓝 (x, t, s),\n        { simp_rw [C, @preimage_union _ _ _ (_ ⁻¹' _), preimage_preimage, fract_fract],\n          refine mem_of_superset _ (subset_union_right _ _),\n          refine continuous_at_id.snd'.snd'.preimage_mem_nhds (h2C₁ s hs) },\n        refine eventually_of_mem this _,\n        intros x hx,\n        simp_rw [γ, loop.coe_mk],\n        refine (hγ₅C hx).trans\n          (h2γ₄ $ (subset_interior_iff_mem_nhds_set.mpr hUC).trans interior_subset hx) },\n      exact hb.fst'.cont_diff_at.congr_of_eventually_eq this },\n    { exact (hγ₅.comp₃ cont_diff_fst smooth_transition.cont_diff.fst'.snd' $ cont_diff_snd.snd'.sub\n        cont_diff_const).cont_diff_at.congr_of_eventually_eq\n        ((eventually_eq.rfl.prod_mk $ eventually_eq.rfl.prod_mk $\n        (fract_eventually_eq hs).comp_tendsto continuous_at_id.snd'.snd').fun_comp ↿γ₅) } },\n  refine ⟨γ, ⟨⟨_, _, _, _, hγ.continuous⟩, _⟩, hγ, _⟩,\n  { intros x t, simp_rw [γ, loop.coe_mk, fract_zero], rw [hγ₅C], exact hγ₃.base x _,\n    exact or.inr (by { rw [mem_preimage, fract_zero], exact h0C₁ }) },\n  { intros x s, simp_rw [γ, loop.coe_mk, smooth_transition.zero_of_nonpos le_rfl], rw [hγ₅C],\n    exact hγ₃.t₀ x (fract s),\n    exact or.inl (show (0 : ℝ) ≤ 5⁻¹, by norm_num) },\n  { intros x t s, simp_rw [γ, loop.coe_mk, smooth_transition_proj_I] },\n  { rintro x -, apply hγε₁, intro s,\n    simp_rw [← (γ₃ x 1).fract_eq s, γ, loop.coe_mk, smooth_transition.one_of_one_le le_rfl],\n    exact (hγ₅₄ (x, 1, fract s)).trans_le ((min_le_left _ _).trans $ min_le_right _ _) },\n  { rintro x - t - s -, rw [← not_mem_compl_iff],\n    by_cases hΩ : Ωᶜ.nonempty, swap,\n    { rw [not_nonempty_iff_eq_empty] at hΩ, rw [hΩ], apply not_mem_empty },\n    refine not_mem_of_dist_lt_inf_dist _,\n    exact (x, γ₃ x (smooth_transition t) (fract s)),\n    rw [dist_comm, dist_prod_same_left],\n    refine (hγ₅₄ (x, _, fract s)).trans_le ((min_le_right _ _).trans $ cInf_le _ _),\n    refine (is_compact_Icc.prod is_compact_Icc).bdd_below_image (h2f x).continuous_on,\n    rw [← hγ₃.proj_I],\n    simp_rw [f, if_pos hΩ],\n    apply mem_image_of_mem _ (mk_mem_prod proj_I_mem_Icc (unit_interval.fract_mem s)) },\n  { refine eventually_of_mem (filter.inter_mem hV hγ₂₁) (λ x hx t s, _),\n    refine (closed_ball_subset_ball _).trans (hΩ x hx.1),\n    refine (dist_triangle _ _ _).trans_lt (add_lt_add_of_le_of_lt\n      ((hγ₅₄ (x, _, fract s)).le.trans $ (min_le_left _ _).trans $ min_le_left _ _) _),\n    simp_rw [γ₄, has_uncurry.uncurry, γ₃, loop.reparam_apply, show γ₂ x = γ₁ x, from hx.2],\n    exact h2γ₁ x hx.1 _ _ }\nend\n\nvariables (g b Ω U K)\nvariables [measurable_space F] [borel_space F]\n\n/-- A \"nice\" family of loops consists of all the properties we want from the `exist_loops` lemma:\nit is a smooth homotopy in `Ω` with fixed endpoints from the constant loop at `b x` to a loop with\naverage `g x` that is also constantly `b x` near `K`.\nThe first two conditions are implementation specific: the homotopy is constant outside the unit\ninterval. -/\nstructure nice_loop (γ : ℝ → E → loop F) : Prop :=\n(t_le_zero : ∀ x, ∀ t ≤ 0, γ t x = γ 0 x)\n(t_ge_one : ∀ x, ∀ t ≥ 1, γ t x = γ 1 x)\n(t_zero : ∀ x s, γ 0 x s = b x)\n(s_zero : ∀ x t, γ t x 0 = b x)\n(avg : ∀ x, (γ 1 x).average = g x)\n(mem_Ω : ∀ x t s, (x, γ t x s) ∈ Ω)\n(smooth : 𝒞 ∞ ↿γ)\n(rel_K : ∀ᶠ x in 𝓝ˢ K, ∀ t s, γ t x s = b x)\n\nvariables {g b Ω U K}\n\n\ntheorem exist_loops [finite_dimensional ℝ E]\n  (hK : is_compact K)\n  (hΩ_op : is_open Ω)\n  (hg : 𝒞 ∞ g) (hb : 𝒞 ∞ b)\n  (hgK : ∀ᶠ x near K, g x = b x)\n  (hconv : ∀ x, g x ∈ hull (connected_component_in (prod.mk x ⁻¹' Ω) $ b x)) :\n  ∃ γ : ℝ → E → loop F, nice_loop g b Ω K γ :=\nbegin\n  obtain ⟨γ₁, hγ₁, hsγ₁, h2γ₁⟩ := exist_loops_aux2 hK hΩ_op hg hb hgK hconv,\n  let γ₂ : smooth_surrounding_family g :=\n    ⟨hg, λ x, γ₁ x 1, hsγ₁.comp₃ cont_diff_fst cont_diff_const cont_diff_snd,\n      λ x, hγ₁.surrounds x (mem_univ _)⟩,\n  classical,\n  let γ₃ : ℝ → E → loop F :=\n  λ t x, (γ₁ x t).reparam $ (γ₂.reparametrize x).equivariant_map,\n  have hγ₃ : 𝒞 ∞ ↿γ₃ :=\n    hsγ₁.comp₃ cont_diff_snd.fst cont_diff_fst (γ₂.reparametrize_smooth.snd'),\n  obtain ⟨χ, hχ, h1χ, h0χ, h2χ⟩ := exists_cont_diff_one_nhds_of_interior hK.is_closed\n    (subset_interior_iff_mem_nhds_set.mpr $ hgK.and h2γ₁),\n  simp_rw [← or_iff_not_imp_left] at h0χ,\n  let γ : ℝ → E → loop F :=\n  λ t x, χ x • loop.const (b x) + (1 - χ x) • γ₃ t x,\n  have h1γ : ∀ x, ∀ t ≤ 0, γ t x = γ 0 x,\n  { intros x t ht, ext s, simp [hγ₁.to_sf.t_le_zero _ _ ht] },\n  have h2γ : ∀ x, ∀ t ≥ 1, γ t x = γ 1 x,\n  { intros x t ht, ext s, simp [hγ₁.to_sf.t_ge_one _ _ ht] },\n  refine ⟨γ, h1γ, h2γ, _, _, _, _, _, _⟩,\n  { intros x t, simp [hγ₁.t₀] },\n  { intros x t, simp [hγ₁.base] },\n  { intros x,\n    have h1 : interval_integrable (χ x • loop.const (b x) : loop F) volume 0 1,\n    { show interval_integrable (λ t, χ x • b x) volume (0 : ℝ) (1 : ℝ),\n      exact interval_integrable_const, },\n    have h2 : interval_integrable ((1 - χ x) • γ₃ 1 x : loop F) volume 0 1 :=\n    ((hγ₃.comp₃ cont_diff_const cont_diff_const cont_diff_id)\n      .continuous.interval_integrable _ _).smul _,\n    have h3 : (γ₃ 1 x).average = g x := γ₂.reparametrize_average x,\n    simp [h1, h2, h3],\n    rcases h0χ x with ⟨hx,-⟩|hx,\n    { rw [hx, smul_add_one_sub_smul] },\n    { simp [hx] } },\n  { intros x t s,\n    have : ∀ (P : F → Prop) t, (∀ t ∈ I, P (γ t x s)) → P (γ t x s),\n    { intros P t hP,\n      rcases le_total 0 t with h1t|h1t, rcases le_total t 1 with h2t|h2t,\n      { exact hP t ⟨h1t, h2t⟩},\n      { rw [h2γ x t h2t], exact hP 1 ⟨zero_le_one, le_rfl⟩ },\n      { rw [h1γ x t h1t], exact hP 0 ⟨le_rfl, zero_le_one⟩ } },\n    refine this (λ y, (x, y) ∈ Ω) t (λ t ht, _),\n    rcases h0χ x with ⟨hx, h2x⟩|hx,\n    { refine h2x t (γ₂.reparametrize x s) _, simp [γ, dist_smul_add_one_sub_smul_le (h2χ x)] },\n    { simp [hx], apply hγ₁.val_in (mem_univ _) } },\n  { exact (hχ.fst'.snd'.smul hb.fst'.snd').add ((cont_diff_const.sub hχ.fst'.snd').smul hγ₃) },\n  { exact h1χ.mono (λ x (hx : χ x = 1), by simp [hx]), }\nend\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/loops/exists.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.499655419764662}}
{"text": "import utils\nimport data.vector data.list data.int.basic tactic.omega data.fin\n       tactic.linarith tactic.apply\n\nopen utils\n\nsection grids\n\nopen list\n\nclass relative_grid (α : Type*) :=\n  (carrier  : Type)\n  (rows     : α → ℕ)\n  (cols     : α → ℕ)\n  (nonempty : Πg, rows g * cols g > 0)\n  (data     : Πg, fin (rows g) → fin (cols g) → carrier)\n\nclass grid (α : Type*) extends relative_grid α :=\n  (bl : α → point)\n\nsection grid_defs\n\nvariables {α : Type*} [grid α] (g : α)\n\nopen grid relative_grid\n\nnotation `|`:max x `|`:0 := int.nat_abs x\n\ndef size := rows g * cols g\n\nattribute [simp]\nlemma size_eq_rows_mul_cols : size g = rows g * cols g := rfl\n\ndef tr (bl : point) (r c : ℕ) : point :=\n  ⟨bl.x + c, bl.y + r⟩\n\nattribute [simp]\ndef grid_rows := rows g\n\nattribute [simp]\ndef grid_cols := cols g\n\nattribute [simp]\ndef gbl := bl g\n\ndef gtr := tr (bl g) (rows g) (cols g)\n\ndef tl : point := ⟨(bl g).x, (bl g).y + rows g⟩\n\ndef br : point := ⟨(bl g).x + cols g, (bl g).y⟩\n\nlemma expand_gbl : gbl g = bl g := by simp\n\nlemma expand_gtr : gtr g = ⟨(bl g).x + cols g, (bl g).y + rows g⟩ :=\n  by simp [gtr, tr]\n\nlemma blx_eq_tlx {g : α} : (bl g).x = (tl g).x := by simp [bl, tl]\n\nlemma brx_eq_trx {g : α} : (br g).x = (gtr g).x := by simp [br, expand_gtr]\n\nlemma bly_eq_bry {g : α} : (bl g).y = (br g).y := by simp [br]\n\nlemma tly_eq_try {g : α} : (tl g).y = (gtr g).y := by simp [expand_gtr, tl]\n\nstructure bounding_box := (p₁ : point) (p₂ : point) (h : p₁ ↗ p₂)\n\ndef bbox_str : bounding_box → string\n  | ⟨p₁, p₂, _⟩ := \"<(\" ++ to_string p₁ ++ \", \" ++ to_string p₂ ++ \")>\"\n\ninstance : has_to_string bounding_box := ⟨bbox_str⟩\n\ninstance : has_repr bounding_box := ⟨bbox_str⟩\n\ndef bb_eq (bb₁ bb₂ : bounding_box) := bb₁.p₁ = bb₂.p₂ ∧ bb₁.p₂ = bb₂.p₂\n\ninstance dec_eq_bb {bb₁ bb₂} : decidable (bb_eq bb₁ bb₂) :=\n  by simp [bb_eq]; apply_instance\n\ninstance : decidable_eq bounding_box :=\n  λbb₁ bb₂, begin\n              cases bb₁, cases bb₂,\n              simp, apply_instance\n            end\n\ndef points_of_box (bb : bounding_box) : point × point := ⟨bb.p₁, bb.p₂⟩\n\ndef rows_of_box (bb : bounding_box) : ℕ :=\n  |bb.p₂.y - bb.p₁.y|\n \ndef cols_of_box (bb : bounding_box) : ℕ :=\n  |bb.p₂.x - bb.p₁.x|\n\ndef bb_size (bb : bounding_box) := rows_of_box bb * cols_of_box bb\n\nprivate def data_option (g : α) (x y : ℕ) :=\n  if h : y < cols g\n  then if h₁ : x < rows g\n       then some $ data g ⟨x, h₁⟩ ⟨y, h⟩\n       else none\n  else none\n\nend grid_defs\n\nsection grid_lemmas\n\nopen grid relative_grid function\n\nvariables {α : Type*} [grid α] {g : α}\n\nprivate theorem data_data_option {x y : ℕ}\n  (h₁ : y < rows g) (h₂ : x < cols g) :\n  some (data g ⟨y, h₁⟩ ⟨x, h₂⟩) = data_option g y x :=\n  by unfold data_option; repeat { rw dif_pos; try { simp [is_bounded, h.2] } };\n     simpa\n\nlemma rows_of_box_pos {bb : bounding_box} : rows_of_box bb > 0 :=\nlet ⟨⟨_, y₁⟩, ⟨_, y₂⟩, h⟩ := bb in\nbegin\n  simp only [rows_of_box, gt_from_lt], simp [grid_bounded_iff] at h,\n  rw [← int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg]; omega\nend\n\nlemma cols_of_box_pos {bb : bounding_box} : cols_of_box bb > 0 :=\nlet ⟨⟨x₁, _⟩, ⟨x₂, _⟩, h⟩ := bb in\nbegin\n  simp only [cols_of_box, gt_from_lt], simp [grid_bounded_iff] at h,\n  rw [← int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg]; omega\nend\n\nlemma rows_pos : 0 < rows g :=\n  (gt_and_gt_of_mul_gt (nonempty g)).1\n\nlemma cols_pos : 0 < cols g :=\n  (gt_and_gt_of_mul_gt (nonempty g)).2\n\nlemma abs_rows_pos : 0 < |rows g| := rows_pos\n\nlemma abs_cols_pos : 0 < |cols g| := cols_pos\n\nlemma coe_rows_pos : (0 : ℤ) < ↑(rows g) := by simp [rows_pos]\n\nlemma coe_cols_pos {g : α} : (0 : ℤ) < ↑(cols g) := by simp [cols_pos]\n\nlemma idx_div_cols_bounded {n} (h : n < size g) :\n  (bl g).y + ↑n / ↑(cols g) < (gtr g).y :=\nbegin\n  simp [expand_gtr, gt_from_lt] at *, norm_cast,\n  rw mul_comm at h,\n  replace h := nat.div_lt_of_lt_mul h,\n  linarith\nend\n\nlemma idx_mod_cols_bounded {n : ℕ} :\n  (bl g).x + ↑n % ↑(cols g) < (gtr g).x :=\n  by simp [expand_gtr]; exact int.mod_lt_of_pos _ coe_cols_pos\n\nlemma grid_is_bounding_box : bl g ↗ gtr g :=\nlet ⟨h₁, h₂⟩ := gt_and_gt_of_mul_gt (nonempty g) in\n  grid_bounded_iff.2 ⟨\n    by simpa [expand_gtr],\n    by simpa [expand_gtr]\n  ⟩\n\nstructure relative_point (g : α) :=\n  (x : fin (rows g))\n  (y : fin (cols g))\n\ndef relative_point_str (g : α) : relative_point g → string\n  | ⟨x, y⟩ := \"[\" ++ to_string x ++ \", \" ++ to_string y ++ \"]\"\n\ninstance : has_to_string (relative_point g) :=\n  ⟨relative_point_str g⟩\n\ninstance : has_repr (relative_point g) :=\n  ⟨relative_point_str g⟩\n\nstructure grid_point (g : α) :=\n  (y : bounded (bl g).y (gtr g).y)\n  (x : bounded (bl g).x (gtr g).x)\n\ndef grid_point_str (g : α) : grid_point g → string\n  | ⟨x, y⟩ := \"[\" ++ to_string x ++ \", \" ++ to_string y ++ \"] - \"\n              ++ to_string (bl g)\n\ninstance : has_to_string (grid_point g) := ⟨grid_point_str g⟩\n\ninstance : has_repr (grid_point g) := ⟨grid_point_str g⟩\n\nlemma blgy_lt_trgy : (bl g).y < (gtr g).y :=\n  by simp [expand_gtr, rows_pos]\n\nlemma gblx_lt_gtrx : (gbl g).x < (gtr g).x :=\n  expand_gtr g ▸ expand_gbl g ▸ lt_add_of_pos_right _ coe_cols_pos\n\nprivate lemma grid_rows_eq_try_sub_bly :\n  grid_rows g = |(gtr g).y - (bl g).y| :=\n  by simp [expand_gtr]\n\nlemma rows_eq_try_sub_bly :\n  rows g = |(gtr g).y - (bl g).y| := grid_rows_eq_try_sub_bly\n\nlemma rows_eq_try_sub_bly' :\n  ↑(rows g) = (gtr g).y - (bl g).y := by simp [gtr, tr]\n\nprivate lemma grid_cols_eq_trx_sub_blx\n  : grid_cols g = |((gtr g).x - (bl g).x)| :=\n  by simp [expand_gtr]\n\nlemma cols_eq_trx_sub_blx\n  : cols g = |((gtr g).x - (bl g).x)| := grid_cols_eq_trx_sub_blx\n\ndef relpoint_of_gpoint {g : α} (p : grid_point g) : relative_point g :=\n    ⟨\n      ⟨|p.y.1 - (bl g).y|,  \n       begin\n         rcases p with ⟨⟨x, ⟨xl, xu⟩⟩, ⟨y, ⟨yl, yu⟩⟩⟩, simp,\n         have eq₁ : x + -(bl g).y ≥ 0, by linarith,\n         have eq₂ : (gtr g).y - (bl g).y ≥ 0, by simp [expand_gtr]; linarith,\n         rw [\n           ← int.coe_nat_lt_coe_nat_iff, rows_eq_try_sub_bly,\n           int.nat_abs_of_nonneg eq₁, int.nat_abs_of_nonneg eq₂\n         ],\n         linarith\n       end\n      ⟩,\n      ⟨|p.x.1 - (bl g).x|,\n       have h : p.x.1 - (tl g).x ≥ 0,\n         from le_sub_iff_add_le.2 (by simp [tl, p.x.2.1]),\n       ((int.coe_nat_lt_coe_nat_iff _ _).1 $\n        (int.nat_abs_of_nonneg h).symm ▸\n        begin\n          let uby := p.x.2.2,\n          simp only [expand_gtr] at uby,\n          simp only [tl],\n          linarith\n        end)\n      ⟩\n    ⟩\n\ndef gpoint_of_relpoint {g : α} (p : relative_point g) : grid_point g :=\n  ⟨\n    ⟨(bl g).y + p.x.1,\n      ⟨\n        by simp [tl, expand_gtr],\n        by rcases p with ⟨⟨_, h⟩, _⟩; simp only [tl, expand_gtr, h]; linarith\n      ⟩\n    ⟩,\n    ⟨(bl g).x + p.y.1,\n      ⟨\n        by simp [tl],\n        by rcases p with ⟨⟨_, _⟩, ⟨_, h⟩⟩; simp only [tl, expand_gtr, h]; linarith\n      ⟩\n    ⟩\n  ⟩\n\nlemma relpoint_gpoint_id {g : α} {p : grid_point g} :\n  gpoint_of_relpoint (relpoint_of_gpoint p) = p :=\nbegin\n  rcases p with ⟨⟨x, ⟨hx₁, _⟩⟩, ⟨y, ⟨hy₁, _⟩⟩⟩,\n  simp [relpoint_of_gpoint, gpoint_of_relpoint, -sub_eq_add_neg],\n  have : x - (bl g).y ≥ 0, by linarith,\n  have : y - (bl g).x ≥ 0, by linarith,\n  split; rw int.nat_abs_of_nonneg; try { simp }; assumption\nend\n\nlemma gpoint_relpoint_id {g : α} {p : relative_point g} :\n  relpoint_of_gpoint (gpoint_of_relpoint p) = p :=\n  by cases p with x y; simp [gpoint_of_relpoint, relpoint_of_gpoint]\n\ndef prod_of_rel_point {g : α} (rp : relative_point g) := (rp.x, rp.y)\n\ndef prod_of_grid_point {g : α} (ap : grid_point g) := (ap.x, ap.y)\n\ndef grid_point_of_prod {g : α}\n  (p : bounded (bl g).x (gtr g).x ×\n       bounded (bl g).y (gtr g).y) : grid_point g :=\n  ⟨p.snd, p.fst⟩\n\ndef grid_point_of_prod' {g : α}\n  (p : bounded (bl g).y (gtr g).y ×\n       bounded (bl g).x (gtr g).x) : grid_point g :=\n  ⟨p.fst, p.snd⟩\n\ndef abs_data (g : α) (gp : grid_point g) :=\n  let rp := relpoint_of_gpoint gp in\n    (data g) rp.x rp.y\n\nlemma try_lt_bly : (gbl g).y < (gtr g).y :=\n  (grid_bounded_iff.1 grid_is_bounding_box).2\n\nprivate lemma bounded_establishes_bounds {a b : ℤ}\n  (h : a < b) (x : bounded 0 ( |b - a| )) :\n  a ≤ a + ↑x ∧ a + ↑x < b :=\nhave xpos : ↑x ≥ 0, from positive_bounded _,\nhave xmax : ↑x < |b - a|, from bounded_lt _,\n  ⟨\n    by apply le_add_of_nonneg_right; unfold coe,\n    begin\n      unfold_coes at *,\n      rw add_comm,\n      rw [← int.coe_nat_lt, int.nat_abs_of_nonneg, lt_sub_iff_add_lt] at xmax,\n      exact xmax,\n      {\n        simp [ge_from_le],\n        rw [\n          ← sub_eq_add_neg, ← add_le_add_iff_right a,\n          zero_add, sub_add_cancel\n        ],\n        exact int.le_of_lt h,\n      }\n    end\n  ⟩\n\nend grid_lemmas\n\nend grids\n\nsection grid_impls\n\nstructure vec_grid (α : Type) :=\n  (r : ℕ)\n  (c : ℕ)\n  (h : r * c > 0)\n  (data : vector α (r * c))\n\nstructure vec_grid₀ (α : Type) extends vec_grid α :=\n  (o : point)\n\nstructure fgrid₀ (α : Type) :=\n  (r : ℕ)\n  (c : ℕ)\n  (h : r * c > 0)\n  (o : point)\n  (data : bounded o.y (o.y + r) → bounded o.x (o.x + c) → α)\n\nend grid_impls\n\nsection grid_instances\n\nopen relative_grid grid\n\nlemma data_not_empty {α : Type} {g : vec_grid₀ α} : ¬empty_list g.data.to_list :=\nassume contra,\nbegin\n  simp [empty_list] at contra,\n  have contra₁ := contra.symm,\n  rw [list_empty_iff_len, vector.to_list_length] at contra₁,\n  rcases g with ⟨⟨_, _, h,_⟩, _⟩,\n  linarith\nend\n\nlemma linearize_array {x y r c : ℕ}\n  (xb : x < c) (yb : y < r) : y * c + x < r * c :=\nhave h₁ : y * c < r * c, by apply mul_lt_mul yb; omega,\nhave h₂ : ∃n, nat.succ y + n = r, from nat_le_dest yb,\nlet ⟨n, h₂⟩ := h₂ in\n  by rw [← h₂, right_distrib, nat.succ_mul, add_assoc]; linarith\n\ndef rel_point_to_fin {α : Type} [grid α] {g : α}\n  (p : relative_point g) : fin (size g) :=\n  ⟨p.x * cols g + p.y, linearize_array p.y.2 p.x.2⟩\n\ndef grid_point_to_fin {α : Type} [grid α] {g : α}\n  (p : grid_point g) : fin (size g) := rel_point_to_fin (relpoint_of_gpoint p)\n\nlemma expand_grid_point_to_fin {α : Type} [grid α] {g : α}\n  (p : grid_point g) : grid_point_to_fin p =\n  ⟨|p.y.1 - (bl g).y| * cols g + |p.x.1 - (bl g).x|,\n  linearize_array\n    begin\n      rcases p with ⟨_, ⟨y, ⟨_, yu⟩⟩⟩,\n      simp only [tl], rw ← int.coe_nat_lt_coe_nat_iff,\n      have : y - (grid.bl g).x ≥ 0, by rw [ge_from_le]; linarith,\n      rw int.nat_abs_of_nonneg this,\n      simp [expand_gtr] at yu,\n      linarith\n    end\n    begin\n      rcases p with ⟨⟨x, ⟨xl, xu⟩⟩, _⟩,\n      simp only [tl], rw ← int.coe_nat_lt_coe_nat_iff,\n      have : x - (bl g).y ≥ 0, by linarith,\n      rw [int.nat_abs_of_nonneg this, rows_eq_try_sub_bly'],\n      linarith\n    end⟩ :=\n  by simp [grid_point_to_fin, relpoint_of_gpoint, rel_point_to_fin]; unfold_coes\n\ninstance rg_vec_grid {α : Type} :\n  relative_grid (vec_grid α) := {\n    carrier  := α,\n    rows     := λg, g.r,\n    cols     := λg, g.c,\n    nonempty := λg, g.h,\n    data     :=\n    λg y x,\n      g.data.nth ⟨\n        y.1 * g.c + x.1,\n        linearize_array x.2 y.2\n      ⟩    \n}\n\ninstance rg_vec_grid₀ {α : Type} :\n  relative_grid (vec_grid₀ α) := {\n    carrier  := α,\n    rows     := λg, g.r,\n    cols     := λg, g.c,\n    nonempty := λg, g.h,\n    data     :=\n    λg y x,\n      g.data.nth ⟨\n        y.1 * g.c + x.1,\n        linearize_array x.2 y.2\n      ⟩   \n}\n\nprivate lemma absolute_bounds {o : ℤ} {r : ℕ}\n                              (x : fin r) : o + ↑x < o + ↑r :=\n  by simp; cases x; unfold_coes; simpa\n\ninstance rg_fgrid₀ {α : Type} :\n  relative_grid (fgrid₀ α) := {\n    carrier  := α,\n    rows     := λg, g.r,\n    cols     := λg, g.c,\n    nonempty := λg, g.h,\n    data     := λg y x,\n      g.data ⟨g.o.y + y, ⟨by simp, absolute_bounds _⟩⟩\n             ⟨g.o.x + x, ⟨by simp, absolute_bounds _⟩⟩\n}\n\ninstance ag_vec_agrid₀ {α : Type} :\n  grid (vec_grid₀ α) := {\n    bl := λg, g.o\n  }\n\ninstance ag_fgrid₀ {α : Type} :\n  grid (fgrid₀ α) := {\n    bl := λg, g.o\n  }\n\ndef point_of_grid_point {α : Type*} [grid α] {g : α} : grid_point g → point\n  | ⟨b₁, b₂⟩ := ⟨b₂, b₁⟩\n\ninstance point_grid_point_coe {α : Type*} [grid α] (g : α) :\n  has_coe (grid_point g) point := ⟨point_of_grid_point⟩\n\nend grid_instances\n\nsection finite_grid\n\nopen list int function\n\nsection spec\n\nopen grid relative_grid\n\nvariables {α : Type} {ag : vec_grid₀ α} {fg : fgrid₀ α}\n\nlemma coe_rows_pos_a : ↑ag.r > (0 : ℤ) :=\n  by change ag.r with (rows ag); simp [gt_from_lt, rows_pos]\n\nlemma coe_rows_pos_f : ↑fg.r > (0 : ℤ) :=\n  by change fg.r with (rows fg); simp [gt_from_lt, rows_pos]\n\nlemma coe_cols_pos_a : ↑ag.c > (0 : ℤ) :=\n  by change ag.c with (cols ag); simp [gt_from_lt, cols_pos]\n\nlemma coe_cols_pos_f : ↑fg.c > (0 : ℤ) :=\n  by change fg.c with (cols fg); simp [gt_from_lt, cols_pos]\n\nend spec\n\nvariables {α : Type*} [grid α] (g : α)\n\ndef grp (a b row : ℤ) : list point :=\n  map (uncurry point.mk) $ zip (range_pure a b)\n                               (repeat row ( |b - a| ))\n\nprivate lemma expand_grp {a b r} (h : a < b) :\n  grp a b r =\n  ⟨a, r⟩ :: grp (a + 1) b r :=\nbegin\n  conv_lhs { simp only [grp] },\n  rw range_pure_next h,\n  have : |b - a| ≥ 1, from nat_abs_ge_one_of_lt h,\n  rw repeat_more this, simp [-sub_eq_add_neg],\n  exact ⟨\n    by simp [uncurry],\n    by simp [grp, -sub_eq_add_neg, abs_minus_plus h]\n  ⟩\nend\n\nprivate lemma expand_grp_g {g : α} :\n  grp (gbl g).x (gtr g).x (gtr g).y =\n  ⟨(gbl g).x, (gtr g).y⟩ ::\n  grp ((gbl g).x + 1) (gtr g).x (gtr g).y :=\nbegin\n  simp only [grp],\n  have h : range_pure ((gbl g).x) ((gtr g).x) =\n           (gbl g).x ::\n           range_pure (((gbl g).x) + 1) ((gtr g).x),\n    from range_pure_next (grid_bounded_iff.1 grid_is_bounding_box).1,\n  rw h,\n  have h₁ : repeat ((gtr g).y)\n                   ( |(gtr g).x - (gbl g).x| ) =\n            (gtr g).y :: repeat (gtr g).y ( |(gtr g).x - (gbl g).x| - 1),\n    {\n      simp only [expand_gbl], apply repeat_more,\n      rw ← cols_eq_trx_sub_blx,\n      exact abs_cols_pos\n    },\n  simp only [map, h₁, zip_cons_cons],\n  exact ⟨\n    by simp [uncurry],\n    by rw abs_minus_plus;\n       exact (grid_bounded_iff.1 grid_is_bounding_box).1\n  ⟩\nend\n\nprivate lemma grp_empty_iff {a b r} :\n  empty_list (grp a b r) ↔ b ≤ a :=\n  ⟨\n    assume h, begin\n      by_cases contra : a < b,\n        {rw expand_grp at h, cases h, exact contra},\n        {exact le_of_not_lt contra}\n    end,\n    assume h, begin\n      unfold grp,\n      have : range_pure a b = [],\n        by unfold1 range_pure; exact if_neg (not_lt_of_le h),\n      simp [zip_nil_left, empty_list, this]\n    end\n  ⟩\n\nlemma grp_empty_iff' {a b r} : grp a b r = [] ↔ (b ≤ a) :=\nbegin\n  split; intros h,\n    {rw ← grp_empty_iff, simp [empty_list, h.symm]},\n    {\n      have : empty_list (grp a b r), from grp_empty_iff.2 h,\n      simp only [empty_list] at this,\n      exact this.symm\n    }\nend\n\nlemma grp_nil_iff {x y} : grp x x y = [] :=\n  have h : empty_list (grp x x y), from grp_empty_iff.2 (le_refl _),\n  h.symm\n\nlemma in_grp_second {a b r} {p} (h₁ : p ∈ grp a b r) :\n  p.y = r :=\nbegin\n  cases p with px py, simp only [point.y] at *,\n  revert h₁,\n  induction eq : grp a b r with hd tl generalizing a; intros,\n    {cases h₁},\n    {\n      by_cases h : a < b,\n        {\n          rw expand_grp h at eq, injection eq with eq₁ eq₂,\n          rw mem_cons_iff at h₁, cases h₁ with h₁ h₁,\n            {cc},\n            {\n              by_cases h₂ : a + 1 < b,\n                {exact ih eq₂ h₁,},\n                {\n                  rw not_lt at h₂, \n                  rw grp_empty_iff'.2 h₂ at eq₂, subst eq₂,\n                  cases h₁\n                }\n            }\n        },\n        {rw not_lt at h, rw grp_empty_iff'.2 h at eq, cases eq}\n    }\nend\n\nlemma in_grp_iff {a b r} {c : point} (h₀ : a < b) :\n  c ∈ grp a b r ↔ is_bounded a b c.x ∧ c.y = r :=\nbegin\n  split; intros h,\n    {\n      split, unfold grp at h, simp [-sub_eq_add_neg, uncurry] at h,\n      rcases h with ⟨a₁, b₂, ⟨h₁, h₂⟩⟩,\n      have : a₁ ∈ range_pure a b, from pair_in_zip_l h₁,\n      rw in_range_pure_iff at this,\n      cases c, cc, exact in_grp_second h\n    },\n    {\n      cases c with x y, simp only [point.x, point.y] at *,\n      unfold is_bounded at h,\n      rcases h with ⟨⟨h, h₁⟩, h₂⟩, simp [grp, -sub_eq_add_neg, uncurry],\n      use x, use y, split,\n        {\n          apply in_zip_of_and, intros, subst h₂, \n          exact eq_of_mem_repeat H,\n          rw in_range_pure_iff, unfold is_bounded, exact ⟨h, h₁⟩,\n          rw length_repeat, rw range_length_pure (int.le_of_lt h₀)\n        },\n        {simp}\n    }\nend\n\nlemma notin_grp_of_lt {p : point} {a b r : ℤ} (h : p.x < a) :\n  p ∉ grp a b r := \nbegin\n  cases p with px py, simp only [point.x] at *,  \n  induction eq : grp a b r with hd tl generalizing a,\n    {intros contra, cases contra},\n    {\n      by_cases h₁ : a < b,\n        {\n          rw expand_grp h₁ at eq, injection eq with eq₁ eq₂, clear eq,\n          intros contra, cases contra,\n            {subst eq₁, subst eq₂, cases contra, linarith},\n            {\n              by_cases h₂ : a + 1 < b,\n                {\n                  specialize @ih (a + 1) (by linarith) eq₂,\n                  contradiction\n                },\n                {\n                  rw not_lt at h₂, rw grp_empty_iff'.2 h₂ at eq₂,\n                  subst eq₂, cases contra\n                }\n            }\n        },\n        {rw not_lt at h₁, rw grp_empty_iff'.2 h₁ at eq, cases eq}\n    }\nend\n\nlemma nodup_grp {a b r} : nodup (grp a b r) :=\nbegin\n  induction eq : grp a b r with hd tl generalizing a,\n    {exact nodup_nil},\n    {\n      by_cases h : a < b,\n        {\n          rw expand_grp h at eq, injection eq with eq₁ eq₂,\n          rw nodup_cons, split,\n            {\n              rw [← eq₂, ← eq₁],\n              apply notin_grp_of_lt,\n              simp only [point.x], linarith\n            },\n            {exact ih eq₂}\n        },\n        {rw not_lt at h, rw grp_empty_iff'.2 h at eq, cases eq}\n    }\nend\n\nopen function\n\nprivate lemma grp_bounds {a b row : ℤ} :\n  ∀{c : point}, c ∈ grp a b row →\n    is_bounded a b c.x ∧ is_bounded row (row + 1) c.y :=\nassume c h,\nbegin\n  simp [grp] at h,\n  rcases h with ⟨a₁, ⟨b₁, ⟨h₂, h₃⟩⟩⟩,\n  have h₄ : a₁ ∈ range_pure a b, from pair_in_zip_l h₂,\n  have h₅ : b₁ ∈ repeat row ( |b + -a| ), from pair_in_zip_r h₂,\n  rw ← h₃,\n  split; split,\n    {exact (range_pure_bounded h₄).1},\n    {exact (range_pure_bounded h₄).2},\n    {simp [repeat_bounded h₅, uncurry]},\n    {rw (repeat_bounded h₅), exact lt_add_succ _ _}\nend\n\nlemma length_grp {a b : ℤ} (h : a < b) {x : ℤ} :\n  length (grp a b x) = |b - a| :=\nhave h₁ : length (range_pure a b) = |b - a|,\n  from range_length_pure (int.le_of_lt h),\n  by simp [grp, length_map, length_zip_left, length_repeat, h₁]\n\nlemma injective_grp {a b} (h : a < b) : injective (grp a b) :=\nbegin\n  intros a₁ a₂,\n  induction eq : grp a b a₁ with hd tl ih generalizing a; intros h₁,\n    {rw expand_grp h at eq, cases eq},\n    {\n      rw expand_grp h at eq h₁,\n      injection eq with eq₁ eq₂, injection h₁ with h₂ h₃,\n      by_cases alt : a + 1 < b,\n        {exact ih alt eq₂ h₃},\n        {cc}\n    }\nend\n\nlemma disjoint_grp_neq_row {a b r₁ r₂} (h₀ : r₁ ≠ r₂) :\n  disjoint (grp a b r₁) (grp a b r₂) :=\nbegin\n  by_cases h : a < b,\n    {\n      induction eq : grp a b r₁ with hd tl ih generalizing a,\n        {rw expand_grp h at eq, cases eq},\n        {\n          cases eq₁ : grp a b r₂ with hd₁ tl₁,\n            {rw expand_grp h at eq₁, cases eq₁},\n            {\n              rw expand_grp h at eq₁, rw expand_grp h at eq,\n              injection eq₁ with eq₂ eq₃,\n              injection eq with eq₄ eq₅,\n              clear eq eq₁,\n              simp only [mem_cons_iff, disjoint_cons_left, disjoint_cons_right],\n              split,\n                {\n                  intros contra, cases contra,\n                    {cc},\n                    {\n                      rw ← eq₅ at contra,\n                      have : hd₁.y = r₁, from in_grp_second contra,\n                      clear contra, subst this, subst eq₄, subst eq₅, subst eq₂,\n                      cc\n                    }\n                },\n                {\n                  split,\n                    {\n                      intros contra, rw ← eq₃ at contra,\n                      have : hd.y = r₂, from in_grp_second contra,\n                      clear contra, subst this, subst eq₄, subst eq₅, subst eq₂,\n                      cc \n                    },\n                    {\n                      rw ← eq₃,\n                      by_cases h₁ : a + 1 < b,\n                        {\n                          exact ih h₁ eq₅\n                        },\n                        {\n                          rw not_lt at h₁,\n                          rw [grp_empty_iff'.2 h₁, disjoint_comm],\n                          exact disjoint_nil_left _,\n                        }\n                    }\n                }\n            }\n        }\n    },\n    {rw not_lt at h, simp [grp_empty_iff'.2 h]}\nend\n\ndef gip (p₁ p₂ : point) : list point :=\n  join (map (grp p₁.x p₂.x) (range_pure p₁.y p₂.y))\n\nlemma gip_no_dup {p₁ p₂} : nodup (gip p₁ p₂) :=\nbegin\n  cases p₁ with p₁x p₁y,\n  cases p₂ with p₂x p₂y,\n  simp only [gip, nodup_join],\n  split,\n    {\n      intros l hl, \n      by_cases h : p₁x < p₂x,\n        {\n          have : nodup (map (grp p₁x p₂x) (range_pure p₁y p₂y)),\n            from nodup_map (injective_grp h) (nodup_range_pure),\n          induction l with hd tl ih generalizing p₁x,\n            {exact nodup_nil},\n            {\n              simp only [map, mem_map] at hl,\n              rcases hl with ⟨l, ⟨c₁, c₂⟩⟩, rw ← c₂,\n              exact nodup_grp\n            }\n        },\n        {\n          rw not_lt at h, simp only [map, mem_map] at hl,\n          rcases hl with ⟨l', ⟨c₁, c₂⟩⟩,\n          rw grp_empty_iff'.2 h at c₂,\n          simp [c₂.symm, nodup_nil]\n        }\n    },\n    {\n      induction eq : range_pure p₁y p₂y with hd tl ih generalizing p₁y,\n        {simp, constructor},\n        {\n          by_cases h : p₁y < p₂y,\n            {\n              rw range_pure_next h at eq, injection eq with eq₁ eq₂,\n              specialize @ih (p₁y + 1) eq₂,\n              simp only [\n                and_imp, disjoint_comm, pairwise_cons, map, mem_map, exists_imp_distrib\n              ], split; try { assumption },\n              intros l x h₁ h₂, subst h₂,\n              have : x ≠ hd,\n                {\n                  intros contra, subst contra, subst eq₁,\n                  rw ← eq₂ at h₁,\n                  have : p₁y ∉ range_pure (p₁y + 1) p₂y,\n                    from @notin_range_pure_of_lt (p₁y + 1) p₂y p₁y (by linarith),\n                  contradiction\n                },\n              exact disjoint_grp_neq_row this\n            },\n            {\n              rw not_lt at h, rw range_pure_empty_iff.2 h at eq,\n              cases eq\n            }\n        }\n    }\nend\n\nopen relative_grid grid\n\ndef gip_g := gip (bl g) (gtr g)\n\nprivate lemma expand_gip {p₁ p₂} (h : p₁ ↗ p₂) :\n  gip p₁ p₂ = ⟨p₁.x, p₁.y⟩ :: grp (p₁.x + 1) p₂.x p₁.y\n           ++ gip ⟨p₁.x, p₁.y + 1⟩ p₂ :=\n  by simp [\n       gip, expand_grp (grid_bounded_iff.1 h).1,\n       range_pure_next (grid_bounded_iff.1 h).2\n     ]\n\nprivate lemma expand_row_gip {p₁ p₂} (h : p₁ ↗ p₂) :\n  gip p₁ p₂ =\n  grp p₁.x p₂.x p₁.y ++ gip ⟨p₁.x, p₁.y + 1⟩ p₂ :=\n  by simp [gip, range_pure_next (grid_bounded_iff.1 h).2]\n\nprivate lemma expand_gip_g :\n  (gip_g g) = grp (gbl g).x (gtr g).x (gbl g).y\n              ++ gip ⟨(gbl g).x, (gbl g).y + 1⟩ ⟨(gtr g).x, ((gtr g).y)⟩ :=\nbegin\n  generalize h : gip ⟨(gbl g).x, (gbl g).y⟩ ⟨(gtr g).x, ((gtr g).y + 1)⟩ = t,\n  simp only [gip_g, gip],\n  rw range_pure_next, dsimp,\n    {apply congr_arg, simp [h.symm, gip]},\n    {exact try_lt_bly}\nend\n\ndef is_in_grid' (xy : point) :=\n  is_bounded (gbl g).y (gtr g).y xy.y ∧\n  is_bounded (gbl g).x (gtr g).x xy.x\n\ndef is_in_grid (bb : bounding_box) (xy : point) :=\n  is_bounded bb.p₁.y bb.p₂.y xy.y ∧ is_bounded bb.p₁.x bb.p₂.x xy.x\n\nattribute [reducible]\ninstance has_mem_grid : has_mem point α := ⟨flip is_in_grid'⟩\n\nattribute [reducible]\ninstance has_mem_bb : has_mem point bounding_box := ⟨flip is_in_grid⟩\n\nlemma gip_in_grid {p₁ p₂ : point} {h : p₁ ↗ p₂} :\n  ∀{a}, a ∈ gip p₁ p₂ → a ∈ (⟨p₁, p₂, h⟩ : bounding_box) :=\nassume a h,\nbegin\n  simp [gip] at h,\n  cases a with al ar,\n  rcases h with ⟨l, ⟨⟨a₁, ⟨h₂, h₃⟩⟩, h₁⟩⟩,\n  have h₄ := range_pure_bounded h₂, rw ← h₃ at h₁,\n  have h₅ := grp_bounds h₁,\n  split; split,\n    {\n      simp [bounding_box.p₁],\n      rcases h₅ with ⟨⟨h₅l₁, h₅l₂⟩, ⟨h₅r₁, h₅r₂⟩⟩,\n      cases h₄, transitivity a₁; assumption\n    },\n    {exact lt_of_le_of_lt (le_of_lt_add_one h₅.2.2) h₄.2},\n    {exact h₅.1.1},\n    {exact h₅.1.2}\nend\n\ndef grid_bounds : bounding_box :=\n  ⟨gbl g, gtr g, grid_is_bounding_box⟩\n\nlemma grid_bounds_p₁ : (grid_bounds g).p₁ = gbl g := rfl\n\nlemma grid_bounds_p₂ : (grid_bounds g).p₂ = gtr g := rfl\n\nlemma gip_g_in_grid {g : α} :\n  ∀{a}, a ∈ gip_g g → a ∈ (grid_bounds g) :=\n  assume a h, gip_in_grid h\n\ndef make_bounded_idx {g : α} {p : point} (h : p ∈ (grid_bounds g)) :\n  bounded (bl g).x (gtr g).x ×\n  bounded (gbl g).y (gtr g).y :=\n    (make_bounded h.2, make_bounded h.1)\n\nprivate def make_bounded_indices (is : list point)\n                         (h : ∀p, p ∈ is → p ∈ (grid_bounds g)) :\n  list (\n    bounded (bl g).x (gtr g).x ×\n    bounded (gbl g).y (gtr g).y\n  ) := map (λp : {x // x ∈ is},\n           (⟨p.1.1, (h p.1 p.2).2⟩,\n            ⟨p.1.2, (h p.1 p.2).1⟩)) (attach is)\n\nlemma is_bounded_y_of_grid_bounds {g : α} {p} (h : p ∈ (grid_bounds g)) :\n  is_bounded (bl g).y (gtr g).y p.y :=\n  by simp [grid_bounds, (∈), flip, is_in_grid] at h; exact h.1\n\nlemma is_bounded_x_of_grid_bounds {g : α} {p} (h : p ∈ (grid_bounds g)) :\n  is_bounded (bl g).x (gtr g).x p.x :=\n  by simp [grid_bounds, (∈), flip, is_in_grid] at h; exact h.2\n\ninstance decidable_is_in_grid' {xy : point}\n   : decidable (is_in_grid' g xy) :=\n   by simp [is_in_grid']; apply_instance\n\ninstance decidable_is_in_grid (bb : bounding_box) {xy : point}\n   : decidable (is_in_grid bb xy) :=\n   by simp [is_in_grid]; apply_instance\n\ninstance decidable_is_in_grid'_op {xy : point}\n   : decidable (xy ∈ g) :=\n   by simp [(∈), is_in_grid', flip]; apply_instance\n\ninstance decidable_is_in_grid_op (bb : bounding_box) {xy : point}\n   : decidable (xy ∈ bb) :=\n   by simp [is_in_grid, (∈), flip]; apply_instance\n\ndef inject_into_bounded (p : {x // x ∈ gip_g g}) :\n  bounded (bl g).x (gtr g).x ×\n  bounded (gbl g).y (gtr g).y :=\n  make_bounded_idx (gip_g_in_grid p.2)\n\nprivate def inject_row_into_bounded\n  {a b r} (p : {x // x ∈ grp a b r}) :\n  bounded a b × bounded r (r + 1) :=\n  ⟨⟨p.1.1, (grp_bounds p.2).1⟩, ⟨p.1.2, (grp_bounds p.2).2⟩⟩\n\nprivate lemma blgx_trgx_of_mem {g : α} {x} {y} (h : point.mk x y ∈ g) :\n  (bl g).x < (gtr g).x :=\n  by simp only [(∈), flip, is_in_grid'] at h; exact lt_of_le_of_lt h.2.1 h.2.2\n\ntheorem in_gip_g_of_in_g {α : Type*} [grid α] {g : α} {p}\n  (h : p ∈ g) : p ∈ gip_g g :=\nbegin  \n  cases p with x y,\n  simp [-gtr, gip_g, gip],\n  have h₂ : y ∈ range_pure (gbl g).y (gtr g).y,\n    by simp [(∈), flip, is_in_grid'] at h; exact in_range_iff.2 h.1,\n  split, {\n    split,\n      {use y, exact ⟨h₂, by simp [grp]⟩},\n      {\n        generalize h₂ : range_pure ((bl g).x) ((gtr g).x) = l₁,\n        generalize h₃ : repeat y ( |(gtr g).x - (bl g).x| ) = l₂,\n        rw point_in_zip_prod_iff,\n        apply point_in_zip_repeat_right _ h₃ _,\n          {\n            simp [\n              h₂.symm, h₃.symm, range_length_pure, length_repeat,\n              int.le_of_lt (blgx_trgx_of_mem h)\n            ]\n          },\n          {\n            rw [← h₂, in_range_iff],\n            simp only [(∈), flip, is_in_grid'] at h,\n            exact h.2\n          }\n      }\n    }\nend\n\ntheorem in_grid_iff_in_gip_g {p} {g : α} : p ∈ g ↔ p ∈ gip_g g :=\n  ⟨\n    in_gip_g_of_in_g,\n    λh, by apply gip_in_grid h; exact grid_is_bounding_box\n  ⟩\n \nlemma in_grid_iff_in_grid_bounds {p} {g : α} : p ∈ grid_bounds g ↔ p ∈ g :=\n  by split; intros h;\n       simp [(∈), flip, is_in_grid, grid_bounds, is_in_grid'] at *;\n         exact h\n\nlemma is_bounded_rows_of_in_gip_g {p} {g : α} (h : p ∈ gip_g g) :\n  is_bounded (gbl g).y ((gbl g).y + ↑(rows g)) p.y :=\n  (in_grid_iff_in_gip_g.2 h).1\n\nlemma is_bounded_cols_of_in_gip_g {p} {g : α} (h : p ∈ gip_g g) :\n  is_bounded (gbl g).x ((gbl g).x + ↑(cols g)) p.x :=\n  (in_grid_iff_in_gip_g.2 h).2\n\ndef grid_point_of_mem {p} (h : p ∈ g) : grid_point g :=\n  ⟨make_bounded h.1, make_bounded h.2⟩\n\ndef generate :=\n  map (abs_data g ∘ grid_point_of_prod ∘ inject_into_bounded g)\n      (attach $ gip_g g)\n\nnotation `℘` g:max := generate g\n\nsection grid_instances\n\ninstance vec_grid_functor : functor vec_grid := {\n  map := λα β f g, {g with data := vector.map f g.data}\n}\n\ninstance vec_grid_functor_law : is_lawful_functor vec_grid := {\n  id_map := λα ⟨r, c, h, d⟩, by unfold functor.map; simp,\n  comp_map := λα β γ f h ⟨r, c, h, d⟩, by simp [(<$>)]\n}\n\ninstance vec_grid₀_functor : functor vec_grid₀ := {\n  map := λα β f g, {g with data := vector.map f g.data}\n}\n\ninstance vec_grid₀_functor_law : is_lawful_functor vec_grid₀ := {\n  id_map := λα ⟨⟨r, c, h, d⟩, o⟩, by simp [(<$>)],\n  comp_map := λα β γ f h ⟨⟨r, c, h, d⟩, o⟩, by simp [(<$>)]\n}\n\ninstance fgrid₀_functor : functor fgrid₀ := {\n  map := λα β f g, {g with data := λx y, f (g.data x y)}\n}\n\ninstance fgrid₀_functor_law : is_lawful_functor fgrid₀ := {\n  id_map := λα ⟨r, c, h, d, o⟩, by simp [(<$>)],\n  comp_map := λα β γ f h ⟨r, c, h, d, o⟩, by simp [(<$>)]\n}\n\nend grid_instances\n\nattribute [simp]\nlemma vec_grid_fmap_r {α β : Type} {g : vec_grid α} {f : α → β} : (f <$> g).r = g.r :=\n  by simp [(<$>)]\n\nattribute [simp]\nlemma vec_grid_fmap_c {α β : Type} {g : vec_grid α} {f : α → β} : (f <$> g).c = g.c :=\n  by simp [(<$>)]\n\nattribute [simp]\nlemma vec_grid₀_fmap_r {α β : Type} {g : vec_grid₀ α} {f : α → β} : (f <$> g).r = g.r\n  := by simp [(<$>)]\n\nattribute [simp]\nlemma vec_grid₀_fmap_c {α β : Type} {g : vec_grid₀ α} {f : α → β} : (f <$> g).c = g.c\n  := by simp [(<$>)]\n\nattribute [simp]\nlemma fgrid₀_fmap_r {α β : Type} {g : fgrid₀ α} {f : α → β} : (f <$> g).r = g.r\n  := by simp [(<$>)]\n\nattribute [simp]\nlemma fgrid₀_fmap_c {α β : Type} {g : fgrid₀ α} {f : α → β} : (f <$> g).c = g.c\n  := by simp [(<$>)]\n\ndef point_of_bounded_prod {a b c d : ℤ} : bounded a b × bounded c d → point\n  | ⟨⟨a, _⟩, ⟨c, _⟩⟩ := ⟨a, c⟩\n\nlemma gip_g_nonempty : ¬empty_list (gip_g g) :=\nassume contra,\nbegin\n  simp [gip_g, gip] at contra,\n  have c₁ : ¬empty_list (\n    range_pure (bl g).y (gtr g).y\n  ),\n    {\n      simp only [empty_list], intros c₂, symmetry' at c₂,\n      rw range_pure_empty_iff at c₂,\n      have c₃ := @grid_is_bounding_box _ _ g, rw grid_bounded_iff at c₃,\n      exact absurd (lt_of_le_of_lt c₂ c₃.2) (lt_irrefl _)\n    },\n  have c₂ := @not_map_empty_of_not_empty _ _ _\n    (grp (bl g).x (tr (bl g) (rows g) (cols g)).x) c₁,\n  have c₃ := not_join_empty_of_not_empty contra,\n  cases c₃,\n    {contradiction},\n    {\n      revert c₃ contra c₂ c₁,\n      generalize c₆ : bl g = bl,\n      generalize c₅ : tr bl (rows g) (cols g) = tr',\n      generalize c₄ :\n        map (grp bl.x tr'.x) (range_pure bl.y (gtr g).y) = l,\n      let h₃ := @grid_is_bounding_box _ _ g, rw grid_bounded_iff at h₃,\n      simp [gtr, c₆, c₅] at h₃,\n      intros,\n      have c₅ : ∃z ∈ l, ¬empty_list z,\n        {\n          let h := grp bl.x tr'.x bl.y,\n          have h₁ : h = grp bl.x tr'.x bl.y, by cc,\n          use h, split,\n            {\n              rw h₁, revert c₄,\n              generalize h₂ : range_pure bl.y tr'.y = l₁, intros,\n              cases l₁ with w ws,\n                {\n                  rw range_pure_empty_iff at h₂,\n                  exact absurd (lt_of_le_of_lt h₂ h₃.2) (lt_irrefl _)\n                },\n                {\n                  have h₄ : w = bl.y,\n                    by unfold1 range_pure at h₂; rw if_pos h₃.2 at h₂;\n                       injection h₂ with h₃ _; rw h₃,\n                  have : bl.y < (gtr g).y, by subst c₅; simp [gtr, c₆]; exact h₃.2,\n                  simp [c₄.symm, range_pure_next this]\n                },\n            },\n            {\n              unfold1 grp at h₁,\n              have h₂ : tr'.x > bl.x, from h₃.1,\n              have h₄ : range_pure (bl.x) (tr'.x) =\n                        bl.x :: range_pure (bl.x + 1) (tr'.x),\n                from range_pure_next h₂,\n              rw h₄ at h₁,\n              have : |tr'.x - bl.x| ≥ 1,\n                begin\n                  apply nat.succ_le_of_lt (lt_of_coe_nat_lt_coe_nat _),\n                  rw [nat_abs_of_nonneg, lt_sub],\n                  simpa, linarith\n                end,\n              have h₅ : repeat bl.y ( |tr'.x - bl.x| ) =\n                bl.y :: repeat bl.y (( |tr'.x - bl.x| ) - 1),\n                from repeat_more this,\n              rw [h₅, zip_cons_cons, map_cons] at h₁, rw h₁,\n              apply not_empty_cons\n            }\n        },\n      rcases c₅ with ⟨c₅l, ⟨c₅₁, c₅₂⟩⟩, rw [← c₄, ← c₅] at c₅₁,\n      simp only [gtr] at c₃, subst c₆,\n      exact absurd (c₃ c₅l c₅₁) c₅₂\n    }\nend\n\nlemma length_gip {p₁ p₂ : point} (h : p₁ ↗ p₂) :\n  length (gip p₁ p₂) = |p₂.y - p₁.y| * |p₂.x - p₁.x| :=\nbegin\n  rw [← int.coe_nat_eq_coe_nat_iff, ← nat_abs_mul],\n  rw grid_bounded_iff at h,\n  have h₁ : (p₂.y - p₁.y) * (p₂.x - p₁.x) > 0,\n    {cases p₁, cases p₂, apply mul_pos; omega},\n  simp [\n    -sub_eq_add_neg, gip, length_join, (∘), length_grp h.1,\n    range_length_pure (int.le_of_lt h.2),\n    nat_abs_of_nonneg (int.le_of_lt h₁)\n  ],\n  repeat {rw nat_abs_of_nonneg}; simp [-sub_eq_add_neg, ge_from_le];\n  apply int.le_of_lt; simp [h.1, h.2]\nend\n\ntheorem length_gip_g : length (gip_g g) = rows g * cols g :=\n  by simp [\n       gip_g, length_gip, rows_eq_try_sub_bly, cols_eq_trx_sub_blx,\n       grid_is_bounding_box\n     ]\n\nprivate theorem length_generate {α : Type*} [grid α] (g : α) :\n  length (℘ g) = grid_rows g * grid_cols g :=\nby unfold generate gip_g;\n   rw [\n     length_map, grid_rows_eq_try_sub_bly, grid_cols_eq_trx_sub_blx,\n     length_attach, length_gip_g, rows_eq_try_sub_bly, cols_eq_trx_sub_blx\n   ]\n\nlemma length_generate_eq_size :\n  length (℘ g) = size g := by simp [size, length_generate]\n\nlemma map_generate_map_v₀ {α β : Type} {g : vec_grid₀ α} {f : α → β} :\n  f <$> (℘ g) = ℘ (f <$> g) :=\n  by simpa [(<$>), generate, abs_data, data, vector.nth_map, (∘)]\n\nlemma map_generate_map_f₀ {α β : Type} (g : fgrid₀ α) {f : α → β} :\n  f <$> (℘ g) = ℘ (f <$> g) :=\n  by simpa [(<$>), generate, abs_data, data]\n\nlemma dec_grid_len_eq_indices_len :\n  length (℘ g) = length (gip_g g) :=\n  by simp [length_generate, length_gip_g]\n\ndef vec_grid₀_of_fgrid₀ {α : Type} (g : fgrid₀ α) : vec_grid₀ α :=\n  {g with data := ⟨℘ g, length_generate_eq_size _⟩}\n\ndef fgrid₀_of_vec_grid₀ {α : Type} (g : vec_grid₀ α) : fgrid₀ α :=\n  {g with data := λx y, abs_data g ⟨x, y⟩}\n\ninstance f₀_v₀_coe {α : Type} : has_coe (fgrid₀ α) (vec_grid₀ α) := ⟨vec_grid₀_of_fgrid₀⟩\ninstance v₀_f₀_coe {α : Type} : has_coe (vec_grid₀ α) (fgrid₀ α) := ⟨fgrid₀_of_vec_grid₀⟩\n\nattribute [simp]\nlemma vec_grid₀_of_fgrid₀_r {α : Type} {g : fgrid₀ α} :\n  (vec_grid₀_of_fgrid₀ g).r = g.r := by simp [vec_grid₀_of_fgrid₀]\n\nattribute [simp]\nlemma vec_grid₀_of_fgrid₀_c {α : Type} {g : fgrid₀ α} :\n  (vec_grid₀_of_fgrid₀ g).c = g.c := by simp [vec_grid₀_of_fgrid₀]\n\nattribute [simp]\nlemma vec_grid₀_of_fgrid₀_o {α : Type} {g : fgrid₀ α} :\n  (vec_grid₀_of_fgrid₀ g).o = g.o := by simp [vec_grid₀_of_fgrid₀]\n\nattribute [simp]\nlemma fgrid₀_of_vec_grid₀_r {α : Type} {g : vec_grid₀ α} :\n  (fgrid₀_of_vec_grid₀ g).r = g.r := by simp [fgrid₀_of_vec_grid₀]\n\nattribute [simp]\nlemma fgrid₀_of_vec_grid₀_c {α : Type} {g : vec_grid₀ α} :\n  (fgrid₀_of_vec_grid₀ g).c = g.c := by simp [fgrid₀_of_vec_grid₀]\n\nattribute [simp]\nlemma fgrid₀_of_vec_grid₀_o {α : Type} {g : vec_grid₀ α} :\n  (fgrid₀_of_vec_grid₀ g).o = g.o := by simp [fgrid₀_of_vec_grid₀]\n\nattribute [simp]\nlemma vec_grid₀_of_fgrid₀_gtr {α : Type} {g : fgrid₀ α} :\n  gtr (vec_grid₀_of_fgrid₀ g) = gtr g :=\n    by simp [expand_gtr, bl, cols, rows, vec_grid₀_of_fgrid₀]\n\nattribute [simp]\nlemma fgrid₀_of_vec_grid₀_gtr {α : Type} {g : vec_grid₀ α} :\n  gtr (fgrid₀_of_vec_grid₀ g) = gtr g :=\n    by simp [expand_gtr, bl, cols, rows, fgrid₀_of_vec_grid₀]\n\nprivate theorem nth_le_grp {n} {a b r : ℤ} (h : a < b) (H) :\n  nth_le (grp a b r) n H = ⟨a + n, r⟩ :=\nbegin\n  rw ← option.some_inj, rw ← nth_le_nth H,\n  induction n with n ih generalizing a b,\n    {simp [expand_grp h]},\n    {\n      simp [expand_grp h],\n      have : a + 1 < b,\n        begin\n          have : a + 1 ≠ b, assume contra, by\n            simp [contra.symm, @length_grp a (a + 1) (by cc)] at H;\n            clear contra h ih; omega,\n          by_contradiction h₁,\n          replace h₁ := le_of_not_lt h₁,\n          rw le_iff_eq_or_lt at h₁, cases h₁; try { cc },\n          have : a = b, by linarith, rw [this, length_grp] at H,\n          simp at H, cases H, linarith\n        end,\n      have lenok : n < length (grp (a + 1) b r),\n        begin\n          rw length_grp this, rw length_grp h at H,\n          have eq₁ : b - (a + 1) ≥ 0, by linarith,\n          have eq₂ : b - a ≥ 0, by linarith,\n          rw [← int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg eq₁],\n          rw [← int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg eq₂] at H,\n          simp, simp at H, linarith\n        end,\n      specialize @ih (a + 1) b this lenok,\n      simp [ih]\n    }\nend\n\nlemma bl_g_in_g {α : Type*} [grid α] {g : α} : bl g ∈ g :=\nbegin\n  simp only [has_mem.mem, flip, is_in_grid, is_in_grid', is_bounded, gbl],\n  split; split; try { linarith },\n  exact blgy_lt_trgy,\n  exact gblx_lt_gtrx\nend\n\nlemma bl_g_in_gip_g {α : Type*} [grid α] {g : α} : bl g ∈ gip_g g :=\n  in_grid_iff_in_gip_g.1 bl_g_in_g\n\ntheorem nth_grp {n} {a b r : ℤ} (h : a < b) (H : n < length (grp a b r)) :\n  nth (grp a b r) n = some ⟨a + n, r⟩ :=\n  by rw nth_le_nth H; exact congr_arg _ (nth_le_grp h _)\n\ntheorem nth_le_gip {n} {p₁ p₂ : point} (h : p₁ ↗ p₂) (H) :\n  nth_le (gip p₁ p₂) n H =\n  ⟨p₁.x + n % |p₂.x - p₁.x|, p₁.y + n / |p₂.x - p₁.x|⟩ :=\nbegin\n  cases p₁ with x₁ y₁, cases p₂ with x₂ y₂,\n  have x₁x₂ : x₁ < x₂, from (grid_bounded_iff.1 h).1,\n  have y₁y₂ : y₁ < y₂, from (grid_bounded_iff.1 h).2,\n  rw [← option.some_inj, ← nth_le_nth H], rw length_gip h at H,\n  repeat { rw nat_abs_of_nonneg (nonneg_of_lt x₁x₂) },\n  simp [-sub_eq_add_neg] at *,\n  have : y₂ = y₁ + (y₂ - y₁), by linarith,\n  rw this, clear this,\n  have : y₂ - y₁ = ↑|y₂ - y₁|,\n    by rw nat_abs_of_nonneg; exact nonneg_of_lt y₁y₂,\n  rw this, clear this,\n  generalize hrows : |y₂ - y₁| = rows, rw hrows at H,\n  induction rows with rows ih generalizing y₁ y₂ n,\n    {exfalso, simp at H, cases H},\n    {\n      rw expand_row_gip _,\n        {\n          by_cases h₁ : n < |x₂ - x₁|,\n            {\n              simp [-sub_eq_add_neg], rw [nth_split, nth_grp];\n              try {simpa [length_grp x₁x₂]},\n              congr' 2;\n              rw [\n                ← int.coe_nat_lt_coe_nat_iff,\n                nat_abs_of_nonneg (nonneg_of_lt x₁x₂)\n              ] at h₁,\n              rw mod_eq_of_lt (coe_zero_le _) h₁,\n              rw div_eq_zero_of_lt (coe_zero_le _) h₁,\n              simp\n            },\n            {\n              generalize hcols : x₂ - x₁ = cols,\n              have rowsnezero : rows ≠ 0, assume contra,\n                by simp [contra, -sub_eq_add_neg] at H; contradiction,\n              have colsnezero : cols ≠ 0, by linarith,\n              have x₂x₁n : |x₂ - x₁| ≤ n, from not_lt.1 h₁,\n              have lenok : ¬n < length (grp x₁ x₂ y₁),\n                by simpa [length_grp x₁x₂, -sub_eq_add_neg],\n              simp [-sub_eq_add_neg], rw nth_split_second lenok,\n              by_cases h₂ : y₁ + 1 < y₂,\n                {\n                  have h₃ : {x := x₁, y := y₁ + 1}↗{x := x₂, y := y₂},\n                    from ⟨x₁x₂, h₂⟩,\n                  have lenok :\n                    n - length (grp x₁ x₂ y₁) < rows * |x₂ - x₁|,\n                    {\n                      rw nat.succ_mul at H,\n                      rw [\n                        length_grp x₁x₂, ← int.coe_nat_lt_coe_nat_iff,\n                        int.coe_nat_sub x₂x₁n, int.coe_nat_mul,\n                        sub_lt_iff_lt_add, ← int.coe_nat_mul, ← int.coe_nat_add\n                      ],\n                      rwa int.coe_nat_lt_coe_nat_iff\n                    },\n                  have rowsok : |y₂ - (y₁ + 1)| = rows,\n                    by rw [← abs_minus_plus y₁y₂, hrows, nat.succ_sub_one],\n                  rw [\n                    ← add_assoc,\n                    @ih (y₁ + 1) y₂ (n - length (grp x₁ x₂ y₁)) h₃ h₂ rowsok lenok,\n                    length_grp x₁x₂\n                  ],\n                  simp [-sub_eq_add_neg],\n                  exact ⟨\n                    begin\n                      rw [\n                        int.coe_nat_sub x₂x₁n, nat_abs_of_nonneg, ← hcols,\n                        mod_eq_mod_iff_mod_sub_eq_zero, mod_eq_zero_of_dvd\n                      ],\n                      simp, rw ← dvd_neg, simp,\n                      exact nonneg_of_lt x₁x₂\n                    end,\n                    begin\n                      rw [\n                        int.coe_nat_sub x₂x₁n,\n                        nat_abs_of_nonneg (nonneg_of_lt x₁x₂), hcols\n                      ],\n                      simp,\n                      have : -cols = cols * (-1 : ℤ), by simp, rw this,\n                      rw int.add_mul_div_left _ _ colsnezero,\n                      simp\n                    end\n                  ⟩\n                },\n                {\n                  have h₃ : y₁ + 1 = y₂, by linarith,\n                  have h₄ : |y₂ - y₁| = 1, by simp [h₃.symm, add_sub_cancel'],\n                  rw h₄ at hrows, injection hrows with contra, cc\n                }\n            }\n      },\n      {\n        exact ⟨\n          (grid_bounded_iff.1 h).1,\n          begin\n            simp [\n              sub_lt_iff_lt_add, lt_add_iff_pos_right, -sub_eq_add_neg\n            ],\n            exact nat.cases_on rows\n              zero_lt_one\n              (λ_, lt_trans zero_lt_one (lt_add_succ _ _)),\n          end\n        ⟩\n      }\n    }\nend\n\ntheorem nth_le_gip_g {n} (H) :\n  nth_le (gip_g g) n H = ⟨(bl g).x + n % cols g, (bl g).y + n / cols g⟩ :=\nbegin\n  rw cols_eq_trx_sub_blx,\n  exact @nth_le_gip n (gbl g) (gtr g) grid_is_bounding_box H\nend\n\ntheorem nth_gip {n} {p₁ p₂ : point} (h : p₁ ↗ p₂) (H : n < length (gip p₁ p₂)) :\n  nth (gip p₁ p₂) n =\n  some ⟨p₁.x + n % |p₂.x - p₁.x|, p₁.y + n / |p₂.x - p₁.x|⟩ :=\n  by simp [nth_le_nth H, nth_le_gip h]\n\ntheorem nth_gip_g {n} (H : n < length (gip_g g)) :\n  nth (gip_g g) n = some ⟨(bl g).x + n % cols g, (bl g).y + n / cols g⟩ :=\n  by simp [nth_le_nth H, nth_le_gip_g]\n\ntheorem nth_generate {n} (H) :\n  nth_le (℘ g) n H =\n  abs_data g ⟨\n    ⟨(bl g).y + n / cols g, ⟨\n      by simp,\n      idx_div_cols_bounded (by rwa length_generate_eq_size at H)\n    ⟩⟩,\n    ⟨(bl g).x + n % cols g, ⟨\n      by simp,\n      idx_mod_cols_bounded⟩\n  ⟩⟩ :=\nbegin\n  rw length_generate at H,\n  rw [← option.some_inj, ← nth_le_nth],\n  simp only [\n    abs_data, (∘), relpoint_of_gpoint, prod_of_rel_point, expand_gtr,\n    generate, nth_map\n  ],\n  have : n < length (attach (gip_g g)), by simpa [length_attach, length_gip_g],\n  simp [\n    nth_le_nth this, inject_into_bounded, make_bounded_idx, make_bounded,\n    nth_le_gip_g, grid_point_of_prod, data_option\n  ]\nend\n\nlemma gip_g_expand : gip_g g =\n  bl g :: grp ((bl g).x + 1) (gtr g).x (bl g).y ++\n  gip ⟨(bl g).x, (bl g).y + 1⟩ (gtr g) :=\nbegin\n  unfold gip_g gip, rw range_pure_next, simp,\n  rw expand_grp, simp,\n  cases (bl g), simp,\n  exact gblx_lt_gtrx,\n  exact blgy_lt_trgy\nend\n\ntheorem nth_generate' {n} (h : n < length ℘ g) :\n  nth (℘ g) n =\n  some (abs_data g ⟨\n    ⟨(bl g).y + n / cols g, ⟨\n      by simp,\n      idx_div_cols_bounded (by rwa length_generate_eq_size at h)\n    ⟩⟩,\n    ⟨(bl g).x + n % cols g, ⟨\n      by simp,\n      idx_mod_cols_bounded⟩\n  ⟩⟩) := by simp [nth_le_nth h, congr_arg, nth_generate]\n\nlemma abs_data_eq_nth_v₀ {α : Type} {g : vec_grid₀ α} {p} :\n  abs_data g p = vector.nth g.data (grid_point_to_fin p) :=\n  by simpa [\n       abs_data, (∘), relpoint_of_gpoint, prod_of_rel_point, data,\n       grid_point_to_fin, rel_point_to_fin\n     ]\n\nlemma abs_data_eq_nth_v₀' {α : Type} {g : vec_grid₀ α} {p} :\n  abs_data g p =\n  vector.nth g.data ⟨|p.y.1 - g.o.y| * g.c + |p.x.1 - g.o.x|,\n  begin\n    rcases p with ⟨⟨x, ⟨xl, xu⟩⟩, ⟨y, ⟨yl, yu⟩⟩⟩,\n    simp [-sub_eq_add_neg],\n    simp [-sub_eq_add_neg, expand_gtr, bl, rows, cols] at *,\n    rw add_comm,\n    have eq₁ : |y - g.o.x| < g.c,\n      {\n        have : y - (g.o).x ≥ 0, by linarith,\n        rw [← int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg this],\n        linarith\n      },\n    have eq₂ : |x - g.o.y| < g.r,\n      {\n        have : x - g.o.y ≥ 0, by linarith,\n        rw [← int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg this],\n        linarith\n      },\n    exact linearize_array eq₁ eq₂\n  end⟩ :=\n  by simp [\n       abs_data, (∘), relpoint_of_gpoint, prod_of_rel_point, data,\n       grid_point_to_fin, rel_point_to_fin, bl, rows, cols\n     ]\n\nlemma abs_data_eq_nth_f₀ {α : Type} {g : fgrid₀ α} {p} :\n  abs_data g p = g.data p.y p.x :=\nbegin\n  rcases p with ⟨⟨x, ⟨xl, xu⟩⟩, ⟨y, ⟨yl, yu⟩⟩⟩,\n  simp only [\n    abs_data, (∘), relpoint_of_gpoint, prod_of_rel_point, data\n  ],\n  unfold_coes, simp only [fin.val, of_nat_eq_coe],\n  have h₁ : x - (bl g).y ≥ 0, by linarith,\n  have h₂ : y - (bl g).x ≥ 0, by linarith,\n  congr; rw int.nat_abs_of_nonneg; try { assumption };\n  simp only [bl];\n  linarith\nend\n\nlemma some_nth_le_generate_v₀ {α : Type} {g : vec_grid₀ α} {n} (H) :\n  some (nth_le (℘ g) n H) =\n  nth g.data.to_list ( |↑n % ↑g.c| + |↑n / ↑g.c| * g.c ) :=\nbegin\n  rcases g with ⟨⟨r, c, h, ⟨d, hd⟩⟩, o⟩,\n  rw [nth_le_nth, nth_generate],\n  simp [abs_data_eq_nth_v₀', expand_gtr, bl, rows, cols, vector.nth, hd],\n  rw mod_add_div_coe,\n  simp [length_generate, rows, cols] at H,\n  simp [H], simpa [hd]\nend\n\nlemma nth_generate_v₀ {α : Type} {g : vec_grid₀ α} {n} (H : n < length ℘ g):\n  nth (℘ g) n =\n  nth g.data.to_list ( |↑n % ↑g.c| + |↑n / ↑g.c| * g.c) :=\n  by simp [nth_le_nth, some_nth_le_generate_v₀, H]\n\nprivate lemma goy_add_n_div_c_lt_goy_add_r {α : Type} {g : fgrid₀ α} {n : ℕ}\n  (h : n < length ℘ g) : g.o.y + ↑n / ↑g.c < g.o.y + ↑g.r :=\n  begin\n    simp [-sub_eq_add_neg], norm_cast,\n    rw [length_generate, nat.mul_comm] at h,\n    exact nat.div_lt_of_lt_mul h\n  end\n\nlemma some_nth_le_generate_f₀ {α : Type} {g : fgrid₀ α} {n} (H) :\n  some (nth_le (℘ g) n H) =\n  g.data\n    ⟨g.o.y + ↑n / ↑g.c, ⟨by simp, goy_add_n_div_c_lt_goy_add_r H⟩⟩\n    ⟨g.o.x + ↑n % ↑g.c, ⟨by simp, by simp; exact mod_lt_of_pos _ coe_cols_pos_f⟩⟩\n  := by simpa [nth_generate, abs_data_eq_nth_f₀, expand_gtr]\n\nlemma nth_generate_f₀ {α : Type} {g : fgrid₀ α} {n} (H : n < length ℘ g) :\n  nth (℘ g) n =\n  g.data\n    ⟨g.o.y + ↑n / ↑g.c, ⟨by simp, goy_add_n_div_c_lt_goy_add_r H⟩⟩\n    ⟨g.o.x + ↑n % ↑g.c, ⟨by simp, by simp; exact mod_lt_of_pos _ coe_cols_pos_f⟩⟩\n  := by simp [nth_le_nth H, some_nth_le_generate_f₀]\n\nlemma nth_le_generate_f₀ {α : Type} {g : fgrid₀ α} {n} (H) :\n  nth_le (℘ g) n H =\n  g.data\n    ⟨g.o.y + ↑n / ↑g.c, ⟨by simp, goy_add_n_div_c_lt_goy_add_r H⟩⟩\n    ⟨g.o.x + ↑n % ↑g.c, ⟨by simp, by simp; exact mod_lt_of_pos _ coe_cols_pos_f⟩⟩\n  := by simpa [nth_generate, abs_data_eq_nth_f₀, expand_gtr]\n\nlemma generate_eq_data {α : Type} (g : vec_grid₀ α) :\n  ℘ g = g.data.to_list :=\nbegin\n  have h₁ : length (℘ g) = rows g * cols g,\n    from length_generate _,\n  have h₂ : length (g.data.to_list) = rows g * cols g,\n    by simp [rows, cols],\n  apply ext_le (eq.trans h₁ h₂.symm) (λi hi₁ hi₂, _),\n  rw h₁ at hi₁, rw h₂ at hi₂,\n  have : hi₁ = hi₂, from rfl, subst this, dedup,\n  rw ← option.some_inj, repeat { rw ← nth_le_nth },\n  rename hi₁_1 hi,\n  rcases g with ⟨⟨r, c, h, ⟨data, hd⟩⟩, o⟩,\n  simp [-sub_eq_add_neg, rows, cols] at *,\n  rw [nth_le_nth (by simpa [length_generate_eq_sizes]), some_nth_le_generate_v₀],\n  rw nth_le_nth hi₂, simp,\n  have : |↑i % ↑c| + |↑i / ↑c| * c = i, from mod_add_div_coe,\n  repeat { rw ← nth_le_nth }, simp [this]\nend\n\nprivate theorem generate_inj_v₀_v₀ {α : Type} {g₁ g₂ : vec_grid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o)\n  (h : ℘ g₁ = ℘ g₂) : g₁ = g₂ :=\nbegin\n  repeat { rw generate_eq_data at h },\n  rcases g₁ with ⟨⟨g₁r, g₁c, g₁h, g₁d⟩, g₁o⟩,\n  rcases g₂ with ⟨⟨g₂r, g₂c, g₂h, g₂d⟩, g₂o⟩,\n  dsimp at hrows hcols horig h,\n  substs hrows hcols horig,\n  congr, exact vector.to_list_inj h\nend\n\nlemma nth_le_attach_gip_in_gip_g {α : Type*} [grid α] {g : α} {i} {hi} :\n  (nth_le (attach (gip_g g)) i hi).val ∈ gip_g g :=\nbegin\n  rw [nth_le_attach, ← in_grid_iff_in_gip_g, nth_le_gip_g],\n  simp only [(∈), flip, is_in_grid', is_bounded],\n  split; split,\n    {\n      have : ↑i / ↑(cols g) ≥ 0,\n        by norm_cast; linarith,\n      simp [le_add_of_nonneg_right this]\n    },\n    {\n      simp [expand_gtr], norm_cast,\n      apply nat.div_lt_of_lt_mul,\n      simp [length_attach, length_gip_g] at hi,\n      rw mul_comm at hi,\n      exact hi\n    },\n    {\n      have : ↑i % ↑(cols g) ≥ 0,\n        by norm_cast; linarith,\n      simp [le_add_of_nonneg_right this]\n    },\n    {\n      simp [expand_gtr],\n      exact mod_lt_of_pos _ coe_cols_pos\n    }  \nend\n\ntheorem grid_eq_iff_v₀_v₀ {α : Type} {g₁ g₂ : vec_grid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o) : g₁ = g₂ ↔ ℘ g₁ = ℘ g₂ :=\n  ⟨λh, h ▸ rfl, generate_inj_v₀_v₀ hrows hcols horig⟩\n\nlemma i_bounded {α : Type*} [grid α] {g : α} {p} (h : p ∈ g) :\n  is_bounded 0 (size g) ( |p.y - (bl g).y| * cols g + |p.x - (bl g).x| ) :=\nbegin\n  have h₁ : |p.x - (bl g).x| ≥ 0, by simp,\n  have h₂ : |p.y - (bl g).y| ≥ 0, by simp,\n  unfold is_bounded, split,\n    {linarith},\n    {\n      simp [(∈), flip, is_in_grid'] at h,\n      rcases h with ⟨⟨h₃, h₄⟩, ⟨h₅, h₆⟩⟩,\n      have eq₁ : |p.x - (bl g).x| < cols g,\n        {\n          rw ← int.coe_nat_lt_coe_nat_iff,\n          rw cols_eq_trx_sub_blx,\n          repeat { rw nat_abs_of_nonneg },\n          simpa, simp [expand_gtr], linarith\n        },\n      have eq₂ : |p.y - (bl g).y| < rows g,\n        {\n          rw ← int.coe_nat_lt_coe_nat_iff,\n          rw rows_eq_try_sub_bly,\n          repeat { rw nat_abs_of_nonneg },\n          simpa, simp [expand_gtr], linarith\n        },\n      exact linearize_array eq₁ eq₂\n    }\nend\n\nprivate theorem generate_inj_f₀_f₀ {α : Type} {g₁ g₂ : fgrid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o)\n  (h : ℘ g₁ = ℘ g₂) : g₁ = g₂ :=\nbegin\n  have hl₁ : length (℘ g₁) = g₁.r * g₁.c,\n    from length_generate _,\n  have hl₂ : length (℘ g₂) = g₂.r * g₂.c,\n    from length_generate _,\n  cases g₁ with g₁r g₁c g₁h g₁o g₁d,\n  cases g₂ with g₂r g₂c g₂h g₂o g₂d,\n  dsimp at hrows hcols horig hl₁ hl₂,\n  subst hrows, subst hcols, subst horig,\n  congr, ext x y,\n  rcases x with ⟨x, ⟨xl, xu⟩⟩, rcases y with ⟨y, ⟨yl, yu⟩⟩,\n  have rowsnezero : g₁r ≠ 0, assume contra,\n    by simp [contra] at g₁h; exact absurd g₁h (lt_irrefl _),\n  have colsnezero : g₁c ≠ 0, assume contra,\n    by simp [contra] at g₂h; exact absurd g₂h (lt_irrefl _),\n  let i := |x - g₁o.y| * g₁c + |y - g₁o.x|,\n  have hi : i = |x - g₁o.y| * g₁c + |y - g₁o.x|, refl,\n  have r_nonneg : x - g₁o.y ≥ 0,\n    by simp only [ge_from_le, le_sub_iff_add_le, zero_add]; exact xl,\n  have c_nonneg : y - g₁o.x ≥ 0,\n    by simp only [ge_from_le, le_sub_iff_add_le, zero_add]; exact yl,\n  have i_nonneg : 0 ≤ i, by linarith,\n  have i_bounded : i < g₁r * g₁c,\n    {\n      have yb : y - g₁o.x < ↑g₁c, from sub_lt_iff_lt_add'.2 yu,\n      have xb : x - g₁o.y < ↑g₁r, from sub_lt_iff_lt_add'.2 xu,\n      rw hi,\n      apply linearize_array;\n        try { rw ← int.coe_nat_lt_coe_nat_iff };\n        rw nat_abs_of_nonneg; try { assumption }\n    },\n  have h₁ : ∀hh,\n    list.nth_le (℘ (\n      {r := g₁r, c := g₁c, h := g₁h, o := g₁o, data := g₁d} : fgrid₀ α\n    )) i hh =\n    list.nth_le (℘ (\n      {r := g₁r, c := g₁c, h := g₂h, o := g₁o, data := g₂d} : fgrid₀ α\n    )) i (hl₂.symm ▸ i_bounded), { rw h, intro, refl },\n  specialize h₁ (hl₁.symm ▸ i_bounded),\n  simp [-sub_eq_add_neg, nth_le_generate_f₀] at h₁,\n  have : g₁o.y + (↑|y - g₁o.x| + ↑|x - g₁o.y| * ↑g₁c) / ↑g₁c = x,\n    {\n      repeat { rw nat_abs_of_nonneg; try { assumption } },\n      rw @int.add_mul_div_right _ _ ↑g₁c (by simp [colsnezero]),\n      rw div_eq_zero_of_lt c_nonneg (sub_lt_iff_lt_add'.2 yu),\n      simp\n    },\n  simp only [this] at h₁,\n  have : g₁o.x + ↑|y - g₁o.x| % ↑g₁c = y,\n    {\n      repeat { rw nat_abs_of_nonneg; try { assumption } },\n      rw mod_eq_of_lt c_nonneg (sub_lt_iff_lt_add'.2 yu),\n      simp\n    },\n  simp only [this] at h₁,\n  exact h₁\nend\n\ntheorem grid_eq_iff_f₀_f₀ {α : Type} {g₁ g₂ : fgrid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o) : g₁ = g₂ ↔ ℘ g₁ = ℘ g₂ :=\n  ⟨λh, h ▸ rfl, generate_inj_f₀_f₀ hrows hcols horig⟩\n\ndef row (n : fin (rows g)) :\n  (fin (cols g)) → carrier α :=\n  data g n\n\ndef col (n : fin (cols g)) :\n  (fin (rows g)) → carrier α :=\n  flip (data g) n\n\ndef top :=\n  row g ⟨\n    0,\n    and.elim_left (gt_and_gt_of_mul_gt (nonempty g))\n  ⟩\n\ndef bot :=\n  row g ⟨nat.pred (rows g),\n         nat.pred_lt (ne_of_gt (gt_and_gt_of_mul_gt (nonempty g)).1)\n        ⟩\n\ndef left :=\n  have h : cols g > 0,\n    from (gt_and_gt_of_mul_gt (nonempty g)).2,\n  col g ⟨0, h⟩\n\ndef right :=\n  have h : cols g > 0,\n    from (gt_and_gt_of_mul_gt (nonempty g)).2,\n  col g ⟨nat.pred (cols g), nat.pred_lt (ne_of_gt h)⟩\n\ndef overlaid_by (bb₁ bb₂ : bounding_box) :=\n  (bb₂.p₁.x ≤ bb₁.p₁.x ∧ bb₁.p₂.x ≤ bb₂.p₂.x) ∧\n  (bb₁.p₂.y ≤ bb₂.p₂.y ∧ bb₂.p₁.y ≤ bb₁.p₁.y)\n\ndef in_grid_bounded (p : point)\n  (h : is_in_grid' g p) :=\n  let ⟨left, right⟩ :=\n    h in (make_bounded left, make_bounded right)\n\ninstance overlaid_decidable (p₁ p₂ : bounding_box) :\n  decidable (overlaid_by p₁ p₂) := by simp [overlaid_by]; apply_instance\n\nlemma overlaid_by_refl (bb : bounding_box) : overlaid_by bb bb :=\n  by simp [overlaid_by]; repeat {split}; refl\n\nlemma overlaid_by_trans {bb₁ bb₂ bb₃ : bounding_box}\n  (h : overlaid_by bb₁ bb₂) (h₁ : overlaid_by bb₂ bb₃) : overlaid_by bb₁ bb₃ :=\n  by simp [overlaid_by] at *; repeat {split}; transitivity; finish\n\nlemma overlaid_by_antisymm {bb₁ bb₂ : bounding_box}\n  (h : overlaid_by bb₁ bb₂) (h₁ : overlaid_by bb₂ bb₁) : bb₁ = bb₂ :=\nbegin\n  simp [overlaid_by] at *,\n  rcases bb₁ with ⟨⟨_, _⟩, ⟨_, _⟩⟩, rcases bb₂ with ⟨⟨_, _⟩, ⟨_, _⟩⟩,\n  safe\nend\n\nlemma overlaid_by_size_le {α : Type*} [grid α] {g : α} {bb : bounding_box}\n  (h : overlaid_by bb (grid_bounds g)) :\n  bb_size bb ≤ size g :=\nbegin\n  unfold bb_size,\n  rw [\n    size_eq_rows_mul_cols, rows_of_box, cols_of_box,\n    rows_eq_try_sub_bly, cols_eq_trx_sub_blx\n  ],\n  simp [overlaid_by, grid_bounds] at h,\n  rcases h with ⟨⟨h₁, h₂⟩, ⟨h₃, h₄⟩⟩,\n  rw ← int.coe_nat_le_coe_nat_iff,\n  repeat { rw int.coe_nat_mul },\n  cases bb with p₁ p₂ hbb, simp [-sub_eq_add_neg] at *,\n  rw grid_bounded_iff at hbb, cases hbb with h₅ h₆,\n  repeat { rw nat_abs_of_nonneg; try { linarith } },\n  apply mul_le_mul; linarith\nend\n\nlemma is_in_larger {bb₁ bb₂ : bounding_box} {xy : point}\n  (h : xy ∈ bb₁) (h₁ : overlaid_by bb₁ bb₂) : xy ∈ bb₂ :=\n  ⟨⟨le_trans h₁.2.2 h.1.1, lt_of_lt_of_le h.1.2 h₁.2.1⟩,\n   ⟨le_trans h₁.1.1 h.2.1, lt_of_lt_of_le h.2.2 h₁.1.2⟩⟩\n\nprivate def bounded_prod_of_point {p : point} {g : α} (h : p ∈ g) :\n  bounded (bl g).x (gtr g).x ×\n  bounded (bl g).y (gtr g).y := ⟨make_bounded h.2, make_bounded h.1⟩\n\nopen bounding_box\n\ndef subgrid (bb : bounding_box) (h : overlaid_by bb (grid_bounds g)) :\n            fgrid₀ (carrier α) :=\n  ⟨rows_of_box bb, cols_of_box bb,\n   mul_pos rows_of_box_pos cols_of_box_pos, bb.p₁,\n   λx y, abs_data g ⟨⟨x.1,\n    begin\n      unfold overlaid_by at h, cases x with x hx, simp,\n      rw grid_bounds_p₁ at h, rw grid_bounds_p₂ at h,\n      exact ⟨\n        le_trans h.2.2 hx.1,\n        begin\n          have : bb.p₁.y + ↑(rows_of_box bb) = bb.p₂.y,\n            begin\n              have : (bb.p₂).y - (bb.p₁).y ≥ 0,\n                by simp [-sub_eq_add_neg, ge_from_le];\n                   apply int.le_of_lt (grid_bounded_iff.1 bb.3).2,\n              simp [-sub_eq_add_neg, rows_of_box],\n              rw nat_abs_of_nonneg this,\n              simp\n            end, rw this at hx,\n          exact lt_of_lt_of_le hx.2 h.2.1\n        end\n      ⟩\n    end⟩, ⟨y.1,\n    begin\n      unfold overlaid_by at h, cases y with y hy, simp,\n      rw grid_bounds_p₁ at h, rw grid_bounds_p₂ at h,\n      have : (bb.p₁).x + ↑(cols_of_box bb) = bb.p₂.x,\n        by simp [\n             -sub_eq_add_neg, bounding_box.p₁, bounding_box.p₂, cols_of_box,\n             nat_abs_of_nonneg (nonneg_of_lt (grid_bounded_iff.1 bb.3).1),\n             add_sub_cancel'_right\n           ], rw this at hy,\n      exact ⟨le_trans h.1.1 hy.1, lt_of_lt_of_le hy.2 h.1.2⟩\n    end⟩⟩⟩\n\ntheorem length_subgrid {bb} {H} : length ℘(subgrid g bb H) = bb_size bb :=\n  by simp [length_generate_eq_size, size, bb_size, subgrid, rows, cols]\n\nlemma gen_subgrid_self :\n  ℘ (subgrid g (grid_bounds g) (overlaid_by_refl _)) = @generate _ _ g :=\nbegin\n  have lenok : length ℘(subgrid g (grid_bounds g) (overlaid_by_refl _)) = length ℘ g,\n    by simp [\n      length_subgrid, length_generate, bb_size, grid_bounds,\n      subgrid, rows, cols, rows_of_box, cols_of_box,\n      rows_eq_try_sub_bly, cols_eq_trx_sub_blx\n    ],\n  have eq₁ : rows_of_box (grid_bounds g) = rows g,\n    by simp [grid_bounds, rows_of_box, rows_eq_try_sub_bly],\n  have eq₂ : cols_of_box (grid_bounds g) = cols g,\n    by simp [grid_bounds, cols_of_box, cols_eq_trx_sub_blx],\n  have eq₃ : (grid_bounds g).p₁ = bl g,\n    by simp [grid_bounds],\n  unfold subgrid,\n  apply list.ext_le lenok, intros,\n  unfold subgrid,\n  repeat { rw nth_generate },\n  simp [abs_data_eq_nth_f₀, bl, eq₃, cols, eq₁, eq₂]\nend\n\nlemma overlaid_by_subgrid_grid {α : Type*} [grid α] {g : α} {bb} {H}\n  : overlaid_by (grid_bounds (subgrid g bb H)) (grid_bounds g) :=\nbegin\n  unfold overlaid_by at H,\n  rcases bb with ⟨p₁, p₂, hbb⟩,\n  rw grid_bounded_iff at hbb,\n  cases hbb with hbb₁ hbb₂,\n  rcases H with ⟨⟨h₁, h₂⟩, ⟨h₃, h₄⟩⟩,\n  simp [grid_bounds, overlaid_by, subgrid, expand_gtr] at *,\n  split; split; try {\n    simp [bl, expand_gtr, rows, cols, rows_of_box, cols_of_box, -sub_eq_add_neg]\n  },\n    {assumption},\n    {\n      have : p₂.x - p₁.x ≥ 0, by linarith,\n      rw nat_abs_of_nonneg this,\n      linarith\n    },\n    {\n      have : p₂.y - p₁.y ≥ 0, by linarith,\n      rw nat_abs_of_nonneg this,\n      linarith\n    },\n    {assumption}\nend\n\nlemma bl_subgrid_g_bb_eq_bb_p₁ {α : Type*} [grid α] {g : α} {bb} {H} :\n  bl (subgrid g bb H) = bb.p₁ := by simp [subgrid, bl]\n\nlemma tr_subgrid_g_bb_eq_bb_p₂ {α : Type*} [grid α] {g : α} {bb} {H} :\n  gtr (subgrid g bb H) = bb.p₂ :=\nbegin\n  simp [expand_gtr, subgrid, bl, rows, cols],\n  have eq₁ : cols_of_box bb > 0, from cols_of_box_pos,\n  have eq₂ : rows_of_box bb > 0, from rows_of_box_pos,\n  rcases bb with ⟨⟨p₁x, p₁y⟩, ⟨p₂x, p₂y⟩, h⟩, rw grid_bounded_iff at h,\n  simp [-sub_eq_add_neg, rows_of_box, cols_of_box],\n  simp [-sub_eq_add_neg, cols_of_box] at eq₁,\n  simp [-sub_eq_add_neg, rows_of_box] at eq₂,\n  simp at h, cases h with hl hr,\n  rw ← int.coe_nat_lt_coe_nat_iff at eq₁ eq₂,\n  rw nat_abs_of_nonneg at eq₁ eq₂,\n  all_goals { try { linarith } },\n  repeat { rw nat_abs_of_nonneg },\n  all_goals { try { linarith } },\n  split; linarith\nend\n\nlemma grid_bounds_subgrid_g {α : Type*} [grid α] {g : α} {bb} {H} :\n  grid_bounds (subgrid g bb H) = bb :=\n  by simp [grid_bounds, bl_subgrid_g_bb_eq_bb_p₁, tr_subgrid_g_bb_eq_bb_p₂];\n     cases bb; refl\n\nlemma size_subgrid {bb} {H} : size (subgrid g bb H) = bb_size bb :=\n  by simp only [\n       size, bb_size,\n       rows_of_box, cols_of_box, rows_eq_try_sub_bly, cols_eq_trx_sub_blx,\n       tr_subgrid_g_bb_eq_bb_p₂, bl_subgrid_g_bb_eq_bb_p₁\n     ]\n\nlemma overlaid_by_subgrid_bb {α : Type*} [grid α] {g : α} {bb} {H}\n  : overlaid_by bb (grid_bounds (subgrid g bb H)) :=\n  by rw grid_bounds_subgrid_g; exact overlaid_by_refl bb\n\nlemma p_in_bb_of_grid_bounds_subgrid_bb_iff {α : Type*} [grid α] {g : α} {bb} {H} {p} :\n  p ∈ grid_bounds (subgrid g bb H) ↔ p ∈ bb :=\nbegin\n  split; intros h,\n    {\n      simp [grid_bounds, flip, is_in_grid] at h,\n      simp [(∈), flip, is_in_grid],\n      rw [bl_subgrid_g_bb_eq_bb_p₁, tr_subgrid_g_bb_eq_bb_p₂] at h,\n      exact h\n    },\n    {\n      simp [grid_bounds, flip, is_in_grid],\n      simp [(∈), flip, is_in_grid] at h,\n      rw [bl_subgrid_g_bb_eq_bb_p₁, tr_subgrid_g_bb_eq_bb_p₂],\n      exact h\n    }\nend\n\ndef inject_filter_bounded {bb : bounding_box}\n  (e : {x // x ∈ filter (λ (p : point), p ∉ bb) (gip_g g)}) :\n  grid_point g :=\n  grid_point_of_mem _ $ in_grid_iff_in_gip_g.2 (mem_filter.1 e.2).1\n\ndef subgrid' (bb : bounding_box) (h : overlaid_by bb (grid_bounds g)) :\n             list (carrier α) :=\n  map (abs_data g ∘ inject_filter_bounded _)\n      (attach $ filter (λp, p ∉ bb) (gip_g g))\n\nlemma countp_grp_x {p₁x p₂x a b row} :\n  countp (λ (p : point), p.x < p₁x ∨ p₂x ≤ p.x) (grp a b row) =\n  countp (λ x, x < p₁x ∨ p₂x ≤ x) (range_pure a b) :=\nbegin\n  induction eq : range_pure a b with hd tl ih generalizing a,\n    {\n      rw range_pure_empty_iff at eq,\n      rw grp_empty_iff'.2 eq,\n      refl\n    },\n    {\n      have : a < b,\n        {\n          by_contradiction contra, rw not_lt at contra,\n          rw range_pure_empty_iff.2 contra at eq, cases eq\n        },\n      rw range_pure_next this at eq, injection eq with eq₁ eq₂, subst eq₁,\n      specialize @ih (a + 1) eq₂,\n      rw expand_grp this, simp [countp],\n      by_cases eq₁ : a < p₁x ∨ p₂x ≤ a; simp [eq₁, ih]\n    }\nend\n\nlemma countp_grp_single_row_l {α : Type} {l : list α}\n  {P₁ P₂ : α → Prop} [decidable_pred P₁] [decidable_pred P₂]\n  (h : ∀x ∈ l, ¬P₂ x) :\n  countp P₁ l = countp (λ x, P₁ x ∨ P₂ x) l :=\nbegin\n  induction l with hd tl ih,\n    {simp},\n    {\n      simp [countp],\n      by_cases eq : (P₁ hd); simp [eq],\n        {exact ih (λ_ h₀, h _ (mem_cons_of_mem _ h₀))},\n        {\n          rw if_neg (h _ _),\n          exact ih (λ_ h₀, h _ (mem_cons_of_mem _ h₀)),\n          exact mem_cons_self _ _\n        }\n    }\nend\n\nlemma countp_grp_single_row_r {α : Type} {l : list α}\n  {P₁ P₂ : α → Prop} [decidable_pred P₁] [decidable_pred P₂]\n  (h : ∀x ∈ l, ¬P₂ x) :\n  countp P₁ l = countp (λ x, P₂ x ∨ P₁ x) l :=\nbegin\n  induction l with hd tl ih,\n    {simp},\n    {\n      simp [countp],\n      by_cases eq : (P₁ hd); simp [eq],\n        {exact ih (λ_ h₀, h _ (mem_cons_of_mem _ h₀))},\n        {\n          rw if_neg (h _ _),\n          exact ih (λ_ h₀, h _ (mem_cons_of_mem _ h₀)),\n          exact mem_cons_self _ _\n        }\n    }\nend\n\nlemma countp_grp_row {p₁x p₁y p₂x p₂y : ℤ} {blx bly trx : ℤ} \n(h₀ : p₁y < p₂y) (hl : bly ≤ p₁y) :\ncountp (λ (p : point), (p.y < p₁y ∨ p₂y ≤ p.y) ∨ p.x < p₁x ∨ p₂x ≤ p.x) (grp blx trx bly) =\nite (p₁y = bly) (countp (λ (p : point), p.x < p₁x ∨ p₂x ≤ p.x) (grp blx trx bly))\n                (length (grp blx trx bly)) :=\nbegin\n  by_cases h₁ : p₁y = bly,\n    {\n      have : ∀p : point, p ∈ grp blx trx bly → p.y = bly, from λp, in_grp_second,\n      rw if_pos h₁,\n      rw ← countp_grp_single_row_r,\n      intros p h₂, rw not_or_distrib, subst h₁,\n      by_cases h : blx < trx,\n        {\n          rw expand_grp h at this,\n          have eq : p.y = p₁y, from in_grp_second h₂, subst eq,\n          split; linarith\n        },\n        {\n          rw not_lt at h, rw grp_empty_iff'.2 h at h₂, cases h₂\n        }\n    },\n    {\n      rw if_neg h₁,\n      have eq : ∀p : point, p ∈ grp blx trx bly → p.y = bly,\n        from λp, in_grp_second,\n      have eq₁ : bly < p₁y,\n        {\n          rw le_iff_eq_or_lt at hl, cases hl, subst hl, contradiction,\n          exact hl\n        },\n      induction iheq : grp blx trx bly with hd tl ih generalizing blx,\n        {simp},\n        {\n          have eq₂ : blx < trx,\n            {\n              by_contradiction contra, rw not_lt at contra,\n              rw grp_empty_iff'.2 contra at iheq, cases iheq\n            },\n          rw expand_grp eq₂ at iheq, injection iheq with i₁ i₂,\n          simp [countp], subst i₁, simp only [point.x, point.y] at *,\n          by_cases h₃ : (bly < p₁y ∨ p₂y ≤ bly) ∨ blx < p₁x ∨ p₂x ≤ blx; simp [h₃],\n            {\n              simp [nat.succ_eq_add_one],\n              rw expand_grp eq₂ at eq,\n              rw @ih (blx + 1) (λ_ hk, eq _ (mem_cons_of_mem _ hk)) i₂\n            },\n            {\n              repeat { rw not_or_distrib at h₃ },\n              rcases h₃ with ⟨⟨a₁, a₂⟩, a₃, a₄⟩,\n              linarith\n            }\n        }\n    }\nend\n\nlemma in_join_grp_range_iff {blx trx bly try} {p : point}\n  (h₀ : blx < trx) :\n  p ∈ join (map (grp blx trx) (range_pure bly try)) ↔\n  is_bounded blx trx p.x ∧ is_bounded bly try p.y :=\nbegin\n  split; intros h,\n    {\n      simp at h, rcases h with ⟨l, ⟨⟨a, ⟨h₁, h₂⟩⟩, h₃⟩⟩,\n      rw in_range_pure_iff at h₁, rw [← h₂, in_grp_iff h₀] at h₃,\n      cases h₃ with h₃ h₄, rw ← h₄ at h₁,\n      exact ⟨h₃, h₁⟩\n    },\n    {\n      cases h with h h₁, simp,\n      use (grp blx trx p.y), use p.y,\n      split, {exact in_range_pure_iff.2 h₁}, {refl},\n      rw in_grp_iff h₀,\n      split, {exact h}, {refl}\n    }\nend\n\nprivate lemma filter_any_ {l₁ l₂ : list ℤ} {p₁x p₂x} (h : length l₁ = length l₂) :\n  length (filter (λ (x : point), x.x < p₁x ∨ p₂x ≤ x.x)\n                 (map (uncurry point.mk) (zip l₁ l₂))) =\n  length (filter (λ (x : ℤ), x < p₁x ∨ p₂x ≤ x) l₁) :=\nbegin\n  induction l₁ with hd tl ih generalizing l₂,\n    {simp},\n    {\n      cases l₂ with hd₂ tl₂,\n        {simp at h, contradiction},\n        {\n          simp [uncurry] at *, \n          by_cases eq : hd < p₁x ∨ p₂x ≤ hd; simp [eq]; exact ih h\n        }\n    }\nend\n\nlemma countp_grp {p₁x p₂x a b r : ℤ}\n  (h : p₁x < p₂x) (h₁ : a ≤ p₁x) (h₂ : p₂x ≤ b):\n  countp (λ (x : point), x.x < p₁x ∨ p₂x ≤ x.x) (grp a b r) =\n  nat_abs (p₁x - a) + nat_abs (b - p₂x) :=\nbegin\n  unfold grp, rw countp_eq_length_filter, rw filter_any_,\n  rw ← countp_eq_length_filter, rw countp_range_pure h h₁ h₂,\n  rw range_length_pure, rw length_repeat, linarith\nend\n\nlemma map_length_grp_range {a b c d : ℤ} (h : c ≤ d) (h₁ : a < b) :\n   length (join (map (grp a b) (range_pure c d))) =\n   |d - c| * |b - a| :=\nbegin\n  generalize eq : range_pure c d = l,\n  rw le_iff_eq_or_lt at h, cases h with h h,\n    {\n      subst h,\n      rw range_pure_same_empty at eq, subst eq,\n      simp\n    },\n    {\n      induction l with hd tl ih generalizing c,\n        {\n          rw range_pure_empty_iff at eq,\n          have : c = d, by linarith,\n          simp [this]\n        },\n        {\n          rw range_pure_next h at eq, injection eq with eq eq₁,\n          simp only [map, join, length_append], rw length_grp h₁,\n          by_cases eq₂ : c + 1 < d,\n            {\n              rw @ih (c + 1) eq₁ eq₂, rw ← abs_minus_plus h,\n              rw ← int.coe_nat_eq_coe_nat_iff,\n              rw int.coe_nat_add, repeat { rw int.coe_nat_mul },\n              rw int.coe_nat_sub,\n              repeat { rw int.nat_abs_of_nonneg }; try { linarith },\n              simp only [int.coe_nat_zero, int.coe_nat_succ, zero_add],\n              ring,\n              rw ← int.coe_nat_le_coe_nat_iff,\n              rw int.nat_abs_of_nonneg; try { linarith },\n              simp, linarith\n            },\n            {\n              rw not_lt at eq₂,\n              have : c + 1 = d, by linarith, subst this,\n              rw range_pure_same_empty at eq₁, subst eq₁,\n              simp\n            }\n        }\n    }\nend\n\nlemma count_outside_join_map {a b c d p₁x p₂x}\n  (h : c < d) (h₁ : p₁x < p₂x) (h₂ : a ≤ p₁x) (h₃ : p₂x ≤ b) :\n  countp (λ (p : point), p.x < p₁x ∨ p₂x ≤ p.x) (join (map (grp a b) (range_pure c d))) =\n  |p₁x - a| * |d - c| + |b - p₂x| * |d - c| :=\nbegin\n  generalize eq : range_pure c d = l,\n  induction l with hd tl ih generalizing c,\n    {rw range_pure_empty_iff at eq, linarith},\n    {\n      by_cases eq₁ : c + 1 < d,\n        {\n          rw range_pure_next h at eq, injection eq with eq eq₂,\n          simp [-sub_eq_add_neg], rw countp_grp; try { linarith },\n          rw @ih (c + 1) eq₁ eq₂, repeat { rw ← abs_minus_plus h },\n          rw ← int.coe_nat_eq_coe_nat_iff,\n          repeat { rw int.coe_nat_add },\n          repeat { rw int.coe_nat_mul },\n          repeat { rw int.coe_nat_sub },\n          simp only [int.coe_nat_zero, int.coe_nat_succ, zero_add],\n          repeat { rw int.nat_abs_of_nonneg }; try { linarith },\n          ring, rw ← int.coe_nat_le_coe_nat_iff,\n          rw int.nat_abs_of_nonneg, simp, linarith, linarith\n        },\n        {\n          rw not_lt at eq₁, rw range_pure_next h at eq,\n          have : d = c + 1, by linarith, subst this,\n          injection eq with eq eq₂, rw range_pure_same_empty at eq₂,\n          subst eq₂, simp [-sub_eq_add_neg], rw countp_grp; try { linarith },\n          simp\n        }\n    }\nend\n\nlemma subgrid_smaller_ints {blx bly trx try p₁x p₁y p₂x p₂y}\n  (h₀ : p₁x < p₂x) (h₁ : p₁y < p₂y) (h₂ : blx ≤ p₁x) (h₃ : p₂x ≤ trx)\n  (h₄ : bly ≤ p₁y) (h₅ : p₂y ≤ try) :\n  |p₂y - p₁y| * |p₂x - p₁x| ≤ |try - bly| * |trx - blx| :=\nbegin\n  rw ← int.coe_nat_le_coe_nat_iff,\n  repeat { rw int.coe_nat_mul },\n  repeat { rw int.nat_abs_of_nonneg }; try { linarith },\n  apply mul_le_mul; linarith\nend\n\nprivate lemma count_notin_ {p₁x p₁y p₂x p₂y : ℤ} {blx bly : ℤ} {c r : ℕ}\n  (cpos : c > 0) (rpos : r > 0)\n  (h₃ : blx ≤ p₁x) (h₄ : p₂x ≤ blx + c) (h₅ : bly ≤ p₁y) (h₆ : p₂y ≤ bly + r)\n  (h₇ : p₁x < p₂x) (h₈ : p₁y < p₂y)\n  :\n  countp (λ (p : point), ((p.y < p₁y ∨ p₂y ≤ p.y) ∨ p.x < p₁x ∨ p₂x ≤ p.x))\n      (join (map (grp blx (blx + ↑c)) (range_pure (bly) (bly + ↑r)))) =\n    r * c - |p₂y - p₁y| * |p₂x - p₁x| :=\nbegin\n  generalize eq₁ : blx + ↑c = trx,\n  generalize eq₂ : bly + ↑r = try,\n  have eq₃ : ↑c = trx - blx, by linarith,\n  have eq₄ : ↑r = try - bly, by linarith,\n  rw ← @nat_abs_of_nonneg (trx - blx) at eq₃; try { linarith },\n  rw ← @nat_abs_of_nonneg (try - bly) at eq₄; try { linarith },\n  simp [-sub_eq_add_neg] at eq₃ eq₄,\n  rw [eq₃, eq₄],\n  generalize eq : range_pure bly try = l,\n  have : ∃l₁ l₂, l = l₁ ++ l₂ ∧\n                     l₁ = range_pure bly p₁y ∧\n                     l₂ = range_pure p₁y try,\n    from @range_pure_app bly try _ (by linarith) eq.symm _ h₅ (by linarith),\n  rcases this with ⟨l₁, ⟨l₂, eq₂, eq₃, eq₄⟩⟩,\n  have : ∃ (l₃ l₄ : list ℤ),\n            l₂ = l₃ ++ l₄ ∧ l₃ = range_pure p₁y p₂y ∧ l₄ = range_pure p₂y try,\n    from @range_pure_app p₁y try _ (by linarith) eq₄ _ (int.le_of_lt h₈) (by linarith),\n  rcases this with ⟨l₃, ⟨l₄, eq₅, eq₆, eq₇⟩⟩,\n  have eq₈ : l = l₁ ++ l₃ ++ l₄, by rw [eq₂, eq₅, append_assoc], rw eq₈,\n  simp [-sub_eq_add_neg], rw [eq₃, eq₆, eq₇],\n  rw countp_eq_length_filter,\n  rw @filter_congr _ _ (λ_, true),\n  swap 2,\n    {\n      intros, split; intros h₃,\n        {trivial},\n        {\n          rw in_join_grp_range_iff at H,\n          unfold is_bounded at H,\n          rcases H with ⟨_, ⟨_, c⟩⟩,\n          left, left, exact c, linarith\n        }\n    }, rw filter_true,\n  rw countp_eq_length_filter,\n  rw @filter_congr _ _ (λp : point, p.x < p₁x ∨ p₂x ≤ p.x),\n  swap 2,\n    {\n      intros, split; intros h₃,\n      {\n        rw in_join_grp_range_iff at H,\n        unfold is_bounded at H,\n        rcases H with ⟨⟨c₁, c₂⟩, ⟨c₃, c₄⟩⟩,\n        cases h₃ with h₃ h₃; cases h₃ with h₃ h₃,\n          {linarith},\n          {linarith},\n          {left, exact h₃},\n          {right, exact h₃},\n          {linarith}\n      },\n      {right, exact h₃}\n    },\n  rw ← countp_eq_length_filter,\n  generalize c₁ :\n    countp (λ (p : point), p.x < p₁x ∨ p₂x ≤ p.x)\n             (join (map (grp blx trx) (range_pure p₁y p₂y))) =\n    n₁,\n  rw countp_eq_length_filter,\n   rw @filter_congr _ _ (λ_, true),\n  swap 2,\n    {\n      intros, split; intros h₃,\n        {trivial},\n        {\n          rw in_join_grp_range_iff at H,\n          unfold is_bounded at H,\n          rcases H with ⟨_, ⟨c, _⟩⟩,\n          left, right, exact c, linarith\n        }\n    }, rw filter_true, repeat { rw map_length_grp_range }; try { linarith },\n  rw ← c₁, rw count_outside_join_map; try { linarith },\n  rw ← int.coe_nat_eq_coe_nat_iff,\n  repeat { rw int.coe_nat_add },\n  repeat { rw int.coe_nat_mul },\n  repeat { rw int.coe_nat_sub },\n  repeat { rw int.coe_nat_mul },\n  repeat { rw int.nat_abs_of_nonneg }; try { linarith },\n  ring,\n  apply subgrid_smaller_ints; linarith\nend\n\nlemma count_notin {α : Type*} [φ : grid α] {g : α} {bb} {H} :\n  countp (λ (p : point), ¬is_in_grid bb p) (gip_g g) =\n  size g - size (subgrid g bb H) :=\nbegin\n  rcases bb with ⟨⟨p₁x, p₁y⟩, ⟨p₂x, p₂y⟩, p₃⟩,\n  simp [grid_bounded_iff] at p₃,\n  simp only [overlaid_by, grid_bounds, expand_gtr] at H,\n  simp only [size_subgrid],\n  simp only [is_in_grid, is_bounded, not_and_distrib, not_le, not_lt],\n  simp only [gip_g, bb_size, rows_of_box, cols_of_box, expand_gtr, gip, size],\n  rw ← @count_notin_ p₁x p₁y p₂x p₂y (bl g).x (bl g).y (cols g) (rows g) cols_pos rows_pos H.1.1 H.1.2 H.2.2 H.2.1 p₃.1 p₃.2,\n  finish\nend\n\nlemma length_subgrid' {α : Type*} [grid α] {g : α} {bb} {H} :\n  length (subgrid' g bb H) = size g - size (subgrid g bb H) :=\nbegin\n  simp only [\n    subgrid', size_eq_rows_mul_cols, map, length, length_attach, length_map, flip\n  ],\n  rw ← countp_eq_length_filter,\n  exact count_notin\nend\n\n-- lemma gip_g_subgrid'_eq_gip_g {α : Type*} [grid α] {g : α} {bb} {H} :\n--   gip_g (subgrid' g bb H) = gip_g g := by unfold gip_g; congr\n\n-- lemma grid_bounds_subgrid'_grid {α : Type*} [grid α] {g : α} {bb} {H} :\n--   grid_bounds (subgrid' g bb H) = grid_bounds g :=\n--   by simp [subgrid', grid_bounds, expand_gbl, expand_gtr, bl, cols, rows]\n\n-- lemma bl_g_subgrid'_eq_bl_g_grid {α : Type*} [grid α] {g : α} {bb} {H} :\n--   bl (subgrid' g bb H) = bl g :=\n--   let bounds := (@grid_bounds_subgrid'_grid _ _ g bb H) in\n--   by simp [grid_bounds] at bounds; exact bounds.1\n\n-- lemma tr_g_subgrid'_eq_tr_g_grid {α : Type*} [grid α] {g : α} {bb} {H} :\n--   gtr (subgrid' g bb H) = gtr g :=\n--   let bounds := (@grid_bounds_subgrid'_grid _ _ g bb H) in\n--   by simp [grid_bounds] at bounds; exact bounds.2\n\n-- lemma overlaid_by_subgrid_subgrid' {α : Type*} [grid α] {g : α} {bb} {H} :\n--   overlaid_by (grid_bounds (subgrid g bb H)) (grid_bounds (subgrid' g bb H)) :=\n--   by simp [grid_bounds_subgrid'_grid, overlaid_by_subgrid_grid]\n\nlemma p_in_g_iff_p_in_grid_bounds_g {α : Type*} [grid α] {g : α} {p} :\n  p ∈ g ↔ p ∈ grid_bounds g :=\nbegin\n  split; intros h,\n    {\n      simp [grid_bounds, flip, is_in_grid],\n      simp [(∈), flip, is_in_grid'] at h,\n      exact h\n    },\n    {\n      simp [(∈), flip, is_in_grid'],\n      simp [grid_bounds, flip, is_in_grid] at h,\n      exact h\n    }\nend\n\nprivate lemma abs_data_none_of_subgrid_ {p} {bb} {H} (h : p ∈ gip_g (subgrid g bb H)) :\n  p ∈ grid_bounds g :=\nbegin\n  have overlaid : overlaid_by (grid_bounds (subgrid g bb H)) (grid_bounds g),\n    from overlaid_by_subgrid_grid,\n  rw [← in_grid_iff_in_gip_g, ← in_grid_iff_in_grid_bounds] at h,\n  exact is_in_larger h overlaid\nend\n\nprivate def modify_vec\n  {α : Type} {m} (v : vector α m) (n : ℕ) (x : α) : vector α m :=\n  ⟨update_nth v.to_list n x,\n   by simp [update_nth_pres_len, *]⟩\n\ndef modify_at {α : Type} (p : point) (x : α) (g : vec_grid₀ α) : vec_grid₀ α :=\n  if h : p ∈ g\n  then let ⟨r, c⟩ :=\n         relpoint_of_gpoint $\n           @grid_point.mk _ _ g\n           ⟨p.y, by simp only [(∈)] at h; exact h.left⟩\n           ⟨p.x, by simp only [(∈)] at h; exact h.right⟩ in\n    ⟨⟨g.r, g.c, g.h, modify_vec g.data (r * g.c + c) x⟩, g.o⟩\n  else g\n\ndef modify_many {α : Type} (l : list (point × α)) (g : vec_grid₀ α) : vec_grid₀ α :=\n  foldr (uncurry modify_at) g l\n\ndef count_grid {α : Type} [grid α] [decidable_eq (carrier α)]\n  (g : α) (x : carrier α) := list.count x (℘ g)\n\nlemma gen_aof_eq_gen {α : Type} {g : fgrid₀ α} :\n  ℘ (vec_grid₀_of_fgrid₀ g) = @generate _ ag_fgrid₀ g :=\n  by simp [vec_grid₀_of_fgrid₀, generate_eq_data]\n\nprivate theorem generate_inj_a_f {α : Type} {g₁ : vec_grid₀ α} {g₂ : fgrid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o)\n  (h : ℘ g₁ = @generate (fgrid₀ α) _ g₂) : g₁ = g₂ :=\nbegin\n  have hl₁ : length (℘ g₁) = g₁.r * g₁.c, from length_generate _,\n  have hl₂ : length (℘ g₂) = g₂.r * g₂.c, from length_generate _,\n  rcases g₁ with ⟨⟨g₁r, g₁c, g₁h, ⟨g₁dv, g₁dh⟩⟩, g₁o⟩,\n  cases g₂ with g₂r g₂c g₂h g₂o g₂d,\n  dsimp at hrows hcols horig hl₁ hl₂,\n  subst hrows, subst hcols, subst horig,\n  unfold_coes,\n  simp [vec_grid₀_of_fgrid₀, h.symm, generate_eq_data]\nend\n\nlemma gen_foa_eq_gen {α : Type} {g : vec_grid₀ α} :\n  ℘ (fgrid₀_of_vec_grid₀ g) = @generate (vec_grid₀ α) _ g :=\nbegin\n  have hl₁ : length (℘ g) = rows g * cols g,\n    from length_generate _,\n  have hl₂ : length (℘ (fgrid₀_of_vec_grid₀ g)) = rows g * cols g,\n    from length_generate _,\n  simp [fgrid₀_of_vec_grid₀] at *,\n  apply list.ext_le (hl₂.trans hl₁.symm) (λi hi₁ hi₂, _),\n  simp [\n    nth_le_generate_f₀, nth_generate, abs_data_eq_nth_v₀', abs_data_eq_nth_f₀,\n    tl, bl, rows, cols, expand_gtr\n  ]\nend\n\nprivate theorem generate_inj_f₀_v₀ {α : Type} {g₁ : fgrid₀ α} {g₂ : vec_grid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o)\n  (h : ℘ g₁ = @generate (fgrid₀ α) _ g₂) : g₁ = g₂ :=\n  generate_inj_f₀_f₀ hrows hcols horig h\n\ntheorem grid_eq_iff_v₀_f₀\n  {α : Type} {g₁ : vec_grid₀ α} {g₂ : fgrid₀ α}\n  (h₁ : g₁.r = g₂.r)\n  (h₂ : g₁.c = g₂.c)\n  (h₃ : g₁.o = g₂.o) :\n  g₁ = g₂ ↔ ℘ g₁ = ℘ g₂ :=\n  ⟨λh, h ▸ rfl, λh, generate_inj_a_f h₁ h₂ h₃ $ by rwa gen_aof_eq_gen.symm⟩\n\ntheorem grid_eq_iff_f₀_v₀\n  {α : Type} {g₁ : fgrid₀ α} {g₂ : vec_grid₀ α}\n  (h₁ : g₁.r = g₂.r)\n  (h₂ : g₁.c = g₂.c)\n  (h₃ : g₁.o = g₂.o) :\n  g₁ = g₂ ↔ ℘ g₁ = ℘ g₂ :=\n    ⟨λh, h ▸ rfl, λh, generate_inj_f₀_v₀ h₁ h₂ h₃ h⟩\n\n@[ext]\ntheorem grid_eq_ext_v₀_v₀ {α : Type} {g₁ g₂ : vec_grid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o) : ℘ g₁ = ℘ g₂ → g₁ = g₂ :=\n  (grid_eq_iff_v₀_v₀ hrows hcols horig).2\n\n@[ext]\ntheorem grid_eq_ext_f₀_f₀ {α : Type} {g₁ g₂ : fgrid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o) : ℘ g₁ = ℘ g₂ → g₁ = g₂ :=\n  (grid_eq_iff_f₀_f₀ hrows hcols horig).2\n\n@[ext]\ntheorem grid_eq_ext_v₀_f₀ {α : Type} {g₁ : vec_grid₀ α} {g₂ : fgrid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o) : ℘ g₁ = ℘ g₂ → g₁ = g₂ :=\n  (grid_eq_iff_v₀_f₀ hrows hcols horig).2\n\n@[ext]\ntheorem grid_eq_ext_f₀_v₀ {α : Type} {g₁ : fgrid₀ α} {g₂ : vec_grid₀ α}\n  (hrows : g₁.r = g₂.r)\n  (hcols : g₁.c = g₂.c)\n  (horig : g₁.o = g₂.o) : ℘ g₁ = ℘ g₂ → g₁ = g₂ :=\n  (grid_eq_iff_f₀_v₀ hrows hcols horig).2\n\nlemma nth_vecgrid_of_fgrid {α : Type} {g : fgrid₀ α} {n} :\n  list.nth (vec_grid₀_of_fgrid₀ g).data.val n = list.nth (℘ g) n :=\n  by delta vec_grid₀_of_fgrid₀; simp\n\ninstance decidable_eq_v₀_v₀ {α : Type} [decidable_eq α]\n  : decidable_eq (vec_grid₀ α) :=\n  λg₁ g₂, if h : g₁.r = g₂.r ∧ g₁.c = g₂.c ∧ g₁.o = g₂.o then\n            by simp [grid_eq_iff_v₀_v₀, *]; apply_instance\n          else is_false $ by finish\n\ninstance decidable_eq_f₀_f₀ {α : Type} [decidable_eq α]\n  : decidable_eq (fgrid₀ α) :=\n  λg₁ g₂, if h : g₁.r = g₂.r ∧ g₁.c = g₂.c ∧ g₁.o = g₂.o then\n            by simp [grid_eq_iff_f₀_f₀, *]; apply_instance\n          else is_false $ by finish\n\ninstance decidable_eq_v₀_f₀ {α : Type} [decidable_eq α]\n  {g₁ : vec_grid₀ α} {g₂ : fgrid₀ α} : decidable (g₁ = g₂) :=\n  if h : g₁.r = g₂.r ∧ g₁.c = g₂.c ∧ g₁.o = g₂.o then\n    by simp [grid_eq_iff_v₀_f₀, *]; apply_instance    \n  else is_false $ by finish\n\ninstance decidable_eq_f₀_v₀ {α : Type} [decidable_eq α]\n  {g₁ : fgrid₀ α} {g₂ : vec_grid₀ α} : decidable (g₁ = g₂) :=\n  if h : g₁.r = g₂.r ∧ g₁.c = g₂.c ∧ g₁.o = g₂.o then\n    by simp [grid_eq_iff_f₀_v₀, *]; apply_instance\n  else is_false $ by finish\n\nlemma subgrid_self {α : Type} {g : vec_grid₀ α} {bb : bounding_box}\n  (h : bb = {bounding_box. p₁ := bl g, p₂ := gtr g, h := grid_is_bounding_box })\n  : subgrid g bb begin unfold grid_bounds, rw h, exact overlaid_by_refl _ end =\n    g :=\nbegin\n  rcases g with ⟨⟨r, c, h, ⟨d, hd⟩⟩, o⟩,\n  simp [h, subgrid], unfold_coes,\n  rw grid_eq_iff_f₀_f₀;\n    try { simp [cols_of_box, bl, expand_gtr, cols] };\n    try { simp };\n    try { simp [rows_of_box, bl, expand_gtr, rows] },\n  rw gen_foa_eq_gen,\n  apply ext_le,\n    {\n      simp [\n        length_generate_eq_size, size, rows, cols,\n        rows_of_box, cols_of_box, bl, expand_gtr\n      ]\n    },\n    {\n      intros,\n      rw nth_le_generate_f₀,\n      simp only [\n        nth_generate, abs_data, data, expand_gtr, bl, (∘),\n        relpoint_of_gpoint, prod_of_rel_point, rows, cols, tl,\n        rows_of_box, cols_of_box\n      ], simp\n    }\nend\n\nlemma p_in_g_iff_v₀_f₀ {α : Type} {g₁ : vec_grid₀ α} {g₂ : fgrid₀ α} {p}\n                     (h₁ : g₁.r = g₂.r)\n                     (h₂ : g₁.c = g₂.c)\n                     (h₃ : g₁.o = g₂.o) : p ∈ g₁ ↔ p ∈ g₂ :=\nbegin\n  rcases g₁ with ⟨⟨r₁, c₁, gh₁, d₁⟩, o₁⟩,\n  rcases g₂ with ⟨r₂, c₂, gh₂, o₂, d₂⟩,\n  simp [flip, is_in_grid'] at *,\n  split; intros; unfold_projs at *;  \n  subst h₁; subst h₂; subst h₃; finish\nend\n\nlemma cols_subgrid {bb} {H} :\n  cols (subgrid g bb H) = cols_of_box bb := rfl\n\nlemma rows_subgrid {bb} {H} :\n  rows (subgrid g bb H) = rows_of_box bb := rfl\n\nprivate lemma expand_repeat_app {α : Type} {l₁ l₂ l₃ : list α} {r : ℤ} :\n  repeat r (length (l₁ ++ l₂ ++ l₃)) = \n  repeat r (length l₁) ++ repeat r (length l₂) ++ repeat r (length l₃) :=\n  by simp [repeat_add]\n\nprivate lemma expand_map_zip_repeat {l₁ l₂ l₃} {r : ℤ} :\n  map (uncurry point.mk) (zip (l₁ ++ l₂ ++ l₃) (repeat r (length (l₁ ++ l₂ ++ l₃)))) =\n  map (uncurry point.mk) (zip l₁ (repeat r (length l₁))) ++\n  map (uncurry point.mk) (zip l₂ (repeat r (length l₂))) ++\n  map (uncurry point.mk) (zip l₃ (repeat r (length l₃))) :=\nbegin\n  repeat { rw ← map_append }, congr,\n  rw expand_repeat_app,\n  repeat { rw zip_append },\n  rw length_repeat,\n  simp\nend\n\nlemma filter_cols_grp_range_pure {p₁x p₂x gbl gtr r}\n  (h : p₁x < p₂x) (h₁ : gbl ≤ p₁x) (h₂ : p₂x ≤ gtr) :\n  filter (λ (p : point), p₁x ≤ p.x ∧ p.x < p₂x) (grp gbl gtr r) =\n  grp p₁x p₂x r :=\nbegin\n  unfold grp,\n  generalize eq : range_pure gbl gtr = l,\n  have : ∃l₁ l₂, l = l₁ ++ l₂ ∧\n                 l₁ = range_pure gbl p₁x ∧\n                 l₂ = range_pure p₁x gtr,\n  from @range_pure_app gbl gtr _ (by linarith) eq.symm _ h₁ (by linarith),\n  rcases this with ⟨l₁, ⟨l₂, eq₁, eq₂, eq₃⟩⟩,\n  have : ∃l₃ l₄, l₂ = l₃ ++ l₄ ∧\n                 l₃ = range_pure p₁x p₂x ∧\n                 l₄ = range_pure p₂x gtr,\n  from @range_pure_app p₁x gtr _ (by linarith) eq₃ _ (int.le_of_lt h) h₂,\n  rcases this with ⟨l₃, ⟨l₄, eq₄, eq₅, eq₆⟩⟩,\n  rw [eq₁, eq₄], rw ← eq₅, rw ← append_assoc,\n  have : length (l₁ ++ l₃ ++ l₄) = |gtr - gbl|,\n    {\n      have : l = l₁ ++ l₃ ++ l₄,\n        by simp [append_assoc, *], rw ← this,\n      rw ← eq, apply range_length_pure, linarith\n    }, rw ← this,\n  rw expand_map_zip_repeat, simp, rw eq₂,\n  rw @filter_congr _ _ (λ_, false), swap 2,\n    {\n      intros, split; intros H₁, cases x with x y,\n      have eq₇ :\n        x ∈ range_pure gbl p₁x ∧\n        y ∈ repeat r (length (range_pure gbl p₁x)),\n      from in_zip_of H,\n      cases eq₇ with eq₇ eq₈,\n      simp at H₁,\n      rw in_range_pure_iff at eq₇,\n      have : y = r, from eq_of_mem_repeat eq₈,\n      subst this,\n      unfold is_bounded at eq₇,\n      cases H₁, cases eq₇, linarith,\n      contradiction\n    },\n  rw [filter_false, nil_append], rw eq₅,\n  rw @filter_congr _ _ (λ_, true), swap 2,\n    {\n      intros, split; intros H₁,\n      trivial,\n      cases x with x y,\n      have eq₇ :\n        x ∈ range_pure p₁x p₂x ∧\n        y ∈ repeat r (length (range_pure p₁x p₂x)),\n      from in_zip_of H,\n      cases eq₇ with eq₇ eq₈,\n      rw in_range_pure_iff at eq₇,\n      have : y = r, from eq_of_mem_repeat eq₈,\n      subst this,\n      exact eq₇\n    }, rw filter_true, rw eq₆,\n  rw @filter_congr _ _ (λ_, false), swap 2,\n    {\n      intros, split; intros H₁, cases x with x y,\n      have eq₇ :\n        x ∈ range_pure p₂x gtr ∧\n        y ∈ repeat r (length (range_pure p₂x gtr)),\n      from in_zip_of H,\n      cases eq₇ with eq₇ eq₈,\n      simp at H₁,\n      rw in_range_pure_iff at eq₇,\n      have : y = r, from eq_of_mem_repeat eq₈,\n      subst this,\n      unfold is_bounded at eq₇,\n      cases H₁, cases eq₇, linarith,\n      contradiction\n    },\n  rw [filter_false, append_nil],\n  rw range_length_pure,\n  simp, linarith\nend\n\nprivate lemma filter_bbox_gip {p₁x p₂x gbl gtr} {l}\n  (h : p₁x < p₂x) (h₁ : gbl ≤ p₁x) (h₂ : p₂x ≤ gtr) :\n  filter (λ (p : point), p₁x ≤ p.x ∧ p.x < p₂x)\n    (join (map (grp gbl gtr) l)) = join (map (grp p₁x p₂x) l) :=\nbegin\n  induction l with hd tl ih,\n    {simp},\n    {simp, rw ih, rw filter_cols_grp_range_pure; linarith}\nend\n\nlemma filter_generate_subgrid {α : Type*} [grid α]\n  {g : α} {bb} {H} :\n  filter (λ (p : point), p ∈ bb) (gip_g g) =\n  gip_g (subgrid g bb H) :=\nbegin\n  rcases bb with ⟨p₁, p₂, hbb⟩, rw grid_bounded_iff at hbb,\n  cases hbb with hbb₁ hbb₂,\n  unfold gip_g gip,\n  rw bl_subgrid_g_bb_eq_bb_p₁,\n  rw tr_subgrid_g_bb_eq_bb_p₂, simp at *,\n  generalize eq : range_pure p₁.y p₂.y = l,\n  generalize eq₁ : range_pure (bl g).y (gtr g).y = l₁,\n  unfold overlaid_by at H,\n  rcases H with ⟨⟨c₁, c₂⟩, c₃, c₄⟩, simp [grid_bounds] at *,\n  have : ∃l₂ l₃, l₁ = l₂ ++ l₃ ∧\n                     l₂ = range_pure (bl g).y p₁.y ∧\n                     l₃ = range_pure p₁.y (gtr g).y,\n  from @range_pure_app (bl g).y (gtr g).y _ blgy_lt_trgy eq₁.symm _ c₄ (by linarith),\n  rcases this with ⟨l₂, ⟨l₃, eq₂, eq₃, eq₄⟩⟩,\n  have : ∃l₄ l₅, l₃ = l₄ ++ l₅ ∧\n                 l₄ = range_pure p₁.y p₂.y ∧\n                 l₅ = range_pure p₂.y (gtr g).y,\n  from @range_pure_app p₁.y (gtr g).y _ (lt_of_lt_of_le hbb₂ c₃) eq₄ _ (int.le_of_lt hbb₂) (by linarith),\n  rcases this with ⟨l₄, ⟨l₅, eq₅, eq₆, eq₇⟩⟩,\n  rw eq₂, rw eq₅,\n  have eq₈ : l₄ = l, by cc, subst eq₈,\n  simp only [flip, is_in_grid, is_bounded],\n  simp, rw eq₃, rw eq₆, rw eq₇,\n  rw @filter_congr _ _ (λ_, false), swap 2,\n  intros, split; intros H₁,\n    {\n      rw in_join_grp_range_iff at H, unfold is_bounded at H,\n      have contra₁ : p₁.y ≤ x.y, from H₁.1.1,\n      have contra₂ : x.y < p₁.y, from H.2.2,\n      linarith,\n      exact gblx_lt_gtrx\n    },\n    {\n      contradiction\n    }, rw [filter_false, nil_append],\n  generalize protect :\n    filter (λ (p : point), (p₁.y ≤ p.y ∧ p.y < p₂.y) ∧ p₁.x ≤ p.x ∧ p.x < p₂.x)\n           (join (map (grp ((bl g).x) ((gtr g).x)) (range_pure (p₁.y) (p₂.y)))) = prot₁,\n  rw @filter_congr _ _ (λ_, false), swap 2,\n  intros, split; intros H₁,\n    {\n      rw in_join_grp_range_iff at H, unfold is_bounded at H,\n      have contra₁ : x.y < p₂.y, from H₁.1.2,\n      have contra₂ : p₂.y ≤ x.y, from H.2.1,\n      linarith,\n      exact gblx_lt_gtrx\n    },\n    {\n      contradiction\n    }, rw [filter_false, append_nil],\n  rw ← protect,\n  rw @filter_congr _ _ (λ (p : point), p₁.x ≤ p.x ∧ p.x < p₂.x),\n  swap 2,\n    {\n      intros, split; intros H₁,\n      exact H₁.right,\n      rw in_join_grp_range_iff at H, unfold is_bounded at H,\n      exact ⟨H.2, H₁⟩,\n      exact gblx_lt_gtrx\n    },\n    {\n      rw filter_bbox_gip; linarith\n    }\nend\n\nlemma nth_le_filter_mem_gip {n} {bb : bounding_box} {H}\n  (h : overlaid_by bb (grid_bounds g)) :\n  nth_le (filter (λ (p : point), p ∈ bb) (gip_g g)) n H =\n    {x := bb.p₁.x + ↑n % ↑(cols_of_box bb),\n     y := bb.p₁.y + ↑n / ↑(cols_of_box bb)} :=\nbegin\n  rw ← option.some_inj, rw ← nth_le_nth,\n  rw @filter_generate_subgrid _ _ _ _ h, rw nth_gip_g,\n  rw bl_subgrid_g_bb_eq_bb_p₁,\n  refl, rw @filter_generate_subgrid _ _ _ _ h at H,\n  exact H\nend\n\nlemma rows_of_overlaid_le {α : Type*} [grid α] {g : α} {bb}\n  (H : overlaid_by bb (grid_bounds g)) : rows_of_box bb ≤ rows g :=\nbegin\n  unfold rows_of_box, unfold overlaid_by grid_bounds at H, simp at H,\n  rcases H with ⟨⟨h₁, h₂⟩, h₃, h₄⟩,\n  rw rows_eq_try_sub_bly,\n  rw ← int.coe_nat_le_coe_nat_iff,\n  repeat { rw int.nat_abs_of_nonneg },\n  linarith,\n  rw expand_gtr, simp,\n  cases bb, simp at *, rw grid_bounded_iff at bb_h, cases bb_h, linarith\nend\n\nlemma cols_of_overlaid_le {α : Type*} [grid α] {g : α} {bb}\n  (H : overlaid_by bb (grid_bounds g)) : cols_of_box bb ≤ cols g :=\nbegin\n  unfold cols_of_box, unfold overlaid_by grid_bounds at H, simp at H,\n  rcases H with ⟨⟨h₁, h₂⟩, h₃, h₄⟩,\n  rw cols_eq_trx_sub_blx,\n  rw ← int.coe_nat_le_coe_nat_iff,\n  repeat { rw int.nat_abs_of_nonneg },\n  linarith,\n  rw expand_gtr, simp,\n  cases bb, simp at *, rw grid_bounded_iff at bb_h, cases bb_h, linarith\nend\n\nlemma size_subgrid_le_grid {α : Type*} [grid α] {g : α} {bb} {H} :\n  size (subgrid g bb H) ≤ size g :=\nbegin\n  rw size_subgrid, unfold bb_size size,\n  apply mul_le_mul,\n  exact rows_of_overlaid_le H,\n  exact cols_of_overlaid_le H,\n  exact le_of_lt cols_of_box_pos,\n  exact le_of_lt rows_pos\nend\n\nprivate lemma filter_congr_heq {α : Type} {l₁ l₂ : list α}\n  (h : l₁ = l₂) {P₁ : {x : α | x ∈ l₁} → Prop} {P₂ : {x : α | x ∈ l₂} → Prop}\n  [decidable_pred P₁] [decidable_pred P₂]\n  (h₁ : ∀x : α, x ∈ l₁ → (P₁ ⟨x, by simp [a]⟩ ↔ P₂ ⟨x, begin simp, rw ← h, exact a end⟩)) :\n  length (filter P₁ (attach l₁)) = length (filter P₂ (attach l₂)) :=\nbegin\n  resetI, subst h,\n  have : P₁ = P₂,\n    {\n      apply funext,\n      intros, cases x with x hx, simp at hx,\n      simp,\n      split; intros h,\n        {\n          specialize h₁ x hx, \n          rw ← h₁,\n          exact h\n        },\n        {\n          specialize h₁ x hx, \n          rw h₁,\n          exact h\n        }\n    },\n  subst this,\n  finish\nend\n\nprivate lemma filter_congr_heq' {α : Type} {l₁ l₂ : list α}\n  (h : l₁ = l₂) {P₁ : {x : α // x ∈ l₁} → Prop} {P₂ : {x : α // x ∈ l₂} → Prop}\n  [decidable_pred P₁] [decidable_pred P₂]\n  (h₁ : ∀x : α, x ∈ l₁ → (P₁ ⟨x, by simp [a]⟩ ↔ P₂ ⟨x, begin rw ← h, exact a end⟩)) :\n  length (filter P₁ (pmap subtype.mk l₁ (λ_, id))) = length (filter P₂ (pmap subtype.mk l₂ (λ_, id))) :=\n  filter_congr_heq h h₁ \n\nlemma count_subgrid_in_bb {α : Type*} [grid α] [decidable_eq (carrier α)]\n  (g : α) {bb} {H₁} {elem : carrier α} :\n  count elem (@generate _ _  (subgrid g bb H₁)) =\n  countp\n    (λ (x : {x // x ∈ filter (λ (p : point), p ∈ bb) (gip_g g)}),\n        elem = abs_data g {\n  x := ⟨(x.val).x,\n  begin\n    rcases x with ⟨⟨x, y⟩, hx⟩, simp, rw mem_filter at hx,\n    cases hx with hx₁ hx₂,\n    rw ← in_grid_iff_in_gip_g at hx₁,\n    exact hx₁.2\n  end⟩,\n  y := ⟨(x.val).y,\n  begin\n    rcases x with ⟨⟨x, y⟩, hx⟩, simp, rw mem_filter at hx,\n    cases hx with hx₁ hx₂,\n    rw ← in_grid_iff_in_gip_g at hx₁,\n    exact hx₁.1\n  end⟩})\n    (attach (filter (λ (p : point), p ∈ bb) (gip_g g))) :=\nbegin\n  simp only [count, generate], repeat { rw countp_eq_length_filter },\n  rw filter_of_map, rw length_map,\n  simp only [\n    (∘), inject_into_bounded, grid_point_of_prod, make_bounded,\n    make_bounded_idx\n  ],\n  let eq := @filter_generate_subgrid _ _ g bb H₁, symmetry' at eq,\n  apply filter_congr_heq eq,\n  rintros ⟨x, y⟩ p,\n  split; intros h; simp [h];  \n  rw abs_data_eq_nth_f₀;\n  delta subgrid; simp; refl\nend\n\nlemma filter_partition_dependent'\n  {α : Type} [decidable_eq α] {l : list α}\n  {Q : α → Prop} {R : α → Prop}\n  [decidable_pred Q] [decidable_pred R]\n  {β} {P : β → Prop} [decidable_pred P]\n  (h : ∀x, ¬Q x ↔ R x)\n  (p : α → Prop) (f : ∀ a, p a → β)\n  {β₁} (i₁ : β₁ → β) (p₁ : α → Prop) (f₁ : ∀ a, p₁ a → β₁)\n  {β₂} (i₂ : β₂ → β) (p₂ : α → Prop) (f₂ : ∀ a, p₂ a → β₂) :\n  ∀ (H : ∀ (a : α), a ∈ l → p a)\n    (H₁ : ∀ (a : α), a ∈ filter Q l → p₁ a)\n    (H₂ : ∀ (a : α), a ∈ filter R l → p₂ a)\n    (heq : ∀x (H₃ : x ∈ l) (H₄ : Q x), P (f x (H x H₃)) → P (i₁ (f₁ x (H₁ x (by simp [H₃, H₄])))))\n    (heq₁ : ∀x (H₃ : x ∈ l) (H₄ : R x), P (f x (H x H₃)) → P (i₂ (f₂ x (H₂ x (by simp [H₃, H₄])))))\n    (heq₂ : ∀x (H₃ : x ∈ l) (H₄ : Q x), ¬P (f x (H x H₃)) → ¬P (i₁ (f₁ x (H₁ x (by simp [H₃, H₄])))))\n    (heq₃ : ∀x (H₃ : x ∈ l) (H₄ : R x), ¬P (f x (H x H₃)) → ¬P (i₂ (f₂ x (H₂ x (by simp [H₃, H₄]))))),\n  length (filter P (pmap f l H)) =\n  length (filter (λ x, P (i₁ x)) (pmap f₁ (filter Q l) H₁)) +\n  length (filter (λ x, P (i₂ x)) (pmap f₂ (filter R l) H₂)) :=\nbegin\n  induction l with hd tl ih; intros,\n    {simp},\n    {\n      by_cases h₁ : P (f hd (H _ (mem_cons_self _ _))),\n        {\n          unfold pmap,\n          rw filter_cons_of_pos _ h₁,\n          rw length_cons,\n          by_cases h₂ : Q hd,\n            {\n              simp [filter_cons_of_pos _ h₂, -add_comm],\n              have : ¬R hd, by finish,\n              simp [filter_cons_of_neg _ this, -add_comm],\n              have h₃ : P (i₁ (f₁ hd (H₁ _ (by simp [h₂])))),\n                {\n                  apply heq, exact h₂, exact h₁\n                },\n              simp [h₃], rw add_comm,\n              apply ih,\n              intros, apply heq, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₁, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₂, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₃, exact H₄, exact a, right, exact H₃\n            },\n            {\n              simp [filter_cons_of_neg _ h₂, -add_comm],\n              have : R hd, by finish,\n              simp [filter_cons_of_pos _ this, -add_comm],\n              have h₃ : P (i₂ (f₂ hd (H₂ _ (by simp [this])))),\n                {\n                  apply heq₁, exact this, exact h₁\n                },\n              simp [h₃],\n              apply ih,\n              intros, apply heq, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₁, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₂, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₃, exact H₄, exact a, right, exact H₃\n            }\n        },\n        {\n          unfold pmap,\n          rw filter_cons_of_neg _ h₁,\n          by_cases h₂ : Q hd,\n            {\n              simp [filter_cons_of_pos _ h₂, -add_comm],\n              have : ¬R hd, by finish,\n              simp [filter_cons_of_neg _ this, -add_comm],\n              have h₃ : ¬P (i₁ (f₁ hd (H₁ _ (by simp [h₂])))),\n                {\n                  apply heq₂, exact h₂, exact h₁\n                },\n              simp [h₃], rw add_comm,\n              apply ih,\n              intros, apply heq, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₁, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₂, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₃, exact H₄, exact a, right, exact H₃\n            },\n            {\n              simp [filter_cons_of_neg _ h₂, -add_comm],\n              have : R hd, by finish,\n              simp [filter_cons_of_pos _ this, -add_comm],\n              have h₃ : ¬P (i₂ (f₂ hd (H₂ _ (by simp [this])))),\n                {\n                  apply heq₃, exact this, exact h₁\n                },\n              simp [h₃],\n              apply ih,\n              intros, apply heq, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₁, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₂, exact H₄, exact a, right, exact H₃,\n              intros, apply heq₃, exact H₄, exact a, right, exact H₃\n            }\n        }\n    }\nend\n\nprivate lemma count_partition_over_filter\n  {α : Type} {l : list α} [decidable_eq α]\n  {P : α → Prop} [decidable_pred P]\n  {P₃ : α → Prop} [decidable_pred P₃]\n  {P₅ : {x // x ∈ l} → Prop} [decidable_pred P₅]\n  (h : ∀x, ¬P x ↔ P₃ x) :\n  length (filter (λ (x : {x // x ∈ l}), P₅ x) (attach l)) =\n  length (filter (λ (x : {x // x ∈ filter P l}), P₅ ⟨x.1, in_l_of_in_filter x.2⟩) (attach (filter P l))) +\n  length (filter (λ (x : {x // x ∈ filter P₃ l}), P₅ ⟨x.1, in_l_of_in_filter x.2⟩) (attach (filter P₃ l))) :=\nbegin\n  apply filter_partition_dependent', exact h,\n  intros, exact a,\n  intros, exact a,\n  intros, exact a,\n  intros, exact a\nend\n\nlemma count_split {α : Type*} [grid α] [decidable_eq (carrier α)] (g : α) (bb) (H₁)\n  {elem : carrier α} :\n  count elem (℘ g) =\n  count elem (@generate _ _ (subgrid g bb H₁)) +\n  count elem (subgrid' g bb H₁) :=\nbegin\n  rw count_subgrid_in_bb,\n  simp only [\n    generate, subgrid', comp, grid_point_of_prod,\n    inject_into_bounded, make_bounded, make_bounded_idx, gbl, map,\n    inject_filter_bounded, grid_point_of_mem \n  ],\n  simp only [\n    count, countp_eq_length_filter,\n    filter_of_map, gbl, map, length, length_map\n  ],\n  simp only [(∘)],\n  apply count_partition_over_filter, finish\nend\n\nend finite_grid\n\nsection grid_instances\n\nopen relative_grid\n\ndef split_rows_cols : ℕ → ℕ → list string → list string\n  | cols 0 ls := [\"\"]\n  | cols (k + 1) ls := list.take cols ls ++ [\"\\n\"]\n                       ++ split_rows_cols cols k (list.drop cols ls)\n\ndef grid_str {α : Type*} [grid α]\n  [has_to_string (carrier α)] (g : α) : string :=\n  let points := list.map to_string $ ℘ g in\n    \" \" ++ (list.foldr append \"\" $\n                       list.intersperse \" \" $\n                       split_rows_cols (cols g)\n                                       (rows g) points)\n\ninstance grid_repr {α : Type*} [grid α]\n  [has_to_string (carrier α)] : has_repr α := ⟨grid_str⟩\n\ninstance grid_to_string {α : Type*} [grid α]\n  [has_to_string (carrier α)] : has_to_string α := ⟨grid_str⟩\n\n-- def test_grid : vec_grid₀ ℕ :=\n--   vec_grid₀.mk ⟨4, 5, dec_trivial,\n--     ⟨[1, 2, 3, 4, 5,\n--       1, 2, 3, 4, 5,\n--       1, 2, 3, 4, 5,\n--       1, 2, 3, 4, 5], rfl⟩⟩ ⟨0, 0⟩\n-- def testbb : bounding_box := ⟨⟨0, 0⟩, ⟨2, 3⟩, sorry⟩\n-- #eval list.filter (λx, x ∈ testbb) (gip_g test_grid)\n-- #eval gip_g (subgrid test_grid testbb sorry)\n-- #eval list.count 4 (℘ test_grid)\n-- #eval list.count 4 (℘ (subgrid test_grid testbb sorry))\n-- #eval list.count 4 ((subgrid' test_grid testbb sorry))\n-- #eval (subgrid' test_grid testbb sorry)\n-- -- 16, 17, 18, 19, 20\n-- -- 11, 12, 13, 14, 16,\n-- -- 6, 7, 8, 9, 10,\n-- -- 1, 2, 3, 4, 5,\n-- #eval grid_bounds test_grid\n-- #eval subgrid' test_grid ⟨⟨1, 1⟩, ⟨4, 3⟩, sorry⟩ sorry\n\nend grid_instances", "meta": {"author": "frankSil", "repo": "CAExtensions", "sha": "f5c74fd9a806696c73497d9abd45b7315f45379f", "save_path": "github-repos/lean/frankSil-CAExtensions", "path": "github-repos/lean/frankSil-CAExtensions/CAExtensions-f5c74fd9a806696c73497d9abd45b7315f45379f/src/grid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6723317123102955, "lm_q1q2_score": 0.4996554197646619}}
{"text": "example  (p : Nat → Prop) (h : ∀ n, p (n+1) = p n) : (p m ↔ p 0) := by\n  induction m\n  case succ ih =>\n    rw [h, ih]\n    exact Iff.rfl\n  case zero => exact Iff.rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/rw_inst_mvars.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.4996554176550304}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.group_theory.group_action.defs\nimport Mathlib.algebra.group.units\nimport Mathlib.algebra.group_with_zero.default\nimport Mathlib.data.equiv.mul_add\nimport Mathlib.group_theory.perm.basic\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# Group actions applied to various types of group\n\nThis file contains lemmas about `smul` on `units`, `group_with_zero`, and `group`.\n-/\n\n@[simp] theorem units.inv_smul_smul {α : Type u} {β : Type v} [monoid α] [mul_action α β] (u : units α) (x : β) : ↑(u⁻¹) • ↑u • x = x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (↑(u⁻¹) • ↑u • x = x)) (smul_smul (↑(u⁻¹)) (↑u) x)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((↑(u⁻¹) * ↑u) • x = x)) (units.inv_mul u)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 • x = x)) (one_smul α x))) (Eq.refl x)))\n\n@[simp] theorem units.smul_inv_smul {α : Type u} {β : Type v} [monoid α] [mul_action α β] (u : units α) (x : β) : ↑u • ↑(u⁻¹) • x = x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (↑u • ↑(u⁻¹) • x = x)) (smul_smul (↑u) (↑(u⁻¹)) x)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((↑u * ↑(u⁻¹)) • x = x)) (units.mul_inv u)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 • x = x)) (one_smul α x))) (Eq.refl x)))\n\n/-- If a monoid `α` acts on `β`, then each `u : units α` defines a permutation of `β`. -/\ndef units.smul_perm_hom {α : Type u} {β : Type v} [monoid α] [mul_action α β] : units α →* equiv.perm β :=\n  monoid_hom.mk\n    (fun (u : units α) =>\n      equiv.mk (fun (x : β) => ↑u • x) (fun (x : β) => ↑(u⁻¹) • x) (units.inv_smul_smul u) (units.smul_inv_smul u))\n    sorry sorry\n\n@[simp] theorem units.smul_left_cancel {α : Type u} {β : Type v} [monoid α] [mul_action α β] (u : units α) {x : β} {y : β} : ↑u • x = ↑u • y ↔ x = y :=\n  equiv.apply_eq_iff_eq (coe_fn units.smul_perm_hom u)\n\ntheorem units.smul_eq_iff_eq_inv_smul {α : Type u} {β : Type v} [monoid α] [mul_action α β] (u : units α) {x : β} {y : β} : ↑u • x = y ↔ x = ↑(u⁻¹) • y :=\n  equiv.apply_eq_iff_eq_symm_apply (coe_fn units.smul_perm_hom u)\n\ntheorem is_unit.smul_left_cancel {α : Type u} {β : Type v} [monoid α] [mul_action α β] {a : α} (ha : is_unit a) {x : β} {y : β} : a • x = a • y ↔ x = y := sorry\n\n@[simp] theorem inv_smul_smul' {α : Type u} {β : Type v} [group_with_zero α] [mul_action α β] {c : α} (hc : c ≠ 0) (x : β) : c⁻¹ • c • x = x :=\n  units.inv_smul_smul (units.mk0 c hc) x\n\n@[simp] theorem smul_inv_smul' {α : Type u} {β : Type v} [group_with_zero α] [mul_action α β] {c : α} (hc : c ≠ 0) (x : β) : c • c⁻¹ • x = x :=\n  units.smul_inv_smul (units.mk0 c hc) x\n\ntheorem inv_smul_eq_iff' {α : Type u} {β : Type v} [group_with_zero α] [mul_action α β] {a : α} (ha : a ≠ 0) {x : β} {y : β} : a⁻¹ • x = y ↔ x = a • y := sorry\n\ntheorem eq_inv_smul_iff' {α : Type u} {β : Type v} [group_with_zero α] [mul_action α β] {a : α} (ha : a ≠ 0) {x : β} {y : β} : x = a⁻¹ • y ↔ a • x = y := sorry\n\n@[simp] theorem inv_smul_smul {α : Type u} {β : Type v} [group α] [mul_action α β] (c : α) (x : β) : c⁻¹ • c • x = x :=\n  units.inv_smul_smul (coe_fn to_units c) x\n\n@[simp] theorem smul_inv_smul {α : Type u} {β : Type v} [group α] [mul_action α β] (c : α) (x : β) : c • c⁻¹ • x = x :=\n  units.smul_inv_smul (coe_fn to_units c) x\n\ntheorem inv_smul_eq_iff {α : Type u} {β : Type v} [group α] [mul_action α β] {a : α} {x : β} {y : β} : a⁻¹ • x = y ↔ x = a • y := sorry\n\ntheorem eq_inv_smul_iff {α : Type u} {β : Type v} [group α] [mul_action α β] {a : α} {x : β} {y : β} : x = a⁻¹ • y ↔ a • x = y := sorry\n\n/-- Given an action of a group `α` on a set `β`, each `g : α` defines a permutation of `β`. -/\ndef mul_action.to_perm (α : Type u) (β : Type v) [group α] [mul_action α β] : α →* equiv.perm β :=\n  monoid_hom.comp units.smul_perm_hom (mul_equiv.to_monoid_hom to_units)\n\nprotected theorem mul_action.bijective {α : Type u} {β : Type v} [group α] [mul_action α β] (g : α) : function.bijective fun (b : β) => g • b :=\n  equiv.bijective (coe_fn (mul_action.to_perm α β) g)\n\ntheorem units.smul_eq_zero {α : Type u} {β : Type v} [monoid α] [add_monoid β] [distrib_mul_action α β] (u : units α) {x : β} : ↑u • x = 0 ↔ x = 0 := sorry\n\ntheorem units.smul_ne_zero {α : Type u} {β : Type v} [monoid α] [add_monoid β] [distrib_mul_action α β] (u : units α) {x : β} : ↑u • x ≠ 0 ↔ x ≠ 0 :=\n  not_congr (units.smul_eq_zero u)\n\n@[simp] theorem is_unit.smul_eq_zero {α : Type u} {β : Type v} [monoid α] [add_monoid β] [distrib_mul_action α β] {u : α} (hu : is_unit u) {x : β} : u • x = 0 ↔ x = 0 :=\n  exists.elim hu fun (u_1 : units α) (hu : ↑u_1 = u) => hu ▸ units.smul_eq_zero u_1\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/group_theory/group_action/group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4996554148853889}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport topology.sheaves.sheaf\nimport category_theory.limits.preserves.shapes.products\nimport category_theory.limits.types\n\n/-!\n# Checking the sheaf condition on the underlying presheaf of types.\n\nIf `G : C ⥤ D` is a functor which reflects isomorphisms and preserves limits\n(we assume all limits exist in both `C` and `D`),\nthen checking the sheaf condition for a presheaf `F : presheaf C X`\nis equivalent to checking the sheaf condition for `F ⋙ G`.\n\nThe important special case is when\n`C` is a concrete category with a forgetful functor\nthat preserves limits and reflects isomorphisms.\nThen to check the sheaf condition it suffices\nto check it on the underlying sheaf of types.\n\n## References\n* https://stacks.math.columbia.edu/tag/0073\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\nopen topological_space\nopen opposite\n\nnamespace Top\n\nnamespace presheaf\n\nnamespace sheaf_condition\n\nopen sheaf_condition_equalizer_products\n\nuniverses v u₁ u₂\n\nvariables {C : Type u₁} [category.{v} C] [has_limits C]\nvariables {D : Type u₂} [category.{v} D] [has_limits D]\nvariables (G : C ⥤ D) [preserves_limits G]\nvariables {X : Top.{v}} (F : presheaf C X)\nvariables {ι : Type v} (U : ι → opens X)\n\nlocal attribute [reducible] diagram left_res right_res\n\n/--\nWhen `G` preserves limits, the sheaf condition diagram for `F` composed with `G` is\nnaturally isomorphic to the sheaf condition diagram for `F ⋙ G`.\n-/\ndef diagram_comp_preserves_limits :\n  diagram F U ⋙ G ≅ diagram (F ⋙ G) U :=\nbegin\n  fapply nat_iso.of_components,\n  rintro ⟨j⟩,\n  exact (preserves_product.iso _ _),\n  exact (preserves_product.iso _ _),\n  rintros ⟨⟩ ⟨⟩ ⟨⟩,\n  { ext, simp, dsimp, simp, }, -- non-terminal `simp`, but `squeeze_simp` fails\n  { ext,\n    simp only [limit.lift_π, functor.comp_map, map_lift_pi_comparison, fan.mk_π_app,\n               preserves_product.iso_hom, parallel_pair_map_left, functor.map_comp,\n               category.assoc],\n    dsimp, simp, },\n  { ext,\n    simp only [limit.lift_π, functor.comp_map, parallel_pair_map_right, fan.mk_π_app,\n               preserves_product.iso_hom, map_lift_pi_comparison, functor.map_comp,\n               category.assoc],\n    dsimp, simp, },\n { ext, simp, dsimp, simp, },\nend\n\nlocal attribute [reducible] res\n\n/--\nWhen `G` preserves limits, the image under `G` of the sheaf condition fork for `F`\nis the sheaf condition fork for `F ⋙ G`,\npostcomposed with the inverse of the natural isomorphism `diagram_comp_preserves_limits`.\n-/\ndef map_cone_fork : G.map_cone (fork F U) ≅\n  (cones.postcompose (diagram_comp_preserves_limits G F U).inv).obj (fork (F ⋙ G) U) :=\ncones.ext (iso.refl _) (λ j,\nbegin\n  dsimp, simp [diagram_comp_preserves_limits], cases j; dsimp,\n  { rw iso.eq_comp_inv,\n    ext,\n    simp, dsimp, simp, },\n  { rw iso.eq_comp_inv,\n    ext,\n    simp, -- non-terminal `simp`, but `squeeze_simp` fails\n    dsimp,\n    simp only [limit.lift_π, fan.mk_π_app, ←G.map_comp, limit.lift_π_assoc, fan.mk_π_app] }\nend)\n\nend sheaf_condition\n\nuniverses v u₁ u₂\n\nopen sheaf_condition sheaf_condition_equalizer_products\n\nvariables {C : Type u₁} [category.{v} C] {D : Type u₂} [category.{v} D]\nvariables (G : C ⥤ D)\nvariables [reflects_isomorphisms G]\nvariables [has_limits C] [has_limits D] [preserves_limits G]\n\nvariables {X : Top.{v}} (F : presheaf C X)\n\n/--\nIf `G : C ⥤ D` is a functor which reflects isomorphisms and preserves limits\n(we assume all limits exist in both `C` and `D`),\nthen checking the sheaf condition for a presheaf `F : presheaf C X`\nis equivalent to checking the sheaf condition for `F ⋙ G`.\n\nThe important special case is when\n`C` is a concrete category with a forgetful functor\nthat preserves limits and reflects isomorphisms.\nThen to check the sheaf condition it suffices to check it on the underlying sheaf of types.\n\nAnother useful example is the forgetful functor `TopCommRing ⥤ Top`.\n\nSee https://stacks.math.columbia.edu/tag/0073.\nIn fact we prove a stronger version with arbitrary complete target category.\n-/\ndef sheaf_condition_equiv_sheaf_condition_comp :\n  sheaf_condition F ≃ sheaf_condition (F ⋙ G) :=\nbegin\n  apply equiv_of_subsingleton_of_subsingleton,\n  { intros S ι U,\n    -- We have that the sheaf condition fork for `F` is a limit fork,\n    have t₁ := S U,\n    -- and since `G` preserves limits, the image under `G` of this fork is a limit fork too.\n    have t₂ := @preserves_limit.preserves _ _ _ _ _ _ _ G _ _ t₁,\n    -- As we established above, that image is just the sheaf condition fork\n    -- for `F ⋙ G` postcomposed with some natural isomorphism,\n    have t₃ := is_limit.of_iso_limit t₂ (map_cone_fork G F U),\n    -- and as postcomposing by a natural isomorphism preserves limit cones,\n    have t₄ := is_limit.postcompose_inv_equiv _ _ t₃,\n    -- we have our desired conclusion.\n    exact t₄, },\n  { intros S ι U,\n    -- Let `f` be the universal morphism from `F.obj U` to the equalizer\n    -- of the sheaf condition fork, whatever it is.\n    -- Our goal is to show that this is an isomorphism.\n    let f := equalizer.lift _ (w F U),\n    -- If we can do that,\n    suffices : is_iso (G.map f),\n    { resetI,\n      -- we have that `f` itself is an isomorphism, since `G` reflects isomorphisms\n      haveI : is_iso f := is_iso_of_reflects_iso f G,\n      -- TODO package this up as a result elsewhere:\n      apply is_limit.of_iso_limit (limit.is_limit _),\n      apply iso.symm,\n      fapply cones.ext,\n      exact (as_iso f),\n      rintro ⟨_|_⟩; { dsimp [f], simp, }, },\n    { -- Returning to the task of shwoing that `G.map f` is an isomorphism,\n      -- we note that `G.map f` is almost but not quite (see below) a morphism\n      -- from the sheaf condition cone for `F ⋙ G` to the\n      -- image under `G` of the equalizer cone for the sheaf condition diagram.\n      let c := fork (F ⋙ G) U,\n      have hc : is_limit c := S U,\n      let d := G.map_cone (equalizer.fork (left_res F U) (right_res F U)),\n      have hd : is_limit d := preserves_limit.preserves (limit.is_limit _),\n      -- Since both of these are limit cones\n      -- (`c` by our hypothesis `S`, and `d` because `G` preserves limits),\n      -- we hope to be able to conclude that `f` is an isomorphism.\n      -- We say \"not quite\" above because `c` and `d` don't quite have the same shape:\n      -- we need to postcompose by the natural isomorphism `diagram_comp_preserves_limits`\n      -- introduced above.\n      let d' := (cones.postcompose (diagram_comp_preserves_limits G F U).hom).obj d,\n      have hd' : is_limit d' :=\n        (is_limit.postcompose_hom_equiv (diagram_comp_preserves_limits G F U) d).symm hd,\n      -- Now everything works: we verify that `f` really is a morphism between these cones:\n      let f' : c ⟶ d' :=\n      fork.mk_hom (G.map f)\n      begin\n        dsimp only [c, d, d', f, diagram_comp_preserves_limits, res],\n        dunfold fork.ι,\n        ext1 j,\n        dsimp,\n        simp only [category.assoc, ←functor.map_comp_assoc, equalizer.lift_ι,\n          map_lift_pi_comparison_assoc],\n        dsimp [res], simp,\n      end,\n      -- conclude that it is an isomorphism,\n      -- just because it's a morphism between two limit cones.\n      haveI : is_iso f' := is_limit.hom_is_iso hc hd' f',\n      -- A cone morphism is an isomorphism exactly if the morphism between the cone points is,\n      -- so we're done!\n      exact is_iso.of_iso ((cones.forget _).map_iso (as_iso f')) }, },\nend\n\n/-!\nAs an example, we now have everything we need to check the sheaf condition\nfor a presheaf of commutative rings, merely by checking the sheaf condition\nfor the underlying sheaf of types.\n```\nexample (X : Top) (F : presheaf CommRing X) (h : sheaf_condition (F ⋙ (forget CommRing))) :\n  sheaf_condition F :=\n(sheaf_condition_equiv_sheaf_condition_forget F).symm h\n```\n-/\n\nend presheaf\n\nend Top\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/sheaves/forget.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.49965541488538884}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\nIntroduces the rational numbers as discrete, linear ordered field.\n-/\n\nimport\n  data.nat.gcd data.pnat data.int.basic data.equiv.encodable order.basic\n  algebra.ordered_field data.real.cau_seq\n\n/- rational numbers -/\n\n/-- `rat`, or `ℚ`, is the type of rational numbers. It is defined\n  as the set of pairs ⟨n, d⟩ of integers such that `d` is positive and `n` and\n  `d` are coprime. This representation is preferred to the quotient\n  because without periodic reduction, the numerator and denominator can grow\n  exponentially (for example, adding 1/2 to itself repeatedly). -/\nstructure rat := mk' ::\n(num : ℤ)\n(denom : ℕ)\n(pos : denom > 0)\n(cop : num.nat_abs.coprime denom)\nnotation `ℚ` := rat\n\nnamespace rat\n\nprotected def repr : ℚ → string\n| ⟨n, d, _, _⟩ := if d = 1 then _root_.repr n else\n  _root_.repr n ++ \"/\" ++ _root_.repr d\n\ninstance : has_repr ℚ := ⟨rat.repr⟩\ninstance : has_to_string ℚ := ⟨rat.repr⟩\nmeta instance : has_to_format ℚ := ⟨coe ∘ rat.repr⟩\n\ninstance : encodable ℚ := encodable.of_equiv (Σ n : ℤ, {d : ℕ // d > 0 ∧ n.nat_abs.coprime d})\n  ⟨λ ⟨a, b, c, d⟩, ⟨a, b, c, d⟩, λ⟨a, b, c, d⟩, ⟨a, b, c, d⟩,\n   λ ⟨a, b, c, d⟩, rfl, λ⟨a, b, c, d⟩, rfl⟩\n\n/-- Embed an integer as a rational number -/\ndef of_int (n : ℤ) : ℚ :=\n⟨n, 1, nat.one_pos, nat.coprime_one_right _⟩\n\ninstance : has_zero ℚ := ⟨of_int 0⟩\ninstance : has_one ℚ := ⟨of_int 1⟩\ninstance : inhabited ℚ := ⟨0⟩\n\n/-- Form the quotient `n / d` where `n:ℤ` and `d:ℕ+` (not necessarily coprime) -/\ndef mk_pnat (n : ℤ) : ℕ+ → ℚ | ⟨d, dpos⟩ :=\nlet n' := n.nat_abs, g := n'.gcd d in\n⟨n / g, d / g, begin\n  apply (nat.le_div_iff_mul_le _ _ (nat.gcd_pos_of_pos_right _ dpos)).2,\n  simp, exact nat.le_of_dvd dpos (nat.gcd_dvd_right _ _)\nend, begin\n  have : int.nat_abs (n / ↑g) = n' / g,\n  { cases int.nat_abs_eq n with e e; rw e, { refl },\n    rw [int.neg_div_of_dvd, int.nat_abs_neg], { refl },\n    exact int.coe_nat_dvd.2 (nat.gcd_dvd_left _ _) },\n  rw this,\n  exact nat.coprime_div_gcd_div_gcd (nat.gcd_pos_of_pos_right _ dpos)\nend⟩\n\n/-- Form the quotient `n / d` where `n:ℤ` and `d:ℕ`. In the case `d = 0`, we\n  define `n / 0 = 0` by convention. -/\ndef mk_nat (n : ℤ) (d : ℕ) : ℚ :=\nif d0 : d = 0 then 0 else mk_pnat n ⟨d, nat.pos_of_ne_zero d0⟩\n\n/-- Form the quotient `n / d` where `n d : ℤ`. -/\ndef mk : ℤ → ℤ → ℚ\n| n (int.of_nat d) := mk_nat n d\n| n -[1+ d]        := mk_pnat (-n) d.succ_pnat\n\nlocal infix ` /. `:70 := mk\n\ntheorem mk_pnat_eq (n d h) : mk_pnat n ⟨d, h⟩ = n /. d :=\nby change n /. d with dite _ _ _; simp [ne_of_gt h]\n\ntheorem mk_nat_eq (n d) : mk_nat n d = n /. d := rfl\n\n@[simp] theorem mk_zero (n) : n /. 0 = 0 := rfl\n\n@[simp] theorem zero_mk_pnat (n) : mk_pnat 0 n = 0 :=\nby cases n; simp [mk_pnat]; change int.nat_abs 0 with 0; simp *; refl\n\n@[simp] theorem zero_mk_nat (n) : mk_nat 0 n = 0 :=\nby by_cases n = 0; simp [*, mk_nat]\n\n@[simp] theorem zero_mk (n) : 0 /. n = 0 :=\nby cases n; simp [mk]\n\nprivate lemma gcd_abs_dvd_left {a b} : (nat.gcd (int.nat_abs a) b : ℤ) ∣ a :=\nint.dvd_nat_abs.1 $ int.coe_nat_dvd.2 $ nat.gcd_dvd_left (int.nat_abs a) b\n\n@[simp] theorem mk_eq_zero {a b : ℤ} (b0 : b ≠ 0) : a /. b = 0 ↔ a = 0 :=\nbegin\n  constructor; intro h; [skip, {subst a, simp}],\n  have : ∀ {a b}, mk_pnat a b = 0 → a = 0,\n  { intros a b e, cases b with b h,\n    injection e with e,\n    apply int.eq_mul_of_div_eq_right gcd_abs_dvd_left e },\n  cases b with b; simp [mk, mk_nat] at h,\n  { simp [mt (congr_arg int.of_nat) b0] at h,\n    exact this h },\n  { apply neg_inj, simp [this h] }\nend\n\ntheorem mk_eq : ∀ {a b c d : ℤ} (hb : b ≠ 0) (hd : d ≠ 0),\n  a /. b = c /. d ↔ a * d = c * b :=\nsuffices ∀ a b c d hb hd, mk_pnat a ⟨b, hb⟩ = mk_pnat c ⟨d, hd⟩ ↔ a * d = c * b,\nbegin\n  intros, cases b with b b; simp [mk, mk_nat, nat.succ_pnat],\n  simp [mt (congr_arg int.of_nat) hb],\n  all_goals {\n    cases d with d d; simp [mk, mk_nat, nat.succ_pnat],\n    simp [mt (congr_arg int.of_nat) hd],\n    all_goals { rw this, try {refl} } },\n  { change a * ↑(d.succ) = -c * ↑b ↔ a * -(d.succ) = c * b,\n    constructor; intro h; apply neg_inj; simpa [left_distrib, neg_add_eq_iff_eq_add,\n      eq_neg_iff_add_eq_zero, neg_eq_iff_add_eq_zero] using h },\n  { change -a * ↑d = c * b.succ ↔ a * d = c * -b.succ,\n    constructor; intro h; apply neg_inj; simpa [left_distrib, eq_comm] using h },\n  { change -a * d.succ = -c * b.succ ↔ a * -d.succ = c * -b.succ,\n    simp [left_distrib] }\nend,\nbegin\n  intros, simp [mk_pnat], constructor; intro h,\n  { cases h with ha hb,\n    have ha, {\n      have dv := @gcd_abs_dvd_left,\n      have := int.eq_mul_of_div_eq_right dv ha,\n      rw ← int.mul_div_assoc _ dv at this,\n      exact int.eq_mul_of_div_eq_left (dvd_mul_of_dvd_right dv _) this.symm },\n    have hb, {\n      have dv := λ {a b}, nat.gcd_dvd_right (int.nat_abs a) b,\n      have := nat.eq_mul_of_div_eq_right dv hb,\n      rw ← nat.mul_div_assoc _ dv at this,\n      exact nat.eq_mul_of_div_eq_left (dvd_mul_of_dvd_right dv _) this.symm },\n    have m0 : (a.nat_abs.gcd b * c.nat_abs.gcd d : ℤ) ≠ 0, {\n      refine int.coe_nat_ne_zero.2 (ne_of_gt _),\n      apply mul_pos; apply nat.gcd_pos_of_pos_right; assumption },\n    apply eq_of_mul_eq_mul_right m0,\n    simpa [mul_comm, mul_left_comm] using\n      congr (congr_arg (*) ha.symm) (congr_arg coe hb) },\n  { suffices : ∀ a c, a * d = c * b →\n      a / a.gcd b = c / c.gcd d ∧ b / a.gcd b = d / c.gcd d,\n    { cases this a.nat_abs c.nat_abs\n        (by simpa [int.nat_abs_mul] using congr_arg int.nat_abs h) with h₁ h₂,\n      have hs := congr_arg int.sign h,\n      simp [int.sign_eq_one_of_pos (int.coe_nat_lt.2 hb),\n            int.sign_eq_one_of_pos (int.coe_nat_lt.2 hd)] at hs,\n      conv in a { rw ← int.sign_mul_nat_abs a },\n      conv in c { rw ← int.sign_mul_nat_abs c },\n      rw [int.mul_div_assoc, int.mul_div_assoc],\n      exact ⟨congr (congr_arg (*) hs) (congr_arg coe h₁), h₂⟩,\n      all_goals { exact int.coe_nat_dvd.2 (nat.gcd_dvd_left _ _) } },\n    intros a c h,\n    suffices bd : b / a.gcd b = d / c.gcd d,\n    { refine ⟨_, bd⟩,\n      apply nat.eq_of_mul_eq_mul_left hb,\n      rw [← nat.mul_div_assoc _ (nat.gcd_dvd_left _ _), mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), bd,\n          ← nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), h, mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_left _ _)] },\n    suffices : ∀ {a c : ℕ} (b>0) (d>0),\n      a * d = c * b → b / a.gcd b ≤ d / c.gcd d,\n    { exact le_antisymm (this _ hb _ hd h) (this _ hd _ hb h.symm) },\n    intros a c b hb d hd h,\n    have gb0 := nat.gcd_pos_of_pos_right a hb,\n    have gd0 := nat.gcd_pos_of_pos_right c hd,\n    apply nat.le_of_dvd,\n    apply (nat.le_div_iff_mul_le _ _ gd0).2,\n    simp, apply nat.le_of_dvd hd (nat.gcd_dvd_right _ _),\n    apply (nat.coprime_div_gcd_div_gcd gb0).symm.dvd_of_dvd_mul_left,\n    refine ⟨c / c.gcd d, _⟩,\n    rw [← nat.mul_div_assoc _ (nat.gcd_dvd_left _ _),\n        ← nat.mul_div_assoc _ (nat.gcd_dvd_right _ _)],\n    apply congr_arg (/ c.gcd d),\n    rw [mul_comm, ← nat.mul_div_assoc _ (nat.gcd_dvd_left _ _),\n        mul_comm, h, nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), mul_comm] }\nend\n\n@[simp] theorem div_mk_div_cancel_left {a b c : ℤ} (c0 : c ≠ 0) :\n  (a * c) /. (b * c) = a /. b :=\nbegin\n  by_cases b0 : b = 0, { subst b0, simp },\n  apply (mk_eq (mul_ne_zero b0 c0) b0).2, simp [mul_comm, mul_assoc]\nend\n\ntheorem num_denom : ∀ a : ℚ, a = a.num /. a.denom\n| ⟨n, d, h, (c:_=1)⟩ := show _ = mk_nat n d,\n  by simp [mk_nat, ne_of_gt h, mk_pnat, c]\n\ntheorem num_denom' (n d h c) : (⟨n, d, h, c⟩ : ℚ) = n /. d := num_denom _\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on {C : ℚ → Sort u}\n   : ∀ (a : ℚ) (H : ∀ n d, d > 0 → (int.nat_abs n).coprime d → C (n /. d)), C a\n| ⟨n, d, h, c⟩ H := by rw num_denom'; exact H n d h c\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on' {C : ℚ → Sort u}\n   (a : ℚ) (H : ∀ (n:ℤ) (d:ℕ), d ≠ 0 → C (n /. d)) : C a :=\nnum_denom_cases_on a $ λ n d h c,\nH n d $ ne_of_gt h\n\ntheorem num_dvd (a) {b : ℤ} (b0 : b ≠ 0) : (a /. b).num ∣ a :=\nbegin\n  cases e : a /. b with n d h c,\n  rw [rat.num_denom', rat.mk_eq b0\n    (ne_of_gt (int.coe_nat_pos.2 h))] at e,\n  refine (int.nat_abs_dvd.1 $ int.dvd_nat_abs.1 $ int.coe_nat_dvd.2 $\n    c.dvd_of_dvd_mul_right _),\n  have := congr_arg int.nat_abs e,\n  simp [int.nat_abs_mul, int.nat_abs_of_nat] at this, simp [this]\nend\n\ntheorem denom_dvd (a b : ℤ) : ((a /. b).denom : ℤ) ∣ b :=\nbegin\n  by_cases b0 : b = 0, {simp [b0]},\n  cases e : a /. b with n d h c,\n  rw [num_denom', mk_eq b0 (ne_of_gt (int.coe_nat_pos.2 h))] at e,\n  refine (int.dvd_nat_abs.1 $ int.coe_nat_dvd.2 $ c.symm.dvd_of_dvd_mul_left _),\n  rw [← int.nat_abs_mul, ← int.coe_nat_dvd, int.dvd_nat_abs, ← e], simp\nend\n\nprotected def add : ℚ → ℚ → ℚ\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := mk_pnat (n₁ * d₂ + n₂ * d₁) ⟨d₁ * d₂, mul_pos h₁ h₂⟩\n\ninstance : has_add ℚ := ⟨rat.add⟩\n\ntheorem lift_binop_eq (f : ℚ → ℚ → ℚ) (f₁ : ℤ → ℤ → ℤ → ℤ → ℤ) (f₂ : ℤ → ℤ → ℤ → ℤ → ℤ)\n  (fv : ∀ {n₁ d₁ h₁ c₁ n₂ d₂ h₂ c₂},\n    f ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ = f₁ n₁ d₁ n₂ d₂ /. f₂ n₁ d₁ n₂ d₂)\n  (f0 : ∀ {n₁ d₁ n₂ d₂} (d₁0 : d₁ ≠ 0) (d₂0 : d₂ ≠ 0), f₂ n₁ d₁ n₂ d₂ ≠ 0)\n  (a b c d : ℤ) (b0 : b ≠ 0) (d0 : d ≠ 0)\n  (H : ∀ {n₁ d₁ n₂ d₂} (h₁ : a * d₁ = n₁ * b) (h₂ : c * d₂ = n₂ * d),\n       f₁ n₁ d₁ n₂ d₂ * f₂ a b c d = f₁ a b c d * f₂ n₁ d₁ n₂ d₂) :\n  f (a /. b) (c /. d) = f₁ a b c d /. f₂ a b c d :=\nbegin\n  generalize ha : a /. b = x, cases x with n₁ d₁ h₁ c₁, rw num_denom' at ha,\n  generalize hc : c /. d = x, cases x with n₂ d₂ h₂ c₂, rw num_denom' at hc,\n  rw fv,\n  have d₁0 := ne_of_gt (int.coe_nat_lt.2 h₁),\n  have d₂0 := ne_of_gt (int.coe_nat_lt.2 h₂),\n  exact (mk_eq (f0 d₁0 d₂0) (f0 b0 d0)).2 (H ((mk_eq b0 d₁0).1 ha) ((mk_eq d0 d₂0).1 hc))\nend\n\n@[simp] theorem add_def {a b c d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n  a /. b + c /. d = (a * d + c * b) /. (b * d) :=\nbegin\n  apply lift_binop_eq rat.add; intros; try {assumption},\n  { apply mk_pnat_eq },\n  { apply mul_ne_zero d₁0 d₂0 },\n  calc (n₁ * d₂ + n₂ * d₁) * (b * d) =\n          (n₁ * b) * d₂ * d + (n₂ * d) * (d₁ * b) : by simp [mul_add, mul_comm, mul_left_comm]\n    ... = (a * d₁) * d₂ * d + (c * d₂) * (d₁ * b) : by rw [h₁, h₂]\n    ... = (a * d + c * b) * (d₁ * d₂)             : by simp [mul_add, mul_comm, mul_left_comm]\nend\n\nprotected def neg : ℚ → ℚ\n| ⟨n, d, h, c⟩ := ⟨-n, d, h, by simp [c]⟩\n\ninstance : has_neg ℚ := ⟨rat.neg⟩\n\n@[simp] theorem neg_def {a b : ℤ} : -(a /. b) = -a /. b :=\nbegin\n  by_cases b0 :  b = 0, { subst b0, simp, refl },\n  generalize ha : a /. b = x, cases x with n₁ d₁ h₁ c₁, rw num_denom' at ha,\n  show rat.mk' _ _ _ _ = _, rw num_denom',\n  have d0 := ne_of_gt (int.coe_nat_lt.2 h₁),\n  apply (mk_eq d0 b0).2, have h₁ := (mk_eq b0 d0).1 ha,\n  simp only [neg_mul_eq_neg_mul_symm, congr_arg has_neg.neg h₁]\nend\n\nprotected def mul : ℚ → ℚ → ℚ\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := mk_pnat (n₁ * n₂) ⟨d₁ * d₂, mul_pos h₁ h₂⟩\n\ninstance : has_mul ℚ := ⟨rat.mul⟩\n\n@[simp] theorem mul_def {a b c d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n  (a /. b) * (c /. d) = (a * c) /. (b * d) :=\nbegin\n  apply lift_binop_eq rat.mul; intros; try {assumption},\n  { apply mk_pnat_eq },\n  { apply mul_ne_zero d₁0 d₂0 },\n  cc\nend\n\nprotected def inv : ℚ → ℚ\n| ⟨(n+1:ℕ), d, h, c⟩ := ⟨d, n+1, n.succ_pos, c.symm⟩\n| ⟨0, d, h, c⟩ := 0\n| ⟨-[1+ n], d, h, c⟩ := ⟨-d, n+1, n.succ_pos, nat.coprime.symm $ by simp; exact c⟩\n\ninstance : has_inv ℚ := ⟨rat.inv⟩\n\n@[simp] theorem inv_def {a b : ℤ} : (a /. b)⁻¹ = b /. a :=\nbegin\n  by_cases a0 : a = 0, { subst a0, simp, refl },\n  by_cases b0 : b = 0, { subst b0, simp, refl },\n  generalize ha : a /. b = x, cases x with n d h c, rw num_denom' at ha,\n  refine eq.trans (_ : rat.inv ⟨n, d, h, c⟩ = d /. n) _,\n  { cases n with n; [cases n with n, skip],\n    { refl },\n    { change int.of_nat n.succ with (n+1:ℕ),\n      unfold rat.inv, rw num_denom' },\n    { unfold rat.inv, rw num_denom', refl } },\n  have n0 : n ≠ 0,\n  { refine mt (λ (n0 : n = 0), _) a0,\n    subst n0, simp at ha,\n    exact (mk_eq_zero b0).1 ha },\n  have d0 := ne_of_gt (int.coe_nat_lt.2 h),\n  have ha := (mk_eq b0 d0).1 ha,\n  apply (mk_eq n0 a0).2,\n  cc\nend\n\nvariables (a b c : ℚ)\n\nprotected theorem add_zero : a + 0 = a :=\nnum_denom_cases_on' a $ λ n d h,\nby rw [← zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem zero_add : 0 + a = a :=\nnum_denom_cases_on' a $ λ n d h,\nby rw [← zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem add_comm : a + b = b + a :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nby simp [h₁, h₂, mul_comm]\n\nprotected theorem add_assoc : a + b + c = a + (b + c) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nnum_denom_cases_on' c $ λ n₃ d₃ h₃,\nby simp [h₁, h₂, h₃, mul_ne_zero, mul_add, mul_comm, mul_left_comm, add_left_comm]\n\nprotected theorem add_left_neg : -a + a = 0 :=\nnum_denom_cases_on' a $ λ n d h,\nby simp [h]\n\nprotected theorem mul_one : a * 1 = a :=\nnum_denom_cases_on' a $ λ n d h,\nby change (1:ℚ) with 1 /. 1; simp [h]\n\nprotected theorem one_mul : 1 * a = a :=\nnum_denom_cases_on' a $ λ n d h,\nby change (1:ℚ) with 1 /. 1; simp [h]\n\nprotected theorem mul_comm : a * b = b * a :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nby simp [h₁, h₂, mul_comm]\n\nprotected theorem mul_assoc : a * b * c = a * (b * c) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nnum_denom_cases_on' c $ λ n₃ d₃ h₃,\nby simp [h₁, h₂, h₃, mul_ne_zero, mul_comm, mul_left_comm]\n\nprotected theorem add_mul : (a + b) * c = a * c + b * c :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nnum_denom_cases_on' c $ λ n₃ d₃ h₃,\nby simp [h₁, h₂, h₃, mul_ne_zero];\n   refine (div_mk_div_cancel_left (int.coe_nat_ne_zero.2 h₃)).symm.trans _;\n   simp [mul_add, mul_comm, mul_assoc, mul_left_comm]\n\nprotected theorem mul_add : a * (b + c) = a * b + a * c :=\nby rw [rat.mul_comm, rat.add_mul, rat.mul_comm, rat.mul_comm c a]\n\nprotected theorem zero_ne_one : 0 ≠ (1:ℚ) :=\nmt (λ (h : 0 = 1 /. 1), (mk_eq_zero one_ne_zero).1 h.symm) one_ne_zero\n\nprotected theorem mul_inv_cancel : a ≠ 0 → a * a⁻¹ = 1 :=\nnum_denom_cases_on' a $ λ n d h a0,\nhave n0 : n ≠ 0, from mt (by intro e; subst e; simp) a0,\nby simp [h, n0, mul_comm]; exact\neq.trans (by simp) (@div_mk_div_cancel_left 1 1 _ n0)\n\nprotected theorem inv_mul_cancel (h : a ≠ 0) : a⁻¹ * a = 1 :=\neq.trans (rat.mul_comm _ _) (rat.mul_inv_cancel _ h)\n\ninstance : decidable_eq ℚ := by tactic.mk_dec_eq_instance\n\ninstance : discrete_field ℚ :=\n{ zero             := 0,\n  add              := rat.add,\n  neg              := rat.neg,\n  one              := 1,\n  mul              := rat.mul,\n  inv              := rat.inv,\n  zero_add         := rat.zero_add,\n  add_zero         := rat.add_zero,\n  add_comm         := rat.add_comm,\n  add_assoc        := rat.add_assoc,\n  add_left_neg     := rat.add_left_neg,\n  mul_one          := rat.mul_one,\n  one_mul          := rat.one_mul,\n  mul_comm         := rat.mul_comm,\n  mul_assoc        := rat.mul_assoc,\n  left_distrib     := rat.mul_add,\n  right_distrib    := rat.add_mul,\n  zero_ne_one      := rat.zero_ne_one,\n  mul_inv_cancel   := rat.mul_inv_cancel,\n  inv_mul_cancel   := rat.inv_mul_cancel,\n  has_decidable_eq := rat.decidable_eq,\n  inv_zero         := rfl }\n\n/- Extra instances to short-circuit type class resolution -/\ninstance : field ℚ              := by apply_instance\ninstance : division_ring ℚ      := by apply_instance\ninstance : integral_domain ℚ    := by apply_instance\n-- TODO(Mario): this instance slows down data.real.basic\n--instance : domain ℚ           := by apply_instance\ninstance : nonzero_comm_ring ℚ  := by apply_instance\ninstance : comm_ring ℚ          := by apply_instance\n--instance : ring ℚ             := by apply_instance\ninstance : comm_semiring ℚ      := by apply_instance\ninstance : semiring ℚ           := by apply_instance\ninstance : add_comm_group ℚ     := by apply_instance\ninstance : add_group ℚ          := by apply_instance\ninstance : add_comm_monoid ℚ    := by apply_instance\ninstance : add_monoid ℚ         := by apply_instance\ninstance : add_left_cancel_semigroup ℚ := by apply_instance\ninstance : add_right_cancel_semigroup ℚ := by apply_instance\ninstance : add_comm_semigroup ℚ := by apply_instance\ninstance : add_semigroup ℚ      := by apply_instance\ninstance : comm_monoid ℚ        := by apply_instance\ninstance : monoid ℚ             := by apply_instance\ninstance : comm_semigroup ℚ     := by apply_instance\ninstance : semigroup ℚ          := by apply_instance\n\ntheorem sub_def {a b c d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n  a /. b - c /. d = (a * d - c * b) /. (b * d) :=\nby simp [b0, d0]\n\nprotected def nonneg : ℚ → Prop\n| ⟨n, d, h, c⟩ := n ≥ 0\n\n@[simp] theorem mk_nonneg (a : ℤ) {b : ℤ} (h : b > 0) : (a /. b).nonneg ↔ a ≥ 0 :=\nbegin\n  generalize ha : a /. b = x, cases x with n₁ d₁ h₁ c₁, rw num_denom' at ha,\n  simp [rat.nonneg],\n  have d0 := int.coe_nat_lt.2 h₁,\n  have := (mk_eq (ne_of_gt h) (ne_of_gt d0)).1 ha,\n  constructor; intro h₂,\n  { apply nonneg_of_mul_nonneg_right _ d0,\n    rw this, exact mul_nonneg h₂ (le_of_lt h) },\n  { apply nonneg_of_mul_nonneg_right _ h,\n    rw ← this, exact mul_nonneg h₂ (int.coe_zero_le _) },\nend\n\nprotected def nonneg_add {a b} : rat.nonneg a → rat.nonneg b → rat.nonneg (a + b) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nbegin\n  have d₁0 : (d₁:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₁),\n  have d₂0 : (d₂:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₂),\n  simp [d₁0, d₂0, h₁, h₂, mul_pos d₁0 d₂0],\n  intros n₁0 n₂0,\n  apply add_nonneg; apply mul_nonneg; {assumption <|> apply int.coe_zero_le}\nend\n\nprotected def nonneg_mul {a b} : rat.nonneg a → rat.nonneg b → rat.nonneg (a * b) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nbegin\n  have d₁0 : (d₁:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₁),\n  have d₂0 : (d₂:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₂),\n  simp [d₁0, d₂0, h₁, h₂, mul_pos d₁0 d₂0],\n  exact mul_nonneg\nend\n\nprotected def nonneg_antisymm {a} : rat.nonneg a → rat.nonneg (-a) → a = 0 :=\nnum_denom_cases_on' a $ λ n d h,\nbegin\n  have d0 : (d:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h),\n  simp [d0, h],\n  exact λ h₁ h₂, le_antisymm (nonpos_of_neg_nonneg h₂) h₁\nend\n\nprotected def nonneg_total : rat.nonneg a ∨ rat.nonneg (-a) :=\nby cases a with n; exact\nor.imp_right neg_nonneg_of_nonpos (le_total 0 n)\n\ninstance decidable_nonneg : decidable (rat.nonneg a) :=\nby cases a; unfold rat.nonneg; apply_instance\n\nprotected def le (a b : ℚ) := rat.nonneg (b - a)\n\ninstance : has_le ℚ := ⟨rat.le⟩\n\ninstance decidable_le : decidable_rel ((≤) : ℚ → ℚ → Prop)\n| a b := show decidable (rat.nonneg (b - a)), by apply_instance\n\nprotected theorem le_def {a b c d : ℤ} (b0 : b > 0) (d0 : d > 0) :\n  a /. b ≤ c /. d ↔ a * d ≤ c * b :=\nshow rat.nonneg _ ↔ _,\nby simpa [ne_of_gt b0, ne_of_gt d0, mul_pos b0 d0, mul_comm]\n   using @sub_nonneg _ _ (b * c) (a * d)\n\nprotected theorem le_refl : a ≤ a :=\nshow rat.nonneg (a - a), by rw sub_self; exact le_refl (0 : ℤ)\n\nprotected theorem le_total : a ≤ b ∨ b ≤ a :=\nby have := rat.nonneg_total (b - a); rwa neg_sub at this\n\nprotected theorem le_antisymm {a b : ℚ} (hab : a ≤ b) (hba : b ≤ a) : a = b :=\nby have := eq_neg_of_add_eq_zero (rat.nonneg_antisymm hba $ by simpa);\n   rwa neg_neg at this\n\nprotected theorem le_trans {a b c : ℚ} (hab : a ≤ b) (hbc : b ≤ c) : a ≤ c :=\nhave rat.nonneg (b - a + (c - b)), from rat.nonneg_add hab hbc,\nhave rat.nonneg (c - a + (b - b)), by simpa [-add_right_neg, add_left_comm],\nby simpa\n\ninstance : decidable_linear_order ℚ :=\n{ le              := rat.le,\n  le_refl         := rat.le_refl,\n  le_trans        := @rat.le_trans,\n  le_antisymm     := @rat.le_antisymm,\n  le_total        := rat.le_total,\n  decidable_eq    := by apply_instance,\n  decidable_le    := assume a b, rat.decidable_nonneg (b - a) }\n\n/- Extra instances to short-circuit type class resolution -/\ninstance : has_lt ℚ                  := by apply_instance\ninstance : lattice.distrib_lattice ℚ := by apply_instance\ninstance : lattice.lattice ℚ         := by apply_instance\ninstance : lattice.semilattice_inf ℚ := by apply_instance\ninstance : lattice.semilattice_sup ℚ := by apply_instance\ninstance : lattice.has_inf ℚ         := by apply_instance\ninstance : lattice.has_sup ℚ         := by apply_instance\ninstance : linear_order ℚ            := by apply_instance\ninstance : partial_order ℚ           := by apply_instance\ninstance : preorder ℚ                := by apply_instance\n\ntheorem nonneg_iff_zero_le {a} : rat.nonneg a ↔ 0 ≤ a :=\nshow rat.nonneg a ↔ rat.nonneg (a - 0), by simp\n\ntheorem num_nonneg_iff_zero_le : ∀ {a : ℚ}, 0 ≤ a.num ↔ 0 ≤ a\n| ⟨n, d, h, c⟩ := @nonneg_iff_zero_le ⟨n, d, h, c⟩\n\ntheorem mk_le {a b c d : ℤ} (h₁ : b > 0) (h₂ : d > 0) :\n  a /. b ≤ c /. d ↔ a * d ≤ c * b :=\nby conv in (_ ≤ _) {\n  simp only [(≤), rat.le],\n  rw [sub_def (ne_of_gt h₂) (ne_of_gt h₁),\n      mk_nonneg _ (mul_pos h₂ h₁), ge, sub_nonneg] }\n\nprotected theorem add_le_add_left {a b c : ℚ} : c + a ≤ c + b ↔ a ≤ b :=\nby unfold has_le.le rat.le; rw add_sub_add_left_eq_sub\n\nprotected theorem mul_nonneg {a b : ℚ} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a * b :=\nby rw ← nonneg_iff_zero_le at ha hb ⊢; exact rat.nonneg_mul ha hb\n\ninstance : discrete_linear_ordered_field ℚ :=\n{ zero_lt_one     := dec_trivial,\n  add_le_add_left := assume a b ab c, rat.add_le_add_left.2 ab,\n  add_lt_add_left := assume a b ab c, lt_of_not_ge $ λ ba,\n    not_le_of_lt ab $ rat.add_le_add_left.1 ba,\n  mul_nonneg      := @rat.mul_nonneg,\n  mul_pos         := assume a b ha hb, lt_of_le_of_ne\n    (rat.mul_nonneg (le_of_lt ha) (le_of_lt hb))\n    (mul_ne_zero (ne_of_lt ha).symm (ne_of_lt hb).symm).symm,\n  ..rat.discrete_field, ..rat.decidable_linear_order }\n\n/- Extra instances to short-circuit type class resolution -/\ninstance : linear_ordered_field ℚ                := by apply_instance\ninstance : decidable_linear_ordered_comm_ring ℚ  := by apply_instance\ninstance : linear_ordered_comm_ring ℚ            := by apply_instance\ninstance : linear_ordered_ring ℚ                 := by apply_instance\ninstance : ordered_ring ℚ                        := by apply_instance\ninstance : decidable_linear_ordered_semiring ℚ   := by apply_instance\ninstance : linear_ordered_semiring ℚ             := by apply_instance\ninstance : ordered_semiring ℚ                    := by apply_instance\ninstance : decidable_linear_ordered_comm_group ℚ := by apply_instance\ninstance : ordered_comm_group ℚ                  := by apply_instance\ninstance : ordered_cancel_comm_monoid ℚ          := by apply_instance\ninstance : ordered_comm_monoid ℚ                 := by apply_instance\n\ntheorem num_pos_iff_pos {a : ℚ} : 0 < a.num ↔ 0 < a :=\nle_iff_le_iff_lt_iff_lt.1 $\nby simpa [(by cases a; refl : (-a).num = -a.num)]\n   using @num_nonneg_iff_zero_le (-a)\n\ntheorem of_int_eq_mk (z : ℤ) : of_int z = z /. 1 := num_denom' _ _ _ _\n\ntheorem coe_int_eq_mk : ∀ z : ℤ, ↑z = z /. 1\n| (n : ℕ) := show (n:ℚ) = n /. 1,\n  by induction n with n IH n; simp [*, show (1:ℚ) = 1 /. 1, from rfl]\n| -[1+ n] := show (-(n + 1) : ℚ) = -[1+ n] /. 1, begin\n  induction n with n IH, {refl},\n  show -(n + 1 + 1 : ℚ) = -[1+ n.succ] /. 1,\n  rw [neg_add, IH],\n  simpa [show -1 = (-1) /. 1, from rfl]\nend\n\ntheorem coe_int_eq_of_int (z : ℤ) : ↑z = of_int z :=\n(coe_int_eq_mk z).trans (of_int_eq_mk z).symm\n\ntheorem mk_eq_div (n d : ℤ) : n /. d = (n / d : ℚ) :=\nbegin\n  by_cases d0 : d = 0, {simp [d0, div_zero]},\n  rw [division_def, coe_int_eq_mk, coe_int_eq_mk, inv_def,\n      mul_def one_ne_zero d0, one_mul, mul_one]\nend\n\n/-- `floor q` is the largest integer `z` such that `z ≤ q` -/\ndef floor : ℚ → ℤ\n| ⟨n, d, h, c⟩ := n / d\n\ntheorem le_floor {z : ℤ} : ∀ {r : ℚ}, z ≤ floor r ↔ (z : ℚ) ≤ r\n| ⟨n, d, h, c⟩ := begin\n  simp [floor],\n  rw [num_denom'],\n  have h' := int.coe_nat_lt.2 h,\n  conv { to_rhs,\n    rw [coe_int_eq_mk, mk_le zero_lt_one h', mul_one] },\n  exact int.le_div_iff_mul_le h'\nend\n\ntheorem floor_lt {r : ℚ} {z : ℤ} : floor r < z ↔ r < z :=\nle_iff_le_iff_lt_iff_lt.1 le_floor\n\ntheorem floor_le (r : ℚ) : (floor r : ℚ) ≤ r :=\nle_floor.1 (le_refl _)\n\ntheorem lt_succ_floor (r : ℚ) : r < (floor r).succ :=\nfloor_lt.1 $ int.lt_succ_self _\n\n@[simp] theorem floor_coe (z : ℤ) : floor z = z :=\neq_of_forall_le_iff $ λ a, by rw [le_floor, int.cast_le]\n\ntheorem floor_mono {a b : ℚ} (h : a ≤ b) : floor a ≤ floor b :=\nle_floor.2 (le_trans (floor_le _) h)\n\n@[simp] theorem floor_add_int (r : ℚ) (z : ℤ) : floor (r + z) = floor r + z :=\neq_of_forall_le_iff $ λ a, by rw [le_floor,\n  ← sub_le_iff_le_add, ← sub_le_iff_le_add, le_floor, int.cast_sub]\n\ntheorem floor_sub_int (r : ℚ) (z : ℤ) : floor (r - z) = floor r - z :=\neq.trans (by rw [int.cast_neg]; refl) (floor_add_int _ _)\n\n/-- `ceil q` is the smallest integer `z` such that `q ≤ z` -/\ndef ceil (r : ℚ) : ℤ :=\n-(floor (-r))\n\ntheorem ceil_le {z : ℤ} {r : ℚ} : ceil r ≤ z ↔ r ≤ z :=\nby rw [ceil, neg_le, le_floor, int.cast_neg, neg_le_neg_iff]\n\ntheorem le_ceil (r : ℚ) : r ≤ ceil r :=\nceil_le.1 (le_refl _)\n\n@[simp] theorem ceil_coe (z : ℤ) : ceil z = z :=\nby rw [ceil, ← int.cast_neg, floor_coe, neg_neg]\n\ntheorem ceil_mono {a b : ℚ} (h : a ≤ b) : ceil a ≤ ceil b :=\nceil_le.2 (le_trans h (le_ceil _))\n\n@[simp] theorem ceil_add_int (r : ℚ) (z : ℤ) : ceil (r + z) = ceil r + z :=\nby rw [ceil, neg_add', floor_sub_int, neg_sub, sub_eq_neg_add]; refl\n\ntheorem ceil_sub_int (r : ℚ) (z : ℤ) : ceil (r - z) = ceil r - z :=\neq.trans (by rw [int.cast_neg]; refl) (ceil_add_int _ _)\n\n/- cast (injection into fields) -/\n\nsection cast\nvariables {α : Type*}\n\nsection\nvariables [division_ring α]\n\n/-- Construct the canonical injection from `ℚ` into an arbitrary\n  division ring. If the field has positive characteristic `p`,\n  we define `1 / p = 1 / 0 = 0` for consistency with our\n  division by zero convention. -/\nprotected def cast : ℚ → α\n| ⟨n, d, h, c⟩ := n / d\n\n@[priority 0] instance cast_coe : has_coe ℚ α := ⟨rat.cast⟩\n\n@[simp] theorem cast_of_int (n : ℤ) : (of_int n : α) = n :=\nshow (n / (1:ℕ) : α) = n, by rw [nat.cast_one, div_one]\n\n@[simp] theorem cast_coe_int (n : ℤ) : ((n : ℚ) : α) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp] theorem coe_int_num (n : ℤ) : (n : ℚ).num = n :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_int_denom (n : ℤ) : (n : ℚ).denom = 1 :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_nat_num (n : ℕ) : (n : ℚ).num = n :=\nby rw [← int.cast_coe_nat, coe_int_num]\n\n@[simp] theorem coe_nat_denom (n : ℕ) : (n : ℚ).denom = 1 :=\nby rw [← int.cast_coe_nat, coe_int_denom]\n\n@[simp] theorem cast_coe_nat (n : ℕ) : ((n : ℚ) : α) = n := cast_coe_int n\n\n@[simp] theorem cast_zero : ((0 : ℚ) : α) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp] theorem cast_one : ((1 : ℚ) : α) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem mul_cast_comm (a : α) :\n  ∀ (n : ℚ), (n.denom : α) ≠ 0 → a * n = n * a\n| ⟨n, d, h, c⟩ h₂ := show a * (n * d⁻¹) = n * d⁻¹ * a,\n  by rw [← mul_assoc, int.mul_cast_comm, mul_assoc, mul_assoc,\n         ← show (d:α)⁻¹ * a = a * d⁻¹, from\n           division_ring.inv_comm_of_comm h₂ (int.mul_cast_comm a d).symm]\n\ntheorem cast_mk_of_ne_zero (a b : ℤ)\n  (b0 : (b:α) ≠ 0) : (a /. b : α) = a / b :=\nbegin\n  have b0' : b ≠ 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:α) ≠ 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:ℤ) ∣ b, by rwa e at dd) with k ke,\n    have : (b:α) = (d:α) * (k:α), {rw [ke, int.cast_mul], refl},\n    rw [d0, zero_mul] at this, contradiction },\n  rw [num_denom'] at e,\n  have := congr_arg (coe : ℤ → α) ((mk_eq b0' $ ne_of_gt $ int.coe_nat_pos.2 h).1 e),\n  rw [int.cast_mul, int.cast_mul, int.cast_coe_nat] at this,\n  symmetry, change (a * b⁻¹ : α) = n / d,\n  rw [eq_div_iff_mul_eq _ _ d0, mul_assoc, nat.mul_cast_comm,\n      ← mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\ntheorem cast_add_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m + n : ℚ) : α) = m + n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', add_def d₁0' d₂0'],\n  suffices : (n₁ * (d₂ * (d₂⁻¹ * d₁⁻¹)) +\n    n₂ * (d₁ * d₂⁻¹) * d₁⁻¹ : α) = n₁ * d₁⁻¹ + n₂ * d₂⁻¹,\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, left_distrib, right_distrib, mul_inv_eq,\n             d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0]} },\n  rw [← mul_assoc (d₂:α), mul_inv_cancel d₂0, one_mul,\n      ← nat.mul_cast_comm], simp [d₁0, mul_assoc]\nend\n\n@[simp] theorem cast_neg : ∀ n, ((-n : ℚ) : α) = -n\n| ⟨n, d, h, c⟩ := show (↑-n * d⁻¹ : α) = -(n * d⁻¹),\n  by rw [int.cast_neg, neg_mul_eq_neg_mul]\n\ntheorem cast_sub_of_ne_zero {m n : ℚ}\n  (m0 : (m.denom : α) ≠ 0) (n0 : (n.denom : α) ≠ 0) : ((m - n : ℚ) : α) = m - n :=\nhave ((-n).denom : α) ≠ 0, by cases n; exact n0,\nby simp [m0, this, cast_add_of_ne_zero]\n\ntheorem cast_mul_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m * n : ℚ) : α) = m * n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', mul_def d₁0' d₂0'],\n  suffices : (n₁ * ((n₂ * d₂⁻¹) * d₁⁻¹) : α) = n₁ * (d₁⁻¹ * (n₂ * d₂⁻¹)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_eq, d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0]} },\n  rw [division_ring.inv_comm_of_comm d₁0 (nat.mul_cast_comm _ _).symm]\nend\n\ntheorem cast_inv_of_ne_zero : ∀ {n : ℚ},\n  (n.num : α) ≠ 0 → (n.denom : α) ≠ 0 → ((n⁻¹ : ℚ) : α) = n⁻¹\n| ⟨n, d, h, c⟩ := λ (n0 : (n:α) ≠ 0) (d0 : (d:α) ≠ 0), begin\n  have n0' : (n:ℤ) ≠ 0 := λ e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d0; exact d0 rfl),\n  rw [num_denom', inv_def],\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, inv_div];\n  simp [n0, d0]\nend\n\ntheorem cast_div_of_ne_zero {m n : ℚ} (md : (m.denom : α) ≠ 0)\n  (nn : (n.num : α) ≠ 0) (nd : (n.denom : α) ≠ 0) : ((m / n : ℚ) : α) = m / n :=\nhave (n⁻¹.denom : ℤ) ∣ n.num,\nby conv in n⁻¹.denom { rw [num_denom n, inv_def] };\n   apply denom_dvd,\nhave (n⁻¹.denom : α) = 0 → (n.num : α) = 0, from\nλ h, let ⟨k, e⟩ := this in\n  by have := congr_arg (coe : ℤ → α) e;\n     rwa [int.cast_mul, int.cast_coe_nat, h, zero_mul] at this,\nby rw [division_def, cast_mul_of_ne_zero md (mt this nn), cast_inv_of_ne_zero nn nd, division_def]\n\n@[simp] theorem cast_inj [char_zero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := begin\n  refine ⟨λ h, _, congr_arg _⟩,\n  have d₁0 : d₁ ≠ 0 := ne_of_gt h₁,\n  have d₂0 : d₂ ≠ 0 := ne_of_gt h₂,\n  have d₁a : (d₁:α) ≠ 0 := nat.cast_ne_zero.2 d₁0,\n  have d₂a : (d₂:α) ≠ 0 := nat.cast_ne_zero.2 d₂0,\n  rw [num_denom', num_denom'] at h ⊢,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d₁0, d₂0] at h ⊢,\n  rwa [eq_div_iff_mul_eq _ _ d₂a, division_def, mul_assoc,\n    division_ring.inv_comm_of_comm d₁a (nat.mul_cast_comm _ _),\n    ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq _ _ d₁a, eq_comm,\n    ← int.cast_coe_nat, ← int.cast_mul, ← int.cast_coe_nat, ← int.cast_mul,\n    int.cast_inj, ← mk_eq (int.coe_nat_ne_zero.2 d₁0) (int.coe_nat_ne_zero.2 d₂0)] at h\nend\n\ntheorem cast_injective [char_zero α] : function.injective (coe : ℚ → α)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 :=\nby rw [← cast_zero, cast_inj]\n\n@[simp] theorem cast_ne_zero [char_zero α] {n : ℚ} : (n : α) ≠ 0 ↔ n ≠ 0 :=\nnot_congr cast_eq_zero\n\ntheorem eq_cast_of_ne_zero (f : ℚ → α) (H1 : f 1 = 1)\n  (Hadd : ∀ x y, f (x + y) = f x + f y)\n  (Hmul : ∀ x y, f (x * y) = f x * f y) :\n  ∀ n : ℚ, (n.denom : α) ≠ 0 → f n = n\n| ⟨n, d, h, c⟩ := λ (h₂ : ((d:ℤ):α) ≠ 0), show _ = (n / (d:ℤ) : α), begin\n  rw [num_denom', mk_eq_div, eq_div_iff_mul_eq _ _ h₂],\n  have : ∀ n : ℤ, f n = n, { apply int.eq_cast; simp [H1, Hadd] },\n  rw [← this, ← this, ← Hmul, div_mul_cancel],\n  exact int.cast_ne_zero.2 (int.coe_nat_ne_zero.2 $ ne_of_gt h),\nend\n\ntheorem eq_cast [char_zero α] (f : ℚ → α) (H1 : f 1 = 1)\n  (Hadd : ∀ x y, f (x + y) = f x + f y)\n  (Hmul : ∀ x y, f (x * y) = f x * f y) (n : ℚ) : f n = n :=\neq_cast_of_ne_zero _ H1 Hadd Hmul _ $\n  nat.cast_ne_zero.2 $ ne_of_gt n.pos\n\nend\n\ntheorem cast_mk [discrete_field α] [char_zero α] (a b : ℤ) : ((a /. b) : α) = a / b :=\nif b0 : b = 0 then by simp [b0, div_zero]\nelse cast_mk_of_ne_zero a b (int.cast_ne_zero.2 b0)\n\n@[simp] theorem cast_add [division_ring α] [char_zero α] (m n) : ((m + n : ℚ) : α) = m + n :=\ncast_add_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_sub [division_ring α] [char_zero α] (m n) : ((m - n : ℚ) : α) = m - n :=\ncast_sub_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_mul [division_ring α] [char_zero α] (m n) : ((m * n : ℚ) : α) = m * n :=\ncast_mul_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_inv [discrete_field α] [char_zero α] (n) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nif n0 : n.num = 0 then\n  by simp [show n = 0, by rw [num_denom n, n0]; simp, inv_zero] else\ncast_inv_of_ne_zero (int.cast_ne_zero.2 n0) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_div [discrete_field α] [char_zero α] (m n) : ((m / n : ℚ) : α) = m / n :=\nby rw [division_def, cast_mul, cast_inv, division_def]\n\n@[simp] theorem cast_bit0 [division_ring α] [char_zero α] (n : ℚ) : ((bit0 n : ℚ) : α) = bit0 n := cast_add _ _\n\n@[simp] theorem cast_bit1 [division_ring α] [char_zero α] (n : ℚ) : ((bit1 n : ℚ) : α) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\n@[simp] theorem cast_nonneg [linear_ordered_field α] : ∀ {n : ℚ}, 0 ≤ (n : α) ↔ 0 ≤ n\n| ⟨n, d, h, c⟩ := show 0 ≤ (n * d⁻¹ : α) ↔ 0 ≤ (⟨n, d, h, c⟩ : ℚ),\n  by rw [num_denom', ← nonneg_iff_zero_le, mk_nonneg _ (int.coe_nat_pos.2 h),\n    mul_nonneg_iff_right_nonneg_of_pos (@inv_pos α _ _ (nat.cast_pos.2 h)),\n    int.cast_nonneg]\n\n@[simp] theorem cast_le [linear_ordered_field α] {m n : ℚ} : (m : α) ≤ n ↔ m ≤ n :=\nby rw [← sub_nonneg, ← cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp] theorem cast_lt [linear_ordered_field α] {m n : ℚ} : (m : α) < n ↔ m < n :=\nby simpa [-cast_le] using not_congr (@cast_le α _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field α] {n : ℚ} : (n : α) ≤ 0 ↔ n ≤ 0 :=\nby rw [← cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field α] {n : ℚ} : (0 : α) < n ↔ 0 < n :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field α] {n : ℚ} : (n : α) < 0 ↔ n < 0 :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_id : ∀ n : ℚ, ↑n = n\n| ⟨n, d, h, c⟩ := show (n / (d : ℤ) : ℚ) = _, by rw [num_denom', mk_eq_div]\n\n@[simp] theorem cast_min [discrete_linear_ordered_field α] {a b : ℚ} : (↑(min a b) : α) = min a b :=\nby by_cases a ≤ b; simp [h, min]\n\n@[simp] theorem cast_max [discrete_linear_ordered_field α] {a b : ℚ} : (↑(max a b) : α) = max a b :=\nby by_cases a ≤ b; simp [h, max]\n\n@[simp] theorem cast_abs [discrete_linear_ordered_field α] {q : ℚ} : ((abs q : ℚ) : α) = abs q :=\nby simp [abs]\n\nend cast\n\n/- nat ceiling -/\n\n/-- `nat_ceil q` is the smallest nonnegative integer `n` with `q ≤ n`.\n  It is the same as `ceil q` when `q ≥ 0`, otherwise it is `0`. -/\ndef nat_ceil (q : ℚ) : ℕ := int.to_nat (ceil q)\n\ntheorem nat_ceil_le {q : ℚ} {n : ℕ} : nat_ceil q ≤ n ↔ q ≤ n :=\nby rw [nat_ceil, int.to_nat_le, ceil_le]; refl\n\ntheorem lt_nat_ceil {q : ℚ} {n : ℕ} : n < nat_ceil q ↔ (n : ℚ) < q :=\nnot_iff_not.1 $ by rw [not_lt, not_lt, nat_ceil_le]\n\ntheorem le_nat_ceil (q : ℚ) : q ≤ nat_ceil q :=\nnat_ceil_le.1 (le_refl _)\n\ntheorem nat_ceil_mono {q₁ q₂ : ℚ} (h : q₁ ≤ q₂) : nat_ceil q₁ ≤ nat_ceil q₂ :=\nnat_ceil_le.2 (le_trans h (le_nat_ceil _))\n\n@[simp] theorem nat_ceil_coe (n : ℕ) : nat_ceil n = n :=\nshow (ceil (n:ℤ)).to_nat = n, by rw [ceil_coe]; refl\n\n@[simp] theorem nat_ceil_zero : nat_ceil 0 = 0 := nat_ceil_coe 0\n\ntheorem nat_ceil_add_nat {q : ℚ} (hq : 0 ≤ q) (n : ℕ) : nat_ceil (q + n) = nat_ceil q + n :=\nshow int.to_nat (ceil (q + (n:ℤ))) = int.to_nat (ceil q) + n,\nby rw [ceil_add_int]; exact\nmatch ceil q, int.eq_coe_of_zero_le (ceil_mono hq) with\n| _, ⟨m, rfl⟩ := rfl\nend\n\ntheorem nat_ceil_lt_add_one {q : ℚ} (hq : q ≥ 0) : ↑(nat_ceil q) < q + 1 :=\nlt_nat_ceil.1 $ by rw [\n  show nat_ceil (q+1) = nat_ceil q+1, from nat_ceil_add_nat hq 1]; apply nat.lt_succ_self\n\n@[simp] lemma denom_neg_eq_denom : ∀ q : ℚ, (-q).denom = q.denom\n| ⟨_, d, _, _⟩ := rfl\n\n@[simp] lemma num_neg_eq_neg_num : ∀ q : ℚ, (-q).num = -(q.num)\n| ⟨n, _, _, _⟩ := rfl\n\n@[simp] lemma num_zero : rat.num 0 = 0 := rfl\n\nlemma zero_of_num_zero {q : ℚ} (hq : q.num = 0) : q = 0 :=\nhave q = q.num /. q.denom, from num_denom _,\nby simpa [hq]\n\nlemma num_ne_zero_of_ne_zero {q : ℚ} (h : q ≠ 0) : q.num ≠ 0 :=\nassume : q.num = 0,\nh $ zero_of_num_zero this\n\nlemma denom_ne_zero (q : ℚ) : q.denom ≠ 0 :=\nne_of_gt q.pos\n\nlemma mk_num_ne_zero_of_ne_zero {q : ℚ} {n d : ℤ} (hq : q ≠ 0) (hqnd : q = n /. d) : n ≠ 0 :=\nassume : n = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_denom_ne_zero_of_ne_zero {q : ℚ} {n d : ℤ} (hq : q ≠ 0) (hqnd : q = n /. d) : d ≠ 0 :=\nassume : d = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_ne_zero_of_ne_zero {n d : ℤ} (h : n ≠ 0) (hd : d ≠ 0) : n /. d ≠ 0 :=\nassume : n /. d = 0,\nh $ (mk_eq_zero hd).1 this\n\nlemma mul_num_denom (q r : ℚ) : q * r = (q.num * r.num) /. ↑(q.denom * r.denom) :=\nhave hq' : (↑q.denom : ℤ) ≠ 0, by have := denom_ne_zero q; simpa,\nhave hr' : (↑r.denom : ℤ) ≠ 0, by have := denom_ne_zero r; simpa,\nsuffices (q.num /. ↑q.denom) * (r.num /. ↑r.denom) = (q.num * r.num) /. ↑(q.denom * r.denom),\n  by rwa [←num_denom q, ←num_denom r] at this,\nby simp [mul_def hq' hr']\n\nlemma num_denom_mk {q : ℚ} {n d : ℤ} (hn : n ≠ 0) (hd : d ≠ 0) (qdf : q = n /. d) :\n      ∃ c : ℤ, n = c * q.num ∧ d = c * q.denom :=\nhave hq : q ≠ 0, from\n  assume : q = 0,\n  hn $ (rat.mk_eq_zero hd).1 (by cc),\nhave q.num /. q.denom = n /. d, by rwa [←rat.num_denom q],\nhave q.num * d = n * ↑(q.denom), from (rat.mk_eq (by simp [rat.denom_ne_zero]) hd).1 this,\nbegin\n  existsi n / q.num,\n  have hqdn : q.num ∣ n, begin rw qdf, apply rat.num_dvd, assumption end,\n  split,\n    { rw int.div_mul_cancel hqdn },\n    { apply int.eq_mul_div_of_mul_eq_mul_of_dvd_left,\n      {apply rat.num_ne_zero_of_ne_zero hq},\n      {simp [rat.denom_ne_zero]},\n      repeat {assumption} }\nend\nend rat\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/data/rat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4996554100061157}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.set.lattice\n\n/-! # Semiquotients\n\nA data type for semiquotients, which are classically equivalent to\nnonempty sets, but are useful for programming; the idea is that\na semiquotient set `S` represents some (particular but unknown)\nelement of `S`. This can be used to model nondeterministic functions,\nwhich return something in a range of values (represented by the\npredicate `S`) but are not completely determined.\n-/\n\n/-- A member of `semiquot α` is classically a nonempty `set α`,\n  and in the VM is represented by an element of `α`; the relation\n  between these is that the VM element is required to be a member\n  of the set `s`. The specific element of `s` that the VM computes\n  is hidden by a quotient construction, allowing for the representation\n  of nondeterministic functions. -/\nstructure {u} semiquot (α : Type*) := mk' ::\n(s : set α)\n(val : trunc ↥s)\n\nnamespace semiquot\nvariables {α : Type*} {β : Type*}\n\ninstance : has_mem α (semiquot α) := ⟨λ a q, a ∈ q.s⟩\n\n/-- Construct a `semiquot α` from `h : a ∈ s` where `s : set α`. -/\ndef mk {a : α} {s : set α} (h : a ∈ s) : semiquot α :=\n⟨s, trunc.mk ⟨a, h⟩⟩\n\ntheorem ext_s {q₁ q₂ : semiquot α} : q₁ = q₂ ↔ q₁.s = q₂.s :=\nbegin\n  refine ⟨congr_arg _, λ h, _⟩,\n  cases q₁,\n  cases q₂,\n  cc,\nend\n\ntheorem ext {q₁ q₂ : semiquot α} : q₁ = q₂ ↔ ∀ a, a ∈ q₁ ↔ a ∈ q₂ :=\next_s.trans set.ext_iff\n\ntheorem exists_mem (q : semiquot α) : ∃ a, a ∈ q :=\nlet ⟨⟨a, h⟩, h₂⟩ := q.2.exists_rep in ⟨a, h⟩\n\ntheorem eq_mk_of_mem {q : semiquot α} {a : α} (h : a ∈ q) :\n  q = @mk _ a q.1 h := ext_s.2 rfl\n\ntheorem nonempty (q : semiquot α) : q.s.nonempty := q.exists_mem\n\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure (a : α) : semiquot α := mk (set.mem_singleton a)\n\n@[simp] theorem mem_pure' {a b : α} : a ∈ semiquot.pure b ↔ a = b :=\nset.mem_singleton_iff\n\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' (q : semiquot α) {s : set α} (h : q.s ⊆ s) : semiquot α :=\n⟨s, trunc.lift (λ a : q.s, trunc.mk ⟨a.1, h a.2⟩)\n  (λ _ _, trunc.eq _ _) q.2⟩\n\n/-- Replace `s` in a `q : semiquot α` with a union `s ∪ q.s` -/\ndef blur (s : set α) (q : semiquot α) : semiquot α :=\nblur' q (set.subset_union_right s q.s)\n\ntheorem blur_eq_blur' (q : semiquot α) (s : set α) (h : q.s ⊆ s) :\n  blur s q = blur' q h :=\nby unfold blur; congr; exact set.union_eq_self_of_subset_right h\n\n@[simp] theorem mem_blur' (q : semiquot α) {s : set α} (h : q.s ⊆ s)\n  {a : α} : a ∈ blur' q h ↔ a ∈ s := iff.rfl\n\n/-- Convert a `trunc α` to a `semiquot α`. -/\ndef of_trunc (q : trunc α) : semiquot α :=\n⟨set.univ, q.map (λ a, ⟨a, trivial⟩)⟩\n\n/-- Convert a `semiquot α` to a `trunc α`. -/\ndef to_trunc (q : semiquot α) : trunc α :=\nq.2.map subtype.val\n\n/-- If `f` is a constant on `q.s`, then `q.lift_on f` is the value of `f`\nat any point of `q`. -/\ndef lift_on (q : semiquot α) (f : α → β) (h : ∀ a b ∈ q, f a = f b) : β :=\ntrunc.lift_on q.2 (λ x, f x.1) (λ x y, h _ x.2 _ y.2)\n\ntheorem lift_on_of_mem (q : semiquot α)\n  (f : α → β) (h : ∀ a b ∈ q, f a = f b)\n  (a : α) (aq : a ∈ q) : lift_on q f h = f a :=\nby revert h; rw eq_mk_of_mem aq; intro; refl\n\n/-- Apply a function to the unknown value stored in a `semiquot α`. -/\ndef map (f : α → β) (q : semiquot α) : semiquot β :=\n⟨f '' q.1, q.2.map (λ x, ⟨f x.1, set.mem_image_of_mem _ x.2⟩)⟩\n\n@[simp] theorem mem_map (f : α → β) (q : semiquot α) (b : β) :\n  b ∈ map f q ↔ ∃ a, a ∈ q ∧ f a = b := set.mem_image _ _ _\n\n/-- Apply a function returning a `semiquot` to a `semiquot`. -/\ndef bind (q : semiquot α) (f : α → semiquot β) : semiquot β :=\n⟨⋃ a ∈ q.1, (f a).1,\n q.2.bind (λ a, (f a.1).2.map (λ b, ⟨b.1, set.mem_bUnion a.2 b.2⟩))⟩\n\n@[simp] theorem mem_bind (q : semiquot α) (f : α → semiquot β) (b : β) :\n  b ∈ bind q f ↔ ∃ a ∈ q, b ∈ f a := set.mem_Union₂\n\ninstance : monad semiquot :=\n{ pure := @semiquot.pure,\n  map := @semiquot.map,\n  bind := @semiquot.bind }\n\n@[simp] lemma map_def {β} : ((<$>) : (α → β) → semiquot α → semiquot β) = map := rfl\n@[simp] lemma bind_def {β} : ((>>=) : semiquot α → (α → semiquot β) → semiquot β) = bind := rfl\n\n@[simp] \n\ntheorem mem_pure_self (a : α) : a ∈ (pure a : semiquot α) :=\nset.mem_singleton a\n\n@[simp] theorem pure_inj {a b : α} : (pure a : semiquot α) = pure b ↔ a = b :=\next_s.trans set.singleton_eq_singleton_iff\n\ninstance : is_lawful_monad semiquot :=\n{ pure_bind  := λ α β x f, ext.2 $ by simp,\n  bind_assoc := λ α β γ s f g, ext.2 $ by simp; exact\n    λ c, ⟨λ ⟨b, ⟨a, as, bf⟩, cg⟩, ⟨a, as, b, bf, cg⟩,\n          λ ⟨a, as, b, bf, cg⟩, ⟨b, ⟨a, as, bf⟩, cg⟩⟩,\n  id_map     := λ α q, ext.2 $ by simp,\n  bind_pure_comp_eq_map := λ α β f s, ext.2 $ by simp [eq_comm] }\n\ninstance : has_le (semiquot α) := ⟨λ s t, s.s ⊆ t.s⟩\n\ninstance : partial_order (semiquot α) :=\n{ le := λ s t, ∀ ⦃x⦄, x ∈ s → x ∈ t,\n  le_refl := λ s, set.subset.refl _,\n  le_trans := λ s t u, set.subset.trans,\n  le_antisymm := λ s t h₁ h₂, ext_s.2 (set.subset.antisymm h₁ h₂) }\n\ninstance : semilattice_sup (semiquot α) :=\n{ sup := λ s, blur s.s,\n  le_sup_left := λ s t, set.subset_union_left _ _,\n  le_sup_right := λ s t, set.subset_union_right _ _,\n  sup_le := λ s t u, set.union_subset,\n  ..semiquot.partial_order }\n\n@[simp] theorem pure_le {a : α} {s : semiquot α} : pure a ≤ s ↔ a ∈ s :=\nset.singleton_subset_iff\n\n/-- Assert that a `semiquot` contains only one possible value. -/\ndef is_pure (q : semiquot α) : Prop := ∀ a b ∈ q, a = b\n\n/-- Extract the value from a `is_pure` semiquotient. -/\ndef get (q : semiquot α) (h : q.is_pure) : α := lift_on q id h\n\ntheorem get_mem {q : semiquot α} (p) : get q p ∈ q :=\nlet ⟨a, h⟩ := exists_mem q in\nby unfold get; rw lift_on_of_mem q _ _ a h; exact h\n\ntheorem eq_pure {q : semiquot α} (p) : q = pure (get q p) :=\next.2 $ λ a, by simp; exact\n⟨λ h, p _ h _ (get_mem _), λ e, e.symm ▸ get_mem _⟩\n\n@[simp] theorem pure_is_pure (a : α) : is_pure (pure a)\n| b ab c ac := by { rw [mem_pure] at ab ac, cc }\n\ntheorem is_pure_iff {s : semiquot α} : is_pure s ↔ ∃ a, s = pure a :=\n⟨λ h, ⟨_, eq_pure h⟩, λ ⟨a, e⟩, e.symm ▸ pure_is_pure _⟩\n\ntheorem is_pure.mono {s t : semiquot α}\n  (st : s ≤ t) (h : is_pure t) : is_pure s\n| a as b bs := h _ (st as) _ (st bs)\n\ntheorem is_pure.min {s t : semiquot α} (h : is_pure t) : s ≤ t ↔ s = t :=\n⟨λ st, le_antisymm st $ by rw [eq_pure h, eq_pure (h.mono st)]; simp;\n   exact h _ (get_mem _) _ (st $ get_mem _),\n le_of_eq⟩\n\ntheorem is_pure_of_subsingleton [subsingleton α] (q : semiquot α) : is_pure q\n| a b aq bq := subsingleton.elim _ _\n\n/-- `univ : semiquot α` represents an unspecified element of `univ : set α`. -/\ndef univ [inhabited α] : semiquot α :=\nmk $ set.mem_univ default\n\ninstance [inhabited α] : inhabited (semiquot α) := ⟨univ⟩\n\n@[simp] theorem mem_univ [inhabited α] : ∀ a, a ∈ @univ α _ :=\n@set.mem_univ α\n\n@[congr] theorem univ_unique (I J : inhabited α) : @univ _ I = @univ _ J :=\next.2 $ by simp\n\n@[simp] theorem is_pure_univ [inhabited α] : @is_pure α univ ↔ subsingleton α :=\n⟨λ h, ⟨λ a b, h a trivial b trivial⟩, λ ⟨h⟩ a _ b _, h a b⟩\n\ninstance [inhabited α] : order_top (semiquot α) :=\n{ top := univ,\n  le_top := λ s, set.subset_univ _ }\n\nend semiquot\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/data/semiquot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.4996554002475694}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser, Jujian Zhang\n\n! This file was ported from Lean 3 source module algebra.direct_sum.decomposition\n! leanprover-community/mathlib commit 4e861f25ba5ceef42ba0712d8ffeb32f38ad6441\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.DirectSum.Module\nimport Mathbin.Algebra.Module.Submodule.Basic\n\n/-!\n# Decompositions of additive monoids, groups, and modules into direct sums\n\n## Main definitions\n\n* `direct_sum.decomposition ℳ`: A typeclass to provide a constructive decomposition from\n  an additive monoid `M` into a family of additive submonoids `ℳ`\n* `direct_sum.decompose ℳ`: The canonical equivalence provided by the above typeclass\n\n\n## Main statements\n\n* `direct_sum.decomposition.is_internal`: The link to `direct_sum.is_internal`.\n\n## Implementation details\n\nAs we want to talk about different types of decomposition (additive monoids, modules, rings, ...),\nwe choose to avoid heavily bundling `direct_sum.decompose`, instead making copies for the\n`add_equiv`, `linear_equiv`, etc. This means we have to repeat statements that follow from these\nbundled homs, but means we don't have to repeat statements for different types of decomposition.\n-/\n\n\nvariable {ι R M σ : Type _}\n\nopen DirectSum BigOperators\n\nnamespace DirectSum\n\nsection AddCommMonoid\n\nvariable [DecidableEq ι] [AddCommMonoid M]\n\nvariable [SetLike σ M] [AddSubmonoidClass σ M] (ℳ : ι → σ)\n\n/-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive\nsubmonoids `ℳ i` of that `M`, such that the \"recomposition\" is canonical. This definition also\nworks for additive groups and modules.\n\nThis is a version of `direct_sum.is_internal` which comes with a constructive inverse to the\ncanonical \"recomposition\" rather than just a proof that the \"recomposition\" is bijective. -/\nclass Decomposition where\n  decompose' : M → ⨁ i, ℳ i\n  left_inv : Function.LeftInverse (DirectSum.coeAddMonoidHom ℳ) decompose'\n  right_inv : Function.RightInverse (DirectSum.coeAddMonoidHom ℳ) decompose'\n#align direct_sum.decomposition DirectSum.Decomposition\n\ninclude M\n\n/-- `direct_sum.decomposition` instances, while carrying data, are always equal. -/\ninstance : Subsingleton (Decomposition ℳ) :=\n  ⟨fun x y => by\n    cases' x with x xl xr\n    cases' y with y yl yr\n    congr\n    exact Function.LeftInverse.eq_rightInverse xr yl⟩\n\nvariable [Decomposition ℳ]\n\nprotected theorem Decomposition.isInternal : DirectSum.IsInternal ℳ :=\n  ⟨Decomposition.right_inv.Injective, Decomposition.left_inv.Surjective⟩\n#align direct_sum.decomposition.is_internal DirectSum.Decomposition.isInternal\n\n/-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as\nto a direct sum of components. This is the canonical spelling of the `decompose'` field. -/\ndef decompose : M ≃ ⨁ i, ℳ i where\n  toFun := Decomposition.decompose'\n  invFun := DirectSum.coeAddMonoidHom ℳ\n  left_inv := Decomposition.left_inv\n  right_inv := Decomposition.right_inv\n#align direct_sum.decompose DirectSum.decompose\n\nprotected theorem Decomposition.inductionOn {p : M → Prop} (h_zero : p 0)\n    (h_homogeneous : ∀ {i} (m : ℳ i), p (m : M)) (h_add : ∀ m m' : M, p m → p m' → p (m + m')) :\n    ∀ m, p m :=\n  by\n  let ℳ' : ι → AddSubmonoid M := fun i =>\n    (⟨ℳ i, fun _ _ => AddMemClass.add_mem, ZeroMemClass.zero_mem _⟩ : AddSubmonoid M)\n  haveI t : DirectSum.Decomposition ℳ' :=\n    { decompose' := DirectSum.decompose ℳ\n      left_inv := fun _ => (decompose ℳ).left_inv _\n      right_inv := fun _ => (decompose ℳ).right_inv _ }\n  have mem : ∀ m, m ∈ supᵢ ℳ' := fun m =>\n    (DirectSum.IsInternal.addSubmonoid_supᵢ_eq_top ℳ' (decomposition.is_internal ℳ')).symm ▸ trivial\n  exact fun m =>\n    AddSubmonoid.supᵢ_induction ℳ' (mem m) (fun i m h => h_homogeneous ⟨m, h⟩) h_zero h_add\n#align direct_sum.decomposition.induction_on DirectSum.Decomposition.inductionOn\n\n@[simp]\ntheorem Decomposition.decompose'_eq : Decomposition.decompose' = decompose ℳ :=\n  rfl\n#align direct_sum.decomposition.decompose'_eq DirectSum.Decomposition.decompose'_eq\n\n@[simp]\ntheorem decompose_symm_of {i : ι} (x : ℳ i) : (decompose ℳ).symm (DirectSum.of _ i x) = x :=\n  DirectSum.coeAddMonoidHom_of ℳ _ _\n#align direct_sum.decompose_symm_of DirectSum.decompose_symm_of\n\n@[simp]\ntheorem decompose_coe {i : ι} (x : ℳ i) : decompose ℳ (x : M) = DirectSum.of _ i x := by\n  rw [← decompose_symm_of, Equiv.apply_symm_apply]\n#align direct_sum.decompose_coe DirectSum.decompose_coe\n\ntheorem decompose_of_mem {x : M} {i : ι} (hx : x ∈ ℳ i) :\n    decompose ℳ x = DirectSum.of (fun i => ℳ i) i ⟨x, hx⟩ :=\n  decompose_coe _ ⟨x, hx⟩\n#align direct_sum.decompose_of_mem DirectSum.decompose_of_mem\n\ntheorem decompose_of_mem_same {x : M} {i : ι} (hx : x ∈ ℳ i) : (decompose ℳ x i : M) = x := by\n  rw [decompose_of_mem _ hx, DirectSum.of_eq_same, Subtype.coe_mk]\n#align direct_sum.decompose_of_mem_same DirectSum.decompose_of_mem_same\n\ntheorem decompose_of_mem_ne {x : M} {i j : ι} (hx : x ∈ ℳ i) (hij : i ≠ j) :\n    (decompose ℳ x j : M) = 0 := by\n  rw [decompose_of_mem _ hx, DirectSum.of_eq_of_ne _ _ _ _ hij, ZeroMemClass.coe_zero]\n#align direct_sum.decompose_of_mem_ne DirectSum.decompose_of_mem_ne\n\n/-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as\nan additive monoid to a direct sum of components. -/\n@[simps (config := { fullyApplied := false })]\ndef decomposeAddEquiv : M ≃+ ⨁ i, ℳ i :=\n  AddEquiv.symm { (decompose ℳ).symm with map_add' := map_add (DirectSum.coeAddMonoidHom ℳ) }\n#align direct_sum.decompose_add_equiv DirectSum.decomposeAddEquiv\n\n@[simp]\ntheorem decompose_zero : decompose ℳ (0 : M) = 0 :=\n  map_zero (decomposeAddEquiv ℳ)\n#align direct_sum.decompose_zero DirectSum.decompose_zero\n\n@[simp]\ntheorem decompose_symm_zero : (decompose ℳ).symm 0 = (0 : M) :=\n  map_zero (decomposeAddEquiv ℳ).symm\n#align direct_sum.decompose_symm_zero DirectSum.decompose_symm_zero\n\n@[simp]\ntheorem decompose_add (x y : M) : decompose ℳ (x + y) = decompose ℳ x + decompose ℳ y :=\n  map_add (decomposeAddEquiv ℳ) x y\n#align direct_sum.decompose_add DirectSum.decompose_add\n\n@[simp]\ntheorem decompose_symm_add (x y : ⨁ i, ℳ i) :\n    (decompose ℳ).symm (x + y) = (decompose ℳ).symm x + (decompose ℳ).symm y :=\n  map_add (decomposeAddEquiv ℳ).symm x y\n#align direct_sum.decompose_symm_add DirectSum.decompose_symm_add\n\n@[simp]\ntheorem decompose_sum {ι'} (s : Finset ι') (f : ι' → M) :\n    decompose ℳ (∑ i in s, f i) = ∑ i in s, decompose ℳ (f i) :=\n  map_sum (decomposeAddEquiv ℳ) f s\n#align direct_sum.decompose_sum DirectSum.decompose_sum\n\n@[simp]\ntheorem decompose_symm_sum {ι'} (s : Finset ι') (f : ι' → ⨁ i, ℳ i) :\n    (decompose ℳ).symm (∑ i in s, f i) = ∑ i in s, (decompose ℳ).symm (f i) :=\n  map_sum (decomposeAddEquiv ℳ).symm f s\n#align direct_sum.decompose_symm_sum DirectSum.decompose_symm_sum\n\ntheorem sum_support_decompose [∀ (i) (x : ℳ i), Decidable (x ≠ 0)] (r : M) :\n    (∑ i in (decompose ℳ r).support, (decompose ℳ r i : M)) = r :=\n  by\n  conv_rhs =>\n    rw [← (decompose ℳ).symm_apply_apply r, ← sum_support_of (fun i => ℳ i) (decompose ℳ r)]\n  rw [decompose_symm_sum]\n  simp_rw [decompose_symm_of]\n#align direct_sum.sum_support_decompose DirectSum.sum_support_decompose\n\nend AddCommMonoid\n\n/-- The `-` in the statements below doesn't resolve without this line.\n\nThis seems to a be a problem of synthesized vs inferred typeclasses disagreeing. If we replace\nthe statement of `decompose_neg` with `@eq (⨁ i, ℳ i) (decompose ℳ (-x)) (-decompose ℳ x)`\ninstead of `decompose ℳ (-x) = -decompose ℳ x`, which forces the typeclasses needed by `⨁ i, ℳ i` to\nbe found by unification rather than synthesis, then everything works fine without this instance. -/\ninstance addCommGroupSetLike [AddCommGroup M] [SetLike σ M] [AddSubgroupClass σ M] (ℳ : ι → σ) :\n    AddCommGroup (⨁ i, ℳ i) := by infer_instance\n#align direct_sum.add_comm_group_set_like DirectSum.addCommGroupSetLike\n\nsection AddCommGroup\n\nvariable [DecidableEq ι] [AddCommGroup M]\n\nvariable [SetLike σ M] [AddSubgroupClass σ M] (ℳ : ι → σ)\n\nvariable [Decomposition ℳ]\n\ninclude M\n\n@[simp]\ntheorem decompose_neg (x : M) : decompose ℳ (-x) = -decompose ℳ x :=\n  map_neg (decomposeAddEquiv ℳ) x\n#align direct_sum.decompose_neg DirectSum.decompose_neg\n\n@[simp]\ntheorem decompose_symm_neg (x : ⨁ i, ℳ i) : (decompose ℳ).symm (-x) = -(decompose ℳ).symm x :=\n  map_neg (decomposeAddEquiv ℳ).symm x\n#align direct_sum.decompose_symm_neg DirectSum.decompose_symm_neg\n\n@[simp]\ntheorem decompose_sub (x y : M) : decompose ℳ (x - y) = decompose ℳ x - decompose ℳ y :=\n  map_sub (decomposeAddEquiv ℳ) x y\n#align direct_sum.decompose_sub DirectSum.decompose_sub\n\n@[simp]\ntheorem decompose_symm_sub (x y : ⨁ i, ℳ i) :\n    (decompose ℳ).symm (x - y) = (decompose ℳ).symm x - (decompose ℳ).symm y :=\n  map_sub (decomposeAddEquiv ℳ).symm x y\n#align direct_sum.decompose_symm_sub DirectSum.decompose_symm_sub\n\nend AddCommGroup\n\nsection Module\n\nvariable [DecidableEq ι] [Semiring R] [AddCommMonoid M] [Module R M]\n\nvariable (ℳ : ι → Submodule R M)\n\nvariable [Decomposition ℳ]\n\ninclude M\n\n/-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as\na module to a direct sum of components. -/\n@[simps (config := { fullyApplied := false })]\ndef decomposeLinearEquiv : M ≃ₗ[R] ⨁ i, ℳ i :=\n  LinearEquiv.symm\n    { (decomposeAddEquiv ℳ).symm with map_smul' := map_smul (DirectSum.coeLinearMap ℳ) }\n#align direct_sum.decompose_linear_equiv DirectSum.decomposeLinearEquiv\n\n@[simp]\ntheorem decompose_smul (r : R) (x : M) : decompose ℳ (r • x) = r • decompose ℳ x :=\n  map_smul (decomposeLinearEquiv ℳ) r x\n#align direct_sum.decompose_smul DirectSum.decompose_smul\n\nend Module\n\nend DirectSum\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/DirectSum/Decomposition.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7431679972357831, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4996553974779279}}
{"text": "import galois.data.bounded_list\nimport galois.list.take_drop_lemmas\nimport galois.list.member\n\nuniverses u v\n\nnamespace merkle\n\nstructure combine_result (Link Data : Type) :=\n(root : Data)\n(left : Link)\n(right : Link)\n\n/-- Operations needed to build a Merkle tree.-/\nstructure ops (Leaf Link Data : Type) :=\n(empty_root : Data)\n(leaf_data : Leaf → Data)\n(combine_data : Data -> Data → combine_result Link Data)\n/-- This stores information about a path from a leaf to a root.\n\n max_req_level bounds the length of the links.\n-/\nstructure path (Leaf Link : Type) (max_req_level : ℕ) :=\n(leaf  : Leaf)\n(links : bounded_list Link max_req_level)\n\n/-- This represents a result of computing a merkle tree-/\nstructure result (Leaf Link Data : Type) (max_req_level : ℕ) :=\n-- what we are aggregating\n(root : Data)\n-- the paths through the tree to get to this point\n(paths : list (path Leaf Link max_req_level))\n-- what we have not yet aggregated\n(remaining : list Leaf)\n\nsection path\n\nparameters {Leaf Link : Type}\n\ndef path.extend_none {n:ℕ} (p : path Leaf Link n)\n: path Leaf Link n.succ :=\n  { links := p.links.extend 1\n  , leaf  := p.leaf\n  }\n\ntheorem path.leaf_extend_none (n : ℕ)\n: path.leaf ∘ @path.extend_none n = path.leaf :=\nbegin\n  apply funext,\n  intro p,\n  cases p,\n  simp [function.comp, path.extend_none],\nend\n\ndef path.extend_sibling {n : ℕ}\n    (l : Link)\n    (p : path Leaf Link n)\n: path Leaf Link n.succ :=\n{ links := p.links.cons l\n, leaf  := p.leaf\n}\n\ntheorem path.leaf_extend_sibling (n : ℕ) (l : Link)\n: path.leaf ∘ @path.extend_sibling n l = path.leaf :=\nbegin\n  apply funext,\n  intro p,\n  cases p,\n  simp [function.comp, path.extend_sibling],\nend\n\nend path\n\nsection merkle\n\n-- This contains the types for the leaves of the tree and link elements\nparameters {Leaf Link Data : Type}\nparameter (ops : ops Leaf Link Data)\n\ndef merkle_core\n     : Π (n : ℕ) (e : Leaf) (rest : list Leaf), result Leaf Link Data n\n| 0 e rest :=\n{ root := ops.leaf_data e\n, paths := [{ leaf := e\n            , links := bounded_list.nil\n            }]\n, remaining := rest\n}\n| (nat.succ n) e rest := do\n  let left_result := merkle_core n e rest in\n  match left_result.remaining with\n  | [] :=\n      { root := left_result.root\n      , paths := left_result.paths.map path.extend_none\n      , remaining := []\n      }\n  | (e' :: rest') :=\n      let right_result := merkle_core n e' rest' in\n      let z := ops.combine_data left_result.root right_result.root in\n      { root := z.root\n      , paths := left_result.paths.map  (path.extend_sibling z.left)\n              ++ right_result.paths.map (path.extend_sibling z.right)\n      , remaining := right_result.remaining\n      }\n  end\n\nsection proofs\n\n\ntheorem merkle_core_ind\n  {P : ℕ → Leaf → list Leaf → Prop}\n  (n : ℕ) (e : Leaf) (l : list Leaf)\n  (base : ∀ (e:Leaf) (l:list Leaf), P 0 e l)\n  (ind1 : ∀ (n:ℕ) (e:Leaf) (l:list Leaf)\n      (pr : (merkle_core n e l).remaining = list.nil)\n      (ind : P n e l), P n.succ e l)\n  (ind2 : ∀ (n:ℕ) (e:Leaf) (l:list Leaf) (v : Leaf) (r : list Leaf)\n      (pr : (merkle_core n e l).remaining = v :: r)\n      (ind : P n e l), P n.succ e l)\n\n: P n e l :=\nbegin\n  induction n,\n  case nat.zero { apply base },\n  case nat.succ m ind {\n    destruct (merkle_core ops m e l).remaining,\n    { intro rl,\n      exact ind1 m e l rl ind,\n    },\n    {\n      intros v r rl,\n      exact ind2 m e l v r rl ind,\n    }\n  }\n\nend\n\nparameters (n :ℕ) (e : Leaf) (l : list Leaf)\n\ntheorem merkle_core_paths_ne : (merkle_core n e l).paths ≠ [] :=\nbegin\n  induction n,\n  { simp [merkle_core], },\n  case nat.succ n ind {\n    simp [merkle_core],\n    cases (merkle_core ops n e l).remaining,\n    all_goals {\n      simp [merkle_core],\n      cases (merkle_core ops n e l).paths,\n      { contradiction, },\n      { simp, },\n    },\n  }\nend\n\ntheorem merkle_core_remaining (n:ℕ) (e : Leaf) (l : list Leaf)\n: (merkle_core n e l).remaining = l.drop (2^n-1) :=\nbegin\n  revert e l,\n  induction n,\n  case nat.zero {\n    intros e l,\n    simp [merkle_core],\n  },\n  case nat.succ n ind {\n    intros e l,\n    simp only [merkle_core, ind],\n    have h : (2^nat.succ n - 1) = (2^n-1) + 2^n,\n    {\n      simp [nat.pow, nat.succ_mul],\n      simp [nat.add_sub_assoc, nat.one_le_pow, nat.succ_le_succ_iff\n           , nat.zero_le],\n    },\n    rw [h, list.drop_add],\n    cases (l.drop (2^n - 1)) with r rest,\n    { simp [merkle_core], },\n    { simp [merkle_core, ind, nat.pow_is_zero_iff], },\n  },\nend\n\ntheorem merkle_core_list_lengths (n:ℕ) (e : Leaf) (l : list Leaf)\n: (merkle_core n e l).paths.length + (merkle_core n e l).remaining.length\n   = l.length + 1 :=\nbegin\n  revert e l,\n  induction n,\n  case nat.zero {\n    intros e l,\n    simp [merkle_core],\n  },\n  case nat.succ n ind {\n    intros e l,\n    simp only [merkle_core],\n    destruct (merkle_core ops n e l).remaining,\n    case list.nil {\n      intro eq,\n      rw [eq],\n      simp only [merkle_core, list.length_map],\n      have pr := ind e l, rw [eq] at pr,\n      apply pr,\n    },\n    case list.cons {\n      intros r rest eq, rw [eq],\n      simp only [merkle_core, list.length_append, list.length_map],\n      rw [ add_assoc, ind],\n      have final := ind e l,\n      rw [eq] at final,\n      exact final,\n    }\n  },\nend\n\nend proofs\n\ndef merkle\n     : Π (n : ℕ) (l : list Leaf), result Leaf Link Data n\n| n [] :=\n{ root := ops.empty_root\n, paths := []\n, remaining := []\n}\n| n (e::r) := merkle_core n e r\n\nsection merkel_proofs\n\nparameters (n : ℕ) (l : list Leaf)\n\ntheorem merkle_paths_ne (pr : l ≠ []) : (merkle n l).paths ≠ [] :=\nbegin\n  cases l,\n  { contradiction, },\n  case list.cons e r {\n    simp [merkle],\n    apply merkle_core_paths_ne,\n  }\nend\n\ntheorem merkle_paths_length (n:ℕ) (l : list Leaf)\n: (merkle n l).paths.length = min (2^n) l.length :=\nbegin\n  cases l,\n  case list.nil { simp [merkle], },\n  case list.cons e l {\n    simp [merkle],\n    have pr := merkle_core_list_lengths ops n e l,\n    simp [merkle_core_remaining] at pr,\n    admit,\n  },\nend\n\ntheorem merkel_paths_nth_leaf  {n:ℕ} {l : list Leaf}\n   {idx : ℕ}\n   {r : Leaf}\n   (r_at_idx : l.nth idx = some r)\n   {p : path Leaf Link n}\n   (pr : (merkle n l).paths.nth idx = some p)\n: p.leaf = r :=\nbegin\n  admit\nend\n\n\nend merkel_proofs\n\nend merkle\n\nend merkle\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/crypto/merkle/merkle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189134878876, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.49961405590266067}}
{"text": "import lovelib\n\nset_option pp.beta true\nset_option pp.generalized_field_notation false\n\nnamespace LoVe\n\nstructure sig := (name : string)\n\nstructure relation := (name : string) (sigs : list sig)\n\nstructure atom := (name : string) (sig : sig)\n\ndef sig_bound := sig → set atom\n\nstructure sig_bounds :=\n(lower : sig_bound)\n(upper : sig_bound)\n\ndef rel_bound := relation → set (list atom)\n\nstructure rel_bounds :=\n(lower : rel_bound)\n(upper : rel_bound)\n\nstructure all_bounds :=\n(sigs : sig_bounds)\n(rels : rel_bounds)\n\n--For now, ignore `join`\n--For now, each bind must include a list of atoms\n--For now, ignore `not in`\ninductive inst : Type\n| and : inst → inst → inst\n| sig_in_atoms : sig → set atom → inst\n| atoms_in_sig : set atom → sig → inst\n| rel_in_atoms : relation → set (list atom) → inst\n| atoms_in_rel : set (list atom) → relation → inst\n\ndef refine_bounds [decidable_eq sig] [decidable_eq relation] : inst → all_bounds → all_bounds\n| (inst.and i1 i2) (bounds : all_bounds) := refine_bounds i2 (refine_bounds i1 bounds)\n| (inst.sig_in_atoms s1 atoms) (bounds : all_bounds) :=\n  all_bounds.mk (\n    sig_bounds.mk bounds.sigs.lower (\n      λ(s : sig),\n        if s = s1 then\n          atoms ∩ (bounds.sigs.upper s)\n        else\n          bounds.sigs.upper s\n    )\n  ) bounds.rels\n| (inst.atoms_in_sig atoms s1) (bounds : all_bounds) :=\n  all_bounds.mk (\n    sig_bounds.mk (\n      λ(s : sig),\n        if s = s1 then\n          atoms ∪ (bounds.sigs.lower s)\n        else\n          bounds.sigs.lower s\n    ) bounds.sigs.upper\n  ) bounds.rels\n| (inst.rel_in_atoms r1 atoms) (bounds : all_bounds) :=\n  all_bounds.mk bounds.sigs (\n    rel_bounds.mk bounds.rels.lower (\n      λ(r : relation),\n        if r = r1 then\n          atoms ∩ (bounds.rels.upper r)\n        else\n          bounds.rels.upper r\n    )\n  )\n| (inst.atoms_in_rel atoms r1) (bounds : all_bounds) :=\n  all_bounds.mk bounds.sigs (\n    rel_bounds.mk (\n      λ(r : relation),\n        if r = r1 then\n          atoms ∪ (bounds.rels.lower r)\n        else\n          bounds.rels.lower r\n    ) bounds.rels.upper\n  )\n\nlemma bounds_conflict_carries_for_sig [decidable_eq sig] [decidable_eq atom] [decidable_eq relation] (s1 : sig) (lower upper : set atom) :\n  (lower ⊆ upper) ↔\n    ((refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (λx, ∅) (λx, set.univ))\n                                      (rel_bounds.mk (λx, ∅) (λx, set.univ)))).sigs.lower s1)\n        ⊆\n       ((refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (λx, ∅) (λx, set.univ))\n                                      (rel_bounds.mk (λx, ∅) (λx, set.univ)))).sigs.upper s1) :=\nbegin\n  have hlower : lower = (refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (λx, ∅) (λx, set.univ))\n                                      (rel_bounds.mk (λx, ∅) (λx, set.univ)))).sigs.lower s1 :=\n      begin\n         calc lower\n             = (λ(s : sig), if s = s1 then (lower ∪ ∅) else ∅) s1 :\n          by simp\n        ... = (sig_bounds.mk (λ(s : sig), if s = s1 then (lower ∪ ∅) else ∅)\n                             (λ(s : sig), if s = s1 then (upper ∩ set.univ) else set.univ)).lower s1 :\n          by simp\n         ... = (all_bounds.mk (sig_bounds.mk (λ(s : sig), if s = s1 then (lower ∪ ∅) else ∅)\n                                             (λ(s : sig), if s = s1 then (upper ∩ set.univ) else set.univ))\n                              (rel_bounds.mk (λx, ∅) (λx, set.univ))).sigs.lower s1 :\n          by simp\n        ... = (refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (λx, ∅) (λx, set.univ))\n                                      (rel_bounds.mk (λx, ∅) (λx, set.univ)))).sigs.lower s1 :\n          by refl\n      end,\n  have hupper : upper = (refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (λx, ∅) (λx, set.univ))\n                                      (rel_bounds.mk (λx, ∅) (λx, set.univ)))).sigs.upper s1 :=\n      begin\n         calc upper\n             = (λ(s : sig), if s = s1 then (upper ∩ set.univ) else set.univ) s1 :\n          by simp\n        ... = (sig_bounds.mk (λ(s : sig), if s = s1 then (lower ∪ ∅) else ∅)\n                             (λ(s : sig), if s = s1 then (upper ∩ set.univ) else set.univ)).upper s1 :\n          by simp\n         ... = (all_bounds.mk (sig_bounds.mk (λ(s : sig), if s = s1 then (lower ∪ ∅) else ∅)\n                                             (λ(s : sig), if s = s1 then (upper ∩ set.univ) else set.univ))\n                              (rel_bounds.mk (λx, ∅) (λx, set.univ))).sigs.upper s1 :\n          by simp\n        ... = (refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (λx, ∅) (λx, set.univ))\n                                      (rel_bounds.mk (λx, ∅) (λx, set.univ)))).sigs.upper s1 :\n          by refl\n      end,\n  apply iff.intro,\n  { intro hlsubu,\n    intro bound,\n    intro hboundlower,\n    simp [refine_bounds],\n    simp,\n    have hboundeltlower : bound ∈ lower :=\n      by cc,\n    apply hlsubu,\n    exact hboundeltlower, },\n  { rw ←hupper,\n    rw ←hlower,\n    intro hlu,\n    exact hlu, },\nend\n\ndef new_bounds : all_bounds :=\n(all_bounds.mk (sig_bounds.mk (λx, ∅) (λx, set.univ))\n               (rel_bounds.mk (λx, ∅) (λx, set.univ)))\n\nlemma and_assoc [decidable_eq sig] [decidable_eq atom] [decidable_eq relation] (i1 i2 i3 : inst) :\n  refine_bounds (inst.and i1 (inst.and i2 i3)) new_bounds = refine_bounds (inst.and (inst.and i1 i2) i3) new_bounds :=\nby refl\n\nlemma add_comm [decidable_eq sig] [decidable_eq atom] [decidable_eq relation] (i1 i2 : inst) :\n  refine_bounds (inst.and i1 i2) new_bounds = refine_bounds (inst.and i2 i1) new_bounds :=\nsorry\n/-!\nbegin\n  cases' i1,\n  case and {\n    sorry\n  },\n  case sig_in_atoms {\n    calc refine_bounds (inst.and (inst.sig_in_atoms x x_1) i2) new_bounds\n        = refine_bounds i2 (refine_bounds (inst.sig_in_atoms x x_1) new_bounds) : sorry\n    ... = refine_bounds i2 (all_bounds.mk (sig_bounds.mk (λx, ∅) (λ(s : sig), if s = x then set.univ ∩ x_1 else set.univ))\n                                          (rel_bounds.mk (λx, ∅) (λx, set.univ))) : sorry\n    ... = sorry\n    sorry\n  },\nend\n-/\n\nlemma and_reverse [decidable_eq sig] [decidable_eq atom] [decidable_eq relation] (i1 i2 i3 : inst) :\n  refine_bounds (inst.and i1 (inst.and i2 i3)) new_bounds = refine_bounds (inst.and i3 (inst.and i2 i1)) new_bounds :=\ncalc refine_bounds (inst.and i1 (inst.and i2 i3)) new_bounds\n    = refine_bounds (inst.and i2 i3) (refine_bounds i1 new_bounds) :\n  by refl\n... = refine_bounds i3 (refine_bounds i2 (refine_bounds i1 new_bounds)) :\n  by refl\n... = refine_bounds i3 (refine_bounds i1 (refine_bounds i2 new_bounds)) :\n  begin\n    have hi1i2eq : (refine_bounds i2 (refine_bounds i1 new_bounds)) = (refine_bounds i1 (refine_bounds i2 new_bounds)) :=\n      by apply add_comm,\n    rw hi1i2eq,\n  end\n... = refine_bounds i3 (refine_bounds (inst.and i2 i1) new_bounds) :\n  by refl\n... = refine_bounds (inst.and (inst.and i2 i1) i3) new_bounds :\n  by refl\n... = refine_bounds (inst.and i3 (inst.and i2 i1)) new_bounds :\n  by apply add_comm\n\nend LoVe\n", "meta": {"author": "bryjikov", "repo": "forge-inst-semantics", "sha": "73b5009a880529495cb29c9c6e8023e40d6ca057", "save_path": "github-repos/lean/bryjikov-forge-inst-semantics", "path": "github-repos/lean/bryjikov-forge-inst-semantics/forge-inst-semantics-73b5009a880529495cb29c9c6e8023e40d6ca057/src/inst-semantics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.49961405325511743}}
{"text": "import Mathlib.Data.Nat.Basic\nimport Mathlib.Data.Fin.Basic\nimport Mathlib.Algebra.Group.Defs\nimport Mathlib.Algebra.GroupWithZero.Defs\nimport Mathlib.Algebra.Ring.Basic\n\nlemma UInt8.size_positive : 0 < UInt8.size := by decide\n\nlemma UInt16.size_positive : 0 < UInt16.size := by decide\n\nlemma UInt32.size_positive : 0 < UInt32.size := by decide\n\nlemma UInt64.size_positive : 0 < UInt64.size := by decide\n\nlemma USize.size_positive : 0 < USize.size := usize_size_gt_zero\n\nlemma UInt8.val_eq_of_lt {a : Nat} : a < UInt8.size -> (ofNat a).val = a := Fin.val_eq_of_lt\n\nlemma UInt16.val_eq_of_lt {a : Nat} : a < UInt16.size -> (ofNat a).val = a := Fin.val_eq_of_lt\n\nlemma UInt32.val_eq_of_lt {a : Nat} : a < UInt32.size -> (ofNat a).val = a := Fin.val_eq_of_lt\n\nlemma UInt64.val_eq_of_lt {a : Nat} : a < UInt64.size -> (ofNat a).val = a := Fin.val_eq_of_lt\n\nlemma USize.val_eq_of_lt {a : Nat} : a < USize.size -> (ofNat a).val = a := Fin.val_eq_of_lt\n\nset_option hygiene false\nlocal macro \"genIntDeclars\" typeName:ident : command => do\n  `(\n    namespace $typeName\n      instance : Inhabited (Fin size) where\n        default := Fin.ofNat' 0 size_positive\n\n      instance : AddSemigroup $typeName where\n        add_assoc := fun _ _ _ => congrArg mk (AddSemigroup.add_assoc _ _ _)\n\n      instance : AddCommSemigroup $typeName where\n        add_comm := fun _ _ => congrArg mk (AddCommSemigroup.add_comm _ _)\n\n      instance : Semigroup $typeName where\n        mul_assoc := fun _ _ _ => congrArg mk (Semigroup.mul_assoc _ _ _)\n\n      instance : Neg $typeName where\n        neg a := mk (-a.val)\n\n      lemma sub_def (a b : $typeName) : a - b = ⟨a.val - b.val⟩ := rfl\n\n      lemma mul_def (a b : $typeName) : a * b = ⟨a.val * b.val⟩ := rfl\n\n      lemma mod_def (a b : $typeName) : a % b = ⟨a.val % b.val⟩ := rfl\n\n      lemma add_def (a b : $typeName) : a + b = ⟨a.val + b.val⟩ := rfl\n\n      lemma eq_of_val_eq : ∀ {a b : $typeName}, a.val = b.val -> a = b\n      | ⟨f1⟩, ⟨f2⟩, h => congrArg mk h\n\n      lemma val_eq_of_eq : ∀ {a b : $typeName}, a = b -> a.val = b.val\n      | ⟨f1⟩, ⟨f2⟩, h => congrArg val h\n\n      @[simp] lemma mk_val_eq : ∀ (a : $typeName), mk a.val = a\n      | ⟨a, _⟩ => rfl\n\n      lemma zero_def : (0 : $typeName) = ⟨0⟩ := rfl\n\n      lemma neg_def (a : $typeName) : -a = ⟨-a.val⟩ := rfl\n\n      lemma one_def : (1 : $typeName) = ⟨1⟩ := rfl\n\n      instance : Semiring $typeName where\n        add_zero := by simp [add_def, zero_def]\n        zero_add := by simp [add_def, zero_def]\n        add_comm := by simp [add_def, add_comm]\n        mul_one  := by simp [mul_def, one_def]\n        one_mul  := by simp [mul_def, one_def]\n        nsmul n a := ⟨AddMonoid.nsmul n a.val⟩\n        nsmul_zero' x := congrArg mk (AddMonoid.nsmul_zero' x.val)\n        nsmul_succ' n a := congrArg mk (AddMonoid.nsmul_succ' n a.val)\n        zero_mul := by simp [mul_def, zero_def]\n        mul_zero := by simp [mul_def, zero_def]\n        npow_zero' := fun _ => rfl\n        npow_succ' := fun _ _ => rfl\n        right_distrib a b c := by\n          simp only [mul_def, add_def]\n          apply eq_of_val_eq\n          exact right_distrib a.val b.val c.val\n        left_distrib a b c := by\n          simp only [mul_def, add_def]\n          apply eq_of_val_eq\n          exact left_distrib a.val b.val c.val\n        natCast n := ⟨n⟩\n        natCast_zero := rfl\n        natCast_succ _ := congrArg mk (Fin.ofNat'_succ)\n        __ := inferInstanceAs (AddCommSemigroup $typeName)\n        __ := inferInstanceAs (Semigroup $typeName)\n\n      instance : Ring $typeName where\n        sub_eq_add_neg := fun _ _ => congrArg mk (sub_eq_add_neg _ _)\n        gsmul := fun x a => mk (Ring.gsmul x a.val)\n        gsmul_zero' := fun a => congrArg mk (SubNegMonoid.gsmul_zero' a.val)\n        gsmul_succ' := fun x a => congrArg mk (SubNegMonoid.gsmul_succ' x a.val)\n        gsmul_neg' := fun x a => congrArg mk (SubNegMonoid.gsmul_neg' x a.val)\n        add_left_neg := fun a => by apply eq_of_val_eq; simp [neg_def, add_def, zero_def]\n        intCast n := ⟨n⟩\n        intCast_ofNat _ := rfl\n        intCast_negSucc _ := rfl\n\n      instance : CommRing $typeName where\n        mul_comm := fun _ _ => by\n          apply eq_of_val_eq\n          simp [mul_def, zero_def]\n          exact mul_comm _ _\n\n    end $typeName\n  )\n\ngenIntDeclars UInt8\ngenIntDeclars UInt16\ngenIntDeclars UInt32\ngenIntDeclars UInt64\ngenIntDeclars USize\n\nnamespace UInt8\n\n/-- Is this an uppercase ASCII letter? -/\ndef isUpper (c : UInt8) : Bool :=\n  c ≥ 65 && c ≤ 90\n\n/-- Is this a lowercase ASCII letter? -/\ndef isLower (c : UInt8) : Bool :=\n  c ≥ 97 && c ≤ 122\n\n/-- Is this an alphabetic ASCII character? -/\ndef isAlpha (c : UInt8) : Bool :=\n  c.isUpper || c.isLower\n\n/-- Is this an ASCII digit character? -/\ndef isDigit (c : UInt8) : Bool :=\n  c ≥ 48 && c ≤ 57\n\n/-- Is this an alphanumeric ASCII character? -/\ndef isAlphanum (c : UInt8) : Bool :=\n  c.isAlpha || c.isDigit\n\ntheorem toChar_aux (n : Nat) (h : n < size) : Nat.isValidChar (UInt32.ofNat n).1 := by\n  rw [UInt32.val_eq_of_lt]\n  exact Or.inl $ Nat.lt_trans h $ by decide\n  exact Nat.lt_trans h $ by decide\n\n/-- The numbers from 0 to 256 are all valid UTF-8 characters, so we can embed one in the other. -/\ndef toChar (n : UInt8) : Char := ⟨n.toUInt32, toChar_aux n.1 n.1.2⟩\n\nend UInt8\n", "meta": {"author": "JOSHCLUNE", "repo": "Keller_reduction", "sha": "dc392b3da352fc1ffcfbecb1d4717d05f5faed4a", "save_path": "github-repos/lean/JOSHCLUNE-Keller_reduction", "path": "github-repos/lean/JOSHCLUNE-Keller_reduction/Keller_reduction-dc392b3da352fc1ffcfbecb1d4717d05f5faed4a/Lean4_Clique/Mathlib/Mathlib/Data/UInt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199795472731, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.49958431977549134}}
{"text": "import data.real.basic\nimport data.bool\n\nimport trace\n\nnamespace Compose1Ge2\n\ninductive WstState\n  | Tracking\n  | NoWst\n\n-- Helper function. If (τₛ.w (t+1)) = this value, then τₛ.upper = τ₁.upper\ndef track (τ₁ τ₂ : Trace) (wst_cur : ℚ) (t : ℕ) : ℚ :=\n  let wst := τ₁.wst (t+1) - (τ₁.C - τ₂.C) * ↑t in\n    if wst_cur > wst then wst_cur else wst\n\n-- Make all propositions decidable\n-- open classical\n-- local attribute [instance] prop_decidable\n\n-- This is how we derive τₛ.w\ndef wst_compose (τ₁ τ₂ : Trace) : ℕ → (ℚ × WstState)\n  | 0 := (0, WstState.Tracking)\n  | (nat.succ t) :=\n    let ⟨wst, s⟩ := (wst_compose t) in\n    match s with\n    | WstState.Tracking :=\n      if τ₁.lower (1 + t) ≥ τ₂.upper 1 + t\n      then (wst, WstState.NoWst)\n      else (track τ₁ τ₂ wst t, WstState.Tracking)\n    | WstState.NoWst :=\n      if τ₂.C * ↑t - wst + τ₂.C ≥ τ₁.upper (1 + t)\n      then (track τ₁ τ₂ wst t, WstState.Tracking)\n      else (wst, WstState.NoWst)\n    end\n\nset_option trace.check true\ntheorem trace_composes_τ₁_ge_τ₂ :\n    ∀(τ₁ τ₂ : Trace),\n        τ₁.C ≥ τ₂.C ∧\n        τ₁.out = τ₂.inp ∧\n        (∀t, τ₁.los t = 0 ∧ τ₂.los t = 0)\n    → ∃(τₛ : Trace),\n        τₛ.C = τ₁.C ∧\n        τₛ.D = τ₁.D + τ₂.D ∧\n        τₛ.inp = τ₁.inp ∧\n        τₛ.out = τ₂.out ∧\n        ∀ t, τₛ.los t = τ₁.los t + τ₂.los t :=\nbegin\n  intros τ₁ τ₂ h, cases h with hc h, cases h with h₁₂ h_los,\n\n  -- We will set τₛ.wst to wst_compose\n  -- generalize h : w = λ t, (waste_compose τ₁ τ₂ t),\n  -- have h : ℕ → (ℚ × WstState) := (λ t, (wst_compose τ₁ τ₂ t)),\n  generalize h_wstₛ : (wst_compose τ₁ τ₂) = wstₛ,\n\n  -- Whenever waste happens, it is allowed\n  have h_cond_waste : ∀t, (wstₛ (1 + t)).1 > (wstₛ t).1 →\n    τ₁.inp (1 + t) ≤ τ₂.C * (1 + t) - (wstₛ (1 + t)).1 :=\n  begin\n    intros t h_inc,\n    induction t,\n    {\n      simp, rw <- h_wstₛ, unfold wst_compose,\n      by_cases h_cond : ((Trace.lower τ₁ (1 + 0) ≥ Trace.upper τ₂ 1 + ↑0)) = tt,\n      rw h_cond,\n\n      sorry\n    },\n    -- Go through wst_compose and get the cases where waste can increase\n    -- rw wstₛ at h_wst,\n    sorry,\n  end,\n\n  sorry,\nend\n\nend Compose1Ge2\n", "meta": {"author": "venkatarun95", "repo": "ccac_proofs", "sha": "6d3ff5b5b9500cc1675313996a33915b7f8b1bbc", "save_path": "github-repos/lean/venkatarun95-ccac_proofs", "path": "github-repos/lean/venkatarun95-ccac_proofs/ccac_proofs-6d3ff5b5b9500cc1675313996a33915b7f8b1bbc/src/compose_1_ge_2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4995843101049339}}
{"text": "/-\nCopyright (c) 2017 Daniel Selsam. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Daniel Selsam\n\nMiscellaneous lemmas that depend on compute_grad_slow_correct.\n-/\nimport .predicates .tcont .expected_value .lemmas .compute_grad_slow_correct\n\nnamespace certigrad\nopen list\n\nlemma is_nabla_gintegrable_of_gintegrable {costs : list ID} :\n  Π (m : env) (nodes : list node) (tgt : reference),\n  well_formed_at costs nodes m tgt →\n  grads_exist_at nodes m tgt →\n  pdfs_exist_at nodes m →\n  is_gdifferentiable (λ m, ⟦sum_costs m costs⟧) tgt m nodes dvec.head →\n  can_differentiate_under_integrals costs nodes m tgt →\n\n  is_gintegrable (λ m, ⟦compute_grad_slow costs nodes m tgt⟧) m nodes dvec.head → is_nabla_gintegrable (λ m, ⟦sum_costs m costs⟧) tgt m nodes dvec.head\n| m [] tgt H_wf H_gs_exist H_pdfs_exist H_gdiff H_diff_under_int H_gint := trivial\n\n| m (⟨ref, parents, operator.det op⟩ :: nodes) tgt H_wf H_gs_exist H_pdfs_exist H_gdiff H_diff_under_int H_gint :=\nlet x : T ref.2 := op^.f (env.get_ks parents m),\n    next_inputs : env := env.insert ref x m in\nhave H_ref_notin_parents : ref ∉ parents, from ref_notin_parents H_wf^.ps_in_env H_wf^.uids,\nhave H_get_ks_next_inputs : env.get_ks parents next_inputs = env.get_ks parents m,\n  begin dsimp, rw (env.get_ks_insert_diff H_ref_notin_parents) end,\nhave H_wfs : well_formed_at costs nodes next_inputs tgt ∧ well_formed_at costs nodes next_inputs ref, from wf_at_next H_wf,\n\nbegin\ndsimp [is_gintegrable, compute_grad_slow] at H_gint,\ndsimp [is_nabla_gintegrable],\nsplit,\n-- tgt\nbegin\napply is_nabla_gintegrable_of_gintegrable,\nexact H_wfs^.left,\nexact H_gs_exist^.left,\nexact H_pdfs_exist,\nexact H_gdiff^.right^.right^.left,\nexact H_diff_under_int^.left,\nexact (iff.mpr (is_gintegrable_k_add _ _ _ _) H_gint)^.left\nend,\n\n-- ref\nbegin\nintros idx H_idx_in_riota H_tgt_eq_dnth_idx,\nassertv H_tgt_at_idx : at_idx parents idx tgt := ⟨in_riota_lt H_idx_in_riota, H_tgt_eq_dnth_idx⟩,\nassertv H_tshape_at_idx : at_idx parents^.p2 idx tgt.2 := at_idx_p2 H_tgt_at_idx,\nassertv H_tgt_in_parents : tgt ∈ parents := mem_of_at_idx H_tgt_at_idx,\nassertv H_f_pre : op^.pre (env.get_ks parents next_inputs) := eq.rec_on (eq.symm H_get_ks_next_inputs) (H_gs_exist^.right H_tgt_in_parents)^.left,\n\n-- TODO(dhs): copy-pasted from compute_grad_slow_correct.lean:223\nassert H_grad_gint_ref : is_gintegrable (λ m, ⟦compute_grad_slow costs nodes m ref⟧) next_inputs nodes dvec.head,\nbegin\nassertv H_op_called : is_gintegrable (λ m, ⟦det.op.pb op (env.get_ks parents m) (env.get ref m) (compute_grad_slow costs nodes m ref) idx (tgt.snd)⟧)\n                                    next_inputs nodes dvec.head :=\n  is_gintegrable_of_sumr_map (λ m idx, det.op.pb op (env.get_ks parents m) (env.get ref m) (compute_grad_slow costs nodes m ref) idx (tgt.snd))\n                                    next_inputs nodes _ (iff.mpr (is_gintegrable_k_add _ _ _ _) H_gint)^.right idx (in_filter _ _ _ H_idx_in_riota H_tgt_eq_dnth_idx),\n\nassert H_op_called_swap : is_gintegrable (λ m, ⟦det.op.pb op (env.get_ks parents next_inputs) x (compute_grad_slow costs nodes m ref) idx (tgt.snd)⟧)\n                                         next_inputs nodes dvec.head,\nbegin\napply is_gintegrable_k_congr _ _ _ _ _ H_wfs^.right^.uids _ H_op_called,\nintros m H_envs_match,\n-- TODO(dhs): this is copy-pasted from above (nested comment!)\nassert H_parents_match : env.get_ks parents m = env.get_ks parents next_inputs,\nbegin\n  apply env.get_ks_env_eq,\n  intros parent H_parent_in_parents,\n  apply H_envs_match,\n  apply env.has_key_insert,\n  exact (H_wf^.ps_in_env^.left parent H_parent_in_parents)\nend,\nassert H_ref_matches : env.get ref m = x,\nbegin\n  assertv H_env_has_key_ref : env.has_key ref next_inputs := env.has_key_insert_same _ _,\n  rw [H_envs_match ref H_env_has_key_ref, env.get_insert_same]\nend,\nsimp only [H_parents_match, H_ref_matches],\nend,\n\nsimp only [λ (m : env), op^.pb_correct (env.get_ks parents next_inputs) x (by rw H_get_ks_next_inputs) (compute_grad_slow costs nodes m ref) H_tshape_at_idx H_f_pre] at H_op_called_swap,\nexact iff.mpr (is_gintegrable_tmulT _ _ _ _) H_op_called_swap\nend,\napply is_nabla_gintegrable_of_gintegrable,\nexact H_wfs^.right,\nexact (H_gs_exist^.right H_tgt_in_parents)^.right,\nexact H_pdfs_exist,\nexact H_gdiff^.right^.right^.right H_idx_in_riota H_tgt_eq_dnth_idx,\nexact H_diff_under_int^.right H_tgt_in_parents,\nexact H_grad_gint_ref\nend\nend\n\n| inputs (⟨ref, parents, operator.rand op⟩ :: nodes) tgt H_wf H_gs_exist H_pdfs_exist H_gdiff H_diff_under_int H_gint :=\nlet θ := env.get tgt inputs in\nlet next_inputs := λ (y : T ref.2), env.insert ref y inputs in\nhave H_ref_in_refs : ref ∈ ref :: map node.ref nodes, from mem_of_cons_same,\nhave H_ref_notin_parents : ref ∉ parents, from ref_notin_parents H_wf^.ps_in_env H_wf^.uids,\nhave H_tgt_neq_ref : tgt ≠ ref, from ref_ne_tgt H_wf^.m_contains_tgt H_wf^.uids,\n\nhave H_wfs : ∀ y, well_formed_at costs nodes (next_inputs y) tgt ∧ well_formed_at costs nodes (next_inputs y) ref,\n  from assume y, wf_at_next H_wf,\n\nbegin\ndsimp [is_gintegrable, compute_grad_slow] at H_gint,\ndsimp [is_nabla_gintegrable],\n\nassert H_cgsc : ∀ x,\nE (graph.to_dist (λ (m : env), ⟦compute_grad_slow costs nodes m tgt⟧)\n                 (env.insert ref x inputs) nodes)\n  dvec.head\n=\n∇ (λ (θ₀ : T (tgt.snd)),\n     E (graph.to_dist (λ (m : env), ⟦sum_costs m costs⟧)\n                      (env.insert ref x (env.insert tgt θ₀ inputs)) nodes)\n        dvec.head)\n  (env.get tgt inputs),\nbegin -- start H_cgsc\nintro x,\nrw -theorems.compute_grad_slow_correct (H_wfs x)^.left (H_gs_exist^.right _) (H_pdfs_exist^.right _) (H_gdiff^.right^.right _)\n                                       _\n                                       (iff.mpr (is_gintegrable_k_add _ _ _ _) (H_gint^.right x))^.left\n                                       (H_diff_under_int^.right _),\n\nsimp only [(λ (θ₀ : T tgt.2), env.insert_insert_flip θ₀ x inputs H_tgt_neq_ref), @env.get_insert_diff tgt ref x inputs H_tgt_neq_ref],\nexact is_nabla_gintegrable_of_gintegrable _ _ _ (H_wfs x)^.left (H_gs_exist^.right _) (H_pdfs_exist^.right _) (H_gdiff^.right^.right _)\n                                          (H_diff_under_int^.right _)\n                                          (iff.mpr (is_gintegrable_k_add _ _ _ _) (H_gint^.right x))^.left,\nend, -- end H_cgsc\n\nsimp only [λ x, E.E_k_add _ _ _ _ (iff.mpr (is_gintegrable_k_add _ _ _ _) (H_gint^.right x))^.left\n                              (iff.mpr (is_gintegrable_k_add _ _ _ _) (H_gint^.right x))^.right] at H_gint,\nsimp only [H_cgsc] at H_gint,\n\n-- TODO(dhs): apply and.intro _ (and.intro _ _) does not instantiate the second metavariable, change back once fixed\nsplit, tactic.swap, split, tactic.rotate 2,\n\nbegin -- start PD\napply (iff.mpr (T.is_integrable_add_middle _ _ _) H_gint^.left)^.left\nend, -- end PD\n\ndunfold sum_downstream_costs at H_gint,\n\n-- Scores\nassert H_score_rw : ∀ y,\nmap\n            (λ (idx : ℕ),\n               E\n                 (graph.to_dist\n                    (λ (m : env), ⟦sum_costs m costs⟧)\n                    (env.insert ref y inputs)\n                    nodes)\n                 dvec.head ⬝ ∇\n                 (λ (θ₀ : T (tgt.snd)), T.log (rand.op.pdf op (dvec.update_at θ₀ (env.get_ks parents inputs) idx) y))\n                 (env.get tgt inputs))\n            (filter (λ (idx : ℕ), tgt = dnth parents idx) (riota (length parents)))\n=\nmap\n    (λ (idx : ℕ),\n       E\n         (graph.to_dist\n            (λ (m : env),\n               ⟦sum_downstream_costs nodes costs ref m ⬝ rand.op.glogpdf op (env.get_ks parents m) (env.get ref m)\n                    idx\n                    (tgt.snd)⟧)\n            (env.insert ref y inputs)\n            nodes)\n         dvec.head)\n    (filter (λ (idx : ℕ), tgt = dnth parents idx) (riota (length parents))),\nbegin -- start H_score_rw\nexact map_filter_expand_helper _ _ _ _ _ _ H_wf H_gs_exist\nend, -- end H_score_rw\n\nassert H_pull_E : ∀ y,\nsumr\n         (map\n            (λ (idx : ℕ),\n               E\n                 (graph.to_dist\n                    (λ (m : env),\n                       ⟦sum_downstream_costs nodes costs ref m ⬝ rand.op.glogpdf op (env.get_ks parents m) (env.get ref m) idx (tgt.snd)⟧)\n                    (env.insert ref y inputs)\n                    nodes)\n                 dvec.head)\n            (filter (λ (idx : ℕ), tgt = dnth parents idx) (riota (length parents))))\n=\nE (graph.to_dist (λ (m : env),\n                    ⟦sumr (map (λ (idx : ℕ), sum_downstream_costs nodes costs ref m ⬝ rand.op.glogpdf op (env.get_ks parents m) (env.get ref m) idx (tgt.snd))\n                               (filter (λ (idx : ℕ), tgt = dnth parents idx) (riota (length parents))))⟧)\n                    (env.insert ref y inputs)\n                    nodes)\n                 dvec.head,\nbegin -- start H_pull_E\nintro y,\nrw -E.E_g_pull_out_of_sum _ _ _ _ (H_pdfs_exist^.right y),\nexact (iff.mpr (is_gintegrable_k_add _ _ _ _) (H_gint^.right y))^.right\nend, -- end H_pull_E\n\nbegin -- start score\nsimp only [H_score_rw], clear H_score_rw,\nsimp only [H_pull_E], clear H_pull_E,\napply (iff.mpr (T.is_integrable_add_middle _ _ _) H_gint^.left)^.right\nend, -- end score\n\n-- Recursive\nbegin\nintro y,\napply is_nabla_gintegrable_of_gintegrable,\nexact (H_wfs y)^.left,\nexact H_gs_exist^.right _,\nexact H_pdfs_exist^.right _,\nexact H_gdiff^.right^.right _,\nexact H_diff_under_int^.right _,\napply (iff.mpr (is_gintegrable_k_add _ _ _ _) (H_gint^.right y))^.left,\nend\n\nend\n\nend certigrad\n", "meta": {"author": "dselsam", "repo": "certigrad", "sha": "c9a06e93f1ec58196d6d3b8563b29868d916727f", "save_path": "github-repos/lean/dselsam-certigrad", "path": "github-repos/lean/dselsam-certigrad/certigrad-c9a06e93f1ec58196d6d3b8563b29868d916727f/src/certigrad/lemmas_extra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.49947800005913506}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\nimport analysis.inner_product_space.basic\nimport measure_theory.integral.set_integral\n\n/-! # `L^2` space\n\nIf `E` is an inner product space over `𝕜` (`ℝ` or `ℂ`), then `Lp E 2 μ` (defined in `lp_space.lean`)\nis also an inner product space, with inner product defined as `inner f g = ∫ a, ⟪f a, g a⟫ ∂μ`.\n\n### Main results\n\n* `mem_L1_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product `λ x, ⟪f x, g x⟫`\n  belongs to `Lp 𝕜 1 μ`.\n* `integrable_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product `λ x, ⟪f x, g x⟫`\n  is integrable.\n* `L2.inner_product_space` : `Lp E 2 μ` is an inner product space.\n\n-/\n\nnoncomputable theory\nopen topological_space measure_theory measure_theory.Lp\nopen_locale nnreal ennreal measure_theory\n\nnamespace measure_theory\n\nsection\n\nvariables {α F : Type*} {m : measurable_space α} {μ : measure α} [normed_group F]\n\nlemma mem_ℒp.integrable_sq {f : α → ℝ} (h : mem_ℒp f 2 μ) :\n  integrable (λ x, (f x)^2) μ :=\nby simpa [← mem_ℒp_one_iff_integrable]\n  using h.norm_rpow ennreal.two_ne_zero ennreal.two_ne_top\n\nlemma mem_ℒp_two_iff_integrable_sq_norm {f : α → F} (hf : ae_strongly_measurable f μ) :\n  mem_ℒp f 2 μ ↔ integrable (λ x, ∥f x∥^2) μ :=\nbegin\n  rw ← mem_ℒp_one_iff_integrable,\n  convert (mem_ℒp_norm_rpow_iff hf ennreal.two_ne_zero ennreal.two_ne_top).symm,\n  { simp },\n  { rw [div_eq_mul_inv, ennreal.mul_inv_cancel ennreal.two_ne_zero ennreal.two_ne_top] }\nend\n\nlemma mem_ℒp_two_iff_integrable_sq {f : α → ℝ} (hf : ae_strongly_measurable f μ) :\n  mem_ℒp f 2 μ ↔ integrable (λ x, (f x)^2) μ :=\nbegin\n  convert mem_ℒp_two_iff_integrable_sq_norm hf,\n  ext x,\n  simp,\nend\n\nend\n\nnamespace L2\n\nvariables {α E F 𝕜 : Type*} [is_R_or_C 𝕜] [measurable_space α] {μ : measure α}\n  [inner_product_space 𝕜 E] [normed_group F]\n\n\nlocal notation `⟪`x`, `y`⟫` := @inner 𝕜 _ _ x y\n\nlemma snorm_rpow_two_norm_lt_top (f : Lp F 2 μ) : snorm (λ x, ∥f x∥ ^ (2 : ℝ)) 1 μ < ∞ :=\nbegin\n  have h_two : ennreal.of_real (2 : ℝ) = 2, by simp [zero_le_one],\n  rw [snorm_norm_rpow f zero_lt_two, one_mul, h_two],\n  exact ennreal.rpow_lt_top_of_nonneg zero_le_two (Lp.snorm_ne_top f),\nend\n\nlemma snorm_inner_lt_top (f g : α →₂[μ] E) : snorm (λ (x : α), ⟪f x, g x⟫) 1 μ < ∞ :=\nbegin\n  have h : ∀ x, is_R_or_C.abs ⟪f x, g x⟫ ≤ ∥f x∥ * ∥g x∥, from λ x, abs_inner_le_norm _ _,\n  have h' : ∀ x, is_R_or_C.abs ⟪f x, g x⟫ ≤ is_R_or_C.abs (∥f x∥^2 + ∥g x∥^2),\n  { refine λ x, le_trans (h x) _,\n    rw [is_R_or_C.abs_to_real, abs_eq_self.mpr],\n    swap, { exact add_nonneg (by simp) (by simp), },\n    refine le_trans _ (half_le_self (add_nonneg (sq_nonneg _) (sq_nonneg _))),\n    refine (le_div_iff (@zero_lt_two ℝ _ _)).mpr ((le_of_eq _).trans (two_mul_le_add_sq _ _)),\n    ring, },\n  simp_rw [← is_R_or_C.norm_eq_abs, ← real.rpow_nat_cast] at h',\n  refine (snorm_mono_ae (ae_of_all _ h')).trans_lt ((snorm_add_le _ _ le_rfl).trans_lt _),\n  { exact ((Lp.ae_strongly_measurable f).norm.ae_measurable.pow_const _).ae_strongly_measurable },\n  { exact ((Lp.ae_strongly_measurable g).norm.ae_measurable.pow_const _).ae_strongly_measurable },\n  simp only [nat.cast_bit0, ennreal.add_lt_top, nat.cast_one],\n  exact ⟨snorm_rpow_two_norm_lt_top f, snorm_rpow_two_norm_lt_top g⟩,\nend\n\nsection inner_product_space\nopen_locale complex_conjugate\n\ninclude 𝕜\n\ninstance : has_inner 𝕜 (α →₂[μ] E) := ⟨λ f g, ∫ a, ⟪f a, g a⟫ ∂μ⟩\n\nlemma inner_def (f g : α →₂[μ] E) : ⟪f, g⟫ = ∫ a : α, ⟪f a, g a⟫ ∂μ := rfl\n\nlemma integral_inner_eq_sq_snorm (f : α →₂[μ] E) :\n  ∫ a, ⟪f a, f a⟫ ∂μ = ennreal.to_real ∫⁻ a, (∥f a∥₊ : ℝ≥0∞) ^ (2:ℝ) ∂μ :=\nbegin\n  simp_rw inner_self_eq_norm_sq_to_K,\n  norm_cast,\n  rw integral_eq_lintegral_of_nonneg_ae,\n  rotate,\n  { exact filter.eventually_of_forall (λ x, sq_nonneg _), },\n  { exact ((Lp.ae_strongly_measurable f).norm.ae_measurable.pow_const _).ae_strongly_measurable },\n  congr,\n  ext1 x,\n  have h_two : (2 : ℝ) = ((2 : ℕ) : ℝ), by simp,\n  rw [← real.rpow_nat_cast _ 2, ← h_two,\n    ← ennreal.of_real_rpow_of_nonneg (norm_nonneg _) zero_le_two, of_real_norm_eq_coe_nnnorm],\n  norm_cast,\nend\n\nprivate lemma norm_sq_eq_inner' (f : α →₂[μ] E) : ∥f∥ ^ 2 = is_R_or_C.re ⟪f, f⟫ :=\nbegin\n  have h_two : (2 : ℝ≥0∞).to_real = 2 := by simp,\n  rw [inner_def, integral_inner_eq_sq_snorm, norm_def, ← ennreal.to_real_pow, is_R_or_C.of_real_re,\n    ennreal.to_real_eq_to_real (ennreal.pow_ne_top (Lp.snorm_ne_top f)) _],\n  { rw [←ennreal.rpow_nat_cast, snorm_eq_snorm' ennreal.two_ne_zero ennreal.two_ne_top, snorm',\n      ← ennreal.rpow_mul, one_div, h_two],\n    simp, },\n  { refine (lintegral_rpow_nnnorm_lt_top_of_snorm'_lt_top zero_lt_two _).ne,\n    rw [← h_two, ← snorm_eq_snorm' ennreal.two_ne_zero ennreal.two_ne_top],\n    exact Lp.snorm_lt_top f, },\nend\n\nlemma mem_L1_inner (f g : α →₂[μ] E) :\n  ae_eq_fun.mk (λ x, ⟪f x, g x⟫)\n    ((Lp.ae_strongly_measurable f).inner (Lp.ae_strongly_measurable g)) ∈ Lp 𝕜 1 μ :=\nby { simp_rw [mem_Lp_iff_snorm_lt_top, snorm_ae_eq_fun], exact snorm_inner_lt_top f g, }\n\nlemma integrable_inner (f g : α →₂[μ] E) : integrable (λ x : α, ⟪f x, g x⟫) μ :=\n(integrable_congr (ae_eq_fun.coe_fn_mk (λ x, ⟪f x, g x⟫)\n    ((Lp.ae_strongly_measurable f).inner (Lp.ae_strongly_measurable g)))).mp\n  (ae_eq_fun.integrable_iff_mem_L1.mpr (mem_L1_inner f g))\n\nprivate lemma add_left' (f f' g : α →₂[μ] E) : ⟪f + f', g⟫ = inner f g + inner f' g :=\nbegin\n  simp_rw [inner_def, ← integral_add (integrable_inner f g) (integrable_inner f' g),\n    ←inner_add_left],\n  refine integral_congr_ae ((coe_fn_add f f').mono (λ x hx, _)),\n  congr,\n  rwa pi.add_apply at hx,\nend\n\nprivate lemma smul_left' (f g : α →₂[μ] E) (r : 𝕜) :\n  ⟪r • f, g⟫ = conj r * inner f g :=\nbegin\n  rw [inner_def, inner_def, ← smul_eq_mul, ← integral_smul],\n  refine integral_congr_ae ((coe_fn_smul r f).mono (λ x hx, _)),\n  rw [smul_eq_mul, ← inner_smul_left],\n  congr,\n  rwa pi.smul_apply at hx,\nend\n\ninstance inner_product_space : inner_product_space 𝕜 (α →₂[μ] E) :=\n{ norm_sq_eq_inner := norm_sq_eq_inner',\n  conj_sym := λ _ _, by simp_rw [inner_def, ← integral_conj, inner_conj_sym],\n  add_left := add_left',\n  smul_left := smul_left', }\n\nend inner_product_space\n\nsection indicator_const_Lp\n\nvariables (𝕜) {s : set α}\n\n/-- The inner product in `L2` of the indicator of a set `indicator_const_Lp 2 hs hμs c` and `f` is\nequal to the integral of the inner product over `s`: `∫ x in s, ⟪c, f x⟫ ∂μ`. -/\nlemma inner_indicator_const_Lp_eq_set_integral_inner (f : Lp E 2 μ) (hs : measurable_set s) (c : E)\n  (hμs : μ s ≠ ∞) :\n  (⟪indicator_const_Lp 2 hs hμs c, f⟫ : 𝕜) = ∫ x in s, ⟪c, f x⟫ ∂μ :=\nbegin\n  rw [inner_def, ← integral_add_compl hs (L2.integrable_inner _ f)],\n  have h_left : ∫ x in s, ⟪(indicator_const_Lp 2 hs hμs c) x, f x⟫ ∂μ = ∫ x in s, ⟪c, f x⟫ ∂μ,\n  { suffices h_ae_eq : ∀ᵐ x ∂μ, x ∈ s → ⟪indicator_const_Lp 2 hs hμs c x, f x⟫ = ⟪c, f x⟫,\n      from set_integral_congr_ae hs h_ae_eq,\n    have h_indicator : ∀ᵐ (x : α) ∂μ, x ∈ s → (indicator_const_Lp 2 hs hμs c x) = c,\n      from indicator_const_Lp_coe_fn_mem,\n    refine h_indicator.mono (λ x hx hxs, _),\n    congr,\n    exact hx hxs, },\n  have h_right : ∫ x in sᶜ, ⟪(indicator_const_Lp 2 hs hμs c) x, f x⟫ ∂μ = 0,\n  { suffices h_ae_eq : ∀ᵐ x ∂μ, x ∉ s → ⟪indicator_const_Lp 2 hs hμs c x, f x⟫ = 0,\n    { simp_rw ← set.mem_compl_iff at h_ae_eq,\n      suffices h_int_zero : ∫ x in sᶜ, inner (indicator_const_Lp 2 hs hμs c x) (f x) ∂μ\n        = ∫ x in sᶜ, (0 : 𝕜) ∂μ,\n      { rw h_int_zero,\n        simp, },\n      exact set_integral_congr_ae hs.compl h_ae_eq, },\n    have h_indicator : ∀ᵐ (x : α) ∂μ, x ∉ s → (indicator_const_Lp 2 hs hμs c x) = 0,\n      from indicator_const_Lp_coe_fn_nmem,\n    refine h_indicator.mono (λ x hx hxs, _),\n    rw hx hxs,\n    exact inner_zero_left, },\n  rw [h_left, h_right, add_zero],\nend\n\n/-- The inner product in `L2` of the indicator of a set `indicator_const_Lp 2 hs hμs c` and `f` is\nequal to the inner product of the constant `c` and the integral of `f` over `s`. -/\nlemma inner_indicator_const_Lp_eq_inner_set_integral [complete_space E] [normed_space ℝ E]\n  (hs : measurable_set s) (hμs : μ s ≠ ∞) (c : E) (f : Lp E 2 μ) :\n  (⟪indicator_const_Lp 2 hs hμs c, f⟫ : 𝕜) = ⟪c, ∫ x in s, f x ∂μ⟫ :=\nby rw [← integral_inner (integrable_on_Lp_of_measure_ne_top f fact_one_le_two_ennreal.elim hμs),\n    L2.inner_indicator_const_Lp_eq_set_integral_inner]\n\nvariables {𝕜}\n\n/-- The inner product in `L2` of the indicator of a set `indicator_const_Lp 2 hs hμs (1 : 𝕜)` and\na real or complex function `f` is equal to the integral of `f` over `s`. -/\nlemma inner_indicator_const_Lp_one (hs : measurable_set s) (hμs : μ s ≠ ∞) (f : Lp 𝕜 2 μ) :\n  ⟪indicator_const_Lp 2 hs hμs (1 : 𝕜), f⟫ = ∫ x in s, f x ∂μ :=\nby { rw L2.inner_indicator_const_Lp_eq_inner_set_integral 𝕜 hs hμs (1 : 𝕜) f, simp, }\n\nend indicator_const_Lp\n\nend L2\n\nsection inner_continuous\n\nvariables {α : Type*} [topological_space α] [measure_space α] [borel_space α] {𝕜 : Type*}\n  [is_R_or_C 𝕜]\nvariables (μ : measure α) [is_finite_measure μ]\n\nopen_locale bounded_continuous_function complex_conjugate\n\nlocal notation `⟪`x`, `y`⟫` := @inner 𝕜 (α →₂[μ] 𝕜) _ x y\n\n/-- For bounded continuous functions `f`, `g` on a finite-measure topological space `α`, the L^2\ninner product is the integral of their pointwise inner product. -/\nlemma bounded_continuous_function.inner_to_Lp (f g : α →ᵇ 𝕜) :\n  ⟪bounded_continuous_function.to_Lp 2 μ 𝕜 f, bounded_continuous_function.to_Lp 2 μ 𝕜 g⟫\n  = ∫ x, conj (f x) * g x ∂μ :=\nbegin\n  apply integral_congr_ae,\n  have hf_ae := f.coe_fn_to_Lp μ,\n  have hg_ae := g.coe_fn_to_Lp μ,\n  filter_upwards [hf_ae, hg_ae] with _ hf hg,\n  rw [hf, hg],\n  simp\nend\n\nvariables [compact_space α]\n\n/-- For continuous functions `f`, `g` on a compact, finite-measure topological space `α`, the L^2\ninner product is the integral of their pointwise inner product. -/\nlemma continuous_map.inner_to_Lp (f g : C(α, 𝕜)) :\n  ⟪continuous_map.to_Lp 2 μ 𝕜 f, continuous_map.to_Lp 2 μ 𝕜 g⟫\n  = ∫ x, conj (f x) * g x ∂μ :=\nbegin\n  apply integral_congr_ae,\n  have hf_ae := f.coe_fn_to_Lp μ,\n  have hg_ae := g.coe_fn_to_Lp μ,\n  filter_upwards [hf_ae, hg_ae] with _ hf hg,\n  rw [hf, hg],\n  simp\nend\n\nend inner_continuous\n\nend measure_theory\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/measure_theory/function/l2_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059560743422, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.49947798109476343}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nComputational realization of topological spaces (experimental).\n-/\nimport topology.bases\nimport data.analysis.filter\nopen set\nopen filter (hiding realizer)\nopen_locale topological_space\n\n/-- A `ctop α σ` is a realization of a topology (basis) on `α`,\n  represented by a type `σ` together with operations for the top element and\n  the intersection operation. -/\nstructure ctop (α σ : Type*) :=\n(f : σ → set α)\n(top : α → σ)\n(top_mem : ∀ x : α, x ∈ f (top x))\n(inter : Π a b (x : α), x ∈ f a ∩ f b → σ)\n(inter_mem : ∀ a b x h, x ∈ f (inter a b x h))\n(inter_sub : ∀ a b x h, f (inter a b x h) ⊆ f a ∩ f b)\n\nvariables {α : Type*} {β : Type*} {σ : Type*} {τ : Type*}\n\nnamespace ctop\nsection\nvariables (F : ctop α σ)\n\ninstance : has_coe_to_fun (ctop α σ) := ⟨_, ctop.f⟩\n\n@[simp] theorem coe_mk (f T h₁ I h₂ h₃ a) : (@ctop.mk α σ f T h₁ I h₂ h₃) a = f a := rfl\n\n/-- Map a ctop to an equivalent representation type. -/\ndef of_equiv (E : σ ≃ τ) : ctop α σ → ctop α τ\n| ⟨f, T, h₁, I, h₂, h₃⟩ :=\n  { f         := λ a, f (E.symm a),\n    top       := λ x, E (T x),\n    top_mem   := λ x, by simpa using h₁ x,\n    inter     := λ a b x h, E (I (E.symm a) (E.symm b) x h),\n    inter_mem := λ a b x h, by simpa using h₂ (E.symm a) (E.symm b) x h,\n    inter_sub := λ a b x h, by simpa using h₃ (E.symm a) (E.symm b) x h }\n\n@[simp] theorem of_equiv_val (E : σ ≃ τ) (F : ctop α σ) (a : τ) :\n  F.of_equiv E a = F (E.symm a) := by cases F; refl\n\nend\n\n/-- Every `ctop` is a topological space. -/\ndef to_topsp (F : ctop α σ) : topological_space α :=\ntopological_space.generate_from (set.range F.f)\n\ntheorem to_topsp_is_topological_basis (F : ctop α σ) :\n  @topological_space.is_topological_basis _ F.to_topsp (set.range F.f) :=\nby letI := F.to_topsp; exact\n⟨λ u ⟨a, e₁⟩ v ⟨b, e₂⟩, e₁ ▸ e₂ ▸\n   λ x h, ⟨_, ⟨_, rfl⟩, F.inter_mem a b x h, F.inter_sub a b x h⟩,\neq_univ_iff_forall.2 $ λ x, ⟨_, ⟨_, rfl⟩, F.top_mem x⟩, rfl⟩\n\n@[simp] theorem mem_nhds_to_topsp (F : ctop α σ) {s : set α} {a : α} :\n  s ∈ @nhds _ F.to_topsp a ↔ ∃ b, a ∈ F b ∧ F b ⊆ s :=\n(@topological_space.is_topological_basis.mem_nhds_iff\n  _ F.to_topsp _ _ _ F.to_topsp_is_topological_basis).trans $\n⟨λ ⟨_, ⟨x, rfl⟩, h⟩, ⟨x, h⟩, λ ⟨x, h⟩, ⟨_, ⟨x, rfl⟩, h⟩⟩\n\nend ctop\n\n/-- A `ctop` realizer for the topological space `T` is a `ctop`\n  which generates `T`. -/\nstructure ctop.realizer (α) [T : topological_space α] :=\n(σ : Type*)\n(F : ctop α σ)\n(eq : F.to_topsp = T)\nopen ctop\n\nprotected def ctop.to_realizer (F : ctop α σ) : @ctop.realizer _ F.to_topsp :=\n@ctop.realizer.mk _ F.to_topsp σ F rfl\n\nnamespace ctop.realizer\n\nprotected theorem is_basis [T : topological_space α] (F : realizer α) :\n  topological_space.is_topological_basis (set.range F.F.f) :=\nby have := to_topsp_is_topological_basis F.F; rwa F.eq at this\n\nprotected theorem mem_nhds [T : topological_space α] (F : realizer α) {s : set α} {a : α} :\n  s ∈ 𝓝 a ↔ ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=\nby have := mem_nhds_to_topsp F.F; rwa F.eq at this\n\ntheorem is_open_iff [topological_space α] (F : realizer α) {s : set α} :\n  is_open s ↔ ∀ a ∈ s, ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=\nis_open_iff_mem_nhds.trans $ ball_congr $ λ a h, F.mem_nhds\n\ntheorem is_closed_iff [topological_space α] (F : realizer α) {s : set α} :\n  is_closed s ↔ ∀ a, (∀ b, a ∈ F.F b → ∃ z, z ∈ F.F b ∩ s) → a ∈ s :=\nis_open_compl_iff.symm.trans $ F.is_open_iff.trans $ forall_congr $ λ a,\nshow (a ∉ s → (∃ (b : F.σ), a ∈ F.F b ∧ ∀ z ∈ F.F b, z ∉ s)) ↔ _,\nby haveI := classical.prop_decidable; rw [not_imp_comm];\n   simp [not_exists, not_and, not_forall, and_comm]\n\ntheorem mem_interior_iff [topological_space α] (F : realizer α) {s : set α} {a : α} :\n  a ∈ interior s ↔ ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=\nmem_interior_iff_mem_nhds.trans F.mem_nhds\n\nprotected theorem is_open [topological_space α] (F : realizer α) (s : F.σ) : is_open (F.F s) :=\nis_open_iff_nhds.2 $ λ a m, by simpa using F.mem_nhds.2 ⟨s, m, subset.refl _⟩\n\n\n\ntheorem ext [T : topological_space α] {σ : Type*} {F : ctop α σ}\n  (H₁ : ∀ a, is_open (F a))\n  (H₂ : ∀ a s, s ∈ 𝓝 a → ∃ b, a ∈ F b ∧ F b ⊆ s) :\n  F.to_topsp = T :=\next' $ λ a s, ⟨H₂ a s, λ ⟨b, h₁, h₂⟩, mem_nhds_sets_iff.2 ⟨_, h₂, H₁ _, h₁⟩⟩\n\nvariable [topological_space α]\n\nprotected def id : realizer α := ⟨{x:set α // is_open x},\n{ f            := subtype.val,\n  top          := λ _, ⟨univ, is_open_univ⟩,\n  top_mem      := mem_univ,\n  inter        := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃, ⟨_, is_open_inter h₁ h₂⟩,\n  inter_mem    := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a, id,\n  inter_sub    := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃, subset.refl _ },\next subtype.property $ λ x s h,\n  let ⟨t, h, o, m⟩ := mem_nhds_sets_iff.1 h in ⟨⟨t, o⟩, m, h⟩⟩\n\ndef of_equiv (F : realizer α) (E : F.σ ≃ τ) : realizer α :=\n⟨τ, F.F.of_equiv E, ext' (λ a s, F.mem_nhds.trans $\n ⟨λ ⟨s, h⟩, ⟨E s, by simpa using h⟩, λ ⟨t, h⟩, ⟨E.symm t, by simpa using h⟩⟩)⟩\n\n@[simp] theorem of_equiv_σ (F : realizer α) (E : F.σ ≃ τ) : (F.of_equiv E).σ = τ := rfl\n@[simp] theorem of_equiv_F (F : realizer α) (E : F.σ ≃ τ) (s : τ) :\n  (F.of_equiv E).F s = F.F (E.symm s) := by delta of_equiv; simp\n\nprotected def nhds (F : realizer α) (a : α) : (𝓝 a).realizer :=\n⟨{s : F.σ // a ∈ F.F s},\n{ f            := λ s, F.F s.1,\n  pt           := ⟨_, F.F.top_mem a⟩,\n  inf          := λ ⟨x, h₁⟩ ⟨y, h₂⟩, ⟨_, F.F.inter_mem x y a ⟨h₁, h₂⟩⟩,\n  inf_le_left  := λ ⟨x, h₁⟩ ⟨y, h₂⟩ z h, (F.F.inter_sub x y a ⟨h₁, h₂⟩ h).1,\n  inf_le_right := λ ⟨x, h₁⟩ ⟨y, h₂⟩ z h, (F.F.inter_sub x y a ⟨h₁, h₂⟩ h).2 },\nfilter_eq $ set.ext $ λ x,\n⟨λ ⟨⟨s, as⟩, h⟩, mem_nhds_sets_iff.2 ⟨_, h, F.is_open _, as⟩,\n λ h, let ⟨s, h, as⟩ := F.mem_nhds.1 h in ⟨⟨s, h⟩, as⟩⟩⟩\n\n@[simp] theorem nhds_σ (m : α → β) (F : realizer α) (a : α) :\n  (F.nhds a).σ = {s : F.σ // a ∈ F.F s} := rfl\n@[simp] theorem nhds_F (m : α → β) (F : realizer α) (a : α) (s) :\n  (F.nhds a).F s = F.F s.1 := rfl\n\ntheorem tendsto_nhds_iff {m : β → α} {f : filter β} (F : f.realizer) (R : realizer α) {a : α} :\n  tendsto m f (𝓝 a) ↔ ∀ t, a ∈ R.F t → ∃ s, ∀ x ∈ F.F s, m x ∈ R.F t :=\n(F.tendsto_iff _ (R.nhds a)).trans subtype.forall\n\nend ctop.realizer\n\nstructure locally_finite.realizer [topological_space α] (F : realizer α) (f : β → set α) :=\n(bas : ∀ a, {s // a ∈ F.F s})\n(sets : ∀ x:α, fintype {i | (f i ∩ F.F (bas x)).nonempty})\n\ntheorem locally_finite.realizer.to_locally_finite [topological_space α]\n  {F : realizer α} {f : β → set α} (R : locally_finite.realizer F f) :\n  locally_finite f :=\nλ a, ⟨_, F.mem_nhds.2\n  ⟨(R.bas a).1, (R.bas a).2, subset.refl _⟩, ⟨R.sets a⟩⟩\n\ntheorem locally_finite_iff_exists_realizer [topological_space α]\n  (F : realizer α) {f : β → set α} : locally_finite f ↔ nonempty (locally_finite.realizer F f) :=\n⟨λ h, let ⟨g, h₁⟩ := classical.axiom_of_choice h,\n    ⟨g₂, h₂⟩ := classical.axiom_of_choice (λ x,\n       show ∃ (b : F.σ), x ∈ (F.F) b ∧ (F.F) b ⊆ g x, from\n       let ⟨h, h'⟩ := h₁ x in F.mem_nhds.1 h) in\n  ⟨⟨λ x, ⟨g₂ x, (h₂ x).1⟩, λ x, finite.fintype $\n    let ⟨h, h'⟩ := h₁ x in h'.subset $ λ i hi,\n    hi.mono (inter_subset_inter_right _ (h₂ x).2)⟩⟩,\n λ ⟨R⟩, R.to_locally_finite⟩\n\ndef compact.realizer [topological_space α] (R : realizer α) (s : set α) :=\n∀ {f : filter α} (F : f.realizer) (x : F.σ), f ≠ ⊥ →\n  F.F x ⊆ s → {a // a∈s ∧ 𝓝 a ⊓ f ≠ ⊥}\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/analysis/topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4994779773665635}}
{"text": "inductive Foo : Nat -> Type  where\n| mk (a b : Nat) : Foo a -> Foo b\n\n#check @Foo.mk\nexample : (a b : Nat) → Foo a → Foo b := @Foo.mk\n\n#print Foo\n\nnamespace Ex2\n\ndef natToType : Nat → Type\n| 0 => Unit\n| _ => Bool\n\ninductive Foo : Nat → Char → Prop\n| mk (n : Nat) (elem : natToType n) (c : Char) : Foo n c\n\n#print Foo\n\nend Ex2\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/1156.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.793105941403651, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.49947797736656346}}
{"text": "class Foo (α : Type) where\n  decEq : DecidableEq α\n\ninstance instDecidableEq {α} [Foo α] : DecidableEq α := Foo.decEq\ninstance instFooNat : Foo Nat := ⟨by infer_instance⟩\n\ndef kron (i j : α) [DecidableEq α] : Nat := if (i=j) then 1 else 0\n\ntheorem kron_right_mul (α : Type) [foo : Foo α]  (i j : α) (x : Nat) : x * kron i j = kron i j * x := sorry\n\nexample {i j : Nat} : i * kron i j = kron i j * i := by\n  rw [kron_right_mul]\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/kronRWIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677583778257, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.49935899615026474}}
{"text": "import analysis.inner_product_space.pi_L2\nimport linear_algebra.affine_space.midpoint\nimport geometry.euclidean.basic\nimport geometry.euclidean.triangle\n\n/-\nBulgarian Mathematical Olympiad 1998, Problem 2\n\nA convex quadrilateral ABCD has AD = CD and ∠DAB = ∠ABC < 90°.\nThe line through D and the midpoint of BC intersects line AB\nin point E. Prove that ∠BEC = ∠DAC. (Note: The problem is valid\nwithout the assumption ∠ABC < 90°.)\n\n-/\n\nopen_locale euclidean_geometry\n\ntheorem bulgaria1998_q2\n    (A B C D E M: euclidean_space ℝ (fin 2))\n    (H1 : dist D A = dist D C)\n    (H2 : ∠ D A B = ∠ A B C)\n    (H3 : M = midpoint ℝ B C) :\n    ∠ B E C = ∠ D A C :=\nbegin\n  let x := ∠ D A C,\n  have : ∠ D A C = ∠ D C A := euclidean_geometry.angle_eq_angle_of_dist_eq H1,\n  let y := ∠ C A B,\n  have : ∠ A B C = x + y,\n  {\n    rw ← H2,\n    sorry, -- hm... might need the acuteness assumption, actually.\n  },\n  sorry\nend\n", "meta": {"author": "dwrensha", "repo": "math-puzzles-in-lean", "sha": "5f27604e4dc4ba97c346a65ce502c64566249269", "save_path": "github-repos/lean/dwrensha-math-puzzles-in-lean", "path": "github-repos/lean/dwrensha-math-puzzles-in-lean/math-puzzles-in-lean-5f27604e4dc4ba97c346a65ce502c64566249269/src/bulgaria1998_q2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.5888891307678319, "lm_q1q2_score": 0.49935899615026474}}
{"text": "/-\nAuthor: <Redacted for anonymized submission>\n-/\n-- import snarks.groth16.declarations\nimport ...attributes\nimport ...integral_domain_tactic\nimport ...general_lemmas.polynomial_degree\nimport data.mv_polynomial.basic\nimport data.mv_polynomial.funext\nimport data.polynomial.field_division\nimport algebra.polynomial.big_operators\n-- import ...attributes\nimport .vars\n\n/-!\n# Knowledge Soundness\n\nThis file proves the knowledge-soundness property of the Groth16 system for type III pairings, as \npresented in \"Another Look at Extraction and Randomization of Groth’s zk-SNARK\" by \n[Baghery et al.](https://eprint.iacr.org/2020/811.pdf).\n\n-/\n\nopen_locale big_operators classical\n\nsection groth16\n\n-- TODO we open mv_polynomial, so we should be able to delete a lot of `mv_polynomial.`\nopen mv_polynomial groth16\n\nnoncomputable theory\n\nuniverses u\n\n\n/-- The finite field parameter of our SNARK -/\nparameter {F : Type u}\nparameter [field F]\n\n/-- The naturals representing:\n  n_stmt - the statement size, \n  n_wit - the witness size -/ \nparameters {n_stmt n_wit n_var : ℕ}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt → (polynomial F) }\nparameter {u_wit : fin n_wit → (polynomial F) }\nparameter {v_stmt : fin n_stmt → (polynomial F) }\nparameter {v_wit : fin n_wit → (polynomial F) }\nparameter {w_stmt : fin n_stmt → (polynomial F) }\nparameter {w_wit : fin n_wit → (polynomial F) }\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit → F} \n/-- t is the polynomial divisibility by which is used to verify satisfaction of the SSP -/\ndef t : polynomial F := ∏ i in (finset.univ : finset (fin n_wit)), (polynomial.X - polynomial.C (r i))\n-- TODO this could potentially be spun off into a mathlib definition\n\n\n/-- Checks whether a statement witness pair satisfies the SSP -/\ndef satisfying (a_stmt : fin n_stmt → F ) (a_wit : fin n_wit → F) := \n((∑ i in (finset.univ : finset (fin n_stmt)), a_stmt i • u_stmt i\n  + (∑ i in (finset.univ : finset (fin n_wit)), a_wit i • u_wit i))\n  * \n(∑ i in (finset.univ : finset (fin n_stmt)), a_stmt i • v_stmt i\n  + (∑ i in (finset.univ : finset (fin n_wit)), a_wit i • v_wit i))\n  -\n(∑ i in (finset.univ : finset (fin n_stmt)), a_stmt i • w_stmt i\n  + (∑ i in (finset.univ : finset (fin n_wit)), a_wit i • w_wit i)))\n   %ₘ t = 0\n\n\nrun_cmd mk_simp_attr `crs\nrun_cmd tactic.add_doc_string `simp_attr.crs \"Attribute for defintions of CRS elements\"\n\n/-- The CRS elements \nThese funtions are actually multivariate Laurent polynomials of the toxic waste samples, \nbut we represent them here as functions on assignments of the variables to values.\n-/\n@[crs]\ndef crs_α  (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.α)\n@[crs]\ndef crs_β (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.β)\n@[crs]\ndef crs_γ (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.γ)\n@[crs]\ndef crs_δ (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.δ)\n@[crs]\ndef crs_powers_of_x (i : fin n_var) (f : groth16.vars → F) : polynomial F := ((polynomial.X)^(i : ℕ))\n@[crs]\ndef crs_l (i : fin n_stmt) (f : groth16.vars → F) : polynomial F := \npolynomial.C (1 / f vars.γ) * (polynomial.C (f vars.β / f vars.γ) * u_stmt i\n+\npolynomial.C  (f vars.α / f vars.γ) * v_stmt i\n+\n(w_stmt i)) \n@[crs]\ndef crs_m (i : fin n_wit) (f : groth16.vars → F) : polynomial F := \npolynomial.C (1 / f vars.δ) * (polynomial.C  (f vars.β / f vars.δ) * (u_wit i)\n+\npolynomial.C  (f vars.α / f vars.δ) * (v_wit i)\n+\n(w_wit i)) \n@[crs]\ndef crs_n (i : fin (n_var - 1)) (f : groth16.vars → F) : polynomial F := \n(polynomial.X)^(i : ℕ) * t * polynomial.C (1 / f vars.δ)\n\n/-- The coefficients of the CRS elements in the algebraic adversary's representation -/\nparameters {A_α A_β A_γ A_δ B_α B_β B_γ B_δ C_α C_β C_γ C_δ  : F}\nparameters {A_x B_x C_x : fin n_var → F}\nparameters {A_l B_l C_l : fin n_stmt → F}\nparameters {A_m B_m C_m : fin n_wit → F}\nparameters {A_h B_h C_h : fin (n_var-1) → F}\n\n\n/-- Polynomial forms of the adversary's proof representation -/\ndef A (f : groth16.vars → F) : polynomial F := \n  polynomial.C A_α * (crs_α f)\n  +\n  polynomial.C A_β * (crs_β f)\n  +\n  polynomial.C A_δ * crs_δ f\n  +\n  ∑ i in ((finset.univ : finset (fin n_var))), polynomial.C (A_x i) * (crs_powers_of_x i f)\n  +\n  ∑ i in (finset.univ : finset (fin n_stmt)), polynomial.C (A_l i) * (crs_l i f)\n  +\n  ∑ i in (finset.univ : finset (fin n_wit)), polynomial.C (A_m i) * (crs_m i f)\n  +\n  ∑ i in (finset.univ : finset (fin (n_var-1))), polynomial.C (A_h i) * (crs_n i f)\n\ndef B (f : groth16.vars → F) : polynomial F  := \n  polynomial.C B_β * crs_β f\n  + \n  polynomial.C B_γ * crs_γ f\n  +\n  polynomial.C B_δ * crs_δ f\n  +\n  ∑ i in ((finset.univ : finset (fin n_var))), polynomial.C (B_x i) * (crs_powers_of_x i f)\n\ndef C (f : groth16.vars → F) : polynomial F  := \n  polynomial.C C_α * crs_α f\n  +\n  polynomial.C C_β * crs_β f\n  +\n  polynomial.C C_δ * crs_δ f\n  +\n  ∑ i in ((finset.univ : finset (fin n_var))), polynomial.C (C_x i) * (crs_powers_of_x i f)\n  +\n  ∑ i in (finset.univ : finset (fin n_stmt)), polynomial.C (C_l i) * (crs_l i f)\n  +\n  ∑ i in (finset.univ : finset (fin n_wit)), polynomial.C (C_m i) * (crs_m i f)\n  +\n  ∑ i in (finset.univ : finset (fin (n_var-1))), polynomial.C (C_h i) * (crs_n i f)\n\n\nlocal notation `groth16polynomial` := mv_polynomial vars (polynomial F)\n\n\n/-- The modified CRS elements \nthese are multivariate (non-Laurent!) polynomials of the toxic waste samples, \nobtained by multiplying the Laurent polynomial forms of the CRS through by γ * δ. \nWe will later prove that the laurent polynomial equation is equivalent to a similar equation of the modified crs elements, allowing us to construct a proof in terms of polynomials -/\n@[crs]\ndef crs'_α  : groth16polynomial := X vars.α * X vars.γ * X vars.δ\n@[crs]\ndef crs'_β : groth16polynomial := X vars.β * X vars.γ * X vars.δ\n@[crs]\ndef crs'_γ : groth16polynomial := X vars.γ * X vars.γ * X vars.δ\n@[crs]\ndef crs'_δ : groth16polynomial := X vars.δ * X vars.γ * X vars.δ\n@[crs]\ndef crs'_powers_of_x (i : fin n_var) : (groth16polynomial) := mv_polynomial.C (polynomial.X ^ (i : ℕ)) * X vars.γ * X vars.δ\n@[crs]\ndef crs'_l (i : fin n_stmt) : (groth16polynomial) := \n(X vars.β * X vars.δ) * mv_polynomial.C (u_stmt i)\n+\n(X vars.α * X vars.δ) * mv_polynomial.C (v_stmt i)\n+\nX vars.δ * mv_polynomial.C (w_stmt i)\n@[crs]\ndef crs'_m (i : fin n_wit) : (groth16polynomial) := \n(X vars.β * X vars.γ) * mv_polynomial.C (u_wit i)\n+\n(X vars.α * X vars.γ) * mv_polynomial.C (v_wit i)\n+\nX vars.γ * mv_polynomial.C (w_wit i)\n@[crs]\ndef crs'_t (i : fin (n_var - 1)) : (groth16polynomial) := \nX vars.γ * mv_polynomial.C ((polynomial.X)^(i : ℕ) * t)\n\n\n/-- Polynomial form of A in the adversary's proof representation -/\ndef A'  : groth16polynomial := \n  crs'_α * mv_polynomial.C (polynomial.C (A_α))\n  +\n  crs'_β * mv_polynomial.C (polynomial.C (A_β))\n  + \n  crs'_δ * mv_polynomial.C (polynomial.C (A_δ))\n  +\n  X vars.γ * X vars.δ * mv_polynomial.C ∑ i in ((finset.univ : finset (fin n_var))), (polynomial.C (A_x i) * polynomial.X ^ (i : ℕ))\n  +\n  ∑ i in (finset.univ : finset (fin n_stmt)), (crs'_l i) * mv_polynomial.C (polynomial.C (A_l i))\n  +\n  ∑ i in (finset.univ : finset (fin n_wit)), (crs'_m i) * mv_polynomial.C (polynomial.C (A_m i))\n  +\n  ∑ i in (finset.univ : finset (fin (n_var-1))), (crs'_t i) * mv_polynomial.C (polynomial.C (A_h i))\n\n/-- Polynomial form of B in the adversary's proof representation -/\ndef B'  : groth16polynomial := \n  crs'_β * mv_polynomial.C (polynomial.C (B_β))\n  + \n  crs'_γ * mv_polynomial.C (polynomial.C (B_γ))\n  +\n  crs'_δ * mv_polynomial.C (polynomial.C (B_δ))\n  +\n  X vars.γ * X vars.δ * mv_polynomial.C ∑ i in ((finset.univ : finset (fin n_var))), (polynomial.C (B_x i) * polynomial.X ^ (i : ℕ))\n\n/-- Polynomial form of C in the adversary's proof representation -/\ndef C'  : groth16polynomial := \n  crs'_α * mv_polynomial.C (polynomial.C (C_α))\n  +\n  crs'_β * mv_polynomial.C (polynomial.C (C_β))\n  + \n  crs'_δ * mv_polynomial.C (polynomial.C (C_δ))\n  +\n  X vars.γ * X vars.δ * mv_polynomial.C ∑ i in ((finset.univ : finset (fin n_var))), (polynomial.C (C_x i) * polynomial.X ^ (i : ℕ))\n  +\n  ∑ i in (finset.univ : finset (fin n_stmt)), (crs'_l i) * mv_polynomial.C (polynomial.C (C_l i))\n  +\n  ∑ i in (finset.univ : finset (fin n_wit)), (crs'_m i) * mv_polynomial.C (polynomial.C (C_m i))\n  +\n  ∑ i in (finset.univ : finset (fin (n_var-1))), (crs'_t i) * mv_polynomial.C (polynomial.C (C_h i))\n\n\n\ndef verified (a_stmt : fin n_stmt → F ) : Prop := A * B = crs_α * crs_β + (∑ i in (finset.univ : finset (fin n_stmt)), a_stmt i • crs_l i ) * crs_γ + C * crs_δ\n\ndef verified' (a_stmt : fin n_stmt → F ) : Prop := A' * B' = crs'_α * crs'_β + (∑ i in (finset.univ : finset (fin n_stmt)), mv_polynomial.C (polynomial.C (a_stmt i)) * crs'_l i ) * crs'_γ + C' * crs'_δ\n\n-- TODO use this for lots of profiling data\n-- set_option profiler true\n\n/--\nThis lemma proves that the verification procedure succeeding on the unmodified (Laurent) CRS \nelements implies that it succeeds with the modified (mv_polynomial) CRS elements. This lets us put \nour hypotheses in terms of mv_polynomial equations.\n-/\nlemma modification_equivalence (a_stmt : fin n_stmt → F ) : \n  verified a_stmt -> verified' a_stmt\n:=\nbegin\n  -- TODO a few conditions likely still need to be added, such as degree bounds and the values \n  -- being nonzero.\n  sorry,\n  -- rw verified,\n  -- rw verified',\n  -- intro h,\n  -- rw function.funext_iff at h,\n  -- -- Apply functional extensionality\n  -- simp [A, B, C] at h,\n\n  -- rw mv_polynomial.funext_iff,\n  -- intro vars_evaluation,\n  -- simp [A', B', C'] with crs,\n  -- -- apply polynomial.funext, -- TODO prove a version of this lemma for degree bounded polynomials on non infinite fields.\n  -- -- intro x_evaluation,\n  -- -- simp,\n  -- -- simp [A', B', C'],\n  -- -- simp with crs,\n\n  -- have h2 := h vars_evaluation,\n  -- done,\n\nend\n\n\nopen finsupp\n\n\n\nlemma A_α_mul (p : polynomial F) : p * polynomial.C A_α  = polynomial.C A_α * p := by ring\n\nlemma B_β_mul (p : polynomial F) : p * polynomial.C B_β  = polynomial.C B_β * p := by ring\n\n-- TODO Add to Mathlib next to C_eq_zero\n@[simp] lemma polynomial.C_eq_one (a : F) : polynomial.C a = 1 ↔ a = 1 :=\ncalc polynomial.C a = 1 ↔ polynomial.C a = polynomial.C 1 : by rw polynomial.C_1\n         ... ↔ a = 1 : polynomial.C_inj\n\n\nlemma simplifier1 (x : fin n_stmt) (a_stmt : fin n_stmt → F ) \n  : polynomial.C (a_stmt x) * u_stmt x = u_stmt x * polynomial.C (a_stmt x)\n  :=\n  by ring\n\nlemma simplifier2 (x : fin n_stmt) (a_stmt : fin n_stmt → F ) \n  : polynomial.C (a_stmt x) * v_stmt x = v_stmt x * polynomial.C (a_stmt x)\n  :=\n  by ring\n\nlemma polynomial.mul_mod_by_monic (t p : polynomial F) (mt : t.monic) : (t * p) %ₘ t = 0 :=\nbegin\n  rw polynomial.dvd_iff_mod_by_monic_eq_zero,\n  apply dvd_mul_right,\n  exact mt,\nend\n\nset_option trace.simp_lemmas true\n\n/-- The main theorem for the soundness of the Groth '16 SNARK. \nThis shows that if the adversary polynomials obey the equations that the verification suggests,\nthen the C_m coefficients give a satisfying witness. -/\ntheorem soundness (a_stmt : fin n_stmt → F ) : \n  verified a_stmt\n  -> (satisfying a_stmt C_m)\n:=\nbegin\n  \n  intros eqn,\n  rw satisfying,\n  simp only [polynomial.smul_eq_C_mul, rearrange_constants_right_hard],\n  suffices : \n    (∑ (i : fin n_stmt) in finset.univ, u_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.univ, u_wit i * polynomial.C (C_m i)) \n    * \n    (∑ (i : fin n_stmt) in finset.univ, v_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.univ, v_wit i * polynomial.C (C_m i)) \n    = \n    (∑ (i : fin n_stmt) in finset.univ, w_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.univ, w_wit i * polynomial.C (C_m i)) \n    +\n    ∑ (x : fin (n_var - 1)) in finset.univ, polynomial.X ^ (x : ℕ) * t * polynomial.C (C_h x),\n  {\n    rw <-sub_eq_iff_eq_add' at this,\n    have h := congr_arg (%ₘ t) this,\n    simp only at h,\n    rw h,\n    clear this h,\n    conv\n    begin\n      to_lhs,\n      congr,\n      congr,\n      skip,\n      funext,\n      rw mul_comm,   \n      rw <-mul_assoc,\n      skip,   \n    end,\n    rw <-finset.sum_mul,\n    rw mul_comm,\n    apply polynomial.mul_mod_by_monic,\n    rw t,\n    apply monic_of_product_form,\n  },\n\n\n\n  -- Step 0: Modify the hypothesis to be an equation of mv_polynomials\n  have eqn' := modification_equivalence a_stmt (eqn),\n  -- done,\n\n  -- Step 1: Obtain the coefficient equations of the mv_polynomials\n\n  rw verified' at eqn',\n  rw [A', B', C'] at eqn',\n  simp only [] with crs at eqn',\n  -- simp only [mv_polynomial.X, C_apply, mv_polynomial.monomial_mul, one_mul, mul_one, add_zero, zero_add, finset.sum_add_distrib, finset.sum_hom, mul_add, add_mul, sum_monomial_hom] at eqn',\n\n  have h0012 := congr_arg (coeff (single vars.α 0 + single vars.β 0 + single vars.γ 1 + single vars.δ 2)) eqn',\n  have h0021 := congr_arg (coeff (single vars.α 0 + single vars.β 0 + single vars.γ 2 + single vars.δ 1)) eqn',\n  have h0022 := congr_arg (coeff (single vars.α 0 + single vars.β 0 + single vars.γ 2 + single vars.δ 2)) eqn',\n  have h0112 := congr_arg (coeff (single vars.α 0 + single vars.β 1 + single vars.γ 1 + single vars.δ 2)) eqn',\n  have h0121 := congr_arg (coeff (single vars.α 0 + single vars.β 1 + single vars.γ 2 + single vars.δ 1)) eqn',\n  have h0122 := congr_arg (coeff (single vars.α 0 + single vars.β 1 + single vars.γ 2 + single vars.δ 2)) eqn',\n  have h0212 := congr_arg (coeff (single vars.α 0 + single vars.β 2 + single vars.γ 1 + single vars.δ 2)) eqn',\n  have h0221 := congr_arg (coeff (single vars.α 0 + single vars.β 2 + single vars.γ 2 + single vars.δ 1)) eqn',\n  have h0222 := congr_arg (coeff (single vars.α 0 + single vars.β 2 + single vars.γ 2 + single vars.δ 2)) eqn',\n  have h1022 := congr_arg (coeff (single vars.α 1 + single vars.β 0 + single vars.γ 2 + single vars.δ 2)) eqn',\n  -- have h1023 := congr_arg (coeff (single vars.α 1 + single vars.β 0 + single vars.γ 2 + single vars.δ 3)) eqn', -- not needed\n  have h1112 := congr_arg (coeff (single vars.α 1 + single vars.β 1 + single vars.γ 1 + single vars.δ 2)) eqn',\n  have h1121 := congr_arg (coeff (single vars.α 1 + single vars.β 1 + single vars.γ 2 + single vars.δ 1)) eqn',\n  have h1122 := congr_arg (coeff (single vars.α 1 + single vars.β 1 + single vars.γ 2 + single vars.δ 2)) eqn',\n\n  clear eqn eqn',\n\n  simp only [finsupp_vars_eq_ext] with coeff_simp finsupp_eq at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n  simp only [] with finsupp_simp at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n\n\n  -- Step 2: Recursively simplify and case-analyze the equations\n  \n  trace \"Moving Cs right\",\n  simp only [simplifier1, simplifier2] at *,\n\n  trace \"Grouping distributivity\",\n  simp only [<-mul_add, <-add_mul, <-add_assoc, add_mul_distrib, add_mul_distrib'] at *,\n\n  -- done,\n\n  trace \"Main simplification\",\n  simp only [*] with integral_domain_simp at *,\n  tactic.integral_domain_tactic_v4,\n\n  -- done,\n\n\n  -- Solve remaining cases by hand\n  { rw [<-h1022, <-h0122, <-h0022],\n    simp only [B_β_mul],\n    simp only [<-mul_assoc],\n    simp only [A_α_mul],\n    simp only [<-mul_assoc],\n    rw h1122,\n    ring, },\n\n\n\n\nend \n\nend groth16\n\n\n\n", "meta": {"author": "BoltonBailey", "repo": "formal-snarks-project", "sha": "154414784f90a1e257162fcbdd7e805ecb2a49c2", "save_path": "github-repos/lean/BoltonBailey-formal-snarks-project", "path": "github-repos/lean/BoltonBailey-formal-snarks-project/formal-snarks-project-154414784f90a1e257162fcbdd7e805ecb2a49c2/src/snarks/groth16typeIII/knowledge_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677468516187, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.49935898936260675}}
{"text": "import tactic.to_int\n\nexample (a b c d : ℕ)\n  (h : a + b ≥ c)\n  (h₀ : a ∣ c)\n  (h' : a + c + 17 ≥ d)\n  (sol : a * c ≤ b + d * c) :\n  a * c ≤ b + d * c :=\nbegin\n  to_int,\n    -- a : ℤ,\n    -- a_nneg : a ≥ 0,\n    -- b : ℤ,\n    -- b_nneg : b ≥ 0,\n    -- c : ℤ,\n    -- c_nneg : c ≥ 0,\n    -- d : ℤ,\n    -- d_nneg : d ≥ 0,\n    -- h : a + b ≥ c,\n    -- h₀ : a ∣ c,\n    -- h' : a + c + 17 ≥ d\n    -- ⊢ a * c ≤ b + d * c\n  guard_hyp a := ℤ,\n  guard_hyp b := ℤ,\n  guard_hyp c := ℤ,\n  guard_hyp d := ℤ,\n  guard_hyp h := a + b ≥ c,\n  guard_target a * c ≤ b + d * c,\n  exact sol\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib-nursery", "sha": "0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec", "save_path": "github-repos/lean/leanprover-community-mathlib-nursery", "path": "github-repos/lean/leanprover-community-mathlib-nursery/mathlib-nursery-0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec/test/tactic/to_int.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677430095496, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.499358987100054}}
{"text": "/-\nCopyright (c) 2021 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang\n-/\nimport algebra.category.CommRing\nimport algebra.category.Module.basic\nimport linear_algebra.tensor_product\n\nopen_locale tensor_product\n\nnamespace change_of_rings\n\nnamespace restriction_of_scalars\n\nuniverse u\n\nvariables {R S : CommRing.{u}} -- [ring R] [ring S] -- (f : R →+* S)\nvariable (f : R ⟶ S)\nvariables (N : Module S) -- [add_comm_monoid N] [module S N]\ninclude f\n\n@[reducible] def module :\n  Module R :=\n{ carrier := N,\n  is_module := module.comp_hom _ f, }.\nlocalized \"notation f `^*` N := restriction_of_scalars.module f N\" in change_of_rings\n\ndef is_module : _root_.module R N := (f ^* N).is_module\n\nlocalized \"attribute [instance] restriction_of_scalars.is_module\" in change_of_rings\n\n\ninstance has_scalar' : _root_.has_scalar S (f ^* N) :=\n{ smul := λ s n, @has_scalar.smul S N _ s n }.\n\n@[simp] lemma smul_def' (r : R) (n : f ^* N) : r • n = f r • n := rfl\n@[simp] lemma smul_def (r : R) (n : N) :\n  @has_scalar.smul R N begin\n    haveI := is_module f N,\n    apply_instance,\n  end r n = f r • n := rfl\n\ndef compatible_smul (N₁ N₂ : Module S) :\n  let m1 := is_module f N₁,\n      m2 := is_module f N₂,\n      m3 := is_module f ⟨S⟩ in\n  begin\n    resetI,\n    exact linear_map.compatible_smul N₁ N₂ R S\n  end :=\nlet m1 := is_module f N₁,\n    m2 := is_module f N₂,\n    m3 := is_module f ⟨S⟩ in\nbegin\n  resetI,\n  fconstructor,\n  intros g r n,\n  calc  g (r • n)\n      = g (f r • n) : by congr' 1\n    ... = f r • g n : by { erw linear_map.map_smul, },\nend\n/--restriction of scalar is a functor from `S`-modules to `R`-modules.-/\ndef functor : Module S ⥤ Module R :=\n{ obj := λ N, f ^* N,\n  map := λ N₁ N₂ l,\n  let m1 := is_module f N₁,\n      m2 := is_module f N₂,\n      m3 := is_module f ⟨S⟩,\n      m4 := compatible_smul f N₁ N₂ in\n  begin\n    dsimp only at m4,\n    resetI,\n    exact linear_map.restrict_scalars R l,\n  end }.\n\nlocalized \"notation f `⥤^*` M := (restriction_of_scalars.functor f).obj M\" in change_of_rings\n\nend restriction_of_scalars\n\nnamespace extension_of_scalars\n\nopen category_theory tensor_product\n\nuniverse u\n\nvariables {R S : CommRing.{u}} (f : R ⟶ S) (M : Module R)\ninclude f\n\n-- /--\n-- This action gives `S` an `R`-module strucutre\n-- -/\n-- def is_R_mod_S : module R S := restriction_of_scalars.is_module ⟨S⟩ f\n\n-- localized \"attribute [instance] extension_of_scalars.is_R_mod_S\" in change_of_rings\n\n-- @[simp] lemma smul_def (r : R) (s : S) :\n--   @has_scalar.smul _ _ begin\n--     haveI := is_R_mod_S f,\n--     resetI,\n--     apply_instance\n--   end r s = f r * s := rfl\n\n\ninclude M\nlocalized \"notation M `⊗[` R `,` f `]` S := @tensor_product R _ M S _ _ _\n  (restriction_of_scalars.is_module f ⟨S⟩)\" in change_of_rings\nlocalized \"notation m `⊗ₜ[` R `,` f `]` s := @tensor_product.tmul R _ _ _ _ _ _\n  (restriction_of_scalars.is_module f ⟨_⟩) m s\" in change_of_rings\n\ndef smul_by (s : S) : (M ⊗[R, f] S) ⟶ (M ⊗[R, f] S) :=\nlet m : module R S := restriction_of_scalars.is_module f ⟨S⟩ in\nbegin\n  resetI,\n  refine tensor_product.lift _,\n  refine ⟨_, _, _⟩,\n  { -- we define `m ↦ (s' ↦ m ⊗ (s * s'))`\n    refine λ m, ⟨λ s', m ⊗ₜ[R, f] (s * s'), _, _⟩,\n    { -- map_add\n      intros,\n      erw [mul_add, tmul_add], },\n    { -- map_smul\n      intros,\n      rw [ring_hom.id_apply, smul_tmul', smul_tmul],\n      congr' 1,\n      rw [restriction_of_scalars.smul_def f ⟨S⟩, smul_eq_mul, ← mul_assoc, mul_comm s,\n        mul_assoc, restriction_of_scalars.smul_def f ⟨S⟩, smul_eq_mul],\n    }, },\n  { intros,\n    ext,\n    simp only [linear_map.coe_mk, map_add, add_tmul],\n    refl, },\n  { intros,\n    ext,\n    simp only [linear_map.coe_mk, ring_hom.id_apply, linear_map.smul_apply],\n    rw [tensor_product.smul_tmul'], }\nend.\n\nlemma smul_by.pure_tensor (s s' : S) (m : M) :\n  (smul_by f M s (m ⊗ₜ[R, f] s')) =\n  m ⊗ₜ[R, f] (s * s') :=\nbegin\n  simp only [smul_by, tensor_product.lift.tmul, linear_map.coe_mk],\nend\n\nlemma smul_by.one : smul_by f M 1 = 𝟙 _ :=\nbegin\n  ext,\n  induction x using tensor_product.induction_on with _ _ _ _ ih1 ih2,\n  { simpa only [smul_by, map_zero], },\n  { simpa only [smul_by.pure_tensor, one_mul], },\n  { simp only [category_theory.types_id_apply] at ih1 ih2 ⊢,\n    conv_rhs { rw [← ih1, ← ih2] },\n    convert map_add _ _ _, },\nend.\n\nlemma smul_by.mul (s s' : S) : smul_by f M (s * s') = smul_by f M s' ≫ smul_by f M s :=\nbegin\n  ext,\n  induction x using tensor_product.induction_on with _ _ x y ih1 ih2,\n  { simp only [smul_by, map_zero, types_comp_apply], },\n  { simp [smul_by, mul_assoc], },\n  { convert congr_arg2 (+) ih1 ih2 using 1,\n    { convert map_add _ _ _ },\n    { simp only [types_comp_apply],\n      calc  smul_by f M s (smul_by f M s' (x + y))\n          = smul_by f M s (smul_by f M s' x + smul_by f M s' y)\n          : by { congr' 1, convert map_add _ _ _}\n      ... = smul_by f M s (smul_by f M s' x) + smul_by f M s (smul_by f M s' y)\n          : by convert map_add _ _ _, }, }\nend.\n\nlemma smul_by.apply_zero (s : S) : smul_by f M s 0 = 0 :=\nby simp only [smul_by, map_zero]\n\nlemma smul_by.apply_add (s : S) (a b) : smul_by f M s (a + b) = smul_by f M s a + smul_by f M s b :=\nby simp [smul_by, map_add]\n\n\nlemma smul_by.add (s s') : smul_by f M (s + s') = smul_by f M s + smul_by f M s' :=\nbegin\n  ext x,\n  induction x using tensor_product.induction_on with _ _ x y ih1 ih2,\n  { simp [smul_by], },\n  { simp [smul_by, add_mul, tmul_add], },\n  { simp only [pi.add_apply, smul_by.apply_add, ih1, ih2],\n    rw show ∀ (a b c d : M ⊗[R, f] S), a + b + (c + d) = a + c + (b + d), from _,\n    intros,\n    -- `ring` doesn't work here for some reason\n    rw calc a + b + (c + d) = a + (b + (c + d)) : by rw add_assoc\n      ... = a + (b + c + d) : by rw add_assoc\n      ... = a + (c + b + d) : by rw add_comm b c\n      ... = a + (c + (b + d)) : by rw add_assoc\n      ... = a + c + (b + d) : by rw add_assoc, }\nend.\n\nlemma smul_by.zero : smul_by f M 0 = 0 :=\nbegin\n  ext,\n  induction x using tensor_product.induction_on with _ _ x y ih1 ih2,\n  { simp [smul_by], },\n  { simp [smul_by], },\n  { simp [smul_by.apply_add, ih1, ih2], }\nend.\n\n/--\nSince `S` has an `R`-module structure, `M ⊗[R] S` can be given an `S`-module structure.\nThe scalar multiplication is defined by `s • (m ⊗ s') := m ⊗ (s * s')`\n-/\n@[reducible] def has_scalar_S_M_tensor_S : _root_.has_scalar S (M ⊗[R, f] S) :=\n{ smul := λ s', smul_by f M s' }\n\nlocal attribute [instance] has_scalar_S_M_tensor_S\n\nlemma smul_pure_tensor (s s' : S) (m : M) :\n  (s • (m ⊗ₜ[R, f] s')) =\n  m ⊗ₜ[R, f] (s * s') :=\nby simp only [smul_by, tensor_product.lift.tmul, linear_map.coe_mk]\n\n@[simp] lemma smul_zero (s : S) : s • (0 : M ⊗[R, f] S) = 0 :=\nby simp [smul_by]\n\n/--\nSee above\n-/\ndef mul_action_S_M_tensor_S : _root_.mul_action S (M ⊗[R, f] S) :=\n{ one_smul := λ x, begin\n    change smul_by _ _ _ _ = _,\n    rw smul_by.one f M,\n    refl,\n  end,\n  mul_smul := λ s s' x, begin\n    change smul_by _ _ _ _ = smul_by _ _ _ (smul_by _ _ _ _),\n    rw smul_by.mul f M,\n    refl,\n  end,\n  ..(has_scalar_S_M_tensor_S f M) }.\n\nlocalized \"attribute [instance] extension_of_scalars.mul_action_S_M_tensor_S\" in change_of_rings\n\ndef distrib_mul_action_S_M_tensor_S : _root_.distrib_mul_action S (M ⊗[R, f] S) :=\n{ smul_zero := λ s, by { change smul_by f M s 0 = 0, apply smul_by.apply_zero, },\n  smul_add := λ s x y, begin\n    change smul_by f M s (x + y) = smul_by f M s x + smul_by f M s y,\n    apply smul_by.apply_add,\n  end }\n\ndef is_module : module S (M ⊗[R, f] S) :=\n{ add_smul := λ s s' x, begin\n    change smul_by _ _ _ _ = smul_by _ _ _ _ + smul_by _ _ _ _,\n    rw smul_by.add,\n    refl,\n  end,\n  zero_smul := λ x, begin\n    change smul_by _ _ _ _ = _,\n    rw smul_by.zero,\n    refl,\n  end,\n  ..(distrib_mul_action_S_M_tensor_S f M) }.\n\ndef is_module' : module R (M ⊗[R, f] S) :=\ninfer_instance\n\n-- def compatible_smul (M1 M2 : Module R) :\n--   linear_map.compatible_smul (M1 ⊗[R, f] S) (M2 ⊗[R, f] S) S R :=\n-- let im1 : module R S := restriction_of_scalars.is_module f ⟨S⟩,\n--     im2 : module S (M1 ⊗[R, f] S) := is_module f M1,\n--     im3 : module S (M2 ⊗[R, f] S) := is_module f M2 in\n-- ⟨λ g s x, begin\n--   resetI,\n--   induction x using tensor_product.induction_on with m1 s' z1 z2 ih1 ih2,\n--   { simp [smul_by.apply_zero], },\n--   { simp only [smul_by.pure_tensor],\n--     revert s,\n--     induction g (m1 ⊗ₜ[R, f] s') using tensor_product.induction_on,\n--     rw ← lift.equiv_symm_apply R M1 S (M2 ⊗[R, f] S) g m1 (s * s'),\n--     rw ← lift.equiv_symm_apply R M1 S (M2 ⊗[R, f] S) g m1 s',\n--     -- dsimp only,\n--     -- squeeze_dsimp,\n--     -- type_check (tensor_product.lift.equiv R M1 S (M2 ⊗[R, f] S)).symm g m1 s,\n--     sorry },\n--   { erw [map_add, smul_add s z1 z2, map_add, ih1, ih2, smul_add s (g z1) (g z2)],\n--     refl, },\n-- end⟩\n\nlocalized \"attribute [instance] extension_of_scalars.is_module extension_of_scalars.is_module'\"\n  in change_of_rings\n/--\nSee above\n-/\ndef module : Module S :=\n{ carrier := M ⊗[R, f] S,\n  is_module := is_module f M }\n\nlocalized \"notation f `_*` M := extension_of_scalars.module f M\" in change_of_rings\n\nomit M\n/--\nExtension of scalars is a functor where an `R`-module `M` is sent to `M ⊗ S` and\n`l : M1 ⟶ M2` is sent to `m ⊗ s ↦ l m ⊗ s`\n-/\ndef map {M1 M2 : Module R} (l : M1 ⟶ M2) : (f _* M1) ⟶ (f _* M2) :=\nlet im1 : _root_.module R S := restriction_of_scalars.is_module f ⟨S⟩,\n    im2 : _root_.module R (f _* M2) := is_module' f M2 in\nbegin\n  resetI,\n  refine\n    { to_fun := tensor_product.lift { to_fun := λ m1, _, map_add' := _, map_smul' := _ },\n      map_add' := _,\n      map_smul' := _ },\n  { -- `S ⟶ f _* M2` given by `s ↦ l m ⊗ s`\n    refine { to_fun := λ s, (l m1) ⊗ₜ[R, f] s, map_add' := _, map_smul' := _ },\n    { -- map_add\n      intros,\n      rw [tmul_add], },\n    { -- map_smul\n      intros,\n      rw [ring_hom.id_apply, restriction_of_scalars.smul_def f ⟨S⟩ r x, smul_tmul',\n        smul_tmul],\n      refl, } },\n  { intros m m',\n    ext s,\n    simp [add_tmul], },\n  { intros r m,\n    ext s,\n    simp [smul_tmul], },\n  { intros z1 z2,\n    simp, },\n  { intros s z,\n    induction z using tensor_product.induction_on with _ _ z1 z2 ih1 ih2,\n    { simp [smul_zero], },\n    { simp [smul_pure_tensor], },\n    { rw [smul_add, map_add, ring_hom.id_apply, ih1, ih2, map_add, smul_add,\n        ring_hom.id_apply], } }\nend.\n\n/--\nThe functor extension of scalars\n-/\ndef functor : Module.{u} R ⥤ Module.{u} S :=\n{ obj := λ M, f _* M,\n  map := λ M1 M2 l, map f l,\n  map_id' := λ M, begin\n    ext x,\n    rw [map, Module.id_apply],\n    induction x using tensor_product.induction_on with _ _ m s ihx ihy,\n    { rw map_zero },\n    { rw [linear_map.coe_mk, tensor_product.lift.tmul], refl, },\n    { rw [linear_map.coe_mk] at ihx ihy ⊢,\n      rw [map_add, ihx, ihy], }\n  end,\n  map_comp' := λ M1 M2 M3 g h, begin\n    ext x,\n    rw [map, map, map, linear_map.coe_mk, category_theory.comp_apply,\n      linear_map.coe_mk, linear_map.coe_mk],\n    induction x using tensor_product.induction_on with _ _ m s ihx ihy,\n    { rw [map_zero, map_zero, map_zero], },\n    { rw [tensor_product.lift.tmul, tensor_product.lift.tmul], refl, },\n    { rw [map_add, ihx, ihy, map_add, map_add], }\n  end }.\n\nlocalized \"notation f `⥤_*` M := (extension_of_scalars.functor f).obj M\" in change_of_rings\n\nend extension_of_scalars\n\nsection adjunction\n\nuniverse u\n\nopen category_theory tensor_product\nopen_locale change_of_rings\n\nvariables {R S : CommRing.{u}} (f : R ⟶ S) (X : Module.{u} R) (Y : Module.{u} S)\n\ndef backward (g : X ⟶ (f ⥤^* Y)) :\n  (f ⥤_* X) ⟶ Y :=\n{ to_fun := λ z,\n  let m1 := restriction_of_scalars.is_module f ⟨S⟩,\n      m2 : module R Y := restriction_of_scalars.is_module f Y,\n      m3 : module S (f ⥤^* Y) := Y.is_module in\n  begin\n    resetI,\n    refine tensor_product.lift\n      { to_fun := λ x,\n          { to_fun := λ s, _,\n            map_add' := _,\n            map_smul' := _, },\n        map_add' := _,\n        map_smul' := _ } z,\n    { -- `x ⊗ s ↦ s • g x` in Y\n      exact s • (g x : Y) },\n    { intros, rw add_smul, },\n    { intros r s,\n      rw [ring_hom.id_apply],\n      calc  (r • s) • g x\n          = (f r * s) • g x : rfl\n      ... = f r • s • g x : by rw [mul_smul], },\n    { intros x y,\n      ext s,\n      simp only [linear_map.coe_mk, smul_add, linear_map.add_apply, map_add], },\n    { intros r x,\n      ext s,\n      simp only [linear_map.coe_mk, ring_hom.id_apply, linear_map.smul_apply,\n        linear_map.map_smul],\n      erw [← mul_smul, mul_comm, mul_smul],\n      refl, },\n  end,\n  map_add' := λ z1 z2, by simp only [map_add],\n  map_smul' := λ r z, begin\n    rw [ring_hom.id_apply],\n    induction z using tensor_product.induction_on with x y x y ih1 ih2,\n    { simp only [smul_zero, map_zero], },\n    { erw [extension_of_scalars.smul_pure_tensor],\n      simp [tensor_product.lift.tmul, mul_smul], },\n    { simp only [smul_add, map_add],\n      dsimp only at ih1 ih2,\n      rw [ih1, ih2], },\n  end }.\n\ndef forward (g : (f ⥤_* X) ⟶ Y) :\n  X ⟶ (f ⥤^* Y) :=\nlet m1 : module R S := restriction_of_scalars.is_module f ⟨S⟩,\n    m2 : module R Y := restriction_of_scalars.is_module f Y in\n{ to_fun := λ x, g (x ⊗ₜ[R, f] 1),\n  map_add' := λ x x', by rw [tensor_product.add_tmul, map_add],\n  map_smul' := λ r x, begin\n    resetI,\n    rw [ring_hom.id_apply],\n    calc  g ((r • x) ⊗ₜ[R, f] (1 : S))\n        = g (x ⊗ₜ[R, f] (r • 1)) : by rw smul_tmul\n    ... = g (x ⊗ₜ[R, f] (f r • 1)) : by rw restriction_of_scalars.smul_def f ⟨S⟩\n    ... = g (f r • (x ⊗ₜ[R, f] 1)) : by congr' 1\n    ... = f r • g (x ⊗ₜ[R, f] 1) : by rw linear_map.map_smul\n    ... = r • g (x ⊗ₜ[R, f] 1) : rfl,\n  end }.\n\ndef equiv :\n  ((extension_of_scalars.functor f).obj X ⟶ Y) ≃ (X ⟶ (restriction_of_scalars.functor f).obj Y) :=\n{ to_fun := forward f X Y,\n  inv_fun := backward f X Y,\n  left_inv := λ g, begin\n    ext z,\n    induction z using tensor_product.induction_on with x s z1 z2 ih1 ih2,\n    { simp only [map_zero], },\n    { erw tensor_product.lift.tmul,\n      simp only [linear_map.coe_mk],\n      change s • g _ = _,\n      rw [← linear_map.map_smul, extension_of_scalars.smul_pure_tensor, mul_one], },\n    { rw [map_add, map_add, ih1, ih2], }\n  end,\n  right_inv := λ g, begin\n    ext,\n    unfold forward backward,\n    simp only [linear_map.coe_mk, tensor_product.lift.tmul, one_smul],\n  end }.\n\ndef unit.map : X ⟶ ((extension_of_scalars.functor f ⋙ restriction_of_scalars.functor f).obj X) :=\nlet m1 : module R S := restriction_of_scalars.is_module f ⟨S⟩ in\n{ to_fun := λ x, x ⊗ₜ[R, f] 1,\n  map_add' := λ x x', by { rw tensor_product.add_tmul, },\n  map_smul' := λ r x, begin\n    resetI,\n    erw [smul_tmul, extension_of_scalars.smul_pure_tensor],\n    congr,\n  end }.\n\ndef unit : 𝟭 (Module ↥R) ⟶ extension_of_scalars.functor f ⋙ restriction_of_scalars.functor f :=\n{ app := unit.map f,\n  naturality' := λ X X' g, begin\n    ext,\n    simp only [unit.map, functor.id_map, Module.coe_comp, linear_map.coe_mk,\n      function.comp_app, functor.comp_map],\n    rw show (restriction_of_scalars.functor f).map ((extension_of_scalars.functor f).map g) =\n      { to_fun := (extension_of_scalars.functor f).map g, map_add' := _, map_smul' := _ }, from rfl,\n    simp only [linear_map.coe_mk],\n    erw tensor_product.lift.tmul,\n    simp only [linear_map.coe_mk],\n  end }\n\ndef counit.map : (restriction_of_scalars.functor f ⋙ extension_of_scalars.functor f).obj Y ⟶ Y :=\nlet m1 : module R S := restriction_of_scalars.is_module f ⟨S⟩,\n    m2 : module R Y := restriction_of_scalars.is_module f Y in\n{ to_fun :=\n    begin\n      resetI,\n      refine tensor_product.lift\n        { to_fun := λ y,\n            { to_fun := λ s, _,\n              map_add' := _,\n              map_smul' := _ },\n          map_add' := _,\n          map_smul' := _ },\n      { exact s • (y : Y), },\n      { intros s s', rw add_smul, },\n      { intros r s,\n        rw [ring_hom.id_apply, restriction_of_scalars.smul_def,\n          restriction_of_scalars.smul_def f ⟨S⟩ r s, smul_eq_mul, mul_smul], },\n      { intros y1 y2,\n        ext,\n        simp only [linear_map.coe_mk, smul_add, linear_map.add_apply], },\n      { intros r y,\n        ext s,\n        simp only [ring_hom.id_apply, restriction_of_scalars.smul_def',\n          linear_map.coe_mk, linear_map.smul_apply],\n        erw [← mul_smul, mul_comm, mul_smul],\n        refl, },\n    end,\n  map_add' := λ z1 z2, by simp only [map_add],\n  map_smul' := λ s z, begin\n    simp only [ring_hom.id_apply],\n    induction z using tensor_product.induction_on with x s' z1 z2 ih1 ih2,\n    { simp only [smul_zero, map_zero], },\n    { erw extension_of_scalars.smul_pure_tensor,\n      simp only [linear_map.coe_mk, tensor_product.lift.tmul],\n      rw mul_smul, },\n    { rw [smul_add, map_add, map_add, ih1, ih2, smul_add], },\n  end }.\n\ndef counit : (restriction_of_scalars.functor f ⋙ extension_of_scalars.functor f) ⟶ (𝟭 _) :=\n{ app := counit.map f,\n  naturality' := λ Y Y' g, begin\n    ext z,\n    simp only [functor.comp_map, Module.coe_comp, function.comp_app, functor.id_map],\n    induction z using tensor_product.induction_on with y s z1 z2 ih1 ih2,\n    { simp only [map_zero], },\n    { unfold counit.map,\n      erw [tensor_product.lift.tmul, tensor_product.lift.tmul],\n      simp only [linear_map.coe_mk, linear_map.map_smulₛₗ, ring_hom.id_apply],\n      refl, },\n    { rw [map_add, map_add, ih1, ih2, map_add, map_add], }\n  end }.\n\ndef adjunction : adjunction (extension_of_scalars.functor f) (restriction_of_scalars.functor f) :=\n{ hom_equiv := equiv f,\n  unit := unit f,\n  counit := counit f,\n  hom_equiv_unit' := λ X Y g, begin\n    ext x,\n    unfold equiv unit,\n    simp only [equiv.coe_fn_mk, Module.coe_comp, function.comp_app],\n    unfold unit.map forward,\n    simp only [linear_map.coe_mk],\n    refl,\n  end,\n  hom_equiv_counit' := λ X Y g, begin\n    ext z,\n    unfold equiv counit,\n    simp only [equiv.coe_fn_symm_mk, Module.coe_comp, function.comp_app],\n    unfold backward counit.map,\n    simp only [linear_map.coe_mk],\n    induction z using tensor_product.induction_on with x s z1 z2 ih1 ih2,\n    { simp only [map_zero], },\n    { erw tensor_product.lift.tmul, },\n    { simp only [map_add, ih1, ih2], }\n  end }.\n\nend adjunction\n\nend change_of_rings\n", "meta": {"author": "jjaassoonn", "repo": "quasicoherent", "sha": "d96ccacf00364afd6d0de7958024f1da10e015da", "save_path": "github-repos/lean/jjaassoonn-quasicoherent", "path": "github-repos/lean/jjaassoonn-quasicoherent/quasicoherent-d96ccacf00364afd6d0de7958024f1da10e015da/src/change_of_rings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.49935437178374953}}
{"text": "-- example on parsing arith language via macros\ninductive Arith: Type :=\n   | Add : Arith -> Arith -> Arith\n   | Int : Int -> Arith\n   | Symbol : String -> Arith\n   | Mul : Arith -> Arith -> Arith\n\ndeclare_syntax_cat arith\nsyntax term : arith\nsyntax  \"END\" : arith\nsyntax  arith \":+\" arith : arith\nsyntax arith \":*\" arith : arith\nsyntax \"(\" arith \")\" : arith\n\n-- auxiliary notation for translating `arith` into `term`\nsyntax \"fromArith% \" arith : term\n\nmacro_rules\n  | `(fromArith% $num:term) => `(Arith.Symbol $num)\n  | `(fromArith% END) => `(Arith.Int 50)\n  | `(fromArith% $x:arith :+ $y:arith ) => `(Arith.Add (fromArith% $x) (fromArith% $y))\n  | `(fromArith% $x:arith :* $y:arith ) => `(Arith.Mul (fromArith% $x) (fromArith% $y))\n  | `(fromArith% ($x:arith)) => `(fromArith% $x)\n\n-- Remark: after this command `brack` will be a \"reserved\" keyword, and we will have to use `«brack»`\n-- to reference the `brack` syntax category\nmacro \"arith\" n:ident \"->\" e:arith  : command =>\n   `(def $n:ident : Arith := fromArith% $e)\n\narith bar -> END\n#print bar\n\narith foo -> \"x\" :* \"y\"\n#print foo\n\narith baz -> \"x\" :+ \"y\"\n#print baz\n\narith baz2 -> (\"x\" :+ \"y\")\n#print baz2\n\narith baz3 -> (\"x\" :+ (\"z\" :* \"y\"))\n#print baz3\n\n\nsyntax ident : «arith»  -- Have to use french quotes since `arith` is now a keyword\n\nmacro_rules\n  | `(fromArith% $x:ident) => `(Arith.Symbol $(Lean.quote (toString x.getId)))\n\narith foo2 -> x \n#print foo2\n\narith foo3 -> x :+ y\n#print foo3\n\n-- arith foo2 -> x + y + z\n-- #print foo2\n \nsyntax \"{\" term \"}\" : «arith» -- escape for embedding terms into `Arith`\n \nmacro_rules\n  | `(fromArith% { $e }) => e\n\narith boo -> {foo3}\n#print boo\n-- \n", "meta": {"author": "opencompl", "repo": "lean-mlir", "sha": "85fd61e38dec57e4d67d7af4d49a1ccc67828c1b", "save_path": "github-repos/lean/opencompl-lean-mlir", "path": "github-repos/lean/opencompl-lean-mlir/lean-mlir-85fd61e38dec57e4d67d7af4d49a1ccc67828c1b/playground/arith.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6859494614282922, "lm_q1q2_score": 0.4993543671100744}}
{"text": "import M4R.Set.Finite.Perm\n\nimport M4R.Function\n\ndef M4R.UnorderedList (α : Type u) : Type u := Quotient (Perm.PermSetoid α)\n\ndef List.to_UnorderedList (l : List α) : M4R.UnorderedList α := Quotient.mk l\n\nnamespace M4R\n  namespace UnorderedList\n    instance UnorderedListCoe : Coe (List α) (UnorderedList α) where coe := List.to_UnorderedList\n\n    @[simp] theorem list_to_eq (l : List α) : l.to_UnorderedList = (↑l : UnorderedList α) := rfl\n    @[simp] theorem list_coe_eq (l : List α) : Quotient.mk l = (↑l : UnorderedList α) := rfl\n    @[simp] theorem list_coe_eq' (l : List α) : Quot.mk Perm l = (↑l : UnorderedList α) := rfl\n\n    @[simp] theorem list_perm_eq {l₁ l₂ : List α} (h : l₁ ~ l₂) : (↑l₁ : UnorderedList α) = ↑l₂ :=\n      Quot.sound h\n\n    protected def mem (a : α) (s : UnorderedList α) : Prop :=\n      Quot.liftOn s (fun l => a ∈ l) (fun l₁ l₂ (p : l₁ ~ l₂) => propext (p.mem_iff _))\n    instance UnorderedListMem : Mem α (UnorderedList α) where mem := UnorderedList.mem\n\n    protected def toSet (l : UnorderedList α) : Set α := Set.toSet l\n    protected def ext_toSet {l : UnorderedList α} {x : α} : x ∈ l ↔ x ∈ l.toSet := ⟨id, id⟩\n\n    def nodup (s : UnorderedList α) : Prop :=\n      Quot.liftOn s List.nodup (fun l₁ l₂ p => propext p.nodupIff)\n\n    protected def sizeOf [SizeOf α] (s : UnorderedList α) : Nat :=\n      Quot.liftOn s sizeOf (fun _ _ => Perm.sizeOf_Eq_sizeOf)\n    instance UnorderedListSizeOf : SizeOf (UnorderedList α) where sizeOf := UnorderedList.sizeOf\n\n    def length (s : UnorderedList α) : Nat :=\n      Quot.liftOn s List.length (fun _ _ => Perm.length_eq)\n\n    protected def cons (a : α) (s : UnorderedList α) : UnorderedList α :=\n      Quot.liftOn s (fun l => List.to_UnorderedList (a::l)) (fun _ _ p => Quot.sound (p.cons a))\n    @[simp] theorem cons_eq (a : α) (l : List α) : ↑(a::l) = (↑l : UnorderedList α).cons a := rfl\n\n    @[simp] theorem nodup_cons {a : α} {s : UnorderedList α} : nodup (s.cons a) ↔ a ∉ s ∧ nodup s :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => nodup (l.cons a) ↔ a ∉ l ∧ nodup l) s\n        fun l => List.nodup_cons\n\n    protected def Empty {α : Type _} : UnorderedList α := List.to_UnorderedList []\n    instance EmptyUnorderedListEmptyCollection : EmptyCollection (UnorderedList α) where\n      emptyCollection := UnorderedList.Empty\n    instance UnorderedListZero : Zero (UnorderedList α) where zero := UnorderedList.Empty\n    @[simp] theorem empty_eq : (↑([] : List α) : UnorderedList α) = 0 := rfl\n    theorem mem_empty {a : α} : a ∈ (0 : UnorderedList α) ↔ False := Iff.rfl\n    theorem nodup_zero (α : Type _) : (0 : UnorderedList α).nodup := List.nodup_nil\n\n    protected def singleton (a : α) : UnorderedList α := ↑[a]\n    @[simp] theorem singleton_eq (a : α) : List.to_UnorderedList [a] = UnorderedList.singleton a := rfl\n    theorem singleton_eq_cons (a : α) : UnorderedList.singleton a = UnorderedList.cons a 0 := rfl\n\n    protected theorem induction {p : UnorderedList α → Prop} (h₁ : p 0)\n      (h₂ : ∀ ⦃a : α⦄ {s : UnorderedList α}, p s → p (s.cons a)) (s : UnorderedList α) : p s :=\n        @Quotient.inductionOn _ _ p s (fun l => by induction l with\n          | nil => exact h₁\n          | cons _ _ ih => exact h₂ ih)\n\n    protected theorem induction_on (p : UnorderedList α → Prop) (s : UnorderedList α)\n      (h₁ : p 0) (h₂ : ∀ ⦃a : α⦄ {s : UnorderedList α}, p s → p (s.cons a)) : p s :=\n        UnorderedList.induction h₁ h₂ s\n\n    def disjoint (s t : UnorderedList α) : Prop := ∀ x, x ∈ s → x ∉ t\n\n    theorem disjoint.symm {s t : UnorderedList α} : disjoint s t ↔ disjoint t s :=\n      have : ∀ s t : UnorderedList α, disjoint s t → disjoint t s :=\n        fun s t h x ht hs => h x hs ht\n      ⟨this s t, this t s⟩\n\n    @[simp] theorem mem_cons {a b : α} {s : UnorderedList α} : a ∈ s.cons b ↔ a = b ∨ a ∈ s :=\n      @Quotient.ind _ _ (fun (l : UnorderedList α) => a ∈ l.cons b ↔ a = b ∨ a ∈ l)\n        (fun _ => Iff.rfl) s\n\n    theorem mem_cons_of_mem {a b : α} {s : UnorderedList α} (h : a ∈ s) : a ∈ s.cons b :=\n      mem_cons.mpr (Or.inr h)\n\n    @[simp] theorem mem_cons_self (a : α) (s : UnorderedList α) : a ∈ s.cons a :=\n      mem_cons.mpr (Or.inl rfl)\n\n    theorem eq_nil_of_length_eq_zero {s : UnorderedList α} : s.length = 0 → s = 0 :=\n      @Quotient.ind _ _ (fun (l : UnorderedList α) => l.length = 0 → l = 0)\n        (fun _ h => congrArg _ (List.eq_nil_of_length_eq_zero h)) s\n\n    @[simp] theorem zero_subset {s : UnorderedList α} : 0 ⊆ s := by\n      intro _ _; contradiction\n\n    @[simp] theorem subset_zero {s : UnorderedList α} : s ⊆ 0 → s = 0 :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => l ⊆ 0 → l = 0) s\n        (fun l => by induction l with\n          | nil => simp\n          | cons a l ih => intro h; have := h (mem_cons_self a ↑l); contradiction)\n\n    protected def append (s t : UnorderedList α) : UnorderedList α :=\n      Quotient.liftOn₂ s t (fun l₁ l₂ => (l₁ ++ l₂ : List α).to_UnorderedList)\n        fun v₁ v₂ w₁ w₂ p₁ p₂ => Quot.sound (p₁.append p₂)\n\n    namespace append\n      instance UnorderedListAdd : Add (UnorderedList α) where add := UnorderedList.append\n\n      theorem comm (s t : UnorderedList α) : s + t = t + s :=\n        @Quotient.inductionOn₂ _ _ _ _ (fun (l₁ l₂ : UnorderedList α) => l₁ + l₂ = l₂ + l₁) s t\n          fun _ _ => Quot.sound Perm.append_comm\n\n      @[simp] theorem add_zero (s : UnorderedList α) : s + 0 = s :=\n        @Quotient.inductionOn _ _ (fun (a : UnorderedList α) => a + 0 = a) s\n          (fun l => Quot.sound (by simp only [List.append_nil]; exact Perm.refl _))\n\n      @[simp] theorem zero_add (s : UnorderedList α) : 0 + s = s := by\n        rw [comm, add_zero]\n\n      theorem cons (a : α) (s : UnorderedList α) : s.cons a = [a] + s := rfl\n      theorem cons' (a : α) (s : UnorderedList α) : s.cons a = s + [a] := by rw [comm, cons]\n\n      theorem assoc (s t u : UnorderedList α) : s + t + u = s + (t + u) :=\n        @Quotient.inductionOn₃ _ _ _ _ _ _\n          (fun (a b c : UnorderedList α) => a + b + c = a + (b + c)) s t u\n          (fun a b c => Quot.sound (by rw [List.append_assoc]; exact Perm.refl _))\n\n      theorem cons_over_right (a : α) (s t : UnorderedList α) : s + (t.cons a) = (s + t).cons a := by\n        simp only [cons]; rw [←assoc, comm s, assoc]\n      theorem cons_over_left (a : α) (s t : UnorderedList α) : (s.cons a) + t = (s + t).cons a := by\n        simp only [cons]; rw [←assoc, comm _ s, assoc]\n\n      @[simp] theorem mem_add {a : α} {s t : UnorderedList α} : a ∈ s + t ↔ a ∈ s ∨ a ∈ t :=\n        @Quotient.inductionOn₂ _ _ _ _ (fun (l₁ l₂ : UnorderedList α) => a ∈ l₁ + l₂ ↔ a ∈ l₁ ∨ a ∈ l₂)\n          s t fun l₁ l₂ => List.mem_append\n\n      theorem nodup_add {s t : UnorderedList α} : (s + t).nodup ↔ s.nodup ∧ t.nodup ∧ disjoint s t :=\n        @Quotient.inductionOn₂ _ _ _ _ (fun (s t : UnorderedList α) => (s + t).nodup ↔ s.nodup ∧ t.nodup ∧ disjoint s t)\n          s t fun l₁ l₂ => List.nodup_append\n\n    end append\n\n    namespace length\n      @[simp] theorem coe_length (l : List α) : length (l : UnorderedList α) = l.length := rfl\n\n      @[simp] theorem zero : @length α 0 = 0 := rfl\n\n      @[simp] theorem add (s t : UnorderedList α) : length (s + t) = length s + length t :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => length (l₁ + l₂) = length l₁ + length l₂) s t\n            List.length_append\n\n      @[simp] theorem cons (a : α) (s : UnorderedList α) : length (s.cons a) = length s + 1 :=\n        @Quotient.inductionOn _ _\n          (fun (l : UnorderedList α) => length (l.cons a) = length l + 1) s fun l => rfl\n\n      @[simp] theorem singleton (a : α) : length (UnorderedList.singleton a) = 1 := by\n        simp only [singleton_eq_cons, zero, cons]\n\n      theorem eq_one {s : UnorderedList α} : length s = 1 ↔ ∃ a, s = UnorderedList.singleton a :=\n        ⟨@Quotient.inductionOn _ _\n          (fun (l : UnorderedList α) => length l = 1 → ∃ a, l = UnorderedList.singleton a) s\n          (fun l h => (List.length_eq_one.mp h).imp fun _ => congrArg List.to_UnorderedList),\n        fun ⟨a, e⟩ => e.symm ▸ rfl⟩\n\n      theorem pos_iff_exists_mem {s : UnorderedList α} : 0 < length s ↔ ∃ a, a ∈ s :=\n        @Quotient.inductionOn _ _\n          (fun (l : UnorderedList α) => 0 < length l ↔ ∃ a, a ∈ l) s\n          (fun l => List.length_pos_iff_exists_mem)\n\n    end length\n\n    protected theorem in_singleton {a a' : α} : a' ∈ UnorderedList.singleton a → a' = a :=\n      List.in_singleton\n\n    protected theorem self_singleton (a : α) : a ∈ UnorderedList.singleton a :=\n      List.self_singleton a\n\n    protected theorem in_double (a b : α) : ∀ x ∈ ([a, b] : UnorderedList α), x = a ∨ x = b :=\n      List.in_double a b\n\n    @[simp] protected theorem cons' (a : α) (l : List α) : Quotient.mk (a :: l) = (↑l : UnorderedList α).cons a := rfl\n\n    protected def map (f : α → β) (s : UnorderedList α) : UnorderedList β :=\n      Quot.liftOn s (fun l : List α => ↑(l.map f))\n        (fun l₁ l₂ p => Quot.sound (p.map f))\n\n    @[simp] theorem map_nil (f : α → β) : UnorderedList.map f 0 = 0 := rfl\n\n    namespace map\n\n      @[simp] theorem cons (f : α → β) (a : α) (s : UnorderedList α) : (s.cons a).map f = (s.map f).cons (f a) :=\n        @Quotient.ind _ _ (fun (l : UnorderedList α) => (l.cons a).map f = (l.map f).cons (f a)) (fun _ => rfl) s\n\n      @[simp] theorem singleton (f : α → β) (a : α) : (UnorderedList.singleton a).map f = UnorderedList.singleton (f a) := rfl\n\n      @[simp] theorem add (f : α → β) (l₁ l₂ : UnorderedList α) : (l₁ + l₂).map f = (l₁.map f) + (l₂.map f) :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (s t : UnorderedList α) => (s + t).map f = (s.map f) + (t.map f)) l₁ l₂\n          (fun s t => congrArg List.to_UnorderedList (List.map_append f s t))\n\n      @[simp] theorem mem_map {f : α → β} {b : β} {s : UnorderedList α} : b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          b ∈ l.map f ↔ ∃ a, a ∈ l ∧ f a = b) s (fun _ => List.mem_map)\n\n      theorem congr {f g : α → β} {s t : UnorderedList α} (h₁ : s = t) (h₂ : ∀ x ∈ t, f x = g x) :\n        s.map f = t.map g := h₁ ▸ @Quotient.inductionOn _ _\n            (fun (l : UnorderedList α) => (∀ x ∈ l, f x = g x) → l.map f = l.map g) t\n            (fun l hl => congrArg List.to_UnorderedList (List.map_congr rfl hl)) h₂\n\n      theorem map_comp (f : α → β) (g : β → γ) (s : UnorderedList α) : (s.map f).map g = s.map (g ∘ f) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => (l.map f).map g = l.map (g ∘ f)) s\n          (fun l => congrArg List.to_UnorderedList (l.map_comp f g))\n\n      theorem map_id (s : UnorderedList α) : s.map id = s :=\n        @Quotient.ind _ _ (fun (l : UnorderedList α) => l.map id = l) (fun l =>\n          congrArg List.to_UnorderedList (List.map_id l)) s\n\n      @[simp] theorem length_map (f : α → β) (s : UnorderedList α) : (s.map f).length = s.length :=\n        @Quotient.ind _ _ (fun (l : UnorderedList α) => (l.map f).length = l.length) (List.length_map f) s\n    end map\n\n    theorem nodup_map_on {f : α → β} {s : UnorderedList α} (H : ∀ x ∈ s, ∀ y ∈ s, f x = f y → x = y) :\n      nodup s → nodup (s.map f) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          (∀ (x : α), x ∈ l → ∀ (y : α), y ∈ l → f x = f y → x = y) → nodup l → nodup (l.map f))\n            s (fun _ => List.nodup_map_on) H\n\n    theorem nodup_map {f : α → β} {s : UnorderedList α} (hf : Function.injective f) :\n      nodup s → nodup (s.map f) :=\n        nodup_map_on (fun x _ y _ h => hf h)\n\n    theorem nodup_ext {s t : UnorderedList α} : nodup s → nodup t → (s = t ↔ ∀ a, a ∈ s ↔ a ∈ t) :=\n      @Quotient.inductionOn₂ _ _ _ _\n        (fun (s' t' : UnorderedList α) => nodup s' → nodup t' → (s' = t' ↔ ∀ a, a ∈ s' ↔ a ∈ t')) s t\n        (fun l₁ l₂ h₁ h₂ => Quotient.eq.trans (Perm.ext h₁ h₂))\n\n    inductive rel {α : Type _} {β : Type _} (r : α → β → Prop) : UnorderedList α → UnorderedList β → Prop\n    | zero : rel r 0 0\n    | cons {a b as bs} : r a b → rel r as bs → rel r (as.cons a) (bs.cons b)\n\n    def pmap {p : α → Prop} (f : ∀ a, p a → β) (s : UnorderedList α) : (∀ a ∈ s, p a) → UnorderedList β :=\n      @Quotient.recOn _ _ (fun (l : UnorderedList α) => (∀ a ∈ l, p a) → UnorderedList β) s\n        (fun l H => ↑(l.pmap f H)) (fun l₁ l₂ pp => by\n          apply funext; intro h₂; have h₁ : ∀ a, a ∈ ↑l₁ → p a := fun a h => h₂ a (pp.subset h)\n          have : ∀ (s₂ e H), @Eq.rec (UnorderedList α) l₁\n            (fun l _ => (∀ a ∈ l, p a) → UnorderedList β) (fun _ => ↑(l₁.pmap f h₁))\n            s₂ e H = ↑(l₁.pmap f h₁) := by\n              intro _ e _; subst e; rfl\n          have t₁ := this ↑l₂ (Quot.sound pp) h₂\n          have t₂ := Quot.sound (@Perm.pmap _ _ _ f _ _ pp h₁ h₂)\n          exact t₁.trans t₂)\n\n    theorem nodup_pmap {p : α → Prop} {f : ∀ a, p a → β} {s : UnorderedList α} {H : ∀ a ∈ s, p a}\n    (hf : ∀ a ha b hb, f a ha = f b hb → a = b) : nodup s → nodup (pmap f s H) :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n        (h : ∀ a ∈ l, p a) → nodup l → nodup (pmap f l h)) s (fun l hl => List.nodup_pmap hf) H\n\n    @[simp] theorem mem_pmap {p : α → Prop} {f : ∀ a, p a → β}\n      {s : UnorderedList α} {H : ∀ a ∈ s, p a} {b : β} : b ∈ pmap f s H ↔ ∃ (a : α) (h : a ∈ s), f a (H a h) = b :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          (H' : ∀ a ∈ l, p a) → b ∈ pmap f l H' ↔ ∃ (a : α) (h : a ∈ l), f a (H' a h) = b) s\n          (fun l h => List.mem_pmap) H\n\n    theorem pmap_empty {p : α → Prop} (f : ∀ a, p a → β) : pmap f 0 (fun _ _ => by contradiction) = 0 := rfl\n\n    theorem pmap_length {p : α → Prop} (f : ∀ a, p a → β) {s : UnorderedList α} (H : ∀ a ∈ s, p a) : (s.pmap f H).length = s.length :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => (H : ∀ a ∈ l, p a) → (l.pmap f H).length = l.length)\n        s (fun _ => List.pmap_length f) H\n\n    section filter\n\n      noncomputable def filter (p : α → Prop) (s : UnorderedList α) : UnorderedList α :=\n        Quot.liftOn s (fun l => (l.filter' p : UnorderedList α))\n          (fun l₁ l₂ h => Quot.sound (h.filter' p))\n\n      @[simp] theorem filter_add (s t : UnorderedList α) : filter p (s + t) = filter p s + filter p t :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => filter p (l₁ + l₂) = filter p l₁ + filter p l₂) s t\n          (fun l₁ l₂ => congrArg List.to_UnorderedList (List.filter'_append _ _))\n\n      theorem nodup_filter (p : α → Prop) {l : UnorderedList α} : nodup l → nodup (filter p l) :=\n        @Quotient.inductionOn _ _ (fun (s : UnorderedList α) =>\n          nodup s → nodup (filter p s)) l fun l => List.nodup_filter' p\n\n      @[simp] theorem filter_cons_of_pos {a : α} (s : UnorderedList α) :\n        p a → filter p (s.cons a) = (filter p s).cons a :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n            p a → filter p (l.cons a) = (filter p l).cons a) s\n            fun l h => congrArg List.to_UnorderedList (List.filter'_cons_of_pos l h)\n\n      @[simp] theorem filter_cons_of_neg {a : α} (s : UnorderedList α) :\n        ¬ p a → filter p (s.cons a) = filter p s :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n            ¬ p a → filter p (l.cons a) = filter p l) s\n            fun l h => congrArg List.to_UnorderedList (List.filter'_cons_of_neg l h)\n\n      @[simp] theorem mem_filter {a : α} {s : UnorderedList α} : a ∈ filter p s ↔ a ∈ s ∧ p a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          a ∈ filter p l ↔ a ∈ l ∧ p a) s fun l => List.mem_filter'\n\n      theorem of_mem_filter {a : α} {s : UnorderedList α} (h : a ∈ filter p s) : p a :=\n        (mem_filter.mp h).right\n\n    end filter\n\n    section ndinsert\n\n      noncomputable def ndinsert (a : α) (s : UnorderedList α) : UnorderedList α :=\n        Quot.liftOn s (fun l => (l.insert a : UnorderedList α))\n          (fun s t p => Quot.sound (p.insert a))\n\n      @[simp] theorem coe_ndinsert (a : α) (l : List α) : ndinsert a l = (l.insert a : List α) := rfl\n\n      @[simp] theorem ndinsert_of_mem {a : α} {s : UnorderedList α} : a ∈ s → ndinsert a s = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => a ∈ l → ndinsert a l = l)\n          s fun l h => congrArg List.to_UnorderedList (List.insert_of_mem h)\n\n      @[simp] theorem ndinsert_of_not_mem {a : α} {s : UnorderedList α} : a ∉ s → ndinsert a s = s.cons a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          a ∉ l → ndinsert a l = l.cons a) s fun l h => congrArg List.to_UnorderedList (List.insert_of_not_mem h)\n\n      @[simp] theorem ndinsert_zero (a : α) : ndinsert a 0 = UnorderedList.singleton a :=\n        ndinsert_of_not_mem (fun _ => by contradiction)\n\n      @[simp] theorem mem_ndinsert {a b : α} {s : UnorderedList α} : a ∈ ndinsert b s ↔ a = b ∨ a ∈ s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          a ∈ ndinsert b l ↔ a = b ∨ a ∈ l) s fun l => List.mem_insert_iff\n\n      @[simp] theorem mem_ndinsert_self (a : α) (s : UnorderedList α) : a ∈ ndinsert a s :=\n        mem_ndinsert.mpr (Or.inl rfl)\n\n      theorem mem_ndinsert_of_mem {a b : α} {s : UnorderedList α} (h : a ∈ s) : a ∈ ndinsert b s :=\n        mem_ndinsert.mpr (Or.inr h)\n\n      theorem nodup_ndinsert (a : α) {s : UnorderedList α} : nodup s → nodup (ndinsert a s) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => nodup l → nodup (ndinsert a l))\n          s fun l => List.nodup_insert\n\n    end ndinsert\n\n    section ndunion\n\n      noncomputable def ndunion (s t : UnorderedList α) : UnorderedList α :=\n        @Quotient.liftOn₂ _ _ _ _ _ s t (fun l₁ l₂ => ↑(l₁ ∪ l₂)) (fun _ _ _ _ p₁ p₂ => Quot.sound (p₁.union p₂))\n\n      @[simp] theorem coe_ndunion (l₁ l₂ : List α) : @ndunion α l₁ l₂ = (l₁ ∪ l₂ : List α) := rfl\n\n      @[simp] theorem zero_ndunion (s : UnorderedList α) : ndunion 0 s = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => ndunion 0 l = l) s\n          fun _ => rfl\n\n      @[simp] theorem cons_ndunion (s t : UnorderedList α) (a : α) :\n        ndunion (s.cons a) t = ndinsert a (ndunion s t) :=\n          @Quotient.inductionOn₂ _ _ _ _ (fun (l₁ l₂ : UnorderedList α) =>\n            ndunion (l₁.cons a) l₂ = ndinsert a (ndunion l₁ l₂)) s t fun _ _ => rfl\n\n      @[simp] theorem mem_ndunion {s t : UnorderedList α} {a : α} : a ∈ ndunion s t ↔ a ∈ s ∨ a ∈ t :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => a ∈ ndunion l₁ l₂ ↔ a ∈ l₁ ∨ a ∈ l₂) s t\n          (fun l₁ l₂ => List.mem_union)\n\n      theorem nodup_ndunion (s : UnorderedList α) {t : UnorderedList α} : nodup t → nodup (ndunion s t) :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => nodup l₂ → nodup (ndunion l₁ l₂)) s t\n          (fun l₁ l₂ => List.nodup_union l₁)\n\n    end ndunion\n\n    section ndinter\n\n      noncomputable def ndinter (s t : UnorderedList α) : UnorderedList α := s.filter (· ∈ t)\n\n      @[simp] theorem zero_ndinter (s : UnorderedList α) : ndinter 0 s = 0 := rfl\n\n      @[simp] theorem cons_ndinter_of_mem {a : α} (s : UnorderedList α) {t : UnorderedList α} (h : a ∈ t) :\n        ndinter (s.cons a) t = (ndinter s t).cons a := by simp only [ndinter, h, filter_cons_of_pos]\n\n      @[simp] theorem ndinter_cons_of_not_mem {a : α} (s : UnorderedList α) {t : UnorderedList α} (h : a ∉ t) :\n        ndinter (s.cons a) t = ndinter s t := by simp only [ndinter, h, filter_cons_of_neg]\n\n      @[simp] theorem mem_ndinter {s t : UnorderedList α} {a : α} : a ∈ ndinter s t ↔ a ∈ s ∧ a ∈ t :=\n        mem_filter\n\n      @[simp] theorem nodup_ndinter {s : UnorderedList α} (t : UnorderedList α) : nodup s → nodup (ndinter s t) :=\n        nodup_filter _\n\n    end ndinter\n\n    protected def le (s t : UnorderedList α) : Prop :=\n        Quotient.liftOn₂ s t (· <+~ ·) (fun _ _ _ _ p₁ p₂ =>\n          propext (p₂.subperm_left.trans p₁.subperm_right))\n\n    namespace le\n      instance UnorderedListle : LE (UnorderedList α) where le := UnorderedList.le\n\n      protected theorem refl (a : UnorderedList α) : a ≤ a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => l ≤ l) a\n          Perm.Subperm.refl\n\n      protected theorem trans {a b c : UnorderedList α} : a ≤ b → b ≤ c → a ≤ c :=\n        @Quotient.inductionOn₃ _ _ _ _ _ _\n          (fun (l₁ l₂ l₃ : UnorderedList α) => l₁ ≤ l₂ → l₂ ≤ l₃ → l₁ ≤ l₃) a b c\n          (fun l₁ l₂ l₃ => Perm.Subperm.trans)\n\n      protected theorem antisymm {a b : UnorderedList α} : a ≤ b → b ≤ a → a = b :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => l₁ ≤ l₂ → l₂ ≤ l₁ → l₁ = l₂) a b\n          (fun l₁ l₂ h₁ h₂ => Quot.sound (Perm.Subperm.antisymm h₁ h₂))\n\n      protected theorem of_eq {a b : UnorderedList α} (h : a = b) : a ≤ b := by rw [h]; exact le.refl _\n\n      @[simp] theorem subperm {l₁ l₂ : List α} : (l₁ : UnorderedList α) ≤ l₂ ↔ l₁ <+~ l₂ := Iff.rfl\n\n      variable {s t : UnorderedList α} {a : α}\n\n      theorem subset_of_le : s ≤ t → s ⊆ t :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => l₁ ≤ l₂ → l₁ ⊆ l₂) s t\n          (fun l₁ l₂ h => Perm.Subperm.subset (le.subperm.mp h))\n\n      theorem mem_of_le (h : s ≤ t) : a ∈ s → a ∈ t :=\n        have := subset_of_le h\n        @this a\n\n      theorem not_mem_mono (h : s ⊆ t) : a ∉ t → a ∉ s := mt (@h _)\n\n      theorem zero_le (s : UnorderedList α) : 0 ≤ s :=\n        Quot.inductionOn s fun l => (List.Sublist.nil_sublist l).subperm\n\n      theorem le_zero : s ≤ 0 ↔ s = 0 := ⟨fun h => le.antisymm h (zero_le _), le.of_eq⟩\n\n      theorem le_iff_subset {s t : UnorderedList α} : nodup s → (s ≤ t ↔ s ⊆ t) :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => nodup l₁ → (l₁ ≤ l₂ ↔ l₁ ⊆ l₂)) s t\n          fun l₁ l₂ d => ⟨subset_of_le, Perm.Subperm.subperm_of_subset_nodup d⟩\n\n      theorem le_induction_on {C : UnorderedList α → UnorderedList α → Prop}\n        (h : s ≤ t) (H : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → C l₁ l₂) : C s t :=\n          @Quotient.inductionOn₂ _ _ _ _\n            (fun (l₁ l₂ : UnorderedList α) => l₁ ≤ l₂ → C l₁ l₂) s t\n            (fun l₁ l₂ ⟨l, p, s'⟩ => by simp; rw [←list_perm_eq p]; exact H s') h\n\n      theorem nodup_of_le (h : s ≤ t) : nodup t → nodup s :=\n        @le_induction_on α s t (fun a b => nodup b → nodup a)\n          h List.nodup_of_sublist\n\n      theorem cons_self (s : UnorderedList α) (a : α) : s ≤ s.cons a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => l ≤ l.cons a)\n          s fun l => (List.Sublist.sublist_cons a l).subperm\n\n      theorem cons_of_le {s t : UnorderedList α} (a : α) (h : s ≤ t) : s ≤ t.cons a :=\n        le.trans h (cons_self t a)\n\n      theorem cons_le_cons_iff (a : α) {s t : UnorderedList α} : s.cons a ≤ t.cons a ↔ s ≤ t :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => l₁.cons a ≤ l₂.cons a ↔ l₁ ≤ l₂) s t\n          fun l₁ l₂ => Perm.Subperm.subperm_cons a\n\n      theorem cons_le_cons (a : α) : s ≤ t → s.cons a ≤ t.cons a := (cons_le_cons_iff a).mpr\n\n      theorem le_cons_of_not_mem (m : a ∉ s) : s ≤ t.cons a ↔ s ≤ t :=\n        ⟨have : ∀ {t' : UnorderedList α} (h₁ : s ≤ t') (h₂ : a ∈ t'), s.cons a ≤ t' := by\n          intro t' h; revert m\n          exact @le_induction_on α s t' (fun l₁ l₂ => a ∉ l₁ → a ∈ l₂ → l₁.cons a ≤ l₂) h (by\n            intro l₁ l₂ s m₁ m₂; let ⟨r₁, r₂, h'⟩ := List.mem_split m₂; rw [h'] at s ⊢\n            exact (Perm.middle a r₁ r₂).subperm_left.mpr ((Perm.Subperm.subperm_cons a).mpr ((List.Sublist.sublist_or_mem_of_sublist s).resolve_right m₁).subperm))\n        fun h => (cons_le_cons_iff a).mp (this h (mem_cons_self _ _)),\n        cons_of_le a⟩\n\n      theorem add_right (s t : UnorderedList α) : s ≤ s + t :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          s ≤ s + l) t (fun l => by\n            induction l with\n            | nil => exact (by simp; exact le.refl _ : s ≤ s + 0)\n            | cons a l ih => simp; rw [append.cons_over_right]; exact cons_of_le a ih)\n\n      theorem add_left (s t : UnorderedList α) : s ≤ t + s := by\n        rw [append.comm]; exact add_right s t\n\n      theorem le_iff_exists_add {s t : UnorderedList α} : s ≤ t ↔ ∃ u, t = s + u :=\n        ⟨fun h => @le_induction_on α s t (fun l₁ l₂ => ∃ u, l₂ = l₁ + u) h (fun s =>\n          let ⟨l, p⟩ := s.exists_perm_append\n          ⟨l, Quot.sound p⟩),\n        fun ⟨u, e⟩ => e.symm ▸ add_right s u⟩\n\n      theorem add_le_add_left (s : UnorderedList α) {t u : UnorderedList α} : s + t ≤ s + u ↔ t ≤ u :=\n        @Quotient.inductionOn₃ _ _ _ _ _ _\n          (fun (l₁ l₂ l₃ : UnorderedList α) => l₁ + l₂ ≤ l₁ + l₃ ↔ l₂ ≤ l₃) s t u\n          fun l₁ l₂ l₃ => Perm.Subperm.subperm_append_left l₁\n\n      theorem add_le_add_right {s t : UnorderedList α} (u : UnorderedList α): s + u ≤ t + u ↔ s ≤ t := by\n        rw [append.comm s, append.comm t]; exact add_le_add_left u\n\n      theorem add_le_add_cancel {s t u : UnorderedList α} : s + t ≤ s + u → t ≤ u :=\n        (add_le_add_left s).mp\n\n      @[simp] theorem filter_le (p : α → Prop) (s : UnorderedList α) : filter p s ≤ s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          filter p l ≤ l) s fun l => (List.filter'_sublist _).subperm\n\n      theorem not_cons_self (s : UnorderedList α) (a : α) : ¬ (s.cons a ≤ s) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => ¬ (l.cons a ≤ l)) s\n          (fun l => Perm.Subperm.not_cons_self l a)\n\n      theorem ne_iff_cons {s t : UnorderedList α} (h : s ≤ t) : s ≠ t ↔ ∃ a, s.cons a ≤ t :=\n        ⟨@Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => l₁ ≤ l₂ → l₁ ≠ l₂ → ∃ a, l₁.cons a ≤ l₂) s t\n          (fun l₁ l₂ h' he =>\n            have p' : ¬ l₁ ~ l₂ := by intro p; exact he (Quot.sound p)\n            Perm.Subperm.exists_of_subperm_ne h' p') h,\n        fun ⟨a, ha⟩ he => by rw [he] at ha; exact absurd ha (not_cons_self t a)⟩\n\n    end le\n\n    theorem length.le_of_le {s t : UnorderedList α} (h : s ≤ t) : length s ≤ length t :=\n      @le.le_induction_on α s t (fun l₁ l₂ => length l₁ ≤ length l₂) h\n        List.Sublist.length_le_of_sublist\n\n    open Classical\n\n    protected noncomputable def erase (s : UnorderedList α) (a : α) : UnorderedList α :=\n        Quotient.liftOn s (fun l => (l.erase a : UnorderedList α))\n          fun l₁ l₂ p => list_perm_eq (p.erase a)\n\n    namespace erase\n      @[simp] theorem coe_erase (l : List α) (a : α) :\n        (l : UnorderedList α).erase a = l.erase a := rfl\n\n      @[simp] theorem erase_zero (a : α) : (0 : UnorderedList α).erase a = 0 := rfl\n\n      @[simp] theorem erase_cons_head (a : α) (s : UnorderedList α) : (s.cons a).erase a = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => (l.cons a).erase a = l)\n          s fun l => congrArg List.to_UnorderedList (List.erase_cons_head a l)\n\n      @[simp] theorem erase_cons_tail {a b : α} (s : UnorderedList α) (h : b ≠ a) :\n        (s.cons b).erase a = (s.erase a).cons b :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => (l.cons b).erase a = (l.erase a).cons b)\n            s fun l => congrArg List.to_UnorderedList (List.erase_cons_tail l h)\n\n      @[simp] theorem erase_of_not_mem {a : α} {s : UnorderedList α} : a ∉ s → s.erase a = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          a ∉ l → l.erase a = l) s fun l h => congrArg List.to_UnorderedList (List.erase_of_not_mem h)\n\n      @[simp] theorem cons_erase {s : UnorderedList α} {a : α} : a ∈ s → (s.erase a).cons a = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          a ∈ l → (l.erase a).cons a = l) s fun l h => Quot.sound (Perm.cons_erase h).symm\n\n      theorem le_cons_erase (s : UnorderedList α) (a : α) : s ≤ (s.erase a).cons a :=\n        if h : a ∈ s then le.of_eq (cons_erase h).symm\n        else by rw [erase_of_not_mem h]; apply le.cons_self\n\n      theorem erase_le (a : α) (s : UnorderedList α) : s.erase a ≤ s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          l.erase a ≤ l) s fun l => (List.erase_sublist a l).subperm\n\n      theorem erase_le_iff_le_cons {s t : UnorderedList α} {a : α} : s.erase a ≤ t ↔ s ≤ t.cons a :=\n        ⟨fun h => le.trans (erase.le_cons_erase _ _) (le.cons_le_cons _ h),\n        fun h => if m : a ∈ s then by\n          rw [←cons_erase m] at h; exact (le.cons_le_cons_iff _).mp h\n        else le.trans (erase_le _ _) ((le.le_cons_of_not_mem m).mp h)⟩\n\n      theorem erase_le_erase {s t : UnorderedList α} (a : α) (h : s ≤ t) : s.erase a ≤ t.erase a :=\n        @le.le_induction_on α s t (fun l₁ l₂ => l₁.erase a ≤ l₂.erase a) h\n          fun h' => (h'.erase _).subperm\n\n      theorem nodup_erase_eq_filter (a : α) {s : UnorderedList α} : nodup s → s.erase a = filter (· ≠ a) s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          nodup l → l.erase a = filter (· ≠ a) l) s\n          (fun l d => congrArg (List.to_UnorderedList) (List.nodup_erase_eq_filter' a d))\n\n      theorem nodup_erase_of_nodup (a : α) {l : UnorderedList α} : nodup l → nodup (l.erase a) :=\n        le.nodup_of_le (erase_le _ _)\n\n      theorem mem_erase_iff_of_nodup {a b : α} {l : UnorderedList α} (d : nodup l) :\n        a ∈ l.erase b ↔ a ≠ b ∧ a ∈ l := by\n          rw [nodup_erase_eq_filter b d, mem_filter, And.comm']; exact Iff.rfl\n\n      theorem mem_erase_of_nodup {a : α} {l : UnorderedList α} (h : nodup l) : a ∉ l.erase a := by\n        rw [mem_erase_iff_of_nodup h, not_and_iff_or_not]; exact Or.inl (iff_not_not.mpr rfl)\n\n    end erase\n\n    protected noncomputable def sub (s t : UnorderedList α) : UnorderedList α :=\n      Quotient.liftOn₂ s t (fun l₁ l₂ => (l₁.diff l₂ : UnorderedList α))\n        (fun _ _ _ _ p₁ p₂ => Quot.sound (p₁.diff p₂))\n\n    namespace sub\n\n      noncomputable instance : Sub (UnorderedList α) where sub := UnorderedList.sub\n\n      @[simp] protected theorem sub_zero (s : UnorderedList α) : s - 0 = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => l - 0 = l) s fun l => rfl\n\n      @[simp] theorem sub_cons (a : α) (s t : UnorderedList α) : s - t.cons a = s.erase a - t :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => l₁ - l₂.cons a = l₁.erase a - l₂) s t\n          fun l₁ l₂ => congrArg List.to_UnorderedList (List.diff_cons _ _ _)\n\n      theorem sub_le_iff_le_add_right {s t : UnorderedList α} : s - t ≤ u ↔ s ≤ u + t := by\n        revert s\n        exact @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          ∀ s, s - l ≤ u ↔ s ≤ u + l) t (fun l => by\n            induction l with\n            | nil => exact fun s => (by simp only [sub.sub_zero, append.add_zero]; exact Iff.rfl : s - 0 ≤ u ↔ s ≤ u + 0)\n            | cons a t ih =>\n              intro s\n              simp at ih\n              simp [ih, append.cons_over_right]\n              exact erase.erase_le_iff_le_cons)\n\n      theorem sub_le_iff_le_add_left {s t : UnorderedList α} : s - t ≤ u ↔ s ≤ t + u := by\n        rw [sub_le_iff_le_add_right, append.comm]; exact Iff.rfl\n\n      theorem le_sub_add (s t : UnorderedList α) : s ≤ (s - t) + t :=\n        sub_le_iff_le_add_right.mp (le.refl _)\n\n      theorem le_add_sub (s t : UnorderedList α) : s ≤ t + (s - t) :=\n        sub_le_iff_le_add_left.mp (le.refl _)\n\n      theorem add_sub_le_left {s t : UnorderedList α}: s + t - s ≤ t :=\n        sub_le_iff_le_add_left.mpr (le.refl _)\n\n      theorem sub_le_sub_right {s t : UnorderedList α} (h : s ≤ t) (u : UnorderedList α) : s - u ≤ t - u :=\n        sub_le_iff_le_add_left.mpr (le.trans h (le_add_sub t u))\n\n    end sub\n\n    @[simp] theorem le.sub_le_self (s t : UnorderedList α) : s - t ≤ s :=\n      sub.sub_le_iff_le_add_left.mpr (le.add_left s t)\n\n    theorem filter_eq_self {s : UnorderedList α} : filter p s = s ↔ ∀ a ∈ s, p a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          filter p l = l ↔ ∀ a ∈ l, p a) s fun l => Iff.trans ⟨fun h =>\n            List.Sublist.eq_of_sublist_of_length_eq (List.filter'_sublist _) (@congrArg _ _ _ _ length h),\n            congrArg List.to_UnorderedList⟩ List.filter'_eq_self\n\n    theorem filter_le_filter (p : α → Prop) {s t : UnorderedList α} (h : s ≤ t) : filter p s ≤ filter p t :=\n      @le.le_induction_on α s t (fun l₁ l₂ => filter p l₁ ≤ filter p l₂) h\n        (fun h => (h.filter' p).subperm)\n\n    theorem le.le_filter {s t : UnorderedList α} : s ≤ filter p t ↔ s ≤ t ∧ ∀ a ∈ s, p a :=\n      ⟨fun h => ⟨le.trans h (filter_le _ _), fun a m => of_mem_filter (mem_of_le h m)⟩,\n        fun ⟨h, al⟩ => filter_eq_self.mpr al ▸ filter_le_filter p h⟩\n\n    noncomputable def countp (p : α → Prop) (s : UnorderedList α) : Nat :=\n      Quot.liftOn s (List.countp p) (fun l₁ l₂ h => Perm.countp_eq p h)\n\n    namespace countp\n      variable (p : α → Prop)\n\n      @[simp] theorem coe_countp (l : List α) : countp p l = l.countp p := rfl\n\n      @[simp] theorem zero : countp p 0 = 0 := rfl\n\n      @[simp] theorem cons_of_pos {p} {a : α} (s : UnorderedList α) :\n        p a → countp p (s.cons a) = countp p s + 1 :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n            p a → countp p (l.cons a) = countp p l + 1) s (List.countp_cons_of_pos p)\n\n      @[simp] theorem cons_of_neg {p} {a : α} (s : UnorderedList α) :\n        ¬ p a → countp p (s.cons a) = countp p s :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n            ¬ p a → countp p (l.cons a) = countp p l) s (List.countp_cons_of_neg p)\n\n      theorem cons (b : α) (s) : countp p (s.cons b) = countp p s + (if p b then 1 else 0) := by\n        byCases h : p b; simp [h]; simp [h]\n\n      theorem countp_eq_length_filter (s : UnorderedList α) : countp p s = length (filter p s) :=\n        @Quotient.inductionOn _ _\n          (fun (l : UnorderedList α) => countp p l = length (filter p l)) s\n            fun l => List.countp_eq_length_filter' _ _\n\n      @[simp] theorem add (s t : UnorderedList α) : countp p (s + t) = countp p s + countp p t := by\n        simp [countp_eq_length_filter]\n\n      theorem pos {s : UnorderedList α} : 0 < countp p s ↔ ∃ a ∈ s, p a := by\n        simp [countp_eq_length_filter, length.pos_iff_exists_mem]\n\n    end countp\n\n    noncomputable def count (a : α) : UnorderedList α → Nat := countp (Eq a)\n\n    namespace count\n\n      @[simp] theorem zero (a : α) : count a 0 = 0 := rfl\n\n      @[simp] theorem cons_self (a : α) (s : UnorderedList α) : count a (s.cons a) = (count a s).succ :=\n        countp.cons_of_pos _ rfl\n\n      @[simp] theorem cons_of_ne {a b : α} (h : a ≠ b) (s : UnorderedList α) :\n        count a (s.cons b) = count a s :=\n          countp.cons_of_neg _ h\n\n      theorem cons (a b : α) (s : UnorderedList α) :\n        count a (s.cons b) = count a s + (if a = b then 1 else 0) := by\n          byCases h : a = b; repeat simp [h]\n\n      theorem singleton_self (a : α) : count a (UnorderedList.singleton a) = 1 := by\n        simp only [cons_self, singleton_eq_cons, zero]\n\n      theorem singleton (a b : α) : count a (UnorderedList.singleton b) = if a = b then 1 else 0 := by\n        simp only [cons, singleton_eq_cons, zero, Nat.zero_add]\n\n      @[simp] theorem add (a : α) : ∀ s t, count a (s + t) = count a s + count a t :=\n          countp.add _\n\n      theorem pos {a : α} {s : UnorderedList α} : 0 < count a s ↔ a ∈ s := by\n        simp [count, countp.pos]\n        exact ⟨fun ⟨x, xs, ax⟩ => by rw [ax]; exact xs, fun as => ⟨a, as, rfl⟩⟩\n\n      @[simp] theorem eq_zero {a : α} {s : UnorderedList α} : count a s = 0 ↔ a ∉ s :=\n        iff_not_comm.mp (pos.symm.trans Nat.pos_iff_ne_zero)\n\n      @[simp] theorem erase_self (a : α) (s : UnorderedList α) :\n        count a (s.erase a) = Nat.pred (count a s) := by\n          byCases h : a ∈ s\n          { rw [(by rw [erase.cons_erase h] : count a s = count a ((s.erase a).cons a)), cons_self]; simp }\n          rw [erase.erase_of_not_mem h, eq_zero.mpr h]; rfl\n\n      @[simp] theorem erase_of_ne {a b : α} (ab : a ≠ b) (s : UnorderedList α) :\n        count a (s.erase b) = count a s := by\n          byCases h : b ∈ s\n          rw [←count.cons_of_ne ab, erase.cons_erase h]\n          rw [erase.erase_of_not_mem h]\n\n      @[simp] theorem sub (a : α) (s t : UnorderedList α) : count a (s - t) = count a s - count a t := by\n        revert s; exact @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          ∀ (s : UnorderedList α), count a (s - l) = count a s - count a l) t\n          (fun l => by\n            induction l with\n            | nil => intro; simp\n            | cons b t ih =>\n              intro s; have := ih (s.erase b)\n              simp at this ⊢; rw [this]\n              byCases ab : a = b\n              { subst b; rw [count.erase_self, count.cons_self, Nat.sub_succ, Nat.pred_sub] }\n              rw [erase_of_ne ab, cons_of_ne ab])\n\n    end count\n\n    theorem nodup_iff_count_le_one {s : UnorderedList α} : nodup s ↔ ∀ a, count a s ≤ 1 :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n        nodup l ↔ ∀ a, count a l ≤ 1) s fun l => List.nodup_iff_count_le_one\n\n    theorem sub.mem_sub_of_nodup {a : α} {s t : UnorderedList α} (d : nodup s) :\n      a ∈ s - t ↔ a ∈ s ∧ a ∉ t :=\n        ⟨fun h => ⟨le.mem_of_le (le.sub_le_self _ _) h, fun h' =>\n          count.eq_zero.mp (by\n            rw [count.sub a s t, Nat.sub_eq_zero_iff_le]\n            exact Nat.le_trans (nodup_iff_count_le_one.mp d a) (count.pos.mpr h')) h⟩,\n        fun ⟨h₁, h₂⟩ => Or.resolve_right (append.mem_add.mp (le.mem_of_le (sub.le_sub_add  s t) h₁)) h₂⟩\n\n    @[simp] theorem le.add_sub_cancel_of_le {s t : UnorderedList α} (h : s ≤ t) : s + (t - s) = t :=\n      le.antisymm (by\n          let ⟨c, e⟩ := le_iff_exists_add.mp h\n          rw [e] at h ⊢\n          exact (le.add_le_add_left s).mpr sub.add_sub_le_left)\n        (sub.le_add_sub t s)\n\n    theorem le.sub_add_cancel_of_le {s t : UnorderedList α} (h : s ≤ t) : t - s + s = t := by\n      rw [append.comm]; exact add_sub_cancel_of_le h\n\n    section ndinsert\n\n      @[simp] theorem le_ndinsert_self (a : α) (s : UnorderedList α) : s ≤ ndinsert a s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          l ≤ ndinsert a l) s fun l => (List.Sublist.insert _ _).subperm\n\n      theorem ndinsert_le {a : α} {s t : UnorderedList α} : ndinsert a s ≤ t ↔ s ≤ t ∧ a ∈ t :=\n        ⟨fun h => ⟨le.trans (le_ndinsert_self _ _) h, le.mem_of_le h (mem_ndinsert_self _ _)⟩,\n        fun ⟨l, m⟩ => if h : a ∈ s then by\n          simp [h, l]\n        else by\n          rw [ndinsert_of_not_mem h, ← erase.cons_erase m, le.cons_le_cons_iff,\n            ←le.le_cons_of_not_mem h, erase.cons_erase m]; exact l⟩\n\n    end ndinsert\n\n    section ndunion\n\n      theorem ndunion_le {s t u : UnorderedList α} : ndunion s t ≤ u ↔ s ⊆ u ∧ t ≤ u :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) =>\n          ndunion l t ≤ u ↔ l ⊆ u ∧ t ≤ u) s (fun l => by\n            induction l with\n            | nil => simp\n            | cons a l ih =>\n              simp at ih; simp [ndinsert_le, ih]\n              exact ⟨fun ⟨⟨h₁, h₂⟩, h₃⟩ => ⟨fun x hx => Or.elim (mem_cons.mp hx)\n                  (fun h => by rw [h]; exact h₃) (fun h => h₁ h), h₂⟩,\n                fun ⟨h₁, h₂⟩ => ⟨⟨fun x hx => h₁ (mem_cons_of_mem hx), h₂⟩,\n                  h₁ (mem_cons_self a ↑l)⟩⟩)\n\n      theorem le_ndunion_right (s t : UnorderedList α) : t ≤ ndunion s t :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => l₂ ≤ ndunion l₁ l₂) s t\n          fun l₁ l₂ => Perm.Subperm.union_left l₂ l₁\n\n      theorem subset_ndunion_right (s t : UnorderedList α) : t ⊆ ndunion s t :=\n        le.subset_of_le (le_ndunion_right s t)\n\n      theorem subset_ndunion_left (s t : UnorderedList α) : s ⊆ ndunion s t :=\n        fun a h => mem_ndunion.mpr (Or.inl h)\n\n      theorem le_ndunion_left {s} (t : UnorderedList α) (d : nodup s) : s ≤ ndunion s t :=\n        (le.le_iff_subset d).mpr (subset_ndunion_left _ _)\n\n    end ndunion\n\n    section union\n\n      protected noncomputable def union (s t : UnorderedList α) : UnorderedList α := s - t + t\n\n      noncomputable instance : Union (UnorderedList α) where union := UnorderedList.union\n\n      theorem le_union_left (s t : UnorderedList α) : s ≤ s ∪ t := sub.le_sub_add s t\n\n      theorem le_union_right (s t : UnorderedList α) : t ≤ s ∪ t := le.add_left t (s - t)\n\n      theorem eq_union_left {s t : UnorderedList α} : t ≤ s → s ∪ t = s := le.sub_add_cancel_of_le\n\n      theorem union_le_union_right {s t : UnorderedList α} (h : s ≤ t) (u : UnorderedList α) : s ∪ u ≤ t ∪ u :=\n        (le.add_le_add_right u).mpr (sub.sub_le_sub_right h u)\n\n      theorem union_le {s t u : UnorderedList α} (h₁ : s ≤ u) (h₂ : t ≤ u) : s ∪ t ≤ u := by\n        rw [←eq_union_left h₂]; exact union_le_union_right h₁ t\n\n      theorem ndunion_le_union (s t : UnorderedList α) : ndunion s t ≤ s ∪ t :=\n        ndunion_le.mpr ⟨le.subset_of_le (le_union_left _ _), le_union_right _ _⟩\n\n      @[simp] theorem ndunion_eq_union {s t : UnorderedList α} (d : nodup s) : ndunion s t = s ∪ t :=\n        le.antisymm (ndunion_le_union _ _) $ union_le (le_ndunion_left _ d) (le_ndunion_right _ _)\n\n    end union\n\n    section ndinter\n\n      theorem le_ndinter {s t u : UnorderedList α} : s ≤ ndinter t u ↔ s ≤ t ∧ s ⊆ u := by\n        simp [ndinter, le.le_filter]; exact Iff.rfl\n\n      theorem ndinter_le_left (s t : UnorderedList α) : ndinter s t ≤ s :=\n        (le_ndinter.mp (le.refl _)).left\n\n      theorem ndinter_subset_left (s t : UnorderedList α) : ndinter s t ⊆ s :=\n        le.subset_of_le (ndinter_le_left s t)\n\n      theorem ndinter_subset_right (s t : UnorderedList α) : ndinter s t ⊆ t :=\n        (le_ndinter.mp (le.refl _)).right\n\n      theorem ndinter_le_right {s} (t : UnorderedList α) (d : nodup s) : ndinter s t ≤ t :=\n        (le.le_iff_subset (nodup_ndinter _ d)).mpr (ndinter_subset_right _ _)\n\n    end ndinter\n\n    section inter\n\n      noncomputable def inter (s t : UnorderedList α) : UnorderedList α :=\n        Quotient.liftOn₂ s t (fun l₁ l₂ => (l₁.bag_inter l₂ : UnorderedList α)) fun _ _ _ _ p₁ p₂ =>\n          Quot.sound (p₁.bag_inter p₂)\n\n      noncomputable instance UnorderedListIntersection : Intersection (UnorderedList α) where intersection := inter\n\n      @[simp] theorem inter_zero (s : UnorderedList α) : s ∩ 0 = 0 :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => l ∩ 0 = 0) s\n          fun l => congrArg List.to_UnorderedList l.bag_inter_nil\n\n      @[simp] theorem zero_inter (s : UnorderedList α) : 0 ∩ s = 0 :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => 0 ∩ l = 0) s\n          fun l => congrArg List.to_UnorderedList l.nil_bag_inter\n\n      @[simp] theorem cons_inter_of_pos {a : α} (s : UnorderedList α) {t : UnorderedList α} :\n        a ∈ t → (s.cons a) ∩ t = (s ∩ t.erase a).cons a :=\n          @Quotient.inductionOn₂ _ _ _ _\n            (fun (l₁ l₂ : UnorderedList α) => a ∈ l₂ → (l₁.cons a) ∩ l₂ = (l₁ ∩ l₂.erase a).cons a) s t\n              (fun _ _ h => congrArg List.to_UnorderedList (List.cons_bag_inter_of_pos _ h))\n\n      @[simp] theorem cons_inter_of_neg {a} (s : UnorderedList α) {t} :\n        a ∉ t → (s.cons a) ∩ t = s ∩ t :=\n          @Quotient.inductionOn₂ _ _ _ _\n            (fun (l₁ l₂ : UnorderedList α) => a ∉ l₂ → (l₁.cons a) ∩ l₂ = l₁ ∩ l₂) s t\n            fun _ _ h => congrArg List.to_UnorderedList (List.cons_bag_inter_of_neg _ h)\n\n      theorem inter_le_left (s t : UnorderedList α) : s ∩ t ≤ s :=\n        @Quotient.inductionOn₂ _ _ _ _\n          (fun (l₁ l₂ : UnorderedList α) => l₁ ∩ l₂ ≤ l₁) s t fun _ _ =>\n            (List.bag_inter_sublist_left _ _).subperm\n\n      theorem inter_le_right (s : UnorderedList α) : ∀ t, s ∩ t ≤ t :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList α) => ∀ t, l ∩ t ≤ t) s\n          (fun l => by\n            induction l with\n            | nil => exact fun t => (zero_inter t).symm ▸ le.zero_le _\n            | cons a s ih =>\n              intro t; byCases h : a ∈ t\n              { have := le.cons_le_cons a (ih (t.erase a));\n                rw [erase.cons_erase h, ←cons_inter_of_pos _ h] at this\n                exact this }\n              { simp only [list_coe_eq, cons_eq]\n                rw [cons_inter_of_neg _ h]\n                exact ih t })\n\n      theorem le_inter {s t : UnorderedList α} (h₁ : s ≤ t) (h₂ : s ≤ u) : s ≤ t ∩ u := by\n        revert s u; exact @Quotient.inductionOn _ _ (fun (l : UnorderedList α)\n          => ∀ {u s : UnorderedList α}, s ≤ l → s ≤ u → s ≤ l ∩ u) t (fun l => by\n            induction l with\n            | nil => intro _ _ h _; simp only [list_coe_eq, empty_eq, zero_inter]; exact h\n            | cons a t ih =>\n              intro u s h₁ h₂\n              byCases h : a ∈ u\n              { rw [list_coe_eq, cons_eq, cons_inter_of_pos _ h, ←erase.erase_le_iff_le_cons]\n                exact ih (erase.erase_le_iff_le_cons.mpr h₁) (erase.erase_le_erase _ h₂) }\n              { rw [list_coe_eq, cons_eq, cons_inter_of_neg _ h]\n                exact ih ((le.le_cons_of_not_mem (mt (le.mem_of_le h₂) h)).mp h₁) h₂ })\n\n      @[simp] theorem mem_inter {s t : UnorderedList α} : a ∈ s ∩ t ↔ a ∈ s ∧ a ∈ t :=\n        ⟨fun h => ⟨le.mem_of_le (inter_le_left _ _) h, le.mem_of_le (inter_le_right _ _) h⟩,\n        fun ⟨h₁, h₂⟩ => by rw [← erase.cons_erase h₁, cons_inter_of_pos _ h₂]; exact mem_cons_self a _⟩\n\n      theorem inter_le_ndinter (s t : UnorderedList α) : s ∩ t ≤ ndinter s t :=\n        le_ndinter.mpr ⟨inter_le_left _ _, le.subset_of_le (inter_le_right _ _)⟩\n\n      @[simp] theorem ndinter_eq_inter {s t : UnorderedList α} (d : nodup s) : ndinter s t = s ∩ t :=\n        le.antisymm (le_inter (ndinter_le_left _ _) (ndinter_le_right _ d)) (inter_le_ndinter _ _)\n\n    end inter\n\n    namespace sub\n\n      theorem sub_add_eq_sub_sub (s t u : UnorderedList α) : s - (t + u) = s - t - u :=\n        le.antisymm (by\n          apply sub.sub_le_iff_le_add_left.mpr; rw [append.assoc]\n          exact le.trans (sub.le_add_sub s t) ((le.add_le_add_left t).mpr (sub.le_add_sub (s - t) u)))\n        (by\n          apply sub.sub_le_iff_le_add_left.mpr\n          apply sub.sub_le_iff_le_add_left.mpr\n          rw [←append.assoc]; exact sub.le_add_sub s _)\n\n      theorem le_add_sub' (s t : UnorderedList α) : s ≤ t + s - t :=\n          le.add_le_add_cancel (sub.le_add_sub (t + s) t)\n\n      theorem le_add_sub'' (s t : UnorderedList α) : s ≤ s + t - t := by\n        rw [append.comm]; exact le_add_sub' s t\n\n      theorem sub_eq_of_eq_add {s t u : UnorderedList α} (h : s = u + t) : s - t = u :=\n        le.antisymm (sub.sub_le_iff_le_add_right.mpr (le.of_eq h)) (by\n          rw [h]; exact sub.le_add_sub'' u t)\n\n      @[simp] theorem add_sub_cancel_right (s t : UnorderedList α) : s + t - t = s :=\n        sub_eq_of_eq_add (by rw [append.comm])\n\n    end sub\n\n    theorem union_add_distrib (s t u : UnorderedList α) : (s ∪ t) + u = (s + u) ∪ (t + u) := by\n      have : s + u - (t + u) = s - t := by\n        rw [append.comm t, sub.sub_add_eq_sub_sub, sub.add_sub_cancel_right]\n      simp only [Union.union, UnorderedList.union]\n      rw [this, append.assoc]\n\n    theorem inter_add_distrib (s t u : UnorderedList α) : (s ∩ t) + u = (s + u) ∩ (t + u) := by\n      apply byContradiction; intro h\n      have := le_inter ((le.add_le_add_right u).mpr (inter_le_left s t)) ((le.add_le_add_right u).mpr (inter_le_right s t))\n      let ⟨a, ha⟩ := (le.ne_iff_cons this).mp h\n      rw [← append.cons_over_left] at ha\n      have : (s ∩ t).cons a = s ∩ t := le.antisymm (le_inter\n        ((le.add_le_add_right u).mp (le.trans ha (inter_le_left (s + u) (t + u))))\n        ((le.add_le_add_right u).mp (le.trans ha (inter_le_right (s + u) (t + u)))))\n        (le.cons_of_le a (le.refl (s ∩ t)))\n      apply Nat.succ_ne_self (length (s ∩ t))\n      rw [←Nat.add_one, ←length.cons a (s ∩ t)]\n      exact congrArg length this\n\n    theorem add_inter_distrib (s t u : UnorderedList α) : s + (t ∩ u) = (s + t) ∩ (s + u) := by\n      rw [append.comm, inter_add_distrib, append.comm s, append.comm s]\n\n    theorem union_add_inter (s t : UnorderedList α) : s ∪ t + s ∩ t = s + t :=\n      le.antisymm (by\n          rw [union_add_distrib]\n          exact union_le ((le.add_le_add_left s).mpr (inter_le_right s t))\n            (by rw [append.comm]; exact (le.add_le_add_right t).mpr (inter_le_left s t)))\n        (by\n          rw [append.comm, add_inter_distrib]\n          apply le_inter ((le.add_le_add_right s).mpr (le_union_right s t))\n          rw [append.comm]\n          exact (le.add_le_add_right t).mpr (le_union_left s t))\n\n    noncomputable def dedup (s : UnorderedList α) : UnorderedList α :=\n      Quotient.liftOn s (fun l => (l.dedup : UnorderedList α))\n        fun _ _ p => Quot.sound p.dedup\n\n    @[simp] theorem dedup_zero : dedup (0 : UnorderedList α) = 0 := rfl\n\n    @[simp] theorem mem_dedup {a : α} {l : UnorderedList α} : a ∈ l.dedup ↔ a ∈ l :=\n      @Quotient.inductionOn _ _ (fun s : UnorderedList α => a ∈ s.dedup ↔ a ∈ s) l fun _ => List.mem_dedup\n\n    theorem nodup_dedup (l : UnorderedList α) : l.dedup.nodup :=\n      @Quotient.inductionOn _ _ (fun s : UnorderedList α => s.dedup.nodup) l List.nodup_dedup\n\n    theorem dedup_le (l : UnorderedList α) : l.dedup ≤ l :=\n      @Quotient.ind _ _ (fun s : UnorderedList α => s.dedup ≤ s) (fun l => l.dedup_sublist.subperm) l\n\n  end UnorderedList\nend M4R\n", "meta": {"author": "Hop311", "repo": "M4R", "sha": "ebd1b04af344f9737d290bf8b48b3cde35e9787b", "save_path": "github-repos/lean/Hop311-M4R", "path": "github-repos/lean/Hop311-M4R/M4R-ebd1b04af344f9737d290bf8b48b3cde35e9787b/M4R/Set/Finite/UnorderedList.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.49935435308904946}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Mario Carneiro, Simon Hudon\n\n! This file was ported from Lean 3 source module data.typevec\n! leanprover-community/mathlib commit 63f84d91dd847f50bae04a01071f3a5491934e36\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Fin.Fin2\nimport Mathbin.Logic.Function.Basic\nimport Mathbin.Tactic.Basic\n\n/-!\n\n# Tuples of types, and their categorical structure.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n## Features\n\n* `typevec n` - n-tuples of types\n* `α ⟹ β`    - n-tuples of maps\n* `f ⊚ g`     - composition\n\nAlso, support functions for operating with n-tuples of types, such as:\n\n* `append1 α β`    - append type `β` to n-tuple `α` to obtain an (n+1)-tuple\n* `drop α`         - drops the last element of an (n+1)-tuple\n* `last α`         - returns the last element of an (n+1)-tuple\n* `append_fun f g` - appends a function g to an n-tuple of functions\n* `drop_fun f`     - drops the last function from an n+1-tuple\n* `last_fun f`     - returns the last function of a tuple.\n\nSince e.g. `append1 α.drop α.last` is propositionally equal to `α` but not definitionally equal\nto it, we need support functions and lemmas to mediate between constructions.\n-/\n\n\nuniverse u v w\n\n#print TypeVec /-\n/-- n-tuples of types, as a category\n-/\ndef TypeVec (n : ℕ) :=\n  Fin2 n → Type _\n#align typevec TypeVec\n-/\n\ninstance {n} : Inhabited (TypeVec.{u} n) :=\n  ⟨fun _ => PUnit⟩\n\nnamespace TypeVec\n\nvariable {n : ℕ}\n\n#print TypeVec.Arrow /-\n/-- arrow in the category of `typevec` -/\ndef Arrow (α β : TypeVec n) :=\n  ∀ i : Fin2 n, α i → β i\n#align typevec.arrow TypeVec.Arrow\n-/\n\n-- mathport name: typevec.arrow\nscoped[MvFunctor] infixl:40 \" ⟹ \" => TypeVec.Arrow\n\n#print TypeVec.Arrow.inhabited /-\ninstance Arrow.inhabited (α β : TypeVec n) [∀ i, Inhabited (β i)] : Inhabited (α ⟹ β) :=\n  ⟨fun _ _ => default⟩\n#align typevec.arrow.inhabited TypeVec.Arrow.inhabited\n-/\n\n#print TypeVec.id /-\n/-- identity of arrow composition -/\ndef id {α : TypeVec n} : α ⟹ α := fun i x => x\n#align typevec.id TypeVec.id\n-/\n\n#print TypeVec.comp /-\n/-- arrow composition in the category of `typevec` -/\ndef comp {α β γ : TypeVec n} (g : β ⟹ γ) (f : α ⟹ β) : α ⟹ γ := fun i x => g i (f i x)\n#align typevec.comp TypeVec.comp\n-/\n\n-- mathport name: typevec.comp\nscoped[MvFunctor] infixr:80 \" ⊚ \" => TypeVec.comp\n\n/- warning: typevec.id_comp -> TypeVec.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {β : TypeVec.{u2} n} (f : TypeVec.Arrow.{u1, u2} n α β), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n α β) (TypeVec.comp.{u1, u2, u2} n α β β (TypeVec.id.{u2} n β) f) f\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} n} {β : TypeVec.{u1} n} (f : TypeVec.Arrow.{u2, u1} n α β), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n α β) (TypeVec.comp.{u2, u1, u1} n α β β (TypeVec.id.{u1} n β) f) f\nCase conversion may be inaccurate. Consider using '#align typevec.id_comp TypeVec.id_compₓ'. -/\n-- type as \\oo\n@[simp]\ntheorem id_comp {α β : TypeVec n} (f : α ⟹ β) : id ⊚ f = f :=\n  rfl\n#align typevec.id_comp TypeVec.id_comp\n\n/- warning: typevec.comp_id -> TypeVec.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {β : TypeVec.{u2} n} (f : TypeVec.Arrow.{u1, u2} n α β), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n α β) (TypeVec.comp.{u1, u1, u2} n α α β f (TypeVec.id.{u1} n α)) f\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} n} {β : TypeVec.{u1} n} (f : TypeVec.Arrow.{u2, u1} n α β), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n α β) (TypeVec.comp.{u2, u2, u1} n α α β f (TypeVec.id.{u2} n α)) f\nCase conversion may be inaccurate. Consider using '#align typevec.comp_id TypeVec.comp_idₓ'. -/\n@[simp]\ntheorem comp_id {α β : TypeVec n} (f : α ⟹ β) : f ⊚ id = f :=\n  rfl\n#align typevec.comp_id TypeVec.comp_id\n\n/- warning: typevec.comp_assoc -> TypeVec.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {β : TypeVec.{u2} n} {γ : TypeVec.{u3} n} {δ : TypeVec.{u4} n} (h : TypeVec.Arrow.{u3, u4} n γ δ) (g : TypeVec.Arrow.{u2, u3} n β γ) (f : TypeVec.Arrow.{u1, u2} n α β), Eq.{max 1 (succ u1) (succ u4)} (TypeVec.Arrow.{u1, u4} n α δ) (TypeVec.comp.{u1, u2, u4} n α β δ (TypeVec.comp.{u2, u3, u4} n β γ δ h g) f) (TypeVec.comp.{u1, u3, u4} n α γ δ h (TypeVec.comp.{u1, u2, u3} n α β γ g f))\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u4} n} {β : TypeVec.{u3} n} {γ : TypeVec.{u2} n} {δ : TypeVec.{u1} n} (h : TypeVec.Arrow.{u2, u1} n γ δ) (g : TypeVec.Arrow.{u3, u2} n β γ) (f : TypeVec.Arrow.{u4, u3} n α β), Eq.{max (succ u4) (succ u1)} (TypeVec.Arrow.{u4, u1} n α δ) (TypeVec.comp.{u4, u3, u1} n α β δ (TypeVec.comp.{u3, u2, u1} n β γ δ h g) f) (TypeVec.comp.{u4, u2, u1} n α γ δ h (TypeVec.comp.{u4, u3, u2} n α β γ g f))\nCase conversion may be inaccurate. Consider using '#align typevec.comp_assoc TypeVec.comp_assocₓ'. -/\ntheorem comp_assoc {α β γ δ : TypeVec n} (h : γ ⟹ δ) (g : β ⟹ γ) (f : α ⟹ β) :\n    (h ⊚ g) ⊚ f = h ⊚ g ⊚ f :=\n  rfl\n#align typevec.comp_assoc TypeVec.comp_assoc\n\n#print TypeVec.append1 /-\n/-- Support for extending a typevec by one element.\n-/\ndef append1 (α : TypeVec n) (β : Type _) : TypeVec (n + 1)\n  | Fin2.fs i => α i\n  | Fin2.fz => β\n#align typevec.append1 TypeVec.append1\n-/\n\n-- mathport name: typevec.append1\ninfixl:67 \" ::: \" => append1\n\n#print TypeVec.drop /-\n/-- retain only a `n-length` prefix of the argument -/\ndef drop (α : TypeVec.{u} (n + 1)) : TypeVec n := fun i => α i.fs\n#align typevec.drop TypeVec.drop\n-/\n\n#print TypeVec.last /-\n/-- take the last value of a `(n+1)-length` vector -/\ndef last (α : TypeVec.{u} (n + 1)) : Type _ :=\n  α Fin2.fz\n#align typevec.last TypeVec.last\n-/\n\n#print TypeVec.last.inhabited /-\ninstance last.inhabited (α : TypeVec (n + 1)) [Inhabited (α Fin2.fz)] : Inhabited (last α) :=\n  ⟨show α Fin2.fz from default⟩\n#align typevec.last.inhabited TypeVec.last.inhabited\n-/\n\n#print TypeVec.drop_append1 /-\ntheorem drop_append1 {α : TypeVec n} {β : Type _} {i : Fin2 n} : drop (append1 α β) i = α i :=\n  rfl\n#align typevec.drop_append1 TypeVec.drop_append1\n-/\n\n#print TypeVec.drop_append1' /-\ntheorem drop_append1' {α : TypeVec n} {β : Type _} : drop (append1 α β) = α := by\n  ext <;> apply drop_append1\n#align typevec.drop_append1' TypeVec.drop_append1'\n-/\n\n#print TypeVec.last_append1 /-\ntheorem last_append1 {α : TypeVec n} {β : Type _} : last (append1 α β) = β :=\n  rfl\n#align typevec.last_append1 TypeVec.last_append1\n-/\n\n#print TypeVec.append1_drop_last /-\n@[simp]\ntheorem append1_drop_last (α : TypeVec (n + 1)) : append1 (drop α) (last α) = α :=\n  funext fun i => by cases i <;> rfl\n#align typevec.append1_drop_last TypeVec.append1_drop_last\n-/\n\n#print TypeVec.append1Cases /-\n/-- cases on `(n+1)-length` vectors -/\n@[elab_as_elim]\ndef append1Cases {C : TypeVec (n + 1) → Sort u} (H : ∀ α β, C (append1 α β)) (γ) : C γ := by\n  rw [← @append1_drop_last _ γ] <;> apply H\n#align typevec.append1_cases TypeVec.append1Cases\n-/\n\n/- warning: typevec.append1_cases_append1 -> TypeVec.append1_cases_append1 is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {C : (TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Sort.{u1}} (H : forall (α : TypeVec.{u2} n) (β : Type.{u2}), C (TypeVec.append1.{u2} n α β)) (α : TypeVec.{u2} n) (β : Type.{u2}), Eq.{u1} (C (TypeVec.append1.{u2} n α β)) (TypeVec.append1Cases.{u1, u2} n C H (TypeVec.append1.{u2} n α β)) (H α β)\nbut is expected to have type\n  forall {n : Nat} {C : (TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Sort.{u2}} (H : forall (α : TypeVec.{u1} n) (β : Type.{u1}), C (TypeVec.append1.{u1} n α β)) (α : TypeVec.{u1} n) (β : Type.{u1}), Eq.{u2} (C (TypeVec.append1.{u1} n α β)) (TypeVec.append1Cases.{u2, u1} n C H (TypeVec.append1.{u1} n α β)) (H α β)\nCase conversion may be inaccurate. Consider using '#align typevec.append1_cases_append1 TypeVec.append1_cases_append1ₓ'. -/\n@[simp]\ntheorem append1_cases_append1 {C : TypeVec (n + 1) → Sort u} (H : ∀ α β, C (append1 α β)) (α β) :\n    @append1Cases _ C H (append1 α β) = H α β :=\n  rfl\n#align typevec.append1_cases_append1 TypeVec.append1_cases_append1\n\n#print TypeVec.splitFun /-\n/-- append an arrow and a function for arbitrary source and target\ntype vectors -/\ndef splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') : α ⟹ α'\n  | Fin2.fs i => f i\n  | Fin2.fz => g\n#align typevec.split_fun TypeVec.splitFun\n-/\n\n#print TypeVec.appendFun /-\n/-- append an arrow and a function as well as their respective source\nand target types / typevecs -/\ndef appendFun {α α' : TypeVec n} {β β' : Type _} (f : α ⟹ α') (g : β → β') :\n    append1 α β ⟹ append1 α' β' :=\n  splitFun f g\n#align typevec.append_fun TypeVec.appendFun\n-/\n\n-- mathport name: typevec.append_fun\ninfixl:0 \" ::: \" => appendFun\n\n#print TypeVec.dropFun /-\n/-- split off the prefix of an arrow -/\ndef dropFun {α β : TypeVec (n + 1)} (f : α ⟹ β) : drop α ⟹ drop β := fun i => f i.fs\n#align typevec.drop_fun TypeVec.dropFun\n-/\n\n#print TypeVec.lastFun /-\n/-- split off the last function of an arrow -/\ndef lastFun {α β : TypeVec (n + 1)} (f : α ⟹ β) : last α → last β :=\n  f Fin2.fz\n#align typevec.last_fun TypeVec.lastFun\n-/\n\n#print TypeVec.nilFun /-\n/-- arrow in the category of `0-length` vectors -/\ndef nilFun {α : TypeVec 0} {β : TypeVec 0} : α ⟹ β := fun i => Fin2.elim0 i\n#align typevec.nil_fun TypeVec.nilFun\n-/\n\n/- warning: typevec.eq_of_drop_last_eq -> TypeVec.eq_of_drop_last_eq is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {β : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {f : TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α β} {g : TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α β}, (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α) (TypeVec.drop.{u2} n β)) (TypeVec.dropFun.{u1, u2} n α β f) (TypeVec.dropFun.{u1, u2} n α β g)) -> (Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n α) -> (TypeVec.last.{u2} n β)) (TypeVec.lastFun.{u1, u2} n α β f) (TypeVec.lastFun.{u1, u2} n α β g)) -> (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α β) f g)\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {β : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {f : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α β} {g : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α β}, (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α) (TypeVec.drop.{u1} n β)) (TypeVec.dropFun.{u2, u1} n α β f) (TypeVec.dropFun.{u2, u1} n α β g)) -> (Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n α) -> (TypeVec.last.{u1} n β)) (TypeVec.lastFun.{u2, u1} n α β f) (TypeVec.lastFun.{u2, u1} n α β g)) -> (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α β) f g)\nCase conversion may be inaccurate. Consider using '#align typevec.eq_of_drop_last_eq TypeVec.eq_of_drop_last_eqₓ'. -/\ntheorem eq_of_drop_last_eq {α β : TypeVec (n + 1)} {f g : α ⟹ β} (h₀ : dropFun f = dropFun g)\n    (h₁ : lastFun f = lastFun g) : f = g := by\n  replace h₀ := congr_fun h₀ <;> ext1 ⟨⟩ <;> apply_assumption\n#align typevec.eq_of_drop_last_eq TypeVec.eq_of_drop_last_eq\n\n/- warning: typevec.drop_fun_split_fun -> TypeVec.dropFun_splitFun is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α' : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} (f : TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α) (TypeVec.drop.{u2} n α')) (g : (TypeVec.last.{u1} n α) -> (TypeVec.last.{u2} n α')), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α) (TypeVec.drop.{u2} n α')) (TypeVec.dropFun.{u1, u2} n α α' (TypeVec.splitFun.{u1, u2} n α α' f g)) f\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α' : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f : TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α) (TypeVec.drop.{u1} n α')) (g : (TypeVec.last.{u2} n α) -> (TypeVec.last.{u1} n α')), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α) (TypeVec.drop.{u1} n α')) (TypeVec.dropFun.{u2, u1} n α α' (TypeVec.splitFun.{u2, u1} n α α' f g)) f\nCase conversion may be inaccurate. Consider using '#align typevec.drop_fun_split_fun TypeVec.dropFun_splitFunₓ'. -/\n@[simp]\ntheorem dropFun_splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') :\n    dropFun (splitFun f g) = f :=\n  rfl\n#align typevec.drop_fun_split_fun TypeVec.dropFun_splitFun\n\n#print TypeVec.Arrow.mp /-\n/-- turn an equality into an arrow -/\ndef Arrow.mp {α β : TypeVec n} (h : α = β) : α ⟹ β\n  | i => Eq.mp (congr_fun h _)\n#align typevec.arrow.mp TypeVec.Arrow.mp\n-/\n\n#print TypeVec.Arrow.mpr /-\n/-- turn an equality into an arrow, with reverse direction -/\ndef Arrow.mpr {α β : TypeVec n} (h : α = β) : β ⟹ α\n  | i => Eq.mpr (congr_fun h _)\n#align typevec.arrow.mpr TypeVec.Arrow.mpr\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.toAppend1DropLast /-\n/-- decompose a vector into its prefix appended with its last element -/\ndef toAppend1DropLast {α : TypeVec (n + 1)} : α ⟹ (drop α ::: last α) :=\n  Arrow.mpr (append1_drop_last _)\n#align typevec.to_append1_drop_last TypeVec.toAppend1DropLast\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.fromAppend1DropLast /-\n/-- stitch two bits of a vector back together -/\ndef fromAppend1DropLast {α : TypeVec (n + 1)} : (drop α ::: last α) ⟹ α :=\n  Arrow.mp (append1_drop_last _)\n#align typevec.from_append1_drop_last TypeVec.fromAppend1DropLast\n-/\n\n/- warning: typevec.last_fun_split_fun -> TypeVec.lastFun_splitFun is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α' : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} (f : TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α) (TypeVec.drop.{u2} n α')) (g : (TypeVec.last.{u1} n α) -> (TypeVec.last.{u2} n α')), Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n α) -> (TypeVec.last.{u2} n α')) (TypeVec.lastFun.{u1, u2} n α α' (TypeVec.splitFun.{u1, u2} n α α' f g)) g\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α' : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f : TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α) (TypeVec.drop.{u1} n α')) (g : (TypeVec.last.{u2} n α) -> (TypeVec.last.{u1} n α')), Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n α) -> (TypeVec.last.{u1} n α')) (TypeVec.lastFun.{u2, u1} n α α' (TypeVec.splitFun.{u2, u1} n α α' f g)) g\nCase conversion may be inaccurate. Consider using '#align typevec.last_fun_split_fun TypeVec.lastFun_splitFunₓ'. -/\n@[simp]\ntheorem lastFun_splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') :\n    lastFun (splitFun f g) = g :=\n  rfl\n#align typevec.last_fun_split_fun TypeVec.lastFun_splitFun\n\n/- warning: typevec.drop_fun_append_fun -> TypeVec.dropFun_appendFun is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {α' : TypeVec.{u2} n} {β : Type.{u1}} {β' : Type.{u2}} (f : TypeVec.Arrow.{u1, u2} n α α') (g : β -> β'), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n α β)) (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n α' β'))) (TypeVec.dropFun.{u1, u2} n (TypeVec.append1.{u1} n α β) (TypeVec.append1.{u2} n α' β') (TypeVec.appendFun.{u1, u2} n α α' β β' f g)) f\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} n} {α' : TypeVec.{u1} n} {β : Type.{u2}} {β' : Type.{u1}} (f : TypeVec.Arrow.{u2, u1} n α α') (g : β -> β'), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n α β)) (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n α' β'))) (TypeVec.dropFun.{u2, u1} n (TypeVec.append1.{u2} n α β) (TypeVec.append1.{u1} n α' β') (TypeVec.appendFun.{u2, u1} n α α' β β' f g)) f\nCase conversion may be inaccurate. Consider using '#align typevec.drop_fun_append_fun TypeVec.dropFun_appendFunₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem dropFun_appendFun {α α' : TypeVec n} {β β' : Type _} (f : α ⟹ α') (g : β → β') :\n    dropFun (f ::: g) = f :=\n  rfl\n#align typevec.drop_fun_append_fun TypeVec.dropFun_appendFun\n\n/- warning: typevec.last_fun_append_fun -> TypeVec.lastFun_appendFun is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {α' : TypeVec.{u2} n} {β : Type.{u1}} {β' : Type.{u2}} (f : TypeVec.Arrow.{u1, u2} n α α') (g : β -> β'), Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n (TypeVec.append1.{u1} n α β)) -> (TypeVec.last.{u2} n (TypeVec.append1.{u2} n α' β'))) (TypeVec.lastFun.{u1, u2} n (TypeVec.append1.{u1} n α β) (TypeVec.append1.{u2} n α' β') (TypeVec.appendFun.{u1, u2} n α α' β β' f g)) g\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} n} {α' : TypeVec.{u1} n} {β : Type.{u2}} {β' : Type.{u1}} (f : TypeVec.Arrow.{u2, u1} n α α') (g : β -> β'), Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n (TypeVec.append1.{u2} n α β)) -> (TypeVec.last.{u1} n (TypeVec.append1.{u1} n α' β'))) (TypeVec.lastFun.{u2, u1} n (TypeVec.append1.{u2} n α β) (TypeVec.append1.{u1} n α' β') (TypeVec.appendFun.{u2, u1} n α α' β β' f g)) g\nCase conversion may be inaccurate. Consider using '#align typevec.last_fun_append_fun TypeVec.lastFun_appendFunₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem lastFun_appendFun {α α' : TypeVec n} {β β' : Type _} (f : α ⟹ α') (g : β → β') :\n    lastFun (f ::: g) = g :=\n  rfl\n#align typevec.last_fun_append_fun TypeVec.lastFun_appendFun\n\n/- warning: typevec.split_drop_fun_last_fun -> TypeVec.split_dropFun_lastFun is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α' : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} (f : TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α α'), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α α') (TypeVec.splitFun.{u1, u2} n α α' (TypeVec.dropFun.{u1, u2} n α α' f) (TypeVec.lastFun.{u1, u2} n α α' f)) f\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α' : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α α'), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α α') (TypeVec.splitFun.{u2, u1} n α α' (TypeVec.dropFun.{u2, u1} n α α' f) (TypeVec.lastFun.{u2, u1} n α α' f)) f\nCase conversion may be inaccurate. Consider using '#align typevec.split_drop_fun_last_fun TypeVec.split_dropFun_lastFunₓ'. -/\ntheorem split_dropFun_lastFun {α α' : TypeVec (n + 1)} (f : α ⟹ α') :\n    splitFun (dropFun f) (lastFun f) = f :=\n  eq_of_drop_last_eq rfl rfl\n#align typevec.split_drop_fun_last_fun TypeVec.split_dropFun_lastFun\n\n/- warning: typevec.split_fun_inj -> TypeVec.splitFun_inj is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α' : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {f : TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α) (TypeVec.drop.{u2} n α')} {f' : TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α) (TypeVec.drop.{u2} n α')} {g : (TypeVec.last.{u1} n α) -> (TypeVec.last.{u2} n α')} {g' : (TypeVec.last.{u1} n α) -> (TypeVec.last.{u2} n α')}, (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α α') (TypeVec.splitFun.{u1, u2} n α α' f g) (TypeVec.splitFun.{u1, u2} n α α' f' g')) -> (And (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α) (TypeVec.drop.{u2} n α')) f f') (Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n α) -> (TypeVec.last.{u2} n α')) g g'))\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α' : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {f : TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α) (TypeVec.drop.{u1} n α')} {f' : TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α) (TypeVec.drop.{u1} n α')} {g : (TypeVec.last.{u2} n α) -> (TypeVec.last.{u1} n α')} {g' : (TypeVec.last.{u2} n α) -> (TypeVec.last.{u1} n α')}, (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α α') (TypeVec.splitFun.{u2, u1} n α α' f g) (TypeVec.splitFun.{u2, u1} n α α' f' g')) -> (And (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α) (TypeVec.drop.{u1} n α')) f f') (Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n α) -> (TypeVec.last.{u1} n α')) g g'))\nCase conversion may be inaccurate. Consider using '#align typevec.split_fun_inj TypeVec.splitFun_injₓ'. -/\ntheorem splitFun_inj {α α' : TypeVec (n + 1)} {f f' : drop α ⟹ drop α'} {g g' : last α → last α'}\n    (H : splitFun f g = splitFun f' g') : f = f' ∧ g = g' := by\n  rw [← drop_fun_split_fun f g, H, ← last_fun_split_fun f g, H] <;> simp\n#align typevec.split_fun_inj TypeVec.splitFun_inj\n\n/- warning: typevec.append_fun_inj -> TypeVec.appendFun_inj is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {α' : TypeVec.{u2} n} {β : Type.{u1}} {β' : Type.{u2}} {f : TypeVec.Arrow.{u1, u2} n α α'} {f' : TypeVec.Arrow.{u1, u2} n α α'} {g : β -> β'} {g' : β -> β'}, (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α β) (TypeVec.append1.{u2} n α' β')) (TypeVec.appendFun.{u1, u2} n α α' β β' f g) (TypeVec.appendFun.{u1, u2} n α α' β β' f' g')) -> (And (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n α α') f f') (Eq.{max (succ u1) (succ u2)} (β -> β') g g'))\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} n} {α' : TypeVec.{u1} n} {β : Type.{u2}} {β' : Type.{u1}} {f : TypeVec.Arrow.{u2, u1} n α α'} {f' : TypeVec.Arrow.{u2, u1} n α α'} {g : β -> β'} {g' : β -> β'}, (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u2} n α β) (TypeVec.append1.{u1} n α' β')) (TypeVec.appendFun.{u2, u1} n α α' β β' f g) (TypeVec.appendFun.{u2, u1} n α α' β β' f' g')) -> (And (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n α α') f f') (Eq.{max (succ u2) (succ u1)} (β -> β') g g'))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_inj TypeVec.appendFun_injₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem appendFun_inj {α α' : TypeVec n} {β β' : Type _} {f f' : α ⟹ α'} {g g' : β → β'} :\n    (f ::: g) = (f' ::: g') → f = f' ∧ g = g' :=\n  splitFun_inj\n#align typevec.append_fun_inj TypeVec.appendFun_inj\n\n/- warning: typevec.split_fun_comp -> TypeVec.splitFun_comp is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α₀ : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α₁ : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α₂ : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} (f₀ : TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n α₀) (TypeVec.drop.{u2} n α₁)) (f₁ : TypeVec.Arrow.{u2, u3} n (TypeVec.drop.{u2} n α₁) (TypeVec.drop.{u3} n α₂)) (g₀ : (TypeVec.last.{u1} n α₀) -> (TypeVec.last.{u2} n α₁)) (g₁ : (TypeVec.last.{u2} n α₁) -> (TypeVec.last.{u3} n α₂)), Eq.{max 1 (succ u1) (succ u3)} (TypeVec.Arrow.{u1, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₀ α₂) (TypeVec.splitFun.{u1, u3} n α₀ α₂ (TypeVec.comp.{u1, u2, u3} n (TypeVec.drop.{u1} n α₀) (TypeVec.drop.{u2} n α₁) (TypeVec.drop.{u3} n α₂) f₁ f₀) (Function.comp.{succ u1, succ u2, succ u3} (TypeVec.last.{u1} n α₀) (TypeVec.last.{u2} n α₁) (TypeVec.last.{u3} n α₂) g₁ g₀)) (TypeVec.comp.{u1, u2, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₀ α₁ α₂ (TypeVec.splitFun.{u2, u3} n α₁ α₂ f₁ g₁) (TypeVec.splitFun.{u1, u2} n α₀ α₁ f₀ g₀))\nbut is expected to have type\n  forall {n : Nat} {α₀ : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α₁ : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α₂ : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f₀ : TypeVec.Arrow.{u3, u2} n (TypeVec.drop.{u3} n α₀) (TypeVec.drop.{u2} n α₁)) (f₁ : TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n α₁) (TypeVec.drop.{u1} n α₂)) (g₀ : (TypeVec.last.{u3} n α₀) -> (TypeVec.last.{u2} n α₁)) (g₁ : (TypeVec.last.{u2} n α₁) -> (TypeVec.last.{u1} n α₂)), Eq.{max (succ u3) (succ u1)} (TypeVec.Arrow.{u3, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₀ α₂) (TypeVec.splitFun.{u3, u1} n α₀ α₂ (TypeVec.comp.{u3, u2, u1} n (TypeVec.drop.{u3} n α₀) (TypeVec.drop.{u2} n α₁) (TypeVec.drop.{u1} n α₂) f₁ f₀) (Function.comp.{succ u3, succ u2, succ u1} (TypeVec.last.{u3} n α₀) (TypeVec.last.{u2} n α₁) (TypeVec.last.{u1} n α₂) g₁ g₀)) (TypeVec.comp.{u3, u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₀ α₁ α₂ (TypeVec.splitFun.{u2, u1} n α₁ α₂ f₁ g₁) (TypeVec.splitFun.{u3, u2} n α₀ α₁ f₀ g₀))\nCase conversion may be inaccurate. Consider using '#align typevec.split_fun_comp TypeVec.splitFun_compₓ'. -/\ntheorem splitFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : drop α₀ ⟹ drop α₁) (f₁ : drop α₁ ⟹ drop α₂)\n    (g₀ : last α₀ → last α₁) (g₁ : last α₁ → last α₂) :\n    splitFun (f₁ ⊚ f₀) (g₁ ∘ g₀) = splitFun f₁ g₁ ⊚ splitFun f₀ g₀ :=\n  eq_of_drop_last_eq rfl rfl\n#align typevec.split_fun_comp TypeVec.splitFun_comp\n\n/- warning: typevec.append_fun_comp_split_fun -> TypeVec.appendFun_comp_splitFun is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {γ : TypeVec.{u2} n} {β : Type.{u1}} {δ : Type.{u2}} {ε : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} (f₀ : TypeVec.Arrow.{u3, u1} n (TypeVec.drop.{u3} n ε) α) (f₁ : TypeVec.Arrow.{u1, u2} n α γ) (g₀ : (TypeVec.last.{u3} n ε) -> β) (g₁ : β -> δ), Eq.{max 1 (succ u3) (succ u2)} (TypeVec.Arrow.{u3, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) ε (TypeVec.append1.{u2} n γ δ)) (TypeVec.comp.{u3, u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) ε (TypeVec.append1.{u1} n α β) (TypeVec.append1.{u2} n γ δ) (TypeVec.appendFun.{u1, u2} n α γ β δ f₁ g₁) (TypeVec.splitFun.{u3, u1} n ε (TypeVec.append1.{u1} n α β) f₀ g₀)) (TypeVec.splitFun.{u3, u2} n ε (TypeVec.append1.{u2} n γ δ) (TypeVec.comp.{u3, u1, u2} n (TypeVec.drop.{u3} n ε) α (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n γ δ)) f₁ f₀) (Function.comp.{succ u3, succ u1, succ u2} (TypeVec.last.{u3} n ε) β (TypeVec.last.{u2} n (TypeVec.append1.{u2} n γ δ)) g₁ g₀))\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u3} n} {γ : TypeVec.{u2} n} {β : Type.{u3}} {δ : Type.{u2}} {ε : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f₀ : TypeVec.Arrow.{u1, u3} n (TypeVec.drop.{u1} n ε) α) (f₁ : TypeVec.Arrow.{u3, u2} n α γ) (g₀ : (TypeVec.last.{u1} n ε) -> β) (g₁ : β -> δ), Eq.{max (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) ε (TypeVec.append1.{u2} n γ δ)) (TypeVec.comp.{u1, u3, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) ε (TypeVec.append1.{u3} n α β) (TypeVec.append1.{u2} n γ δ) (TypeVec.appendFun.{u3, u2} n α γ β δ f₁ g₁) (TypeVec.splitFun.{u1, u3} n ε (TypeVec.append1.{u3} n α β) f₀ g₀)) (TypeVec.splitFun.{u1, u2} n ε (TypeVec.append1.{u2} n γ δ) (TypeVec.comp.{u1, u3, u2} n (TypeVec.drop.{u1} n ε) α (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n γ δ)) f₁ f₀) (Function.comp.{succ u1, succ u3, succ u2} (TypeVec.last.{u1} n ε) β (TypeVec.last.{u2} n (TypeVec.append1.{u2} n γ δ)) g₁ g₀))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_comp_split_fun TypeVec.appendFun_comp_splitFunₓ'. -/\ntheorem appendFun_comp_splitFun {α γ : TypeVec n} {β δ : Type _} {ε : TypeVec (n + 1)}\n    (f₀ : drop ε ⟹ α) (f₁ : α ⟹ γ) (g₀ : last ε → β) (g₁ : β → δ) :\n    appendFun f₁ g₁ ⊚ splitFun f₀ g₀ = splitFun (f₁ ⊚ f₀) (g₁ ∘ g₀) :=\n  (splitFun_comp _ _ _ _).symm\n#align typevec.append_fun_comp_split_fun TypeVec.appendFun_comp_splitFun\n\n/- warning: typevec.append_fun_comp -> TypeVec.appendFun_comp is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α₀ : TypeVec.{u1} n} {α₁ : TypeVec.{u2} n} {α₂ : TypeVec.{u3} n} {β₀ : Type.{u1}} {β₁ : Type.{u2}} {β₂ : Type.{u3}} (f₀ : TypeVec.Arrow.{u1, u2} n α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u3} n α₁ α₂) (g₀ : β₀ -> β₁) (g₁ : β₁ -> β₂), Eq.{max 1 (succ u1) (succ u3)} (TypeVec.Arrow.{u1, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α₀ β₀) (TypeVec.append1.{u3} n α₂ β₂)) (TypeVec.appendFun.{u1, u3} n α₀ α₂ β₀ β₂ (TypeVec.comp.{u1, u2, u3} n α₀ α₁ α₂ f₁ f₀) (Function.comp.{succ u1, succ u2, succ u3} β₀ β₁ β₂ g₁ g₀)) (TypeVec.comp.{u1, u2, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α₀ β₀) (TypeVec.append1.{u2} n α₁ β₁) (TypeVec.append1.{u3} n α₂ β₂) (TypeVec.appendFun.{u2, u3} n α₁ α₂ β₁ β₂ f₁ g₁) (TypeVec.appendFun.{u1, u2} n α₀ α₁ β₀ β₁ f₀ g₀))\nbut is expected to have type\n  forall {n : Nat} {α₀ : TypeVec.{u3} n} {α₁ : TypeVec.{u2} n} {α₂ : TypeVec.{u1} n} {β₀ : Type.{u3}} {β₁ : Type.{u2}} {β₂ : Type.{u1}} (f₀ : TypeVec.Arrow.{u3, u2} n α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u1} n α₁ α₂) (g₀ : β₀ -> β₁) (g₁ : β₁ -> β₂), Eq.{max (succ u3) (succ u1)} (TypeVec.Arrow.{u3, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u3} n α₀ β₀) (TypeVec.append1.{u1} n α₂ β₂)) (TypeVec.appendFun.{u3, u1} n α₀ α₂ β₀ β₂ (TypeVec.comp.{u3, u2, u1} n α₀ α₁ α₂ f₁ f₀) (Function.comp.{succ u3, succ u2, succ u1} β₀ β₁ β₂ g₁ g₀)) (TypeVec.comp.{u3, u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u3} n α₀ β₀) (TypeVec.append1.{u2} n α₁ β₁) (TypeVec.append1.{u1} n α₂ β₂) (TypeVec.appendFun.{u2, u1} n α₁ α₂ β₁ β₂ f₁ g₁) (TypeVec.appendFun.{u3, u2} n α₀ α₁ β₀ β₁ f₀ g₀))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_comp TypeVec.appendFun_compₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem appendFun_comp {α₀ α₁ α₂ : TypeVec n} {β₀ β₁ β₂ : Type _} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂)\n    (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (f₁ ⊚ f₀ ::: g₁ ∘ g₀) = (f₁ ::: g₁) ⊚ (f₀ ::: g₀) :=\n  eq_of_drop_last_eq rfl rfl\n#align typevec.append_fun_comp TypeVec.appendFun_comp\n\n/- warning: typevec.append_fun_comp' -> TypeVec.appendFun_comp' is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α₀ : TypeVec.{u1} n} {α₁ : TypeVec.{u2} n} {α₂ : TypeVec.{u3} n} {β₀ : Type.{u1}} {β₁ : Type.{u2}} {β₂ : Type.{u3}} (f₀ : TypeVec.Arrow.{u1, u2} n α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u3} n α₁ α₂) (g₀ : β₀ -> β₁) (g₁ : β₁ -> β₂), Eq.{max 1 (succ u1) (succ u3)} (TypeVec.Arrow.{u1, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α₀ β₀) (TypeVec.append1.{u3} n α₂ β₂)) (TypeVec.comp.{u1, u2, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α₀ β₀) (TypeVec.append1.{u2} n α₁ β₁) (TypeVec.append1.{u3} n α₂ β₂) (TypeVec.appendFun.{u2, u3} n α₁ α₂ β₁ β₂ f₁ g₁) (TypeVec.appendFun.{u1, u2} n α₀ α₁ β₀ β₁ f₀ g₀)) (TypeVec.appendFun.{u1, u3} n α₀ α₂ β₀ β₂ (TypeVec.comp.{u1, u2, u3} n α₀ α₁ α₂ f₁ f₀) (Function.comp.{succ u1, succ u2, succ u3} β₀ β₁ β₂ g₁ g₀))\nbut is expected to have type\n  forall {n : Nat} {α₀ : TypeVec.{u3} n} {α₁ : TypeVec.{u2} n} {α₂ : TypeVec.{u1} n} {β₀ : Type.{u3}} {β₁ : Type.{u2}} {β₂ : Type.{u1}} (f₀ : TypeVec.Arrow.{u3, u2} n α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u1} n α₁ α₂) (g₀ : β₀ -> β₁) (g₁ : β₁ -> β₂), Eq.{max (succ u3) (succ u1)} (TypeVec.Arrow.{u3, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u3} n α₀ β₀) (TypeVec.append1.{u1} n α₂ β₂)) (TypeVec.comp.{u3, u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u3} n α₀ β₀) (TypeVec.append1.{u2} n α₁ β₁) (TypeVec.append1.{u1} n α₂ β₂) (TypeVec.appendFun.{u2, u1} n α₁ α₂ β₁ β₂ f₁ g₁) (TypeVec.appendFun.{u3, u2} n α₀ α₁ β₀ β₁ f₀ g₀)) (TypeVec.appendFun.{u3, u1} n α₀ α₂ β₀ β₂ (TypeVec.comp.{u3, u2, u1} n α₀ α₁ α₂ f₁ f₀) (Function.comp.{succ u3, succ u2, succ u1} β₀ β₁ β₂ g₁ g₀))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_comp' TypeVec.appendFun_comp'ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem appendFun_comp' {α₀ α₁ α₂ : TypeVec n} {β₀ β₁ β₂ : Type _} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂)\n    (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (f₁ ::: g₁) ⊚ (f₀ ::: g₀) = (f₁ ⊚ f₀ ::: g₁ ∘ g₀) :=\n  eq_of_drop_last_eq rfl rfl\n#align typevec.append_fun_comp' TypeVec.appendFun_comp'\n\n/- warning: typevec.nil_fun_comp -> TypeVec.nilFun_comp is a dubious translation:\nlean 3 declaration is\n  forall {α₀ : TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))} (f₀ : TypeVec.Arrow.{u1, u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) α₀ (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2}))), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) α₀ (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2}))) (TypeVec.comp.{u1, u2, u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) α₀ (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})) (TypeVec.nilFun.{u2, u2} (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2}))) f₀) f₀\nbut is expected to have type\n  forall {α₀ : TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))} (f₀ : TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) α₀ (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1}))), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) α₀ (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1}))) (TypeVec.comp.{u2, u1, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) α₀ (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1})) (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1})) (TypeVec.nilFun.{u1, u1} (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1})) (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1}))) f₀) f₀\nCase conversion may be inaccurate. Consider using '#align typevec.nil_fun_comp TypeVec.nilFun_compₓ'. -/\ntheorem nilFun_comp {α₀ : TypeVec 0} (f₀ : α₀ ⟹ Fin2.elim0) : nilFun ⊚ f₀ = f₀ :=\n  funext fun x => Fin2.elim0 x\n#align typevec.nil_fun_comp TypeVec.nilFun_comp\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.appendFun_comp_id /-\ntheorem appendFun_comp_id {α : TypeVec n} {β₀ β₁ β₂ : Type _} (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) :\n    (@id _ α ::: g₁ ∘ g₀) = (id ::: g₁) ⊚ (id ::: g₀) :=\n  eq_of_drop_last_eq rfl rfl\n#align typevec.append_fun_comp_id TypeVec.appendFun_comp_id\n-/\n\n/- warning: typevec.drop_fun_comp -> TypeVec.dropFun_comp is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α₀ : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α₁ : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α₂ : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} (f₀ : TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₁ α₂), Eq.{max 1 (succ u1) (succ u3)} (TypeVec.Arrow.{u1, u3} n (TypeVec.drop.{u1} n α₀) (TypeVec.drop.{u3} n α₂)) (TypeVec.dropFun.{u1, u3} n α₀ α₂ (TypeVec.comp.{u1, u2, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₀ α₁ α₂ f₁ f₀)) (TypeVec.comp.{u1, u2, u3} n (TypeVec.drop.{u1} n α₀) (TypeVec.drop.{u2} n α₁) (TypeVec.drop.{u3} n α₂) (TypeVec.dropFun.{u2, u3} n α₁ α₂ f₁) (TypeVec.dropFun.{u1, u2} n α₀ α₁ f₀))\nbut is expected to have type\n  forall {n : Nat} {α₀ : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α₁ : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α₂ : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f₀ : TypeVec.Arrow.{u3, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₁ α₂), Eq.{max (succ u3) (succ u1)} (TypeVec.Arrow.{u3, u1} n (TypeVec.drop.{u3} n α₀) (TypeVec.drop.{u1} n α₂)) (TypeVec.dropFun.{u3, u1} n α₀ α₂ (TypeVec.comp.{u3, u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₀ α₁ α₂ f₁ f₀)) (TypeVec.comp.{u3, u2, u1} n (TypeVec.drop.{u3} n α₀) (TypeVec.drop.{u2} n α₁) (TypeVec.drop.{u1} n α₂) (TypeVec.dropFun.{u2, u1} n α₁ α₂ f₁) (TypeVec.dropFun.{u3, u2} n α₀ α₁ f₀))\nCase conversion may be inaccurate. Consider using '#align typevec.drop_fun_comp TypeVec.dropFun_compₓ'. -/\n@[simp]\ntheorem dropFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) :\n    dropFun (f₁ ⊚ f₀) = dropFun f₁ ⊚ dropFun f₀ :=\n  rfl\n#align typevec.drop_fun_comp TypeVec.dropFun_comp\n\n/- warning: typevec.last_fun_comp -> TypeVec.lastFun_comp is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α₀ : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α₁ : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} {α₂ : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))} (f₀ : TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₁ α₂), Eq.{max (succ u1) (succ u3)} ((TypeVec.last.{u1} n α₀) -> (TypeVec.last.{u3} n α₂)) (TypeVec.lastFun.{u1, u3} n α₀ α₂ (TypeVec.comp.{u1, u2, u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) α₀ α₁ α₂ f₁ f₀)) (Function.comp.{succ u1, succ u2, succ u3} (TypeVec.last.{u1} n α₀) (TypeVec.last.{u2} n α₁) (TypeVec.last.{u3} n α₂) (TypeVec.lastFun.{u2, u3} n α₁ α₂ f₁) (TypeVec.lastFun.{u1, u2} n α₀ α₁ f₀))\nbut is expected to have type\n  forall {n : Nat} {α₀ : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α₁ : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {α₂ : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f₀ : TypeVec.Arrow.{u3, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₀ α₁) (f₁ : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₁ α₂), Eq.{max (succ u3) (succ u1)} ((TypeVec.last.{u3} n α₀) -> (TypeVec.last.{u1} n α₂)) (TypeVec.lastFun.{u3, u1} n α₀ α₂ (TypeVec.comp.{u3, u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) α₀ α₁ α₂ f₁ f₀)) (Function.comp.{succ u3, succ u2, succ u1} (TypeVec.last.{u3} n α₀) (TypeVec.last.{u2} n α₁) (TypeVec.last.{u1} n α₂) (TypeVec.lastFun.{u2, u1} n α₁ α₂ f₁) (TypeVec.lastFun.{u3, u2} n α₀ α₁ f₀))\nCase conversion may be inaccurate. Consider using '#align typevec.last_fun_comp TypeVec.lastFun_compₓ'. -/\n@[simp]\ntheorem lastFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) :\n    lastFun (f₁ ⊚ f₀) = lastFun f₁ ∘ lastFun f₀ :=\n  rfl\n#align typevec.last_fun_comp TypeVec.lastFun_comp\n\n/- warning: typevec.append_fun_aux -> TypeVec.appendFun_aux is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {α' : TypeVec.{u2} n} {β : Type.{u1}} {β' : Type.{u2}} (f : TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α β) (TypeVec.append1.{u2} n α' β')), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n α β)) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n α β))) (TypeVec.append1.{u2} n (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n α' β')) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n α' β')))) (TypeVec.appendFun.{u1, u2} n (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n α β)) (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n α' β')) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n α β)) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n α' β')) (TypeVec.dropFun.{u1, u2} n (TypeVec.append1.{u1} n α β) (TypeVec.append1.{u2} n α' β') f) (TypeVec.lastFun.{u1, u2} n (TypeVec.append1.{u1} n α β) (TypeVec.append1.{u2} n α' β') f)) f\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} n} {α' : TypeVec.{u1} n} {β : Type.{u2}} {β' : Type.{u1}} (f : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u2} n α β) (TypeVec.append1.{u1} n α' β')), Eq.{max (succ u1) (succ u2)} (TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u2} n (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n α β)) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n α β))) (TypeVec.append1.{u1} n (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n α' β')) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n α' β')))) (TypeVec.appendFun.{u2, u1} n (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n α β)) (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n α' β')) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n α β)) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n α' β')) (TypeVec.dropFun.{u2, u1} n (TypeVec.append1.{u2} n α β) (TypeVec.append1.{u1} n α' β') f) (TypeVec.lastFun.{u2, u1} n (TypeVec.append1.{u2} n α β) (TypeVec.append1.{u1} n α' β') f)) f\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_aux TypeVec.appendFun_auxₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem appendFun_aux {α α' : TypeVec n} {β β' : Type _} (f : (α ::: β) ⟹ (α' ::: β')) :\n    (dropFun f ::: lastFun f) = f :=\n  eq_of_drop_last_eq rfl rfl\n#align typevec.append_fun_aux TypeVec.appendFun_aux\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.appendFun_id_id /-\ntheorem appendFun_id_id {α : TypeVec n} {β : Type _} : (@TypeVec.id n α ::: @id β) = TypeVec.id :=\n  eq_of_drop_last_eq rfl rfl\n#align typevec.append_fun_id_id TypeVec.appendFun_id_id\n-/\n\n#print TypeVec.subsingleton0 /-\ninstance subsingleton0 : Subsingleton (TypeVec 0) :=\n  ⟨fun a b => funext fun a => Fin2.elim0 a⟩\n#align typevec.subsingleton0 TypeVec.subsingleton0\n-/\n\nrun_cmd\n  do\n    mk_simp_attr `typevec\n    tactic.add_doc_string `simp_attr.typevec\n        \"simp set for the manipulation of typevec and arrow expressions\"\n\n-- mathport name: «expr♯ »\nlocal prefix:0 \"♯\" => cast (by try simp <;> congr 1 <;> try simp)\n\n#print TypeVec.casesNil /-\n/-- cases distinction for 0-length type vector -/\nprotected def casesNil {β : TypeVec 0 → Sort _} (f : β Fin2.elim0) : ∀ v, β v := fun v => ♯f\n#align typevec.cases_nil TypeVec.casesNil\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.casesCons /-\n/-- cases distinction for (n+1)-length type vector -/\nprotected def casesCons (n : ℕ) {β : TypeVec (n + 1) → Sort _}\n    (f : ∀ (t) (v : TypeVec n), β (v ::: t)) : ∀ v, β v := fun v : TypeVec (n + 1) =>\n  ♯f v.getLast v.drop\n#align typevec.cases_cons TypeVec.casesCons\n-/\n\n/- warning: typevec.cases_nil_append1 -> TypeVec.casesNil_append1 is a dubious translation:\nlean 3 declaration is\n  forall {β : (TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> Sort.{u2}} (f : β (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1}))), Eq.{u2} (β (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1}))) (TypeVec.casesNil.{u1, u2} β f (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1}))) f\nbut is expected to have type\n  forall {β : (TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> Sort.{u1}} (f : β (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2}))), Eq.{u1} (β (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2}))) (TypeVec.casesNil.{u2, u1} β f (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2}))) f\nCase conversion may be inaccurate. Consider using '#align typevec.cases_nil_append1 TypeVec.casesNil_append1ₓ'. -/\nprotected theorem casesNil_append1 {β : TypeVec 0 → Sort _} (f : β Fin2.elim0) :\n    TypeVec.casesNil f Fin2.elim0 = f :=\n  rfl\n#align typevec.cases_nil_append1 TypeVec.casesNil_append1\n\n/- warning: typevec.cases_cons_append1 -> TypeVec.casesCons_append1 is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat) {β : (TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Sort.{u2}} (f : forall (t : Type.{u1}) (v : TypeVec.{u1} n), β (TypeVec.append1.{u1} n v t)) (v : TypeVec.{u1} n) (α : Type.{u1}), Eq.{u2} (β (TypeVec.append1.{u1} n v α)) (TypeVec.casesCons.{u1, u2} n β f (TypeVec.append1.{u1} n v α)) (f α v)\nbut is expected to have type\n  forall (n : Nat) {β : (TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Sort.{u1}} (f : forall (t : Type.{u2}) (v : TypeVec.{u2} n), β (TypeVec.append1.{u2} n v t)) (v : TypeVec.{u2} n) (α : Type.{u2}), Eq.{u1} (β (TypeVec.append1.{u2} n v α)) (TypeVec.casesCons.{u2, u1} n β f (TypeVec.append1.{u2} n v α)) (f α v)\nCase conversion may be inaccurate. Consider using '#align typevec.cases_cons_append1 TypeVec.casesCons_append1ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprotected theorem casesCons_append1 (n : ℕ) {β : TypeVec (n + 1) → Sort _}\n    (f : ∀ (t) (v : TypeVec n), β (v ::: t)) (v : TypeVec n) (α) :\n    TypeVec.casesCons n f (v ::: α) = f α v :=\n  rfl\n#align typevec.cases_cons_append1 TypeVec.casesCons_append1\n\n#print TypeVec.typevecCasesNil₃ /-\n/-- cases distinction for an arrow in the category of 0-length type vectors -/\ndef typevecCasesNil₃ {β : ∀ v v' : TypeVec 0, v ⟹ v' → Sort _}\n    (f : β Fin2.elim0 Fin2.elim0 nilFun) : ∀ v v' fs, β v v' fs := fun v v' fs => by\n  refine' cast _ f <;> congr 1 <;> ext <;> try intros <;> casesm Fin2 0; rfl\n#align typevec.typevec_cases_nil₃ TypeVec.typevecCasesNil₃\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.typevecCasesCons₃ /-\n/-- cases distinction for an arrow in the category of (n+1)-length type vectors -/\ndef typevecCasesCons₃ (n : ℕ) {β : ∀ v v' : TypeVec (n + 1), v ⟹ v' → Sort _}\n    (F :\n      ∀ (t t') (f : t → t') (v v' : TypeVec n) (fs : v ⟹ v'), β (v ::: t) (v' ::: t') (fs ::: f)) :\n    ∀ v v' fs, β v v' fs := by\n  intro v v'\n  rw [← append1_drop_last v, ← append1_drop_last v']\n  intro fs\n  rw [← split_drop_fun_last_fun fs]\n  apply F\n#align typevec.typevec_cases_cons₃ TypeVec.typevecCasesCons₃\n-/\n\n#print TypeVec.typevecCasesNil₂ /-\n/-- specialized cases distinction for an arrow in the category of 0-length type vectors -/\ndef typevecCasesNil₂ {β : Fin2.elim0 ⟹ Fin2.elim0 → Sort _} (f : β nilFun) : ∀ f, β f :=\n  by\n  intro g; have : g = nil_fun; ext ⟨⟩\n  rw [this]; exact f\n#align typevec.typevec_cases_nil₂ TypeVec.typevecCasesNil₂\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.typevecCasesCons₂ /-\n/-- specialized cases distinction for an arrow in the category of (n+1)-length type vectors -/\ndef typevecCasesCons₂ (n : ℕ) (t t' : Type _) (v v' : TypeVec n)\n    {β : (v ::: t) ⟹ (v' ::: t') → Sort _} (F : ∀ (f : t → t') (fs : v ⟹ v'), β (fs ::: f)) :\n    ∀ fs, β fs := by\n  intro fs\n  rw [← split_drop_fun_last_fun fs]\n  apply F\n#align typevec.typevec_cases_cons₂ TypeVec.typevecCasesCons₂\n-/\n\n/- warning: typevec.typevec_cases_nil₂_append_fun -> TypeVec.typevecCasesNil₂_appendFun is a dubious translation:\nlean 3 declaration is\n  forall {β : (TypeVec.Arrow.{u1, u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2}))) -> Sort.{u3}} (f : β (TypeVec.nilFun.{u1, u2} (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})))), Eq.{u3} (β (TypeVec.nilFun.{u1, u2} (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})))) (TypeVec.typevecCasesNil₂.{u1, u2, u3} β f (TypeVec.nilFun.{u1, u2} (Fin2.elim0.{succ (succ u1)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})))) f\nbut is expected to have type\n  forall {β : (TypeVec.Arrow.{u3, u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (Fin2.elim0.{succ (succ u3)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2}))) -> Sort.{u1}} (f : β (TypeVec.nilFun.{u3, u2} (Fin2.elim0.{succ (succ u3)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2})))), Eq.{u1} (β (TypeVec.nilFun.{u3, u2} (Fin2.elim0.{succ (succ u3)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2})))) (TypeVec.typevecCasesNil₂.{u3, u2, u1} β f (TypeVec.nilFun.{u3, u2} (Fin2.elim0.{succ (succ u3)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (ᾰ : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2})))) f\nCase conversion may be inaccurate. Consider using '#align typevec.typevec_cases_nil₂_append_fun TypeVec.typevecCasesNil₂_appendFunₓ'. -/\ntheorem typevecCasesNil₂_appendFun {β : Fin2.elim0 ⟹ Fin2.elim0 → Sort _} (f : β nilFun) :\n    typevecCasesNil₂ f nilFun = f :=\n  rfl\n#align typevec.typevec_cases_nil₂_append_fun TypeVec.typevecCasesNil₂_appendFun\n\n/- warning: typevec.typevec_cases_cons₂_append_fun -> TypeVec.typevecCasesCons₂_appendFun is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat) (t : Type.{u1}) (t' : Type.{u2}) (v : TypeVec.{u1} n) (v' : TypeVec.{u2} n) {β : (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n v t) (TypeVec.append1.{u2} n v' t')) -> Sort.{u3}} (F : forall (f : t -> t') (fs : TypeVec.Arrow.{u1, u2} n v v'), β (TypeVec.appendFun.{u1, u2} n v v' t t' fs f)) (f : t -> t') (fs : TypeVec.Arrow.{u1, u2} n v v'), Eq.{u3} (β (TypeVec.appendFun.{u1, u2} n v v' t t' fs f)) (TypeVec.typevecCasesCons₂.{u1, u2, u3} n t t' v v' β F (TypeVec.appendFun.{u1, u2} n v v' t t' fs f)) (F f fs)\nbut is expected to have type\n  forall (n : Nat) (t : Type.{u3}) (t' : Type.{u2}) (v : TypeVec.{u3} n) (v' : TypeVec.{u2} n) {β : (TypeVec.Arrow.{u3, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u3} n v t) (TypeVec.append1.{u2} n v' t')) -> Sort.{u1}} (F : forall (f : t -> t') (fs : TypeVec.Arrow.{u3, u2} n v v'), β (TypeVec.appendFun.{u3, u2} n v v' t t' fs f)) (f : t -> t') (fs : TypeVec.Arrow.{u3, u2} n v v'), Eq.{u1} (β (TypeVec.appendFun.{u3, u2} n v v' t t' fs f)) (TypeVec.typevecCasesCons₂.{u3, u2, u1} n t t' v v' β F (TypeVec.appendFun.{u3, u2} n v v' t t' fs f)) (F f fs)\nCase conversion may be inaccurate. Consider using '#align typevec.typevec_cases_cons₂_append_fun TypeVec.typevecCasesCons₂_appendFunₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem typevecCasesCons₂_appendFun (n : ℕ) (t t' : Type _) (v v' : TypeVec n)\n    {β : (v ::: t) ⟹ (v' ::: t') → Sort _} (F : ∀ (f : t → t') (fs : v ⟹ v'), β (fs ::: f)) (f fs) :\n    typevecCasesCons₂ n t t' v v' F (fs ::: f) = F f fs :=\n  rfl\n#align typevec.typevec_cases_cons₂_append_fun TypeVec.typevecCasesCons₂_appendFun\n\n#print TypeVec.PredLast /-\n-- for lifting predicates and relations\n/-- `pred_last α p x` predicates `p` of the last element of `x : α.append1 β`. -/\ndef PredLast (α : TypeVec n) {β : Type _} (p : β → Prop) : ∀ ⦃i⦄, (α.append1 β) i → Prop\n  | Fin2.fs i => fun x => True\n  | Fin2.fz => p\n#align typevec.pred_last TypeVec.PredLast\n-/\n\n#print TypeVec.RelLast /-\n/-- `rel_last α r x y` says that `p` the last elements of `x y : α.append1 β` are related by `r` and\nall the other elements are equal. -/\ndef RelLast (α : TypeVec n) {β γ : Type _} (r : β → γ → Prop) :\n    ∀ ⦃i⦄, (α.append1 β) i → (α.append1 γ) i → Prop\n  | Fin2.fs i => Eq\n  | Fin2.fz => r\n#align typevec.rel_last TypeVec.RelLast\n-/\n\nsection Liftp'\n\nopen Nat\n\n#print TypeVec.repeat /-\n/-- `repeat n t` is a `n-length` type vector that contains `n` occurences of `t` -/\ndef repeat : ∀ (n : ℕ) (t : Sort _), TypeVec n\n  | 0, t => Fin2.elim0\n  | Nat.succ i, t => append1 (repeat i t) t\n#align typevec.repeat TypeVec.repeat\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.prod /-\n/-- `prod α β` is the pointwise product of the components of `α` and `β` -/\ndef prod : ∀ {n} (α β : TypeVec.{u} n), TypeVec n\n  | 0, α, β => Fin2.elim0\n  | n + 1, α, β => Prod (drop α) (drop β) ::: last α × last β\n#align typevec.prod TypeVec.prod\n-/\n\n-- mathport name: typevec.prod\nscoped[MvFunctor] infixl:45 \" ⊗ \" => TypeVec.prod\n\n#print TypeVec.const /-\n/-- `const x α` is an arrow that ignores its source and constructs a `typevec` that\ncontains nothing but `x` -/\nprotected def const {β} (x : β) : ∀ {n} (α : TypeVec n), α ⟹ repeat _ β\n  | succ n, α, Fin2.fs i => const (drop α) _\n  | succ n, α, Fin2.fz => fun _ => x\n#align typevec.const TypeVec.const\n-/\n\nopen Function (uncurry)\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.repeatEq /-\n/-- vector of equality on a product of vectors -/\ndef repeatEq : ∀ {n} (α : TypeVec n), α ⊗ α ⟹ repeat _ Prop\n  | 0, α => nilFun\n  | succ n, α => repeat_eq (drop α) ::: uncurry Eq\n#align typevec.repeat_eq TypeVec.repeatEq\n-/\n\n/- warning: typevec.const_append1 -> TypeVec.const_append1 is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} {γ : Type.{u2}} (x : γ) {n : Nat} (α : TypeVec.{u1} n), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α β) (TypeVec.repeat.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) γ)) (TypeVec.const.{u2, u1} γ x (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α β)) (TypeVec.appendFun.{u1, u2} n α (TypeVec.repeat.{u2} (Nat.add n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) γ) β γ (TypeVec.const.{u2, u1} γ x n α) (fun (_x : β) => x))\nbut is expected to have type\n  forall {β : Type.{u2}} {γ : Type.{u1}} (x : γ) {n : Nat} (α : TypeVec.{u2} n), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u2} n α β) (TypeVec.repeat.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) γ)) (TypeVec.const.{u1, u2} γ x (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u2} n α β)) (TypeVec.appendFun.{u2, u1} n α (TypeVec.repeat.{u1} n γ) β γ (TypeVec.const.{u1, u2} γ x n α) (fun (_x : β) => x))\nCase conversion may be inaccurate. Consider using '#align typevec.const_append1 TypeVec.const_append1ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem const_append1 {β γ} (x : γ) {n} (α : TypeVec n) :\n    TypeVec.const x (α ::: β) = appendFun (TypeVec.const x α) fun _ => x := by\n  ext i : 1 <;> cases i <;> rfl\n#align typevec.const_append1 TypeVec.const_append1\n\n/- warning: typevec.eq_nil_fun -> TypeVec.eq_nilFun is a dubious translation:\nlean 3 declaration is\n  forall {α : TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))} {β : TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))} (f : TypeVec.Arrow.{u1, u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) α β), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) α β) f (TypeVec.nilFun.{u1, u2} α β)\nbut is expected to have type\n  forall {α : TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))} {β : TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))} (f : TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) α β), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) α β) f (TypeVec.nilFun.{u2, u1} α β)\nCase conversion may be inaccurate. Consider using '#align typevec.eq_nil_fun TypeVec.eq_nilFunₓ'. -/\ntheorem eq_nilFun {α β : TypeVec 0} (f : α ⟹ β) : f = nilFun := by ext x <;> cases x\n#align typevec.eq_nil_fun TypeVec.eq_nilFun\n\n#print TypeVec.id_eq_nilFun /-\ntheorem id_eq_nilFun {α : TypeVec 0} : @id _ α = nilFun := by ext x <;> cases x\n#align typevec.id_eq_nil_fun TypeVec.id_eq_nilFun\n-/\n\n/- warning: typevec.const_nil -> TypeVec.const_nil is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} (x : β) (α : TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))), Eq.{max 1 (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) α (TypeVec.repeat.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) β)) (TypeVec.const.{u1, u2} β x (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) α) (TypeVec.nilFun.{u2, u1} α (TypeVec.repeat.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) β))\nbut is expected to have type\n  forall {β : Type.{u2}} (x : β) (α : TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))), Eq.{max (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) α (TypeVec.repeat.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) β)) (TypeVec.const.{u2, u1} β x (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) α) (TypeVec.nilFun.{u1, u2} α (TypeVec.repeat.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) β))\nCase conversion may be inaccurate. Consider using '#align typevec.const_nil TypeVec.const_nilₓ'. -/\ntheorem const_nil {β} (x : β) (α : TypeVec 0) : TypeVec.const x α = nilFun := by\n  ext i : 1 <;> cases i <;> rfl\n#align typevec.const_nil TypeVec.const_nil\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.repeat_eq_append1 /-\n@[typevec]\ntheorem repeat_eq_append1 {β} {n} (α : TypeVec n) :\n    repeatEq (α ::: β) = splitFun (repeatEq α) (uncurry Eq) := by induction n <;> rfl\n#align typevec.repeat_eq_append1 TypeVec.repeat_eq_append1\n-/\n\n#print TypeVec.repeat_eq_nil /-\n@[typevec]\ntheorem repeat_eq_nil (α : TypeVec 0) : repeatEq α = nilFun := by ext i : 1 <;> cases i <;> rfl\n#align typevec.repeat_eq_nil TypeVec.repeat_eq_nil\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.PredLast' /-\n/-- predicate on a type vector to constrain only the last object -/\ndef PredLast' (α : TypeVec n) {β : Type _} (p : β → Prop) : (α ::: β) ⟹ repeat (n + 1) Prop :=\n  splitFun (TypeVec.const True α) p\n#align typevec.pred_last' TypeVec.PredLast'\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.RelLast' /-\n/-- predicate on the product of two type vectors to constrain only their last object -/\ndef RelLast' (α : TypeVec n) {β : Type _} (p : β → β → Prop) :\n    (α ::: β) ⊗ (α ::: β) ⟹ repeat (n + 1) Prop :=\n  splitFun (repeatEq α) (uncurry p)\n#align typevec.rel_last' TypeVec.RelLast'\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.Curry /-\n/-- given `F : typevec.{u} (n+1) → Type u`, `curry F : Type u → typevec.{u} → Type u`,\ni.e. its first argument can be fed in separately from the rest of the vector of arguments -/\ndef Curry (F : TypeVec.{u} (n + 1) → Type _) (α : Type u) (β : TypeVec.{u} n) : Type _ :=\n  F (β ::: α)\n#align typevec.curry TypeVec.Curry\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.Curry.inhabited /-\ninstance Curry.inhabited (F : TypeVec.{u} (n + 1) → Type _) (α : Type u) (β : TypeVec.{u} n)\n    [I : Inhabited (F <| (β ::: α))] : Inhabited (Curry F α β) :=\n  I\n#align typevec.curry.inhabited TypeVec.Curry.inhabited\n-/\n\n#print TypeVec.dropRepeat /-\n/-- arrow to remove one element of a `repeat` vector -/\ndef dropRepeat (α : Type _) : ∀ {n}, drop (repeat (succ n) α) ⟹ repeat n α\n  | succ n, Fin2.fs i => drop_repeat i\n  | succ n, Fin2.fz => id\n#align typevec.drop_repeat TypeVec.dropRepeat\n-/\n\n#print TypeVec.ofRepeat /-\n/-- projection for a repeat vector -/\ndef ofRepeat {α : Sort _} : ∀ {n i}, repeat n α i → α\n  | _, Fin2.fz => id\n  | _, Fin2.fs i => @of_repeat _ i\n#align typevec.of_repeat TypeVec.ofRepeat\n-/\n\n#print TypeVec.const_iff_true /-\ntheorem const_iff_true {α : TypeVec n} {i x p} : ofRepeat (TypeVec.const p α i x) ↔ p := by\n  induction i <;> [rfl, erw [TypeVec.const, @i_ih (drop α) x]]\n#align typevec.const_iff_true TypeVec.const_iff_true\n-/\n\n-- variables  {F : typevec.{u} n → Type*} [mvfunctor F]\nvariable {α β γ : TypeVec.{u} n}\n\nvariable (p : α ⟹ repeat n Prop) (r : α ⊗ α ⟹ repeat n Prop)\n\n#print TypeVec.prod.fst /-\n/-- left projection of a `prod` vector -/\ndef prod.fst : ∀ {n} {α β : TypeVec.{u} n}, α ⊗ β ⟹ α\n  | succ n, α, β, Fin2.fs i => @Prod.fst _ (drop α) (drop β) i\n  | succ n, α, β, Fin2.fz => Prod.fst\n#align typevec.prod.fst TypeVec.prod.fst\n-/\n\n#print TypeVec.prod.snd /-\n/-- right projection of a `prod` vector -/\ndef prod.snd : ∀ {n} {α β : TypeVec.{u} n}, α ⊗ β ⟹ β\n  | succ n, α, β, Fin2.fs i => @Prod.snd _ (drop α) (drop β) i\n  | succ n, α, β, Fin2.fz => Prod.snd\n#align typevec.prod.snd TypeVec.prod.snd\n-/\n\n#print TypeVec.prod.diag /-\n/-- introduce a product where both components are the same -/\ndef prod.diag : ∀ {n} {α : TypeVec.{u} n}, α ⟹ α ⊗ α\n  | succ n, α, Fin2.fs i, x => @prod.diag _ (drop α) _ x\n  | succ n, α, Fin2.fz, x => (x, x)\n#align typevec.prod.diag TypeVec.prod.diag\n-/\n\n#print TypeVec.prod.mk /-\n/-- constructor for `prod` -/\ndef prod.mk : ∀ {n} {α β : TypeVec.{u} n} (i : Fin2 n), α i → β i → (α ⊗ β) i\n  | succ n, α, β, Fin2.fs i => Prod.mk i\n  | succ n, α, β, Fin2.fz => Prod.mk\n#align typevec.prod.mk TypeVec.prod.mk\n-/\n\n#print TypeVec.prod_fst_mk /-\n@[simp]\ntheorem prod_fst_mk {α β : TypeVec n} (i : Fin2 n) (a : α i) (b : β i) :\n    TypeVec.prod.fst i (prod.mk i a b) = a := by induction i <;> simp_all [Prod.fst, Prod.mk]\n#align typevec.prod_fst_mk TypeVec.prod_fst_mk\n-/\n\n#print TypeVec.prod_snd_mk /-\n@[simp]\ntheorem prod_snd_mk {α β : TypeVec n} (i : Fin2 n) (a : α i) (b : β i) :\n    TypeVec.prod.snd i (prod.mk i a b) = b := by induction i <;> simp_all [Prod.snd, Prod.mk]\n#align typevec.prod_snd_mk TypeVec.prod_snd_mk\n-/\n\n#print TypeVec.prod.map /-\n/-- `prod` is functorial -/\nprotected def prod.map : ∀ {n} {α α' β β' : TypeVec.{u} n}, α ⟹ β → α' ⟹ β' → α ⊗ α' ⟹ β ⊗ β'\n  | succ n, α, α', β, β', x, y, Fin2.fs i, a =>\n    @Prod.map _ (drop α) (drop α') (drop β) (drop β') (dropFun x) (dropFun y) _ a\n  | succ n, α, α', β, β', x, y, Fin2.fz, a => (x _ a.1, y _ a.2)\n#align typevec.prod.map TypeVec.prod.map\n-/\n\n-- mathport name: typevec.prod.map\nscoped[MvFunctor] infixl:45 \" ⊗' \" => TypeVec.prod.map\n\n#print TypeVec.fst_prod_mk /-\ntheorem fst_prod_mk {α α' β β' : TypeVec n} (f : α ⟹ β) (g : α' ⟹ β') :\n    TypeVec.prod.fst ⊚ (f ⊗' g) = f ⊚ TypeVec.prod.fst := by\n  ext i <;> induction i <;> [rfl, apply i_ih]\n#align typevec.fst_prod_mk TypeVec.fst_prod_mk\n-/\n\n#print TypeVec.snd_prod_mk /-\ntheorem snd_prod_mk {α α' β β' : TypeVec n} (f : α ⟹ β) (g : α' ⟹ β') :\n    TypeVec.prod.snd ⊚ (f ⊗' g) = g ⊚ TypeVec.prod.snd := by\n  ext i <;> induction i <;> [rfl, apply i_ih]\n#align typevec.snd_prod_mk TypeVec.snd_prod_mk\n-/\n\n#print TypeVec.fst_diag /-\ntheorem fst_diag {α : TypeVec n} : TypeVec.prod.fst ⊚ (prod.diag : α ⟹ _) = id := by\n  ext i <;> induction i <;> [rfl, apply i_ih]\n#align typevec.fst_diag TypeVec.fst_diag\n-/\n\n#print TypeVec.snd_diag /-\ntheorem snd_diag {α : TypeVec n} : TypeVec.prod.snd ⊚ (prod.diag : α ⟹ _) = id := by\n  ext i <;> induction i <;> [rfl, apply i_ih]\n#align typevec.snd_diag TypeVec.snd_diag\n-/\n\n#print TypeVec.repeatEq_iff_eq /-\ntheorem repeatEq_iff_eq {α : TypeVec n} {i x y} : ofRepeat (repeatEq α i (prod.mk _ x y)) ↔ x = y :=\n  by induction i <;> [rfl, erw [repeat_eq, @i_ih (drop α) x y]]\n#align typevec.repeat_eq_iff_eq TypeVec.repeatEq_iff_eq\n-/\n\n#print TypeVec.Subtype_ /-\n/-- given a predicate vector `p` over vector `α`, `subtype_ p` is the type of vectors\nthat contain an `α` that satisfies `p` -/\ndef Subtype_ : ∀ {n} {α : TypeVec.{u} n} (p : α ⟹ repeat n Prop), TypeVec n\n  | _, α, p, Fin2.fz => Subtype fun x => p Fin2.fz x\n  | _, α, p, Fin2.fs i => subtype_ (dropFun p) i\n#align typevec.subtype_ TypeVec.Subtype_\n-/\n\n#print TypeVec.subtypeVal /-\n/-- projection on `subtype_` -/\ndef subtypeVal : ∀ {n} {α : TypeVec.{u} n} (p : α ⟹ repeat n Prop), Subtype_ p ⟹ α\n  | succ n, α, p, Fin2.fs i => @subtype_val n _ _ i\n  | succ n, α, p, Fin2.fz => Subtype.val\n#align typevec.subtype_val TypeVec.subtypeVal\n-/\n\n#print TypeVec.toSubtype /-\n/-- arrow that rearranges the type of `subtype_` to turn a subtype of vector into\na vector of subtypes -/\ndef toSubtype :\n    ∀ {n} {α : TypeVec.{u} n} (p : α ⟹ repeat n Prop),\n      (fun i : Fin2 n => { x // ofRepeat <| p i x }) ⟹ Subtype_ p\n  | succ n, α, p, Fin2.fs i, x => to_subtype (dropFun p) i x\n  | succ n, α, p, Fin2.fz, x => x\n#align typevec.to_subtype TypeVec.toSubtype\n-/\n\n#print TypeVec.ofSubtype /-\n/-- arrow that rearranges the type of `subtype_` to turn a vector of subtypes\ninto a subtype of vector -/\ndef ofSubtype :\n    ∀ {n} {α : TypeVec.{u} n} (p : α ⟹ repeat n Prop),\n      Subtype_ p ⟹ fun i : Fin2 n => { x // ofRepeat <| p i x }\n  | succ n, α, p, Fin2.fs i, x => of_subtype _ i x\n  | succ n, α, p, Fin2.fz, x => x\n#align typevec.of_subtype TypeVec.ofSubtype\n-/\n\n#print TypeVec.toSubtype' /-\n/-- similar to `to_subtype` adapted to relations (i.e. predicate on product) -/\ndef toSubtype' :\n    ∀ {n} {α : TypeVec.{u} n} (p : α ⊗ α ⟹ repeat n Prop),\n      (fun i : Fin2 n => { x : α i × α i // ofRepeat <| p i (prod.mk _ x.1 x.2) }) ⟹ Subtype_ p\n  | succ n, α, p, Fin2.fs i, x => to_subtype' (dropFun p) i x\n  | succ n, α, p, Fin2.fz, x => ⟨x.val, cast (by congr <;> simp [Prod.mk]) x.property⟩\n#align typevec.to_subtype' TypeVec.toSubtype'\n-/\n\n#print TypeVec.ofSubtype' /-\n/-- similar to `of_subtype` adapted to relations (i.e. predicate on product) -/\ndef ofSubtype' :\n    ∀ {n} {α : TypeVec.{u} n} (p : α ⊗ α ⟹ repeat n Prop),\n      Subtype_ p ⟹ fun i : Fin2 n => { x : α i × α i // ofRepeat <| p i (prod.mk _ x.1 x.2) }\n  | _, α, p, Fin2.fs i, x => of_subtype' _ i x\n  | _, α, p, Fin2.fz, x => ⟨x.val, cast (by congr <;> simp [Prod.mk]) x.property⟩\n#align typevec.of_subtype' TypeVec.ofSubtype'\n-/\n\n#print TypeVec.diagSub /-\n/-- similar to `diag` but the target vector is a `subtype_`\nguaranteeing the equality of the components -/\ndef diagSub : ∀ {n} {α : TypeVec.{u} n}, α ⟹ Subtype_ (repeatEq α)\n  | succ n, α, Fin2.fs i, x => @diag_sub _ (drop α) _ x\n  | succ n, α, Fin2.fz, x => ⟨(x, x), rfl⟩\n#align typevec.diag_sub TypeVec.diagSub\n-/\n\n#print TypeVec.subtypeVal_nil /-\ntheorem subtypeVal_nil {α : TypeVec.{u} 0} (ps : α ⟹ repeat 0 Prop) :\n    TypeVec.subtypeVal ps = nilFun :=\n  funext <| by rintro ⟨⟩ <;> rfl\n#align typevec.subtype_val_nil TypeVec.subtypeVal_nil\n-/\n\n#print TypeVec.diag_sub_val /-\ntheorem diag_sub_val {n} {α : TypeVec.{u} n} : subtypeVal (repeatEq α) ⊚ diagSub = prod.diag := by\n  ext i <;> induction i <;> [rfl, apply i_ih]\n#align typevec.diag_sub_val TypeVec.diag_sub_val\n-/\n\n#print TypeVec.prod_id /-\ntheorem prod_id : ∀ {n} {α β : TypeVec.{u} n}, (id ⊗' id) = (id : α ⊗ β ⟹ _) :=\n  by\n  intros ; ext (i a); induction i\n  · cases a\n    rfl\n  · apply i_ih\n#align typevec.prod_id TypeVec.prod_id\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print TypeVec.append_prod_appendFun /-\ntheorem append_prod_appendFun {n} {α α' β β' : TypeVec.{u} n} {φ φ' ψ ψ' : Type u} {f₀ : α ⟹ α'}\n    {g₀ : β ⟹ β'} {f₁ : φ → φ'} {g₁ : ψ → ψ'} :\n    (f₀ ⊗' g₀ ::: Prod.map f₁ g₁) = ((f₀ ::: f₁) ⊗' (g₀ ::: g₁)) := by\n  ext (i a) <;> cases i <;> [cases a, skip] <;> rfl\n#align typevec.append_prod_append_fun TypeVec.append_prod_appendFun\n-/\n\nend Liftp'\n\n#print TypeVec.dropFun_diag /-\n@[simp]\ntheorem dropFun_diag {α} : dropFun (@prod.diag (n + 1) α) = prod.diag :=\n  by\n  ext i : 2\n  induction i <;> simp [drop_fun, *] <;> rfl\n#align typevec.drop_fun_diag TypeVec.dropFun_diag\n-/\n\n#print TypeVec.dropFun_subtypeVal /-\n@[simp]\ntheorem dropFun_subtypeVal {α} (p : α ⟹ repeat (n + 1) Prop) :\n    dropFun (subtypeVal p) = subtypeVal _ :=\n  rfl\n#align typevec.drop_fun_subtype_val TypeVec.dropFun_subtypeVal\n-/\n\n#print TypeVec.lastFun_subtypeVal /-\n@[simp]\ntheorem lastFun_subtypeVal {α} (p : α ⟹ repeat (n + 1) Prop) :\n    lastFun (subtypeVal p) = Subtype.val :=\n  rfl\n#align typevec.last_fun_subtype_val TypeVec.lastFun_subtypeVal\n-/\n\n#print TypeVec.dropFun_toSubtype /-\n@[simp]\ntheorem dropFun_toSubtype {α} (p : α ⟹ repeat (n + 1) Prop) : dropFun (toSubtype p) = toSubtype _ :=\n  by\n  ext i : 2\n  induction i <;> simp [drop_fun, *] <;> rfl\n#align typevec.drop_fun_to_subtype TypeVec.dropFun_toSubtype\n-/\n\n#print TypeVec.lastFun_toSubtype /-\n@[simp]\ntheorem lastFun_toSubtype {α} (p : α ⟹ repeat (n + 1) Prop) : lastFun (toSubtype p) = id :=\n  by\n  ext i : 2\n  induction i <;> simp [drop_fun, *] <;> rfl\n#align typevec.last_fun_to_subtype TypeVec.lastFun_toSubtype\n-/\n\n#print TypeVec.dropFun_of_subtype /-\n@[simp]\ntheorem dropFun_of_subtype {α} (p : α ⟹ repeat (n + 1) Prop) :\n    dropFun (ofSubtype p) = ofSubtype _ := by\n  ext i : 2\n  induction i <;> simp [drop_fun, *] <;> rfl\n#align typevec.drop_fun_of_subtype TypeVec.dropFun_of_subtype\n-/\n\n#print TypeVec.lastFun_of_subtype /-\n@[simp]\ntheorem lastFun_of_subtype {α} (p : α ⟹ repeat (n + 1) Prop) : lastFun (ofSubtype p) = id :=\n  by\n  ext i : 2\n  induction i <;> simp [drop_fun, *] <;> rfl\n#align typevec.last_fun_of_subtype TypeVec.lastFun_of_subtype\n-/\n\n#print TypeVec.dropFun_RelLast' /-\n@[simp]\ntheorem dropFun_RelLast' {α : TypeVec n} {β} (R : β → β → Prop) :\n    dropFun (RelLast' α R) = repeatEq α :=\n  rfl\n#align typevec.drop_fun_rel_last TypeVec.dropFun_RelLast'\n-/\n\nattribute [simp] drop_append1'\n\nopen MvFunctor\n\n#print TypeVec.dropFun_prod /-\n@[simp]\ntheorem dropFun_prod {α α' β β' : TypeVec (n + 1)} (f : α ⟹ β) (f' : α' ⟹ β') :\n    dropFun (f ⊗' f') = (dropFun f ⊗' dropFun f') :=\n  by\n  ext i : 2\n  induction i <;> simp [drop_fun, *] <;> rfl\n#align typevec.drop_fun_prod TypeVec.dropFun_prod\n-/\n\n#print TypeVec.lastFun_prod /-\n@[simp]\ntheorem lastFun_prod {α α' β β' : TypeVec (n + 1)} (f : α ⟹ β) (f' : α' ⟹ β') :\n    lastFun (f ⊗' f') = Prod.map (lastFun f) (lastFun f') :=\n  by\n  ext i : 1\n  induction i <;> simp [last_fun, *] <;> rfl\n#align typevec.last_fun_prod TypeVec.lastFun_prod\n-/\n\n#print TypeVec.dropFun_from_append1_drop_last /-\n@[simp]\ntheorem dropFun_from_append1_drop_last {α : TypeVec (n + 1)} :\n    dropFun (@fromAppend1DropLast _ α) = id :=\n  rfl\n#align typevec.drop_fun_from_append1_drop_last TypeVec.dropFun_from_append1_drop_last\n-/\n\n#print TypeVec.lastFun_from_append1_drop_last /-\n@[simp]\ntheorem lastFun_from_append1_drop_last {α : TypeVec (n + 1)} :\n    lastFun (@fromAppend1DropLast _ α) = id :=\n  rfl\n#align typevec.last_fun_from_append1_drop_last TypeVec.lastFun_from_append1_drop_last\n-/\n\n#print TypeVec.dropFun_id /-\n@[simp]\ntheorem dropFun_id {α : TypeVec (n + 1)} : dropFun (@TypeVec.id _ α) = id :=\n  rfl\n#align typevec.drop_fun_id TypeVec.dropFun_id\n-/\n\n#print TypeVec.prod_map_id /-\n@[simp]\ntheorem prod_map_id {α β : TypeVec n} : (@TypeVec.id _ α ⊗' @TypeVec.id _ β) = id :=\n  by\n  ext i : 2\n  induction i <;> simp only [TypeVec.prod.map, *, drop_fun_id]\n  cases x\n  rfl\n  rfl\n#align typevec.prod_map_id TypeVec.prod_map_id\n-/\n\n#print TypeVec.subtypeVal_diagSub /-\n@[simp]\ntheorem subtypeVal_diagSub {α : TypeVec n} : subtypeVal (repeatEq α) ⊚ diagSub = prod.diag :=\n  by\n  clear * -\n  ext i\n  induction i <;> [rfl, apply i_ih]\n#align typevec.subtype_val_diag_sub TypeVec.subtypeVal_diagSub\n-/\n\n#print TypeVec.toSubtype_of_subtype /-\n@[simp]\ntheorem toSubtype_of_subtype {α : TypeVec n} (p : α ⟹ repeat n Prop) :\n    toSubtype p ⊚ ofSubtype p = id := by\n  ext (i x) <;> induction i <;> dsimp only [id, to_subtype, comp, of_subtype] at * <;> simp [*]\n#align typevec.to_subtype_of_subtype TypeVec.toSubtype_of_subtype\n-/\n\n#print TypeVec.subtypeVal_toSubtype /-\n@[simp]\ntheorem subtypeVal_toSubtype {α : TypeVec n} (p : α ⟹ repeat n Prop) :\n    subtypeVal p ⊚ toSubtype p = fun _ => Subtype.val := by\n  ext (i x) <;> induction i <;> dsimp only [to_subtype, comp, subtype_val] at * <;> simp [*]\n#align typevec.subtype_val_to_subtype TypeVec.subtypeVal_toSubtype\n-/\n\n/- warning: typevec.to_subtype_of_subtype_assoc -> TypeVec.toSubtype_of_subtype_assoc is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {α : TypeVec.{u1} n} {β : TypeVec.{u2} n} (p : TypeVec.Arrow.{u1, 0} n α (TypeVec.repeat.{0} n Prop)) (f : TypeVec.Arrow.{u2, u1} n β (TypeVec.Subtype_.{u1} n α p)), Eq.{max 1 (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n β (TypeVec.Subtype_.{u1} n α p)) (TypeVec.comp.{u2, u1, u1} n β (fun (i : Fin2 n) => Subtype.{succ u1} (α i) (fun (x : α i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.Subtype_.{u1} n α p) (TypeVec.toSubtype.{u1} n α p) (TypeVec.comp.{u2, u1, u1} n β (TypeVec.Subtype_.{u1} n (fun (i : Fin2 n) => α i) (fun (i : Fin2 n) (x : α i) => p i x)) (fun (i : Fin2 n) => Subtype.{succ u1} (α i) (fun (x : α i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.ofSubtype.{u1} n (fun (i : Fin2 n) => α i) (fun (i : Fin2 n) (x : α i) => p i x)) f)) f\nbut is expected to have type\n  forall {n : Nat} {α : TypeVec.{u2} n} {β : TypeVec.{u1} n} (p : TypeVec.Arrow.{u2, 0} n α (TypeVec.repeat.{0} n Prop)) (f : TypeVec.Arrow.{u1, u2} n β (TypeVec.Subtype_.{u2} n α p)), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u1, u2} n β (TypeVec.Subtype_.{u2} n α p)) (TypeVec.comp.{u1, u2, u2} n β (fun (i : Fin2 n) => Subtype.{succ u2} (α i) (fun (x : α i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.Subtype_.{u2} n α p) (TypeVec.toSubtype.{u2} n α p) (TypeVec.comp.{u1, u2, u2} n β (TypeVec.Subtype_.{u2} n (fun (i : Fin2 n) => α i) (fun (i : Fin2 n) (x : α i) => p i x)) (fun (i : Fin2 n) => Subtype.{succ u2} (α i) (fun (x : α i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.ofSubtype.{u2} n (fun (i : Fin2 n) => α i) (fun (i : Fin2 n) (x : α i) => p i x)) f)) f\nCase conversion may be inaccurate. Consider using '#align typevec.to_subtype_of_subtype_assoc TypeVec.toSubtype_of_subtype_assocₓ'. -/\n@[simp]\ntheorem toSubtype_of_subtype_assoc {α β : TypeVec n} (p : α ⟹ repeat n Prop) (f : β ⟹ Subtype_ p) :\n    @toSubtype n _ p ⊚ ofSubtype _ ⊚ f = f := by rw [← comp_assoc, to_subtype_of_subtype] <;> simp\n#align typevec.to_subtype_of_subtype_assoc TypeVec.toSubtype_of_subtype_assoc\n\n#print TypeVec.toSubtype'_of_subtype' /-\n@[simp]\ntheorem toSubtype'_of_subtype' {α : TypeVec n} (r : α ⊗ α ⟹ repeat n Prop) :\n    toSubtype' r ⊚ ofSubtype' r = id := by\n  ext (i x) <;> induction i <;> dsimp only [id, to_subtype', comp, of_subtype'] at * <;>\n    simp [Subtype.eta, *]\n#align typevec.to_subtype'_of_subtype' TypeVec.toSubtype'_of_subtype'\n-/\n\n#print TypeVec.subtypeVal_toSubtype' /-\ntheorem subtypeVal_toSubtype' {α : TypeVec n} (r : α ⊗ α ⟹ repeat n Prop) :\n    subtypeVal r ⊚ toSubtype' r = fun i x => prod.mk i x.1.fst x.1.snd := by\n  ext (i x) <;> induction i <;> dsimp only [id, to_subtype', comp, subtype_val, Prod.mk] at * <;>\n    simp [*]\n#align typevec.subtype_val_to_subtype' TypeVec.subtypeVal_toSubtype'\n-/\n\nend TypeVec\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Typevec.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.49935434499255443}}
{"text": "/-\nCopyright (c) 2022 Paul Reichert. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Paul Reichert\n\n! This file was ported from Lean 3 source module linear_algebra.affine_space.restrict\n! leanprover-community/mathlib commit 09258fb7f75d741b7eda9fa18d5c869e2135d9f1\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.LinearAlgebra.AffineSpace.AffineSubspace\n\n/-!\n# Affine map restrictions\n\nThis file defines restrictions of affine maps.\n\n## Main definitions\n\n* The domain and codomain of an affine map can be restricted using\n  `AffineMap.restrict`.\n\n## Main theorems\n\n* The associated linear map of the restriction is the restriction of the\n  linear map associated to the original affine map.\n* The restriction is injective if the original map is injective.\n* The restriction in surjective if the codomain is the image of the domain.\n-/\n\n\nvariable {k V₁ P₁ V₂ P₂ : Type _} [Ring k] [AddCommGroup V₁] [AddCommGroup V₂] [Module k V₁]\n  [Module k V₂] [AddTorsor V₁ P₁] [AddTorsor V₂ P₂]\n\n-- not an instance because it loops with `Nonempty`\ntheorem AffineSubspace.nonempty_map {E : AffineSubspace k P₁} [Ene : Nonempty E] {φ : P₁ →ᵃ[k] P₂} :\n    Nonempty (E.map φ) := by\n  obtain ⟨x, hx⟩ := id Ene\n  refine' ⟨⟨φ x, AffineSubspace.mem_map.mpr ⟨x, hx, rfl⟩⟩⟩\n#align affine_subspace.nonempty_map AffineSubspace.nonempty_map\n\n-- Porting note: removed \"local nolint fails_quickly\" attribute\nattribute [local instance] AffineSubspace.nonempty_map AffineSubspace.toAddTorsor\n\n/-- Restrict domain and codomain of an affine map to the given subspaces. -/\ndef AffineMap.restrict (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂}\n    [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : E →ᵃ[k] F := by\n  refine' ⟨_, _, _⟩\n  · exact fun x => ⟨φ x, hEF <| AffineSubspace.mem_map.mpr ⟨x, x.property, rfl⟩⟩\n  · refine' φ.linear.restrict (_ : E.direction ≤ F.direction.comap φ.linear)\n    rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n    exact AffineSubspace.direction_le hEF\n  · intro p v\n    simp only [Subtype.ext_iff, Subtype.coe_mk, AffineSubspace.coe_vadd]\n    apply AffineMap.map_vadd\n#align affine_map.restrict AffineMap.restrict\n\ntheorem AffineMap.restrict.coe_apply (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) (x : E) :\n    ↑(φ.restrict hEF x) = φ x :=\n  rfl\n#align affine_map.restrict.coe_apply AffineMap.restrict.coe_apply\n\ntheorem AffineMap.restrict.linear_aux {φ : P₁ →ᵃ[k] P₂} {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} (hEF : E.map φ ≤ F) : E.direction ≤ F.direction.comap φ.linear := by\n  rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n  exact AffineSubspace.direction_le hEF\n#align affine_map.restrict.linear_aux AffineMap.restrict.linear_aux\n\ntheorem AffineMap.restrict.linear (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) :\n    (φ.restrict hEF).linear = φ.linear.restrict (AffineMap.restrict.linear_aux hEF) :=\n  rfl\n#align affine_map.restrict.linear AffineMap.restrict.linear\n\ntheorem AffineMap.restrict.injective {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Injective φ)\n    {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F]\n    (hEF : E.map φ ≤ F) : Function.Injective (AffineMap.restrict φ hEF) := by\n  intro x y h\n  simp only [Subtype.ext_iff, Subtype.coe_mk, AffineMap.restrict.coe_apply] at h⊢\n  exact hφ h\n#align affine_map.restrict.injective AffineMap.restrict.injective\n\ntheorem AffineMap.restrict.surjective (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (h : E.map φ = F) :\n    Function.Surjective (AffineMap.restrict φ (le_of_eq h)) := by\n  rintro ⟨x, hx : x ∈ F⟩\n  rw [← h, AffineSubspace.mem_map] at hx\n  obtain ⟨y, hy, rfl⟩ := hx\n  exact ⟨⟨y, hy⟩, rfl⟩\n#align affine_map.restrict.surjective AffineMap.restrict.surjective\n\ntheorem AffineMap.restrict.bijective {E : AffineSubspace k P₁} [Nonempty E] {φ : P₁ →ᵃ[k] P₂}\n    (hφ : Function.Injective φ) : Function.Bijective (φ.restrict (le_refl (E.map φ))) :=\n  ⟨AffineMap.restrict.injective hφ _, AffineMap.restrict.surjective _ rfl⟩\n#align affine_map.restrict.bijective AffineMap.restrict.bijective\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/LinearAlgebra/AffineSpace/Restrict.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.49935434499255443}}
{"text": "/-\nCopyright (c) 2022 Antoine Labelle. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Labelle\n-/\nimport category_theory.closed.monoidal\nimport category_theory.monoidal.functor_category\n\n/-!\n# Functors from a groupoid into a monoidal closed category form a monoidal closed category.\n\n(Using the pointwise monoidal structure on the functor category.)\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.monoidal_category\nopen category_theory.monoidal_closed\n\nnamespace category_theory.functor\n\nvariables {C D : Type*} [groupoid D] [category C] [monoidal_category C] [monoidal_closed C]\n\n/-- Auxiliary definition for `category_theory.monoidal_closed.functor_closed`.\nThe internal hom functor `F ⟶[C] -` -/\n@[simps] def closed_ihom (F : D ⥤ C) : (D ⥤ C) ⥤ (D ⥤ C) :=\n((whiskering_right₂ D Cᵒᵖ C C).obj internal_hom).obj (groupoid.inv_functor D ⋙ F.op)\n\n/-- Auxiliary definition for `category_theory.monoidal_closed.functor_closed`.\nThe unit for the adjunction `(tensor_left F) ⊣ (ihom F)`. -/\n@[simps]\ndef closed_unit (F : D ⥤ C) : 𝟭 (D ⥤ C) ⟶ (tensor_left F) ⋙ (closed_ihom F) :=\n{ app := λ G,\n  { app := λ X, (ihom.coev (F.obj X)).app (G.obj X),\n    naturality' := begin\n      intros X Y f,\n      dsimp,\n      simp only [ihom.coev_naturality, closed_ihom_obj_map, monoidal.tensor_obj_map],\n      dsimp,\n      rw [coev_app_comp_pre_app_assoc, ←functor.map_comp],\n      simp,\n    end } }\n\n/-- Auxiliary definition for `category_theory.monoidal_closed.functor_closed`.\nThe counit for the adjunction `(tensor_left F) ⊣ (ihom F)`. -/\n@[simps]\ndef closed_counit (F : D ⥤ C) : (closed_ihom F) ⋙ (tensor_left F) ⟶ 𝟭 (D ⥤ C) :=\n{ app := λ G,\n  { app := λ X, (ihom.ev (F.obj X)).app (G.obj X),\n    naturality' := begin\n      intros X Y f,\n      dsimp,\n      simp only [closed_ihom_obj_map, pre_comm_ihom_map],\n      rw [←tensor_id_comp_id_tensor, id_tensor_comp],\n      simp,\n    end } }\n\n/-- If `C` is a monoidal closed category and `D` is groupoid, then every functor `F : D ⥤ C` is\nclosed in the functor category `F : D ⥤ C` with the pointwise monoidal structure. -/\n@[simps] instance closed (F : D ⥤ C) : closed F :=\n{ is_adj :=\n  { right := closed_ihom F,\n    adj := adjunction.mk_of_unit_counit\n    { unit := closed_unit F,\n      counit := closed_counit F } } }\n\n/-- If `C` is a monoidal closed category and `D` is groupoid, then the functor category `D ⥤ C`,\nwith the pointwise monoidal structure, is monoidal closed. -/\n@[simps] instance monoidal_closed : monoidal_closed (D ⥤ C) :=\n{ closed' := by apply_instance }\n\nlemma ihom_map (F : D ⥤ C) {G H : D ⥤ C} (f : G ⟶ H) :\n  (ihom F).map f = (closed_ihom F).map f := rfl\n\nlemma ihom_ev_app (F G : D ⥤ C) :\n  (ihom.ev F).app G = (closed_counit F).app G := rfl\n\nlemma ihom_coev_app (F G : D ⥤ C) :\n  (ihom.coev F).app G = (closed_unit F).app G := rfl\n\nend category_theory.functor\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/closed/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117898012104, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.49927756717751404}}
{"text": "/-\nCopyright (c) 2021-2022 Julien Marquet. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Julien Marquet\n-/\n\nimport Flows.Groundwork\nimport Flows.Term\nimport Flows.Subst\nimport Flows.Vehicle\n\nopen Classical\n\nset_option codegen false\n\nsection\n\nvariable {α β : Type u}\n\ndef vanishing (θ : Subst α β) :=\n  ∀ {x}, (Term.Var x : Term α β) • θ ≠ Term.Var x →\n    ∀ y, ¬ (x ∈ (𝒱 ((Term.Var y : Term α β) • θ) : Fintype β))\n\ntheorem vanishing_on_term {θ : Subst α β} (h₁ : vanishing θ)\n  {x : β} (h₂ : (Term.Var x : Term α β) • θ ≠ Term.Var x)\n  (u : Term α β) : ¬ x ∈ (𝒱 (u • θ) : Fintype β) := by\n  induction u with\n  | Cst c => match θ with\n    | ⟨ θ, h ⟩ => intro h; cases h <;> trivial\n  | Var y => exact h₁ h₂ _\n  | Cons l r hl hr =>\n    rw [subst_cons]\n    intro h\n    cases (Fintype.mem_union_iff _ _ _).1 h with\n    | inl h => exact hl h\n    | inr h => exact hr h\n\ntheorem vanishing_on_vehicle {θ : Subst α β} (h₁ : vanishing θ)\n  {x : β} (h₂ : (Term.Var x : Term α β) • θ ≠ Term.Var x) :\n  ¬ x ∈ (𝒱 θ : Fintype β) := by\n  suffices h : 𝒱 θ ⊆ 𝒱 θ \\ (Fintype.mk [x]) by\n    apply Fintype.not_mem_iff_in_without.2\n    exact h\n  conv => lhs; simp only [HasVehicle.vehicle, Subst.vehicle]\n  apply Fintype.image_in_of_all_in\n  intro a h\n  apply Fintype.included_trans _\n    <| Fintype.included_without_of_included _\n    <| Fintype.in_image_of_is_image h\n  apply Fintype.not_mem_iff_in_without.1\n  apply vanishing_on_term h₁ h₂\n\ntheorem vanishing_respects_vehicle {θ : Subst α β} (h₁ : vanishing θ) {x : β}\n  (h₂ : ¬ x ∈ (𝒱 θ : Fintype β)) {u : Term α β} (h₃ : ¬ x ∈ (𝒱 u : Fintype β)) :\n  ¬ x ∈ (𝒱 (u • θ) : Fintype β) := by\n  apply Fintype.not_mem_of_superset_not_mem (vehicle_on_image Fintype.included_refl _)\n  intro h\n  rw [Fintype.mem_union_iff] at h\n  exact match h with\n  | Or.inl h => h₂ h\n  | Or.inr h => h₃ h\n\ntheorem cons_vanishing {θ φ : Subst α β} {l₁ r₁ l₂ r₂ : Term α β}\n  (h₁ : (𝒱 θ : Fintype β) ⊆ 𝒱 l₁ ∪ 𝒱 l₂)\n  (h₂ : (𝒱 φ : Fintype β) ⊆ 𝒱 (r₁ • θ) ∪ 𝒱 (r₂ • θ))\n  (h₃ : vanishing θ) (h₄ : vanishing φ) : vanishing (θ * φ) := by\n  intro x hx y\n  by_cases hθ : (Term.Var x : Term α β) • θ = Term.Var x\n  focus\n    let p := show (Term.Var x : Term α β) • φ ≠ Term.Var x by\n      intro hφ\n      apply hx\n      rw [← RAction.smul_mul, hθ, hφ]\n    rw [← RAction.smul_mul]\n    apply vanishing_on_term h₄ p\n  focus\n    let p := show ¬ x ∈ (𝒱 φ : Fintype β) by\n      apply Fintype.not_mem_of_superset_not_mem h₂\n      intro h\n      rw [Fintype.mem_union_iff] at h\n      exact match h with\n      | Or.inl h => (vanishing_on_term h₃ hθ r₁) h\n      | Or.inr h => (vanishing_on_term h₃ hθ r₂) h\n    rw [← RAction.smul_mul]\n    exact vanishing_respects_vehicle h₄ p (h₃ hθ _)\n\ntheorem elementary_vanishing {x : β} {u : Term α β} {h₁ : Term.Var x ≠ u}\n  (h₂ : ¬ x ∈ (𝒱 u : Fintype β)) :\n  vanishing (Subst.elementary h₁ : Subst α β) := by\n  intro z hz t\n  intro h'\n  have p : z = x := by\n    let p := carrier_spec.2 hz\n    rw [elementary_carrier, Fintype.mem_mk_iff] at p\n    cases p <;> trivial\n  rw [p] at h'\n  by_cases p' : t = x\n  focus\n    rw [p'] at h'\n    rw [Subst.elementary_spec₁] at h'\n    exact h₂ h'\n  focus\n    rw [Subst.elementary_spec₂ _ p'] at h'\n    apply Ne.symm p'\n    cases h' <;> trivial\n\nend\n\n", "meta": {"author": "thejohncrafter", "repo": "flows", "sha": "f4732e6784aa6ea13b07dc042be2c3816a73fa84", "save_path": "github-repos/lean/thejohncrafter-flows", "path": "github-repos/lean/thejohncrafter-flows/flows-f4732e6784aa6ea13b07dc042be2c3816a73fa84/Flows/Vanishing.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.499129092186713}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Johannes Hölzl, Yury Kudryashov\n-/\nimport algebra.category.Group.basic\nimport category_theory.concrete_category.reflects_isomorphisms\nimport algebra.ring.equiv\n\n/-!\n# Category instances for semiring, ring, comm_semiring, and comm_ring.\n\nWe introduce the bundled categories:\n* `SemiRing`\n* `Ring`\n* `CommSemiRing`\n* `CommRing`\nalong with the relevant forgetful functors between them.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of semirings. -/\ndef SemiRing : Type (u+1) := bundled semiring\n\nnamespace SemiRing\n\n/-- `ring_hom` doesn't actually assume associativity. This alias is needed to make the category\ntheory machinery work. We use the same trick in `category_theory.Mon.assoc_monoid_hom`. -/\nabbreviation assoc_ring_hom (M N : Type*) [semiring M] [semiring N] := ring_hom M N\n\ninstance bundled_hom : bundled_hom assoc_ring_hom :=\n⟨λ M N [semiring M] [semiring N], by exactI @ring_hom.to_fun M N _ _,\n λ M [semiring M], by exactI @ring_hom.id M _,\n λ M N P [semiring M] [semiring N] [semiring P], by exactI @ring_hom.comp M N P _ _ _,\n λ M N [semiring M] [semiring N], by exactI @ring_hom.coe_inj M N _ _⟩\n\nattribute [derive [large_category, concrete_category]] SemiRing\n\ninstance : has_coe_to_sort SemiRing Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled SemiRing from the underlying type and typeclass. -/\ndef of (R : Type u) [semiring R] : SemiRing := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `SemiRing`. -/\ndef of_hom {R S : Type u} [semiring R] [semiring S] (f : R →+* S) : of R ⟶ of S := f\n\n@[simp] lemma of_hom_apply {R S : Type u} [semiring R] [semiring S] (f : R →+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited SemiRing := ⟨of punit⟩\n\ninstance (R : SemiRing) : semiring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [semiring R] : (SemiRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_Mon : has_forget₂ SemiRing Mon :=\nbundled_hom.mk_has_forget₂\n  (λ R hR, @monoid_with_zero.to_monoid R (@semiring.to_monoid_with_zero R hR))\n  (λ R₁ R₂, ring_hom.to_monoid_hom) (λ _ _ _, rfl)\n\ninstance has_forget_to_AddCommMon : has_forget₂ SemiRing AddCommMon :=\n-- can't use bundled_hom.mk_has_forget₂, since AddCommMon is an induced category\n{ forget₂ :=\n  { obj := λ R, AddCommMon.of R,\n    map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }\n\nend SemiRing\n\n/-- The category of rings. -/\ndef Ring : Type (u+1) := bundled ring\n\nnamespace Ring\n\ninstance : bundled_hom.parent_projection @ring.to_semiring := ⟨⟩\n\nattribute [derive [(λ Ring, has_coe_to_sort Ring Type*), large_category, concrete_category]] Ring\n\n/-- Construct a bundled Ring from the underlying type and typeclass. -/\ndef of (R : Type u) [ring R] : Ring := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `Ring`. -/\ndef of_hom {R S : Type u} [ring R] [ring S] (f : R →+* S) : of R ⟶ of S := f\n\n@[simp] lemma of_hom_apply {R S : Type u} [ring R] [ring S] (f : R →+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited Ring := ⟨of punit⟩\n\ninstance (R : Ring) : ring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [ring R] : (Ring.of R : Type u) = R := rfl\n\ninstance has_forget_to_SemiRing : has_forget₂ Ring SemiRing := bundled_hom.forget₂ _ _\ninstance has_forget_to_AddCommGroup : has_forget₂ Ring AddCommGroup :=\n-- can't use bundled_hom.mk_has_forget₂, since AddCommGroup is an induced category\n{ forget₂ :=\n  { obj := λ R, AddCommGroup.of R,\n    map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }\n\nend Ring\n\n/-- The category of commutative semirings. -/\ndef CommSemiRing : Type (u+1) := bundled comm_semiring\n\nnamespace CommSemiRing\n\ninstance : bundled_hom.parent_projection @comm_semiring.to_semiring := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommSemiRing\n\ninstance : has_coe_to_sort CommSemiRing Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled CommSemiRing from the underlying type and typeclass. -/\ndef of (R : Type u) [comm_semiring R] : CommSemiRing := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `CommSemiRing`. -/\ndef of_hom {R S : Type u} [comm_semiring R] [comm_semiring S] (f : R →+* S) : of R ⟶ of S := f\n\n@[simp]\nlemma of_hom_apply {R S : Type u} [comm_semiring R] [comm_semiring S] (f : R →+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited CommSemiRing := ⟨of punit⟩\n\ninstance (R : CommSemiRing) : comm_semiring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [comm_semiring R] : (CommSemiRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_SemiRing : has_forget₂ CommSemiRing SemiRing := bundled_hom.forget₂ _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommMon : has_forget₂ CommSemiRing CommMon :=\nhas_forget₂.mk'\n  (λ R : CommSemiRing, CommMon.of R) (λ R, rfl)\n  (λ R₁ R₂ f, f.to_monoid_hom) (by tidy)\n\nend CommSemiRing\n\n/-- The category of commutative rings. -/\ndef CommRing : Type (u+1) := bundled comm_ring\n\nnamespace CommRing\n\ninstance : bundled_hom.parent_projection @comm_ring.to_ring := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommRing\n\ninstance : has_coe_to_sort CommRing Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled CommRing from the underlying type and typeclass. -/\ndef of (R : Type u) [comm_ring R] : CommRing := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `CommRing`. -/\ndef of_hom {R S : Type u} [comm_ring R] [comm_ring S] (f : R →+* S) : of R ⟶ of S := f\n\n@[simp] lemma of_hom_apply {R S : Type u} [comm_ring R] [comm_ring S] (f : R →+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited CommRing := ⟨of punit⟩\n\ninstance (R : CommRing) : comm_ring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [comm_ring R] : (CommRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_Ring : has_forget₂ CommRing Ring := bundled_hom.forget₂ _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommSemiRing : has_forget₂ CommRing CommSemiRing :=\nhas_forget₂.mk' (λ R : CommRing, CommSemiRing.of R) (λ R, rfl) (λ R₁ R₂ f, f) (by tidy)\n\ninstance : full (forget₂ CommRing CommSemiRing) :=\n{ preimage := λ X Y f, f, }\n\nend CommRing\n\n-- This example verifies an improvement possible in Lean 3.8.\n-- Before that, to have `add_ring_hom.map_zero` usable by `simp` here,\n-- we had to mark all the concrete category `has_coe_to_sort` instances reducible.\n-- Now, it just works.\nexample {R S : CommRing} (i : R ⟶ S) (r : R) (h : r = 0) : i r = 0 :=\nby simp [h]\n\nnamespace ring_equiv\n\nvariables {X Y : Type u}\n\n/-- Build an isomorphism in the category `Ring` from a `ring_equiv` between `ring`s. -/\n@[simps] def to_Ring_iso [ring X] [ring Y] (e : X ≃+* Y) : Ring.of X ≅ Ring.of Y :=\n{ hom := e.to_ring_hom,\n  inv := e.symm.to_ring_hom }\n\n/-- Build an isomorphism in the category `CommRing` from a `ring_equiv` between `comm_ring`s. -/\n@[simps] def to_CommRing_iso [comm_ring X] [comm_ring Y] (e : X ≃+* Y) :\n  CommRing.of X ≅ CommRing.of Y :=\n{ hom := e.to_ring_hom,\n  inv := e.symm.to_ring_hom }\n\nend ring_equiv\n\nnamespace category_theory.iso\n\n/-- Build a `ring_equiv` from an isomorphism in the category `Ring`. -/\ndef Ring_iso_to_ring_equiv {X Y : Ring} (i : X ≅ Y) : X ≃+* Y :=\n{ to_fun    := i.hom,\n  inv_fun   := i.inv,\n  left_inv  := by tidy,\n  right_inv := by tidy,\n  map_add'  := by tidy,\n  map_mul'  := by tidy }.\n\n/-- Build a `ring_equiv` from an isomorphism in the category `CommRing`. -/\ndef CommRing_iso_to_ring_equiv {X Y : CommRing} (i : X ≅ Y) : X ≃+* Y :=\n{ to_fun    := i.hom,\n  inv_fun   := i.inv,\n  left_inv  := by tidy,\n  right_inv := by tidy,\n  map_add'  := by tidy,\n  map_mul'  := by tidy }.\n\n@[simp]\nlemma CommRing_iso_to_ring_equiv_to_ring_hom {X Y : CommRing} (i : X ≅ Y) :\n  i.CommRing_iso_to_ring_equiv.to_ring_hom = i.hom := by { ext, refl }\n\n@[simp]\nlemma CommRing_iso_to_ring_equiv_symm_to_ring_hom {X Y : CommRing} (i : X ≅ Y) :\n  i.CommRing_iso_to_ring_equiv.symm.to_ring_hom = i.inv := by { ext, refl }\n\nend category_theory.iso\n\n/-- Ring equivalences between `ring`s are the same as (isomorphic to) isomorphisms in `Ring`. -/\ndef ring_equiv_iso_Ring_iso {X Y : Type u} [ring X] [ring Y] :\n  (X ≃+* Y) ≅ (Ring.of X ≅ Ring.of Y) :=\n{ hom := λ e, e.to_Ring_iso,\n  inv := λ i, i.Ring_iso_to_ring_equiv, }\n\n/-- Ring equivalences between `comm_ring`s are the same as (isomorphic to) isomorphisms\nin `CommRing`. -/\ndef ring_equiv_iso_CommRing_iso {X Y : Type u} [comm_ring X] [comm_ring Y] :\n  (X ≃+* Y) ≅ (CommRing.of X ≅ CommRing.of Y) :=\n{ hom := λ e, e.to_CommRing_iso,\n  inv := λ i, i.CommRing_iso_to_ring_equiv, }\n\ninstance Ring.forget_reflects_isos : reflects_isomorphisms (forget Ring.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Ring).map f),\n    let e : X ≃+* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Ring_iso).1⟩,\n  end }\n\ninstance CommRing.forget_reflects_isos : reflects_isomorphisms (forget CommRing.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommRing).map f),\n    let e : X ≃+* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommRing_iso).1⟩,\n  end }\n\n-- It would be nice if we could have the following,\n-- but it requires making `reflects_isomorphisms_forget₂` an instance,\n-- which can cause typeclass loops:\n\nlocal attribute [priority 50,instance] reflects_isomorphisms_forget₂\nexample : reflects_isomorphisms (forget₂ Ring AddCommGroup) := by apply_instance\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/category/CommRing/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303336, "lm_q2_score": 0.7662936430859598, "lm_q1q2_score": 0.4991290818143764}}
{"text": "import M4R.Algebra.Group.Defs\n\nnamespace M4R\n  namespace Monoid\n\n    protected instance Product (α₁ : Type _) (α₂ : Type _) [Monoid α₁] [Monoid α₂] : Monoid (α₁ × α₂) where\n      zero      := (0, 0)\n      add       := fun (x₁, x₂) (y₁, y₂) => (x₁ + y₁, x₂ + y₂)\n      add_zero  := fun (a₁, a₂) => by simp only [HAdd.hAdd, Add.add, Prod.mk.injEq]; exact ⟨add_zero a₁, add_zero a₂⟩\n      zero_add  := fun (a₁, a₂) => by simp only [HAdd.hAdd, Add.add, Prod.mk.injEq]; exact ⟨zero_add a₁, zero_add a₂⟩\n      add_assoc := fun (a₁, a₂) (b₁, b₂) (c₁, c₂) => by\n        simp only [HAdd.hAdd, Add.add, Prod.mk.injEq]\n        exact ⟨add_assoc a₁ b₁ c₁, add_assoc a₂ b₂ c₂⟩\n\n    theorem product_zero (α₁ : Type _) (α₂ : Type _) [Monoid α₁] [Monoid α₂] : (0 : α₁ × α₂) = (0, 0) := rfl\n    theorem product_add {α₁ : Type _} {α₂ : Type _} [Monoid α₁] [Monoid α₂] : ∀ x y : α₁ × α₂, x + y = (x.fst + y.fst, x.snd + y.snd) :=\n      fun (x₁, x₂) (y₁, y₂) => rfl\n\n    protected instance multi_product.Zero {ι : Type _} (fι : ι → Type _) [∀ i, Zero (fι i)] : Zero (MultiProd fι) where\n      zero := fun _ => 0\n    protected theorem multi_product.Zero_def {ι : Type _} {fι : ι → Type _} [∀ i, Zero (fι i)] : ∀ i, (0 : MultiProd fι) i = 0 :=\n      fun _ => rfl\n\n    protected instance multi_product.Add {ι : Type _} (fι : ι → Type _) [∀ i, Add (fι i)] : Add (MultiProd fι) where\n      add := fun a b i => a i + b i\n    protected theorem multi_product.Add_def {ι : Type _} {fι : ι → Type _} [∀ i, Add (fι i)] (a b : MultiProd fι) :\n      ∀ i, (a + b) i = a i + b i := fun _ => rfl\n\n    protected instance multi_product {ι : Type _} (fι : ι → Type _) [∀ i, Monoid (fι i)] : Monoid (MultiProd fι) where\n      add_zero  := fun a => funext fun i => Monoid.add_zero (a i)\n      zero_add  := fun a => funext fun i => Monoid.zero_add (a i)\n      add_assoc := fun a b c => funext fun i => Monoid.add_assoc (a i) (b i) (c i)\n\n  end Monoid\n\n  namespace CommMonoid\n\n    protected instance Product (α₁ : Type _) (α₂ : Type _) [CommMonoid α₁] [CommMonoid α₂] : CommMonoid (α₁ × α₂) where\n      add_comm := fun (a₁, a₂) (b₁, b₂) => by simp [HAdd.hAdd, Add.add]; exact ⟨add_comm a₁ b₁, add_comm a₂ b₂⟩\n\n    protected instance multi_product {ι : Type _} (fι : ι → Type _) [∀ i, CommMonoid (fι i)] : CommMonoid (MultiProd fι) where\n      add_comm := fun a b => funext fun i => CommMonoid.add_comm (a i) (b i)\n\n    theorem add_right_comm [CommMonoid α] (a b c : α) : a + b + c = a + c + b := by\n      rw [Monoid.add_assoc, add_comm b, ←Monoid.add_assoc]\n    theorem add_left_comm [CommMonoid α] (a b c : α) : a + (b + c) = b + (a + c) := by\n      rw [←Monoid.add_assoc, add_comm a, Monoid.add_assoc]\n\n    protected class constructor_cm (α : Type _) extends Zero α, Add α where\n      add_zero  : ∀ a : α, a + 0 = a\n      add_assoc : ∀ a b c : α, (a + b) + c = a + (b + c)\n      add_comm  : ∀ a b : α, a + b = b + a\n\n    protected def construct {α : Type _} (c : CommMonoid.constructor_cm α) : CommMonoid α where\n      add_zero  := c.add_zero\n      zero_add  := fun a => by rw [c.add_comm]; exact c.add_zero a\n      add_assoc := c.add_assoc\n      add_comm  := c.add_comm\n\n    protected def to_constructor (α : Type _) [CommMonoid α] : CommMonoid.constructor_cm α where\n      add_zero  := Monoid.add_zero\n      add_assoc := Monoid.add_assoc\n      add_comm  := CommMonoid.add_comm\n\n  end CommMonoid\n\n  instance NatMonoid : CommMonoid Nat := CommMonoid.construct\n    {\n      add_zero  := Nat.add_zero\n      add_assoc := Nat.add_assoc\n      add_comm  := Nat.add_comm\n    }\n\n  instance UnorderedListMonoid (α : Type _) : CommMonoid (UnorderedList α) := CommMonoid.construct {\n    add_zero  := UnorderedList.append.add_zero\n    add_assoc := UnorderedList.append.assoc\n    add_comm  := UnorderedList.append.comm\n  }\n\nend M4R\n", "meta": {"author": "Hop311", "repo": "M4R", "sha": "ebd1b04af344f9737d290bf8b48b3cde35e9787b", "save_path": "github-repos/lean/Hop311-M4R", "path": "github-repos/lean/Hop311-M4R/M4R-ebd1b04af344f9737d290bf8b48b3cde35e9787b/M4R/Algebra/Group/Monoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4991290800476842}}
{"text": "import model4 model_theory.bundled \n\ninstance modelA : (first_order.language.unary_preds).Structure (fin 3 × ℕ) := \nfirst_order.language.Structure.mk₂ empty.elim empty.elim empty.elim \n(λ (b : bool), bool.rec {x : fin 3 × ℕ | x.fst = 0} {x : fin 3 × ℕ | x.fst = 1} b) empty.elim\n\ninstance modelB : (first_order.language.unary_preds).Structure (fin 2 × ℕ) := \nfirst_order.language.Structure.mk₂ empty.elim empty.elim empty.elim \n(λ (b : bool), bool.rec {x : fin 2 × ℕ | x.fst = 0} {x : fin 2 × ℕ | x.fst = 1} b) empty.elim\n\nlemma modelA₁up₁ : (fin 3 × ℕ) ⊨ (set.range (first_order.language.sentence.unary_card_ge first_order.language.up₁)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₁,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 1,\n  use x_snd + 1,\n  simp,\nend\n\nlemma modelB₁up₁ : (fin 2 × ℕ) ⊨ (set.range (first_order.language.sentence.unary_card_ge first_order.language.up₁)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₁,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 1,\n  use x_snd + 1,\n  simp,\nend\n\nlemma modelA₂up₁ : (fin 3 × ℕ) ⊨ (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up₁)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₁,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 2,\n  use x_snd + 1,\n  simp,\n  intro h,\n  simp at h,\n  injections_and_clear,\n  simp at *,\n  norm_num at h_1,\nend\n\nlemma modelB₂up₁ : (fin 2 × ℕ) ⊨ (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up₁)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₁,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 2,\n  use x_snd + 1,\n  simp,\n  intro h,\n  simp at h,\n  injections_and_clear,\n  simp at *,\n  norm_num at h_1,\nend\n\nlemma modelA₃ : (fin 3 × ℕ) ⊨ (first_order.language.sentence.unary_disjoint) :=\nbegin\n  simp,\n  rw first_order.language.up₁,\n  rw first_order.language.up₂,\n  simp,\n  rw disjoint_iff,\n  simp,\n  rw set.eq_empty_iff_forall_not_mem,\n  simp,\nend\n\nlemma modelB₃ : (fin 2 × ℕ) ⊨ (first_order.language.sentence.unary_disjoint) :=\nbegin\n  simp,\n  rw first_order.language.up₁,\n  rw first_order.language.up₂,\n  simp,\n  rw disjoint_iff,\n  simp,\n  rw set.eq_empty_iff_forall_not_mem,\n  simp,\nend\n\nlemma modelA₁up₂ : (fin 3 × ℕ) ⊨ (set.range (first_order.language.sentence.unary_card_ge first_order.language.up₂)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₂,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 0,\n  use x_snd + 1,\n  simp,\nend\n\nlemma modelB₁up₂ : (fin 2 × ℕ) ⊨ (set.range (first_order.language.sentence.unary_card_ge first_order.language.up₂)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₂,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 0,\n  use x_snd + 1,\n  simp,\nend\n\nlemma modelA₂up₂ : (fin 3 × ℕ) ⊨ (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up₂)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₂,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 2,\n  use x_snd + 1,\n  simp,\n  intro h,\n  simp at h,\n  injections_and_clear,\n  simp at *,\n  norm_num at h_1,\nend\n\nlemma modelB₂up₂ : (fin 2 × ℕ) ⊨ (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up₂)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up₂,\n  simp,\n  refine set.infinite_of_not_bdd_above _,\n  rw not_bdd_above_iff',\n  intros x,\n  induction x,\n  fconstructor,\n  fconstructor,\n  use 1,\n  use x_snd + 1,\n  simp,\n  intro h,\n  simp at h,\n  exact h\nend\n\ninstance modelAT : (fin 3 × ℕ) ⊨ (first_order.language.Theory.disjoint_unary_preds) :=\nbegin\n  rw first_order.language.Theory.disjoint_unary_preds,\n  rw first_order.language.Theory.model_union_iff,\n  rw first_order.language.Theory.model_union_iff,\n  rw first_order.language.Theory.model_union_iff,\n  rw first_order.language.Theory.model_union_iff,\n  split,\n  split,\n  split,\n  split,\n  exact modelA₁up₁,\n  exact modelA₁up₂,\n  exact modelA₂up₁,\n  exact modelA₂up₂,\n  rw first_order.language.Theory.model_singleton_iff,\n  exact modelA₃,\nend\n\n\ninstance modelBT : (fin 2 × ℕ) ⊨ (first_order.language.Theory.disjoint_unary_preds) :=\nbegin\n  rw first_order.language.Theory.disjoint_unary_preds,\n  rw first_order.language.Theory.model_union_iff,\n  rw first_order.language.Theory.model_union_iff,\n  rw first_order.language.Theory.model_union_iff,\n  rw first_order.language.Theory.model_union_iff,\n  split,\n  split,\n  split,\n  split,\n  exact modelB₁up₁,\n  exact modelB₁up₂,\n  exact modelB₂up₁,\n  exact modelB₂up₂,\n  rw first_order.language.Theory.model_singleton_iff,\n  exact modelB₃,\nend\n\nlemma modelAℵ₀ : cardinal.mk (fin 3 × ℕ) = cardinal.aleph_0 := \nbegin\n  rw ← cardinal.denumerable_iff,\n  fconstructor,\n  exact denumerable.of_encodable_of_infinite (fin 3 × ℕ),\nend\n\nlemma modelBℵ₀ : cardinal.mk (fin 2 × ℕ) = cardinal.aleph_0 := \nbegin\n  rw ← cardinal.denumerable_iff,\n  fconstructor,\n  exact denumerable.of_encodable_of_infinite (fin 2 × ℕ),\nend\n\ndef ModelA : first_order.language.Theory.Model (first_order.language.Theory.disjoint_unary_preds) := \n{ carrier := fin 3 × ℕ }\n\ndef ModelB : first_order.language.Theory.Model (first_order.language.Theory.disjoint_unary_preds) := \n{ carrier := fin 2 × ℕ }", "meta": {"author": "koly777", "repo": "model4oxflean", "sha": "8a7c7eaff9cc4104ec7760e4d1668d4992635492", "save_path": "github-repos/lean/koly777-model4oxflean", "path": "github-repos/lean/koly777-model4oxflean/model4oxflean-8a7c7eaff9cc4104ec7760e4d1668d4992635492/model4_c.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.49908371184476386}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang, Eric Wieser\n\nFrom: https://github.com/leanprover-community/mathlib/pull/14582\n-/\n\nimport cicm2022.internal.decomposition\nimport cicm2022.internal.graded_ring\n\n/-! # Graded scalar multiplication -/\n\n\n/-! ### External version on graded monoid -/\n\nnamespace graded_monoid\n\nvariables {ι : Type*} (A : ι → Type*) (M : ι → Type*)\n\n/-- A graded version of `has_smul`. Scalar multiplication combines grades additively, i.e.\nif `a ∈ A i` and `m ∈ M j`, then `a • b` must be in `M (i + j)`-/\nclass ghas_smul [has_add ι] :=\n(smul {i j} : A i → M j → M (i + j))\n\ninstance ghas_mul.to_ghas_mul [has_add ι] [ghas_mul A] : ghas_smul A A :=\n{ smul := λ _ _, ghas_mul.mul }\n\ninstance [has_add ι] [ghas_smul A M] : has_smul (graded_monoid A) (graded_monoid M) :=\n⟨λ (x : graded_monoid A) (y : graded_monoid M), ⟨_, ghas_smul.smul x.snd y.snd⟩⟩\n\n/-- A graded version of `mul_action`. -/\nclass gmul_action [add_monoid ι] [graded_monoid.gmonoid A] extends ghas_smul A M :=\n(one_smul (b : graded_monoid M) : (1 : graded_monoid A) • b = b)\n(mul_smul (a a' : graded_monoid A) (b : graded_monoid M) : (a * a') • b = a • a' • b)\n\ninstance gmonoid.to_gmul_action [add_monoid ι] [gmonoid A] :\n  gmul_action A A :=\n{ one_smul := λ x, graded_monoid.gmonoid.one_mul x,\n  mul_smul := graded_monoid.gmonoid.mul_assoc }\n\ninstance [add_monoid ι] [gmonoid A] [gmul_action A M] :\n  mul_action (graded_monoid A) (graded_monoid M) :=\n{ one_smul := gmul_action.one_smul,\n  mul_smul := gmul_action.mul_smul }\n\nend graded_monoid\n\n/-! ### Internal version -/\n\nsection set_like\n\n/-- A version of `graded_monoid.ghas_smul` for internally graded objects. -/\nclass set_like.has_graded_smul {ι S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add ι] (A : ι → S) (B : ι → N) : Prop :=\n(smul_mem : ∀ ⦃i j : ι⦄ {ai bj}, ai ∈ A i → bj ∈ B j → ai • bj ∈ B (i + j))\n\nlemma set_like.smul_mem_graded {ι S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add ι] (A : ι → S) (B : ι → N) [set_like.has_graded_smul A B]\n  ⦃i j⦄ {gi gj} (hi : gi ∈ A i) (hj : gj ∈ B j) :\n  gi • gj ∈ B (i + j) :=\nset_like.has_graded_smul.smul_mem hi hj\n\ninstance set_like.ghas_smul {ι S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add ι] (A : ι → S) (B : ι → N) [set_like.has_graded_smul A B] :\n  graded_monoid.ghas_smul (λ i, A i) (λ i, B i) :=\n{ smul := λ i j a b, ⟨(a : R) • b, set_like.has_graded_smul.smul_mem a.2 b.2⟩ }\n\n@[simp] lemma set_like.coe_ghas_smul {ι S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add ι] (A : ι → S) (B : ι → N) [set_like.has_graded_smul A B]\n  {i j : ι} (x : A i) (y : B j) :\n  (@graded_monoid.ghas_smul.smul ι (λ i, A i) (λ i, B i) _ _ i j x y : M) = ((x : R) • y) :=\nrfl\n\ninstance set_like.has_graded_mul.to_has_graded_smul\n  {ι S R : Type*} [set_like S R] [monoid R] [add_monoid ι] (A : ι → S) [set_like.has_graded_mul A] :\n  set_like.has_graded_smul A A :=\n{ smul_mem := λ i j ai bj hi hj, set_like.has_graded_mul.mul_mem hi hj, }\n\nend set_like\n\n/-! ### Graded modules -/\n\nsection gmodule\n\nsection defs\n\nvariables {ι : Type*} [add_monoid ι] (A : ι → Type*) (M : ι → Type*)\n\n/-- A graded version of `distrib_mul_action`. -/\nclass gdistrib_mul_action [graded_monoid.gmonoid A] [Π i, add_monoid $ M i]\n  extends graded_monoid.gmul_action A M :=\n(smul_add {i j} (a : A i) (b c : M j) : smul a (b + c) = smul a b + smul a c)\n(smul_zero {i j} (a : A i) : smul a (0 : M j) = 0)\n\n/-- A graded version of `module`. -/\nclass gmodule [graded_monoid.gmonoid A] [Π i, add_comm_monoid $ M i] [Π i, add_comm_monoid $ A i]\n  extends gdistrib_mul_action A M :=\n(add_smul {i j} (a a' : A i) (b : M j) : smul (a + a') b = smul a b + smul a' b)\n(zero_smul {i j} (b : M j) : smul (0 : A i) b = 0)\n\nend defs\n\n-- External version of graded module\nopen_locale direct_sum\n\nvariables {ι : Type*} [add_monoid ι] (A : ι → Type*) (M : ι → Type*)\nvariables [Π (i : ι), add_comm_monoid (A i)] [Π i, add_comm_monoid $ M i]\n\n/-- The piecewise multiplication from the `has_mul` instance, as a bundled homomorphism. -/\n@[simps]\ndef gsmul_hom {i j} [graded_monoid.gmonoid A] [gmodule A M] : A i →+ M j →+ M (i + j) :=\n{ to_fun := λ a,\n  { to_fun := λ b, graded_monoid.ghas_smul.smul a b,\n    map_zero' := gdistrib_mul_action.smul_zero _,\n    map_add' := gdistrib_mul_action.smul_add _ },\n  map_zero' := add_monoid_hom.ext $ λ a, gmodule.zero_smul a,\n  map_add' := λ a₁ a₂, add_monoid_hom.ext $ λ b, gmodule.add_smul _ _ _}\n\n/-- The multiplication from the `has_smul` instance, as a bundled homomorphism. -/\ndef gmodule.smul_add_monoid_hom [decidable_eq ι] [graded_monoid.gmonoid A] [gmodule A M] :\n  (⨁ i, A i) →+ (⨁ i, M i) →+ ⨁ i, M i :=\ndirect_sum.to_add_monoid $ λ i,\n  add_monoid_hom.flip $ direct_sum.to_add_monoid $ λ j, add_monoid_hom.flip $\n    (direct_sum.of M _).comp_hom.comp $ gsmul_hom A M\n\nsection\n\nvariables [decidable_eq ι] [graded_monoid.gmonoid A] [gmodule A M]\ninstance : has_smul (⨁ i, A i) (⨁ i, M i) :=\n{ smul := λ x y, gmodule.smul_add_monoid_hom A M x y }\n\n@[simp] lemma gmodule.smul_def\n  (x : ⨁ i, A i) (y : ⨁ i, M i) : x • y = gmodule.smul_add_monoid_hom _ _ x y := rfl\n@[simp] lemma gmodule.smul_add_monoid_hom_apply_of_of {i j} (x : A i) (y : M j) :\n  gmodule.smul_add_monoid_hom A M (direct_sum.of A i x) (direct_sum.of M j y) =\n  direct_sum.of M (i + j) (graded_monoid.ghas_smul.smul x y) :=\nby simp [gmodule.smul_add_monoid_hom]\n\n@[simp] lemma gmodule.of_smul_of\n  {i j} (x : A i) (y : M j) :\n  direct_sum.of A i x • direct_sum.of M j y =\n  direct_sum.of M (i + j) (graded_monoid.ghas_smul.smul x y) :=\ngmodule.smul_add_monoid_hom_apply_of_of _ _ _ _\n\nend\n\nopen add_monoid_hom\n\n-- Almost identical to the proof of `direct_sum.one_mul`\nprivate lemma one_smul [decidable_eq ι] [direct_sum.gsemiring A] [gmodule A M] (x : ⨁ i, M i) :\n  (1 : ⨁ i, A i) • x = x :=\nsuffices gmodule.smul_add_monoid_hom A M 1 = add_monoid_hom.id (⨁ i, M i),\n  from add_monoid_hom.congr_fun this x,\nbegin\n  apply direct_sum.add_hom_ext, intros i xi,\n  unfold has_one.one,\n  rw gmodule.smul_add_monoid_hom_apply_of_of,\n  exact direct_sum.of_eq_of_graded_monoid_eq (one_smul (graded_monoid A) $ graded_monoid.mk i xi),\nend\n\n-- Almost identical to the proof of `direct_sum.mul_assoc`\nprivate lemma mul_smul [decidable_eq ι] [direct_sum.gsemiring A] [gmodule A M]\n  (a b : ⨁ i, A i) (c : ⨁ i, M i) : (a * b) • c = a • (b • c) :=\nsuffices (gmodule.smul_add_monoid_hom A M).comp_hom.comp (direct_sum.mul_hom A) -- `λ a b c, (a * b) • c` as a bundled hom\n       = (add_monoid_hom.comp_hom add_monoid_hom.flip_hom $                     -- `λ a b c, a • (b • c)` as a bundled hom\n             (gmodule.smul_add_monoid_hom A M).flip.comp_hom.comp (gmodule.smul_add_monoid_hom A M)).flip,\n  from add_monoid_hom.congr_fun (add_monoid_hom.congr_fun (add_monoid_hom.congr_fun this a) b) c,\nbegin\n  ext ai ax bi bx ci cx : 6,\n  dsimp only [coe_comp, function.comp_app, comp_hom_apply_apply, flip_apply, flip_hom_apply],\n  rw [gmodule.smul_add_monoid_hom_apply_of_of, gmodule.smul_add_monoid_hom_apply_of_of,\n    direct_sum.mul_hom_of_of, gmodule.smul_add_monoid_hom_apply_of_of],\n  exact direct_sum.of_eq_of_graded_monoid_eq\n    (mul_smul (graded_monoid.mk ai ax) (graded_monoid.mk bi bx) (graded_monoid.mk ci cx)),\nend\n\ninstance gmodule.module [decidable_eq ι] [direct_sum.gsemiring A] [gmodule A M] :\n  module (⨁ i, A i) (⨁ i, M i) :=\n{ smul := (•),\n  one_smul := one_smul _ _,\n  mul_smul := mul_smul _ _,\n  smul_add := λ r, (gmodule.smul_add_monoid_hom A M r).map_add,\n  smul_zero := λ r, (gmodule.smul_add_monoid_hom A M r).map_zero,\n  add_smul := λ r s x, by simp only [gmodule.smul_def, map_add, add_monoid_hom.add_apply],\n  zero_smul := λ x, by simp only [gmodule.smul_def, map_zero, add_monoid_hom.zero_apply] }\n\nend gmodule\n\nsection\n\n-- internal version of graded module\n\nvariables {ι R A M σ σ' : Type*}\nvariables [add_monoid ι] [comm_semiring R] [semiring A] [algebra R A]\nvariables (𝓐 : ι → σ') [set_like σ' A]\nvariables (𝓜 : ι → σ)\n\nopen_locale direct_sum\n\nnamespace graded_module\n\ninclude σ' A σ M\n\ninstance gdistrib_mul_action [add_monoid M] [distrib_mul_action A M]\n  [set_like σ M] [add_submonoid_class σ M] [set_like.graded_monoid 𝓐]\n  [set_like.has_graded_smul 𝓐 𝓜] :\n  gdistrib_mul_action (λ i, 𝓐 i) (λ i, 𝓜 i) :=\n{ smul := λ i j x y, ⟨(x : A) • (y : M), set_like.has_graded_smul.smul_mem x.2 y.2⟩,\n  one_smul := λ ⟨i, m⟩, sigma.subtype_ext (zero_add _) (one_smul _ _),\n  mul_smul := λ ⟨i, a⟩ ⟨j, a'⟩ ⟨k, b⟩, sigma.subtype_ext (add_assoc _ _ _) (mul_smul _ _ _),\n  smul_add := λ i j a b c, subtype.ext $ smul_add _ _ _,\n  smul_zero := λ i j a, subtype.ext $ smul_zero _ }\n\nvariables [add_comm_monoid M] [module A M] [set_like σ M] [add_submonoid_class σ' A]\n  [add_submonoid_class σ M] [set_like.graded_monoid 𝓐] [set_like.has_graded_smul 𝓐 𝓜]\n\n-- [set_like.graded_monoid 𝓐] [set_like.has_graded_smul 𝓐 𝓜] is the internal version of graded module\n-- the internal version can be translated into the external version `gmodule`.\ninstance gmodule : gmodule (λ i, 𝓐 i) (λ i, 𝓜 i) :=\n{ smul := λ i j x y, ⟨(x : A) • (y : M), set_like.has_graded_smul.smul_mem x.2 y.2⟩,\n  add_smul := λ i j a a' b, subtype.ext $ add_smul _ _ _,\n  zero_smul := λ i j b, subtype.ext $ zero_smul _ _,\n  ..graded_module.gdistrib_mul_action 𝓐 𝓜}\n\n/--\nThe smul multiplication of `A` on `⨁ i, 𝓜 i` from `(⨁ i, 𝓐 i) →+ (⨁ i, 𝓜 i) →+ ⨁ i, 𝓜 i`\nturns `⨁ i, 𝓜 i` into an `A`-module\n-/\ndef is_module [decidable_eq ι] [graded_ring 𝓐] :\n  module A (⨁ i, 𝓜 i) :=\n{ smul := λ a b, direct_sum.decompose 𝓐 a • b,\n  ..module.comp_hom _ $\n    (direct_sum.decompose_ring_equiv 𝓐 : A ≃+* ⨁ i, 𝓐 i).to_ring_hom }\n\nlocal attribute [instance] graded_module.is_module\n\n/--\n`⨁ i, 𝓜 i` and `M` are isomorphic as `A`-modules.\n\"The internal version\" and \"the external version\" are isomorphism as `A`-modules.\n-/\ndef linear_equiv [decidable_eq ι] [graded_ring 𝓐] \n  [direct_sum.decomposition 𝓜] :\n  M ≃ₗ[A] ⨁ i, 𝓜 i :=\n{ to_fun := direct_sum.decompose_add_equiv 𝓜,\n  map_smul' := λ x y, begin\n    classical,\n    rw [← direct_sum.sum_support_decompose 𝓐 x, map_sum, finset.sum_smul, map_sum,\n      finset.sum_smul, finset.sum_congr rfl (λ i hi, _)],\n    rw [ring_hom.id_apply, ← direct_sum.sum_support_decompose 𝓜 y, map_sum, finset.smul_sum,\n      map_sum, finset.smul_sum, finset.sum_congr rfl (λ j hj, _)],\n    unfold has_smul.smul,\n    simp only [direct_sum.decompose_add_equiv_apply, direct_sum.decompose_coe,\n      gmodule.smul_add_monoid_hom_apply_of_of],\n    convert direct_sum.decompose_coe 𝓜 _,\n    refl,\n  end,\n  .. (direct_sum.decompose_add_equiv 𝓜) }\n\nend graded_module\n\nend\n", "meta": {"author": "eric-wieser", "repo": "lean-graded-rings", "sha": "53bccd2553ee2052907ff9519e63f1945e6add4c", "save_path": "github-repos/lean/eric-wieser-lean-graded-rings", "path": "github-repos/lean/eric-wieser-lean-graded-rings/lean-graded-rings-53bccd2553ee2052907ff9519e63f1945e6add4c/src/cicm2022/examples/graded_action.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.63341027059799, "lm_q1q2_score": 0.4990837118447637}}
{"text": "import ExtParser.Grammar\n\nnamespace AST\n  open Grammar\n\n  inductive PreAST (n : Nat) (b : Nat) where\n    | skip (s e : Fin b) (G : PEG n)\n    | ε (s e : Fin b)\n    | any (s e : Fin b) (x : Char)\n    | terminal (s e : Fin b) (a x : Char)\n    | nonTerminal (s e : Fin b) (A : Fin n) (T : PreAST n b)\n    | seq (s e : Fin b) (T1 T2 : PreAST n b)\n    | prior (s e : Fin b) (T1 T2 : PreAST n b)\n    | star (s e : Fin b) (T0 TS : PreAST n b)\n    | notP (s e : Fin b) (T : PreAST n b)\n\n  inductive PreAST.SkipPreAST : PreAST n b → Prop where\n    | skip : SkipPreAST (.skip s e G)\n\n  inductive PreAST.StarPreAST : PreAST n b → Prop where\n    | star : StarPreAST (.star s e T0 TS)\n\n  inductive PreAST.IsValid : PreAST n b → Prop where\n    | skip : IsValid (.skip s e G)\n    | ε : IsValid (.ε s e)\n    | any : IsValid (.any s e x)\n    | terminal : IsValid (.terminal s e a x)\n    | nonTerminal : IsValid sub_T → ¬SkipPreAST sub_T → IsValid (.nonTerminal s e A sub_T)\n    | seq : IsValid T1 → IsValid T2 → ¬SkipPreAST T1 → IsValid (.seq s e T1 T2)\n    | prior : IsValid T1 → IsValid T2 → ¬SkipPreAST T1 → IsValid (.prior s e T1 T2)\n    | star : IsValid T0 → IsValid TS → ¬SkipPreAST T0 → (SkipPreAST TS ∨ StarPreAST TS) → IsValid (.star s e T0 TS)\n    | notP : IsValid sub_T → ¬SkipPreAST sub_T → IsValid (.notP s e sub_T)\n\n  def PreAST.size (T : PreAST n b) : Nat :=\n    match T with\n    | .skip _ _ _ => 0\n    | .ε _ _ => 0\n    | .any _ _ _ => 0\n    | .terminal _ _ _ _ => 0\n    | .nonTerminal _ _ _ T => T.size + 1\n    | .seq _ _ T1 T2 => T1.size + T2.size + 1\n    | .prior _ _ T1 T2 => T1.size + T2.size + 1\n    | .star _ _ T0 TS => T0.size + TS.size + 1\n    | .notP _ _ T => T.size + 1\n  \n  def PreAST.start (T : PreAST n b) : Fin b :=\n    match T with\n    | .skip s _ _             => s\n    | .ε s _                  => s\n    | .any s _ _              => s\n    | .terminal s _ _ _       => s\n    | .nonTerminal s _ _ _    => s\n    | .seq s _ _ _            => s\n    | .prior s _ _ _          => s\n    | .star s _ _ _           => s\n    | .notP s _ _             => s\n\n  def PreAST.end (T : PreAST n b) : Fin b :=\n    match T with\n    | .skip _ e _             => e\n    | .ε _ e                  => e\n    | .any _ e _              => e\n    | .terminal _ e _ _       => e\n    | .nonTerminal _ e _ _    => e\n    | .seq _ e _ _            => e\n    | .prior _ e _ _          => e\n    | .star _ e _ _           => e\n    | .notP _ e _             => e\n\n  mutual\n\n  inductive PreAST.SuccessAST : PreAST n b → Prop where\n    | ε : s = e → SuccessAST (.ε s e)\n    | any : s.inbound_succ h = e → SuccessAST (.any s e x)\n    | terminal : s.inbound_succ h = e → a = x → SuccessAST (.terminal s e a x)\n    | nonTerminal : SuccessAST T → SuccessAST (.nonTerminal s e A T)\n    | seq : SuccessAST T1 → SuccessAST T2 → SuccessAST (.seq s e T1 T2)\n    | prior_S : SuccessAST T1 → SuccessAST (.prior s e T1 T2)\n    | prior_FS : FailureAST T1 → SuccessAST T2 → SuccessAST (.prior s e T1 T2)\n    | star_F : FailureAST T0 → SuccessAST (.star s e T0 TS)\n    | star_SS : SuccessAST T0 → SuccessAST TS → SuccessAST (.star s e T0 TS)\n    | notP : FailureAST T → SuccessAST (.notP s e T)\n\n  inductive PreAST.FailureAST : PreAST n b → Prop where\n    | any : s = e → Fin.IsMax e → FailureAST (.any s e x)\n    | terminal_mismatch : s.inbound_succ h = e → a ≠ x → FailureAST (.terminal s e a x)\n    | terminal_empty : s = e → Fin.IsMax e → FailureAST (.terminal s e a x)\n    | nonTerminal : FailureAST T → FailureAST (.nonTerminal s e A T)\n    | seq_F : FailureAST T1 → FailureAST (.seq s e T1 T2)\n    | seq_SF : SuccessAST T1 → FailureAST T2 → FailureAST (.seq s e T1 T2)\n    | prior : FailureAST T1 → FailureAST T2 → FailureAST (.prior s e T1 T2)\n    | notP : SuccessAST T → FailureAST (.notP s e T)\n\n  end\n\n  theorem PreAST.SuccessAST.ne_failure : ∀ {T : PreAST n b}, PreAST.IsValid T → SuccessAST T → ¬FailureAST T := by\n    intro T valid_T hs hf;\n    match T with\n      | .skip _ _ _ => cases hs;\n      | .ε _ _ => cases hf;\n      | .any _ _ _ => cases hs; cases hf; apply absurd (by assumption); apply Fin.ne_of_val_ne; apply Nat.ne_of_lt; apply Fin.lt_from_inbound_succ; assumption;\n      | .terminal s e a x => cases hs; cases hf; contradiction; apply absurd (by assumption); apply Fin.ne_of_val_ne; apply Nat.ne_of_lt; apply Fin.lt_from_inbound_succ; assumption;\n      | .nonTerminal s e A _ => match hs with\n        | .nonTerminal (T := Ts) st =>\n          {\n            match hf with\n            | .nonTerminal (T := Ts) ft => \n              {\n                apply absurd ft; apply ne_failure; cases valid_T; assumption; assumption;\n              }\n          }\n      | .seq s e _ _ => match hs with\n        | .seq (T1 := T1) (T2 := T2) st1 st2 =>\n          {\n            match hf with\n              | .seq_F (T1 := T1) (T2 := T2) ft1 =>\n                {\n                  apply absurd ft1; apply ne_failure; cases valid_T; assumption; assumption;\n                }\n              | .seq_SF (T1 := T1) (T2 := T2) _ ft2 =>\n                {\n                  apply absurd ft2; apply ne_failure; cases valid_T; assumption; assumption;\n                }\n          }\n      | .prior s e _ _ => match hf with\n        | .prior (T1 := T1) (T2 := T2) ft1 ft2 =>\n          {\n            match hs with\n              | .prior_S (T1 := T1) (T2 := T2) st1 =>\n                {\n                  apply absurd ft1; apply ne_failure; cases valid_T; assumption; assumption;\n                }\n              | .prior_FS (T1 := T1) (T2 := T2) _ st2 =>\n                {\n                  apply absurd ft2; apply ne_failure; cases valid_T; assumption; assumption;\n                }\n          }\n      | .star s e _ _ => cases hf;\n      | .notP s e _ => match hs with\n        | .notP (T := T) ft =>\n          {\n            match hf with\n              | .notP (T := T) st =>\n                {\n                  apply absurd ft; apply ne_failure; cases valid_T; assumption; assumption;\n                }\n          }\n\n  theorem PreAST.FailureAST.ne_success : ∀ {T : PreAST n b}, PreAST.IsValid T → FailureAST T → ¬SuccessAST T := by\n    intro T valid_T hf hs;\n    exact SuccessAST.ne_failure valid_T hs hf;\n\n  theorem PreAST.PreAST.star_cannot_fail : ∀ {T : PreAST n b}, StarPreAST T → ¬FailureAST T := by\n    intro T h_star h_fail;\n    cases h_star; cases h_fail;\n  \n  def PreAST.IsMeaningful (T : PreAST n b) : Prop := SuccessAST T ∨ FailureAST T\n\n  inductive PreAST.IsWellformed : PreAST n b → Prop where\n    | ε :           IsMeaningful (.ε (n := n) (b := b) s e)\n                    → IsWellformed (.ε (n := n) (b := b) s e)\n    | any :         IsMeaningful (.any (n := n) (b := b) s e x)\n                    → IsWellformed (.any (n := n) (b := b) s e x)\n    | terminal :    IsMeaningful (.terminal (n := n) (b := b) s e a x)\n                    → IsWellformed (.terminal (n := n) (b := b) s e a x)\n    | nonTerminal : ∀ {sub_T : PreAST n b},\n                    s = sub_T.start → e = sub_T.end \n                    → IsWellformed sub_T \n                    → IsWellformed (.nonTerminal s e A sub_T)\n    | seq_F :       ∀ {T1 T2 : PreAST n b},\n                    s = T1.start → T1.end = T2.start → e = T2.end → T2.start = T2.end\n                    → IsWellformed T1 → FailureAST T1 → SkipPreAST T2\n                    → IsWellformed (.seq s e T1 T2)\n    | seq_S :       ∀ {T1 T2 : PreAST n b},\n                    s = T1.start → T1.end = T2.start → e = T2.end \n                    → IsWellformed T1 → SuccessAST T1 → IsWellformed T2\n                    → IsWellformed (.seq s e T1 T2)\n    | prior_S :     ∀ {T1 T2 : PreAST n b},\n                    s = T1.start → s = T2.start → s = T2.end → e = T1.end \n                    → IsWellformed T1 → SuccessAST T1 → SkipPreAST T2\n                    → IsWellformed (.prior s e T1 T2)\n    | prior_F :     ∀ {T1 T2 : PreAST n b},\n                    s = T1.start → s = T2.start → e = T2.end \n                    → IsWellformed T1 → FailureAST T1 → IsWellformed T2\n                    → IsWellformed (.prior s e T1 T2)\n    | star_S :      ∀ {T0 TS : PreAST n b},\n                    s = T0.start → T0.end = TS.start → e = TS.end\n                    → IsWellformed T0 → SuccessAST T0 → IsWellformed TS\n                    → IsWellformed (.star s e T0 TS)\n    | star_F :      ∀ {T0 TS : PreAST n b},\n                    s = T0.start → T0.end = TS.start → TS.start = TS.end → s = e\n                    → IsWellformed T0 → FailureAST T0 → SkipPreAST TS\n                    → IsWellformed (.star s e T0 TS)\n    | notP :        ∀ {sub_T : PreAST n b},\n                    s = e → s = sub_T.start\n                    → IsWellformed sub_T \n                    → IsWellformed (.notP s e sub_T)\n\n  theorem PreAST.skip_is_not_wellformed : ∀ {T : PreAST n b}, SkipPreAST T → ¬IsWellformed T := by\n    intro T hskip hwf;\n    cases hskip; cases hwf;\n\n  theorem PreAST.valid_and_wellformed_implies_meaningful : ∀ {T : PreAST n b}, IsValid T → IsWellformed T → IsMeaningful T := by\n    intro T h_valid hwf;\n    match hwf with\n    | .ε _ => assumption;\n    | .any _ => assumption;\n    | .terminal _ => assumption;\n    | .nonTerminal _ _ hwfT =>\n      {\n        cases h_valid; cases valid_and_wellformed_implies_meaningful (by assumption) hwfT;\n        apply Or.inl; constructor <;> assumption;\n        apply Or.inr; constructor <;> assumption;\n      }\n    | .seq_F _ _ _ _ _ hf1 hskip2 =>\n      {\n        cases h_valid; apply Or.inr;\n        apply FailureAST.seq_F <;> assumption;\n      }\n    | .seq_S _ _ _ _ hs1 hwf2 =>\n      {\n        cases h_valid; cases valid_and_wellformed_implies_meaningful (by assumption) hwf2;\n        apply Or.inl; constructor <;> assumption;\n        apply Or.inr; apply FailureAST.seq_SF <;> assumption;\n      }\n    | .prior_S _ _ _ _ _ hs1 hskip2 =>\n      {\n        cases h_valid; apply Or.inl;\n        apply SuccessAST.prior_S <;> assumption;\n      }\n    | .prior_F _ _ _ _ hf1 hwf2 =>\n      {\n        cases h_valid; cases valid_and_wellformed_implies_meaningful (by assumption) hwf2;\n        apply Or.inl; apply SuccessAST.prior_FS <;> assumption;\n        apply Or.inr; constructor <;> assumption;\n      }\n    | .star_S (TS := TS) _ _ _ _ hs0 hwfS =>\n      {\n        match h_valid with\n        | PreAST.IsValid.star _ _ _ svs => \n          match svs with\n          | Or.inl hskip =>\n            {\n              apply absurd hwfS;\n              apply skip_is_not_wellformed; assumption;\n            }\n          | Or.inr hstar =>\n            {\n              apply Or.inl; apply SuccessAST.star_SS;\n              assumption;\n              match valid_and_wellformed_implies_meaningful (by assumption) hwfS with\n              | Or.inl _ => assumption\n              | Or.inr hf => cases hstar; cases hf;\n            }\n        \n      }\n    | .star_F _ _ _ _ _ hf0 hskipS =>\n      {\n        cases h_valid; apply Or.inl;\n        apply SuccessAST.star_F <;> assumption;\n      }\n    | .notP _ _ hwfT =>\n      {\n        cases h_valid; cases valid_and_wellformed_implies_meaningful (by assumption) hwfT;\n        apply Or.inr; constructor <;> assumption;\n        apply Or.inl; constructor <;> assumption;\n      }\n  \n  theorem PreAST.valid_and_wellformed_implies_start_le_end : ∀ {T : PreAST n b}, IsValid T → IsWellformed T → T.start ≤ T.end := by\n    intro T h_valid hwf;\n    match hwf with\n    | .ε hm =>\n      {\n        simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        match hm with\n        | Or.inl hs => cases hs; apply Nat.le_of_eq; apply Fin.val_eq_of_eq; assumption;\n      }\n    | .any hm =>\n      {\n        simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        match hm with\n        | Or.inl hs => cases hs; apply Nat.le_of_lt; apply Fin.lt_from_inbound_succ; assumption;\n        | Or.inr hf => cases hf; apply Nat.le_of_eq; apply Fin.val_eq_of_eq; assumption;\n      }\n    | .terminal hm =>\n      {\n        simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        match hm with\n        | Or.inl hs => cases hs; apply Nat.le_of_lt; apply Fin.lt_from_inbound_succ; assumption;\n        | Or.inr hf => cases hf; apply Nat.le_of_lt; apply Fin.lt_from_inbound_succ; assumption; apply Nat.le_of_eq; apply Fin.val_eq_of_eq; assumption;\n      }\n    | .nonTerminal hssT heeT hwfT =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hssT, heeT];\n        apply valid_and_wellformed_implies_start_le_end <;> assumption;\n      }\n    | .seq_F hss1 he1s2 hee2 hs2e2 hwf1 _ hskip2 =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hss1, hee2, ←hs2e2, ←he1s2]\n        apply valid_and_wellformed_implies_start_le_end <;> assumption;\n      }\n    | .seq_S hss1 he1s2 hee2 hwf1 _ hwf2 =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hss1, hee2];\n        apply Nat.le_trans;\n        apply valid_and_wellformed_implies_start_le_end (by assumption) hwf1;\n        rw [he1s2];\n        apply valid_and_wellformed_implies_start_le_end (by assumption) hwf2;\n      }\n    | .prior_S hss1 _ _ hee1 hwf1 _ hskip2 =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hss1, hee1];\n        apply valid_and_wellformed_implies_start_le_end (by assumption) hwf1;\n      }\n    | .prior_F _ hss2 hee2 _ _ hwf2 =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hss2, hee2];\n        apply valid_and_wellformed_implies_start_le_end (by assumption) hwf2;\n      }\n    | .star_S (TS := TS) hss0 he0sS heeS hwf0 _ hwfS =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hss0, heeS];\n        apply Nat.le_trans;\n        apply valid_and_wellformed_implies_start_le_end (by assumption) hwf0;\n        rw [he0sS];\n        apply valid_and_wellformed_implies_start_le_end (by assumption) hwfS;\n      }\n    | .star_F _ _ _ hse _ _ hskipS =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hse];\n        apply Nat.le_refl;\n      }\n    | .notP hse _ hwfT =>\n      {\n        cases h_valid; simp [PreAST.start, PreAST.end, PreAST.start, PreAST.end];\n        rw [hse];\n        apply Nat.le_refl;\n      }\n\n  structure AST (n : Nat) (b : Nat) where\n    T : PreAST n b\n    valid_T : PreAST.IsValid T\n    wf_T : PreAST.IsWellformed T\n  \n  def AST.size (T : AST n b) : Nat := T.T.size\n  def AST.start (T : AST n b) : Fin b := T.T.start\n  def AST.end (T : AST n b) : Fin b := T.T.end\n\n  theorem AST.meaningful (T : AST n b) : PreAST.IsMeaningful T.T := PreAST.valid_and_wellformed_implies_meaningful T.valid_T T.wf_T\n  theorem AST.start_le_end (T : AST n b) : T.start ≤ T.end := by\n    rw [AST.start, AST.end];\n    apply PreAST.valid_and_wellformed_implies_start_le_end T.valid_T T.wf_T;\n\nend AST", "meta": {"author": "lituzou", "repo": "ExtParser", "sha": "7ddd0f3c16dd2bbf6ada6aa9fd84f618733cf4b5", "save_path": "github-repos/lean/lituzou-ExtParser", "path": "github-repos/lean/lituzou-ExtParser/ExtParser-7ddd0f3c16dd2bbf6ada6aa9fd84f618733cf4b5/ExtParser/AST.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.49908370639216176}}
{"text": "import Mathlib.GroupTheory.Submonoid.Basic\nimport Mathlib.Algebra.Divisibility.Basic\nimport Mathlib.GroupTheory.Submonoid.Membership\nimport Mathlib.Algebra.Associated\n\nnamespace Submonoid\n\nvariable {M N : Type _} [CommMonoid M] [CommMonoid N]\n\ndef Absorbing (S : Submonoid M) : Prop :=\n  ∀ x y, x * y ∈ S → ∃ z ∈ S, Associated x z ∧ ∃ z ∈ S, Associated y z\n\nsection Basic\n\ntheorem absorbing_def {S : Submonoid M} :\n    Absorbing S ↔ ∀ x y, x * y ∈ S → ∃ z ∈ S, Associated x z ∧ ∃ z ∈ S, Associated y z :=\n  Iff.rfl\n\nvariable (M)\n\nvariable (N)\n\ntheorem top_absorbing : (⊤ : Submonoid M).Absorbing := fun x y _ =>\n  ⟨x, Submonoid.mem_top _, Associated.refl _, y, Submonoid.mem_top _, Associated.refl _⟩\n\ntheorem bot_absorbing : (⊥ : Submonoid M).Absorbing := fun x y hxy =>\n  ⟨1, (⊥ : Submonoid M).one_mem, associated_one_of_mul_eq_one _ (Submonoid.mem_bot.1 hxy), 1,\n    (⊥ : Submonoid M).one_mem,\n    associated_one_of_mul_eq_one _ (Submonoid.mem_bot.1 (by rwa [mul_comm] at hxy))⟩\n\ntheorem IsUnit.submonoid_absorbing : (IsUnit.submonoid M).Absorbing := fun x y hxy =>\n  ⟨x, isUnit_of_mul_isUnit_left hxy, Associated.refl _, y, isUnit_of_mul_isUnit_right hxy,\n    Associated.refl _⟩\n\ntheorem Associated.prod (x z : M × N) : Associated x z ↔ Associated x.1 z.1 ∧ Associated x.2 z.2 :=\n  by\n  refine'\n    ⟨_, fun ⟨⟨u₁, hu₁⟩, ⟨u₂, hu₂⟩⟩ =>\n      ⟨MulEquiv.prodUnits.invFun (u₁, u₂), Prod.eq_iff_fst_eq_snd_eq.2 ⟨hu₁, hu₂⟩⟩⟩\n  rintro ⟨u, hu⟩\n  cases' u.isUnit.exists_right_inv with b hb\n  rw [Prod.mul_def, Prod.mk_eq_one] at hb\n  rw [← hu, Prod.fst_mul, Prod.snd_mul]\n  refine'\n    ⟨(associated_mul_isUnit_right_iff (isUnit_of_mul_eq_one _ _ hb.1)).2 (Associated.refl _),\n      (associated_mul_isUnit_right_iff (isUnit_of_mul_eq_one _ _ hb.2)).2 (Associated.refl _)⟩\n\ntheorem Submonoid.prod_absorbing (s : Submonoid M) (t : Submonoid N) :\n    (s.prod t).Absorbing ↔ Absorbing s ∧ Absorbing t :=\n  by\n  refine' ⟨fun h => ⟨fun x y hxy => _, fun x y hxy => _⟩, _⟩\n  · specialize h (x, 1) (y, 1)\n    rw [Prod.mk_one_mul_mk_one] at h\n    rcases h (Submonoid.mem_prod.2 ⟨hxy, t.one_mem⟩) with ⟨a, ha, ha₂, ⟨b, hb, hb₂⟩⟩\n    exact\n      ⟨a.1, (Submonoid.mem_prod.1 ha).1, ((Associated.prod _ _ _ _).1 ha₂).1, b.1,\n        (Submonoid.mem_prod.1 hb).1, ((Associated.prod _ _ _ _).1 hb₂).1⟩\n  · specialize h (1, x) (1, y)\n    rw [Prod.one_mk_mul_one_mk] at h\n    rcases h (Submonoid.mem_prod.2 ⟨s.one_mem, hxy⟩) with ⟨a, ha, ha₂, ⟨b, hb, hb₂⟩⟩\n    exact\n      ⟨a.2, (Submonoid.mem_prod.1 ha).2, ((Associated.prod _ _ _ _).1 ha₂).2, b.2,\n        (Submonoid.mem_prod.1 hb).2, ((Associated.prod _ _ _ _).1 hb₂).2⟩\n  · rintro ⟨hs, ht⟩ x y hxy\n    rcases hs x.1 y.1 hxy.1 with ⟨z, hz, hz₂, ⟨z', hz', hz'₂⟩⟩\n    rcases ht x.2 y.2 hxy.2 with ⟨w, hw, hw₂, ⟨w', hw', hw'₂⟩⟩\n    exact\n      ⟨(z, w), Submonoid.mem_prod.2 ⟨hz, hw⟩, (Associated.prod _ _ _ _).2 ⟨hz₂, hw₂⟩, (z', w'),\n        Submonoid.mem_prod.2 ⟨hz', hw'⟩, (Associated.prod _ _ _ _).2 ⟨hz'₂, hw'₂⟩⟩\n\nend Basic\n\nsection CommMonoid\n\ntheorem absorbing_iff_of_comm {S : Submonoid M} :\n    Absorbing S ↔ ∀ x y, x * y ∈ S → ∃ z ∈ S, Associated x z :=\n  by\n  refine' ⟨fun hS x y hxy => _, fun h x y hxy => _⟩\n  · rcases hS x y hxy with ⟨z, hz, hz₂, _⟩\n    exact ⟨z, hz, hz₂⟩\n  · obtain ⟨z, hz, hz₂⟩ := h x y hxy\n    refine' ⟨z, hz, hz₂, _⟩\n    rw [mul_comm] at hxy\n    exact h y x hxy\n\n\nend CommMonoid\n\nend Submonoid\n", "meta": {"author": "riccardobrasca", "repo": "kaplanski4", "sha": "e59ce97eca3aa2b4662d67b3b7bda7493d51cb39", "save_path": "github-repos/lean/riccardobrasca-kaplanski4", "path": "github-repos/lean/riccardobrasca-kaplanski4/kaplanski4-e59ce97eca3aa2b4662d67b3b7bda7493d51cb39/Kaplanski4/Absorbing.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311856832191, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.499083694630999}}
{"text": "/-\nCopyright (c) 2021 Ivan Sadofschi Costa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Ivan Sadofschi Costa.\n-/\nimport data.mv_polynomial.basic\nimport data.mv_polynomial.comm_ring\nimport data.mv_polynomial.equiv\nimport data.mv_polynomial.supported\nimport data.polynomial.basic\nimport data.polynomial.ring_division\nimport algebra.algebra.basic\n--import pr.fin_succ_equiv\n\n/-\n# Lemma 2.1\n\n## Main results\n\n- `lemma_2_1`: Let F be a field and f ∈ F[x₀,…,xₙ]. Suppose that for 0 ≤ i ≤ n,\n  the degree of f in xᵢ is at most tᵢ. Let S₀,…,Sₙ ⊆ F be subsets such that tᵢ < |Sᵢ|.\n  Suppose that f(s₀,…,sₙ) = 0 for each (s₀,…,sₙ) ∈ S₀ × … × Sₙ. Then f = 0.\n\n  This is Lemma 2.1 in Alon's paper \"Combinatorial Nullstellensatz\".\n-/\n\nopen_locale big_operators\n\nlocal attribute [instance] classical.prop_decidable\n\nnamespace mv_polynomial\n\nprivate lemma lemma_2_1_fin_n { n : ℕ } {R : Type*} [comm_ring R] [is_domain R]\n  (f : mv_polynomial (fin n) R)\n  (S : fin n → finset R)\n  (hS : ∀ i : fin n, degree_of i f < (S i).card) \n  (hz : ∀ s : fin n → R, (∀ i : fin n, s i ∈ S i ) → eval s f = 0) :\n  f = 0 :=\nbegin\n  induction n with n hn,\n  simp only [forall_const] at hz,\n  apply (ring_equiv.map_eq_zero_iff (is_empty_ring_equiv R (fin 0))).1,\n  simp only [is_empty_ring_equiv_apply],\n  simpa using (hz fin.is_empty.elim),\n  apply (ring_equiv.map_eq_zero_iff ↑(fin_succ_equiv R n)).1 ∘ polynomial.ext_iff.2,\n  intro i,\n  rw ← polynomial.coeff_zero i,\n  apply hn (polynomial.coeff ((fin_succ_equiv R n) f) i),\n  exact λ j, lt_of_le_of_lt (degree_of_coeff_fin_succ_equiv f j i) (hS j.succ),\n  intros s hs,\n  rw [ ← coeff_eval_eq_eval_coeff],\n  suffices h : polynomial.map (eval s) (fin_succ_equiv R n f) = 0,\n  { rw h,\n    simp },\n  by_contradiction c1,\n  suffices h1 : (S 0).val ⊆ (polynomial.map (eval (λ (i : fin n), s i)) (fin_succ_equiv R n f)).roots, \n  { simpa using lt_of_le_of_lt ((polynomial.card_le_degree_of_subset_roots h1).trans _) (hS 0),\n    rw ← nat_degree_fin_succ_equiv f,\n    exact polynomial.nat_degree_le_nat_degree (polynomial.degree_mono (polynomial.support_map_subset _ _)),},\n  suffices h0 : ∀ s' : fin n → R, (∀ i : fin n, s' i ∈ S i.succ) → ∀ y : R, y ∈ S 0 →  \n    polynomial.eval y (polynomial.map (eval s') ((fin_succ_equiv R n) f)) = 0,\n  { rw multiset.subset_iff,\n    intros x hx,\n    rw polynomial.mem_roots c1,\n    simpa using h0 _ hs x hx },  \n  intros s' hs' y hy,\n  rw [← eval_eq_eval_mv_eval', hz],\n  intro i,\n  by_cases c : i ≠ 0,\n  { rw [ ←fin.succ_pred i c, fin.cons_succ],\n    exact hs' (fin.pred i c) },\n  { rwa [not_not.1 c, fin.cons_zero] },\nend\n\n/- Lemma 2.1 in Alon's \"Combinatorial Nullstellensatz\" paper. -/\nlemma lemma_2_1 {R σ : Type*} [comm_ring R] [is_domain R] [fintype σ] (f : mv_polynomial σ R)\n  (S : σ → finset R) (hS : ∀ i : σ, degree_of i f < (S i).card) \n  (hz : ∀ s : σ → R, (∀ i : σ, s i ∈ S i ) → eval s f = 0) : f = 0 :=\nbegin\n  rcases exists_fin_rename f with ⟨n, ⟨ψ,⟨hψ,⟨g,hg⟩⟩⟩⟩,\n  rw hg,\n  rw hg at hS,\n  rw hg at hz,\n  clear hg f,\n  have h_S_nonempty : ∀ i, ∃ x, x ∈ S i,\n  { intro i,\n    apply multiset.card_pos_iff_exists_mem.1,\n    convert lt_of_le_of_lt (zero_le _) (hS i), },\n  have hs0 : ∃ s0 : σ → R, (∀ i : σ, s0 i ∈ S i ) := by apply classical.skolem.1 h_S_nonempty,\n  cases hs0 with s0 hs0,\n  by_cases c : nonempty (fin n),\n  { have hS' : ∀ i : (fin n), degree_of i g < ((S ∘ ψ) i).card,\n    { intro i,\n      convert hS (ψ i),\n      rw degree_of_rename_of_injective hψ i },\n    suffices hz' : ∀ s : (fin n) → R, (∀ i : fin n, s i ∈ (S ∘ ψ) i ) → eval s g = 0,\n      by simp [lemma_2_1_fin_n g (S ∘ ψ ) hS' hz'],\n    intros s' h,\n    let φ := @function.inv_fun (fin n) σ c ψ,\n    have φ_left_inv := @function.left_inverse_inv_fun (fin n) σ c ψ hψ,\n    let s : σ → R := λ i, if h : ∃ j : fin n, ψ j = i then (s' ∘ φ) i else s0 i,\n    have hs' : s' = s ∘ ψ,\n    { ext,\n      have hx  : ∃ j, ψ j = ψ x := ⟨x, by refl⟩,\n      simp only [function.comp_app, s, hx, dif_pos, φ, φ_left_inv x], },\n    suffices hs : ∀ (i : σ), s i ∈ S i,\n    { rw hs',\n      convert hz s hs, \n      simp only [eval, eval₂_hom_rename] },\n    intro i,\n    by_cases ch : ∃ (j : fin n), ψ j = i,\n    { simp only [s, dite_eq_ite, function.comp_app, if_pos, ch, φ ],\n      cases ch with j hj,\n      simpa [← hj, φ_left_inv j] using h j},\n    { simpa only [s, dite_eq_ite, if_neg, ch, not_false_iff] using hs0 i } },\n  { simp only [not_nonempty_iff] at c,\n    cases @C_surjective R _ (fin n) c g with a ha,\n    simp only [←ha, rename_C] at hz,\n    have t := hz s0 hs0,\n    rw [eval_C] at t,\n    simp [←ha, rename_C, t] },\nend\n\nend mv_polynomial\n", "meta": {"author": "isadofschi", "repo": "combinatorial_nullstellensatz", "sha": "b5f2e75d51c3c8b9345d698a3ff4964c95bb5028", "save_path": "github-repos/lean/isadofschi-combinatorial_nullstellensatz", "path": "github-repos/lean/isadofschi-combinatorial_nullstellensatz/combinatorial_nullstellensatz-b5f2e75d51c3c8b9345d698a3ff4964c95bb5028/src/lemma_2_1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.499077651483062}}
{"text": "/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Ashvni Narayanan\n-/\nimport field_theory.ratfunc\nimport ring_theory.algebraic\nimport ring_theory.dedekind_domain\nimport ring_theory.integrally_closed\n\n/-!\n# Function fields\n\nThis file defines a function field and the ring of integers corresponding to it.\n\n## Main definitions\n - `function_field Fq F` states that `F` is a function field over the (finite) field `Fq`,\n   i.e. it is a finite extension of the field of rational functions in one variable over `Fq`.\n - `function_field.ring_of_integers` defines the ring of integers corresponding to a function field\n    as the integral closure of `polynomial Fq` in the function field.\n\n## Implementation notes\nThe definitions that involve a field of fractions choose a canonical field of fractions,\nbut are independent of that choice. We also omit assumptions like `finite Fq` or\n`is_scalar_tower (polynomial Fq) (fraction_ring (polynomial Fq)) F` in definitions,\nadding them back in lemmas when they are needed.\n\n## References\n* [D. Marcus, *Number Fields*][marcus1977number]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n* [P. Samuel, *Algebraic Theory of Numbers*][samuel1970algebraic]\n\n## Tags\nfunction field, ring of integers\n-/\n\nnoncomputable theory\n\nvariables (Fq F : Type) [field Fq] [field F]\n\n/-- `F` is a function field over the finite field `Fq` if it is a finite\nextension of the field of rational functions in one variable over `Fq`.\n\nNote that `F` can be a function field over multiple, non-isomorphic, `Fq`.\n-/\nabbreviation function_field [algebra (ratfunc Fq) F] : Prop :=\nfinite_dimensional (ratfunc Fq) F\n\n/-- `F` is a function field over `Fq` iff it is a finite extension of `Fq(t)`. -/\nprotected lemma function_field_iff (Fqt : Type*) [field Fqt]\n  [algebra (polynomial Fq) Fqt] [is_fraction_ring (polynomial Fq) Fqt]\n  [algebra (ratfunc Fq) F] [algebra Fqt F]\n  [algebra (polynomial Fq) F] [is_scalar_tower (polynomial Fq) Fqt F]\n  [is_scalar_tower (polynomial Fq) (ratfunc Fq) F] :\n  function_field Fq F ↔ finite_dimensional Fqt F :=\nbegin\n  let e := is_localization.alg_equiv (non_zero_divisors (polynomial Fq)) (ratfunc Fq) Fqt,\n  have : ∀ c (x : F), e c • x = c • x,\n  { intros c x,\n    rw [algebra.smul_def, algebra.smul_def],\n    congr,\n    refine congr_fun _ c,\n    refine is_localization.ext (non_zero_divisors (polynomial Fq)) _ _ _ _ _ _ _;\n      intros; simp only [alg_equiv.map_one, ring_hom.map_one, alg_equiv.map_mul, ring_hom.map_mul,\n                         alg_equiv.commutes, ← is_scalar_tower.algebra_map_apply], },\n  split; intro h; resetI,\n  { let b := finite_dimensional.fin_basis (ratfunc Fq) F,\n    exact finite_dimensional.of_fintype_basis (b.map_coeffs e this) },\n  { let b := finite_dimensional.fin_basis Fqt F,\n    refine finite_dimensional.of_fintype_basis (b.map_coeffs e.symm _),\n    intros c x, convert (this (e.symm c) x).symm, simp only [e.apply_symm_apply] },\nend\n\nnamespace function_field\n\n/-- The function field analogue of `number_field.ring_of_integers`:\n`function_field.ring_of_integers Fq Fqt F` is the integral closure of `Fq[t]` in `F`.\n\nWe don't actually assume `F` is a function field over `Fq` in the definition,\nonly when proving its properties.\n-/\ndef ring_of_integers [algebra (polynomial Fq) F] := integral_closure (polynomial Fq) F\n\nnamespace ring_of_integers\n\nvariables [algebra (polynomial Fq) F]\n\ninstance : is_domain (ring_of_integers Fq F) :=\n(ring_of_integers Fq F).is_domain\n\ninstance : is_integral_closure (ring_of_integers Fq F) (polynomial Fq) F :=\nintegral_closure.is_integral_closure _ _\n\nvariables [algebra (ratfunc Fq) F] [function_field Fq F]\nvariables [is_scalar_tower (polynomial Fq) (ratfunc Fq) F]\n\ninstance : is_fraction_ring (ring_of_integers Fq F) F :=\nintegral_closure.is_fraction_ring_of_finite_extension (ratfunc Fq) F\n\ninstance : is_integrally_closed (ring_of_integers Fq F) :=\nintegral_closure.is_integrally_closed_of_finite_extension (ratfunc Fq)\n\ninstance [is_separable (ratfunc Fq) F] :\n  is_dedekind_domain (ring_of_integers Fq F) :=\nis_integral_closure.is_dedekind_domain (polynomial Fq) (ratfunc Fq) F _\n\nend ring_of_integers\n\nend function_field\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/number_theory/function_field.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.6688802537704064, "lm_q1q2_score": 0.4990776465580952}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Robert Y. Lewis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.witt_vector.truncated\nimport Mathlib.ring_theory.witt_vector.identities\nimport Mathlib.data.padics.ring_homs\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n\n# Comparison isomorphism between `witt_vector p (zmod p)` and `ℤ_[p]`\n\nWe construct a ring isomorphism between `witt_vector p (zmod p)` and `ℤ_[p]`.\nThis isomorphism follows from the fact that both satisfy the universal property\nof the inverse limit of `zmod (p^n)`.\n\n## Main declarations\n\n* `witt_vector.to_zmod_pow`: a family of compatible ring homs `𝕎 (zmod p) → zmod (p^k)`\n* `witt_vector.equiv`: the isomorphism\n\n-/\n\nnamespace truncated_witt_vector\n\n\ntheorem eq_of_le_of_cast_pow_eq_zero (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1)\n    [comm_ring R] [char_p R p] (i : ℕ) (hin : i ≤ n) (hpi : ↑p ^ i = 0) : i = n :=\n  sorry\n\ntheorem card_zmod (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) :\n    fintype.card (truncated_witt_vector p n (zmod p)) = p ^ n :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (fintype.card (truncated_witt_vector p n (zmod p)) = p ^ n)) (card p n)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (fintype.card (zmod p) ^ n = p ^ n)) (zmod.card p)))\n      (Eq.refl (p ^ n)))\n\ntheorem char_p_zmod (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) :\n    char_p (truncated_witt_vector p n (zmod p)) (p ^ n) :=\n  char_p_of_prime_pow_injective (truncated_witt_vector p n (zmod p)) p n (card_zmod p n)\n    (eq_of_le_of_cast_pow_eq_zero p n (zmod p))\n\n/--\nThe unique isomorphism between `zmod p^n` and `truncated_witt_vector p n (zmod p)`.\n\nThis isomorphism exists, because `truncated_witt_vector p n (zmod p)` is a finite ring\nwith characteristic and cardinality `p^n`.\n-/\ndef zmod_equiv_trunc (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) :\n    zmod (p ^ n) ≃+* truncated_witt_vector p n (zmod p) :=\n  zmod.ring_equiv (truncated_witt_vector p n (zmod p)) (card_zmod p n)\n\ntheorem zmod_equiv_trunc_apply (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {x : zmod (p ^ n)} :\n    coe_fn (zmod_equiv_trunc p n) x =\n        coe_fn (zmod.cast_hom (dvd_refl (p ^ n)) (truncated_witt_vector p n (zmod p))) x :=\n  rfl\n\n/--\nThe following diagram commutes:\n```text\n          zmod (p^n) ----------------------------> zmod (p^m)\n            |                                        |\n            |                                        |\n            v                                        v\ntruncated_witt_vector p n (zmod p) ----> truncated_witt_vector p m (zmod p)\n```\nHere the vertical arrows are `truncated_witt_vector.zmod_equiv_trunc`,\nthe horizontal arrow at the top is `zmod.cast_hom`,\nand the horizontal arrow at the bottom is `truncated_witt_vector.truncate`.\n-/\ntheorem commutes (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m) :\n    ring_hom.comp (truncate hm) (ring_equiv.to_ring_hom (zmod_equiv_trunc p m)) =\n        ring_hom.comp (ring_equiv.to_ring_hom (zmod_equiv_trunc p n))\n          (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n))) :=\n  ring_hom.ext_zmod (ring_hom.comp (truncate hm) (ring_equiv.to_ring_hom (zmod_equiv_trunc p m)))\n    (ring_hom.comp (ring_equiv.to_ring_hom (zmod_equiv_trunc p n))\n      (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n))))\n\ntheorem commutes' (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m)\n    (x : zmod (p ^ m)) :\n    coe_fn (truncate hm) (coe_fn (zmod_equiv_trunc p m) x) =\n        coe_fn (zmod_equiv_trunc p n)\n          (coe_fn (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n))) x) :=\n  sorry\n\ntheorem commutes_symm' (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m)\n    (x : truncated_witt_vector p m (zmod p)) :\n    coe_fn (ring_equiv.symm (zmod_equiv_trunc p n)) (coe_fn (truncate hm) x) =\n        coe_fn (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n)))\n          (coe_fn (ring_equiv.symm (zmod_equiv_trunc p m)) x) :=\n  sorry\n\n/--\nThe following diagram commutes:\n```text\ntruncated_witt_vector p n (zmod p) ----> truncated_witt_vector p m (zmod p)\n            |                                        |\n            |                                        |\n            v                                        v\n          zmod (p^n) ----------------------------> zmod (p^m)\n```\nHere the vertical arrows are `(truncated_witt_vector.zmod_equiv_trunc p _).symm`,\nthe horizontal arrow at the top is `zmod.cast_hom`,\nand the horizontal arrow at the bottom is `truncated_witt_vector.truncate`.\n-/\ntheorem commutes_symm (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m) :\n    ring_hom.comp (ring_equiv.to_ring_hom (ring_equiv.symm (zmod_equiv_trunc p n))) (truncate hm) =\n        ring_hom.comp (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n)))\n          (ring_equiv.to_ring_hom (ring_equiv.symm (zmod_equiv_trunc p m))) :=\n  ring_hom.ext fun (x : truncated_witt_vector p m (zmod p)) => commutes_symm' p n hm x\n\nend truncated_witt_vector\n\n\nnamespace witt_vector\n\n\n/--\n`to_zmod_pow` is a family of compatible ring homs. We get this family by composing\n`truncated_witt_vector.zmod_equiv_trunc` (in right-to-left direction)\nwith `witt_vector.truncate`.\n-/\ndef to_zmod_pow (p : ℕ) [hp : fact (nat.prime p)] (k : ℕ) :\n    witt_vector p (zmod p) →+* zmod (p ^ k) :=\n  ring_hom.comp\n    (ring_equiv.to_ring_hom (ring_equiv.symm (truncated_witt_vector.zmod_equiv_trunc p k)))\n    (truncate k)\n\ntheorem to_zmod_pow_compat (p : ℕ) [hp : fact (nat.prime p)] (m : ℕ) (n : ℕ) (h : m ≤ n) :\n    ring_hom.comp (zmod.cast_hom (pow_dvd_pow p h) (zmod (p ^ m))) (to_zmod_pow p n) =\n        to_zmod_pow p m :=\n  sorry\n\n/--\n`to_padic_int` lifts `to_zmod_pow : 𝕎 (zmod p) →+* zmod (p ^ k)` to a ring hom to `ℤ_[p]`\nusing `padic_int.lift`, the universal property of `ℤ_[p]`.\n-/\ndef to_padic_int (p : ℕ) [hp : fact (nat.prime p)] : witt_vector p (zmod p) →+* padic_int p :=\n  padic_int.lift (to_zmod_pow_compat p)\n\ntheorem zmod_equiv_trunc_compat (p : ℕ) [hp : fact (nat.prime p)] (k₁ : ℕ) (k₂ : ℕ) (hk : k₁ ≤ k₂) :\n    ring_hom.comp (truncated_witt_vector.truncate hk)\n          (ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k₂))\n            (padic_int.to_zmod_pow k₂)) =\n        ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k₁))\n          (padic_int.to_zmod_pow k₁) :=\n  sorry\n\n/--\n`from_padic_int` uses `witt_vector.lift` to lift `truncated_witt_vector.zmod_equiv_trunc`\ncomposed with `padic_int.to_zmod_pow` to a ring hom `ℤ_[p] →+* 𝕎 (zmod p)`.\n-/\ndef from_padic_int (p : ℕ) [hp : fact (nat.prime p)] : padic_int p →+* witt_vector p (zmod p) :=\n  lift\n    (fun (k : ℕ) =>\n      ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k))\n        (padic_int.to_zmod_pow k))\n    (zmod_equiv_trunc_compat p)\n\ntheorem to_padic_int_comp_from_padic_int (p : ℕ) [hp : fact (nat.prime p)] :\n    ring_hom.comp (to_padic_int p) (from_padic_int p) = ring_hom.id (padic_int p) :=\n  sorry\n\ntheorem to_padic_int_comp_from_padic_int_ext (p : ℕ) [hp : fact (nat.prime p)] (x : padic_int p) :\n    coe_fn (ring_hom.comp (to_padic_int p) (from_padic_int p)) x =\n        coe_fn (ring_hom.id (padic_int p)) x :=\n  sorry\n\ntheorem from_padic_int_comp_to_padic_int (p : ℕ) [hp : fact (nat.prime p)] :\n    ring_hom.comp (from_padic_int p) (to_padic_int p) = ring_hom.id (witt_vector p (zmod p)) :=\n  sorry\n\ntheorem from_padic_int_comp_to_padic_int_ext (p : ℕ) [hp : fact (nat.prime p)]\n    (x : witt_vector p (zmod p)) :\n    coe_fn (ring_hom.comp (from_padic_int p) (to_padic_int p)) x =\n        coe_fn (ring_hom.id (witt_vector p (zmod p))) x :=\n  sorry\n\n/--\nThe ring of Witt vectors over `zmod p` is isomorphic to the ring of `p`-adic integers. This\nequivalence is witnessed by `witt_vector.to_padic_int` with inverse `witt_vector.from_padic_int`.\n-/\ndef equiv (p : ℕ) [hp : fact (nat.prime p)] : witt_vector p (zmod p) ≃+* padic_int p :=\n  ring_equiv.mk (⇑(to_padic_int p)) (⇑(from_padic_int p)) (from_padic_int_comp_to_padic_int_ext p)\n    (to_padic_int_comp_from_padic_int_ext p) sorry sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/compare_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7461389817407017, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4990776413046463}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.module.linear_map\nimport Mathlib.algebra.opposites\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# Module operations on `Mᵒᵖ`\n\nThis file contains definitions that could not be placed into `algebra.opposites` due to import\ncycles.\n-/\n\nnamespace opposite\n\n\n/-- `opposite.distrib_mul_action` extends to a `semimodule` -/\nprotected instance semimodule (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : semimodule R (Mᵒᵖ) :=\n  semimodule.mk sorry sorry\n\n/-- The function `op` is a linear equivalence. -/\ndef op_linear_equiv (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] :\n    linear_equiv R M (Mᵒᵖ) :=\n  linear_equiv.mk (add_equiv.to_fun op_add_equiv) sorry sorry (add_equiv.inv_fun op_add_equiv) sorry\n    sorry\n\n@[simp] theorem coe_op_linear_equiv (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : ⇑(op_linear_equiv R) = op :=\n  rfl\n\n@[simp] theorem coe_op_linear_equiv_symm (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : ⇑(linear_equiv.symm (op_linear_equiv R)) = unop :=\n  rfl\n\n@[simp] theorem coe_op_linear_equiv_to_linear_map (R : Type u) {M : Type v} [semiring R]\n    [add_comm_monoid M] [semimodule R M] : ⇑(linear_equiv.to_linear_map (op_linear_equiv R)) = op :=\n  rfl\n\n@[simp] theorem coe_op_linear_equiv_symm_to_linear_map (R : Type u) {M : Type v} [semiring R]\n    [add_comm_monoid M] [semimodule R M] :\n    ⇑(linear_equiv.to_linear_map (linear_equiv.symm (op_linear_equiv R))) = unop :=\n  rfl\n\n@[simp] theorem op_linear_equiv_to_add_equiv (R : Type u) {M : Type v} [semiring R]\n    [add_comm_monoid M] [semimodule R M] :\n    linear_equiv.to_add_equiv (op_linear_equiv R) = op_add_equiv :=\n  rfl\n\n@[simp] theorem op_linear_equiv_symm_to_add_equiv (R : Type u) {M : Type v} [semiring R]\n    [add_comm_monoid M] [semimodule R M] :\n    linear_equiv.to_add_equiv (linear_equiv.symm (op_linear_equiv R)) =\n        add_equiv.symm op_add_equiv :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/module/opposites_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6688802537704064, "lm_q1q2_score": 0.49907763900640434}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport logic.function.basic\nimport tactic.ext\nimport tactic.lint\nimport tactic.simps\n\n/-!\n# Subtypes\n\nThis file provides basic API for subtypes, which are defined in core.\n\nA subtype is a type made from restricting another type, say `α`, to its elements that satisfy some\npredicate, say `p : α → Prop`. Specifically, it is the type of pairs `⟨val, property⟩` where\n`val : α` and `property : p val`. It is denoted `subtype p` and notation `{val : α // p val}` is\navailable.\n\nA subtype has a natural coercion to the parent type, by coercing `⟨val, property⟩` to `val`. As\nsuch, subtypes can be thought of as bundled sets, the difference being that elements of a set are\nstill of type `α` while elements of a subtype aren't.\n-/\n\nopen function\n\nnamespace subtype\nvariables {α β γ : Sort*} {p q : α → Prop}\n\n/-- See Note [custom simps projection] -/\ndef simps.coe (x : subtype p) : α := x\n\ninitialize_simps_projections subtype (val → coe)\n\n/-- A version of `x.property` or `x.2` where `p` is syntactically applied to the coercion of `x`\n  instead of `x.1`. A similar result is `subtype.mem` in `data.set.basic`. -/\nlemma prop (x : subtype p) : p x := x.2\n\n@[simp] lemma val_eq_coe {x : subtype p} : x.1 = ↑x := rfl\n\n@[simp] protected theorem «forall» {q : {a // p a} → Prop} :\n  (∀ x, q x) ↔ (∀ a b, q ⟨a, b⟩) :=\n⟨assume h a b, h ⟨a, b⟩, assume h ⟨a, b⟩, h a b⟩\n\n/-- An alternative version of `subtype.forall`. This one is useful if Lean cannot figure out `q`\n  when using `subtype.forall` from right to left. -/\nprotected theorem forall' {q : ∀ x, p x → Prop} :\n  (∀ x h, q x h) ↔ (∀ x : {a // p a}, q x x.2) :=\n(@subtype.forall _ _ (λ x, q x.1 x.2)).symm\n\n@[simp] protected theorem «exists» {q : {a // p a} → Prop} :\n  (∃ x, q x) ↔ (∃ a b, q ⟨a, b⟩) :=\n⟨assume ⟨⟨a, b⟩, h⟩, ⟨a, b, h⟩, assume ⟨a, b, h⟩, ⟨⟨a, b⟩, h⟩⟩\n\n/-- An alternative version of `subtype.exists`. This one is useful if Lean cannot figure out `q`\n  when using `subtype.exists` from right to left. -/\nprotected theorem exists' {q : ∀x, p x → Prop} :\n  (∃ x h, q x h) ↔ (∃ x : {a // p a}, q x x.2) :=\n(@subtype.exists _ _ (λ x, q x.1 x.2)).symm\n\n@[ext] protected lemma ext : ∀ {a1 a2 : {x // p x}}, (a1 : α) = (a2 : α) → a1 = a2\n| ⟨x, h1⟩ ⟨.(x), h2⟩ rfl := rfl\n\nlemma ext_iff {a1 a2 : {x // p x}} : a1 = a2 ↔ (a1 : α) = (a2 : α) :=\n⟨congr_arg _, subtype.ext⟩\n\nlemma heq_iff_coe_eq (h : ∀ x, p x ↔ q x) {a1 : {x // p x}} {a2 : {x // q x}} :\n  a1 == a2 ↔ (a1 : α) = (a2 : α) :=\neq.rec (λ a2', heq_iff_eq.trans ext_iff) (funext $ λ x, propext (h x)) a2\n\nlemma heq_iff_coe_heq {α β : Sort*} {p : α → Prop} {q : β → Prop} {a : {x // p x}}\n  {b : {y // q y}} (h : α = β) (h' : p == q) :\n  a == b ↔ (a : α) == (b : β) :=\nby { subst h, subst h', rw [heq_iff_eq, heq_iff_eq, ext_iff] }\n\nlemma ext_val {a1 a2 : {x // p x}} : a1.1 = a2.1 → a1 = a2 :=\nsubtype.ext\n\nlemma ext_iff_val {a1 a2 : {x // p x}} : a1 = a2 ↔ a1.1 = a2.1 :=\next_iff\n\n@[simp] theorem coe_eta (a : {a // p a}) (h : p a) : mk ↑a h = a := subtype.ext rfl\n\n@[simp] theorem coe_mk (a h) : (@mk α p a h : α) = a := rfl\n\n@[simp, nolint simp_nf] -- built-in reduction doesn't always work\ntheorem mk_eq_mk {a h a' h'} : @mk α p a h = @mk α p a' h' ↔ a = a' :=\next_iff\n\ntheorem coe_eq_iff {a : {a // p a}} {b : α} : ↑a = b ↔ ∃ h, a = ⟨b, h⟩ :=\n⟨λ h, h ▸ ⟨a.2, (coe_eta _ _).symm⟩, λ ⟨hb, ha⟩, ha.symm ▸ rfl⟩\n\ntheorem coe_injective : injective (coe : subtype p → α) :=\nλ a b, subtype.ext\n\ntheorem val_injective : injective (@val _ p) :=\ncoe_injective\n\n/-- Restrict a (dependent) function to a subtype -/\ndef restrict {α} {β : α → Type*} (f : Π x, β x) (p : α → Prop) (x : subtype p) : β x.1 :=\nf x\n\nlemma restrict_apply {α} {β : α → Type*} (f : Π x, β x) (p : α → Prop) (x : subtype p) :\n  restrict f p x = f x.1 :=\nby refl\n\nlemma restrict_def {α β} (f : α → β) (p : α → Prop) : restrict f p = f ∘ coe :=\nby refl\n\nlemma restrict_injective {α β} {f : α → β} (p : α → Prop) (h : injective f) :\n  injective (restrict f p) :=\nh.comp coe_injective\n\nlemma surjective_restrict {α} {β : α → Type*} [ne : Π a, nonempty (β a)] (p : α → Prop) :\n  surjective (λ f : Π x, β x, restrict f p) :=\nbegin\n  letI := classical.dec_pred p,\n  refine λ f, ⟨λ x, if h : p x then f ⟨x, h⟩ else nonempty.some (ne x), funext $ _⟩,\n  rintro ⟨x, hx⟩,\n  exact dif_pos hx\nend\n\n/-- Defining a map into a subtype, this can be seen as an \"coinduction principle\" of `subtype`-/\n@[simps] def coind {α β} (f : α → β) {p : β → Prop} (h : ∀ a, p (f a)) : α → subtype p :=\nλ a, ⟨f a, h a⟩\n\ntheorem coind_injective {α β} {f : α → β} {p : β → Prop} (h : ∀ a, p (f a))\n  (hf : injective f) : injective (coind f h) :=\nλ x y hxy, hf $ by apply congr_arg subtype.val hxy\n\ntheorem coind_surjective {α β} {f : α → β} {p : β → Prop} (h : ∀ a, p (f a))\n  (hf : surjective f) : surjective (coind f h) :=\nλ x, let ⟨a, ha⟩ := hf x in ⟨a, coe_injective ha⟩\n\ntheorem coind_bijective {α β} {f : α → β} {p : β → Prop} (h : ∀ a, p (f a))\n  (hf : bijective f) : bijective (coind f h) :=\n⟨coind_injective h hf.1, coind_surjective h hf.2⟩\n\n/-- Restriction of a function to a function on subtypes. -/\n@[simps] def map {p : α → Prop} {q : β → Prop} (f : α → β) (h : ∀ a, p a → q (f a)) :\n  subtype p → subtype q :=\nλ x, ⟨f x, h x x.prop⟩\n\ntheorem map_comp {p : α → Prop} {q : β → Prop} {r : γ → Prop} {x : subtype p}\n  (f : α → β) (h : ∀ a, p a → q (f a)) (g : β → γ) (l : ∀ a, q a → r (g a)) :\n  map g l (map f h x) = map (g ∘ f) (assume a ha, l (f a) $ h a ha) x :=\nrfl\n\ntheorem map_id {p : α → Prop} {h : ∀ a, p a → p (id a)} : map (@id α) h = id :=\nfunext $ assume ⟨v, h⟩, rfl\n\nlemma map_injective {p : α → Prop} {q : β → Prop} {f : α → β} (h : ∀ a, p a → q (f a))\n  (hf : injective f) : injective (map f h) :=\ncoind_injective _ $ hf.comp coe_injective\n\nlemma map_involutive {p : α → Prop} {f : α → α} (h : ∀ a, p a → p (f a))\n  (hf : involutive f) : involutive (map f h) :=\nλ x, subtype.ext (hf x)\n\ninstance [has_equiv α] (p : α → Prop) : has_equiv (subtype p) :=\n⟨λ s t, (s : α) ≈ (t : α)⟩\n\ntheorem equiv_iff [has_equiv α] {p : α → Prop} {s t : subtype p} :\n  s ≈ t ↔ (s : α) ≈ (t : α) :=\niff.rfl\n\nvariables [setoid α]\n\nprotected theorem refl (s : subtype p) : s ≈ s :=\nsetoid.refl ↑s\n\nprotected theorem symm {s t : subtype p} (h : s ≈ t) : t ≈ s :=\nsetoid.symm h\n\nprotected theorem trans {s t u : subtype p} (h₁ : s ≈ t) (h₂ : t ≈ u) : s ≈ u :=\nsetoid.trans h₁ h₂\n\ntheorem equivalence (p : α → Prop) : equivalence (@has_equiv.equiv (subtype p) _) :=\nmk_equivalence _ subtype.refl (@subtype.symm _ p _) (@subtype.trans _ p _)\n\ninstance (p : α → Prop) : setoid (subtype p) :=\nsetoid.mk (≈) (equivalence p)\n\nend subtype\n\nnamespace subtype\n/-! Some facts about sets, which require that `α` is a type. -/\nvariables {α β γ : Type*} {p : α → Prop}\n\n@[simp] lemma coe_prop {S : set α} (a : {a // a ∈ S}) : ↑a ∈ S := a.prop\n\nlemma val_prop {S : set α} (a : {a // a ∈ S}) : a.val ∈ S := a.property\n\nend subtype\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/subtype.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7745833945721304, "lm_q1q2_score": 0.4990060698508044}}
{"text": "import algebra.category.Group.limits\nimport for_mathlib.Profinite.extend\nimport Lbar.basic\nimport Lbar.functor\nimport pseudo_normed_group.category.strictProFiltPseuNormGrpWithTinv\nimport pseudo_normed_group.bounded_limits\n\nnoncomputable theory\n\nuniverses u v\n\nopen_locale nnreal\n\n\nset_option pp.universes true\n\nopen Lbar Profinite CommGroup category_theory.limits\n\nlemma limit_torsion_free_to_Ab\n  {C : Type u} [category_theory.small_category C] (J : C ⥤ Ab.{u})\n  (h_tf : ∀ j, no_zero_smul_divisors ℤ (J.obj j))\n  : no_zero_smul_divisors ℤ (limit J).α :=\nbegin\n  let L := get_limit_cone _,\n  haveI := AddCommGroup.forget_preserves_limits.{u u},\n  have h_inj := @concrete.to_product_injective_of_is_limit AddCommGroup.{u} _ _\n    C _ J _ L.cone L.is_limit,\n  fconstructor,\n  intros c x hx,\n  let φ := λ x : (limit J), λ j, (L.cone.π.app j) x,\n  have h1: φ 0 = 0,\n  { ext j,\n    exact (L.cone.π.app j).2 },\n  have h2: φ (c • x) = c • φ x,\n  { ext j,\n    exact map_zsmul (L.cone.π.app j) _ _ },\n  apply_fun φ at hx,\n  simp only [h1, h2, pi.zero_def, function.funext_iff, pi.smul_apply, smul_eq_zero] at hx,\n  by_cases hc : c = 0,\n  { apply or.intro_left, exact hc},\n  { simp only [hc, false_or] at hx,\n    apply or.intro_right,\n    apply h_inj,\n    funext j,\n    specialize hx j,\n    simp only [_root_.map_zero],\n    exact hx },\nend\n\n--[FAE] not needed for LTE, may be for mathlib?\nlemma add_comm_group.limit_on_nat_torsion_free\n  (J : (category_theory.as_small.{u} ℕ) ⥤ AddCommGroup.{u})\n  (h_tf : ∀ j, no_zero_smul_divisors ℤ (J.obj j))\n  : no_zero_smul_divisors ℤ (limit J).α := limit_torsion_free_to_Ab J h_tf\n\nopen CompHausFiltPseuNormGrp₁ category_theory\n\ninstance : concrete_category.{u} PseuNormGrp₁.{u} :=\n{ forget :=\n  { obj := λ M, M,\n    map := λ M N f, f,\n    map_id' := λ M, rfl,\n    map_comp' := λ _ _ _ f g, rfl },\n  forget_faithful := { map_injective' := λ M N f g h, by { ext, dsimp at h, rw h, } } }\n\nlemma PNG₁.iso_injective {X Y : PseuNormGrp₁.{u}} (f : X ≅ Y) :\n  function.injective f.hom :=\nbegin\n  intros x y h,\n  apply_fun f.inv at h,\n  simp only [← category_theory.comp_apply, f.hom_inv_id] at h,\n  exact h,\nend\n\nlemma PNG₁.map_zsmul {X Y : PseuNormGrp₁} (f : X ⟶ Y) (n : ℤ) (x : X) :\n  f (n • x) = n • f x :=\nf.to_add_monoid_hom.map_zsmul _ _\n\nnamespace Profinite\n\nlemma extend_torsion_free (A : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁)\n  (hA : ∀ X, no_zero_smul_divisors ℤ (A.obj X)) (S : Profinite) :\n  no_zero_smul_divisors ℤ ((Profinite.extend A).obj S) :=\nbegin\n  let T := Ab.explicit_limit_cone.{u u}\n    ((S.fintype_diagram ⋙ A ⋙ to_PNG₁) ⋙ PseuNormGrp₁.to_Ab),\n  set T' := limit.cone.{u u} ((S.fintype_diagram ⋙ A ⋙ to_PNG₁) ⋙ PseuNormGrp₁.to_Ab) with hT',\n  let hT : is_limit T := Ab.explicit_limit_cone_is_limit _,\n  let E := PseuNormGrp₁.bounded_cone.{u} ⟨T,hT⟩,\n  let hE : is_limit E := PseuNormGrp₁.bounded_cone_is_limit _,\n  suffices claim : no_zero_smul_divisors ℤ E.X,\n  { resetI,\n    let iso : to_PNG₁.obj ((extend (A)).obj S) ≅ E.X :=\n      (is_limit_of_preserves to_PNG₁\n      (limit.is_limit _)).cone_point_unique_up_to_iso hE,\n    apply function.injective.no_zero_smul_divisors iso.hom (PNG₁.iso_injective _),\n    any_goals { apply_instance },\n    { apply strict_pseudo_normed_group_hom.map_zero },\n    { intros, rw PNG₁.map_zsmul } },\n  let ι : E.X →+ T.X := add_subgroup.subtype _,\n  apply function.injective.no_zero_smul_divisors ι (subtype.val_injective.{u+1}) ι.map_zero,\n  any_goals { apply_instance },\n  { intros c x, apply ι.map_zsmul, },\n  let iso_pts := functor.map_iso (limits.cones.forget.{u} _)\n    (hT.unique_up_to_iso (limit_cone.is_limit.{u u u u+1} _)),\n  let φ := (@iso.AddCommGroup_iso_to_add_equiv.{u} T.X T'.X iso_pts),\n  apply function.injective.no_zero_smul_divisors φ φ.injective φ.map_zero,\n  { intros c x,\n    exact map_zsmul φ _ _ },\n  apply limit_torsion_free_to_Ab.{u},\n  intro j,\n  exact hA ((S.fintype_diagram).obj j),\nend\n\nend Profinite\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/Lbar/torsion_free_profinite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6442251133170356, "lm_q1q2_score": 0.4990060684371406}}
{"text": "/-\nCopyright (c) 2019 The Flypitch Project. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n\nAuthors: Jesse Han, Floris van Doorn\n-/\nimport .compactness\n\nopen set function nat\nuniverse variable u\nnamespace fol\n\nlocal notation h :: t  := dvector.cons h t\nlocal notation `[` l:(foldr `, ` (h t, dvector.cons h t) dvector.nil `]`:0) := l\n\n\nnamespace Language\ndef Lconstants (α : Type u) : Language :=\n⟨λn, nat.rec α (λn ih, pempty) n, λn, pempty⟩\n\nprotected def sum (L L' : Language) : Language :=\n⟨λn, L.functions n ⊕ L'.functions n, λ n, L.relations n ⊕ L'.relations n⟩\n\ndef symbols (L : Language) := (Σl, L.functions l) ⊕ (Σl, L.relations l)\nend Language\n\nsection\nvariable {L : Language}\n\n\n@[simp] def symbols_in_term : ∀{l}, preterm L l → set L.symbols\n| _ &k          := ∅\n| l (func f)    := {sum.inl ⟨l,f⟩}\n| _ (app t₁ t₂) := symbols_in_term t₁ ∪ symbols_in_term t₂\n\n@[simp] def symbols_in_formula : ∀{l}, preformula L l → set L.symbols\n| _ falsum       := ∅\n| _ (t₁ ≃ t₂)    := symbols_in_term t₁ ∪ symbols_in_term t₂\n| l (rel R)      := {sum.inr ⟨l, R⟩}\n| _ (apprel f t) := symbols_in_formula f ∪ symbols_in_term t\n| _ (f₁ ⟹ f₂)   := symbols_in_formula f₁ ∪ symbols_in_formula f₂\n| _ (∀' f)       := symbols_in_formula f\n\n@[simp] lemma symbols_in_term_lift_at (n m) : ∀{l} (t : preterm L l),\n  symbols_in_term (t ↑' n # m) = symbols_in_term t\n| _ &k          := by by_cases h : m ≤ k; simp [h]\n| l (func f)    := by refl\n| _ (app t₁ t₂) := by simp*\n\n@[simp] lemma symbols_in_term_lift (n) {l} (t : preterm L l) :\n  symbols_in_term (t ↑ n) = symbols_in_term t :=\nsymbols_in_term_lift_at n 0 t\n\nlemma symbols_in_term_subst (s : term L) (n) : ∀{l} (t : preterm L l),\n  symbols_in_term (t[s // n]) ⊆ symbols_in_term t ∪ symbols_in_term s\n| _ &k          := by apply decidable.lt_by_cases n k; intro h; simp [h]\n| _ (func f)    := subset_union_left _ _\n| _ (app t₁ t₂) :=\n  by { simp; split; refine subset.trans (symbols_in_term_subst _) _;\n       simp [subset_union2_left, subset_union2_middle] }\n\nlemma symbols_in_formula_subst : ∀{l} (f : preformula L l) (s : term L) (n),\n  symbols_in_formula (f[s // n]) ⊆ symbols_in_formula f ∪ symbols_in_term s\n| _ falsum       s n := empty_subset _\n| _ (t₁ ≃ t₂)    s n :=\n  by { simp; split; refine subset.trans (symbols_in_term_subst _ _ _) _;\n       simp [subset_union2_left, subset_union2_middle] }\n| _ (rel R)      s n := subset_union_left _ _\n| _ (apprel f t) s n :=\n  by { simp; split; [refine subset.trans (symbols_in_formula_subst _ _ _) _,\n         refine subset.trans (symbols_in_term_subst _ _ _) _];\n       simp [subset_union2_left, subset_union2_middle] }\n| _ (f₁ ⟹ f₂)   s n :=\n  by { simp; split; refine subset.trans (symbols_in_formula_subst _ _ _) _;\n       simp [subset_union2_left, subset_union2_middle] }\n| _ (∀' f)       s n := symbols_in_formula_subst f _ _\n\nend\n\n-- def symbols_in_prf : ∀{Γ : set $ formula L} {f : formula L} (P : Γ ⊢ f), set L.symbols\n-- | Γ f (axm h)              := symbols_in_formula f\n-- | Γ (f₁ ⟹ f₂) (impI P)    := symbols_in_prf P ∪ symbols_in_formula f₁\n-- | Γ f₂ (impE f₁ P₁ P₂)     := symbols_in_prf P₁ ∪ symbols_in_prf P₂\n-- | Γ f (falsumE P)          := symbols_in_prf P ∪ symbols_in_formula f\n-- | Γ (∀' f) (allI P)        := symbols_in_prf P\n-- | Γ _ (allE₂ f t P)        := symbols_in_prf P ∪ symbols_in_term t\n-- | Γ (_ ≃ t) (ref _ _)     := symbols_in_term t\n-- | Γ _ (subst₂ s t f P₁ P₂) := symbols_in_prf P₁ ∪ symbols_in_prf P₂\n\n-- def interpolation : ∀{Γ : set $ formula L} {f : formula L} (P : Γ ⊢ f),\n--   Σ' (f' : formula L) (P₁ : Γ ⊢ f') (P₂ : {f'} ⊢ f),\n--     symbols_in_prf P₁ ⊆ ⋃₀ (symbols_in_formula '' Γ) ∧\n--     symbols_in_prf P₂ ⊆ symbols_in_formula f ∧\n--     symbols_in_formula f' ⊆ ⋃₀ (symbols_in_formula '' Γ) ∩ symbols_in_formula f :=\n-- sorry -- probably the last property follows automatically\n\n\n\n\nstructure Lhom (L L' : Language) :=\n(on_function : ∀{n}, L.functions n → L'.functions n)\n(on_relation : ∀{n}, L.relations n → L'.relations n)\n\ninfix ` →ᴸ `:10 := Lhom -- \\^L\n\nnamespace Lhom\n/- -/\nvariables {L : Language.{u}} {L' : Language.{u}} (ϕ : L →ᴸ L')\n\nprotected def id (L : Language) : L →ᴸ L :=\n⟨λn, id, λ n, id⟩\n\nprotected def sum_inl {L L' : Language} : L →ᴸ L.sum L' :=\n⟨λn, sum.inl, λ n, sum.inl⟩\n\nprotected def sum_inr {L L' : Language} : L' →ᴸ L.sum L' :=\n⟨λn, sum.inr, λ n, sum.inr⟩\n\n@[reducible]def comp {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) : L1 →ᴸ L3 :=\nbegin\n--  rcases g with ⟨g1, g2⟩, rcases f with ⟨f1,f2⟩,\n--  exact ⟨λn, g1 ∘ f1, λn, g2 ∘ f2⟩\nsplit,\n  all_goals{intro n},\n  let g1 := g.on_function, let f1 := f.on_function,-- Lean's not letting me \"@\" g.on_function etc\n    exact (@g1 n) ∘ (@f1 n),\n  let g2 := g.on_relation, let f2 := f.on_relation,\n    exact (@g2 n) ∘ (@f2 n)\nend\n\nlemma Lhom_funext {L1} {L2} {F G : L1 →ᴸ L2} (h_fun : F.on_function = G.on_function ) (h_rel : F.on_relation = G.on_relation ) : F = G :=\nby {cases F with Ff Fr, cases G with Gf Gr, simp only *, exact and.intro h_fun h_rel}\n\nlocal infix ` ∘ `:60 := Lhom.comp\n\n@[simp]lemma id_is_left_identity {L1 L2} {F : L1 →ᴸ L2} : (Lhom.id L2) ∘ F = F := by {cases F, refl}\n\n@[simp]lemma id_is_right_identity {L1 L2} {F : L1 →ᴸ L2} : F ∘ (Lhom.id L1) = F := by {cases F, refl}\n\nstructure is_injective : Prop :=\n(on_function {n} : injective (on_function ϕ : L.functions n → L'.functions n))\n(on_relation {n} : injective (on_relation ϕ : L.relations n → L'.relations n))\n\nclass has_decidable_range : Type u :=\n(on_function {n} : decidable_pred (range (on_function ϕ : L.functions n → L'.functions n)))\n(on_relation {n} : decidable_pred (range (on_relation ϕ : L.relations n → L'.relations n)))\n\nattribute [instance] has_decidable_range.on_function has_decidable_range.on_relation\n\n@[simp] def on_symbol : L.symbols → L'.symbols\n| (sum.inl ⟨l, f⟩) := sum.inl ⟨l, ϕ.on_function f⟩\n| (sum.inr ⟨l, R⟩) := sum.inr ⟨l, ϕ.on_relation R⟩\n\n@[simp] def on_term : ∀{l}, preterm L l → preterm L' l\n| _ &k          := &k\n| _ (func f)    := func $ ϕ.on_function f\n| _ (app t₁ t₂) := app (on_term t₁) (on_term t₂)\n\n@[simp] lemma on_term_lift_at : ∀{l} (t : preterm L l) (n m : ℕ),\n  ϕ.on_term (t ↑' n # m) = ϕ.on_term t ↑' n # m\n| _ &k          n m := by simp\n| _ (func f)    n m := by refl\n| _ (app t₁ t₂) n m := by simp*\n\n@[simp] lemma on_term_lift {l} (n : ℕ) (t : preterm L l) : ϕ.on_term (t ↑ n) = ϕ.on_term t ↑ n :=\nϕ.on_term_lift_at t n 0\n\n@[simp] lemma on_term_subst : ∀{l} (t : preterm L l) (s : term L) (n : ℕ),\n  ϕ.on_term (t[s // n]) = ϕ.on_term t[ϕ.on_term s // n]\n| _ &k          s n := by apply decidable.lt_by_cases k n; intro h; simp [h]\n| _ (func f)    s n := by refl\n| _ (app t₁ t₂) s n := by simp*\n\n@[simp] def on_term_apps : ∀{l} (t : preterm L l) (ts : dvector (term L) l),\n  ϕ.on_term (apps t ts) = apps (ϕ.on_term t) (ts.map ϕ.on_term)\n| _ t []       := by refl\n| _ t (t'::ts) := by simp*\n\nlemma not_mem_symbols_in_term_on_term {s : L'.symbols} (h : s ∉ range (ϕ.on_symbol)) :\n  ∀{l} (t : preterm L l), s ∉ symbols_in_term (ϕ.on_term t)\n| _ &k          h' := not_mem_empty _ h'\n| l (func f)    h' := h ⟨sum.inl ⟨l, f⟩, (eq_of_mem_singleton h').symm⟩\n| _ (app t₁ t₂) h' :=\n  or.elim h' (not_mem_symbols_in_term_on_term t₁) (not_mem_symbols_in_term_on_term t₂)\n\n@[simp] def on_formula : ∀{l}, preformula L l → preformula L' l\n| _ falsum       := falsum\n| _ (t₁ ≃ t₂)    := ϕ.on_term t₁ ≃ ϕ.on_term t₂\n| _ (rel R)      := rel $ ϕ.on_relation R\n| _ (apprel f t) := apprel (on_formula f) $ ϕ.on_term t\n| _ (f₁ ⟹ f₂)   := on_formula f₁ ⟹ on_formula f₂\n| _ (∀' f)       := ∀' on_formula f\n\n@[simp] lemma on_formula_lift_at : ∀{l} (n m : ℕ) (f : preformula L l),\n  ϕ.on_formula (f ↑' n # m) = ϕ.on_formula f ↑' n # m\n| _ n m falsum       := by refl\n| _ n m (t₁ ≃ t₂)    := by simp\n| _ n m (rel R)      := by refl\n| _ n m (apprel f t) := by simp*\n| _ n m (f₁ ⟹ f₂)   := by simp*\n| _ n m (∀' f)       := by simp*\n\n@[simp] lemma on_formula_lift {l} (n : ℕ) (f : preformula L l) :\n  ϕ.on_formula (f ↑ n) = ϕ.on_formula f ↑ n :=\nϕ.on_formula_lift_at n 0 f\n\n@[simp] lemma on_formula_subst : ∀{l} (f : preformula L l) (s : term L) (n : ℕ),\n  ϕ.on_formula (f[s // n]) = (ϕ.on_formula f)[ϕ.on_term s // n]\n| _ falsum       s n := by refl\n| _ (t₁ ≃ t₂)    s n := by simp\n| _ (rel R)      s n := by refl\n| _ (apprel f t) s n := by simp*\n| _ (f₁ ⟹ f₂)   s n := by simp*\n| _ (∀' f)       s n := by simp*\n\n@[simp] def on_formula_apps_rel : ∀{l} (f : preformula L l) (ts : dvector (term L) l),\n  ϕ.on_formula (apps_rel f ts) = apps_rel (ϕ.on_formula f) (ts.map ϕ.on_term)\n| _ f []       := by refl\n| _ f (t'::ts) := by simp*\n\nlemma not_mem_symbols_in_formula_on_formula {s : L'.symbols} (h : s ∉ range (ϕ.on_symbol)) :\n  ∀{l} (f : preformula L l), s ∉ symbols_in_formula (ϕ.on_formula f)\n| _ falsum       h' := not_mem_empty _ h'\n| _ (t₁ ≃ t₂)    h' := by cases h'; apply not_mem_symbols_in_term_on_term ϕ h _ h'\n| l (rel R)      h' := h ⟨sum.inr ⟨l, R⟩, (eq_of_mem_singleton h').symm⟩\n| _ (apprel f t) h' :=\n  by { cases h', apply not_mem_symbols_in_formula_on_formula _ h',\n       apply not_mem_symbols_in_term_on_term ϕ h _ h' }\n| _ (f₁ ⟹ f₂)   h' := by cases h'; apply not_mem_symbols_in_formula_on_formula _ h'\n| _ (∀' f)       h' := not_mem_symbols_in_formula_on_formula f h'\n\nlemma not_mem_function_in_formula_on_formula {l'} {f' : L'.functions l'}\n  (h : f' ∉ range (@on_function _ _ ϕ l')) {l} (f : preformula L l) :\n  (sum.inl ⟨l', f'⟩ : L'.symbols) ∉ symbols_in_formula (ϕ.on_formula f) :=\nbegin\n  apply not_mem_symbols_in_formula_on_formula,\n  intro h', apply h,\n  rcases h' with ⟨⟨n, f⟩ | ⟨n, R⟩, hf₂⟩; dsimp at hf₂; cases hf₂ with hf₂',\n  apply mem_range_self\nend\n\n@[simp] def on_bounded_term {n} : ∀{l} (t : bounded_preterm L n l), bounded_preterm L' n l\n| _ &k           := &k\n| _ (bd_func f)  := bd_func $ ϕ.on_function f\n| _ (bd_app t s) := bd_app (on_bounded_term t) (on_bounded_term s)\n\n@[simp] def on_bounded_term_fst {n} : ∀{l} (t : bounded_preterm L n l),\n  (ϕ.on_bounded_term t).fst = ϕ.on_term t.fst\n| _ &k           := by refl\n| _ (bd_func f)  := by refl\n| _ (bd_app t s) := by dsimp; simp*\n\n@[simp] def on_bounded_formula : ∀{n l} (f : bounded_preformula L n l), bounded_preformula L' n l\n| _ _ bd_falsum       := ⊥\n| _ _ (t₁ ≃ t₂)       := ϕ.on_bounded_term t₁ ≃ ϕ.on_bounded_term t₂\n| _ _ (bd_rel R)      := bd_rel $ ϕ.on_relation R\n| _ _ (bd_apprel f t) := bd_apprel (on_bounded_formula f) $ ϕ.on_bounded_term t\n| _ _ (f₁ ⟹ f₂)      := on_bounded_formula f₁ ⟹ on_bounded_formula f₂\n| _ _ (∀' f)          := ∀' on_bounded_formula f\n\n@[simp] def on_bounded_formula_fst : ∀{n l} (f : bounded_preformula L n l),\n  (ϕ.on_bounded_formula f).fst = ϕ.on_formula f.fst\n| _ _ bd_falsum       := by refl\n| _ _ (t₁ ≃ t₂)       := by simp\n| _ _ (bd_rel R)      := by refl\n| _ _ (bd_apprel f t) := by simp*\n| _ _ (f₁ ⟹ f₂)      := by simp*\n| _ _ (∀' f)          := by simp*\n\n\n/- Various lemmas of the shape \"on_etc is a functor to Type*\" -/\n@[simp]lemma comp_on_function {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2):\n      (g ∘ f).on_function =\n      begin intro n, let g1 := g.on_function, let f1 := f.on_function,\n      exact function.comp (@g1 n) (@f1 n) end\n      := by refl\n\n/- comp_on_function with explicit nat parameter -/\n@[simp]lemma comp_on_function' {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) (n):\n      @on_function L1 L3 (g ∘ f) n  =\n      function.comp (@on_function L2 L3 g n) (@on_function L1 L2 f n)\n      := by refl\n\n@[simp]lemma comp_on_relation {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :\n      (g ∘ f).on_relation =\n      begin intro n, let g1 := g.on_relation, let f1 := f.on_relation,\n      exact function.comp (@g1 n) (@f1 n) end\n      := by refl\n\n/- comp_on_relation with explicit nat parameter -/\n@[simp]lemma comp_on_relation' {L1} {L2} {L3} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) (n):\n      @on_relation L1 L3 (g ∘ f) n  =\n      function.comp (@on_relation L2 L3 g n) (@on_relation L1 L2 f n)\n      := by refl\n\n@[simp]lemma comp_on_term {L1} {L2} {L3} {l : ℕ} (g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :\n@on_term L1 L3 (g ∘ f) l = function.comp (@on_term L2 L3 g l) (@on_term L1 L2 f l) :=\nby {fapply funext, intro x, induction x, tidy}\n\n@[simp]lemma comp_on_formula {L1} {L2} {L3} {l : ℕ}(g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :\n@on_formula L1 L3 (g ∘ f) l = function.comp (@on_formula L2 L3 g l) (@on_formula L1 L2 f l) :=\nby {fapply funext, intro x, induction x, tidy, all_goals{rw[comp_on_term]} }\n\n@[simp]lemma comp_on_bounded_term {L1} {L2} {L3} {n l : ℕ}(g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :\n@on_bounded_term L1 L3 (g ∘ f) n l = function.comp (@on_bounded_term L2 L3 g n l) (@on_bounded_term L1 L2 f n l) :=\nfunext $ λ _, by tidy\n\n@[simp]lemma comp_on_bounded_formula {L1} {L2} {L3} {n l : ℕ}(g : L2 →ᴸ L3) (f : L1 →ᴸ L2) :\n@on_bounded_formula L1 L3 (g ∘ f) n l = function.comp (@on_bounded_formula L2 L3 g n l) (@on_bounded_formula L1 L2 f n l) :=\nby {apply funext, intro x, ext, induction x; simp}\n\nlemma id_term {L} : Πl, Π f, (@on_term L L (Lhom.id L) l) f = f\n| _ &k          := by refl\n| _ (func f)    := by refl\n| l (app t₁ t₂) := by simp[id_term (l+1) t₁, id_term 0 t₂]\n\nlemma id_formula {L} : Π l, Π f, (@on_formula L L (Lhom.id L) l) f = f\n| _   falsum        := by refl\n| _ (t₁ ≃ t₂)         := by simp[id_term]\n| _ (rel R)       := by refl\n| l (apprel f t)  := by {dsimp, rw[id_formula _ f, id_term _ t]}\n| _ (f₁ ⟹ f₂)    := by {dsimp, rw[id_formula _ f₁, id_formula _ f₂]}\n| _ (∀' f)        := by {dsimp, rw[id_formula _ f]}\n\nlemma id_bounded_term {L} (n) : Πl, Π f, (@on_bounded_term L L (Lhom.id L) n l) f = f\n| _ (bd_var k) := by refl\n| _ (bd_func k) := by refl\n| l (bd_app t₁ t₂) := by simp[id_bounded_term (l+1) t₁, id_bounded_term 0 t₂]\n\nlemma id_bounded_formula {L} : Π n l, Π f, (@on_bounded_formula L L (Lhom.id L) n l) f = f\n| _ _   bd_falsum        := by refl\n| _ _ (t₁ ≃ t₂)         := by simp[id_bounded_term]\n| _ _ (bd_rel R)       := by refl\n| _ l (bd_apprel f t)  := by {dsimp, rw[id_bounded_formula _ _ f, id_bounded_term _ _ t]}\n| _ _ (f₁ ⟹ f₂)    := by {dsimp, rw[id_bounded_formula _ _ f₁, id_bounded_formula _ _ f₂]}\n| _ _ (∀' f)        := by {dsimp, rw[id_bounded_formula _ _ f]}\n\n@[simp] def on_closed_term (t : closed_term L) : closed_term L' := ϕ.on_bounded_term t\n@[simp] def on_sentence (f : sentence L) : sentence L' := ϕ.on_bounded_formula f\ndef on_sentence_fst (f : sentence L) : (ϕ.on_sentence f).fst = ϕ.on_formula f.fst :=\nϕ.on_bounded_formula_fst f\n\ndef on_prf {Γ : set $ formula L} {f : formula L} (h : Γ ⊢ f) : ϕ.on_formula '' Γ ⊢ ϕ.on_formula f :=\nbegin\n  induction h,\n  { apply axm, exact mem_image_of_mem _ h_h, },\n  { apply impI, rw [←image_insert_eq], exact h_ih },\n  { exact impE _ h_ih_h₁ h_ih_h₂, },\n  { apply falsumE, rw [image_insert_eq] at h_ih, exact h_ih },\n  { apply allI, rw [image_image] at h_ih ⊢, simp [image_congr' (on_formula_lift ϕ 1)] at h_ih,\n    exact h_ih },\n  { apply allE _ _ h_ih, symmetry, apply on_formula_subst },\n  { apply prf.ref },\n  { simp at h_ih_h₂, apply subst _ h_ih_h₁ h_ih_h₂, simp }\nend\n\ndef on_sprf {Γ : set $ sentence L} {f : sentence L} (h : Γ ⊢ f) :\n  ϕ.on_sentence '' Γ ⊢ ϕ.on_sentence f :=\nby have := ϕ.on_prf h; simp only [sprf, Theory.fst, image_image, function.comp,\n  on_bounded_formula_fst, on_sentence] at this ⊢; exact this\n\n\n/- replace all symbols not in the image of ϕ by a new variable -/\nnoncomputable def reflect_term [has_decidable_range ϕ] (t : term L') (m : ℕ) : term L :=\nterm.elim (λk, &k ↑' 1 # m)\n     (λl f' ts' ts, if hf' : f' ∈ range (@on_function _ _ ϕ l)\n       then apps (func (classical.some hf')) ts else &m) t\n\nvariable {ϕ}\nlemma reflect_term_apps_pos [has_decidable_range ϕ] {l} {f : L'.functions l}\n  (hf : f ∈ range (@on_function _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :\n  ϕ.reflect_term (apps (func f) ts) m =\n  apps (func (classical.some hf)) (ts.map (λt, ϕ.reflect_term t m)) :=\n(term.elim_apps _ _ f ts).trans $ by rw [dif_pos hf]; refl\n\nlemma reflect_term_apps_neg [has_decidable_range ϕ] {l} {f : L'.functions l}\n  (hf : f ∉ range (@on_function _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :\n  ϕ.reflect_term (apps (func f) ts) m = &m :=\n(term.elim_apps _ _ f ts).trans $ by rw [dif_neg hf]\n\n\nlemma reflect_term_const_pos [has_decidable_range ϕ] {c : L'.constants}\n  (hf : c ∈ range (@on_function _ _ ϕ 0)) (m : ℕ) :\n  ϕ.reflect_term (func c) m = func (classical.some hf) :=\nby apply reflect_term_apps_pos hf ([]) m\n\nlemma reflect_term_const_neg [has_decidable_range ϕ] {c : L'.constants}\n  (hf : c ∉ range (@on_function _ _ ϕ 0)) (m : ℕ) :\n  ϕ.reflect_term (func c) m = &m :=\nby apply reflect_term_apps_neg hf ([]) m\n\n@[simp] lemma reflect_term_var [has_decidable_range ϕ] (k : ℕ) (m : ℕ) :\n  ϕ.reflect_term &k m = &k ↑' 1 # m := by refl\n\n@[simp] lemma reflect_term_on_term [has_decidable_range ϕ] (hϕ : is_injective ϕ) (t : term L)\n  (m : ℕ) : ϕ.reflect_term (ϕ.on_term t) m = t ↑' 1 # m :=\nbegin\n  refine term.rec _ _ t; clear t; intros,\n  { refl },\n  { simp [reflect_term_apps_pos (mem_range_self f)],\n    rw [classical.some_eq f (λy hy, hϕ.on_function hy), dvector.map_congr_pmem ih_ts] }\nend\n\nlemma reflect_term_lift_at [has_decidable_range ϕ] (hϕ : is_injective ϕ) {n m m' : ℕ} (h : m ≤ m')\n  (t : term L') : ϕ.reflect_term (t ↑' n # m) (m'+n) = ϕ.reflect_term t m' ↑' n # m :=\nbegin\n  refine term.rec _ _ t; clear t; intros,\n  { simp [-lift_term_at], rw[lift_term_at2_small _ _ _ h], simp },\n  { by_cases h' : f ∈ range (@on_function _ _ ϕ l); simp [reflect_term_apps_pos,\n      reflect_term_apps_neg, h', h, dvector.map_congr_pmem ih_ts, -add_comm] }\nend\n\nlemma reflect_term_lift [has_decidable_range ϕ] (hϕ : is_injective ϕ) {n m : ℕ}\n  (t : term L') : ϕ.reflect_term (t ↑ n) (m+n) = ϕ.reflect_term t m ↑ n :=\nreflect_term_lift_at hϕ m.zero_le t\n\nlemma reflect_term_subst [has_decidable_range ϕ] (hϕ : is_injective ϕ) (n m : ℕ)\n  (s t : term L') :\n  ϕ.reflect_term (t[s // n]) (m+n) = (ϕ.reflect_term t (m+n+1))[ϕ.reflect_term s m // n] :=\nbegin\n  refine term.rec _ _ t; clear t; intros,\n  { simp [-lift_term_at, -add_comm, -add_assoc],\n    apply decidable.lt_by_cases k n; intro h,\n    { have h₂ : ¬(m + n ≤ k), from λh', not_le_of_gt h (le_trans (le_add_left n m) h'),\n      have h₃ : ¬(m + n + 1 ≤ k), from λh', h₂ $ le_trans (le_succ _) h',\n      simp [h, h₂, h₃, -add_comm, -add_assoc] },\n    { have h₂ : ¬(m + n + 1 ≤ n), from not_le_of_gt (lt_of_le_of_lt (le_add_left n m) (lt.base _)) ,\n      simp [h, h₂, reflect_term_lift hϕ, -add_comm, -add_assoc] },\n    { have hk := one_le_of_lt h,\n      have h₄ : n < k + 1, from lt.trans h (lt.base k),\n      by_cases h₂' : m + n + 1 ≤ k,\n      { have h₂ : m + n + 1 ≤ k, from h₂',\n        have h₃ : m + n ≤ k - 1, from (nat.le_sub_right_iff_add_le hk).mpr h₂,\n        simp [h, h₂, h₃, h₄, -add_comm, -add_assoc],\n        rw [sub_add_eq_max, max_eq_left hk] },\n      { have h₂ : ¬(m + n + 1 ≤ k), from h₂',\n        have h₃ : ¬(m + n ≤ k - 1), from λh', h₂ $ (nat.le_sub_right_iff_add_le hk).mp h',\n        simp [h, h₂, h₃, -add_comm, -add_assoc] }}},\n  { have h : n < m + n + 1, from nat.lt_succ_of_le (nat.le_add_left n m),\n    by_cases h' : f ∈ range (@on_function _ _ ϕ l); simp [reflect_term_apps_pos,\n      reflect_term_apps_neg, h, h', dvector.map_congr_pmem ih_ts, -add_comm, -add_assoc] }\nend\n\nvariable (ϕ)\n\nnoncomputable def reflect_formula [has_decidable_range ϕ] (f : formula L') :\n  ∀(m : ℕ), formula L :=\nformula.rec (λm, ⊥) (λt₁ t₂ m, ϕ.reflect_term t₁ m ≃ ϕ.reflect_term t₂ m)\n  (λl R' xs' m, if hR' : R' ∈ range (@on_relation _ _ ϕ l)\n       then apps_rel (rel (classical.some hR')) (xs'.map $ λt, ϕ.reflect_term t m) else ⊥)\n   (λf₁' f₂' f₁ f₂ m, f₁ m ⟹ f₂ m) (λf' f m, ∀' f (m+1)) f\n\nvariable {ϕ}\nlemma reflect_formula_apps_rel_pos [has_decidable_range ϕ] {l} {R : L'.relations l}\n  (hR : R ∈ range (@on_relation _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :\n  ϕ.reflect_formula (apps_rel (rel R) ts) m =\n  apps_rel (rel (classical.some hR)) (ts.map (λt, ϕ.reflect_term t m)) :=\nby simp [reflect_formula, formula.rec_apps_rel, dif_pos hR]\n\nlemma reflect_formula_apps_rel_neg [has_decidable_range ϕ] {l} {R : L'.relations l}\n  (hR : R ∉ range (@on_relation _ _ ϕ l)) (ts : dvector (term L') l) (m : ℕ) :\n  ϕ.reflect_formula (apps_rel (rel R) ts) m = ⊥ :=\nby simp [reflect_formula, formula.rec_apps_rel, dif_neg hR]\n\n@[simp] lemma reflect_formula_equal [has_decidable_range ϕ] (t₁ t₂ : term L') (m : ℕ) :\n  ϕ.reflect_formula (t₁ ≃ t₂) m = ϕ.reflect_term t₁ m ≃ ϕ.reflect_term t₂ m := by refl\n@[simp] lemma reflect_formula_imp [has_decidable_range ϕ] (f₁ f₂ : formula L') (m : ℕ) :\n  ϕ.reflect_formula (f₁ ⟹ f₂) m = ϕ.reflect_formula f₁ m ⟹ ϕ.reflect_formula f₂ m := by refl\n@[simp] lemma reflect_formula_all [has_decidable_range ϕ] (f : formula L') (m : ℕ) :\n  ϕ.reflect_formula (∀' f) m = ∀' (ϕ.reflect_formula f (m+1)) := by refl\n\n@[simp] lemma reflect_formula_on_formula [has_decidable_range ϕ] (hϕ : is_injective ϕ) (m : ℕ)\n  (f : formula L) : ϕ.reflect_formula (ϕ.on_formula f) m = f ↑' 1 # m :=\nbegin\n  revert m, refine formula.rec _ _ _ _ _ f; clear f; intros,\n  { refl },\n  { simp [hϕ] },\n  { simp [reflect_formula_apps_rel_pos (mem_range_self R), hϕ],\n    rw [classical.some_eq R (λy hy, hϕ.on_relation hy)] },\n  { simp* },\n  { simp* }\nend\n\nlemma reflect_formula_lift_at [has_decidable_range ϕ] (hϕ : is_injective ϕ) {n m m' : ℕ}\n  (h : m ≤ m') (f : formula L') :\n  ϕ.reflect_formula (f ↑' n # m) (m'+n) = ϕ.reflect_formula f m' ↑' n # m :=\nbegin\n  revert m m', refine formula.rec _ _ _ _ _ f; clear f; intros,\n  { refl },\n  { simp [reflect_term_lift_at hϕ h, -add_comm] },\n  { by_cases h' : R ∈ range (@on_relation _ _ ϕ l); simp [reflect_formula_apps_rel_pos,\n      reflect_formula_apps_rel_neg, h', h, ts.map_congr (reflect_term_lift_at hϕ h), -add_comm] },\n  { simp [ih₁ h, ih₂ h, -add_comm] },\n  { simp [-add_comm, -add_assoc], rw [←ih], simp, exact add_le_add_right h 1 },\nend\n\nlemma reflect_formula_lift [has_decidable_range ϕ] (hϕ : is_injective ϕ) (n m : ℕ)\n  (f : formula L') : ϕ.reflect_formula (f ↑ n) (m+n) = ϕ.reflect_formula f m ↑ n :=\nreflect_formula_lift_at hϕ m.zero_le f\n\nlemma reflect_formula_lift1 [has_decidable_range ϕ] (hϕ : is_injective ϕ) (m : ℕ)\n  (f : formula L') : ϕ.reflect_formula (f ↑ 1) (m+1) = ϕ.reflect_formula f m ↑ 1 :=\nreflect_formula_lift hϕ 1 m f\n\nlemma reflect_formula_subst [has_decidable_range ϕ] (hϕ : is_injective ϕ) (f : formula L')\n  (n m : ℕ) (s : term L') :\n  ϕ.reflect_formula (f[s // n]) (m+n) = (ϕ.reflect_formula f (m+n+1))[ϕ.reflect_term s m // n] :=\nbegin\n  revert n, refine formula.rec _ _ _ _ _ f; clear f; intros,\n  { refl },\n  { simp [reflect_term_subst hϕ, -add_comm] },\n  { by_cases h' : R ∈ range (@on_relation _ _ ϕ l); simp [reflect_formula_apps_rel_pos,\n      reflect_formula_apps_rel_neg, h', ts.map_congr (reflect_term_subst hϕ n m s), -add_comm] },\n  { simp [ih₁, ih₂, -add_comm] },\n  { simp [-add_comm, ih] },\nend\n\n@[simp] lemma reflect_formula_subst0 [has_decidable_range ϕ] (hϕ : is_injective ϕ) (m : ℕ)\n  (f : formula L') (s : term L') :\n  ϕ.reflect_formula (f[s // 0]) m = (ϕ.reflect_formula f (m+1))[ϕ.reflect_term s m // 0] :=\nreflect_formula_subst hϕ f 0 m s\n\nnoncomputable def reflect_prf_gen [has_decidable_range ϕ] (hϕ : is_injective ϕ) {Γ}\n  {f : formula L'} (m) (H : Γ ⊢ f) : (λf, ϕ.reflect_formula f m) '' Γ ⊢ ϕ.reflect_formula f m :=\nbegin\n  induction H generalizing m,\n  { apply axm, apply mem_image_of_mem _ H_h },\n  { apply impI, have h := @H_ih m, rw [image_insert_eq] at h, exact h },\n  { apply impE, apply H_ih_h₁, apply H_ih_h₂ },\n  { apply falsumE, have h := @H_ih m, rw [image_insert_eq] at h, exact h },\n  { apply allI, rw [image_image], have h := @H_ih (m+1), rw [image_image] at h,\n    apply cast _ h, congr1, apply image_congr' (reflect_formula_lift1 hϕ m) },\n  { apply allE, have h := @H_ih m, simp at h, exact h, symmetry,\n    apply reflect_formula_subst0 hϕ },\n  { apply ref },\n  { apply subst, have h := @H_ih_h₁ m, simp at h, exact h,\n    have h := @H_ih_h₂ m, simp [hϕ] at h, exact h, simp [hϕ] },\nend\n\nsection\n\n/- maybe generalize to filter_symbol? -/\n@[reducible] def filter_symbols (p : L.symbols → Prop) : Language :=\n⟨λl, subtype (λf, p (sum.inl ⟨l, f⟩)), λl, subtype (λR, p (sum.inr ⟨l, R⟩))⟩\n\ndef filter_symbols_Lhom (p : L.symbols → Prop) : filter_symbols p →ᴸ L :=\n⟨λl, subtype.val, λl, subtype.val⟩\n\ndef is_injective_filter_symbols_Lhom (p : L.symbols → Prop) :\n  is_injective (filter_symbols_Lhom p) :=\n⟨λl, subtype.val_injective, λl, subtype.val_injective⟩\n\nlemma find_term_filter_symbols (p : L.symbols → Prop) :\n  ∀{l} (t : preterm L l) (h : symbols_in_term t ⊆ { s | p s }),\n  { t' : preterm (filter_symbols p) l // (filter_symbols_Lhom p).on_term t' = t }\n| _ &k          h := ⟨&k, rfl⟩\n| _ (func f)    h := ⟨func ⟨f, h $ mem_singleton _⟩, rfl⟩\n| _ (app t₁ t₂) h :=\n  begin\n    let ih₁ := find_term_filter_symbols t₁ (subset.trans (subset_union_left _ _) h),\n    let ih₂ := find_term_filter_symbols t₂ (subset.trans (subset_union_right _ _) h),\n    refine ⟨app ih₁.1 ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]\n  end\n\nlemma find_formula_filter_symbols (p : L.symbols → Prop) :\n  ∀{l} (f : preformula L l) (h : symbols_in_formula f ⊆ { s | p s }),\n  { f' : preformula (filter_symbols p) l // (filter_symbols_Lhom p).on_formula f' = f }\n| _ falsum       h := ⟨⊥, rfl⟩\n| _ (t₁ ≃ t₂)    h :=\n  begin\n    let ih₁ := find_term_filter_symbols p t₁ (subset.trans (subset_union_left _ _) h),\n    let ih₂ := find_term_filter_symbols p t₂ (subset.trans (subset_union_right _ _) h),\n    refine ⟨ih₁.1 ≃ ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]\n  end\n| _ (rel R)      h := ⟨rel ⟨R, h $ mem_singleton _⟩, rfl⟩\n| _ (apprel f t) h :=\n  begin\n    let ih₁ := find_formula_filter_symbols f (subset.trans (subset_union_left _ _) h),\n    let ih₂ := find_term_filter_symbols p t (subset.trans (subset_union_right _ _) h),\n    refine ⟨apprel ih₁.1 ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]\n  end\n| _ (f₁ ⟹ f₂)   h :=\n  begin\n    let ih₁ := find_formula_filter_symbols f₁ (subset.trans (subset_union_left _ _) h),\n    let ih₂ := find_formula_filter_symbols f₂ (subset.trans (subset_union_right _ _) h),\n    refine ⟨ih₁.1 ⟹ ih₂.1, _⟩, dsimp, rw [ih₁.2, ih₂.2]\n  end\n| _ (∀' f)       h :=\n  begin\n    let ih := find_formula_filter_symbols f h,\n    refine ⟨∀' ih.1, _⟩, dsimp, rw [ih.2]\n  end\n\nend\n\nnoncomputable def generalize_constant {Γ} (c : L.constants)\n  (hΓ : (sum.inl ⟨0, c⟩ : L.symbols) ∉ ⋃₀ (symbols_in_formula '' Γ))\n  {f : formula L} (hf : (sum.inl ⟨0, c⟩ : L.symbols) ∉ symbols_in_formula f)\n  (H : Γ ⊢ f[func c // 0]) : Γ ⊢ ∀' f :=\nbegin\n  apply allI,\n  let p : L.symbols → Prop := (≠ sum.inl ⟨0, c⟩),\n  let ϕ := filter_symbols_Lhom p,\n  have hϕ : is_injective ϕ := is_injective_filter_symbols_Lhom p,\n  have hc : c ∉ range (on_function ϕ),\n  { intro hc, rw [mem_range] at hc, rcases hc with ⟨c', hc'⟩,\n    apply c'.2, rw [←hc'], refl },\n  have hf' : symbols_in_formula f ⊆ {s : Language.symbols L | p s},\n  { intros s hs hps, subst hps, exact hf hs },\n  rcases find_formula_filter_symbols p f hf' with ⟨f, rfl⟩,\n  have : {Γ' // Lhom.on_formula ϕ '' Γ' = Γ } ,\n  { refine ⟨Lhom.on_formula ϕ ⁻¹' Γ, _⟩,\n    apply image_preimage_eq_of_subset, intros f' hf',\n    have : symbols_in_formula f' ⊆ {s : Language.symbols L | p s},\n    { intros s hs hps, subst hps, exact hΓ ⟨_, mem_image_of_mem _ hf', hs⟩ },\n    rcases find_formula_filter_symbols p f' this with ⟨f, rfl⟩,\n    apply mem_range_self },\n  rcases this with ⟨Γ, rfl⟩,\n  rw [image_image, ←image_congr' (ϕ.on_formula_lift 1),\n    ←image_image ϕ.on_formula],\n  apply ϕ.on_prf,\n  haveI : has_decidable_range (filter_symbols_Lhom p) :=\n    ⟨λn f, classical.prop_decidable _, λn R, classical.prop_decidable _⟩,\n  have := reflect_prf_gen hϕ 0 H,\n  rwa [reflect_formula_subst0 hϕ, reflect_term_const_neg hc, image_image,\n    image_congr' (reflect_formula_on_formula hϕ 0),\n    reflect_formula_on_formula hϕ, lift_subst_formula_cancel] at this\nend\n\nnoncomputable def sgeneralize_constant {T : Theory L} (c : L.constants)\n  (hΓ : (sum.inl ⟨0, c⟩ : L.symbols) ∉ ⋃₀ (symbols_in_formula '' T.fst))\n  {f : bounded_formula L 1} (hf : (sum.inl ⟨0, c⟩ : L.symbols) ∉ symbols_in_formula f.fst)\n  (H : T ⊢ f[bd_func c /0]) : T ⊢ ∀' f :=\nby { simp [sprf] at H, exact generalize_constant c hΓ hf H }\n\n\nnoncomputable def reflect_prf {Γ : set $ formula L} {f : formula L} (hϕ : ϕ.is_injective)\n  (h : ϕ.on_formula '' Γ ⊢ ϕ.on_formula f) : Γ ⊢ f :=\nbegin\n  haveI : has_decidable_range ϕ :=\n    ⟨λl f, classical.prop_decidable _, λl R, classical.prop_decidable _⟩,\n  apply reflect_prf_lift1,\n  have := reflect_prf_gen hϕ 0 h, simp [image_image, hϕ] at this, exact this\nend\n\nnoncomputable def reflect_sprf {Γ : set $ sentence L} {f : sentence L} (hϕ : ϕ.is_injective)\n  (h : ϕ.on_sentence '' Γ ⊢ ϕ.on_sentence f) : Γ ⊢ f :=\nby { apply reflect_prf hϕ, simp only [sprf, Theory.fst, image_image, function.comp,\n     on_bounded_formula_fst, on_sentence] at h ⊢, exact h }\n\nlemma on_term_inj (h : ϕ.is_injective) {l} : injective (ϕ.on_term : preterm L l → preterm L' l) :=\nbegin\n  intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},\n  { rw [hxy'] },\n  { rw [h.on_function hxy'] },\n  { congr1, exact x_ih_t hxy', exact x_ih_s hxy'' }\nend\n\nlemma on_formula_inj (h : ϕ.is_injective) {l} :\n  injective (ϕ.on_formula : preformula L l → preformula L' l) :=\nbegin\n  intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},\n  { refl },\n  { rw [on_term_inj h hxy', on_term_inj h hxy''] },\n  { rw [h.on_relation hxy'] },\n  { rw [x_ih hxy', on_term_inj h hxy''] },\n  { rw [x_ih_f₁ hxy', x_ih_f₂ hxy''] },\n  { rw [x_ih hxy'] }\nend\n\nlemma on_bounded_term_inj (h : ϕ.is_injective) {n} {l} : injective (ϕ.on_bounded_term : bounded_preterm L n l → bounded_preterm L' n l) :=\nbegin\n  intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},\n  { rw [hxy'] },\n  { rw [h.on_function hxy'] },\n  { congr1, exact x_ih_t hxy', exact x_ih_s hxy'' }\nend\n\nlemma on_bounded_formula_inj (h : ϕ.is_injective) {n l}:\n  injective (ϕ.on_bounded_formula : bounded_preformula L n l → bounded_preformula L' n l) :=\nbegin\n  intros x y hxy, induction x generalizing y; cases y; try {injection hxy with hxy' hxy''},\n  { refl },\n  { rw [on_bounded_term_inj h hxy', on_bounded_term_inj h hxy''] },\n  { rw [h.on_relation hxy'] },\n  { rw [x_ih hxy', on_bounded_term_inj h hxy''] },\n  { rw [x_ih_f₁ hxy', x_ih_f₂ hxy''] },\n  { rw [x_ih hxy'] }\nend\n\nvariable (ϕ)\n\n/-- Given L → L' and an L'-structure S, the reduct of S to L is the L-structure given by\nrestricting interpretations from L' to L --/\ndef reduct (S : Structure L') : Structure L :=\n⟨ S.carrier, λn f, S.fun_map $ ϕ.on_function f, λn R, S.rel_map $ ϕ.on_relation R⟩\n\nnotation S`[[`:95 ϕ`]]`:90 := reduct ϕ S\n\nvariable {ϕ}\n\n@[simp] def reduct_coe (S : Structure L') : ↥(reduct ϕ S) = S :=\nby refl\n\ndef reduct_id {S : Structure L'} : S → S[[ϕ]] := id\n\n@[simp] lemma reduct_term_eq {S : Structure L'} (hϕ : ϕ.is_injective) {n} :\n  Π(xs : dvector S n) {l} (t : bounded_preterm L n l) (xs' : dvector S l), realize_bounded_term xs (on_bounded_term ϕ t) xs' = @realize_bounded_term L (reduct ϕ S) n xs l t xs'\n| xs _ (bd_var k)   xs' := by refl\n| xs _ (bd_func f)  xs' := by refl\n| xs l (bd_app t s) xs' := by simp*\n\nlemma reduct_bounded_formula_iff {S : Structure L'} (hϕ : ϕ.is_injective) : Π{n l} (xs : dvector S n) (xs' : dvector S l) (f : bounded_preformula L n l),\n  realize_bounded_formula xs (on_bounded_formula ϕ f) xs' ↔ @realize_bounded_formula L (reduct ϕ S) n l xs f xs'\n| _ _ xs xs' (bd_falsum)      := by refl\n| _ _ xs xs' (bd_equal t₁ t₂) := by simp [hϕ]\n| _ _ xs xs' (bd_rel R)       := by refl\n| _ _ xs xs' (bd_apprel f t)  := by simp*\n| _ _ xs xs' (f₁ ⟹ f₂)       := by simp*\n| _ _ xs xs' (∀' f)           := by apply forall_congr; intro x;simp*\n\nlemma reduct_ssatisfied {S : Structure L'} {f : sentence L} (hϕ : ϕ.is_injective)\n (h : S ⊨ ϕ.on_sentence f) : ϕ.reduct S ⊨ f :=\n(reduct_bounded_formula_iff hϕ ([]) ([]) f).mp h\n\nlemma reduct_ssatisfied' {S : Structure L'} {f : sentence L} (hϕ : ϕ.is_injective)\n (h : S ⊨ ϕ.on_bounded_formula f) : ϕ.reduct S ⊨ f :=\n(reduct_bounded_formula_iff hϕ ([]) ([]) f).mp h\n\ndef reduct_all_ssatisfied {S : Structure L'} {T : Theory L} (hϕ : ϕ.is_injective)\n  (h : S ⊨ ϕ.on_sentence '' T) : S[[ϕ]] ⊨ T :=\nλf hf, reduct_ssatisfied hϕ $ h $ mem_image_of_mem _ hf\n\nlemma reduct_nonempty_of_nonempty {S : Structure L'} (H : nonempty S) : nonempty (reduct ϕ S) :=\nby {apply nonempty.map, repeat{assumption}, exact reduct_id}\n\nvariable (ϕ)\n@[reducible]def Theory_induced (T : Theory L) : Theory L' := ϕ.on_sentence '' T\n\nvariable {ϕ}\nlemma is_consistent_Theory_induced (hϕ : ϕ.is_injective) {T : Theory L} (hT : is_consistent T) :\n  is_consistent (ϕ.Theory_induced T) :=\nλH, hT $ H.map $ λh, reflect_sprf hϕ (by apply h)\n\n/- we could generalize this, replacing set.univ by any set s, but then we cannot use set.image\n  anymore (since the domain of g would be s), and things would be more annoying -/\nlemma is_consistent_extend {T : Theory L} (hT : is_consistent T) (hϕ : ϕ.is_injective)\n  (h : bounded_formula L 1 → bounded_formula L 1)\n  (hT' : ∀(f : bounded_formula L 1), T ⊢ ∃' (h f))\n  (g : bounded_formula L 1 → L'.constants) (hg : injective g)\n  (hg' : ∀x, g x ∉ range (@on_function L L' ϕ 0)) :\n  is_consistent (ϕ.Theory_induced T ∪\n  (λf, (ϕ.on_bounded_formula (h f))[bd_const (g f)/0]) '' set.univ) :=\nbegin\n  haveI : decidable_eq (bounded_formula L 1) := λx y, classical.prop_decidable _,\n  haveI : decidable_eq (sentence L') := λx y, classical.prop_decidable _,\n  have lem : ∀(s₀ : finset (bounded_formula L 1)),\n    is_consistent (ϕ.Theory_induced T ∪\n      (λf, (ϕ.on_bounded_formula (h f))[bd_const (g f)/0]) '' ↑s₀),\n  { refine finset.induction _ _,\n    { simp, exact is_consistent_Theory_induced hϕ hT },\n    { intros ψ s hψ ih hs, refine sprovable.elim _ hs, clear hs, intro hs, apply ih, constructor,\n      simp [image_insert_eq] at hs,\n      have : _ ⊢ (ϕ.on_bounded_formula $ ∼(h ψ))[bd_const (g ψ)/0] := simpI hs,\n      have := sgeneralize_constant (g ψ) _ _ this,\n      { refine simpE _ _ this, apply sweakening (subset_union_left _ _) (ϕ.on_sprf $ hT' ψ) },\n      { intro h', rcases h' with ⟨s', ⟨ψ', ⟨ψ', ⟨ψ', hψ₂, rfl⟩ | ⟨ψ', hψ₂, rfl⟩, rfl⟩, rfl⟩, hψ₃⟩,\n        { rw [ϕ.on_sentence_fst] at hψ₃,\n          exact ϕ.not_mem_function_in_formula_on_formula (hg' _) _ hψ₃ },\n        { simp at hψ₃,\n          cases symbols_in_formula_subst _ _ _ hψ₃ with hψ₄ hψ₄,\n          { exact ϕ.not_mem_function_in_formula_on_formula (hg' _) _ hψ₄ },\n          { injection eq_of_mem_singleton hψ₄ with hψ₅, injection hψ₅ with x hψ₆,\n            cases hg (eq_of_heq hψ₆), exact hψ hψ₂ }}},\n      { rw [on_bounded_formula_fst], apply not_mem_function_in_formula_on_formula, apply hg' }}},\n  intro H, rcases theory_proof_compactness H with ⟨T₀, h₀, hT⟩,\n  have : decidable_pred (∈ ϕ.Theory_induced T) := λx, classical.prop_decidable _,\n  rcases finset.subset_union_elim hT with ⟨t₀, s₀, rfl, ht₀, hs₀⟩,\n  have hs₀' := subset.trans hs₀ (diff_subset _ _),\n  rcases finset.subset_image_iff.mp hs₀' with ⟨s₀, hs₀x, rfl⟩,\n  apply lem s₀, refine h₀.map _, apply sweakening,\n  simp, refine subset.trans ht₀ _, simp\nend\n\nend Lhom\n\n\nend fol\n\n\n\n\n-- instance nonempty_Language_over : nonempty (Language_over) :=\n--   begin fapply nonempty.intro, exact ⟨L, language_id_morphism L⟩ end\n\n--TODO define map induced by a language_morphism on terms/preterms, formulas/preformulas, sets of formulas/theories\n", "meta": {"author": "flypitch", "repo": "flypitch", "sha": "aea5800db1f4cce53fc4a113711454b27388ecf8", "save_path": "github-repos/lean/flypitch-flypitch", "path": "github-repos/lean/flypitch-flypitch/flypitch-aea5800db1f4cce53fc4a113711454b27388ecf8/src/language_extension.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.49900139208871896}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Heather Macbeth, Sébastien Gouëzel\n-/\nimport analysis.calculus.times_cont_diff\nimport tactic.ring_exp\nimport analysis.normed_space.banach\nimport topology.local_homeomorph\n\n/-!\n# Inverse function theorem\n\nIn this file we prove the inverse function theorem. It says that if a map `f : E → F`\nhas an invertible strict derivative `f'` at `a`, then it is locally invertible,\nand the inverse function has derivative `f' ⁻¹`.\n\nWe define `has_strict_deriv_at.to_local_homeomorph` that repacks a function `f`\nwith a `hf : has_strict_fderiv_at f f' a`, `f' : E ≃L[𝕜] F`, into a `local_homeomorph`.\nThe `to_fun` of this `local_homeomorph` is `defeq` to `f`, so one can apply theorems\nabout `local_homeomorph` to `hf.to_local_homeomorph f`, and get statements about `f`.\n\nThen we define `has_strict_fderiv_at.local_inverse` to be the `inv_fun` of this `local_homeomorph`,\nand prove two versions of the inverse function theorem:\n\n* `has_strict_fderiv_at.to_local_inverse`: if `f` has an invertible derivative `f'` at `a` in the\n  strict sense (`hf`), then `hf.local_inverse f f' a` has derivative `f'.symm` at `f a` in the\n  strict sense;\n\n* `has_strict_fderiv_at.to_local_left_inverse`: if `f` has an invertible derivative `f'` at `a` in\n  the strict sense and `g` is locally left inverse to `f` near `a`, then `g` has derivative\n  `f'.symm` at `f a` in the strict sense.\n\nIn the one-dimensional case we reformulate these theorems in terms of `has_strict_deriv_at` and\n`f'⁻¹`.\n\nWe also reformulate the theorems in terms of `times_cont_diff`, to give that `C^k` (respectively,\nsmooth) inputs give `C^k` (smooth) inverses.  These versions require that continuous\ndifferentiability implies strict differentiability; this is false over a general field, true over\n`ℝ` or `ℂ` and implemented here assuming `is_R_or_C 𝕂`.\n\nSome related theorems, providing the derivative and higher regularity assuming that we already know\nthe inverse function, are formulated in `fderiv.lean`, `deriv.lean`, and `times_cont_diff.lean`.\n\n## Notations\n\nIn the section about `approximates_linear_on` we introduce some `local notation` to make formulas\nshorter:\n\n* by `N` we denote `∥f'⁻¹∥`;\n* by `g` we denote the auxiliary contracting map `x ↦ x + f'.symm (y - f x)` used to prove that\n  `{x | f x = y}` is nonempty.\n\n## Tags\n\nderivative, strictly differentiable, continuously differentiable, smooth, inverse function\n-/\n\nopen function set filter metric\nopen_locale topological_space classical nnreal\n\nnoncomputable theory\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\nvariables {E : Type*} [normed_group E] [normed_space 𝕜 E]\nvariables {F : Type*} [normed_group F] [normed_space 𝕜 F]\nvariables {G : Type*} [normed_group G] [normed_space 𝕜 G]\nvariables {G' : Type*} [normed_group G'] [normed_space 𝕜 G']\nvariables {ε : ℝ}\n\n\nopen asymptotics filter metric set\nopen continuous_linear_map (id)\n\n\n/-!\n### Non-linear maps close to affine maps\n\nIn this section we study a map `f` such that `∥f x - f y - f' (x - y)∥ ≤ c * ∥x - y∥` on an open set\n`s`, where `f' : E →L[𝕜] F` is a continuous linear map and `c` is suitably small. Maps of this type\nbehave like `f a + f' (x - a)` near each `a ∈ s`.\n\nWhen `f'` is onto, we show that `f` is locally onto.\n\nWhen `f'` is a continuous linear equiv, we show that `f` is a homeomorphism\nbetween `s` and `f '' s`. More precisely, we define `approximates_linear_on.to_local_homeomorph` to\nbe a `local_homeomorph` with `to_fun = f`, `source = s`, and `target = f '' s`.\n\nMaps of this type naturally appear in the proof of the inverse function theorem (see next section),\nand `approximates_linear_on.to_local_homeomorph` will imply that the locally inverse function\nexists.\n\nWe define this auxiliary notion to split the proof of the inverse function theorem into small\nlemmas. This approach makes it possible\n\n- to prove a lower estimate on the size of the domain of the inverse function;\n\n- to reuse parts of the proofs in the case if a function is not strictly differentiable. E.g., for a\n  function `f : E × F → G` with estimates on `f x y₁ - f x y₂` but not on `f x₁ y - f x₂ y`.\n-/\n\n/-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`,\nif `∥f x - f y - f' (x - y)∥ ≤ c * ∥x - y∥` whenever `x, y ∈ s`.\n\nThis predicate is defined to facilitate the splitting of the inverse function theorem into small\nlemmas. Some of these lemmas can be useful, e.g., to prove that the inverse function is defined\non a specific set. -/\ndef approximates_linear_on (f : E → F) (f' : E →L[𝕜] F) (s : set E) (c : ℝ≥0) : Prop :=\n∀ (x ∈ s) (y ∈ s), ∥f x - f y - f' (x - y)∥ ≤ c * ∥x - y∥\n\nnamespace approximates_linear_on\n\nvariables [cs : complete_space E] {f : E → F}\n\n/-! First we prove some properties of a function that `approximates_linear_on` a (not necessarily\ninvertible) continuous linear map. -/\n\nsection\n\nvariables {f' : E →L[𝕜] F} {s t : set E} {c c' : ℝ≥0}\n\ntheorem mono_num (hc : c ≤ c') (hf : approximates_linear_on f f' s c) :\n  approximates_linear_on f f' s c' :=\nλ x hx y hy, le_trans (hf x hx y hy) (mul_le_mul_of_nonneg_right hc $ norm_nonneg _)\n\ntheorem mono_set (hst : s ⊆ t) (hf : approximates_linear_on f f' t c) :\n  approximates_linear_on f f' s c :=\nλ x hx y hy, hf x (hst hx) y (hst hy)\n\nlemma lipschitz_sub (hf : approximates_linear_on f f' s c) :\n  lipschitz_with c (λ x : s, f x - f' x) :=\nbegin\n  refine lipschitz_with.of_dist_le_mul (λ x y, _),\n  rw [dist_eq_norm, subtype.dist_eq, dist_eq_norm],\n  convert hf x x.2 y y.2 using 2,\n  rw [f'.map_sub], abel\nend\n\nprotected lemma lipschitz (hf : approximates_linear_on f f' s c) :\n  lipschitz_with (nnnorm f' + c) (s.restrict f) :=\nby simpa only [restrict_apply, add_sub_cancel'_right]\n  using (f'.lipschitz.restrict s).add hf.lipschitz_sub\n\nprotected lemma continuous (hf : approximates_linear_on f f' s c) :\n  continuous (s.restrict f) :=\nhf.lipschitz.continuous\n\nprotected lemma continuous_on (hf : approximates_linear_on f f' s c) :\n  continuous_on f s :=\ncontinuous_on_iff_continuous_restrict.2 hf.continuous\n\nend\n\nsection locally_onto\n/-!\nWe prove that a function which is linearly approximated by a continuous linear map with a nonlinear\nright inverse is locally onto. This will apply to the case where the approximating map is a linear\nequivalence, for the local inverse theorem, but also whenever the approximating map is onto,\nby Banach's open mapping theorem. -/\n\ninclude cs\n\nvariables {s : set E} {c : ℝ≥0} {f' : E →L[𝕜] F}\n\n/-- If a function is linearly approximated by a continuous linear map with a (possibly nonlinear)\nright inverse, then it is locally onto: a ball of an explicit radius is included in the image\nof the map. -/\ntheorem surj_on_closed_ball_of_nonlinear_right_inverse\n  (hf : approximates_linear_on f f' s c)  (f'symm : f'.nonlinear_right_inverse)\n  {ε : ℝ} {b : E} (ε0 : 0 ≤ ε) (hε : closed_ball b ε ⊆ s) :\n  surj_on f (closed_ball b ε) (closed_ball (f b) (((f'symm.nnnorm : ℝ)⁻¹ - c) * ε)) :=\nbegin\n  assume y hy,\n  cases le_or_lt (f'symm.nnnorm : ℝ) ⁻¹ c with hc hc,\n  { refine ⟨b, by simp [ε0], _⟩,\n    have : dist y (f b) ≤ 0 :=\n      (mem_closed_ball.1 hy).trans (mul_nonpos_of_nonpos_of_nonneg (by linarith) ε0),\n    simp only [dist_le_zero] at this,\n    rw this },\n  have If' : (0 : ℝ) < f'symm.nnnorm,\n    by { rw [← inv_pos], exact (nnreal.coe_nonneg _).trans_lt hc },\n  have Icf' : (c : ℝ) * f'symm.nnnorm < 1, by rwa [inv_eq_one_div, lt_div_iff If'] at hc,\n  have Jf' : (f'symm.nnnorm : ℝ) ≠ 0 := ne_of_gt If',\n  have Jcf' : (1 : ℝ) - c * f'symm.nnnorm ≠ 0, by { apply ne_of_gt, linarith },\n  /- We have to show that `y` can be written as `f x` for some `x ∈ closed_ball b ε`.\n  The idea of the proof is to apply the Banach contraction principle to the map\n  `g : x ↦ x + f'symm (y - f x)`, as a fixed point of this map satisfies `f x = y`.\n  When `f'symm` is a genuine linear inverse, `g` is a contracting map. In our case, since `f'symm`\n  is nonlinear, this map is not contracting (it is not even continuous), but still the proof of\n  the contraction theorem holds: `uₙ = gⁿ b` is a Cauchy sequence, converging exponentially fast\n  to the desired point `x`. Instead of appealing to general results, we check this by hand.\n\n  The main point is that `f (u n)` becomes exponentially close to `y`, and therefore\n  `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive\n  bound on `dist (u n) b`, from which one checks that `u n` stays in the ball on which one has a\n  control. Therefore, the bound can be checked at the next step, and so on inductively.\n  -/\n  set g := λ x, x + f'symm (y - f x) with hg,\n  set u := λ (n : ℕ), g ^[n] b with hu,\n  have usucc : ∀ n, u (n + 1) = g (u n), by simp [hu, ← iterate_succ_apply' g _ b],\n  -- First bound: if `f z` is close to `y`, then `g z` is close to `z` (i.e., almost a fixed point).\n  have A : ∀ z, dist (g z) z ≤ f'symm.nnnorm * dist (f z) y,\n  { assume z,\n    rw [dist_eq_norm, hg, add_sub_cancel', dist_eq_norm'],\n    exact f'symm.bound _ },\n  -- Second bound: if `z` and `g z` are in the set with good control, then `f (g z)` becomes closer\n  -- to `y` than `f z` was (this uses the linear approximation property, and is the reason for the\n  -- choice of the formula for `g`).\n  have B : ∀ z ∈ closed_ball b ε, g z ∈ closed_ball b ε →\n    dist (f (g z)) y ≤ c * f'symm.nnnorm * dist (f z) y,\n  { assume z hz hgz,\n    set v := f'symm (y - f z) with hv,\n    calc dist (f (g z)) y = ∥f (z + v) - y∥ : by rw [dist_eq_norm]\n    ... = ∥f (z + v) - f  z - f' v + f' v - (y - f z)∥ : by { congr' 1, abel }\n    ... = ∥f (z + v) - f z - f' ((z + v) - z)∥ :\n      by simp only [continuous_linear_map.nonlinear_right_inverse.right_inv,\n                    add_sub_cancel', sub_add_cancel]\n    ... ≤ c * ∥(z + v) - z∥ : hf _ (hε hgz) _ (hε hz)\n    ... ≤ c * (f'symm.nnnorm * dist (f z) y) : begin\n      apply mul_le_mul_of_nonneg_left _ (nnreal.coe_nonneg c),\n      simpa [hv, dist_eq_norm'] using f'symm.bound (y - f z),\n    end\n    ... = c * f'symm.nnnorm * dist (f z) y : by ring },\n  -- Third bound: a complicated bound on `dist w b` (that will show up in the induction) is enough\n  -- to check that `w` is in the ball on which one has controls. Will be used to check that `u n`\n  -- belongs to this ball for all `n`.\n  have C : ∀ (n : ℕ) (w : E),\n    dist w b ≤ f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y\n    → w ∈ closed_ball b ε,\n  { assume n w hw,\n    apply hw.trans,\n    rw [div_mul_eq_mul_div, div_le_iff], swap, { linarith },\n    calc (f'symm.nnnorm : ℝ) * (1 - (c * f'symm.nnnorm) ^ n) * dist (f b) y\n      = f'symm.nnnorm * dist (f b) y * (1 - (c * f'symm.nnnorm) ^ n) : by ring\n      ... ≤ f'symm.nnnorm * dist (f b) y * 1 :\n      begin\n        apply mul_le_mul_of_nonneg_left _ (mul_nonneg (nnreal.coe_nonneg _) dist_nonneg),\n        rw [sub_le_self_iff],\n        exact pow_nonneg (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _)) _,\n      end\n    ... ≤ f'symm.nnnorm * (((f'symm.nnnorm : ℝ)⁻¹ - c) * ε) :\n      by { rw [mul_one],\n           exact mul_le_mul_of_nonneg_left (mem_closed_ball'.1 hy) (nnreal.coe_nonneg _) }\n    ... = ε * (1 - c * f'symm.nnnorm) : by { field_simp, ring } },\n  /- Main inductive control: `f (u n)` becomes exponentially close to `y`, and therefore\n  `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive\n  bound on `dist (u n) b`, from which one checks that `u n` remains in the ball on which we\n  have estimates. -/\n  have D : ∀ (n : ℕ), dist (f (u n)) y ≤ (c * f'symm.nnnorm)^n * dist (f b) y\n    ∧ dist (u n) b ≤ f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm)\n      * dist (f b) y,\n  { assume n,\n    induction n with n IH, { simp [hu, le_refl] },\n    rw usucc,\n    have Ign : dist (g (u n)) b ≤\n      f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n.succ) / (1 - c * f'symm.nnnorm) * dist (f b) y :=\n    calc\n      dist (g (u n)) b ≤ dist (g (u n)) (u n) + dist (u n) b : dist_triangle _ _ _\n      ... ≤ f'symm.nnnorm * dist (f (u n)) y + dist (u n) b : add_le_add (A _) (le_refl _)\n      ... ≤ f'symm.nnnorm * ((c * f'symm.nnnorm)^n * dist (f b) y) +\n        f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y :\n          add_le_add (mul_le_mul_of_nonneg_left IH.1 (nnreal.coe_nonneg _)) IH.2\n      ... = f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n.succ) / (1 - c * f'symm.nnnorm)\n        * dist (f b) y : by { field_simp [Jcf'], ring_exp },\n    refine ⟨_, Ign⟩,\n    calc dist (f (g (u n))) y ≤ c * f'symm.nnnorm * dist (f (u n)) y :\n      B _ (C n _ IH.2) (C n.succ _ Ign)\n    ... ≤ (c * f'symm.nnnorm) * ((c * f'symm.nnnorm)^n * dist (f b) y) :\n      mul_le_mul_of_nonneg_left IH.1 (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _))\n    ... = (c * f'symm.nnnorm) ^ n.succ * dist (f b) y : by ring_exp },\n  -- Deduce from the inductive bound that `uₙ` is a Cauchy sequence, therefore converging.\n  have : cauchy_seq u,\n  { have : ∀ (n : ℕ), dist (u n) (u (n+1)) ≤ f'symm.nnnorm * dist (f b) y * (c * f'symm.nnnorm)^n,\n    { assume n,\n      calc dist (u n) (u (n+1)) = dist (g (u n)) (u n) :  by rw [usucc, dist_comm]\n      ... ≤ f'symm.nnnorm * dist (f (u n)) y : A _\n      ... ≤ f'symm.nnnorm * ((c * f'symm.nnnorm)^n * dist (f b) y) :\n        mul_le_mul_of_nonneg_left (D n).1 (nnreal.coe_nonneg _)\n      ... = f'symm.nnnorm * dist (f b) y * (c * f'symm.nnnorm)^n : by ring },\n    exact cauchy_seq_of_le_geometric _ _ Icf' this },\n  obtain ⟨x, hx⟩ : ∃ x, tendsto u at_top (𝓝 x) := cauchy_seq_tendsto_of_complete this,\n  -- As all the `uₙ` belong to the ball `closed_ball b ε`, so does their limit `x`.\n  have xmem : x ∈ closed_ball b ε :=\n    is_closed_ball.mem_of_tendsto hx (eventually_of_forall (λ n, C n _ (D n).2)),\n  refine ⟨x, xmem, _⟩,\n  -- It remains to check that `f x = y`. This follows from continuity of `f` on `closed_ball b ε`\n  -- and from the fact that `f uₙ` is converging to `y` by construction.\n  have hx' : tendsto u at_top (𝓝[closed_ball b ε] x),\n  { simp only [nhds_within, tendsto_inf, hx, true_and, ge_iff_le, tendsto_principal],\n    exact eventually_of_forall (λ n, C n _ (D n).2) },\n  have T1 : tendsto (λ n, f (u n)) at_top (𝓝 (f x)) :=\n    (hf.continuous_on.mono hε x xmem).tendsto.comp hx',\n  have T2 : tendsto (λ n, f (u n)) at_top (𝓝 y),\n  { rw tendsto_iff_dist_tendsto_zero,\n    refine squeeze_zero (λ n, dist_nonneg) (λ n, (D n).1) _,\n    simpa using (tendsto_pow_at_top_nhds_0_of_lt_1\n      (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _)) Icf').mul tendsto_const_nhds },\n  exact tendsto_nhds_unique T1 T2,\nend\n\nlemma open_image (hf : approximates_linear_on f f' s c)  (f'symm : f'.nonlinear_right_inverse)\n  (hs : is_open s) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) : is_open (f '' s) :=\nbegin\n  cases hc with hE hc, { resetI, apply is_open_discrete },\n  simp only [is_open_iff_mem_nhds, nhds_basis_closed_ball.mem_iff, ball_image_iff] at hs ⊢,\n  intros x hx,\n  rcases hs x hx with ⟨ε, ε0, hε⟩,\n  refine ⟨(f'symm.nnnorm⁻¹ - c) * ε, mul_pos (sub_pos.2 hc) ε0, _⟩,\n  exact (hf.surj_on_closed_ball_of_nonlinear_right_inverse f'symm (le_of_lt ε0) hε).mono\n    hε (subset.refl _)\nend\n\nlemma image_mem_nhds (hf : approximates_linear_on f f' s c) (f'symm : f'.nonlinear_right_inverse)\n  {x : E} (hs : s ∈ 𝓝 x) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) :\n  f '' s ∈ 𝓝 (f x) :=\nbegin\n  obtain ⟨t, hts, ht, xt⟩ : ∃ t ⊆ s, is_open t ∧ x ∈ t := _root_.mem_nhds_iff.1 hs,\n  have := is_open.mem_nhds ((hf.mono_set hts).open_image f'symm ht hc) (mem_image_of_mem _ xt),\n  exact mem_of_superset this (image_subset _ hts),\nend\n\nlemma map_nhds_eq (hf : approximates_linear_on f f' s c) (f'symm : f'.nonlinear_right_inverse)\n  {x : E} (hs : s ∈ 𝓝 x) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) :\n  map f (𝓝 x) = 𝓝 (f x) :=\nbegin\n  refine le_antisymm ((hf.continuous_on x (mem_of_mem_nhds hs)).continuous_at hs)\n    (le_map (λ t ht, _)),\n  have : f '' (s ∩ t) ∈ 𝓝 (f x) := (hf.mono_set (inter_subset_left s t)).image_mem_nhds\n    f'symm (inter_mem hs ht) hc,\n  exact mem_of_superset this (image_subset _ (inter_subset_right _ _)),\nend\n\nend locally_onto\n\n/-!\nFrom now on we assume that `f` approximates an invertible continuous linear map `f : E ≃L[𝕜] F`.\n\nWe also assume that either `E = {0}`, or `c < ∥f'⁻¹∥⁻¹`. We use `N` as an abbreviation for `∥f'⁻¹∥`.\n-/\n\nvariables {f' : E ≃L[𝕜] F} {s : set E} {c : ℝ≥0}\n\nlocal notation `N` := nnnorm (f'.symm : F →L[𝕜] E)\n\nprotected lemma antilipschitz (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  antilipschitz_with (N⁻¹ - c)⁻¹ (s.restrict f) :=\nbegin\n  cases hc with hE hc,\n  { haveI : subsingleton s := ⟨λ x y, subtype.eq $ @subsingleton.elim _ hE _ _⟩,\n    exact antilipschitz_with.of_subsingleton },\n  convert (f'.antilipschitz.restrict s).add_lipschitz_with hf.lipschitz_sub hc,\n  simp [restrict]\nend\n\nprotected lemma injective (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  injective (s.restrict f) :=\n(hf.antilipschitz hc).injective\n\nprotected lemma inj_on (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  inj_on f s :=\ninj_on_iff_injective.2 $ hf.injective hc\n\n/-- A map approximating a linear equivalence on a set defines a local equivalence on this set.\nShould not be used outside of this file, because it is superseded by `to_local_homeomorph` below.\n\nThis is a first step towards the inverse function. -/\ndef to_local_equiv (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) : local_equiv E F :=\n(hf.inj_on hc).to_local_equiv _ _\n\n/-- The inverse function is continuous on `f '' s`. Use properties of `local_homeomorph` instead. -/\nlemma inverse_continuous_on (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  continuous_on (hf.to_local_equiv hc).symm (f '' s) :=\nbegin\n  apply continuous_on_iff_continuous_restrict.2,\n  refine ((hf.antilipschitz hc).to_right_inv_on' _ (hf.to_local_equiv hc).right_inv').continuous,\n  exact (λ x hx, (hf.to_local_equiv hc).map_target hx)\nend\n\ninclude cs\n\nsection\nvariables (f s)\n\n/-- Given a function `f` that approximates a linear equivalence on an open set `s`,\nreturns a local homeomorph with `to_fun = f` and `source = s`. -/\ndef to_local_homeomorph (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) : local_homeomorph E F :=\n{ to_local_equiv := hf.to_local_equiv hc,\n  open_source := hs,\n  open_target := hf.open_image f'.to_nonlinear_right_inverse hs\n    (by rwa f'.to_linear_equiv.to_equiv.subsingleton_congr at hc),\n  continuous_to_fun := hf.continuous_on,\n  continuous_inv_fun := hf.inverse_continuous_on hc }\n\nend\n\n@[simp] lemma to_local_homeomorph_coe (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs : E → F) = f := rfl\n\n@[simp] lemma to_local_homeomorph_source (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs).source = s := rfl\n\n@[simp] lemma to_local_homeomorph_target (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs).target = f '' s := rfl\n\nlemma closed_ball_subset_target (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) {b : E} (ε0 : 0 ≤ ε) (hε : closed_ball b ε ⊆ s) :\n  closed_ball (f b) ((N⁻¹ - c) * ε) ⊆ (hf.to_local_homeomorph f s hc hs).target :=\n(hf.surj_on_closed_ball_of_nonlinear_right_inverse f'.to_nonlinear_right_inverse\n  ε0 hε).mono hε (subset.refl _)\n\nend approximates_linear_on\n\n/-!\n### Inverse function theorem\n\nNow we prove the inverse function theorem. Let `f : E → F` be a map defined on a complete vector\nspace `E`. Assume that `f` has an invertible derivative `f' : E ≃L[𝕜] F` at `a : E` in the strict\nsense. Then `f` approximates `f'` in the sense of `approximates_linear_on` on an open neighborhood\nof `a`, and we can apply `approximates_linear_on.to_local_homeomorph` to construct the inverse\nfunction. -/\n\nnamespace has_strict_fderiv_at\n\n/-- If `f` has derivative `f'` at `a` in the strict sense and `c > 0`, then `f` approximates `f'`\nwith constant `c` on some neighborhood of `a`. -/\nlemma approximates_deriv_on_nhds {f : E → F} {f' : E →L[𝕜] F} {a : E}\n  (hf : has_strict_fderiv_at f f' a) {c : ℝ≥0} (hc : subsingleton E ∨ 0 < c) :\n  ∃ s ∈ 𝓝 a, approximates_linear_on f f' s c :=\nbegin\n  cases hc with hE hc,\n  { refine ⟨univ, is_open.mem_nhds is_open_univ trivial, λ x hx y hy, _⟩,\n    simp [@subsingleton.elim E hE x y] },\n  have := hf.def hc,\n  rw [nhds_prod_eq, filter.eventually, mem_prod_same_iff] at this,\n  rcases this with ⟨s, has, hs⟩,\n  exact ⟨s, has, λ x hx y hy, hs (mk_mem_prod hx hy)⟩\nend\n\nlemma map_nhds_eq_of_surj [complete_space E] [complete_space F]\n  {f : E → F} {f' : E →L[𝕜] F} {a : E}\n  (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) (h : f'.range = ⊤) :\n  map f (𝓝 a) = 𝓝 (f a) :=\nbegin\n  let f'symm := f'.nonlinear_right_inverse_of_surjective h,\n  set c : ℝ≥0 := f'symm.nnnorm⁻¹ / 2 with hc,\n  have f'symm_pos : 0 < f'symm.nnnorm := f'.nonlinear_right_inverse_of_surjective_nnnorm_pos h,\n  have cpos : 0 < c, by simp [hc, nnreal.half_pos, nnreal.inv_pos, f'symm_pos],\n  obtain ⟨s, s_nhds, hs⟩ : ∃ s ∈ 𝓝 a, approximates_linear_on f f' s c :=\n    hf.approximates_deriv_on_nhds (or.inr cpos),\n  apply hs.map_nhds_eq f'symm s_nhds (or.inr (nnreal.half_lt_self _)),\n  simp [ne_of_gt f'symm_pos],\nend\n\nvariables [cs : complete_space E] {f : E → F} {f' : E ≃L[𝕜] F} {a : E}\n\nlemma approximates_deriv_on_open_nhds (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∃ (s : set E) (hs : a ∈ s ∧ is_open s),\n    approximates_linear_on f (f' : E →L[𝕜] F) s ((nnnorm (f'.symm : F →L[𝕜] E))⁻¹ / 2) :=\nbegin\n  refine ((nhds_basis_opens a).exists_iff _).1 _,\n  exact (λ s t, approximates_linear_on.mono_set),\n  exact (hf.approximates_deriv_on_nhds $ f'.subsingleton_or_nnnorm_symm_pos.imp id $\n    λ hf', nnreal.half_pos $ nnreal.inv_pos.2 $ hf')\nend\n\ninclude cs\n\nvariable (f)\n\n/-- Given a function with an invertible strict derivative at `a`, returns a `local_homeomorph`\nwith `to_fun = f` and `a ∈ source`. This is a part of the inverse function theorem.\nThe other part `has_strict_fderiv_at.to_local_inverse` states that the inverse function\nof this `local_homeomorph` has derivative `f'.symm`. -/\ndef to_local_homeomorph (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) : local_homeomorph E F :=\napproximates_linear_on.to_local_homeomorph f\n  (classical.some hf.approximates_deriv_on_open_nhds)\n  (classical.some_spec hf.approximates_deriv_on_open_nhds).snd\n  (f'.subsingleton_or_nnnorm_symm_pos.imp id $ λ hf', nnreal.half_lt_self $ ne_of_gt $\n    nnreal.inv_pos.2 $ hf')\n  (classical.some_spec hf.approximates_deriv_on_open_nhds).fst.2\n\nvariable {f}\n\n@[simp] lemma to_local_homeomorph_coe (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  (hf.to_local_homeomorph f : E → F) = f := rfl\n\nlemma mem_to_local_homeomorph_source (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  a ∈ (hf.to_local_homeomorph f).source :=\n(classical.some_spec hf.approximates_deriv_on_open_nhds).fst.1\n\nlemma image_mem_to_local_homeomorph_target (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  f a ∈ (hf.to_local_homeomorph f).target :=\n(hf.to_local_homeomorph f).map_source hf.mem_to_local_homeomorph_source\n\nlemma map_nhds_eq_of_equiv (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  map f (𝓝 a) = 𝓝 (f a) :=\n(hf.to_local_homeomorph f).map_nhds_eq hf.mem_to_local_homeomorph_source\n\nvariables (f f' a)\n\n/-- Given a function `f` with an invertible derivative, returns a function that is locally inverse\nto `f`. -/\ndef local_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) : F → E :=\n(hf.to_local_homeomorph f).symm\n\nvariables {f f' a}\n\nlemma local_inverse_def (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  hf.local_inverse f _ _ = (hf.to_local_homeomorph f).symm :=\nrfl\n\nlemma eventually_left_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∀ᶠ x in 𝓝 a, hf.local_inverse f f' a (f x) = x :=\n(hf.to_local_homeomorph f).eventually_left_inverse hf.mem_to_local_homeomorph_source\n\n@[simp] \n\nlemma eventually_right_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∀ᶠ y in 𝓝 (f a), f (hf.local_inverse f f' a y) = y :=\n(hf.to_local_homeomorph f).eventually_right_inverse' hf.mem_to_local_homeomorph_source\n\nlemma local_inverse_continuous_at (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  continuous_at (hf.local_inverse f f' a) (f a) :=\n(hf.to_local_homeomorph f).continuous_at_symm hf.image_mem_to_local_homeomorph_target\n\nlemma local_inverse_tendsto (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  tendsto (hf.local_inverse f f' a) (𝓝 $ f a) (𝓝 a) :=\n(hf.to_local_homeomorph f).tendsto_symm hf.mem_to_local_homeomorph_source\n\nlemma local_inverse_unique (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) {g : F → E}\n  (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  ∀ᶠ y in 𝓝 (f a), g y = local_inverse f f' a hf y :=\neventually_eq_of_left_inv_of_right_inv hg hf.eventually_right_inverse $\n  (hf.to_local_homeomorph f).tendsto_symm hf.mem_to_local_homeomorph_source\n\n/-- If `f` has an invertible derivative `f'` at `a` in the sense of strict differentiability `(hf)`,\nthen the inverse function `hf.local_inverse f` has derivative `f'.symm` at `f a`. -/\ntheorem to_local_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  has_strict_fderiv_at (hf.local_inverse f f' a) (f'.symm : F →L[𝕜] E) (f a) :=\n(hf.to_local_homeomorph f).has_strict_fderiv_at_symm hf.image_mem_to_local_homeomorph_target $\n  by simpa [← local_inverse_def] using hf\n\n/-- If `f : E → F` has an invertible derivative `f'` at `a` in the sense of strict differentiability\nand `g (f x) = x` in a neighborhood of `a`, then `g` has derivative `f'.symm` at `f a`.\n\nFor a version assuming `f (g y) = y` and continuity of `g` at `f a` but not `[complete_space E]`\nsee `of_local_left_inverse`.  -/\ntheorem to_local_left_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) {g : F → E}\n  (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  has_strict_fderiv_at g (f'.symm : F →L[𝕜] E) (f a) :=\nhf.to_local_inverse.congr_of_eventually_eq $ (hf.local_inverse_unique hg).mono $ λ _, eq.symm\n\nend has_strict_fderiv_at\n\n/-- If a function has an invertible strict derivative at all points, then it is an open map. -/\nlemma open_map_of_strict_fderiv_equiv [complete_space E] {f : E → F} {f' : E → E ≃L[𝕜] F}\n  (hf : ∀ x, has_strict_fderiv_at f (f' x : E →L[𝕜] F) x) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ λ x, (hf x).map_nhds_eq_of_equiv.ge\n\n/-!\n### Inverse function theorem, 1D case\n\nIn this case we prove a version of the inverse function theorem for maps `f : 𝕜 → 𝕜`.\nWe use `continuous_linear_equiv.units_equiv_aut` to translate `has_strict_deriv_at f f' a` and\n`f' ≠ 0` into `has_strict_fderiv_at f (_ : 𝕜 ≃L[𝕜] 𝕜) a`.\n-/\n\nnamespace has_strict_deriv_at\n\nvariables [cs : complete_space 𝕜] {f : 𝕜 → 𝕜} {f' a : 𝕜} (hf : has_strict_deriv_at f f' a)\n  (hf' : f' ≠ 0)\n\ninclude cs\n\nvariables (f f' a)\n\n/-- A function that is inverse to `f` near `a`. -/\n@[reducible] def local_inverse : 𝕜 → 𝕜 :=\n(hf.has_strict_fderiv_at_equiv hf').local_inverse _ _ _\n\nvariables {f f' a}\n\nlemma map_nhds_eq : map f (𝓝 a) = 𝓝 (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').map_nhds_eq_of_equiv\n\ntheorem to_local_inverse : has_strict_deriv_at (hf.local_inverse f f' a hf') f'⁻¹ (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_inverse\n\ntheorem to_local_left_inverse {g : 𝕜 → 𝕜} (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  has_strict_deriv_at g f'⁻¹ (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_left_inverse hg\n\nend has_strict_deriv_at\n\n/-- If a function has a non-zero strict derivative at all points, then it is an open map. -/\nlemma open_map_of_strict_deriv [complete_space 𝕜] {f f' : 𝕜 → 𝕜}\n  (hf : ∀ x, has_strict_deriv_at f (f' x) x) (h0 : ∀ x, f' x ≠ 0) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ λ x, ((hf x).map_nhds_eq (h0 x)).ge\n\n/-!\n### Inverse function theorem, smooth case\n\n-/\n\nnamespace times_cont_diff_at\nvariables {𝕂 : Type*} [is_R_or_C 𝕂]\nvariables {E' : Type*} [normed_group E'] [normed_space 𝕂 E']\nvariables {F' : Type*} [normed_group F'] [normed_space 𝕂 F']\nvariables [complete_space E'] (f : E' → F') {f' : E' ≃L[𝕂] F'} {a : E'}\n\n/-- Given a `times_cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible\nderivative at `a`, returns a `local_homeomorph` with `to_fun = f` and `a ∈ source`. -/\ndef to_local_homeomorph\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  local_homeomorph E' F' :=\n(hf.has_strict_fderiv_at' hf' hn).to_local_homeomorph f\n\nvariable {f}\n\n@[simp] lemma to_local_homeomorph_coe\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  (hf.to_local_homeomorph f hf' hn : E' → F') = f := rfl\n\nlemma mem_to_local_homeomorph_source\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  a ∈ (hf.to_local_homeomorph f hf' hn).source :=\n(hf.has_strict_fderiv_at' hf' hn).mem_to_local_homeomorph_source\n\nlemma image_mem_to_local_homeomorph_target\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  f a ∈ (hf.to_local_homeomorph f hf' hn).target :=\n(hf.has_strict_fderiv_at' hf' hn).image_mem_to_local_homeomorph_target\n\n/-- Given a `times_cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible derivative\nat `a`, returns a function that is locally inverse to `f`. -/\ndef local_inverse\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  F' → E' :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse f f' a\n\nlemma local_inverse_apply_image\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  hf.local_inverse hf' hn (f a) = a :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse_apply_image\n\n/-- Given a `times_cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible derivative\nat `a`, the inverse function (produced by `times_cont_diff.to_local_homeomorph`) is\nalso `times_cont_diff`. -/\nlemma to_local_inverse\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  times_cont_diff_at 𝕂 n (hf.local_inverse hf' hn) (f a) :=\nbegin\n  have := hf.local_inverse_apply_image hf' hn,\n  apply (hf.to_local_homeomorph f hf' hn).times_cont_diff_at_symm\n    (image_mem_to_local_homeomorph_target hf hf' hn),\n  { convert hf' },\n  { convert hf }\nend\n\nend times_cont_diff_at\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/calculus/inverse.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.4990013888102211}}
{"text": "/-\nCopyright (c) 2020 Kevin Buzzard\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, and whoever else wants to join in.\n-/\n\n -- need the definition of an affine alg set\nimport affine_algebraic_set.basic\n\n -- need so I can state that the kernel of the evaluation map is 𝕀\nimport affine_algebraic_set.I\n\n/-!\n\n# Regular functions\n\nLet k be a field (or even an integral domain), and let V be an\naffine algebraic subset of 𝔸ⁿ (where n can even be infinite).\nA _regular function_ on V is a function V → k which is induced\nby some polynomial F ∈ k[X₁, X₂, …, Xₙ]. Note that F itself\nis not part of the data, and a regular function can be induced\nby more than one polynomial in general.\n\n-/\n\n-- I think it might all work with commutative semirings but\n-- let's let k be a commutative ring.\nvariables {k : Type*} [comm_ring k] {n : Type*}\n\nlocal notation `𝔸ⁿ` := n → k\nlocal notation `k[n]` := mv_polynomial n k\n\n-- The idea: a mathematician shouldn't need to look at most of this file.\n-- The plan would be that they just read the API in the comments above. \n\n-- They just need to know the API. \n\n-- Throughout this file, let V ⊆ 𝔸ⁿ be an affine algebraic subset.\nvariable {V : affine_algebraic_set k n}\n\nlocal notation `subset_of` := set\n\nopen mv_polynomial\n\ndef is_regular2 (f : (V : subset_of 𝔸ⁿ) → k) : Prop :=\n  ∃ F : k[n], ∀ (x : 𝔸ⁿ) (hx : x ∈ V), F.eval x = f ⟨x, hx⟩\n\ndef is_regular (f : (V : subset_of 𝔸ⁿ) → k) : Prop :=\n  ∃ F : k[n], ∀ (x : (V : subset_of 𝔸ⁿ)), F.eval x = f x\n\n/-- A \"regular function\" is a pair: a function V → k, and a proof that\nit comes from a polynomial -/\nstructure regular_fun (V : affine_algebraic_set k n) :=\n(to_fun : {x : 𝔸ⁿ // x ∈ (V : subset_of 𝔸ⁿ)} → k)\n(is_regular' : is_regular to_fun)\n\nlocal notation `k[V]` := regular_fun V\n\nnamespace regular_fun\n\n/-- A regular function on V can be regarded as a function from V to k -/\ninstance : has_coe_to_fun (k[V]) :=\n⟨_, regular_fun.to_fun⟩\n\nvariable {V}\n\n/-- A regular function is induced from a polynomial -/\nlemma is_regular (f : k[V]): ∃ F : k[n],\n   ∀ (x : (V : subset_of 𝔸ⁿ)), F.eval x = f x := f.is_regular'\n\nvariable (V)\n\ndef mk' (V : affine_algebraic_set k n) (F : k[n]) : regular_fun V :=\n{ to_fun := λ x, F.eval x, -- i.e. F(x)\n  is_regular' := ⟨F, λ x, rfl⟩ }\n\nvariable {V}\n\ndef mk'.some_spec (F : k[n]) (x : (V : subset_of 𝔸ⁿ)) :\n  (classical.some (mk' V F).is_regular).eval x = _ := classical.some_spec (mk' V F).is_regular x\n\n\n\n/- Two regular functions are equal if and only if their\n underlying functions V → k are equal -/\n@[ext] lemma ext (f g : k[V]) : (f : (V : set 𝔸ⁿ) → k) = g → f = g :=\nbegin\n  intro h,\n  cases f,\n  cases g,\n  congr',\nend\n\n/-- The iff is also sometimes helpful-/\nlemma ext_iff (f g : k[V]) : f = g ↔ (f : (V : set 𝔸ⁿ) → k) = g :=\n⟨λ h, h ▸ rfl, ext f g⟩\n\n-- We prove the regular functions are naturally a ring.\n\ndef zero : k[V] :=\n{ to_fun := λ x, 0,\n  is_regular' := begin\n    -- the function V → k sending everything to zero is a regular function\n    use 0,\n    intros,\n    rw eval_zero,  \n  end\n}\n\ninstance : has_zero (k[V]) := ⟨zero⟩\n\ndef one : k[V] :=\n{ to_fun := λ x, 1,\n  is_regular' := begin\n    -- the function V → k sending everything to zero is a regular function\n    use 1,\n    intros,\n    rw eval_one,  \n  end\n}\n\ninstance : has_one (k[V]) := ⟨one⟩\n\ndef add (f g : k[V]) : k[V] :=\n{ to_fun := λ x, f x + g x,\n  is_regular' := begin\n    -- sum of two regular functions is regular\n    cases f.is_regular with F hF,\n    cases g.is_regular with G hG,\n    use F + G,\n    intro x,\n    rw eval_add,\n    rw hF,\n    rw hG,\n  end\n}\n\ninstance : has_add (k[V]) := ⟨add⟩\n\ndef neg (f : k[V]) : k[V] :=\n{ to_fun := λ x, -(f x),\n  is_regular' := begin\n    -- additive inverse of a regular function is regular\n    cases f.is_regular with F hF,\n    use -F,\n    intro x,\n    rw eval_neg,\n    rw hF,\n  end\n}\n\ninstance : has_neg (k[V]) := ⟨neg⟩\n\ndef mul (f g : k[V]) : k[V] :=\n{ to_fun := λ x, (f x) * (g x),\n  is_regular' := begin\n    -- additive inverse of a regular function is regular\n    cases f.is_regular with F hF,\n    cases g.is_regular with G hG,\n    use F * G,\n    intro x,\n    rw eval_mul,\n    rw hF,\n    rw hG,\n  end\n}\n\ninstance : has_mul (k[V]) := ⟨mul⟩\n\ninstance : comm_ring (k[V]) :=\n{ add := (+),\n  add_assoc := begin intros f g h, ext, apply add_assoc, end,\n  zero := 0,\n  zero_add := begin intro f, ext, apply zero_add, end,\n  add_zero := begin intro f, ext, apply add_zero, end,\n  neg := has_neg.neg,\n  add_left_neg := begin intro f, ext, apply add_left_neg, end,\n  add_comm := begin intros f g, ext, apply add_comm, end,\n  mul := (*),\n  mul_assoc := begin intros f g h, ext, apply mul_assoc, end,\n  one := 1,\n  one_mul := begin intro f, ext, apply one_mul, end,\n  mul_one := begin intro f, ext, apply mul_one, end,\n  left_distrib := begin intros f g h, ext, apply left_distrib, end,\n  right_distrib := begin intros f g h, ext, apply right_distrib, end,\n  mul_comm := begin intros f g, ext, apply mul_comm, end }\n\nend regular_fun\n\n/-- The ring homomorphism from k[X₁, X₂, …, Xₙ] to k[V] -/\nnoncomputable def mv_polynomial.to_regular_fun : mv_polynomial n k →+* k[V] :=\n{ to_fun := λ F,\n  { to_fun := λ x, F.eval x.1,\n    is_regular' := ⟨F, λ x, rfl⟩\n  },\n  -- proof that it's a ring homomorphism\n  map_one' := begin\n    ext,\n    apply eval_one,\n  end,\n  map_mul' := begin\n    intros f g,\n    ext,\n    apply eval_mul,\n  end,\n  map_zero' := begin\n    ext,\n    unfold_coes, dsimp,\n    apply eval_zero,\n  end,\n  map_add' := begin\n    intros f g,\n    ext,\n    apply eval_add,\n  end\n}\n\nnamespace regular_fun\n\ninstance : has_scalar k k[V] :=\n{ smul := λ t f,\n  { to_fun := λ v, t * f v,\n    is_regular' := begin\n      cases f.is_regular with F hF,\n      use (C t) * F,\n      intro x,\n      rw [eval_mul, eval_C, hF]\n    end\n  }\n}\n\ninstance : is_ring_hom (λ t, mk' V (C t)) :=\n{ map_one := begin\n    ext x,\n    unfold_coes,\n    unfold mk',\n    dsimp,\n    rw eval_one,\n    refl,\n  end,\n  map_mul := \n  begin\n    intros s t,\n    ext x,\n    unfold_coes,\n    unfold mk', \n    dsimp,\n    rw eval_C,\n    simp [eval_C],\n    refl,\n  end,\n  map_add := \n  begin\n    intros s t,\n    ext x,\n    unfold_coes,\n    unfold mk',\n    dsimp,\n    simp [eval_C],\n    refl\n  end\n}.\n\nnoncomputable instance : algebra k k[V] :=\n{ to_fun := (λ t, mk' V (C t)),\n  hom := by apply_instance,\n  commutes' := begin\n    intros r x,\n    apply mul_comm,\n  end,\n  smul_def' := begin\n    intros r f,\n    ext x,\n    show _ = mk' V (C r) x * f x,\n    unfold_coes,\n    unfold mk',\n    simp only [eval_C],\n    refl,\n  end\n}\nend regular_fun\n\nopen mv_polynomial function\n\nlemma mv_polynomial.to_regular_fun.surjective :\n  surjective\n    ((to_regular_fun : mv_polynomial n k →+* k[V]) : mv_polynomial n k → k[V]) :=\nbegin\n  intro f,\n  cases f.is_regular with F hF,\n  use F,\n  ext x,\n  rw ←hF x,\n  refl,\nend\n\nopen affine_algebraic_set\n\nlemma to_regular_fun.mem_kernel (F : mv_polynomial n k) :\n  ((to_regular_fun : mv_polynomial n k →+* k[V]) : mv_polynomial n k → k[V]) F = 0\n  ↔ F ∈ 𝕀 V :=\nbegin\n  rw mem_𝕀_iff,\n  rw regular_fun.ext_iff,\n  rw funext_iff,\n  split, -- sigh\n  { intros f x hx, exact f ⟨x, hx⟩},\n  { intros f x, exact f x.1 x.2}\nend\n\n-- let's prove it's a k-algebra hom\nnoncomputable def mv_polynomial.to_regular_fun_algebra_map : k[n] →ₐ[k] k[V] :=\n{ to_fun := to_regular_fun.to_fun,\n  map_one' := begin\n    ext x,\n    cases x with x hx,\n    exact eval_one x\n  end,\n  map_mul' := begin\n    intros f g,\n    ext x,\n    exact eval_mul,\n  end,\n  map_zero' := begin\n    ext x,\n    cases x with x hx,\n    convert @eval_zero _ _ _ x,\n  end,\n  map_add' := begin\n    intros f g,\n    ext x,\n    exact eval_add,\n  end,\n  commutes' := begin\n    intro s,\n    refl,\n  end }\n\n/-\nTODO -- ask on Zulip why f is implicit and x explicit (note the trouble this caused me in map_zero')\n\nmv_polynomial.eval_one : ∀ {X : Type u_2} {R : Type u_1} [_inst_1 : comm_semiring R] (x : X → R), eval x 1 = 1\nmv_polynomial.eval_zero : ∀ {α : Type ?} {n : Type ?} [_inst_1 : comm_semiring α] {f : n → α}, eval f 0 = 0\n-/\n", "meta": {"author": "ImperialCollegeLondon", "repo": "M4P33", "sha": "1a179372db71ad6802d11eacbc1f02f327d55f8f", "save_path": "github-repos/lean/ImperialCollegeLondon-M4P33", "path": "github-repos/lean/ImperialCollegeLondon-M4P33/M4P33-1a179372db71ad6802d11eacbc1f02f327d55f8f/src/affine_algebraic_set/regular_function.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4990013793690751}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard,\nAmelia Livingston, Yury Kudryashov\n\n! This file was ported from Lean 3 source module group_theory.submonoid.basic\n! leanprover-community/mathlib commit feb99064803fd3108e37c18b0f77d0a8344677a3\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Hom.Group\nimport Mathbin.Algebra.Group.Units\nimport Mathbin.GroupTheory.Subsemigroup.Basic\n\n/-!\n# Submonoids: definition and `complete_lattice` structure\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines bundled multiplicative and additive submonoids. We also define\na `complete_lattice` structure on `submonoid`s, define the closure of a set as the minimal submonoid\nthat includes this set, and prove a few results about extending properties from a dense set (i.e.\na set with `closure s = ⊤`) to the whole monoid, see `submonoid.dense_induction` and\n`monoid_hom.of_mclosure_eq_top_left`/`monoid_hom.of_mclosure_eq_top_right`.\n\n## Main definitions\n\n* `submonoid M`: the type of bundled submonoids of a monoid `M`; the underlying set is given in\n  the `carrier` field of the structure, and should be accessed through coercion as in `(S : set M)`.\n* `add_submonoid M` : the type of bundled submonoids of an additive monoid `M`.\n\nFor each of the following definitions in the `submonoid` namespace, there is a corresponding\ndefinition in the `add_submonoid` namespace.\n\n* `submonoid.copy` : copy of a submonoid with `carrier` replaced by a set that is equal but possibly\n  not definitionally equal to the carrier of the original `submonoid`.\n* `submonoid.closure` :  monoid closure of a set, i.e., the least submonoid that includes the set.\n* `submonoid.gi` : `closure : set M → submonoid M` and coercion `coe : submonoid M → set M`\n  form a `galois_insertion`;\n* `monoid_hom.eq_mlocus`: the submonoid of elements `x : M` such that `f x = g x`;\n* `monoid_hom.of_mclosure_eq_top_right`:  if a map `f : M → N` between two monoids satisfies\n  `f 1 = 1` and `f (x * y) = f x * f y` for `y` from some dense set `s`, then `f` is a monoid\n  homomorphism. E.g., if `f : ℕ → M` satisfies `f 0 = 0` and `f (x + 1) = f x + f 1`, then `f` is\n  an additive monoid homomorphism.\n\n## Implementation notes\n\nSubmonoid inclusion is denoted `≤` rather than `⊆`, although `∈` is defined as\nmembership of a submonoid's underlying set.\n\nNote that `submonoid M` does not actually require `monoid M`, instead requiring only the weaker\n`mul_one_class M`.\n\nThis file is designed to have very few dependencies. In particular, it should not use natural\nnumbers. `submonoid` is implemented by extending `subsemigroup` requiring `one_mem'`.\n\n## Tags\nsubmonoid, submonoids\n-/\n\n\n-- Only needed for notation\n-- Only needed for notation\nvariable {M : Type _} {N : Type _}\n\nvariable {A : Type _}\n\nsection NonAssoc\n\nvariable [MulOneClass M] {s : Set M}\n\nvariable [AddZeroClass A] {t : Set A}\n\n#print OneMemClass /-\n/-- `one_mem_class S M` says `S` is a type of subsets `s ≤ M`, such that `1 ∈ s` for all `s`. -/\nclass OneMemClass (S M : Type _) [One M] [SetLike S M] : Prop where\n  one_mem : ∀ s : S, (1 : M) ∈ s\n#align one_mem_class OneMemClass\n-/\n\nexport OneMemClass (one_mem)\n\n#print ZeroMemClass /-\n/-- `zero_mem_class S M` says `S` is a type of subsets `s ≤ M`, such that `0 ∈ s` for all `s`. -/\nclass ZeroMemClass (S M : Type _) [Zero M] [SetLike S M] : Prop where\n  zero_mem : ∀ s : S, (0 : M) ∈ s\n#align zero_mem_class ZeroMemClass\n-/\n\nexport ZeroMemClass (zero_mem)\n\nattribute [to_additive] OneMemClass\n\nsection\n\n#print Submonoid /-\n/-- A submonoid of a monoid `M` is a subset containing 1 and closed under multiplication. -/\nstructure Submonoid (M : Type _) [MulOneClass M] extends Subsemigroup M where\n  one_mem' : (1 : M) ∈ carrier\n#align submonoid Submonoid\n-/\n\nend\n\n/-- A submonoid of a monoid `M` can be considered as a subsemigroup of that monoid. -/\nadd_decl_doc Submonoid.toSubsemigroup\n\n#print SubmonoidClass /-\n/-- `submonoid_class S M` says `S` is a type of subsets `s ≤ M` that contain `1`\nand are closed under `(*)` -/\nclass SubmonoidClass (S M : Type _) [MulOneClass M] [SetLike S M] extends MulMemClass S M,\n  OneMemClass S M : Prop\n#align submonoid_class SubmonoidClass\n-/\n\nsection\n\n#print AddSubmonoid /-\n/-- An additive submonoid of an additive monoid `M` is a subset containing 0 and\n  closed under addition. -/\nstructure AddSubmonoid (M : Type _) [AddZeroClass M] extends AddSubsemigroup M where\n  zero_mem' : (0 : M) ∈ carrier\n#align add_submonoid AddSubmonoid\n-/\n\nend\n\n/-- An additive submonoid of an additive monoid `M` can be considered as an\nadditive subsemigroup of that additive monoid. -/\nadd_decl_doc AddSubmonoid.toAddSubsemigroup\n\n#print AddSubmonoidClass /-\n/-- `add_submonoid_class S M` says `S` is a type of subsets `s ≤ M` that contain `0`\nand are closed under `(+)` -/\nclass AddSubmonoidClass (S M : Type _) [AddZeroClass M] [SetLike S M] extends AddMemClass S M,\n  ZeroMemClass S M : Prop\n#align add_submonoid_class AddSubmonoidClass\n-/\n\nattribute [to_additive] Submonoid SubmonoidClass\n\n/- warning: pow_mem -> pow_mem is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_3 : Monoid.{u1} M] {A : Type.{u2}} [_inst_4 : SetLike.{u2, u1} A M] [_inst_5 : SubmonoidClass.{u2, u1} A M (Monoid.toMulOneClass.{u1} M _inst_3) _inst_4] {S : A} {x : M}, (Membership.Mem.{u1, u2} M A (SetLike.hasMem.{u2, u1} A M _inst_4) x S) -> (forall (n : Nat), Membership.Mem.{u1, u2} M A (SetLike.hasMem.{u2, u1} A M _inst_4) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_3)) x n) S)\nbut is expected to have type\n  forall {M : Type.{u2}} {_inst_3 : Type.{u1}} [A : Monoid.{u2} M] [_inst_4 : SetLike.{u1, u2} _inst_3 M] [_inst_5 : SubmonoidClass.{u1, u2} _inst_3 M (Monoid.toMulOneClass.{u2} M A) _inst_4] {S : _inst_3} {x : M}, (Membership.mem.{u2, u1} M _inst_3 (SetLike.instMembership.{u1, u2} _inst_3 M _inst_4) x S) -> (forall (n : Nat), Membership.mem.{u2, u1} M _inst_3 (SetLike.instMembership.{u1, u2} _inst_3 M _inst_4) (HPow.hPow.{u2, 0, u2} M Nat M (instHPow.{u2, 0} M Nat (Monoid.Pow.{u2} M A)) x n) S)\nCase conversion may be inaccurate. Consider using '#align pow_mem pow_memₓ'. -/\n@[to_additive]\ntheorem pow_mem {M} [Monoid M] {A : Type _} [SetLike A M] [SubmonoidClass A M] {S : A} {x : M}\n    (hx : x ∈ S) : ∀ n : ℕ, x ^ n ∈ S\n  | 0 => by\n    rw [pow_zero]\n    exact OneMemClass.one_mem S\n  | n + 1 => by\n    rw [pow_succ]\n    exact MulMemClass.mul_mem hx (pow_mem n)\n#align pow_mem pow_mem\n#align nsmul_mem nsmul_mem\n\nnamespace Submonoid\n\n@[to_additive]\ninstance : SetLike (Submonoid M) M\n    where\n  coe := Submonoid.carrier\n  coe_injective' p q h := by cases p <;> cases q <;> congr\n\n@[to_additive]\ninstance : SubmonoidClass (Submonoid M) M\n    where\n  one_mem := Submonoid.one_mem'\n  mul_mem := Submonoid.mul_mem'\n\n/-- See Note [custom simps projection] -/\n@[to_additive \" See Note [custom simps projection]\"]\ndef Simps.coe (S : Submonoid M) : Set M :=\n  S\n#align submonoid.simps.coe Submonoid.Simps.coe\n#align add_submonoid.simps.coe AddSubmonoid.Simps.coe\n\ninitialize_simps_projections Submonoid (carrier → coe)\n\ninitialize_simps_projections AddSubmonoid (carrier → coe)\n\n/- warning: submonoid.mem_carrier -> Submonoid.mem_carrier is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Submonoid.{u1} M _inst_1} {x : M}, Iff (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x (Submonoid.carrier.{u1} M _inst_1 s)) (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x s)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Submonoid.{u1} M _inst_1} {x : M}, Iff (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (Subsemigroup.carrier.{u1} M (MulOneClass.toMul.{u1} M _inst_1) (Submonoid.toSubsemigroup.{u1} M _inst_1 s))) (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_carrier Submonoid.mem_carrierₓ'. -/\n@[simp, to_additive]\ntheorem mem_carrier {s : Submonoid M} {x : M} : x ∈ s.carrier ↔ x ∈ s :=\n  Iff.rfl\n#align submonoid.mem_carrier Submonoid.mem_carrier\n#align add_submonoid.mem_carrier AddSubmonoid.mem_carrier\n\n/- warning: submonoid.mem_mk -> Submonoid.mem_mk is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {x : M} (h_one : forall {a : M} {b : M}, (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) a s) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) b s) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) a b) s)) (h_mul : Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))) s), Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Submonoid.mk.{u1} M _inst_1 s h_one h_mul)) (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x s)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {x : M} (h_one : s (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))) (h_mul : forall {a : M} {b : M}, (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) a s) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) b s) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) a b) s)), Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Submonoid.mk.{u1} M _inst_1 (Subsemigroup.mk.{u1} M (MulOneClass.toMul.{u1} M _inst_1) s h_mul) h_one)) (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s)\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_mk Submonoid.mem_mkₓ'. -/\n@[simp, to_additive]\ntheorem mem_mk {s : Set M} {x : M} (h_one) (h_mul) : x ∈ mk s h_one h_mul ↔ x ∈ s :=\n  Iff.rfl\n#align submonoid.mem_mk Submonoid.mem_mk\n#align add_submonoid.mem_mk AddSubmonoid.mem_mk\n\n/- warning: submonoid.coe_set_mk -> Submonoid.coe_set_mk is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} (h_one : forall {a : M} {b : M}, (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) a s) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) b s) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) a b) s)) (h_mul : Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))) s), Eq.{succ u1} (Set.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.mk.{u1} M _inst_1 s h_one h_mul)) s\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} (h_one : s (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))) (h_mul : forall {a : M} {b : M}, (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) a s) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) b s) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) a b) s)), Eq.{succ u1} (Set.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Submonoid.mk.{u1} M _inst_1 (Subsemigroup.mk.{u1} M (MulOneClass.toMul.{u1} M _inst_1) s h_mul) h_one)) s\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_set_mk Submonoid.coe_set_mkₓ'. -/\n@[simp, to_additive]\ntheorem coe_set_mk {s : Set M} (h_one) (h_mul) : (mk s h_one h_mul : Set M) = s :=\n  rfl\n#align submonoid.coe_set_mk Submonoid.coe_set_mk\n#align add_submonoid.coe_set_mk AddSubmonoid.coe_set_mk\n\n/- warning: submonoid.mk_le_mk -> Submonoid.mk_le_mk is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {t : Set.{u1} M} (h_one : forall {a : M} {b : M}, (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) a s) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) b s) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) a b) s)) (h_mul : Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))) s) (h_one' : forall {a : M} {b : M}, (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) a t) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) b t) -> (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) a b) t)) (h_mul' : Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))) t), Iff (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.mk.{u1} M _inst_1 s h_one h_mul) (Submonoid.mk.{u1} M _inst_1 t h_one' h_mul')) (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s t)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {t : Set.{u1} M} (h_one : s (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))) (h_mul : forall {a : M} {b : M}, (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) a s) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) b s) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) a b) s)) (h_one' : t (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))) (h_mul' : forall {a : M} {b : M}, (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) a t) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) b t) -> (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) a b) t)), Iff (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.instPartialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)))) (Submonoid.mk.{u1} M _inst_1 (Subsemigroup.mk.{u1} M (MulOneClass.toMul.{u1} M _inst_1) s h_mul) h_one) (Submonoid.mk.{u1} M _inst_1 (Subsemigroup.mk.{u1} M (MulOneClass.toMul.{u1} M _inst_1) t h_mul') h_one')) (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s t)\nCase conversion may be inaccurate. Consider using '#align submonoid.mk_le_mk Submonoid.mk_le_mkₓ'. -/\n@[simp, to_additive]\ntheorem mk_le_mk {s t : Set M} (h_one) (h_mul) (h_one') (h_mul') :\n    mk s h_one h_mul ≤ mk t h_one' h_mul' ↔ s ⊆ t :=\n  Iff.rfl\n#align submonoid.mk_le_mk Submonoid.mk_le_mk\n#align add_submonoid.mk_le_mk AddSubmonoid.mk_le_mk\n\n/- warning: submonoid.ext -> Submonoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Submonoid.{u1} M _inst_1} {T : Submonoid.{u1} M _inst_1}, (forall (x : M), Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x S) (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x T)) -> (Eq.{succ u1} (Submonoid.{u1} M _inst_1) S T)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Submonoid.{u1} M _inst_1} {T : Submonoid.{u1} M _inst_1}, (forall (x : M), Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x S) (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x T)) -> (Eq.{succ u1} (Submonoid.{u1} M _inst_1) S T)\nCase conversion may be inaccurate. Consider using '#align submonoid.ext Submonoid.extₓ'. -/\n/-- Two submonoids are equal if they have the same elements. -/\n@[ext, to_additive \"Two `add_submonoid`s are equal if they have the same elements.\"]\ntheorem ext {S T : Submonoid M} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=\n  SetLike.ext h\n#align submonoid.ext Submonoid.ext\n#align add_submonoid.ext AddSubmonoid.ext\n\n/- warning: submonoid.copy -> Submonoid.copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1) (s : Set.{u1} M), (Eq.{succ u1} (Set.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S)) -> (Submonoid.{u1} M _inst_1)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1) (s : Set.{u1} M), (Eq.{succ u1} (Set.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) S)) -> (Submonoid.{u1} M _inst_1)\nCase conversion may be inaccurate. Consider using '#align submonoid.copy Submonoid.copyₓ'. -/\n/-- Copy a submonoid replacing `carrier` with a set that is equal to it. -/\n@[to_additive \"Copy an additive submonoid replacing `carrier` with a set that is equal to it.\"]\nprotected def copy (S : Submonoid M) (s : Set M) (hs : s = S) : Submonoid M\n    where\n  carrier := s\n  one_mem' := hs.symm ▸ S.one_mem'\n  mul_mem' _ _ := hs.symm ▸ S.mul_mem'\n#align submonoid.copy Submonoid.copy\n#align add_submonoid.copy AddSubmonoid.copy\n\nvariable {S : Submonoid M}\n\n/- warning: submonoid.coe_copy -> Submonoid.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Submonoid.{u1} M _inst_1} {s : Set.{u1} M} (hs : Eq.{succ u1} (Set.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S)), Eq.{succ u1} (Set.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.copy.{u1} M _inst_1 S s hs)) s\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Submonoid.{u1} M _inst_1} {s : Set.{u1} M} (hs : Eq.{succ u1} (Set.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) S)), Eq.{succ u1} (Set.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Submonoid.copy.{u1} M _inst_1 S s hs)) s\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_copy Submonoid.coe_copyₓ'. -/\n@[simp, to_additive]\ntheorem coe_copy {s : Set M} (hs : s = S) : (S.copy s hs : Set M) = s :=\n  rfl\n#align submonoid.coe_copy Submonoid.coe_copy\n#align add_submonoid.coe_copy AddSubmonoid.coe_copy\n\n/- warning: submonoid.copy_eq -> Submonoid.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Submonoid.{u1} M _inst_1} {s : Set.{u1} M} (hs : Eq.{succ u1} (Set.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.copy.{u1} M _inst_1 S s hs) S\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Submonoid.{u1} M _inst_1} {s : Set.{u1} M} (hs : Eq.{succ u1} (Set.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) S)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.copy.{u1} M _inst_1 S s hs) S\nCase conversion may be inaccurate. Consider using '#align submonoid.copy_eq Submonoid.copy_eqₓ'. -/\n@[to_additive]\ntheorem copy_eq {s : Set M} (hs : s = S) : S.copy s hs = S :=\n  SetLike.coe_injective hs\n#align submonoid.copy_eq Submonoid.copy_eq\n#align add_submonoid.copy_eq AddSubmonoid.copy_eq\n\nvariable (S)\n\n/- warning: submonoid.one_mem -> Submonoid.one_mem is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1), Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))) S\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1), Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1))) S\nCase conversion may be inaccurate. Consider using '#align submonoid.one_mem Submonoid.one_memₓ'. -/\n/-- A submonoid contains the monoid's 1. -/\n@[to_additive \"An `add_submonoid` contains the monoid's 0.\"]\nprotected theorem one_mem : (1 : M) ∈ S :=\n  one_mem S\n#align submonoid.one_mem Submonoid.one_mem\n#align add_submonoid.zero_mem AddSubmonoid.zero_mem\n\n/- warning: submonoid.mul_mem -> Submonoid.mul_mem is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1) {x : M} {y : M}, (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x S) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) y S) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y) S)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1) {x : M} {y : M}, (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x S) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) y S) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) x y) S)\nCase conversion may be inaccurate. Consider using '#align submonoid.mul_mem Submonoid.mul_memₓ'. -/\n/-- A submonoid is closed under multiplication. -/\n@[to_additive \"An `add_submonoid` is closed under addition.\"]\nprotected theorem mul_mem {x y : M} : x ∈ S → y ∈ S → x * y ∈ S :=\n  mul_mem\n#align submonoid.mul_mem Submonoid.mul_mem\n#align add_submonoid.add_mem AddSubmonoid.add_mem\n\n/-- The submonoid `M` of the monoid `M`. -/\n@[to_additive \"The additive submonoid `M` of the `add_monoid M`.\"]\ninstance : Top (Submonoid M) :=\n  ⟨{  carrier := Set.univ\n      one_mem' := Set.mem_univ 1\n      mul_mem' := fun _ _ _ _ => Set.mem_univ _ }⟩\n\n/-- The trivial submonoid `{1}` of an monoid `M`. -/\n@[to_additive \"The trivial `add_submonoid` `{0}` of an `add_monoid` `M`.\"]\ninstance : Bot (Submonoid M) :=\n  ⟨{  carrier := {1}\n      one_mem' := Set.mem_singleton 1\n      mul_mem' := fun a b ha hb =>\n        by\n        simp only [Set.mem_singleton_iff] at *\n        rw [ha, hb, mul_one] }⟩\n\n@[to_additive]\ninstance : Inhabited (Submonoid M) :=\n  ⟨⊥⟩\n\n/- warning: submonoid.mem_bot -> Submonoid.mem_bot is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {x : M}, Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Bot.bot.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasBot.{u1} M _inst_1))) (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {x : M}, Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Bot.bot.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instBotSubmonoid.{u1} M _inst_1))) (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_bot Submonoid.mem_botₓ'. -/\n@[simp, to_additive]\ntheorem mem_bot {x : M} : x ∈ (⊥ : Submonoid M) ↔ x = 1 :=\n  Set.mem_singleton_iff\n#align submonoid.mem_bot Submonoid.mem_bot\n#align add_submonoid.mem_bot AddSubmonoid.mem_bot\n\n/- warning: submonoid.mem_top -> Submonoid.mem_top is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (x : M), Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasTop.{u1} M _inst_1))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (x : M), Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instTopSubmonoid.{u1} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_top Submonoid.mem_topₓ'. -/\n@[simp, to_additive]\ntheorem mem_top (x : M) : x ∈ (⊤ : Submonoid M) :=\n  Set.mem_univ x\n#align submonoid.mem_top Submonoid.mem_top\n#align add_submonoid.mem_top AddSubmonoid.mem_top\n\n/- warning: submonoid.coe_top -> Submonoid.coe_top is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Set.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasTop.{u1} M _inst_1))) (Set.univ.{u1} M)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Set.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instTopSubmonoid.{u1} M _inst_1))) (Set.univ.{u1} M)\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_top Submonoid.coe_topₓ'. -/\n@[simp, to_additive]\ntheorem coe_top : ((⊤ : Submonoid M) : Set M) = Set.univ :=\n  rfl\n#align submonoid.coe_top Submonoid.coe_top\n#align add_submonoid.coe_top AddSubmonoid.coe_top\n\n/- warning: submonoid.coe_bot -> Submonoid.coe_bot is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Set.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Bot.bot.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasBot.{u1} M _inst_1))) (Singleton.singleton.{u1, u1} M (Set.{u1} M) (Set.hasSingleton.{u1} M) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Set.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Bot.bot.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instBotSubmonoid.{u1} M _inst_1))) (Singleton.singleton.{u1, u1} M (Set.{u1} M) (Set.instSingletonSet.{u1} M) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_bot Submonoid.coe_botₓ'. -/\n@[simp, to_additive]\ntheorem coe_bot : ((⊥ : Submonoid M) : Set M) = {1} :=\n  rfl\n#align submonoid.coe_bot Submonoid.coe_bot\n#align add_submonoid.coe_bot AddSubmonoid.coe_bot\n\n/-- The inf of two submonoids is their intersection. -/\n@[to_additive \"The inf of two `add_submonoid`s is their intersection.\"]\ninstance : Inf (Submonoid M) :=\n  ⟨fun S₁ S₂ =>\n    { carrier := S₁ ∩ S₂\n      one_mem' := ⟨S₁.one_mem, S₂.one_mem⟩\n      mul_mem' := fun _ _ ⟨hx, hx'⟩ ⟨hy, hy'⟩ => ⟨S₁.mul_mem hx hy, S₂.mul_mem hx' hy'⟩ }⟩\n\n/- warning: submonoid.coe_inf -> Submonoid.coe_inf is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (p : Submonoid.{u1} M _inst_1) (p' : Submonoid.{u1} M _inst_1), Eq.{succ u1} (Set.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Inf.inf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) p p')) (Inter.inter.{u1} (Set.{u1} M) (Set.hasInter.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) p) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) p'))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (p : Submonoid.{u1} M _inst_1) (p' : Submonoid.{u1} M _inst_1), Eq.{succ u1} (Set.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Inf.inf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSubmonoid.{u1} M _inst_1) p p')) (Inter.inter.{u1} (Set.{u1} M) (Set.instInterSet.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) p) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) p'))\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_inf Submonoid.coe_infₓ'. -/\n@[simp, to_additive]\ntheorem coe_inf (p p' : Submonoid M) : ((p ⊓ p' : Submonoid M) : Set M) = p ∩ p' :=\n  rfl\n#align submonoid.coe_inf Submonoid.coe_inf\n#align add_submonoid.coe_inf AddSubmonoid.coe_inf\n\n/- warning: submonoid.mem_inf -> Submonoid.mem_inf is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p : Submonoid.{u1} M _inst_1} {p' : Submonoid.{u1} M _inst_1} {x : M}, Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Inf.inf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) p p')) (And (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x p) (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x p'))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p : Submonoid.{u1} M _inst_1} {p' : Submonoid.{u1} M _inst_1} {x : M}, Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Inf.inf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSubmonoid.{u1} M _inst_1) p p')) (And (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x p) (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x p'))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_inf Submonoid.mem_infₓ'. -/\n@[simp, to_additive]\ntheorem mem_inf {p p' : Submonoid M} {x : M} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=\n  Iff.rfl\n#align submonoid.mem_inf Submonoid.mem_inf\n#align add_submonoid.mem_inf AddSubmonoid.mem_inf\n\n@[to_additive]\ninstance : InfSet (Submonoid M) :=\n  ⟨fun s =>\n    { carrier := ⋂ t ∈ s, ↑t\n      one_mem' := Set.mem_binterᵢ fun i h => i.one_mem\n      mul_mem' := fun x y hx hy =>\n        Set.mem_binterᵢ fun i h =>\n          i.mul_mem (by apply Set.mem_interᵢ₂.1 hx i h) (by apply Set.mem_interᵢ₂.1 hy i h) }⟩\n\n/- warning: submonoid.coe_Inf -> Submonoid.coe_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Set.{u1} (Submonoid.{u1} M _inst_1)), Eq.{succ u1} (Set.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (InfSet.infₛ.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) S)) (Set.interᵢ.{u1, succ u1} M (Submonoid.{u1} M _inst_1) (fun (s : Submonoid.{u1} M _inst_1) => Set.interᵢ.{u1, 0} M (Membership.Mem.{u1, u1} (Submonoid.{u1} M _inst_1) (Set.{u1} (Submonoid.{u1} M _inst_1)) (Set.hasMem.{u1} (Submonoid.{u1} M _inst_1)) s S) (fun (H : Membership.Mem.{u1, u1} (Submonoid.{u1} M _inst_1) (Set.{u1} (Submonoid.{u1} M _inst_1)) (Set.hasMem.{u1} (Submonoid.{u1} M _inst_1)) s S) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) s)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Set.{u1} (Submonoid.{u1} M _inst_1)), Eq.{succ u1} (Set.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (InfSet.infₛ.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSetSubmonoid.{u1} M _inst_1) S)) (Set.interᵢ.{u1, succ u1} M (Submonoid.{u1} M _inst_1) (fun (s : Submonoid.{u1} M _inst_1) => Set.interᵢ.{u1, 0} M (Membership.mem.{u1, u1} (Submonoid.{u1} M _inst_1) (Set.{u1} (Submonoid.{u1} M _inst_1)) (Set.instMembershipSet.{u1} (Submonoid.{u1} M _inst_1)) s S) (fun (H : Membership.mem.{u1, u1} (Submonoid.{u1} M _inst_1) (Set.{u1} (Submonoid.{u1} M _inst_1)) (Set.instMembershipSet.{u1} (Submonoid.{u1} M _inst_1)) s S) => SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) s)))\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_Inf Submonoid.coe_infₛₓ'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_infₛ (S : Set (Submonoid M)) : ((infₛ S : Submonoid M) : Set M) = ⋂ s ∈ S, ↑s :=\n  rfl\n#align submonoid.coe_Inf Submonoid.coe_infₛ\n#align add_submonoid.coe_Inf AddSubmonoid.coe_infₛ\n\n/- warning: submonoid.mem_Inf -> Submonoid.mem_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Set.{u1} (Submonoid.{u1} M _inst_1)} {x : M}, Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (InfSet.infₛ.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) S)) (forall (p : Submonoid.{u1} M _inst_1), (Membership.Mem.{u1, u1} (Submonoid.{u1} M _inst_1) (Set.{u1} (Submonoid.{u1} M _inst_1)) (Set.hasMem.{u1} (Submonoid.{u1} M _inst_1)) p S) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x p))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {S : Set.{u1} (Submonoid.{u1} M _inst_1)} {x : M}, Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (InfSet.infₛ.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSetSubmonoid.{u1} M _inst_1) S)) (forall (p : Submonoid.{u1} M _inst_1), (Membership.mem.{u1, u1} (Submonoid.{u1} M _inst_1) (Set.{u1} (Submonoid.{u1} M _inst_1)) (Set.instMembershipSet.{u1} (Submonoid.{u1} M _inst_1)) p S) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x p))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_Inf Submonoid.mem_infₛₓ'. -/\n@[to_additive]\ntheorem mem_infₛ {S : Set (Submonoid M)} {x : M} : x ∈ infₛ S ↔ ∀ p ∈ S, x ∈ p :=\n  Set.mem_interᵢ₂\n#align submonoid.mem_Inf Submonoid.mem_infₛ\n#align add_submonoid.mem_Inf AddSubmonoid.mem_infₛ\n\n/- warning: submonoid.mem_infi -> Submonoid.mem_infᵢ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} {S : ι -> (Submonoid.{u1} M _inst_1)} {x : M}, Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (infᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) ι (fun (i : ι) => S i))) (forall (i : ι), Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (S i))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} {S : ι -> (Submonoid.{u1} M _inst_1)} {x : M}, Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (infᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSetSubmonoid.{u1} M _inst_1) ι (fun (i : ι) => S i))) (forall (i : ι), Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (S i))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_infi Submonoid.mem_infᵢₓ'. -/\n@[to_additive]\ntheorem mem_infᵢ {ι : Sort _} {S : ι → Submonoid M} {x : M} : (x ∈ ⨅ i, S i) ↔ ∀ i, x ∈ S i := by\n  simp only [infᵢ, mem_Inf, Set.forall_range_iff]\n#align submonoid.mem_infi Submonoid.mem_infᵢ\n#align add_submonoid.mem_infi AddSubmonoid.mem_infᵢ\n\n/- warning: submonoid.coe_infi -> Submonoid.coe_infᵢ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} {S : ι -> (Submonoid.{u1} M _inst_1)}, Eq.{succ u1} (Set.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (infᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) ι (fun (i : ι) => S i))) (Set.interᵢ.{u1, u2} M ι (fun (i : ι) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (S i)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} {S : ι -> (Submonoid.{u1} M _inst_1)}, Eq.{succ u1} (Set.{u1} M) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (infᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSetSubmonoid.{u1} M _inst_1) ι (fun (i : ι) => S i))) (Set.interᵢ.{u1, u2} M ι (fun (i : ι) => SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (S i)))\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_infi Submonoid.coe_infᵢₓ'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_infᵢ {ι : Sort _} {S : ι → Submonoid M} : (↑(⨅ i, S i) : Set M) = ⋂ i, S i := by\n  simp only [infᵢ, coe_Inf, Set.binterᵢ_range]\n#align submonoid.coe_infi Submonoid.coe_infᵢ\n#align add_submonoid.coe_infi AddSubmonoid.coe_infᵢ\n\n/-- Submonoids of a monoid form a complete lattice. -/\n@[to_additive \"The `add_submonoid`s of an `add_monoid` form a complete lattice.\"]\ninstance : CompleteLattice (Submonoid M) :=\n  {\n    completeLatticeOfInf (Submonoid M) fun s =>\n      IsGLB.of_image (fun S T => show (S : Set M) ≤ T ↔ S ≤ T from SetLike.coe_subset_coe)\n        isGLB_binfᵢ with\n    le := (· ≤ ·)\n    lt := (· < ·)\n    bot := ⊥\n    bot_le := fun S x hx => (mem_bot.1 hx).symm ▸ S.one_mem\n    top := ⊤\n    le_top := fun S x hx => mem_top x\n    inf := (· ⊓ ·)\n    infₛ := InfSet.infₛ\n    le_inf := fun a b c ha hb x hx => ⟨ha hx, hb hx⟩\n    inf_le_left := fun a b x => And.left\n    inf_le_right := fun a b x => And.right }\n\n#print Submonoid.subsingleton_iff /-\n@[simp, to_additive]\ntheorem subsingleton_iff : Subsingleton (Submonoid M) ↔ Subsingleton M :=\n  ⟨fun h =>\n    ⟨fun x y =>\n      have : ∀ i : M, i = 1 := fun i =>\n        mem_bot.mp <| Subsingleton.elim (⊤ : Submonoid M) ⊥ ▸ mem_top i\n      (this x).trans (this y).symm⟩,\n    fun h =>\n    ⟨fun x y => Submonoid.ext fun i => Subsingleton.elim 1 i ▸ by simp [Submonoid.one_mem]⟩⟩\n#align submonoid.subsingleton_iff Submonoid.subsingleton_iff\n#align add_submonoid.subsingleton_iff AddSubmonoid.subsingleton_iff\n-/\n\n#print Submonoid.nontrivial_iff /-\n@[simp, to_additive]\ntheorem nontrivial_iff : Nontrivial (Submonoid M) ↔ Nontrivial M :=\n  not_iff_not.mp\n    ((not_nontrivial_iff_subsingleton.trans subsingleton_iff).trans\n      not_nontrivial_iff_subsingleton.symm)\n#align submonoid.nontrivial_iff Submonoid.nontrivial_iff\n#align add_submonoid.nontrivial_iff AddSubmonoid.nontrivial_iff\n-/\n\n@[to_additive]\ninstance [Subsingleton M] : Unique (Submonoid M) :=\n  ⟨⟨⊥⟩, fun a => @Subsingleton.elim _ (subsingleton_iff.mpr ‹_›) a _⟩\n\n@[to_additive]\ninstance [Nontrivial M] : Nontrivial (Submonoid M) :=\n  nontrivial_iff.mpr ‹_›\n\n#print Submonoid.closure /-\n/-- The `submonoid` generated by a set. -/\n@[to_additive \"The `add_submonoid` generated by a set\"]\ndef closure (s : Set M) : Submonoid M :=\n  infₛ { S | s ⊆ S }\n#align submonoid.closure Submonoid.closure\n#align add_submonoid.closure AddSubmonoid.closure\n-/\n\n/- warning: submonoid.mem_closure -> Submonoid.mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {x : M}, Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) (forall (S : Submonoid.{u1} M _inst_1), (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S)) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x S))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {x : M}, Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) (forall (S : Submonoid.{u1} M _inst_1), (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) S)) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x S))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_closure Submonoid.mem_closureₓ'. -/\n@[to_additive]\ntheorem mem_closure {x : M} : x ∈ closure s ↔ ∀ S : Submonoid M, s ⊆ S → x ∈ S :=\n  mem_infₛ\n#align submonoid.mem_closure Submonoid.mem_closure\n#align add_submonoid.mem_closure AddSubmonoid.mem_closure\n\n/- warning: submonoid.subset_closure -> Submonoid.subset_closure is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M}, HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1 s))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M}, HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 s))\nCase conversion may be inaccurate. Consider using '#align submonoid.subset_closure Submonoid.subset_closureₓ'. -/\n/-- The submonoid generated by a set includes the set. -/\n@[simp, to_additive \"The `add_submonoid` generated by a set includes the set.\"]\ntheorem subset_closure : s ⊆ closure s := fun x hx => mem_closure.2 fun S hS => hS hx\n#align submonoid.subset_closure Submonoid.subset_closure\n#align add_submonoid.subset_closure AddSubmonoid.subset_closure\n\n/- warning: submonoid.not_mem_of_not_mem_closure -> Submonoid.not_mem_of_not_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {P : M}, (Not (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) P (Submonoid.closure.{u1} M _inst_1 s))) -> (Not (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) P s))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {P : M}, (Not (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) P (Submonoid.closure.{u1} M _inst_1 s))) -> (Not (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) P s))\nCase conversion may be inaccurate. Consider using '#align submonoid.not_mem_of_not_mem_closure Submonoid.not_mem_of_not_mem_closureₓ'. -/\n@[to_additive]\ntheorem not_mem_of_not_mem_closure {P : M} (hP : P ∉ closure s) : P ∉ s := fun h =>\n  hP (subset_closure h)\n#align submonoid.not_mem_of_not_mem_closure Submonoid.not_mem_of_not_mem_closure\n#align add_submonoid.not_mem_of_not_mem_closure AddSubmonoid.not_mem_of_not_mem_closure\n\nvariable {S}\n\nopen Set\n\n/- warning: submonoid.closure_le -> Submonoid.closure_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {S : Submonoid.{u1} M _inst_1}, Iff (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1 s) S) (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {S : Submonoid.{u1} M _inst_1}, Iff (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))))) (Submonoid.closure.{u1} M _inst_1 s) S) (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_le Submonoid.closure_leₓ'. -/\n/-- A submonoid `S` includes `closure s` if and only if it includes `s`. -/\n@[simp, to_additive \"An additive submonoid `S` includes `closure s` if and only if it includes `s`\"]\ntheorem closure_le : closure s ≤ S ↔ s ⊆ S :=\n  ⟨Subset.trans subset_closure, fun h => infₛ_le h⟩\n#align submonoid.closure_le Submonoid.closure_le\n#align add_submonoid.closure_le AddSubmonoid.closure_le\n\n/- warning: submonoid.closure_mono -> Submonoid.closure_mono is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {{s : Set.{u1} M}} {{t : Set.{u1} M}}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s t) -> (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1 s) (Submonoid.closure.{u1} M _inst_1 t))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {{s : Set.{u1} M}} {{t : Set.{u1} M}}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s t) -> (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))))) (Submonoid.closure.{u1} M _inst_1 s) (Submonoid.closure.{u1} M _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_mono Submonoid.closure_monoₓ'. -/\n/-- Submonoid closure of a set is monotone in its argument: if `s ⊆ t`,\nthen `closure s ≤ closure t`. -/\n@[to_additive\n      \"Additive submonoid closure of a set is monotone in its argument: if `s ⊆ t`,\\nthen `closure s ≤ closure t`\"]\ntheorem closure_mono ⦃s t : Set M⦄ (h : s ⊆ t) : closure s ≤ closure t :=\n  closure_le.2 <| Subset.trans h subset_closure\n#align submonoid.closure_mono Submonoid.closure_mono\n#align add_submonoid.closure_mono AddSubmonoid.closure_mono\n\n/- warning: submonoid.closure_eq_of_le -> Submonoid.closure_eq_of_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {S : Submonoid.{u1} M _inst_1}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S)) -> (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S (Submonoid.closure.{u1} M _inst_1 s)) -> (Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 s) S)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {S : Submonoid.{u1} M _inst_1}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) S)) -> (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))))) S (Submonoid.closure.{u1} M _inst_1 s)) -> (Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 s) S)\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_eq_of_le Submonoid.closure_eq_of_leₓ'. -/\n@[to_additive]\ntheorem closure_eq_of_le (h₁ : s ⊆ S) (h₂ : S ≤ closure s) : closure s = S :=\n  le_antisymm (closure_le.2 h₁) h₂\n#align submonoid.closure_eq_of_le Submonoid.closure_eq_of_le\n#align add_submonoid.closure_eq_of_le AddSubmonoid.closure_eq_of_le\n\nvariable (S)\n\n/- warning: submonoid.closure_induction -> Submonoid.closure_induction is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {p : M -> Prop} {x : M}, (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) -> (forall (x : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y))) -> (p x)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {p : M -> Prop} {x : M}, (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) -> (forall (x : M), (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) x y))) -> (p x)\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_induction Submonoid.closure_inductionₓ'. -/\n/-- An induction principle for closure membership. If `p` holds for `1` and all elements of `s`, and\nis preserved under multiplication, then `p` holds for all elements of the closure of `s`. -/\n@[elab_as_elim,\n  to_additive\n      \"An induction principle for additive closure membership. If `p`\\nholds for `0` and all elements of `s`, and is preserved under addition, then `p` holds for all\\nelements of the additive closure of `s`.\"]\ntheorem closure_induction {p : M → Prop} {x} (h : x ∈ closure s) (Hs : ∀ x ∈ s, p x) (H1 : p 1)\n    (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=\n  (@closure_le _ _ _ ⟨p, Hmul, H1⟩).2 Hs h\n#align submonoid.closure_induction Submonoid.closure_induction\n#align add_submonoid.closure_induction AddSubmonoid.closure_induction\n\n/- warning: submonoid.closure_induction' -> Submonoid.closure_induction' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (s : Set.{u1} M) {p : forall (x : M), (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) -> Prop}, (forall (x : M) (h : Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x s), p x (Submonoid.subset_closure.{u1} M _inst_1 s x h)) -> (p (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))) (OneMemClass.one_mem.{u1, u1} (Submonoid.{u1} M _inst_1) M (MulOneClass.toHasOne.{u1} M _inst_1) (Submonoid.setLike.{u1} M _inst_1) (SubmonoidClass.to_oneMemClass.{u1, u1} (Submonoid.{u1} M _inst_1) M _inst_1 (Submonoid.setLike.{u1} M _inst_1) (Submonoid.submonoidClass.{u1} M _inst_1)) (Submonoid.closure.{u1} M _inst_1 s))) -> (forall (x : M) (hx : Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) (y : M) (hy : Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) y (Submonoid.closure.{u1} M _inst_1 s)), (p x hx) -> (p y hy) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y) (MulMemClass.mul_mem.{u1, u1} (Submonoid.{u1} M _inst_1) M (MulOneClass.toHasMul.{u1} M _inst_1) (Submonoid.setLike.{u1} M _inst_1) (SubmonoidClass.to_mulMemClass.{u1, u1} (Submonoid.{u1} M _inst_1) M _inst_1 (Submonoid.setLike.{u1} M _inst_1) (Submonoid.submonoidClass.{u1} M _inst_1)) (Submonoid.closure.{u1} M _inst_1 s) x y hx hy))) -> (forall {x : M} (hx : Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)), p x hx)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (s : Set.{u1} M) {p : forall (x : M), (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) -> Prop}, (forall (x : M) (h : Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s), p x (Submonoid.subset_closure.{u1} M _inst_1 s x h)) -> (p (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1))) (OneMemClass.one_mem.{u1, u1} (Submonoid.{u1} M _inst_1) M (MulOneClass.toOne.{u1} M _inst_1) (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (SubmonoidClass.toOneMemClass.{u1, u1} (Submonoid.{u1} M _inst_1) M _inst_1 (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Submonoid.instSubmonoidClassSubmonoidInstSetLikeSubmonoid.{u1} M _inst_1)) (Submonoid.closure.{u1} M _inst_1 s))) -> (forall (x : M) (hx : Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) (y : M) (hy : Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) y (Submonoid.closure.{u1} M _inst_1 s)), (p x hx) -> (p y hy) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) x y) (MulMemClass.mul_mem.{u1, u1} (Submonoid.{u1} M _inst_1) M (MulOneClass.toMul.{u1} M _inst_1) (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (SubmonoidClass.toMulMemClass.{u1, u1} (Submonoid.{u1} M _inst_1) M _inst_1 (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (Submonoid.instSubmonoidClassSubmonoidInstSetLikeSubmonoid.{u1} M _inst_1)) (Submonoid.closure.{u1} M _inst_1 s) x y hx hy))) -> (forall {x : M} (hx : Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)), p x hx)\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_induction' Submonoid.closure_induction'ₓ'. -/\n/-- A dependent version of `submonoid.closure_induction`.  -/\n@[elab_as_elim, to_additive \"A dependent version of `add_submonoid.closure_induction`. \"]\ntheorem closure_induction' (s : Set M) {p : ∀ x, x ∈ closure s → Prop}\n    (Hs : ∀ (x) (h : x ∈ s), p x (subset_closure h)) (H1 : p 1 (one_mem _))\n    (Hmul : ∀ x hx y hy, p x hx → p y hy → p (x * y) (mul_mem hx hy)) {x} (hx : x ∈ closure s) :\n    p x hx := by\n  refine' Exists.elim _ fun (hx : x ∈ closure s) (hc : p x hx) => hc\n  exact\n    closure_induction hx (fun x hx => ⟨_, Hs x hx⟩) ⟨_, H1⟩ fun x y ⟨hx', hx⟩ ⟨hy', hy⟩ =>\n      ⟨_, Hmul _ _ _ _ hx hy⟩\n#align submonoid.closure_induction' Submonoid.closure_induction'\n#align add_submonoid.closure_induction' AddSubmonoid.closure_induction'\n\n/- warning: submonoid.closure_induction₂ -> Submonoid.closure_induction₂ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {p : M -> M -> Prop} {x : M} {y : M}, (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) y (Submonoid.closure.{u1} M _inst_1 s)) -> (forall (x : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x s) -> (forall (y : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) y s) -> (p x y))) -> (forall (x : M), p (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1)))) x) -> (forall (x : M), p x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))) -> (forall (x : M) (y : M) (z : M), (p x z) -> (p y z) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y) z)) -> (forall (x : M) (y : M) (z : M), (p z x) -> (p z y) -> (p z (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y))) -> (p x y)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {s : Set.{u1} M} {p : M -> M -> Prop} {x : M} {y : M}, (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x (Submonoid.closure.{u1} M _inst_1 s)) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) y (Submonoid.closure.{u1} M _inst_1 s)) -> (forall (x : M), (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s) -> (forall (y : M), (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) y s) -> (p x y))) -> (forall (x : M), p (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1))) x) -> (forall (x : M), p x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))) -> (forall (x : M) (y : M) (z : M), (p x z) -> (p y z) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) x y) z)) -> (forall (x : M) (y : M) (z : M), (p z x) -> (p z y) -> (p z (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) x y))) -> (p x y)\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_induction₂ Submonoid.closure_induction₂ₓ'. -/\n/-- An induction principle for closure membership for predicates with two arguments.  -/\n@[elab_as_elim,\n  to_additive\n      \"An induction principle for additive closure membership for\\npredicates with two arguments.\"]\ntheorem closure_induction₂ {p : M → M → Prop} {x} {y : M} (hx : x ∈ closure s) (hy : y ∈ closure s)\n    (Hs : ∀ x ∈ s, ∀ y ∈ s, p x y) (H1_left : ∀ x, p 1 x) (H1_right : ∀ x, p x 1)\n    (Hmul_left : ∀ x y z, p x z → p y z → p (x * y) z)\n    (Hmul_right : ∀ x y z, p z x → p z y → p z (x * y)) : p x y :=\n  closure_induction hx\n    (fun x xs =>\n      closure_induction hy (Hs x xs) (H1_right x) fun z y h₁ h₂ => Hmul_right z _ _ h₁ h₂)\n    (H1_left y) fun x z h₁ h₂ => Hmul_left _ _ _ h₁ h₂\n#align submonoid.closure_induction₂ Submonoid.closure_induction₂\n#align add_submonoid.closure_induction₂ AddSubmonoid.closure_induction₂\n\n/- warning: submonoid.dense_induction -> Submonoid.dense_induction is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p : M -> Prop} (x : M) {s : Set.{u1} M}, (Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 s) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasTop.{u1} M _inst_1))) -> (forall (x : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y))) -> (p x)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p : M -> Prop} (x : M) {s : Set.{u1} M}, (Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 s) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instTopSubmonoid.{u1} M _inst_1))) -> (forall (x : M), (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) x y))) -> (p x)\nCase conversion may be inaccurate. Consider using '#align submonoid.dense_induction Submonoid.dense_inductionₓ'. -/\n/-- If `s` is a dense set in a monoid `M`, `submonoid.closure s = ⊤`, then in order to prove that\nsome predicate `p` holds for all `x : M` it suffices to verify `p x` for `x ∈ s`, verify `p 1`,\nand verify that `p x` and `p y` imply `p (x * y)`. -/\n@[elab_as_elim,\n  to_additive\n      \"If `s` is a dense set in an additive monoid `M`,\\n`add_submonoid.closure s = ⊤`, then in order to prove that some predicate `p` holds for all `x : M`\\nit suffices to verify `p x` for `x ∈ s`, verify `p 0`, and verify that `p x` and `p y` imply\\n`p (x + y)`.\"]\ntheorem dense_induction {p : M → Prop} (x : M) {s : Set M} (hs : closure s = ⊤) (Hs : ∀ x ∈ s, p x)\n    (H1 : p 1) (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=\n  by\n  have : ∀ x ∈ closure s, p x := fun x hx => closure_induction hx Hs H1 Hmul\n  simpa [hs] using this x\n#align submonoid.dense_induction Submonoid.dense_induction\n#align add_submonoid.dense_induction AddSubmonoid.dense_induction\n\nvariable (M)\n\n/- warning: submonoid.gi -> Submonoid.gi is a dubious translation:\nlean 3 declaration is\n  forall (M : Type.{u1}) [_inst_1 : MulOneClass.{u1} M], GaloisInsertion.{u1, u1} (Set.{u1} M) (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Set.{u1} M) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} M) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} M) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} M) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} M) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} M) (Set.completeBooleanAlgebra.{u1} M))))))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1))) (Submonoid.closure.{u1} M _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))))\nbut is expected to have type\n  forall (M : Type.{u1}) [_inst_1 : MulOneClass.{u1} M], GaloisInsertion.{u1, u1} (Set.{u1} M) (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Set.{u1} M) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} M) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} M) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} M) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} M) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} M) (Set.instCompleteBooleanAlgebraSet.{u1} M))))))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1) (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align submonoid.gi Submonoid.giₓ'. -/\n/-- `closure` forms a Galois insertion with the coercion to set. -/\n@[to_additive \"`closure` forms a Galois insertion with the coercion to set.\"]\nprotected def gi : GaloisInsertion (@closure M _) coe\n    where\n  choice s _ := closure s\n  gc s t := closure_le\n  le_l_u s := subset_closure\n  choice_eq s h := rfl\n#align submonoid.gi Submonoid.gi\n#align add_submonoid.gi AddSubmonoid.gi\n\nvariable {M}\n\n/- warning: submonoid.closure_eq -> Submonoid.closure_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) S)) S\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (S : Submonoid.{u1} M _inst_1), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) S)) S\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_eq Submonoid.closure_eqₓ'. -/\n/-- Closure of a submonoid `S` equals `S`. -/\n@[simp, to_additive \"Additive closure of an additive submonoid `S` equals `S`\"]\ntheorem closure_eq : closure (S : Set M) = S :=\n  (Submonoid.gi M).l_u_eq S\n#align submonoid.closure_eq Submonoid.closure_eq\n#align add_submonoid.closure_eq AddSubmonoid.closure_eq\n\n/- warning: submonoid.closure_empty -> Submonoid.closure_empty is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (EmptyCollection.emptyCollection.{u1} (Set.{u1} M) (Set.hasEmptyc.{u1} M))) (Bot.bot.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasBot.{u1} M _inst_1))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (EmptyCollection.emptyCollection.{u1} (Set.{u1} M) (Set.instEmptyCollectionSet.{u1} M))) (Bot.bot.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instBotSubmonoid.{u1} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_empty Submonoid.closure_emptyₓ'. -/\n@[simp, to_additive]\ntheorem closure_empty : closure (∅ : Set M) = ⊥ :=\n  (Submonoid.gi M).gc.l_bot\n#align submonoid.closure_empty Submonoid.closure_empty\n#align add_submonoid.closure_empty AddSubmonoid.closure_empty\n\n/- warning: submonoid.closure_univ -> Submonoid.closure_univ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Set.univ.{u1} M)) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasTop.{u1} M _inst_1))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Set.univ.{u1} M)) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instTopSubmonoid.{u1} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_univ Submonoid.closure_univₓ'. -/\n@[simp, to_additive]\ntheorem closure_univ : closure (univ : Set M) = ⊤ :=\n  @coe_top M _ ▸ closure_eq ⊤\n#align submonoid.closure_univ Submonoid.closure_univ\n#align add_submonoid.closure_univ AddSubmonoid.closure_univ\n\n/- warning: submonoid.closure_union -> Submonoid.closure_union is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (s : Set.{u1} M) (t : Set.{u1} M), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Union.union.{u1} (Set.{u1} M) (Set.hasUnion.{u1} M) s t)) (Sup.sup.{u1} (Submonoid.{u1} M _inst_1) (SemilatticeSup.toHasSup.{u1} (Submonoid.{u1} M _inst_1) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toLattice.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.completeLattice.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1 s) (Submonoid.closure.{u1} M _inst_1 t))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (s : Set.{u1} M) (t : Set.{u1} M), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Union.union.{u1} (Set.{u1} M) (Set.instUnionSet.{u1} M) s t)) (Sup.sup.{u1} (Submonoid.{u1} M _inst_1) (SemilatticeSup.toSup.{u1} (Submonoid.{u1} M _inst_1) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toLattice.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1 s) (Submonoid.closure.{u1} M _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_union Submonoid.closure_unionₓ'. -/\n@[to_additive]\ntheorem closure_union (s t : Set M) : closure (s ∪ t) = closure s ⊔ closure t :=\n  (Submonoid.gi M).gc.l_sup\n#align submonoid.closure_union Submonoid.closure_union\n#align add_submonoid.closure_union AddSubmonoid.closure_union\n\n/- warning: submonoid.closure_Union -> Submonoid.closure_unionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} (s : ι -> (Set.{u1} M)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Set.unionᵢ.{u1, u2} M ι (fun (i : ι) => s i))) (supᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.completeLattice.{u1} M _inst_1))) ι (fun (i : ι) => Submonoid.closure.{u1} M _inst_1 (s i)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} (s : ι -> (Set.{u1} M)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Set.unionᵢ.{u1, u2} M ι (fun (i : ι) => s i))) (supᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteLattice.toSupSet.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)) ι (fun (i : ι) => Submonoid.closure.{u1} M _inst_1 (s i)))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_Union Submonoid.closure_unionᵢₓ'. -/\n@[to_additive]\ntheorem closure_unionᵢ {ι} (s : ι → Set M) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=\n  (Submonoid.gi M).gc.l_supᵢ\n#align submonoid.closure_Union Submonoid.closure_unionᵢ\n#align add_submonoid.closure_Union AddSubmonoid.closure_unionᵢ\n\n/- warning: submonoid.closure_singleton_le_iff_mem -> Submonoid.closure_singleton_le_iff_mem is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (m : M) (p : Submonoid.{u1} M _inst_1), Iff (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1 (Singleton.singleton.{u1, u1} M (Set.{u1} M) (Set.hasSingleton.{u1} M) m)) p) (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) m p)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] (m : M) (p : Submonoid.{u1} M _inst_1), Iff (LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))))) (Submonoid.closure.{u1} M _inst_1 (Singleton.singleton.{u1, u1} M (Set.{u1} M) (Set.instSingletonSet.{u1} M) m)) p) (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) m p)\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_singleton_le_iff_mem Submonoid.closure_singleton_le_iff_memₓ'. -/\n@[simp, to_additive]\ntheorem closure_singleton_le_iff_mem (m : M) (p : Submonoid M) : closure {m} ≤ p ↔ m ∈ p := by\n  rw [closure_le, singleton_subset_iff, SetLike.mem_coe]\n#align submonoid.closure_singleton_le_iff_mem Submonoid.closure_singleton_le_iff_mem\n#align add_submonoid.closure_singleton_le_iff_mem AddSubmonoid.closure_singleton_le_iff_mem\n\n/- warning: submonoid.mem_supr -> Submonoid.mem_supᵢ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} (p : ι -> (Submonoid.{u1} M _inst_1)) {m : M}, Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) m (supᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.completeLattice.{u1} M _inst_1))) ι (fun (i : ι) => p i))) (forall (N : Submonoid.{u1} M _inst_1), (forall (i : ι), LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (p i) N) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) m N))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} (p : ι -> (Submonoid.{u1} M _inst_1)) {m : M}, Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) m (supᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteLattice.toSupSet.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)) ι (fun (i : ι) => p i))) (forall (N : Submonoid.{u1} M _inst_1), (forall (i : ι), LE.le.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))))) (p i) N) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) m N))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_supr Submonoid.mem_supᵢₓ'. -/\n@[to_additive]\ntheorem mem_supᵢ {ι : Sort _} (p : ι → Submonoid M) {m : M} :\n    (m ∈ ⨆ i, p i) ↔ ∀ N, (∀ i, p i ≤ N) → m ∈ N :=\n  by\n  rw [← closure_singleton_le_iff_mem, le_supᵢ_iff]\n  simp only [closure_singleton_le_iff_mem]\n#align submonoid.mem_supr Submonoid.mem_supᵢ\n#align add_submonoid.mem_supr AddSubmonoid.mem_supᵢ\n\n/- warning: submonoid.supr_eq_closure -> Submonoid.supᵢ_eq_closure is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} (p : ι -> (Submonoid.{u1} M _inst_1)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (supᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.completeLattice.{u1} M _inst_1))) ι (fun (i : ι) => p i)) (Submonoid.closure.{u1} M _inst_1 (Set.unionᵢ.{u1, u2} M ι (fun (i : ι) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (p i))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {ι : Sort.{u2}} (p : ι -> (Submonoid.{u1} M _inst_1)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (supᵢ.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteLattice.toSupSet.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)) ι (fun (i : ι) => p i)) (Submonoid.closure.{u1} M _inst_1 (Set.unionᵢ.{u1, u2} M ι (fun (i : ι) => SetLike.coe.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1) (p i))))\nCase conversion may be inaccurate. Consider using '#align submonoid.supr_eq_closure Submonoid.supᵢ_eq_closureₓ'. -/\n@[to_additive]\ntheorem supᵢ_eq_closure {ι : Sort _} (p : ι → Submonoid M) :\n    (⨆ i, p i) = Submonoid.closure (⋃ i, (p i : Set M)) := by\n  simp_rw [Submonoid.closure_unionᵢ, Submonoid.closure_eq]\n#align submonoid.supr_eq_closure Submonoid.supᵢ_eq_closure\n#align add_submonoid.supr_eq_closure AddSubmonoid.supᵢ_eq_closure\n\n/- warning: submonoid.disjoint_def -> Submonoid.disjoint_def is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p₁ : Submonoid.{u1} M _inst_1} {p₂ : Submonoid.{u1} M _inst_1}, Iff (Disjoint.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) (BoundedOrder.toOrderBot.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.completeLattice.{u1} M _inst_1))) p₁ p₂) (forall {x : M}, (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x p₁) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x p₂) -> (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p₁ : Submonoid.{u1} M _inst_1} {p₂ : Submonoid.{u1} M _inst_1}, Iff (Disjoint.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))) (BoundedOrder.toOrderBot.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))))) (CompleteLattice.toBoundedOrder.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))) p₁ p₂) (forall {x : M}, (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x p₁) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x p₂) -> (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align submonoid.disjoint_def Submonoid.disjoint_defₓ'. -/\n@[to_additive]\ntheorem disjoint_def {p₁ p₂ : Submonoid M} : Disjoint p₁ p₂ ↔ ∀ {x : M}, x ∈ p₁ → x ∈ p₂ → x = 1 :=\n  by simp_rw [disjoint_iff_inf_le, SetLike.le_def, mem_inf, and_imp, mem_bot]\n#align submonoid.disjoint_def Submonoid.disjoint_def\n#align add_submonoid.disjoint_def AddSubmonoid.disjoint_def\n\n/- warning: submonoid.disjoint_def' -> Submonoid.disjoint_def' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p₁ : Submonoid.{u1} M _inst_1} {p₂ : Submonoid.{u1} M _inst_1}, Iff (Disjoint.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) (BoundedOrder.toOrderBot.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.completeLattice.{u1} M _inst_1))) p₁ p₂) (forall {x : M} {y : M}, (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) x p₁) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)) y p₂) -> (Eq.{succ u1} M x y) -> (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {p₁ : Submonoid.{u1} M _inst_1} {p₂ : Submonoid.{u1} M _inst_1}, Iff (Disjoint.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))) (BoundedOrder.toOrderBot.{u1} (Submonoid.{u1} M _inst_1) (Preorder.toLE.{u1} (Submonoid.{u1} M _inst_1) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))))) (CompleteLattice.toBoundedOrder.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1))) p₁ p₂) (forall {x : M} {y : M}, (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) x p₁) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M _inst_1) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u1} M _inst_1)) y p₂) -> (Eq.{succ u1} M x y) -> (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (MulOneClass.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align submonoid.disjoint_def' Submonoid.disjoint_def'ₓ'. -/\n@[to_additive]\ntheorem disjoint_def' {p₁ p₂ : Submonoid M} :\n    Disjoint p₁ p₂ ↔ ∀ {x y : M}, x ∈ p₁ → y ∈ p₂ → x = y → x = 1 :=\n  disjoint_def.trans ⟨fun h x y hx hy hxy => h hx <| hxy.symm ▸ hy, fun h x hx hx' => h hx hx' rfl⟩\n#align submonoid.disjoint_def' Submonoid.disjoint_def'\n#align add_submonoid.disjoint_def' AddSubmonoid.disjoint_def'\n\nend Submonoid\n\nnamespace MonoidHom\n\nvariable [MulOneClass N]\n\nopen Submonoid\n\n#print MonoidHom.eqLocusM /-\n/-- The submonoid of elements `x : M` such that `f x = g x` -/\n@[to_additive \"The additive submonoid of elements `x : M` such that `f x = g x`\"]\ndef eqLocusM (f g : M →* N) : Submonoid M\n    where\n  carrier := { x | f x = g x }\n  one_mem' := by rw [Set.mem_setOf_eq, f.map_one, g.map_one]\n  mul_mem' x y (hx : _ = _) (hy : _ = _) := by simp [*]\n#align monoid_hom.eq_mlocus MonoidHom.eqLocusM\n#align add_monoid_hom.eq_mlocus AddMonoidHom.eqLocusM\n-/\n\n/- warning: monoid_hom.eq_mlocus_same -> MonoidHom.eqLocusM_same is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_3 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_3), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (MonoidHom.eqLocusM.{u1, u2} M N _inst_1 _inst_3 f f) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasTop.{u1} M _inst_1))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_3 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_3), Eq.{succ u2} (Submonoid.{u2} M _inst_1) (MonoidHom.eqLocusM.{u2, u1} M N _inst_1 _inst_3 f f) (Top.top.{u2} (Submonoid.{u2} M _inst_1) (Submonoid.instTopSubmonoid.{u2} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.eq_mlocus_same MonoidHom.eqLocusM_sameₓ'. -/\n@[simp, to_additive]\ntheorem eqLocusM_same (f : M →* N) : f.eqLocus f = ⊤ :=\n  SetLike.ext fun _ => eq_self_iff_true _\n#align monoid_hom.eq_mlocus_same MonoidHom.eqLocusM_same\n#align add_monoid_hom.eq_mlocus_same AddMonoidHom.eqLocusM_same\n\n/- warning: monoid_hom.eq_on_mclosure -> MonoidHom.eqOn_closureM is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_3 : MulOneClass.{u2} N] {f : MonoidHom.{u1, u2} M N _inst_1 _inst_3} {g : MonoidHom.{u1, u2} M N _inst_1 _inst_3} {s : Set.{u1} M}, (Set.EqOn.{u1, u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) g) s) -> (Set.EqOn.{u1, u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) g) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Submonoid.closure.{u1} M _inst_1 s)))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_3 : MulOneClass.{u1} N] {f : MonoidHom.{u2, u1} M N _inst_1 _inst_3} {g : MonoidHom.{u2, u1} M N _inst_1 _inst_3} {s : Set.{u2} M}, (Set.EqOn.{u2, u1} M N (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) g) s) -> (Set.EqOn.{u2, u1} M N (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) g) (SetLike.coe.{u2, u2} (Submonoid.{u2} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u2} M _inst_1) (Submonoid.closure.{u2} M _inst_1 s)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.eq_on_mclosure MonoidHom.eqOn_closureMₓ'. -/\n/-- If two monoid homomorphisms are equal on a set, then they are equal on its submonoid closure. -/\n@[to_additive\n      \"If two monoid homomorphisms are equal on a set, then they are equal on its submonoid\\nclosure.\"]\ntheorem eqOn_closureM {f g : M →* N} {s : Set M} (h : Set.EqOn f g s) : Set.EqOn f g (closure s) :=\n  show closure s ≤ f.eqLocus g from closure_le.2 h\n#align monoid_hom.eq_on_mclosure MonoidHom.eqOn_closureM\n#align add_monoid_hom.eq_on_mclosure AddMonoidHom.eqOn_closureM\n\n/- warning: monoid_hom.eq_of_eq_on_mtop -> MonoidHom.eq_of_eqOn_topM is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_3 : MulOneClass.{u2} N] {f : MonoidHom.{u1, u2} M N _inst_1 _inst_3} {g : MonoidHom.{u1, u2} M N _inst_1 _inst_3}, (Set.EqOn.{u1, u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) g) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M _inst_1) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M _inst_1) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M _inst_1) M (Submonoid.setLike.{u1} M _inst_1)))) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasTop.{u1} M _inst_1)))) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_3 : MulOneClass.{u1} N] {f : MonoidHom.{u2, u1} M N _inst_1 _inst_3} {g : MonoidHom.{u2, u1} M N _inst_1 _inst_3}, (Set.EqOn.{u2, u1} M N (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) g) (SetLike.coe.{u2, u2} (Submonoid.{u2} M _inst_1) M (Submonoid.instSetLikeSubmonoid.{u2} M _inst_1) (Top.top.{u2} (Submonoid.{u2} M _inst_1) (Submonoid.instTopSubmonoid.{u2} M _inst_1)))) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) f g)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.eq_of_eq_on_mtop MonoidHom.eq_of_eqOn_topMₓ'. -/\n@[to_additive]\ntheorem eq_of_eqOn_topM {f g : M →* N} (h : Set.EqOn f g (⊤ : Submonoid M)) : f = g :=\n  ext fun x => h trivial\n#align monoid_hom.eq_of_eq_on_mtop MonoidHom.eq_of_eqOn_topM\n#align add_monoid_hom.eq_of_eq_on_mtop AddMonoidHom.eq_of_eqOn_topM\n\n/- warning: monoid_hom.eq_of_eq_on_mdense -> MonoidHom.eq_of_eqOn_denseM is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_3 : MulOneClass.{u2} N] {s : Set.{u1} M}, (Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 s) (Top.top.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasTop.{u1} M _inst_1))) -> (forall {f : MonoidHom.{u1, u2} M N _inst_1 _inst_3} {g : MonoidHom.{u1, u2} M N _inst_1 _inst_3}, (Set.EqOn.{u1, u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_3) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_3) g) s) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_3) f g))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_3 : MulOneClass.{u1} N] {s : Set.{u2} M}, (Eq.{succ u2} (Submonoid.{u2} M _inst_1) (Submonoid.closure.{u2} M _inst_1 s) (Top.top.{u2} (Submonoid.{u2} M _inst_1) (Submonoid.instTopSubmonoid.{u2} M _inst_1))) -> (forall {f : MonoidHom.{u2, u1} M N _inst_1 _inst_3} {g : MonoidHom.{u2, u1} M N _inst_1 _inst_3}, (Set.EqOn.{u2, u1} M N (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) M N _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_3))) g) s) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_3) f g))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.eq_of_eq_on_mdense MonoidHom.eq_of_eqOn_denseMₓ'. -/\n@[to_additive]\ntheorem eq_of_eqOn_denseM {s : Set M} (hs : closure s = ⊤) {f g : M →* N} (h : s.EqOn f g) :\n    f = g :=\n  eq_of_eqOn_topM <| hs ▸ eqOn_closureM h\n#align monoid_hom.eq_of_eq_on_mdense MonoidHom.eq_of_eqOn_denseM\n#align add_monoid_hom.eq_of_eq_on_mdense AddMonoidHom.eq_of_eqOn_denseM\n\nend MonoidHom\n\nend NonAssoc\n\nsection Assoc\n\nvariable [Monoid M] [Monoid N] {s : Set M}\n\nsection IsUnit\n\n#print IsUnit.submonoid /-\n/-- The submonoid consisting of the units of a monoid -/\n@[to_additive \"The additive submonoid consisting of the additive units of an additive monoid\"]\ndef IsUnit.submonoid (M : Type _) [Monoid M] : Submonoid M\n    where\n  carrier := setOf IsUnit\n  one_mem' := by simp only [isUnit_one, Set.mem_setOf_eq]\n  mul_mem' := by\n    intro a b ha hb\n    rw [Set.mem_setOf_eq] at *\n    exact IsUnit.mul ha hb\n#align is_unit.submonoid IsUnit.submonoid\n#align is_add_unit.add_submonoid IsAddUnit.addSubmonoid\n-/\n\n/- warning: is_unit.mem_submonoid_iff -> IsUnit.mem_submonoid_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_3 : Monoid.{u1} M] (a : M), Iff (Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3))) a (IsUnit.submonoid.{u1} M _inst_3)) (IsUnit.{u1} M _inst_3 a)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_3 : Monoid.{u1} M] (a : M), Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3))) a (IsUnit.submonoid.{u1} M _inst_3)) (IsUnit.{u1} M _inst_3 a)\nCase conversion may be inaccurate. Consider using '#align is_unit.mem_submonoid_iff IsUnit.mem_submonoid_iffₓ'. -/\n@[to_additive]\ntheorem IsUnit.mem_submonoid_iff {M : Type _} [Monoid M] (a : M) :\n    a ∈ IsUnit.submonoid M ↔ IsUnit a :=\n  by\n  change a ∈ setOf IsUnit ↔ IsUnit a\n  rw [Set.mem_setOf_eq]\n#align is_unit.mem_submonoid_iff IsUnit.mem_submonoid_iff\n#align is_add_unit.mem_add_submonoid_iff IsAddUnit.mem_addSubmonoid_iff\n\nend IsUnit\n\nnamespace MonoidHom\n\nopen Submonoid\n\n/- warning: monoid_hom.of_mclosure_eq_top_left -> MonoidHom.ofClosureMEqTopLeft is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_3 : Monoid.{u1} M] [_inst_4 : Monoid.{u2} N] {s : Set.{u1} M} (f : M -> N), (Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3) s) (Top.top.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.hasTop.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)))) -> (Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N _inst_4)))))) -> (forall (x : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x s) -> (forall (y : M), Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N (Monoid.toMulOneClass.{u2} N _inst_4))) (f x) (f y)))) -> (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_3) (Monoid.toMulOneClass.{u2} N _inst_4))\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_3 : Monoid.{u1} M] [_inst_4 : Monoid.{u2} N] {s : Set.{u1} M} (f : M -> N), (Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3) s) (Top.top.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.instTopSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)))) -> (Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_3)))) (OfNat.ofNat.{u2} N 1 (One.toOfNat1.{u2} N (Monoid.toOne.{u2} N _inst_4)))) -> (forall (x : M), (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s) -> (forall (y : M), Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toMul.{u2} N (Monoid.toMulOneClass.{u2} N _inst_4))) (f x) (f y)))) -> (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_3) (Monoid.toMulOneClass.{u2} N _inst_4))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.of_mclosure_eq_top_left MonoidHom.ofClosureMEqTopLeftₓ'. -/\n/-- Let `s` be a subset of a monoid `M` such that the closure of `s` is the whole monoid.\nThen `monoid_hom.of_mclosure_eq_top_left` defines a monoid homomorphism from `M` asking for\na proof of `f (x * y) = f x * f y` only for `x ∈ s`. -/\n@[to_additive\n      \"/-- Let `s` be a subset of an additive monoid `M` such that the closure of `s` is\\nthe whole monoid. Then `add_monoid_hom.of_mclosure_eq_top_left` defines an additive monoid\\nhomomorphism from `M` asking for a proof of `f (x + y) = f x + f y` only for `x ∈ s`. -/\"]\ndef ofClosureMEqTopLeft {M N} [Monoid M] [Monoid N] {s : Set M} (f : M → N) (hs : closure s = ⊤)\n    (h1 : f 1 = 1) (hmul : ∀ x ∈ s, ∀ (y), f (x * y) = f x * f y) : M →* N\n    where\n  toFun := f\n  map_one' := h1\n  map_mul' x :=\n    dense_induction x hs hmul (fun y => by rw [one_mul, h1, one_mul]) fun a b ha hb y => by\n      rw [mul_assoc, ha, ha, hb, mul_assoc]\n#align monoid_hom.of_mclosure_eq_top_left MonoidHom.ofClosureMEqTopLeft\n#align add_monoid_hom.of_mclosure_eq_top_left AddMonoidHom.ofClosureMEqTopLeft\n\n/- warning: monoid_hom.coe_of_mclosure_eq_top_left -> MonoidHom.coe_ofClosureMEqTopLeft is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Monoid.{u2} N] {s : Set.{u1} M} (f : M -> N) (hs : Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) s) (Top.top.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.hasTop.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (h1 : Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N _inst_2)))))) (hmul : forall (x : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) x s) -> (forall (y : M), Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N (Monoid.toMulOneClass.{u2} N _inst_2))) (f x) (f y)))), Eq.{max (succ u1) (succ u2)} (M -> N) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) (MonoidHom.ofClosureMEqTopLeft.{u1, u2} M N _inst_1 _inst_2 s f hs h1 hmul)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Monoid.{u2} M] [_inst_2 : Monoid.{u1} N] {s : Set.{u2} M} (f : M -> N) (hs : Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.closure.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1) s) (Top.top.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instTopSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))) (h1 : Eq.{succ u1} N (f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M _inst_1)))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N _inst_2)))) (hmul : forall (x : M), (Membership.mem.{u2, u2} M (Set.{u2} M) (Set.instMembershipSet.{u2} M) x s) -> (forall (y : M), Eq.{succ u1} N (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N _inst_2))) (f x) (f y)))), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)))) (MonoidHom.ofClosureMEqTopLeft.{u2, u1} M N _inst_1 _inst_2 s f hs h1 hmul)) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_of_mclosure_eq_top_left MonoidHom.coe_ofClosureMEqTopLeftₓ'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_ofClosureMEqTopLeft (f : M → N) (hs : closure s = ⊤) (h1 hmul) :\n    ⇑(ofClosureMEqTopLeft f hs h1 hmul) = f :=\n  rfl\n#align monoid_hom.coe_of_mclosure_eq_top_left MonoidHom.coe_ofClosureMEqTopLeft\n#align add_monoid_hom.coe_of_mclosure_eq_top_left AddMonoidHom.coe_ofClosureMEqTopLeft\n\n/- warning: monoid_hom.of_mclosure_eq_top_right -> MonoidHom.ofClosureMEqTopRight is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_3 : Monoid.{u1} M] [_inst_4 : Monoid.{u2} N] {s : Set.{u1} M} (f : M -> N), (Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3) s) (Top.top.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.hasTop.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)))) -> (Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N _inst_4)))))) -> (forall (x : M) (y : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) y s) -> (Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N (Monoid.toMulOneClass.{u2} N _inst_4))) (f x) (f y)))) -> (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_3) (Monoid.toMulOneClass.{u2} N _inst_4))\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_3 : Monoid.{u1} M] [_inst_4 : Monoid.{u2} N] {s : Set.{u1} M} (f : M -> N), (Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3) s) (Top.top.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)) (Submonoid.instTopSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3)))) -> (Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_3)))) (OfNat.ofNat.{u2} N 1 (One.toOfNat1.{u2} N (Monoid.toOne.{u2} N _inst_4)))) -> (forall (x : M) (y : M), (Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) y s) -> (Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_3))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toMul.{u2} N (Monoid.toMulOneClass.{u2} N _inst_4))) (f x) (f y)))) -> (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_3) (Monoid.toMulOneClass.{u2} N _inst_4))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.of_mclosure_eq_top_right MonoidHom.ofClosureMEqTopRightₓ'. -/\n/-- Let `s` be a subset of a monoid `M` such that the closure of `s` is the whole monoid.\nThen `monoid_hom.of_mclosure_eq_top_right` defines a monoid homomorphism from `M` asking for\na proof of `f (x * y) = f x * f y` only for `y ∈ s`. -/\n@[to_additive\n      \"/-- Let `s` be a subset of an additive monoid `M` such that the closure of `s` is\\nthe whole monoid. Then `add_monoid_hom.of_mclosure_eq_top_right` defines an additive monoid\\nhomomorphism from `M` asking for a proof of `f (x + y) = f x + f y` only for `y ∈ s`. -/\"]\ndef ofClosureMEqTopRight {M N} [Monoid M] [Monoid N] {s : Set M} (f : M → N) (hs : closure s = ⊤)\n    (h1 : f 1 = 1) (hmul : ∀ (x), ∀ y ∈ s, f (x * y) = f x * f y) : M →* N\n    where\n  toFun := f\n  map_one' := h1\n  map_mul' x y :=\n    dense_induction y hs (fun y hy x => hmul x y hy) (by simp [h1])\n      (fun y₁ y₂ h₁ h₂ x => by simp only [← mul_assoc, h₁, h₂]) x\n#align monoid_hom.of_mclosure_eq_top_right MonoidHom.ofClosureMEqTopRight\n#align add_monoid_hom.of_mclosure_eq_top_right AddMonoidHom.ofClosureMEqTopRight\n\n/- warning: monoid_hom.coe_of_mclosure_eq_top_right -> MonoidHom.coe_ofClosureMEqTopRight is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Monoid.{u2} N] {s : Set.{u1} M} (f : M -> N) (hs : Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) s) (Top.top.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.hasTop.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (h1 : Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N _inst_2)))))) (hmul : forall (x : M) (y : M), (Membership.Mem.{u1, u1} M (Set.{u1} M) (Set.hasMem.{u1} M) y s) -> (Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N (Monoid.toMulOneClass.{u2} N _inst_2))) (f x) (f y)))), Eq.{max (succ u1) (succ u2)} (M -> N) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) (MonoidHom.ofClosureMEqTopRight.{u1, u2} M N _inst_1 _inst_2 s f hs h1 hmul)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Monoid.{u2} M] [_inst_2 : Monoid.{u1} N] {s : Set.{u2} M} (f : M -> N) (hs : Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.closure.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1) s) (Top.top.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instTopSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))) (h1 : Eq.{succ u1} N (f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M _inst_1)))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N _inst_2)))) (hmul : forall (x : M) (y : M), (Membership.mem.{u2, u2} M (Set.{u2} M) (Set.instMembershipSet.{u2} M) y s) -> (Eq.{succ u1} N (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N _inst_2))) (f x) (f y)))), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)))) (MonoidHom.ofClosureMEqTopRight.{u2, u1} M N _inst_1 _inst_2 s f hs h1 hmul)) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_of_mclosure_eq_top_right MonoidHom.coe_ofClosureMEqTopRightₓ'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_ofClosureMEqTopRight (f : M → N) (hs : closure s = ⊤) (h1 hmul) :\n    ⇑(ofClosureMEqTopRight f hs h1 hmul) = f :=\n  rfl\n#align monoid_hom.coe_of_mclosure_eq_top_right MonoidHom.coe_ofClosureMEqTopRight\n#align add_monoid_hom.coe_of_mclosure_eq_top_right AddMonoidHom.coe_ofClosureMEqTopRight\n\nend MonoidHom\n\nend Assoc\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/GroupTheory/Submonoid/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979746, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.4990013706489667}}
{"text": "/-\nCopyright (c) 2021 Yakov Pechersky. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yakov Pechersky\n\n! This file was ported from Lean 3 source module data.list.cycle\n! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Multiset.Sort\nimport Mathlib.Data.Fintype.List\nimport Mathlib.Data.List.Rotate\n\n/-!\n# Cycles of a list\n\nLists have an equivalence relation of whether they are rotational permutations of one another.\nThis relation is defined as `IsRotated`.\n\nBased on this, we define the quotient of lists by the rotation relation, called `Cycle`.\n\nWe also define a representation of concrete cycles, available when viewing them in a goal state or\nvia `#eval`, when over representatble types. For example, the cycle `(2 1 4 3)` will be shown\nas `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation\nis different.\n\n-/\n\n\nnamespace List\n\nvariable {α : Type _} [DecidableEq α]\n\n/-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/\ndef nextOr : ∀ (_ : List α) (_ _ : α), α\n  | [], _, default => default\n  | [_], _, default => default\n  -- Handles the not-found and the wraparound case\n  | y :: z :: xs, x, default => if x = y then z else nextOr (z :: xs) x default\n#align list.next_or List.nextOr\n\n@[simp]\ntheorem nextOr_nil (x d : α) : nextOr [] x d = d :=\n  rfl\n#align list.next_or_nil List.nextOr_nil\n\n@[simp]\ntheorem nextOr_singleton (x y d : α) : nextOr [y] x d = d :=\n  rfl\n#align list.next_or_singleton List.nextOr_singleton\n\n@[simp]\ntheorem nextOr_self_cons_cons (xs : List α) (x y d : α) : nextOr (x :: y :: xs) x d = y :=\n  if_pos rfl\n#align list.next_or_self_cons_cons List.nextOr_self_cons_cons\n\ntheorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) :\n    nextOr (y :: xs) x d = nextOr xs x d := by\n  cases' xs with z zs\n  · rfl\n  · exact if_neg h\n#align list.next_or_cons_of_ne List.nextOr_cons_of_ne\n\n/-- `nextOr` does not depend on the default value, if the next value appears. -/\ntheorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x ∈ xs)\n    (x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' :=\n  by\n  induction' xs with y ys IH\n  · cases x_mem\n  cases' ys with z zs\n  · simp at x_mem x_ne\n    contradiction\n  by_cases h : x = y\n  · rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons]\n  · rw [nextOr, nextOr, IH]\n    . simpa [h] using x_mem\n    . simpa using x_ne\n#align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne\n\ntheorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs :=\n  by\n  induction' xs with y ys IH\n  · simp at h\n  cases' ys with z zs\n  · simp at h\n  · by_cases hx : x = y\n    · simp [hx]\n    · rw [nextOr_cons_of_ne _ _ _ _ hx] at h\n      simpa [hx] using IH h\n#align list.mem_of_next_or_ne List.mem_of_nextOr_ne\n\ntheorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (xs ++ [x]) x d = d :=\n  by\n  induction' xs with z zs IH\n  · simp\n  · obtain ⟨hz, hzs⟩ := not_or.mp (mt mem_cons.2 h)\n    rw [cons_append, nextOr_cons_of_ne _ _ _ _ hz, IH hzs]\n#align list.next_or_concat List.nextOr_concat\n\ntheorem nextOr_mem {xs : List α} {x d : α} (hd : d ∈ xs) : nextOr xs x d ∈ xs := by\n  revert hd\n  suffices ∀ (xs' : List α) (_ : ∀ x ∈ xs, x ∈ xs') (_ : d ∈ xs'), nextOr xs x d ∈ xs' by\n    exact this xs fun _ => id\n  intro xs' hxs' hd\n  induction' xs with y ys ih\n  · exact hd\n  cases' ys with z zs\n  · exact hd\n  rw [nextOr]\n  split_ifs with h\n  · exact hxs' _ (mem_cons_of_mem _ (mem_cons_self _ _))\n  · exact ih fun _ h => hxs' _ (mem_cons_of_mem _ h)\n#align list.next_or_mem List.nextOr_mem\n\n/-- Given an element `x : α` of `l : list α` such that `x ∈ l`, get the next\nelement of `l`. This works from head to tail, (including a check for last element)\nso it will match on first hit, ignoring later duplicates.\n\nFor example:\n * `next [1, 2, 3] 2 _ = 3`\n * `next [1, 2, 3] 3 _ = 1`\n * `next [1, 2, 3, 2, 4] 2 _ = 3`\n * `next [1, 2, 3, 2] 2 _ = 3`\n * `next [1, 1, 2, 3, 2] 1 _ = 1`\n-/\ndef next (l : List α) (x : α) (h : x ∈ l) : α :=\n  nextOr l x (l.get ⟨0, length_pos_of_mem h⟩)\n#align list.next List.next\n\n/-- Given an element `x : α` of `l : list α` such that `x ∈ l`, get the previous\nelement of `l`. This works from head to tail, (including a check for last element)\nso it will match on first hit, ignoring later duplicates.\n\n * `prev [1, 2, 3] 2 _ = 1`\n * `prev [1, 2, 3] 1 _ = 3`\n * `prev [1, 2, 3, 2, 4] 2 _ = 1`\n * `prev [1, 2, 3, 4, 2] 2 _ = 1`\n * `prev [1, 1, 2] 1 _ = 2`\n-/\ndef prev : ∀ (l : List α) (x : α) (_h : x ∈ l), α\n  | [], _, h => by simp at h\n  | [y], _, _ => y\n  | y :: z :: xs, x, h =>\n    if hx : x = y then getLast (z :: xs) (cons_ne_nil _ _)\n    else if x = z then y else prev (z :: xs) x (by simpa [hx] using h)\n#align list.prev List.prev\n\nvariable (l : List α) (x : α)\n\n@[simp]\ntheorem next_singleton (x y : α) (h : x ∈ [y]) : next [y] x h = y :=\n  rfl\n#align list.next_singleton List.next_singleton\n\n@[simp]\ntheorem prev_singleton (x y : α) (h : x ∈ [y]) : prev [y] x h = y :=\n  rfl\n#align list.prev_singleton List.prev_singleton\n\ntheorem next_cons_cons_eq' (y z : α) (h : x ∈ y :: z :: l) (hx : x = y) :\n    next (y :: z :: l) x h = z := by rw [next, nextOr, if_pos hx]\n#align list.next_cons_cons_eq' List.next_cons_cons_eq'\n\n@[simp]\ntheorem next_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) : next (x :: z :: l) x h = z :=\n  next_cons_cons_eq' l x x z h rfl\n#align list.next_cons_cons_eq List.next_cons_cons_eq\n\ntheorem next_ne_head_ne_getLast (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠ y)\n    (hx : x ≠ getLast (y :: l) (cons_ne_nil _ _)) :\n    next (y :: l) x h = next l x (by simpa [hy] using h) := by\n  rw [next, next, nextOr_cons_of_ne _ _ _ _ hy, nextOr_eq_nextOr_of_mem_of_ne]\n  · rwa [getLast_cons] at hx\n    exact ne_nil_of_mem (by assumption)\n  · rwa [getLast_cons] at hx\n#align list.next_ne_head_ne_last List.next_ne_head_ne_getLast\n\ntheorem next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l)\n    (h : x ∈ y :: l ++ [x] := mem_append_right _ (mem_singleton_self x)) :\n    next (y :: l ++ [x]) x h = y := by\n  rw [next, nextOr_concat]\n  · rfl\n  · simp [hy, hx]\n#align list.next_cons_concat List.next_cons_concat\n\ntheorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠ y)\n    (hx : x = getLast (y :: l) (cons_ne_nil _ _)) (hl : Nodup l) : next (y :: l) x h = y :=\n  by\n  rw [next, get, ← dropLast_append_getLast (cons_ne_nil y l), hx, nextOr_concat]\n  subst hx\n  intro H\n  obtain ⟨⟨_ | k, hk⟩, hk'⟩ := get_of_mem H\n  · rw [← Option.some_inj] at hk'\n    rw [← get?_eq_get, dropLast_eq_take, get?_take, get?_zero, head?_cons,\n      Option.some_inj] at hk'\n    exact hy (Eq.symm hk')\n    rw [Nat.zero_eq, length_cons, Nat.pred_succ]\n    exact length_pos_of_mem (by assumption)\n  suffices k.succ = l.length by simp [this] at hk\n  cases' l with hd tl\n  · simp at hk\n  · rw [nodup_iff_injective_get] at hl\n    rw [length, Nat.succ_inj']\n    refine' Fin.veq_of_eq (@hl ⟨k, Nat.lt_of_succ_lt <| by simpa using hk⟩ ⟨tl.length, by simp⟩ _)\n    rw [← Option.some_inj] at hk'\n    rw [← get?_eq_get, dropLast_eq_take, get?_take, get?, get?_eq_get, Option.some_inj] at hk'\n    rw [hk']\n    simp [getLast_eq_get]\n    simpa using hk\n#align list.next_last_cons List.next_getLast_cons\n\ntheorem prev_getLast_cons' (y : α) (hxy : x ∈ y :: l) (hx : x = y) :\n    prev (y :: l) x hxy = getLast (y :: l) (cons_ne_nil _ _) := by cases l <;> simp [prev, hx]\n#align list.prev_last_cons' List.prev_getLast_cons'\n\n@[simp]\ntheorem prev_getLast_cons (h : x ∈ x :: l) :\n    prev (x :: l) x h = getLast (x :: l) (cons_ne_nil _ _) :=\n  prev_getLast_cons' l x x h rfl\n#align list.prev_last_cons List.prev_getLast_cons\n\ntheorem prev_cons_cons_eq' (y z : α) (h : x ∈ y :: z :: l) (hx : x = y) :\n    prev (y :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) := by rw [prev, dif_pos hx]\n#align list.prev_cons_cons_eq' List.prev_cons_cons_eq'\n\n--@[simp] Porting note: `simp` can prove it\ntheorem prev_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) :\n    prev (x :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) :=\n  prev_cons_cons_eq' l x x z h rfl\n#align list.prev_cons_cons_eq List.prev_cons_cons_eq\n\ntheorem prev_cons_cons_of_ne' (y z : α) (h : x ∈ y :: z :: l) (hy : x ≠ y) (hz : x = z) :\n    prev (y :: z :: l) x h = y := by\n  cases l\n  · simp [prev, hy, hz]\n  · rw [prev, dif_neg hy, if_pos hz]\n#align list.prev_cons_cons_of_ne' List.prev_cons_cons_of_ne'\n\ntheorem prev_cons_cons_of_ne (y : α) (h : x ∈ y :: x :: l) (hy : x ≠ y) :\n    prev (y :: x :: l) x h = y :=\n  prev_cons_cons_of_ne' _ _ _ _ _ hy rfl\n#align list.prev_cons_cons_of_ne List.prev_cons_cons_of_ne\n\ntheorem prev_ne_cons_cons (y z : α) (h : x ∈ y :: z :: l) (hy : x ≠ y) (hz : x ≠ z) :\n    prev (y :: z :: l) x h = prev (z :: l) x (by simpa [hy] using h) := by\n  cases l\n  · simp [hy, hz] at h\n  · rw [prev, dif_neg hy, if_neg hz]\n#align list.prev_ne_cons_cons List.prev_ne_cons_cons\n\ntheorem next_mem (h : x ∈ l) : l.next x h ∈ l :=\n  nextOr_mem (get_mem _ _ _)\n#align list.next_mem List.next_mem\n\ntheorem prev_mem (h : x ∈ l) : l.prev x h ∈ l := by\n  cases' l with hd tl\n  · simp at h\n  induction' tl with hd' tl hl generalizing hd\n  · simp\n  · by_cases hx : x = hd\n    · simp only [hx, prev_cons_cons_eq]\n      exact mem_cons_of_mem _ (getLast_mem _)\n    · rw [prev, dif_neg hx]\n      split_ifs with hm\n      · exact mem_cons_self _ _\n      · exact mem_cons_of_mem _ (hl _ _)\n#align list.prev_mem List.prev_mem\n\n--Porting note: new theorem\ntheorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),\n    next l (l.get i) (get_mem _ _ _) = l.get ⟨(i + 1) % l.length,\n      Nat.mod_lt _ (i.1.zero_le.trans_lt i.2)⟩\n  | [], _, i => by simpa using i.2\n  | [_], _, _ => by simp\n  | x::y::l, _h, ⟨0, h0⟩ => by\n    have h₁ : get (x :: y :: l) { val := 0, isLt := h0 } = x := by simp\n    rw [next_cons_cons_eq' _ _ _ _ _ h₁]\n    simp\n  | x::y::l, hn, ⟨i+1, hi⟩ => by\n    have hx' : (x :: y :: l).get ⟨i+1, hi⟩ ≠ x := by\n      intro H\n      suffices (i + 1 : ℕ) = 0 by simpa\n      rw [nodup_iff_injective_get] at hn\n      refine' Fin.veq_of_eq (@hn ⟨i + 1, hi⟩ ⟨0, by simp⟩ _)\n      simpa using H\n    have hi' : i ≤ l.length := Nat.le_of_lt_succ (Nat.succ_lt_succ_iff.1 hi)\n    rcases hi'.eq_or_lt with (hi' | hi')\n    · subst hi'\n      rw [next_getLast_cons]\n      · simp [hi', get]\n      . rw [get_cons_succ]; exact get_mem _ _ _\n      . exact hx'\n      . simp [getLast_eq_get]\n      . exact hn.of_cons\n    . rw [next_ne_head_ne_getLast _ _ _ _ _ hx']\n      simp only [get_cons_succ]\n      rw [next_get (y::l), ← get_cons_succ (a := x)]\n      congr\n      dsimp\n      rw [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'),\n        Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 (Nat.succ_lt_succ_iff.2 hi'))]\n      . simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi']\n      . exact hn.of_cons\n      . rw [getLast_eq_get]\n        intro h\n        have := nodup_iff_injective_get.1 hn h\n        simp at this; simp [this] at hi'\n      . rw [get_cons_succ]; exact get_mem _ _ _\n\nset_option linter.deprecated false in\n@[deprecated next_get]\ntheorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :\n    next l (l.nthLe n hn) (nthLe_mem _ _ _) =\n      l.nthLe ((n + 1) % l.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) :=\n  next_get l h ⟨n, hn⟩\n#align list.next_nth_le List.next_nthLe\n\nset_option linter.deprecated false in\ntheorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :\n    prev l (l.nthLe n hn) (nthLe_mem _ _ _) =\n      l.nthLe ((n + (l.length - 1)) % l.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) := by\n  cases' l with x l\n  · simp at hn\n  induction' l with y l hl generalizing n x\n  · simp\n  · rcases n with (_ | _ | n)\n    · simp [Nat.add_succ_sub_one, add_zero, List.prev_cons_cons_eq, Nat.zero_eq, List.length,\n        List.nthLe, Nat.succ_add_sub_one, zero_add, getLast_eq_get,\n        Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)]\n    · simp only [mem_cons, nodup_cons] at h\n      push_neg  at h\n      simp only [List.prev_cons_cons_of_ne _ _ _ _ h.left.left.symm, Nat.zero_eq, List.length,\n        List.nthLe, add_comm, eq_self_iff_true, Nat.succ_add_sub_one, Nat.mod_self, zero_add,\n        List.get]\n    · rw [prev_ne_cons_cons]\n      · convert hl n.succ y h.of_cons (Nat.le_of_succ_le_succ hn) using 1\n        have : ∀ k hk, (y :: l).nthLe k hk = (x :: y :: l).nthLe (k + 1) (Nat.succ_lt_succ hk) :=\n          by\n          intros\n          simp [List.nthLe]\n        rw [this]\n        congr\n        simp only [Nat.add_succ_sub_one, add_zero, length]\n        simp only [length, Nat.succ_lt_succ_iff] at hn\n        set k := l.length\n        rw [Nat.succ_add, ← Nat.add_succ, Nat.add_mod_right, Nat.succ_add, ← Nat.add_succ _ k,\n          Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt]\n        · exact Nat.lt_succ_of_lt hn\n        · exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn)\n      · intro H\n        suffices n.succ.succ = 0 by simpa\n        rw [nodup_iff_nthLe_inj] at h\n        refine' h _ _ hn Nat.succ_pos' _\n        simpa using H\n      · intro H\n        suffices n.succ.succ = 1 by simpa\n        rw [nodup_iff_nthLe_inj] at h\n        refine' h _ _ hn (Nat.succ_lt_succ Nat.succ_pos') _\n        simpa using H\n#align list.prev_nth_le List.prev_nthLe\n\nset_option linter.deprecated false in\ntheorem pmap_next_eq_rotate_one (h : Nodup l) : (l.pmap l.next fun _ h => h) = l.rotate 1 := by\n  apply List.ext_nthLe\n  · simp\n  · intros\n    rw [nthLe_pmap, nthLe_rotate, next_nthLe _ h]\n#align list.pmap_next_eq_rotate_one List.pmap_next_eq_rotate_one\n\nset_option linter.deprecated false in\ntheorem pmap_prev_eq_rotate_length_sub_one (h : Nodup l) :\n    (l.pmap l.prev fun _ h => h) = l.rotate (l.length - 1) :=\n  by\n  apply List.ext_nthLe\n  · simp\n  · intro n hn hn'\n    rw [nthLe_rotate, nthLe_pmap, prev_nthLe _ h]\n#align list.pmap_prev_eq_rotate_length_sub_one List.pmap_prev_eq_rotate_length_sub_one\n\nset_option linter.deprecated false in\ntheorem prev_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :\n    prev l (next l x hx) (next_mem _ _ _) = x :=\n  by\n  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx\n  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]\n  cases' l with hd tl\n  · simp at hx\n  · have : (n + 1 + length tl) % (length tl + 1) = n := by\n      rw [length_cons] at hn\n      rw [add_assoc, add_comm 1, Nat.add_mod_right, Nat.mod_eq_of_lt hn]\n    simp only [length_cons, Nat.succ_sub_succ_eq_sub, tsub_zero, Nat.succ_eq_add_one, this]\n#align list.prev_next List.prev_next\n\nset_option linter.deprecated false in\ntheorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :\n    next l (prev l x hx) (prev_mem _ _ _) = x :=\n  by\n  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx\n  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]\n  cases' l with hd tl\n  · simp at hx\n  · have : (n + length tl + 1) % (length tl + 1) = n := by\n      rw [length_cons] at hn\n      rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn]\n    simp [this]\n#align list.next_prev List.next_prev\n\nset_option linter.deprecated false in\ntheorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :\n    prev l.reverse x (mem_reverse'.mpr hx) = next l x hx :=\n  by\n  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx\n  have lpos : 0 < l.length := k.zero_le.trans_lt hk\n  have key : l.length - 1 - k < l.length :=\n    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')\n  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]\n  simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]\n  rw [← nthLe_pmap l.reverse.prev fun _ h => h]\n  · simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,\n      length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'),\n      tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)]\n    rw [← nthLe_reverse]\n    · simp [tsub_tsub_cancel_of_le (Nat.le_pred_of_lt hk)]\n    · simpa using (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')\n    . simpa\n#align list.prev_reverse_eq_next List.prev_reverse_eq_next\n\ntheorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :\n    next l.reverse x (mem_reverse'.mpr hx) = prev l x hx :=\n  by\n  convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x ((mem_reverse _ _).mpr hx)).symm\n  exact (reverse_reverse l).symm\n#align list.next_reverse_eq_prev List.next_reverse_eq_prev\n\nset_option linter.deprecated false in\ntheorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :\n    l.next x hx = l'.next x (h.mem_iff.mp hx) :=\n  by\n  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx\n  obtain ⟨n, rfl⟩ := id h\n  rw [next_nthLe _ hn]\n  simp_rw [← nthLe_rotate' _ n k]\n  rw [next_nthLe _ (h.nodup_iff.mp hn), ← nthLe_rotate' _ n]\n  simp [add_assoc]\n#align list.is_rotated_next_eq List.isRotated_next_eq\n\ntheorem isRotated_prev_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :\n    l.prev x hx = l'.prev x (h.mem_iff.mp hx) :=\n  by\n  rw [← next_reverse_eq_prev _ hn, ← next_reverse_eq_prev _ (h.nodup_iff.mp hn)]\n  exact isRotated_next_eq h.reverse (nodup_reverse.mpr hn) _\n#align list.is_rotated_prev_eq List.isRotated_prev_eq\n\nend List\n\nopen List\n\n/-- `Cycle α` is the quotient of `List α` by cyclic permutation.\nDuplicates are allowed.\n-/\ndef Cycle (α : Type _) : Type _ :=\n  Quotient (IsRotated.setoid α)\n#align cycle Cycle\n\nnamespace Cycle\n\nvariable {α : Type _}\n\n--Porting note: new definition\n/-- The coercion from `List α` to `Cycle α` -/\n@[coe] def ofList : List α → Cycle α :=\n  Quot.mk _\n\ninstance : Coe (List α) (Cycle α) :=\n  ⟨ofList⟩\n\n@[simp]\ntheorem coe_eq_coe {l₁ l₂ : List α} : (l₁ : Cycle α) = (l₂ : Cycle α) ↔ l₁ ~r l₂ :=\n  @Quotient.eq _ (IsRotated.setoid _) _ _\n#align cycle.coe_eq_coe Cycle.coe_eq_coe\n\n@[simp]\ntheorem mk_eq_coe (l : List α) : Quot.mk _ l = (l : Cycle α) :=\n  rfl\n#align cycle.mk_eq_coe Cycle.mk_eq_coe\n\n@[simp]\ntheorem mk''_eq_coe (l : List α) : Quotient.mk'' l = (l : Cycle α) :=\n  rfl\n#align cycle.mk'_eq_coe Cycle.mk''_eq_coe\n\ntheorem coe_cons_eq_coe_append (l : List α) (a : α) :\n    (↑(a :: l) : Cycle α) = (↑(l ++ [a]) : Cycle α) :=\n  Quot.sound ⟨1, by rw [rotate_cons_succ, rotate_zero]⟩\n#align cycle.coe_cons_eq_coe_append Cycle.coe_cons_eq_coe_append\n\n/-- The unique empty cycle. -/\ndef nil : Cycle α :=\n  ([] : List α)\n#align cycle.nil Cycle.nil\n\n@[simp]\ntheorem coe_nil : ↑([] : List α) = @nil α :=\n  rfl\n#align cycle.coe_nil Cycle.coe_nil\n\n@[simp]\ntheorem coe_eq_nil (l : List α) : (l : Cycle α) = nil ↔ l = [] :=\n  coe_eq_coe.trans isRotated_nil_iff\n#align cycle.coe_eq_nil Cycle.coe_eq_nil\n\n/-- For consistency with `EmptyCollection (List α)`. -/\ninstance : EmptyCollection (Cycle α) :=\n  ⟨nil⟩\n\n@[simp]\ntheorem empty_eq : ∅ = @nil α :=\n  rfl\n#align cycle.empty_eq Cycle.empty_eq\n\ninstance : Inhabited (Cycle α) :=\n  ⟨nil⟩\n\n/-- An induction principle for `Cycle`. Use as `induction s using Cycle.induction_on`. -/\n@[elab_as_elim]\ntheorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)\n    (HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=\n  Quotient.inductionOn' s fun l => by\n    refine List.recOn l ?_ ?_ <;> simp\n    assumption'\n#align cycle.induction_on Cycle.induction_on\n\n/-- For `x : α`, `s : Cycle α`, `x ∈ s` indicates that `x` occurs at least once in `s`. -/\ndef Mem (a : α) (s : Cycle α) : Prop :=\n  Quot.liftOn s (fun l => a ∈ l) fun _ _ e => propext <| e.mem_iff\n#align cycle.mem Cycle.Mem\n\ninstance : Membership α (Cycle α) :=\n  ⟨Mem⟩\n\n@[simp]\ntheorem mem_coe_iff {a : α} {l : List α} : a ∈ (↑l : Cycle α) ↔ a ∈ l :=\n  Iff.rfl\n#align cycle.mem_coe_iff Cycle.mem_coe_iff\n\n@[simp]\ntheorem not_mem_nil : ∀ a, a ∉ @nil α :=\n  List.not_mem_nil\n#align cycle.not_mem_nil Cycle.not_mem_nil\n\ninstance [DecidableEq α] : DecidableEq (Cycle α) := fun s₁ s₂ =>\n  Quotient.recOnSubsingleton₂' s₁ s₂ fun _ _ => decidable_of_iff' _ Quotient.eq''\n\ninstance [DecidableEq α] (x : α) (s : Cycle α) : Decidable (x ∈ s) :=\n  Quotient.recOnSubsingleton' s fun l => show Decidable (x ∈ l) from inferInstance\n\n/-- Reverse a `s : Cycle α` by reversing the underlying `List`. -/\nnonrec def reverse (s : Cycle α) : Cycle α :=\n  Quot.map reverse (fun _ _ => IsRotated.reverse) s\n#align cycle.reverse Cycle.reverse\n\n@[simp]\ntheorem reverse_coe (l : List α) : (l : Cycle α).reverse = l.reverse :=\n  rfl\n#align cycle.reverse_coe Cycle.reverse_coe\n\n@[simp]\ntheorem mem_reverse_iff {a : α} {s : Cycle α} : a ∈ s.reverse ↔ a ∈ s :=\n  Quot.inductionOn s fun _ => mem_reverse'\n#align cycle.mem_reverse_iff Cycle.mem_reverse_iff\n\n@[simp]\ntheorem reverse_reverse (s : Cycle α) : s.reverse.reverse = s :=\n  Quot.inductionOn s fun _ => by simp\n#align cycle.reverse_reverse Cycle.reverse_reverse\n\n@[simp]\ntheorem reverse_nil : nil.reverse = @nil α :=\n  rfl\n#align cycle.reverse_nil Cycle.reverse_nil\n\n/-- The length of the `s : Cycle α`, which is the number of elements, counting duplicates. -/\ndef length (s : Cycle α) : ℕ :=\n  Quot.liftOn s List.length fun _ _ e => e.perm.length_eq\n#align cycle.length Cycle.length\n\n@[simp]\ntheorem length_coe (l : List α) : length (l : Cycle α) = l.length :=\n  rfl\n#align cycle.length_coe Cycle.length_coe\n\n@[simp]\ntheorem length_nil : length (@nil α) = 0 :=\n  rfl\n#align cycle.length_nil Cycle.length_nil\n\n@[simp]\ntheorem length_reverse (s : Cycle α) : s.reverse.length = s.length :=\n  Quot.inductionOn s List.length_reverse\n#align cycle.length_reverse Cycle.length_reverse\n\n/-- A `s : Cycle α` that is at most one element. -/\ndef Subsingleton (s : Cycle α) : Prop :=\n  s.length ≤ 1\n#align cycle.subsingleton Cycle.Subsingleton\n\ntheorem subsingleton_nil : Subsingleton (@nil α) :=\n  zero_le_one\n#align cycle.subsingleton_nil Cycle.subsingleton_nil\n\ntheorem length_subsingleton_iff {s : Cycle α} : Subsingleton s ↔ length s ≤ 1 :=\n  Iff.rfl\n#align cycle.length_subsingleton_iff Cycle.length_subsingleton_iff\n\n@[simp]\ntheorem subsingleton_reverse_iff {s : Cycle α} : s.reverse.Subsingleton ↔ s.Subsingleton := by\n  simp [length_subsingleton_iff]\n#align cycle.subsingleton_reverse_iff Cycle.subsingleton_reverse_iff\n\ntheorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :\n    ∀ ⦃x⦄ (_hx : x ∈ s) ⦃y⦄ (_hy : y ∈ s), x = y :=\n  by\n  induction' s using Quot.inductionOn with l\n  simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, Nat.lt_add_one_iff,\n    length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h\n  rcases h with (rfl | ⟨z, rfl⟩) <;> simp\n#align cycle.subsingleton.congr Cycle.Subsingleton.congr\n\n/-- A `s : Cycle α` that is made up of at least two unique elements. -/\ndef Nontrivial (s : Cycle α) : Prop :=\n  ∃ (x y : α)(_h : x ≠ y), x ∈ s ∧ y ∈ s\n#align cycle.nontrivial Cycle.Nontrivial\n\n@[simp]\ntheorem nontrivial_coe_nodup_iff {l : List α} (hl : l.Nodup) :\n    Nontrivial (l : Cycle α) ↔ 2 ≤ l.length :=\n  by\n  rw [Nontrivial]\n  rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)\n  · simp\n  · simp\n  · simp only [mem_cons, exists_prop, mem_coe_iff, List.length, Ne.def, Nat.succ_le_succ_iff,\n      zero_le, iff_true_iff]\n    refine' ⟨hd, hd', _, by simp⟩\n    simp only [not_or, mem_cons, nodup_cons] at hl\n    exact hl.left.left\n#align cycle.nontrivial_coe_nodup_iff Cycle.nontrivial_coe_nodup_iff\n\n@[simp]\ntheorem nontrivial_reverse_iff {s : Cycle α} : s.reverse.Nontrivial ↔ s.Nontrivial := by\n  simp [Nontrivial]\n#align cycle.nontrivial_reverse_iff Cycle.nontrivial_reverse_iff\n\ntheorem length_nontrivial {s : Cycle α} (h : Nontrivial s) : 2 ≤ length s := by\n  obtain ⟨x, y, hxy, hx, hy⟩ := h\n  induction' s using Quot.inductionOn with l\n  rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)\n  · simp at hx\n  · simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy\n    simp [hx, hy] at hxy\n  · simp [Nat.succ_le_succ_iff]\n#align cycle.length_nontrivial Cycle.length_nontrivial\n\n/-- The `s : Cycle α` contains no duplicates. -/\nnonrec def Nodup (s : Cycle α) : Prop :=\n  Quot.liftOn s Nodup fun _l₁ _l₂ e => propext <| e.nodup_iff\n#align cycle.nodup Cycle.Nodup\n\n@[simp]\nnonrec theorem nodup_nil : Nodup (@nil α) :=\n  nodup_nil\n#align cycle.nodup_nil Cycle.nodup_nil\n\n@[simp]\ntheorem nodup_coe_iff {l : List α} : Nodup (l : Cycle α) ↔ l.Nodup :=\n  Iff.rfl\n#align cycle.nodup_coe_iff Cycle.nodup_coe_iff\n\n@[simp]\ntheorem nodup_reverse_iff {s : Cycle α} : s.reverse.Nodup ↔ s.Nodup :=\n  Quot.inductionOn s fun _ => nodup_reverse\n#align cycle.nodup_reverse_iff Cycle.nodup_reverse_iff\n\ntheorem Subsingleton.nodup {s : Cycle α} (h : Subsingleton s) : Nodup s :=\n  by\n  induction' s using Quot.inductionOn with l\n  cases' l with hd tl\n  · simp\n  · have : tl = [] := by simpa [Subsingleton, length_eq_zero, Nat.succ_le_succ_iff] using h\n    simp [this]\n#align cycle.subsingleton.nodup Cycle.Subsingleton.nodup\n\ntheorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬Subsingleton s :=\n  by\n  rw [length_subsingleton_iff]\n  induction s using Quotient.inductionOn'\n  simp only [mk''_eq_coe, nodup_coe_iff] at h\n  simp [h, Nat.succ_le_iff]\n#align cycle.nodup.nontrivial_iff Cycle.Nodup.nontrivial_iff\n\n/-- The `s : Cycle α` as a `Multiset α`.\n-/\ndef toMultiset (s : Cycle α) : Multiset α :=\n  Quotient.liftOn' s (↑) fun _ _  h => Multiset.coe_eq_coe.mpr h.perm\n#align cycle.to_multiset Cycle.toMultiset\n\n@[simp]\ntheorem coe_toMultiset (l : List α) : (l : Cycle α).toMultiset = l :=\n  rfl\n#align cycle.coe_to_multiset Cycle.coe_toMultiset\n\n@[simp]\ntheorem nil_toMultiset : nil.toMultiset = (0 : Multiset α) :=\n  rfl\n#align cycle.nil_to_multiset Cycle.nil_toMultiset\n\n@[simp]\ntheorem card_toMultiset (s : Cycle α) : Multiset.card s.toMultiset = s.length :=\n  Quotient.inductionOn' s (by simp)\n#align cycle.card_to_multiset Cycle.card_toMultiset\n\n@[simp]\ntheorem toMultiset_eq_nil {s : Cycle α} : s.toMultiset = 0 ↔ s = Cycle.nil :=\n  Quotient.inductionOn' s (by simp)\n#align cycle.to_multiset_eq_nil Cycle.toMultiset_eq_nil\n\n/-- The lift of `list.map`. -/\ndef map {β : Type _} (f : α → β) : Cycle α → Cycle β :=\n  Quotient.map' (List.map f) fun _ _ h => h.map _\n#align cycle.map Cycle.map\n\n@[simp]\ntheorem map_nil {β : Type _} (f : α → β) : map f nil = nil :=\n  rfl\n#align cycle.map_nil Cycle.map_nil\n\n@[simp]\ntheorem map_coe {β : Type _} (f : α → β) (l : List α) : map f ↑l = List.map f l :=\n  rfl\n#align cycle.map_coe Cycle.map_coe\n\n@[simp]\ntheorem map_eq_nil {β : Type _} (f : α → β) (s : Cycle α) : map f s = nil ↔ s = nil :=\n  Quotient.inductionOn' s (by simp)\n#align cycle.map_eq_nil Cycle.map_eq_nil\n\n@[simp]\ntheorem mem_map {β : Type _} {f : α → β} {b : β} {s : Cycle α} :\n    b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=\n  Quotient.inductionOn' s (by simp)\n#align cycle.mem_map Cycle.mem_map\n\n/-- The `Multiset` of lists that can make the cycle. -/\ndef lists (s : Cycle α) : Multiset (List α) :=\n  Quotient.liftOn' s (fun l => (l.cyclicPermutations : Multiset (List α))) fun l₁ l₂ h => by\n    simpa using h.cyclicPermutations.perm\n#align cycle.lists Cycle.lists\n\n@[simp]\n\n\n@[simp]\ntheorem mem_lists_iff_coe_eq {s : Cycle α} {l : List α} : l ∈ s.lists ↔ (l : Cycle α) = s :=\n  Quotient.inductionOn' s fun l => by\n    rw [lists, Quotient.liftOn'_mk'']\n    simp\n#align cycle.mem_lists_iff_coe_eq Cycle.mem_lists_iff_coe_eq\n\n@[simp]\ntheorem lists_nil : lists (@nil α) = [([] : List α)] := by\n  rw [nil, lists_coe, cyclicPermutations_nil]\n#align cycle.lists_nil Cycle.lists_nil\n\nsection Decidable\n\nvariable [DecidableEq α]\n\n/-- Auxiliary decidability algorithm for lists that contain at least two unique elements.\n-/\ndef decidableNontrivialCoe : ∀ l : List α, Decidable (Nontrivial (l : Cycle α))\n  | [] => isFalse (by simp [Nontrivial])\n  | [x] => isFalse (by simp [Nontrivial])\n  | x :: y :: l =>\n    if h : x = y then\n      @decidable_of_iff' _ (Nontrivial (x :: l : Cycle α)) (by simp [h, Nontrivial])\n        (decidableNontrivialCoe (x :: l))\n    else isTrue ⟨x, y, h, by simp, by simp⟩\n#align cycle.decidable_nontrivial_coe Cycle.decidableNontrivialCoe\n\ninstance {s : Cycle α} : Decidable (Nontrivial s) :=\n  Quot.recOnSubsingleton' s decidableNontrivialCoe\n\ninstance {s : Cycle α} : Decidable (Nodup s) :=\n  Quot.recOnSubsingleton' s List.nodupDecidable\n\ninstance fintypeNodupCycle [Fintype α] : Fintype { s : Cycle α // s.Nodup } :=\n  Fintype.ofSurjective (fun l : { l : List α // l.Nodup } => ⟨l.val, by simpa using l.prop⟩)\n    fun ⟨s, hs⟩ => by\n    induction' s using Quotient.inductionOn' with s hs\n    exact ⟨⟨s, hs⟩, by simp⟩\n#align cycle.fintype_nodup_cycle Cycle.fintypeNodupCycle\n\ninstance fintypeNodupNontrivialCycle [Fintype α] :\n    Fintype { s : Cycle α // s.Nodup ∧ s.Nontrivial } :=\n  Fintype.subtype\n    (((Finset.univ : Finset { s : Cycle α // s.Nodup }).map (Function.Embedding.subtype _)).filter\n      Cycle.Nontrivial)\n    (by simp)\n#align cycle.fintype_nodup_nontrivial_cycle Cycle.fintypeNodupNontrivialCycle\n\n/-- The `s : Cycle α` as a `Finset α`. -/\ndef toFinset (s : Cycle α) : Finset α :=\n  s.toMultiset.toFinset\n#align cycle.to_finset Cycle.toFinset\n\n@[simp]\ntheorem toFinset_toMultiset (s : Cycle α) : s.toMultiset.toFinset = s.toFinset :=\n  rfl\n#align cycle.to_finset_to_multiset Cycle.toFinset_toMultiset\n\n@[simp]\ntheorem coe_toFinset (l : List α) : (l : Cycle α).toFinset = l.toFinset :=\n  rfl\n#align cycle.coe_to_finset Cycle.coe_toFinset\n\n@[simp]\ntheorem nil_toFinset : (@nil α).toFinset = ∅ :=\n  rfl\n#align cycle.nil_to_finset Cycle.nil_toFinset\n\n@[simp]\ntheorem toFinset_eq_nil {s : Cycle α} : s.toFinset = ∅ ↔ s = Cycle.nil :=\n  Quotient.inductionOn' s (by simp)\n#align cycle.to_finset_eq_nil Cycle.toFinset_eq_nil\n\n/-- Given a `s : Cycle α` such that `Nodup s`, retrieve the next element after `x ∈ s`. -/\nnonrec def next : ∀ (s : Cycle α) (_hs : Nodup s) (x : α) (_hx : x ∈ s), α := fun s =>\n  Quot.hrecOn (motive := fun (s : Cycle α) => ∀ (_hs : Cycle.Nodup s) (x : α) (_hx : x ∈ s), α) s\n  (fun l _hn x hx => next l x hx) fun l₁ l₂ h =>\n    Function.hfunext (propext h.nodup_iff) fun h₁ h₂ _he =>\n      Function.hfunext rfl fun x y hxy =>\n        Function.hfunext (propext (by rw [eq_of_heq hxy]; simpa [eq_of_heq hxy] using h.mem_iff))\n  fun hm hm' he' => heq_of_eq\n    (by rw [heq_iff_eq] at hxy; subst x; simpa using isRotated_next_eq h h₁ _)\n#align cycle.next Cycle.next\n\n/-- Given a `s : Cycle α` such that `Nodup s`, retrieve the previous element before `x ∈ s`. -/\nnonrec def prev : ∀ (s : Cycle α) (_hs : Nodup s) (x : α) (_hx : x ∈ s), α := fun s =>\n  Quot.hrecOn (motive := fun (s : Cycle α) => ∀ (_hs : Cycle.Nodup s) (x : α) (_hx : x ∈ s), α) s\n  (fun l _hn x hx => prev l x hx) fun l₁ l₂ h =>\n    Function.hfunext (propext h.nodup_iff) fun h₁ h₂ _he =>\n      Function.hfunext rfl fun x y hxy =>\n        Function.hfunext (propext (by rw [eq_of_heq hxy]; simpa [eq_of_heq hxy] using h.mem_iff))\n  fun hm hm' he' => heq_of_eq\n    (by rw [heq_iff_eq] at hxy; subst x; simpa using isRotated_prev_eq h h₁ _)\n#align cycle.prev Cycle.prev\n\n--Porting note: removed `simp` and added `prev_reverse_eq_next'` with `simp` attribute\nnonrec theorem prev_reverse_eq_next (s : Cycle α) : ∀ (hs : Nodup s) (x : α) (hx : x ∈ s),\n    s.reverse.prev (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.next hs x hx :=\n  Quotient.inductionOn' s prev_reverse_eq_next\n#align cycle.prev_reverse_eq_next Cycle.prev_reverse_eq_next\n\n--Porting note: new theorem\n@[simp]\nnonrec theorem prev_reverse_eq_next' (s : Cycle α) (hs : Nodup s.reverse) (x : α)\n    (hx : x ∈ s.reverse) :\n    s.reverse.prev hs x hx = s.next (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx) :=\n  prev_reverse_eq_next s (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx)\n\n--Porting note: removed `simp` and added `next_reverse_eq_prev'` with `simp` attribute\ntheorem next_reverse_eq_prev (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) :\n    s.reverse.next (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.prev hs x hx := by\n  simp [← prev_reverse_eq_next]\n#align cycle.next_reverse_eq_prev Cycle.next_reverse_eq_prev\n\n--Porting note: new theorem\n@[simp]\ntheorem next_reverse_eq_prev' (s : Cycle α) (hs : Nodup s.reverse) (x : α) (hx : x ∈ s.reverse) :\n    s.reverse.next hs x hx = s.prev (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx) := by\n  simp [← prev_reverse_eq_next]\n\n@[simp]\nnonrec theorem next_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.next hs x hx ∈ s := by\n  induction s using Quot.inductionOn\n  apply next_mem; assumption\n#align cycle.next_mem Cycle.next_mem\n\ntheorem prev_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.prev hs x hx ∈ s :=\n  by\n  rw [← next_reverse_eq_prev, ← mem_reverse_iff]\n  apply next_mem\n#align cycle.prev_mem Cycle.prev_mem\n\n@[simp]\nnonrec theorem prev_next (s : Cycle α) : ∀ (hs : Nodup s) (x : α) (hx : x ∈ s),\n    s.prev hs (s.next hs x hx) (next_mem s hs x hx) = x :=\n  Quotient.inductionOn' s prev_next\n#align cycle.prev_next Cycle.prev_next\n\n@[simp]\nnonrec theorem next_prev (s : Cycle α) : ∀ (hs : Nodup s) (x : α) (hx : x ∈ s),\n    s.next hs (s.prev hs x hx) (prev_mem s hs x hx) = x :=\n  Quotient.inductionOn' s next_prev\n#align cycle.next_prev Cycle.next_prev\n\nend Decidable\n\n/-- We define a representation of concrete cycles, available when viewing them in a goal state or\nvia `#eval`, when over representable types. For example, the cycle `(2 1 4 3)` will be shown\nas `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation\nis different.\n-/\nunsafe instance [Repr α] : Repr (Cycle α) :=\n  ⟨fun s _ => \"c[\" ++ Std.Format.joinSep (s.map repr).lists.unquot.head! \", \" ++ \"]\"⟩\n\n/-- `chain R s` means that `R` holds between adjacent elements of `s`.\n\n`chain R ([a, b, c] : Cycle α) ↔ R a b ∧ R b c ∧ R c a` -/\nnonrec def Chain (r : α → α → Prop) (c : Cycle α) : Prop :=\n  Quotient.liftOn' c\n    (fun l =>\n      match l with\n      | [] => True\n      | a :: m => Chain r a (m ++ [a]))\n    fun a b hab =>\n    propext <| by\n      cases' a with a l <;> cases' b with b m\n      · rfl\n      · have := isRotated_nil_iff'.1 hab\n        contradiction\n      · have := isRotated_nil_iff.1 hab\n        contradiction\n      · dsimp only\n        cases' hab with n hn\n        induction' n with d hd generalizing a b l m\n        · simp only [Nat.zero_eq, rotate_zero, cons.injEq] at hn\n          rw [hn.1, hn.2]\n        · cases' l with c s\n          · simp only [rotate_cons_succ, nil_append, rotate_singleton, cons.injEq] at hn\n            rw [hn.1, hn.2]\n          · rw [Nat.succ_eq_one_add, ← rotate_rotate, rotate_cons_succ, rotate_zero,\n              cons_append] at hn\n            rw [← hd c _ _ _ hn]\n            simp [and_comm]\n#align cycle.chain Cycle.Chain\n\n@[simp]\ntheorem Chain.nil (r : α → α → Prop) : Cycle.Chain r (@nil α) := by trivial\n#align cycle.chain.nil Cycle.Chain.nil\n\n@[simp]\ntheorem chain_coe_cons (r : α → α → Prop) (a : α) (l : List α) :\n    Chain r (a :: l) ↔ List.Chain r a (l ++ [a]) :=\n  Iff.rfl\n#align cycle.chain_coe_cons Cycle.chain_coe_cons\n\n--@[simp] Porting note: `simp` can prove it\ntheorem chain_singleton (r : α → α → Prop) (a : α) : Chain r [a] ↔ r a a := by\n  rw [chain_coe_cons, nil_append, List.chain_singleton]\n#align cycle.chain_singleton Cycle.chain_singleton\n\ntheorem chain_ne_nil (r : α → α → Prop) {l : List α} :\n    ∀ hl : l ≠ [], Chain r l ↔ List.Chain r (getLast l hl) l :=\n  l.reverseRecOn (fun hm => hm.irrefl.elim) (by\n    intro m a _H _\n    rw [← coe_cons_eq_coe_append, chain_coe_cons, getLast_append_singleton])\n#align cycle.chain_ne_nil Cycle.chain_ne_nil\n\ntheorem chain_map {β : Type _} {r : α → α → Prop} (f : β → α) {s : Cycle β} :\n    Chain r (s.map f) ↔ Chain (fun a b => r (f a) (f b)) s :=\n  Quotient.inductionOn' s fun l => by\n    cases' l with a l\n    rfl\n    dsimp only [Chain, ← mk''_eq_coe, Quotient.liftOn'_mk'', Cycle.map, Quotient.map', Quot.map,\n      Quotient.mk'', Quotient.liftOn', Quotient.liftOn, Quot.liftOn_mk, List.map]\n    rw [← concat_eq_append, ← List.map_concat, List.chain_map f]\n    simp\n#align cycle.chain_map Cycle.chain_map\n\nnonrec theorem chain_range_succ (r : ℕ → ℕ → Prop) (n : ℕ) :\n    Chain r (List.range n.succ) ↔ r n 0 ∧ ∀ m < n, r m m.succ := by\n  rw [range_succ, ← coe_cons_eq_coe_append, chain_coe_cons, ← range_succ, chain_range_succ]\n#align cycle.chain_range_succ Cycle.chain_range_succ\n\nvariable {r : α → α → Prop} {s : Cycle α}\n\ntheorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s := by\n  induction' s using Cycle.induction_on with a l _\n  exact fun _ => Cycle.Chain.nil r\n  intro hs\n  have Ha : a ∈ (a :: l : Cycle α) := by simp\n  have Hl : ∀ {b} (_hb : b ∈ l), b ∈ (a :: l : Cycle α) := @fun b hb => by simp [hb]\n  rw [Cycle.chain_coe_cons]\n  apply Pairwise.chain\n  rw [pairwise_cons]\n  refine'\n    ⟨fun b hb => _,\n      pairwise_append.2\n        ⟨pairwise_of_forall_mem_list fun b hb c hc => hs b (Hl hb) c (Hl hc),\n          pairwise_singleton r a, fun b hb c hc => _⟩⟩\n  · rw [mem_append] at hb\n    cases' hb with hb hb\n    · exact hs a Ha b (Hl hb)\n    · rw [mem_singleton] at hb\n      rw [hb]\n      exact hs a Ha a Ha\n  · rw [mem_singleton] at hc\n    rw [hc]\n    exact hs b (Hl hb) a Ha\n#align cycle.chain_of_pairwise Cycle.chain_of_pairwise\n\ntheorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈ s, r a b :=\n  ⟨by\n    induction' s using Cycle.induction_on with a l _\n    · exact fun _ b hb => (not_mem_nil _ hb).elim\n    intro hs b hb c hc\n    rw [Cycle.chain_coe_cons, List.chain_iff_pairwise] at hs\n    simp only [pairwise_append, pairwise_cons, mem_append, mem_singleton, List.not_mem_nil,\n      IsEmpty.forall_iff, imp_true_iff, Pairwise.nil, forall_eq, true_and_iff] at hs\n    simp only [mem_coe_iff, mem_cons] at hb hc\n    rcases hb with (rfl | hb) <;> rcases hc with (rfl | hc)\n    · exact hs.1 c (Or.inr rfl)\n    · exact hs.1 c (Or.inl hc)\n    · exact hs.2.2 b hb\n    · exact _root_.trans (hs.2.2 b hb) (hs.1 c (Or.inl hc)), Cycle.chain_of_pairwise⟩\n#align cycle.chain_iff_pairwise Cycle.chain_iff_pairwise\n\ntheorem forall_eq_of_chain [IsTrans α r] [IsAntisymm α r] (hs : Chain r s) {a b : α} (ha : a ∈ s)\n    (hb : b ∈ s) : a = b := by\n  rw [chain_iff_pairwise] at hs\n  exact antisymm (hs a ha b hb) (hs b hb a ha)\n#align cycle.forall_eq_of_chain Cycle.forall_eq_of_chain\n\nend Cycle\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/List/Cycle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979746, "lm_q2_score": 0.7310585669110202, "lm_q1q2_score": 0.4990013666494311}}
{"text": "/- Type classes -/\n\n\nnamespace tp \n\n  structure Add1 (α : Type u) where\n    add : α → α → α \n\n  def double (s : Add1 α) (x : α) :=\n    s.add x x\n\n  #eval double {add := Nat.add} 10 -- 20\n\n  class Add (α : Type u) where\n    add : α → α → α \n\n  instance : Add Nat where\n    add := Nat.add\n\n  instance [Add α] : Add (Array α) where \n    add x y := Array.zipWith x y (Add.add . .)\n\n  #eval Add.add #[1, 2] #[3, 4] -- #[4, 6]\n\n  namespace Ex\n\n    class Inhabited (α : Type u) where \n      default : α \n\n    instance : Inhabited Bool where \n      default := true \n\n    instance : Inhabited Nat where \n      default := 0\n\n    export Inhabited (default)\n\n    #eval (default : Nat)  -- 0\n    #eval (default : Bool) -- true\n\n  end Ex \nend tp \n\n\n/- Chaining Instances -/\n\nnamespace ci \n\n  instance [Inhabited α] [Inhabited β] : Inhabited (α × β) where \n    default := (default, default)\n\n  #eval (default : Nat × Bool) -- (0, false)\n\n  instance [Inhabited β] : Inhabited (α → β) where \n    default := fun _ => default \n\n  instance [Inhabited α] : Inhabited (List α) where \n    default := [default]\n\n  #eval (default : List Nat) -- [0]\n\n  instance [Inhabited α] : Inhabited (Sum α β) where \n    default := Sum.inl default \n\n  #print inferInstance \n\nend ci\n\n\n/- ToString -/\n\nnamespace ts  \n\n  structure Person where\n    name : String \n    age : Nat \n\n  instance : ToString Person where \n    toString p := p.name ++ \"@\" ++ toString p.age \n\n  #eval toString ({name := \"Leo\", age := 25 : Person}, 10) -- \"(Leo@25, 10)\"\nend ts \n\n\n/- Numerals -/\n\nnamespace num \n\n  structure Rational where\n    num : Int \n    den : Nat \n    inv : den ≠ 0 \n\n  instance : OfNat Rational n where \n    ofNat := {num := n, den := 1, inv := by decide}\n\n  instance : ToString Rational where \n    toString r := s!\"{r.num}/{r.den}\"\n\n  #eval (2 : Rational) -- 2/1\n\n  class Monoid (α : Type u) where \n    unit : α \n    op : α → α → α \n\n  instance [s : Monoid α] : OfNat α (nat_lit 1) where \n    ofNat := s.unit\n\n  def getUnit [Monoid α] : α :=\n    1 \n\nend num \n\n\n/- Output Parameters -/\n\nnamespace op  \n\n  class HMul (α : Type u) (β : Type v) (γ : outParam (Type w)) where \n    hMul : α → β → γ \n\n  export HMul (hMul)\n\n  instance : HMul Nat Nat Nat where \n    hMul := Nat.mul\n\n  instance [HMul α β γ]: HMul α (Array β) (Array γ) where \n    hMul a bs := bs.map (fun b => hMul a b)\n\n  #eval hMul 3 #[1, 2] -- #[3, 6]\n\n  #eval hMul 3 #[#[1, 2], #[3]] -- #[#[3, 6], #[9]]\n\nend op \n\n\n/- Defalut instances -/\n\nnamespace di \n\n  class HMul (α : Type u) (β : Type v) (γ : outParam (Type w)) where \n    hMul : α → β → γ \n\n  export HMul (hMul)\n\n  @[defaultInstance]\n  instance : HMul Int Int Int where \n    hMul := Int.mul \n\n  #check (fun y => [1, 2].map (fun x => hMul y x)) -- Int → List Int \n\n  class Mul (α : Type u) where \n    mul : α → α → α \n\n  @[defaultInstance 10]\n  instance [Mul α] : HMul α α α  where \n    hMul := Mul.mul\n\nend di\n\n\n/- Local Instances -/\n\nnamespace li  \n\n  structure Point where \n    x : Nat \n    y : Nat \n\n  section \n    local instance addPoint : Add Point where \n      add p q := {x := p.x + q.x, y:= p.y + q.y}\n\n    attribute [-instance] addPoint \n  end \nend li \n\n\n/- Scoped Instances -/\n\nnamespace si  \n\n  structure Point where \n    x : Nat \n    y : Nat \n\n  namespace Point \n    scoped instance addPoint : Add Point where \n      add p q := {x := p.x + q.x, y:= p.y + q.y}\n  end Point \n\nend si\n\n\n/- Decidable Propositions -/\n\nnamespace dp \n\n  class inductive Decidable (p : Prop) where\n  | isFalse (h : ¬ p) : Decidable p\n  | isTrue (h : p) : Decidable p \n\n  def ite {α : Sort u} (c : Prop) [h : Decidable c] (t e : α) : α :=\n    match h with \n    | Decidable.isTrue _  => t\n    | Decidable.isFalse _ => e \n\n  def dite {α : Sort u} (c : Prop) [h : Decidable c] (t : c → α) (e : ¬ c → α) : α :=\n    match h with \n    | Decidable.isTrue c => t c\n    | Decidable.isFalse nc => e nc \n\n  example : ¬ (True ∧ False) := by decide \n\nend dp \n\n/- Managing Type Class Inference -/\n\nnamespace mtci \n\n  def foo : Inhabited (Nat → Nat) := inferInstance\n\n  def Set (α : Type u) := α → Prop \n\n  example : Inhabited (Set α) := \n    inferInstanceAs (Inhabited (α → Prop))\n\nend mtci\n\n\n/- Coercions using Type Classes-/\n\nnamespace coer \n\n  instance : Coe Bool Prop where \n    coe b := b = true \n\n  #eval if true then 5 else 3 -- 5\n\n  def Set (α : Type u) := α → Prop \n  def Set.empty {α : Type u} : Set α := fun _ => False \n  def Set.mem (a : α) (s : Set α) : Prop := s a \n  def Set.singleton (a : α) : Set α := fun x => x = a \n  def Set.union (a b : Set α) : Set α := fun x => a x ∨ b x \n  notation \"{\" a \"}\" => Set.singleton a \n  infix:55 \" ∪ \" => Set.union\n\n\n  def List.toSet : List α → Set α\n    | []    => Set.empty\n    | a::as => {a} ∪ toSet as \n\n  instance : Coe (List α) (Set α) where \n    coe as := List.toSet as \n\n  /-\n  {1} ∪ List.toSet [1, 2] : Set Nat\n  -/\n  #check {1} ∪ ↑[1, 2] \n\n\n  instance (p : Prop) [Decidable p] : CoeDep Prop p Bool where \n    coe := decide p \n\n  \n  structure Semigroup where \n    carrier : Type u\n    mul : carrier → carrier → carrier \n    mul_assoc (a b c : carrier) : mul (mul a b) c = mul a (mul b c)\n\n  instance (S : Semigroup) : Mul S.carrier where \n    mul := S.mul \n\n  instance : CoeSort Semigroup (Type u) where \n    coe s := s.carrier \n\n  example (S : Semigroup) (a b c : S) : (a * b) * c = a * (b * c) := \n    S.mul_assoc a b c \n\n\n  structure Morphism (S1 S2 : Semigroup) where \n    mor : S1 → S2 \n    resp_mul : ∀ a b : S1, mor (a * b) = mor a * mor b \n  \n  #check @Morphism.mor\n\n  instance (S1 S2 : Semigroup) : CoeFun (Morphism S1 S2) (fun _ => S1 → S2) where \n    coe m := m.mor \n\n  theorem resp_mul {S1 S2 : Semigroup} (f : Morphism S1 S2) (a b : S1)\n      : f (a * b) = f a * f b := f.resp_mul a b \n\n  example {S1 S2 : Semigroup} (f : Morphism S1 S2) (a : S1)\n      : f (a * a * a) = f a * f a * f a := by simp only [resp_mul]\n\n      \n\n\nend coer", "meta": {"author": "ManuelAlejandroMartinezFlores", "repo": "LEAN_projects", "sha": "e60bda4bf3d9bbf4b958dd24641c97ac90da9514", "save_path": "github-repos/lean/ManuelAlejandroMartinezFlores-LEAN_projects", "path": "github-repos/lean/ManuelAlejandroMartinezFlores-LEAN_projects/LEAN_projects-e60bda4bf3d9bbf4b958dd24641c97ac90da9514/TheoremProvingLean/type_classes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669998, "lm_q2_score": 0.7577943767446202, "lm_q1q2_score": 0.4989450896343649}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.fp.basic\n! leanprover-community/mathlib commit 7b78d1776212a91ecc94cf601f83bdcc46b04213\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Semiquot\nimport Mathlib.Data.Rat.Floor\n\n/-!\n# Implementation of floating-point numbers (experimental).\n-/\n\n-- Porting note: TODO add docs and remove `@[nolint docBlame]`\n\n@[nolint docBlame]\ndef Int.shift2 (a b : ℕ) : ℤ → ℕ × ℕ\n  | Int.ofNat e => (a.shiftl e, b)\n  | Int.negSucc e => (a, b.shiftl e.succ)\n#align int.shift2 Int.shift2\n\nnamespace FP\n\n@[nolint docBlame]\ninductive RMode\n  | NE -- round to nearest even\n  deriving Inhabited\n#align fp.rmode FP.RMode\n\n@[nolint docBlame]\nclass FloatCfg where\n  (prec emax : ℕ)\n  precPos : 0 < prec\n  precMax : prec ≤ emax\nattribute [nolint docBlame] FloatCfg.prec FloatCfg.emax FloatCfg.precPos FloatCfg.precMax\n#align fp.float_cfg FP.FloatCfg\n\nvariable [C : FloatCfg]\n\n@[nolint docBlame]\ndef prec :=\n  C.prec\n#align fp.prec FP.prec\n\n@[nolint docBlame]\ndef emax :=\n  C.emax\n#align fp.emax FP.emax\n\n@[nolint docBlame]\ndef emin : ℤ :=\n  1 - C.emax\n#align fp.emin FP.emin\n\n@[nolint docBlame]\ndef ValidFinite (e : ℤ) (m : ℕ) : Prop :=\n  emin ≤ e + prec - 1 ∧ e + prec - 1 ≤ emax ∧ e = max (e + m.size - prec) emin\n#align fp.valid_finite FP.ValidFinite\n\ninstance decValidFinite (e m) : Decidable (ValidFinite e m) := by\n  (unfold ValidFinite; infer_instance)\n#align fp.dec_valid_finite FP.decValidFinite\n\n@[nolint docBlame]\ninductive Float\n  | inf : Bool → Float\n  | nan : Float\n  | finite : Bool → ∀ e m, ValidFinite e m → Float\n#align fp.float FP.Float\n\n@[nolint docBlame]\ndef Float.isFinite : Float → Bool\n  | Float.finite _ _ _ _ => true\n  | _ => false\n#align fp.float.is_finite FP.Float.isFinite\n\n@[nolint docBlame]\ndef toRat : ∀ f : Float, f.isFinite → ℚ\n  | Float.finite s e m _, _ =>\n    let (n, d) := Int.shift2 m 1 e\n    let r := mkRat n d\n    if s then -r else r\n#align fp.to_rat FP.toRat\n\ntheorem Float.Zero.valid : ValidFinite emin 0 :=\n  ⟨by\n    rw [add_sub_assoc]\n    apply le_add_of_nonneg_right\n    apply sub_nonneg_of_le\n    apply Int.ofNat_le_ofNat_of_le\n    exact C.precPos,\n    suffices prec ≤ 2 * emax by\n      rw [← Int.ofNat_le] at this\n      rw [← sub_nonneg] at *\n      simp only [emin, emax] at *\n      ring_nf\n      rw [mul_comm]\n      assumption\n    le_trans C.precMax (Nat.le_mul_of_pos_left (by decide)),\n    by (rw [max_eq_right]; simp [sub_eq_add_neg])⟩\n#align fp.float.zero.valid FP.Float.Zero.valid\n\n@[nolint docBlame]\ndef Float.zero (s : Bool) : Float :=\n  Float.finite s emin 0 Float.Zero.valid\n#align fp.float.zero FP.Float.zero\n\ninstance : Inhabited Float :=\n  ⟨Float.zero true⟩\n\n@[nolint docBlame]\nprotected def Float.sign' : Float → Semiquot Bool\n  | Float.inf s => pure s\n  | Float.nan => ⊤\n  | Float.finite s _ _ _ => pure s\n#align fp.float.sign' FP.Float.sign'\n\n@[nolint docBlame]\nprotected def Float.sign : Float → Bool\n  | Float.inf s => s\n  | Float.nan => false\n  | Float.finite s _ _ _ => s\n#align fp.float.sign FP.Float.sign\n\n@[nolint docBlame]\nprotected def Float.isZero : Float → Bool\n  | Float.finite _ _ 0 _ => true\n  | _ => false\n#align fp.float.is_zero FP.Float.isZero\n\n@[nolint docBlame]\nprotected def Float.neg : Float → Float\n  | Float.inf s => Float.inf (not s)\n  | Float.nan => Float.nan\n  | Float.finite s e m f => Float.finite (not s) e m f\n#align fp.float.neg FP.Float.neg\n\n@[nolint docBlame]\ndef divNatLtTwoPow (n d : ℕ) : ℤ → Bool\n  | Int.ofNat e => n < d.shiftl e\n  | Int.negSucc e => n.shiftl e.succ < d\n#align fp.div_nat_lt_two_pow FP.divNatLtTwoPowₓ -- Porting note: TC argument `[C : FP.FloatCfg]` no longer present\n\n\n-- TODO(Mario): Prove these and drop 'unsafe'\n@[nolint docBlame]\nunsafe def ofPosRatDn (n : ℕ+) (d : ℕ+) : Float × Bool := by\n  let e₁ : ℤ := n.1.size - d.1.size - prec\n  cases' h₁ : Int.shift2 d.1 n.1 (e₁ + prec) with d₁ n₁\n  let e₂ := if n₁ < d₁ then e₁ - 1 else e₁\n  let e₃ := max e₂ emin\n  cases' h₂ : Int.shift2 d.1 n.1 (e₃ + prec) with d₂ n₂\n  let r := mkRat n₂ d₂\n  let m := r.floor\n  refine' (Float.finite Bool.false e₃ (Int.toNat m) _, r.den = 1)\n  · exact lcProof\n#align fp.of_pos_rat_dn FP.ofPosRatDn\n\n-- Porting note: remove this line when you dropped 'lcProof'\nset_option linter.unusedVariables false in\n@[nolint docBlame]\nunsafe def nextUpPos (e m) (v : ValidFinite e m) : Float :=\n  let m' := m.succ\n  if ss : m'.size = m.size then\n    Float.finite false e m' (by unfold ValidFinite at *; rw [ss]; exact v)\n  else if h : e = emax then Float.inf false else Float.finite false e.succ (Nat.div2 m') lcProof\n#align fp.next_up_pos FP.nextUpPos\n\nset_option linter.deprecated false in\n-- Porting note: remove this line when you dropped 'lcProof'\nset_option linter.unusedVariables false in\n@[nolint docBlame]\nunsafe def nextDnPos (e m) (v : ValidFinite e m) : Float :=\n  match m with\n  | 0 => nextUpPos _ _ Float.Zero.valid\n  | Nat.succ m' =>\n    -- Porting note: was `m'.size = m.size`\n    if ss : m'.size = m'.succ.size then\n      Float.finite false e m' (by unfold ValidFinite at *; rw [ss]; exact v)\n    else\n      if h : e = emin then Float.finite false emin m' lcProof\n      else Float.finite false e.pred (bit1 m') lcProof\n#align fp.next_dn_pos FP.nextDnPos\n\n@[nolint docBlame]\nunsafe def nextUp : Float → Float\n  | Float.finite Bool.false e m f => nextUpPos e m f\n  | Float.finite Bool.true e m f => Float.neg <| nextDnPos e m f\n  | f => f\n#align fp.next_up FP.nextUp\n\n@[nolint docBlame]\nunsafe def nextDn : Float → Float\n  | Float.finite Bool.false e m f => nextDnPos e m f\n  | Float.finite Bool.true e m f => Float.neg <| nextUpPos e m f\n  | f => f\n#align fp.next_dn FP.nextDn\n\n@[nolint docBlame]\nunsafe def ofRatUp : ℚ → Float\n  | ⟨0, _, _, _⟩ => Float.zero false\n  | ⟨Nat.succ n, d, h, _⟩ =>\n    let (f, exact) := ofPosRatDn n.succPNat ⟨d, Nat.pos_of_ne_zero h⟩\n    if exact then f else nextUp f\n  | ⟨Int.negSucc n, d, h, _⟩ => Float.neg (ofPosRatDn n.succPNat ⟨d, Nat.pos_of_ne_zero h⟩).1\n#align fp.of_rat_up FP.ofRatUp\n\n@[nolint docBlame]\nunsafe def ofRatDn (r : ℚ) : Float :=\n  Float.neg <| ofRatUp (-r)\n#align fp.of_rat_dn FP.ofRatDn\n\n@[nolint docBlame]\nunsafe def ofRat : RMode → ℚ → Float\n  | RMode.NE, r =>\n    let low := ofRatDn r\n    let high := ofRatUp r\n    if hf : high.isFinite then\n      if r = toRat _ hf then high\n      else\n        if lf : low.isFinite then\n          if r - toRat _ lf > toRat _ hf - r then high\n          else\n            if r - toRat _ lf < toRat _ hf - r then low\n            else\n              match low, lf with\n              | Float.finite _ _ m _, _ => if 2 ∣ m then low else high\n        else Float.inf true\n    else Float.inf false\n#align fp.of_rat FP.ofRat\n\nnamespace Float\n\ninstance : Neg Float :=\n  ⟨Float.neg⟩\n\n@[nolint docBlame]\nunsafe def add (mode : RMode) : Float → Float → Float\n  | nan, _ => nan\n  | _, nan => nan\n  | inf Bool.true, inf Bool.false=> nan\n  | inf Bool.false, inf Bool.true => nan\n  | inf s₁, _ => inf s₁\n  | _, inf s₂ => inf s₂\n  | finite s₁ e₁ m₁ v₁, finite s₂ e₂ m₂ v₂ =>\n    let f₁ := finite s₁ e₁ m₁ v₁\n    let f₂ := finite s₂ e₂ m₂ v₂\n    ofRat mode (toRat f₁ rfl + toRat f₂ rfl)\n#align fp.float.add FP.Float.add\n\nunsafe instance : Add Float :=\n  ⟨Float.add RMode.NE⟩\n\n@[nolint docBlame]\nunsafe def sub (mode : RMode) (f1 f2 : Float) : Float :=\n  add mode f1 (-f2)\n#align fp.float.sub FP.Float.sub\n\nunsafe instance : Sub Float :=\n  ⟨Float.sub RMode.NE⟩\n\n@[nolint docBlame]\nunsafe def mul (mode : RMode) : Float → Float → Float\n  | nan, _ => nan\n  | _, nan => nan\n  | inf s₁, f₂ => if f₂.isZero then nan else inf (xor s₁ f₂.sign)\n  | f₁, inf s₂ => if f₁.isZero then nan else inf (xor f₁.sign s₂)\n  | finite s₁ e₁ m₁ v₁, finite s₂ e₂ m₂ v₂ =>\n    let f₁ := finite s₁ e₁ m₁ v₁\n    let f₂ := finite s₂ e₂ m₂ v₂\n    ofRat mode (toRat f₁ rfl * toRat f₂ rfl)\n#align fp.float.mul FP.Float.mul\n\n@[nolint docBlame]\nunsafe def div (mode : RMode) : Float → Float → Float\n  | nan, _ => nan\n  | _, nan => nan\n  | inf _, inf _ => nan\n  | inf s₁, f₂ => inf (xor s₁ f₂.sign)\n  | f₁, inf s₂ => zero (xor f₁.sign s₂)\n  | finite s₁ e₁ m₁ v₁, finite s₂ e₂ m₂ v₂ =>\n    let f₁ := finite s₁ e₁ m₁ v₁\n    let f₂ := finite s₂ e₂ m₂ v₂\n    if f₂.isZero then inf (xor s₁ s₂) else ofRat mode (toRat f₁ rfl / toRat f₂ rfl)\n#align fp.float.div FP.Float.div\n\nend Float\n\nend FP\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/FP/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145999, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4989450881566584}}
{"text": "def Set (α : Type u) := α → Prop\n\ndef setOf {α : Type u} (p : α → Prop) : Set α :=\np\n\nnamespace Set\n\nprotected def mem (a : α) (s : Set α) :=\ns a\n\ninstance : Membership α (Set α) :=\n⟨Set.mem⟩\n\ntheorem ext {a b : Set α} (h : ∀ (x : α), x ∈ a ↔ x ∈ b) : a = b :=\nfunext (fun x => propext (h x))\n\nprotected def subset (s₁ s₂ : Set α) :=\n∀ {a}, a ∈ s₁ → a ∈ s₂\n\nclass Subset (α : Type u) where\n  /-- Subset relation: `a ⊆ b`  -/\n  subset : α → α → Prop\n\n/-- Subset relation: `a ⊆ b`  -/\ninfix:50 \" ⊆ \" => Subset.subset\n\ninstance : Subset (Set α) :=\n⟨Set.subset⟩\n\ninstance : EmptyCollection (Set α) :=\n⟨λ _ => False⟩\n\nexample (U : Type) (A B : Set U) : A ⊆ B → A = A :=\n  fun h =>\n  match @h with | (h : A ⊆ B) => sorry\n\nexample (U : Type) (A B : Set U) : A ⊆ B → A = A := by\n  intro (h : A ⊆ B)\n  sorry\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/subset.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4989450830774215}}
{"text": "macro_rules | `(tactic| rfl) => `(tactic| exact Iff.rfl)\n\ntheorem r (A : Prop) : A ↔ A := by rfl\n\ntheorem s (A B : Prop) (h : A ↔ B) : B ↔ A := by\n  rw [h]\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/iffRefl.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.49894508095359763}}
{"text": "/-\nCopyright (c) 2015 Nathaniel Thomas. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.big_operators.basic\nimport Mathlib.algebra.group.hom\nimport Mathlib.algebra.ring.basic\nimport Mathlib.data.rat.cast\nimport Mathlib.group_theory.group_action.group\nimport Mathlib.tactic.nth_rewrite.default\nimport Mathlib.PostPort\n\nuniverses u v l w x z u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Modules over a ring\n\nIn this file we define\n\n* `semimodule R M` : an additive commutative monoid `M` is a `semimodule` over a\n  `semiring` `R` if for `r : R` and `x : M` their \"scalar multiplication `r • x : M` is defined, and\n  the operation `•` satisfies some natural associativity and distributivity axioms similar to those\n  on a ring.\n\n* `module R M` : same as `semimodule R M` but assumes that `R` is a `ring` and `M` is an\n  additive commutative group.\n\n* `vector_space k M` : same as `semimodule k M` and `module k M` but assumes that `k` is a `field`\n  and `M` is an additive commutative group.\n\n* `linear_map R M M₂`, `M →ₗ[R] M₂` : a linear map between two R-`semimodule`s.\n\n## Implementation notes\n\n* `vector_space` and `module` are abbreviations for `semimodule R M`.\n\n## Tags\n\nsemimodule, module, vector space\n-/\n\n/-- A semimodule is a generalization of vector spaces to a scalar semiring.\n  It consists of a scalar semiring `R` and an additive monoid of \"vectors\" `M`,\n  connected by a \"scalar multiplication\" operation `r • x : M`\n  (where `r : R` and `x : M`) with some natural associativity and\n  distributivity axioms similar to those on a ring. -/\nclass semimodule (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    extends distrib_mul_action R M where\n  add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x\n  zero_smul : ∀ (x : M), 0 • x = 0\n\ntheorem add_smul {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (r : R)\n    (s : R) (x : M) : (r + s) • x = r • x + s • x :=\n  semimodule.add_smul r s x\n\n@[simp] theorem zero_smul (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (x : M) : 0 • x = 0 :=\n  semimodule.zero_smul x\n\ntheorem two_smul (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (x : M) : bit0 1 • x = x + x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (bit0 1 • x = x + x)) (bit0.equations._eqn_1 1)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((1 + 1) • x = x + x)) (add_smul 1 1 x)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 • x + 1 • x = x + x)) (one_smul R x))) (Eq.refl (x + x))))\n\ntheorem two_smul' (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (x : M) : bit0 1 • x = bit0 x :=\n  two_smul R x\n\n/-- Pullback a `semimodule` structure along an injective additive monoid homomorphism. -/\nprotected def function.injective.semimodule (R : Type u) {M : Type w} {M₂ : Type x} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M₂] [has_scalar R M₂] (f : M₂ →+ M)\n    (hf : function.injective ⇑f) (smul : ∀ (c : R) (x : M₂), coe_fn f (c • x) = c • coe_fn f x) :\n    semimodule R M₂ :=\n  semimodule.mk sorry sorry\n\n/-- Pushforward a `semimodule` structure along a surjective additive monoid homomorphism. -/\nprotected def function.surjective.semimodule (R : Type u) {M : Type w} {M₂ : Type x} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M₂] [has_scalar R M₂] (f : M →+ M₂)\n    (hf : function.surjective ⇑f) (smul : ∀ (c : R) (x : M), coe_fn f (c • x) = c • coe_fn f x) :\n    semimodule R M₂ :=\n  semimodule.mk sorry sorry\n\n/-- `(•)` as an `add_monoid_hom`. -/\ndef smul_add_hom (R : Type u) (M : Type w) [semiring R] [add_comm_monoid M] [semimodule R M] :\n    R →+ M →+ M :=\n  add_monoid_hom.mk (const_smul_hom M) sorry sorry\n\n@[simp] theorem smul_add_hom_apply {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (r : R) (x : M) : coe_fn (coe_fn (smul_add_hom R M) r) x = r • x :=\n  rfl\n\ntheorem semimodule.eq_zero_of_zero_eq_one {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (x : M) (zero_eq_one : 0 = 1) : x = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (x = 0)) (Eq.symm (one_smul R x))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (1 • x = 0)) (Eq.symm zero_eq_one)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 • x = 0)) (zero_smul R x))) (Eq.refl 0)))\n\ntheorem list.sum_smul {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {l : List R} {x : M} : list.sum l • x = list.sum (list.map (fun (r : R) => r • x) l) :=\n  add_monoid_hom.map_list_sum (coe_fn (add_monoid_hom.flip (smul_add_hom R M)) x) l\n\ntheorem multiset.sum_smul {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {l : multiset R} {x : M} :\n    multiset.sum l • x = multiset.sum (multiset.map (fun (r : R) => r • x) l) :=\n  add_monoid_hom.map_multiset_sum (coe_fn (add_monoid_hom.flip (smul_add_hom R M)) x) l\n\ntheorem finset.sum_smul {R : Type u} {M : Type w} {ι : Type z} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {f : ι → R} {s : finset ι} {x : M} :\n    (finset.sum s fun (i : ι) => f i) • x = finset.sum s fun (i : ι) => f i • x :=\n  add_monoid_hom.map_sum (coe_fn (add_monoid_hom.flip (smul_add_hom R M)) x) f s\n\n/-- An `add_comm_monoid` that is a `semimodule` over a `ring` carries a natural `add_comm_group`\nstructure. -/\ndef semimodule.add_comm_monoid_to_add_comm_group (R : Type u) {M : Type w} [ring R]\n    [add_comm_monoid M] [semimodule R M] : add_comm_group M :=\n  add_comm_group.mk add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry\n    (fun (a : M) => -1 • a)\n    (add_group.sub._default add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry\n      fun (a : M) => -1 • a)\n    sorry sorry\n\n/-- A structure containing most informations as in a semimodule, except the fields `zero_smul`\nand `smul_zero`. As these fields can be deduced from the other ones when `M` is an `add_comm_group`,\nthis provides a way to construct a semimodule structure by checking less properties, in\n`semimodule.of_core`. -/\nstructure semimodule.core (R : Type u) (M : Type w) [semiring R] [add_comm_group M]\n    extends has_scalar R M where\n  smul_add : ∀ (r : R) (x y : M), r • (x + y) = r • x + r • y\n  add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x\n  mul_smul : ∀ (r s : R) (x : M), (r * s) • x = r • s • x\n  one_smul : ∀ (x : M), 1 • x = x\n\n/-- Define `semimodule` without proving `zero_smul` and `smul_zero` by using an auxiliary\nstructure `semimodule.core`, when the underlying space is an `add_comm_group`. -/\ndef semimodule.of_core {R : Type u} {M : Type w} [semiring R] [add_comm_group M]\n    (H : semimodule.core R M) : semimodule R M :=\n  semimodule.mk (semimodule.core.add_smul H) sorry\n\n/--\nModules are defined as an `abbreviation` for semimodules,\nif the base semiring is a ring.\n(A previous definition made `module` a structure\ndefined to be `semimodule`.)\nThis has as advantage that modules are completely transparent\nfor type class inference, which means that all instances for semimodules\nare immediately picked up for modules as well.\nA cosmetic disadvantage is that one can not extend modules as such,\nin definitions such as `normed_space`.\nThe solution is to extend `semimodule` instead.\n-/\n/-- A module is the same as a semimodule, except the scalar semiring is actually\n  a ring.\n  This is the traditional generalization of spaces like `ℤ^n`, which have a natural\n  addition operation and a way to multiply them by elements of a ring, but no multiplication\n  operation between vectors. -/\ndef module (R : Type u) (M : Type v) [ring R] [add_comm_group M] := semimodule R M\n\n/--\nTo prove two semimodule structures on a fixed `add_comm_monoid` agree,\nit suffices to check the scalar multiplications agree.\n-/\n-- We'll later use this to show `semimodule ℕ M` and `module ℤ M` are subsingletons.\n\ntheorem semimodule_ext {R : Type u_1} [semiring R] {M : Type u_2} [add_comm_monoid M]\n    (P : semimodule R M) (Q : semimodule R M) (w : ∀ (r : R) (m : M), r • m = r • m) : P = Q :=\n  sorry\n\n@[simp] theorem neg_smul {R : Type u} {M : Type w} [ring R] [add_comm_group M] [module R M] (r : R)\n    (x : M) : -r • x = -(r • x) :=\n  sorry\n\ntheorem neg_one_smul (R : Type u) {M : Type w} [ring R] [add_comm_group M] [module R M] (x : M) :\n    -1 • x = -x :=\n  sorry\n\ntheorem sub_smul {R : Type u} {M : Type w} [ring R] [add_comm_group M] [module R M] (r : R) (s : R)\n    (y : M) : (r - s) • y = r • y - s • y :=\n  sorry\n\ntheorem smul_eq_zero {R : Type u_1} {E : Type u_2} [division_ring R] [add_comm_group E] [module R E]\n    {c : R} {x : E} : c • x = 0 ↔ c = 0 ∨ x = 0 :=\n  sorry\n\n/-- A semimodule over a `subsingleton` semiring is a `subsingleton`. We cannot register this\nas an instance because Lean has no way to guess `R`. -/\ntheorem semimodule.subsingleton (R : Type u_1) (M : Type u_2) [semiring R] [subsingleton R]\n    [add_comm_monoid M] [semimodule R M] : subsingleton M :=\n  sorry\n\nprotected instance semiring.to_semimodule {R : Type u} [semiring R] : semimodule R R :=\n  semimodule.mk sorry sorry\n\n@[simp] theorem smul_eq_mul {R : Type u} [semiring R] {a : R} {a' : R} : a • a' = a * a' := rfl\n\n/-- A ring homomorphism `f : R →+* M` defines a module structure by `r • x = f r * x`. -/\ndef ring_hom.to_semimodule {R : Type u} {S : Type v} [semiring R] [semiring S] (f : R →+* S) :\n    semimodule R S :=\n  semimodule.mk sorry sorry\n\n/--\nVector spaces are defined as an `abbreviation` for semimodules,\nif the base ring is a field.\n(A previous definition made `vector_space` a structure\ndefined to be `module`.)\nThis has as advantage that vector spaces are completely transparent\nfor type class inference, which means that all instances for semimodules\nare immediately picked up for vector spaces as well.\nA cosmetic disadvantage is that one can not extend vector spaces as such,\nin definitions such as `normed_space`.\nThe solution is to extend `semimodule` instead.\n-/\n/-- A vector space is the same as a module, except the scalar ring is actually\n  a field. (This adds commutativity of the multiplication and existence of inverses.)\n  This is the traditional generalization of spaces like `ℝ^n`, which have a natural\n  addition operation and a way to multiply them by real numbers, but no multiplication\n  operation between vectors. -/\ndef vector_space (R : Type u) (M : Type v) [field R] [add_comm_group M] := semimodule R M\n\n/-- The natural ℕ-semimodule structure on any `add_comm_monoid`. -/\n-- We don't make this a global instance, as it results in too many instances,\n\n-- and confusing ambiguity in the notation `n • x` when `n : ℕ`.\n\ninstance add_comm_monoid.nat_semimodule {M : Type w} [add_comm_monoid M] : semimodule ℕ M :=\n  semimodule.mk sorry sorry\n\n/-- `nsmul` is defined as the `smul` action of `add_comm_monoid.nat_semimodule`. -/\ntheorem nsmul_def {M : Type w} [add_comm_monoid M] (n : ℕ) (x : M) : n •ℕ x = n • x := rfl\n\n/-- `nsmul` is equal to any other semimodule structure via a cast. -/\ntheorem nsmul_eq_smul_cast (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (n : ℕ) (b : M) : n •ℕ b = ↑n • b :=\n  sorry\n\n/-- `nsmul` is equal to any `ℕ`-semimodule structure. -/\ntheorem nsmul_eq_smul {M : Type w} [add_comm_monoid M] [semimodule ℕ M] (n : ℕ) (b : M) :\n    n •ℕ b = n • b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n •ℕ b = n • b)) (nsmul_eq_smul_cast ℕ n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑n • b = n • b)) (nat.cast_id n))) (Eq.refl (n • b)))\n\n/-- All `ℕ`-semimodule structures are equal. -/\nprotected instance add_comm_monoid.nat_semimodule.subsingleton {M : Type w} [add_comm_monoid M] :\n    subsingleton (semimodule ℕ M) :=\n  subsingleton.intro\n    fun (P Q : semimodule ℕ M) =>\n      semimodule_ext P Q\n        fun (n : ℕ) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n • m = n • m)) (Eq.symm (nsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n •ℕ m = n • m)) (Eq.symm (nsmul_eq_smul n m))))\n              (Eq.refl (n •ℕ m)))\n\n/-- Note this does not depend on the `nat_semimodule` definition above, to avoid issues when\ndiamonds occur in finding `semimodule ℕ M` instances. -/\nprotected instance add_comm_monoid.nat_is_scalar_tower {R : Type u} {M : Type w} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [semimodule ℕ R] [semimodule ℕ M] :\n    is_scalar_tower ℕ R M :=\n  sorry\n\nprotected instance add_comm_monoid.nat_smul_comm_class {R : Type u} {M : Type w} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [semimodule ℕ M] : smul_comm_class ℕ R M :=\n  sorry\n\n-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop\n\nprotected instance add_comm_monoid.nat_smul_comm_class' {R : Type u} {M : Type w} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [semimodule ℕ M] : smul_comm_class R ℕ M :=\n  smul_comm_class.symm ℕ R M\n\n/-- The natural ℤ-module structure on any `add_comm_group`. -/\n-- We don't immediately make this a global instance, as it results in too many instances,\n\n-- and confusing ambiguity in the notation `n • x` when `n : ℤ`.\n\n-- We do turn it into a global instance, but only at the end of this file,\n\n-- and I remain dubious whether this is a good idea.\n\ninstance add_comm_group.int_module {M : Type w} [add_comm_group M] : module ℤ M :=\n  semimodule.mk sorry sorry\n\n/-- `gsmul` is defined as the `smul` action of `add_comm_group.int_module`. -/\ntheorem gsmul_def {M : Type w} [add_comm_group M] (n : ℤ) (x : M) : n •ℤ x = n • x := rfl\n\n/-- `gsmul` is equal to any other module structure via a cast. -/\ntheorem gsmul_eq_smul_cast (R : Type u) {M : Type w} [ring R] [add_comm_group M] [semimodule R M]\n    (n : ℤ) (b : M) : n •ℤ b = ↑n • b :=\n  sorry\n\n/-- `gsmul` is equal to any `ℤ`-module structure. -/\ntheorem gsmul_eq_smul {M : Type w} [add_comm_group M] [semimodule ℤ M] (n : ℤ) (b : M) :\n    n •ℤ b = n • b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n •ℤ b = n • b)) (gsmul_eq_smul_cast ℤ n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑n • b = n • b)) (int.cast_id n))) (Eq.refl (n • b)))\n\n/-- All `ℤ`-module structures are equal. -/\nprotected instance add_comm_group.int_module.subsingleton {M : Type w} [add_comm_group M] :\n    subsingleton (semimodule ℤ M) :=\n  subsingleton.intro\n    fun (P Q : semimodule ℤ M) =>\n      semimodule_ext P Q\n        fun (n : ℤ) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n • m = n • m)) (Eq.symm (gsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n •ℤ m = n • m)) (Eq.symm (gsmul_eq_smul n m))))\n              (Eq.refl (n •ℤ m)))\n\nprotected instance add_comm_group.int_is_scalar_tower {R : Type u} {M : Type w} [ring R]\n    [add_comm_group M] [semimodule R M] [semimodule ℤ R] [semimodule ℤ M] : is_scalar_tower ℤ R M :=\n  sorry\n\nprotected instance add_comm_group.int_smul_comm_class {S : Type v} {M : Type w} [semiring S]\n    [add_comm_group M] [semimodule S M] [semimodule ℤ M] : smul_comm_class ℤ S M :=\n  sorry\n\n-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop\n\nprotected instance add_comm_group.int_smul_comm_class' {S : Type v} {M : Type w} [semiring S]\n    [add_comm_group M] [semimodule S M] [semimodule ℤ M] : smul_comm_class S ℤ M :=\n  smul_comm_class.symm ℤ S M\n\nnamespace add_monoid_hom\n\n\n-- We prove this without using the `add_comm_group.int_module` instance, so the `•`s here\n\n-- come from whatever the local `module ℤ` structure actually is.\n\ntheorem map_int_module_smul {M : Type w} {M₂ : Type x} [add_comm_group M] [add_comm_group M₂]\n    [module ℤ M] [module ℤ M₂] (f : M →+ M₂) (x : ℤ) (a : M) : coe_fn f (x • a) = x • coe_fn f a :=\n  sorry\n\ntheorem map_int_cast_smul {R : Type u} {M : Type w} {M₂ : Type x} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] (f : M →+ M₂) (x : ℤ) (a : M) :\n    coe_fn f (↑x • a) = ↑x • coe_fn f a :=\n  sorry\n\ntheorem map_nat_cast_smul {R : Type u} {M : Type w} {M₂ : Type x} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : M →+ M₂) (x : ℕ) (a : M) :\n    coe_fn f (↑x • a) = ↑x • coe_fn f a :=\n  sorry\n\ntheorem map_rat_cast_smul {R : Type u_1} [division_ring R] [char_zero R] {E : Type u_2}\n    [add_comm_group E] [module R E] {F : Type u_3} [add_comm_group F] [module R F] (f : E →+ F)\n    (c : ℚ) (x : E) : coe_fn f (↑c • x) = ↑c • coe_fn f x :=\n  sorry\n\ntheorem map_rat_module_smul {E : Type u_1} [add_comm_group E] [vector_space ℚ E] {F : Type u_2}\n    [add_comm_group F] [module ℚ F] (f : E →+ F) (c : ℚ) (x : E) :\n    coe_fn f (c • x) = c • coe_fn f x :=\n  rat.cast_id c ▸ map_rat_cast_smul f c x\n\n@[simp] theorem nat_smul_apply {M : Type w} {M₂ : Type x} [add_monoid M] [add_comm_monoid M₂]\n    [semimodule ℕ (M →+ M₂)] [semimodule ℕ M₂] (n : ℕ) (f : M →+ M₂) (a : M) :\n    coe_fn (n • f) a = n • coe_fn f a :=\n  sorry\n\n@[simp] theorem int_smul_apply {M : Type w} {M₂ : Type x} [add_monoid M] [add_comm_group M₂]\n    [module ℤ (M →+ M₂)] [module ℤ M₂] (n : ℤ) (f : M →+ M₂) (a : M) :\n    coe_fn (n • f) a = n • coe_fn f a :=\n  sorry\n\nend add_monoid_hom\n\n\n/-! Some tests for the vanishing of elements in modules over division rings. -/\n\ntheorem smul_nat_eq_zero (R : Type u) {M : Type w} [division_ring R] [add_comm_group M] [module R M]\n    [semimodule ℕ M] [char_zero R] {v : M} {n : ℕ} : n • v = 0 ↔ n = 0 ∨ v = 0 :=\n  sorry\n\ntheorem eq_zero_of_smul_two_eq_zero (R : Type u) {M : Type w} [division_ring R] [add_comm_group M]\n    [module R M] [semimodule ℕ M] [char_zero R] {v : M} (hv : bit0 1 • v = 0) : v = 0 :=\n  sorry\n\ntheorem eq_zero_of_eq_neg (R : Type u) {M : Type w} [division_ring R] [add_comm_group M]\n    [module R M] [char_zero R] {v : M} (hv : v = -v) : v = 0 :=\n  sorry\n\ntheorem ne_neg_of_ne_zero (R : Type u) [division_ring R] [char_zero R] {v : R} (hv : v ≠ 0) :\n    v ≠ -v :=\n  fun (h : v = -v) =>\n    (fun (this : semimodule ℕ R) => hv (eq_zero_of_eq_neg R h)) add_comm_monoid.nat_semimodule\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/module/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6584175005616829, "lm_q1q2_score": 0.49894506867129995}}
{"text": "import polytime.data_structures.list\n\nvariables {α β γ : Type} [tencodable α] [tencodable β] [tencodable γ]\nopen_locale complexity_class\n\n@[simp] def zip {α β : Type*} : list α → list β → list (α × β)\n| (x :: xs) (y :: ys) := (x, y) :: zip xs ys\n| _ _ := []\n\ntheorem zip_eq_stack_rec (l₁ : list α) (l₂ : list β) :\n  zip l₁ l₂ = l₁.stack_rec (λ l₂' : list β, []) (λ x xs l₂', l₂'.tail)\n    (λ ih x xs l₂', @list.cases_on _ (λ _, list (α × β)) l₂' [] (λ y ys, (x, y) :: ih)) l₂ :=\nby induction l₁ generalizing l₂; cases l₂; simp [*]\n\nexample : (@zip α β) ∈ₑ PTIME :=\nbegin\n  complexity using λ l₁ l₂, l₁.stack_rec (λ l₂' : list β, []) (λ x xs l₂', l₂'.tail)\n    (λ ih x xs l₂', @list.cases_on _ (λ _, list (α × β)) l₂' [] (λ y ys, (x, y) :: ih)) l₂,\n  induction l₁ generalizing l₂; cases l₂; simp [*],\nend\n\n", "meta": {"author": "prakol16", "repo": "circuits", "sha": "cdf4ce1e019d6817e4abe0d082d8d379539fddca", "save_path": "github-repos/lean/prakol16-circuits", "path": "github-repos/lean/prakol16-circuits/circuits-cdf4ce1e019d6817e4abe0d082d8d379539fddca/src/polytime/example.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.49894506571588715}}
{"text": "/-\nCopyright (c) 2018 Michael Jendrusch. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Jendrusch, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.products.basic\nimport Mathlib.PostPort\n\nuniverses v u l \n\nnamespace Mathlib\n\n/-!\n# Monoidal categories\n\nA monoidal category is a category equipped with a tensor product, unitors, and an associator.\nIn the definition, we provide the tensor product as a pair of functions\n* `tensor_obj : C → C → C`\n* `tensor_hom : (X₁ ⟶ Y₁) → (X₂ ⟶ Y₂) → ((X₁ ⊗ X₂) ⟶ (Y₁ ⊗ Y₂))`\nand allow use of the overloaded notation `⊗` for both.\nThe unitors and associator are provided componentwise.\n\nThe tensor product can be expressed as a functor via `tensor : C × C ⥤ C`.\nThe unitors and associator are gathered together as natural\nisomorphisms in `left_unitor_nat_iso`, `right_unitor_nat_iso` and `associator_nat_iso`.\n\nSome consequences of the definition are proved in other files,\ne.g. `(λ_ (𝟙_ C)).hom = (ρ_ (𝟙_ C)).hom` in `category_theory.monoidal.unitors_equal`.\n\n## Implementation\nDealing with unitors and associators is painful, and at this stage we do not have a useful\nimplementation of coherence for monoidal categories.\n\nIn an effort to lessen the pain, we put some effort into choosing the right `simp` lemmas.\nGenerally, the rule is that the component index of a natural transformation \"weighs more\"\nin considering the complexity of an expression than does a structural isomorphism (associator, etc).\n\nAs an example when we prove Proposition 2.2.4 of\n<http://www-math.mit.edu/~etingof/egnobookfinal.pdf>\nwe state it as a `@[simp]` lemma as\n```\n(λ_ (X ⊗ Y)).hom = (α_ (𝟙_ C) X Y).inv ≫ (λ_ X).hom ⊗ (𝟙 Y)\n```\n\nThis is far from completely effective, but seems to prove a useful principle.\n\n## References\n* Tensor categories, Etingof, Gelaki, Nikshych, Ostrik,\n  http://www-math.mit.edu/~etingof/egnobookfinal.pdf\n* https://stacks.math.columbia.edu/tag/0FFK.\n-/\n\nnamespace category_theory\n\n\n/--\nIn a monoidal category, we can take the tensor product of objects, `X ⊗ Y` and of morphisms `f ⊗ g`.\nTensor product does not need to be strictly associative on objects, but there is a\nspecified associator, `α_ X Y Z : (X ⊗ Y) ⊗ Z ≅ X ⊗ (Y ⊗ Z)`. There is a tensor unit `𝟙_ C`,\nwith specified left and right unitor isomorphisms `λ_ X : 𝟙_ C ⊗ X ≅ X` and `ρ_ X : X ⊗ 𝟙_ C ≅ X`.\nThese associators and unitors satisfy the pentagon and triangle equations.\n\nSee https://stacks.math.columbia.edu/tag/0FFK.\n-/\n-- curried tensor product of objects:\n\nclass monoidal_category (C : Type u) [𝒞 : category C] \nwhere\n  tensor_obj : C → C → C\n  tensor_hom : {X₁ Y₁ X₂ Y₂ : C} → (X₁ ⟶ Y₁) → (X₂ ⟶ Y₂) → (tensor_obj X₁ X₂ ⟶ tensor_obj Y₁ Y₂)\n  tensor_id' : autoParam (C → C → tensor_hom 𝟙 𝟙 = 𝟙)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  tensor_comp' : autoParam\n  (∀ {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂),\n    tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) = tensor_hom f₁ f₂ ≫ tensor_hom g₁ g₂)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  tensor_unit : C\n  associator : (X Y Z : C) → tensor_obj (tensor_obj X Y) Z ≅ tensor_obj X (tensor_obj Y Z)\n  associator_naturality' : autoParam\n  (∀ {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃),\n    tensor_hom (tensor_hom f₁ f₂) f₃ ≫ iso.hom (associator Y₁ Y₂ Y₃) =\n      iso.hom (associator X₁ X₂ X₃) ≫ tensor_hom f₁ (tensor_hom f₂ f₃))\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  left_unitor : (X : C) → tensor_obj tensor_unit X ≅ X\n  left_unitor_naturality' : autoParam (∀ {X Y : C} (f : X ⟶ Y), tensor_hom 𝟙 f ≫ iso.hom (left_unitor Y) = iso.hom (left_unitor X) ≫ f)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  right_unitor : (X : C) → tensor_obj X tensor_unit ≅ X\n  right_unitor_naturality' : autoParam (∀ {X Y : C} (f : X ⟶ Y), tensor_hom f 𝟙 ≫ iso.hom (right_unitor Y) = iso.hom (right_unitor X) ≫ f)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  pentagon' : autoParam\n  (∀ (W X Y Z : C),\n    tensor_hom (iso.hom (associator W X Y)) 𝟙 ≫\n        iso.hom (associator W (tensor_obj X Y) Z) ≫ tensor_hom 𝟙 (iso.hom (associator X Y Z)) =\n      iso.hom (associator (tensor_obj W X) Y Z) ≫ iso.hom (associator W X (tensor_obj Y Z)))\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  triangle' : autoParam\n  (∀ (X Y : C),\n    iso.hom (associator X tensor_unit Y) ≫ tensor_hom 𝟙 (iso.hom (left_unitor Y)) =\n      tensor_hom (iso.hom (right_unitor X)) 𝟙)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n-- curried tensor product of morphisms:\n\n-- tensor product laws:\n\n-- tensor unit:\n\n-- associator:\n\n-- left unitor:\n\n-- right unitor:\n\n-- pentagon identity:\n\n-- triangle identity:\n\n@[simp] theorem monoidal_category.tensor_id {C : Type u} [𝒞 : category C] [c : monoidal_category C] (X₁ : C) (X₂ : C) : monoidal_category.tensor_hom 𝟙 𝟙 = 𝟙 := sorry\n\n@[simp] theorem monoidal_category.tensor_comp {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X₁ : C} {Y₁ : C} {Z₁ : C} {X₂ : C} {Y₂ : C} {Z₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) : monoidal_category.tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) =\n  monoidal_category.tensor_hom f₁ f₂ ≫ monoidal_category.tensor_hom g₁ g₂ := sorry\n\ntheorem monoidal_category.tensor_comp_assoc {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X₁ : C} {Y₁ : C} {Z₁ : C} {X₂ : C} {Y₂ : C} {Z₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) {X' : C} (f' : monoidal_category.tensor_obj Z₁ Z₂ ⟶ X') : monoidal_category.tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) ≫ f' =\n  monoidal_category.tensor_hom f₁ f₂ ≫ monoidal_category.tensor_hom g₁ g₂ ≫ f' := sorry\n\ntheorem monoidal_category.associator_naturality {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X₁ : C} {X₂ : C} {X₃ : C} {Y₁ : C} {Y₂ : C} {Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) : monoidal_category.tensor_hom (monoidal_category.tensor_hom f₁ f₂) f₃ ≫ iso.hom (monoidal_category.associator Y₁ Y₂ Y₃) =\n  iso.hom (monoidal_category.associator X₁ X₂ X₃) ≫ monoidal_category.tensor_hom f₁ (monoidal_category.tensor_hom f₂ f₃) := sorry\n\ntheorem monoidal_category.associator_naturality_assoc {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X₁ : C} {X₂ : C} {X₃ : C} {Y₁ : C} {Y₂ : C} {Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) {X' : C} (f' : monoidal_category.tensor_obj Y₁ (monoidal_category.tensor_obj Y₂ Y₃) ⟶ X') : monoidal_category.tensor_hom (monoidal_category.tensor_hom f₁ f₂) f₃ ≫\n    iso.hom (monoidal_category.associator Y₁ Y₂ Y₃) ≫ f' =\n  iso.hom (monoidal_category.associator X₁ X₂ X₃) ≫\n    monoidal_category.tensor_hom f₁ (monoidal_category.tensor_hom f₂ f₃) ≫ f' := sorry\n\ntheorem monoidal_category.left_unitor_naturality {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) : monoidal_category.tensor_hom 𝟙 f ≫ iso.hom (monoidal_category.left_unitor Y) =\n  iso.hom (monoidal_category.left_unitor X) ≫ f := sorry\n\ntheorem monoidal_category.left_unitor_naturality_assoc {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) {X' : C} (f' : Y ⟶ X') : monoidal_category.tensor_hom 𝟙 f ≫ iso.hom (monoidal_category.left_unitor Y) ≫ f' =\n  iso.hom (monoidal_category.left_unitor X) ≫ f ≫ f' := sorry\n\ntheorem monoidal_category.right_unitor_naturality {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) : monoidal_category.tensor_hom f 𝟙 ≫ iso.hom (monoidal_category.right_unitor Y) =\n  iso.hom (monoidal_category.right_unitor X) ≫ f := sorry\n\ntheorem monoidal_category.right_unitor_naturality_assoc {C : Type u} [𝒞 : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) {X' : C} (f' : Y ⟶ X') : monoidal_category.tensor_hom f 𝟙 ≫ iso.hom (monoidal_category.right_unitor Y) ≫ f' =\n  iso.hom (monoidal_category.right_unitor X) ≫ f ≫ f' := sorry\n\ntheorem monoidal_category.pentagon {C : Type u} [𝒞 : category C] [c : monoidal_category C] (W : C) (X : C) (Y : C) (Z : C) : monoidal_category.tensor_hom (iso.hom (monoidal_category.associator W X Y)) 𝟙 ≫\n    iso.hom (monoidal_category.associator W (monoidal_category.tensor_obj X Y) Z) ≫\n      monoidal_category.tensor_hom 𝟙 (iso.hom (monoidal_category.associator X Y Z)) =\n  iso.hom (monoidal_category.associator (monoidal_category.tensor_obj W X) Y Z) ≫\n    iso.hom (monoidal_category.associator W X (monoidal_category.tensor_obj Y Z)) := sorry\n\n@[simp] theorem monoidal_category.triangle {C : Type u} [𝒞 : category C] [c : monoidal_category C] (X : C) (Y : C) : iso.hom (monoidal_category.associator X (monoidal_category.tensor_unit C) Y) ≫\n    monoidal_category.tensor_hom 𝟙 (iso.hom (monoidal_category.left_unitor Y)) =\n  monoidal_category.tensor_hom (iso.hom (monoidal_category.right_unitor X)) 𝟙 := sorry\n\n@[simp] theorem monoidal_category.triangle_assoc {C : Type u} [𝒞 : category C] [c : monoidal_category C] (X : C) (Y : C) {X' : C} (f' : monoidal_category.tensor_obj X Y ⟶ X') : iso.hom (monoidal_category.associator X (monoidal_category.tensor_unit C) Y) ≫\n    monoidal_category.tensor_hom 𝟙 (iso.hom (monoidal_category.left_unitor Y)) ≫ f' =\n  monoidal_category.tensor_hom (iso.hom (monoidal_category.right_unitor X)) 𝟙 ≫ f' := sorry\n\ninfixr:70 \" ⊗ \" => Mathlib.category_theory.monoidal_category.tensor_obj\n\ninfixr:70 \" ⊗ \" => Mathlib.category_theory.monoidal_category.tensor_hom\n\nnotation:1024 \"𝟙_\" => Mathlib.category_theory.monoidal_category.tensor_unit\n\nnotation:1024 \"α_\" => Mathlib.category_theory.monoidal_category.associator\n\nnotation:1024 \"λ_\" => Mathlib.category_theory.monoidal_category.left_unitor\n\nnotation:1024 \"ρ_\" => Mathlib.category_theory.monoidal_category.right_unitor\n\n/-- The tensor product of two isomorphisms is an isomorphism. -/\ndef tensor_iso {C : Type u} {X : C} {Y : C} {X' : C} {Y' : C} [category C] [monoidal_category C] (f : X ≅ Y) (g : X' ≅ Y') : X ⊗ X' ≅ Y ⊗ Y' :=\n  iso.mk (iso.hom f ⊗ iso.hom g) (iso.inv f ⊗ iso.inv g)\n\ninfixr:70 \" ⊗ \" => Mathlib.category_theory.tensor_iso\n\nnamespace monoidal_category\n\n\nprotected instance tensor_is_iso {C : Type u} [category C] [monoidal_category C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) [is_iso f] (g : Y ⟶ Z) [is_iso g] : is_iso (f ⊗ g) :=\n  is_iso.mk (iso.inv (as_iso f ⊗ as_iso g))\n\n@[simp] theorem inv_tensor {C : Type u} [category C] [monoidal_category C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) [is_iso f] (g : Y ⟶ Z) [is_iso g] : inv (f ⊗ g) = inv f ⊗ inv g :=\n  rfl\n\n-- When `rewrite_search` lands, add @[search] attributes to\n\n-- monoidal_category.tensor_id monoidal_category.tensor_comp monoidal_category.associator_naturality\n\n-- monoidal_category.left_unitor_naturality monoidal_category.right_unitor_naturality\n\n-- monoidal_category.pentagon monoidal_category.triangle\n\n-- tensor_comp_id tensor_id_comp comp_id_tensor_tensor_id\n\n-- triangle_assoc_comp_left triangle_assoc_comp_right\n\n-- triangle_assoc_comp_left_inv triangle_assoc_comp_right_inv\n\n-- left_unitor_tensor left_unitor_tensor_inv\n\n-- right_unitor_tensor right_unitor_tensor_inv\n\n-- pentagon_inv\n\n-- associator_inv_naturality\n\n-- left_unitor_inv_naturality\n\n-- right_unitor_inv_naturality\n\n@[simp] theorem comp_tensor_id {C : Type u} [category C] [monoidal_category C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) (g : X ⟶ Y) : f ≫ g ⊗ 𝟙 = (f ⊗ 𝟙) ≫ (g ⊗ 𝟙) := sorry\n\n@[simp] theorem id_tensor_comp {C : Type u} [category C] [monoidal_category C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) (g : X ⟶ Y) : 𝟙 ⊗ f ≫ g = (𝟙 ⊗ f) ≫ (𝟙 ⊗ g) := sorry\n\n@[simp] theorem id_tensor_comp_tensor_id {C : Type u} [category C] [monoidal_category C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) (g : Y ⟶ Z) : (𝟙 ⊗ f) ≫ (g ⊗ 𝟙) = g ⊗ f := sorry\n\n@[simp] theorem tensor_id_comp_id_tensor_assoc {C : Type u} [category C] [monoidal_category C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) (g : Y ⟶ Z) {X' : C} (f' : Z ⊗ X ⟶ X') : (g ⊗ 𝟙) ≫ (𝟙 ⊗ f) ≫ f' = (g ⊗ f) ≫ f' := sorry\n\ntheorem left_unitor_inv_naturality {C : Type u} [category C] [monoidal_category C] {X : C} {X' : C} (f : X ⟶ X') : f ≫ iso.inv λ_ = iso.inv λ_ ≫ (𝟙 ⊗ f) := sorry\n\ntheorem right_unitor_inv_naturality {C : Type u} [category C] [monoidal_category C] {X : C} {X' : C} (f : X ⟶ X') : f ≫ iso.inv ρ_ = iso.inv ρ_ ≫ (f ⊗ 𝟙) := sorry\n\n@[simp] theorem right_unitor_conjugation {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) : iso.inv ρ_ ≫ (f ⊗ 𝟙) ≫ iso.hom ρ_ = f := sorry\n\n@[simp] theorem left_unitor_conjugation {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) : iso.inv λ_ ≫ (𝟙 ⊗ f) ≫ iso.hom λ_ = f := sorry\n\n@[simp] theorem tensor_left_iff {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) (g : X ⟶ Y) : 𝟙 ⊗ f = 𝟙 ⊗ g ↔ f = g := sorry\n\n@[simp] theorem tensor_right_iff {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X ⟶ Y) (g : X ⟶ Y) : f ⊗ 𝟙 = g ⊗ 𝟙 ↔ f = g := sorry\n\n-- We now prove:\n\n--   ((α_ (𝟙_ C) X Y).hom) ≫\n\n--     ((λ_ (X ⊗ Y)).hom)\n\n--   = ((λ_ X).hom ⊗ (𝟙 Y))\n\n-- (and the corresponding fact for right unitors)\n\n-- following the proof on nLab:\n\n-- Lemma 2.2 at <https://ncatlab.org/nlab/revision/monoidal+category/115>\n\ntheorem left_unitor_product_aux_perimeter {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.hom α_ ⊗ 𝟙) ≫ iso.hom α_ ≫ (𝟙 ⊗ iso.hom α_) ≫ (𝟙 ⊗ iso.hom λ_) = ((iso.hom ρ_ ⊗ 𝟙) ⊗ 𝟙) ≫ iso.hom α_ := sorry\n\ntheorem left_unitor_product_aux_triangle {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.hom α_ ⊗ 𝟙) ≫ ((𝟙 ⊗ iso.hom λ_) ⊗ 𝟙) = (iso.hom ρ_ ⊗ 𝟙) ⊗ 𝟙 := sorry\n\ntheorem left_unitor_product_aux_square {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom α_ ≫ (𝟙 ⊗ iso.hom λ_ ⊗ 𝟙) = ((𝟙 ⊗ iso.hom λ_) ⊗ 𝟙) ≫ iso.hom α_ := sorry\n\ntheorem left_unitor_product_aux {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (𝟙 ⊗ iso.hom α_) ≫ (𝟙 ⊗ iso.hom λ_) = 𝟙 ⊗ iso.hom λ_ ⊗ 𝟙 := sorry\n\ntheorem right_unitor_product_aux_perimeter {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.hom α_ ⊗ 𝟙) ≫ iso.hom α_ ≫ (𝟙 ⊗ iso.hom α_) ≫ (𝟙 ⊗ 𝟙 ⊗ iso.hom λ_) = (iso.hom ρ_ ⊗ 𝟙) ≫ iso.hom α_ := sorry\n\ntheorem right_unitor_product_aux_triangle {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (𝟙 ⊗ iso.hom α_) ≫ (𝟙 ⊗ 𝟙 ⊗ iso.hom λ_) = 𝟙 ⊗ iso.hom ρ_ ⊗ 𝟙 := sorry\n\ntheorem right_unitor_product_aux_square {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom α_ ≫ (𝟙 ⊗ iso.hom ρ_ ⊗ 𝟙) = ((𝟙 ⊗ iso.hom ρ_) ⊗ 𝟙) ≫ iso.hom α_ := sorry\n\ntheorem right_unitor_product_aux {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.hom α_ ⊗ 𝟙) ≫ ((𝟙 ⊗ iso.hom ρ_) ⊗ 𝟙) = iso.hom ρ_ ⊗ 𝟙 := sorry\n\n-- See Proposition 2.2.4 of <http://www-math.mit.edu/~etingof/egnobookfinal.pdf>\n\ntheorem left_unitor_tensor' {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom α_ ≫ iso.hom λ_ = iso.hom λ_ ⊗ 𝟙 := sorry\n\n@[simp] theorem left_unitor_tensor {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom λ_ = iso.inv α_ ≫ (iso.hom λ_ ⊗ 𝟙) := sorry\n\ntheorem left_unitor_tensor_inv' {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.inv λ_ ≫ iso.inv α_ = iso.inv λ_ ⊗ 𝟙 := sorry\n\n@[simp] theorem left_unitor_tensor_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.inv λ_ = (iso.inv λ_ ⊗ 𝟙) ≫ iso.hom α_ := sorry\n\n@[simp] theorem right_unitor_tensor {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom ρ_ = iso.hom α_ ≫ (𝟙 ⊗ iso.hom ρ_) := sorry\n\n@[simp] theorem right_unitor_tensor_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.inv ρ_ = (𝟙 ⊗ iso.inv ρ_) ≫ iso.inv α_ := sorry\n\ntheorem associator_inv_naturality {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} {Z : C} {X' : C} {Y' : C} {Z' : C} (f : X ⟶ X') (g : Y ⟶ Y') (h : Z ⟶ Z') : (f ⊗ g ⊗ h) ≫ iso.inv α_ = iso.inv α_ ≫ ((f ⊗ g) ⊗ h) := sorry\n\ntheorem pentagon_inv {C : Type u} [category C] [monoidal_category C] (W : C) (X : C) (Y : C) (Z : C) : (𝟙 ⊗ iso.inv α_) ≫ iso.inv α_ ≫ (iso.inv α_ ⊗ 𝟙) = iso.inv α_ ≫ iso.inv α_ := sorry\n\ntheorem triangle_assoc_comp_left {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom α_ ≫ (𝟙 ⊗ iso.hom λ_) = iso.hom ρ_ ⊗ 𝟙 :=\n  triangle X Y\n\n@[simp] theorem triangle_assoc_comp_right {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.inv α_ ≫ (iso.hom ρ_ ⊗ 𝟙) = 𝟙 ⊗ iso.hom λ_ := sorry\n\n@[simp] theorem triangle_assoc_comp_right_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.inv ρ_ ⊗ 𝟙) ≫ iso.hom α_ = 𝟙 ⊗ iso.inv λ_ := sorry\n\n@[simp] theorem triangle_assoc_comp_left_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (𝟙 ⊗ iso.inv λ_) ≫ iso.inv α_ = iso.inv ρ_ ⊗ 𝟙 := sorry\n\n/-- The tensor product expressed as a functor. -/\ndef tensor (C : Type u) [category C] [monoidal_category C] : C × C ⥤ C :=\n  functor.mk (fun (X : C × C) => prod.fst X ⊗ prod.snd X) fun {X Y : C × C} (f : X ⟶ Y) => prod.fst f ⊗ prod.snd f\n\n/-- The left-associated triple tensor product as a functor. -/\ndef left_assoc_tensor (C : Type u) [category C] [monoidal_category C] : C × C × C ⥤ C :=\n  functor.mk (fun (X : C × C × C) => (prod.fst X ⊗ prod.fst (prod.snd X)) ⊗ prod.snd (prod.snd X))\n    fun {X Y : C × C × C} (f : X ⟶ Y) => (prod.fst f ⊗ prod.fst (prod.snd f)) ⊗ prod.snd (prod.snd f)\n\n@[simp] theorem left_assoc_tensor_obj (C : Type u) [category C] [monoidal_category C] (X : C × C × C) : functor.obj (left_assoc_tensor C) X = (prod.fst X ⊗ prod.fst (prod.snd X)) ⊗ prod.snd (prod.snd X) :=\n  rfl\n\n@[simp] theorem left_assoc_tensor_map (C : Type u) [category C] [monoidal_category C] {X : C × C × C} {Y : C × C × C} (f : X ⟶ Y) : functor.map (left_assoc_tensor C) f = (prod.fst f ⊗ prod.fst (prod.snd f)) ⊗ prod.snd (prod.snd f) :=\n  rfl\n\n/-- The right-associated triple tensor product as a functor. -/\ndef right_assoc_tensor (C : Type u) [category C] [monoidal_category C] : C × C × C ⥤ C :=\n  functor.mk (fun (X : C × C × C) => prod.fst X ⊗ prod.fst (prod.snd X) ⊗ prod.snd (prod.snd X))\n    fun {X Y : C × C × C} (f : X ⟶ Y) => prod.fst f ⊗ prod.fst (prod.snd f) ⊗ prod.snd (prod.snd f)\n\n@[simp] theorem right_assoc_tensor_obj (C : Type u) [category C] [monoidal_category C] (X : C × C × C) : functor.obj (right_assoc_tensor C) X = prod.fst X ⊗ prod.fst (prod.snd X) ⊗ prod.snd (prod.snd X) :=\n  rfl\n\n@[simp] theorem right_assoc_tensor_map (C : Type u) [category C] [monoidal_category C] {X : C × C × C} {Y : C × C × C} (f : X ⟶ Y) : functor.map (right_assoc_tensor C) f = prod.fst f ⊗ prod.fst (prod.snd f) ⊗ prod.snd (prod.snd f) :=\n  rfl\n\n/-- The functor `λ X, 𝟙_ C ⊗ X`. -/\ndef tensor_unit_left (C : Type u) [category C] [monoidal_category C] : C ⥤ C :=\n  functor.mk (fun (X : C) => 𝟙_ ⊗ X) fun {X Y : C} (f : X ⟶ Y) => 𝟙 ⊗ f\n\n/-- The functor `λ X, X ⊗ 𝟙_ C`. -/\ndef tensor_unit_right (C : Type u) [category C] [monoidal_category C] : C ⥤ C :=\n  functor.mk (fun (X : C) => X ⊗ 𝟙_) fun {X Y : C} (f : X ⟶ Y) => f ⊗ 𝟙\n\n-- We can express the associator and the unitors, given componentwise above,\n\n-- as natural isomorphisms.\n\n/-- The associator as a natural isomorphism. -/\n@[simp] theorem associator_nat_iso_hom_app (C : Type u) [category C] [monoidal_category C] (X : C × C × C) : nat_trans.app (iso.hom (associator_nat_iso C)) X = iso.hom α_ :=\n  Eq.refl (iso.hom α_)\n\n/-- The left unitor as a natural isomorphism. -/\n@[simp] theorem left_unitor_nat_iso_inv_app (C : Type u) [category C] [monoidal_category C] (X : C) : nat_trans.app (iso.inv (left_unitor_nat_iso C)) X = iso.inv λ_ :=\n  Eq.refl (iso.inv λ_)\n\n/-- The right unitor as a natural isomorphism. -/\n@[simp] theorem right_unitor_nat_iso_inv_app (C : Type u) [category C] [monoidal_category C] (X : C) : nat_trans.app (iso.inv (right_unitor_nat_iso C)) X = iso.inv ρ_ :=\n  Eq.refl (iso.inv ρ_)\n\n/-- Tensoring on the left with a fixed object, as a functor. -/\n@[simp] theorem tensor_left_map {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) (Y' : C) (f : Y ⟶ Y') : functor.map (tensor_left X) f = 𝟙 ⊗ f :=\n  Eq.refl (functor.map (tensor_left X) f)\n\n/--\nTensoring on the left with `X ⊗ Y` is naturally isomorphic to\ntensoring on the left with `Y`, and then again with `X`.\n-/\ndef tensor_left_tensor {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : tensor_left (X ⊗ Y) ≅ tensor_left Y ⋙ tensor_left X :=\n  nat_iso.of_components α_ sorry\n\n@[simp] theorem tensor_left_tensor_hom_app {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) (Z : C) : nat_trans.app (iso.hom (tensor_left_tensor X Y)) Z = iso.hom α_ :=\n  rfl\n\n@[simp] theorem tensor_left_tensor_inv_app {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) (Z : C) : nat_trans.app (iso.inv (tensor_left_tensor X Y)) Z = iso.inv α_ :=\n  rfl\n\n/-- Tensoring on the right with a fixed object, as a functor. -/\n@[simp] theorem tensor_right_obj {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : functor.obj (tensor_right X) Y = Y ⊗ X :=\n  Eq.refl (functor.obj (tensor_right X) Y)\n\n/--\nTensoring on the right, as a functor from `C` into endofunctors of `C`.\n\nWe later show this is a monoidal functor.\n-/\ndef tensoring_right (C : Type u) [category C] [monoidal_category C] : C ⥤ C ⥤ C :=\n  functor.mk tensor_right fun (X Y : C) (f : X ⟶ Y) => nat_trans.mk fun (Z : C) => 𝟙 ⊗ f\n\nprotected instance tensoring_right.category_theory.faithful (C : Type u) [category C] [monoidal_category C] : faithful (tensoring_right C) :=\n  faithful.mk\n\n/--\nTensoring on the right with `X ⊗ Y` is naturally isomorphic to\ntensoring on the right with `X`, and then again with `Y`.\n-/\ndef tensor_right_tensor {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : tensor_right (X ⊗ Y) ≅ tensor_right X ⋙ tensor_right Y :=\n  nat_iso.of_components (fun (Z : C) => iso.symm α_) sorry\n\n@[simp] theorem tensor_right_tensor_hom_app {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) (Z : C) : nat_trans.app (iso.hom (tensor_right_tensor X Y)) Z = iso.inv α_ :=\n  rfl\n\n@[simp] theorem tensor_right_tensor_inv_app {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) (Z : C) : nat_trans.app (iso.inv (tensor_right_tensor X Y)) Z = iso.hom α_ :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256512199033, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.49892194646262067}}
{"text": "theorem succ_inj' {a b : mynat} (hs : succ(a) = succ(b)) :  a = b := \nbegin\napply succ_inj hs,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/6-advanced-addition-world/l1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256313782276, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.49892193470312224}}
{"text": "import Mathlib.Data.Int.Basic\nimport Mathlib.Tactic.Ring\n\n\nsection ring_lemmas\n\nvariable {R : Type u} [CommRing R]\n\nlemma factorize1 (root b p : R) (q : ℕ) : root * p ^ q * (p ^ q * b) + root * p ^ q * (root * p ^ q) = p ^ q * p ^ q * ((root + b) * root) := by ring\n\nlemma factorize2 (root a p : R) (q : ℕ) : 2 * (root * p ^ q) * (p ^ 1 * a) = p ^ q  * p ^ 1  * (2 * a * root) := by ring\n\nlemma factorize3 (root p : R) (q : ℕ) : 3 * (root * p ^ q * (root * p ^ q)) = p ^ q * p ^ q * (3 * root * root) := by ring\n\nlemma factorize4 (root a b c p : R) (q : ℕ) : p ^ (2 * q + 1) * c + root * p ^ q * (p ^ (q + 1) * b) + (root * p ^ q) ^ 2 * (p ^ 1 * a) = p ^ q * p ^ q * p ^ 1 * (a * root ^ 2) + p ^ q * p ^ (q + 1) * (b * root) + p ^ (2 * q + 1) * c := by ring\n\nlemma factorize5 (b c p : R) : p ^ 1 * b * (p ^ 1 * b) + 4 * (p ^ 2 * c) = p ^ 2 * (b * b + 4 * c) := by ring\n\nlemma factorize6 (p x b c : R) : p ^ 2 * x ^ 2 + p * x * (p ^ 1 * b) + p ^ 2 * -c = p ^ 2 * (1 * x ^ 2 + b * x + -c) := by ring\n\nlemma factorize7 (a b r p : R) : p ^ 2 * a + 2 * (p * r) * (p ^ 1 * b) + 3 * (p * r) ^ 2 = p ^ 2 * (a + 2 * r * b + 3 * r ^ 2) := by ring\n\nlemma factorize8 (a b c r p : R) : (p ^ 3 * a) + (p * r) * (p ^ 2 * b) + (p * r) ^ 2 * (p ^ 1 * c) + (p * r) ^ 3 = p ^ 3 * (a + r * b + r ^ 2 * c + r ^ 3) := by ring\n\nlemma factorize9 (a1 a2 a3 a4 a6 b8 p : R) : p ^ 1 * a1 * (p ^ 1 * a1) * (p ^ 3 * a6) + p ^ 1 * a1 * (p ^ 2 * a3) * -a4 + 4 * a2 * (p ^ 3 * a6) + a2 * (p ^ 2 * a3) * (p ^ 2 * a3) + p ^ 3 * -b8 = p ^ 3 * (p ^ 1 * a1 * (p ^ 1 * a1) * a6 + a1 * a3 * -a4 + 4 * a2 * a6 + a2 * a3 * (p ^ 1 * a3) + -b8) := by ring\n\nend ring_lemmas\n", "meta": {"author": "KisaraBlue", "repo": "ec-tate-lean", "sha": "2b1b26c2622fde0344feaadddc077caca73bd929", "save_path": "github-repos/lean/KisaraBlue-ec-tate-lean", "path": "github-repos/lean/KisaraBlue-ec-tate-lean/ec-tate-lean-2b1b26c2622fde0344feaadddc077caca73bd929/ECTate/Algebra/EllipticCurve/AuxRingLemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.863391595913457, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.49860464498040274}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\n\nimport category_theory.limits.shapes\nimport category_theory.limits.shapes.regular_mono\nimport category_theory.epi_mono\nimport sub\n\n/-!\n# Subobject classifiers\n\nDefine a subobject classifier, show that it implies there's a terminal object,\nshow that if there is a subobject classifier then every mono is regular.\n-/\nuniverses v u v₂ u₂\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u} [category.{v} C]\n\n/-- Define what it means for χ to classify the mono f. -/\nabbreviation classifying {Ω Ω₀ U X : C} (truth : Ω₀ ⟶ Ω) (f : U ⟶ X) (χ : X ⟶ Ω) := has_pullback_top f χ truth\n\ninstance subsingleton_classifying {Ω Ω₀ U X : C} (truth : Ω₀ ⟶ Ω) [mono truth] (f : U ⟶ X) (χ : X ⟶ Ω) :\n  subsingleton (classifying truth f χ) :=\n⟨by { intros P Q, cases P, cases Q, congr, rw [← cancel_mono truth, P_comm, Q_comm] }⟩\n\n/--\n`is_subobject_classifier truth` holds if the morphism `truth : Ω₀ ⟶ Ω` is a subobject classifier,\ni.e. that for any monomorphism `U ⟶ X`, there is a unique morphism `X ⟶ Ω` forming a pullback\nsquare.\nNote we do not require `truth` to be a monomorphism here, nor that `Ω₀` is terminal.\n-/\nstructure is_subobject_classifier {Ω Ω₀ : C} (truth : Ω₀ ⟶ Ω) :=\n(classifier_of : ∀ {U X} (f : U ⟶ X) [mono.{v} f], X ⟶ Ω)\n(classifies' : ∀ {U X} (f : U ⟶ X) [mono f], classifying truth f (classifier_of f))\n(uniquely' : ∀ {U X} (f : U ⟶ X) [mono f] (χ₁ : X ⟶ Ω), classifying truth f χ₁ → classifier_of f = χ₁)\n\nvariable (C)\n\n/--\nA category has a subobject classifier if there is a monomorphism `truth` which is a\nsubobject classifier.\nWe do not require `Ω₀` to be terminal, nor do we assume the existence of any limits.\n-/\nclass has_subobject_classifier :=\n(Ω Ω₀ : C)\n(truth : Ω₀ ⟶ Ω)\n[truth_mono : mono.{v} truth]\n(is_subobj_classifier : is_subobject_classifier truth)\n\nvariables [has_subobject_classifier.{v} C]\n\n/-! Convenience interface to the `has_subobject_classifier` class. -/\nnamespace classifier\n\n/-- Convenience notation for the classifier target given the typeclass `has_subobject_classifier`. -/\ndef Ω : C := has_subobject_classifier.Ω.{v}\n/-- Convenience notation for the classifier source given the typeclass `has_subobject_classifier`. -/\ndef Ω₀ : C := has_subobject_classifier.Ω₀.{v}\n/-- Convenience notation for the classifier given the typeclass `has_subobject_classifier`. -/\ndef truth : Ω₀ C ⟶ Ω C := has_subobject_classifier.truth\n/-- From the typeclass `has_subobject_classifier`, show that the classifier `truth` is a monomorphism. -/\ninstance truth_mono : mono (truth C) := has_subobject_classifier.truth_mono\n/-- The subobject classifier given by `has_subobject_classifier` is actually a classifier. -/\ndef subobj_classifier_is_subobj_classifier : is_subobject_classifier (truth C) := has_subobject_classifier.is_subobj_classifier\n\nvariable {C}\ndef classifier_of {U X : C} (f : U ⟶ X) [mono f] : X ⟶ Ω C :=\n(subobj_classifier_is_subobj_classifier C).classifier_of f\ndef classifies {U X : C} (f : U ⟶ X) [mono f] : classifying (truth C) f (classifier_of f) :=\n(subobj_classifier_is_subobj_classifier C).classifies' f\nlemma uniquely {U X : C} (f : U ⟶ X) [mono f] (χ₁ : X ⟶ Ω C) (hχ : classifying (truth C) f χ₁) : classifier_of f = χ₁ :=\n(subobj_classifier_is_subobj_classifier C).uniquely' f χ₁ hχ\n\nend classifier\n\nopen classifier\n\n-- Usually we would assume C has finite limits, and Ω₀ C might not be equal to it.\ninstance unique_to_Ω₀ (P : C) : unique (P ⟶ Ω₀ C) :=\n{ default := (classifies (𝟙 _)).top,\n  uniq := λ a,\n  begin\n    rw [← cancel_mono (truth C), (classifies (𝟙 _)).comm, id_comp, uniquely],\n    apply left_iso_has_pullback_top a (𝟙 P) (truth C) _ (id_comp _).symm,\n  end }\n\ninstance truth_is_split : split_mono (truth C) :=\n{ retraction := default _ }\n\nvariable {C}\n\n/-- In a category with a subobject classifier, any mono is regular. -/\ndef mono_is_regular {A B : C} (m : A ⟶ B) [mono m] : regular_mono m :=\nregular_of_is_pullback_snd_of_regular _ (classifies m).is_pb\n\n/--\n`factors_through f g` is usually a `Prop`, but if `g` is a mono, it's a regular mono so we can\nlift it to data.\n-/\ndef raised_factors {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} (h : factors_through f g) [mono g] : {k // k ≫ g = f} :=\nbegin\n  haveI := mono_is_regular g,\n  refine regular_mono.lift' _ _ _,\n  casesI h,\n  have : h.left ≫ g = f := over.w h,\n  rw [← this, assoc, assoc, regular_mono.w],\nend\n\n/-- A category with a subobject classifier is balanced. -/\n-- Making this an instance screws with resolution (unsurprisingly).\ndef balanced {A B : C} (f : A ⟶ B) [ef : epi f] [mono f] : is_iso f :=\n@is_iso_limit_cone_parallel_pair_of_epi _ _ _ _ _ _ _ (mono_is_regular f).is_limit ef\n\n/--\nIf the source of a faithful functor has a subobject classifier, the functor reflects\nisomorphisms. This holds for any balanced category.\n-/\ndef reflects_isos (D : Type u₂) [category.{v₂} D] (F : C ⥤ D) [faithful F] : reflects_isomorphisms F :=\n⟨λ A B f i, by exactI\nbegin\n  haveI : epi f := faithful_reflects_epi F (by apply_instance),\n  haveI : mono f := faithful_reflects_mono F (by apply_instance),\n  apply balanced\nend⟩\n", "meta": {"author": "b-mehta", "repo": "topos", "sha": "c9032b11789e36038bc841a1e2b486972421b983", "save_path": "github-repos/lean/b-mehta-topos", "path": "github-repos/lean/b-mehta-topos/topos-c9032b11789e36038bc841a1e2b486972421b983/src/subobject_classifier.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.498598354853738}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz, Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.structured_arrow\n! leanprover-community/mathlib commit f47581155c818e6361af4e4fda60d27d020c226b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Punit\nimport Mathbin.CategoryTheory.Comma\nimport Mathbin.CategoryTheory.Limits.Shapes.Terminal\nimport Mathbin.CategoryTheory.EssentiallySmall\n\n/-!\n# The category of \"structured arrows\"\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nFor `T : C ⥤ D`, a `T`-structured arrow with source `S : D`\nis just a morphism `S ⟶ T.obj Y`, for some `Y : C`.\n\nThese form a category with morphisms `g : Y ⟶ Y'` making the obvious diagram commute.\n\nWe prove that `𝟙 (T.obj Y)` is the initial object in `T`-structured objects with source `T.obj Y`.\n-/\n\n\nnamespace CategoryTheory\n\n-- morphism levels before object levels. See note [category_theory universes].\nuniverse v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]\n\n#print CategoryTheory.StructuredArrow /-\n/-- The category of `T`-structured arrows with domain `S : D` (here `T : C ⥤ D`),\nhas as its objects `D`-morphisms of the form `S ⟶ T Y`, for some `Y : C`,\nand morphisms `C`-morphisms `Y ⟶ Y'` making the obvious triangle commute.\n-/\n@[nolint has_nonempty_instance]\ndef StructuredArrow (S : D) (T : C ⥤ D) :=\n  Comma (Functor.fromPUnit S) T deriving Category\n#align category_theory.structured_arrow CategoryTheory.StructuredArrow\n-/\n\nnamespace StructuredArrow\n\n#print CategoryTheory.StructuredArrow.proj /-\n/-- The obvious projection functor from structured arrows. -/\n@[simps]\ndef proj (S : D) (T : C ⥤ D) : StructuredArrow S T ⥤ C :=\n  Comma.snd _ _\n#align category_theory.structured_arrow.proj CategoryTheory.StructuredArrow.proj\n-/\n\nvariable {S S' S'' : D} {Y Y' : C} {T : C ⥤ D}\n\n/- warning: category_theory.structured_arrow.mk -> CategoryTheory.StructuredArrow.mk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2}, (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y)) -> (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2}, (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y)) -> (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.mk CategoryTheory.StructuredArrow.mkₓ'. -/\n/-- Construct a structured arrow from a morphism. -/\ndef mk (f : S ⟶ T.obj Y) : StructuredArrow S T :=\n  ⟨⟨⟨⟩⟩, Y, f⟩\n#align category_theory.structured_arrow.mk CategoryTheory.StructuredArrow.mk\n\n/- warning: category_theory.structured_arrow.mk_left -> CategoryTheory.StructuredArrow.mk_left is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y)), Eq.{succ u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)) (CategoryTheory.Discrete.mk.{u2} PUnit.{succ u2} PUnit.unit.{succ u2})\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y)), Eq.{succ u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)) (CategoryTheory.Discrete.mk.{u2} PUnit.{succ u2} PUnit.unit.{succ u2})\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.mk_left CategoryTheory.StructuredArrow.mk_leftₓ'. -/\n@[simp]\ntheorem mk_left (f : S ⟶ T.obj Y) : (mk f).left = ⟨⟨⟩⟩ :=\n  rfl\n#align category_theory.structured_arrow.mk_left CategoryTheory.StructuredArrow.mk_left\n\n/- warning: category_theory.structured_arrow.mk_right -> CategoryTheory.StructuredArrow.mk_right is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y)), Eq.{succ u3} C (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)) Y\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y)), Eq.{succ u3} C (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)) Y\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.mk_right CategoryTheory.StructuredArrow.mk_rightₓ'. -/\n@[simp]\ntheorem mk_right (f : S ⟶ T.obj Y) : (mk f).right = Y :=\n  rfl\n#align category_theory.structured_arrow.mk_right CategoryTheory.StructuredArrow.mk_right\n\n/- warning: category_theory.structured_arrow.mk_hom_eq_self -> CategoryTheory.StructuredArrow.mk_hom_eq_self is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y)), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f))) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)))) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)) f\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y)), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f))) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)))) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T f)) f\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.mk_hom_eq_self CategoryTheory.StructuredArrow.mk_hom_eq_selfₓ'. -/\n@[simp]\ntheorem mk_hom_eq_self (f : S ⟶ T.obj Y) : (mk f).Hom = f :=\n  rfl\n#align category_theory.structured_arrow.mk_hom_eq_self CategoryTheory.StructuredArrow.mk_hom_eq_self\n\n/- warning: category_theory.structured_arrow.w -> CategoryTheory.StructuredArrow.w is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ (max u2 u1), max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T))) A B), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) (CategoryTheory.CommaMorphism.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A B f))) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{max (succ u1) (succ u2), max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) A B), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) (CategoryTheory.CommaMorphism.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A B f))) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.w CategoryTheory.StructuredArrow.wₓ'. -/\n@[simp, reassoc.1]\ntheorem w {A B : StructuredArrow S T} (f : A ⟶ B) : A.Hom ≫ T.map f.right = B.Hom := by\n  have := f.w <;> tidy\n#align category_theory.structured_arrow.w CategoryTheory.StructuredArrow.w\n\n/- warning: category_theory.structured_arrow.hom_mk -> CategoryTheory.StructuredArrow.homMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f') g)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) -> (Quiver.Hom.{succ (max u2 u1), max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T))) f f')\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f') g)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) -> (Quiver.Hom.{max (succ u1) (succ u2), max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) f f')\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.hom_mk CategoryTheory.StructuredArrow.homMkₓ'. -/\n/-- To construct a morphism of structured arrows,\nwe need a morphism of the objects underlying the target,\nand to check that the triangle commutes.\n-/\n@[simps]\ndef homMk {f f' : StructuredArrow S T} (g : f.right ⟶ f'.right) (w : f.Hom ≫ T.map g = f'.Hom) :\n    f ⟶ f' where\n  left := eqToHom (by ext)\n  right := g\n  w' := by\n    dsimp\n    simpa using w.symm\n#align category_theory.structured_arrow.hom_mk CategoryTheory.StructuredArrow.homMk\n\n/- warning: category_theory.structured_arrow.hom_mk' -> CategoryTheory.StructuredArrow.homMk' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {X : D} {Y : C} (U : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U) Y), Quiver.Hom.{succ (max u2 u1), max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 X F))) U (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 X Y F (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) X (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U) Y f)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {X : D} {Y : C} (U : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U) Y), Quiver.Hom.{max (succ u1) (succ u2), max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 X F))) U (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 X Y F (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) X (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 X) F U) Y f)))\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.hom_mk' CategoryTheory.StructuredArrow.homMk'ₓ'. -/\n/-- Given a structured arrow `X ⟶ F(U)`, and an arrow `U ⟶ Y`, we can construct a morphism of\nstructured arrow given by `(X ⟶ F(U)) ⟶ (X ⟶ F(U) ⟶ F(Y))`.\n-/\ndef homMk' {F : C ⥤ D} {X : D} {Y : C} (U : StructuredArrow X F) (f : U.right ⟶ Y) :\n    U ⟶ mk (U.Hom ≫ F.map f) where\n  left := eqToHom (by ext)\n  right := f\n#align category_theory.structured_arrow.hom_mk' CategoryTheory.StructuredArrow.homMk'\n\n/- warning: category_theory.structured_arrow.iso_mk -> CategoryTheory.StructuredArrow.isoMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : CategoryTheory.Iso.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f') (CategoryTheory.Iso.hom.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f') g))) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) -> (CategoryTheory.Iso.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.commaCategory.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T) f f')\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : CategoryTheory.Iso.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f') (CategoryTheory.Iso.hom.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f') g))) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T f')) -> (CategoryTheory.Iso.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) f f')\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.iso_mk CategoryTheory.StructuredArrow.isoMkₓ'. -/\n/-- To construct an isomorphism of structured arrows,\nwe need an isomorphism of the objects underlying the target,\nand to check that the triangle commutes.\n-/\n@[simps]\ndef isoMk {f f' : StructuredArrow S T} (g : f.right ≅ f'.right) (w : f.Hom ≫ T.map g.Hom = f'.Hom) :\n    f ≅ f' :=\n  Comma.isoMk (eqToIso (by ext)) g (by simpa [eq_to_hom_map] using w.symm)\n#align category_theory.structured_arrow.iso_mk CategoryTheory.StructuredArrow.isoMk\n\n#print CategoryTheory.StructuredArrow.ext /-\ntheorem ext {A B : StructuredArrow S T} (f g : A ⟶ B) : f.right = g.right → f = g :=\n  CommaMorphism.ext _ _ (Subsingleton.elim _ _)\n#align category_theory.structured_arrow.ext CategoryTheory.StructuredArrow.ext\n-/\n\n#print CategoryTheory.StructuredArrow.ext_iff /-\ntheorem ext_iff {A B : StructuredArrow S T} (f g : A ⟶ B) : f = g ↔ f.right = g.right :=\n  ⟨fun h => h ▸ rfl, ext f g⟩\n#align category_theory.structured_arrow.ext_iff CategoryTheory.StructuredArrow.ext_iff\n-/\n\n#print CategoryTheory.StructuredArrow.proj_faithful /-\ninstance proj_faithful : Faithful (proj S T) where map_injective' X Y := ext\n#align category_theory.structured_arrow.proj_faithful CategoryTheory.StructuredArrow.proj_faithful\n-/\n\n#print CategoryTheory.StructuredArrow.mono_of_mono_right /-\n/-- The converse of this is true with additional assumptions, see `mono_iff_mono_right`. -/\ntheorem mono_of_mono_right {A B : StructuredArrow S T} (f : A ⟶ B) [h : Mono f.right] : Mono f :=\n  (proj S T).mono_of_mono_map h\n#align category_theory.structured_arrow.mono_of_mono_right CategoryTheory.StructuredArrow.mono_of_mono_right\n-/\n\n#print CategoryTheory.StructuredArrow.epi_of_epi_right /-\ntheorem epi_of_epi_right {A B : StructuredArrow S T} (f : A ⟶ B) [h : Epi f.right] : Epi f :=\n  (proj S T).epi_of_epi_map h\n#align category_theory.structured_arrow.epi_of_epi_right CategoryTheory.StructuredArrow.epi_of_epi_right\n-/\n\n/- warning: category_theory.structured_arrow.mono_hom_mk -> CategoryTheory.StructuredArrow.mono_homMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) [h : CategoryTheory.Mono.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f], CategoryTheory.Mono.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) A B (CategoryTheory.StructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T A B f w)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) [h : CategoryTheory.Mono.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f], CategoryTheory.Mono.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) A B (CategoryTheory.StructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T A B f w)\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.mono_hom_mk CategoryTheory.StructuredArrow.mono_homMkₓ'. -/\ninstance mono_homMk {A B : StructuredArrow S T} (f : A.right ⟶ B.right) (w) [h : Mono f] :\n    Mono (homMk f w) :=\n  (proj S T).mono_of_mono_map h\n#align category_theory.structured_arrow.mono_hom_mk CategoryTheory.StructuredArrow.mono_homMk\n\n/- warning: category_theory.structured_arrow.epi_hom_mk -> CategoryTheory.StructuredArrow.epi_homMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) [h : CategoryTheory.Epi.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f], CategoryTheory.Epi.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) A B (CategoryTheory.StructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T A B f w)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S)) (CategoryTheory.Comma.left.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f)) (CategoryTheory.Comma.hom.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B)) [h : CategoryTheory.Epi.{u1, u3} C _inst_1 (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T A) (CategoryTheory.Comma.right.{u2, u1, u2, u2, u3, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) C _inst_1 D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 S) T B) f], CategoryTheory.Epi.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) A B (CategoryTheory.StructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T A B f w)\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.epi_hom_mk CategoryTheory.StructuredArrow.epi_homMkₓ'. -/\ninstance epi_homMk {A B : StructuredArrow S T} (f : A.right ⟶ B.right) (w) [h : Epi f] :\n    Epi (homMk f w) :=\n  (proj S T).epi_of_epi_map h\n#align category_theory.structured_arrow.epi_hom_mk CategoryTheory.StructuredArrow.epi_homMk\n\n#print CategoryTheory.StructuredArrow.eq_mk /-\n/-- Eta rule for structured arrows. Prefer `structured_arrow.eta`, since equality of objects tends\n    to cause problems. -/\ntheorem eq_mk (f : StructuredArrow S T) : f = mk f.Hom :=\n  by\n  cases f\n  congr\n  ext\n#align category_theory.structured_arrow.eq_mk CategoryTheory.StructuredArrow.eq_mk\n-/\n\n#print CategoryTheory.StructuredArrow.eta /-\n/-- Eta rule for structured arrows. -/\n@[simps]\ndef eta (f : StructuredArrow S T) : f ≅ mk f.Hom :=\n  isoMk (Iso.refl _) (by tidy)\n#align category_theory.structured_arrow.eta CategoryTheory.StructuredArrow.eta\n-/\n\n#print CategoryTheory.StructuredArrow.map /-\n/-- A morphism between source objects `S ⟶ S'`\ncontravariantly induces a functor between structured arrows,\n`structured_arrow S' T ⥤ structured_arrow S T`.\n\nIdeally this would be described as a 2-functor from `D`\n(promoted to a 2-category with equations as 2-morphisms)\nto `Cat`.\n-/\n@[simps]\ndef map (f : S ⟶ S') : StructuredArrow S' T ⥤ StructuredArrow S T :=\n  Comma.mapLeft _ ((Functor.const _).map f)\n#align category_theory.structured_arrow.map CategoryTheory.StructuredArrow.map\n-/\n\n/- warning: category_theory.structured_arrow.map_mk -> CategoryTheory.StructuredArrow.map_mk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {S' : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S' (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y)} (g : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S S'), Eq.{succ (max u3 u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Functor.obj.{max u2 u1, max u2 u1, max u3 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S' T g) (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' Y T f)) (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) S S' (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y) g f))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {S' : D} {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S' (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y)} (g : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S S'), Eq.{max (succ u3) (succ u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T))) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S' T g)) (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' Y T f)) (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y T (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) S S' (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y) g f))\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.map_mk CategoryTheory.StructuredArrow.map_mkₓ'. -/\n@[simp]\ntheorem map_mk {f : S' ⟶ T.obj Y} (g : S ⟶ S') : (map g).obj (mk f) = mk (g ≫ f) :=\n  rfl\n#align category_theory.structured_arrow.map_mk CategoryTheory.StructuredArrow.map_mk\n\n/- warning: category_theory.structured_arrow.map_id -> CategoryTheory.StructuredArrow.map_id is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T}, Eq.{succ (max u3 u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Functor.obj.{max u2 u1, max u2 u1, max u3 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S T (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) S)) f) f\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T}, Eq.{max (succ u3) (succ u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S T (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) S))) f) f\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.map_id CategoryTheory.StructuredArrow.map_idₓ'. -/\n@[simp]\ntheorem map_id {f : StructuredArrow S T} : (map (𝟙 S)).obj f = f :=\n  by\n  rw [eq_mk f]\n  simp\n#align category_theory.structured_arrow.map_id CategoryTheory.StructuredArrow.map_id\n\n/- warning: category_theory.structured_arrow.map_comp -> CategoryTheory.StructuredArrow.map_comp is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {S' : D} {S'' : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S S'} {f' : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S' S''} {h : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T}, Eq.{succ (max u3 u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Functor.obj.{max u2 u1, max u2 u1, max u3 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S'' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S'' T (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) S S' S'' f f')) h) (CategoryTheory.Functor.obj.{max u2 u1, max u2 u1, max u3 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S' T f) (CategoryTheory.Functor.obj.{max u2 u1, max u2 u1, max u3 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S'' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' S'' T f') h))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {S' : D} {S'' : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S S'} {f' : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) S' S''} {h : CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T}, Eq.{max (succ u3) (succ u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T))) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S'' T (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) S S' S'' f f'))) h) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T))) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S S' T f)) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T))) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S'' T) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' T) (CategoryTheory.StructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S' S'' T f')) h))\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.map_comp CategoryTheory.StructuredArrow.map_compₓ'. -/\n@[simp]\ntheorem map_comp {f : S ⟶ S'} {f' : S' ⟶ S''} {h : StructuredArrow S'' T} :\n    (map (f ≫ f')).obj h = (map f).obj ((map f').obj h) :=\n  by\n  rw [eq_mk h]\n  simp\n#align category_theory.structured_arrow.map_comp CategoryTheory.StructuredArrow.map_comp\n\n#print CategoryTheory.StructuredArrow.proj_reflectsIsomorphisms /-\ninstance proj_reflectsIsomorphisms : ReflectsIsomorphisms (proj S T)\n    where reflects Y Z f t :=\n    ⟨⟨structured_arrow.hom_mk (inv ((proj S T).map f)) (by simp), by tidy⟩⟩\n#align category_theory.structured_arrow.proj_reflects_iso CategoryTheory.StructuredArrow.proj_reflectsIsomorphisms\n-/\n\nopen CategoryTheory.Limits\n\nattribute [local tidy] tactic.discrete_cases\n\n/- warning: category_theory.structured_arrow.mk_id_initial -> CategoryTheory.StructuredArrow.mkIdInitial is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} [_inst_3 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 T] [_inst_4 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 T], CategoryTheory.Limits.IsInitial.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y) T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y) T) (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y) Y T (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {Y : C} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} [_inst_3 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 T] [_inst_4 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 T], CategoryTheory.Limits.IsInitial.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y) T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y) T) (CategoryTheory.StructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y) Y T (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 T) Y)))\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.mk_id_initial CategoryTheory.StructuredArrow.mkIdInitialₓ'. -/\n/-- The identity structured arrow is initial. -/\ndef mkIdInitial [Full T] [Faithful T] : IsInitial (mk (𝟙 (T.obj Y)))\n    where\n  desc c :=\n    homMk (T.preimage c.pt.Hom)\n      (by\n        dsimp\n        simp)\n  uniq c m _ := by\n    ext\n    apply T.map_injective\n    simpa only [hom_mk_right, T.image_preimage, ← w m] using (category.id_comp _).symm\n#align category_theory.structured_arrow.mk_id_initial CategoryTheory.StructuredArrow.mkIdInitial\n\nvariable {A : Type u₃} [Category.{v₃} A] {B : Type u₄} [Category.{v₄} B]\n\n#print CategoryTheory.StructuredArrow.pre /-\n/-- The functor `(S, F ⋙ G) ⥤ (S, G)`. -/\n@[simps]\ndef pre (S : D) (F : B ⥤ C) (G : C ⥤ D) : StructuredArrow S (F ⋙ G) ⥤ StructuredArrow S G :=\n  Comma.preRight _ F G\n#align category_theory.structured_arrow.pre CategoryTheory.StructuredArrow.pre\n-/\n\n/- warning: category_theory.structured_arrow.post -> CategoryTheory.StructuredArrow.post is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u1, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u2, u5} D] {B : Type.{u6}} [_inst_4 : CategoryTheory.Category.{u3, u6} B] (S : C) (F : CategoryTheory.Functor.{u3, u1, u6, u4} B _inst_4 C _inst_1) (G : CategoryTheory.Functor.{u1, u2, u4, u5} C _inst_1 D _inst_2), CategoryTheory.Functor.{max u1 u3, max u2 u3, max u6 u1, max u6 u2} (CategoryTheory.StructuredArrow.{u3, u1, u6, u4} B _inst_4 C _inst_1 S F) (CategoryTheory.StructuredArrow.category.{u1, u4, u6, u3} B _inst_4 C _inst_1 S F) (CategoryTheory.StructuredArrow.{u3, u2, u6, u5} B _inst_4 D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u4, u5} C _inst_1 D _inst_2 G S) (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G)) (CategoryTheory.StructuredArrow.category.{u2, u5, u6, u3} B _inst_4 D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u4, u5} C _inst_1 D _inst_2 G S) (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u1, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u2, u5} D] {B : Type.{u6}} [_inst_4 : CategoryTheory.Category.{u3, u6} B] (S : C) (F : CategoryTheory.Functor.{u3, u1, u6, u4} B _inst_4 C _inst_1) (G : CategoryTheory.Functor.{u1, u2, u4, u5} C _inst_1 D _inst_2), CategoryTheory.Functor.{max u1 u3, max u2 u3, max u6 u1, max u6 u2} (CategoryTheory.StructuredArrow.{u3, u1, u6, u4} B _inst_4 C _inst_1 S F) (CategoryTheory.instCategoryStructuredArrow.{u3, u1, u6, u4} B _inst_4 C _inst_1 S F) (CategoryTheory.StructuredArrow.{u3, u2, u6, u5} B _inst_4 D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u4} C (CategoryTheory.Category.toCategoryStruct.{u1, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u5} D (CategoryTheory.Category.toCategoryStruct.{u2, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u4, u5} C _inst_1 D _inst_2 G) S) (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G)) (CategoryTheory.instCategoryStructuredArrow.{u3, u2, u6, u5} B _inst_4 D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u4} C (CategoryTheory.Category.toCategoryStruct.{u1, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u5} D (CategoryTheory.Category.toCategoryStruct.{u2, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u4, u5} C _inst_1 D _inst_2 G) S) (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G))\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.post CategoryTheory.StructuredArrow.postₓ'. -/\n/-- The functor `(S, F) ⥤ (G(S), F ⋙ G)`. -/\n@[simps]\ndef post (S : C) (F : B ⥤ C) (G : C ⥤ D) : StructuredArrow S F ⥤ StructuredArrow (G.obj S) (F ⋙ G)\n    where\n  obj X := StructuredArrow.mk (G.map X.Hom)\n  map X Y f := StructuredArrow.homMk f.right (by simp [functor.comp_map, ← G.map_comp, ← f.w])\n#align category_theory.structured_arrow.post CategoryTheory.StructuredArrow.post\n\n/- warning: category_theory.structured_arrow.small_proj_preimage_of_locally_small -> CategoryTheory.StructuredArrow.small_proj_preimage_of_locallySmall is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {𝒢 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (coeSort.{succ u3, succ (succ u3)} (Set.{u3} C) Type.{u3} (Set.hasCoeToSort.{u3} C) 𝒢)] [_inst_6 : CategoryTheory.LocallySmall.{u1, u2, u4} D _inst_2], Small.{u1, max u3 u2} (coeSort.{succ (max u3 u2), succ (succ (max u3 u2))} (Set.{max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)) Type.{max u3 u2} (Set.hasCoeToSort.{max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)) (Set.preimage.{max u3 u2, u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) C (CategoryTheory.Functor.obj.{max u2 u1, u1, max u3 u2, u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) C _inst_1 (CategoryTheory.StructuredArrow.proj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)) 𝒢))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {S : D} {T : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {𝒢 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (Set.Elem.{u3} C 𝒢)] [_inst_6 : CategoryTheory.LocallySmall.{u1, u2, u4} D _inst_2], Small.{u1, max u3 u2} (Set.Elem.{max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (Set.preimage.{max u3 u2, u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) C (Prefunctor.obj.{max (succ u1) (succ u2), succ u1, max u3 u2, u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Functor.toPrefunctor.{max u1 u2, u1, max u3 u2, u3} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) C _inst_1 (CategoryTheory.StructuredArrow.proj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) 𝒢))\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow.small_proj_preimage_of_locally_small CategoryTheory.StructuredArrow.small_proj_preimage_of_locallySmallₓ'. -/\ninstance small_proj_preimage_of_locallySmall {𝒢 : Set C} [Small.{v₁} 𝒢] [LocallySmall.{v₁} D] :\n    Small.{v₁} ((proj S T).obj ⁻¹' 𝒢) :=\n  by\n  suffices (proj S T).obj ⁻¹' 𝒢 = Set.range fun f : ΣG : 𝒢, S ⟶ T.obj G => mk f.2\n    by\n    rw [this]\n    infer_instance\n  exact Set.ext fun X => ⟨fun h => ⟨⟨⟨_, h⟩, X.Hom⟩, (eq_mk _).symm⟩, by tidy⟩\n#align category_theory.structured_arrow.small_proj_preimage_of_locally_small CategoryTheory.StructuredArrow.small_proj_preimage_of_locallySmall\n\nend StructuredArrow\n\n#print CategoryTheory.CostructuredArrow /-\n/-- The category of `S`-costructured arrows with target `T : D` (here `S : C ⥤ D`),\nhas as its objects `D`-morphisms of the form `S Y ⟶ T`, for some `Y : C`,\nand morphisms `C`-morphisms `Y ⟶ Y'` making the obvious triangle commute.\n-/\n@[nolint has_nonempty_instance]\ndef CostructuredArrow (S : C ⥤ D) (T : D) :=\n  Comma S (Functor.fromPUnit T)deriving Category\n#align category_theory.costructured_arrow CategoryTheory.CostructuredArrow\n-/\n\nnamespace CostructuredArrow\n\n#print CategoryTheory.CostructuredArrow.proj /-\n/-- The obvious projection functor from costructured arrows. -/\n@[simps]\ndef proj (S : C ⥤ D) (T : D) : CostructuredArrow S T ⥤ C :=\n  Comma.fst _ _\n#align category_theory.costructured_arrow.proj CategoryTheory.CostructuredArrow.proj\n-/\n\nvariable {T T' T'' : D} {Y Y' : C} {S : C ⥤ D}\n\n/- warning: category_theory.costructured_arrow.mk -> CategoryTheory.CostructuredArrow.mk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2}, (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y) T) -> (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2}, (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y) T) -> (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.mk CategoryTheory.CostructuredArrow.mkₓ'. -/\n/-- Construct a costructured arrow from a morphism. -/\ndef mk (f : S.obj Y ⟶ T) : CostructuredArrow S T :=\n  ⟨Y, ⟨⟨⟩⟩, f⟩\n#align category_theory.costructured_arrow.mk CategoryTheory.CostructuredArrow.mk\n\n/- warning: category_theory.costructured_arrow.mk_left -> CategoryTheory.CostructuredArrow.mk_left is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y) T), Eq.{succ u3} C (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) Y\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y) T), Eq.{succ u3} C (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) Y\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.mk_left CategoryTheory.CostructuredArrow.mk_leftₓ'. -/\n@[simp]\ntheorem mk_left (f : S.obj Y ⟶ T) : (mk f).left = Y :=\n  rfl\n#align category_theory.costructured_arrow.mk_left CategoryTheory.CostructuredArrow.mk_left\n\n/- warning: category_theory.costructured_arrow.mk_right -> CategoryTheory.CostructuredArrow.mk_right is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y) T), Eq.{succ u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) (CategoryTheory.Discrete.mk.{u2} PUnit.{succ u2} PUnit.unit.{succ u2})\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y) T), Eq.{succ u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) (CategoryTheory.Discrete.mk.{u2} PUnit.{succ u2} PUnit.unit.{succ u2})\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.mk_right CategoryTheory.CostructuredArrow.mk_rightₓ'. -/\n@[simp]\ntheorem mk_right (f : S.obj Y ⟶ T) : (mk f).right = ⟨⟨⟩⟩ :=\n  rfl\n#align category_theory.costructured_arrow.mk_right CategoryTheory.CostructuredArrow.mk_right\n\n/- warning: category_theory.costructured_arrow.mk_hom_eq_self -> CategoryTheory.CostructuredArrow.mk_hom_eq_self is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y) T), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f))) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)))) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) f\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} (f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y) T), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f))) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)))) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) f\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.mk_hom_eq_self CategoryTheory.CostructuredArrow.mk_hom_eq_selfₓ'. -/\n@[simp]\ntheorem mk_hom_eq_self (f : S.obj Y ⟶ T) : (mk f).Hom = f :=\n  rfl\n#align category_theory.costructured_arrow.mk_hom_eq_self CategoryTheory.CostructuredArrow.mk_hom_eq_self\n\n/- warning: category_theory.costructured_arrow.w -> CategoryTheory.CostructuredArrow.w is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ (max u1 u2), max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T))) A B), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) (CategoryTheory.CommaMorphism.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A B f)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{max (succ u1) (succ u2), max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) A B), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) (CategoryTheory.CommaMorphism.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A B f)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.w CategoryTheory.CostructuredArrow.wₓ'. -/\n@[simp, reassoc.1]\ntheorem w {A B : CostructuredArrow S T} (f : A ⟶ B) : S.map f.left ≫ B.Hom = A.Hom := by tidy\n#align category_theory.costructured_arrow.w CategoryTheory.CostructuredArrow.w\n\n/- warning: category_theory.costructured_arrow.hom_mk -> CategoryTheory.CostructuredArrow.homMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f') g) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) -> (Quiver.Hom.{succ (max u1 u2), max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T))) f f')\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f') g) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) -> (Quiver.Hom.{max (succ u1) (succ u2), max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) f f')\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.hom_mk CategoryTheory.CostructuredArrow.homMkₓ'. -/\n/-- To construct a morphism of costructured arrows,\nwe need a morphism of the objects underlying the source,\nand to check that the triangle commutes.\n-/\n@[simps]\ndef homMk {f f' : CostructuredArrow S T} (g : f.left ⟶ f'.left) (w : S.map g ≫ f'.Hom = f.Hom) :\n    f ⟶ f' where\n  left := g\n  right := eqToHom (by ext)\n  w' := by simpa [eq_to_hom_map] using w\n#align category_theory.costructured_arrow.hom_mk CategoryTheory.CostructuredArrow.homMk\n\n/- warning: category_theory.costructured_arrow.iso_mk -> CategoryTheory.CostructuredArrow.isoMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : CategoryTheory.Iso.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f') (CategoryTheory.Iso.hom.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f') g)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) -> (CategoryTheory.Iso.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.commaCategory.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) f f')\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {f' : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (g : CategoryTheory.Iso.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f'))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f') (CategoryTheory.Iso.hom.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f') g)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f')) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) f)) -> (CategoryTheory.Iso.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) f f')\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.iso_mk CategoryTheory.CostructuredArrow.isoMkₓ'. -/\n/-- To construct an isomorphism of costructured arrows,\nwe need an isomorphism of the objects underlying the source,\nand to check that the triangle commutes.\n-/\n@[simps]\ndef isoMk {f f' : CostructuredArrow S T} (g : f.left ≅ f'.left) (w : S.map g.Hom ≫ f'.Hom = f.Hom) :\n    f ≅ f' :=\n  Comma.isoMk g (eqToIso (by ext)) (by simpa [eq_to_hom_map] using w)\n#align category_theory.costructured_arrow.iso_mk CategoryTheory.CostructuredArrow.isoMk\n\n#print CategoryTheory.CostructuredArrow.ext /-\ntheorem ext {A B : CostructuredArrow S T} (f g : A ⟶ B) (h : f.left = g.left) : f = g :=\n  CommaMorphism.ext _ _ h (Subsingleton.elim _ _)\n#align category_theory.costructured_arrow.ext CategoryTheory.CostructuredArrow.ext\n-/\n\n#print CategoryTheory.CostructuredArrow.ext_iff /-\ntheorem ext_iff {A B : CostructuredArrow S T} (f g : A ⟶ B) : f = g ↔ f.left = g.left :=\n  ⟨fun h => h ▸ rfl, ext f g⟩\n#align category_theory.costructured_arrow.ext_iff CategoryTheory.CostructuredArrow.ext_iff\n-/\n\n#print CategoryTheory.CostructuredArrow.proj_faithful /-\ninstance proj_faithful : Faithful (proj S T) where map_injective' X Y := ext\n#align category_theory.costructured_arrow.proj_faithful CategoryTheory.CostructuredArrow.proj_faithful\n-/\n\n#print CategoryTheory.CostructuredArrow.mono_of_mono_left /-\ntheorem mono_of_mono_left {A B : CostructuredArrow S T} (f : A ⟶ B) [h : Mono f.left] : Mono f :=\n  (proj S T).mono_of_mono_map h\n#align category_theory.costructured_arrow.mono_of_mono_left CategoryTheory.CostructuredArrow.mono_of_mono_left\n-/\n\n#print CategoryTheory.CostructuredArrow.epi_of_epi_left /-\n/-- The converse of this is true with additional assumptions, see `epi_iff_epi_left`. -/\ntheorem epi_of_epi_left {A B : CostructuredArrow S T} (f : A ⟶ B) [h : Epi f.left] : Epi f :=\n  (proj S T).epi_of_epi_map h\n#align category_theory.costructured_arrow.epi_of_epi_left CategoryTheory.CostructuredArrow.epi_of_epi_left\n-/\n\n/- warning: category_theory.costructured_arrow.mono_hom_mk -> CategoryTheory.CostructuredArrow.mono_homMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) [h : CategoryTheory.Mono.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f], CategoryTheory.Mono.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) A B (CategoryTheory.CostructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T S A B f w)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) [h : CategoryTheory.Mono.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f], CategoryTheory.Mono.{max u2 u1, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) A B (CategoryTheory.CostructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T S A B f w)\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.mono_hom_mk CategoryTheory.CostructuredArrow.mono_homMkₓ'. -/\ninstance mono_homMk {A B : CostructuredArrow S T} (f : A.left ⟶ B.left) (w) [h : Mono f] :\n    Mono (homMk f w) :=\n  (proj S T).mono_of_mono_map h\n#align category_theory.costructured_arrow.mono_hom_mk CategoryTheory.CostructuredArrow.mono_homMk\n\n/- warning: category_theory.costructured_arrow.epi_hom_mk -> CategoryTheory.CostructuredArrow.epi_homMk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Functor.obj.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) [h : CategoryTheory.Epi.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f], CategoryTheory.Epi.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) A B (CategoryTheory.CostructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T S A B f w)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {A : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} {B : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (w : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (Prefunctor.obj.{succ u2, succ u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.CategoryStruct.toQuiver.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.Category.toCategoryStruct.{u2, u2} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}))) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u2, u2, u4} (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T)) (CategoryTheory.Comma.right.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B)) (CategoryTheory.Comma.hom.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A)) [h : CategoryTheory.Epi.{u1, u3} C _inst_1 (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) A) (CategoryTheory.Comma.left.{u1, u2, u2, u3, u2, u4} C _inst_1 (CategoryTheory.Discrete.{u2} PUnit.{succ u2}) (CategoryTheory.discreteCategory.{u2} PUnit.{succ u2}) D _inst_2 S (CategoryTheory.Functor.fromPUnit.{u2, u4} D _inst_2 T) B) f], CategoryTheory.Epi.{max u2 u1, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) A B (CategoryTheory.CostructuredArrow.homMk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T S A B f w)\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.epi_hom_mk CategoryTheory.CostructuredArrow.epi_homMkₓ'. -/\ninstance epi_homMk {A B : CostructuredArrow S T} (f : A.left ⟶ B.left) (w) [h : Epi f] :\n    Epi (homMk f w) :=\n  (proj S T).epi_of_epi_map h\n#align category_theory.costructured_arrow.epi_hom_mk CategoryTheory.CostructuredArrow.epi_homMk\n\n#print CategoryTheory.CostructuredArrow.eq_mk /-\n/-- Eta rule for costructured arrows. Prefer `costructured_arrow.eta`, as equality of objects tends\n    to cause problems. -/\ntheorem eq_mk (f : CostructuredArrow S T) : f = mk f.Hom :=\n  by\n  cases f\n  congr\n  ext\n#align category_theory.costructured_arrow.eq_mk CategoryTheory.CostructuredArrow.eq_mk\n-/\n\n#print CategoryTheory.CostructuredArrow.eta /-\n/-- Eta rule for costructured arrows. -/\n@[simps]\ndef eta (f : CostructuredArrow S T) : f ≅ mk f.Hom :=\n  isoMk (Iso.refl _) (by tidy)\n#align category_theory.costructured_arrow.eta CategoryTheory.CostructuredArrow.eta\n-/\n\n#print CategoryTheory.CostructuredArrow.map /-\n/-- A morphism between target objects `T ⟶ T'`\ncovariantly induces a functor between costructured arrows,\n`costructured_arrow S T ⥤ costructured_arrow S T'`.\n\nIdeally this would be described as a 2-functor from `D`\n(promoted to a 2-category with equations as 2-morphisms)\nto `Cat`.\n-/\n@[simps]\ndef map (f : T ⟶ T') : CostructuredArrow S T ⥤ CostructuredArrow S T' :=\n  Comma.mapRight _ ((Functor.const _).map f)\n#align category_theory.costructured_arrow.map CategoryTheory.CostructuredArrow.map\n-/\n\n/- warning: category_theory.costructured_arrow.map_mk -> CategoryTheory.CostructuredArrow.map_mk is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {T' : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y) T} (g : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) T T'), Eq.{succ (max u3 u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.Functor.obj.{max u1 u2, max u1 u2, max u3 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T' S g) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T' Y S (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y) T T' f g))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {T' : D} {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y) T} (g : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) T T'), Eq.{max (succ u3) (succ u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T' S g)) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T Y S f)) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 T' Y S (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y) T T' f g))\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.map_mk CategoryTheory.CostructuredArrow.map_mkₓ'. -/\n@[simp]\ntheorem map_mk {f : S.obj Y ⟶ T} (g : T ⟶ T') : (map g).obj (mk f) = mk (f ≫ g) :=\n  rfl\n#align category_theory.costructured_arrow.map_mk CategoryTheory.CostructuredArrow.map_mk\n\n/- warning: category_theory.costructured_arrow.map_id -> CategoryTheory.CostructuredArrow.map_id is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T}, Eq.{succ (max u3 u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Functor.obj.{max u1 u2, max u1 u2, max u3 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T S (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) T)) f) f\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T}, Eq.{max (succ u3) (succ u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T S (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) T))) f) f\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.map_id CategoryTheory.CostructuredArrow.map_idₓ'. -/\n@[simp]\ntheorem map_id {f : CostructuredArrow S T} : (map (𝟙 T)).obj f = f :=\n  by\n  rw [eq_mk f]\n  simp\n#align category_theory.costructured_arrow.map_id CategoryTheory.CostructuredArrow.map_id\n\n/- warning: category_theory.costructured_arrow.map_comp -> CategoryTheory.CostructuredArrow.map_comp is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {T' : D} {T'' : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) T T'} {f' : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) T' T''} {h : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T}, Eq.{succ (max u3 u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.Functor.obj.{max u1 u2, max u1 u2, max u3 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T'') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T'' S (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) T T' T'' f f')) h) (CategoryTheory.Functor.obj.{max u1 u2, max u1 u2, max u3 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T'') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T' T'' S f') (CategoryTheory.Functor.obj.{max u1 u2, max u1 u2, max u3 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T' S f) h))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {T' : D} {T'' : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {f : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) T T'} {f' : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) T' T''} {h : CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T}, Eq.{max (succ u3) (succ u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T''))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T'' S (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) T T' T'' f f'))) h) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'))) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T''))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T' T'' S f')) (Prefunctor.obj.{max (succ u2) (succ u1), max (succ u2) (succ u1), max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CategoryStruct.toQuiver.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.Category.toCategoryStruct.{max u2 u1, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T'))) (CategoryTheory.Functor.toPrefunctor.{max u2 u1, max u2 u1, max u2 u3, max u2 u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T') (CategoryTheory.CostructuredArrow.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 T T' S f)) h))\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.map_comp CategoryTheory.CostructuredArrow.map_compₓ'. -/\n@[simp]\ntheorem map_comp {f : T ⟶ T'} {f' : T' ⟶ T''} {h : CostructuredArrow S T} :\n    (map (f ≫ f')).obj h = (map f').obj ((map f).obj h) :=\n  by\n  rw [eq_mk h]\n  simp\n#align category_theory.costructured_arrow.map_comp CategoryTheory.CostructuredArrow.map_comp\n\n#print CategoryTheory.CostructuredArrow.proj_reflectsIsomorphisms /-\ninstance proj_reflectsIsomorphisms : ReflectsIsomorphisms (proj S T)\n    where reflects Y Z f t :=\n    ⟨⟨costructured_arrow.hom_mk (inv ((proj S T).map f)) (by simp), by tidy⟩⟩\n#align category_theory.costructured_arrow.proj_reflects_iso CategoryTheory.CostructuredArrow.proj_reflectsIsomorphisms\n-/\n\nopen CategoryTheory.Limits\n\nattribute [local tidy] tactic.discrete_cases\n\n/- warning: category_theory.costructured_arrow.mk_id_terminal -> CategoryTheory.CostructuredArrow.mkIdTerminal is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} [_inst_3 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 S] [_inst_4 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 S], CategoryTheory.Limits.IsTerminal.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y)) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y)) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y) Y S (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S Y)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {Y : C} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} [_inst_3 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 S] [_inst_4 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 S], CategoryTheory.Limits.IsTerminal.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y)) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y)) (CategoryTheory.CostructuredArrow.mk.{u1, u2, u3, u4} C _inst_1 D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y) Y S (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 S) Y)))\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.mk_id_terminal CategoryTheory.CostructuredArrow.mkIdTerminalₓ'. -/\n/-- The identity costructured arrow is terminal. -/\ndef mkIdTerminal [Full S] [Faithful S] : IsTerminal (mk (𝟙 (S.obj Y)))\n    where\n  lift c :=\n    homMk (S.preimage c.pt.Hom)\n      (by\n        dsimp\n        simp)\n  uniq := by\n    rintro c m -\n    ext\n    apply S.map_injective\n    simpa only [hom_mk_left, S.image_preimage, ← w m] using (category.comp_id _).symm\n#align category_theory.costructured_arrow.mk_id_terminal CategoryTheory.CostructuredArrow.mkIdTerminal\n\nvariable {A : Type u₃} [Category.{v₃} A] {B : Type u₄} [Category.{v₄} B]\n\n#print CategoryTheory.CostructuredArrow.pre /-\n/-- The functor `(F ⋙ G, S) ⥤ (G, S)`. -/\n@[simps]\ndef pre (F : B ⥤ C) (G : C ⥤ D) (S : D) : CostructuredArrow (F ⋙ G) S ⥤ CostructuredArrow G S :=\n  Comma.preLeft F G _\n#align category_theory.costructured_arrow.pre CategoryTheory.CostructuredArrow.pre\n-/\n\n/- warning: category_theory.costructured_arrow.post -> CategoryTheory.CostructuredArrow.post is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u1, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u2, u5} D] {B : Type.{u6}} [_inst_4 : CategoryTheory.Category.{u3, u6} B] (F : CategoryTheory.Functor.{u3, u1, u6, u4} B _inst_4 C _inst_1) (G : CategoryTheory.Functor.{u1, u2, u4, u5} C _inst_1 D _inst_2) (S : C), CategoryTheory.Functor.{max u3 u1, max u3 u2, max u6 u1, max u6 u2} (CategoryTheory.CostructuredArrow.{u3, u1, u6, u4} B _inst_4 C _inst_1 F S) (CategoryTheory.CostructuredArrow.category.{u1, u4, u6, u3} B _inst_4 C _inst_1 F S) (CategoryTheory.CostructuredArrow.{u3, u2, u6, u5} B _inst_4 D _inst_2 (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G) (CategoryTheory.Functor.obj.{u1, u2, u4, u5} C _inst_1 D _inst_2 G S)) (CategoryTheory.CostructuredArrow.category.{u2, u5, u6, u3} B _inst_4 D _inst_2 (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G) (CategoryTheory.Functor.obj.{u1, u2, u4, u5} C _inst_1 D _inst_2 G S))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u1, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u2, u5} D] {B : Type.{u6}} [_inst_4 : CategoryTheory.Category.{u3, u6} B] (F : CategoryTheory.Functor.{u3, u1, u6, u4} B _inst_4 C _inst_1) (G : CategoryTheory.Functor.{u1, u2, u4, u5} C _inst_1 D _inst_2) (S : C), CategoryTheory.Functor.{max u1 u3, max u2 u3, max u6 u1, max u6 u2} (CategoryTheory.CostructuredArrow.{u3, u1, u6, u4} B _inst_4 C _inst_1 F S) (CategoryTheory.instCategoryCostructuredArrow.{u3, u1, u6, u4} B _inst_4 C _inst_1 F S) (CategoryTheory.CostructuredArrow.{u3, u2, u6, u5} B _inst_4 D _inst_2 (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G) (Prefunctor.obj.{succ u1, succ u2, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u4} C (CategoryTheory.Category.toCategoryStruct.{u1, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u5} D (CategoryTheory.Category.toCategoryStruct.{u2, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u4, u5} C _inst_1 D _inst_2 G) S)) (CategoryTheory.instCategoryCostructuredArrow.{u3, u2, u6, u5} B _inst_4 D _inst_2 (CategoryTheory.Functor.comp.{u3, u1, u2, u6, u4, u5} B _inst_4 C _inst_1 D _inst_2 F G) (Prefunctor.obj.{succ u1, succ u2, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u4} C (CategoryTheory.Category.toCategoryStruct.{u1, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u5} D (CategoryTheory.Category.toCategoryStruct.{u2, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u4, u5} C _inst_1 D _inst_2 G) S))\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.post CategoryTheory.CostructuredArrow.postₓ'. -/\n/-- The functor `(F, S) ⥤ (F ⋙ G, G(S))`. -/\n@[simps]\ndef post (F : B ⥤ C) (G : C ⥤ D) (S : C) :\n    CostructuredArrow F S ⥤ CostructuredArrow (F ⋙ G) (G.obj S)\n    where\n  obj X := CostructuredArrow.mk (G.map X.Hom)\n  map X Y f := CostructuredArrow.homMk f.left (by simp [functor.comp_map, ← G.map_comp, ← f.w])\n#align category_theory.costructured_arrow.post CategoryTheory.CostructuredArrow.post\n\n/- warning: category_theory.costructured_arrow.small_proj_preimage_of_locally_small -> CategoryTheory.CostructuredArrow.small_proj_preimage_of_locallySmall is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {𝒢 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (coeSort.{succ u3, succ (succ u3)} (Set.{u3} C) Type.{u3} (Set.hasCoeToSort.{u3} C) 𝒢)] [_inst_6 : CategoryTheory.LocallySmall.{u1, u2, u4} D _inst_2], Small.{u1, max u3 u2} (coeSort.{succ (max u3 u2), succ (succ (max u3 u2))} (Set.{max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)) Type.{max u3 u2} (Set.hasCoeToSort.{max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)) (Set.preimage.{max u3 u2, u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) C (CategoryTheory.Functor.obj.{max u1 u2, u1, max u3 u2, u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 S T) C _inst_1 (CategoryTheory.CostructuredArrow.proj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T)) 𝒢))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {T : D} {S : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2} {𝒢 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (Set.Elem.{u3} C 𝒢)] [_inst_6 : CategoryTheory.LocallySmall.{u1, u2, u4} D _inst_2], Small.{u1, max u3 u2} (Set.Elem.{max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (Set.preimage.{max u3 u2, u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) C (Prefunctor.obj.{max (succ u1) (succ u2), succ u1, max u3 u2, u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.CategoryStruct.toQuiver.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.Category.toCategoryStruct.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Functor.toPrefunctor.{max u1 u2, u1, max u3 u2, u3} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T) C _inst_1 (CategoryTheory.CostructuredArrow.proj.{u1, u2, u3, u4} C _inst_1 D _inst_2 S T))) 𝒢))\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow.small_proj_preimage_of_locally_small CategoryTheory.CostructuredArrow.small_proj_preimage_of_locallySmallₓ'. -/\ninstance small_proj_preimage_of_locallySmall {𝒢 : Set C} [Small.{v₁} 𝒢] [LocallySmall.{v₁} D] :\n    Small.{v₁} ((proj S T).obj ⁻¹' 𝒢) :=\n  by\n  suffices (proj S T).obj ⁻¹' 𝒢 = Set.range fun f : ΣG : 𝒢, S.obj G ⟶ T => mk f.2\n    by\n    rw [this]\n    infer_instance\n  exact Set.ext fun X => ⟨fun h => ⟨⟨⟨_, h⟩, X.Hom⟩, (eq_mk _).symm⟩, by tidy⟩\n#align category_theory.costructured_arrow.small_proj_preimage_of_locally_small CategoryTheory.CostructuredArrow.small_proj_preimage_of_locallySmall\n\nend CostructuredArrow\n\nopen Opposite\n\nnamespace StructuredArrow\n\n#print CategoryTheory.StructuredArrow.toCostructuredArrow /-\n/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of structured arrows `d ⟶ F.obj c` to the category of costructured arrows\n`F.op.obj c ⟶ (op d)`.\n-/\n@[simps]\ndef toCostructuredArrow (F : C ⥤ D) (d : D) :\n    (StructuredArrow d F)ᵒᵖ ⥤ CostructuredArrow F.op (op d)\n    where\n  obj X := @CostructuredArrow.mk _ _ _ _ _ (op X.unop.right) F.op X.unop.Hom.op\n  map X Y f :=\n    CostructuredArrow.homMk f.unop.right.op\n      (by\n        dsimp\n        rw [← op_comp, ← f.unop.w, functor.const_obj_map]\n        erw [category.id_comp])\n#align category_theory.structured_arrow.to_costructured_arrow CategoryTheory.StructuredArrow.toCostructuredArrow\n-/\n\n#print CategoryTheory.StructuredArrow.toCostructuredArrow' /-\n/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of structured arrows `op d ⟶ F.op.obj c` to the category of costructured arrows\n`F.obj c ⟶ d`.\n-/\n@[simps]\ndef toCostructuredArrow' (F : C ⥤ D) (d : D) :\n    (StructuredArrow (op d) F.op)ᵒᵖ ⥤ CostructuredArrow F d\n    where\n  obj X := @CostructuredArrow.mk _ _ _ _ _ (unop X.unop.right) F X.unop.Hom.unop\n  map X Y f :=\n    CostructuredArrow.homMk f.unop.right.unop\n      (by\n        dsimp\n        rw [← Quiver.Hom.unop_op (F.map (Quiver.Hom.unop f.unop.right)), ← unop_comp, ← F.op_map, ←\n          f.unop.w, functor.const_obj_map]\n        erw [category.id_comp])\n#align category_theory.structured_arrow.to_costructured_arrow' CategoryTheory.StructuredArrow.toCostructuredArrow'\n-/\n\nend StructuredArrow\n\nnamespace CostructuredArrow\n\n#print CategoryTheory.CostructuredArrow.toStructuredArrow /-\n/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of costructured arrows `F.obj c ⟶ d` to the category of structured arrows\n`op d ⟶ F.op.obj c`.\n-/\n@[simps]\ndef toStructuredArrow (F : C ⥤ D) (d : D) : (CostructuredArrow F d)ᵒᵖ ⥤ StructuredArrow (op d) F.op\n    where\n  obj X := @StructuredArrow.mk _ _ _ _ _ (op X.unop.left) F.op X.unop.Hom.op\n  map X Y f :=\n    StructuredArrow.homMk f.unop.left.op\n      (by\n        dsimp\n        rw [← op_comp, f.unop.w, functor.const_obj_map]\n        erw [category.comp_id])\n#align category_theory.costructured_arrow.to_structured_arrow CategoryTheory.CostructuredArrow.toStructuredArrow\n-/\n\n#print CategoryTheory.CostructuredArrow.toStructuredArrow' /-\n/-- For a functor `F : C ⥤ D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of costructured arrows `F.op.obj c ⟶ op d` to the category of structured arrows\n`d ⟶ F.obj c`.\n-/\n@[simps]\ndef toStructuredArrow' (F : C ⥤ D) (d : D) : (CostructuredArrow F.op (op d))ᵒᵖ ⥤ StructuredArrow d F\n    where\n  obj X := @StructuredArrow.mk _ _ _ _ _ (unop X.unop.left) F X.unop.Hom.unop\n  map X Y f :=\n    StructuredArrow.homMk f.unop.left.unop\n      (by\n        dsimp\n        rw [← Quiver.Hom.unop_op (F.map f.unop.left.unop), ← unop_comp, ← F.op_map, f.unop.w,\n          functor.const_obj_map]\n        erw [category.comp_id])\n#align category_theory.costructured_arrow.to_structured_arrow' CategoryTheory.CostructuredArrow.toStructuredArrow'\n-/\n\nend CostructuredArrow\n\n/- warning: category_theory.structured_arrow_op_equivalence -> CategoryTheory.structuredArrowOpEquivalence is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (d : D), CategoryTheory.Equivalence.{max u2 u1, max u1 u2, max u3 u2, max u3 u2} (Opposite.{succ (max u3 u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 d F)) (CategoryTheory.Category.opposite.{max u2 u1, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 d F) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 d F)) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (Opposite.op.{succ u4} D d)) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (Opposite.op.{succ u4} D d))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (d : D), CategoryTheory.Equivalence.{max u1 u2, max u1 u2, max u3 u2, max u3 u2} (Opposite.{succ (max u3 u2)} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 d F)) (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (Opposite.op.{succ u4} D d)) (CategoryTheory.Category.opposite.{max u1 u2, max u3 u2} (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 d F) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 d F)) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (Opposite.op.{succ u4} D d))\nCase conversion may be inaccurate. Consider using '#align category_theory.structured_arrow_op_equivalence CategoryTheory.structuredArrowOpEquivalenceₓ'. -/\n/-- For a functor `F : C ⥤ D` and an object `d : D`, the category of structured arrows `d ⟶ F.obj c`\nis contravariantly equivalent to the category of costructured arrows `F.op.obj c ⟶ op d`.\n-/\ndef structuredArrowOpEquivalence (F : C ⥤ D) (d : D) :\n    (StructuredArrow d F)ᵒᵖ ≌ CostructuredArrow F.op (op d) :=\n  Equivalence.mk (StructuredArrow.toCostructuredArrow F d)\n    (CostructuredArrow.toStructuredArrow' F d).rightOp\n    (NatIso.ofComponents\n      (fun X =>\n        (@StructuredArrow.isoMk _ _ _ _ _ _ (StructuredArrow.mk (unop X).Hom) (unop X) (Iso.refl _)\n            (by tidy)).op)\n      fun X Y f => Quiver.Hom.unop_inj <| by ext; dsimp; simp)\n    (NatIso.ofComponents\n      (fun X =>\n        @CostructuredArrow.isoMk _ _ _ _ _ _ (CostructuredArrow.mk X.Hom) X (Iso.refl _) (by tidy))\n      fun X Y f => by ext; dsimp; simp)\n#align category_theory.structured_arrow_op_equivalence CategoryTheory.structuredArrowOpEquivalence\n\n/- warning: category_theory.costructured_arrow_op_equivalence -> CategoryTheory.costructuredArrowOpEquivalence is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (d : D), CategoryTheory.Equivalence.{max u1 u2, max u2 u1, max u3 u2, max u3 u2} (Opposite.{succ (max u3 u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 F d)) (CategoryTheory.Category.opposite.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 F d) (CategoryTheory.CostructuredArrow.category.{u2, u4, u3, u1} C _inst_1 D _inst_2 F d)) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (Opposite.op.{succ u4} D d) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F)) (CategoryTheory.StructuredArrow.category.{u2, u4, u3, u1} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (Opposite.op.{succ u4} D d) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (d : D), CategoryTheory.Equivalence.{max u1 u2, max u1 u2, max u3 u2, max u3 u2} (Opposite.{succ (max u3 u2)} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 F d)) (CategoryTheory.StructuredArrow.{u1, u2, u3, u4} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (Opposite.op.{succ u4} D d) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F)) (CategoryTheory.Category.opposite.{max u1 u2, max u3 u2} (CategoryTheory.CostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 F d) (CategoryTheory.instCategoryCostructuredArrow.{u1, u2, u3, u4} C _inst_1 D _inst_2 F d)) (CategoryTheory.instCategoryStructuredArrow.{u1, u2, u3, u4} (Opposite.{succ u3} C) (CategoryTheory.Category.opposite.{u1, u3} C _inst_1) (Opposite.{succ u4} D) (CategoryTheory.Category.opposite.{u2, u4} D _inst_2) (Opposite.op.{succ u4} D d) (CategoryTheory.Functor.op.{u1, u2, u3, u4} C _inst_1 D _inst_2 F))\nCase conversion may be inaccurate. Consider using '#align category_theory.costructured_arrow_op_equivalence CategoryTheory.costructuredArrowOpEquivalenceₓ'. -/\n/-- For a functor `F : C ⥤ D` and an object `d : D`, the category of costructured arrows\n`F.obj c ⟶ d` is contravariantly equivalent to the category of structured arrows\n`op d ⟶ F.op.obj c`.\n-/\ndef costructuredArrowOpEquivalence (F : C ⥤ D) (d : D) :\n    (CostructuredArrow F d)ᵒᵖ ≌ StructuredArrow (op d) F.op :=\n  Equivalence.mk (CostructuredArrow.toStructuredArrow F d)\n    (StructuredArrow.toCostructuredArrow' F d).rightOp\n    (NatIso.ofComponents\n      (fun X =>\n        (@CostructuredArrow.isoMk _ _ _ _ _ _ (CostructuredArrow.mk (unop X).Hom) (unop X)\n            (Iso.refl _) (by tidy)).op)\n      fun X Y f => Quiver.Hom.unop_inj <| by ext; dsimp; simp)\n    (NatIso.ofComponents\n      (fun X =>\n        @StructuredArrow.isoMk _ _ _ _ _ _ (StructuredArrow.mk X.Hom) X (Iso.refl _) (by tidy))\n      fun X Y f => by ext; dsimp; simp)\n#align category_theory.costructured_arrow_op_equivalence CategoryTheory.costructuredArrowOpEquivalence\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/StructuredArrow.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6791787121629465, "lm_q1q2_score": 0.4985983548537378}}
{"text": "import tactic.move_add\nimport data.list.of_fn\nimport algebra.group.pi\n\nvariables {R : Type*} [add_comm_semigroup R] {a b c d e f g h : R}\n\nexample (e f g : R) (h : a + b + c = d) : b + (a + c) = d :=\nbegin\n  success_if_fail_with_msg {move_add [d] at *} \"'d' is an unused variable\",\n  move_add at *,\n  success_if_fail_with_msg {move_add at *} \"nothing changed\",\n  success_if_fail_with_msg {move_add [a, e, f, g] at h a b c ⊢}\n    \"'[a, b, c]' did not change\\n'[e, f, g]' are unused variables\",\n  success_if_fail_with_msg {move_add [a, e, f, g] at h ⊢} \"'[e, f, g]' are unused variables\",\n  success_if_fail_with_msg {move_add at ⊢ h} \"Goal did not change\\n'[h]' did not change\",\n  move_add ← a at *,  -- `move_add` closes the goal, since, after rearranging, it tries `assumption`\nend\n\nexample {R : Type*} [comm_semigroup R] (a b c d e f g : R) (h : a * b * c = d) : b * (a * c) = d :=\nbegin\n  success_if_fail_with_msg {move_mul [d] at *} \"'d' is an unused variable\",\n  move_mul at *,\n  success_if_fail_with_msg {move_mul at *} \"nothing changed\",\n  success_if_fail_with_msg {move_mul [a, e, f, g] at h a b c ⊢}\n    \"'[a, b, c]' did not change\\n'[e, f, g]' are unused variables\",\n  success_if_fail_with_msg {move_mul [a, e, f, g] at h ⊢} \"'[e, f, g]' are unused variables\",\n  success_if_fail_with_msg {move_mul at ⊢ h} \"Goal did not change\\n'[h]' did not change\",\n  success_if_fail_with_msg {move_mul at ⊢} \"Goal did not change\",\n  move_mul ← a at *,  -- `move_mul` closes the goal, since, after rearranging, it tries `assumption`\nend\n\nexample : let k := c + (a + b) in k = a + b + c :=\nbegin\n  move_add [← a, c],\n  simp only,\nend\n\nexample (n : ℕ) : list.of_fn (λ i : fin (n + 3), (i : ℕ)) = list.of_fn (λ i : fin (3 + n), i) :=\nbegin\n  move_add [←n],\nend\n\nexample (a b : ℕ) : a + max a b = max b a + a :=\nbegin\n  move_oper [max] ← a at *,\n  move_oper [(+)] a at *,\nend\n\nexample (h : b + a = b + c + a) : a + b = a + b + c :=\nby move_add [a]\n\nexample {R : Type*} [comm_semigroup R] {a b : R} :\n  ∀ x : R, ∃ y : R, a * x * b * y = x * y * b * a :=\nby { move_mul [a, b], exact λ x, ⟨x, rfl⟩ }\n\nexample {R : Type*} [has_add R] [comm_semigroup R] {a b c d e f g : R} :\n  a * (b * c * a) * ((d * e) * e) * f * g = (c * b * a) * (e * (e * d)) * g * f * a :=\nby move_mul [a, a, b, c, d, e, f]\n\nexample [has_mul R] [has_neg R] : a + (b + c + a) * (- (d + e) + e) + f + g =\n  (c + b + a) * (e + - (e + d)) + g + f + a :=\nby move_add [b, d, g, f, a, e]\n\nexample (h : d + b + a = b + a → d + c + a = c + a) : a + d + b = b + a → d + c + a = a + c :=\nby move_add [a]\n\nexample [decidable_eq R] : if b + a = c + a then a + b = c + a else a + b ≠ c + a :=\nbegin\n  move_add [← a],\n  split_ifs; exact h,\nend\n\nexample (r : R → R → Prop) (h : r (a + b) (c + b + a)) : r (a + b) (a + b + c) :=\nby move_add [a, b, c] at h\n\nexample (h : a + c + b = a + d + b) : c + b + a = b + a + d :=\nby move_add [← a, b]  -- Goal before `exact h`: `a + c + b = a + d + b`\n\nexample [has_mul R] (h : a * c + c + b * c = a * d + d + b * d) :\n  c + b * c + a * c = a * d + d + b * d :=\nbegin\n  -- the first input `_ * c` unifies with `b * c` and moves to the right\n  -- the second input `_ * c` unifies with `a * c` and moves to the left\n  move_add [_ * c, ← _ * c], -- Goal before `exact h`: `a * c + c + b * c = a * d + d + b * d`\nend\n\nvariables [has_mul R] [has_one R] {X r s t u : R} (C D E : R → R)\n\nexample (he : E (C r * D X + D X * h + 7 + 42 + f) = C r * D X + h * D X + 7 + 42 + g) :\n  E (7 + f + (C r * D X + 42) + D X * h) = C r * D X + h * D X + g + 7 + 42 :=\nbegin\n  -- move `7, 42, f, g` to the right of their respective sides\n  move_add [(7 : R), (42 : R), f, g],\nend\n\nexample : true :=\nbegin\n  letI iacs : ∀ i, add_comm_semigroup (fin i → ℕ) := λ i, by apply_instance,\n  letI ia : ∀ i, has_add (fin i → ℕ) := λ i,\n    @add_semigroup.to_has_add _\n    (@add_comm_semigroup.to_add_semigroup _ (iacs i)),\n  -- move_add should work if there are unified metavariables\n  have : ∀ (a b : fin _ → ℕ), @has_add.add _ (ia _) a b = @has_add.add _ (ia _) b a,\n  { intros a b,\n    move_add [a] },\n  trivial, -- close the outer goal\n  exact 37 -- resolve the metavariable\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/move_add.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4985983492701425}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Oliver Nash\n\n! This file was ported from Lean 3 source module data.finset.prod\n! leanprover-community/mathlib commit e04043d6bf7264a3c84bc69711dc354958ca4516\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.Card\n\n/-!\n# Finsets in product types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines finset constructions on the product type `α × β`. Beware not to confuse with the\n`finset.prod` operation which computes the multiplicative product.\n\n## Main declarations\n\n* `finset.product`: Turns `s : finset α`, `t : finset β` into their product in `finset (α × β)`.\n* `finset.diag`: For `s : finset α`, `s.diag` is the `finset (α × α)` of pairs `(a, a)` with\n  `a ∈ s`.\n* `finset.off_diag`: For `s : finset α`, `s.off_diag` is the `finset (α × α)` of pairs `(a, b)` with\n  `a, b ∈ s` and `a ≠ b`.\n-/\n\n\nopen Multiset\n\nvariable {α β γ : Type _}\n\nnamespace Finset\n\n/-! ### prod -/\n\n\nsection Prod\n\nvariable {s s' : Finset α} {t t' : Finset β} {a : α} {b : β}\n\n#print Finset.product /-\n/-- `product s t` is the set of pairs `(a, b)` such that `a ∈ s` and `b ∈ t`. -/\nprotected def product (s : Finset α) (t : Finset β) : Finset (α × β) :=\n  ⟨_, s.Nodup.product t.Nodup⟩\n#align finset.product Finset.product\n-/\n\n-- mathport name: finset.product\ninfixr:82\n  \" ×ˢ \" =>-- This notation binds more strongly than (pre)images, unions and intersections.\n  Finset.product\n\n/- warning: finset.product_val -> Finset.product_val is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, Eq.{succ (max u1 u2)} (Multiset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.val.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t)) (Multiset.product.{u1, u2} α β (Finset.val.{u1} α s) (Finset.val.{u2} β t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β}, Eq.{max (succ u2) (succ u1)} (Multiset.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.val.{max u2 u1} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) (Multiset.product.{u2, u1} α β (Finset.val.{u2} α s) (Finset.val.{u1} β t))\nCase conversion may be inaccurate. Consider using '#align finset.product_val Finset.product_valₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem product_val : (s ×ˢ t).1 = s.1 ×ˢ t.1 :=\n  rfl\n#align finset.product_val Finset.product_val\n\n/- warning: finset.mem_product -> Finset.mem_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} {p : Prod.{u1, u2} α β}, Iff (Membership.Mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasMem.{max u1 u2} (Prod.{u1, u2} α β)) p (Finset.product.{u1, u2} α β s t)) (And (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) (Prod.fst.{u1, u2} α β p) s) (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) (Prod.snd.{u1, u2} α β p) t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} {p : Prod.{u2, u1} α β}, Iff (Membership.mem.{max u2 u1, max u1 u2} (Prod.{u2, u1} α β) (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instMembershipFinset.{max u2 u1} (Prod.{u2, u1} α β)) p (Finset.product.{u2, u1} α β s t)) (And (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) (Prod.fst.{u2, u1} α β p) s) (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) (Prod.snd.{u2, u1} α β p) t))\nCase conversion may be inaccurate. Consider using '#align finset.mem_product Finset.mem_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem mem_product {p : α × β} : p ∈ s ×ˢ t ↔ p.1 ∈ s ∧ p.2 ∈ t :=\n  mem_product\n#align finset.mem_product Finset.mem_product\n\n/- warning: finset.mk_mem_product -> Finset.mk_mem_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} {a : α} {b : β}, (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) b t) -> (Membership.Mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasMem.{max u1 u2} (Prod.{u1, u2} α β)) (Prod.mk.{u1, u2} α β a b) (Finset.product.{u1, u2} α β s t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} {a : α} {b : β}, (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a s) -> (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) b t) -> (Membership.mem.{max u1 u2, max u1 u2} (Prod.{u2, u1} α β) (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instMembershipFinset.{max u2 u1} (Prod.{u2, u1} α β)) (Prod.mk.{u2, u1} α β a b) (Finset.product.{u2, u1} α β s t))\nCase conversion may be inaccurate. Consider using '#align finset.mk_mem_product Finset.mk_mem_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem mk_mem_product (ha : a ∈ s) (hb : b ∈ t) : (a, b) ∈ s ×ˢ t :=\n  mem_product.2 ⟨ha, hb⟩\n#align finset.mk_mem_product Finset.mk_mem_product\n\n/- warning: finset.coe_product -> Finset.coe_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ (max u1 u2)} (Set.{max u1 u2} (Prod.{u1, u2} α β)) ((fun (a : Type.{max u1 u2}) (b : Type.{max u1 u2}) [self : HasLiftT.{succ (max u1 u2), succ (max u1 u2)} a b] => self.0) (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Set.{max u1 u2} (Prod.{u1, u2} α β)) (HasLiftT.mk.{succ (max u1 u2), succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Set.{max u1 u2} (Prod.{u1, u2} α β)) (CoeTCₓ.coe.{succ (max u1 u2), succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Set.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.Set.hasCoeT.{max u1 u2} (Prod.{u1, u2} α β)))) (Finset.product.{u1, u2} α β s t)) (Set.prod.{u1, u2} α β ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) s) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} β) (Set.{u2} β) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (Finset.Set.hasCoeT.{u2} β))) t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (s : Finset.{u2} α) (t : Finset.{u1} β), Eq.{max (succ u2) (succ u1)} (Set.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.toSet.{max u2 u1} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) (Set.prod.{u2, u1} α β (Finset.toSet.{u2} α s) (Finset.toSet.{u1} β t))\nCase conversion may be inaccurate. Consider using '#align finset.coe_product Finset.coe_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp, norm_cast]\ntheorem coe_product (s : Finset α) (t : Finset β) : (↑(s ×ˢ t) : Set (α × β)) = s ×ˢ t :=\n  Set.ext fun x => Finset.mem_product\n#align finset.coe_product Finset.coe_product\n\n/- warning: finset.subset_product_image_fst -> Finset.subset_product_image_fst is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} [_inst_1 : DecidableEq.{succ u1} α], HasSubset.Subset.{u1} (Finset.{u1} α) (Finset.hasSubset.{u1} α) (Finset.image.{max u1 u2, u1} (Prod.{u1, u2} α β) α (fun (a : α) (b : α) => _inst_1 a b) (Prod.fst.{u1, u2} α β) (Finset.product.{u1, u2} α β s t)) s\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} [_inst_1 : DecidableEq.{succ u2} α], HasSubset.Subset.{u2} (Finset.{u2} α) (Finset.instHasSubsetFinset.{u2} α) (Finset.image.{max u1 u2, u2} (Prod.{u2, u1} α β) α (fun (a : α) (b : α) => _inst_1 a b) (Prod.fst.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) s\nCase conversion may be inaccurate. Consider using '#align finset.subset_product_image_fst Finset.subset_product_image_fstₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem subset_product_image_fst [DecidableEq α] : (s ×ˢ t).image Prod.fst ⊆ s := fun i => by\n  simp (config := { contextual := true }) [mem_image]\n#align finset.subset_product_image_fst Finset.subset_product_image_fst\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.subset_product_image_snd /-\ntheorem subset_product_image_snd [DecidableEq β] : (s ×ˢ t).image Prod.snd ⊆ t := fun i => by\n  simp (config := { contextual := true }) [mem_image]\n#align finset.subset_product_image_snd Finset.subset_product_image_snd\n-/\n\n/- warning: finset.product_image_fst -> Finset.product_image_fst is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} [_inst_1 : DecidableEq.{succ u1} α], (Finset.Nonempty.{u2} β t) -> (Eq.{succ u1} (Finset.{u1} α) (Finset.image.{max u1 u2, u1} (Prod.{u1, u2} α β) α (fun (a : α) (b : α) => _inst_1 a b) (Prod.fst.{u1, u2} α β) (Finset.product.{u1, u2} α β s t)) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} [_inst_1 : DecidableEq.{succ u2} α], (Finset.Nonempty.{u1} β t) -> (Eq.{succ u2} (Finset.{u2} α) (Finset.image.{max u1 u2, u2} (Prod.{u2, u1} α β) α (fun (a : α) (b : α) => _inst_1 a b) (Prod.fst.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_image_fst Finset.product_image_fstₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_image_fst [DecidableEq α] (ht : t.Nonempty) : (s ×ˢ t).image Prod.fst = s :=\n  by\n  ext i\n  simp [mem_image, ht.bex]\n#align finset.product_image_fst Finset.product_image_fst\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.product_image_snd /-\ntheorem product_image_snd [DecidableEq β] (ht : s.Nonempty) : (s ×ˢ t).image Prod.snd = t :=\n  by\n  ext i\n  simp [mem_image, ht.bex]\n#align finset.product_image_snd Finset.product_image_snd\n-/\n\n/- warning: finset.subset_product -> Finset.subset_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] {s : Finset.{max u1 u2} (Prod.{u1, u2} α β)}, HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasSubset.{max u1 u2} (Prod.{u1, u2} α β)) s (Finset.product.{u1, u2} α β (Finset.image.{max u1 u2, u1} (Prod.{u1, u2} α β) α (fun (a : α) (b : α) => _inst_1 a b) (Prod.fst.{u1, u2} α β) s) (Finset.image.{max u1 u2, u2} (Prod.{u1, u2} α β) β (fun (a : β) (b : β) => _inst_2 a b) (Prod.snd.{u1, u2} α β) s))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β] {s : Finset.{max u1 u2} (Prod.{u2, u1} α β)}, HasSubset.Subset.{max u2 u1} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instHasSubsetFinset.{max u2 u1} (Prod.{u2, u1} α β)) s (Finset.product.{u2, u1} α β (Finset.image.{max u1 u2, u2} (Prod.{u2, u1} α β) α (fun (a : α) (b : α) => _inst_1 a b) (Prod.fst.{u2, u1} α β) s) (Finset.image.{max u1 u2, u1} (Prod.{u2, u1} α β) β (fun (a : β) (b : β) => _inst_2 a b) (Prod.snd.{u2, u1} α β) s))\nCase conversion may be inaccurate. Consider using '#align finset.subset_product Finset.subset_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem subset_product [DecidableEq α] [DecidableEq β] {s : Finset (α × β)} :\n    s ⊆ s.image Prod.fst ×ˢ s.image Prod.snd := fun p hp =>\n  mem_product.2 ⟨mem_image_of_mem _ hp, mem_image_of_mem _ hp⟩\n#align finset.subset_product Finset.subset_product\n\n/- warning: finset.product_subset_product -> Finset.product_subset_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β}, (HasSubset.Subset.{u1} (Finset.{u1} α) (Finset.hasSubset.{u1} α) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} β) (Finset.hasSubset.{u2} β) t t') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasSubset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t'))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {s' : Finset.{u2} α} {t : Finset.{u1} β} {t' : Finset.{u1} β}, (HasSubset.Subset.{u2} (Finset.{u2} α) (Finset.instHasSubsetFinset.{u2} α) s s') -> (HasSubset.Subset.{u1} (Finset.{u1} β) (Finset.instHasSubsetFinset.{u1} β) t t') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instHasSubsetFinset.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s' t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_subset_product Finset.product_subset_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_subset_product (hs : s ⊆ s') (ht : t ⊆ t') : s ×ˢ t ⊆ s' ×ˢ t' := fun ⟨x, y⟩ h =>\n  mem_product.2 ⟨hs (mem_product.1 h).1, ht (mem_product.1 h).2⟩\n#align finset.product_subset_product Finset.product_subset_product\n\n/- warning: finset.product_subset_product_left -> Finset.product_subset_product_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β}, (HasSubset.Subset.{u1} (Finset.{u1} α) (Finset.hasSubset.{u1} α) s s') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasSubset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {s' : Finset.{u2} α} {t : Finset.{u1} β}, (HasSubset.Subset.{u2} (Finset.{u2} α) (Finset.instHasSubsetFinset.{u2} α) s s') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instHasSubsetFinset.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s' t))\nCase conversion may be inaccurate. Consider using '#align finset.product_subset_product_left Finset.product_subset_product_leftₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_subset_product_left (hs : s ⊆ s') : s ×ˢ t ⊆ s' ×ˢ t :=\n  product_subset_product hs (Subset.refl _)\n#align finset.product_subset_product_left Finset.product_subset_product_left\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.product_subset_product_right /-\ntheorem product_subset_product_right (ht : t ⊆ t') : s ×ˢ t ⊆ s ×ˢ t' :=\n  product_subset_product (Subset.refl _) ht\n#align finset.product_subset_product_right Finset.product_subset_product_right\n-/\n\n/- warning: finset.map_swap_product -> Finset.map_swap_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.map.{max u2 u1, max u1 u2} (Prod.{u2, u1} β α) (Prod.{u1, u2} α β) (Function.Embedding.mk.{succ (max u2 u1), succ (max u1 u2)} (Prod.{u2, u1} β α) (Prod.{u1, u2} α β) (Prod.swap.{u2, u1} β α) (Prod.swap_injective.{u2, u1} β α)) (Finset.product.{u2, u1} β α t s)) (Finset.product.{u1, u2} α β s t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (s : Finset.{u2} α) (t : Finset.{u1} β), Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.map.{max u2 u1, max u2 u1} (Prod.{u1, u2} β α) (Prod.{u2, u1} α β) (Function.Embedding.mk.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u1, u2} β α) (Prod.{u2, u1} α β) (Prod.swap.{u1, u2} β α) (Prod.swap_injective.{u2, u1} β α)) (Finset.product.{u1, u2} β α t s)) (Finset.product.{u2, u1} α β s t)\nCase conversion may be inaccurate. Consider using '#align finset.map_swap_product Finset.map_swap_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem map_swap_product (s : Finset α) (t : Finset β) :\n    (t ×ˢ s).map ⟨Prod.swap, Prod.swap_injective⟩ = s ×ˢ t :=\n  coe_injective <| by\n    push_cast\n    exact Set.image_swap_prod _ _\n#align finset.map_swap_product Finset.map_swap_product\n\n/- warning: finset.image_swap_product -> Finset.image_swap_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.image.{max u2 u1, max u1 u2} (Prod.{u2, u1} β α) (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b) (Prod.swap.{u2, u1} β α) (Finset.product.{u2, u1} β α t s)) (Finset.product.{u1, u2} α β s t)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{max (succ u2) (succ u1)} (Prod.{u1, u2} α β)] (_inst_2 : Finset.{u1} α) (s : Finset.{u2} β), Eq.{max (succ u1) (succ u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.image.{max u1 u2, max u1 u2} (Prod.{u2, u1} β α) (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => _inst_1 a b) (Prod.swap.{u2, u1} β α) (Finset.product.{u2, u1} β α s _inst_2)) (Finset.product.{u1, u2} α β _inst_2 s)\nCase conversion may be inaccurate. Consider using '#align finset.image_swap_product Finset.image_swap_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem image_swap_product [DecidableEq α] [DecidableEq β] (s : Finset α) (t : Finset β) :\n    (t ×ˢ s).image Prod.swap = s ×ˢ t :=\n  coe_injective <| by\n    push_cast\n    exact Set.image_swap_prod _ _\n#align finset.image_swap_product Finset.image_swap_product\n\n/- warning: finset.product_eq_bUnion -> Finset.product_eq_bunionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.bunionᵢ.{u1, max u1 u2} α (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b) s (fun (a : α) => Finset.image.{u2, max u1 u2} β (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b) (fun (b : β) => Prod.mk.{u1, u2} α β a b) t))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{max (succ u2) (succ u1)} (Prod.{u1, u2} α β)] (_inst_2 : Finset.{u1} α) (s : Finset.{u2} β), Eq.{max (succ u1) (succ u2)} (Finset.{max u2 u1} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β _inst_2 s) (Finset.bunionᵢ.{u1, max u2 u1} α (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => _inst_1 a b) _inst_2 (fun (a : α) => Finset.image.{u2, max u2 u1} β (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => _inst_1 a b) (fun (b : β) => Prod.mk.{u1, u2} α β a b) s))\nCase conversion may be inaccurate. Consider using '#align finset.product_eq_bUnion Finset.product_eq_bunionᵢₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_eq_bunionᵢ [DecidableEq α] [DecidableEq β] (s : Finset α) (t : Finset β) :\n    s ×ˢ t = s.bunionᵢ fun a => t.image fun b => (a, b) :=\n  ext fun ⟨x, y⟩ => by\n    simp only [mem_product, mem_bUnion, mem_image, exists_prop, Prod.mk.inj_iff, and_left_comm,\n      exists_and_left, exists_eq_right, exists_eq_left]\n#align finset.product_eq_bUnion Finset.product_eq_bunionᵢ\n\n/- warning: finset.product_eq_bUnion_right -> Finset.product_eq_bunionᵢ_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.bunionᵢ.{u2, max u1 u2} β (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b) t (fun (b : β) => Finset.image.{u1, max u1 u2} α (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b) (fun (a : α) => Prod.mk.{u1, u2} α β a b) s))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{max (succ u2) (succ u1)} (Prod.{u1, u2} α β)] (_inst_2 : Finset.{u1} α) (s : Finset.{u2} β), Eq.{max (succ u1) (succ u2)} (Finset.{max u2 u1} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β _inst_2 s) (Finset.bunionᵢ.{u2, max u2 u1} β (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => _inst_1 a b) s (fun (b : β) => Finset.image.{u1, max u2 u1} α (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => _inst_1 a b) (fun (a : α) => Prod.mk.{u1, u2} α β a b) _inst_2))\nCase conversion may be inaccurate. Consider using '#align finset.product_eq_bUnion_right Finset.product_eq_bunionᵢ_rightₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_eq_bunionᵢ_right [DecidableEq α] [DecidableEq β] (s : Finset α) (t : Finset β) :\n    s ×ˢ t = t.bunionᵢ fun b => s.image fun a => (a, b) :=\n  ext fun ⟨x, y⟩ => by\n    simp only [mem_product, mem_bUnion, mem_image, exists_prop, Prod.mk.inj_iff, and_left_comm,\n      exists_and_left, exists_eq_right, exists_eq_left]\n#align finset.product_eq_bUnion_right Finset.product_eq_bunionᵢ_right\n\n/- warning: finset.product_bUnion -> Finset.product_bunionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} γ] (s : Finset.{u1} α) (t : Finset.{u2} β) (f : (Prod.{u1, u2} α β) -> (Finset.{u3} γ)), Eq.{succ u3} (Finset.{u3} γ) (Finset.bunionᵢ.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (fun (a : γ) (b : γ) => _inst_1 a b) (Finset.product.{u1, u2} α β s t) f) (Finset.bunionᵢ.{u1, u3} α γ (fun (a : γ) (b : γ) => _inst_1 a b) s (fun (a : α) => Finset.bunionᵢ.{u2, u3} β γ (fun (a : γ) (b : γ) => _inst_1 a b) t (fun (b : β) => f (Prod.mk.{u1, u2} α β a b))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} γ] (s : Finset.{u2} α) (t : Finset.{u1} β) (f : (Prod.{u2, u1} α β) -> (Finset.{u3} γ)), Eq.{succ u3} (Finset.{u3} γ) (Finset.bunionᵢ.{max u2 u1, u3} (Prod.{u2, u1} α β) γ (fun (a : γ) (b : γ) => _inst_1 a b) (Finset.product.{u2, u1} α β s t) f) (Finset.bunionᵢ.{u2, u3} α γ (fun (a : γ) (b : γ) => _inst_1 a b) s (fun (a : α) => Finset.bunionᵢ.{u1, u3} β γ (fun (a : γ) (b : γ) => _inst_1 a b) t (fun (b : β) => f (Prod.mk.{u2, u1} α β a b))))\nCase conversion may be inaccurate. Consider using '#align finset.product_bUnion Finset.product_bunionᵢₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- See also `finset.sup_product_left`. -/\n@[simp]\ntheorem product_bunionᵢ [DecidableEq γ] (s : Finset α) (t : Finset β) (f : α × β → Finset γ) :\n    (s ×ˢ t).bunionᵢ f = s.bunionᵢ fun a => t.bunionᵢ fun b => f (a, b) := by\n  classical simp_rw [product_eq_bUnion, bUnion_bUnion, image_bUnion]\n#align finset.product_bUnion Finset.product_bunionᵢ\n\n/- warning: finset.card_product -> Finset.card_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{1} Nat (Finset.card.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} α s) (Finset.card.{u2} β t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (s : Finset.{u2} α) (t : Finset.{u1} β), Eq.{1} Nat (Finset.card.{max u1 u2} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u2} α s) (Finset.card.{u1} β t))\nCase conversion may be inaccurate. Consider using '#align finset.card_product Finset.card_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem card_product (s : Finset α) (t : Finset β) : card (s ×ˢ t) = card s * card t :=\n  Multiset.card_product _ _\n#align finset.card_product Finset.card_product\n\n/- warning: finset.filter_product -> Finset.filter_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} (p : α -> Prop) (q : β -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] [_inst_2 : DecidablePred.{succ u2} β q], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.filter.{max u1 u2} (Prod.{u1, u2} α β) (fun (x : Prod.{u1, u2} α β) => And (p (Prod.fst.{u1, u2} α β x)) (q (Prod.snd.{u1, u2} α β x))) (fun (a : Prod.{u1, u2} α β) => And.decidable (p (Prod.fst.{u1, u2} α β a)) (q (Prod.snd.{u1, u2} α β a)) (_inst_1 (Prod.fst.{u1, u2} α β a)) (_inst_2 (Prod.snd.{u1, u2} α β a))) (Finset.product.{u1, u2} α β s t)) (Finset.product.{u1, u2} α β (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s) (Finset.filter.{u2} β q (fun (a : β) => _inst_2 a) t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} (p : α -> Prop) (q : β -> Prop) [_inst_1 : DecidablePred.{succ u2} α p] [_inst_2 : DecidablePred.{succ u1} β q], Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.filter.{max u2 u1} (Prod.{u2, u1} α β) (fun (x : Prod.{u2, u1} α β) => And (p (Prod.fst.{u2, u1} α β x)) (q (Prod.snd.{u2, u1} α β x))) (fun (a : Prod.{u2, u1} α β) => instDecidableAnd (p (Prod.fst.{u2, u1} α β a)) (q (Prod.snd.{u2, u1} α β a)) (_inst_1 (Prod.fst.{u2, u1} α β a)) (_inst_2 (Prod.snd.{u2, u1} α β a))) (Finset.product.{u2, u1} α β s t)) (Finset.product.{u2, u1} α β (Finset.filter.{u2} α p (fun (a : α) => _inst_1 a) s) (Finset.filter.{u1} β q (fun (a : β) => _inst_2 a) t))\nCase conversion may be inaccurate. Consider using '#align finset.filter_product Finset.filter_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem filter_product (p : α → Prop) (q : β → Prop) [DecidablePred p] [DecidablePred q] :\n    ((s ×ˢ t).filterₓ fun x : α × β => p x.1 ∧ q x.2) = s.filterₓ p ×ˢ t.filterₓ q :=\n  by\n  ext ⟨a, b⟩\n  simp only [mem_filter, mem_product]\n  exact and_and_and_comm (a ∈ s) (b ∈ t) (p a) (q b)\n#align finset.filter_product Finset.filter_product\n\n/- warning: finset.filter_product_left -> Finset.filter_product_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.filter.{max u1 u2} (Prod.{u1, u2} α β) (fun (x : Prod.{u1, u2} α β) => p (Prod.fst.{u1, u2} α β x)) (fun (a : Prod.{u1, u2} α β) => _inst_1 (Prod.fst.{u1, u2} α β a)) (Finset.product.{u1, u2} α β s t)) (Finset.product.{u1, u2} α β (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s) t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u2} α p], Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.filter.{max u2 u1} (Prod.{u2, u1} α β) (fun (x : Prod.{u2, u1} α β) => p (Prod.fst.{u2, u1} α β x)) (fun (a : Prod.{u2, u1} α β) => _inst_1 (Prod.fst.{u2, u1} α β a)) (Finset.product.{u2, u1} α β s t)) (Finset.product.{u2, u1} α β (Finset.filter.{u2} α p (fun (a : α) => _inst_1 a) s) t)\nCase conversion may be inaccurate. Consider using '#align finset.filter_product_left Finset.filter_product_leftₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem filter_product_left (p : α → Prop) [DecidablePred p] :\n    ((s ×ˢ t).filterₓ fun x : α × β => p x.1) = s.filterₓ p ×ˢ t := by\n  simpa using filter_product p fun _ => True\n#align finset.filter_product_left Finset.filter_product_left\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.filter_product_right /-\ntheorem filter_product_right (q : β → Prop) [DecidablePred q] :\n    ((s ×ˢ t).filterₓ fun x : α × β => q x.2) = s ×ˢ t.filterₓ q := by\n  simpa using filter_product (fun _ : α => True) q\n#align finset.filter_product_right Finset.filter_product_right\n-/\n\n/- warning: finset.filter_product_card -> Finset.filter_product_card is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (s : Finset.{u1} α) (t : Finset.{u2} β) (p : α -> Prop) (q : β -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] [_inst_2 : DecidablePred.{succ u2} β q], Eq.{1} Nat (Finset.card.{max u1 u2} (Prod.{u1, u2} α β) (Finset.filter.{max u1 u2} (Prod.{u1, u2} α β) (fun (x : Prod.{u1, u2} α β) => Iff (p (Prod.fst.{u1, u2} α β x)) (q (Prod.snd.{u1, u2} α β x))) (fun (a : Prod.{u1, u2} α β) => Iff.decidable (p (Prod.fst.{u1, u2} α β a)) (q (Prod.snd.{u1, u2} α β a)) (_inst_1 (Prod.fst.{u1, u2} α β a)) (_inst_2 (Prod.snd.{u1, u2} α β a))) (Finset.product.{u1, u2} α β s t))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} α (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s)) (Finset.card.{u2} β (Finset.filter.{u2} β q (fun (a : β) => _inst_2 a) t))) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} α (Finset.filter.{u1} α (Function.comp.{succ u1, 1, 1} α Prop Prop Not p) (fun (a : α) => Not.decidable (p a) (_inst_1 a)) s)) (Finset.card.{u2} β (Finset.filter.{u2} β (Function.comp.{succ u2, 1, 1} β Prop Prop Not q) (fun (a : β) => Not.decidable (q a) (_inst_2 a)) t))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (s : Finset.{u2} α) (t : Finset.{u1} β) (p : α -> Prop) (q : β -> Prop) [_inst_1 : DecidablePred.{succ u2} α p] [_inst_2 : DecidablePred.{succ u1} β q], Eq.{1} Nat (Finset.card.{max u2 u1} (Prod.{u2, u1} α β) (Finset.filter.{max u2 u1} (Prod.{u2, u1} α β) (fun (x : Prod.{u2, u1} α β) => Eq.{1} Prop (p (Prod.fst.{u2, u1} α β x)) (q (Prod.snd.{u2, u1} α β x))) (fun (a : Prod.{u2, u1} α β) => instDecidableEqProp (p (Prod.fst.{u2, u1} α β a)) (q (Prod.snd.{u2, u1} α β a)) (instDecidableIff (p (Prod.fst.{u2, u1} α β a)) (q (Prod.snd.{u2, u1} α β a)) (_inst_1 (Prod.fst.{u2, u1} α β a)) (_inst_2 (Prod.snd.{u2, u1} α β a)))) (Finset.product.{u2, u1} α β s t))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u2} α (Finset.filter.{u2} α p (fun (a : α) => _inst_1 a) s)) (Finset.card.{u1} β (Finset.filter.{u1} β q (fun (a : β) => _inst_2 a) t))) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u2} α (Finset.filter.{u2} α (fun (x._@.Mathlib.Data.Finset.Prod._hyg.1940 : α) => Not (p x._@.Mathlib.Data.Finset.Prod._hyg.1940)) (fun (a : α) => instDecidableNot (p a) (_inst_1 a)) s)) (Finset.card.{u1} β (Finset.filter.{u1} β (fun (x._@.Mathlib.Data.Finset.Prod._hyg.1956 : β) => Not (q x._@.Mathlib.Data.Finset.Prod._hyg.1956)) (fun (a : β) => instDecidableNot (q a) (_inst_2 a)) t))))\nCase conversion may be inaccurate. Consider using '#align finset.filter_product_card Finset.filter_product_cardₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem filter_product_card (s : Finset α) (t : Finset β) (p : α → Prop) (q : β → Prop)\n    [DecidablePred p] [DecidablePred q] :\n    ((s ×ˢ t).filterₓ fun x : α × β => p x.1 ↔ q x.2).card =\n      (s.filterₓ p).card * (t.filterₓ q).card +\n        (s.filterₓ (Not ∘ p)).card * (t.filterₓ (Not ∘ q)).card :=\n  by\n  classical\n    rw [← card_product, ← card_product, ← filter_product, ← filter_product, ← card_union_eq]\n    · apply congr_arg\n      ext ⟨a, b⟩\n      simp only [filter_union_right, mem_filter, mem_product]\n      constructor <;> intro h <;> use h.1\n      simp only [Function.comp_apply, and_self_iff, h.2, em (q b)]\n      cases h.2 <;>\n        · try simp at h_1\n          simp [h_1]\n    · apply Finset.disjoint_filter_filter'\n      exact (disjoint_compl_right.inf_left _).inf_right _\n#align finset.filter_product_card Finset.filter_product_card\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.empty_product /-\ntheorem empty_product (t : Finset β) : (∅ : Finset α) ×ˢ t = ∅ :=\n  rfl\n#align finset.empty_product Finset.empty_product\n-/\n\n/- warning: finset.product_empty -> Finset.product_empty is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (s : Finset.{u1} α), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} β) (Finset.hasEmptyc.{u2} β))) (EmptyCollection.emptyCollection.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasEmptyc.{max u1 u2} (Prod.{u1, u2} α β)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (s : Finset.{u2} α), Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} β) (Finset.instEmptyCollectionFinset.{u1} β))) (EmptyCollection.emptyCollection.{max u2 u1} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instEmptyCollectionFinset.{max u2 u1} (Prod.{u2, u1} α β)))\nCase conversion may be inaccurate. Consider using '#align finset.product_empty Finset.product_emptyₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_empty (s : Finset α) : s ×ˢ (∅ : Finset β) = ∅ :=\n  eq_empty_of_forall_not_mem fun x h => (Finset.mem_product.1 h).2\n#align finset.product_empty Finset.product_empty\n\n/- warning: finset.nonempty.product -> Finset.Nonempty.product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, (Finset.Nonempty.{u1} α s) -> (Finset.Nonempty.{u2} β t) -> (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β}, (Finset.Nonempty.{u2} α s) -> (Finset.Nonempty.{u1} β t) -> (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t))\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.product Finset.Nonempty.productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Nonempty.product (hs : s.Nonempty) (ht : t.Nonempty) : (s ×ˢ t).Nonempty :=\n  let ⟨x, hx⟩ := hs\n  let ⟨y, hy⟩ := ht\n  ⟨(x, y), mem_product.2 ⟨hx, hy⟩⟩\n#align finset.nonempty.product Finset.Nonempty.product\n\n/- warning: finset.nonempty.fst -> Finset.Nonempty.fst is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t)) -> (Finset.Nonempty.{u1} α s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β}, (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) -> (Finset.Nonempty.{u2} α s)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.fst Finset.Nonempty.fstₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Nonempty.fst (h : (s ×ˢ t).Nonempty) : s.Nonempty :=\n  let ⟨xy, hxy⟩ := h\n  ⟨xy.1, (mem_product.1 hxy).1⟩\n#align finset.nonempty.fst Finset.Nonempty.fst\n\n/- warning: finset.nonempty.snd -> Finset.Nonempty.snd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t)) -> (Finset.Nonempty.{u2} β t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β}, (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) -> (Finset.Nonempty.{u1} β t)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.snd Finset.Nonempty.sndₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Nonempty.snd (h : (s ×ˢ t).Nonempty) : t.Nonempty :=\n  let ⟨xy, hxy⟩ := h\n  ⟨xy.2, (mem_product.1 hxy).2⟩\n#align finset.nonempty.snd Finset.Nonempty.snd\n\n/- warning: finset.nonempty_product -> Finset.nonempty_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, Iff (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t)) (And (Finset.Nonempty.{u1} α s) (Finset.Nonempty.{u2} β t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β}, Iff (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t)) (And (Finset.Nonempty.{u2} α s) (Finset.Nonempty.{u1} β t))\nCase conversion may be inaccurate. Consider using '#align finset.nonempty_product Finset.nonempty_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem nonempty_product : (s ×ˢ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty :=\n  ⟨fun h => ⟨h.fst, h.snd⟩, fun h => h.1.product h.2⟩\n#align finset.nonempty_product Finset.nonempty_product\n\n/- warning: finset.product_eq_empty -> Finset.product_eq_empty is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, Iff (Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (EmptyCollection.emptyCollection.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasEmptyc.{max u1 u2} (Prod.{u1, u2} α β)))) (Or (Eq.{succ u1} (Finset.{u1} α) s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} α) (Finset.hasEmptyc.{u1} α))) (Eq.{succ u2} (Finset.{u2} β) t (EmptyCollection.emptyCollection.{u2} (Finset.{u2} β) (Finset.hasEmptyc.{u2} β))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β}, Iff (Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s t) (EmptyCollection.emptyCollection.{max u2 u1} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instEmptyCollectionFinset.{max u2 u1} (Prod.{u2, u1} α β)))) (Or (Eq.{succ u2} (Finset.{u2} α) s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} α) (Finset.instEmptyCollectionFinset.{u2} α))) (Eq.{succ u1} (Finset.{u1} β) t (EmptyCollection.emptyCollection.{u1} (Finset.{u1} β) (Finset.instEmptyCollectionFinset.{u1} β))))\nCase conversion may be inaccurate. Consider using '#align finset.product_eq_empty Finset.product_eq_emptyₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem product_eq_empty {s : Finset α} {t : Finset β} : s ×ˢ t = ∅ ↔ s = ∅ ∨ t = ∅ := by\n  rw [← not_nonempty_iff_eq_empty, nonempty_product, not_and_or, not_nonempty_iff_eq_empty,\n    not_nonempty_iff_eq_empty]\n#align finset.product_eq_empty Finset.product_eq_empty\n\n/- warning: finset.singleton_product -> Finset.singleton_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {t : Finset.{u2} β} {a : α}, Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) t) (Finset.map.{u2, max u1 u2} β (Prod.{u1, u2} α β) (Function.Embedding.mk.{succ u2, succ (max u1 u2)} β (Prod.{u1, u2} α β) (Prod.mk.{u1, u2} α β a) (Prod.mk.inj_left.{u1, u2} α β a)) t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {t : Finset.{u1} β} {a : α}, Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β (Singleton.singleton.{u2, u2} α (Finset.{u2} α) (Finset.instSingletonFinset.{u2} α) a) t) (Finset.map.{u1, max u1 u2} β (Prod.{u2, u1} α β) (Function.Embedding.mk.{succ u1, succ (max u1 u2)} β (Prod.{u2, u1} α β) (Prod.mk.{u2, u1} α β a) (Prod.mk.inj_left.{u1, u2} α β a)) t)\nCase conversion may be inaccurate. Consider using '#align finset.singleton_product Finset.singleton_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem singleton_product {a : α} : ({a} : Finset α) ×ˢ t = t.map ⟨Prod.mk a, Prod.mk.inj_left _⟩ :=\n  by\n  ext ⟨x, y⟩\n  simp [and_left_comm, eq_comm]\n#align finset.singleton_product Finset.singleton_product\n\n/- warning: finset.product_singleton -> Finset.product_singleton is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {b : β}, Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b)) (Finset.map.{u1, max u1 u2} α (Prod.{u1, u2} α β) (Function.Embedding.mk.{succ u1, succ (max u1 u2)} α (Prod.{u1, u2} α β) (fun (i : α) => Prod.mk.{u1, u2} α β i b) (Prod.mk.inj_right.{u1, u2} α β b)) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {b : β}, Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b)) (Finset.map.{u2, max u1 u2} α (Prod.{u2, u1} α β) (Function.Embedding.mk.{succ u2, succ (max u1 u2)} α (Prod.{u2, u1} α β) (fun (i : α) => Prod.mk.{u2, u1} α β i b) (Prod.mk.inj_right.{u1, u2} α β b)) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_singleton Finset.product_singletonₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem product_singleton {b : β} : s ×ˢ {b} = s.map ⟨fun i => (i, b), Prod.mk.inj_right _⟩ :=\n  by\n  ext ⟨x, y⟩\n  simp [and_left_comm, eq_comm]\n#align finset.product_singleton Finset.product_singleton\n\n/- warning: finset.singleton_product_singleton -> Finset.singleton_product_singleton is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {a : α} {b : β}, Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b)) (Singleton.singleton.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasSingleton.{max u1 u2} (Prod.{u1, u2} α β)) (Prod.mk.{u1, u2} α β a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {a : α} {b : β}, Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β (Singleton.singleton.{u2, u2} α (Finset.{u2} α) (Finset.instSingletonFinset.{u2} α) a) (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b)) (Singleton.singleton.{max u1 u2, max u2 u1} (Prod.{u2, u1} α β) (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instSingletonFinset.{max u2 u1} (Prod.{u2, u1} α β)) (Prod.mk.{u2, u1} α β a b))\nCase conversion may be inaccurate. Consider using '#align finset.singleton_product_singleton Finset.singleton_product_singletonₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem singleton_product_singleton {a : α} {b : β} :\n    ({a} : Finset α) ×ˢ ({b} : Finset β) = {(a, b)} := by\n  simp only [product_singleton, Function.Embedding.coeFn_mk, map_singleton]\n#align finset.singleton_product_singleton Finset.singleton_product_singleton\n\n/- warning: finset.union_product -> Finset.union_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s s') t) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasUnion.{max u1 u2} (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {s' : Finset.{u2} α} {t : Finset.{u1} β} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β (Union.union.{u2} (Finset.{u2} α) (Finset.instUnionFinset.{u2} α (fun (a : α) (b : α) => _inst_1 a b)) s s') t) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instUnionFinset.{max u2 u1} (Prod.{u2, u1} α β) (fun (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β) => instDecidableEqProd.{u2, u1} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s' t))\nCase conversion may be inaccurate. Consider using '#align finset.union_product Finset.union_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem union_product [DecidableEq α] [DecidableEq β] : (s ∪ s') ×ˢ t = s ×ˢ t ∪ s' ×ˢ t :=\n  by\n  ext ⟨x, y⟩\n  simp only [or_and_right, mem_union, mem_product]\n#align finset.union_product Finset.union_product\n\n/- warning: finset.product_union -> Finset.product_union is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s (Union.union.{u2} (Finset.{u2} β) (Finset.hasUnion.{u2} β (fun (a : β) (b : β) => _inst_2 a b)) t t')) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasUnion.{max u1 u2} (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s t'))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} {t' : Finset.{u1} β} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s (Union.union.{u1} (Finset.{u1} β) (Finset.instUnionFinset.{u1} β (fun (a : β) (b : β) => _inst_2 a b)) t t')) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instUnionFinset.{max u2 u1} (Prod.{u2, u1} α β) (fun (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β) => instDecidableEqProd.{u2, u1} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_union Finset.product_unionₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem product_union [DecidableEq α] [DecidableEq β] : s ×ˢ (t ∪ t') = s ×ˢ t ∪ s ×ˢ t' :=\n  by\n  ext ⟨x, y⟩\n  simp only [and_or_left, mem_union, mem_product]\n#align finset.product_union Finset.product_union\n\n/- warning: finset.inter_product -> Finset.inter_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s s') t) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasInter.{max u1 u2} (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {s' : Finset.{u2} α} {t : Finset.{u1} β} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β (Inter.inter.{u2} (Finset.{u2} α) (Finset.instInterFinset.{u2} α (fun (a : α) (b : α) => _inst_1 a b)) s s') t) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instInterFinset.{max u2 u1} (Prod.{u2, u1} α β) (fun (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β) => instDecidableEqProd.{u2, u1} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s' t))\nCase conversion may be inaccurate. Consider using '#align finset.inter_product Finset.inter_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem inter_product [DecidableEq α] [DecidableEq β] : (s ∩ s') ×ˢ t = s ×ˢ t ∩ s' ×ˢ t :=\n  by\n  ext ⟨x, y⟩\n  simp only [← and_and_right, mem_inter, mem_product]\n#align finset.inter_product Finset.inter_product\n\n/- warning: finset.product_inter -> Finset.product_inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s (Inter.inter.{u2} (Finset.{u2} β) (Finset.hasInter.{u2} β (fun (a : β) (b : β) => _inst_2 a b)) t t')) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasInter.{max u1 u2} (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s t'))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} {t' : Finset.{u1} β} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s (Inter.inter.{u1} (Finset.{u1} β) (Finset.instInterFinset.{u1} β (fun (a : β) (b : β) => _inst_2 a b)) t t')) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instInterFinset.{max u2 u1} (Prod.{u2, u1} α β) (fun (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β) => instDecidableEqProd.{u2, u1} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_inter Finset.product_interₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_inter [DecidableEq α] [DecidableEq β] : s ×ˢ (t ∩ t') = s ×ˢ t ∩ s ×ˢ t' :=\n  by\n  ext ⟨x, y⟩\n  simp only [← and_and_left, mem_inter, mem_product]\n#align finset.product_inter Finset.product_inter\n\n/- warning: finset.product_inter_product -> Finset.product_inter_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.hasInter.{max u1 u2} (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t')) (Finset.product.{u1, u2} α β (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s s') (Inter.inter.{u2} (Finset.{u2} β) (Finset.hasInter.{u2} β (fun (a : β) (b : β) => _inst_2 a b)) t t'))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {s' : Finset.{u2} α} {t : Finset.{u1} β} {t' : Finset.{u1} β} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.instInterFinset.{max u2 u1} (Prod.{u2, u1} α β) (fun (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β) => instDecidableEqProd.{u2, u1} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s' t')) (Finset.product.{u2, u1} α β (Inter.inter.{u2} (Finset.{u2} α) (Finset.instInterFinset.{u2} α (fun (a : α) (b : α) => _inst_1 a b)) s s') (Inter.inter.{u1} (Finset.{u1} β) (Finset.instInterFinset.{u1} β (fun (a : β) (b : β) => _inst_2 a b)) t t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_inter_product Finset.product_inter_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_inter_product [DecidableEq α] [DecidableEq β] :\n    s ×ˢ t ∩ s' ×ˢ t' = (s ∩ s') ×ˢ (t ∩ t') :=\n  by\n  ext ⟨x, y⟩\n  simp only [and_assoc', and_left_comm, mem_inter, mem_product]\n#align finset.product_inter_product Finset.product_inter_product\n\n/- warning: finset.disjoint_product -> Finset.disjoint_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β}, Iff (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.orderBot.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t')) (Or (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s s') (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.orderBot.{u2} β) t t'))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β}, Iff (Disjoint.{max u2 u1} (Finset.{max u2 u1} (Prod.{u1, u2} α β)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t')) (Or (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) s s') (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} β) t t'))\nCase conversion may be inaccurate. Consider using '#align finset.disjoint_product Finset.disjoint_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem disjoint_product : Disjoint (s ×ˢ t) (s' ×ˢ t') ↔ Disjoint s s' ∨ Disjoint t t' := by\n  simp_rw [← disjoint_coe, coe_product, Set.disjoint_prod]\n#align finset.disjoint_product Finset.disjoint_product\n\n/- warning: finset.disj_union_product -> Finset.disjUnion_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} (hs : Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s s'), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β (Finset.disjUnion.{u1} α s s' hs) t) (Finset.disjUnion.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t) (Iff.mpr (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.orderBot.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s' t)) (Or (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s s') (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.orderBot.{u2} β) t t)) (Finset.disjoint_product.{u1, u2} α β s s' t t) (Or.inl (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s s') (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.orderBot.{u2} β) t t) hs)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {s' : Finset.{u2} α} {t : Finset.{u1} β} (hs : Disjoint.{u2} (Finset.{u2} α) (Finset.partialOrder.{u2} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} α) s s'), Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β (Finset.disjUnion.{u2} α s s' hs) t) (Finset.disjUnion.{max u2 u1} (Prod.{u2, u1} α β) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s' t) (Iff.mpr (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.partialOrder.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{max u2 u1} (Prod.{u2, u1} α β)) (Finset.product.{u2, u1} α β s t) (Finset.product.{u2, u1} α β s' t)) (Or (Disjoint.{u2} (Finset.{u2} α) (Finset.partialOrder.{u2} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} α) s s') (Disjoint.{u1} (Finset.{u1} β) (Finset.partialOrder.{u1} β) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} β) t t)) (Finset.disjoint_product.{u2, u1} α β s s' t t) (Or.inl (Disjoint.{u2} (Finset.{u2} α) (Finset.partialOrder.{u2} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} α) s s') (Disjoint.{u1} (Finset.{u1} β) (Finset.partialOrder.{u1} β) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} β) t t) hs)))\nCase conversion may be inaccurate. Consider using '#align finset.disj_union_product Finset.disjUnion_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem disjUnion_product (hs : Disjoint s s') :\n    s.disjUnion s' hs ×ˢ t = (s ×ˢ t).disjUnion (s' ×ˢ t) (disjoint_product.mpr <| Or.inl hs) :=\n  eq_of_veq <| Multiset.add_product _ _ _\n#align finset.disj_union_product Finset.disjUnion_product\n\n/- warning: finset.product_disj_union -> Finset.product_disjUnion is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} (ht : Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.orderBot.{u2} β) t t'), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s (Finset.disjUnion.{u2} β t t' ht)) (Finset.disjUnion.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s t') (Iff.mpr (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.orderBot.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s t')) (Or (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s s) (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.orderBot.{u2} β) t t')) (Finset.disjoint_product.{u1, u2} α β s s t t') (Or.inr (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s s) (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.orderBot.{u2} β) t t') ht)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} (ht : Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} β) t t'), Eq.{max (succ u1) (succ u2)} (Finset.{max u2 u1} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s (Finset.disjUnion.{u2} β t t' ht)) (Finset.disjUnion.{max u1 u2} (Prod.{u1, u2} α β) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s t') (Iff.mpr (Disjoint.{max u2 u1} (Finset.{max u2 u1} (Prod.{u1, u2} α β)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.product.{u1, u2} α β s t) (Finset.product.{u1, u2} α β s t')) (Or (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) s s) (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} β) t t')) (Finset.disjoint_product.{u1, u2} α β s s t t') (Or.inr (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) s s) (Disjoint.{u2} (Finset.{u2} β) (Finset.partialOrder.{u2} β) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} β) t t') ht)))\nCase conversion may be inaccurate. Consider using '#align finset.product_disj_union Finset.product_disjUnionₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem product_disjUnion (ht : Disjoint t t') :\n    s ×ˢ t.disjUnion t' ht = (s ×ˢ t).disjUnion (s ×ˢ t') (disjoint_product.mpr <| Or.inr ht) :=\n  eq_of_veq <| Multiset.product_add _ _ _\n#align finset.product_disj_union Finset.product_disjUnion\n\nend Prod\n\nsection Diag\n\nvariable [DecidableEq α] (s t : Finset α)\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.diag /-\n/-- Given a finite set `s`, the diagonal, `s.diag` is the set of pairs of the form `(a, a)` for\n`a ∈ s`. -/\ndef diag :=\n  (s ×ˢ s).filterₓ fun a : α × α => a.fst = a.snd\n#align finset.diag Finset.diag\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.offDiag /-\n/-- Given a finite set `s`, the off-diagonal, `s.off_diag` is the set of pairs `(a, b)` with `a ≠ b`\nfor `a, b ∈ s`. -/\ndef offDiag :=\n  (s ×ˢ s).filterₓ fun a : α × α => a.fst ≠ a.snd\n#align finset.off_diag Finset.offDiag\n-/\n\nvariable {s} {x : α × α}\n\n#print Finset.mem_diag /-\n@[simp]\ntheorem mem_diag : x ∈ s.diag ↔ x.1 ∈ s ∧ x.1 = x.2 :=\n  by\n  simp only [diag, mem_filter, mem_product]\n  constructor <;> intro h <;> simp only [h, and_true_iff, eq_self_iff_true, and_self_iff]\n  rw [← h.2]\n  exact h.1\n#align finset.mem_diag Finset.mem_diag\n-/\n\n#print Finset.mem_offDiag /-\n@[simp]\ntheorem mem_offDiag : x ∈ s.offDiag ↔ x.1 ∈ s ∧ x.2 ∈ s ∧ x.1 ≠ x.2 :=\n  by\n  simp only [off_diag, mem_filter, mem_product]\n  constructor <;> intro h <;> simp only [h, Ne.def, not_false_iff, and_self_iff]\n#align finset.mem_off_diag Finset.mem_offDiag\n-/\n\nvariable (s)\n\n#print Finset.coe_offDiag /-\n@[simp, norm_cast]\ntheorem coe_offDiag : (s.offDiag : Set (α × α)) = (s : Set α).offDiag :=\n  Set.ext fun _ => mem_offDiag\n#align finset.coe_off_diag Finset.coe_offDiag\n-/\n\n#print Finset.diag_card /-\n@[simp]\ntheorem diag_card : (diag s).card = s.card :=\n  by\n  suffices diag s = s.image fun a => (a, a) by\n    rw [this]\n    apply card_image_of_inj_on\n    exact fun x1 h1 x2 h2 h3 => (Prod.mk.inj h3).1\n  ext ⟨a₁, a₂⟩\n  rw [mem_diag]\n  constructor <;> intro h <;> rw [Finset.mem_image] at *\n  · use a₁, h.1, prod.mk.inj_iff.mpr ⟨rfl, h.2⟩\n  · rcases h with ⟨a, h1, h2⟩\n    have h := Prod.mk.inj h2\n    rw [← h.1, ← h.2]\n    use h1\n#align finset.diag_card Finset.diag_card\n-/\n\n#print Finset.offDiag_card /-\n@[simp]\ntheorem offDiag_card : (offDiag s).card = s.card * s.card - s.card :=\n  by\n  suffices (diag s).card + (off_diag s).card = s.card * s.card\n    by\n    nth_rw 3 [← s.diag_card]\n    simp only [diag_card] at *\n    rw [tsub_eq_of_eq_add_rev]\n    rw [this]\n  rw [← card_product]\n  apply filter_card_add_filter_neg_card_eq_card\n#align finset.off_diag_card Finset.offDiag_card\n-/\n\n#print Finset.diag_mono /-\n@[mono]\ntheorem diag_mono : Monotone (diag : Finset α → Finset (α × α)) := fun s t h x hx =>\n  mem_diag.2 <| And.imp_left (@h _) <| mem_diag.1 hx\n#align finset.diag_mono Finset.diag_mono\n-/\n\n#print Finset.offDiag_mono /-\n@[mono]\ntheorem offDiag_mono : Monotone (offDiag : Finset α → Finset (α × α)) := fun s t h x hx =>\n  mem_offDiag.2 <| And.imp (@h _) (And.imp_left <| @h _) <| mem_offDiag.1 hx\n#align finset.off_diag_mono Finset.offDiag_mono\n-/\n\n#print Finset.diag_empty /-\n@[simp]\ntheorem diag_empty : (∅ : Finset α).diag = ∅ :=\n  rfl\n#align finset.diag_empty Finset.diag_empty\n-/\n\n#print Finset.offDiag_empty /-\n@[simp]\ntheorem offDiag_empty : (∅ : Finset α).offDiag = ∅ :=\n  rfl\n#align finset.off_diag_empty Finset.offDiag_empty\n-/\n\n/- warning: finset.diag_union_off_diag -> Finset.diag_union_offDiag is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasUnion.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Finset.product.{u1, u1} α α s s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Finset.product.{u1, u1} α α s s)\nCase conversion may be inaccurate. Consider using '#align finset.diag_union_off_diag Finset.diag_union_offDiagₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem diag_union_offDiag : s.diag ∪ s.offDiag = s ×ˢ s :=\n  filter_union_filter_neg_eq _ _\n#align finset.diag_union_off_diag Finset.diag_union_offDiag\n\n/- warning: finset.disjoint_diag_off_diag -> Finset.disjoint_diag_offDiag is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Disjoint.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.partialOrder.{u1} (Prod.{u1, u1} α α)) (Finset.orderBot.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Disjoint.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.partialOrder.{u1} (Prod.{u1, u1} α α)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.disjoint_diag_off_diag Finset.disjoint_diag_offDiagₓ'. -/\n@[simp]\ntheorem disjoint_diag_offDiag : Disjoint s.diag s.offDiag :=\n  disjoint_filter_filter_neg _ _ _\n#align finset.disjoint_diag_off_diag Finset.disjoint_diag_offDiag\n\n/- warning: finset.product_sdiff_diag -> Finset.product_sdiff_diag is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasSdiff.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.product.{u1, u1} α α s s) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instSDiffFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.product.{u1, u1} α α s s) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_sdiff_diag Finset.product_sdiff_diagₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_sdiff_diag : s ×ˢ s \\ s.diag = s.offDiag := by\n  rw [← diag_union_off_diag, union_comm, union_sdiff_self,\n    sdiff_eq_self_of_disjoint (disjoint_diag_off_diag _).symm]\n#align finset.product_sdiff_diag Finset.product_sdiff_diag\n\n/- warning: finset.product_sdiff_off_diag -> Finset.product_sdiff_offDiag is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasSdiff.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.product.{u1, u1} α α s s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instSDiffFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.product.{u1, u1} α α s s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_sdiff_off_diag Finset.product_sdiff_offDiagₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_sdiff_offDiag : s ×ˢ s \\ s.offDiag = s.diag := by\n  rw [← diag_union_off_diag, union_sdiff_self, sdiff_eq_self_of_disjoint (disjoint_diag_off_diag _)]\n#align finset.product_sdiff_off_diag Finset.product_sdiff_offDiag\n\n/- warning: finset.diag_inter -> Finset.diag_inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α) (t : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasInter.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α) (t : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} α) (Finset.instInterFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instInterFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t))\nCase conversion may be inaccurate. Consider using '#align finset.diag_inter Finset.diag_interₓ'. -/\ntheorem diag_inter : (s ∩ t).diag = s.diag ∩ t.diag :=\n  ext fun x => by simpa only [mem_diag, mem_inter] using and_and_right _ _ _\n#align finset.diag_inter Finset.diag_inter\n\n/- warning: finset.off_diag_inter -> Finset.offDiag_inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α) (t : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasInter.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α) (t : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} α) (Finset.instInterFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instInterFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t))\nCase conversion may be inaccurate. Consider using '#align finset.off_diag_inter Finset.offDiag_interₓ'. -/\ntheorem offDiag_inter : (s ∩ t).offDiag = s.offDiag ∩ t.offDiag :=\n  coe_injective <| by\n    push_cast\n    exact Set.offDiag_inter _ _\n#align finset.off_diag_inter Finset.offDiag_inter\n\n/- warning: finset.diag_union -> Finset.diag_union is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α) (t : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasUnion.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Finset.{u1} α) (t : Finset.{u1} α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t))\nCase conversion may be inaccurate. Consider using '#align finset.diag_union Finset.diag_unionₓ'. -/\ntheorem diag_union : (s ∪ t).diag = s.diag ∪ t.diag :=\n  by\n  ext ⟨i, j⟩\n  simp only [mem_diag, mem_union, or_and_right]\n#align finset.diag_union Finset.diag_union\n\nvariable {s t}\n\n/- warning: finset.off_diag_union -> Finset.offDiag_union is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u1} α} {t : Finset.{u1} α}, (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s t) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasUnion.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasUnion.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasUnion.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t)) (Finset.product.{u1, u1} α α s t)) (Finset.product.{u1, u1} α α t s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u1} α} {t : Finset.{u1} α}, (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) s t) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t)) (Finset.product.{u1, u1} α α s t)) (Finset.product.{u1, u1} α α t s)))\nCase conversion may be inaccurate. Consider using '#align finset.off_diag_union Finset.offDiag_unionₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem offDiag_union (h : Disjoint s t) :\n    (s ∪ t).offDiag = s.offDiag ∪ t.offDiag ∪ s ×ˢ t ∪ t ×ˢ s :=\n  coe_injective <| by\n    push_cast\n    exact Set.offDiag_union (disjoint_coe.2 h)\n#align finset.off_diag_union Finset.offDiag_union\n\nvariable (a : α)\n\n#print Finset.offDiag_singleton /-\n@[simp]\ntheorem offDiag_singleton : ({a} : Finset α).offDiag = ∅ := by simp [← Finset.card_eq_zero]\n#align finset.off_diag_singleton Finset.offDiag_singleton\n-/\n\n#print Finset.diag_singleton /-\ntheorem diag_singleton : ({a} : Finset α).diag = {(a, a)} := by\n  rw [← product_sdiff_off_diag, off_diag_singleton, sdiff_empty, singleton_product_singleton]\n#align finset.diag_singleton Finset.diag_singleton\n-/\n\n/- warning: finset.diag_insert -> Finset.diag_insert is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u1} α} (a : α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Insert.insert.{u1, u1} α (Finset.{u1} α) (Finset.hasInsert.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) a s)) (Insert.insert.{u1, u1} (Prod.{u1, u1} α α) (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasInsert.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Prod.mk.{u1, u1} α α a a) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u1} α} (a : α), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Insert.insert.{u1, u1} α (Finset.{u1} α) (Finset.instInsertFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) a s)) (Insert.insert.{u1, u1} (Prod.{u1, u1} α α) (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instInsertFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Prod.mk.{u1, u1} α α a a) (Finset.diag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s))\nCase conversion may be inaccurate. Consider using '#align finset.diag_insert Finset.diag_insertₓ'. -/\ntheorem diag_insert : (insert a s).diag = insert (a, a) s.diag := by\n  rw [insert_eq, insert_eq, diag_union, diag_singleton]\n#align finset.diag_insert Finset.diag_insert\n\n/- warning: finset.off_diag_insert -> Finset.offDiag_insert is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u1} α} (a : α), (Not (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s)) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Insert.insert.{u1, u1} α (Finset.{u1} α) (Finset.hasInsert.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) a s)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasUnion.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.hasUnion.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => Prod.decidableEq.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.product.{u1, u1} α α (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) s)) (Finset.product.{u1, u1} α α s (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u1} α} (a : α), (Not (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) a s)) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (Insert.insert.{u1, u1} α (Finset.{u1} α) (Finset.instInsertFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) a s)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} α α)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} α α) (fun (a : Prod.{u1, u1} α α) (b : Prod.{u1, u1} α α) => instDecidableEqProd.{u1, u1} α α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : α) (b : α) => _inst_1 a b) a b)) (Finset.offDiag.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) (Finset.product.{u1, u1} α α (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.instSingletonFinset.{u1} α) a) s)) (Finset.product.{u1, u1} α α s (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.instSingletonFinset.{u1} α) a))))\nCase conversion may be inaccurate. Consider using '#align finset.off_diag_insert Finset.offDiag_insertₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem offDiag_insert (has : a ∉ s) : (insert a s).offDiag = s.offDiag ∪ {a} ×ˢ s ∪ s ×ˢ {a} := by\n  rw [insert_eq, union_comm, off_diag_union (disjoint_singleton_right.2 has), off_diag_singleton,\n    union_empty, union_right_comm]\n#align finset.off_diag_insert Finset.offDiag_insert\n\nend Diag\n\nend Finset\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finset/Prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4985983453193212}}
{"text": "import ch2\n\nuniverse u\n\nnamespace Set\n\n@[simp]\nlemma pair_mem_pair_sep {p : Set → Set → Prop} {x y a b : Set} :\na.pair b ∈ pair_sep p x y ↔ a ∈ x ∧ b ∈ y ∧ p a b :=\nbegin\n  simp only [mem_pair_sep], split,\n  { rintro ⟨a', ha, b', hb, he, hp⟩,\n    have hpe : a = a' ∧ b = b' := pair_inj he,\n    simp only [hpe.left, hpe.right],\n    exact ⟨ha, hb, hp⟩, },\n  { rintro ⟨ha, hb, hp⟩,\n    exact ⟨a, ha, b, hb, rfl, hp⟩, },\nend\n\nlemma pair_mem_pair_sep' {p : Set → Set → Prop} {x y a : Set} (a' : a ∈ x) {b : Set} (b' : b ∈ y) :\n  a.pair b ∈ pair_sep p x y ↔ p a b :=\nbegin\n  simp only [pair_mem_pair_sep], split,\n    rintro ⟨-, -, pab⟩, exact pab,\n  intro pab, exact ⟨a', b', pab⟩,\nend\n\ntheorem pair_unordered {a b : Set} : ({a, b} : Set) = {b, a} :=\nbegin\n  apply ext,\n  intro z,\n  simp only [mem_pair, or_comm],\nend\n-- We have x.pair y = {{x}, {x, y}}\n-- And pair_inj which shows injectivity of pair\n-- pair_sep p x y supplies us with the set of all ordered pairs from x × y that satisfies p\n-- Corralary 3C is basically mem_pair_sep\n-- We also have prod and mem_prod\ntheorem ch3_p4 : ¬ ∃ S : Set, ∀ x y : Set, x.pair y ∈ S :=\nbegin\n  rintro ⟨S, h⟩,\n  apply univ_not_set,\n  refine ⟨S.Union.Union, _⟩,\n  intro x,\n  specialize h x x,\n  rw mem_Union,\n  refine ⟨{x}, _, _⟩,\n  rw mem_Union,\n  refine ⟨x.pair x, h, _⟩,\n  simp only [pair, true_or, eq_self_iff_true, mem_pair],\n  simp only [mem_singleton],\nend\n\ndef is_pair (x : Set) : Prop := ∃ (y z : Set), x = y.pair z\ndef is_rel (R : Set) : Prop := ∀ x : Set, x ∈ R → x.is_pair\ndef dom (R : Set) : Set := {x ∈ R.Union.Union | ∃ y, x.pair y ∈ R}\ndef ran (R : Set) : Set := {x ∈ R.Union.Union | ∃ t : Set, t.pair x ∈ R}\ndef fld (R : Set) : Set := R.dom ∪ R.ran\n\nlemma empty_is_rel : (∅ : Set).is_rel :=\nbegin\n  intros x hx, exfalso, exact mem_empty _ hx,\nend\n\nlemma singleton_is_rel {x y : Set} : ({x.pair y} : Set).is_rel :=\nbegin\n  intros z hz, rw mem_singleton at hz, exact ⟨_, _, hz⟩,\nend\n\nlemma inter_rel_is_rel {R : Set} (hR : R.is_rel) {S : Set} : (R ∩ S).is_rel :=\nbegin\n  intros x hx, rw [mem_inter] at hx, exact hR _ hx.left,\nend\n\nlemma union_rel_is_rel {R : Set} (hR : R.is_rel) {S : Set} (hS : S.is_rel) : (R ∪ S).is_rel :=\nbegin\n  intros x hx, rw [mem_union] at hx, cases hx,\n    exact hR _ hx,\n  exact hS _ hx,\nend\n\nlemma Union_is_rel {S : Set} (h : ∀ ⦃x : Set⦄, x ∈ S → x.is_rel) : S.Union.is_rel :=\nbegin\n  intros z hz, rw mem_Union at hz, rcases hz with ⟨x, hx, hz⟩, exact h hx _ hz,\nend\n\nlemma rel_eq {R : Set} (hR : R.is_rel) {S : Set} (hS : S.is_rel) (h : ∀ ⦃x y : Set⦄, x.pair y ∈ R ↔ x.pair y ∈ S) : R = S :=\nbegin\n  apply ext, intro z, split,\n  { intro hz,\n    have hxy := hR _ hz, rcases hxy with ⟨x, y, hxy⟩,\n    rw hxy at hz, rw hxy, rw ←h, exact hz, },\n  { intro hz,\n    have hxy := hS _ hz, rcases hxy with ⟨x, y, hxy⟩,\n    rw hxy at hz, rw hxy, rw h, exact hz, },\nend\n\nlemma rel_eq_empty {R : Set} (hR : R.is_rel) : R = ∅ ↔ ∀ ⦃x y : Set⦄, x.pair y ∉ R :=\nbegin\n  split,\n  { intro he, simp only [he, mem_empty, forall_const, not_false_iff], },\n  { intro ha, apply rel_eq hR empty_is_rel, intros x y, split,\n    { intro h, exfalso, exact ha h, },\n    { intro h, exfalso, exact mem_empty _ h, }, },\nend\n\nlemma is_pair_of_mem_prod {p A B : Set} (h : p ∈ A.prod B) : p.is_pair :=\nbegin\n  simp only [mem_prod, exists_prop] at h, rcases h with ⟨a, ha, b, hb, he⟩,\n  exact ⟨_, _, he⟩,\nend\n\nlemma pair_sep_is_rel {p : Set → Set → Prop} {x y : Set} : (pair_sep p x y).is_rel :=\nbegin\n  intros z hz,\n  simp only [mem_pair_sep] at hz,\n  rcases hz with ⟨a, ha, b, hb, he, hp⟩,\n  exact ⟨a, b, he⟩,\nend\n\nlemma prod_is_rel {X Y : Set} : (X.prod Y).is_rel := pair_sep_is_rel\n\nlemma sub_rel_is_rel {X Y : Set} (hY : Y.is_rel) (XY : X ⊆ Y) : X.is_rel :=\nλ z, assume zX, hY _ (XY zX)\n\nlemma diff_is_rel {X Y : Set} (hX : X.is_rel) : (X \\ Y).is_rel :=\nsub_rel_is_rel hX subset_diff\n\ntheorem rel_sub {R : Set} (hR : R.is_rel) {S : Set} (hext : ∀ ⦃x y : Set⦄, x.pair y ∈ R → x.pair y ∈ S) : R ⊆ S :=\nbegin\n  intros z hz, specialize hR z hz, rcases hR with ⟨x, y, he⟩, subst he, exact hext hz,\nend\n\ntheorem rel_ext {R : Set} (hR : R.is_rel) {S : Set} (hS : S.is_rel) (hext : ∀ ⦃x y : Set⦄, x.pair y ∈ R ↔ x.pair y ∈ S) : R = S :=\nbegin\n  rw eq_iff_subset_and_subset, refine ⟨rel_sub hR _, rel_sub hS _⟩,\n    intros x y hxy, exact (@hext x y).mp hxy,\n  intros x y hxy, exact (@hext x y).mpr hxy,\nend\n\ntheorem rel_ext' {A B R : Set} (RAB : R ⊆ A.prod B) {S : Set} (SAB : S ⊆ A.prod B)\n  (hext : ∀ ⦃x : Set⦄, x ∈ A → ∀ ⦃y : Set⦄, y ∈ B → (x.pair y ∈ R ↔ x.pair y ∈ S)) : R = S :=\nbegin\n  apply rel_ext (sub_rel_is_rel prod_is_rel RAB) (sub_rel_is_rel prod_is_rel SAB), intros x y, split; intros xy,\n    have xy' := RAB xy, rw pair_mem_prod at xy', rw ←hext xy'.left xy'.right, exact xy,\n  have xy' := SAB xy, rw pair_mem_prod at xy', rw hext xy'.left xy'.right, exact xy,\nend\n\nsection\nlocal attribute [instance] classical.prop_decidable\nlemma prod_diff {A B C : Set} : A.prod B \\ A.prod C = A.prod (B \\ C) :=\nbegin\n  apply rel_ext (diff_is_rel prod_is_rel) prod_is_rel,\n  simp only [mem_diff, pair_mem_prod], tauto,\nend\nend\n\nlemma union_prod {A B C : Set} : (A ∪ B).prod C = (A.prod C) ∪ (B.prod C) :=\nbegin\n  apply rel_ext prod_is_rel (union_rel_is_rel prod_is_rel prod_is_rel),\n  simp only [pair_mem_prod, mem_union, or_and_distrib_right, iff_self, forall_const],\nend\n\nlemma prod_union {A B C : Set} : A.prod (B ∪ C) = (A.prod B) ∪ (A.prod C) :=\nbegin\n  apply rel_ext prod_is_rel (union_rel_is_rel prod_is_rel prod_is_rel),\n  simp only [pair_mem_prod, mem_union, and_or_distrib_left, iff_self, forall_const],\nend\n\nlemma prod_inter {A B C : Set} : A.prod (B ∩ C) = A.prod B ∩ A.prod C :=\nbegin\n  apply rel_ext prod_is_rel (sub_rel_is_rel prod_is_rel inter_subset_right),\n  simp only [pair_mem_prod, mem_inter], intros x y,\n  nth_rewrite 3 and_comm, rw and_assoc, nth_rewrite 2 ←and_assoc,\n  rw and_self, simp only [←and_assoc], nth_rewrite 1 and_comm,\nend\n\nlemma pair_sep_sub_prod {p : Set → Set → Prop} {x y : Set} : pair_sep p x y ⊆ x.prod y :=\nbegin\n  intro p, simp only [mem_pair_sep, mem_prod, exists_prop], rintro ⟨a, ha, b, hb, he, hp⟩,\n  exact ⟨_, ha, _, hb, he⟩,\nend\n\nlemma L3D_bulk {x y A : Set} (h : x.pair y ∈ A) : {x, y} ∈ A.Union :=\nbegin\n  rw mem_Union,\n  refine ⟨_, h, _⟩,\n  simp only [pair, mem_pair], right, refl,\nend\n\nlemma L3D_left {x y A : Set} (h : x.pair y ∈ A) : x ∈ A.Union.Union :=\nbegin\n  rw mem_Union,\n  refine ⟨_, L3D_bulk h, _⟩,\n  simp only [mem_pair], left, refl,\nend\n\nlemma L3D_right {x y A : Set} (h : x.pair y ∈ A) : y ∈ A.Union.Union :=\nbegin\n  rw mem_Union,\n  refine ⟨_, L3D_bulk h, _⟩,\n  simp only [mem_pair], right, refl,\nend\n\n@[simp]\nlemma mem_dom {R : Set} (x : Set) : x ∈ R.dom ↔ ∃ y, x.pair y ∈ R :=\nbegin\n  simp only [dom, mem_sep],\n  apply and_iff_right_of_left_if_right,\n  rintro ⟨y, h⟩,\n  exact L3D_left h,\nend\n@[simp]\nlemma mem_ran {R : Set} (x : Set) : x ∈ R.ran ↔ ∃ t : Set, t.pair x ∈ R :=\nbegin\n  simp only [ran, mem_sep],\n  apply and_iff_right_of_left_if_right,\n  rintro ⟨t, h⟩,\n  exact L3D_right h,\nend\n\nlemma ran_empty_eq_empty : ran ∅ = ∅ :=\nbegin\n  rw eq_empty, intros y hy, rw mem_ran at hy, rcases hy with ⟨x, hxy⟩, exact mem_empty _ hxy,\nend\n\nlemma dom_empty_eq_empty : dom ∅ = ∅ :=\nbegin\n  rw eq_empty, intros x hx, rw mem_dom at hx, rcases hx with ⟨y, hxy⟩, exact mem_empty _ hxy,\nend\n\nlemma ran_ne_of_ne {C A B : Set} (CAB : C ⊆ A.prod B) (Cne : C ≠ ∅) : C.ran ≠ ∅ :=\nbegin\n  intro Ce, apply Cne, rw eq_empty,\n  intros z zC, specialize CAB zC, rw mem_prod at CAB, rcases CAB with ⟨a, aC, b, bB, zab⟩, subst zab,\n  apply mem_empty b, rw [←Ce, mem_ran], exact ⟨_, zC⟩,\nend\n\nlemma pair_sep_dom_sub {p : Set → Set → Prop} {x y : Set} : (pair_sep p x y).dom ⊆ x :=\nbegin\n  intros z hz, simp only [mem_dom, pair_mem_pair_sep] at hz, finish,\nend\n\n@[simp]\nlemma dom_singleton {x y : Set} : ({x.pair y} : Set).dom = {x} :=\nbegin\n  apply ext, simp only [mem_singleton, mem_dom], intro z, split,\n  { rintro ⟨y, hy⟩, exact (pair_inj hy).left, },\n  { rintro hx, rw hx, exact ⟨_, rfl⟩, },\nend\n\n@[simp]\nlemma ran_singleton {x y : Set} : ({x.pair y} : Set).ran = {y} :=\nbegin\n  apply ext, simp only [mem_singleton, mem_ran], intro z, split,\n  { rintro ⟨y, hy⟩, exact (pair_inj hy).right, },\n  { rintro hx, rw hx, exact ⟨_, rfl⟩, },\nend\n\n-- chapter 3 problem 6\nlemma rel_sub_dom_ran {R : Set} : R.is_rel ↔ R ⊆ R.dom.prod R.ran :=\nbegin\n  split,\n    intros hR z hz, rw mem_prod, specialize hR _ hz, rcases hR with ⟨x, y, hxy⟩, rw hxy at hz,\n    simp only [exists_prop, mem_dom, mem_ran], exact ⟨_, ⟨_, hz⟩, _, ⟨_, hz⟩, hxy⟩,\n  intros hR z hz, specialize hR hz, simp only [mem_prod, exists_prop] at hR, rcases hR with ⟨x, hx, y, hy, he⟩,\n  exact ⟨_, _, he⟩,\nend\n\ndef fst (p : Set) : Set := ({p} : Set).dom.Union\ndef snd (p : Set) : Set := ({p} : Set).ran.Union\n\nlemma fst_snd_spec {p : Set} (hp : p.is_pair) : p = p.fst.pair p.snd :=\nbegin\n  rcases hp with ⟨x, y, hp⟩, rw hp, congr,\n  { rw [fst, dom_singleton, Union_singleton], },\n  { rw [snd, ran_singleton, Union_singleton], },\nend\n\nlemma fst_congr {x y : Set} : (x.pair y).fst = x :=\nbegin\n  have h : x.pair y = (x.pair y).fst.pair (x.pair y).snd := fst_snd_spec ⟨_, _, rfl⟩,\n  symmetry, exact (pair_inj h).left,\nend\n\nlemma snd_congr {x y : Set} : (x.pair y).snd = y :=\nbegin\n  have h : x.pair y = (x.pair y).fst.pair (x.pair y).snd := fst_snd_spec ⟨_, _, rfl⟩,\n  symmetry, exact (pair_inj h).right,\nend\n\nlemma pair_eq {p : Set} (hp : p.is_pair) {q : Set} (hq : q.is_pair) (hf : p.fst = q.fst) (hs : p.snd = q.snd) : p = q :=\nbegin\n  rcases hp with ⟨a, b, pab⟩, rcases hq with ⟨c, d, qcd⟩, subst pab, subst qcd,\n  simp only [fst_congr] at hf, simp only [snd_congr] at hs, rw [hf, hs],\nend\n\nlemma fst_ne_of_pair_ne {x y z : Set} (h : x.pair z ≠ y.pair z) : x ≠ y :=\nbegin\n  intro xy, subst xy, exact h rfl,\nend\n\nlemma fst_snd_mem_dom_ran {p A B : Set} (hp : p ∈ A.prod B) : p.fst ∈ A ∧ p.snd ∈ B :=\nbegin\n  simp only [mem_prod, exists_prop] at hp,\n  rcases hp with ⟨a, ha, b, hb, he⟩,\n  have he' : a.pair b = p.fst.pair p.snd, rw ←he, exact fst_snd_spec ⟨_, _, he⟩,\n  rw [←(pair_inj he').left, ←(pair_inj he').right], finish,\nend\n\nlemma ran_subset_of_subset {H F : Set} (h : H ⊆ F) : H.ran ⊆ F.ran :=\nbegin\n  intro z, simp only [mem_ran],\n  rintro ⟨x, hx⟩,\n  exact ⟨x, h hx⟩,\nend\n\nlemma ran_prod {A B : Set} : (A.prod B).ran ⊆ B :=\nbegin\n  intro b, simp only [mem_ran, pair_mem_prod], rintro ⟨-, -, xB⟩, exact xB,\nend\n\nlemma ran_sub_of_sub_prod {C A B : Set} (CAB : C ⊆ A.prod B) : C.ran ⊆ B :=\nsubset_trans (ran_subset_of_subset CAB) ran_prod\n\nlemma ran_Union_eq_Union_ran {C A : Set} (hA : ∀ ⦃y⦄, y ∈ A ↔ ∃ f : Set, y ∈ f.ran ∧ f ∈ C) : A = C.Union.ran :=\nbegin\n  apply ext,\n  simp only [hA, mem_ran], intro y, split,\n    rintro ⟨f, ⟨x, hxy⟩, hf⟩, use x, rw mem_Union, exact ⟨_, hf, hxy⟩,\n  rintro ⟨x, hxy⟩, rw mem_Union at hxy, rcases hxy with ⟨f, hf, hxy⟩, exact ⟨_, ⟨_, hxy⟩, hf⟩,\nend\n\nlemma dom_Union_eq_Union_dom {C A : Set} (hA : ∀ ⦃x⦄, x ∈ A ↔ ∃ f : Set, x ∈ f.dom ∧ f ∈ C) : A = C.Union.dom :=\nbegin\n  apply ext,\n  simp only [hA, mem_dom], intro x, split,\n    rintro ⟨f, ⟨y, hxy⟩, hf⟩, use y, rw mem_Union, exact ⟨_, hf, hxy⟩,\n  rintro ⟨y, hxy⟩, rw mem_Union at hxy, rcases hxy with ⟨f, hf, hxy⟩, exact ⟨_, ⟨_, hxy⟩, hf⟩,\nend\n\ndef pow : Set → ℕ → Set\n| S 0 := {∅}\n| S 1 := S\n| S (n + 1) := (S.pow n).prod S\ndef is_n_ary (S : Set) (n : ℕ) : Prop := S ⊆ S.pow n\ndef is_function (F : Set) : Prop := F.is_rel ∧ ∀ x : Set, x ∈ F.dom → ∃! y, x.pair y ∈ F\n\ndef fun_value (F x : Set) : Set := {y ∈ F.Union.Union | x.pair y ∈ F}.Union\n\nlemma is_function_iff {F : Set} : F.is_function ↔ F.is_rel ∧ ∀ x y y' : Set, x.pair y ∈ F → x.pair y' ∈ F → y = y' :=\nbegin\n  simp only [is_function, mem_dom, exists_imp_distrib, and.congr_right_iff], intro hr, split,\n  { intros h x y y' hy hy', refine unique_of_exists_unique (h _ _ hy) hy hy', },\n  { intros h x y hy, exact exists_unique_of_exists_of_unique ⟨_, hy⟩ (h x), },\nend\n\n@[simp]\nlemma mem_fun_value {F x z : Set} : z ∈ F.fun_value x ↔ ∃ y : Set, x.pair y ∈ F ∧ z ∈ y :=\nbegin\n  simp only [fun_value, mem_Union], split,\n  { rintro ⟨y, h₁, h₂⟩,\n    simp only [mem_sep] at h₁,\n    exact ⟨_, h₁.right, h₂⟩, },\n  { rintro ⟨y, h₁, h₂⟩,\n    refine ⟨_, _, h₂⟩,\n    simp only [mem_sep],\n    exact ⟨L3D_right h₁, h₁⟩, },\nend\n\nlemma fun_lemma {F x y z : Set} (hf : F.is_function) (hy : x.pair y ∈ F) (hz : x.pair z ∈ F) : y = z :=\nbegin\n  have hd : x ∈ F.dom, simp only [mem_dom], exact ⟨_, hy⟩,\n  exact unique_of_exists_unique (hf.right x hd) hy hz,\nend\n\nlemma fun_value_def {F x y : Set} (hf : F.is_function) (hp : x.pair y ∈ F) : y = F.fun_value x :=\nbegin\n  apply ext, intro z, simp only [mem_fun_value], split,\n  { intro hm, exact ⟨_, hp, hm⟩, },\n  { rintro ⟨w, hw, hm⟩,\n    rw fun_lemma hf hp hw,\n    assumption, },\nend\n\nlemma fun_value_def' {F x : Set} (hf : F.is_function) (hd : x ∈ F.dom) : x.pair (F.fun_value x) ∈ F :=\nbegin\n  simp only [mem_dom] at hd,\n  rcases hd with ⟨y, hy⟩,\n  rw ←fun_value_def hf hy,\n  exact hy,\nend\n\nlemma fun_value_def'' {F x : Set} (hf : F.is_function) (hd : x ∈ F.dom) : (F.fun_value x) ∈ F.ran :=\nbegin\n  simp only [mem_ran],\n  exact ⟨x, fun_value_def' hf hd⟩,\nend\n\nlemma fun_value_def''' {F x y : Set} (hf : F.is_function) (hd : x ∈ F.dom) (hy : y = F.fun_value x) : x.pair y ∈ F :=\nbegin\n  rw hy, exact fun_value_def' hf hd,\nend\n\nlemma eq_fun_value_of_mem_ran {F y : Set} (hf : F.is_function) (hy : y ∈ F.ran) : ∃ x ∈ F.dom, y = F.fun_value x :=\nbegin\n  rw mem_ran at hy, rcases hy with ⟨x, hy⟩, refine ⟨x, _, _⟩,\n  { rw mem_dom, exact ⟨_, hy⟩, },\n  { exact fun_value_def hf hy, },\nend\n\nlemma mem_ran_iff {F : Set} (hf : F.is_function) {y : Set} : y ∈ F.ran ↔ ∃ x : Set, x ∈ F.dom ∧ y = F.fun_value x :=\nbegin\n  split,\n  { intro hy,\n    have h := eq_fun_value_of_mem_ran hf hy,\n    simp only [exists_prop] at h, assumption, },\n  { rintro ⟨x, hx, he⟩, rw he, exact fun_value_def'' hf hx, },\nend\n\nlemma of_ran {f : Set} (ffun : f.is_function) {p : Set → Prop} (h : ∀ {x : Set}, x ∈ f.dom → p (f.fun_value x)) :\n  ∀ ⦃y : Set⦄, y ∈ f.ran → p y :=\nbegin\n  intro y, rw mem_ran_iff ffun, rintro ⟨x, xf, e⟩, subst e, exact h xf,\nend\n\nlemma dom_ran_eq_empty_iff {R : Set} : R.dom = ∅ ↔ R.ran = ∅ :=\nbegin\n  split,\n    intro de, rw eq_empty, intros y yr, rw mem_ran at yr, rcases yr with ⟨x, xyR⟩,\n    apply mem_empty x, rw ←de, rw mem_dom, exact ⟨_, xyR⟩,\n  intro re, rw eq_empty, intros x xd, rw mem_dom at xd, rcases xd with ⟨y, xyR⟩,\n    apply mem_empty y, rw ←re, rw mem_ran, exact ⟨_, xyR⟩,\nend\n\nlemma ran_sub {F : Set} (hf : F.is_function) {A : Set} (h : ∀ x : Set, x ∈ F.dom → F.fun_value x ∈ A) : F.ran ⊆ A :=\nbegin\n  intro y, rw mem_ran_iff hf, rintro ⟨x, xdom, Fx⟩, subst Fx, exact h _ xdom,\nend\n\ndef into_fun (F A B : Set) : Prop := F.is_function ∧ F.dom = A ∧ F.ran ⊆ B\n\nlemma fun_def_equiv {F A B : Set} : F.into_fun A B ↔ A.is_func B F :=\nbegin\n  split,\n  { rintro ⟨⟨hf, hu⟩, hd, hr⟩, refine ⟨λ p hp, _, λ x hx, _⟩,\n    { simp only [mem_prod], specialize hf p hp, rcases hf with ⟨x, y, he⟩,\n      have hx : x ∈ A, rw [←hd, mem_dom], use y, rw ←he, assumption,\n      have hy : y ∈ B, apply hr, rw mem_ran, use x, rw ←he, assumption,\n      exact ⟨_, hx, _, hy, he⟩, },\n    { rw [←hd, mem_dom] at hx, apply exists_unique_of_exists_of_unique hx (λ y₁ y₂ hy₁ hy₂, _),\n      refine unique_of_exists_unique (hu x _) hy₁ hy₂,\n      { rw mem_dom, assumption, }, }, },\n  { rintro ⟨hsp, hu⟩, refine ⟨⟨λ p hp, _, λ x hx, _⟩, _, _⟩,\n    { specialize hsp hp, rw mem_prod at hsp, rcases hsp with ⟨x, hx, y, hp, he⟩, exact ⟨_, _, he⟩, },\n    { apply hu, rw mem_dom at hx, rcases hx with ⟨y, hp⟩, specialize hsp hp,\n      rw mem_prod at hsp, rcases hsp with ⟨a, ha, b, hb, he⟩, rw (pair_inj he).left, assumption, },\n    { apply ext, simp only [mem_dom], intro x, split,\n      { rintro ⟨y, hp⟩, specialize hsp hp, rw mem_prod at hsp,\n        rcases hsp with ⟨a, ha, b, hb, he⟩, rw (pair_inj he).left, assumption, },\n      { intro hx, exact exists_of_exists_unique (hu _ hx), }, },\n    { intros y hy, rw mem_ran at hy, rcases hy with ⟨x, hp⟩, specialize hsp hp,\n      rw mem_prod at hsp, rcases hsp with ⟨a, ha, b, hb, he⟩, rw (pair_inj he).right, assumption, }, },\nend\n\nlemma is_function_of_into {F A B : Set} (hf : F.into_fun A B) : F.is_function := hf.left\nlemma dom_eq_of_into {F A B : Set} (hf : F.into_fun A B) : F.dom = A := hf.right.left\nlemma ran_sub_of_into {F A B : Set} (hf : F.into_fun A B) : F.ran ⊆ B := hf.right.right\n\ndef onto_fun (F A B : Set) : Prop := F.is_function ∧ F.dom = A ∧ F.ran = B\ndef one_to_one (F : Set) : Prop := ∀ y : Set, y ∈ F.ran → ∃! x : Set, x.pair y ∈ F -- also called single-rooted\ndef inv (F : Set) : Set := pair_sep (λ a b, b.pair a ∈ F) F.ran F.dom\n\nlemma inv_sub_prod {R A B : Set} (RAB : R ⊆ A.prod B) : R.inv ⊆ B.prod A :=\nbegin\n  intros z zR, simp only [inv, mem_pair_sep] at zR, rcases zR with ⟨a, -, b, -, zab, baR⟩, subst zab,\n  specialize RAB baR, rw mem_prod at RAB, rcases RAB with ⟨c, cA, d, dB, bacd⟩,\n  obtain ⟨bc, ad⟩ := pair_inj bacd, subst bc, subst ad, rw pair_mem_prod, finish,\nend\n\nlemma one_to_one_of {F : Set} (hf : F.is_function)\n(h : ∀ {m : Set}, m ∈ F.dom → ∀ {n : Set}, n ∈ F.dom → m ≠ n → F.fun_value m ≠ F.fun_value n) : F.one_to_one :=\nbegin\n  intros y hy, rw mem_ran at hy, rcases hy with ⟨x, hx⟩, refine ⟨_, hx, _⟩,\n  intros x' hx', apply classical.by_contradiction, intros hne, refine @h x _ x' _ _ _,\n  { rw mem_dom, exact ⟨_, hx⟩, },\n  { rw mem_dom, exact ⟨_, hx'⟩, },\n  { intro he, apply hne, symmetry, assumption, },\n  { rw ←fun_value_def hf hx, rw ←fun_value_def hf hx', },\nend\n\nlemma from_one_to_one {F : Set} (hf : F.is_function) (hoto : F.one_to_one) {x x' : Set}\n(hx : x ∈ F.dom) (hx' : x' ∈ F.dom) (he : F.fun_value x = F.fun_value x') : x = x' :=\nbegin\n  refine unique_of_exists_unique (hoto (F.fun_value x) _) _ _,\n  { apply fun_value_def'' hf, assumption, },\n  { apply fun_value_def' hf, assumption, },\n  { rw he, apply fun_value_def' hf, assumption, },\nend\n\nlemma eq_iff_fun_value_eq_of_oto {F : Set} (hf : F.is_function) (hoto : F.one_to_one) {x x' : Set}\n(hx : x ∈ F.dom) (hx' : x' ∈ F.dom) : x = x' ↔ F.fun_value x = F.fun_value x' :=\n⟨λ xx, xx ▸ rfl, λ fxx, from_one_to_one hf hoto hx hx' fxx⟩\n\nlemma one_to_one_iff {R : Set} : R.one_to_one ↔ ∀ {y x x' : Set}, x.pair y ∈ R → x'.pair y ∈ R → x = x' :=\nbegin\n  simp only [one_to_one, mem_ran], split,\n    intros h y x x' hxy hxy', apply unique_of_exists_unique (h _ ⟨_, hxy⟩) hxy hxy',\n  rintros h y ex, apply exists_unique_of_exists_of_unique ex, intros x x' hxy hxy', exact h hxy hxy',\nend\n\nlemma onto_of_into {F A B : Set} (hf : F.into_fun A B) (he : F.ran = B) : F.onto_fun A B :=\n⟨is_function_of_into hf, dom_eq_of_into hf, he⟩\n\nlemma onto_ran_of_into {F A B : Set} (hf : F.into_fun A B) : F.onto_fun A F.ran := ⟨hf.left, hf.right.left, rfl⟩\n\nlemma into_of_onto {F A B : Set} (hf : F.onto_fun A B) : F.into_fun A B :=\nbegin\n  rcases hf with ⟨hf, hd, hr⟩, refine ⟨hf, hd, _⟩, rw hr, exact subset_self,\nend\n\nlemma into_of_into_ran_sub {F A B C : Set} (h : B ⊆ C) (hf : F.into_fun A B) : F.into_fun A C :=\n⟨hf.left, hf.right.left, subset_trans hf.right.right h⟩\n\nlemma into_of_onto_ran_sub {F A B C : Set} (h : B ⊆ C) (hf : F.onto_fun A B) : F.into_fun A C :=\ninto_of_into_ran_sub h (into_of_onto hf)\n\nlemma singleton_is_fun {x y : Set} : is_function {x.pair y} :=\nbegin\n  rw [is_function_iff], split,\n    exact singleton_is_rel,\n  intros a b b' hab hab', rw [mem_singleton] at hab hab', rw ←hab' at hab,\n  exact (pair_inj hab).right,\nend\n\nlemma union_singleton_is_fun {F : Set} (hF : F.is_function) {x y : Set} (hx : x ∉ F.dom) : (F ∪ {x.pair y}).is_function :=\nbegin\n  rw is_function_iff, split,\n    exact union_rel_is_rel hF.left singleton_is_rel,\n  intros a b b' hb hb', rw [mem_union, mem_singleton] at hb hb',\n  rw is_function_iff at hF,\n  cases hb; cases hb',\n        exact hF.right _ _ _ hb hb',\n      exfalso, apply hx, rw mem_dom, rw (pair_inj hb').left at hb, exact ⟨_, hb⟩,\n    exfalso, apply hx, rw mem_dom, rw (pair_inj hb).left at hb', exact ⟨_, hb'⟩,\n  rw ←hb' at hb, exact (pair_inj hb).right,\nend\n\nlemma union_singleton_one_to_one {F : Set} (hF : F.one_to_one) {x y : Set} (hy : y ∉ F.ran) : (F ∪ {x.pair y}).one_to_one :=\nbegin\n  rw one_to_one_iff at *, simp only [mem_union, mem_singleton],\n  rintros b a a' (hab|hab) (hab'|hab'),\n        exact hF hab hab',\n      exfalso, apply hy, rw mem_ran, rw (pair_inj hab').right at hab, exact ⟨_, hab⟩,\n    exfalso, apply hy, rw mem_ran, rw (pair_inj hab).right at hab', exact ⟨_, hab'⟩,\n  rw [(pair_inj hab).left, (pair_inj hab').left],\nend\n\n@[simp]\nlemma mem_inv {F p : Set} : p ∈ F.inv ↔ ∃ (a b : Set), p = a.pair b ∧ b.pair a ∈ F :=\nbegin\n  simp only [inv, mem_pair_sep], split,\n  { rintro ⟨a, ha, b, hb, he, hm⟩,\n    exact ⟨_, _, he, hm⟩, },\n  { rintro ⟨a, b, he, hm⟩,\n    refine ⟨_, _, _, _, he, hm⟩,\n    rw mem_ran, exact ⟨_, hm⟩,\n    rw mem_dom, exact ⟨_, hm⟩, },\nend\n\nlemma inv_rel {F : Set} : F.inv.is_rel := pair_sep_is_rel\n\n@[simp]\nlemma pair_mem_inv {F a b : Set} : a.pair b ∈ F.inv ↔ b.pair a ∈ F :=\nbegin\n  simp only [mem_inv], split,\n  { rintro ⟨x, y, he, hm⟩,\n    suffices hinj : a = x ∧ b = y,\n      rw hinj.left, rw hinj.right, assumption,\n    exact pair_inj he, },\n  { intro h, exact ⟨a, b, rfl, h⟩, },\nend\n\nlemma inv_inv {F : Set} (hf : F.is_rel) : F.inv.inv = F :=\nbegin\n  apply rel_eq inv_rel hf, simp only [pair_mem_inv], finish,\nend\n\ndef comp (F G : Set) : Set := pair_sep (λ a b, ∃ t : Set, a.pair t ∈ G ∧ t.pair b ∈ F) G.dom F.ran\n\nlemma comp_rel {F G : Set} : (F.comp G).is_rel := pair_sep_is_rel\n\n@[simp]\nlemma mem_comp {F G p : Set} : p ∈ F.comp G ↔ ∃ (a b c : Set), p = a.pair c ∧ a.pair b ∈ G ∧ b.pair c ∈ F :=\nbegin\n  simp only [comp, mem_pair_sep], split,\n  { rintro ⟨a, ha, b, hb, he, t, hm1, hm2⟩,\n    exact ⟨a, t, b, he, hm1, hm2⟩, },\n  { rintro ⟨a, b, c, he, hm1, hm2⟩,\n    refine ⟨a, _, c, _, he, _, hm1, hm2⟩,\n      rw mem_dom, exact ⟨_, hm1⟩,\n      rw mem_ran, exact ⟨_, hm2⟩, },\nend\n\n@[simp]\nlemma pair_mem_comp {F G a c : Set} : a.pair c ∈ F.comp G ↔ ∃ b : Set, a.pair b ∈ G ∧ b.pair c ∈ F :=\nbegin\n  simp only [mem_comp], split,\n  { rintro ⟨a', b, c', he, hg, hf⟩,\n    have hinj : a = a' ∧ c = c' := pair_inj he,\n    rw hinj.left, rw hinj.right,\n    exact ⟨_, hg, hf⟩, },\n  { rintro ⟨b, hg, hf⟩,\n    exact ⟨_, _, _, rfl, hg, hf⟩, },\nend\n\ndef restrict (F A : Set) : Set := pair_sep (λ a b, a.pair b ∈ F ∧ a ∈ A) F.dom F.ran\n\nlemma restrict_is_rel {F A : Set} : (F.restrict A).is_rel := pair_sep_is_rel\n\n@[simp]\nlemma mem_restrict {F A p : Set} : p ∈ F.restrict A ↔ ∃ (a b : Set), p = a.pair b ∧ a.pair b ∈ F ∧ a ∈ A :=\nbegin\n  simp only [restrict, mem_pair_sep], split; intro h,\n    rcases h with ⟨a, H₁, b, H₂, h₁, h₂, h₃⟩, exact ⟨_, _, h₁, h₂, h₃⟩,\n  rcases h with ⟨a, b, h₁, h₂, h₃⟩,\n  refine ⟨a, _, b, _, _⟩,\n  simp only [mem_dom], exact ⟨_, h₂⟩,\n  simp only [mem_ran], exact ⟨_, h₂⟩,\n  exact ⟨h₁, h₂, h₃⟩,\nend\n\n@[simp]\nlemma pair_mem_restrict {F A x y : Set} : x.pair y ∈ F.restrict A ↔ x.pair y ∈ F ∧ x ∈ A :=\nbegin\n  simp, split,\n  { rintro ⟨a, b, he, hp, hm⟩, rw he, rw (pair_inj he).left, finish, },\n  { rintro ⟨hp, hm⟩, exact ⟨_, _, rfl, hp, hm⟩, },\nend\n\nlemma restrict_empty {F : Set} : F.restrict ∅ = ∅ :=\nbegin\n  simp only [rel_eq_empty restrict_is_rel, pair_mem_restrict], rintros x y ⟨-, h⟩,\n  exact mem_empty _ h,\nend\n\nlemma restrict_combine {F : Set} (hf : F.is_rel) {A B : Set} (hd : A ∪ B = F.dom) : F.restrict A ∪ F.restrict B = F :=\nbegin\n  apply ext, simp only [mem_union, mem_restrict], intro p, split,\n  { rintro (⟨a, b, he, hp, hm⟩|⟨a, b, he, hp, hm⟩),\n    { rw he, exact hp, },\n    { rw he, exact hp, }, },\n  { intro hp, have h := hf _ hp, rcases h with ⟨x, y, h⟩,\n    have hx : x ∈ F.dom, rw mem_dom, finish,\n    rw ←hd at hx, rw mem_union at hx, rcases hx with hx|hx,\n    { finish, },\n    { finish, }, },\nend\n\nlemma restrict_singleton_eq {F : Set} (hf : F.is_function) {x : Set} (hx : x ∈ F.dom) : F.restrict {x} = {x.pair (F.fun_value x)} :=\nbegin\n  apply ext, intro p, simp only [mem_singleton, mem_restrict], split,\n  { rintro ⟨x', y, he, hp, hm⟩, rw he, congr,\n    { exact hm, },\n    { rw ←hm, exact fun_value_def hf hp, }, },\n  { rintro he, refine ⟨_, _, he, _, rfl⟩, exact fun_value_def' hf hx, },\nend\n\nlemma restrict_is_function {F : Set} (hf : F.is_function) {A : Set} : (F.restrict A).is_function :=\nbegin\n  rw is_function_iff, split,\n  { intro z, rw [mem_restrict], rintro ⟨x, y, he, hp, hx⟩, exact ⟨_, _, he⟩, },\n  { simp only [pair_mem_restrict], rintros x y y' ⟨hp, hx⟩ ⟨hp', -⟩,\n    rw is_function_iff at hf, exact hf.right x y y' hp hp', },\nend\n\nlemma restrict_fun_value {F : Set} (hf : F.is_function) {A : Set} (hA : A ⊆ F.dom) {x : Set} (hx : x ∈ A) : (F.restrict A).fun_value x = F.fun_value x :=\nbegin\n  symmetry, apply fun_value_def (restrict_is_function hf), rw pair_mem_restrict,\n  refine ⟨fun_value_def' hf (hA hx), hx⟩,\nend\n\nlemma restrict_dom {F A : Set} (hA : A ⊆ F.dom) : (F.restrict A).dom = A :=\nbegin\n  apply ext, intro x, simp only [mem_dom, pair_mem_restrict, and_iff_right_iff_imp, exists_and_distrib_right],\n  intro hxA, rw ←mem_dom, exact hA hxA,\nend\n\nlemma restrict_dom_inter {F A : Set} : (F.restrict A).dom = F.dom ∩ A :=\nbegin\n  apply ext,\n  simp only [mem_dom, mem_inter, pair_mem_restrict, iff_self, exists_and_distrib_right, implies_true_iff],\nend\n\nlemma restrict_fun_value' {F : Set} (hf : F.is_function) {x : Set} (hx : x ∈ F.dom) {A : Set} (hxA : x ∈ A) : (F.restrict A).fun_value x = F.fun_value x :=\nbegin\n  symmetry, apply fun_value_def (restrict_is_function hf), rw pair_mem_restrict,\n  exact ⟨fun_value_def' hf hx, hxA⟩,\nend\n\nlemma restrict_subset {F A : Set} : F.restrict A ⊆ F :=\nbegin\n  apply rel_sub restrict_is_rel, intros x y, rw pair_mem_restrict, finish,\nend\n\nlemma restrict_one_to_one {F : Set} (hf : F.is_function) (hoto : F.one_to_one) {A : Set} (hA : A ⊆ F.dom) : (F.restrict A).one_to_one :=\nbegin\n  apply one_to_one_of (restrict_is_function hf),\n  intros x hx x' hx' hne he,\n  rw [restrict_dom hA] at *,\n  rw [restrict_fun_value hf hA hx, restrict_fun_value hf hA hx'] at he, apply hne,\n  exact from_one_to_one hf hoto (hA hx) (hA hx') he,\nend\n\ndef img (F A : Set) : Set := (F.restrict A).ran\n\n@[simp]\nlemma mem_img {F A y : Set} : y ∈ F.img A ↔ ∃ x : Set, x ∈ A ∧ x.pair y ∈ F :=\nbegin\n  simp only [img, mem_ran, mem_restrict], split,\n    rintro ⟨t, a, b, h₁, h₂, h₃⟩,\n    have h₄ : y = b := (pair_inj h₁).right,\n    subst h₄,\n    exact ⟨_, h₃, h₂⟩,\n  rintro ⟨x, h₁, h₂⟩,\n  exact ⟨x, x, y, rfl, h₂, h₁⟩,\nend\n\nlemma mem_img' {F A y : Set} (h : F.is_function) (h' : A ⊆ F.dom) : y ∈ F.img A ↔ ∃ x : Set, x ∈ A ∧ y = F.fun_value x :=\nbegin\n  simp only [mem_img],\n  split,\n    rintro ⟨x, h₁, h₂⟩,\n    refine ⟨_, h₁, fun_value_def h h₂⟩,\n  rintros ⟨x, h₁, h₂⟩,\n  rw h₂,\n  refine ⟨_, h₁, _⟩,\n  apply fun_value_def', exact h,\n  exact h' h₁,\nend\n\nlemma fun_value_mem_img {F : Set} (hf : F.is_function) {A : Set} (hd : A ⊆ F.dom) {x : Set} (h : x ∈ A) : F.fun_value x ∈ F.img A :=\nbegin\n  rw mem_img' hf hd, exact ⟨_, h, rfl⟩,\nend\n\nlemma img_subset_ran {F A : Set} : F.img A ⊆ F.ran :=\nbegin\n  intro y, simp only [mem_img, mem_ran, and_imp, exists_imp_distrib],\n  intros x hxA hxyF, exact ⟨_, hxyF⟩,\nend\n\nlemma img_singleton_eq {F : Set} (hF : F.is_function) {x : Set} (hx : x ∈ F.dom) : F.img {x} = {F.fun_value x} :=\nbegin\n  have h : {x} ⊆ F.dom, intros z hz, rw mem_singleton at hz, subst hz, exact hx,\n  apply ext, simp only [mem_singleton, mem_img' hF h], intro z, split,\n    rintro ⟨x', hx', hz⟩, subst hx', exact hz,\n  intro hz, exact ⟨_, rfl, hz⟩,\nend\n\nlemma restrict_ran {F A : Set} : (F.restrict A).ran = F.img A :=\nbegin\n  apply ext, intro y, simp only [mem_ran, mem_img, pair_mem_restrict, and_comm],\nend\n\nlemma img_fun_eq {A : Set} {f : Set} (hf : f.is_function) (Af : A ⊆ f.dom) {g : Set} (hg : g.is_function) (Ag : A ⊆ g.dom)\n  (h : ∀ {a : Set}, a ∈ A → f.fun_value a = g.fun_value a) : f.img A = g.img A :=\next (λ y, calc\n  y ∈ f.img A ↔ ∃ x : Set, x ∈ A ∧ y = f.fun_value x : by rw mem_img' hf Af\n  ... ↔ ∃ x : Set, x ∈ A ∧ y = g.fun_value x : exists_congr (λ x, and_congr_right (λ xA, eq.congr_right (h xA)))\n  ... ↔ y ∈ g.img A : by rw mem_img' hg Ag)\n\nlemma restrict_into_fun {F D₁ D₂ R : Set} (hF : F.into_fun D₁ R) (h : D₂ ⊆ D₁) : (F.restrict D₂).into_fun D₂ R :=\nbegin\n  refine ⟨restrict_is_function hF.left, _, _⟩,\n  { rw ←hF.right.left at h, exact restrict_dom h, },\n  { rw restrict_ran, exact subset_trans img_subset_ran hF.right.right, },\nend\n\nlemma img_ne_ran_of_ne_dom {F : Set} (hF : F.is_function) (hF' : F.one_to_one) {A : Set} (hAsub : A ⊆ F.dom) (hAne : A ≠ F.dom) : F.img A ≠ F.ran :=\nbegin\n  intro he, apply hAne, rw eq_iff_subset_and_subset, refine ⟨hAsub, _⟩, intros x hx,\n  rw mem_dom at hx, rcases hx with ⟨y, hx⟩,\n  have hy : y ∈ F.ran, rw mem_ran, exact ⟨_, hx⟩,\n  rw [←he, mem_img] at hy, rcases hy with ⟨x', hx', hy⟩,\n  have hxx' : x = x', apply unique_of_exists_unique,\n    { refine hF' y _, rw mem_ran, exact ⟨_, hx⟩, },\n    { exact hx, },\n    { exact hy, },\n  rw hxx', exact hx',\nend\n\nlemma one_to_one_ext {F : Set} (hf : F.is_function) (ha : ∀ x y : Set, x ∈ F.dom → y ∈ F.dom → F.fun_value x = F.fun_value y → x = y) : F.one_to_one :=\nbegin\n  intros y hy,\n  apply exists_unique_of_exists_of_unique,\n    simp only [mem_ran] at hy, exact hy,\n  intros x x' hx hx',\n  apply ha x x',\n  rw mem_dom, exact ⟨_, hx⟩,\n  rw mem_dom, exact ⟨_, hx'⟩,\n  rw ←fun_value_def hf hx,\n  rw ←fun_value_def hf hx',\nend\n\n@[simp]\ntheorem T3E_a {F : Set} : F.inv.dom = F.ran :=\nbegin\n  apply ext, intro z, simp only [mem_dom, mem_ran, pair_mem_inv],\nend\n\n@[simp]\ntheorem T3E_b {F : Set} : F.inv.ran = F.dom :=\nbegin\n  apply ext, intro z, simp only [mem_ran, mem_dom, pair_mem_inv],\nend\n\ntheorem T3E_c {F : Set} (h : F.is_rel) : F.inv.inv = F :=\nbegin\n  apply ext, intro z, rw mem_inv, simp only [pair_mem_inv], split,\n  { rintro ⟨a, b, he, hm⟩, rw he, assumption, },\n  { intro hm,\n    specialize h _ hm,\n    rcases h with ⟨a, b, he⟩,\n    rw he at hm,\n    exact ⟨_, _, he, hm⟩, },\nend\n\ntheorem T3F_a {F : Set} : F.inv.is_function ↔ F.one_to_one :=\nbegin\n  simp only [is_function, one_to_one, and_iff_right inv_rel, T3E_a, pair_mem_inv],\nend\n\ntheorem T3F_b {F : Set} (h : F.is_rel) : F.is_function ↔ F.inv.one_to_one :=\nbegin\n  simp only [is_function, one_to_one, and_iff_right h, T3E_b, pair_mem_inv],\nend\n\ntheorem T3G_a {F : Set} (hf : F.is_function) (ho : F.one_to_one) : ∀ x ∈ F.dom, F.inv.fun_value (F.fun_value x) = x :=\nbegin\n  intros x hm,\n  have hp : x.pair (F.fun_value x) ∈ F := fun_value_def' hf hm,\n  have hpinv : (F.fun_value x).pair x ∈ F.inv,\n    simp only [pair_mem_inv],\n    exact hp,\n  have hinvfun : F.inv.is_function := T3F_a.mpr ho,\n  symmetry,\n  exact fun_value_def hinvfun hpinv,\nend\n\ntheorem T3G_b {F : Set} (hf : F.is_function) (ho : F.one_to_one) : ∀ y ∈ F.ran, F.fun_value (F.inv.fun_value y) = y :=\nbegin\n  intros y hm,\n  rw ←T3E_a at hm,\n  have hinvfun : F.inv.is_function := T3F_a.mpr ho,\n  have hinvoto : F.inv.one_to_one := (T3F_b hf.left).mp hf,\n  have h : F.inv.inv.fun_value (F.inv.fun_value y) = y := T3G_a hinvfun hinvoto y hm,\n  rw T3E_c hf.left at h,\n  exact h,\nend\n\ntheorem T3H_a {F G : Set} (hf : F.is_function) (hg : G.is_function) : (F.comp G).is_function :=\nbegin\n  split,\n    intros p hp, rw mem_comp at hp,\n    rcases hp with ⟨a, b, c, he, hmg, hmf⟩,\n    exact ⟨_, _, he⟩,\n  intros p hp,\n  rw mem_dom at hp,\n  rcases hp with ⟨y, hp⟩,\n  refine ⟨_, hp, _⟩,\n  intros w hw,\n  simp only [pair_mem_comp] at hp,\n  simp only [pair_mem_comp] at hw,\n  rcases hp with ⟨u, hu⟩,\n  rcases hw with ⟨v, hv⟩,\n  have h : u = v := fun_lemma hg hu.left hv.left,\n  rw h at hu,\n  apply fun_lemma hf,\n  exact hv.right,\n  exact hu.right,\nend\n\ntheorem T3H_b {F G : Set} (hf : F.is_function) (hg : G.is_function) : (F.comp G).dom = {x ∈ G.dom | G.fun_value x ∈ F.dom} :=\nbegin\n  apply ext, intro x, simp only [mem_sep, mem_dom, pair_mem_comp],\n  split,\n  { rintro ⟨y, t, hx, ht⟩,\n    refine ⟨⟨t, hx⟩, y, _⟩,\n    rw ←fun_value_def hg hx,\n    exact ht, },\n  { rintro ⟨⟨t, ht⟩, y, hy⟩,\n    refine ⟨y, _, ht, _⟩,\n    rw fun_value_def hg ht,\n    exact hy, },\nend\n\ntheorem T3H_c {F G x : Set} (hf : F.is_function) (hg : G.is_function) (hd : x ∈ (F.comp G).dom) : (F.comp G).fun_value x = F.fun_value (G.fun_value x) :=\nbegin\n  simp only [T3H_b hf hg, mem_sep, mem_dom] at hd,\n  rcases hd with ⟨⟨t, ht⟩, y, hy⟩,\n  symmetry,\n  apply fun_value_def (T3H_a hf hg),\n  simp only [pair_mem_comp],\n  refine ⟨_, ht, _⟩,\n  rw ←fun_value_def hf hy,\n  rw fun_value_def hg ht,\n  exact hy,\nend\n\ntheorem T3I {F G : Set} : (F.comp G).inv = G.inv.comp F.inv :=\nbegin\n  apply ext, intro z, simp only [mem_inv, pair_mem_comp, mem_comp, pair_mem_inv],\n  split,\n  { rintro ⟨a, b, he, b', t, a', hpe, hg, hf⟩,\n    have hinj : b = b' ∧ a = a' := pair_inj hpe,\n    refine ⟨a, t, b, he, _, _⟩,\n      rw hinj.right,\n      assumption,\n    rw hinj.left,\n    assumption, },\n  { rintro ⟨a, t, b, he, hf, hg⟩,\n    exact ⟨a, b, he, b, t, a, rfl, hg, hf⟩, },\nend\n\ntheorem inv_onto_of_onto {F A B : Set} (Fonto : F.onto_fun A B) (Foto : F.one_to_one) : F.inv.onto_fun B A :=\nbegin\n  rw [onto_fun, T3F_a, T3E_a, T3E_b, Fonto.right.right],\n  exact ⟨Foto, rfl, Fonto.right.left⟩,\nend\n\nlemma dom_comp_sub {F G : Set} : (F.comp G).dom ⊆ G.dom :=\nbegin\n  intros x hx, simp only [mem_dom, pair_mem_comp] at *, finish,\nend\n\nlemma dom_comp {F G : Set} (h : G.ran ⊆ F.dom) : (F.comp G).dom = G.dom :=\nbegin\n  rw eq_iff_subset_and_subset, split,\n  { exact dom_comp_sub, },\n  { intros x hx, simp only [mem_dom, pair_mem_comp] at *,\n    rcases hx with ⟨y, hy⟩,\n    have hd : y ∈ F.dom, apply h, rw mem_ran, finish,\n    rw mem_dom at hd, finish, },\nend\n\nlemma ran_comp_sub {F G : Set} : (F.comp G).ran ⊆ F.ran :=\nbegin\n  rw [←T3E_a, T3I, ←T3E_a], exact dom_comp_sub,\nend\n\nlemma ran_comp {F G : Set} (h : F.dom ⊆ G.ran) : (F.comp G).ran = F.ran :=\nbegin\n  rw [←T3E_a, ←T3E_b] at h, rw [←T3E_a, T3I, ←T3E_a], exact dom_comp h,\nend\n\nlemma ran_comp_complex {f g : Set} (hf : f.one_to_one) : (f.comp g).ran = f.ran \\ f.img (f.dom \\ g.ran) :=\nbegin\n  apply ext, simp only [mem_ran, pair_mem_comp, mem_diff, mem_img, mem_dom], intro y, split,\n    rintro ⟨z, x, hzx, hxy⟩, refine ⟨⟨_, hxy⟩, _⟩, rintro ⟨x', ⟨⟨y', hxy'⟩, he⟩, hx'y⟩,\n    apply he, rw one_to_one_iff at hf, specialize hf hxy hx'y, rw ←hf, exact ⟨_, hzx⟩,\n  rintro⟨⟨z, hzy⟩, hne⟩, apply classical.by_contradiction, intro hne', apply hne,\n  refine ⟨_, ⟨⟨_, hzy⟩, _⟩, hzy⟩, rintro ⟨x', hx'z⟩, apply hne', exact ⟨_, _, hx'z, hzy⟩,\nend\n\nlemma comp_into_fun {A B C f : Set} (hf : f.into_fun A B) {g : Set} (hg : g.into_fun B C) : (g.comp f).into_fun A C :=\nbegin\n  refine ⟨T3H_a hg.left hf.left, _, _⟩,\n  { have h : f.ran ⊆ g.dom, rw hg.right.left, exact hf.right.right,\n    rw ←hf.right.left, exact dom_comp h, },\n  { apply subset_trans, exact ran_comp_sub, exact hg.right.right, },\nend\n\nlemma inv_into_fun {f A B : Set} (hfun : f.onto_fun A B) (foto : f.one_to_one) : f.inv.into_fun B A :=\nbegin\n  refine ⟨T3F_a.mpr foto, _, _⟩,\n  { rw T3E_a, exact hfun.right.right, },\n  { rw [T3E_b, hfun.right.left], exact subset_self, },\nend\n\nlemma fun_ext {F G : Set} (hf : F.is_function) (hg : G.is_function) (hd : F.dom = G.dom) (ha : ∀ x ∈ F.dom, F.fun_value x = G.fun_value x) : F = G :=\nbegin\n  have h : ∀ F G : Set, F.is_function → G.is_function → F.dom = G.dom → (∀ x ∈ F.dom, F.fun_value x = G.fun_value x) → ∀ z : Set, z ∈ F → z ∈ G,\n    intros F G hf hg hd ha z hm,\n    have hp : z.is_pair := hf.left _ hm,\n    rcases hp with ⟨x, y, hp⟩, subst hp,\n    have hxd : x ∈ F.dom, simp only [mem_dom], exact ⟨_, hm⟩,\n    specialize ha _ hxd,\n    rw ←fun_value_def hf hm at ha,\n    rw ha,\n    rw hd at hxd,\n    exact fun_value_def' hg hxd,\n  apply ext, intro z, split,\n  { exact h F G hf hg hd ha z, },\n  { refine h G F hg hf hd.symm _ z,\n    rw ←hd, intros x hx, exact (ha x hx).symm, },\nend\n\nlemma union_of_rel_is_rel {A B : Set} (hA : A.is_rel) (hB : B.is_rel) : (A ∪ B).is_rel :=\nbegin\n  intros x hx,\n  simp only [mem_union] at hx,\n  cases hx,\n    exact hA _ hx,\n  exact hB _ hx,\nend\n\ndef id (A : Set) : Set := pair_sep (λ a b, a = b) A A\n\nlemma id_is_function {A : Set} : A.id.is_function :=\nbegin\n  refine ⟨pair_sep_is_rel, _⟩,\n  simp only [mem_dom, pair_mem_pair_sep, id],\n  rintros x ⟨y, hx⟩,\n  refine ⟨y, hx, _⟩,\n  intros y' hy,\n  rw ←hx.right.right,\n  rw ←hy.right.right,\nend\n\nlemma id_onto {A : Set} : A.id.onto_fun A A :=\nbegin\n  simp only [onto_fun],\n  refine ⟨id_is_function, _, _⟩,\n    apply ext, simp only [mem_dom, id, pair_mem_pair_sep],\n    intro z, split,\n    { rintro ⟨y, h, _⟩, exact h, },\n    { intro h, exact ⟨_, h, h, rfl⟩, },\n  apply ext, simp only [mem_ran, id, pair_mem_pair_sep],\n  intro z, split,\n  { rintro ⟨x, _, h, _⟩, exact h, },\n  { intro h, exact ⟨_, h, h, rfl⟩, },\nend\n\nlemma id_into {A : Set} : A.id.into_fun A A := into_of_onto id_onto\n\nlemma id_value {A x : Set} (hx : x ∈ A) : A.id.fun_value x = x :=\nbegin\n  have h : x.pair x ∈ A.id,\n    simp only [id, pair_mem_pair_sep],\n    exact ⟨hx, hx, rfl⟩,\n  rw ←fun_value_def id_is_function h,\nend\n\nlemma id_singleton_value {x : Set} : (id {x}).fun_value x = x :=\nid_value ((@mem_singleton _ _).mpr rfl)\n\nlemma id_oto {A : Set} : A.id.one_to_one :=\nbegin\n  apply one_to_one_of id_is_function, intros m hm n hn hne he, apply hne,\n  rw id_onto.right.left at hm, rw id_onto.right.left at hn,\n  rw ←id_value hm, rw he, rw id_value hn,\nend\n\nlemma id_inv {A : Set} : A.id.inv = A.id :=\nbegin\n  apply rel_eq inv_rel id_is_function.left,\n  simp only [pair_mem_inv, id, pair_mem_pair_sep],finish,\nend\n\nlemma comp_id {f : Set} (hf : f.is_function) : f.comp f.dom.id = f :=\nbegin\n  have hd : (f.comp f.dom.id).dom = f.dom,\n    have h : f.dom.id.ran ⊆ f.dom, rw id_onto.right.right, exact subset_self,\n    rw [dom_comp h, id_onto.right.left],\n  apply fun_ext (T3H_a hf id_is_function) hf hd,\n  intros x hx, rw T3H_c hf id_onto.left hx, rw hd at hx, rw id_value hx,\nend\n\nlemma id_comp {A f : Set} (hA : f.ran ⊆ A) (hf : f.is_function) : A.id.comp f = f :=\nbegin\n  have hd : (A.id.comp f).dom = f.dom,\n    have h : f.ran ⊆ A.id.dom, rw id_onto.right.left, exact hA,\n    rw dom_comp h,\n  apply fun_ext (T3H_a id_is_function hf) hf hd,\n  intros x hx, rw T3H_c id_onto.left hf hx,\n  have h : f.fun_value x ∈ A, apply hA, apply fun_value_def'' hf, rw hd at hx, exact hx,\n  rw id_value h,\nend\n\nlemma eq_id {f : Set} (hf : f.is_function) (hf' : f.one_to_one) : f.inv.comp f = f.dom.id :=\nbegin\n  apply ext, intro z, simp only [mem_comp, id, mem_pair_sep, exists_prop, mem_dom, pair_mem_inv], split,\n  { rintro ⟨x, y, x', he, hxy, hxy'⟩, refine ⟨_, ⟨_, hxy⟩, _, ⟨_, hxy'⟩, he, _⟩,\n    refine unique_of_exists_unique _ hxy hxy', apply hf', rw mem_ran, exact ⟨_, hxy⟩, },\n  { rintro ⟨x, ⟨y, hxy⟩, x', ⟨y', hxy'⟩, he, hxx'⟩, rw hxx' at hxy he,\n    have hyy' : y = y', refine unique_of_exists_unique _ hxy hxy', apply hf.right,\n      rw mem_dom, exact ⟨_, hxy⟩,\n    rw hyy' at hxy, exact ⟨_, _, _, he, hxy, hxy⟩, },\nend\n\nlemma eq_inv_id {f : Set} (hf : f.is_function) (hf' : f.one_to_one) : f.comp f.inv = f.ran.id :=\nbegin\n  have h : f.inv.inv.comp f.inv = f.inv.dom.id, apply eq_id,\n    { rw T3F_a, exact hf' },\n    { rw ←T3F_b hf.left, exact hf, },\n  rw [inv_inv hf.left, T3E_a] at h, exact h,\nend\n\nlemma union_fun {F G : Set} (hf : F.is_function) (hg : G.is_function) (hdisj : F.dom ∩ G.dom = ∅) : (F ∪ G).onto_fun (F.dom ∪ G.dom) (F.ran ∪ G.ran) :=\nbegin\n  have hd : (F ∪ G).dom = F.dom ∪ G.dom,\n    apply ext, simp only [mem_dom, mem_union],\n    intro z,\n    exact exists_or_distrib,\n  split,\n  { refine ⟨union_of_rel_is_rel hf.left hg.left, _⟩,\n    simp only [hd, mem_union, mem_dom],\n    rintros x (⟨y, hmf⟩ | ⟨y, hmg⟩),\n    { refine ⟨y, or.inl hmf, _⟩,\n      rintros z (hz | hz),\n      exact fun_lemma hf hz hmf,\n      exfalso,\n      apply mem_empty x,\n      simp only [←hdisj, mem_inter, mem_dom],\n      exact ⟨⟨_, hmf⟩, _, hz⟩, },\n    { refine ⟨y, or.inr hmg, _⟩,\n      rintros z (hz | hz),\n      exfalso,\n      apply mem_empty x,\n      simp only [←hdisj, mem_inter, mem_dom],\n      exact ⟨⟨_, hz⟩, _, hmg⟩,\n      exact fun_lemma hg hz hmg, }, },\n  refine ⟨hd, _⟩,\n  apply ext, simp only [mem_ran, mem_union],\n  intro z,\n  exact exists_or_distrib,\nend\n\nlemma union_dom {F G : Set} : (F ∪ G).dom = F.dom ∪ G.dom :=\nbegin\n  apply ext, simp only [mem_dom, mem_union, exists_or_distrib, forall_const, iff_self],\nend\n\nlemma union_fun_into_fun {F G D₁ D₂ R : Set} (hF : F.into_fun D₁ R) (hG : G.into_fun D₂ R) (hdisj : D₁ ∩ D₂ = ∅) : (F ∪ G).into_fun (D₁ ∪ D₂) R :=\nbegin\n  have onto : (F ∪ G).onto_fun (F.dom ∪ G.dom) (F.ran ∪ G.ran), apply union_fun hF.left hG.left, rw [hF.right.left, hG.right.left], exact hdisj,\n  rw [←hF.right.left, ←hG.right.left], refine ⟨onto.left, onto.right.left, _⟩,\n  rw onto.right.right, exact union_subset_of_subset_of_subset hF.right.right hG.right.right,\nend\n\nlemma ran_union {F G : Set} : (F ∪ G).ran = F.ran ∪ G.ran :=\nbegin\n  apply ext, intro x, simp only [mem_ran, mem_union], exact exists_or_distrib,\nend\n\nlemma union_fun_value_left {F G D₁ D₂ R₁ R₂ : Set} (Fonto : F.onto_fun D₁ R₁) (Gonto : G.onto_fun D₂ R₂) (disj : D₁ ∩ D₂ = ∅)\n  {x : Set} (xD : x ∈ D₁) : (F ∪ G).fun_value x = F.fun_value x :=\nbegin\n  symmetry, refine fun_value_def (union_fun Fonto.left Gonto.left _).left _,\n    rw [Fonto.right.left, Gonto.right.left], exact disj,\n  rw mem_union, left, apply fun_value_def' Fonto.left, rw Fonto.right.left, exact xD,\nend\n\nlemma union_fun_value_right {F G D₁ D₂ R₁ R₂ : Set} (Fonto : F.onto_fun D₁ R₁) (Gonto : G.onto_fun D₂ R₂) (disj : D₁ ∩ D₂ = ∅)\n  {x : Set} (xD : x ∈ D₂) : (F ∪ G).fun_value x = G.fun_value x :=\nbegin\n  symmetry, refine fun_value_def (union_fun Fonto.left Gonto.left _).left _,\n    rw [Fonto.right.left, Gonto.right.left], exact disj,\n  rw mem_union, right, apply fun_value_def' Gonto.left, rw Gonto.right.left, exact xD,\nend\n\nlemma ran_single_pair {x y : Set} : ({x.pair y} : Set).ran = {y} :=\nbegin\n  apply ext, intro y, simp only [mem_ran, mem_singleton], split,\n  { rintro ⟨x, hx⟩, exact (pair_inj hx).right, },\n  { intro hy, rw hy, exact ⟨_, rfl⟩, },\nend\n\nlemma union_one_to_one {f : Set} (hf : f.one_to_one) {g : Set} (hg : g.one_to_one) (hfg : f.ran ∩ g.ran = ∅) : (f ∪ g).one_to_one :=\nbegin\n  intros y hy, simp only [mem_ran, mem_union] at hy, simp only [mem_union], rcases hy with ⟨x, hx|hx⟩,\n  { refine ⟨_, or.inl hx, _⟩,\n    have hyfr : y ∈ f.ran, rw mem_ran, exact ⟨_, hx⟩,\n    rintros x' (hx'|hx'),\n    { apply unique_of_exists_unique (hf _ hyfr) hx' hx, },\n    { have hygr : y ∈ g.ran, rw mem_ran, exact ⟨_, hx'⟩,\n      exfalso, apply mem_empty y, rw [←hfg, mem_inter], exact ⟨hyfr, hygr⟩, }, },\n  { refine ⟨_, or.inr hx, _⟩,\n    have hygr : y ∈ g.ran, rw mem_ran, exact ⟨_, hx⟩,\n    rintros x' (hx'|hx'),\n    { have hyfr : y ∈ f.ran, rw mem_ran, exact ⟨_, hx'⟩,\n      exfalso, apply mem_empty y, rw [←hfg, mem_inter], exact ⟨hyfr, hygr⟩, },\n    { apply unique_of_exists_unique (hg _ hygr) hx' hx, }, },\nend\n\nlemma restrict_union_eq {F G : Set} (hF : F.is_rel) (hdisj : F.dom ∩ G.dom = ∅) : (F ∪ G).restrict F.dom = F :=\nbegin\n  apply rel_eq restrict_is_rel hF, simp only [pair_mem_restrict, mem_union], intros x y, split,\n  { rintro ⟨(hxy|hxy), hd⟩,\n      exact hxy,\n    exfalso, apply mem_empty x, rw ←hdisj, rw mem_inter, refine ⟨hd, _⟩, rw mem_dom, exact ⟨_, hxy⟩, },\n  { intro hxy, rw mem_dom, refine ⟨or.inl hxy, _, hxy⟩, },\nend\n\nlemma single_pair_oto {x y : Set} : ({x.pair y} : Set).one_to_one :=\nbegin\n  intros z hz, rw [ran_single_pair, mem_singleton] at hz, simp only [mem_singleton, hz],\n  refine ⟨_, rfl, _⟩, intros x' hx', exact (pair_inj hx').left,\nend\n\nlemma single_pair_into {x y R : Set} (hy : y ∈ R) : ({x.pair y} : Set).into_fun {x} R :=\nbegin\n  rw fun_def_equiv, split,\n    intros p hp, rw mem_singleton at hp, rw [hp, pair_mem_prod, mem_singleton], exact ⟨rfl, hy⟩,\n  simp only [mem_singleton], intros z he, rw he, exact ⟨_, rfl, λ y' he', (pair_inj he').right⟩,\nend\n\nlemma single_pair_fun_value {x y : Set} : ({x.pair y} : Set).fun_value x = y :=\nbegin\n  symmetry, apply fun_value_def (@single_pair_into _ _ {y} _).left,\n    rw mem_singleton,\n  rw mem_singleton,\nend\n\nlemma single_pair_onto {x y : Set} : onto_fun {x.pair y} {x} {y} :=\nbegin\n  apply onto_of_into,\n    apply single_pair_into, rw mem_singleton,\n  exact ran_single_pair,\nend\n\nlemma prod_singleton_fun {A x : Set} : (A.prod {x}).is_function :=\nbegin\n  refine ⟨prod_is_rel, _⟩,\n  simp only [mem_dom, mem_singleton, pair_mem_prod],\n  rintros z ⟨y, hy⟩,\n  refine ⟨y, hy, _⟩,\n  intros y' hy',\n  rw hy'.right, symmetry, exact hy.right,\nend\n\nlemma empty_fun : is_function ∅ :=\nbegin\n  rw is_function_iff, refine ⟨empty_is_rel, λ x y y' hxy hxy', _⟩,\n  exfalso, exact mem_empty _ hxy,\nend\n\nlemma empty_onto : onto_fun ∅ ∅ ∅ :=\n⟨empty_fun, dom_empty_eq_empty, ran_empty_eq_empty⟩\n\nlemma empty_oto : one_to_one ∅ :=\nbegin\n  rw one_to_one_iff, intros y x x' hxy hxy', exfalso, exact mem_empty _ hxy,\nend\n\nlemma dom_prod_nonempty {A B : Set} (hb : ∃ x : Set, x ∈ B) : (A.prod B).dom = A :=\nbegin\n  apply ext, intro z,\n  simp only [hb, mem_dom, and_true, pair_mem_prod, exists_and_distrib_left],\nend\n\nlemma ran_prod_nonempty {A B : Set} : (A.prod B).ran ⊆ B :=\nbegin\n  intros z hz,\n  simp only [mem_ran, pair_mem_prod] at hz,\n  rcases hz with ⟨t, hA, hB⟩, exact hB,\nend\n\nlemma one_to_one_of_has_left_inv {F A B : Set} (hf : F.into_fun A B) (he : ∃ G : Set, G.into_fun B A ∧ G.comp F = A.id) : F.one_to_one :=\nbegin\n  rcases he with ⟨G, hif, hcid⟩,\n  apply one_to_one_ext hf.left,\n  intros x y hxd hyd he,\n  simp only [hf.right.left] at hxd hyd,\n  rw ←id_value hxd, rw ←id_value hyd, rw ←hcid,\n  rw T3H_c hif.left hf.left _,\n  rw T3H_c hif.left hf.left _,\n  rw he,\n  simp only [hcid, (id_onto).right.left, hyd],\n  simp only [hcid, (id_onto).right.left, hxd],\nend\n\nlemma T3J_a {F A B : Set} (hf : F.into_fun A B) (hne : ∃ x, x ∈ A) : (∃ G : Set, G.into_fun B A ∧ G.comp F = A.id) ↔ F.one_to_one :=\nbegin\n  simp only [into_fun] at *,\n  split,\n  { intro he, exact one_to_one_of_has_left_inv hf he, },\n  { rcases hne with ⟨x, hxm⟩,\n    intro hoto,\n    let F' := F.inv,\n    let E := (B \\ F.ran).prod {x},\n    let G := F' ∪ E,\n    have honto : G.onto_fun (F'.dom ∪ E.dom) (F'.ran ∪ E.ran),\n      refine union_fun _ _ _,\n      { simp only [T3F_a, hoto], },\n      { exact prod_singleton_fun, },\n      { simp only [eq_empty],\n        intros z hz,\n        simp only [mem_inter, mem_dom, pair_mem_prod, mem_diff, pair_mem_inv, mem_ran] at hz,\n        rcases hz with ⟨⟨y, hy⟩, y', ⟨_, him⟩, _⟩,\n        exact him ⟨_, hy⟩, },\n    refine ⟨_, ⟨honto.left, _, _⟩, _⟩,\n    { rw honto.right.left,\n      simp only [T3E_a, dom_prod_nonempty ⟨x, mem_singleton.mpr rfl⟩],\n      apply ext, intro z,\n      have hz : z ∈ F.ran → z ∈ B,\n        apply subset_def.mp, exact hf.right.right,\n      simp only [mem_union, mem_diff, or_and_distrib_left, classical.em, and_true, or_iff_right_of_imp hz], },\n    { rw honto.right.right,\n      intros z hz,\n      simp only [mem_union, T3E_b] at hz,\n      cases hz,\n      { rw ←hf.right.left, assumption, },\n      { have hz' : z ∈ {x},\n          apply ran_prod_nonempty,\n          exact hz,\n        simp only [mem_singleton] at hz', rw hz', assumption, }, },\n    have hcdom : (G.comp F).dom = A,\n      apply ext, intro z, simp only [T3H_b honto.left hf.left, mem_sep, hf.right.left, mem_dom],\n      split,\n      { rintro ⟨hmz, _⟩, assumption, },\n      { intro hmz, refine ⟨hmz, _⟩,\n        existsi z,\n        simp only [mem_union, pair_mem_inv],\n        apply or.inl, apply fun_value_def' hf.left, rw hf.right.left, assumption, },\n      apply fun_ext,\n      exact T3H_a honto.left hf.left,\n      exact id_is_function,\n    simp only [id_onto.right.left, hcdom],\n    intros z hz, rw hcdom at hz,\n    have hz' : z ∈ (G.comp F).dom, rw hcdom, assumption,\n    simp only [id_value hz, T3H_c honto.left hf.left hz'],\n    symmetry,\n    apply fun_value_def honto.left,\n    simp only [mem_union, pair_mem_inv],\n    apply or.inl,\n    apply fun_value_def' hf.left, rw hf.right.left, assumption, },\nend\n\n-- For choice, we have choice which satisfies the property that if x is a set and it does not contain the empty set,\n-- then x.choice is a function with domain x and range x.Union and where the value of x.choice at a is a member of a for a in x.\n\nlemma choice_is_fun (x : Set) (h : ∅ ∉ x) : x.choice.into_fun x x.Union :=\nbegin\n  have choice := choice_is_func x h,\n  have hd : x.choice.dom = x,\n    apply ext,\n    intro z,\n    simp only [mem_dom],\n    split,\n    { rintro ⟨y, hy⟩,\n      exact (pair_mem_prod.mp (choice.1 hy)).1, },\n    { intro mz,\n      apply exists_of_exists_unique,\n      exact choice.2 _ mz, },\n  refine ⟨⟨_, _⟩, _, _⟩,\n  { intros z hz,\n    have hp := choice.left hz,\n    simp only [mem_prod] at hp,\n    rcases hp with ⟨a, H, b, H, he⟩,\n    exact ⟨a, b, he⟩, },\n  { intros z hz, rw hd at hz,\n    exact choice.2 _ hz, },\n  { exact hd },\n  { intros z hz, simp only [mem_ran] at hz,\n    cases hz with t hz,\n    have hp : t.pair z ∈ x.prod x.Union,\n      exact choice.1 hz,\n    exact (pair_mem_prod.mp hp).2, },\nend\n\nlemma choice_mem' (x : Set.{u}) (hx : ∅ ∉ x) (y : Set) (hy : y ∈ x) : x.choice.fun_value y ∈ y :=\nbegin\n  have hf := (choice_is_fun x hx),\n  have h : (x.choice : Class.{u}).fval (y : Class.{u}) = (x.choice.fun_value y : Class.{u}),\n    apply Class.iota_val, intro v, split,\n    { rintro ⟨a, ha, hp⟩,\n      simp only [Class.mem_hom_right] at hp,\n      apply fun_value_def, exact hf.left, rw ←(Class.of_Set.inj ha), assumption, },\n    { intro hv, refine ⟨y, rfl, _⟩,\n      simp only [Class.mem_hom_right], rw hv, apply fun_value_def', exact hf.left,\n      rw (choice_is_fun x hx).right.left, assumption, },\n  suffices h₂ : (x.choice.fun_value y : Class.{u}) ∈ (y : Class.{u}),\n    simp only [Class.mem_hom_left, Class.mem_hom_right] at h₂, assumption,\n  rw ←h, exact choice_mem x hx y hy,\nend\n\nlemma pair_sep_eq_is_fun {A B : Set} {f : Set → Set} : (pair_sep (λ a b, b = f a) A B).is_function :=\nbegin\n  rw is_function_iff, split,\n  { exact pair_sep_is_rel, },\n  { simp only [pair_mem_pair_sep, and_imp],\n    intros, finish, },\nend\n\nlemma pair_sep_eq_dom_eq {A B : Set} {f : Set → Set} (h : ∀ a ∈ A, f a ∈ B) : (pair_sep (λ a b, b = f a) A B).dom = A :=\nbegin\n  apply ext, intro a,\n  simp only [mem_dom, pair_mem_pair_sep, exists_eq_right, exists_and_distrib_left, and_iff_left_iff_imp],\n  intro ha, finish,\nend\n\nlemma pair_sep_eq_ran_eq {A B : Set} {f : Set → Set} (h : ∀ b ∈ B, ∃ a, a ∈ A ∧ b = f a)\n: (pair_sep (λ a b, b = f a) A B).ran = B :=\nbegin\n  apply ext, intro b, simp only [mem_ran, pair_mem_pair_sep], split,\n  { rintro ⟨t, _, hb, _⟩, assumption, },\n  { intro hb, specialize h _ hb, finish, },\nend\n\nlemma pair_sep_eq_ran_sub {A B : Set} {p : Set → Set → Prop} : (pair_sep p A B).ran ⊆ B :=\nbegin\n  intros b hb, simp only [mem_ran, pair_mem_pair_sep] at hb, finish,\nend\n\nlemma pair_sep_eq_oto {A B : Set} {f : Set → Set} (hf : ∀ ⦃a₁ : Set⦄, a₁ ∈ A → ∀ ⦃a₂ : Set⦄, a₂ ∈ A → f a₁ = f a₂ → a₁ = a₂) : (pair_sep (λ a b, b = f a) A B).one_to_one :=\nbegin\n  intros b hb, simp only [mem_ran, pair_mem_pair_sep] at hb, rcases hb with ⟨a, ha, hb, he⟩,\n  simp only [pair_mem_pair_sep], refine ⟨_, ⟨ha, hb, he⟩, λ a' ha', _⟩, rcases ha' with ⟨ha', -, he'⟩,\n  rw he' at he, exact hf ha' ha he,\nend\n\ndef pair_sep_eq (A B : Set) (f : Set → Set) : Set := pair_sep (λ a b, b = f a) A B\n\n@[simp]\nlemma pair_mem_pair_sep_eq {A B : Set} {f : Set → Set} {a b : Set} : a.pair b ∈ pair_sep_eq A B f ↔ a ∈ A ∧ b ∈ B ∧ b = f a :=\nby simp only [pair_sep_eq, pair_mem_pair_sep]\n\nlemma pair_sep_eq_fun_value {A B : Set} {f : Set → Set} {a : Set} (ha : a ∈ (pair_sep_eq A B f).dom) : (pair_sep_eq A B f).fun_value a = f a :=\nbegin\n  symmetry, apply fun_value_def pair_sep_eq_is_fun, rw [pair_mem_pair_sep],\n  simp only [mem_dom, pair_mem_pair_sep_eq] at ha, rcases ha with ⟨b, ha, hb, he⟩, rw he at hb,\n  exact ⟨ha, hb, rfl⟩,\nend\n\nlemma pair_sep_eq_into {A B : Set} {f : Set → Set} (h : ∀ a ∈ A, f a ∈ B) : (pair_sep_eq A B f).into_fun A B :=\n⟨pair_sep_eq_is_fun, pair_sep_eq_dom_eq h, pair_sep_eq_ran_sub⟩\n\n-- These are all stated and proved equivalent in chapter 6, but some are stated earlier.\n\ndef Axiom_of_choice_I : Prop := ∀ {R : Set}, R.is_rel → ∃ F : Set, F.is_function ∧ F ⊆ R ∧ F.dom = R.dom\ndef Axiom_of_choice_II : Prop := ∀ {I H : Set}, (H.is_function ∧ H.dom = I ∧ (∀ i : Set, i ∈ I → H.fun_value i ≠ ∅))\n→ ∃ f : Set, f.is_function ∧ f.dom = I ∧ ∀ i : Set, i ∈ I → f.fun_value i ∈ H.fun_value i\ndef Axiom_of_choice_III : Prop := ∀ {A : Set}, ∃ F : Set, F.is_function ∧ F.dom = {x ∈ A.powerset | x ≠ ∅}\n∧ ∀ B : Set, B ∈ F.dom → F.fun_value B ∈ B\ndef Axiom_of_choice_IV : Prop := ∀ {𝓐 : Set}, (∀ a ∈ 𝓐, a ≠ ∅ ∧ ∀ b ∈ 𝓐, b ≠ a → a ∩ b = ∅)\n→ ∃ C : Set, ∀ B ∈ 𝓐, ∃ x : Set, C ∩ B = {x}\n\ntheorem ax_ch_3 : Axiom_of_choice_III :=\nbegin\n  intro A,\n  let A' := {x ∈ A.powerset | x ≠ ∅},\n  have hne : ∅ ∉ A', intro h, simp at h, assumption,\n  have hf := choice_is_fun _ hne,\n  refine ⟨A'.choice, hf.left, _, (λ B hB, _)⟩,\n  { apply ext, intro z, simp only [hf.right.left, mem_sep, mem_dom], },\n  { apply choice_mem' _ hne,\n    rw hf.right.left at hB, assumption, },\nend\n\n-- first 4 parts of theorem 6M\ntheorem choice_equiv : list.tfae [Axiom_of_choice_I.{u}, Axiom_of_choice_II.{u}, Axiom_of_choice_III.{u}, Axiom_of_choice_IV.{u}] :=\nbegin\n  tfae_have : 1 → 2,\n  { dsimp only [Axiom_of_choice_I, Axiom_of_choice_II], rintros ax1 I H ⟨Hfun, Hdom, Hne⟩,\n    let R : Set := pair_sep (λ i y, y ∈ H.fun_value i) I H.ran.Union,\n    specialize @ax1 R pair_sep_is_rel, rcases ax1 with ⟨F, Ffun, FR, Fdom⟩,\n    have Rdom : R.dom = I, rw eq_iff_subset_and_subset, split,\n        exact pair_sep_dom_sub,\n      intros i hi, simp only [mem_dom, pair_mem_pair_sep],\n      specialize Hne _ hi, replace Hne := inhabited_of_ne_empty Hne,\n      rcases Hne with ⟨y, hy⟩, simp only [mem_Union, exists_prop],\n      refine ⟨_, hi, ⟨_, _, hy⟩, hy⟩, apply fun_value_def'' Hfun, rw Hdom, exact hi,\n    rw Rdom at Fdom, refine ⟨_, Ffun, Fdom, _⟩, intros i hi,\n    have hiy : i.pair (F.fun_value i) ∈ R, apply FR, apply fun_value_def' Ffun, rw Fdom, exact hi,\n    simp only [pair_mem_pair_sep] at hiy, exact hiy.right.right, },\n  tfae_have : 2 → 4,\n  { dsimp only [Axiom_of_choice_II, Axiom_of_choice_IV], rintros ax2 A hA,\n    let H := A.id,\n    have Hh : ∀ i : Set, i ∈ H.dom → H.fun_value i ≠ ∅, rw id_into.right.left,\n      intros i hi, rw id_value hi, specialize hA _ hi, exact hA.left,\n    specialize ax2 ⟨id_is_function, rfl, Hh⟩, rcases ax2 with ⟨f, ffun, fdom, hf⟩, use f.ran,\n    intros B hBA, use f.fun_value B, apply ext, simp only [mem_singleton, mem_inter, mem_ran],\n    rw id_into.right.left at hf, intro C, split,\n      rintros ⟨⟨X, hXC⟩, hCB⟩, have hXA : X ∈ f.dom, rw mem_dom, exact ⟨_, hXC⟩, rw [fdom, id_into.right.left] at hXA,\n      have hCfX : C = f.fun_value X := fun_value_def ffun hXC, rw hCfX,\n      suffices hXB : X = B, rw hXB,\n      apply classical.by_contradiction, intro hXB, apply @mem_empty (f.fun_value X),\n      rw [←(hA _ hBA).right _ hXA hXB, mem_inter], split,\n        rw ←hCfX, exact hCB,\n      specialize hf X hXA, rw id_value hXA at hf, exact hf,\n    intro he, split,\n      use B, refine fun_value_def''' ffun _ he, rw [fdom, id_into.right.left], exact hBA,\n    specialize hf _ hBA, rw [id_value hBA] at hf, rw he, exact hf, },\n  tfae_have : 4 → 3,\n  { dsimp only [Axiom_of_choice_IV, Axiom_of_choice_III], rintro ax4 A,\n    let 𝓐 := {x ∈ (A.powerset.Union ∪ A.powerset).powerset.powerset.powerset | ∃ B, B ⊆ A ∧ B ≠ ∅ ∧ x = prod {B} B},\n    have h𝓐 : ∀ x, x ∈ 𝓐 ↔ ∃ B, B ⊆ A ∧ B ≠ ∅ ∧ x = prod {B} B,\n      simp only [and_imp, mem_powerset, and_iff_right_iff_imp, ne.def, exists_imp_distrib, mem_sep],\n      intros X B hBA hBne hXB z hz, rw mem_powerset, intros y hy, rw mem_powerset, intros x hx,\n      simp only [mem_powerset, mem_union], rw hXB at hz,\n      simp only [mem_prod, exists_prop, mem_singleton] at hz,\n      rcases hz with ⟨B', hBB', b, hb, hbp⟩, rw hbp at hy, simp only [pair, mem_insert, mem_singleton] at hy,\n      cases hy,\n        rw [hy, mem_singleton] at hx, right, rw [hx, hBB'], exact hBA,\n      rw hy at hx, simp only [mem_insert, mem_singleton] at hx, cases hx,\n        right, rw [hx, hBB'], exact hBA,\n      left, simp only [hx, mem_Union, exists_prop, mem_powerset], exact ⟨_, hBA, hb⟩,\n    have h𝓐' : ∀ a ∈ 𝓐, a ≠ ∅ ∧ ∀ b ∈ 𝓐, b ≠ a → a ∩ b = ∅, intros a ha,\n      rw h𝓐 _ at ha, rcases ha with ⟨B, -, hBne, he⟩, split,\n        apply ne_empty_of_inhabited, rw he,\n        replace hBne := inhabited_of_ne_empty hBne, rcases hBne with ⟨b, hb⟩, use B.pair b,\n        rw [pair_mem_prod, mem_singleton], exact ⟨rfl, hb⟩,\n      intros b hb hba, rw eq_empty, intros z hz,\n      rw h𝓐 _ at hb, rcases hb with ⟨B', -, hBne', he'⟩, apply hba, rw [he, he'],\n      have hBB' : B = B',\n        simp only [he, he', mem_inter, mem_prod, exists_prop, mem_singleton] at hz,\n        rcases hz with ⟨⟨x, hx, y, hy, hxy⟩, x', hx', y', hy', hxy'⟩, rw [←hx, ←hx'], rw hxy at hxy',\n        exact (pair_inj hxy').left,\n      rw hBB',\n    specialize ax4 h𝓐', rcases ax4 with ⟨C, hC⟩,\n    let F := C ∩ 𝓐.Union, use F,\n    have hFinto : F.into_fun {x ∈ A.powerset | x ≠ ∅} F.ran, rw fun_def_equiv,\n      have Fsubprod : F ⊆ {x ∈ A.powerset | x ≠ ∅}.prod F.ran,\n        intros z hz, simp only [mem_inter, mem_Union, exists_prop] at hz,\n        rcases hz with ⟨hzC, X, hX𝓐, hzX⟩, simp only [mem_prod, exists_prop, mem_ran, mem_sep, mem_inter, mem_powerset],\n        rw h𝓐 _ at hX𝓐, rcases hX𝓐 with ⟨B, hBA, hBne, hX⟩, refine ⟨_, ⟨hBA, hBne⟩, _⟩, rw hX at hzX,\n        simp only [mem_prod, exists_prop, mem_singleton] at hzX, rcases hzX with ⟨B', hB', b, hb, he⟩,\n        rw he at hzC, rw ←hB', refine ⟨_, ⟨_, hzC, _⟩, he⟩, simp only [mem_Union, exists_prop, h𝓐 _],\n        refine ⟨_, ⟨_, hBA, hBne, rfl⟩, _⟩, simp only [pair_mem_prod, mem_singleton], exact ⟨hB', hb⟩,\n      refine ⟨Fsubprod, _⟩,\n      intros B hB, simp only [mem_sep, exists_prop, mem_powerset] at hB, simp only [mem_inter, mem_Union],\n      have hB𝓐 : prod {B} B ∈ 𝓐, rw h𝓐 _, exact ⟨_, hB.left, hB.right, rfl⟩,\n      have he : ∃ x, C ∩ prod {B} B = {x}, apply hC _ hB𝓐,\n      replace he : ∃! x, x ∈ C ∩ prod {B} B, rcases he with ⟨x, he⟩, rw ←ext_iff at he, simp only [mem_singleton] at he,\n        refine ⟨x, (he x).mpr rfl, λ x' hx, _⟩, apply (he x').mp, exact hx,\n      simp only [mem_inter, mem_prod, exists_prop, mem_singleton] at he,\n      rcases he with ⟨x, ⟨hxC, B', hBB', b, hb, he⟩, ha⟩, rw [he, hBB'] at hxC, refine ⟨_, ⟨hxC, _, hB𝓐, _⟩, λ b' hb', _⟩,\n        rw [pair_mem_prod, mem_singleton], exact ⟨rfl, hb⟩,\n      rcases hb' with ⟨hxC', X, hX𝓐, he'⟩, rw h𝓐 X at hX𝓐, rcases hX𝓐 with ⟨B'', hBA'', hBne'', hB''⟩,\n      refine (@pair_inj B _ B _ _).right, rw [he, hBB'] at ha, apply ha _, refine ⟨hxC', _, rfl, b', _, rfl⟩,\n      rw [hB'', pair_mem_prod, mem_singleton] at he', rw he'.left, exact he'.right,\n    refine ⟨hFinto.left, hFinto.right.left, λ B hB, _⟩,\n    rw mem_dom at hB, rcases hB with ⟨b, hb⟩,\n    have hb' : ∃ X, X ∈ 𝓐 ∧ B.pair b ∈ X, simp only [mem_inter, mem_Union, exists_prop] at hb, exact hb.right,\n    rcases hb' with ⟨X, hX𝓐, hBX⟩, rw h𝓐 _ at hX𝓐, rcases hX𝓐 with ⟨B', hBA', hB', he⟩,\n    simp only [he, pair_mem_prod, exists_prop, mem_singleton] at hBX, rw hBX.left,\n    rw hBX.left at hb, rw fun_value_def hFinto.left hb at hBX, exact hBX.right, },\n  tfae_have : 3 → 1,\n  { dsimp only [Axiom_of_choice_III, Axiom_of_choice_I], intros ax3 R hR, specialize @ax3 R.ran,\n    rcases ax3 with ⟨G, Gfun, GsubR, hG⟩,\n    let F := pair_sep_eq R.dom G.ran (λ x, G.fun_value {y ∈ R.ran | x.pair y ∈ R}),\n    have Ffun : F.is_function := pair_sep_eq_is_fun,\n    have BGdom : ∀ {a : Set}, a ∈ R.dom → {y ∈ R.ran | a.pair y ∈ R} ∈ G.dom, intros a ha,\n        simp only [GsubR, mem_sep, mem_powerset], split,\n          exact sep_subset,\n        apply ne_empty_of_inhabited, rw mem_dom at ha, simp only [inhab, mem_sep, mem_ran],\n        rcases ha with ⟨b, hab⟩, exact ⟨b, ⟨a, hab⟩, hab⟩,\n    refine ⟨_, Ffun, _, _⟩,\n      intros z hz, simp only [F, pair_sep_eq, mem_pair_sep, exists_prop] at hz,\n      rcases hz with ⟨a, ha, b, hb, he, he'⟩, subst he, subst he',\n      specialize hG _ (BGdom ha), rw mem_sep at hG, exact hG.right,\n    apply pair_sep_eq_dom_eq, intros a ha, apply fun_value_def'' Gfun (BGdom ha), },\n  tfae_finish,\nend\n\ntheorem ax_ch_1 : Axiom_of_choice_I :=\nbegin\n  refine list.tfae_prf choice_equiv _ _ @ax_ch_3, finish, finish,\nend\n\ntheorem ax_ch_2 : Axiom_of_choice_II :=\nbegin\n  refine list.tfae_prf choice_equiv _ _ @ax_ch_3, finish, finish,\nend\n\nlemma T3J_b {F A B : Set} (hf : F.into_fun A B) : (∃ H : Set, H.into_fun B A ∧ F.comp H = B.id) ↔ F.onto_fun A B :=\nbegin\n  rcases hf with ⟨hf, hd, hr⟩,\n  split,\n  { rintro ⟨H, ⟨hhf, hhd, hhr⟩, heq⟩,\n    refine ⟨hf, hd, _⟩,\n    apply ext, intro z, split,\n    { intro hz, exact hr hz, },\n    { intro hz,\n      rw mem_ran, existsi H.fun_value z,\n      apply fun_value_def''' hf, rw hd,\n      apply hhr, refine fun_value_def'' hhf _, rw hhd, assumption,\n      rw ←T3H_c hf hhf, rw heq, symmetry, exact id_value hz,\n      rw heq, rw id_onto.right.left, assumption, }, },\n  { rintro ⟨-, -, hre⟩,\n    rcases @ax_ch_1 F.inv inv_rel with ⟨H, hhf, hhs, hhd⟩,\n    existsi H, split, refine ⟨hhf, _, _⟩,\n      simp only [hhd, T3E_a, hre],\n      rw ←hd, rw ←T3E_b, exact ran_subset_of_subset hhs,\n    apply fun_ext (T3H_a hf hhf) id_is_function,\n      apply ext, intro z,\n      simp only [T3H_b hf hhf, mem_sep, hhd, T3E_a, hre, id_onto.right.left, and_iff_left_iff_imp],\n      intro hz, simp only [←T3E_b], apply ran_subset_of_subset hhs,\n      apply fun_value_def'' hhf, simp only [hhd, T3E_a, hre, hz],\n    intros x hx, rw id_value, rw T3H_c hf hhf hx, symmetry,\n    apply fun_value_def hf,\n    rw ←pair_mem_inv, apply hhs,\n    apply fun_value_def' hhf,\n    simp only [T3H_b hf hhf, mem_sep] at hx, finish,\n    simp only [T3H_b hf hhf, mem_sep] at hx, finish, },\nend\n\ndef img_fun_img (F 𝓐 : Set) : Set := {B ∈ F.ran.powerset | ∃ A ∈ 𝓐, B = F.img A}\n\n@[simp]\nlemma mem_img_fun_img {F 𝓐 B : Set} : B ∈ F.img_fun_img 𝓐 ↔ ∃ A ∈ 𝓐, B = F.img A :=\nbegin\n  simp only [img_fun_img, mem_sep, and_imp, exists_prop, mem_powerset, and_iff_right_iff_imp, exists_imp_distrib],\n  intros A hA hB y hy, rw hB at hy, simp only [mem_ran, mem_img] at *, finish,\nend\n\ntheorem T3K_a {F 𝓐 : Set} : F.img 𝓐.Union = (F.img_fun_img 𝓐).Union :=\nbegin\n  apply ext, intro y, simp only [exists_prop, mem_img_fun_img, mem_img, mem_Union], split,\n  { rintro ⟨x, ⟨A, hA, hx⟩, hp⟩, refine ⟨F.img A, ⟨A, hA, rfl⟩, _⟩,\n    simp only [mem_img], exact ⟨_, hx, hp⟩, },\n  { rintro ⟨B, ⟨A, hA, hB⟩, hy⟩, rw [hB, mem_img] at hy, rcases hy with ⟨x, hx, hp⟩,\n    exact ⟨_, ⟨_, hA, hx⟩, hp⟩, },\nend\n\ntheorem T3K_b {F 𝓐 : Set} : F.img 𝓐.Inter ⊆ (F.img_fun_img 𝓐).Inter :=\nbegin\n  intro y, simp only [and_imp, mem_img, exists_imp_distrib, inhab, exists_prop, mem_img_fun_img, mem_Inter],\n  intros x A hA ha hp, refine ⟨⟨F.img A, _, hA, rfl⟩, (λ B X hX hB, _)⟩, rw [hB, mem_img],\n  exact ⟨_, ha _ hX, hp⟩,\nend\n\ntheorem T3K_b_eq {F 𝓐 : Set} (hf : F.one_to_one) : F.img 𝓐.Inter = (F.img_fun_img 𝓐).Inter :=\nbegin\n  rw eq_iff_subset_and_subset, refine ⟨T3K_b, _⟩, intro y,\n  simp only [mem_Inter, inhab, and_imp, exists_prop, mem_img_fun_img, mem_img, exists_imp_distrib],\n  intros B A hA hB ha,\n  have hy : y ∈ F.img A, exact ha _ _ hA rfl, rw mem_img at hy, rcases hy with ⟨x, hx, hp⟩,\n  refine ⟨_, ⟨⟨_, hA⟩, (λ X hX, _)⟩, hp⟩,\n  have hy : y ∈ F.img X, exact ha _ _ hX rfl, rw mem_img at hy, rcases hy with ⟨x', hx', hp'⟩,\n  have he : x = x', refine unique_of_exists_unique (hf y _) hp hp', rw mem_ran, exact ⟨_, hp⟩,\n  rw he, assumption,\nend\n\ntheorem T3K_c {F A B : Set} : F.img A \\ F.img B ⊆ F.img (A \\ B) :=\nbegin\n  intro y, simp only [mem_img, mem_diff, not_exists, and_imp, not_and, exists_imp_distrib],\n  intros x hx hp ha, exact ⟨_, ⟨hx, (λ h, ha _ h hp)⟩, hp⟩,\nend\n\ntheorem T3K_c_eq {F A B : Set} (hf : F.one_to_one) : F.img A \\ F.img B = F.img (A \\ B) :=\nbegin\n  rw eq_iff_subset_and_subset, refine ⟨T3K_c, _⟩, intro y,\n  simp only [not_exists, and_imp, not_and, mem_diff, mem_img, exists_imp_distrib],\n  intros x hA hB hp, refine ⟨⟨_, hA, hp⟩, (λ x' hB' hp', _)⟩, apply hB,\n  have he : x = x', refine unique_of_exists_unique (hf y _) hp hp', rw mem_ran, exact ⟨_, hp⟩,\n  rw he, assumption,\nend\n\ndef into_funs (X Y : Set) : Set := {f ∈ (X.prod Y).powerset | f.into_fun X Y}\n\n@[simp]\nlemma mem_into_funs {X Y f : Set} : f ∈ X.into_funs Y ↔ f.into_fun X Y :=\nbegin\n  simp only [into_funs, mem_powerset, and_iff_right_iff_imp, mem_sep], rintros ⟨hf, hd, hr⟩ p hp,\n  have hp' : ∃ x y : Set, p = x.pair y, from hf.left _ hp,\n  rcases hp' with ⟨x, y, hp'⟩,\n  simp *,\n  have hd' : x ∈ f.dom, rw hp' at hp, simp, exact ⟨_, hp⟩,\n  have hr' : y ∈ f.ran, rw hp' at hp, simp, exact ⟨_, hp⟩,\n  rw hd at hd', refine ⟨hd', hr hr'⟩,\nend\n\n-- these examples are from the very end of the section on functions\n\ntheorem ex1 {A : Set} (h : A.inhab) : A.into_funs ∅ = ∅ :=\nbegin\n  rw eq_empty, intros f hf, rw mem_into_funs at hf, rcases h with ⟨x, hx⟩, rcases hf with ⟨hf, hd, hr⟩,\n  rw ←hd at hx, rw mem_dom at hx, rcases hx with ⟨y, hy⟩, apply (mem_empty y), apply hr, rw mem_ran,\n  exact ⟨_, hy⟩,\nend\n\ntheorem ex2 {A : Set} : (∅ : Set).into_funs A = {∅} :=\nbegin\n  apply ext, simp only [mem_singleton, mem_into_funs], intro f, split,\n  { rintro ⟨⟨hre, hf⟩, hd, hr⟩, rw eq_empty, intros p hp,\n    have hx := hre _ hp,\n    rcases hx with ⟨x, y, hx⟩, rw hx at hp, apply mem_empty x, rw ←hd, rw mem_dom, exact ⟨_, hp⟩, },\n  { have hd : (∅ : Set).dom = ∅, rw eq_empty, intros x hx, rw mem_dom at hx, rcases hx with ⟨y, hy⟩,\n      exact mem_empty _ hy,\n    intro he, rw he, refine ⟨⟨(λ p hp, _), (λ x hx, _)⟩, _, _⟩,\n    { exfalso, exact p.mem_empty hp, },\n    { rw hd at hx, exfalso, exact x.mem_empty hx, },\n    { exact hd, },\n    { intros y hy, rw mem_ran at hy, rcases hy with ⟨y, hy⟩,\n        exfalso, exact mem_empty _ hy, }, },\nend\n\ntheorem p16 : ¬ ∃ X : Set, ∀ f : Set, f ∈ X ↔ f.is_function :=\nbegin\n  rintro ⟨X, hX⟩, apply univ_not_set, refine ⟨X.Union.Union.Union, (λ x, _)⟩,\n  simp only [exists_prop, mem_Union], refine ⟨{x}, ⟨x.pair x, ⟨{x.pair x}, _, _⟩, _⟩, _⟩,\n  { rw hX, refine ⟨(λ p hp, _), (λ t ht, ⟨x, _, _⟩)⟩,\n    { rw mem_singleton at hp, rw hp, exact ⟨_, _, rfl⟩, },\n    { change t.pair x ∈ {x.pair x}, rw mem_singleton, rw mem_dom at ht, rcases ht with ⟨y, hy⟩,\n      rw mem_singleton at hy, rw (pair_inj hy).left, },\n    { intros x' hx', rw mem_singleton at hx', exact (pair_inj hx').right, }, },\n  { rw mem_singleton, },\n  { rw [pair, mem_pair], left, refl, },\n  { rw mem_singleton, },\nend\n\n-- Chapter 3, problem 17\ntheorem comp_one_to_one {f : Set} (hf : f.one_to_one) {g : Set} (hg : g.one_to_one) : (f.comp g).one_to_one :=\nbegin\n  intros y hy, rw [mem_ran] at hy, apply exists_unique_of_exists_of_unique hy,\n  intros x x' hx hx', rw [pair_mem_comp] at hx hx',\n  rcases hx with ⟨z, hxz, hzy⟩, rcases hx' with ⟨z', hxz', hzy'⟩,\n  have hze : z = z', refine unique_of_exists_unique (hf _ _) hzy hzy', rw mem_ran, finish,\n  subst hze,\n  refine unique_of_exists_unique (hg _ _) hxz hxz', rw mem_ran, finish,\nend\n\n-- chapter 3, problem 21\ntheorem comp_assoc {R S T : Set} : (R.comp S).comp T = R.comp (S.comp T) :=\nbegin\n  apply ext, simp only [mem_comp, pair_mem_comp], intro z, split,\n  { rintro ⟨a, b, d, hz, hT, c, hS, hR⟩, exact ⟨a, c, d, hz, ⟨b, hT, hS⟩, hR⟩, },\n  { rintro ⟨a, c, d, hz, ⟨b, hT, hS⟩, hR⟩, exact ⟨a, b, d, hz, hT, c, hS, hR⟩, },\nend\n\nsection p30\nparameters {A F : Set.{u}}\n\ndef B : Set := {X ∈ A.powerset | F.fun_value X ⊆ X}.Inter\ndef C : Set := {X ∈ A.powerset | X ⊆ F.fun_value X}.Union\n\nlemma F_sub_of_self (hf : F.into_fun A.powerset A.powerset) {X : Set} (h : X ∈ A.powerset) : F.fun_value X ∈ A.powerset :=\nbegin\n  apply ran_sub_of_into hf, apply fun_value_def'' (is_function_of_into hf),\n  rw dom_eq_of_into hf, assumption,\nend\n\nlemma C_subset_A : C ∈ A.powerset :=\nbegin\n  rw mem_powerset, intro z, simp only [C, mem_Union, exists_prop, mem_sep, mem_powerset],\n  rintro ⟨X, ⟨hX, -⟩, hz⟩, exact hX hz,\nend\n\nlemma B_subset_A (hf : F.into_fun A.powerset A.powerset) : B ∈ A.powerset :=\nbegin\n  rw mem_powerset, intro z, simp only [B, mem_Inter, mem_sep],\n  rintro ⟨hin, ha⟩, apply ha, refine ⟨mem_powerset_self, _⟩, rw ←mem_powerset, apply F_sub_of_self hf,\n  exact mem_powerset_self,\nend\n\nlemma subset_C {X : Set} (hA : X ∈ A.powerset) (hX : X ⊆ F.fun_value X) : X ⊆ C :=\nbegin\n  rw C, apply subset_Union, rw [mem_sep, mem_powerset], finish,\nend\n\nlemma B_subset {X : Set} (hA : X ∈ A.powerset) (hX : F.fun_value X ⊆ X) : B ⊆ X :=\nbegin\n  rw B, apply subset_Inter, rw [mem_sep, mem_powerset], finish,\nend\n\ntheorem p30_b {X : Set}\n(hA : X ⊆ A)\n(hX : F.fun_value X = X)\n: B ⊆ X ∧ X ⊆ C :=\nbegin\n  rw eq_iff_subset_and_subset at hX, refine ⟨(λ x hx, _), (λ x hx, _)⟩,\n  { rw B at hx, simp only [mem_Inter, mem_sep, mem_powerset] at hx,\n    apply hx.right, exact ⟨hA, hX.left⟩, },\n  { rw C, simp only [mem_Union, mem_sep, mem_powerset, exists_prop],\n    exact ⟨_, ⟨hA, hX.right⟩, hx⟩, },\nend\n\ntheorem p30_a {hf : F.into_fun A.powerset A.powerset}\n{hmon : ∀ {X Y : Set}, X ⊆ Y → Y ∈ A.powerset → F.fun_value X ⊆ F.fun_value Y}\n: F.fun_value B = B ∧ F.fun_value C = C :=\nbegin\n  have hC : C ⊆ F.fun_value C, intros z hz,\n    simp only [C, mem_Union, exists_prop, mem_sep] at hz,\n    rcases hz with ⟨X, ⟨hA, hX⟩, hz⟩, exact hmon (subset_C hA hX) C_subset_A (hX hz),\n  have hB : F.fun_value B ⊆ B, intros z hz,\n    simp only [B, mem_Inter, mem_sep], refine ⟨⟨A, _⟩, (λ X ⟨hA, hX⟩, hX (hmon (B_subset hA hX) hA hz))⟩,\n    simp only [mem_sep], rw ←mem_powerset, refine ⟨mem_powerset_self, _⟩,\n    apply F_sub_of_self hf, exact mem_powerset_self,\n  simp only [eq_iff_subset_and_subset], refine ⟨⟨hB, _⟩, _, hC⟩,\n  { apply B_subset, apply F_sub_of_self hf, exact B_subset_A hf, apply hmon hB (B_subset_A hf), },\n  { apply subset_C, apply F_sub_of_self hf, exact C_subset_A, apply hmon hC, apply F_sub_of_self hf, exact C_subset_A, },\nend\nend p30\n\ndef inf_prod (H I : Set) : Set\n:= {f ∈ I.into_funs (H.img I).Union | f.is_function ∧ f.dom = I ∧ ∀ i : Set, i ∈ I → f.fun_value i ∈ H.fun_value i}\n\n@[simp]\nlemma mem_inf_prod {H I f : Set} (hF : H.is_function) (hD : I ⊆ H.dom)\n: f ∈ H.inf_prod I ↔ f.is_function ∧ f.dom = I ∧ ∀ i : Set, i ∈ I → f.fun_value i ∈ H.fun_value i :=\nbegin\n  simp only [inf_prod, mem_sep, and_imp, mem_fun_value, and_iff_right_iff_imp, mem_into_funs],\n  intros hf hd ha, refine ⟨hf, hd, (λ y hy, _)⟩, simp only [mem_Union, exists_prop, mem_img_fun_img],\n  rw mem_ran at hy, rcases hy with ⟨x, hy⟩,\n  have hxi : x ∈ I, rw [←hd, mem_dom], exact ⟨_, hy⟩,\n  have hY := ha _ hxi, rcases hY with ⟨Y, hH, hY⟩,\n  refine ⟨Y, _, _⟩,\n  { simp only [mem_img], refine ⟨x, hxi, hH⟩, },\n  { rw fun_value_def hf hy, assumption, },\nend\n\ntheorem inf_prod_inhab {H I : Set} (hF : H.is_function) (hD : H.dom = I) (hA : ∀ i : Set, i ∈ I → H.fun_value i ≠ ∅)\n: (H.inf_prod I ).inhab :=\nbegin\n  have hD' : I ⊆ H.dom, rw hD, exact subset_self,\n  simp only [inhab, mem_inf_prod hF hD'], exact @ax_ch_2 _ _ ⟨hF, hD, hA⟩,\nend\n\ndef symmetric (R : Set) : Prop := ∀ ⦃x y : Set⦄, x.pair y ∈ R → y.pair x ∈ R\ndef transitive (R : Set) : Prop := ∀ ⦃x y z : Set⦄, x.pair y ∈ R → y.pair z ∈ R → x.pair z ∈ R\n\nstructure equiv_rel (R A : Set) : Prop :=\n(rel : R ⊆ A.prod A)\n(refl : ∀ ⦃x : Set⦄, x ∈ A → x.pair x ∈ R)\n(symm : R.symmetric)\n(trans : R.transitive)\n\ntheorem T3M {R : Set} (hr : R.is_rel) (hs : R.symmetric) (ht : R.transitive) : R.equiv_rel R.fld :=\nbegin\n  refine ⟨(λ p hp, _), _, hs, ht⟩,\n  { have h : ∃ x y : Set, p = x.pair y := hr _ hp, rcases h with ⟨x, y, h⟩, rw h at hp,\n    simp only [mem_prod, exists_prop, fld, mem_union, mem_dom, mem_ran],\n    exact ⟨_, or.inl ⟨_, hp⟩, _, or.inr ⟨_, hp⟩, h⟩, },\n  have h : ∀ {x y : Set}, x.pair y ∈ R → x.pair x ∈ R,\n    intros x y h, exact ht h (hs h),\n  simp only [fld, mem_union, mem_dom, mem_ran], rintros x (⟨y, hp⟩|⟨y, hp⟩),\n  { exact h hp, },\n  { exact h (hs hp), },\nend\n\ndef eq_class (R x : Set) : Set := {t ∈ R.ran | x.pair t ∈ R}\n\n@[simp]\nlemma mem_eq_class {R x t : Set} : t ∈ R.eq_class x ↔ x.pair t ∈ R :=\nbegin\n  simp only [eq_class, and_iff_right_iff_imp, mem_ran, mem_sep],\n  intro h, exact ⟨_, h⟩,\nend\n\nlemma mem_eq_class_of_self {R A x : Set} (hr : R.equiv_rel A) (hx : x ∈ A) : x ∈ R.eq_class x :=\nbegin\n  rw mem_eq_class, exact hr.refl hx,\nend\n\ndef eq_classes (R A : Set) : Set := {X ∈ R.ran.powerset | ∃ x : Set, X = R.eq_class x ∧ x ∈ A}\n\n@[simp]\nlemma mem_eq_classes {R A X : Set} : X ∈ R.eq_classes A ↔ ∃ x : Set, X = R.eq_class x ∧ x ∈ A :=\nbegin\n  simp only [eq_classes, mem_powerset, and_iff_right_iff_imp, exists_imp_distrib, mem_sep],\n  rintros x ⟨hX, hx⟩, rw hX, intro t, rw [eq_class, mem_sep], finish,\nend\n\nlemma L3N {R A : Set} (hr : R.equiv_rel A) {x y : Set} (hx : x ∈ A) (hy : y ∈ A)\n: R.eq_class x = R.eq_class y ↔ x.pair y ∈ R :=\nbegin\n  refine ⟨(λ h, _), (λ h, _)⟩,\n  { rw [←mem_eq_class, h, mem_eq_class], exact hr.refl hy, },\n  { apply ext, intro t, simp only [mem_eq_class], split,\n    { exact (λ ht, hr.trans (hr.symm h) ht), },\n    { exact (λ ht, hr.trans h ht), }, },\nend\n\nstructure partition (P A : Set) : Prop :=\n(subs : ∀ ⦃x : Set⦄, x ∈ P → x ⊆ A)\n(nonem : ∀ ⦃x : Set⦄, x ∈ P → x ≠ ∅)\n(disj : ∀ ⦃x y : Set⦄, x ∈ P → y ∈ P → x ≠ y → (x ∩ y) = ∅)\n(exhaust : ∀ ⦃x : Set⦄, x ∈ A → ∃ X : Set, X ∈ P ∧ x ∈ X)\n\ntheorem T3P {R A : Set} (hr : R.equiv_rel A) : (R.eq_classes A).partition A :=\nbegin\n  refine ⟨_, _, _, _⟩,\n  { simp only [mem_eq_classes], rintros X ⟨x, hX⟩ t ht, simp only [hX, mem_eq_class] at ht,\n    replace ht : x.pair t ∈ A.prod A := hr.rel ht, simp only [pair_mem_prod] at ht,\n    exact ht.right },\n  { simp only [mem_eq_classes], rintros X ⟨x, hX, hx⟩, apply ne_empty_of_inhabited, existsi x,\n    rw hX, exact mem_eq_class_of_self hr hx, },\n  { simp only [mem_eq_classes], rintros X Y ⟨x, hX, hx⟩ ⟨y, hY, hy⟩ hne, rw eq_empty,\n    intros t ht, simp only [mem_inter, hX, hY, mem_eq_class] at ht,\n    apply hne, rw [hX, hY, L3N hr hx hy], exact hr.trans ht.left (hr.symm ht.right), },\n  { simp only [mem_eq_classes], intros x hx, exact ⟨_, ⟨_, rfl, hx⟩, mem_eq_class_of_self hr hx⟩, },\nend\n\n-- I'm not writing any lemmas for this unless we use it\ndef natural_map (R A : Set) : Set := pair_sep (λ x X, X = R.eq_class x) A (R.eq_classes A)\n\n-- thm 3Q\n--37\n--38, maybe\n--39, maybe\n--42\n--delay 3Q until it's needed\n\nstructure lin_order (A R : Set) : Prop :=\n(rel : R ⊆ A.prod A)\n(trans : R.transitive)\n(irrefl : ∀ ⦃x : Set⦄, x.pair x ∉ R)\n(conn : ∀ ⦃x y : Set⦄, x ∈ A → y ∈ A → x ≠ y → x.pair y ∈ R ∨ y.pair x ∈ R)\n\nlemma inv_lin_order {A R : Set} (lin : A.lin_order R) : A.lin_order R.inv :=\nbegin\n  split,\n  { exact inv_sub_prod lin.rel, },\n  { intros x y z xy yz, rw pair_mem_inv at xy yz ⊢, exact lin.trans yz xy, },\n  { intros x xx, rw pair_mem_inv at xx, exact lin.irrefl xx, },\n  { intros x y xA yA xy, simp only [pair_mem_inv, or_comm], exact lin.conn xA yA xy, },\nend\n\nlemma prod_disj {A B C D : Set} (h : C ∩ D = ∅) : A.prod C ∩ B.prod D = ∅ :=\nbegin\n  rw eq_empty, intros z hz, simp only [mem_inter, mem_prod, exists_prop] at hz,\n  rcases hz with ⟨⟨a, ha, b, hb, he⟩, a', ha', b', hb', he'⟩,\n  rw he' at he, rw (pair_inj he).right at hb',\n  have hb'' : b ∈ C ∩ D, rw mem_inter, finish,\n  rw h at hb'', exact mem_empty _ hb'',\nend\n\nlemma singleton_disj_of_ne {A B : Set} (hne : A ≠ B) : {A} ∩ {B} = (∅ : Set) :=\nbegin\n  rw eq_empty, intros z hz, simp only [mem_inter, mem_singleton] at hz, apply hne, rw ←hz.left, rw ←hz.right,\nend\n\nend Set", "meta": {"author": "ehaskell1", "repo": "set_theory", "sha": "e6c829c4dd953d98c9cba08f9f79784cd91794fb", "save_path": "github-repos/lean/ehaskell1-set_theory", "path": "github-repos/lean/ehaskell1-set_theory/set_theory-e6c829c4dd953d98c9cba08f9f79784cd91794fb/src/ch3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.49859834136849995}}
{"text": "import tactic\n\nimport group_theory.index\nimport group_theory.p_group\nimport group_theory.quotient_group\nimport group_theory.coset\nimport group_theory.specific_groups.cyclic\nimport group_theory.abelianization\nimport data.finite.basic\nimport data.finite.card\n\nopen fintype\nopen is_p_group\nopen group\n\nlemma group.center_eq_top_of_comm {H : Type*} [group H] (h : ∀ a b : H, a * b = b * a) : subgroup.center H = ⊤ :=\nbegin\n  rw subgroup.eq_top_iff',\n  intros x y,\n  exact (h y x),\nend\n\nlemma group.center_eq_top_of_comm_comm_group {H : Type*} [comm_group H] : subgroup.center H = ⊤ :=\nbegin\n  exact comm_group.center_eq_top,\nend\n\nlemma group.of_comm_center_eq_top {H : Type*} [group H] (h : (subgroup.center H = ⊤)) : (∀ a b : H, a * b = b * a) :=\nbegin\n  rw subgroup.eq_top_iff' at h,\n  intros x y,\n  rw (h x),\nend\n\nvariables (p : ℕ) [fact (nat.prime p)]\nvariables (G : Type*) [fintype G] [group G]\n\ndef order_psq : Prop := card G = p^2\n\nnamespace order_psq\n\nlemma has_ord_psq : order_psq p G → ∃ q : ℕ , card G = q^2 :=\nbegin\n  intro h1,\n  use p,\n  apply h1,\nend\n\nsection G_has_order_psq\n\nvariables (hG : order_psq p G)\ninclude hG\n\nlemma p_group : is_p_group p G :=\nbegin\n  exact of_card hG,\nend\n\nlemma psq_center_nontrivial [nontrivial G] : nontrivial (subgroup.center G) :=\ncenter_nontrivial (p_group p G hG)\n\nopen_locale classical\n\n@[instance] def quotient_with_center_is_fintype : finite (G ⧸ subgroup.center G) :=\ninfer_instance\n\n\nlemma center_index_not_prime : ¬ nat.prime (fintype.card (G ⧸ subgroup.center G)) :=\nbegin\n  intro h1,\n  haveI : fact(nat.prime (card (G ⧸ subgroup.center G))) := ⟨h1⟩,\n  haveI := is_cyclic_of_prime_card (rfl : card (G ⧸ subgroup.center G) = _),\n  have h2 := commutative_of_cyclic_center_quotient (quotient_group.mk' (subgroup.center G)) (by simp),\n  have h4 : card (G ⧸ subgroup.center G) = 1,\n  {\n    simp_rw [group.center_eq_top_of_comm h2, ← nat.card_eq_fintype_card],\n    exact subgroup.index_top,\n  },\n  rw h4 at h1,\n  exact nat.not_prime_one h1,\nend\n\nlemma center_index_not_prime_2 : ¬ nat.prime (fintype.card (G ⧸ subgroup.center G)) :=\nbegin\n  intro h1,\n  haveI : fact(nat.prime (card (G ⧸ subgroup.center G))) := ⟨h1⟩,\n  haveI := is_cyclic_of_prime_card (rfl : card (G ⧸ subgroup.center G) = _),\n  letI := comm_group_of_cycle_center_quotient (quotient_group.mk' (subgroup.center G)) (by simp),\n  have h3 : subgroup.center G = ⊤,\n  {\n    exact comm_group.center_eq_top,  -- not working\n  },\n  have h4 : card (G ⧸ subgroup.center G) = 1,\n  {\n    simp_rw [h3, ← nat.card_eq_fintype_card],\n    exact subgroup.index_top,\n  },\n  rw h4 at h1,\n  exact nat.not_prime_one h1,\nend\n\ntheorem order_psq_are_abelian [nontrivial G] : (∀ x1 x2 : G, x1 * x2 = x2 * x1) :=\nbegin\n  apply group.of_comm_center_eq_top,\n  have h1 : (card (subgroup.center G) ∣ card (G)),\n  {\n    exact (subgroup.center G).card_subgroup_dvd_card,\n  },\n  have h2 : (card G = p^2),\n  {\n    exact hG,\n  },\n  rw h2 at h1,\n  rw nat.dvd_prime_pow at h1,\n  rcases h1 with ⟨k, hk1, hk2⟩,\n  swap,\n  apply fact.out,\n  interval_cases k,\n  {\n    exfalso,\n    have h31 : nontrivial (subgroup.center G),\n    {\n      exact center_nontrivial (p_group p G hG),\n    },\n    rw subgroup.nontrivial_iff_exists_ne_one at h31,\n    \n  },\n  {\n    exfalso,\n    have h41 : card ()\n    sorry,\n  },\n  {\n    sorry,\n  },\nend\n\nend G_has_order_psq\n\nend order_psq", "meta": {"author": "thefundamentaltheor3m", "repo": "Groups_of_ord_psq", "sha": "feb8197d3a219ed1638d35ba1dd9d5eade63a4e9", "save_path": "github-repos/lean/thefundamentaltheor3m-Groups_of_ord_psq", "path": "github-repos/lean/thefundamentaltheor3m-Groups_of_ord_psq/Groups_of_ord_psq-feb8197d3a219ed1638d35ba1dd9d5eade63a4e9/src/V3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4985801007773759}}
{"text": "open nat (add_assoc add_comm)\n\ntheorem hello_world (a b c : ℕ) : a + b + c = a + c + b :=\nbegin\n  rw [add_assoc, add_comm b, ←add_assoc]\nend\n", "meta": {"author": "yangky11", "repo": "lean-example", "sha": "5a0360e49946815cb53132638ccdd46fb1859e2a", "save_path": "github-repos/lean/yangky11-lean-example", "path": "github-repos/lean/yangky11-lean-example/lean-example-5a0360e49946815cb53132638ccdd46fb1859e2a/src/example.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4985800964495384}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport order.hom.bounded\nimport order.hom.order\nimport topology.order.hom.basic\n\n/-!\n# Esakia morphisms\n\nThis file defines pseudo-epimorphisms and Esakia morphisms.\n\nWe use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to\nbe satisfied by itself and all stricter types.\n\n## Types of morphisms\n\n* `pseudo_epimorphism`: Pseudo-epimorphisms. Maps `f` such that `f a ≤ b` implies the existence of\n  `a'` such that `a ≤ a'` and `f a' = b`.\n* `esakia_hom`: Esakia morphisms. Continuous pseudo-epimorphisms.\n\n## Typeclasses\n\n* `pseudo_epimorphism_class`\n* `esakia_hom_class`\n\n## References\n\n* [Wikipedia, *Esakia space*](https://en.wikipedia.org/wiki/Esakia_space)\n-/\n\nopen function\n\nvariables {F α β γ δ : Type*}\n\n/-- The type of pseudo-epimorphisms, aka p-morphisms, aka bounded maps, from `α` to `β`. -/\nstructure pseudo_epimorphism (α β : Type*) [preorder α] [preorder β] extends α →o β :=\n(exists_map_eq_of_map_le' ⦃a : α⦄ ⦃b : β⦄ : to_fun a ≤ b → ∃ c, a ≤ c ∧ to_fun c = b)\n\n/-- The type of Esakia morphisms, aka continuous pseudo-epimorphisms, from `α` to `β`. -/\nstructure esakia_hom (α β : Type*) [topological_space α] [preorder α] [topological_space β]\n  [preorder β] extends α →Co β :=\n(exists_map_eq_of_map_le' ⦃a : α⦄ ⦃b : β⦄ : to_fun a ≤ b → ∃ c, a ≤ c ∧ to_fun c = b)\n\n/-- `pseudo_epimorphism_class F α β` states that `F` is a type of `⊔`-preserving morphisms.\n\nYou should extend this class when you extend `pseudo_epimorphism`. -/\nclass pseudo_epimorphism_class (F : Type*) (α β : out_param $ Type*) [preorder α] [preorder β]\n  extends rel_hom_class F ((≤) : α → α → Prop) ((≤) : β → β → Prop) :=\n(exists_map_eq_of_map_le (f : F) ⦃a : α⦄ ⦃b : β⦄ : f a ≤ b → ∃ c, a ≤ c ∧ f c = b)\n\n/-- `esakia_hom_class F α β` states that `F` is a type of lattice morphisms.\n\nYou should extend this class when you extend `esakia_hom`. -/\nclass esakia_hom_class (F : Type*) (α β : out_param $ Type*) [topological_space α] [preorder α]\n  [topological_space β] [preorder β]\n  extends continuous_order_hom_class F α β :=\n(exists_map_eq_of_map_le (f : F) ⦃a : α⦄ ⦃b : β⦄ : f a ≤ b → ∃ c, a ≤ c ∧ f c = b)\n\nexport pseudo_epimorphism_class (exists_map_eq_of_map_le)\n\n@[priority 100] -- See note [lower instance priority]\ninstance pseudo_epimorphism_class.to_top_hom_class [partial_order α] [order_top α] [preorder β]\n  [order_top β] [pseudo_epimorphism_class F α β] : top_hom_class F α β :=\n⟨λ f, let ⟨b, h⟩ := exists_map_eq_of_map_le f (@le_top _ _ _ $ f ⊤) in\n  by rw [←top_le_iff.1 h.1, h.2]⟩\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_pseudo_epimorphism_class [preorder α] [preorder β]\n  [order_iso_class F α β] : pseudo_epimorphism_class F α β :=\n⟨λ f a b h, ⟨equiv_like.inv f b, (le_map_inv_iff f).2 h, equiv_like.right_inv _ _⟩⟩\n\n@[priority 100] -- See note [lower instance priority]\ninstance esakia_hom_class.to_pseudo_epimorphism_class [topological_space α] [preorder α]\n  [topological_space β] [preorder β] [esakia_hom_class F α β] : pseudo_epimorphism_class F α β :=\n{ .. ‹esakia_hom_class F α β› }\n\ninstance [preorder α] [preorder β] [pseudo_epimorphism_class F α β] :\n  has_coe_t F (pseudo_epimorphism α β) :=\n⟨λ f, ⟨f, exists_map_eq_of_map_le f⟩⟩\n\ninstance [topological_space α] [preorder α] [topological_space β] [preorder β]\n  [esakia_hom_class F α β] : has_coe_t F (esakia_hom α β) :=\n⟨λ f, ⟨f, exists_map_eq_of_map_le f⟩⟩\n\n/-! ### Pseudo-epimorphisms -/\n\nnamespace pseudo_epimorphism\nvariables [preorder α] [preorder β] [preorder γ] [preorder δ]\n\ninstance : pseudo_epimorphism_class (pseudo_epimorphism α β) α β :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h, by { obtain ⟨⟨_, _⟩, _⟩ := f, obtain ⟨⟨_, _⟩, _⟩ := g, congr' },\n  map_rel := λ f, f.monotone',\n  exists_map_eq_of_map_le := pseudo_epimorphism.exists_map_eq_of_map_le' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (pseudo_epimorphism α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : pseudo_epimorphism α β} : f.to_fun = (f : α → β) := rfl\n\n@[ext] lemma ext {f g : pseudo_epimorphism α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of a `pseudo_epimorphism` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\nprotected def copy (f : pseudo_epimorphism α β) (f' : α → β) (h : f' = f) :\n  pseudo_epimorphism α β :=\n⟨f.to_order_hom.copy f' h, by simpa only [h.symm, to_fun_eq_coe] using f.exists_map_eq_of_map_le'⟩\n\nvariables (α)\n\n/-- `id` as a `pseudo_epimorphism`. -/\nprotected def id : pseudo_epimorphism α α := ⟨order_hom.id, λ a b h, ⟨b, h, rfl⟩⟩\n\ninstance : inhabited (pseudo_epimorphism α α) := ⟨pseudo_epimorphism.id α⟩\n\n@[simp] lemma coe_id : ⇑(pseudo_epimorphism.id α) = id := rfl\n@[simp] lemma coe_id_order_hom : (pseudo_epimorphism.id α : α →o α) = order_hom.id := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : pseudo_epimorphism.id α a = a := rfl\n\n/-- Composition of `pseudo_epimorphism`s as a `pseudo_epimorphism`. -/\ndef comp (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) : pseudo_epimorphism α γ :=\n⟨g.to_order_hom.comp f.to_order_hom, λ a b h₀, begin\n  obtain ⟨b, h₁, rfl⟩ := g.exists_map_eq_of_map_le' h₀,\n  obtain ⟨b, h₂, rfl⟩ := f.exists_map_eq_of_map_le' h₁,\n  exact ⟨b, h₂, rfl⟩,\nend⟩\n\n@[simp] lemma coe_comp (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) :\n  (g.comp f : α → γ) = g ∘ f := rfl\n@[simp] lemma coe_comp_order_hom (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) :\n  (g.comp f : α →o γ) = (g : β →o γ).comp f := rfl\n@[simp] lemma comp_apply (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) (a : α) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma comp_assoc (h : pseudo_epimorphism γ δ) (g : pseudo_epimorphism β γ)\n  (f : pseudo_epimorphism α β) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] \n\nlemma cancel_right {g₁ g₂ : pseudo_epimorphism β γ} {f : pseudo_epimorphism α β}\n  (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : pseudo_epimorphism β γ} {f₁ f₂ : pseudo_epimorphism α β} (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, ext $ λ a, hg $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩\n\nend pseudo_epimorphism\n\n/-! ### Esakia morphisms -/\n\nnamespace esakia_hom\nvariables [topological_space α] [preorder α] [topological_space β] [preorder β]\n  [topological_space γ] [preorder γ] [topological_space δ] [preorder δ]\n\n/-- Reinterpret an `esakia_hom` as a `pseudo_epimorphism`. -/\ndef to_pseudo_epimorphism (f : esakia_hom α β) : pseudo_epimorphism α β := { ..f }\n\ninstance : esakia_hom_class (esakia_hom α β) α β :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h,\n    by { obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := f, obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := g, congr' },\n  map_rel := λ f, f.monotone',\n  map_continuous := λ f, f.continuous_to_fun,\n  exists_map_eq_of_map_le := λ f, f.exists_map_eq_of_map_le' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (esakia_hom α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : esakia_hom α β} : f.to_fun = (f : α → β) := rfl\n\n@[ext] lemma ext {f g : esakia_hom α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of an `esakia_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : esakia_hom α β) (f' : α → β) (h : f' = f) : esakia_hom α β :=\n⟨f.to_continuous_order_hom.copy f' h,\n  by simpa only [h.symm, to_fun_eq_coe] using f.exists_map_eq_of_map_le'⟩\n\nvariables (α)\n\n/-- `id` as an `esakia_hom`. -/\nprotected def id : esakia_hom α α := ⟨continuous_order_hom.id α, λ a b h, ⟨b, h, rfl⟩⟩\n\ninstance : inhabited (esakia_hom α α) := ⟨esakia_hom.id α⟩\n\n@[simp] lemma coe_id : ⇑(esakia_hom.id α) = id := rfl\n@[simp] lemma coe_id_continuous_order_hom :\n  (esakia_hom.id α : α →Co α) = continuous_order_hom.id α := rfl\n@[simp] lemma coe_id_pseudo_epimorphism :\n  (esakia_hom.id α : pseudo_epimorphism α α) = pseudo_epimorphism.id α  := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : esakia_hom.id α a = a := rfl\n\n/-- Composition of `esakia_hom`s as an `esakia_hom`. -/\ndef comp (g : esakia_hom β γ) (f : esakia_hom α β) : esakia_hom α γ :=\n⟨g.to_continuous_order_hom.comp f.to_continuous_order_hom, λ a b h₀, begin\n  obtain ⟨b, h₁, rfl⟩ := g.exists_map_eq_of_map_le' h₀,\n  obtain ⟨b, h₂, rfl⟩ := f.exists_map_eq_of_map_le' h₁,\n  exact ⟨b, h₂, rfl⟩,\nend⟩\n\n@[simp] lemma coe_comp (g : esakia_hom β γ) (f : esakia_hom α β) : (g.comp f : α → γ) = g ∘ f := rfl\n@[simp] lemma comp_apply (g : esakia_hom β γ) (f : esakia_hom α β) (a : α) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma coe_comp_continuous_order_hom (g : esakia_hom β γ) (f : esakia_hom α β) :\n  (g.comp f : α →Co γ) = (g : β →Co γ).comp f := rfl\n@[simp] lemma coe_comp_pseudo_epimorphism (g : esakia_hom β γ) (f : esakia_hom α β) :\n  (g.comp f : pseudo_epimorphism α γ) = (g : pseudo_epimorphism β γ).comp f := rfl\n@[simp] lemma comp_assoc (h : esakia_hom γ δ) (g : esakia_hom β γ) (f : esakia_hom α β) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] lemma comp_id (f : esakia_hom α β) : f.comp (esakia_hom.id α) = f := ext $ λ a, rfl\n@[simp] lemma id_comp (f : esakia_hom α β) : (esakia_hom.id β).comp f = f := ext $ λ a, rfl\n\nlemma cancel_right {g₁ g₂ : esakia_hom β γ} {f : esakia_hom α β} (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : esakia_hom β γ} {f₁ f₂ : esakia_hom α β} (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, ext $ λ a, hg $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩\n\nend esakia_hom\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/order/hom/esakia.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624840223698, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.49858009322015406}}
{"text": "import Complexes.Structures.SerreGraph\n\nclass CombinatorialTwoComplex (V : Sort _) extends SerreGraph V where  \n  relator : {v : V} → Loop v → Sort _\n  inv : {v w : V} → (e : v ⟶ w) → relator (.cons (op e) $ .cons e .nil) -- the trivial relations are satisfied\n  flip :  {v : V} → {l : Loop v} → relator l → relator l.inv\n  flip_inv : {v : V} → {l : Loop v} → (r : relator l) → (Eq.subst l.inverse_inv $ flip (flip r)) = r\n\ninductive NullHomotopy {V : Sort _} [CombinatorialTwoComplex V] : {v : V} → (ℓ : Loop v) → Sort _\n  | nil : {v : V} →  NullHomotopy (.nil v)\n  | relator : {v : V} → {l : Loop v} → CombinatorialTwoComplex.relator l → NullHomotopy l\n  | concat : {v : V} → {l l' : Loop v} → NullHomotopy l → NullHomotopy l' → NullHomotopy (.append l l')\n  | delete : {v : V} → {l l' : Loop v} → NullHomotopy l → NullHomotopy (.append l l') → NullHomotopy l'\n  | rotate : {v : V} → {l : Loop v} → NullHomotopy l → NullHomotopy l.rotate\n  | rotate' : {v : V} → {l : Loop v} → NullHomotopy l → NullHomotopy l.rotate'\n\ninductive Path.Homotopy {V : Sort _} [CombinatorialTwoComplex V] : {v w : V} → (p q : Path v w) → Prop\n  | rel : {v w : V} → {p q : Path v w} → NullHomotopy (.append p q.inverse) → Homotopy p q\n\n\nnamespace NullHomotopy\n\nvariable {V : Sort _} [C : CombinatorialTwoComplex V] {u v w : V} (l l' : Loop v)\n\ndef subst : {u v : V} → (h : u = v) → (l : Loop u) → (l' : Loop v) → (l = (congrArg Loop h) ▸ l') → NullHomotopy l → NullHomotopy l'\n  | _, _, rfl, _, _, rfl => id\n\ndef swap {u v : V} : {p : Path u v} → {q : Path v u} → NullHomotopy (.append p q) → NullHomotopy (.append q p)\n  | .nil, _ => by rw [Path.append_nil]; exact id\n  | .cons _ _, _ => by\n    dsimp [Path.append]\n    intro r\n    let r' := NullHomotopy.rotate r\n    dsimp [Loop.next, Path.first, Loop.rotate] at r'\n    rw [Path.append_cons]\n    apply swap\n    rw [Path.append_snoc]\n    exact r'\n\ndef delete' {v : V} {l l' : Loop v} (r : NullHomotopy l) (r' : NullHomotopy (.append l' l)) : NullHomotopy l' :=\n  NullHomotopy.delete r $ swap r'\n\ndef contract {u v : V} {p : Path u v} {l : Loop v} (rel : NullHomotopy l) {q : Path v u} : NullHomotopy (.append p (.append l q)) → NullHomotopy (.append p q) := by\n  intro r\n  let r' := swap r\n  rw [Path.append_assoc] at r'\n  let r'' := delete rel r'\n  exact swap r''\n\ndef splice {u v : V} {p : Path u v} {l : Loop v} (rel : NullHomotopy l) {q : Path v u} : NullHomotopy (.append p q) → NullHomotopy (.append p (.append l q)) := by\n  intro r\n  apply swap\n  rw [Path.append_assoc]\n  apply concat rel\n  apply swap\n  exact r\n\ndef trivial {u v : V} : (p : Path u v) → NullHomotopy (.append p p.inverse)\n  | .nil => .nil\n  | .cons e p' => by\n    rename_i x\n    dsimp [Path.append, Path.inverse]\n    rw [Path.append_snoc]\n    rw [← Path.snoc_cons]\n    let erel : Loop x := .cons (SerreGraph.op e) (.cons e .nil)\n    let l : Loop x := .append erel (.append p' p'.inverse)\n    show NullHomotopy l.rotate\n    apply NullHomotopy.rotate\n    apply NullHomotopy.concat\n    · apply NullHomotopy.relator\n      apply CombinatorialTwoComplex.inv\n    · apply trivial\n\ndef inv {v : V} {l : Loop v} : NullHomotopy l → NullHomotopy l.inv\n  | .nil => .nil\n  | .relator d => .relator $ CombinatorialTwoComplex.flip d\n  | .concat r r' => by\n      rw [Loop.inv, Path.inverse_append]\n      apply NullHomotopy.concat\n      · exact inv r'\n      · exact inv r\n  | .delete r r' => by\n      let r'' := inv r'\n      rw [Loop.inv, Path.inverse_append] at r''\n      exact NullHomotopy.delete' (inv r) r''\n  | .rotate r => by\n      apply subst (Loop.prev_inv _ _)\n      · apply Loop.rotate'_inv\n      · exact rotate' <| inv r\n  | .rotate' r => by\n      apply subst (Loop.next_inv _ _)\n      · apply Loop.rotate_inv\n      · exact rotate <| inv r\n\nend NullHomotopy\n\n\nnamespace Path.Homotopy\n\nvariable {V : Sort _} [C : CombinatorialTwoComplex V] {u v : V} (p q r : Path u v)\n\ntheorem refl : (p : Path u v) → Path.Homotopy p p := (.rel $ NullHomotopy.trivial ·)\n\ntheorem symm : Path.Homotopy p q → Path.Homotopy q p\n  | .rel h => by\n    let h' := h.inv\n    rw [Loop.inv, Path.inverse_append, Path.inverse_inv] at h'\n    exact .rel h'\n\ntheorem trans : Path.Homotopy p q → Path.Homotopy q r → Path.Homotopy p r\n  |.rel h, .rel h' => by\n    let H := NullHomotopy.concat h h'\n    rw [Path.append_assoc p _ _, ← Path.append_assoc _ q _] at H\n    let H' := NullHomotopy.contract (.swap $ .trivial _) H\n    exact .rel H'\n\ninstance equivalence (u v : V) : Equivalence (@Path.Homotopy V C u v) where\n  refl := refl\n  symm := symm _ _\n  trans := trans _ _ _\n\ninstance setoid (u v : V) : Setoid (Path u v) where\n  r := Path.Homotopy\n  iseqv := equivalence u v\n\ntheorem inv_cancel_left (p : Path u v) : Path.Homotopy (.append (.inverse p) p) .nil := \n  .rel $ by\n    simp [inverse]\n    apply NullHomotopy.swap\n    apply NullHomotopy.trivial\n\ntheorem inv_cancel_right (p : Path u v) : Path.Homotopy (.append p (.inverse p)) .nil := \n  .rel $ by\n    simp [inverse]\n    apply NullHomotopy.trivial\n\ntheorem mul_sound {u v w : V} {p q : Path u v} {r s : Path v w} : \n  Path.Homotopy p q → Path.Homotopy r s → \n  Path.Homotopy (.append p r) (.append q s)\n  | .rel a, .rel b  => .rel $ by\n    rw [inverse_append, append_assoc, ← append_assoc _ _ (inverse q)]\n    exact NullHomotopy.splice b a\n\ntheorem inv_sound {u v : V} {p q : Path u v} : \n  Path.Homotopy p q → \n  Path.Homotopy p.inverse q.inverse\n  | .rel r =>.rel $ by\n    rw [← inverse_append]\n    apply NullHomotopy.inv\n    apply NullHomotopy.swap\n    exact r\n\nend Path.Homotopy\n", "meta": {"author": "siddhartha-gadgil", "repo": "Polylean", "sha": "3b411dc1dca8c84ab221cc544d1ae3bd4f83de5a", "save_path": "github-repos/lean/siddhartha-gadgil-Polylean", "path": "github-repos/lean/siddhartha-gadgil-Polylean/Polylean-3b411dc1dca8c84ab221cc544d1ae3bd4f83de5a/Complexes/Structures/CombinatorialTwoComplex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.49858008999076964}}
{"text": "structure X :=\n  ( a : ℕ ) ( b : ℕ )\n\n@[reducible] def f ( x : X ) : X := ⟨ x^.b + 1, x^.a ⟩\n\nlemma t (x : ℕ × ℕ) : (x^.fst, x^.snd) = x :=\nbegin\ncases x,\ndsimp,\ntrivial\nend", "meta": {"author": "semorrison", "repo": "proof", "sha": "5ee398aa239a379a431190edbb6022b1a0aa2c70", "save_path": "github-repos/lean/semorrison-proof", "path": "github-repos/lean/semorrison-proof/proof-5ee398aa239a379a431190edbb6022b1a0aa2c70/lean/20170323-equality-for-inductive-types.2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.880797071719777, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.49854746833984365}}
{"text": "import GMLInit.Data.Nat.Extended.Basic\n\nnamespace ENat\n\nabbrev Finite (e : ENat) : Prop := ∃ x, e.isLE x\n\nnamespace Finite\nvariable (e : ENat)\n\nprivate def rel (x y : Nat) : Prop := x = y + 1 ∧ ¬e.isLE y\n\nprivate def wf (isFinite : Finite e) : WellFounded (Finite.rel e) := by\n  constr\n  intro x\n  match isFinite with\n  | ⟨n,hn⟩ =>\n    apply Acc.intro\n    intro x' ⟨h', hx⟩\n    cases h'\n    have : x + 1 ≤ n := by\n      apply Nat.succ_le_of_lt\n      apply Nat.lt_of_not_ge\n      intro hge\n      apply hx\n      apply e.mono hge\n      exact hn\n    match Nat.le.dest this with\n    | ⟨y, hxy⟩ =>\n      clear this\n      induction y generalizing x with\n      | zero =>\n        rw [hxy]\n        apply Acc.intro\n        intro | _, ⟨rfl, _⟩ => contradiction\n      | succ y H =>\n        apply Acc.intro\n        intro\n        | _, ⟨rfl, h⟩ =>\n          apply H\n          · exact h\n          · rw [←hxy]\n            simp_arith\n\nend Finite\n\nprivate def toNatAux {e : ENat} (isFinite : Finite e) (x : Nat) : Nat :=\n  if h : e.isLE x then x else toNatAux isFinite (x+1)\ntermination_by' ⟨Finite.rel e, Finite.wf e isFinite⟩\ndecreasing_by trivial\n\nprivate theorem toNatAux_eq {e : ENat} (isFinite : Finite e) (x : Nat) : toNatAux isFinite x = if e.isLE x then x else toNatAux isFinite (x+1) :=\n  WellFounded.fix_eq _ _ _\n\nprivate theorem isLE_toNatAux {e : ENat} (isFinite : Finite e) (x : Nat) : e.isLE (toNatAux isFinite x) := by\n  rw [toNatAux_eq]\n  split\n  · assumption\n  · apply isLE_toNatAux\ntermination_by' ⟨Finite.rel e, Finite.wf e isFinite⟩\ndecreasing_by trivial\n\nprivate theorem toNatAux_le {e : ENat} {y : Nat} (hy : e.isLE y) {x} (hle : x ≤ y) : toNatAux ⟨y,hy⟩ x ≤ y := by\n  rw [toNatAux_eq]\n  split\n  · assumption\n  · apply toNatAux_le hy\n    apply Nat.succ_le_of_lt\n    apply Nat.lt_of_le_of_ne\n    · exact hle\n    · intro heq\n      cases heq\n      contradiction\ntermination_by' invImage PSigma.fst ⟨Finite.rel e, Finite.wf e ⟨y,hy⟩⟩\ndecreasing_by trivial\n\ndef toNat (e : ENat) (isFinite : Finite e) : Nat := toNatAux isFinite 0\n\ntheorem isLE_toNat (e : ENat) (isFinite : Finite e) : e.isLE (e.toNat isFinite) :=\n  isLE_toNatAux isFinite 0\n\ntheorem toNat_le_of_isLE {e : ENat} {x : Nat} (h : e.isLE x) : toNat e ⟨x,h⟩ ≤ x := by\n  apply toNatAux_le\n  · exact h\n  · exact Nat.zero_le x\n\ntheorem isLE_iff_toNat_le (e : ENat) (isFinite : Finite e) (x : Nat) : e.isLE x ↔ e.toNat isFinite ≤ x := by\n  constr\n  · intro h\n    apply toNat_le_of_isLE\n    exact h\n  · intro h\n    apply mono _ h\n    apply isLE_toNat\n\n@[simp] theorem toNat_ofNat (x : Nat) : toNat (ENat.ofNat x) ⟨x, ofNat_isLE_self x⟩ = x := by\n  antisymmetry using (.≤.:Nat→Nat→Prop)\n  · rw [←isLE_iff_toNat_le]\n    exact ofNat_isLE_self x\n  · cases x with\n    | zero => exact Nat.zero_le _\n    | succ x =>\n      apply Nat.succ_le_of_lt\n      apply Nat.lt_of_not_ge\n      intro (h : _ ≤ x)\n      rw [←isLE_iff_toNat_le, ofNat_isLE_iff_le] at h\n      apply Nat.not_gt_of_le h\n      exact Nat.lt_succ_self x\n\n@[simp] theorem ofNat_toNat (e : ENat) (h : Finite e) : ENat.ofNat (toNat e h) = e := by\n  apply ENat.ext\n  intro x\n  cases hx : e.isLE x with\n  | true => rw [ofNat_isLE_iff_le, ←isLE_iff_toNat_le, hx]\n  | false =>\n    rw [←Bool.not_eq_true] at hx ⊢\n    apply mt _ hx\n    intro hx\n    rw [ofNat_isLE_iff_le] at hx\n    rw [isLE_iff_toNat_le _ h]\n    exact hx\n\nend ENat\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/Nat/Extended/Finite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4985157395064323}}
{"text": "import Rings.ToMathlib.fol\nimport Rings.ToMathlib.list\nimport Rings.ToMathlib.nat\nimport Rings.Rings\n\nopen Rings fol\n\nnamespace realize_ring_term\n\nvariables\n  {A : Type*} [comm_ring A]\n  {c : ℕ} (xs : dvector (struc_to_ring_struc.Structure A) c)\n\n@[simp] lemma list_sumr :\n  Π {l : list (bounded_ring_term c)},\n  realize_bounded_term xs (list.sumr l) dvector.nil\n  =\n  list.sumr (list.map (λ t, realize_bounded_term xs t dvector.nil) l)\n| list.nil := by simp\n| (list.cons t ts) :=\nbegin\n  simp only [list.map, models_ring_theory_to_comm_ring.realize_add,\n    list.sumr, realize_bounded_term],\n  simp only [struc_to_ring_struc.func_map, dvector.last,\n    struc_to_ring_struc.binaries_map, add_right_inj, dvector.nth],\n  rw list_sumr,\nend\n\ndef add_zero_hom :\n  add_zero_hom (bounded_ring_term c) A :=\n⟨ λ t, realize_bounded_term xs t dvector.nil ,\n  models_ring_theory_to_comm_ring.realize_zero ,\n  λ t s, models_ring_theory_to_comm_ring.realize_add ⟩\n\nlemma sumr\n  {ts : list (bounded_ring_term c)} :\n  realize_bounded_term xs (ts).sumr dvector.nil\n  =\n  (list.map (add_zero_hom xs).to_fun ts).sumr :=\nbegin\n  rw ← list.add_zero_hom_sumr (add_zero_hom xs) ts,\n  refl,\nend\n\nlemma nat_non_comm_prod :\n  Π (n : ℕ) (ts : fin n → bounded_ring_term c),\n  realize_bounded_term xs (nat.non_comm_prod _ ts) dvector.nil\n  =\n  nat.non_comm_prod n (λ i, realize_bounded_term xs (ts i) dvector.nil)\n| nat.zero ts :=\nbegin\n  simp only [nat.non_comm_prod],\n  refl,\nend\n| (nat.succ n) ts :=\nbegin\n  simp only [nat.non_comm_prod, struc_to_ring_struc.func_map,\n    dvector.last, struc_to_ring_struc.binaries_map, realize_bounded_term,\n    dvector.nth],\n  rw nat_non_comm_prod n,\nend\n\nlemma pow (t : bounded_ring_term c) : Π (n : ℕ),\n  realize_bounded_term xs (npow_rec n t) dvector.nil\n  =\n  (realize_bounded_term xs t dvector.nil) ^ n\n| nat.zero := by simpa\n| (nat.succ n) := by simp [npow_rec, pow n, pow_succ]\n\nend realize_ring_term\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/RealizeThings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4985157395064323}}
{"text": "import tactic.induction\nimport tactic\n\ninductive eexpr : Type\n| int : ℤ → eexpr\n| str : string → eexpr\n| var : ℕ → eexpr\n| plus : eexpr → eexpr → eexpr\n| cat : eexpr → eexpr → eexpr\n| len : eexpr → eexpr\n| lett : eexpr → eexpr → eexpr\n\ninductive typ : Type\n| num : typ\n| str : typ\n\ndef env : Type := list typ\n\ndef lookup (n : ℕ ) (τ : typ) (Γ : env) : Prop :=\n  list.nth Γ n = some τ\n\nlemma lookup_lt (n : ℕ ) (τ : typ) (Γ : env) (h : lookup n τ Γ ) :\n  n < list.length Γ :=\nbegin\n  induction' Γ ,\n  simp [lookup] at h,\n  contradiction,\n  cases' n,\n  simp,\n  simp,\n  have : n < Γ.length, {\n    apply ih n τ,\n    simp [lookup],\n    simp [lookup] at h,\n    assumption,\n  },\n  exact nat.succ_lt_succ this,\nend\n\n-- Typing derivations\ninductive has_type : env → eexpr → typ → Prop\n| refl (n : ℕ ) (τ : typ) (Γ : env) :\n      lookup n τ Γ →\n      has_type Γ (eexpr.var n) τ\n| strlit (s : string) (Γ : env) :\n      has_type Γ (eexpr.str s) typ.str\n| numlit (n : ℤ) (Γ : env) :\n      has_type Γ (eexpr.int n) typ.num\n| plus (e1 e2 : eexpr) (Γ : env) :\n      has_type Γ e1 typ.num →\n      has_type Γ e2 typ.num →\n      has_type Γ (eexpr.plus e1 e2) typ.num\n| cat (e1 e2 : eexpr) (Γ : env) :\n      has_type Γ e1 typ.str →\n      has_type Γ e2 typ.str →\n      has_type Γ (eexpr.cat e1 e2) typ.str\n| len (e1 : eexpr) (Γ : env) :\n      has_type Γ e1 typ.str →\n      has_type Γ (eexpr.len e1) typ.num\n| lett (e1 e2 : eexpr) (τ1 τ2: typ) (Γ : env): \n      has_type Γ e1 τ1 →\n      has_type (τ1 :: Γ) e2 τ2 →\n      has_type Γ (eexpr.lett e1 e2) τ2\n\n-- ∅ ⊢ let 1+1 in x0 : int\n-- [int] ⊢ x0 : int\n\n-- ∅ ⊢ let 1+1 in let \"foo\" in len(x0) + x1 : int\n-- [int] ⊢ let \"foo\" in len(x0) + x1 : int\n-- [str, int] ⊢ len(x0) + x1 : int\n\n-- Unicity: term can only have one type\nlemma unicity (Γ : env) (e : eexpr) (τ1 : typ) (h1 : has_type Γ e τ1) :\n  ∀ τ2, (has_type Γ e τ2) → τ1 = τ2 :=\nbegin\n  induction' h1,\n  all_goals {\n    try {\n      intros τ2 h2,\n      cases h2,\n      refl,\n    }\n  },\n  case refl : v τ Γ h {\n    intros τ2 hh,\n    cases' hh,\n    simp [lookup] at *,\n    apply option.some.inj,\n    rw ← h,\n    rw ← h_1,\n  },\n  case has_type.lett {\n    intros τ2 h2,\n    cases' h2,\n    have : τ1 = τ1_2,\n    {\n      apply ih_h1,\n      assumption,\n    },\n    rw ← this at *,\n    apply ih_h1_1,\n    assumption,\n  }\nend\n\nlemma env_append (Γ : env) (stuff : list typ) (n : ℕ ) (τ : typ) :\n  lookup n τ Γ → lookup n τ (list.append Γ stuff) :=\nbegin\n  induction' Γ ,\n  simp [lookup],\n  cases' n,\n  simp [lookup],\n  simp [lookup] at *,\n  apply ih,\nend\n\n-- Weakening: you can add extra stuff in the context and typing doesn't change\nlemma weakening (Γ : env) (stuff : list typ) (e : eexpr) (τ : typ) :\n  has_type Γ e τ → has_type (list.append Γ stuff) e τ :=\nbegin\n  intros ht,\n  induction' ht,\n  case refl {\n    apply has_type.refl,\n    apply env_append,\n    assumption,\n  },\n  case strlit {\n    constructor,\n  },\n  case numlit {\n    constructor,\n  },\n  case lett {\n    apply has_type.lett _ _ τ1 τ,\n    {\n      apply ih_ht,\n    },\n    {\n      simp [list.append] at ih_ht_1,\n      apply ih_ht_1,\n    },\n  },\n  case plus {\n    constructor,\n    apply ih_ht,\n    apply ih_ht_1,\n  },\n  case cat {\n    constructor,\n    apply ih_ht,\n    apply ih_ht_1,\n  },\n  case len {\n    constructor,\n    apply ih,\n  },\nend\n\n-- Example of typing inversion: plus expression and its parts can only have num type\nlemma inversion_plus (Γ : env) (e1 e2 : eexpr) (τ : typ) (h : has_type Γ (eexpr.plus e1 e2) τ):\n  τ = typ.num ∧ (has_type Γ e1 typ.num) ∧ (has_type Γ e2 typ.num) :=\nbegin\n  cases' h,\n  split,\n  refl,\n  split,\n  assumption',\nend\n\ndef incr : ℕ → eexpr → eexpr\n| n (eexpr.var n1) := eexpr.var (if (n1 < n) then n1 else nat.succ n1)\n| n (eexpr.int x) := eexpr.int x\n| n (eexpr.str x) := eexpr.str x\n| n (eexpr.plus e1 e2) := eexpr.plus (incr n e1) (incr n e2)\n| n (eexpr.cat e1 e2) := eexpr.cat (incr n e1) (incr n e2)\n| n (eexpr.len e1) := eexpr.len (incr n e1)\n| n (eexpr.lett e1 e2) := eexpr.lett (incr n e1) (incr (nat.succ n) e2)\n\ndef subst : ℕ → eexpr → eexpr → eexpr\n| _ _ (eexpr.int n) := eexpr.int n\n| _ _ (eexpr.str n) := eexpr.str n\n| n e (eexpr.plus e1 e2) := eexpr.plus (subst n e e1) (subst n e e2)\n| n e (eexpr.cat e1 e2) := eexpr.cat (subst n e e1) (subst n e e2)\n| n e (eexpr.len e1) := eexpr.len (subst n e e1)\n| n e (eexpr.var n1) := ite (n = n1) e (eexpr.var n1)\n| n e (eexpr.lett e1 e2) := (eexpr.lett (subst n e e1) (subst (nat.succ n) (incr 0 e) e2))\n\n\nlemma closed_incr (e : eexpr) (τ : typ) (Γ : env) (ht : has_type Γ  e τ) (n : ℕ ) (hn : n >= list.length Γ ):\n  incr n e = e :=\nbegin\n  induction' ht,\n  case refl {\n    dsimp [incr],\n    simp [hn],\n    have : n_1 < list.length Γ, apply lookup_lt _ _ _ h,\n    intro h1,\n    linarith,\n  },\n  case lett {\n    simp [incr],\n    split,\n    exact ih_ht n hn,\n    apply ih_ht_1 n.succ,\n    simp [list.length],\n    apply nat.succ_le_succ,\n    linarith,\n  },\n  all_goals { try { simp [incr]}},\n  case plus {\n    split,\n    apply ih_ht, assumption,\n    apply ih_ht_1, assumption,\n  },\n  case cat {\n    split,\n    apply ih_ht, assumption,\n    apply ih_ht_1, assumption,\n  },\n  case len {\n    apply ih, assumption,\n  },\nend\n\nvariable {α : Type}\n\n@[simp] def insert_nth : ∀ (l : list α) (n : ℕ) (h : n ≤ l.length), α → list α\n| xs 0 _ a := a :: xs\n| (x::xs) (nat.succ i) h a := x :: insert_nth xs i (nat.le_of_succ_le_succ h) a\n| []      (nat.succ i) h _ := absurd h (by {simp [list.length]})\n\nlemma blah (l : list α) (h : 0 ≤ l.length) (x : α):\n  insert_nth l 0 h x = x :: l :=\nbegin\n  induction' l,\n  simp,\n  simp,\nend\n\nlemma map_insert (l : list α) (x : α) (n n1 : ℕ) (hn : n ≤ l.length) :\n  (list.nth (insert_nth l n hn x) (ite (n1 < n) n1 n1.succ)) = list.nth l n1 :=\nbegin\n  induction' l,\n  simp [insert_nth],\n  have hh : n = 0, {\n    simp [list.length] at hn,\n    assumption,\n  },\n  cases' n,\n  simp,\n  apply nat.succ_le_succ,\n  exact zero_le n1,\n  contradiction,\n\n\n  cases' n,\n  simp [insert_nth],\n  simp [insert_nth],\n  cases' n1,\n  simp,\n  simp [list.nth],\n  have : n ≤ l.length, {\n    simp [list.length] at hn,\n    apply nat.succ_le_succ_iff.mp,\n    assumption',\n  },\n  specialize ih x n n1 this,\n  have : ite (n1.succ < n.succ) n1.succ n1.succ.succ = (ite (n1 < n) n1 n1.succ).succ, {\n    by_cases (n1 < n),\n    simp [h],\n    intro hh,\n    rw nat.succ_le_succ_iff at hh,\n    exact nat.lt_le_antisymm h hh,\n    simp [h],\n    intro hh,\n    rw nat.succ_lt_succ_iff at hh,\n    contradiction,\n  },\n  rw this,\n  simp [list.nth],\n  exact ih,\nend\n\nlemma incr_type (e : eexpr) (τ τ' : typ) (Γ : env)\n  (ht : has_type Γ e τ) (n : ℕ ) (hn : n ≤ list.length Γ ) :\n  has_type (insert_nth Γ n hn τ') (incr n e) τ :=\nbegin\n  induction' ht,\n  all_goals { simp [incr]},\n  case refl {\n    constructor,\n    simp [lookup],\n    rw (map_insert),\n    simp [lookup] at h,\n    assumption,\n  },\n  case lett {\n    apply has_type.lett _ _ τ1,\n    apply ih_ht,\n    specialize ih_ht_1 τ' n.succ,\n    simp [insert_nth] at ih_ht_1,\n    apply ih_ht_1,\n    exact nat.succ_le_succ hn,\n  },\n  case strlit {\n    constructor,\n  },\n  case numlit {\n    constructor,\n  },\n  case plus {\n    constructor,\n    apply ih_ht,\n    apply ih_ht_1,\n  },\n  case cat {\n    constructor,\n    apply ih_ht,\n    apply ih_ht_1,\n  },\n  case len {\n    constructor,\n    apply ih,\n  }\nend\n\nlemma type_subst\n  (e e' : eexpr) (Γ : env) (τ τ' : typ)\n  (n : ℕ ) (te : has_type Γ e τ)\n  (hn : lookup n τ Γ )\n  (te' : has_type Γ e' τ')\n  : has_type Γ (subst n e e') τ'\n  :=\nbegin\n  -- induction on the derivation of te'\n  induction' te',\n  case refl {\n    dsimp [subst],\n    by_cases hh : (n=n_1),\n    rw ← hh at *,\n    simp,\n    have : τ' = τ,\n    {\n      simp [lookup] at *,\n      apply option.some.inj,\n      rw ← hn,\n      rw ← h,\n    },\n    rw this,\n    assumption,\n    simp [hh],\n    constructor,\n    assumption,\n  },\n  case lett {\n    dsimp [subst],\n    apply has_type.lett _ _ τ1 τ',\n    {\n      apply ih_te',\n      exact te,\n      exact hn,\n    },\n    {\n      apply ih_te'_1 (incr 0 e) τ n.succ,\n      rw ← blah _ (nat.zero_le Γ.length),\n      apply incr_type,\n      exact te,\n      dsimp [lookup],\n      dsimp [lookup] at hn,\n      assumption,\n    },\n  },\n  {\n    apply has_type.strlit,\n  },\n  {\n    apply has_type.numlit,\n  },\n  case plus {\n    apply has_type.plus,\n    exact ih_te' _ _ _ te hn,\n    exact ih_te'_1 _ _ _ te hn,\n  },\n  case cat {\n    apply has_type.cat,\n    exact ih_te' _ _ _ te hn,\n    exact ih_te'_1 _ _ _ te hn,\n  },\n  case len {\n    apply has_type.len,\n    exact ih _ _ _ te hn,\n  },\nend\n", "meta": {"author": "mattiast", "repo": "lean-playground", "sha": "40407cbc7e4dd9172c69bbfbfec35d490e7fe155", "save_path": "github-repos/lean/mattiast-lean-playground", "path": "github-repos/lean/mattiast-lean-playground/lean-playground-40407cbc7e4dd9172c69bbfbfec35d490e7fe155/src/lang_e.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6654105587468141, "lm_q1q2_score": 0.4984505410287646}}
{"text": "import .prop\n\nnamespace fol\n\nvariable {α : Type}\n\nclass is_symb (α : Type) extends prop.is_symb α :=\n(fa : α) (ex : α)\n\ninductive symb : Type \n| fn : string → symb \n| prd : string → symb \n| true : symb\n| false : symb\n| not : symb\n| and : symb\n| or  : symb\n| imp : symb\n| fa  : symb\n| ex  : symb\n\ninstance : decidable_eq symb :=\nby tactic.mk_dec_eq_instance\n\ninstance : is_symb symb := \n{ true  := symb.true,\n  false := symb.false,\n  not   := symb.not,\n  and   := symb.and,\n  or    := symb.or,\n  imp   := symb.imp,\n  fa    := symb.fa,\n  ex    := symb.ex }\n\ndef fa [is_symb α] (p : exp α) := exp.app (exp.cst (is_symb.fa α)) (exp.lam p)\nnotation  `∀'` p := fa p\n\ndef ex [is_symb α] (p : exp α) := exp.app (exp.cst (is_symb.ex α)) (exp.lam p)\nnotation  `∃'` p := ex p\n\ndef pred (P : string) (args : list (exp symb)) : exp symb := \nlist.foldl exp.app (exp.cst (symb.prd P)) args\n\ndef func (F : string) (args : list (exp symb)) : exp symb := \nlist.foldl exp.app (exp.cst (symb.fn F)) args\n\ninductive inf [is_symb α] : list (seq α) → seq α → Prop\n| prop : ∀ S s, prop.inf S s → inf S s\n| fal : ∀ t Γ Δ p, inf [(inst t p)::Γ ==> Δ] ((∀' p)::Γ ==> Δ)\n| far : ∀ k Γ Δ p, k ∉ fvrs_list Γ → k ∉ fvrs_list Δ   \n  → inf [Γ ==> (inst (exp.fvr α k) p)::Δ] (Γ ==> (∀' p)::Δ)\n| exl : ∀ k Γ Δ p, k ∉ fvrs_list Γ → k ∉ fvrs_list Δ   \n  → inf [(inst (exp.fvr α k) p)::Γ ==> Δ] ((∃' p)::Γ ==> Δ) \n| exr : ∀ t Γ Δ p, inf [Γ ==> (inst t p)::Δ] (Γ ==> (∃' p)::Δ)\n\ninductive thm [is_symb α] : (seq α) → Prop  \n| inf : ∀ {s S}, inf S s → (∀ s' ∈ S, thm s') → thm s \n\n\n\n/- Derived rules -/\n\nopen list\n\nlemma thm.id [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p, thm (p::Γ ==> p::Δ) :=\nbegin\n  intros Γ Δ p, apply thm.inf, apply inf.prop,\n  apply prop.inf.id, apply forall_mem_nil \nend\n \nlemma thm.truer [is_symb α] : \n  ∀ (Γ Δ : list (exp α)), thm (Γ ==> ⊤'::Δ) :=\nbegin\n  intros Γ Δ, apply thm.inf, apply inf.prop,\n  apply prop.inf.truer, apply forall_mem_nil\nend\n\nlemma thm.falsel [is_symb α] : \n  ∀ (Γ Δ : list (exp α)), thm (⊥'::Γ ==> Δ) :=\nbegin\n  intros Γ Δ, apply thm.inf, apply inf.prop,\n  apply prop.inf.falsel, apply forall_mem_nil\nend\n\nlemma thm.andl [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p q,\n  thm ((p ∧' q)::Γ ==> Δ) → thm (p::q::Γ ==> Δ) :=\nbegin\n  intros Γ Δ p q h, apply thm.inf, apply inf.prop, apply prop.inf.andl, \n  rewrite forall_mem_singleton, apply h \nend\n\nlemma thm.andr [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p q, \n  thm (Γ ==> p::Δ) → thm (Γ ==> q::Δ) \n  → thm (Γ ==> (p ∧' q)::Δ) :=\nbegin\n  intros Γ Δ p q h1 h2, \n  apply thm.inf, apply inf.prop, apply prop.inf.andr, intros s hs,\n  rewrite mem_cons_iff at hs, cases hs with hs hs,\n  rewrite hs, apply h1, rewrite mem_singleton at hs,\n  rewrite hs, apply h2\nend\n\nlemma thm.orl [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p q,\n  thm (p::Γ ==> Δ) → thm (q::Γ ==> Δ)\n  → thm ((p ∨' q)::Γ ==> Δ) :=\nbegin\n  intros Γ Δ p q h1 h2, \n  apply thm.inf, apply inf.prop, apply prop.inf.orl, intros s hs,\n  rewrite mem_cons_iff at hs, cases hs with hs hs,\n  rewrite hs, apply h1, rewrite mem_singleton at hs,\n  rewrite hs, apply h2\nend\n\nlemma thm.orr [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p q, \n  thm (Γ ==> p::q::Δ) → thm (Γ ==> (p ∨' q)::Δ) := \nbegin\n  intros Γ Δ p q h, apply thm.inf, apply inf.prop, apply prop.inf.orr, \n  rewrite forall_mem_singleton, apply h \nend\n\nlemma thm.impl [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p q, \n  thm (Γ ==> p::Δ) → thm (q::Γ ==> Δ) \n  → thm ((p →' q)::Γ ==> Δ) :=\nbegin\n  intros Γ Δ p q h1 h2, apply thm.inf, apply inf.prop, apply prop.inf.impl, \n  intros s hs, rewrite mem_cons_iff at hs, \n  cases hs with hs hs, rewrite hs, apply h1, \n  rewrite mem_singleton at hs, rewrite hs, apply h2\nend\n\nlemma thm.impr [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p q, \n  thm (p::Γ ==> q::Δ) → thm (Γ ==> (p →' q)::Δ) :=\nbegin\n  intros Γ Δ p q h, apply thm.inf, apply inf.prop, apply prop.inf.impr, \n  rewrite forall_mem_singleton, apply h\nend\n\nlemma thm.wl [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p, \n  thm (Γ ==> Δ) → thm (p::Γ ==> Δ) :=  \nbegin\n  intros Γ Δ p h, apply thm.inf, apply inf.prop, apply prop.inf.wl, \n  rewrite forall_mem_singleton, apply h\nend\n\nlemma thm.wr [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p, \n  thm (Γ ==> Δ) → thm (Γ ==> p::Δ) :=\nbegin\n  intros Γ Δ p h, apply thm.inf, apply inf.prop, apply prop.inf.wr, \n  rewrite forall_mem_singleton, apply h\nend\n\nlemma thm.cl [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p, \n  thm (p::p::Γ ==> Δ) → thm (p::Γ ==> Δ) := \nbegin\n  intros Γ Δ p h, apply thm.inf, apply inf.prop, apply prop.inf.cl, \n  rewrite forall_mem_singleton, apply h\nend\n\nlemma thm.cr [is_symb α] : \n  ∀ (Γ Δ : list (exp α)) p, \n  thm (Γ ==> p::p::Δ) → thm (Γ ==> p::Δ) := \nbegin\n  intros Γ Δ p h, apply thm.inf, apply inf.prop, apply prop.inf.cr, \n  rewrite forall_mem_singleton, apply h\nend\n\nlemma thm.rl [is_symb α] : \n  ∀ n (Γ Δ : list (exp α)), thm (rotate n Γ ==> Δ) → thm (Γ ==> Δ) :=\nbegin\n  intros n Γ Δ h, apply thm.inf, apply inf.prop,\n  apply prop.inf.pl (rotate n Γ), \n  apply perm_rotate, intros s' hs', \n  rewrite list.mem_singleton at hs', \n  rewrite hs', apply h\nend\n \nlemma thm.rr [is_symb α] : \n  ∀ n (Γ Δ : list (exp α)), thm (Γ ==> rotate n Δ) → thm (Γ ==> Δ) :=\nbegin\n  intros n Γ Δ h, apply thm.inf, apply inf.prop,\n  apply prop.inf.pr _ (rotate n Δ), \n  apply perm_rotate, intros s' hs', \n  rewrite list.mem_singleton at hs', \n  rewrite hs', apply h\nend\n\nlemma thm.fal [is_symb α] : \n  ∀ t (Γ Δ : list (exp α)) p, \n  thm ((inst t p)::Γ ==> Δ) → thm ((∀' p)::Γ ==> Δ) :=\nbegin\n  intros t Γ Δ p h, apply thm.inf, apply inf.fal t, \n  rewrite list.forall_mem_singleton, apply h\nend\n\nlemma thm.far [is_symb α] : \n  ∀ k (Γ Δ : list (exp α)) p, \n  k ∉ fvrs_list Γ → k ∉ fvrs_list Δ   \n  → thm (Γ ==> (inst (exp.fvr α k) p)::Δ) → thm (Γ ==> (∀' p)::Δ) :=\nbegin\n  intros k Γ Δ p h1 h2 h3, \n  apply thm.inf, apply inf.far k; try {assumption},\n  rewrite list.forall_mem_singleton, apply h3\nend\n\nlemma thm.exl [is_symb α] : \n  ∀ k (Γ Δ : list (exp α)) p, \n  k ∉ fvrs_list Γ → k ∉ fvrs_list Δ   \n  → thm ((inst (exp.fvr α k) p)::Γ ==> Δ) → thm ((∃' p)::Γ ==> Δ) :=\nbegin\n  intros k Γ Δ p h1 h2 h3, \n  apply thm.inf, apply inf.exl k; try {assumption},\n  rewrite list.forall_mem_singleton, apply h3\nend\n\nlemma thm.exr [is_symb α] : \n  ∀ t (Γ Δ : list (exp α)) p, \n  thm (Γ ==> (inst t p)::Δ) → thm (Γ ==> (∃' p)::Δ) :=\nbegin\n  intros t Γ Δ p h, apply thm.inf, apply inf.exr t, \n  rewrite list.forall_mem_singleton, apply h\nend\n\nopen tactic\n\nmeta def apply_exl (n : nat) : tactic unit := \ndo to_expr ``(thm.exl %%(`(n))) >>= apply, \n   dec_triv_tac, dec_triv_tac\n\nmeta def apply_far (n : nat) : tactic unit := \ndo to_expr ``(thm.far %%(`(n))) >>= apply, \n   dec_triv_tac, dec_triv_tac\n\n\n/- Printing -/\n\nopen expr \n\nmeta def getsqt : tactic (list (exp symb) × list (exp symb)) :=\ndo `(thm (%%Γe ==> %%Δe)) ← tactic.target,\n    Γ ← eval_expr (list (exp symb)) Γe, \n    Δ ← eval_expr (list (exp symb)) Δe, \n    return (Γ,Δ)\n\ndef fml2str : exp symb → string \n| (exp.app (exp.app e p) q) := \n  if e = exp.cst (prop.is_symb.and symb)\n  then \"(\" ++ fml2str p ++ \" ∧ \" ++ fml2str q ++ \")\" else \n  if e = exp.cst (prop.is_symb.or symb)\n  then \"(\" ++ fml2str p ++ \" ∨ \" ++ fml2str q ++ \")\" else \n  if e = exp.cst (prop.is_symb.imp symb)\n  then \"(\" ++ fml2str p ++ \" → \" ++ fml2str q ++ \")\" else \n    fml2str (exp.app e p) ++ \" \" ++ fml2str q\n| (exp.app e1 e2) := fml2str e1 ++ \" \" ++ fml2str e2\n| (exp.lam e) := fml2str e\n| (exp.cst s) := \n  if s = prop.is_symb.true symb\n  then \"⊤\" else\n  if s = prop.is_symb.false symb\n  then \"⊥\" else\n  match s with \n  | (symb.fa) := \"∀\"\n  | (symb.ex) := \"∃\"\n  | (symb.not) := \"¬\"\n  | (symb.prd str) := str \n  | (symb.fn str) := str \n  | _ := \"ERROR 1\"\n  end\n| (exp.bvr _ n) := \"#\" ++ to_string n\n| (exp.fvr _ n) := \"&\" ++ to_string n\n\nmeta def showgoal : tactic unit :=\n(do (Γ,Δ) ← getsqt, trace (sqt2str fml2str Γ Δ)) <|> trace \"No Goals\"\n\n\n/- Examples -/\n\nexample : thm ([] ==> [∀' (pred \"P\" [# 0]) →' ∃' (pred \"P\" [# 0])]) :=\nbegin\n  showgoal,\n  apply thm.impr, \n  apply thm.fal (& 0),\n  apply thm.exr (& 0),\n  apply thm.id, \n  showgoal\nend\n\nexample : thm ([∃' (pred \"P\" [# 0] ∨' pred \"Q\" [# 0])] ==> [∃' (pred \"P\" [# 0]) ∨' ∃' (pred \"Q\" [# 0])]) :=\nbegin\n  showgoal,\n  apply_exl 0, apply thm.orr, apply thm.orl, \n  apply thm.exr (& 0), apply thm.id, apply thm.rr 1,\n  apply thm.exr (& 0), apply thm.id,\n  showgoal\nend\n\nexample : thm ([∀' (pred \"P\" [# 0]), ∀' ((pred \"P\" [# 0]) →' (pred \"Q\" [# 0]))] ==> [∀' (pred \"Q\" [# 0])]) :=\nbegin\n  showgoal,\n  apply_far 0, apply thm.fal (& 0),\n  apply thm.rl 1, apply thm.fal (& 0),\n  apply thm.impl, apply thm.id, apply thm.id,\n  showgoal\nend\n\nexample : thm ([∀' (pred \"P\" [# 0]), (pred \"P\" [& 0]) →' ((pred \"P\" [& 1]) →' (pred \"Q\" []))] ==> [pred \"Q\" []]) :=\nbegin\n  showgoal,\n  apply thm.rl 1, apply thm.impl, \n  apply thm.fal (& 0), apply thm.id,\n  apply thm.impl, apply thm.fal (& 1), \n  apply thm.id, apply thm.id,\n  showgoal\nend\n\nend fol\n", "meta": {"author": "avigad", "repo": "embed", "sha": "0e3612028d4039d29d06239ef03bc50576ca0f8b", "save_path": "github-repos/lean/avigad-embed", "path": "github-repos/lean/avigad-embed/embed-0e3612028d4039d29d06239ef03bc50576ca0f8b/src/fol.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4984505410287646}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.witt_vector.basic\nimport Mathlib.ring_theory.witt_vector.is_poly\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-! ## The Verschiebung operator -/\n\nnamespace witt_vector\n\n\n-- unfortunately, without this attribute, some of the code breaks for reasons I don't understand\n\n/--\n`verschiebung_fun x` shifts the coefficients of `x` up by one,\nby inserting 0 as the 0th coefficient.\n`x.coeff i` then becomes `(verchiebung_fun x).coeff (i + 1)`.\n\n`verschiebung_fun` is the underlying function of the additive monoid hom `witt_vector.verschiebung`.\n-/\ndef verschiebung_fun {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) : witt_vector p R :=\n  mk p fun (n : ℕ) => ite (n = 0) 0 (coeff x (n - 1))\n\ntheorem verschiebung_fun_coeff {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) : coeff (verschiebung_fun x) n = ite (n = 0) 0 (coeff x (n - 1)) := sorry\n\ntheorem verschiebung_fun_coeff_zero {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) : coeff (verschiebung_fun x) 0 = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coeff (verschiebung_fun x) 0 = 0)) (verschiebung_fun_coeff x 0)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (ite (0 = 0) 0 (coeff x (0 - 1)) = 0)) (if_pos rfl))) (Eq.refl 0))\n\n@[simp] theorem verschiebung_fun_coeff_succ {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) : coeff (verschiebung_fun x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem ghost_component_zero_verschiebung_fun {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) : coe_fn (ghost_component 0) (verschiebung_fun x) = 0 := sorry\n\ntheorem ghost_component_verschiebung_fun {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : ℕ) : coe_fn (ghost_component (n + 1)) (verschiebung_fun x) = ↑p * coe_fn (ghost_component n) x := sorry\n\n/--\nThe 0th Verschiebung polynomial is 0. For `n > 0`, the `n`th Verschiebung polynomial is the\nvariable `X (n-1)`.\n-/\ndef verschiebung_poly (n : ℕ) : mv_polynomial ℕ ℤ :=\n  ite (n = 0) 0 (mv_polynomial.X (n - 1))\n\n@[simp] theorem verschiebung_poly_zero : verschiebung_poly 0 = 0 :=\n  rfl\n\ntheorem aeval_verschiebung_poly' {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) : coe_fn (mv_polynomial.aeval (coeff x)) (verschiebung_poly n) = coeff (verschiebung_fun x) n := sorry\n\n/--\n`witt_vector.verschiebung` has polynomial structure given by `witt_vector.verschiebung_poly`.\n-/\ntheorem verschiebung_fun_is_poly (p : ℕ) : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => verschiebung_fun := sorry\n\n/--\n`verschiebung x` shifts the coefficients of `x` up by one, by inserting 0 as the 0th coefficient.\n`x.coeff i` then becomes `(verchiebung x).coeff (i + 1)`.\n\nThis is a additive monoid hom with underlying function `verschiebung_fun`.\n-/\ndef verschiebung {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] : witt_vector p R →+ witt_vector p R :=\n  add_monoid_hom.mk verschiebung_fun sorry sorry\n\n/-- `witt_vector.verschiebung` is a polynomial function. -/\ntheorem verschiebung_is_poly {p : ℕ} [hp : fact (nat.prime p)] : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => ⇑verschiebung :=\n  verschiebung_fun_is_poly p\n\n/-- verschiebung is a natural transformation -/\n@[simp] theorem map_verschiebung {p : ℕ} {R : Type u_1} {S : Type u_2} [hp : fact (nat.prime p)] [comm_ring R] [comm_ring S] (f : R →+* S) (x : witt_vector p R) : coe_fn (map f) (coe_fn verschiebung x) = coe_fn verschiebung (coe_fn (map f) x) := sorry\n\ntheorem ghost_component_zero_verschiebung {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) : coe_fn (ghost_component 0) (coe_fn verschiebung x) = 0 :=\n  ghost_component_zero_verschiebung_fun x\n\ntheorem ghost_component_verschiebung {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : ℕ) : coe_fn (ghost_component (n + 1)) (coe_fn verschiebung x) = ↑p * coe_fn (ghost_component n) x :=\n  ghost_component_verschiebung_fun x n\n\n@[simp] theorem verschiebung_coeff_zero {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) : coeff (coe_fn verschiebung x) 0 = 0 :=\n  rfl\n\n-- simp_nf complains if this is simp\n\ntheorem verschiebung_coeff_add_one {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : ℕ) : coeff (coe_fn verschiebung x) (n + 1) = coeff x n :=\n  rfl\n\n@[simp] theorem verschiebung_coeff_succ {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : ℕ) : coeff (coe_fn verschiebung x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem aeval_verschiebung_poly {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : ℕ) : coe_fn (mv_polynomial.aeval (coeff x)) (verschiebung_poly n) = coeff (coe_fn verschiebung x) n :=\n  aeval_verschiebung_poly' x n\n\n@[simp] theorem bind₁_verschiebung_poly_witt_polynomial {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) : coe_fn (mv_polynomial.bind₁ verschiebung_poly) (witt_polynomial p ℤ n) =\n  ite (n = 0) 0 (↑p * witt_polynomial p ℤ (n - 1)) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/verschiebung.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6654105521116445, "lm_q1q2_score": 0.49845053605844397}}
{"text": "/-\nCopyright (c) 2021 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.limits.comma\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Arrow\nimport Mathbin.CategoryTheory.Limits.Constructions.EpiMono\nimport Mathbin.CategoryTheory.Limits.Creates\nimport Mathbin.CategoryTheory.Limits.Unit\nimport Mathbin.CategoryTheory.StructuredArrow\n\n/-!\n# Limits and colimits in comma categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe build limits in the comma category `comma L R` provided that the two source categories have\nlimits and `R` preserves them.\nThis is used to construct limits in the arrow category, structured arrow category and under\ncategory, and show that the appropriate forgetful functors create limits.\n\nThe duals of all the above are also given.\n-/\n\n\nnamespace CategoryTheory\n\nopen Category Limits\n\nuniverse w' w v u₁ u₂ u₃\n\nvariable {J : Type w} [Category.{w'} J]\n\nvariable {A : Type u₁} [Category.{v} A]\n\nvariable {B : Type u₂} [Category.{v} B]\n\nvariable {T : Type u₃} [Category.{v} T]\n\nnamespace Comma\n\nvariable {L : A ⥤ T} {R : B ⥤ T}\n\nvariable (F : J ⥤ Comma L R)\n\n#print CategoryTheory.Comma.limitAuxiliaryCone /-\n/-- (Implementation). An auxiliary cone which is useful in order to construct limits\nin the comma category. -/\n@[simps]\ndef limitAuxiliaryCone (c₁ : Cone (F ⋙ fst L R)) : Cone ((F ⋙ snd L R) ⋙ R) :=\n  (Cones.postcompose (whiskerLeft F (Comma.natTrans L R) : _)).obj (L.mapCone c₁)\n#align category_theory.comma.limit_auxiliary_cone CategoryTheory.Comma.limitAuxiliaryCone\n-/\n\n#print CategoryTheory.Comma.coneOfPreserves /-\n/-- If `R` preserves the appropriate limit, then given a cone for `F ⋙ fst L R : J ⥤ L` and a\nlimit cone for `F ⋙ snd L R : J ⥤ R` we can build a cone for `F` which will turn out to be a limit\ncone.\n-/\n@[simps]\ndef coneOfPreserves [PreservesLimit (F ⋙ snd L R) R] (c₁ : Cone (F ⋙ fst L R))\n    {c₂ : Cone (F ⋙ snd L R)} (t₂ : IsLimit c₂) : Cone F\n    where\n  pt :=\n    { left := c₁.pt\n      right := c₂.pt\n      Hom := (isLimitOfPreserves R t₂).lift (limitAuxiliaryCone _ c₁) }\n  π :=\n    { app := fun j =>\n        { left := c₁.π.app j\n          right := c₂.π.app j\n          w' := ((isLimitOfPreserves R t₂).fac (limitAuxiliaryCone F c₁) j).symm }\n      naturality' := fun j₁ j₂ t => by ext <;> dsimp <;> simp [← c₁.w t, ← c₂.w t] }\n#align category_theory.comma.cone_of_preserves CategoryTheory.Comma.coneOfPreserves\n-/\n\n#print CategoryTheory.Comma.coneOfPreservesIsLimit /-\n/-- Provided that `R` preserves the appropriate limit, then the cone in `cone_of_preserves` is a\nlimit. -/\ndef coneOfPreservesIsLimit [PreservesLimit (F ⋙ snd L R) R] {c₁ : Cone (F ⋙ fst L R)}\n    (t₁ : IsLimit c₁) {c₂ : Cone (F ⋙ snd L R)} (t₂ : IsLimit c₂) :\n    IsLimit (coneOfPreserves F c₁ t₂)\n    where\n  lift s :=\n    { left := t₁.lift ((fst L R).mapCone s)\n      right := t₂.lift ((snd L R).mapCone s)\n      w' :=\n        (isLimitOfPreserves R t₂).hom_ext fun j =>\n          by\n          rw [cone_of_preserves_X_hom, assoc, assoc, (is_limit_of_preserves R t₂).fac,\n            limit_auxiliary_cone_π_app, ← L.map_comp_assoc, t₁.fac, R.map_cone_π_app, ← R.map_comp,\n            t₂.fac]\n          exact (s.π.app j).w }\n  uniq s m w :=\n    CommaMorphism.ext _ _ (t₁.uniq ((fst L R).mapCone s) _ fun j => by simp [← w])\n      (t₂.uniq ((snd L R).mapCone s) _ fun j => by simp [← w])\n#align category_theory.comma.cone_of_preserves_is_limit CategoryTheory.Comma.coneOfPreservesIsLimit\n-/\n\n#print CategoryTheory.Comma.colimitAuxiliaryCocone /-\n/-- (Implementation). An auxiliary cocone which is useful in order to construct colimits\nin the comma category. -/\n@[simps]\ndef colimitAuxiliaryCocone (c₂ : Cocone (F ⋙ snd L R)) : Cocone ((F ⋙ fst L R) ⋙ L) :=\n  (Cocones.precompose (whiskerLeft F (Comma.natTrans L R) : _)).obj (R.mapCocone c₂)\n#align category_theory.comma.colimit_auxiliary_cocone CategoryTheory.Comma.colimitAuxiliaryCocone\n-/\n\n#print CategoryTheory.Comma.coconeOfPreserves /-\n/--\nIf `L` preserves the appropriate colimit, then given a colimit cocone for `F ⋙ fst L R : J ⥤ L` and\na cocone for `F ⋙ snd L R : J ⥤ R` we can build a cocone for `F` which will turn out to be a\ncolimit cocone.\n-/\n@[simps]\ndef coconeOfPreserves [PreservesColimit (F ⋙ fst L R) L] {c₁ : Cocone (F ⋙ fst L R)}\n    (t₁ : IsColimit c₁) (c₂ : Cocone (F ⋙ snd L R)) : Cocone F\n    where\n  pt :=\n    { left := c₁.pt\n      right := c₂.pt\n      Hom := (isColimitOfPreserves L t₁).desc (colimitAuxiliaryCocone _ c₂) }\n  ι :=\n    { app := fun j =>\n        { left := c₁.ι.app j\n          right := c₂.ι.app j\n          w' := (isColimitOfPreserves L t₁).fac (colimitAuxiliaryCocone _ c₂) j }\n      naturality' := fun j₁ j₂ t => by ext <;> dsimp <;> simp [← c₁.w t, ← c₂.w t] }\n#align category_theory.comma.cocone_of_preserves CategoryTheory.Comma.coconeOfPreserves\n-/\n\n#print CategoryTheory.Comma.coconeOfPreservesIsColimit /-\n/-- Provided that `L` preserves the appropriate colimit, then the cocone in `cocone_of_preserves` is\na colimit. -/\ndef coconeOfPreservesIsColimit [PreservesColimit (F ⋙ fst L R) L] {c₁ : Cocone (F ⋙ fst L R)}\n    (t₁ : IsColimit c₁) {c₂ : Cocone (F ⋙ snd L R)} (t₂ : IsColimit c₂) :\n    IsColimit (coconeOfPreserves F t₁ c₂)\n    where\n  desc s :=\n    { left := t₁.desc ((fst L R).mapCocone s)\n      right := t₂.desc ((snd L R).mapCocone s)\n      w' :=\n        (isColimitOfPreserves L t₁).hom_ext fun j =>\n          by\n          rw [cocone_of_preserves_X_hom, (is_colimit_of_preserves L t₁).fac_assoc,\n            colimit_auxiliary_cocone_ι_app, assoc, ← R.map_comp, t₂.fac, L.map_cocone_ι_app, ←\n            L.map_comp_assoc, t₁.fac]\n          exact (s.ι.app j).w }\n  uniq s m w :=\n    CommaMorphism.ext _ _ (t₁.uniq ((fst L R).mapCocone s) _ (by simp [← w]))\n      (t₂.uniq ((snd L R).mapCocone s) _ (by simp [← w]))\n#align category_theory.comma.cocone_of_preserves_is_colimit CategoryTheory.Comma.coconeOfPreservesIsColimit\n-/\n\n#print CategoryTheory.Comma.hasLimit /-\ninstance hasLimit (F : J ⥤ Comma L R) [HasLimit (F ⋙ fst L R)] [HasLimit (F ⋙ snd L R)]\n    [PreservesLimit (F ⋙ snd L R) R] : HasLimit F :=\n  HasLimit.mk ⟨_, coneOfPreservesIsLimit _ (limit.isLimit _) (limit.isLimit _)⟩\n#align category_theory.comma.has_limit CategoryTheory.Comma.hasLimit\n-/\n\n#print CategoryTheory.Comma.hasLimitsOfShape /-\ninstance hasLimitsOfShape [HasLimitsOfShape J A] [HasLimitsOfShape J B]\n    [PreservesLimitsOfShape J R] : HasLimitsOfShape J (Comma L R) where\n#align category_theory.comma.has_limits_of_shape CategoryTheory.Comma.hasLimitsOfShape\n-/\n\n#print CategoryTheory.Comma.hasLimits /-\ninstance hasLimits [HasLimits A] [HasLimits B] [PreservesLimits R] : HasLimits (Comma L R) :=\n  ⟨inferInstance⟩\n#align category_theory.comma.has_limits CategoryTheory.Comma.hasLimits\n-/\n\n#print CategoryTheory.Comma.hasColimit /-\ninstance hasColimit (F : J ⥤ Comma L R) [HasColimit (F ⋙ fst L R)] [HasColimit (F ⋙ snd L R)]\n    [PreservesColimit (F ⋙ fst L R) L] : HasColimit F :=\n  HasColimit.mk ⟨_, coconeOfPreservesIsColimit _ (colimit.isColimit _) (colimit.isColimit _)⟩\n#align category_theory.comma.has_colimit CategoryTheory.Comma.hasColimit\n-/\n\n#print CategoryTheory.Comma.hasColimitsOfShape /-\ninstance hasColimitsOfShape [HasColimitsOfShape J A] [HasColimitsOfShape J B]\n    [PreservesColimitsOfShape J L] : HasColimitsOfShape J (Comma L R) where\n#align category_theory.comma.has_colimits_of_shape CategoryTheory.Comma.hasColimitsOfShape\n-/\n\n#print CategoryTheory.Comma.hasColimits /-\ninstance hasColimits [HasColimits A] [HasColimits B] [PreservesColimits L] :\n    HasColimits (Comma L R) :=\n  ⟨inferInstance⟩\n#align category_theory.comma.has_colimits CategoryTheory.Comma.hasColimits\n-/\n\nend Comma\n\nnamespace Arrow\n\n#print CategoryTheory.Arrow.hasLimit /-\ninstance hasLimit (F : J ⥤ Arrow T) [i₁ : HasLimit (F ⋙ leftFunc)] [i₂ : HasLimit (F ⋙ rightFunc)] :\n    HasLimit F :=\n  @Comma.hasLimit _ _ _ _ _ i₁ i₂ _\n#align category_theory.arrow.has_limit CategoryTheory.Arrow.hasLimit\n-/\n\n#print CategoryTheory.Arrow.hasLimitsOfShape /-\ninstance hasLimitsOfShape [HasLimitsOfShape J T] : HasLimitsOfShape J (Arrow T) where\n#align category_theory.arrow.has_limits_of_shape CategoryTheory.Arrow.hasLimitsOfShape\n-/\n\n#print CategoryTheory.Arrow.hasLimits /-\ninstance hasLimits [HasLimits T] : HasLimits (Arrow T) :=\n  ⟨inferInstance⟩\n#align category_theory.arrow.has_limits CategoryTheory.Arrow.hasLimits\n-/\n\n#print CategoryTheory.Arrow.hasColimit /-\ninstance hasColimit (F : J ⥤ Arrow T) [i₁ : HasColimit (F ⋙ leftFunc)]\n    [i₂ : HasColimit (F ⋙ rightFunc)] : HasColimit F :=\n  @Comma.hasColimit _ _ _ _ _ i₁ i₂ _\n#align category_theory.arrow.has_colimit CategoryTheory.Arrow.hasColimit\n-/\n\n#print CategoryTheory.Arrow.hasColimitsOfShape /-\ninstance hasColimitsOfShape [HasColimitsOfShape J T] : HasColimitsOfShape J (Arrow T) where\n#align category_theory.arrow.has_colimits_of_shape CategoryTheory.Arrow.hasColimitsOfShape\n-/\n\n#print CategoryTheory.Arrow.hasColimits /-\ninstance hasColimits [HasColimits T] : HasColimits (Arrow T) :=\n  ⟨inferInstance⟩\n#align category_theory.arrow.has_colimits CategoryTheory.Arrow.hasColimits\n-/\n\nend Arrow\n\nnamespace StructuredArrow\n\nvariable {X : T} {G : A ⥤ T} (F : J ⥤ StructuredArrow X G)\n\n#print CategoryTheory.StructuredArrow.hasLimit /-\ninstance hasLimit [i₁ : HasLimit (F ⋙ proj X G)] [i₂ : PreservesLimit (F ⋙ proj X G) G] :\n    HasLimit F :=\n  @Comma.hasLimit _ _ _ _ _ _ i₁ i₂\n#align category_theory.structured_arrow.has_limit CategoryTheory.StructuredArrow.hasLimit\n-/\n\n#print CategoryTheory.StructuredArrow.hasLimitsOfShape /-\ninstance hasLimitsOfShape [HasLimitsOfShape J A] [PreservesLimitsOfShape J G] :\n    HasLimitsOfShape J (StructuredArrow X G) where\n#align category_theory.structured_arrow.has_limits_of_shape CategoryTheory.StructuredArrow.hasLimitsOfShape\n-/\n\n#print CategoryTheory.StructuredArrow.hasLimits /-\ninstance hasLimits [HasLimits A] [PreservesLimits G] : HasLimits (StructuredArrow X G) :=\n  ⟨inferInstance⟩\n#align category_theory.structured_arrow.has_limits CategoryTheory.StructuredArrow.hasLimits\n-/\n\n#print CategoryTheory.StructuredArrow.createsLimit /-\nnoncomputable instance createsLimit [i : PreservesLimit (F ⋙ proj X G) G] :\n    CreatesLimit F (proj X G) :=\n  createsLimitOfReflectsIso fun c t =>\n    { liftedCone := @Comma.coneOfPreserves _ _ _ _ _ i pUnitCone t\n      makesLimit := Comma.coneOfPreservesIsLimit _ pUnitConeIsLimit _\n      validLift := Cones.ext (Iso.refl _) fun j => (id_comp _).symm }\n#align category_theory.structured_arrow.creates_limit CategoryTheory.StructuredArrow.createsLimit\n-/\n\n#print CategoryTheory.StructuredArrow.createsLimitsOfShape /-\nnoncomputable instance createsLimitsOfShape [PreservesLimitsOfShape J G] :\n    CreatesLimitsOfShape J (proj X G) where\n#align category_theory.structured_arrow.creates_limits_of_shape CategoryTheory.StructuredArrow.createsLimitsOfShape\n-/\n\n#print CategoryTheory.StructuredArrow.createsLimits /-\nnoncomputable instance createsLimits [PreservesLimits G] : CreatesLimits (proj X G : _) :=\n  ⟨⟩\n#align category_theory.structured_arrow.creates_limits CategoryTheory.StructuredArrow.createsLimits\n-/\n\n#print CategoryTheory.StructuredArrow.mono_right_of_mono /-\ninstance mono_right_of_mono [HasPullbacks A] [PreservesLimitsOfShape WalkingCospan G]\n    {Y Z : StructuredArrow X G} (f : Y ⟶ Z) [Mono f] : Mono f.right :=\n  show Mono ((proj X G).map f) from inferInstance\n#align category_theory.structured_arrow.mono_right_of_mono CategoryTheory.StructuredArrow.mono_right_of_mono\n-/\n\n#print CategoryTheory.StructuredArrow.mono_iff_mono_right /-\ntheorem mono_iff_mono_right [HasPullbacks A] [PreservesLimitsOfShape WalkingCospan G]\n    {Y Z : StructuredArrow X G} (f : Y ⟶ Z) : Mono f ↔ Mono f.right :=\n  ⟨fun h => inferInstance, fun h => mono_of_mono_right f⟩\n#align category_theory.structured_arrow.mono_iff_mono_right CategoryTheory.StructuredArrow.mono_iff_mono_right\n-/\n\nend StructuredArrow\n\nnamespace CostructuredArrow\n\nvariable {G : A ⥤ T} {X : T} (F : J ⥤ CostructuredArrow G X)\n\n#print CategoryTheory.CostructuredArrow.hasColimit /-\ninstance hasColimit [i₁ : HasColimit (F ⋙ proj G X)] [i₂ : PreservesColimit (F ⋙ proj G X) G] :\n    HasColimit F :=\n  @Comma.hasColimit _ _ _ _ _ i₁ _ i₂\n#align category_theory.costructured_arrow.has_colimit CategoryTheory.CostructuredArrow.hasColimit\n-/\n\n#print CategoryTheory.CostructuredArrow.hasColimitsOfShape /-\ninstance hasColimitsOfShape [HasColimitsOfShape J A] [PreservesColimitsOfShape J G] :\n    HasColimitsOfShape J (CostructuredArrow G X) where\n#align category_theory.costructured_arrow.has_colimits_of_shape CategoryTheory.CostructuredArrow.hasColimitsOfShape\n-/\n\n#print CategoryTheory.CostructuredArrow.hasColimits /-\ninstance hasColimits [HasColimits A] [PreservesColimits G] : HasColimits (CostructuredArrow G X) :=\n  ⟨inferInstance⟩\n#align category_theory.costructured_arrow.has_colimits CategoryTheory.CostructuredArrow.hasColimits\n-/\n\n#print CategoryTheory.CostructuredArrow.createsColimit /-\nnoncomputable instance createsColimit [i : PreservesColimit (F ⋙ proj G X) G] :\n    CreatesColimit F (proj G X) :=\n  createsColimitOfReflectsIso fun c t =>\n    { liftedCocone := @Comma.coconeOfPreserves _ _ _ _ _ i t pUnitCocone\n      makesColimit := Comma.coconeOfPreservesIsColimit _ _ pUnitCoconeIsColimit\n      validLift := Cocones.ext (Iso.refl _) fun j => comp_id _ }\n#align category_theory.costructured_arrow.creates_colimit CategoryTheory.CostructuredArrow.createsColimit\n-/\n\n#print CategoryTheory.CostructuredArrow.createsColimitsOfShape /-\nnoncomputable instance createsColimitsOfShape [PreservesColimitsOfShape J G] :\n    CreatesColimitsOfShape J (proj G X) where\n#align category_theory.costructured_arrow.creates_colimits_of_shape CategoryTheory.CostructuredArrow.createsColimitsOfShape\n-/\n\n#print CategoryTheory.CostructuredArrow.createsColimits /-\nnoncomputable instance createsColimits [PreservesColimits G] : CreatesColimits (proj G X : _) :=\n  ⟨⟩\n#align category_theory.costructured_arrow.creates_colimits CategoryTheory.CostructuredArrow.createsColimits\n-/\n\n#print CategoryTheory.CostructuredArrow.epi_left_of_epi /-\ninstance epi_left_of_epi [HasPushouts A] [PreservesColimitsOfShape WalkingSpan G]\n    {Y Z : CostructuredArrow G X} (f : Y ⟶ Z) [Epi f] : Epi f.left :=\n  show Epi ((proj G X).map f) from inferInstance\n#align category_theory.costructured_arrow.epi_left_of_epi CategoryTheory.CostructuredArrow.epi_left_of_epi\n-/\n\n#print CategoryTheory.CostructuredArrow.epi_iff_epi_left /-\ntheorem epi_iff_epi_left [HasPushouts A] [PreservesColimitsOfShape WalkingSpan G]\n    {Y Z : CostructuredArrow G X} (f : Y ⟶ Z) : Epi f ↔ Epi f.left :=\n  ⟨fun h => inferInstance, fun h => epi_of_epi_left f⟩\n#align category_theory.costructured_arrow.epi_iff_epi_left CategoryTheory.CostructuredArrow.epi_iff_epi_left\n-/\n\nend CostructuredArrow\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Comma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.49845053357415375}}
{"text": "/-\nCopyright (c) 2020 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz, Bhavik Mehta\n-/\n\nimport category_theory.adjunction.reflective\nimport topology.category.Top\nimport topology.stone_cech\nimport category_theory.monad.limits\nimport topology.urysohns_lemma\n\n/-!\n# The category of Compact Hausdorff Spaces\n\nWe construct the category of compact Hausdorff spaces.\nThe type of compact Hausdorff spaces is denoted `CompHaus`, and it is endowed with a category\ninstance making it a full subcategory of `Top`.\nThe fully faithful functor `CompHaus ⥤ Top` is denoted `CompHaus_to_Top`.\n\n**Note:** The file `topology/category/Compactum.lean` provides the equivalence between `Compactum`,\nwhich is defined as the category of algebras for the ultrafilter monad, and `CompHaus`.\n`Compactum_to_CompHaus` is the functor from `Compactum` to `CompHaus` which is proven to be an\nequivalence of categories in `Compactum_to_CompHaus.is_equivalence`.\nSee `topology/category/Compactum.lean` for a more detailed discussion where these definitions are\nintroduced.\n\n-/\n\nuniverse u\n\nopen category_theory\n\n/-- The type of Compact Hausdorff topological spaces. -/\nstructure CompHaus :=\n(to_Top : Top)\n[is_compact : compact_space to_Top]\n[is_hausdorff : t2_space to_Top]\n\nnamespace CompHaus\n\ninstance : inhabited CompHaus := ⟨{to_Top := { α := pempty }}⟩\n\ninstance : has_coe_to_sort CompHaus Type* := ⟨λ X, X.to_Top⟩\ninstance {X : CompHaus} : compact_space X := X.is_compact\ninstance {X : CompHaus} : t2_space X := X.is_hausdorff\n\ninstance category : category CompHaus := induced_category.category to_Top\n\ninstance concrete_category : concrete_category CompHaus :=\ninduced_category.concrete_category _\n\n@[simp]\nlemma coe_to_Top {X : CompHaus} : (X.to_Top : Type*) = X :=\nrfl\n\nvariables (X : Type*) [topological_space X] [compact_space X] [t2_space X]\n\n/-- A constructor for objects of the category `CompHaus`,\ntaking a type, and bundling the compact Hausdorff topology\nfound by typeclass inference. -/\ndef of : CompHaus :=\n{ to_Top := Top.of X,\n  is_compact := ‹_›,\n  is_hausdorff := ‹_› }\n\n@[simp] lemma coe_of : (CompHaus.of X : Type _) = X := rfl\n\n/-- Any continuous function on compact Hausdorff spaces is a closed map. -/\nlemma is_closed_map {X Y : CompHaus.{u}} (f : X ⟶ Y) : is_closed_map f :=\nλ C hC, (hC.is_compact.image f.continuous).is_closed\n\n/-- Any continuous bijection of compact Hausdorff spaces is an isomorphism. -/\nlemma is_iso_of_bijective {X Y : CompHaus.{u}} (f : X ⟶ Y) (bij : function.bijective f) :\n  is_iso f :=\nbegin\n  let E := equiv.of_bijective _ bij,\n  have hE : continuous E.symm,\n  { rw continuous_iff_is_closed,\n    intros S hS,\n    rw ← E.image_eq_preimage,\n    exact is_closed_map f S hS },\n  refine ⟨⟨⟨E.symm, hE⟩, _, _⟩⟩,\n  { ext x,\n    apply E.symm_apply_apply },\n  { ext x,\n    apply E.apply_symm_apply }\nend\n\n/-- Any continuous bijection of compact Hausdorff spaces induces an isomorphism. -/\nnoncomputable\ndef iso_of_bijective {X Y : CompHaus.{u}} (f : X ⟶ Y) (bij : function.bijective f) : X ≅ Y :=\nby letI := is_iso_of_bijective _ bij; exact as_iso f\n\nend CompHaus\n\n/-- The fully faithful embedding of `CompHaus` in `Top`. -/\n@[simps {rhs_md := semireducible}, derive [full, faithful]]\ndef CompHaus_to_Top : CompHaus.{u} ⥤ Top.{u} := induced_functor _\n\ninstance CompHaus.forget_reflects_isomorphisms : reflects_isomorphisms (forget CompHaus.{u}) :=\n⟨by introsI A B f hf; exact CompHaus.is_iso_of_bijective _ ((is_iso_iff_bijective f).mp hf)⟩\n\n/--\n(Implementation) The object part of the compactification functor from topological spaces to\ncompact Hausdorff spaces.\n-/\n@[simps]\ndef StoneCech_obj (X : Top) : CompHaus := CompHaus.of (stone_cech X)\n\n/--\n(Implementation) The bijection of homsets to establish the reflective adjunction of compact\nHausdorff spaces in topological spaces.\n-/\nnoncomputable def stone_cech_equivalence (X : Top.{u}) (Y : CompHaus.{u}) :\n  (StoneCech_obj X ⟶ Y) ≃ (X ⟶ CompHaus_to_Top.obj Y) :=\n{ to_fun := λ f,\n  { to_fun := f ∘ stone_cech_unit,\n    continuous_to_fun := f.2.comp (@continuous_stone_cech_unit X _) },\n  inv_fun := λ f,\n  { to_fun := stone_cech_extend f.2,\n    continuous_to_fun := continuous_stone_cech_extend f.2 },\n  left_inv :=\n  begin\n    rintro ⟨f : stone_cech X ⟶ Y, hf : continuous f⟩,\n    ext (x : stone_cech X),\n    refine congr_fun _ x,\n    apply continuous.ext_on dense_range_stone_cech_unit (continuous_stone_cech_extend _) hf,\n    rintro _ ⟨y, rfl⟩,\n    apply congr_fun (stone_cech_extend_extends (hf.comp _)) y,\n  end,\n  right_inv :=\n  begin\n    rintro ⟨f : (X : Type*) ⟶ Y, hf : continuous f⟩,\n    ext,\n    exact congr_fun (stone_cech_extend_extends hf) _,\n  end }\n\n/--\nThe Stone-Cech compactification functor from topological spaces to compact Hausdorff spaces,\nleft adjoint to the inclusion functor.\n-/\nnoncomputable def Top_to_CompHaus : Top.{u} ⥤ CompHaus.{u} :=\nadjunction.left_adjoint_of_equiv stone_cech_equivalence.{u} (λ _ _ _ _ _, rfl)\n\nlemma Top_to_CompHaus_obj (X : Top) : ↥(Top_to_CompHaus.obj X) = stone_cech X :=\nrfl\n\n/--\nThe category of compact Hausdorff spaces is reflective in the category of topological spaces.\n-/\nnoncomputable instance CompHaus_to_Top.reflective : reflective CompHaus_to_Top :=\n{ to_is_right_adjoint := ⟨Top_to_CompHaus, adjunction.adjunction_of_equiv_left _ _⟩ }\n\nnoncomputable instance CompHaus_to_Top.creates_limits : creates_limits CompHaus_to_Top :=\nmonadic_creates_limits _\n\ninstance CompHaus.has_limits : limits.has_limits CompHaus :=\nhas_limits_of_has_limits_creates_limits CompHaus_to_Top\n\ninstance CompHaus.has_colimits : limits.has_colimits CompHaus :=\nhas_colimits_of_reflective CompHaus_to_Top\n\nnamespace CompHaus\n\n/-- An explicit limit cone for a functor `F : J ⥤ CompHaus`, defined in terms of\n`Top.limit_cone`. -/\ndef limit_cone {J : Type u} [small_category J] (F : J ⥤ CompHaus.{u}) :\n  limits.cone F :=\n{ X :=\n  { to_Top := (Top.limit_cone (F ⋙ CompHaus_to_Top)).X,\n    is_compact := begin\n      show compact_space ↥{u : Π j, (F.obj j) | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j},\n      rw ← is_compact_iff_compact_space,\n      apply is_closed.is_compact,\n      have : {u : Π j, F.obj j | ∀ {i j : J} (f : i ⟶ j), F.map f (u i) = u j} =\n        ⋂ (i j : J) (f : i ⟶ j), {u | F.map f (u i) = u j},\n      { ext1, simp only [set.mem_Inter, set.mem_set_of_eq], },\n      rw this,\n      apply is_closed_Inter, intros i,\n      apply is_closed_Inter, intros j,\n      apply is_closed_Inter, intros f,\n      apply is_closed_eq,\n      { exact (continuous_map.continuous (F.map f)).comp (continuous_apply i), },\n      { exact continuous_apply j, }\n    end,\n    is_hausdorff :=\n      show t2_space ↥{u : Π j, (F.obj j) | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j},\n      from infer_instance },\n  π :=\n  { app := λ j, (Top.limit_cone (F ⋙ CompHaus_to_Top)).π.app j,\n    naturality' := by { intros _ _ _, ext ⟨x, hx⟩,\n      simp only [comp_apply, functor.const.obj_map, id_apply], exact (hx f).symm, } } }\n\n/-- The limit cone `CompHaus.limit_cone F` is indeed a limit cone. -/\ndef limit_cone_is_limit {J : Type u} [small_category J] (F : J ⥤ CompHaus.{u}) :\n  limits.is_limit (limit_cone F) :=\n{ lift := λ S,\n    (Top.limit_cone_is_limit (F ⋙ CompHaus_to_Top)).lift (CompHaus_to_Top.map_cone S),\n  uniq' := λ S m h, (Top.limit_cone_is_limit _).uniq (CompHaus_to_Top.map_cone S) _ h }\n\nlemma epi_iff_surjective {X Y : CompHaus.{u}} (f : X ⟶ Y) : epi f ↔ function.surjective f :=\nbegin\n  split,\n  { contrapose!,\n    rintros ⟨y, hy⟩ hf,\n    let C := set.range f,\n    have hC : is_closed C := (is_compact_range f.continuous).is_closed,\n    let D := {y},\n    have hD : is_closed D := is_closed_singleton,\n    have hCD : disjoint C D,\n    { rw set.disjoint_singleton_right, rintro ⟨y', hy'⟩, exact hy y' hy' },\n    haveI : normal_space ↥(Y.to_Top) := normal_of_compact_t2,\n    obtain ⟨φ, hφ0, hφ1, hφ01⟩ := exists_continuous_zero_one_of_closed hC hD hCD,\n    haveI : compact_space (ulift.{u} $ set.Icc (0:ℝ) 1) := homeomorph.ulift.symm.compact_space,\n    haveI : t2_space (ulift.{u} $ set.Icc (0:ℝ) 1) := homeomorph.ulift.symm.t2_space,\n    let Z := of (ulift.{u} $ set.Icc (0:ℝ) 1),\n    let g : Y ⟶ Z := ⟨λ y', ⟨⟨φ y', hφ01 y'⟩⟩,\n      continuous_ulift_up.comp (continuous_subtype_mk (λ y', hφ01 y') φ.continuous)⟩,\n    let h : Y ⟶ Z := ⟨λ _, ⟨⟨0, set.left_mem_Icc.mpr zero_le_one⟩⟩, continuous_const⟩,\n    have H : h = g,\n    { rw ← cancel_epi f,\n      ext x, dsimp,\n      simp only [comp_apply, continuous_map.coe_mk, subtype.coe_mk, hφ0 (set.mem_range_self x),\n        pi.zero_apply], },\n    apply_fun (λ e, (e y).down) at H,\n    dsimp at H,\n    simp only [subtype.mk_eq_mk, hφ1 (set.mem_singleton y), pi.one_apply] at H,\n    exact zero_ne_one H, },\n  { rw ← category_theory.epi_iff_surjective,\n    apply faithful_reflects_epi (forget CompHaus) },\nend\n\nlemma mono_iff_injective {X Y : CompHaus.{u}} (f : X ⟶ Y) : mono f ↔ function.injective f :=\nbegin\n  split,\n  { introsI hf x₁ x₂ h,\n    let g₁ : of punit ⟶ X := ⟨λ _, x₁, continuous_of_discrete_topology⟩,\n    let g₂ : of punit ⟶ X := ⟨λ _, x₂, continuous_of_discrete_topology⟩,\n    have : g₁ ≫ f = g₂ ≫ f, by { ext, exact h },\n    rw cancel_mono at this,\n    apply_fun (λ e, e punit.star) at this,\n    exact this },\n  { rw ← category_theory.mono_iff_injective,\n    apply faithful_reflects_mono (forget CompHaus) }\nend\n\nend CompHaus\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/category/CompHaus/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.49845053108812315}}
{"text": "import tactic\nimport recording_tableau\n\n/-\n\nRSK (Robinson-Schensted-Knuth) Insertion\n\n\nGiven a biword w (list (ℕ × ℕ) sorted in lex order), we create two semistandard\nYoung tableaux (ssyt) of the same shape (ν : young_diagram), called the\n`insertion / bumping tableau B` and `recording tableau R`.\n\nThese are defined inductively by inserting the next value ((w.nth n).2) into the\ninsertion tableau using [ssyt.row_bump], then placing a value ((w.nth n).1)\ninto the recording tableau in the outer corner that resulted [ssyt.row_bump.1].\n\nThe inductive definition is [ssyt.rsk_inductive] (you may be surprised to see\nthat it has two base cases. It feels like only one should be necessary!)\n\nThe actual definition is [rsk], which has the signature\n*   rsk : Π (w : list (lex (ℕ × ℕ))), w.sorted (≤) →\n          Σ (μ : young_diagram), ssyt μ × ssyt μ\n\nCurrently the only additional facts proven\nare the size and weights of the resulting tableaux.\n  [rsk_size] [rsk_wtR] [rsk_wtB]\n\nThe next goal is to show that [rsk] is a bijection.\n-/\n\nsection biword\n\nabbreviation rsk_le := (prod.lex.has_le ℕ ℕ).le\n\nlemma rsk_mono_iff {x y : lex (ℕ × ℕ)} {w : list (lex (ℕ × ℕ))} : \n  (x :: y :: w).sorted (≤) ↔ \n  (x.1 < y.1 ∨ x.1 = y.1 ∧ x.2 ≤ y.2) ∧ (y :: w).sorted (≤) :=\nbegin\n  repeat {rw list.sorted_cons at *},\n  split; intro h,\n  { exact ⟨(prod.lex_def _ _).mp (h.1 y (or.inl rfl)), h.2⟩ },\n  { split, rotate, exact h.2,\n    intros b hb,\n    apply @le_trans _ _ _ y _ ((prod.lex_def _ _).mpr h.1),\n    cases hb, exact le_of_eq hb.symm, exact h.2.1 b hb },\nend\n\ndef wtR (w : list (lex (ℕ × ℕ))) (val : ℕ) : ℕ := \nlist.count val $ w.map prod.fst\n\ndef wtB (w : list (lex (ℕ × ℕ))) (val : ℕ) : ℕ := \nlist.count val $ w.map prod.snd\n\nlemma wtR_cons (x : lex (ℕ × ℕ)) (w : list (lex (ℕ × ℕ))) (val : ℕ) :\n  wtR (x :: w) val = ite (val = x.1) 1 0 + wtR w val :=\nbegin\n  unfold wtR,\n  rw [list.map_cons, list.count_cons, ite_add, zero_add, add_comm],\nend\n\nlemma wtB_cons (x : lex (ℕ × ℕ)) (w : list (lex (ℕ × ℕ))) (val : ℕ) :\n  wtB (x :: w) val = ite (val = x.2) 1 0 + wtB w val :=\nbegin\n  unfold wtB,\n  rw [list.map_cons, list.count_cons, ite_add, zero_add, add_comm],\nend\n\nend biword\n\nsection rsk_inductive\n\ndef ssyt.rec_cert.rsk_step\n  {μ : young_diagram} {R B : ssyt μ} (rcert : ssyt.rec_cert R B) :\n  Σ (ν : young_diagram), ssyt ν × ssyt ν :=\n⟨_, ⟨rcert.rec_step, (B.row_bump rcert.bumpval).2⟩⟩\n\ndef ssyt.rec_cert.rsk_inductive :\n  Π {μ : young_diagram} {R B : ssyt μ} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (ℕ × ℕ)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le),\nΣ {ν : young_diagram}, ssyt ν × ssyt ν\n| μ R B rcert [] _ := \n  ⟨_, ⟨rcert.rsk_step.2.1, rcert.rsk_step.2.2⟩⟩\n| μ R B rcert ((recval', bumpval') :: xs) hw := \n  ssyt.rec_cert.rsk_inductive\n    (rcert.next_cert recval' bumpval' (rsk_mono_iff.mp hw).1)\n    xs (rsk_mono_iff.mp hw).2\n\nlemma ssyt.rec_cert.rsk_inductive_size :\n  Π {μ : young_diagram} {R B : ssyt μ} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (ℕ × ℕ)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le),\n  (rcert.rsk_inductive w hw).1.size =\n  μ.size + 1 + w.length\n| μ R B rcert [] _ := by apply B.row_bump_size\n| μ R B rcert ((recval', bumpval') :: xs) hw := begin\n  rw ssyt.rec_cert.rsk_inductive,\n  rw [ssyt.rec_cert.rsk_inductive_size, add_assoc, add_comm 1],\n  rw [B.row_bump_size rcert.bumpval, list.length_cons],\nend\n\nlemma ssyt.rec_cert.rsk_inductive_wtR :\n  Π {μ : young_diagram} {R B : ssyt μ} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (ℕ × ℕ)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le)\n  (val : ℕ),\n  (rcert.rsk_inductive w hw).2.1.wt val =\n  R.wt val + (ite (val = rcert.recval) 1 0) + wtR w val\n| μ R B rcert [] _ val := begin\n  unfold wtR, rw [list.map_nil, list.count_nil, add_zero],\n  exact rcert.rec_wt val,\nend\n| μ R B rcert ((recval', bumpval') :: xs) hw val := begin\n  rw [← rcert.rec_wt val, wtR_cons, ← add_assoc],\n  rw ssyt.rec_cert.rsk_inductive,\n  rw ssyt.rec_cert.rsk_inductive_wtR, refl,\nend\n\nlemma ssyt.rec_cert.rsk_inductive_wtB :\n  Π {μ : young_diagram} {R B : ssyt μ} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (ℕ × ℕ)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le)\n  (val : ℕ),\n  (rcert.rsk_inductive w hw).2.2.wt val =\n  B.wt val + (ite (val = rcert.bumpval) 1 0) + wtB w val\n| μ R B rcert [] _ val := begin\n  unfold wtB, rw [list.map_nil, list.count_nil, add_zero],\n  exact B.row_bump_wt _ val,\nend\n| μ R B rcert ((recval', bumpval') :: xs) hw val := begin\n  rw [← B.row_bump_wt _ val, wtB_cons, ← add_assoc],\n  rw ssyt.rec_cert.rsk_inductive,\n  rw ssyt.rec_cert.rsk_inductive_wtB, refl,\nend\n\nend rsk_inductive\n\nsection rsk\n\ndef rsk_start_cert (recval bumpval : ℕ) : ssyt.rec_cert T_empty T_empty :=\n{ recval := recval, bumpval := bumpval,\n  rec_le := λ _ _, nat.zero_le _,\n  rec_eq_left := λ _ _ cell _, false.rec _ cell }\n\ndef rsk :\n  Π (w : list (lex (ℕ × ℕ))), w.sorted (≤) →\n  Σ (μ : young_diagram), ssyt μ × ssyt μ\n| [] _ := ⟨∅, ∅, ∅⟩\n| [(recval, bumpval)] _ :=\n  (rsk_start_cert recval bumpval).rsk_step\n| ((recval, bumpval) :: rb' :: xs) hw :=\n  (rsk_start_cert recval bumpval).rsk_inductive (rb' :: xs) hw\n\nlemma rsk_size :\n  Π (w : list (lex (ℕ × ℕ))) (hw : w.sorted (≤)),\n  (rsk w hw).1.size = w.length\n| [] _ := rfl\n| [(recval, bumpval)] _ := by apply young_diagram.outer_corner.add_size\n| ((recval, bumpval) :: rb' :: xs) hw := by {\n  rw [rsk, ssyt.rec_cert.rsk_inductive_size, \n      μ_empty_size, zero_add, add_comm], refl,\n}\n\nlemma rsk_wtR :\n  Π (w : list (lex (ℕ × ℕ))) (hw : w.sorted (≤)) (val : ℕ),\n  (rsk w hw).2.1.wt val = wtR w val\n| [] _ val := rfl\n| [(recval, bumpval)] _ val := begin\n  rw [rsk, ssyt.rec_cert.rsk_step, ssyt.rec_cert.rec_wt, T_empty_wt, zero_add],\n  refl,\nend\n| ((recval, bumpval) :: rb' :: xs) hw val := by {\n  rw [wtR_cons, rsk, ssyt.rec_cert.rsk_inductive_wtR, T_empty_wt, zero_add],\n  refl,\n}\n\nlemma rsk_wtB :\n  Π (w : list (lex (ℕ × ℕ))) (hw : w.sorted (≤)) (val : ℕ),\n  (rsk w hw).2.2.wt val = wtB w val\n| [] _ val := rfl\n| [(recval, bumpval)] _ val := begin\n  rw [rsk, ssyt.rec_cert.rsk_step, ssyt.row_bump_wt, T_empty_wt, zero_add],\n  refl,\nend\n| ((recval, bumpval) :: rb' :: xs) hw val := by {\n  rw [wtB_cons, rsk, ssyt.rec_cert.rsk_inductive_wtB, T_empty_wt, zero_add],\n  refl,\n}\n\nend rsk\n\nsection examples\n\ndef rsk.ex0 : list (lex (ℕ × ℕ)) :=\n  [(1, 1), (1, 3), (1, 3), (2, 2), (2, 2), (3, 1), (3, 2)]\n\nlemma rsk.ex0_sorted : rsk.ex0.sorted rsk_le :=\nbegin\n  rw rsk.ex0, repeat {rw rsk_mono_iff}, simp,\nend\n\ndef rsk.ex0_μ : young_diagram := (rsk rsk.ex0 rsk.ex0_sorted).1\ndef rsk.ex0_R : ssyt rsk.ex0_μ := (rsk rsk.ex0 rsk.ex0_sorted).2.1\ndef rsk.ex0_B : ssyt rsk.ex0_μ := (rsk rsk.ex0 rsk.ex0_sorted).2.2\n\n#eval rsk.ex0_μ\n#eval rsk.ex0_R\n#eval rsk.ex0_B\n\nend examples", "meta": {"author": "jakelev", "repo": "lean-rsk", "sha": "dbd97f8fe9fc2ba13d080d37e298ae87d03ff541", "save_path": "github-repos/lean/jakelev-lean-rsk", "path": "github-repos/lean/jakelev-lean-rsk/lean-rsk-dbd97f8fe9fc2ba13d080d37e298ae87d03ff541/src/rsk.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.49845052363351244}}
{"text": "import algebra.homology.single\nimport category_theory.limits.shapes.finite_products\nimport category_theory.limits.preserves.finite\n\nnoncomputable theory\n\nopen category_theory category_theory.limits\n  category_theory.category\n\nnamespace category_theory.limits\n\nlemma is_limit.of_is_zero {J C : Type*} [category J] [category C] [has_zero_object C]\n  [has_zero_morphisms C]\n  (F : J ⥤ C) (hF : is_zero F) (c : cone F) (hc : is_zero c.X) : is_limit c :=\n{ lift := λ s, 0,\n  fac' := λ s j, (F.is_zero_iff.1 hF j).eq_of_tgt _ _,\n  uniq' := λ s m hm, hc.eq_of_tgt _ _, }\n\nlemma preserves_limits_of_shape_of_is_zero {J C D : Type*}\n  [category J] [category C] [category D] [has_zero_object D] [has_zero_morphisms D]\n  (G : C ⥤ D) (hG : is_zero G) :\n  preserves_limits_of_shape J G :=\n⟨λ F, ⟨λ c hc, begin\n  rw functor.is_zero_iff at hG,\n  apply is_limit.of_is_zero,\n  { rw functor.is_zero_iff,\n    exact λ X, hG _, },\n  { exact hG c.X, },\nend⟩⟩\n\nlemma is_colimit.of_is_zero {J C : Type*} [category J] [category C] [has_zero_object C]\n  [has_zero_morphisms C]\n  (F : J ⥤ C) (hF : is_zero F) (c : cocone F) (hc : is_zero c.X) : is_colimit c :=\n{ desc := λ s, 0,\n  fac' := λ s j, (F.is_zero_iff.1 hF j).eq_of_src _ _,\n  uniq' := λ s m hm, hc.eq_of_src _ _, }\n\nlemma preserves_colimits_of_shape_of_is_zero {J C D : Type*}\n  [category J] [category C] [category D] [has_zero_object D] [has_zero_morphisms D]\n  (G : C ⥤ D) (hG : is_zero G):\n  preserves_colimits_of_shape J G :=\n⟨λ F, ⟨λ c hc, begin\n  rw functor.is_zero_iff at hG,\n  apply is_colimit.of_is_zero,\n  { rw functor.is_zero_iff,\n    exact λ X, hG _, },\n  { exact hG c.X, },\nend⟩⟩\n\nend category_theory.limits\n\nopen category_theory category_theory.limits\n  category_theory.category\n\nnamespace homological_complex\n\nvariables (C : Type*) {ι J : Type*} [category C] [category J] [has_zero_morphisms C]\n  (c : complex_shape ι) (F : J ⥤ homological_complex C c)\n\ndef single_nat_iso_self [has_zero_object C] [decidable_eq ι] (i : ι) :\n  single C c i ⋙ eval C c i ≅ 𝟭 C :=\nnat_iso.of_components (λ A, single_obj_X_self C c i A) (by tidy)\n\nlemma is_zero_single_comp_eval_of_neq [has_zero_object C] [decidable_eq ι] (i j : ι) (h : i ≠ j) :\n  is_zero (single C c i ⋙ eval C c j) :=\nbegin\n  rw functor.is_zero_iff,\n  intro A,\n  dsimp,\n  rw if_neg,\n  { exact limits.is_zero_zero C, },\n  { tauto, },\nend\n\nvariables {C c}\n\nnamespace limits\n\nsection\n\nvariables [∀ (n : ι), has_limit (F ⋙ homological_complex.eval C c n)]\n\n@[protected, simps]\ndef cone_of_limit_eval : cone F :=\n{ X :=\n  { X := λ n, limit (F ⋙ homological_complex.eval C c n),\n    d := λ n m, lim_map { app := λ j, (F.obj j).d n m, },\n    shape' := λ n m h, begin\n      ext j,\n      simp only [lim_map_π, zero_comp, (F.obj j).shape _ _ h, comp_zero],\n    end, },\n  π :=\n  { app := λ j,\n    { f := λ n, limit.π _ j, },\n    naturality' := λ i j φ, begin\n      ext n,\n      dsimp,\n      erw [limit.w, id_comp],\n    end, }, }\n\nlemma is_limit_cone : is_limit (cone_of_limit_eval F) :=\n{ lift := λ s,\n  { f := λ n, limit.lift _ ((eval C c n).map_cone s), },\n  uniq' := λ s m hm, begin\n    ext n j,\n    simp only [limit.lift_π, functor.map_cone_π_app, eval_map,\n      ← hm, comp_f, cone_of_limit_eval_π_app_f],\n  end, }\n\ninstance : has_limit F := ⟨⟨⟨ _, is_limit_cone F⟩⟩⟩\n\ninstance (n : ι) : preserves_limit F (homological_complex.eval C c n) :=\npreserves_limit_of_preserves_limit_cone (is_limit_cone F)\n  (is_limit.of_iso_limit (limit.is_limit _)\n    (cones.ext (iso.refl _) (by tidy)))\n\nend\n\nsection\n\nvariables [∀ (n : ι), has_colimit (F ⋙ homological_complex.eval C c n)]\n\n@[simps]\ndef cocone_of_colimit_eval : cocone F :=\n{ X :=\n  { X := λ n, colimit (F ⋙ homological_complex.eval C c n),\n    d:= λ n m, colim_map { app := λ j, (F.obj j).d n m, },\n    shape' := λ n m h, begin\n      ext j,\n      simp only [ι_colim_map, comp_zero, (F.obj j).shape _ _ h, zero_comp],\n    end, },\n  ι :=\n  { app := λ j,\n    { f := λ n, colimit.ι (F ⋙ eval C c n) j, },\n    naturality' := λ i j φ, begin\n      ext n,\n      dsimp,\n      rw [comp_id],\n      exact colimit.w (F ⋙ eval C c n) φ,\n    end, }, }\n\nlemma is_colimit_cocone : is_colimit (cocone_of_colimit_eval F) :=\n{ desc := λ s,\n  { f := λ n, colimit.desc _ ((eval C c n).map_cocone s), },\n  uniq' := λ s m hm, begin\n    ext n j,\n    simp only [←hm, functor.map_cocone_ι_app, eval_map, colimit.ι_desc, comp_f,\n      cocone_of_colimit_eval_ι_app_f],\n  end, }\n\ninstance : has_colimit F := ⟨⟨⟨ _, is_colimit_cocone F⟩⟩⟩\n\ninstance (n : ι) : preserves_colimit F (homological_complex.eval C c n) :=\npreserves_colimit_of_preserves_colimit_cocone (is_colimit_cocone F)\n  (is_colimit.of_iso_colimit (colimit.is_colimit _)\n    (cocones.ext (iso.refl _) (by tidy)))\n\nend\n\ninstance [has_limits_of_shape J C] :\n  has_limits_of_shape J (homological_complex C c) :=\n⟨λ F, infer_instance⟩\n\ninstance [has_colimits_of_shape J C] :\n  has_colimits_of_shape J (homological_complex C c) :=\n⟨λ F, infer_instance⟩\n\ninstance [has_limits_of_shape J C] (n : ι) :\n  preserves_limits_of_shape J (homological_complex.eval C c n) :=\n⟨λ F, infer_instance⟩\n\ninstance [has_colimits_of_shape J C] (n : ι) :\n  preserves_colimits_of_shape J (homological_complex.eval C c n) :=\n⟨λ F, infer_instance⟩\n\ninstance [has_finite_limits C] :\n  has_finite_limits (homological_complex C c) :=\n⟨λ J, begin\n  introI,\n  introI,\n  apply_instance,\nend⟩\n\ninstance [has_finite_colimits C] :\n  has_finite_colimits (homological_complex C c) :=\n⟨λ J, begin\n  introI,\n  introI,\n  apply_instance,\nend⟩\n\ninstance [has_finite_limits C] (n : ι) :\n  preserves_finite_limits (homological_complex.eval C c n) :=\n⟨λ J, begin\n  introI,\n  introI,\n  apply_instance,\nend⟩\n\ninstance [has_finite_colimits C] (n : ι) :\n  preserves_finite_colimits (homological_complex.eval C c n) :=\n⟨λ J, begin\n  introI,\n  introI,\n  apply_instance,\nend⟩\n\ninstance [has_finite_products C] :\n  has_finite_products (homological_complex C c) :=\n⟨λ n, infer_instance⟩\n\ninstance [has_finite_coproducts C] :\n  has_finite_coproducts (homological_complex C c) :=\n⟨λ n, infer_instance⟩\n\nvariable {F}\n\ndef is_limit_of_eval (s : limits.cone F) [has_limits_of_shape J C]\n  (hs : ∀ (i : ι), is_limit ((eval C c i).map_cone s)) : is_limit s :=\n{ lift := λ t,\n  { f := λ i, (hs i).lift ((eval C c i).map_cone t),\n    comm' := λ i i' hii', is_limit.hom_ext (hs i') (begin\n      intro j,\n      have eq := λ i, (hs i).fac ((eval C c i).map_cone t),\n      simp only [functor.map_cone_π_app, eval_map] at eq,\n      simp only [functor.map_cone_π_app, eval_map, assoc],\n      rw [eq i', ← hom.comm, reassoc_of (eq i), hom.comm],\n    end), },\n  fac' := λ t j, begin\n    ext i,\n    simp only [comp_f],\n    apply (hs i).fac,\n  end,\n  uniq' := λ t m hm, begin\n    ext i,\n    exact (hs i).uniq ((eval C c i).map_cone t) (m.f i)\n      (λ j, congr_fun (congr_arg homological_complex.hom.f (hm j)) i),\n  end, }\n\ndef preserves_limits_of_shape_of_eval {D : Type*} [category D]\n  (G : D ⥤ homological_complex C c) [has_limits_of_shape J C]\n  (hG : Π (i : ι), preserves_limits_of_shape J (G ⋙ eval C c i)) :\n  preserves_limits_of_shape J G :=\n⟨λ F, ⟨λ s hs, is_limit_of_eval _ (λ i, begin\n  let hs' := is_limit_of_preserves (G ⋙ eval C c i) hs,\n  exact hs',\nend)⟩⟩\n\ndef is_colimit_of_eval (s : limits.cocone F) [has_colimits_of_shape J C]\n  (hs : ∀ (i : ι), is_colimit ((eval C c i).map_cocone s)) : is_colimit s :=\n{ desc := λ t,\n  { f := λ i, (hs i).desc ((eval C c i).map_cocone t),\n    comm' := λ i i' hii', is_colimit.hom_ext (hs i) begin\n      intro j,\n      have eq := λ i, (hs i).fac ((eval C c i).map_cocone t),\n      simp only [functor.map_cocone_ι_app, eval_map] at eq,\n      simp only [functor.map_cocone_ι_app, eval_map, hom.comm_assoc],\n      rw [eq i', reassoc_of (eq i), hom.comm],\n    end, },\n  fac' := λ t j, begin\n    ext i,\n    simp only [comp_f],\n    apply (hs i).fac,\n  end,\n  uniq' := λ t m hm, begin\n    ext i,\n    exact (hs i).uniq ((eval C c i).map_cocone t) (m.f i)\n      (λ j, congr_fun (congr_arg homological_complex.hom.f (hm j)) i),\n  end, }\n\ndef preserves_colimits_of_shape_of_eval {D : Type*} [category D]\n  (G : D ⥤ homological_complex C c) [has_colimits_of_shape J C]\n  (hG : Π (i : ι), preserves_colimits_of_shape J (G ⋙ eval C c i)) :\n  preserves_colimits_of_shape J G :=\n⟨λ F, ⟨λ s hs, is_colimit_of_eval _ (λ i, begin\n  let hs' := is_colimit_of_preserves (G ⋙ eval C c i) hs,\n  exact hs',\nend)⟩⟩\n\n\nvariables [has_zero_object C] [decidable_eq ι]\n\ninstance [has_zero_object C] [has_limits_of_shape J C] (i : ι) :\n  preserves_limits_of_shape J (single C c i) :=\npreserves_limits_of_shape_of_eval _ (λ i', begin\n  by_cases i = i',\n  { subst h,\n    exact preserves_limits_of_shape_of_nat_iso (single_nat_iso_self C c i).symm, },\n  { apply limits.preserves_limits_of_shape_of_is_zero,\n    exact is_zero_single_comp_eval_of_neq C c i i' h, },\nend)\n\ninstance [has_zero_object C] [has_colimits_of_shape J C] (i : ι) :\n  preserves_colimits_of_shape J (single C c i) :=\npreserves_colimits_of_shape_of_eval _ (λ i', begin\n  by_cases i = i',\n  { subst h,\n    exact preserves_colimits_of_shape_of_nat_iso (single_nat_iso_self C c i).symm, },\n  { apply limits.preserves_colimits_of_shape_of_is_zero,\n    exact is_zero_single_comp_eval_of_neq C c i i' h, },\nend)\n\ninstance [has_finite_limits C] (i : ι) : preserves_finite_limits (single C c i) :=\n⟨λ J, by { introI, introI, apply_instance, }⟩\n\ninstance [has_finite_colimits C] (i : ι) : preserves_finite_colimits (single C c i) :=\n⟨λ J, by { introI, introI, apply_instance, }⟩\n\nend limits\n\nend homological_complex\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebra/homology/homological_complex_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4984184480335287}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.ring\nimport Mathlib.data.num.lemmas\nimport Mathlib.data.tree\nimport Mathlib.PostPort\n\nuniverses u_1 l \n\nnamespace Mathlib\n\n/-!\n# ring2\n\nAn experimental variant on the `ring` tactic that uses computational\nreflection instead of proof generation. Useful for kernel benchmarking.\n-/\n\nnamespace tree\n\n\n/-- `(reflect' t u α)` quasiquotes a tree `(t: tree expr)` of quoted\nvalues of type `α` at level `u` into an `expr` which reifies to a `tree α`\ncontaining the reifications of the `expr`s from the original `t`. -/\n/-- Returns an element indexed by `n`, or zero if `n` isn't a valid index.\nSee `tree.get`. -/\nprotected def get_or_zero {α : Type u_1} [HasZero α] (t : tree α) (n : pos_num) : α :=\n  get_or_else n t 0\n\nend tree\n\n\nnamespace tactic.ring2\n\n\n/-- A reflected/meta representation of an expression in a commutative\nsemiring. This representation is a direct translation of such\nexpressions - see `horner_expr` for a normal form. -/\n/- (atom n) is an opaque element of the csring. For example,\ninductive csring_expr \nwhere\n| atom : pos_num → csring_expr\n| const : num → csring_expr\n| add : csring_expr → csring_expr → csring_expr\n| mul : csring_expr → csring_expr → csring_expr\n| pow : csring_expr → num → csring_expr\n\na local variable in the context. n indexes into a storage\nof such atoms - a `tree α`. -/\n\n/- (const n) is technically the csring's one, added n times.\nOr the zero if n is 0. -/\n\nnamespace csring_expr\n\n\nprotected instance inhabited : Inhabited csring_expr :=\n  { default := const 0 }\n\n/-- Evaluates a reflected `csring_expr` into an element of the\noriginal `comm_semiring` type `α`, retrieving opaque elements\n(atoms) from the tree `t`. -/\ndef eval {α : Type u_1} [comm_semiring α] (t : tree α) : csring_expr → α :=\n  sorry\n\nend csring_expr\n\n\n/-- An efficient representation of expressions in a commutative\nsemiring using the sparse Horner normal form. This type admits\nnon-optimal instantiations (e.g. `P` can be represented as `P+0+0`),\nso to get good performance out of it, care must be taken to maintain\nan optimal, *canonical* form. -/\n/- (const n) is a constant n in the csring, similarly to the same\ninductive horner_expr \nwhere\n| const : znum → horner_expr\n| horner : horner_expr → pos_num → num → horner_expr → horner_expr\n\nconstructor in `csring_expr`. This one, however, can be negative. -/\n\n/- (horner a x n b) is a*xⁿ + b, where x is the x-th atom\nin the atom tree. -/\n\nnamespace horner_expr\n\n\n/-- True iff the `horner_expr` argument is a valid `csring_expr`.\nFor that to be the case, all its constants must be non-negative. -/\ndef is_cs : horner_expr → Prop :=\n  sorry\n\nprotected instance has_zero : HasZero horner_expr :=\n  { zero := const 0 }\n\nprotected instance has_one : HasOne horner_expr :=\n  { one := const 1 }\n\nprotected instance inhabited : Inhabited horner_expr :=\n  { default := 0 }\n\n/-- Represent a `csring_expr.atom` in Horner form. -/\ndef atom (n : pos_num) : horner_expr :=\n  horner 1 n 1 0\n\ndef to_string : horner_expr → string :=\n  sorry\n\nprotected instance has_to_string : has_to_string horner_expr :=\n  has_to_string.mk to_string\n\n/-- Alternative constructor for (horner a x n b) which maintains canonical\nform by simplifying special cases of `a`. -/\ndef horner' (a : horner_expr) (x : pos_num) (n : num) (b : horner_expr) : horner_expr :=\n  sorry\n\ndef add_const (k : znum) (e : horner_expr) : horner_expr :=\n  ite (k = 0) e\n    (horner_expr.rec (fun (n : znum) => const (k + n))\n      (fun (a : horner_expr) (x : pos_num) (n : num) (b A B : horner_expr) => horner a x n B) e)\n\ndef add_aux (a₁ : horner_expr) (A₁ : horner_expr → horner_expr) (x₁ : pos_num) : horner_expr → num → horner_expr → (horner_expr → horner_expr) → horner_expr :=\n  sorry\n\ndef add : horner_expr → horner_expr → horner_expr :=\n  sorry\n\n/-begin\n  induction e₁ with n₁ a₁ x₁ n₁ b₁ A₁ B₁ generalizing e₂,\n  { exact add_const n₁ e₂ },\n  exact match e₂ with e₂ := begin\n    induction e₂ with n₂ a₂ x₂ n₂ b₂ A₂ B₂ generalizing n₁ b₁;\n    let e₁ := horner a₁ x₁ n₁ b₁,\n    { exact add_const n₂ e₁ },\n    let e₂ := horner a₂ x₂ n₂ b₂,\n    exact match pos_num.cmp x₁ x₂ with\n    | ordering.lt := horner a₁ x₁ n₁ (B₁ e₂)\n    | ordering.gt := horner a₂ x₂ n₂ (B₂ n₁ b₁)\n    | ordering.eq :=\n      match num.sub' n₁ n₂ with\n      | znum.zero := horner' (A₁ a₂) x₁ n₁ (B₁ b₂)\n      | (znum.pos k) := horner (A₂ k 0) x₁ n₂ (B₁ b₂)\n      | (znum.neg k) := horner (A₁ (horner a₂ x₁ k 0)) x₁ n₁ (B₁ b₂)\n      end\n    end\n  end end\nend-/\n\ndef neg (e : horner_expr) : horner_expr :=\n  horner_expr.rec (fun (n : znum) => const (-n))\n    (fun (a : horner_expr) (x : pos_num) (n : num) (b A B : horner_expr) => horner A x n B) e\n\ndef mul_const (k : znum) (e : horner_expr) : horner_expr :=\n  ite (k = 0) 0\n    (ite (k = 1) e\n      (horner_expr.rec (fun (n : znum) => const (n * k))\n        (fun (a : horner_expr) (x : pos_num) (n : num) (b A B : horner_expr) => horner A x n B) e))\n\ndef mul_aux (a₁ : horner_expr) (x₁ : pos_num) (n₁ : num) (b₁ : horner_expr) (A₁ : horner_expr → horner_expr) (B₁ : horner_expr → horner_expr) : horner_expr → horner_expr :=\n  sorry\n\ndef mul : horner_expr → horner_expr → horner_expr :=\n  sorry\n\n/-begin\n  induction e₁ with n₁ a₁ x₁ n₁ b₁ A₁ B₁ generalizing e₂,\n  { exact mul_const n₁ e₂ },\n  induction e₂ with n₂ a₂ x₂ n₂ b₂ A₂ B₂;\n  let e₁ := horner a₁ x₁ n₁ b₁,\n  { exact mul_const n₂ e₁ },\n  let e₂ := horner a₂ x₂ n₂ b₂,\n  cases pos_num.cmp x₁ x₂,\n  { exact horner (A₁ e₂) x₁ n₁ (B₁ e₂) },\n  { let haa := horner' A₂ x₁ n₂ 0,\n    exact if b₂ = 0 then haa else\n      haa.add (horner (A₁ b₂) x₁ n₁ (B₁ b₂)) },\n  { exact horner A₂ x₂ n₂ B₂ }\nend-/\n\nprotected instance has_add : Add horner_expr :=\n  { add := add }\n\nprotected instance has_neg : Neg horner_expr :=\n  { neg := neg }\n\nprotected instance has_mul : Mul horner_expr :=\n  { mul := mul }\n\ndef pow (e : horner_expr) : num → horner_expr :=\n  sorry\n\ndef inv (e : horner_expr) : horner_expr :=\n  0\n\n/-- Brings expressions into Horner normal form. -/\ndef of_csexpr : csring_expr → horner_expr :=\n  sorry\n\n/-- Evaluates a reflected `horner_expr` - see `csring_expr.eval`. -/\ndef cseval {α : Type u_1} [comm_semiring α] (t : tree α) : horner_expr → α :=\n  sorry\n\ntheorem cseval_atom {α : Type u_1} [comm_semiring α] (t : tree α) (n : pos_num) : is_cs (atom n) ∧ cseval t (atom n) = tree.get_or_zero t n :=\n  { left := { left := Exists.intro 1 rfl, right := Exists.intro 0 rfl },\n    right := Eq.symm (ring.horner_atom (tree.get_or_zero t n)) }\n\ntheorem cseval_add_const {α : Type u_1} [comm_semiring α] (t : tree α) (k : num) {e : horner_expr} (cs : is_cs e) : is_cs (add_const (num.to_znum k) e) ∧ cseval t (add_const (num.to_znum k) e) = ↑k + cseval t e := sorry\n\ntheorem cseval_horner' {α : Type u_1} [comm_semiring α] (t : tree α) (a : horner_expr) (x : pos_num) (n : num) (b : horner_expr) (h₁ : is_cs a) (h₂ : is_cs b) : is_cs (horner' a x n b) ∧ cseval t (horner' a x n b) = ring.horner (cseval t a) (tree.get_or_zero t x) (↑n) (cseval t b) := sorry\n\ntheorem cseval_add {α : Type u_1} [comm_semiring α] (t : tree α) {e₁ : horner_expr} {e₂ : horner_expr} (cs₁ : is_cs e₁) (cs₂ : is_cs e₂) : is_cs (add e₁ e₂) ∧ cseval t (add e₁ e₂) = cseval t e₁ + cseval t e₂ := sorry\n\ntheorem cseval_mul_const {α : Type u_1} [comm_semiring α] (t : tree α) (k : num) {e : horner_expr} (cs : is_cs e) : is_cs (mul_const (num.to_znum k) e) ∧ cseval t (mul_const (num.to_znum k) e) = cseval t e * ↑k := sorry\n\ntheorem cseval_mul {α : Type u_1} [comm_semiring α] (t : tree α) {e₁ : horner_expr} {e₂ : horner_expr} (cs₁ : is_cs e₁) (cs₂ : is_cs e₂) : is_cs (mul e₁ e₂) ∧ cseval t (mul e₁ e₂) = cseval t e₁ * cseval t e₂ := sorry\n\ntheorem cseval_pow {α : Type u_1} [comm_semiring α] (t : tree α) {x : horner_expr} (cs : is_cs x) (n : num) : is_cs (pow x n) ∧ cseval t (pow x n) = cseval t x ^ ↑n := sorry\n\n/-- For any given tree `t` of atoms and any reflected expression `r`,\nthe Horner form of `r` is a valid csring expression, and under `t`,\nthe Horner form evaluates to the same thing as `r`. -/\ntheorem cseval_of_csexpr {α : Type u_1} [comm_semiring α] (t : tree α) (r : csring_expr) : is_cs (of_csexpr r) ∧ cseval t (of_csexpr r) = csring_expr.eval t r := sorry\n\nend horner_expr\n\n\n/-- The main proof-by-reflection theorem. Given reflected csring expressions\n`r₁` and `r₂` plus a storage `t` of atoms, if both expressions go to the\nsame Horner normal form, then the original non-reflected expressions are\nequal. `H` follows from kernel reduction and is therefore `rfl`. -/\ntheorem correctness {α : Type u_1} [comm_semiring α] (t : tree α) (r₁ : csring_expr) (r₂ : csring_expr) (H : horner_expr.of_csexpr r₁ = horner_expr.of_csexpr r₂) : csring_expr.eval t r₁ = csring_expr.eval t r₂ := sorry\n\n/-- Reflects a csring expression into a `csring_expr`, together\nwith a dlist of atoms, i.e. opaque variables over which the\nexpression is a polynomial. -/\n/-| `(%%e₁ - %%e₂) :=\n  let (r₁, l₁) := reflect_expr e₁, (r₂, l₂) := reflect_expr e₂ in\n  (r₁.add r₂.neg, l₁ ++ l₂)\n| `(- %%e) := let (r, l) := reflect_expr e in (r.neg, l)-/\n\n/-| `(has_inv.inv %%e) := let (r, l) := reflect_expr e in (r.neg, l)\n| `(%%e₁ / %%e₂) :=\n  let (r₁, l₁) := reflect_expr e₁, (r₂, l₂) := reflect_expr e₂ in\n  (r₁.mul r₂.inv, l₁ ++ l₂)-/\n\n/-- In the output of `reflect_expr`, `atom`s are initialized with incorrect indices.\nThe indices cannot be computed until the whole tree is built, so another pass over\nthe expressions is needed - this is what `replace` does. The computation (expressed\nin the state monad) fixes up `atom`s to match their positions in the atom tree.\nThe initial state is a list of all atom occurrences in the goal, left-to-right. -/\n--| (csring_expr.neg x)  := csring_expr.neg <$> x.replace\n\n--| (csring_expr.inv x)  := csring_expr.inv <$> x.replace\n\nend tactic.ring2\n\n\nnamespace tactic\n\n\nnamespace interactive\n\n\n/-- `ring2` solves equations in the language of rings.\n\nIt supports only the commutative semiring operations, i.e. it does not normalize subtraction or division.\n\n  This variant on the `ring` tactic uses kernel computation instead\n  of proof generation. In general, you should use `ring` instead of `ring2`. -/\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/ring2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.6224593452091672, "lm_q1q2_score": 0.49839822525967736}}
{"text": "import Logic.Predicate.FirstOrder.Language\nimport Logic.Predicate.Coding\n\nuniverse u v\n\nnamespace FirstOrder\n\nvariable {L : Language.{u}} [∀ k : ℕ, Encodable (L.func k)]\n  [∀ k, Encodable (L.rel k)] {μ : Type v} [Encodable μ]\n\nnamespace SubFormula\nopen Encodable\n\ndef toNat : {n : ℕ} → SubFormula L μ n → ℕ\n  | _, ⊤                 => 0\n  | _, ⊥                 => 1\n  | _, rel (k := k) r v  => (Nat.bit false $ Nat.bit false $ Nat.mkpair k  $ Nat.mkpair (encode r) (encode v)) + 2\n  | _, nrel (k := k) r v => (Nat.bit false $ Nat.bit true  $ Nat.mkpair k  $ Nat.mkpair (encode r) (encode v)) + 2\n  | _, p ⋏ q             => (Nat.bit true  $ Nat.bit false $ Nat.bit false $ Nat.mkpair p.toNat q.toNat) + 2\n  | _, p ⋎ q             => (Nat.bit true  $ Nat.bit false $ Nat.bit true  $ Nat.mkpair p.toNat q.toNat) + 2\n  | _, ∀' p              => (Nat.bit true  $ Nat.bit true  $ Nat.bit false p.toNat) + 2\n  | _, ∃' p              => (Nat.bit true  $ Nat.bit true  $ Nat.bit true  p.toNat) + 2\n\ndef ofNat : (n : ℕ) → ℕ → Option (SubFormula L μ n)\n  | n, 0     => some ⊤\n  | n, 1     => some ⊥\n  | n, (e + 2) =>\n    match e.bodd with\n    | false =>\n      let x := e.div2.div2\n      let k := x.unpair.1\n      let r' := decode₂ (L.rel k) x.unpair.2.unpair.1\n      let v' := decode₂ (Fin k → SubTerm L μ n) x.unpair.2.unpair.2\n      match e.div2.bodd with\n      | false => r'.bind fun r => v'.map fun v => rel r v\n      | true  => r'.bind fun r => v'.map fun v => nrel r v\n    | true  =>\n      let x := e.div2.div2.div2\n      have div8 : x ≤ e := by\n        simp[Nat.div2_val]\n        exact le_trans (Nat.div_le_self (e / 2 / 2) 2) (le_trans (Nat.div_le_self (e/2) 2) (Nat.div_le_self e 2))\n      have h : x < e + 2 := Nat.lt.step $ Nat.lt_succ_iff.mpr div8\n      have : x.unpair.1 < e + 2 := lt_of_le_of_lt (Nat.unpair_left_le _) h\n      have : x.unpair.2 < e + 2 := lt_of_le_of_lt (Nat.unpair_right_le _) h\n      match e.div2.bodd with\n      | false =>  \n        let p' := ofNat n x.unpair.1\n        let q' := ofNat n x.unpair.2\n        match e.div2.div2.bodd with\n        | false => p'.bind fun p => q'.map fun q => p ⋏ q\n        | true  => p'.bind fun p => q'.map fun q => p ⋎ q\n      | true  =>\n        let p' := ofNat (n + 1) x\n        match e.div2.div2.bodd with\n        | false => p'.bind fun p => ∀' p\n        | true  => p'.bind fun p => ∃' p\n  termination_by ofNat n e => e\n\nlemma ofNat_toNat : ∀ {n} (p : SubFormula L μ n), ofNat n p.toNat = some p\n  | _, ⊤ => by simp[toNat, ofNat]\n  | _, ⊥ => by simp[toNat, ofNat]\n  | n, rel r v => by\n      simp[toNat, ofNat]\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit, Nat.unpair_mkpair]; simp\n  | n, nrel r v => by\n      simp[toNat, ofNat]\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit, Nat.unpair_mkpair]; simp     \n  | n, p ⋏ q => by\n      simp[toNat, ofNat]\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp[ofNat_toNat p, ofNat_toNat q]\n  | n, p ⋎ q => by\n      simp[toNat, ofNat]\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp[ofNat_toNat p, ofNat_toNat q]    \n  | n, ∀' p => by\n      simp[toNat, ofNat]\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp[ofNat_toNat p]\n  | n, ∃' p => by\n      simp[toNat, ofNat]\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp\n      rw[Nat.bodd_bit, Nat.div2_bit]; simp[ofNat_toNat p]\n\ninstance (n) : Encodable (SubFormula L μ n) where\n  encode  := toNat\n  decode  := ofNat n\n  encodek := ofNat_toNat\n\nend SubFormula\n\n\nend FirstOrder\n", "meta": {"author": "iehality", "repo": "lean4-logic", "sha": "ef518051931fb1ecd0b89e94240b2900cd54d95c", "save_path": "github-repos/lean/iehality-lean4-logic", "path": "github-repos/lean/iehality-lean4-logic/lean4-logic-ef518051931fb1ecd0b89e94240b2900cd54d95c/Logic/Predicate/FirstOrder/Coding.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.800691997339971, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.4983982051629154}}
{"text": "\nimport mvpfunctor.basic\nimport mvqpf.basic\n\nuniverses u\n\nnamespace mvqpf\nvariables {n m : ℕ}\n  (F : typevec.{u} n → Type*) [mvfunctor F] [q : mvqpf F]\n  (G : fin' n → typevec.{u} m → Type u) [∀ i, mvfunctor $ G i] [q' : ∀ i, mvqpf $ G i]\n\ndef comp (v : typevec.{u} m) : Type* :=\nF $ λ i : fin' n, G i v\n\nnamespace comp\nopen mvfunctor mvpfunctor\nvariables {F G} {α β : typevec.{u} m} (f : α ⟹ β)\n\nprotected def mk (x : F $ λ i, G i α) : (comp F G) α := x\n\nprotected def get (x : (comp F G) α) : F $ λ i, G i α := x\n\n@[simp] protected lemma mk_get (x : (comp F G) α) : comp.mk (comp.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : F $ λ i, G i α) : comp.get (comp.mk x) = x := rfl\n\nprotected def map' : (λ (i : fin' n), G i α) ⟹ λ (i : fin' n), G i β :=\nλ i, map f\n\nprotected def map : (comp F G) α → (comp F G) β :=\n(map (λ i, map f) : F (λ i, G i α) → F (λ i, G i β))\n\ninstance : mvfunctor (comp F G) :=\n{ map := λ α β, comp.map }\n\nlemma map_mk (x : F $ λ i, G i α) :\n  f <$$> comp.mk x = comp.mk ((λ i (x : G i α), f <$$> x) <$$> x) := rfl\n\nlemma get_map (x : comp F G α) :\n  comp.get (f <$$> x) = (λ i (x : G i α), f <$$> x) <$$> comp.get x := rfl\n\ninclude q q'\n\ninstance : mvqpf (comp F G) :=\n{ P         := mvpfunctor.comp (P F) (λ i, P $ G i),\n  abs       := λ α, comp.mk ∘ map (λ i, abs) ∘ abs ∘ mvpfunctor.comp.get,\n  repr'     := λ α,  mvpfunctor.comp.mk ∘ repr ∘\n                 map (λ i, (repr : G i α → (λ (i : fin' n), apply (P (G i)) α) i)) ∘ comp.get,\n  abs_repr' := by { intros, simp [(∘), mvfunctor.map_map, (⊚), abs_repr] },\n  abs_map   := by { intros, simp [(∘)], rw [← abs_map],\n                    simp [id_map, (⊚), map_mk, mvpfunctor.comp.get_map, abs_map,\n                      mvfunctor.map_map, abs_repr] } }\n\nend comp\n\nend mvqpf\n", "meta": {"author": "avigad", "repo": "qpf", "sha": "debe2eacb8cf46b21aba2eaf3f2e20940da0263b", "save_path": "github-repos/lean/avigad-qpf", "path": "github-repos/lean/avigad-qpf/qpf-debe2eacb8cf46b21aba2eaf3f2e20940da0263b/src/mvqpf/comp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152498, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.49821898877456033}}
{"text": "/-\nCopyright (c) 2020 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.group_theory.congruence\nimport Mathlib.linear_algebra.multilinear\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_4 u_3 u_6 u_5 \n\nnamespace Mathlib\n\n/-!\n# Tensor product of an indexed family of semimodules over commutative semirings\n\nWe define the tensor product of an indexed family `s : ι → Type*` of semimodules over commutative\nsemirings. We denote this space by `⨂[R] i, s i` and define it as `free_add_monoid (R × Π i, s i)`\nquotiented by the appropriate equivalence relation. The treatment follows very closely that of the\nbinary tensor product in `linear_algebra/tensor_product.lean`.\n\n## Main definitions\n\n* `pi_tensor_product R s` with `R` a commutative semiring and `s : ι → Type*` is the tensor product\n  of all the `s i`'s. This is denoted by `⨂[R] i, s i`.\n* `tprod R f` with `f : Π i, s i` is the tensor product of the vectors `f i` over all `i : ι`.\n  This is bundled as a multilinear map from `Π i, s i` to `⨂[R] i, s i`.\n* `lift_add_hom` constructs an `add_monoid_hom` from `(⨂[R] i, s i)` to some space `F` from a\n  function `φ : (R × Π i, s i) → F` with the appropriate properties.\n* `lift φ` with `φ : multilinear_map R s E` is the corresponding linear map\n  `(⨂[R] i, s i) →ₗ[R] E`. This is bundled as a linear equivalence.\n\n## Notations\n\n* `⨂[R] i, s i` is defined as localized notation in locale `tensor_product`\n* `⨂ₜ[R] i, f i` with `f : Π i, f i` is defined globally as the tensor product of all the `f i`'s.\n\n## Implementation notes\n\n* We define it via `free_add_monoid (R × Π i, s i)` with the `R` representing a \"hidden\" tensor\n  factor, rather than `free_add_monoid (Π i, s i)` to ensure that, if `ι` is an empty type,\n  the space is isomorphic to the base ring `R`.\n* We have not restricted the index type `ι` to be a `fintype`, as nothing we do here strictly\n  requires it. However, problems may arise in the case where `ι` is infinite; use at your own\n  caution.\n\n## TODO\n\n* Define tensor powers, symmetric subspace, etc.\n* API for the various ways `ι` can be split into subsets; connect this with the binary\n  tensor product.\n* Include connection with holors.\n* Port more of the API from the binary tensor product over to this case.\n\n## Tags\n\nmultilinear, tensor, tensor product\n-/\n\nnamespace pi_tensor_product\n\n\n/-- The relation on `free_add_monoid (R × Π i, s i)` that generates a congruence whose quotient is\nthe tensor product. -/\ninductive eqv {ι : Type u_1} [DecidableEq ι] (R : Type u_2) [comm_semiring R] (s : ι → Type u_4)\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    free_add_monoid (R × ((i : ι) → s i)) → free_add_monoid (R × ((i : ι) → s i)) → Prop\n    where\n| of_zero : ∀ (r : R) (f : (i : ι) → s i) (i : ι), f i = 0 → eqv R s (free_add_monoid.of (r, f)) 0\n| of_zero_scalar : ∀ (f : (i : ι) → s i), eqv R s (free_add_monoid.of (0, f)) 0\n| of_add :\n    ∀ (r : R) (f : (i : ι) → s i) (i : ι) (m₁ m₂ : s i),\n      eqv R s\n        (free_add_monoid.of (r, function.update f i m₁) +\n          free_add_monoid.of (r, function.update f i m₂))\n        (free_add_monoid.of (r, function.update f i (m₁ + m₂)))\n| of_add_scalar :\n    ∀ (r r' : R) (f : (i : ι) → s i),\n      eqv R s (free_add_monoid.of (r, f) + free_add_monoid.of (r', f))\n        (free_add_monoid.of (r + r', f))\n| of_smul :\n    ∀ (r : R) (f : (i : ι) → s i) (i : ι) (r' : R),\n      eqv R s (free_add_monoid.of (r, function.update f i (r' • f i)))\n        (free_add_monoid.of (r' * r, f))\n| add_comm : ∀ (x y : free_add_monoid (R × ((i : ι) → s i))), eqv R s (x + y) (y + x)\n\nend pi_tensor_product\n\n\n/-- `pi_tensor_product R s` with `R` a commutative semiring and `s : ι → Type*` is the tensor\n  product of all the `s i`'s. This is denoted by `⨂[R] i, s i`. -/\ndef pi_tensor_product {ι : Type u_1} [DecidableEq ι] (R : Type u_2) [comm_semiring R]\n    (s : ι → Type u_4) [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :=\n  add_con.quotient (add_con_gen sorry)\n\n/- This enables the notation `⨂[R] i : ι, s i` for the pi tensor product, given `s : ι → Type*`. -/\n\nnamespace pi_tensor_product\n\n\nprotected instance add_comm_monoid {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    (s : ι → Type u_4) [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    add_comm_monoid (pi_tensor_product R fun (i : ι) => s i) :=\n  add_comm_monoid.mk add_monoid.add sorry add_monoid.zero sorry sorry sorry\n\nprotected instance inhabited {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    (s : ι → Type u_4) [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    Inhabited (pi_tensor_product R fun (i : ι) => s i) :=\n  { default := 0 }\n\n/-- `tprod_coeff R r f` with `r : R` and `f : Π i, s i` is the tensor product of the vectors `f i`\nover all `i : ι`, multiplied by the coefficient `r`. Note that this is meant as an auxiliary\ndefinition for this file alone, and that one should use `tprod` defined below for most purposes. -/\ndef tprod_coeff {ι : Type u_1} [DecidableEq ι] (R : Type u_2) [comm_semiring R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (r : R) (f : (i : ι) → s i) :\n    pi_tensor_product R fun (i : ι) => s i :=\n  coe_fn (add_con.mk' (add_con_gen (eqv R fun (i : ι) => s i))) (free_add_monoid.of (r, f))\n\ntheorem zero_tprod_coeff {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    (f : (i : ι) → s i) : tprod_coeff R 0 f = 0 :=\n  quotient.sound' (add_con_gen.rel.of (free_add_monoid.of (0, f)) 0 (eqv.of_zero_scalar f))\n\ntheorem zero_tprod_coeff' {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (z : R)\n    (f : (i : ι) → s i) (i : ι) (hf : f i = 0) : tprod_coeff R z f = 0 :=\n  quotient.sound' (add_con_gen.rel.of (free_add_monoid.of (z, f)) 0 (eqv.of_zero z f i hf))\n\ntheorem add_tprod_coeff {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (z : R)\n    (f : (i : ι) → s i) (i : ι) (m₁ : s i) (m₂ : s i) :\n    tprod_coeff R z (function.update f i m₁) + tprod_coeff R z (function.update f i m₂) =\n        tprod_coeff R z (function.update f i (m₁ + m₂)) :=\n  quotient.sound'\n    (add_con_gen.rel.of\n      (free_add_monoid.of (z, function.update f i m₁) +\n        free_add_monoid.of (z, function.update f i m₂))\n      (free_add_monoid.of (z, function.update f i (m₁ + m₂))) (eqv.of_add z f i m₁ m₂))\n\ntheorem add_tprod_coeff' {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (z₁ : R)\n    (z₂ : R) (f : (i : ι) → s i) :\n    tprod_coeff R z₁ f + tprod_coeff R z₂ f = tprod_coeff R (z₁ + z₂) f :=\n  quotient.sound'\n    (add_con_gen.rel.of (free_add_monoid.of (z₁, f) + free_add_monoid.of (z₂, f))\n      (free_add_monoid.of (z₁ + z₂, f)) (eqv.of_add_scalar z₁ z₂ f))\n\ntheorem smul_tprod_coeff_aux {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (z : R)\n    (f : (i : ι) → s i) (i : ι) (r : R) :\n    tprod_coeff R z (function.update f i (r • f i)) = tprod_coeff R (r * z) f :=\n  quotient.sound'\n    (add_con_gen.rel.of (free_add_monoid.of (z, function.update f i (r • f i)))\n      (free_add_monoid.of (r * z, f)) (eqv.of_smul z f i r))\n\ntheorem smul_tprod_coeff {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (z : R) (f : (i : ι) → s i)\n    (i : ι) (r : R') [semimodule R' (s i)] [is_scalar_tower R' R (s i)] :\n    tprod_coeff R z (function.update f i (r • f i)) = tprod_coeff R (r • z) f :=\n  sorry\n\n/-- Construct an `add_monoid_hom` from `(⨂[R] i, s i)` to some space `F` from a function\n`φ : (R × Π i, s i) → F` with the appropriate properties. -/\ndef lift_add_hom {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] {F : Type u_6}\n    [add_comm_monoid F] (φ : R × ((i : ι) → s i) → F)\n    (C0 : ∀ (r : R) (f : (i : ι) → s i) (i : ι), f i = 0 → φ (r, f) = 0)\n    (C0' : ∀ (f : (i : ι) → s i), φ (0, f) = 0)\n    (C_add :\n      ∀ (r : R) (f : (i : ι) → s i) (i : ι) (m₁ m₂ : s i),\n        φ (r, function.update f i m₁) + φ (r, function.update f i m₂) =\n          φ (r, function.update f i (m₁ + m₂)))\n    (C_add_scalar : ∀ (r r' : R) (f : (i : ι) → s i), φ (r, f) + φ (r', f) = φ (r + r', f))\n    (C_smul :\n      ∀ (r : R) (f : (i : ι) → s i) (i : ι) (r' : R),\n        φ (r, function.update f i (r' • f i)) = φ (r' * r, f)) :\n    (pi_tensor_product R fun (i : ι) => s i) →+ F :=\n  add_con.lift (add_con_gen (eqv R s)) (coe_fn free_add_monoid.lift φ) sorry\n\n-- Most of the time we want the instance below this one, which is easier for typeclass resolution\n\n-- to find.\n\nprotected instance has_scalar' {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    has_scalar R' (pi_tensor_product R fun (i : ι) => s i) :=\n  has_scalar.mk\n    fun (r : R') =>\n      ⇑(lift_add_hom (fun (f : R × ((i : ι) → s i)) => tprod_coeff R (r • prod.fst f) (prod.snd f))\n          sorry sorry sorry sorry sorry)\n\nprotected instance has_scalar {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    has_scalar R (pi_tensor_product R fun (i : ι) => s i) :=\n  pi_tensor_product.has_scalar'\n\ntheorem smul_tprod_coeff' {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (r : R') (z : R)\n    (f : (i : ι) → s i) : r • tprod_coeff R z f = tprod_coeff R (r • z) f :=\n  rfl\n\nprotected theorem smul_add {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] (r : R')\n    (x : pi_tensor_product R fun (i : ι) => s i) (y : pi_tensor_product R fun (i : ι) => s i) :\n    r • (x + y) = r • x + r • y :=\n  sorry\n\nprotected theorem induction_on' {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {C : (pi_tensor_product R fun (i : ι) => s i) → Prop}\n    (z : pi_tensor_product R fun (i : ι) => s i)\n    (C1 : ∀ {r : R} {f : (i : ι) → s i}, C (tprod_coeff R r f))\n    (Cp : ∀ {x y : pi_tensor_product R fun (i : ι) => s i}, C x → C y → C (x + y)) : C z :=\n  sorry\n\n-- Most of the time we want the instance below this one, which is easier for typeclass resolution\n\n-- to find.\n\nprotected instance semimodule' {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    semimodule R' (pi_tensor_product R fun (i : ι) => s i) :=\n  semimodule.mk sorry sorry\n\nprotected instance semimodule {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    semimodule R' (pi_tensor_product R fun (i : ι) => s i) :=\n  pi_tensor_product.semimodule'\n\n/-- The canonical `multilinear_map R s (⨂[R] i, s i)`. -/\ndef tprod {ι : Type u_1} [DecidableEq ι] (R : Type u_2) [comm_semiring R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    multilinear_map R s (pi_tensor_product R fun (i : ι) => s i) :=\n  multilinear_map.mk (tprod_coeff R 1) sorry sorry\n\n@[simp] theorem tprod_coeff_eq_smul_tprod {ι : Type u_1} [DecidableEq ι] {R : Type u_2}\n    [comm_semiring R] {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)]\n    [(i : ι) → semimodule R (s i)] (z : R) (f : (i : ι) → s i) :\n    tprod_coeff R z f = z • coe_fn (tprod R) f :=\n  sorry\n\nprotected theorem induction_on {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {C : (pi_tensor_product R fun (i : ι) => s i) → Prop}\n    (z : pi_tensor_product R fun (i : ι) => s i)\n    (C1 : ∀ {r : R} {f : (i : ι) → s i}, C (r • coe_fn (tprod R) f))\n    (Cp : ∀ {x y : pi_tensor_product R fun (i : ι) => s i}, C x → C y → C (x + y)) : C z :=\n  sorry\n\ntheorem ext {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] {E : Type u_5}\n    [add_comm_monoid E] [semimodule R E]\n    {φ₁ : linear_map R (pi_tensor_product R fun (i : ι) => s i) E}\n    {φ₂ : linear_map R (pi_tensor_product R fun (i : ι) => s i) E}\n    (H :\n      linear_map.comp_multilinear_map φ₁ (tprod R) = linear_map.comp_multilinear_map φ₂ (tprod R)) :\n    φ₁ = φ₂ :=\n  sorry\n\n/-- Auxiliary function to constructing a linear map `(⨂[R] i, s i) → E` given a\n`multilinear map R s E` with the property that its composition with the canonical\n`multilinear_map R s (⨂[R] i, s i)` is the given multilinear map. -/\ndef lift_aux {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] {E : Type u_5}\n    [add_comm_monoid E] [semimodule R E] (φ : multilinear_map R s E) :\n    (pi_tensor_product R fun (i : ι) => s i) →+ E :=\n  lift_add_hom (fun (p : R × ((i : ι) → s i)) => prod.fst p • coe_fn φ (prod.snd p)) sorry sorry\n    sorry sorry sorry\n\ntheorem lift_aux_tprod {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] (φ : multilinear_map R s E)\n    (f : (i : ι) → s i) : coe_fn (lift_aux φ) (coe_fn (tprod R) f) = coe_fn φ f :=\n  sorry\n\ntheorem lift_aux_tprod_coeff {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] (φ : multilinear_map R s E) (z : R)\n    (f : (i : ι) → s i) : coe_fn (lift_aux φ) (tprod_coeff R z f) = z • coe_fn φ f :=\n  sorry\n\ntheorem lift_aux.smul {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {φ : multilinear_map R s E} (r : R)\n    (x : pi_tensor_product R fun (i : ι) => s i) :\n    coe_fn (lift_aux φ) (r • x) = r • coe_fn (lift_aux φ) x :=\n  sorry\n\n/-- Constructing a linear map `(⨂[R] i, s i) → E` given a `multilinear_map R s E` with the\nproperty that its composition with the canonical `multilinear_map R s E` is\nthe given multilinear map `φ`. -/\ndef lift {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R] {s : ι → Type u_4}\n    [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] {E : Type u_5}\n    [add_comm_monoid E] [semimodule R E] :\n    linear_equiv R (multilinear_map R s E)\n        (linear_map R (pi_tensor_product R fun (i : ι) => s i) E) :=\n  linear_equiv.mk\n    (fun (φ : multilinear_map R s E) =>\n      linear_map.mk (add_monoid_hom.to_fun (lift_aux φ)) sorry sorry)\n    sorry sorry\n    (fun (φ' : linear_map R (pi_tensor_product R fun (i : ι) => s i) E) =>\n      linear_map.comp_multilinear_map φ' (tprod R))\n    sorry sorry\n\n@[simp] theorem lift.tprod {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {φ : multilinear_map R s E}\n    (f : (i : ι) → s i) : coe_fn (coe_fn lift φ) (coe_fn (tprod R) f) = coe_fn φ f :=\n  lift_aux_tprod φ f\n\ntheorem lift.unique' {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {φ : multilinear_map R s E}\n    {φ' : linear_map R (pi_tensor_product R fun (i : ι) => s i) E}\n    (H : linear_map.comp_multilinear_map φ' (tprod R) = φ) : φ' = coe_fn lift φ :=\n  ext (Eq.symm H ▸ Eq.symm (linear_equiv.symm_apply_apply lift φ))\n\ntheorem lift.unique {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {φ : multilinear_map R s E}\n    {φ' : linear_map R (pi_tensor_product R fun (i : ι) => s i) E}\n    (H : ∀ (f : (i : ι) → s i), coe_fn φ' (coe_fn (tprod R) f) = coe_fn φ f) : φ' = coe_fn lift φ :=\n  lift.unique' (multilinear_map.ext H)\n\ntheorem lift_tprod {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_semiring R]\n    {s : ι → Type u_4} [(i : ι) → add_comm_monoid (s i)] [(i : ι) → semimodule R (s i)] :\n    coe_fn lift (tprod R) = linear_map.id :=\n  Eq.symm (lift.unique' rfl)\n\nend pi_tensor_product\n\n\nnamespace pi_tensor_product\n\n\n/- Unlike for the binary tensor product, we require `R` to be a `comm_ring` here, otherwise\nthis is false in the case where `ι` is empty. -/\n\nprotected instance add_comm_group {ι : Type u_1} [DecidableEq ι] {R : Type u_2} [comm_ring R]\n    {s : ι → Type u_3} [(i : ι) → add_comm_group (s i)] [(i : ι) → module R (s i)] :\n    add_comm_group (pi_tensor_product R fun (i : ι) => s i) :=\n  semimodule.add_comm_monoid_to_add_comm_group R\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/pi_tensor_product_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.498208817495433}}
{"text": "import .formula .asubst\n\nvariables {α β : Type}\n\nopen list atom tactic\n\ndef formula.atoms : formula → list atom\n| ⊤' := []\n| ⊥' := []\n| (A' a) := [a]\n| (¬' p) := p.atoms\n| (p ∨' q) := p.atoms ++ q.atoms\n| (p ∧' q) := p.atoms ++ q.atoms\n| (∃' p) := p.atoms\n\ndef head_coeff : atom → znum\n| (le i [])         := 0\n| (le i (k::_))     := k\n| (dvd d i [])      := 0\n| (dvd d i (k::_))  := k\n| (ndvd d i [])     := 0\n| (ndvd d i (k::_)) := k\n\ndef dep_0 (a : atom) := head_coeff a ≠ 0\n\ninstance dec_dep_0 : decidable_pred dep_0 :=\nbegin intro a, cases a; simp [dep_0, head_coeff]; apply_instance end\n\ndef formula.atoms_dep_0 (p : formula) : list atom :=\np.atoms.filter dep_0\n\ndef atom.unify : znum → atom → atom\n| m (atom.le i (k::ks)) :=\n  if k = 0\n  then (atom.le i (0::ks))\n  else let m' := (m / (abs k)) in\n       atom.le (m' * i) (znum.sign k :: map_mul m' ks)\n| m (atom.dvd d i (k::ks)) :=\n  if k = 0\n  then (atom.dvd d i (0::ks))\n  else let m' := (m / k) in\n       atom.dvd (m' * d) (m' * i) (1 :: map_mul m' ks)\n| m (atom.ndvd d i (k::ks)) :=\n  if k = 0\n  then (atom.ndvd d i (0::ks))\n  else let m' := (m / k) in\n       atom.ndvd (m' * d) (m' * i) (1 :: map_mul m' ks)\n| m (atom.le i []) := (atom.le i [])\n| m (atom.dvd d i []) := (atom.dvd d i [])\n| m (atom.ndvd d i []) := (atom.ndvd d i [])\n\ndef coeffs_lcm (p : formula) :=\n  znum.lcms (map head_coeff p.atoms_dep_0)\n\ndef divisor : atom → znum\n| (atom.le i ks)     := 1\n| (atom.dvd d i ks)  := d\n| (atom.ndvd d i ks) := d\n\n\ndef divisors_lcm (p : formula) :=\n  znum.lcms (map divisor (p.atoms_dep_0))\n\ndef formula.unify (p : formula) : formula :=\nA' (atom.dvd (coeffs_lcm p) 0 [1]) ∧' (p.map (atom.unify (coeffs_lcm p)))\n\ndef inf_minus : formula → formula\n| ⊤' := ⊤'\n| ⊥' := ⊥'\n| (A' (atom.le i (k::ks))) :=\n  if k < 0\n  then ⊤'\n  else if k > 0\n       then ⊥'\n       else A' (atom.le i (0::ks))\n| (A' a) := A' a\n| (p ∧' q) := and_o (inf_minus p) (inf_minus q)\n| (p ∨' q) := or_o (inf_minus p) (inf_minus q)\n| (¬' p) := ¬' p\n| (∃' p) := ∃' p\n\nlemma inf_minus_le_eq_of_lt {i k ks} :\n  k < 0 → inf_minus (A' (atom.le i (k::ks))) = ⊤' :=\nbegin intro h, simp [inf_minus], rw if_pos, assumption end\n\nlemma inf_minus_le_eq_of_eq {i ks} :\n  inf_minus (A' (atom.le i (0::ks))) = (A' (atom.le i (0::ks))) :=\nbegin\n  simp [inf_minus], rw if_neg,\n  rw if_neg, exact_dec_trivial, exact_dec_trivial\nend\n\nlemma inf_minus_le_eq_of_gt {i k ks} :\n  k > 0 → inf_minus (A' (atom.le i (k::ks))) = ⊥' :=\nbegin\n  intro h, simp [inf_minus], rw if_neg,\n  rw if_pos, apply h, rw not_lt, apply le_of_lt h,\nend\n\ndef inf_minus_le_eq {i k ks} :\n  inf_minus (A' (atom.le i (k::ks))) =\n  if k < 0\n  then ⊤'\n  else if k > 0\n       then ⊥'\n       else A' (atom.le i (0::ks)) := rfl\n\ndef subst (i ks) (p : formula) := p.map (asubst i ks)\n\ndef get_lb : atom → option (znum × list znum)\n| (atom.le i (k::ks)) :=\n  if k > 0 then (i,ks) else none\n| (atom.le _ []) := none\n| (atom.dvd _ _ _) := none\n| (atom.ndvd _ _ _) := none\n\ndef bnd_points (p : formula) :=\n  filter_map get_lb (p.atoms_dep_0)\n\nlemma bnd_points_le_eq {i k ks} :\n  k > 0 → bnd_points (A' (atom.le i (k::ks))) = [(i,ks)] :=\nbegin\n  intro h, simp [formula.atoms, bnd_points,\n    formula.atoms_dep_0, dep_0, filter, head_coeff],\n  rw if_pos, simp [filter_map, get_lb],\n  rw if_pos, refl, assumption, intro hc,\n  subst hc, cases h\nend\n\nlemma znum.range_neg_eq_range :\n  ∀ {z}, znum.range (-z) = znum.range z :=\nbegin intro z, cases z; simp [znum.range, znum.abs]; refl end\n\nlemma znum.mem_range {z y : znum} :\n  0 ≤ z → z < y → z ∈ znum.range y :=\nbegin\n  intros hz hzy, have hy : 0 ≤ y := le_of_lt (lt_of_le_of_lt hz hzy),\n  unfold znum.range, rewrite mem_map, rewrite znum.nonneg_iff_exists at hz,\n  cases hz with n hn, subst hn, existsi n, apply and.intro _ rfl,\n  rewrite num.mem_range, rewrite iff.symm num.lt_to_znum,\n  rw znum.to_znum_abs hy, assumption,\nend\n\nlemma znum.mem_range' {z y : znum} :\n  0 ≤ z → z < (abs y) → z ∈ znum.range y :=\nbegin\n  by_cases hy : (0 ≤ y),\n  { rw abs_of_nonneg hy, apply znum.mem_range },\n  { simp [not_le] at hy, rw abs_of_nonpos (le_of_lt hy),\n    rw znum.range_neg_eq_range.symm, apply znum.mem_range }\nend\n\nlemma znum.mem_range_iff {x y : znum} :\n   0 ≤ y → (x ∈ znum.range y ↔ (0 ≤ x ∧ x < y)) :=\nbegin\n  intro h1, constructor; intro h2,\n  { simp [znum.range] at h2, cases h2 with n hn,\n    cases hn with hn1 hn2, subst hn2, constructor,\n    apply num.to_znum_nonneg, simp [num.mem_range] at hn1,\n    rw num.lt_to_znum.symm at hn1,\n    rw znum.to_znum_abs h1 at hn1, assumption },\n  { apply znum.mem_range h2.left h2.right }\nend\n\ndef sqe_inf (p : formula) : formula :=\n  disj_map (znum.range (divisors_lcm p)) (λ n, subst n [] (inf_minus p))\n\ndef sqe_bnd  (p : formula) : formula :=\n  disj_map (bnd_points p)\n   (λ iks, disj_map (znum.range (divisors_lcm p))\n     (λ n, subst (iks^.fst + n) (map_neg iks^.snd) p))\n\ndef sqe_core (p : formula) : formula :=\n  or_o (sqe_inf p) (sqe_bnd p)\n\ndef sqe (p : formula) : formula := sqe_core p.unify\n", "meta": {"author": "skbaek", "repo": "cooper", "sha": "812afc6b158821f2e7dac9c91d3b6123c7a19faf", "save_path": "github-repos/lean/skbaek-cooper", "path": "github-repos/lean/skbaek-cooper/cooper-812afc6b158821f2e7dac9c91d3b6123c7a19faf/lia/sqe.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851918, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4982088001793127}}
{"text": "/-\nCopyright (c) 2021 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport analysis.analytic.basic\n\n/-!\n# Linear functions are analytic\n\nIn this file we prove that a `continuous_linear_map` defines an analytic function with\nthe formal power series `f x = f a + f (x - a)`.\n-/\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{E : Type*} [normed_group E] [normed_space 𝕜 E]\n{F : Type*} [normed_group F] [normed_space 𝕜 F]\n{G : Type*} [normed_group G] [normed_space 𝕜 G]\n\nopen_locale topological_space classical big_operators nnreal ennreal\nopen set filter asymptotics\n\nnoncomputable theory\n\nnamespace continuous_linear_map\n\n/-- Formal power series of a continuous linear map `f : E →L[𝕜] F` at `x : E`:\n`f y = f x + f (y - x)`. -/\n@[simp] def fpower_series (f : E →L[𝕜] F) (x : E) : formal_multilinear_series 𝕜 E F\n| 0 := continuous_multilinear_map.curry0 𝕜 _ (f x)\n| 1 := (continuous_multilinear_curry_fin1 𝕜 E F).symm f\n| _ := 0\n\n@[simp] lemma fpower_series_apply_add_two (f : E →L[𝕜] F) (x : E) (n : ℕ) :\n  f.fpower_series x (n + 2) = 0 := rfl\n\n@[simp] lemma fpower_series_radius (f : E →L[𝕜] F) (x : E) : (f.fpower_series x).radius = ∞ :=\n(f.fpower_series x).radius_eq_top_of_forall_image_add_eq_zero 2 $ λ n, rfl\n\nprotected theorem has_fpower_series_on_ball (f : E →L[𝕜] F) (x : E) :\n  has_fpower_series_on_ball f (f.fpower_series x) x ∞ :=\n{ r_le := by simp,\n  r_pos := ennreal.coe_lt_top,\n  has_sum := λ y _, (has_sum_nat_add_iff' 2).1 $\n    by simp [finset.sum_range_succ, ← sub_sub, has_sum_zero] }\n\nprotected theorem has_fpower_series_at (f : E →L[𝕜] F) (x : E) :\n  has_fpower_series_at f (f.fpower_series x) x :=\n⟨∞, f.has_fpower_series_on_ball x⟩\n\nprotected theorem analytic_at (f : E →L[𝕜] F) (x : E) : analytic_at 𝕜 f x :=\n(f.has_fpower_series_at x).analytic_at\n\n/-- Reinterpret a bilinear map `f : E →L[𝕜] F →L[𝕜] G` as a multilinear map\n`(E × F) [×2]→L[𝕜] G`. This multilinear map is the second term in the formal\nmultilinear series expansion of `uncurry f`. It is given by\n`f.uncurry_bilinear ![(x, y), (x', y')] = f x y'`. -/\ndef uncurry_bilinear (f : E →L[𝕜] F →L[𝕜] G) : (E × F) [×2]→L[𝕜] G :=\n@continuous_linear_map.uncurry_left 𝕜 1 (λ _, E × F) G _ _ _ _ _ $\n  (↑(continuous_multilinear_curry_fin1 𝕜 (E × F) G).symm : (E × F →L[𝕜] G) →L[𝕜] _).comp $\n    f.bilinear_comp (fst _ _ _) (snd _ _ _)\n\n@[simp] lemma uncurry_bilinear_apply (f : E →L[𝕜] F →L[𝕜] G) (m : fin 2 → E × F) :\n  f.uncurry_bilinear m = f (m 0).1 (m 1).2 :=\nrfl\n\n/-- Formal multilinear series expansion of a bilinear function `f : E →L[𝕜] F →L[𝕜] G`. -/\n@[simp] def fpower_series_bilinear (f : E →L[𝕜] F →L[𝕜] G) (x : E × F) :\n  formal_multilinear_series 𝕜 (E × F) G\n| 0 := continuous_multilinear_map.curry0 𝕜 _ (f x.1 x.2)\n| 1 := (continuous_multilinear_curry_fin1 𝕜 (E × F) G).symm (f.deriv₂ x)\n| 2 := f.uncurry_bilinear\n| _ := 0\n\n@[simp] lemma fpower_series_bilinear_radius (f : E →L[𝕜] F →L[𝕜] G) (x : E × F) :\n  (f.fpower_series_bilinear x).radius = ∞ :=\n(f.fpower_series_bilinear x).radius_eq_top_of_forall_image_add_eq_zero 3 $ λ n, rfl\n\nprotected \n\nprotected theorem has_fpower_series_at_bilinear (f : E →L[𝕜] F →L[𝕜] G) (x : E × F) :\n  has_fpower_series_at (λ x : E × F, f x.1 x.2) (f.fpower_series_bilinear x) x :=\n⟨∞, f.has_fpower_series_on_ball_bilinear x⟩\n\nprotected theorem analytic_at_bilinear (f : E →L[𝕜] F →L[𝕜] G) (x : E × F) :\n  analytic_at 𝕜 (λ x : E × F, f x.1 x.2) x :=\n(f.has_fpower_series_at_bilinear x).analytic_at\n\nend continuous_linear_map\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/analysis/analytic/linear.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4981807732570775}}
{"text": "import system_of_complexes.basic\n\nuniverse variables u\n\nnoncomputable theory\nopen_locale nnreal\nopen category_theory opposite normed_add_group_hom system_of_complexes\n\nvariables (M M' N : system_of_complexes.{u}) (f : M ⟶ M') (g : M' ⟶ N)\n\n/-- The normed snake lemma, weak version. See Proposition 9.10 from Analytic.pdf -/\n--TODO Add the non weak version for complete system of complexes\nlemma weak_normed_snake {k k' k'' K K' K'' : ℝ≥0}\n  [hk : fact (1 ≤ k)] [hk' : fact (1 ≤ k')] [hk'' : fact (1 ≤ k'')]\n  {m : ℕ} {c₀ : ℝ≥0}\n  (hM : M.is_weak_bounded_exact k K (m+1) c₀)\n  (hM' : M'.is_weak_bounded_exact k' K' (m+1) c₀)\n  (hM'_adm : M'.admissible)\n  (hf : ∀ c i, (f.apply : M c i ⟶ M' c i).norm_noninc)\n  (Hf : ∀ (c : ℝ≥0) [fact (c₀ ≤ c)] (i : ℕ) (hi : i ≤ m+1+1) (x : M (k'' * c) i),\n    ∥(res x : M c i)∥ ≤ K'' * ∥f x∥)\n  (hg : ∀ c i, (g.apply : M' c i ⟶ N c i).ker = f.apply.range)\n  (hgquot : system_of_complexes.is_quotient g) :\n  N.is_weak_bounded_exact (k''*k*k') (K'*(K*K'' + 1)) m c₀ :=\nbegin\n  introsI c hc i hi,\n  let c₁ := k'' * (k * (k' * c)),\n  suffices : ∀ n : N c₁ i, ∀ ε > 0,\n    ∃ i₀ (hi₀ : i₀ = i - 1) (y : N c i₀),\n      ∥res n - N.d _ _ y∥ ≤ K' * (K * K'' + 1) * ∥N.d i (i+1) n∥ + ε,\n  { dsimp [c₁] at this,\n    intros n₁ ε hε,\n    haveI hc : fact (k'' * k * k' * c = c₁) :=\n      { out := (mul_assoc _ _ _).trans ((mul_assoc _ _ _).trans rfl) },\n    rcases this (res n₁) ε hε with ⟨i₀, hi₀, y, hy⟩,\n    rw [res_res, d_res] at hy,\n    refine ⟨i₀, _, hi₀, rfl, _⟩,\n    refine ⟨y, hy.trans (add_le_add_right (mul_le_mul_of_nonneg_left _ _) ε)⟩,\n    { apply (admissible_of_quotient hgquot hM'_adm).res_norm_noninc },\n    { exact (nnreal.zero_le_coe : 0 ≤ K' * (K * K'' + 1)) } },\n  intros n ε hε,\n  let ε₁ := ε/(K' * (K * K'' + 2) + 1),\n\n  have hε₁ : 0 < ε₁ :=\n    div_pos hε (lt_of_lt_of_le zero_lt_one (nnreal.one_le_add'.out : 1 ≤ K' * (K * K'' + 2) + 1)),\n\n  obtain ⟨m' : M' c₁ i, rfl : g m' = n⟩ := (hgquot _ _).surjective _,\n  let m₁' := M'.d i (i+1) m',\n  have hm₁' : g m₁' = N.d i (i+1) (g m') := (d_apply _ _ g m').symm,\n  obtain ⟨m₁'' : M' c₁ (i+1),\n          hgm₁'' : g m₁'' = N.d i (i+1) (g m'),\n          hnorm_m₁'' : ∥m₁''∥ < ∥N.d i (i+1) (g m')∥ + ε₁⟩ :=\n    (hgquot _ _).norm_lift hε₁ (N.d i (i+1) (g m')),\n  obtain ⟨m₁, hm₁⟩ : ∃ m₁ : M c₁ (i+1), f m₁ + m₁'' = m₁',\n  { have hrange : m₁' - m₁'' ∈ f.apply.range,\n    { rw [← hg _ _, mem_ker  _ _, _root_.map_sub],\n      change g m₁' - g m₁'' = 0,\n      rw [hm₁', hgm₁'', sub_self] },\n    obtain ⟨m₁, hm₁ : f m₁ = m₁' - m₁''⟩ := (mem_range _ _).1 hrange,\n    exact ⟨m₁, by rw [hm₁, sub_add_cancel]⟩ },\n\n  have him : i+2 ≤ m+2 := add_le_add_right hi _,\n  have hm₂ : f (M.d (i+1) (i+2) m₁) = -M'.d (i+1) (i+2) m₁'',\n  { rw [← d_apply, eq_sub_of_add_eq hm₁, _root_.map_sub, ← category_theory.comp_apply,\n       d_comp_d, coe_zero, ← neg_inj, pi.zero_apply, zero_sub], },\n  have hle : ∥res (M.d (i+1) (i+2) m₁)∥ ≤ K'' * ∥m₁''∥,\n  { calc ∥res (M.d (i+1) (i+2) m₁)∥\n        ≤ K'' * ∥f (M.d (i+1) (i+2) m₁)∥ : Hf _ _ him _\n    ... = K'' * ∥M'.d (i+1) (i+2) m₁''∥ : by rw [hm₂, norm_neg]\n    ... ≤ K'' * ∥m₁''∥ : (mul_le_mul_of_nonneg_left\n                           (hM'_adm.d_norm_noninc _ _ _ _ m₁'') $ nnreal.coe_nonneg K'') },\n  obtain ⟨i', j, hi', rfl, m₀, hm₀⟩ :=\n    hM _ ⟨hc.out.trans $ le_mul_of_one_le_left' hk'.out⟩ _ (nat.succ_le_succ hi) (res m₁) ε₁ hε₁,\n  rw [← nat.pred_eq_sub_one, i.pred_succ] at hi', subst i',\n  replace hm₀ : ∥res m₁ - M.d i (i+1) m₀∥ ≤ K * K'' * ∥N.d i (i+1) (g m')∥ + K*K''*ε₁ + ε₁,\n  { calc ∥res m₁ - M.d i (i+1) m₀∥  = ∥res (res m₁) - M.d i (i+1) m₀∥ : by rw res_res\n    ... ≤ K * ∥M.d (i+1) (i+2) (res m₁)∥ + ε₁ : hm₀\n    ... = K * ∥res (M.d (i+1) (i+2) m₁)∥ + ε₁ : by rw d_res\n    ... ≤ K*(K'' * ∥m₁''∥) + ε₁ : add_le_add_right (mul_le_mul_of_nonneg_left hle nnreal.zero_le_coe) _\n    ... ≤ K*(K'' * (∥N.d i (i+1) (g m')∥ + ε₁)) + ε₁ :  add_le_add_right (mul_le_mul_of_nonneg_left\n                                        (mul_le_mul_of_nonneg_left hnorm_m₁''.le nnreal.zero_le_coe)\n                                         nnreal.zero_le_coe) ε₁\n    ... = K * K'' * ∥N.d i (i+1) (g m')∥ + K*K''*ε₁ + ε₁ : by ring },\n\n  let mnew₁' := M'.d i (i+1) (res m' - f m₀),\n  have hmnew' : mnew₁' = res m₁'' + f (res m₁ - M.d i (i+1) m₀),\n  { calc mnew₁'\n        = M'.d i (i+1) (res m' - f m₀) : rfl\n    ... = res (M'.d i (i+1) m') - (f (M.d i (i+1) m₀)) : by rw [_root_.map_sub, d_res _, d_apply]\n    ... = res (M'.d i (i+1) m') - (f (res m₁)) + (f (res m₁) - f (M.d i (i+1) m₀)) : by abel\n    ... = res m₁'' + f ((res m₁) - (M.d i (i+1) m₀)) : by\n                        { rw [← system_of_complexes.map_sub, ← res_apply,\n                              ← _root_.map_sub, ← sub_eq_of_eq_add' hm₁.symm] } },\n  have hnormle : ∥mnew₁'∥ ≤ (K*K'' + 1)*∥N.d i (i+1) (g m')∥ + (K*K'' + 2) * ε₁,\n  { calc ∥mnew₁'∥\n        = ∥res m₁'' + f (res m₁ - M.d i (i+1) m₀)∥ : by rw [hmnew']\n    ... ≤ ∥res m₁''∥ + ∥f (res m₁ - M.d i (i+1) m₀)∥ : norm_add_le _ _\n    ... ≤ ∥m₁''∥ + ∥f (res m₁ - M.d i (i+1) m₀)∥ : add_le_add_right\n                                      (hM'_adm.res_norm_noninc _ _ _ _ m₁'') _\n    ... ≤ ∥m₁''∥ + ∥res m₁ - M.d i (i+1) m₀∥ : add_le_add_left (hf _ _ _) _\n    ... ≤ ∥N.d i (i+1) (g m')∥ + ε₁ + ∥res m₁ - M.d i (i+1) m₀∥ : add_le_add_right (le_of_lt hnorm_m₁'')  _\n    ... ≤ ∥N.d i (i+1) (g m')∥ + ε₁ + (K * K'' * ∥N.d i (i+1) (g m')∥ + K * K'' * ε₁ + ε₁) : add_le_add_left hm₀ _\n    ... = (K*K'' + 1)*∥d _ _ (i+1) (g m')∥ + (K*K'' + 2) * ε₁ : by ring },\n  obtain ⟨i₀, _, hi₀, rfl, mnew₀, hmnew₀⟩ := hM' _ hc _ (hi.trans m.le_succ) (res m' - f m₀) _ hε₁,\n  replace hmnew₀ : ∥res (res m' - f m₀) - d _ _ _ mnew₀∥ ≤\n    K' * ((K * K'' + 1) * ∥N.d i (i+1) (g m')∥ + (K * K'' + 2) * ε₁) + ε₁ :=\n    hmnew₀.trans (add_le_add_right (mul_le_mul_of_nonneg_left hnormle nnreal.zero_le_coe) ε₁),\n  let nnew₀ : ↥(N c i₀) := g mnew₀,\n  have hmnewlift : g (res (res m' - f m₀) - M'.d i₀ i mnew₀) = res (g m') - N.d i₀ i nnew₀,\n  { suffices h : g (res m' - f m₀) = res (g m'),\n    { rw [system_of_complexes.map_sub, ← res_apply, ← d_apply, h, res_res] },\n    rw system_of_complexes.map_sub,\n    have hker : f m₀ ∈ g.apply.ker,\n    { rw [hg _ _, mem_range _ _],\n      exact ⟨m₀, rfl⟩ },\n    replace hker : g (f m₀) = 0, { rwa mem_ker at hker },\n    rw [hker, sub_zero, ← res_apply] },\n  refine ⟨i₀, hi₀, nnew₀, _⟩,\n  rw ← hmnewlift,\n  refine ((hgquot _ _).norm_le _).trans (hmnew₀.trans (le_of_eq _)),\n  have hε₁_ε : (K' * (K * K'' + 2) + 1 : ℝ)*ε₁ = ε := mul_div_cancel' _\n    (by { refine (lt_of_lt_of_le zero_lt_one _).ne',\n          exact (nnreal.one_le_add'.out : 1 ≤ K' * (K * K'' + 2) + 1) }),\n  rw ← hε₁_ε,\n  ring,\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/normed_snake.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580952177051, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4981807702232247}}
{"text": "\ninductive direction | left | right\ninstance : decidable_eq direction := by tactic.mk_dec_eq_instance\n\nlocal prefix ^ := option\n\ndef nondet_turing_machine (state symbol : Type) [decidable_eq state] [decidable_eq symbol] :=\nstate → ^symbol → state → ^symbol → direction → bool\n\ndef turing_machine (state symbol : Type) [decidable_eq state] [decidable_eq symbol] :=\nstate → ^symbol → ^(state × ^symbol × direction)\n\nvariables {S A : Type} [decidable_eq S] [decidable_eq A]\n\ndef to_nondet (TM : turing_machine S A) : nondet_turing_machine S A :=\nλ s a s' a' d', (TM s a = some (s', a', d') : bool)\n\ninstance : has_coe (turing_machine S A) (nondet_turing_machine S A) :=\n⟨to_nondet⟩\n\nstructure TM_config (S A : Type) :=\n(cur : S)\n(head : ^A)\n(left : list (^A))\n(right : list (^A))\n\ndef uncons : list (^A) → ^A × list (^A)\n| []       := (none, [])\n| (a :: s) := (a, s)\n\ndef cons' : ^A → list (^A) → list (^A)\n| none [] := []\n| v    s  := v::s\n\ndef apply_step\n  (l r : list (^A)) (c : S) (v : ^A) : direction → TM_config S A\n| direction.left  := let ⟨a, l'⟩ := uncons l in ⟨c, a, l', cons' v r⟩\n| direction.right := let ⟨a, r'⟩ := uncons r in ⟨c, a, cons' v l, r'⟩\n\ninductive step (TM : nondet_turing_machine S A) :\n  TM_config S A → TM_config S A → Prop\n| mk {c h l r c' v d} :\n  TM c h c' v d → step ⟨c, h, l, r⟩ (apply_step l r c' v d)\n\ndef halts (TM) (s : TM_config S A) : Prop := ∀ s', ¬ step TM s s'\n\ninductive computes (TM) (res : TM_config S A) : nat → TM_config S A → Prop\n| done : halts TM res → computes 0 res\n| step {s s' n} : step TM s s' → computes n s' → computes (n+1) s\n\ndef next (TM : turing_machine S A) : TM_config S A → option (TM_config S A)\n| ⟨c, h, l, r⟩ := match TM c h with\n  | none := none\n  | some (c', v, d) := some (apply_step l r c' v d)\n  end\n\ntheorem next_step {TM : turing_machine S A}\n  (s s' : TM_config S A) : next TM s = some s' ↔ @step S A _ _ TM s s' :=\nbegin\n  constructor,\n  { cases s, simp [next],\n    ginduction TM cur head with e,\n    { intro e, injection e },\n    { cases a with s' a, cases a with v d,\n      simp [next], intro i, injection i with h, subst h,\n      exact ⟨to_bool_true e⟩ } },\n  { intro h, induction h,\n    simp [next],\n    conv at a {whnf}, rw of_to_bool_true a,\n    refl }\nend\n\ntheorem next_halts {TM : turing_machine S A}\n  (s : TM_config S A) : next TM s = none ↔ @halts S A _ _ TM s :=\nbegin\n  ginduction (next TM s) with e,\n  { simp, intros s' h,\n    injection e.symm.trans ((next_step _ _).2 h) },\n  { constructor; intro h, {contradiction},\n    exact absurd ((next_step _ _).1 e) (h _) }\nend\n\ninductive tape_alpha (n : nat) : Type\n| input {} : bool → tape_alpha\n| delim {} : tape_alpha\n| work {} : fin n → tape_alpha\ninstance (n) : decidable_eq (tape_alpha n) := by tactic.mk_dec_eq_instance\n\ndef TATM (s n : nat) := turing_machine (fin (s+1)) (tape_alpha n)\n\ndef NTATM (s n : nat) := nondet_turing_machine (fin (s+1)) (tape_alpha n)\n\ninstance (s n) : has_coe (TATM s n) (NTATM s n) := ⟨to_nondet⟩\n\ndef encode {n} : list (list bool) → list (^tape_alpha n)\n| [] := []\n| ([] :: ls) := some tape_alpha.delim :: encode ls\n| ((a::l) :: ls) := some (tape_alpha.input a) :: encode (l::ls)\n\ndef computes_fn_in_time {s n} (TM : NTATM s n) {m}\n  (f : (fin m → list bool) → list bool)\n  (tm : (fin m → list bool) → nat) : Prop :=\n∀ i : fin m → list bool,\n∃ (n ≤ tm i) e,\n  computes TM\n    ⟨e, none, [], encode [f i]⟩ n\n    ⟨0, none, [], encode (array.to_list ⟨i⟩)⟩\n", "meta": {"author": "thalesant", "repo": "formalabstracts-2017", "sha": "c47181342c9e41954aa8d41f5049965b5f332bca", "save_path": "github-repos/lean/thalesant-formalabstracts-2017", "path": "github-repos/lean/thalesant-formalabstracts-2017/formalabstracts-2017-c47181342c9e41954aa8d41f5049965b5f332bca/fabstract/Cook_S_P_NP/turing_machines.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.49818076770616404}}
{"text": "import algebra.field\nimport algebra.char_zero\nimport algebra.char_p\nimport gtm106.naive_plane\nimport gtm106.weierstrass_equation.basic\nimport gtm106.weierstrass_equation.linear_change_of_variable\nimport myhelper.char\nimport tactic\n\nnamespace weierstrass_equation\n\ndef is_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) :=\nE.a1 = 0 ∧ E.a3 = 0\n\n@[simp]\nlemma b2_of_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2) :\nE.b2 = 4*E.a2 :=\nbegin\n  simp [b2, h.1, zero_pow],\nend\n\n@[simp]\nlemma b4_of_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2) :\nE.b4 = 2*E.a4 :=\nbegin\n  simp [b4, h.1, h.2],\nend\n\n@[simp]\nlemma b6_of_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2) :\nE.b6 = 4*E.a6 :=\nbegin\n  simp [b6, h.2, zero_pow],\nend\n\n@[simp]\nlemma b8_of_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2) :\nE.b8 = 4*E.a2*E.a6 - E.a4^2 :=\nbegin\n  simp [b8, h.1, h.2, zero_pow],\nend\n\n@[simp]\nlemma c4_of_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2) :\nE.c4 = 16*E.a2^2 - 48*E.a4 :=\nbegin\n  simp [c4, h],\n  ring,\nend\n\n@[simp]\nlemma c6_of_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2) :\nE.c6 = -64*E.a2^3 + 288*E.a2*E.a4 - 864*E.a6 :=\nbegin\n  simp [c6, h],\n  ring,\nend\n\n@[simp]\nlemma disc_of_model_of_char_neq_2 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2) :\nE.disc = -64*E.a2^3*E.a6 + 16*E.a2^2*E.a4^2 - 64*E.a4^3 - 432*E.a6^2 +288*E.a2*E.a4*E.a6 :=\nbegin\n  simp [disc, h],\n  ring,\nend\n\nlemma have_model_of_char_neq_2 {K : Type*} [field K]\n(E : weierstrass_equation K) (hchar2 : ring_char K ≠ 2)\n: ∃ (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_neq_2 :=\nbegin\n  replace hchar2 := prime_neq_char_is_non_zero K 2 (by norm_num) hchar2,\n  norm_cast at hchar2,\n  use ⟨ 1, 0, -E.a1/2, -E.a3/2, by simp ⟩,\n  simp [is_model_of_char_neq_2, linear_change_of_variable.change_curve],\n  field_simp [hchar2],\n  simp [mul_comm],\nend\n\ndef is_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) :=\nE.a1 = 0 ∧ E.a2 = 0 ∧ E.a3 = 0\n\n@[simp]\nlemma b2_of_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) :\nE.b2 = 0 :=\nbegin\n  simp [b2, h.1, h.2.1, zero_pow],\nend\n\n@[simp]\nlemma b4_of_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) :\nE.b4 = 2*E.a4 := E.b4_of_model_of_char_neq_2 ⟨ h.1, h.2.2 ⟩\n\n@[simp]\nlemma b6_of_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) :\nE.b6 = 4*E.a6 := E.b6_of_model_of_char_neq_2 ⟨ h.1, h.2.2 ⟩\n\n@[simp]\nlemma b8_of_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) :\nE.b8 = -E.a4^2 :=\nbegin\n  simp [b8, h.1, h.2.1, h.2.2, zero_pow],\nend\n\n@[simp]\nlemma c4_of_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) :\nE.c4 = -48*E.a4 :=\nbegin\n  simp [c4, h],\n  ring,\nend\n\n@[simp]\nlemma c6_of_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) :\nE.c6 = -864*E.a6 :=\nbegin\n  simp [c6, h],\n  ring,\nend\n\n@[simp]\nlemma disc_of_model_of_char_neq_2_and_3 {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) :\nE.disc = -16*(4*E.a4^3 + 27*E.a6^2) :=\nbegin\n  simp [disc, h],\n  ring,\nend\n\n@[simp]\nlemma j_of_model_of_char_neq_2_and_3 {K : Type*} [field K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) (hchar2 : ring_char K ≠ 2) :\nE.j = 6912*E.a4^3/(4*E.a4^3 + 27*E.a6^2) :=\nbegin\n  simp [j, h],\n  by_cases h : 4*E.a4^3 + 27*E.a6^2 = 0, {\n    rw h, simp,\n  },\n  have h16 := power_of_prime_neq_char_is_non_zero K 16 2 4 (by norm_num) (by norm_num) hchar2,\n  norm_num at h16,\n  field_simp [h, h16],\n  ring,\nend\n\nlemma have_model_of_char_neq_2_and_3 {K : Type*} [field K]\n(E : weierstrass_equation K) (hchar2 : ring_char K ≠ 2) (hchar3 : ring_char K ≠ 3)\n: ∃ (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_neq_2_and_3 :=\nbegin\n  rcases E.have_model_of_char_neq_2 hchar2 with ⟨ C, h1 ⟩,\n  set E' := C.change_curve E with hE,\n  replace hchar3 := prime_neq_char_is_non_zero K 3 (by norm_num) hchar3,\n  norm_cast at hchar3,\n  let C' : linear_change_of_variable K := ⟨ 1, -E'.a2/3, 0, 0, by simp ⟩,\n  use C'.composite C,\n  rw [linear_change_of_variable.change_curve.comp, ← hE],\n  simp [is_model_of_char_neq_2_and_3,\n    linear_change_of_variable.change_curve,\n    h1.1, h1.2, zero_pow],\n  field_simp [hchar3],\n  ring,\nend\n\ndef is_model_of_char_3_j_non_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) :=\nE.a1 = 0 ∧ E.a3 = 0 ∧ E.a4 = 0\n\n@[simp]\nlemma c4_of_model_of_char_3_j_non_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_3_j_non_zero) (hchar3 : ring_char K = 3) :\nE.c4 = E.a2^2 :=\nbegin\n  simp [c4, b2, b4,\n    h.1, h.2.1, h.2.2, zero_pow],\n  ring_char3,\nend\n\n@[simp]\nlemma disc_of_model_of_char_3_j_non_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_3_j_non_zero) (hchar3 : ring_char K = 3) :\nE.disc = -E.a2^3*E.a6 :=\nbegin\n  simp [disc, b2, b4,\n    b6, b8,\n    h.1, h.2.1, h.2.2, zero_pow],\n  ring_char3,\nend\n\n@[simp]\nlemma j_of_model_of_char_3_j_non_zero {K : Type*} [field K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_3_j_non_zero) (hchar3 : ring_char K = 3) :\nE.j = -E.a2^3/E.a6 :=\nbegin\n  simp [j, h, hchar3],\n  by_cases ha6 : E.a6 = 0, {\n    rw ha6, simp,\n  },\n  by_cases ha2 : E.a2 = 0, {\n    rw ha2, simp [zero_pow],\n  },\n  field_simp [ha2, ha6], ring,\nend\n\n@[simp]\nlemma c4_of_model_of_char_3_j_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) (hchar3 : ring_char K = 3) :\nE.c4 = 0 :=\nbegin\n  simp [h],\n  ring_char3,\nend\n\n@[simp]\nlemma disc_of_model_of_char_3_j_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) (hchar3 : ring_char K = 3) :\nE.disc = -E.a4^3 :=\nbegin\n  simp [h],\n  ring_char3,\nend\n\n@[simp]\nlemma j_of_model_of_char_3_j_zero {K : Type*} [field K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_neq_2_and_3) (hchar3 : ring_char K = 3) :\nE.j = 0 :=\nbegin\n  simp [j, h, hchar3],\nend\n\nlemma have_model_of_char_3 {K : Type*} [field K]\n(E : weierstrass_equation K) (hchar3 : ring_char K = 3)\n: ((E.non_singular' → E.j ≠ 0) ∧ ∃ (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_3_j_non_zero)\n∨ (E.j = 0 ∧ ∃ (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_neq_2_and_3) :=\nbegin\n  have hchar2 : ring_char K ≠ 2 := by {\n    rw hchar3, norm_num,\n  },\n  rcases E.have_model_of_char_neq_2 hchar2 with ⟨ C, h1 ⟩,\n  set E' := C.change_curve E with hE,\n  have hdisc : E'.disc = E'.a2^2*E'.a4^2 - E'.a2^3*E'.a6 - E'.a4^3 := by {\n    clear_value E',\n    simp [h1],\n    ring_char3,\n  },\n  have hc4 : E'.c4 = E'.a2^2 := by {\n    clear_value E',\n    simp [h1],\n    ring_char3,\n  },\n  have hj : E'.j = E.j := C.j E,\n  have hnonsing : E.non_singular' ↔ E'.non_singular' := C.preserve_non_singular' E,\n  rw [← hj, hnonsing],\n  unfold j non_singular',\n  rw hc4,\n  by_cases ha2 : E'.a2 = 0, {\n    right,\n    split, { rw ha2, ring, },\n    use C,\n    exact ⟨ h1.1, ha2, h1.2 ⟩,\n  },\n  left,\n  clear_value E',\n  split, {\n    intro hdisc,\n    simp [ha2, hdisc],\n  },\n  let C' : linear_change_of_variable K := ⟨ 1, E'.a4/E'.a2, 0, 0, by simp ⟩,\n  use C'.composite C,\n  rw [linear_change_of_variable.change_curve.comp, ← hE],\n  simp [is_model_of_char_3_j_non_zero,\n    linear_change_of_variable.change_curve,\n    h1.1, h1.2],\n  field_simp [ha2],\n  ring_char3,\nend\n\ndef is_model_of_char_2_j_non_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) :=\nE.a1 = 1 ∧ E.a3 = 0 ∧ E.a4 = 0\n\ndef is_model_of_char_2_j_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) :=\nE.a1 = 0 ∧ E.a2 = 0\n\n@[simp]\nlemma c4_of_model_of_char_2_j_non_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_2_j_non_zero) (hchar2 : ring_char K = 2) :\nE.c4 = 1 :=\nbegin\n  simp [c4, b2, b4,\n    h.1, h.2.1, h.2.2, zero_pow],\n  ring_char2,\nend\n\n@[simp]\nlemma disc_of_model_of_char_2_j_non_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_2_j_non_zero) (hchar2 : ring_char K = 2) :\nE.disc = E.a6 :=\nsub_eq_zero.1 begin\n  simp [disc, b2, b4,\n    b6, b8,\n    h.1, h.2.1, h.2.2, zero_pow],\n  ring_char2,\nend\n\n@[simp]\nlemma j_of_model_of_char_2_j_non_zero {K : Type*} [field K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_2_j_non_zero) (hchar2 : ring_char K = 2) :\nE.j = 1/E.a6 :=\nbegin\n  simp [j, h, hchar2],\nend\n\n@[simp]\nlemma c4_of_model_of_char_2_j_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_2_j_zero) (hchar2 : ring_char K = 2) :\nE.c4 = 0 :=\nbegin\n  simp [c4, b2, b4,\n    h.1, h.2, zero_pow],\n  ring_char2,\nend\n\n@[simp]\nlemma disc_of_model_of_char_2_j_zero {K : Type*} [comm_ring K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_2_j_zero) (hchar2 : ring_char K = 2) :\nE.disc = E.a3^4 :=\nsub_eq_zero.1 begin\n  simp [disc, b2, b4,\n    b6, b8,\n    h.1, h.2, zero_pow],\n  ring_char2,\nend\n\n@[simp]\nlemma j_of_model_of_char_2_j_zero {K : Type*} [field K]\n(E : weierstrass_equation K) (h : E.is_model_of_char_2_j_zero) (hchar2 : ring_char K = 2) :\nE.j = 0 :=\nbegin\n  simp [j, h, hchar2],\nend\n\nlemma have_model_of_char_2 {K : Type*} [field K]\n(E : weierstrass_equation K) (hchar2 : ring_char K = 2)\n: ((E.non_singular' → E.j ≠ 0) ∧ ∃ (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_2_j_non_zero)\n∨ (E.j = 0 ∧ ∃ (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_2_j_zero) :=\nbegin\n  have hc4 : E.c4 = E.a1^4 := by {\n    simp [c4, b2, b4],\n    ring_char2,\n  },\n  unfold j,\n  rw hc4,\n  by_cases ha1 : E.a1 = 0, {\n    right,\n    split, {\n      rw ha1,\n      ring,\n    },\n    use ⟨ 1, E.a2, 0, 0, by simp ⟩,\n    simp [is_model_of_char_2_j_zero,\n      linear_change_of_variable.change_curve,\n      ha1],\n    ring_char2,\n  },\n  left,\n  split, {\n    unfold non_singular',\n    intro hdisc,\n    field_simp [ha1, hdisc],\n  },\n  use ⟨ E.a1, E.a3/E.a1, 0, (E.a1^2*E.a4+E.a3^2)/E.a1^3, ha1 ⟩,\n  simp [is_model_of_char_2_j_non_zero,\n    linear_change_of_variable.change_curve,\n    ha1],\n  split, {\n    field_simp [ha1], ring_char2,\n  },\n  field_simp [pow_succ, ha1], ring_char2,\nend\n\nend weierstrass_equation\n", "meta": {"author": "acmepjz", "repo": "my-lean-test", "sha": "fd1bb144adc9ccd23794a867a2dd2cf57648b089", "save_path": "github-repos/lean/acmepjz-my-lean-test", "path": "github-repos/lean/acmepjz-my-lean-test/my-lean-test-fd1bb144adc9ccd23794a867a2dd2cf57648b089/gtm106/weierstrass_equation/models_by_characteristic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424411924673, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4981663088734499}}
{"text": "/-\nCopyright (c) 2018 Bruno Bentzen. All rights reserved.\nReleased under the Apache License 2.0 (see \"License\");\nAuthor: Bruno Bentzen\n-/\n\nimport .consistency ..encode\n\nopen nat set classical\n\nlocal attribute [instance, priority 0] prop_decidable\n\nvariables {σ : nat}\n\n/- maximal set of a context -/\n\nnamespace ctx\ndef is_max (Γ : ctx σ) := is_consist Γ ∧ ∀ p, p ∈ Γ ∨ (~p) ∈ Γ\n\ndef insert_form (Γ : ctx σ) (p : form σ) : ctx σ :=\nif is_consist (Γ ⸴ p) then Γ ⸴ p else Γ ⸴ ~p\n\ndef insert_code (Γ : ctx σ) (n : nat) : ctx σ :=\nmatch encodable.decode (form σ) n with\n| none := Γ\n| some p := insert_form Γ p\nend\n\n@[simp]\ndef maxn (Γ : ctx σ) : nat → ctx σ\n| 0     := Γ\n| (n+1) := insert_code (maxn n) n\n\n@[simp]\ndef max (Γ : ctx σ) : ctx σ := \n⋃ n, maxn Γ n\n\n/- maximal extensions are extensions -/\n\nlemma subset_insert_code {Γ : ctx σ} (n) :\n  Γ ⊆ insert_code Γ n :=\nbegin\n  intros v hv,\n  unfold insert_code,\n  cases (encodable.decode (form σ) _); unfold insert_code insert_form,\n  { assumption },\n  { split_ifs; exact set.mem_insert_of_mem _ hv },\nend\n\nlemma subset_maxn {Γ : ctx σ} :\n  ∀ n, Γ ⊆ maxn Γ n\n| 0        := by refl\n| (succ n) := subset.trans (subset_maxn n) (subset_insert_code _)\n\nlemma maxn_subset_max {Γ : ctx σ} (n) :\n  maxn Γ n ⊆ max Γ :=\nsubset_Union _ _\n\nlemma subset_max_self {Γ : ctx σ} :\n  Γ ⊆ max Γ :=\nmaxn_subset_max 0\n\nlemma maxn_subset_succ {Γ : ctx σ} {n : nat} :\n  maxn Γ n ⊆ maxn Γ (n+1) :=\nsubset_insert_code _\n\nlemma maxn_mono {Γ : ctx σ} {m n : nat} (h : n ≤ m) :\n  maxn Γ n ⊆ maxn Γ m :=\nby induction h; [refl, exact subset.trans h_ih (subset_insert_code _)]\n\n/- maximal extensions are maximal -/\n\nlemma insert_form_self {Γ : ctx σ} {p : form σ} :\n  p ∈ insert_form Γ p ∨ (~p) ∈ insert_form Γ p :=\nbegin\n  unfold insert_form, split_ifs,\n  { exact or.inl (mem_insert _ _) },\n  { exact or.inr (mem_insert _ _) },\nend\n\nlemma insert_code_self {Γ : ctx σ} (p : form σ) :\n  p ∈ insert_code Γ (encodable.encode p) ∨ (~p) ∈ insert_code Γ (encodable.encode p) :=\nbegin\n  unfold insert_code,\n  rw (encodable.encodek p),\n  apply insert_form_self,\nend\n\nlemma mem_or_mem_max {Γ : ctx σ} (p : form σ) :\n  p ∈ max Γ ∨ (~p) ∈ max Γ :=\nbegin\n  have := maxn_subset_max (encodable.encode p + 1),\n  exact (insert_code_self p).imp (@this _) (@this _),\nend\n\n/- maximal extensions preserves consistency -/\n\nlemma is_consist_insert_form {Γ : ctx σ} {p : form σ}\n  (H : is_consist Γ) : is_consist (insert_form Γ p) :=\nbegin\n  rw insert_form, split_ifs,\n  { exact h },\n  { exact inconsist_to_neg_consist H h },\nend\n\nlemma is_consist_insert_code {Γ : ctx σ} (n)\n  (H : is_consist Γ) : is_consist (insert_code Γ n) :=\nbegin\n  rw insert_code, cases encodable.decode _ _,\n  { exact H },\n  { exact is_consist_insert_form H }\nend\n\nlemma is_consist_maxn {Γ : ctx σ} : \n  ∀ n, is_consist Γ → is_consist (maxn Γ n)\n| 0 H := H\n| (n+1) H := is_consist_insert_code _ (is_consist_maxn _ H)\n\nlemma in_ext_ctx_max_set_is_in_ext_ctx_at {Γ : ctx σ} {p : form σ} :\n  (p ∈ max Γ) → ∃ n, p ∈ maxn Γ n :=\nmem_Union.1\n\nlemma ext_ctx_lvl {Γ : ctx σ} {p : form σ} :\n  (max Γ ⊢ₛ₅ p) → ∃ n, maxn Γ n ⊢ₛ₅ p :=\nbegin\n  generalize eq : max Γ = Γ',\n  intro h, induction h; subst eq,\n    { cases in_ext_ctx_max_set_is_in_ext_ctx_at h_h,\n      constructor,\n      apply prf.ax,\n      assumption },\n\n    repeat {\n      constructor,\n      apply prf.pl1 <|> apply prf.pl2 <|> apply prf.pl3,\n      exact 0\n    },\n    \n    { cases h_ih_hpq rfl with n0 h_ext_pq,\n      cases h_ih_hp rfl with n1 h_ext_p,\n        cases (prop_decidable (n0 ≤ n1)),\n            have hh: n1 ≤ n0 :=\n              begin\n                cases nat.le_total,\n                assumption,\n                contradiction\n            end,\n          constructor,\n            apply prf.mp,\n            assumption,\n              apply prf.sub_weak,\n                exact h_ext_p,\n                apply maxn_mono,\n                assumption,\n          constructor,\n            apply prf.mp,\n              apply prf.sub_weak,\n                exact h_ext_pq,\n                apply maxn_mono,\n                assumption,\n              assumption },\n\n    { constructor,\n      apply prf.k,\n      exact 0 },\n\n    { constructor,\n      apply prf.t,\n      exact 0 },\n    \n    { constructor,\n      apply prf.s4,\n      exact 0 },\n    \n    { constructor,\n      apply prf.b,\n      exact 0 },\n    \n    { constructor,\n      apply prf.nec h_h,\n      exact 0 }\nend\n\nlemma is_consist_max {Γ : ctx σ} :\n  is_consist Γ → is_consist (max Γ) :=\nλ hc nc, let ⟨n, ht⟩ := ext_ctx_lvl nc in is_consist_maxn _ hc ht\n\n/- maximal consistent sets are closed under derivability -/\n\nlemma max_of_max {Γ : ctx σ} {p : form σ} (h : is_consist Γ) : is_max (max Γ) :=\n⟨ is_consist_max h , mem_or_mem_max⟩ \n\nlemma mem_max_of_prf {Γ : ctx σ} {p : form σ} (h₁ : is_max Γ)\n  (h₂ : Γ ⊢ₛ₅ p) : p ∈ Γ :=\n(h₁.2 p).resolve_right $ λ hn,\nh₁.1 (prf.mp (prf.ax hn) h₂)\n\nend ctx\n\n/- the canonical model construction -/\n\n-- domain\n\nnamespace canonical\ndef domain (σ : nat) : set (wrld σ) := {w | ctx.is_max w}\n\nlemma mem_domain_max {w : wrld σ} :\n  w ∈ domain σ → ∀ p, (p ∈ w) ∨ ((~p) ∈ w) :=\nand.right\n\nlemma mem_domain_consist {w : wrld σ} :\n  w ∈ domain σ → is_consist w :=\nand.left\n\nlemma mem_domain {w : wrld σ}\n  (h : is_consist w) : ctx.max w ∈ domain σ :=\n⟨ctx.is_consist_max h, ctx.mem_or_mem_max⟩\n\nlemma mem_domain_of_prf {p : form σ} (w ∈ domain σ)\n  (h : w ⊢ₛ₅ p) : p ∈ w :=\n(mem_domain_max H p).resolve_right $\nλ hn, (mem_domain_consist H) (prf.mp (prf.ax hn) h)\n\n-- accessibility\n\ndef unbox (w : wrld σ) : wrld σ := {p | (◻p) ∈ w}\n\nnoncomputable def access : wrld σ → wrld σ → bool :=\nassume w v, if (unbox w ⊆ v) then tt else ff\n\nlemma subset_unbox_iff_access {w v : wrld σ} : access w v = tt ↔ unbox w ⊆ v :=\nby unfold access; simp \n\nlemma mem_unbox_iff_mem_box {p : form σ} {w : wrld σ} :\n  p ∈ unbox w ↔ (◻p) ∈ w :=\n⟨ id, id ⟩ \n\nlemma not_mem_unbox_of_mem_not_box {p : form σ} {w : wrld σ} (hc : w ∈ domain σ) :\n  (~◻p) ∈ w → p ∉ unbox w :=\nλ h np, (mem_domain_consist hc) (prf.mp (prf.ax h) (prf.ax (mem_unbox_iff_mem_box.1 np)))\n\nlemma mem_box_of_unbox_prf {p : form σ} {w : wrld σ} (H : w ∈ domain σ) :\n  (unbox w ⊢ₛ₅ p) → (◻p) ∈ w :=\nbegin\n  generalize eq : unbox w = Γ',\n  intro h, induction h; subst eq,\n    { assumption },\n    repeat { apply ctx.mem_max_of_prf H,\n      apply prf.nec,\n      apply prf.pl1 <|> apply prf.pl2 <|> apply prf.pl3 },\n    { apply ctx.mem_max_of_prf H,\n      refine prf.mp (prf.ax _) (prf.ax (h_ih_hp rfl)),\n      exact (ctx.mem_max_of_prf H) (prf.mp prf.k (prf.ax (h_ih_hpq rfl))) },\n    { apply ctx.mem_max_of_prf H,\n      exact prf.nec prf.k },\n    { apply ctx.mem_max_of_prf H,\n      exact prf.nec prf.t },\n    { apply ctx.mem_max_of_prf H,\n      exact prf.nec prf.s4 },\n    { apply ctx.mem_max_of_prf H,\n      exact prf.nec prf.b },\n    { apply ctx.mem_max_of_prf H,\n      apply prf.nec (prf.nec h_h) }\nend\n\nlemma not_unbox_prf_of_not_box_mem {p : form σ} {w : wrld σ} (hw : w ∈ domain σ) :\n  (~◻p) ∈ w → (unbox w ⊬ₛ₅ p) :=\nby { intros h nhp, apply mem_domain_consist hw, apply prf.mp (prf.ax h) (prf.ax (mem_box_of_unbox_prf hw nhp)) }\n\nlemma consist_unbox_of_not_box_mem {p : form σ} {w : wrld σ} (hw : w ∈ domain σ) :\n  (~◻p) ∈ w → is_consist (unbox w ⸴ (~p)) :=\nλ hn, consist_not_of_not_prf (not_unbox_prf_of_not_box_mem hw hn)\n\n-- valuation\n\nnoncomputable def val : fin σ → wrld σ → bool :=\nassume p w, if w ∈ domain σ ∧ (#p) ∈ w then tt else ff\n\n-- reflexivity\n\nlemma access.refl :\n  ∀ w ∈ domain σ, access w w = tt :=\nbegin\n  intros w h, unfold access,\n  simp, intros p hp, cases mem_domain_max h p,\n  { assumption },\n  { exfalso, apply mem_domain_consist h,\n    apply prf.mp,\n    { apply prf.ax h_1 }, \n    { apply prf.mp,\n      { apply prf.t },\n      { apply prf.ax,\n        apply mem_unbox_iff_mem_box.1,\n        assumption } } }\nend\n\n-- symmetry\n\nlemma access.symm : ∀ w ∈ domain σ, ∀ v ∈ domain σ, access w v = tt → access v w = tt :=\nbegin\n  intros w hw v hv, unfold access,\n  simp, intros sw p hp,\n  apply mem_domain_of_prf _ hw,\n  apply prf.mp,\n    { apply prf.sub_weak, apply prf.contrap_b, simp },\n    { have h₁ : ∀ p, p ∉ v → p ∉ unbox w, from \n      (λ p, (@not_imp_not _ _ (prop_decidable _)).2 (@sw _ ) ),\n      have h₂ : (◻~◻p) ∉ w, from \n      begin\n        apply h₁,\n        intro h, apply mem_domain_consist hv,\n        apply prf.mp,\n        { apply prf.ax h }, \n        { apply prf.ax, assumption }\n      end,\n      cases mem_domain_max hw (◻~◻p),\n      { contradiction },\n      { apply prf.ax, assumption } }\nend\n\n-- transitivity\n\nlemma access.trans : ∀ w ∈ domain σ, ∀ v ∈ domain σ, ∀ u ∈ domain σ,\n  access w v = tt → access v u = tt → access w u = tt :=\nbegin\n  intros w hw v hv u hu, unfold access,\n  simp, intros sw sv p hp,\n  apply sv, apply mem_unbox_iff_mem_box.2,\n  apply sw, apply mem_unbox_iff_mem_box.2,\n  apply mem_domain_of_prf, assumption,\n  apply prf.mp,\n  { exact prf.s4 },\n  { apply prf.ax,\n    apply mem_unbox_iff_mem_box.1,\n    assumption }\nend\n\nnoncomputable def model : @model σ :=\nbegin\n  fapply model.mk,\n    apply domain,\n    apply access,\n    apply val,\n    apply access.refl,\n    apply access.symm,\n    apply access.trans\nend\n\n/- truth is membership in the canonical model -/\n\nlemma form_tt_iff_mem_wrld {p : form σ} : \n  ∀ (w ∈ domain σ), (w ⊩⦃model⦄ p) = tt ↔ p ∈ w :=\nbegin\n  induction p with v p q hp hq p hp,\n  { intros, unfold forces_form model val, simp,\n    apply iff.intro,\n    { intro h, exact h.right },\n    { intro h, split, repeat {assumption} } },\n  \n  { unfold forces_form, simp,\n    intros w wm h, apply mem_domain_consist wm (prf.ax h) },\n\n  { unfold forces_form, simp, intros v wm, \n    apply iff.intro,\n    { intro h, cases h, \n      { cases mem_domain_max wm p with h₁ h₂,\n        { refine ctx.mem_max_of_prf wm _, \n          exact (prf.mp prf.pl1 (prf.ax ((hq _ wm).1 h))) },\n        { refine ctx.mem_max_of_prf wm _, \n          apply prf.mp prf.contrap (prf.mp prf.pl1 (prf.ax h₂)) } },\n      { cases mem_domain_max wm q with h₁ h₂,\n        { refine ctx.mem_max_of_prf wm _,\n          exact prf.mp prf.pl1 (prf.ax h₁) },\n        { refine ctx.mem_max_of_prf wm _,\n          refine prf.mp prf.contrap (prf.mp prf.pl1 _),\n          cases mem_domain_max wm p with hp₁ hp₂,\n          { exfalso, apply ff_eq_tt_eq_false,\n            transitivity, \n            { exact h.symm },\n            { exact (hp _ wm).2 hp₁} },\n          { apply prf.ax hp₂ } } } },\n      { intro h,\n        cases mem_domain_max wm q with h₁ h₂,\n        { left, exact (hq _ wm).2 h₁ },\n        { cases mem_domain_max wm p with hp₁ hp₂,\n          { exfalso, apply mem_domain_consist wm,\n            exact prf.mp (prf.ax h₂) (prf.mp (prf.ax h) (prf.ax hp₁)) },\n          { right, apply eq_ff_of_not_eq_tt,\n            intro ptt, apply mem_domain_consist wm,\n            exact prf.mp (prf.ax hp₂) (prf.ax ((hp _ wm).1 ptt)) } } } },\n  \n  { unfold forces_form,\n    simp, intros w wm,\n    apply iff.intro,\n    { intro h,\n      cases mem_domain_max wm (◻p) with h₁ h₂,\n      { exact h₁ },\n        exfalso, apply ctx.is_consist_max (consist_unbox_of_not_box_mem wm h₂),\n        apply prf.mp,\n        { apply prf.ax (ctx.subset_max_self (mem_insert _ _)) },\n        { apply prf.ax, \n          apply (hp _ (mem_domain (consist_unbox_of_not_box_mem wm h₂))).1,\n          apply h, apply mem_domain (consist_unbox_of_not_box_mem wm h₂), exact wm,\n          apply subset_unbox_iff_access.2,\n          intros p pm, apply ctx.subset_max_self,\n          apply mem_insert_of_mem _ pm } },\n      \n    { intro h,\n      intros w v, unfold model access, simp, \n      intros wm' rwv, \n      exact (hp _ v).2 (rwv (mem_unbox_iff_mem_box.2 h)) } }\nend\n\nlemma ctx_tt_of_mem_domain (Γ : ctx σ) (wm : Γ ∈ domain σ) : \n  (Γ ⊩⦃model⦄ Γ) = tt :=\nmem_tt_to_ctx_tt Γ (λ p pm, (form_tt_iff_mem_wrld _ wm).2 pm)\n\n/- the completeness lemma -/\n\ntheorem completeness {Γ : ctx σ} {p : form σ} : \n  (Γ ⊨ₛ₅ p) → (Γ ⊢ₛ₅ p) :=\nbegin\n  apply (@not_imp_not (Γ ⊢ₛ₅ p) (Γ ⊨ₛ₅ p) (prop_decidable _)).1,\n  intros nhp hp, cases hp,\n  have c : is_consist (Γ ⸴ ~p) := consist_not_of_not_prf nhp,\n  apply absurd,\n  fapply hp,\n    { exact model },\n    { exact ctx.max (Γ ⸴ ~p) },\n    { apply mem_domain c },\n\n    { apply cons_ctx_tt_to_ctx_tt,\n      apply ctx_tt_to_subctx_tt,\n      apply ctx_tt_of_mem_domain (ctx.max (Γ ⸴ ~p)),\n      apply mem_domain c,\n      apply ctx.subset_max_self },\n\n    { simp, apply eq_ff_of_not_eq_tt,\n      apply neg_tt_iff_ff.1, \n      apply and.elim_right,\n      apply cons_ctx_tt_iff_and.1, \n      apply ctx_tt_to_subctx_tt,\n      apply ctx_tt_of_mem_domain (ctx.max (Γ ⸴ ~p)),\n      apply mem_domain c,\n      apply ctx.subset_max_self },\nend\n\nend canonical", "meta": {"author": "bbentzen", "repo": "mpl", "sha": "bb5066ec51fa11a4b66f440c4f6c9a3d8fb2e0de", "save_path": "github-repos/lean/bbentzen-mpl", "path": "github-repos/lean/bbentzen-mpl/mpl-bb5066ec51fa11a4b66f440c4f6c9a3d8fb2e0de/src/s5/completeness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.49814609795740805}}
{"text": "import tactic\n\n@[derive fintype] inductive bool2\n| ff2 : bool2\n| tt2 : bool2\n\nnamespace bool2\n\ndefinition and2 : bool2 → bool2 → bool2\n| ff2 P := ff2\n| tt2 P := P\n\ndefinition or2 : bool2 → bool2 → bool2\n| tt2 P := tt2\n| ff2 P := P\n\ndefinition not2 : bool2 → bool2\n| tt2 := ff2\n| ff2 := tt2\n\ndefinition xor2 (x y : bool2) := and2 (or2 x y) (not2 (and2 x y))\n\ndefinition going : bool2 → bool\n| ff2 := tt\n| tt2 := ff\n\nend bool2\n\nopen bool2\n\ndefinition bool.to2 : bool → bool2\n| tt := ff2\n| ff := tt2\n\nnamespace bool2\n\n-- no good -- false and true name clash\n\n-- `bool2.F`, standing for \"From `bool` (to `bool2` in this case)\".\n\n-- `bool2.T`, standing for \"To `bool` (from `bool2` in this case)\"\n-- So anything we can do in `bool` about `bool2` \n\n-- These functions bijectively identify `bool` and `bool2`.\n\nopen bool\n\ndefinition equiv : bool2 ≃ bool :=\n{ to_fun := going,\n  inv_fun := to2,\n  left_inv := begin\n    intro x,\n    cases x;\n    refl,\n  end,\n  right_inv := begin\n    rintro (ht | hf);\n    refl\n  end\n   }\nend bool2\n\n-- every definition involving bool has a corresponding definition\n-- in bool2\n\n-- What construction in `bool2` corresponds to `and` in `bool`?\n\nexample (x y : bool) : (x && y).to2 = or2 x.to2 y.to2 :=\nbegin\n  cases x;\n  cases y;\n  refl,\nend\n\nexample (x y : bool) : (x || y).to2 = and2 x.to2 y.to2 :=\nbegin\n  cases x;\n  cases y;\n  refl,\nend\n\nexample (x y : bool) : (bxor x y).to2 = not2 (xor2 x.to2 y.to2) :=\nbegin\n  cases x;\n  cases y;\n  refl,\n--  sorry,sorry,sorry,sorry,\nend\n\n#print prefix bool\nexample (x : bool) : (bnot x).to2 = not2 (x.to2) :=\nbegin\n  cases x;\n  refl\nend\n\ndef bimp : bool → bool → bool\n| ff tt := ff\n| _  _  := tt\n\n-- corresponds to something awful\n\n-- Computer scientists don't want to reason about bool\n-- or prove theorems about it -- they just need it\n-- to make data structures, recording yes-no answers\n-- to questions about the terms involved.\n\nexample (b : bool) : b = ff ∨ b = tt := bool.dichotomy b\n\n-- I can'y do this -- ask Chris?\nexample : ∀ f : bool → bool → bool, \n  (∀ x y : bool, f x y = f y x) → \n  (f = bor ∨ f = band ∨ f = bxor ∨ f = λ x y, bnot (band x y) \n  ∨ f = λ x y, bnot (bor x y) ∨ f = λ x y, bnot (bxor x y) ∨ f = λ x y, tt ∨ f = λ x y, ff) :=\nbegin\n  intros,\n  rw function.funext_iff,\n  rw function.funext_iff,\n  rw function.funext_iff,\n  rw function.funext_iff,\n  cases (f tt tt).dichotomy;\n  cases (f tt ff).dichotomy;\n  cases (f ff tt).dichotomy;\n  cases (f ff ff).dichotomy,\n\n  { \n    sorry },\n  repeat {sorry},\n  \n--  exact dec_trivial,\nend\n\n-- now let's see forall and exists\nvariables (Ω : Type) (X Y : set Ω)\n\nexample : ¬ (∃ a, X a) ↔ ∀ b, ¬ (X b) :=\nbegin\n  split,\n  { intro h,\n    intros b hb,\n    apply h,\n    use b,\n    assumption },\n  { intro h,\n    intro h2,\n    cases h2 with a ha,\n    apply h a,\n    assumption },\nend\nexample : ¬ (∀ a, X a) ↔ ∃ b, ¬ (X b) :=\nbegin\n  split,\n  { -- classical\n    intro h,\n    classical,\n    by_contra hnX,\n    apply h,\n    intro a,\n    by_contra hXa,\n    apply hnX,\n    use a }, \n  { intro h,\n    cases h with b hb,\n    intro h,\n    apply hb,\n    apply h }\nend\n\nexample : ¬ (∃ a, X a) ↔ ∀ b, ¬ (X b) :=\nbegin\n  split,\n  { intro h,\n    intros b hb,\n    apply h,\n    use b,\n    assumption },\n  { intro h,\n    intro h2,\n    cases h2 with a ha,\n    apply h a,\n    assumption },\nend\n\n", "meta": {"author": "ImperialCollegeLondon", "repo": "M40001_lean", "sha": "62a76fa92654c855af2b2fc2bef8e60acd16ccec", "save_path": "github-repos/lean/ImperialCollegeLondon-M40001_lean", "path": "github-repos/lean/ImperialCollegeLondon-M40001_lean/M40001_lean-62a76fa92654c855af2b2fc2bef8e60acd16ccec/src/2020/logic/bool_not.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.4981460857272879}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport data.polynomial.expand\nimport linear_algebra.finite_dimensional\nimport linear_algebra.matrix.charpoly.linear_map\nimport ring_theory.adjoin.fg\nimport ring_theory.finite_type\nimport ring_theory.polynomial.scale_roots\nimport ring_theory.polynomial.tower\nimport ring_theory.tensor_product\n\n/-!\n# Integral closure of a subring.\n\nIf A is an R-algebra then `a : A` is integral over R if it is a root of a monic polynomial\nwith coefficients in R. Enough theory is developed to prove that integral elements\nform a sub-R-algebra of A.\n\n## Main definitions\n\nLet `R` be a `comm_ring` and let `A` be an R-algebra.\n\n* `ring_hom.is_integral_elem (f : R →+* A) (x : A)` : `x` is integral with respect to the map `f`,\n\n* `is_integral (x : A)`  : `x` is integral over `R`, i.e., is a root of a monic polynomial with\n                           coefficients in `R`.\n* `integral_closure R A` : the integral closure of `R` in `A`, regarded as a sub-`R`-algebra of `A`.\n-/\n\nopen_locale classical\nopen_locale big_operators polynomial\nopen polynomial submodule\n\nsection ring\nvariables {R S A : Type*}\nvariables [comm_ring R] [ring A] [ring S] (f : R →+* S)\n\n/-- An element `x` of `A` is said to be integral over `R` with respect to `f`\nif it is a root of a monic polynomial `p : R[X]` evaluated under `f` -/\ndef ring_hom.is_integral_elem (f : R →+* A) (x : A) :=\n∃ p : R[X], monic p ∧ eval₂ f x p = 0\n\n/-- A ring homomorphism `f : R →+* A` is said to be integral\nif every element `A` is integral with respect to the map `f` -/\ndef ring_hom.is_integral (f : R →+* A) :=\n∀ x : A, f.is_integral_elem x\n\nvariables [algebra R A] (R)\n\n/-- An element `x` of an algebra `A` over a commutative ring `R` is said to be *integral*,\nif it is a root of some monic polynomial `p : R[X]`.\nEquivalently, the element is integral over `R` with respect to the induced `algebra_map` -/\ndef is_integral (x : A) : Prop :=\n(algebra_map R A).is_integral_elem x\n\nvariable (A)\n\n/-- An algebra is integral if every element of the extension is integral over the base ring -/\nprotected def algebra.is_integral : Prop :=\n(algebra_map R A).is_integral\n\nvariables {R A}\n\nlemma ring_hom.is_integral_map {x : R} : f.is_integral_elem (f x) :=\n⟨X - C x, monic_X_sub_C _, by simp⟩\n\ntheorem is_integral_algebra_map {x : R} : is_integral R (algebra_map R A x) :=\n(algebra_map R A).is_integral_map\n\ntheorem is_integral_of_noetherian (H : is_noetherian R A) (x : A) :\n  is_integral R x :=\nbegin\n  let leval : (R[X] →ₗ[R] A) := (aeval x).to_linear_map,\n  let D : ℕ → submodule R A := λ n, (degree_le R n).map leval,\n  let M := well_founded.min (is_noetherian_iff_well_founded.1 H)\n    (set.range D) ⟨_, ⟨0, rfl⟩⟩,\n  have HM : M ∈ set.range D := well_founded.min_mem _ _ _,\n  cases HM with N HN,\n  have HM : ¬M < D (N+1) := well_founded.not_lt_min\n    (is_noetherian_iff_well_founded.1 H) (set.range D) _ ⟨N+1, rfl⟩,\n  rw ← HN at HM,\n  have HN2 : D (N+1) ≤ D N := classical.by_contradiction (λ H, HM\n    (lt_of_le_not_le (map_mono (degree_le_mono\n      (with_bot.coe_le_coe.2 (nat.le_succ N)))) H)),\n  have HN3 : leval (X^(N+1)) ∈ D N,\n  { exact HN2 (mem_map_of_mem (mem_degree_le.2 (degree_X_pow_le _))) },\n  rcases HN3 with ⟨p, hdp, hpe⟩,\n  refine ⟨X^(N+1) - p, monic_X_pow_sub (mem_degree_le.1 hdp), _⟩,\n  show leval (X ^ (N + 1) - p) = 0,\n  rw [linear_map.map_sub, hpe, sub_self]\nend\n\ntheorem is_integral_of_submodule_noetherian (S : subalgebra R A)\n  (H : is_noetherian R S.to_submodule) (x : A) (hx : x ∈ S) :\n  is_integral R x :=\nbegin\n  suffices : is_integral R (show S, from ⟨x, hx⟩),\n  { rcases this with ⟨p, hpm, hpx⟩,\n    replace hpx := congr_arg S.val hpx,\n    refine ⟨p, hpm, eq.trans _ hpx⟩,\n    simp only [aeval_def, eval₂, sum_def],\n    rw S.val.map_sum,\n    refine finset.sum_congr rfl (λ n hn, _),\n    rw [S.val.map_mul, S.val.map_pow, S.val.commutes, S.val_apply, subtype.coe_mk], },\n  refine is_integral_of_noetherian H ⟨x, hx⟩\nend\n\nend ring\n\nsection\nvariables {R A B S : Type*}\nvariables [comm_ring R] [comm_ring A] [comm_ring B] [comm_ring S]\nvariables [algebra R A] [algebra R B] (f : R →+* S)\n\nlemma map_is_integral {B C F : Type*} [ring B] [ring C] [algebra R B] [algebra A B]\n  [algebra R C] [is_scalar_tower R A B] [algebra A C] [is_scalar_tower R A C] {b : B}\n  [alg_hom_class F A B C] (f : F) (hb : is_integral R b) : is_integral R (f b) :=\nbegin\n  obtain ⟨P, hP⟩ := hb,\n  refine ⟨P, hP.1, _⟩,\n  rw [← aeval_def, show (aeval (f b)) P = (aeval (f b)) (P.map (algebra_map R A)), by simp,\n    aeval_alg_hom_apply, aeval_map_algebra_map, aeval_def, hP.2, _root_.map_zero]\nend\n\nlemma is_integral_map_of_comp_eq_of_is_integral {R S T U : Type*} [comm_ring R] [comm_ring S]\n  [comm_ring T] [comm_ring U] [algebra R S] [algebra T U] (φ : R →+* T) (ψ : S →+* U)\n  (h : (algebra_map T U).comp φ = ψ.comp (algebra_map R S)) {a : S} (ha : is_integral R a) :\n  is_integral T (ψ a) :=\nbegin\n  rw [is_integral, ring_hom.is_integral_elem] at ⊢ ha,\n  obtain ⟨p, hp⟩ := ha,\n  refine ⟨p.map φ, hp.left.map _, _⟩,\n  rw [← eval_map, map_map, h, ← map_map, eval_map, eval₂_at_apply,\n    eval_map, hp.right, ring_hom.map_zero],\nend\n\ntheorem is_integral_alg_hom_iff {A B : Type*} [ring A] [ring B] [algebra R A] [algebra R B]\n  (f : A →ₐ[R] B) (hf : function.injective f) {x : A} : is_integral R (f x) ↔ is_integral R x :=\nbegin\n  refine ⟨_, map_is_integral f⟩,\n  rintros ⟨p, hp, hx⟩,\n  use [p, hp],\n  rwa [← f.comp_algebra_map, ← alg_hom.coe_to_ring_hom, ← polynomial.hom_eval₂,\n    alg_hom.coe_to_ring_hom, map_eq_zero_iff f hf] at hx\nend\n\n@[simp]\ntheorem is_integral_alg_equiv {A B : Type*} [ring A] [ring B] [algebra R A] [algebra R B]\n  (f : A ≃ₐ[R] B) {x : A} : is_integral R (f x) ↔ is_integral R x :=\n⟨λ h, by simpa using map_is_integral f.symm.to_alg_hom h, map_is_integral f.to_alg_hom⟩\n\ntheorem is_integral_of_is_scalar_tower [algebra A B] [is_scalar_tower R A B]\n  {x : B} (hx : is_integral R x) : is_integral A x :=\nlet ⟨p, hp, hpx⟩ := hx in\n⟨p.map $ algebra_map R A, hp.map _,\n  by rw [← aeval_def, aeval_map_algebra_map, aeval_def, hpx]⟩\n\nlemma map_is_integral_int {B C F : Type*} [ring B] [ring C] {b : B}\n  [ring_hom_class F B C] (f : F) (hb : is_integral ℤ b) :\n  is_integral ℤ (f b) :=\nmap_is_integral (f : B →+* C).to_int_alg_hom hb\n\ntheorem is_integral_of_subring {x : A} (T : subring R)\n  (hx : is_integral T x) : is_integral R x :=\nis_integral_of_is_scalar_tower hx\n\nlemma is_integral.algebra_map [algebra A B] [is_scalar_tower R A B]\n  {x : A} (h : is_integral R x) :\n  is_integral R (algebra_map A B x) :=\nbegin\n  rcases h with ⟨f, hf, hx⟩,\n  use [f, hf],\n  rw [is_scalar_tower.algebra_map_eq R A B, ← hom_eval₂, hx, ring_hom.map_zero]\nend\n\nlemma is_integral_algebra_map_iff [algebra A B] [is_scalar_tower R A B]\n  {x : A} (hAB : function.injective (algebra_map A B)) :\n  is_integral R (algebra_map A B x) ↔ is_integral R x :=\nis_integral_alg_hom_iff (is_scalar_tower.to_alg_hom R A B) hAB\n\ntheorem is_integral_iff_is_integral_closure_finite {r : A} :\n  is_integral R r ↔ ∃ s : set R, s.finite ∧ is_integral (subring.closure s) r :=\nbegin\n  split; intro hr,\n  { rcases hr with ⟨p, hmp, hpr⟩,\n    refine ⟨_, finset.finite_to_set _, p.restriction, monic_restriction.2 hmp, _⟩,\n    rw [← aeval_def, ← aeval_map_algebra_map R r p.restriction,\n      map_restriction, aeval_def, hpr], },\n  rcases hr with ⟨s, hs, hsr⟩,\n  exact is_integral_of_subring _ hsr\nend\n\ntheorem fg_adjoin_singleton_of_integral (x : A) (hx : is_integral R x) :\n  (algebra.adjoin R ({x} : set A)).to_submodule.fg :=\nbegin\n  rcases hx with ⟨f, hfm, hfx⟩,\n  existsi finset.image ((^) x) (finset.range (nat_degree f + 1)),\n  apply le_antisymm,\n  { rw span_le, intros s hs, rw finset.mem_coe at hs,\n    rcases finset.mem_image.1 hs with ⟨k, hk, rfl⟩, clear hk,\n    exact (algebra.adjoin R {x}).pow_mem (algebra.subset_adjoin (set.mem_singleton _)) k },\n  intros r hr, change r ∈ algebra.adjoin R ({x} : set A) at hr,\n  rw algebra.adjoin_singleton_eq_range_aeval at hr,\n  rcases (aeval x).mem_range.mp hr with ⟨p, rfl⟩,\n  rw ← mod_by_monic_add_div p hfm,\n  rw ← aeval_def at hfx,\n  rw [alg_hom.map_add, alg_hom.map_mul, hfx, zero_mul, add_zero],\n  have : degree (p %ₘ f) ≤ degree f := degree_mod_by_monic_le p hfm,\n  generalize_hyp : p %ₘ f = q at this ⊢,\n  rw [← sum_C_mul_X_pow_eq q, aeval_def, eval₂_sum, sum_def],\n  refine sum_mem (λ k hkq, _),\n  rw [eval₂_mul, eval₂_C, eval₂_pow, eval₂_X, ← algebra.smul_def],\n  refine smul_mem _ _ (subset_span _),\n  rw finset.mem_coe, refine finset.mem_image.2 ⟨_, _, rfl⟩,\n  rw [finset.mem_range, nat.lt_succ_iff], refine le_of_not_lt (λ hk, _),\n  rw [degree_le_iff_coeff_zero] at this,\n  rw [mem_support_iff] at hkq, apply hkq, apply this,\n  exact lt_of_le_of_lt degree_le_nat_degree (with_bot.coe_lt_coe.2 hk)\nend\n\ntheorem fg_adjoin_of_finite {s : set A} (hfs : s.finite)\n  (his : ∀ x ∈ s, is_integral R x) : (algebra.adjoin R s).to_submodule.fg :=\nset.finite.induction_on hfs (λ _, ⟨{1}, submodule.ext $ λ x,\n  by { erw [algebra.adjoin_empty, finset.coe_singleton, ← one_eq_span, one_eq_range,\n            linear_map.mem_range, algebra.mem_bot], refl }⟩)\n(λ a s has hs ih his, by rw [← set.union_singleton, algebra.adjoin_union_coe_submodule]; exact\n  fg.mul (ih $ λ i hi, his i $ set.mem_insert_of_mem a hi)\n    (fg_adjoin_singleton_of_integral _ $ his a $ set.mem_insert a s)) his\n\nlemma is_noetherian_adjoin_finset [is_noetherian_ring R] (s : finset A)\n  (hs : ∀ x ∈ s, is_integral R x) :\n  is_noetherian R (algebra.adjoin R (↑s : set A)) :=\nis_noetherian_of_fg_of_noetherian _ (fg_adjoin_of_finite s.finite_to_set hs)\n\n/-- If `S` is a sub-`R`-algebra of `A` and `S` is finitely-generated as an `R`-module,\n  then all elements of `S` are integral over `R`. -/\ntheorem is_integral_of_mem_of_fg (S : subalgebra R A)\n  (HS : S.to_submodule.fg) (x : A) (hx : x ∈ S) : is_integral R x :=\nbegin\n  -- say `x ∈ S`. We want to prove that `x` is integral over `R`.\n  -- Say `S` is generated as an `R`-module by the set `y`.\n  cases HS with y hy,\n  -- We can write `x` as `∑ rᵢ yᵢ` for `yᵢ ∈ Y`.\n  obtain ⟨lx, hlx1, hlx2⟩ :\n    ∃ (l : A →₀ R) (H : l ∈ finsupp.supported R R ↑y), (finsupp.total A A R id) l = x,\n  { rwa [←(@finsupp.mem_span_image_iff_total A A R _ _ _ id ↑y x), set.image_id ↑y, hy] },\n  -- Note that `y ⊆ S`.\n  have hyS : ∀ {p}, p ∈ y → p ∈ S := λ p hp, show p ∈ S.to_submodule,\n    by { rw ← hy, exact subset_span hp },\n  -- Now `S` is a subalgebra so the product of two elements of `y` is also in `S`.\n  have : ∀ (jk : (↑(y ×ˢ y) : set (A × A))), jk.1.1 * jk.1.2 ∈ S.to_submodule :=\n    λ jk, S.mul_mem (hyS (finset.mem_product.1 jk.2).1) (hyS (finset.mem_product.1 jk.2).2),\n  rw [← hy, ← set.image_id ↑y] at this, simp only [finsupp.mem_span_image_iff_total] at this,\n  -- Say `yᵢyⱼ = ∑rᵢⱼₖ yₖ`\n  choose ly hly1 hly2,\n  -- Now let `S₀` be the subring of `R` generated by the `rᵢ` and the `rᵢⱼₖ`.\n  let S₀ : subring R :=\n    subring.closure ↑(lx.frange ∪ finset.bUnion finset.univ (finsupp.frange ∘ ly)),\n  -- It suffices to prove that `x` is integral over `S₀`.\n  refine is_integral_of_subring S₀ _,\n  letI : comm_ring S₀ := subring_class.to_comm_ring S₀,\n  letI : algebra S₀ A := algebra.of_subring S₀,\n  -- Claim: the `S₀`-module span (in `A`) of the set `y ∪ {1}` is closed under\n  -- multiplication (indeed, this is the motivation for the definition of `S₀`).\n  have :\n    span S₀ (insert 1 ↑y : set A) * span S₀ (insert 1 ↑y : set A) ≤ span S₀ (insert 1 ↑y : set A),\n  { rw span_mul_span, refine span_le.2 (λ z hz, _),\n    rcases set.mem_mul.1 hz with ⟨p, q, rfl | hp, hq, rfl⟩,\n    { rw one_mul, exact subset_span hq },\n    rcases hq with rfl | hq,\n    { rw mul_one, exact subset_span (or.inr hp) },\n    erw ← hly2 ⟨(p, q), finset.mem_product.2 ⟨hp, hq⟩⟩,\n    rw [finsupp.total_apply, finsupp.sum],\n    refine (span S₀ (insert 1 ↑y : set A)).sum_mem (λ t ht, _),\n    have : ly ⟨(p, q), finset.mem_product.2 ⟨hp, hq⟩⟩ t ∈ S₀ :=\n    subring.subset_closure (finset.mem_union_right _ $ finset.mem_bUnion.2\n      ⟨⟨(p, q), finset.mem_product.2 ⟨hp, hq⟩⟩, finset.mem_univ _,\n        finsupp.mem_frange.2 ⟨finsupp.mem_support_iff.1 ht, _, rfl⟩⟩),\n    change (⟨_, this⟩ : S₀) • t ∈ _, exact smul_mem _ _ (subset_span $ or.inr $ hly1 _ ht) },\n  -- Hence this span is a subring. Call this subring `S₁`.\n  let S₁ : subring A :=\n  { carrier := span S₀ (insert 1 ↑y : set A),\n    one_mem' := subset_span $ or.inl rfl,\n    mul_mem' := λ p q hp hq, this $ mul_mem_mul hp hq,\n    zero_mem' := (span S₀ (insert 1 ↑y : set A)).zero_mem,\n    add_mem' := λ _ _, (span S₀ (insert 1 ↑y : set A)).add_mem,\n    neg_mem' := λ _, (span S₀ (insert 1 ↑y : set A)).neg_mem },\n  have : S₁ = subalgebra.to_subring (algebra.adjoin S₀ (↑y : set A)),\n  { ext z,\n    suffices : z ∈ span ↥S₀ (insert 1 ↑y : set A) ↔\n      z ∈ (algebra.adjoin ↥S₀ (y : set A)).to_submodule,\n    { simpa },\n    split; intro hz,\n    { exact (span_le.2\n        (set.insert_subset.2 ⟨(algebra.adjoin S₀ ↑y).one_mem, algebra.subset_adjoin⟩)) hz },\n    { rw [subalgebra.mem_to_submodule, algebra.mem_adjoin_iff] at hz,\n      suffices : subring.closure (set.range ⇑(algebra_map ↥S₀ A) ∪ ↑y) ≤ S₁,\n      { exact this hz },\n      refine subring.closure_le.2 (set.union_subset _ (λ t ht, subset_span $ or.inr ht)),\n      rw set.range_subset_iff,\n      intro y,\n      rw algebra.algebra_map_eq_smul_one,\n      exact smul_mem _ y (subset_span (or.inl rfl)) } },\n  have foo : ∀ z, z ∈ S₁ ↔ z ∈ algebra.adjoin ↥S₀ (y : set A),\n    simp [this],\n  haveI : is_noetherian_ring ↥S₀ := is_noetherian_subring_closure _ (finset.finite_to_set _),\n  refine is_integral_of_submodule_noetherian (algebra.adjoin S₀ ↑y)\n    (is_noetherian_of_fg_of_noetherian _ ⟨insert 1 y,\n      by { rw [finset.coe_insert], ext z, simp [S₁], convert foo z}⟩) _ _,\n  rw [← hlx2, finsupp.total_apply, finsupp.sum], refine subalgebra.sum_mem _ (λ r hr, _),\n  have : lx r ∈ S₀ :=\n    subring.subset_closure (finset.mem_union_left _ (finset.mem_image_of_mem _ hr)),\n  change (⟨_, this⟩ : S₀) • r ∈ _,\n  rw finsupp.mem_supported at hlx1,\n  exact subalgebra.smul_mem _ (algebra.subset_adjoin $ hlx1 hr) _\nend\n\nlemma module.End.is_integral {M : Type*} [add_comm_group M] [module R M] [module.finite R M] :\n  algebra.is_integral R (module.End R M) :=\nlinear_map.exists_monic_and_aeval_eq_zero R\n\n/-- Suppose `A` is an `R`-algebra, `M` is an `A`-module such that `a • m ≠ 0` for all non-zero `a`\nand `m`. If `x : A` fixes a nontrivial f.g. `R`-submodule `N` of `M`, then `x` is `R`-integral. -/\nlemma is_integral_of_smul_mem_submodule {M : Type*} [add_comm_group M] [module R M]\n  [module A M] [is_scalar_tower R A M] [no_zero_smul_divisors A M]\n  (N : submodule R M) (hN : N ≠ ⊥) (hN' : N.fg) (x : A)\n    (hx : ∀ n ∈ N, x • n ∈ N) : is_integral R x :=\nbegin\n  let A' : subalgebra R A :=\n  { carrier := { x | ∀ n ∈ N, x • n ∈ N },\n    mul_mem' := λ a b ha hb n hn, smul_smul a b n ▸ ha _ (hb _ hn),\n    one_mem' := λ n hn, (one_smul A n).symm ▸ hn,\n    add_mem' := λ a b ha hb n hn, (add_smul a b n).symm ▸ N.add_mem (ha _ hn) (hb _ hn),\n    zero_mem' := λ n hn, (zero_smul A n).symm ▸ N.zero_mem,\n    algebra_map_mem' := λ r n hn, (algebra_map_smul A r n).symm ▸ N.smul_mem r hn },\n  let f : A' →ₐ[R] module.End R N := alg_hom.of_linear_map\n    { to_fun := λ x, (distrib_mul_action.to_linear_map R M x).restrict x.prop,\n      map_add' := λ x y, linear_map.ext $ λ n, subtype.ext $ add_smul x y n,\n      map_smul' := λ r s, linear_map.ext $ λ n, subtype.ext $ smul_assoc r s n }\n      (linear_map.ext $ λ n, subtype.ext $ one_smul _ _)\n      (λ x y, linear_map.ext $ λ n, subtype.ext $ mul_smul x y n),\n  obtain ⟨a, ha₁, ha₂⟩ : ∃ a ∈ N, a ≠ (0 : M),\n  { by_contra h', push_neg at h', apply hN, rwa eq_bot_iff },\n  have : function.injective f,\n  { show function.injective f.to_linear_map,\n    rw [← linear_map.ker_eq_bot, eq_bot_iff],\n    intros s hs,\n    have : s.1 • a = 0 := congr_arg subtype.val (linear_map.congr_fun hs ⟨a, ha₁⟩),\n    exact subtype.ext ((eq_zero_or_eq_zero_of_smul_eq_zero this).resolve_right ha₂) },\n  show is_integral R (A'.val ⟨x, hx⟩),\n  rw [is_integral_alg_hom_iff A'.val subtype.val_injective,\n    ← is_integral_alg_hom_iff f this],\n  haveI : module.finite R N := by rwa [module.finite_def, submodule.fg_top],\n  apply module.End.is_integral,\nend\n\nvariables {f}\n\nlemma ring_hom.finite.to_is_integral (h : f.finite) : f.is_integral :=\nby { letI := f.to_algebra, exact λ x, is_integral_of_mem_of_fg ⊤ h.1 _ trivial }\n\nalias ring_hom.finite.to_is_integral ← ring_hom.is_integral.of_finite\n\nlemma ring_hom.is_integral.to_finite (h : f.is_integral) (h' : f.finite_type) : f.finite :=\nbegin\n  letI := f.to_algebra,\n  unfreezingI { obtain ⟨s, hs⟩ := h' },\n  constructor,\n  change (⊤ : subalgebra R S).to_submodule.fg,\n  rw ← hs,\n  exact fg_adjoin_of_finite (set.to_finite _) (λ x _, h x)\nend\n\nalias ring_hom.is_integral.to_finite ← ring_hom.finite.of_is_integral_of_finite_type\n\n/-- finite = integral + finite type -/\nlemma ring_hom.finite_iff_is_integral_and_finite_type :\n  f.finite ↔ f.is_integral ∧ f.finite_type :=\n⟨λ h, ⟨h.to_is_integral, h.to_finite_type⟩, λ ⟨h, h'⟩, h.to_finite h'⟩\n\nlemma algebra.is_integral.finite (h : algebra.is_integral R A) [h' : algebra.finite_type R A] :\n  module.finite R A :=\nbegin\n  have := h.to_finite\n    (by { delta ring_hom.finite_type, convert h', ext, exact (algebra.smul_def _ _).symm }),\n  delta ring_hom.finite at this, convert this, ext, exact algebra.smul_def _ _,\nend\n\nlemma algebra.is_integral.of_finite [h : module.finite R A] : algebra.is_integral R A :=\nbegin\n  apply ring_hom.finite.to_is_integral,\n  delta ring_hom.finite, convert h, ext, exact (algebra.smul_def _ _).symm,\nend\n\n/-- finite = integral + finite type -/\nlemma algebra.finite_iff_is_integral_and_finite_type :\n  module.finite R A ↔ algebra.is_integral R A ∧ algebra.finite_type R A :=\n⟨λ h, by exactI ⟨algebra.is_integral.of_finite, infer_instance⟩, λ ⟨h, h'⟩, by exactI h.finite⟩\n\nvariables (f)\n\nlemma ring_hom.is_integral_of_mem_closure {x y z : S}\n  (hx : f.is_integral_elem x) (hy : f.is_integral_elem y)\n  (hz : z ∈ subring.closure ({x, y} : set S)) :\n  f.is_integral_elem z :=\nbegin\n  letI : algebra R S := f.to_algebra,\n  have := (fg_adjoin_singleton_of_integral x hx).mul (fg_adjoin_singleton_of_integral y hy),\n  rw [← algebra.adjoin_union_coe_submodule, set.singleton_union] at this,\n  exact is_integral_of_mem_of_fg (algebra.adjoin R {x, y}) this z\n    (algebra.mem_adjoin_iff.2 $ subring.closure_mono (set.subset_union_right _ _) hz),\nend\n\ntheorem is_integral_of_mem_closure {x y z : A}\n  (hx : is_integral R x) (hy : is_integral R y)\n  (hz : z ∈ subring.closure ({x, y} : set A)) :\n  is_integral R z :=\n(algebra_map R A).is_integral_of_mem_closure hx hy hz\n\nlemma ring_hom.is_integral_zero : f.is_integral_elem 0 :=\nf.map_zero ▸ f.is_integral_map\n\ntheorem is_integral_zero : is_integral R (0:A) :=\n(algebra_map R A).is_integral_zero\n\nlemma ring_hom.is_integral_one : f.is_integral_elem 1 :=\nf.map_one ▸ f.is_integral_map\n\ntheorem is_integral_one : is_integral R (1:A) :=\n(algebra_map R A).is_integral_one\n\nlemma ring_hom.is_integral_add {x y : S}\n  (hx : f.is_integral_elem x) (hy : f.is_integral_elem y) :\n  f.is_integral_elem (x + y) :=\nf.is_integral_of_mem_closure hx hy $ subring.add_mem _\n  (subring.subset_closure (or.inl rfl)) (subring.subset_closure (or.inr rfl))\n\ntheorem is_integral_add {x y : A}\n  (hx : is_integral R x) (hy : is_integral R y) :\n  is_integral R (x + y) :=\n(algebra_map R A).is_integral_add hx hy\n\nlemma ring_hom.is_integral_neg {x : S}\n  (hx : f.is_integral_elem x) : f.is_integral_elem (-x) :=\nf.is_integral_of_mem_closure hx hx (subring.neg_mem _ (subring.subset_closure (or.inl rfl)))\n\ntheorem is_integral_neg {x : A}\n  (hx : is_integral R x) : is_integral R (-x) :=\n(algebra_map R A).is_integral_neg hx\n\nlemma ring_hom.is_integral_sub {x y : S}\n  (hx : f.is_integral_elem x) (hy : f.is_integral_elem y) : f.is_integral_elem (x - y) :=\nby simpa only [sub_eq_add_neg] using f.is_integral_add hx (f.is_integral_neg hy)\n\ntheorem is_integral_sub {x y : A}\n  (hx : is_integral R x) (hy : is_integral R y) : is_integral R (x - y) :=\n(algebra_map R A).is_integral_sub hx hy\n\nlemma ring_hom.is_integral_mul {x y : S}\n  (hx : f.is_integral_elem x) (hy : f.is_integral_elem y) : f.is_integral_elem (x * y) :=\nf.is_integral_of_mem_closure hx hy (subring.mul_mem _\n  (subring.subset_closure (or.inl rfl)) (subring.subset_closure (or.inr rfl)))\n\ntheorem is_integral_mul {x y : A}\n  (hx : is_integral R x) (hy : is_integral R y) : is_integral R (x * y) :=\n(algebra_map R A).is_integral_mul hx hy\n\nlemma is_integral_smul [algebra S A] [algebra R S] [is_scalar_tower R S A] {x : A} (r : R)\n  (hx : is_integral S x) : is_integral S (r • x) :=\nbegin\n  rw [algebra.smul_def, is_scalar_tower.algebra_map_apply R S A],\n  exact is_integral_mul is_integral_algebra_map hx,\nend\n\nlemma is_integral_of_pow {x : A} {n : ℕ} (hn : 0 < n) (hx : is_integral R $ x ^ n) :\n  is_integral R x :=\nbegin\n  rcases hx with ⟨p, ⟨hmonic, heval⟩⟩,\n  exact ⟨expand R n p, monic.expand hn hmonic,\n         by rwa [eval₂_eq_eval_map, map_expand, expand_eval, ← eval₂_eq_eval_map]⟩\nend\n\nvariables (R A)\n\n/-- The integral closure of R in an R-algebra A. -/\ndef integral_closure : subalgebra R A :=\n{ carrier := { r | is_integral R r },\n  zero_mem' := is_integral_zero,\n  one_mem' := is_integral_one,\n  add_mem' := λ _ _, is_integral_add,\n  mul_mem' := λ _ _, is_integral_mul,\n  algebra_map_mem' := λ x, is_integral_algebra_map }\n\ntheorem mem_integral_closure_iff_mem_fg {r : A} :\n  r ∈ integral_closure R A ↔ ∃ M : subalgebra R A, M.to_submodule.fg ∧ r ∈ M :=\n⟨λ hr, ⟨algebra.adjoin R {r}, fg_adjoin_singleton_of_integral _ hr, algebra.subset_adjoin rfl⟩,\nλ ⟨M, Hf, hrM⟩, is_integral_of_mem_of_fg M Hf _ hrM⟩\n\nvariables {R} {A}\n\nlemma adjoin_le_integral_closure {x : A} (hx : is_integral R x) :\n  algebra.adjoin R {x} ≤ integral_closure R A :=\nbegin\n  rw [algebra.adjoin_le_iff],\n  simp only [set_like.mem_coe, set.singleton_subset_iff],\n  exact hx\nend\n\nlemma le_integral_closure_iff_is_integral {S : subalgebra R A} :\n  S ≤ integral_closure R A ↔ algebra.is_integral R S :=\nset_like.forall.symm.trans (forall_congr (λ x, show is_integral R (algebra_map S A x)\n  ↔ is_integral R x, from is_integral_algebra_map_iff subtype.coe_injective))\n\nlemma is_integral_sup {S T : subalgebra R A} :\n  algebra.is_integral R ↥(S ⊔ T) ↔ algebra.is_integral R S ∧ algebra.is_integral R T :=\nby simp only [←le_integral_closure_iff_is_integral, sup_le_iff]\n\n/-- Mapping an integral closure along an `alg_equiv` gives the integral closure. -/\nlemma integral_closure_map_alg_equiv (f : A ≃ₐ[R] B) :\n  (integral_closure R A).map (f : A →ₐ[R] B) = integral_closure R B :=\nbegin\n  ext y,\n  rw subalgebra.mem_map,\n  split,\n  { rintros ⟨x, hx, rfl⟩,\n    exact map_is_integral f hx },\n  { intro hy,\n    use [f.symm y, map_is_integral (f.symm : B →ₐ[R] A) hy],\n    simp }\nend\n\nlemma integral_closure.is_integral (x : integral_closure R A) : is_integral R x :=\nlet ⟨p, hpm, hpx⟩ := x.2 in ⟨p, hpm, subtype.eq $\nby rwa [← aeval_def, subtype.val_eq_coe, ← subalgebra.val_apply, aeval_alg_hom_apply] at hpx⟩\n\nlemma ring_hom.is_integral_of_is_integral_mul_unit (x y : S) (r : R) (hr : f r * y = 1)\n  (hx : f.is_integral_elem (x * y)) : f.is_integral_elem x :=\nbegin\n  obtain ⟨p, ⟨p_monic, hp⟩⟩ := hx,\n  refine ⟨scale_roots p r, ⟨(monic_scale_roots_iff r).2 p_monic, _⟩⟩,\n  convert scale_roots_eval₂_eq_zero f hp,\n  rw [mul_comm x y, ← mul_assoc, hr, one_mul],\nend\n\ntheorem is_integral_of_is_integral_mul_unit {x y : A} {r : R} (hr : algebra_map R A r * y = 1)\n  (hx : is_integral R (x * y)) : is_integral R x :=\n(algebra_map R A).is_integral_of_is_integral_mul_unit x y r hr hx\n\n/-- Generalization of `is_integral_of_mem_closure` bootstrapped up from that lemma -/\nlemma is_integral_of_mem_closure' (G : set A) (hG : ∀ x ∈ G, is_integral R x) :\n  ∀ x ∈ (subring.closure G), is_integral R x :=\nλ x hx, subring.closure_induction hx hG is_integral_zero is_integral_one\n  (λ _ _, is_integral_add) (λ _, is_integral_neg) (λ _ _, is_integral_mul)\n\nlemma is_integral_of_mem_closure'' {S : Type*} [comm_ring S] {f : R →+* S} (G : set S)\n  (hG : ∀ x ∈ G, f.is_integral_elem x) : ∀ x ∈ (subring.closure G), f.is_integral_elem x :=\nλ x hx, @is_integral_of_mem_closure' R S _ _ f.to_algebra G hG x hx\n\nlemma is_integral.pow {x : A} (h : is_integral R x) (n : ℕ) : is_integral R (x ^ n) :=\n(integral_closure R A).pow_mem h n\n\nlemma is_integral.nsmul {x : A} (h : is_integral R x) (n : ℕ) : is_integral R (n • x) :=\n(integral_closure R A).nsmul_mem h n\n\nlemma is_integral.zsmul {x : A} (h : is_integral R x) (n : ℤ) : is_integral R (n • x) :=\n(integral_closure R A).zsmul_mem h n\n\nlemma is_integral.multiset_prod {s : multiset A} (h : ∀ x ∈ s, is_integral R x) :\n  is_integral R s.prod :=\n(integral_closure R A).multiset_prod_mem h\n\nlemma is_integral.multiset_sum {s : multiset A} (h : ∀ x ∈ s, is_integral R x) :\n  is_integral R s.sum :=\n(integral_closure R A).multiset_sum_mem h\n\nlemma is_integral.prod {α : Type*} {s : finset α} (f : α → A) (h : ∀ x ∈ s, is_integral R (f x)) :\n  is_integral R (∏ x in s, f x) :=\n(integral_closure R A).prod_mem h\n\nlemma is_integral.sum {α : Type*} {s : finset α} (f : α → A) (h : ∀ x ∈ s, is_integral R (f x)) :\n  is_integral R (∑ x in s, f x) :=\n(integral_closure R A).sum_mem h\n\nlemma is_integral.det {n : Type*} [fintype n] [decidable_eq n] {M : matrix n n A}\n  (h : ∀ i j, is_integral R (M i j)) :\n  is_integral R M.det :=\nbegin\n  rw [matrix.det_apply],\n  exact is_integral.sum _ (λ σ hσ, is_integral.zsmul (is_integral.prod _ (λ i hi, h _ _)) _)\nend\n\n@[simp] lemma is_integral.pow_iff {x : A} {n : ℕ} (hn : 0 < n) :\n  is_integral R (x ^ n) ↔ is_integral R x :=\n⟨is_integral_of_pow hn, λ hx, is_integral.pow hx n⟩\n\nopen_locale tensor_product\n\nlemma is_integral.tmul (x : A) {y : B} (h : is_integral R y) : is_integral A (x ⊗ₜ[R] y) :=\nbegin\n  obtain ⟨p, hp, hp'⟩ := h,\n  refine ⟨(p.map (algebra_map R A)).scale_roots x, _, _⟩,\n  { rw polynomial.monic_scale_roots_iff, exact hp.map _ },\n  convert @polynomial.scale_roots_eval₂_mul (A ⊗[R] B) A _ _ _\n    algebra.tensor_product.include_left.to_ring_hom (1 ⊗ₜ y) x using 2,\n  { simp only [alg_hom.to_ring_hom_eq_coe, alg_hom.coe_to_ring_hom, mul_one, one_mul,\n      algebra.tensor_product.include_left_apply, algebra.tensor_product.tmul_mul_tmul] },\n  convert (mul_zero _).symm,\n  rw [polynomial.eval₂_map, algebra.tensor_product.include_left_comp_algebra_map,\n    ← polynomial.eval₂_map],\n  convert polynomial.eval₂_at_apply algebra.tensor_product.include_right.to_ring_hom y,\n  rw [polynomial.eval_map, hp', _root_.map_zero],\nend\n\nsection\n\nvariables (p : R[X]) (x : S)\n\n/--  The monic polynomial whose roots are `p.leading_coeff * x` for roots `x` of `p`. -/\nnoncomputable\ndef normalize_scale_roots (p : R[X]) : R[X] :=\n∑ i in p.support, monomial i\n  (if i = p.nat_degree then 1 else p.coeff i * p.leading_coeff ^ (p.nat_degree - 1 - i))\n\nlemma normalize_scale_roots_coeff_mul_leading_coeff_pow (i : ℕ) (hp : 1 ≤ nat_degree p) :\n  (normalize_scale_roots p).coeff i * p.leading_coeff ^ i =\n    p.coeff i * p.leading_coeff ^ (p.nat_degree - 1) :=\nbegin\n  simp only [normalize_scale_roots, finset_sum_coeff, coeff_monomial, finset.sum_ite_eq', one_mul,\n    zero_mul, mem_support_iff, ite_mul, ne.def, ite_not],\n  split_ifs with h₁ h₂,\n  { simp [h₁], },\n  { rw [h₂, leading_coeff, ← pow_succ, tsub_add_cancel_of_le hp], },\n  { rw [mul_assoc, ← pow_add, tsub_add_cancel_of_le],\n    apply nat.le_pred_of_lt,\n    rw lt_iff_le_and_ne,\n    exact ⟨le_nat_degree_of_ne_zero h₁, h₂⟩, },\nend\n\nlemma leading_coeff_smul_normalize_scale_roots (p : R[X]) :\n  p.leading_coeff • normalize_scale_roots p = scale_roots p p.leading_coeff :=\nbegin\n  ext,\n  simp only [coeff_scale_roots, normalize_scale_roots, coeff_monomial, coeff_smul, finset.smul_sum,\n    ne.def, finset.sum_ite_eq', finset_sum_coeff, smul_ite, smul_zero, mem_support_iff],\n  split_ifs with h₁ h₂,\n  { simp [*] },\n  { simp [*] },\n  { rw [algebra.id.smul_eq_mul, mul_comm, mul_assoc, ← pow_succ', tsub_right_comm,\n      tsub_add_cancel_of_le],\n    rw nat.succ_le_iff,\n    exact tsub_pos_of_lt (lt_of_le_of_ne (le_nat_degree_of_ne_zero h₁) h₂) },\nend\n\nlemma normalize_scale_roots_support :\n  (normalize_scale_roots p).support ≤ p.support :=\nbegin\n  intro x,\n  contrapose,\n  simp only [not_mem_support_iff, normalize_scale_roots, finset_sum_coeff, coeff_monomial,\n    finset.sum_ite_eq', mem_support_iff, ne.def, not_not, ite_eq_right_iff],\n  intros h₁ h₂,\n  exact (h₂ h₁).rec _,\nend\n\nlemma normalize_scale_roots_degree :\n  (normalize_scale_roots p).degree = p.degree :=\nbegin\n  apply le_antisymm,\n  { exact finset.sup_mono (normalize_scale_roots_support p) },\n  { rw [← degree_scale_roots, ← leading_coeff_smul_normalize_scale_roots],\n    exact degree_smul_le _ _ }\nend\n\nlemma normalize_scale_roots_eval₂_leading_coeff_mul (h : 1 ≤ p.nat_degree) (f : R →+* S) (x : S) :\n  (normalize_scale_roots p).eval₂ f (f p.leading_coeff * x) =\n    f p.leading_coeff ^ (p.nat_degree - 1) * (p.eval₂ f x) :=\nbegin\n  rw [eval₂_eq_sum_range, eval₂_eq_sum_range, finset.mul_sum],\n  apply finset.sum_congr,\n  { rw nat_degree_eq_of_degree_eq (normalize_scale_roots_degree p) },\n  intros n hn,\n  rw [mul_pow, ← mul_assoc, ← f.map_pow, ← f.map_mul,\n    normalize_scale_roots_coeff_mul_leading_coeff_pow _ _ h, f.map_mul, f.map_pow],\n  ring,\nend\n\nlemma normalize_scale_roots_monic (h : p ≠ 0) : (normalize_scale_roots p).monic :=\nbegin\n  delta monic leading_coeff,\n  rw nat_degree_eq_of_degree_eq (normalize_scale_roots_degree p),\n  suffices : p = 0 → (0 : R) = 1,\n  { simpa [normalize_scale_roots, coeff_monomial] },\n  exact λ h', (h h').rec _,\nend\n\n/-- Given a `p : R[X]` and a `x : S` such that `p.eval₂ f x = 0`,\n`f p.leading_coeff * x` is integral. -/\nlemma ring_hom.is_integral_elem_leading_coeff_mul (h : p.eval₂ f x = 0) :\n  f.is_integral_elem (f p.leading_coeff * x) :=\nbegin\n  by_cases h' : 1 ≤ p.nat_degree,\n  { use normalize_scale_roots p,\n    have : p ≠ 0 := λ h'', by { rw [h'', nat_degree_zero] at h', exact nat.not_succ_le_zero 0 h' },\n    use normalize_scale_roots_monic p this,\n    rw [normalize_scale_roots_eval₂_leading_coeff_mul p h' f x, h, mul_zero] },\n  { by_cases hp : p.map f = 0,\n    { apply_fun (λ q, coeff q p.nat_degree) at hp,\n      rw [coeff_map, coeff_zero, coeff_nat_degree] at hp,\n      rw [hp, zero_mul],\n      exact f.is_integral_zero },\n    { rw [nat.one_le_iff_ne_zero, not_not] at h',\n      rw [eq_C_of_nat_degree_eq_zero h', eval₂_C] at h,\n      suffices : p.map f = 0,\n      { exact (hp this).rec _ },\n      rw [eq_C_of_nat_degree_eq_zero h', map_C, h, C_eq_zero] } }\nend\n\n/-- Given a `p : R[X]` and a root `x : S`,\nthen `p.leading_coeff • x : S` is integral over `R`. -/\nlemma is_integral_leading_coeff_smul [algebra R S] (h : aeval x p = 0) :\n  is_integral R (p.leading_coeff • x) :=\nbegin\n  rw aeval_def at h,\n  rw algebra.smul_def,\n  exact (algebra_map R S).is_integral_elem_leading_coeff_mul p x h,\nend\n\nend\n\nend\n\nsection is_integral_closure\n\n/-- `is_integral_closure A R B` is the characteristic predicate stating `A` is\nthe integral closure of `R` in `B`,\ni.e. that an element of `B` is integral over `R` iff it is an element of (the image of) `A`.\n-/\nclass is_integral_closure (A R B : Type*) [comm_ring R] [comm_semiring A] [comm_ring B]\n  [algebra R B] [algebra A B] : Prop :=\n(algebra_map_injective [] : function.injective (algebra_map A B))\n(is_integral_iff : ∀ {x : B}, is_integral R x ↔ ∃ y, algebra_map A B y = x)\n\ninstance integral_closure.is_integral_closure (R A : Type*) [comm_ring R] [comm_ring A]\n  [algebra R A] : is_integral_closure (integral_closure R A) R A :=\n⟨subtype.coe_injective, λ x, ⟨λ h, ⟨⟨x, h⟩, rfl⟩, by { rintro ⟨⟨_, h⟩, rfl⟩, exact h }⟩⟩\n\nnamespace is_integral_closure\n\nvariables {R A B : Type*} [comm_ring R] [comm_ring A] [comm_ring B]\nvariables [algebra R B] [algebra A B] [is_integral_closure A R B]\n\nvariables (R) {A} (B)\nprotected theorem is_integral [algebra R A] [is_scalar_tower R A B] (x : A) : is_integral R x :=\n(is_integral_algebra_map_iff (algebra_map_injective A R B)).mp $\nshow is_integral R (algebra_map A B x), from is_integral_iff.mpr ⟨x, rfl⟩\n\ntheorem is_integral_algebra [algebra R A] [is_scalar_tower R A B] :\n  algebra.is_integral R A :=\nλ x, is_integral_closure.is_integral R B x\n\ntheorem no_zero_smul_divisors [algebra R A] [is_scalar_tower R A B] [no_zero_smul_divisors R B] :\n  no_zero_smul_divisors R A :=\nbegin\n  refine function.injective.no_zero_smul_divisors\n      _ (is_integral_closure.algebra_map_injective A R B) (map_zero _) (λ _ _, _),\n  simp only [algebra.algebra_map_eq_smul_one, is_scalar_tower.smul_assoc],\n end\n\nvariables {R} (A) {B}\n\n/-- If `x : B` is integral over `R`, then it is an element of the integral closure of `R` in `B`. -/\nnoncomputable def mk' (x : B) (hx : is_integral R x) : A :=\nclassical.some (is_integral_iff.mp hx)\n\n@[simp] lemma algebra_map_mk' (x : B) (hx : is_integral R x) :\n  algebra_map A B (mk' A x hx) = x :=\nclassical.some_spec (is_integral_iff.mp hx)\n\n@[simp] lemma mk'_one (h : is_integral R (1 : B) := is_integral_one) :\n  mk' A 1 h = 1 :=\nalgebra_map_injective A R B $ by rw [algebra_map_mk', ring_hom.map_one]\n\n@[simp] lemma mk'_zero (h : is_integral R (0 : B) := is_integral_zero) :\n  mk' A 0 h = 0 :=\nalgebra_map_injective A R B $ by rw [algebra_map_mk', ring_hom.map_zero]\n\n@[simp] \n\n@[simp] lemma mk'_mul (x y : B) (hx : is_integral R x) (hy : is_integral R y) :\n  mk' A (x * y) (is_integral_mul hx hy) = mk' A x hx * mk' A y hy :=\nalgebra_map_injective A R B $ by simp only [algebra_map_mk', ring_hom.map_mul]\n\n@[simp] lemma mk'_algebra_map [algebra R A] [is_scalar_tower R A B] (x : R)\n  (h : is_integral R (algebra_map R B x) := is_integral_algebra_map) :\n  is_integral_closure.mk' A (algebra_map R B x) h = algebra_map R A x :=\nalgebra_map_injective A R B $ by rw [algebra_map_mk', ← is_scalar_tower.algebra_map_apply]\n\nsection lift\n\nvariables {R} (A B) {S : Type*} [comm_ring S] [algebra R S] [algebra S B] [is_scalar_tower R S B]\nvariables [algebra R A] [is_scalar_tower R A B] (h : algebra.is_integral R S)\n\n/-- If `B / S / R` is a tower of ring extensions where `S` is integral over `R`,\nthen `S` maps (uniquely) into an integral closure `B / A / R`. -/\nnoncomputable def lift : S →ₐ[R] A :=\n{ to_fun := λ x, mk' A (algebra_map S B x) (is_integral.algebra_map (h x)),\n  map_one' := by simp only [ring_hom.map_one, mk'_one],\n  map_zero' := by simp only [ring_hom.map_zero, mk'_zero],\n  map_add' := λ x y, by simp_rw [← mk'_add, ring_hom.map_add],\n  map_mul' := λ x y, by simp_rw [← mk'_mul, ring_hom.map_mul],\n  commutes' := λ x, by simp_rw [← is_scalar_tower.algebra_map_apply, mk'_algebra_map] }\n\n@[simp] lemma algebra_map_lift (x : S) : algebra_map A B (lift A B h x) = algebra_map S B x :=\nalgebra_map_mk' _ _ _\n\nend lift\n\nsection equiv\n\nvariables (R A B) (A' : Type*) [comm_ring A'] [algebra A' B] [is_integral_closure A' R B]\nvariables [algebra R A] [algebra R A'] [is_scalar_tower R A B] [is_scalar_tower R A' B]\n\n/-- Integral closures are all isomorphic to each other. -/\nnoncomputable def equiv : A ≃ₐ[R] A' :=\nalg_equiv.of_alg_hom (lift _ B (is_integral_algebra R B)) (lift _ B (is_integral_algebra R B))\n  (by { ext x, apply algebra_map_injective A' R B, simp })\n  (by { ext x, apply algebra_map_injective A R B, simp })\n\n@[simp] lemma algebra_map_equiv (x : A) : algebra_map A' B (equiv R A B A' x) = algebra_map A B x :=\nalgebra_map_lift _ _ _ _\n\nend equiv\n\nend is_integral_closure\n\nend is_integral_closure\n\nsection algebra\nopen algebra\nvariables {R A B S T : Type*}\nvariables [comm_ring R] [comm_ring A] [comm_ring B] [comm_ring S] [comm_ring T]\nvariables [algebra A B] [algebra R B] (f : R →+* S) (g : S →+* T)\n\nlemma is_integral_trans_aux (x : B) {p : A[X]} (pmonic : monic p) (hp : aeval x p = 0) :\n  is_integral (adjoin R (↑(p.map $ algebra_map A B).frange : set B)) x :=\nbegin\n  generalize hS : (↑(p.map $ algebra_map A B).frange : set B) = S,\n  have coeffs_mem : ∀ i, (p.map $ algebra_map A B).coeff i ∈ adjoin R S,\n  { intro i, by_cases hi : (p.map $ algebra_map A B).coeff i = 0,\n    { rw hi, exact subalgebra.zero_mem _ },\n    rw ← hS,\n    exact subset_adjoin (coeff_mem_frange _ _ hi) },\n  obtain ⟨q, hq⟩ : ∃ q : (adjoin R S)[X], q.map (algebra_map (adjoin R S) B) =\n      (p.map $ algebra_map A B),\n  { rw ← set.mem_range, exact (polynomial.mem_map_range _).2 (λ i, ⟨⟨_, coeffs_mem i⟩, rfl⟩) },\n  use q,\n  split,\n  { suffices h : (q.map (algebra_map (adjoin R S) B)).monic,\n    { refine monic_of_injective _ h,\n      exact subtype.val_injective },\n    { rw hq, exact pmonic.map _ } },\n  { convert hp using 1,\n    replace hq := congr_arg (eval x) hq,\n    convert hq using 1; symmetry; apply eval_map },\nend\n\nvariables [algebra R A] [is_scalar_tower R A B]\n\n/-- If A is an R-algebra all of whose elements are integral over R,\nand x is an element of an A-algebra that is integral over A, then x is integral over R.-/\nlemma is_integral_trans (A_int : algebra.is_integral R A) (x : B) (hx : is_integral A x) :\n  is_integral R x :=\nbegin\n  rcases hx with ⟨p, pmonic, hp⟩,\n  let S : set B := ↑(p.map $ algebra_map A B).frange,\n  refine is_integral_of_mem_of_fg (adjoin R (S ∪ {x})) _ _ (subset_adjoin $ or.inr rfl),\n  refine fg_trans (fg_adjoin_of_finite (finset.finite_to_set _) (λ x hx, _)) _,\n  { rw [finset.mem_coe, frange, finset.mem_image] at hx,\n    rcases hx with ⟨i, _, rfl⟩,\n    rw coeff_map,\n    exact map_is_integral (is_scalar_tower.to_alg_hom R A B) (A_int _) },\n  { apply fg_adjoin_singleton_of_integral,\n    exact is_integral_trans_aux _ pmonic hp }\nend\n\n/-- If A is an R-algebra all of whose elements are integral over R,\nand B is an A-algebra all of whose elements are integral over A,\nthen all elements of B are integral over R.-/\nlemma algebra.is_integral_trans (hA : algebra.is_integral R A) (hB : algebra.is_integral A B) :\n  algebra.is_integral R B :=\nλ x, is_integral_trans hA x (hB x)\n\nlemma ring_hom.is_integral_trans (hf : f.is_integral) (hg : g.is_integral) :\n  (g.comp f).is_integral :=\n@algebra.is_integral_trans R S T _ _ _ g.to_algebra (g.comp f).to_algebra f.to_algebra\n  (@is_scalar_tower.of_algebra_map_eq R S T _ _ _ f.to_algebra g.to_algebra (g.comp f).to_algebra\n  (ring_hom.comp_apply g f)) hf hg\n\nlemma ring_hom.is_integral_of_surjective (hf : function.surjective f) : f.is_integral :=\nλ x, (hf x).rec_on (λ y hy, (hy ▸ f.is_integral_map : f.is_integral_elem x))\n\nlemma is_integral_of_surjective (h : function.surjective (algebra_map R A)) :\n  algebra.is_integral R A := (algebra_map R A).is_integral_of_surjective h\n\n/-- If `R → A → B` is an algebra tower with `A → B` injective,\nthen if the entire tower is an integral extension so is `R → A` -/\nlemma is_integral_tower_bot_of_is_integral (H : function.injective (algebra_map A B))\n  {x : A} (h : is_integral R (algebra_map A B x)) : is_integral R x :=\nbegin\n  rcases h with ⟨p, ⟨hp, hp'⟩⟩,\n  refine ⟨p, ⟨hp, _⟩⟩,\n  rw [is_scalar_tower.algebra_map_eq R A B, ← eval₂_map,\n      eval₂_hom, ← ring_hom.map_zero (algebra_map A B)] at hp',\n  rw [eval₂_eq_eval_map],\n  exact H hp',\nend\n\nlemma ring_hom.is_integral_tower_bot_of_is_integral (hg : function.injective g)\n  (hfg : (g.comp f).is_integral) : f.is_integral :=\nλ x,\n  @is_integral_tower_bot_of_is_integral R S T _ _ _ g.to_algebra (g.comp f).to_algebra f.to_algebra\n  (@is_scalar_tower.of_algebra_map_eq R S T _ _ _ f.to_algebra g.to_algebra (g.comp f).to_algebra\n  (ring_hom.comp_apply g f))  hg x (hfg (g x))\n\nlemma is_integral_tower_bot_of_is_integral_field {R A B : Type*} [comm_ring R] [field A]\n  [comm_ring B] [nontrivial B] [algebra R A] [algebra A B] [algebra R B] [is_scalar_tower R A B]\n  {x : A} (h : is_integral R (algebra_map A B x)) : is_integral R x :=\nis_integral_tower_bot_of_is_integral (algebra_map A B).injective h\n\nlemma ring_hom.is_integral_elem_of_is_integral_elem_comp {x : T}\n  (h : (g.comp f).is_integral_elem x) : g.is_integral_elem x :=\nlet ⟨p, ⟨hp, hp'⟩⟩ := h in ⟨p.map f, hp.map f, by rwa ← eval₂_map at hp'⟩\n\nlemma ring_hom.is_integral_tower_top_of_is_integral (h : (g.comp f).is_integral) : g.is_integral :=\nλ x, ring_hom.is_integral_elem_of_is_integral_elem_comp f g (h x)\n\n/-- If `R → A → B` is an algebra tower,\nthen if the entire tower is an integral extension so is `A → B`. -/\nlemma is_integral_tower_top_of_is_integral {x : B} (h : is_integral R x) : is_integral A x :=\nbegin\n  rcases h with ⟨p, ⟨hp, hp'⟩⟩,\n  refine ⟨p.map (algebra_map R A), ⟨hp.map (algebra_map R A), _⟩⟩,\n  rw [is_scalar_tower.algebra_map_eq R A B, ← eval₂_map] at hp',\n  exact hp',\nend\n\nlemma ring_hom.is_integral_quotient_of_is_integral {I : ideal S} (hf : f.is_integral) :\n  (ideal.quotient_map I f le_rfl).is_integral :=\nbegin\n  rintros ⟨x⟩,\n  obtain ⟨p, ⟨p_monic, hpx⟩⟩ := hf x,\n  refine ⟨p.map (ideal.quotient.mk _), ⟨p_monic.map _, _⟩⟩,\n  simpa only [hom_eval₂, eval₂_map] using congr_arg (ideal.quotient.mk I) hpx\nend\n\nlemma is_integral_quotient_of_is_integral {I : ideal A} (hRA : algebra.is_integral R A) :\n  algebra.is_integral (R ⧸ I.comap (algebra_map R A)) (A ⧸ I) :=\n(algebra_map R A).is_integral_quotient_of_is_integral hRA\n\nlemma is_integral_quotient_map_iff {I : ideal S} :\n  (ideal.quotient_map I f le_rfl).is_integral ↔\n    ((ideal.quotient.mk I).comp f : R →+* S ⧸ I).is_integral :=\nbegin\n  let g := ideal.quotient.mk (I.comap f),\n  have := ideal.quotient_map_comp_mk le_rfl,\n  refine ⟨λ h, _, λ h, ring_hom.is_integral_tower_top_of_is_integral g _ (this ▸ h)⟩,\n  refine this ▸ ring_hom.is_integral_trans g (ideal.quotient_map I f le_rfl) _ h,\n  exact ring_hom.is_integral_of_surjective g ideal.quotient.mk_surjective,\nend\n\n/-- If the integral extension `R → S` is injective, and `S` is a field, then `R` is also a field. -/\nlemma is_field_of_is_integral_of_is_field\n  {R S : Type*} [comm_ring R] [nontrivial R] [comm_ring S] [is_domain S]\n  [algebra R S] (H : algebra.is_integral R S) (hRS : function.injective (algebra_map R S))\n  (hS : is_field S) : is_field R :=\nbegin\n  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, λ a ha, _⟩,\n  -- Let `a_inv` be the inverse of `algebra_map R S a`,\n  -- then we need to show that `a_inv` is of the form `algebra_map R S b`.\n  obtain ⟨a_inv, ha_inv⟩ := hS.mul_inv_cancel (λ h, ha (hRS (trans h (ring_hom.map_zero _).symm))),\n\n  -- Let `p : R[X]` be monic with root `a_inv`,\n  -- and `q` be `p` with coefficients reversed (so `q(a) = q'(a) * a + 1`).\n  -- We claim that `q(a) = 0`, so `-q'(a)` is the inverse of `a`.\n  obtain ⟨p, p_monic, hp⟩ := H a_inv,\n  use -∑ (i : ℕ) in finset.range p.nat_degree, (p.coeff i) * a ^ (p.nat_degree - i - 1),\n\n  -- `q(a) = 0`, because multiplying everything with `a_inv^n` gives `p(a_inv) = 0`.\n  -- TODO: this could be a lemma for `polynomial.reverse`.\n  have hq : ∑ (i : ℕ) in finset.range (p.nat_degree + 1), (p.coeff i) * a ^ (p.nat_degree - i) = 0,\n  { apply (injective_iff_map_eq_zero (algebra_map R S)).mp hRS,\n    have a_inv_ne_zero : a_inv ≠ 0 := right_ne_zero_of_mul (mt ha_inv.symm.trans one_ne_zero),\n    refine (mul_eq_zero.mp _).resolve_right (pow_ne_zero p.nat_degree a_inv_ne_zero),\n    rw [eval₂_eq_sum_range] at hp,\n    rw [ring_hom.map_sum, finset.sum_mul],\n    refine (finset.sum_congr rfl (λ i hi, _)).trans hp,\n    rw [ring_hom.map_mul, mul_assoc],\n    congr,\n    have : a_inv ^ p.nat_degree = a_inv ^ (p.nat_degree - i) * a_inv ^ i,\n    { rw [← pow_add a_inv, tsub_add_cancel_of_le (nat.le_of_lt_succ (finset.mem_range.mp hi))] },\n    rw [ring_hom.map_pow, this, ← mul_assoc, ← mul_pow, ha_inv, one_pow, one_mul] },\n\n  -- Since `q(a) = 0` and `q(a) = q'(a) * a + 1`, we have `a * -q'(a) = 1`.\n  -- TODO: we could use a lemma for `polynomial.div_X` here.\n  rw [finset.sum_range_succ_comm, p_monic.coeff_nat_degree, one_mul, tsub_self, pow_zero,\n      add_eq_zero_iff_eq_neg, eq_comm] at hq,\n  rw [mul_comm, neg_mul, finset.sum_mul],\n  convert hq using 2,\n  refine finset.sum_congr rfl (λ i hi, _),\n  have : 1 ≤ p.nat_degree - i := le_tsub_of_add_le_left (finset.mem_range.mp hi),\n  rw [mul_assoc, ← pow_succ', tsub_add_cancel_of_le this]\nend\n\nlemma is_field_of_is_integral_of_is_field'\n  {R S : Type*} [comm_ring R] [comm_ring S] [is_domain S] [algebra R S]\n  (H : algebra.is_integral R S) (hR : is_field R) :\n  is_field S :=\nbegin\n  letI := hR.to_field,\n  refine ⟨⟨0, 1, zero_ne_one⟩, mul_comm, λ x hx, _⟩,\n  let A := algebra.adjoin R ({x} : set S),\n  haveI : is_noetherian R A :=\n  is_noetherian_of_fg_of_noetherian A.to_submodule (fg_adjoin_singleton_of_integral x (H x)),\n  haveI : module.finite R A := module.is_noetherian.finite R A,\n  obtain ⟨y, hy⟩ := linear_map.surjective_of_injective (@linear_map.mul_left_injective R A _ _ _ _\n    ⟨x, subset_adjoin (set.mem_singleton x)⟩ (λ h, hx (subtype.ext_iff.mp h))) 1,\n  exact ⟨y, subtype.ext_iff.mp hy⟩,\nend\n\nlemma algebra.is_integral.is_field_iff_is_field\n  {R S : Type*} [comm_ring R] [nontrivial R] [comm_ring S] [is_domain S] [algebra R S]\n  (H : algebra.is_integral R S) (hRS : function.injective (algebra_map R S)) :\n  is_field R ↔ is_field S :=\n⟨is_field_of_is_integral_of_is_field' H, is_field_of_is_integral_of_is_field H hRS⟩\n\nend algebra\n\ntheorem integral_closure_idem {R : Type*} {A : Type*} [comm_ring R] [comm_ring A] [algebra R A] :\n  integral_closure (integral_closure R A : set A) A = ⊥ :=\neq_bot_iff.2 $ λ x hx, algebra.mem_bot.2\n⟨⟨x, @is_integral_trans _ _ _ _ _ _ _ _ (integral_closure R A).algebra\n     _ integral_closure.is_integral x hx⟩, rfl⟩\n\nsection is_domain\nvariables {R S : Type*} [comm_ring R] [comm_ring S] [is_domain S] [algebra R S]\n\ninstance : is_domain (integral_closure R S) :=\ninfer_instance\n\ntheorem roots_mem_integral_closure {f : R[X]} (hf : f.monic) {a : S}\n  (ha : a ∈ (f.map $ algebra_map R S).roots) : a ∈ integral_closure R S :=\n⟨f, hf, (eval₂_eq_eval_map _).trans $ (mem_roots $ (hf.map _).ne_zero).1 ha⟩\n\nend is_domain\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/integral_closure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.49814539165670635}}
{"text": "/-\nCopyright (c) 2021 Justus Springer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Justus Springer\n\n! This file was ported from Lean 3 source module algebra.category.Module.filtered_colimits\n! leanprover-community/mathlib commit 806bbb0132ba63b93d5edbe4789ea226f8329979\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Category.Group.FilteredColimits\nimport Mathbin.Algebra.Category.Module.Basic\n\n/-!\n# The forgetful functor from `R`-modules preserves filtered colimits.\n\nForgetful functors from algebraic categories usually don't preserve colimits. However, they tend\nto preserve _filtered_ colimits.\n\nIn this file, we start with a ring `R`, a small filtered category `J` and a functor\n`F : J ⥤ Module R`. We show that the colimit of `F ⋙ forget₂ (Module R) AddCommGroup`\n(in `AddCommGroup`) carries the structure of an `R`-module, thereby showing that the forgetful\nfunctor `forget₂ (Module R) AddCommGroup` preserves filtered colimits. In particular, this implies\nthat `forget (Module R)` preserves filtered colimits.\n\n-/\n\n\nuniverse u v\n\nnoncomputable section\n\nopen Classical\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nopen CategoryTheory.IsFiltered renaming max → max'\n\n-- avoid name collision with `_root_.max`.\nopen AddMonCat.FilteredColimits (colimit_zero_eq colimit_add_mk_eq)\n\nnamespace ModuleCat.FilteredColimits\n\nsection\n\n-- We use parameters here, mainly so we can have the abbreviations `M` and `M.mk` below, without\n-- passing around `F` all the time.\nparameter {R : Type u}[Ring R]{J : Type v}[SmallCategory J][IsFiltered J]\n\nparameter (F : J ⥤ ModuleCat.{max v u} R)\n\n/-- The colimit of `F ⋙ forget₂ (Module R) AddCommGroup` in the category `AddCommGroup`.\nIn the following, we will show that this has the structure of an `R`-module.\n-/\nabbrev m : AddCommGroupCat :=\n  AddCommGroupCat.FilteredColimits.colimit (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat.{max v u})\n#align Module.filtered_colimits.M ModuleCat.FilteredColimits.m\n\n/-- The canonical projection into the colimit, as a quotient type. -/\nabbrev m.mk : (Σj, F.obj j) → M :=\n  Quot.mk (Types.Quot.Rel (F ⋙ forget (ModuleCat R)))\n#align Module.filtered_colimits.M.mk ModuleCat.FilteredColimits.m.mk\n\ntheorem m.mk_eq (x y : Σj, F.obj j)\n    (h : ∃ (k : J)(f : x.1 ⟶ k)(g : y.1 ⟶ k), F.map f x.2 = F.map g y.2) : M.mk x = M.mk y :=\n  Quot.EqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget (ModuleCat R)) x y h)\n#align Module.filtered_colimits.M.mk_eq ModuleCat.FilteredColimits.m.mk_eq\n\n/-- The \"unlifted\" version of scalar multiplication in the colimit. -/\ndef colimitSmulAux (r : R) (x : Σj, F.obj j) : M :=\n  M.mk ⟨x.1, r • x.2⟩\n#align Module.filtered_colimits.colimit_smul_aux ModuleCat.FilteredColimits.colimitSmulAux\n\ntheorem colimitSmulAux_eq_of_rel (r : R) (x y : Σj, F.obj j)\n    (h : Types.FilteredColimit.Rel (F ⋙ forget (ModuleCat R)) x y) :\n    colimit_smul_aux r x = colimit_smul_aux r y :=\n  by\n  apply M.mk_eq\n  obtain ⟨k, f, g, hfg⟩ := h\n  use k, f, g\n  simp only [CategoryTheory.Functor.comp_map, forget_map_eq_coe] at hfg\n  rw [LinearMap.map_smul, LinearMap.map_smul, hfg]\n#align Module.filtered_colimits.colimit_smul_aux_eq_of_rel ModuleCat.FilteredColimits.colimitSmulAux_eq_of_rel\n\n/-- Scalar multiplication in the colimit. See also `colimit_smul_aux`. -/\ninstance colimitHasSmul : SMul R M\n    where smul r x := by\n    refine' Quot.lift (colimit_smul_aux F r) _ x\n    intro x y h\n    apply colimit_smul_aux_eq_of_rel\n    apply types.filtered_colimit.rel_of_quot_rel\n    exact h\n#align Module.filtered_colimits.colimit_has_smul ModuleCat.FilteredColimits.colimitHasSmul\n\n@[simp]\ntheorem colimit_smul_mk_eq (r : R) (x : Σj, F.obj j) : r • M.mk x = M.mk ⟨x.1, r • x.2⟩ :=\n  rfl\n#align Module.filtered_colimits.colimit_smul_mk_eq ModuleCat.FilteredColimits.colimit_smul_mk_eq\n\ninstance colimitModule : Module R M\n    where\n  one_smul x := by\n    apply Quot.inductionOn x; clear x; intro x; cases' x with j x\n    erw [colimit_smul_mk_eq F 1 ⟨j, x⟩, one_smul]\n    rfl\n  mul_smul r s x := by\n    apply Quot.inductionOn x; clear x; intro x; cases' x with j x\n    erw [colimit_smul_mk_eq F (r * s) ⟨j, x⟩, colimit_smul_mk_eq F s ⟨j, x⟩,\n      colimit_smul_mk_eq F r ⟨j, _⟩, mul_smul]\n  smul_add r x y := by\n    apply Quot.induction_on₂ x y; clear x y; intro x y; cases' x with i x; cases' y with j y\n    erw [colimit_add_mk_eq _ ⟨i, x⟩ ⟨j, y⟩ (max' i j) (left_to_max i j) (right_to_max i j),\n      colimit_smul_mk_eq, smul_add, colimit_smul_mk_eq, colimit_smul_mk_eq,\n      colimit_add_mk_eq _ ⟨i, _⟩ ⟨j, _⟩ (max' i j) (left_to_max i j) (right_to_max i j),\n      LinearMap.map_smul, LinearMap.map_smul]\n    rfl\n  smul_zero r :=\n    by\n    erw [colimit_zero_eq _ (is_filtered.nonempty.some : J), colimit_smul_mk_eq, smul_zero]\n    rfl\n  zero_smul x := by\n    apply Quot.inductionOn x; clear x; intro x; cases' x with j x\n    erw [colimit_smul_mk_eq, zero_smul, colimit_zero_eq _ j]\n    rfl\n  add_smul r s x := by\n    apply Quot.inductionOn x; clear x; intro x; cases' x with j x\n    erw [colimit_smul_mk_eq, add_smul, colimit_smul_mk_eq, colimit_smul_mk_eq,\n      colimit_add_mk_eq _ ⟨j, _⟩ ⟨j, _⟩ j (𝟙 j) (𝟙 j), CategoryTheory.Functor.map_id, id_apply,\n      id_apply]\n    rfl\n#align Module.filtered_colimits.colimit_module ModuleCat.FilteredColimits.colimitModule\n\n/-- The bundled `R`-module giving the filtered colimit of a diagram. -/\ndef colimit : ModuleCat R :=\n  ModuleCat.of R M\n#align Module.filtered_colimits.colimit ModuleCat.FilteredColimits.colimit\n\n/-- The linear map from a given `R`-module in the diagram to the colimit module. -/\ndef coconeMorphism (j : J) : F.obj j ⟶ colimit :=\n  {\n    (AddCommGroupCat.FilteredColimits.colimitCocone\n            (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat.{max v u})).ι.app\n      j with\n    map_smul' := fun r x => by erw [colimit_smul_mk_eq F r ⟨j, x⟩]; rfl }\n#align Module.filtered_colimits.cocone_morphism ModuleCat.FilteredColimits.coconeMorphism\n\n/-- The cocone over the proposed colimit module. -/\ndef colimitCocone : cocone F where\n  pt := colimit\n  ι :=\n    { app := cocone_morphism\n      naturality' := fun j j' f =>\n        LinearMap.coe_injective ((Types.colimitCocone (F ⋙ forget (ModuleCat R))).ι.naturality f) }\n#align Module.filtered_colimits.colimit_cocone ModuleCat.FilteredColimits.colimitCocone\n\n/-- Given a cocone `t` of `F`, the induced monoid linear map from the colimit to the cocone point.\nWe already know that this is a morphism between additive groups. The only thing left to see is that\nit is a linear map, i.e. preserves scalar multiplication.\n-/\ndef colimitDesc (t : cocone F) : colimit ⟶ t.pt :=\n  {\n    (AddCommGroupCat.FilteredColimits.colimitCoconeIsColimit\n          (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat.{max v u})).desc\n      ((forget₂ (ModuleCat R) AddCommGroupCat.{max v u}).mapCocone t) with\n    map_smul' := fun r x => by\n      apply Quot.inductionOn x; clear x; intro x; cases' x with j x\n      erw [colimit_smul_mk_eq]\n      exact LinearMap.map_smul (t.ι.app j) r x }\n#align Module.filtered_colimits.colimit_desc ModuleCat.FilteredColimits.colimitDesc\n\n/-- The proposed colimit cocone is a colimit in `Module R`. -/\ndef colimitCoconeIsColimit : IsColimit colimit_cocone\n    where\n  desc := colimit_desc\n  fac t j :=\n    LinearMap.coe_injective <|\n      (Types.colimitCoconeIsColimit (F ⋙ forget (ModuleCat R))).fac\n        ((forget (ModuleCat R)).mapCocone t) j\n  uniq t m h :=\n    LinearMap.coe_injective <|\n      (Types.colimitCoconeIsColimit (F ⋙ forget (ModuleCat R))).uniq\n        ((forget (ModuleCat R)).mapCocone t) m fun j => funext fun x => LinearMap.congr_fun (h j) x\n#align Module.filtered_colimits.colimit_cocone_is_colimit ModuleCat.FilteredColimits.colimitCoconeIsColimit\n\ninstance forget₂AddCommGroupPreservesFilteredColimits :\n    PreservesFilteredColimits (forget₂ (ModuleCat R) AddCommGroupCat.{u})\n    where PreservesFilteredColimits J _ _ :=\n    {\n      PreservesColimit := fun F =>\n        preserves_colimit_of_preserves_colimit_cocone (colimit_cocone_is_colimit F)\n          (AddCommGroupCat.FilteredColimits.colimitCoconeIsColimit\n            (F ⋙ forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) }\n#align Module.filtered_colimits.forget₂_AddCommGroup_preserves_filtered_colimits ModuleCat.FilteredColimits.forget₂AddCommGroupPreservesFilteredColimits\n\ninstance forgetPreservesFilteredColimits : PreservesFilteredColimits (forget (ModuleCat.{u} R)) :=\n  Limits.compPreservesFilteredColimits (forget₂ (ModuleCat R) AddCommGroupCat)\n    (forget AddCommGroupCat)\n#align Module.filtered_colimits.forget_preserves_filtered_colimits ModuleCat.FilteredColimits.forgetPreservesFilteredColimits\n\nend\n\nend ModuleCat.FilteredColimits\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Category/Module/FilteredColimits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.49814538684314347}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport linear_algebra.affine_space.midpoint\nimport topology.metric_space.isometry\nimport topology.instances.real_vector_space\n\n/-!\n# Torsors of additive normed group actions.\n\nThis file defines torsors of additive normed group actions, with a\nmetric space structure.  The motivating case is Euclidean affine\nspaces.\n\n-/\n\nnoncomputable theory\nopen_locale nnreal topological_space\nopen filter\n\n/-- A `semi_normed_add_torsor V P` is a torsor of an additive seminormed group\naction by a `semi_normed_group V` on points `P`. We bundle the pseudometric space\nstructure and require the distance to be the same as results from the\nnorm (which in fact implies the distance yields a pseudometric space, but\nbundling just the distance and using an instance for the pseudometric space\nresults in type class problems). -/\nclass semi_normed_add_torsor (V : out_param $ Type*) (P : Type*)\n  [out_param $ semi_normed_group V] [pseudo_metric_space P]\n  extends add_torsor V P :=\n(dist_eq_norm' : ∀ (x y : P), dist x y = ∥(x -ᵥ y : V)∥)\n\n/-- A `normed_add_torsor V P` is a torsor of an additive normed group\naction by a `normed_group V` on points `P`. We bundle the metric space\nstructure and require the distance to be the same as results from the\nnorm (which in fact implies the distance yields a metric space, but\nbundling just the distance and using an instance for the metric space\nresults in type class problems). -/\nclass normed_add_torsor (V : out_param $ Type*) (P : Type*)\n  [out_param $ normed_group V] [metric_space P]\n  extends add_torsor V P :=\n(dist_eq_norm' : ∀ (x y : P), dist x y = ∥(x -ᵥ y : V)∥)\n\n/-- A `normed_add_torsor` is a `semi_normed_add_torsor`. -/\n@[priority 100]\ninstance normed_add_torsor.to_semi_normed_add_torsor {V P : Type*} [normed_group V] [metric_space P]\n  [β : normed_add_torsor V P] : semi_normed_add_torsor V P := { ..β }\n\nvariables {α V P : Type*} [semi_normed_group V] [pseudo_metric_space P] [semi_normed_add_torsor V P]\nvariables {W Q : Type*} [normed_group W] [metric_space Q] [normed_add_torsor W Q]\n\n/-- A `semi_normed_group` is a `semi_normed_add_torsor` over itself. -/\n@[priority 100]\ninstance semi_normed_group.normed_add_torsor : semi_normed_add_torsor V V :=\n{ dist_eq_norm' := dist_eq_norm }\n\n/-- A `normed_group` is a `normed_add_torsor` over itself. -/\n@[priority 100]\ninstance normed_group.normed_add_torsor : normed_add_torsor W W :=\n{ dist_eq_norm' := dist_eq_norm }\n\ninclude V\n\nsection\n\nvariables (V W)\n\n/-- The distance equals the norm of subtracting two points. In this\nlemma, it is necessary to have `V` as an explicit argument; otherwise\n`rw dist_eq_norm_vsub` sometimes doesn't work. -/\nlemma dist_eq_norm_vsub (x y : P) :\n  dist x y = ∥(x -ᵥ y)∥ :=\nsemi_normed_add_torsor.dist_eq_norm' x y\n\nend\n\n@[simp] lemma dist_vadd_cancel_left (v : V) (x y : P) :\n  dist (v +ᵥ x) (v +ᵥ y) = dist x y :=\nby rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, vadd_vsub_vadd_cancel_left]\n\n@[simp] lemma dist_vadd_cancel_right (v₁ v₂ : V) (x : P) :\n  dist (v₁ +ᵥ x) (v₂ +ᵥ x) = dist v₁ v₂ :=\nby rw [dist_eq_norm_vsub V, dist_eq_norm, vadd_vsub_vadd_cancel_right]\n\n@[simp] lemma dist_vadd_left (v : V) (x : P) : dist (v +ᵥ x) x = ∥v∥ :=\nby simp [dist_eq_norm_vsub V _ x]\n\n@[simp] lemma dist_vadd_right (v : V) (x : P) : dist x (v +ᵥ x) = ∥v∥ :=\nby rw [dist_comm, dist_vadd_left]\n\n@[simp] lemma dist_vsub_cancel_left (x y z : P) : dist (x -ᵥ y) (x -ᵥ z) = dist y z :=\nby rw [dist_eq_norm, vsub_sub_vsub_cancel_left, dist_comm, dist_eq_norm_vsub V]\n\n@[simp] lemma dist_vsub_cancel_right (x y z : P) : dist (x -ᵥ z) (y -ᵥ z) = dist x y :=\nby rw [dist_eq_norm, vsub_sub_vsub_cancel_right, dist_eq_norm_vsub V]\n\nlemma dist_vadd_vadd_le (v v' : V) (p p' : P) :\n  dist (v +ᵥ p) (v' +ᵥ p') ≤ dist v v' + dist p p' :=\nby simpa using dist_triangle (v +ᵥ p) (v' +ᵥ p) (v' +ᵥ p')\n\nlemma dist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :\n  dist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ dist p₁ p₃ + dist p₂ p₄ :=\nby { rw [dist_eq_norm, vsub_sub_vsub_comm, dist_eq_norm_vsub V, dist_eq_norm_vsub V],\n exact norm_sub_le _ _ }\n\nlemma nndist_vadd_vadd_le (v v' : V) (p p' : P) :\n  nndist (v +ᵥ p) (v' +ᵥ p') ≤ nndist v v' + nndist p p' :=\nby simp only [← nnreal.coe_le_coe, nnreal.coe_add, ← dist_nndist, dist_vadd_vadd_le]\n\nlemma nndist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :\n  nndist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ nndist p₁ p₃ + nndist p₂ p₄ :=\nby simp only [← nnreal.coe_le_coe, nnreal.coe_add, ← dist_nndist, dist_vsub_vsub_le]\n\nlemma edist_vadd_vadd_le (v v' : V) (p p' : P) :\n  edist (v +ᵥ p) (v' +ᵥ p') ≤ edist v v' + edist p p' :=\nby { simp only [edist_nndist], apply_mod_cast nndist_vadd_vadd_le }\n\nlemma edist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :\n  edist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ edist p₁ p₃ + edist p₂ p₄ :=\nby { simp only [edist_nndist], apply_mod_cast nndist_vsub_vsub_le }\n\nomit V\n\n/-- The pseudodistance defines a pseudometric space structure on the torsor. This\nis not an instance because it depends on `V` to define a `metric_space\nP`. -/\ndef pseudo_metric_space_of_normed_group_of_add_torsor (V P : Type*) [semi_normed_group V]\n  [add_torsor V P] : pseudo_metric_space P :=\n{ dist := λ x y, ∥(x -ᵥ y : V)∥,\n  dist_self := λ x, by simp,\n  dist_comm := λ x y, by simp only [←neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change ∥x -ᵥ z∥ ≤ ∥x -ᵥ y∥ + ∥y -ᵥ z∥,\n    rw ←vsub_add_vsub_cancel,\n    apply norm_add_le\n  end }\n\n/-- The distance defines a metric space structure on the torsor. This\nis not an instance because it depends on `V` to define a `metric_space\nP`. -/\ndef metric_space_of_normed_group_of_add_torsor (V P : Type*) [normed_group V] [add_torsor V P] :\n  metric_space P :=\n{ dist := λ x y, ∥(x -ᵥ y : V)∥,\n  dist_self := λ x, by simp,\n  eq_of_dist_eq_zero := λ x y h, by simpa using h,\n  dist_comm := λ x y, by simp only [←neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change ∥x -ᵥ z∥ ≤ ∥x -ᵥ y∥ + ∥y -ᵥ z∥,\n    rw ←vsub_add_vsub_cancel,\n    apply norm_add_le\n  end }\n\ninclude V\n\nnamespace isometric\n\n/-- The map `v ↦ v +ᵥ p` as an isometric equivalence between `V` and `P`. -/\ndef vadd_const (p : P) : V ≃ᵢ P :=\n⟨equiv.vadd_const p, isometry_emetric_iff_metric.2 $ λ x₁ x₂, dist_vadd_cancel_right x₁ x₂ p⟩\n\n@[simp] lemma coe_vadd_const (p : P) : ⇑(vadd_const p) = λ v, v +ᵥ p := rfl\n\n@[simp] lemma coe_vadd_const_symm (p : P) : ⇑(vadd_const p).symm = λ p', p' -ᵥ p := rfl\n\n@[simp] lemma vadd_const_to_equiv (p : P) : (vadd_const p).to_equiv = equiv.vadd_const p := rfl\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef const_vsub (p : P) : P ≃ᵢ V :=\n⟨equiv.const_vsub p, isometry_emetric_iff_metric.2 $ λ p₁ p₂, dist_vsub_cancel_left _ _ _⟩\n\n@[simp] lemma coe_const_vsub (p : P) : ⇑(const_vsub p) = (-ᵥ) p := rfl\n\n@[simp] lemma coe_const_vsub_symm (p : P) : ⇑(const_vsub p).symm = λ v, -v +ᵥ p := rfl\n\nvariables (P)\n\n/-- The map `p ↦ v +ᵥ p` as an isometric automorphism of `P`. -/\ndef const_vadd (v : V) : P ≃ᵢ P :=\n⟨equiv.const_vadd P v, isometry_emetric_iff_metric.2 $ dist_vadd_cancel_left v⟩\n\n@[simp] lemma coe_const_vadd (v : V) : ⇑(const_vadd P v) = (+ᵥ) v := rfl\n\nvariable (V)\n\n@[simp] lemma const_vadd_zero : const_vadd P (0:V) = isometric.refl P :=\nisometric.to_equiv_inj $ equiv.const_vadd_zero V P\n\nvariables {P V}\n\n/-- Point reflection in `x` as an `isometric` homeomorphism. -/\ndef point_reflection (x : P) : P ≃ᵢ P :=\n(const_vsub x).trans (vadd_const x)\n\nlemma point_reflection_apply (x y : P) : point_reflection x y = x -ᵥ y +ᵥ x := rfl\n\n@[simp] lemma point_reflection_to_equiv (x : P) :\n  (point_reflection x).to_equiv = equiv.point_reflection x := rfl\n\n@[simp] lemma point_reflection_self (x : P) : point_reflection x x = x :=\nequiv.point_reflection_self x\n\nlemma point_reflection_involutive (x : P) : function.involutive (point_reflection x : P → P) :=\nequiv.point_reflection_involutive x\n\n@[simp] lemma point_reflection_symm (x : P) : (point_reflection x).symm = point_reflection x :=\nto_equiv_inj $ equiv.point_reflection_symm x\n\n@[simp] lemma dist_point_reflection_fixed (x y : P) :\n  dist (point_reflection x y) x = dist y x :=\nby rw [← (point_reflection x).dist_eq y x, point_reflection_self]\n\nlemma dist_point_reflection_self' (x y : P) :\n  dist (point_reflection x y) y = ∥bit0 (x -ᵥ y)∥ :=\nby rw [point_reflection_apply, dist_eq_norm_vsub V, vadd_vsub_assoc, bit0]\n\nlemma dist_point_reflection_self (𝕜 : Type*) [normed_field 𝕜] [semi_normed_space 𝕜 V] (x y : P) :\n  dist (point_reflection x y) y = ∥(2:𝕜)∥ * dist x y :=\nby rw [dist_point_reflection_self', ← two_smul' 𝕜 (x -ᵥ y), norm_smul, ← dist_eq_norm_vsub V]\n\nlemma point_reflection_fixed_iff (𝕜 : Type*) [normed_field 𝕜] [semi_normed_space 𝕜 V]\n  [invertible (2:𝕜)] {x y : P} : point_reflection x y = y ↔ y = x :=\naffine_equiv.point_reflection_fixed_iff_of_module 𝕜\n\nvariables [semi_normed_space ℝ V]\n\nlemma dist_point_reflection_self_real (x y : P) :\n  dist (point_reflection x y) y = 2 * dist x y :=\nby { rw [dist_point_reflection_self ℝ, real.norm_two], apply_instance }\n\n@[simp] lemma point_reflection_midpoint_left (x y : P) :\n  point_reflection (midpoint ℝ x y) x = y :=\naffine_equiv.point_reflection_midpoint_left x y\n\n@[simp] lemma point_reflection_midpoint_right (x y : P) :\n  point_reflection (midpoint ℝ x y) y = x :=\naffine_equiv.point_reflection_midpoint_right x y\n\nend isometric\n\nlemma lipschitz_with.vadd [pseudo_emetric_space α] {f : α → V} {g : α → P} {Kf Kg : ℝ≥0}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f +ᵥ g) :=\nλ x y,\ncalc edist (f x +ᵥ g x) (f y +ᵥ g y) ≤ edist (f x) (f y) + edist (g x) (g y) :\n  edist_vadd_vadd_le _ _ _ _\n... ≤ Kf * edist x y + Kg * edist x y :\n  add_le_add (hf x y) (hg x y)\n... = (Kf + Kg) * edist x y :\n  (add_mul _ _ _).symm\n\nlemma lipschitz_with.vsub [pseudo_emetric_space α] {f g : α → P} {Kf Kg : ℝ≥0}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f -ᵥ g) :=\nλ x y,\ncalc edist (f x -ᵥ g x) (f y -ᵥ g y) ≤ edist (f x) (f y) + edist (g x) (g y) :\n  edist_vsub_vsub_le _ _ _ _\n... ≤ Kf * edist x y + Kg * edist x y :\n  add_le_add (hf x y) (hg x y)\n... = (Kf + Kg) * edist x y :\n  (add_mul _ _ _).symm\n\nlemma uniform_continuous_vadd : uniform_continuous (λ x : V × P, x.1 +ᵥ x.2) :=\n(lipschitz_with.prod_fst.vadd lipschitz_with.prod_snd).uniform_continuous\n\nlemma uniform_continuous_vsub : uniform_continuous (λ x : P × P, x.1 -ᵥ x.2) :=\n(lipschitz_with.prod_fst.vsub lipschitz_with.prod_snd).uniform_continuous\n\nlemma continuous_vadd : continuous (λ x : V × P, x.1 +ᵥ x.2) :=\nuniform_continuous_vadd.continuous\n\nlemma continuous_vsub : continuous (λ x : P × P, x.1 -ᵥ x.2) :=\nuniform_continuous_vsub.continuous\n\nlemma filter.tendsto.vadd {l : filter α} {f : α → V} {g : α → P} {v : V} {p : P}\n  (hf : tendsto f l (𝓝 v)) (hg : tendsto g l (𝓝 p)) :\n  tendsto (f +ᵥ g) l (𝓝 (v +ᵥ p)) :=\n(continuous_vadd.tendsto (v, p)).comp (hf.prod_mk_nhds hg)\n\nlemma filter.tendsto.vsub {l : filter α} {f g : α → P} {x y : P}\n  (hf : tendsto f l (𝓝 x)) (hg : tendsto g l (𝓝 y)) :\n  tendsto (f -ᵥ g) l (𝓝 (x -ᵥ y)) :=\n(continuous_vsub.tendsto (x, y)).comp (hf.prod_mk_nhds hg)\n\nsection\n\nvariables [topological_space α]\n\nlemma continuous.vadd {f : α → V} {g : α → P} (hf : continuous f) (hg : continuous g) :\n  continuous (f +ᵥ g) :=\ncontinuous_vadd.comp (hf.prod_mk hg)\n\nlemma continuous.vsub {f g : α → P} (hf : continuous f) (hg : continuous g) :\n  continuous (f -ᵥ g) :=\ncontinuous_vsub.comp (hf.prod_mk hg : _)\n\nlemma continuous_at.vadd {f : α → V} {g : α → P} {x : α} (hf : continuous_at f x)\n  (hg : continuous_at g x) :\n  continuous_at (f +ᵥ g) x :=\nhf.vadd hg\n\nlemma continuous_at.vsub {f g : α → P}  {x : α} (hf : continuous_at f x) (hg : continuous_at g x) :\n  continuous_at (f -ᵥ g) x :=\nhf.vsub hg\n\nlemma continuous_within_at.vadd {f : α → V} {g : α → P} {x : α} {s : set α}\n  (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n  continuous_within_at (f +ᵥ g) s x :=\nhf.vadd hg\n\nlemma continuous_within_at.vsub {f g : α → P} {x : α} {s : set α}\n  (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n  continuous_within_at (f -ᵥ g) s x :=\nhf.vsub hg\n\nend\n\nsection\n\nvariables {R : Type*} [ring R] [topological_space R] [module R V] [has_continuous_smul R V]\n\nlemma filter.tendsto.line_map {l : filter α} {f₁ f₂ : α → P} {g : α → R} {p₁ p₂ : P} {c : R}\n  (h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) (hg : tendsto g l (𝓝 c)) :\n  tendsto (λ x, affine_map.line_map (f₁ x) (f₂ x) (g x)) l (𝓝 $ affine_map.line_map p₁ p₂ c) :=\n(hg.smul (h₂.vsub h₁)).vadd h₁\n\nlemma filter.tendsto.midpoint [invertible (2:R)] {l : filter α} {f₁ f₂ : α → P} {p₁ p₂ : P}\n  (h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) :\n  tendsto (λ x, midpoint R (f₁ x) (f₂ x)) l (𝓝 $ midpoint R p₁ p₂) :=\nh₁.line_map h₂ tendsto_const_nhds\n\nend\n\nvariables {V' : Type*} {P' : Type*} [semi_normed_group V'] [pseudo_metric_space P']\n  [semi_normed_add_torsor V' P']\n\n/-- The map `g` from `V1` to `V2` corresponding to a map `f` from `P1`\nto `P2`, at a base point `p`, is an isometry if `f` is one. -/\nlemma isometry.vadd_vsub {f : P → P'} (hf : isometry f) {p : P} {g : V → V'}\n  (hg : ∀ v, g v = f (v +ᵥ p) -ᵥ f p) : isometry g :=\nbegin\n  convert (isometric.vadd_const (f p)).symm.isometry.comp\n    (hf.comp (isometric.vadd_const p).isometry),\n  exact funext hg\nend\n\nsection normed_space\n\nvariables {𝕜 : Type*} [normed_field 𝕜] [semi_normed_space 𝕜 V]\n\nopen affine_map\n\n/-- If `f` is an affine map, then its linear part is continuous iff `f` is continuous. -/\nlemma affine_map.continuous_linear_iff [semi_normed_space 𝕜 V'] {f : P →ᵃ[𝕜] P'} :\n  continuous f.linear ↔ continuous f :=\nbegin\n  inhabit P,\n  have : (f.linear : V → V') =\n    (isometric.vadd_const $ f $ default P).to_homeomorph.symm ∘ f ∘\n      (isometric.vadd_const $ default P).to_homeomorph,\n  { ext v, simp },\n  rw this,\n  simp only [homeomorph.comp_continuous_iff, homeomorph.comp_continuous_iff'],\nend\n\n@[simp] lemma dist_center_homothety (p₁ p₂ : P) (c : 𝕜) :\n  dist p₁ (homothety p₁ c p₂) = ∥c∥ * dist p₁ p₂ :=\nby simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm]\n\n@[simp] lemma dist_homothety_center (p₁ p₂ : P) (c : 𝕜) :\n  dist (homothety p₁ c p₂) p₁ = ∥c∥ * dist p₁ p₂ :=\nby rw [dist_comm, dist_center_homothety]\n\n@[simp] lemma dist_homothety_self (p₁ p₂ : P) (c : 𝕜) :\n  dist (homothety p₁ c p₂) p₂ = ∥1 - c∥ * dist p₁ p₂ :=\nby rw [homothety_eq_line_map, ← line_map_apply_one_sub, ← homothety_eq_line_map,\n  dist_homothety_center, dist_comm]\n\n@[simp] lemma dist_self_homothety (p₁ p₂ : P) (c : 𝕜) :\n  dist p₂ (homothety p₁ c p₂) = ∥1 - c∥ * dist p₁ p₂ :=\nby rw [dist_comm, dist_homothety_self]\n\nvariables [invertible (2:𝕜)]\n\n@[simp] lemma dist_left_midpoint (p₁ p₂ : P) :\n  dist p₁ (midpoint 𝕜 p₁ p₂) = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [midpoint, ← homothety_eq_line_map, dist_center_homothety, inv_of_eq_inv,\n  ← normed_field.norm_inv]\n\n@[simp] lemma dist_midpoint_left (p₁ p₂ : P) :\n  dist (midpoint 𝕜 p₁ p₂) p₁ = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [dist_comm, dist_left_midpoint]\n\n@[simp] lemma dist_midpoint_right (p₁ p₂ : P) :\n  dist (midpoint 𝕜 p₁ p₂) p₂ = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [midpoint_comm, dist_midpoint_left, dist_comm]\n\n@[simp] lemma dist_right_midpoint (p₁ p₂ : P) :\n  dist p₂ (midpoint 𝕜 p₁ p₂) = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [dist_comm, dist_midpoint_right]\n\nlemma dist_midpoint_midpoint_le' (p₁ p₂ p₃ p₄ : P) :\n  dist (midpoint 𝕜 p₁ p₂) (midpoint 𝕜 p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / ∥(2 : 𝕜)∥ :=\nbegin\n  rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, midpoint_vsub_midpoint];\n    try { apply_instance },\n  rw [midpoint_eq_smul_add, norm_smul, inv_of_eq_inv, normed_field.norm_inv, ← div_eq_inv_mul],\n  exact div_le_div_of_le_of_nonneg (norm_add_le _ _) (norm_nonneg _),\nend\n\nend normed_space\n\nvariables [semi_normed_space ℝ V] [normed_space ℝ W]\n\nlemma dist_midpoint_midpoint_le (p₁ p₂ p₃ p₄ : V) :\n  dist (midpoint ℝ p₁ p₂) (midpoint ℝ p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / 2 :=\nby simpa using dist_midpoint_midpoint_le' p₁ p₂ p₃ p₄\n\ninclude W\n\n/-- A continuous map between two normed affine spaces is an affine map provided that\nit sends midpoints to midpoints. -/\ndef affine_map.of_map_midpoint (f : P → Q)\n  (h : ∀ x y, f (midpoint ℝ x y) = midpoint ℝ (f x) (f y))\n  (hfc : continuous f) :\n  P →ᵃ[ℝ] Q :=\naffine_map.mk' f\n  ↑((add_monoid_hom.of_map_midpoint ℝ ℝ\n    ((affine_equiv.vadd_const ℝ (f $ classical.arbitrary P)).symm ∘ f ∘\n      (affine_equiv.vadd_const ℝ (classical.arbitrary P))) (by simp)\n      (λ x y, by simp [h])).to_real_linear_map $ by apply_rules [continuous.vadd, continuous.vsub,\n        continuous_const, hfc.comp, continuous_id])\n  (classical.arbitrary P)\n  (λ p, by simp)\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/analysis/normed_space/add_torsor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.49814537903890166}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\n\nimport algebra.char_p.basic\nimport data.mv_polynomial.comm_ring\nimport data.mv_polynomial.equiv\nimport ring_theory.polynomial.content\nimport ring_theory.unique_factorization_domain\n\n/-!\n# Ring-theoretic supplement of data.polynomial.\n\n## Main results\n* `mv_polynomial.is_domain`:\n  If a ring is an integral domain, then so is its polynomial ring over finitely many variables.\n* `polynomial.is_noetherian_ring`:\n  Hilbert basis theorem, that if a ring is noetherian then so is its polynomial ring.\n* `polynomial.wf_dvd_monoid`:\n  If an integral domain is a `wf_dvd_monoid`, then so is its polynomial ring.\n* `polynomial.unique_factorization_monoid`, `mv_polynomial.unique_factorization_monoid`:\n  If an integral domain is a `unique_factorization_monoid`, then so is its polynomial ring (of any\n  number of variables).\n-/\n\nnoncomputable theory\nopen_locale classical big_operators polynomial\n\nuniverses u v w\n\nnamespace polynomial\n\ninstance {R : Type u} [semiring R] (p : ℕ) [h : char_p R p] : char_p R[X] p :=\nlet ⟨h⟩ := h in ⟨λ n, by rw [← map_nat_cast C, ← C_0, C_inj, h]⟩\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R R[X] :=\n⨅ k : ℕ, ⨅ h : ↑k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : ℕ) : submodule R R[X] :=\n⨅ k : ℕ, ⨅ h : k ≥ n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot ℕ} {f : R[X]} :\n  f ∈ degree_le R n ↔ degree f ≤ n :=\nby simp only [degree_le, submodule.mem_infi, degree_le_iff_coeff_zero, linear_map.mem_ker]; refl\n\n@[mono] theorem degree_le_mono {m n : with_bot ℕ} (H : m ≤ n) :\n  degree_le R m ≤ degree_le R n :=\nλ f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : ℕ} :\n  degree_le R n = submodule.span R ↑((finset.range (n+1)).image (λ n, (X : R[X])^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [← polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_le_coe.1 (finset.sup_le_iff.1 hp k hk),\n    rw [monomial_eq_C_mul_X, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_le.2,\n  exact (degree_X_pow_le _).trans\n    (with_bot.coe_le_coe.2 $ nat.le_of_lt_succ $ finset.mem_range.1 hk)\nend\n\ntheorem mem_degree_lt {n : ℕ} {f : R[X]} :\n  f ∈ degree_lt R n ↔ degree f < n :=\nby { simp_rw [degree_lt, submodule.mem_infi, linear_map.mem_ker, degree,\n    finset.sup_lt_iff (with_bot.bot_lt_coe n), mem_support_iff, with_bot.some_eq_coe,\n    with_bot.coe_lt_coe, lt_iff_not_ge', ne, not_imp_not], refl }\n\n@[mono] theorem degree_lt_mono {m n : ℕ} (H : m ≤ n) :\n  degree_lt R m ≤ degree_lt R n :=\nλ f hf, mem_degree_lt.2 (lt_of_lt_of_le (mem_degree_lt.1 hf) $ with_bot.coe_le_coe.2 H)\n\ntheorem degree_lt_eq_span_X_pow {n : ℕ} :\n  degree_lt R n = submodule.span R ↑((finset.range n).image (λ n, X^n) : finset R[X]) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [← polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_lt_coe.1 ((finset.sup_lt_iff $ with_bot.bot_lt_coe n).1 hp k hk),\n    rw [monomial_eq_C_mul_X, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 this, rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_lt.2,\n  exact lt_of_le_of_lt (degree_X_pow_le _) (with_bot.coe_lt_coe.2 $ finset.mem_range.1 hk)\nend\n\n/-- The first `n` coefficients on `degree_lt n` form a linear equivalence with `fin n → F`. -/\ndef degree_lt_equiv (F : Type*) [field F] (n : ℕ) : degree_lt F n ≃ₗ[F] (fin n → F) :=\n{ to_fun := λ p n, (↑p : F[X]).coeff n,\n  inv_fun := λ f, ⟨∑ i : fin n, monomial i (f i),\n    (degree_lt F n).sum_mem (λ i _, mem_degree_lt.mpr (lt_of_le_of_lt\n      (degree_monomial_le i (f i)) (with_bot.coe_lt_coe.mpr i.is_lt)))⟩,\n  map_add' := λ p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := λ x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro ⟨p, hp⟩, ext1,\n    simp only [submodule.coe_mk],\n    by_cases hp0 : p = 0,\n    { subst hp0, simp only [coeff_zero, linear_map.map_zero, finset.sum_const_zero] },\n    rw [mem_degree_lt, degree_eq_nat_degree hp0, with_bot.coe_lt_coe] at hp,\n    conv_rhs { rw [p.as_sum_range' n hp, ← fin.sum_univ_eq_sum_range] },\n  end,\n  right_inv :=\n  begin\n    intro f, ext i,\n    simp only [finset_sum_coeff, submodule.coe_mk],\n    rw [finset.sum_eq_single i, coeff_monomial, if_pos rfl],\n    { rintro j - hji, rw [coeff_monomial, if_neg], rwa [← subtype.ext_iff] },\n    { intro h, exact (h (finset.mem_univ _)).elim }\n  end }\n\n/-- The finset of nonzero coefficients of a polynomial. -/\ndef frange (p : R[X]) : finset R :=\nfinset.image (λ n, p.coeff n) p.support\n\nlemma frange_zero : frange (0 : R[X]) = ∅ :=\nrfl\n\nlemma mem_frange_iff {p : R[X]} {c : R} :\n  c ∈ p.frange ↔ ∃ n ∈ p.support, c = p.coeff n :=\nby simp [frange, eq_comm]\n\nlemma frange_one : frange (1 : R[X]) ⊆ {1} :=\nbegin\n  simp [frange, finset.image_subset_iff],\n  simp only [← C_1, coeff_C],\n  assume n hn,\n  simp only [exists_prop, ite_eq_right_iff, not_forall] at hn,\n  simp [hn],\nend\n\nlemma coeff_mem_frange (p : R[X]) (n : ℕ) (h : p.coeff n ≠ 0) :\n  p.coeff n ∈ p.frange :=\nbegin\n  simp only [frange, exists_prop, mem_support_iff, finset.mem_image, ne.def],\n  exact ⟨n, h, rfl⟩,\nend\n\n/-- Given a polynomial, return the polynomial whose coefficients are in\nthe ring closure of the original coefficients. -/\ndef restriction (p : R[X]) : polynomial (subring.closure (↑p.frange : set R)) :=\n∑ i in p.support, monomial i (⟨p.coeff i,\n  if H : p.coeff i = 0 then H.symm ▸ (subring.closure _).zero_mem\n  else subring.subset_closure (p.coeff_mem_frange _ H)⟩ : (subring.closure (↑p.frange : set R)))\n\n@[simp] theorem coeff_restriction {p : R[X]} {n : ℕ} :\n  ↑(coeff (restriction p) n) = coeff p n :=\nbegin\n  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ne.def, ite_not],\n  split_ifs,\n  { rw h, refl },\n  { refl }\nend\n\n@[simp] theorem coeff_restriction' {p : R[X]} {n : ℕ} :\n  (coeff (restriction p) n).1 = coeff p n :=\ncoeff_restriction\n\n@[simp] lemma support_restriction (p : R[X]) :\n  support (restriction p) = support p :=\nbegin\n  ext i,\n  simp only [mem_support_iff, not_iff_not, ne.def],\n  conv_rhs { rw [← coeff_restriction] },\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem map_restriction (p : R[X]) : p.restriction.map (algebra_map _ _) = p :=\next $ λ n, by rw [coeff_map, algebra.algebra_map_of_subring_apply, coeff_restriction]\n\n@[simp] theorem degree_restriction {p : R[X]} : (restriction p).degree = p.degree :=\nby simp [degree]\n\n@[simp] theorem nat_degree_restriction {p : R[X]} :\n  (restriction p).nat_degree = p.nat_degree :=\nby simp [nat_degree]\n\n@[simp] theorem monic_restriction {p : R[X]} : monic (restriction p) ↔ monic p :=\nbegin\n  simp only [monic, leading_coeff, nat_degree_restriction],\n  rw [←@coeff_restriction _ _ p],\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem restriction_zero : restriction (0 : R[X]) = 0 :=\nby simp only [restriction, finset.sum_empty, support_zero]\n\n@[simp] theorem restriction_one : restriction (1 : R[X]) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables {S : Type v} [ring S] {f : R →+* S} {x : S}\n\ntheorem eval₂_restriction {p : R[X]} :\n  eval₂ f x p =\n  eval₂ (f.comp (subring.subtype (subring.closure (p.frange : set R)))) x p.restriction :=\nbegin\n  simp only [eval₂_eq_sum, sum, support_restriction, ←@coeff_restriction _ _ p],\n  refl,\nend\n\nlemma geom_sum_X_comp_X_add_one_eq_sum (n : ℕ) :\n  (geom_sum (X : R[X]) n).comp (X + 1) =\n  (finset.range n).sum (λ (i : ℕ), (n.choose (i + 1) : R[X]) * X ^ i) :=\nbegin\n  ext i,\n  transitivity (n.choose (i + 1) : R), swap,\n  { simp only [finset_sum_coeff, ← C_eq_nat_cast, coeff_C_mul_X_pow],\n    rw [finset.sum_eq_single i, if_pos rfl],\n    { simp only [@eq_comm _ i, if_false, eq_self_iff_true, implies_true_iff] {contextual := tt}, },\n    { simp only [nat.lt_add_one_iff, nat.choose_eq_zero_of_lt, nat.cast_zero, finset.mem_range,\n        not_lt, eq_self_iff_true, if_true, implies_true_iff] {contextual := tt}, } },\n  induction n with n ih generalizing i,\n  { simp only [geom_sum_zero, zero_comp, coeff_zero, nat.choose_zero_succ, nat.cast_zero], },\n  simp only [geom_sum_succ', ih, add_comp, pow_comp, X_comp, coeff_add, nat.choose_succ_succ,\n    nat.cast_add, add_pow, one_pow, mul_one, finset_sum_coeff, ← C_eq_nat_cast, mul_comm _ (C _),\n    coeff_C_mul_X_pow],\n  rw [finset.sum_eq_single i, if_pos rfl],\n  { simp only [@eq_comm _ i, if_false, eq_self_iff_true, implies_true_iff] {contextual := tt}, },\n  { simp only [nat.lt_add_one_iff, nat.choose_eq_zero_of_lt, nat.cast_zero, finset.mem_range,\n      eq_self_iff_true, if_true, implies_true_iff, not_le] {contextual := tt}, },\nend\n\nlemma monic.geom_sum {R : Type*} [semiring R] {P : R[X]}\n  (hP : P.monic) (hdeg : 0 < P.nat_degree) {n : ℕ} (hn : n ≠ 0) : (geom_sum P n).monic :=\nbegin\n  nontriviality R,\n  cases n, { exact (hn rfl).elim },\n  rw [geom_sum_succ', geom_sum_def],\n  refine (hP.pow _).add_of_left _,\n  refine lt_of_le_of_lt (degree_sum_le _ _) _,\n  rw [finset.sup_lt_iff],\n  { simp only [finset.mem_range, degree_eq_nat_degree (hP.pow _).ne_zero,\n      with_bot.coe_lt_coe, hP.nat_degree_pow],\n    intro k, exact nsmul_lt_nsmul hdeg },\n  { rw [bot_lt_iff_ne_bot, ne.def, degree_eq_bot],\n    exact (hP.pow _).ne_zero }\nend\n\n\n\nlemma monic_geom_sum_X (R : Type*) [semiring R] {n : ℕ} (hn : n ≠ 0) :\n  (geom_sum (X : R[X]) n).monic :=\nbegin\n  nontriviality R,\n  apply monic_X.geom_sum _ hn,\n  simpa only [nat_degree_X] using zero_lt_one\nend\n\nsection to_subring\n\nvariables (p : R[X]) (T : subring R)\n\n/-- Given a polynomial `p` and a subring `T` that contains the coefficients of `p`,\nreturn the corresponding polynomial whose coefficients are in `T. -/\ndef to_subring (hp : (↑p.frange : set R) ⊆ T) : T[X] :=\n∑ i in p.support, monomial i (⟨p.coeff i,\n  if H : p.coeff i = 0 then H.symm ▸ T.zero_mem\n  else hp (p.coeff_mem_frange _ H)⟩ : T)\n\nvariables (hp : (↑p.frange : set R) ⊆ T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : ℕ} : ↑(coeff (to_subring p T hp) n) = coeff p n :=\nbegin\n  simp only [to_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ne.def, ite_not],\n  split_ifs,\n  { rw h, refl },\n  { refl }\nend\n\n@[simp] theorem coeff_to_subring' {n : ℕ} : (coeff (to_subring p T hp) n).1 = coeff p n :=\ncoeff_to_subring _ _ hp\n\n@[simp] lemma support_to_subring :\n  support (to_subring p T hp) = support p :=\nbegin\n  ext i,\n  simp only [mem_support_iff, not_iff_not, ne.def],\n  conv_rhs { rw [← coeff_to_subring p T hp] },\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem degree_to_subring : (to_subring p T hp).degree = p.degree :=\nby simp [degree]\n\n@[simp] theorem nat_degree_to_subring : (to_subring p T hp).nat_degree = p.nat_degree :=\nby simp [nat_degree]\n\n@[simp] theorem monic_to_subring : monic (to_subring p T hp) ↔ monic p :=\nbegin\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, ← coeff_to_subring p T hp],\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\nomit hp\n\n@[simp] theorem to_subring_zero : to_subring (0 : R[X]) T (by simp [frange_zero]) = 0 :=\nby { ext i, simp }\n\n@[simp] theorem to_subring_one : to_subring (1 : R[X]) T\n  (set.subset.trans frange_one $finset.singleton_subset_set_iff.2 T.one_mem) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_to_subring', coeff_one, coeff_one]; split_ifs; refl\n\n@[simp] theorem map_to_subring : (p.to_subring T hp).map (subring.subtype T) = p :=\nby { ext n, simp [coeff_map] }\n\nend to_subring\n\nvariables (T : subring R)\n\n/-- Given a polynomial whose coefficients are in some subring, return\nthe corresponding polynomial whose coefficients are in the ambient ring. -/\ndef of_subring (p : T[X]) : R[X] :=\n∑ i in p.support, monomial i (p.coeff i : R)\n\nlemma coeff_of_subring (p : T[X]) (n : ℕ) :\n  coeff (of_subring T p) n = (coeff p n : T) :=\nbegin\n  simp only [of_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ite_eq_right_iff, ne.def, ite_not, not_not, ite_eq_left_iff],\n  assume h,\n  rw h,\n  refl\nend\n\n@[simp] theorem frange_of_subring {p : T[X]} :\n  (↑(p.of_subring T).frange : set R) ⊆ T :=\nbegin\n  assume i hi,\n  simp only [frange, set.mem_image, mem_support_iff, ne.def, finset.mem_coe, finset.coe_image]\n    at hi,\n  rcases hi with ⟨n, hn, h'n⟩,\n  rw [← h'n, coeff_of_subring],\n  exact subtype.mem (coeff p n : T)\nend\n\nsection mod_by_monic\n\nvariables {q : R[X]}\n\nlemma mem_ker_mod_by_monic (hq : q.monic) {p : R[X]} :\n  p ∈ (mod_by_monic_hom q).ker ↔ q ∣ p :=\nlinear_map.mem_ker.trans (dvd_iff_mod_by_monic_eq_zero hq)\n\n@[simp] lemma ker_mod_by_monic_hom (hq : q.monic) :\n  (polynomial.mod_by_monic_hom q).ker = (ideal.span {q}).restrict_scalars R :=\nsubmodule.ext (λ f, (mem_ker_mod_by_monic hq).trans ideal.mem_span_singleton.symm)\n\nend mod_by_monic\n\nend polynomial\n\nvariables {R : Type u} {S : Type*} {σ : Type v} {M : Type w}\nvariables [comm_ring R] [comm_ring S] [add_comm_group M] [module R M]\n\nnamespace ideal\nopen polynomial\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself -/\nlemma polynomial_mem_ideal_of_coeff_mem_ideal (I : ideal R[X]) (p : R[X])\n  (hp : ∀ (n : ℕ), (p.coeff n) ∈ I.comap C) : p ∈ I :=\nsum_C_mul_X_eq p ▸ submodule.sum_mem I (λ n hn, I.mul_mem_right _ (hp n))\n\n/-- The push-forward of an ideal `I` of `R` to `polynomial R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : R[X]} :\n  f ∈ (ideal.map C I : ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw ← sum_monomial_eq f,\n    refine (I.map C : ideal R[X]).sum_mem (λ n hn, _),\n    simp [monomial_eq_C_mul_X],\n    rw mul_comm,\n    exact (I.map C : ideal R[X]).mul_mem_left _ (mem_map_of_mem _ (hf n)) }\nend\n\nlemma _root_.polynomial.ker_map_ring_hom (f : R →+* S) :\n  (polynomial.map_ring_hom f).ker = f.ker.map C :=\nbegin\n  ext,\n  rw [mem_map_C_iff, ring_hom.mem_ker, polynomial.ext_iff],\n  simp_rw [coe_map_ring_hom, coeff_map, coeff_zero, ring_hom.mem_ker],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} :\n  ∀ a ∈ I, ((quotient.mk (map C I : ideal R[X])).comp C) a = 0 :=\nbegin\n  intros a ha,\n  rw [ring_hom.comp_apply, quotient.eq_zero_iff_mem],\n  exact mem_map_of_mem _ ha,\nend\n\nlemma eval₂_C_mk_eq_zero {I : ideal R} :\n  ∀ f ∈ (map C I : ideal R[X]), eval₂_ring_hom (C.comp (quotient.mk I)) X f = 0 :=\nbegin\n  intros a ha,\n  rw ← sum_monomial_eq a,\n  dsimp,\n  rw eval₂_sum,\n  refine finset.sum_eq_zero (λ n hn, _),\n  dsimp,\n  rw eval₂_monomial (C.comp (quotient.mk I)) X,\n  refine mul_eq_zero_of_left (polynomial.ext (λ m, _)) (X ^ n),\n  erw coeff_C,\n  by_cases h : m = 0,\n  { simpa [h] using quotient.eq_zero_iff_mem.2 ((mem_map_C_iff.1 ha) n) },\n  { simp [h] }\nend\n\n/-- If `I` is an ideal of `R`, then the ring polynomials over the quotient ring `I.quotient` is\nisomorphic to the quotient of `polynomial R` by the ideal `map C I`,\nwhere `map C I` contains exactly the polynomials whose coefficients all lie in `I` -/\ndef polynomial_quotient_equiv_quotient_polynomial (I : ideal R) :\n  polynomial (R ⧸ I) ≃+* R[X] ⧸ (map C I : ideal R[X]) :=\n{ to_fun := eval₂_ring_hom\n    (quotient.lift I ((quotient.mk (map C I : ideal R[X])).comp C) quotient_map_C_eq_zero)\n    ((quotient.mk (map C I : ideal R[X]) X)),\n  inv_fun := quotient.lift (map C I : ideal R[X])\n    (eval₂_ring_hom (C.comp (quotient.mk I)) X) eval₂_C_mk_eq_zero,\n  map_mul' := λ f g, by simp only [coe_eval₂_ring_hom, eval₂_mul],\n  map_add' := λ f g, by simp only [eval₂_add, coe_eval₂_ring_hom],\n  left_inv := begin\n    intro f,\n    apply polynomial.induction_on' f,\n    { intros p q hp hq,\n      simp only [coe_eval₂_ring_hom] at hp,\n      simp only [coe_eval₂_ring_hom] at hq,\n      simp only [coe_eval₂_ring_hom, hp, hq, ring_hom.map_add] },\n    { rintros n ⟨x⟩,\n      simp only [monomial_eq_smul_X, C_mul', quotient.lift_mk, submodule.quotient.quot_mk_eq_mk,\n        quotient.mk_eq_mk, eval₂_X_pow, eval₂_smul, coe_eval₂_ring_hom, ring_hom.map_pow,\n        eval₂_C, ring_hom.coe_comp, ring_hom.map_mul, eval₂_X] }\n  end,\n  right_inv := begin\n    rintro ⟨f⟩,\n    apply polynomial.induction_on' f,\n    { simp_intros p q hp hq,\n      rw [hp, hq] },\n    { intros n a,\n      simp only [monomial_eq_smul_X, ← C_mul' a (X ^ n), quotient.lift_mk,\n        submodule.quotient.quot_mk_eq_mk, quotient.mk_eq_mk, eval₂_X_pow,\n        eval₂_smul, coe_eval₂_ring_hom, ring_hom.map_pow, eval₂_C, ring_hom.coe_comp,\n        ring_hom.map_mul, eval₂_X] },\n  end, }\n\n@[simp]\nlemma polynomial_quotient_equiv_quotient_polynomial_symm_mk (I : ideal R) (f : R[X]) :\n  I.polynomial_quotient_equiv_quotient_polynomial.symm (quotient.mk _ f) = f.map (quotient.mk I) :=\nby rw [polynomial_quotient_equiv_quotient_polynomial, ring_equiv.symm_mk, ring_equiv.coe_mk,\n  ideal.quotient.lift_mk, coe_eval₂_ring_hom, eval₂_eq_eval_map, ←polynomial.map_map,\n  ←eval₂_eq_eval_map, polynomial.eval₂_C_X]\n\n@[simp]\nlemma polynomial_quotient_equiv_quotient_polynomial_map_mk (I : ideal R) (f : R[X]) :\n  I.polynomial_quotient_equiv_quotient_polynomial (f.map I^.quotient.mk) = quotient.mk _ f :=\nbegin\n  apply (polynomial_quotient_equiv_quotient_polynomial I).symm.injective,\n  rw [ring_equiv.symm_apply_apply, polynomial_quotient_equiv_quotient_polynomial_symm_mk],\nend\n\n/-- If `P` is a prime ideal of `R`, then `R[x]/(P)` is an integral domain. -/\nlemma is_domain_map_C_quotient {P : ideal R} (H : is_prime P) :\n  is_domain (R[X] ⧸ (map C P : ideal R[X])) :=\nring_equiv.is_domain (polynomial (R ⧸ P))\n  (polynomial_quotient_equiv_quotient_polynomial P).symm\n\n/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/\nlemma is_prime_map_C_of_is_prime {P : ideal R} (H : is_prime P) :\n  is_prime (map C P : ideal R[X]) :=\n(quotient.is_domain_iff_prime (map C P : ideal R[X])).mp\n  (is_domain_map_C_quotient H)\n\n/-- Given any ring `R` and an ideal `I` of `polynomial R`, we get a map `R → R[x] → R[x]/I`.\n  If we let `R` be the image of `R` in `R[x]/I` then we also have a map `R[x] → R'[x]`.\n  In particular we can map `I` across this map, to get `I'` and a new map `R' → R'[x] → R'[x]/I`.\n  This theorem shows `I'` will not contain any non-zero constant polynomials\n  -/\nlemma eq_zero_of_polynomial_mem_map_range (I : ideal R[X])\n  (x : ((quotient.mk I).comp C).range)\n  (hx : C x ∈ (I.map (polynomial.map_ring_hom ((quotient.mk I).comp C).range_restrict))) :\n  x = 0 :=\nbegin\n  let i := ((quotient.mk I).comp C).range_restrict,\n  have hi' : (polynomial.map_ring_hom i).ker ≤ I,\n  { refine λ f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (λ n, _),\n    rw [mem_comap, ← quotient.eq_zero_iff_mem, ← ring_hom.comp_apply],\n    rw [ring_hom.mem_ker, coe_map_ring_hom] at hf,\n    replace hf := congr_arg (λ (f : polynomial _), f.coeff n) hf,\n    simp only [coeff_map, coeff_zero] at hf,\n    rwa [subtype.ext_iff, ring_hom.coe_range_restrict] at hf },\n  obtain ⟨x, hx'⟩ := x,\n  obtain ⟨y, rfl⟩ := (ring_hom.mem_range).1 hx',\n  refine subtype.eq _,\n  simp only [ring_hom.comp_apply, quotient.eq_zero_iff_mem, add_submonoid_class.coe_zero,\n    subtype.val_eq_coe],\n  suffices : C (i y) ∈ (I.map (polynomial.map_ring_hom i)),\n  { obtain ⟨f, hf⟩ := mem_image_of_mem_map_of_surjective (polynomial.map_ring_hom i)\n      (polynomial.map_surjective _ (((quotient.mk I).comp C).range_restrict_surjective)) this,\n    refine sub_add_cancel (C y) f ▸ I.add_mem (hi' _ : (C y - f) ∈ I) hf.1,\n    rw [ring_hom.mem_ker, ring_hom.map_sub, hf.2, sub_eq_zero, coe_map_ring_hom, map_C] },\n  exact hx,\nend\n\n/-- `polynomial R` is never a field for any ring `R`. -/\nlemma polynomial_not_is_field : ¬ is_field R[X] :=\nbegin\n  by_contradiction hR,\n  by_cases hR' : ∃ (x y : R), x ≠ y,\n  { haveI : nontrivial R := let ⟨x, y, hxy⟩ := hR' in nontrivial_of_ne x y hxy,\n    obtain ⟨p, hp⟩ := hR.mul_inv_cancel X_ne_zero,\n    by_cases hp0 : p = 0,\n    { replace hp := congr_arg degree hp,\n      rw [hp0, mul_zero, degree_zero, degree_one] at hp,\n      contradiction },\n    { have : p.degree < (X * p).degree := (mul_comm p X) ▸ degree_lt_degree_mul_X hp0,\n      rw [congr_arg degree hp, degree_one, nat.with_bot.lt_zero_iff, degree_eq_bot] at this,\n      exact hp0 this } },\n  { push_neg at hR',\n    exact let ⟨x, y, hxy⟩ := hR.exists_pair_ne in hxy (polynomial.ext (λ n, hR' _ _)) }\nend\n\n/-- The only constant in a maximal ideal over a field is `0`. -/\nlemma eq_zero_of_constant_mem_of_maximal (hR : is_field R)\n  (I : ideal R[X]) [hI : I.is_maximal] (x : R) (hx : C x ∈ I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (λ hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain ⟨y, hy⟩ := hR.mul_inv_cancel hx0,\n  convert I.mul_mem_left (C y) hx,\n  rw [← C.map_mul, mul_comm y x, hy, ring_hom.map_one],\nend\n\n/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/\ndef of_polynomial (I : ideal R[X]) : submodule R R[X] :=\n{ carrier := I.carrier,\n  zero_mem' := I.zero_mem,\n  add_mem' := λ _ _, I.add_mem,\n  smul_mem' := λ c x H, by { rw [← C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal R[X]}\ntheorem mem_of_polynomial (x) : x ∈ I.of_polynomial ↔ x ∈ I := iff.rfl\nvariables (I)\n\n/-- Given an ideal `I` of `R[X]`, make the `R`-submodule of `I`\nconsisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R R[X] :=\ndegree_le R n ⊓ I.of_polynomial\n\n/-- Given an ideal `I` of `R[X]`, make the ideal in `R` of\nleading coefficients of polynomials in `I` with degree ≤ `n`. -/\ndef leading_coeff_nth (n : ℕ) : ideal R :=\n(I.degree_le n).map $ lcoeff R n\n\ntheorem mem_leading_coeff_nth (n : ℕ) (x) :\n  x ∈ I.leading_coeff_nth n ↔ ∃ p ∈ I, degree p ≤ n ∧ leading_coeff p = x :=\nbegin\n  simp only [leading_coeff_nth, degree_le, submodule.mem_map, lcoeff_apply, submodule.mem_inf,\n    mem_degree_le],\n  split,\n  { rintro ⟨p, ⟨hpdeg, hpI⟩, rfl⟩,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine ⟨0, I.zero_mem, bot_le, _⟩,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine ⟨p, hpI, le_of_eq hpdeg, _⟩,\n      rw [leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro ⟨p, hpI, hpdeg, rfl⟩,\n    have : nat_degree p + (n - nat_degree p) = n,\n    { exact add_tsub_cancel_of_le (nat_degree_le_of_degree_le hpdeg) },\n    refine ⟨p * X ^ (n - nat_degree p), ⟨_, I.mul_mem_right _ hpI⟩, _⟩,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [← with_bot.coe_add, this],\n      exact le_rfl },\n    { rw [leading_coeff, ← coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x ∈ I.leading_coeff_nth 0 ↔ C x ∈ I :=\n(mem_leading_coeff_nth _ _ _).trans\n⟨λ ⟨p, hpI, hpdeg, hpx⟩, by rwa [← hpx, leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  ← eq_C_of_degree_le_zero hpdeg],\nλ hx, ⟨C x, hx, degree_C_le, leading_coeff_C x⟩⟩\n\ntheorem leading_coeff_nth_mono {m n : ℕ} (H : m ≤ n) :\n  I.leading_coeff_nth m ≤ I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr ⊢,\n  rcases hr with ⟨p, hpI, hpdeg, rfl⟩,\n  refine ⟨p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow⟩,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [← with_bot.coe_add, add_tsub_cancel_of_le H],\n  exact le_rfl\nend\n\n/-- Given an ideal `I` in `R[X]`, make the ideal in `R` of the\nleading coefficients in `I`. -/\ndef leading_coeff : ideal R :=\n⨆ n : ℕ, I.leading_coeff_nth n\n\ntheorem mem_leading_coeff (x) :\n  x ∈ I.leading_coeff ↔ ∃ p ∈ I, polynomial.leading_coeff p = x :=\nbegin\n  rw [leading_coeff, submodule.mem_supr_of_directed],\n  simp only [mem_leading_coeff_nth],\n  { split, { rintro ⟨i, p, hpI, hpdeg, rfl⟩, exact ⟨p, hpI, rfl⟩ },\n    rintro ⟨p, hpI, rfl⟩, exact ⟨nat_degree p, p, hpI, degree_le_nat_degree, rfl⟩ },\n  intros i j, exact ⟨i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)⟩\nend\n\ntheorem is_fg_degree_le [is_noetherian_ring R] (n : ℕ) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  ⟨_, degree_le_eq_span_X_pow.symm⟩) _\n\nend ideal\n\nsection prime\nvariables (σ) {r : R}\n\nnamespace polynomial\nlemma prime_C_iff : prime (C r) ↔ prime r :=\n⟨ comap_prime C (eval_ring_hom (0 : R)) (λ r, eval_C),\n  λ hr, by { have := hr.1,\n    rw ← ideal.span_singleton_prime at hr ⊢,\n    { convert ideal.is_prime_map_C_of_is_prime hr using 1,\n      rw [ideal.map_span, set.image_singleton] },\n    exacts [λ h, this (C_eq_zero.1 h), this] } ⟩\nend polynomial\n\nnamespace mv_polynomial\n\nprivate lemma prime_C_iff_of_fintype [fintype σ] : prime (C r : mv_polynomial σ R) ↔ prime r :=\nbegin\n  rw (rename_equiv R (fintype.equiv_fin σ)).to_mul_equiv.prime_iff,\n  convert_to prime (C r) ↔ _, { congr, apply rename_C },\n  { symmetry, induction fintype.card σ with d hd,\n    { exact (is_empty_alg_equiv R (fin 0)).to_mul_equiv.symm.prime_iff },\n    { rw [hd, ← polynomial.prime_C_iff],\n      convert (fin_succ_equiv R d).to_mul_equiv.symm.prime_iff,\n      rw ← fin_succ_equiv_comp_C_eq_C, refl } },\nend\n\nlemma prime_C_iff : prime (C r : mv_polynomial σ R) ↔ prime r :=\n⟨ comap_prime C constant_coeff constant_coeff_C,\n  λ hr, ⟨ λ h, hr.1 $ by { rw [← C_inj, h], simp },\n    λ h, hr.2.1 $ by { rw ← constant_coeff_C r, exact h.map _ },\n    λ a b hd, begin\n      obtain ⟨s,a',b',rfl,rfl⟩ := exists_finset_rename₂ a b,\n      rw ← algebra_map_eq at hd, have : algebra_map R _ r ∣ a' * b',\n      { convert (kill_compl subtype.coe_injective).to_ring_hom.map_dvd hd, simpa, simp },\n      rw ← rename_C (coe : s → σ), let f := (rename (coe : s → σ)).to_ring_hom,\n      exact (((prime_C_iff_of_fintype s).2 hr).2.2 a' b' this).imp f.map_dvd f.map_dvd,\n    end ⟩ ⟩\n\nvariable {σ}\nlemma prime_rename_iff (s : set σ) {p : mv_polynomial s R} :\n  prime (rename (coe : s → σ) p) ↔ prime p :=\nbegin\n  classical, symmetry, let eqv := (sum_alg_equiv R _ _).symm.trans\n    (rename_equiv R $ (equiv.sum_comm ↥sᶜ s).trans $ equiv.set.sum_compl s),\n  rw [← prime_C_iff ↥sᶜ, eqv.to_mul_equiv.prime_iff], convert iff.rfl,\n  suffices : (rename coe).to_ring_hom = eqv.to_alg_hom.to_ring_hom.comp C,\n  { apply ring_hom.congr_fun this },\n  { apply ring_hom_ext,\n    { intro, dsimp [eqv], erw [iter_to_sum_C_C, rename_C, rename_C] },\n    { intro, dsimp [eqv], erw [iter_to_sum_C_X, rename_X, rename_X], refl } },\nend\n\nend mv_polynomial\n\nend prime\n\nnamespace polynomial\n\n@[priority 100]\ninstance {R : Type*} [comm_ring R] [is_domain R] [wf_dvd_monoid R] :\n  wf_dvd_monoid R[X] :=\n{ well_founded_dvd_not_unit := begin\n    classical,\n    refine rel_hom_class.well_founded (⟨λ (p : R[X]),\n        ((if p = 0 then ⊤ else ↑p.degree : with_top (with_bot ℕ)), p.leading_coeff), _⟩ :\n        dvd_not_unit →r prod.lex (<) dvd_not_unit)\n      (prod.lex_wf (with_top.well_founded_lt $ with_bot.well_founded_lt nat.lt_wf)\n        ‹wf_dvd_monoid R›.well_founded_dvd_not_unit),\n    rintros a b ⟨ane0, ⟨c, ⟨not_unit_c, rfl⟩⟩⟩,\n    rw [polynomial.degree_mul, if_neg ane0],\n    split_ifs with hac,\n    { rw [hac, polynomial.leading_coeff_zero],\n      apply prod.lex.left,\n      exact lt_of_le_of_ne le_top with_top.coe_ne_top },\n    have cne0 : c ≠ 0 := right_ne_zero_of_mul hac,\n    simp only [cne0, ane0, polynomial.leading_coeff_mul],\n    by_cases hdeg : c.degree = 0,\n    { simp only [hdeg, add_zero],\n      refine prod.lex.right _ ⟨_, ⟨c.leading_coeff, (λ unit_c, not_unit_c _), rfl⟩⟩,\n      { rwa [ne, polynomial.leading_coeff_eq_zero] },\n      rw [polynomial.is_unit_iff, polynomial.eq_C_of_degree_eq_zero hdeg],\n      use [c.leading_coeff, unit_c],\n      rw [polynomial.leading_coeff, polynomial.nat_degree_eq_of_degree_eq_some hdeg] },\n    { apply prod.lex.left,\n      rw polynomial.degree_eq_nat_degree cne0 at *,\n      rw [with_top.coe_lt_coe, polynomial.degree_eq_nat_degree ane0,\n          ← with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (λ h, hdeg (h.symm ▸ with_bot.coe_zero))) },\n  end }\n\nend polynomial\n\n/-- Hilbert basis theorem: a polynomial ring over a noetherian ring is a noetherian ring. -/\nprotected theorem polynomial.is_noetherian_ring [is_noetherian_ring R] :\n  is_noetherian_ring R[X] :=\nis_noetherian_ring_iff.2 ⟨assume I : ideal R[X],\nlet M := well_founded.min (is_noetherian_iff_well_founded.1 (by apply_instance))\n  (set.range I.leading_coeff_nth) ⟨_, ⟨0, rfl⟩⟩ in\nhave hm : M ∈ set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet ⟨N, HN⟩ := hm, ⟨s, hs⟩ := I.is_fg_degree_le N in\nhave hm2 : ∀ k, I.leading_coeff_nth k ≤ M := λ k, or.cases_on (le_or_lt k N)\n  (λ h, HN ▸ I.leading_coeff_nth_mono h)\n  (λ h x hx, classical.by_contradiction $ λ hxm,\n    have ¬M < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact ⟨k, rfl⟩,\n    this ⟨HN ▸ I.leading_coeff_nth_mono (le_of_lt h), λ H, hxm (H hx)⟩),\nhave hs2 : ∀ {x}, x ∈ I.degree_le N → x ∈ ideal.span (↑s : set R[X]),\nfrom hs ▸ λ x hx, submodule.span_induction hx (λ _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (λ _ _, ideal.add_mem _) (λ c f hf, f.C_mul' c ▸ ideal.mul_mem_left _ _ hf),\n⟨s, le_antisymm\n  (ideal.span_le.2 $ λ x hx, have x ∈ I.degree_le N, from hs ▸ submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span R[X] ↑s = ideal.span ↑s, by refl,\n  rw this,\n  intros p hp, generalize hn : p.nat_degree = k,\n  induction k using nat.strong_induction_on with k ih generalizing p,\n  cases le_or_lt k N,\n  { subst k, refine hs2 ⟨polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp⟩ },\n  { have hp0 : p ≠ 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) ≠ 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [← h, mul_zero], refl },\n    haveI : nontrivial R := ⟨⟨0, 1, this⟩⟩,\n    have : p.leading_coeff ∈ I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        ⟨_, hp, hn ▸ polynomial.degree_le_nat_degree, rfl⟩) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with ⟨q, hq, hdq, hlqp⟩,\n    have hq0 : q ≠ 0,\n    { intro H, rw [← polynomial.leading_coeff_eq_zero] at H,\n      rw [hlqp, polynomial.leading_coeff_eq_zero] at H, exact hp0 H },\n    have h1 : p.degree = (q * polynomial.X ^ (k - q.nat_degree)).degree,\n    { rw [polynomial.degree_mul', polynomial.degree_X_pow],\n      rw [polynomial.degree_eq_nat_degree hp0, polynomial.degree_eq_nat_degree hq0],\n      rw [← with_bot.coe_add, add_tsub_cancel_of_le, hn],\n      { refine le_trans (polynomial.nat_degree_le_of_degree_le hdq) (le_of_lt h) },\n      rw [polynomial.leading_coeff_X_pow, mul_one],\n      exact mt polynomial.leading_coeff_eq_zero.1 hq0 },\n    have h2 : p.leading_coeff = (q * polynomial.X ^ (k - q.nat_degree)).leading_coeff,\n    { rw [← hlqp, polynomial.leading_coeff_mul_X_pow] },\n    have := polynomial.degree_sub_lt h1 hp0 h2,\n    rw [polynomial.degree_eq_nat_degree hp0] at this,\n    rw ← sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span ↑s).add_mem _ ((ideal.span ↑s).mul_mem_right _ _),\n    { by_cases hpq : p - q * polynomial.X ^ (k - q.nat_degree) = 0,\n      { rw hpq, exact ideal.zero_mem _ },\n      refine ih _ _ (I.sub_mem hp (I.mul_mem_right _ hq)) rfl,\n      rwa [polynomial.degree_eq_nat_degree hpq, with_bot.coe_lt_coe, hn] at this },\n    exact hs2 ⟨polynomial.mem_degree_le.2 hdq, hq⟩ }\nend⟩⟩\n\nattribute [instance] polynomial.is_noetherian_ring\n\nnamespace polynomial\n\ntheorem exists_irreducible_of_degree_pos\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : R[X]} (hf : 0 < f.degree) : ∃ g, irreducible g ∧ g ∣ f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (λ huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (λ hf0, not_lt_of_lt hf $ hf0.symm ▸ (@degree_zero R _).symm ▸ with_bot.bot_lt_coe _)\n\ntheorem exists_irreducible_of_nat_degree_pos\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : R[X]} (hf : 0 < f.nat_degree) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_degree_pos $ by { contrapose! hf, exact nat_degree_le_of_degree_le hf }\n\ntheorem exists_irreducible_of_nat_degree_ne_zero\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : R[X]} (hf : f.nat_degree ≠ 0) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_aeval\n  (f : M →ₗ[R] M) (v : M) :\n  linear_independent R (λ n : ℕ, (f ^ n) v)\n    ↔ ∀ (p : R[X]), aeval f p v = 0 → p = 0 :=\nbegin\n  rw linear_independent_iff,\n  simp only [finsupp.total_apply, aeval_endomorphism, forall_iff_forall_finsupp, sum, support,\n    coeff, of_finsupp_eq_zero],\n  exact iff.rfl,\nend\n\nlemma disjoint_ker_aeval_of_coprime\n  (f : M →ₗ[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  disjoint (aeval f p).ker (aeval f q).ker :=\nbegin\n  intros v hv,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  simpa [linear_map.mem_ker.1 (submodule.mem_inf.1 hv).1,\n         linear_map.mem_ker.1 (submodule.mem_inf.1 hv).2]\n    using congr_arg (λ p : R[X], aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M →ₗ[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).range ⊔ (aeval f q).range = ⊤ :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 ⟨aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 ⟨aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (λ p : R[X], aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M →ₗ[R] M} {p q : R[X]} :\n  (aeval f p).ker ⊔ (aeval f q).ker ≤ (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with ⟨x, hx, y, hy, hxy⟩,\n  have h_eval_x : aeval f (p * q) x = 0,\n  { rw [mul_comm, aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hx, linear_map.map_zero] },\n  have h_eval_y : aeval f (p * q) y = 0,\n  { rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hy, linear_map.map_zero] },\n  rw [linear_map.mem_ker, ←hxy, linear_map.map_add, h_eval_x, h_eval_y, add_zero],\nend\n\nlemma sup_ker_aeval_eq_ker_aeval_mul_of_coprime\n  (f : M →ₗ[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).ker ⊔ (aeval f q).ker = (aeval f (p * q)).ker :=\nbegin\n  apply le_antisymm sup_ker_aeval_le_ker_aeval_mul,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  have h_eval₂_qpp' := calc\n    aeval f (q * (p * p')) v = aeval f (p' * (p * q)) v :\n      by rw [mul_comm, mul_assoc, mul_comm, mul_assoc, mul_comm q p]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  have h_eval₂_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [←mul_assoc, mul_comm]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  rw aeval_mul at h_eval₂_qpp' h_eval₂_pqq',\n  refine ⟨aeval f (q * q') v, linear_map.mem_ker.1 h_eval₂_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval₂_qpp', _⟩,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa using congr_arg (λ p : R[X], aeval f p v) hpq'\nend\n\nend polynomial\n\nnamespace mv_polynomial\n\nlemma is_noetherian_ring_fin_0 [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial (fin 0) R) :=\nis_noetherian_ring_of_ring_equiv R\n  ((mv_polynomial.is_empty_ring_equiv R pempty).symm.trans\n   (rename_equiv R fin_zero_equiv'.symm).to_ring_equiv)\n\ntheorem is_noetherian_ring_fin [is_noetherian_ring R] :\n  ∀ {n : ℕ}, is_noetherian_ring (mv_polynomial (fin n) R)\n| 0 := is_noetherian_ring_fin_0\n| (n+1) :=\n  @is_noetherian_ring_of_ring_equiv (polynomial (mv_polynomial (fin n) R)) _ _ _\n    (mv_polynomial.fin_succ_equiv _ n).to_ring_equiv.symm\n    (@polynomial.is_noetherian_ring (mv_polynomial (fin n) R) _ (is_noetherian_ring_fin))\n\n/-- The multivariate polynomial ring in finitely many variables over a noetherian ring\nis itself a noetherian ring. -/\ninstance is_noetherian_ring [fintype σ] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial σ R) :=\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card σ)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin σ).symm).to_ring_equiv is_noetherian_ring_fin\n\nlemma is_domain_fin_zero (R : Type u) [comm_ring R] [is_domain R] :\n  is_domain (mv_polynomial (fin 0) R) :=\nring_equiv.is_domain R\n  ((rename_equiv R fin_zero_equiv').to_ring_equiv.trans\n    (mv_polynomial.is_empty_ring_equiv R pempty))\n\n/-- Auxiliary lemma:\nMultivariate polynomials over an integral domain\nwith variables indexed by `fin n` form an integral domain.\nThis fact is proven inductively,\nand then used to prove the general case without any finiteness hypotheses.\nSee `mv_polynomial.is_domain` for the general case. -/\nlemma is_domain_fin (R : Type u) [comm_ring R] [is_domain R] :\n  ∀ (n : ℕ), is_domain (mv_polynomial (fin n) R)\n| 0 := is_domain_fin_zero R\n| (n+1) :=\n  begin\n    haveI := is_domain_fin n,\n    exact ring_equiv.is_domain\n      (polynomial (mv_polynomial (fin n) R))\n      (mv_polynomial.fin_succ_equiv _ n).to_ring_equiv\n  end\n\n/-- Auxiliary definition:\nMultivariate polynomials in finitely many variables over an integral domain form an integral domain.\nThis fact is proven by transport of structure from the `mv_polynomial.is_domain_fin`,\nand then used to prove the general case without finiteness hypotheses.\nSee `mv_polynomial.is_domain` for the general case. -/\nlemma is_domain_fintype (R : Type u) (σ : Type v) [comm_ring R] [fintype σ]\n  [is_domain R] : is_domain (mv_polynomial σ R) :=\n@ring_equiv.is_domain _ (mv_polynomial (fin $ fintype.card σ) R) _ _\n  (mv_polynomial.is_domain_fin _ _)\n  (rename_equiv R (fintype.equiv_fin σ)).to_ring_equiv\n\nprotected theorem eq_zero_or_eq_zero_of_mul_eq_zero\n  {R : Type u} [comm_ring R] [is_domain R] {σ : Type v}\n  (p q : mv_polynomial σ R) (h : p * q = 0) : p = 0 ∨ q = 0 :=\nbegin\n  obtain ⟨s, p, rfl⟩ := exists_finset_rename p,\n  obtain ⟨t, q, rfl⟩ := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x ∈ s} → {x // x ∈ s ∪ t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x ∈ t} → {x // x ∈ s ∪ t}) q = 0,\n  { apply rename_injective _ subtype.val_injective, simpa using h },\n  letI := mv_polynomial.is_domain_fintype R {x // x ∈ (s ∪ t)},\n  rw mul_eq_zero at this,\n  cases this; [left, right],\n  all_goals { simpa using congr_arg (rename subtype.val) this }\nend\n\n/-- The multivariate polynomial ring over an integral domain is an integral domain. -/\ninstance {R : Type u} {σ : Type v} [comm_ring R] [is_domain R] :\n  is_domain (mv_polynomial σ R) :=\n{ eq_zero_or_eq_zero_of_mul_eq_zero := mv_polynomial.eq_zero_or_eq_zero_of_mul_eq_zero,\n  exists_pair_ne := ⟨0, 1, λ H,\n  begin\n    have : eval₂ (ring_hom.id _) (λ s, (0:R)) (0 : mv_polynomial σ R) =\n      eval₂ (ring_hom.id _) (λ s, (0:R)) (1 : mv_polynomial σ R),\n    { congr, exact H },\n    simpa,\n  end⟩,\n  .. (by apply_instance : comm_ring (mv_polynomial σ R)) }\n\nlemma map_mv_polynomial_eq_eval₂ {S : Type*} [comm_ring S] [fintype σ]\n  (ϕ : mv_polynomial σ R →+* S) (p : mv_polynomial σ R) :\n  ϕ p = mv_polynomial.eval₂ (ϕ.comp mv_polynomial.C) (λ s, ϕ (mv_polynomial.X s)) p :=\nbegin\n  refine trans (congr_arg ϕ (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval₂_eq', ϕ.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, ϕ.map_pow, ϕ.map_prod, ϕ.comp_apply, ϕ.map_mul, finsupp.prod_pow],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} {i : R} (hi : i ∈ I) :\n  (ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial σ R))).comp C i = 0 :=\nbegin\n  simp only [function.comp_app, ring_hom.coe_comp, ideal.quotient.eq_zero_iff_mem],\n  exact ideal.mem_map_of_mem _ hi\nend\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself,\nmultivariate version. -/\nlemma mem_ideal_of_coeff_mem_ideal (I : ideal (mv_polynomial σ R)) (p : mv_polynomial σ R)\n  (hcoe : ∀ (m : σ →₀ ℕ), p.coeff m ∈ I.comap C) : p ∈ I :=\nbegin\n  rw as_sum p,\n  suffices : ∀ m ∈ p.support, monomial m (mv_polynomial.coeff m p) ∈ I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [← mul_one (coeff m p), ← C_mul_monomial],\n  suffices : C (coeff m p) ∈ I,\n  { exact I.mul_mem_right (monomial m 1) this },\n  simpa [ideal.mem_comap] using hcoe m\nend\n\n/-- The push-forward of an ideal `I` of `R` to `mv_polynomial σ R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : mv_polynomial σ R} :\n  f ∈ (ideal.map C I : ideal (mv_polynomial σ R)) ↔ ∀ (m : σ →₀ ℕ), f.coeff m ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n    { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : ∀ m ∈ f.support, monomial m (coeff m f) ∈\n      (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [← mul_one (coeff m f), ← C_mul_monomial],\n    suffices : C (coeff m f) ∈ (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact ideal.mul_mem_right _ _ this },\n    apply ideal.mem_map_of_mem _,\n    exact hf m }\nend\n\nlemma ker_map (f : R →+* S) : (map f : mv_polynomial σ R →+* mv_polynomial σ S).ker = f.ker.map C :=\nbegin\n  ext,\n  rw [mv_polynomial.mem_map_C_iff, ring_hom.mem_ker, mv_polynomial.ext_iff],\n  simp_rw [coeff_map, coeff_zero, ring_hom.mem_ker],\nend\n\nlemma eval₂_C_mk_eq_zero {I : ideal R} {a : mv_polynomial σ R}\n  (ha : a ∈ (ideal.map C I : ideal (mv_polynomial σ R))) :\n  eval₂_hom (C.comp (ideal.quotient.mk I)) X a = 0 :=\nbegin\n  rw as_sum a,\n  rw [coe_eval₂_hom, eval₂_sum],\n  refine finset.sum_eq_zero (λ n hn, _),\n  simp only [eval₂_monomial, function.comp_app, ring_hom.coe_comp],\n  refine mul_eq_zero_of_left _ _,\n  suffices : coeff n a ∈ I,\n  { rw [← @ideal.mk_ker R _ I, ring_hom.mem_ker] at this,\n    simp only [this, C_0] },\n  exact mem_map_C_iff.1 ha n\nend\n\n/-- If `I` is an ideal of `R`, then the ring `mv_polynomial σ I.quotient` is isomorphic as an\n`R`-algebra to the quotient of `mv_polynomial σ R` by the ideal generated by `I`. -/\ndef quotient_equiv_quotient_mv_polynomial (I : ideal R) :\n  mv_polynomial σ (R ⧸ I) ≃ₐ[R]\n    mv_polynomial σ R ⧸ (ideal.map C I : ideal (mv_polynomial σ R)) :=\n{ to_fun := eval₂_hom (ideal.quotient.lift I ((ideal.quotient.mk (ideal.map C I : ideal\n    (mv_polynomial σ R))).comp C) (λ i hi, quotient_map_C_eq_zero hi))\n    (λ i, ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial σ R)) (X i)),\n  inv_fun := ideal.quotient.lift (ideal.map C I : ideal (mv_polynomial σ R))\n    (eval₂_hom (C.comp (ideal.quotient.mk I)) X) (λ a ha, eval₂_C_mk_eq_zero ha),\n  map_mul' := ring_hom.map_mul _,\n  map_add' := ring_hom.map_add _,\n  left_inv := begin\n    intro f,\n    apply induction_on f,\n    { rintro ⟨r⟩,\n      rw [coe_eval₂_hom, eval₂_C],\n      simp only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk,\n        ideal.quotient.mk_eq_mk, bind₂_C_right, ring_hom.coe_comp] },\n    { simp_intros p q hp hq only [ring_hom.map_add, mv_polynomial.coe_eval₂_hom, coe_eval₂_hom,\n        mv_polynomial.eval₂_add, mv_polynomial.eval₂_hom_eq_bind₂, eval₂_hom_eq_bind₂],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval₂_hom_eq_bind₂, coe_eval₂_hom],\n      simp only [hp, eval₂_hom_eq_bind₂, coe_eval₂_hom, ideal.quotient.lift_mk, bind₂_X_right,\n        eval₂_mul, ring_hom.map_mul, eval₂_X] }\n  end,\n  right_inv := begin\n    rintro ⟨f⟩,\n    apply induction_on f,\n    { intros r,\n      simp only [submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk,\n        ring_hom.coe_comp, eval₂_hom_C] },\n    { simp_intros p q hp hq only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, eval₂_add,\n        ring_hom.map_add, coe_eval₂_hom, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, coe_eval₂_hom,\n        ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk, bind₂_X_right, eval₂_mul, ring_hom.map_mul,\n        eval₂_X],\n      simp only [hp] }\n  end,\n  commutes' := λ r, eval₂_hom_C _ _ (ideal.quotient.mk I r) }\n\nend mv_polynomial\n\nsection unique_factorization_domain\nvariables {D : Type u} [comm_ring D] [is_domain D] [unique_factorization_monoid D] (σ)\nopen unique_factorization_monoid\n\nnamespace polynomial\n\n@[priority 100]\ninstance unique_factorization_monoid : unique_factorization_monoid (polynomial D) :=\nbegin\n  haveI := arbitrary (normalization_monoid D),\n  haveI := to_normalized_gcd_monoid D,\n  exact ufm_of_gcd_of_wf_dvd_monoid\nend\n\nend polynomial\n\nnamespace mv_polynomial\n\nprivate lemma unique_factorization_monoid_of_fintype [fintype σ] :\n  unique_factorization_monoid (mv_polynomial σ D) :=\n(rename_equiv D (fintype.equiv_fin σ)).to_mul_equiv.symm.unique_factorization_monoid $\nbegin\n  induction fintype.card σ with d hd,\n  { apply (is_empty_alg_equiv D (fin 0)).to_mul_equiv.symm.unique_factorization_monoid,\n    apply_instance },\n  { apply (fin_succ_equiv D d).to_mul_equiv.symm.unique_factorization_monoid,\n    exactI polynomial.unique_factorization_monoid },\nend\n\n@[priority 100]\ninstance : unique_factorization_monoid (mv_polynomial σ D) :=\nbegin\n  rw iff_exists_prime_factors,\n  intros a ha, obtain ⟨s,a',rfl⟩ := exists_finset_rename a,\n  obtain ⟨w,h,u,hw⟩ := iff_exists_prime_factors.1\n    (unique_factorization_monoid_of_fintype s) a' (λ h, ha $ by simp [h]),\n  exact ⟨ w.map (rename coe),\n    λ b hb, let ⟨b',hb',he⟩ := multiset.mem_map.1 hb in he ▸ (prime_rename_iff ↑s).2 (h b' hb'),\n    units.map (@rename s σ D _ coe).to_ring_hom.to_monoid_hom u,\n    by erw [multiset.prod_hom, ← map_mul, hw] ⟩,\nend\n\nend mv_polynomial\nend unique_factorization_domain\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/ring_theory/polynomial/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.49813250551889077}}
{"text": "/-\nCopyright (c) 2019 Alexander Bentkamp. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alexander Bentkamp, François Dupuis\n-/\nimport analysis.convex.basic\nimport tactic.field_simp\nimport tactic.linarith\nimport tactic.ring\n\n/-!\n# Convex and concave functions\n\nThis file defines convex and concave functions in vector spaces and proves the finite Jensen\ninequality. The integral version can be found in `analysis.convex.integral`.\n\nA function `f : E → β` is `convex_on` a set `s` if `s` is itself a convex set, and for any two\npoints `x y ∈ s`, the segment joining `(x, f x)` to `(y, f y)` is above the graph of `f`.\nEquivalently, `convex_on 𝕜 f s` means that the epigraph `{p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2}` is\na convex set.\n\n## Main declarations\n\n* `convex_on 𝕜 s f`: The function `f` is convex on `s` with scalars `𝕜`.\n* `concave_on 𝕜 s f`: The function `f` is concave on `s` with scalars `𝕜`.\n* `strict_convex_on 𝕜 s f`: The function `f` is strictly convex on `s` with scalars `𝕜`.\n* `strict_concave_on 𝕜 s f`: The function `f` is strictly concave on `s` with scalars `𝕜`.\n-/\n\nopen finset linear_map set\nopen_locale big_operators classical convex pointwise\n\nvariables {𝕜 E F β ι : Type*}\n\nsection ordered_semiring\nvariables [ordered_semiring 𝕜]\n\nsection add_comm_monoid\nvariables [add_comm_monoid E] [add_comm_monoid F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection has_scalar\nvariables (𝕜) [has_scalar 𝕜 E] [has_scalar 𝕜 β] (s : set E) (f : E → β)\n\n/-- Convexity of functions -/\ndef convex_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 →\n    f (a • x + b • y) ≤ a • f x + b • f y\n\n/-- Concavity of functions -/\ndef concave_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 →\n    a • f x + b • f y ≤ f (a • x + b • y)\n\n/-- Strict convexity of functions -/\ndef strict_convex_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) < a • f x + b • f y\n\n/-- Strict concavity of functions -/\ndef strict_concave_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    a • f x + b • f y < f (a • x + b • y)\n\nvariables {𝕜 s f}\n\nopen order_dual (to_dual of_dual)\n\nlemma convex_on.dual (hf : convex_on 𝕜 s f) : concave_on 𝕜 s (to_dual ∘ f) := hf\n\nlemma concave_on.dual (hf : concave_on 𝕜 s f) : convex_on 𝕜 s (to_dual ∘ f) := hf\n\nlemma strict_convex_on.dual (hf : strict_convex_on 𝕜 s f) : strict_concave_on 𝕜 s (to_dual ∘ f) :=\nhf\n\nlemma strict_concave_on.dual (hf : strict_concave_on 𝕜 s f) : strict_convex_on 𝕜 s (to_dual ∘ f) :=\nhf\n\nlemma convex_on_id {s : set β} (hs : convex 𝕜 s) : convex_on 𝕜 s id := ⟨hs, by { intros, refl }⟩\n\nlemma concave_on_id {s : set β} (hs : convex 𝕜 s) : concave_on 𝕜 s id := ⟨hs, by { intros, refl }⟩\n\nlemma convex_on.subset {t : set E} (hf : convex_on 𝕜 t f) (hst : s ⊆ t) (hs : convex 𝕜 s) :\n  convex_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma concave_on.subset {t : set E} (hf : concave_on 𝕜 t f) (hst : s ⊆ t) (hs : convex 𝕜 s) :\n  concave_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma strict_convex_on.subset {t : set E} (hf : strict_convex_on 𝕜 t f) (hst : s ⊆ t)\n  (hs : convex 𝕜 s) :\n  strict_convex_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma strict_concave_on.subset {t : set E} (hf : strict_concave_on 𝕜 t f) (hst : s ⊆ t)\n  (hs : convex 𝕜 s) :\n  strict_concave_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nend has_scalar\n\nsection distrib_mul_action\nvariables [has_scalar 𝕜 E] [distrib_mul_action 𝕜 β] {s : set E} {f g : E → β}\n\nlemma convex_on.add (hf : convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) ≤ (a • f x + b • f y) + (a • g x + b • g y)\n      : add_le_add (hf.2 hx hy ha hb hab) (hg.2 hx hy ha hb hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma concave_on.add (hf : concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  concave_on 𝕜 s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [has_scalar 𝕜 E] [module 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on_const (c : β) (hs : convex 𝕜 s) : convex_on 𝕜 s (λ x:E, c) :=\n⟨hs, λ x y _ _ a b _ _ hab, (convex.combo_self hab c).ge⟩\n\nlemma concave_on_const (c : β) (hs : convex 𝕜 s) : concave_on 𝕜 s (λ x:E, c) :=\n@convex_on_const _ _ βᵒᵈ _ _ _ _ _ _ c hs\n\nlemma convex_on_of_convex_epigraph (h : convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2}) :\n  convex_on 𝕜 s f :=\n⟨λ x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) ⟨hx, le_rfl⟩ ⟨hy, le_rfl⟩ a b ha hb hab).1,\n  λ x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) ⟨hx, le_rfl⟩ ⟨hy, le_rfl⟩ a b ha hb hab).2⟩\n\nlemma concave_on_of_convex_hypograph (h : convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1}) :\n  concave_on 𝕜 s f :=\n@convex_on_of_convex_epigraph 𝕜  E βᵒᵈ _ _ _ _ _ _ _ h\n\nend module\n\nsection ordered_smul\nvariables [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.convex_le (hf : convex_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | f x ≤ r} :=\nλ x y hx hy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha hb hab,\n  calc\n    f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx.1 hy.1 ha hb hab\n                  ... ≤ a • r + b • r     : add_le_add (smul_le_smul_of_nonneg hx.2 ha)\n                                              (smul_le_smul_of_nonneg hy.2 hb)\n                  ... = r                 : convex.combo_self hab r⟩\n\nlemma concave_on.convex_ge (hf : concave_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | r ≤ f x} :=\nhf.dual.convex_le r\n\nlemma convex_on.convex_epigraph (hf : convex_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2} :=\nbegin\n  rintro ⟨x, r⟩ ⟨y, t⟩ ⟨hx, hr⟩ ⟨hy, ht⟩ a b ha hb hab,\n  refine ⟨hf.1 hx hy ha hb hab, _⟩,\n  calc f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx hy ha hb hab\n  ... ≤ a • r + b • t : add_le_add (smul_le_smul_of_nonneg hr ha)\n                            (smul_le_smul_of_nonneg ht hb)\nend\n\nlemma concave_on.convex_hypograph (hf : concave_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1} :=\nhf.dual.convex_epigraph\n\nlemma convex_on_iff_convex_epigraph :\n  convex_on 𝕜 s f ↔ convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2} :=\n⟨convex_on.convex_epigraph, convex_on_of_convex_epigraph⟩\n\nlemma concave_on_iff_convex_hypograph :\n  concave_on 𝕜 s f ↔ convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1} :=\n@convex_on_iff_convex_epigraph 𝕜 E βᵒᵈ _ _ _ _ _ _ _ f\n\nend ordered_smul\n\nsection module\nvariables [module 𝕜 E] [has_scalar 𝕜 β] {s : set E} {f : E → β}\n\n/-- Right translation preserves convexity. -/\nlemma convex_on.translate_right (hf : convex_on 𝕜 s f) (c : E) :\n  convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\n⟨hf.1.translate_preimage_right _, λ x y hx hy a b ha hb hab,\n  calc\n    f (c + (a • x + b • y)) = f (a • (c + x) + b • (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... ≤ a • f (c + x) + b • f (c + y) : hf.2 hx hy ha hb hab⟩\n\n/-- Right translation preserves concavity. -/\nlemma concave_on.translate_right (hf : concave_on 𝕜 s f) (c : E) :\n  concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves convexity. -/\nlemma convex_on.translate_left (hf : convex_on 𝕜 s f) (c : E) :\n  convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\n/-- Left translation preserves concavity. -/\nlemma concave_on.translate_left (hf : concave_on 𝕜 s f) (c : E) :\n  concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nhf.dual.translate_left _\n\nend module\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β]\n\nlemma convex_on_iff_forall_pos {s : set E} {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧\n    ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → f (a • x + b • y) ≤ a • f x + b • f y :=\nbegin\n  refine and_congr_right' ⟨λ h x y hx hy a b ha hb hab, h hx hy ha.le hb.le hab,\n    λ h x y hx hy a b ha hb hab, _⟩,\n  obtain rfl | ha' := ha.eq_or_lt,\n  { rw [zero_add] at hab, subst b, simp_rw [zero_smul, zero_add, one_smul] },\n  obtain rfl | hb' := hb.eq_or_lt,\n  { rw [add_zero] at hab, subst a, simp_rw [zero_smul, add_zero, one_smul] },\n  exact h hx hy ha' hb' hab,\nend\n\nlemma concave_on_iff_forall_pos {s : set E} {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧\n    ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → a • f x + b • f y ≤ f (a • x + b • y) :=\n@convex_on_iff_forall_pos 𝕜 E βᵒᵈ _ _ _ _ _ _ _\n\nlemma convex_on_iff_pairwise_pos {s : set E} {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧\n    s.pairwise (λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → f (a • x + b • y) ≤ a • f x + b • f y) :=\nbegin\n  rw convex_on_iff_forall_pos,\n  refine and_congr_right' ⟨λ h x hx y hy _ a b ha hb hab, h hx hy ha hb hab,\n    λ h x y hx hy a b ha hb hab, _⟩,\n  obtain rfl | hxy := eq_or_ne x y,\n  { rw [convex.combo_self hab, convex.combo_self hab] },\n  exact h hx hy hxy ha hb hab,\nend\n\nlemma concave_on_iff_pairwise_pos {s : set E} {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧\n   s.pairwise (λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → a • f x + b • f y ≤ f (a • x + b • y)) :=\n@convex_on_iff_pairwise_pos 𝕜 E βᵒᵈ _ _ _ _ _ _ _\n\n/-- A linear map is convex. -/\nlemma linear_map.convex_on (f : E →ₗ[𝕜] β) {s : set E} (hs : convex 𝕜 s) : convex_on 𝕜 s f :=\n⟨hs, λ _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]⟩\n\n/-- A linear map is concave. -/\nlemma linear_map.concave_on (f : E →ₗ[𝕜] β) {s : set E} (hs : convex 𝕜 s) : concave_on 𝕜 s f :=\n⟨hs, λ _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]⟩\n\nlemma strict_convex_on.convex_on {s : set E} {f : E → β} (hf : strict_convex_on 𝕜 s f) :\n  convex_on 𝕜 s f :=\nconvex_on_iff_pairwise_pos.mpr ⟨hf.1, λ x hx y hy hxy a b ha hb hab, (hf.2 hx hy hxy ha hb hab).le⟩\n\nlemma strict_concave_on.concave_on {s : set E} {f : E → β} (hf : strict_concave_on 𝕜 s f) :\n  concave_on 𝕜 s f :=\nhf.dual.convex_on\n\nsection ordered_smul\nvariables [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma strict_convex_on.convex_lt (hf : strict_convex_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | f x < r} :=\nconvex_iff_pairwise_pos.2 $ λ x hx y hy hxy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a • x + b • y) < a • f x + b • f y : hf.2 hx.1 hy.1 hxy ha hb hab\n                  ... ≤ a • r + b • r     : add_le_add (smul_lt_smul_of_pos hx.2 ha).le\n                                              (smul_lt_smul_of_pos hy.2 hb).le\n                  ... = r                 : convex.combo_self hab r⟩\n\nlemma strict_concave_on.convex_gt (hf : strict_concave_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | r < f x} :=\nhf.dual.convex_lt r\n\nend ordered_smul\n\nsection linear_order\nvariables [linear_order E] {s : set E} {f : E → β}\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is convex, it suffices to\nverify the inequality `f (a • x + b • y) ≤ a • f x + b • f y` only for `x < y` and positive `a`,\n`b`. The main use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order.\n-/\nlemma linear_order.convex_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) ≤ a • f x + b • f y) : convex_on 𝕜 s f :=\nbegin\n  refine convex_on_iff_pairwise_pos.2 ⟨hs, λ x hx y hy hxy a b ha hb hab, _⟩,\n  wlog h : x ≤ y using [x y a b, y x b a],\n  { exact le_total _ _ },\n  exact hf hx hy (h.lt_of_ne hxy) ha hb hab,\nend\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is concave it suffices to\nverify the inequality `a • f x + b • f y ≤ f (a • x + b • y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = ℝ` however one can apply it, e.g., to `ℝ^n` with lexicographic order. -/\nlemma linear_order.concave_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n     a • f x + b • f y ≤ f (a • x + b • y)) : concave_on 𝕜 s f :=\n@linear_order.convex_on_of_lt _ _ βᵒᵈ _ _ _ _ _ _ s f hs hf\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is convex, it suffices to\nverify the inequality `f (a • x + b • y) ≤ a • f x + b • f y` for `x < y` and positive `a`, `b`. The\nmain use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order. -/\nlemma linear_order.strict_convex_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) < a • f x + b • f y) : strict_convex_on 𝕜 s f :=\nbegin\n  refine ⟨hs, λ x y hx hy hxy a b ha hb hab, _⟩,\n  wlog h : x ≤ y using [x y a b, y x b a],\n  { exact le_total _ _ },\n  exact hf hx hy (h.lt_of_ne hxy) ha hb hab,\nend\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is concave it suffices to\nverify the inequality `a • f x + b • f y ≤ f (a • x + b • y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order. -/\nlemma linear_order.strict_concave_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n     a • f x + b • f y < f (a • x + b • y)) : strict_concave_on 𝕜 s f :=\n@linear_order.strict_convex_on_of_lt _ _ βᵒᵈ _ _ _ _ _ _ _ _ hs hf\n\nend linear_order\nend module\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 F] [has_scalar 𝕜 β]\n\n/-- If `g` is convex on `s`, so is `(f ∘ g)` on `f ⁻¹' s` for a linear `f`. -/\nlemma convex_on.comp_linear_map {f : F → β} {s : set F} (hf : convex_on 𝕜 s f) (g : E →ₗ[𝕜] F) :\n  convex_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\n⟨hf.1.linear_preimage _, λ x y hx hy a b ha hb hab,\n  calc\n    f (g (a • x + b • y)) = f (a • (g x) + b • (g y)) : by rw [g.map_add, g.map_smul, g.map_smul]\n                      ... ≤ a • f (g x) + b • f (g y) : hf.2 hx hy ha hb hab⟩\n\n/-- If `g` is concave on `s`, so is `(g ∘ f)` on `f ⁻¹' s` for a linear `f`. -/\nlemma concave_on.comp_linear_map {f : F → β} {s : set F} (hf : concave_on 𝕜 s f) (g : E →ₗ[𝕜] F) :\n  concave_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\nhf.dual.comp_linear_map g\n\nend module\nend ordered_add_comm_monoid\n\nsection ordered_cancel_add_comm_monoid\nvariables [ordered_cancel_add_comm_monoid β]\n\nsection distrib_mul_action\nvariables [has_scalar 𝕜 E] [distrib_mul_action 𝕜 β] {s : set E} {f g : E → β}\n\nlemma strict_convex_on.add_convex_on (hf : strict_convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) < (a • f x + b • f y) + (a • g x + b • g y)\n      : add_lt_add_of_lt_of_le (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy ha.le hb.le hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma convex_on.add_strict_convex_on (hf : convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f + g) :=\n(add_comm g f) ▸ hg.add_convex_on hf\n\nlemma strict_convex_on.add (hf : strict_convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) < (a • f x + b • f y) + (a • g x + b • g y)\n      : add_lt_add (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy hxy ha hb hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma strict_concave_on.add_concave_on (hf : strict_concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f + g) :=\nhf.dual.add_convex_on hg.dual\n\nlemma concave_on.add_strict_concave_on (hf : concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f + g) :=\nhf.dual.add_strict_convex_on hg.dual\n\nlemma strict_concave_on.add (hf : strict_concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.convex_lt (hf : convex_on 𝕜 s f) (r : β) : convex 𝕜 {x ∈ s | f x < r} :=\nconvex_iff_forall_pos.2 $ λ x y hx hy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a • x + b • y)\n        ≤ a • f x + b • f y : hf.2 hx.1 hy.1 ha.le hb.le hab\n    ... < a • r + b • r     : add_lt_add_of_lt_of_le (smul_lt_smul_of_pos hx.2 ha)\n                                (smul_le_smul_of_nonneg hy.2.le hb.le)\n    ... = r                 : convex.combo_self hab _⟩\n\nlemma concave_on.convex_gt (hf : concave_on 𝕜 s f) (r : β) : convex 𝕜 {x ∈ s | r < f x} :=\nhf.dual.convex_lt r\n\nlemma convex_on.open_segment_subset_strict_epigraph (hf : convex_on 𝕜 s f) (p q : E × β)\n  (hp : p.1 ∈ s ∧ f p.1 < p.2) (hq : q.1 ∈ s ∧ f q.1 ≤ q.2) :\n  open_segment 𝕜 p q ⊆ {p : E × β | p.1 ∈ s ∧ f p.1 < p.2} :=\nbegin\n  rintro _ ⟨a, b, ha, hb, hab, rfl⟩,\n  refine ⟨hf.1 hp.1 hq.1 ha.le hb.le hab, _⟩,\n  calc f (a • p.1 + b • q.1) ≤ a • f p.1 + b • f q.1 : hf.2 hp.1 hq.1 ha.le hb.le hab\n  ... < a • p.2 + b • q.2 :\n    add_lt_add_of_lt_of_le (smul_lt_smul_of_pos hp.2 ha) (smul_le_smul_of_nonneg hq.2 hb.le)\nend\n\nlemma concave_on.open_segment_subset_strict_hypograph (hf : concave_on 𝕜 s f) (p q : E × β)\n  (hp : p.1 ∈ s ∧ p.2 < f p.1) (hq : q.1 ∈ s ∧ q.2 ≤ f q.1) :\n  open_segment 𝕜 p q ⊆ {p : E × β | p.1 ∈ s ∧ p.2 < f p.1} :=\nhf.dual.open_segment_subset_strict_epigraph p q hp hq\n\nlemma convex_on.convex_strict_epigraph (hf : convex_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 < p.2} :=\nconvex_iff_open_segment_subset.mpr $\n  λ p q hp hq, hf.open_segment_subset_strict_epigraph p q hp ⟨hq.1, hq.2.le⟩\n\nlemma concave_on.convex_strict_hypograph (hf : concave_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 < f p.1} :=\nhf.dual.convex_strict_epigraph\n\nend module\nend ordered_cancel_add_comm_monoid\n\nsection linear_ordered_add_comm_monoid\nvariables [linear_ordered_add_comm_monoid β] [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β]\n  {s : set E} {f g : E → β}\n\n/-- The pointwise maximum of convex functions is convex. -/\nlemma convex_on.sup (hf : convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  convex_on 𝕜 s (f ⊔ g) :=\nbegin\n  refine ⟨hf.left, λ x y hx hy a b ha hb hab, sup_le _ _⟩,\n  { calc f (a • x + b • y) ≤ a • f x + b • f y : hf.right hx hy ha hb hab\n     ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n     (smul_le_smul_of_nonneg le_sup_left ha)\n     (smul_le_smul_of_nonneg le_sup_left hb) },\n  { calc g (a • x + b • y) ≤ a • g x + b • g y : hg.right hx hy ha hb hab\n     ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n     (smul_le_smul_of_nonneg le_sup_right ha)\n     (smul_le_smul_of_nonneg le_sup_right hb) }\nend\n\n/-- The pointwise minimum of concave functions is concave. -/\nlemma concave_on.inf (hf : concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  concave_on 𝕜 s (f ⊓ g) :=\nhf.dual.sup hg\n\n/-- The pointwise maximum of strictly convex functions is strictly convex. -/\nlemma strict_convex_on.sup (hf : strict_convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f ⊔ g) :=\n⟨hf.left, λ x y hx hy hxy a b ha hb hab, max_lt\n  (calc f (a • x + b • y) < a • f x + b • f y : hf.2 hx hy hxy ha hb hab\n    ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n    (smul_le_smul_of_nonneg le_sup_left ha.le)\n    (smul_le_smul_of_nonneg le_sup_left hb.le))\n  (calc g (a • x + b • y) < a • g x + b • g y : hg.2 hx hy hxy ha hb hab\n    ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n    (smul_le_smul_of_nonneg le_sup_right ha.le)\n    (smul_le_smul_of_nonneg le_sup_right hb.le))⟩\n\n/-- The pointwise minimum of strictly concave functions is strictly concave. -/\nlemma strict_concave_on.inf (hf : strict_concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n   strict_concave_on 𝕜 s (f ⊓ g) :=\nhf.dual.sup hg\n\n/-- A convex function on a segment is upper-bounded by the max of its endpoints. -/\nlemma convex_on.le_on_segment' (hf : convex_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) :\n  f (a • x + b • y) ≤ max (f x) (f y) :=\ncalc\n  f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx hy ha hb hab\n  ... ≤ a • max (f x) (f y) + b • max (f x) (f y) :\n    add_le_add (smul_le_smul_of_nonneg (le_max_left _ _) ha)\n      (smul_le_smul_of_nonneg (le_max_right _ _) hb)\n  ... = max (f x) (f y) : convex.combo_self hab _\n\n/-- A concave function on a segment is lower-bounded by the min of its endpoints. -/\nlemma concave_on.ge_on_segment' (hf : concave_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) :\n  min (f x) (f y) ≤ f (a • x + b • y) :=\nhf.dual.le_on_segment' hx hy ha hb hab\n\n/-- A convex function on a segment is upper-bounded by the max of its endpoints. -/\nlemma convex_on.le_on_segment (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s) (hy : y ∈ s)\n  (hz : z ∈ [x -[𝕜] y]) :\n  f z ≤ max (f x) (f y) :=\nlet ⟨a, b, ha, hb, hab, hz⟩ := hz in hz ▸ hf.le_on_segment' hx hy ha hb hab\n\n/-- A concave function on a segment is lower-bounded by the min of its endpoints. -/\nlemma concave_on.ge_on_segment (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s) (hy : y ∈ s)\n  (hz : z ∈ [x -[𝕜] y]) :\n  min (f x) (f y) ≤ f z :=\nhf.dual.le_on_segment hx hy hz\n\n/-- A strictly convex function on an open segment is strictly upper-bounded by the max of its\nendpoints. -/\nlemma strict_convex_on.lt_on_open_segment' (hf : strict_convex_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  f (a • x + b • y) < max (f x) (f y) :=\ncalc\n  f (a • x + b • y) < a • f x + b • f y : hf.2 hx hy hxy ha hb hab\n  ... ≤ a • max (f x) (f y) + b • max (f x) (f y) :\n    add_le_add (smul_le_smul_of_nonneg (le_max_left _ _) ha.le)\n      (smul_le_smul_of_nonneg (le_max_right _ _) hb.le)\n  ... = max (f x) (f y) : convex.combo_self hab _\n\n/-- A strictly concave function on an open segment is strictly lower-bounded by the min of its\nendpoints. -/\nlemma strict_concave_on.lt_on_open_segment' (hf : strict_concave_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  min (f x) (f y) < f (a • x + b • y) :=\nhf.dual.lt_on_open_segment' hx hy hxy ha hb hab\n\n/-- A strictly convex function on an open segment is strictly upper-bounded by the max of its\nendpoints. -/\nlemma strict_convex_on.lt_on_open_segment (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) (hz : z ∈ open_segment 𝕜 x y) :\n  f z < max (f x) (f y) :=\nlet ⟨a, b, ha, hb, hab, hz⟩ := hz in hz ▸ hf.lt_on_open_segment' hx hy hxy ha hb hab\n\n/-- A strictly concave function on an open segment is strictly lower-bounded by the min of its\nendpoints. -/\nlemma strict_concave_on.lt_on_open_segment (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) (hz : z ∈ open_segment 𝕜 x y) :\n  min (f x) (f y) < f z :=\nhf.dual.lt_on_open_segment hx hy hxy hz\n\nend linear_ordered_add_comm_monoid\n\nsection linear_ordered_cancel_add_comm_monoid\nvariables [linear_ordered_cancel_add_comm_monoid β]\n\nsection ordered_smul\nvariables [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f g : E → β}\n\nlemma convex_on.le_left_of_right_le' (hf : convex_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) (hfy : f y ≤ f (a • x + b • y)) :\n  f (a • x + b • y) ≤ f x :=\nle_of_not_lt $ λ h, lt_irrefl (f (a • x + b • y)) $\n  calc\n    f (a • x + b • y)\n        ≤ a • f x + b • f y : hf.2 hx hy ha.le hb hab\n    ... < a • f (a • x + b • y) + b • f (a • x + b • y)\n        : add_lt_add_of_lt_of_le (smul_lt_smul_of_pos h ha) (smul_le_smul_of_nonneg hfy hb)\n    ... = f (a • x + b • y) : convex.combo_self hab _\n\nlemma concave_on.left_le_of_le_right' (hf : concave_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) (hfy : f (a • x + b • y) ≤ f y) :\n  f x ≤ f (a • x + b • y) :=\nhf.dual.le_left_of_right_le' hx hy ha hb hab hfy\n\nlemma convex_on.le_right_of_left_le' (hf : convex_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x ≤ f (a • x + b • y)) :\n  f (a • x + b • y) ≤ f y :=\nbegin\n  rw add_comm at ⊢ hab hfx,\n  exact hf.le_left_of_right_le' hy hx hb ha hab hfx,\nend\n\nlemma concave_on.le_right_of_left_le' (hf : concave_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a • x + b • y) ≤ f x) :\n  f y ≤ f (a • x + b • y) :=\nhf.dual.le_right_of_left_le' hx hy ha hb hab hfx\n\nlemma convex_on.le_left_of_right_le (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f y ≤ f z) :\n  f z ≤ f x :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.le_left_of_right_le' hx hy ha hb.le hab hyz,\nend\n\nlemma concave_on.left_le_of_le_right (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f z ≤ f y) :\n  f x ≤ f z :=\nhf.dual.le_left_of_right_le hx hy hz hyz\n\nlemma convex_on.le_right_of_left_le (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f x ≤ f z) :\n  f z ≤ f y :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.le_right_of_left_le' hx hy ha.le hb hab hxz,\nend\n\nlemma concave_on.le_right_of_left_le (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f z ≤ f x) :\n  f y ≤ f z :=\nhf.dual.le_right_of_left_le hx hy hz hxz\n\nend ordered_smul\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f g : E → β}\n\n/- The following lemmas don't require `module 𝕜 E` if you add the hypothesis `x ≠ y`. At the time of\nthe writing, we decided the resulting lemmas wouldn't be useful. Feel free to reintroduce them. -/\nlemma strict_convex_on.lt_left_of_right_lt' (hf : strict_convex_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f y < f (a • x + b • y)) :\n  f (a • x + b • y) < f x :=\nnot_le.1 $ λ h, lt_irrefl (f (a • x + b • y)) $\n  calc\n    f (a • x + b • y)\n        < a • f x + b • f y : hf.2 hx hy begin\n            rintro rfl,\n            rw convex.combo_self hab at hfy,\n            exact lt_irrefl _ hfy,\n          end ha hb hab\n    ... < a • f (a • x + b • y) + b • f (a • x + b • y)\n        : add_lt_add_of_le_of_lt (smul_le_smul_of_nonneg h ha.le) (smul_lt_smul_of_pos hfy hb)\n    ... = f (a • x + b • y) : convex.combo_self hab _\n\nlemma strict_concave_on.left_lt_of_lt_right' (hf : strict_concave_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f (a • x + b • y) < f y) :\n  f x < f (a • x + b • y) :=\nhf.dual.lt_left_of_right_lt' hx hy ha hb hab hfy\n\nlemma strict_convex_on.lt_right_of_left_lt' (hf : strict_convex_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x < f (a • x + b • y)) :\n  f (a • x + b • y) < f y :=\nbegin\n  rw add_comm at ⊢ hab hfx,\n  exact hf.lt_left_of_right_lt' hy hx hb ha hab hfx,\nend\n\nlemma strict_concave_on.lt_right_of_left_lt' (hf : strict_concave_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a • x + b • y) < f x) :\n  f y < f (a • x + b • y) :=\nhf.dual.lt_right_of_left_lt' hx hy ha hb hab hfx\n\nlemma strict_convex_on.lt_left_of_right_lt (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f y < f z) :\n  f z < f x :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.lt_left_of_right_lt' hx hy ha hb hab hyz,\nend\n\nlemma strict_concave_on.left_lt_of_lt_right (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f z < f y) :\n  f x < f z :=\nhf.dual.lt_left_of_right_lt hx hy hz hyz\n\nlemma strict_convex_on.lt_right_of_left_lt (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f x < f z) :\n  f z < f y :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.lt_right_of_left_lt' hx hy ha hb hab hxz,\nend\n\nlemma strict_concave_on.lt_right_of_left_lt (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f z < f x) :\n  f y < f z :=\nhf.dual.lt_right_of_left_lt hx hy hz hxz\n\nend module\nend linear_ordered_cancel_add_comm_monoid\n\nsection ordered_add_comm_group\nvariables [ordered_add_comm_group β] [has_scalar 𝕜 E] [module 𝕜 β] {s : set E} {f g : E → β}\n\n/-- A function `-f` is convex iff `f` is concave. -/\n@[simp] lemma neg_convex_on_iff : convex_on 𝕜 s (-f) ↔ concave_on 𝕜 s f :=\nbegin\n  split,\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy a b ha hb hab, _⟩,\n    simp [neg_apply, neg_le, add_comm] at h,\n    exact h hx hy ha hb hab },\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy a b ha hb hab, _⟩,\n    rw ←neg_le_neg_iff,\n    simp_rw [neg_add, pi.neg_apply, smul_neg, neg_neg],\n    exact h hx hy ha hb hab }\nend\n\n/-- A function `-f` is concave iff `f` is convex. -/\n@[simp] lemma neg_concave_on_iff : concave_on 𝕜 s (-f) ↔ convex_on 𝕜 s f:=\nby rw [← neg_convex_on_iff, neg_neg f]\n\n/-- A function `-f` is strictly convex iff `f` is strictly concave. -/\n@[simp] lemma neg_strict_convex_on_iff : strict_convex_on 𝕜 s (-f) ↔ strict_concave_on 𝕜 s f :=\nbegin\n  split,\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy hxy a b ha hb hab, _⟩,\n    simp [neg_apply, neg_lt, add_comm] at h,\n    exact h hx hy hxy ha hb hab },\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy hxy a b ha hb hab, _⟩,\n    rw ←neg_lt_neg_iff,\n    simp_rw [neg_add, pi.neg_apply, smul_neg, neg_neg],\n    exact h hx hy hxy ha hb hab }\nend\n\n/-- A function `-f` is strictly concave iff `f` is strictly convex. -/\n@[simp] lemma neg_strict_concave_on_iff : strict_concave_on 𝕜 s (-f) ↔ strict_convex_on 𝕜 s f :=\nby rw [← neg_strict_convex_on_iff, neg_neg f]\n\nalias neg_convex_on_iff ↔ _ concave_on.neg\nalias neg_concave_on_iff ↔ _ convex_on.neg\nalias neg_strict_convex_on_iff ↔ _ strict_concave_on.neg\nalias neg_strict_concave_on_iff ↔ _ strict_convex_on.neg\n\nlemma convex_on.sub (hf : convex_on 𝕜 s f) (hg : concave_on 𝕜 s g) : convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma concave_on.sub (hf : concave_on 𝕜 s f) (hg : convex_on 𝕜 s g) : concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma strict_convex_on.sub (hf : strict_convex_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma strict_concave_on.sub (hf : strict_concave_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma convex_on.sub_strict_concave_on (hf : convex_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_strict_convex_on hg.neg\n\nlemma concave_on.sub_strict_convex_on (hf : concave_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_strict_concave_on hg.neg\n\nlemma strict_convex_on.sub_concave_on (hf : strict_convex_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_convex_on hg.neg\n\nlemma strict_concave_on.sub_convex_on (hf : strict_concave_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_concave_on hg.neg\n\nend ordered_add_comm_group\nend add_comm_monoid\n\nsection add_cancel_comm_monoid\nvariables [add_cancel_comm_monoid E] [ordered_add_comm_monoid β] [module 𝕜 E] [has_scalar 𝕜 β]\n  {s : set E} {f : E → β}\n\n/-- Right translation preserves strict convexity. -/\nlemma strict_convex_on.translate_right (hf : strict_convex_on 𝕜 s f) (c : E) :\n  strict_convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\n⟨hf.1.translate_preimage_right _, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (c + (a • x + b • y)) = f (a • (c + x) + b • (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... < a • f (c + x) + b • f (c + y) : hf.2 hx hy ((add_right_injective c).ne hxy) ha hb hab⟩\n\n/-- Right translation preserves strict concavity. -/\nlemma strict_concave_on.translate_right (hf : strict_concave_on 𝕜 s f) (c : E) :\n  strict_concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves strict convexity. -/\nlemma strict_convex_on.translate_left (hf : strict_convex_on 𝕜 s f) (c : E) :\n  strict_convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\n/-- Left translation preserves strict concavity. -/\nlemma strict_concave_on.translate_left (hf : strict_concave_on 𝕜 s f) (c : E) :\n  strict_concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\nend add_cancel_comm_monoid\nend ordered_semiring\n\nsection ordered_comm_semiring\nvariables [ordered_comm_semiring 𝕜] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection module\nvariables [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.smul {c : 𝕜} (hc : 0 ≤ c) (hf : convex_on 𝕜 s f) : convex_on 𝕜 s (λ x, c • f x) :=\n⟨hf.1, λ x y hx hy a b ha hb hab,\n  calc\n    c • f (a • x + b • y) ≤ c • (a • f x + b • f y)\n      : smul_le_smul_of_nonneg (hf.2 hx hy ha hb hab) hc\n    ... = a • (c • f x) + b • (c • f y)\n      : by rw [smul_add, smul_comm c, smul_comm c]; apply_instance⟩\n\nlemma concave_on.smul {c : 𝕜} (hc : 0 ≤ c) (hf : concave_on 𝕜 s f) :\n  concave_on 𝕜 s (λ x, c • f x) :=\nhf.dual.smul hc\n\nend module\nend ordered_add_comm_monoid\nend ordered_comm_semiring\n\nsection ordered_ring\nvariables [linear_ordered_field 𝕜] [add_comm_group E] [add_comm_group F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 F] [has_scalar 𝕜 β]\n\n/-- If a function is convex on `s`, it remains convex when precomposed by an affine map. -/\nlemma convex_on.comp_affine_map {f : F → β} (g : E →ᵃ[𝕜] F) {s : set F} (hf : convex_on 𝕜 s f) :\n  convex_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\n⟨hf.1.affine_preimage _, λ x y hx hy a b ha hb hab,\n  calc\n    (f ∘ g) (a • x + b • y) = f (g (a • x + b • y))         : rfl\n                       ...  = f (a • (g x) + b • (g y))     : by rw [convex.combo_affine_apply hab]\n                       ...  ≤ a • f (g x) + b • f (g y)     : hf.2 hx hy ha hb hab⟩\n\n/-- If a function is concave on `s`, it remains concave when precomposed by an affine map. -/\nlemma concave_on.comp_affine_map {f : F → β} (g : E →ᵃ[𝕜] F) {s : set F} (hf : concave_on 𝕜 s f) :\n  concave_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\nhf.dual.comp_affine_map g\n\nend module\nend ordered_add_comm_monoid\nend ordered_ring\n\nsection linear_ordered_field\nvariables [linear_ordered_field 𝕜] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection has_scalar\nvariables [has_scalar 𝕜 E] [has_scalar 𝕜 β] {s : set E}\n\nlemma convex_on_iff_div {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → 0 < a + b\n  → f ((a/(a+b)) • x + (b/(a+b)) • y) ≤ (a/(a+b)) • f x + (b/(a+b)) • f y :=\nand_congr iff.rfl\n⟨begin\n  intros h x y hx hy a b ha hb hab,\n  apply h hx hy (div_nonneg ha hab.le) (div_nonneg hb hab.le),\n  rw [←add_div, div_self hab.ne'],\nend,\nbegin\n  intros h x y hx hy a b ha hb hab,\n  simpa [hab, zero_lt_one] using h hx hy ha hb,\nend⟩\n\nlemma concave_on_iff_div {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b\n  → 0 < a + b → (a/(a+b)) • f x + (b/(a+b)) • f y ≤ f ((a/(a+b)) • x + (b/(a+b)) • y) :=\n@convex_on_iff_div _ _ βᵒᵈ _ _ _ _ _ _ _\n\nlemma strict_convex_on_iff_div {f : E → β} :\n  strict_convex_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a\n    → 0 < b → f ((a/(a+b)) • x + (b/(a+b)) • y) < (a/(a+b)) • f x + (b/(a+b)) • f y :=\nand_congr iff.rfl\n⟨begin\n  intros h x y hx hy hxy a b ha hb,\n  have hab := add_pos ha hb,\n  apply h hx hy hxy (div_pos ha hab) (div_pos hb hab),\n  rw [←add_div, div_self hab.ne'],\nend,\nbegin\n  intros h x y hx hy hxy a b ha hb hab,\n  simpa [hab, zero_lt_one] using h hx hy hxy ha hb,\nend⟩\n\nlemma strict_concave_on_iff_div {f : E → β} :\n  strict_concave_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a\n    → 0 < b → (a/(a+b)) • f x + (b/(a+b)) • f y < f ((a/(a+b)) • x + (b/(a+b)) • y) :=\n@strict_convex_on_iff_div _ _ βᵒᵈ _ _ _ _ _ _ _\n\nend has_scalar\nend ordered_add_comm_monoid\nend linear_ordered_field\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/analysis/convex/function.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.7057850154599563, "lm_q1q2_score": 0.4981324967833507}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Scott Morrison, Mario Carneiro\n-/\nimport category_theory.concrete_category.bundled_hom\nimport category_theory.elementwise\nimport topology.continuous_function.basic\n\n/-!\n# Category instance for topological spaces\n\nWe introduce the bundled category `Top` of topological spaces together with the functors `discrete`\nand `trivial` from the category of types to `Top` which equip a type with the corresponding\ndiscrete, resp. trivial, topology. For a proof that these functors are left, resp. right adjoint\nto the forgetful functor, see `topology.category.Top.adjunctions`.\n-/\n\nopen category_theory\nopen topological_space\n\nuniverse u\n\n/-- The category of topological spaces and continuous maps. -/\ndef Top : Type (u+1) := bundled topological_space\n\nnamespace Top\n\ninstance bundled_hom : bundled_hom @continuous_map :=\n⟨@continuous_map.to_fun, @continuous_map.id, @continuous_map.comp, @continuous_map.coe_injective⟩\n\nattribute [derive [large_category, concrete_category]] Top\n\ninstance : has_coe_to_sort Top Type* := bundled.has_coe_to_sort\n\ninstance topological_space_unbundled (x : Top) : topological_space x := x.str\n\n@[simp] lemma id_app (X : Top.{u}) (x : X) :\n  (𝟙 X : X → X) x = x := rfl\n\n@[simp] lemma comp_app {X Y Z : Top.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :\n  (f ≫ g : X → Z) x = g (f x) := rfl\n\n/-- Construct a bundled `Top` from the underlying type and the typeclass. -/\ndef of (X : Type u) [topological_space X] : Top := ⟨X⟩\n\ninstance (X : Top) : topological_space X := X.str\n\n@[simp] lemma coe_of (X : Type u) [topological_space X] : (of X : Type u) = X := rfl\n\ninstance : inhabited Top := ⟨Top.of empty⟩\n\n/-- The discrete topology on any type. -/\ndef discrete : Type u ⥤ Top.{u} :=\n{ obj := λ X, ⟨X, ⊥⟩,\n  map := λ X Y f, { to_fun := f, continuous_to_fun := continuous_bot } }\n\ninstance {X : Type u} : discrete_topology (discrete.obj X) := ⟨rfl⟩\n\n/-- The trivial topology on any type. -/\ndef trivial : Type u ⥤ Top.{u} :=\n{ obj := λ X, ⟨X, ⊤⟩,\n  map := λ X Y f, { to_fun := f, continuous_to_fun := continuous_top } }\n\n/-- Any homeomorphisms induces an isomorphism in `Top`. -/\n@[simps] def iso_of_homeo {X Y : Top.{u}} (f : X ≃ₜ Y) : X ≅ Y :=\n{ hom := ⟨f⟩,\n  inv := ⟨f.symm⟩ }\n\n/-- Any isomorphism in `Top` induces a homeomorphism. -/\n@[simps] def homeo_of_iso {X Y : Top.{u}} (f : X ≅ Y) : X ≃ₜ Y :=\n{ to_fun := f.hom,\n  inv_fun := f.inv,\n  left_inv := λ x, by simp,\n  right_inv := λ x, by simp,\n  continuous_to_fun := f.hom.continuous,\n  continuous_inv_fun := f.inv.continuous }\n\n@[simp] lemma of_iso_of_homeo {X Y : Top.{u}} (f : X ≃ₜ Y) : homeo_of_iso (iso_of_homeo f) = f :=\nby { ext, refl }\n\n@[simp] lemma of_homeo_of_iso {X Y : Top.{u}} (f : X ≅ Y) : iso_of_homeo (homeo_of_iso f) = f :=\nby { ext, refl }\n\n@[simp]\nlemma open_embedding_iff_comp_is_iso {X Y Z : Top} (f : X ⟶ Y) (g : Y ⟶ Z) [is_iso g] :\n  open_embedding (f ≫ g) ↔ open_embedding f :=\n(Top.homeo_of_iso (as_iso g)).open_embedding.of_comp_iff f\n\n@[simp]\nlemma open_embedding_iff_is_iso_comp {X Y Z : Top} (f : X ⟶ Y) (g : Y ⟶ Z) [is_iso f] :\n  open_embedding (f ≫ g) ↔ open_embedding g :=\nbegin\n  split,\n  { intro h,\n    convert h.comp (Top.homeo_of_iso (as_iso f).symm).open_embedding,\n    exact congr_arg _ (is_iso.inv_hom_id_assoc f g).symm },\n  { exact λ h, h.comp (Top.homeo_of_iso (as_iso f)).open_embedding }\nend\n\nend Top\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/category/Top/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.49810725697555047}}
{"text": "/-\nCopyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Pierre-Alexandre Bazin\n-/\nimport algebra.direct_sum.module\nimport linear_algebra.isomorphisms\nimport group_theory.torsion\nimport ring_theory.coprime.ideal\nimport ring_theory.finiteness\n\n/-!\n# Torsion submodules\n\n## Main definitions\n\n* `torsion_of R M x` : the torsion ideal of `x`, containing all `a` such that `a • x = 0`.\n* `submodule.torsion_by R M a` : the `a`-torsion submodule, containing all elements `x` of `M` such\n  that `a • x = 0`.\n* `submodule.torsion_by_set R M s` : the submodule containing all elements `x` of `M` such that\n  `a • x = 0` for all `a` in `s`.\n* `submodule.torsion' R M S` : the `S`-torsion submodule, containing all elements `x` of `M` such\n  that `a • x = 0` for some `a` in `S`.\n* `submodule.torsion R M` : the torsion submoule, containing all elements `x` of `M` such that\n  `a • x = 0` for some non-zero-divisor `a` in `R`.\n* `module.is_torsion_by R M a` : the property that defines a `a`-torsion module. Similarly,\n  `is_torsion_by_set`, `is_torsion'` and `is_torsion`.\n* `module.is_torsion_by_set.module` : Creates a `R ⧸ I`-module from a `R`-module that\n  `is_torsion_by_set R _ I`.\n\n## Main statements\n\n* `quot_torsion_of_equiv_span_singleton` : isomorphism between the span of an element of `M` and\n  the quotient by its torsion ideal.\n* `torsion' R M S` and `torsion R M` are submodules.\n* `torsion_by_set_eq_torsion_by_span` : torsion by a set is torsion by the ideal generated by it.\n* `submodule.torsion_by_is_torsion_by` : the `a`-torsion submodule is a `a`-torsion module.\n  Similar lemmas for `torsion'` and `torsion`.\n* `submodule.torsion_by_is_internal` : a `∏ i, p i`-torsion module is the internal direct sum of its\n  `p i`-torsion submodules when the `p i` are pairwise coprime. A more general version with coprime\n  ideals is `submodule.torsion_by_set_is_internal`.\n* `submodule.no_zero_smul_divisors_iff_torsion_bot` : a module over a domain has\n  `no_zero_smul_divisors` (that is, there is no non-zero `a`, `x` such that `a • x = 0`)\n  iff its torsion submodule is trivial.\n* `submodule.quotient_torsion.torsion_eq_bot` : quotienting by the torsion submodule makes the\n  torsion submodule of the new module trivial. If `R` is a domain, we can derive an instance\n  `submodule.quotient_torsion.no_zero_smul_divisors : no_zero_smul_divisors R (M ⧸ torsion R M)`.\n\n## Notation\n\n* The notions are defined for a `comm_semiring R` and a `module R M`. Some additional hypotheses on\n  `R` and `M` are required by some lemmas.\n* The letters `a`, `b`, ... are used for scalars (in `R`), while `x`, `y`, ... are used for vectors\n  (in `M`).\n\n## Tags\n\nTorsion, submodule, module, quotient\n-/\n\nnamespace ideal\n\nsection\nvariables (R M : Type*) [semiring R] [add_comm_monoid M] [module R M]\n/--The torsion ideal of `x`, containing all `a` such that `a • x = 0`.-/\n@[simps] def torsion_of (x : M) : ideal R := (linear_map.to_span_singleton R M x).ker\nvariables {R M}\n@[simp] lemma mem_torsion_of_iff (x : M) (a : R) : a ∈ torsion_of R M x ↔ a • x = 0 := iff.rfl\nend\n\nsection\nvariables (R M : Type*) [ring R] [add_comm_group M] [module R M]\n/--The span of `x` in `M` is isomorphic to `R` quotiented by the torsion ideal of `x`.-/\nnoncomputable def quot_torsion_of_equiv_span_singleton (x : M) :\n  (R ⧸ torsion_of R M x) ≃ₗ[R] (R ∙ x) :=\n(linear_map.to_span_singleton R M x).quot_ker_equiv_range.trans $\nlinear_equiv.of_eq _ _ (linear_map.span_singleton_eq_range R M x).symm\n\nvariables {R M}\n@[simp] lemma quot_torsion_of_equiv_span_singleton_apply_mk (x : M) (a : R) :\n  quot_torsion_of_equiv_span_singleton R M x (submodule.quotient.mk a) =\n    a • ⟨x, submodule.mem_span_singleton_self x⟩ := rfl\nend\nend ideal\n\nopen_locale non_zero_divisors\n\nsection defs\n\nvariables (R M : Type*) [comm_semiring R] [add_comm_monoid M] [module R M]\n\nnamespace submodule\n\n/-- The `a`-torsion submodule for `a` in `R`, containing all elements `x` of `M` such that\n  `a • x = 0`. -/\n@[simps] def torsion_by (a : R) : submodule R M := (distrib_mul_action.to_linear_map _ _ a).ker\n\n/-- The submodule containing all elements `x` of `M` such that `a • x = 0` for all `a` in `s`. -/\n@[simps] def torsion_by_set (s : set R) : submodule R M := Inf (torsion_by R M '' s)\n\n/-- The `S`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some\n`a` in `S`. -/\n@[simps] def torsion' (S : Type*)\n  [comm_monoid S] [distrib_mul_action S M] [smul_comm_class S R M] :\n  submodule R M :=\n{ carrier := { x | ∃ a : S, a • x = 0 },\n  zero_mem' := ⟨1, smul_zero _⟩,\n  add_mem' := λ x y ⟨a, hx⟩ ⟨b, hy⟩,\n    ⟨b * a,\n      by rw [smul_add, mul_smul, mul_comm, mul_smul, hx, hy, smul_zero, smul_zero, add_zero]⟩,\n  smul_mem' := λ a x ⟨b, h⟩, ⟨b, by rw [smul_comm, h, smul_zero]⟩ }\n\n/-- The torsion submodule, containing all elements `x` of `M` such that  `a • x = 0` for some\n  non-zero-divisor `a` in `R`. -/\n@[reducible] def torsion := torsion' R M R⁰\n\nend submodule\n\nnamespace module\n\n/-- A `a`-torsion module is a module where every element is `a`-torsion. -/\n@[reducible] def is_torsion_by (a : R) := ∀ ⦃x : M⦄, a • x = 0\n\n/-- A module where every element is `a`-torsion for all `a` in `s`. -/\n@[reducible] def is_torsion_by_set (s : set R) := ∀ ⦃x : M⦄ ⦃a : s⦄, (a : R) • x = 0\n\n/-- A `S`-torsion module is a module where every element is `a`-torsion for some `a` in `S`. -/\n@[reducible] def is_torsion' (S : Type*) [has_scalar S M] := ∀ ⦃x : M⦄, ∃ a : S, a • x = 0\n\n/-- A torsion module is a module where every element is `a`-torsion for some non-zero-divisor `a`.\n-/\n@[reducible] def is_torsion := ∀ ⦃x : M⦄, ∃ a : R⁰, a • x = 0\n\nend module\n\nend defs\n\nvariables {R M : Type*}\n\nsection\nvariables [comm_semiring R] [add_comm_monoid M] [module R M] (s : set R) (a : R)\n\nnamespace submodule\n\n@[simp] lemma smul_torsion_by (x : torsion_by R M a) : a • x = 0 := subtype.ext x.prop\n@[simp] lemma smul_coe_torsion_by (x : torsion_by R M a) : a • (x : M) = 0 := x.prop\n@[simp] lemma mem_torsion_by_iff (x : M) : x ∈ torsion_by R M a ↔ a • x = 0 := iff.rfl\n\n@[simp] lemma mem_torsion_by_set_iff (x : M) :\n  x ∈ torsion_by_set R M s ↔ ∀ a : s, (a : R) • x = 0 :=\nbegin\n  refine ⟨λ h ⟨a, ha⟩, mem_Inf.mp h _ (set.mem_image_of_mem _ ha), λ h, mem_Inf.mpr _⟩,\n  rintro _ ⟨a, ha, rfl⟩, exact h ⟨a, ha⟩\nend\n\n@[simp] lemma torsion_by_singleton_eq : torsion_by_set R M {a} = torsion_by R M a :=\nbegin\n  ext x,\n  simp only [mem_torsion_by_set_iff, set_coe.forall, subtype.coe_mk, set.mem_singleton_iff,\n    forall_eq, mem_torsion_by_iff]\nend\n\n\n\n/-- Torsion by a set is torsion by the ideal generated by it. -/\nlemma torsion_by_set_eq_torsion_by_span :\n  torsion_by_set R M s = torsion_by_set R M (ideal.span s) :=\nbegin\n  refine le_antisymm (λ x hx, _) (torsion_by_set_le_torsion_by_set_of_subset subset_span),\n  rw mem_torsion_by_set_iff at hx ⊢,\n  suffices : ideal.span s ≤ ideal.torsion_of R M x,\n  { rintro ⟨a, ha⟩, exact this ha },\n  rw ideal.span_le, exact λ a ha, hx ⟨a, ha⟩\nend\n\nlemma torsion_by_span_singleton_eq : torsion_by_set R M (R ∙ a) = torsion_by R M a :=\n((torsion_by_set_eq_torsion_by_span _).symm.trans $ torsion_by_singleton_eq _)\n\nlemma torsion_by_le_torsion_by_of_dvd (a b : R) (dvd : a ∣ b) :\n  torsion_by R M a ≤ torsion_by R M b :=\nbegin\n  rw [← torsion_by_span_singleton_eq, ← torsion_by_singleton_eq],\n  apply torsion_by_set_le_torsion_by_set_of_subset,\n  rintro c (rfl : c = b), exact ideal.mem_span_singleton.mpr dvd\nend\n\n@[simp] lemma torsion_by_one : torsion_by R M 1 = ⊥ :=\neq_bot_iff.mpr (λ _ h, by { rw [mem_torsion_by_iff, one_smul] at h, exact h })\n@[simp] lemma torsion_by_univ : torsion_by_set R M set.univ = ⊥ :=\nby { rw [eq_bot_iff, ← torsion_by_one, ← torsion_by_singleton_eq],\n  exact torsion_by_set_le_torsion_by_set_of_subset (λ _ _, trivial) }\n\nend submodule\nopen submodule\nnamespace module\n\n@[simp] lemma is_torsion_by_singleton_iff : is_torsion_by_set R M {a} ↔ is_torsion_by R M a :=\nbegin\n  refine ⟨λ h x, @h _ ⟨_, set.mem_singleton _⟩, λ h x, _⟩,\n  rintro ⟨b, rfl : b = a⟩, exact @h _\nend\n\nlemma is_torsion_by_set_iff_torsion_by_set_eq_top :\n  is_torsion_by_set R M s ↔ submodule.torsion_by_set R M s = ⊤ :=\n⟨λ h, eq_top_iff.mpr (λ _ _, (mem_torsion_by_set_iff _ _).mpr $ @h _),\n  λ h x, by { rw [← mem_torsion_by_set_iff, h], trivial }⟩\n\n/-- A `a`-torsion module is a module whose `a`-torsion submodule is the full space. -/\nlemma is_torsion_by_iff_torsion_by_eq_top : is_torsion_by R M a ↔ torsion_by R M a = ⊤ :=\nby rw [← torsion_by_singleton_eq, ← is_torsion_by_singleton_iff,\n  is_torsion_by_set_iff_torsion_by_set_eq_top]\n\nlemma is_torsion_by_set_iff_is_torsion_by_span :\n  is_torsion_by_set R M s ↔ is_torsion_by_set R M (ideal.span s) :=\nby rw [is_torsion_by_set_iff_torsion_by_set_eq_top, is_torsion_by_set_iff_torsion_by_set_eq_top,\n  torsion_by_set_eq_torsion_by_span]\n\nlemma is_torsion_by_span_singleton_iff : is_torsion_by_set R M (R ∙ a) ↔ is_torsion_by R M a :=\n((is_torsion_by_set_iff_is_torsion_by_span _).symm.trans $ is_torsion_by_singleton_iff _)\n\nend module\nnamespace submodule\nopen module\n\nlemma torsion_by_set_is_torsion_by_set : is_torsion_by_set R (torsion_by_set R M s) s :=\nλ ⟨x, hx⟩ a, subtype.ext $ (mem_torsion_by_set_iff _ _).mp hx a\n\n/-- The `a`-torsion submodule is a `a`-torsion module. -/\nlemma torsion_by_is_torsion_by : is_torsion_by R (torsion_by R M a) a := λ _, smul_torsion_by _ _\n\n@[simp] lemma torsion_by_torsion_by_eq_top : torsion_by R (torsion_by R M a) a = ⊤ :=\n(is_torsion_by_iff_torsion_by_eq_top a).mp $ torsion_by_is_torsion_by a\n@[simp] lemma torsion_by_set_torsion_by_set_eq_top :\n  torsion_by_set R (torsion_by_set R M s) s = ⊤ :=\n(is_torsion_by_set_iff_torsion_by_set_eq_top s).mp $ torsion_by_set_is_torsion_by_set s\n\nvariables (R M)\nlemma torsion_gc : @galois_connection (submodule R M) (ideal R)ᵒᵈ _ _\n  annihilator (λ I, torsion_by_set R M $ I.of_dual) :=\nλ A I, ⟨λ h x hx, (mem_torsion_by_set_iff _ _).mpr $ λ ⟨a, ha⟩, mem_annihilator.mp (h ha) x hx,\n  λ h a ha, mem_annihilator.mpr $ λ x hx, (mem_torsion_by_set_iff _ _).mp (h hx) ⟨a, ha⟩⟩\n\nvariables {R M}\nsection coprime\nopen_locale big_operators\nvariables {ι : Type*} {p : ι → ideal R} {S : finset ι}\nvariables (hp : (S : set ι).pairwise $ λ i j, p i ⊔ p j = ⊤)\ninclude hp\n\nlemma supr_torsion_by_ideal_eq_torsion_by_infi :\n  (⨆ i ∈ S, torsion_by_set R M $ p i) = torsion_by_set R M ↑(⨅ i ∈ S, p i) :=\nbegin\n  cases S.eq_empty_or_nonempty with h h,\n  { rw h, convert supr_emptyset, convert torsion_by_univ, convert top_coe, exact infi_emptyset },\n  apply le_antisymm,\n  { apply supr_le _, intro i, apply supr_le _, intro is,\n    apply torsion_by_set_le_torsion_by_set_of_subset,\n    exact (infi_le (λ i, ⨅ (H : i ∈ S), p i) i).trans (infi_le _ is), },\n  { intros x hx,\n    rw mem_supr_finset_iff_exists_sum,\n    obtain ⟨μ, hμ⟩ := (mem_supr_finset_iff_exists_sum _ _).mp\n      ((ideal.eq_top_iff_one _).mp $ (ideal.supr_infi_eq_top_iff_pairwise h _).mpr hp),\n    refine ⟨λ i, ⟨(μ i : R) • x, _⟩, _⟩,\n    { rw mem_torsion_by_set_iff at hx ⊢,\n      rintro ⟨a, ha⟩, rw smul_smul,\n      suffices : a * μ i ∈ ⨅ i ∈ S, p i, from hx ⟨_, this⟩,\n      rw mem_infi, intro j, rw mem_infi, intro hj,\n      by_cases ij : j = i,\n      { rw ij, exact ideal.mul_mem_right _ _ ha },\n      { have := coe_mem (μ i), simp only [mem_infi] at this,\n        exact ideal.mul_mem_left _ _ (this j hj ij) } },\n    { simp_rw coe_mk, rw [← finset.sum_smul, hμ, one_smul] } }\nend\n\nlemma sup_indep_torsion_by_ideal : S.sup_indep (λ i, torsion_by_set R M $ p i) :=\nλ T hT i hi hiT, begin\n  rw [disjoint_iff, finset.sup_eq_supr,\n    supr_torsion_by_ideal_eq_torsion_by_infi $ λ i hi j hj ij, hp (hT hi) (hT hj) ij],\n  have := @galois_connection.u_inf _ _ (order_dual.to_dual _) (order_dual.to_dual _) _ _ _ _\n    (torsion_gc R M), dsimp at this ⊢,\n  rw [← this, ideal.sup_infi_eq_top, top_coe, torsion_by_univ],\n  intros j hj, apply hp hi (hT hj), rintro rfl, exact hiT hj\nend\n\nomit hp\nvariables {q : ι → R} (hq : (S : set ι).pairwise $ is_coprime on q)\ninclude hq\n\nlemma supr_torsion_by_eq_torsion_by_prod :\n  (⨆ i ∈ S, torsion_by R M $ q i) = torsion_by R M (∏ i in S, q i) :=\nbegin\n  rw [← torsion_by_span_singleton_eq, ideal.submodule_span_eq,\n    ← ideal.finset_inf_span_singleton _ _ hq, finset.inf_eq_infi,\n    ← supr_torsion_by_ideal_eq_torsion_by_infi],\n  { congr, ext : 1, congr, ext : 1, exact (torsion_by_span_singleton_eq _).symm },\n  { exact λ i hi j hj ij, (ideal.sup_eq_top_iff_is_coprime _ _).mpr (hq hi hj ij), }\nend\n\nlemma sup_indep_torsion_by : S.sup_indep (λ i, torsion_by R M $ q i) :=\nbegin\n  convert sup_indep_torsion_by_ideal\n    (λ i hi j hj ij, (ideal.sup_eq_top_iff_is_coprime (q i) _).mpr $ hq hi hj ij),\n  ext : 1, exact (torsion_by_span_singleton_eq _).symm,\nend\n\nend coprime\nend submodule\nend\n\nsection needs_group\nvariables [comm_ring R] [add_comm_group M] [module R M]\n\nnamespace submodule\nopen_locale big_operators\nvariables {ι : Type*} [decidable_eq ι] {S : finset ι}\n\n/--If the `p i` are pairwise coprime, a `⨅ i, p i`-torsion module is the internal direct sum of\nits `p i`-torsion submodules.-/\nlemma torsion_by_set_is_internal {p : ι → ideal R}\n  (hp : (S : set ι).pairwise $ λ i j, p i ⊔ p j = ⊤)\n  (hM : module.is_torsion_by_set R M (⨅ i ∈ S, p i : ideal R)) :\n  direct_sum.is_internal (λ i : S, torsion_by_set R M $ p i) :=\ndirect_sum.is_internal_submodule_of_independent_of_supr_eq_top\n  (complete_lattice.independent_iff_sup_indep.mpr $ sup_indep_torsion_by_ideal hp)\n  ((supr_subtype'' ↑S $ λ i, torsion_by_set R M $ p i).trans $\n    (supr_torsion_by_ideal_eq_torsion_by_infi hp).trans $\n    (module.is_torsion_by_set_iff_torsion_by_set_eq_top _).mp hM)\n\n/--If the `q i` are pairwise coprime, a `∏ i, q i`-torsion module is the internal direct sum of\nits `q i`-torsion submodules.-/\nlemma torsion_by_is_internal {q : ι → R} (hq : (S : set ι).pairwise $ is_coprime on q)\n  (hM : module.is_torsion_by R M $ ∏ i in S, q i) :\n  direct_sum.is_internal (λ i : S, torsion_by R M $ q i) :=\nbegin\n  rw [← module.is_torsion_by_span_singleton_iff, ideal.submodule_span_eq,\n    ← ideal.finset_inf_span_singleton _ _ hq, finset.inf_eq_infi] at hM,\n  convert torsion_by_set_is_internal\n    (λ i hi j hj ij, (ideal.sup_eq_top_iff_is_coprime (q i) _).mpr $ hq hi hj ij) hM,\n  ext : 1, exact (torsion_by_span_singleton_eq _).symm,\nend\n\nend submodule\n\nnamespace module\nvariables {I : ideal R} (hM : is_torsion_by_set R M I)\ninclude hM\n\n/-- can't be an instance because hM can't be inferred -/\ndef is_torsion_by_set.has_scalar : has_scalar (R ⧸ I) M :=\n{ smul := λ b x, quotient.lift_on' b (• x) $ λ b₁ b₂ h, begin\n    show b₁ • x = b₂ • x,\n    have : (-b₁ + b₂) • x = 0 := @hM x ⟨_, h⟩,\n    rw [add_smul, neg_smul, neg_add_eq_zero] at this,\n    exact this\n  end }\n\n@[simp] lemma is_torsion_by_set.mk_smul (b : R) (x : M) :\n  by haveI := hM.has_scalar; exact ideal.quotient.mk I b • x = b • x := rfl\n\n/-- A `(R ⧸ I)`-module is a `R`-module which `is_torsion_by_set R M I`. -/\ndef is_torsion_by_set.module : module (R ⧸ I) M :=\n@function.surjective.module_left _ _ _ _ _ _ _ hM.has_scalar\n  _ ideal.quotient.mk_surjective (is_torsion_by_set.mk_smul hM)\n\nend module\n\nnamespace submodule\n\ninstance (I : ideal R) : module (R ⧸ I) (torsion_by_set R M I) :=\nmodule.is_torsion_by_set.module $ torsion_by_set_is_torsion_by_set I\n\n@[simp] lemma torsion_by_set.mk_smul (I : ideal R) (b : R) (x : torsion_by_set R M I) :\n  ideal.quotient.mk I b • x = b • x := rfl\n\ninstance (I : ideal R) {S : Type*} [has_scalar S R] [has_scalar S M]\n  [is_scalar_tower S R M] [is_scalar_tower S R R] :\n  is_scalar_tower S (R ⧸ I) (torsion_by_set R M I) :=\n{ smul_assoc := λ b d x, quotient.induction_on' d $ λ c, (smul_assoc b c x : _) }\n\n/-- The `a`-torsion submodule as a `(R ⧸ R∙a)`-module. -/\ninstance (a : R) : module (R ⧸ R ∙ a) (torsion_by R M a) :=\nmodule.is_torsion_by_set.module $\n  (module.is_torsion_by_span_singleton_iff a).mpr $ torsion_by_is_torsion_by a\n\n@[simp] lemma torsion_by.mk_smul (a b : R) (x : torsion_by R M a) :\n  ideal.quotient.mk (R ∙ a) b • x = b • x := rfl\n\ninstance (a : R) {S : Type*} [has_scalar S R] [has_scalar S M]\n  [is_scalar_tower S R M] [is_scalar_tower S R R] :\n  is_scalar_tower S (R ⧸ R ∙ a) (torsion_by R M a) :=\n{ smul_assoc := λ b d x, quotient.induction_on' d $ λ c, (smul_assoc b c x : _) }\n\nend submodule\nend needs_group\n\nnamespace submodule\nsection torsion'\nopen module\n\nvariables [comm_semiring R] [add_comm_monoid M] [module R M]\nvariables (S : Type*) [comm_monoid S] [distrib_mul_action S M] [smul_comm_class S R M]\n\n@[simp] lemma mem_torsion'_iff (x : M) : x ∈ torsion' R M S ↔ ∃ a : S, a • x = 0 := iff.rfl\n@[simp] lemma mem_torsion_iff (x : M) : x ∈ torsion R M ↔ ∃ a : R⁰, a • x = 0 := iff.rfl\n\n@[simps] instance : has_scalar S (torsion' R M S) :=\n⟨λ s x, ⟨s • x, by { obtain ⟨x, a, h⟩ := x, use a, dsimp, rw [smul_comm, h, smul_zero] }⟩⟩\ninstance : distrib_mul_action S (torsion' R M S) := subtype.coe_injective.distrib_mul_action\n  ((torsion' R M S).subtype).to_add_monoid_hom (λ (c : S) x, rfl)\ninstance : smul_comm_class S R (torsion' R M S) := ⟨λ s a x, subtype.ext $ smul_comm _ _ _⟩\n\n/-- A `S`-torsion module is a module whose `S`-torsion submodule is the full space. -/\nlemma is_torsion'_iff_torsion'_eq_top : is_torsion' M S ↔ torsion' R M S = ⊤ :=\n⟨λ h, eq_top_iff.mpr (λ _ _, @h _), λ h x, by { rw [← @mem_torsion'_iff R, h], trivial }⟩\n\n/-- The `S`-torsion submodule is a `S`-torsion module. -/\nlemma torsion'_is_torsion' : is_torsion' (torsion' R M S) S := λ ⟨x, ⟨a, h⟩⟩, ⟨a, subtype.ext h⟩\n\n@[simp] lemma torsion'_torsion'_eq_top : torsion' R (torsion' R M S) S = ⊤ :=\n(is_torsion'_iff_torsion'_eq_top S).mp $ torsion'_is_torsion' S\n\n/-- The torsion submodule of the torsion submodule (viewed as a module) is the full\ntorsion module. -/\n@[simp] lemma torsion_torsion_eq_top : torsion R (torsion R M) = ⊤ := torsion'_torsion'_eq_top R⁰\n\n/-- The torsion submodule is always a torsion module. -/\nlemma torsion_is_torsion : module.is_torsion R (torsion R M) := torsion'_is_torsion' R⁰\nend torsion'\n\nsection torsion\nvariables [comm_semiring R] [add_comm_monoid M] [module R M]\nopen_locale big_operators\n\nlemma is_torsion_by_ideal_of_finite_of_is_torsion [module.finite R M] (hM : module.is_torsion R M) :\n  ∃ I : ideal R, (I : set R) ∩ R⁰ ≠ ∅ ∧ module.is_torsion_by_set R M I :=\nbegin\n  cases (module.finite_def.mp infer_instance : (⊤ : submodule R M).fg) with S h,\n  refine ⟨∏ x in S, ideal.torsion_of R M x, _, _⟩,\n  { rw set.ne_empty_iff_nonempty,\n    refine ⟨_, _, (∏ x in S, (@hM x).some : R⁰).2⟩,\n    rw [subtype.val_eq_coe, submonoid.coe_finset_prod],\n    apply ideal.prod_mem_prod,\n    exact λ x _, (@hM x).some_spec },\n  { rw [module.is_torsion_by_set_iff_torsion_by_set_eq_top, eq_top_iff, ← h, span_le],\n    intros x hx, apply torsion_by_set_le_torsion_by_set_of_subset,\n    { apply ideal.le_of_dvd, exact finset.dvd_prod_of_mem _ hx },\n    { rw mem_torsion_by_set_iff, rintro ⟨a, ha⟩, exact ha } }\nend\n\nvariables [no_zero_divisors R] [nontrivial R]\n\nlemma coe_torsion_eq_annihilator_ne_bot :\n  (torsion R M : set M) = { x : M | (R ∙ x).annihilator ≠ ⊥ } :=\nbegin\n  ext x, simp_rw [submodule.ne_bot_iff, mem_annihilator, mem_span_singleton],\n  exact ⟨λ ⟨a, hax⟩, ⟨a, λ _ ⟨b, hb⟩, by rw [← hb, smul_comm, ← submonoid.smul_def, hax, smul_zero],\n    non_zero_divisors.coe_ne_zero _⟩,\n    λ ⟨a, hax, ha⟩, ⟨⟨_, mem_non_zero_divisors_of_ne_zero ha⟩, hax x ⟨1, one_smul _ _⟩⟩⟩\nend\n\n/-- A module over a domain has `no_zero_smul_divisors` iff its torsion submodule is trivial. -/\nlemma no_zero_smul_divisors_iff_torsion_eq_bot :\n  no_zero_smul_divisors R M ↔ torsion R M = ⊥ :=\nbegin\n  split; intro h,\n  { haveI : no_zero_smul_divisors R M := h,\n    rw eq_bot_iff, rintro x ⟨a, hax⟩,\n    change (a : R) • x = 0 at hax,\n    cases eq_zero_or_eq_zero_of_smul_eq_zero hax with h0 h0,\n    { exfalso, exact non_zero_divisors.coe_ne_zero a h0 }, { exact h0 } },\n  { exact { eq_zero_or_eq_zero_of_smul_eq_zero := λ a x hax, begin\n      by_cases ha : a = 0,\n      { left, exact ha },\n      { right, rw [← mem_bot _, ← h],\n        exact ⟨⟨a, mem_non_zero_divisors_of_ne_zero ha⟩, hax⟩ }\n    end } }\nend\nend torsion\n\nnamespace quotient_torsion\n\nvariables [comm_ring R] [add_comm_group M] [module R M]\n\n/-- Quotienting by the torsion submodule gives a torsion-free module. -/\n@[simp] lemma torsion_eq_bot : torsion R (M ⧸ torsion R M) = ⊥ :=\neq_bot_iff.mpr $ λ z, quotient.induction_on' z $ λ x ⟨a, hax⟩,\nbegin\n  rw [quotient.mk'_eq_mk, ← quotient.mk_smul, quotient.mk_eq_zero] at hax,\n  rw [mem_bot, quotient.mk'_eq_mk, quotient.mk_eq_zero],\n  cases hax with b h,\n  exact ⟨b * a, (mul_smul _ _ _).trans h⟩\nend\n\ninstance no_zero_smul_divisors [is_domain R] : no_zero_smul_divisors R (M ⧸ torsion R M) :=\nno_zero_smul_divisors_iff_torsion_eq_bot.mpr torsion_eq_bot\n\nend quotient_torsion\n\nsection p_torsion\nopen module\nsection\nvariables [monoid R] [add_comm_monoid M] [distrib_mul_action R M]\n\nlemma is_torsion'_powers_iff (p : R) :\n  is_torsion' M (submonoid.powers p) ↔ ∀ x : M, ∃ n : ℕ, p ^ n • x = 0 :=\n⟨λ h x, let ⟨⟨a, ⟨n, rfl⟩⟩, hx⟩ := @h x in ⟨n, hx⟩,\nλ h x, let ⟨n, hn⟩ := h x in ⟨⟨_, ⟨n, rfl⟩⟩, hn⟩⟩\n\n/--In a `p ^ ∞`-torsion module (that is, a module where all elements are cancelled by scalar\nmultiplication by some power of `p`), the smallest `n` such that `p ^ n • x = 0`.-/\ndef p_order {p : R} (hM : is_torsion' M $ submonoid.powers p) (x : M)\n  [Π n : ℕ, decidable (p ^ n • x = 0)] :=\nnat.find $ (is_torsion'_powers_iff p).mp hM x\n@[simp] lemma pow_p_order_smul {p : R} (hM : is_torsion' M $ submonoid.powers p) (x : M)\n  [Π n : ℕ, decidable (p ^ n • x = 0)] : p ^ p_order hM x • x = 0 :=\nnat.find_spec $ (is_torsion'_powers_iff p).mp hM x\n\nend\nvariables [comm_semiring R] [add_comm_monoid M] [module R M] [Π x : M, decidable (x = 0)]\n\nlemma exists_is_torsion_by {p : R} (hM : is_torsion' M $ submonoid.powers p)\n  (d : ℕ) (hd : d ≠ 0) (s : fin d → M) (hs : span R (set.range s) = ⊤) :\n  ∃ j : fin d, module.is_torsion_by R M (p ^ p_order hM (s j)) :=\nbegin\n  let oj := list.argmax (λ i, p_order hM $ s i) (list.fin_range d),\n  have hoj : oj.is_some := (option.ne_none_iff_is_some.mp $\n    λ eq_none, hd $ list.fin_range_eq_nil.mp $ list.argmax_eq_none.mp eq_none),\n  use option.get hoj,\n  rw [is_torsion_by_iff_torsion_by_eq_top, eq_top_iff, ← hs, submodule.span_le,\n    set.range_subset_iff], intro i, change _ • _ = _,\n  have : p_order hM (s i) ≤ p_order hM (s $ option.get hoj) :=\n    list.le_of_mem_argmax (list.mem_fin_range i) (option.get_mem hoj),\n  rw [← nat.sub_add_cancel this, pow_add, mul_smul, pow_p_order_smul, smul_zero]\nend\n\nend p_torsion\nend submodule\n\nnamespace ideal.quotient\n\nopen submodule\n\nlemma torsion_by_eq_span_singleton {R : Type*} [comm_ring R] (a b : R) (ha : a ∈ R⁰) :\n  torsion_by R (R ⧸ R ∙ a * b) a = R ∙ (mk _ b) :=\nbegin\n  ext x, rw [mem_torsion_by_iff, mem_span_singleton],\n  obtain ⟨x, rfl⟩ := mk_surjective x, split; intro h,\n  { rw [← mk_eq_mk, ← quotient.mk_smul, quotient.mk_eq_zero, mem_span_singleton] at h,\n    obtain ⟨c, h⟩ := h, rw [smul_eq_mul, smul_eq_mul, mul_comm, mul_assoc,\n      mul_cancel_left_mem_non_zero_divisor ha, mul_comm] at h,\n    use c, rw [← h, ← mk_eq_mk, ← quotient.mk_smul, smul_eq_mul, mk_eq_mk] },\n  { obtain ⟨c, h⟩ := h,\n    rw [← h, smul_comm, ← mk_eq_mk, ← quotient.mk_smul,\n      (quotient.mk_eq_zero _).mpr $ mem_span_singleton_self _, smul_zero] }\nend\nend ideal.quotient\n\nnamespace add_monoid\n\ntheorem is_torsion_iff_is_torsion_nat [add_comm_monoid M] :\n  add_monoid.is_torsion M ↔ module.is_torsion ℕ M :=\nbegin\n  refine ⟨λ h x, _, λ h x, _⟩,\n  { obtain ⟨n, h0, hn⟩ := (is_of_fin_add_order_iff_nsmul_eq_zero x).mp (h x),\n    exact ⟨⟨n, mem_non_zero_divisors_of_ne_zero $ ne_of_gt h0⟩, hn⟩ },\n  { rw is_of_fin_add_order_iff_nsmul_eq_zero,\n    obtain ⟨n, hn⟩ := @h x,\n    refine ⟨n, nat.pos_of_ne_zero (non_zero_divisors.coe_ne_zero _), hn⟩ }\nend\n\ntheorem is_torsion_iff_is_torsion_int [add_comm_group M] :\n  add_monoid.is_torsion M ↔ module.is_torsion ℤ M :=\nbegin\n  refine ⟨λ h x, _, λ h x, _⟩,\n  { obtain ⟨n, h0, hn⟩ := (is_of_fin_add_order_iff_nsmul_eq_zero x).mp (h x),\n    exact ⟨⟨n, mem_non_zero_divisors_of_ne_zero $ ne_of_gt $ int.coe_nat_pos.mpr h0⟩,\n      (coe_nat_zsmul _ _).trans hn⟩ },\n  { rw is_of_fin_add_order_iff_nsmul_eq_zero,\n    obtain ⟨n, hn⟩ := @h x,\n    exact exists_nsmul_eq_zero_of_zsmul_eq_zero (non_zero_divisors.coe_ne_zero n) hn }\nend\n\nend add_monoid\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/module/torsion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.49810723960106557}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.interactive\nimport Mathlib.tactic.norm_num\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# `field_simp` tactic\n\nTactic to clear denominators in algebraic expressions, based on `simp` with a specific simpset.\n-/\n\nnamespace tactic\n\n\n/-- Try to prove a goal of the form `x ≠ 0` by calling `assumption`, or `norm_num1` if `x` is\na numeral. -/\nnamespace interactive\n\n\n/--\nThe goal of `field_simp` is to reduce an expression in a field to an expression of the form `n / d`\nwhere neither `n` nor `d` contains any division symbol, just using the simplifier (with a carefully\ncrafted simpset named `field_simps`) to reduce the number of division symbols whenever possible by\niterating the following steps:\n\n- write an inverse as a division\n- in any product, move the division to the right\n- if there are several divisions in a product, group them together at the end and write them as a\n  single division\n- reduce a sum to a common denominator\n\nIf the goal is an equality, this simpset will also clear the denominators, so that the proof\ncan normally be concluded by an application of `ring` or `ring_exp`.\n\n`field_simp [hx, hy]` is a short form for\n`simp [-one_div, -mul_eq_zero, hx, hy] with field_simps {discharger := [field_simp.ne_zero]}`\n\nNote that this naive algorithm will not try to detect common factors in denominators to reduce the\ncomplexity of the resulting expression. Instead, it relies on the ability of `ring` to handle\ncomplicated expressions in the next step.\n\nAs always with the simplifier, reduction steps will only be applied if the preconditions of the\nlemmas can be checked. This means that proofs that denominators are nonzero should be included. The\nfact that a product is nonzero when all factors are, and that a power of a nonzero number is\nnonzero, are included in the simpset, but more complicated assertions (especially dealing with sums)\nshould be given explicitly. If your expression is not completely reduced by the simplifier\ninvocation, check the denominators of the resulting expression and provide proofs that they are\nnonzero to enable further progress.\n\nTo check that denominators are nonzero, `field_simp` will look for facts in the context, and\nwill try to apply `norm_num` to close numerical goals.\n\nThe invocation of `field_simp` removes the lemma `one_div` from the simpset, as this lemma\nworks against the algorithm explained above. It also removes\n`mul_eq_zero : x * y = 0 ↔ x = 0 ∨ y = 0`, as `norm_num` can not work on disjunctions to\nclose goals of the form `24 ≠ 0`, and replaces it with `mul_ne_zero : x ≠ 0 → y ≠ 0 → x * y ≠ 0`\ncreating two goals instead of a disjunction.\n\nFor example,\n```lean\nexample (a b c d x y : ℂ) (hx : x ≠ 0) (hy : y ≠ 0) :\n  a + b / x + c / x^2 + d / x^3 = a + x⁻¹ * (y * b / y + (d / x + c) / x) :=\nbegin\n  field_simp,\n  ring\nend\n```\n\nSee also the `cancel_denoms` tactic, which tries to do a similar simplification for expressions\nthat have numerals in denominators.\nThe tactics are not related: `cancel_denoms` will only handle numeric denominators, and will try to\nentirely remove (numeric) division from the expression by multiplying by a factor.\n-/\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/field_simp_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.4980315081132347}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Gabriel Ebner, Simon Hudon, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.equiv_rw\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n## The `transport` tactic\n\n`transport` attempts to move an `s : S α` expression across an equivalence `e : α ≃ β` to solve\na goal of the form `S β`, by building the new object field by field, taking each field of `s`\nand rewriting it along `e` using the `equiv_rw` tactic.\n\nWe try to ensure good definitional properties, so that, for example, when we transport a `monoid α`\nto a `monoid β`, the new multiplication is definitionally `λ x y, e (e.symm a * e.symm b)`.\n-/\n\nnamespace tactic\n\n\n/--\nGiven `s : S α` for some structure `S` depending on a type `α`,\nand an equivalence `e : α ≃ β`,\ntry to produce an `S β`,\nby transporting data and axioms across `e` using `equiv_rw`.\n-/\nnamespace interactive\n\n\n/--\nGiven a goal `⊢ S β` for some type class `S`, and an equivalence `e : α ≃ β`.\n`transport using e` will look for a hypothesis `s : S α`,\nand attempt to close the goal by transporting `s` across the equivalence `e`.\n\n```lean\nexample {α : Type} [ring α] {β : Type} (e : α ≃ β) : ring β :=\nby transport using e.\n```\n\nYou can specify the object to transport using `transport s using e`.\n\n`transport` works by attempting to copy each of the operations and axiom fields of `s`,\nrewriting them using `equiv_rw e` and defining a new structure using these rewritten fields.\n\nIf it fails to fill in all the new fields, `transport` will produce new subgoals.\nIt's probably best to think about which missing `simp` lemmas would have allowed `transport`\nto finish, rather than solving these goals by hand.\n(This may require looking at the implementation of `tranport` to understand its algorithm;\nthere are several examples of \"transport-by-hand\" at the end of `test/equiv_rw.lean`,\nwhich `transport` is an abstraction of.)\n-/\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/transport_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.7122321964553657, "lm_q1q2_score": 0.49803150326417467}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.list\nimport Mathlib.logic.function.iterate\nimport Mathlib.PostPort\n\nuniverses u_1 l u_2 u_3 u_5 u_4 \n\nnamespace Mathlib\n\n/-!\n# The primitive recursive functions\n\nThe primitive recursive functions are the least collection of functions\n`nat → nat` which are closed under projections (using the mkpair\npairing function), composition, zero, successor, and primitive recursion\n(i.e. nat.rec where the motive is C n := nat).\n\nWe can extend this definition to a large class of basic types by\nusing canonical encodings of types as natural numbers (Gödel numbering),\nwhich we implement through the type class `encodable`. (More precisely,\nwe need that the composition of encode with decode yields a\nprimitive recursive function, so we have the `primcodable` type class\nfor this.)\n\n## References\n\n* [Mario Carneiro, *Formalizing computability theory via partial recursive functions*][carneiro2019]\n-/\n\nnamespace nat\n\n\ndef elim {C : Sort u_1} : C → (ℕ → C → C) → ℕ → C := Nat.rec\n\n@[simp] theorem elim_zero {C : Sort u_1} (a : C) (f : ℕ → C → C) : elim a f 0 = a := rfl\n\n@[simp] theorem elim_succ {C : Sort u_1} (a : C) (f : ℕ → C → C) (n : ℕ) :\n    elim a f (Nat.succ n) = f n (elim a f n) :=\n  rfl\n\ndef cases {C : Sort u_1} (a : C) (f : ℕ → C) : ℕ → C := elim a fun (n : ℕ) (_x : C) => f n\n\n@[simp] theorem cases_zero {C : Sort u_1} (a : C) (f : ℕ → C) : cases a f 0 = a := rfl\n\n@[simp] theorem cases_succ {C : Sort u_1} (a : C) (f : ℕ → C) (n : ℕ) :\n    cases a f (Nat.succ n) = f n :=\n  rfl\n\n@[simp] def unpaired {α : Sort u_1} (f : ℕ → ℕ → α) (n : ℕ) : α :=\n  f (prod.fst (unpair n)) (prod.snd (unpair n))\n\n/-- The primitive recursive functions `ℕ → ℕ`. -/\ninductive primrec : (ℕ → ℕ) → Prop where\n| zero : primrec fun (n : ℕ) => 0\n| succ : primrec Nat.succ\n| left : primrec fun (n : ℕ) => prod.fst (unpair n)\n| right : primrec fun (n : ℕ) => prod.snd (unpair n)\n| pair : ∀ {f g : ℕ → ℕ}, primrec f → primrec g → primrec fun (n : ℕ) => mkpair (f n) (g n)\n| comp : ∀ {f g : ℕ → ℕ}, primrec f → primrec g → primrec fun (n : ℕ) => f (g n)\n| prec :\n    ∀ {f g : ℕ → ℕ},\n      primrec f →\n        primrec g →\n          primrec\n            (unpaired fun (z n : ℕ) => elim (f z) (fun (y IH : ℕ) => g (mkpair z (mkpair y IH))) n)\n\nnamespace primrec\n\n\ntheorem of_eq {f : ℕ → ℕ} {g : ℕ → ℕ} (hf : primrec f) (H : ∀ (n : ℕ), f n = g n) : primrec g :=\n  funext H ▸ hf\n\ntheorem const (n : ℕ) : primrec fun (_x : ℕ) => n := sorry\n\nprotected theorem id : primrec id := sorry\n\ntheorem prec1 {f : ℕ → ℕ} (m : ℕ) (hf : primrec f) :\n    primrec fun (n : ℕ) => elim m (fun (y IH : ℕ) => f (mkpair y IH)) n :=\n  sorry\n\ntheorem cases1 {f : ℕ → ℕ} (m : ℕ) (hf : primrec f) : primrec (cases m f) := sorry\n\ntheorem cases {f : ℕ → ℕ} {g : ℕ → ℕ} (hf : primrec f) (hg : primrec g) :\n    primrec (unpaired fun (z n : ℕ) => cases (f z) (fun (y : ℕ) => g (mkpair z y)) n) :=\n  sorry\n\nprotected theorem swap : primrec (unpaired (function.swap mkpair)) := sorry\n\ntheorem swap' {f : ℕ → ℕ → ℕ} (hf : primrec (unpaired f)) : primrec (unpaired (function.swap f)) :=\n  sorry\n\ntheorem pred : primrec Nat.pred := sorry\n\ntheorem add : primrec (unpaired Add.add) := sorry\n\ntheorem sub : primrec (unpaired Sub.sub) := sorry\n\ntheorem mul : primrec (unpaired Mul.mul) := sorry\n\ntheorem pow : primrec (unpaired pow) := sorry\n\nend primrec\n\n\nend nat\n\n\n/-- A `primcodable` type is an `encodable` type for which\n  the encode/decode functions are primitive recursive. -/\nclass primcodable (α : Type u_1) extends encodable α where\n  prim : nat.primrec fun (n : ℕ) => encodable.encode (encodable.decode α n)\n\nnamespace primcodable\n\n\nprotected instance of_denumerable (α : Type u_1) [denumerable α] : primcodable α := mk sorry\n\ndef of_equiv (α : Type u_1) {β : Type u_2} [primcodable α] (e : β ≃ α) : primcodable β := mk sorry\n\nprotected instance empty : primcodable empty := mk nat.primrec.zero\n\nprotected instance unit : primcodable PUnit := mk sorry\n\nprotected instance option {α : Type u_1} [h : primcodable α] : primcodable (Option α) := mk sorry\n\nprotected instance bool : primcodable Bool := mk sorry\n\nend primcodable\n\n\n/-- `primrec f` means `f` is primitive recursive (after\n  encoding its input and output as natural numbers). -/\ndef primrec {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] (f : α → β) :=\n  nat.primrec fun (n : ℕ) => encodable.encode (option.map f (encodable.decode α n))\n\nnamespace primrec\n\n\nprotected theorem encode {α : Type u_1} [primcodable α] : primrec encodable.encode := sorry\n\nprotected theorem decode {α : Type u_1} [primcodable α] : primrec (encodable.decode α) :=\n  nat.primrec.comp nat.primrec.succ (primcodable.prim α)\n\ntheorem dom_denumerable {α : Type u_1} {β : Type u_2} [denumerable α] [primcodable β] {f : α → β} :\n    primrec f ↔ nat.primrec fun (n : ℕ) => encodable.encode (f (denumerable.of_nat α n)) :=\n  sorry\n\ntheorem nat_iff {f : ℕ → ℕ} : primrec f ↔ nat.primrec f := dom_denumerable\n\ntheorem encdec {α : Type u_1} [primcodable α] :\n    primrec fun (n : ℕ) => encodable.encode (encodable.decode α n) :=\n  iff.mpr nat_iff (primcodable.prim α)\n\ntheorem option_some {α : Type u_1} [primcodable α] : primrec some := sorry\n\ntheorem of_eq {α : Type u_1} {σ : Type u_3} [primcodable α] [primcodable σ] {f : α → σ} {g : α → σ}\n    (hf : primrec f) (H : ∀ (n : α), f n = g n) : primrec g :=\n  funext H ▸ hf\n\ntheorem const {α : Type u_1} {σ : Type u_3} [primcodable α] [primcodable σ] (x : σ) :\n    primrec fun (a : α) => x :=\n  sorry\n\nprotected theorem id {α : Type u_1} [primcodable α] : primrec id := sorry\n\ntheorem comp {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : β → σ} {g : α → β} (hf : primrec f) (hg : primrec g) :\n    primrec fun (a : α) => f (g a) :=\n  sorry\n\ntheorem succ : primrec Nat.succ := iff.mpr nat_iff nat.primrec.succ\n\ntheorem pred : primrec Nat.pred := iff.mpr nat_iff nat.primrec.pred\n\ntheorem encode_iff {α : Type u_1} {σ : Type u_3} [primcodable α] [primcodable σ] {f : α → σ} :\n    (primrec fun (a : α) => encodable.encode (f a)) ↔ primrec f :=\n  sorry\n\ntheorem of_nat_iff {α : Type u_1} {β : Type u_2} [denumerable α] [primcodable β] {f : α → β} :\n    primrec f ↔ primrec fun (n : ℕ) => f (denumerable.of_nat α n) :=\n  iff.trans dom_denumerable (iff.trans (iff.symm nat_iff) encode_iff)\n\nprotected theorem of_nat (α : Type u_1) [denumerable α] : primrec (denumerable.of_nat α) :=\n  iff.mp of_nat_iff primrec.id\n\ntheorem option_some_iff {α : Type u_1} {σ : Type u_3} [primcodable α] [primcodable σ] {f : α → σ} :\n    (primrec fun (a : α) => some (f a)) ↔ primrec f :=\n  { mp :=\n      fun (h : primrec fun (a : α) => some (f a)) =>\n        iff.mp encode_iff (comp pred (iff.mpr encode_iff h)),\n    mpr := comp option_some }\n\ntheorem of_equiv {α : Type u_1} [primcodable α] {β : Type u_2} {e : β ≃ α} : primrec ⇑e :=\n  iff.mp encode_iff primrec.encode\n\ntheorem of_equiv_symm {α : Type u_1} [primcodable α] {β : Type u_2} {e : β ≃ α} :\n    primrec ⇑(equiv.symm e) :=\n  sorry\n\ntheorem of_equiv_iff {α : Type u_1} {σ : Type u_3} [primcodable α] [primcodable σ] {β : Type u_2}\n    (e : β ≃ α) {f : σ → β} : (primrec fun (a : σ) => coe_fn e (f a)) ↔ primrec f :=\n  sorry\n\ntheorem of_equiv_symm_iff {α : Type u_1} {σ : Type u_3} [primcodable α] [primcodable σ]\n    {β : Type u_2} (e : β ≃ α) {f : σ → α} :\n    (primrec fun (a : σ) => coe_fn (equiv.symm e) (f a)) ↔ primrec f :=\n  sorry\n\nend primrec\n\n\nnamespace primcodable\n\n\nprotected instance prod {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] :\n    primcodable (α × β) :=\n  mk sorry\n\nend primcodable\n\n\nnamespace primrec\n\n\ntheorem fst {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] : primrec prod.fst :=\n  sorry\n\ntheorem snd {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] : primrec prod.snd :=\n  sorry\n\ntheorem pair {α : Type u_1} {β : Type u_2} {γ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable γ] {f : α → β} {g : α → γ} (hf : primrec f) (hg : primrec g) :\n    primrec fun (a : α) => (f a, g a) :=\n  sorry\n\ntheorem unpair : primrec nat.unpair := sorry\n\ntheorem list_nth₁ {α : Type u_1} [primcodable α] (l : List α) : primrec (list.nth l) := sorry\n\nend primrec\n\n\n/-- `primrec₂ f` means `f` is a binary primitive recursive function.\n  This is technically unnecessary since we can always curry all\n  the arguments together, but there are enough natural two-arg\n  functions that it is convenient to express this directly. -/\ndef primrec₂ {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] (f : α → β → σ) :=\n  primrec fun (p : α × β) => f (prod.fst p) (prod.snd p)\n\n/-- `primrec_pred p` means `p : α → Prop` is a (decidable)\n  primitive recursive predicate, which is to say that\n  `to_bool ∘ p : α → bool` is primitive recursive. -/\ndef primrec_pred {α : Type u_1} [primcodable α] (p : α → Prop) [decidable_pred p] :=\n  primrec fun (a : α) => to_bool (p a)\n\n/-- `primrec_rel p` means `p : α → β → Prop` is a (decidable)\n  primitive recursive relation, which is to say that\n  `to_bool ∘ p : α → β → bool` is primitive recursive. -/\ndef primrec_rel {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] (s : α → β → Prop)\n    [(a : α) → (b : β) → Decidable (s a b)] :=\n  primrec₂ fun (a : α) (b : β) => to_bool (s a b)\n\nnamespace primrec₂\n\n\ntheorem of_eq {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} {g : α → β → σ} (hg : primrec₂ f)\n    (H : ∀ (a : α) (b : β), f a b = g a b) : primrec₂ g :=\n  (funext fun (a : α) => funext fun (b : β) => H a b) ▸ hg\n\ntheorem const {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] (x : σ) : primrec₂ fun (a : α) (b : β) => x :=\n  primrec.const x\n\nprotected theorem pair {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] :\n    primrec₂ Prod.mk :=\n  primrec.pair primrec.fst primrec.snd\n\ntheorem left {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] :\n    primrec₂ fun (a : α) (b : β) => a :=\n  primrec.fst\n\ntheorem right {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] :\n    primrec₂ fun (a : α) (b : β) => b :=\n  primrec.snd\n\ntheorem mkpair : primrec₂ nat.mkpair := sorry\n\ntheorem unpaired {α : Type u_1} [primcodable α] {f : ℕ → ℕ → α} :\n    primrec (nat.unpaired f) ↔ primrec₂ f :=\n  sorry\n\ntheorem unpaired' {f : ℕ → ℕ → ℕ} : nat.primrec (nat.unpaired f) ↔ primrec₂ f :=\n  iff.trans (iff.symm primrec.nat_iff) unpaired\n\ntheorem encode_iff {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} :\n    (primrec₂ fun (a : α) (b : β) => encodable.encode (f a b)) ↔ primrec₂ f :=\n  primrec.encode_iff\n\ntheorem option_some_iff {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} : (primrec₂ fun (a : α) (b : β) => some (f a b)) ↔ primrec₂ f :=\n  primrec.option_some_iff\n\ntheorem of_nat_iff {α : Type u_1} {β : Type u_2} {σ : Type u_3} [denumerable α] [denumerable β]\n    [primcodable σ] {f : α → β → σ} :\n    primrec₂ f ↔ primrec₂ fun (m n : ℕ) => f (denumerable.of_nat α m) (denumerable.of_nat β n) :=\n  sorry\n\ntheorem uncurry {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} : primrec (function.uncurry f) ↔ primrec₂ f :=\n  sorry\n\ntheorem curry {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α × β → σ} : primrec₂ (function.curry f) ↔ primrec f :=\n  sorry\n\nend primrec₂\n\n\ntheorem primrec.comp₂ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} [primcodable α]\n    [primcodable β] [primcodable γ] [primcodable σ] {f : γ → σ} {g : α → β → γ} (hf : primrec f)\n    (hg : primrec₂ g) : primrec₂ fun (a : α) (b : β) => f (g a b) :=\n  primrec.comp hf hg\n\ntheorem primrec₂.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_5} [primcodable α]\n    [primcodable β] [primcodable γ] [primcodable σ] {f : β → γ → σ} {g : α → β} {h : α → γ}\n    (hf : primrec₂ f) (hg : primrec g) (hh : primrec h) : primrec fun (a : α) => f (g a) (h a) :=\n  primrec.comp hf (primrec.pair hg hh)\n\ntheorem primrec₂.comp₂ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {σ : Type u_5}\n    [primcodable α] [primcodable β] [primcodable γ] [primcodable δ] [primcodable σ] {f : γ → δ → σ}\n    {g : α → β → γ} {h : α → β → δ} (hf : primrec₂ f) (hg : primrec₂ g) (hh : primrec₂ h) :\n    primrec₂ fun (a : α) (b : β) => f (g a b) (h a b) :=\n  primrec₂.comp hf hg hh\n\ntheorem primrec_pred.comp {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β]\n    {p : β → Prop} [decidable_pred p] {f : α → β} :\n    primrec_pred p → primrec f → primrec_pred fun (a : α) => p (f a) :=\n  primrec.comp\n\ntheorem primrec_rel.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [primcodable α]\n    [primcodable β] [primcodable γ] {R : β → γ → Prop} [(a : β) → (b : γ) → Decidable (R a b)]\n    {f : α → β} {g : α → γ} :\n    primrec_rel R → primrec f → primrec g → primrec_pred fun (a : α) => R (f a) (g a) :=\n  primrec₂.comp\n\ntheorem primrec_rel.comp₂ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4}\n    [primcodable α] [primcodable β] [primcodable γ] [primcodable δ] {R : γ → δ → Prop}\n    [(a : γ) → (b : δ) → Decidable (R a b)] {f : α → β → γ} {g : α → β → δ} :\n    primrec_rel R →\n        primrec₂ f → primrec₂ g → primrec_rel fun (a : α) (b : β) => R (f a b) (g a b) :=\n  primrec_rel.comp\n\ntheorem primrec_pred.of_eq {α : Type u_1} [primcodable α] {p : α → Prop} {q : α → Prop}\n    [decidable_pred p] [decidable_pred q] (hp : primrec_pred p) (H : ∀ (a : α), p a ↔ q a) :\n    primrec_pred q :=\n  primrec.of_eq hp fun (a : α) => to_bool_congr (H a)\n\ntheorem primrec_rel.of_eq {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β]\n    {r : α → β → Prop} {s : α → β → Prop} [(a : α) → (b : β) → Decidable (r a b)]\n    [(a : α) → (b : β) → Decidable (s a b)] (hr : primrec_rel r)\n    (H : ∀ (a : α) (b : β), r a b ↔ s a b) : primrec_rel s :=\n  primrec₂.of_eq hr fun (a : α) (b : β) => to_bool_congr (H a b)\n\nnamespace primrec₂\n\n\ntheorem swap {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} (h : primrec₂ f) : primrec₂ (function.swap f) :=\n  comp₂ h right left\n\ntheorem nat_iff {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} :\n    primrec₂ f ↔\n        nat.primrec\n          (nat.unpaired\n            fun (m n : ℕ) =>\n              encodable.encode\n                (option.bind (encodable.decode α m)\n                  fun (a : α) => option.map (f a) (encodable.decode β n))) :=\n  sorry\n\ntheorem nat_iff' {α : Type u_1} {β : Type u_2} {σ : Type u_3} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} :\n    primrec₂ f ↔\n        primrec₂\n          fun (m n : ℕ) =>\n            option.bind (encodable.decode α m)\n              fun (a : α) => option.map (f a) (encodable.decode β n) :=\n  iff.trans nat_iff (iff.trans unpaired' encode_iff)\n\nend primrec₂\n\n\nnamespace primrec\n\n\ntheorem to₂ {α : Type u_1} {β : Type u_2} {σ : Type u_5} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α × β → σ} (hf : primrec f) : primrec₂ fun (a : α) (b : β) => f (a, b) :=\n  of_eq hf\n    fun (_x : α × β) =>\n      (fun (_a : α × β) =>\n          prod.cases_on _a fun (fst : α) (snd : β) => idRhs (f (fst, snd) = f (fst, snd)) rfl)\n        _x\n\ntheorem nat_elim {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {f : α → β}\n    {g : α → ℕ × β → β} (hf : primrec f) (hg : primrec₂ g) :\n    primrec₂ fun (a : α) (n : ℕ) => nat.elim (f a) (fun (n : ℕ) (IH : β) => g a (n, IH)) n :=\n  sorry\n\ntheorem nat_elim' {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {f : α → ℕ}\n    {g : α → β} {h : α → ℕ × β → β} (hf : primrec f) (hg : primrec g) (hh : primrec₂ h) :\n    primrec fun (a : α) => nat.elim (g a) (fun (n : ℕ) (IH : β) => h a (n, IH)) (f a) :=\n  primrec₂.comp (nat_elim hg hh) primrec.id hf\n\ntheorem nat_elim₁ {α : Type u_1} [primcodable α] {f : ℕ → α → α} (a : α) (hf : primrec₂ f) :\n    primrec (nat.elim a f) :=\n  nat_elim' primrec.id (const a) (comp₂ hf primrec₂.right)\n\ntheorem nat_cases' {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {f : α → β}\n    {g : α → ℕ → β} (hf : primrec f) (hg : primrec₂ g) :\n    primrec₂ fun (a : α) => nat.cases (f a) (g a) :=\n  nat_elim hf (primrec₂.comp₂ hg primrec₂.left (comp₂ fst primrec₂.right))\n\ntheorem nat_cases {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {f : α → ℕ}\n    {g : α → β} {h : α → ℕ → β} (hf : primrec f) (hg : primrec g) (hh : primrec₂ h) :\n    primrec fun (a : α) => nat.cases (g a) (h a) (f a) :=\n  primrec₂.comp (nat_cases' hg hh) primrec.id hf\n\ntheorem nat_cases₁ {α : Type u_1} [primcodable α] {f : ℕ → α} (a : α) (hf : primrec f) :\n    primrec (nat.cases a f) :=\n  nat_cases primrec.id (const a) (comp₂ hf primrec₂.right)\n\ntheorem nat_iterate {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {f : α → ℕ}\n    {g : α → β} {h : α → β → β} (hf : primrec f) (hg : primrec g) (hh : primrec₂ h) :\n    primrec fun (a : α) => nat.iterate (h a) (f a) (g a) :=\n  sorry\n\ntheorem option_cases {α : Type u_1} {β : Type u_2} {σ : Type u_5} [primcodable α] [primcodable β]\n    [primcodable σ] {o : α → Option β} {f : α → σ} {g : α → β → σ} (ho : primrec o) (hf : primrec f)\n    (hg : primrec₂ g) : primrec fun (a : α) => option.cases_on (o a) (f a) (g a) :=\n  sorry\n\ntheorem option_bind {α : Type u_1} {β : Type u_2} {σ : Type u_5} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → Option β} {g : α → β → Option σ} (hf : primrec f) (hg : primrec₂ g) :\n    primrec fun (a : α) => option.bind (f a) (g a) :=\n  sorry\n\ntheorem option_bind₁ {α : Type u_1} {σ : Type u_5} [primcodable α] [primcodable σ]\n    {f : α → Option σ} (hf : primrec f) : primrec fun (o : Option α) => option.bind o f :=\n  option_bind primrec.id (to₂ (comp hf snd))\n\ntheorem option_map {α : Type u_1} {β : Type u_2} {σ : Type u_5} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → Option β} {g : α → β → σ} (hf : primrec f) (hg : primrec₂ g) :\n    primrec fun (a : α) => option.map (g a) (f a) :=\n  option_bind hf (comp₂ option_some hg)\n\ntheorem option_map₁ {α : Type u_1} {σ : Type u_5} [primcodable α] [primcodable σ] {f : α → σ}\n    (hf : primrec f) : primrec (option.map f) :=\n  option_map primrec.id (to₂ (comp hf snd))\n\ntheorem option_iget {α : Type u_1} [primcodable α] [Inhabited α] : primrec option.iget := sorry\n\ntheorem option_is_some {α : Type u_1} [primcodable α] : primrec option.is_some := sorry\n\ntheorem option_get_or_else {α : Type u_1} [primcodable α] : primrec₂ option.get_or_else := sorry\n\ntheorem bind_decode_iff {α : Type u_1} {β : Type u_2} {σ : Type u_5} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → Option σ} :\n    (primrec₂ fun (a : α) (n : ℕ) => option.bind (encodable.decode β n) (f a)) ↔ primrec₂ f :=\n  sorry\n\ntheorem map_decode_iff {α : Type u_1} {β : Type u_2} {σ : Type u_5} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → β → σ} :\n    (primrec₂ fun (a : α) (n : ℕ) => option.map (f a) (encodable.decode β n)) ↔ primrec₂ f :=\n  iff.trans bind_decode_iff primrec₂.option_some_iff\n\ntheorem nat_add : primrec₂ Add.add := iff.mp primrec₂.unpaired' nat.primrec.add\n\ntheorem nat_sub : primrec₂ Sub.sub := iff.mp primrec₂.unpaired' nat.primrec.sub\n\ntheorem nat_mul : primrec₂ Mul.mul := iff.mp primrec₂.unpaired' nat.primrec.mul\n\ntheorem cond {α : Type u_1} {σ : Type u_5} [primcodable α] [primcodable σ] {c : α → Bool}\n    {f : α → σ} {g : α → σ} (hc : primrec c) (hf : primrec f) (hg : primrec g) :\n    primrec fun (a : α) => cond (c a) (f a) (g a) :=\n  sorry\n\ntheorem ite {α : Type u_1} {σ : Type u_5} [primcodable α] [primcodable σ] {c : α → Prop}\n    [decidable_pred c] {f : α → σ} {g : α → σ} (hc : primrec_pred c) (hf : primrec f)\n    (hg : primrec g) : primrec fun (a : α) => ite (c a) (f a) (g a) :=\n  sorry\n\ntheorem nat_le : primrec_rel LessEq := sorry\n\ntheorem nat_min : primrec₂ min := ite nat_le fst snd\n\ntheorem nat_max : primrec₂ max := ite (primrec_rel.comp nat_le snd fst) fst snd\n\ntheorem dom_bool {α : Type u_1} [primcodable α] (f : Bool → α) : primrec f :=\n  of_eq (cond primrec.id (const (f tt)) (const (f false)))\n    fun (b : Bool) =>\n      bool.cases_on b (Eq.refl (cond (id false) (f tt) (f false)))\n        (Eq.refl (cond (id tt) (f tt) (f false)))\n\ntheorem dom_bool₂ {α : Type u_1} [primcodable α] (f : Bool → Bool → α) : primrec₂ f := sorry\n\nprotected theorem bnot : primrec bnot := dom_bool bnot\n\nprotected theorem band : primrec₂ band := dom_bool₂ band\n\nprotected theorem bor : primrec₂ bor := dom_bool₂ bor\n\nprotected theorem not {α : Type u_1} [primcodable α] {p : α → Prop} [decidable_pred p]\n    (hp : primrec_pred p) : primrec_pred fun (a : α) => ¬p a :=\n  sorry\n\nprotected theorem and {α : Type u_1} [primcodable α] {p : α → Prop} {q : α → Prop}\n    [decidable_pred p] [decidable_pred q] (hp : primrec_pred p) (hq : primrec_pred q) :\n    primrec_pred fun (a : α) => p a ∧ q a :=\n  sorry\n\nprotected theorem or {α : Type u_1} [primcodable α] {p : α → Prop} {q : α → Prop} [decidable_pred p]\n    [decidable_pred q] (hp : primrec_pred p) (hq : primrec_pred q) :\n    primrec_pred fun (a : α) => p a ∨ q a :=\n  sorry\n\nprotected theorem eq {α : Type u_1} [primcodable α] [DecidableEq α] : primrec_rel Eq := sorry\n\ntheorem nat_lt : primrec_rel Less := sorry\n\ntheorem option_guard {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β]\n    {p : α → β → Prop} [(a : α) → (b : β) → Decidable (p a b)] (hp : primrec_rel p) {f : α → β}\n    (hf : primrec f) : primrec fun (a : α) => option.guard (p a) (f a) :=\n  ite (primrec_rel.comp hp primrec.id hf) (iff.mpr option_some_iff hf) (const none)\n\ntheorem option_orelse {α : Type u_1} [primcodable α] : primrec₂ has_orelse.orelse := sorry\n\nprotected theorem decode2 {α : Type u_1} [primcodable α] : primrec (encodable.decode2 α) :=\n  option_bind primrec.decode\n    (option_guard (primrec_rel.comp primrec.eq (iff.mpr encode_iff snd) (comp fst fst)) snd)\n\ntheorem list_find_index₁ {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β]\n    {p : α → β → Prop} [(a : α) → (b : β) → Decidable (p a b)] (hp : primrec_rel p) (l : List β) :\n    primrec fun (a : α) => list.find_index (p a) l :=\n  sorry\n\ntheorem list_index_of₁ {α : Type u_1} [primcodable α] [DecidableEq α] (l : List α) :\n    primrec fun (a : α) => list.index_of a l :=\n  list_find_index₁ primrec.eq l\n\ntheorem dom_fintype {α : Type u_1} {σ : Type u_5} [primcodable α] [primcodable σ] [fintype α]\n    (f : α → σ) : primrec f :=\n  sorry\n\ntheorem nat_bodd_div2 : primrec nat.bodd_div2 := sorry\n\ntheorem nat_bodd : primrec nat.bodd := comp fst nat_bodd_div2\n\ntheorem nat_div2 : primrec nat.div2 := comp snd nat_bodd_div2\n\ntheorem nat_bit0 : primrec bit0 := primrec₂.comp nat_add primrec.id primrec.id\n\ntheorem nat_bit1 : primrec bit1 := primrec₂.comp nat_add nat_bit0 (const 1)\n\ntheorem nat_bit : primrec₂ nat.bit := sorry\n\ntheorem nat_div_mod : primrec₂ fun (n k : ℕ) => (n / k, n % k) := sorry\n\ntheorem nat_div : primrec₂ Div.div := comp₂ fst nat_div_mod\n\ntheorem nat_mod : primrec₂ Mod.mod := comp₂ snd nat_div_mod\n\nend primrec\n\n\nnamespace primcodable\n\n\nprotected instance sum {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] :\n    primcodable (α ⊕ β) :=\n  mk sorry\n\nprotected instance list {α : Type u_1} [primcodable α] : primcodable (List α) := mk sorry\n\nend primcodable\n\n\nnamespace primrec\n\n\ntheorem sum_inl {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] : primrec sum.inl :=\n  iff.mp encode_iff (comp nat_bit0 primrec.encode)\n\ntheorem sum_inr {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] : primrec sum.inr :=\n  iff.mp encode_iff (comp nat_bit1 primrec.encode)\n\ntheorem sum_cases {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_4} [primcodable α]\n    [primcodable β] [primcodable γ] [primcodable σ] {f : α → β ⊕ γ} {g : α → β → σ} {h : α → γ → σ}\n    (hf : primrec f) (hg : primrec₂ g) (hh : primrec₂ h) :\n    primrec fun (a : α) => sum.cases_on (f a) (g a) (h a) :=\n  sorry\n\ntheorem list_cons {α : Type u_1} [primcodable α] : primrec₂ List.cons :=\n  list_cons' (primcodable.prim (List α))\n\ntheorem list_cases {α : Type u_1} {β : Type u_2} {σ : Type u_4} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → List β} {g : α → σ} {h : α → β × List β → σ} :\n    primrec f →\n        primrec g →\n          primrec₂ h →\n            primrec\n              fun (a : α) => list.cases_on (f a) (g a) fun (b : β) (l : List β) => h a (b, l) :=\n  list_cases' (primcodable.prim (List β))\n\ntheorem list_foldl {α : Type u_1} {β : Type u_2} {σ : Type u_4} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → List β} {g : α → σ} {h : α → σ × β → σ} :\n    primrec f →\n        primrec g →\n          primrec₂ h →\n            primrec fun (a : α) => list.foldl (fun (s : σ) (b : β) => h a (s, b)) (g a) (f a) :=\n  list_foldl' (primcodable.prim (List β))\n\ntheorem list_reverse {α : Type u_1} [primcodable α] : primrec list.reverse :=\n  list_reverse' (primcodable.prim (List α))\n\ntheorem list_foldr {α : Type u_1} {β : Type u_2} {σ : Type u_4} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → List β} {g : α → σ} {h : α → β × σ → σ} (hf : primrec f)\n    (hg : primrec g) (hh : primrec₂ h) :\n    primrec fun (a : α) => list.foldr (fun (b : β) (s : σ) => h a (b, s)) (g a) (f a) :=\n  sorry\n\ntheorem list_head' {α : Type u_1} [primcodable α] : primrec list.head' := sorry\n\ntheorem list_head {α : Type u_1} [primcodable α] [Inhabited α] : primrec list.head :=\n  of_eq (comp option_iget list_head') fun (l : List α) => Eq.symm (list.head_eq_head' l)\n\ntheorem list_tail {α : Type u_1} [primcodable α] : primrec list.tail := sorry\n\ntheorem list_rec {α : Type u_1} {β : Type u_2} {σ : Type u_4} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → List β} {g : α → σ} {h : α → β × List β × σ → σ} (hf : primrec f)\n    (hg : primrec g) (hh : primrec₂ h) :\n    primrec\n        fun (a : α) =>\n          list.rec_on (f a) (g a) fun (b : β) (l : List β) (IH : σ) => h a (b, l, IH) :=\n  sorry\n\ntheorem list_nth {α : Type u_1} [primcodable α] : primrec₂ list.nth := sorry\n\ntheorem list_inth {α : Type u_1} [primcodable α] [Inhabited α] : primrec₂ list.inth :=\n  comp₂ option_iget list_nth\n\ntheorem list_append {α : Type u_1} [primcodable α] : primrec₂ append := sorry\n\ntheorem list_concat {α : Type u_1} [primcodable α] :\n    primrec₂ fun (l : List α) (a : α) => l ++ [a] :=\n  primrec₂.comp list_append fst (primrec₂.comp list_cons snd (const []))\n\ntheorem list_map {α : Type u_1} {β : Type u_2} {σ : Type u_4} [primcodable α] [primcodable β]\n    [primcodable σ] {f : α → List β} {g : α → β → σ} (hf : primrec f) (hg : primrec₂ g) :\n    primrec fun (a : α) => list.map (g a) (f a) :=\n  sorry\n\ntheorem list_range : primrec list.range := sorry\n\ntheorem list_join {α : Type u_1} [primcodable α] : primrec list.join := sorry\n\ntheorem list_length {α : Type u_1} [primcodable α] : primrec list.length := sorry\n\ntheorem list_find_index {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β]\n    {f : α → List β} {p : α → β → Prop} [(a : α) → (b : β) → Decidable (p a b)] (hf : primrec f)\n    (hp : primrec_rel p) : primrec fun (a : α) => list.find_index (p a) (f a) :=\n  sorry\n\ntheorem list_index_of {α : Type u_1} [primcodable α] [DecidableEq α] : primrec₂ list.index_of :=\n  to₂ (list_find_index snd (primrec_rel.comp₂ primrec.eq (to₂ (comp fst fst)) (to₂ snd)))\n\ntheorem nat_strong_rec {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] (f : α → ℕ → σ)\n    {g : α → List σ → Option σ} (hg : primrec₂ g)\n    (H : ∀ (a : α) (n : ℕ), g a (list.map (f a) (list.range n)) = some (f a n)) : primrec₂ f :=\n  sorry\n\nend primrec\n\n\nnamespace primcodable\n\n\ndef subtype {α : Type u_1} [primcodable α] {p : α → Prop} [decidable_pred p] (hp : primrec_pred p) :\n    primcodable (Subtype p) :=\n  mk sorry\n\nprotected instance fin {n : ℕ} : primcodable (fin n) :=\n  of_equiv (Subtype fun (a : ℕ) => id a < n) (equiv.fin_equiv_subtype n)\n\nprotected instance vector {α : Type u_1} [primcodable α] {n : ℕ} : primcodable (vector α n) :=\n  subtype sorry\n\nprotected instance fin_arrow {α : Type u_1} [primcodable α] {n : ℕ} : primcodable (fin n → α) :=\n  of_equiv (vector α n) (equiv.symm (equiv.vector_equiv_fin α n))\n\nprotected instance array {α : Type u_1} [primcodable α] {n : ℕ} : primcodable (array n α) :=\n  of_equiv (fin n → α) (equiv.array_equiv_fin n α)\n\nprotected instance ulower {α : Type u_1} [primcodable α] : primcodable (ulower α) :=\n  (fun (this : primrec_pred fun (n : ℕ) => encodable.decode2 α n ≠ none) => subtype sorry) sorry\n\nend primcodable\n\n\nnamespace primrec\n\n\ntheorem subtype_val {α : Type u_1} [primcodable α] {p : α → Prop} [decidable_pred p]\n    {hp : primrec_pred p} : primrec subtype.val :=\n  sorry\n\ntheorem subtype_val_iff {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {p : β → Prop}\n    [decidable_pred p] {hp : primrec_pred p} {f : α → Subtype p} :\n    (primrec fun (a : α) => subtype.val (f a)) ↔ primrec f :=\n  sorry\n\ntheorem subtype_mk {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {p : β → Prop}\n    [decidable_pred p] {hp : primrec_pred p} {f : α → β} {h : ∀ (a : α), p (f a)} (hf : primrec f) :\n    primrec fun (a : α) => { val := f a, property := h a } :=\n  iff.mp subtype_val_iff hf\n\ntheorem option_get {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {f : α → Option β}\n    {h : ∀ (a : α), ↥(option.is_some (f a))} :\n    primrec f → primrec fun (a : α) => option.get (h a) :=\n  sorry\n\ntheorem ulower_down {α : Type u_1} [primcodable α] : primrec ulower.down :=\n  subtype_mk primrec.encode\n\ntheorem ulower_up {α : Type u_1} [primcodable α] : primrec ulower.up :=\n  option_get (comp primrec.decode2 subtype_val)\n\ntheorem fin_val_iff {α : Type u_1} [primcodable α] {n : ℕ} {f : α → fin n} :\n    (primrec fun (a : α) => subtype.val (f a)) ↔ primrec f :=\n  iff.trans (iff.trans (iff.refl (primrec fun (a : α) => subtype.val (f a))) subtype_val_iff)\n    (of_equiv_iff (equiv.fin_equiv_subtype n))\n\ntheorem fin_val {n : ℕ} : primrec coe := iff.mpr fin_val_iff primrec.id\n\ntheorem fin_succ {n : ℕ} : primrec fin.succ := sorry\n\ntheorem vector_to_list {α : Type u_1} [primcodable α] {n : ℕ} : primrec vector.to_list :=\n  subtype_val\n\ntheorem vector_to_list_iff {α : Type u_1} {β : Type u_2} [primcodable α] [primcodable β] {n : ℕ}\n    {f : α → vector β n} : (primrec fun (a : α) => vector.to_list (f a)) ↔ primrec f :=\n  subtype_val_iff\n\ntheorem vector_cons {α : Type u_1} [primcodable α] {n : ℕ} : primrec₂ vector.cons := sorry\n\ntheorem vector_length {α : Type u_1} [primcodable α] {n : ℕ} : primrec vector.length := const n\n\ntheorem vector_head {α : Type u_1} [primcodable α] {n : ℕ} : primrec vector.head := sorry\n\ntheorem vector_tail {α : Type u_1} [primcodable α] {n : ℕ} : primrec vector.tail := sorry\n\ntheorem vector_nth {α : Type u_1} [primcodable α] {n : ℕ} : primrec₂ vector.nth := sorry\n\ntheorem list_of_fn {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {n : ℕ}\n    {f : fin n → α → σ} :\n    (∀ (i : fin n), primrec (f i)) → primrec fun (a : α) => list.of_fn fun (i : fin n) => f i a :=\n  sorry\n\ntheorem vector_of_fn {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {n : ℕ}\n    {f : fin n → α → σ} (hf : ∀ (i : fin n), primrec (f i)) :\n    primrec fun (a : α) => vector.of_fn fun (i : fin n) => f i a :=\n  sorry\n\ntheorem vector_nth' {α : Type u_1} [primcodable α] {n : ℕ} : primrec vector.nth := of_equiv_symm\n\ntheorem vector_of_fn' {α : Type u_1} [primcodable α] {n : ℕ} : primrec vector.of_fn := of_equiv\n\ntheorem fin_app {σ : Type u_4} [primcodable σ] {n : ℕ} : primrec₂ id := sorry\n\ntheorem fin_curry₁ {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {n : ℕ}\n    {f : fin n → α → σ} : primrec₂ f ↔ ∀ (i : fin n), primrec (f i) :=\n  sorry\n\ntheorem fin_curry {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {n : ℕ}\n    {f : α → fin n → σ} : primrec f ↔ primrec₂ f :=\n  sorry\n\nend primrec\n\n\nnamespace nat\n\n\n/-- An alternative inductive definition of `primrec` which\n  does not use the pairing function on ℕ, and so has to\n  work with n-ary functions on ℕ instead of unary functions.\n  We prove that this is equivalent to the regular notion\n  in `to_prim` and `of_prim`. -/\ninductive primrec' : {n : ℕ} → (vector ℕ n → ℕ) → Prop where\n| zero : primrec' fun (_x : vector ℕ 0) => 0\n| succ : primrec' fun (v : vector ℕ 1) => Nat.succ (vector.head v)\n| nth : ∀ {n : ℕ} (i : fin n), primrec' fun (v : vector ℕ n) => vector.nth v i\n| comp :\n    ∀ {m n : ℕ} {f : vector ℕ n → ℕ} (g : fin n → vector ℕ m → ℕ),\n      primrec' f →\n        (∀ (i : fin n), primrec' (g i)) →\n          primrec' fun (a : vector ℕ m) => f (vector.of_fn fun (i : fin n) => g i a)\n| prec :\n    ∀ {n : ℕ} {f : vector ℕ n → ℕ} {g : vector ℕ (n + bit0 1) → ℕ},\n      primrec' f →\n        primrec' g →\n          primrec'\n            fun (v : vector ℕ (n + 1)) =>\n              elim (f (vector.tail v)) (fun (y IH : ℕ) => g (y::ᵥIH::ᵥvector.tail v))\n                (vector.head v)\n\nend nat\n\n\nnamespace nat.primrec'\n\n\ntheorem to_prim {n : ℕ} {f : vector ℕ n → ℕ} (pf : primrec' f) : primrec f := sorry\n\ntheorem of_eq {n : ℕ} {f : vector ℕ n → ℕ} {g : vector ℕ n → ℕ} (hf : primrec' f)\n    (H : ∀ (i : vector ℕ n), f i = g i) : primrec' g :=\n  funext H ▸ hf\n\ntheorem const {n : ℕ} (m : ℕ) : primrec' fun (v : vector ℕ n) => m := sorry\n\ntheorem head {n : ℕ} : primrec' vector.head := sorry\n\ntheorem tail {n : ℕ} {f : vector ℕ n → ℕ} (hf : primrec' f) :\n    primrec' fun (v : vector ℕ (Nat.succ n)) => f (vector.tail v) :=\n  sorry\n\ndef vec {n : ℕ} {m : ℕ} (f : vector ℕ n → vector ℕ m) :=\n  ∀ (i : fin m), primrec' fun (v : vector ℕ n) => vector.nth (f v) i\n\nprotected theorem nil {n : ℕ} : vec fun (_x : vector ℕ n) => vector.nil :=\n  fun (i : fin 0) => fin.elim0 i\n\nprotected theorem cons {n : ℕ} {m : ℕ} {f : vector ℕ n → ℕ} {g : vector ℕ n → vector ℕ m}\n    (hf : primrec' f) (hg : vec g) : vec fun (v : vector ℕ n) => f v::ᵥg v :=\n  sorry\n\ntheorem idv {n : ℕ} : vec id := nth\n\ntheorem comp' {n : ℕ} {m : ℕ} {f : vector ℕ m → ℕ} {g : vector ℕ n → vector ℕ m} (hf : primrec' f)\n    (hg : vec g) : primrec' fun (v : vector ℕ n) => f (g v) :=\n  sorry\n\ntheorem comp₁ (f : ℕ → ℕ) (hf : primrec' fun (v : vector ℕ 1) => f (vector.head v)) {n : ℕ}\n    {g : vector ℕ n → ℕ} (hg : primrec' g) : primrec' fun (v : vector ℕ n) => f (g v) :=\n  comp (fun (i : fin 1) => g) hf fun (i : fin 1) => hg\n\ntheorem comp₂ (f : ℕ → ℕ → ℕ)\n    (hf : primrec' fun (v : vector ℕ (bit0 1)) => f (vector.head v) (vector.head (vector.tail v)))\n    {n : ℕ} {g : vector ℕ n → ℕ} {h : vector ℕ n → ℕ} (hg : primrec' g) (hh : primrec' h) :\n    primrec' fun (v : vector ℕ n) => f (g v) (h v) :=\n  sorry\n\ntheorem prec' {n : ℕ} {f : vector ℕ n → ℕ} {g : vector ℕ n → ℕ} {h : vector ℕ (n + bit0 1) → ℕ}\n    (hf : primrec' f) (hg : primrec' g) (hh : primrec' h) :\n    primrec' fun (v : vector ℕ n) => elim (g v) (fun (y IH : ℕ) => h (y::ᵥIH::ᵥv)) (f v) :=\n  sorry\n\ntheorem pred : primrec' fun (v : vector ℕ 1) => Nat.pred (vector.head v) := sorry\n\ntheorem add : primrec' fun (v : vector ℕ (bit0 1)) => vector.head v + vector.head (vector.tail v) :=\n  sorry\n\ntheorem sub : primrec' fun (v : vector ℕ (bit0 1)) => vector.head v - vector.head (vector.tail v) :=\n  sorry\n\ntheorem mul : primrec' fun (v : vector ℕ (bit0 1)) => vector.head v * vector.head (vector.tail v) :=\n  sorry\n\ntheorem if_lt {n : ℕ} {a : vector ℕ n → ℕ} {b : vector ℕ n → ℕ} {f : vector ℕ n → ℕ}\n    {g : vector ℕ n → ℕ} (ha : primrec' a) (hb : primrec' b) (hf : primrec' f) (hg : primrec' g) :\n    primrec' fun (v : vector ℕ n) => ite (a v < b v) (f v) (g v) :=\n  sorry\n\ntheorem mkpair :\n    primrec' fun (v : vector ℕ (bit0 1)) => mkpair (vector.head v) (vector.head (vector.tail v)) :=\n  if_lt head (tail head) (comp₂ Add.add add (tail (comp₂ Mul.mul mul head head)) head)\n    (comp₂ Add.add add (comp₂ Add.add add (comp₂ Mul.mul mul head head) head) (tail head))\n\nprotected theorem encode {n : ℕ} : primrec' encodable.encode := sorry\n\ntheorem sqrt : primrec' fun (v : vector ℕ 1) => sqrt (vector.head v) := sorry\n\ntheorem unpair₁ {n : ℕ} {f : vector ℕ n → ℕ} (hf : primrec' f) :\n    primrec' fun (v : vector ℕ n) => prod.fst (unpair (f v)) :=\n  sorry\n\ntheorem unpair₂ {n : ℕ} {f : vector ℕ n → ℕ} (hf : primrec' f) :\n    primrec' fun (v : vector ℕ n) => prod.snd (unpair (f v)) :=\n  sorry\n\ntheorem of_prim {n : ℕ} {f : vector ℕ n → ℕ} : primrec f → primrec' f := sorry\n\ntheorem prim_iff {n : ℕ} {f : vector ℕ n → ℕ} : primrec' f ↔ primrec f :=\n  { mp := to_prim, mpr := of_prim }\n\ntheorem prim_iff₁ {f : ℕ → ℕ} : (primrec' fun (v : vector ℕ 1) => f (vector.head v)) ↔ primrec f :=\n  sorry\n\ntheorem prim_iff₂ {f : ℕ → ℕ → ℕ} :\n    (primrec' fun (v : vector ℕ (bit0 1)) => f (vector.head v) (vector.head (vector.tail v))) ↔\n        primrec₂ f :=\n  sorry\n\ntheorem vec_iff {m : ℕ} {n : ℕ} {f : vector ℕ m → vector ℕ n} : vec f ↔ primrec f := sorry\n\nend nat.primrec'\n\n\ntheorem primrec.nat_sqrt : primrec nat.sqrt := iff.mp nat.primrec'.prim_iff₁ nat.primrec'.sqrt\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/computability/primrec_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.4980314947217899}}
{"text": "/-\nCopyright (c) 2017 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Mario Carneiro\n-/\nimport data.rat.cast\nimport data.rat.meta_defs\n\n/-!\n# `norm_num`\n\nEvaluating arithmetic expressions including `*`, `+`, `-`, `^`, `≤`.\n-/\n\nuniverses u v w\n\nnamespace tactic\n\n/-- Reflexivity conversion: given `e` returns `(e, ⊢ e = e)` -/\nmeta def refl_conv (e : expr) : tactic (expr × expr) :=\ndo p ← mk_eq_refl e, return (e, p)\n\n/-- Turns a conversion tactic into one that always succeeds, where failure is interpreted as a\nproof by reflexivity. -/\nmeta def or_refl_conv (tac : expr → tactic (expr × expr))\n  (e : expr) : tactic (expr × expr) := tac e <|> refl_conv e\n\n/-- Transitivity conversion: given two conversions (which take an\nexpression `e` and returns `(e', ⊢ e = e')`), produces another\nconversion that combines them with transitivity, treating failures\nas reflexivity conversions. -/\nmeta def trans_conv (t₁ t₂ : expr → tactic (expr × expr)) (e : expr) :\n  tactic (expr × expr) :=\n(do (e₁, p₁) ← t₁ e,\n  (do (e₂, p₂) ← t₂ e₁,\n    p ← mk_eq_trans p₁ p₂, return (e₂, p)) <|>\n  return (e₁, p₁)) <|> t₂ e\n\nnamespace instance_cache\n\n/-- Faster version of `mk_app ``bit0 [e]`. -/\nmeta def mk_bit0 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) :=\ndo (c, ai) ← c.get ``has_add,\n   return (c, (expr.const ``bit0 [c.univ]).mk_app [c.α, ai, e])\n\n/-- Faster version of `mk_app ``bit1 [e]`. -/\nmeta def mk_bit1 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) :=\ndo (c, ai) ← c.get ``has_add,\n   (c, oi) ← c.get ``has_one,\n   return (c, (expr.const ``bit1 [c.univ]).mk_app [c.α, oi, ai, e])\n\nend instance_cache\n\nend tactic\n\nopen tactic\n\n/-!\nEach lemma in this file is written the way it is to exactly match (with no defeq reduction allowed)\nthe conclusion of some lemma generated by the proof procedure that uses it. That proof procedure\nshould describe the shape of the generated lemma in its docstring.\n-/\n\nnamespace norm_num\nvariable {α : Type u}\n\nlemma subst_into_add {α} [has_add α] (l r tl tr t)\n  (prl : (l : α) = tl) (prr : r = tr) (prt : tl + tr = t) : l + r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_mul {α} [has_mul α] (l r tl tr t)\n  (prl : (l : α) = tl) (prr : r = tr) (prt : tl * tr = t) : l * r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_neg {α} [has_neg α] (a ta t : α) (pra : a = ta) (prt : -ta = t) : -a = t :=\nby simp [pra, prt]\n\n/-- The result type of `match_numeral`, either `0`, `1`, or a top level\ndecomposition of `bit0 e` or `bit1 e`. The `other` case means it is not a numeral. -/\nmeta inductive match_numeral_result\n| zero | one | bit0 (e : expr) | bit1 (e : expr) | other\n\n/-- Unfold the top level constructor of the numeral expression. -/\nmeta def match_numeral : expr → match_numeral_result\n| `(bit0 %%e) := match_numeral_result.bit0 e\n| `(bit1 %%e) := match_numeral_result.bit1 e\n| `(@has_zero.zero _ _) := match_numeral_result.zero\n| `(@has_one.one _ _) := match_numeral_result.one\n| _ := match_numeral_result.other\n\ntheorem zero_succ {α} [semiring α] : (0 + 1 : α) = 1 := zero_add _\ntheorem one_succ {α} [semiring α] : (1 + 1 : α) = 2 := rfl\ntheorem bit0_succ {α} [semiring α] (a : α) : bit0 a + 1 = bit1 a := rfl\ntheorem bit1_succ {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 = bit0 b :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\n/-- Given `a`, `b` natural numerals, proves `⊢ a + 1 = b`, assuming that this is provable.\n(It may prove garbage instead of failing if `a + 1 = b` is false.) -/\nmeta def prove_succ : instance_cache → expr → expr → tactic (instance_cache × expr)\n| c e r := match match_numeral e with\n  | zero := c.mk_app ``zero_succ []\n  | one := c.mk_app ``one_succ []\n  | bit0 e := c.mk_app ``bit0_succ [e]\n  | bit1 e := do\n    let r := r.app_arg,\n    (c, p) ← prove_succ c e r,\n    c.mk_app ``bit1_succ [e, r, p]\n  | _ := failed\n  end\nend\n\n/-- Given `a` natural numeral, returns `(b, ⊢ a + 1 = b)`. -/\nmeta def prove_succ' (c : instance_cache) (a : expr) : tactic (instance_cache × expr × expr) :=\ndo na ← a.to_nat,\n  (c, b) ← c.of_nat (na + 1),\n  (c, p) ← prove_succ c a b,\n  return (c, b, p)\n\ntheorem zero_adc {α} [semiring α] (a b : α) (h : a + 1 = b) : 0 + a + 1 = b := by rwa zero_add\ntheorem adc_zero {α} [semiring α] (a b : α) (h : a + 1 = b) : a + 0 + 1 = b := by rwa add_zero\ntheorem one_add {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + a = b := by rwa add_comm\ntheorem add_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b = bit0 c :=\nh ▸ by simp [bit0, add_left_comm, add_assoc]\ntheorem add_bit0_bit1 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit1 b = bit1 c :=\nh ▸ by simp [bit0, bit1, add_left_comm, add_assoc]\ntheorem add_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit1 a + bit0 b = bit1 c :=\nh ▸ by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem add_bit1_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) : bit1 a + bit1 b = bit0 c :=\nh ▸ by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem adc_one_one {α} [semiring α] : (1 + 1 + 1 : α) = 3 := rfl\ntheorem adc_bit0_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit0 a + 1 + 1 = bit0 b :=\nh ▸ by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit0 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit0 a + 1 = bit0 b :=\nh ▸ by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 + 1 = bit1 b :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit1 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit1 a + 1 = bit1 b :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b + 1 = bit1 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) :\n  bit1 a + bit0 b + 1 = bit0 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) :\n  bit0 a + bit1 b + 1 = bit0 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) :\n  bit1 a + bit1 b + 1 = bit1 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\nmeta mutual def prove_add_nat, prove_adc_nat\nwith prove_add_nat : instance_cache → expr → expr → expr → tactic (instance_cache × expr)\n| c a b r := do\n  match match_numeral a, match_numeral b with\n  | zero, _ := c.mk_app ``zero_add [b]\n  | _, zero := c.mk_app ``add_zero [a]\n  | _, one := prove_succ c a r\n  | one, _ := do (c, p) ← prove_succ c b r, c.mk_app ``one_add [b, r, p]\n  | bit0 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit0_bit0 [a, b, r, p]\n  | bit0 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit0_bit1 [a, b, r, p]\n  | bit1 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit1_bit0 [a, b, r, p]\n  | bit1 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``add_bit1_bit1 [a, b, r, p]\n  | _, _ := failed\n  end\nwith prove_adc_nat : instance_cache → expr → expr → expr → tactic (instance_cache × expr)\n| c a b r := do\n  match match_numeral a, match_numeral b with\n  | zero, _ := do (c, p) ← prove_succ c b r, c.mk_app ``zero_adc [b, r, p]\n  | _, zero := do (c, p) ← prove_succ c b r, c.mk_app ``adc_zero [b, r, p]\n  | one, one := c.mk_app ``adc_one_one []\n  | bit0 a, one :=\n    do let r := r.app_arg, (c, p) ← prove_succ c a r, c.mk_app ``adc_bit0_one [a, r, p]\n  | one, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_succ c b r, c.mk_app ``adc_one_bit0 [b, r, p]\n  | bit1 a, one :=\n    do let r := r.app_arg, (c, p) ← prove_succ c a r, c.mk_app ``adc_bit1_one [a, r, p]\n  | one, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_succ c b r, c.mk_app ``adc_one_bit1 [b, r, p]\n  | bit0 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``adc_bit0_bit0 [a, b, r, p]\n  | bit0 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit0_bit1 [a, b, r, p]\n  | bit1 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit1_bit0 [a, b, r, p]\n  | bit1 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit1_bit1 [a, b, r, p]\n  | _, _ := failed\n  end\n\n/-- Given `a`,`b`,`r` natural numerals, proves `⊢ a + b = r`. -/\nadd_decl_doc prove_add_nat\n/-- Given `a`,`b`,`r` natural numerals, proves `⊢ a + b + 1 = r`. -/\nadd_decl_doc prove_adc_nat\n\n/-- Given `a`,`b` natural numerals, returns `(r, ⊢ a + b = r)`. -/\nmeta def prove_add_nat' (c : instance_cache) (a b : expr) : tactic (instance_cache × expr × expr) :=\ndo na ← a.to_nat,\n  nb ← b.to_nat,\n  (c, r) ← c.of_nat (na + nb),\n  (c, p) ← prove_add_nat c a b r,\n  return (c, r, p)\n\nend\n\ntheorem bit0_mul {α} [semiring α] (a b c : α) (h : a * b = c) :\n  bit0 a * b = bit0 c := h ▸ by simp [bit0, add_mul]\ntheorem mul_bit0' {α} [semiring α] (a b c : α) (h : a * b = c) :\n  a * bit0 b = bit0 c := h ▸ by simp [bit0, mul_add]\ntheorem mul_bit0_bit0 {α} [semiring α] (a b c : α) (h : a * b = c) :\n  bit0 a * bit0 b = bit0 (bit0 c) := bit0_mul _ _ _ (mul_bit0' _ _ _ h)\ntheorem mul_bit1_bit1 {α} [semiring α] (a b c d e : α)\n  (hc : a * b = c) (hd : a + b = d) (he : bit0 c + d = e) :\n  bit1 a * bit1 b = bit1 e :=\nby rw [← he, ← hd, ← hc]; simp [bit1, bit0, mul_add, add_mul, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\n/-- Given `a`,`b` natural numerals, returns `(r, ⊢ a * b = r)`. -/\nmeta def prove_mul_nat : instance_cache → expr → expr → tactic (instance_cache × expr × expr)\n| ic a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := do\n    (ic, z) ← ic.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``zero_mul [b],\n    return (ic, z, p)\n  | _, zero := do\n    (ic, z) ← ic.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``mul_zero [a],\n    return (ic, z, p)\n  | one, _ := do (ic, p) ← ic.mk_app ``one_mul [b], return (ic, b, p)\n  | _, one := do (ic, p) ← ic.mk_app ``mul_one [a], return (ic, a, p)\n  | bit0 a, bit0 b := do\n    (ic, c, p) ← prove_mul_nat ic a b,\n    (ic, p) ← ic.mk_app ``mul_bit0_bit0 [a, b, c, p],\n    (ic, c') ← ic.mk_bit0 c,\n    (ic, c') ← ic.mk_bit0 c',\n    return (ic, c', p)\n  | bit0 a, _ := do\n    (ic, c, p) ← prove_mul_nat ic a b,\n    (ic, p) ← ic.mk_app ``bit0_mul [a, b, c, p],\n    (ic, c') ← ic.mk_bit0 c,\n    return (ic, c', p)\n  | _, bit0 b := do\n    (ic, c, p) ← prove_mul_nat ic a b,\n    (ic, p) ← ic.mk_app ``mul_bit0' [a, b, c, p],\n    (ic, c') ← ic.mk_bit0 c,\n    return (ic, c', p)\n  | bit1 a, bit1 b := do\n    (ic, c, pc) ← prove_mul_nat ic a b,\n    (ic, d, pd) ← prove_add_nat' ic a b,\n    (ic, c') ← ic.mk_bit0 c,\n    (ic, e, pe) ← prove_add_nat' ic c' d,\n    (ic, p) ← ic.mk_app ``mul_bit1_bit1 [a, b, c, d, e, pc, pd, pe],\n    (ic, e') ← ic.mk_bit1 e,\n    return (ic, e', p)\n  | _, _ := failed\n  end\n\nend\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a positive natural numeral, returns `⊢ 0 < a`. -/\nmeta def prove_pos_nat (c : instance_cache) : expr → tactic (instance_cache × expr)\n| e :=\n  match match_numeral e with\n  | one := c.mk_app ``zero_lt_one' []\n  | bit0 e := do (c, p) ← prove_pos_nat e, c.mk_app ``bit0_pos [e, p]\n  | bit1 e := do (c, p) ← prove_pos_nat e, c.mk_app ``bit1_pos' [e, p]\n  | _ := failed\n  end\n\nend\n\n/-- Given `a` a rational numeral, returns `⊢ 0 < a`. -/\nmeta def prove_pos (c : instance_cache) : expr → tactic (instance_cache × expr)\n| `(%%e₁ / %%e₂) := do\n  (c, p₁) ← prove_pos_nat c e₁, (c, p₂) ← prove_pos_nat c e₂,\n  c.mk_app ``div_pos [e₁, e₂, p₁, p₂]\n| e := prove_pos_nat c e\n\n/-- `match_neg (- e) = some e`, otherwise `none` -/\nmeta def match_neg : expr → option expr\n| `(- %%e) := some e\n| _ := none\n\n/-- `match_sign (- e) = inl e`, `match_sign 0 = inr ff`, otherwise `inr tt` -/\nmeta def match_sign : expr → expr ⊕ bool\n| `(- %%e) := sum.inl e\n| `(has_zero.zero) := sum.inr ff\n| _ := sum.inr tt\n\ntheorem ne_zero_of_pos {α} [ordered_add_comm_group α] (a : α) : 0 < a → a ≠ 0 := ne_of_gt\ntheorem ne_zero_neg {α} [add_group α] (a : α) : a ≠ 0 → -a ≠ 0 := mt neg_eq_zero.1\n\n/-- Given `a` a rational numeral, returns `⊢ a ≠ 0`. -/\nmeta def prove_ne_zero' (c : instance_cache) : expr → tactic (instance_cache × expr)\n| a :=\n  match match_neg a with\n  | some a := do (c, p) ← prove_ne_zero' a, c.mk_app ``ne_zero_neg [a, p]\n  | none := do (c, p) ← prove_pos c a, c.mk_app ``ne_zero_of_pos [a, p]\n  end\n\ntheorem clear_denom_div {α} [division_ring α] (a b b' c d : α)\n  (h₀ : b ≠ 0) (h₁ : b * b' = d) (h₂ : a * b' = c) : (a / b) * d = c :=\nby rwa [← h₁, ← mul_assoc, div_mul_cancel _ h₀]\n\n/-- Given `a` nonnegative rational and `d` a natural number, returns `(b, ⊢ a * d = b)`.\n(`d` should be a multiple of the denominator of `a`, so that `b` is a natural number.) -/\nmeta def prove_clear_denom'\n  (prove_ne_zero : instance_cache → expr → ℚ → tactic (instance_cache × expr))\n  (c : instance_cache) (a d : expr) (na : ℚ) (nd : ℕ) :\n  tactic (instance_cache × expr × expr) :=\nif na.denom = 1 then\n  prove_mul_nat c a d\nelse do\n  [_, _, a, b] ← return a.get_app_args,\n  (c, b') ← c.of_nat (nd / na.denom),\n  (c, p₀) ← prove_ne_zero c b (rat.of_int na.denom),\n  (c, _, p₁) ← prove_mul_nat c b b',\n  (c, r, p₂) ← prove_mul_nat c a b',\n  (c, p) ← c.mk_app ``clear_denom_div [a, b, b', r, d, p₀, p₁, p₂],\n  return (c, r, p)\n\ntheorem nonneg_pos {α} [ordered_cancel_add_comm_monoid α] (a : α) : 0 < a → 0 ≤ a := le_of_lt\n\ntheorem lt_one_bit0 {α} [linear_ordered_semiring α] (a : α) (h : 1 ≤ a) : 1 < bit0 a :=\nlt_of_lt_of_le one_lt_two (bit0_le_bit0.2 h)\ntheorem lt_one_bit1 {α} [linear_ordered_semiring α] (a : α) (h : 0 < a) : 1 < bit1 a :=\none_lt_bit1.2 h\ntheorem lt_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a < b → bit0 a < bit0 b :=\nbit0_lt_bit0.2\ntheorem lt_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a < bit1 b :=\nlt_of_le_of_lt (bit0_le_bit0.2 h) (lt_add_one _)\ntheorem lt_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a < bit0 b :=\nlt_of_lt_of_le (by simp [bit0, bit1, zero_lt_one, add_assoc]) (bit0_le_bit0.2 h)\ntheorem lt_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) : a < b → bit1 a < bit1 b :=\nbit1_lt_bit1.2\n\ntheorem le_one_bit0 {α} [linear_ordered_semiring α] (a : α) (h : 1 ≤ a) : 1 ≤ bit0 a :=\nle_of_lt (lt_one_bit0 _ h)\n-- deliberately strong hypothesis because bit1 0 is not a numeral\ntheorem le_one_bit1 {α} [linear_ordered_semiring α] (a : α) (h : 0 < a) : 1 ≤ bit1 a :=\nle_of_lt (lt_one_bit1 _ h)\ntheorem le_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a ≤ b → bit0 a ≤ bit0 b :=\nbit0_le_bit0.2\ntheorem le_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a ≤ bit1 b :=\nle_of_lt (lt_bit0_bit1 _ _ h)\ntheorem le_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a ≤ bit0 b :=\nle_of_lt (lt_bit1_bit0 _ _ h)\ntheorem le_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) : a ≤ b → bit1 a ≤ bit1 b :=\nbit1_le_bit1.2\n\ntheorem sle_one_bit0 {α} [linear_ordered_semiring α] (a : α) : 1 ≤ a → 1 + 1 ≤ bit0 a :=\nbit0_le_bit0.2\ntheorem sle_one_bit1 {α} [linear_ordered_semiring α] (a : α) : 1 ≤ a → 1 + 1 ≤ bit1 a :=\nle_bit0_bit1 _ _\ntheorem sle_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a + 1 ≤ b → bit0 a + 1 ≤ bit0 b :=\nle_bit1_bit0 _ _\ntheorem sle_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a + 1 ≤ bit1 b :=\nbit1_le_bit1.2 h\ntheorem sle_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) :\n  bit1 a + 1 ≤ bit0 b :=\n(bit1_succ a _ rfl).symm ▸ bit0_le_bit0.2 h\ntheorem sle_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) :\n  bit1 a + 1 ≤ bit1 b :=\n(bit1_succ a _ rfl).symm ▸ le_bit0_bit1 _ _ h\n\n/-- Given `a` a rational numeral, returns `⊢ 0 ≤ a`. -/\nmeta def prove_nonneg (ic : instance_cache) : expr → tactic (instance_cache × expr)\n| e@`(has_zero.zero) := ic.mk_app ``le_refl [e]\n| e :=\n  if ic.α = `(ℕ) then\n    return (ic, `(nat.zero_le).mk_app [e])\n  else do\n    (ic, p) ← prove_pos ic e,\n    ic.mk_app ``nonneg_pos [e, p]\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a rational numeral, returns `⊢ 1 ≤ a`. -/\nmeta def prove_one_le_nat (ic : instance_cache) : expr → tactic (instance_cache × expr)\n| a :=\n  match match_numeral a with\n  | one := ic.mk_app ``le_refl [a]\n  | bit0 a := do (ic, p) ← prove_one_le_nat a, ic.mk_app ``le_one_bit0 [a, p]\n  | bit1 a := do (ic, p) ← prove_pos_nat ic a, ic.mk_app ``le_one_bit1 [a, p]\n  | _ := failed\n  end\n\nmeta mutual def prove_le_nat, prove_sle_nat (ic : instance_cache)\nwith prove_le_nat : expr → expr → tactic (instance_cache × expr)\n| a b :=\n  if a = b then ic.mk_app ``le_refl [a] else\n  match match_numeral a, match_numeral b with\n  | zero, _ := prove_nonneg ic b\n  | one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``le_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) ← prove_pos_nat ic b, ic.mk_app ``le_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``le_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\nwith prove_sle_nat : expr → expr → tactic (instance_cache × expr)\n| a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := prove_nonneg ic b\n  | one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``sle_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``sle_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``sle_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\n\n/-- Given `a`,`b` natural numerals, proves `⊢ a ≤ b`. -/\nadd_decl_doc prove_le_nat\n/-- Given `a`,`b` natural numerals, proves `⊢ a + 1 ≤ b`. -/\nadd_decl_doc prove_sle_nat\n\n/-- Given `a`,`b` natural numerals, proves `⊢ a < b`. -/\nmeta def prove_lt_nat (ic : instance_cache) : expr → expr → tactic (instance_cache × expr)\n| a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := prove_pos ic b\n  | one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``lt_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) ← prove_pos_nat ic b, ic.mk_app ``lt_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) ← prove_lt_nat a b, ic.mk_app ``lt_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) ← prove_le_nat ic a b, ic.mk_app ``lt_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) ← prove_sle_nat ic a b, ic.mk_app ``lt_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) ← prove_lt_nat a b, ic.mk_app ``lt_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\n\nend\n\ntheorem clear_denom_lt {α} [linear_ordered_semiring α] (a a' b b' d : α)\n  (h₀ : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' < b') : a < b :=\nlt_of_mul_lt_mul_right (by rwa [ha, hb]) (le_of_lt h₀)\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `⊢ a < b`. -/\nmeta def prove_lt_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_lt_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) ← ic.of_nat nd,\n  (ic, p₀) ← prove_pos ic d,\n  (ic, a', pa) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) ← prove_lt_nat ic a' b',\n  ic.mk_app ``clear_denom_lt [a, a', b, b', d, p₀, pa, pb, p]\n\nlemma lt_neg_pos {α} [ordered_add_comm_group α] (a b : α) (ha : 0 < a) (hb : 0 < b) : -a < b :=\nlt_trans (neg_neg_of_pos ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a < b`. -/\nmeta def prove_lt_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  -- we have to switch the order of `a` and `b` because `a < b ↔ -b < -a`\n  (ic, p) ← prove_lt_nonneg_rat ic b a (-nb) (-na),\n  ic.mk_app ``neg_lt_neg [b, a, p]\n| sum.inl a, sum.inr ff := do\n  (ic, p) ← prove_pos ic a,\n  ic.mk_app ``neg_neg_of_pos [a, p]\n| sum.inl a, sum.inr tt := do\n  (ic, pa) ← prove_pos ic a,\n  (ic, pb) ← prove_pos ic b,\n  ic.mk_app ``lt_neg_pos [a, b, pa, pb]\n| sum.inr ff, _ := prove_pos ic b\n| sum.inr tt, _ := prove_lt_nonneg_rat ic a b na nb\nend\n\ntheorem clear_denom_le {α} [linear_ordered_semiring α] (a a' b b' d : α)\n  (h₀ : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' ≤ b') : a ≤ b :=\nle_of_mul_le_mul_right (by rwa [ha, hb]) h₀\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `⊢ a ≤ b`. -/\nmeta def prove_le_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_le_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) ← ic.of_nat nd,\n  (ic, p₀) ← prove_pos ic d,\n  (ic, a', pa) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) ← prove_le_nat ic a' b',\n  ic.mk_app ``clear_denom_le [a, a', b, b', d, p₀, pa, pb, p]\n\nlemma le_neg_pos {α} [ordered_add_comm_group α] (a b : α) (ha : 0 ≤ a) (hb : 0 ≤ b) : -a ≤ b :=\nle_trans (neg_nonpos_of_nonneg ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a ≤ b`. -/\nmeta def prove_le_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, p) ← prove_le_nonneg_rat ic a b (-na) (-nb),\n  ic.mk_app ``neg_le_neg [a, b, p]\n| sum.inl a, sum.inr ff := do\n  (ic, p) ← prove_nonneg ic a,\n  ic.mk_app ``neg_nonpos_of_nonneg [a, p]\n| sum.inl a, sum.inr tt := do\n  (ic, pa) ← prove_nonneg ic a,\n  (ic, pb) ← prove_nonneg ic b,\n  ic.mk_app ``le_neg_pos [a, b, pa, pb]\n| sum.inr ff, _ := prove_nonneg ic b\n| sum.inr tt, _ := prove_le_nonneg_rat ic a b na nb\nend\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a ≠ b`. This version tries to prove\n`⊢ a < b` or `⊢ b < a`, and so is not appropriate for types without an order relation. -/\nmeta def prove_ne_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nif na < nb then do\n  (ic, p) ← prove_lt_rat ic a b na nb,\n  ic.mk_app ``ne_of_lt [a, b, p]\nelse do\n  (ic, p) ← prove_lt_rat ic b a nb na,\n  ic.mk_app ``ne_of_gt [a, b, p]\n\ntheorem nat_cast_zero {α} [semiring α] : ↑(0 : ℕ) = (0 : α) := nat.cast_zero\ntheorem nat_cast_one {α} [semiring α] : ↑(1 : ℕ) = (1 : α) := nat.cast_one\ntheorem nat_cast_bit0 {α} [semiring α] (a : ℕ) (a' : α) (h : ↑a = a') : ↑(bit0 a) = bit0 a' :=\nh ▸ nat.cast_bit0 _\ntheorem nat_cast_bit1 {α} [semiring α] (a : ℕ) (a' : α) (h : ↑a = a') : ↑(bit1 a) = bit1 a' :=\nh ▸ nat.cast_bit1 _\ntheorem int_cast_zero {α} [ring α] : ↑(0 : ℤ) = (0 : α) := int.cast_zero\ntheorem int_cast_one {α} [ring α] : ↑(1 : ℤ) = (1 : α) := int.cast_one\ntheorem int_cast_bit0 {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑(bit0 a) = bit0 a' :=\nh ▸ int.cast_bit0 _\ntheorem int_cast_bit1 {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑(bit1 a) = bit1 a' :=\nh ▸ int.cast_bit1 _\ntheorem rat_cast_bit0 {α} [division_ring α] [char_zero α] (a : ℚ) (a' : α) (h : ↑a = a') :\n  ↑(bit0 a) = bit0 a' :=\nh ▸ rat.cast_bit0 _\ntheorem rat_cast_bit1 {α} [division_ring α] [char_zero α] (a : ℚ) (a' : α) (h : ↑a = a') :\n  ↑(bit1 a) = bit1 a' :=\nh ▸ rat.cast_bit1 _\n\n/-- Given `a' : α` a natural numeral, returns `(a : ℕ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_nat_uncast (ic nc : instance_cache) : ∀ (a' : expr),\n  tactic (instance_cache × instance_cache × expr × expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (nc, e) ← nc.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``nat_cast_zero [],\n    return (ic, nc, e, p)\n  | match_numeral_result.one := do\n    (nc, e) ← nc.mk_app ``has_one.one [],\n    (ic, p) ← ic.mk_app ``nat_cast_one [],\n    return (ic, nc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, nc, a, p) ← prove_nat_uncast a',\n    (nc, a0) ← nc.mk_bit0 a,\n    (ic, p) ← ic.mk_app ``nat_cast_bit0 [a, a', p],\n    return (ic, nc, a0, p)\n  | match_numeral_result.bit1 a' := do\n    (ic, nc, a, p) ← prove_nat_uncast a',\n    (nc, a1) ← nc.mk_bit1 a,\n    (ic, p) ← ic.mk_app ``nat_cast_bit1 [a, a', p],\n    return (ic, nc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : α` a natural numeral, returns `(a : ℤ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_int_uncast_nat (ic zc : instance_cache) : ∀ (a' : expr),\n  tactic (instance_cache × instance_cache × expr × expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (zc, e) ← zc.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``int_cast_zero [],\n    return (ic, zc, e, p)\n  | match_numeral_result.one := do\n    (zc, e) ← zc.mk_app ``has_one.one [],\n    (ic, p) ← ic.mk_app ``int_cast_one [],\n    return (ic, zc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, zc, a, p) ← prove_int_uncast_nat a',\n    (zc, a0) ← zc.mk_bit0 a,\n    (ic, p) ← ic.mk_app ``int_cast_bit0 [a, a', p],\n    return (ic, zc, a0, p)\n  | match_numeral_result.bit1 a' := do\n    (ic, zc, a, p) ← prove_int_uncast_nat a',\n    (zc, a1) ← zc.mk_bit1 a,\n    (ic, p) ← ic.mk_app ``int_cast_bit1 [a, a', p],\n    return (ic, zc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : α` a natural numeral, returns `(a : ℚ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_rat_uncast_nat (ic qc : instance_cache) (cz_inst : expr) : ∀ (a' : expr),\n  tactic (instance_cache × instance_cache × expr × expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (qc, e) ← qc.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``rat.cast_zero [],\n    return (ic, qc, e, p)\n  | match_numeral_result.one := do\n    (qc, e) ← qc.mk_app ``has_one.one [],\n    (ic, p) ← ic.mk_app ``rat.cast_one [],\n    return (ic, qc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, qc, a, p) ← prove_rat_uncast_nat a',\n    (qc, a0) ← qc.mk_bit0 a,\n    (ic, p) ← ic.mk_app ``rat_cast_bit0 [cz_inst, a, a', p],\n    return (ic, qc, a0, p)\n  | match_numeral_result.bit1 a' := do\n    (ic, qc, a, p) ← prove_rat_uncast_nat a',\n    (qc, a1) ← qc.mk_bit1 a,\n    (ic, p) ← ic.mk_app ``rat_cast_bit1 [cz_inst, a, a', p],\n    return (ic, qc, a1, p)\n  | _ := failed\n  end\n\ntheorem rat_cast_div {α} [division_ring α] [char_zero α] (a b : ℚ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') : ↑(a / b) = a' / b' :=\nha ▸ hb ▸ rat.cast_div _ _\n\n/-- Given `a' : α` a nonnegative rational numeral, returns `(a : ℚ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_rat_uncast_nonneg (ic qc : instance_cache) (cz_inst a' : expr) (na' : ℚ) :\n tactic (instance_cache × instance_cache × expr × expr) :=\nif na'.denom = 1 then\n  prove_rat_uncast_nat ic qc cz_inst a'\nelse do\n  [_, _, a', b'] ← return a'.get_app_args,\n  (ic, qc, a, pa) ← prove_rat_uncast_nat ic qc cz_inst a',\n  (ic, qc, b, pb) ← prove_rat_uncast_nat ic qc cz_inst b',\n  (qc, e) ← qc.mk_app ``has_div.div [a, b],\n  (ic, p) ← ic.mk_app ``rat_cast_div [cz_inst, a, b, a', b', pa, pb],\n  return (ic, qc, e, p)\n\ntheorem int_cast_neg {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑-a = -a' :=\nh ▸ int.cast_neg _\ntheorem rat_cast_neg {α} [division_ring α] (a : ℚ) (a' : α) (h : ↑a = a') : ↑-a = -a' :=\nh ▸ rat.cast_neg _\n\n/-- Given `a' : α` an integer numeral, returns `(a : ℤ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_int_uncast (ic zc : instance_cache) (a' : expr) :\n  tactic (instance_cache × instance_cache × expr × expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, zc, a, p) ← prove_int_uncast_nat ic zc a',\n  (zc, e) ← zc.mk_app ``has_neg.neg [a],\n  (ic, p) ← ic.mk_app ``int_cast_neg [a, a', p],\n  return (ic, zc, e, p)\n| none := prove_int_uncast_nat ic zc a'\nend\n\n/-- Given `a' : α` a rational numeral, returns `(a : ℚ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_rat_uncast (ic qc : instance_cache) (cz_inst a' : expr) (na' : ℚ) :\n  tactic (instance_cache × instance_cache × expr × expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, qc, a, p) ← prove_rat_uncast_nonneg ic qc cz_inst a' (-na'),\n  (qc, e) ← qc.mk_app ``has_neg.neg [a],\n  (ic, p) ← ic.mk_app ``rat_cast_neg [a, a', p],\n  return (ic, qc, e, p)\n| none := prove_rat_uncast_nonneg ic qc cz_inst a' na'\nend\n\ntheorem nat_cast_ne {α} [semiring α] [char_zero α] (a b : ℕ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=\nha ▸ hb ▸ mt nat.cast_inj.1 h\ntheorem int_cast_ne {α} [ring α] [char_zero α] (a b : ℤ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=\nha ▸ hb ▸ mt int.cast_inj.1 h\ntheorem rat_cast_ne {α} [division_ring α] [char_zero α] (a b : ℚ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=\nha ▸ hb ▸ mt rat.cast_inj.1 h\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a ≠ b`. Currently it tries two methods:\n\n  * Prove `⊢ a < b` or `⊢ b < a`, if the base type has an order\n  * Embed `↑(a':ℚ) = a` and `↑(b':ℚ) = b`, and then prove `a' ≠ b'`.\n    This requires that the base type be `char_zero`, and also that it be a `division_ring`\n    so that the coercion from `ℚ` is well defined.\n\nWe may also add coercions to `ℤ` and `ℕ` as well in order to support `char_zero`\nrings and semirings. -/\nmeta def prove_ne : instance_cache → expr → expr → ℚ → ℚ → tactic (instance_cache × expr)\n| ic a b na nb := prove_ne_rat ic a b na nb <|> do\n  cz_inst ← mk_mapp ``char_zero [ic.α, none, none] >>= mk_instance,\n  if na.denom = 1 ∧ nb.denom = 1 then\n    if na ≥ 0 ∧ nb ≥ 0 then do\n      guard (ic.α ≠ `(ℕ)),\n      nc ← mk_instance_cache `(ℕ),\n      (ic, nc, a', pa) ← prove_nat_uncast ic nc a,\n      (ic, nc, b', pb) ← prove_nat_uncast ic nc b,\n      (nc, p) ← prove_ne_rat nc a' b' na nb,\n      ic.mk_app ``nat_cast_ne [cz_inst, a', b', a, b, pa, pb, p]\n    else do\n      guard (ic.α ≠ `(ℤ)),\n      zc ← mk_instance_cache `(ℤ),\n      (ic, zc, a', pa) ← prove_int_uncast ic zc a,\n      (ic, zc, b', pb) ← prove_int_uncast ic zc b,\n      (zc, p) ← prove_ne_rat zc a' b' na nb,\n      ic.mk_app ``int_cast_ne [cz_inst, a', b', a, b, pa, pb, p]\n  else do\n    guard (ic.α ≠ `(ℚ)),\n    qc ← mk_instance_cache `(ℚ),\n    (ic, qc, a', pa) ← prove_rat_uncast ic qc cz_inst a na,\n    (ic, qc, b', pb) ← prove_rat_uncast ic qc cz_inst b nb,\n    (qc, p) ← prove_ne_rat qc a' b' na nb,\n    ic.mk_app ``rat_cast_ne [cz_inst, a', b', a, b, pa, pb, p]\n\n/-- Given `a` a rational numeral, returns `⊢ a ≠ 0`. -/\nmeta def prove_ne_zero (ic : instance_cache) : expr → ℚ → tactic (instance_cache × expr)\n| a na := do\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  prove_ne ic a z na 0\n\n/-- Given `a` nonnegative rational and `d` a natural number, returns `(b, ⊢ a * d = b)`.\n(`d` should be a multiple of the denominator of `a`, so that `b` is a natural number.) -/\nmeta def prove_clear_denom : instance_cache → expr → expr → ℚ → ℕ →\n  tactic (instance_cache × expr × expr) := prove_clear_denom' prove_ne_zero\n\ntheorem clear_denom_add {α} [division_ring α] (a a' b b' c c' d : α)\n  (h₀ : d ≠ 0) (ha : a * d = a') (hb : b * d = b') (hc : c * d = c')\n  (h : a' + b' = c') : a + b = c :=\nmul_right_cancel' h₀ $ by rwa [add_mul, ha, hb, hc]\n\n/-- Given `a`,`b`,`c` nonnegative rational numerals, returns `⊢ a + b = c`. -/\nmeta def prove_add_nonneg_rat (ic : instance_cache) (a b c : expr) (na nb nc : ℚ) :\n  tactic (instance_cache × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_add_nat ic a b c\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) ← ic.of_nat nd,\n  (ic, p₀) ← prove_ne_zero ic d (rat.of_int nd),\n  (ic, a', pa) ← prove_clear_denom ic a d na nd,\n  (ic, b', pb) ← prove_clear_denom ic b d nb nd,\n  (ic, c', pc) ← prove_clear_denom ic c d nc nd,\n  (ic, p) ← prove_add_nat ic a' b' c',\n  ic.mk_app ``clear_denom_add [a, a', b, b', c, c', d, p₀, pa, pb, pc, p]\n\ntheorem add_pos_neg_pos {α} [add_group α] (a b c : α) (h : c + b = a) : a + -b = c :=\nh ▸ by simp\ntheorem add_pos_neg_neg {α} [add_group α] (a b c : α) (h : c + a = b) : a + -b = -c :=\nh ▸ by simp\ntheorem add_neg_pos_pos {α} [add_group α] (a b c : α) (h : a + c = b) : -a + b = c :=\nh ▸ by simp\ntheorem add_neg_pos_neg {α} [add_group α] (a b c : α) (h : b + c = a) : -a + b = -c :=\nh ▸ by simp\ntheorem add_neg_neg {α} [add_group α] (a b c : α) (h : b + a = c) : -a + -b = -c :=\nh ▸ by simp\n\n/-- Given `a`,`b`,`c` rational numerals, returns `⊢ a + b = c`. -/\nmeta def prove_add_rat (ic : instance_cache) (ea eb ec : expr) (a b c : ℚ) :\n  tactic (instance_cache × expr) :=\nmatch match_neg ea, match_neg eb, match_neg ec with\n| some ea, some eb, some ec := do\n  (ic, p) ← prove_add_nonneg_rat ic eb ea ec (-b) (-a) (-c),\n  ic.mk_app ``add_neg_neg [ea, eb, ec, p]\n| some ea, none, some ec := do\n  (ic, p) ← prove_add_nonneg_rat ic eb ec ea b (-c) (-a),\n  ic.mk_app ``add_neg_pos_neg [ea, eb, ec, p]\n| some ea, none, none := do\n  (ic, p) ← prove_add_nonneg_rat ic ea ec eb (-a) c b,\n  ic.mk_app ``add_neg_pos_pos [ea, eb, ec, p]\n| none, some eb, some ec := do\n  (ic, p) ← prove_add_nonneg_rat ic ec ea eb (-c) a (-b),\n  ic.mk_app ``add_pos_neg_neg [ea, eb, ec, p]\n| none, some eb, none := do\n  (ic, p) ← prove_add_nonneg_rat ic ec eb ea c (-b) a,\n  ic.mk_app ``add_pos_neg_pos [ea, eb, ec, p]\n| _, _, _ := prove_add_nonneg_rat ic ea eb ec a b c\nend\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a + b = c)`. -/\nmeta def prove_add_rat' (ic : instance_cache) (a b : expr) :\n  tactic (instance_cache × expr × expr) :=\ndo na ← a.to_rat,\n  nb ← b.to_rat,\n  let nc := na + nb,\n  (ic, c) ← ic.of_rat nc,\n  (ic, p) ← prove_add_rat ic a b c na nb nc,\n  return (ic, c, p)\n\ntheorem clear_denom_simple_nat {α} [division_ring α] (a : α) :\n  (1:α) ≠ 0 ∧ a * 1 = a := ⟨one_ne_zero, mul_one _⟩\ntheorem clear_denom_simple_div {α} [division_ring α] (a b : α) (h : b ≠ 0) :\n  b ≠ 0 ∧ a / b * b = a := ⟨h, div_mul_cancel _ h⟩\n\n/-- Given `a` a nonnegative rational numeral, returns `(b, c, ⊢ a * b = c)`\nwhere `b` and `c` are natural numerals. (`b` will be the denominator of `a`.) -/\nmeta def prove_clear_denom_simple (c : instance_cache) (a : expr) (na : ℚ) :\n  tactic (instance_cache × expr × expr × expr) :=\nif na.denom = 1 then do\n  (c, d) ← c.mk_app ``has_one.one [],\n  (c, p) ← c.mk_app ``clear_denom_simple_nat [a],\n  return (c, d, a, p)\nelse do\n  [α, _, a, b] ← return a.get_app_args,\n  (c, p₀) ← prove_ne_zero c b (rat.of_int na.denom),\n  (c, p) ← c.mk_app ``clear_denom_simple_div [a, b, p₀],\n  return (c, b, a, p)\n\ntheorem clear_denom_mul {α} [field α] (a a' b b' c c' d₁ d₂ d : α)\n  (ha : d₁ ≠ 0 ∧ a * d₁ = a') (hb : d₂ ≠ 0 ∧ b * d₂ = b')\n  (hc : c * d = c') (hd : d₁ * d₂ = d)\n  (h : a' * b' = c') : a * b = c :=\nmul_right_cancel' ha.1 $ mul_right_cancel' hb.1 $\nby rw [mul_assoc c, hd, hc, ← h, ← ha.2, ← hb.2, ← mul_assoc, mul_right_comm a]\n\n/-- Given `a`,`b` nonnegative rational numerals, returns `(c, ⊢ a * b = c)`. -/\nmeta def prove_mul_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_mul_nat ic a b\nelse do\n  let nc := na * nb, (ic, c) ← ic.of_rat nc,\n  (ic, d₁, a', pa) ← prove_clear_denom_simple ic a na,\n  (ic, d₂, b', pb) ← prove_clear_denom_simple ic b nb,\n  (ic, d, pd) ← prove_mul_nat ic d₁ d₂, nd ← d.to_nat,\n  (ic, c', pc) ← prove_clear_denom ic c d nc nd,\n  (ic, _, p) ← prove_mul_nat ic a' b',\n  (ic, p) ← ic.mk_app ``clear_denom_mul [a, a', b, b', c, c', d₁, d₂, d, pa, pb, pc, pd, p],\n  return (ic, c, p)\n\ntheorem mul_neg_pos {α} [ring α] (a b c : α) (h : a * b = c) : -a * b = -c := h ▸ by simp\ntheorem mul_pos_neg {α} [ring α] (a b c : α) (h : a * b = c) : a * -b = -c := h ▸ by simp\ntheorem mul_neg_neg {α} [ring α] (a b c : α) (h : a * b = c) : -a * -b = c := h ▸ by simp\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a * b = c)`. -/\nmeta def prove_mul_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr × expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, c, p) ← prove_mul_nonneg_rat ic a b (-na) (-nb),\n  (ic, p) ← ic.mk_app ``mul_neg_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff, _ := do\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  (ic, p) ← ic.mk_app ``zero_mul [b],\n  return (ic, z, p)\n| _, sum.inr ff := do\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  (ic, p) ← ic.mk_app ``mul_zero [a],\n  return (ic, z, p)\n| sum.inl a, sum.inr tt := do\n  (ic, c, p) ← prove_mul_nonneg_rat ic a b (-na) nb,\n  (ic, p) ← ic.mk_app ``mul_neg_pos [a, b, c, p],\n  (ic, c') ← ic.mk_app ``has_neg.neg [c],\n  return (ic, c', p)\n| sum.inr tt, sum.inl b := do\n  (ic, c, p) ← prove_mul_nonneg_rat ic a b na (-nb),\n  (ic, p) ← ic.mk_app ``mul_pos_neg [a, b, c, p],\n  (ic, c') ← ic.mk_app ``has_neg.neg [c],\n  return (ic, c', p)\n| sum.inr tt, sum.inr tt := prove_mul_nonneg_rat ic a b na nb\nend\n\ntheorem inv_neg {α} [division_ring α] (a b : α) (h : a⁻¹ = b) : (-a)⁻¹ = -b :=\nh ▸ by simp only [inv_eq_one_div, one_div_neg_eq_neg_one_div]\n\n\n\n/-- Given `a` a rational numeral, returns `(b, ⊢ a⁻¹ = b)`. -/\nmeta def prove_inv : instance_cache → expr → ℚ → tactic (instance_cache × expr × expr)\n| ic e n :=\n  match match_sign e with\n  | sum.inl e := do\n    (ic, e', p) ← prove_inv ic e (-n),\n    (ic, r) ← ic.mk_app ``has_neg.neg [e'],\n    (ic, p) ← ic.mk_app ``inv_neg [e, e', p],\n    return (ic, r, p)\n  | sum.inr ff := do\n    (ic, p) ← ic.mk_app ``inv_zero [],\n    return (ic, e, p)\n  | sum.inr tt :=\n    if n.num = 1 then\n      if n.denom = 1 then do\n        (ic, p) ← ic.mk_app ``inv_one [],\n        return (ic, e, p)\n      else do\n        let e := e.app_arg,\n        (ic, p) ← ic.mk_app ``inv_one_div [e],\n        return (ic, e, p)\n    else if n.denom = 1 then do\n      (ic, p) ← ic.mk_app ``inv_div_one [e],\n      e ← infer_type p,\n      return (ic, e.app_arg, p)\n    else do\n      [_, _, a, b] ← return e.get_app_args,\n      (ic, e') ← ic.mk_app ``has_div.div [b, a],\n      (ic, p) ← ic.mk_app ``inv_div [a, b],\n      return (ic, e', p)\n  end\n\ntheorem div_eq {α} [division_ring α] (a b b' c : α)\n  (hb : b⁻¹ = b') (h : a * b' = c) : a / b = c :=\nby rwa [ ← hb, ← div_eq_mul_inv] at h\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a / b = c)`. -/\nmeta def prove_div (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr × expr) :=\ndo (ic, b', pb) ← prove_inv ic b nb,\n  (ic, c, p) ← prove_mul_rat ic a b' na nb⁻¹,\n  (ic, p) ← ic.mk_app ``div_eq [a, b, b', c, pb, p],\n  return (ic, c, p)\n\n/-- Given `a` a rational numeral, returns `(b, ⊢ -a = b)`. -/\nmeta def prove_neg (ic : instance_cache) (a : expr) : tactic (instance_cache × expr × expr) :=\nmatch match_sign a with\n| sum.inl a := do\n  (ic, p) ← ic.mk_app ``neg_neg [a],\n  return (ic, a, p)\n| sum.inr ff := do\n  (ic, p) ← ic.mk_app ``neg_zero [],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, a') ← ic.mk_app ``has_neg.neg [a],\n  p ← mk_eq_refl a',\n  return (ic, a', p)\nend\n\ntheorem sub_pos {α} [add_group α] (a b b' c : α) (hb : -b = b') (h : a + b' = c) : a - b = c :=\nby rwa [← hb, ← sub_eq_add_neg] at h\n\ntheorem sub_neg {α} [add_group α] (a b c : α) (h : a + b = c) : a - -b = c :=\nby rwa sub_neg_eq_add\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a - b = c)`. -/\nmeta def prove_sub (ic : instance_cache) (a b : expr) : tactic (instance_cache × expr × expr) :=\nmatch match_sign b with\n| sum.inl b := do\n  (ic, c, p) ← prove_add_rat' ic a b,\n  (ic, p) ← ic.mk_app ``sub_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff := do\n  (ic, p) ← ic.mk_app ``sub_zero [a],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, b', pb) ← prove_neg ic b,\n  (ic, c, p) ← prove_add_rat' ic a b',\n  (ic, p) ← ic.mk_app ``sub_pos [a, b, b', c, pb, p],\n  return (ic, c, p)\nend\n\ntheorem sub_nat_pos (a b c : ℕ) (h : b + c = a) : a - b = c :=\nh ▸ nat.add_sub_cancel_left _ _\ntheorem sub_nat_neg (a b c : ℕ) (h : a + c = b) : a - b = 0 :=\nnat.sub_eq_zero_of_le $ h ▸ nat.le_add_right _ _\n\n/-- Given `a : nat`,`b : nat` natural numerals, returns `(c, ⊢ a - b = c)`. -/\nmeta def prove_sub_nat (ic : instance_cache) (a b : expr) : tactic (expr × expr) :=\ndo na ← a.to_nat, nb ← b.to_nat,\n  if nb ≤ na then do\n    (ic, c) ← ic.of_nat (na - nb),\n    (ic, p) ← prove_add_nat ic b c a,\n    return (c, `(sub_nat_pos).mk_app [a, b, c, p])\n  else do\n    (ic, c) ← ic.of_nat (nb - na),\n    (ic, p) ← prove_add_nat ic a c b,\n    return (`(0 : ℕ), `(sub_nat_neg).mk_app [a, b, c, p])\n\n/-- Evaluates the basic field operations `+`,`neg`,`-`,`*`,`inv`,`/` on numerals.\nAlso handles nat subtraction. Does not do recursive simplification; that is,\n`1 + 1 + 1` will not simplify but `2 + 1` will. This is handled by the top level\n`simp` call in `norm_num.derive`. -/\nmeta def eval_field : expr → tactic (expr × expr)\n| `(%%e₁ + %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  let n₃ := n₁ + n₂,\n  (c, e₃) ← c.of_rat n₃,\n  (_, p) ← prove_add_rat c e₁ e₂ e₃ n₁ n₂ n₃,\n  return (e₃, p)\n| `(%%e₁ * %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  prod.snd <$> prove_mul_rat c e₁ e₂ n₁ n₂\n| `(- %%e) := do\n  c ← infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_neg c e\n| `(@has_sub.sub %%α %%inst %%a %%b) := do\n  c ← mk_instance_cache α,\n  if α = `(nat) then prove_sub_nat c a b\n  else prod.snd <$> prove_sub c a b\n| `(has_inv.inv %%e) := do\n  n ← e.to_rat,\n  c ← infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_inv c e n\n| `(%%e₁ / %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  prod.snd <$> prove_div c e₁ e₂ n₁ n₂\n| _ := failed\n\nlemma pow_bit0 [monoid α] (a c' c : α) (b : ℕ)\n  (h : a ^ b = c') (h₂ : c' * c' = c) : a ^ bit0 b = c :=\nh₂ ▸ by simp [pow_bit0, h]\n\nlemma pow_bit1 [monoid α] (a c₁ c₂ c : α) (b : ℕ)\n  (h : a ^ b = c₁) (h₂ : c₁ * c₁ = c₂) (h₃ : c₂ * a = c) : a ^ bit1 b = c :=\nby rw [← h₃, ← h₂]; simp [pow_bit1, h]\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a rational numeral and `b : nat`, returns `(c, ⊢ a ^ b = c)`. -/\nmeta def prove_pow (a : expr) (na : ℚ) :\n  instance_cache → expr → tactic (instance_cache × expr × expr)\n| ic b :=\n  match match_numeral b with\n  | zero := do\n    (ic, p) ← ic.mk_app ``pow_zero [a],\n    (ic, o) ← ic.mk_app ``has_one.one [],\n    return (ic, o, p)\n  | one := do\n    (ic, p) ← ic.mk_app ``pow_one [a],\n    return (ic, a, p)\n  | bit0 b := do\n    (ic, c', p) ← prove_pow ic b,\n    nc' ← expr.to_rat c',\n    (ic, c, p₂) ← prove_mul_rat ic c' c' nc' nc',\n    (ic, p) ← ic.mk_app ``pow_bit0 [a, c', c, b, p, p₂],\n    return (ic, c, p)\n  | bit1 b := do\n    (ic, c₁, p) ← prove_pow ic b,\n    nc₁ ← expr.to_rat c₁,\n    (ic, c₂, p₂) ← prove_mul_rat ic c₁ c₁ nc₁ nc₁,\n    (ic, c, p₃) ← prove_mul_rat ic c₂ a (nc₁ * nc₁) na,\n    (ic, p) ← ic.mk_app ``pow_bit1 [a, c₁, c₂, c, b, p, p₂, p₃],\n    return (ic, c, p)\n  | _ := failed\n  end\n\nend\n\n/-- Evaluates expressions of the form `a ^ b`, `monoid.npow a b` or `nat.pow a b`. -/\nmeta def eval_pow : expr → tactic (expr × expr)\n| `(@has_pow.pow %%α _ %%m %%e₁ %%e₂) := do\n  n₁ ← e₁.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  match m with\n  | `(@monoid.has_pow %%_ %%_) := prod.snd <$> prove_pow e₁ n₁ c e₂\n  | _ := failed\n  end\n| `(monoid.npow %%e₁ %%e₂) := do\n  n₁ ← e₁.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  prod.snd <$> prove_pow e₁ n₁ c e₂\n| _ := failed\n\n/-- Given `⊢ p`, returns `(true, ⊢ p = true)`. -/\nmeta def true_intro (p : expr) : tactic (expr × expr) :=\nprod.mk `(true) <$> mk_app ``eq_true_intro [p]\n\n/-- Given `⊢ ¬ p`, returns `(false, ⊢ p = false)`. -/\nmeta def false_intro (p : expr) : tactic (expr × expr) :=\nprod.mk `(false) <$> mk_app ``eq_false_intro [p]\n\ntheorem not_refl_false_intro {α} (a : α) : (a ≠ a) = false :=\neq_false_intro $ not_not_intro rfl\n\n/-- Evaluates the inequality operations `=`,`<`,`>`,`≤`,`≥`,`≠` on numerals. -/\nmeta def eval_ineq : expr → tactic (expr × expr)\n| `(%%e₁ < %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ < n₂ then\n    do (_, p) ← prove_lt_rat c e₁ e₂ n₁ n₂, true_intro p\n  else if n₁ = n₂ then do\n    (_, p) ← c.mk_app ``lt_irrefl [e₁],\n    false_intro p\n  else do\n    (c, p') ← prove_lt_rat c e₂ e₁ n₂ n₁,\n    (_, p) ← c.mk_app ``not_lt_of_gt [e₁, e₂, p'],\n    false_intro p\n| `(%%e₁ ≤ %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ ≤ n₂ then do\n    (_, p) ←\n      if n₁ = n₂ then c.mk_app ``le_refl [e₁]\n      else prove_le_rat c e₁ e₂ n₁ n₂,\n    true_intro p\n  else do\n    (c, p) ← prove_lt_rat c e₂ e₁ n₂ n₁,\n    (_, p) ← c.mk_app ``not_le_of_gt [e₁, e₂, p],\n    false_intro p\n| `(%%e₁ = %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ = n₂ then mk_eq_refl e₁ >>= true_intro\n  else do (_, p) ← prove_ne c e₁ e₂ n₁ n₂, false_intro p\n| `(%%e₁ > %%e₂) := mk_app ``has_lt.lt [e₂, e₁] >>= eval_ineq\n| `(%%e₁ ≥ %%e₂) := mk_app ``has_le.le [e₂, e₁] >>= eval_ineq\n| `(%%e₁ ≠ %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ = n₂ then\n    prod.mk `(false) <$> mk_app ``not_refl_false_intro [e₁]\n  else do (_, p) ← prove_ne c e₁ e₂ n₁ n₂, true_intro p\n| _ := failed\n\ntheorem nat_succ_eq (a b c : ℕ) (h₁ : a = b) (h₂ : b + 1 = c) : nat.succ a = c := by rwa h₁\n\n/-- Evaluates the expression `nat.succ ... (nat.succ n)` where `n` is a natural numeral.\n(We could also just handle `nat.succ n` here and rely on `simp` to work bottom up, but we figure\nthat towers of successors coming from e.g. `induction` are a common case.) -/\nmeta def prove_nat_succ (ic : instance_cache) : expr → tactic (instance_cache × ℕ × expr × expr)\n| `(nat.succ %%a) := do\n  (ic, n, b, p₁) ← prove_nat_succ a,\n  let n' := n + 1,\n  (ic, c) ← ic.of_nat n',\n  (ic, p₂) ← prove_add_nat ic b `(1) c,\n  return (ic, n', c, `(nat_succ_eq).mk_app [a, b, c, p₁, p₂])\n| e := do\n  n ← e.to_nat,\n  p ← mk_eq_refl e,\n  return (ic, n, e, p)\n\nlemma nat_div (a b q r m : ℕ) (hm : q * b = m) (h : r + m = a) (h₂ : r < b) : a / b = q :=\nby rw [← h, ← hm, nat.add_mul_div_right _ _ (lt_of_le_of_lt (nat.zero_le _) h₂),\n       nat.div_eq_of_lt h₂, zero_add]\n\nlemma int_div (a b q r m : ℤ) (hm : q * b = m) (h : r + m = a) (h₁ : 0 ≤ r) (h₂ : r < b) :\n  a / b = q :=\nby rw [← h, ← hm, int.add_mul_div_right _ _ (ne_of_gt (lt_of_le_of_lt h₁ h₂)),\n       int.div_eq_zero_of_lt h₁ h₂, zero_add]\n\nlemma nat_mod (a b q r m : ℕ) (hm : q * b = m) (h : r + m = a) (h₂ : r < b) : a % b = r :=\nby rw [← h, ← hm, nat.add_mul_mod_self_right, nat.mod_eq_of_lt h₂]\n\nlemma int_mod (a b q r m : ℤ) (hm : q * b = m) (h : r + m = a) (h₁ : 0 ≤ r) (h₂ : r < b) :\n  a % b = r :=\nby rw [← h, ← hm, int.add_mul_mod_self, int.mod_eq_of_lt h₁ h₂]\n\nlemma int_div_neg (a b c' c : ℤ) (h : a / b = c') (h₂ : -c' = c) : a / -b = c :=\nh₂ ▸ h ▸ int.div_neg _ _\n\nlemma int_mod_neg (a b c : ℤ) (h : a % b = c) : a % -b = c :=\n(int.mod_neg _ _).trans h\n\n/-- Given `a`,`b` numerals in `nat` or `int`,\n  * `prove_div_mod ic a b ff` returns `(c, ⊢ a / b = c)`\n  * `prove_div_mod ic a b tt` returns `(c, ⊢ a % b = c)`\n-/\nmeta def prove_div_mod (ic : instance_cache) :\n  expr → expr → bool → tactic (instance_cache × expr × expr)\n| a b mod :=\n  match match_neg b with\n  | some b := do\n    (ic, c', p) ← prove_div_mod a b mod,\n    if mod then\n      return (ic, c', `(int_mod_neg).mk_app [a, b, c', p])\n    else do\n      (ic, c, p₂) ← prove_neg ic c',\n      return (ic, c, `(int_div_neg).mk_app [a, b, c', c, p, p₂])\n  | none := do\n    nb ← b.to_nat,\n    na ← a.to_int,\n    let nq := na / nb,\n    let nr := na % nb,\n    let nm := nq * nr,\n    (ic, q) ← ic.of_int nq,\n    (ic, r) ← ic.of_int nr,\n    (ic, m, pm) ← prove_mul_rat ic q b (rat.of_int nq) (rat.of_int nb),\n    (ic, p) ← prove_add_rat ic r m a (rat.of_int nr) (rat.of_int nm) (rat.of_int na),\n    (ic, p') ← prove_lt_nat ic r b,\n    if ic.α = `(nat) then\n      if mod then return (ic, r, `(nat_mod).mk_app [a, b, q, r, m, pm, p, p'])\n      else        return (ic, q, `(nat_div).mk_app [a, b, q, r, m, pm, p, p'])\n    else if ic.α = `(int) then do\n      (ic, p₀) ← prove_nonneg ic r,\n      if mod then return (ic, r, `(int_mod).mk_app [a, b, q, r, m, pm, p, p₀, p'])\n      else        return (ic, q, `(int_div).mk_app [a, b, q, r, m, pm, p, p₀, p'])\n    else failed\n  end\n\ntheorem dvd_eq_nat (a b c : ℕ) (p) (h₁ : b % a = c) (h₂ : (c = 0) = p) : (a ∣ b) = p :=\n(propext $ by rw [← h₁, nat.dvd_iff_mod_eq_zero]).trans h₂\ntheorem dvd_eq_int (a b c : ℤ) (p) (h₁ : b % a = c) (h₂ : (c = 0) = p) : (a ∣ b) = p :=\n(propext $ by rw [← h₁, int.dvd_iff_mod_eq_zero]).trans h₂\n\ntheorem int_to_nat_pos (a : ℤ) (b : ℕ) (h : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = a) :\n  a.to_nat = b := by rw ← h; simp\ntheorem int_to_nat_neg (a : ℤ) (h : 0 < a) : (-a).to_nat = 0 :=\nby simp [int.to_nat_zero_of_neg, h]\n\ntheorem nat_abs_pos (a : ℤ) (b : ℕ) (h : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = a) :\n  a.nat_abs = b := by rw ← h; simp\ntheorem nat_abs_neg (a : ℤ) (b : ℕ) (h : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = a) :\n  (-a).nat_abs = b := by rw ← h; simp\n\ntheorem neg_succ_of_nat (a b : ℕ) (c : ℤ) (h₁ : a + 1 = b)\n  (h₂ : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = c) :\n  -[1+ a] = -c := by rw [← h₂, ← h₁, int.nat_cast_eq_coe_nat]; refl\n\n/-- Evaluates some extra numeric operations on `nat` and `int`, specifically\n`nat.succ`, `/` and `%`, and `∣` (divisibility). -/\nmeta def eval_nat_int_ext : expr → tactic (expr × expr)\n| e@`(nat.succ _) := do\n  ic ← mk_instance_cache `(ℕ),\n  (_, _, ep) ← prove_nat_succ ic e,\n  return ep\n| `(%%a / %%b) := do\n  c ← infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b ff\n| `(%%a % %%b) := do\n  c ← infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b tt\n| `(%%a ∣ %%b) := do\n  α ← infer_type a,\n  ic ← mk_instance_cache α,\n  th ← if α = `(nat) then return (`(dvd_eq_nat):expr) else\n       if α = `(int) then return `(dvd_eq_int) else failed,\n  (ic, c, p₁) ← prove_div_mod ic b a tt,\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  (e', p₂) ← mk_app ``eq [c, z] >>= eval_ineq,\n  return (e', th.mk_app [a, b, c, e', p₁, p₂])\n| `(int.to_nat %%a) := do\n  n ← a.to_int,\n  ic ← mk_instance_cache `(ℤ),\n  if n ≥ 0 then do\n    nc ← mk_instance_cache `(ℕ),\n    (_, _, b, p) ← prove_nat_uncast ic nc a,\n    pure (b, `(int_to_nat_pos).mk_app [a, b, p])\n  else do\n    a ← match_neg a,\n    (_, p) ← prove_pos ic a,\n    pure (`(0), `(int_to_nat_neg).mk_app [a, p])\n| `(int.nat_abs %%a) := do\n  n ← a.to_int,\n  ic ← mk_instance_cache `(ℤ),\n  nc ← mk_instance_cache `(ℕ),\n  if n ≥ 0 then do\n    (_, _, b, p) ← prove_nat_uncast ic nc a,\n    pure (b, `(nat_abs_pos).mk_app [a, b, p])\n  else do\n    a ← match_neg a,\n    (_, _, b, p) ← prove_nat_uncast ic nc a,\n    pure (b, `(nat_abs_neg).mk_app [a, b, p])\n| `(int.neg_succ_of_nat %%a) := do\n  na ← a.to_nat,\n  ic ← mk_instance_cache `(ℤ),\n  nc ← mk_instance_cache `(ℕ),\n  let nb := na + 1,\n  (nc, b) ← nc.of_nat nb,\n  (nc, p₁) ← prove_add_nat nc a `(1) b,\n  (ic, c) ← ic.of_nat nb,\n  (_, _, _, p₂) ← prove_nat_uncast ic nc c,\n  pure (`(-%%c : ℤ), `(neg_succ_of_nat).mk_app [a, b, c, p₁, p₂])\n| _ := failed\n\ntheorem int_to_nat_cast (a : ℕ) (b : ℤ)\n  (h : (by haveI := @nat.cast_coe ℤ; exact a : ℤ) = b) :\n  ↑a = b := eq.trans (by simp) h\n\n/-- Evaluates the `↑n` cast operation from `ℕ`, `ℤ`, `ℚ` to an arbitrary type `α`. -/\nmeta def eval_cast : expr → tactic (expr × expr)\n| `(@coe ℕ %%α %%inst %%a) := do\n  if inst.is_app_of ``coe_to_lift then\n    if inst.app_arg.is_app_of ``nat.cast_coe then do\n      n ← a.to_nat,\n      ic ← mk_instance_cache α,\n      nc ← mk_instance_cache `(ℕ),\n      (ic, b) ← ic.of_nat n,\n      (_, _, _, p) ← prove_nat_uncast ic nc b,\n      pure (b, p)\n    else if inst.app_arg.is_app_of ``int.cast_coe then do\n      n ← a.to_int,\n      ic ← mk_instance_cache α,\n      zc ← mk_instance_cache `(ℤ),\n      (ic, b) ← ic.of_int n,\n      (_, _, _, p) ← prove_int_uncast ic zc b,\n      pure (b, p)\n    else if inst.app_arg.is_app_of ``int.cast_coe then do\n      n ← a.to_rat,\n      cz_inst ← mk_mapp ``char_zero [α, none, none] >>= mk_instance,\n      ic ← mk_instance_cache α,\n      qc ← mk_instance_cache `(ℚ),\n        (ic, b) ← ic.of_rat n,\n      (_, _, _, p) ← prove_rat_uncast ic qc cz_inst b n,\n      pure (b, p)\n    else failed\n  else if inst = `(@coe_base nat int int.has_coe) then do\n    n ← a.to_nat,\n    ic ← mk_instance_cache `(ℤ),\n    nc ← mk_instance_cache `(ℕ),\n    (ic, b) ← ic.of_nat n,\n    (_, _, _, p) ← prove_nat_uncast ic nc b,\n    pure (b, `(int_to_nat_cast).mk_app [a, b, p])\n  else failed\n| _ := failed\n\n/-- This version of `derive` does not fail when the input is already a numeral -/\nmeta def derive.step (e : expr) : tactic (expr × expr) :=\neval_field e <|> eval_pow e <|> eval_ineq e <|> eval_cast e <|> eval_nat_int_ext e\n\n/-- An attribute for adding additional extensions to `norm_num`. To use this attribute, put\n`@[norm_num]` on a tactic of type `expr → tactic (expr × expr)`; the tactic will be called on\nsubterms by `norm_num`, and it is responsible for identifying that the expression is a numerical\nfunction applied to numerals, for example `nat.fib 17`, and should return the reduced numerical\nexpression (which must be in `norm_num`-normal form: a natural or rational numeral, i.e. `37`,\n`12 / 7` or `-(2 / 3)`, although this can be an expression in any type), and the proof that the\noriginal expression is equal to the rewritten expression.\n\nFailure is used to indicate that this tactic does not apply to the term. For performance reasons,\nit is best to detect non-applicability as soon as possible so that the next tactic can have a go,\nso generally it will start with a pattern match and then checking that the arguments to the term\nare numerals or of the appropriate form, followed by proof construction, which should not fail.\n\nPropositions are treated like any other term. The normal form for propositions is `true` or\n`false`, so it should produce a proof of the form `p = true` or `p = false`. `eq_true_intro` can be\nused to help here.\n-/\n@[user_attribute]\nprotected meta def attr : user_attribute (expr → tactic (expr × expr)) unit :=\n{ name      := `norm_num,\n  descr     := \"Add norm_num derivers\",\n  cache_cfg :=\n  { mk_cache := λ ns, do {\n      t ← ns.mfoldl\n        (λ (t : expr → tactic (expr × expr)) n, do\n          t' ← eval_expr (expr → tactic (expr × expr)) (expr.const n []),\n          pure (λ e, t' e <|> t e))\n        (λ _, failed),\n      pure (λ e, derive.step e <|> t e) },\n    dependencies := [] } }\n\nadd_tactic_doc\n{ name := \"norm_num\",\n  category := doc_category.attr,\n  decl_names := [`norm_num.attr],\n  tags := [\"arithmetic\", \"decision_procedure\"] }\n\n/-- Look up the `norm_num` extensions in the cache and return a tactic extending `derive.step` with\nadditional reduction procedures. -/\nmeta def get_step : tactic (expr → tactic (expr × expr)) := norm_num.attr.get_cache\n\n/-- Simplify an expression bottom-up using `step` to simplify the subexpressions. -/\nmeta def derive' (step : expr → tactic (expr × expr))\n  : expr → tactic (expr × expr) | e :=\ndo e ← instantiate_mvars e,\n   (_, e', pr) ←\n    ext_simplify_core () {} simp_lemmas.mk (λ _, failed) (λ _ _ _ _ _, failed)\n      (λ _ _ _ _ e,\n        do (new_e, pr) ← step e,\n           guard (¬ new_e =ₐ e),\n           return ((), new_e, some pr, tt))\n      `eq e,\n    return (e', pr)\n\n/-- Simplify an expression bottom-up using the default `norm_num` set to simplify the\nsubexpressions. -/\nmeta def derive (e : expr) : tactic (expr × expr) := do f ← get_step, derive' f e\n\nend norm_num\n\n/-- Basic version of `norm_num` that does not call `simp`. It uses the provided `step` tactic\nto simplify the expression; use `get_step` to get the default `norm_num` set and `derive.step` for\nthe basic builtin set of simplifications. -/\nmeta def tactic.norm_num1 (step : expr → tactic (expr × expr))\n  (loc : interactive.loc) : tactic unit :=\ndo ns ← loc.get_locals,\n   success ← tactic.replace_at (norm_num.derive' step) ns loc.include_goal,\n   when loc.include_goal $ try tactic.triv,\n   when (¬ ns.empty) $ try tactic.contradiction,\n   monad.unlessb success $ done <|> fail \"norm_num failed to simplify\"\n\n/-- Normalize numerical expressions. It uses the provided `step` tactic to simplify the expression;\nuse `get_step` to get the default `norm_num` set and `derive.step` for the basic builtin set of\nsimplifications. -/\nmeta def tactic.norm_num (step : expr → tactic (expr × expr))\n  (hs : list simp_arg_type) (l : interactive.loc) : tactic unit :=\nrepeat1 $ orelse' (tactic.norm_num1 step l) $\ninteractive.simp_core {} (tactic.norm_num1 step (interactive.loc.ns [none]))\n  ff (simp_arg_type.except ``one_div :: hs) [] l >> skip\n\nnamespace tactic.interactive\nopen norm_num interactive interactive.types\n\n/-- Basic version of `norm_num` that does not call `simp`. -/\nmeta def norm_num1 (loc : parse location) : tactic unit :=\ndo f ← get_step, tactic.norm_num1 f loc\n\n/-- Normalize numerical expressions. Supports the operations\n`+` `-` `*` `/` `^` and `%` over numerical types such as\n`ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ` and some general algebraic types,\nand can prove goals of the form `A = B`, `A ≠ B`, `A < B` and `A ≤ B`,\nwhere `A` and `B` are numerical expressions.\nIt also has a relatively simple primality prover. -/\nmeta def norm_num (hs : parse simp_arg_list) (l : parse location) : tactic unit :=\ndo f ← get_step, tactic.norm_num f hs l\n\nadd_hint_tactic \"norm_num\"\n\n/-- Normalizes a numerical expression and tries to close the goal with the result. -/\nmeta def apply_normed (x : parse texpr) : tactic unit :=\ndo x₁ ← to_expr x,\n  (x₂,_) ← derive x₁,\n  tactic.exact x₂\n\n/--\nNormalises numerical expressions. It supports the operations `+` `-` `*` `/` `^` and `%` over\nnumerical types such as `ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ`, and can prove goals of the form `A = B`, `A ≠ B`,\n`A < B` and `A ≤ B`, where `A` and `B` are\nnumerical expressions. It also has a relatively simple primality prover.\n```lean\nimport data.real.basic\n\nexample : (2 : ℝ) + 2 = 4 := by norm_num\nexample : (12345.2 : ℝ) ≠ 12345.3 := by norm_num\nexample : (73 : ℝ) < 789/2 := by norm_num\nexample : 123456789 + 987654321 = 1111111110 := by norm_num\nexample (R : Type*) [ring R] : (2 : R) + 2 = 4 := by norm_num\nexample (F : Type*) [linear_ordered_field F] : (2 : F) + 2 < 5 := by norm_num\nexample : nat.prime (2^13 - 1) := by norm_num\nexample : ¬ nat.prime (2^11 - 1) := by norm_num\nexample (x : ℝ) (h : x = 123 + 456) : x = 579 := by norm_num at h; assumption\n```\n\nThe variant `norm_num1` does not call `simp`.\n\nBoth `norm_num` and `norm_num1` can be called inside the `conv` tactic.\n\nThe tactic `apply_normed` normalises a numerical expression and tries to close the goal with\nthe result. Compare:\n```lean\ndef a : ℕ := 2^100\n#print a -- 2 ^ 100\n\ndef normed_a : ℕ := by apply_normed 2^100\n#print normed_a -- 1267650600228229401496703205376\n```\n-/\nadd_tactic_doc\n{ name        := \"norm_num\",\n  category    := doc_category.tactic,\n  decl_names  := [`tactic.interactive.norm_num1, `tactic.interactive.norm_num,\n                  `tactic.interactive.apply_normed],\n  tags        := [\"arithmetic\", \"decision procedure\"] }\n\nend tactic.interactive\n\nnamespace conv.interactive\nopen conv interactive tactic.interactive\nopen norm_num (derive)\n\n/-- Basic version of `norm_num` that does not call `simp`. -/\nmeta def norm_num1 : conv unit := replace_lhs derive\n\n/-- Normalize numerical expressions. Supports the operations\n`+` `-` `*` `/` `^` and `%` over numerical types such as\n`ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ` and some general algebraic types,\nand can prove goals of the form `A = B`, `A ≠ B`, `A < B` and `A ≤ B`,\nwhere `A` and `B` are numerical expressions.\nIt also has a relatively simple primality prover. -/\nmeta def norm_num (hs : parse simp_arg_list) : conv unit :=\nrepeat1 $ orelse' norm_num1 $\nconv.interactive.simp ff (simp_arg_type.except ``one_div :: hs) []\n  { discharger := tactic.interactive.norm_num1 (loc.ns [none]) }\n\nend conv.interactive\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/tactic/norm_num.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.49803149064321994}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport data.set.image\n\n/-!\n# Sets in sigma types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines `set.sigma`, the indexed sum of sets.\n-/\n\nnamespace set\nvariables {ι ι' : Type*} {α β : ι → Type*} {s s₁ s₂ : set ι} {t t₁ t₂ : Π i, set (α i)}\n  {u : set (Σ i, α i)} {x : Σ i, α i} {i j : ι} {a : α i}\n\n@[simp] theorem range_sigma_mk (i : ι) :\n  range (sigma.mk i : α i → sigma α) = sigma.fst ⁻¹' {i} :=\nbegin\n  apply subset.antisymm,\n  { rintros _ ⟨b, rfl⟩, simp },\n  { rintros ⟨x, y⟩ (rfl|_),\n    exact mem_range_self y }\nend\n\ntheorem preimage_image_sigma_mk_of_ne (h : i ≠ j) (s : set (α j)) :\n  sigma.mk i ⁻¹' (sigma.mk j '' s) = ∅ :=\nby { ext x, simp [h.symm] }\n\nlemma image_sigma_mk_preimage_sigma_map_subset {β : ι' → Type*} (f : ι → ι')\n  (g : Π i, α i → β (f i)) (i : ι) (s : set (β (f i))) :\n  sigma.mk i '' (g i ⁻¹' s) ⊆ sigma.map f g ⁻¹' (sigma.mk (f i) '' s) :=\nimage_subset_iff.2 $ λ x hx, ⟨g i x, hx, rfl⟩\n\nlemma image_sigma_mk_preimage_sigma_map {β : ι' → Type*} {f : ι → ι'} (hf : function.injective f)\n  (g : Π i, α i → β (f i)) (i : ι) (s : set (β (f i))) :\n  sigma.mk i '' (g i ⁻¹' s) = sigma.map f g ⁻¹' (sigma.mk (f i) '' s) :=\nbegin\n  refine (image_sigma_mk_preimage_sigma_map_subset f g i s).antisymm _,\n  rintro ⟨j, x⟩ ⟨y, hys, hxy⟩,\n  simp only [hf.eq_iff, sigma.map] at hxy,\n  rcases hxy with ⟨rfl, hxy⟩, rw [heq_iff_eq] at hxy, subst y,\n  exact ⟨x, hys, rfl⟩\nend\n\n/-- Indexed sum of sets. `s.sigma t` is the set of dependent pairs `⟨i, a⟩` such that `i ∈ s` and\n`a ∈ t i`.-/\nprotected def sigma (s : set ι) (t : Π i, set (α i)) : set (Σ i, α i) := {x | x.1 ∈ s ∧ x.2 ∈ t x.1}\n\n@[simp] lemma mem_sigma_iff : x ∈ s.sigma t ↔ x.1 ∈ s ∧ x.2 ∈ t x.1 := iff.rfl\n@[simp] lemma mk_sigma_iff : (⟨i, a⟩ : Σ i, α i) ∈ s.sigma t ↔ i ∈ s ∧ a ∈ t i := iff.rfl\n\nlemma mk_mem_sigma (hi : i ∈ s) (ha : a ∈ t i) : (⟨i, a⟩ : Σ i, α i) ∈ s.sigma t := ⟨hi, ha⟩\n\nlemma sigma_mono (hs : s₁ ⊆ s₂) (ht : ∀ i, t₁ i ⊆ t₂ i) : s₁.sigma t₁ ⊆ s₂.sigma t₂ :=\nλ x hx, ⟨hs hx.1, ht _ hx.2⟩\n\nlemma sigma_subset_iff : s.sigma t ⊆ u ↔ ∀ ⦃i⦄, i ∈ s → ∀ ⦃a⦄, a ∈ t i → (⟨i, a⟩ : Σ i, α i) ∈ u :=\n⟨λ h i hi a ha, h $ mk_mem_sigma hi ha, λ h ⟨i, a⟩ ha, h ha.1 ha.2⟩\n\nlemma forall_sigma_iff {p : (Σ i, α i) → Prop} :\n  (∀ x ∈ s.sigma t, p x) ↔ ∀ ⦃i⦄, i ∈ s → ∀ ⦃a⦄, a ∈ t i → p ⟨i, a⟩ :=\nsigma_subset_iff\n\nlemma exists_sigma_iff {p : (Σ i, α i) → Prop} :\n  (∃ x ∈ s.sigma t, p x) ↔ ∃ (i ∈ s) (a ∈ t i), p ⟨i, a⟩ :=\n⟨λ ⟨⟨i, a⟩, ha, h⟩, ⟨i, ha.1, a, ha.2, h⟩, λ ⟨i, hi, a, ha, h⟩, ⟨⟨i, a⟩, ⟨hi, ha⟩, h⟩⟩\n\n@[simp] lemma sigma_empty : s.sigma (λ i, (∅ : set (α i))) = ∅ := ext $ λ _, and_false _\n@[simp] lemma empty_sigma : (∅ : set ι).sigma t = ∅ := ext $ λ _, false_and _\nlemma univ_sigma_univ : (@univ ι).sigma (λ _, @univ (α i)) = univ := ext $ λ _, true_and _\n@[simp] lemma sigma_univ : s.sigma (λ _, univ : Π i, set (α i)) = sigma.fst ⁻¹' s :=\next $ λ _, and_true _\n\n@[simp] lemma singleton_sigma : ({i} : set ι).sigma t = sigma.mk i '' t i :=\next $ λ x, begin\n  split,\n  { obtain ⟨j, a⟩ := x,\n    rintro ⟨(rfl : j = i), ha⟩,\n    exact mem_image_of_mem _ ha },\n  { rintro ⟨b, hb, rfl⟩,\n    exact ⟨rfl, hb⟩ }\nend\n\n@[simp] lemma sigma_singleton {a : Π i, α i} :\n  s.sigma (λ i, ({a i} : set (α i))) = (λ i, sigma.mk i $ a i) '' s :=\nby { ext ⟨x, y⟩, simp [and.left_comm, eq_comm] }\n\nlemma singleton_sigma_singleton {a : Π i, α i} :\n  ({i} : set ι).sigma (λ i, ({a i} : set (α i))) = {⟨i, a i⟩} :=\nby rw [sigma_singleton, image_singleton]\n\n@[simp] lemma union_sigma : (s₁ ∪ s₂).sigma t = s₁.sigma t ∪ s₂.sigma t :=\next $ λ _, or_and_distrib_right\n\n@[simp] lemma sigma_union : s.sigma (λ i, t₁ i ∪ t₂ i) = s.sigma t₁ ∪ s.sigma t₂ :=\next $ λ _, and_or_distrib_left\n\nlemma sigma_inter_sigma : s₁.sigma t₁ ∩ s₂.sigma t₂ = (s₁ ∩ s₂).sigma (λ i, t₁ i ∩ t₂ i) :=\nby { ext ⟨x, y⟩, simp [and_assoc, and.left_comm] }\n\nlemma insert_sigma : (insert i s).sigma t = (sigma.mk i '' t i) ∪ s.sigma t :=\nby rw [insert_eq, union_sigma, singleton_sigma]\n\nlemma sigma_insert {a : Π i, α i} :\n  s.sigma (λ i, insert (a i) (t i)) = ((λ i, ⟨i, a i⟩) '' s) ∪ s.sigma t :=\nby simp_rw [insert_eq, sigma_union, sigma_singleton]\n\nlemma sigma_preimage_eq {f : ι' → ι} {g : Π i, β i → α i} :\n  (f ⁻¹' s).sigma (λ i, g (f i) ⁻¹' t (f i)) =\n    (λ p : Σ i, β (f i), sigma.mk _ (g _ p.2)) ⁻¹' (s.sigma t) := rfl\n\nlemma sigma_preimage_left {f : ι' → ι} :\n  (f ⁻¹' s).sigma (λ i, t (f i)) = (λ p : Σ i, α (f i), sigma.mk _ p.2) ⁻¹' (s.sigma t) := rfl\n\nlemma sigma_preimage_right {g : Π i, β i → α i} :\n  s.sigma (λ i, g i ⁻¹' t i) = (λ p : Σ i, β i, sigma.mk p.1 (g _ p.2)) ⁻¹' (s.sigma t) := rfl\n\nlemma preimage_sigma_map_sigma {α' : ι' → Type*} (f : ι → ι') (g : Π i, α i → α' (f i)) (s : set ι')\n  (t : Π i, set (α' i)) :\n  sigma.map f g ⁻¹' (s.sigma t) = (f ⁻¹' s).sigma (λ i, g i ⁻¹' t (f i)) := rfl\n\n@[simp] lemma mk_preimage_sigma (hi : i ∈ s) : sigma.mk i ⁻¹' s.sigma t = t i :=\next $ λ _, and_iff_right hi\n\n@[simp] lemma mk_preimage_sigma_eq_empty (hi : i ∉ s) : sigma.mk i ⁻¹' s.sigma t = ∅ :=\next $ λ _, iff_of_false (hi ∘ and.left) id\n\nlemma mk_preimage_sigma_eq_if [decidable_pred (∈ s)] :\n  sigma.mk i ⁻¹' s.sigma t = if i ∈ s then t i else ∅ :=\nby split_ifs; simp [h]\n\nlemma mk_preimage_sigma_fn_eq_if {β : Type*} [decidable_pred (∈ s)] (g : β → α i) :\n  (λ b, sigma.mk i (g b)) ⁻¹' s.sigma t = if i ∈ s then g ⁻¹' t i else ∅ :=\next $ λ _, by split_ifs; simp [h]\n\nlemma sigma_univ_range_eq {f : Π i, α i → β i} :\n  (univ : set ι).sigma (λ i, range (f i)) = range (λ x : Σ i, α i, ⟨x.1, f _ x.2⟩) :=\next $ by simp [range]\n\nprotected lemma nonempty.sigma :\n  s.nonempty → (∀ i, (t i).nonempty) → (s.sigma t : set _).nonempty :=\nλ ⟨i, hi⟩ h, let ⟨a, ha⟩ := h i in ⟨⟨i, a⟩, hi, ha⟩\n\nlemma nonempty.sigma_fst : (s.sigma t : set _).nonempty → s.nonempty := λ ⟨x, hx⟩, ⟨x.1, hx.1⟩\nlemma nonempty.sigma_snd : (s.sigma t : set _).nonempty → ∃ i ∈ s, (t i).nonempty :=\nλ ⟨x, hx⟩, ⟨x.1, hx.1, x.2, hx.2⟩\n\nlemma sigma_nonempty_iff : (s.sigma t : set _).nonempty ↔ ∃ i ∈ s, (t i).nonempty :=\n⟨nonempty.sigma_snd, λ ⟨i, hi, a, ha⟩, ⟨⟨i, a⟩, hi, ha⟩⟩\n\nlemma sigma_eq_empty_iff : s.sigma t = ∅ ↔ ∀ i ∈ s, t i = ∅ :=\nnot_nonempty_iff_eq_empty.symm.trans $ sigma_nonempty_iff.not.trans $\n  by simp only [not_nonempty_iff_eq_empty, not_exists]\n\nlemma image_sigma_mk_subset_sigma_left {a : Π i, α i} (ha : ∀ i, a i ∈ t i) :\n  (λ i, sigma.mk i (a i)) '' s ⊆ s.sigma t :=\nimage_subset_iff.2 $ λ i hi, ⟨hi, ha _⟩\n\nlemma image_sigma_mk_subset_sigma_right (hi : i ∈ s) : sigma.mk i '' t i ⊆ s.sigma t :=\nimage_subset_iff.2 $ λ a, and.intro hi\n\nlemma sigma_subset_preimage_fst (s : set ι) (t : Π i, set (α i)) : s.sigma t ⊆ sigma.fst ⁻¹' s :=\nλ a, and.left\n\nlemma fst_image_sigma_subset (s : set ι) (t : Π i, set (α i)) : sigma.fst '' s.sigma t ⊆ s :=\nimage_subset_iff.2 $ λ a, and.left\n\nlemma fst_image_sigma (s : set ι) (ht : ∀ i, (t i).nonempty) : sigma.fst '' s.sigma t = s :=\n(fst_image_sigma_subset _ _).antisymm $ λ i hi, let ⟨a, ha⟩ := ht i in ⟨⟨i, a⟩, ⟨hi, ha⟩, rfl⟩\n\nlemma sigma_diff_sigma : s₁.sigma t₁ \\ s₂.sigma t₂ = s₁.sigma (t₁ \\ t₂) ∪ (s₁ \\ s₂).sigma t₁ :=\next $ λ x, by by_cases h₁ : x.1 ∈ s₁; by_cases h₂ : x.2 ∈ t₁ x.1; simp [*, ←imp_iff_or_not]\n\nend set\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/set/sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635868562172, "lm_q2_score": 0.7772998611746912, "lm_q1q2_score": 0.49796617169690405}}
{"text": "import tactic\n\ndef Atom := ℕ\n\ninductive FormO : Type\n| pos : Atom × ℕ → FormO\n| neg : Atom × ℕ → FormO\n| tensor : FormO → FormO → FormO\n| par : FormO → FormO → FormO\n\ndef FormO.negation : FormO → FormO\n| (FormO.pos A) := FormO.neg A\n| (FormO.neg A) := FormO.pos A\n| (FormO.tensor A B) := FormO.par (FormO.negation A) (FormO.negation B)\n| (FormO.par A B) := FormO.tensor (FormO.negation A) (FormO.negation B)\n\ninfix ` ⊗ `:70 := FormO.tensor\ninfix ` ⅋ `:65 := FormO.par\nprefix `~` := FormO.negation\n\ninductive Link : Type\n| ax : Atom × ℕ → Link\n| cut : FormO → Link\n| tensor : FormO → FormO → Link\n| par : FormO → FormO → Link\n\ninductive premise : FormO → Link → Prop\n| cut_pos {Ai}         : premise Ai (Link.cut Ai)\n| cut_neg {Ai}         : premise (~Ai) (Link.cut Ai)\n| tensor_left {Ai Bj}  : premise Ai (Link.tensor Ai Bj)\n| tensor_right {Ai Bj} : premise Bj (Link.tensor Ai Bj)\n| par_left {Ai Bj}     : premise Ai (Link.par Ai Bj)\n| par_right {Ai Bj}    : premise Bj (Link.par Ai Bj)\n\ninductive conclusion : FormO → Link → Prop\n| ax_pos {A i}   : conclusion (FormO.pos (A,i)) (Link.ax (A,i))\n| ax_neg {A i}   : conclusion (FormO.neg (A,i)) (Link.ax (A,i))\n| tensor {Ai Bi} : conclusion (Ai ⊗ Bi) (Link.tensor Ai Bi)\n| par {Ai Bi}    : conclusion (Ai ⊗ Bi) (Link.par Ai Bi)\n\ninductive mem_Link (Ai : FormO) (l : Link) : Prop\n| prem : premise Ai l → mem_Link\n| con : conclusion Ai l → mem_Link\n\ninstance : has_mem FormO Link := ⟨mem_Link⟩\n\nstructure proof_structure : Type :=\n(links : set Link)\n(prem_unique : ∀ Ai : FormO, ∀ l₁ l₂ ∈ links, premise Ai l₁ → premise Ai l₂ → l₁ = l₂)\n(con_unique : ∀ Ai : FormO, ∀ l₁ l₂ ∈ links, conclusion Ai l₁ → conclusion Ai l₂ → l₁ = l₂)\n\ninductive mem_FormO_ps (Ai : FormO) (ps : proof_structure) : Prop\n| mk {l} : l ∈ ps.links → Ai ∈ l → mem_FormO_ps\n\ninstance : has_mem FormO proof_structure := ⟨mem_FormO_ps⟩\n\n@[reducible]\ndef dir := bool\n\n@[pattern] def down := ff\n@[pattern] def up := tt\n\n@[pattern] def with_down (Ai : FormO) := (Ai,down)\n@[pattern] def with_up (Ai : FormO) := (Ai,up)\npostfix `↓`:max_plus := with_down\npostfix `↑`:max_plus := with_up\n\n@[reducible]\ndef switch := bool\n\n@[reducible, pattern] def L := ff\n@[reducible, pattern] def R := tt\n\ndef switching := Link → switch\n\n@[simp]\ndef switch.flip {α β} (f : α → α → β) : switch → α → α → β\n| L a b := f a b\n| R a b := f b a\n\ninductive steps_tensor (Ai Bi : FormO) : FormO × dir → FormO × dir → Prop\n| down : steps_tensor Ai↓ (Ai ⊗ Bi)↓\n| turn : steps_tensor Bi↓ Ai↑\n| up : steps_tensor (Ai ⊗ Bi)↑ Bi↑\n\ninductive steps_par (Ai Bi : FormO) : FormO × dir → FormO × dir → Prop\n| down : steps_par Ai↓ (Ai ⅋ Bi)↓\n| turn : steps_par Bi↓ Bi↑\n| up : steps_par (Ai ⅋ Bi)↑ Ai↑\n\ninductive steps (T : switch) : Link → FormO × dir → FormO × dir → Prop\n| ax_pos  {ai} : steps (Link.ax ai) (FormO.pos ai)↑ (FormO.neg ai)↓\n| ax_neg  {ai} : steps (Link.ax ai) (FormO.neg ai)↑ (FormO.pos ai)↓\n| cut_pos  {Ai} : steps (Link.cut Ai) Ai↓ (~Ai)↑\n| cut_neg  {Ai} : steps (Link.cut Ai) (~Ai)↓ Ai↑\n| tensor {Ai Bi X Y} :\n  T.flip steps_tensor Ai Bi X Y →\n  steps (Link.tensor Ai Bi) X Y\n| par {Ai Bi X Y} :\n  T.flip steps_par Ai Bi X Y →\n  steps (Link.par Ai Bi) X Y\n\ninductive trip (ps : proof_structure) (S : switching) : ℕ → FormO × dir → FormO × dir → Prop\n| single {Ai d}    : Ai ∈ ps → trip 0 (Ai,d) (Ai,d)\n| cons {X Y Z Δ n} : Δ ∈ ps.links → steps (S Δ) Δ X Y → trip n Y Z → trip (n.succ) X Z\n\ninductive journey (ps : proof_structure) (S : switching) : ℕ → FormO × dir → FormO × dir → Type\n| trip {n X Y} : trip ps S n X Y → journey 0 X Y\n| chain {Ai n m X Z} : (∀ Δ ∈ ps.links, ¬premise Ai Δ) → trip ps S n X Ai↓ → journey m Ai↑ Z → journey m.succ X Z \n\ninductive trip2 (ps : proof_structure) (S : switching) : FormO × dir → FormO × dir → Prop\n| single (Ai : FormO) (d : dir) : Ai ∈ ps → trip2 (Ai,d) (Ai,d)\n| front (Ai Bi Ci : FormO) (d₁ d₂ d₃ : dir) (Δ : Link) :\n  Δ ∈ ps.links → steps (S Δ) Δ (Ai,d₁) (Bi,d₂) → trip2 (Bi,d₂) (Ci, d₃) → trip2 (Ai,d₁) (Ci,d₃)\n| back (Ai Bi Ci : FormO) (d₁ d₂ d₃ : dir) (Δ : Link) :\n  Δ ∈ ps.links → steps (S Δ) Δ (Bi,d₂) (Ci,d₃) → trip2 (Ai,d₁) (Bi, d₂) → trip2 (Ai,d₁) (Ci,d₃)\n\ninductive list_trip (ps : proof_structure) (S : switching) : list (FormO × dir) → Prop\n| emp : list_trip []\n| single (Ai : FormO) (d : dir) : Ai ∈ ps → list_trip [(Ai,d)]\n| cons (Ai Bi : FormO) (d₁ d₂ : dir) (Γ : list (FormO × dir)) (Δ : Link) :\n  Δ ∈ ps.links → steps (S Δ) Δ (Ai,d₁) (Bi,d₂) → list_trip ((Bi,d₂) :: Γ) → list_trip ((Ai,d₁) :: (Bi,d₂) :: Γ)\n\nlemma not_self_dual {Ai} : (~Ai) ≠ Ai :=\n  by induction Ai; rintro ⟨_⟩\n\nlemma not_self_sub_left_tensor {Ai Bi} : Ai ≠ Ai ⊗ Bi :=\nbegin\n  intro e,\n  apply_fun FormO.sizeof at e,\n  refine ne_of_lt _ e,\n  rw [FormO.sizeof, nat.add_comm],\n  apply nat.lt_of_succ_le,\n  rw nat.add_comm, rw nat.add_comm 1,\n  apply nat.le_add_right,\nend\n\nlemma not_self_sub_right_tensor {Ai Bi} : Bi ≠ Ai ⊗ Bi :=\nbegin\n  intro e,\n  apply_fun FormO.sizeof at e,\n  refine ne_of_lt _ e,\n  rw [FormO.sizeof, nat.add_comm],\n  apply nat.lt_of_succ_le,\n  rw [←nat.add_assoc],\n  apply nat.le_add_right,\nend\n\nlemma not_self_sub_left_par {Ai Bi} : Ai ≠ Ai ⅋ Bi :=\nbegin\n  intro e,\n  apply_fun FormO.sizeof at e,\n  refine ne_of_lt _ e,\n  rw [FormO.sizeof, nat.add_comm],\n  apply nat.lt_of_succ_le,\n  rw nat.add_comm, rw nat.add_comm 1,\n  apply nat.le_add_right,\nend\n\nlemma not_self_sub_right_par {Ai Bi} : Bi ≠ Ai ⅋ Bi :=\nbegin\n  intro e,\n  apply_fun FormO.sizeof at e,\n  refine ne_of_lt _ e,\n  rw [FormO.sizeof, nat.add_comm],\n  apply nat.lt_of_succ_le,\n  rw [←nat.add_assoc],\n  apply nat.le_add_right,\nend\n\nsection\n  variable {Δ : Link}\n  variable {T : switch}\n  variables {Ai Bi Ci : FormO}\n  variables {X Y Z : FormO × dir}\n\n  lemma steps_tensor_unique_prev : Ai ≠ Bi → steps_tensor Ai Bi X Z → steps_tensor Ai Bi Y Z → X = Y :=\n  begin\n    intros nAB s₁ s₂,\n    generalize_hyp e₁ : Z = Z' at s₂,\n    cases s₁;\n    cases s₂;\n    try {refl};\n    try { cases e₁, apply absurd rfl nAB};\n    try {generalize_hyp e₃ : Ai ⊗ Bi = AiBi at e₁, cases e₁ },\n  end\n\n  lemma steps_tensor_unique_next : Ai ≠ Bi → steps_tensor Ai Bi X Y → steps_tensor Ai Bi X Z → Y = Z :=\n  begin\n    intros nAB s₁ s₂,\n    generalize_hyp e₁ : X = X' at s₂,\n    cases s₁;\n    cases s₂;\n    try {refl};\n    try { cases e₁, apply absurd rfl nAB};\n    try {generalize_hyp e₃ : Ai ⊗ Bi = AiBi at e₁, cases e₁ },\n  end\n\n  lemma steps_par_unique_prev : Ai ≠ Bi → steps_par Ai Bi X Z → steps_par Ai Bi Y Z → X = Y :=\n  begin\n    intros nAB s₁ s₂,\n    generalize_hyp e₁ : Z = Z' at s₂,\n    cases s₁;\n    cases s₂;\n    try {refl};\n    try { cases e₁, apply absurd rfl nAB};\n    try {generalize_hyp e₃ : Ai ⅋ Bi = AiBi at e₁, cases e₁ },\n  end\n\n  lemma steps_par_unique_next : Ai ≠ Bi → steps_par Ai Bi X Y → steps_par Ai Bi X Z → Y = Z :=\n  begin\n    intros nAB s₁ s₂,\n    generalize_hyp e₁ : X = X' at s₂,\n    cases s₁;\n    cases s₂;\n    try {refl};\n    try { cases e₁, apply absurd rfl nAB};\n    try {generalize_hyp e₃ : Ai ⅋ Bi = AiBi at e₁, cases e₁ },\n  end\n\n  theorem steps_unique_prev : steps T Δ X Z → steps T Δ Y Z → X = Y :=\n  begin\n    intros s₁ s₂,\n    cases s₁,\n    case steps.ax_pos : ai { cases s₂, refl },\n    case steps.ax_neg : ai { cases s₂, refl },\n    case steps.cut_pos : Ai { \n      generalize_hyp e₁ : (~Ai) = nAi at s₂,\n      cases s₂, refl, apply absurd e₁ not_self_dual },\n    case steps.cut_neg : Ai { \n      generalize_hyp e₁ : (Ai,up) = Aiu at s₂,\n      cases s₂,\n      generalize_hyp e₂ : (~Ai) = nAi at e₁,\n      cases e₁, apply absurd e₂ not_self_dual, refl },\n    case steps.tensor : Ai Bi X Z' t₁ {\n      rcases s₂ with _ | _ | _ | _ | ⟨_,_,_,_,t₂⟩,\n      cases T; simp at t₁ t₂;\n      apply steps_tensor_unique_prev _ t₁ t₂,\n      cases hΔ, finish,\n      intro e, injection e with e1,\n      exact not_self_sub_right_tensor e1,\n      intro e, injection e with e1,\n      exact not_self_sub_left_tensor e1,\n      finish,\n      intro e, injection e with e1,\n      exact not_self_sub_left_tensor e1,\n      intro e, injection e with e1,\n      exact not_self_sub_right_tensor e1,\n    },\n    case steps.par : A B ai bi ci X y p₁ {\n      rcases s₂ with _ | _ | _ | ⟨_,_,_,_,_,_,_,p₂⟩,\n      cases T; simp at p₁ p₂;\n      apply steps_par_unique_prev _ _ _ p₁ p₂;\n      cases hΔ, finish,\n      intro e, injection e with e1,\n      exact not_self_sub_right_par e1,\n      intro e, injection e with e1,\n      exact not_self_sub_left_par e1,\n      finish,\n      intro e, injection e with e1,\n      exact not_self_sub_left_par e1,\n      intro e, injection e with e1,\n      exact not_self_sub_right_par e1,\n    },\n  end\n\n  theorem steps_unique_next : valid_link Δ → steps T Δ X Y → steps T Δ X Z → Y = Z :=\n  begin\n    intros hΔ s₁ s₂,\n    cases s₁,\n    case steps.ax : A ai ni Bi Ci d₁ {\n      cases s₂ with _ _ _ Di _ d₂,\n      rw dual_unique_next d₁ d₂ },\n    case steps.cut : A ai ni Bi Ci d₁ {\n      rcases s₂ with _ | ⟨_,_,_,Di,_,d₂⟩,\n      rw dual_unique_next d₂ d₁\n    },\n    case steps.tensor : A B ai bi ci X y t₁ {\n      rcases s₂ with _ | _ | ⟨_,_,_,_,_,_,_,t₂⟩,\n      cases T; simp at t₁ t₂;\n      apply steps_tensor_unique_next _ _ _ t₁ t₂;\n      cases hΔ, finish,\n      intro e, injection e with e1,\n      exact not_self_sub_right_tensor e1,\n      intro e, injection e with e1,\n      exact not_self_sub_left_tensor e1,\n      finish,\n      intro e, injection e with e1,\n      exact not_self_sub_left_tensor e1,\n      intro e, injection e with e1,\n      exact not_self_sub_right_tensor e1,\n    },\n    case steps.par : A B ai bi ci X y p₁ {\n      rcases s₂ with _ | _ | _ | ⟨_,_,_,_,_,_,_,p₂⟩,\n      cases T; simp at p₁ p₂;\n      apply steps_par_unique_next _ _ _ p₁ p₂;\n      cases hΔ, finish,\n      intro e, injection e with e1,\n      exact not_self_sub_right_par e1,\n      intro e, injection e with e1,\n      exact not_self_sub_left_par e1,\n      finish,\n      intro e, injection e with e1,\n      exact not_self_sub_left_par e1,\n      intro e, injection e with e1,\n      exact not_self_sub_right_par e1,\n    },\n  end\n\n  lemma con_of_steps_up :\n    steps T Δ Ai↑ X → conclusion Ai Δ :=\n  begin\n    intros s, cases s,\n    case steps.ax : A i j Ai Bi u { cases u; constructor, },\n    case steps.tensor : A B i j k Ci u { cases T; cases u; constructor },\n    case steps.par : A B i j k Ci u { cases T; cases u; constructor },\n  end\n\n  lemma prem_of_steps_down :\n    steps T Δ Ai↓ X → premise Ai Δ :=\n  begin\n    intros s, cases s,\n    case steps.cut : A i j Ai Bi u { cases u; constructor, },\n    case steps.tensor : A B i j k Ci u { cases T; cases u; constructor },\n    case steps.par : A B i j k Ci u { cases T; cases u; constructor }\n  end\n\n  lemma con_of_steps_down :\n    steps T Δ X Ai↓ → conclusion Ai Δ :=\n  begin\n    intros s, cases s,\n    case steps.ax : A i j Ai Bi u { cases u; constructor, },\n    case steps.tensor : A B i j k Ci u { cases T; cases u; constructor },\n    case steps.par : A B i j k Ci u { cases T; cases u; constructor },\n  end\n\n  lemma prem_of_steps_up :\n    steps T Δ X Ai↑ → premise Ai Δ :=\n  begin\n    intros s, cases s,\n    case steps.cut : A i j Ai Bi u { cases u; constructor, },\n    case steps.tensor : A B i j k Ci u { cases T; cases u; constructor },\n    case steps.par : A B i j k Ci u { cases T; cases u; constructor }\n  end\n\n  lemma mem_ps_of_steps_prev {ps : proof_structure} {d : dir} :\n    Δ ∈ ps.links → steps T Δ (Ai,d) X → Ai ∈ ps :=\n  begin\n    intros hΔ s, cases d,\n    case bool.ff : { exact ⟨hΔ, mem_Link.prem $ prem_of_steps_down s⟩, }, \n    case bool.tt : { exact ⟨hΔ, mem_Link.con $ con_of_steps_up s⟩, }, \n  end\n\n  lemma mem_ps_of_steps_next {ps : proof_structure} {d : dir} :\n    Δ ∈ ps.links → steps T Δ X (Bi,d) → Bi ∈ ps :=\n  begin\n    intros hΔ s, cases d,\n    case bool.ff : { exact ⟨hΔ, mem_Link.con $ con_of_steps_down s⟩, }, \n    case bool.tt : { exact ⟨hΔ, mem_Link.prem $ prem_of_steps_up s⟩, }, \n  end\n\nend\n\nsection\n  variable {ps : proof_structure}\n  variable {S : switching}\n  variables {X Y Z : FormO × dir}\n  variables {n m : ℕ}\n\n  theorem link_unique_of_steps_prev {Δ₁ Δ₂} :\n    Δ₁ ∈ ps.links → Δ₂ ∈ ps.links → steps (S Δ₁) Δ₁ X Y → steps (S Δ₂) Δ₂ X Z → Δ₁ = Δ₂ :=\n  begin\n    intros v₁ v₂ s₁ s₂,\n    rcases X with ⟨Ai,⟨_|_⟩⟩,\n      apply ps.prem_unique Ai _ _ v₁ v₂ (prem_of_steps_down s₁) (prem_of_steps_down s₂),\n    apply ps.con_unique Ai _ _ v₁ v₂ (con_of_steps_up s₁) (con_of_steps_up s₂),\n  end\n\n  theorem link_unique_of_steps_next {Δ₁ Δ₂} :\n    Δ₁ ∈ ps.links → Δ₂ ∈ ps.links → steps (S Δ₁) Δ₁ X Z → steps (S Δ₂) Δ₂ Y Z → Δ₁ = Δ₂ :=\n  begin\n    intros v₁ v₂ s₁ s₂,\n    rcases Z with ⟨Ci,⟨_|_⟩⟩,\n      apply ps.con_unique Ci _ _ v₁ v₂ (con_of_steps_down s₁) (con_of_steps_down s₂),\n    apply ps.prem_unique Ci _ _ v₁ v₂ (prem_of_steps_up s₁) (prem_of_steps_up s₂),\n  end\n\n  def trip.rcons {Δ} : Δ ∈ ps.links → trip ps S n X Y → steps (S Δ) Δ Y Z → trip ps S n.succ X Z :=\n  begin\n    revert X Y Z,\n    apply nat.strong_induction_on n,\n    intros n ih,\n    rintros X Y Z hΔ tXY sYZ,\n    cases tXY,\n    case trip.single : Ai d hA { \n      apply trip.cons hΔ sYZ,\n      cases Z with Ci d', simp,\n      apply trip.single,\n      apply mem_ps_of_steps_next hΔ sYZ,\n    },\n    case trip.cons : _ W _ Δ' k hΔ' sXW tWY {\n      apply trip.cons hΔ' sXW, simp,\n      apply ih k (lt_add_one k) hΔ tWY sYZ },\n    \n  end\n\n  def trip.concat : trip ps S n X Y → trip ps S m Y Z → trip ps S (n + m) X Z :=\n  begin\n    revert X Y Z n,\n    induction m,\n    case nat.zero : {\n      intros X Y Z _ tXY tYZ,\n      cases tYZ,\n      exact tXY,\n    },\n    case nat.succ : m ih {\n      intros X Y Z n tXY tYZ,\n      rw [nat.add_succ, nat.add_comm, ←nat.add_succ, nat.add_comm],\n      cases tYZ with _ _ _ _ W _ Δ' _ hΔ' sYW tWZ,\n      apply ih _ tWZ,\n      apply trip.rcons hΔ' tXY sYW }\n  end\n\n  theorem trip_unique_start : trip ps S n X Z → trip ps S n Y Z → X = Y :=\n  begin\n    intros tX tY,\n    revert X Y,\n    induction n,\n    case nat.zero : { intros, cases tX; cases tY, refl},\n    case nat.succ : n ih {\n      rintros X Y tX tY,\n      rcases tX with _ | ⟨_,X',_,Δ,_,hΔ,sX,tX'⟩,\n      rcases tY with _ | ⟨_,Y',_,Δ',_,hΔ',sY,tY'⟩,\n      have : Y' = X', by exact ih tY' tX',\n      rw this at sY,\n      have : Δ' = Δ, apply link_unique_of_steps_next hΔ' hΔ sY sX,\n      rw this at sY,\n      exact steps_unique_prev (ps.valid Δ hΔ) sX sY,\n      }\n  end\n\n  lemma trip_exists_rcons : trip ps S n.succ X Z → ∃ Y Δ, ∃ hΔ : Δ ∈ ps.links, ∃ tXY : trip ps S n X Y, steps (S Δ) Δ Y Z :=\n  begin\n    revert X,\n    induction n,\n    case nat.zero : {\n      intros X tXZ, cases tXZ with _ _ _ _ Y _ Δ _ hΔ sXY tYZ,\n      use X, use Δ, refine ⟨hΔ,_⟩,\n      constructor,\n      cases X with Ai d,\n      constructor,\n      apply mem_ps_of_steps_prev hΔ sXY,\n      cases tYZ, assumption,\n      },\n    case nat.succ : n ih {\n      intros X tXZ, cases tXZ with _ _ _ _ Y _ Δ _ hΔ sXY tYZ,\n      specialize ih tYZ,\n      rcases ih with ⟨Y',Δ',hΔ',tYY',sY'Z⟩,\n      exact ⟨Y',Δ',hΔ',trip.cons hΔ sXY tYY',sY'Z⟩,\n    }\n  end\n\n  theorem trip_unique_stop : trip ps S n X Y → trip ps S n X Z → Y = Z :=\n  begin\n    revert Y Z,\n    induction n,\n    case nat.zero : { intros _ _ tXY tXZ, cases tXY, cases tXZ, refl },\n    case nat.succ : n ih {\n      intros Y Z tXY tXZ,\n      rcases (trip_exists_rcons tXY) with ⟨U,Δ₁,hΔ₁,tXU, sUY⟩,\n      rcases (trip_exists_rcons tXZ) with ⟨V,Δ₂,hΔ₂,tXV, sVZ⟩,\n      have : V = U, apply ih tXV tXU,\n      rw this at sVZ,\n      have : Δ₂ = Δ₁, apply link_unique_of_steps_prev hΔ₂ hΔ₁ sVZ sUY,\n      rw this at sVZ,\n      apply steps_unique_next (ps.valid Δ₁ hΔ₁) sUY sVZ,\n      }\n  end\n\nend\n\n", "meta": {"author": "blinkybool", "repo": "proofnet", "sha": "4c94599d3cb45530b0e082ef3991900f9dd023eb", "save_path": "github-repos/lean/blinkybool-proofnet", "path": "github-repos/lean/blinkybool-proofnet/proofnet-4c94599d3cb45530b0e082ef3991900f9dd023eb/src/mll.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.49796616764056645}}
{"text": "import ECTate.Algebra.EllipticCurve.Kronecker\nimport ECTate.Algebra.EllipticCurve.Model\nimport ECTate.Algebra.ValuedRing\nimport ECTate.Data.Nat.Enat\nimport Mathlib.Data.Int.Basic\nimport Mathlib.Tactic.LibrarySearch\nimport Mathlib.Tactic.NormNum\nimport Mathlib.Tactic.Contrapose\nimport Aesop\nimport Mathlib.Tactic.Linarith\nimport ECTate.Algebra.ResidueRing\n-- import ECTate.Tactic.ELinarith\n-- import Mathlib.Algebra.Order.Field.Defs\n\n\nopen Enat\n\nvariable {R : Type u} [CommRing R] [inst : IsDomain R]\n\n\nnamespace Model\n\nvariable {p : R}\n\ndef is_local_singular_point (valp : SurjVal p) (e : Model R) (P : R × R) : Prop :=\nvalp (weierstrass e P) > 0 ∧ valp (dweierstrass_dx e P) > 0 ∧ valp (dweierstrass_dy e P) > 0\n\nlemma mk'_apply [NonAssocRing R] (x : R) (c : RingCon R) : c.mk' x = x := rfl\nlemma is_local_singular_point_iff (evr : EnatValRing p) (e : Model R) (P : R × R) :\n  is_local_singular_point evr.valtn e P ↔ is_singular_point (e.map evr.RingCon.mk') (P.map evr.RingCon.mk' evr.RingCon.mk')\n  := by\n  rw [is_singular_point]\n  rw [weierstrass_map, dweierstrass_dx_map, dweierstrass_dy_map]\n  simp [mk'_apply]\n  rw [← RingCon.coe_zero]\n  rw [RingCon.eq, RingCon.rel_mk, SurjVal.s.r_eq, congruence_p]\n  rw [RingCon.eq, RingCon.rel_mk, SurjVal.s.r_eq, congruence_p]\n  rw [RingCon.eq, RingCon.rel_mk, SurjVal.s.r_eq, congruence_p]\n  simp\n  rfl\n\nlemma singular_of_val_discr (valp : SurjVal p) (e : Model R) (h : valp e.discr > 0) :\n  ∃ P, is_local_singular_point valp e P :=\nby\n  sorry\n\n--TODO norm_reprs here?\ndef singular_point_on_special [DecidableEq R] (evr : EnatValRing p) (e : Model R) : R × R :=\n  if 0 < evr.valtn e.c4 then\n    match evr.residue_char with\n    | 2 => (evr.pth_root e.a4, evr.pth_root (e.a2 * e.a4 + e.a6))\n    | 3 => (evr.pth_root (-(e.a3 ^ 2) - e.a6), e.a1 * evr.pth_root (-(e.a3 ^ 2) - e.a6) + e.a3)\n    | _ => (-e.b2 * evr.inv_mod 12, -(-e.a1 * e.b2 * evr.inv_mod 12 + e.a3) * evr.inv_mod 2)\n  else\n    ((18 * e.b6 - e.b2 * e.b4) * evr.inv_mod e.c4, (e.b2 * e.b5 + 3 * e.b7) * evr.inv_mod e.c4)\n\ndef move_singular_point_to_origin_triple [DecidableEq R] (evr : EnatValRing p) (e : Model R) : R × R × R :=\n⟨(singular_point_on_special evr e).1, 0, (singular_point_on_special evr e).2⟩\n\n-- def move_singular_point_to_origin_iso [DecidableEq R] (evr : EnatValRing p) (e : Model R) : R × R × R :=\n--   match evr.residue_char with\n--   | 2 => (evr.norm_repr e.a4, 0, evr.norm_repr (e.a6 + e.a4 * e.a2))\n--   | 3 => (evr.norm_repr (-e.b6), 0, evr.norm_repr (e.a3 - e.b6 * e.a1))\n--   | _ => (0, 0, 0) --need to fill here\n\n-- def move_singular_point_to_origin_iso [DecidableEq R] (evr : EnatValRing p) (e : Model R) : R × R × R :=\n-- rst_triple e (move_singular_point_to_origin_triple e)\n\ndef move_singular_point_to_origin_iso [DecidableEq R] (evr : EnatValRing p) (e : Model R) :\n  Model R :=\nrst_triple e (move_singular_point_to_origin_triple evr e)\n\nlemma move_singular_point_to_origin [DecidableEq R] (evr : EnatValRing p) (e : Model R) :\n(∃ P, is_local_singular_point evr.valtn e P) →\n  is_local_singular_point evr.valtn (move_singular_point_to_origin_iso evr e) (0, 0) :=\nby\n  rintro ⟨P, h⟩\n  have := Model.Field.move_singular_point_to_origin' (e.map evr.RingCon.mk') ⟨P.map evr.RingCon.mk' evr.RingCon.mk', ?_⟩\n  . rw [is_local_singular_point_iff]\n    simp\n    convert this\n    simp [move_singular_point_to_origin_iso, Field.move_singular_point_to_origin_iso,\n          move_singular_point_to_origin_triple, Field.move_singular_point_to_origin_triple]\n    sorry\n  . rwa [is_local_singular_point_iff] at h\n\nlemma a6_of_is_local_singular_point_zero_zero [DecidableEq R] (evr : EnatValRing p) (e : Model R)\n  (h : is_local_singular_point evr.valtn e (0, 0)) : 0 < evr.valtn e.a6 :=\nby simpa [is_local_singular_point, weierstrass] using h.1\n\ndef pi_scaling (evr : EnatValRing p) (e : Model R) : Model R :=\n{ a1 := evr.sub_val 1 e.a1\n  a2 := evr.sub_val 2 e.a2\n  a3 := evr.sub_val 3 e.a3\n  a4 := evr.sub_val 4 e.a4\n  a6 := evr.sub_val 6 e.a6 }\n\nopen SurjVal\n\nlemma pi_scaling_of_b2 (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) :\n  evr.sub_val 2 e.b2 = evr.sub_val 1 e.a1 * evr.sub_val 1 e.a1 + 4 * evr.sub_val 2 e.a2 := by\n  rw [←evr.sub_val_mul_right h1, ←evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    ←evr.sub_val_mul_right h2, ←evr.sub_val_add _ _]\n  . rfl\n  . exact val_mul_ge_of_both_ge evr.valtn h1 h1\n  . exact val_mul_ge_of_right_ge evr.valtn h2\n\nlemma pi_scaling_of_b4 (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4) :\n  evr.sub_val 4 e.b4 = evr.sub_val 1 e.a1 * evr.sub_val 3 e.a3 + 2 * evr.sub_val 4 e.a4 := by\n  rw [←evr.sub_val_mul_right h3, ←evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    ←evr.sub_val_mul_right h4, ←evr.sub_val_add _ _]\n  . rfl\n  . exact val_mul_ge_of_both_ge evr.valtn h1 h3\n  . exact val_mul_ge_of_right_ge evr.valtn h4\n\nlemma pi_scaling_of_b6 (evr : EnatValRing p) (e : Model R) (h3 : evr.valtn e.a3 ≥ 3)\n  (h6 : evr.valtn e.a6 ≥ 6) :\n  evr.sub_val 6 e.b6 = evr.sub_val 3 e.a3 * evr.sub_val 3 e.a3 + 4 * evr.sub_val 6 e.a6 := by\n  rw [←evr.sub_val_mul_right h3, ←evr.sub_val_mul_left h3, evr.sub_val_sub_val,\n    ←evr.sub_val_mul_right h6, ←evr.sub_val_add _ _]\n  . rfl\n  . exact val_mul_ge_of_both_ge evr.valtn h3 h3\n  . exact val_mul_ge_of_right_ge evr.valtn h6\n\nlemma pi_scaling_of_b8 (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4)\n  (h6 : evr.valtn e.a6 ≥ 6) :\n  evr.sub_val 8 e.b8 = evr.sub_val 1 e.a1 * evr.sub_val 1 e.a1 * evr.sub_val 6 e.a6\n    - evr.sub_val 1 e.a1 * evr.sub_val 3 e.a3 * evr.sub_val 4 e.a4\n    + 4 * evr.sub_val 2 e.a2 * evr.sub_val 6 e.a6\n    + evr.sub_val 2 e.a2 * evr.sub_val 3 e.a3 * evr.sub_val 3 e.a3\n    - evr.sub_val 4 e.a4 * evr.sub_val 4 e.a4 :=\nby\n  rw [←evr.sub_val_mul_right h1, ←evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    ←evr.sub_val_mul_right h6, ←evr.sub_val_mul_left (val_mul_ge_of_both_ge evr.valtn h1 h1), evr.sub_val_sub_val]\n  rw [←evr.sub_val_mul_right h3, ←evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    ←evr.sub_val_mul_right h4, ←evr.sub_val_mul_left (val_mul_ge_of_both_ge evr.valtn h1 h3), evr.sub_val_sub_val]\n  rw [←evr.sub_val_mul_right h2, ←evr.sub_val_mul_right h6,\n    ←evr.sub_val_mul_left (val_mul_ge_of_right_ge evr.valtn h2), evr.sub_val_sub_val]\n  rw [←evr.sub_val_mul_left h2, ←evr.sub_val_mul_right h3, ←evr.sub_val_mul_right h3,\n    evr.sub_val_sub_val, ←evr.sub_val_mul_left (val_mul_ge_of_both_ge evr.valtn h2 h3), evr.sub_val_sub_val]\n  rw [←evr.sub_val_mul_right h4, ←evr.sub_val_mul_left h4, evr.sub_val_sub_val]\n  have h116 := val_mul_ge_of_both_ge evr.valtn (val_mul_ge_of_both_ge evr.valtn h1 h1) h6\n  have h134 := (val_mul_ge_of_both_ge evr.valtn (val_mul_ge_of_both_ge evr.valtn h1 h3) h4)\n  have h26 := val_mul_ge_of_both_ge evr.valtn (@val_mul_ge_of_right_ge R _ _ 2 p evr.valtn 4 e.a2 h2) h6\n  have h233 := val_mul_ge_of_both_ge evr.valtn (val_mul_ge_of_both_ge evr.valtn h2 h3) h3\n  have h44 := val_mul_ge_of_both_ge evr.valtn h4 h4\n  simp only [add_ofN] at h116 h134 h44 h26 h233\n  rw [←val_neg] at h134\n  rw [←val_neg] at h44\n\n  rw [sub_eq_add_neg, sub_eq_add_neg, ←evr.sub_val_neg, ←evr.sub_val_neg,\n    ←evr.sub_val_add h116 h134, ←evr.sub_val_add _ h26, ←evr.sub_val_add _ h233,\n    ←evr.sub_val_add _ h44, ←sub_eq_add_neg, ←sub_eq_add_neg]\n  . rfl\n  . exact val_add_ge_of_ge evr.valtn\n      (val_add_ge_of_ge evr.valtn (val_add_ge_of_ge evr.valtn h116 h134) h26) h233\n  . exact val_add_ge_of_ge evr.valtn (val_add_ge_of_ge evr.valtn h116 h134) h26\n  . exact val_add_ge_of_ge evr.valtn h116 h134\n\nopen EnatValRing in\nlemma pi_scaling_of_discr (evr : EnatValRing p) (e : Model R)\n  (hb2 : evr.valtn e.b2 ≥ 2) (hb4 : evr.valtn e.b4 ≥ 4)\n  (hb6 : evr.valtn e.b6 ≥ 6) (hb8 : evr.valtn e.b8 ≥ 8) :\n  evr.sub_val 12 e.discr = -evr.sub_val 2 e.b2 * evr.sub_val 2 e.b2 * evr.sub_val 8 e.b8\n    - 8 * ((evr.sub_val 4 e.b4) ^ 3) - 27 * evr.sub_val 6 e.b6 * evr.sub_val 6 e.b6\n    + 9 * evr.sub_val 2 e.b2 * evr.sub_val 4 e.b4 * evr.sub_val 6 e.b6 :=\nby\n  rw [discr,\n      sub_val_add,\n      sub_val_sub,\n      sub_val_sub,\n      sub_val_mul _ _ _ _ _ hb8,\n      sub_val_mul _ _ _ _ _ hb2,\n      sub_val_mul _ _ _ _ _ hb6,\n      sub_val_mul_right _ hb6,\n      sub_val_mul _ _ _ _ _ hb6,\n      sub_val_mul _ _ _ _ _ hb4,\n      sub_val_mul_right _ hb2,\n      sub_val_mul_right,\n      sub_val_pow _ _ _ _ hb4,\n      sub_val_neg]\n  . rfl\n  . exact val_pow_ge_of_ge evr.valtn 3 hb4\n  swap\n  . rfl\n  . exact val_mul_ge_of_right_ge _ hb2\n  . rfl\n  . exact val_mul_ge_of_both_ge evr.valtn (val_mul_ge_of_right_ge evr.valtn hb2) hb4\n  . rfl\n  . exact val_mul_ge_of_right_ge evr.valtn hb6\n  swap\n  . rfl\n  . simpa\n  . rfl\n  . exact val_mul_ge_of_both_ge evr.valtn (by simpa : evr.valtn (-b2 e) ≥ 2) hb2\n  . exact val_mul_ge_of_both_ge evr.valtn\n      (val_mul_ge_of_both_ge evr.valtn (by simpa : evr.valtn (-b2 e) ≥ 2) hb2) hb8\n  . exact val_mul_ge_of_right_ge evr.valtn $ val_pow_ge_of_ge evr.valtn 3 hb4\n  . apply val_sub_ge_of_ge\n    . exact val_mul_ge_of_both_ge evr.valtn\n        (val_mul_ge_of_both_ge evr.valtn (by simpa : evr.valtn (-b2 e) ≥ 2) hb2) hb8\n    . exact val_mul_ge_of_right_ge evr.valtn (val_pow_ge_of_ge evr.valtn 3 hb4)\n  . exact val_mul_ge_of_both_ge evr.valtn (val_mul_ge_of_right_ge evr.valtn hb6) hb6\n  . repeat' apply val_sub_ge_of_ge\n    . exact val_mul_ge_of_both_ge evr.valtn\n        (val_mul_ge_of_both_ge evr.valtn (by simpa : evr.valtn (-b2 e) ≥ 2) hb2) hb8\n    -- . simp [-ge_iff_le, evr.valtn.v_mul_eq_add_v]\n    --   cases h : evr.valtn (b2 e)\n    --   . simp [-ge_iff_le]\n    --     cases h' : evr.valtn (b8 e)\n    --     . simp [-ge_iff_le]\n    --       norm_cast\n    --       sorry\n    --     . simp\n    --   . simp\n    --   -- refine val_mul_ge_of_both_ge evr.valtn\n    --   --   (val_mul_ge_of_both_ge evr.valtn ?_ hb2) hb8\n\n    . apply val_mul_ge_of_right_ge evr.valtn\n      exact val_pow_ge_of_ge evr.valtn 3 hb4\n    . exact val_mul_ge_of_both_ge evr.valtn (val_mul_ge_of_right_ge evr.valtn hb6) hb6\n  . exact val_mul_ge_of_both_ge\n      evr.valtn (val_mul_ge_of_both_ge evr.valtn (val_mul_ge_of_right_ge evr.valtn hb2) hb4) hb6\n\nlemma b2_of_pi_scaling (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) : (pi_scaling evr e).b2 = evr.sub_val 2 e.b2 := by\n  simp only [b2, pi_scaling]\n  exact (pi_scaling_of_b2 evr e h1 h2).symm\n\nlemma b4_of_pi_scaling (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4) :\n  (pi_scaling evr e).b4 = evr.sub_val 4 e.b4 := by\n  simp only [b4, pi_scaling]\n  exact (pi_scaling_of_b4 evr e h1 h3 h4).symm\n\nlemma b6_of_pi_scaling (evr : EnatValRing p) (e : Model R) (h3 : evr.valtn e.a3 ≥ 3)\n  (h6 : evr.valtn e.a6 ≥ 6) :\n  (pi_scaling evr e).b6 = evr.sub_val 6 e.b6 := by\n  simp only [b6, pi_scaling]\n  exact (pi_scaling_of_b6 evr e h3 h6).symm\n\nlemma b8_of_pi_scaling (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4)\n  (h6 : evr.valtn e.a6 ≥ 6) : (pi_scaling evr e).b8 = evr.sub_val 8 e.b8 := by\n  simp only [b8, pi_scaling]\n  exact (pi_scaling_of_b8 evr e h1 h2 h3 h4 h6).symm\n\nlemma val_b2_of_val_a12 (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) : evr.valtn e.b2 ≥ 2 := by\n  simp only [b2]\n  apply val_add_ge_of_ge\n  . apply val_mul_ge_of_both_ge evr.valtn h1 h1\n  . apply val_mul_ge_of_right_ge evr.valtn h2\n\nlemma val_b4_of_val_a134 (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4) : evr.valtn e.b4 ≥ 4 := by\n  simp only [b4]\n  apply val_add_ge_of_ge\n  . apply val_mul_ge_of_both_ge evr.valtn h1 h3\n  . apply val_mul_ge_of_right_ge evr.valtn h4\n\nlemma val_b6_of_val_a36 (evr : EnatValRing p) (e : Model R) (h3 : evr.valtn e.a3 ≥ 3)\n  (h6 : evr.valtn e.a6 ≥ 6) : evr.valtn e.b6 ≥ 6 := by\n  simp only [b6]\n  apply val_add_ge_of_ge\n  . apply val_mul_ge_of_both_ge evr.valtn h3 h3\n  . apply val_mul_ge_of_right_ge evr.valtn h6\n\nlemma val_b8_of_val_ai (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4)\n  (h6 : evr.valtn e.a6 ≥ 6) : evr.valtn e.b8 ≥ 8 := by\n  simp only [b8, sub_eq_add_neg]\n  apply val_add_ge_of_ge\n  . apply val_add_ge_of_ge\n    . apply val_add_ge_of_ge\n      . apply val_add_ge_of_ge\n        . apply val_mul_ge_of_both_ge _ (val_mul_ge_of_both_ge _ h1 h1) h6\n        . rw [val_neg]\n          apply val_mul_ge_of_both_ge _ (val_mul_ge_of_both_ge _ h1 h3) h4\n      . rw [mul_assoc]\n        apply val_mul_ge_of_right_ge _ (val_mul_ge_of_both_ge _ h2 h6)\n    . apply val_mul_ge_of_both_ge _ (val_mul_ge_of_both_ge _ h2 h3) h3\n  . rw [val_neg]\n    apply val_mul_ge_of_both_ge _ h4 h4\n\nlemma discr_of_pi_scaling (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) (h3 : evr.valtn e.a3 ≥ 3)\n  (h4 : evr.valtn e.a4 ≥ 4) (h6 : evr.valtn e.a6 ≥ 6) :\n  (pi_scaling evr e).discr = evr.sub_val 12 e.discr := by\n  simp only [discr, b2_of_pi_scaling evr e h1 h2, b4_of_pi_scaling evr e h1 h3 h4,\n    b6_of_pi_scaling evr e h3 h6, b8_of_pi_scaling evr e h1 h2 h3 h4 h6]\n  exact (pi_scaling_of_discr evr e (val_b2_of_val_a12 evr e h1 h2)\n    (val_b4_of_val_a134 evr e h1 h3 h4) (val_b6_of_val_a36 evr e h3 h6)\n    (val_b8_of_val_ai evr e h1 h2 h3 h4 h6)).symm\n\nlemma val_discr_of_val_ai (evr : EnatValRing p) (e : Model R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4)\n  (h6 : evr.valtn e.a6 ≥ 6) : evr.valtn e.discr ≥ 12 := by\n  have hb2 := val_b2_of_val_a12 evr e h1 h2\n  have hb4 := val_b4_of_val_a134 evr e h1 h3 h4\n  have hb6 := val_b6_of_val_a36 evr e h3 h6\n  have hb8 := val_b8_of_val_ai evr e h1 h2 h3 h4 h6\n  simp only [discr, sub_eq_add_neg]\n  repeat' apply val_add_ge_of_ge\n  . rw [←neg_mul_eq_neg_mul, ←neg_mul_eq_neg_mul, val_neg]\n    apply val_mul_ge_of_both_ge _ (val_mul_ge_of_both_ge _ hb2 hb2) hb8\n  . rw [val_neg, pow_succ', pow_succ', pow_one]\n    apply val_mul_ge_of_right_ge _ (val_mul_ge_of_both_ge _ (val_mul_ge_of_both_ge _ hb4 hb4) hb4)\n  . rw [val_neg, mul_assoc]\n    apply val_mul_ge_of_right_ge _ (val_mul_ge_of_both_ge _ hb6 hb6)\n  . rw [mul_assoc, mul_assoc]\n    apply val_mul_ge_of_right_ge _ (val_mul_ge_of_both_ge _ hb2 (val_mul_ge_of_both_ge _ hb4 hb6))\n\nend Model\n\n\nnamespace ValidModel\n\ndef pi_scaling (evr : EnatValRing p) (e : ValidModel R) (h1 : evr.valtn e.a1 ≥ 1)\n  (h2 : evr.valtn e.a2 ≥ 2) (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4)\n  (h6 : evr.valtn e.a6 ≥ 6) : ValidModel R := {\n  toModel := Model.pi_scaling evr e.toModel,\n  discr_not_zero := by\n    rw [Model.discr_of_pi_scaling evr e.toModel h1 h2 h3 h4 h6]\n    intro H\n    have H' := let_value_eq (fun (x:R) => p ^ 12 * x) H\n    simp only [mul_zero] at H'\n    rw [←evr.factor_p_of_le_val (Model.val_discr_of_val_ai evr e.toModel h1 h2 h3 h4 h6)] at H'\n    apply e.discr_not_zero H' }\n\n@[simp]\ntheorem pi_scaling_toModel\n  (evr : EnatValRing p) (e : ValidModel R) (h1 : SurjVal.v evr.valtn e.toModel.a1 ≥ 1)\n  (h2 : SurjVal.v evr.valtn e.toModel.a2 ≥ 2) (h3 : SurjVal.v evr.valtn e.toModel.a3 ≥ 3)\n  (h4 : SurjVal.v evr.valtn e.toModel.a4 ≥ 4) (h6 : SurjVal.v evr.valtn e.toModel.a6 ≥ 6) :\n  (pi_scaling evr e h1 h2 h3 h4 h6).toModel = Model.pi_scaling evr e.toModel :=\nEq.refl (pi_scaling evr e h1 h2 h3 h4 h6).toModel\n\nopen SurjVal\n\ndef val_discr_to_nat {p : R} (valp : SurjVal p) (e : ValidModel R) : ℕ :=\nnat_of_val valp e.discr_not_zero\n\n@[simp]\nlemma iso_rst_val_discr_to_nat {p : R} (valp : SurjVal p) (r s t : R) (e : ValidModel R) :\n  val_discr_to_nat valp (rst_iso r s t e) = val_discr_to_nat valp e :=\nby simp [val_discr_to_nat, nat_of_val, ValidModel.rst_iso, Model.rst_discr]\n\nlemma ofN_val_discr_to_nat {p : R} (valp : SurjVal p) (e : ValidModel R) :\n  val_discr_to_nat valp e = valp e.discr := by\n  cases h : valp e.discr with\n  | ofN n =>\n    rwa [val_discr_to_nat, nat_of_val, ofN_to_nat_eq_self]\n  | top =>\n    exfalso\n    rw [valp.v_eq_top_iff_zero] at h\n    exact e.discr_not_zero h\n\nlemma pi_scaling_val_discr_to_nat {p : R} (evr : EnatValRing p) (e : ValidModel R)\n  (h1 : evr.valtn e.a1 ≥ 1) (h2 : evr.valtn e.a2 ≥ 2)\n  (h3 : evr.valtn e.a3 ≥ 3) (h4 : evr.valtn e.a4 ≥ 4) (h6 : evr.valtn e.a6 ≥ 6) :\n  val_discr_to_nat evr.valtn (pi_scaling evr e h1 h2 h3 h4 h6) = val_discr_to_nat evr.valtn e - 12 :=\nby\n  rw [Enat.eq_ofN, ofN_val_discr_to_nat, pi_scaling_toModel evr e h1 h2 h3 h4 h6,\n    Model.discr_of_pi_scaling _ _ h1 h2 h3 h4 h6, evr.val_sub_val_eq]\n  rw [ofN_val_discr_to_nat]\n\nlemma v_b2_of_v_a1_a2 {p : R} (valp : SurjVal p) (e : ValidModel R) (h1 : valp e.a1 ≥ 1)\n  (h2 : valp e.a2 = 1) : valp e.b2 ≥ 1 :=\n  val_add_ge_of_ge valp (val_mul_ge_of_left_ge valp h1) (val_mul_ge_of_right_ge valp (le_of_eq h2.symm))\n\nlemma v_b4_of_v_a1_a3_a4 {p : R} (valp : SurjVal p) (e : ValidModel R) (h1 : valp e.a1 ≥ 1)\n  (h3 : valp e.a3 ≥ q) (h4 : valp e.a4 ≥ q + 1) : valp e.b4 ≥ q + 1 := by\n  apply val_add_ge_of_ge valp\n  . rw [add_comm]\n    exact (val_mul_ge_of_both_ge valp h1 h3)\n  . exact (val_mul_ge_of_right_ge valp h4)\n\nlemma v_b6_of_v_a3_a6 {p : R} {q : ℕ} (valp : SurjVal p) (e : ValidModel R) (h3 : valp e.a3 ≥ q)\n  (h6 : valp e.a6 ≥ 2 * q) : valp e.b6 ≥ 2 * q := by\n  apply val_add_ge_of_ge valp\n  . simp -- TOOD use powers in defs of bis not mul...\n    rw [(show 2 * (q : Enat) = q + q by ring)]\n    exact add_le_add h3 h3\n  . exact (val_mul_ge_of_right_ge valp h6)\n\nlemma v_b8_of_v_ai {p : R} {q : ℕ} (valp : SurjVal p) (e : ValidModel R) (h1 : valp e.a1 ≥ 1)\n  (h2 : valp e.a2 = 1) (h3 : valp e.a3 ≥ q) (h4 : valp e.a4 ≥ q + 1)\n  (h6 : valp e.a6 ≥ 2 * q) : valp e.b8 ≥ 2 * q + 1 := by\n  simp only [Model.b8]\n  rw [sub_eq_add_neg, sub_eq_add_neg]\n  repeat apply val_add_ge_of_ge valp\n  . simp\n    rw [(show 2 * (q : Enat) + 1 = 0 + 1 + 2 * q by ring)]\n    repeat' apply add_le_add\n    exact zero_le _\n    assumption\n    assumption\n  . simp\n    rw [(show 2 * (q : Enat) + 1 = 0 + q + (q + 1) by ring)]\n    repeat' apply add_le_add\n    exact zero_le _\n    assumption\n    assumption\n  . simp\n    rw [(show 2 * (q : Enat) + 1 = 0 + 1 + (2 * q) by ring)]\n    repeat' apply add_le_add\n    exact zero_le _\n    apply le_of_eq\n    exact h2.symm\n    assumption\n  . simp at *\n    rw [(show 2 * (q : Enat) + 1 = 1 + q + q by ring)]\n    repeat' apply add_le_add\n    apply le_of_eq\n    exact h2.symm\n    assumption\n    assumption\n  . simp\n    rw [(show 2 * (q : Enat) + 1 = q + 1 + q by ring)]\n    apply add_le_add\n    assumption\n    exact le_of_succ_le h4\n\n\nprivate lemma aux (n q : ℕ) (h : 1 < q) (hn : 2 * q ≤ n) : 2 * q + 3 ≤ n + n :=\nby linarith\n\nprivate lemma aux' (n q m t : ℕ) (h : 1 < q) (h2': 1 ≤ n) (h4': q + 1 ≤ m) (h6': 2 * q ≤ t) :\n  2 * q + 3 ≤ n + (m + t) :=\nby linarith\n\nlemma v_discr_of_v_ai {p : R} {q : ℕ} (valp : SurjVal p) (e : ValidModel R) (hq : q > 1)\n  (h1 : valp e.a1 ≥ 1) (h2 : valp e.a2 = 1) (h3 : valp e.a3 ≥ q)\n  (h4 : valp e.a4 ≥ q + 1) (h6 : valp e.a6 ≥ 2 * q) :\n  valp e.discr ≥ 2 * q + 3 := by\n  have h2' := v_b2_of_v_a1_a2 valp e h1 h2\n  have h4' := v_b4_of_v_a1_a3_a4 valp e h1 h3 h4\n  have h6' := v_b6_of_v_a3_a6 valp e h3 h6\n  have h8' := v_b8_of_v_ai valp e h1 h2 h3 h4 h6\n  simp only [Model.discr]\n  rw [sub_eq_add_neg, sub_eq_add_neg]\n  repeat' apply val_add_ge_of_ge valp\n  . rw [←neg_mul_eq_neg_mul, ←neg_mul_eq_neg_mul, val_neg]\n    simp only [v_mul_eq_add_v, ge_iff_le] at *\n    rw [(show 2 * (q : Enat) + 3 = 1 + 1 + (2 * q + 1) by ring)]\n    repeat' apply add_le_add\n    all_goals assumption\n  . rw [val_neg, pow_succ', pow_succ', pow_one, ←add_self_eq_mul_two,\n      (show (q : Enat) + q + 3 = q + 1 + (q + 1) + 1 by ring)]\n    exact val_mul_ge_of_right_ge valp (val_mul_ge_of_both_ge valp\n      (val_mul_ge_of_both_ge valp h4' h4') (le_trans ((le_ofN _ _).2 (Nat.le_add_left 1 q)) h4'))\n  . simp only [val_neg, v_mul_eq_add_v, ge_iff_le] at *\n    cases hh6 : v valp (Model.b6 e.toModel) with\n    | ofN n =>\n      rw [add_assoc]\n      apply le_add_of_nonneg_of_le (zero_le _) _\n      simp [hh6] at *\n      norm_cast at *\n      exact aux n q hq h6' -- TODO linarith doesn't work\n    | top =>\n      simp\n      exact Enat.le_top _\n    -- rw [(show 2 * (q : Enat) + 3 = 0 + 1 + (2 * q + 1) by ring)]\n    -- rw [val_neg, mul_assoc, (show 3 = 2 + 1 by rfl)]\n    -- apply val_mul_ge_of_right_ge valp (val_mul_ge_of_both_ge valp h6' (le_trans ((le_ofN _ _).2 _) h6'))\n    -- rw [←add_self_eq_mul_two q]\n    -- exact Nat.add_le_add (Nat.succ_le_of_lt hq) (Nat.le_of_lt hq)\n  . cases hh2 : v valp (Model.b2 e.toModel) with\n    | ofN n =>\n      cases hh4 : v valp (Model.b4 e.toModel) with\n      | ofN m =>\n        cases hh6 : v valp (Model.b6 e.toModel) with\n        | ofN t =>\n          simp [*] at *\n          rw [add_assoc, add_assoc]\n          apply le_add_of_nonneg_of_le (zero_le _) _\n          norm_cast at *\n          exact aux' n q m t hq h2' h4' h6' -- TODO linarith doesn't work\n        | top =>\n          simp [hh6]\n          exact Enat.le_top _\n      | top =>\n        simp [hh4]\n        exact Enat.le_top _\n    | top =>\n      simp [hh2]\n      exact Enat.le_top _\n    -- rw [(show 3 = 1 + (1 + 1) by rfl), mul_comm, mul_assoc 9]\n    -- exact val_mul_ge_of_both_ge valp h6' (val_mul_ge_of_right_ge valp\n    --   (val_mul_ge_of_both_ge valp h2' (le_trans ((le_ofN _ _).2\n    --   (Nat.add_le_add (Nat.le_of_lt hq) (le_of_eq rfl))) h4')))\n\nlemma small_char_div_12 {p : R} (hp : p = 2 ∨ p = 3) (valp : SurjVal p) : valp 12 ≥ 1 := by\n  cases hp with\n  | inl p2 =>\n    rw [(show (12 : R) = 2 * 6 by norm_num)]\n    apply val_mul_ge_of_left_ge\n    rw [←p2]\n    exact le_of_eq (valp.v_uniformizer).symm\n  | inr p3 =>\n    rw [(show (12 : R) = 3 * 4 by norm_num)]\n    apply val_mul_ge_of_left_ge\n    rw [←p3]\n    exact le_of_eq (valp.v_uniformizer).symm\n\nlemma v_rst_b2_of_small_char {p : R} (valp : SurjVal p) (e : ValidModel R) (r s t : R)\n  (h_b2 : valp e.b2 ≥ 1) (h_p : valp 12 ≥ 1) : valp (rst_iso r s t e).b2 ≥ 1 := by\n  simp only [rst_iso]\n  -- aesop\n  rw [Model.rst_b2]\n  apply val_add_ge_of_ge valp h_b2\n  exact val_mul_ge_of_left_ge valp h_p\n\nsection cubic\n\ndef Δcubic (c : R × R × R) : R :=\n18 * c.1 * c.2.1 * c.2.2 - 4 * c.1 ^ 3 * c.2.2 + c.1 ^ 2 * c.2.1 ^ 2 - 4 * c.2.1 ^ 3 - 27 * c.2.2 ^ 2\n\ndef model_to_cubic {p : R} (evr : EnatValRing p) (e : ValidModel R) : R × R × R :=\n(evr.sub_val 1 e.a2, evr.sub_val 2 e.a4, evr.sub_val 3 e.a6)\n\ndef cubic_has_distinct_roots {p : R} (evr : EnatValRing p) (e : ValidModel R) : Prop :=\nevr.valtn (Δcubic (model_to_cubic evr e)) = 0\n\ndef δmultiplicity (c : R × R × R) : R := 3 * c.2.1 - c.1 ^ 2\n\ndef cubic_has_double_root {p : R} (evr : EnatValRing p) (e : ValidModel R) : Prop :=\nevr.valtn (Δcubic (model_to_cubic evr e)) > 0 ∧ evr.valtn (δmultiplicity (model_to_cubic evr e)) = 0\n\ndef cubic_has_triple_root {p : R} (evr : EnatValRing p) (e : ValidModel R) : Prop :=\nevr.valtn (Δcubic (model_to_cubic evr e)) > 0 ∧ evr.valtn (δmultiplicity (model_to_cubic evr e)) > 0\n\ndef move_cubic_double_root_to_origin_iso {p : R} (evr : EnatValRing p) (e : ValidModel R) : ValidModel R :=\n  let (a2p, a4p2, _) := model_to_cubic evr e\n  rst_iso (p * (evr.norm_repr (if evr.residue_char = 2 then a4p2 else evr.inv_mod a2p * evr.pth_root a4p2))) 0 0 e\n\ndef cubic_double_root_is_zero {p : R} (evr : EnatValRing p) (e : ValidModel R) : Prop :=\n  let (a2p, a4p2, a6p3) := model_to_cubic evr e\n  evr.valtn a2p = 0 ∧ evr.valtn a4p2 > 0 ∧ evr.valtn a6p3 > 0\n\nlemma move_cubic_double_root_to_origin {p : R} (evr : EnatValRing p) (e : ValidModel R) :\n  cubic_has_double_root evr e → cubic_double_root_is_zero evr (move_cubic_double_root_to_origin_iso evr e) := sorry\n\ndef move_cubic_triple_root_to_origin_iso {p : R} (evr : EnatValRing p) (e : ValidModel R) : ValidModel R :=\n  let (a2p, _, a6p3) := model_to_cubic evr e\n  rst_iso (evr.norm_repr (if evr.residue_char = 3 then -evr.pth_root a6p3 else -a2p * evr.inv_mod 3)) 0 0 e\n\ndef cubic_triple_root_is_zero {p : R} (evr : EnatValRing p) (e : ValidModel R) : Prop :=\n  let (a2p, a4p2, a6p3) := model_to_cubic evr e\n  evr.valtn a2p > 0 ∧ evr.valtn a4p2 > 0 ∧ evr.valtn a6p3 > 0\n\nlemma move_cubic_triple_root_to_origin {p : R} (evr : EnatValRing p) (e : ValidModel R) :\ncubic_has_triple_root evr e → cubic_triple_root_is_zero evr (move_cubic_triple_root_to_origin_iso evr e) := sorry\n\nend cubic\n\n\nend ValidModel\n", "meta": {"author": "KisaraBlue", "repo": "ec-tate-lean", "sha": "2b1b26c2622fde0344feaadddc077caca73bd929", "save_path": "github-repos/lean/KisaraBlue-ec-tate-lean", "path": "github-repos/lean/KisaraBlue-ec-tate-lean/ec-tate-lean-2b1b26c2622fde0344feaadddc077caca73bd929/ECTate/Algebra/EllipticCurve/LocalEC.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619350028204, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4979188082435052}}
{"text": "/-\nCopyright (c) 2022 Chris Birkbeck. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Birkbeck, David Loeffler\n\n! This file was ported from Lean 3 source module order.filter.zero_and_bounded_at_filter\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Module.Submodule.Basic\nimport Mathbin.Topology.Algebra.Monoid\nimport Mathbin.Analysis.Asymptotics.Asymptotics\n\n/-!\n# Zero and Bounded at filter\n\nGiven a filter `l` we define the notion of a function being `zero_at_filter` as well as being\n`bounded_at_filter`. Alongside this we construct the `submodule`, `add_submonoid` of functions\nthat are `zero_at_filter`. Similarly, we construct the `submodule` and `subalgebra` of functions\nthat are `bounded_at_filter`.\n\n-/\n\n\nnamespace Filter\n\nvariable {α β : Type _}\n\nopen Topology\n\n/-- If `l` is a filter on `α`, then a function `f : α → β` is `zero_at_filter l`\n  if it tends to zero along `l`. -/\ndef ZeroAtFilter [Zero β] [TopologicalSpace β] (l : Filter α) (f : α → β) : Prop :=\n  Filter.Tendsto f l (𝓝 0)\n#align filter.zero_at_filter Filter.ZeroAtFilter\n\ntheorem zero_zeroAtFilter [Zero β] [TopologicalSpace β] (l : Filter α) :\n    ZeroAtFilter l (0 : α → β) :=\n  tendsto_const_nhds\n#align filter.zero_zero_at_filter Filter.zero_zeroAtFilter\n\ntheorem ZeroAtFilter.add [TopologicalSpace β] [AddZeroClass β] [ContinuousAdd β] {l : Filter α}\n    {f g : α → β} (hf : ZeroAtFilter l f) (hg : ZeroAtFilter l g) : ZeroAtFilter l (f + g) := by\n  simpa using hf.add hg\n#align filter.zero_at_filter.add Filter.ZeroAtFilter.add\n\ntheorem ZeroAtFilter.neg [TopologicalSpace β] [AddGroup β] [ContinuousNeg β] {l : Filter α}\n    {f : α → β} (hf : ZeroAtFilter l f) : ZeroAtFilter l (-f) := by simpa using hf.neg\n#align filter.zero_at_filter.neg Filter.ZeroAtFilter.neg\n\ntheorem ZeroAtFilter.smul {𝕜 : Type _} [TopologicalSpace 𝕜] [TopologicalSpace β] [Zero 𝕜] [Zero β]\n    [SMulWithZero 𝕜 β] [ContinuousSMul 𝕜 β] {l : Filter α} {f : α → β} (c : 𝕜)\n    (hf : ZeroAtFilter l f) : ZeroAtFilter l (c • f) := by simpa using hf.const_smul c\n#align filter.zero_at_filter.smul Filter.ZeroAtFilter.smul\n\n/-- `zero_at_filter_submodule l` is the submodule of `f : α → β` which\ntend to zero along `l`. -/\ndef zeroAtFilterSubmodule [TopologicalSpace β] [Semiring β] [ContinuousAdd β] [ContinuousMul β]\n    (l : Filter α) : Submodule β (α → β)\n    where\n  carrier := ZeroAtFilter l\n  zero_mem' := zero_zeroAtFilter l\n  add_mem' a b ha hb := ha.add hb\n  smul_mem' c f hf := hf.smul c\n#align filter.zero_at_filter_submodule Filter.zeroAtFilterSubmodule\n\n/-- `zero_at_filter_add_submonoid l` is the additive submonoid of `f : α → β`\nwhich tend to zero along `l`. -/\ndef zeroAtFilterAddSubmonoid [TopologicalSpace β] [AddZeroClass β] [ContinuousAdd β]\n    (l : Filter α) : AddSubmonoid (α → β)\n    where\n  carrier := ZeroAtFilter l\n  add_mem' a b ha hb := ha.add hb\n  zero_mem' := zero_zeroAtFilter l\n#align filter.zero_at_filter_add_submonoid Filter.zeroAtFilterAddSubmonoid\n\n/-- If `l` is a filter on `α`, then a function `f: α → β` is `bounded_at_filter l`\nif `f =O[l] 1`. -/\ndef BoundedAtFilter [Norm β] (l : Filter α) (f : α → β) : Prop :=\n  Asymptotics.IsO l f (1 : α → ℝ)\n#align filter.bounded_at_filter Filter.BoundedAtFilter\n\ntheorem ZeroAtFilter.boundedAtFilter [NormedAddCommGroup β] {l : Filter α} {f : α → β}\n    (hf : ZeroAtFilter l f) : BoundedAtFilter l f :=\n  by\n  rw [zero_at_filter, ← Asymptotics.isOCat_const_iff (one_ne_zero' ℝ)] at hf\n  exact hf.is_O\n#align filter.zero_at_filter.bounded_at_filter Filter.ZeroAtFilter.boundedAtFilter\n\ntheorem const_boundedAtFilter [NormedField β] (l : Filter α) (c : β) :\n    BoundedAtFilter l (Function.const α c : α → β) :=\n  Asymptotics.isO_const_const c one_ne_zero l\n#align filter.const_bounded_at_filter Filter.const_boundedAtFilter\n\ntheorem BoundedAtFilter.add [NormedAddCommGroup β] {l : Filter α} {f g : α → β}\n    (hf : BoundedAtFilter l f) (hg : BoundedAtFilter l g) : BoundedAtFilter l (f + g) := by\n  simpa using hf.add hg\n#align filter.bounded_at_filter.add Filter.BoundedAtFilter.add\n\ntheorem BoundedAtFilter.neg [NormedAddCommGroup β] {l : Filter α} {f : α → β}\n    (hf : BoundedAtFilter l f) : BoundedAtFilter l (-f) :=\n  hf.neg_left\n#align filter.bounded_at_filter.neg Filter.BoundedAtFilter.neg\n\ntheorem BoundedAtFilter.smul {𝕜 : Type _} [NormedField 𝕜] [NormedAddCommGroup β] [NormedSpace 𝕜 β]\n    {l : Filter α} {f : α → β} (c : 𝕜) (hf : BoundedAtFilter l f) : BoundedAtFilter l (c • f) :=\n  hf.const_smul_left c\n#align filter.bounded_at_filter.smul Filter.BoundedAtFilter.smul\n\ntheorem BoundedAtFilter.mul [NormedField β] {l : Filter α} {f g : α → β} (hf : BoundedAtFilter l f)\n    (hg : BoundedAtFilter l g) : BoundedAtFilter l (f * g) :=\n  by\n  refine' (hf.mul hg).trans _\n  convert Asymptotics.isO_refl _ l\n  ext x\n  simp\n#align filter.bounded_at_filter.mul Filter.BoundedAtFilter.mul\n\n/-- The submodule of functions that are bounded along a filter `l`. -/\ndef boundedFilterSubmodule [NormedField β] (l : Filter α) : Submodule β (α → β)\n    where\n  carrier := BoundedAtFilter l\n  zero_mem' := const_boundedAtFilter l 0\n  add_mem' f g hf hg := hf.add hg\n  smul_mem' c f hf := hf.smul c\n#align filter.bounded_filter_submodule Filter.boundedFilterSubmodule\n\n/-- The subalgebra of functions that are bounded along a filter `l`. -/\ndef boundedFilterSubalgebra [NormedField β] (l : Filter α) : Subalgebra β (α → β) :=\n  by\n  refine' Submodule.toSubalgebra (bounded_filter_submodule l) _ fun f g hf hg => _\n  · exact const_bounded_at_filter l (1 : β)\n  · simpa only [Pi.one_apply, mul_one, norm_mul] using hf.mul hg\n#align filter.bounded_filter_subalgebra Filter.boundedFilterSubalgebra\n\nend Filter\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Filter/ZeroAndBoundedAtFilter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.49790529030579933}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.module.pi\n\n/-!\n# Bundled hom instances for module and multiplicative actions\n\nThis file defines instances for module, mul_action and related structures on bundled `_hom` types.\n\nThese are analogous to the instances in `algebra.module.pi`, but for bundled instead of unbundled\nfunctions.\n-/\n\nvariables {R S A B : Type*}\n\nnamespace add_monoid_hom\n\nsection\nvariables [monoid R] [monoid S] [add_monoid A] [add_comm_monoid B]\nvariables [distrib_mul_action R B] [distrib_mul_action S B]\n\ninstance : distrib_mul_action R (A →+ B) :=\n{ smul := λ r f,\n  { to_fun := r • f,\n    map_zero' := by simp,\n    map_add' := λ x y, by simp [smul_add] },\n  one_smul := λ f, by simp,\n  mul_smul := λ r s f, by simp [mul_smul],\n  smul_add := λ r f g, ext $ λ x, by simp [smul_add],\n  smul_zero := λ r, ext $ λ x, by simp [smul_zero] }\n\n@[simp] lemma coe_smul (r : R) (f : A →+ B) : ⇑(r • f) = r • f := rfl\nlemma smul_apply (r : R) (f : A →+ B) (x : A) : (r • f) x = r • f x := rfl\n\ninstance [smul_comm_class R S B] : smul_comm_class R S (A →+ B) :=\n⟨λ a b f, ext $ λ x, smul_comm _ _ _⟩\n\ninstance [has_smul R S] [is_scalar_tower R S B] : is_scalar_tower R S (A →+ B) :=\n⟨λ a b f, ext $ λ x, smul_assoc _ _ _⟩\n\ninstance [distrib_mul_action Rᵐᵒᵖ B] [is_central_scalar R B] : is_central_scalar R (A →+ B) :=\n⟨λ a b, ext $ λ x, op_smul_eq_smul _ _⟩\n\nend\n\ninstance [semiring R] [add_monoid A] [add_comm_monoid B] [module R B] :\n  module R (A →+ B) :=\n{ add_smul := λ r s x, ext $ λ y, by simp [add_smul],\n  zero_smul := λ x, ext $ λ y, by simp [zero_smul],\n  ..add_monoid_hom.distrib_mul_action }\n\nend add_monoid_hom\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/algebra/module/hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.4979052767710188}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury G. Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.affine_space.midpoint\nimport Mathlib.algebra.module.ordered\nimport Mathlib.tactic.field_simp\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Ordered modules as affine spaces\n\nIn this file we define the slope of a function `f : k → PE` taking values in an affine space over\n`k` and prove some theorems about `slope` and `line_map` in the case when `PE` is an ordered\nsemimodule over `k`. The `slope` function naturally appears in the Mean Value Theorem, and in the\nproof of the fact that a function with nonnegative second derivative on an interval is convex on\nthis interval. In the third part of this file we prove inequalities that will be used in\n`analysis.convex.basic` to link convexity of a function on an interval to monotonicity of the slope,\nsee section docstring below for details.\n\n## Implementation notes\n\nWe do not introduce the notion of ordered affine spaces (yet?). Instead, we prove various theorems\nfor an ordered semimodule interpreted as an affine space.\n\n## Tags\n\naffine space, ordered semimodule, slope\n-/\n\n/-!\n### Definition of `slope` and basic properties\n\nIn this section we define `slope f a b` and prove some properties that do not require order on the\ncodomain.  -/\n\n/-- `slope f a b = (b - a)⁻¹ • (f b -ᵥ f a)` is the slope of a function `f` on the interval\n`[a, b]`. Note that `slope f a a = 0`, not the derivative of `f` at `a`. -/\ndef slope {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E]\n    [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) : E :=\n  b - a⁻¹ • (f b -ᵥ f a)\n\ntheorem slope_def_field {k : Type u_1} [field k] (f : k → k) (a : k) (b : k) :\n    slope f a b = (f b - f a) / (b - a) :=\n  Eq.symm div_eq_inv_mul\n\n@[simp] theorem slope_same {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k]\n    [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) : slope f a a = 0 :=\n  sorry\n\ntheorem eq_of_slope_eq_zero {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k]\n    [add_comm_group E] [semimodule k E] [add_torsor E PE] {f : k → PE} {a : k} {b : k}\n    (h : slope f a b = 0) : f a = f b :=\n  sorry\n\ntheorem slope_comm {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E]\n    [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) : slope f a b = slope f b a :=\n  sorry\n\n/-- `slope f a c` is a linear combination of `slope f a b` and `slope f b c`. This version\nexplicitly provides coefficients. If `a ≠ c`, then the sum of the coefficients is `1`, so it is\nactually an affine combination, see `line_map_slope_slope_sub_div_sub`. -/\ntheorem sub_div_sub_smul_slope_add_sub_div_sub_smul_slope {k : Type u_1} {E : Type u_2}\n    {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE)\n    (a : k) (b : k) (c : k) :\n    ((b - a) / (c - a)) • slope f a b + ((c - b) / (c - a)) • slope f b c = slope f a c :=\n  sorry\n\n/-- `slope f a c` is an affine combination of `slope f a b` and `slope f b c`. This version uses\n`line_map` to express this property. -/\ntheorem line_map_slope_slope_sub_div_sub {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k]\n    [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) (c : k)\n    (h : a ≠ c) :\n    coe_fn (affine_map.line_map (slope f a b) (slope f b c)) ((c - b) / (c - a)) = slope f a c :=\n  sorry\n\n/-- `slope f a b` is an affine combination of `slope f a (line_map a b r)` and\n`slope f (line_map a b r) b`. We use `line_map` to express this property. -/\ntheorem line_map_slope_line_map_slope_line_map {k : Type u_1} {E : Type u_2} {PE : Type u_3}\n    [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k)\n    (r : k) :\n    coe_fn\n          (affine_map.line_map (slope f (coe_fn (affine_map.line_map a b) r) b)\n            (slope f a (coe_fn (affine_map.line_map a b) r)))\n          r =\n        slope f a b :=\n  sorry\n\n/-!\n### Monotonicity of `line_map`\n\nIn this section we prove that `line_map a b r` is monotone (strictly or not) in its arguments if\nother arguments belong to specific domains.\n-/\n\ntheorem line_map_mono_left {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E]\n    [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E} {r : k} (ha : a ≤ a')\n    (hr : r ≤ 1) : coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a' b) r :=\n  sorry\n\ntheorem line_map_strict_mono_left {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E}\n    {r : k} (ha : a < a') (hr : r < 1) :\n    coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a' b) r :=\n  sorry\n\ntheorem line_map_mono_right {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {b' : E}\n    {r : k} (hb : b ≤ b') (hr : 0 ≤ r) :\n    coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a b') r :=\n  sorry\n\ntheorem line_map_strict_mono_right {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {b' : E}\n    {r : k} (hb : b < b') (hr : 0 < r) :\n    coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a b') r :=\n  sorry\n\ntheorem line_map_mono_endpoints {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E}\n    {b' : E} {r : k} (ha : a ≤ a') (hb : b ≤ b') (h₀ : 0 ≤ r) (h₁ : r ≤ 1) :\n    coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a' b') r :=\n  has_le.le.trans (line_map_mono_left ha h₁) (line_map_mono_right hb h₀)\n\ntheorem line_map_strict_mono_endpoints {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E}\n    {b' : E} {r : k} (ha : a < a') (hb : b < b') (h₀ : 0 ≤ r) (h₁ : r ≤ 1) :\n    coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a' b') r :=\n  sorry\n\ntheorem line_map_lt_line_map_iff_of_lt {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    {r' : k} (h : r < r') :\n    coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a b) r' ↔ a < b :=\n  sorry\n\ntheorem left_lt_line_map_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : 0 < r) : a < coe_fn (affine_map.line_map a b) r ↔ a < b :=\n  sorry\n\ntheorem line_map_lt_left_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : 0 < r) : coe_fn (affine_map.line_map a b) r < a ↔ b < a :=\n  left_lt_line_map_iff_lt h\n\ntheorem line_map_lt_right_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : r < 1) : coe_fn (affine_map.line_map a b) r < b ↔ a < b :=\n  sorry\n\ntheorem right_lt_line_map_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : r < 1) : b < coe_fn (affine_map.line_map a b) r ↔ b < a :=\n  line_map_lt_right_iff_lt h\n\ntheorem line_map_le_line_map_iff_of_lt {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    {r' : k} (h : r < r') :\n    coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a b) r' ↔ a ≤ b :=\n  sorry\n\ntheorem left_le_line_map_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : 0 < r) : a ≤ coe_fn (affine_map.line_map a b) r ↔ a ≤ b :=\n  sorry\n\n@[simp] theorem left_le_midpoint {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} :\n    a ≤ midpoint k a b ↔ a ≤ b :=\n  left_le_line_map_iff_le (iff.mpr inv_pos zero_lt_two)\n\ntheorem line_map_le_left_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : 0 < r) : coe_fn (affine_map.line_map a b) r ≤ a ↔ b ≤ a :=\n  left_le_line_map_iff_le h\n\n@[simp] theorem midpoint_le_left {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} :\n    midpoint k a b ≤ a ↔ b ≤ a :=\n  line_map_le_left_iff_le (iff.mpr inv_pos zero_lt_two)\n\ntheorem line_map_le_right_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : r < 1) : coe_fn (affine_map.line_map a b) r ≤ b ↔ a ≤ b :=\n  sorry\n\n@[simp] theorem midpoint_le_right {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} :\n    midpoint k a b ≤ b ↔ a ≤ b :=\n  line_map_le_right_iff_le (inv_lt_one one_lt_two)\n\ntheorem right_le_line_map_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k}\n    (h : r < 1) : b ≤ coe_fn (affine_map.line_map a b) r ↔ b ≤ a :=\n  line_map_le_right_iff_le h\n\n@[simp] theorem right_le_midpoint {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} :\n    b ≤ midpoint k a b ↔ b ≤ a :=\n  right_le_line_map_iff_le (inv_lt_one one_lt_two)\n\n/-!\n### Convexity and slope\n\nGiven an interval `[a, b]` and a point `c ∈ (a, b)`, `c = line_map a b r`, there are a few ways to\nsay that the point `(c, f c)` is above/below the segment `[(a, f a), (b, f b)]`:\n\n* compare `f c` to `line_map (f a) (f b) r`;\n* compare `slope f a c` to `slope `f a b`;\n* compare `slope f c b` to `slope f a b`;\n* compare `slope f a c` to `slope f c b`.\n\nIn this section we prove equivalence of these four approaches. In order to make the statements more\nreadable, we introduce local notation `c = line_map a b r`. Then we prove lemmas like\n\n```\nlemma map_le_line_map_iff_slope_le_slope_left (h : 0 < r * (b - a)) :\n  f c ≤ line_map (f a) (f b) r ↔ slope f a c ≤ slope f a b :=\n```\n\nFor each inequality between `f c` and `line_map (f a) (f b) r` we provide 3 lemmas:\n\n* `*_left` relates it to an inequality on `slope f a c` and `slope f a b`;\n* `*_right` relates it to an inequality on `slope f a b` and `slope f c b`;\n* no-suffix version relates it to an inequality on `slope f a c` and `slope f c b`.\n\nLater these inequalities will be used in to restate `convex_on` in terms of monotonicity of the\nslope.\n-/\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is non-strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c ≤ slope f a b`. -/\ntheorem map_le_line_map_iff_slope_le_slope_left {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) :\n    f (coe_fn (affine_map.line_map a b) r) ≤ coe_fn (affine_map.line_map (f a) (f b)) r ↔\n        slope f a (coe_fn (affine_map.line_map a b) r) ≤ slope f a b :=\n  sorry\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is non-strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b ≤ slope f a c`. -/\ntheorem line_map_le_map_iff_slope_le_slope_left {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) :\n    coe_fn (affine_map.line_map (f a) (f b)) r ≤ f (coe_fn (affine_map.line_map a b) r) ↔\n        slope f a b ≤ slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_le_line_map_iff_slope_le_slope_left h\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c < slope f a b`. -/\ntheorem map_lt_line_map_iff_slope_lt_slope_left {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) :\n    f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r ↔\n        slope f a (coe_fn (affine_map.line_map a b) r) < slope f a b :=\n  lt_iff_lt_of_le_iff_le' (line_map_le_map_iff_slope_le_slope_left h)\n    (map_le_line_map_iff_slope_le_slope_left h)\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b < slope f a c`. -/\ntheorem line_map_lt_map_iff_slope_lt_slope_left {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) :\n    coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) ↔\n        slope f a b < slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_lt_line_map_iff_slope_lt_slope_left h\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is non-strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b ≤ slope f c b`. -/\ntheorem map_le_line_map_iff_slope_le_slope_right {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) :\n    f (coe_fn (affine_map.line_map a b) r) ≤ coe_fn (affine_map.line_map (f a) (f b)) r ↔\n        slope f a b ≤ slope f (coe_fn (affine_map.line_map a b) r) b :=\n  sorry\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is non-strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b ≤ slope f a b`. -/\ntheorem line_map_le_map_iff_slope_le_slope_right {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) :\n    coe_fn (affine_map.line_map (f a) (f b)) r ≤ f (coe_fn (affine_map.line_map a b) r) ↔\n        slope f (coe_fn (affine_map.line_map a b) r) b ≤ slope f a b :=\n  map_le_line_map_iff_slope_le_slope_right h\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b < slope f c b`. -/\ntheorem map_lt_line_map_iff_slope_lt_slope_right {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) :\n    f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r ↔\n        slope f a b < slope f (coe_fn (affine_map.line_map a b) r) b :=\n  lt_iff_lt_of_le_iff_le' (line_map_le_map_iff_slope_le_slope_right h)\n    (map_le_line_map_iff_slope_le_slope_right h)\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b < slope f a b`. -/\ntheorem line_map_lt_map_iff_slope_lt_slope_right {k : Type u_1} {E : Type u_2}\n    [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E]\n    {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) :\n    coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) ↔\n        slope f (coe_fn (affine_map.line_map a b) r) b < slope f a b :=\n  map_lt_line_map_iff_slope_lt_slope_right h\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is non-strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c ≤ slope f c b`. -/\ntheorem map_le_line_map_iff_slope_le_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) :\n    f (coe_fn (affine_map.line_map a b) r) ≤ coe_fn (affine_map.line_map (f a) (f b)) r ↔\n        slope f a (coe_fn (affine_map.line_map a b) r) ≤\n          slope f (coe_fn (affine_map.line_map a b) r) b :=\n  sorry\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is non-strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b ≤ slope f a c`. -/\ntheorem line_map_le_map_iff_slope_le_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) :\n    coe_fn (affine_map.line_map (f a) (f b)) r ≤ f (coe_fn (affine_map.line_map a b) r) ↔\n        slope f (coe_fn (affine_map.line_map a b) r) b ≤\n          slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_le_line_map_iff_slope_le_slope hab h₀ h₁\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c < slope f c b`. -/\ntheorem map_lt_line_map_iff_slope_lt_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) :\n    f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r ↔\n        slope f a (coe_fn (affine_map.line_map a b) r) <\n          slope f (coe_fn (affine_map.line_map a b) r) b :=\n  lt_iff_lt_of_le_iff_le' (line_map_le_map_iff_slope_le_slope hab h₀ h₁)\n    (map_le_line_map_iff_slope_le_slope hab h₀ h₁)\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b < slope f a c`. -/\ntheorem line_map_lt_map_iff_slope_lt_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k]\n    [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) :\n    coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) ↔\n        slope f (coe_fn (affine_map.line_map a b) r) b <\n          slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_lt_line_map_iff_slope_lt_slope hab h₀ h₁\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/affine_space/ordered_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7905303087996143, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.49785590937243546}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.category.preorder\nimport category_theory.eq_to_hom\nimport topology.category.Top.epi_mono\nimport topology.sets.opens\n\n/-!\n# The category of open sets in a topological space.\n\nWe define `to_Top : opens X ⥤ Top` and\n`map (f : X ⟶ Y) : opens Y ⥤ opens X`, given by taking preimages of open sets.\n\nUnfortunately `opens` isn't (usefully) a functor `Top ⥤ Cat`.\n(One can in fact define such a functor,\nbut using it results in unresolvable `eq.rec` terms in goals.)\n\nReally it's a 2-functor from (spaces, continuous functions, equalities)\nto (categories, functors, natural isomorphisms).\nWe don't attempt to set up the full theory here, but do provide the natural isomorphisms\n`map_id : map (𝟙 X) ≅ 𝟭 (opens X)` and\n`map_comp : map (f ≫ g) ≅ map g ⋙ map f`.\n\nBeyond that, there's a collection of simp lemmas for working with these constructions.\n-/\n\nopen category_theory\nopen topological_space\nopen opposite\n\nuniverse u\n\nnamespace topological_space.opens\n\nvariables {X Y Z : Top.{u}}\n\n/-!\nSince `opens X` has a partial order, it automatically receives a `category` instance.\nUnfortunately, because we do not allow morphisms in `Prop`,\nthe morphisms `U ⟶ V` are not just proofs `U ≤ V`, but rather\n`ulift (plift (U ≤ V))`.\n-/\n\ninstance opens_hom_has_coe_to_fun {U V : opens X} : has_coe_to_fun (U ⟶ V) (λ f, U → V) :=\n⟨λ f x, ⟨x, f.le x.2⟩⟩\n\n/-!\nWe now construct as morphisms various inclusions of open sets.\n-/\n-- This is tedious, but necessary because we decided not to allow Prop as morphisms in a category...\n\n/--\nThe inclusion `U ⊓ V ⟶ U` as a morphism in the category of open sets.\n-/\ndef inf_le_left (U V : opens X) : U ⊓ V ⟶ U := inf_le_left.hom\n\n/--\nThe inclusion `U ⊓ V ⟶ V` as a morphism in the category of open sets.\n-/\ndef inf_le_right (U V : opens X) : U ⊓ V ⟶ V := inf_le_right.hom\n\n/--\nThe inclusion `U i ⟶ supr U` as a morphism in the category of open sets.\n-/\ndef le_supr {ι : Type*} (U : ι → opens X) (i : ι) : U i ⟶ supr U := (le_supr U i).hom\n\n/--\nThe inclusion `⊥ ⟶ U` as a morphism in the category of open sets.\n-/\ndef bot_le (U : opens X) : ⊥ ⟶ U := bot_le.hom\n\n/--\nThe inclusion `U ⟶ ⊤` as a morphism in the category of open sets.\n-/\ndef le_top (U : opens X) : U ⟶ ⊤ := le_top.hom\n\n-- We do not mark this as a simp lemma because it breaks open `x`.\n-- Nevertheless, it is useful in `sheaf_of_functions`.\nlemma inf_le_left_apply (U V : opens X) (x) :\n  (inf_le_left U V) x = ⟨x.1, (@_root_.inf_le_left _ _ U V : _ ≤ _) x.2⟩ :=\nrfl\n\n@[simp]\nlemma inf_le_left_apply_mk (U V : opens X) (x) (m) :\n  (inf_le_left U V) ⟨x, m⟩ = ⟨x, (@_root_.inf_le_left _ _ U V : _ ≤ _) m⟩ :=\nrfl\n\n@[simp]\nlemma le_supr_apply_mk {ι : Type*} (U : ι → opens X) (i : ι) (x) (m) :\n  (le_supr U i) ⟨x, m⟩ = ⟨x, (_root_.le_supr U i : _) m⟩ :=\nrfl\n\n/--\nThe functor from open sets in `X` to `Top`,\nrealising each open set as a topological space itself.\n-/\ndef to_Top (X : Top.{u}) : opens X ⥤ Top :=\n{ obj := λ U, ⟨U, infer_instance⟩,\n  map := λ U V i, ⟨λ x, ⟨x.1, i.le x.2⟩,\n    (embedding.continuous_iff embedding_subtype_coe).2 continuous_induced_dom⟩ }\n\n@[simp]\nlemma to_Top_map (X : Top.{u}) {U V : opens X} {f : U ⟶ V} {x} {h} :\n  ((to_Top X).map f) ⟨x, h⟩ = ⟨x, f.le h⟩ :=\nrfl\n\n/--\nThe inclusion map from an open subset to the whole space, as a morphism in `Top`.\n-/\n@[simps { fully_applied := ff }]\ndef inclusion {X : Top.{u}} (U : opens X) : (to_Top X).obj U ⟶ X :=\n{ to_fun := _,\n  continuous_to_fun := continuous_subtype_coe }\n\nlemma open_embedding {X : Top.{u}} (U : opens X) : open_embedding (inclusion U) :=\nis_open.open_embedding_subtype_coe U.2\n\n/--\nThe inclusion of the top open subset (i.e. the whole space) is an isomorphism.\n-/\ndef inclusion_top_iso (X : Top.{u}) : (to_Top X).obj ⊤ ≅ X :=\n{ hom := inclusion ⊤,\n  inv := ⟨λ x, ⟨x, trivial⟩, continuous_def.2 $ λ U ⟨S, hS, hSU⟩, hSU ▸ hS⟩ }\n\n/-- `opens.map f` gives the functor from open sets in Y to open set in X,\n    given by taking preimages under f. -/\ndef map (f : X ⟶ Y) : opens Y ⥤ opens X :=\n{ obj := λ U, ⟨ f ⁻¹' U, U.is_open.preimage f.continuous ⟩,\n  map := λ U V i, ⟨ ⟨ λ x h, i.le h ⟩ ⟩ }.\n\nlemma map_coe (f : X ⟶ Y) (U : opens Y) :\n  ↑((map f).obj U) = f ⁻¹' U :=\nrfl\n\n@[simp] lemma map_obj (f : X ⟶ Y) (U) (p) :\n  (map f).obj ⟨U, p⟩ = ⟨f ⁻¹' U, p.preimage f.continuous⟩ := rfl\n\n@[simp] lemma map_id_obj (U : opens X) : (map (𝟙 X)).obj U = U :=\nlet ⟨_,_⟩ := U in rfl\n\n@[simp] lemma map_id_obj' (U) (p) : (map (𝟙 X)).obj ⟨U, p⟩ = ⟨U, p⟩ :=\nrfl\n\n@[simp] lemma map_id_obj_unop (U : (opens X)ᵒᵖ) : (map (𝟙 X)).obj (unop U) = unop U :=\nlet ⟨_,_⟩ := U.unop in rfl\n@[simp] \n\n/--\nThe inclusion `U ⟶ (map f).obj ⊤` as a morphism in the category of open sets.\n-/\ndef le_map_top (f : X ⟶ Y) (U : opens X) : U ⟶ (map f).obj ⊤ :=\nle_top U\n\n@[simp] lemma map_comp_obj (f : X ⟶ Y) (g : Y ⟶ Z) (U) :\n  (map (f ≫ g)).obj U = (map f).obj ((map g).obj U) :=\nrfl\n\n@[simp] lemma map_comp_obj' (f : X ⟶ Y) (g : Y ⟶ Z) (U) (p) :\n  (map (f ≫ g)).obj ⟨U, p⟩ = (map f).obj ((map g).obj ⟨U, p⟩) :=\nrfl\n\n@[simp] lemma map_comp_map (f : X ⟶ Y) (g : Y ⟶ Z) {U V} (i : U ⟶ V) :\n  (map (f ≫ g)).map i = (map f).map ((map g).map i) :=\nrfl\n\n@[simp] lemma map_comp_obj_unop (f : X ⟶ Y) (g : Y ⟶ Z) (U) :\n  (map (f ≫ g)).obj (unop U) = (map f).obj ((map g).obj (unop U)) :=\nrfl\n\n@[simp] lemma op_map_comp_obj (f : X ⟶ Y) (g : Y ⟶ Z) (U) :\n  (map (f ≫ g)).op.obj U = (map f).op.obj ((map g).op.obj U) :=\nrfl\n\nlemma map_supr (f : X ⟶ Y) {ι : Type*} (U : ι → opens Y) :\n  (map f).obj (supr U) = supr ((map f).obj ∘ U) :=\nbegin\n  ext1, rw [supr_def, supr_def, map_obj],\n  dsimp, rw set.preimage_Union, refl,\nend\n\nsection\nvariable (X)\n\n/--\nThe functor `opens X ⥤ opens X` given by taking preimages under the identity function\nis naturally isomorphic to the identity functor.\n-/\n@[simps]\ndef map_id : map (𝟙 X) ≅ 𝟭 (opens X) :=\n{ hom := { app := λ U, eq_to_hom (map_id_obj U) },\n  inv := { app := λ U, eq_to_hom (map_id_obj U).symm } }\n\nlemma map_id_eq : map (𝟙 X) = 𝟭 (opens X) :=\nby { unfold map, congr, ext, refl, ext }\n\nend\n\n/--\nThe natural isomorphism between taking preimages under `f ≫ g`, and the composite\nof taking preimages under `g`, then preimages under `f`.\n-/\n@[simps]\ndef map_comp (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=\n{ hom := { app := λ U, eq_to_hom (map_comp_obj f g U) },\n  inv := { app := λ U, eq_to_hom (map_comp_obj f g U).symm } }\n\nlemma map_comp_eq (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) = map g ⋙ map f :=\nrfl\n\n/--\nIf two continuous maps `f g : X ⟶ Y` are equal,\nthen the functors `opens Y ⥤ opens X` they induce are isomorphic.\n-/\n-- We could make `f g` implicit here, but it's nice to be able to see when\n-- they are the identity (often!)\ndef map_iso (f g : X ⟶ Y) (h : f = g) : map f ≅ map g :=\nnat_iso.of_components (λ U, eq_to_iso (congr_fun (congr_arg functor.obj (congr_arg map h)) U) )\n  (by obviously)\n\nlemma map_eq (f g : X ⟶ Y) (h : f = g) : map f = map g :=\nby { unfold map, congr, ext, rw h, rw h, assumption' }\n\n@[simp] lemma map_iso_refl (f : X ⟶ Y) (h) : map_iso f f h = iso.refl (map _) := rfl\n\n@[simp] lemma map_iso_hom_app (f g : X ⟶ Y) (h : f = g) (U : opens Y) :\n  (map_iso f g h).hom.app U = eq_to_hom (congr_fun (congr_arg functor.obj (congr_arg map h)) U) :=\nrfl\n\n@[simp] lemma map_iso_inv_app (f g : X ⟶ Y) (h : f = g) (U : opens Y) :\n  (map_iso f g h).inv.app U =\n     eq_to_hom (congr_fun (congr_arg functor.obj (congr_arg map h.symm)) U) :=\nrfl\n\n/-- A homeomorphism of spaces gives an equivalence of categories of open sets.\n\nTODO: define `order_iso.equivalence`, use it.\n-/\n@[simps] def map_map_iso {X Y : Top.{u}} (H : X ≅ Y) : opens Y ≌ opens X :=\n{ functor := map H.hom,\n  inverse := map H.inv,\n  unit_iso := nat_iso.of_components (λ U, eq_to_iso (by simp [map, set.preimage_preimage]))\n    (by { intros _ _ _, simp }),\n  counit_iso := nat_iso.of_components (λ U, eq_to_iso (by simp [map, set.preimage_preimage]))\n    (by { intros _ _ _, simp }) }\n\nend topological_space.opens\n\n/--\nAn open map `f : X ⟶ Y` induces a functor `opens X ⥤ opens Y`.\n-/\n@[simps]\ndef is_open_map.functor {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) :\n  opens X ⥤ opens Y :=\n{ obj := λ U, ⟨f '' U, hf U U.2⟩,\n  map := λ U V h, ⟨⟨set.image_subset _ h.down.down⟩⟩ }\n\n/--\nAn open map `f : X ⟶ Y` induces an adjunction between `opens X` and `opens Y`.\n-/\ndef is_open_map.adjunction {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) :\n  adjunction hf.functor (topological_space.opens.map f) :=\nadjunction.mk_of_unit_counit\n{ unit := { app := λ U, hom_of_le $ λ x hxU, ⟨x, hxU, rfl⟩ },\n  counit := { app := λ V, hom_of_le $ λ y ⟨x, hfxV, hxy⟩, hxy ▸ hfxV } }\n\ninstance is_open_map.functor_full_of_mono {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f)\n  [H : mono f] : full hf.functor :=\n{ preimage := λ U V i, hom_of_le (λ x hx, by\n  { obtain ⟨y, hy, eq⟩ := i.le ⟨x, hx, rfl⟩, exact (Top.mono_iff_injective f).mp H eq ▸ hy }) }\n\ninstance is_open_map.functor_faithful {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) :\n  faithful hf.functor := {}\n\nnamespace topological_space.opens\nopen topological_space\n\n@[simp] lemma open_embedding_obj_top {X : Top} (U : opens X) :\n  U.open_embedding.is_open_map.functor.obj ⊤ = U :=\nby { ext1, exact set.image_univ.trans subtype.range_coe }\n\n@[simp] lemma inclusion_map_eq_top {X : Top} (U : opens X) :\n  (opens.map U.inclusion).obj U = ⊤ :=\nby { ext1, exact subtype.coe_preimage_self _ }\n\n@[simp]\nlemma adjunction_counit_app_self {X : Top} (U : opens X) :\n  U.open_embedding.is_open_map.adjunction.counit.app U = eq_to_hom (by simp) :=\nby ext\n\nlemma inclusion_top_functor (X : Top) :\n  (@opens.open_embedding X ⊤).is_open_map.functor =\n  map (inclusion_top_iso X).inv :=\nbegin\n  apply functor.hext, intro, abstract obj_eq { ext,\n  exact ⟨ λ ⟨⟨_,_⟩,h,rfl⟩, h, λ h, ⟨⟨x,trivial⟩,h,rfl⟩ ⟩ },\n  intros, apply subsingleton.helim, congr' 1,\n  iterate 2 {apply inclusion_top_functor.obj_eq},\nend\n\nlemma functor_obj_map_obj {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) (U : opens Y) :\n  hf.functor.obj ((opens.map f).obj U) = hf.functor.obj ⊤ ⊓ U :=\nbegin\n  ext, split,\n  { rintros ⟨x, hx, rfl⟩, exact ⟨⟨x, trivial, rfl⟩, hx⟩ },\n  { rintros ⟨⟨x, -, rfl⟩, hx⟩, exact ⟨x, hx, rfl⟩ }\nend\n\n@[simp] lemma functor_map_eq_inf {X : Top} (U V : opens X) :\n  U.open_embedding.is_open_map.functor.obj ((opens.map U.inclusion).obj V) = V ⊓ U :=\nby { ext1, refine set.image_preimage_eq_inter_range.trans _, simpa }\n\nlemma map_functor_eq' {X U : Top} (f : U ⟶ X) (hf : _root_.open_embedding f) (V) :\n  ((opens.map f).obj $ hf.is_open_map.functor.obj V) = V :=\nopens.ext $ set.preimage_image_eq _ hf.inj\n\n@[simp] lemma map_functor_eq {X : Top} {U : opens X} (V : opens U) :\n  ((opens.map U.inclusion).obj $ U.open_embedding.is_open_map.functor.obj V) = V :=\ntopological_space.opens.map_functor_eq' _ U.open_embedding V\n\n@[simp] lemma adjunction_counit_map_functor {X : Top} {U : opens X} (V : opens U) :\n  U.open_embedding.is_open_map.adjunction.counit.app (U.open_embedding.is_open_map.functor.obj V)\n    = eq_to_hom (by { conv_rhs { rw ← V.map_functor_eq }, refl }) :=\nby ext\n\nend topological_space.opens\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/category/Top/opens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597974, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.49777433051375786}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.eq_to_hom\nimport category_theory.quotient\nimport combinatorics.quiver.path\n\n/-!\n# The category paths on a quiver.\nWhen `C` is a quiver, `paths C` is the category of paths.\n\n## When the quiver is itself a category\nWe provide `path_composition : paths C ⥤ C`.\n\nWe check that the quotient of the path category of a category by the canonical relation\n(paths are related if they compose to the same path) is equivalent to the original category.\n-/\n\nuniverses v₁ v₂ u₁ u₂\n\nnamespace category_theory\n\nsection\n\n/--\nA type synonym for the category of paths in a quiver.\n-/\ndef paths (V : Type u₁) : Type u₁ := V\n\ninstance (V : Type u₁) [inhabited V] : inhabited (paths V) := ⟨(default : V)⟩\n\nvariables (V : Type u₁) [quiver.{v₁+1} V]\n\nnamespace paths\n\ninstance category_paths : category.{max u₁ v₁} (paths V) :=\n{ hom := λ (X Y : V), quiver.path X Y,\n  id := λ X, quiver.path.nil,\n  comp := λ X Y Z f g, quiver.path.comp f g, }\n\nvariables {V}\n\n/--\nThe inclusion of a quiver `V` into its path category, as a prefunctor.\n-/\n@[simps]\ndef of : prefunctor V (paths V) :=\n{ obj := λ X, X,\n  map := λ X Y f, f.to_path, }\n\nlocal attribute [ext] functor.ext\n\n/-- Two functors out of a path category are equal when they agree on singleton paths. -/\n@[ext]\nlemma ext_functor {C} [category C]\n  {F G : paths V ⥤ C}\n  (h_obj : F.obj = G.obj)\n  (h : ∀ (a b : V) (e : a ⟶ b), F.map e.to_path =\n  eq_to_hom (congr_fun h_obj a) ≫ G.map e.to_path ≫ eq_to_hom (congr_fun h_obj.symm b)) :\n  F = G :=\nbegin\n  ext X Y f,\n  { induction f with Y' Z' g e ih,\n    { erw [F.map_id, G.map_id, category.id_comp, eq_to_hom_trans, eq_to_hom_refl], },\n    { erw [F.map_comp g e.to_path, G.map_comp g e.to_path, ih, h],\n      simp only [category.id_comp, eq_to_hom_refl, eq_to_hom_trans_assoc, category.assoc], }, },\n  { intro X, rw h_obj, }\nend\n\nend paths\n\nvariables (W : Type u₂) [quiver.{v₂+1} W]\n\n-- A restatement of `prefunctor.map_path_comp` using `f ≫ g` instead of `f.comp g`.\n@[simp] lemma prefunctor.map_path_comp' (F : prefunctor V W)\n  {X Y Z : paths V} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  F.map_path (f ≫ g) = (F.map_path f).comp (F.map_path g) :=\nprefunctor.map_path_comp _ _ _\n\nend\n\nsection\n\nvariables {C : Type u₁} [category.{v₁} C]\n\nopen quiver\n\n/-- A path in a category can be composed to a single morphism. -/\n@[simp]\ndef compose_path {X : C} : Π {Y : C} (p : path X Y), X ⟶ Y\n| _ path.nil := 𝟙 X\n| _ (path.cons p e) := compose_path p ≫ e\n\n@[simp]\nlemma compose_path_to_path {X Y : C} (f : X ⟶ Y) : compose_path (f.to_path) = f :=\ncategory.id_comp _\n\n@[simp]\nlemma compose_path_comp {X Y Z : C} (f : path X Y) (g : path Y Z) :\n  compose_path (f.comp g) = compose_path f ≫ compose_path g :=\nbegin\n  induction g with Y' Z' g e ih,\n  { simp, },\n  { simp [ih], },\nend\n\n@[simp]\n\n\n@[simp]\nlemma compose_path_comp' {X Y Z : paths C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  compose_path (f ≫ g) = compose_path f ≫ compose_path g :=\ncompose_path_comp f g\n\nvariables (C)\n\n/-- Composition of paths as functor from the path category of a category to the category. -/\n@[simps]\ndef path_composition : paths C ⥤ C :=\n{ obj := λ X, X,\n  map := λ X Y f, compose_path f, }\n\n/-- The canonical relation on the path category of a category:\ntwo paths are related if they compose to the same morphism. -/\n-- TODO: This, and what follows, should be generalized to\n-- the `hom_rel` for the kernel of any functor.\n-- Indeed, this should be part of an equivalence between congruence relations on a category `C`\n-- and full, essentially surjective functors out of `C`.\n@[simp]\ndef paths_hom_rel : hom_rel (paths C) :=\nλ X Y p q, (path_composition C).map p = (path_composition C).map q\n\n/-- The functor from a category to the canonical quotient of its path category. -/\n@[simps]\ndef to_quotient_paths : C ⥤ quotient (paths_hom_rel C) :=\n{ obj := λ X, quotient.mk X,\n  map := λ X Y f, quot.mk _ f.to_path,\n  map_id' := λ X, quot.sound (quotient.comp_closure.of _ _ _ (by simp)),\n  map_comp' := λ X Y Z f g, quot.sound (quotient.comp_closure.of _ _ _ (by simp)), }\n\n/-- The functor from the canonical quotient of a path category of a category\nto the original category. -/\n@[simps]\ndef quotient_paths_to : quotient (paths_hom_rel C) ⥤ C :=\nquotient.lift _ (path_composition C) (λ X Y p q w, w)\n\n/-- The canonical quotient of the path category of a category\nis equivalent to the original category. -/\ndef quotient_paths_equiv : quotient (paths_hom_rel C) ≌ C :=\n{ functor := quotient_paths_to C,\n  inverse := to_quotient_paths C,\n  unit_iso := nat_iso.of_components (λ X, by { cases X, refl, }) begin\n    intros,\n    cases X, cases Y,\n    induction f,\n    dsimp,\n    simp only [category.comp_id, category.id_comp],\n    apply quot.sound,\n    apply quotient.comp_closure.of,\n    simp [paths_hom_rel],\n  end,\n  counit_iso := nat_iso.of_components (λ X, iso.refl _) (by tidy),\n  functor_unit_iso_comp' := by { intros, cases X, dsimp, simp, refl, }, }\n\nend\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/path_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125848754471, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.49777432784082665}}
{"text": "theorem append_nil_both\n  {t: Type} {xs ys: list t}: xs ++ ys = [] ↔ xs = [] ∧ ys = [] :=\nbegin\n  split,\n  intro h,\n  induction xs,\n  induction ys,\n  split,\n  refl,\n  refl,\n  split,\n  refl,\n  cases h,\n  cases h,\n  intro h,\n  cases h,\n  rw h_left,\n  rw h_right,\n  simp [list.append],\nend\n", "meta": {"author": "azdavis", "repo": "hatsugen", "sha": "a18f70f9ea4ce30c0baf0c40748aad5ccd176c60", "save_path": "github-repos/lean/azdavis-hatsugen", "path": "github-repos/lean/azdavis-hatsugen/hatsugen-a18f70f9ea4ce30c0baf0c40748aad5ccd176c60/src/util/list/append.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.49777432549844086}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n\n! This file was ported from Lean 3 source module init.meta.well_founded_tactics\n! leanprover-community/mathlib commit 5885f626d8db2f03abe21c45749d8e3995f0988e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nprelude\nimport Leanbin.Init.Meta.Default\nimport Leanbin.Init.Data.Sigma.Lex\nimport Leanbin.Init.Data.Nat.Lemmas\nimport Leanbin.Init.Data.List.Instances\nimport Leanbin.Init.Data.List.Qsort\n\n#print Nat.lt_add_of_zero_lt_left /-\n-- TODO(Leo): move this lemma, or delete it after we add algebraic normalizer. \n-- TODO(Leo): move this lemma, or delete it after we add algebraic normalizer.\ntheorem Nat.lt_add_of_zero_lt_left (a b : Nat) (h : 0 < b) : a < a + b :=\n  show a + 0 < a + b by\n    apply Nat.add_lt_add_left\n    assumption\n#align nat.lt_add_of_zero_lt_left Nat.lt_add_of_zero_lt_left\n-/\n\n#print Nat.zero_lt_one_add /-\n-- TODO(Leo): move this lemma, or delete it after we add algebraic normalizer.\ntheorem Nat.zero_lt_one_add (a : Nat) : 0 < 1 + a :=\n  suffices 0 < a + 1 by\n    simp [Nat.add_comm]\n    assumption\n  Nat.zero_lt_succ _\n#align nat.zero_lt_one_add Nat.zero_lt_one_add\n-/\n\n#print Nat.lt_add_right /-\n-- TODO(Leo): move this lemma, or delete it after we add algebraic normalizer.\ntheorem Nat.lt_add_right (a b c : Nat) : a < b → a < b + c := fun h =>\n  lt_of_lt_of_le h (Nat.le_add_right _ _)\n#align nat.lt_add_right Nat.lt_add_right\n-/\n\n#print Nat.lt_add_left /-\n-- TODO(Leo): move this lemma, or delete it after we add algebraic normalizer.\ntheorem Nat.lt_add_left (a b c : Nat) : a < b → a < c + b := fun h =>\n  lt_of_lt_of_le h (Nat.le_add_left _ _)\n#align nat.lt_add_left Nat.lt_add_left\n-/\n\nprotected def PSum.Alt.sizeof.{u, v} {α : Type u} {β : Type v} [SizeOf α] [SizeOf β] : PSum α β → ℕ\n  | PSum.inl a => SizeOf.sizeOf a\n  | PSum.inr b => SizeOf.sizeOf b\n#align psum.alt.sizeof PSum.Alt.sizeof\n\n@[reducible]\nprotected def PSum.hasSizeofAlt.{u, v} (α : Type u) (β : Type v) [SizeOf α] [SizeOf β] :\n    SizeOf (PSum α β) :=\n  ⟨PSum.Alt.sizeof⟩\n#align psum.has_sizeof_alt PSum.hasSizeofAlt\n\nnamespace WellFoundedTactics\n\nopen Tactic\n\ndef IdTag.wf : Unit :=\n  ()\n#align well_founded_tactics.id_tag.wf WellFoundedTactics.IdTag.wf\n\nunsafe def mk_alt_sizeof : expr → expr\n  | expr.app (expr.app (expr.app (expr.app (expr.const `` PSum.hasSizeof l) α) β) iα) iβ =>\n    (expr.const `` PSum.hasSizeofAlt l : expr) α β iα (mk_alt_sizeof iβ)\n  | e => e\n#align well_founded_tactics.mk_alt_sizeof well_founded_tactics.mk_alt_sizeof\n\nunsafe def default_rel_tac (e : expr) (eqns : List expr) : tactic Unit := do\n  let tgt ← target\n  let rel ← mk_instance tgt\n  exact <|\n      match e, Rel with\n      | expr.local_const _ (Name.mk_string \"_mutual\" _) _ _,\n        expr.app (e@q(@hasWellFoundedOfHasSizeof _)) sz => e (mk_alt_sizeof sz)\n      | _, _ => Rel\n#align well_founded_tactics.default_rel_tac well_founded_tactics.default_rel_tac\n\nprivate unsafe def clear_wf_rec_goal_aux : List expr → tactic Unit\n  | [] => return ()\n  | h :: hs =>\n    clear_wf_rec_goal_aux hs >>\n      try (guard (h.local_pp_name.is_internal || h.is_aux_decl) >> clear h)\n#align well_founded_tactics.clear_wf_rec_goal_aux well_founded_tactics.clear_wf_rec_goal_aux\n\nunsafe def clear_internals : tactic Unit :=\n  local_context >>= clear_wf_rec_goal_aux\n#align well_founded_tactics.clear_internals well_founded_tactics.clear_internals\n\nunsafe def unfold_wf_rel : tactic Unit :=\n  dunfold_target [`` WellFoundedRelation.R] { failIfUnchanged := false }\n#align well_founded_tactics.unfold_wf_rel well_founded_tactics.unfold_wf_rel\n\nunsafe def is_psigma_mk : expr → tactic (expr × expr)\n  | q(PSigma.mk $(a) $(b)) => return (a, b)\n  | _ => failed\n#align well_founded_tactics.is_psigma_mk well_founded_tactics.is_psigma_mk\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\nunsafe def process_lex : tactic Unit → tactic Unit\n  | tac => do\n    let t ← target >>= whnf\n    if t `psigma.lex 6 then\n        let a := t\n        let b := t\n        do\n        let (a₁, a₂) ← is_psigma_mk a\n        let (b₁, b₂) ← is_psigma_mk b\n        (is_def_eq a₁ b₁ >> sorry) >> process_lex tac <|> sorry >> tac\n      else tac\n#align well_founded_tactics.process_lex well_founded_tactics.process_lex\n\nprivate unsafe def unfold_sizeof_measure : tactic Unit :=\n  dunfold_target [`` SizeofMeasure, `` Measure, `` InvImage] { failIfUnchanged := false }\n#align well_founded_tactics.unfold_sizeof_measure well_founded_tactics.unfold_sizeof_measure\n\nprivate unsafe def add_simps : simp_lemmas → List Name → tactic simp_lemmas\n  | s, [] => return s\n  | s, n :: ns => do\n    let s' ← s.add_simp n false\n    add_simps s' ns\n#align well_founded_tactics.add_simps well_founded_tactics.add_simps\n\nprivate unsafe def collect_sizeof_lemmas (e : expr) : tactic simp_lemmas :=\n  e.mfold simp_lemmas.mk fun c d s =>\n    if c.is_constant then\n      match c.const_name with\n      | Name.mk_string \"sizeof\" p => do\n        let eqns ← get_eqn_lemmas_for true c.const_name\n        add_simps s eqns\n      | _ => return s\n    else return s\n#align well_founded_tactics.collect_sizeof_lemmas well_founded_tactics.collect_sizeof_lemmas\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\nprivate unsafe def unfold_sizeof_loop : tactic Unit := do\n  dunfold_target [`` SizeOf.sizeOf, `` SizeOf.sizeOf] { failIfUnchanged := ff }\n  let S ← target >>= collect_sizeof_lemmas\n  simp_target S >> unfold_sizeof_loop <|> try sorry\n#align well_founded_tactics.unfold_sizeof_loop well_founded_tactics.unfold_sizeof_loop\n\nunsafe def unfold_sizeof : tactic Unit :=\n  unfold_sizeof_measure >> unfold_sizeof_loop\n#align well_founded_tactics.unfold_sizeof well_founded_tactics.unfold_sizeof\n\n/- The following section should be removed as soon as we implement the\n   algebraic normalizer. -/\nsection SimpleDecTac\n\nopen Tactic Expr\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\nprivate unsafe\n  def\n    collect_add_args\n    : expr → List expr\n    | q( $ ( a ) + $ ( b ) ) => collect_add_args a ++ collect_add_args b | e => [ e ]\n#align well_founded_tactics.collect_add_args well_founded_tactics.collect_add_args\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\nprivate unsafe\n  def\n    mk_nat_add\n    : List expr → tactic expr\n    | [ ] => to_expr ` `( 0 )\n      | [ a ] => return a\n      | a :: as => do let rs ← mk_nat_add as to_expr ` `( $ ( a ) + $ ( rs ) )\n#align well_founded_tactics.mk_nat_add well_founded_tactics.mk_nat_add\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\nprivate unsafe\n  def\n    mk_nat_add_add\n    : List expr → List expr → tactic expr\n    | [ ] , b => mk_nat_add b\n      | a , [ ] => mk_nat_add a\n      | a , b => do let t ← mk_nat_add a let s ← mk_nat_add b to_expr ` `( $ ( t ) + $ ( s ) )\n#align well_founded_tactics.mk_nat_add_add well_founded_tactics.mk_nat_add_add\n\nprivate unsafe def get_add_fn (e : expr) : expr :=\n  if is_napp_of e `has_add.add 4 then e.app_fn.app_fn else e\n#align well_founded_tactics.get_add_fn well_founded_tactics.get_add_fn\n\nprivate unsafe def prove_eq_by_perm (a b : expr) : tactic expr :=\n  is_def_eq a b >> to_expr ``(Eq.refl $(a)) <|>\n    perm_ac (get_add_fn a) q(Nat.add_assoc) q(Nat.add_comm) a b\n#align well_founded_tactics.prove_eq_by_perm well_founded_tactics.prove_eq_by_perm\n\nprivate unsafe def num_small_lt (a b : expr) : Bool :=\n  if a = b then false\n  else\n    if is_napp_of a `has_one.one 2 then true\n    else if is_napp_of b `has_one.one 2 then false else a.lt b\n#align well_founded_tactics.num_small_lt well_founded_tactics.num_small_lt\n\nprivate unsafe def sort_args (args : List expr) : List expr :=\n  args.qsort num_small_lt\n#align well_founded_tactics.sort_args well_founded_tactics.sort_args\n\nprivate def tagged_proof.wf : Unit :=\n  ()\n#align well_founded_tactics.tagged_proof.wf well_founded_tactics.tagged_proof.wf\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n-- failed to format: unknown constant 'term.pseudo.antiquot'\nunsafe\n  def\n    cancel_nat_add_lt\n    : tactic Unit\n    :=\n      do\n        let q( $ ( lhs ) < $ ( rhs ) ) ← target\n          let ty ← infer_type lhs >>= whnf\n          guard ( ty = q( Nat ) )\n          let lhs_args := collect_add_args lhs\n          let rhs_args := collect_add_args rhs\n          let common := lhs_args . bagInterₓ rhs_args\n          if\n            common = [ ]\n            then\n            return ( )\n            else\n            do\n              let lhs_rest := lhs_args common\n                let rhs_rest := rhs_args common\n                let new_lhs ← mk_nat_add_add common ( sort_args lhs_rest )\n                let new_rhs ← mk_nat_add_add common ( sort_args rhs_rest )\n                let lhs_pr ← prove_eq_by_perm lhs new_lhs\n                let rhs_pr ← prove_eq_by_perm rhs new_rhs\n                let\n                  target_pr ← to_expr ` `( congr ( congr_arg ( · < · ) $ ( lhs_pr ) ) $ ( rhs_pr ) )\n                let new_target ← to_expr ` `( $ ( new_lhs ) < $ ( new_rhs ) )\n                replace_target new_target target_pr ` ` id_tag.wf\n                sorry <|> sorry\n#align well_founded_tactics.cancel_nat_add_lt well_founded_tactics.cancel_nat_add_lt\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\nunsafe\n  def check_target_is_value_lt : tactic Unit := do let q( $ ( lhs ) < $ ( rhs ) ) ← target guard lhs\n#align well_founded_tactics.check_target_is_value_lt well_founded_tactics.check_target_is_value_lt\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\nunsafe def trivial_nat_lt : tactic Unit :=\n  comp_val <|>\n    sorry <|>\n      sorry <|>\n        assumption <|>\n          (do\n              check_target_is_value_lt\n              sorry >> trivial_nat_lt <|> sorry >> trivial_nat_lt) <|>\n            failed\n#align well_founded_tactics.trivial_nat_lt well_founded_tactics.trivial_nat_lt\n\nend SimpleDecTac\n\nunsafe def default_dec_tac : tactic Unit :=\n  abstract do\n    clear_internals\n    unfold_wf_rel\n    -- The next line was adapted from code in mathlib by Scott Morrison.\n          -- Because `unfold_sizeof` could actually discharge the goal, add a test\n          -- using `done` to detect this.\n          process_lex\n          (unfold_sizeof >>\n            (done <|>\n              cancel_nat_add_lt >>\n                trivial_nat_lt)) <|>-- Clean up the goal state but not too much before printing the error\n          unfold_sizeof >>\n          fail \"default_dec_tac failed\"\n#align well_founded_tactics.default_dec_tac well_founded_tactics.default_dec_tac\n\nend WellFoundedTactics\n\n/-- Argument for using_well_founded\n\n  The tactic `rel_tac` has to synthesize an element of type (has_well_founded A).\n  The two arguments are: a local representing the function being defined by well\n  founded recursion, and a list of recursive equations.\n  The equations can be used to decide which well founded relation should be used.\n\n  The tactic `dec_tac` has to synthesize decreasing proofs.\n-/\nunsafe structure well_founded_tactics where\n  rel_tac : expr → List expr → tactic Unit := well_founded_tactics.default_rel_tac\n  dec_tac : tactic Unit := well_founded_tactics.default_dec_tac\n#align well_founded_tactics well_founded_tactics\n\nunsafe def well_founded_tactics.default : well_founded_tactics where\n#align well_founded_tactics.default well_founded_tactics.default\n\n", "meta": {"author": "leanprover-community", "repo": "lean3port", "sha": "9ed1898f23e4379865ee93d62cb6353e5ed6c270", "save_path": "github-repos/lean/leanprover-community-lean3port", "path": "github-repos/lean/leanprover-community-lean3port/lean3port-9ed1898f23e4379865ee93d62cb6353e5ed6c270/Leanbin/Init/Meta/WellFoundedTactics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.49777432549844086}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport algebra.big_operators.multiset.basic\n\n/-!\n# Bind operation for multisets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines a few basic operations on `multiset`, notably the monadic bind.\n\n## Main declarations\n\n* `multiset.join`: The join, aka union or sum, of multisets.\n* `multiset.bind`: The bind of a multiset-indexed family of multisets.\n* `multiset.product`: Cartesian product of two multisets.\n* `multiset.sigma`: Disjoint sum of multisets in a sigma type.\n-/\n\nvariables {α β γ δ : Type*}\n\nnamespace multiset\n\n/-! ### Join -/\n\n/-- `join S`, where `S` is a multiset of multisets, is the lift of the list join\n  operation, that is, the union of all the sets.\n     join {{1, 2}, {1, 2}, {0, 1}} = {0, 1, 1, 1, 2, 2} -/\ndef join : multiset (multiset α) → multiset α := sum\n\nlemma coe_join : ∀ L : list (list α),\n  join (L.map (@coe _ (multiset α) _) : multiset (multiset α)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (λ s : multiset α, ↑l + s) (coe_join L)\n\n@[simp] \n\n@[simp] lemma mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s :=\nmultiset.induction_on S (by simp) $\n  by simp [or_and_distrib_right, exists_or_distrib] {contextual := tt}\n\n@[simp] lemma card_join (S) : card (@join α S) = sum (map card S) :=\nmultiset.induction_on S (by simp) (by simp)\n\nlemma rel_join {r : α → β → Prop} {s t} (h : rel (rel r) s t) : rel r s.join t.join :=\nbegin\n  induction h,\n  case rel.zero { simp },\n  case rel.cons : a b s t hab hst ih { simpa using hab.add ih }\nend\n\n/-! ### Bind -/\n\nsection bind\nvariables (a : α) (s t : multiset α) (f g : α → multiset β)\n\n/-- `s.bind f` is the monad bind operation, defined as `(s.map f).join`. It is the union of `f a` as\n`a` ranges over `s`. -/\ndef bind (s : multiset α) (f : α → multiset β) : multiset β := (s.map f).join\n\n@[simp] lemma coe_bind (l : list α) (f : α → list β) : @bind α β l (λ a, f a) = l.bind f :=\nby rw [list.bind, ←coe_join, list.map_map]; refl\n\n@[simp] lemma zero_bind : bind 0 f = 0 := rfl\n@[simp] lemma cons_bind : (a ::ₘ s).bind f = f a + s.bind f := by simp [bind]\n@[simp] lemma singleton_bind : bind {a} f = f a := by simp [bind]\n@[simp] lemma add_bind : (s + t).bind f = s.bind f + t.bind f := by simp [bind]\n@[simp] lemma bind_zero : s.bind (λ a, 0 : α → multiset β) = 0 := by simp [bind, join, nsmul_zero]\n@[simp] lemma bind_add : s.bind (λ a, f a + g a) = s.bind f + s.bind g := by simp [bind, join]\n\n@[simp] lemma bind_cons (f : α → β) (g : α → multiset β) :\n  s.bind (λ a, f a ::ₘ g a) = map f s + s.bind g :=\nmultiset.induction_on s (by simp) (by simp [add_comm, add_left_comm] {contextual := tt})\n\n@[simp] lemma bind_singleton (f : α → β) : s.bind (λ x, ({f x} : multiset β)) = map f s :=\nmultiset.induction_on s (by rw [zero_bind, map_zero]) (by simp [singleton_add])\n\n@[simp] lemma mem_bind {b s} {f : α → multiset β} : b ∈ bind s f ↔ ∃ a ∈ s, b ∈ f a :=\nby simp [bind]; simp [-exists_and_distrib_right, exists_and_distrib_right.symm];\n   rw exists_swap; simp [and_assoc]\n\n@[simp] lemma card_bind : (s.bind f).card = (s.map (card ∘ f)).sum := by simp [bind]\n\nlemma bind_congr {f g : α → multiset β} {m : multiset α} :\n  (∀ a ∈ m, f a = g a) → bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {β' : Type*} {m : multiset α} {f : α → multiset β} {f' : α → multiset β'}\n  (h : β = β') (hf : ∀a ∈ m, f a == f' a) :\n  bind m f == bind m f' :=\nbegin subst h, simp at hf, simp [bind_congr hf] end\n\nlemma map_bind (m : multiset α) (n : α → multiset β) (f : β → γ) :\n  map f (bind m n) = bind m (λ a, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset α) (n : β → multiset γ) (f : α → β) :\n  bind (map f m) n = bind m (λ a, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset α} {f : α → multiset β} {g : β → multiset γ} :\n  (s.bind f).bind g = s.bind (λ a, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset α) (n : multiset β) {f : α → β → multiset γ} :\n  (bind m $ λ a, bind n $ λ b, f a b) = (bind n $ λ b, bind m $ λ a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset α) (n : multiset β) {f : α → β → γ} :\n  (bind m $ λ a, n.map $ λ b, f a b) = (bind n $ λ b, m.map $ λ a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid β] (s : multiset α) (t : α → multiset β) :\n  (s.bind t).prod = (s.map $ λ a, (t a).prod).prod :=\nmultiset.induction_on s (by simp) (assume a s ih, by simp [ih, cons_bind])\n\nlemma rel_bind {r : α → β → Prop} {p : γ → δ → Prop} {s t} {f : α → multiset γ} {g : β → multiset δ}\n  (h : (r ⇒ rel p) f g) (hst : rel r s t) :\n  rel p (s.bind f) (t.bind g) :=\nby { apply rel_join, rw rel_map, exact hst.mono (λ a ha b hb hr, h hr) }\n\nlemma count_sum [decidable_eq α] {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (map f m).sum = sum (m.map $ λ b, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind [decidable_eq α] {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (bind m f) = sum (m.map $ λ b, count a $ f b) := count_sum\n\nlemma le_bind {α β : Type*} {f : α → multiset β} (S : multiset α) {x : α} (hx : x ∈ S) :\n  f x ≤ S.bind f :=\nbegin\n  classical,\n  rw le_iff_count, intro a,\n  rw count_bind, apply le_sum_of_mem,\n  rw mem_map, exact ⟨x, hx, rfl⟩\nend\n\n@[simp] theorem attach_bind_coe (s : multiset α) (f : α → multiset β) :\n  s.attach.bind (λ i, f i) = s.bind f :=\ncongr_arg join $ attach_map_coe' _ _\n\nend bind\n\n/-! ### Product of two multisets -/\n\nsection product\nvariables (a : α) (b : β) (s : multiset α) (t : multiset β)\n\n/-- The multiplicity of `(a, b)` in `s ×ˢ t` is\n  the product of the multiplicity of `a` in `s` and `b` in `t`. -/\ndef product (s : multiset α) (t : multiset β) : multiset (α × β) := s.bind $ λ a, t.map $ prod.mk a\n\n/- This notation binds more strongly than (pre)images, unions and intersections. -/\ninfixr (name := multiset.product) ` ×ˢ `:82 := multiset.product\n\n@[simp] lemma coe_product (l₁ : list α) (l₂ : list β) : @product α β l₁ l₂ = l₁.product l₂ :=\nby { rw [product, list.product, ←coe_bind], simp }\n\n@[simp] lemma zero_product : @product α β 0 t = 0 := rfl\n@[simp] lemma cons_product : (a ::ₘ s) ×ˢ t = map (prod.mk a) t + s ×ˢ t := by simp [product]\n@[simp] lemma product_zero : s ×ˢ (0 : multiset β) = 0 := by simp [product]\n@[simp] lemma product_cons : s ×ˢ (b ::ₘ t) = s.map (λ a, (a, b)) + s ×ˢ t := by simp [product]\n\n@[simp] lemma product_singleton : ({a} : multiset α) ×ˢ ({b} : multiset β) = {(a, b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] lemma add_product (s t : multiset α) (u : multiset β) : (s + t) ×ˢ u = s ×ˢ u + t ×ˢ u :=\nby simp [product]\n\n@[simp] lemma product_add (s : multiset α) : ∀ t u : multiset β, s ×ˢ (t + u) = s ×ˢ t + s ×ˢ u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] lemma mem_product {s t} : ∀ {p : α × β}, p ∈ @product α β s t ↔ p.1 ∈ s ∧ p.2 ∈ t\n| (a, b) := by simp [product, and.left_comm]\n\n@[simp] lemma card_product : (s ×ˢ t).card = s.card * t.card := by simp [product]\n\nend product\n\n/-! ### Disjoint sum of multisets -/\n\nsection sigma\nvariables {σ : α → Type*} (a : α) (s : multiset α) (t : Π a, multiset (σ a))\n\n/-- `sigma s t` is the dependent version of `product`. It is the sum of\n  `(a, b)` as `a` ranges over `s` and `b` ranges over `t a`. -/\nprotected def sigma (s : multiset α) (t : Π a, multiset (σ a)) : multiset (Σ a, σ a) :=\ns.bind $ λ a, (t a).map $ sigma.mk a\n\n@[simp] lemma coe_sigma (l₁ : list α) (l₂ : Π a, list (σ a)) :\n  @multiset.sigma α σ l₁ (λ a, l₂ a) = l₁.sigma l₂ :=\nby rw [multiset.sigma, list.sigma, ←coe_bind]; simp\n\n@[simp] lemma zero_sigma : @multiset.sigma α σ 0 t = 0 := rfl\n\n@[simp] lemma cons_sigma : (a ::ₘ s).sigma t = (t a).map (sigma.mk a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_singleton (b : α → β) :\n  ({a} : multiset α).sigma (λ a, ({b a} : multiset β)) = {⟨a, b a⟩} := rfl\n\n@[simp] lemma add_sigma (s t : multiset α) (u : Π a, multiset (σ a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_add : ∀ t u : Π a, multiset (σ a),\n  s.sigma (λ a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] lemma mem_sigma {s t} : ∀ {p : Σ a, σ a},\n  p ∈ @multiset.sigma α σ s t ↔ p.1 ∈ s ∧ p.2 ∈ t p.1\n| ⟨a, b⟩ := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] lemma card_sigma :\n  card (s.sigma t) = sum (map (λ a, card (t a)) s) :=\nby simp [multiset.sigma, (∘)]\n\nend sigma\nend multiset\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/multiset/bind.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499941, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.4977743254984408}}
{"text": "import .vec_space\nimport group_theory.subgroup\nimport data.finset\nimport algebra.big_operators\nimport algebra.pointwise\n--import ring_theory.polynomial.basic\n\nopen_locale big_operators classical\n\n\nnamespace vec_space\n\nuniverses u v w x\n\nopen subgroup\n\nstructure subspace (F : Type u) (α : Type v) [field F] [add_comm_group α] [vec_space F α] extends add_subgroup α :=\n(smul_mem : ∀ (a : F) {x}, x ∈ carrier → a • x ∈ carrier)\n\nnamespace subspace\n\nvariables (F : Type u) (α : Type v) [field F] [add_comm_group α] [vec_space F α] (β : subspace F α)\n\n--instance : has_coe_t (subspace F β) (set β) := ⟨λ s, s.carrier⟩\ninstance : has_coe (subspace F α) (add_subgroup α) := { coe := subspace.to_add_subgroup }\n\n\n/-instance : has_coe_t (subspace F β) (set β) := ⟨λ s, s.carrier⟩\ninstance : has_mem M (submodule R M) := ⟨λ x p, x ∈ (p : set M)⟩\ninstance : has_coe_to_sort (submodule R M) := ⟨_, λ p, {x : M // x ∈ p}⟩\n\n\ninstance : has_add β := ⟨λx y, ⟨x.1 + y.1, add_mem _ x.2 y.2⟩⟩\ninstance : has_zero p := ⟨⟨0, zero_mem _⟩⟩\ninstance : inhabited p := ⟨0⟩\ninstance : has_scalar R p := ⟨λ c x, ⟨c • x.1, smul_mem _ c x.2⟩⟩-/\n\n/-begin\n    intros a b,\n    refine ⟨a • b, _⟩, \n    exact subspace.smul_mem β a b.2, -- b.2 proving that a thing is a subtype\nend,-/\n\ninstance to_vec_space (F : Type u) (α : Type v) [field F] [add_comm_group α] [vec_space F α](β : subspace F α) : vec_space F β :=\n{ smul := λ a b, ⟨a • b, β.smul_mem a b.2⟩,\n  smul_add := λ r a b, subtype.eq (vec_space.smul_add r a b),\n  add_smul := λ r s a, subtype.eq (vec_space.add_smul r s a),\n  mul_smul := λ r s a, subtype.eq (vec_space.mul_smul r s a),\n  one_smul := λ a, subtype.eq (vec_space.one_smul a) }\n\nlemma sum_mem_sum (S : finset (subspace F α)) (f : subspace F α → α)\n  (hf : ∀ x ∈ S, f x ∈ x.carrier) : \n  (∑ x in S, f x) ∈ (∑ x in S, x : set α) :=\nbegin\n    -- ∀ Uᵢ ∈ {U₁, ..., U_m}, f(x) ∈ Uᵢ\n    -- u₁ + ... + u_m ∈ U₁ + ... + U_m\n    revert hf,\n    apply finset.induction_on S,\n    rw finset.sum_empty,\n    rw finset.sum_empty,\n    intro hyp,\n    exact set.zero_mem_zero,\n    intros β s hyp IH hyp2,\n    rw finset.forall_mem_insert at hyp2,\n    cases hyp2 with hyp2 hyp3,\n    rw finset.sum_insert hyp,\n    rw finset.sum_insert hyp,\n    apply set.add_mem_add,\n    exact hyp2,\n    apply IH,\n    exact hyp3,\n    --sorry,\nend\n\n/-lemma sum_mem_sum' (S : finset (subspace F α)) (u : α)\n  (hu : u ∈ (∑ x in S, x : set α)) : \n  ∃ (f : subspace F α → α), (∀ x ∈ S, f x ∈ x.carrier) ∧ u = (∑ x in S, f x) :=\nbegin -- u ∈ U₁ + ... + U_m then u = ∑ uᵢ for uᵢ ∈ Uᵢ\n-- ∀ Uᵢ, ∃ uᵢ s.t. \n    revert hu,\n    revert u,\n    apply finset.induction_on S,\n    rw finset.sum_empty,\n    --rw finset.sum_empty,\n    intros u hyp3,\n    use λ x, 0,\n    split,\n    intros x hyp2,\n    exact add_subgroup.zero_mem x,\n\n    rw finset.sum_const_zero,\n    rw set.mem_zero at hyp3,\n    exact hyp3,\n\n    intros a s hyp2 IH u hyp3,\n    rw finset.sum_insert hyp2 at hyp3,\n    rw set.mem_add at hyp3,\n    rcases hyp3 with ⟨b, c, hyp3, hyp4, hyp5⟩,\n    specialize IH c hyp4,\n    refine ⟨_, _, _⟩,\n    intro d,\n    use b, -- function that maps a to b\n    --intros x hyp6,\n    intros x hyp7,\n    rw finset.mem_insert,\n    --have hyp7 : if x ∈ s then f x else b,\n    --if x ∈ s then f x else b, if_pos, if_neg\nend-/\n\n\n/-def subspace_sum (S : finset (subspace F α)) : subspace F α := \n{\n  carrier := ∑ x in S, x,\n  --{y | ∃ f : (Π x : subspace F α, x ∈ S → x), (∑ x in S.attach, f x x.2 : α) = y} , \n  -- {u₁ + ... + u_m : u₁ ∈ U₁, ..., u_m ∈ U_m}\n  zero_mem' := \n  begin\n    convert sum_mem_sum F α S (λ x, 0) (λ x hyp, add_subgroup.zero_mem x),\n    rw finset.sum_const_zero,\n  end,\n  add_mem' := λ a b hyp hyp2, _,\n  neg_mem' := _,\n  smul_mem := _ }-/\n\n/-def add (s : finset (subspace F α)) : subspace F α :=\n{y | ∃ (f : Π (i : (↑s : set (subspace F α))), i), y = ∑ x in (↑s : set (subspace F α)), f x}-/\n\nend subspace\n\nend vec_space", "meta": {"author": "agusakov", "repo": "vector_spaces", "sha": "b23954c19b357a689e2a73e07fcf6c9e4a74713a", "save_path": "github-repos/lean/agusakov-vector_spaces", "path": "github-repos/lean/agusakov-vector_spaces/vector_spaces-b23954c19b357a689e2a73e07fcf6c9e4a74713a/src/subspace.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.49777431312542075}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Sébastien Gouëzel, Zhouhang Zhou, Reid Barton\n-/\nimport logic.equiv.fin\nimport topology.dense_embedding\nimport topology.support\n\n/-!\n# Homeomorphisms\n\nThis file defines homeomorphisms between two topological spaces. They are bijections with both\ndirections continuous. We denote homeomorphisms with the notation `≃ₜ`.\n\n# Main definitions\n\n* `homeomorph α β`: The type of homeomorphisms from `α` to `β`.\n  This type can be denoted using the following notation: `α ≃ₜ β`.\n\n# Main results\n\n* Pretty much every topological property is preserved under homeomorphisms.\n* `homeomorph.homeomorph_of_continuous_open`: A continuous bijection that is\n  an open map is a homeomorphism.\n\n-/\n\nopen set filter\nopen_locale topological_space\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\n\n/-- Homeomorphism between `α` and `β`, also called topological isomorphism -/\n@[nolint has_inhabited_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (α : Type*) (β : Type*) [topological_space α] [topological_space β]\n  extends α ≃ β :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` ≃ₜ `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n\ninstance : has_coe_to_fun (α ≃ₜ β) (λ _, α → β) := ⟨λe, e.to_equiv⟩\n\n@[simp] lemma homeomorph_mk_coe (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c) : α → β) = a :=\nrfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : α ≃ₜ β) : β ≃ₜ α :=\n{ continuous_to_fun  := h.continuous_inv_fun,\n  continuous_inv_fun := h.continuous_to_fun,\n  to_equiv := h.to_equiv.symm }\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : α ≃ₜ β) : α → β := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : α ≃ₜ β) : β → α := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply, -to_equiv)\n\n@[simp] lemma coe_to_equiv (h : α ≃ₜ β) : ⇑h.to_equiv = h := rfl\n@[simp] lemma coe_symm_to_equiv (h : α ≃ₜ β) : ⇑h.to_equiv.symm = h.symm := rfl\n\nlemma to_equiv_injective : function.injective (to_equiv : α ≃ₜ β → α ≃ β)\n| ⟨e, h₁, h₂⟩ ⟨e', h₁', h₂'⟩ rfl := rfl\n\n@[ext] lemma ext {h h' : α ≃ₜ β} (H : ∀ x, h x = h' x) : h = h' :=\nto_equiv_injective $ equiv.ext H\n\n/-- Identity map as a homeomorphism. -/\n@[simps apply {fully_applied := ff}]\nprotected def refl (α : Type*) [topological_space α] : α ≃ₜ α :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl α }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) : α ≃ₜ γ :=\n{ continuous_to_fun  := h₂.continuous_to_fun.comp h₁.continuous_to_fun,\n  continuous_inv_fun := h₁.continuous_inv_fun.comp h₂.continuous_inv_fun,\n  to_equiv := equiv.trans h₁.to_equiv h₂.to_equiv }\n\n@[simp] lemma trans_apply (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) (a : α) : h₁.trans h₂ a = h₂ (h₁ a) := rfl\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c).symm : β → α) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl α).symm = homeomorph.refl α := rfl\n\n@[continuity]\nprotected lemma continuous (h : α ≃ₜ β) : continuous h := h.continuous_to_fun\n\n@[continuity] -- otherwise `by continuity` can't prove continuity of `h.to_equiv.symm`\nprotected lemma continuous_symm (h : α ≃ₜ β) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : α ≃ₜ β) (x : β) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : α ≃ₜ β) (x : α) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : α ≃ₜ β) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : α ≃ₜ β) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : α ≃ₜ β) : function.surjective h := h.to_equiv.surjective\n\n/-- Change the homeomorphism `f` to make the inverse function definitionally equal to `g`. -/\ndef change_inv (f : α ≃ₜ β) (g : β → α) (hg : function.right_inverse g f) : α ≃ₜ β :=\nhave g = f.symm, from funext (λ x, calc g x = f.symm (f (g x)) : (f.left_inv (g x)).symm\n                                        ... = f.symm x : by rw hg x),\n{ to_fun := f,\n  inv_fun := g,\n  left_inv := by convert f.left_inv,\n  right_inv := by convert f.right_inv,\n  continuous_to_fun := f.continuous,\n  continuous_inv_fun := by convert f.symm.continuous }\n\n@[simp] lemma symm_comp_self (h : α ≃ₜ β) : ⇑h.symm ∘ ⇑h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : α ≃ₜ β) : ⇑h ∘ ⇑h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : α ≃ₜ β) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : α ≃ₜ β) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : α ≃ₜ β) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : α ≃ₜ β) (s : set β) : h '' (h ⁻¹' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : α ≃ₜ β) (s : set α) : h ⁻¹' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : α ≃ₜ β) : inducing h :=\ninducing_of_inducing_compose h.continuous h.symm.continuous $\n  by simp only [symm_comp_self, inducing_id]\n\nlemma induced_eq (h : α ≃ₜ β) : topological_space.induced h ‹_› = ‹_› := h.inducing.1.symm\n\nprotected lemma quotient_map (h : α ≃ₜ β) : quotient_map h :=\nquotient_map.of_quotient_map_compose h.symm.continuous h.continuous $\n  by simp only [self_comp_symm, quotient_map.id]\n\nlemma coinduced_eq (h : α ≃ₜ β) : topological_space.coinduced h ‹_› = ‹_› :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : α ≃ₜ β) : embedding h :=\n⟨h.inducing, h.injective⟩\n\n/-- Homeomorphism given an embedding. -/\nnoncomputable def of_embedding (f : α → β) (hf : embedding f) : α ≃ₜ (set.range f) :=\n{ continuous_to_fun := continuous_subtype_mk _ hf.continuous,\n  continuous_inv_fun := by simp [hf.continuous_iff, continuous_subtype_coe],\n  .. equiv.of_injective f hf.inj }\n\nprotected lemma second_countable_topology [topological_space.second_countable_topology β]\n  (h : α ≃ₜ β) :\n  topological_space.second_countable_topology α :=\nh.inducing.second_countable_topology\n\nlemma compact_image {s : set α} (h : α ≃ₜ β) : is_compact (h '' s) ↔ is_compact s :=\nh.embedding.is_compact_iff_is_compact_image.symm\n\nlemma compact_preimage {s : set β} (h : α ≃ₜ β) : is_compact (h ⁻¹' s) ↔ is_compact s :=\nby rw ← image_symm; exact h.symm.compact_image\n\n@[simp] lemma comap_cocompact (h : α ≃ₜ β) : comap h (cocompact β) = cocompact α :=\n(comap_cocompact_le h.continuous).antisymm $\n  (has_basis_cocompact.le_basis_iff (has_basis_cocompact.comap h)).2 $ λ K hK,\n    ⟨h ⁻¹' K, h.compact_preimage.2 hK, subset.rfl⟩\n\n@[simp] lemma map_cocompact (h : α ≃ₜ β) : map h (cocompact α) = cocompact β :=\nby rw [← h.comap_cocompact, map_comap_of_surjective h.surjective]\n\nprotected lemma compact_space [compact_space α] (h : α ≃ₜ β) : compact_space β :=\n{ compact_univ := by { rw [← image_univ_of_surjective h.surjective, h.compact_image],\n    apply compact_space.compact_univ } }\n\nprotected lemma t0_space [t0_space α] (h : α ≃ₜ β) : t0_space β :=\nh.symm.embedding.t0_space\n\nprotected lemma t1_space [t1_space α] (h : α ≃ₜ β) : t1_space β :=\nh.symm.embedding.t1_space\n\nprotected lemma t2_space [t2_space α] (h : α ≃ₜ β) : t2_space β :=\nh.symm.embedding.t2_space\n\nprotected lemma regular_space [regular_space α] (h : α ≃ₜ β) : regular_space β :=\nh.symm.embedding.regular_space\n\nprotected lemma dense_embedding (h : α ≃ₜ β) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : α ≃ₜ β) {s : set β} : is_open (h ⁻¹' s) ↔ is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : α ≃ₜ β) {s : set α} : is_open (h '' s) ↔ is_open s :=\nby rw [← preimage_symm, is_open_preimage]\n\nprotected lemma is_open_map (h : α ≃ₜ β) : is_open_map h := λ s, h.is_open_image.2\n\n@[simp] lemma is_closed_preimage (h : α ≃ₜ β) {s : set β} : is_closed (h ⁻¹' s) ↔ is_closed s :=\nby simp only [← is_open_compl_iff, ← preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : α ≃ₜ β) {s : set α} : is_closed (h '' s) ↔ is_closed s :=\nby rw [← preimage_symm, is_closed_preimage]\n\nprotected lemma is_closed_map (h : α ≃ₜ β) : is_closed_map h := λ s, h.is_closed_image.2\n\nprotected lemma open_embedding (h : α ≃ₜ β) : open_embedding h :=\nopen_embedding_of_embedding_open h.embedding h.is_open_map\n\nprotected lemma closed_embedding (h : α ≃ₜ β) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\nprotected lemma normal_space [normal_space α] (h : α ≃ₜ β) : normal_space β :=\nh.symm.closed_embedding.normal_space\n\nlemma preimage_closure (h : α ≃ₜ β) (s : set β) : h ⁻¹' (closure s) = closure (h ⁻¹' s) :=\nh.is_open_map.preimage_closure_eq_closure_preimage h.continuous _\n\nlemma image_closure (h : α ≃ₜ β) (s : set α) : h '' (closure s) = closure (h '' s) :=\nby rw [← preimage_symm, preimage_closure]\n\n\n\nlemma image_interior (h : α ≃ₜ β) (s : set α) : h '' (interior s) = interior (h '' s) :=\nby rw [← preimage_symm, preimage_interior]\n\nlemma preimage_frontier (h : α ≃ₜ β) (s : set β) : h ⁻¹' (frontier s) = frontier (h ⁻¹' s) :=\nh.is_open_map.preimage_frontier_eq_frontier_preimage h.continuous _\n\n@[to_additive]\nlemma _root_.has_compact_mul_support.comp_homeomorph {M} [has_one M] {f : β → M}\n  (hf : has_compact_mul_support f) (φ : α ≃ₜ β) : has_compact_mul_support (f ∘ φ) :=\nhf.comp_closed_embedding φ.closed_embedding\n\n@[simp] lemma map_nhds_eq (h : α ≃ₜ β) (x : α) : map h (𝓝 x) = 𝓝 (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : α ≃ₜ β) (x : α) : map h.symm (𝓝 (h x)) = 𝓝 x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : α ≃ₜ β) (x : α) : 𝓝 x = comap h (𝓝 (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : α ≃ₜ β) (y : β) : comap h (𝓝 y) = 𝓝 (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : α ≃ β` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : α ≃ β) (h₁ : continuous e) (h₂ : is_open_map e) :\n  α ≃ₜ β :=\n{ continuous_to_fun := h₁,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert ← h₂ s hs using 1,\n    apply e.image_eq_preimage\n  end,\n  to_equiv := e }\n\n@[simp] lemma comp_continuous_on_iff (h : α ≃ₜ β) (f : γ → α) (s : set γ) :\n  continuous_on (h ∘ f) s ↔ continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : α ≃ₜ β) {f : γ → α} :\n  continuous (h ∘ f) ↔ continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : α ≃ₜ β) {f : β → γ} :\n  continuous (f ∘ h) ↔ continuous f :=\nh.quotient_map.continuous_iff.symm\n\nlemma comp_continuous_at_iff (h : α ≃ₜ β) (f : γ → α) (x : γ) :\n  continuous_at (h ∘ f) x ↔ continuous_at f x :=\nh.inducing.continuous_at_iff.symm\n\nlemma comp_continuous_at_iff' (h : α ≃ₜ β) (f : β → γ) (x : α) :\n  continuous_at (f ∘ h) x ↔ continuous_at f (h x) :=\nh.inducing.continuous_at_iff' (by simp)\n\nlemma comp_continuous_within_at_iff (h : α ≃ₜ β) (f : γ → α) (s : set γ) (x : γ) :\n  continuous_within_at f s x ↔ continuous_within_at (h ∘ f) s x :=\nh.inducing.continuous_within_at_iff\n\n@[simp] lemma comp_is_open_map_iff (h : α ≃ₜ β) {f : γ → α} :\n  is_open_map (h ∘ f) ↔ is_open_map f :=\nbegin\n  refine ⟨_, λ hf, h.is_open_map.comp hf⟩,\n  intros hf,\n  rw [← function.comp.left_id f, ← h.symm_comp_self, function.comp.assoc],\n  exact h.symm.is_open_map.comp hf,\nend\n\n@[simp] lemma comp_is_open_map_iff' (h : α ≃ₜ β) {f : β → γ} :\n  is_open_map (f ∘ h) ↔ is_open_map f :=\nbegin\n  refine ⟨_, λ hf, hf.comp h.is_open_map⟩,\n  intros hf,\n  rw [← function.comp.right_id f, ← h.self_comp_symm, ← function.comp.assoc],\n  exact hf.comp h.symm.is_open_map,\nend\n\n/-- If two sets are equal, then they are homeomorphic. -/\ndef set_congr {s t : set α} (h : s = t) : s ≃ₜ t :=\n{ continuous_to_fun := continuous_subtype_mk _ continuous_subtype_val,\n  continuous_inv_fun := continuous_subtype_mk _ continuous_subtype_val,\n  to_equiv := equiv.set_congr h }\n\n/-- Sum of two homeomorphisms. -/\ndef sum_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α ⊕ γ ≃ₜ β ⊕ δ :=\n{ continuous_to_fun  :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h₁.continuous)\n      (continuous_inr.comp h₂.continuous),\n    ext x, cases x; refl,\n  end,\n  continuous_inv_fun :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h₁.symm.continuous)\n      (continuous_inr.comp h₂.symm.continuous),\n    ext x, cases x; refl\n  end,\n  to_equiv := h₁.to_equiv.sum_congr h₂.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α × γ ≃ₜ β × δ :=\n{ continuous_to_fun  := (h₁.continuous.comp continuous_fst).prod_mk\n    (h₂.continuous.comp continuous_snd),\n  continuous_inv_fun := (h₁.symm.continuous.comp continuous_fst).prod_mk\n    (h₂.symm.continuous.comp continuous_snd),\n  to_equiv := h₁.to_equiv.prod_congr h₂.to_equiv }\n\n@[simp] lemma prod_congr_symm (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  (h₁.prod_congr h₂).symm = h₁.symm.prod_congr h₂.symm := rfl\n\n@[simp] lemma coe_prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  ⇑(h₁.prod_congr h₂) = prod.map h₁ h₂ := rfl\n\nsection\nvariables (α β γ)\n\n/-- `α × β` is homeomorphic to `β × α`. -/\ndef prod_comm : α × β ≃ₜ β × α :=\n{ continuous_to_fun  := continuous_snd.prod_mk continuous_fst,\n  continuous_inv_fun := continuous_snd.prod_mk continuous_fst,\n  to_equiv := equiv.prod_comm α β }\n\n@[simp] lemma prod_comm_symm : (prod_comm α β).symm = prod_comm β α := rfl\n@[simp] lemma coe_prod_comm : ⇑(prod_comm α β) = prod.swap := rfl\n\n/-- `(α × β) × γ` is homeomorphic to `α × (β × γ)`. -/\ndef prod_assoc : (α × β) × γ ≃ₜ α × (β × γ) :=\n{ continuous_to_fun  := (continuous_fst.comp continuous_fst).prod_mk\n    ((continuous_snd.comp continuous_fst).prod_mk continuous_snd),\n  continuous_inv_fun := (continuous_fst.prod_mk (continuous_fst.comp continuous_snd)).prod_mk\n    (continuous_snd.comp continuous_snd),\n  to_equiv := equiv.prod_assoc α β γ }\n\n/-- `α × {*}` is homeomorphic to `α`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : α × punit ≃ₜ α :=\n{ to_equiv := equiv.prod_punit α,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} × α` is homeomorphic to `α`. -/\ndef punit_prod : punit × α ≃ₜ α :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : ⇑(punit_prod α) = prod.snd := rfl\n\nend\n\n/-- `ulift α` is homeomorphic to `α`. -/\ndef {u v} ulift {α : Type u} [topological_space α] : ulift.{v u} α ≃ₜ α :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(α ⊕ β) × γ` is homeomorphic to `α × γ ⊕ β × γ`. -/\ndef sum_prod_distrib : (α ⊕ β) × γ ≃ₜ α × γ ⊕ β × γ :=\nbegin\n  refine (homeomorph.homeomorph_of_continuous_open (equiv.sum_prod_distrib α β γ).symm _ _).symm,\n  { convert continuous_sum_rec\n      ((continuous_inl.comp continuous_fst).prod_mk continuous_snd)\n      ((continuous_inr.comp continuous_fst).prod_mk continuous_snd),\n    ext1 x, cases x; refl, },\n  { exact (is_open_map_sum\n    (open_embedding_inl.prod open_embedding_id).is_open_map\n    (open_embedding_inr.prod open_embedding_id).is_open_map) }\nend\n\n/-- `α × (β ⊕ γ)` is homeomorphic to `α × β ⊕ α × γ`. -/\ndef prod_sum_distrib : α × (β ⊕ γ) ≃ₜ α × β ⊕ α × γ :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {ι : Type*} {σ : ι → Type*} [Π i, topological_space (σ i)]\n\n/-- `(Σ i, σ i) × β` is homeomorphic to `Σ i, (σ i × β)`. -/\ndef sigma_prod_distrib : ((Σ i, σ i) × β) ≃ₜ (Σ i, (σ i × β)) :=\nhomeomorph.symm $\nhomeomorph_of_continuous_open (equiv.sigma_prod_distrib σ β).symm\n  (continuous_sigma $ λ i,\n    (continuous_sigma_mk.comp continuous_fst).prod_mk continuous_snd)\n  (is_open_map_sigma $ λ i,\n    (open_embedding_sigma_mk.prod open_embedding_id).is_open_map)\n\nend distrib\n\n/-- If `ι` has a unique element, then `ι → α` is homeomorphic to `α`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (ι α : Type*) [unique ι] [topological_space α] : (ι → α) ≃ₜ α :=\n{ to_equiv := equiv.fun_unique ι α,\n  continuous_to_fun := continuous_apply _,\n  continuous_inv_fun := continuous_pi (λ _, continuous_id) }\n\n/-- Homeomorphism between dependent functions `Π i : fin 2, α i` and `α 0 × α 1`. -/\n@[simps { fully_applied := ff }]\ndef {u} pi_fin_two (α : fin 2 → Type u) [Π i, topological_space (α i)] : (Π i, α i) ≃ₜ α 0 × α 1 :=\n{ to_equiv := pi_fin_two_equiv α,\n  continuous_to_fun := (continuous_apply 0).prod_mk (continuous_apply 1),\n  continuous_inv_fun := continuous_pi $ fin.forall_fin_two.2 ⟨continuous_fst, continuous_snd⟩ }\n\n/-- Homeomorphism between `α² = fin 2 → α` and `α × α`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 → α) ≃ₜ α × α :=\n{ to_equiv := fin_two_arrow_equiv α, ..  pi_fin_two (λ _, α) }\n\n/--\nA subset of a topological space is homeomorphic to its image under a homeomorphism.\n-/\n@[simps] def image (e : α ≃ₜ β) (s : set α) : s ≃ₜ e '' s :=\n{ continuous_to_fun := by continuity!,\n  continuous_inv_fun := by continuity!,\n  to_equiv := e.to_equiv.image s, }\n\n/-- `set.univ α` is homeomorphic to `α`. -/\n@[simps { fully_applied := ff }]\ndef set.univ (α : Type*) [topological_space α] : (univ : set α) ≃ₜ α :=\n{ to_equiv := equiv.set.univ α,\n  continuous_to_fun := continuous_subtype_coe,\n  continuous_inv_fun := continuous_subtype_mk _ continuous_id }\n\nend homeomorph\n\n/-- An inducing equiv between topological spaces is a homeomorphism. -/\n@[simps] def equiv.to_homeomorph_of_inducing [topological_space α] [topological_space β] (f : α ≃ β)\n  (hf : inducing f) :\n  α ≃ₜ β :=\n{ continuous_to_fun := hf.continuous,\n  continuous_inv_fun := hf.continuous_iff.2 $ by simpa using continuous_id,\n  .. f }\n\nnamespace continuous\nvariables [topological_space α] [topological_space β]\n\nlemma continuous_symm_of_equiv_compact_to_t2 [compact_space α] [t2_space β]\n  {f : α ≃ β} (hf : continuous f) : continuous f.symm :=\nbegin\n  rw continuous_iff_is_closed,\n  intros C hC,\n  have hC' : is_closed (f '' C) := (hC.is_compact.image hf).is_closed,\n  rwa equiv.image_eq_preimage at hC',\nend\n\n/-- Continuous equivalences from a compact space to a T2 space are homeomorphisms.\n\nThis is not true when T2 is weakened to T1\n(see `continuous.homeo_of_equiv_compact_to_t2.t1_counterexample`). -/\n@[simps]\ndef homeo_of_equiv_compact_to_t2 [compact_space α] [t2_space β]\n  {f : α ≃ β} (hf : continuous f) : α ≃ₜ β :=\n{ continuous_to_fun := hf,\n  continuous_inv_fun := hf.continuous_symm_of_equiv_compact_to_t2,\n  ..f }\n\nend continuous\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/topology/homeomorph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.4977286584323719}}
{"text": "/-\nCopyright (c) 2022 Joachim Breitner. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joachim Breitner\n-/\nimport group_theory.order_of_element\nimport data.finset.noncomm_prod\nimport data.fintype.big_operators\nimport data.nat.gcd.big_operators\nimport order.sup_indep\n\n/-!\n# Canonical homomorphism from a finite family of monoids\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the construction of the canonical homomorphism from a family of monoids.\n\nGiven a family of morphisms `ϕ i : N i →* M` for each `i : ι` where elements in the\nimages of different morphisms commute, we obtain a canonical morphism\n`monoid_hom.noncomm_pi_coprod : (Π i, N i) →* M` that coincides with `ϕ`\n\n## Main definitions\n\n* `monoid_hom.noncomm_pi_coprod : (Π i, N i) →* M` is the main homomorphism\n* `subgroup.noncomm_pi_coprod : (Π i, H i) →* G` is the specialization to `H i : subgroup G`\n   and the subgroup embedding.\n\n## Main theorems\n\n* `monoid_hom.noncomm_pi_coprod` coincides with `ϕ i` when restricted to `N i`\n* `monoid_hom.noncomm_pi_coprod_mrange`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `⨆ (i : ι), (ϕ i).mrange`\n* `monoid_hom.noncomm_pi_coprod_range`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `⨆ (i : ι), (ϕ i).range`\n* `subgroup.noncomm_pi_coprod_range`: The range of `subgroup.noncomm_pi_coprod` is `⨆ (i : ι), H i`.\n* `monoid_hom.injective_noncomm_pi_coprod_of_independent`: in the case of groups, `pi_hom.hom` is\n   injective if the `ϕ` are injective and the ranges of the `ϕ` are independent.\n* `monoid_hom.independent_range_of_coprime_order`: If the `N i` have coprime orders, then the ranges\n   of the `ϕ` are independent.\n* `subgroup.independent_of_coprime_order`: If commuting normal subgroups `H i` have coprime orders,\n   they are independent.\n\n-/\n\nopen_locale big_operators\n\nnamespace subgroup\n\nvariables {G : Type*} [group G]\n\n/-- `finset.noncomm_prod` is “injective” in `f` if `f` maps into independent subgroups.  This\ngeneralizes (one direction of) `subgroup.disjoint_iff_mul_eq_one`. -/\n@[to_additive \"`finset.noncomm_sum` is “injective” in `f` if `f` maps into independent subgroups.\nThis generalizes (one direction of) `add_subgroup.disjoint_iff_add_eq_zero`. \"]\nlemma eq_one_of_noncomm_prod_eq_one_of_independent {ι : Type*} (s : finset ι) (f : ι → G) (comm)\n  (K : ι → subgroup G) (hind : complete_lattice.independent K) (hmem : ∀ (x ∈ s), f x ∈ K x)\n  (heq1 : s.noncomm_prod f comm = 1) : ∀ (i ∈ s), f i = 1 :=\nbegin\n  classical,\n  revert heq1,\n  induction s using finset.induction_on with i s hnmem ih,\n  { simp, },\n  { have hcomm := comm.mono (finset.coe_subset.2 $ finset.subset_insert _ _),\n    simp only [finset.forall_mem_insert] at hmem,\n    have hmem_bsupr: s.noncomm_prod f hcomm ∈ ⨆ (i ∈ (s : set ι)), K i,\n    { refine subgroup.noncomm_prod_mem _ _ _,\n      intros x hx,\n      have : K x ≤ ⨆ (i ∈ (s : set ι)), K i := le_supr₂ x hx,\n      exact this (hmem.2 x hx), },\n    intro heq1,\n    rw finset.noncomm_prod_insert_of_not_mem _ _ _ _ hnmem at heq1,\n    have hnmem' : i ∉ (s : set ι), by simpa,\n    obtain ⟨heq1i : f i = 1, heq1S : s.noncomm_prod f _ = 1⟩ :=\n      subgroup.disjoint_iff_mul_eq_one.mp (hind.disjoint_bsupr hnmem') hmem.1 hmem_bsupr heq1,\n    intros i h,\n    simp only [finset.mem_insert] at h,\n    rcases h with ⟨rfl | _⟩,\n    { exact heq1i },\n    { exact ih hcomm hmem.2 heq1S _ h } }\nend\n\nend subgroup\n\n\nsection family_of_monoids\n\nvariables {M : Type*} [monoid M]\n\n-- We have a family of monoids\n-- The fintype assumption is not always used, but declared here, to keep things in order\nvariables {ι : Type*} [hdec : decidable_eq ι] [fintype ι]\nvariables {N : ι → Type*} [∀ i, monoid (N i)]\n\n-- And morphisms ϕ into G\nvariables (ϕ : Π (i : ι), N i →* M)\n\n-- We assume that the elements of different morphism commute\nvariables (hcomm : pairwise $ λ i j, ∀ x y, commute (ϕ i x) (ϕ j y))\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `Π (i : ι), N i`\nvariables (f g : Π (i : ι), N i)\n\nnamespace monoid_hom\n\n/-- The canonical homomorphism from a family of monoids. -/\n@[to_additive \"The canonical homomorphism from a family of additive monoids.\n\nSee also `linear_map.lsum` for a linear version without the commutativity assumption.\"]\ndef noncomm_pi_coprod : (Π (i : ι), N i) →* M :=\n{ to_fun := λ f, finset.univ.noncomm_prod (λ i, ϕ i (f i)) $ λ i _ j _ h, hcomm h _ _,\n  map_one' := by {apply (finset.noncomm_prod_eq_pow_card _ _ _ _ _).trans (one_pow _), simp},\n  map_mul' := λ f g,\n  begin\n    classical,\n    convert @finset.noncomm_prod_mul_distrib _ _ _ _ (λ i, ϕ i (f i)) (λ i, ϕ i (g i)) _ _ _,\n    { ext i, exact map_mul (ϕ i) (f i) (g i), },\n    { rintros i - j - h, exact hcomm h _ _ },\n  end }\n\nvariable {hcomm}\n\ninclude hdec\n\n@[simp, to_additive]\nlemma noncomm_pi_coprod_mul_single (i : ι) (y : N i):\n  noncomm_pi_coprod ϕ hcomm (pi.mul_single i y) = ϕ i y :=\nbegin\n  change finset.univ.noncomm_prod (λ j, ϕ j (pi.mul_single i y j)) _ = ϕ i y,\n  simp only [←finset.insert_erase (finset.mem_univ i)] {single_pass := tt},\n  rw finset.noncomm_prod_insert_of_not_mem _ _ _ _ (finset.not_mem_erase i _),\n  rw pi.mul_single_eq_same,\n  rw finset.noncomm_prod_eq_pow_card,\n  { rw one_pow, exact mul_one _  },\n  { intros j hj, simp only [finset.mem_erase] at hj, simp [hj], },\nend\n\nomit hcomm\n\n/-- The universal property of `noncomm_pi_coprod` -/\n@[to_additive \"The universal property of `noncomm_pi_coprod`\"]\ndef noncomm_pi_coprod_equiv :\n  {ϕ : Π i, N i →* M // pairwise (λ i j, ∀ x y, commute (ϕ i x) (ϕ j y)) }\n    ≃ ((Π i, N i) →* M) :=\n{ to_fun := λ ϕ, noncomm_pi_coprod ϕ.1 ϕ.2,\n  inv_fun := λ f,\n  ⟨ λ i, f.comp (monoid_hom.single N i),\n    λ i j hij x y, commute.map (pi.mul_single_commute hij x y) f ⟩,\n  left_inv := λ ϕ, by { ext, simp, },\n  right_inv := λ f, pi_ext (λ i x, by simp) }\n\nomit hdec\n\ninclude hcomm\n\n@[to_additive]\nlemma noncomm_pi_coprod_mrange : (noncomm_pi_coprod ϕ hcomm).mrange = ⨆ i : ι, (ϕ i).mrange :=\nbegin\n  classical,\n  apply le_antisymm,\n  { rintro x ⟨f, rfl⟩,\n    refine submonoid.noncomm_prod_mem _ _ _ _ _,\n    intros i hi,\n    apply submonoid.mem_Sup_of_mem, { use i },\n    simp, },\n  { refine supr_le _,\n    rintro i x ⟨y, rfl⟩,\n    refine ⟨pi.mul_single i y, noncomm_pi_coprod_mul_single _ _ _⟩, },\nend\n\nend monoid_hom\n\nend family_of_monoids\n\nsection family_of_groups\n\nvariables {G : Type*} [group G]\nvariables {ι : Type*} [hdec : decidable_eq ι] [hfin : fintype ι]\nvariables {H : ι → Type*} [∀ i, group (H i)]\nvariables (ϕ : Π (i : ι), H i →* G)\nvariables {hcomm : ∀ (i j : ι), i ≠ j → ∀ (x : H i) (y : H j), commute (ϕ i x) (ϕ j y)}\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `Π (i : ι), H i`\nvariables (f g : Π (i : ι), H i)\n\ninclude hfin\n\nnamespace monoid_hom\n\n-- The subgroup version of `noncomm_pi_coprod_mrange`\n@[to_additive]\nlemma noncomm_pi_coprod_range : (noncomm_pi_coprod ϕ hcomm).range = ⨆ i : ι, (ϕ i).range :=\nbegin\n  classical,\n  apply le_antisymm,\n  { rintro x ⟨f, rfl⟩,\n    refine subgroup.noncomm_prod_mem _ _ _,\n    intros i hi,\n    apply subgroup.mem_Sup_of_mem, { use i },\n    simp, },\n  { refine supr_le _,\n    rintro i x ⟨y, rfl⟩,\n    refine ⟨pi.mul_single i y, noncomm_pi_coprod_mul_single _ _ _⟩, },\nend\n\n@[to_additive]\nlemma injective_noncomm_pi_coprod_of_independent\n  (hind : complete_lattice.independent (λ i, (ϕ i).range))\n  (hinj : ∀ i, function.injective (ϕ i)) :\n  function.injective (noncomm_pi_coprod ϕ hcomm):=\nbegin\n  classical,\n  apply (monoid_hom.ker_eq_bot_iff _).mp,\n  apply eq_bot_iff.mpr,\n  intros f heq1,\n  change finset.univ.noncomm_prod (λ i, ϕ i (f i)) _ = 1 at heq1,\n  change f = 1,\n  have : ∀ i, i ∈ finset.univ → ϕ i (f i) = 1 :=\n    subgroup.eq_one_of_noncomm_prod_eq_one_of_independent _ _ _ _ hind (by simp) heq1,\n  ext i,\n  apply hinj,\n  simp [this i (finset.mem_univ i)],\nend\n\nvariable (hcomm)\n\nomit hfin\n\n@[to_additive]\nlemma independent_range_of_coprime_order [finite ι] [Π i, fintype (H i)]\n  (hcoprime : ∀ i j, i ≠ j → nat.coprime (fintype.card (H i)) (fintype.card (H j))) :\n  complete_lattice.independent (λ i, (ϕ i).range) :=\nbegin\n  casesI nonempty_fintype ι,\n  classical,\n  rintros i,\n  rw disjoint_iff_inf_le,\n  rintros f ⟨hxi, hxp⟩, dsimp at hxi hxp,\n  rw [supr_subtype', ← noncomm_pi_coprod_range] at hxp,\n  rotate, { intros _ _ hj, apply hcomm, exact hj ∘ subtype.ext },\n  cases hxp with g hgf, cases hxi with g' hg'f,\n  have hxi : order_of f ∣ fintype.card (H i),\n  { rw ← hg'f, exact (order_of_map_dvd _ _).trans order_of_dvd_card_univ },\n  have hxp : order_of f ∣ ∏ j : {j // j ≠ i}, fintype.card (H j),\n  { rw [← hgf, ← fintype.card_pi], exact (order_of_map_dvd _ _).trans order_of_dvd_card_univ },\n  change f = 1, rw [← pow_one f, ← order_of_dvd_iff_pow_eq_one],\n  convert ← nat.dvd_gcd hxp hxi, rw ← nat.coprime_iff_gcd_eq_one,\n  apply nat.coprime_prod_left, intros j _, apply hcoprime, exact j.2,\nend\n\nend monoid_hom\n\nend family_of_groups\n\nnamespace subgroup\n\n-- We have an family of subgroups\nvariables {G : Type*} [group G]\nvariables {ι : Type*} [hdec : decidable_eq ι] [hfin : fintype ι] {H : ι → subgroup G}\n\n-- Elements of `Π (i : ι), H i` are called `f` and `g` here\nvariables (f g : Π (i : ι), H i)\n\nsection commuting_subgroups\n\n-- We assume that the elements of different subgroups commute\nvariables (hcomm : ∀ (i j : ι), i ≠ j → ∀ (x y : G), x ∈ H i → y ∈ H j → commute x y)\ninclude hcomm\n\n@[to_additive]\nlemma commute_subtype_of_commute (i j : ι) (hne : i ≠ j) :\n  ∀ (x : H i) (y : H j), commute ((H i).subtype x) ((H j).subtype y) :=\nby { rintros ⟨x, hx⟩ ⟨y, hy⟩, exact hcomm i j hne x y hx hy }\n\ninclude hfin\n\n/-- The canonical homomorphism from a family of subgroups where elements from different subgroups\ncommute -/\n@[to_additive \"The canonical homomorphism from a family of additive subgroups where elements from\ndifferent subgroups commute\"]\ndef noncomm_pi_coprod : (Π (i : ι), H i) →* G :=\n  monoid_hom.noncomm_pi_coprod (λ i, (H i).subtype) (commute_subtype_of_commute hcomm)\n\nvariable {hcomm}\n\ninclude hdec\n\n@[simp, to_additive]\nlemma noncomm_pi_coprod_mul_single (i : ι) (y : H i) :\n  noncomm_pi_coprod hcomm (pi.mul_single i y) = y :=\nby apply monoid_hom.noncomm_pi_coprod_mul_single\n\nomit hdec\n\n@[to_additive]\nlemma noncomm_pi_coprod_range : (noncomm_pi_coprod hcomm).range = ⨆ i : ι, H i :=\nby simp [noncomm_pi_coprod, monoid_hom.noncomm_pi_coprod_range]\n\n@[to_additive]\nlemma injective_noncomm_pi_coprod_of_independent (hind : complete_lattice.independent H) :\n  function.injective (noncomm_pi_coprod hcomm) :=\nbegin\n  apply monoid_hom.injective_noncomm_pi_coprod_of_independent,\n  { simpa using hind },\n  { intro i, exact subtype.coe_injective }\nend\n\nvariable (hcomm)\n\nomit hfin\n\n@[to_additive]\nlemma independent_of_coprime_order [finite ι] [∀ i, fintype (H i)]\n  (hcoprime : ∀ i j, i ≠ j → nat.coprime (fintype.card (H i)) (fintype.card (H j))) :\n  complete_lattice.independent H :=\nby simpa using monoid_hom.independent_range_of_coprime_order (λ i, (H i).subtype)\n  (commute_subtype_of_commute hcomm) hcoprime\n\nend commuting_subgroups\n\nend subgroup\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/group_theory/noncomm_pi_coprod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239131, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.4977286542581503}}
{"text": "import SciLean.Data.ArrayType.Basic\nimport SciLean.Data.ArrayType.Notation\nimport SciLean.Data.ArrayType.MatrixOperations\n\n\nnamespace SciLean\n\n/-- This class says that `T` is the canonical type to store `numOf I` element of `X`. \n\nThis class allows for the notation `X^I` and `T = X^I`. -/\nclass PowType (T : outParam Type) (I X : Type) extends ArrayType T I X\n\n/-- Obtains the type of `X^I` by providing `X` and `I` -/\nabbrev PowTypeCarrier (X I : Type) {T : outParam Type} [PowType T I X] := T\n\n/-- This class says that `T n` is the canonical type to store `n` elements of `X`.\n\nThis class allows for the notation `X^{n}` and `T n = X^{n}`. -/\nclass LinearPowType (T : outParam (Nat → Type)) (X : Type) extends LinearArrayType T X\n\ninstance (T : Nat → Type) (X : Type) [LinearPowType T X] (n : Nat) : PowType (T n) (Fin n) X := PowType.mk\n\n/-- Type that behaves like and array with values in `X` and indices in `I`.\n\nFor `x : X^I` you can:\n  1. get a value: `x[i] : X` for `i : I`\n  2. set a value: `setElem x i xi : X^I` for `x : X^I`, `i : I`, `xi : X` \n     in do blocks: `x[i] := xi`, `x[i] += xi`, ...\n  3. introduce new array: \n     `let x : X^I := λ [i] => f i`\n     for `f : I → X`\n\nThe precise type of `X^I` depends on `X` and `I` and it is determined by the typeclass `PowType`. Often `X^I` is internally `Array` or `DataArray` bundled with a proposition about its size e.g. `array.size = numOf I` for `array : Array` and `[Enumtype I]`.\n-/\nnotation X \"^\" I => PowTypeCarrier X I\n\n-- instance (T : Nat → Type) [∀ n, PowType (T n) (Fin n) X] [DropElem T X] [PushElem T X] [ReserveElem T X] \n--   : LinearArrayType T X := LinearArrayType.mk (by infer_instance) sorry_proof sorry_proof sorry_proof\n\n\nsection CustomNotation\n\n/-- Type that behaves like a multidimensional array with values in `X`.\n\nFor `x : X^{n₁,...,nₘ}` you can:\n  1. get a value: `x[i₁,...,iₘ] : X` for `i₁ : Fin n₁`, ... , `iₘ : Fin nₘ`\n  2. set a value in do blocks: `x[i₁,...,iₘ] := xi`, `x[i₁,...,iₘ] += xi`\n     for `x : X^{n₁,...,nₘ}`, `i₁ : Fin n₁`, ... , `iₘ : Fin nₘ`, `xi : X` \n  3. introduce new array: \n     `let x : X^{n₁,...,nₘ} := λ [i₁,...,iₘ] => f i₁ ... iₘ`\n     for `f : Fin n₁ → ... → Fin nₘ → X`\n\nThe type `X^{n₁,...,nₘ}` is just a notation for `X^(Fin n₁ × ... Fin nₘ)`\n-/\nsyntax term \"^{\" term,* \"}\" : term\nmacro_rules \n| `($X:term ^{ $n }) => do\n  `($X ^ (Fin $n))\n| `($X:term ^{ $ns,* }) => do\n  if 0 < ns.getElems.size then\n    let last := ns.getElems[ns.getElems.size-1]!\n    let ns' := ns.getElems[:ns.getElems.size-1]\n    let I ← ns'.foldrM (λ x y => `(Fin $x × $y)) (← `(Fin $last))\n    `($X ^ $I)\n  else \n    `(Unit)\n\n\n-- -- TODO: Generalize this\n-- /-- `A[i,j]` is just a notation for `A[(i,j)]` -/\n-- macro A:term  noWs \"[\" id1:term \",\" id2:term \"]\" : term => `($A[($id1, $id2)])\n-- /-- `A[i,j,k]` is just a notation for `A[(i,j,k)]` -/\n-- macro A:term  noWs \"[\" id1:term \",\" id2:term \",\" id3:term \"]\" : term => `($A[($id1, $id2, $id3)])\n-- /-- `A[i,j,k,l]` is just a notation for `A[(i,j,k,l)]` -/\n-- macro A:term  noWs \"[\" id1:term \",\" id2:term \",\" id3:term \",\" id4:term \"]\" : term => `($A[($id1, $id2, $id3, $id4)])\n\nmacro A:term  noWs \"[\" id:term \",\" ids:term,* \"]\" : term => `($A[($id,$ids:term,*)])\n\n/-- `A[i,:]` is just a notation for `λ [j] => A[i,j]` -/\nmacro A:term  noWs \"[\" id1:term \",\" \":\" \"]\" : term => `(λ [j] => $A[($id1, j)])\n/-- `A[i,·]` is just a notation for `λ [j] => A[i,j]` -/\nmacro A:term  noWs \"[\" id1:term \",\" \"·\" \"]\" : term => `(λ j => $A[($id1, j)])\n/-- `A[:,j]` is just a notation for `λ [i] => A[i,j]` -/\nmacro A:term  noWs \"[\" \":\" \",\" id2:term \"]\" : term => `(λ [i] => $A[(i, $id2)])\n/-- `A[·,j]` is just a notation for `λ i => A[i,j]` -/\nmacro A:term  noWs \"[\" \"·\" \",\" id2:term \"]\" : term => `(λ i => $A[(i, $id2)])\n\n\n-- This should be improved such that we can specify the type of arguments\n-- This clashes with typeclass arguments, but who in their right mind\n-- starts a lambda arguments with a typeclass?\nsyntax (name:=powTypeIntroSyntax) \"λ\" Lean.Parser.Term.funBinder+  \" ==> \" term : term\nsyntax (name:=powTypeIntroSyntaxAlt) \"⊞\" Lean.Parser.Term.funBinder+  \" , \" term : term\n\n-- Having this as an abbrev was causing some issues\ndef introPowElem {X I} {T : outParam Type} [Enumtype I] [PowType T I X] (f : I → X) : X^I := introElem λ i => f i\n\nmacro_rules (kind := powTypeIntroSyntax)\n| `(λ $xs:funBinder* ==> $b:term) => `(introPowElem λ $xs* => $b)\nmacro_rules (kind := powTypeIntroSyntaxAlt)\n| `(⊞ $xs:funBinder* , $b:term) => `(introPowElem λ $xs* => $b)\n\nend CustomNotation\n\nnamespace PowTypeCarrier\n\nsection FixedSize\n\nvariable {X I} {T : outParam Type} [Enumtype I] [PowType T I X] -- [Inhabited X]\n\nabbrev get (x : X^I) (i : I) : X := getElem x i True.intro\nabbrev set (x : X^I) (i : I) (xi : X) : X^I := setElem x i xi\nabbrev intro (f : I → X) : X^I := introElem f\nabbrev modify (x : X^I) (i : I) (f : X → X) : X^I := ArrayType.modifyElem x i f\nabbrev mapIdx (f : I → X → X) (x : X^I) : X^I := ArrayType.mapIdx f x\nabbrev map (f : X → X) (x : X^I) : X^I := ArrayType.map f x\n\ndef toArray (v : X^I) : Array X := Id.run do\n  let mut array : Array X := Array.mkEmpty (numOf I)\n  for (i, _) in Enumtype.fullRange I do\n    array := array.push v[i]\n  return array\n\nabbrev Index (_ : X^I) := I\nabbrev Elem  (_ : X^I) := X\n\nopen Lean in\ninstance [ToJson X] : ToJson (X^I) where\n  toJson v := toJson (v.toArray)\n\nopen Lean in\ninstance [FromJson X] : FromJson (X^I) where\n  fromJson? json := \n    match fromJson? (α := Array X) json with\n    | .error msg => .error msg\n    | .ok array => \n      if h : (numOf I) = array.size then\n        .ok (introElem λ i => array[h ▸ toFin i])\n      else \n        .error \"Failed to convert to json to PowType X^{n}, json size does not match `n`\"\n\nend FixedSize\n\n\nsection VariableSize\nvariable {X} {T : outParam (Nat → Type)} [LinearPowType T X]\n\nabbrev empty : X^{0} := ArrayType.empty \nabbrev split {n m : Nat} (x : X^{n+m}) : X^{n} × X^{m} := ArrayType.split x\nabbrev merge {n m : Nat} (x : X^{n}) (y : X^{m}) : X^{n+m} := ArrayType.append x y\nabbrev append {n m : Nat} (x : X^{n}) (y : X^{m}) : X^{n+m} := ArrayType.append x y\nabbrev drop (k : Nat := 1) (x : X^{n+k}) : X^{n} := dropElem k x\nabbrev push (x : X^{n}) (xi : X) (k : Nat := 1) : X^{n+k} := pushElem k xi x\n\n/-- Computes: `y[i] := a i * x[i] + b i * x[i+1]` \n\nSpecial case for `i=n-1`: `y[n-1] := a (n-1) * x[n-1]` -/\nabbrev generateUpperTriangularArray (f : (n' : Nat) → X^{n'+1} → X^{n'}) (x : X^{n}) : X^{(n*(n+1))/2} := \n  ArrayType.generateUpperTriangularArray f x\nabbrev upper2DiagonalUpdate [Vec X] (a : Fin n → ℝ) (b : Fin (n-1) → ℝ) (x : X^{n}) : X^{n} :=\n  ArrayType.upper2DiagonalUpdate a b x\n\n/-- Computes: `y[i] := a i * x[i] + b (i-1) * x[i-1]` \n\nSpecial case for `i=0`: `y[0] := a 0 * x[0]` -/\nabbrev lower2DiagonalUpdate [Vec X] (a : Fin n → ℝ) (b : Fin (n-1) → ℝ) (x : X^{n}) : X^{n} :=\n  ArrayType.lower2DiagonalUpdate a b x\n\n/-- Computes: `y[i] := x[i+1] - x[i]` -/\nabbrev differences [Vec X] (x : X^{n+1}) : X^{n} :=\n  ArrayType.differences x\n\n/-- Computes: `y[i] := (1-t) * x[i] + t * x[i+1]` -/\nabbrev linearInterpolate [Vec X] (t : ℝ) (x : X^{n+1}) : X^{n} :=\n  ArrayType.linearInterpolate t x\n\n-- example [Vec X] : IsLin (λ x : X^{n} => x.upper2DiagonalUpdate (λ _ => 1) (λ _ => -1)) := by infer_instance\n-- example [Vec X] : IsLin (λ x : X^{n+1} => x.drop) := by infer_instance\n-- example [Vec X] (xi : X) : IsSmooth (λ x : X^{n} => x.push xi) := by infer_instance\n\n-- example [Vec X] : IsSmooth (λ x : X^{n+1} => x.linearInterpolate) := by infer_instance\n-- example [Vec X] (x : X^{n+1}) : IsSmooth (λ t => x.linearInterpolate t) := by infer_instance\n\nend VariableSize\n\n\nsection Currying\n\nvariable {X I J}  [Enumtype I] [Enumtype J]\nvariable {T : outParam Type} [PowType T J X]\nvariable {T' : outParam Type} [PowType T' I (X^J)]\nvariable {T'' : outParam Type} [PowType T'' (I×J) X]\n\n-- sometimes this should be effectivelly identity function\n-- sometimes you have to reshuffle memory around, how to deal with this?\n-- def curry : (X^(I×J)) → ((X^J)^I) := sorry\n-- def uncurry : ((X^J)^I) → (X^(I×J)) := sorry\n\nend Currying\n\n\nend PowTypeCarrier\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Data/ArrayType/PowType.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.4977286534882218}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport topology.category.Top.basic\nimport measure_theory.giry_monad\nimport category_theory.monad.algebra\n\n/-!\n# The category of measurable spaces\n\nMeasurable spaces and measurable functions form a (concrete) category `Meas`.\n\n## Main definitions\n\n* `Measure : Meas ⥤ Meas`: the functor which sends a measurable space `X`\nto the space of measures on `X`; it is a monad (the \"Giry monad\").\n\n* `Borel : Top ⥤ Meas`: sends a topological space `X` to `X` equipped with the\n`σ`-algebra of Borel sets (the `σ`-algebra generated by the open subsets of `X`).\n\n## Tags\n\nmeasurable space, giry monad, borel\n-/\n\nnoncomputable theory\n\nopen category_theory measure_theory\nopen_locale ennreal\nuniverses u v\n\n/-- The category of measurable spaces and measurable functions. -/\n@[derive has_coe_to_sort]\ndef Meas : Type (u+1) := bundled measurable_space\n\nnamespace Meas\n\ninstance (X : Meas) : measurable_space X := X.str\n\n/-- Construct a bundled `Meas` from the underlying type and the typeclass. -/\ndef of (α : Type u) [measurable_space α] : Meas := ⟨α⟩\n\n@[simp] lemma coe_of (X : Type u) [measurable_space X] : (of X : Type u) = X := rfl\n\ninstance unbundled_hom : unbundled_hom @measurable := ⟨@measurable_id, @measurable.comp⟩\n\nattribute [derive [large_category, concrete_category]] Meas\n\ninstance : inhabited Meas := ⟨Meas.of empty⟩\n\n/-- `Measure X` is the measurable space of measures over the measurable space `X`. It is the\nweakest measurable space, s.t. λμ, μ s is measurable for all measurable sets `s` in `X`. An\nimportant purpose is to assign a monadic structure on it, the Giry monad. In the Giry monad,\nthe pure values are the Dirac measure, and the bind operation maps to the integral:\n`(μ >>= ν) s = ∫ x. (ν x) s dμ`.\n\nIn probability theory, the `Meas`-morphisms `X → Prob X` are (sub-)Markov kernels (here `Prob` is\nthe restriction of `Measure` to (sub-)probability space.)\n-/\ndef Measure : Meas ⥤ Meas :=\n{ obj      := λX, ⟨@measure_theory.measure X.1 X.2⟩,\n  map      := λX Y f, ⟨measure.map (f : X → Y), measure.measurable_map f f.2⟩,\n  map_id'  := assume ⟨α, I⟩, subtype.eq $ funext $ assume μ, @measure.map_id α I μ,\n  map_comp':=\n    assume X Y Z ⟨f, hf⟩ ⟨g, hg⟩, subtype.eq $ funext $ assume μ, (measure.map_map hg hf).symm }\n\n/-- The Giry monad, i.e. the monadic structure associated with `Measure`. -/\ndef Giry : category_theory.monad Meas :=\n{ to_functor := Measure,\n  η' :=\n  { app         := λX, ⟨@measure.dirac X.1 X.2, measure.measurable_dirac⟩,\n    naturality' :=\n      assume X Y ⟨f, hf⟩, subtype.eq $ funext $ assume a, (measure.map_dirac hf a).symm },\n  μ' :=\n  { app         := λX, ⟨@measure.join X.1 X.2, measure.measurable_join⟩,\n    naturality' :=\n      assume X Y ⟨f, hf⟩, subtype.eq $ funext $ assume μ, measure.join_map_map hf μ },\n  assoc' := assume α, subtype.eq $ funext $ assume μ, @measure.join_map_join _ _ _,\n  left_unit' := assume α, subtype.eq $ funext $ assume μ, @measure.join_dirac _ _ _,\n  right_unit' := assume α, subtype.eq $ funext $ assume μ, @measure.join_map_dirac _ _ _ }\n\n/-- An example for an algebra on `Measure`: the nonnegative Lebesgue integral is a hom, behaving\nnicely under the monad operations. -/\ndef Integral : Giry.algebra :=\n{ A      := Meas.of ℝ≥0∞ ,\n  a      := ⟨λm:measure ℝ≥0∞, ∫⁻ x, x ∂m, measure.measurable_lintegral measurable_id ⟩,\n  unit'  := subtype.eq $ funext $ assume r:ℝ≥0∞, lintegral_dirac' _ measurable_id,\n  assoc' := subtype.eq $ funext $ assume μ : measure (measure ℝ≥0∞),\n    show ∫⁻ x, x ∂ μ.join = ∫⁻ x, x ∂ (measure.map (λm:measure ℝ≥0∞, ∫⁻ x, x ∂m) μ),\n    by rw [measure.lintegral_join, lintegral_map];\n      apply_rules [measurable_id, measure.measurable_lintegral] }\n\nend Meas\n\ninstance Top.has_forget_to_Meas : has_forget₂ Top.{u} Meas.{u} :=\nbundled_hom.mk_has_forget₂\n  borel\n  (λ X Y f, ⟨f.1, f.2.borel_measurable⟩)\n  (by intros; refl)\n\n/-- The Borel functor, the canonical embedding of topological spaces into measurable spaces. -/\n@[reducible] def Borel : Top.{u} ⥤ Meas.{u} := forget₂ Top.{u} Meas.{u}\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/measure_theory/category/Meas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.49772864513977894}}
{"text": "/-\nCopyright 2022 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\nAuthors: Moritz Firsching\n-/\nimport tactic\nimport data.finset.basic\nimport combinatorics.simple_graph.adj_matrix\nimport combinatorics.simple_graph.subgraph\nimport combinatorics.simple_graph.coloring\nimport combinatorics.simple_graph.connectivity\nimport order.well_founded_set\nimport data.set.basic\nimport analysis.special_functions.exp\nimport analysis.special_functions.log.base\n\n\nopen simple_graph\n/-!\n# Probability makes counting (sometimes) easy\n\n## Structure\n  - Theorem 1\n    - proof\n  - Ramsey Numbers\n  - Theorem 2\n    - proof\n  - Triangle-free graphs with high chromatic number (TODO)\n  - Theorem 3\n    - proof\n  - Theorem 4 (TODO : Define crossing number)\n-/\n\n\nsection\n\n\nvariables {α : Type*} {X : finset α}\nparameters {d : ℕ} {h_d : d ≥ 2}\n\n/-- `𝓕` is a collection of `d`-sets of `X`-/\n\nvariables (𝓕 : finset (finset X)) (H_𝓕 : ∀ A : finset X, A ∈ 𝓕 → A.card = d)\n\ndef two_colorable :=\n  ∃ c : X → fin 2, ∀ A : finset X, A ∈ 𝓕 → ∃ x y : A, c x = 0 ∧ c y = 0\n\ninclude H_𝓕\ntheorem theorem_1 : 𝓕.card ≤ 2 ^ (d-1) → two_colorable 𝓕 :=\nbegin\n  sorry,\nend\n\nend\n\n/-! Ramsey Numbers and Theorem 2-/\n\n\n/--\nA complete graph `G` on `N` vertices has the Ramsey property `R(m, n)`, if for each two-coloring of\nthe edges of `G`, either there is a complete subgraph on `m` vertices  of the first color, or there\nis a complete subgraph on `n` vertices in the second color. -/\ndef ramsey_property (m n : ℕ) (N : ℕ) :=\n  ∀ c : (complete_graph (fin N)).edge_set → fin 2,\n  ( ∃ g : complete_graph (fin m) →g complete_graph (fin N), ∀ e : (complete_graph (fin m)).edge_set,\n      c (g.map_edge_set e) = 0 ) ∨\n  ( ∃ h : complete_graph (fin n) →g complete_graph (fin N), ∀ e : (complete_graph (fin n)).edge_set,\n    c (h.map_edge_set e) = 1 )\n\n\nlemma ramsey_exists (m n : ℕ) (h_m : m ≥ 2) (h_n : n ≥ 2) : ∃ N, ramsey_property m n N :=\nbegin\n  sorry,\nend\n\n/--\nThe Ramsey Numbers. Noe that this is only defined for `m, n ≥ 2`\nWould it make sense to make this not noncomputable?\n-/\nnoncomputable def ramsey (m n : ℕ) :=\n   Inf {N : ℕ | ramsey_property m n N }\n\nnamespace ramsey\n\nlemma symm (m n : ℕ) (h_m : m ≥ 2) (h_n : n ≥ 2) : ramsey m n = ramsey n m :=\nbegin\n  sorry,\nend\n\nlemma two (m : ℕ) (h_m : m ≥ 2) : ramsey m 2 = m :=\nbegin\n  sorry,\nend\n\nlemma bound (m n : ℕ) (h_m : m ≥ 3) (h_n : n ≥ 3) :\n  ramsey m n ≤ ramsey (m - 1) n + ramsey m (n - 1) :=\nbegin\n  sorry,\nend\n\nend ramsey\n\n\n/--Theorem 2. Lower bound for `ramsey k k`-/\ntheorem ramsey_geq_two_pow_half (k : ℕ) (h_k : k ≥ 2) :\n  (ramsey k k : ℝ) ≥ real.exp ((real.log 2) + (k: ℝ) / 2) :=\nbegin\n  sorry,\nend\n\n/-! Theorem 3-/\n\n/-- Chromatic Number of a graph -- Should be introduced in part about Kneser Graphs-/\n\n\n\nnoncomputable def girth {V : Type*} (G : simple_graph V) :=\n  Inf {N : ℕ | N ≥ 1 ∧ ∃ (u : V) (W : G.walk u u), N = W.length ∧ W.is_cycle}\n\ntheorem theorem_3 (k : ℕ) (h_k : k ≥ 2) :\n  ∃ (n : ℕ) (G : simple_graph (fin n)), G.chromatic_number > k ∧ girth G > k :=\nbegin\n  sorry,\nend\n\n\n/-! Crossing Number and Theorem 4, TODO: Finish Def. of crossing numbers-/\nnoncomputable def crossing_number {V : Type*} (G: simple_graph V) :=\n  Inf {N : ℕ | ∃ (c : V → ℝ × ℝ) (f : G.edge_set → (set.Icc (0:ℝ) 1) → ℝ × ℝ),\n                  function.injective c ∧\n                  ∀ (e : G.edge_set) (v : V) (h : v ∈ (e : sym2 V)),\n                    ({v, sym2.mem.other h} :set V).image c = (coe ⁻¹' ({0,1} : set ℝ)).image (f e) ∧\n                    true }\n        -- We'd like that at every point in ℝ× ℝ, at most two paths intersect transversally\n\n/-- Theorem 4, TODO: should infer [fintype G.edge_set]-/\ntheorem theorem_4 {V : Type*} [fintype V] (G : simple_graph V) [fintype G.edge_set] (m n : ℕ)\n  (H : m ≥ 4 * n) (h_n : n = fintype.card V) (h_m : m = fintype.card G.edge_set) :\n  crossing_number G ≥ m ^ 3 / n ^ 2 / 64 :=\nbegin\n  sorry,\nend", "meta": {"author": "mo271", "repo": "formal_book", "sha": "34cbc0b9e9d361b74adbe0fd06192a72e684b992", "save_path": "github-repos/lean/mo271-formal_book", "path": "github-repos/lean/mo271-formal_book/formal_book-34cbc0b9e9d361b74adbe0fd06192a72e684b992/src/chapters/45_Probability_makes_counting_(sometimes)_easy.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.4977286443698501}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n-/\nimport category_theory.category.basic\nimport category_theory.equivalence\nimport category_theory.eq_to_hom\n\n/-!\n# Basic API for ulift\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains a very basic API for working with the categorical\ninstance on `ulift C` where `C` is a type with a category instance.\n\n1. `category_theory.ulift.up` is the functorial version of the usual `ulift.up`.\n2. `category_theory.ulift.down` is the functorial version of the usual `ulift.down`.\n3. `category_theory.ulift.equivalence` is the categorical equivalence between\n  `C` and `ulift C`.\n\n# ulift_hom\n\nGiven a type `C : Type u`, `ulift_hom.{w} C` is just an alias for `C`.\nIf we have `category.{v} C`, then `ulift_hom.{w} C` is endowed with a category instance\nwhose morphisms are obtained by applying `ulift.{w}` to the morphisms from `C`.\n\nThis is a category equivalent to `C`. The forward direction of the equivalence is `ulift_hom.up`,\nthe backward direction is `ulift_hom.donw` and the equivalence is `ulift_hom.equiv`.\n\n# as_small\n\nThis file also contains a construction which takes a type `C : Type u` with a\ncategory instance `category.{v} C` and makes a small category\n`as_small.{w} C : Type (max w v u)` equivalent to `C`.\n\nThe forward direction of the equivalence, `C ⥤ as_small C`, is denoted `as_small.up`\nand the backward direction is `as_small.down`. The equivalence itself is `as_small.equiv`.\n-/\n\nuniverses w₁ v₁ v₂ u₁ u₂\n\nnamespace category_theory\n\nvariables {C : Type u₁} [category.{v₁} C]\n\n/-- The functorial version of `ulift.up`. -/\n@[simps]\ndef ulift.up_functor : C ⥤ (ulift.{u₂} C) :=\n{ obj := ulift.up,\n  map := λ X Y f, f }\n\n/-- The functorial version of `ulift.down`. -/\n@[simps]\ndef ulift.down_functor : (ulift.{u₂} C) ⥤ C :=\n{ obj := ulift.down,\n  map := λ X Y f, f }\n\n/-- The categorical equivalence between `C` and `ulift C`. -/\n@[simps]\ndef ulift.equivalence : C ≌ (ulift.{u₂} C) :=\n{ functor := ulift.up_functor,\n  inverse := ulift.down_functor,\n  unit_iso :=\n  { hom := 𝟙 _,\n    inv := 𝟙 _ },\n  counit_iso :=\n  { hom :=\n    { app := λ X, 𝟙 _,\n      naturality' := λ X Y f, by {change f ≫ 𝟙 _ = 𝟙 _ ≫ f, simp} },\n    inv :=\n    { app := λ X, 𝟙 _,\n      naturality' := λ X Y f, by {change f ≫ 𝟙 _ = 𝟙 _ ≫ f, simp} },\n  hom_inv_id' := by {ext, change (𝟙 _) ≫ (𝟙 _) = 𝟙 _, simp},\n  inv_hom_id' := by {ext, change (𝟙 _) ≫ (𝟙 _) = 𝟙 _, simp} },\n  functor_unit_iso_comp' := λ X, by {change (𝟙 X) ≫ (𝟙 X) = 𝟙 X, simp} }\n\nsection ulift_hom\n\n/-- `ulift_hom.{w} C` is an alias for `C`, which is endowed with a category instance\n  whose morphisms are obtained by applying `ulift.{w}` to the morphisms from `C`.\n-/\ndef {w u} ulift_hom (C : Type u) := C\n\ninstance {C} [inhabited C] : inhabited (ulift_hom C) := ⟨(arbitrary C : C)⟩\n\n/-- The obvious function `ulift_hom C → C`. -/\ndef ulift_hom.obj_down {C} (A : ulift_hom C) : C := A\n\n/-- The obvious function `C → ulift_hom C`. -/\ndef ulift_hom.obj_up {C} (A : C) : ulift_hom C := A\n\n@[simp] lemma obj_down_obj_up {C} (A : C) : (ulift_hom.obj_up A).obj_down = A := rfl\n@[simp] lemma obj_up_obj_down {C} (A : ulift_hom C) : ulift_hom.obj_up A.obj_down = A := rfl\n\ninstance : category.{max v₂ v₁} (ulift_hom.{v₂} C) :=\n{ hom := λ A B, ulift.{v₂} $ A.obj_down ⟶ B.obj_down,\n  id := λ A, ⟨𝟙 _⟩,\n  comp := λ A B C f g, ⟨f.down ≫ g.down⟩}\n\n/-- One half of the quivalence between `C` and `ulift_hom C`. -/\n@[simps]\ndef ulift_hom.up : C ⥤ ulift_hom C :=\n{ obj := ulift_hom.obj_up,\n  map := λ X Y f, ⟨f⟩ }\n\n/-- One half of the quivalence between `C` and `ulift_hom C`. -/\n@[simps]\ndef ulift_hom.down : ulift_hom C ⥤ C :=\n{ obj := ulift_hom.obj_down,\n  map := λ X Y f, f.down }\n\n/-- The equivalence between `C` and `ulift_hom C`. -/\ndef ulift_hom.equiv : C ≌ ulift_hom C :=\n{ functor := ulift_hom.up,\n  inverse := ulift_hom.down,\n  unit_iso := nat_iso.of_components (λ A, eq_to_iso rfl) (by tidy),\n  counit_iso := nat_iso.of_components (λ A, eq_to_iso rfl) (by tidy) }\n\nend ulift_hom\n\n/-- `as_small C` is a small category equivalent to `C`.\n  More specifically, if `C : Type u` is endowed with `category.{v} C`, then\n  `as_small.{w} C : Type (max w v u)` is endowed with an instance of a small category.\n\n  The objects and morphisms of `as_small C` are defined by applying `ulift` to the\n  objects and morphisms of `C`.\n\n  Note: We require a category instance for this definition in order to have direct\n  access to the universe level `v`.\n-/\n@[nolint unused_arguments]\ndef {w v u} as_small (C : Type u) [category.{v} C] := ulift.{max w v} C\n\ninstance : small_category (as_small.{w₁} C) :=\n{ hom := λ X Y, ulift.{max w₁ u₁} $ X.down ⟶ Y.down,\n  id := λ X, ⟨𝟙 _⟩,\n  comp := λ X Y Z f g, ⟨f.down ≫ g.down⟩ }\n\n/-- One half of the equivalence between `C` and `as_small C`. -/\n@[simps]\ndef as_small.up : C ⥤ as_small C :=\n{ obj := λ X, ⟨X⟩,\n  map := λ X Y f, ⟨f⟩ }\n\n/-- One half of the equivalence between `C` and `as_small C`. -/\n@[simps]\ndef as_small.down : as_small C ⥤ C :=\n{ obj := λ X, X.down,\n  map := λ X Y f, f.down }\n\n/-- The equivalence between `C` and `as_small C`. -/\n@[simps]\ndef as_small.equiv : C ≌ as_small C :=\n{ functor := as_small.up,\n  inverse := as_small.down,\n  unit_iso := nat_iso.of_components (λ X, eq_to_iso rfl) (by tidy),\n  counit_iso := nat_iso.of_components (λ X, eq_to_iso $ by { ext, refl }) (by tidy) }\n\ninstance [inhabited C] : inhabited (as_small C) := ⟨⟨arbitrary _⟩⟩\n\n/-- The equivalence between `C` and `ulift_hom (ulift C)`. -/\ndef {v' u' v u} ulift_hom_ulift_category.equiv (C : Type u) [category.{v} C] :\n  C ≌ ulift_hom.{v'} (ulift.{u'} C) :=\nulift.equivalence.trans ulift_hom.equiv\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/category/ulift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.49772864058059324}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport algebra.group.defs\nimport logic.equiv.defs\nimport logic.nontrivial\n\n/-!\n# Multiplicative opposite and algebraic operations on it\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we define `mul_opposite α = αᵐᵒᵖ` to be the multiplicative opposite of `α`. It inherits\nall additive algebraic structures on `α` (in other files), and reverses the order of multipliers in\nmultiplicative structures, i.e., `op (x * y) = op y * op x`, where `mul_opposite.op` is the\ncanonical map from `α` to `αᵐᵒᵖ`.\n\nWe also define `add_opposite α = αᵃᵒᵖ` to be the additive opposite of `α`. It inherits all\nmultiplicative algebraic structures on `α` (in other files), and reverses the order of summands in\nadditive structures, i.e. `op (x + y) = op y + op x`, where `add_opposite.op` is the canonical map\nfrom `α` to `αᵃᵒᵖ`.\n\n## Notation\n\n* `αᵐᵒᵖ = mul_opposite α`\n* `αᵃᵒᵖ = add_opposite α`\n\n## Tags\n\nmultiplicative opposite, additive opposite\n-/\n\nuniverses u v\nopen function\n\n/-- Multiplicative opposite of a type. This type inherits all additive structures on `α` and\nreverses left and right in multiplication.-/\n@[to_additive \"Additive opposite of a type. This type inherits all multiplicative structures on\n`α` and reverses left and right in addition.\"]\ndef mul_opposite (α : Type u) : Type u := α\n\npostfix `ᵐᵒᵖ`:std.prec.max_plus := mul_opposite\npostfix `ᵃᵒᵖ`:std.prec.max_plus := add_opposite\n\nvariables {α : Type u}\n\nnamespace mul_opposite\n\n/-- The element of `mul_opposite α` that represents `x : α`. -/\n@[pp_nodot, to_additive \"The element of `αᵃᵒᵖ` that represents `x : α`.\"]\ndef op : α → αᵐᵒᵖ := id\n\n/-- The element of `α` represented by `x : αᵐᵒᵖ`. -/\n@[pp_nodot, to_additive \"The element of `α` represented by `x : αᵃᵒᵖ`.\"]\ndef unop : αᵐᵒᵖ → α := id\n\nattribute [pp_nodot] add_opposite.op add_opposite.unop\n\n@[simp, to_additive] lemma unop_op (x : α) : unop (op x) = x := rfl\n@[simp, to_additive] lemma op_unop (x : αᵐᵒᵖ) : op (unop x) = x := rfl\n@[simp, to_additive] lemma op_comp_unop : (op : α → αᵐᵒᵖ) ∘ unop = id := rfl\n@[simp, to_additive] lemma unop_comp_op : (unop : αᵐᵒᵖ → α) ∘ op = id := rfl\n\nattribute [irreducible] mul_opposite\n\n/-- A recursor for `mul_opposite`. Use as `induction x using mul_opposite.rec`. -/\n@[simp, to_additive \"A recursor for `add_opposite`. Use as `induction x using add_opposite.rec`.\"]\nprotected def rec {F : Π (X : αᵐᵒᵖ), Sort v} (h : Π X, F (op X)) : Π X, F X :=\nλ X, h (unop X)\n\n/-- The canonical bijection between `α` and `αᵐᵒᵖ`. -/\n@[to_additive \"The canonical bijection between `α` and `αᵃᵒᵖ`.\",\n  simps apply symm_apply { fully_applied := ff }]\ndef op_equiv : α ≃ αᵐᵒᵖ := ⟨op, unop, unop_op, op_unop⟩\n\n@[to_additive] lemma op_bijective : bijective (op : α → αᵐᵒᵖ) := op_equiv.bijective\n@[to_additive] lemma unop_bijective : bijective (unop : αᵐᵒᵖ → α) := op_equiv.symm.bijective\n@[to_additive] lemma op_injective : injective (op : α → αᵐᵒᵖ) := op_bijective.injective\n@[to_additive] lemma op_surjective : surjective (op : α → αᵐᵒᵖ) := op_bijective.surjective\n@[to_additive] lemma unop_injective : injective (unop : αᵐᵒᵖ → α) := unop_bijective.injective\n@[to_additive] lemma unop_surjective : surjective (unop : αᵐᵒᵖ → α) := unop_bijective.surjective\n\n@[simp, to_additive] lemma op_inj {x y : α} : op x = op y ↔ x = y := op_injective.eq_iff\n@[simp, to_additive] lemma unop_inj {x y : αᵐᵒᵖ} : unop x = unop y ↔ x = y := unop_injective.eq_iff\n\nvariable (α)\n\n@[to_additive] instance [nontrivial α] : nontrivial αᵐᵒᵖ := op_injective.nontrivial\n@[to_additive] instance [inhabited α] : inhabited αᵐᵒᵖ := ⟨op default⟩\n@[to_additive] instance [subsingleton α] : subsingleton αᵐᵒᵖ := unop_injective.subsingleton\n@[to_additive] instance [unique α] : unique αᵐᵒᵖ := unique.mk' _\n@[to_additive] instance [is_empty α] : is_empty αᵐᵒᵖ := function.is_empty unop\n\ninstance [has_zero α] : has_zero αᵐᵒᵖ := { zero := op 0 }\n\n@[to_additive] instance [has_one α] : has_one αᵐᵒᵖ := { one := op 1 }\n\ninstance [has_add α] : has_add αᵐᵒᵖ :=\n{ add := λ x y, op (unop x + unop y) }\n\ninstance [has_sub α] : has_sub αᵐᵒᵖ :=\n{ sub := λ x y, op (unop x - unop y) }\n\ninstance [has_neg α] : has_neg αᵐᵒᵖ :=\n{ neg := λ x, op $ -(unop x) }\n\ninstance [has_involutive_neg α] : has_involutive_neg αᵐᵒᵖ :=\n{ neg_neg := λ a, unop_injective $ neg_neg _,\n  ..mul_opposite.has_neg α }\n\n@[to_additive] instance [has_mul α] : has_mul αᵐᵒᵖ :=\n{ mul := λ x y, op (unop y * unop x) }\n\n@[to_additive] instance [has_inv α] : has_inv αᵐᵒᵖ :=\n{ inv := λ x, op $ (unop x)⁻¹ }\n\n@[to_additive] instance [has_involutive_inv α] : has_involutive_inv αᵐᵒᵖ :=\n{ inv_inv := λ a, unop_injective $ inv_inv _,\n  ..mul_opposite.has_inv α }\n\n@[to_additive] instance (R : Type*) [has_smul R α] : has_smul R αᵐᵒᵖ :=\n{ smul := λ c x, op (c • unop x) }\n\nsection\nvariables (α)\n\n@[simp] lemma op_zero [has_zero α] : op (0 : α) = 0 := rfl\n@[simp] \n\n@[simp, to_additive] lemma op_one [has_one α] : op (1 : α) = 1 := rfl\n@[simp, to_additive] lemma unop_one [has_one α] : unop (1 : αᵐᵒᵖ) = 1 := rfl\n\nvariable {α}\n\n@[simp] lemma op_add [has_add α] (x y : α) : op (x + y) = op x + op y := rfl\n@[simp] lemma unop_add [has_add α] (x y : αᵐᵒᵖ) : unop (x + y) = unop x + unop y := rfl\n\n@[simp] lemma op_neg [has_neg α] (x : α) : op (-x) = -op x := rfl\n@[simp] lemma unop_neg [has_neg α] (x : αᵐᵒᵖ) : unop (-x) = -unop x := rfl\n\n@[simp, to_additive] lemma op_mul [has_mul α] (x y : α) : op (x * y) = op y * op x := rfl\n@[simp, to_additive] lemma unop_mul [has_mul α] (x y : αᵐᵒᵖ) : unop (x * y) = unop y * unop x := rfl\n\n@[simp, to_additive] lemma op_inv [has_inv α] (x : α) : op (x⁻¹) = (op x)⁻¹ := rfl\n@[simp, to_additive] lemma unop_inv [has_inv α] (x : αᵐᵒᵖ) : unop (x⁻¹) = (unop x)⁻¹ := rfl\n\n@[simp] lemma op_sub [has_sub α] (x y : α) : op (x - y) = op x - op y := rfl\n@[simp] lemma unop_sub [has_sub α] (x y : αᵐᵒᵖ) : unop (x - y) = unop x - unop y := rfl\n\n@[simp, to_additive] lemma op_smul {R : Type*} [has_smul R α] (c : R) (a : α) :\n  op (c • a) = c • op a := rfl\n\n@[simp, to_additive] lemma unop_smul {R : Type*} [has_smul R α] (c : R) (a : αᵐᵒᵖ) :\n  unop (c • a) = c • unop a := rfl\n\nend\n\nvariable {α}\n\n@[simp] lemma unop_eq_zero_iff [has_zero α] (a : αᵐᵒᵖ) : a.unop = (0 : α) ↔ a = (0 : αᵐᵒᵖ) :=\nunop_injective.eq_iff' rfl\n\n@[simp] lemma op_eq_zero_iff [has_zero α] (a : α) : op a = (0 : αᵐᵒᵖ) ↔ a = (0 : α) :=\nop_injective.eq_iff' rfl\n\nlemma unop_ne_zero_iff [has_zero α] (a : αᵐᵒᵖ) : a.unop ≠ (0 : α) ↔ a ≠ (0 : αᵐᵒᵖ) :=\nnot_congr $ unop_eq_zero_iff a\n\nlemma op_ne_zero_iff [has_zero α] (a : α) : op a ≠ (0 : αᵐᵒᵖ) ↔ a ≠ (0 : α) :=\nnot_congr $ op_eq_zero_iff a\n\n@[simp, to_additive] lemma unop_eq_one_iff [has_one α] (a : αᵐᵒᵖ) : a.unop = 1 ↔ a = 1 :=\nunop_injective.eq_iff' rfl\n\n@[simp, to_additive] lemma op_eq_one_iff [has_one α] (a : α) : op a = 1 ↔ a = 1 :=\nop_injective.eq_iff' rfl\n\nend mul_opposite\n\nnamespace add_opposite\n\ninstance [has_one α] : has_one αᵃᵒᵖ := { one := op 1 }\n\n@[simp] lemma op_one [has_one α] : op (1 : α) = 1 := rfl\n@[simp] lemma unop_one [has_one α] : unop 1 = (1 : α) := rfl\n\n@[simp] lemma op_eq_one_iff [has_one α] {a : α} : op a = 1 ↔ a = 1 := op_injective.eq_iff' op_one\n\n@[simp] lemma unop_eq_one_iff [has_one α] {a : αᵃᵒᵖ} : unop a = 1 ↔ a = 1 :=\nunop_injective.eq_iff' unop_one\n\ninstance [has_mul α] : has_mul αᵃᵒᵖ := { mul := λ a b, op (unop a * unop b) }\n\n@[simp] lemma op_mul [has_mul α] (a b : α) : op (a * b) = op a * op b := rfl\n@[simp] lemma unop_mul [has_mul α] (a b : αᵃᵒᵖ) : unop (a * b) = unop a * unop b := rfl\n\ninstance [has_inv α] : has_inv αᵃᵒᵖ := { inv := λ a, op (unop a)⁻¹ }\n\ninstance [has_involutive_inv α] : has_involutive_inv αᵃᵒᵖ :=\n{ inv_inv := λ a, unop_injective $ inv_inv _,\n  ..add_opposite.has_inv }\n\n@[simp] lemma op_inv [has_inv α] (a : α) : op a⁻¹ = (op a)⁻¹ := rfl\n@[simp] lemma unop_inv [has_inv α] (a : αᵃᵒᵖ) : unop a⁻¹ = (unop a)⁻¹ := rfl\n\ninstance [has_div α] : has_div αᵃᵒᵖ := { div := λ a b, op (unop a / unop b) }\n\n@[simp] lemma op_div [has_div α] (a b : α) : op (a / b) = op a / op b := rfl\n@[simp] lemma unop_div [has_div α] (a b : αᵃᵒᵖ) : unop (a / b) = unop a / unop b := rfl\n\nend add_opposite\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/opposites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.49772864019562857}}
{"text": "import hilbert.wr.ad\n\nnamespace clfrags\n    namespace hilbert\n        namespace wr\n            namespace ad\n                \n                theorem ad₂₆ {a b c : Prop} (h₁ : a) (h₂ : b) : ad a b c :=\n                    have h₃ : ad (ad a b c) b a, from ad₂ h₂,\n                    show ad a b c, from ad₁ h₁ h₃\n                \n                theorem ad₄' {a b c : Prop} (h₁ : a) : ad c a (ad c a (ad b a c)) :=\n                    have h₂ : ad a a a, from ad₂₆ h₁ h₁,\n                    have h₃ : ad (ad c a (ad c a (ad b a c))) a a, from ad₄ h₂,\n                    show ad c a (ad c a (ad b a c)), from ad₁ h₁ h₃\n\n                theorem ad₂₇ {a b c d e : Prop} (h₁ : ad (ad a b c) d e) : ad (ad a d e) b c :=\n                    have h₂ : (ad a d e) or (ad a b c), from ad₁₀ h₁,\n                    have h₃ : (ad a b c) or (ad a d e), from ad₁₃ h₂,\n                    show ad (ad a d e) b c, from ad₁₁ h₃\n            \n                theorem ad₆' {a b : Prop} (h₁ : a) : a or b := \n                    ad₆ h₁\n                \n                theorem ad₁_ad {a b c d e : Prop} (h₁ : ad c d e) (h₂ : ad (ad a b c) d e) :\n                    ad a d e := \n                    have h₃ : (ad (ad a b c) d e) → ((ad a d e) or (ad a b c)), from ad₁₀,\n                    have h₄ : ad a d e → ad a d e, from R,\n                    have h₅ : ad c d e → ad a b c → ad a d e, from ad₉,\n                    have h₆ : ad c d e → ad a d e → ad a d e, from M₁ h₄,\n                    have h₇ : ad c d e → ((ad a d e) or (ad a b c)) → ad a d e, from δ_or₂ h₆ h₅,\n                    have h₈ : ad c d e → (ad (ad a b c) d e) → ((ad a d e) or (ad a b c)), from M₁ h₃,\n                    show ad a d e, from (T₂ h₈ h₇) h₁ h₂\n\n                theorem ad₂_ad {a b c d e : Prop} (h₁ : ad a d e) : ad (ad (ad c a b) a c) d e := \n                    let b' := ad c a b in\n                        have h₂ : (ad a d e) → (((ad c a c) or b') or ((ad c d e) or b')),\n                            from (assume h, ad₂₀ $ ad₁₃ $ ad₂₀ $ ad₁₀ $ ad₈ $ ad₁₃ $ ad₆' h),\n                        have h₃ : ((ad c a c) or b') → ((ad b' d e) or (ad b' a c)),\n                            from (assume h, ad₁₃ $ ad₆' $ ad₁₁ h),\n                        have h₄ : ((ad c d e) or b') → ((ad b' d e) or (ad b' a c)), \n                            from (assume h, ad₆' $ ad₁₁ h),\n                        have h₅ : (((ad c a c) or b') or ((ad c d e) or b')) → ((ad b' d e) or (ad b' a c)), \n                            from δ_or₁ h₃ h₄,\n                        have h₆ : ad a d e → ((ad b' d e) or (ad b' a c)), \n                            from T₁ h₂ h₅,\n                        show ad (ad b' a c) d e, \n                            from ad₁₁ (h₆ h₁)\n\n                theorem ad₃_ad {a b c d e f g h : Prop} (h₁ : ad (ad a b c) g h) :\n                    ad (ad (ad (ad (ad f a d) a (ad e a d)) a (ad (ad f a e) a d)) b c) g h :=\n                    let j := ad (ad f a d) a (ad e a d), k := ad (ad f a e) a d, i := ad j a k in\n                        have h₂ : (ad (ad a b c) g h) → ((ad a g h) or (ad a b c)), \n                            from ad₁₀,\n                        have h₃ : ad a g h → ad (ad i b c) g h,\n                            from (assume h₃₁, ad₁₁ $ ad₆' $ ad₃ h₃₁),\n                        have h₄ : ad a b c → ad (ad i b c) g h,\n                            from (assume h₄₁, ad₆ $ ad₃ h₄₁),\n                        have h₅ : ((ad a g h) or (ad a b c)) → ad (ad i b c) g h,\n                            from (δ_or₁ h₃ h₄),\n                        (T₁ h₂ h₅) h₁\n\n                theorem ad₄_ad {a b c d e f g : Prop} (h₁ : ad (ad a b c) f g) :\n                    ad (ad (ad d a (ad d a (ad e a d))) b c) f g := \n                    let h := ad d a (ad d a (ad e a d)) in\n                        have h₂ : (ad (ad a b c) f g) → ((ad a f g) or (ad a b c)), \n                            from ad₁₀,\n                        have h₃ : ad a f g → ad (ad h b c) f g,\n                            from (assume h₃₁, ad₁₁ $ ad₆' $ ad₄ h₃₁),\n                        have h₄ : ad a b c → ad (ad h b c) f g,\n                            from (assume h₄₁, ad₆ $ ad₄ h₄₁),\n                        have h₅ : ((ad a f g) or (ad a b c)) → ad (ad h b c) f g,\n                            from δ_or₁ h₃ h₄,\n                        (T₁ h₂ h₅) h₁\n\n                theorem ad₅_ad {a b c d e : Prop} (h₁ : ad (ad a b c) d e) : ad (b or a) d e :=\n                    have h₂ : ad (ad a b c) d e → ((ad a d e) or (ad a b c)), \n                        from ad₁₀,\n                    have h₃ : (ad a d e) → (ad (b or a) d e), \n                        from (assume h, ad₈ $ ad₁₃ $ ad₆' h),\n                    have h₄ : (ad a b c) → (ad (b or a) d e), \n                        from (assume h, ad₆ $ ad₅ h),\n                    have h₅ : ((ad a d e) or (ad a b c)) → (ad (b or a) d e), \n                        from δ_or₁ h₃ h₄,\n                    (T₁ h₂ h₅) h₁\n\n                theorem ad₆_ad {a b c d e : Prop} (h₁ : ad a d e) : ad (ad a b c) d e := \n                    ad₁₁ $ ad₆' h₁\n\n                theorem ad₇_ad {a b c d e f : Prop} (h₁ : ad (ad (c or d) a b) e f) : \n                    ad ((ad c a b) or (ad d a b)) e f := \n                    have h₂ : ad (ad (c or d) a b) e f → ((ad (c or d) e f) or (ad (c or d) a b)), \n                        from ad₁₀,\n                    have h₃ : ad (c or d) e f → ((ad c e f) or (ad d e f)),\n                        from ad₇,\n                    have h₄ : ad c e f → ad ((ad c a b) or (ad d a b)) e f,\n                        from (assume h, ad₈ $ ad₆' $ ad₁₁ $ ad₆' h),\n                    have h₅ : ad d e f → ad ((ad c a b) or (ad d a b)) e f,\n                        from (assume h, ad₈ $ ad₁₃ $ ad₆' $ ad₁₁ $ ad₆' h),\n                    have h₆ : ((ad c e f) or (ad d e f)) → ad ((ad c a b) or (ad d a b)) e f,\n                        from δ_or₁ h₄ h₅,\n                    have h₇ : ad (c or d) e f → ad ((ad c a b) or (ad d a b)) e f,\n                        from T₁ h₃ h₆,\n                    have h₈ : ad (c or d) a b → ad ((ad c a b) or (ad d a b)) e f,\n                        from (assume h, ad₆ $ ad₇ h),\n                    have h₉ : ((ad (c or d) e f) or (ad (c or d) a b)) → ad ((ad c a b) or (ad d a b)) e f,\n                        from δ_or₁ h₇ h₈,\n                    (T₁ h₂ h₉) h₁\n                        \n                theorem ad₁₂_ad {a b c: Prop} (h₁ : ad (a or a) b c) : ad a b c := \n                    ad₁₂ $ ad₇ h₁\n\n                theorem ad₁₃_ad {a b c d : Prop} (h₁ : ad (a or b) c d) : ad (b or a) c d :=\n                    ad₈ $ ad₁₃ $ ad₇ h₁\n\n                theorem ad₁₄_ad {a b c d e : Prop} (h₁ : ad (a or (b or c)) d e) : ad ((a or b) or c) d e :=\n                    ad₈ $ ad₁₃ $ ad₂₂ $ ad₁₃ $ ad₁₄ $ ad₂₁ $ ad₇ h₁\n \n                theorem ad₈' {a b c d e f : Prop} (h₁ : ad (ad c a b) e f) : ad (ad (c or d) a b) e f := \n                    have h₂ : (ad (ad c a b) e f) → ((ad c e f) or (ad c a b)), from ad₁₀,\n                    have h₃ : (ad c e f) → (ad (ad (c or d) a b) e f), from (assume h, ad₂₇ $ ad₆ $ ad₆_ad h),\n                    have h₄ : (ad c a b) → (ad (ad (c or d) a b) e f), from (assume h, ad₆ $ ad₆_ad h),\n                    have h₅ : ((ad c e f) or (ad c a b)) → (ad (ad (c or d) a b) e f), from δ_or₁ h₃ h₄,\n                    show ad (ad (c or d) a b) e f, from (T₁ h₂ h₅) h₁               \n\n                theorem ad₈'' {a b c d e f : Prop} (h₁ : ad (ad (c or d) a b) e f) : ad (ad (d or c) a b) e f :=\n                    have h₃₁ : (ad (ad (c or d) a b) e f) → ((ad (c or d) e f) or (ad (c or d) a b)),\n                        from ad₁₀,\n                    have h₃₂ : ad (c or d) e f → ad (ad (d or c) a b) e f,\n                        from (assume h, ad₂₇ $ ad₆ $ ad₁₃_ad h),\n                    have h₃₃ : ad (c or d) a b → ad (ad (d or c) a b) e f,\n                        from (assume h, ad₆ $ ad₁₃_ad h),\n                    have h₃₄ : ((ad (c or d) e f) or (ad (c or d) a b)) → ad (ad (d or c) a b) e f,\n                        from δ_or₁ h₃₂ h₃₃,\n                    (T₁ h₃₁ h₃₄) h₁\n                \n                theorem ad₈_ad {a b c d e f : Prop} (h₁ : ad ((ad c a b) or (ad d a b)) e f) : \n                    ad (ad (c or d) a b) e f := \n                    have h₂ : ad ((ad c a b) or (ad d a b)) e f → ((ad (ad c a b) e f) or (ad (ad d a b) e f)),\n                        from ad₇,\n                    have h₃ : ad (ad c a b) e f → ad (ad (c or d) a b) e f, \n                        from ad₈',\n                    have h₄ : ad (ad d a b) e f → ad (ad (c or d) a b) e f, \n                        from (assume h, ad₈'' $ ad₈' h),\n                    have h₅ : ((ad (ad c a b) e f) or (ad (ad d a b) e f)) → ad (ad (c or d) a b) e f,\n                        from δ_or₁ h₃ h₄,\n                    (T₁ h₂ h₅) h₁\n\n                theorem ad₉_ad {a b c d e f g : Prop} (h₁ : ad (ad a b c) f g) (h₂ : ad (ad d e a) f g) : ad (ad d b c) f g :=\n                    let g' := ad d f g, c' := ad d b c in\n                        have h₃ : ad (ad a b c) f g → ((ad a f g) or (ad a b c)), \n                            from ad₁₀,\n                        have h₄ : ad (ad d e a) f g → (g' or (ad d e a)), \n                            from ad₁₀,\n                        have h₅ : ad a b c → ad d f g → (g' or c'), \n                            from M₁ ad₆',\n                        have h₆ : ad a b c → ad d e a → (g' or c'), \n                            from (assume h, assume i, ad₁₃ $ ad₆' $ ad₉ h i),\n                        have h₇ : ad a f g → ad d f g → (g' or c'), \n                            from M₁ ad₆',\n                        have h₈ : ad a f g → ad d e a → (g' or c'), \n                            from (assume h, assume i, ad₆' $ ad₉ h i),\n                        have h₉ : (g' or (ad d e a)) → ad a b c → (g' or c'),\n                            from flip (δ_or₂ h₅ h₆),\n                        have h₁₀ : (g' or (ad d e a)) → ad a f g  → (g' or c'),\n                            from flip (δ_or₂ h₇ h₈),\n                        have h₁₁ : (g' or (ad d e a)) → ((ad a f g) or (ad a b c)) → (g' or c'),\n                            from δ_or₂ h₁₀ h₉,\n                        have h₁₂ : (ad (ad a b c) f g) → (g' or (ad d e a)) → (g' or c'),\n                            from flip (T₂ (M₁ h₃) h₁₁),\n                        have h₁₃ : (ad (ad a b c) f g) → (ad (ad d e a) f g) → (g' or c'),\n                            from T₂ (M₁ h₄) h₁₂,\n                        ad₁₁ (h₁₃ h₁ h₂)\n\n                theorem ad₁₀_ad {a b c d e f g : Prop} (h₁ : ad (ad (ad e d c) a b) f g) \n                    : ad ((ad e a b) or (ad e d c)) f g :=\n                    have h₂ : ad (ad (ad e d c) a b) f g → ((ad (ad e d c) f g) or (ad (ad e d c) a b)), \n                        from ad₁₀,\n                    have h₃ : ad (ad e d c) f g → ad ((ad e a b) or (ad e d c)) f g,\n                        from (assume h, ad₈ $ ad₁₃ $ ad₆' h),\n                    have h₄ : ad (ad e d c) a b → ad ((ad e a b) or (ad e d c)) f g,\n                        from (assume h, ad₆ $ ad₁₀ h),\n                    have h₅ : ((ad (ad e d c) f g) or (ad (ad e d c) a b)) → ad ((ad e a b) or (ad e d c)) f g,\n                        from δ_or₁ h₃ h₄,\n                    (T₁ h₂ h₅) h₁\n\n                theorem ad₁₁_ad {a b c d e f g : Prop} (h₁ : ad ((ad e a b) or (ad e d c)) f g) \n                    : ad (ad (ad e d c) a b) f g :=\n                    have h₂ : ad ((ad e a b) or (ad e d c)) f g → ((ad (ad e a b) f g) or (ad (ad e d c) f g)),\n                        from ad₇, \n                    have h₃ : ad (ad e a b) f g → ((ad e f g) or (ad e a b)),\n                        from ad₁₀,\n                    have h₄ : ad e f g → ((ad e f g) or (ad e d c)), \n                        from ad₆',\n                    have h₅ : ((ad e f g) or (ad e d c)) → ad (ad (ad e d c) a b) f g,\n                        from (assume h, ad₁₁ $ ad₁₃ $ ad₁₀ $ ad₆ $ ad₁₁ h),\n                    have h₆ : ad e f g → ad (ad (ad e d c) a b) f g,\n                        from T₁ h₄ h₅,\n                    have h₇ : ((ad e a b) or (ad e d c)) → ad (ad (ad e d c) a b) f g,\n                        from (assume h, ad₆ $ ad₁₁ h),\n                    have h₈ : ad e a b → ((ad e a b) or (ad e d c)), \n                        from ad₆',\n                    have h₉ : ad e a b → ad (ad (ad e d c) a b) f g,\n                        from T₁ h₈ h₇,\n                    have h₁₀ : ((ad e f g) or (ad e a b)) → ad (ad (ad e d c) a b) f g,\n                        from δ_or₁ h₆ h₉,\n                    have h₁₁ : ad (ad e a b) f g → ad (ad (ad e d c) a b) f g,\n                        from T₁ h₃ h₁₀,\n                    have h₁₂ : ad (ad e d c) f g → ad (ad (ad e d c) a b) f g,\n                        from (assume h, ad₂₇ $ ad₆ $ ad₁₁ $ ad₁₀ h),\n                    have h₁₃ : ((ad (ad e a b) f g) or (ad (ad e d c) f g)) → ad (ad (ad e d c) a b) f g,\n                        from δ_or₁ h₁₁ h₁₂,\n                    (T₁ h₂ h₁₃) h₁\n            end ad\n        end wr\n    end hilbert\nend clfrags\n", "meta": {"author": "greati", "repo": "hilbert-classical-fragments", "sha": "18a21ac6b2e890060eb4ae65752fc0245394d226", "save_path": "github-repos/lean/greati-hilbert-classical-fragments", "path": "github-repos/lean/greati-hilbert-classical-fragments/hilbert-classical-fragments-18a21ac6b2e890060eb4ae65752fc0245394d226/clfrags/src/hilbert/wr/proofs/ad.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339756938819, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.49768228024040645}}
{"text": "/-\nAuthor: <Redacted for anonymized submission>\n-/\n-- import snarks.groth16.declarations\nimport ...attributes\nimport ...integral_domain_tactic\nimport ...general_lemmas.polynomial_degree\nimport ...general_lemmas.monomial_pow\nimport data.mv_polynomial.basic\nimport data.mv_polynomial.funext\nimport data.polynomial.field_division\nimport algebra.polynomial.big_operators\n-- import ...attributes\nimport .vars\n\n/-!\n# Knowledge Soundness\n\nThis file proves the knowledge-soundness property of the Groth16 system for type III pairings, as \npresented in \"Another Look at Extraction and Randomization of Groth’s zk-SNARK\" by \n[Baghery et al.](https://eprint.iacr.org/2020/811.pdf), for the Lipmaa SNARK\n\n-/\n\nopen_locale big_operators classical\n\nsection lipmaa\n\n-- TODO we open mv_polynomial, so we should be able to delete a lot of `mv_polynomial.`\nopen mv_polynomial\n\nnoncomputable theory\n\nuniverses u\n\n\n/-- The finite field parameter of our SNARK -/\nparameter {F : Type u}\nparameter [field F]\n\n/-- The naturals representing:\n  n_stmt - the statement size, \n  n_wit - the witness size -/ \nparameters {n_stmt n_wit n_var : ℕ}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt → (polynomial F) }\nparameter {u_wit : fin n_wit → (polynomial F) }\nparameter {v_stmt : fin n_stmt → (polynomial F) }\nparameter {v_wit : fin n_wit → (polynomial F) }\nparameter {w_stmt : fin n_stmt → (polynomial F) }\nparameter {w_wit : fin n_wit → (polynomial F) }\n\n\n\n-- We choose the following exponents\n-- def α : ℕ := 6 \n-- def β : ℕ := 7\n-- def γ : ℕ := 0\n-- def δ : ℕ := 10\n-- def η : ℕ := 5\n\ndef α : ℕ := 26 \ndef β : ℕ := 27\ndef γ : ℕ := 0\ndef δ : ℕ := 40\ndef η : ℕ := 24\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit → F} \n/-- l is the polynomial divisibility by which is used to verify satisfaction of the QAP -/\ndef l : polynomial F := ∏ i in (finset.fin_range n_wit), (polynomial.X - polynomial.C (r i))\n-- TODO this could potentially be spun off into a mathlib definition\n\n\n/-- Checks whether a statement witness pair satisfies the QAP -/\ndef satisfying (a_stmt : fin n_stmt → F ) (a_wit : fin n_wit → F) := \n((∑ i in (finset.fin_range n_stmt), a_stmt i • u_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • u_wit i))\n  * \n(∑ i in (finset.fin_range n_stmt), a_stmt i • v_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • v_wit i))\n  -\n(∑ i in (finset.fin_range n_stmt), a_stmt i • w_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • w_wit i)))\n   %ₘ l = 0\n\nrun_cmd mk_simp_attr `crs\nrun_cmd tactic.add_doc_string `simp_attr.crs \"Attribute for defintions of CRS elements\"\n\n/-- The modified CRS elements, see fig 3 of the paper  -/\n@[crs]\ndef crs'_P_all_wit_1 (i : fin n_wit) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (β - α + δ) * C (u_wit i) \n + (X vars.y) ^ (β - α + γ) * C (v_wit i) \n + (X vars.y) ^ (2 * β - α) * C (w_wit i) \n@[crs]\ndef crs'_P_α_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ α\n@[crs]\ndef crs'_P_powers_1 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ β * C (polynomial.X ^ (i : ℕ)) \n@[crs]\ndef crs'_P_l_1 (i : fin (n_var - 1)) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (2 * β - α) * C l * C (polynomial.X ^ (i : ℕ)) \n-- @[crs]\n-- def crs'_P_γ_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ γ\n@[crs]\ndef crs'_P_δ_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ δ\n@[crs]\ndef crs'_P_se_α_z_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ α * (X vars.z) -- Only in S_qap^se\n@[crs]\ndef crs'_P_se_powers_1 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ β * (X vars.z) * C (polynomial.X ^ (i : ℕ))  -- Only in S_qap^se\n-- @[crs]\n-- def crs'_P_α_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ α\n@[crs]\ndef crs'_P_powers_2 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ β * C (polynomial.X ^ (i : ℕ)) -- same as crs'_P_powers_1\n\n@[crs]\ndef crs'_V_all_stmt_1 (i : fin n_stmt) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (β - η + δ) * C (u_stmt i) \n + (X vars.y) ^ (β - η + γ) * C (v_stmt i) \n + (X vars.y) ^ (2 * β - η) * C (w_stmt i) \n-- @[crs]\n-- def crs'_V_γ_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ γ -- Same as crs'_P_γ_1\n@[crs]\ndef crs'_V_se_z_1 : mv_polynomial vars (polynomial F) := \n  (X vars.z) -- Only in S_qap^se\n-- @[crs]\n-- def crs'_V_α_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ α\n@[crs]\ndef crs'_V_δ_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ δ\n@[crs]\ndef crs'_V_η_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ η\n@[crs]\ndef crs'_V_γ_δ_T : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ (γ + δ)\n\n-- Elements both prover and verifier use\n\n@[crs]\ndef crs'_γ_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ γ\n@[crs]\ndef crs'_α_2 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ α\n\n\nparameters {A_comp_crs'_P_all_wit_1 : fin n_wit → F}\nparameters {A_comp_crs'_P_α_1 : F}\nparameters {A_comp_crs'_P_powers_1 : fin n_var → F}\nparameters {A_comp_crs'_P_l_1 : fin (n_var - 1) → F}\nparameters {A_comp_crs'_γ_1 : F}\nparameters {A_comp_crs'_P_δ_1 : F}\n-- parameters {A_comp_crs'_P_se_α_z_1 : F}\n-- parameters {A_comp_crs'_P_se_powers_1 : fin n_var → F}\nparameters {A_comp_crs'_V_all_stmt_1 : fin n_stmt → F}\n-- parameters {A_comp_crs'_V_γ_1 : F} -- Same as previous\n-- parameters {A_comp_crs'_V_se_z_1 : F}\n\n\n/-- Polynomial form of A in the adversary's proof representation -/\ndef A' : mv_polynomial vars (polynomial F) := \n  ∑ i in (finset.fin_range n_wit), (crs'_P_all_wit_1 i) * C (polynomial.C (A_comp_crs'_P_all_wit_1 i))\n  +\n  crs'_P_α_1 * C (polynomial.C (A_comp_crs'_P_α_1))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  ∑ i in (finset.fin_range (n_var - 1)), (crs'_P_l_1 i) * C (polynomial.C (A_comp_crs'_P_l_1 i))\n  +\n  crs'_γ_1 * C (polynomial.C (A_comp_crs'_γ_1))\n  +\n  crs'_P_δ_1 * C (polynomial.C (A_comp_crs'_P_δ_1))\n  +\n  ∑ i in (finset.fin_range n_stmt), (crs'_V_all_stmt_1 i) * C (polynomial.C (A_comp_crs'_V_all_stmt_1 i))\n\n\nparameters {B_comp_crs'_α_2 : F}\nparameters {B_comp_crs'_P_powers_2 : fin n_var → F}\n-- parameters {B_comp_crs'_V_α_2 : F} -- Same as previous\nparameters {B_comp_crs'_V_δ_2 : F}\nparameters {B_comp_crs'_V_η_2 : F}\n\n/-- Polynomial form of B in the adversary's proof representation -/\ndef B' : mv_polynomial vars (polynomial F) := \n  crs'_α_2 * C (polynomial.C (B_comp_crs'_α_2))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_2 i) * C (polynomial.C (B_comp_crs'_P_powers_2 i))\n  +\n  crs'_V_δ_2 * C (polynomial.C (B_comp_crs'_V_δ_2))\n  +\n  crs'_V_η_2 * C (polynomial.C (B_comp_crs'_V_η_2))\n\n\nparameters {C_comp_crs'_P_all_wit_1 : fin n_wit → F}\nparameters {C_comp_crs'_P_α_1 : F}\nparameters {C_comp_crs'_P_powers_1 : fin n_var → F}\nparameters {C_comp_crs'_P_l_1 : fin (n_var - 1) → F}\nparameters {C_comp_crs'_P_γ_1 : F}\nparameters {C_comp_crs'_P_δ_1 : F}\n-- parameters {C_comp_crs'_P_se_α_z_1 : F}\n-- parameters {C_comp_crs'_P_se_powers_1 : fin n_var → F}\nparameters {C_comp_crs'_V_all_stmt_1 : fin n_stmt → F}\n-- parameters {C_comp_crs'_V_γ_1 : F} -- Same as previous\n-- parameters {C_comp_crs'_V_se_z_1 : F}\n\n/-- Polynomial form of C in the adversary's proof representation -/\ndef C' : mv_polynomial vars (polynomial F) := \n  ∑ i in (finset.fin_range n_wit), (crs'_P_all_wit_1 i) * C (polynomial.C (C_comp_crs'_P_all_wit_1 i))\n  +\n  crs'_P_α_1 * C (polynomial.C (C_comp_crs'_P_α_1))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (C_comp_crs'_P_powers_1 i))\n  +\n  ∑ i in (finset.fin_range (n_var - 1)), (crs'_P_l_1 i) * C (polynomial.C (C_comp_crs'_P_l_1 i))\n  +\n  crs'_γ_1 * C (polynomial.C (C_comp_crs'_P_γ_1))\n  +\n  crs'_P_δ_1 * C (polynomial.C (C_comp_crs'_P_δ_1))\n  +\n  ∑ i in (finset.fin_range n_stmt), (crs'_V_all_stmt_1 i) * C (polynomial.C (C_comp_crs'_V_all_stmt_1 i))\n\n\n\ndef verified' (a_stmt : fin n_stmt → F ) : Prop :=\n  (∑ i in finset.fin_range n_stmt, C (polynomial.C (a_stmt i)) * crs'_V_all_stmt_1 i ) * crs'_V_η_2 \n  +\n  C' * crs'_α_2 \n  =\n  (A' + crs'_γ_1) * (B' + crs'_V_δ_2) - crs'_V_γ_δ_T \n\n-- A, modified to be more like what we see in Baghery et al. - this includes athe extra y^γ we see \n-- that the verifier adds.\n\ndef A_mod_comp_crs_P_γ_1 := A_comp_crs'_γ_1 + 1\n\nlemma A_mod_transform : \n  A' + crs'_γ_1 =\n   ∑ i in (finset.fin_range n_wit), (crs'_P_all_wit_1 i) * C (polynomial.C (A_comp_crs'_P_all_wit_1 i))\n  +\n  crs'_P_α_1 * C (polynomial.C (A_comp_crs'_P_α_1))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  ∑ i in (finset.fin_range (n_var - 1)), (crs'_P_l_1 i) * C (polynomial.C (A_comp_crs'_P_l_1 i))\n  +\n  crs'_γ_1 * C (polynomial.C (A_mod_comp_crs_P_γ_1))\n  +\n  crs'_P_δ_1 * C (polynomial.C (A_comp_crs'_P_δ_1))\n  +\n  ∑ i in (finset.fin_range n_stmt), (crs'_V_all_stmt_1 i) * C (polynomial.C (A_comp_crs'_V_all_stmt_1 i)) :=\nbegin\n  rw [A', A_mod_comp_crs_P_γ_1],\n  simp only [mv_polynomial.C_add, ring_hom.map_add, ring_hom.map_one, mv_polynomial.C_1, mul_add, mul_one],\n  abel,\nend\n\n-- B, modified to be more like what we see in Baghery et al. - this includes athe extra y^γ we see \n-- that the verifier adds. \n\ndef B_mod_comp_crs_V_δ_2 := B_comp_crs'_V_δ_2 + 1\n\nlemma B_mod_transform : \n  B' + crs'_V_δ_2 =\n  crs'_α_2 * C (polynomial.C (B_comp_crs'_α_2))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_2 i) * C (polynomial.C (B_comp_crs'_P_powers_2 i))\n  +\n  crs'_V_δ_2 * C (polynomial.C (B_mod_comp_crs_V_δ_2))\n  +\n  crs'_V_η_2 * C (polynomial.C (B_comp_crs'_V_η_2)) :=\nbegin\n  rw [B', B_mod_comp_crs_V_δ_2],\n  simp only [mv_polynomial.C_add, ring_hom.map_add, ring_hom.map_one, mv_polynomial.C_1, mul_add, mul_one],\n  abel,\nend\n\n\n-- TODO use this for lots of profiling data\n-- set_option profiler true\n\nopen finsupp\n\n-- TODO Add to Mathlib next to C_eq_zero\n@[simp] lemma polynomial.C_eq_one (a : F) : polynomial.C a = 1 ↔ a = 1 :=\ncalc polynomial.C a = 1 ↔ polynomial.C a = polynomial.C 1 : by rw polynomial.C_1\n         ... ↔ a = 1 : polynomial.C_inj\n\n\nlemma simplifier1 (x : fin n_stmt) (a_stmt : fin n_stmt → F ) \n  : polynomial.C (a_stmt x) * u_stmt x = u_stmt x * polynomial.C (a_stmt x)\n  :=\n  by ring\n\nlemma simplifier2 (x : fin n_stmt) (a_stmt : fin n_stmt → F ) \n  : polynomial.C (a_stmt x) * v_stmt x = v_stmt x * polynomial.C (a_stmt x)\n  :=\n  by ring\n\nlemma polynomial.mul_mod_by_monic (t p : polynomial F) (mt : t.monic) : (t * p) %ₘ t = 0 :=\nbegin\n  rw polynomial.dvd_iff_mod_by_monic_eq_zero,\n  apply dvd_mul_right,\n  exact mt,\nend\n\nlemma A_mod_comp_crs_P_γ_1_mul (p : polynomial F) : p * polynomial.C A_mod_comp_crs_P_γ_1  = polynomial.C A_mod_comp_crs_P_γ_1 * p := by ring\n\nlemma B_mod_comp_crs_V_δ_2_mul (p : polynomial F) : p * polynomial.C B_mod_comp_crs_V_δ_2  = polynomial.C B_mod_comp_crs_V_δ_2 * p := by ring\n\n\n/-- The main theorem for the soundness of the Lipmaa SNARK. This fixed version does go through. -/\ntheorem soundness (a_stmt : fin n_stmt → F ) : \n  verified' a_stmt\n  -> (satisfying a_stmt C_comp_crs'_P_all_wit_1)\n:=\nbegin\n  \n  intros eqn',\n\n  rw satisfying,\n  simp only [polynomial.smul_eq_C_mul, rearrange_constants_right_hard],\n  suffices : \n    (∑ (i : fin n_stmt) in finset.fin_range n_stmt, u_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.fin_range n_wit, u_wit i * polynomial.C (C_comp_crs'_P_all_wit_1  i)) \n    * \n    (∑ (i : fin n_stmt) in finset.fin_range n_stmt, v_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.fin_range n_wit, v_wit i * polynomial.C (C_comp_crs'_P_all_wit_1  i)) \n    = \n    (∑ (i : fin n_stmt) in finset.fin_range n_stmt, w_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.fin_range n_wit, w_wit i * polynomial.C (C_comp_crs'_P_all_wit_1  i)) \n    +\n    ∑ (x : fin (n_var - 1)) in finset.fin_range (n_var - 1), l * polynomial.X ^ (x : ℕ) * polynomial.C (C_comp_crs'_P_l_1 x),\n  {\n    rw <-sub_eq_iff_eq_add' at this,\n    have h := congr_arg (%ₘ l) this,\n    simp only at h,\n    rw h,\n    clear this h,\n    conv\n    begin\n      to_lhs,\n      congr,\n      congr,\n      skip,\n      funext,\n      rw mul_comm,   \n      rw <-mul_assoc,\n      skip,   \n    end,\n    simp_rw mul_comm _ l,\n    simp_rw mul_assoc,\n    simp_rw mul_comm l _,\n    rw <-finset.sum_mul,\n    rw mul_comm,\n    apply polynomial.mul_mod_by_monic,\n    rw l,\n    apply monic_of_product_form,\n  },\n  \n  rw verified' at eqn',\n  rw [A_mod_transform, B_mod_transform, C'] at eqn',\n  simp only [] with crs at eqn',\n  -- simp only [] with polynomial_nf_3 at eqn',\n  simp only [α, β, γ, δ, η, algebra.id.smul_eq_mul, nat.succ_sub_succ, nat.sub_zero, nat.zero_mul, nat.mul_zero, nat.zero_add, nat.add_zero, nat.mul_succ, nat.add_succ] at eqn',\n  -- done,\n  simp only [mv_polynomial.X, C_apply, mv_polynomial.monomial_mul, mv_polynomial.monomial_pow, finsupp.smul_single, one_pow, one_mul, mul_one, add_zero, zero_add, finset.sum_add_distrib, finset.sum_hom, mul_add, add_mul, sum_monomial_hom] at eqn',\n\n  -- have h0 := congr_arg (coeff (single vars.y 0)) eqn',\n  -- -- have h1 := congr_arg (coeff (single vars.y 1)) eqn',\n  -- -- have h2 := congr_arg (coeff (single vars.y 2)) eqn',\n  -- -- have h3 := congr_arg (coeff (single vars.y 3)) eqn',\n  -- -- have h4 := congr_arg (coeff (single vars.y 4)) eqn',\n  -- have h5 := congr_arg (coeff (single vars.y 5)) eqn',\n  -- -- have h6 := congr_arg (coeff (single vars.y 6)) eqn',\n  -- have h7 := congr_arg (coeff (single vars.y 7)) eqn',\n  -- -- have h8 := congr_arg (coeff (single vars.y 8)) eqn',\n  -- -- have h9 := congr_arg (coeff (single vars.y 9)) eqn',\n  -- have h10 := congr_arg (coeff (single vars.y 10)) eqn',\n  -- -- have h11 := congr_arg (coeff (single vars.y 11)) eqn',\n  -- -- have h12 := congr_arg (coeff (single vars.y 12)) eqn',\n  -- -- have h13 := congr_arg (coeff (single vars.y 13)) eqn',\n  -- have h14 := congr_arg (coeff (single vars.y 14)) eqn',\n  -- -- have h15 := congr_arg (coeff (single vars.y 15)) eqn',\n  -- -- have h16 := congr_arg (coeff (single vars.y 16)) eqn',\n  -- have h17 := congr_arg (coeff (single vars.y 17)) eqn',\n  -- have h18 := congr_arg (coeff (single vars.y 18)) eqn',\n  -- -- have h19 := congr_arg (coeff (single vars.y 19)) eqn',\n  -- have h20 := congr_arg (coeff (single vars.y 20)) eqn',\n  -- -- have h21 := congr_arg (coeff (single vars.y 21)) eqn',\n  -- -- have h22 := congr_arg (coeff (single vars.y 22)) eqn',\n  -- -- have h23 := congr_arg (coeff (single vars.y 23)) eqn',\n  -- -- have h24 := congr_arg (coeff (single vars.y 24)) eqn',\n  -- -- have h25 := congr_arg (coeff (single vars.y 25)) eqn',\n  -- -- have h26 := congr_arg (coeff (single vars.y 26)) eqn',\n  -- -- have h27 := congr_arg (coeff (single vars.y 27)) eqn',\n\n\n-- def α : ℕ := 26 \n-- def β : ℕ := 27\n-- def γ : ℕ := 0\n-- def δ : ℕ := 40\n-- def η : ℕ := 24\n\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 0 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 1 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 2 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 2 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 2 - (β-η) * 2 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 2\n  -- -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 3\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 1 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 2,\n\n\n  have h0012 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 0 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h0021 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 0 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h0022 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 0 + (β-η) * 0 + (β-α) * 0))) eqn',\n  -- have h0022 := congr_arg (coeff (single vars.y (46))) eqn',\n  have h0112 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 1 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h0121 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h0122 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 0))) eqn',\n  have h0212 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 2 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h0221 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 2 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h0222 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 2 + (β-η) * 0 + (β-α) * 0))) eqn',\n  have h1022 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 0 + (β-η) * 0 + (β-α) * 0))) eqn',\n  -- have h1023 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 0 + (β-η) * 0 - (β-α) * 3))) eqn',\n  have h1112 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 1 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h1121 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h1122 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 0))) eqn',\n\n  simp only [α, β, η, δ, γ, algebra.id.smul_eq_mul, nat.succ_sub_succ, nat.sub_zero, nat.zero_mul, nat.mul_zero, nat.zero_add, nat.add_zero, nat.mul_succ, nat.add_succ] at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n  -- done,\n\n\n  clear eqn',\n  -- clear h0012 h0021 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n  -- done,\n\n\n  simp only [finsupp_vars_eq_ext, mv_polynomial.coeff_sub] with coeff_simp finsupp_eq at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n  -- simp only [finsupp_vars_eq_ext, mv_polynomial.coeff_sub] with coeff_simp finsupp_eq at h0022,\n\n  -- simp only [algebra.id.smul_eq_mul, nat.succ_sub_succ, nat.sub_zero, nat.zero_mul, nat.mul_zero, nat.mul_succ, nat.add_succ] with finsupp_simp at h0022,\n  simp only [algebra.id.smul_eq_mul, nat.succ_sub_succ, sub_zero, nat.zero_mul, nat.mul_zero, nat.mul_succ, nat.add_succ] with finsupp_simp at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n\n  -- abel at *,\n  rw sub_eq_zero at h1122,\n\n\n\n\n  done,\n\n  -- Step 2: Recursively simplify and case-analyze the equations\n  \n  trace \"Moving Cs right\",\n  simp only [simplifier1, simplifier2] at *,\n\n  trace \"Grouping distributivity\",\n  simp only [<-mul_add, <-add_mul, <-add_assoc, add_mul_distrib, add_mul_distrib'] at *,\n\n  have h1022' : \n    polynomial.C A_mod_comp_crs_P_γ_1 *\n      ∑ (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : ℕ) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n      (∑ (x : fin n_stmt) in finset.fin_range n_stmt, v_stmt x * polynomial.C (A_comp_crs'_V_all_stmt_1 x)) *\n        polynomial.C B_comp_crs'_V_η_2 +\n    (∑ (x : fin n_wit) in finset.fin_range n_wit, v_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) *\n          polynomial.C B_comp_crs'_α_2 =\n    ∑ (x : fin n_stmt) in finset.fin_range n_stmt, v_stmt x * polynomial.C (a_stmt x) +\n      ∑ (x : fin n_wit) in finset.fin_range n_wit, v_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x),\n  {\n    rw h1022,\n    ring,\n  },\n\n  have h0122' : \n    polynomial.C A_comp_crs'_P_δ_1 *\n      ∑ (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : ℕ) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (∑ (x : fin n_var) in finset.fin_range n_var,\n       polynomial.X ^ (x : ℕ) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n            polynomial.C B_mod_comp_crs_V_δ_2 +\n    (∑ (x : fin n_stmt) in finset.fin_range n_stmt, u_stmt x * polynomial.C (A_comp_crs'_V_all_stmt_1 x)) *\n        polynomial.C B_comp_crs'_V_η_2 +\n    (∑ (x : fin n_wit) in finset.fin_range n_wit, u_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) *\n              polynomial.C B_comp_crs'_α_2  =\n    ∑ (x : fin n_stmt) in finset.fin_range n_stmt, u_stmt x * polynomial.C (a_stmt x) +\n      ∑ (x : fin n_wit) in finset.fin_range n_wit, u_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x),\n  {\n    rw h0122,\n    ring,\n  },\n\n  have h0022' : \n    (∑ (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : ℕ) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n    ∑ (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : ℕ) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (∑ (x : fin n_stmt) in finset.fin_range n_stmt, w_stmt x * polynomial.C (A_comp_crs'_V_all_stmt_1 x)) *\n        polynomial.C B_comp_crs'_V_η_2 +\n    polynomial.C B_comp_crs'_α_2  * \n      ((∑ (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) +\n       (∑ (x : fin (n_var - 1)) in finset.fin_range (n_var - 1),\n         l * polynomial.X ^ (x : ℕ) * polynomial.C (A_comp_crs'_P_l_1 x)))\n    =\n    ∑ (x : fin n_stmt) in finset.fin_range n_stmt, w_stmt x * polynomial.C (a_stmt x) +\n        ∑ (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x) +\n      ∑ (x : fin (n_var - 1)) in\n        finset.fin_range (n_var - 1),\n        l * polynomial.X ^ (x : ℕ) * polynomial.C (C_comp_crs'_P_l_1 x),\n  {\n    rw h0022,\n    ring,\n  },\n\n  clear h0122 h1022 h0022,\n\n  -- hack rewrites to get things the same as in the groth16typeIII \n  rw eq_comm at h0012 h0021 h0112 h0121 h0212 h0221 h0222 h1112 h1121 h1122 h0122' h1022' h0022',\n\n  rw eq_comm at h0021 h0022' h0121 h0012 h0112 h0122' h1022' h0212 h0221 h0222 h1112 h1121 h1122,\n\n  -- done,\n\n  trace \"Main simplification\",\n  simp only [*] with integral_domain_simp at *,\n\n  -- have hγη : (1 + polynomial.C A_comp_crs'_P_γ_1) * polynomial.C B_comp_crs'_V_η_2 = 0,\n  -- { rw add_mul, rw <-h5, ring, },\n  -- rw mul_eq_zero at hγη,\n\n  -- have hδδ : polynomial.C A_comp_crs'_P_δ_1 * (1 + polynomial.C B_comp_crs'_V_δ_2) = 0,\n  -- { rw mul_add, rw <-h0222, ring, },\n  -- rw mul_eq_zero at hδδ,\n\n  -- have hγδ : (1 + polynomial.C A_comp_crs'_P_γ_1) * (1 + polynomial.C B_comp_crs'_V_δ_2) = 1,\n  -- { rw <-sub_eq_zero, rw <-h1122, ring, },\n\n  -- have hββ := h14,\n  -- have hβγ := h7,\n  -- have hβδ := h17,\n  -- have hγγ := h0,\n  -- have hγδ := h10,\n\n  -- clear h0 h5 h7 h10 h14 h17 h20,\n\n\n\n\n  tactic.integral_domain_tactic_v4,\n\n  -- rw <-hβγ,\n  -- rw <-hβδ,\n  -- rw <-hββ,\n\n\n  -- done,\n\n  -- Solve remaining four cases by hand\n  { rw [<-h1022', <-h0122', <-h0022'],\n    simp only [B_mod_comp_crs_V_δ_2_mul],\n    simp only [<-mul_assoc],\n    simp only [A_mod_comp_crs_P_γ_1_mul],\n    simp only [<-mul_assoc],\n    rw h1122,\n    ring, },\n\n\n\n\nend \n\nend lipmaa\n\n\n\n", "meta": {"author": "BoltonBailey", "repo": "formal-snarks-project", "sha": "154414784f90a1e257162fcbdd7e805ecb2a49c2", "save_path": "github-repos/lean/BoltonBailey-formal-snarks-project", "path": "github-repos/lean/BoltonBailey-formal-snarks-project/formal-snarks-project-154414784f90a1e257162fcbdd7e805ecb2a49c2/src/snarks/lipmaafixedexponents/knowledge_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.49768227073208704}}
{"text": "/-\nCopyright (c) 2021 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Scott Morrison\n-/\nimport topology.algebra.ring\nimport topology.algebra.group_with_zero\n\n/-!\n# Topological fields\n\nA topological division ring is a topological ring whose inversion function is continuous at every\nnon-zero element.\n\n-/\n\n\nnamespace topological_ring\nopen topological_space function\nvariables (R : Type*) [ring R]\n\nvariables  [topological_space R]\n\n/-- The induced topology on units of a topological ring.\nThis is not a global instance since other topologies could be relevant. Instead there is a class\n`induced_units` asserting that something equivalent to this construction holds. -/\ndef topological_space_units : topological_space (units R) := induced (coe : units R → R) ‹_›\n\n/-- Asserts the topology on units is the induced topology.\n\n Note: this is not always the correct topology.\n Another good candidate is the subspace topology of $R \\times R$,\n with the units embedded via $u \\mapsto (u, u^{-1})$.\n These topologies are not (propositionally) equal in general. -/\nclass induced_units [t : topological_space $ units R] : Prop :=\n(top_eq : t = induced (coe : units R → R) ‹_›)\n\nvariables [topological_space $ units R]\n\nlemma units_topology_eq [induced_units R] :\n  ‹topological_space (units R)› = induced (coe : units R → R) ‹_› :=\ninduced_units.top_eq\n\nlemma induced_units.continuous_coe [induced_units R] : continuous (coe : units R → R) :=\n(units_topology_eq R).symm ▸ continuous_induced_dom\n\nlemma units_embedding [induced_units R] :\n  embedding (coe : units R → R) :=\n{ induced := units_topology_eq R,\n  inj := λ x y h, units.ext h }\n\ninstance top_monoid_units [topological_ring R] [induced_units R] :\n  has_continuous_mul (units R) :=\n⟨begin\n  let mulR := (λ (p : R × R), p.1*p.2),\n  let mulRx := (λ (p : units R × units R), p.1*p.2),\n  have key : coe ∘ mulRx = mulR ∘ (λ p, (p.1.val, p.2.val)), from rfl,\n  rw [continuous_iff_le_induced, units_topology_eq R, prod_induced_induced,\n      induced_compose, key, ← induced_compose],\n  apply induced_mono,\n  rw ← continuous_iff_le_induced,\n  exact continuous_mul,\nend⟩\nend topological_ring\n\nvariables (K : Type*) [division_ring K] [topological_space K]\n\n/-- A topological division ring is a division ring with a topology where all operations are\n    continuous, including inversion. -/\nclass topological_division_ring extends topological_ring K : Prop :=\n(continuous_inv : ∀ x : K, x ≠ 0 → continuous_at (λ x : K, x⁻¹ : K → K) x)\n\nnamespace topological_division_ring\nopen filter set\n/-!\nIn this section, we show that units of a topological division ring endowed with the\ninduced topology form a topological group. These are not global instances because\none could want another topology on units. To turn on this feature, use:\n\n```lean\nlocal attribute [instance]\ntopological_ring.topological_space_units topological_division_ring.units_top_group\n```\n-/\n\nlocal attribute [instance] topological_ring.topological_space_units\n\n@[priority 100] instance induced_units : topological_ring.induced_units K := ⟨rfl⟩\n\nvariables [topological_division_ring K]\n\nlemma units_top_group : topological_group (units K) :=\n{ continuous_inv := begin\n     have : (coe : units K → K) ∘ (λ x, x⁻¹ : units K → units K) =\n            (λ x, x⁻¹ : K → K) ∘ (coe : units K → K), from funext units.coe_inv',\n     rw continuous_iff_continuous_at,\n     intros x,\n     rw [continuous_at, nhds_induced, nhds_induced, tendsto_iff_comap, comap_comm this],\n     apply comap_mono,\n     rw [← tendsto_iff_comap, units.coe_inv'],\n     exact topological_division_ring.continuous_inv (x : K) x.ne_zero\n   end ,\n  ..topological_ring.top_monoid_units K}\n\nlocal attribute [instance] units_top_group\n\nlemma continuous_units_inv : continuous (λ x : units K, (↑(x⁻¹) : K)) :=\n(topological_ring.induced_units.continuous_coe K).comp topological_group.continuous_inv\n\nend topological_division_ring\n\n\nsection affine_homeomorph\n/-!\nThis section is about affine homeomorphisms from a topological field `𝕜` to itself.\nTechnically it does not require `𝕜` to be a topological field, a topological ring that\nhappens to be a field is enough.\n-/\nvariables {𝕜 : Type*} [field 𝕜] [topological_space 𝕜] [topological_ring 𝕜]\n\n/--\nThe map `λ x, a * x + b`, as a homeomorphism from `𝕜` (a topological field) to itself, when `a ≠ 0`.\n-/\n@[simps]\ndef affine_homeomorph (a b : 𝕜) (h : a ≠ 0) : 𝕜 ≃ₜ 𝕜 :=\n{ to_fun := λ x, a * x + b,\n  inv_fun := λ y, (y - b) / a,\n  left_inv := λ x, by { simp only [add_sub_cancel], exact mul_div_cancel_left x h, },\n  right_inv := λ y, by { simp [mul_div_cancel' _ h], }, }\n\nend affine_homeomorph\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/topology/algebra/field.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.49764269623787255}}
{"text": "import system.io data.list.set\n\nmeta constant io.mkdir (s : string) [io.interface] : io nat\n\nclass has_smul (α β : Type) := (smul : α → β → β)\ndef smul {α β : Type} [has_smul α β] : α → β → β := has_smul.smul\ninfixl ` ⬝ ` := smul\n\ndef pextt {P : Prop} : P → (P = true) := λ Hp, propext (iff_true_intro Hp)\ndef pextf {P : Prop} : ¬ P → (P = false) := λ Hnp, propext (iff.intro (λ Hp, Hnp Hp) (λ Hf, false.rec _ Hf))\n\nnamespace nat\n\nlemma bit1_ne_bit0_eq {n m : ℕ} : (bit1 n ≠ bit0 m) = true := pextt (nat.bit1_ne_bit0 _ _)\nlemma bit0_ne_bit1_eq {n m : ℕ} : (bit0 n ≠ bit1 m) = true := pextt (nat.bit0_ne_bit1 _ _)\n\nlemma bit0_inj_eq {n m : ℕ} : (bit0 n ≠ bit0 m) = (n ≠ m) :=\nbegin\napply propext,\nsplit,\nintros H_ne H_eq,\nsubst H_eq,\nexact H_ne rfl,\nintros H_ne H_eq,\nexact H_ne (nat.bit0_inj H_eq)\nend\n\nlemma bit1_inj_eq {n m : ℕ} : (bit1 n ≠ bit1 m) = (n ≠ m) :=\nbegin\napply propext,\nsplit,\nintros H_ne H_eq,\nsubst H_eq,\nexact H_ne rfl,\nintros H_ne H_eq,\nexact H_ne (nat.bit1_inj H_eq)\nend\n\nlemma zero_ne_bit0_eq {n : ℕ} : (0 ≠ bit0 n) = (n ≠ 0) :=\nbegin\napply propext,\nsplit,\nintros H_ne H_eq,\nsubst H_eq,\nexact H_ne rfl,\napply nat.zero_ne_bit0\nend\n\nlemma bit0_ne_zero_eq {n : ℕ} : (bit0 n ≠ 0) = (n ≠ 0) :=\nbegin\napply propext,\nsplit,\nintros H_ne H_eq,\nsubst H_eq,\nexact H_ne rfl,\napply nat.bit0_ne_zero\nend\n\nlemma one_ne_bit1_eq {n : ℕ} : (1 ≠ bit1 n) = (n ≠ 0) :=\nbegin\napply propext,\nsplit,\nintros H_ne H_eq,\nsubst H_eq,\nexact H_ne rfl,\napply nat.one_ne_bit1\nend\n\nlemma bit1_ne_one_eq {n : ℕ} : (bit1 n ≠ 1) = (n ≠ 0) :=\nbegin\napply propext,\nsplit,\nintros H_ne H_eq,\nsubst H_eq,\nexact H_ne rfl,\napply nat.bit1_ne_one\nend\n\nlemma one_ne_bit0_eq (n : ℕ) : (1 ≠ bit0 n) = true := pextt (nat.one_ne_bit0 _)\nlemma bit0_ne_one_eq (n : ℕ) : (bit0 n ≠ 1) = true := pextt (nat.bit0_ne_one _)\n\nlemma zero_ne_bit1_eq (n : ℕ) : (0 ≠ bit1 n) = true := pextt (nat.zero_ne_bit1 _)\nlemma bit1_ne_zero_eq (n : ℕ) : (bit1 n ≠ 0) = true := pextt (nat.bit1_ne_zero _)\n\nlemma zero_ne_one_eq : (0 ≠ 1) = true := pextt nat.zero_ne_one\nlemma one_ne_zero_eq : (1 ≠ 0) = true := pextt nat.one_ne_zero\n\nend nat\n\nnamespace prod\nsection lt\nuniverses u v\nvariables {A : Type u} [A_deceq : decidable_eq A] [A_lt : has_lt A] [A_dec_lt : decidable_rel (@has_lt.lt A _)]\n          {B : Type v} [B_lt : has_lt B] [B_dec_lt : decidable_rel (@has_lt.lt B _)]\n\ninclude A_deceq A_lt A_dec_lt B_lt B_dec_lt\n\ndef less_than : A × B → A × B → Prop\n| ⟨x₁, y₁⟩ ⟨x₂, y₂⟩ := if x₁ < x₂ then true else (if x₂ < x₁ then false else (y₁ < y₂))\n\ninstance : has_lt (A × B) := ⟨less_than⟩\n\ndef decidable_less_than : ∀ (p q : A × B), decidable (p < q)\n| ⟨x₁, y₁⟩ ⟨x₂, y₂⟩ := show decidable (if x₁ < x₂ then true else (if x₂ < x₁ then false else (y₁ < y₂))), by apply_instance\n\ninstance : decidable_rel (@has_lt.lt (A × B) _) := decidable_less_than\n\nend lt\nend prod\n\nlemma pair_neq_of_neq₁ {X Y : Type} {x₁ x₂ : X} {y₁ y₂ : Y} : x₁ ≠ x₂ → (x₁, y₁) ≠ (x₂, y₂) :=\nassume (H : x₁ ≠ x₂) (H_contra : (x₁, y₁) = (x₂, y₂)),\nby { injection H_contra with Hx Hy, exact H Hx }\n\nnamespace list\nsection lt\nvariables {A : Type*} [A_deceq : decidable_eq A] [A_lt : has_lt A] [A_dec_lt : decidable_rel (@has_lt.lt A _)]\n\ninclude A_deceq A_lt A_dec_lt\n\ndef less_than : list A → list A → Prop\n| []      (y::ys) := true\n| _       []      := false\n| (x::xs) (y::ys) := x < y ∨ (x = y ∧ less_than xs ys)\n\ninstance : has_lt (list A) := ⟨less_than⟩\n\ndef decidable_less_than : ∀ (xs ys : list A), decidable (xs < ys)\n| []      (y::ys) := decidable.true\n| []       []     := decidable.false\n| (x::xs)  []     := decidable.false\n| (x::xs) (y::ys) :=\nshow decidable (x < y ∨ (x = y ∧ less_than xs ys)), from\nhave H_lt : decidable (less_than xs ys), by apply decidable_less_than,\nby apply_instance\n\ninstance : decidable_rel (@has_lt.lt (list A) _) := decidable_less_than\n\nend lt\n\ndef p1 {X Y : Type} : list (X × Y) → list X\n| [] := []\n| (xy::xys) := xy.1 :: p1 xys\n\ndef p2 {X Y : Type} : list (X × Y) → list Y\n| [] := []\n| (xy::xys) := xy.2 :: p2 xys\n\nlemma length_p1_same {X Y : Type} : ∀ (xs : list (X × Y)), length xs^.p1 = length xs\n| []      := rfl\n| (x::xs) := begin dsimp [length, p1], rw length_p1_same end\n\nlemma length_p2_same {X Y : Type} : ∀ (xs : list (X × Y)), length xs^.p2 = length xs\n| []      := rfl\n| (x::xs) := begin dsimp [length, p2], rw length_p2_same end\n\ndef sumr {α : Type} [has_add α] [has_zero α] : list α → α\n| [] := 0\n| (x::xs) := x + sumr xs\n\ndef sumrd {α : Type} [has_add α] (d : α) : list α → α\n| [] := d\n| (x::xs) := x + sumrd xs\n\nlemma sumrd_sumr {α : Type} [add_comm_group α] (d : α) : ∀ (xs : list α), sumrd d xs = d + sumr xs\n| []      := begin dunfold sumrd sumr, rw add_zero end\n| (x::xs) := begin dunfold sumrd sumr, rw sumrd_sumr, rw [-add_assoc, -add_assoc], rw add_comm x d end\n\ndef sumr₁ {α : Type} [has_add α] [has_zero α] : list α → α\n| [] := 0\n| [x] := x\n| (x::y::xs) := x + sumr₁ (y::xs)\n\nlemma sumr_sumr₁ {α : Type} [add_group α] : ∀ (xs : list α), sumr₁ xs = sumr xs\n| [] := rfl\n| [x] := begin dunfold sumr sumr₁, rw add_zero, end\n| (x::y::xs) := begin dunfold sumr sumr₁, rw sumr_sumr₁, reflexivity end\n\ndef prod {α : Type*} [has_mul α] [has_one α] : list α → α :=\nfoldr has_mul.mul 1\n\nlemma append_single {α : Type*} (x : α) (xs : list α) : [x] ++ xs = x :: xs := rfl\n\nlemma append_nil_left {α : Type*} (xs : list α) : [] ++ xs = xs := rfl\n\nlemma in_filter {α : Type*} (P : α → Prop) [decidable_pred P] : Π (xs : list α) (x : α), x ∈ xs → P x → x ∈ filter P xs\n| []      x H_x_in HPx := H_x_in\n| (y::ys) x H_x_in HPx :=\nhave Hx : x = y ∨ x ∈ ys, from iff.mp (mem_cons_iff _ _ _) H_x_in,\nhave Hy : P y ∨ ¬ (P y), from decidable.em _,\nbegin\ndunfold filter,\ncases Hx with H_eq H_in,\n{ subst H_eq, simp [HPx] },\ncases Hy with HPy HnPy,\n{ simp [HPy], exact or.inr (in_filter _ _ H_in HPx) },\n{ simp [HnPy], exact in_filter _ _ H_in HPx }\nend\n\nlemma of_in_filter {α : Type*} (P : α → Prop) [decidable_pred P] : Π (xs : list α) (x : α), x ∈ filter P xs → x ∈ xs ∧ P x\n| []      x H_x_in := false.rec _ (not_mem_nil _ H_x_in)\n| (y::ys) x H_x_in :=\nhave Hy : P y ∨ ¬ (P y), from decidable.em _,\nbegin\ncases Hy with HPy HnPy,\ndunfold filter at H_x_in,\nsimp [HPy] at H_x_in,\nsplit,\n\ncases H_x_in with H_eq H_in,\n{ subst H_eq, apply mem_cons_self },\n{ apply mem_cons_of_mem, exact (of_in_filter _ _ H_in)^.left },\n\ncases H_x_in with H_eq H_in,\n{ subst H_eq, exact HPy  },\n{ exact (of_in_filter _ _ H_in)^.right  },\n\ndunfold filter at H_x_in,\nsimp [HnPy] at H_x_in,\nsplit,\napply mem_cons_of_mem, exact (of_in_filter _ _ H_x_in)^.left,\nexact (of_in_filter _ _ H_x_in)^.right\nend\n\ndef miota : ℕ → ℕ → list ℕ\n| i 0     := []\n| i (k+1) := i :: miota (i+1) k\n\ndef riota : ℕ → list ℕ\n| 0 := []\n| (n+1) := n :: riota n\n\nlemma in_riota_lt : ∀ {idx n : ℕ}, idx ∈ riota n → idx < n\n| idx 0     H_mem := false.rec _ (not_mem_nil (riota 0) H_mem)\n| idx (n+1) H_mem :=\nbegin\ndsimp [riota, list.mem] at H_mem,\ncases H_mem with H_idx_eq H_mem,\n{ rw H_idx_eq, apply nat.lt_succ_self },\napply nat.lt.step,\napply in_riota_lt,\nexact H_mem\nend\n\nlemma map_compose {X Y Z : Type} (f : X → Y) (g : Y → Z) (xs : list X) : map g (map f xs) = map (λ x, g (f x)) xs := by apply map_map\n\nlemma map_congr_fn {X Y : Type} (f g : X → Y) (xs : list X) : f = g → map f xs = map g xs := begin intro H, rw H end\nlemma map_congr_fn_pred {X Y : Type} (f g : X → Y) : Π (xs : list X) (H : ∀ x, x ∈ xs → f x = g x), map f xs = map g xs\n| []      H := rfl\n| (x::xs) H :=\n  show f x :: map f xs = g x :: map g xs, from\n  have H_x : x ∈ x :: xs, by apply mem_cons_self,\n  have H_rest : ∀ x, x ∈ xs → f x = g x,\n    begin intros y H_y_in_xs, apply H, apply mem_cons_of_mem, exact H_y_in_xs end,\n  begin rw H x H_x, rw (map_congr_fn_pred xs H_rest) end\n\ndef dnth {α : Type*} [inhabited α] : list α → nat → α\n| []       n     := default α\n| (a :: l) 0     := a\n| (a :: l) (n+1) := dnth l n\n\nlemma p1_dnth {α β : Type*} [inhabited α] [inhabited β] : ∀ (xs : list (α × β)) (idx : ℕ), (dnth xs idx).1 = dnth (p1 xs) idx\n| []      _       := rfl\n| (x::xs) 0       := rfl\n| (x::xs) (idx+1) := begin dsimp [p1, dnth], apply p1_dnth end\n\nlemma p2_dnth {α β : Type*} [inhabited α] [inhabited β] : ∀ (xs : list (α × β)) (idx : ℕ), (dnth xs idx).2 = dnth (p2 xs) idx\n| []      _       := rfl\n| (x::xs) 0       := rfl\n| (x::xs) (idx+1) := begin dsimp [p2, dnth], apply p2_dnth end\n\ndef at_idx {X : Type} [inhabited X] (xs : list X) (idx : ℕ) (x : X) : Prop :=\n  idx < length xs ∧ x = dnth xs idx\n\ninductive elem_at_idx {X : Type} : Π (xs : list X) (idx : ℕ) (x : X), Prop\n| base : ∀ (xs : list X) (x : X), elem_at_idx (x::xs) 0 x\n| step : ∀ (xs : list X) (x y : X) (idx : ℕ), elem_at_idx xs idx y → elem_at_idx (x::xs) (idx+1) y\n\n\nlemma elem_at_idx_of_at_idx {X : Type} [inhabited X] : ∀ {xs : list X} {idx : ℕ} {x : X},\n  at_idx xs idx x → elem_at_idx xs idx x\n| [] _ _ H_at_idx := false.rec _ (nat.not_lt_zero _ H_at_idx^.left)\n| (x::xs) 0       x₀ H_at_idx := by { dsimp [at_idx, dnth] at H_at_idx, rw H_at_idx^.right, constructor }\n| (x::xs) (idx+1) x₀ H_at_idx :=\nbegin\ndsimp [at_idx, dnth] at H_at_idx,\napply elem_at_idx.step,\napply elem_at_idx_of_at_idx,\napply and.intro,\nexact nat.lt_of_succ_lt_succ H_at_idx^.left,\nexact H_at_idx^.right\nend\n\nlemma at_idx_0 {α : Type*} [inhabited α] {x : α} {xs : list α} : at_idx (x::xs) 0 x :=\nbegin dunfold at_idx, split, exact nat.zero_lt_succ (length xs), reflexivity end\n\nlemma at_idx_inj {α : Type*} [inhabited α] {x x₁ x₂ : α} {xs : list α} : at_idx (x::xs) 0 x₁ → at_idx (x::xs) 0 x₂ → x₁ = x₂ :=\nbegin dunfold at_idx, intros H₁ H₂, rw [H₁^.right, H₂^.right] end\n\nlemma at_idx_of_cons {α : Type*} [inhabited α] {x : α} {xs : list α} {y : α} {idx : ℕ} :\n  at_idx (x::xs) (idx+1) y → at_idx xs idx y :=\nbegin\ndunfold at_idx,\nintro H,\ncases H with H_lt H_dnth,\nsplit,\nexact nat.lt_of_succ_lt_succ H_lt,\nrw H_dnth, reflexivity\nend\n\nlemma at_idx_cons {α : Type*} [inhabited α] {x : α} {xs : list α} {y : α} {idx : ℕ} :\n  at_idx xs idx y → at_idx (x::xs) (idx+1) y :=\nbegin\ndunfold at_idx,\nintro H,\ncases H with H_lt H_dnth,\nsplit,\nexact nat.succ_lt_succ H_lt,\nrw H_dnth, reflexivity\nend\n\nlemma at_idx_p1 {α β : Type} [inhabited α] [inhabited β] {xs : list (α × β)} {x : α × β} {idx : ℕ} :\n  at_idx xs idx x → at_idx xs^.p1 idx x.1 :=\nbegin\nintro H_at_idx,\ncases H_at_idx with H_lt H_eq,\napply and.intro,\nrw length_p1_same, exact H_lt,\nrw H_eq,\napply p1_dnth\nend\n\nlemma at_idx_p2 {α β : Type} [inhabited α] [inhabited β] {xs : list (α × β)} {x : α × β} {idx : ℕ} :\n  at_idx xs idx x → at_idx xs^.p2 idx x.2 :=\nbegin\nintro H_at_idx,\ncases H_at_idx with H_lt H_eq,\napply and.intro,\nrw length_p2_same, exact H_lt,\nrw H_eq,\napply p2_dnth\nend\n\nlemma mem_of_at_idx {α : Type*} [inhabited α] {x : α} {xs : list α} {idx : ℕ} : at_idx xs idx x → x ∈ xs :=\nbegin\nintro H_at_idx,\nassert H_elem_at_idx : elem_at_idx xs idx x, { exact elem_at_idx_of_at_idx H_at_idx },\nclear H_at_idx,\ninduction H_elem_at_idx with xs x xs idx' x y H_elem_at_idx IH,\napply mem_cons_self,\napply mem_cons_of_mem,\nexact IH\nend\n\nlemma at_idx_over {X : Type} [inhabited X] {xs : list X} {idx : ℕ} {x : X} : at_idx xs idx x → ¬ (idx < length xs) → false :=\nassume H_at_idx H_idx_big, H_idx_big H_at_idx^.left\n\ninstance decidable_at_idx {α : Type*} [decidable_eq α] [inhabited α] (xs : list α) (idx : ℕ) (x : α) : decidable (at_idx xs idx x) :=\nif H : idx < length xs ∧ x = dnth xs idx then decidable.is_true H else decidable.is_false H\n\nlemma mem_of_cons_same {α : Type*} {x : α} {xs : list α} : x ∈ x::xs := by { apply or.inl, reflexivity }\n\ndefinition all_prop {α : Type*} (p : α → Prop) (l : list α) : Prop :=\nfoldr (λ a r, p a ∧ r) true l\n\ndef rcons {α : Type*} (a : α) : list α → list α\n| []        := [a]\n| (x :: xs) := x :: (rcons xs)\n\ndef dnth_all {A : Type} [inhabited A] (idxs : list ℕ) (xs : list A) : list A := map (λ idx, dnth xs idx) idxs\n\nlemma mem_not_mem_neq {X : Type*} {x₁ x₂ : X} {xs : list X} : x₁ ∈ xs → x₂ ∉ xs → x₁ ≠ x₂ :=\nbegin\nintros H_in H_nin,\nintro H_eq,\nsubst H_eq,\nexact H_nin H_in\nend\n\nlemma nodup_cons_neq {X : Type} {x₁ x₂ : X} {xs : list X} : x₂ ∈ xs → nodup (x₁ :: xs) → x₁ ≠ x₂ :=\nassume H_in H_nd,\nhave H_nin : x₁ ∉ xs, from not_mem_of_nodup_cons H_nd,\nne.symm $ mem_not_mem_neq H_in H_nin\n\nlemma nodup_at_idx_neq {A : Type} [inhabited A] {x : A} {xs : list A} {y : A} {idx : ℕ} :\n  nodup (x::xs) → at_idx (x::xs) (idx+1) y → y ≠ x :=\nbegin\nintros H_nd H_at_idx,\nnote H_at_idx' := at_idx_of_cons H_at_idx,\nassert H_in_xs : y ∈ xs,\napply mem_of_at_idx H_at_idx',\napply ne.symm,\napply nodup_cons_neq H_in_xs H_nd,\nend\n\nlemma sublist_cons_nil {X : Type*} {xs : list X} {x : X} : ¬ (x :: xs <+ []) :=\nbegin\nintro H_contra,\nnote H := list.eq_nil_of_sublist_nil H_contra,\ninjection H\nend\n\nlemma disjoint_of_sublist_left {α : Type*} {l₁ l₂ l : list α} : l₁ <+ l → disjoint l l₂ → disjoint l₁ l₂ :=\nλ ss d x xinl₁, d (subset_of_sublist ss xinl₁)\n\nlemma disjoint_of_sublist_right {α : Type*} {l₁ l₂ l : list α} : l₂ <+ l → disjoint l₁ l → disjoint l₁ l₂ :=\nλ ss d x xinl xinl₁, d xinl (subset_of_sublist ss xinl₁)\n\nlemma nodup_append_sublist₁ {X : Type*} {ys zs : list X} (xs : list X) : nodup (ys ++ zs) → xs <+ ys → nodup (xs ++ zs) :=\nassume H_nd H_sl,\nhave H_nd_xs : nodup xs, from nodup_of_sublist H_sl (nodup_of_nodup_append_left H_nd),\nhave H_nd_zs : nodup zs, from nodup_of_nodup_append_right H_nd,\nhave H_dj : disjoint xs zs, from disjoint_of_sublist_left H_sl (disjoint_of_nodup_append H_nd),\nnodup_append_of_nodup_of_nodup_of_disjoint H_nd_xs H_nd_zs H_dj\n\nlemma nodup_append_swap {X : Type} {xs₁ xs₂ : list X} {x : X} : nodup (xs₁ ++ (x :: xs₂)) → nodup ((x::xs₁) ++ xs₂) :=\nby apply list.nodup_head\n\nlemma nodup_mem_append₂ {X : Type} {x : X} {xs₁ xs₂ : list X} : nodup (xs₁ ++ xs₂) → x ∈ xs₂ → x ∉ xs₁ :=\nassume (H_nd : nodup (xs₁ ++ xs₂)) (H₂ : x ∈ xs₂) (H₁ : x ∈ xs₁),\nhave H_dj : disjoint xs₁ xs₂, from disjoint_of_nodup_append H_nd,\nH_dj H₁ H₂\n\nlemma nodup_append_cons {X : Type} {xs₁ xs₂ : list X} {x : X} : nodup (xs₁ ++ (x :: xs₂)) → nodup (xs₁ ++ [x]) :=\nassume H_nd,\nhave H_nd₁ : nodup xs₁, from nodup_of_nodup_append_left H_nd,\nhave H_dj : disjoint xs₁ (x :: xs₂), from disjoint_of_nodup_append H_nd,\nhave H_nin : x ∉ xs₁, from disjoint_right H_dj mem_of_cons_same,\nbegin apply nodup_app_comm, simp, apply nodup_cons H_nin H_nd₁ end\n\nlemma nodup_append_cons_rest {X : Type} {xs₁ xs₂ : list X} {x : X} : nodup (xs₁ ++ (x :: xs₂)) → nodup (xs₁ ++ xs₂) :=\nassume H_nd, nodup_of_nodup_cons (nodup_head H_nd)\n\nlemma nodup_append_neq {X : Type} {xs₁ xs₂ : list X} {x₁ x₂ : X} : x₁ ∈ xs₁ → x₂ ∈ xs₂ → nodup (xs₁ ++ xs₂) → x₁ ≠ x₂ :=\nassume H₁_in H₂_in H_nd,\nhave H_dj : disjoint xs₁ xs₂, from disjoint_of_nodup_append H_nd,\nhave H₁_nin : x₁ ∉ xs₂, from disjoint_left H_dj H₁_in,\nne.symm $ mem_not_mem_neq H₂_in H₁_nin\n\nlemma nodup_append_cons_neq {X : Type} {xs : list X} {x₁ x₂ : X} : x₁ ∈ xs → nodup (xs ++ [x₂]) → x₁ ≠ x₂ :=\nassume H₁_in H_nd,\nhave H_nd' : nodup (x₂ :: xs), from nodup_app_comm H_nd,\nhave H₂_nin : x₂ ∉ xs, from not_mem_of_nodup_cons H_nd',\nmem_not_mem_neq H₁_in H₂_nin\n\nlemma nodup_of_append_cons_cons {X : Type} {xs ys : list X} {y₁ y₂ : X} : nodup (xs ++ (y₁ :: y₂ :: ys)) → nodup (xs ++ (y₁ :: ys)) :=\nassume H_nd,\nhave H_nd' : nodup (y₁ :: (xs ++ y₂ :: ys)), from nodup_head H_nd,\nhave H₁_nin : y₁ ∉ xs ++ y₂ :: ys, from not_mem_of_nodup_cons H_nd',\nhave H₁_nin₁ : y₁ ∉ xs, from not_mem_of_not_mem_append_left H₁_nin,\nhave H₁_nin₂ : y₁ ∉ ys, from not_mem_of_not_mem_cons (not_mem_of_not_mem_append_right H₁_nin),\nhave H_nd'' : nodup (xs ++ y₂ :: ys), from nodup_of_nodup_cons H_nd',\nhave H_nd''' : nodup (y₂ :: (xs ++ ys)), from nodup_head H_nd'',\nhave H_nd'''' : nodup (xs ++ ys), from nodup_of_nodup_cons H_nd''',\nnodup_middle (nodup_cons (not_mem_append H₁_nin₁ H₁_nin₂) H_nd'''')\n\nlemma map_filter_congr {α β : Type*} {f g : α → β} {p : α → Prop} [decidable_pred p] :\n  ∀ {xs : list α}, (∀ x, x ∈ xs → p x → f x = g x) → map f (filter p xs) = map g (filter p xs)\n| []      H := rfl\n| (x::xs) H :=\nbegin\ndsimp [map, filter],\nassert H_px_em : p x ∨ ¬ (p x), { exact decidable.em _ },\ncases H_px_em,\n{ simph, apply congr_arg, apply map_filter_congr,\n  intros y H_y_in_xs H_py,\n  exact H y (mem_cons_of_mem _ H_y_in_xs) H_py },\n{ simph, apply map_filter_congr,\n  intros y H_y_in_xs H_py,\n  exact H y (mem_cons_of_mem _ H_y_in_xs) H_py }\nend\n\nlemma filter_congr {α : Type*} {p q : α → Prop} [decidable_pred p] [decidable_pred q] :\n  ∀ {xs : list α}, (∀ x, x ∈ xs → (p x ↔ q x)) → filter p xs = filter q xs\n| [] H := rfl\n\n| (y::ys) H :=\nbegin\ndunfold filter,\nsimp [H y mem_of_cons_same],\ncases (decidable.em (q y)) with Hq Hq,\n{\nsimp [Hq],\nrw filter_congr,\nintros x H_in_ys,\napply H,\napply mem_cons_of_mem,\nexact H_in_ys\n},\n{\nsimp [Hq],\nrw filter_congr,\nintros x H_in_ys,\napply H,\napply mem_cons_of_mem,\nexact H_in_ys\n}\nend\n\nlemma in_riota_cons : ∀ (idx m : ℕ), idx + 1 ∈ riota (m + 1) → idx ∈ riota m\n| 0       0 :=\nbegin\nrw zero_add,\ndunfold riota,\nexact dec_trivial\nend\n\n| idx       (m+1) :=\nbegin\ndunfold riota,\nintro H,\ncases eq_or_mem_of_mem_cons H with H_in H_in,\n{\nassert H_idx_eq_m : idx = m, exact add_right_cancel H_in,\nsubst H_idx_eq_m,\nsimp,\n},\napply list.mem_cons_of_mem,\napply in_riota_cons,\nexact H_in\nend\n\n| idx 0 :=\nbegin\ndunfold riota,\nexact dec_trivial\nend\n\nlemma in_riota_self (idx : ℕ) : idx ∈ riota (idx + 1) := by { dunfold riota, apply mem_of_cons_same }\n\nlemma nin_neq_dnth {α : Type*} [inhabited α] [decidable_eq α] (x : α) : ∀ xs, x ∉ xs → ∀ idx, idx ∈ riota (list.length xs) → x ≠ dnth xs idx\n| []      H_nin idx H_in := begin exfalso, exact not_mem_nil _ H_in end\n\n| (y::ys) H_nin 0       H_in :=\nbegin\ndunfold dnth,\nexact ne_of_not_mem_cons H_nin\nend\n\n| (y::ys) H_nin (idx+1) H_in :=\nbegin\ndunfold dnth,\napply nin_neq_dnth,\nexact list.not_mem_of_not_mem_cons H_nin,\ndunfold riota length at H_in,\napply in_riota_cons,\nexact H_in\nend\n\nlemma lt_length_of_in_riota {α : Type*} : Π (xs : list α) (idx : ℕ), idx ∈ riota (length xs) → idx < length xs\n| [] idx H_in := begin exfalso, exact list.not_mem_nil _ H_in end\n\n| (x::xs) 0 H_in :=\nbegin\ndunfold riota length at H_in,\nexact dec_trivial\nend\n\n| (x::xs) (idx+1) H_in :=\nbegin\ndunfold riota length at H_in,\napply nat.succ_lt_succ,\napply lt_length_of_in_riota,\nexact in_riota_cons _ _ H_in\nend\n\nlemma dnth_mem_of_lt_length {α : Type*} [inhabited α] : Π (xs : list α) (idx : ℕ), idx < length xs → dnth xs idx ∈ xs\n| [] idx H_lt := begin exfalso, exact nat.not_lt_zero _ H_lt end\n\n| (x::xs) 0 H_lt := mem_of_cons_same\n\n| (x::xs) (idx+1) H_lt :=\nbegin\ndunfold dnth,\napply list.mem_cons_of_mem,\napply dnth_mem_of_lt_length,\napply nat.lt_of_succ_lt_succ,\nexact H_lt\nend\n\nlemma filter_false {α : Type*} [decidable_eq α] [inhabited α] : Π (xs : list α), filter (λ x, false) xs = nil\n| [] := rfl\n| (x::xs) := begin dunfold filter, simp [filter_false] end\n\nlemma not_in_filter_of_match_riota {α : Type*} [decidable_eq α] [inhabited α] (x : α) :\n  ∀ (xs : list α), x ∉ xs → filter (λ (idx : ℕ), x = dnth xs idx) (riota (length xs)) = nil :=\nassume xs H_nin,\nhave H : filter (λ (idx : ℕ), x = dnth xs idx) (riota (length xs)) = filter (λ idx : ℕ, false) (riota (length xs)),\nbegin\napply filter_congr,\nintros idx H_in,\nsplit,\nintro H_eq,\nsubst H_eq,\nassert H_x_in : dnth xs idx ∈ xs,\napply dnth_mem_of_lt_length,\napply lt_length_of_in_riota,\nexact H_in,\nexact H_nin H_x_in,\nintro Hf,\nexfalso,\nexact Hf\nend,\nbegin\nrw H,\nrw filter_false\nend\n\nend list\n\nnamespace monad\n\ndef foldrM {M : Type → Type} [m : monad M] {X Y : Type} (f : Y → X → M Y) (init : Y) (xs : list X) : M Y :=\n  list.foldr (λ (x : X) (k : Y → M Y) (y : Y), f y x >>= k) return xs init\n\nend monad\n\n@[simp]\ndef if_is_true {A : Type} (P : Prop) (p : P) (t e : A) :\n  @ite P (is_true p) A t e = t := rfl\n\n@[simp]\ndef if_is_false {A : Type} (P : Prop) (np : ¬ P) (t e : A) :\n  @ite P (is_false np) A t e = e := rfl\n\ndef decidable_and (P Q : Prop) [dP : decidable P] [dQ : decidable Q] : decidable (P ∧ Q) :=\n  match dP, dQ with\n  | is_true p,   is_true q   := is_true (and.intro p q)\n  | is_false np, _           := is_false (λ H : P ∧ Q, np H^.left)\n  | _,           is_false nq := is_false (λ H : P ∧ Q, nq H^.right)\n  end\n\ndef decidable_or (P Q : Prop) [dP : decidable P] [dQ : decidable Q] : decidable (P ∨ Q) :=\n  match dP, dQ with\n  | is_true p,   _           := is_true (or.inl p)\n  | _,           is_true q   := is_true (or.inr q)\n  | is_false np, is_false nq := is_false (λ H : P ∨ Q, or.rec_on H (λ p, np p) (λ q, nq q))\n  end\n", "meta": {"author": "dselsam", "repo": "certigrad", "sha": "c9a06e93f1ec58196d6d3b8563b29868d916727f", "save_path": "github-repos/lean/dselsam-certigrad", "path": "github-repos/lean/dselsam-certigrad/certigrad-c9a06e93f1ec58196d6d3b8563b29868d916727f/src/certigrad/util.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.49764269137825423}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n\nThe `simp_rw` tactic, a mix of `simp` and `rewrite`.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.core\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# The `simp_rw` tactic\n\nThis module defines a tactic `simp_rw` which functions as a mix of `simp` and\n`rw`. Like `rw`, it applies each rewrite rule in the given order, but like\n`simp` it repeatedly applies these rules and also under binders like `∀ x, ...`,\n`∃ x, ...` and `λ x, ...`.\n\n## Implementation notes\n\nThe tactic works by taking each rewrite rule in turn and applying `simp only` to\nit. Arguments to `simp_rw` are of the format used by `rw` and are translated to\ntheir equivalents for `simp`.\n-/\n\nnamespace tactic.interactive\n\n\n/--\n`simp_rw` functions as a mix of `simp` and `rw`. Like `rw`, it applies each\nrewrite rule in the given order, but like `simp` it repeatedly applies these\nrules and also under binders like `∀ x, ...`, `∃ x, ...` and `λ x, ...`.\n\nUsage:\n  - `simp_rw [lemma_1, ..., lemma_n]` will rewrite the goal by applying the\n    lemmas in that order. A lemma preceded by `←` is applied in the reverse direction.\n  - `simp_rw [lemma_1, ..., lemma_n] at h₁ ... hₙ` will rewrite the given hypotheses.\n  - `simp_rw [...] at ⊢ h₁ ... hₙ` rewrites the goal as well as the given hypotheses.\n  - `simp_rw [...] at *` rewrites in the whole context: all hypotheses and the goal.\n\nLemmas passed to `simp_rw` must be expressions that are valid arguments to `simp`.\n\nFor example, neither `simp` nor `rw` can solve the following, but `simp_rw` can:\n```lean\nexample {α β : Type} {f : α → β} {t : set β} : (∀ s, f '' s ⊆ t) = ∀ s : set α, ∀ x ∈ s, x ∈ f ⁻¹' t :=\nby simp_rw [set.image_subset_iff, set.subset_def]\n```\n-/\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/simp_rw_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.4976426903720859}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module order.filter.n_ary\n! leanprover-community/mathlib commit 78f647f8517f021d839a7553d5dc97e79b508dea\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Order.Filter.Prod\n\n/-!\n# N-ary maps of filter\n\nThis file defines the binary and ternary maps of filters. This is mostly useful to define pointwise\noperations on filters.\n\n## Main declarations\n\n* `Filter.map₂`: Binary map of filters.\n* `Filter.map₃`: Ternary map of filters.\n\n## Notes\n\nThis file is very similar to `Data.Set.NAry`, `Data.Finset.NAry` and `Data.Option.NAry`. Please\nkeep them in sync.\n-/\n\n\nopen Function Set\n\nopen Filter\n\nnamespace Filter\n\nvariable {α α' β β' γ γ' δ δ' ε ε' : Type _} {m : α → β → γ} {f f₁ f₂ : Filter α}\n  {g g₁ g₂ : Filter β} {h h₁ h₂ : Filter γ} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {u : Set γ}\n  {v : Set δ} {a : α} {b : β} {c : γ}\n\n/-- The image of a binary function `m : α → β → γ` as a function `Filter α → Filter β → Filter γ`.\nMathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/\ndef map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter γ\n    where\n  sets := { s | ∃ u v, u ∈ f ∧ v ∈ g ∧ image2 m u v ⊆ s }\n  univ_sets := ⟨univ, univ, univ_sets _, univ_sets _, subset_univ _⟩\n  sets_of_superset hs hst :=\n    Exists₂.imp (fun u v => And.imp_right <| And.imp_right fun h => Subset.trans h hst) hs\n  inter_sets := by\n    simp only [exists_prop, Set.mem_setOf_eq, subset_inter_iff]\n    rintro _ _ ⟨s₁, s₂, hs₁, hs₂, hs⟩ ⟨t₁, t₂, ht₁, ht₂, ht⟩\n    exact\n      ⟨s₁ ∩ t₁, s₂ ∩ t₂, inter_sets f hs₁ ht₁, inter_sets g hs₂ ht₂,\n        (image2_subset (inter_subset_left _ _) <| inter_subset_left _ _).trans hs,\n        (image2_subset (inter_subset_right _ _) <| inter_subset_right _ _).trans ht⟩\n#align filter.map₂ Filter.map₂\n\n@[simp]\ntheorem mem_map₂_iff : u ∈ map₂ m f g ↔ ∃ s t, s ∈ f ∧ t ∈ g ∧ image2 m s t ⊆ u :=\n  Iff.rfl\n#align filter.mem_map₂_iff Filter.mem_map₂_iff\n\ntheorem image2_mem_map₂ (hs : s ∈ f) (ht : t ∈ g) : image2 m s t ∈ map₂ m f g :=\n  ⟨_, _, hs, ht, Subset.rfl⟩\n#align filter.image2_mem_map₂ Filter.image2_mem_map₂\n\ntheorem map_prod_eq_map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) :\n    Filter.map (fun p : α × β => m p.1 p.2) (f ×ᶠ g) = map₂ m f g := by\n  ext s\n  simp [mem_prod_iff, prod_subset_iff]\n#align filter.map_prod_eq_map₂ Filter.map_prod_eq_map₂\n\ntheorem map_prod_eq_map₂' (m : α × β → γ) (f : Filter α) (g : Filter β) :\n    Filter.map m (f ×ᶠ g) = map₂ (fun a b => m (a, b)) f g :=\n  map_prod_eq_map₂ (curry m) f g\n#align filter.map_prod_eq_map₂' Filter.map_prod_eq_map₂'\n\n@[simp]\ntheorem map₂_mk_eq_prod (f : Filter α) (g : Filter β) : map₂ Prod.mk f g = f ×ᶠ g := by\n  simp only [← map_prod_eq_map₂, map_id']\n#align filter.map₂_mk_eq_prod Filter.map₂_mk_eq_prod\n\n-- lemma image2_mem_map₂_iff (hm : injective2 m) : image2 m s t ∈ map₂ m f g ↔ s ∈ f ∧ t ∈ g :=\n-- ⟨by { rintro ⟨u, v, hu, hv, h⟩, rw image2_subset_image2_iff hm at h,\n--   exact ⟨mem_of_superset hu h.1, mem_of_superset hv h.2⟩ }, λ h, image2_mem_map₂ h.1 h.2⟩\ntheorem map₂_mono (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : map₂ m f₁ g₁ ≤ map₂ m f₂ g₂ :=\n  fun _ ⟨s, t, hs, ht, hst⟩ => ⟨s, t, hf hs, hg ht, hst⟩\n#align filter.map₂_mono Filter.map₂_mono\n\ntheorem map₂_mono_left (h : g₁ ≤ g₂) : map₂ m f g₁ ≤ map₂ m f g₂ :=\n  map₂_mono Subset.rfl h\n#align filter.map₂_mono_left Filter.map₂_mono_left\n\ntheorem map₂_mono_right (h : f₁ ≤ f₂) : map₂ m f₁ g ≤ map₂ m f₂ g :=\n  map₂_mono h Subset.rfl\n#align filter.map₂_mono_right Filter.map₂_mono_right\n\n@[simp]\ntheorem le_map₂_iff {h : Filter γ} :\n    h ≤ map₂ m f g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → image2 m s t ∈ h :=\n  ⟨fun H _ hs _ ht => H <| image2_mem_map₂ hs ht, fun H _ ⟨_, _, hs, ht, hu⟩ =>\n    mem_of_superset (H hs ht) hu⟩\n#align filter.le_map₂_iff Filter.le_map₂_iff\n\n@[simp]\ntheorem map₂_bot_left : map₂ m ⊥ g = ⊥ :=\n  empty_mem_iff_bot.1 ⟨∅, univ, trivial, univ_mem, image2_empty_left.subset⟩\n#align filter.map₂_bot_left Filter.map₂_bot_left\n\n@[simp]\ntheorem map₂_bot_right : map₂ m f ⊥ = ⊥ :=\n  empty_mem_iff_bot.1 ⟨univ, ∅, univ_mem, trivial, image2_empty_right.subset⟩\n#align filter.map₂_bot_right Filter.map₂_bot_right\n\n@[simp]\ntheorem map₂_eq_bot_iff : map₂ m f g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := by\n  simp only [← empty_mem_iff_bot, mem_map₂_iff, subset_empty_iff, image2_eq_empty_iff]\n  constructor\n  · rintro ⟨s, t, hs, ht, rfl | rfl⟩\n    · exact Or.inl hs\n    · exact Or.inr ht\n  · rintro (h | h)\n    · exact ⟨_, _, h, univ_mem, Or.inl rfl⟩\n    · exact ⟨_, _, univ_mem, h, Or.inr rfl⟩\n#align filter.map₂_eq_bot_iff Filter.map₂_eq_bot_iff\n\n@[simp]\ntheorem map₂_neBot_iff : (map₂ m f g).NeBot ↔ f.NeBot ∧ g.NeBot := by\n  simp_rw [neBot_iff]\n  exact map₂_eq_bot_iff.not.trans not_or\n#align filter.map₂_ne_bot_iff Filter.map₂_neBot_iff\n\ntheorem NeBot.map₂ (hf : f.NeBot) (hg : g.NeBot) : (map₂ m f g).NeBot :=\n  map₂_neBot_iff.2 ⟨hf, hg⟩\n#align filter.ne_bot.map₂ Filter.NeBot.map₂\n\n-- Porting note: Why do I have to specify the `Filter` namespace for `map₂` here?\ntheorem NeBot.of_map₂_left (h : (Filter.map₂ m f g).NeBot) : f.NeBot :=\n  (map₂_neBot_iff.1 h).1\n#align filter.ne_bot.of_map₂_left Filter.NeBot.of_map₂_left\n\ntheorem NeBot.of_map₂_right (h : (Filter.map₂ m f g).NeBot) : g.NeBot :=\n  (map₂_neBot_iff.1 h).2\n#align filter.ne_bot.of_map₂_right Filter.NeBot.of_map₂_right\n\ntheorem map₂_sup_left : map₂ m (f₁ ⊔ f₂) g = map₂ m f₁ g ⊔ map₂ m f₂ g := by\n  ext u\n  constructor\n  · rintro ⟨s, t, ⟨h₁, h₂⟩, ht, hu⟩\n    exact ⟨mem_of_superset (image2_mem_map₂ h₁ ht) hu, mem_of_superset (image2_mem_map₂ h₂ ht) hu⟩\n  · rintro ⟨⟨s₁, t₁, hs₁, ht₁, hu₁⟩, s₂, t₂, hs₂, ht₂, hu₂⟩\n    refine' ⟨s₁ ∪ s₂, t₁ ∩ t₂, union_mem_sup hs₁ hs₂, inter_mem ht₁ ht₂, _⟩\n    rw [image2_union_left]\n    exact\n      union_subset ((image2_subset_left <| inter_subset_left _ _).trans hu₁)\n        ((image2_subset_left <| inter_subset_right _ _).trans hu₂)\n#align filter.map₂_sup_left Filter.map₂_sup_left\n\ntheorem map₂_sup_right : map₂ m f (g₁ ⊔ g₂) = map₂ m f g₁ ⊔ map₂ m f g₂ := by\n  ext u\n  constructor\n  · rintro ⟨s, t, hs, ⟨h₁, h₂⟩, hu⟩\n    exact ⟨mem_of_superset (image2_mem_map₂ hs h₁) hu, mem_of_superset (image2_mem_map₂ hs h₂) hu⟩\n  · rintro ⟨⟨s₁, t₁, hs₁, ht₁, hu₁⟩, s₂, t₂, hs₂, ht₂, hu₂⟩\n    refine' ⟨s₁ ∩ s₂, t₁ ∪ t₂, inter_mem hs₁ hs₂, union_mem_sup ht₁ ht₂, _⟩\n    rw [image2_union_right]\n    exact\n      union_subset ((image2_subset_right <| inter_subset_left _ _).trans hu₁)\n        ((image2_subset_right <| inter_subset_right _ _).trans hu₂)\n#align filter.map₂_sup_right Filter.map₂_sup_right\n\ntheorem map₂_inf_subset_left : map₂ m (f₁ ⊓ f₂) g ≤ map₂ m f₁ g ⊓ map₂ m f₂ g :=\n  le_inf (map₂_mono_right inf_le_left) (map₂_mono_right inf_le_right)\n#align filter.map₂_inf_subset_left Filter.map₂_inf_subset_left\n\ntheorem map₂_inf_subset_right : map₂ m f (g₁ ⊓ g₂) ≤ map₂ m f g₁ ⊓ map₂ m f g₂ :=\n  le_inf (map₂_mono_left inf_le_left) (map₂_mono_left inf_le_right)\n#align filter.map₂_inf_subset_right Filter.map₂_inf_subset_right\n\n@[simp]\ntheorem map₂_pure_left : map₂ m (pure a) g = g.map fun b => m a b :=\n  Filter.ext fun u =>\n    ⟨fun ⟨s, t, hs, ht, hu⟩ =>\n      mem_of_superset (image_mem_map ht) ((image_subset_image2_right <| mem_pure.1 hs).trans hu),\n      fun h => ⟨{a}, _, singleton_mem_pure, h, by rw [image2_singleton_left, image_subset_iff]⟩⟩\n#align filter.map₂_pure_left Filter.map₂_pure_left\n\n@[simp]\ntheorem map₂_pure_right : map₂ m f (pure b) = f.map fun a => m a b :=\n  Filter.ext fun u =>\n    ⟨fun ⟨s, t, hs, ht, hu⟩ =>\n      mem_of_superset (image_mem_map hs) ((image_subset_image2_left <| mem_pure.1 ht).trans hu),\n      fun h => ⟨_, {b}, h, singleton_mem_pure, by rw [image2_singleton_right, image_subset_iff]⟩⟩\n#align filter.map₂_pure_right Filter.map₂_pure_right\n\ntheorem map₂_pure : map₂ m (pure a) (pure b) = pure (m a b) := by rw [map₂_pure_right, map_pure]\n#align filter.map₂_pure Filter.map₂_pure\n\ntheorem map₂_swap (m : α → β → γ) (f : Filter α) (g : Filter β) :\n    map₂ m f g = map₂ (fun a b => m b a) g f := by\n  ext u\n  constructor <;> rintro ⟨s, t, hs, ht, hu⟩ <;> refine' ⟨t, s, ht, hs, by rwa [image2_swap]⟩\n#align filter.map₂_swap Filter.map₂_swap\n\n@[simp]\ntheorem map₂_left (h : g.NeBot) : map₂ (fun x _ => x) f g = f := by\n  ext u\n  refine' ⟨_, fun hu => ⟨_, _, hu, univ_mem, (image2_left <| h.nonempty_of_mem univ_mem).subset⟩⟩\n  rintro ⟨s, t, hs, ht, hu⟩\n  rw [image2_left (h.nonempty_of_mem ht)] at hu\n  exact mem_of_superset hs hu\n#align filter.map₂_left Filter.map₂_left\n\n@[simp]\ntheorem map₂_right (h : f.NeBot) : map₂ (fun _ y => y) f g = g := by rw [map₂_swap, map₂_left h]\n#align filter.map₂_right Filter.map₂_right\n\n/-- The image of a ternary function `m : α → β → γ → δ` as a function\n`Filter α → Filter β → Filter γ → Filter δ`. Mathematically this should be thought of as the image\nof the corresponding function `α × β × γ → δ`. -/\ndef map₃ (m : α → β → γ → δ) (f : Filter α) (g : Filter β) (h : Filter γ) : Filter δ\n    where\n  sets := { s | ∃ u v w, u ∈ f ∧ v ∈ g ∧ w ∈ h ∧ image3 m u v w ⊆ s }\n  univ_sets := ⟨univ, univ, univ, univ_sets _, univ_sets _, univ_sets _, subset_univ _⟩\n  sets_of_superset hs hst :=\n    Exists₃.imp\n      (fun u v w => And.imp_right <| And.imp_right <| And.imp_right fun h => Subset.trans h hst) hs\n  inter_sets := by\n    simp only [exists_prop, mem_setOf_eq, subset_inter_iff]\n    rintro _ _ ⟨s₁, s₂, s₃, hs₁, hs₂, hs₃, hs⟩ ⟨t₁, t₂, t₃, ht₁, ht₂, ht₃, ht⟩\n    exact\n      ⟨s₁ ∩ t₁, s₂ ∩ t₂, s₃ ∩ t₃, inter_mem hs₁ ht₁, inter_mem hs₂ ht₂, inter_mem hs₃ ht₃,\n        (image3_mono (inter_subset_left _ _) (inter_subset_left _ _) <| inter_subset_left _ _).trans\n          hs,\n        (image3_mono (inter_subset_right _ _) (inter_subset_right _ _) <|\n              inter_subset_right _ _).trans\n          ht⟩\n#align filter.map₃ Filter.map₃\n\ntheorem map₂_map₂_left (m : δ → γ → ε) (n : α → β → δ) :\n    map₂ m (map₂ n f g) h = map₃ (fun a b c => m (n a b) c) f g h := by\n  ext w\n  constructor\n  · rintro ⟨s, t, ⟨u, v, hu, hv, hs⟩, ht, hw⟩\n    refine' ⟨u, v, t, hu, hv, ht, _⟩\n    rw [← image2_image2_left]\n    exact (image2_subset_right hs).trans hw\n  · rintro ⟨s, t, u, hs, ht, hu, hw⟩\n    exact ⟨_, u, image2_mem_map₂ hs ht, hu, by rwa [image2_image2_left]⟩\n#align filter.map₂_map₂_left Filter.map₂_map₂_left\n\ntheorem map₂_map₂_right (m : α → δ → ε) (n : β → γ → δ) :\n    map₂ m f (map₂ n g h) = map₃ (fun a b c => m a (n b c)) f g h := by\n  ext w\n  constructor\n  · rintro ⟨s, t, hs, ⟨u, v, hu, hv, ht⟩, hw⟩\n    refine' ⟨s, u, v, hs, hu, hv, _⟩\n    rw [← image2_image2_right]\n    exact (image2_subset_left ht).trans hw\n  · rintro ⟨s, t, u, hs, ht, hu, hw⟩\n    exact ⟨s, _, hs, image2_mem_map₂ ht hu, by rwa [image2_image2_right]⟩\n#align filter.map₂_map₂_right Filter.map₂_map₂_right\n\ntheorem map_map₂ (m : α → β → γ) (n : γ → δ) :\n    (map₂ m f g).map n = map₂ (fun a b => n (m a b)) f g := by\n  rw [← map_prod_eq_map₂, ← map_prod_eq_map₂, map_map]; rfl\n#align filter.map_map₂ Filter.map_map₂\n\ntheorem map₂_map_left (m : γ → β → δ) (n : α → γ) :\n    map₂ m (f.map n) g = map₂ (fun a b => m (n a) b) f g := by\n  rw [← map_prod_eq_map₂, ← map_prod_eq_map₂, ← @map_id _ g, prod_map_map_eq, map_map, map_id]; rfl\n#align filter.map₂_map_left Filter.map₂_map_left\n\ntheorem map₂_map_right (m : α → γ → δ) (n : β → γ) :\n    map₂ m f (g.map n) = map₂ (fun a b => m a (n b)) f g := by\n  rw [map₂_swap, map₂_map_left, map₂_swap]\n#align filter.map₂_map_right Filter.map₂_map_right\n\n@[simp]\ntheorem map₂_curry (m : α × β → γ) (f : Filter α) (g : Filter β) :\n    map₂ (curry m) f g = (f ×ᶠ g).map m :=\n  (map_prod_eq_map₂' _  _ _).symm\n#align filter.map₂_curry Filter.map₂_curry\n\n@[simp]\ntheorem map_uncurry_prod (m : α → β → γ) (f : Filter α) (g : Filter β) :\n    (f ×ᶠ g).map (uncurry m) = map₂ m f g :=\n  (map₂_curry (uncurry m) f g).symm\n#align filter.map_uncurry_prod Filter.map_uncurry_prod\n\n/-!\n### Algebraic replacement rules\n\nA collection of lemmas to transfer associativity, commutativity, distributivity, ... of operations\nto the associativity, commutativity, distributivity, ... of `Filter.map₂` of those operations.\n\nThe proof pattern is `map₂_lemma operation_lemma`. For example, `map₂_comm mul_comm` proves that\n`map₂ (*) f g = map₂ (*) g f` in a `comm_semigroup`.\n-/\n\n\ntheorem map₂_assoc {m : δ → γ → ε} {n : α → β → δ} {m' : α → ε' → ε} {n' : β → γ → ε'}\n    {h : Filter γ} (h_assoc : ∀ a b c, m (n a b) c = m' a (n' b c)) :\n    map₂ m (map₂ n f g) h = map₂ m' f (map₂ n' g h) := by\n  simp only [map₂_map₂_left, map₂_map₂_right, h_assoc]\n#align filter.map₂_assoc Filter.map₂_assoc\n\ntheorem map₂_comm {n : β → α → γ} (h_comm : ∀ a b, m a b = n b a) : map₂ m f g = map₂ n g f :=\n  (map₂_swap _ _ _).trans <| by simp_rw [h_comm]\n#align filter.map₂_comm Filter.map₂_comm\n\ntheorem map₂_left_comm {m : α → δ → ε} {n : β → γ → δ} {m' : α → γ → δ'} {n' : β → δ' → ε}\n    (h_left_comm : ∀ a b c, m a (n b c) = n' b (m' a c)) :\n    map₂ m f (map₂ n g h) = map₂ n' g (map₂ m' f h) := by\n  rw [map₂_swap m', map₂_swap m]\n  exact map₂_assoc fun _ _ _ => h_left_comm _ _ _\n#align filter.map₂_left_comm Filter.map₂_left_comm\n\ntheorem map₂_right_comm {m : δ → γ → ε} {n : α → β → δ} {m' : α → γ → δ'} {n' : δ' → β → ε}\n    (h_right_comm : ∀ a b c, m (n a b) c = n' (m' a c) b) :\n    map₂ m (map₂ n f g) h = map₂ n' (map₂ m' f h) g := by\n  rw [map₂_swap n, map₂_swap n']\n  exact map₂_assoc fun _ _ _ => h_right_comm _ _ _\n#align filter.map₂_right_comm Filter.map₂_right_comm\n\ntheorem map_map₂_distrib {n : γ → δ} {m' : α' → β' → δ} {n₁ : α → α'} {n₂ : β → β'}\n    (h_distrib : ∀ a b, n (m a b) = m' (n₁ a) (n₂ b)) :\n    (map₂ m f g).map n = map₂ m' (f.map n₁) (g.map n₂) := by\n  simp_rw [map_map₂, map₂_map_left, map₂_map_right, h_distrib]\n#align filter.map_map₂_distrib Filter.map_map₂_distrib\n\n/-- Symmetric statement to `Filter.map₂_map_left_comm`. -/\ntheorem map_map₂_distrib_left {n : γ → δ} {m' : α' → β → δ} {n' : α → α'}\n    (h_distrib : ∀ a b, n (m a b) = m' (n' a) b) : (map₂ m f g).map n = map₂ m' (f.map n') g :=\n  map_map₂_distrib h_distrib\n#align filter.map_map₂_distrib_left Filter.map_map₂_distrib_left\n\n/-- Symmetric statement to `Filter.map_map₂_right_comm`. -/\ntheorem map_map₂_distrib_right {n : γ → δ} {m' : α → β' → δ} {n' : β → β'}\n    (h_distrib : ∀ a b, n (m a b) = m' a (n' b)) : (map₂ m f g).map n = map₂ m' f (g.map n') :=\n  map_map₂_distrib h_distrib\n#align filter.map_map₂_distrib_right Filter.map_map₂_distrib_right\n\n/-- Symmetric statement to `Filter.map_map₂_distrib_left`. -/\ntheorem map₂_map_left_comm {m : α' → β → γ} {n : α → α'} {m' : α → β → δ} {n' : δ → γ}\n    (h_left_comm : ∀ a b, m (n a) b = n' (m' a b)) : map₂ m (f.map n) g = (map₂ m' f g).map n' :=\n  (map_map₂_distrib_left fun a b => (h_left_comm a b).symm).symm\n#align filter.map₂_map_left_comm Filter.map₂_map_left_comm\n\n/-- Symmetric statement to `Filter.map_map₂_distrib_right`. -/\ntheorem map_map₂_right_comm {m : α → β' → γ} {n : β → β'} {m' : α → β → δ} {n' : δ → γ}\n    (h_right_comm : ∀ a b, m a (n b) = n' (m' a b)) : map₂ m f (g.map n) = (map₂ m' f g).map n' :=\n  (map_map₂_distrib_right fun a b => (h_right_comm a b).symm).symm\n#align filter.map_map₂_right_comm Filter.map_map₂_right_comm\n\n/-- The other direction does not hold because of the `f`-`f` cross terms on the RHS. -/\ntheorem map₂_distrib_le_left {m : α → δ → ε} {n : β → γ → δ} {m₁ : α → β → β'} {m₂ : α → γ → γ'}\n    {n' : β' → γ' → ε} (h_distrib : ∀ a b c, m a (n b c) = n' (m₁ a b) (m₂ a c)) :\n    map₂ m f (map₂ n g h) ≤ map₂ n' (map₂ m₁ f g) (map₂ m₂ f h) := by\n  rintro s ⟨t₁, t₂, ⟨u₁, v, hu₁, hv, ht₁⟩, ⟨u₂, w, hu₂, hw, ht₂⟩, hs⟩\n  refine' ⟨u₁ ∩ u₂, _, inter_mem hu₁ hu₂, image2_mem_map₂ hv hw, _⟩\n  refine' (image2_distrib_subset_left h_distrib).trans ((image2_subset _ _).trans hs)\n  · exact (image2_subset_right <| inter_subset_left _ _).trans ht₁\n  · exact (image2_subset_right <| inter_subset_right _ _).trans ht₂\n#align filter.map₂_distrib_le_left Filter.map₂_distrib_le_left\n\n/-- The other direction does not hold because of the `h`-`h` cross terms on the RHS. -/\n\n\ntheorem map_map₂_antidistrib {n : γ → δ} {m' : β' → α' → δ} {n₁ : β → β'} {n₂ : α → α'}\n    (h_antidistrib : ∀ a b, n (m a b) = m' (n₁ b) (n₂ a)) :\n    (map₂ m f g).map n = map₂ m' (g.map n₁) (f.map n₂) := by\n  rw [map₂_swap m]\n  exact map_map₂_distrib fun _ _ => h_antidistrib _ _\n#align filter.map_map₂_antidistrib Filter.map_map₂_antidistrib\n\n/-- Symmetric statement to `Filter.map₂_map_left_anticomm`. -/\ntheorem map_map₂_antidistrib_left {n : γ → δ} {m' : β' → α → δ} {n' : β → β'}\n    (h_antidistrib : ∀ a b, n (m a b) = m' (n' b) a) : (map₂ m f g).map n = map₂ m' (g.map n') f :=\n  map_map₂_antidistrib h_antidistrib\n#align filter.map_map₂_antidistrib_left Filter.map_map₂_antidistrib_left\n\n/-- Symmetric statement to `Filter.map_map₂_right_anticomm`. -/\ntheorem map_map₂_antidistrib_right {n : γ → δ} {m' : β → α' → δ} {n' : α → α'}\n    (h_antidistrib : ∀ a b, n (m a b) = m' b (n' a)) : (map₂ m f g).map n = map₂ m' g (f.map n') :=\n  map_map₂_antidistrib h_antidistrib\n#align filter.map_map₂_antidistrib_right Filter.map_map₂_antidistrib_right\n\n/-- Symmetric statement to `Filter.map_map₂_antidistrib_left`. -/\ntheorem map₂_map_left_anticomm {m : α' → β → γ} {n : α → α'} {m' : β → α → δ} {n' : δ → γ}\n    (h_left_anticomm : ∀ a b, m (n a) b = n' (m' b a)) :\n    map₂ m (f.map n) g = (map₂ m' g f).map n' :=\n  (map_map₂_antidistrib_left fun a b => (h_left_anticomm b a).symm).symm\n#align filter.map₂_map_left_anticomm Filter.map₂_map_left_anticomm\n\n/-- Symmetric statement to `Filter.map_map₂_antidistrib_right`. -/\ntheorem map_map₂_right_anticomm {m : α → β' → γ} {n : β → β'} {m' : β → α → δ} {n' : δ → γ}\n    (h_right_anticomm : ∀ a b, m a (n b) = n' (m' b a)) :\n    map₂ m f (g.map n) = (map₂ m' g f).map n' :=\n  (map_map₂_antidistrib_right fun a b => (h_right_anticomm b a).symm).symm\n#align filter.map_map₂_right_anticomm Filter.map_map₂_right_anticomm\n\n/-- If `a` is a left identity for `f : α → β → β`, then `pure a` is a left identity for\n`Filter.map₂ f`. -/\ntheorem map₂_left_identity {f : α → β → β} {a : α} (h : ∀ b, f a b = b) (l : Filter β) :\n    map₂ f (pure a) l = l := by rw [map₂_pure_left, show f a = id from funext h, map_id]\n#align filter.map₂_left_identity Filter.map₂_left_identity\n\n/-- If `b` is a right identity for `f : α → β → α`, then `pure b` is a right identity for\n`Filter.map₂ f`. -/\ntheorem map₂_right_identity {f : α → β → α} {b : β} (h : ∀ a, f a b = a) (l : Filter α) :\n    map₂ f l (pure b) = l := by rw [map₂_pure_right, funext h, map_id']\n#align filter.map₂_right_identity Filter.map₂_right_identity\n\nend Filter\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Order/Filter/NAry.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.49764268651863586}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Kenny Lau\n-/\nimport data.list.big_operators.basic\nimport algebra.order.monoid.min_max\n\n/-!\n# zip & unzip\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides results about `list.zip_with`, `list.zip` and `list.unzip` (definitions are in\ncore Lean).\n`zip_with f l₁ l₂` applies `f : α → β → γ` pointwise to a list `l₁ : list α` and `l₂ : list β`. It\napplies, until one of the lists is exhausted. For example,\n`zip_with f [0, 1, 2] [6.28, 31] = [f 0 6.28, f 1 31]`.\n`zip` is `zip_with` applied to `prod.mk`. For example,\n`zip [a₁, a₂] [b₁, b₂, b₃] = [(a₁, b₁), (a₂, b₂)]`.\n`unzip` undoes `zip`. For example, `unzip [(a₁, b₁), (a₂, b₂)] = ([a₁, a₂], [b₁, b₂])`.\n-/\n\nuniverse u\n\nopen nat\n\nnamespace list\nvariables {α : Type u} {β γ δ ε : Type*}\n\n@[simp] theorem zip_with_cons_cons (f : α → β → γ) (a : α) (b : β) (l₁ : list α) (l₂ : list β) :\n  zip_with f (a :: l₁) (b :: l₂) = f a b :: zip_with f l₁ l₂ := rfl\n\n@[simp] theorem zip_cons_cons (a : α) (b : β) (l₁ : list α) (l₂ : list β) :\n  zip (a :: l₁) (b :: l₂) = (a, b) :: zip l₁ l₂ := rfl\n\n@[simp] theorem zip_with_nil_left (f : α → β → γ) (l) : zip_with f [] l = [] := rfl\n\n@[simp] theorem zip_with_nil_right (f : α → β → γ) (l)  : zip_with f l [] = [] :=\nby cases l; refl\n\n@[simp] lemma zip_with_eq_nil_iff {f : α → β → γ} {l l'} :\n  zip_with f l l' = [] ↔ l = [] ∨ l' = [] :=\nby { cases l; cases l'; simp }\n\n@[simp] theorem zip_nil_left (l : list α) : zip ([] : list β) l = [] := rfl\n\n@[simp] theorem zip_nil_right (l : list α) : zip l ([] : list β) = [] :=\nzip_with_nil_right _ l\n\n@[simp] theorem zip_swap : ∀ (l₁ : list α) (l₂ : list β),\n  (zip l₁ l₂).map prod.swap = zip l₂ l₁\n| []      l₂      := (zip_nil_right _).symm\n| l₁      []      := by rw zip_nil_right; refl\n| (a::l₁) (b::l₂) := by simp only [zip_cons_cons, map_cons, zip_swap l₁ l₂, prod.swap_prod_mk];\n    split; refl\n\n@[simp] theorem length_zip_with (f : α → β → γ) : ∀  (l₁ : list α) (l₂ : list β),\n   length (zip_with f l₁ l₂) = min (length l₁) (length l₂)\n| []      l₂      := rfl\n| l₁      []      := by simp only [length, min_zero, zip_with_nil_right]\n| (a::l₁) (b::l₂) := by simp [length, zip_cons_cons, length_zip_with l₁ l₂, min_add_add_right]\n\n@[simp] theorem length_zip : ∀ (l₁ : list α) (l₂ : list β),\n   length (zip l₁ l₂) = min (length l₁) (length l₂) :=\nlength_zip_with _\n\ntheorem all₂_zip_with {f : α → β → γ} {p : γ → Prop} :\n  ∀ {l₁ : list α} {l₂ : list β} (h : length l₁ = length l₂),\n  all₂ p (zip_with f l₁ l₂) ↔ forall₂ (λ x y, p (f x y)) l₁ l₂\n| [] [] _ := by simp\n| (a :: l₁) (b :: l₂) h :=\n  by { simp only [length_cons, add_left_inj] at h, simp [all₂_zip_with h] }\n\nlemma lt_length_left_of_zip_with {f : α → β → γ} {i : ℕ} {l : list α} {l' : list β}\n  (h : i < (zip_with f l l').length) :\n  i < l.length :=\nby { rw [length_zip_with, lt_min_iff] at h, exact h.left }\n\nlemma lt_length_right_of_zip_with {f : α → β → γ} {i : ℕ} {l : list α} {l' : list β}\n  (h : i < (zip_with f l l').length) :\n  i < l'.length :=\nby { rw [length_zip_with, lt_min_iff] at h, exact h.right }\n\nlemma lt_length_left_of_zip {i : ℕ} {l : list α} {l' : list β} (h : i < (zip l l').length) :\n  i < l.length :=\nlt_length_left_of_zip_with h\n\nlemma lt_length_right_of_zip {i : ℕ} {l : list α} {l' : list β} (h : i < (zip l l').length) :\n  i < l'.length :=\nlt_length_right_of_zip_with h\n\ntheorem zip_append : ∀ {l₁ r₁ : list α} {l₂ r₂ : list β} (h : length l₁ = length l₂),\n   zip (l₁ ++ r₁) (l₂ ++ r₂) = zip l₁ l₂ ++ zip r₁ r₂\n| []      r₁ l₂      r₂ h := by simp only [eq_nil_of_length_eq_zero h.symm]; refl\n| l₁      r₁ []      r₂ h := by simp only [eq_nil_of_length_eq_zero h]; refl\n| (a::l₁) r₁ (b::l₂) r₂ h := by simp only [cons_append, zip_cons_cons, zip_append (succ.inj h)];\n    split; refl\n\ntheorem zip_map (f : α → γ) (g : β → δ) : ∀ (l₁ : list α) (l₂ : list β),\n   zip (l₁.map f) (l₂.map g) = (zip l₁ l₂).map (prod.map f g)\n| []      l₂      := rfl\n| l₁      []      := by simp only [map, zip_nil_right]\n| (a::l₁) (b::l₂) := by simp only [map, zip_cons_cons, zip_map l₁ l₂, prod.map]; split; refl\n\ntheorem zip_map_left (f : α → γ) (l₁ : list α) (l₂ : list β) :\n   zip (l₁.map f) l₂ = (zip l₁ l₂).map (prod.map f id) :=\nby rw [← zip_map, map_id]\n\ntheorem zip_map_right (f : β → γ) (l₁ : list α) (l₂ : list β) :\n   zip l₁ (l₂.map f) = (zip l₁ l₂).map (prod.map id f) :=\nby rw [← zip_map, map_id]\n\n@[simp] lemma zip_with_map {μ}\n  (f : γ → δ → μ) (g : α → γ) (h : β → δ) (as : list α) (bs : list β) :\n  zip_with f (as.map g) (bs.map h) =\n  zip_with (λ a b, f (g a) (h b)) as bs :=\nbegin\n  induction as generalizing bs,\n  { simp },\n  { cases bs; simp * }\nend\n\nlemma zip_with_map_left\n  (f : α → β → γ) (g : δ → α) (l : list δ) (l' : list β) :\n  zip_with f (l.map g) l' = zip_with (f ∘ g) l l' :=\nby { convert (zip_with_map f g id l l'), exact eq.symm (list.map_id _) }\n\nlemma zip_with_map_right\n  (f : α → β → γ) (l : list α) (g : δ → β) (l' : list δ) :\n  zip_with f l (l'.map g) = zip_with (λ x, f x ∘ g) l l' :=\nby { convert (list.zip_with_map f id g l l'), exact eq.symm (list.map_id _) }\n\ntheorem zip_map' (f : α → β) (g : α → γ) : ∀ (l : list α),\n   zip (l.map f) (l.map g) = l.map (λ a, (f a, g a))\n| []     := rfl\n| (a::l) := by simp only [map, zip_cons_cons, zip_map' l]; split; refl\n\nlemma map_zip_with {δ : Type*} (f : α → β) (g : γ → δ → α) (l : list γ) (l' : list δ) :\n  map f (zip_with g l l') = zip_with (λ x y, f (g x y)) l l' :=\nbegin\n  induction l with hd tl hl generalizing l',\n  { simp },\n  { cases l',\n    { simp },\n    { simp [hl] } }\nend\n\ntheorem mem_zip {a b} : ∀ {l₁ : list α} {l₂ : list β},\n   (a, b) ∈ zip l₁ l₂ → a ∈ l₁ ∧ b ∈ l₂\n| (_::l₁) (_::l₂) (or.inl rfl) := ⟨or.inl rfl, or.inl rfl⟩\n| (a'::l₁) (b'::l₂) (or.inr h) := by split; simp only [mem_cons_iff, or_true, mem_zip h]\n\ntheorem map_fst_zip : ∀ (l₁ : list α) (l₂ : list β),\n  l₁.length ≤ l₂.length →\n  map prod.fst (zip l₁ l₂) = l₁\n| [] bs _ := rfl\n| (a :: as) (b :: bs) h := by { simp at h, simp! * }\n| (a :: as) [] h := by { simp at h, contradiction }\n\ntheorem map_snd_zip : ∀ (l₁ : list α) (l₂ : list β),\n  l₂.length ≤ l₁.length →\n  map prod.snd (zip l₁ l₂) = l₂\n| _ [] _ := by { rw zip_nil_right, refl }\n| [] (b :: bs) h := by { simp at h, contradiction }\n| (a :: as) (b :: bs) h := by { simp at h, simp! * }\n\n@[simp] theorem unzip_nil : unzip (@nil (α × β)) = ([], []) := rfl\n\n@[simp] theorem unzip_cons (a : α) (b : β) (l : list (α × β)) :\n   unzip ((a, b) :: l) = (a :: (unzip l).1, b :: (unzip l).2) :=\nby rw unzip; cases unzip l; refl\n\ntheorem unzip_eq_map : ∀ (l : list (α × β)), unzip l = (l.map prod.fst, l.map prod.snd)\n| []            := rfl\n| ((a, b) :: l) := by simp only [unzip_cons, map_cons, unzip_eq_map l]\n\ntheorem unzip_left (l : list (α × β)) : (unzip l).1 = l.map prod.fst :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_right (l : list (α × β)) : (unzip l).2 = l.map prod.snd :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_swap (l : list (α × β)) : unzip (l.map prod.swap) = (unzip l).swap :=\nby simp only [unzip_eq_map, map_map]; split; refl\n\ntheorem zip_unzip : ∀ (l : list (α × β)), zip (unzip l).1 (unzip l).2 = l\n| []            := rfl\n| ((a, b) :: l) := by simp only [unzip_cons, zip_cons_cons, zip_unzip l]; split; refl\n\ntheorem unzip_zip_left : ∀ {l₁ : list α} {l₂ : list β}, length l₁ ≤ length l₂ →\n  (unzip (zip l₁ l₂)).1 = l₁\n| []      l₂      h := rfl\n| l₁      []      h := by rw eq_nil_of_length_eq_zero (nat.eq_zero_of_le_zero h); refl\n| (a::l₁) (b::l₂) h := by simp only [zip_cons_cons, unzip_cons,\n    unzip_zip_left (le_of_succ_le_succ h)]; split; refl\n\ntheorem unzip_zip_right {l₁ : list α} {l₂ : list β} (h : length l₂ ≤ length l₁) :\n  (unzip (zip l₁ l₂)).2 = l₂ :=\nby rw [← zip_swap, unzip_swap]; exact unzip_zip_left h\n\ntheorem unzip_zip {l₁ : list α} {l₂ : list β} (h : length l₁ = length l₂) :\n  unzip (zip l₁ l₂) = (l₁, l₂) :=\nby rw [← @prod.mk.eta _ _ (unzip (zip l₁ l₂)),\n  unzip_zip_left (le_of_eq h), unzip_zip_right (ge_of_eq h)]\n\nlemma zip_of_prod {l : list α} {l' : list β} {lp : list (α × β)}\n  (hl : lp.map prod.fst = l) (hr : lp.map prod.snd = l') :\n  lp = l.zip l' :=\nby rw [←hl, ←hr, ←zip_unzip lp, ←unzip_left, ←unzip_right, zip_unzip, zip_unzip]\n\nlemma map_prod_left_eq_zip {l : list α} (f : α → β) : l.map (λ x, (x, f x)) = l.zip (l.map f) :=\nby { rw ←zip_map', congr, exact map_id _ }\n\n\n\nlemma zip_with_comm (f : α → β → γ) : ∀ (la : list α) (lb : list β),\n  zip_with f la lb = zip_with (λ b a, f a b) lb la\n| [] _ := (list.zip_with_nil_right _ _).symm\n| (a :: as) [] := rfl\n| (a :: as) (b :: bs) := congr_arg _ (zip_with_comm as bs)\n\n@[congr]\nlemma zip_with_congr (f g : α → β → γ) (la : list α) (lb : list β)\n  (h : list.forall₂ (λ a b, f a b = g a b) la lb) :\n  zip_with f la lb = zip_with g la lb :=\nbegin\n  induction h with a b as bs hfg habs ih,\n  { refl },\n  { exact congr_arg2 _ hfg ih }\nend\n\nlemma zip_with_comm_of_comm (f : α → α → β) (comm : ∀ (x y : α), f x y = f y x) (l l' : list α) :\n  zip_with f l l' = zip_with f l' l :=\nby { rw zip_with_comm, simp only [comm] }\n\n@[simp]\nlemma zip_with_same (f : α → α → δ) : ∀ (l : list α), zip_with f l l = l.map (λ a, f a a)\n| [] := rfl\n| (x :: xs) := congr_arg _ (zip_with_same xs)\n\nlemma zip_with_zip_with_left (f : δ → γ → ε) (g : α → β → δ) :\n  ∀ (la : list α) (lb : list β) (lc : list γ),\n    zip_with f (zip_with g la lb) lc = zip_with3 (λ a b c, f (g a b) c) la lb lc\n| [] _ _ := rfl\n| (a :: as) [] _ := rfl\n| (a :: as) (b :: bs) [] := rfl\n| (a :: as) (b :: bs) (c :: cs) := congr_arg (cons _) $ zip_with_zip_with_left as bs cs\n\nlemma zip_with_zip_with_right (f : α → δ → ε) (g : β → γ → δ) :\n  ∀ (la : list α) (lb : list β) (lc : list γ),\n    zip_with f la (zip_with g lb lc) = zip_with3 (λ a b c, f a (g b c)) la lb lc\n| [] _ _ := rfl\n| (a :: as) [] _ := rfl\n| (a :: as) (b :: bs) [] := rfl\n| (a :: as) (b :: bs) (c :: cs) := congr_arg (cons _) $ zip_with_zip_with_right as bs cs\n\n@[simp]\nlemma zip_with3_same_left (f : α → α → β → γ) : ∀ (la : list α) (lb : list β),\n  zip_with3 f la la lb = zip_with (λ a b, f a a b) la lb\n| [] _ := rfl\n| (a :: as) [] := rfl\n| (a :: as) (b :: bs) := congr_arg (cons _) $ zip_with3_same_left as bs\n\n@[simp]\nlemma zip_with3_same_mid (f : α → β → α → γ) : ∀ (la : list α) (lb : list β),\n  zip_with3 f la lb la = zip_with (λ a b, f a b a) la lb\n| [] _ := rfl\n| (a :: as) [] := rfl\n| (a :: as) (b :: bs) := congr_arg (cons _) $ zip_with3_same_mid as bs\n\n@[simp]\nlemma zip_with3_same_right (f : α → β → β → γ) : ∀ (la : list α) (lb : list β),\n  zip_with3 f la lb lb = zip_with (λ a b, f a b b) la lb\n| [] _ := rfl\n| (a :: as) [] := rfl\n| (a :: as) (b :: bs) := congr_arg (cons _) $ zip_with3_same_right as bs\n\ninstance (f : α → α → β) [is_symm_op α β f] : is_symm_op (list α) (list β) (zip_with f) :=\n⟨zip_with_comm_of_comm f is_symm_op.symm_op⟩\n\n@[simp] theorem length_revzip (l : list α) : length (revzip l) = length l :=\nby simp only [revzip, length_zip, length_reverse, min_self]\n\n@[simp] theorem unzip_revzip (l : list α) : (revzip l).unzip = (l, l.reverse) :=\nunzip_zip (length_reverse l).symm\n\n@[simp] theorem revzip_map_fst (l : list α) : (revzip l).map prod.fst = l :=\nby rw [← unzip_left, unzip_revzip]\n\n@[simp] theorem revzip_map_snd (l : list α) : (revzip l).map prod.snd = l.reverse :=\nby rw [← unzip_right, unzip_revzip]\n\ntheorem reverse_revzip (l : list α) : reverse l.revzip = revzip l.reverse :=\nby rw [← zip_unzip.{u u} (revzip l).reverse, unzip_eq_map]; simp; simp [revzip]\n\ntheorem revzip_swap (l : list α) : (revzip l).map prod.swap = revzip l.reverse :=\nby simp [revzip]\n\nlemma nth_zip_with (f : α → β → γ) (l₁ : list α) (l₂ : list β) (i : ℕ) :\n  (zip_with f l₁ l₂).nth i = ((l₁.nth i).map f).bind (λ g, (l₂.nth i).map g) :=\nbegin\n  induction l₁ generalizing l₂ i,\n  { simp [zip_with, (<*>)] },\n  { cases l₂; simp only [zip_with, has_seq.seq, functor.map, nth, option.map_none'],\n    { cases ((l₁_hd :: l₁_tl).nth i); refl },\n    { cases i; simp only [option.map_some', nth, option.some_bind', *] } }\nend\n\nlemma nth_zip_with_eq_some {α β γ} (f : α → β → γ) (l₁ : list α) (l₂ : list β) (z : γ) (i : ℕ) :\n  (zip_with f l₁ l₂).nth i = some z ↔ ∃ x y, l₁.nth i = some x ∧ l₂.nth i = some y ∧ f x y = z :=\nbegin\n  induction l₁ generalizing l₂ i,\n  { simp [zip_with] },\n  { cases l₂; simp only [zip_with, nth, exists_false, and_false, false_and],\n    cases i; simp *, },\nend\n\nlemma nth_zip_eq_some (l₁ : list α) (l₂ : list β) (z : α × β) (i : ℕ) :\n  (zip l₁ l₂).nth i = some z ↔ l₁.nth i = some z.1 ∧ l₂.nth i = some z.2 :=\nbegin\n  cases z,\n  rw [zip, nth_zip_with_eq_some], split,\n  { rintro ⟨x, y, h₀, h₁, h₂⟩, cc },\n  { rintro ⟨h₀, h₁⟩, exact ⟨_,_,h₀,h₁,rfl⟩ }\nend\n\n@[simp] lemma nth_le_zip_with {f : α → β → γ} {l : list α} {l' : list β} {i : ℕ}\n  {h : i < (zip_with f l l').length} :\n  (zip_with f l l').nth_le i h =\n    f (l.nth_le i (lt_length_left_of_zip_with h)) (l'.nth_le i (lt_length_right_of_zip_with h)) :=\nbegin\n  rw [←option.some_inj, ←nth_le_nth, nth_zip_with_eq_some],\n  refine ⟨l.nth_le i (lt_length_left_of_zip_with h), l'.nth_le i (lt_length_right_of_zip_with h),\n          nth_le_nth _, _⟩,\n  simp only [←nth_le_nth, eq_self_iff_true, and_self]\nend\n\n@[simp] lemma nth_le_zip {l : list α} {l' : list β} {i : ℕ} {h : i < (zip l l').length} :\n  (zip l l').nth_le i h =\n    (l.nth_le i (lt_length_left_of_zip h), l'.nth_le i (lt_length_right_of_zip h)) :=\nnth_le_zip_with\n\nlemma mem_zip_inits_tails {l : list α} {init tail : list α} :\n  (init, tail) ∈ zip l.inits l.tails ↔ init ++ tail = l :=\nbegin\n  induction l generalizing init tail;\n    simp_rw [tails, inits, zip_cons_cons],\n  { simp },\n  { split; rw [mem_cons_iff, zip_map_left, mem_map, prod.exists],\n    { rintros (⟨rfl, rfl⟩ | ⟨_, _, h, rfl, rfl⟩),\n      { simp },\n      { simp [l_ih.mp h], }, },\n    { cases init,\n      { simp },\n      { intro h,\n        right,\n        use [init_tl, tail],\n        simp * at *, }, }, },\nend\n\nlemma map_uncurry_zip_eq_zip_with\n  (f : α → β → γ) (l : list α) (l' : list β) :\n  map (function.uncurry f) (l.zip l') = zip_with f l l' :=\nbegin\n  induction l with hd tl hl generalizing l',\n  { simp },\n  { cases l' with hd' tl',\n    { simp },\n    { simp [hl] } }\nend\n\n@[simp] lemma sum_zip_with_distrib_left {γ : Type*} [semiring γ]\n  (f : α → β → γ) (n : γ) (l : list α) (l' : list β) :\n  (l.zip_with (λ x y, n * f x y) l').sum = n * (l.zip_with f l').sum :=\nbegin\n  induction l with hd tl hl generalizing f n l',\n  { simp },\n  { cases l' with hd' tl',\n    { simp, },\n    { simp [hl, mul_add] } }\nend\n\nsection distrib\n\n/-! ### Operations that can be applied before or after a `zip_with` -/\n\nvariables (f : α → β → γ) (l : list α) (l' : list β) (n : ℕ)\n\nlemma zip_with_distrib_take :\n  (zip_with f l l').take n = zip_with f (l.take n) (l'.take n) :=\nbegin\n  induction l with hd tl hl generalizing l' n,\n  { simp },\n  { cases l',\n    { simp },\n    { cases n,\n      { simp },\n      { simp [hl] } } }\nend\n\nlemma zip_with_distrib_drop :\n  (zip_with f l l').drop n = zip_with f (l.drop n) (l'.drop n) :=\nbegin\n  induction l with hd tl hl generalizing l' n,\n  { simp },\n  { cases l',\n    { simp },\n    { cases n,\n      { simp },\n      { simp [hl] } } }\nend\n\nlemma zip_with_distrib_tail :\n  (zip_with f l l').tail = zip_with f l.tail l'.tail :=\nby simp_rw [←drop_one, zip_with_distrib_drop]\n\nlemma zip_with_append (f : α → β → γ) (l la : list α) (l' lb : list β) (h : l.length = l'.length) :\n  zip_with f (l ++ la) (l' ++ lb) = zip_with f l l' ++ zip_with f la lb :=\nbegin\n  induction l with hd tl hl generalizing l',\n  { have : l' = [] := eq_nil_of_length_eq_zero (by simpa using h.symm),\n    simp [this], },\n  { cases l',\n    { simpa using h },\n    { simp only [add_left_inj, length] at h,\n      simp [hl _ h] } }\nend\n\nlemma zip_with_distrib_reverse (h : l.length = l'.length) :\n  (zip_with f l l').reverse = zip_with f l.reverse l'.reverse :=\nbegin\n  induction l with hd tl hl generalizing l',\n  { simp },\n  { cases l' with hd' tl',\n    { simp },\n    { simp only [add_left_inj, length] at h,\n      have : tl.reverse.length = tl'.reverse.length := by simp [h],\n      simp [hl _ h, zip_with_append _ _ _ _ _ this] } }\nend\n\nend distrib\n\nsection comm_monoid\n\nvariables [comm_monoid α]\n\n@[to_additive]\nlemma prod_mul_prod_eq_prod_zip_with_mul_prod_drop : ∀ (L L' : list α), L.prod * L'.prod =\n  (zip_with (*) L L').prod * (L.drop L'.length).prod * (L'.drop L.length).prod\n| [] ys := by simp [nat.zero_le]\n| xs [] := by simp [nat.zero_le]\n| (x :: xs) (y :: ys) := begin\n  simp only [drop, length, zip_with_cons_cons, prod_cons],\n  rw [mul_assoc x, mul_comm xs.prod, mul_assoc y, mul_comm ys.prod,\n    prod_mul_prod_eq_prod_zip_with_mul_prod_drop xs ys, mul_assoc, mul_assoc, mul_assoc, mul_assoc]\nend\n\n@[to_additive]\nlemma prod_mul_prod_eq_prod_zip_with_of_length_eq (L L' : list α) (h : L.length = L'.length) :\n  L.prod * L'.prod = (zip_with (*) L L').prod :=\n(prod_mul_prod_eq_prod_zip_with_mul_prod_drop L L').trans (by simp [h])\n\nend comm_monoid\n\nend list\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/list/zip.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.49764268651863586}}
{"text": "/-\nCopyright (c) 2022 Kyle Miller. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kyle Miller\n\n! This file was ported from Lean 3 source module data.finite.basic\n! leanprover-community/mathlib commit 327c3c0d9232d80e250dc8f65e7835b82b266ea5\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Fintype.Powerset\nimport Mathbin.Data.Fintype.Prod\nimport Mathbin.Data.Fintype.Sigma\nimport Mathbin.Data.Fintype.Sum\nimport Mathbin.Data.Fintype.Vector\n\n/-!\n# Finite types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we prove some theorems about `finite` and provide some instances. This typeclass is a\n`Prop`-valued counterpart of the typeclass `fintype`. See more details in the file where `finite` is\ndefined.\n\n## Main definitions\n\n* `fintype.finite`, `finite.of_fintype` creates a `finite` instance from a `fintype` instance. The\n  former lemma takes `fintype α` as an explicit argument while the latter takes it as an instance\n  argument.\n* `fintype.of_finite` noncomputably creates a `fintype` instance from a `finite` instance.\n\n## Implementation notes\n\nThere is an apparent duplication of many `fintype` instances in this module,\nhowever they follow a pattern: if a `fintype` instance depends on `decidable`\ninstances or other `fintype` instances, then we need to \"lower\" the instance\nto be a `finite` instance by removing the `decidable` instances and switching\nthe `fintype` instances to `finite` instances. These are precisely the ones\nthat cannot be inferred using `finite.of_fintype`. (However, when using\n`open_locale classical` or the `classical` tactic the instances relying only\non `decidable` instances will give `finite` instances.) In the future we might\nconsider writing automation to create these \"lowered\" instances.\n\n## Tags\n\nfiniteness, finite types\n-/\n\n\nnoncomputable section\n\nopen Classical\n\nvariable {α β γ : Type _}\n\nnamespace Finite\n\n#print Finite.of_subsingleton /-\n-- see Note [lower instance priority]\ninstance (priority := 100) of_subsingleton {α : Sort _} [Subsingleton α] : Finite α :=\n  of_injective (Function.const α ()) <| Function.injective_of_subsingleton _\n#align finite.of_subsingleton Finite.of_subsingleton\n-/\n\n#print Finite.prop /-\n-- Higher priority for `Prop`s\n@[nolint instance_priority]\ninstance prop (p : Prop) : Finite p :=\n  Finite.of_subsingleton\n#align finite.prop Finite.prop\n-/\n\ninstance [Finite α] [Finite β] : Finite (α × β) :=\n  by\n  haveI := Fintype.ofFinite α\n  haveI := Fintype.ofFinite β\n  infer_instance\n\ninstance {α β : Sort _} [Finite α] [Finite β] : Finite (PProd α β) :=\n  of_equiv _ Equiv.pprodEquivProdPLift.symm\n\n#print Finite.prod_left /-\ntheorem prod_left (β) [Finite (α × β)] [Nonempty β] : Finite α :=\n  of_surjective (Prod.fst : α × β → α) Prod.fst_surjective\n#align finite.prod_left Finite.prod_left\n-/\n\n#print Finite.prod_right /-\ntheorem prod_right (α) [Finite (α × β)] [Nonempty α] : Finite β :=\n  of_surjective (Prod.snd : α × β → β) Prod.snd_surjective\n#align finite.prod_right Finite.prod_right\n-/\n\ninstance [Finite α] [Finite β] : Finite (Sum α β) :=\n  by\n  haveI := Fintype.ofFinite α\n  haveI := Fintype.ofFinite β\n  infer_instance\n\n#print Finite.sum_left /-\ntheorem sum_left (β) [Finite (Sum α β)] : Finite α :=\n  of_injective (Sum.inl : α → Sum α β) Sum.inl_injective\n#align finite.sum_left Finite.sum_left\n-/\n\n#print Finite.sum_right /-\ntheorem sum_right (α) [Finite (Sum α β)] : Finite β :=\n  of_injective (Sum.inr : β → Sum α β) Sum.inr_injective\n#align finite.sum_right Finite.sum_right\n-/\n\ninstance {β : α → Type _} [Finite α] [∀ a, Finite (β a)] : Finite (Σa, β a) :=\n  by\n  letI := Fintype.ofFinite α\n  letI := fun a => Fintype.ofFinite (β a)\n  infer_instance\n\ninstance {ι : Sort _} {π : ι → Sort _} [Finite ι] [∀ i, Finite (π i)] : Finite (Σ'i, π i) :=\n  of_equiv _ (Equiv.psigmaEquivSigmaPLift π).symm\n\ninstance [Finite α] : Finite (Set α) :=\n  by\n  cases nonempty_fintype α\n  infer_instance\n\nend Finite\n\n#print Subtype.finite /-\n/-- This instance also provides `[finite s]` for `s : set α`. -/\ninstance Subtype.finite {α : Sort _} [Finite α] {p : α → Prop} : Finite { x // p x } :=\n  Finite.of_injective coe Subtype.coe_injective\n#align subtype.finite Subtype.finite\n-/\n\n#print Pi.finite /-\ninstance Pi.finite {α : Sort _} {β : α → Sort _} [Finite α] [∀ a, Finite (β a)] :\n    Finite (∀ a, β a) := by\n  haveI := Fintype.ofFinite (PLift α)\n  haveI := fun a => Fintype.ofFinite (PLift (β a))\n  exact\n    Finite.of_equiv (∀ a : PLift α, PLift (β (Equiv.plift a)))\n      (Equiv.piCongr Equiv.plift fun _ => Equiv.plift)\n#align pi.finite Pi.finite\n-/\n\n#print Vector.finite /-\ninstance Vector.finite {α : Type _} [Finite α] {n : ℕ} : Finite (Vector α n) :=\n  by\n  haveI := Fintype.ofFinite α\n  infer_instance\n#align vector.finite Vector.finite\n-/\n\n#print Quot.finite /-\ninstance Quot.finite {α : Sort _} [Finite α] (r : α → α → Prop) : Finite (Quot r) :=\n  Finite.of_surjective _ (surjective_quot_mk r)\n#align quot.finite Quot.finite\n-/\n\n#print Quotient.finite /-\ninstance Quotient.finite {α : Sort _} [Finite α] (s : Setoid α) : Finite (Quotient s) :=\n  Quot.finite _\n#align quotient.finite Quotient.finite\n-/\n\n/- warning: function.embedding.finite -> Function.Embedding.finite is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u2} β], Finite.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u2} β], Finite.{max (max 1 u2) u1} (Function.Embedding.{u1, u2} α β)\nCase conversion may be inaccurate. Consider using '#align function.embedding.finite Function.Embedding.finiteₓ'. -/\ninstance Function.Embedding.finite {α β : Sort _} [Finite β] : Finite (α ↪ β) :=\n  by\n  cases' isEmpty_or_nonempty (α ↪ β) with _ h\n  · infer_instance\n  · refine' h.elim fun f => _\n    haveI : Finite α := Finite.of_injective _ f.injective\n    exact Finite.of_injective _ FunLike.coe_injective\n#align function.embedding.finite Function.Embedding.finite\n\n/- warning: equiv.finite_right -> Equiv.finite_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u2} β], Finite.{max 1 (imax u1 u2) (imax u2 u1)} (Equiv.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u2} β], Finite.{max (max 1 u2) u1} (Equiv.{u1, u2} α β)\nCase conversion may be inaccurate. Consider using '#align equiv.finite_right Equiv.finite_rightₓ'. -/\ninstance Equiv.finite_right {α β : Sort _} [Finite β] : Finite (α ≃ β) :=\n  Finite.of_injective Equiv.toEmbedding fun e₁ e₂ h => Equiv.ext <| by convert FunLike.congr_fun h\n#align equiv.finite_right Equiv.finite_right\n\n/- warning: equiv.finite_left -> Equiv.finite_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u1} α], Finite.{max 1 (imax u1 u2) (imax u2 u1)} (Equiv.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u1} α], Finite.{max (max 1 u2) u1} (Equiv.{u1, u2} α β)\nCase conversion may be inaccurate. Consider using '#align equiv.finite_left Equiv.finite_leftₓ'. -/\ninstance Equiv.finite_left {α β : Sort _} [Finite α] : Finite (α ≃ β) :=\n  Finite.of_equiv _ ⟨Equiv.symm, Equiv.symm, Equiv.symm_symm, Equiv.symm_symm⟩\n#align equiv.finite_left Equiv.finite_left\n\ninstance [Finite α] {n : ℕ} : Finite (Sym α n) :=\n  by\n  haveI := Fintype.ofFinite α\n  infer_instance\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finite/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.7401743563075447, "lm_q1q2_score": 0.4976426826651858}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.limits.shapes.reflexive\n! leanprover-community/mathlib commit 97eab48559068f3d6313da387714ef25768fb730\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Shapes.Equalizers\nimport Mathbin.CategoryTheory.Limits.Shapes.KernelPair\n\n/-!\n# Reflexive coequalizers\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define reflexive pairs as a pair of morphisms which have a common section. We say a category has\nreflexive coequalizers if it has coequalizers of all reflexive pairs.\nReflexive coequalizers often enjoy nicer properties than general coequalizers, and feature heavily\nin some versions of the monadicity theorem.\n\nWe also give some examples of reflexive pairs: for an adjunction `F ⊣ G` with counit `ε`, the pair\n`(FGε_B, ε_FGB)` is reflexive. If a pair `f,g` is a kernel pair for some morphism, then it is\nreflexive.\n\n# TODO\n* If `C` has binary coproducts and reflexive coequalizers, then it has all coequalizers.\n* If `T` is a monad on cocomplete category `C`, then `algebra T` is cocomplete iff it has reflexive\n  coequalizers.\n* If `C` is locally cartesian closed and has reflexive coequalizers, then it has images: in fact\n  regular epi (and hence strong epi) images.\n-/\n\n\nnamespace CategoryTheory\n\nuniverse v v₂ u u₂\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\nvariable {A B : C} {f g : A ⟶ B}\n\n#print CategoryTheory.IsReflexivePair /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`common_section] [] -/\n/-- The pair `f g : A ⟶ B` is reflexive if there is a morphism `B ⟶ A` which is a section for both.\n-/\nclass IsReflexivePair (f g : A ⟶ B) : Prop where\n  common_section : ∃ s : B ⟶ A, s ≫ f = 𝟙 B ∧ s ≫ g = 𝟙 B\n#align category_theory.is_reflexive_pair CategoryTheory.IsReflexivePair\n-/\n\n#print CategoryTheory.IsCoreflexivePair /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`common_retraction] [] -/\n/--\nThe pair `f g : A ⟶ B` is coreflexive if there is a morphism `B ⟶ A` which is a retraction for both.\n-/\nclass IsCoreflexivePair (f g : A ⟶ B) : Prop where\n  common_retraction : ∃ s : B ⟶ A, f ≫ s = 𝟙 A ∧ g ≫ s = 𝟙 A\n#align category_theory.is_coreflexive_pair CategoryTheory.IsCoreflexivePair\n-/\n\n#print CategoryTheory.IsReflexivePair.mk' /-\ntheorem IsReflexivePair.mk' (s : B ⟶ A) (sf : s ≫ f = 𝟙 B) (sg : s ≫ g = 𝟙 B) :\n    IsReflexivePair f g :=\n  ⟨⟨s, sf, sg⟩⟩\n#align category_theory.is_reflexive_pair.mk' CategoryTheory.IsReflexivePair.mk'\n-/\n\n#print CategoryTheory.IsCoreflexivePair.mk' /-\ntheorem IsCoreflexivePair.mk' (s : B ⟶ A) (fs : f ≫ s = 𝟙 A) (gs : g ≫ s = 𝟙 A) :\n    IsCoreflexivePair f g :=\n  ⟨⟨s, fs, gs⟩⟩\n#align category_theory.is_coreflexive_pair.mk' CategoryTheory.IsCoreflexivePair.mk'\n-/\n\n#print CategoryTheory.commonSection /-\n/-- Get the common section for a reflexive pair. -/\nnoncomputable def commonSection (f g : A ⟶ B) [IsReflexivePair f g] : B ⟶ A :=\n  (IsReflexivePair.common_section f g).some\n#align category_theory.common_section CategoryTheory.commonSection\n-/\n\n#print CategoryTheory.section_comp_left /-\n@[simp, reassoc.1]\ntheorem section_comp_left (f g : A ⟶ B) [IsReflexivePair f g] : commonSection f g ≫ f = 𝟙 B :=\n  (IsReflexivePair.common_section f g).choose_spec.1\n#align category_theory.section_comp_left CategoryTheory.section_comp_left\n-/\n\n#print CategoryTheory.section_comp_right /-\n@[simp, reassoc.1]\ntheorem section_comp_right (f g : A ⟶ B) [IsReflexivePair f g] : commonSection f g ≫ g = 𝟙 B :=\n  (IsReflexivePair.common_section f g).choose_spec.2\n#align category_theory.section_comp_right CategoryTheory.section_comp_right\n-/\n\n#print CategoryTheory.commonRetraction /-\n/-- Get the common retraction for a coreflexive pair. -/\nnoncomputable def commonRetraction (f g : A ⟶ B) [IsCoreflexivePair f g] : B ⟶ A :=\n  (IsCoreflexivePair.common_retraction f g).some\n#align category_theory.common_retraction CategoryTheory.commonRetraction\n-/\n\n#print CategoryTheory.left_comp_retraction /-\n@[simp, reassoc.1]\ntheorem left_comp_retraction (f g : A ⟶ B) [IsCoreflexivePair f g] :\n    f ≫ commonRetraction f g = 𝟙 A :=\n  (IsCoreflexivePair.common_retraction f g).choose_spec.1\n#align category_theory.left_comp_retraction CategoryTheory.left_comp_retraction\n-/\n\n#print CategoryTheory.right_comp_retraction /-\n@[simp, reassoc.1]\ntheorem right_comp_retraction (f g : A ⟶ B) [IsCoreflexivePair f g] :\n    g ≫ commonRetraction f g = 𝟙 A :=\n  (IsCoreflexivePair.common_retraction f g).choose_spec.2\n#align category_theory.right_comp_retraction CategoryTheory.right_comp_retraction\n-/\n\n#print CategoryTheory.IsKernelPair.isReflexivePair /-\n/-- If `f,g` is a kernel pair for some morphism `q`, then it is reflexive. -/\ntheorem IsKernelPair.isReflexivePair {R : C} {f g : R ⟶ A} {q : A ⟶ B} (h : IsKernelPair q f g) :\n    IsReflexivePair f g :=\n  IsReflexivePair.mk' _ (h.lift' _ _ rfl).2.1 (h.lift' _ _ _).2.2\n#align category_theory.is_kernel_pair.is_reflexive_pair CategoryTheory.IsKernelPair.isReflexivePair\n-/\n\n#print CategoryTheory.IsReflexivePair.swap /-\n-- This shouldn't be an instance as it would instantly loop.\n/-- If `f,g` is reflexive, then `g,f` is reflexive. -/\ntheorem IsReflexivePair.swap [IsReflexivePair f g] : IsReflexivePair g f :=\n  IsReflexivePair.mk' _ (section_comp_right f g) (section_comp_left f g)\n#align category_theory.is_reflexive_pair.swap CategoryTheory.IsReflexivePair.swap\n-/\n\n#print CategoryTheory.IsCoreflexivePair.swap /-\n-- This shouldn't be an instance as it would instantly loop.\n/-- If `f,g` is coreflexive, then `g,f` is coreflexive. -/\ntheorem IsCoreflexivePair.swap [IsCoreflexivePair f g] : IsCoreflexivePair g f :=\n  IsCoreflexivePair.mk' _ (right_comp_retraction f g) (left_comp_retraction f g)\n#align category_theory.is_coreflexive_pair.swap CategoryTheory.IsCoreflexivePair.swap\n-/\n\nvariable {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G)\n\n/-- For an adjunction `F ⊣ G` with counit `ε`, the pair `(FGε_B, ε_FGB)` is reflexive. -/\ninstance (B : D) :\n    IsReflexivePair (F.map (G.map (adj.counit.app B))) (adj.counit.app (F.obj (G.obj B))) :=\n  IsReflexivePair.mk' (F.map (adj.Unit.app (G.obj B)))\n    (by\n      rw [← F.map_comp, adj.right_triangle_components]\n      apply F.map_id)\n    adj.left_triangle_components\n\nnamespace Limits\n\nvariable (C)\n\n#print CategoryTheory.Limits.HasReflexiveCoequalizers /-\n/-- `C` has reflexive coequalizers if it has coequalizers for every reflexive pair. -/\nclass HasReflexiveCoequalizers : Prop where\n  has_coeq : ∀ ⦃A B : C⦄ (f g : A ⟶ B) [IsReflexivePair f g], HasCoequalizer f g\n#align category_theory.limits.has_reflexive_coequalizers CategoryTheory.Limits.HasReflexiveCoequalizers\n-/\n\n#print CategoryTheory.Limits.HasCoreflexiveEqualizers /-\n/-- `C` has coreflexive equalizers if it has equalizers for every coreflexive pair. -/\nclass HasCoreflexiveEqualizers : Prop where\n  has_eq : ∀ ⦃A B : C⦄ (f g : A ⟶ B) [IsCoreflexivePair f g], HasEqualizer f g\n#align category_theory.limits.has_coreflexive_equalizers CategoryTheory.Limits.HasCoreflexiveEqualizers\n-/\n\nattribute [instance] has_reflexive_coequalizers.has_coeq\n\nattribute [instance] has_coreflexive_equalizers.has_eq\n\n#print CategoryTheory.Limits.hasCoequalizer_of_common_section /-\ntheorem hasCoequalizer_of_common_section [HasReflexiveCoequalizers C] {A B : C} {f g : A ⟶ B}\n    (r : B ⟶ A) (rf : r ≫ f = 𝟙 _) (rg : r ≫ g = 𝟙 _) : HasCoequalizer f g :=\n  by\n  letI := is_reflexive_pair.mk' r rf rg\n  infer_instance\n#align category_theory.limits.has_coequalizer_of_common_section CategoryTheory.Limits.hasCoequalizer_of_common_section\n-/\n\n#print CategoryTheory.Limits.hasEqualizer_of_common_retraction /-\ntheorem hasEqualizer_of_common_retraction [HasCoreflexiveEqualizers C] {A B : C} {f g : A ⟶ B}\n    (r : B ⟶ A) (fr : f ≫ r = 𝟙 _) (gr : g ≫ r = 𝟙 _) : HasEqualizer f g :=\n  by\n  letI := is_coreflexive_pair.mk' r fr gr\n  infer_instance\n#align category_theory.limits.has_equalizer_of_common_retraction CategoryTheory.Limits.hasEqualizer_of_common_retraction\n-/\n\n#print CategoryTheory.Limits.hasReflexiveCoequalizers_of_hasCoequalizers /-\n/-- If `C` has coequalizers, then it has reflexive coequalizers. -/\ninstance (priority := 100) hasReflexiveCoequalizers_of_hasCoequalizers [HasCoequalizers C] :\n    HasReflexiveCoequalizers C where has_coeq A B f g i := by infer_instance\n#align category_theory.limits.has_reflexive_coequalizers_of_has_coequalizers CategoryTheory.Limits.hasReflexiveCoequalizers_of_hasCoequalizers\n-/\n\n#print CategoryTheory.Limits.hasCoreflexiveEqualizers_of_hasEqualizers /-\n/-- If `C` has equalizers, then it has coreflexive equalizers. -/\ninstance (priority := 100) hasCoreflexiveEqualizers_of_hasEqualizers [HasEqualizers C] :\n    HasCoreflexiveEqualizers C where has_eq A B f g i := by infer_instance\n#align category_theory.limits.has_coreflexive_equalizers_of_has_equalizers CategoryTheory.Limits.hasCoreflexiveEqualizers_of_hasEqualizers\n-/\n\nend Limits\n\nopen Limits\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Shapes/Reflexive.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.740174367770488, "lm_q1q2_score": 0.4976426806528491}}
{"text": "/-\nCopyright (c) 2018 Reid Barton All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Scott Morrison, David Wärn\n\n! This file was ported from Lean 3 source module category_theory.groupoid\n! leanprover-community/mathlib commit e97cf15cd1aec9bd5c193b2ffac5a6dc9118912b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.FullSubcategory\nimport Mathbin.CategoryTheory.Products.Basic\nimport Mathbin.CategoryTheory.Pi.Basic\nimport Mathbin.CategoryTheory.Category.Basic\nimport Mathbin.Combinatorics.Quiver.ConnectedComponent\n\n/-!\n# Groupoids\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define `groupoid` as a typeclass extending `category`,\nasserting that all morphisms have inverses.\n\nThe instance `is_iso.of_groupoid (f : X ⟶ Y) : is_iso f` means that you can then write\n`inv f` to access the inverse of any morphism `f`.\n\n`groupoid.iso_equiv_hom : (X ≅ Y) ≃ (X ⟶ Y)` provides the equivalence between\nisomorphisms and morphisms in a groupoid.\n\nWe provide a (non-instance) constructor `groupoid.of_is_iso` from an existing category\nwith `is_iso f` for every `f`.\n\n## See also\n\nSee also `category_theory.core` for the groupoid of isomorphisms in a category.\n-/\n\n\nnamespace CategoryTheory\n\nuniverse v v₂ u u₂\n\n#print CategoryTheory.Groupoid /-\n-- morphism levels before object levels. See note [category_theory universes].\n/-- A `groupoid` is a category such that all morphisms are isomorphisms. -/\nclass Groupoid (obj : Type u) extends Category.{v} obj : Type max u (v + 1) where\n  inv : ∀ {X Y : obj}, (X ⟶ Y) → (Y ⟶ X)\n  inv_comp' : ∀ {X Y : obj} (f : X ⟶ Y), comp (inv f) f = id Y := by obviously\n  comp_inv' : ∀ {X Y : obj} (f : X ⟶ Y), comp f (inv f) = id X := by obviously\n#align category_theory.groupoid CategoryTheory.Groupoid\n-/\n\nrestate_axiom groupoid.inv_comp'\n\nrestate_axiom groupoid.comp_inv'\n\n#print CategoryTheory.LargeGroupoid /-\n/-- A `large_groupoid` is a groupoid\nwhere the objects live in `Type (u+1)` while the morphisms live in `Type u`.\n-/\nabbrev LargeGroupoid (C : Type (u + 1)) : Type (u + 1) :=\n  Groupoid.{u} C\n#align category_theory.large_groupoid CategoryTheory.LargeGroupoid\n-/\n\n#print CategoryTheory.SmallGroupoid /-\n/-- A `small_groupoid` is a groupoid\nwhere the objects and morphisms live in the same universe.\n-/\nabbrev SmallGroupoid (C : Type u) : Type (u + 1) :=\n  Groupoid.{u} C\n#align category_theory.small_groupoid CategoryTheory.SmallGroupoid\n-/\n\nsection\n\nvariable {C : Type u} [Groupoid.{v} C] {X Y : C}\n\n#print CategoryTheory.IsIso.of_groupoid /-\n-- see Note [lower instance priority]\ninstance (priority := 100) IsIso.of_groupoid (f : X ⟶ Y) : IsIso f :=\n  ⟨⟨Groupoid.inv f, Groupoid.comp_inv f, Groupoid.inv_comp f⟩⟩\n#align category_theory.is_iso.of_groupoid CategoryTheory.IsIso.of_groupoid\n-/\n\n#print CategoryTheory.Groupoid.inv_eq_inv /-\n@[simp]\ntheorem Groupoid.inv_eq_inv (f : X ⟶ Y) : Groupoid.inv f = inv f :=\n  IsIso.eq_inv_of_hom_inv_id <| Groupoid.comp_inv f\n#align category_theory.groupoid.inv_eq_inv CategoryTheory.Groupoid.inv_eq_inv\n-/\n\n#print CategoryTheory.Groupoid.invEquiv /-\n/-- `groupoid.inv` is involutive. -/\n@[simps]\ndef Groupoid.invEquiv : (X ⟶ Y) ≃ (Y ⟶ X) :=\n  ⟨Groupoid.inv, Groupoid.inv, fun f => by simp, fun f => by simp⟩\n#align category_theory.groupoid.inv_equiv CategoryTheory.Groupoid.invEquiv\n-/\n\n#print CategoryTheory.groupoidHasInvolutiveReverse /-\ninstance (priority := 100) groupoidHasInvolutiveReverse : Quiver.HasInvolutiveReverse C\n    where\n  reverse' X Y f := Groupoid.inv f\n  inv' X Y f := by\n    dsimp [Quiver.reverse]\n    simp\n#align category_theory.groupoid_has_involutive_reverse CategoryTheory.groupoidHasInvolutiveReverse\n-/\n\n#print CategoryTheory.Groupoid.reverse_eq_inv /-\n@[simp]\ntheorem Groupoid.reverse_eq_inv (f : X ⟶ Y) : Quiver.reverse f = Groupoid.inv f :=\n  rfl\n#align category_theory.groupoid.reverse_eq_inv CategoryTheory.Groupoid.reverse_eq_inv\n-/\n\n#print CategoryTheory.functorMapReverse /-\ninstance functorMapReverse {D : Type _} [Groupoid D] (F : C ⥤ D) : F.toPrefunctor.MapReverse\n    where map_reverse' X Y f := by\n    simp only [Quiver.reverse, Quiver.HasReverse.reverse', groupoid.inv_eq_inv,\n      functor.to_prefunctor_map, functor.map_inv]\n#align category_theory.functor_map_reverse CategoryTheory.functorMapReverse\n-/\n\nvariable (X Y)\n\n#print CategoryTheory.Groupoid.isoEquivHom /-\n/-- In a groupoid, isomorphisms are equivalent to morphisms. -/\ndef Groupoid.isoEquivHom : (X ≅ Y) ≃ (X ⟶ Y)\n    where\n  toFun := Iso.hom\n  invFun f := ⟨f, Groupoid.inv f⟩\n  left_inv i := Iso.ext rfl\n  right_inv f := rfl\n#align category_theory.groupoid.iso_equiv_hom CategoryTheory.Groupoid.isoEquivHom\n-/\n\nvariable (C)\n\n#print CategoryTheory.Groupoid.invFunctor /-\n/-- The functor from a groupoid `C` to its opposite sending every morphism to its inverse. -/\n@[simps]\nnoncomputable def Groupoid.invFunctor : C ⥤ Cᵒᵖ\n    where\n  obj := Opposite.op\n  map {X Y} f := (inv f).op\n#align category_theory.groupoid.inv_functor CategoryTheory.Groupoid.invFunctor\n-/\n\nend\n\nsection\n\nvariable {C : Type u} [Category.{v} C]\n\n#print CategoryTheory.Groupoid.ofIsIso /-\n/-- A category where every morphism `is_iso` is a groupoid. -/\nnoncomputable def Groupoid.ofIsIso (all_is_iso : ∀ {X Y : C} (f : X ⟶ Y), IsIso f) : Groupoid.{v} C\n    where inv X Y f := inv f\n#align category_theory.groupoid.of_is_iso CategoryTheory.Groupoid.ofIsIso\n-/\n\n#print CategoryTheory.Groupoid.ofHomUnique /-\n/-- A category with a unique morphism between any two objects is a groupoid -/\ndef Groupoid.ofHomUnique (all_unique : ∀ {X Y : C}, Unique (X ⟶ Y)) : Groupoid.{v} C\n    where inv X Y f := all_unique.default\n#align category_theory.groupoid.of_hom_unique CategoryTheory.Groupoid.ofHomUnique\n-/\n\nend\n\n#print CategoryTheory.InducedCategory.groupoid /-\ninstance InducedCategory.groupoid {C : Type u} (D : Type u₂) [Groupoid.{v} D] (F : C → D) :\n    Groupoid.{v} (InducedCategory D F) :=\n  { InducedCategory.category F with\n    inv := fun X Y f => Groupoid.inv f\n    inv_comp' := fun X Y f => Groupoid.inv_comp f\n    comp_inv' := fun X Y f => Groupoid.comp_inv f }\n#align category_theory.induced_category.groupoid CategoryTheory.InducedCategory.groupoid\n-/\n\nsection\n\n#print CategoryTheory.groupoidPi /-\ninstance groupoidPi {I : Type u} {J : I → Type u₂} [∀ i, Groupoid.{v} (J i)] :\n    Groupoid.{max u v} (∀ i : I, J i)\n    where inv (x y : ∀ i, J i) (f : ∀ i, x i ⟶ y i) := fun i : I => Groupoid.inv (f i)\n#align category_theory.groupoid_pi CategoryTheory.groupoidPi\n-/\n\n#print CategoryTheory.groupoidProd /-\ninstance groupoidProd {α : Type u} {β : Type v} [Groupoid.{u₂} α] [Groupoid.{v₂} β] :\n    Groupoid.{max u₂ v₂} (α × β)\n    where inv (x y : α × β) (f : x ⟶ y) := (Groupoid.inv f.1, Groupoid.inv f.2)\n#align category_theory.groupoid_prod CategoryTheory.groupoidProd\n-/\n\nend\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Groupoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.49764267881173563}}
{"text": "import M4R.Algebra.Ring.Ring\nimport M4R.Algebra.Ring.RMorphism\n\nopen Classical\n\nnamespace M4R\n\n  namespace Finsupp\n\n    protected noncomputable instance one (α : Type _) (β : Type _) [Zero α] [Zero β] [One β] :\n      One (α →₀ β) where one := single 0 1\n\n    theorem one_def [Zero α] [Zero β] [One β] : (1 : α →₀ β) = single 0 1 := rfl\n\n    theorem all_trivial (α : Type _) (β : Type _) [Zero α] [NCSemiring β] (h10 : (1 : β) = 0)\n      (x : α →₀ β) : x = 0 :=\n        zero_fun fun a => NCSemiring.all_trivial h10 _\n\n    protected noncomputable instance mul' [Monoid α] [NCSemiring β] : Mul (α →₀ β) where\n      mul :=  fun x y => ∑ fun a₁ b₁ => ∑ fun a₂ b₂ => single (a₁ + a₂) (b₁ * b₂) in y in x\n\n    theorem mul_def [Monoid α] [NCSemiring β] {f g : α →₀ β} :\n      f * g = ∑ fun a₁ b₁ => ∑ fun a₂ b₂ => single (a₁ + a₂) (b₁ * b₂) in g in f := rfl\n\n    noncomputable instance toNCSemiring [Monoid α] [NCSemiring β] : NCSemiring (α →₀ β) :=\n      {\n        mul_zero          := fun x => by simp only [mul_def, map_sum.zero_sum, map_sum.sum_zero]\n        zero_mul          := fun x => by simp only [mul_def, map_sum.zero_sum]\n        mul_one           := fun x => by\n          have : (fun (a₁ : α) (b₁ : β) => ∑ fun a₂ b₂ => single (a₁ + a₂) (b₁ * b₂) in single 0 1)\n            = fun a₁ b₁ => single a₁ b₁ := by\n              apply funext; intro a₁; apply funext; intro b₁\n              rw [map_sum.single (0 : α) (1 : β) (fun a₂ b₂ => single (a₁ + a₂) (b₁ * b₂))\n                (by simp only [NCSemiring.mul_zero, single.zero]),\n                Monoid.add_zero, NCSemiring.mul_one]\n          simp only [mul_def, one_def, mul_eq, this, map_sum.sum_single]\n        one_mul           := fun x => by\n          have : (fun (a₂ : α) (b₂ : β) => single (0 + a₂) (1 * b₂)) = fun a₂ b₂ => single a₂ b₂ := by\n            apply funext; intro a₂; apply funext; intro b₂\n            rw [Monoid.zero_add, NCSemiring.one_mul]\n          simp only [mul_def, one_def, mul_eq]\n          rw [map_sum.single 0 1 _ (by simp only [NCSemiring.zero_mul, single.zero, map_sum.sum_zero]),\n            this, map_sum.sum_single]\n        mul_assoc         := fun x y z => by\n          simp only [mul_def]\n          have h₁ : ∀ a, (∑ fun a₂ b₂ => single (a + a₂) (0 * b₂) in z) = 0 := by\n            intros; simp only [NCSemiring.zero_mul, single.zero, map_sum.sum_zero]\n          have h₂ : ∀ (a : α) (b₁ b₂ : β),\n            (∑ fun a₂ b₂_1 => single (a + a₂) ((b₁ + b₂) * b₂_1) in z) =\n              (∑ fun a₂ b₂ => single (a + a₂) (b₁ * b₂) in z) + ∑ fun a₂ b₂_1 => single (a + a₂) (b₂ * b₂_1) in z := by\n                intro a b b'; simp only; rw [←map_sum.sum_add]; apply map_sum.congr\n                intros; rw [←single.add, NCSemiring.mul_distrib_right]\n          have h₃ : ∀ {a₁} a, single (a₁ + a) (to_fun x a₁ * 0) = 0 := by\n            intros; rw [NCSemiring.mul_zero, single.zero]\n          have h₄ : ∀ {a₁} (a) (b₁ b₂), single (a₁ + a) (to_fun x a₁ * (b₁ + b₂)) =\n              single (a₁ + a) (to_fun x a₁ * b₁) + single (a₁ + a) (to_fun x a₁ * b₂) := by\n                intros; rw [←single.add, NCSemiring.mul_distrib_left]\n          rw [map_sum.sum_sum h₁ h₂]; apply map_sum.congr; intros\n          rw [map_sum.sum_sum h₁ h₂, map_sum.sum_sum h₃ h₄]; apply map_sum.congr; intros\n          rw [map_sum.single _ _ _ (by\n            conv => rhs; rw [←map_sum.sum_zero z]\n            apply map_sum.congr; intros; rw [NCSemiring.zero_mul, single.zero])]\n          rw [map_sum.sum_sum h₃ h₄]; apply map_sum.congr; intros\n          rw [map_sum.single _ _ _ (by rw [NCSemiring.mul_zero, single.zero]), Monoid.add_assoc, NCSemiring.mul_assoc]\n        mul_distrib_left  := fun x y z => by\n          simp only [mul_def]\n          have : (fun a₁ b₁ => (∑ fun a₂ b₂ => single (a₁ + a₂) (b₁ * b₂) in (y + z))) =\n            fun a₁ b₁ => (∑ fun a₂ b₂ => single (a₁ + a₂) (b₁ * b₂) in y) + ∑ fun a₂ b₂ => single (a₁ + a₂) (b₁ * b₂) in z :=\n              funext fun _ => funext fun _ =>\n                map_sum.add_sum y z _ (fun _ => by rw [NCSemiring.mul_zero, single.zero])\n                  (fun _ => by rw [←single.add, add_apply, NCSemiring.mul_distrib_left])\n          rw [this]; exact map_sum.sum_add\n        mul_distrib_right := fun x y z => by\n          simp only [mul_def]\n          exact map_sum.add_sum x y _ (fun _ =>\n            map_sum.map_eq_zero (by intros; rw [NCSemiring.zero_mul, single.zero]))\n              (fun _ => by\n                rw [←map_sum.sum_add]; exact map_sum.congr (by\n                  intros; rw [←single.add, add_apply, NCSemiring.mul_distrib_right]))\n      }\n\n    noncomputable instance toNonTrivialNCSemiring [Monoid α] [NonTrivialNCSemiring β] : NonTrivialNCSemiring (α →₀ β) where\n      one_neq_zero := by\n        intro h; simp only [one_def] at h\n        have := congrArg (fun (x : α →₀ β) => x (0 : α)) h\n        simp only [single.eq_same, zero_apply] at this\n        exact absurd this NonTrivial.one_neq_zero\n\n    noncomputable instance toSemiring [CommMonoid α] [Semiring β] : Semiring (α →₀ β) where\n      mul_comm := fun x y => by\n        simp only [mul_def, Finsupp.map_sum, Semiring.mul_comm]\n        rw [Finset.map_sum.comm]; simp only [CommMonoid.add_comm]\n\n    noncomputable instance toNCRing [Monoid α] [NCRing β] : NCRing (α →₀ β) where\n      toNeg   := Finsupp.neg\n      add_neg := toGroup.add_neg\n\n    noncomputable instance toRing [CommMonoid α] [Ring β] : Ring (α →₀ β) where\n      toNCRing := toNCRing\n      mul_comm := toSemiring.mul_comm\n\n    noncomputable instance UnitFinsuppNCSemiring [NCSemiring α] : (Unit →₀ α) ≅* α where\n      toMHomomorphism := UnitFinsuppMonoid.toMHomomorphism\n      preserve_mul := fun x y => by\n        simp only [mul_def]\n        have : (fun a₂ b₂ => single (Unit.unit + a₂) ((0 : α) * b₂)) = fun _ _ => (0 : Unit →₀ α) := by\n          apply funext; intro u; cases u; apply funext; intro u\n          rw [NCSemiring.zero_mul, single.zero]\n        rw [map_sum.unit_sum x (by rw [this, map_sum.sum_zero]), map_sum.unit_sum y\n          (by rw [NCSemiring.mul_zero, single.zero])]\n        simp only [UnitFinsuppMonoid]; have : Unit.unit + Unit.unit = Unit.unit := rfl\n        rw [this, single.eq_same]\n      inv := UnitFinsuppMonoid.inv\n      left_inv := UnitFinsuppMonoid.left_inv\n      right_inv := UnitFinsuppMonoid.right_inv\n\n    noncomputable instance UnitFinsuppNCRing [NCRing α] : (Unit →₀ α) ≅ᵣ α where\n      toSMulMap := UnitFinsuppNCSemiring.toSMulMap\n      preserve_neg := UnitFinsuppGroup.preserve_neg\n      inv := UnitFinsuppMonoid.inv\n      left_inv := UnitFinsuppMonoid.left_inv\n      right_inv := UnitFinsuppMonoid.right_inv\n\n    @[simp] theorem single_mul_single [Monoid α] [NCSemiring β] {a₁ a₂ : α} {b₁ b₂ : β} :\n        single a₁ b₁ * single a₂ b₂ = single (a₁ + a₂) (b₁ * b₂) := by\n          simp only [mul_def, map_sum.single, NCSemiring.zero_mul, NCSemiring.mul_zero, single.zero]\n\n  end Finsupp\nend M4R\n", "meta": {"author": "Hop311", "repo": "M4R", "sha": "ebd1b04af344f9737d290bf8b48b3cde35e9787b", "save_path": "github-repos/lean/Hop311-M4R", "path": "github-repos/lean/Hop311-M4R/M4R-ebd1b04af344f9737d290bf8b48b3cde35e9787b/M4R/Algebra/Ring/MapRings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.82893881677331, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4975194283662686}}
{"text": "namespace fol_06\n\nvariable A : Type\nvariables P Q : A → Prop\n\nvariable h : ¬ ∃ x, P x ∨ Q x\ninclude h\n\ntheorem fol_06 : ∀ x, ¬ P x ∧ ¬ Q x :=\nassume s,\nhave h1: ∀ t, ¬ (P t ∨ Q t), from\n  (assume t: A,\n   classical.by_contradiction\n    (assume h2: ¬¬(P t ∨ Q t),\n     have h3: P t ∨ Q t, from classical.by_contradiction h2,\n     h (exists.intro t h3))),\n\nhave h4: ¬ (P s ∨ Q s), from h1 s,\n\nhave h5: ¬ P s, from classical.by_contradiction\n  (assume h6: ¬¬P s,\n   have h7: P s, from classical.by_contradiction h6,\n   have h8: P s ∨ Q s, from or.inl h7,\n   h4 h8),\nhave h9: ¬ Q s, from classical.by_contradiction\n  (assume h10: ¬¬Q s,\n   have h11: Q s, from classical.by_contradiction h10,\n   have h12: P s ∨ Q s, from or.inr h11,\n   h4 h12),\n\nhave h13: ¬ P s ∧ ¬ Q s, from and.intro h5 h9,\nshow ¬P s ∧ ¬Q s, from h13\n\nend fol_06", "meta": {"author": "tomasz-lisowski", "repo": "lean-logic-examples", "sha": "2b2ccd467b49c3989bf6c92ec0358a8d6ee68c5d", "save_path": "github-repos/lean/tomasz-lisowski-lean-logic-examples", "path": "github-repos/lean/tomasz-lisowski-lean-logic-examples/lean-logic-examples-2b2ccd467b49c3989bf6c92ec0358a8d6ee68c5d/src/logic_first_order/fol_06.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511469672595, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.49750891686354837}}
{"text": "/-\nCopyright (c) 2021 OpenAI. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f\n-/\nimport mathzoo.imports.miniF2F\n\nopen_locale nat rat real big_operators topological_space\n\ntheorem amc12a_2009_p5\n  (x : ℝ)\n  (h₀ : x^3 - (x + 1) * (x - 1) * x = 5) :\n  x^3 = 125 :=\nbegin\n  nlinarith [pow_two x],\nend", "meta": {"author": "leanprover-community", "repo": "mathzoo", "sha": "87e9b492daeb929838706942aaa2437621b34a0e", "save_path": "github-repos/lean/leanprover-community-mathzoo", "path": "github-repos/lean/leanprover-community-mathzoo/mathzoo-87e9b492daeb929838706942aaa2437621b34a0e/src/mathzoo/olympiads/amc/12/2009/a/p5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511396138365, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.49750891258898094}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.list.forall2\n\n/-!\n# List sections\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves some stuff about `list.sections` (definition in `data.list.defs`). A section of a\nlist of lists `[l₁, ..., lₙ]` is a list whose `i`-th element comes from the `i`-th list.\n-/\n\n\nopen nat function\n\nnamespace list\nvariables {α β : Type*}\n\ntheorem mem_sections {L : list (list α)} {f} : f ∈ sections L ↔ forall₂ (∈) f L :=\nbegin\n  refine ⟨λ h, _, λ h, _⟩,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall₂.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with ⟨_, _, _, _, rfl⟩,\n    simp only [*, forall₂_cons, true_and] },\n  { induction h with a l f L al fL fs, {exact or.inl rfl},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map],\n    exact ⟨_, fs, _, al, rfl, rfl⟩ }\nend\n\n\n\nlemma rel_sections {r : α → β → Prop} :\n  (forall₂ (forall₂ r) ⇒ forall₂ (forall₂ r)) sections sections\n| _ _ forall₂.nil := forall₂.cons forall₂.nil forall₂.nil\n| _ _ (forall₂.cons h₀ h₁) :=\n  rel_bind (rel_sections h₁) (assume _ _ hl, rel_map (assume _ _ ha, forall₂.cons ha hl) h₀)\n\nend list\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/list/sections.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.4975016542289335}}
{"text": "/-\nCopyright (c) 2018 Sean Leather. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sean Leather, Mario Carneiro\n\n! This file was ported from Lean 3 source module data.finmap\n! leanprover-community/mathlib commit cea83e192eae2d368ab2b500a0975667da42c920\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.List.Alist\nimport Mathbin.Data.Finset.Sigma\nimport Mathbin.Data.Part\n\n/-!\n# Finite maps over `multiset`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nuniverse u v w\n\nopen List\n\nvariable {α : Type u} {β : α → Type v}\n\n/-! ### multisets of sigma types-/\n\n\nnamespace Multiset\n\n#print Multiset.keys /-\n/-- Multiset of keys of an association multiset. -/\ndef keys (s : Multiset (Sigma β)) : Multiset α :=\n  s.map Sigma.fst\n#align multiset.keys Multiset.keys\n-/\n\n#print Multiset.coe_keys /-\n@[simp]\ntheorem coe_keys {l : List (Sigma β)} : keys (l : Multiset (Sigma β)) = (l.keys : Multiset α) :=\n  rfl\n#align multiset.coe_keys Multiset.coe_keys\n-/\n\n#print Multiset.NodupKeys /-\n/-- `nodupkeys s` means that `s` has no duplicate keys. -/\ndef NodupKeys (s : Multiset (Sigma β)) : Prop :=\n  Quot.liftOn s List.NodupKeys fun s t p => propext <| perm_nodupKeys p\n#align multiset.nodupkeys Multiset.NodupKeys\n-/\n\n#print Multiset.coe_nodupKeys /-\n@[simp]\ntheorem coe_nodupKeys {l : List (Sigma β)} : @NodupKeys α β l ↔ l.NodupKeys :=\n  Iff.rfl\n#align multiset.coe_nodupkeys Multiset.coe_nodupKeys\n-/\n\n#print Multiset.nodup_keys /-\ntheorem nodup_keys {m : Multiset (Σa, β a)} : m.keys.Nodup ↔ m.NodupKeys :=\n  by\n  rcases m with ⟨l⟩\n  rfl\n#align multiset.nodup_keys Multiset.nodup_keys\n-/\n\nalias nodup_keys ↔ _ nodupkeys.nodup_keys\n#align multiset.nodupkeys.nodup_keys Multiset.NodupKeys.nodup_keys\n\n#print Multiset.NodupKeys.nodup /-\ntheorem NodupKeys.nodup {m : Multiset (Σa, β a)} (h : m.NodupKeys) : m.Nodup :=\n  h.nodup_keys.of_map _\n#align multiset.nodupkeys.nodup Multiset.NodupKeys.nodup\n-/\n\nend Multiset\n\n/-! ### finmap -/\n\n\n#print Finmap /-\n/-- `finmap β` is the type of finite maps over a multiset. It is effectively\n  a quotient of `alist β` by permutation of the underlying list. -/\nstructure Finmap (β : α → Type v) : Type max u v where\n  entries : Multiset (Sigma β)\n  NodupKeys : entries.NodupKeys\n#align finmap Finmap\n-/\n\n#print AList.toFinmap /-\n/-- The quotient map from `alist` to `finmap`. -/\ndef AList.toFinmap (s : AList β) : Finmap β :=\n  ⟨s.entries, s.NodupKeys⟩\n#align alist.to_finmap AList.toFinmap\n-/\n\n-- mathport name: to_finmap\nlocal notation:arg \"⟦\" a \"⟧\" => AList.toFinmap a\n\n#print AList.toFinmap_eq /-\ntheorem AList.toFinmap_eq {s₁ s₂ : AList β} : ⟦s₁⟧ = ⟦s₂⟧ ↔ s₁.entries ~ s₂.entries := by\n  cases s₁ <;> cases s₂ <;> simp [AList.toFinmap]\n#align alist.to_finmap_eq AList.toFinmap_eq\n-/\n\n#print AList.toFinmap_entries /-\n@[simp]\ntheorem AList.toFinmap_entries (s : AList β) : ⟦s⟧.entries = s.entries :=\n  rfl\n#align alist.to_finmap_entries AList.toFinmap_entries\n-/\n\n#print List.toFinmap /-\n/-- Given `l : list (sigma β)`, create a term of type `finmap β` by removing\nentries with duplicate keys. -/\ndef List.toFinmap [DecidableEq α] (s : List (Sigma β)) : Finmap β :=\n  s.toAList.toFinmap\n#align list.to_finmap List.toFinmap\n-/\n\nnamespace Finmap\n\nopen AList\n\n#print Finmap.nodup_entries /-\ntheorem nodup_entries (f : Finmap β) : f.entries.Nodup :=\n  f.NodupKeys.Nodup\n#align finmap.nodup_entries Finmap.nodup_entries\n-/\n\n/-! ### lifting from alist -/\n\n\n#print Finmap.liftOn /-\n/-- Lift a permutation-respecting function on `alist` to `finmap`. -/\n@[elab_as_elim]\ndef liftOn {γ} (s : Finmap β) (f : AList β → γ)\n    (H : ∀ a b : AList β, a.entries ~ b.entries → f a = f b) : γ :=\n  by\n  refine'\n    (Quotient.liftOn s.1 (fun l => (⟨_, fun nd => f ⟨l, nd⟩⟩ : Part γ)) fun l₁ l₂ p =>\n            Part.ext' (perm_nodupkeys p) _ :\n          Part γ).get\n      _\n  · exact fun h₁ h₂ => H _ _ p\n  · have := s.nodupkeys\n    rcases s.entries with ⟨l⟩\n    exact id\n#align finmap.lift_on Finmap.liftOn\n-/\n\n/- warning: finmap.lift_on_to_finmap -> Finmap.liftOn_toFinmap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} {γ : Type.{u3}} (s : AList.{u1, u2} α β) (f : (AList.{u1, u2} α β) -> γ) (H : forall (a : AList.{u1, u2} α β) (b : AList.{u1, u2} α β), (List.Perm.{max u1 u2} (Sigma.{u1, u2} α β) (AList.entries.{u1, u2} α β a) (AList.entries.{u1, u2} α β b)) -> (Eq.{succ u3} γ (f a) (f b))), Eq.{succ u3} γ (Finmap.liftOn.{u1, u2, u3} α β γ (AList.toFinmap.{u1, u2} α β s) f H) (f s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : α -> Type.{u3}} {γ : Type.{u1}} (s : AList.{u2, u3} α β) (f : (AList.{u2, u3} α β) -> γ) (H : forall (a : AList.{u2, u3} α β) (b : AList.{u2, u3} α β), (List.Perm.{max u2 u3} (Sigma.{u2, u3} α β) (AList.entries.{u2, u3} α β a) (AList.entries.{u2, u3} α β b)) -> (Eq.{succ u1} γ (f a) (f b))), Eq.{succ u1} γ (Finmap.liftOn.{u2, u3, u1} α β γ (AList.toFinmap.{u2, u3} α β s) f H) (f s)\nCase conversion may be inaccurate. Consider using '#align finmap.lift_on_to_finmap Finmap.liftOn_toFinmapₓ'. -/\n@[simp]\ntheorem liftOn_toFinmap {γ} (s : AList β) (f : AList β → γ) (H) : liftOn ⟦s⟧ f H = f s := by\n  cases s <;> rfl\n#align finmap.lift_on_to_finmap Finmap.liftOn_toFinmap\n\n#print Finmap.liftOn₂ /-\n/-- Lift a permutation-respecting function on 2 `alist`s to 2 `finmap`s. -/\n@[elab_as_elim]\ndef liftOn₂ {γ} (s₁ s₂ : Finmap β) (f : AList β → AList β → γ)\n    (H :\n      ∀ a₁ b₁ a₂ b₂ : AList β,\n        a₁.entries ~ a₂.entries → b₁.entries ~ b₂.entries → f a₁ b₁ = f a₂ b₂) :\n    γ :=\n  liftOn s₁ (fun l₁ => liftOn s₂ (f l₁) fun b₁ b₂ p => H _ _ _ _ (Perm.refl _) p) fun a₁ a₂ p =>\n    by\n    have H' : f a₁ = f a₂ := funext fun _ => H _ _ _ _ p (Perm.refl _)\n    simp only [H']\n#align finmap.lift_on₂ Finmap.liftOn₂\n-/\n\n/- warning: finmap.lift_on₂_to_finmap -> Finmap.liftOn₂_toFinmap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} {γ : Type.{u3}} (s₁ : AList.{u1, u2} α β) (s₂ : AList.{u1, u2} α β) (f : (AList.{u1, u2} α β) -> (AList.{u1, u2} α β) -> γ) (H : forall (a₁ : AList.{u1, u2} α β) (b₁ : AList.{u1, u2} α β) (a₂ : AList.{u1, u2} α β) (b₂ : AList.{u1, u2} α β), (List.Perm.{max u1 u2} (Sigma.{u1, u2} α β) (AList.entries.{u1, u2} α β a₁) (AList.entries.{u1, u2} α β a₂)) -> (List.Perm.{max u1 u2} (Sigma.{u1, u2} α β) (AList.entries.{u1, u2} α β b₁) (AList.entries.{u1, u2} α β b₂)) -> (Eq.{succ u3} γ (f a₁ b₁) (f a₂ b₂))), Eq.{succ u3} γ (Finmap.liftOn₂.{u1, u2, u3} α β γ (AList.toFinmap.{u1, u2} α β s₁) (AList.toFinmap.{u1, u2} α β s₂) f H) (f s₁ s₂)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : α -> Type.{u3}} {γ : Type.{u1}} (s₁ : AList.{u2, u3} α β) (s₂ : AList.{u2, u3} α β) (f : (AList.{u2, u3} α β) -> (AList.{u2, u3} α β) -> γ) (H : forall (a₁ : AList.{u2, u3} α β) (b₁ : AList.{u2, u3} α β) (a₂ : AList.{u2, u3} α β) (b₂ : AList.{u2, u3} α β), (List.Perm.{max u2 u3} (Sigma.{u2, u3} α β) (AList.entries.{u2, u3} α β a₁) (AList.entries.{u2, u3} α β a₂)) -> (List.Perm.{max u2 u3} (Sigma.{u2, u3} α β) (AList.entries.{u2, u3} α β b₁) (AList.entries.{u2, u3} α β b₂)) -> (Eq.{succ u1} γ (f a₁ b₁) (f a₂ b₂))), Eq.{succ u1} γ (Finmap.liftOn₂.{u2, u3, u1} α β γ (AList.toFinmap.{u2, u3} α β s₁) (AList.toFinmap.{u2, u3} α β s₂) f H) (f s₁ s₂)\nCase conversion may be inaccurate. Consider using '#align finmap.lift_on₂_to_finmap Finmap.liftOn₂_toFinmapₓ'. -/\n@[simp]\ntheorem liftOn₂_toFinmap {γ} (s₁ s₂ : AList β) (f : AList β → AList β → γ) (H) :\n    liftOn₂ ⟦s₁⟧ ⟦s₂⟧ f H = f s₁ s₂ := by cases s₁ <;> cases s₂ <;> rfl\n#align finmap.lift_on₂_to_finmap Finmap.liftOn₂_toFinmap\n\n/-! ### induction -/\n\n\n#print Finmap.induction_on /-\n@[elab_as_elim]\ntheorem induction_on {C : Finmap β → Prop} (s : Finmap β) (H : ∀ a : AList β, C ⟦a⟧) : C s := by\n  rcases s with ⟨⟨a⟩, h⟩ <;> exact H ⟨a, h⟩\n#align finmap.induction_on Finmap.induction_on\n-/\n\n#print Finmap.induction_on₂ /-\n@[elab_as_elim]\ntheorem induction_on₂ {C : Finmap β → Finmap β → Prop} (s₁ s₂ : Finmap β)\n    (H : ∀ a₁ a₂ : AList β, C ⟦a₁⟧ ⟦a₂⟧) : C s₁ s₂ :=\n  induction_on s₁ fun l₁ => induction_on s₂ fun l₂ => H l₁ l₂\n#align finmap.induction_on₂ Finmap.induction_on₂\n-/\n\n#print Finmap.induction_on₃ /-\n@[elab_as_elim]\ntheorem induction_on₃ {C : Finmap β → Finmap β → Finmap β → Prop} (s₁ s₂ s₃ : Finmap β)\n    (H : ∀ a₁ a₂ a₃ : AList β, C ⟦a₁⟧ ⟦a₂⟧ ⟦a₃⟧) : C s₁ s₂ s₃ :=\n  induction_on₂ s₁ s₂ fun l₁ l₂ => induction_on s₃ fun l₃ => H l₁ l₂ l₃\n#align finmap.induction_on₃ Finmap.induction_on₃\n-/\n\n/-! ### extensionality -/\n\n\n#print Finmap.ext /-\n@[ext]\ntheorem ext : ∀ {s t : Finmap β}, s.entries = t.entries → s = t\n  | ⟨l₁, h₁⟩, ⟨l₂, h₂⟩, H => by congr\n#align finmap.ext Finmap.ext\n-/\n\n#print Finmap.ext_iff /-\n@[simp]\ntheorem ext_iff {s t : Finmap β} : s.entries = t.entries ↔ s = t :=\n  ⟨ext, congr_arg _⟩\n#align finmap.ext_iff Finmap.ext_iff\n-/\n\n/-! ### mem -/\n\n\n/-- The predicate `a ∈ s` means that `s` has a value associated to the key `a`. -/\ninstance : Membership α (Finmap β) :=\n  ⟨fun a s => a ∈ s.entries.keys⟩\n\n#print Finmap.mem_def /-\ntheorem mem_def {a : α} {s : Finmap β} : a ∈ s ↔ a ∈ s.entries.keys :=\n  Iff.rfl\n#align finmap.mem_def Finmap.mem_def\n-/\n\n#print Finmap.mem_toFinmap /-\n@[simp]\ntheorem mem_toFinmap {a : α} {s : AList β} : a ∈ ⟦s⟧ ↔ a ∈ s :=\n  Iff.rfl\n#align finmap.mem_to_finmap Finmap.mem_toFinmap\n-/\n\n/-! ### keys -/\n\n\n#print Finmap.keys /-\n/-- The set of keys of a finite map. -/\ndef keys (s : Finmap β) : Finset α :=\n  ⟨s.entries.keys, s.NodupKeys.nodup_keys⟩\n#align finmap.keys Finmap.keys\n-/\n\n#print Finmap.keys_val /-\n@[simp]\ntheorem keys_val (s : AList β) : (keys ⟦s⟧).val = s.keys :=\n  rfl\n#align finmap.keys_val Finmap.keys_val\n-/\n\n#print Finmap.keys_ext /-\n@[simp]\ntheorem keys_ext {s₁ s₂ : AList β} : keys ⟦s₁⟧ = keys ⟦s₂⟧ ↔ s₁.keys ~ s₂.keys := by\n  simp [keys, AList.keys]\n#align finmap.keys_ext Finmap.keys_ext\n-/\n\n#print Finmap.mem_keys /-\ntheorem mem_keys {a : α} {s : Finmap β} : a ∈ s.keys ↔ a ∈ s :=\n  induction_on s fun s => AList.mem_keys\n#align finmap.mem_keys Finmap.mem_keys\n-/\n\n/-! ### empty -/\n\n\n/-- The empty map. -/\ninstance : EmptyCollection (Finmap β) :=\n  ⟨⟨0, nodupKeys_nil⟩⟩\n\ninstance : Inhabited (Finmap β) :=\n  ⟨∅⟩\n\n#print Finmap.empty_toFinmap /-\n@[simp]\ntheorem empty_toFinmap : (⟦∅⟧ : Finmap β) = ∅ :=\n  rfl\n#align finmap.empty_to_finmap Finmap.empty_toFinmap\n-/\n\n#print Finmap.toFinmap_nil /-\n@[simp]\ntheorem toFinmap_nil [DecidableEq α] : ([].toFinmap : Finmap β) = ∅ :=\n  rfl\n#align finmap.to_finmap_nil Finmap.toFinmap_nil\n-/\n\n#print Finmap.not_mem_empty /-\ntheorem not_mem_empty {a : α} : a ∉ (∅ : Finmap β) :=\n  Multiset.not_mem_zero a\n#align finmap.not_mem_empty Finmap.not_mem_empty\n-/\n\n#print Finmap.keys_empty /-\n@[simp]\ntheorem keys_empty : (∅ : Finmap β).keys = ∅ :=\n  rfl\n#align finmap.keys_empty Finmap.keys_empty\n-/\n\n/-! ### singleton -/\n\n\n#print Finmap.singleton /-\n/-- The singleton map. -/\ndef singleton (a : α) (b : β a) : Finmap β :=\n  ⟦AList.singleton a b⟧\n#align finmap.singleton Finmap.singleton\n-/\n\n#print Finmap.keys_singleton /-\n@[simp]\ntheorem keys_singleton (a : α) (b : β a) : (singleton a b).keys = {a} :=\n  rfl\n#align finmap.keys_singleton Finmap.keys_singleton\n-/\n\n#print Finmap.mem_singleton /-\n@[simp]\ntheorem mem_singleton (x y : α) (b : β y) : x ∈ singleton y b ↔ x = y := by\n  simp only [singleton] <;> erw [mem_cons_eq, mem_nil_iff, or_false_iff]\n#align finmap.mem_singleton Finmap.mem_singleton\n-/\n\nsection\n\nvariable [DecidableEq α]\n\n#print Finmap.decidableEq /-\ninstance decidableEq [∀ a, DecidableEq (β a)] : DecidableEq (Finmap β)\n  | s₁, s₂ => decidable_of_iff _ ext_iff\n#align finmap.has_decidable_eq Finmap.decidableEq\n-/\n\n/-! ### lookup -/\n\n\n#print Finmap.lookup /-\n/-- Look up the value associated to a key in a map. -/\ndef lookup (a : α) (s : Finmap β) : Option (β a) :=\n  liftOn s (lookup a) fun s t => perm_lookup\n#align finmap.lookup Finmap.lookup\n-/\n\n#print Finmap.lookup_toFinmap /-\n@[simp]\ntheorem lookup_toFinmap (a : α) (s : AList β) : lookup a ⟦s⟧ = s.dlookup a :=\n  rfl\n#align finmap.lookup_to_finmap Finmap.lookup_toFinmap\n-/\n\n#print Finmap.dlookup_list_toFinmap /-\n@[simp]\ntheorem dlookup_list_toFinmap (a : α) (s : List (Sigma β)) : lookup a s.toFinmap = s.dlookup a := by\n  rw [List.toFinmap, lookup_to_finmap, lookup_to_alist]\n#align finmap.lookup_list_to_finmap Finmap.dlookup_list_toFinmap\n-/\n\n#print Finmap.lookup_empty /-\n@[simp]\ntheorem lookup_empty (a) : lookup a (∅ : Finmap β) = none :=\n  rfl\n#align finmap.lookup_empty Finmap.lookup_empty\n-/\n\n#print Finmap.lookup_isSome /-\ntheorem lookup_isSome {a : α} {s : Finmap β} : (s.dlookup a).isSome ↔ a ∈ s :=\n  induction_on s fun s => AList.lookup_isSome\n#align finmap.lookup_is_some Finmap.lookup_isSome\n-/\n\n#print Finmap.lookup_eq_none /-\ntheorem lookup_eq_none {a} {s : Finmap β} : lookup a s = none ↔ a ∉ s :=\n  induction_on s fun s => AList.lookup_eq_none\n#align finmap.lookup_eq_none Finmap.lookup_eq_none\n-/\n\n#print Finmap.mem_lookup_iff /-\ntheorem mem_lookup_iff {f : Finmap β} {a : α} {b : β a} :\n    b ∈ f.dlookup a ↔ Sigma.mk a b ∈ f.entries :=\n  by\n  rcases f with ⟨⟨l⟩, hl⟩\n  exact List.mem_dlookup_iff hl\n#align finmap.mem_lookup_iff Finmap.mem_lookup_iff\n-/\n\n#print Finmap.lookup_eq_some_iff /-\n/-- A version of `finmap.mem_lookup_iff` with LHS in the simp-normal form. -/\ntheorem lookup_eq_some_iff {f : Finmap β} {a : α} {b : β a} :\n    f.dlookup a = some b ↔ Sigma.mk a b ∈ f.entries :=\n  mem_lookup_iff\n#align finmap.lookup_eq_some_iff Finmap.lookup_eq_some_iff\n-/\n\n#print Finmap.sigma_keys_lookup /-\n@[simp]\ntheorem sigma_keys_lookup (f : Finmap β) :\n    (f.keys.Sigma fun i => (f.dlookup i).toFinset) = ⟨f.entries, f.nodup_entries⟩ :=\n  by\n  ext x\n  have : x ∈ f.entries → x.fst ∈ f.keys := Multiset.mem_map_of_mem _\n  simpa [lookup_eq_some_iff]\n#align finmap.sigma_keys_lookup Finmap.sigma_keys_lookup\n-/\n\n#print Finmap.lookup_singleton_eq /-\n@[simp]\ntheorem lookup_singleton_eq {a : α} {b : β a} : (singleton a b).dlookup a = some b := by\n  rw [singleton, lookup_to_finmap, AList.singleton, AList.lookup, lookup_cons_eq]\n#align finmap.lookup_singleton_eq Finmap.lookup_singleton_eq\n-/\n\ninstance (a : α) (s : Finmap β) : Decidable (a ∈ s) :=\n  decidable_of_iff _ lookup_isSome\n\n#print Finmap.mem_iff /-\ntheorem mem_iff {a : α} {s : Finmap β} : a ∈ s ↔ ∃ b, s.dlookup a = some b :=\n  induction_on s fun s =>\n    Iff.trans List.mem_keys <| exists_congr fun b => (List.mem_dlookup_iff s.NodupKeys).symm\n#align finmap.mem_iff Finmap.mem_iff\n-/\n\n#print Finmap.mem_of_lookup_eq_some /-\ntheorem mem_of_lookup_eq_some {a : α} {b : β a} {s : Finmap β} (h : s.dlookup a = some b) : a ∈ s :=\n  mem_iff.mpr ⟨_, h⟩\n#align finmap.mem_of_lookup_eq_some Finmap.mem_of_lookup_eq_some\n-/\n\n#print Finmap.ext_lookup /-\ntheorem ext_lookup {s₁ s₂ : Finmap β} : (∀ x, s₁.dlookup x = s₂.dlookup x) → s₁ = s₂ :=\n  induction_on₂ s₁ s₂ fun s₁ s₂ h =>\n    by\n    simp only [AList.lookup, lookup_to_finmap] at h\n    rw [AList.toFinmap_eq]\n    apply lookup_ext s₁.nodupkeys s₂.nodupkeys\n    intro x y\n    rw [h]\n#align finmap.ext_lookup Finmap.ext_lookup\n-/\n\n#print Finmap.keysLookupEquiv /-\n/-- An equivalence between `finmap β` and pairs `(keys : finset α, lookup : Π a, option (β a))` such\nthat `(lookup a).is_some ↔ a ∈ keys`. -/\n@[simps apply_coe_fst apply_coe_snd]\ndef keysLookupEquiv :\n    Finmap β ≃ { f : Finset α × ∀ a, Option (β a) // ∀ i, (f.2 i).isSome ↔ i ∈ f.1 }\n    where\n  toFun f := ⟨(f.keys, fun i => f.dlookup i), fun i => lookup_isSome⟩\n  invFun f :=\n    ⟨(f.1.1.Sigma fun i => (f.1.2 i).toFinset).val,\n      by\n      refine' Multiset.nodup_keys.1 ((Finset.nodup _).map_onₓ _)\n      simp only [Finset.mem_val, Finset.mem_sigma, Option.mem_toFinset, Option.mem_def]\n      rintro ⟨i, x⟩ ⟨hi, hx⟩ ⟨j, y⟩ ⟨hj, hy⟩ (rfl : i = j)\n      obtain rfl : x = y; exact Option.some.inj (hx.symm.trans hy)\n      rfl⟩\n  left_inv f := ext <| by simp\n  right_inv := fun ⟨⟨s, f⟩, hf⟩ => by\n    ext : 2 <;> dsimp [keys]\n    · ext1 i\n      have : i ∈ s → ∃ x, f i = some x := fun hi => ⟨Option.get _, Option.get_mem <| (hf i).2 hi⟩\n      simpa [Multiset.keys]\n    · ext (i x) : 2\n      simp only [Option.mem_def, lookup_eq_some_iff, Finset.mem_val, Finset.mem_sigma,\n        Option.mem_toFinset, and_iff_right_iff_imp, ← hf]\n      exact fun h => Option.isSome_iff_exists.2 ⟨_, h⟩\n#align finmap.keys_lookup_equiv Finmap.keysLookupEquiv\n-/\n\n#print Finmap.keysLookupEquiv_symm_apply_keys /-\n@[simp]\ntheorem keysLookupEquiv_symm_apply_keys :\n    ∀ f : { f : Finset α × ∀ a, Option (β a) // ∀ i, (f.2 i).isSome ↔ i ∈ f.1 },\n      (keysLookupEquiv.symm f).keys = (f : Finset α × ∀ a, Option (β a)).1 :=\n  keysLookupEquiv.Surjective.forall.2 fun f => by\n    simp only [Equiv.symm_apply_apply, keys_lookup_equiv_apply_coe_fst]\n#align finmap.keys_lookup_equiv_symm_apply_keys Finmap.keysLookupEquiv_symm_apply_keys\n-/\n\n#print Finmap.keysLookupEquiv_symm_apply_lookup /-\n@[simp]\ntheorem keysLookupEquiv_symm_apply_lookup :\n    ∀ (f : { f : Finset α × ∀ a, Option (β a) // ∀ i, (f.2 i).isSome ↔ i ∈ f.1 }) (a),\n      (keysLookupEquiv.symm f).dlookup a = (f : Finset α × ∀ a, Option (β a)).2 a :=\n  keysLookupEquiv.Surjective.forall.2 fun f a => by\n    simp only [Equiv.symm_apply_apply, keys_lookup_equiv_apply_coe_snd]\n#align finmap.keys_lookup_equiv_symm_apply_lookup Finmap.keysLookupEquiv_symm_apply_lookup\n-/\n\n/-! ### replace -/\n\n\n#print Finmap.replace /-\n/-- Replace a key with a given value in a finite map.\n  If the key is not present it does nothing. -/\ndef replace (a : α) (b : β a) (s : Finmap β) : Finmap β :=\n  liftOn s (fun t => ⟦replace a b t⟧) fun s₁ s₂ p => toFinmap_eq.2 <| perm_replace p\n#align finmap.replace Finmap.replace\n-/\n\n#print Finmap.replace_toFinmap /-\n@[simp]\ntheorem replace_toFinmap (a : α) (b : β a) (s : AList β) : replace a b ⟦s⟧ = ⟦s.replace a b⟧ := by\n  simp [replace]\n#align finmap.replace_to_finmap Finmap.replace_toFinmap\n-/\n\n#print Finmap.keys_replace /-\n@[simp]\ntheorem keys_replace (a : α) (b : β a) (s : Finmap β) : (replace a b s).keys = s.keys :=\n  induction_on s fun s => by simp\n#align finmap.keys_replace Finmap.keys_replace\n-/\n\n#print Finmap.mem_replace /-\n@[simp]\ntheorem mem_replace {a a' : α} {b : β a} {s : Finmap β} : a' ∈ replace a b s ↔ a' ∈ s :=\n  induction_on s fun s => by simp\n#align finmap.mem_replace Finmap.mem_replace\n-/\n\nend\n\n/-! ### foldl -/\n\n\n#print Finmap.foldl /-\n/-- Fold a commutative function over the key-value pairs in the map -/\ndef foldl {δ : Type w} (f : δ → ∀ a, β a → δ)\n    (H : ∀ d a₁ b₁ a₂ b₂, f (f d a₁ b₁) a₂ b₂ = f (f d a₂ b₂) a₁ b₁) (d : δ) (m : Finmap β) : δ :=\n  m.entries.foldl (fun d s => f d s.1 s.2) (fun d s t => H _ _ _ _ _) d\n#align finmap.foldl Finmap.foldl\n-/\n\n#print Finmap.any /-\n/-- `any f s` returns `tt` iff there exists a value `v` in `s` such that `f v = tt`. -/\ndef any (f : ∀ x, β x → Bool) (s : Finmap β) : Bool :=\n  s.foldl (fun x y z => x || f y z)\n    (by\n      intros\n      simp_rw [Bool.or_assoc, Bool.or_comm])\n    false\n#align finmap.any Finmap.any\n-/\n\n#print Finmap.all /-\n/-- `all f s` returns `tt` iff `f v = tt` for all values `v` in `s`. -/\ndef all (f : ∀ x, β x → Bool) (s : Finmap β) : Bool :=\n  s.foldl (fun x y z => x && f y z)\n    (by\n      intros\n      simp_rw [Bool.and_assoc, Bool.and_comm])\n    true\n#align finmap.all Finmap.all\n-/\n\n/-! ### erase -/\n\n\nsection\n\nvariable [DecidableEq α]\n\n#print Finmap.erase /-\n/-- Erase a key from the map. If the key is not present it does nothing. -/\ndef erase (a : α) (s : Finmap β) : Finmap β :=\n  liftOn s (fun t => ⟦erase a t⟧) fun s₁ s₂ p => toFinmap_eq.2 <| perm_erase p\n#align finmap.erase Finmap.erase\n-/\n\n#print Finmap.erase_toFinmap /-\n@[simp]\ntheorem erase_toFinmap (a : α) (s : AList β) : erase a ⟦s⟧ = ⟦s.eraseₓ a⟧ := by simp [erase]\n#align finmap.erase_to_finmap Finmap.erase_toFinmap\n-/\n\n#print Finmap.keys_erase_toFinset /-\n@[simp]\ntheorem keys_erase_toFinset (a : α) (s : AList β) : keys ⟦s.eraseₓ a⟧ = (keys ⟦s⟧).eraseₓ a := by\n  simp [Finset.erase, keys, AList.erase, keys_kerase]\n#align finmap.keys_erase_to_finset Finmap.keys_erase_toFinset\n-/\n\n#print Finmap.keys_erase /-\n@[simp]\ntheorem keys_erase (a : α) (s : Finmap β) : (erase a s).keys = s.keys.eraseₓ a :=\n  induction_on s fun s => by simp\n#align finmap.keys_erase Finmap.keys_erase\n-/\n\n#print Finmap.mem_erase /-\n@[simp]\ntheorem mem_erase {a a' : α} {s : Finmap β} : a' ∈ erase a s ↔ a' ≠ a ∧ a' ∈ s :=\n  induction_on s fun s => by simp\n#align finmap.mem_erase Finmap.mem_erase\n-/\n\n#print Finmap.not_mem_erase_self /-\ntheorem not_mem_erase_self {a : α} {s : Finmap β} : ¬a ∈ erase a s := by\n  rw [mem_erase, not_and_or, Classical.not_not] <;> left <;> rfl\n#align finmap.not_mem_erase_self Finmap.not_mem_erase_self\n-/\n\n#print Finmap.lookup_erase /-\n@[simp]\ntheorem lookup_erase (a) (s : Finmap β) : lookup a (erase a s) = none :=\n  induction_on s <| lookup_erase a\n#align finmap.lookup_erase Finmap.lookup_erase\n-/\n\n#print Finmap.lookup_erase_ne /-\n@[simp]\ntheorem lookup_erase_ne {a a'} {s : Finmap β} (h : a ≠ a') : lookup a (erase a' s) = lookup a s :=\n  induction_on s fun s => lookup_erase_ne h\n#align finmap.lookup_erase_ne Finmap.lookup_erase_ne\n-/\n\n#print Finmap.erase_erase /-\ntheorem erase_erase {a a' : α} {s : Finmap β} : erase a (erase a' s) = erase a' (erase a s) :=\n  induction_on s fun s => ext (by simp only [erase_erase, erase_to_finmap])\n#align finmap.erase_erase Finmap.erase_erase\n-/\n\n/-! ### sdiff -/\n\n\n#print Finmap.sdiff /-\n/-- `sdiff s s'` consists of all key-value pairs from `s` and `s'` where the keys are in `s` or\n`s'` but not both. -/\ndef sdiff (s s' : Finmap β) : Finmap β :=\n  s'.foldl (fun s x _ => s.eraseₓ x) (fun a₀ a₁ _ a₂ _ => erase_erase) s\n#align finmap.sdiff Finmap.sdiff\n-/\n\ninstance : SDiff (Finmap β) :=\n  ⟨sdiff⟩\n\n/-! ### insert -/\n\n\n#print Finmap.insert /-\n/-- Insert a key-value pair into a finite map, replacing any existing pair with\n  the same key. -/\ndef insert (a : α) (b : β a) (s : Finmap β) : Finmap β :=\n  liftOn s (fun t => ⟦insert a b t⟧) fun s₁ s₂ p => toFinmap_eq.2 <| perm_insert p\n#align finmap.insert Finmap.insert\n-/\n\n#print Finmap.insert_toFinmap /-\n@[simp]\ntheorem insert_toFinmap (a : α) (b : β a) (s : AList β) : insert a b ⟦s⟧ = ⟦s.insert a b⟧ := by\n  simp [insert]\n#align finmap.insert_to_finmap Finmap.insert_toFinmap\n-/\n\n#print Finmap.insert_entries_of_neg /-\ntheorem insert_entries_of_neg {a : α} {b : β a} {s : Finmap β} :\n    a ∉ s → (insert a b s).entries = ⟨a, b⟩ ::ₘ s.entries :=\n  induction_on s fun s h => by simp [insert_entries_of_neg (mt mem_to_finmap.1 h)]\n#align finmap.insert_entries_of_neg Finmap.insert_entries_of_neg\n-/\n\n#print Finmap.mem_insert /-\n@[simp]\ntheorem mem_insert {a a' : α} {b' : β a'} {s : Finmap β} : a ∈ insert a' b' s ↔ a = a' ∨ a ∈ s :=\n  induction_on s mem_insert\n#align finmap.mem_insert Finmap.mem_insert\n-/\n\n#print Finmap.lookup_insert /-\n@[simp]\ntheorem lookup_insert {a} {b : β a} (s : Finmap β) : lookup a (insert a b s) = some b :=\n  induction_on s fun s => by simp only [insert_to_finmap, lookup_to_finmap, lookup_insert]\n#align finmap.lookup_insert Finmap.lookup_insert\n-/\n\n#print Finmap.lookup_insert_of_ne /-\n@[simp]\ntheorem lookup_insert_of_ne {a a'} {b : β a} (s : Finmap β) (h : a' ≠ a) :\n    lookup a' (insert a b s) = lookup a' s :=\n  induction_on s fun s => by simp only [insert_to_finmap, lookup_to_finmap, lookup_insert_ne h]\n#align finmap.lookup_insert_of_ne Finmap.lookup_insert_of_ne\n-/\n\n#print Finmap.insert_insert /-\n@[simp]\ntheorem insert_insert {a} {b b' : β a} (s : Finmap β) :\n    (s.insert a b).insert a b' = s.insert a b' :=\n  induction_on s fun s => by simp only [insert_to_finmap, insert_insert]\n#align finmap.insert_insert Finmap.insert_insert\n-/\n\n#print Finmap.insert_insert_of_ne /-\ntheorem insert_insert_of_ne {a a'} {b : β a} {b' : β a'} (s : Finmap β) (h : a ≠ a') :\n    (s.insert a b).insert a' b' = (s.insert a' b').insert a b :=\n  induction_on s fun s => by\n    simp only [insert_to_finmap, AList.toFinmap_eq, insert_insert_of_ne _ h]\n#align finmap.insert_insert_of_ne Finmap.insert_insert_of_ne\n-/\n\n#print Finmap.toFinmap_cons /-\ntheorem toFinmap_cons (a : α) (b : β a) (xs : List (Sigma β)) :\n    List.toFinmap (⟨a, b⟩ :: xs) = insert a b xs.toFinmap :=\n  rfl\n#align finmap.to_finmap_cons Finmap.toFinmap_cons\n-/\n\n#print Finmap.mem_list_toFinmap /-\ntheorem mem_list_toFinmap (a : α) (xs : List (Sigma β)) :\n    a ∈ xs.toFinmap ↔ ∃ b : β a, Sigma.mk a b ∈ xs :=\n  by\n  induction' xs with x xs <;> [skip, cases x] <;>\n      simp only [to_finmap_cons, *, not_mem_empty, exists_or, not_mem_nil, to_finmap_nil,\n        exists_false, mem_cons_iff, mem_insert, exists_and_left] <;>\n    apply or_congr _ Iff.rfl\n  conv =>\n    lhs\n    rw [← and_true_iff (a = x_fst)]\n  apply and_congr_right\n  rintro ⟨⟩\n  simp only [exists_eq, heq_iff_eq]\n#align finmap.mem_list_to_finmap Finmap.mem_list_toFinmap\n-/\n\n#print Finmap.insert_singleton_eq /-\n@[simp]\ntheorem insert_singleton_eq {a : α} {b b' : β a} : insert a b (singleton a b') = singleton a b := by\n  simp only [singleton, Finmap.insert_toFinmap, AList.insert_singleton_eq]\n#align finmap.insert_singleton_eq Finmap.insert_singleton_eq\n-/\n\n/-! ### extract -/\n\n\n#print Finmap.extract /-\n/-- Erase a key from the map, and return the corresponding value, if found. -/\ndef extract (a : α) (s : Finmap β) : Option (β a) × Finmap β :=\n  liftOn s (fun t => Prod.map id toFinmap (extract a t)) fun s₁ s₂ p => by\n    simp [perm_lookup p, to_finmap_eq, perm_erase p]\n#align finmap.extract Finmap.extract\n-/\n\n#print Finmap.extract_eq_lookup_erase /-\n@[simp]\ntheorem extract_eq_lookup_erase (a : α) (s : Finmap β) : extract a s = (lookup a s, erase a s) :=\n  induction_on s fun s => by simp [extract]\n#align finmap.extract_eq_lookup_erase Finmap.extract_eq_lookup_erase\n-/\n\n/-! ### union -/\n\n\n#print Finmap.union /-\n/-- `s₁ ∪ s₂` is the key-based union of two finite maps. It is left-biased: if\nthere exists an `a ∈ s₁`, `lookup a (s₁ ∪ s₂) = lookup a s₁`. -/\ndef union (s₁ s₂ : Finmap β) : Finmap β :=\n  liftOn₂ s₁ s₂ (fun s₁ s₂ => ⟦s₁ ∪ s₂⟧) fun s₁ s₂ s₃ s₄ p₁₃ p₂₄ =>\n    toFinmap_eq.mpr <| perm_union p₁₃ p₂₄\n#align finmap.union Finmap.union\n-/\n\ninstance : Union (Finmap β) :=\n  ⟨union⟩\n\n#print Finmap.mem_union /-\n@[simp]\ntheorem mem_union {a} {s₁ s₂ : Finmap β} : a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂ :=\n  induction_on₂ s₁ s₂ fun _ _ => mem_union\n#align finmap.mem_union Finmap.mem_union\n-/\n\n#print Finmap.union_toFinmap /-\n@[simp]\ntheorem union_toFinmap (s₁ s₂ : AList β) : ⟦s₁⟧ ∪ ⟦s₂⟧ = ⟦s₁ ∪ s₂⟧ := by simp [(· ∪ ·), union]\n#align finmap.union_to_finmap Finmap.union_toFinmap\n-/\n\n#print Finmap.keys_union /-\ntheorem keys_union {s₁ s₂ : Finmap β} : (s₁ ∪ s₂).keys = s₁.keys ∪ s₂.keys :=\n  induction_on₂ s₁ s₂ fun s₁ s₂ => Finset.ext <| by simp [keys]\n#align finmap.keys_union Finmap.keys_union\n-/\n\n#print Finmap.lookup_union_left /-\n@[simp]\ntheorem lookup_union_left {a} {s₁ s₂ : Finmap β} : a ∈ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₁ :=\n  induction_on₂ s₁ s₂ fun s₁ s₂ => lookup_union_left\n#align finmap.lookup_union_left Finmap.lookup_union_left\n-/\n\n#print Finmap.lookup_union_right /-\n@[simp]\ntheorem lookup_union_right {a} {s₁ s₂ : Finmap β} : a ∉ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₂ :=\n  induction_on₂ s₁ s₂ fun s₁ s₂ => lookup_union_right\n#align finmap.lookup_union_right Finmap.lookup_union_right\n-/\n\n#print Finmap.lookup_union_left_of_not_in /-\ntheorem lookup_union_left_of_not_in {a} {s₁ s₂ : Finmap β} (h : a ∉ s₂) :\n    lookup a (s₁ ∪ s₂) = lookup a s₁ :=\n  by\n  by_cases h' : a ∈ s₁\n  · rw [lookup_union_left h']\n  · rw [lookup_union_right h', lookup_eq_none.mpr h, lookup_eq_none.mpr h']\n#align finmap.lookup_union_left_of_not_in Finmap.lookup_union_left_of_not_in\n-/\n\n#print Finmap.mem_lookup_union /-\n@[simp]\ntheorem mem_lookup_union {a} {b : β a} {s₁ s₂ : Finmap β} :\n    b ∈ lookup a (s₁ ∪ s₂) ↔ b ∈ lookup a s₁ ∨ a ∉ s₁ ∧ b ∈ lookup a s₂ :=\n  induction_on₂ s₁ s₂ fun s₁ s₂ => mem_lookup_union\n#align finmap.mem_lookup_union Finmap.mem_lookup_union\n-/\n\n#print Finmap.mem_lookup_union_middle /-\ntheorem mem_lookup_union_middle {a} {b : β a} {s₁ s₂ s₃ : Finmap β} :\n    b ∈ lookup a (s₁ ∪ s₃) → a ∉ s₂ → b ∈ lookup a (s₁ ∪ s₂ ∪ s₃) :=\n  induction_on₃ s₁ s₂ s₃ fun s₁ s₂ s₃ => mem_lookup_union_middle\n#align finmap.mem_lookup_union_middle Finmap.mem_lookup_union_middle\n-/\n\n#print Finmap.insert_union /-\ntheorem insert_union {a} {b : β a} {s₁ s₂ : Finmap β} : insert a b (s₁ ∪ s₂) = insert a b s₁ ∪ s₂ :=\n  induction_on₂ s₁ s₂ fun a₁ a₂ => by simp [insert_union]\n#align finmap.insert_union Finmap.insert_union\n-/\n\n#print Finmap.union_assoc /-\ntheorem union_assoc {s₁ s₂ s₃ : Finmap β} : s₁ ∪ s₂ ∪ s₃ = s₁ ∪ (s₂ ∪ s₃) :=\n  induction_on₃ s₁ s₂ s₃ fun s₁ s₂ s₃ => by\n    simp only [AList.toFinmap_eq, union_to_finmap, AList.union_assoc]\n#align finmap.union_assoc Finmap.union_assoc\n-/\n\n#print Finmap.empty_union /-\n@[simp]\ntheorem empty_union {s₁ : Finmap β} : ∅ ∪ s₁ = s₁ :=\n  induction_on s₁ fun s₁ => by\n    rw [← empty_to_finmap] <;>\n      simp [-empty_to_finmap, AList.toFinmap_eq, union_to_finmap, AList.union_assoc]\n#align finmap.empty_union Finmap.empty_union\n-/\n\n#print Finmap.union_empty /-\n@[simp]\ntheorem union_empty {s₁ : Finmap β} : s₁ ∪ ∅ = s₁ :=\n  induction_on s₁ fun s₁ => by\n    rw [← empty_to_finmap] <;>\n      simp [-empty_to_finmap, AList.toFinmap_eq, union_to_finmap, AList.union_assoc]\n#align finmap.union_empty Finmap.union_empty\n-/\n\n#print Finmap.erase_union_singleton /-\ntheorem erase_union_singleton (a : α) (b : β a) (s : Finmap β) (h : s.dlookup a = some b) :\n    s.eraseₓ a ∪ singleton a b = s :=\n  ext_lookup fun x => by\n    by_cases h' : x = a\n    · subst a\n      rw [lookup_union_right not_mem_erase_self, lookup_singleton_eq, h]\n    · have : x ∉ singleton a b := by rwa [mem_singleton]\n      rw [lookup_union_left_of_not_in this, lookup_erase_ne h']\n#align finmap.erase_union_singleton Finmap.erase_union_singleton\n-/\n\nend\n\n/-! ### disjoint -/\n\n\n#print Finmap.Disjoint /-\n/-- `disjoint s₁ s₂` holds if `s₁` and `s₂` have no keys in common. -/\ndef Disjoint (s₁ s₂ : Finmap β) : Prop :=\n  ∀ x ∈ s₁, ¬x ∈ s₂\n#align finmap.disjoint Finmap.Disjoint\n-/\n\n#print Finmap.disjoint_empty /-\ntheorem disjoint_empty (x : Finmap β) : Disjoint ∅ x :=\n  fun.\n#align finmap.disjoint_empty Finmap.disjoint_empty\n-/\n\n#print Finmap.Disjoint.symm /-\n@[symm]\ntheorem Disjoint.symm (x y : Finmap β) (h : Disjoint x y) : Disjoint y x := fun p hy hx => h p hx hy\n#align finmap.disjoint.symm Finmap.Disjoint.symm\n-/\n\n#print Finmap.Disjoint.symm_iff /-\ntheorem Disjoint.symm_iff (x y : Finmap β) : Disjoint x y ↔ Disjoint y x :=\n  ⟨Disjoint.symm x y, Disjoint.symm y x⟩\n#align finmap.disjoint.symm_iff Finmap.Disjoint.symm_iff\n-/\n\nsection\n\nvariable [DecidableEq α]\n\ninstance : DecidableRel (@Disjoint α β) := fun x y => by dsimp only [Disjoint] <;> infer_instance\n\n#print Finmap.disjoint_union_left /-\ntheorem disjoint_union_left (x y z : Finmap β) : Disjoint (x ∪ y) z ↔ Disjoint x z ∧ Disjoint y z :=\n  by simp [Disjoint, Finmap.mem_union, or_imp, forall_and]\n#align finmap.disjoint_union_left Finmap.disjoint_union_left\n-/\n\n#print Finmap.disjoint_union_right /-\ntheorem disjoint_union_right (x y z : Finmap β) :\n    Disjoint x (y ∪ z) ↔ Disjoint x y ∧ Disjoint x z := by\n  rw [disjoint.symm_iff, disjoint_union_left, disjoint.symm_iff _ x, disjoint.symm_iff _ x]\n#align finmap.disjoint_union_right Finmap.disjoint_union_right\n-/\n\n#print Finmap.union_comm_of_disjoint /-\ntheorem union_comm_of_disjoint {s₁ s₂ : Finmap β} : Disjoint s₁ s₂ → s₁ ∪ s₂ = s₂ ∪ s₁ :=\n  induction_on₂ s₁ s₂ fun s₁ s₂ => by\n    intro h\n    simp only [AList.toFinmap_eq, union_to_finmap, AList.union_comm_of_disjoint h]\n#align finmap.union_comm_of_disjoint Finmap.union_comm_of_disjoint\n-/\n\n#print Finmap.union_cancel /-\ntheorem union_cancel {s₁ s₂ s₃ : Finmap β} (h : Disjoint s₁ s₃) (h' : Disjoint s₂ s₃) :\n    s₁ ∪ s₃ = s₂ ∪ s₃ ↔ s₁ = s₂ :=\n  ⟨fun h'' => by\n    apply ext_lookup\n    intro x\n    have : (s₁ ∪ s₃).dlookup x = (s₂ ∪ s₃).dlookup x := h'' ▸ rfl\n    by_cases hs₁ : x ∈ s₁\n    · rwa [lookup_union_left hs₁, lookup_union_left_of_not_in (h _ hs₁)] at this\n    · by_cases hs₂ : x ∈ s₂\n      · rwa [lookup_union_left_of_not_in (h' _ hs₂), lookup_union_left hs₂] at this\n      · rw [lookup_eq_none.mpr hs₁, lookup_eq_none.mpr hs₂], fun h => h ▸ rfl⟩\n#align finmap.union_cancel Finmap.union_cancel\n-/\n\nend\n\nend Finmap\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finmap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4975016459776711}}
{"text": "/-\nCopyright (c) 2020 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\nimport analysis.inner_product_space.projection\nimport analysis.normed_space.dual\n\n/-!\n# The Fréchet-Riesz representation theorem\n\nWe consider an inner product space `E` over `𝕜`, which is either `ℝ` or `ℂ`. We define\n`to_dual_map`, a conjugate-linear isometric embedding of `E` into its dual, which maps an element\n`x` of the space to `λ y, ⟪x, y⟫`.\n\nUnder the hypothesis of completeness (i.e., for Hilbert spaces), we upgrade this to `to_dual`, a\nconjugate-linear isometric *equivalence* of `E` onto its dual; that is, we establish the\nsurjectivity of `to_dual_map`.  This is the Fréchet-Riesz representation theorem: every element of\nthe dual of a Hilbert space `E` has the form `λ u, ⟪x, u⟫` for some `x : E`.\n\n## References\n\n* [M. Einsiedler and T. Ward, *Functional Analysis, Spectral Theory, and Applications*]\n  [EinsiedlerWard2017]\n\n## Tags\n\ndual, Fréchet-Riesz\n-/\n\nnoncomputable theory\nopen_locale classical\nuniverses u v\n\nnamespace inner_product_space\nopen is_R_or_C continuous_linear_map\n\nvariables (𝕜 : Type*)\nvariables (E : Type*) [is_R_or_C 𝕜] [inner_product_space 𝕜 E]\nlocal notation `⟪`x`, `y`⟫` := @inner 𝕜 E _ x y\nlocal postfix `†`:90 := star_ring_aut\n\n/--\nAn element `x` of an inner product space `E` induces an element of the dual space `dual 𝕜 E`,\nthe map `λ y, ⟪x, y⟫`; moreover this operation is a conjugate-linear isometric embedding of `E`\ninto `dual 𝕜 E`.\nIf `E` is complete, this operation is surjective, hence a conjugate-linear isometric equivalence;\nsee `to_dual`.\n-/\ndef to_dual_map : E →ₗᵢ⋆[𝕜] normed_space.dual 𝕜 E :=\n{ to_fun := λ x, linear_map.mk_continuous\n    { to_fun := λ y, ⟪x, y⟫,\n      map_add' := λ _ _, inner_add_right,\n      map_smul' := λ _ _, inner_smul_right }\n    ∥x∥\n    (λ y, by { rw [is_R_or_C.norm_eq_abs], exact abs_inner_le_norm _ _ }),\n  map_add' := λ x y, by { ext z, simp [inner_add_left] },\n  map_smul' := λ c y, by { ext z, simp [inner_smul_left] },\n  norm_map' := λ x, begin\n    refine le_antisymm _ _,\n    { exact linear_map.mk_continuous_norm_le _ (norm_nonneg _) _ },\n    { cases eq_or_lt_of_le (norm_nonneg x) with h h,\n      { have : x = 0 := norm_eq_zero.mp (eq.symm h),\n        simp [this] },\n      { refine (mul_le_mul_right h).mp _,\n        calc ∥x∥ * ∥x∥ = ∥x∥ ^ 2 : by ring\n        ... = re ⟪x, x⟫ : norm_sq_eq_inner _\n        ... ≤ abs ⟪x, x⟫ : re_le_abs _\n        ... = ∥linear_map.mk_continuous _ _ _ x∥ : by simp [norm_eq_abs]\n        ... ≤ ∥linear_map.mk_continuous _ _ _∥ * ∥x∥ : le_op_norm _ x } }\n  end }\n\nvariables {E}\n\n@[simp] lemma to_dual_map_apply {x y : E} : to_dual_map 𝕜 E x y = ⟪x, y⟫ := rfl\n\nvariables (E) [complete_space E]\n\n/--\nFréchet-Riesz representation: any `ℓ` in the dual of a Hilbert space `E` is of the form\n`λ u, ⟪y, u⟫` for some `y : E`, i.e. `to_dual_map` is surjective.\n-/\ndef to_dual : E ≃ₗᵢ⋆[𝕜] normed_space.dual 𝕜 E :=\nlinear_isometry_equiv.of_surjective (to_dual_map 𝕜 E)\nbegin\n  intros ℓ,\n  set Y := ker ℓ with hY,\n  by_cases htriv : Y = ⊤,\n  { have hℓ : ℓ = 0,\n    { have h' := linear_map.ker_eq_top.mp htriv,\n      rw [←coe_zero] at h',\n      apply coe_injective,\n      exact h' },\n    exact ⟨0, by simp [hℓ]⟩ },\n  { rw [← submodule.orthogonal_eq_bot_iff] at htriv,\n    change Yᗮ ≠ ⊥ at htriv,\n    rw [submodule.ne_bot_iff] at htriv,\n    obtain ⟨z : E, hz : z ∈ Yᗮ, z_ne_0 : z ≠ 0⟩ := htriv,\n    refine ⟨((ℓ z)† / ⟪z, z⟫) • z, _⟩,\n    ext x,\n    have h₁ : (ℓ z) • x - (ℓ x) • z ∈ Y,\n    { rw [mem_ker, map_sub, map_smul, map_smul, algebra.id.smul_eq_mul, algebra.id.smul_eq_mul,\n          mul_comm],\n      exact sub_self (ℓ x * ℓ z) },\n    have h₂ : (ℓ z) * ⟪z, x⟫ = (ℓ x) * ⟪z, z⟫,\n    { have h₃ := calc\n        0    = ⟪z, (ℓ z) • x - (ℓ x) • z⟫       : by { rw [(Y.mem_orthogonal' z).mp hz], exact h₁ }\n         ... = ⟪z, (ℓ z) • x⟫ - ⟪z, (ℓ x) • z⟫  : by rw [inner_sub_right]\n         ... = (ℓ z) * ⟪z, x⟫ - (ℓ x) * ⟪z, z⟫  : by simp [inner_smul_right],\n      exact sub_eq_zero.mp (eq.symm h₃) },\n    have h₄ := calc\n      ⟪((ℓ z)† / ⟪z, z⟫) • z, x⟫ = (ℓ z) / ⟪z, z⟫ * ⟪z, x⟫\n            : by simp [inner_smul_left, ring_equiv.map_div, conj_conj]\n                            ... = (ℓ z) * ⟪z, x⟫ / ⟪z, z⟫\n            : by rw [←div_mul_eq_mul_div]\n                            ... = (ℓ x) * ⟪z, z⟫ / ⟪z, z⟫\n            : by rw [h₂]\n                            ... = ℓ x\n            : begin\n                have : ⟪z, z⟫ ≠ 0,\n                { change z = 0 → false at z_ne_0,\n                  rwa ←inner_self_eq_zero at z_ne_0 },\n                field_simp [this]\n              end,\n    exact h₄ }\nend\n\nvariables {E}\n\n@[simp] lemma to_dual_apply {x y : E} : to_dual 𝕜 E x y = ⟪x, y⟫ := rfl\n\n@[simp] lemma to_dual_symm_apply {x : E} {y : normed_space.dual 𝕜 E} :\n  ⟪(to_dual 𝕜 E).symm y, x⟫ = y x :=\nbegin\n  rw ← to_dual_apply,\n  simp only [linear_isometry_equiv.apply_symm_apply],\nend\n\nend inner_product_space\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/inner_product_space/dual.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4974225261574915}}
{"text": "/-\nCopyright (c) 2021 Paula Neeley. All rights reserved.\nAuthor: Paula Neeley\nFollowing the textbook \"Dynamic Epistemic Logic\" by \nHans van Ditmarsch, Wiebe van der Hoek, and Barteld Kooi\n-/\n\nimport del.semantics.translationlemmas\nimport del.semantics.completenessDEL del.syntax.syntaxlemmasPADEL\nimport tactic.linarith\n\nvariables {agents : Type}\nopen prfPA\nopen PAlemma\n\n---------------------- Completeness by Translation ----------------------\n\n\ntheorem equiv_translation_aux' {Γ : ctxPA agents} (n : nat) (φ : formPA agents) (h : complexity φ ≤ n) : \n  prfPA Γ (φ ↔ to_PA (translate φ)) :=\nbegin\n  simp at *,\n  induction n with n ih generalizing φ,\n  { have h1 : complexity φ > 0, from comp_gt_zero, linarith},\n  cases φ,\n  case formPA.bot \n    { exact mp (mp pl4 iden) iden },\n  case formPA.var : m \n    { exact mp (mp pl4 iden) iden },\n  case formPA.and : φ ψ \n    { rw translate,\n      exact iff_iff_and_iff (ih φ (compand1 h)) (ih ψ (compand2 h))\n    },\n  case formPA.impl : φ ψ \n    { rw translate,\n      repeat {rw to_PA},\n      exact iff_iff_imp_iff (ih φ (compimp1 h)) (ih ψ (compimp2 h))\n    },\n  case formPA.box : a φ \n    { simp at *,\n      have h1 : complexity φ ≤ n, from nat.lt_succ_iff.mp (nat.one_add_le_iff.mp h),\n      exact iff_k_dist (ih φ h1), \n    },\n  case formPA.update : φ ψ \n    { cases ψ,\n      case formPA.bot \n        { repeat {rw translate},\n          repeat {rw complexity at h},\n          have h1 : complexity φ ≤ n, \n            {have : complexity φ + 1 ≤ nat.succ n, linarith,\n             exact nat.lt_succ_iff.mp this},\n          have h2 := atomicbot, \n          exact update_iff1 (ih φ h1) h2\n        },\n      case formPA.var : m \n        { repeat {rw translate},\n          repeat {rw complexity at h},\n          have h1 : complexity φ ≤ n, \n            {have : complexity φ + 1 ≤ nat.succ n, linarith,\n             exact nat.lt_succ_iff.mp this},\n          have h2 := atomicperm, \n          exact update_iff1 (ih φ h1) h2\n        },\n      case formPA.and : ψ χ \n        { repeat {rw translate},\n          exact update_iff2 (ih (U φ ψ) (updatecompand1 h)) (ih (U φ χ) (updatecompand2 h)) announceconj,\n        },\n      case formPA.impl : ψ χ\n        { repeat {rw translate},\n          exact update_iff3 (ih (U φ ψ) (updatecompimp1 h)) (ih (U φ χ) (updatecompimp2 h)) announceimp,\n        },\n      case formPA.box : a ψ\n        { repeat {rw translate}, \n          exact update_iff4 announceknow (ih (φ ⊃ K a (U φ ψ)) (updatecompknow2 h))\n        },\n      case formPA.update : ψ χ\n        { rw translate, \n          exact update_iff5 announcecomp (ih (U (φ & (U φ ψ)) χ) (updatecompupdate h))\n        } \n    }\nend\n\n\ntheorem equiv_translation (Γ : ctxPA agents) : ∀ φ : formPA agents, prfPA Γ (φ ↔ to_PA (translate φ)) :=\nbegin\nintro φ,\nhave h : complexity φ ≤ complexity φ + 1, linarith,\nsimp,\nexact equiv_translation_aux' (complexity φ + 1) φ h\nend\n\n\nlemma forces_ctxPA_iff_forces_ctx (f : frame agents) \n  (v : nat → f.states → Prop) : \n  forces_ctxPA f v ∅ ↔ forces_ctx f v ∅ :=\nbegin\nsplit,\nrepeat {intros h1 φ x h2,\nexact false.elim h2},\nend\n\n\nlemma global_sem_csqPA_iff_global_sem_csq (F : set (frame agents)) (φ : form agents) : \n  global_sem_csqPA ∅ F (to_PA φ) ↔ global_sem_csq ∅ F φ :=\nbegin\nsplit,\nintros h1 f h2 v h3 x,\nhave h4 := (forces_ctxPA_iff_forces_ctx f v).mpr h3,\nexact (forcesPA_iff_forces φ f v x).mp (h1 f h2 v h4 x),\nintros h1 f h2 v h3 x,\nhave h4 := (forces_ctxPA_iff_forces_ctx f v).mp h3,\nexact (forcesPA_iff_forces φ f v x).mpr (h1 f h2 v h4 x)\nend\n\n\ntheorem completenessPA {φ : formPA agents} (Γ : ctxPA agents) : \n  global_sem_csqPA ∅ equiv_class φ → prfPA ∅ φ :=\nbegin\nintros h1,\nhave h2 := mp pl5 (equiv_translation ∅ φ),\nhave h3 := soundnessPA,\nhave h4 : global_sem_csqPA ∅ equiv_class (to_PA (translate φ)), \n{intros f h4 v h5 x,\nexact h3 h2 f h4 v h5 x (h1 f h4 v h5 x)},\nhave h5 := (global_sem_csqPA_iff_global_sem_csq equiv_class (translate φ) ).mp h4,\nhave h6 := canonical.completeness sem_consS5 (translate φ),\nhave h7 := to_prfPA (h6 h5),\nsimp at *,\nexact mp (mp pl6 (equiv_translation ∅ φ)) h7\nend", "meta": {"author": "paulaneeley", "repo": "modal", "sha": "ee5d149d4ecb337005b850bddf4453e56a5daf04", "save_path": "github-repos/lean/paulaneeley-modal", "path": "github-repos/lean/paulaneeley-modal/modal-ee5d149d4ecb337005b850bddf4453e56a5daf04/src/del/semantics/translation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.497422521653905}}
{"text": "namespace Hidden\n\ninductive Eq {α : Sort u} (a : α) : α → Prop where\n  | intro : Eq a a\n\ninductive Nonempty (α : Sort u) : Prop where\n  | intro : α → Nonempty α\n\ntheorem elim_from_prop_is_bad\n(choice : ∀{α}, Nonempty α → α) :\n¬({α : Type u} → {x : α} → choice ⟨x⟩ = x) := by\n  intro h\n  let true' : ULift Bool := ⟨true⟩\n  let false' : ULift Bool := ⟨false⟩\n  have t_eq_f : true' = false' := h.symm.trans h\n  have : true = false := congrArg ULift.down t_eq_f\n  contradiction\n\ndef Or.by_cases [Decidable p] [Decidable q] {α : Sort u}\n(h : p ∨ q) (fp : p → α) (fq : q → α) : α :=\n  if hp : p then fp hp else\n  if hq : q then fq hq else\n  False.elim (Or.elim h hp hq)\n\ndef Nat.strong_rec {p : Nat → Sort u}\n(h : (n : Nat) → ((m : Nat) → m < n → p m) → p n)\n(n : Nat) : p n :=\n  h n (aux n)\nwhere\n  aux : (n m : Nat) → m < n → p m\n    | 0, m, h₁ => absurd h₁ (Nat.not_lt_zero m)\n    | n+1, m, h₁ => Or.by_cases (Nat.eq_or_lt_of_le (Nat.le_of_lt_succ h₁))\n      (λ h₂ => h₂ ▸ h n (aux n))\n      (λ h₂ => (aux n) m h₂)\n\nend Hidden", "meta": {"author": "sjdrodge", "repo": "lean4_learning", "sha": "32bce551cb30e3979ff7494c4574a11fc3abbb2f", "save_path": "github-repos/lean/sjdrodge-lean4_learning", "path": "github-repos/lean/sjdrodge-lean4_learning/lean4_learning-32bce551cb30e3979ff7494c4574a11fc3abbb2f/Lean4Learning.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4974225152885853}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.functor.fully_faithful\nimport category_theory.full_subcategory\nimport category_theory.whiskering\nimport category_theory.essential_image\nimport tactic.slice\n\n/-!\n# Equivalence of categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nAn equivalence of categories `C` and `D` is a pair of functors `F : C ⥤ D` and `G : D ⥤ C` such\nthat `η : 𝟭 C ≅ F ⋙ G` and `ε : G ⋙ F ≅ 𝟭 D`. In many situations, equivalences are a better\nnotion of \"sameness\" of categories than the stricter isomorphims of categories.\n\nRecall that one way to express that two functors `F : C ⥤ D` and `G : D ⥤ C` are adjoint is using\ntwo natural transformations `η : 𝟭 C ⟶ F ⋙ G` and `ε : G ⋙ F ⟶ 𝟭 D`, called the unit and the\ncounit, such that the compositions `F ⟶ FGF ⟶ F` and `G ⟶ GFG ⟶ G` are the identity. Unfortunately,\nit is not the case that the natural isomorphisms `η` and `ε` in the definition of an equivalence\nautomatically give an adjunction. However, it is true that\n* if one of the two compositions is the identity, then so is the other, and\n* given an equivalence of categories, it is always possible to refine `η` in such a way that the\n  identities are satisfied.\n\nFor this reason, in mathlib we define an equivalence to be a \"half-adjoint equivalence\", which is\na tuple `(F, G, η, ε)` as in the first paragraph such that the composite `F ⟶ FGF ⟶ F` is the\nidentity. By the remark above, this already implies that the tuple is an \"adjoint equivalence\",\ni.e., that the composite `G ⟶ GFG ⟶ G` is also the identity.\n\nWe also define essentially surjective functors and show that a functor is an equivalence if and only\nif it is full, faithful and essentially surjective.\n\n## Main definitions\n\n* `equivalence`: bundled (half-)adjoint equivalences of categories\n* `is_equivalence`: type class on a functor `F` containing the data of the inverse `G` as well as\n  the natural isomorphisms `η` and `ε`.\n* `ess_surj`: type class on a functor `F` containing the data of the preimages and the isomorphisms\n  `F.obj (preimage d) ≅ d`.\n\n## Main results\n\n* `equivalence.mk`: upgrade an equivalence to a (half-)adjoint equivalence\n* `is_equivalence.equiv_of_iso`: when `F` and `G` are isomorphic functors, `F` is an equivalence\niff `G` is.\n* `equivalence.of_fully_faithfully_ess_surj`: a fully faithful essentially surjective functor is an\n  equivalence.\n\n## Notations\n\nWe write `C ≌ D` (`\\backcong`, not to be confused with `≅`/`\\cong`) for a bundled equivalence.\n\n-/\n\nnamespace category_theory\nopen category_theory.functor nat_iso category\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\n/-- We define an equivalence as a (half)-adjoint equivalence, a pair of functors with\n  a unit and counit which are natural isomorphisms and the triangle law `Fη ≫ εF = 1`, or in other\n  words the composite `F ⟶ FGF ⟶ F` is the identity.\n\n  In `unit_inverse_comp`, we show that this is actually an adjoint equivalence, i.e., that the\n  composite `G ⟶ GFG ⟶ G` is also the identity.\n\n  The triangle equation is written as a family of equalities between morphisms, it is more\n  complicated if we write it as an equality of natural transformations, because then we would have\n  to insert natural transformations like `F ⟶ F1`.\n\nSee <https://stacks.math.columbia.edu/tag/001J>\n-/\nstructure equivalence (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D] :=\nmk' ::\n(functor : C ⥤ D)\n(inverse : D ⥤ C)\n(unit_iso   : 𝟭 C ≅ functor ⋙ inverse)\n(counit_iso : inverse ⋙ functor ≅ 𝟭 D)\n(functor_unit_iso_comp' : ∀(X : C), functor.map ((unit_iso.hom : 𝟭 C ⟶ functor ⋙ inverse).app X) ≫\n  counit_iso.hom.app (functor.obj X) = 𝟙 (functor.obj X) . obviously)\n\nrestate_axiom equivalence.functor_unit_iso_comp'\n\ninfixr ` ≌ `:10  := equivalence\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\nnamespace equivalence\n\n/-- The unit of an equivalence of categories. -/\nabbreviation unit (e : C ≌ D) : 𝟭 C ⟶ e.functor ⋙ e.inverse := e.unit_iso.hom\n/-- The counit of an equivalence of categories. -/\nabbreviation counit (e : C ≌ D) : e.inverse ⋙ e.functor ⟶ 𝟭 D := e.counit_iso.hom\n/-- The inverse of the unit of an equivalence of categories. -/\nabbreviation unit_inv (e : C ≌ D) : e.functor ⋙ e.inverse ⟶ 𝟭 C := e.unit_iso.inv\n/-- The inverse of the counit of an equivalence of categories. -/\nabbreviation counit_inv (e : C ≌ D) : 𝟭 D ⟶ e.inverse ⋙ e.functor := e.counit_iso.inv\n\n/- While these abbreviations are convenient, they also cause some trouble,\npreventing structure projections from unfolding. -/\n@[simp] lemma equivalence_mk'_unit (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit = unit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit = counit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_unit_inv (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit_inv = unit_iso.inv := rfl\n@[simp] lemma equivalence_mk'_counit_inv (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit_inv = counit_iso.inv := rfl\n\n@[simp] lemma functor_unit_comp (e : C ≌ D) (X : C) :\n  e.functor.map (e.unit.app X) ≫ e.counit.app (e.functor.obj X) = 𝟙 (e.functor.obj X) :=\ne.functor_unit_iso_comp X\n\n@[simp] lemma counit_inv_functor_comp (e : C ≌ D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) ≫ e.functor.map (e.unit_inv.app X) = 𝟙 (e.functor.obj X) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.functor.map_iso (e.unit_iso.app X) ≪≫ e.counit_iso.app (e.functor.obj X)) (iso.refl _)],\n  exact e.functor_unit_comp X\nend\n\nlemma counit_inv_app_functor (e : C ≌ D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) = e.functor.map (e.unit.app X) :=\nby { symmetry, erw [←iso.comp_hom_eq_id (e.counit_iso.app _), functor_unit_comp], refl }\n\nlemma counit_app_functor (e : C ≌ D) (X : C) :\n  e.counit.app (e.functor.obj X) = e.functor.map (e.unit_inv.app X) :=\nby { erw [←iso.hom_comp_eq_id (e.functor.map_iso (e.unit_iso.app X)), functor_unit_comp], refl }\n\n/-- The other triangle equality. The proof follows the following proof in Globular:\n  http://globular.science/1905.001 -/\n@[simp] lemma unit_inverse_comp (e : C ≌ D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) ≫ e.inverse.map (e.counit.app Y) = 𝟙 (e.inverse.obj Y) :=\nbegin\n  rw [←id_comp (e.inverse.map _), ←map_id e.inverse, ←counit_inv_functor_comp, map_comp],\n  dsimp,\n  rw [←iso.hom_inv_id_assoc (e.unit_iso.app _) (e.inverse.map (e.functor.map _)),\n      app_hom, app_inv],\n  slice_lhs 2 3 { erw [e.unit.naturality] },\n  slice_lhs 1 2 { erw [e.unit.naturality] },\n  slice_lhs 4 4\n  { rw [←iso.hom_inv_id_assoc (e.inverse.map_iso (e.counit_iso.app _)) (e.unit_inv.app _)] },\n  slice_lhs 3 4 { erw [←map_comp e.inverse, e.counit.naturality],\n    erw [(e.counit_iso.app _).hom_inv_id, map_id] }, erw [id_comp],\n  slice_lhs 2 3 { erw [←map_comp e.inverse, e.counit_iso.inv.naturality, map_comp] },\n  slice_lhs 3 4 { erw [e.unit_inv.naturality] },\n  slice_lhs 4 5 { erw [←map_comp (e.functor ⋙ e.inverse), (e.unit_iso.app _).hom_inv_id, map_id] },\n  erw [id_comp],\n  slice_lhs 3 4 { erw [←e.unit_inv.naturality] },\n  slice_lhs 2 3 { erw [←map_comp e.inverse, ←e.counit_iso.inv.naturality,\n    (e.counit_iso.app _).hom_inv_id, map_id] }, erw [id_comp, (e.unit_iso.app _).hom_inv_id], refl\nend\n\n@[simp] lemma inverse_counit_inv_comp (e : C ≌ D) (Y : D) :\n  e.inverse.map (e.counit_inv.app Y) ≫ e.unit_inv.app (e.inverse.obj Y) = 𝟙 (e.inverse.obj Y) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.unit_iso.app (e.inverse.obj Y) ≪≫ e.inverse.map_iso (e.counit_iso.app Y)) (iso.refl _)],\n  exact e.unit_inverse_comp Y\nend\n\nlemma unit_app_inverse (e : C ≌ D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counit_inv.app Y) :=\nby { erw [←iso.comp_hom_eq_id (e.inverse.map_iso (e.counit_iso.app Y)), unit_inverse_comp], refl }\n\nlemma unit_inv_app_inverse (e : C ≌ D) (Y : D) :\n  e.unit_inv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) :=\nby { symmetry, erw [←iso.hom_comp_eq_id (e.unit_iso.app _), unit_inverse_comp], refl }\n\n@[simp] lemma fun_inv_map (e : C ≌ D) (X Y : D) (f : X ⟶ Y) :\n  e.functor.map (e.inverse.map f) = e.counit.app X ≫ f ≫ e.counit_inv.app Y :=\n(nat_iso.naturality_2 (e.counit_iso) f).symm\n\n@[simp] lemma inv_fun_map (e : C ≌ D) (X Y : C) (f : X ⟶ Y) :\n  e.inverse.map (e.functor.map f) = e.unit_inv.app X ≫ f ≫ e.unit.app Y :=\n(nat_iso.naturality_1 (e.unit_iso) f).symm\n\nsection\n-- In this section we convert an arbitrary equivalence to a half-adjoint equivalence.\nvariables {F : C ⥤ D} {G : D ⥤ C} (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D)\n\n/-- If `η : 𝟭 C ≅ F ⋙ G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it\nto a refined natural isomorphism `adjointify_η η : 𝟭 C ≅ F ⋙ G` which exhibits the properties\nrequired for a half-adjoint equivalence. See `equivalence.mk`. -/\ndef adjointify_η : 𝟭 C ≅ F ⋙ G :=\ncalc\n  𝟭 C ≅ F ⋙ G               : η\n  ... ≅ F ⋙ (𝟭 D ⋙ G)      : iso_whisker_left F (left_unitor G).symm\n  ... ≅ F ⋙ ((G ⋙ F) ⋙ G) : iso_whisker_left F (iso_whisker_right ε.symm G)\n  ... ≅ F ⋙ (G ⋙ (F ⋙ G)) : iso_whisker_left F (associator G F G)\n  ... ≅ (F ⋙ G) ⋙ (F ⋙ G) : (associator F G (F ⋙ G)).symm\n  ... ≅ 𝟭 C ⋙ (F ⋙ G)      : iso_whisker_right η.symm (F ⋙ G)\n  ... ≅ F ⋙ G               : left_unitor (F ⋙ G)\n\nlemma adjointify_η_ε (X : C) :\n  F.map ((adjointify_η η ε).hom.app X) ≫ ε.hom.app (F.obj X) = 𝟙 (F.obj X) :=\nbegin\n  dsimp [adjointify_η], simp,\n  have := ε.hom.naturality (F.map (η.inv.app X)), dsimp at this, rw [this], clear this,\n  rw [←assoc _ _ (F.map _)],\n  have := ε.hom.naturality (ε.inv.app $ F.obj X), dsimp at this, rw [this], clear this,\n  have := (ε.app $ F.obj X).hom_inv_id, dsimp at this, rw [this], clear this,\n  rw [id_comp], have := (F.map_iso $ η.app X).hom_inv_id, dsimp at this, rw [this]\nend\n\nend\n\n/-- Every equivalence of categories consisting of functors `F` and `G` such that `F ⋙ G` and\n    `G ⋙ F` are naturally isomorphic to identity functors can be transformed into a half-adjoint\n    equivalence without changing `F` or `G`. -/\nprotected definition mk (F : C ⥤ D) (G : D ⥤ C)\n  (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : C ≌ D :=\n⟨F, G, adjointify_η η ε, ε, adjointify_η_ε η ε⟩\n\n/-- Equivalence of categories is reflexive. -/\n@[refl, simps] def refl : C ≌ C :=\n⟨𝟭 C, 𝟭 C, iso.refl _, iso.refl _, λ X, category.id_comp _⟩\n\ninstance : inhabited (C ≌ C) :=\n⟨refl⟩\n\n/-- Equivalence of categories is symmetric. -/\n@[symm, simps] def symm (e : C ≌ D) : D ≌ C :=\n⟨e.inverse, e.functor, e.counit_iso.symm, e.unit_iso.symm, e.inverse_counit_inv_comp⟩\n\nvariables {E : Type u₃} [category.{v₃} E]\n\n/-- Equivalence of categories is transitive. -/\n@[trans, simps] def trans (e : C ≌ D) (f : D ≌ E) : C ≌ E :=\n{ functor := e.functor ⋙ f.functor,\n  inverse := f.inverse ⋙ e.inverse,\n  unit_iso :=\n  begin\n    refine iso.trans e.unit_iso _,\n    exact iso_whisker_left e.functor (iso_whisker_right f.unit_iso e.inverse) ,\n  end,\n  counit_iso :=\n  begin\n    refine iso.trans _ f.counit_iso,\n    exact iso_whisker_left f.inverse (iso_whisker_right e.counit_iso f.functor)\n  end,\n  -- We wouldn't have needed to give this proof if we'd used `equivalence.mk`,\n  -- but we choose to avoid using that here, for the sake of good structure projection `simp`\n  -- lemmas.\n  functor_unit_iso_comp' := λ X,\n  begin\n    dsimp,\n    rw [← f.functor.map_comp_assoc, e.functor.map_comp, ←counit_inv_app_functor, fun_inv_map,\n        iso.inv_hom_id_app_assoc, assoc, iso.inv_hom_id_app, counit_app_functor,\n        ← functor.map_comp],\n    erw [comp_id, iso.hom_inv_id_app, functor.map_id],\n  end }\n\n/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic\nfunctor. -/\ndef fun_inv_id_assoc (e : C ≌ D) (F : C ⥤ E) : e.functor ⋙ e.inverse ⋙ F ≅ F :=\n(functor.associator _ _ _).symm ≪≫ iso_whisker_right e.unit_iso.symm F ≪≫ F.left_unitor\n\n@[simp] lemma fun_inv_id_assoc_hom_app (e : C ≌ D) (F : C ⥤ E) (X : C) :\n  (fun_inv_id_assoc e F).hom.app X = F.map (e.unit_inv.app X) :=\nby { dsimp [fun_inv_id_assoc], tidy }\n\n@[simp] lemma fun_inv_id_assoc_inv_app (e : C ≌ D) (F : C ⥤ E) (X : C) :\n  (fun_inv_id_assoc e F).inv.app X = F.map (e.unit.app X) :=\nby { dsimp [fun_inv_id_assoc], tidy }\n\n/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic\nfunctor. -/\ndef inv_fun_id_assoc (e : C ≌ D) (F : D ⥤ E) : e.inverse ⋙ e.functor ⋙ F ≅ F :=\n(functor.associator _ _ _).symm ≪≫ iso_whisker_right e.counit_iso F ≪≫ F.left_unitor\n\n@[simp] lemma inv_fun_id_assoc_hom_app (e : C ≌ D) (F : D ⥤ E) (X : D) :\n  (inv_fun_id_assoc e F).hom.app X = F.map (e.counit.app X) :=\nby { dsimp [inv_fun_id_assoc], tidy }\n\n@[simp] lemma inv_fun_id_assoc_inv_app (e : C ≌ D) (F : D ⥤ E) (X : D) :\n  (inv_fun_id_assoc e F).inv.app X = F.map (e.counit_inv.app X) :=\nby { dsimp [inv_fun_id_assoc], tidy }\n\n/-- If `C` is equivalent to `D`, then `C ⥤ E` is equivalent to `D ⥤ E`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_left (e : C ≌ D) : (C ⥤ E) ≌ (D ⥤ E) :=\nequivalence.mk\n  ((whiskering_left _ _ _).obj e.inverse)\n  ((whiskering_left _ _ _).obj e.functor)\n  (nat_iso.of_components (λ F, (e.fun_inv_id_assoc F).symm) (by tidy))\n  (nat_iso.of_components (λ F, e.inv_fun_id_assoc F) (by tidy))\n\n/-- If `C` is equivalent to `D`, then `E ⥤ C` is equivalent to `E ⥤ D`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_right (e : C ≌ D) : (E ⥤ C) ≌ (E ⥤ D) :=\nequivalence.mk\n  ((whiskering_right _ _ _).obj e.functor)\n  ((whiskering_right _ _ _).obj e.inverse)\n  (nat_iso.of_components\n    (λ F, F.right_unitor.symm ≪≫ iso_whisker_left F e.unit_iso ≪≫ functor.associator _ _ _)\n    (by tidy))\n  (nat_iso.of_components\n    (λ F, functor.associator _ _ _ ≪≫ iso_whisker_left F e.counit_iso ≪≫ F.right_unitor)\n    (by tidy))\n\nsection cancellation_lemmas\nvariables (e : C ≌ D)\n\n/- We need special forms of `cancel_nat_iso_hom_right(_assoc)` and\n`cancel_nat_iso_inv_right(_assoc)` for units and counits, because neither `simp` or `rw` will apply\nthose lemmas in this setting without providing `e.unit_iso` (or similar) as an explicit argument.\nWe also provide the lemmas for length four compositions, since they're occasionally useful.\n(e.g. in proving that equivalences take monos to monos) -/\n\n@[simp] lemma cancel_unit_right {X Y : C}\n  (f f' : X ⟶ Y) :\n  f ≫ e.unit.app Y = f' ≫ e.unit.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_inv_right {X Y : C}\n  (f f' : X ⟶ e.inverse.obj (e.functor.obj Y))   :\n  f ≫ e.unit_inv.app Y = f' ≫ e.unit_inv.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_right {X Y : D}\n  (f f' : X ⟶ e.functor.obj (e.inverse.obj Y))   :\n  f ≫ e.counit.app Y = f' ≫ e.counit.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right {X Y : D}\n  (f f' : X ⟶ Y) :\n  f ≫ e.counit_inv.app Y = f' ≫ e.counit_inv.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc {W X X' Y : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) :\n  f ≫ g ≫ e.unit.app Y = f' ≫ g' ≫ e.unit.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right_assoc {W X X' Y : D}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) :\n  f ≫ g ≫ e.counit_inv.app Y = f' ≫ g' ≫ e.counit_inv.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc' {W X X' Y Y' Z : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z) (f' : W ⟶ X') (g' : X' ⟶ Y') (h' : Y' ⟶ Z) :\n  f ≫ g ≫ h ≫ e.unit.app Z = f' ≫ g' ≫ h' ≫ e.unit.app Z ↔ f ≫ g ≫ h = f' ≫ g' ≫ h' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] \n\nend cancellation_lemmas\n\nsection\n\n-- There's of course a monoid structure on `C ≌ C`,\n-- but let's not encourage using it.\n-- The power structure is nevertheless useful.\n\n/-- Natural number powers of an auto-equivalence.  Use `(^)` instead. -/\ndef pow_nat (e : C ≌ C) : ℕ → (C ≌ C)\n| 0 := equivalence.refl\n| 1 := e\n| (n+2) := e.trans (pow_nat (n+1))\n\n/-- Powers of an auto-equivalence.  Use `(^)` instead. -/\ndef pow (e : C ≌ C) : ℤ → (C ≌ C)\n| (int.of_nat n) := e.pow_nat n\n| (int.neg_succ_of_nat n) := e.symm.pow_nat (n+1)\n\ninstance : has_pow (C ≌ C) ℤ := ⟨pow⟩\n\n@[simp] lemma pow_zero (e : C ≌ C) : e^(0 : ℤ) = equivalence.refl := rfl\n@[simp] lemma pow_one (e : C ≌ C) : e^(1 : ℤ) = e := rfl\n@[simp] lemma pow_neg_one (e : C ≌ C) : e^(-1 : ℤ) = e.symm := rfl\n\n-- TODO as necessary, add the natural isomorphisms `(e^a).trans e^b ≅ e^(a+b)`.\n-- At this point, we haven't even defined the category of equivalences.\n\nend\n\nend equivalence\n\n\n/-- A functor that is part of a (half) adjoint equivalence -/\nclass is_equivalence (F : C ⥤ D) :=\nmk' ::\n(inverse    : D ⥤ C)\n(unit_iso   : 𝟭 C ≅ F ⋙ inverse)\n(counit_iso : inverse ⋙ F ≅ 𝟭 D)\n(functor_unit_iso_comp' : ∀ (X : C), F.map ((unit_iso.hom : 𝟭 C ⟶ F ⋙ inverse).app X) ≫\n  counit_iso.hom.app (F.obj X) = 𝟙 (F.obj X) . obviously)\n\nrestate_axiom is_equivalence.functor_unit_iso_comp'\n\nattribute [simp, reassoc] is_equivalence.functor_unit_iso_comp\n\nnamespace is_equivalence\n\ninstance of_equivalence (F : C ≌ D) : is_equivalence F.functor :=\n{ ..F }\n\ninstance of_equivalence_inverse (F : C ≌ D) : is_equivalence F.inverse :=\nis_equivalence.of_equivalence F.symm\n\nopen equivalence\n/-- To see that a functor is an equivalence, it suffices to provide an inverse functor `G` such that\n    `F ⋙ G` and `G ⋙ F` are naturally isomorphic to identity functors. -/\nprotected definition mk {F : C ⥤ D} (G : D ⥤ C)\n  (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : is_equivalence F :=\n⟨G, adjointify_η η ε, ε, adjointify_η_ε η ε⟩\n\nend is_equivalence\n\n\nnamespace functor\n\n/-- Interpret a functor that is an equivalence as an equivalence. -/\ndef as_equivalence (F : C ⥤ D) [is_equivalence F] : C ≌ D :=\n⟨F, is_equivalence.inverse F, is_equivalence.unit_iso, is_equivalence.counit_iso,\n  is_equivalence.functor_unit_iso_comp⟩\n\ninstance is_equivalence_refl : is_equivalence (𝟭 C) :=\nis_equivalence.of_equivalence equivalence.refl\n\n/-- The inverse functor of a functor that is an equivalence. -/\ndef inv (F : C ⥤ D) [is_equivalence F] : D ⥤ C :=\nis_equivalence.inverse F\n\ninstance is_equivalence_inv (F : C ⥤ D) [is_equivalence F] : is_equivalence F.inv :=\nis_equivalence.of_equivalence F.as_equivalence.symm\n\n@[simp] lemma as_equivalence_functor (F : C ⥤ D) [is_equivalence F] :\n  F.as_equivalence.functor = F := rfl\n\n@[simp] lemma as_equivalence_inverse (F : C ⥤ D) [is_equivalence F] :\n  F.as_equivalence.inverse = inv F := rfl\n\n@[simp] lemma as_equivalence_unit {F : C ⥤ D} [h : is_equivalence F] :\n  F.as_equivalence.unit_iso = @@is_equivalence.unit_iso _ _ h := rfl\n\n@[simp] lemma as_equivalence_counit {F : C ⥤ D} [is_equivalence F] :\n  F.as_equivalence.counit_iso = is_equivalence.counit_iso := rfl\n\n@[simp] lemma inv_inv (F : C ⥤ D) [is_equivalence F] :\n  inv (inv F) = F := rfl\n\nvariables {E : Type u₃} [category.{v₃} E]\n\ninstance is_equivalence_trans (F : C ⥤ D) (G : D ⥤ E) [is_equivalence F] [is_equivalence G] :\n  is_equivalence (F ⋙ G) :=\nis_equivalence.of_equivalence (equivalence.trans (as_equivalence F) (as_equivalence G))\n\nend functor\n\nnamespace equivalence\n\n@[simp]\nlemma functor_inv (E : C ≌ D) : E.functor.inv = E.inverse := rfl\n\n@[simp]\nlemma inverse_inv (E : C ≌ D) : E.inverse.inv = E.functor := rfl\n\n@[simp]\nlemma functor_as_equivalence (E : C ≌ D) : E.functor.as_equivalence = E :=\nby { cases E, congr, }\n\n@[simp]\nlemma inverse_as_equivalence (E : C ≌ D) : E.inverse.as_equivalence = E.symm :=\nby { cases E, congr, }\n\nend equivalence\n\nnamespace is_equivalence\n\n@[simp] lemma fun_inv_map (F : C ⥤ D) [is_equivalence F] (X Y : D) (f : X ⟶ Y) :\n  F.map (F.inv.map f) = F.as_equivalence.counit.app X ≫ f ≫ F.as_equivalence.counit_inv.app Y :=\nbegin\n  erw [nat_iso.naturality_2],\n  refl\nend\n@[simp] lemma inv_fun_map (F : C ⥤ D) [is_equivalence F] (X Y : C) (f : X ⟶ Y) :\n  F.inv.map (F.map f) = F.as_equivalence.unit_inv.app X ≫ f ≫ F.as_equivalence.unit.app Y :=\nbegin\n  erw [nat_iso.naturality_1],\n  refl\nend\n\n/-- When a functor `F` is an equivalence of categories, and `G` is isomorphic to `F`, then\n`G` is also an equivalence of categories. -/\n@[simps]\ndef of_iso {F G : C ⥤ D} (e : F ≅ G) (hF : is_equivalence F) : is_equivalence G :=\n{ inverse := hF.inverse,\n  unit_iso := hF.unit_iso ≪≫ nat_iso.hcomp e (iso.refl hF.inverse),\n  counit_iso := nat_iso.hcomp (iso.refl hF.inverse) e.symm ≪≫ hF.counit_iso,\n  functor_unit_iso_comp' := λ X, begin\n    dsimp [nat_iso.hcomp],\n    erw [id_comp, F.map_id, comp_id],\n    apply (cancel_epi (e.hom.app X)).mp,\n    slice_lhs 1 2 { rw ← e.hom.naturality, },\n    slice_lhs 2 3 { rw [← nat_trans.vcomp_app', e.hom_inv_id], },\n    simp only [nat_trans.id_app, id_comp, comp_id, F.map_comp, assoc],\n    erw hF.counit_iso.hom.naturality,\n    slice_lhs 1 2 { rw functor_unit_iso_comp, },\n    simp only [functor.id_map, id_comp],\n  end }\n\n/-- Compatibility of `of_iso` with the composition of isomorphisms of functors -/\nlemma of_iso_trans {F G H : C ⥤ D} (e : F ≅ G) (e' : G ≅ H) (hF : is_equivalence F) :\n  (of_iso e' (of_iso e hF)) = of_iso (e ≪≫ e') hF :=\nbegin\n  dsimp [of_iso],\n  congr' 1; ext X; dsimp [nat_iso.hcomp],\n  { simp only [id_comp, assoc, functor.map_comp], },\n  { simp only [functor.map_id, comp_id, id_comp, assoc], },\nend\n\n/-- Compatibility of `of_iso` with identity isomorphisms of functors -/\nlemma of_iso_refl (F : C ⥤ D) (hF : is_equivalence F) : of_iso (iso.refl F) hF = hF :=\nbegin\n  unfreezingI { rcases hF with ⟨Finv, Funit, Fcounit, Fcomp⟩, },\n  dsimp [of_iso],\n  congr' 1; ext X; dsimp [nat_iso.hcomp],\n  { simp only [comp_id, map_id], },\n  { simp only [id_comp, map_id], },\nend\n\n/-- When `F` and `G` are two isomorphic functors, then `F` is an equivalence iff `G` is. -/\n@[simps]\ndef equiv_of_iso {F G : C ⥤ D} (e : F ≅ G) : is_equivalence F ≃ is_equivalence G :=\n{ to_fun := of_iso e,\n  inv_fun := of_iso e.symm,\n  left_inv := λ hF, by rw [of_iso_trans, iso.self_symm_id, of_iso_refl],\n  right_inv := λ hF, by rw [of_iso_trans, iso.symm_self_id, of_iso_refl], }\n\n/-- If `G` and `F ⋙ G` are equivalence of categories, then `F` is also an equivalence. -/\n@[simp]\ndef cancel_comp_right {E : Type*} [category E]\n  (F : C ⥤ D) (G : D ⥤ E) (hG : is_equivalence G) (hGF : is_equivalence (F ⋙ G)) :\n  is_equivalence F :=\nof_iso ((functor.associator F G G.inv) ≪≫ nat_iso.hcomp (iso.refl F) hG.unit_iso.symm ≪≫\n  right_unitor F) (functor.is_equivalence_trans (F ⋙ G) (G.inv))\n\n/-- If `F` and `F ⋙ G` are equivalence of categories, then `G` is also an equivalence. -/\n@[simp]\ndef cancel_comp_left {E : Type*} [category E]\n  (F : C ⥤ D) (G : D ⥤ E) (hF : is_equivalence F) (hGF : is_equivalence (F ⋙ G)) :\n  is_equivalence G :=\nof_iso ((functor.associator F.inv F G).symm ≪≫ nat_iso.hcomp hF.counit_iso (iso.refl G) ≪≫\n  left_unitor G) (functor.is_equivalence_trans F.inv (F ⋙ G))\n\nend is_equivalence\n\nnamespace equivalence\n\n/--\nAn equivalence is essentially surjective.\n\nSee <https://stacks.math.columbia.edu/tag/02C3>.\n-/\nlemma ess_surj_of_equivalence (F : C ⥤ D) [is_equivalence F] : ess_surj F :=\n⟨λ Y, ⟨F.inv.obj Y, ⟨F.as_equivalence.counit_iso.app Y⟩⟩⟩\n\n/--\nAn equivalence is faithful.\n\nSee <https://stacks.math.columbia.edu/tag/02C3>.\n-/\n@[priority 100] -- see Note [lower instance priority]\ninstance faithful_of_equivalence (F : C ⥤ D) [is_equivalence F] : faithful F :=\n{ map_injective' := λ X Y f g w,\n  begin\n    have p := congr_arg (@category_theory.functor.map _ _ _ _ F.inv _ _) w,\n    simpa only [cancel_epi, cancel_mono, is_equivalence.inv_fun_map] using p\n  end }.\n\n/--\nAn equivalence is full.\n\nSee <https://stacks.math.columbia.edu/tag/02C3>.\n-/\n@[priority 100] -- see Note [lower instance priority]\ninstance full_of_equivalence (F : C ⥤ D) [is_equivalence F] : full F :=\n{ preimage := λ X Y f, F.as_equivalence.unit.app X ≫ F.inv.map f ≫ F.as_equivalence.unit_inv.app Y,\n  witness' := λ X Y f, F.inv.map_injective $\n  by simpa only [is_equivalence.inv_fun_map, assoc, iso.inv_hom_id_app_assoc, iso.inv_hom_id_app]\n    using comp_id _ }\n\n@[simps] private noncomputable def equivalence_inverse (F : C ⥤ D) [full F] [faithful F]\n  [ess_surj F] : D ⥤ C :=\n{ obj  := λ X, F.obj_preimage X,\n  map := λ X Y f, F.preimage ((F.obj_obj_preimage_iso X).hom ≫ f ≫ (F.obj_obj_preimage_iso Y).inv),\n  map_id' := λ X, begin apply F.map_injective, tidy end,\n  map_comp' := λ X Y Z f g, by apply F.map_injective; simp }\n\n/--\nA functor which is full, faithful, and essentially surjective is an equivalence.\n\nSee <https://stacks.math.columbia.edu/tag/02C3>.\n-/\nnoncomputable def of_fully_faithfully_ess_surj\n  (F : C ⥤ D) [full F] [faithful F] [ess_surj F] : is_equivalence F :=\nis_equivalence.mk (equivalence_inverse F)\n  (nat_iso.of_components\n    (λ X, (F.preimage_iso $ F.obj_obj_preimage_iso $ F.obj X).symm)\n    (λ X Y f, by { apply F.map_injective, obviously }))\n  (nat_iso.of_components F.obj_obj_preimage_iso (by tidy))\n\n@[simp] lemma functor_map_inj_iff (e : C ≌ D) {X Y : C} (f g : X ⟶ Y) :\n  e.functor.map f = e.functor.map g ↔ f = g :=\n⟨λ h, e.functor.map_injective h, λ h, h ▸ rfl⟩\n\n@[simp] lemma inverse_map_inj_iff (e : C ≌ D) {X Y : D} (f g : X ⟶ Y) :\n  e.inverse.map f = e.inverse.map g ↔ f = g :=\nfunctor_map_inj_iff e.symm f g\n\ninstance ess_surj_induced_functor {C' : Type*} (e : C' ≃ D) : ess_surj (induced_functor e) :=\n{ mem_ess_image := λ Y, ⟨e.symm Y, by simp⟩, }\n\nnoncomputable\ninstance induced_functor_of_equiv {C' : Type*} (e : C' ≃ D) : is_equivalence (induced_functor e) :=\nequivalence.of_fully_faithfully_ess_surj _\n\nnoncomputable\ninstance fully_faithful_to_ess_image (F : C ⥤ D) [full F] [faithful F] :\n  is_equivalence F.to_ess_image :=\nof_fully_faithfully_ess_surj F.to_ess_image\n\nend equivalence\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/equivalence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4972988808295925}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\nimport init.data.bool.basic init.meta\n\nattribute [simp] cond bor band bnot bxor\n\n@[simp] lemma {u} cond_a_a {α : Type u} (b : bool) (a : α) : cond b a a = a :=\nby cases b; simp\n\n@[simp] lemma band_self (b : bool) : b && b = b :=\nby cases b; simp\n\n@[simp] lemma band_tt (b : bool) : b && tt = b :=\nby cases b; simp\n\n@[simp] lemma band_ff (b : bool) : b && ff = ff :=\nby cases b; simp\n\n@[simp] lemma tt_band (b : bool) : tt && b = b :=\nby cases b; simp\n\n@[simp] lemma ff_band (b : bool) : ff && b = ff :=\nby cases b; simp\n\n@[simp] lemma bor_self (b : bool) : b || b = b :=\nby cases b; simp\n\n@[simp] lemma bor_tt (b : bool) : b || tt = tt :=\nby cases b; simp\n\n@[simp] lemma bor_ff (b : bool) : b || ff = b :=\nby cases b; simp\n\n@[simp] lemma tt_bor (b : bool) : tt || b = tt :=\nby cases b; simp\n\n@[simp] lemma ff_bor (b : bool) : ff || b = b :=\nby cases b; simp\n\n@[simp] lemma bxor_self (b : bool) : bxor b b = ff :=\nby cases b; simp\n\n@[simp] lemma bxor_tt (b : bool) : bxor b tt = bnot b :=\nby cases b; simp\n\nlemma bxor_ff (b : bool) : bxor b ff = b :=\nby cases b; simp\n\n@[simp] lemma tt_bxor (b : bool) : bxor tt b = bnot b :=\nby cases b; simp\n\nlemma ff_bxor (b : bool) : bxor ff b = b :=\nby cases b; simp\n\n@[simp] lemma bnot_bnot (b : bool) : bnot (bnot b) = b :=\nby cases b; simp\n\nlemma tt_eq_ff_eq_false : ¬(tt = ff) :=\nby contradiction\n\nlemma ff_eq_tt_eq_false : ¬(ff = tt) :=\nby contradiction\n\n@[simp] lemma eq_ff_eq_not_eq_tt (b : bool) : (¬(b = tt)) = (b = ff) :=\nby cases b; simp\n\n@[simp] lemma eq_tt_eq_not_eq_ff (b : bool) : (¬(b = ff)) = (b = tt) :=\nby cases b; simp\n\nlemma eq_ff_of_not_eq_tt {b : bool} : (¬(b = tt)) → (b = ff) :=\neq.mp (eq_ff_eq_not_eq_tt b)\n\nlemma eq_tt_of_not_eq_ff {b : bool} : (¬(b = ff)) → (b = tt) :=\neq.mp (eq_tt_eq_not_eq_ff b)\n\n@[simp] lemma band_eq_true_eq_eq_tt_and_eq_tt (a b : bool) : (a && b = tt) = (a = tt ∧ b = tt) :=\nby cases a; cases b; simp\n\n@[simp] lemma bor_eq_true_eq_eq_tt_or_eq_tt (a b : bool) : (a || b = tt) = (a = tt ∨ b = tt) :=\nby cases a; cases b; simp\n\n@[simp] lemma bnot_eq_true_eq_eq_ff (a : bool) : (bnot a = tt) = (a = ff) :=\nby cases a; simp\n\n@[simp] lemma band_eq_false_eq_eq_ff_or_eq_ff (a b : bool) : (a && b = ff) = (a = ff ∨ b = ff) :=\nby cases a; cases b; simp\n\n@[simp] lemma bor_eq_false_eq_eq_ff_and_eq_ff (a b : bool) : (a || b = ff) = (a = ff ∧ b = ff) :=\nby cases a; cases b; simp\n\n@[simp] lemma bnot_eq_ff_eq_eq_tt (a : bool) : (bnot a = ff) = (a = tt) :=\nby cases a; simp\n\n@[simp] lemma coe_ff : ↑ff = false :=\nshow (ff = tt) = false, by simp\n\n@[simp] lemma coe_tt : ↑tt = true :=\nshow (tt = tt) = true, by simp\n\n@[simp] lemma coe_sort_ff : ↥ff = false :=\nshow (ff = tt) = false, by simp\n\n@[simp] lemma coe_sort_tt : ↥tt = true :=\nshow (tt = tt) = true, by simp\n\n@[simp] theorem to_bool_iff (p : Prop) [d : decidable p] : (to_bool p = tt) ↔ p :=\nmatch d with\n| is_true hp := ⟨λh, hp, λ_, rfl⟩\n| is_false hnp := ⟨λh, bool.no_confusion h, λhp, absurd hp hnp⟩\nend\n\ntheorem to_bool_true {p : Prop} [decidable p] : p → to_bool p := (to_bool_iff p).2\n\ntheorem to_bool_tt {p : Prop} [decidable p] : p → to_bool p = tt := to_bool_true\n\ntheorem of_to_bool_true {p : Prop} [decidable p] : to_bool p → p := (to_bool_iff p).1\n\ntheorem bool_iff_false {b : bool} : ¬ b ↔ b = ff := by cases b; exact dec_trivial\n\ntheorem bool_eq_false {b : bool} : ¬ b → b = ff := bool_iff_false.1\n\n@[simp] theorem to_bool_ff_iff (p : Prop) [decidable p] : to_bool p = ff ↔ ¬p :=\nbool_iff_false.symm.trans (not_congr (to_bool_iff _))\n\ntheorem to_bool_ff {p : Prop} [decidable p] : ¬p → to_bool p = ff := (to_bool_ff_iff p).2\n\ntheorem of_to_bool_ff {p : Prop} [decidable p] : to_bool p = ff → ¬p := (to_bool_ff_iff p).1\n\ntheorem to_bool_congr {p q : Prop} [decidable p] [decidable q] (h : p ↔ q) : to_bool p = to_bool q :=\nbegin\n  induction h' : to_bool q,\n  exact to_bool_ff (mt h.1 $ of_to_bool_ff h'),\n  exact to_bool_true (h.2 $ of_to_bool_true h')\nend\n\n@[simp] theorem bor_coe_iff (a b : bool) : a || b ↔ a ∨ b :=\nby cases a; cases b; exact dec_trivial\n\n@[simp] theorem band_coe_iff (a b : bool) : a && b ↔ a ∧ b :=\nby cases a; cases b; exact dec_trivial\n\n@[simp] theorem bxor_coe_iff (a b : bool) : bxor a b ↔ xor a b :=\nby cases a; cases b; exact dec_trivial\n\n@[simp] theorem ite_eq_tt_distrib (c : Prop) [decidable c] (a b : bool) : ((if c then a else b) = tt) = (if c then a = tt else b = tt) :=\nby by_cases c; simp [*]\n\n@[simp] theorem ite_eq_ff_distrib (c : Prop) [decidable c] (a b : bool) : ((if c then a else b) = ff) = (if c then a = ff else b = ff) :=\nby by_cases c; simp [*]\n", "meta": {"author": "subfish-zhou", "repo": "N2Lean", "sha": "8e858cc5b01f1ad921094dc355db3cb9473a42fd", "save_path": "github-repos/lean/subfish-zhou-N2Lean", "path": "github-repos/lean/subfish-zhou-N2Lean/N2Lean-8e858cc5b01f1ad921094dc355db3cb9473a42fd/library/init/data/bool/lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.49729887049528976}}
{"text": "/-\nCopyright (c) 2020 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n\n! This file was ported from Lean 3 source module data.list.indexes\n! leanprover-community/mathlib commit 8631e2d5ea77f6c13054d9151d82b83069680cb1\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.List.OfFn\nimport Mathlib.Data.List.Range\n\n/-!\n# Lemmas about List.*Idx functions.\n\nSome specification lemmas for `List.mapIdx`, `List.mapIdxM`, `List.foldlIdx` and `List.foldrIdx`.\n-/\n\n\nuniverse u v\n\nopen Function\n\nnamespace List\n\nvariable {α : Type u} {β : Type v}\n\nsection MapIdx\n\n-- Porting note: Add back old definition because it's easier for writing proofs.\n\n/-- Lean3 `map_with_index` helper function -/\nprotected def oldMapIdxCore (f : ℕ → α → β) : ℕ → List α → List β\n  | _, []      => []\n  | k, a :: as => f k a :: List.oldMapIdxCore f (k + 1) as\n\n/-- Given a function `f : ℕ → α → β` and `as : List α`, `as = [a₀, a₁, ...]`, returns the list\n`[f 0 a₀, f 1 a₁, ...]`. -/\nprotected def oldMapIdx (f : ℕ → α → β) (as : List α) : List β :=\n  List.oldMapIdxCore f 0 as\n\n@[simp]\ntheorem mapIdx_nil {α β} (f : ℕ → α → β) : mapIdx f [] = [] :=\n  rfl\n#align list.map_with_index_nil List.mapIdx_nil\n\n-- Porting note: new theorem.\nprotected theorem oldMapIdxCore_eq (l : List α) (f : ℕ → α → β) (n : ℕ) :\n    l.oldMapIdxCore f n = l.oldMapIdx fun i a ↦ f (i + n) a := by\n  induction' l with hd tl hl generalizing f n\n  · rfl\n  · rw [List.oldMapIdx]\n    simp only [List.oldMapIdxCore, hl, add_left_comm, add_comm, add_zero, zero_add]\n#noalign list.map_with_index_core_eq\n\n-- Porting note: convert new definition to old definition.\n--   A few new theorems are added to achieve this\n--   1. Prove that `oldMapIdxCore f (l ++ [e]) = oldMapIdxCore f l ++ [f l.length e]`\n--   2. Prove that `oldMapIdx f (l ++ [e]) = oldMapIdx f l ++ [f l.length e]`\n--   3. Prove list induction using `∀ l e, p [] → (p l → p (l ++ [e])) → p l`\n-- Porting note: new theorem.\ntheorem list_reverse_induction (p : List α → Prop) (base : p [])\n    (ind : ∀ (l : List α) (e : α), p l → p (l ++ [e])) : (∀ (l : List α), p l) := by\n  let q := fun l ↦ p (reverse l)\n  have pq : ∀ l, p (reverse l) → q l := by simp only [reverse_reverse]; intro; exact id\n  have qp : ∀ l, q (reverse l) → p l := by simp only [reverse_reverse]; intro; exact id\n  intro l\n  apply qp\n  generalize (reverse l) = l\n  induction' l with head tail ih\n  · apply pq; simp only [reverse_nil, base]\n  · apply pq; simp only [reverse_cons]; apply ind; apply qp; rw [reverse_reverse]; exact ih\n\n-- Porting note: new theorem.\nprotected theorem oldMapIdxCore_append : ∀ (f : ℕ → α → β) (n : ℕ) (l₁ l₂ : List α),\n    List.oldMapIdxCore f n (l₁ ++ l₂) =\n    List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂ := by\n  intros f n l₁ l₂\n  generalize e : (l₁ ++ l₂).length = len\n  revert n l₁ l₂\n  induction' len with len ih <;> intros n l₁ l₂ h\n  · have l₁_nil : l₁ = [] := by cases l₁; rfl; contradiction\n    have l₂_nil : l₂ = [] := by cases l₂; rfl; rw [List.length_append] at h; contradiction\n    simp only [l₁_nil, l₂_nil]; rfl\n  · cases' l₁ with head tail\n    · rfl\n    · simp only [List.oldMapIdxCore, List.append_eq, length_cons, cons_append,cons.injEq, true_and]\n      suffices : n + Nat.succ (length tail) = n + 1 + tail.length\n      { rw [this]\n        apply ih (n + 1) _ _ _\n        simp only [cons_append, length_cons, length_append, Nat.succ.injEq] at h\n        simp only [length_append, h] }\n      { rw [Nat.add_assoc]; simp only [Nat.add_comm] }\n\n-- Porting note: new theorem.\nprotected theorem oldMapIdx_append : ∀ (f : ℕ → α → β) (l : List α) (e : α),\n    List.oldMapIdx f (l ++ [e]) = List.oldMapIdx f l ++ [f l.length e] := by\n  intros f l e\n  unfold List.oldMapIdx\n  rw [List.oldMapIdxCore_append f 0 l [e]]\n  simp only [zero_add, append_cancel_left_eq]; rfl\n\n-- Porting note: new theorem.\ntheorem mapIdxGo_append : ∀ (f : ℕ → α → β) (l₁ l₂ : List α) (arr : Array β),\n    mapIdx.go f (l₁ ++ l₂) arr = mapIdx.go f l₂ (List.toArray (mapIdx.go f l₁ arr)) := by\n  intros f l₁ l₂ arr\n  generalize e : (l₁ ++ l₂).length = len\n  revert l₁ l₂ arr\n  induction' len with len ih <;> intros l₁ l₂ arr h\n  · have l₁_nil : l₁ = [] := by cases l₁; rfl; contradiction\n    have l₂_nil : l₂ = [] := by cases l₂; rfl; rw [List.length_append] at h; contradiction\n    rw [l₁_nil, l₂_nil]; simp only [mapIdx.go, Array.toList_eq, Array.toArray_data]\n  · cases' l₁ with head tail <;> simp only [mapIdx.go]\n    · simp only [nil_append, Array.toList_eq, Array.toArray_data]\n    · simp only [List.append_eq]\n      rw [ih]\n      · simp only [cons_append, length_cons, length_append, Nat.succ.injEq] at h\n        simp only [length_append, h]\n\n-- Porting note: new theorem.\ntheorem mapIdxGo_length : ∀ (f : ℕ → α → β) (l : List α) (arr : Array β),\n    length (mapIdx.go f l arr) = length l + arr.size := by\n  intro f l\n  induction' l with head tail ih\n  · intro; simp only [mapIdx.go, Array.toList_eq, length_nil, zero_add]\n  · intro; simp only [mapIdx.go]; rw [ih]; simp only [Array.size_push, length_cons];\n    simp only [Nat.add_succ, add_zero, Nat.add_comm]\n\n-- Porting note: new theorem.\ntheorem mapIdx_append_one : ∀ (f : ℕ → α → β) (l : List α) (e : α),\n    mapIdx f (l ++ [e]) = mapIdx f l ++ [f l.length e] := by\n  intros f l e\n  unfold mapIdx\n  rw [mapIdxGo_append f l [e]]\n  simp only [mapIdx.go, Array.size_toArray, mapIdxGo_length, length_nil, add_zero, Array.toList_eq,\n    Array.push_data, Array.data_toArray]\n\n-- Porting note: new theorem.\nprotected theorem new_def_eq_old_def :\n    ∀ (f : ℕ → α → β) (l : List α), l.mapIdx f = List.oldMapIdx f l := by\n  intro f\n  apply list_reverse_induction\n  · rfl\n  · intro l e h\n    rw [List.oldMapIdx_append, mapIdx_append_one, h]\n\n@[local simp]\ntheorem map_enumFrom_eq_zipWith : ∀ (l : List α) (n : ℕ) (f : ℕ → α → β),\n    map (uncurry f) (enumFrom n l) = zipWith (fun i ↦ f (i + n)) (range (length l)) l := by\n  intro l\n  generalize e : l.length = len\n  revert l\n  induction' len with len ih <;> intros l e n f\n  · have : l = [] := by cases l; rfl; contradiction\n    rw [this] ; rfl\n  · cases' l with head tail\n    · contradiction\n    · simp only [map, uncurry_apply_pair, range_succ_eq_map, zipWith, zero_add, zipWith_map_left]\n      rw [ih]\n      suffices : (fun i ↦ f (i + (n + 1))) = ((fun i ↦ f (i + n)) ∘ Nat.succ)\n      rw [this]\n      funext n' a\n      simp only [comp, Nat.add_assoc, Nat.add_comm, Nat.add_succ]\n      simp only [length_cons, Nat.succ.injEq] at e; exact e\n\ntheorem mapIdx_eq_enum_map (l : List α) (f : ℕ → α → β) :\n    l.mapIdx f = l.enum.map (Function.uncurry f) := by\n  rw [List.new_def_eq_old_def]\n  induction' l with hd tl hl generalizing f\n  · rfl\n  · rw [List.oldMapIdx, List.oldMapIdxCore, List.oldMapIdxCore_eq, hl]\n    simp [enum_eq_zip_range, map_uncurry_zip_eq_zipWith]\n#align list.map_with_index_eq_enum_map List.mapIdx_eq_enum_map\n\n@[simp]\ntheorem mapIdx_cons {α β} (l : List α) (f : ℕ → α → β) (a : α) :\n    mapIdx f (a :: l) = f 0 a :: mapIdx (fun i ↦ f (i + 1)) l := by\n  simp [mapIdx_eq_enum_map, enum_eq_zip_range, map_uncurry_zip_eq_zipWith,\n    range_succ_eq_map, zipWith_map_left]\n#align list.map_with_index_cons List.mapIdx_cons\n\ntheorem mapIdx_append {α} (K L : List α) (f : ℕ → α → β) :\n    (K ++ L).mapIdx f = K.mapIdx f ++ L.mapIdx fun i a ↦ f (i + K.length) a := by\n  induction' K with a J IH generalizing f\n  · rfl\n  · simp [IH fun i ↦ f (i + 1), add_assoc]\n#align list.map_with_index_append List.mapIdx_append\n\n@[simp]\ntheorem length_mapIdx {α β} (l : List α) (f : ℕ → α → β) : (l.mapIdx f).length = l.length := by\n  induction' l with hd tl IH generalizing f\n  · rfl\n  · simp [IH]\n#align list.length_map_with_index List.length_mapIdx\n\n@[simp, deprecated]\ntheorem nthLe_mapIdx {α β} (l : List α) (f : ℕ → α → β) (i : ℕ) (h : i < l.length)\n    (h' : i < (l.mapIdx f).length := h.trans_le (l.length_mapIdx f).ge) :\n    (l.mapIdx f).nthLe i h' = f i (l.nthLe i h) := by\n  simp [mapIdx_eq_enum_map, enum_eq_zip_range]\n#align list.nth_le_map_with_index List.nthLe_mapIdx\n\n-- Porting note: Changed the type to use `List.get` instead of deprecated `List.nthLe`.\ntheorem mapIdx_eq_ofFn {α β} (l : List α) (f : ℕ → α → β) :\n    l.mapIdx f = ofFn fun i : Fin l.length ↦ f (i : ℕ) (l.get i) := by\n  induction' l with hd tl IH generalizing f\n  · rfl\n  · simp [IH]\n#align list.map_with_index_eq_of_fn List.mapIdx_eq_ofFn\n\nend MapIdx\n\nsection FoldrIdx\n\n-- Porting note: Changed argument order of `foldrIdxSpec` to align better with `foldrIdx`.\n/-- Specification of `foldrIdx`. -/\ndef foldrIdxSpec (f : ℕ → α → β → β) (b : β) (as : List α) (start : ℕ) : β :=\n  foldr (uncurry f) b <| enumFrom start as\n#align list.foldr_with_index_aux_spec List.foldrIdxSpecₓ\n\ntheorem foldrIdxSpec_cons (f : ℕ → α → β → β) (b a as start) :\n    foldrIdxSpec f b (a :: as) start = f start a (foldrIdxSpec f b as (start + 1)) :=\n  rfl\n#align list.foldr_with_index_aux_spec_cons List.foldrIdxSpec_consₓ\n\ntheorem foldrIdx_eq_foldrIdxSpec (f : ℕ → α → β → β) (b as start) :\n    foldrIdx f b as start = foldrIdxSpec f b as start := by\n  induction as generalizing start\n  · rfl\n  · simp only [foldrIdx, foldrIdxSpec_cons, *]\n#align list.foldr_with_index_aux_eq_foldr_with_index_aux_spec List.foldrIdx_eq_foldrIdxSpecₓ\n\ntheorem foldrIdx_eq_foldr_enum (f : ℕ → α → β → β) (b : β) (as : List α) :\n    foldrIdx f b as = foldr (uncurry f) b (enum as) := by\n  simp only [foldrIdx, foldrIdxSpec, foldrIdx_eq_foldrIdxSpec, enum]\n#align list.foldr_with_index_eq_foldr_enum List.foldrIdx_eq_foldr_enum\n\nend FoldrIdx\n\ntheorem indexesValues_eq_filter_enum (p : α → Prop) [DecidablePred p] (as : List α) :\n    indexesValues p as = filter (p ∘ Prod.snd) (enum as) := by\n  simp [indexesValues, foldrIdx_eq_foldr_enum, uncurry, filter_eq_foldr]\n#align list.indexes_values_eq_filter_enum List.indexesValues_eq_filter_enum\n\ntheorem findIdxs_eq_map_indexesValues (p : α → Prop) [DecidablePred p] (as : List α) :\n    findIdxs p as = map Prod.fst (indexesValues p as) := by\n  simp only [indexesValues_eq_filter_enum, map_filter_eq_foldr, findIdxs, uncurry,\n    foldrIdx_eq_foldr_enum, decide_eq_true_eq, comp_apply, Bool.cond_decide]\n#align list.find_indexes_eq_map_indexes_values List.findIdxs_eq_map_indexesValues\n\nsection FoldlIdx\n\n-- Porting note: Changed argument order of `foldlIdxSpec` to align better with `foldlIdx`.\n/-- Specification of `foldlIdx`. -/\ndef foldlIdxSpec (f : ℕ → α → β → α) (a : α) (bs : List β) (start : ℕ) : α :=\n  foldl (fun a p ↦ f p.fst a p.snd) a <| enumFrom start bs\n#align list.foldl_with_index_aux_spec List.foldlIdxSpecₓ\n\ntheorem foldlIdxSpec_cons (f : ℕ → α → β → α) (a b bs start) :\n    foldlIdxSpec f a (b :: bs) start = foldlIdxSpec f (f start a b) bs (start + 1) :=\n  rfl\n#align list.foldl_with_index_aux_spec_cons List.foldlIdxSpec_consₓ\n\ntheorem foldlIdx_eq_foldlIdxSpec (f : ℕ → α → β → α) (a bs start) :\n    foldlIdx f a bs start = foldlIdxSpec f a bs start := by\n  induction bs generalizing start a\n  · rfl\n  · simp [foldlIdxSpec, *]\n#align list.foldl_with_index_aux_eq_foldl_with_index_aux_spec List.foldlIdx_eq_foldlIdxSpecₓ\n\ntheorem foldlIdx_eq_foldl_enum (f : ℕ → α → β → α) (a : α) (bs : List β) :\n    foldlIdx f a bs = foldl (fun a p ↦ f p.fst a p.snd) a (enum bs) := by\n  simp only [foldlIdx, foldlIdxSpec, foldlIdx_eq_foldlIdxSpec, enum]\n#align list.foldl_with_index_eq_foldl_enum List.foldlIdx_eq_foldl_enum\n\nend FoldlIdx\n\nsection FoldIdxM\n\n-- Porting note: `foldrM_eq_foldr` now depends on `[LawfulMonad m]`\nvariable {m : Type u → Type v} [Monad m]\n\ntheorem foldrIdxM_eq_foldrM_enum {α β} (f : ℕ → α → β → m β) (b : β) (as : List α) [LawfulMonad m] :\n    foldrIdxM f b as = foldrM (uncurry f) b (enum as) := by\n  simp only [foldrIdxM, foldrM_eq_foldr, foldrIdx_eq_foldr_enum, uncurry]\n#align list.mfoldr_with_index_eq_mfoldr_enum List.foldrIdxM_eq_foldrM_enum\n\ntheorem foldlIdxM_eq_foldlM_enum [LawfulMonad m] {α β} (f : ℕ → β → α → m β) (b : β) (as : List α) :\n    foldlIdxM f b as = List.foldlM (fun b p ↦ f p.fst b p.snd) b (enum as) := by\n  rw [foldlIdxM, foldlM_eq_foldl, foldlIdx_eq_foldl_enum]\n#align list.mfoldl_with_index_eq_mfoldl_enum List.foldlIdxM_eq_foldlM_enum\n\nend FoldIdxM\n\nsection MapIdxM\n\n-- Porting note: `[Applicative m]` replaced by `[Monad m] [LawfulMonad m]`\nvariable {m : Type u → Type v} [Monad m] [LawfulMonad m]\n\n/-- Specification of `mapIdxMAux`. -/\ndef mapIdxMAuxSpec {α β} (f : ℕ → α → m β) (start : ℕ) (as : List α) : m (List β) :=\n  List.traverse (uncurry f) <| enumFrom start as\n#align list.mmap_with_index_aux_spec List.mapIdxMAuxSpec\n\n-- Note: `traverse` the class method would require a less universe-polymorphic\n-- `m : Type u → Type u`.\n\n\ntheorem mapIdxMGo_eq_mapIdxMAuxSpec {α β} (f : ℕ → α → m β) (arr : Array β) (as : List α) :\n    mapIdxM.go f as arr = (arr.toList ++ ·) <$> mapIdxMAuxSpec f arr.size as := by\n  generalize e : as.length = len\n  revert as arr\n  induction' len with len ih <;> intro arr as h\n  · have : as = [] := by cases as; rfl; contradiction\n    simp only [this, mapIdxM.go, mapIdxMAuxSpec, List.traverse, map_pure, append_nil]\n  · match as with\n    | nil => contradiction\n    | cons head tail =>\n      simp only [length_cons, Nat.succ.injEq] at h\n      simp only [mapIdxM.go, mapIdxMAuxSpec_cons, map_eq_pure_bind, seq_eq_bind_map,\n        LawfulMonad.bind_assoc, pure_bind]\n      congr\n      conv => { lhs; intro x; rw [ih _ _ h]; }\n      funext x\n      simp only [Array.toList_eq, Array.push_data, append_assoc, singleton_append, Array.size_push,\n        map_eq_pure_bind]\n#align list.mmap_with_index_aux_eq_mmap_with_index_aux_spec List.mapIdxMGo_eq_mapIdxMAuxSpec\n\ntheorem mapIdxM_eq_mmap_enum {α β} (f : ℕ → α → m β) (as : List α) :\n    as.mapIdxM f = List.traverse (uncurry f) (enum as) := by\n  simp only [mapIdxM, mapIdxMGo_eq_mapIdxMAuxSpec, Array.toList_eq, Array.data_toArray,\n    nil_append, mapIdxMAuxSpec, Array.size_toArray, length_nil, id_map', enum]\n#align list.mmap_with_index_eq_mmap_enum List.mapIdxM_eq_mmap_enum\n\nend MapIdxM\n\nsection MapIdxM'\n\n-- Porting note: `[Applicative m] [LawfulApplicative m]` replaced by [Monad m] [LawfulMonad m]\nvariable {m : Type u → Type v} [Monad m] [LawfulMonad m]\n\ntheorem mapIdxMAux'_eq_mapIdxMGo {α} (f : ℕ → α → m PUnit) (as : List α) (arr : Array PUnit) :\n    mapIdxMAux' f arr.size as = mapIdxM.go f as arr *> pure PUnit.unit := by\n  revert arr\n  induction' as with head tail ih <;> intro arr\n  · simp only [mapIdxMAux', mapIdxM.go, seqRight_eq, map_pure, seq_pure]\n  · simp only [mapIdxMAux', seqRight_eq, map_eq_pure_bind, seq_eq_bind, bind_pure_unit,\n      LawfulMonad.bind_assoc, pure_bind, mapIdxM.go, seq_pure]\n    generalize (f (Array.size arr) head) = head\n    let arr_1 := arr.push ⟨⟩\n    have : arr_1.size = arr.size + 1 := Array.size_push arr ⟨⟩\n    rw [← this, ih arr_1]\n    simp only [seqRight_eq, map_eq_pure_bind, seq_pure, LawfulMonad.bind_assoc, pure_bind]\n#align list.mmap_with_index'_aux_eq_mmap_with_index_aux List.mapIdxMAux'_eq_mapIdxMGo\n\ntheorem mapIdxM'_eq_mapIdxM {α} (f : ℕ → α → m PUnit) (as : List α) :\n    mapIdxM' f as = mapIdxM as f *> pure PUnit.unit :=\n  mapIdxMAux'_eq_mapIdxMGo f as #[]\n#align list.mmap_with_index'_eq_mmap_with_index List.mapIdxM'_eq_mapIdxM\n\nend MapIdxM'\n\nend List\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/List/Indexes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.7634837743174788, "lm_q1q2_score": 0.4972988704952897}}
{"text": "import .lang\n\n/-\nThe `has_app` typeclass provides an interpretation of a language.\n-/\nclass has_app (L : lang) (A : Type*) :=\n(app {n} : L n → ftuple A n → A)\n\nnotation `applyo` := has_app.app\n\n/-\nA morphism of raw algebras relative to a language L.\nUse the notation `A →$[L] B`.\n-/\nstructure ralg_hom (L : lang) (A : Type*) (B : Type*) [has_app L A] [has_app L B] :=\n(to_fn : A → B)\n(applyo_map' {n} {t : L n} {as : ftuple A n} : applyo t (as.map to_fn) = to_fn (applyo t as))\n\nnotation A ` →$[`:25 L:25 `] `:0 B:0 := ralg_hom L A B\n\nnamespace ralg_hom\ninstance {L : lang} {A : Type*} {B : Type*} [has_app L A] [has_app L B] : has_coe_to_fun (A →$[L] B ) := ⟨_,to_fn⟩\n\ntheorem applyo_map {n} {L : lang} {A : Type*} {B : Type*} [has_app L A] [has_app L B] \n  (f : A →$[L] B) (t : L n) (as : ftuple A n) : applyo t (as.map f) = f (applyo t as) := by apply ralg_hom.applyo_map'\n\ndef comp {L : lang} {A : Type*} {B : Type*} {C : Type*} [has_app L A] [has_app L B] [has_app L C] : \n  (A →$[L] B) → (B →$[L] C) → (A →$[L] C) := λ f g, \n{ to_fn := g ∘ f,\n  applyo_map' :=\n  begin\n    intros n t as, \n    change _ = g _,\n    simp_rw ←applyo_map, \n    refl,\n  end }\n\n@[ext]\ntheorem ext {L : lang} {A : Type*} {B : Type*} [has_app L A] [has_app L B] (f g : A →$[L] B) : ⇑f = g → f = g := \n  by {cases f, cases g, finish}\n\ntheorem comp_assoc {L : lang} {A : Type*} {B : Type*} {C : Type*} {D : Type*} \n  [has_app L A] [has_app L B] [has_app L C] [has_app L D]\n  (f : A →$[L] B) (g : B →$[L] C) (h : C →$[L] D) : (f.comp g).comp h = f.comp (g.comp h) := by {apply ext, refl}\nend ralg_hom\n\ndef applyt {n} {L : lang} {A : Type*} [has_app L A] (t : L.gen n) : ftuple A n → A :=\n  lang.term.rec_on t \n  (λ _, applyo) \n  (λ as, as 0)\n  (λ _ _ f _ h as, h (as.proj f)) \n  (λ _ _ _ _ h1 h2 as, as.compl h1 h2) \n  (λ _ _ _ _ h1 h2 as, as.compr h1 h2) \n\nnamespace ralg_hom\nlemma applyt_map {n} {L : lang} {A : Type*} {B : Type*} [has_app L A] [has_app L B]\n  (f : A →$[L] B) (t : L.gen n) (as : ftuple A n) : applyt t (as.map f) = f (applyt t as) := \nbegin\n  induction t with _ _ _ _ _ _ h _ _ t1 t2 h1 h2 _ _ t1 t2 h1 h2,\n  { apply ralg_hom.applyo_map,},\n  { refl, },\n  { apply h },\n  repeat { change applyt t2 (ftuple.append (ftuple.of $ applyt t1 _) _) = _ <|>\n    change applyt t2 (ftuple.append _ (ftuple.of $ applyt t1 _)) = _, \n    simp only [←ftuple.map_init, h1, ←ftuple.map_of, ←ftuple.map_last, ←ftuple.map_append, h2],\n    refl },\nend\nend ralg_hom\n\n--instance {L : lang} {A : Type*} [has_app L A] : has_app L.gen A := ⟨λ n, applyt⟩\n\n/-\nnamespace ralg_hom\ndef gen {L : lang} {A : Type*} {B : Type*} [has_app L A] [has_app L B] (f : A →$[L] B) : A →$[L.gen] B := \n  ⟨f,λ _, by apply gen.applyt_map⟩ \nend ralg_hom\n-/\n\nclass ualg {L : lang} (R : rules L) (A : Type*) extends has_app L A :=\n(cond_eq {n} (t1 t2 : L.gen n) (as : ftuple A n) : R t1 t2 → applyt t1 as = applyt t2 as)\n\n/-\nnamespace vac\ninstance {L} {A : Type*} [has_app L A] : ualg L.vac A := \n{ cond_eq := by tauto, \n  ..show has_app L A, by apply_instance } \nend vac\n-/", "meta": {"author": "adamtopaz", "repo": "UnivAlg", "sha": "2458d47a6e4fd0525e3a25b07cb7dd518ac173ef", "save_path": "github-repos/lean/adamtopaz-UnivAlg", "path": "github-repos/lean/adamtopaz-UnivAlg/UnivAlg-2458d47a6e4fd0525e3a25b07cb7dd518ac173ef/src/ualg.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.49729885315033306}}
{"text": "import analysis.topology.topological_space\n\nimport pequiv\n\nstructure phomeo α β [topological_space α] [topological_space β] extends pequiv α β :=\n(to_cont : ∀ V : set β, is_open V → is_open (to_fun ⁻¹' (V ∩ range) ∩ domain))\n(inv_cont : ∀ U : set α, is_open U → is_open (inv_fun ⁻¹' (U ∩ domain) ∩ range))\n\nnamespace phomeo\nvariables {α : Type*} {β : Type*} [topological_space α] [topological_space β]\n\n\ninstance : has_coe (phomeo α β) (pequiv α β) := ⟨λ f, f.to_pequiv⟩\n\ndef symm (f : phomeo α  β) : phomeo β α :=\n⟨f.to_pequiv.symm, f.inv_cont, f.to_cont⟩\n\nlemma is_open_map {f : phomeo α β} {U : set α} (H : is_open U) : is_open (f '' (U ∩ f.domain)) :=\nbegin\n  change is_open ((f.to_pequiv) '' (U ∩ (f.to_pequiv).domain)),\n  rw pequiv.image_eq_preimage,  \n  exact f.inv_cont U H\nend\nend phomeo\n", "meta": {"author": "PatrickMassot", "repo": "lean-differential-topology", "sha": "5b020daa5f935140c53408748a9f11ba02e7bf42", "save_path": "github-repos/lean/PatrickMassot-lean-differential-topology", "path": "github-repos/lean/PatrickMassot-lean-differential-topology/lean-differential-topology-5b020daa5f935140c53408748a9f11ba02e7bf42/src/phomeo.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.49724096485839503}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport algebra.big_operators.multiset\n\n/-!\n# Bind operation for multisets\n\nThis file defines a few basic operations on `multiset`, notably the monadic bind.\n\n## Main declarations\n\n* `multiset.join`: The join, aka union or sum, of multisets.\n* `multiset.bind`: The bind of a multiset-indexed family of multisets.\n* `multiset.product`: Cartesian product of two multisets.\n* `multiset.sigma`: Disjoint sum of multisets in a sigma type.\n-/\n\nvariables {α β γ δ : Type*}\n\nnamespace multiset\n\n/-! ### Join -/\n\n/-- `join S`, where `S` is a multiset of multisets, is the lift of the list join\n  operation, that is, the union of all the sets.\n     join {{1, 2}, {1, 2}, {0, 1}} = {0, 1, 1, 1, 2, 2} -/\ndef join : multiset (multiset α) → multiset α := sum\n\nlemma coe_join : ∀ L : list (list α),\n  join (L.map (@coe _ (multiset α) _) : multiset (multiset α)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (λ s : multiset α, ↑l + s) (coe_join L)\n\n@[simp] \n\n@[simp] lemma mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s :=\nmultiset.induction_on S (by simp) $\n  by simp [or_and_distrib_right, exists_or_distrib] {contextual := tt}\n\n@[simp] lemma card_join (S) : card (@join α S) = sum (map card S) :=\nmultiset.induction_on S (by simp) (by simp)\n\nlemma rel_join {r : α → β → Prop} {s t} (h : rel (rel r) s t) : rel r s.join t.join :=\nbegin\n  induction h,\n  case rel.zero { simp },\n  case rel.cons : a b s t hab hst ih { simpa using hab.add ih }\nend\n\n/-! ### Bind -/\n\nsection bind\nvariables (a : α) (s t : multiset α) (f g : α → multiset β)\n\n/-- `s.bind f` is the monad bind operation, defined as `(s.map f).join`. It is the union of `f a` as\n`a` ranges over `s`. -/\ndef bind (s : multiset α) (f : α → multiset β) : multiset β := (s.map f).join\n\n@[simp] lemma coe_bind (l : list α) (f : α → list β) : @bind α β l (λ a, f a) = l.bind f :=\nby rw [list.bind, ←coe_join, list.map_map]; refl\n\n@[simp] lemma zero_bind : bind 0 f = 0 := rfl\n@[simp] lemma cons_bind : (a ::ₘ s).bind f = f a + s.bind f := by simp [bind]\n@[simp] lemma singleton_bind : bind {a} f = f a := by simp [bind]\n@[simp] lemma add_bind : (s + t).bind f = s.bind f + t.bind f := by simp [bind]\n@[simp] lemma bind_zero : s.bind (λ a, 0 : α → multiset β) = 0 := by simp [bind, join, nsmul_zero]\n@[simp] lemma bind_add : s.bind (λ a, f a + g a) = s.bind f + s.bind g := by simp [bind, join]\n\n@[simp] lemma bind_cons (f : α → β) (g : α → multiset β) :\n  s.bind (λ a, f a ::ₘ g a) = map f s + s.bind g :=\nmultiset.induction_on s (by simp) (by simp [add_comm, add_left_comm] {contextual := tt})\n\n@[simp] lemma bind_singleton (f : α → β) : s.bind (λ x, ({f x} : multiset β)) = map f s :=\nmultiset.induction_on s (by rw [zero_bind, map_zero]) (by simp [singleton_add])\n\n@[simp] lemma mem_bind {b s} {f : α → multiset β} : b ∈ bind s f ↔ ∃ a ∈ s, b ∈ f a :=\nby simp [bind]; simp [-exists_and_distrib_right, exists_and_distrib_right.symm];\n   rw exists_swap; simp [and_assoc]\n\n@[simp] lemma card_bind : (s.bind f).card = (s.map (card ∘ f)).sum := by simp [bind]\n\nlemma bind_congr {f g : α → multiset β} {m : multiset α} :\n  (∀ a ∈ m, f a = g a) → bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {β' : Type*} {m : multiset α} {f : α → multiset β} {f' : α → multiset β'}\n  (h : β = β') (hf : ∀a ∈ m, f a == f' a) :\n  bind m f == bind m f' :=\nbegin subst h, simp at hf, simp [bind_congr hf] end\n\nlemma map_bind (m : multiset α) (n : α → multiset β) (f : β → γ) :\n  map f (bind m n) = bind m (λ a, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset α) (n : β → multiset γ) (f : α → β) :\n  bind (map f m) n = bind m (λ a, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset α} {f : α → multiset β} {g : β → multiset γ} :\n  (s.bind f).bind g = s.bind (λ a, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset α) (n : multiset β) {f : α → β → multiset γ} :\n  (bind m $ λ a, bind n $ λ b, f a b) = (bind n $ λ b, bind m $ λ a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset α) (n : multiset β) {f : α → β → γ} :\n  (bind m $ λ a, n.map $ λ b, f a b) = (bind n $ λ b, m.map $ λ a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid β] (s : multiset α) (t : α → multiset β) :\n  (s.bind t).prod = (s.map $ λ a, (t a).prod).prod :=\nmultiset.induction_on s (by simp) (assume a s ih, by simp [ih, cons_bind])\n\nlemma rel_bind {r : α → β → Prop} {p : γ → δ → Prop} {s t} {f : α → multiset γ} {g : β → multiset δ}\n  (h : (r ⇒ rel p) f g) (hst : rel r s t) :\n  rel p (s.bind f) (t.bind g) :=\nby { apply rel_join, rw rel_map, exact hst.mono (λ a ha b hb hr, h hr) }\n\nlemma count_sum [decidable_eq α] {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (map f m).sum = sum (m.map $ λ b, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind [decidable_eq α] {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (bind m f) = sum (m.map $ λ b, count a $ f b) := count_sum\n\nend bind\n\n/-! ### Product of two multisets -/\n\nsection product\nvariables (a : α) (b : β) (s : multiset α) (t : multiset β)\n\n/-- The multiplicity of `(a, b)` in `s.product t` is\n  the product of the multiplicity of `a` in `s` and `b` in `t`. -/\ndef product (s : multiset α) (t : multiset β) : multiset (α × β) := s.bind $ λ a, t.map $ prod.mk a\n\n@[simp] lemma coe_product (l₁ : list α) (l₂ : list β) : @product α β l₁ l₂ = l₁.product l₂ :=\nby { rw [product, list.product, ←coe_bind], simp }\n\n@[simp] lemma zero_product : @product α β 0 t = 0 := rfl\n--TODO: Add `product_zero`\n\n@[simp] lemma cons_product : (a ::ₘ s).product t = map (prod.mk a) t + s.product t :=\nby simp [product]\n\n@[simp] lemma product_singleton : ({a} : multiset α).product ({b} : multiset β) = {(a, b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] lemma add_product (s t : multiset α) (u : multiset β) :\n  (s + t).product u = s.product u + product t u :=\nby simp [product]\n\n@[simp] lemma product_add (s : multiset α) : ∀ t u : multiset β,\n  s.product (t + u) = s.product t + s.product u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] lemma mem_product {s t} : ∀ {p : α × β}, p ∈ @product α β s t ↔ p.1 ∈ s ∧ p.2 ∈ t\n| (a, b) := by simp [product, and.left_comm]\n\n@[simp] lemma card_product : (s.product t).card = s.card * t.card :=\nby simp [product, repeat, (∘), mul_comm]\n\nend product\n\n/-! ### Disjoint sum of multisets -/\n\nsection sigma\nvariables {σ : α → Type*} (a : α) (s : multiset α) (t : Π a, multiset (σ a))\n\n/-- `sigma s t` is the dependent version of `product`. It is the sum of\n  `(a, b)` as `a` ranges over `s` and `b` ranges over `t a`. -/\nprotected def sigma (s : multiset α) (t : Π a, multiset (σ a)) : multiset (Σ a, σ a) :=\ns.bind $ λ a, (t a).map $ sigma.mk a\n\n@[simp] lemma coe_sigma (l₁ : list α) (l₂ : Π a, list (σ a)) :\n  @multiset.sigma α σ l₁ (λ a, l₂ a) = l₁.sigma l₂ :=\nby rw [multiset.sigma, list.sigma, ←coe_bind]; simp\n\n@[simp] lemma zero_sigma : @multiset.sigma α σ 0 t = 0 := rfl\n\n@[simp] lemma cons_sigma : (a ::ₘ s).sigma t = (t a).map (sigma.mk a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_singleton (b : α → β) :\n  ({a} : multiset α).sigma (λ a, ({b a} : multiset β)) = {⟨a, b a⟩} := rfl\n\n@[simp] lemma add_sigma (s t : multiset α) (u : Π a, multiset (σ a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_add : ∀ t u : Π a, multiset (σ a),\n  s.sigma (λ a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] lemma mem_sigma {s t} : ∀ {p : Σ a, σ a},\n  p ∈ @multiset.sigma α σ s t ↔ p.1 ∈ s ∧ p.2 ∈ t p.1\n| ⟨a, b⟩ := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] lemma card_sigma :\n  card (s.sigma t) = sum (map (λ a, card (t a)) s) :=\nby simp [multiset.sigma, (∘)]\n\nend sigma\nend multiset\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/data/multiset/bind.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7718435030872968, "lm_q1q2_score": 0.49724096296722636}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport analysis.normed_space.multilinear\n\n/-!\n# Formal multilinear series\n\nIn this file we define `formal_multilinear_series 𝕜 E F` to be a family of `n`-multilinear maps for\nall `n`, designed to model the sequence of derivatives of a function. In other files we use this\nnotion to define `C^n` functions (called `cont_diff` in `mathlib`) and analytic functions.\n\n## Notations\n\nWe use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with\nvalues in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.\n\n## Tags\n\nmultilinear, formal series\n-/\n\nnoncomputable theory\n\nopen set fin\nopen_locale topological_space\n\nvariables {𝕜 𝕜' E F G : Type*}\n\nsection\nvariables [comm_ring 𝕜]\n  [add_comm_group E] [module 𝕜 E] [topological_space E] [topological_add_group E]\n  [has_continuous_const_smul 𝕜 E]\n  [add_comm_group F] [module 𝕜 F] [topological_space F] [topological_add_group F]\n  [has_continuous_const_smul 𝕜 F]\n  [add_comm_group G] [module 𝕜 G] [topological_space G] [topological_add_group G]\n  [has_continuous_const_smul 𝕜 G]\n\n\n/-- A formal multilinear series over a field `𝕜`, from `E` to `F`, is given by a family of\nmultilinear maps from `E^n` to `F` for all `n`. -/\n@[derive add_comm_group, nolint unused_arguments]\ndef formal_multilinear_series (𝕜 : Type*) (E : Type*) (F : Type*)\n  [ring 𝕜]\n  [add_comm_group E] [module 𝕜 E] [topological_space E] [topological_add_group E]\n    [has_continuous_const_smul 𝕜 E]\n  [add_comm_group F] [module 𝕜 F] [topological_space F] [topological_add_group F]\n    [has_continuous_const_smul 𝕜 F] :=\nΠ (n : ℕ), (E [×n]→L[𝕜] F)\n\ninstance : inhabited (formal_multilinear_series 𝕜 E F) := ⟨0⟩\n\nsection module\n/- `derive` is not able to find the module structure, probably because Lean is confused by the\ndependent types. We register it explicitly. -/\n\ninstance : module 𝕜 (formal_multilinear_series 𝕜 E F) :=\nbegin\n  letI : Π n, module 𝕜 (continuous_multilinear_map 𝕜 (λ (i : fin n), E) F) :=\n    λ n, by apply_instance,\n  refine pi.module _ _ _,\nend\n\nend module\n\nnamespace formal_multilinear_series\n\n/-- Killing the zeroth coefficient in a formal multilinear series -/\ndef remove_zero (p : formal_multilinear_series 𝕜 E F) : formal_multilinear_series 𝕜 E F\n| 0       := 0\n| (n + 1) := p (n + 1)\n\n@[simp] lemma remove_zero_coeff_zero (p : formal_multilinear_series 𝕜 E F) :\n  p.remove_zero 0 = 0 := rfl\n\n@[simp] lemma remove_zero_coeff_succ (p : formal_multilinear_series 𝕜 E F) (n : ℕ) :\n  p.remove_zero (n+1) = p (n+1) := rfl\n\nlemma remove_zero_of_pos (p : formal_multilinear_series 𝕜 E F) {n : ℕ} (h : 0 < n) :\n  p.remove_zero n = p n :=\nby { rw ← nat.succ_pred_eq_of_pos h, refl }\n\n/-- Convenience congruence lemma stating in a dependent setting that, if the arguments to a formal\nmultilinear series are equal, then the values are also equal. -/\nlemma congr (p : formal_multilinear_series 𝕜 E F) {m n : ℕ} {v : fin m → E} {w : fin n → E}\n  (h1 : m = n) (h2 : ∀ (i : ℕ) (him : i < m) (hin : i < n), v ⟨i, him⟩ = w ⟨i, hin⟩) :\n  p m v = p n w :=\nby { cases h1, congr' with ⟨i, hi⟩, exact h2 i hi hi }\n\n/-- Composing each term `pₙ` in a formal multilinear series with `(u, ..., u)` where `u` is a fixed\ncontinuous linear map, gives a new formal multilinear series `p.comp_continuous_linear_map u`. -/\ndef comp_continuous_linear_map (p : formal_multilinear_series 𝕜 F G) (u : E →L[𝕜] F) :\n  formal_multilinear_series 𝕜 E G :=\nλ n, (p n).comp_continuous_linear_map (λ (i : fin n), u)\n\n@[simp] lemma comp_continuous_linear_map_apply\n  (p : formal_multilinear_series 𝕜 F G) (u : E →L[𝕜] F) (n : ℕ) (v : fin n → E) :\n  (p.comp_continuous_linear_map u) n v = p n (u ∘ v) := rfl\n\nvariables (𝕜) [comm_ring 𝕜'] [has_scalar 𝕜 𝕜']\nvariables [module 𝕜' E] [has_continuous_const_smul 𝕜' E] [is_scalar_tower 𝕜 𝕜' E]\nvariables [module 𝕜' F] [has_continuous_const_smul 𝕜' F] [is_scalar_tower 𝕜 𝕜' F]\n\n/-- Reinterpret a formal `𝕜'`-multilinear series as a formal `𝕜`-multilinear series. -/\n@[simp] protected def restrict_scalars (p : formal_multilinear_series 𝕜' E F) :\n  formal_multilinear_series 𝕜 E F :=\nλ n, (p n).restrict_scalars 𝕜\n\nend formal_multilinear_series\n\nend\n\nnamespace formal_multilinear_series\n\nvariables [nondiscrete_normed_field 𝕜]\n  [normed_group E] [normed_space 𝕜 E]\n  [normed_group F] [normed_space 𝕜 F]\n  [normed_group G] [normed_space 𝕜 G]\n\nvariables (p : formal_multilinear_series 𝕜 E F)\n\n/-- Forgetting the zeroth term in a formal multilinear series, and interpreting the following terms\nas multilinear maps into `E →L[𝕜] F`. If `p` corresponds to the Taylor series of a function, then\n`p.shift` is the Taylor series of the derivative of the function. -/\ndef shift : formal_multilinear_series 𝕜 E (E →L[𝕜] F) :=\nλn, (p n.succ).curry_right\n\n/-- Adding a zeroth term to a formal multilinear series taking values in `E →L[𝕜] F`. This\ncorresponds to starting from a Taylor series for the derivative of a function, and building a Taylor\nseries for the function itself. -/\ndef unshift (q : formal_multilinear_series 𝕜 E (E →L[𝕜] F)) (z : F) :\n  formal_multilinear_series 𝕜 E F\n| 0       := (continuous_multilinear_curry_fin0 𝕜 E F).symm z\n| (n + 1) := continuous_multilinear_curry_right_equiv' 𝕜 n E F (q n)\n\nend formal_multilinear_series\n\nnamespace continuous_linear_map\nvariables [comm_ring 𝕜]\n  [add_comm_group E] [module 𝕜 E] [topological_space E] [topological_add_group E]\n  [has_continuous_const_smul 𝕜 E]\n  [add_comm_group F] [module 𝕜 F] [topological_space F] [topological_add_group F]\n  [has_continuous_const_smul 𝕜 F]\n  [add_comm_group G] [module 𝕜 G] [topological_space G] [topological_add_group G]\n  [has_continuous_const_smul 𝕜 G]\n\n/-- Composing each term `pₙ` in a formal multilinear series with a continuous linear map `f` on the\nleft gives a new formal multilinear series `f.comp_formal_multilinear_series p` whose general term\nis `f ∘ pₙ`. -/\ndef comp_formal_multilinear_series (f : F →L[𝕜] G) (p : formal_multilinear_series 𝕜 E F) :\n  formal_multilinear_series 𝕜 E G :=\nλ n, f.comp_continuous_multilinear_map (p n)\n\n@[simp] lemma comp_formal_multilinear_series_apply\n  (f : F →L[𝕜] G) (p : formal_multilinear_series 𝕜 E F) (n : ℕ) :\n  (f.comp_formal_multilinear_series p) n = f.comp_continuous_multilinear_map (p n) :=\nrfl\n\nlemma comp_formal_multilinear_series_apply'\n  (f : F →L[𝕜] G) (p : formal_multilinear_series 𝕜 E F) (n : ℕ) (v : fin n → E) :\n  (f.comp_formal_multilinear_series p) n v = f (p n v) :=\nrfl\n\nend continuous_linear_map\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/analysis/calculus/formal_multilinear_series.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4972409595861899}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Chris Hughes\n-/\nimport algebra.algebra.basic\nimport data.polynomial.field_division\nimport field_theory.minpoly.basic\nimport ring_theory.adjoin.basic\nimport ring_theory.finite_presentation\nimport ring_theory.finite_type\nimport ring_theory.power_basis\nimport ring_theory.principal_ideal_domain\nimport ring_theory.quotient_noetherian\n\n/-!\n# Adjoining roots of polynomials\n\nThis file defines the commutative ring `adjoin_root f`, the ring R[X]/(f) obtained from a\ncommutative ring `R` and a polynomial `f : R[X]`. If furthermore `R` is a field and `f` is\nirreducible, the field structure on `adjoin_root f` is constructed.\n\nWe suggest stating results on `is_adjoin_root` instead of `adjoin_root` to achieve higher\ngenerality, since `is_adjoin_root` works for all different constructions of `R[α]`\nincluding `adjoin_root f = R[X]/(f)` itself.\n\n## Main definitions and results\n\nThe main definitions are in the `adjoin_root` namespace.\n\n*  `mk f : R[X] →+* adjoin_root f`, the natural ring homomorphism.\n\n*  `of f : R →+* adjoin_root f`, the natural ring homomorphism.\n\n* `root f : adjoin_root f`, the image of X in R[X]/(f).\n\n* `lift (i : R →+* S) (x : S) (h : f.eval₂ i x = 0) : (adjoin_root f) →+* S`, the ring\n  homomorphism from R[X]/(f) to S extending `i : R →+* S` and sending `X` to `x`.\n\n* `lift_hom (x : S) (hfx : aeval x f = 0) : adjoin_root f →ₐ[R] S`, the algebra\n  homomorphism from R[X]/(f) to S extending `algebra_map R S` and sending `X` to `x`\n\n* `equiv : (adjoin_root f →ₐ[F] E) ≃ {x // x ∈ (f.map (algebra_map F E)).roots}` a\n  bijection between algebra homomorphisms from `adjoin_root` and roots of `f` in `S`\n\n-/\nnoncomputable theory\nopen_locale classical\nopen_locale big_operators polynomial\n\nuniverses u v w\n\nvariables {R : Type u} {S : Type v} {K : Type w}\n\nopen polynomial ideal\n\n/-- Adjoin a root of a polynomial `f` to a commutative ring `R`. We define the new ring\nas the quotient of `R[X]` by the principal ideal generated by `f`. -/\ndef adjoin_root [comm_ring R] (f : R[X]) : Type u :=\npolynomial R ⧸ (span {f} : ideal R[X])\n\nnamespace adjoin_root\n\nsection comm_ring\nvariables [comm_ring R] (f : R[X])\n\ninstance : comm_ring (adjoin_root f) := ideal.quotient.comm_ring _\n\ninstance : inhabited (adjoin_root f) := ⟨0⟩\n\ninstance : decidable_eq (adjoin_root f) := classical.dec_eq _\n\nprotected lemma nontrivial [is_domain R] (h : degree f ≠ 0) : nontrivial (adjoin_root f) :=\nideal.quotient.nontrivial\nbegin\n  simp_rw [ne.def, span_singleton_eq_top, polynomial.is_unit_iff, not_exists, not_and],\n  rintro x hx rfl,\n  exact h (degree_C hx.ne_zero),\nend\n\n/-- Ring homomorphism from `R[x]` to `adjoin_root f` sending `X` to the `root`. -/\ndef mk : R[X] →+* adjoin_root f := ideal.quotient.mk _\n\n@[elab_as_eliminator]\ntheorem induction_on {C : adjoin_root f → Prop} (x : adjoin_root f)\n  (ih : ∀ p : R[X], C (mk f p)) : C x :=\nquotient.induction_on' x ih\n\n/-- Embedding of the original ring `R` into `adjoin_root f`. -/\ndef of : R →+* adjoin_root f := (mk f).comp C\n\ninstance [comm_semiring S] [algebra S R] : algebra S (adjoin_root f) :=\nideal.quotient.algebra S\n\ninstance [comm_semiring S] [comm_semiring K] [has_smul S K] [algebra S R] [algebra K R]\n  [is_scalar_tower S K R] :\n  is_scalar_tower S K (adjoin_root f) :=\nsubmodule.quotient.is_scalar_tower _ _\n\ninstance [comm_semiring S] [comm_semiring K] [algebra S R] [algebra K R] [smul_comm_class S K R] :\n  smul_comm_class S K (adjoin_root f) :=\nsubmodule.quotient.smul_comm_class _ _\n\n@[simp] \n\nvariables (S)\n\nlemma algebra_map_eq' [comm_semiring S] [algebra S R] :\n  algebra_map S (adjoin_root f) = (of f).comp (algebra_map S R) := rfl\n\nvariables {S}\n\nlemma finite_type : algebra.finite_type R (adjoin_root f) :=\n(algebra.finite_type.polynomial R).of_surjective _ (ideal.quotient.mkₐ_surjective R _)\n\nlemma finite_presentation : algebra.finite_presentation R (adjoin_root f) :=\n(algebra.finite_presentation.polynomial R).quotient (submodule.fg_span_singleton f)\n\n/-- The adjoined root. -/\ndef root : adjoin_root f := mk f X\n\nvariables {f}\n\ninstance has_coe_t : has_coe_t R (adjoin_root f) := ⟨of f⟩\n\n/-- Two `R`-`alg_hom` from `adjoin_root f` to the same `R`-algebra are the same iff\n    they agree on `root f`. -/\n@[ext] lemma alg_hom_ext [semiring S] [algebra R S] {g₁ g₂ : adjoin_root f →ₐ[R] S}\n  (h : g₁ (root f) = g₂ (root f)) : g₁ = g₂ :=\nideal.quotient.alg_hom_ext R $ polynomial.alg_hom_ext h\n\n@[simp] lemma mk_eq_mk {g h : R[X]} : mk f g = mk f h ↔ f ∣ g - h :=\nideal.quotient.eq.trans ideal.mem_span_singleton\n\n@[simp] lemma mk_eq_zero {g : R[X]} : mk f g = 0 ↔ f ∣ g :=\nmk_eq_mk.trans $ by rw sub_zero\n\n@[simp] lemma mk_self : mk f f = 0 :=\nquotient.sound' $ quotient_add_group.left_rel_apply.mpr (mem_span_singleton.2 $ by simp)\n\n@[simp] lemma mk_C (x : R) : mk f (C x) = x := rfl\n\n@[simp] lemma mk_X : mk f X = root f := rfl\n\nlemma mk_ne_zero_of_degree_lt (hf : monic f)\n  {g : R[X]} (h0 : g ≠ 0) (hd : degree g < degree f) : mk f g ≠ 0 :=\nmk_eq_zero.not.2 $ hf.not_dvd_of_degree_lt h0 hd\n\nlemma mk_ne_zero_of_nat_degree_lt (hf : monic f)\n  {g : R[X]} (h0 : g ≠ 0) (hd : nat_degree g < nat_degree f) : mk f g ≠ 0 :=\nmk_eq_zero.not.2 $ hf.not_dvd_of_nat_degree_lt h0 hd\n\n@[simp] lemma aeval_eq (p : R[X]) : aeval (root f) p = mk f p :=\npolynomial.induction_on p (λ x, by { rw aeval_C, refl })\n  (λ p q ihp ihq, by rw [alg_hom.map_add, ring_hom.map_add, ihp, ihq])\n  (λ n x ih, by { rw [alg_hom.map_mul, aeval_C, alg_hom.map_pow, aeval_X,\n    ring_hom.map_mul, mk_C, ring_hom.map_pow, mk_X], refl })\n\ntheorem adjoin_root_eq_top : algebra.adjoin R ({root f} : set (adjoin_root f)) = ⊤ :=\nalgebra.eq_top_iff.2 $ λ x, induction_on f x $ λ p,\n(algebra.adjoin_singleton_eq_range_aeval R (root f)).symm ▸ ⟨p, aeval_eq p⟩\n\n@[simp] lemma eval₂_root (f : R[X]) : f.eval₂ (of f) (root f) = 0 :=\nby rw [← algebra_map_eq, ← aeval_def, aeval_eq, mk_self]\n\nlemma is_root_root (f : R[X]) : is_root (f.map (of f)) (root f) :=\nby rw [is_root, eval_map, eval₂_root]\n\nlemma is_algebraic_root (hf : f ≠ 0) : is_algebraic R (root f) :=\n⟨f, hf, eval₂_root f⟩\n\nlemma of.injective_of_degree_ne_zero [is_domain R] (hf : f.degree ≠ 0) :\n  function.injective (adjoin_root.of f) :=\nbegin\n  rw injective_iff_map_eq_zero,\n  intros p hp,\n  rw [adjoin_root.of, ring_hom.comp_apply, adjoin_root.mk_eq_zero] at hp,\n  by_cases h : f = 0,\n  { exact C_eq_zero.mp (eq_zero_of_zero_dvd (by rwa h at hp)) },\n  { contrapose! hf with h_contra,\n    rw ← degree_C h_contra,\n    apply le_antisymm (degree_le_of_dvd hp (by rwa [ne.def, C_eq_zero])) _,\n    rwa [degree_C h_contra, zero_le_degree_iff] },\nend\n\nvariables [comm_ring S]\n\n/-- Lift a ring homomorphism `i : R →+* S` to `adjoin_root f →+* S`. -/\ndef lift (i : R →+* S) (x : S) (h : f.eval₂ i x = 0) : (adjoin_root f) →+* S :=\nbegin\n  apply ideal.quotient.lift _ (eval₂_ring_hom i x),\n  intros g H,\n  rcases mem_span_singleton.1 H with ⟨y, hy⟩,\n  rw [hy, ring_hom.map_mul, coe_eval₂_ring_hom, h, zero_mul]\nend\n\nvariables {i : R →+* S} {a : S} (h : f.eval₂ i a = 0)\n\n@[simp] lemma lift_mk (g : R[X]) : lift i a h (mk f g) = g.eval₂ i a :=\nideal.quotient.lift_mk _ _ _\n\n@[simp] lemma lift_root : lift i a h (root f) = a := by rw [root, lift_mk, eval₂_X]\n\n@[simp] lemma lift_of {x : R} : lift i a h x = i x :=\nby rw [← mk_C x, lift_mk, eval₂_C]\n\n@[simp] lemma lift_comp_of : (lift i a h).comp (of f) = i :=\nring_hom.ext $ λ _, @lift_of _ _ _ _ _ _ _ h _\n\nvariables (f) [algebra R S]\n\n/-- Produce an algebra homomorphism `adjoin_root f →ₐ[R] S` sending `root f` to\na root of `f` in `S`. -/\ndef lift_hom (x : S) (hfx : aeval x f = 0) : adjoin_root f →ₐ[R] S :=\n{ commutes' := λ r, show lift _ _ hfx r = _, from lift_of hfx,\n  .. lift (algebra_map R S) x hfx }\n\n@[simp] lemma coe_lift_hom (x : S) (hfx : aeval x f = 0) :\n  (lift_hom f x hfx : adjoin_root f →+* S) = lift (algebra_map R S) x hfx := rfl\n\n@[simp] lemma aeval_alg_hom_eq_zero (ϕ : adjoin_root f →ₐ[R] S) : aeval (ϕ (root f)) f = 0 :=\nbegin\n  have h : ϕ.to_ring_hom.comp (of f) = algebra_map R S := ring_hom.ext_iff.mpr (ϕ.commutes),\n  rw [aeval_def, ←h, ←ring_hom.map_zero ϕ.to_ring_hom, ←eval₂_root f, hom_eval₂],\n  refl,\nend\n\n@[simp] lemma lift_hom_eq_alg_hom (f : R[X]) (ϕ : adjoin_root f →ₐ[R] S) :\n  lift_hom f (ϕ (root f)) (aeval_alg_hom_eq_zero f ϕ) = ϕ :=\nbegin\n  suffices : ϕ.equalizer (lift_hom f (ϕ (root f)) (aeval_alg_hom_eq_zero f ϕ)) = ⊤,\n  { exact (alg_hom.ext (λ x, (set_like.ext_iff.mp (this) x).mpr algebra.mem_top)).symm },\n  rw [eq_top_iff, ←adjoin_root_eq_top, algebra.adjoin_le_iff, set.singleton_subset_iff],\n  exact (@lift_root _ _ _ _ _ _ _ (aeval_alg_hom_eq_zero f ϕ)).symm,\nend\n\nvariables (hfx : aeval a f = 0)\n\n@[simp] lemma lift_hom_mk {g : R[X]} : lift_hom f a hfx (mk f g) = aeval a g :=\nlift_mk hfx g\n\n@[simp] lemma lift_hom_root : lift_hom f a hfx (root f) = a :=\nlift_root hfx\n\n@[simp] lemma lift_hom_of {x : R} : lift_hom f a hfx (of f x) = algebra_map _ _ x :=\nlift_of hfx\n\nsection adjoin_inv\n\n@[simp] lemma root_is_inv (r : R) : of _ r * root (C r * X - 1) = 1 :=\nby convert sub_eq_zero.1 ((eval₂_sub _).symm.trans $ eval₂_root $ C r * X - 1);\n  simp only [eval₂_mul, eval₂_C, eval₂_X, eval₂_one]\n\nlemma alg_hom_subsingleton {S : Type*} [comm_ring S] [algebra R S] {r : R} :\n  subsingleton (adjoin_root (C r * X - 1) →ₐ[R] S) :=\n⟨λ f g, alg_hom_ext (@inv_unique _ _ (algebra_map R S r) _ _\n  (by rw [← f.commutes, ← f.map_mul, algebra_map_eq, root_is_inv, map_one])\n  (by rw [← g.commutes, ← g.map_mul, algebra_map_eq, root_is_inv, map_one]))⟩\n\nend adjoin_inv\n\nsection prime\n\nvariable {f}\n\ntheorem is_domain_of_prime (hf : prime f) : is_domain (adjoin_root f) :=\n(ideal.quotient.is_domain_iff_prime (span {f} : ideal R[X])).mpr $\n  (ideal.span_singleton_prime hf.ne_zero).mpr hf\n\ntheorem no_zero_smul_divisors_of_prime_of_degree_ne_zero [is_domain R] (hf : prime f)\n  (hf' : f.degree ≠ 0) : no_zero_smul_divisors R (adjoin_root f) :=\nbegin\n  haveI := is_domain_of_prime hf,\n  exact no_zero_smul_divisors.iff_algebra_map_injective.mpr (of.injective_of_degree_ne_zero hf')\nend\n\nend prime\n\nend comm_ring\n\nsection irreducible\n\nvariables [field K] {f : K[X]}\n\ninstance span_maximal_of_irreducible [fact (irreducible f)] : (span {f}).is_maximal :=\nprincipal_ideal_ring.is_maximal_of_irreducible $ fact.out _\n\nnoncomputable instance field [fact (irreducible f)] : field (adjoin_root f) :=\n{ ..adjoin_root.comm_ring f,\n  ..ideal.quotient.field (span {f} : ideal K[X]) }\n\nlemma coe_injective (h : degree f ≠ 0) : function.injective (coe : K → adjoin_root f) :=\nhave _ := adjoin_root.nontrivial f h, by exactI (of f).injective\n\nlemma coe_injective' [fact (irreducible f)] : function.injective (coe : K → adjoin_root f) :=\n(of f).injective\n\nvariable (f)\n\nlemma mul_div_root_cancel [fact (irreducible f)] :\n  ((X - C (root f)) * (f.map (of f) / (X - C (root f)))) = f.map (of f) :=\nmul_div_eq_iff_is_root.2 $ is_root_root _\n\nend irreducible\n\nsection is_noetherian_ring\n\ninstance [comm_ring R] [is_noetherian_ring R] {f : R[X]} : is_noetherian_ring (adjoin_root f) :=\nideal.quotient.is_noetherian_ring _\n\nend is_noetherian_ring\n\nsection power_basis\n\nvariables [comm_ring R] {g : R[X]}\n\nlemma is_integral_root' (hg : g.monic) : is_integral R (root g) :=\n⟨g, hg, eval₂_root g⟩\n\n/-- `adjoin_root.mod_by_monic_hom` sends the equivalence class of `f` mod `g` to `f %ₘ g`.\n\nThis is a well-defined right inverse to `adjoin_root.mk`, see `adjoin_root.mk_left_inverse`. -/\ndef mod_by_monic_hom (hg : g.monic) :\n  adjoin_root g →ₗ[R] R[X] :=\n(submodule.liftq _ (polynomial.mod_by_monic_hom g)\n  (λ f (hf : f ∈ (ideal.span {g}).restrict_scalars R),\n    (mem_ker_mod_by_monic hg).mpr (ideal.mem_span_singleton.mp hf))).comp $\n(submodule.quotient.restrict_scalars_equiv R (ideal.span {g} : ideal R[X]))\n  .symm.to_linear_map\n\n@[simp] lemma mod_by_monic_hom_mk (hg : g.monic) (f : R[X]) :\n  mod_by_monic_hom hg (mk g f) = f %ₘ g := rfl\n\nlemma mk_left_inverse (hg : g.monic) :\n  function.left_inverse (mk g) (mod_by_monic_hom hg) :=\nλ f, induction_on g f $ λ f, begin\n  rw [mod_by_monic_hom_mk hg, mk_eq_mk, mod_by_monic_eq_sub_mul_div _ hg,\n      sub_sub_cancel_left, dvd_neg],\n  apply dvd_mul_right\nend\n\nlemma mk_surjective (hg : g.monic) : function.surjective (mk g) :=\n(mk_left_inverse hg).surjective\n\n/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `adjoin_root g`,\nwhere `g` is a monic polynomial of degree `d`. -/\ndef power_basis_aux' (hg : g.monic) :\n  basis (fin g.nat_degree) R (adjoin_root g) :=\nbasis.of_equiv_fun\n{ to_fun := λ f i, (mod_by_monic_hom hg f).coeff i,\n  inv_fun := λ c, mk g $ ∑ (i : fin g.nat_degree), monomial i (c i),\n  map_add' := λ f₁ f₂, funext $ λ i,\n    by simp only [(mod_by_monic_hom hg).map_add, coeff_add, pi.add_apply],\n  map_smul' := λ f₁ f₂, funext $ λ i,\n    by simp only [(mod_by_monic_hom hg).map_smul, coeff_smul, pi.smul_apply, ring_hom.id_apply],\n  left_inv := λ f, induction_on g f (λ f, eq.symm $ mk_eq_mk.mpr $\n    by { simp only [mod_by_monic_hom_mk, sum_mod_by_monic_coeff hg degree_le_nat_degree],\n         rw [mod_by_monic_eq_sub_mul_div _ hg, sub_sub_cancel],\n         exact dvd_mul_right _ _ }),\n  right_inv := λ x, funext $ λ i, begin\n    nontriviality R,\n    simp only [mod_by_monic_hom_mk],\n    rw [(mod_by_monic_eq_self_iff hg).mpr, finset_sum_coeff],\n    { simp_rw [coeff_monomial, fin.coe_eq_coe, finset.sum_ite_eq', if_pos (finset.mem_univ _)] },\n    { simp_rw ← C_mul_X_pow_eq_monomial,\n      exact (degree_eq_nat_degree $ hg.ne_zero).symm ▸ degree_sum_fin_lt _ },\n  end}\n\n/-- This lemma could be autogenerated by `@[simps]` but unfortunately that would require\nunfolding that causes a timeout. -/\n@[simp] lemma power_basis_aux'_repr_symm_apply (hg : g.monic) (c : fin g.nat_degree →₀ R) :\n  (power_basis_aux' hg).repr.symm c = mk g (∑ (i : fin _), monomial i (c i)) := rfl\n\n/-- This lemma could be autogenerated by `@[simps]` but unfortunately that would require\nunfolding that causes a timeout. -/\n@[simp] theorem power_basis_aux'_repr_apply_to_fun (hg : g.monic) (f : adjoin_root g)\n  (i : fin g.nat_degree) :\n  (power_basis_aux' hg).repr f i = (mod_by_monic_hom hg f).coeff ↑i :=\nrfl\n\n/-- The power basis `1, root g, ..., root g ^ (d - 1)` for `adjoin_root g`,\nwhere `g` is a monic polynomial of degree `d`. -/\n@[simps] def power_basis' (hg : g.monic) : power_basis R (adjoin_root g) :=\n{ gen := root g,\n  dim := g.nat_degree,\n  basis := power_basis_aux' hg,\n  basis_eq_pow := λ i, begin\n    simp only [power_basis_aux', basis.coe_of_equiv_fun, linear_equiv.coe_symm_mk],\n    rw finset.sum_eq_single i,\n    { rw [function.update_same, monomial_one_right_eq_X_pow, (mk g).map_pow, mk_X] },\n    { intros j _ hj,\n      rw ← monomial_zero_right _,\n      convert congr_arg _ (function.update_noteq hj _ _) }, -- Fix `decidable_eq` mismatch\n    { intros, have := finset.mem_univ i, contradiction },\n  end}\n\nvariables [field K] {f : K[X]}\n\nlemma is_integral_root (hf : f ≠ 0) : is_integral K (root f) :=\nis_algebraic_iff_is_integral.mp (is_algebraic_root hf)\n\nlemma minpoly_root (hf : f ≠ 0) : minpoly K (root f) = f * C (f.leading_coeff⁻¹) :=\nbegin\n  have f'_monic : monic _ := monic_mul_leading_coeff_inv hf,\n  refine (minpoly.unique K _ f'_monic _ _).symm,\n  { rw [alg_hom.map_mul, aeval_eq, mk_self, zero_mul] },\n  intros q q_monic q_aeval,\n  have commutes : (lift (algebra_map K (adjoin_root f)) (root f) q_aeval).comp (mk q) = mk f,\n  { ext,\n    { simp only [ring_hom.comp_apply, mk_C, lift_of], refl },\n    { simp only [ring_hom.comp_apply, mk_X, lift_root] } },\n  rw [degree_eq_nat_degree f'_monic.ne_zero, degree_eq_nat_degree q_monic.ne_zero,\n      with_bot.coe_le_coe, nat_degree_mul hf, nat_degree_C, add_zero],\n  apply nat_degree_le_of_dvd,\n  { have : mk f q = 0, by rw [←commutes, ring_hom.comp_apply, mk_self, ring_hom.map_zero],\n    rwa [←ideal.mem_span_singleton, ←ideal.quotient.eq_zero_iff_mem] },\n  { exact q_monic.ne_zero },\n  { rwa [ne.def, C_eq_zero, inv_eq_zero, leading_coeff_eq_zero] },\nend\n\n/-- The elements `1, root f, ..., root f ^ (d - 1)` form a basis for `adjoin_root f`,\nwhere `f` is an irreducible polynomial over a field of degree `d`. -/\ndef power_basis_aux (hf : f ≠ 0) : basis (fin f.nat_degree) K (adjoin_root f) :=\nbegin\n  set f' := f * C (f.leading_coeff⁻¹) with f'_def,\n  have deg_f' : f'.nat_degree = f.nat_degree,\n  { rw [nat_degree_mul hf, nat_degree_C, add_zero],\n    { rwa [ne.def, C_eq_zero, inv_eq_zero, leading_coeff_eq_zero] } },\n  have minpoly_eq : minpoly K (root f) = f' := minpoly_root hf,\n  apply @basis.mk _ _ _ (λ (i : fin f.nat_degree), (root f ^ i.val)),\n  { rw [← deg_f', ← minpoly_eq],\n    exact linear_independent_pow (root f) },\n  { rintros y -,\n    rw [← deg_f', ← minpoly_eq],\n    apply (is_integral_root hf).mem_span_pow,\n    obtain ⟨g⟩ := y,\n    use g,\n    rw aeval_eq,\n    refl }\nend\n\n/-- The power basis `1, root f, ..., root f ^ (d - 1)` for `adjoin_root f`,\nwhere `f` is an irreducible polynomial over a field of degree `d`. -/\n@[simps] def power_basis (hf : f ≠ 0) :\n  power_basis K (adjoin_root f) :=\n{ gen := root f,\n  dim := f.nat_degree,\n  basis := power_basis_aux hf,\n  basis_eq_pow := basis.mk_apply _ _ }\n\nlemma minpoly_power_basis_gen (hf : f ≠ 0) :\n  minpoly K (power_basis hf).gen = f * C (f.leading_coeff⁻¹) :=\nby rw [power_basis_gen, minpoly_root hf]\n\nlemma minpoly_power_basis_gen_of_monic (hf : f.monic) (hf' : f ≠ 0 := hf.ne_zero) :\n  minpoly K (power_basis hf').gen = f :=\nby rw [minpoly_power_basis_gen hf', hf.leading_coeff, inv_one, C.map_one, mul_one]\n\nend power_basis\n\nsection equiv\n\nsection minpoly\n\nvariables [comm_ring R] [comm_ring S] [algebra R S] (x : S) (R)\n\nopen algebra polynomial\n\n/-- The surjective algebra morphism `R[X]/(minpoly R x) → R[x]`.\nIf `R` is a GCD domain and `x` is integral, this is an isomorphism,\nsee `adjoin_root.minpoly.equiv_adjoin`. -/\n@[simps] def minpoly.to_adjoin : adjoin_root (minpoly R x) →ₐ[R] adjoin R ({x} : set S) :=\nlift_hom _ ⟨x, self_mem_adjoin_singleton R x⟩\n  (by simp [← subalgebra.coe_eq_zero, aeval_subalgebra_coe])\n\nvariables {R x}\n\nlemma minpoly.to_adjoin_apply' (a : adjoin_root (minpoly R x)) : minpoly.to_adjoin R x a =\n  lift_hom (minpoly R x) (⟨x, self_mem_adjoin_singleton R x⟩ : adjoin R ({x} : set S))\n  (by simp [← subalgebra.coe_eq_zero, aeval_subalgebra_coe]) a := rfl\n\nlemma minpoly.to_adjoin.apply_X : minpoly.to_adjoin R x (mk (minpoly R x) X) =\n  ⟨x, self_mem_adjoin_singleton R x⟩ :=\nby simp\n\nvariables (R x)\n\nlemma minpoly.to_adjoin.surjective : function.surjective (minpoly.to_adjoin R x) :=\nbegin\n  rw [← range_top_iff_surjective, _root_.eq_top_iff, ← adjoin_adjoin_coe_preimage],\n  refine adjoin_le _,\n  simp only [alg_hom.coe_range, set.mem_range],\n  rintro ⟨y₁, y₂⟩ h,\n  refine ⟨mk (minpoly R x) X, by simpa using h.symm⟩\nend\n\nend minpoly\n\nsection equiv'\n\nvariables [comm_ring R] [comm_ring S] [algebra R S]\nvariables (g : R[X]) (pb : _root_.power_basis R S)\n\n/-- If `S` is an extension of `R` with power basis `pb` and `g` is a monic polynomial over `R`\nsuch that `pb.gen` has a minimal polynomial `g`, then `S` is isomorphic to `adjoin_root g`.\n\nCompare `power_basis.equiv_of_root`, which would require\n`h₂ : aeval pb.gen (minpoly R (root g)) = 0`; that minimal polynomial is not\nguaranteed to be identical to `g`. -/\n@[simps {fully_applied := ff}]\ndef equiv' (h₁ : aeval (root g) (minpoly R pb.gen) = 0) (h₂ : aeval pb.gen g = 0) :\n  adjoin_root g ≃ₐ[R] S :=\n{ to_fun := adjoin_root.lift_hom g pb.gen h₂,\n  inv_fun := pb.lift (root g) h₁,\n  left_inv := λ x, induction_on g x $ λ f, by rw [lift_hom_mk, pb.lift_aeval, aeval_eq],\n  right_inv := λ x, begin\n    nontriviality S,\n    obtain ⟨f, hf, rfl⟩ := pb.exists_eq_aeval x,\n    rw [pb.lift_aeval, aeval_eq, lift_hom_mk]\n  end,\n  .. adjoin_root.lift_hom g pb.gen h₂ }\n\n@[simp] lemma equiv'_to_alg_hom\n  (h₁ : aeval (root g) (minpoly R pb.gen) = 0) (h₂ : aeval pb.gen g = 0) :\n  (equiv' g pb h₁ h₂).to_alg_hom = adjoin_root.lift_hom g pb.gen h₂ :=\nrfl\n\n@[simp] lemma equiv'_symm_to_alg_hom\n  (h₁ : aeval (root g) (minpoly R pb.gen) = 0) (h₂ : aeval pb.gen g = 0) :\n  (equiv' g pb h₁ h₂).symm.to_alg_hom = pb.lift (root g) h₁ :=\nrfl\n\nend equiv'\n\nsection field\n\nvariables (K) (L F : Type*) [field F] [field K] [field L] [algebra F K] [algebra F L]\nvariables (pb : _root_.power_basis F K)\n\n/-- If `L` is a field extension of `F` and `f` is a polynomial over `F` then the set\nof maps from `F[x]/(f)` into `L` is in bijection with the set of roots of `f` in `L`. -/\ndef equiv (f : F[X]) (hf : f ≠ 0) :\n  (adjoin_root f →ₐ[F] L) ≃ {x // x ∈ (f.map (algebra_map F L)).roots} :=\n(power_basis hf).lift_equiv'.trans ((equiv.refl _).subtype_equiv (λ x,\n  begin\n    rw [power_basis_gen, minpoly_root hf, polynomial.map_mul, roots_mul,\n        polynomial.map_C, roots_C, add_zero, equiv.refl_apply],\n    rw ← polynomial.map_mul, exact map_monic_ne_zero (monic_mul_leading_coeff_inv hf)\n  end))\n\nend field\n\nend equiv\n\nsection\n\nopen ideal double_quot polynomial\n\nvariables [comm_ring R] (I : ideal R) (f : R[X])\n\n/-- The natural isomorphism `R[α]/(I[α]) ≅ R[α]/((I[x] ⊔ (f)) / (f))` for `α` a root of\n`f : R[X]` and `I : ideal R`.\n\nSee `adjoin_root.quot_map_of_equiv` for the isomorphism with `(R/I)[X] / (f mod I)`. -/\ndef quot_map_of_equiv_quot_map_C_map_span_mk :\n  adjoin_root f ⧸ I.map (of f) ≃+*\n    adjoin_root f ⧸ (I.map (C : R →+* R[X])).map (span {f})^.quotient.mk :=\nideal.quot_equiv_of_eq (by rw [of, adjoin_root.mk, ideal.map_map])\n\n@[simp]\nlemma quot_map_of_equiv_quot_map_C_map_span_mk_mk (x : adjoin_root f) :\n  quot_map_of_equiv_quot_map_C_map_span_mk I f (ideal.quotient.mk (I.map (of f)) x) =\n    ideal.quotient.mk _ x :=\nrfl\n\n--this lemma should have the simp tag but this causes a lint issue\nlemma quot_map_of_equiv_quot_map_C_map_span_mk_symm_mk (x : adjoin_root f) :\n  (quot_map_of_equiv_quot_map_C_map_span_mk I f).symm\n  (ideal.quotient.mk ((I.map (C : R →+* R[X])).map (span {f})^.quotient.mk) x) =\n    ideal.quotient.mk (I.map (of f)) x :=\nby rw [quot_map_of_equiv_quot_map_C_map_span_mk, ideal.quot_equiv_of_eq_symm, quot_equiv_of_eq_mk]\n\n/-- The natural isomorphism `R[α]/((I[x] ⊔ (f)) / (f)) ≅ (R[x]/I[x])/((f) ⊔ I[x] / I[x])`\n  for `α` a root of `f : R[X]` and `I : ideal R`-/\ndef quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk :\n  (adjoin_root f) ⧸ (I.map (C : R →+* R[X])).map (span ({f} : set R[X]))^.quotient.mk ≃+*\n    (R[X] ⧸ I.map (C : R →+* R[X])) ⧸ (span ({f} : set R[X])).map\n    (I.map (C : R →+* R[X]))^.quotient.mk :=\nquot_quot_equiv_comm (ideal.span ({f} : set R[X])) (I.map (C : R →+* R[X]))\n\n@[simp]\nlemma quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk_mk (p : R[X]) :\n  quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk I f (ideal.quotient.mk _ (mk f p)) =\n    quot_quot_mk (I.map C) (span {f}) p :=\nrfl\n\n@[simp]\nlemma quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk_symm_quot_quot_mk (p : R[X]) :\n  (quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk I f).symm\n  (quot_quot_mk (I.map C) (span {f}) p) = (ideal.quotient.mk _ (mk f p)) :=\nrfl\n\n/-- The natural isomorphism `(R/I)[x]/(f mod I) ≅ (R[x]/I*R[x])/(f mod I[x])` where\n  `f : R[X]` and `I : ideal R`-/\ndef polynomial.quot_quot_equiv_comm :\n  (R ⧸ I)[X] ⧸ span ({f.map (I^.quotient.mk)} : set (polynomial (R ⧸ I))) ≃+*\n    (R[X] ⧸ map C I) ⧸ span ({(ideal.quotient.mk (I.map C)) f} : set (R[X] ⧸ map C I)) :=\nquotient_equiv (span ({f.map (I^.quotient.mk)} : set (polynomial (R ⧸ I))))\n  (span {ideal.quotient.mk (I.map polynomial.C) f})\n  (polynomial_quotient_equiv_quotient_polynomial I)\n  (by rw [map_span, set.image_singleton, ring_equiv.coe_to_ring_hom,\n    polynomial_quotient_equiv_quotient_polynomial_map_mk I f])\n\n@[simp]\nlemma polynomial.quot_quot_equiv_comm_mk (p : R[X]) :\n  (polynomial.quot_quot_equiv_comm I f) (ideal.quotient.mk  _ (p.map I^.quotient.mk)) =\n  (ideal.quotient.mk _ (ideal.quotient.mk _ p)) :=\nby simp only [polynomial.quot_quot_equiv_comm, quotient_equiv_mk,\n  polynomial_quotient_equiv_quotient_polynomial_map_mk]\n\n@[simp]\nlemma polynomial.quot_quot_equiv_comm_symm_mk_mk (p : R[X]) :\n  (polynomial.quot_quot_equiv_comm I f).symm (ideal.quotient.mk _ (ideal.quotient.mk _ p)) =\n    (ideal.quotient.mk  _ (p.map I^.quotient.mk)) :=\nby simp only [polynomial.quot_quot_equiv_comm, quotient_equiv_symm_mk,\n  polynomial_quotient_equiv_quotient_polynomial_symm_mk]\n\n/-- The natural isomorphism `R[α]/I[α] ≅ (R/I)[X]/(f mod I)` for `α` a root of `f : R[X]`\n  and `I : ideal R`.-/\ndef quot_adjoin_root_equiv_quot_polynomial_quot : (adjoin_root f) ⧸ (I.map (of f)) ≃+*\n  (R ⧸ I)[X] ⧸ (span ({f.map (I^.quotient.mk)} : set (R ⧸ I)[X])) :=\n(quot_map_of_equiv_quot_map_C_map_span_mk I f).trans\n  ((quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk I f).trans\n  ((ideal.quot_equiv_of_eq\n  (show (span ({f} : set R[X])).map (I.map (C : R →+* R[X]))^.quotient.mk =\n    span ({(ideal.quotient.mk (I.map polynomial.C)) f} : set (R[X] ⧸ map C I)),\n    from by rw [map_span, set.image_singleton])).trans\n  (polynomial.quot_quot_equiv_comm I f).symm))\n\n@[simp]\nlemma quot_adjoin_root_equiv_quot_polynomial_quot_mk_of (p : R[X]) :\n  quot_adjoin_root_equiv_quot_polynomial_quot I f (ideal.quotient.mk (I.map (of f)) (mk f p)) =\n    ideal.quotient.mk (span ({f.map (I^.quotient.mk)} : set (R ⧸ I)[X]))\n    (p.map I^.quotient.mk) :=\nby rw [quot_adjoin_root_equiv_quot_polynomial_quot, ring_equiv.trans_apply, ring_equiv.trans_apply,\n    ring_equiv.trans_apply, quot_map_of_equiv_quot_map_C_map_span_mk_mk,\n    quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk_mk, quot_quot_mk, ring_hom.comp_apply,\n    quot_equiv_of_eq_mk, polynomial.quot_quot_equiv_comm_symm_mk_mk]\n\n@[simp]\nlemma quot_adjoin_root_equiv_quot_polynomial_quot_symm_mk_mk (p : R[X]) :\n  (quot_adjoin_root_equiv_quot_polynomial_quot I f).symm\n  (ideal.quotient.mk (span ({f.map (I^.quotient.mk)} : set (R ⧸ I)[X]))\n    (p.map I^.quotient.mk)) = (ideal.quotient.mk (I.map (of f)) (mk f p)) :=\nby rw [quot_adjoin_root_equiv_quot_polynomial_quot, ring_equiv.symm_trans_apply,\n    ring_equiv.symm_trans_apply, ring_equiv.symm_trans_apply, ring_equiv.symm_symm,\n    polynomial.quot_quot_equiv_comm_mk, ideal.quot_equiv_of_eq_symm,\n    ideal.quot_equiv_of_eq_mk, ← ring_hom.comp_apply, ← double_quot.quot_quot_mk,\n    quot_map_C_map_span_mk_equiv_quot_map_C_quot_map_span_mk_symm_quot_quot_mk,\n    quot_map_of_equiv_quot_map_C_map_span_mk_symm_mk]\n\n/-- Promote `adjoin_root.quot_adjoin_root_equiv_quot_polynomial_quot` to an alg_equiv.  -/\n@[simps apply symm_apply]\nnoncomputable def quot_equiv_quot_map (f : R[X]) (I : ideal R) :\n  ((adjoin_root f) ⧸ (ideal.map (of f) I)) ≃ₐ[R]\n     ((R ⧸ I) [X]) ⧸ (ideal.span ({polynomial.map I^.quotient.mk f} : set ((R ⧸ I) [X]))) :=\nalg_equiv.of_ring_equiv (show ∀ x, (quot_adjoin_root_equiv_quot_polynomial_quot I f)\n  (algebra_map R _ x) = algebra_map R _ x, from λ x, begin\n    have : algebra_map R ((adjoin_root f) ⧸ (ideal.map (of f) I)) x = ideal.quotient.mk\n      (ideal.map (adjoin_root.of f) I) ((mk f) (C x)) := rfl,\n    simpa only [this, quot_adjoin_root_equiv_quot_polynomial_quot_mk_of, map_C]\n  end)\n\n@[simp]\nlemma quot_equiv_quot_map_apply_mk (f g : R[X]) (I : ideal R)  :\n  adjoin_root.quot_equiv_quot_map f I (ideal.quotient.mk _ (adjoin_root.mk f g)) =\n    ideal.quotient.mk _ (g.map I^.quotient.mk) :=\nby rw [adjoin_root.quot_equiv_quot_map_apply,\n    adjoin_root.quot_adjoin_root_equiv_quot_polynomial_quot_mk_of]\n\n@[simp]\nlemma quot_equiv_quot_map_symm_apply_mk (f g : R[X]) (I : ideal R)  :\n  (adjoin_root.quot_equiv_quot_map f I).symm (ideal.quotient.mk _ (map (ideal.quotient.mk I) g)) =\n    ideal.quotient.mk _ (adjoin_root.mk f g) :=\nby rw [adjoin_root.quot_equiv_quot_map_symm_apply,\n    adjoin_root.quot_adjoin_root_equiv_quot_polynomial_quot_symm_mk_mk]\n\nend\n\nend adjoin_root\n\nnamespace power_basis\n\nopen adjoin_root alg_equiv\n\nvariables [comm_ring R] [comm_ring S] [algebra R S]\n\n/-- Let `α` have minimal polynomial `f` over `R` and `I` be an ideal of `R`,\nthen `R[α] / (I) = (R[x] / (f)) / pS = (R/p)[x] / (f mod p)`. -/\n@[simps apply symm_apply]\nnoncomputable def quotient_equiv_quotient_minpoly_map (pb : power_basis R S)\n  (I : ideal R) :\n  (S ⧸ I.map (algebra_map R S)) ≃ₐ[R] (polynomial (R ⧸ I)) ⧸\n    (ideal.span ({(minpoly R pb.gen).map I^.quotient.mk} : set (polynomial (R ⧸ I)))) :=\n(of_ring_equiv\n  (show ∀ x, (ideal.quotient_equiv _ (ideal.map (adjoin_root.of (minpoly R pb.gen)) I)\n    (adjoin_root.equiv' (minpoly R pb.gen) pb\n    (by rw [adjoin_root.aeval_eq, adjoin_root.mk_self])\n    (minpoly.aeval _ _)).symm.to_ring_equiv\n    (by rw [ideal.map_map, alg_equiv.to_ring_equiv_eq_coe, ← alg_equiv.coe_ring_hom_commutes,\n          ← adjoin_root.algebra_map_eq, alg_hom.comp_algebra_map]))\n    (algebra_map R (S ⧸ I.map (algebra_map R S)) x) = algebra_map R _ x, from\n  (λ x, by rw [← ideal.quotient.mk_algebra_map, ideal.quotient_equiv_apply,\n    ring_hom.to_fun_eq_coe, ideal.quotient_map_mk, alg_equiv.to_ring_equiv_eq_coe,\n    ring_equiv.coe_to_ring_hom, alg_equiv.coe_ring_equiv, alg_equiv.commutes,\n    quotient.mk_algebra_map]))).trans (adjoin_root.quot_equiv_quot_map _ _)\n\n@[simp]\nlemma quotient_equiv_quotient_minpoly_map_apply_mk (pb : power_basis R S) (I : ideal R)\n  (g : R[X]) : pb.quotient_equiv_quotient_minpoly_map I\n  (ideal.quotient.mk _ (aeval pb.gen g)) = ideal.quotient.mk _ (g.map I^.quotient.mk) :=\nby rw [power_basis.quotient_equiv_quotient_minpoly_map, alg_equiv.trans_apply,\n    alg_equiv.of_ring_equiv_apply, quotient_equiv_mk, alg_equiv.coe_ring_equiv',\n    adjoin_root.equiv'_symm_apply, power_basis.lift_aeval,\n    adjoin_root.aeval_eq, adjoin_root.quot_equiv_quot_map_apply_mk]\n\n@[simp]\nlemma quotient_equiv_quotient_minpoly_map_symm_apply_mk (pb : power_basis R S) (I : ideal R)\n  (g : R[X]) : (pb.quotient_equiv_quotient_minpoly_map I).symm\n  (ideal.quotient.mk _ (g.map I^.quotient.mk)) = (ideal.quotient.mk _ (aeval pb.gen g)) :=\nbegin simp only [quotient_equiv_quotient_minpoly_map, to_ring_equiv_eq_coe, symm_trans_apply,\n    quot_equiv_quot_map_symm_apply_mk, of_ring_equiv_symm_apply, quotient_equiv_symm_mk,\n    to_ring_equiv_symm, ring_equiv.symm_symm, adjoin_root.equiv'_apply, coe_ring_equiv,\n    lift_hom_mk, symm_to_ring_equiv],\n\nend\n\nend power_basis\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/adjoin_root.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4972409595861899}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n-/\nimport category_theory.adjunction.whiskering\nimport category_theory.sites.sheafification\nimport category_theory.sites.whiskering\n\n/-!\n\nIn this file, we show that an adjunction `F ⊣ G` induces an adjunction between\ncategories of sheaves, under certain hypotheses on `F` and `G`.\n\n-/\n\nnamespace category_theory\n\nopen category_theory.grothendieck_topology\nopen category_theory\nopen category_theory.limits\nopen opposite\n\nuniverses w₁ w₂ v u\nvariables {C : Type u} [category.{v} C] (J : grothendieck_topology C)\nvariables {D : Type w₁} [category.{max v u} D]\nvariables {E : Type w₂} [category.{max v u} E]\nvariables {F : D ⥤ E} {G : E ⥤ D}\nvariables [∀ (X : C) (S : J.cover X) (P : Cᵒᵖ ⥤ D),\n  preserves_limit (S.index P).multicospan F]\n\nvariables\n  [concrete_category.{max v u} D]\n  [preserves_limits (forget D)]\n\n/-- The forgetful functor from `Sheaf J D` to sheaves of types, for a concrete category `D`\nwhose forgetful functor preserves the correct limits. -/\nabbreviation Sheaf_forget : Sheaf J D ⥤ SheafOfTypes J :=\nSheaf_compose J (forget D) ⋙ (Sheaf_equiv_SheafOfTypes J).functor\n\n-- We need to sheafify...\nvariables\n  [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.cover X), has_multiequalizer (S.index P)]\n  [∀ (X : C), has_colimits_of_shape (J.cover X)ᵒᵖ D]\n  [∀ (X : C), preserves_colimits_of_shape (J.cover X)ᵒᵖ (forget D)]\n  [reflects_isomorphisms (forget D)]\n\nnamespace Sheaf\nnoncomputable theory\n\n/-- This is the functor sending a sheaf `X : Sheaf J E` to the sheafification\nof `X ⋙ G`. -/\nabbreviation compose_and_sheafify (G : E ⥤ D) : Sheaf J E ⥤ Sheaf J D :=\nSheaf_to_presheaf J E ⋙ (whiskering_right _ _ _).obj G ⋙ presheaf_to_Sheaf J D\n\n/-- An auxiliary definition to be used in defining `category_theory.Sheaf.adjunction` below. -/\n@[simps]\ndef compose_equiv (adj : G ⊣ F) (X : Sheaf J E) (Y : Sheaf J D) :\n((compose_and_sheafify J G).obj X ⟶ Y) ≃ (X ⟶ (Sheaf_compose J F).obj Y) :=\nlet A := adj.whisker_right Cᵒᵖ in\n{ to_fun := λ η, ⟨A.hom_equiv _ _ (J.to_sheafify _  ≫ η.val)⟩,\n  inv_fun := λ γ, ⟨J.sheafify_lift ((A.hom_equiv _ _).symm ((Sheaf_to_presheaf _ _).map γ)) Y.2⟩,\n  left_inv := begin\n    intros η,\n    ext1,\n    dsimp,\n    symmetry,\n    apply J.sheafify_lift_unique,\n    rw equiv.symm_apply_apply,\n  end,\n  right_inv := begin\n    intros γ,\n    ext1,\n    dsimp,\n    rw [J.to_sheafify_sheafify_lift, equiv.apply_symm_apply],\n  end }\n\n/-- An adjunction `adj : G ⊣ F` with `F : D ⥤ E` and `G : E ⥤ D` induces an adjunction\nbetween `Sheaf J D` and `Sheaf J E`, in contexts where one can sheafify `D`-valued presheaves,\nand `F` preserves the correct limits. -/\n@[simps unit_app_val counit_app_val]\ndef adjunction (adj : G ⊣ F) : compose_and_sheafify J G ⊣ Sheaf_compose J F :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := compose_equiv J adj,\n  hom_equiv_naturality_left_symm' := λ X' X Y f g, by { ext1, dsimp, simp },\n  hom_equiv_naturality_right' := λ X Y Y' f g, by { ext1, dsimp, simp } }\n\ninstance [is_right_adjoint F] : is_right_adjoint (Sheaf_compose J F) :=\n⟨_, adjunction J (adjunction.of_right_adjoint F)⟩\n\nsection forget_to_type\n\n/-- This is the functor sending a sheaf of types `X` to the sheafification of `X ⋙ G`. -/\nabbreviation compose_and_sheafify_from_types (G : Type (max v u) ⥤ D) :\n  SheafOfTypes J ⥤ Sheaf J D :=\n(Sheaf_equiv_SheafOfTypes J).inverse ⋙ compose_and_sheafify _ G\n\n/-- A variant of the adjunction between sheaf categories, in the case where the right adjoint\nis the forgetful functor to sheaves of types. -/\ndef adjunction_to_types {G : Type (max v u) ⥤ D} (adj : G ⊣ forget D) :\n  compose_and_sheafify_from_types J G ⊣ Sheaf_forget J :=\n((Sheaf_equiv_SheafOfTypes J).symm.to_adjunction).comp (adjunction J adj)\n\n@[simp]\nlemma adjunction_to_types_unit_app_val {G : Type (max v u) ⥤ D} (adj : G ⊣ forget D)\n  (Y : SheafOfTypes J) :\n  ((adjunction_to_types J adj).unit.app Y).val =\n  (adj.whisker_right _).unit.app ((SheafOfTypes_to_presheaf J).obj Y) ≫\n  whisker_right (J.to_sheafify _) (forget D) :=\nbegin\n  dsimp [adjunction_to_types, adjunction.comp],\n  simpa,\nend\n\n@[simp]\nlemma adjunction_to_types_counit_app_val {G : Type (max v u) ⥤ D} (adj : G ⊣ forget D)\n  (X : Sheaf J D) :\n  ((adjunction_to_types J adj).counit.app X).val =\n  J.sheafify_lift ((functor.associator _ _ _).hom ≫ (adj.whisker_right _).counit.app _) X.2 :=\nbegin\n  dsimp [adjunction_to_types, adjunction.comp, adjunction.whisker_right],\n  rw category.id_comp,\n  apply J.sheafify_lift_unique,\n  rw [adjunction_counit_app_val, J.sheafify_map_sheafify_lift, J.to_sheafify_sheafify_lift],\n  ext,\n  dsimp [Sheaf_equiv_SheafOfTypes, equivalence.symm,\n    equivalence.to_adjunction, nat_iso.of_components],\n  simp,\nend\n\ninstance [is_right_adjoint (forget D)] : is_right_adjoint (Sheaf_forget J) :=\n⟨_, adjunction_to_types J (adjunction.of_right_adjoint (forget D))⟩\n\nend forget_to_type\n\nend Sheaf\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/sites/adjunction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6442250996557035, "lm_q1q2_score": 0.4972409543139847}}
{"text": "import SciLean.Notation\nimport SciLean.Core.Attributes\nimport SciLean.Core.HasAdjoint\nimport SciLean.Core.Defs\n\nimport SciLean.Tactic.CustomSimp.AllPrePost\n\nnamespace SciLean\n\ninstance adjoint.arg_y.hasAdjoint {X Y} [SemiHilbert X] [SemiHilbert Y] (f : X → Y) [HasAdjointT f]\n  : HasAdjoint (f†) := sorry_proof\n\n\ninstance adjoint.arg_fy.isSmooth_2 {X Y W} [Vec W] [SemiHilbert X] [SemiHilbert Y]\n  (A : W → X → Y) [∀ x, HasAdjointT (A x)] [∀ w, IsSmoothT (A w)] [IsSmoothT λ w => λ x ⟿ A w x] (w : W)\n  : IsSmoothT (λ y => (A w)† y) := sorry_proof\n\ninstance adjoint.arg_fy.isSmooth_1 {X Y W} [Vec W] [SemiHilbert X] [SemiHilbert Y]\n  (A : W → X → Y) [∀ x, HasAdjointT (A x)] [∀ w, IsSmoothT (A w)] [IsSmoothT λ w => λ x ⟿ A w x]\n  : IsSmoothT (λ w => λ y ⟿ (A w)† y) := sorry_proof\n\n-- on Hilbert spaces any linear function has adjoint\n-- We only want this to apply for atomic functions that is why we ask for `IsLin` and not for `IsLinT`\n-- This causes some issues\n-- instance {X Y} [Hilbert X] [Hilbert Y] (A : X → Y) [IsLin A] : HasAdjointT A := sorry_proof\n\n-- example {X Y} [Hilbert X] [Hilbert Y] (A : X ⊸ Y) : IsLinT λ x => adjoint A x := by infer_instance\n\n--------------------------------------------------------------------------------\n\nvariable {α β γ : Type}\nvariable {X Y Z : Type} [SemiHilbert X] [SemiHilbert Y] [SemiHilbert Z]\nvariable {Y₁ Y₂ : Type} [SemiHilbert Y₁] [SemiHilbert Y₂]\nvariable {ι : Type} [Enumtype ι]\n\n@[simp ↓, diff]\ntheorem id.arg_x.adj_simp\n  : (λ x : X => x)† = λ x => x := sorry_proof\n\n@[simp ↓, diff]\ntheorem const.arg_x.adj_simp\n  : (λ (x : X) (i : ι) => x)† = λ f => ∑ i, f i := sorry_proof\n\n@[simp ↓, diff]\ntheorem const.arg_y.adj_simp\n  : (λ (y : Y) => (0 : X))† = λ y' => (0 : Y) := sorry_proof\n\n@[simp ↓ low-3, diff low-3]\ntheorem swap.arg_y.adj_simp\n  (f : ι → Y → Z) [∀ i, HasAdjointT (f i)] \n  : (λ y i => f i y)† = λ g => ∑ i, (f i)† (g i) := sorry_proof\n\n@[simp ↓ low-4, diff low-4]\ntheorem swapDep.arg_y.adj_simp\n  {ι Y} {Z : ι → Type} [SemiHilbert Y] [∀ i, SemiHilbert (Z i)] [Enumtype ι]\n  (f : (i : ι) → Y → Z i) [∀ i, HasAdjointT (f i)] \n  : (λ y i => f i y)† = λ g => ∑ i, (f i)† (g i) := sorry_proof\n\n-- @[simp ↓ (low-1), diff low-4, simp_guard g (λ x => x)]\ntheorem scomb.arg_x.adj_simp\n  (f : X → Y → Z) [HasAdjointNT 2 f]\n  (g : X → Y) [HasAdjointT g]\n  : (λ x => f x (g x))† \n    =\n    λ z' =>\n      let (x',y') := (uncurryN 2 f)† z'\n      x' + g† y'  \n  := sorry_proof\n  \n@[simp ↓ low, diff low-3, simp_guard g (λ x => x)]\ntheorem comp.arg_x.adj_simp\n  (f : Y → Z) [HasAdjointT f] \n  (g : X → Y) [HasAdjointT g] \n  : (λ x => f (g x))† = λ z => g† (f† z) := sorry_proof\n\n-- @[simp ↓ low]\n-- theorem subst.arg_x.adj_simp\n--   (f : X → Y → Z) [HasAdjoint (λ ((x,y) : X × Y) => f x y)] \n--   (g : X → Y) [HasAdjoint g] \n--   : (λ x => f x (g x))† \n--     = λ z =>\n--         let f' := (λ (x,y) => f x y)†\n--         (f' z).1 + g† (f' z).2\n-- := by sorry_proof\n\n-- TODO: add simp guard!\n@[simp ↓ low, diff low, simp_guard g₁ Prod.fst, g₂ Prod.snd]\ntheorem diag.arg_x.adj_simp\n  (f : Y₁ → Y₂ → Z) [HasAdjointNT 2 f] \n  (g₁ : X → Y₁) [HasAdjointT g₁] \n  (g₂ : X → Y₂) [HasAdjointT g₂] \n  : (λ x => f (g₁ x) (g₂ x))† \n    = λ z => \n      let (y₁, y₂) := (uncurryN 2 f)† z\n      (g₁† y₁) + (g₂† y₂)\n:= by sorry_proof\n\n-- This prevents an infinite loop when using `adjoint_of_diag` \n-- with `g₁ = Prod.fst` and `g₂ = Prod.snd`\n-- @[simp ↓ low+1, diff low+1]\n-- theorem diag.arg_x.adj_simp_safeguard\n--   (f : X → Y → Z) [HasAdjointNT 2 f]\n--   : adjoint (λ xy => f xy.1 xy.2) = (uncurryN 2 f)† := by rfl; done \n\n@[simp ↓ low, diff low]\ntheorem eval.arg_f.adj_simp\n  (i : ι)\n  : (λ (f : ι → X) => f i)† = (λ f' j => ([[i = j]] • f' : X))\n:= sorry_proof\n\n@[simp ↓ low-1, diff low-1]\ntheorem evalDep.arg_f.adj_simp\n  {ι} {X : ι → Type} [∀ i, SemiHilbert (X i)] [Enumtype ι]\n  (i : ι)\n  : (λ (f : (i' : ι) → X i') => f i)† = (λ f' j => (if h : i = j then h ▸ f' else 0))\n:= sorry_proof\n\n@[simp ↓ low-1, diff low-1]\ntheorem eval.arg_x.parm1.adj_simp\n  (f : X → ι → Z) [HasAdjointT f] (i : ι)\n  : (λ x => f x i)† = (λ x' => f† (λ j => ([[i = j]] • x')))\n:= \nby \n  rw [comp.arg_x.adj_simp (λ (x : ι → Z) => x i) f]\n  simp; done\n\n@[simp ↓ low-2, diff low-2]\ntheorem evalDep.arg_x.parm1.adj_simp\n  {ι Y} {Z : ι → Type} [SemiHilbert Y] [∀ i, SemiHilbert (Z i)] [Enumtype ι]\n  (f : X → (i : ι) → Z i) [HasAdjointT f] (i : ι)\n  : (λ x => f x i)† = (λ x' => f† (λ j => (if h : i = j then h ▸ x' else 0)))\n:= \nby \n  rw [comp.arg_x.adj_simp (λ (x : (i : ι) → Z i) => x i) f]\n  simp; done\n\n--------------------------------------------------------------------------------\n-- Unification Hints\n--------------------------------------------------------------------------------\n\nunif_hint comp.arg_x.adj_simp.unif_hint_1 (f? : Y → Z)\n  (f :  Y → α → Z) (g  : X → Y) (a : α)  \nwhere\n  f? =?= λ x => f x a\n  |- \n  (λ x => f? (g x))† =?= (λ x => f (g x) a)†\n\nunif_hint comp.arg_x.adj_simp.unif_hint_2 (f? : Y → Z)  \n  (f  : Y → α → β → Z) (g  : X → Y) (a : α) (b : β)\nwhere\n  f? =?= λ x => f x a b\n  |-\n  (λ x => f? (g x))† =?= (λ x => f (g x) a b)†\n\nunif_hint comp.arg_x.adj_simp.unif_hint_3 (f? : Y → Z)\n  (f  : Y → α → β → γ → Z) (g  : X → Y) (a : α) (b : β) (c : γ)  \nwhere\n  f? =?= λ x => f x a b c\n  |-\n  (λ x => f? (g x))† =?= (λ x => f (g x) a b c)†\n\n-- unif_hint scomb.arg_x.adj_simp.unif_hint_1\n--   (a : α)\n--   (g? : X → Y) (f? : X → Y → Z)\n--   (g : X → Y) (f  : X → Y → α → Z) where\n--   g? =?= g\n--   f? =?= λ x y => f x y a\n--   |-\n--   (λ x => f? x (g? x))† =?= (λ x => f x (g x) a)†\n\n\nunif_hint diag.arg_x.adj_simp.unif_hint_1 (f? : Y₁ → Y₂ → Z)\n  (f : Y₁ → Y₂ → α → Z) (g₁ : X → Y₁) (g₂ : X → Y₂) (a : α)\nwhere  \n  f? =?= λ y₁ y₂ => f y₁ y₂ a\n  |-\n  (λ x => f? (g₁ x) (g₂ x))† =?= (λ x => f (g₁ x) (g₂ x) a)† \n\nunif_hint diag.arg_x.adj_simp.unif_hint_2 (f? : Y₁ → Y₂ → Z)\n  (f : Y₁ → Y₂ → α → β → Z) (g₁ : X → Y₁) (g₂ : X → Y₂) (a : α) (b : β)\nwhere  \n  f? =?= λ y₁ y₂ => f y₁ y₂ a b\n  |-\n  (λ x => f? (g₁ x) (g₂ x))† =?= (λ x => f (g₁ x) (g₂ x) a b)† \n\nunif_hint diag.arg_x.adj_simp.unif_hint_3 (f? : Y₁ → Y₂ → Z)\n  (f : Y₁ → Y₂ → α → β → γ → Z) (g₁ : X → Y₁) (g₂ : X → Y₂) (a : α) (b : β) (c : γ)\nwhere  \n  f? =?= λ y₁ y₂ => f y₁ y₂ a b c\n  |-\n  (λ x => f? (g₁ x) (g₂ x))† =?= (λ x => f (g₁ x) (g₂ x) a b c)† \n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Core/Adjoint.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.497224379049118}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.int.basic algebra.associated data.nat.gcd\n\n/-- The ring of integers adjoined with a square root of `d`.\n  These have the form `a + b √d` where `a b : ℤ`. The components\n  are called `re` and `im` by analogy to the negative `d` case,\n  but of course both parts are real here since `d` is nonnegative. -/\nstructure zsqrtd (d : ℤ) := mk {} ::\n(re : ℤ)\n(im : ℤ)\n\nprefix `ℤ√`:100 := zsqrtd\n\nnamespace zsqrtd\nsection\n  parameters {d : ℤ}\n\n  instance : decidable_eq ℤ√d :=\n  by tactic.mk_dec_eq_instance\n\n  theorem ext : ∀ {z w : ℤ√d}, z = w ↔ z.re = w.re ∧ z.im = w.im\n  | ⟨x, y⟩ ⟨x', y'⟩ := ⟨λ h, by injection h; split; assumption,\n                        λ ⟨h₁, h₂⟩, by congr; assumption⟩\n\n  /-- Convert an integer to a `ℤ√d` -/\n  def of_int (n : ℤ) : ℤ√d := ⟨n, 0⟩\n  @[simp] theorem of_int_re (n : ℤ) : (of_int n).re = n := rfl\n  @[simp] theorem of_int_im (n : ℤ) : (of_int n).im = 0 := rfl\n\n  /-- The zero of the ring -/\n  def zero : ℤ√d := of_int 0\n  instance : has_zero ℤ√d := ⟨zsqrtd.zero⟩\n  @[simp] theorem zero_re : (0 : ℤ√d).re = 0 := rfl\n  @[simp] theorem zero_im : (0 : ℤ√d).im = 0 := rfl\n\n  /-- The one of the ring -/\n  def one : ℤ√d := of_int 1\n  instance : has_one ℤ√d := ⟨zsqrtd.one⟩\n  @[simp] theorem one_re : (1 : ℤ√d).re = 1 := rfl\n  @[simp] theorem one_im : (1 : ℤ√d).im = 0 := rfl\n\n  /-- The representative of `√d` in the ring -/\n  def sqrtd : ℤ√d := ⟨0, 1⟩\n  @[simp] theorem sqrtd_re : (sqrtd : ℤ√d).re = 0 := rfl\n  @[simp] theorem sqrtd_im : (sqrtd : ℤ√d).im = 1 := rfl\n\n  /-- Addition of elements of `ℤ√d` -/\n  def add : ℤ√d → ℤ√d → ℤ√d\n  | ⟨x, y⟩ ⟨x', y'⟩ := ⟨x + x', y + y'⟩\n  instance : has_add ℤ√d := ⟨zsqrtd.add⟩\n  @[simp] theorem add_def (x y x' y' : ℤ) :\n    (⟨x, y⟩ + ⟨x', y'⟩ : ℤ√d) = ⟨x + x', y + y'⟩ := rfl\n  @[simp] theorem add_re : ∀ z w : ℤ√d, (z + w).re = z.re + w.re\n  | ⟨x, y⟩ ⟨x', y'⟩ := rfl\n  @[simp] theorem add_im : ∀ z w : ℤ√d, (z + w).im = z.im + w.im\n  | ⟨x, y⟩ ⟨x', y'⟩ := rfl\n\n  @[simp] theorem bit0_re (z) : (bit0 z : ℤ√d).re = bit0 z.re := add_re _ _\n  @[simp] theorem bit0_im (z) : (bit0 z : ℤ√d).im = bit0 z.im := add_im _ _\n\n  @[simp] theorem bit1_re (z) : (bit1 z : ℤ√d).re = bit1 z.re := by simp [bit1]\n  @[simp] theorem bit1_im (z) : (bit1 z : ℤ√d).im = bit0 z.im := by simp [bit1]\n\n  /-- Negation in `ℤ√d` -/\n  def neg : ℤ√d → ℤ√d\n  | ⟨x, y⟩ := ⟨-x, -y⟩\n  instance : has_neg ℤ√d := ⟨zsqrtd.neg⟩\n  @[simp] theorem neg_re : ∀ z : ℤ√d, (-z).re = -z.re\n  | ⟨x, y⟩ := rfl\n  @[simp] theorem neg_im : ∀ z : ℤ√d, (-z).im = -z.im\n  | ⟨x, y⟩ := rfl\n\n  /-- Conjugation in `ℤ√d`. The conjugate of `a + b √d` is `a - b √d`. -/\n  def conj : ℤ√d → ℤ√d\n  | ⟨x, y⟩ := ⟨x, -y⟩\n  @[simp] theorem conj_re : ∀ z : ℤ√d, (conj z).re = z.re\n  | ⟨x, y⟩ := rfl\n  @[simp] theorem conj_im : ∀ z : ℤ√d, (conj z).im = -z.im\n  | ⟨x, y⟩ := rfl\n\n  /-- Multiplication in `ℤ√d` -/\n  def mul : ℤ√d → ℤ√d → ℤ√d\n  | ⟨x, y⟩ ⟨x', y'⟩ := ⟨x * x' + d * y * y', x * y' + y * x'⟩\n  instance : has_mul ℤ√d := ⟨zsqrtd.mul⟩\n  @[simp] theorem mul_re : ∀ z w : ℤ√d, (z * w).re = z.re * w.re + d * z.im * w.im\n  | ⟨x, y⟩ ⟨x', y'⟩ := rfl\n  @[simp] theorem mul_im : ∀ z w : ℤ√d, (z * w).im = z.re * w.im + z.im * w.re\n  | ⟨x, y⟩ ⟨x', y'⟩ := rfl\n\n  instance : comm_ring ℤ√d := by refine\n  { add            := (+),\n    zero           := 0,\n    neg            := has_neg.neg,\n    mul            := (*),\n    one            := 1, ..};\n  { intros, simp [ext, add_mul, mul_add, mul_comm, mul_left_comm] }\n\n  instance : add_comm_monoid ℤ√d    := by apply_instance\n  instance : add_monoid ℤ√d         := by apply_instance\n  instance : monoid ℤ√d             := by apply_instance\n  instance : comm_monoid ℤ√d        := by apply_instance\n  instance : comm_semigroup ℤ√d     := by apply_instance\n  instance : semigroup ℤ√d          := by apply_instance\n  instance : add_comm_semigroup ℤ√d := by apply_instance\n  instance : add_semigroup ℤ√d      := by apply_instance\n  instance : comm_semiring ℤ√d      := by apply_instance\n  instance : semiring ℤ√d           := by apply_instance\n  instance : ring ℤ√d               := by apply_instance\n  instance : distrib ℤ√d            := by apply_instance\n\n  instance : zero_ne_one_class ℤ√d :=\n  { zero := 0, one := 1, zero_ne_one := dec_trivial }\n\n  instance : nonzero_comm_ring ℤ√d :=\n  { ..zsqrtd.comm_ring, ..zsqrtd.zero_ne_one_class }\n\n  @[simp] theorem coe_nat_re (n : ℕ) : (n : ℤ√d).re = n :=\n  by induction n; simp *\n  @[simp] theorem coe_nat_im (n : ℕ) : (n : ℤ√d).im = 0 :=\n  by induction n; simp *\n  theorem coe_nat_val (n : ℕ) : (n : ℤ√d) = ⟨n, 0⟩ :=\n  by simp [ext]\n\n  @[simp] theorem coe_int_re (n : ℤ) : (n : ℤ√d).re = n :=\n  by cases n; simp [*, int.of_nat_eq_coe, int.neg_succ_of_nat_eq]\n  @[simp] theorem coe_int_im (n : ℤ) : (n : ℤ√d).im = 0 :=\n  by cases n; simp *\n  theorem coe_int_val (n : ℤ) : (n : ℤ√d) = ⟨n, 0⟩ :=\n  by simp [ext]\n\n  instance : char_zero ℤ√d :=\n  { cast_inj := λ m n, ⟨by simp [zsqrtd.ext], congr_arg _⟩ }\n\n  @[simp] theorem of_int_eq_coe (n : ℤ) : (of_int n : ℤ√d) = n :=\n  by simp [ext]\n\n  @[simp] theorem smul_val (n x y : ℤ) : (n : ℤ√d) * ⟨x, y⟩ = ⟨n * x, n * y⟩ :=\n  by simp [ext]\n\n  @[simp] theorem muld_val (x y : ℤ) : sqrtd * ⟨x, y⟩ = ⟨d * y, x⟩ :=\n  by simp [ext]\n\n  @[simp] theorem smuld_val (n x y : ℤ) : sqrtd * (n : ℤ√d) * ⟨x, y⟩ = ⟨d * n * y, n * x⟩ :=\n  by simp [ext]\n\n  theorem decompose {x y : ℤ} : (⟨x, y⟩ : ℤ√d) = x + sqrtd * y :=\n  by simp [ext]\n\n  theorem mul_conj {x y : ℤ} : (⟨x, y⟩ * conj ⟨x, y⟩ : ℤ√d) = x * x - d * y * y :=\n  by simp [ext, mul_comm]\n\n  theorem conj_mul : Π {a b : ℤ√d}, conj (a * b) = conj a * conj b :=\n  by simp [ext]\n\n  protected lemma coe_int_add (m n : ℤ) : (↑(m + n) : ℤ√d) = ↑m + ↑n := by simp [ext]\n  protected lemma coe_int_sub (m n : ℤ) : (↑(m - n) : ℤ√d) = ↑m - ↑n := by simp [ext]\n  protected lemma coe_int_mul (m n : ℤ) : (↑(m * n) : ℤ√d) = ↑m * ↑n := by simp [ext]\n  protected lemma coe_int_inj {m n : ℤ} (h : (↑m : ℤ√d) = ↑n) : m = n :=\n  by simpa using congr_arg re h\n\n  /-- Read `sq_le a c b d` as `a √c ≤ b √d` -/\n  def sq_le (a c b d : ℕ) : Prop := c*a*a ≤ d*b*b\n\n  theorem sq_le_of_le {c d x y z w : ℕ} (xz : z ≤ x) (yw : y ≤ w) (xy : sq_le x c y d) : sq_le z c w d :=\n  le_trans (mul_le_mul (nat.mul_le_mul_left _ xz) xz (nat.zero_le _) (nat.zero_le _)) $\n    le_trans xy (mul_le_mul (nat.mul_le_mul_left _ yw) yw (nat.zero_le _) (nat.zero_le _))\n\n  theorem sq_le_add_mixed {c d x y z w : ℕ} (xy : sq_le x c y d) (zw : sq_le z c w d) :\n    c * (x * z) ≤ d * (y * w) :=\n  nat.mul_self_le_mul_self_iff.2 $\n  by simpa [mul_comm, mul_left_comm] using\n     mul_le_mul xy zw (nat.zero_le _) (nat.zero_le _)\n\n  theorem sq_le_add {c d x y z w : ℕ} (xy : sq_le x c y d) (zw : sq_le z c w d) :\n    sq_le (x + z) c (y + w) d :=\n  begin\n    have xz := sq_le_add_mixed xy zw,\n    simp [sq_le, mul_assoc] at xy zw,\n    simp [sq_le, mul_add, mul_comm, mul_left_comm, add_le_add, *]\n  end\n\n  theorem sq_le_cancel {c d x y z w : ℕ} (zw : sq_le y d x c) (h : sq_le (x + z) c (y + w) d) : sq_le z c w d :=\n  begin\n    apply le_of_not_gt,\n    intro l,\n    refine not_le_of_gt _ h,\n    simp [sq_le, mul_add, mul_comm, mul_left_comm],\n    have hm := sq_le_add_mixed zw (le_of_lt l),\n    simp [sq_le, mul_assoc] at l zw,\n    exact lt_of_le_of_lt (add_le_add_right zw _)\n      (add_lt_add_left (add_lt_add_of_le_of_lt hm (add_lt_add_of_le_of_lt hm l)) _)\n  end\n\n  theorem sq_le_smul {c d x y : ℕ} (n : ℕ) (xy : sq_le x c y d) : sq_le (n * x) c (n * y) d :=\n  by simpa [sq_le, mul_left_comm, mul_assoc] using\n     nat.mul_le_mul_left (n * n) xy\n\n  theorem sq_le_mul {d x y z w : ℕ} :\n    (sq_le x 1 y d → sq_le z 1 w d → sq_le (x * w + y * z) d (x * z + d * y * w) 1) ∧\n    (sq_le x 1 y d → sq_le w d z 1 → sq_le (x * z + d * y * w) 1 (x * w + y * z) d) ∧\n    (sq_le y d x 1 → sq_le z 1 w d → sq_le (x * z + d * y * w) 1 (x * w + y * z) d) ∧\n    (sq_le y d x 1 → sq_le w d z 1 → sq_le (x * w + y * z) d (x * z + d * y * w) 1) :=\n  by refine ⟨_, _, _, _⟩; {\n    intros xy zw,\n    have := int.mul_nonneg (sub_nonneg_of_le (int.coe_nat_le_coe_nat_of_le xy))\n                           (sub_nonneg_of_le (int.coe_nat_le_coe_nat_of_le zw)),\n    refine int.le_of_coe_nat_le_coe_nat (le_of_sub_nonneg _),\n    simpa [mul_add, mul_left_comm, mul_comm] }\n\n  /-- \"Generalized\" `nonneg`. `nonnegg c d x y` means `a √c + b √d ≥ 0`;\n    we are interested in the case `c = 1` but this is more symmetric -/\n  def nonnegg (c d : ℕ) : ℤ → ℤ → Prop\n  | (a : ℕ) (b : ℕ) := true\n  | (a : ℕ) -[1+ b] := sq_le (b+1) c a d\n  | -[1+ a] (b : ℕ) := sq_le (a+1) d b c\n  | -[1+ a] -[1+ b] := false\n\n  theorem nonnegg_comm {c d : ℕ} {x y : ℤ} : nonnegg c d x y = nonnegg d c y x :=\n  by induction x; induction y; refl\n\n  theorem nonnegg_neg_pos {c d} : Π {a b : ℕ}, nonnegg c d (-a) b ↔ sq_le a d b c\n  | 0     b := ⟨by simp [sq_le, nat.zero_le], λa, trivial⟩\n  | (a+1) b := by rw ← int.neg_succ_of_nat_coe; refl\n\n  theorem nonnegg_pos_neg {c d} {a b : ℕ} : nonnegg c d a (-b) ↔ sq_le b c a d :=\n  by rw nonnegg_comm; exact nonnegg_neg_pos\n\n  theorem nonnegg_cases_right {c d} {a : ℕ} : Π {b : ℤ}, (Π x : ℕ, b = -x → sq_le x c a d) → nonnegg c d a b\n  | (b:nat) h := trivial\n  | -[1+ b] h := h (b+1) rfl\n\n  theorem nonnegg_cases_left {c d} {b : ℕ} {a : ℤ} (h : Π x : ℕ, a = -x → sq_le x d b c) : nonnegg c d a b :=\n  cast nonnegg_comm (nonnegg_cases_right h)\n\nsection norm\n\ndef norm (n : ℤ√d) : ℤ := n.re * n.re - d * n.im * n.im\n\n@[simp] lemma norm_zero : norm 0 = 0 := by simp [norm]\n\n@[simp] lemma norm_one : norm 1 = 1 := by simp [norm]\n\n@[simp] lemma norm_int_cast (n : ℤ) : norm n = n * n := by simp [norm]\n\n@[simp] lemma norm_nat_cast (n : ℕ) : norm n = n * n := norm_int_cast n\n\n@[simp] lemma norm_mul (n m : ℤ√d) : norm (n * m) = norm n * norm m :=\nby simp [norm, mul_add, add_mul, mul_comm, mul_assoc, mul_left_comm]\n\nlemma norm_eq_mul_conj (n : ℤ√d) : (norm n : ℤ√d) = n * n.conj :=\nby cases n; simp [norm, conj, zsqrtd.ext, mul_comm]\n\ninstance : is_monoid_hom norm :=\n{ map_one := norm_one, map_mul := norm_mul }\n\nlemma norm_nonneg (hd : d ≤ 0) (n : ℤ√d) : 0 ≤ n.norm :=\nadd_nonneg (mul_self_nonneg _)\n  (by rw [mul_assoc, neg_mul_eq_neg_mul];\n    exact (mul_nonneg (neg_nonneg.2 hd) (mul_self_nonneg _)))\n\nlemma norm_eq_one_iff {x : ℤ√d} : x.norm.nat_abs = 1 ↔ is_unit x :=\n⟨λ h, is_unit_iff_dvd_one.2 $\n  (le_total 0 (norm x)).cases_on\n    (λ hx, show x ∣ 1, from ⟨x.conj,\n      by rwa [← int.coe_nat_inj', int.nat_abs_of_nonneg hx,\n        ← @int.cast_inj (ℤ√d) _ _, norm_eq_mul_conj, eq_comm] at h⟩)\n    (λ hx, show x ∣ 1, from ⟨- x.conj,\n      by rwa [← int.coe_nat_inj', int.of_nat_nat_abs_of_nonpos hx,\n        ← @int.cast_inj (ℤ√d) _ _, int.cast_neg, norm_eq_mul_conj, neg_mul_eq_mul_neg,\n        eq_comm] at h⟩),\nλ h, let ⟨y, hy⟩ := is_unit_iff_dvd_one.1 h in begin\n  have := congr_arg (int.nat_abs ∘ norm) hy,\n  rw [function.comp_app, function.comp_app, norm_mul, int.nat_abs_mul,\n    norm_one, int.nat_abs_one, eq_comm, nat.mul_eq_one_iff] at this,\n  exact this.1\nend⟩\n\nend norm\n\nend\n\nsection\nparameter {d : ℕ}\n\n  /-- Nonnegativity of an element of `ℤ√d`. -/\n  def nonneg : ℤ√d → Prop | ⟨a, b⟩ := nonnegg d 1 a b\n\n  protected def le (a b : ℤ√d) : Prop := nonneg (b - a)\n\n  instance : has_le ℤ√d := ⟨zsqrtd.le⟩\n\n  protected def lt (a b : ℤ√d) : Prop := ¬(b ≤ a)\n\n  instance : has_lt ℤ√d := ⟨zsqrtd.lt⟩\n\n  instance decidable_nonnegg (c d a b) : decidable (nonnegg c d a b) :=\n  by cases a; cases b; repeat {rw int.of_nat_eq_coe}; unfold nonnegg sq_le; apply_instance\n\n  instance decidable_nonneg : Π (a : ℤ√d), decidable (nonneg a)\n  | ⟨a, b⟩ := zsqrtd.decidable_nonnegg _ _ _ _\n\n  instance decidable_le (a b : ℤ√d) : decidable (a ≤ b) := decidable_nonneg _\n\n  theorem nonneg_cases : Π {a : ℤ√d}, nonneg a → ∃ x y : ℕ, a = ⟨x, y⟩ ∨ a = ⟨x, -y⟩ ∨ a = ⟨-x, y⟩\n  | ⟨(x : ℕ), (y : ℕ)⟩ h := ⟨x, y, or.inl rfl⟩\n  | ⟨(x : ℕ), -[1+ y]⟩ h := ⟨x, y+1, or.inr $ or.inl rfl⟩\n  | ⟨-[1+ x], (y : ℕ)⟩ h := ⟨x+1, y, or.inr $ or.inr rfl⟩\n  | ⟨-[1+ x], -[1+ y]⟩ h := false.elim h\n\n  lemma nonneg_add_lem {x y z w : ℕ} (xy : nonneg ⟨x, -y⟩) (zw : nonneg ⟨-z, w⟩) : nonneg (⟨x, -y⟩ + ⟨-z, w⟩) :=\n  have nonneg ⟨int.sub_nat_nat x z, int.sub_nat_nat w y⟩, from int.sub_nat_nat_elim x z\n    (λm n i, sq_le y d m 1 → sq_le n 1 w d → nonneg ⟨i, int.sub_nat_nat w y⟩)\n    (λj k, int.sub_nat_nat_elim w y\n      (λm n i, sq_le n d (k + j) 1 → sq_le k 1 m d → nonneg ⟨int.of_nat j, i⟩)\n      (λm n xy zw, trivial)\n      (λm n xy zw, sq_le_cancel zw xy))\n    (λj k, int.sub_nat_nat_elim w y\n      (λm n i, sq_le n d k 1 → sq_le (k + j + 1) 1 m d → nonneg ⟨-[1+ j], i⟩)\n      (λm n xy zw, sq_le_cancel xy zw)\n      (λm n xy zw, let t := nat.le_trans zw (sq_le_of_le (nat.le_add_right n (m+1)) (le_refl _) xy) in\n        have k + j + 1 ≤ k, from nat.mul_self_le_mul_self_iff.2 (by repeat{rw one_mul at t}; exact t),\n        absurd this (not_le_of_gt $ nat.succ_le_succ $ nat.le_add_right _ _))) (nonnegg_pos_neg.1 xy) (nonnegg_neg_pos.1 zw),\n  show nonneg ⟨_, _⟩, by rw [neg_add_eq_sub]; rwa [int.sub_nat_nat_eq_coe,int.sub_nat_nat_eq_coe] at this\n\n  theorem nonneg_add {a b : ℤ√d} (ha : nonneg a) (hb : nonneg b) : nonneg (a + b) :=\n  begin\n    rcases nonneg_cases ha with ⟨x, y, rfl|rfl|rfl⟩;\n    rcases nonneg_cases hb with ⟨z, w, rfl|rfl|rfl⟩; dsimp [add, nonneg] at ha hb ⊢,\n    { trivial },\n    { refine nonnegg_cases_right (λi h, sq_le_of_le _ _ (nonnegg_pos_neg.1 hb)),\n      { exact int.coe_nat_le.1 (le_of_neg_le_neg (@int.le.intro _ _ y (by simp *))) },\n      { apply nat.le_add_left } },\n    { refine nonnegg_cases_left (λi h, sq_le_of_le _ _ (nonnegg_neg_pos.1 hb)),\n      { exact int.coe_nat_le.1 (le_of_neg_le_neg (@int.le.intro _ _ x (by simp *))) },\n      { apply nat.le_add_left } },\n    { refine nonnegg_cases_right (λi h, sq_le_of_le _ _ (nonnegg_pos_neg.1 ha)),\n      { exact int.coe_nat_le.1 (le_of_neg_le_neg (@int.le.intro _ _ w (by simp *))) },\n      { apply nat.le_add_right } },\n    { simpa using nonnegg_pos_neg.2 (sq_le_add (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb)) },\n    { exact nonneg_add_lem ha hb },\n    { refine nonnegg_cases_left (λi h, sq_le_of_le _ _ (nonnegg_neg_pos.1 ha)),\n      { exact int.coe_nat_le.1 (le_of_neg_le_neg (@int.le.intro _ _ z (by simp *))) },\n      { apply nat.le_add_right } },\n    { rw [add_comm, add_comm ↑y], exact nonneg_add_lem hb ha },\n    { simpa using nonnegg_neg_pos.2 (sq_le_add (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb)) },\n  end\n\n  theorem le_refl (a : ℤ√d) : a ≤ a := show nonneg (a - a), by simp\n\n  protected theorem le_trans {a b c : ℤ√d} (ab : a ≤ b) (bc : b ≤ c) : a ≤ c :=\n  have nonneg (b - a + (c - b)), from nonneg_add ab bc,\n  by simpa\n\n  theorem nonneg_iff_zero_le {a : ℤ√d} : nonneg a ↔ 0 ≤ a := show _ ↔ nonneg _, by simp\n\n  theorem le_of_le_le {x y z w : ℤ} (xz : x ≤ z) (yw : y ≤ w) : (⟨x, y⟩ : ℤ√d) ≤ ⟨z, w⟩ :=\n  show nonneg ⟨z - x, w - y⟩, from\n  match z - x, w - y, int.le.dest_sub xz, int.le.dest_sub yw with ._, ._, ⟨a, rfl⟩, ⟨b, rfl⟩ := trivial end\n\n  theorem le_arch (a : ℤ√d) : ∃n : ℕ, a ≤ n :=\n  let ⟨x, y, (h : a ≤ ⟨x, y⟩)⟩ := show ∃x y : ℕ, nonneg (⟨x, y⟩ + -a), from match -a with\n  | ⟨int.of_nat x, int.of_nat y⟩ := ⟨0, 0, trivial⟩\n  | ⟨int.of_nat x, -[1+ y]⟩      := ⟨0, y+1, by simp [int.neg_succ_of_nat_coe]⟩\n  | ⟨-[1+ x],      int.of_nat y⟩ := ⟨x+1, 0, by simp [int.neg_succ_of_nat_coe]⟩\n  | ⟨-[1+ x],      -[1+ y]⟩      := ⟨x+1, y+1, by simp [int.neg_succ_of_nat_coe]⟩\n  end in begin\n    refine ⟨x + d*y, zsqrtd.le_trans h _⟩,\n    rw [← int.cast_coe_nat, ← of_int_eq_coe],\n    change nonneg ⟨(↑x + d*y) - ↑x, 0-↑y⟩,\n    cases y with y,\n    { simp },\n    have h : ∀y, sq_le y d (d * y) 1 := λ y,\n      by simpa [sq_le, mul_comm, mul_left_comm] using\n         nat.mul_le_mul_right (y * y) (nat.le_mul_self d),\n    rw [show (x:ℤ) + d * nat.succ y - x = d * nat.succ y, by simp],\n    exact h (y+1)\n  end\n\n  protected theorem nonneg_total : Π (a : ℤ√d), nonneg a ∨ nonneg (-a)\n  | ⟨(x : ℕ), (y : ℕ)⟩ := or.inl trivial\n  | ⟨-[1+ x], -[1+ y]⟩ := or.inr trivial\n  | ⟨0,       -[1+ y]⟩ := or.inr trivial\n  | ⟨-[1+ x], 0⟩       := or.inr trivial\n  | ⟨(x+1:ℕ), -[1+ y]⟩ := nat.le_total\n  | ⟨-[1+ x], (y+1:ℕ)⟩ := nat.le_total\n\n  protected theorem le_total (a b : ℤ√d) : a ≤ b ∨ b ≤ a :=\n  let t := nonneg_total (b - a) in by rw [show -(b-a) = a-b, from neg_sub b a] at t; exact t\n\n  instance : preorder ℤ√d :=\n  { le               := zsqrtd.le,\n    le_refl          := zsqrtd.le_refl,\n    le_trans         := @zsqrtd.le_trans,\n    lt               := zsqrtd.lt,\n    lt_iff_le_not_le := λ a b,\n      (and_iff_right_of_imp (zsqrtd.le_total _ _).resolve_left).symm }\n\n  protected theorem add_le_add_left (a b : ℤ√d) (ab : a ≤ b) (c : ℤ√d) : c + a ≤ c + b :=\n  show nonneg _, by rw add_sub_add_left_eq_sub; exact ab\n\n  protected theorem le_of_add_le_add_left (a b c : ℤ√d) (h : c + a ≤ c + b) : a ≤ b :=\n  by simpa using zsqrtd.add_le_add_left _ _ h (-c)\n\n  protected theorem add_lt_add_left (a b : ℤ√d) (h : a < b) (c) : c + a < c + b :=\n  λ h', h (zsqrtd.le_of_add_le_add_left _ _ _ h')\n\n  theorem nonneg_smul {a : ℤ√d} {n : ℕ} (ha : nonneg a) : nonneg (n * a) :=\n  by rw ← int.cast_coe_nat; exact match a, nonneg_cases ha, ha with\n  | ._, ⟨x, y, or.inl rfl⟩,          ha := by rw smul_val; trivial\n  | ._, ⟨x, y, or.inr $ or.inl rfl⟩, ha := by rw smul_val; simpa using\n    nonnegg_pos_neg.2 (sq_le_smul n $ nonnegg_pos_neg.1 ha)\n  | ._, ⟨x, y, or.inr $ or.inr rfl⟩, ha := by rw smul_val; simpa using\n    nonnegg_neg_pos.2 (sq_le_smul n $ nonnegg_neg_pos.1 ha)\n  end\n\n  theorem nonneg_muld {a : ℤ√d} (ha : nonneg a) : nonneg (sqrtd * a) :=\n  by refine match a, nonneg_cases ha, ha with\n  | ._, ⟨x, y, or.inl rfl⟩,          ha := trivial\n  | ._, ⟨x, y, or.inr $ or.inl rfl⟩, ha := by simp; apply nonnegg_neg_pos.2;\n    simpa [sq_le, mul_comm, mul_left_comm] using\n      nat.mul_le_mul_left d (nonnegg_pos_neg.1 ha)\n  | ._, ⟨x, y, or.inr $ or.inr rfl⟩, ha := by simp; apply nonnegg_pos_neg.2;\n    simpa [sq_le, mul_comm, mul_left_comm] using\n      nat.mul_le_mul_left d (nonnegg_neg_pos.1 ha)\n  end\n\n  theorem nonneg_mul_lem {x y : ℕ} {a : ℤ√d} (ha : nonneg a) : nonneg (⟨x, y⟩ * a) :=\n  have (⟨x, y⟩ * a : ℤ√d) = x * a + sqrtd * (y * a), by rw [decompose, right_distrib, mul_assoc]; refl,\n  by rw this; exact nonneg_add (nonneg_smul ha) (nonneg_muld $ nonneg_smul ha)\n\n  theorem nonneg_mul {a b : ℤ√d} (ha : nonneg a) (hb : nonneg b) : nonneg (a * b) :=\n  match a, b, nonneg_cases ha, nonneg_cases hb, ha, hb with\n  | ._, ._, ⟨x, y, or.inl rfl⟩,          ⟨z, w, or.inl rfl⟩,          ha, hb := trivial\n  | ._, ._, ⟨x, y, or.inl rfl⟩,          ⟨z, w, or.inr $ or.inr rfl⟩, ha, hb := nonneg_mul_lem hb\n  | ._, ._, ⟨x, y, or.inl rfl⟩,          ⟨z, w, or.inr $ or.inl rfl⟩, ha, hb := nonneg_mul_lem hb\n  | ._, ._, ⟨x, y, or.inr $ or.inr rfl⟩, ⟨z, w, or.inl rfl⟩,          ha, hb := by rw mul_comm; exact nonneg_mul_lem ha\n  | ._, ._, ⟨x, y, or.inr $ or.inl rfl⟩, ⟨z, w, or.inl rfl⟩,          ha, hb := by rw mul_comm; exact nonneg_mul_lem ha\n  | ._, ._, ⟨x, y, or.inr $ or.inr rfl⟩, ⟨z, w, or.inr $ or.inr rfl⟩, ha, hb :=\n    by rw [calc (⟨-x, y⟩ * ⟨-z, w⟩ : ℤ√d) = ⟨_, _⟩ : rfl\n        ... = ⟨x * z + d * y * w, -(x * w + y * z)⟩ : by simp]; exact\n    nonnegg_pos_neg.2 (sq_le_mul.left (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb))\n  | ._, ._, ⟨x, y, or.inr $ or.inr rfl⟩, ⟨z, w, or.inr $ or.inl rfl⟩, ha, hb :=\n    by rw [calc (⟨-x, y⟩ * ⟨z, -w⟩ : ℤ√d) = ⟨_, _⟩ : rfl\n        ... = ⟨-(x * z + d * y * w), x * w + y * z⟩ : by simp]; exact\n    nonnegg_neg_pos.2 (sq_le_mul.right.left (nonnegg_neg_pos.1 ha) (nonnegg_pos_neg.1 hb))\n  | ._, ._, ⟨x, y, or.inr $ or.inl rfl⟩, ⟨z, w, or.inr $ or.inr rfl⟩, ha, hb :=\n    by rw [calc (⟨x, -y⟩ * ⟨-z, w⟩ : ℤ√d) = ⟨_, _⟩ : rfl\n        ... = ⟨-(x * z + d * y * w), x * w + y * z⟩ : by simp]; exact\n    nonnegg_neg_pos.2 (sq_le_mul.right.right.left (nonnegg_pos_neg.1 ha) (nonnegg_neg_pos.1 hb))\n  | ._, ._, ⟨x, y, or.inr $ or.inl rfl⟩, ⟨z, w, or.inr $ or.inl rfl⟩, ha, hb :=\n    by rw [calc (⟨x, -y⟩ * ⟨z, -w⟩ : ℤ√d) = ⟨_, _⟩ : rfl\n        ... = ⟨x * z + d * y * w, -(x * w + y * z)⟩ : by simp]; exact\n    nonnegg_pos_neg.2 (sq_le_mul.right.right.right (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb))\n  end\n\n  protected theorem mul_nonneg (a b : ℤ√d) : 0 ≤ a → 0 ≤ b → 0 ≤ a * b :=\n  by repeat {rw ← nonneg_iff_zero_le}; exact nonneg_mul\n\n  theorem not_sq_le_succ (c d y) (h : c > 0) : ¬sq_le (y + 1) c 0 d :=\n  not_le_of_gt $ mul_pos (mul_pos h $ nat.succ_pos _) $ nat.succ_pos _\n\n  /-- A nonsquare is a natural number that is not equal to the square of an\n    integer. This is implemented as a typeclass because it's a necessary condition\n    for much of the Pell equation theory. -/\n  class nonsquare (x : ℕ) : Prop := (ns : ∀n : ℕ, x ≠ n*n)\n\n  parameter [dnsq : nonsquare d]\n  include dnsq\n\n  theorem d_pos : 0 < d := lt_of_le_of_ne (nat.zero_le _) $ ne.symm $ (nonsquare.ns d 0)\n\n  theorem divides_sq_eq_zero {x y} (h : x * x = d * y * y) : x = 0 ∧ y = 0 :=\n  let g := x.gcd y in or.elim g.eq_zero_or_pos\n    (λH, ⟨nat.eq_zero_of_gcd_eq_zero_left H, nat.eq_zero_of_gcd_eq_zero_right H⟩)\n    (λgpos, false.elim $\n      let ⟨m, n, co, (hx : x = m * g), (hy : y = n * g)⟩ := nat.exists_coprime gpos in\n      begin\n        rw [hx, hy] at h,\n        have : m * m = d * (n * n) := nat.eq_of_mul_eq_mul_left (mul_pos gpos gpos)\n          (by simpa [mul_comm, mul_left_comm] using h),\n        have co2 := let co1 := co.mul_right co in co1.mul co1,\n        exact nonsquare.ns d m (nat.dvd_antisymm (by rw this; apply dvd_mul_right) $\n          co2.dvd_of_dvd_mul_right $ by simp [this])\n      end)\n\n  theorem divides_sq_eq_zero_z {x y : ℤ} (h : x * x = d * y * y) : x = 0 ∧ y = 0 :=\n  by rw [mul_assoc, ← int.nat_abs_mul_self, ← int.nat_abs_mul_self, ← int.coe_nat_mul, ← mul_assoc] at h;\n  exact let ⟨h1, h2⟩ := divides_sq_eq_zero (int.coe_nat_inj h) in\n  ⟨int.eq_zero_of_nat_abs_eq_zero h1, int.eq_zero_of_nat_abs_eq_zero h2⟩\n\n  theorem not_divides_square (x y) : (x + 1) * (x + 1) ≠ d * (y + 1) * (y + 1) :=\n  λe, by have t := (divides_sq_eq_zero e).left; contradiction\n\n  theorem nonneg_antisymm : Π {a : ℤ√d}, nonneg a → nonneg (-a) → a = 0\n  | ⟨0,         0⟩         xy yx := rfl\n  | ⟨-[1+ x],   -[1+ y]⟩   xy yx := false.elim xy\n  | ⟨(x+1:nat), (y+1:nat)⟩ xy yx := false.elim yx\n  | ⟨-[1+ x],   0⟩         xy yx := absurd xy (not_sq_le_succ _ _ _ dec_trivial)\n  | ⟨(x+1:nat), 0⟩         xy yx := absurd yx (not_sq_le_succ _ _ _ dec_trivial)\n  | ⟨0,         -[1+ y]⟩   xy yx := absurd xy (not_sq_le_succ _ _ _ d_pos)\n  | ⟨0,         (y+1:nat)⟩ _  yx := absurd yx (not_sq_le_succ _ _ _ d_pos)\n  | ⟨(x+1:nat), -[1+ y]⟩   (xy : sq_le _ _ _ _) (yx : sq_le _ _ _ _) :=\n    let t := le_antisymm yx xy in by rw[one_mul] at t; exact absurd t (not_divides_square _ _)\n  | ⟨-[1+ x],   (y+1:nat)⟩ (xy : sq_le _ _ _ _) (yx : sq_le _ _ _ _) :=\n    let t := le_antisymm xy yx in by rw[one_mul] at t; exact absurd t (not_divides_square _ _)\n\n  theorem le_antisymm {a b : ℤ√d} (ab : a ≤ b) (ba : b ≤ a) : a = b :=\n  eq_of_sub_eq_zero $ nonneg_antisymm ba (by rw neg_sub; exact ab)\n\n  instance : decidable_linear_order ℤ√d :=\n  { le_antisymm     := @zsqrtd.le_antisymm,\n    le_total        := zsqrtd.le_total,\n    decidable_le    := zsqrtd.decidable_le,\n    ..zsqrtd.preorder }\n\n  protected theorem eq_zero_or_eq_zero_of_mul_eq_zero : Π {a b : ℤ√d}, a * b = 0 → a = 0 ∨ b = 0\n  | ⟨x, y⟩ ⟨z, w⟩ h := by injection h with h1 h2; exact\n    have h1 : x*z = -(d*y*w), from eq_neg_of_add_eq_zero h1,\n    have h2 : x*w = -(y*z), from eq_neg_of_add_eq_zero h2,\n    have fin : x*x = d*y*y → (⟨x, y⟩:ℤ√d) = 0, from\n    λe, match x, y, divides_sq_eq_zero_z e with ._, ._, ⟨rfl, rfl⟩ := rfl end,\n    if z0 : z = 0 then if w0 : w = 0 then\n      or.inr (match z, w, z0, w0 with ._, ._, rfl, rfl := rfl end)\n    else\n       or.inl $ fin $ eq_of_mul_eq_mul_right w0 $ calc\n         x * x * w = -y * (x * z) : by simp [h2, mul_assoc, mul_left_comm]\n               ... = d * y * y * w : by simp [h1, mul_assoc, mul_left_comm]\n    else\n       or.inl $ fin $ eq_of_mul_eq_mul_right z0 $ calc\n         x * x * z = d * -y * (x * w) : by simp [h1, mul_assoc, mul_left_comm]\n               ... = d * y * y * z : by simp [h2, mul_assoc, mul_left_comm]\n\n  instance : integral_domain ℤ√d :=\n  { zero_ne_one := zero_ne_one,\n    eq_zero_or_eq_zero_of_mul_eq_zero := @zsqrtd.eq_zero_or_eq_zero_of_mul_eq_zero,\n    ..zsqrtd.comm_ring }\n\n  protected theorem mul_pos (a b : ℤ√d) (a0 : 0 < a) (b0 : 0 < b) : 0 < a * b := λab,\n  or.elim (eq_zero_or_eq_zero_of_mul_eq_zero (le_antisymm ab (mul_nonneg _ _ (le_of_lt a0) (le_of_lt b0))))\n    (λe, ne_of_gt a0 e)\n    (λe, ne_of_gt b0 e)\n\n  instance : decidable_linear_ordered_comm_ring ℤ√d :=\n  { add_le_add_left := @zsqrtd.add_le_add_left,\n    add_lt_add_left := @zsqrtd.add_lt_add_left,\n    zero_ne_one     := zero_ne_one,\n    mul_nonneg      := @zsqrtd.mul_nonneg,\n    mul_pos         := @zsqrtd.mul_pos,\n    zero_lt_one     := dec_trivial,\n    ..zsqrtd.comm_ring, ..zsqrtd.decidable_linear_order }\n\n  instance : decidable_linear_ordered_semiring ℤ√d := by apply_instance\n  instance : linear_ordered_semiring ℤ√d           := by apply_instance\n  instance : ordered_semiring ℤ√d                  := by apply_instance\n\nend\nend zsqrtd\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/data/zsqrtd/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.497224379049118}}
{"text": "-- WIP: only 2 lemma2 to prove: AssocList.contains_exists, addSubSup.sub_sup\n\n-- Tested with: \n-- leanprover/lean4:nightly unchanged - Lean (version 4.0.0-nightly-2023-01-28, commit e37f209c1a2a, Release)\n\nimport Std.Data.AssocList\nimport Std.Data.List.Lemmas\nimport Std.Classes.BEq\n\nnamespace MWE10\n\ntheorem cond_eq_ite (c : Bool) (a b : α) : cond c a b = if c then a else b := by cases c <;> rfl\n\ntheorem cond_decide {α} (p : Prop) [Decidable p] (t e : α) : cond (decide p) t e = if p then t else e := by\n  by_cases p <;> simp [*]\n\n-- https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Problems.20simplifying.20.20conditions.20with.20hypotheses/near/324212540\n@[simp] theorem beq_eq_eq [DecidableEq α] (x y : α) :\n  (x == y) = decide (x = y) := rfl\n\nabbrev Strings := List String\n\ninstance : Repr (Std.AssocList String Strings) where reprPrec s n := s.toList.repr n\n\ndef addDecl (s: Std.AssocList String Strings) (d: String) : Std.AssocList String Strings :=\nmatch s.contains d with\n| true => s\n| false => .cons d [] s\n\ntheorem addDecl.added (s: Std.AssocList String Strings) (d: String): (addDecl s d).contains d\n:= by\n  simp [addDecl]\n  split <;> simp\n  next x heq => simp_all\n\ntheorem addDecl.cons (s: Std.AssocList String Strings) (d: String): (addDecl s d).isEmpty = false\n:= by\n  simp [addDecl]\n  split <;> simp [List.isEmpty]\n  . case h_1 x heq =>\n    split <;> simp_all\n\ntheorem addDecl.after (s: Std.AssocList String Strings) (x y: String): s.contains x → (addDecl s y).contains x\n:= by\n  intro h\n  simp [Std.AssocList.contains, addDecl] at h ⊢\n  apply Exists.elim h\n  split <;> simp_all\n  done\n\ndef addSubSup: String → String → Std.AssocList String Strings → Std.AssocList String Strings\n| sub, sup, .nil            => .cons sub [sup] .nil\n| sub, sup, .cons a as tail => bif a = sub then .cons sub (as.insert sup) tail else .cons a as (addSubSup sub sup tail)\n  \n@[simp] theorem addSubSup.sub (sub sup: String) (ss: Std.AssocList String Strings): (addSubSup sub sup ss).contains sub\n:= by\n  induction ss <;> simp_all\n  . case cons key value tail tail_ih =>\n    simp [addSubSup, cond_eq_ite]\n    by_cases key = sub\n    . case pos h =>\n      simp [h]\n    . case neg h =>\n      simp [h]\n      apply tail_ih\n\n@[simp] theorem addSubSup.exists.sub (sub sup: String) (tail: Std.AssocList String Strings)\n: ∃ x, x ∈ Std.AssocList.toList (addSubSup sub sup tail) ∧ x.fst = sub\n:= by\n  induction tail <;> simp_all\n  . case cons key value t ih =>\n    simp [addSubSup, cond_eq_ite]\n    by_cases key = sub\n    . case pos h =>\n      simp [h]\n    . case neg h =>\n      simp [h]\n      apply ih\n\ndef addBoth (sub sup: String) (ss: Std.AssocList String Strings) : Std.AssocList String Strings :=\n  let ss' := addDecl ss sup\n  addSubSup sub sup ss'\n\n@[simp] theorem addSubSup.cons\n  (sub sup: String) \n  (tail: Std.AssocList String Strings)\n  (h: ∃ x, x ∈ Std.AssocList.toList (addSubSup sub sup tail) ∧ x.fst = sup)\n: ∃ x, x ∈ Std.AssocList.toList (addSubSup sub sup (Std.AssocList.cons sup [] (Std.AssocList.cons key value tail))) ∧ x.fst = sup\n:= by\n  simp [addSubSup, cond_eq_ite]\n  by_cases sup = sub <;> simp_all\n\n@[simp] theorem addSubSup.cons2\n  (sub sup: String) \n  (tail: Std.AssocList String Strings)\n  (h: ∃ x, x ∈ Std.AssocList.toList (addSubSup sub sup (Std.AssocList.cons sup [] tail)) ∧ x.fst = sup)\n: ∃ x, x ∈ Std.AssocList.toList (addSubSup sub sup (Std.AssocList.cons sup [] (Std.AssocList.cons key value tail))) ∧ x.fst = sup\n:= by\n  simp [addSubSup, cond_eq_ite]\n  by_cases sup = sub <;> simp_all\n\ntheorem addBoth.sub_eq (sub sup: String) (ss: Std.AssocList String Strings) \n: (addBoth sub sup ss).contains sub\n:= by\n  induction ss <;> simp_all\n  . case nil =>\n    simp [addBoth, addDecl, addSubSup, cond_eq_ite]\n    split <;> simp_all\n  . case cons =>\n    simp [addBoth, addDecl]\n\n@[simp] theorem AssocList.contains_exists\n  (s: Std.AssocList String Strings)\n  (x: String)\n  (h: s.contains x)\n: ∃ a, a ∈ Std.AssocList.toList s ∧ a.fst = x\n:= by\n  sorry\n\n@[simp] theorem addSubSup.sub_sup\n  (sub sup: String) \n  (tail: Std.AssocList String Strings)\n  (h: ∃ x, x ∈ Std.AssocList.toList tail ∧ x.fst = sup)\n: ∃ x, x ∈ Std.AssocList.toList (addSubSup sub sup tail) ∧ x.fst = sup\n:= by\n  sorry\n\ntheorem addBoth.sup_eq2 (sub sup: String) (ss: Std.AssocList String Strings) \n: (addBoth sub sup ss).contains sup\n:= by\n  rw [addBoth]\n  let ss' := addDecl ss sup\n  have h1: ss'.contains sup := addDecl.added ss sup\n  have h2: ∃ x, x ∈ Std.AssocList.toList ss' ∧ x.fst = sup := by\n    exact AssocList.contains_exists ss' sup h1\n  simp_all\n\nend MWE10", "meta": {"author": "NicolasRouquette", "repo": "oml.lean4", "sha": "a60689536837a52fe21595d79877063f28ec7cfc", "save_path": "github-repos/lean/NicolasRouquette-oml.lean4", "path": "github-repos/lean/NicolasRouquette-oml.lean4/oml.lean4-a60689536837a52fe21595d79877063f28ec7cfc/src/Oml/MWE10.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4972243749721245}}
{"text": "declare_syntax_cat foo\n\nvariable {m : Type → Type}\nvariable [s : Functor m]\n\n#check @Nat.rec\n\n#check s.map\n\n/-\nThe following doesn't work because\n```\nvariable [r : Monad m]\n#check r.map\n```\nbecause `Monad.to* methods have bad binder annotations\n-/\n\ntheorem aux (a b c : Nat) (h₁ : a = b) (h₂ : c = b) : a = c := by\n  have aux := h₂.symm\n  subst aux\n  subst h₁\n  exact rfl\n\n\ndef ex1 : {α : Type} → {a b c : α} → a = b → b = c → a = c :=\n  @(by intro α a b c h₁ h₂\n       exact Eq.trans h₁ h₂)\n\ndef f1 (x : Nat) : Nat := by\n  apply (· + ?hole)\n  exact 1\n  case hole => exact x\n\ntheorem ex2 (x : Nat) : f1 x = 1 + x :=\nrfl\n\ndef f2 (x : Nat) : Nat := by\n  apply Nat.add _\n  exact 1\n  exact x\n\ntheorem ex3 (x : Nat) : f2 x = x + 1 :=\n  rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/new_frontend2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.49722437089513105}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport topology.constructions\nimport topology.algebra.monoid\n/-!\n# Topology on lists and vectors\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n-/\nopen topological_space set filter\nopen_locale topology filter\n\nvariables {α : Type*} {β : Type*} [topological_space α] [topological_space β]\n\ninstance : topological_space (list α) :=\ntopological_space.mk_of_nhds (traverse nhds)\n\nlemma nhds_list (as : list α) : 𝓝 as = traverse 𝓝 as :=\nbegin\n  refine nhds_mk_of_nhds _ _ _ _,\n  { assume l, induction l,\n    case list.nil { exact le_rfl },\n    case list.cons : a l ih\n    { suffices : list.cons <$> pure a <*> pure l ≤ list.cons <$> 𝓝 a <*> traverse 𝓝 l,\n      { simpa only [] with functor_norm using this },\n      exact filter.seq_mono (filter.map_mono $ pure_le_nhds a) ih } },\n  { assume l s hs,\n    rcases (mem_traverse_iff _ _).1 hs with ⟨u, hu, hus⟩, clear as hs,\n    have : ∃v:list (set α), l.forall₂ (λa s, is_open s ∧ a ∈ s) v ∧ sequence v ⊆ s,\n    { induction hu generalizing s,\n      case list.forall₂.nil : hs this\n        { existsi [], simpa only [list.forall₂_nil_left_iff, exists_eq_left] },\n      case list.forall₂.cons : a s as ss ht h ih t hts\n      { rcases mem_nhds_iff.1 ht with ⟨u, hut, hu⟩,\n        rcases ih _ subset.rfl with ⟨v, hv, hvss⟩,\n        exact ⟨u::v, list.forall₂.cons hu hv,\n          subset.trans (set.seq_mono (set.image_subset _ hut) hvss) hts⟩ } },\n    rcases this with ⟨v, hv, hvs⟩,\n    refine ⟨sequence v, mem_traverse _ _ _, hvs, _⟩,\n    { exact hv.imp (assume a s ⟨hs, ha⟩, is_open.mem_nhds hs ha) },\n    { assume u hu,\n      have hu := (list.mem_traverse _ _).1 hu,\n      have : list.forall₂ (λa s, is_open s ∧ a ∈ s) u v,\n      { refine list.forall₂.flip _,\n        replace hv := hv.flip,\n        simp only [list.forall₂_and_left, flip] at ⊢ hv,\n        exact ⟨hv.1, hu.flip⟩ },\n      refine mem_of_superset _ hvs,\n      exact mem_traverse _ _ (this.imp $ assume a s ⟨hs, ha⟩, is_open.mem_nhds hs ha) } }\nend\n\n@[simp] lemma nhds_nil : 𝓝 ([] : list α) = pure [] :=\nby rw [nhds_list, list.traverse_nil _]; apply_instance\n\nlemma nhds_cons (a : α) (l : list α) :\n  𝓝 (a :: l) = list.cons <$> 𝓝 a <*> 𝓝 l  :=\nby rw [nhds_list, list.traverse_cons _, ← nhds_list]; apply_instance\n\nlemma list.tendsto_cons {a : α} {l : list α} :\n  tendsto (λp:α×list α, list.cons p.1 p.2) (𝓝 a ×ᶠ 𝓝 l) (𝓝 (a :: l)) :=\nby rw [nhds_cons, tendsto, filter.map_prod]; exact le_rfl\n\nlemma filter.tendsto.cons {α : Type*} {f : α → β} {g : α → list β}\n  {a : _root_.filter α} {b : β} {l : list β} (hf : tendsto f a (𝓝 b)) (hg : tendsto g a (𝓝 l)) :\n  tendsto (λa, list.cons (f a) (g a)) a (𝓝 (b :: l)) :=\nlist.tendsto_cons.comp (tendsto.prod_mk hf hg)\n\nnamespace list\n\nlemma tendsto_cons_iff {β : Type*} {f : list α → β} {b : _root_.filter β} {a : α} {l : list α} :\n  tendsto f (𝓝 (a :: l)) b ↔ tendsto (λp:α×list α, f (p.1 :: p.2)) (𝓝 a ×ᶠ 𝓝 l) b :=\nhave 𝓝 (a :: l) = (𝓝 a ×ᶠ 𝓝 l).map (λp:α×list α, (p.1 :: p.2)),\nbegin\n  simp only\n    [nhds_cons, filter.prod_eq, (filter.map_def _ _).symm, (filter.seq_eq_filter_seq _ _).symm],\n  simp [-filter.seq_eq_filter_seq, -filter.map_def, (∘)] with functor_norm,\nend,\nby rw [this, filter.tendsto_map'_iff]\n\nlemma continuous_cons : continuous (λ x : α × list α, (x.1 :: x.2 : list α)) :=\ncontinuous_iff_continuous_at.mpr $ λ ⟨x, y⟩, continuous_at_fst.cons continuous_at_snd\n\nlemma tendsto_nhds {β : Type*} {f : list α → β} {r : list α → _root_.filter β}\n  (h_nil : tendsto f (pure []) (r []))\n  (h_cons : ∀l a, tendsto f (𝓝 l) (r l) →\n    tendsto (λp:α×list α, f (p.1 :: p.2)) (𝓝 a ×ᶠ 𝓝 l) (r (a::l))) :\n  ∀l, tendsto f (𝓝 l) (r l)\n| []     := by rwa [nhds_nil]\n| (a::l) := by rw [tendsto_cons_iff]; exact h_cons l a (tendsto_nhds l)\n\nlemma continuous_at_length :\n  ∀(l : list α), continuous_at list.length l :=\nbegin\n  simp only [continuous_at, nhds_discrete],\n  refine tendsto_nhds _ _,\n  { exact tendsto_pure_pure _ _ },\n  { assume l a ih,\n    dsimp only [list.length],\n    refine tendsto.comp (tendsto_pure_pure (λx, x + 1) _) _,\n    refine tendsto.comp ih tendsto_snd }\nend\n\nlemma tendsto_insert_nth' {a : α} : ∀{n : ℕ} {l : list α},\n  tendsto (λp:α×list α, insert_nth n p.1 p.2) (𝓝 a ×ᶠ 𝓝 l) (𝓝 (insert_nth n a l))\n| 0     l  := tendsto_cons\n| (n+1) [] := by simp\n| (n+1) (a'::l) :=\n  have 𝓝 a ×ᶠ 𝓝 (a' :: l) =\n    (𝓝 a ×ᶠ (𝓝 a' ×ᶠ 𝓝 l)).map (λp:α×α×list α, (p.1, p.2.1 :: p.2.2)),\n  begin\n    simp only [nhds_cons, filter.prod_eq, ← filter.map_def, ← filter.seq_eq_filter_seq],\n    simp [-filter.seq_eq_filter_seq, -filter.map_def, (∘)] with functor_norm\n  end,\n  begin\n    rw [this, tendsto_map'_iff],\n    exact (tendsto_fst.comp tendsto_snd).cons\n      ((@tendsto_insert_nth' n l).comp $ tendsto_fst.prod_mk $ tendsto_snd.comp tendsto_snd)\n  end\n\nlemma tendsto_insert_nth {β} {n : ℕ} {a : α} {l : list α} {f : β → α} {g : β → list α}\n  {b : _root_.filter β} (hf : tendsto f b (𝓝 a)) (hg : tendsto g b (𝓝 l)) :\n  tendsto (λb:β, insert_nth n (f b) (g b)) b (𝓝 (insert_nth n a l)) :=\ntendsto_insert_nth'.comp (tendsto.prod_mk hf hg)\n\nlemma continuous_insert_nth {n : ℕ} : continuous (λp:α×list α, insert_nth n p.1 p.2) :=\ncontinuous_iff_continuous_at.mpr $\n  assume ⟨a, l⟩, by rw [continuous_at, nhds_prod_eq]; exact tendsto_insert_nth'\n\nlemma tendsto_remove_nth : ∀{n : ℕ} {l : list α},\n  tendsto (λl, remove_nth l n) (𝓝 l) (𝓝 (remove_nth l n))\n| _ []      := by rw [nhds_nil]; exact tendsto_pure_nhds _ _\n| 0 (a::l) := by rw [tendsto_cons_iff]; exact tendsto_snd\n| (n+1) (a::l) :=\n  begin\n    rw [tendsto_cons_iff],\n    dsimp [remove_nth],\n    exact tendsto_fst.cons ((@tendsto_remove_nth n l).comp tendsto_snd)\n  end\n\nlemma continuous_remove_nth {n : ℕ} : continuous (λl : list α, remove_nth l n) :=\ncontinuous_iff_continuous_at.mpr $ assume a, tendsto_remove_nth\n\n@[to_additive]\nlemma tendsto_prod [monoid α] [has_continuous_mul α] {l : list α} :\n  tendsto list.prod (𝓝 l) (𝓝 l.prod) :=\nbegin\n  induction l with x l ih,\n  { simp [nhds_nil, mem_of_mem_nhds, tendsto_pure_left] {contextual := tt} },\n  simp_rw [tendsto_cons_iff, prod_cons],\n  have := continuous_iff_continuous_at.mp continuous_mul (x, l.prod),\n  rw [continuous_at, nhds_prod_eq] at this,\n  exact this.comp (tendsto_id.prod_map ih)\nend\n\n@[to_additive]\nlemma continuous_prod [monoid α] [has_continuous_mul α] : continuous (prod : list α → α) :=\ncontinuous_iff_continuous_at.mpr $ λ l, tendsto_prod\n\nend list\n\nnamespace vector\nopen list\n\ninstance (n : ℕ) : topological_space (vector α n) :=\nby unfold vector; apply_instance\n\n\n\nlemma tendsto_insert_nth\n  {n : ℕ} {i : fin (n+1)} {a:α} :\n  ∀{l:vector α n}, tendsto (λp:α×vector α n, insert_nth p.1 i p.2)\n    (𝓝 a ×ᶠ 𝓝 l) (𝓝 (insert_nth a i l))\n| ⟨l, hl⟩ :=\nbegin\n  rw [insert_nth, tendsto_subtype_rng],\n  simp [insert_nth_val],\n  exact list.tendsto_insert_nth tendsto_fst (tendsto.comp continuous_at_subtype_coe tendsto_snd : _)\nend\n\nlemma continuous_insert_nth' {n : ℕ} {i : fin (n+1)} :\n  continuous (λp:α×vector α n, insert_nth p.1 i p.2) :=\ncontinuous_iff_continuous_at.mpr $ assume ⟨a, l⟩,\n  by rw [continuous_at, nhds_prod_eq]; exact tendsto_insert_nth\n\nlemma continuous_insert_nth {n : ℕ} {i : fin (n+1)}\n  {f : β → α} {g : β → vector α n} (hf : continuous f) (hg : continuous g) :\n  continuous (λb, insert_nth (f b) i (g b)) :=\ncontinuous_insert_nth'.comp (hf.prod_mk hg : _)\n\nlemma continuous_at_remove_nth {n : ℕ} {i : fin (n+1)} :\n  ∀{l:vector α (n+1)}, continuous_at (remove_nth i) l\n| ⟨l, hl⟩ :=\n--  ∀{l:vector α (n+1)}, tendsto (remove_nth i) (𝓝 l) (𝓝 (remove_nth i l))\n--| ⟨l, hl⟩ :=\nbegin\n  rw [continuous_at, remove_nth, tendsto_subtype_rng],\n  simp only [← subtype.val_eq_coe, vector.remove_nth_val],\n  exact tendsto.comp list.tendsto_remove_nth continuous_at_subtype_coe,\nend\n\nlemma continuous_remove_nth {n : ℕ} {i : fin (n+1)} :\n  continuous (remove_nth i : vector α (n+1) → vector α n) :=\ncontinuous_iff_continuous_at.mpr $ assume ⟨a, l⟩, continuous_at_remove_nth\n\nend vector\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/list.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.7248702761768249, "lm_q1q2_score": 0.497224361587652}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.set.lattice\n\n/-!\n# A model of ZFC\n\nIn this file, we model Zermelo-Fraenkel set theory (+ Choice) using Lean's underlying type theory.\nWe do this in four main steps:\n* Define pre-sets inductively.\n* Define extensional equivalence on pre-sets and give it a `setoid` instance.\n* Define ZFC sets by quotienting pre-sets by extensional equivalence.\n* Define classes as sets of ZFC sets.\nThen the rest is usual set theory.\n\n## The model\n\n* `pSet`: Pre-set. A pre-set is inductively defined by its indexing type and its members, which are\n  themselves pre-sets.\n* `Set`: ZFC set. Defined as `pSet` quotiented by `pSet.equiv`, the extensional equivalence.\n* `Class`: Class. Defined as `set Set`.\n* `Set.choice`: Axiom of choice. Proved from Lean's axiom of choice.\n\n## Other definitions\n\n* `arity α n`: `n`-ary function `α → α → ... → α`. Defined inductively.\n* `arity.const a n`: `n`-ary constant function equal to `a`.\n* `pSet.type`: Underlying type of a pre-set.\n* `pSet.func`: Underlying family of pre-sets of a pre-set.\n* `pSet.equiv`: Extensional equivalence of pre-sets. Defined inductively.\n* `pSet.omega`, `Set.omega`: The von Neumann ordinal `ω` as a `pSet`, as a `Set`.\n* `pSet.arity.equiv`: Extensional equivalence of `n`-ary `pSet`-valued functions. Extension of\n  `pSet.equiv`.\n* `pSet.resp`: Collection of `n`-ary `pSet`-valued functions that respect extensional equivalence.\n* `pSet.eval`: Turns a `pSet`-valued function that respect extensional equivalence into a\n  `Set`-valued function.\n* `classical.all_definable`: All functions are classically definable.\n* `Set.is_func` : Predicate that a ZFC set is a subset of `x × y` that can be considered as a ZFC\n  function `x → y`. That is, each member of `x` is related by the ZFC set to exactly one member of\n  `y`.\n* `Set.funs`: ZFC set of ZFC functions `x → y`.\n* `Class.iota`: Definite description operator.\n\n## Notes\n\nTo avoid confusion between the Lean `set` and the ZFC `Set`, docstrings in this file refer to them\nrespectively as \"`set`\" and \"ZFC set\".\n\n## TODO\n\nProve `Set.map_definable_aux` computably.\n-/\n\nuniverses u v\n\n/-- The type of `n`-ary functions `α → α → ... → α`. -/\ndef arity (α : Type u) : ℕ → Type u\n| 0     := α\n| (n+1) := α → arity n\n\nnamespace arity\n\n/-- Constant `n`-ary function with value `a`. -/\ndef const {α : Type u} (a : α) : ∀ n, arity α n\n| 0     := a\n| (n+1) := λ _, const n\n\ninstance arity.inhabited {α n} [inhabited α] : inhabited (arity α n) :=\n⟨const default _⟩\n\nend arity\n\n/-- The type of pre-sets in universe `u`. A pre-set\n  is a family of pre-sets indexed by a type in `Type u`.\n  The ZFC universe is defined as a quotient of this\n  to ensure extensionality. -/\ninductive pSet : Type (u+1)\n| mk (α : Type u) (A : α → pSet) : pSet\n\nnamespace pSet\n\n/-- The underlying type of a pre-set -/\n@[nolint has_inhabited_instance] def type : pSet → Type u\n| ⟨α, A⟩ := α\n\n/-- The underlying pre-set family of a pre-set -/\ndef func : Π (x : pSet), x.type → pSet\n| ⟨α, A⟩ := A\n\ntheorem mk_type_func : Π (x : pSet), mk x.type x.func = x\n| ⟨α, A⟩ := rfl\n\n/-- Two pre-sets are extensionally equivalent if every element of the first family is extensionally\nequivalent to some element of the second family and vice-versa. -/\ndef equiv (x y : pSet) : Prop :=\npSet.rec (λ α z m ⟨β, B⟩, (∀ a, ∃ b, m a (B b)) ∧ (∀ b, ∃ a, m a (B b))) x y\n\ntheorem equiv.refl (x) : equiv x x :=\npSet.rec_on x $ λ α A IH, ⟨λ a, ⟨a, IH a⟩, λ a, ⟨a, IH a⟩⟩\n\ntheorem equiv.rfl : ∀ {x}, equiv x x := equiv.refl\n\ntheorem equiv.euc {x} : Π {y z}, equiv x y → equiv z y → equiv x z :=\npSet.rec_on x $ λ α A IH y, pSet.cases_on y $ λ β B ⟨γ, Γ⟩ ⟨αβ, βα⟩ ⟨γβ, βγ⟩,\n⟨λ a, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, IH a ab bc⟩,\n  λ c, let ⟨b, cb⟩ := γβ c, ⟨a, ba⟩ := βα b in ⟨a, IH a ba cb⟩⟩\n\ntheorem equiv.symm {x y} : equiv x y → equiv y x :=\n(equiv.refl y).euc\n\ntheorem equiv.trans {x y z} (h1 : equiv x y) (h2 : equiv y z) : equiv x z :=\nh1.euc h2.symm\n\ninstance setoid : setoid pSet :=\n⟨pSet.equiv, equiv.refl, λ x y, equiv.symm, λ x y z, equiv.trans⟩\n\n/-- A pre-set is a subset of another pre-set if every element of the first family is extensionally\nequivalent to some element of the second family.-/\nprotected def subset : pSet → pSet → Prop\n| ⟨α, A⟩ ⟨β, B⟩ := ∀ a, ∃ b, equiv (A a) (B b)\n\ninstance : has_subset pSet := ⟨pSet.subset⟩\n\ntheorem equiv.ext : Π (x y : pSet), equiv x y ↔ (x ⊆ y ∧ y ⊆ x)\n| ⟨α, A⟩ ⟨β, B⟩ :=\n  ⟨λ ⟨αβ, βα⟩, ⟨αβ, λ b, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩,\n    λ ⟨αβ, βα⟩, ⟨αβ, λ b, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩⟩\n\ntheorem subset.congr_left : Π {x y z : pSet}, equiv x y → (x ⊆ z ↔ y ⊆ z)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=\n  ⟨λ αγ b, let ⟨a, ba⟩ := βα b, ⟨c, ac⟩ := αγ a in ⟨c, (equiv.symm ba).trans ac⟩,\n    λ βγ a, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, equiv.trans ab bc⟩⟩\n\ntheorem subset.congr_right : Π {x y z : pSet}, equiv x y → (z ⊆ x ↔ z ⊆ y)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=\n  ⟨λ γα c, let ⟨a, ca⟩ := γα c, ⟨b, ab⟩ := αβ a in ⟨b, ca.trans ab⟩,\n    λ γβ c, let ⟨b, cb⟩ := γβ c, ⟨a, ab⟩ := βα b in ⟨a, cb.trans (equiv.symm ab)⟩⟩\n\n/-- `x ∈ y` as pre-sets if `x` is extensionally equivalent to a member of the family `y`. -/\ndef mem : pSet → pSet → Prop\n| x ⟨β, B⟩ := ∃ b, equiv x (B b)\ninstance : has_mem pSet.{u} pSet.{u} := ⟨mem⟩\n\ntheorem mem.mk {α: Type u} (A : α → pSet) (a : α) : A a ∈ mk α A :=\n⟨a, equiv.refl (A a)⟩\n\ntheorem mem.ext : Π {x y : pSet.{u}}, (∀ w : pSet.{u}, w ∈ x ↔ w ∈ y) → equiv x y\n| ⟨α, A⟩ ⟨β, B⟩ h := ⟨λ a, (h (A a)).1 (mem.mk A a),\n    λ b, let ⟨a, ha⟩ := (h (B b)).2 (mem.mk B b) in ⟨a, ha.symm⟩⟩\n\ntheorem mem.congr_right : Π {x y : pSet.{u}}, equiv x y → (∀ {w : pSet.{u}}, w ∈ x ↔ w ∈ y)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩ w :=\n  ⟨λ ⟨a, ha⟩, let ⟨b, hb⟩ := αβ a in ⟨b, ha.trans hb⟩,\n    λ ⟨b, hb⟩, let ⟨a, ha⟩ := βα b in ⟨a, hb.euc ha⟩⟩\n\ntheorem equiv_iff_mem {x y : pSet.{u}} : equiv x y ↔ (∀ {w : pSet.{u}}, w ∈ x ↔ w ∈ y) :=\n⟨mem.congr_right, match x, y with\n| ⟨α, A⟩, ⟨β, B⟩, h := ⟨λ a, h.1 (mem.mk A a), λ b,\n  let ⟨a, h⟩ := h.2 (mem.mk B b) in ⟨a, h.symm⟩⟩\nend⟩\n\ntheorem mem.congr_left : Π {x y : pSet.{u}}, equiv x y → (∀ {w : pSet.{u}}, x ∈ w ↔ y ∈ w)\n| x y h ⟨α, A⟩ := ⟨λ ⟨a, ha⟩, ⟨a, h.symm.trans ha⟩, λ ⟨a, ha⟩, ⟨a, h.trans ha⟩⟩\n\n/-- Convert a pre-set to a `set` of pre-sets. -/\ndef to_set (u : pSet.{u}) : set pSet.{u} := {x | x ∈ u}\n\n/-- Two pre-sets are equivalent iff they have the same members. -/\ntheorem equiv.eq {x y : pSet} : equiv x y ↔ to_set x = to_set y :=\nequiv_iff_mem.trans set.ext_iff.symm\n\ninstance : has_coe pSet (set pSet) := ⟨to_set⟩\n\n/-- The empty pre-set -/\nprotected def empty : pSet := ⟨ulift empty, λ e, match e with end⟩\n\ninstance : has_emptyc pSet := ⟨pSet.empty⟩\n\ninstance : inhabited pSet := ⟨∅⟩\n\ntheorem mem_empty (x : pSet.{u}) : x ∉ (∅ : pSet.{u}) := λ e, match e with end\n\n/-- Insert an element into a pre-set -/\nprotected def insert : pSet → pSet → pSet\n| u ⟨α, A⟩ := ⟨option α, λ o, option.rec u A o⟩\n\ninstance : has_insert pSet pSet := ⟨pSet.insert⟩\n\ninstance : has_singleton pSet pSet := ⟨λ s, insert s ∅⟩\n\ninstance : is_lawful_singleton pSet pSet := ⟨λ _, rfl⟩\n\n/-- The n-th von Neumann ordinal -/\ndef of_nat : ℕ → pSet\n| 0     := ∅\n| (n+1) := pSet.insert (of_nat n) (of_nat n)\n\n/-- The von Neumann ordinal ω -/\ndef omega : pSet := ⟨ulift ℕ, λ n, of_nat n.down⟩\n\n/-- The pre-set separation operation `{x ∈ a | p x}` -/\nprotected def sep (p : set pSet) : pSet → pSet\n| ⟨α, A⟩ := ⟨{a // p (A a)}, λ x, A x.1⟩\n\ninstance : has_sep pSet pSet := ⟨pSet.sep⟩\n\n/-- The pre-set powerset operator -/\ndef powerset : pSet → pSet\n| ⟨α, A⟩ := ⟨set α, λ p, ⟨{a // p a}, λ x, A x.1⟩⟩\n\ntheorem mem_powerset : Π {x y : pSet}, y ∈ powerset x ↔ y ⊆ x\n| ⟨α, A⟩ ⟨β, B⟩ := ⟨λ ⟨p, e⟩, (subset.congr_left e).2 $ λ ⟨a, pa⟩, ⟨a, equiv.refl (A a)⟩,\n  λ βα, ⟨{a | ∃ b, equiv (B b) (A a)}, λ b, let ⟨a, ba⟩ := βα b in ⟨⟨a, b, ba⟩, ba⟩,\n    λ ⟨a, b, ba⟩, ⟨b, ba⟩⟩⟩\n\n/-- The pre-set union operator -/\ndef Union : pSet → pSet\n| ⟨α, A⟩ := ⟨Σx, (A x).type, λ ⟨x, y⟩, (A x).func y⟩\n\ntheorem mem_Union : Π {x y : pSet.{u}}, y ∈ Union x ↔ ∃ z : pSet.{u}, ∃ _ : z ∈ x, y ∈ z\n| ⟨α, A⟩ y :=\n  ⟨λ ⟨⟨a, c⟩, (e : equiv y ((A a).func c))⟩,\n    have func (A a) c ∈ mk (A a).type (A a).func, from mem.mk (A a).func c,\n    ⟨_, mem.mk _ _, (mem.congr_left e).2 (by rwa mk_type_func at this)⟩,\n  λ ⟨⟨β, B⟩, ⟨a, (e : equiv (mk β B) (A a))⟩, ⟨b, yb⟩⟩,\n    by { rw ←(mk_type_func (A a)) at e, exact\n    let ⟨βt, tβ⟩ := e, ⟨c, bc⟩ := βt b in ⟨⟨a, c⟩, yb.trans bc⟩ }⟩\n\n/-- The image of a function from pre-sets to pre-sets. -/\ndef image (f : pSet.{u} → pSet.{u}) : pSet.{u} → pSet\n| ⟨α, A⟩ := ⟨α, λ a, f (A a)⟩\n\ntheorem mem_image {f : pSet.{u} → pSet.{u}} (H : ∀ {x y}, equiv x y → equiv (f x) (f y)) :\n  Π {x y : pSet.{u}}, y ∈ image f x ↔ ∃ z ∈ x, equiv y (f z)\n| ⟨α, A⟩ y := ⟨λ ⟨a, ya⟩, ⟨A a, mem.mk A a, ya⟩, λ ⟨z, ⟨a, za⟩, yz⟩, ⟨a, yz.trans (H za)⟩⟩\n\n/-- Universe lift operation -/\nprotected def lift : pSet.{u} → pSet.{max u v}\n| ⟨α, A⟩ := ⟨ulift α, λ ⟨x⟩, lift (A x)⟩\n\n/-- Embedding of one universe in another -/\n@[nolint check_univs] -- intended to be used with explicit universe parameters\ndef embed : pSet.{max (u+1) v} := ⟨ulift.{v u+1} pSet, λ ⟨x⟩, pSet.lift.{u (max (u+1) v)} x⟩\n\ntheorem lift_mem_embed : Π (x : pSet.{u}), pSet.lift.{u (max (u+1) v)} x ∈ embed.{u v} :=\nλ x, ⟨⟨x⟩, equiv.rfl⟩\n\n/-- Function equivalence is defined so that `f ~ g` iff `∀ x y, x ~ y → f x ~ g y`. This extends to\nequivalence of `n`-ary functions. -/\ndef arity.equiv : Π {n}, arity pSet.{u} n → arity pSet.{u} n → Prop\n| 0     a b := equiv a b\n| (n+1) a b := ∀ x y, equiv x y → arity.equiv (a x) (b y)\n\nlemma arity.equiv_const {a : pSet.{u}} : ∀ n, arity.equiv (arity.const a n) (arity.const a n)\n| 0 := equiv.rfl\n| (n+1) := λ x y h, arity.equiv_const _\n\n/-- `resp n` is the collection of n-ary functions on `pSet` that respect\n  equivalence, i.e. when the inputs are equivalent the output is as well. -/\ndef resp (n) := {x : arity pSet.{u} n // arity.equiv x x}\n\ninstance resp.inhabited {n} : inhabited (resp n) :=\n⟨⟨arity.const default _, arity.equiv_const _⟩⟩\n\n/-- The `n`-ary image of a `(n + 1)`-ary function respecting equivalence as a function respecting\nequivalence. -/\ndef resp.f {n} (f : resp (n+1)) (x : pSet) : resp n :=\n⟨f.1 x, f.2 _ _ $ equiv.refl x⟩\n\n/-- Function equivalence for functions respecting equivalence. See `pSet.arity.equiv`. -/\ndef resp.equiv {n} (a b : resp n) : Prop := arity.equiv a.1 b.1\n\ntheorem resp.refl {n} (a : resp n) : resp.equiv a a := a.2\n\ntheorem resp.euc : Π {n} {a b c : resp n}, resp.equiv a b → resp.equiv c b → resp.equiv a c\n| 0     a b c hab hcb := hab.euc hcb\n| (n+1) a b c hab hcb := λ x y h,\n  @resp.euc n (a.f x) (b.f y) (c.f y) (hab _ _ h) (hcb _ _ $ equiv.refl y)\n\ninstance resp.setoid {n} : setoid (resp n) :=\n⟨resp.equiv, resp.refl, λ x y h, resp.euc (resp.refl y) h,\n  λ x y z h1 h2, resp.euc h1 $ resp.euc (resp.refl z) h2⟩\n\nend pSet\n\n/-- The ZFC universe of sets consists of the type of pre-sets,\n  quotiented by extensional equivalence. -/\ndef Set : Type (u+1) := quotient pSet.setoid.{u}\n\nnamespace pSet\n\nnamespace resp\n\n/-- Helper function for `pSet.eval`. -/\ndef eval_aux : Π {n}, {f : resp n → arity Set.{u} n // ∀ (a b : resp n), resp.equiv a b → f a = f b}\n| 0     := ⟨λ a, ⟦a.1⟧, λ a b h, quotient.sound h⟩\n| (n+1) := let F : resp (n + 1) → arity Set (n + 1) := λ a, @quotient.lift _ _ pSet.setoid\n    (λ x, eval_aux.1 (a.f x)) (λ b c h, eval_aux.2 _ _ (a.2 _ _ h)) in\n  ⟨F, λ b c h, funext $ @quotient.ind _ _ (λ q, F b q = F c q) $ λ z,\n  eval_aux.2 (resp.f b z) (resp.f c z) (h _ _ (equiv.refl z))⟩\n\n/-- An equivalence-respecting function yields an n-ary ZFC set function. -/\ndef eval (n) : resp n → arity Set.{u} n := eval_aux.1\n\ntheorem eval_val {n f x} : (@eval (n+1) f : Set → arity Set n) ⟦x⟧ = eval n (resp.f f x) := rfl\n\nend resp\n\n/-- A set function is \"definable\" if it is the image of some n-ary pre-set\n  function. This isn't exactly definability, but is useful as a sufficient\n  condition for functions that have a computable image. -/\nclass inductive definable (n) : arity Set.{u} n → Type (u+1)\n| mk (f) : definable (resp.eval _ f)\nattribute [instance] definable.mk\n\n/-- The evaluation of a function respecting equivalence is definable, by that same function. -/\ndef definable.eq_mk {n} (f) : Π {s : arity Set.{u} n} (H : resp.eval _ f = s), definable n s\n| ._ rfl := ⟨f⟩\n\n/-- Turns a definable function into a function that respects equivalence. -/\ndef definable.resp {n} : Π (s : arity Set.{u} n) [definable n s], resp n\n| ._ ⟨f⟩ := f\n\ntheorem definable.eq {n} :\n  Π (s : arity Set.{u} n) [H : definable n s], (@definable.resp n s H).eval _ = s\n| ._ ⟨f⟩ := rfl\n\nend pSet\n\nnamespace classical\nopen pSet\n\n/-- All functions are classically definable. -/\nnoncomputable def all_definable : Π {n} (F : arity Set.{u} n), definable n F\n| 0     F := let p := @quotient.exists_rep pSet _ F in\n              definable.eq_mk ⟨some p, equiv.rfl⟩ (some_spec p)\n| (n+1) (F : arity Set.{u} (n + 1)) := begin\n    have I := λ x, (all_definable (F x)),\n    refine definable.eq_mk ⟨λ x : pSet, (@definable.resp _ _ (I ⟦x⟧)).1, _⟩ _,\n    { dsimp [arity.equiv],\n      introsI x y h,\n      rw @quotient.sound pSet _ _ _ h,\n      exact (definable.resp (F ⟦y⟧)).2 },\n    refine funext (λ q, quotient.induction_on q $ λ x, _),\n    simp_rw [resp.eval_val, resp.f, subtype.val_eq_coe, subtype.coe_eta],\n    exact @definable.eq _ (F ⟦x⟧) (I ⟦x⟧),\n  end\n\nend classical\n\nnamespace Set\nopen pSet\n\n/-- Turns a pre-set into a ZFC set. -/\ndef mk : pSet → Set := quotient.mk\n\n@[simp] theorem mk_eq (x : pSet) : @eq Set ⟦x⟧ (mk x) := rfl\n\n@[simp] lemma eval_mk {n f x} :\n  (@resp.eval (n+1) f : Set → arity Set n) (mk x) = resp.eval n (resp.f f x) :=\nrfl\n\n/-- The membership relation for ZFC sets is inherited from the membership relation for pre-sets. -/\ndef mem : Set → Set → Prop :=\nquotient.lift₂ pSet.mem\n  (λ x y x' y' hx hy, propext ((mem.congr_left hx).trans (mem.congr_right hy)))\n\ninstance : has_mem Set Set := ⟨mem⟩\n\n/-- Convert a ZFC set into a `set` of ZFC sets -/\ndef to_set (u : Set.{u}) : set Set.{u} := {x | x ∈ u}\n\n/-- `x ⊆ y` as ZFC sets means that all members of `x` are members of `y`. -/\nprotected def subset (x y : Set.{u}) :=\n∀ ⦃z⦄, z ∈ x → z ∈ y\n\ninstance has_subset : has_subset Set :=\n⟨Set.subset⟩\n\nlemma subset_def {x y : Set.{u}} : x ⊆ y ↔ ∀ ⦃z⦄, z ∈ x → z ∈ y := iff.rfl\n\ntheorem subset_iff : Π (x y : pSet), mk x ⊆ mk y ↔ x ⊆ y\n| ⟨α, A⟩ ⟨β, B⟩ := ⟨λ h a, @h ⟦A a⟧ (mem.mk A a),\n  λ h z, quotient.induction_on z (λ z ⟨a, za⟩, let ⟨b, ab⟩ := h a in ⟨b, za.trans ab⟩)⟩\n\ntheorem ext {x y : Set.{u}} : (∀ z : Set.{u}, z ∈ x ↔ z ∈ y) → x = y :=\nquotient.induction_on₂ x y (λ u v h, quotient.sound (mem.ext (λ w, h ⟦w⟧)))\n\ntheorem ext_iff {x y : Set.{u}} : (∀ z : Set.{u}, z ∈ x ↔ z ∈ y) ↔ x = y :=\n⟨ext, λ h, by simp [h]⟩\n\n/-- The empty ZFC set -/\ndef empty : Set := mk ∅\ninstance : has_emptyc Set := ⟨empty⟩\ninstance : inhabited Set := ⟨∅⟩\n\n@[simp] theorem mem_empty (x) : x ∉ (∅ : Set.{u}) :=\nquotient.induction_on x pSet.mem_empty\n\ntheorem eq_empty (x : Set.{u}) : x = ∅ ↔ ∀ y : Set.{u}, y ∉ x :=\n⟨λ h y, (h.symm ▸ mem_empty y),\nλ h, ext (λ y, ⟨λ yx, absurd yx (h y), λ y0, absurd y0 (mem_empty _)⟩)⟩\n\n/-- `insert x y` is the set `{x} ∪ y` -/\nprotected def insert : Set → Set → Set :=\nresp.eval 2 ⟨pSet.insert, λ u v uv ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λ o, match o with\n   | some a := let ⟨b, hb⟩ := αβ a in ⟨some b, hb⟩\n   | none := ⟨none, uv⟩\n   end, λ o, match o with\n   | some b := let ⟨a, ha⟩ := βα b in ⟨some a, ha⟩\n   | none := ⟨none, uv⟩\n   end⟩⟩\n\ninstance : has_insert Set Set := ⟨Set.insert⟩\n\ninstance : has_singleton Set Set := ⟨λ x, insert x ∅⟩\n\ninstance : is_lawful_singleton Set Set := ⟨λ x, rfl⟩\n\n@[simp] theorem mem_insert {x y z : Set.{u}} : x ∈ insert y z ↔ x = y ∨ x ∈ z :=\nquotient.induction_on₃ x y z\n (λ x y ⟨α, A⟩, show x ∈ pSet.mk (option α) (λ o, option.rec y A o) ↔\n    mk x = mk y ∨ x ∈ pSet.mk α A, from\n  ⟨λ m, match m with\n  | ⟨some a, ha⟩ := or.inr ⟨a, ha⟩\n  | ⟨none, h⟩ := or.inl (quotient.sound h)\n  end, λ m, match m with\n  | or.inr ⟨a, ha⟩ := ⟨some a, ha⟩\n  | or.inl h := ⟨none, quotient.exact h⟩\n  end⟩)\n\n@[simp] theorem mem_singleton {x y : Set.{u}} : x ∈ @singleton Set.{u} Set.{u} _ y ↔ x = y :=\niff.trans mem_insert ⟨λ o, or.rec (λ h, h) (λ n, absurd n (mem_empty _)) o, or.inl⟩\n\n@[simp] theorem mem_pair {x y z : Set.{u}} : x ∈ ({y, z} : Set) ↔ x = y ∨ x = z :=\niff.trans mem_insert $ or_congr iff.rfl mem_singleton\n\n/-- `omega` is the first infinite von Neumann ordinal -/\ndef omega : Set := mk omega\n\n@[simp] theorem omega_zero : ∅ ∈ omega :=\n⟨⟨0⟩, equiv.rfl⟩\n\n@[simp] theorem omega_succ {n} : n ∈ omega.{u} → insert n n ∈ omega.{u} :=\nquotient.induction_on n (λ x ⟨⟨n⟩, h⟩, ⟨⟨n+1⟩,\n  have Set.insert ⟦x⟧ ⟦x⟧ = Set.insert ⟦of_nat n⟧ ⟦of_nat n⟧, by rw (@quotient.sound pSet _ _ _ h),\n  quotient.exact this⟩)\n\n/-- `{x ∈ a | p x}` is the set of elements in `a` satisfying `p` -/\nprotected def sep (p : Set → Prop) : Set → Set :=\nresp.eval 1 ⟨pSet.sep (λ y, p ⟦y⟧), λ ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λ ⟨a, pa⟩, let ⟨b, hb⟩ := αβ a in ⟨⟨b, by rwa ←(@quotient.sound pSet _ _ _ hb)⟩, hb⟩,\n   λ ⟨b, pb⟩, let ⟨a, ha⟩ := βα b in ⟨⟨a, by rwa (@quotient.sound pSet _ _ _ ha)⟩, ha⟩⟩⟩\n\ninstance : has_sep Set Set := ⟨Set.sep⟩\n\n@[simp] theorem mem_sep {p : Set.{u} → Prop} {x y : Set.{u}} : y ∈ {y ∈ x | p y} ↔ y ∈ x ∧ p y :=\nquotient.induction_on₂ x y (λ ⟨α, A⟩ y,\n  ⟨λ ⟨⟨a, pa⟩, h⟩, ⟨⟨a, h⟩, by { rw (@quotient.sound pSet _ _ _ h), exact pa }⟩,\n  λ ⟨⟨a, h⟩, pa⟩, ⟨⟨a, by { rw ←(@quotient.sound pSet _ _ _ h), exact pa }⟩, h⟩⟩)\n\n/-- The powerset operation, the collection of subsets of a ZFC set -/\ndef powerset : Set → Set :=\nresp.eval 1 ⟨powerset, λ ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λ p, ⟨{b | ∃ a, p a ∧ equiv (A a) (B b)},\n    λ ⟨a, pa⟩, let ⟨b, ab⟩ := αβ a in ⟨⟨b, a, pa, ab⟩, ab⟩,\n    λ ⟨b, a, pa, ab⟩, ⟨⟨a, pa⟩, ab⟩⟩,\n   λ q, ⟨{a | ∃ b, q b ∧ equiv (A a) (B b)},\n    λ ⟨a, b, qb, ab⟩, ⟨⟨b, qb⟩, ab⟩,\n    λ ⟨b, qb⟩, let ⟨a, ab⟩ := βα b in ⟨⟨a, b, qb, ab⟩, ab⟩⟩⟩⟩\n\n@[simp] theorem mem_powerset {x y : Set.{u}} : y ∈ powerset x ↔ y ⊆ x :=\nquotient.induction_on₂ x y ( λ ⟨α, A⟩ ⟨β, B⟩,\n  show (⟨β, B⟩ : pSet.{u}) ∈ (pSet.powerset.{u} ⟨α, A⟩) ↔ _,\n    by simp [mem_powerset, subset_iff])\n\ntheorem Union_lem {α β : Type u} (A : α → pSet) (B : β → pSet) (αβ : ∀ a, ∃ b, equiv (A a) (B b)) :\n  ∀ a, ∃ b, (equiv ((Union ⟨α, A⟩).func a) ((Union ⟨β, B⟩).func b))\n| ⟨a, c⟩ := let ⟨b, hb⟩ := αβ a in\n  begin\n    induction ea : A a with γ Γ,\n    induction eb : B b with δ Δ,\n    rw [ea, eb] at hb,\n    cases hb with γδ δγ,\n    exact\n    let c : type (A a) := c, ⟨d, hd⟩ := γδ (by rwa ea at c) in\n    have pSet.equiv ((A a).func c) ((B b).func (eq.rec d (eq.symm eb))), from\n    match A a, B b, ea, eb, c, d, hd with ._, ._, rfl, rfl, x, y, hd := hd end,\n    ⟨⟨b, eq.rec d (eq.symm eb)⟩, this⟩\n  end\n\n/-- The union operator, the collection of elements of elements of a ZFC set -/\ndef Union : Set → Set :=\nresp.eval 1 ⟨pSet.Union, λ ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨Union_lem A B αβ, λ a, exists.elim (Union_lem B A (λ b,\n    exists.elim (βα b) (λ c hc, ⟨c, pSet.equiv.symm hc⟩)) a) (λ b hb, ⟨b, pSet.equiv.symm hb⟩)⟩⟩\n\nnotation `⋃` := Union\n\n@[simp] theorem mem_Union {x y : Set.{u}} : y ∈ Union x ↔ ∃ z ∈ x, y ∈ z :=\nquotient.induction_on₂ x y (λ x y, iff.trans mem_Union\n  ⟨λ ⟨z, h⟩, ⟨⟦z⟧, h⟩, λ ⟨z, h⟩, quotient.induction_on z (λ z h, ⟨z, h⟩) h⟩)\n\n@[simp] theorem Union_singleton {x : Set.{u}} : Union {x} = x :=\next $ λ y, by simp_rw [mem_Union, exists_prop, mem_singleton, exists_eq_left]\n\ntheorem singleton_inj {x y : Set.{u}} (H : ({x} : Set) = {y}) : x = y :=\nlet this := congr_arg Union H in by rwa [Union_singleton, Union_singleton] at this\n\n/-- The binary union operation -/\nprotected def union (x y : Set.{u}) : Set.{u} := ⋃ {x, y}\n\n/-- The binary intersection operation -/\nprotected def inter (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∈ y}\n\n/-- The set difference operation -/\nprotected def diff (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∉ y}\n\ninstance : has_union Set := ⟨Set.union⟩\ninstance : has_inter Set := ⟨Set.inter⟩\ninstance : has_sdiff Set := ⟨Set.diff⟩\n\n@[simp] theorem mem_union {x y z : Set.{u}} : z ∈ x ∪ y ↔ z ∈ x ∨ z ∈ y :=\niff.trans mem_Union\n ⟨λ ⟨w, wxy, zw⟩, match mem_pair.1 wxy with\n  | or.inl wx := or.inl (by rwa ←wx)\n  | or.inr wy := or.inr (by rwa ←wy)\n  end, λ zxy, match zxy with\n  | or.inl zx := ⟨x, mem_pair.2 (or.inl rfl), zx⟩\n  | or.inr zy := ⟨y, mem_pair.2 (or.inr rfl), zy⟩\n  end⟩\n\n@[simp] theorem mem_inter {x y z : Set.{u}} : z ∈ x ∩ y ↔ z ∈ x ∧ z ∈ y :=\n@@mem_sep (λ z : Set.{u}, z ∈ y)\n\n@[simp] theorem mem_diff {x y z : Set.{u}} : z ∈ x \\ y ↔ z ∈ x ∧ z ∉ y :=\n@@mem_sep (λ z : Set.{u}, z ∉ y)\n\ntheorem induction_on {p : Set → Prop} (x) (h : ∀ x, (∀ y ∈ x, p y) → p x) : p x :=\nquotient.induction_on x $ λ u, pSet.rec_on u $ λ α A IH, h _ $ λ y,\nshow @has_mem.mem _ _ Set.has_mem y ⟦⟨α, A⟩⟧ → p y, from\nquotient.induction_on y (λ v ⟨a, ha⟩, by { rw (@quotient.sound pSet _ _ _ ha), exact IH a })\n\ntheorem regularity (x : Set.{u}) (h : x ≠ ∅) : ∃ y ∈ x, x ∩ y = ∅ :=\nclassical.by_contradiction $ λ ne, h $ (eq_empty x).2 $ λ y,\ninduction_on y $ λ z (IH : ∀ w : Set.{u}, w ∈ z → w ∉ x), show z ∉ x, from λ zx,\nne ⟨z, zx, (eq_empty _).2 (λ w wxz, let ⟨wx, wz⟩ := mem_inter.1 wxz in IH w wz wx)⟩\n\n/-- The image of a (definable) ZFC set function -/\ndef image (f : Set → Set) [H : definable 1 f] : Set → Set :=\nlet r := @definable.resp 1 f _ in\nresp.eval 1 ⟨image r.1, λ x y e, mem.ext $ λ z,\n  iff.trans (mem_image r.2) $ iff.trans (by exact\n   ⟨λ ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).1 h1, h2⟩,\n    λ ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).2 h1, h2⟩⟩) $\n  iff.symm (mem_image r.2)⟩\n\ntheorem image.mk :\n  Π (f : Set.{u} → Set.{u}) [H : definable 1 f] (x) {y} (h : y ∈ x), f y ∈ @image f H x\n| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ ⟨α, A⟩ y ⟨a, ya⟩, ⟨a, F.2 _ _ ya⟩\n\n@[simp] theorem mem_image : Π {f : Set.{u} → Set.{u}} [H : definable 1 f] {x y : Set.{u}},\n  y ∈ @image f H x ↔ ∃ z ∈ x, f z = y\n| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ ⟨α, A⟩ y,\n  ⟨λ ⟨a, ya⟩, ⟨⟦A a⟧, mem.mk A a, eq.symm $ quotient.sound ya⟩,\n  λ ⟨z, hz, e⟩, e ▸ image.mk _ _ hz⟩\n\n/-- Kuratowski ordered pair -/\ndef pair (x y : Set.{u}) : Set.{u} := {{x}, {x, y}}\n\n/-- A subset of pairs `{(a, b) ∈ x × y | p a b}` -/\ndef pair_sep (p : Set.{u} → Set.{u} → Prop) (x y : Set.{u}) : Set.{u} :=\n{z ∈ powerset (powerset (x ∪ y)) | ∃ a ∈ x, ∃ b ∈ y, z = pair a b ∧ p a b}\n\n@[simp] theorem mem_pair_sep {p} {x y z : Set.{u}} :\n  z ∈ pair_sep p x y ↔ ∃ a ∈ x, ∃ b ∈ y, z = pair a b ∧ p a b :=\nbegin\n  refine mem_sep.trans ⟨and.right, λ e, ⟨_, e⟩⟩,\n  rcases e with ⟨a, ax, b, bY, rfl, pab⟩,\n  simp only [mem_powerset, subset_def, mem_union, pair, mem_pair],\n  rintros u (rfl|rfl) v; simp only [mem_singleton, mem_pair],\n  { rintro rfl, exact or.inl ax },\n  { rintro (rfl|rfl); [left, right]; assumption }\nend\n\ntheorem pair_inj {x y x' y' : Set.{u}} (H : pair x y = pair x' y') : x = x' ∧ y = y' :=\nbegin\n  have ae := ext_iff.2 H,\n  simp only [pair, mem_pair] at ae,\n  obtain rfl : x = x',\n  { cases (ae {x}).1 (by simp) with h h,\n    { exact singleton_inj h },\n    { have m : x' ∈ ({x} : Set),\n      { simp [h] },\n      rw mem_singleton.mp m } },\n  have he : x = y → y = y',\n  { rintro rfl,\n    cases (ae {x, y'}).2 (by simp only [eq_self_iff_true, or_true]) with xy'x xy'xx,\n    { rw [eq_comm, ←mem_singleton, ←xy'x, mem_pair],\n      exact or.inr rfl },\n    { simpa [eq_comm] using (ext_iff.2 xy'xx y').1 (by simp) } },\n  obtain xyx | xyy' := (ae {x, y}).1 (by simp),\n  { obtain rfl := mem_singleton.mp ((ext_iff.2 xyx y).1 $ by simp),\n    simp [he rfl] },\n  { obtain rfl | yy' := mem_pair.mp ((ext_iff.2 xyy' y).1 $ by simp),\n    { simp [he rfl] },\n    { simp [yy'] } }\nend\n\n/-- The cartesian product, `{(a, b) | a ∈ x, b ∈ y}` -/\ndef prod : Set.{u} → Set.{u} → Set.{u} := pair_sep (λ a b, true)\n\n@[simp] theorem mem_prod {x y z : Set.{u}} : z ∈ prod x y ↔ ∃ a ∈ x, ∃ b ∈ y, z = pair a b :=\nby simp [prod]\n\n@[simp] theorem pair_mem_prod {x y a b : Set.{u}} : pair a b ∈ prod x y ↔ a ∈ x ∧ b ∈ y :=\n⟨λ h, let ⟨a', a'x, b', b'y, e⟩ := mem_prod.1 h in\n  match a', b', pair_inj e, a'x, b'y with ._, ._, ⟨rfl, rfl⟩, ax, bY := ⟨ax, bY⟩ end,\nλ ⟨ax, bY⟩, mem_prod.2 ⟨a, ax, b, bY, rfl⟩⟩\n\n/-- `is_func x y f` is the assertion that `f` is a subset of `x × y` which relates to each element\nof `x` a unique element of `y`, so that we can consider `f`as a ZFC function `x → y`. -/\ndef is_func (x y f : Set.{u}) : Prop :=\nf ⊆ prod x y ∧ ∀ z : Set.{u}, z ∈ x → ∃! w, pair z w ∈ f\n\n/-- `funs x y` is `y ^ x`, the set of all set functions `x → y` -/\ndef funs (x y : Set.{u}) : Set.{u} :=\n{f ∈ powerset (prod x y) | is_func x y f}\n\n@[simp] theorem mem_funs {x y f : Set.{u}} : f ∈ funs x y ↔ is_func x y f :=\nby simp [funs, is_func]\n\n-- TODO(Mario): Prove this computably\nnoncomputable instance map_definable_aux (f : Set → Set) [H : definable 1 f] :\n  definable 1 (λ y, pair y (f y)) :=\n@classical.all_definable 1 _\n\n/-- Graph of a function: `map f x` is the ZFC function which maps `a ∈ x` to `f a` -/\nnoncomputable def map (f : Set → Set) [H : definable 1 f] : Set → Set :=\nimage (λ y, pair y (f y))\n\n@[simp] theorem mem_map {f : Set → Set} [H : definable 1 f] {x y : Set} :\n  y ∈ map f x ↔ ∃ z ∈ x, pair z (f z) = y :=\nmem_image\n\ntheorem map_unique {f : Set.{u} → Set.{u}} [H : definable 1 f] {x z : Set.{u}} (zx : z ∈ x) :\n  ∃! w, pair z w ∈ map f x :=\n⟨f z, image.mk _ _ zx, λ y yx, let ⟨w, wx, we⟩ := mem_image.1 yx, ⟨wz, fy⟩ := pair_inj we in\n  by rw[←fy, wz]⟩\n\n@[simp] theorem map_is_func {f : Set → Set} [H : definable 1 f] {x y : Set} :\n  is_func x y (map f x) ↔ ∀ z ∈ x, f z ∈ y :=\n⟨λ ⟨ss, h⟩ z zx, let ⟨t, t1, t2⟩ := h z zx in\n  (t2 (f z) (image.mk _ _ zx)).symm ▸ (pair_mem_prod.1 (ss t1)).right,\nλ h, ⟨λ y yx, let ⟨z, zx, ze⟩ := mem_image.1 yx in ze ▸ pair_mem_prod.2 ⟨zx, h z zx⟩,\n     λ z, map_unique⟩⟩\n\nend Set\n\n/-- The collection of all classes. A class is defined as a `set` of ZFC sets. -/\n@[derive [has_subset, has_sep Set, has_emptyc, inhabited, has_insert Set, has_union, has_inter,\n  has_compl, has_sdiff]]\ndef Class := set Set\n\nnamespace Class\n\n/-- Coerce a ZFC set into a class -/\ndef of_Set (x : Set.{u}) : Class.{u} := {y | y ∈ x}\ninstance : has_coe Set Class := ⟨of_Set⟩\n\n/-- The universal class -/\ndef univ : Class := set.univ\n\n/-- Assert that `A` is a ZFC set satisfying `p` -/\ndef to_Set (p : Set.{u} → Prop) (A : Class.{u}) : Prop := ∃ x, ↑x = A ∧ p x\n\n/-- `A ∈ B` if `A` is a ZFC set which is a member of `B` -/\nprotected def mem (A B : Class.{u}) : Prop := to_Set.{u} B A\ninstance : has_mem Class Class := ⟨Class.mem⟩\n\ntheorem mem_univ {A : Class.{u}} : A ∈ univ.{u} ↔ ∃ x : Set.{u}, ↑x = A :=\nexists_congr $ λ x, and_true _\n\n/-- Convert a conglomerate (a collection of classes) into a class -/\ndef Cong_to_Class (x : set Class.{u}) : Class.{u} := {y | ↑y ∈ x}\n\n/-- Convert a class into a conglomerate (a collection of classes) -/\ndef Class_to_Cong (x : Class.{u}) : set Class.{u} := {y | y ∈ x}\n\n/-- The power class of a class is the class of all subclasses that are ZFC sets -/\ndef powerset (x : Class) : Class := Cong_to_Class (set.powerset x)\n\n/-- The union of a class is the class of all members of ZFC sets in the class -/\ndef Union (x : Class) : Class := set.sUnion (Class_to_Cong x)\nnotation `⋃` := Union\n\ntheorem of_Set.inj {x y : Set.{u}} (h : (x : Class.{u}) = y) : x = y :=\nSet.ext $ λ z, by { change (x : Class.{u}) z ↔ (y : Class.{u}) z, rw h }\n\n@[simp] theorem to_Set_of_Set (p : Set.{u} → Prop) (x : Set.{u}) : to_Set p x ↔ p x :=\n⟨λ ⟨y, yx, py⟩, by rwa of_Set.inj yx at py, λ px, ⟨x, rfl, px⟩⟩\n\n@[simp] theorem mem_hom_left (x : Set.{u}) (A : Class.{u}) : (x : Class.{u}) ∈ A ↔ A x :=\nto_Set_of_Set _ _\n\n@[simp] theorem mem_hom_right (x y : Set.{u}) : (y : Class.{u}) x ↔ x ∈ y := iff.rfl\n\n@[simp] theorem subset_hom (x y : Set.{u}) : (x : Class.{u}) ⊆ y ↔ x ⊆ y := iff.rfl\n\n@[simp] theorem sep_hom (p : Set.{u} → Prop) (x : Set.{u}) :\n  (↑{y ∈ x | p y} : Class.{u}) = {y ∈ x | p y} :=\nset.ext $ λ y, Set.mem_sep\n\n@[simp] theorem empty_hom : ↑(∅ : Set.{u}) = (∅ : Class.{u}) :=\nset.ext $ λ y, (iff_false _).2 (Set.mem_empty y)\n\n@[simp] theorem insert_hom (x y : Set.{u}) : (@insert Set.{u} Class.{u} _ x y) = ↑(insert x y) :=\nset.ext $ λ z, iff.symm Set.mem_insert\n\n@[simp] theorem union_hom (x y : Set.{u}) : (x : Class.{u}) ∪ y = (x ∪ y : Set.{u}) :=\nset.ext $ λ z, iff.symm Set.mem_union\n\n@[simp] theorem inter_hom (x y : Set.{u}) : (x : Class.{u}) ∩ y = (x ∩ y : Set.{u}) :=\nset.ext $ λ z, iff.symm Set.mem_inter\n\n@[simp] theorem diff_hom (x y : Set.{u}) : (x : Class.{u}) \\ y = (x \\ y : Set.{u}) :=\nset.ext $ λ z, iff.symm Set.mem_diff\n\n@[simp] theorem powerset_hom (x : Set.{u}) : powerset.{u} x = Set.powerset x :=\nset.ext $ λ z, iff.symm Set.mem_powerset\n\n@[simp] theorem Union_hom (x : Set.{u}) : Union.{u} x = Set.Union x :=\nset.ext $ λ z, by { refine iff.trans _ Set.mem_Union.symm, exact\n⟨λ ⟨._, ⟨a, rfl, ax⟩, za⟩, ⟨a, ax, za⟩, λ ⟨a, ax, za⟩, ⟨_, ⟨a, rfl, ax⟩, za⟩⟩ }\n\n/-- The definite description operator, which is `{x}` if `{a | p a} = {x}` and `∅` otherwise. -/\ndef iota (p : Set → Prop) : Class := Union {x | ∀ y, p y ↔ y = x}\n\ntheorem iota_val (p : Set → Prop) (x : Set) (H : ∀ y, p y ↔ y = x) : iota p = ↑x :=\nset.ext $ λ y, ⟨λ ⟨._, ⟨x', rfl, h⟩, yx'⟩, by rwa ←((H x').1 $ (h x').2 rfl),\n  λ yx, ⟨_, ⟨x, rfl, H⟩, yx⟩⟩\n\n/-- Unlike the other set constructors, the `iota` definite descriptor\n  is a set for any set input, but not constructively so, so there is no\n  associated `(Set → Prop) → Set` function. -/\ntheorem iota_ex (p) : iota.{u} p ∈ univ.{u} :=\nmem_univ.2 $ or.elim (classical.em $ ∃ x, ∀ y, p y ↔ y = x)\n (λ ⟨x, h⟩, ⟨x, eq.symm $ iota_val p x h⟩)\n (λ hn, ⟨∅, set.ext (λ z, empty_hom.symm ▸ ⟨false.rec _, λ ⟨._, ⟨x, rfl, H⟩, zA⟩, hn ⟨x, H⟩⟩)⟩)\n\n/-- Function value -/\ndef fval (F A : Class.{u}) : Class.{u} := iota (λ y, to_Set (λ x, F (Set.pair x y)) A)\ninfixl `′`:100 := fval\n\ntheorem fval_ex (F A : Class.{u}) : F ′ A ∈ univ.{u} := iota_ex _\n\nend Class\n\nnamespace Set\n\n@[simp] theorem map_fval {f : Set.{u} → Set.{u}} [H : pSet.definable 1 f]\n  {x y : Set.{u}} (h : y ∈ x) :\n  (Set.map f x ′ y : Class.{u}) = f y :=\nClass.iota_val _ _ (λ z, by { rw [Class.to_Set_of_Set, Class.mem_hom_right, mem_map], exact\n  ⟨λ ⟨w, wz, pr⟩, let ⟨wy, fw⟩ := Set.pair_inj pr in by rw[←fw, wy],\n  λ e, by { subst e, exact ⟨_, h, rfl⟩ }⟩ })\n\nvariables (x : Set.{u}) (h : ∅ ∉ x)\n\n/-- A choice function on the class of nonempty ZFC sets. -/\nnoncomputable def choice : Set :=\n@map (λ y, classical.epsilon (λ z, z ∈ y)) (classical.all_definable _) x\n\ninclude h\ntheorem choice_mem_aux (y : Set.{u}) (yx : y ∈ x) : classical.epsilon (λ z : Set.{u}, z ∈ y) ∈ y :=\n@classical.epsilon_spec _ (λ z : Set.{u}, z ∈ y) $ classical.by_contradiction $ λ n, h $\nby rwa ←((eq_empty y).2 $ λ z zx, n ⟨z, zx⟩)\n\ntheorem choice_is_func : is_func x (Union x) (choice x) :=\n(@map_is_func _ (classical.all_definable _) _ _).2 $\n  λ y yx, mem_Union.2 ⟨y, yx, choice_mem_aux x h y yx⟩\n\ntheorem choice_mem (y : Set.{u}) (yx : y ∈ x) : (choice x ′ y : Class.{u}) ∈ (y : Class.{u}) :=\nbegin\n  delta choice,\n  rw [map_fval yx, Class.mem_hom_left, Class.mem_hom_right],\n  exact choice_mem_aux x h y yx\nend\n\nend Set\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/set_theory/zfc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4970904236151254}}
{"text": "theorem zeroLtOfLt : {a b : Nat} → a < b → 0 < b\n| 0,   _, h => h\n| a+1, b, h =>\n  have : a < b := Nat.ltTrans (Nat.ltSuccSelf _) h\n  zeroLtOfLt this\n\ndef fold {m α β} [Monad m] (as : Array α) (b : β) (f : α → β → m β) : m β := do\nlet rec loop : (i : Nat) → i ≤ as.size → β → m β\n  | 0,   h, b => b\n  | i+1, h, b => do\n    have h' : i < as.size          := Nat.ltOfLtOfLe (Nat.ltSuccSelf i) h\n    have : as.size - 1 < as.size     := Nat.subLt (zeroLtOfLt h') (by decide)\n    have : as.size - 1 - i < as.size := Nat.ltOfLeOfLt (Nat.subLe (as.size - 1) i) this\n    let b ← f (as.get ⟨as.size - 1 - i, this⟩) b\n    loop i (Nat.leOfLt h') b\nloop as.size (Nat.leRefl _) b\n\n#eval Id.run $ fold #[1, 2, 3, 4] 0 (pure $ · + ·)\n\ntheorem ex : (Id.run $ fold #[1, 2, 3, 4] 0 (pure $ · + ·)) = 10 :=\nrfl\n\ndef fold2 {m α β} [Monad m] (as : Array α) (b : β) (f : α → β → m β) : m β :=\nlet rec loop (i : Nat) (h : i ≤ as.size) (b : β) : m β := do\n  match i, h with\n  | 0,   h => return b\n  | i+1, h =>\n    have h' : i < as.size          := Nat.ltOfLtOfLe (Nat.ltSuccSelf i) h\n    have : as.size - 1 < as.size     := Nat.subLt (zeroLtOfLt h') (by decide)\n    have : as.size - 1 - i < as.size := Nat.ltOfLeOfLt (Nat.subLe (as.size - 1) i) this\n    let b ← f (as.get ⟨as.size - 1 - i, this⟩) b\n    loop i (Nat.leOfLt h') b\nloop as.size (Nat.leRefl _) b\n\ndef f (x : Nat) (ref : IO.Ref Nat) : IO Nat := do\nlet mut x := x\nif x == 0 then\n  x ← ref.get\nIO.println x\nreturn x + 1\n\ndef fTest : IO Unit := do\nunless (← f 0 (← IO.mkRef 10)) == 11 do throw $ IO.userError \"unexpected\"\nunless (← f 1 (← IO.mkRef 10)) == 2 do throw $ IO.userError \"unexpected\"\n\ndef g (x y : Nat) (ref : IO.Ref (Nat × Nat)) : IO (Nat × Nat) := do\n  let mut (x, y) := (x, y)\n  if x == 0 then\n    (x, y) ← ref.get\n  IO.println (\"x: \" ++ toString x ++ \", y: \" ++ toString y)\n  return (x, y)\n\ndef gTest : IO Unit := do\nunless (← g 2 1 (← IO.mkRef (10, 20))) == (2, 1)   do throw $ IO.userError \"unexpected\"\nunless (← g 0 1 (← IO.mkRef (10, 20))) == (10, 20) do throw $ IO.userError \"unexpected\"\nreturn ()\n\n#eval gTest\n\nmacro \"ret!\" x:term : doElem => `(return $x)\n\ndef f1 (x : Nat) : Nat := do\n  let mut x := x\n  if x == 0 then\n    ret! 100\n  x := x + 1\n  ret! x\n\ntheorem ex1 : f1 0 = 100 := rfl\ntheorem ex2 : f1 1 = 2 := rfl\ntheorem ex3 : f1 3 = 4 := rfl\n\nsyntax \"inc!\" ident : doElem\n\nmacro_rules\n| `(doElem| inc! $x) => `(doElem| $x:ident := $x + 1)\n\ndef f2 (x : Nat) : Nat := do\n  let mut x := x\n  inc! x\n  ret! x\n\ntheorem ex4 : f2 0 = 1 := rfl\ntheorem ex5 : f2 3 = 4 := rfl\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/run/doNotation3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680199891789, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4970904187097689}}
{"text": "/-\nCopyright (c) 2021 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n\n! This file was ported from Lean 3 source module analysis.normed.group.hom\n! leanprover-community/mathlib commit 3c4225288b55380a90df078ebae0991080b12393\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Analysis.Normed.Group.Basic\n\n/-!\n# Normed groups homomorphisms\n\nThis file gathers definitions and elementary constructions about bounded group homomorphisms\nbetween normed (abelian) groups (abbreviated to \"normed group homs\").\n\nThe main lemmas relate the boundedness condition to continuity and Lipschitzness.\n\nThe main construction is to endow the type of normed group homs between two given normed groups\nwith a group structure and a norm, giving rise to a normed group structure. We provide several\nsimple constructions for normed group homs, like kernel, range and equalizer.\n\nSome easy other constructions are related to subgroups of normed groups.\n\nSince a lot of elementary properties don't require `‖x‖ = 0 → x = 0` we start setting up the\ntheory of `SeminormedAddGroupHom` and we specialize to `NormedAddGroupHom` when needed.\n-/\n\n\nnoncomputable section\n\nopen NNReal BigOperators\n\n-- TODO: migrate to the new morphism / morphism_class style\n/-- A morphism of seminormed abelian groups is a bounded group homomorphism. -/\nstructure NormedAddGroupHom (V W : Type _) [SeminormedAddCommGroup V]\n  [SeminormedAddCommGroup W] where\n  /-- The function underlying a `NormedAddGroupHom` -/\n  toFun : V → W\n  /-- A `NormedAddGroupHom` is additive. -/\n  map_add' : ∀ v₁ v₂, toFun (v₁ + v₂) = toFun v₁ + toFun v₂\n  /-- A `NormedAddGroupHom` is bounded. -/\n  bound' : ∃ C, ∀ v, ‖toFun v‖ ≤ C * ‖v‖\n#align normed_add_group_hom NormedAddGroupHom\n\nnamespace AddMonoidHom\n\nvariable {V W : Type _} [SeminormedAddCommGroup V] [SeminormedAddCommGroup W]\n  {f g : NormedAddGroupHom V W}\n\n/-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition.\n\nSee `AddMonoidHom.mkNormedAddGroupHom'` for a version that uses `ℝ≥0` for the bound. -/\ndef mkNormedAddGroupHom (f : V →+ W) (C : ℝ) (h : ∀ v, ‖f v‖ ≤ C * ‖v‖) : NormedAddGroupHom V W :=\n  { f with bound' := ⟨C, h⟩ }\n#align add_monoid_hom.mk_normed_add_group_hom AddMonoidHom.mkNormedAddGroupHom\n\n/-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition.\n\nSee `AddMonoidHom.mkNormedAddGroupHom` for a version that uses `ℝ` for the bound. -/\ndef mkNormedAddGroupHom' (f : V →+ W) (C : ℝ≥0) (hC : ∀ x, ‖f x‖₊ ≤ C * ‖x‖₊) :\n    NormedAddGroupHom V W :=\n  { f with bound' := ⟨C, hC⟩ }\n#align add_monoid_hom.mk_normed_add_group_hom' AddMonoidHom.mkNormedAddGroupHom'\n\nend AddMonoidHom\n\ntheorem exists_pos_bound_of_bound {V W : Type _} [SeminormedAddCommGroup V]\n    [SeminormedAddCommGroup W] {f : V → W} (M : ℝ) (h : ∀ x, ‖f x‖ ≤ M * ‖x‖) :\n    ∃ N, 0 < N ∧ ∀ x, ‖f x‖ ≤ N * ‖x‖ :=\n  ⟨max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), fun x =>\n    calc\n      ‖f x‖ ≤ M * ‖x‖ := h x\n      _ ≤ max M 1 * ‖x‖ := mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg _)\n      ⟩\n#align exists_pos_bound_of_bound exists_pos_bound_of_bound\n\nnamespace NormedAddGroupHom\n\nvariable {V V₁ V₂ V₃ : Type _} [SeminormedAddCommGroup V] [SeminormedAddCommGroup V₁]\n  [SeminormedAddCommGroup V₂] [SeminormedAddCommGroup V₃]\n\nvariable {f g : NormedAddGroupHom V₁ V₂}\n\n/-- A Lipschitz continuous additive homomorphism is a normed additive group homomorphism. -/\ndef ofLipschitz (f : V₁ →+ V₂) {K : ℝ≥0} (h : LipschitzWith K f) : NormedAddGroupHom V₁ V₂ :=\n  f.mkNormedAddGroupHom K fun x ↦ by simpa only [map_zero, dist_zero_right] using h.dist_le_mul x 0\n\n-- porting note: moved this declaration up so we could get a `FunLike` instance sooner.\ninstance toAddMonoidHomClass : AddMonoidHomClass (NormedAddGroupHom V₁ V₂) V₁ V₂ where\n  coe := toFun\n  coe_injective' := fun f g h => by cases f; cases g; congr\n  map_add f := f.map_add'\n  map_zero f := (AddMonoidHom.mk' f.toFun f.map_add').map_zero\n\n/-- Helper instance for when there are too many metavariables to apply `FunLike.coeFun` directly. -/\ninstance coeFun : CoeFun (NormedAddGroupHom V₁ V₂) fun _ => V₁ → V₂ :=\n  ⟨FunLike.coe⟩\n\ninitialize_simps_projections NormedAddGroupHom (toFun → apply)\n\ntheorem coe_inj (H : (f : V₁ → V₂) = g) : f = g := by\n  cases f; cases g; congr\n#align normed_add_group_hom.coe_inj NormedAddGroupHom.coe_inj\n\ntheorem coe_injective : @Function.Injective (NormedAddGroupHom V₁ V₂) (V₁ → V₂) toFun := by\n  apply coe_inj\n#align normed_add_group_hom.coe_injective NormedAddGroupHom.coe_injective\n\ntheorem coe_inj_iff : f = g ↔ (f : V₁ → V₂) = g :=\n  ⟨congr_arg _, coe_inj⟩\n#align normed_add_group_hom.coe_inj_iff NormedAddGroupHom.coe_inj_iff\n\n@[ext]\ntheorem ext (H : ∀ x, f x = g x) : f = g :=\n  coe_inj <| funext H\n#align normed_add_group_hom.ext NormedAddGroupHom.ext\n\ntheorem ext_iff : f = g ↔ ∀ x, f x = g x :=\n  ⟨by rintro rfl x; rfl, ext⟩\n#align normed_add_group_hom.ext_iff NormedAddGroupHom.ext_iff\n\nvariable (f g)\n\n@[simp]\ntheorem toFun_eq_coe : f.toFun = f :=\n  rfl\n#align normed_add_group_hom.to_fun_eq_coe NormedAddGroupHom.toFun_eq_coe\n\n-- porting note: removed `simp` because `simpNF` complains the LHS doesn't simplify.\ntheorem coe_mk (f) (h₁) (h₂) (h₃) : ⇑(⟨f, h₁, h₂, h₃⟩ : NormedAddGroupHom V₁ V₂) = f :=\n  rfl\n#align normed_add_group_hom.coe_mk NormedAddGroupHom.coe_mk\n\n@[simp]\ntheorem coe_mkNormedAddGroupHom (f : V₁ →+ V₂) (C) (hC) : ⇑(f.mkNormedAddGroupHom C hC) = f :=\n  rfl\n#align normed_add_group_hom.coe_mk_normed_add_group_hom NormedAddGroupHom.coe_mkNormedAddGroupHom\n\n@[simp]\ntheorem coe_mkNormedAddGroupHom' (f : V₁ →+ V₂) (C) (hC) : ⇑(f.mkNormedAddGroupHom' C hC) = f :=\n  rfl\n#align normed_add_group_hom.coe_mk_normed_add_group_hom' NormedAddGroupHom.coe_mkNormedAddGroupHom'\n\n/-- The group homomorphism underlying a bounded group homomorphism. -/\ndef toAddMonoidHom (f : NormedAddGroupHom V₁ V₂) : V₁ →+ V₂ :=\n  AddMonoidHom.mk' f f.map_add'\n#align normed_add_group_hom.to_add_monoid_hom NormedAddGroupHom.toAddMonoidHom\n\n@[simp]\ntheorem coe_toAddMonoidHom : ⇑f.toAddMonoidHom = f :=\n  rfl\n#align normed_add_group_hom.coe_to_add_monoid_hom NormedAddGroupHom.coe_toAddMonoidHom\n\ntheorem toAddMonoidHom_injective :\n    Function.Injective (@NormedAddGroupHom.toAddMonoidHom V₁ V₂ _ _) := fun f g h =>\n  coe_inj <| by rw [←coe_toAddMonoidHom f, ←coe_toAddMonoidHom g, h]\n#align normed_add_group_hom.to_add_monoid_hom_injective NormedAddGroupHom.toAddMonoidHom_injective\n\n@[simp]\ntheorem mk_toAddMonoidHom (f) (h₁) (h₂) :\n    (⟨f, h₁, h₂⟩ : NormedAddGroupHom V₁ V₂).toAddMonoidHom = AddMonoidHom.mk' f h₁ :=\n  rfl\n#align normed_add_group_hom.mk_to_add_monoid_hom NormedAddGroupHom.mk_toAddMonoidHom\n\ntheorem bound : ∃ C, 0 < C ∧ ∀ x, ‖f x‖ ≤ C * ‖x‖ :=\n  let ⟨_C, hC⟩ := f.bound'\n  exists_pos_bound_of_bound _ hC\n#align normed_add_group_hom.bound NormedAddGroupHom.bound\n\ntheorem antilipschitz_of_norm_ge {K : ℝ≥0} (h : ∀ x, ‖x‖ ≤ K * ‖f x‖) : AntilipschitzWith K f :=\n  AntilipschitzWith.of_le_mul_dist fun x y => by simpa only [dist_eq_norm, map_sub] using h (x - y)\n#align normed_add_group_hom.antilipschitz_of_norm_ge NormedAddGroupHom.antilipschitz_of_norm_ge\n\n/-- A normed group hom is surjective on the subgroup `K` with constant `C` if every element\n`x` of `K` has a preimage whose norm is bounded above by `C*‖x‖`. This is a more\nabstract version of `f` having a right inverse defined on `K` with operator norm\nat most `C`. -/\ndef SurjectiveOnWith (f : NormedAddGroupHom V₁ V₂) (K : AddSubgroup V₂) (C : ℝ) : Prop :=\n  ∀ h ∈ K, ∃ g, f g = h ∧ ‖g‖ ≤ C * ‖h‖\n#align normed_add_group_hom.surjective_on_with NormedAddGroupHom.SurjectiveOnWith\n\ntheorem SurjectiveOnWith.mono {f : NormedAddGroupHom V₁ V₂} {K : AddSubgroup V₂} {C C' : ℝ}\n    (h : f.SurjectiveOnWith K C) (H : C ≤ C') : f.SurjectiveOnWith K C' := by\n  intro k k_in\n  rcases h k k_in with ⟨g, rfl, hg⟩\n  use g, rfl\n  by_cases Hg : ‖f g‖ = 0\n  · simpa [Hg] using hg\n  · exact hg.trans ((mul_le_mul_right <| (Ne.symm Hg).le_iff_lt.mp (norm_nonneg _)).mpr H)\n#align normed_add_group_hom.surjective_on_with.mono NormedAddGroupHom.SurjectiveOnWith.mono\n\ntheorem SurjectiveOnWith.exists_pos {f : NormedAddGroupHom V₁ V₂} {K : AddSubgroup V₂} {C : ℝ}\n    (h : f.SurjectiveOnWith K C) : ∃ C' > 0, f.SurjectiveOnWith K C' := by\n  refine' ⟨|C| + 1, _, _⟩\n  · linarith [abs_nonneg C]\n  · apply h.mono\n    linarith [le_abs_self C]\n#align normed_add_group_hom.surjective_on_with.exists_pos NormedAddGroupHom.SurjectiveOnWith.exists_pos\n\ntheorem SurjectiveOnWith.surjOn {f : NormedAddGroupHom V₁ V₂} {K : AddSubgroup V₂} {C : ℝ}\n    (h : f.SurjectiveOnWith K C) : Set.SurjOn f Set.univ K := fun x hx =>\n  (h x hx).imp fun _a ⟨ha, _⟩ => ⟨Set.mem_univ _, ha⟩\n#align normed_add_group_hom.surjective_on_with.surj_on NormedAddGroupHom.SurjectiveOnWith.surjOn\n\n/-! ### The operator norm -/\n\n\n/-- The operator norm of a seminormed group homomorphism is the inf of all its bounds. -/\ndef opNorm (f : NormedAddGroupHom V₁ V₂) :=\n  infₛ { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ }\n#align normed_add_group_hom.op_norm NormedAddGroupHom.opNorm\n\ninstance hasOpNorm : Norm (NormedAddGroupHom V₁ V₂) :=\n  ⟨opNorm⟩\n#align normed_add_group_hom.has_op_norm NormedAddGroupHom.hasOpNorm\n\ntheorem norm_def : ‖f‖ = infₛ { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ } :=\n  rfl\n#align normed_add_group_hom.norm_def NormedAddGroupHom.norm_def\n\n-- So that invocations of `le_cinfₛ` make sense: we show that the set of\n-- bounds is nonempty and bounded below.\ntheorem bounds_nonempty {f : NormedAddGroupHom V₁ V₂} :\n    ∃ c, c ∈ { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ } :=\n  let ⟨M, hMp, hMb⟩ := f.bound\n  ⟨M, le_of_lt hMp, hMb⟩\n#align normed_add_group_hom.bounds_nonempty NormedAddGroupHom.bounds_nonempty\n\ntheorem bounds_bddBelow {f : NormedAddGroupHom V₁ V₂} :\n    BddBelow { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ } :=\n  ⟨0, fun _ ⟨hn, _⟩ => hn⟩\n#align normed_add_group_hom.bounds_bdd_below NormedAddGroupHom.bounds_bddBelow\n\ntheorem opNorm_nonneg : 0 ≤ ‖f‖ :=\n  le_cinfₛ bounds_nonempty fun _ ⟨hx, _⟩ => hx\n#align normed_add_group_hom.op_norm_nonneg NormedAddGroupHom.opNorm_nonneg\n\n/-- The fundamental property of the operator norm: `‖f x‖ ≤ ‖f‖ * ‖x‖`. -/\ntheorem le_opNorm (x : V₁) : ‖f x‖ ≤ ‖f‖ * ‖x‖ := by\n  obtain ⟨C, _Cpos, hC⟩ := f.bound\n  replace hC := hC x\n  by_cases h : ‖x‖ = 0\n  · rwa [h, mul_zero] at hC⊢\n  have hlt : 0 < ‖x‖ := lt_of_le_of_ne (norm_nonneg x) (Ne.symm h)\n  exact\n    (div_le_iff hlt).mp\n      (le_cinfₛ bounds_nonempty fun c ⟨_, hc⟩ => (div_le_iff hlt).mpr <| by apply hc)\n#align normed_add_group_hom.le_op_norm NormedAddGroupHom.le_opNorm\n\ntheorem le_opNorm_of_le {c : ℝ} {x} (h : ‖x‖ ≤ c) : ‖f x‖ ≤ ‖f‖ * c :=\n  le_trans (f.le_opNorm x) (mul_le_mul_of_nonneg_left h f.opNorm_nonneg)\n#align normed_add_group_hom.le_op_norm_of_le NormedAddGroupHom.le_opNorm_of_le\n\ntheorem le_of_opNorm_le {c : ℝ} (h : ‖f‖ ≤ c) (x : V₁) : ‖f x‖ ≤ c * ‖x‖ :=\n  (f.le_opNorm x).trans (mul_le_mul_of_nonneg_right h (norm_nonneg x))\n#align normed_add_group_hom.le_of_op_norm_le NormedAddGroupHom.le_of_opNorm_le\n\n/-- continuous linear maps are Lipschitz continuous. -/\ntheorem lipschitz : LipschitzWith ⟨‖f‖, opNorm_nonneg f⟩ f :=\n  LipschitzWith.of_dist_le_mul fun x y => by\n    rw [dist_eq_norm, dist_eq_norm, ← map_sub]\n    apply le_opNorm\n#align normed_add_group_hom.lipschitz NormedAddGroupHom.lipschitz\n\nprotected theorem uniformContinuous (f : NormedAddGroupHom V₁ V₂) : UniformContinuous f :=\n  f.lipschitz.uniformContinuous\n#align normed_add_group_hom.uniform_continuous NormedAddGroupHom.uniformContinuous\n\n@[continuity]\nprotected theorem continuous (f : NormedAddGroupHom V₁ V₂) : Continuous f :=\n  f.uniformContinuous.continuous\n#align normed_add_group_hom.continuous NormedAddGroupHom.continuous\n\ntheorem ratio_le_opNorm (x : V₁) : ‖f x‖ / ‖x‖ ≤ ‖f‖ :=\n  div_le_of_nonneg_of_le_mul (norm_nonneg _) f.opNorm_nonneg (le_opNorm _ _)\n#align normed_add_group_hom.ratio_le_op_norm NormedAddGroupHom.ratio_le_opNorm\n\n/-- If one controls the norm of every `f x`, then one controls the norm of `f`. -/\ntheorem opNorm_le_bound {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ x, ‖f x‖ ≤ M * ‖x‖) : ‖f‖ ≤ M :=\n  cinfₛ_le bounds_bddBelow ⟨hMp, hM⟩\n#align normed_add_group_hom.op_norm_le_bound NormedAddGroupHom.opNorm_le_bound\n\ntheorem opNorm_eq_of_bounds {M : ℝ} (M_nonneg : 0 ≤ M) (h_above : ∀ x, ‖f x‖ ≤ M * ‖x‖)\n    (h_below : ∀ N ≥ 0, (∀ x, ‖f x‖ ≤ N * ‖x‖) → M ≤ N) : ‖f‖ = M :=\n  le_antisymm (f.opNorm_le_bound M_nonneg h_above)\n    ((le_cinfₛ_iff NormedAddGroupHom.bounds_bddBelow ⟨M, M_nonneg, h_above⟩).mpr\n      fun N ⟨N_nonneg, hN⟩ => h_below N N_nonneg hN)\n#align normed_add_group_hom.op_norm_eq_of_bounds NormedAddGroupHom.opNorm_eq_of_bounds\n\ntheorem opNorm_le_of_lipschitz {f : NormedAddGroupHom V₁ V₂} {K : ℝ≥0} (hf : LipschitzWith K f) :\n    ‖f‖ ≤ K :=\n  f.opNorm_le_bound K.2 fun x => by simpa only [dist_zero_right, map_zero] using hf.dist_le_mul x 0\n#align normed_add_group_hom.op_norm_le_of_lipschitz NormedAddGroupHom.opNorm_le_of_lipschitz\n\n/-- If a bounded group homomorphism map is constructed from a group homomorphism via the constructor\n`AddMonoidHom.mkNormedAddGroupHom`, then its norm is bounded by the bound given to the constructor\nif it is nonnegative. -/\ntheorem mkNormedAddGroupHom_norm_le (f : V₁ →+ V₂) {C : ℝ} (hC : 0 ≤ C) (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :\n    ‖f.mkNormedAddGroupHom C h‖ ≤ C :=\n  opNorm_le_bound _ hC h\n#align normed_add_group_hom.mk_normed_add_group_hom_norm_le NormedAddGroupHom.mkNormedAddGroupHom_norm_le\n\n/-- If a bounded group homomorphism map is constructed from a group homomorphism via the constructor\n`NormedAddGroupHom.ofLipschitz`, then its norm is bounded by the bound given to the constructor. -/\ntheorem ofLipschitz_norm_le (f : V₁ →+ V₂) {K : ℝ≥0} (h : LipschitzWith K f) :\n    ‖ofLipschitz f h‖ ≤ K :=\n  mkNormedAddGroupHom_norm_le f K.coe_nonneg _\n\n/-- If a bounded group homomorphism map is constructed from a group homomorphism\nvia the constructor `AddMonoidHom.mkNormedAddGroupHom`, then its norm is bounded by the bound\ngiven to the constructor or zero if this bound is negative. -/\ntheorem mkNormedAddGroupHom_norm_le' (f : V₁ →+ V₂) {C : ℝ} (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :\n    ‖f.mkNormedAddGroupHom C h‖ ≤ max C 0 :=\n  opNorm_le_bound _ (le_max_right _ _) fun x =>\n    (h x).trans <| mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg x)\n#align normed_add_group_hom.mk_normed_add_group_hom_norm_le' NormedAddGroupHom.mkNormedAddGroupHom_norm_le'\n\nalias mkNormedAddGroupHom_norm_le ← _root_.AddMonoidHom.mkNormedAddGroupHom_norm_le\n#align add_monoid_hom.mk_normed_add_group_hom_norm_le AddMonoidHom.mkNormedAddGroupHom_norm_le\n\nalias mkNormedAddGroupHom_norm_le' ← _root_.AddMonoidHom.mkNormedAddGroupHom_norm_le'\n#align add_monoid_hom.mk_normed_add_group_hom_norm_le' AddMonoidHom.mkNormedAddGroupHom_norm_le'\n\n/-! ### Addition of normed group homs -/\n\n\n/-- Addition of normed group homs. -/\ninstance add : Add (NormedAddGroupHom V₁ V₂) :=\n  ⟨fun f g =>\n    (f.toAddMonoidHom + g.toAddMonoidHom).mkNormedAddGroupHom (‖f‖ + ‖g‖) fun v =>\n      calc\n        ‖f v + g v‖ ≤ ‖f v‖ + ‖g v‖ := norm_add_le _ _\n        _ ≤ ‖f‖ * ‖v‖ + ‖g‖ * ‖v‖ := (add_le_add (le_opNorm f v) (le_opNorm g v))\n        _ = (‖f‖ + ‖g‖) * ‖v‖ := by rw [add_mul]\n        ⟩\n\n/-- The operator norm satisfies the triangle inequality. -/\ntheorem opNorm_add_le : ‖f + g‖ ≤ ‖f‖ + ‖g‖ :=\n  mkNormedAddGroupHom_norm_le _ (add_nonneg (opNorm_nonneg _) (opNorm_nonneg _)) _\n#align normed_add_group_hom.op_norm_add_le NormedAddGroupHom.opNorm_add_le\n\n-- porting note: this library note doesn't seem to apply anymore\n/-\nlibrary_note \"addition on function coercions\"/--\nTerms containing `@has_add.add (has_coe_to_fun.F ...) pi.has_add`\nseem to cause leanchecker to [crash due to an out-of-memory\ncondition](https://github.com/leanprover-community/lean/issues/543).\nAs a workaround, we add a type annotation: `(f + g : V₁ → V₂)`\n-/\n-/\n\n@[simp]\ntheorem coe_add (f g : NormedAddGroupHom V₁ V₂) : ⇑(f + g) = f + g :=\n  rfl\n#align normed_add_group_hom.coe_add NormedAddGroupHom.coe_add\n\n@[simp]\ntheorem add_apply (f g : NormedAddGroupHom V₁ V₂) (v : V₁) :\n    (f + g) v = f v + g v :=\n  rfl\n#align normed_add_group_hom.add_apply NormedAddGroupHom.add_apply\n\n/-! ### The zero normed group hom -/\n\n\ninstance zero : Zero (NormedAddGroupHom V₁ V₂) :=\n  ⟨(0 : V₁ →+ V₂).mkNormedAddGroupHom 0 (by simp)⟩\n\ninstance inhabited : Inhabited (NormedAddGroupHom V₁ V₂) :=\n  ⟨0⟩\n\n/-- The norm of the `0` operator is `0`. -/\ntheorem opNorm_zero : ‖(0 : NormedAddGroupHom V₁ V₂)‖ = 0 :=\n  le_antisymm\n    (cinfₛ_le bounds_bddBelow\n      ⟨ge_of_eq rfl, fun _ =>\n        le_of_eq\n          (by\n            rw [zero_mul]\n            exact norm_zero)⟩)\n    (opNorm_nonneg _)\n#align normed_add_group_hom.op_norm_zero NormedAddGroupHom.opNorm_zero\n\n/-- For normed groups, an operator is zero iff its norm vanishes. -/\ntheorem opNorm_zero_iff {V₁ V₂ : Type _} [NormedAddCommGroup V₁] [NormedAddCommGroup V₂]\n    {f : NormedAddGroupHom V₁ V₂} : ‖f‖ = 0 ↔ f = 0 :=\n  Iff.intro\n    (fun hn =>\n      ext fun x =>\n        norm_le_zero_iff.1\n          (calc\n            _ ≤ ‖f‖ * ‖x‖ := le_opNorm _ _\n            _ = _ := by rw [hn, zero_mul]\n            ))\n    fun hf => by rw [hf, opNorm_zero]\n#align normed_add_group_hom.op_norm_zero_iff NormedAddGroupHom.opNorm_zero_iff\n\n@[simp]\n\n\n@[simp]\ntheorem zero_apply (v : V₁) : (0 : NormedAddGroupHom V₁ V₂) v = 0 :=\n  rfl\n#align normed_add_group_hom.zero_apply NormedAddGroupHom.zero_apply\n\nvariable {f g}\n\n/-! ### The identity normed group hom -/\n\n\nvariable (V)\n\n/-- The identity as a continuous normed group hom. -/\n@[simps!]\ndef id : NormedAddGroupHom V V :=\n  (AddMonoidHom.id V).mkNormedAddGroupHom 1 (by simp [le_refl])\n#align normed_add_group_hom.id NormedAddGroupHom.id\n\n/-- The norm of the identity is at most `1`. It is in fact `1`, except when the norm of every\nelement vanishes, where it is `0`. (Since we are working with seminorms this can happen even if the\nspace is non-trivial.) It means that one can not do better than an inequality in general. -/\ntheorem norm_id_le : ‖(id V : NormedAddGroupHom V V)‖ ≤ 1 :=\n  opNorm_le_bound _ zero_le_one fun x => by simp\n#align normed_add_group_hom.norm_id_le NormedAddGroupHom.norm_id_le\n\n/-- If there is an element with norm different from `0`, then the norm of the identity equals `1`.\n(Since we are working with seminorms supposing that the space is non-trivial is not enough.) -/\ntheorem norm_id_of_nontrivial_seminorm (h : ∃ x : V, ‖x‖ ≠ 0) : ‖id V‖ = 1 :=\n  le_antisymm (norm_id_le V) <| by\n    let ⟨x, hx⟩ := h\n    have := (id V).ratio_le_opNorm x\n    rwa [id_apply, div_self hx] at this\n#align normed_add_group_hom.norm_id_of_nontrivial_seminorm NormedAddGroupHom.norm_id_of_nontrivial_seminorm\n\n/-- If a normed space is non-trivial, then the norm of the identity equals `1`. -/\ntheorem norm_id {V : Type _} [NormedAddCommGroup V] [Nontrivial V] : ‖id V‖ = 1 := by\n  refine' norm_id_of_nontrivial_seminorm V _\n  obtain ⟨x, hx⟩ := exists_ne (0 : V)\n  exact ⟨x, ne_of_gt (norm_pos_iff.2 hx)⟩\n#align normed_add_group_hom.norm_id NormedAddGroupHom.norm_id\n\ntheorem coe_id : (NormedAddGroupHom.id V : V → V) = _root_.id :=\n  rfl\n#align normed_add_group_hom.coe_id NormedAddGroupHom.coe_id\n\n/-! ### The negation of a normed group hom -/\n\n\n/-- Opposite of a normed group hom. -/\ninstance neg : Neg (NormedAddGroupHom V₁ V₂) :=\n  ⟨fun f => (-f.toAddMonoidHom).mkNormedAddGroupHom ‖f‖ fun v => by simp [le_opNorm f v]⟩\n\n@[simp]\ntheorem coe_neg (f : NormedAddGroupHom V₁ V₂) : ⇑(-f) = -f :=\n  rfl\n#align normed_add_group_hom.coe_neg NormedAddGroupHom.coe_neg\n\n@[simp]\ntheorem neg_apply (f : NormedAddGroupHom V₁ V₂) (v : V₁) :\n    (-f : NormedAddGroupHom V₁ V₂) v = -f v :=\n  rfl\n#align normed_add_group_hom.neg_apply NormedAddGroupHom.neg_apply\n\ntheorem opNorm_neg (f : NormedAddGroupHom V₁ V₂) : ‖-f‖ = ‖f‖ := by\n  simp only [norm_def, coe_neg, norm_neg, Pi.neg_apply]\n#align normed_add_group_hom.op_norm_neg NormedAddGroupHom.opNorm_neg\n\n/-! ### Subtraction of normed group homs -/\n\n\n/-- Subtraction of normed group homs. -/\ninstance sub : Sub (NormedAddGroupHom V₁ V₂) :=\n  ⟨fun f g =>\n    { f.toAddMonoidHom - g.toAddMonoidHom with\n      bound' := by\n        simp only [AddMonoidHom.sub_apply, AddMonoidHom.toFun_eq_coe, sub_eq_add_neg]\n        exact (f + -g).bound' }⟩\n\n@[simp]\ntheorem coe_sub (f g : NormedAddGroupHom V₁ V₂) : ⇑(f - g) = f - g :=\n  rfl\n#align normed_add_group_hom.coe_sub NormedAddGroupHom.coe_sub\n\n@[simp]\ntheorem sub_apply (f g : NormedAddGroupHom V₁ V₂) (v : V₁) :\n    (f - g : NormedAddGroupHom V₁ V₂) v = f v - g v :=\n  rfl\n#align normed_add_group_hom.sub_apply NormedAddGroupHom.sub_apply\n\n/-! ### Scalar actions on normed group homs -/\n\n\nsection SMul\n\nvariable {R R' : Type _} [MonoidWithZero R] [DistribMulAction R V₂] [PseudoMetricSpace R]\n  [BoundedSMul R V₂] [MonoidWithZero R'] [DistribMulAction R' V₂] [PseudoMetricSpace R']\n  [BoundedSMul R' V₂]\n\ninstance smul : SMul R (NormedAddGroupHom V₁ V₂) where\n  smul r f :=\n    { toFun := r • ⇑f\n      map_add' := (r • f.toAddMonoidHom).map_add'\n      bound' :=\n        let ⟨b, hb⟩ := f.bound'\n        ⟨dist r 0 * b, fun x => by\n          have := dist_smul_pair r (f x) (f 0)\n          rw [map_zero, smul_zero, dist_zero_right, dist_zero_right] at this\n          rw [mul_assoc]\n          refine' this.trans _\n          refine' mul_le_mul_of_nonneg_left _ dist_nonneg\n          exact hb x⟩ }\n\n@[simp]\ntheorem coe_smul (r : R) (f : NormedAddGroupHom V₁ V₂) : ⇑(r • f) = r • ⇑f :=\n  rfl\n#align normed_add_group_hom.coe_smul NormedAddGroupHom.coe_smul\n\n@[simp]\ntheorem smul_apply (r : R) (f : NormedAddGroupHom V₁ V₂) (v : V₁) : (r • f) v = r • f v :=\n  rfl\n#align normed_add_group_hom.smul_apply NormedAddGroupHom.smul_apply\n\ninstance smulCommClass [SMulCommClass R R' V₂] :\n    SMulCommClass R R' (NormedAddGroupHom V₁ V₂) where\n  smul_comm _ _ _ := ext fun _ => smul_comm _ _ _\n\ninstance isScalarTower [SMul R R'] [IsScalarTower R R' V₂] :\n    IsScalarTower R R' (NormedAddGroupHom V₁ V₂) where\n  smul_assoc _ _ _ := ext fun _ => smul_assoc _ _ _\n\ninstance isCentralScalar [DistribMulAction Rᵐᵒᵖ V₂] [IsCentralScalar R V₂] :\n    IsCentralScalar R (NormedAddGroupHom V₁ V₂) where\n  op_smul_eq_smul _ _ := ext fun _ => op_smul_eq_smul _ _\n\nend SMul\n\ninstance nsmul : SMul ℕ (NormedAddGroupHom V₁ V₂) where\n  smul n f :=\n    { toFun := n • ⇑f\n      map_add' := (n • f.toAddMonoidHom).map_add'\n      bound' :=\n        let ⟨b, hb⟩ := f.bound'\n        ⟨n • b, fun v => by\n          rw [Pi.smul_apply, nsmul_eq_mul, mul_assoc]\n          exact (norm_nsmul_le _ _).trans (mul_le_mul_of_nonneg_left (hb _) (Nat.cast_nonneg _))⟩ }\n#align normed_add_group_hom.has_nat_scalar NormedAddGroupHom.nsmul\n\n@[simp]\ntheorem coe_nsmul (r : ℕ) (f : NormedAddGroupHom V₁ V₂) : ⇑(r • f) = r • ⇑f :=\n  rfl\n#align normed_add_group_hom.coe_nsmul NormedAddGroupHom.coe_nsmul\n\n@[simp]\ntheorem nsmul_apply (r : ℕ) (f : NormedAddGroupHom V₁ V₂) (v : V₁) : (r • f) v = r • f v :=\n  rfl\n#align normed_add_group_hom.nsmul_apply NormedAddGroupHom.nsmul_apply\n\ninstance zsmul : SMul ℤ (NormedAddGroupHom V₁ V₂) where\n  smul z f :=\n    { toFun := z • ⇑f\n      map_add' := (z • f.toAddMonoidHom).map_add'\n      bound' :=\n        let ⟨b, hb⟩ := f.bound'\n        ⟨‖z‖ • b, fun v => by\n          rw [Pi.smul_apply, smul_eq_mul, mul_assoc]\n          exact (norm_zsmul_le _ _).trans (mul_le_mul_of_nonneg_left (hb _) <| norm_nonneg _)⟩ }\n#align normed_add_group_hom.has_int_scalar NormedAddGroupHom.zsmul\n\n@[simp]\ntheorem coe_zsmul (r : ℤ) (f : NormedAddGroupHom V₁ V₂) : ⇑(r • f) = r • ⇑f :=\n  rfl\n#align normed_add_group_hom.coe_zsmul NormedAddGroupHom.coe_zsmul\n\n@[simp]\ntheorem zsmul_apply (r : ℤ) (f : NormedAddGroupHom V₁ V₂) (v : V₁) : (r • f) v = r • f v :=\n  rfl\n#align normed_add_group_hom.zsmul_apply NormedAddGroupHom.zsmul_apply\n\n/-! ### Normed group structure on normed group homs -/\n\n\n/-- Homs between two given normed groups form a commutative additive group. -/\ninstance toAddCommGroup : AddCommGroup (NormedAddGroupHom V₁ V₂) :=\n  coe_injective.addCommGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    fun _ _ => rfl\n\n/-- Normed group homomorphisms themselves form a seminormed group with respect to\n    the operator norm. -/\ninstance toSeminormedAddCommGroup : SeminormedAddCommGroup (NormedAddGroupHom V₁ V₂) :=\n  AddGroupSeminorm.toSeminormedAddCommGroup\n    { toFun := opNorm\n      map_zero' := opNorm_zero\n      neg' := opNorm_neg\n      add_le' := opNorm_add_le }\n#align normed_add_group_hom.to_seminormed_add_comm_group NormedAddGroupHom.toSeminormedAddCommGroup\n\n/-- Normed group homomorphisms themselves form a normed group with respect to\n    the operator norm. -/\ninstance toNormedAddCommGroup {V₁ V₂ : Type _} [NormedAddCommGroup V₁] [NormedAddCommGroup V₂] :\n    NormedAddCommGroup (NormedAddGroupHom V₁ V₂) :=\n  AddGroupNorm.toNormedAddCommGroup\n    { toFun := opNorm\n      map_zero' := opNorm_zero\n      neg' := opNorm_neg\n      add_le' := opNorm_add_le\n      eq_zero_of_map_eq_zero' := fun _f => opNorm_zero_iff.1 }\n#align normed_add_group_hom.to_normed_add_comm_group NormedAddGroupHom.toNormedAddCommGroup\n\n/-- Coercion of a `NormedAddGroupHom` is an `AddMonoidHom`. Similar to `AddMonoidHom.coeFn`.  -/\n@[simps]\ndef coeAddHom : NormedAddGroupHom V₁ V₂ →+ V₁ → V₂ where\n  toFun := FunLike.coe\n  map_zero' := coe_zero\n  map_add' := coe_add\n#align normed_add_group_hom.coe_fn_add_hom NormedAddGroupHom.coeAddHom\n\n@[simp]\ntheorem coe_sum {ι : Type _} (s : Finset ι) (f : ι → NormedAddGroupHom V₁ V₂) :\n    ⇑(∑ i in s, f i) = ∑ i in s, (f i : V₁ → V₂) :=\n  (coeAddHom : _ →+ V₁ → V₂).map_sum f s\n#align normed_add_group_hom.coe_sum NormedAddGroupHom.coe_sum\n\ntheorem sum_apply {ι : Type _} (s : Finset ι) (f : ι → NormedAddGroupHom V₁ V₂) (v : V₁) :\n    (∑ i in s, f i) v = ∑ i in s, f i v := by simp only [coe_sum, Finset.sum_apply]\n#align normed_add_group_hom.sum_apply NormedAddGroupHom.sum_apply\n\n/-! ### Module structure on normed group homs -/\n\n\ninstance distribMulAction {R : Type _} [MonoidWithZero R] [DistribMulAction R V₂]\n    [PseudoMetricSpace R] [BoundedSMul R V₂] : DistribMulAction R (NormedAddGroupHom V₁ V₂) :=\n  Function.Injective.distribMulAction coeAddHom coe_injective coe_smul\n\ninstance module {R : Type _} [Semiring R] [Module R V₂] [PseudoMetricSpace R] [BoundedSMul R V₂] :\n    Module R (NormedAddGroupHom V₁ V₂) :=\n  Function.Injective.module _ coeAddHom coe_injective coe_smul\n\n/-! ### Composition of normed group homs -/\n\n\n/-- The composition of continuous normed group homs. -/\n@[simps!]\nprotected def comp (g : NormedAddGroupHom V₂ V₃) (f : NormedAddGroupHom V₁ V₂) :\n    NormedAddGroupHom V₁ V₃ :=\n  (g.toAddMonoidHom.comp f.toAddMonoidHom).mkNormedAddGroupHom (‖g‖ * ‖f‖) fun v =>\n    calc\n      ‖g (f v)‖ ≤ ‖g‖ * ‖f v‖ := le_opNorm _ _\n      _ ≤ ‖g‖ * (‖f‖ * ‖v‖) := (mul_le_mul_of_nonneg_left (le_opNorm _ _) (opNorm_nonneg _))\n      _ = ‖g‖ * ‖f‖ * ‖v‖ := by rw [mul_assoc]\n\n#align normed_add_group_hom.comp NormedAddGroupHom.comp\n\ntheorem norm_comp_le (g : NormedAddGroupHom V₂ V₃) (f : NormedAddGroupHom V₁ V₂) :\n    ‖g.comp f‖ ≤ ‖g‖ * ‖f‖ :=\n  mkNormedAddGroupHom_norm_le _ (mul_nonneg (opNorm_nonneg _) (opNorm_nonneg _)) _\n#align normed_add_group_hom.norm_comp_le NormedAddGroupHom.norm_comp_le\n\ntheorem norm_comp_le_of_le {g : NormedAddGroupHom V₂ V₃} {C₁ C₂ : ℝ} (hg : ‖g‖ ≤ C₂)\n    (hf : ‖f‖ ≤ C₁) : ‖g.comp f‖ ≤ C₂ * C₁ :=\n  le_trans (norm_comp_le g f) <| mul_le_mul hg hf (norm_nonneg _) (le_trans (norm_nonneg _) hg)\n#align normed_add_group_hom.norm_comp_le_of_le NormedAddGroupHom.norm_comp_le_of_le\n\ntheorem norm_comp_le_of_le' {g : NormedAddGroupHom V₂ V₃} (C₁ C₂ C₃ : ℝ) (h : C₃ = C₂ * C₁)\n    (hg : ‖g‖ ≤ C₂) (hf : ‖f‖ ≤ C₁) : ‖g.comp f‖ ≤ C₃ := by\n  rw [h]\n  exact norm_comp_le_of_le hg hf\n#align normed_add_group_hom.norm_comp_le_of_le' NormedAddGroupHom.norm_comp_le_of_le'\n\n/-- Composition of normed groups hom as an additive group morphism. -/\ndef compHom : NormedAddGroupHom V₂ V₃ →+ NormedAddGroupHom V₁ V₂ →+ NormedAddGroupHom V₁ V₃ :=\n  AddMonoidHom.mk'\n    (fun g =>\n      AddMonoidHom.mk' (fun f => g.comp f)\n        (by\n          intros\n          ext\n          exact map_add g _ _))\n    (by\n      intros\n      ext\n      simp only [comp_apply, Pi.add_apply, Function.comp_apply, AddMonoidHom.add_apply,\n        AddMonoidHom.mk'_apply, coe_add])\n#align normed_add_group_hom.comp_hom NormedAddGroupHom.compHom\n\n@[simp]\ntheorem comp_zero (f : NormedAddGroupHom V₂ V₃) : f.comp (0 : NormedAddGroupHom V₁ V₂) = 0 := by\n  ext\n  exact map_zero f\n#align normed_add_group_hom.comp_zero NormedAddGroupHom.comp_zero\n\n@[simp]\ntheorem zero_comp (f : NormedAddGroupHom V₁ V₂) : (0 : NormedAddGroupHom V₂ V₃).comp f = 0 := by\n  ext\n  rfl\n#align normed_add_group_hom.zero_comp NormedAddGroupHom.zero_comp\n\ntheorem comp_assoc {V₄ : Type _} [SeminormedAddCommGroup V₄] (h : NormedAddGroupHom V₃ V₄)\n    (g : NormedAddGroupHom V₂ V₃) (f : NormedAddGroupHom V₁ V₂) :\n    (h.comp g).comp f = h.comp (g.comp f) := by\n  ext\n  rfl\n#align normed_add_group_hom.comp_assoc NormedAddGroupHom.comp_assoc\n\ntheorem coe_comp (f : NormedAddGroupHom V₁ V₂) (g : NormedAddGroupHom V₂ V₃) :\n    (g.comp f : V₁ → V₃) = (g : V₂ → V₃) ∘ (f : V₁ → V₂) :=\n  rfl\n#align normed_add_group_hom.coe_comp NormedAddGroupHom.coe_comp\n\nend NormedAddGroupHom\n\nnamespace NormedAddGroupHom\n\nvariable {V W V₁ V₂ V₃ : Type _} [SeminormedAddCommGroup V] [SeminormedAddCommGroup W]\n  [SeminormedAddCommGroup V₁] [SeminormedAddCommGroup V₂] [SeminormedAddCommGroup V₃]\n\n/-- The inclusion of an `AddSubgroup`, as bounded group homomorphism. -/\n@[simps!]\ndef incl (s : AddSubgroup V) : NormedAddGroupHom s V where\n  toFun := (Subtype.val : s → V)\n  map_add' v w := AddSubgroup.coe_add _ _ _\n  bound' := ⟨1, fun v => by rw [one_mul, AddSubgroup.coe_norm]⟩\n#align normed_add_group_hom.incl NormedAddGroupHom.incl\n\ntheorem norm_incl {V' : AddSubgroup V} (x : V') : ‖incl _ x‖ = ‖x‖ :=\n  rfl\n#align normed_add_group_hom.norm_incl NormedAddGroupHom.norm_incl\n\n/-!### Kernel -/\n\n\nsection Kernels\n\nvariable (f : NormedAddGroupHom V₁ V₂) (g : NormedAddGroupHom V₂ V₃)\n\n/-- The kernel of a bounded group homomorphism. Naturally endowed with a\n`SeminormedAddCommGroup` instance. -/\ndef ker : AddSubgroup V₁ :=\n  f.toAddMonoidHom.ker\n#align normed_add_group_hom.ker NormedAddGroupHom.ker\n\ntheorem mem_ker (v : V₁) : v ∈ f.ker ↔ f v = 0 := by\n  erw [f.toAddMonoidHom.mem_ker, coe_toAddMonoidHom]\n#align normed_add_group_hom.mem_ker NormedAddGroupHom.mem_ker\n\n/-- Given a normed group hom `f : V₁ → V₂` satisfying `g.comp f = 0` for some `g : V₂ → V₃`,\n    the corestriction of `f` to the kernel of `g`. -/\n@[simps]\ndef ker.lift (h : g.comp f = 0) : NormedAddGroupHom V₁ g.ker where\n  toFun v := ⟨f v, by rw [g.mem_ker, ←comp_apply g f, h, zero_apply]⟩\n  map_add' v w := by simp only [map_add, AddSubmonoid.mk_add_mk]\n  bound' := f.bound'\n#align normed_add_group_hom.ker.lift NormedAddGroupHom.ker.lift\n\n@[simp]\ntheorem ker.incl_comp_lift (h : g.comp f = 0) : (incl g.ker).comp (ker.lift f g h) = f := by\n  ext\n  rfl\n#align normed_add_group_hom.ker.incl_comp_lift NormedAddGroupHom.ker.incl_comp_lift\n\n@[simp]\ntheorem ker_zero : (0 : NormedAddGroupHom V₁ V₂).ker = ⊤ := by\n  ext\n  simp [mem_ker]\n#align normed_add_group_hom.ker_zero NormedAddGroupHom.ker_zero\n\ntheorem coe_ker : (f.ker : Set V₁) = (f : V₁ → V₂) ⁻¹' {0} :=\n  rfl\n#align normed_add_group_hom.coe_ker NormedAddGroupHom.coe_ker\n\ntheorem isClosed_ker {V₂ : Type _} [NormedAddCommGroup V₂] (f : NormedAddGroupHom V₁ V₂) :\n    IsClosed (f.ker : Set V₁) :=\n  f.coe_ker ▸ IsClosed.preimage f.continuous (T1Space.t1 0)\n#align normed_add_group_hom.is_closed_ker NormedAddGroupHom.isClosed_ker\n\nend Kernels\n\n/-! ### Range -/\n\n\nsection Range\n\nvariable (f : NormedAddGroupHom V₁ V₂) (g : NormedAddGroupHom V₂ V₃)\n\n/-- The image of a bounded group homomorphism. Naturally endowed with a\n`SeminormedAddCommGroup` instance. -/\ndef range : AddSubgroup V₂ :=\n  f.toAddMonoidHom.range\n#align normed_add_group_hom.range NormedAddGroupHom.range\n\ntheorem mem_range (v : V₂) : v ∈ f.range ↔ ∃ w, f w = v := Iff.rfl\n#align normed_add_group_hom.mem_range NormedAddGroupHom.mem_range\n\n@[simp]\ntheorem mem_range_self (v : V₁) : f v ∈ f.range :=\n  ⟨v, rfl⟩\n#align normed_add_group_hom.mem_range_self NormedAddGroupHom.mem_range_self\n\ntheorem comp_range : (g.comp f).range = AddSubgroup.map g.toAddMonoidHom f.range := by\n  erw [AddMonoidHom.map_range]\n  rfl\n#align normed_add_group_hom.comp_range NormedAddGroupHom.comp_range\n\ntheorem incl_range (s : AddSubgroup V₁) : (incl s).range = s := by\n  ext x\n  exact ⟨fun ⟨y, hy⟩ => by rw [← hy]; simp, fun hx => ⟨⟨x, hx⟩, by simp⟩⟩\n#align normed_add_group_hom.incl_range NormedAddGroupHom.incl_range\n\n@[simp]\ntheorem range_comp_incl_top : (f.comp (incl (⊤ : AddSubgroup V₁))).range = f.range := by\n  simp [comp_range, incl_range, ← AddMonoidHom.range_eq_map]; rfl\n#align normed_add_group_hom.range_comp_incl_top NormedAddGroupHom.range_comp_incl_top\n\nend Range\n\nvariable {f : NormedAddGroupHom V W}\n\n/-- A `NormedAddGroupHom` is *norm-nonincreasing* if `‖f v‖ ≤ ‖v‖` for all `v`. -/\ndef NormNoninc (f : NormedAddGroupHom V W) : Prop :=\n  ∀ v, ‖f v‖ ≤ ‖v‖\n#align normed_add_group_hom.norm_noninc NormedAddGroupHom.NormNoninc\n\nnamespace NormNoninc\n\ntheorem normNoninc_iff_norm_le_one : f.NormNoninc ↔ ‖f‖ ≤ 1 := by\n  refine' ⟨fun h => _, fun h => fun v => _⟩\n  · refine' opNorm_le_bound _ zero_le_one fun v => _\n    simpa [one_mul] using h v\n  · simpa using le_of_opNorm_le f h v\n#align normed_add_group_hom.norm_noninc.norm_noninc_iff_norm_le_one NormedAddGroupHom.NormNoninc.normNoninc_iff_norm_le_one\n\ntheorem zero : (0 : NormedAddGroupHom V₁ V₂).NormNoninc := fun v => by simp\n#align normed_add_group_hom.norm_noninc.zero NormedAddGroupHom.NormNoninc.zero\n\ntheorem id : (id V).NormNoninc := fun _v => le_rfl\n#align normed_add_group_hom.norm_noninc.id NormedAddGroupHom.NormNoninc.id\n\ntheorem comp {g : NormedAddGroupHom V₂ V₃} {f : NormedAddGroupHom V₁ V₂} (hg : g.NormNoninc)\n    (hf : f.NormNoninc) : (g.comp f).NormNoninc := fun v => (hg (f v)).trans (hf v)\n#align normed_add_group_hom.norm_noninc.comp NormedAddGroupHom.NormNoninc.comp\n\n@[simp]\ntheorem neg_iff {f : NormedAddGroupHom V₁ V₂} : (-f).NormNoninc ↔ f.NormNoninc :=\n  ⟨fun h x => by simpa using h x, fun h x => (norm_neg (f x)).le.trans (h x)⟩\n#align normed_add_group_hom.norm_noninc.neg_iff NormedAddGroupHom.NormNoninc.neg_iff\n\nend NormNoninc\n\nsection Isometry\n\ntheorem norm_eq_of_isometry {f : NormedAddGroupHom V W} (hf : Isometry f) (v : V) : ‖f v‖ = ‖v‖ :=\n  (AddMonoidHomClass.isometry_iff_norm f).mp hf v\n#align normed_add_group_hom.norm_eq_of_isometry NormedAddGroupHom.norm_eq_of_isometry\n\ntheorem isometry_id : @Isometry V V _ _ (id V) :=\n  _root_.isometry_id\n#align normed_add_group_hom.isometry_id NormedAddGroupHom.isometry_id\n\ntheorem isometry_comp {g : NormedAddGroupHom V₂ V₃} {f : NormedAddGroupHom V₁ V₂} (hg : Isometry g)\n    (hf : Isometry f) : Isometry (g.comp f) :=\n  hg.comp hf\n#align normed_add_group_hom.isometry_comp NormedAddGroupHom.isometry_comp\n\ntheorem normNoninc_of_isometry (hf : Isometry f) : f.NormNoninc := fun v =>\n  le_of_eq <| norm_eq_of_isometry hf v\n#align normed_add_group_hom.norm_noninc_of_isometry NormedAddGroupHom.normNoninc_of_isometry\n\nend Isometry\n\nvariable {W₁ W₂ W₃ : Type _} [SeminormedAddCommGroup W₁] [SeminormedAddCommGroup W₂]\n  [SeminormedAddCommGroup W₃]\n\nvariable (f) (g : NormedAddGroupHom V W)\n\nvariable {f₁ g₁ : NormedAddGroupHom V₁ W₁}\n\nvariable {f₂ g₂ : NormedAddGroupHom V₂ W₂}\n\nvariable {f₃ g₃ : NormedAddGroupHom V₃ W₃}\n\n/-- The equalizer of two morphisms `f g : NormedAddGroupHom V W`. -/\ndef equalizer :=\n  (f - g).ker\n#align normed_add_group_hom.equalizer NormedAddGroupHom.equalizer\n\nnamespace Equalizer\n\n/-- The inclusion of `f.equalizer g` as a `NormedAddGroupHom`. -/\ndef ι : NormedAddGroupHom (f.equalizer g) V :=\n  incl _\n#align normed_add_group_hom.equalizer.ι NormedAddGroupHom.Equalizer.ι\n\ntheorem comp_ι_eq : f.comp (ι f g) = g.comp (ι f g) := by\n  ext x\n  rw [comp_apply, comp_apply, ← sub_eq_zero, ← NormedAddGroupHom.sub_apply]\n  exact x.2\n#align normed_add_group_hom.equalizer.comp_ι_eq NormedAddGroupHom.Equalizer.comp_ι_eq\n\nvariable {f g}\n\n/-- If `φ : NormedAddGroupHom V₁ V` is such that `f.comp φ = g.comp φ`, the induced morphism\n`NormedAddGroupHom V₁ (f.equalizer g)`. -/\n@[simps]\ndef lift (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) :\n    NormedAddGroupHom V₁ (f.equalizer g)\n    where\n  toFun v :=\n    ⟨φ v,\n      show (f - g) (φ v) = 0 by\n        rw [NormedAddGroupHom.sub_apply, sub_eq_zero, ← comp_apply, h, comp_apply]⟩\n  map_add' v₁ v₂ := by\n    ext\n    simp only [map_add, AddSubgroup.coe_add, Subtype.coe_mk]\n  bound' := by\n    obtain ⟨C, _C_pos, hC⟩ := φ.bound\n    exact ⟨C, hC⟩\n#align normed_add_group_hom.equalizer.lift NormedAddGroupHom.Equalizer.lift\n\n@[simp]\ntheorem ι_comp_lift (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) :\n    (ι _ _).comp (lift φ h) = φ := by\n  ext\n  rfl\n#align normed_add_group_hom.equalizer.ι_comp_lift NormedAddGroupHom.Equalizer.ι_comp_lift\n\n/-- The lifting property of the equalizer as an equivalence. -/\n@[simps]\ndef liftEquiv :\n    { φ : NormedAddGroupHom V₁ V // f.comp φ = g.comp φ } ≃ NormedAddGroupHom V₁ (f.equalizer g)\n    where\n  toFun φ := lift φ φ.prop\n  invFun ψ := ⟨(ι f g).comp ψ, by rw [← comp_assoc, ← comp_assoc, comp_ι_eq]⟩\n  left_inv φ := by simp\n  right_inv ψ := by\n    ext\n    rfl\n#align normed_add_group_hom.equalizer.lift_equiv NormedAddGroupHom.Equalizer.liftEquiv\n\n/-- Given `φ : NormedAddGroupHom V₁ V₂` and `ψ : NormedAddGroupHom W₁ W₂` such that\n`ψ.comp f₁ = f₂.comp φ` and `ψ.comp g₁ = g₂.comp φ`, the induced morphism\n`NormedAddGroupHom (f₁.equalizer g₁) (f₂.equalizer g₂)`. -/\ndef map (φ : NormedAddGroupHom V₁ V₂) (ψ : NormedAddGroupHom W₁ W₂) (hf : ψ.comp f₁ = f₂.comp φ)\n    (hg : ψ.comp g₁ = g₂.comp φ) : NormedAddGroupHom (f₁.equalizer g₁) (f₂.equalizer g₂) :=\n  lift (φ.comp <| ι _ _) <| by\n    simp only [← comp_assoc, ← hf, ← hg]\n    simp only [comp_assoc, comp_ι_eq f₁ g₁]\n#align normed_add_group_hom.equalizer.map NormedAddGroupHom.Equalizer.map\n\nvariable {φ : NormedAddGroupHom V₁ V₂} {ψ : NormedAddGroupHom W₁ W₂}\n\nvariable {φ' : NormedAddGroupHom V₂ V₃} {ψ' : NormedAddGroupHom W₂ W₃}\n\n@[simp]\ntheorem ι_comp_map (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ) :\n    (ι f₂ g₂).comp (map φ ψ hf hg) = φ.comp (ι f₁ g₁) :=\n  ι_comp_lift _ _\n#align normed_add_group_hom.equalizer.ι_comp_map NormedAddGroupHom.Equalizer.ι_comp_map\n\n@[simp]\ntheorem map_id : map (f₂ := f₁) (g₂ := g₁) (id V₁) (id W₁) rfl rfl = id (f₁.equalizer g₁) := by\n  ext\n  rfl\n#align normed_add_group_hom.equalizer.map_id NormedAddGroupHom.Equalizer.map_id\n\ntheorem comm_sq₂ (hf : ψ.comp f₁ = f₂.comp φ) (hf' : ψ'.comp f₂ = f₃.comp φ') :\n    (ψ'.comp ψ).comp f₁ = f₃.comp (φ'.comp φ) := by\n  rw [comp_assoc, hf, ← comp_assoc, hf', comp_assoc]\n#align normed_add_group_hom.equalizer.comm_sq₂ NormedAddGroupHom.Equalizer.comm_sq₂\n\ntheorem map_comp_map (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ)\n    (hf' : ψ'.comp f₂ = f₃.comp φ') (hg' : ψ'.comp g₂ = g₃.comp φ') :\n    (map φ' ψ' hf' hg').comp (map φ ψ hf hg) =\n      map (φ'.comp φ) (ψ'.comp ψ) (comm_sq₂ hf hf') (comm_sq₂ hg hg') := by\n  ext\n  rfl\n#align normed_add_group_hom.equalizer.map_comp_map NormedAddGroupHom.Equalizer.map_comp_map\n\ntheorem ι_normNoninc : (ι f g).NormNoninc := fun _v => le_rfl\n#align normed_add_group_hom.equalizer.ι_norm_noninc NormedAddGroupHom.Equalizer.ι_normNoninc\n\n/-- The lifting of a norm nonincreasing morphism is norm nonincreasing. -/\ntheorem lift_normNoninc (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) (hφ : φ.NormNoninc) :\n    (lift φ h).NormNoninc :=\n  hφ\n#align normed_add_group_hom.equalizer.lift_norm_noninc NormedAddGroupHom.Equalizer.lift_normNoninc\n\n/-- If `φ` satisfies `‖φ‖ ≤ C`, then the same is true for the lifted morphism. -/\ntheorem norm_lift_le (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) (C : ℝ) (hφ : ‖φ‖ ≤ C) :\n    ‖lift φ h‖ ≤ C :=\n  hφ\n#align normed_add_group_hom.equalizer.norm_lift_le NormedAddGroupHom.Equalizer.norm_lift_le\n\ntheorem map_normNoninc (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ)\n    (hφ : φ.NormNoninc) : (map φ ψ hf hg).NormNoninc :=\n  lift_normNoninc _ _ <| hφ.comp ι_normNoninc\n#align normed_add_group_hom.equalizer.map_norm_noninc NormedAddGroupHom.Equalizer.map_normNoninc\n\ntheorem norm_map_le (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ) (C : ℝ)\n    (hφ : ‖φ.comp (ι f₁ g₁)‖ ≤ C) : ‖map φ ψ hf hg‖ ≤ C :=\n  norm_lift_le _ _ _ hφ\n#align normed_add_group_hom.equalizer.norm_map_le NormedAddGroupHom.Equalizer.norm_map_le\n\nend Equalizer\n\nend NormedAddGroupHom\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Analysis/Normed/Group/Hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431679972357831, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.49709040839582785}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin and Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Robert Y. Lewis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.witt_vector.basic\nimport Mathlib.ring_theory.witt_vector.is_poly\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n\n# `init` and `tail`\n\nGiven a Witt vector `x`, we are sometimes interested\nin its components before and after an index `n`.\nThis file defines those operations, proves that `init` is polynomial,\nand shows how that polynomial interacts with `mv_polynomial.bind₁`.\n\n## Main declarations\n\n* `witt_vector.init n x`: the first `n` coefficients of `x`, as a Witt vector. All coefficients at\n  indices ≥ `n` are 0.\n* `witt_vector.tail n x`: the complementary part to `init`. All coefficients at indices < `n` are 0,\n  otherwise they are the same as in `x`.\n* `witt_vector.coeff_add_of_disjoint`: if `x` and `y` are Witt vectors such that for every `n`\n  the `n`-th coefficient of `x` or of `y` is `0`, then the coefficients of `x + y`\n  are just `x.coeff n + y.coeff n`.\n-/\n\nnamespace tactic\n\n\nnamespace interactive\n\n\n/--\n`init_ring` is an auxiliary tactic that discharges goals factoring `init` over ring operations.\n-/\nend interactive\n\n\nend tactic\n\n\nnamespace witt_vector\n\n\n/-- `witt_vector.select P x`, for a predicate `P : ℕ → Prop` is the Witt vector\nwhose `n`-th coefficient is `x.coeff n` if `P n` is true, and `0` otherwise.\n-/\ndef select {p : ℕ} {R : Type u_1} [comm_ring R] (P : ℕ → Prop) (x : witt_vector p R) : witt_vector p R :=\n  mk p fun (n : ℕ) => ite (P n) (coeff x n) 0\n\n/-- The polynomial that witnesses that `witt_vector.select` is a polynomial function.\n`select_poly n` is `X n` if `P n` holds, and `0` otherwise. -/\ndef select_poly (P : ℕ → Prop) (n : ℕ) : mv_polynomial ℕ ℤ :=\n  ite (P n) (mv_polynomial.X n) 0\n\ntheorem coeff_select {p : ℕ} {R : Type u_1} [comm_ring R] (P : ℕ → Prop) (x : witt_vector p R) (n : ℕ) : coeff (select P x) n = coe_fn (mv_polynomial.aeval (coeff x)) (select_poly P n) := sorry\n\ntheorem select_is_poly {p : ℕ} (P : ℕ → Prop) : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) (x : witt_vector p R) => select P x :=\n  Exists.intro (select_poly P)\n    (id fun (R : Type u_1) (_Rcr : comm_ring R) (x : witt_vector p R) => funext fun (i : ℕ) => coeff_select P x i)\n\ntheorem select_add_select_not {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (P : ℕ → Prop) (x : witt_vector p R) : select P x + select (fun (i : ℕ) => ¬P i) x = x := sorry\n\ntheorem coeff_add_of_disjoint {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (h : ∀ (n : ℕ), coeff x n = 0 ∨ coeff y n = 0) : coeff (x + y) n = coeff x n + coeff y n := sorry\n\n/-- `witt_vector.init n x` is the Witt vector of which the first `n` coefficients are those from `x`\nand all other coefficients are `0`.\nSee `witt_vector.tail` for the complementary part.\n-/\ndef init {p : ℕ} {R : Type u_1} [comm_ring R] (n : ℕ) : witt_vector p R → witt_vector p R :=\n  select fun (i : ℕ) => i < n\n\n/-- `witt_vector.tail n x` is the Witt vector of which the first `n` coefficients are `0`\nand all other coefficients are those from `x`.\nSee `witt_vector.init` for the complementary part. -/\ndef tail {p : ℕ} {R : Type u_1} [comm_ring R] (n : ℕ) : witt_vector p R → witt_vector p R :=\n  select fun (i : ℕ) => n ≤ i\n\n@[simp] theorem init_add_tail {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) : init n x + tail n x = x := sorry\n\n@[simp] theorem init_init {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) : init n (init n x) = init n x := sorry\n\ntheorem init_add {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (n : ℕ) : init n (x + y) = init n (init n x + init n y) := sorry\n\ntheorem init_mul {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (n : ℕ) : init n (x * y) = init n (init n x * init n y) := sorry\n\ntheorem init_neg {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) : init n (-x) = init n (-init n x) := sorry\n\ntheorem init_sub {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (n : ℕ) : init n (x - y) = init n (init n x - init n y) := sorry\n\n/-- `witt_vector.init n x` is polynomial in the coefficients of `x`. -/\ntheorem init_is_poly (p : ℕ) (n : ℕ) : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => init n :=\n  select_is_poly fun (i : ℕ) => i < n\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/init_tail.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4970904083958278}}
{"text": "/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n\n! This file was ported from Lean 3 source module number_theory.class_number.admissible_absolute_value\n! leanprover-community/mathlib commit ad0089aca372256fe53dde13ca0dfea569bf5ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Real.Basic\nimport Mathbin.Combinatorics.Pigeonhole\nimport Mathbin.Algebra.Order.EuclideanAbsoluteValue\n\n/-!\n# Admissible absolute values\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\nThis file defines a structure `absolute_value.is_admissible` which we use to show the class number\nof the ring of integers of a global field is finite.\n\n## Main definitions\n\n * `absolute_value.is_admissible abv` states the absolute value `abv : R → ℤ`\n   respects the Euclidean domain structure on `R`, and that a large enough set\n   of elements of `R^n` contains a pair of elements whose remainders are\n   pointwise close together.\n\n## Main results\n\n * `absolute_value.abs_is_admissible` shows the \"standard\" absolute value on `ℤ`,\n   mapping negative `x` to `-x`, is admissible.\n * `polynomial.card_pow_degree_is_admissible` shows `card_pow_degree`,\n   mapping `p : polynomial 𝔽_q` to `q ^ degree p`, is admissible\n-/\n\n\n-- mathport name: «expr ≺ »\nlocal infixl:50 \" ≺ \" => EuclideanDomain.r\n\nnamespace AbsoluteValue\n\nvariable {R : Type _} [EuclideanDomain R]\n\nvariable (abv : AbsoluteValue R ℤ)\n\n#print AbsoluteValue.IsAdmissible /-\n/-- An absolute value `R → ℤ` is admissible if it respects the Euclidean domain\nstructure and a large enough set of elements in `R^n` will contain a pair of\nelements whose remainders are pointwise close together. -/\nstructure IsAdmissible extends IsEuclidean abv where\n  card : ℝ → ℕ\n  exists_partition' :\n    ∀ (n : ℕ) {ε : ℝ} (hε : 0 < ε) {b : R} (hb : b ≠ 0) (A : Fin n → R),\n      ∃ t : Fin n → Fin (card ε), ∀ i₀ i₁, t i₀ = t i₁ → (abv (A i₁ % b - A i₀ % b) : ℝ) < abv b • ε\n#align absolute_value.is_admissible AbsoluteValue.IsAdmissible\n-/\n\nattribute [protected] is_admissible.card\n\nnamespace IsAdmissible\n\nvariable {abv}\n\n/- warning: absolute_value.is_admissible.exists_partition -> AbsoluteValue.IsAdmissible.exists_partition is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : EuclideanDomain.{u1} R] {abv : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))} {ι : Type.{u2}} [_inst_2 : Fintype.{u2} ι] {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (forall {b : R}, (Ne.{succ u1} R b (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))))))) -> (forall (A : ι -> R) (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv), Exists.{succ u2} (ι -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε))) (fun (t : ι -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε))) => forall (i₀ : ι) (i₁ : ι), (Eq.{1} (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε)) (t i₀) (t i₁)) -> (LT.lt.{0} Real Real.hasLt ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int Real (HasLiftT.mk.{1, 1} Int Real (CoeTCₓ.coe.{1, 1} Int Real (Int.castCoe.{0} Real Real.hasIntCast))) (coeFn.{succ u1, succ u1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) (fun (f : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) => R -> Int) (AbsoluteValue.hasCoeToFun.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) abv (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1)))))))) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i₁) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i₀) b)))) (SMul.smul.{0, 0} Int Real (SubNegMonoid.SMulInt.{0} Real (AddGroup.toSubNegMonoid.{0} Real Real.addGroup)) (coeFn.{succ u1, succ u1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) (fun (f : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) => R -> Int) (AbsoluteValue.hasCoeToFun.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) abv b) ε)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : EuclideanDomain.{u1} R] {abv : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))} {ι : Type.{u2}} [_inst_2 : Fintype.{u2} ι] {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (forall {b : R}, (Ne.{succ u1} R b (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) -> (forall (A : ι -> R) (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv), Exists.{succ u2} (ι -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε))) (fun (t : ι -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε))) => forall (i₀ : ι) (i₁ : ι), (Eq.{1} (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε)) (t i₀) (t i₁)) -> (LT.lt.{0} Real Real.instLTReal (Int.cast.{0} Real Real.intCast (FunLike.coe.{succ u1, succ u1, 1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) f) (SubadditiveHomClass.toFunLike.{u1, u1, 0} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R Int (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) (Distrib.toAdd.{0} Int (NonUnitalNonAssocSemiring.toDistrib.{0} Int (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Int (Semiring.toNonAssocSemiring.{0} Int (OrderedSemiring.toSemiring.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))))) (Preorder.toLE.{0} Int (PartialOrder.toPreorder.{0} Int (OrderedSemiring.toPartialOrder.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))) (AbsoluteValue.subadditiveHomClass.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing)))))) abv (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1)))) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i₁) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i₀) b)))) (HSMul.hSMul.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) b) Real Real (instHSMul.{0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) b) Real (SubNegMonoid.SMulInt.{0} Real (AddGroup.toSubNegMonoid.{0} Real Real.instAddGroupReal))) (FunLike.coe.{succ u1, succ u1, 1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) f) (SubadditiveHomClass.toFunLike.{u1, u1, 0} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R Int (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) (Distrib.toAdd.{0} Int (NonUnitalNonAssocSemiring.toDistrib.{0} Int (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Int (Semiring.toNonAssocSemiring.{0} Int (OrderedSemiring.toSemiring.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))))) (Preorder.toLE.{0} Int (PartialOrder.toPreorder.{0} Int (OrderedSemiring.toPartialOrder.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))) (AbsoluteValue.subadditiveHomClass.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing)))))) abv b) ε)))))\nCase conversion may be inaccurate. Consider using '#align absolute_value.is_admissible.exists_partition AbsoluteValue.IsAdmissible.exists_partitionₓ'. -/\n/-- For all `ε > 0` and finite families `A`, we can partition the remainders of `A` mod `b`\ninto `abv.card ε` sets, such that all elements in each part of remainders are close together. -/\ntheorem exists_partition {ι : Type _} [Fintype ι] {ε : ℝ} (hε : 0 < ε) {b : R} (hb : b ≠ 0)\n    (A : ι → R) (h : abv.IsAdmissible) :\n    ∃ t : ι → Fin (h.card ε), ∀ i₀ i₁, t i₀ = t i₁ → (abv (A i₁ % b - A i₀ % b) : ℝ) < abv b • ε :=\n  by\n  let e := Fintype.equivFin ι\n  obtain ⟨t, ht⟩ := h.exists_partition' (Fintype.card ι) hε hb (A ∘ e.symm)\n  refine' ⟨t ∘ e, fun i₀ i₁ h => _⟩\n  convert ht (e i₀) (e i₁) h <;> simp only [e.symm_apply_apply]\n#align absolute_value.is_admissible.exists_partition AbsoluteValue.IsAdmissible.exists_partition\n\n/- warning: absolute_value.is_admissible.exists_approx_aux -> AbsoluteValue.IsAdmissible.exists_approx_aux is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : EuclideanDomain.{u1} R] {abv : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))} (n : Nat) (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv) {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (forall {b : R}, (Ne.{succ u1} R b (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))))))) -> (forall (A : (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) -> (Fin n) -> R), Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) (fun (i₀ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) => Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) (fun (i₁ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) => And (Ne.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) i₀ i₁) (forall (k : Fin n), LT.lt.{0} Real Real.hasLt ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int Real (HasLiftT.mk.{1, 1} Int Real (CoeTCₓ.coe.{1, 1} Int Real (Int.castCoe.{0} Real Real.hasIntCast))) (coeFn.{succ u1, succ u1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) (fun (f : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) => R -> Int) (AbsoluteValue.hasCoeToFun.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) abv (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1)))))))) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i₁ k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i₀ k) b)))) (SMul.smul.{0, 0} Int Real (SubNegMonoid.SMulInt.{0} Real (AddGroup.toSubNegMonoid.{0} Real Real.addGroup)) (coeFn.{succ u1, succ u1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) (fun (f : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) => R -> Int) (AbsoluteValue.hasCoeToFun.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) abv b) ε))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : EuclideanDomain.{u1} R] {abv : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))} (n : Nat) (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv) {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (forall {b : R}, (Ne.{succ u1} R b (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) -> (forall (A : (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) -> (Fin n) -> R), Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) (fun (i₀ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) => Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) (fun (i₁ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) => And (Ne.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) n))) i₀ i₁) (forall (k : Fin n), LT.lt.{0} Real Real.instLTReal (Int.cast.{0} Real Real.intCast (FunLike.coe.{succ u1, succ u1, 1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) f) (SubadditiveHomClass.toFunLike.{u1, u1, 0} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R Int (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) (Distrib.toAdd.{0} Int (NonUnitalNonAssocSemiring.toDistrib.{0} Int (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Int (Semiring.toNonAssocSemiring.{0} Int (OrderedSemiring.toSemiring.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))))) (Preorder.toLE.{0} Int (PartialOrder.toPreorder.{0} Int (OrderedSemiring.toPartialOrder.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))) (AbsoluteValue.subadditiveHomClass.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing)))))) abv (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1)))) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i₁ k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i₀ k) b)))) (HSMul.hSMul.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) b) Real Real (instHSMul.{0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) b) Real (SubNegMonoid.SMulInt.{0} Real (AddGroup.toSubNegMonoid.{0} Real Real.instAddGroupReal))) (FunLike.coe.{succ u1, succ u1, 1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) f) (SubadditiveHomClass.toFunLike.{u1, u1, 0} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R Int (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) (Distrib.toAdd.{0} Int (NonUnitalNonAssocSemiring.toDistrib.{0} Int (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Int (Semiring.toNonAssocSemiring.{0} Int (OrderedSemiring.toSemiring.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))))) (Preorder.toLE.{0} Int (PartialOrder.toPreorder.{0} Int (OrderedSemiring.toPartialOrder.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))) (AbsoluteValue.subadditiveHomClass.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing)))))) abv b) ε))))))\nCase conversion may be inaccurate. Consider using '#align absolute_value.is_admissible.exists_approx_aux AbsoluteValue.IsAdmissible.exists_approx_auxₓ'. -/\n/-- Any large enough family of vectors in `R^n` has a pair of elements\nwhose remainders are close together, pointwise. -/\ntheorem exists_approx_aux (n : ℕ) (h : abv.IsAdmissible) :\n    ∀ {ε : ℝ} (hε : 0 < ε) {b : R} (hb : b ≠ 0) (A : Fin (h.card ε ^ n).succ → Fin n → R),\n      ∃ i₀ i₁, i₀ ≠ i₁ ∧ ∀ k, (abv (A i₁ k % b - A i₀ k % b) : ℝ) < abv b • ε :=\n  by\n  haveI := Classical.decEq R\n  induction' n with n ih\n  · intro ε hε b hb A\n    refine' ⟨0, 1, _, _⟩\n    · simp\n    rintro ⟨i, ⟨⟩⟩\n  intro ε hε b hb A\n  set M := h.card ε with hM\n  -- By the \"nicer\" pigeonhole principle, we can find a collection `s`\n  -- of more than `M^n` remainders where the first components lie close together:\n  obtain ⟨s, s_inj, hs⟩ :\n    ∃ s : Fin (M ^ n).succ → Fin (M ^ n.succ).succ,\n      Function.Injective s ∧ ∀ i₀ i₁, (abv (A (s i₁) 0 % b - A (s i₀) 0 % b) : ℝ) < abv b • ε :=\n    by\n    -- We can partition the `A`s into `M` subsets where\n    -- the first components lie close together:\n    obtain ⟨t, ht⟩ :\n      ∃ t : Fin (M ^ n.succ).succ → Fin M,\n        ∀ i₀ i₁, t i₀ = t i₁ → (abv (A i₁ 0 % b - A i₀ 0 % b) : ℝ) < abv b • ε :=\n      h.exists_partition hε hb fun x => A x 0\n    -- Since the `M` subsets contain more than `M * M^n` elements total,\n    -- there must be a subset that contains more than `M^n` elements.\n    obtain ⟨s, hs⟩ :=\n      @Fintype.exists_lt_card_fiber_of_mul_lt_card _ _ _ _ _ t (M ^ n)\n        (by simpa only [Fintype.card_fin, pow_succ] using Nat.lt_succ_self (M ^ n.succ))\n    refine'\n      ⟨fun i => (finset.univ.filter fun x => t x = s).toList.nthLe i _, _, fun i₀ i₁ => ht _ _ _⟩\n    · refine' i.2.trans_le _\n      rwa [Finset.length_toList]\n    · intro i j h\n      ext\n      exact list.nodup_iff_nth_le_inj.mp (Finset.nodup_toList _) _ _ _ _ h\n    have :\n      ∀ i h,\n        (finset.univ.filter fun x => t x = s).toList.nthLe i h ∈\n          finset.univ.filter fun x => t x = s :=\n      by\n      intro i h\n      exact finset.mem_to_list.mp (List.nthLe_mem _ _ _)\n    obtain ⟨_, h₀⟩ := finset.mem_filter.mp (this i₀ _)\n    obtain ⟨_, h₁⟩ := finset.mem_filter.mp (this i₁ _)\n    exact h₀.trans h₁.symm\n  -- Since `s` is large enough, there are two elements of `A ∘ s`\n  -- where the second components lie close together.\n  obtain ⟨k₀, k₁, hk, h⟩ := ih hε hb fun x => Fin.tail (A (s x))\n  refine' ⟨s k₀, s k₁, fun h => hk (s_inj h), fun i => Fin.cases _ (fun i => _) i⟩\n  · exact hs k₀ k₁\n  · exact h i\n#align absolute_value.is_admissible.exists_approx_aux AbsoluteValue.IsAdmissible.exists_approx_aux\n\n/- warning: absolute_value.is_admissible.exists_approx -> AbsoluteValue.IsAdmissible.exists_approx is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : EuclideanDomain.{u1} R] {abv : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))} {ι : Type.{u2}} [_inst_2 : Fintype.{u2} ι] {ε : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) ε) -> (forall {b : R}, (Ne.{succ u1} R b (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))))))) -> (forall (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv) (A : (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) -> ι -> R), Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) (fun (i₀ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) => Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) (fun (i₁ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) => And (Ne.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) i₀ i₁) (forall (k : ι), LT.lt.{0} Real Real.hasLt ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int Real (HasLiftT.mk.{1, 1} Int Real (CoeTCₓ.coe.{1, 1} Int Real (Int.castCoe.{0} Real Real.hasIntCast))) (coeFn.{succ u1, succ u1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) (fun (f : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) => R -> Int) (AbsoluteValue.hasCoeToFun.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) abv (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1)))))))) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i₁ k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i₀ k) b)))) (SMul.smul.{0, 0} Int Real (SubNegMonoid.SMulInt.{0} Real (AddGroup.toSubNegMonoid.{0} Real Real.addGroup)) (coeFn.{succ u1, succ u1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) (fun (f : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) => R -> Int) (AbsoluteValue.hasCoeToFun.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (StrictOrderedSemiring.toOrderedSemiring.{0} Int (StrictOrderedRing.toStrictOrderedSemiring.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) abv b) ε))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : EuclideanDomain.{u1} R] {abv : AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))} {ι : Type.{u2}} [_inst_2 : Fintype.{u2} ι] {ε : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) ε) -> (forall {b : R}, (Ne.{succ u1} R b (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) -> (forall (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv) (A : (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) -> ι -> R), Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) (fun (i₀ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) => Exists.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) (fun (i₁ : Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) => And (Ne.{1} (Fin (Nat.succ (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h ε) (Fintype.card.{u2} ι _inst_2)))) i₀ i₁) (forall (k : ι), LT.lt.{0} Real Real.instLTReal (Int.cast.{0} Real Real.intCast (FunLike.coe.{succ u1, succ u1, 1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) f) (SubadditiveHomClass.toFunLike.{u1, u1, 0} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R Int (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) (Distrib.toAdd.{0} Int (NonUnitalNonAssocSemiring.toDistrib.{0} Int (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Int (Semiring.toNonAssocSemiring.{0} Int (OrderedSemiring.toSemiring.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))))) (Preorder.toLE.{0} Int (PartialOrder.toPreorder.{0} Int (OrderedSemiring.toPartialOrder.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))) (AbsoluteValue.subadditiveHomClass.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing)))))) abv (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1)))) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i₁ k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i₀ k) b)))) (HSMul.hSMul.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) b) Real Real (instHSMul.{0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) b) Real (SubNegMonoid.SMulInt.{0} Real (AddGroup.toSubNegMonoid.{0} Real Real.instAddGroupReal))) (FunLike.coe.{succ u1, succ u1, 1} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => Int) f) (SubadditiveHomClass.toFunLike.{u1, u1, 0} (AbsoluteValue.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))) R Int (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))))))) (Distrib.toAdd.{0} Int (NonUnitalNonAssocSemiring.toDistrib.{0} Int (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Int (Semiring.toNonAssocSemiring.{0} Int (OrderedSemiring.toSemiring.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))))) (Preorder.toLE.{0} Int (PartialOrder.toPreorder.{0} Int (OrderedSemiring.toPartialOrder.{0} Int (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing))))))) (AbsoluteValue.subadditiveHomClass.{u1, 0} R Int (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R (EuclideanDomain.toCommRing.{u1} R _inst_1))) (OrderedCommSemiring.toOrderedSemiring.{0} Int (StrictOrderedCommSemiring.toOrderedCommSemiring.{0} Int (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{0} Int (LinearOrderedCommRing.toLinearOrderedCommSemiring.{0} Int Int.linearOrderedCommRing)))))) abv b) ε))))))\nCase conversion may be inaccurate. Consider using '#align absolute_value.is_admissible.exists_approx AbsoluteValue.IsAdmissible.exists_approxₓ'. -/\n/-- Any large enough family of vectors in `R^ι` has a pair of elements\nwhose remainders are close together, pointwise. -/\ntheorem exists_approx {ι : Type _} [Fintype ι] {ε : ℝ} (hε : 0 < ε) {b : R} (hb : b ≠ 0)\n    (h : abv.IsAdmissible) (A : Fin (h.card ε ^ Fintype.card ι).succ → ι → R) :\n    ∃ i₀ i₁, i₀ ≠ i₁ ∧ ∀ k, (abv (A i₁ k % b - A i₀ k % b) : ℝ) < abv b • ε :=\n  by\n  let e := Fintype.equivFin ι\n  obtain ⟨i₀, i₁, ne, h⟩ := h.exists_approx_aux (Fintype.card ι) hε hb fun x y => A x (e.symm y)\n  refine' ⟨i₀, i₁, Ne, fun k => _⟩\n  convert h (e k) <;> simp only [e.symm_apply_apply]\n#align absolute_value.is_admissible.exists_approx AbsoluteValue.IsAdmissible.exists_approx\n\nend IsAdmissible\n\nend AbsoluteValue\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/NumberTheory/ClassNumber/AdmissibleAbsoluteValue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431679972357831, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.49709040349047157}}
{"text": "import tactic general set_lemmas linear_algebra.basis new_free ring_theory.principal_ideal_domain torsion primes\nrun_cmd tactic.skip\nopen_locale classical\n\nvariables {R : Type*} [integral_domain R] [is_principal_ideal_ring R]\n\nnoncomputable def projection {ι : Type*} {M : Type*} [add_comm_group M] [module R M]\n  (v : ι → M) (hv : is_basis R v) (a : ι) :\n  linear_map R M M :=\n{ to_fun := λ x, x - hv.repr x a • v a,\n  map_add' := λ x y, by {show (x + y) - hv.repr (x + y) a • v a = (x - _) + (y - _),\n  rw linear_map.map_add, erw add_smul, abel, },\n  map_smul' := λ c x, by {show c • x - hv.repr (c • x) a • v a = c • (x - _),\n  rw linear_map.map_smul, rw smul_sub, rw ←mul_smul, refl, } }\n\ntheorem proj_mem {ι : Type*} {M : Type*} [add_comm_group M] [module R M]\n  {s : set ι} {v : ι → M} (hv : is_basis R (v ∘ subtype.val : s → M)) {a : ι} (ha : a ∈ s) {x : M} :\n  projection _ hv ⟨a, ha⟩ x ∈ submodule.span R (set.range (v ∘ subtype.val : (s \\ {a} → M))) :=\nbegin\n  show _ - _ ∈ _,\n  conv {to_lhs, congr, rw ←hv.total_repr x},\n  cases classical.em ((⟨a, ha⟩ : s) ∈ (hv.repr x).support),\n  rw finsupp.total_apply, unfold finsupp.sum,\n  rw ←finset.insert_erase h,\n  erw finset.sum_insert (finset.not_mem_erase (⟨a, ha⟩ : s) (hv.repr x).support),\n  simp only [add_sub_cancel', function.comp_app],\n  refine @submodule.sum_mem R M _ _ _ _ (submodule.span R (set.range (v ∘ subtype.val))) (((hv.repr) x).support.erase ⟨a, ha⟩)\n  (λ (y : s), ((hv.repr) x) y • v y.val) _,\n  intros y hy, dsimp,\n  apply submodule.smul_mem (submodule.span R (set.range (v ∘ subtype.val))) _,\n  apply submodule.subset_span, use y,\n  rw set.mem_diff, split,\n  exact y.2,\n  intro hya,\n  have hyan : y = ⟨a, ha⟩ := subtype.ext_iff.2 hya,\n  exact (finset.ne_of_mem_erase hy) hyan,\n  rw finsupp.not_mem_support_iff.1 h, rw zero_smul, rw sub_zero,\n    refine @submodule.sum_mem R M _ _ _ _ (submodule.span R (set.range (v ∘ subtype.val)))\n      (((hv.repr) x).support)\n  (λ (y : s), ((hv.repr) x) y • v y.val) _,\n  intros y hy, dsimp,\n  apply submodule.smul_mem (submodule.span R (set.range (v ∘ subtype.val))) _,\n  apply submodule.subset_span, use y,\n  rw set.mem_diff, split,\n  exact y.2,\n  intro hya,\n  have hyan : y = ⟨a, ha⟩ := subtype.ext_iff.2 hya,\n  rw hyan at hy, exact h hy,\nend\n\nlemma proj_ker {ι : Type*} {M : Type*} [add_comm_group M] [module R M]\n  {s : set ι} {v : ι → M} (hv : is_basis R (v ∘ subtype.val : s → M)) {a : ι} (ha : a ∈ s) :\n  (projection _ hv ⟨a, ha⟩).ker = submodule.span R {v a} :=\nbegin\n  ext,\n  split,\n  intro hx,\n  rw linear_map.mem_ker at hx,\n  erw sub_eq_zero at hx,\n  rw submodule.mem_span_singleton,\n  use hv.repr x ⟨a, ha⟩,\n  exact hx.symm,\n  intro hx,\n  rw submodule.mem_span_singleton at hx,\n  cases hx with r hr,\n  rw linear_map.mem_ker,\n  erw sub_eq_zero,\n  rw ←hr, rw linear_map.map_smul,\n  have := @is_basis.repr_eq_single _ _ _ _ _ _ _ hv ⟨a, ha⟩,\n  have hh : hv.repr ((v ∘ subtype.val) (⟨a, ha⟩ : s)) (⟨a, ha⟩ : s) = (1 : R) := by\n    rw this; exact finsupp.single_eq_same,\n  simp only [finsupp.smul_apply, algebra.id.smul_eq_mul, function.comp_app],\n  rw mul_comm,\n  rw mul_smul,\n  rw hh, rw one_smul,\nend\n\nlemma projective_of_has_basis {ι : Type*} {M : Type*} [add_comm_group M] [module R M]\n  {v : ι → M} (hv : is_basis R v) :\n  projective R M :=\nbegin\n  intros _ _ _ _ _ _ _ _ hg,\n  let F' := λ i : ι, classical.some (hg (f (v i))),\n  let F := @is_basis.constr _ _ _ _ _ _ _ _inst_6 _ _inst_7 hv F',\n  use F,\n  have huh : ∀ i : ι, g (F $ v i) = f (v i) := by {\n  intro i, rw constr_basis, exact classical.some_spec (hg (f $ v i))},\n  have : @linear_map.comp R M A B _ _ (@add_comm_group.to_add_comm_monoid A _inst_6)\n   (@add_comm_group.to_add_comm_monoid B _inst_7_1) _ _ _ g F = f := @is_basis.ext\n     _ _ _ _ _ _ _ _inst_7_1 _ _inst_7_2 (@linear_map.comp R M A B _ _\n     (@add_comm_group.to_add_comm_monoid A _inst_6) (@add_comm_group.to_add_comm_monoid B _inst_7_1)\n     _ _ _ g F) f\n    hv (λ x, huh x),\n  intro x,\n  rw ←this,\n  refl,\nend\n\nlemma split_of_left_inv {M : Type*} [add_comm_group M] [module R M] (A : submodule R M)\n{B : Type*} [add_comm_group B] [module R B] (f : M →ₗ[R] B) (H : A.subtype.range = f.ker)\n(g : B →ₗ[R] M) (hfg : f.comp g = linear_map.id) (hf : f.range = ⊤) :\n  A ⊓ g.range = ⊥ ∧ A ⊔ g.range = ⊤ :=\nbegin\n  split,\n  rw eq_bot_iff,\n  intros x hx,\n  refine (submodule.mem_bot R).2 _,\n  cases hx.2 with y hy,\n  have : f x = 0, by {rw ←linear_map.mem_ker, rw ←H, exact ⟨⟨x, hx.1⟩, trivial, rfl⟩},\n  rw ←hy.2 at this, rw ←linear_map.comp_apply at this,\n  rw hfg at this,\n  rw linear_map.id_apply at this,\n  rw ←hy.2,\n  rw this,\n  rw g.map_zero,\n  rw eq_top_iff,\n  intros x _,\n  apply submodule.mem_sup.2,\n  clear a,\n  use x - g (f x),\n  split,\n  rw ←submodule.range_subtype A, rw H,\n  rw linear_map.mem_ker,\n  rw linear_map.map_sub,\n  show f x - f.comp g (f x) = 0,\n  rw hfg,\n  exact sub_self (f x),\n  use g (f x),\n  split,\n  exact linear_map.mem_range.2 ⟨f x, rfl⟩,\n  rw sub_add_cancel,\nend\n\nvariables {ι : Type*} {M : Type*} (s : set ι)\n  [fintype ι] [add_comm_group M]\n  [module R M] (v : ι → M)\n  (a : ι)\n\nvariables (R)\n\ndef wtf' (i : (s \\ ({a} : set ι) : set ι)) : submodule.span R\n  (set.range (v ∘ subtype.val : s \\ {a} → M)) :=\nsubtype.mk ((v ∘ subtype.val) i) (submodule.subset_span $ set.mem_range_self i)\n\nvariables {R}\nlemma is_basis_diff {n : ℕ} {ι : Type*} {M : Type*} {s : set ι}\n  [fintype ι] (hs : fintype.card ↥s = nat.succ n) [add_comm_group M]\n  [module R M] {v : ι → M} (hv : is_basis R (v ∘ subtype.val : s → M))\n  {a : ι} (ha : a ∈ s) :\n is_basis R (wtf' R s v a ∘ (subtype.val : (@set.univ (s \\ ({a} : set ι) : set ι) : set _) →\n   (s \\ ({a} : set ι) : set ι))) :=\nbegin\n  split,\n  refine linear_independent.comp _ subtype.val subtype.val_injective,\n  apply linear_independent_span,\n  dsimp,\n  cases hv with hv1 hv2,\n  have := linear_independent.to_subtype_range hv1,\n  have H := linear_independent.mono (show (set.range (v ∘ subtype.val : s \\ {a} → M) ⊆\n  set.range (v ∘ subtype.val : s → M)), by\n  {rw set.range_subset_iff, intro y,\n  exact ⟨⟨(y : ι), set.diff_subset _ _ y.2⟩, rfl⟩}) this,\n  refine linear_independent.of_subtype_range _ H,\n  have hi := linear_independent.injective hv1,\n  intros x y h,\n  have hxy : (⟨(x : ι), set.diff_subset _ _ x.2⟩ : s) = (⟨(y : ι), set.diff_subset _ _ y.2⟩ : s) :=\n  hi (by simpa only [function.comp_app] using h),\n  apply subtype.ext_iff.2, simpa only [] using hxy,\n  refine linear_map.map_injective (submodule.ker_subtype _) _,\n  rw submodule.map_subtype_top, rw ←submodule.span_image,\n  rw ←set.range_comp, congr' 1,\n  ext,\n  split,\n  rintro ⟨y, hy⟩, simp only [submodule.subtype_apply, function.comp_app, wtf'] at hy,\n  rw ←hy, use y.1, refl,\n  rintro ⟨y, hy⟩,\n  rw ←hy, use y, simp only [wtf', submodule.subtype_apply, submodule.coe_mk, function.comp_app],\nend\n\ntheorem free_subm0 (ι : Type*) [fintype ι] (s : set ι) (hs : fintype.card s = 0)\n  (M : Type*) [add_comm_group M] [module R M] (v : ι → M)\n  (hv : is_basis R (v ∘ (subtype.val : s → ι)))\n  (S : submodule R M) : ∃ (t : set M), linear_independent R (λ x, x : t → M) ∧\n    submodule.span R (set.range (λ x, x : t → M)) = S :=\nbegin\n  use ∅,\n  split,\n  exact linear_independent_empty R M,\n  cases hv with hv1 hv2,\n  have hs := fintype.card_eq_zero_iff.1 hs,\n  erw subtype.range_coe_subtype, erw submodule.span_empty,\n  suffices : ∀ x : M, x = 0, by {symmetry, rw eq_bot_iff, intros x hx, apply (submodule.mem_bot R).2,\n    exact this (x : M)},\n  intro x,\n  have : set.range (v ∘ (subtype.val : s → ι )) = ∅ :=\n  by {apply set.range_eq_empty.2, intro h, cases h with y hy, exact hs y },\n  rw this at hv2, rw submodule.span_empty at hv2,\n  apply (submodule.mem_bot R).1, rw hv2, exact submodule.mem_top,\nend\n\nnoncomputable def free_equiv {ι : Type*} (x : ι)\n  {M : Type*} [add_comm_group M] [module R M] {v : ι → M}\n  (hv : is_basis R (v ∘ (subtype.val : ({x}: set ι) → ι))) :\n  linear_equiv R R M :=\nequiv_of_is_basis (@is_basis_singleton_one ({x} : set ι) R\n  (set.unique_singleton x) _) hv (equiv.refl _)\n\n\nlemma free_subm1 (ι : Type*) [fintype ι] (s : set ι) (hs : ¬ 1 < fintype.card s)\n  (M : Type*) [add_comm_group M] [module R M] (v : ι → M) (hv : is_basis R (v ∘ (subtype.val : s → ι)))\n  (S : submodule R M) : ∃ (t : set M), linear_independent R (λ x, x : t → M) ∧\n    submodule.span R (set.range (λ x, x : t → M)) = S :=\nbegin\n  cases classical.em (S = ⊥),\n  use ∅, split, exact linear_independent_empty _ _, rw h, simp,\n  have : fintype.card s = 0 ∨ fintype.card s = 1 := by omega,\n  cases this with hl hr, exact free_subm0 ι s hl M v hv S,\n  cases fintype.card_eq_one_iff.1 hr with y hy,\n  have hrange : set.range (v ∘ subtype.val) = {(v ∘ subtype.val) y} := by {rw ←set.image_univ,\n  convert set.image_singleton, symmetry, rw ←set.univ_subset_iff, intros t ht, exact hy t,},\n  have hys : {(y : ι)} = s := by {ext a, split, intro ha, convert y.2, intro ha,\n  exact subtype.ext_iff.1 (hy ⟨a, ha⟩)},\n  let Smap := S.map (@free_equiv R _ _ ι (y : ι) M _ _ v (hys.symm ▸ hv)).symm.to_linear_map,\n  cases submodule.is_principal.principal Smap with c hc,\n  let C := @free_equiv R _ _ ι (y : ι) M _ _ v (hys.symm ▸ hv) c,\n  use {C},\n  have hCy : C ∈ submodule.span R {(v ∘ subtype.val) y} := by {rw ←hrange, rw hv.2,\n  exact submodule.mem_top,},\n  cases submodule.mem_span_singleton.1 hCy with r hr,\n  have hCS : S = submodule.span R {C} := by {simp only [Smap, C] at hc ⊢, rw ←set.image_singleton,\n    erw submodule.span_image,\n   rw ←hc, rw ←submodule.map_comp, symmetry, convert submodule.map_id S, ext z,\n   exact linear_equiv.apply_symm_apply (@free_equiv R _ _ ι (y : ι) M _ _ v (hys.symm ▸ hv)) z,},\n  have hC0 : C ≠ 0 := λ hC0, by {rw hC0 at hCS, change S = submodule.span R (⊥ : submodule R M) at hCS,\n    erw submodule.span_eq at hCS, exact h hCS},\n  have hr0 : r ≠ 0 := λ hr0, by {rw hr0 at hr, rw zero_smul at hr, apply hC0, exact hr.symm},\n  split,\n  refine linear_independent.mono _ _, exact {r • v (y : ι)}, rw ←hr,\n  rw set.singleton_subset_iff, exact set.mem_singleton _,\n  have hry : {r • v (y : ι)} = set.range (λ m : s, r • (v ∘ subtype.val) m) :=\n    by {rw ←set.image_univ, erw ←@set.image_singleton _ _ (λ m : s, r • (v ∘ subtype.val) m) y,\n     congr, exact set.eq_univ_of_forall hy},\n  rw hry,\n  apply linear_independent.to_subtype_range, rw linear_independent_iff,\n  have hv1 := linear_independent_iff.1 hv.1, intros l hl,\n  let L : {x // x ∈ s} →₀ R := finsupp.map_range (λ m, r • m) (smul_zero r) l,\n  have hvL := hv1 L (by {rw finsupp.total_apply at hl ⊢, unfold finsupp.sum,\n    simp only [finsupp.map_range_apply],\n  rw finset.sum_subset (finsupp.support_map_range), convert hl,dsimp,\n    simp only [mul_comm r, mul_smul], refl,\n  intros X hX hX0, have hm := finsupp.not_mem_support_iff.1 hX0,\n  rw finsupp.map_range_apply at hm,rw hm, rw zero_smul,\n  }),\n  ext,\n  rw finsupp.ext_iff at hvL, specialize hvL a,\n  exact or.resolve_left (mul_eq_zero.1 hvL) hr0,\n  convert hCS.symm,\n  simp only [subtype.range_coe_subtype], refl,\nend\n\nlemma one_empty {n : ℕ} {ι : Type*} {M : Type*} {s : set ι} [hι : fintype ι]\n  (hs : fintype.card ↥s = n.succ)\n[add_comm_group M] [module R M] {v : ι → M} (hv : is_basis R (v ∘ subtype.val : s → M))\n{S : submodule R M} (h1 : 1 < fintype.card ↥s) {b : ι} (hb : b ∈ s)\n{t : set ↥(submodule.span R (set.range (v ∘ subtype.val : s \\ {b} → M)))}\n(ht : linear_independent R (λ (x : t), (↑x : submodule.span R (set.range\n (v ∘ subtype.val : s \\ {b} → M)))) ∧ submodule.span R (set.range (λ (x : ↥t),\n (↑x : submodule.span R (set.range\n (v ∘ subtype.val : s \\ {b} → M))))) =\n      submodule.map\n        (linear_map.cod_restrict (submodule.span R (set.range (v ∘ subtype.val)))\n           (projection (v ∘ subtype.val) hv ⟨b, hb⟩)\n           (λ c, proj_mem hv hb))\n        S)\n{l : set ↥((projection (v ∘ subtype.val) hv ⟨b, hb⟩).ker)}\n(hl :\n  linear_independent R (λ (x : ↥l), (↑x : (projection (v ∘ subtype.val) hv ⟨b, hb⟩).ker)) ∧\n    submodule.span R (set.range (λ (x : ↥l), (↑x : (projection (v ∘ subtype.val) hv ⟨b, hb⟩).ker))) =\n    ((submodule.of_le $ @inf_le_right _ _ S (projection _ hv ⟨b, hb⟩).ker).range))\n(h : l = ∅) :\n∃ (t : set M),\n    linear_independent R (λ (x : ↥t), (↑x : M)) ∧ submodule.span R (set.range (λ (x : ↥t), ↑x)) = S :=\nbegin\n  use (submodule.span R (set.range (v ∘ subtype.val : s \\ {b} → M))).subtype '' t,\n  split,\n  apply linear_independent.image_subtype,\n  exact ht.1,\n  simp only [disjoint_bot_right, submodule.ker_subtype],\n  simp only [submodule.subtype_apply, subtype.range_coe_subtype],\n  show submodule.span R ((submodule.span R (set.range (v ∘ subtype.val))).subtype '' t) = S,\n  rw submodule.span_image,\n  apply le_antisymm,\n  rw submodule.map_le_iff_le_comap,\n  intros y hy,\n  simp only [submodule.mem_comap, submodule.subtype_apply],\n  sorry, sorry,\nend\n\ntheorem free_subm (ι : Type*) [fintype ι] (s : set ι) (n : ℕ) (hs : fintype.card s = n)\n  (M : Type*) [add_comm_group M] [module R M] (v : ι → M) (hv : is_basis R (v ∘ (subtype.val : s → ι)))\n  (S : submodule R M) : ∃ (t : set M), linear_independent R (λ x, x : t → M) ∧ submodule.span R (set.range (λ x, x : t → M)) = S :=\nbegin\n  unfreezingI {revert ι M s,\n  induction n using nat.case_strong_induction_on with n hn},\n  intros ι M s hι h0 inst inst' v hv S,\n    exact @free_subm0 _ _ _ ι hι s h0 M inst inst' v hv S,\n  intros ι M s hι hs _ _ v hv S,\n  resetI,\n  cases (classical.em (1 < fintype.card s)) with h1 h1,\n  rcases fintype.card_pos_iff.1 (show 0 < fintype.card s, by omega) with ⟨b, hb⟩,\n  rcases hn n (nat.le_refl n) (s \\ ({b} : set ι) : set ι)\n    (submodule.span R (set.range (v ∘ subtype.val : (s \\ ({b} : set ι)) → M))) (set.univ)\n  (by {\n    apply (add_right_inj 1).1, rw add_comm 1 n, rw ←nat.succ_eq_add_one n, rw ← hs,\n    erw univ_card'', rw add_comm,\n    rw (card_insert' (s \\ ({b} : set ι)) not_mem_diff_singleton).symm,\n    congr, rw ←eq_insert_erase_of_mem s b hb, apply_instance, apply_instance})\n    (λ i, ⟨v i, submodule.subset_span $ set.mem_range_self i⟩)\n    (by convert is_basis_diff hs hv hb)\n   (S.map $ (projection _ hv ⟨b, hb⟩).cod_restrict (submodule.span R (set.range\n     (v ∘ subtype.val : (s \\ ({b} : set ι)) → M)))\n   (λ c, proj_mem hv hb)) with ⟨t, ht⟩,\n  rcases hn 1 (by omega) ({b} : set ι) (projection _ hv ⟨b, hb⟩).ker set.univ sorry\n    (λ x, ⟨v x, by {rw proj_ker,apply submodule.subset_span,convert set.mem_singleton _, exact x.2.symm}⟩)\n  (by {split,\n  suffices : linear_independent R (v ∘ subtype.val : ({b} : set ι) → M), by\n    {  apply linear_independent.comp _ subtype.val subtype.val_injective,\n       erw linear_independent_comp_subtype at this,\n       rw linear_independent_iff,intros l hl,\n       specialize this (finsupp.emb_domain (function.embedding.subtype ({b} : set ι)) l)\n         (by {rw finsupp.mem_supported, rw finsupp.support_emb_domain,\n         intros x hx, rcases finset.mem_map.1 hx with ⟨y, hym, hy⟩,\n         rw ←hy, exact y.2}), rw finsupp.total_apply at hl,\n      rw finsupp.total_emb_domain at this,rw finsupp.total_apply at this,\n      simp only [function.comp_app] at this,\n      change ((l.sum (λ (i : ({b} : set ι)) (c : R), c • v (↑i : ι)) = 0) →\n  (finsupp.emb_domain (function.embedding.subtype ({b} : set ι)) l = 0)) at this,\n     specialize this (by {rw subtype.ext_iff at hl,dsimp at hl,rw ←hl,\n     show _ = submodule.subtype _ _,\n     conv_rhs {rw ←finsupp.total_apply},\n     rw linear_map.map_finsupp_total, rw finsupp.total_apply,\n     apply finset.sum_congr rfl, intros x hx, simp only [submodule.subtype_apply, submodule.coe_mk,\n     function.comp_app], }),\n     rw finsupp.ext_iff at this,ext,specialize this a,erw finsupp.emb_domain_apply at this,\n     rw this,simp only [finsupp.zero_apply], },\n  have huh := linear_independent.to_subtype_range hv.1,\n  have hm := linear_independent.mono (show set.range (v ∘ subtype.val : ({b} : set ι) → M) ⊆\n    set.range (v ∘ subtype.val : s → M), by\n  {rw set.range_subset_iff, intro y, use b, exact hb, rw ←subtype.eta y y.2, simp only\n    [function.comp_app, subtype.eta],\n  exact congr_arg v y.2.symm,\n  }) huh,\n  apply linear_independent.of_subtype_range, intros c d hcd,\n  rw subtype.ext_iff, rw (show (c : ι) = b, from c.2), symmetry, exact d.2, exact hm,\n  apply linear_map.map_injective (projection _ hv ⟨b, hb⟩).ker.ker_subtype,\n  rw submodule.map_subtype_top, rw ←submodule.span_image, symmetry,\n  convert proj_ker hv hb,\n  rw ←set.range_comp,\n  ext m,\n  split,\n  rintro ⟨k, hk⟩,\n  rw ← hk, show _ = _, simpa only [] using congr_arg v k.1.2,\n  intro hm, use b, exact set.mem_singleton _, rw (show _ = _, from hm), refl,\n  })\n  (submodule.of_le $ @inf_le_right _ _ S (projection _ hv ⟨b, hb⟩).ker).range with ⟨l, hl⟩,\n  cases (classical.em (l = ∅)),\n    exact one_empty hs hv h1 hb ht hl h,\n  let V := (submodule.span R (set.range (v ∘ subtype.val : (s \\ ({b} : set ι)) → M))).subtype '' t,\n  let W := (projection (v ∘ subtype.val) hv ⟨b, hb⟩).ker.subtype '' l,\n  use V ∪ W,\n  refine union_is_basis_of_gen_compl S ((submodule.span R (set.range (v ∘ subtype.val :\n    (s \\ ({b} : set ι)) → M))).comap S.subtype) V (submodule.comap S.subtype $\n    linear_map.ker (projection (v ∘ subtype.val) hv ⟨b, hb⟩)) W _ _ _ _ _ _,\n  rw submodule.map_comap_subtype,\n    sorry,\n  rw submodule.map_comap_subtype, sorry,\n  refine linear_independent.image_subtype _ _,\n  exact ht.1, sorry,\n  refine linear_independent.image_subtype _ _,\n  exact hl.1, sorry,\n  rw ←submodule.comap_inf,\n  rw eq_bot_iff,\n  intros x hx, rw submodule.mem_bot,\n  cases hx with hxl hxr,\n  simp at hxr,\n  sorry,\n  sorry,\n  exact free_subm1 ι s h1 M v hv S,\nend\n\nlemma tf_iff {M : Type*} [add_comm_group M] [module R M] :\n  tors R M = ⊥ ↔ ∀ (x : M) (r : R), r • x = 0 → r = 0 ∨ x = 0 :=\nbegin\n  split,\n  intro h,\n  rw eq_bot_iff at h,\n  intros x r hx,\n  cases (classical.em (r = 0)),\n  left, assumption,\n  right,\n  exact (submodule.mem_bot R).1 (h ⟨r, h_1, hx⟩),\n  intros h,\n  rw eq_bot_iff,\n  intros x hx,\n  cases hx with r hr,\n  exact (submodule.mem_bot R).2 (or.resolve_left (h x r hr.2) hr.1)\nend\n\ntheorem fg_quotient {M : Type*} [add_comm_group M] [module R M]\n  (S : submodule R M) (Hfg : S.fg) (A : submodule R S) : (⊤ : submodule R A.quotient).fg :=\n@is_noetherian.noetherian _ _ _ _ _\n  (is_noetherian_of_quotient_of_noetherian R S A $ is_noetherian_of_fg_of_noetherian S Hfg) ⊤\n\nlemma span_insert_zero_eq' {s : set M} :\n  submodule.span R (insert (0 : M) s) = submodule.span R s :=\nbegin\n  rw ←set.union_singleton,\n  rw submodule.span_union,\n  rw submodule.span_singleton_eq_bot.2 rfl,\n  rw sup_bot_eq,\nend\n\nlemma card_pos_of_ne_bot {M : Type*} [add_comm_group M] [module R M] {s : finset M}\n  {S : submodule R M} (h : S ≠ ⊥) (hs : submodule.span R (↑s : set M) = S) :\n  0 < (s.erase 0).card :=\nbegin\n  rw nat.pos_iff_ne_zero,\n  intro h0,\n  rw finset.card_eq_zero at h0,\n  cases classical.em ((0 : M) ∈ s) with hl hr,\n  rw ←finset.insert_erase hl at hs,\n  rw insert_to_set' at hs,\n  rw span_insert_zero_eq' at hs,\n  rw h0 at hs, erw submodule.span_empty at hs, exact h hs.symm,\n  rw finset.erase_eq_of_not_mem hr at h0,\n  rw h0 at hs, erw submodule.span_empty at hs,\n  exact h hs.symm,\nend\n\nlemma subset_singleton' {c : M} {l : finset M} (h : l ⊆ {c}) : l = ∅ ∨ l = {c} :=\nbegin\n  cases (finset.eq_empty_or_nonempty l),\n  left,\n  exact h_1,\n  right,\n  erw finset.eq_singleton_iff_unique_mem,\n  cases h_1 with w hw,\n  have := finset.mem_singleton.1 (h hw),\n  rw ←this,\n  split,\n  exact hw,\n  intros x hx,\n  rw this,\n  exact finset.mem_singleton.1 (h hx),\nend\n\nlemma single_of_singleton_support {α : Type*} {l : α →₀ R} {x : α}\n  (h : l.support = {x}) : l = finsupp.single x (l x) :=\nbegin\n  ext,\n  cases classical.em (a = x),\n  rw h_1, simp only [finsupp.single_eq_same],\n  rw finsupp.not_mem_support_iff.1 (by rw h; exact finset.not_mem_singleton.2 h_1),\n  rw finsupp.single_eq_of_ne (ne.symm h_1),\nend\n\n\ndef WHY (s : finset M) : set M := @has_lift.lift _ _ finset.has_lift s\n\n\nnoncomputable def finsupp_insert {s : finset M} {x : M} {l :  (set.insert x (WHY s)) →₀ R}\n  (hx : x ∉ s) (hl : l.2 (⟨x, set.mem_insert x (WHY s)⟩ : set.insert x (WHY s)) = 0) :\n  WHY s →₀ R :=\n{ support := subtype_mk' (finset.image subtype.val l.support) (WHY s) (by {intros y hy,\nerw finset.mem_image at hy, rcases hy with ⟨z, hzm, hz⟩, rw ←hz, exact\nor.resolve_left z.2 (by {intro hzx, rw finsupp.mem_support_iff at hzm, apply hzm, rw ←hl,\n  congr, rw subtype.ext_iff, exact hzx})}),\n  to_fun := λ x, l ⟨x, set.subset_insert _ _ x.2⟩,\n  mem_support_to_fun := λ y, by {split, intros h h0, erw finset.mem_image at h,\n  rcases h with ⟨b, hmb, hb⟩, cases b with b1 b2, erw finset.mem_image at b2, rcases b2 with ⟨c, hmc, hc⟩,\n  apply finsupp.mem_support_iff.1 hmc, rw ←subtype.eta c c.2, rw ←h0, congr' 1,\n    rw subtype.mk_eq_mk, rw hc, rw ←hb, refl,\n    intros h0, apply finset.mem_image.2, use (y : M), apply finset.mem_image.2,\n    use ⟨y, set.subset_insert _ _ y.2⟩,\n    split, exact finsupp.mem_support_iff.2 h0, refl,\n    split, exact finset.mem_univ _, rw subtype.ext_iff, refl,} }\n\nlemma finsupp_insert_apply {s : finset M} {x : M} {l :  (set.insert x (WHY s)) →₀ R}\n  (hx : x ∉ s) (hl : l.2 (⟨x, set.mem_insert x (WHY s)⟩ : set.insert x (WHY s)) = 0)\n  {y : M} (hy : y ∈ s) : finsupp_insert hx hl ⟨y, hy⟩ = l ⟨y, set.subset_insert _ _ hy⟩ :=\nrfl\n\n\n\nlemma finsupp_insert_total {s : finset M} {x : M} {l :  (set.insert x (WHY s)) →₀ R}\n  (hx : x ∉ s) (hl : l.2 (⟨x, set.mem_insert x (WHY s)⟩ : set.insert x (WHY s)) = 0)\n  : finsupp.total (WHY s) M R subtype.val (finsupp_insert hx hl) =\n    finsupp.total (set.insert x (WHY s)) M R subtype.val l :=\nbegin\n  rw finsupp.total_apply,\n  rw finsupp.total_apply,\n  unfold finsupp.sum,\n  show (subtype_mk' _ _ _).sum (λ (z : WHY s), l ⟨z, set.subset_insert _ _ z.2⟩ • (z : M)) = _,\n  sorry,\nend\n\nvariables (ρ : finset M) (T : set M)\n\ninstance fucksake2 (s : finset M) : fintype (WHY s) :=\nfinset_coe.fintype s\n\nnoncomputable def dep_coeff_map {M : Type*} [add_comm_group M] [module R M] (s : finset M) (z : M)\n(h : ¬(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker = ⊥) :\n  (finsupp.total (set.insert z (WHY s)) M R subtype.val).ker :=\n@classical.some (finsupp.total (set.insert z (WHY s)) M R subtype.val).ker (λ f, f ≠ 0) (by {\n  have h' : ¬(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker ≤ ⊥, from λ h', h (eq_bot_iff.2 h'),\n  rcases submodule.not_le_iff_exists.1 h' with ⟨y, hym, hy⟩, use y,exact hym,\n  intro hy0, rw subtype.ext_iff at hy0,\nexact hy hy0})\n\nnoncomputable def dep_coeff {M : Type*} [add_comm_group M] [module R M] (s : finset M) (z : M)\n(h : ¬(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker = ⊥) : R :=\ndep_coeff_map s z h ⟨z, (set.mem_insert z _)⟩\n\ntheorem dep_coeff_spec {M : Type*} [add_comm_group M] [module R M] (s : finset M) (z : M)\n  (h : ¬(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker = ⊥) :\n  dep_coeff_map s z h ≠ 0 :=\n@classical.some_spec (finsupp.total (set.insert z (WHY s)) M R subtype.val).ker (λ f, f ≠ 0) (by {\n  have h' : ¬(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker ≤ ⊥,\n    from λ h', h (eq_bot_iff.2 h'),\n  rcases submodule.not_le_iff_exists.1 h' with ⟨y, hym, hy⟩, use y,\n    exact hym, intro hy0, rw subtype.ext_iff at hy0,\nexact hy hy0})\n\nlemma prod_ne_zero {M : Type*} [add_comm_group M] [module R M] (Y s : finset M)\n(h : ∀ z : M, z ∈ Y \\ s → ¬(finsupp.total (set.insert (z : M) (WHY s)) M R subtype.val).ker = ⊥)\n  (hli : (finsupp.total (WHY s) M R subtype.val).ker = ⊥) :\n finset.prod (finset.image (λ w : (WHY (Y \\ s)), dep_coeff s (w : M) $ h w w.2)\n (@finset.univ (WHY (Y \\ s)) _)) id ≠ 0 :=\nbegin\n  intro hr0,\n  have hr := finset_prod_eq_zero_iff.1 hr0,\n  rw finset.mem_image at hr, rcases hr with ⟨x, hxm, hx⟩,\n  rw eq_bot_iff at hli,\n  have H := classical.not_not.2 hli,\n  apply H,\n  rw submodule.not_le_iff_exists,\n  let F := @finsupp_insert R _ _ _ _ _ s x (dep_coeff_map s x (h x x.2)) (finset.mem_sdiff.1 x.2).2 hx,\n  use F,\n  split,\n  rw linear_map.mem_ker,\n  erw finsupp_insert_total (finset.mem_sdiff.1 x.2).2 hx,\n  have huh := (dep_coeff_map s (x : M) (h x x.2)).2,\n  rw linear_map.mem_ker at huh, exact huh,\n  intro hF0,\n  apply dep_coeff_spec s (x : M) (h x x.2),\n  rw submodule.mem_bot at hF0,\n  rw subtype.ext_iff,\n  rw submodule.coe_zero,\n  ext,\n  cases (set.mem_insert_iff.1 a.2),\n  rw finsupp.zero_apply, rw ←hx, congr, rw subtype.ext_iff, exact h_1,\n  have huh := finsupp.ext_iff.1 hF0 ⟨a, h_1⟩,\n  rw finsupp_insert_apply at huh,\n  rw subtype.coe_eta at huh, rw huh, refl,\nend\n\nlemma prod_smul_mem {M : Type*} [add_comm_group M] [module R M] (Y s : finset M)\n(h : ∀ z : M, z ∈ Y \\ s → ¬(finsupp.total (set.insert (z : M) (WHY s)) M R subtype.val).ker = ⊥)\n (hli : (finsupp.total (WHY s) M R subtype.val).ker = ⊥)\n {y} (hy : y ∈ Y) :\n finset.prod (finset.image (λ w : (WHY (Y \\ s)), dep_coeff s (w : M) $ h w w.2)\n (@finset.univ (WHY (Y \\ s)) _)) id • y ∈ submodule.span R (↑s : set M) :=\nbegin\n  sorry,\nend\n\nvariables {r : R} (S : submodule R M)\n\nnoncomputable def r_equiv (htf : ∀ (x : S) (r : R), r • x = 0 → r = 0 ∨ x = 0) (r : R) (hr : r ≠ 0) :=\nlinear_equiv.of_injective ((r • linear_map.id).comp S.subtype) (by {\nrw linear_map.ker_eq_bot', intros m hm, exact or.resolve_left\n(htf m r $ subtype.ext_iff.2 $ by {dsimp at hm, rw ←submodule.coe_smul at hm,\n  rw ←@submodule.coe_zero _ _ _ _ _ S at hm, exact hm}) hr})\n\nlemma equiv_apply (htf : ∀ (x : S) (r : R), r • x = 0 → r = 0 ∨ x = 0) (r : R) (hr : r ≠ 0) {x : S} :\n(r_equiv S htf r hr x : M) = r • x := rfl\n\ntheorem free_of_tf (M : Type*) [add_comm_group M] [module R M] (S : submodule R M)\n  (hfg : S.fg) (htf : ∀ (x : S) (r : R), r • x = 0 → r = 0 ∨ x = 0) :\n  ∃ (t : set M), linear_independent R (λ x, x : t → M) ∧\n  submodule.span R (set.range (λ x, x : t → M)) = S :=\nbegin\n  cases (classical.em (S = ⊥)),\n  {  use ∅,\n       split,\n       exact linear_independent_empty _ _,\n       rw h, simp only [subtype.range_coe_subtype], exact submodule.span_empty},\n  cases hfg with X hX,\n  set Y := X.erase 0,\n  have hY : (↑Y : set M) ⊆ S := set.subset.trans (finset.erase_subset 0 X) (hX ▸ submodule.subset_span),\n  set n := nat.find_greatest (λ n, ∃ s : finset M, s ⊆ Y ∧\n    linear_independent R (λ x, x : (WHY s) → M) ∧ s.card = n) Y.card,\n  cases @nat.find_greatest_spec (λ n, ∃ s : finset M, s ⊆ Y ∧\n    linear_independent R (λ x, x : (WHY s) → M) ∧ s.card = n) _ Y.card\n    ⟨1, nat.succ_le_of_lt $ card_pos_of_ne_bot h hX, by\n    {cases finset.card_pos.1 (card_pos_of_ne_bot h hX) with c hc,\n    use {c}, split,\n    exact finset.singleton_subset_iff.2 hc, split,\n    rw linear_independent_subtype, intros l hlm hl,\n    cases subset_singleton ((finsupp.mem_supported _ _).1 hlm) with hl0 hlc,\n    rw ←finsupp.support_eq_empty, exact hl0,\n    rw single_of_singleton_support hlc at hl ⊢,\n    rw finsupp.total_single at hl,\n    rw finsupp.single_eq_zero,\n    exact or.resolve_right (htf ⟨c, hY hc⟩ (l c) (subtype.ext_iff.2 $ hl))\n    (λ h0, (finset.mem_erase.1 hc).1 $ subtype.ext_iff.1 h0),\n    exact finset.card_singleton _,\n     }⟩ with s hs,\n  cases (classical.em (∃ x, x ∈ Y \\ s)),\n  cases h_1 with z hz,\n  have hnl : ∀ z, z ∈ Y \\ s → ¬(linear_independent R $ (λ y, y : (set.insert z (WHY s) : set M) → M)) :=\n    λ x hx hnl,\n  by {have huh := @nat.find_greatest_is_greatest (λ n, ∃ s : finset M, s ⊆ Y ∧\n    linear_independent R (λ x, x : (WHY s) → M) ∧ s.card = n) _ Y.card\n      ⟨1, nat.succ_le_of_lt $ card_pos_of_ne_bot h hX, by\n    {cases finset.card_pos.1 (card_pos_of_ne_bot h hX) with c hc,\n    use {c}, split,\n    exact finset.singleton_subset_iff.2 hc, split,\n    rw linear_independent_subtype, intros l hlm hl,\n    cases subset_singleton ((finsupp.mem_supported _ _).1 hlm) with hl0 hlc,\n    rw ←finsupp.support_eq_empty, exact hl0,\n    rw single_of_singleton_support hlc at hl ⊢,\n    rw finsupp.total_single at hl,\n    rw finsupp.single_eq_zero,\n    exact or.resolve_right (htf ⟨c, hY hc⟩ (l c) (subtype.ext_iff.2 $ hl))\n      (λ h0, (finset.mem_erase.1 hc).1 $ subtype.ext_iff.1 h0),\n    exact finset.card_singleton _,\n     }⟩ n.succ (by {split, exact nat.lt_succ_self _, rw nat.succ_le_iff, simp only [n], erw ←hs.2.2,\n     apply finset.card_lt_card, rw finset.ssubset_iff_of_subset, use x,\n     rw ←finset.mem_sdiff, exact hx, exact hs.1}),\n     exact huh ⟨(insert x s), by {split, rw finset.insert_subset,split,\n     exact (finset.mem_sdiff.1 hx).1, exact hs.1, split,\n     simp only [*, not_exists, set.diff_singleton_subset_iff, submodule.mem_coe,\n     finset.coe_erase, not_and, finset.mem_sdiff, ne.def,\n   set.insert_eq_of_mem, submodule.zero_mem, finset.mem_erase] at *, convert hnl,\n   all_goals {try {exact finset.coe_insert _ _}},\n     rw finset.card_insert_of_not_mem, rw hs.2.2, exact (finset.mem_sdiff.1 hx).2,\n      }⟩, },\n  unfold linear_independent at hnl,\nset r : R := finset.prod (finset.image (λ w : (↑(Y \\ s) : set M),\n   dep_coeff s (w : M) $ hnl w w.2) (@finset.univ (↑(Y \\ s) : set M) _)) id,\n have hr0 : r ≠ 0 := prod_ne_zero Y s hnl hs.2.1,\n  have hrX : ∀ x, x ∈ X → r • x ∈ submodule.span R (↑s : set M) := sorry,\n  have hrS : ∀ x, x ∈ S → r • x ∈ submodule.span R (↑s : set M) := λ w hw,\n  by {rw ←hX at hw, rw ←set.image_id (↑X : set M) at hw, rcases\n  (finsupp.mem_span_iff_total R).1 hw with ⟨f, hfm, hf⟩,\n  rw ←hf, rw finsupp.total_apply, rw finsupp.smul_sum,\n  apply submodule.sum_mem (submodule.span R (↑s : set M)), intros c hc,\n  dsimp, rw ←mul_smul, rw mul_comm, rw mul_smul,\n  apply submodule.smul_mem (submodule.span R (↑s : set M)) (f c),\n  exact hrX c (hfm hc)\n   },\n  cases free_subm (↑s : set M) set.univ s.card (by { rw univ_card s, rw finset.card_univ,\n  apply fintype.card_congr, symmetry,\n  exact (equiv.set.univ _).symm,\n  }) (submodule.span R (↑s : set M) : set M) (λ x, ⟨x, submodule.subset_span x.2⟩)\n  ⟨sorry, sorry⟩ (submodule.comap (submodule.span R (↑s : set M)).subtype\n    (submodule.map (r • linear_map.id) S)) with t ht,\n  let T := (λ x, r • x)⁻¹' (subtype.val '' t),\n  use T,\n  split, simp only [],\n  unfold linear_independent at *,\n  rw eq_bot_iff at *,\n  by_contradiction,\n  rcases submodule.not_le_iff_exists.1 a with ⟨f, hfm, hf⟩,\n  refine absurd ht.1 _,\n  apply submodule.not_le_iff_exists.2,\n  let sset : finset t := @finset.preimage _ _ (subtype.val ∘ subtype.val)\n     (finset.image (λ x : T, r • (x : M)) f.1) sorry,\n  let func : t → R := λ x, f.2 ⟨r • x, sorry⟩,\n  let F : t →₀ R := ⟨sset, func, sorry⟩,\n  use F,\n  split,\n    sorry, sorry,\n  ext i, split,\n  intro hmem,\n  sorry, sorry,\n  use (↑s : set M),\n  split,\n  exact hs.2.1,\n  rw ←hX,\n  have hsY : s = Y := le_antisymm hs.1 sorry,\n  rw hsY,\n  sorry,\nend\n\ntheorem torsion_decomp {M : Type*} [add_comm_group M] [module R M] (S : submodule R M)\n  (hfg : S.fg) : ∃ t : set S, linear_independent R (λ x, x : t → S) ∧\n  (tors R S) ⊓ (submodule.span R t) = ⊥ ∧ (tors R S) ⊔ (submodule.span R t) = ⊤ :=\nbegin\n  cases free_of_tf (tors R S).quotient ⊤ (fg_quotient S hfg (tors R S))\n    (tf_iff.1 $ eq_bot_iff.2 $ λ b hb, by {have := eq_bot_iff.1 (tors_free_of_quotient R S),\n    rcases hb with ⟨c, hc⟩,\n    have h0 : c • (b : (tors R S).quotient) = 0 := by {rw ←submodule.coe_smul,\n      rw ←@submodule.coe_zero R (tors R S).quotient _ _ _ ⊤, congr, exact hc.2 },\n    have ffs := this ⟨c, hc.1, h0⟩,\n    rw submodule.mem_bot at ffs ⊢, rw subtype.ext_iff,\n    rw ffs, refl}\n    ) with t ht,\n  cases (projective_of_has_basis ht S (tors R S).quotient linear_map.id (tors R S).mkq\n    (λ x, quotient.induction_on' x $ λ y, ⟨y, rfl⟩)) with f hf,\n  have HP := split_of_left_inv (tors R S) (tors R S).mkq (by {rw submodule.ker_mkq,\n    rw submodule.range_subtype}) f (linear_map.ext hf) (submodule.range_mkq _),\n  use (set.range ((f : _ → S) ∘ subtype.val : t → S)),\n  split,\n  apply linear_independent.to_subtype_range,\n  apply linear_independent.restrict_of_comp_subtype,\n  rw linear_independent_comp_subtype,\n  intros l hlm hl,\n  apply (linear_independent_subtype.1 ht.1 l hlm),\n  rw finsupp.total_apply at *,\n  apply f.to_add_monoid_hom.injective_iff.1 (function.left_inverse.injective hf),\n  rw ←hl,\n  erw (finset.sum_hom l.support f).symm,\n  apply finset.sum_congr rfl,\n  intros x hx, dsimp,\n  rw linear_map.map_smul,\n  convert HP, all_goals\n  {rw ←set.image_univ,\n  rw set.image_comp, rw submodule.span_image,\n  show _ = (⊤ : submodule R (tors R S).quotient).map f,\n  congr, convert ht.2, rw set.image_univ, refl},\nend\n\ndef tf_basis {M : Type*} [add_comm_group M] [module R M] (S : submodule R M)\n  (hfg : S.fg) := classical.some (torsion_decomp S hfg)\n\ntheorem tf_basis_is_basis {M : Type*} [add_comm_group M] [module R M] (S : submodule R M)\n  (hfg : S.fg) : linear_independent R (λ x, x : tf_basis S hfg → S) :=\n(classical.some_spec (torsion_decomp S hfg)).1\n\ntheorem disjoint_tors_tf {M : Type*} [add_comm_group M] [module R M] {S : submodule R M}\n  (hfg : S.fg) : (tors R S) ⊓ (submodule.span R $ tf_basis S hfg) = ⊥ :=\n(classical.some_spec (torsion_decomp S hfg)).2.1\n\ntheorem tors_tf_span {M : Type*} [add_comm_group M] [module R M] {S : submodule R M}\n  (hfg : S.fg) : (tors R S) ⊔ (submodule.span R $ tf_basis S hfg) = ⊤ :=\n(classical.some_spec (torsion_decomp S hfg)).2.2", "meta": {"author": "101damnations", "repo": "fg_over_pid", "sha": "a1a587c455a54a802f6ff61b07bb033701e451a7", "save_path": "github-repos/lean/101damnations-fg_over_pid", "path": "github-repos/lean/101damnations-fg_over_pid/fg_over_pid-a1a587c455a54a802f6ff61b07bb033701e451a7/src/free_take_three.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.49709040128940746}}
{"text": "/-\nCopyright (c) 2022 María Inés de Frutos-Fernández. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: María Inés de Frutos-Fernández\n-/\nimport field_theory.ratfunc\nimport ring_theory.dedekind_domain.adic_valuation\nimport data.polynomial.basic\nimport analysis.special_functions.log.base\nimport basic\n\n/-!\n# Ostrowski's theorem for K(X)\n\n## References\n* https://kconrad.math.uconn.edu/blurbs/gradnumthy/ostrowskiF(T).pdf\n\n## Tags\nring_norm, ostrowski\n-/\n\nnoncomputable theory\n\nopen polynomial\n\nopen_locale polynomial big_operators\n\nsection infty\n\n/-- The norm on K(X) associated to the place at infinity. -/\nnoncomputable! def mul_ring_norm.infty (K : Type*) [field K] [decidable_eq (ratfunc K)] \n  (c : ℝ) (hc_pos : 0 < c) (hc_one_lt : 1 < c) : mul_ring_norm (ratfunc K) :=\n{ to_fun := λ r, if r = 0 then 0 else c ^ r.int_degree,\n  map_zero' := sorry,\n  add_le' := sorry,\n  neg' := λ r,\n  begin\n    by_cases r = 0,\n    { simp only [h, neg_zero] } ,\n    { have h₁ : ¬ -r = 0,\n      { intro h₁,\n        apply h,\n        exact neg_eq_zero.1 h₁ },\n      simp only [h, h₁, ratfunc.int_degree_neg] }\n  end,\n  map_one' := sorry,\n  map_mul' :=\n  begin\n    intros r s,\n    simp [mul_eq_zero, ite_mul, mul_ite, mul_zero, zero_mul],\n    by_cases r = 0 ∨ s = 0,\n    { simp only [h, if_true],\n      cases h,\n      { simp only [h, eq_self_iff_true, if_true, if_t_t] },\n      { simp only [h, eq_self_iff_true, if_true] } },\n    { simp only [h, if_false],\n      rw not_or_distrib at h,\n      cases h with h₁ h₂,\n      simp only [h₁, h₂, if_false],\n      rw ratfunc.int_degree_mul h₁ h₂,\n      repeat {rw ←real.rpow_int_cast},\n      push_cast,\n      exact real.rpow_add hc_pos _ _ }\n  end,\n  eq_zero_of_map_eq_zero' := λ x hx,\n  begin\n    by_contra,\n    simp only [h, if_false] at hx,\n    linarith [zpow_eq_zero hx],\n  end }\n\n@[simp] lemma mul_ring_norm.infty_def (K : Type*) [field K] [decidable_eq (ratfunc K)] (c : ℝ) \n  (hc_pos : 0 < c) (hc_one_lt : 1 < c) (r : ratfunc K):\n    mul_ring_norm.infty K c hc_pos hc_one_lt r = if r = 0 then 0 else c ^ r.int_degree := rfl\n\nlemma mul_ring_norm.infty_is_nonarchimedean (K : Type*) [field K] [decidable_eq (ratfunc K)] (c : ℝ)\n  (hc_pos : 0 < c) (hc_one_lt : 1 < c) :\n  is_nonarchimedean (mul_ring_norm.infty K c hc_pos hc_one_lt) :=\nbegin\n  intros r s,\n  simp only [mul_ring_norm.infty_def, le_max_iff],\n  by_cases r + s = 0,\n  { simp only [h, eq_self_iff_true, if_true],\n    sorry},\n  { simp only [h, if_false],\n    by_cases h₁ : r = 0,\n    { right,\n      have h₂ : ¬ s = 0,\n      { intro h₃,\n        apply h,\n        simp only [h₁, h₃, add_zero] },\n      simp only [h₁, h₂, zero_add, if_false] },\n    { have h₂ : ¬ s = 0 := sorry, -- this is false,\n      simp only [h₁, h₂, if_false],\n\n      sorry} }\nend\n\nend infty\n\n/-- The maximal ideal on K[X] generated by an irreducible polynomial. -/\ndef polynomial.maximal_ideal_of_irreducible {K : Type*} [field K] [decidable_eq (ratfunc K)]\n  {p : polynomial K} (hp : irreducible p) : is_dedekind_domain.height_one_spectrum (K[X]) :=\n{ as_ideal := ideal.span({p}),\n  is_prime := (ideal.span_singleton_prime (prime.ne_zero \n    (principal_ideal_ring.irreducible_iff_prime.mp hp))).mpr \n      (principal_ideal_ring.irreducible_iff_prime.mp hp),\n  ne_bot   := by simp only [ne.def, ideal.span_singleton_eq_bot, \n    prime.ne_zero (principal_ideal_ring.irreducible_iff_prime.mp hp), not_false_iff] }\n\nsection adic\n\n/-- The norm on K(X) associated to an irreducible polynomial. -/\nnoncomputable! def mul_ring_norm.adic {K : Type*} [field K] [decidable_eq (ratfunc K)] (c : ℝ) \n  (hc_pos : 0 < c) (hc_one_lt : 1 < c) {p : polynomial K} (hp : irreducible p) :\n    mul_ring_norm (ratfunc K) :=\n{ to_fun := λ r, if hr : r = 0 then 0 else c ^ multiplicative.to_add (with_zero.unzero\n  ((@polynomial.maximal_ideal_of_irreducible K _ _ p hp).valuation.ne_zero_iff.mpr hr)),\n  map_zero' := sorry,\n  add_le' := \n  begin\n    intros r s,\n    by_cases r + s = 0,\n    { simp only [h, dif_pos],\n      by_cases hr : r = 0,\n      { have hs : s = 0,\n        {sorry},\n        simp only [hs, hr, dif_pos],\n        linarith },\n      { have hs : ¬ s = 0,\n        {sorry},\n        simp only [hs, hr, not_false_iff, dif_neg],\n        exact add_nonneg (zpow_nonneg (le_of_lt hc_pos) _) \n          (zpow_nonneg (le_of_lt hc_pos) _) } },\n    { simp only [h, not_false_iff, dif_neg],\n      by_cases hr : r = 0,\n      { have hs : ¬ s = 0,\n        {sorry},\n        simp only [hr, hs, not_false_iff, zero_add, dif_pos, dif_neg] },\n      { by_cases hs : s = 0,\n        {sorry},\n        {sorry} } }\n  end,\n  neg' := sorry,\n  map_one' := sorry,\n  map_mul' :=\n  begin\n    intros x y,\n    simp [mul_eq_zero, valuation.map_mul],\n    by_cases (x = 0 ∨ y = 0),\n    {sorry},\n    { rw not_or_distrib at h,\n      simp only [h.1, h.2, or_self, not_false_iff, dif_neg],\n      rw ←@zpow_add₀ _ _ c (by linarith),\n      congr,\n      rw ←to_add_mul,\n      congr,\n      rw ←with_zero.coe_inj,\n      push_cast,\n      repeat {rw with_zero.coe_unzero} },\n  end,\n  eq_zero_of_map_eq_zero' :=\n  begin\n    intros x hx,\n    by_contra,\n    simp only [h, not_false_iff, dif_neg] at hx,\n    linarith [zpow_eq_zero hx]\n  end }\n\n@[simp] lemma mul_ring_norm.adic_def {K : Type*} [field K] [decidable_eq (ratfunc K)] \n  (c : ℝ) (hc_pos : 0 < c) (hc_one_lt : 1 < c) {p : polynomial K} (hp : irreducible p) \n    (r : ratfunc K): mul_ring_norm.adic c hc_pos hc_one_lt hp r = if hr : r = 0 then 0 else \n      c ^ multiplicative.to_add (with_zero.unzero ((\n        @polynomial.maximal_ideal_of_irreducible K _ _ p hp).valuation.ne_zero_iff.mpr hr)) \n:= rfl\n\nlemma mul_ring_norm.adic_is_nonarchimedean (K : Type*) [field K] [decidable_eq (ratfunc K)] (c : ℝ)\n  (hc_pos : 0 < c) (hc_one_lt : 1 < c) {p : polynomial K} (hp : irreducible p) :\n  is_nonarchimedean (@mul_ring_norm.adic K _ _ c hc_pos hc_one_lt p hp) :=\nbegin\n  intros x y,\n  simp only [nonempty_of_inhabited, mul_ring_norm.adic_def, le_max_iff],\n  by_cases x + y = 0,\n  {sorry},\n  { simp only [h, not_false_iff, dif_neg],\n    by_cases hx : x = 0,\n    { have hy : ¬ y = 0,\n      {sorry},\n      simp only [hx, hy, not_false_iff, zero_add, dif_neg, le_refl, or_true] },\n    { left,\n      simp only [hx, not_false_iff, dif_neg],\n      repeat {rw ←real.rpow_int_cast},\n      apply real.rpow_le_rpow_of_exponent_le,\n      { linarith },\n      { sorry } } }\nend\n\nend adic\n\nopen filter\n\n-- Done in PR17863\nlemma Sum_le {R : Type*} [ring R] (f : mul_ring_norm R) (n : ℕ) {ι : ℕ → R} : \n  f (∑ i in finset.range n, ι i) ≤ ∑ i in finset.range n, f (ι i) := sorry\n\n-- Done in PR17863\nlemma is_nonarchimedean_iff_exists_ne_zero_map_nat_mul_le_one {R : Type*} \n  [comm_ring R] {f : mul_ring_norm R} :\n    is_nonarchimedean f ↔ (∃ x : R, x ≠ 0 ∧ ∀ n : ℕ, f (n * x) ≤ 1) := sorry\n\nlemma unknown_name1 {K : Type*} [field K] [decidable_eq (ratfunc K)]\n  {f : mul_ring_norm (ratfunc K)} (hf_nontriv : f ≠ 1) \n    (hf_triv_K : ∀ {x : K} (hx : x ≠ 0), f (ratfunc.C x) = 1) :\n      is_nonarchimedean f :=\nbegin\n  rw is_nonarchimedean_iff_exists_ne_zero_map_nat_mul_le_one,\n  refine ⟨1, _⟩,\n  simp only [ne.def, one_ne_zero, not_false_iff, mul_one, true_and],\n  intro n,\n  have hn1 : ratfunc.C (n : K) = (n : ratfunc K),\n  { simp only [map_nat_cast] },\n  by_cases h : (n : K) = 0,\n  { have hn : (n : ratfunc K) = 0,\n    { rw ← hn1,\n      rw h,\n      simp only [map_zero] },\n    rw hn,\n    simp only [map_zero, zero_le_one] },\n  { specialize hf_triv_K h,\n    rw hn1 at hf_triv_K,\n    rw hf_triv_K }\nend\n\nlemma mul_ring_norm.is_nonarchimedaen_eq_max_of_neq {R : Type*} [non_assoc_ring R] \n  {f : mul_ring_norm R} (hf : is_nonarchimedean f) {r s : R} (h_neq : f r ≠ f s) : \n    f (r + s) = max (f r) (f s) :=\nbegin\n  have hf₁ := hf,\n  specialize hf r s,\n  cases ne.lt_or_lt h_neq with h₁ h₂,\n  { specialize hf₁ (r + s) (-r),\n    simp only [add_neg_cancel_comm, map_neg_eq_map, le_max_iff] at hf₁,\n    cases hf₁ with h₃ h₄,\n    { have hrs : f r ≤ f s := by linarith,\n      rw max_eq_right hrs at hf ⊢,\n      linarith },\n    { linarith } },\n  { specialize hf₁ (r + s) (-s),\n    simp only [add_neg_cancel_right, map_neg_eq_map, le_max_iff] at hf₁,\n    cases hf₁ with h₃ h₄,\n    { have hrs : f s ≤ f r := by linarith,\n      rw max_eq_left hrs at hf ⊢,\n      linarith },\n    { linarith } }\nend\n\nlemma unknown_name {R : Type*} [non_assoc_ring R] {f : mul_ring_norm R} \n  (hf : is_nonarchimedean f) (s : finset ℕ) {g : ℕ → R} {a : ℕ}\n    (h_max : ∀ p : ℕ, f (g p) ≤ f (g a)) :\n      f (∑ p in s, g p) = f (g a) :=\nbegin\n  sorry\nend\n\n/-- Ostrowski's Theorem -/\ntheorem rat_ring_norm_p_adic_or_real' (K : Type*) [field K] [decidable_eq (ratfunc K)]\n  (c : ℝ) (hc_pos : 0 < c) (hc_one_lt : 1 < c) (f : mul_ring_norm (ratfunc K))\n    (hf_nontriv : f ≠ 1) (hf_triv_K : ∀ {x : K} (hx : x ≠ 0), f (ratfunc.C x) = 1) :\n      (mul_ring_norm.equiv f (mul_ring_norm.infty K c hc_pos hc_one_lt)) ∨\n        ∃ (p : K[X]) [hp : irreducible p],\n          mul_ring_norm.equiv f (@mul_ring_norm.adic K _ _ c hc_pos hc_one_lt p hp) :=\nbegin\n  by_cases 1 < f (ratfunc.mk X 1),\n  { left,\n    let c₁ := 1 / f (ratfunc.mk X 1),\n    have hc₁ : 0 < c₁,\n    {sorry}, -- easy\n    have hc₂ : 0 ≤ c₁,\n    { linarith [hc₁] },\n    have hc₃ : c₁ ≠ 1,\n    {sorry}, -- easy as well\n    have hc : c ≠ 0,\n    { linarith },\n    have hc1 : 0 ≤ c,\n    { linarith },\n    have h₁ : ∀ x : K[X], f (ratfunc.mk x 1) = c₁ ^ -(x.nat_degree : ℝ),\n    { intro x,\n      nth_rewrite 0 as_sum_support_C_mul_X_pow x,\n      have h₁ : ratfunc.mk (x.support.sum (λ (i : ℕ), C (x.coeff i) * X ^ i)) 1\n      = ∑ p in x.support, (ratfunc.mk (C (x.coeff p) * X ^ p) 1),\n      {sorry},\n      rw h₁, clear h₁,\n      have h₂ : ∀ (p : ℕ), f (ratfunc.mk (C (x.coeff p) * X ^ p) 1)\n        ≤ f (ratfunc.mk (C (x.coeff (nat_degree x)) * X ^ (nat_degree x)) 1),\n      {sorry},\n      have hf : is_nonarchimedean f,\n      { exact unknown_name1 hf_nontriv @hf_triv_K },\n      rw unknown_name hf (x.support) h₂,\n      clear h₂,\n      have h₃ : f (ratfunc.mk (C (x.coeff x.nat_degree) * X ^ x.nat_degree) 1)\n         = f (ratfunc.mk (C (x.coeff x.nat_degree)) 1) * f (ratfunc.mk (X ^ x.nat_degree) 1),\n      {sorry},\n      rw h₃,\n      clear h₃,\n      have h₄ : f (ratfunc.mk (C (x.coeff x.nat_degree)) 1) = 1,\n      {sorry},\n      rw h₄,\n      clear h₄,\n      rw one_mul,\n      have h₅ : f (ratfunc.mk (X ^ x.nat_degree) 1) = (f (ratfunc.mk X 1)) ^ (x.nat_degree),\n      {sorry},\n      rw h₅,\n      clear h₅,\n      dsimp [c₁],\n      rw one_div,\n      rw ←real.rpow_neg_one,\n      rw ←real.rpow_mul,\n      { simp only [neg_mul, one_mul, neg_neg, real.rpow_nat_cast] },\n      sorry}, -- main step here\n    refine ⟨-real.logb c₁ c, _, _⟩,\n    {sorry}, -- 0 < -real.logb c₁ c-\n    { ext,\n      rw [mul_ring_norm.infty_def],\n      by_cases h₂ : x = 0,\n      {sorry}, -- easy\n      { simp only [h₂, if_false],\n        have h₃ := h₁ (x.num),\n        specialize h₁ x.denom,\n        have h₄ : x = (ratfunc.mk x.num 1) / (ratfunc.mk x.denom 1),\n        {sorry}, -- quite tricky here\n        rw h₄,\n        have h₅ : f (ratfunc.mk x.num 1 / ratfunc.mk x.denom 1) = f (ratfunc.mk x.num 1) / f (ratfunc.mk x.denom 1),\n        {sorry}, -- This should be a separate lemma\n        rw h₅,\n        rw [h₁, h₃],\n        rw ←real.rpow_sub hc₁,\n        field_simp,\n        rw ←real.rpow_mul hc₂,\n        rw ←neg_mul_comm,\n        field_simp,\n        rw mul_comm,\n        rw real.rpow_mul hc₂,\n        rw real.rpow_logb_eq_abs hc₁ hc₃ hc,\n        rw abs_eq_self.2 hc1,\n        dsimp [ratfunc.int_degree],\n        rw ←real.rpow_int_cast,\n        push_cast } } },\n  { right,\n    sorry}\nend\n", "meta": {"author": "mariainesdff", "repo": "ostrowski", "sha": "b29d8bd9d98923ec2fab923cb67c76a54aa70386", "save_path": "github-repos/lean/mariainesdff-ostrowski", "path": "github-repos/lean/mariainesdff-ostrowski/ostrowski-b29d8bd9d98923ec2fab923cb67c76a54aa70386/src/function_field.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942290328345, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.497075300970032}}
{"text": "import Mathbin\n\nopen MvPolynomial\n\n@[simp] \nlemma eq_zero_of_zero_eq (R : Type u) [HasZero R] (r : R) : 0 = r ↔ r = 0 :=\n  by exact eq_comm\n\n@[simp] lemma zero_sub_eq_iff (R : Type u) [AddCommGroup R] (a b : R) : 0 - a = b ↔ a + b = 0 := by\n  apply Iff.intro\n  · intro h\n    rw [←h]\n    sorry\n  · sorry\n\nregister_simp_attr polynomial_nf \n  \"Attribute for lemmas that are used in the conversion of mv_polynomial expressions to a normal form consisting of adds of sums of muls of mv_polynomials\"\n\nattribute [polynomial_nf] Polynomial.eval₂\nattribute [polynomial_nf] Polynomial.sum\nattribute [polynomial_nf] Finsupp.sum\nattribute [polynomial_nf] mul_add\nattribute [polynomial_nf] add_mul\nattribute [polynomial_nf] Finset.sum_mul\nattribute [polynomial_nf] Finset.mul_sum\nattribute [polynomial_nf] Finset.sum_add_distrib\nattribute [polynomial_nf] mul_assoc\nattribute [polynomial_nf] finsupp.smul_sum\nattribute [polynomial_nf] mul_smul_comm\nattribute [polynomial_nf] smul_add\nattribute [polynomial_nf] mul_smul\nattribute [polynomial_nf] smul_mul_assoc\n\nregister_simp_attr polynomial_nf_2\n  \"Attribute for lemmas that are used in the conversion of mv_polynomial expressions to a normal form consisting of adds of sums of muls of mv_polynomials\"\n\nattribute [polynomial_nf_2] mul_add\nattribute [polynomial_nf_2] add_mul\nattribute [polynomial_nf_2] finset.sum_add_distrib\nattribute [polynomial_nf_2] sum_X_mul\nattribute [polynomial_nf_2] sum_C_mul\nattribute [polynomial_nf_2] rearrange_constants_right\nattribute [polynomial_nf_2] rearrange_constants_right_with_extra\nattribute [polynomial_nf_2] rearrange_sums_right\nattribute [polynomial_nf_2] rearrange_sums_right_with_extra\nattribute [polynomial_nf_2] C_mul_C\nattribute [polynomial_nf_2] finset.sum_hom\nattribute [polynomial_nf_2] mv_polynomial.smul_eq_C_mul\nattribute [polynomial_nf_2] mul_assoc\nattribute [polynomial_nf_2] finsupp.smul_sum\nattribute [polynomial_nf_2] mul_smul_comm\nattribute [polynomial_nf_2] smul_add\nattribute [polynomial_nf_2] mul_smul\nattribute [polynomial_nf_2] smul_mul_assoc\n\nregister_simp_attr polynomial_nf_3\n  \"Attribute for lemmas that are used in the conversion of mv_polynomial expressions to a normal form consisting of adds of sums of muls of mv_polynomials\"\n\nattribute [polynomial_nf_3] mul_add\nattribute [polynomial_nf_3] add_mul\nattribute [polynomial_nf_3] finset.sum_add_distrib\nattribute [polynomial_nf_3] mul_sum_symm\nattribute [polynomial_nf_3] rearrange_constants_right\nattribute [polynomial_nf_3] rearrange_constants_right_with_extra\nattribute [polynomial_nf_3] rearrange_sums_right\nattribute [polynomial_nf_3] rearrange_sums_right_with_extra\nattribute [polynomial_nf_3] C_mul_C\nattribute [polynomial_nf_3] finset.sum_hom\nattribute [polynomial_nf_3] mv_polynomial.smul_eq_C_mul\nattribute [polynomial_nf_3] mul_assoc\n", "meta": {"author": "lurk-lab", "repo": "ZKSnark.lean", "sha": "a92ff01fac8e59ffb0de13a41eac6461af6d7cf0", "save_path": "github-repos/lean/lurk-lab-ZKSnark.lean", "path": "github-repos/lean/lurk-lab-ZKSnark.lean/ZKSnark.lean-a92ff01fac8e59ffb0de13a41eac6461af6d7cf0/ZkSNARK/Attributes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.497049248909814}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.adjunction.basic\nimport category_theory.category.preorder\nimport category_theory.isomorphism_classes\nimport category_theory.thin\n\n/-!\n# Skeleton of a category\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nDefine skeletal categories as categories in which any two isomorphic objects are equal.\n\nConstruct the skeleton of an arbitrary category by taking isomorphism classes, and show it is a\nskeleton of the original category.\n\nIn addition, construct the skeleton of a thin category as a partial ordering, and (noncomputably)\nshow it is a skeleton of the original category. The advantage of this special case being handled\nseparately is that lemmas and definitions about orderings can be used directly, for example for the\nsubobject lattice. In addition, some of the commutative diagrams about the functors commute\ndefinitionally on the nose which is convenient in practice.\n-/\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\nnamespace category_theory\n\nopen category\n\nvariables (C : Type u₁) [category.{v₁} C]\nvariables (D : Type u₂) [category.{v₂} D]\nvariables {E : Type u₃} [category.{v₃} E]\n\n/-- A category is skeletal if isomorphic objects are equal. -/\ndef skeletal : Prop := ∀ ⦃X Y : C⦄, is_isomorphic X Y → X = Y\n\n/--\n`is_skeleton_of C D F` says that `F : D ⥤ C` exhibits `D` as a skeletal full subcategory of `C`,\nin particular `F` is a (strong) equivalence and `D` is skeletal.\n-/\nstructure is_skeleton_of (F : D ⥤ C) :=\n(skel : skeletal D)\n(eqv : is_equivalence F)\n\nlocal attribute [instance] is_isomorphic_setoid\n\nvariables {C D}\n/-- If `C` is thin and skeletal, then any naturally isomorphic functors to `C` are equal. -/\nlemma functor.eq_of_iso {F₁ F₂ : D ⥤ C} [quiver.is_thin C] (hC : skeletal C)\n  (hF : F₁ ≅ F₂) : F₁ = F₂ :=\nfunctor.ext (λ X, hC ⟨hF.app X⟩) (λ _ _ _, subsingleton.elim _ _)\n\n/--\nIf `C` is thin and skeletal, `D ⥤ C` is skeletal.\n`category_theory.functor_thin` shows it is thin also.\n-/\nlemma functor_skeletal [quiver.is_thin C] (hC : skeletal C) : skeletal (D ⥤ C) :=\nλ F₁ F₂ h, h.elim (functor.eq_of_iso hC)\nvariables (C D)\n\n/--\nConstruct the skeleton category as the induced category on the isomorphism classes, and derive\nits category structure.\n-/\n@[derive category]\ndef skeleton : Type u₁ := induced_category C quotient.out\n\ninstance [inhabited C] : inhabited (skeleton C) := ⟨⟦default⟧⟩\n\n/-- The functor from the skeleton of `C` to `C`. -/\n@[simps, derive [full, faithful]]\nnoncomputable def from_skeleton : skeleton C ⥤ C := induced_functor _\n\ninstance : ess_surj (from_skeleton C) :=\n{ mem_ess_image := λ X, ⟨quotient.mk X, quotient.mk_out X⟩ }\n\nnoncomputable instance : is_equivalence (from_skeleton C) :=\nequivalence.of_fully_faithfully_ess_surj (from_skeleton C)\n\n/-- The equivalence between the skeleton and the category itself. -/\nnoncomputable def skeleton_equivalence : skeleton C ≌ C :=\n(from_skeleton C).as_equivalence\n\nlemma skeleton_skeletal : skeletal (skeleton C) :=\nbegin\n  rintro X Y ⟨h⟩,\n  have : X.out ≈ Y.out := ⟨(from_skeleton C).map_iso h⟩,\n  simpa using quotient.sound this,\nend\n\n/-- The `skeleton` of `C` given by choice is a skeleton of `C`. -/\nnoncomputable def skeleton_is_skeleton : is_skeleton_of C (skeleton C) (from_skeleton C) :=\n{ skel := skeleton_skeletal C,\n  eqv := from_skeleton.is_equivalence C }\n\nsection\nvariables {C D}\n\n/--\nTwo categories which are categorically equivalent have skeletons with equivalent objects.\n-/\nnoncomputable\ndef equivalence.skeleton_equiv (e : C ≌ D) : skeleton C ≃ skeleton D :=\nlet f := ((skeleton_equivalence C).trans e).trans (skeleton_equivalence D).symm in\n{ to_fun := f.functor.obj,\n  inv_fun := f.inverse.obj,\n  left_inv := λ X, skeleton_skeletal C ⟨(f.unit_iso.app X).symm⟩,\n  right_inv := λ Y, skeleton_skeletal D ⟨(f.counit_iso.app Y)⟩, }\n\nend\n\n/--\nConstruct the skeleton category by taking the quotient of objects. This construction gives a\npreorder with nice definitional properties, but is only really appropriate for thin categories.\nIf your original category is not thin, you probably want to be using `skeleton` instead of this.\n-/\ndef thin_skeleton : Type u₁ := quotient (is_isomorphic_setoid C)\n\ninstance inhabited_thin_skeleton [inhabited C] : inhabited (thin_skeleton C) :=\n⟨quotient.mk default⟩\n\ninstance thin_skeleton.preorder : preorder (thin_skeleton C) :=\n{ le := quotient.lift₂ (λ X Y, nonempty (X ⟶ Y))\n  begin\n    rintros _ _ _ _ ⟨i₁⟩ ⟨i₂⟩,\n    exact propext ⟨nonempty.map (λ f, i₁.inv ≫ f ≫ i₂.hom),\n      nonempty.map (λ f, i₁.hom ≫ f ≫ i₂.inv)⟩,\n  end,\n  le_refl :=\n  begin\n    refine quotient.ind (λ a, _),\n    exact ⟨𝟙 _⟩,\n  end,\n  le_trans := λ a b c, quotient.induction_on₃ a b c $ λ A B C, nonempty.map2 (≫) }\n\n/-- The functor from a category to its thin skeleton. -/\n@[simps]\ndef to_thin_skeleton : C ⥤ thin_skeleton C :=\n{ obj := quotient.mk,\n  map := λ X Y f, hom_of_le (nonempty.intro f) }\n\n/-!\nThe constructions here are intended to be used when the category `C` is thin, even though\nsome of the statements can be shown without this assumption.\n-/\nnamespace thin_skeleton\n\n/-- The thin skeleton is thin. -/\ninstance thin : quiver.is_thin (thin_skeleton C) :=\nλ _ _, ⟨by { rintros ⟨⟨f₁⟩⟩ ⟨⟨f₂⟩⟩, refl }⟩\n\nvariables {C} {D}\n\n/-- A functor `C ⥤ D` computably lowers to a functor `thin_skeleton C ⥤ thin_skeleton D`. -/\n@[simps]\ndef map (F : C ⥤ D) : thin_skeleton C ⥤ thin_skeleton D :=\n{ obj := quotient.map F.obj $ λ X₁ X₂ ⟨hX⟩, ⟨F.map_iso hX⟩,\n  map := λ X Y, quotient.rec_on_subsingleton₂ X Y $\n           λ x y k, hom_of_le (k.le.elim (λ t, ⟨F.map t⟩)) }\n\nlemma comp_to_thin_skeleton (F : C ⥤ D) : F ⋙ to_thin_skeleton D = to_thin_skeleton C ⋙ map F :=\nrfl\n\n/-- Given a natural transformation `F₁ ⟶ F₂`, induce a natural transformation `map F₁ ⟶ map F₂`.-/\ndef map_nat_trans {F₁ F₂ : C ⥤ D} (k : F₁ ⟶ F₂) : map F₁ ⟶ map F₂ :=\n{ app := λ X, quotient.rec_on_subsingleton X (λ x, ⟨⟨⟨k.app x⟩⟩⟩) }\n\n-- TODO: state the lemmas about what happens when you compose with `to_thin_skeleton`\n/-- A functor `C ⥤ D ⥤ E` computably lowers to a functor\n`thin_skeleton C ⥤ thin_skeleton D ⥤ thin_skeleton E` -/\n@[simps]\ndef map₂ (F : C ⥤ D ⥤ E) :\n  thin_skeleton C ⥤ thin_skeleton D ⥤ thin_skeleton E :=\n{ obj := λ x,\n  { obj := λ y, quotient.map₂ (λ X Y, (F.obj X).obj Y)\n                (λ X₁ X₂ ⟨hX⟩ Y₁ Y₂ ⟨hY⟩, ⟨(F.obj X₁).map_iso hY ≪≫ (F.map_iso hX).app Y₂⟩) x y,\n    map := λ y₁ y₂, quotient.rec_on_subsingleton x $\n            λ X, quotient.rec_on_subsingleton₂ y₁ y₂ $\n              λ Y₁ Y₂ hY, hom_of_le (hY.le.elim (λ g, ⟨(F.obj X).map g⟩)) },\n  map := λ x₁ x₂, quotient.rec_on_subsingleton₂ x₁ x₂ $\n           λ X₁ X₂ f,\n           { app := λ y, quotient.rec_on_subsingleton y\n              (λ Y, hom_of_le (f.le.elim (λ f', ⟨(F.map f').app Y⟩))) } }\n\nvariables (C)\n\nsection\nvariables [quiver.is_thin C]\n\ninstance to_thin_skeleton_faithful : faithful (to_thin_skeleton C) := {}\n\n/-- Use `quotient.out` to create a functor out of the thin skeleton. -/\n@[simps]\nnoncomputable def from_thin_skeleton : thin_skeleton C ⥤ C :=\n{ obj := quotient.out,\n  map := λ x y, quotient.rec_on_subsingleton₂ x y $\n    λ X Y f,\n            (nonempty.some (quotient.mk_out X)).hom\n          ≫ f.le.some\n          ≫ (nonempty.some (quotient.mk_out Y)).inv }\n\nnoncomputable instance from_thin_skeleton_equivalence : is_equivalence (from_thin_skeleton C) :=\n{ inverse := to_thin_skeleton C,\n  counit_iso := nat_iso.of_components (λ X, (nonempty.some (quotient.mk_out X))) (by tidy),\n  unit_iso :=\n    nat_iso.of_components\n      (λ x, quotient.rec_on_subsingleton x\n        (λ X, eq_to_iso (quotient.sound ⟨(nonempty.some (quotient.mk_out X)).symm⟩)))\n      (by tidy) }\n\n/-- The equivalence between the thin skeleton and the category itself. -/\nnoncomputable def equivalence : thin_skeleton C ≌ C :=\n(from_thin_skeleton C).as_equivalence\n\nvariables {C}\n\nlemma equiv_of_both_ways {X Y : C} (f : X ⟶ Y) (g : Y ⟶ X) : X ≈ Y :=\n⟨iso_of_both_ways f g⟩\n\ninstance thin_skeleton_partial_order : partial_order (thin_skeleton C) :=\n{ le_antisymm := quotient.ind₂\n  begin\n    rintros _ _ ⟨f⟩ ⟨g⟩,\n    apply quotient.sound (equiv_of_both_ways f g),\n  end,\n  ..category_theory.thin_skeleton.preorder C }\n\nlemma skeletal : skeletal (thin_skeleton C) :=\nλ X Y, quotient.induction_on₂ X Y $ λ x y h, h.elim $ λ i, i.1.le.antisymm i.2.le\n\nlemma map_comp_eq (F : E ⥤ D) (G : D ⥤ C) : map (F ⋙ G) = map F ⋙ map G :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (λ X, quotient.rec_on_subsingleton X (λ x, iso.refl _)) (by tidy)\n\nlemma map_id_eq : map (𝟭 C) = 𝟭 (thin_skeleton C) :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (λ X, quotient.rec_on_subsingleton X (λ x, iso.refl _)) (by tidy)\n\nlemma map_iso_eq {F₁ F₂ : D ⥤ C} (h : F₁ ≅ F₂) : map F₁ = map F₂ :=\nfunctor.eq_of_iso skeletal { hom := map_nat_trans h.hom, inv := map_nat_trans h.inv }\n\n/-- `from_thin_skeleton C` exhibits the thin skeleton as a skeleton. -/\nnoncomputable def thin_skeleton_is_skeleton : is_skeleton_of C (thin_skeleton C)\n  (from_thin_skeleton C) :=\n{ skel := skeletal,\n  eqv := thin_skeleton.from_thin_skeleton_equivalence C }\n\nnoncomputable instance is_skeleton_of_inhabited :\n  inhabited (is_skeleton_of C (thin_skeleton C) (from_thin_skeleton C)) :=\n⟨thin_skeleton_is_skeleton⟩\n\nend\n\nvariables {C}\n\n/-- An adjunction between thin categories gives an adjunction between their thin skeletons. -/\ndef lower_adjunction\n  (R : D ⥤ C) (L : C ⥤ D) (h : L ⊣ R) :\n  thin_skeleton.map L ⊣ thin_skeleton.map R :=\nadjunction.mk_of_unit_counit\n{ unit :=\n  { app := λ X,\n    begin\n      letI := is_isomorphic_setoid C,\n      refine quotient.rec_on_subsingleton X (λ x, hom_of_le ⟨h.unit.app x⟩),\n      -- TODO: make quotient.rec_on_subsingleton' so the letI isn't needed\n    end },\n  counit :=\n  { app := λ X,\n    begin\n      letI := is_isomorphic_setoid D,\n      refine quotient.rec_on_subsingleton X (λ x, hom_of_le ⟨h.counit.app x⟩),\n    end } }\n\nend thin_skeleton\n\nopen thin_skeleton\n\nsection\nvariables {C} {α : Type*} [partial_order α]\n\n/--\nWhen `e : C ≌ α` is a categorical equivalence from a thin category `C` to some partial order `α`,\nthe `thin_skeleton C` is order isomorphic to `α`.\n-/\nnoncomputable\ndef equivalence.thin_skeleton_order_iso\n  [quiver.is_thin C] (e : C ≌ α) : thin_skeleton C ≃o α :=\n((thin_skeleton.equivalence C).trans e).to_order_iso\n\nend\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/skeletal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.49704924605093675}}
{"text": "/-\nCopyright (c) 2020 Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Calle Sönne\n-/\n\nimport topology.category.CompHaus\nimport topology.connected\nimport topology.subset_properties\nimport category_theory.adjunction.reflective\nimport category_theory.monad.limits\n\n/-!\n# The category of Profinite Types\n\nWe construct the category of profinite topological spaces,\noften called profinite sets -- perhaps they could be called\nprofinite types in Lean.\n\nThe type of profinite topological spaces is called `Profinite`. It has a category\ninstance and is a fully faithful subcategory of `Top`. The fully faithful functor\nis called `Profinite_to_Top`.\n\n## Implementation notes\n\nA profinite type is defined to be a topological space which is\ncompact, Hausdorff and totally disconnected.\n\n## TODO\n\n0. Link to category of projective limits of finite discrete sets.\n1. finite coproducts\n2. Clausen/Scholze topology on the category `Profinite`.\n\n## Tags\n\nprofinite\n\n-/\n\nopen category_theory\n\n/-- The type of profinite topological spaces. -/\nstructure Profinite :=\n(to_Top : Top)\n[is_compact : compact_space to_Top]\n[is_t2 : t2_space to_Top]\n[is_totally_disconnected : totally_disconnected_space to_Top]\n\nnamespace Profinite\n\ninstance : inhabited Profinite := ⟨{to_Top := { α := pempty }}⟩\n\ninstance category : category Profinite := induced_category.category to_Top\ninstance concrete_category : concrete_category Profinite := induced_category.concrete_category _\ninstance has_forget₂ : has_forget₂ Profinite Top := induced_category.has_forget₂ _\n\ninstance : has_coe_to_sort Profinite := ⟨Type*, λ X, X.to_Top⟩\ninstance {X : Profinite} : compact_space X := X.is_compact\ninstance {X : Profinite} : t2_space X := X.is_t2\ninstance {X : Profinite} : totally_disconnected_space X := X.is_totally_disconnected\n\n@[simp]\nlemma coe_to_Top {X : Profinite} : (X.to_Top : Type*) = X :=\nrfl\n\n@[simp] lemma coe_id (X : Profinite) : (𝟙 X : X → X) = id := rfl\n\n@[simp] lemma coe_comp {X Y Z : Profinite} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g : X → Z) = g ∘ f := rfl\n\nend Profinite\n\n/-- The fully faithful embedding of `Profinite` in `Top`. -/\n@[simps, derive [full, faithful]]\ndef Profinite_to_Top : Profinite ⥤ Top := forget₂ _ _\n\n/-- The fully faithful embedding of `Profinite` in `CompHaus`. -/\n@[simps] def Profinite.to_CompHaus : Profinite ⥤ CompHaus :=\n{ obj := λ X, { to_Top := X.to_Top },\n  map := λ _ _ f, f }\n\ninstance : full Profinite.to_CompHaus := { preimage := λ _ _ f, f }\ninstance : faithful Profinite.to_CompHaus := {}\n\n@[simp] lemma Profinite.to_CompHaus_to_Top :\n  Profinite.to_CompHaus ⋙ CompHaus_to_Top = Profinite_to_Top :=\nrfl\n\nsection Profinite\nlocal attribute [instance] connected_component_setoid\n\nuniverses u\n\n/--\n(Implementation) The object part of the connected_components functor from compact Hausdorff spaces\nto Profinite spaces, given by quotienting a space by its connected components.\nSee: https://stacks.math.columbia.edu/tag/0900\n-/\n-- Without explicit universe annotations here, Lean introduces two universe variables and\n-- unhelpfully defines a function `CompHaus.{max u₁ u₂} → Profinite.{max u₁ u₂}`.\ndef CompHaus.to_Profinite_obj (X : CompHaus.{u}) : Profinite.{u} :=\n{ to_Top := { α := connected_components X.to_Top.α },\n  is_compact := quotient.compact_space,\n  is_t2 := connected_components.t2,\n  is_totally_disconnected := connected_components.totally_disconnected_space }\n\n/--\n(Implementation) The bijection of homsets to establish the reflective adjunction of Profinite\nspaces in compact Hausdorff spaces.\n-/\ndef Profinite.to_CompHaus_equivalence (X : CompHaus.{u}) (Y : Profinite.{u}) :\n  (CompHaus.to_Profinite_obj X ⟶ Y) ≃ (X ⟶ Profinite.to_CompHaus.obj Y) :=\n{ to_fun := λ f,\n  { to_fun := f.1 ∘ quotient.mk,\n    continuous_to_fun := continuous.comp f.2 (continuous_quotient_mk) },\n  inv_fun := λ g,\n    { to_fun := continuous.connected_components_lift g.2,\n      continuous_to_fun := continuous.connected_components_lift_continuous g.2},\n  left_inv := λ f, continuous_map.ext $ λ x, quotient.induction_on x $ λ a, rfl,\n  right_inv := λ f, continuous_map.ext $ λ x, rfl }\n\n/--\nThe connected_components functor from compact Hausdorff spaces to profinite spaces,\nleft adjoint to the inclusion functor.\n-/\ndef CompHaus.to_Profinite : CompHaus ⥤ Profinite :=\nadjunction.left_adjoint_of_equiv Profinite.to_CompHaus_equivalence (λ _ _ _ _ _, rfl)\n\nlemma CompHaus.to_Profinite_obj' (X : CompHaus) :\n  ↥(CompHaus.to_Profinite.obj X) = connected_components X.to_Top.α := rfl\n\nend Profinite\n\nnamespace Profinite\n\n/--\nThe adjunction between CompHaus.to_Profinite and Profinite.to_CompHaus\n-/\ndef to_Profinite_adj_to_CompHaus : CompHaus.to_Profinite ⊣ Profinite.to_CompHaus :=\nadjunction.adjunction_of_equiv_left _ _\n\n/-- The category of profinite sets is reflective in the category of compact hausdroff spaces -/\ninstance to_CompHaus.reflective : reflective Profinite.to_CompHaus :=\n{ to_is_right_adjoint := ⟨CompHaus.to_Profinite, Profinite.to_Profinite_adj_to_CompHaus⟩ }\n\nnoncomputable\ninstance to_CompHaus.creates_limits : creates_limits Profinite.to_CompHaus :=\nmonadic_creates_limits _\n\nnoncomputable\ninstance to_Top.reflective : reflective (Profinite_to_Top : Profinite ⥤ Top) :=\nreflective.comp Profinite.to_CompHaus CompHaus_to_Top\n\nnoncomputable\ninstance to_Top.creates_limits : creates_limits Profinite_to_Top :=\nmonadic_creates_limits _\n\ninstance has_limits : limits.has_limits Profinite :=\nhas_limits_of_has_limits_creates_limits Profinite_to_Top\n\ninstance has_colimits : limits.has_colimits Profinite :=\nhas_colimits_of_reflective to_CompHaus\n\n/-- Any morphism of profinite spaces is a closed map. -/\nlemma is_closed_map {X Y : Profinite} (f : X ⟶ Y) : is_closed_map f :=\nshow is_closed_map (Profinite.to_CompHaus.map f), from CompHaus.is_closed_map _\n\n/-- Any continuous bijection of profinite spaces induces an isomorphism. -/\nlemma is_iso_of_bijective {X Y : Profinite} (f : X ⟶ Y)\n  (bij : function.bijective f) : is_iso f :=\nbegin\n  haveI := CompHaus.is_iso_of_bijective (Profinite.to_CompHaus.map f) bij,\n  exact is_iso_of_fully_faithful Profinite.to_CompHaus _\nend\n\n/-- Any continuous bijection of profinite spaces induces an isomorphism. -/\nnoncomputable def iso_of_bijective {X Y : Profinite} (f : X ⟶ Y)\n  (bij : function.bijective f) : X ≅ Y :=\nby letI := Profinite.is_iso_of_bijective f bij; exact as_iso f\n\ninstance forget_reflects_isomorphisms : reflects_isomorphisms (forget Profinite) :=\n⟨by introsI A B f hf; exact Profinite.is_iso_of_bijective _ ((is_iso_iff_bijective ⇑f).mp hf)⟩\n\nend Profinite\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/category/Profinite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.49704924384987687}}
{"text": "import inner_product_spaces.real_ip.ip_normed_space\nimport linear_algebra.basic\nimport analysis.normed_space.bounded_linear_maps\nimport data.set.countable\nimport linear_algebra.linear_combination\n\nnoncomputable theory\n\nvariables {α : Type*} {β : Type*}\nvariables [decidable_eq α] [add_comm_group α] [vector_space ℝ α] [ℝ_inner_product_space α]\nvariables [decidable_eq β] [add_comm_group β] [vector_space ℝ β] [ℝ_inner_product_space β]\n\nopen real function\n\ndef ℝ_topological_space : topological_space ℝ := by apply_instance\n\ndef α_uniform_space : uniform_space α :=\nbegin\n    have w := @ip_space_is_metric_space α _ _ _ _,\n    exact @metric_space.to_uniform_space α w,\nend\n\ndef α_topological_space : topological_space α := @uniform_space.to_topological_space α α_uniform_space\n\nsection ip_map\n\ndef ip_map (x : α) : linear_map ℝ α ℝ :=\nbegin\n    refine_struct {..},\n    use λ y, ⟪x ∥ y⟫,\n    repeat {simp},\nend\n\n@[simp] lemma ip_map_to_fun (x : α) : ⇑(ip_map x) = λ y, ⟪x ∥ y⟫ := rfl\n\ntheorem ip_map_is_bounded_linear_map (x : α) : @is_bounded_linear_map ℝ _ α ip_space_is_normed_space ℝ _ (ip_map x) :=\nbegin\n    constructor,\n    constructor,\n    repeat {simp},\n\n    by_cases (x = 0),\n\n    use 1,\n    split,\n    exact zero_lt_one,\n    intros y,\n    rw [h],\n    simp,\n\n    use ∥x∥,\n    split,\n    have w := (@norm_neq_zero_iff_neq_zero α (ip_space_is_normed_space) x).2 h,\n    have α_normed_group : normed_group α := begin\n        have w := @ip_space_is_normed_space α _ _ _ _,\n        exact @normed_space.to_normed_group ℝ α _ w,\n    end,\n    have k := (@norm_pos_iff α α_normed_group x).2,\n    rw [ne.def] at k,\n    sorry,\n    intros y,\n    exact cauchy_schwarz x y,\nend\n\nlemma ip_map_is_continuous (x : α) : @continuous α _ α_topological_space ℝ_topological_space (ip_map x) :=\n@is_bounded_linear_map.continuous ℝ _ α ip_space_is_normed_space ℝ _ _ (ip_map_is_bounded_linear_map x)\n\nend ip_map\n\nsection hilbert_space\n\nclass Hilbert_space (α : Type*) [decidable_eq α] [add_comm_group α] [vector_space ℝ α] extends ℝ_inner_product_space α :=\n(complete : ∀ {f : filter α}, (@cauchy α (@α_uniform_space α _ _ _ _)) f → ∃x, f ≤ @nhds α (@α_topological_space α _ _ _ _) x)\n\nvariables [Hilbert_space α] [Hilbert_space β]\n\nstructure unitary_operator (α : Type*) (β : Type*) [decidable_eq α] [add_comm_group α] [vector_space ℝ α] [ℝ_inner_product_space α] [Hilbert_space α]\n[decidable_eq β] [add_comm_group β] [vector_space ℝ β] [ℝ_inner_product_space β] [Hilbert_space β] extends linear_map ℝ α β :=\n(bijective : bijective to_fun)\n(norm_preserving : ∀ (x : α), ∥to_fun x∥ = ∥x∥)\n\nvariables {T : unitary_operator α β}\n\n@[simp] lemma norm_preserving (x : α) : ∥T.to_fun x∥ = ∥x∥ :=\nby apply unitary_operator.norm_preserving\n\nlemma polarisation_identity (x y : α) : ⟪x ∥ y⟫ = 1/4*(∥x+y∥^2 - ∥x-y∥^2) :=\nbegin\n    conv {to_lhs, rw [←one_mul ⟪x ∥ y⟫, ←@inv_mul_cancel _ _ (4 : ℝ) four_ne_zero]},\n    rw [←one_div_eq_inv, mul_assoc],\n    apply congr_arg (λ (r : ℝ), 1/4 * r),\n    dsimp [norm],\n    rw [sqr_sqrt (norm_sq_nonneg _), sqr_sqrt (norm_sq_nonneg _)],\n    dsimp [norm_sq],\n    rw [add_left, add_left, add_right, add_right, add_right, add_right, ←neg_one_smul ℝ y,\n    mul_left, mul_left, mul_right, mul_right, conj_symm y x],\n    ring,\nend\n\n@[simp] theorem ip_preserving (x y : α) : ⟪T.to_fun x ∥ T.to_fun y⟫ = ⟪x ∥ y⟫ :=\nbegin\n    rw [polarisation_identity (T.to_fun x) (T.to_fun y), ←linear_map.add, \n        sub_eq_add_neg (T.to_fun x) (T.to_fun y), ←neg_one_smul ℝ (T.to_fun y),\n        ←linear_map.smul, ←linear_map.add, norm_preserving, norm_preserving,\n        neg_one_smul, ←sub_eq_add_neg, ←polarisation_identity],\nend\n\nend hilbert_space\n\nopen set finsupp\n\nsection separable\n\n\n\n-- def coeff_sum (f : α →₀ ℝ) : finset.sum (finset.map (λ (a : α), f a • a) f.support)\n\n\nlocal attribute [instance, priority 0] classical.prop_decidable\nnoncomputable theory\n\n-- def lc.total' {α β} [discrete_field α] [add_comm_group β] [vector_space α β] (f : β →₀ α) : β := (lc.total _ _ _ id).1 f\n-- variables [Hilbert_space α]\n-- variables (sep : ∃ (S : set α), countable S ∧ ∀ (x : α) (ε > 0), ∃ (f : α →₀ ℝ), ∥sum {z | ∃ (e ∈ S), z = f e • e} - x∥ < ε)\n\nend separable", "meta": {"author": "MartinSkilleter", "repo": "real_ip_spaces", "sha": "1ad1e0456602038711cbb0de7aa92b88d6eff06f", "save_path": "github-repos/lean/MartinSkilleter-real_ip_spaces", "path": "github-repos/lean/MartinSkilleter-real_ip_spaces/real_ip_spaces-1ad1e0456602038711cbb0de7aa92b88d6eff06f/src/inner_product_spaces/real_ip/hilbert_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527631, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4970323294970124}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport category_theory.morphism_property\nimport category_theory.category.Quiv\n\n/-!\n\n# Construction of the localized category\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file constructs the localized category, obtained by formally inverting\na class of maps `W : morphism_property C` in a category `C`.\n\nWe first construct a quiver `loc_quiver W` whose objects are the same as those\nof `C` and whose maps are the maps in `C` and placeholders for the formal\ninverses of the maps in `W`.\n\nThe localized category `W.localization` is obtained by taking the quotient\nof the path category of `loc_quiver W` by the congruence generated by four\ntypes of relations.\n\nThe obvious functor `Q W : C ⥤ W.localization` satisfies the universal property\nof the localization. Indeed, if `G : C ⥤ D` sends morphisms in `W` to isomorphisms\nin `D` (i.e. we have `hG : W.is_inverted_by G`), then there exists a unique functor\n`G' : W.localization ⥤ D` such that `Q W ≫ G' = G`. This `G'` is `lift G hG`.\nThe expected property of `lift G hG` if expressed by the lemma `fac` and the\nuniqueness is expressed by `uniq`.\n\n## References\n\n* [P. Gabriel, M. Zisman, *Calculus of fractions and homotopy theory*][gabriel-zisman-1967]\n\n-/\n\nnoncomputable theory\n\nopen category_theory.category\n\nnamespace category_theory\n\nvariables {C : Type*} [category C] (W : morphism_property C) {D : Type*} [category D]\n\nnamespace localization\n\nnamespace construction\n\n/-- If `W : morphism_property C`, `loc_quiver W` is a quiver with the same objects\nas `C`, and whose morphisms are those in `C` and placeholders for formal\ninverses of the morphisms in `W`. -/\n@[nolint has_nonempty_instance]\nstructure loc_quiver (W : morphism_property C) := (obj : C)\n\ninstance : quiver (loc_quiver W) :=\n{ hom := λ A B, (A.obj ⟶ B.obj) ⊕ { f : B.obj ⟶ A.obj // W f} }\n\n/-- The object in the path category of `loc_quiver W` attached to an object in\nthe category `C` -/\ndef ι_paths (X : C) : paths (loc_quiver W) := ⟨X⟩\n\n/-- The morphism in the path category associated to a morphism in the original category. -/\n@[simp]\ndef ψ₁ {X Y : C} (f : X ⟶ Y) : ι_paths W X ⟶ ι_paths W Y := paths.of.map (sum.inl f)\n\n/-- The morphism in the path category corresponding to a formal inverse. -/\n@[simp]\ndef ψ₂ {X Y : C} (w : X ⟶ Y) (hw : W w) : ι_paths W Y ⟶ ι_paths W X :=\npaths.of.map (sum.inr ⟨w, hw⟩)\n\n/-- The relations by which we take the quotient in order to get the localized category. -/\ninductive relations : hom_rel (paths (loc_quiver W))\n| id (X : C) :\n  relations (ψ₁ W (𝟙 X)) (𝟙 _)\n| comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  relations (ψ₁ W (f ≫ g)) (ψ₁ W f ≫ ψ₁ W g)\n| Winv₁ {X Y : C} (w : X ⟶ Y) (hw : W w) :\n  relations (ψ₁ W w ≫ ψ₂ W w hw) (𝟙 _)\n| Winv₂ {X Y : C} (w : X ⟶ Y) (hw : W w) :\n  relations (ψ₂ W w hw ≫ ψ₁ W w) (𝟙 _)\n\nend construction\n\nend localization\n\nnamespace morphism_property\n\nopen localization.construction\n\n/-- The localized category obtained by formally inverting the morphisms\nin `W : morphism_property C` -/\n@[derive category, nolint has_nonempty_instance]\ndef localization := category_theory.quotient (localization.construction.relations W)\n\n/-- The obvious functor `C ⥤ W.localization` -/\ndef Q : C ⥤ W.localization :=\n{ obj := λ X, (quotient.functor _).obj (paths.of.obj ⟨X⟩),\n  map := λ X Y f, (quotient.functor _).map (ψ₁ W f),\n  map_id' := λ X, quotient.sound _ (relations.id X),\n  map_comp' := λ X Z Y f g, quotient.sound _ (relations.comp f g), }\n\nend morphism_property\n\nnamespace localization\n\nnamespace construction\n\nvariable {W}\n\n/-- The isomorphism in `W.localization` associated to a morphism `w` in W -/\ndef Wiso {X Y : C} (w : X ⟶ Y) (hw : W w) : iso (W.Q.obj X) (W.Q.obj Y) :=\n{ hom := W.Q.map w,\n  inv := (quotient.functor _).map (paths.of.map (sum.inr ⟨w, hw⟩)),\n  hom_inv_id' := quotient.sound _ (relations.Winv₁ w hw),\n  inv_hom_id' := quotient.sound _ (relations.Winv₂ w hw), }\n\n/-- The formal inverse in `W.localization` of a morphism `w` in `W`. -/\nabbreviation Winv {X Y : C} (w : X ⟶ Y) (hw : W w) := (Wiso w hw).inv\n\nvariable (W)\n\nlemma _root_.category_theory.morphism_property.Q_inverts : W.is_inverted_by W.Q :=\nλ X Y w hw, is_iso.of_iso (localization.construction.Wiso w hw)\n\nvariables {W} (G : C ⥤ D) (hG : W.is_inverted_by G)\n\ninclude G hG\n\n/-- The lifting of a functor to the path category of `loc_quiver W` -/\n@[simps]\ndef lift_to_path_category : paths (loc_quiver W) ⥤ D :=\nQuiv.lift\n{ obj := λ X, G.obj X.obj,\n  map := λ X Y, begin\n    rintro (f|⟨g, hg⟩),\n    { exact G.map f, },\n    { haveI := hG g hg,\n      exact inv (G.map g), },\n  end, }\n\n/-- The lifting of a functor `C ⥤ D` inverting `W` as a functor `W.localization ⥤ D` -/\n@[simps]\ndef lift : W.localization ⥤ D :=\nquotient.lift (relations W) (lift_to_path_category G hG)\nbegin\n  rintro ⟨X⟩ ⟨Y⟩ f₁ f₂ r,\n  rcases r,\n  tidy,\nend\n\n@[simp]\nlemma fac : W.Q ⋙ lift G hG = G :=\nfunctor.ext (λ X, rfl)\nbegin\n  intros X Y f,\n  simp only [functor.comp_map, eq_to_hom_refl, comp_id, id_comp],\n  dsimp [lift, lift_to_path_category, morphism_property.Q],\n  rw compose_path_to_path,\nend\n\nomit G hG\n\n\n\nvariable (W)\n\n/-- The canonical bijection between objects in a category and its\nlocalization with respect to a morphism_property `W` -/\n@[simps]\ndef obj_equiv : C ≃ W.localization :=\n{ to_fun := W.Q.obj,\n  inv_fun := λ X, X.as.obj,\n  left_inv := λ X, rfl,\n  right_inv := by { rintro ⟨⟨X⟩⟩, refl, }, }\n\nvariable {W}\n\n/-- A `morphism_property` in `W.localization` is satisfied by all\nmorphisms in the localized category if it contains the image of the\nmorphisms in the original category, the inverses of the morphisms\nin `W` and if it is stable under composition -/\nlemma morphism_property_is_top\n  (P : morphism_property W.localization)\n  (hP₁ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), P (W.Q.map f))\n  (hP₂ : ∀ ⦃X Y : C⦄ (w : X ⟶ Y) (hw : W w), P (Winv w hw))\n  (hP₃ : P.stable_under_composition) : P = ⊤ :=\nbegin\n  ext X Y f,\n  split,\n  { intro hf,\n    simp only [pi.top_apply], },\n  { intro hf, clear hf,\n    let G : _ ⥤ W.localization := quotient.functor _,\n    suffices : ∀ (X₁ X₂ : C) (p : localization.construction.ι_paths W X₁ ⟶\n      localization.construction.ι_paths W X₂), P (G.map p),\n    { rcases X with ⟨⟨X⟩⟩,\n      rcases Y with ⟨⟨Y⟩⟩,\n      simpa only [functor.image_preimage] using this _ _ (G.preimage f), },\n    intros X₁ X₂ p,\n    induction p with X₂ X₃ p g hp,\n    { simpa only [functor.map_id] using hP₁ (𝟙 X₁), },\n    { cases X₂,\n      cases X₃,\n      let p' : ι_paths W X₁ ⟶ ι_paths W X₂ := p,\n      rw [show p.cons g = p' ≫ quiver.hom.to_path g, by refl, G.map_comp],\n      refine hP₃ _ _ hp _,\n      rcases g with (g | ⟨g, hg⟩),\n      { apply hP₁, },\n      { apply hP₂, }, }, },\nend\n\n/-- A `morphism_property` in `W.localization` is satisfied by all\nmorphisms in the localized category if it contains the image of the\nmorphisms in the original category, if is stable under composition\nand if the property is stable by passing to inverses. -/\nlemma morphism_property_is_top'\n  (P : morphism_property W.localization)\n  (hP₁ : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), P (W.Q.map f))\n  (hP₂ : ∀ ⦃X Y : W.localization⦄ (e : X ≅ Y) (he : P e.hom), P e.inv)\n  (hP₃ : P.stable_under_composition) : P = ⊤ :=\nmorphism_property_is_top P hP₁ (λ X Y w hw, hP₂ _ (by exact hP₁ w)) hP₃\n\nnamespace nat_trans_extension\n\nvariables {F₁ F₂ : W.localization ⥤ D} (τ : W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂)\ninclude τ\n\n/-- If `F₁` and `F₂` are functors `W.localization ⥤ D` and if we have\n`τ : W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂`, we shall define a natural transformation `F₁ ⟶ F₂`.\nThis is the `app` field of this natural transformation. -/\ndef app (X : W.localization) : F₁.obj X ⟶ F₂.obj X :=\neq_to_hom (congr_arg F₁.obj ((obj_equiv W).right_inv X).symm) ≫\n    τ.app ((obj_equiv W).inv_fun X) ≫ eq_to_hom (congr_arg F₂.obj ((obj_equiv W).right_inv X))\n\n@[simp]\nlemma app_eq (X : C) : (app τ) (W.Q.obj X) = τ.app X :=\nby simpa only [app, eq_to_hom_refl, comp_id, id_comp]\n\nend nat_trans_extension\n\n/-- If `F₁` and `F₂` are functors `W.localization ⥤ D`, a natural transformation `F₁ ⟶ F₂`\ncan be obtained from a natural transformation `W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂`. -/\n@[simps]\ndef nat_trans_extension {F₁ F₂ : W.localization ⥤ D} (τ : W.Q ⋙ F₁ ⟶ W.Q ⋙ F₂) :\n  F₁ ⟶ F₂ :=\n{ app := nat_trans_extension.app τ,\n  naturality' := λ X Y f, begin\n    have h := morphism_property_is_top'\n      (morphism_property.naturality_property (nat_trans_extension.app τ)) _\n      (morphism_property.naturality_property.is_stable_under_inverse _)\n      (morphism_property.naturality_property.is_stable_under_composition _), swap,\n    { intros X Y f,\n      simpa only [morphism_property.naturality_property, nat_trans_extension.app_eq]\n        using τ.naturality f, },\n    have hf : (⊤ : morphism_property _) f := by simp only [pi.top_apply],\n    simpa only [← h] using hf,\n  end,  }\n\n@[simp]\nlemma nat_trans_extension_hcomp {F G : W.localization ⥤ D} (τ : W.Q ⋙ F ⟶ W.Q ⋙ G) :\n  (𝟙 W.Q) ◫ nat_trans_extension τ = τ :=\nbegin\n  ext X,\n  simp only [nat_trans.hcomp_app, nat_trans.id_app, G.map_id, comp_id,\n    nat_trans_extension_app, nat_trans_extension.app_eq],\nend\n\nlemma nat_trans_hcomp_injective {F G : W.localization ⥤ D} {τ₁ τ₂ : F ⟶ G}\n  (h : 𝟙 W.Q ◫ τ₁ = 𝟙 W.Q ◫ τ₂) : τ₁ = τ₂ :=\nbegin\n  ext X,\n  have eq := (obj_equiv W).right_inv X,\n  simp only [obj_equiv] at eq,\n  rw [← eq, ← nat_trans.id_hcomp_app, ← nat_trans.id_hcomp_app, h],\nend\n\nvariables (W D)\n\nnamespace whiskering_left_equivalence\n\n/-- The functor `(W.localization ⥤ D) ⥤ (W.functors_inverting D)` induced by the\ncomposition with `W.Q : C ⥤ W.localization`. -/\n@[simps]\ndef functor : (W.localization ⥤ D) ⥤ (W.functors_inverting D) :=\nfull_subcategory.lift _ ((whiskering_left _ _ D).obj W.Q)\n  (λ F, morphism_property.is_inverted_by.of_comp W W.Q W.Q_inverts _)\n\n/-- The function `(W.functors_inverting D) ⥤ (W.localization ⥤ D)` induced by\n`construction.lift`. -/\n@[simps]\ndef inverse : (W.functors_inverting D) ⥤ (W.localization ⥤ D) :=\n{ obj := λ G, lift G.obj G.property,\n  map := λ G₁ G₂ τ, nat_trans_extension (eq_to_hom (by rw fac) ≫ τ ≫ eq_to_hom (by rw fac)),\n  map_id' := λ G, nat_trans_hcomp_injective begin\n    rw nat_trans_extension_hcomp,\n    ext X,\n    simpa only [nat_trans.comp_app, eq_to_hom_app, eq_to_hom_refl, comp_id, id_comp,\n      nat_trans.hcomp_id_app, nat_trans.id_app, functor.map_id],\n  end,\n  map_comp' := λ G₁ G₂ G₃ τ₁ τ₂, nat_trans_hcomp_injective begin\n    ext X,\n    simpa only [nat_trans_extension_hcomp, nat_trans.comp_app, eq_to_hom_app, eq_to_hom_refl,\n      id_comp, comp_id, nat_trans.hcomp_app, nat_trans.id_app, functor.map_id,\n      nat_trans_extension_app, nat_trans_extension.app_eq],\n  end, }\n\n/-- The unit isomorphism of the equivalence of categories `whiskering_left_equivalence W D`. -/\n@[simps]\ndef unit_iso : 𝟭 (W.localization ⥤ D) ≅ functor W D ⋙ inverse W D := eq_to_iso\nbegin\n  refine functor.ext (λ G, _) (λ G₁ G₂ τ, _),\n  { apply uniq,\n    dsimp [functor],\n    rw fac, },\n  { apply nat_trans_hcomp_injective,\n    ext X,\n    simp only [functor.id_map, nat_trans.hcomp_app, comp_id, functor.comp_map,\n      inverse_map, nat_trans.comp_app, eq_to_hom_app, eq_to_hom_refl, nat_trans_extension_app,\n      nat_trans_extension.app_eq, functor_map_app, id_comp], },\nend\n\n/-- The counit isomorphism of the equivalence of categories `whiskering_left_equivalence W D`. -/\n@[simps]\ndef counit_iso : inverse W D ⋙ functor W D ≅ 𝟭 (W.functors_inverting D) := eq_to_iso\nbegin\n  refine functor.ext _ _,\n  { rintro ⟨G, hG⟩,\n    ext1,\n    apply fac, },\n  { rintros ⟨G₁, hG₁⟩ ⟨G₂, hG₂⟩ f,\n    ext X,\n    apply nat_trans_extension.app_eq, },\nend\n\nend whiskering_left_equivalence\n\n/-- The equivalence of categories `(W.localization ⥤ D) ≌ (W.functors_inverting D)`\ninduced by the composition with `W.Q : C ⥤ W.localization`. -/\ndef whiskering_left_equivalence : (W.localization ⥤ D) ≌ W.functors_inverting D :=\n{ functor := whiskering_left_equivalence.functor W D,\n  inverse := whiskering_left_equivalence.inverse W D,\n  unit_iso := whiskering_left_equivalence.unit_iso W D,\n  counit_iso := whiskering_left_equivalence.counit_iso W D,\n  functor_unit_iso_comp' := λ F, begin\n    ext X,\n    simpa only [eq_to_hom_app, whiskering_left_equivalence.unit_iso_hom,\n      whiskering_left_equivalence.counit_iso_hom, eq_to_hom_map, eq_to_hom_trans,\n      eq_to_hom_refl],\n  end, }\n\nend construction\n\nend localization\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/localization/construction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.6187804337438502, "lm_q1q2_score": 0.49698823008141835}}
{"text": "open Nat.SOM\nexample : (x + y) * (x + y + 1) = x * (1 + y + x) + (y + 1 + x) * y :=\n  let ctx := [x, y]\n  let lhs : Expr := .mul (.add (.var 0) (.var 1)) (.add (.add (.var 0) (.var 1)) (.num 1))\n  let rhs : Expr := .add (.mul (.var 0) (.add (.add (.num 1) (.var 1)) (.var 0)))\n                         (.mul (.add (.add (.var 1) (.num 1)) (.var 0)) (.var 1))\n  Expr.eq_of_toPoly_eq ctx lhs rhs (Eq.refl true)\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/som1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.49698823008141824}}
{"text": "import analysis.real xenalib.M1Fstuff \n\ntheorem Q1 (S : set ℝ) (H1 : ∃ s : ℝ, s ∈ S) (H2 : ∃ b : ℝ, ∀ s : ℝ, s ∈ S → s ≤ b) :\n  ∃ x : ℝ, is_lub S x ∧ \n  ∀ T : set ℝ, (T ⊆ S ∧ ∃ t : ℝ, t ∈ T) → ∃ y : ℝ, is_lub T y ∧ y ≤ x :=\nbegin\ncases H1 with s₁ Hs₁,\ncases H2 with b Hb,\nhave Hlub := exists_supremum_real Hs₁ Hb,\ncases Hlub with x Hx,\nexistsi x,\nsplit,exact Hx,\nintros T HT,\nhave HT_bounded_above : ∀ t : ℝ, t ∈ T → t ≤ b,\n{ intros t Ht,\n  apply Hb,\n  apply HT.left,\n  exact Ht,\n},\ncases HT.right with t₁ Ht₁,\nhave HlubT := exists_supremum_real Ht₁ HT_bounded_above,\ncases HlubT with y₁ Hy₁,\nexistsi y₁,\nsplit, exact Hy₁,\napply Hy₁.right,\nintro t₂,\nintro Ht₂,\napply Hx.left,\napply HT.left,\nexact Ht₂\nend\n\nnoncomputable def decimal_expansion' (x : ℝ) (H1 : x ≥ 0) (H2 : x < 1) : ℕ → fin 10\n| 0 := ⟨0,dec_trivial⟩\n| (nat.succ m) := decimal_expansion' m \n-- crap I can't do yhis\n\n/-\nnoncomputable def decimal_expansion (x : ℝ) : ℤ × Π n : ℕ, fin 10 := \nbegin \nhave H1 := M1F.floor_real_exists x,\nhave Hm := classical.indefinite_description _ H1,\ncases Hm with m H1,\nrefine (m,_),\nlet y := x-m,\nhave H2 : y < 1,\nsimp [H1.right,add_comm],\nexact (λ d, match d with\n| 0 := ⟨0,dec_trivial⟩\n| succ e := ⟨1,dec_trivial⟩\nend),\nadmit,\nend\n-/\n-- Author: Chris Hughes\nimport data.nat.modeq data.set.finite\nopen nat\nlocal attribute [instance, priority 0] classical.prop_decidable\nnamespace set\nopen function\nuniverse u\nvariable α : Type u\n\n-- Two lemmas courtesy of Johannes Hölzl via gitter, due to be added to mathlib\nlemma infinite_univ_nat : infinite (univ : set ℕ) :=\n assume (h : finite (univ : set ℕ)),\n let ⟨n, hn⟩ := finset.exists_nat_subset_range h.to_finset in\n have n ∈ finset.range n, from finset.subset_iff.mpr hn $ by simp,\n by simp * at *\n\nlemma not_injective_nat_fintype [fintype α] [decidable_eq α] {f : ℕ → α} : ¬ injective f :=\n assume (h : injective f),\n have finite (f '' univ),\n   from finite_subset (finset.finite_to_set $ fintype.elems α) (assume a h, fintype.complete a),\n have finite (univ : set ℕ), from finite_of_finite_image h this,\n infinite_univ_nat this\n\nend set\n\n\nnoncomputable instance subtype.fintype_le_nat (n : ℕ) : fintype {i : ℕ // i ≤ n} :=\n  classical.choice $ set.finite_le_nat n\n\ntheorem sheet_7_2e (f : ℕ → ℕ) (d) : d > 0 → ∃ a b, a ≠ b ∧ f a ≡ f b [MOD d]:=begin\n  assume hd,\n  unfold modeq,\n  apply by_contradiction,\n  assume h,\n  let f' : ℕ → {i // i ≤ d} := λ n, ⟨f n % d, le_of_lt (mod_lt (f n) hd)⟩,\n  have h_inj : function.injective f',\n   assume a b,\n   simp[f'],\n   rw not_exists at h, have := h a, rw not_exists at this,\n   have := this b,\n   rwa [not_and',not_not] at this,\n  exact set.not_injective_nat_fintype {i // i ≤ d} h_inj,\nend", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/M1F/problem_bank/PB0701/S0701.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4969882300814182}}
{"text": "\nlemma commutativity_forall{S: Type}:\n  (∀(s: S), ∀(P: S → Prop), P s) ↔ \n    (∀(P: S → Prop), ∀(s: S), P s) := \nbegin\n  split,\n    assume pfUnivPS,\n    intros,\n    exact pfUnivPS s P,\n\n    assume pfUnivPS,\n    intros,\n    exact pfUnivPS P s,\nend\n\nlemma commutativity_forall'{S: Type}:\n  (∀(s: S), ∀(P: S → Prop), P s) ↔ \n    (∀(P': S → Prop), ∀(s': S), P' s') := \nbegin\n  split,\n    assume pfUnivPS,\n    intros,\n    exact pfUnivPS s' P',\n\n    assume pfUnivPS,\n    intros,\n    exact pfUnivPS P s,\nend\n\nlemma forall_is_impl{P Q: Prop}:\n   (∀(p: P), Q) ↔ (P → Q) :=\nbegin\n  split,\n    assume pfPimpQ,\n    assumption,\n\n    assume pfPimpQ,\n    assumption,\nend\n", "meta": {"author": "kevinsullivan", "repo": "uva-cs-dm-s19", "sha": "3e7177682acdb56a2d16914e0344c10335583dcf", "save_path": "github-repos/lean/kevinsullivan-uva-cs-dm-s19", "path": "github-repos/lean/kevinsullivan-uva-cs-dm-s19/uva-cs-dm-s19-3e7177682acdb56a2d16914e0344c10335583dcf/examples/forall_properties.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.49697243034907845}}
{"text": "open function\n\n#print surjective\n\nuniverses u v w\nvariables {α : Type u} {β : Type v} {γ : Type w}\nopen function\n\nlemma surjective_comp {g : β → γ} {f : α → β}\n  (hg : surjective g) (hf : surjective f) :\nsurjective (g ∘ f) := (\n  assume c: γ,\n  let ⟨b, (hgb: g b = c)⟩ := hg c in\n  let ⟨a, (hfa: f a = b)⟩ := hf b in\n  have hc: (g ∘ f) a = c, by rsimp,\n  ⟨a, hc⟩\n).", "meta": {"author": "ntabee", "repo": "lean-exercise", "sha": "5b23b9be3d361fff5e981d5be3a0a1175504b9f6", "save_path": "github-repos/lean/ntabee-lean-exercise", "path": "github-repos/lean/ntabee-lean-exercise/lean-exercise-5b23b9be3d361fff5e981d5be3a0a1175504b9f6/8.9.1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042765, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4969724303490784}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport order.hom.bounded\nimport topology.order.hom.basic\n\n/-!\n# Esakia morphisms\n\nThis file defines pseudo-epimorphisms and Esakia morphisms.\n\nWe use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to\nbe satisfied by itself and all stricter types.\n\n## Types of morphisms\n\n* `pseudo_epimorphism`: Pseudo-epimorphisms. Maps `f` such that `f a ≤ b` implies the existence of\n  `a'` such that `a ≤ a'` and `f a' = b`.\n* `esakia_hom`: Esakia morphisms. Continuous pseudo-epimorphisms.\n\n## Typeclasses\n\n* `pseudo_epimorphism_class`\n* `esakia_hom_class`\n\n## References\n\n* [Wikipedia, *Esakia space*](https://en.wikipedia.org/wiki/Esakia_space)\n-/\n\nopen function\n\nvariables {F α β γ δ : Type*}\n\n/-- The type of pseudo-epimorphisms, aka p-morphisms, aka bounded maps, from `α` to `β`. -/\nstructure pseudo_epimorphism (α β : Type*) [preorder α] [preorder β] extends α →o β :=\n(exists_map_eq_of_map_le' ⦃a : α⦄ ⦃b : β⦄ : to_fun a ≤ b → ∃ c, a ≤ c ∧ to_fun c = b)\n\n/-- The type of Esakia morphisms, aka continuous pseudo-epimorphisms, from `α` to `β`. -/\nstructure esakia_hom (α β : Type*) [topological_space α] [preorder α] [topological_space β]\n  [preorder β] extends α →Co β :=\n(exists_map_eq_of_map_le' ⦃a : α⦄ ⦃b : β⦄ : to_fun a ≤ b → ∃ c, a ≤ c ∧ to_fun c = b)\n\nsection\nset_option old_structure_cmd true\n\n/-- `pseudo_epimorphism_class F α β` states that `F` is a type of `⊔`-preserving morphisms.\n\nYou should extend this class when you extend `pseudo_epimorphism`. -/\nclass pseudo_epimorphism_class (F : Type*) (α β : out_param $ Type*) [preorder α] [preorder β]\n  extends rel_hom_class F ((≤) : α → α → Prop) ((≤) : β → β → Prop) :=\n(exists_map_eq_of_map_le (f : F) ⦃a : α⦄ ⦃b : β⦄ : f a ≤ b → ∃ c, a ≤ c ∧ f c = b)\n\n/-- `esakia_hom_class F α β` states that `F` is a type of lattice morphisms.\n\nYou should extend this class when you extend `esakia_hom`. -/\nclass esakia_hom_class (F : Type*) (α β : out_param $ Type*) [topological_space α] [preorder α]\n  [topological_space β] [preorder β]\n  extends continuous_order_hom_class F α β :=\n(exists_map_eq_of_map_le (f : F) ⦃a : α⦄ ⦃b : β⦄ : f a ≤ b → ∃ c, a ≤ c ∧ f c = b)\n\nend\n\nexport pseudo_epimorphism_class (exists_map_eq_of_map_le)\n\n@[priority 100] -- See note [lower instance priority]\ninstance pseudo_epimorphism_class.to_top_hom_class [partial_order α] [order_top α] [preorder β]\n  [order_top β] [pseudo_epimorphism_class F α β] : top_hom_class F α β :=\n{ map_top := λ f, let ⟨b, h⟩ := exists_map_eq_of_map_le f (@le_top _ _ _ $ f ⊤) in\n                  by rw [←top_le_iff.1 h.1, h.2]\n  .. ‹pseudo_epimorphism_class F α β› }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_pseudo_epimorphism_class [preorder α] [preorder β]\n  [order_iso_class F α β] : pseudo_epimorphism_class F α β :=\n{ exists_map_eq_of_map_le :=\n      λ f a b h, ⟨equiv_like.inv f b, (le_map_inv_iff f).2 h, equiv_like.right_inv _ _⟩,\n  .. order_iso_class.to_order_hom_class }\n\n@[priority 100] -- See note [lower instance priority]\ninstance esakia_hom_class.to_pseudo_epimorphism_class [topological_space α] [preorder α]\n  [topological_space β] [preorder β] [esakia_hom_class F α β] : pseudo_epimorphism_class F α β :=\n{ .. ‹esakia_hom_class F α β› }\n\ninstance [preorder α] [preorder β] [pseudo_epimorphism_class F α β] :\n  has_coe_t F (pseudo_epimorphism α β) :=\n⟨λ f, ⟨f, exists_map_eq_of_map_le f⟩⟩\n\ninstance [topological_space α] [preorder α] [topological_space β] [preorder β]\n  [esakia_hom_class F α β] : has_coe_t F (esakia_hom α β) :=\n⟨λ f, ⟨f, exists_map_eq_of_map_le f⟩⟩\n\n/-! ### Pseudo-epimorphisms -/\n\nnamespace pseudo_epimorphism\nvariables [preorder α] [preorder β] [preorder γ] [preorder δ]\n\ninstance : pseudo_epimorphism_class (pseudo_epimorphism α β) α β :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h, by { obtain ⟨⟨_, _⟩, _⟩ := f, obtain ⟨⟨_, _⟩, _⟩ := g, congr' },\n  map_rel := λ f, f.monotone',\n  exists_map_eq_of_map_le := pseudo_epimorphism.exists_map_eq_of_map_le' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (pseudo_epimorphism α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : pseudo_epimorphism α β} : f.to_fun = (f : α → β) := rfl\n\n@[ext] lemma ext {f g : pseudo_epimorphism α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of a `pseudo_epimorphism` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\nprotected def copy (f : pseudo_epimorphism α β) (f' : α → β) (h : f' = f) :\n  pseudo_epimorphism α β :=\n⟨f.to_order_hom.copy f' h, by simpa only [h.symm, to_fun_eq_coe] using f.exists_map_eq_of_map_le'⟩\n\n@[simp] lemma coe_copy (f : pseudo_epimorphism α β) (f' : α → β) (h : f' = f) :\n  ⇑(f.copy f' h) = f' :=\nrfl\n\nlemma copy_eq (f : pseudo_epimorphism α β) (f' : α → β) (h : f' = f) :\n  f.copy f' h = f :=\nfun_like.ext' h\n\nvariables (α)\n\n/-- `id` as a `pseudo_epimorphism`. -/\nprotected def id : pseudo_epimorphism α α := ⟨order_hom.id, λ a b h, ⟨b, h, rfl⟩⟩\n\ninstance : inhabited (pseudo_epimorphism α α) := ⟨pseudo_epimorphism.id α⟩\n\n@[simp] lemma coe_id : ⇑(pseudo_epimorphism.id α) = id := rfl\n@[simp] lemma coe_id_order_hom : (pseudo_epimorphism.id α : α →o α) = order_hom.id := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : pseudo_epimorphism.id α a = a := rfl\n\n/-- Composition of `pseudo_epimorphism`s as a `pseudo_epimorphism`. -/\ndef comp (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) : pseudo_epimorphism α γ :=\n⟨g.to_order_hom.comp f.to_order_hom, λ a b h₀, begin\n  obtain ⟨b, h₁, rfl⟩ := g.exists_map_eq_of_map_le' h₀,\n  obtain ⟨b, h₂, rfl⟩ := f.exists_map_eq_of_map_le' h₁,\n  exact ⟨b, h₂, rfl⟩,\nend⟩\n\n@[simp] lemma coe_comp (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) :\n  (g.comp f : α → γ) = g ∘ f := rfl\n@[simp] lemma coe_comp_order_hom (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) :\n  (g.comp f : α →o γ) = (g : β →o γ).comp f := rfl\n@[simp] lemma comp_apply (g : pseudo_epimorphism β γ) (f : pseudo_epimorphism α β) (a : α) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma comp_assoc (h : pseudo_epimorphism γ δ) (g : pseudo_epimorphism β γ)\n  (f : pseudo_epimorphism α β) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] \n\nlemma cancel_right {g₁ g₂ : pseudo_epimorphism β γ} {f : pseudo_epimorphism α β}\n  (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : pseudo_epimorphism β γ} {f₁ f₂ : pseudo_epimorphism α β} (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, ext $ λ a, hg $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩\n\nend pseudo_epimorphism\n\n/-! ### Esakia morphisms -/\n\nnamespace esakia_hom\nvariables [topological_space α] [preorder α] [topological_space β] [preorder β]\n  [topological_space γ] [preorder γ] [topological_space δ] [preorder δ]\n\n/-- Reinterpret an `esakia_hom` as a `pseudo_epimorphism`. -/\ndef to_pseudo_epimorphism (f : esakia_hom α β) : pseudo_epimorphism α β := { ..f }\n\ninstance : esakia_hom_class (esakia_hom α β) α β :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h,\n    by { obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := f, obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := g, congr' },\n  map_rel := λ f, f.monotone',\n  map_continuous := λ f, f.continuous_to_fun,\n  exists_map_eq_of_map_le := λ f, f.exists_map_eq_of_map_le' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (esakia_hom α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : esakia_hom α β} : f.to_fun = (f : α → β) := rfl\n\n@[ext] lemma ext {f g : esakia_hom α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of an `esakia_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : esakia_hom α β) (f' : α → β) (h : f' = f) : esakia_hom α β :=\n⟨f.to_continuous_order_hom.copy f' h,\n  by simpa only [h.symm, to_fun_eq_coe] using f.exists_map_eq_of_map_le'⟩\n\n@[simp] lemma coe_copy (f : esakia_hom α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl\nlemma copy_eq (f : esakia_hom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f := fun_like.ext' h\n\nvariables (α)\n\n/-- `id` as an `esakia_hom`. -/\nprotected def id : esakia_hom α α := ⟨continuous_order_hom.id α, λ a b h, ⟨b, h, rfl⟩⟩\n\ninstance : inhabited (esakia_hom α α) := ⟨esakia_hom.id α⟩\n\n@[simp] lemma coe_id : ⇑(esakia_hom.id α) = id := rfl\n@[simp] lemma coe_id_continuous_order_hom :\n  (esakia_hom.id α : α →Co α) = continuous_order_hom.id α := rfl\n@[simp] lemma coe_id_pseudo_epimorphism :\n  (esakia_hom.id α : pseudo_epimorphism α α) = pseudo_epimorphism.id α  := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : esakia_hom.id α a = a := rfl\n\n/-- Composition of `esakia_hom`s as an `esakia_hom`. -/\ndef comp (g : esakia_hom β γ) (f : esakia_hom α β) : esakia_hom α γ :=\n⟨g.to_continuous_order_hom.comp f.to_continuous_order_hom, λ a b h₀, begin\n  obtain ⟨b, h₁, rfl⟩ := g.exists_map_eq_of_map_le' h₀,\n  obtain ⟨b, h₂, rfl⟩ := f.exists_map_eq_of_map_le' h₁,\n  exact ⟨b, h₂, rfl⟩,\nend⟩\n\n@[simp] lemma coe_comp (g : esakia_hom β γ) (f : esakia_hom α β) : (g.comp f : α → γ) = g ∘ f := rfl\n@[simp] lemma comp_apply (g : esakia_hom β γ) (f : esakia_hom α β) (a : α) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma coe_comp_continuous_order_hom (g : esakia_hom β γ) (f : esakia_hom α β) :\n  (g.comp f : α →Co γ) = (g : β →Co γ).comp f := rfl\n@[simp] lemma coe_comp_pseudo_epimorphism (g : esakia_hom β γ) (f : esakia_hom α β) :\n  (g.comp f : pseudo_epimorphism α γ) = (g : pseudo_epimorphism β γ).comp f := rfl\n@[simp] lemma comp_assoc (h : esakia_hom γ δ) (g : esakia_hom β γ) (f : esakia_hom α β) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] lemma comp_id (f : esakia_hom α β) : f.comp (esakia_hom.id α) = f := ext $ λ a, rfl\n@[simp] lemma id_comp (f : esakia_hom α β) : (esakia_hom.id β).comp f = f := ext $ λ a, rfl\n\nlemma cancel_right {g₁ g₂ : esakia_hom β γ} {f : esakia_hom α β} (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : esakia_hom β γ} {f₁ f₂ : esakia_hom α β} (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, ext $ λ a, hg $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩\n\nend esakia_hom\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/order/hom/esakia.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.49697241926264035}}
{"text": "import algebra.homology.short_complex.Module\nimport for_mathlib.category_theory.abelian.extensions_derived_category\nimport ring_theory.non_zero_divisors\n\nnoncomputable theory\n\nopen category_theory category_theory.abelian category_theory.limits\n\nvariables {R : Type*} [comm_ring R] (x : R)\n\nnamespace Module\n\n@[simps]\ndef short_complex_ring_mod_ideal_span_singleton : short_complex (Module R) :=\n{ X₁ := Module.of R R,\n  X₂ := Module.of R R,\n  X₃ := Module.of R (R ⧸(ideal.span {x} : ideal R)),\n  f := x • 𝟙 _,\n  g := Module.of_hom (submodule.mkq _),\n  zero := begin\n    ext1,\n    erw ideal.quotient.eq_zero_iff_mem,\n    rw ideal.mem_span_singleton',\n    exact ⟨1, by simp⟩,\n  end, }\n\nnamespace short_complex_ring_mod_ideal_span_singleton\n\ninstance : epi (short_complex_ring_mod_ideal_span_singleton x).g :=\nbegin\n  rw Module.epi_iff_surjective,\n  rintro ⟨a⟩,\n  exact ⟨a, rfl⟩,\nend\n\nlemma exact : (short_complex_ring_mod_ideal_span_singleton x).exact :=\nbegin\n  rw short_complex.Module_exact_iff,\n  intros a ha,\n  dsimp at a ha,\n  rw [ideal.quotient.eq_zero_iff_mem, ideal.mem_span_singleton'] at ha,\n  obtain ⟨b, hb⟩ := ha,\n  exact ⟨b, by { dsimp, rw [← hb, mul_comm], }⟩,\nend\n\nlemma mono_f (hx : x ∈ non_zero_divisors R) :\n  mono (short_complex_ring_mod_ideal_span_singleton x).f :=\nbegin\n  simp only [Module.mono_iff_ker_eq_bot, short_complex_ring_mod_ideal_span_singleton_f],\n  ext a,\n  split,\n  { intro ha,\n    simp only [linear_map.mem_ker, linear_map.smul_apply, Module.id_apply,\n      algebra.id.smul_eq_mul] at ha,\n    rw mem_non_zero_divisors_iff at hx,\n    simpa only [ideal.mem_bot] using hx a (by rw [mul_comm, ha]), },\n  { intro ha,\n    simp only [ideal.mem_bot] at ha,\n    simp only [ha, linear_map.mem_ker, linear_map.smul_apply, Module.id_apply,\n      algebra.id.smul_eq_mul, mul_zero], },\nend\n\nlemma short_exact (hx : x ∈ non_zero_divisors R) :\n  (short_complex_ring_mod_ideal_span_singleton x).short_exact :=\nbegin\n  haveI := mono_f x hx,\n  exact short_complex.short_exact.mk (short_complex_ring_mod_ideal_span_singleton.exact x),\nend\n\nend short_complex_ring_mod_ideal_span_singleton\n\nvariable (hx : x ∈ non_zero_divisors R)\n\ndef extension_of_non_zero_divisor (hx : x ∈ non_zero_divisors R) :\n  extension (Module.of R (R ⧸(ideal.span {x} : ideal R))) (Module.of R R) :=\n(short_complex_ring_mod_ideal_span_singleton.short_exact x hx).extension\n\nnamespace extension_of_non_zero_divisor\n\nlemma nonempty_iso_trivial_iff :\n  nonempty (extension_of_non_zero_divisor x hx ≅ extension.trivial _ _) ↔\n    is_unit x :=\nbegin\n  split,\n  { rintro ⟨e⟩,\n    rw is_unit_iff_exists_inv,\n    obtain ⟨s, hs⟩ := (extension.iso_trivial_equiv _).symm.surjective e,\n    refine ⟨s.r (1 : R),_⟩,\n    let φ : ((of R R) ⟶ (of R R)) → R := λ φ, φ (1 : R),\n    have eq := congr_arg φ s.f_r,\n    dsimp only [extension_of_non_zero_divisor] at eq,\n    simpa only [short_complex.short_exact.extension_i,\n      short_complex_ring_mod_ideal_span_singleton_f, linear.smul_comp] using eq, },\n  { intro hx',\n    haveI := is_unit.invertible hx',\n    refine nonempty.intro _,\n    equiv_rw extension.iso_trivial_equiv _,\n    have h : is_zero (short_complex_ring_mod_ideal_span_singleton x).X₃,\n    { rw is_zero.iff_id_eq_zero,\n      ext,\n      simp only [linear_map.coe_comp, function.comp_app, submodule.mkq_apply,\n        ideal.quotient.mk_eq_mk, map_one, id_apply, linear_map.zero_apply],\n      erw [ideal.quotient.eq_zero_iff_mem, ideal.mem_span_singleton'],\n      exact ⟨⅟x, by simp only [inv_of_mul_self]⟩, },\n    exact\n    { r := ⅟x • 𝟙 _,\n      f_r := begin\n        dsimp [extension_of_non_zero_divisor],\n        simp only [smul_smul, linear.comp_smul, category.comp_id, inv_of_mul_self, one_smul],\n      end,\n      s := 0,\n      s_g := h.eq_of_src _ _,\n      id := begin\n        dsimp [extension_of_non_zero_divisor],\n        simp only [comp_zero, add_zero, linear.smul_comp, category.id_comp,\n          smul_smul, inv_of_mul_self, one_smul],\n      end, }, },\nend\n\nlemma δ_neq_zero  : (extension_of_non_zero_divisor x hx).δ ≠ 0 ↔ ¬is_unit x :=\nby simp only [extension.δ_neq_zero_iff, ← nonempty_iso_trivial_iff x hx, not_nonempty_iff]\n\nend extension_of_non_zero_divisor\n\nend Module\n\nlemma int.non_zero_divisor_of_two_le (n : ℤ) (hn : 2 ≤ n) :\n  n ∈ non_zero_divisors ℤ :=\nbegin\n  intros a ha,\n  rw mul_eq_zero at ha,\n  cases ha,\n  { exact ha, },\n  { linarith, },\nend\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/abelian/extension_example.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950986284991, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4969606510905707}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.category.Mon.limits\nimport algebra.category.Group.preadditive\nimport category_theory.over\nimport group_theory.subgroup.basic\nimport category_theory.concrete_category.elementwise\n\n/-!\n# The category of (commutative) (additive) groups has all limits\n\nFurther, these limits are preserved by the forgetful functor --- that is,\nthe underlying types are just the limits in the category of types.\n\n-/\n\nopen category_theory\nopen category_theory.limits\n\nuniverses v u\n\nnoncomputable theory\n\nvariables {J : Type v} [small_category J]\n\nnamespace Group\n\n@[to_additive]\ninstance group_obj (F : J ⥤ Group.{max v u}) (j) :\n  group ((F ⋙ forget Group).obj j) :=\nby { change group (F.obj j), apply_instance }\n\n/--\nThe flat sections of a functor into `Group` form a subgroup of all sections.\n-/\n@[to_additive\n  \"The flat sections of a functor into `AddGroup` form an additive subgroup of all sections.\"]\ndef sections_subgroup (F : J ⥤ Group) :\n  subgroup (Π j, F.obj j) :=\n{ carrier := (F ⋙ forget Group).sections,\n  inv_mem' := λ a ah j j' f,\n  begin\n    simp only [forget_map_eq_coe, functor.comp_map, pi.inv_apply, monoid_hom.map_inv, inv_inj],\n    dsimp [functor.sections] at ah,\n    rw ah f,\n  end,\n  ..(Mon.sections_submonoid (F ⋙ forget₂ Group Mon)) }\n\n@[to_additive]\ninstance limit_group (F : J ⥤ Group.{max v u}) :\n  group (types.limit_cone (F ⋙ forget Group)).X :=\nbegin\n  change group (sections_subgroup F),\n  apply_instance,\nend\n\n/-- We show that the forgetful functor `Group ⥤ Mon` creates limits.\n\nAll we need to do is notice that the limit point has a `group` instance available, and then reuse\nthe existing limit. -/\n@[to_additive \"We show that the forgetful functor `AddGroup ⥤ AddMon` creates limits.\n\nAll we need to do is notice that the limit point has an `add_group` instance available, and then\nreuse the existing limit.\"]\ninstance forget₂.creates_limit (F : J ⥤ Group.{max v u}) :\n  creates_limit F (forget₂ Group.{max v u} Mon.{max v u}) :=\ncreates_limit_of_reflects_iso (λ c' t,\n{ lifted_cone :=\n  { X := Group.of (types.limit_cone (F ⋙ forget Group)).X,\n    π :=\n    { app := Mon.limit_π_monoid_hom (F ⋙ forget₂ Group Mon.{max v u}),\n      naturality' :=\n        (Mon.has_limits.limit_cone (F ⋙ forget₂ Group Mon.{max v u})).π.naturality, } },\n  valid_lift := by apply is_limit.unique_up_to_iso (Mon.has_limits.limit_cone_is_limit _) t,\n  makes_limit := is_limit.of_faithful (forget₂ Group Mon.{max v u})\n    (Mon.has_limits.limit_cone_is_limit _) (λ s, _) (λ s, rfl) })\n\n/--\nA choice of limit cone for a functor into `Group`.\n(Generally, you'll just want to use `limit F`.)\n-/\n@[to_additive \"A choice of limit cone for a functor into `Group`.\n(Generally, you'll just want to use `limit F`.)\"]\ndef limit_cone (F : J ⥤ Group.{max v u}) : cone F :=\nlift_limit (limit.is_limit (F ⋙ (forget₂ Group Mon.{max v u})))\n\n/--\nThe chosen cone is a limit cone.\n(Generally, you'll just want to use `limit.cone F`.)\n-/\n@[to_additive \"The chosen cone is a limit cone.\n(Generally, you'll just want to use `limit.cone F`.)\"]\ndef limit_cone_is_limit (F : J ⥤ Group.{max v u}) : is_limit (limit_cone F) :=\nlifted_limit_is_limit _\n\n/-- The category of groups has all limits. -/\n@[to_additive \"The category of additive groups has all limits.\"]\ninstance has_limits_of_size : has_limits_of_size.{v v} Group.{max v u} :=\n{ has_limits_of_shape := λ J 𝒥, by exactI\n  { has_limit := λ F, has_limit_of_created F (forget₂ Group Mon.{max v u}) } }\n\n@[to_additive]\ninstance has_limits : has_limits Group.{u} := Group.has_limits_of_size.{u u}\n\n/-- The forgetful functor from groups to monoids preserves all limits.\n\nThis means the underlying monoid of a limit can be computed as a limit in the category of monoids.\n-/\n@[to_additive AddGroup.forget₂_AddMon_preserves_limits \"The forgetful functor from additive groups\nto additive monoids preserves all limits.\n\nThis means the underlying additive monoid of a limit can be computed as a limit in the category of\nadditive monoids.\"]\ninstance forget₂_Mon_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget₂ Group Mon.{max v u}) :=\n{ preserves_limits_of_shape := λ J 𝒥,\n  { preserves_limit := λ F, by apply_instance } }\n\n@[to_additive]\ninstance forget₂_Mon_preserves_limits : preserves_limits (forget₂ Group Mon.{u}) :=\nGroup.forget₂_Mon_preserves_limits_of_size.{u u}\n\n/-- The forgetful functor from groups to types preserves all limits.\n\nThis means the underlying type of a limit can be computed as a limit in the category of types. -/\n@[to_additive \"The forgetful functor from additive groups to types preserves all limits.\n\nThis means the underlying type of a limit can be computed as a limit in the category of types.\"]\ninstance forget_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget Group.{max v u}) :=\n{ preserves_limits_of_shape := λ J 𝒥, by exactI\n  { preserves_limit := λ F, limits.comp_preserves_limit (forget₂ Group Mon) (forget Mon) } }\n\n@[to_additive]\ninstance forget_preserves_limits : preserves_limits (forget Group.{u}) :=\nGroup.forget_preserves_limits_of_size.{u u}\n\nend Group\n\nnamespace CommGroup\n\n@[to_additive]\ninstance comm_group_obj (F : J ⥤ CommGroup.{max v u}) (j) :\n  comm_group ((F ⋙ forget CommGroup).obj j) :=\nby { change comm_group (F.obj j), apply_instance }\n\n@[to_additive]\ninstance limit_comm_group (F : J ⥤ CommGroup.{max v u}) :\n  comm_group (types.limit_cone (F ⋙ forget CommGroup.{max v u})).X :=\n@subgroup.to_comm_group (Π j, F.obj j) _\n  (Group.sections_subgroup (F ⋙ forget₂ CommGroup Group.{max v u}))\n\n/--\nWe show that the forgetful functor `CommGroup ⥤ Group` creates limits.\n\nAll we need to do is notice that the limit point has a `comm_group` instance available,\nand then reuse the existing limit.\n-/\n@[to_additive \"We show that the forgetful functor `AddCommGroup ⥤ AddGroup` creates limits.\n\nAll we need to do is notice that the limit point has an `add_comm_group` instance available, and\nthen reuse the existing limit.\"]\ninstance forget₂.creates_limit (F : J ⥤ CommGroup.{max v u}) :\n  creates_limit F (forget₂ CommGroup Group.{max v u}) :=\ncreates_limit_of_reflects_iso (λ c' t,\n{ lifted_cone :=\n  { X := CommGroup.of (types.limit_cone (F ⋙ forget CommGroup)).X,\n    π :=\n    { app := Mon.limit_π_monoid_hom\n        (F ⋙ forget₂ CommGroup Group.{max v u} ⋙ forget₂ Group Mon.{max v u}),\n      naturality' := (Mon.has_limits.limit_cone _).π.naturality, } },\n  valid_lift := by apply is_limit.unique_up_to_iso (Group.limit_cone_is_limit _) t,\n  makes_limit := is_limit.of_faithful (forget₂ _ Group.{max v u} ⋙ forget₂ _ Mon.{max v u})\n    (by apply Mon.has_limits.limit_cone_is_limit _) (λ s, _) (λ s, rfl) })\n\n/--\nA choice of limit cone for a functor into `CommGroup`.\n(Generally, you'll just want to use `limit F`.)\n-/\n@[to_additive \"A choice of limit cone for a functor into `CommGroup`.\n(Generally, you'll just want to use `limit F`.)\"]\ndef limit_cone (F : J ⥤ CommGroup.{max v u}) : cone F :=\nlift_limit (limit.is_limit (F ⋙ (forget₂ CommGroup Group.{max v u})))\n\n/--\nThe chosen cone is a limit cone.\n(Generally, you'll just want to use `limit.cone F`.)\n-/\n@[to_additive \"The chosen cone is a limit cone.\n(Generally, you'll just wantto use `limit.cone F`.)\"]\ndef limit_cone_is_limit (F : J ⥤ CommGroup.{max v u}) : is_limit (limit_cone F) :=\nlifted_limit_is_limit _\n\n/-- The category of commutative groups has all limits. -/\n@[to_additive \"The category of additive commutative groups has all limits.\"]\ninstance has_limits_of_size : has_limits_of_size.{v v} CommGroup.{max v u} :=\n{ has_limits_of_shape := λ J 𝒥, by exactI\n  { has_limit := λ F, has_limit_of_created F (forget₂ CommGroup Group.{max v u}) } }\n\n@[to_additive]\ninstance has_limits : has_limits CommGroup.{u} := CommGroup.has_limits_of_size.{u u}\n\n/--\nThe forgetful functor from commutative groups to groups preserves all limits.\n(That is, the underlying group could have been computed instead as limits in the category\nof groups.)\n-/\n@[to_additive AddCommGroup.forget₂_AddGroup_preserves_limits\n\"The forgetful functor from additive commutative groups to groups preserves all limits.\n(That is, the underlying group could have been computed instead as limits in the category\nof additive groups.)\"]\ninstance forget₂_Group_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget₂ CommGroup Group.{max v u}) :=\n{ preserves_limits_of_shape := λ J 𝒥,\n  { preserves_limit := λ F, by apply_instance } }\n\n@[to_additive]\ninstance forget₂_Group_preserves_limits : preserves_limits (forget₂ CommGroup Group.{u}) :=\nCommGroup.forget₂_Group_preserves_limits_of_size.{u u}\n\n/--\nAn auxiliary declaration to speed up typechecking.\n-/\n@[to_additive AddCommGroup.forget₂_AddCommMon_preserves_limits_aux\n  \"An auxiliary declaration to speed up typechecking.\"]\ndef forget₂_CommMon_preserves_limits_aux (F : J ⥤ CommGroup.{max v u}) :\n  is_limit ((forget₂ CommGroup CommMon).map_cone (limit_cone F)) :=\nCommMon.limit_cone_is_limit (F ⋙ forget₂ CommGroup CommMon)\n\n/--\nThe forgetful functor from commutative groups to commutative monoids preserves all limits.\n(That is, the underlying commutative monoids could have been computed instead as limits\nin the category of commutative monoids.)\n-/\n@[to_additive AddCommGroup.forget₂_AddCommMon_preserves_limits\n\"The forgetful functor from additive commutative groups to additive commutative monoids preserves\nall limits. (That is, the underlying additive commutative monoids could have been computed instead\nas limits in the category of additive commutative monoids.)\"]\ninstance forget₂_CommMon_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget₂ CommGroup CommMon.{max v u}) :=\n{ preserves_limits_of_shape := λ J 𝒥, by exactI\n  { preserves_limit := λ F, preserves_limit_of_preserves_limit_cone\n    (limit_cone_is_limit F) (forget₂_CommMon_preserves_limits_aux F) } }\n\n/--\nThe forgetful functor from commutative groups to types preserves all limits. (That is, the\nunderlying types could have been computed instead as limits in the category of types.)\n-/\n@[to_additive AddCommGroup.forget_preserves_limits\n\"The forgetful functor from additive commutative groups to types preserves all limits. (That is,\nthe underlying types could have been computed instead as limits in the category of types.)\"]\ninstance forget_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget CommGroup.{max v u}) :=\n{ preserves_limits_of_shape := λ J 𝒥, by exactI\n  { preserves_limit := λ F, limits.comp_preserves_limit (forget₂ CommGroup Group) (forget Group) } }\n\n-- Verify we can form limits indexed over smaller categories.\nexample (f : ℕ → AddCommGroup) : has_product f := by apply_instance\n\nend CommGroup\n\nnamespace AddCommGroup\n\n/--\nThe categorical kernel of a morphism in `AddCommGroup`\nagrees with the usual group-theoretical kernel.\n-/\ndef kernel_iso_ker {G H : AddCommGroup.{u}} (f : G ⟶ H) :\n  kernel f ≅ AddCommGroup.of f.ker :=\n{ hom :=\n  { to_fun := λ g, ⟨kernel.ι f g,\n    begin\n      -- TODO where is this `has_coe_t_aux.coe` coming from? can we prevent it appearing?\n      change (kernel.ι f) g ∈ f.ker,\n      simp [add_monoid_hom.mem_ker],\n    end⟩,\n    map_zero' := by { ext, simp, },\n    map_add' := λ g g', by { ext, simp, }, },\n  inv := kernel.lift f (add_subgroup.subtype f.ker) (by tidy),\n  hom_inv_id' := by { apply equalizer.hom_ext _, ext, simp, },\n  inv_hom_id' :=\n  begin\n    apply AddCommGroup.ext,\n    simp only [add_monoid_hom.coe_mk, coe_id, coe_comp],\n    rintro ⟨x, mem⟩,\n    simp,\n  end, }.\n\n@[simp]\nlemma kernel_iso_ker_hom_comp_subtype {G H : AddCommGroup} (f : G ⟶ H) :\n  (kernel_iso_ker f).hom ≫ add_subgroup.subtype f.ker = kernel.ι f :=\nby ext; refl\n\n@[simp]\nlemma kernel_iso_ker_inv_comp_ι {G H : AddCommGroup} (f : G ⟶ H) :\n  (kernel_iso_ker f).inv ≫ kernel.ι f = add_subgroup.subtype f.ker :=\nbegin\n  ext,\n  simp [kernel_iso_ker],\nend\n\n/--\nThe categorical kernel inclusion for `f : G ⟶ H`, as an object over `G`,\nagrees with the `subtype` map.\n-/\n@[simps]\ndef kernel_iso_ker_over {G H : AddCommGroup.{u}} (f : G ⟶ H) :\n  over.mk (kernel.ι f) ≅ @over.mk _ _ G (AddCommGroup.of f.ker) (add_subgroup.subtype f.ker) :=\nover.iso_mk (kernel_iso_ker f) (by simp)\n\nend AddCommGroup\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/category/Group/limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.49689690796292607}}
{"text": "import algebra.ring group_theory.submonoid ring_theory.ideal_operations linear_algebra.basic\n\nnamespace localization_alt\n\nuniverses u v w\nvariables {A : Type u} {B : Type v} {C : Type w} \nvariables [comm_ring A] [comm_ring B] [comm_ring C]\nvariables (S : set A) [is_submonoid S] (f : A → B) [is_ring_hom f]\n\n/- This is essentially the same logic as units.ext, but in more \n   convenient form.\n-/\nlemma comm_monoid.inv_unique {M : Type*} [comm_monoid M]\n  {a ai₁ ai₂ : M} (e₁ : a * ai₁ = 1) (e₂ : a * ai₂ = 1) : ai₁ = ai₂ :=\nby rw [← mul_one ai₁, ← e₂, ← mul_assoc, mul_comm ai₁, e₁, one_mul]\n\n/-- preserve definitional equality -/\ndef ideal.mk (I : set A) (J : ideal A) (H : I = J) : ideal A :=\n{ carrier := I,\n  zero := H.symm ▸ J.zero,\n  add := H.symm ▸ J.add,\n  smul := H.symm ▸ J.smul }\n\ndef ker : ideal A :=\nideal.mk {x | f x = 0} (ideal.comap f ⊥) $\nset.ext $ λ x, submodule.mem_bot.symm\n\ndef inverts_data (S : set A) (f : A → B) : Type* :=\nΠ s : S, {si : B // (f s) * si = 1}\n\ndef inverts (S : set A) (f : A → B) : Prop := \n∀ s : S, ∃ si : B, (f s) * si = 1\n\nlemma inverts_subsingleton (S : set A) (f : A → B) :\n  subsingleton (inverts_data S f) :=\n⟨λ fi1 fi2, funext $ λ s, subtype.eq $ comm_monoid.inv_unique (fi1 s).2 (fi2 s).2⟩\n\ndef inverts_of_data (h : inverts_data S f) : inverts S f :=\nλ s, ⟨(h s).1,(h s).2⟩\n\nnoncomputable def inverts_some (h : inverts S f) : inverts_data S f :=\nλ s, classical.indefinite_description _ (h s)\n\ndef has_denom_data (S : set A) (f : A → B) :=\nΠ b : B, {sa : S × A // (f sa.1) * b = f sa.2 }\n\ndef has_denom (S : set A) (f : A → B) : Prop :=\n∀ b : B, ∃ (sa : S × A), (f sa.1) * b = (f sa.2)\n\ndef has_denom_of_data (h : has_denom_data S f) : has_denom S f :=\nλ b, subtype.exists_of_subtype (h b)\n\nnoncomputable def has_denom_some (h : has_denom S f) : has_denom_data S f := \nλ b, classical.indefinite_description _ (h b)\n\ndef ann_aux (S : set A) [is_submonoid S] : Type* :=\n{ as : A × S // as.1 * as.2 = 0 }\n\nnamespace ann_aux\n\ndef zero : ann_aux S := ⟨(0, 1), mul_one _⟩\n\ndef add (as bt : ann_aux S) : ann_aux S :=\n⟨(as.1.1 + bt.1.1, as.1.2 * bt.1.2), show (as.1.1 + bt.1.1) * (as.1.2 * bt.1.2) = 0,\nby rw [add_mul, ← mul_assoc, as.2, zero_mul, zero_add, mul_left_comm, bt.2, mul_zero]⟩\n\ndef smul (a : A) (bt : ann_aux S) : ann_aux S :=\n⟨(a * bt.1.1, bt.1.2), show (a * bt.1.1) * bt.1.2 = 0, by rw [mul_assoc, bt.2, mul_zero]⟩\n\nend ann_aux\n\ndef submonoid_ann (S : set A) [is_submonoid S] : ideal A :=\n{ carrier := set.range (λ as : ann_aux S, as.1.1),\n  zero := ⟨ann_aux.zero S, rfl⟩,\n  add := λ _ _ ⟨as,has⟩ ⟨bt,hbt⟩, ⟨ann_aux.add S as bt, has ▸ hbt ▸ rfl⟩,\n  smul := λ a _ ⟨bt,h⟩, ⟨ann_aux.smul S a bt, h ▸ rfl⟩ }\n\nlemma inverts_ker (hf : inverts S f) : submonoid_ann S ≤ ker f :=\nλ x ⟨⟨⟨a,s⟩,asz⟩,rfl⟩, let ⟨si,e1⟩ := hf s in show f x = 0,\nby rw [← mul_one (f x), ← e1, ← mul_assoc, ← is_ring_hom.map_mul f, asz, is_ring_hom.map_zero f, zero_mul]\n\nstructure is_localization_data :=\n(inverts : inverts_data S f)\n(has_denom : has_denom_data S f)\n(ker_le : ker f ≤ submonoid_ann S)\n\ndef is_localization : Prop :=\n(inverts S f) ∧ (has_denom S f) ∧ (ker f = submonoid_ann S)\n\nlemma localization_epi (hf : is_localization S f)\n  (g₁ g₂ : B → C) [is_ring_hom g₁] [is_ring_hom g₂] \n  (e : g₁ ∘ f = g₂ ∘ f) : g₁ = g₂ := \nbegin\n  have e' : ∀ x, g₁ (f x) = g₂ (f x) := λ x, by convert congr_fun e x,\n  ext b,\n  rcases hf.2.1 b with ⟨⟨s,a⟩,e1⟩,\n  rcases hf.1 s with ⟨si,e2⟩,\n  have e4 : g₁ (f s) * (g₁ si) = 1,\n  { rw [← is_ring_hom.map_mul g₁, e2, is_ring_hom.map_one g₁] },\n  have e5 : g₁ (f s) * (g₂ si) = 1,\n  { rw [e', ← is_ring_hom.map_mul g₂, e2, is_ring_hom.map_one g₂] },\n  rw [← mul_one b, ← e2, mul_left_comm, ← mul_assoc, e1],\n  rw [is_ring_hom.map_mul g₁, is_ring_hom.map_mul g₂, e', comm_monoid.inv_unique e4 e5]\nend\n\nsection localization_initial \nvariables (hf : is_localization_data S f) (g : A → C) [is_ring_hom g] (hg : inverts_data S g)\n\ndef is_localization_initial (hf : is_localization_data S f)\n  (g : A → C) [is_ring_hom g] (hg : inverts_data S g) : B → C :=\nλ b, g (hf.has_denom b).1.2 * hg (hf.has_denom b).1.1\n\nlemma useful (hf : is_localization_data S f) (g : A → C) [is_ring_hom g] (hg : inverts_data S g)\n  {a₁ a₂ : A} (H : f a₁ = f a₂) : g a₁ = g a₂ :=\nbegin\n  rw [← sub_eq_zero, ← is_ring_hom.map_sub f] at H,\n  rw [← sub_eq_zero, ← is_ring_hom.map_sub g],\n  generalize_hyp : a₁ - a₂ = a at H ⊢,\n  rcases hf.3 H with ⟨⟨as,h1⟩,h2⟩,\n  rw [← h2],\n  cases hg as.2 with c h3,\n  rw [← mul_one (g as.1), ← h3, ← mul_assoc, ← is_ring_hom.map_mul g, h1, is_ring_hom.map_zero g, zero_mul]\nend\n\nlemma useful2 {x y z w : A} (h : x * y = 1) : z * x = w * x ↔ z = w :=\n⟨λ H, have _ := congr_arg (* y) H, by rwa [mul_assoc, h, mul_one, mul_assoc, h, mul_one] at this,\nλ H, by rw H⟩\n\ninstance (hf : is_localization_data S f) (g : A → C) [is_ring_hom g] (hg : inverts_data S g) :\n  is_ring_hom (is_localization_initial S f hf g hg) :=\n{ map_one := begin\n    unfold is_localization_initial,\n    rcases hf.has_denom 1 with ⟨⟨s,a⟩,h⟩,\n    dsimp only at *,\n    rw mul_one at h, replace h := useful S f hf g hg h,\n    cases hg s with c hc,\n    rw ← h, exact hc\n  end,\n  map_mul := λ x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with ⟨⟨sx,ax⟩,h1⟩,\n    rcases hf.has_denom y with ⟨⟨sy,ay⟩,h2⟩,\n    rcases hf.has_denom (x*y) with ⟨⟨sxy,axy⟩,h3⟩,\n    cases hg sx with sigx h4,\n    cases hg sy with sigy h5,\n    cases hg sxy with sigxy h6,\n    cases hf.inverts sx with sifx h7,\n    cases hf.inverts sy with sify h8,\n    cases hf.inverts sxy with sifxy h9,\n    dsimp only [subtype.coe_mk] at *,\n    replace h1 : _ * _ = _ * _ := by convert congr_arg (* sifx) h1,\n    rw [mul_right_comm, h7, one_mul] at h1,\n    replace h2 : _ * _ = _ * _ := by convert congr_arg (* sify) h2,\n    rw [mul_right_comm, h8, one_mul] at h2,\n    rw [h1, h2] at h3,\n    rw [← useful2 h4, ← useful2 h5, ← useful2 h6],\n    have : g axy * sigxy * g ↑sx * g ↑sy * g ↑sxy = g axy * g ↑sx * g ↑sy * (g ↑sxy * sigxy),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h6, mul_one], clear this,\n    have : g ax * sigx * (g ay * sigy) * g ↑sx * g ↑sy * g ↑sxy = g ax * g ay * g ↑sxy * (g ↑sx * sigx) * (g ↑sy * sigy),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h4, h5, mul_one, mul_one], clear this,\n    iterate 4 { rw ← is_ring_hom.map_mul g }, apply useful S f hf g hg,\n    iterate 4 { rw is_ring_hom.map_mul f }, rw ← h3,\n    have : f ↑sxy * (f ax * sifx * (f ay * sify)) * f ↑sx * f ↑sy = f ax * f ay * f ↑sxy * (f ↑sx * sifx) * (f ↑sy * sify),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h7, h8, mul_one, mul_one]\n  end,\n  map_add := λ x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with ⟨⟨sx,ax⟩,h1⟩,\n    rcases hf.has_denom y with ⟨⟨sy,ay⟩,h2⟩,\n    rcases hf.has_denom (x+y) with ⟨⟨sxy,axy⟩,h3⟩,\n    cases hg sx with sigx h4,\n    cases hg sy with sigy h5,\n    cases hg sxy with sigxy h6,\n    cases hf.inverts sx with sifx h7,\n    cases hf.inverts sy with sify h8,\n    cases hf.inverts sxy with sifxy h9,\n    dsimp only [subtype.coe_mk] at *,\n    replace h1 : _ * _ = _ * _ := by convert congr_arg (* sifx) h1,\n    rw [mul_right_comm, h7, one_mul] at h1,\n    replace h2 : _ * _ = _ * _ := by convert congr_arg (* sify) h2,\n    rw [mul_right_comm, h8, one_mul] at h2,\n    rw [h1, h2] at h3,\n    rw [← useful2 h4, ← useful2 h5, ← useful2 h6],\n    have : g axy * sigxy * g ↑sx * g ↑sy * g ↑sxy = g axy * g ↑sx * g ↑sy * (g ↑sxy * sigxy),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h6, mul_one], clear this,\n    have : (g ax * sigx + g ay * sigy) * g ↑sx * g ↑sy * g ↑sxy =\n      g ax * g ↑sy * g ↑sxy * (g ↑sx * sigx) + g ay * g ↑sx * g ↑sxy * (g ↑sy * sigy),\n    { simp only [add_mul, mul_add, mul_assoc, mul_comm, mul_left_comm] }, rw [this, h4, h5, mul_one, mul_one], clear this,\n    iterate 6 { rw ← is_ring_hom.map_mul g }, rw ← is_ring_hom.map_add g, apply useful S f hf g hg,\n    rw is_ring_hom.map_add f, iterate 6 { rw is_ring_hom.map_mul f }, rw ← h3,\n    have : f ↑sxy * (f ax * sifx + f ay * sify) * f ↑sx * f ↑sy =\n      f ax * f ↑sy * f ↑sxy * (f ↑sx * sifx) + f ay * f ↑sx * f ↑sxy * (f ↑sy * sify),\n    { simp only [add_mul, mul_add, mul_assoc, mul_comm, mul_left_comm] }, rw [this, h7, h8, mul_one, mul_one]\n  end }\n\nlemma is_localization_initial_comp (hf : is_localization_data S f)\n  (g : A → C) [is_ring_hom g] (hg : inverts_data S g) (a : A) :\n  is_localization_initial S f hf g hg (f a) = g a :=\nbegin\n  unfold is_localization_initial,\n  rcases hf.has_denom (f a) with ⟨⟨s,x⟩,h1⟩,\n  cases hg s with si h2,\n  dsimp only [subtype.coe_mk] at *,\n  rw [← useful2 h2, mul_right_comm, mul_assoc, h2, mul_one, ← is_ring_hom.map_mul g],\n  apply useful S f hf g hg,\n  rw [← h1, is_ring_hom.map_mul f, mul_comm]\nend\n\nend localization_initial\n\nend localization_alt\n", "meta": {"author": "kckennylau", "repo": "Lean", "sha": "907d0a4d2bd8f23785abd6142ad53d308c54fdcb", "save_path": "github-repos/lean/kckennylau-Lean", "path": "github-repos/lean/kckennylau-Lean/Lean-907d0a4d2bd8f23785abd6142ad53d308c54fdcb/localization_alt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929104825007, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.49687950882864107}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\n\nimport ring_theory.integrally_closed\nimport ring_theory.valuation.integers\n\n/-!\n# Integral elements over the ring of integers of a valution\n\nThe ring of integers is integrally closed inside the original ring.\n-/\n\nuniverses u v w\n\nopen_locale big_operators\n\nnamespace valuation\n\nnamespace integers\n\nsection comm_ring\n\nvariables {R : Type u} {Γ₀ : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero Γ₀]\nvariables {v : valuation R Γ₀} {O : Type w} [comm_ring O] [algebra O R] (hv : integers v O)\ninclude hv\n\nopen polynomial\n\nlemma mem_of_integral {x : R} (hx : is_integral O x) : x ∈ v.integer :=\nlet ⟨p, hpm, hpx⟩ := hx in le_of_not_lt $ λ hvx, begin\n  rw [hpm.as_sum, eval₂_add, eval₂_pow, eval₂_X, eval₂_finset_sum, add_eq_zero_iff_eq_neg] at hpx,\n  replace hpx := congr_arg v hpx, refine ne_of_gt _ hpx,\n  rw [v.map_neg, v.map_pow],\n  refine v.map_sum_lt' (zero_lt_one₀.trans_le (one_le_pow_of_one_le' hvx.le _)) (λ i hi, _),\n  rw [eval₂_mul, eval₂_pow, eval₂_C, eval₂_X, v.map_mul, v.map_pow, ← one_mul (v x ^ p.nat_degree)],\n  cases (hv.2 $ p.coeff i).lt_or_eq with hvpi hvpi,\n  { exact mul_lt_mul₀ hvpi (pow_lt_pow₀ hvx $ finset.mem_range.1 hi) },\n  { erw hvpi, rw [one_mul, one_mul], exact pow_lt_pow₀ hvx (finset.mem_range.1 hi) }\nend\n\nprotected lemma integral_closure : integral_closure O R = ⊥ :=\nbot_unique $ λ r hr, let ⟨x, hx⟩ := hv.3 (hv.mem_of_integral hr) in algebra.mem_bot.2 ⟨x, hx⟩\n\nend comm_ring\n\nsection fraction_field\n\nvariables {K : Type u} {Γ₀ : Type v} [field K] [linear_ordered_comm_group_with_zero Γ₀]\nvariables {v : valuation K Γ₀} {O : Type w} [comm_ring O] [is_domain O]\nvariables [algebra O K] [is_fraction_ring O K]\nvariables (hv : integers v O)\n\nlemma integrally_closed : is_integrally_closed O :=\n(is_integrally_closed.integral_closure_eq_bot_iff K).mp (valuation.integers.integral_closure hv)\n\nend fraction_field\n\nend integers\n\nend valuation\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/ring_theory/valuation/integral.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867873410141, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.49683880823221854}}
{"text": "import order.bounded_lattice\nimport data.set.intervals.basic\nimport data.fin\nimport .fin\nimport data.set_like.basic\nimport data.list.sort\nimport data.equiv.fin\nimport data.equiv.option\n\nuniverse u\n\nopen set\n\nclass jordan_hoelder_class (X : Type u) [lattice X] :=\n(is_maximal : X → X → Prop)\n(lt_of_is_maximal : ∀ {x y}, is_maximal x y → x < y)\n(sup_eq_of_is_maximal : ∀ {x y z}, is_maximal x z → is_maximal y z →\n  x ≠ y → x ⊔ y = z)\n(is_maximal_inf : ∀ {x y z}, is_maximal x z → is_maximal y z → x ≠ y →\n  is_maximal (x ⊓ y) y)\n(isom : (X × X) → (X × X) → Prop)\n(isom_refl : ∀ x, isom x x)\n(isom_symm : ∀ {x y}, isom x y → isom y x)\n(isom_trans : ∀ {x y z}, isom x y → isom y z → isom x z)\n(second_iso : ∀ x y, isom (y, x ⊔ y) (x ⊓ y, x))\n\nopen jordan_hoelder_class\n\nattribute [refl] isom_refl\nattribute [symm] isom_symm\nattribute [trans] isom_trans\n\nstructure composition_series (X : Type u) [lattice X] [jordan_hoelder_class X] : Type u :=\n(length : ℕ)\n(series : fin length.succ → X)\n(step' : ∀ i : fin length, is_maximal (series i.cast_succ) (series i.succ))\n\nnamespace composition_series\n\nvariables {X : Type u} [lattice X] [jordan_hoelder_class X]\n\ninstance : has_coe_to_fun (composition_series X) :=\n{ F := _, coe := composition_series.series }\n\nvariables {X}\n\nlemma step (s : composition_series X) : ∀ i : fin s.length,\n  is_maximal (s i.cast_succ) (s i.succ) := s.step'\n\n@[simp] lemma coe_fn_mk (length : ℕ) (series step) :\n  (@composition_series.mk X _ _ length series step : fin length.succ → X) = series := rfl\n\ntheorem lt_succ (s : composition_series X) (i : fin s.length) :\n  s i.cast_succ < s i.succ :=\nlt_of_is_maximal (s.step _)\n\nprotected theorem strict_mono (s : composition_series X) : strict_mono s :=\nfin.strict_mono_iff_lt_succ.2 (λ i h, s.lt_succ ⟨i, nat.lt_of_succ_lt_succ h⟩)\n\nprotected theorem injective (s : composition_series X) : function.injective s :=\ns.strict_mono.injective\n\n@[simp] protected theorem inj (s : composition_series X) {i j : fin s.length.succ} :\n  s i = s j ↔ i = j :=\ns.injective.eq_iff\n\ninstance : has_mem X (composition_series X) :=\n⟨λ x s, x ∈ set.range s⟩\n\nlemma mem_def {x : X} {s : composition_series X} : x ∈ s ↔ x ∈ set.range s := iff.rfl\n\nlemma total {s : composition_series X} {x y : X} (hx : x ∈ s) (hy : y ∈ s) : x ≤ y ∨ y ≤ x :=\nbegin\n  rcases set.mem_range.1 hx with ⟨i, rfl⟩,\n  rcases set.mem_range.1 hy with ⟨j, rfl⟩,\n  rw [s.strict_mono.le_iff_le, s.strict_mono.le_iff_le],\n  exact le_total i j\nend\n\ndef to_list (s : composition_series X) : list X := list.of_fn s\n\nlemma ext_fun {s₁ s₂ : composition_series X}\n  (hl : s₁.length = s₂.length)\n  (h : ∀ i, s₁ i = s₂ (fin.cast (congr_arg nat.succ hl) i)) :\n  s₁ = s₂ :=\nbegin\n  cases s₁, cases s₂,\n  dsimp at *,\n  subst hl,\n  simpa [function.funext_iff] using h\nend\n\nlemma length_to_list (s : composition_series X) : s.to_list.length = s.length.succ :=\nby rw [to_list, list.length_of_fn]\n\nlemma to_list_injective : function.injective (@composition_series.to_list X _ _) :=\nλ s₁ s₂ (h : list.of_fn s₁ = list.of_fn s₂),\nhave h₁ : s₁.length = s₂.length,\n  from nat.succ_injective\n    ((list.length_of_fn s₁).symm.trans $\n      (congr_arg list.length h).trans $\n      list.length_of_fn s₂),\nhave h₂ : ∀ i : fin s₁.length.succ, (s₁ i) = s₂ (fin.cast (congr_arg nat.succ h₁) i),\n  begin\n    assume i,\n    rw [← list.nth_le_of_fn s₁ i, ← list.nth_le_of_fn s₂],\n    simp [h]\n  end,\nbegin\n  cases s₁, cases s₂,\n  dsimp at *,\n  subst h₁,\n  simp only [heq_iff_eq, eq_self_iff_true, true_and],\n  simp only [fin.cast_refl] at h₂,\n  exact funext h₂\nend\n\nlemma to_list_sorted (s : composition_series X) : s.to_list.sorted (<) :=\nlist.pairwise_iff_nth_le.2 (λ i j hi hij,\n  begin\n    dsimp [to_list],\n    rw [list.nth_le_of_fn', list.nth_le_of_fn'],\n    exact s.strict_mono hij\n  end)\n\nlemma to_list_nodup (s : composition_series X) : s.to_list.nodup :=\nlist.nodup_iff_nth_le_inj.2\n  (λ i j hi hj,\n    begin\n      delta to_list,\n      rw [list.nth_le_of_fn', list.nth_le_of_fn', s.injective.eq_iff, fin.ext_iff, fin.coe_mk, fin.coe_mk],\n      exact id\n    end)\n\n@[simp] lemma mem_to_list {s : composition_series X} {x : X} : x ∈ s.to_list ↔ x ∈ s :=\nbegin\n  rw [to_list, list.mem_of_fn],\n  refl\nend\n\n@[ext] lemma ext {s₁ s₂ : composition_series X} (h : ∀ x, x ∈ s₁ ↔ x ∈ s₂) : s₁ = s₂ :=\nto_list_injective $ list.eq_of_perm_of_sorted\n  (by classical; exact list.perm_of_nodup_nodup_to_finset_eq\n    s₁.to_list_nodup\n    s₂.to_list_nodup\n    (finset.ext $ by simp *))\n  s₁.to_list_sorted s₂.to_list_sorted\n\ndef top (s : composition_series X) : X := s (fin.last _)\n\nlemma top_mem (s : composition_series X) : s.top ∈ s :=\nmem_def.2 (set.mem_range.2 ⟨fin.last _, rfl⟩)\n\nlemma le_top {s : composition_series X} {x : X} (hx : x ∈ s) : x ≤ s.top :=\nlet ⟨i, hi⟩ := set.mem_range.1 hx in hi ▸ s.strict_mono.monotone (fin.le_last _)\n\ndef bot (s : composition_series X) : X := s 0\n\nlemma bot_mem (s : composition_series X) : s.bot ∈ s :=\nmem_def.2 (set.mem_range.2 ⟨0, rfl⟩)\n\nlemma bot_le {s : composition_series X} {x : X} (hx : x ∈ s) : s.bot ≤ x :=\nlet ⟨i, hi⟩ := set.mem_range.1 hx in hi ▸ s.strict_mono.monotone (fin.zero_le _)\n\ninstance : set_like (composition_series X) X :=\n{ coe := λ s, set.range s,\n  coe_injective' := λ s₁ s₂ h, ext $ λ x, begin\n    dsimp at h,\n    rw [mem_def, mem_def, h]\n  end }\n\n@[simps] def erase_top (s : composition_series X) : composition_series X :=\n{ length := s.length - 1,\n  series := λ i, s ⟨i, lt_of_lt_of_le i.2 (nat.succ_le_succ (nat.sub_le_self _ _))⟩,\n  step' := λ i, begin\n    have := s.step ⟨i, lt_of_lt_of_le i.2 (nat.sub_le_self _ _)⟩,\n    cases i,\n    exact this\n  end }\n\nlemma top_erase_top (s : composition_series X) :\n  s.erase_top.top = s ⟨s.length - 1, lt_of_le_of_lt (nat.sub_le_self _ _) (nat.lt_succ_self _)⟩ :=\nshow s _ = s _, from congr_arg s\nbegin\n  ext,\n  simp only [erase_top_length, fin.coe_last, fin.coe_cast_succ, fin.coe_of_nat_eq_mod,\n    fin.coe_mk, coe_coe]\nend\n\n@[simp] lemma bot_erase_top (s : composition_series X) : s.erase_top.bot = s.bot := rfl\n\nlemma length_pos_of_mem_ne {s : composition_series X}\n  {x y : X} (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y) :\n  0 < s.length :=\nlet ⟨i, hi⟩ := hx, ⟨j, hj⟩ := hy in\nhave hij : i ≠ j, from mt s.inj.2 $ λ h, hxy (hi ▸ hj ▸ h),\nhij.lt_or_lt.elim\n  (λ hij, (lt_of_le_of_lt (zero_le i)\n    (lt_of_lt_of_le hij (nat.le_of_lt_succ j.2))))\n  (λ hji, (lt_of_le_of_lt (zero_le j)\n    (lt_of_lt_of_le hji (nat.le_of_lt_succ i.2))))\n\nlemma forall_mem_eq_of_length_eq_zero {s : composition_series X}\n  (hs : s.length = 0) {x y} (hx : x ∈ s) (hy : y ∈ s) : x = y :=\nby_contradiction (λ hxy, pos_iff_ne_zero.1 (length_pos_of_mem_ne hx hy hxy) hs)\n\nlemma mem_erase_top_of_ne_of_mem {s : composition_series X} {x : X}\n  (hx : x ≠ s.top) (hxs : x ∈ s) : x ∈ s.erase_top :=\nbegin\n  { rcases hxs with ⟨i, rfl⟩,\n    have hi : (i : ℕ) < (s.length - 1).succ,\n    { conv_rhs { rw [← nat.succ_sub (length_pos_of_mem_ne ⟨i, rfl⟩ s.top_mem hx),\n        nat.succ_sub_one] },\n      exact lt_of_le_of_ne\n        (nat.le_of_lt_succ i.2)\n        (by simpa [top, s.inj, fin.ext_iff] using hx) },\n    refine ⟨i.cast_succ, _⟩,\n    simp [fin.ext_iff, nat.mod_eq_of_lt hi] }\nend\n\nlemma erase_top_le (s : composition_series X) : s.erase_top ≤ s :=\nbegin\n  rintros x ⟨i, rfl⟩,\n  simp [mem_def],\nend\n\nlemma mem_erase_top {s : composition_series X} {x : X}\n  (h : 0 < s.length) : x ∈ s.erase_top ↔ x ≠ s.top ∧ x ∈ s :=\nbegin\n  simp only [mem_def],\n  dsimp only [erase_top, coe_fn_mk],\n  split,\n  { rintros ⟨i, rfl⟩,\n    have hi : (i : ℕ) < s.length,\n    { conv_rhs { rw [← nat.succ_sub_one s.length, nat.succ_sub h] },\n      exact i.2 },\n    simp [top, fin.ext_iff, (ne_of_lt hi)] },\n  { intro h,\n    exact mem_erase_top_of_ne_of_mem h.1 h.2 }\nend\n\nlemma lt_top_of_mem_erase_top\n  {s : composition_series X} {x : X}\n  (h : 0 < s.length)\n  (hx : x ∈ s.erase_top) :\n  x < s.top :=\nlt_of_le_of_ne\n  (le_top ((mem_erase_top h).1 hx).2)\n  ((mem_erase_top h).1 hx).1\n\nlemma is_maximal_erase_top_top {s : composition_series X} (h : 0 < s.length) :\n  is_maximal s.erase_top.top s.top :=\nhave s.length - 1 + 1 = s.length,\n  by conv_rhs { rw [← nat.succ_sub_one s.length] }; rw nat.succ_sub h,\nbegin\n  rw [top_erase_top, top],\n  convert s.step ⟨s.length - 1, nat.sub_lt h zero_lt_one⟩;\n  ext; simp [this]\nend\n\nlemma append_cast_add_aux\n  {s₁ s₂ : composition_series X}\n  (h : s₁ (fin.last _) = s₂ 0)\n  (i : fin s₁.length) :\n  fin.append (nat.add_succ _ _).symm (s₁ ∘ fin.cast_succ) s₂\n  (fin.cast_add s₂.length i).cast_succ = s₁ i.cast_succ :=\nby { cases i, simp [fin.append, *] }\n\nlemma append_succ_cast_add_aux\n  {s₁ s₂ : composition_series X}\n  (h : s₁ (fin.last _) = s₂ 0)\n  (i : fin s₁.length) :\n  fin.append (nat.add_succ _ _).symm (s₁ ∘ fin.cast_succ) s₂\n  (fin.cast_add s₂.length i).succ = s₁ i.succ :=\nbegin\n  cases i with i hi,\n  simp only [fin.append, hi, fin.succ_mk, function.comp_app, fin.cast_succ_mk,\n    fin.coe_mk, fin.cast_add_mk],\n  split_ifs,\n  { refl },\n  { have : i + 1 = s₁.length, from le_antisymm hi (le_of_not_gt h_1),\n    calc s₂ ⟨i + 1 - s₁.length, by simp [this]⟩\n        = s₂ 0 : congr_arg s₂ (by simp [fin.ext_iff, this])\n    ... = s₁ (fin.last _) : h.symm\n    ... = _ : congr_arg s₁ (by simp [fin.ext_iff, this]) }\nend\n\nlemma append_cast_add_right_aux\n  {s₁ s₂ : composition_series X}\n  (h : s₁ (fin.last _) = s₂ 0)\n  (i : fin s₂.length) :\n  fin.append (nat.add_succ _ _).symm (s₁ ∘ fin.cast_succ) s₂\n  (fin.cast_add_right s₁.length i).cast_succ = s₂ i.cast_succ :=\nby { cases i, simp [fin.append, *] }\n\nlemma append_succ_cast_add_right_aux\n  {s₁ s₂ : composition_series X}\n  (h : s₁ (fin.last _) = s₂ 0)\n  (i : fin s₂.length) :\n  fin.append (nat.add_succ _ _).symm (s₁ ∘ fin.cast_succ) s₂\n  (fin.cast_add_right s₁.length i).succ = s₂ i.succ :=\nbegin\n  cases i with i hi,\n  simp [fin.append, add_assoc]\nend\n\n@[simps length] def append {s₁ s₂ : composition_series X}\n  (h : s₁.top = s₂.bot) :\n  composition_series X :=\n{ length := s₁.length + s₂.length,\n  series := fin.append (nat.add_succ _ _).symm (s₁ ∘ fin.cast_succ) s₂,\n  step' := λ i, begin\n    refine fin.add_cases  _ _ i,\n    { intro i,\n      rw [append_succ_cast_add_aux h, append_cast_add_aux h],\n      exact s₁.step i },\n    { intro i,\n      rw [append_cast_add_right_aux h, append_succ_cast_add_right_aux h],\n      exact s₂.step i }\n  end }\n\n@[simp] lemma append_cast_add\n  {s₁ s₂ : composition_series X}\n  (h : s₁.top = s₂.bot)\n  (i : fin s₁.length) :\n  append h (fin.cast_add s₂.length i).cast_succ = s₁ i.cast_succ :=\nappend_cast_add_aux h i\n\n@[simp] lemma append_succ_cast_add\n  {s₁ s₂ : composition_series X}\n  (h : s₁.top = s₂.bot)\n  (i : fin s₁.length) :\n  append h (fin.cast_add s₂.length i).succ = s₁ i.succ :=\nappend_succ_cast_add_aux h i\n\n@[simp] lemma append_cast_add_right\n  {s₁ s₂ : composition_series X}\n  (h : s₁.top = s₂.bot)\n  (i : fin s₂.length) :\n  append h (fin.cast_add_right s₁.length i).cast_succ = s₂ i.cast_succ :=\nappend_cast_add_right_aux h i\n\n@[simp] lemma append_succ_cast_add_right\n  {s₁ s₂ : composition_series X}\n  (h : s₁.top = s₂.bot)\n  (i : fin s₂.length) :\n  append h (fin.cast_add_right s₁.length i).succ = s₂ i.succ :=\nappend_succ_cast_add_right_aux h i\n\n@[simps] def insert\n  (s : composition_series X)\n  (x : X)\n  (hsat : is_maximal s.top x) :\n  composition_series X :=\n{ length := s.length + 1,\n  series := fin.snoc s x,\n  step' := λ i, begin\n    refine fin.last_cases _ _ i,\n    { rwa [fin.snoc_cast_succ, fin.succ_last, fin.snoc_last, ← top] },\n    { intro i,\n      rw [fin.snoc_cast_succ, ← fin.cast_succ_fin_succ, fin.snoc_cast_succ],\n      exact s.step _ }\n  end }\n\n-- @[simp] lemma insert_series'\n--   (s : composition_series X)\n--   (x : X)\n--   (hlt : ∀ y ∈ s, y < x)\n--   (hsat : is_maximal s.top x) :\n--   @eq (fin (s.length + 2) → X) (insert s x hlt hsat) (fin.snoc s x) :=\n-- rfl\n\n@[simp] lemma top_insert\n  (s : composition_series X)\n  (x : X)\n  (hsat : is_maximal s.top x) :\n  (insert s x hsat).top = x :=\nfin.snoc_last _ _\n\n@[simp] lemma insert_last\n  (s : composition_series X)\n  (x : X)\n  (hsat : is_maximal s.top x) :\n  insert s x hsat (fin.last _) = x :=\nfin.snoc_last _ _\n\n@[simp] lemma insert_cast_succ\n  (s : composition_series X)\n  (x : X)\n  (hsat : is_maximal s.top x) (i : fin (s.length + 1)) :\n  insert s x hsat (i.cast_succ) = s i :=\nfin.snoc_cast_succ _ _ _\n\n@[simp] lemma bot_insert\n  (s : composition_series X)\n  (x : X)\n  (hsat : is_maximal s.top x) :\n  (insert s x hsat).bot = s.bot :=\nby rw [bot, bot, ← fin.cast_succ_zero, insert_cast_succ]\n\nlemma mem_insert\n  {s : composition_series X}\n  {x y: X}\n  {hsat : is_maximal s.top x} :\n  y ∈ insert s x hsat ↔ y ∈ s ∨ y = x :=\nbegin\n  simp only [insert, mem_def],\n  split,\n  { rintros ⟨i, rfl⟩,\n    refine fin.last_cases _ (λ i, _) i,\n    { right, simp },\n    { left, simp } },\n  { intro h,\n    rcases h with ⟨i, rfl⟩ | rfl,\n    { use i.cast_succ, simp },\n    { use (fin.last _), simp } }\nend\n\nlemma eq_insert_erase_top\n  {s : composition_series X}\n  (h : 0 < s.length) :\n  s = insert (erase_top s) s.top\n    (is_maximal_erase_top_top h) :=\nbegin\n  ext x,\n  simp [mem_insert, mem_erase_top h],\n  by_cases h : x = s.top; simp [*, s.top_mem]\nend\n\n@[simp] lemma insert_erase_top_top {s : composition_series X}\n  (h : is_maximal s.erase_top.top s.top) :\n  s.erase_top.insert s.top h = s :=\nhave h : 0 < s.length,\n  from nat.pos_of_ne_zero begin\n    assume hs,\n    refine ne_of_gt (lt_of_is_maximal h) _,\n    simp [top, fin.ext_iff, hs]\n  end,\n(eq_insert_erase_top h).symm\n\ndef equivalent (s₁ s₂ : composition_series X) : Prop :=\n∃ f : fin s₁.length ≃ fin s₂.length,\n  ∀ i : fin s₁.length,\n    isom (s₁ i.cast_succ, s₁ i.succ)\n    (s₂ (f i).cast_succ, s₂ (f i).succ)\n\nnamespace equivalent\n\n@[refl] lemma refl (s : composition_series X) : equivalent s s :=\n⟨equiv.refl _, λ _, isom_refl _⟩\n\n@[symm] lemma symm {s₁ s₂ : composition_series X} (h : equivalent s₁ s₂) :\n  equivalent s₂ s₁ :=\n⟨h.some.symm, λ i, isom_symm (by simpa using h.some_spec (h.some.symm i))⟩\n\n@[trans] lemma trans {s₁ s₂ s₃ : composition_series X}\n  (h₁ : equivalent s₁ s₂)\n  (h₂ : equivalent s₂ s₃) :\n  equivalent s₁ s₃ :=\n⟨h₁.some.trans h₂.some, λ i, isom_trans (h₁.some_spec i) (h₂.some_spec (h₁.some i))⟩\n\ndef append\n  {s₁ s₂ t₁ t₂ : composition_series X}\n  (hs : s₁.top = s₂.bot)\n  (ht : t₁.top = t₂.bot)\n  (h₁ : equivalent s₁ t₁)\n  (h₂ : equivalent s₂ t₂) :\n  equivalent (append hs) (append ht) :=\nlet e : fin (s₁.length + s₂.length) ≃ fin (t₁.length + t₂.length) :=\n  calc fin (s₁.length + s₂.length) ≃ fin s₁.length ⊕ fin s₂.length : fin_sum_fin_equiv.symm\n  ... ≃ fin t₁.length ⊕ fin t₂.length : equiv.sum_congr h₁.some h₂.some\n  ... ≃ fin (t₁.length + t₂.length) : fin_sum_fin_equiv in\n⟨e, begin\n  assume i,\n  refine fin.add_cases _ _ i,\n  { assume i,\n    simpa [top, bot] using h₁.some_spec i },\n  { assume i,\n    simpa [top, bot] using h₂.some_spec i }\nend⟩\n\nlemma fin.succ_cast_succ {n : ℕ} (i : fin n) :\n  i.cast_succ.succ = i.succ.cast_succ :=\nfin.ext (by simp)\n\nprotected lemma insert\n  {s₁ s₂ : composition_series X}\n  {x₁ x₂ : X}\n  {hsat₁ : is_maximal s₁.top x₁}\n  {hsat₂ : is_maximal s₂.top x₂}\n  (hequiv : equivalent s₁ s₂)\n  (htop : isom (s₁.top, x₁) (s₂.top, x₂)) :\n  equivalent (s₁.insert x₁ hsat₁) (s₂.insert x₂ hsat₂) :=\nlet e : fin s₁.length.succ ≃ fin s₂.length.succ :=\n  calc fin (s₁.length + 1) ≃ option (fin s₁.length) : fin_succ_equiv_last\n  ... ≃ option (fin s₂.length) : functor.map_equiv option hequiv.some\n  ... ≃ fin (s₂.length + 1) : fin_succ_equiv_last.symm in\n⟨e,  λ i, begin\n  refine fin.last_cases _ _ i,\n  { simpa [top] using htop },\n  { assume i,\n    simpa [fin.succ_cast_succ] using hequiv.some_spec i }\nend⟩\n\nvariables {α β : Type*} (e : α ≃ β)\n\ndef swap_top_two_fin {m n : ℕ} (e : fin m ≃ fin n) : fin (m + 2) ≃ fin (n + 2) :=\ncalc fin (m + 2)\n    ≃ fin m ⊕ fin 2 : fin_sum_fin_equiv.symm\n... ≃ fin n ⊕ fin 2 : equiv.sum_congr e (equiv.swap 0 1)\n... ≃ fin (n + 2) : fin_sum_fin_equiv\n\n@[simp] lemma swap_top_two_fin_last {m n : ℕ} (e : fin m ≃ fin n) :\n  swap_top_two_fin e (fin.last _) = fin.cast_succ (fin.last _) :=\nby simp [swap_top_two_fin, fin.ext_iff]\n\n@[simp] lemma swap_top_two_fin_cast_succ_last {m n : ℕ} (e : fin m ≃ fin n) :\n  swap_top_two_fin e (fin.cast_succ (fin.last _)) = fin.last _ :=\nby simp [swap_top_two_fin, fin.ext_iff]\n\n@[simp] lemma swap_top_two_fin_cast_succ_cast_succ {m n : ℕ} (e : fin m ≃ fin n) (i : fin m) :\n  swap_top_two_fin e i.cast_succ.cast_succ = (e i).cast_succ.cast_succ :=\nhave ∀ {m : ℕ} {i : fin m}, i.cast_succ.cast_succ = fin.cast_add 2 i := λ _ _, fin.ext rfl,\nby simp [swap_top_two_fin, this]\n\nlemma insert_insert_swap\n  {s₁ s₂ : composition_series X}\n  {x₁ x₂ y₁ y₂ : X}\n  {hsat₁ : is_maximal s₁.top x₁}\n  {hsat₂ : is_maximal s₂.top x₂}\n  {hsaty₁ : is_maximal (insert s₁ x₁ hsat₁).top y₁}\n  {hsaty₂ : is_maximal (insert s₂ x₂ hsat₂).top y₂}\n  (hequiv : equivalent s₁ s₂)\n  (hr₁ : isom (s₁.top, x₁) (x₂, y₂))\n  (hr₂ : isom (x₁, y₁) (s₂.top, x₂)) :\n  equivalent\n    (insert (insert s₁ x₁ hsat₁) y₁ hsaty₁)\n    (insert (insert s₂ x₂ hsat₂) y₂ hsaty₂) :=\nlet e : fin (s₁.length + 1 + 1) ≃ fin (s₂.length + 1 + 1) :=\nswap_top_two_fin hequiv.some in\n⟨e, begin\n  intro i,\n  dsimp only [e],\n  refine fin.last_cases _ (λ i, _) i,\n  { erw [swap_top_two_fin_last, insert_cast_succ, insert_last, fin.succ_last, insert_last,\n      insert_cast_succ, insert_cast_succ, fin.succ_cast_succ, insert_cast_succ,\n      fin.succ_last, insert_last],\n    exact hr₂ },\n  { refine fin.last_cases _ (λ i, _) i,\n    { erw [swap_top_two_fin_cast_succ_last, insert_cast_succ, insert_cast_succ,\n        insert_cast_succ, fin.succ_cast_succ, insert_cast_succ,\n        fin.succ_last, insert_last, insert_last, fin.succ_last, insert_last],\n      exact hr₁ },\n    { erw [swap_top_two_fin_cast_succ_cast_succ, insert_cast_succ, insert_cast_succ,\n        insert_cast_succ, insert_cast_succ, fin.succ_cast_succ, insert_cast_succ,\n        fin.succ_cast_succ, insert_cast_succ, fin.succ_cast_succ, insert_cast_succ,\n        fin.succ_cast_succ, insert_cast_succ],\n      exact hequiv.some_spec i } }\nend⟩\n\nlemma length_eq {s₁ s₂ : composition_series X} (h : equivalent s₁ s₂) : s₁.length = s₂.length :=\nby simpa using fintype.card_congr h.some\n\nend equivalent\n\nlemma length_eq_zero_of_bot_eq_bot_of_top_eq_top_of_length_eq_zero\n  {s₁ s₂ : composition_series X}\n  (hb : s₁.bot = s₂.bot) (ht : s₁.top = s₂.top)\n  (hs₁ : s₁.length = 0) : s₂.length = 0 :=\nbegin\n  have : s₁.bot = s₁.top,\n    from congr_arg s₁ (fin.ext (by simp [hs₁])),\n  have : (fin.last s₂.length) = (0 : fin s₂.length.succ),\n    from s₂.injective (hb.symm.trans (this.trans ht)).symm,\n  simpa [fin.ext_iff]\nend\n\nlemma length_pos_of_bot_eq_bot_of_top_eq_top_of_length_pos\n  {s₁ s₂ : composition_series X}\n  (hb : s₁.bot = s₂.bot) (ht : s₁.top = s₂.top) :\n  0 < s₁.length → 0 < s₂.length :=\nnot_imp_not.1 begin\n  simp only [pos_iff_ne_zero, ne.def, not_iff_not, not_not],\n  exact length_eq_zero_of_bot_eq_bot_of_top_eq_top_of_length_eq_zero hb.symm ht.symm\nend\n\nlemma eq_of_bot_eq_bot_of_top_eq_top_of_length_eq_zero\n  {s₁ s₂ : composition_series X}\n  (hb : s₁.bot = s₂.bot) (ht : s₁.top = s₂.top)\n  (hs₁0 : s₁.length = 0) :\n  s₁ = s₂ :=\nhave ∀ x, x ∈ s₁ ↔ x = s₁.top,\n  from λ x, ⟨λ hx, forall_mem_eq_of_length_eq_zero hs₁0 hx s₁.top_mem, λ hx, hx.symm ▸ s₁.top_mem⟩,\nhave ∀ x, x ∈ s₂ ↔ x = s₂.top,\n  from λ x, ⟨λ hx, forall_mem_eq_of_length_eq_zero\n      (length_eq_zero_of_bot_eq_bot_of_top_eq_top_of_length_eq_zero hb ht hs₁0)\n    hx s₂.top_mem, λ hx, hx.symm ▸ s₂.top_mem⟩,\nby { ext, simp * }\n\nlemma intersection (s : composition_series X) (x : X)\n  (hm : is_maximal x s.top) (hb : s.bot ≤ x) :\n  ∃ t : composition_series X, t.bot = s.bot ∧ t.length + 1 = s.length ∧\n    ∃ htx : t.top = x, equivalent s (insert t s.top (htx.symm ▸ hm)) :=\nbegin\n  induction hn : s.length with n ih generalizing s x,\n  { exact (ne_of_gt (lt_of_le_of_lt hb (lt_of_is_maximal hm))\n      (forall_mem_eq_of_length_eq_zero hn s.top_mem s.bot_mem)).elim },\n  { have h0s : 0 < s.length, from hn.symm ▸ nat.succ_pos _,\n    by_cases hetx : s.erase_top.top = x,\n    { use s.erase_top,\n      simp [← hetx, hn] },\n    { have imxs : is_maximal (x ⊓ s.erase_top.top) s.erase_top.top,\n        from is_maximal_inf hm (is_maximal_erase_top_top h0s) (ne.symm hetx),\n      have := ih _ _ imxs (le_inf (by simpa) (le_top s.erase_top.bot_mem)) (by simp [hn]),\n      rcases this with ⟨t, htb, htl, htt, hteqv⟩,\n      have hmtx : is_maximal t.top x,\n      { rw [htt, inf_comm],\n        exact is_maximal_inf (is_maximal_erase_top_top h0s) hm  hetx },\n      use insert t x hmtx,\n      refine ⟨by simp [htb], by simp [htl], by simp, _⟩,\n      have : s.equivalent ((insert t s.erase_top.top (htt.symm ▸ imxs)).insert s.top\n        (by simpa using is_maximal_erase_top_top h0s)),\n      { conv_lhs { rw eq_insert_erase_top h0s },\n        exact equivalent.insert hteqv (by simp) },\n      refine this.trans _,\n      refine equivalent.insert_insert_swap (by refl) _ _,\n      { rw [← sup_eq_of_is_maximal (is_maximal_erase_top_top h0s) hm hetx, htt, inf_comm],\n        exact isom_symm (second_iso s.erase_top.top x) },\n      { rw [← sup_eq_of_is_maximal (is_maximal_erase_top_top h0s) hm hetx, htt, sup_comm],\n        exact second_iso _ _ } } }\nend\n\ntheorem jordan_hoelder (s₁ s₂ : composition_series X)\n  (hb : s₁.bot = s₂.bot) (ht : s₁.top = s₂.top) :\n  equivalent s₁ s₂ :=\nbegin\n  induction hle : s₁.length with n ih generalizing s₁ s₂,\n  { rw [eq_of_bot_eq_bot_of_top_eq_top_of_length_eq_zero hb ht hle] },\n  { have h0s₂ : 0 < s₂.length,\n      from length_pos_of_bot_eq_bot_of_top_eq_top_of_length_pos hb ht (hle.symm ▸ nat.succ_pos _),\n    rcases intersection s₁ s₂.erase_top.top\n      (ht.symm ▸ is_maximal_erase_top_top h0s₂)\n      (hb.symm ▸ s₂.bot_erase_top ▸ bot_le (top_mem _)) with ⟨t₂, htb₂, htl₂, htt₂, hteq₂⟩,\n    have := ih t₂ s₂.erase_top (by simp [htb₂, ← hb]) htt₂ (nat.succ_inj'.1 (htl₂.trans hle)),\n    refine hteq₂.trans _,\n    conv_rhs { rw [eq_insert_erase_top h0s₂] },\n    simp only [ht],\n    refine equivalent.insert this (by simp [htt₂]) }\nend\n\nend composition_series\n", "meta": {"author": "ChrisHughes24", "repo": "jordan_hoelder", "sha": "41ba0efabeded8655399420a0dfe107eb5acf664", "save_path": "github-repos/lean/ChrisHughes24-jordan_hoelder", "path": "github-repos/lean/ChrisHughes24-jordan_hoelder/jordan_hoelder-41ba0efabeded8655399420a0dfe107eb5acf664/src/jordan_hoelder.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396211, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4968388078459679}}
{"text": "import data.nat.basic\n\nexample (u w x y z : ℕ) (h₁ : x = y + z) (h₂ : w = u + x) :\n  w = z + y + u :=\nby simp [*, add_assoc, add_comm, add_left_comm]\n\nvariables (p q r : Prop)\n\nexample (hp : p) : p ∧ q ↔ q :=\nby simp *\n\nexample (hp : p) : p ∨ q :=\nby simp *\n\nexample (hp : p) (hq : q) : p ∧ (q ∨ r) :=\nby simp *\n", "meta": {"author": "agryman", "repo": "theorem-proving-in-lean", "sha": "cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9", "save_path": "github-repos/lean/agryman-theorem-proving-in-lean", "path": "github-repos/lean/agryman-theorem-proving-in-lean/theorem-proving-in-lean-cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9/src/05-Tactics/example-5.7-6.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7981867681382279, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4968388018694911}}
{"text": "import SciLean.Prelude\nimport SciLean.Algebra\nimport SciLean.Mathlib.Data.PowType\n\n\ndef Nat.toInt (n : ℕ) : Int := Int.ofNat n\n\n\nnamespace SciLean\n\ninstance : PowType ℤ where\n  powType n := {u : Array ℤ // u.size = n}\n  intro {n} f := Id.run do\n    let mut u : Array ℤ := Array.mkEmpty n\n    for i in [0:n] do\n      u := u.push (f ⟨i, sorry⟩)\n    ⟨u, sorry⟩\n  get v i := v.1.get ⟨i, by rw[v.2] apply i.2⟩\n  set v i val := ⟨v.1.set ⟨i, by rw[v.2] apply i.2⟩ val, sorry⟩\n  ext := sorry\n\ninductive Node (LeafData NodeData : Type) : Type where\n| leaf  (data : LeafData) : Node LeafData NodeData\n| node  (data : NodeData) (children : Array (Node LeafData NodeData)) : Node LeafData NodeData\n\nnamespace VDB_LIKE\n\n  structure GridNode (dim : Nat) (size : Nat) where\n    pos : ℤ^dim\n    lvl : Nat\n\n  abbrev Index (dim : Nat) (size : Nat) := Fin (size^dim)\n\n  def Index.toPos (idx : Index dim size) : ℤ^dim := Id.run do\n    let mut pos : ℤ^dim := 0\n    let mut idx := idx.1\n    for i in [0:dim] do\n      pos[!i] := (idx % size).toInt\n      idx := idx / size\n    pos\n    -- let mask := (2^scl) - 1\n    -- PowType.intro λ i => ((idx.1 >>> (i.1 * scl)) &&& mask).toInt\n\n  def toIndex {dim : Nat} (p : ℤ^dim) : Index dim scl :=\n    let size := 2^scl\n    ⟨∑ i, (p[i].fmod size).toNat <<< (i.1 * scl), sorry⟩\n      \n  def test : IO Unit := do\n    let dim := 2\n    let scl := 3\n    let N := 2^(dim * scl)\n    for i in [0:N] do\n      let idx : Index dim scl := ⟨i, sorry⟩\n      IO.println s!\"{i} {idx.toPos} {((idx.toPos |> toIndex) : Index dim scl)}\"\n\n  #eval test\n\n  namespace GridNode\n\n    variable {dim scl : Nat}\n\n    def count (node : GridNode dim scl) := 2^(dim * scl)\n    def size  (node : GridNode dim scl) := 2^(scl * node.lvl)\n    def originOffset (lvl scl : Nat) : ℤ := ∑ i : Fin (lvl+1), if (i.1 % 2 = 1) then - ((1:ℕ) <<< (i.1 - 1) * scl).toInt else 0\n\n    #eval originOffset 1 2\n    def min (node : GridNode dim scl) : ℤ^dim := node.size.toInt * node.pos\n    def max (node : GridNode dim scl) : ℤ^dim := node.pos.map (λ x => node.size.toInt * x - 1) -- node.size.toInt * (node.pos + 1) - 1\n\n    def parent (node : GridNode dim scl) : GridNode dim scl := \n      ⟨node.pos.map (λ x => x.fdiv scl), node.lvl+1⟩\n    def child  (node : GridNode dim scl) (idx : Index dim scl) : GridNode dim scl := \n      if node.lvl = 0 \n      then node\n      else ⟨((1:ℕ) <<< scl).toInt * node.pos + idx.toPos, node.lvl-1⟩\n    def localPos (node : GridNode dim scl) : ℤ^dim := \n      let size := (1:ℕ) <<< scl\n      node.pos.map λ x => x.fmod size\n    def index (node : GridNode dim scl) : Index dim scl := \n      node.pos |> toIndex\n\n    -- def node : GridNode 2 2 := ⟨^[-1,0], 0⟩\n    -- #eval node.index\n\n    theorem parent_child_index (node : GridNode dim scl) : node.parent.child node.index = node := sorry\n    \n    def common_index (i j : ℤ) (scl : ℕ) : ℤ×ℕ := Id.run do\n      let upper_bound := (Nat.max i.natAbs j.natAbs).log2 + 10\n      dbg_trace s!\"upper bound := {upper_bound}\"\n      let mut i := i\n      let mut j := j\n      let size := (1:ℕ) <<< scl\n      for l in [0:upper_bound] do\n        if i = j then \n          return (i, l)\n        else \n          i := i.fdiv size\n          j := j.fdiv size\n      panic! \"This should be unreachable\"\n\n    #eval common_index (8) (-13) 2\n\n    #eval (2^4) - 1\n    #check (2^4) - 1\n\n    #eval (2:ℕ).log2 + 1\n\n    -- def min (node : GridNode dim scl) := ((1:ℕ) <<< scl).toInt * pos\n\n  end GridNode\n\n\nend VDB_LIKE\n\n\n\n\nnamespace NewApproach\n\n\n  structure GridCell (dim size lvl : Nat) where\n    pos : ℤ^dim\n\n  namespace GridCell\n\n    def Impl {α} (a : α) := α\n\n    -- Origin of level `lvl+lvlInc` w.r.t. origin of level `lvl`\n    -- really not sure if this is correct ...\n    -- What is the proper definition ???\n    def originOffset (size lvl lvlInc : Nat) : ℤ := \n      if lvl%2 = 0 \n      then \n        let e := 2*((lvlInc+1)/2) \n        (1 - (-size.toInt)^e) / (1 + size)       \n      else \n        let e := 2*((lvlInc)/2) \n        size*(1 - (-size.toInt)^e) / (1 + size)\n  \n    theorem originOffset_by_one (size lvl)\n      : originOffset size lvl 1 = if lvl%2=0 then 1 - size else 0 := sorry\n\n    def nparent (n : Nat) : GridCell dim size lvl → GridCell dim size (lvl+n) :=\n      let offset := originOffset size lvl n\n      let nsize := size^n\n      λ ⟨p⟩ => ⟨p.map λ xi => (xi - offset).fdiv nsize⟩\n\n    def child (idx : Fin (size^dim)) : GridCell dim size (lvl+1) → GridCell dim size lvl :=\n      let offset := originOffset size lvl 1\n      let loc_p : ℤ^dim := sorry\n      λ ⟨p⟩ => ⟨size.toInt * p + offset * (1:ℤ^dim) + loc_p⟩\n\n    def inParentIdx : GridCell dim size lvl → Fin (size^dim) := sorry\n    def inParentPos (node : GridCell dim size lvl) : ℤ^dim := (sorry : Impl $ node.nparent 1 |>.child (!0) |>.pos) \n    -- optimize by\n    --   finish_opt\n    \n\n    theorem nchild_parentIdx (node : GridCell dim size lvl) : (node.nparent 1).child node.inParentIdx = node := sorry\n\n\n\n  end GridCell\n\n  \n  #eval  2*((3)/2)\n\nend NewApproach\n\n\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Data/VDBLike.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.6224593171945417, "lm_q1q2_score": 0.49683879666551606}}
{"text": "import category_theory.category.default\nimport game.world1.level3\n\nuniverses v u  -- The order in this declaration matters: v often needs to be explicitly specified while u often can be omitted\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/-\n# Category world\n\n## Level 5: More tactic reviews\n-/\n\n/-blah blah\n\n-/\n\n/- Lemma\nIf $$f : X ⟶ Y$$ and $$g : X ⟶ Y$$ are morphisms such that $$f = g$$, then $$f ≫ h = g ≫ h$$.\n-/\nlemma id_of_comp_left_id' (X : C) (f : X ⟶ X) (w : ∀ {Y : C} (g : X ⟶ Y), f ≫ g = g) : f = 𝟙 X :=\nbegin\n    apply eq_of_comp_left_eq'',\n    intros Z h,\n    rw category.id_comp h,\n    apply w,\nend\n\nend category_theory", "meta": {"author": "agusakov", "repo": "category-theory-game", "sha": "652dd7e90ae706643b2a597e2c938403653e167d", "save_path": "github-repos/lean/agusakov-category-theory-game", "path": "github-repos/lean/agusakov-category-theory-game/category-theory-game-652dd7e90ae706643b2a597e2c938403653e167d/src/game/world1/level5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744673038221, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.49680989237627843}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.subobject.factor_thru\n! leanprover-community/mathlib commit 829895f162a1f29d0133f4b3538f4cd1fb5bffd3\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Subobject.Basic\nimport Mathbin.CategoryTheory.Preadditive.Basic\n\n/-!\n# Factoring through subobjects\n\nThe predicate `h : P.factors f`, for `P : subobject Y` and `f : X ⟶ Y`\nasserts the existence of some `P.factor_thru f : X ⟶ (P : C)` making the obvious diagram commute.\n\n-/\n\n\nuniverse v₁ v₂ u₁ u₂\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits\n\nvariable {C : Type u₁} [Category.{v₁} C] {X Y Z : C}\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\nnamespace CategoryTheory\n\nnamespace MonoOver\n\n/-- When `f : X ⟶ Y` and `P : mono_over Y`,\n`P.factors f` expresses that there exists a factorisation of `f` through `P`.\nGiven `h : P.factors f`, you can recover the morphism as `P.factor_thru f h`.\n-/\ndef Factors {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) : Prop :=\n  ∃ g : X ⟶ (P : C), g ≫ P.arrow = f\n#align category_theory.mono_over.factors CategoryTheory.MonoOver.Factors\n\ntheorem factors_congr {X : C} {f g : MonoOver X} {Y : C} (h : Y ⟶ X) (e : f ≅ g) :\n    f.Factors h ↔ g.Factors h :=\n  ⟨fun ⟨u, hu⟩ => ⟨u ≫ ((MonoOver.forget _).map e.Hom).left, by simp [hu]⟩, fun ⟨u, hu⟩ =>\n    ⟨u ≫ ((MonoOver.forget _).map e.inv).left, by simp [hu]⟩⟩\n#align category_theory.mono_over.factors_congr CategoryTheory.MonoOver.factors_congr\n\n/-- `P.factor_thru f h` provides a factorisation of `f : X ⟶ Y` through some `P : mono_over Y`,\ngiven the evidence `h : P.factors f` that such a factorisation exists. -/\ndef factorThru {X Y : C} (P : MonoOver Y) (f : X ⟶ Y) (h : Factors P f) : X ⟶ (P : C) :=\n  Classical.choose h\n#align category_theory.mono_over.factor_thru CategoryTheory.MonoOver.factorThru\n\nend MonoOver\n\nnamespace Subobject\n\n/-- When `f : X ⟶ Y` and `P : subobject Y`,\n`P.factors f` expresses that there exists a factorisation of `f` through `P`.\nGiven `h : P.factors f`, you can recover the morphism as `P.factor_thru f h`.\n-/\ndef Factors {X Y : C} (P : Subobject Y) (f : X ⟶ Y) : Prop :=\n  Quotient.liftOn' P (fun P => P.Factors f)\n    (by\n      rintro P Q ⟨h⟩\n      apply propext\n      constructor\n      · rintro ⟨i, w⟩\n        exact ⟨i ≫ h.hom.left, by erw [category.assoc, over.w h.hom, w]⟩\n      · rintro ⟨i, w⟩\n        exact ⟨i ≫ h.inv.left, by erw [category.assoc, over.w h.inv, w]⟩)\n#align category_theory.subobject.factors CategoryTheory.Subobject.Factors\n\n@[simp]\ntheorem mk_factors_iff {X Y Z : C} (f : Y ⟶ X) [Mono f] (g : Z ⟶ X) :\n    (Subobject.mk f).Factors g ↔ (MonoOver.mk' f).Factors g :=\n  Iff.rfl\n#align category_theory.subobject.mk_factors_iff CategoryTheory.Subobject.mk_factors_iff\n\ntheorem mk_factors_self (f : X ⟶ Y) [Mono f] : (mk f).Factors f :=\n  ⟨𝟙 _, by simp⟩\n#align category_theory.subobject.mk_factors_self CategoryTheory.Subobject.mk_factors_self\n\ntheorem factors_iff {X Y : C} (P : Subobject Y) (f : X ⟶ Y) :\n    P.Factors f ↔ (representative.obj P).Factors f :=\n  Quot.inductionOn P fun a => MonoOver.factors_congr _ (representativeIso _).symm\n#align category_theory.subobject.factors_iff CategoryTheory.Subobject.factors_iff\n\ntheorem factors_self {X : C} (P : Subobject X) : P.Factors P.arrow :=\n  (factors_iff _ _).mpr ⟨𝟙 P, by simp⟩\n#align category_theory.subobject.factors_self CategoryTheory.Subobject.factors_self\n\ntheorem factors_comp_arrow {X Y : C} {P : Subobject Y} (f : X ⟶ P) : P.Factors (f ≫ P.arrow) :=\n  (factors_iff _ _).mpr ⟨f, rfl⟩\n#align category_theory.subobject.factors_comp_arrow CategoryTheory.Subobject.factors_comp_arrow\n\ntheorem factors_of_factors_right {X Y Z : C} {P : Subobject Z} (f : X ⟶ Y) {g : Y ⟶ Z}\n    (h : P.Factors g) : P.Factors (f ≫ g) := by\n  revert P\n  refine' Quotient.ind' _\n  intro P\n  rintro ⟨g, rfl⟩\n  exact ⟨f ≫ g, by simp⟩\n#align category_theory.subobject.factors_of_factors_right CategoryTheory.Subobject.factors_of_factors_right\n\ntheorem factors_zero [HasZeroMorphisms C] {X Y : C} {P : Subobject Y} : P.Factors (0 : X ⟶ Y) :=\n  (factors_iff _ _).mpr ⟨0, by simp⟩\n#align category_theory.subobject.factors_zero CategoryTheory.Subobject.factors_zero\n\ntheorem factors_of_le {Y Z : C} {P Q : Subobject Y} (f : Z ⟶ Y) (h : P ≤ Q) :\n    P.Factors f → Q.Factors f := by\n  simp only [factors_iff]\n  exact fun ⟨u, hu⟩ => ⟨u ≫ of_le _ _ h, by simp [← hu]⟩\n#align category_theory.subobject.factors_of_le CategoryTheory.Subobject.factors_of_le\n\n/-- `P.factor_thru f h` provides a factorisation of `f : X ⟶ Y` through some `P : subobject Y`,\ngiven the evidence `h : P.factors f` that such a factorisation exists. -/\ndef factorThru {X Y : C} (P : Subobject Y) (f : X ⟶ Y) (h : Factors P f) : X ⟶ P :=\n  Classical.choose ((factors_iff _ _).mp h)\n#align category_theory.subobject.factor_thru CategoryTheory.Subobject.factorThru\n\n@[simp, reassoc.1]\ntheorem factorThru_arrow {X Y : C} (P : Subobject Y) (f : X ⟶ Y) (h : Factors P f) :\n    P.factorThru f h ≫ P.arrow = f :=\n  Classical.choose_spec ((factors_iff _ _).mp h)\n#align category_theory.subobject.factor_thru_arrow CategoryTheory.Subobject.factorThru_arrow\n\n@[simp]\ntheorem factorThru_self {X : C} (P : Subobject X) (h) : P.factorThru P.arrow h = 𝟙 P :=\n  by\n  ext\n  simp\n#align category_theory.subobject.factor_thru_self CategoryTheory.Subobject.factorThru_self\n\n@[simp]\ntheorem factorThru_mk_self (f : X ⟶ Y) [Mono f] :\n    (mk f).factorThru f (mk_factors_self f) = (underlyingIso f).inv :=\n  by\n  ext\n  simp\n#align category_theory.subobject.factor_thru_mk_self CategoryTheory.Subobject.factorThru_mk_self\n\n@[simp]\ntheorem factorThru_comp_arrow {X Y : C} {P : Subobject Y} (f : X ⟶ P) (h) :\n    P.factorThru (f ≫ P.arrow) h = f := by\n  ext\n  simp\n#align category_theory.subobject.factor_thru_comp_arrow CategoryTheory.Subobject.factorThru_comp_arrow\n\n@[simp]\ntheorem factorThru_eq_zero [HasZeroMorphisms C] {X Y : C} {P : Subobject Y} {f : X ⟶ Y}\n    {h : Factors P f} : P.factorThru f h = 0 ↔ f = 0 :=\n  by\n  fconstructor\n  · intro w\n    replace w := w =≫ P.arrow\n    simpa using w\n  · rintro rfl\n    ext\n    simp\n#align category_theory.subobject.factor_thru_eq_zero CategoryTheory.Subobject.factorThru_eq_zero\n\ntheorem factorThru_right {X Y Z : C} {P : Subobject Z} (f : X ⟶ Y) (g : Y ⟶ Z) (h : P.Factors g) :\n    f ≫ P.factorThru g h = P.factorThru (f ≫ g) (factors_of_factors_right f h) :=\n  by\n  apply (cancel_mono P.arrow).mp\n  simp\n#align category_theory.subobject.factor_thru_right CategoryTheory.Subobject.factorThru_right\n\n@[simp]\ntheorem factorThru_zero [HasZeroMorphisms C] {X Y : C} {P : Subobject Y}\n    (h : P.Factors (0 : X ⟶ Y)) : P.factorThru 0 h = 0 := by simp\n#align category_theory.subobject.factor_thru_zero CategoryTheory.Subobject.factorThru_zero\n\n-- `h` is an explicit argument here so we can use\n-- `rw factor_thru_le h`, obtaining a subgoal `P.factors f`.\n-- (While the reverse direction looks plausible as a simp lemma, it seems to be unproductive.)\ntheorem factorThru_ofLe {Y Z : C} {P Q : Subobject Y} {f : Z ⟶ Y} (h : P ≤ Q) (w : P.Factors f) :\n    Q.factorThru f (factors_of_le f h w) = P.factorThru f w ≫ ofLe P Q h :=\n  by\n  ext\n  simp\n#align category_theory.subobject.factor_thru_of_le CategoryTheory.Subobject.factorThru_ofLe\n\nsection Preadditive\n\nvariable [Preadditive C]\n\ntheorem factors_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y) (wf : P.Factors f)\n    (wg : P.Factors g) : P.Factors (f + g) :=\n  (factors_iff _ _).mpr ⟨P.factorThru f wf + P.factorThru g wg, by simp⟩\n#align category_theory.subobject.factors_add CategoryTheory.Subobject.factors_add\n\n-- This can't be a `simp` lemma as `wf` and `wg` may not exist.\n-- However you can `rw` by it to assert that `f` and `g` factor through `P` separately.\ntheorem factorThru_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y) (w : P.Factors (f + g))\n    (wf : P.Factors f) (wg : P.Factors g) :\n    P.factorThru (f + g) w = P.factorThru f wf + P.factorThru g wg :=\n  by\n  ext\n  simp\n#align category_theory.subobject.factor_thru_add CategoryTheory.Subobject.factorThru_add\n\ntheorem factors_left_of_factors_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)\n    (w : P.Factors (f + g)) (wg : P.Factors g) : P.Factors f :=\n  (factors_iff _ _).mpr ⟨P.factorThru (f + g) w - P.factorThru g wg, by simp⟩\n#align category_theory.subobject.factors_left_of_factors_add CategoryTheory.Subobject.factors_left_of_factors_add\n\n@[simp]\ntheorem factorThru_add_sub_factorThru_right {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)\n    (w : P.Factors (f + g)) (wg : P.Factors g) :\n    P.factorThru (f + g) w - P.factorThru g wg =\n      P.factorThru f (factors_left_of_factors_add f g w wg) :=\n  by\n  ext\n  simp\n#align category_theory.subobject.factor_thru_add_sub_factor_thru_right CategoryTheory.Subobject.factorThru_add_sub_factorThru_right\n\ntheorem factors_right_of_factors_add {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)\n    (w : P.Factors (f + g)) (wf : P.Factors f) : P.Factors g :=\n  (factors_iff _ _).mpr ⟨P.factorThru (f + g) w - P.factorThru f wf, by simp⟩\n#align category_theory.subobject.factors_right_of_factors_add CategoryTheory.Subobject.factors_right_of_factors_add\n\n@[simp]\ntheorem factorThru_add_sub_factorThru_left {X Y : C} {P : Subobject Y} (f g : X ⟶ Y)\n    (w : P.Factors (f + g)) (wf : P.Factors f) :\n    P.factorThru (f + g) w - P.factorThru f wf =\n      P.factorThru g (factors_right_of_factors_add f g w wf) :=\n  by\n  ext\n  simp\n#align category_theory.subobject.factor_thru_add_sub_factor_thru_left CategoryTheory.Subobject.factorThru_add_sub_factorThru_left\n\nend Preadditive\n\nend Subobject\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Subobject/FactorThru.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489892, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.49651942241422303}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.group_theory.group_action.basic\nimport Mathlib.algebra.group_action_hom\nimport Mathlib.algebra.module.basic\nimport Mathlib.PostPort\n\nuniverses u v l \n\nnamespace Mathlib\n\n/-!\n\n# Sets invariant to a `mul_action`\n\nIn this file we define `sub_mul_action R M`; a subset of a `mul_action M` which is closed with\nrespect to scalar multiplication.\n\nFor most uses, typically `submodule R M` is more powerful.\n\n## Tags\n\nsubmodule, mul_action\n-/\n\n/-- A sub_mul_action is a set which is closed under scalar multiplication.  -/\nstructure sub_mul_action (R : Type u) (M : Type v) [has_scalar R M] where\n  carrier : set M\n  smul_mem' : ∀ (c : R) {x : M}, x ∈ carrier → c • x ∈ carrier\n\nnamespace sub_mul_action\n\n\nprotected instance set.has_coe_t {R : Type u} {M : Type v} [has_scalar R M] :\n    has_coe_t (sub_mul_action R M) (set M) :=\n  has_coe_t.mk fun (s : sub_mul_action R M) => carrier s\n\nprotected instance has_mem {R : Type u} {M : Type v} [has_scalar R M] :\n    has_mem M (sub_mul_action R M) :=\n  has_mem.mk fun (x : M) (p : sub_mul_action R M) => x ∈ ↑p\n\nprotected instance has_coe_to_sort {R : Type u} {M : Type v} [has_scalar R M] :\n    has_coe_to_sort (sub_mul_action R M) :=\n  has_coe_to_sort.mk (Type (max 0 v)) fun (p : sub_mul_action R M) => Subtype fun (x : M) => x ∈ p\n\nprotected instance has_top {R : Type u} {M : Type v} [has_scalar R M] :\n    has_top (sub_mul_action R M) :=\n  has_top.mk (mk set.univ sorry)\n\nprotected instance has_bot {R : Type u} {M : Type v} [has_scalar R M] :\n    has_bot (sub_mul_action R M) :=\n  has_bot.mk (mk ∅ sorry)\n\nprotected instance inhabited {R : Type u} {M : Type v} [has_scalar R M] :\n    Inhabited (sub_mul_action R M) :=\n  { default := ⊥ }\n\n@[simp] theorem coe_sort_coe {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) :\n    ↥↑p = ↥p :=\n  rfl\n\nprotected theorem exists {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    {q : ↥p → Prop} : (∃ (x : ↥p), q x) ↔ ∃ (x : M), ∃ (H : x ∈ p), q { val := x, property := H } :=\n  set_coe.exists\n\nprotected theorem forall {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    {q : ↥p → Prop} : (∀ (x : ↥p), q x) ↔ ∀ (x : M) (H : x ∈ p), q { val := x, property := H } :=\n  set_coe.forall\n\ntheorem coe_injective {R : Type u} {M : Type v} [has_scalar R M] : function.injective coe := sorry\n\n@[simp] theorem coe_set_eq {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    {q : sub_mul_action R M} : ↑p = ↑q ↔ p = q :=\n  function.injective.eq_iff coe_injective\n\ntheorem ext'_iff {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    {q : sub_mul_action R M} : p = q ↔ ↑p = ↑q :=\n  iff.symm coe_set_eq\n\ntheorem ext {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    {q : sub_mul_action R M} (h : ∀ (x : M), x ∈ p ↔ x ∈ q) : p = q :=\n  coe_injective (set.ext h)\n\nend sub_mul_action\n\n\nnamespace sub_mul_action\n\n\n@[simp] theorem mem_coe {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M)\n    {x : M} : x ∈ ↑p ↔ x ∈ p :=\n  iff.rfl\n\ntheorem smul_mem {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) {x : M} (r : R)\n    (h : x ∈ p) : r • x ∈ p :=\n  smul_mem' p r h\n\nprotected instance has_scalar {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) :\n    has_scalar R ↥p :=\n  has_scalar.mk fun (c : R) (x : ↥p) => { val := c • subtype.val x, property := sorry }\n\n@[simp] theorem coe_eq_coe {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    {x : ↥p} {y : ↥p} : ↑x = ↑y ↔ x = y :=\n  iff.symm subtype.ext_iff_val\n\n@[simp] theorem coe_smul {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} (r : R)\n    (x : ↥p) : ↑(r • x) = r • ↑x :=\n  rfl\n\n@[simp] theorem coe_mk {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} (x : M)\n    (hx : x ∈ p) : ↑{ val := x, property := hx } = x :=\n  rfl\n\n@[simp] theorem coe_mem {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    (x : ↥p) : ↑x ∈ p :=\n  subtype.property x\n\n@[simp] protected theorem eta {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    (x : ↥p) (hx : ↑x ∈ p) : { val := ↑x, property := hx } = x :=\n  subtype.eta x hx\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) :\n    mul_action_hom R (↥p) M :=\n  mul_action_hom.mk coe sorry\n\n@[simp] theorem subtype_apply {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M)\n    (x : ↥p) : coe_fn (sub_mul_action.subtype p) x = ↑x :=\n  rfl\n\ntheorem subtype_eq_val {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) :\n    ⇑(sub_mul_action.subtype p) = subtype.val :=\n  rfl\n\n@[simp] theorem smul_mem_iff' {R : Type u} {M : Type v} [monoid R] [mul_action R M]\n    (p : sub_mul_action R M) {x : M} (u : units R) : ↑u • x ∈ p ↔ x ∈ p :=\n  sorry\n\n/-- If the scalar product forms a `mul_action`, then the subset inherits this action -/\nprotected instance mul_action {R : Type u} {M : Type v} [monoid R] [mul_action R M]\n    (p : sub_mul_action R M) : mul_action R ↥p :=\n  mul_action.mk sorry sorry\n\ntheorem zero_mem {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (p : sub_mul_action R M) (h : set.nonempty ↑p) : 0 ∈ p :=\n  sorry\n\n/-- If the scalar product forms a `semimodule`, and the `sub_mul_action` is not `⊥`, then the\nsubset inherits the zero. -/\nprotected instance has_zero {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : sub_mul_action R M) [n_empty : Nonempty ↥p] : HasZero ↥p :=\n  { zero := { val := 0, property := sorry } }\n\ntheorem neg_mem {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : sub_mul_action R M) {x : M} (hx : x ∈ p) : -x ∈ p :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (-x ∈ p)) (Eq.symm (neg_one_smul R x)))) (smul_mem p (-1) hx)\n\n@[simp] theorem neg_mem_iff {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : sub_mul_action R M) {x : M} : -x ∈ p ↔ x ∈ p :=\n  { mp :=\n      fun (h : -x ∈ p) =>\n        eq.mpr (id (Eq._oldrec (Eq.refl (x ∈ p)) (Eq.symm (neg_neg x)))) (neg_mem p h),\n    mpr := neg_mem p }\n\nprotected instance has_neg {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : sub_mul_action R M) : Neg ↥p :=\n  { neg := fun (x : ↥p) => { val := -subtype.val x, property := sorry } }\n\n@[simp] theorem coe_neg {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : sub_mul_action R M) (x : ↥p) : ↑(-x) = -↑x :=\n  rfl\n\nend sub_mul_action\n\n\nnamespace sub_mul_action\n\n\ntheorem smul_mem_iff {R : Type u} {M : Type v} [division_ring R] [add_comm_group M] [module R M]\n    (p : sub_mul_action R M) {r : R} {x : M} (r0 : r ≠ 0) : r • x ∈ p ↔ x ∈ p :=\n  smul_mem_iff' p (units.mk0 r r0)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/group_theory/group_action/sub_mul_action_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.4965194199699586}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl\n-/\nimport algebra.hom.group\nimport algebra.order.monoid.order_dual\nimport algebra.order.monoid.with_zero.basic\nimport data.nat.cast.defs\n\n/-! # Adjoining top/bottom elements to ordered monoids.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\nuniverses u v\nvariables {α : Type u} {β : Type v}\n\nopen function\n\nnamespace with_top\n\nsection has_one\n\nvariables [has_one α]\n\n@[to_additive] instance : has_one (with_top α) := ⟨(1 : α)⟩\n\n@[simp, norm_cast, to_additive] lemma coe_one : ((1 : α) : with_top α) = 1 := rfl\n\n@[simp, norm_cast, to_additive] lemma coe_eq_one {a : α} : (a : with_top α) = 1 ↔ a = 1 :=\ncoe_eq_coe\n\n@[simp, to_additive] lemma untop_one : (1 : with_top α).untop coe_ne_top = 1 := rfl\n@[simp, to_additive] lemma untop_one' (d : α) : (1 : with_top α).untop' d = 1 := rfl\n\n@[simp, norm_cast, to_additive coe_nonneg]\nlemma one_le_coe [has_le α] {a : α} : 1 ≤ (a : with_top α) ↔ 1 ≤ a := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_le_zero]\nlemma coe_le_one [has_le α] {a : α} : (a : with_top α) ≤ 1 ↔ a ≤ 1 := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_pos]\nlemma one_lt_coe [has_lt α] {a : α} : 1 < (a : with_top α) ↔ 1 < a := coe_lt_coe\n\n@[simp, norm_cast, to_additive coe_lt_zero]\nlemma coe_lt_one [has_lt α] {a : α} : (a : with_top α) < 1 ↔ a < 1 := coe_lt_coe\n\n@[simp, to_additive] protected lemma map_one {β} (f : α → β) :\n  (1 : with_top α).map f = (f 1 : with_top β) := rfl\n\n@[simp, norm_cast, to_additive] theorem one_eq_coe {a : α} : 1 = (a : with_top α) ↔ a = 1 :=\ntrans eq_comm coe_eq_one\n\n@[simp, to_additive] theorem top_ne_one : ⊤ ≠ (1 : with_top α) .\n@[simp, to_additive] theorem one_ne_top : (1 : with_top α) ≠ ⊤ .\n\ninstance [has_zero α] [has_le α] [zero_le_one_class α] : zero_le_one_class (with_top α) :=\n⟨some_le_some.2 zero_le_one⟩\n\nend has_one\n\nsection has_add\nvariables [has_add α] {a b c d : with_top α} {x y : α}\n\ninstance : has_add (with_top α) := ⟨option.map₂ (+)⟩\n\n@[norm_cast] lemma coe_add : ((x + y : α) : with_top α) = x + y := rfl\n@[norm_cast] lemma coe_bit0 : ((bit0 x : α) : with_top α) = bit0 x := rfl\n@[norm_cast] lemma coe_bit1 [has_one α] {a : α} : ((bit1 a : α) : with_top α) = bit1 a := rfl\n\n@[simp] lemma top_add (a : with_top α) : ⊤ + a = ⊤ := rfl\n@[simp] \n\n@[simp] lemma add_eq_top : a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤ :=\nby cases a; cases b; simp [none_eq_top, some_eq_coe, ←with_top.coe_add]\n\nlemma add_ne_top : a + b ≠ ⊤ ↔ a ≠ ⊤ ∧ b ≠ ⊤ := add_eq_top.not.trans not_or_distrib\n\nlemma add_lt_top [has_lt α] {a b : with_top α} : a + b < ⊤ ↔ a < ⊤ ∧ b < ⊤ :=\nby simp_rw [with_top.lt_top_iff_ne_top, add_ne_top]\n\nlemma add_eq_coe : ∀ {a b : with_top α} {c : α},\n  a + b = c ↔ ∃ (a' b' : α), ↑a' = a ∧ ↑b' = b ∧ a' + b' = c\n| none b c := by simp [none_eq_top]\n| (some a) none c := by simp [none_eq_top]\n| (some a) (some b) c :=\n    by simp only [some_eq_coe, ← coe_add, coe_eq_coe, exists_and_distrib_left, exists_eq_left]\n\n@[simp] lemma add_coe_eq_top_iff {x : with_top α} {y : α} : x + y = ⊤ ↔ x = ⊤ :=\nby { induction x using with_top.rec_top_coe; simp [← coe_add] }\n\n@[simp] lemma coe_add_eq_top_iff {y : with_top α} : ↑x + y = ⊤ ↔ y = ⊤ :=\nby { induction y using with_top.rec_top_coe; simp [← coe_add] }\n\ninstance covariant_class_add_le [has_le α] [covariant_class α α (+) (≤)] :\n  covariant_class (with_top α) (with_top α) (+) (≤) :=\n⟨λ a b c h, begin\n  cases a; cases c; try { exact le_top },\n  rcases le_coe_iff.1 h with ⟨b, rfl, h'⟩,\n  exact coe_le_coe.2 (add_le_add_left (coe_le_coe.1 h) _)\nend⟩\n\ninstance covariant_class_swap_add_le [has_le α] [covariant_class α α (swap (+)) (≤)] :\n  covariant_class (with_top α) (with_top α) (swap (+)) (≤) :=\n⟨λ a b c h, begin\n  cases a; cases c; try { exact le_top },\n  rcases le_coe_iff.1 h with ⟨b, rfl, h'⟩,\n  exact coe_le_coe.2 (add_le_add_right (coe_le_coe.1 h) _)\nend⟩\n\ninstance contravariant_class_add_lt [has_lt α] [contravariant_class α α (+) (<)] :\n  contravariant_class (with_top α) (with_top α) (+) (<) :=\n⟨λ a b c h, begin\n  induction a using with_top.rec_top_coe, { exact (not_none_lt _ h).elim },\n  induction b using with_top.rec_top_coe, { exact (not_none_lt _ h).elim },\n  induction c using with_top.rec_top_coe,\n  { exact coe_lt_top _ },\n  { exact coe_lt_coe.2 (lt_of_add_lt_add_left $ coe_lt_coe.1 h) }\nend⟩\n\ninstance contravariant_class_swap_add_lt [has_lt α] [contravariant_class α α (swap (+)) (<)] :\n  contravariant_class (with_top α) (with_top α) (swap (+)) (<) :=\n⟨λ a b c h, begin\n  cases a; cases b; try { exact (not_none_lt _ h).elim },\n  cases c,\n  { exact coe_lt_top _ },\n  { exact coe_lt_coe.2 (lt_of_add_lt_add_right $ coe_lt_coe.1 h) }\nend⟩\n\nprotected lemma le_of_add_le_add_left [has_le α] [contravariant_class α α (+) (≤)] (ha : a ≠ ⊤)\n  (h : a + b ≤ a + c) : b ≤ c :=\nbegin\n  lift a to α using ha,\n  induction c using with_top.rec_top_coe, { exact le_top },\n  induction b using with_top.rec_top_coe, { exact (not_top_le_coe _ h).elim },\n  simp only [← coe_add, coe_le_coe] at h ⊢,\n  exact le_of_add_le_add_left h\nend\n\nprotected lemma le_of_add_le_add_right [has_le α] [contravariant_class α α (swap (+)) (≤)]\n  (ha : a ≠ ⊤) (h : b + a ≤ c + a) : b ≤ c :=\nbegin\n  lift a to α using ha,\n  cases c,\n  { exact le_top },\n  cases b,\n  { exact (not_top_le_coe _ h).elim },\n  { exact coe_le_coe.2 (le_of_add_le_add_right $ coe_le_coe.1 h) }\nend\n\nprotected lemma add_lt_add_left [has_lt α] [covariant_class α α (+) (<)] (ha : a ≠ ⊤) (h : b < c) :\n  a + b < a + c :=\nbegin\n  lift a to α using ha,\n  rcases lt_iff_exists_coe.1 h with ⟨b, rfl, h'⟩,\n  cases c,\n  { exact coe_lt_top _ },\n  { exact coe_lt_coe.2 (add_lt_add_left (coe_lt_coe.1 h) _) }\nend\n\nprotected lemma add_lt_add_right [has_lt α] [covariant_class α α (swap (+)) (<)]\n  (ha : a ≠ ⊤) (h : b < c) :\n  b + a < c + a :=\nbegin\n  lift a to α using ha,\n  rcases lt_iff_exists_coe.1 h with ⟨b, rfl, h'⟩,\n  cases c,\n  { exact coe_lt_top _ },\n  { exact coe_lt_coe.2 (add_lt_add_right (coe_lt_coe.1 h) _) }\nend\n\nprotected lemma add_le_add_iff_left [has_le α] [covariant_class α α (+) (≤)]\n  [contravariant_class α α (+) (≤)]\n  (ha : a ≠ ⊤) : a + b ≤ a + c ↔ b ≤ c :=\n⟨with_top.le_of_add_le_add_left ha, λ h, add_le_add_left h a⟩\n\nprotected lemma add_le_add_iff_right [has_le α] [covariant_class α α (swap (+)) (≤)]\n  [contravariant_class α α (swap (+)) (≤)] (ha : a ≠ ⊤) : b + a ≤ c + a ↔ b ≤ c :=\n⟨with_top.le_of_add_le_add_right ha, λ h, add_le_add_right h a⟩\n\nprotected lemma add_lt_add_iff_left [has_lt α] [covariant_class α α (+) (<)]\n  [contravariant_class α α (+) (<)] (ha : a ≠ ⊤) : a + b < a + c ↔ b < c :=\n⟨lt_of_add_lt_add_left, with_top.add_lt_add_left ha⟩\n\nprotected lemma add_lt_add_iff_right [has_lt α] [covariant_class α α (swap (+)) (<)]\n  [contravariant_class α α (swap (+)) (<)] (ha : a ≠ ⊤) : b + a < c + a ↔ b < c :=\n⟨lt_of_add_lt_add_right, with_top.add_lt_add_right ha⟩\n\nprotected lemma add_lt_add_of_le_of_lt [preorder α] [covariant_class α α (+) (<)]\n  [covariant_class α α (swap (+)) (≤)] (ha : a ≠ ⊤) (hab : a ≤ b) (hcd : c < d) : a + c < b + d :=\n(with_top.add_lt_add_left ha hcd).trans_le $ add_le_add_right hab _\n\nprotected lemma add_lt_add_of_lt_of_le [preorder α] [covariant_class α α (+) (≤)]\n  [covariant_class α α (swap (+)) (<)] (hc : c ≠ ⊤) (hab : a < b) (hcd : c ≤ d) : a + c < b + d :=\n(with_top.add_lt_add_right hc hab).trans_le $ add_le_add_left hcd _\n\n/-  There is no `with_top.map_mul_of_mul_hom`, since `with_top` does not have a multiplication. -/\n@[simp] protected lemma map_add {F} [has_add β] [add_hom_class F α β] (f : F) (a b : with_top α) :\n  (a + b).map f = a.map f + b.map f :=\nbegin\n  induction a using with_top.rec_top_coe,\n  { exact (top_add _).symm },\n  { induction b using with_top.rec_top_coe,\n    { exact (add_top _).symm },\n    { rw [map_coe, map_coe, ← coe_add, ← coe_add, ← map_add],\n      refl } },\nend\n\nend has_add\n\ninstance [add_semigroup α] : add_semigroup (with_top α) :=\n{ add_assoc := λ _ _ _, option.map₂_assoc add_assoc,\n  ..with_top.has_add }\n\ninstance [add_comm_semigroup α] : add_comm_semigroup (with_top α) :=\n{ add_comm := λ _ _, option.map₂_comm add_comm,\n  ..with_top.add_semigroup }\n\ninstance [add_zero_class α] : add_zero_class (with_top α) :=\n{ zero_add := option.map₂_left_identity zero_add,\n  add_zero := option.map₂_right_identity add_zero,\n  ..with_top.has_zero,\n  ..with_top.has_add }\n\ninstance [add_monoid α] : add_monoid (with_top α) :=\n{ ..with_top.add_zero_class,\n  ..with_top.has_zero,\n  ..with_top.add_semigroup }\n\ninstance [add_comm_monoid α] : add_comm_monoid (with_top α) :=\n{ ..with_top.add_monoid, ..with_top.add_comm_semigroup }\n\ninstance [add_monoid_with_one α] : add_monoid_with_one (with_top α) :=\n{ nat_cast := λ n, ↑(n : α),\n  nat_cast_zero := by rw [nat.cast_zero, with_top.coe_zero],\n  nat_cast_succ := λ n, by rw [nat.cast_add_one, with_top.coe_add, with_top.coe_one],\n  .. with_top.has_one, .. with_top.add_monoid }\n\ninstance [add_comm_monoid_with_one α] : add_comm_monoid_with_one (with_top α) :=\n{ .. with_top.add_monoid_with_one, .. with_top.add_comm_monoid }\n\ninstance [ordered_add_comm_monoid α] : ordered_add_comm_monoid (with_top α) :=\n{ add_le_add_left :=\n    begin\n      rintros a b h (_|c), { simp [none_eq_top] },\n      rcases b with (_|b), { simp [none_eq_top] },\n      rcases le_coe_iff.1 h with ⟨a, rfl, h⟩,\n      simp only [some_eq_coe, ← coe_add, coe_le_coe] at h ⊢,\n      exact add_le_add_left h c\n    end,\n  ..with_top.partial_order, ..with_top.add_comm_monoid }\n\ninstance [linear_ordered_add_comm_monoid α] :\n  linear_ordered_add_comm_monoid_with_top (with_top α) :=\n{ top_add' := with_top.top_add,\n  ..with_top.order_top,\n  ..with_top.linear_order,\n  ..with_top.ordered_add_comm_monoid,\n  ..option.nontrivial }\n\ninstance [has_le α] [has_add α] [has_exists_add_of_le α] : has_exists_add_of_le (with_top α) :=\n⟨λ a b, match a, b with\n  | ⊤, ⊤ := by simp\n  | (a : α), ⊤ := λ _, ⟨⊤, rfl⟩\n  | (a : α), (b : α) := λ h, begin\n      obtain ⟨c, rfl⟩ := exists_add_of_le (with_top.coe_le_coe.1 h),\n      exact ⟨c, rfl⟩\n    end\n  | ⊤, (b : α) := λ h, (not_top_le_coe _ h).elim\nend⟩\n\ninstance [canonically_ordered_add_monoid α] : canonically_ordered_add_monoid (with_top α) :=\n{ le_self_add := λ a b, match a, b with\n  | ⊤, ⊤ := le_rfl\n  | (a : α), ⊤ := le_top\n  | (a : α), (b : α) := with_top.coe_le_coe.2 le_self_add\n  | ⊤, (b : α) := le_rfl\n  end,\n  ..with_top.order_bot, ..with_top.ordered_add_comm_monoid, ..with_top.has_exists_add_of_le }\n\ninstance [canonically_linear_ordered_add_monoid α] :\n  canonically_linear_ordered_add_monoid (with_top α) :=\n{ ..with_top.canonically_ordered_add_monoid, ..with_top.linear_order }\n\n@[simp, norm_cast] lemma coe_nat [add_monoid_with_one α] (n : ℕ) : ((n : α) : with_top α) = n := rfl\n@[simp] lemma nat_ne_top [add_monoid_with_one α] (n : ℕ) : (n : with_top α) ≠ ⊤ := coe_ne_top\n@[simp] lemma top_ne_nat [add_monoid_with_one α] (n : ℕ) : (⊤ : with_top α) ≠ n := top_ne_coe\n\n/-- Coercion from `α` to `with_top α` as an `add_monoid_hom`. -/\ndef coe_add_hom [add_monoid α] : α →+ with_top α :=\n⟨coe, rfl, λ _ _, rfl⟩\n\n@[simp] lemma coe_coe_add_hom [add_monoid α] : ⇑(coe_add_hom : α →+ with_top α) = coe := rfl\n\n@[simp] lemma zero_lt_top [ordered_add_comm_monoid α] : (0 : with_top α) < ⊤ :=\ncoe_lt_top 0\n\n@[simp, norm_cast] lemma zero_lt_coe [ordered_add_comm_monoid α] (a : α) :\n  (0 : with_top α) < a ↔ 0 < a :=\ncoe_lt_coe\n\n/-- A version of `with_top.map` for `one_hom`s. -/\n@[to_additive \"A version of `with_top.map` for `zero_hom`s\", simps { fully_applied := ff }]\nprotected def _root_.one_hom.with_top_map {M N : Type*} [has_one M] [has_one N] (f : one_hom M N) :\n  one_hom (with_top M) (with_top N) :=\n{ to_fun := with_top.map f,\n  map_one' := by rw [with_top.map_one, map_one, coe_one] }\n\n/-- A version of `with_top.map` for `add_hom`s. -/\n@[simps { fully_applied := ff }] protected def _root_.add_hom.with_top_map\n  {M N : Type*} [has_add M] [has_add N] (f : add_hom M N) :\n  add_hom (with_top M) (with_top N) :=\n{ to_fun := with_top.map f,\n  map_add' := with_top.map_add f }\n\n/-- A version of `with_top.map` for `add_monoid_hom`s. -/\n@[simps { fully_applied := ff }] protected def _root_.add_monoid_hom.with_top_map\n  {M N : Type*} [add_zero_class M] [add_zero_class N] (f : M →+ N) :\n  with_top M →+ with_top N :=\n{ to_fun := with_top.map f,\n  .. f.to_zero_hom.with_top_map, .. f.to_add_hom.with_top_map }\n\nend with_top\n\nnamespace with_bot\n\n@[to_additive] instance [has_one α] : has_one (with_bot α) := with_top.has_one\ninstance [has_add α] : has_add (with_bot α) := with_top.has_add\ninstance [add_semigroup α] : add_semigroup (with_bot α) := with_top.add_semigroup\ninstance [add_comm_semigroup α] : add_comm_semigroup (with_bot α) := with_top.add_comm_semigroup\ninstance [add_zero_class α] : add_zero_class (with_bot α) := with_top.add_zero_class\ninstance [add_monoid α] : add_monoid (with_bot α) := with_top.add_monoid\ninstance [add_comm_monoid α] : add_comm_monoid (with_bot α) := with_top.add_comm_monoid\ninstance [add_monoid_with_one α] : add_monoid_with_one (with_bot α) := with_top.add_monoid_with_one\n\ninstance [add_comm_monoid_with_one α] : add_comm_monoid_with_one (with_bot α) :=\nwith_top.add_comm_monoid_with_one\n\ninstance [has_zero α] [has_one α] [has_le α] [zero_le_one_class α] :\n  zero_le_one_class (with_bot α) :=\n⟨some_le_some.2 zero_le_one⟩\n\n-- `by norm_cast` proves this lemma, so I did not tag it with `norm_cast`\n@[to_additive]\nlemma coe_one [has_one α] : ((1 : α) : with_bot α) = 1 := rfl\n\n-- `by norm_cast` proves this lemma, so I did not tag it with `norm_cast`\n@[to_additive]\nlemma coe_eq_one [has_one α] {a : α} : (a : with_bot α) = 1 ↔ a = 1 :=\nwith_top.coe_eq_one\n\n@[simp, to_additive] lemma unbot_one [has_one α] : (1 : with_bot α).unbot coe_ne_bot = 1 := rfl\n@[simp, to_additive] lemma unbot_one' [has_one α] (d : α) : (1 : with_bot α).unbot' d = 1 := rfl\n\n@[simp, norm_cast, to_additive coe_nonneg]\nlemma one_le_coe [has_one α] [has_le α] {a : α} : 1 ≤ (a : with_bot α) ↔ 1 ≤ a := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_le_zero]\nlemma coe_le_one [has_one α] [has_le α] {a : α} : (a : with_bot α) ≤ 1 ↔ a ≤ 1 := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_pos]\nlemma one_lt_coe [has_one α] [has_lt α] {a : α} : 1 < (a : with_bot α) ↔ 1 < a := coe_lt_coe\n\n@[simp, norm_cast, to_additive coe_lt_zero]\nlemma coe_lt_one [has_one α] [has_lt α] {a : α} : (a : with_bot α) < 1 ↔ a < 1 := coe_lt_coe\n\n@[simp, to_additive] protected lemma map_one {β} [has_one α] (f : α → β) :\n  (1 : with_bot α).map f = (f 1 : with_bot β) := rfl\n\n@[norm_cast] lemma coe_nat [add_monoid_with_one α] (n : ℕ) : ((n : α) : with_bot α) = n := rfl\n@[simp] lemma nat_ne_bot [add_monoid_with_one α] (n : ℕ) : (n : with_bot α) ≠ ⊥ := coe_ne_bot\n@[simp] lemma bot_ne_nat [add_monoid_with_one α] (n : ℕ) : (⊥ : with_bot α) ≠ n := bot_ne_coe\n\nsection has_add\nvariables [has_add α] {a b c d : with_bot α} {x y : α}\n\n-- `norm_cast` proves those lemmas, because `with_top`/`with_bot` are reducible\nlemma coe_add (a b : α) : ((a + b : α) : with_bot α) = a + b := rfl\nlemma coe_bit0 : ((bit0 x : α) : with_bot α) = bit0 x := rfl\nlemma coe_bit1 [has_one α] {a : α} : ((bit1 a : α) : with_bot α) = bit1 a := rfl\n\n@[simp] lemma bot_add (a : with_bot α) : ⊥ + a = ⊥ := rfl\n@[simp] lemma add_bot (a : with_bot α) : a + ⊥ = ⊥ := by cases a; refl\n\n@[simp] lemma add_eq_bot : a + b = ⊥ ↔ a = ⊥ ∨ b = ⊥ := with_top.add_eq_top\nlemma add_ne_bot : a + b ≠ ⊥ ↔ a ≠ ⊥ ∧ b ≠ ⊥ := with_top.add_ne_top\n\nlemma bot_lt_add [has_lt α] {a b : with_bot α} : ⊥ < a + b ↔ ⊥ < a ∧ ⊥ < b :=\n@with_top.add_lt_top αᵒᵈ _ _ _ _\n\nlemma add_eq_coe : a + b = x ↔ ∃ (a' b' : α), ↑a' = a ∧ ↑b' = b ∧ a' + b' = x := with_top.add_eq_coe\n\n@[simp] lemma add_coe_eq_bot_iff : a + y = ⊥ ↔ a = ⊥ := with_top.add_coe_eq_top_iff\n@[simp] lemma coe_add_eq_bot_iff : ↑x + b = ⊥ ↔ b = ⊥ := with_top.coe_add_eq_top_iff\n\n/-  There is no `with_bot.map_mul_of_mul_hom`, since `with_bot` does not have a multiplication. -/\n@[simp] protected lemma map_add {F} [has_add β] [add_hom_class F α β] (f : F) (a b : with_bot α) :\n  (a + b).map f = a.map f + b.map f :=\nwith_top.map_add f a b\n\n/-- A version of `with_bot.map` for `one_hom`s. -/\n@[to_additive \"A version of `with_bot.map` for `zero_hom`s\", simps { fully_applied := ff }]\nprotected def _root_.one_hom.with_bot_map {M N : Type*} [has_one M] [has_one N] (f : one_hom M N) :\n  one_hom (with_bot M) (with_bot N) :=\n{ to_fun := with_bot.map f,\n  map_one' := by rw [with_bot.map_one, map_one, coe_one] }\n\n/-- A version of `with_bot.map` for `add_hom`s. -/\n@[simps { fully_applied := ff }] protected def _root_.add_hom.with_bot_map\n  {M N : Type*} [has_add M] [has_add N] (f : add_hom M N) :\n  add_hom (with_bot M) (with_bot N) :=\n{ to_fun := with_bot.map f,\n  map_add' := with_bot.map_add f }\n\n/-- A version of `with_bot.map` for `add_monoid_hom`s. -/\n@[simps { fully_applied := ff }] protected def _root_.add_monoid_hom.with_bot_map\n  {M N : Type*} [add_zero_class M] [add_zero_class N] (f : M →+ N) :\n  with_bot M →+ with_bot N :=\n{ to_fun := with_bot.map f,\n  .. f.to_zero_hom.with_bot_map, .. f.to_add_hom.with_bot_map }\n\nvariables [preorder α]\n\ninstance covariant_class_add_le [covariant_class α α (+) (≤)] :\n  covariant_class (with_bot α) (with_bot α) (+) (≤) :=\n@order_dual.covariant_class_add_le (with_top αᵒᵈ) _ _ _\n\ninstance covariant_class_swap_add_le [covariant_class α α (swap (+)) (≤)] :\n  covariant_class (with_bot α) (with_bot α) (swap (+)) (≤) :=\n@order_dual.covariant_class_swap_add_le (with_top αᵒᵈ) _ _ _\n\ninstance contravariant_class_add_lt [contravariant_class α α (+) (<)] :\n  contravariant_class (with_bot α) (with_bot α) (+) (<) :=\n@order_dual.contravariant_class_add_lt (with_top αᵒᵈ) _ _ _\n\ninstance contravariant_class_swap_add_lt [contravariant_class α α (swap (+)) (<)] :\n  contravariant_class (with_bot α) (with_bot α) (swap (+)) (<) :=\n@order_dual.contravariant_class_swap_add_lt (with_top αᵒᵈ) _ _ _\n\nprotected lemma le_of_add_le_add_left [contravariant_class α α (+) (≤)] (ha : a ≠ ⊥)\n  (h : a + b ≤ a + c) : b ≤ c :=\n@with_top.le_of_add_le_add_left αᵒᵈ _ _ _ _ _ _ ha h\n\nprotected lemma le_of_add_le_add_right [contravariant_class α α (swap (+)) (≤)] (ha : a ≠ ⊥)\n  (h : b + a ≤ c + a) : b ≤ c :=\n@with_top.le_of_add_le_add_right αᵒᵈ _ _ _ _ _ _ ha h\n\nprotected lemma add_lt_add_left [covariant_class α α (+) (<)] (ha : a ≠ ⊥) (h : b < c) :\n  a + b < a + c :=\n@with_top.add_lt_add_left αᵒᵈ _ _ _ _ _ _ ha h\n\nprotected lemma add_lt_add_right [covariant_class α α (swap (+)) (<)] (ha : a ≠ ⊥) (h : b < c) :\n  b + a < c + a :=\n@with_top.add_lt_add_right αᵒᵈ _ _ _ _ _ _ ha h\n\nprotected lemma add_le_add_iff_left [covariant_class α α (+) (≤)] [contravariant_class α α (+) (≤)]\n  (ha : a ≠ ⊥) : a + b ≤ a + c ↔ b ≤ c :=\n⟨with_bot.le_of_add_le_add_left ha, λ h, add_le_add_left h a⟩\n\nprotected lemma add_le_add_iff_right [covariant_class α α (swap (+)) (≤)]\n  [contravariant_class α α (swap (+)) (≤)] (ha : a ≠ ⊥) : b + a ≤ c + a ↔ b ≤ c :=\n⟨with_bot.le_of_add_le_add_right ha, λ h, add_le_add_right h a⟩\n\nprotected lemma add_lt_add_iff_left [covariant_class α α (+) (<)] [contravariant_class α α (+) (<)]\n  (ha : a ≠ ⊥) : a + b < a + c ↔ b < c :=\n⟨lt_of_add_lt_add_left, with_bot.add_lt_add_left ha⟩\n\nprotected lemma add_lt_add_iff_right [covariant_class α α (swap (+)) (<)]\n  [contravariant_class α α (swap (+)) (<)] (ha : a ≠ ⊥) : b + a < c + a ↔ b < c :=\n⟨lt_of_add_lt_add_right, with_bot.add_lt_add_right ha⟩\n\nprotected lemma add_lt_add_of_le_of_lt [covariant_class α α (+) (<)]\n  [covariant_class α α (swap (+)) (≤)] (hb : b ≠ ⊥) (hab : a ≤ b) (hcd : c < d) : a + c < b + d :=\n@with_top.add_lt_add_of_le_of_lt αᵒᵈ _ _ _ _ _ _ _ _ hb hab hcd\n\nprotected lemma add_lt_add_of_lt_of_le [covariant_class α α (+) (≤)]\n  [covariant_class α α (swap (+)) (<)] (hd : d ≠ ⊥) (hab : a < b) (hcd : c ≤ d) : a + c < b + d :=\n@with_top.add_lt_add_of_lt_of_le αᵒᵈ _ _ _ _ _ _ _ _ hd hab hcd\n\nend has_add\n\ninstance [ordered_add_comm_monoid α] : ordered_add_comm_monoid (with_bot α) :=\n{ add_le_add_left := λ a b h c, add_le_add_left h c,\n  ..with_bot.partial_order,\n  ..with_bot.add_comm_monoid }\n\ninstance [linear_ordered_add_comm_monoid α] : linear_ordered_add_comm_monoid (with_bot α) :=\n{ ..with_bot.linear_order, ..with_bot.ordered_add_comm_monoid }\n\nend with_bot\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/order/monoid/with_top.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.49651941445493847}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.products.basic\n! leanprover-community/mathlib commit dc6c365e751e34d100e80fe6e314c3c3e0fd2988\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.EqToHom\nimport Mathlib.CategoryTheory.Functor.Const\nimport Mathlib.Data.Prod.Basic\n\n/-!\n# Cartesian products of categories\n\nWe define the category instance on `C × D` when `C` and `D` are categories.\n\nWe define:\n* `sectl C Z` : the functor `C ⥤ C × D` given by `X ↦ ⟨X, Z⟩`\n* `sectr Z D` : the functor `D ⥤ C × D` given by `Y ↦ ⟨Z, Y⟩`\n* `fst`       : the functor `⟨X, Y⟩ ↦ X`\n* `snd`       : the functor `⟨X, Y⟩ ↦ Y`\n* `swap`      : the functor `C × D ⥤ D × C` given by `⟨X, Y⟩ ↦ ⟨Y, X⟩`\n    (and the fact this is an equivalence)\n\nWe further define `evaluation : C ⥤ (C ⥤ D) ⥤ D` and `evaluationUncurried : C × (C ⥤ D) ⥤ D`,\nand products of functors and natural transformations, written `F.prod G` and `α.prod β`.\n-/\n\n\nnamespace CategoryTheory\n\n-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation\nuniverse v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄\n\nsection\n\nvariable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D]\n\n-- the generates simp lemmas like `id_fst` and `comp_snd`\n/-- `prod C D` gives the cartesian product of two categories.\n\nSee <https://stacks.math.columbia.edu/tag/001K>.\n-/\n@[simps (config := { notRecursive := [] })]\ninstance prod : Category.{max v₁ v₂} (C × D)\n    where\n  Hom X Y := (X.1 ⟶ Y.1) × (X.2 ⟶ Y.2)\n  id X := ⟨𝟙 X.1, 𝟙 X.2⟩\n  comp f g := (f.1 ≫ g.1, f.2 ≫ g.2)\n#align category_theory.prod CategoryTheory.prod\n\n/-- Two rfl lemmas that cannot be generated by `@[simps]`. -/\n@[simp]\ntheorem prod_id (X : C) (Y : D) : 𝟙 (X, Y) = (𝟙 X, 𝟙 Y) :=\n  rfl\n#align category_theory.prod_id CategoryTheory.prod_id\n\n@[simp]\ntheorem prod_comp {P Q R : C} {S T U : D} (f : (P, S) ⟶ (Q, T)) (g : (Q, T) ⟶ (R, U)) :\n    f ≫ g = (f.1 ≫ g.1, f.2 ≫ g.2) :=\n  rfl\n#align category_theory.prod_comp CategoryTheory.prod_comp\n\ntheorem isIso_prod_iff {P Q : C} {S T : D} {f : (P, S) ⟶ (Q, T)} :\n    IsIso f ↔ IsIso f.1 ∧ IsIso f.2 := by\n  constructor\n  · rintro ⟨g, hfg, hgf⟩\n    simp at hfg hgf\n    rcases hfg with ⟨hfg₁, hfg₂⟩\n    rcases hgf with ⟨hgf₁, hgf₂⟩\n    exact ⟨⟨⟨g.1, hfg₁, hgf₁⟩⟩, ⟨⟨g.2, hfg₂, hgf₂⟩⟩⟩\n  · rintro ⟨⟨g₁, hfg₁, hgf₁⟩, ⟨g₂, hfg₂, hgf₂⟩⟩\n    dsimp at hfg₁ hgf₁ hfg₂ hgf₂\n    refine' ⟨⟨(g₁, g₂), _, _⟩⟩\n    repeat { simp; constructor; assumption; assumption }\n#align category_theory.is_iso_prod_iff CategoryTheory.isIso_prod_iff\n\nsection\n\nvariable {C D}\n\n/-- The isomorphism between `(X.1, X.2)` and `X`. -/\n@[simps]\ndef prod.etaIso (X : C × D) : (X.1, X.2) ≅ X\n    where\n  hom := (𝟙 _, 𝟙 _)\n  inv := (𝟙 _, 𝟙 _)\n#align category_theory.prod.eta_iso CategoryTheory.prod.etaIso\n\n/-- Construct an isomorphism in `C × D` out of two isomorphisms in `C` and `D`. -/\n@[simps]\ndef Iso.prod {P Q : C} {S T : D} (f : P ≅ Q) (g : S ≅ T) : (P, S) ≅ (Q, T)\n    where\n  hom := (f.hom, g.hom)\n  inv := (f.inv, g.inv)\n#align category_theory.iso.prod CategoryTheory.Iso.prod\n\nend\n\nend\n\nsection\n\nvariable (C : Type u₁) [Category.{v₁} C] (D : Type u₁) [Category.{v₁} D]\n\n/-- `Category.uniformProd C D` is an additional instance specialised so both factors have the same\nuniverse levels. This helps typeclass resolution.\n-/\ninstance uniformProd : Category (C × D) :=\n  CategoryTheory.prod C D\n#align category_theory.uniform_prod CategoryTheory.uniformProd\n\nend\n\n-- Next we define the natural functors into and out of product categories. For now this doesn't\n-- address the universal properties.\nnamespace Prod\n\n/-- `sectl C Z` is the functor `C ⥤ C × D` given by `X ↦ (X, Z)`. -/\n@[simps]\ndef sectl (C : Type u₁) [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] (Z : D) : C ⥤ C × D\n    where\n  obj X := (X, Z)\n  map f := (f, 𝟙 Z)\n#align category_theory.prod.sectl CategoryTheory.Prod.sectl\n\n/-- `sectr Z D` is the functor `D ⥤ C × D` given by `Y ↦ (Z, Y)` . -/\n@[simps]\ndef sectr {C : Type u₁} [Category.{v₁} C] (Z : C) (D : Type u₂) [Category.{v₂} D] : D ⥤ C × D\n    where\n  obj X := (Z, X)\n  map f := (𝟙 Z, f)\n#align category_theory.prod.sectr CategoryTheory.Prod.sectr\n\nvariable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D]\n\n/-- `fst` is the functor `(X, Y) ↦ X`. -/\n@[simps]\ndef fst : C × D ⥤ C where\n  obj X := X.1\n  map f := f.1\n#align category_theory.prod.fst CategoryTheory.Prod.fst\n\n/-- `snd` is the functor `(X, Y) ↦ Y`. -/\n@[simps]\ndef snd : C × D ⥤ D where\n  obj X := X.2\n  map f := f.2\n#align category_theory.prod.snd CategoryTheory.Prod.snd\n\n/-- The functor swapping the factors of a cartesian product of categories, `C × D ⥤ D × C`. -/\n@[simps]\ndef swap : C × D ⥤ D × C where\n  obj X := (X.2, X.1)\n  map f := (f.2, f.1)\n#align category_theory.prod.swap CategoryTheory.Prod.swap\n\n/-- Swapping the factors of a cartesion product of categories twice is naturally isomorphic\nto the identity functor.\n-/\n@[simps]\ndef symmetry : swap C D ⋙ swap D C ≅ 𝟭 (C × D)\n    where\n  hom := { app := fun X => 𝟙 X }\n  inv := { app := fun X => 𝟙 X }\n#align category_theory.prod.symmetry CategoryTheory.Prod.symmetry\n\n/-- The equivalence, given by swapping factors, between `C × D` and `D × C`.\n-/\n@[simps!]\ndef braiding : C × D ≌ D × C :=\n  Equivalence.mk (swap C D) (swap D C)\n    (NatIso.ofComponents (fun X => eqToIso (by simp)) (by aesop_cat))\n    (NatIso.ofComponents (fun X => eqToIso (by simp)) (by aesop_cat))\n#align category_theory.prod.braiding CategoryTheory.Prod.braiding\n\ninstance swapIsEquivalence : IsEquivalence (swap C D) :=\n  (by infer_instance : IsEquivalence (braiding C D).functor)\n#align category_theory.prod.swap_is_equivalence CategoryTheory.Prod.swapIsEquivalence\n\nend Prod\n\nsection\n\nvariable (C : Type u₁) [Category.{v₁} C] (D : Type u₂) [Category.{v₂} D]\n\n/-- The \"evaluation at `X`\" functor, such that\n`(evaluation.obj X).obj F = F.obj X`,\nwhich is functorial in both `X` and `F`.\n-/\n@[simps]\ndef evaluation : C ⥤ (C ⥤ D) ⥤ D\n    where\n  obj X :=\n    { obj := fun F => F.obj X\n      map := fun α => α.app X }\n  map {X} {Y} f :=\n    { app := fun F => F.map f\n      naturality := fun {F} {G} α => Eq.symm (α.naturality f) }\n#align category_theory.evaluation CategoryTheory.evaluation\n\n/-- The \"evaluation of `F` at `X`\" functor,\nas a functor `C × (C ⥤ D) ⥤ D`.\n-/\n@[simps]\ndef evaluationUncurried : C × (C ⥤ D) ⥤ D\n    where\n  obj p := p.2.obj p.1\n  map := fun {x} {y} f => x.2.map f.1 ≫ f.2.app y.1\n  map_comp := fun {X} {Y} {Z} f g => by\n    cases g; cases f; cases Z; cases Y; cases X\n    simp only [prod_comp, NatTrans.comp_app, Functor.map_comp, Category.assoc]\n    rw [← NatTrans.comp_app, NatTrans.naturality, NatTrans.comp_app, Category.assoc,\n      NatTrans.naturality]\n#align category_theory.evaluation_uncurried CategoryTheory.evaluationUncurried\n\nvariable {C}\n\n/-- The constant functor followed by the evalutation functor is just the identity. -/\n@[simps!]\ndef Functor.constCompEvaluationObj (X : C) : Functor.const C ⋙ (evaluation C D).obj X ≅ 𝟭 D :=\n  NatIso.ofComponents (fun Y => Iso.refl _) fun {Y} {Z} f => by simp\n#align category_theory.functor.const_comp_evaluation_obj CategoryTheory.Functor.constCompEvaluationObj\n\nend\n\nvariable {A : Type u₁} [Category.{v₁} A] {B : Type u₂} [Category.{v₂} B] {C : Type u₃}\n  [Category.{v₃} C] {D : Type u₄} [Category.{v₄} D]\n\nnamespace Functor\n\n/-- The cartesian product of two functors. -/\n@[simps]\ndef prod (F : A ⥤ B) (G : C ⥤ D) : A × C ⥤ B × D\n    where\n  obj X := (F.obj X.1, G.obj X.2)\n  map f := (F.map f.1, G.map f.2)\n#align category_theory.functor.prod CategoryTheory.Functor.prod\n\n/- Because of limitations in Lean 3's handling of notations, we do not setup a notation `F × G`.\n   You can use `F.prod G` as a \"poor man's infix\", or just write `functor.prod F G`. -/\n/-- Similar to `prod`, but both functors start from the same category `A` -/\n@[simps]\ndef prod' (F : A ⥤ B) (G : A ⥤ C) : A ⥤ B × C\n    where\n  obj a := (F.obj a, G.obj a)\n  map f := (F.map f, G.map f)\n#align category_theory.functor.prod' CategoryTheory.Functor.prod'\n\n/-- The product `F.prod' G` followed by projection on the first component is isomorphic to `F` -/\n@[simps!]\ndef prod'CompFst (F : A ⥤ B) (G : A ⥤ C) : F.prod' G ⋙ CategoryTheory.Prod.fst B C ≅ F :=\n  NatIso.ofComponents (fun X => Iso.refl _) fun f => by simp\n#align category_theory.functor.prod'_comp_fst CategoryTheory.Functor.prod'CompFst\n\n/-- The product `F.prod' G` followed by projection on the second component is isomorphic to `G` -/\n@[simps!]\ndef prod'CompSnd (F : A ⥤ B) (G : A ⥤ C) : F.prod' G ⋙ CategoryTheory.Prod.snd B C ≅ G :=\n  NatIso.ofComponents (fun X => Iso.refl _) fun f => by simp\n#align category_theory.functor.prod'_comp_snd CategoryTheory.Functor.prod'CompSnd\n\nsection\n\nvariable (C)\n\n/-- The diagonal functor. -/\ndef diag : C ⥤ C × C :=\n  (𝟭 C).prod' (𝟭 C)\n#align category_theory.functor.diag CategoryTheory.Functor.diag\n\n@[simp]\ntheorem diag_obj (X : C) : (diag C).obj X = (X, X) :=\n  rfl\n#align category_theory.functor.diag_obj CategoryTheory.Functor.diag_obj\n\n@[simp]\ntheorem diag_map {X Y : C} (f : X ⟶ Y) : (diag C).map f = (f, f) :=\n  rfl\n#align category_theory.functor.diag_map CategoryTheory.Functor.diag_map\n\nend\n\nend Functor\n\nnamespace NatTrans\n\n/-- The cartesian product of two natural transformations. -/\n@[simps]\ndef prod {F G : A ⥤ B} {H I : C ⥤ D} (α : F ⟶ G) (β : H ⟶ I) : F.prod H ⟶ G.prod I\n    where\n  app X := (α.app X.1, β.app X.2)\n  naturality {X} {Y} f := by\n    cases X; cases Y\n    simp only [Functor.prod_map, prod_comp]\n    rw [Prod.mk.inj_iff]\n    constructor\n    repeat {rw [naturality]}\n#align category_theory.nat_trans.prod CategoryTheory.NatTrans.prod\n\n/- Again, it is inadvisable in Lean 3 to setup a notation `α × β`;\n   use instead `α.prod β` or `NatTrans.prod α β`. -/\nend NatTrans\n\n/-- `F.flip` composed with evaluation is the same as evaluating `F`. -/\n@[simps!]\ndef flipCompEvaluation (F : A ⥤ B ⥤ C) (a) : F.flip ⋙ (evaluation _ _).obj a ≅ F.obj a :=\n  (NatIso.ofComponents fun b => eqToIso rfl) <| by aesop_cat\n#align category_theory.flip_comp_evaluation CategoryTheory.flipCompEvaluation\n\nvariable (A B C)\n\n/-- The forward direction for `functorProdFunctorEquiv` -/\n@[simps]\ndef prodFunctorToFunctorProd : (A ⥤ B) × (A ⥤ C) ⥤ A ⥤ B × C\n    where\n  obj F := F.1.prod' F.2\n  map f := { app := fun X => (f.1.app X, f.2.app X) }\n#align category_theory.prod_functor_to_functor_prod CategoryTheory.prodFunctorToFunctorProd\n\n/-- The backward direction for `functorProdFunctorEquiv` -/\n@[simps]\ndef functorProdToProdFunctor : (A ⥤ B × C) ⥤ (A ⥤ B) × (A ⥤ C)\n    where\n  obj F := ⟨F ⋙ CategoryTheory.Prod.fst B C, F ⋙ CategoryTheory.Prod.snd B C⟩\n  map α :=\n    ⟨{  app := fun X => (α.app X).1\n        naturality := fun X Y f => by\n          simp only [Functor.comp_map, Prod.fst_map, ← prod_comp_fst, α.naturality] },\n      { app := fun X => (α.app X).2\n        naturality := fun X Y f => by\n          simp only [Functor.comp_map, Prod.snd_map, ← prod_comp_snd, α.naturality] }⟩\n#align category_theory.functor_prod_to_prod_functor CategoryTheory.functorProdToProdFunctor\n\n/-- The unit isomorphism for `functorProdFunctorEquiv` -/\n@[simps!]\ndef functorProdFunctorEquivUnitIso :\n    𝟭 _ ≅ prodFunctorToFunctorProd A B C ⋙ functorProdToProdFunctor A B C :=\n  NatIso.ofComponents\n    (fun F =>\n      (((Functor.prod'CompFst F.fst F.snd).prod (Functor.prod'CompSnd F.fst F.snd)).trans\n        (prod.etaIso F)).symm)\n      (fun α => by aesop_cat)\n#align category_theory.functor_prod_functor_equiv_unit_iso CategoryTheory.functorProdFunctorEquivUnitIso\n\n/-- The counit isomorphism for `functorProdFunctorEquiv` -/\n@[simps!]\ndef functorProdFunctorEquivCounitIso :\n    functorProdToProdFunctor A B C ⋙ prodFunctorToFunctorProd A B C ≅ 𝟭 _ :=\n  NatIso.ofComponents (fun F => NatIso.ofComponents (fun X => prod.etaIso (F.obj X)) (by aesop_cat))\n    (by aesop_cat)\n#align category_theory.functor_prod_functor_equiv_counit_iso CategoryTheory.functorProdFunctorEquivCounitIso\n\n/- Porting note: unlike with Lean 3, we needed to provide `functor_unitIso_comp` because\nLean 4 could not see through `functorProdFunctorEquivUnitIso` (or the co-unit version)\nto run the auto tactic `by aesop_cat` -/\n\n/-- The equivalence of categories between `(A ⥤ B) × (A ⥤ C)` and `A ⥤ (B × C)` -/\n@[simps]\ndef functorProdFunctorEquiv : (A ⥤ B) × (A ⥤ C) ≌ A ⥤ B × C :=\n  { functor := prodFunctorToFunctorProd A B C,\n    inverse := functorProdToProdFunctor A B C,\n    unitIso := functorProdFunctorEquivUnitIso A B C,\n    counitIso := functorProdFunctorEquivCounitIso A B C,\n    functor_unitIso_comp := by\n      simp only [functorProdFunctorEquivUnitIso]\n      aesop_cat\n  }\n#align category_theory.functor_prod_functor_equiv CategoryTheory.functorProdFunctorEquiv\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Products/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4965194017483226}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Reid Barton\n-/\nimport category_theory.limits.shapes.images\nimport category_theory.filtered\nimport tactic.equiv_rw\n\nuniverses u\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory.limits.types\n\nvariables {J : Type u} [small_category J]\n\n/--\n(internal implementation) the limit cone of a functor,\nimplemented as flat sections of a pi type\n-/\ndef limit_cone (F : J ⥤ Type u) : cone F :=\n{ X := F.sections,\n  π := { app := λ j u, u.val j } }\n\nlocal attribute [elab_simple] congr_fun\n/-- (internal implementation) the fact that the proposed limit cone is the limit -/\ndef limit_cone_is_limit (F : J ⥤ Type u) : is_limit (limit_cone F) :=\n{ lift := λ s v, ⟨λ j, s.π.app j v, λ j j' f, congr_fun (cone.w s f) _⟩,\n  uniq' := by { intros, ext x j, exact congr_fun (w j) x } }\n\n/--\nThe category of types has all limits.\n\nSee https://stacks.math.columbia.edu/tag/002U.\n-/\ninstance : has_limits (Type u) :=\n{ has_limits_of_shape := λ J 𝒥, by exactI\n  { has_limit := λ F, has_limit.mk\n    { cone := limit_cone F, is_limit := limit_cone_is_limit F } } }\n\n/--\nThe equivalence between a limiting cone of `F` in `Type u` and the \"concrete\" definition as the\nsections of `F`.\n-/\ndef is_limit_equiv_sections {F : J ⥤ Type u} {c : cone F} (t : is_limit c) :\n  c.X ≃ F.sections :=\n(is_limit.cone_point_unique_up_to_iso t (limit_cone_is_limit F)).to_equiv\n\n@[simp]\nlemma is_limit_equiv_sections_apply\n  {F : J ⥤ Type u} {c : cone F} (t : is_limit c) (j : J) (x : c.X) :\n  (((is_limit_equiv_sections t) x) : Π j, F.obj j) j = c.π.app j x :=\nrfl\n\n@[simp]\nlemma is_limit_equiv_sections_symm_apply\n  {F : J ⥤ Type u} {c : cone F} (t : is_limit c) (x : F.sections) (j : J) :\n  c.π.app j ((is_limit_equiv_sections t).symm x) = (x : Π j, F.obj j) j :=\nbegin\n  equiv_rw (is_limit_equiv_sections t).symm at x,\n  simp,\nend\n\n/--\nThe equivalence between the abstract limit of `F` in `Type u`\nand the \"concrete\" definition as the sections of `F`.\n-/\nnoncomputable\ndef limit_equiv_sections (F : J ⥤ Type u) : (limit F : Type u) ≃ F.sections :=\nis_limit_equiv_sections (limit.is_limit _)\n\n@[simp]\nlemma limit_equiv_sections_apply (F : J ⥤ Type u) (x : limit F) (j : J) :\n  (((limit_equiv_sections F) x) : Π j, F.obj j) j = limit.π F j x :=\nrfl\n\n@[simp]\nlemma limit_equiv_sections_symm_apply (F : J ⥤ Type u) (x : F.sections) (j : J) :\n  limit.π F j ((limit_equiv_sections F).symm x) = (x : Π j, F.obj j) j :=\nis_limit_equiv_sections_symm_apply _ _ _\n\n/--\nConstruct a term of `limit F : Type u` from a family of terms `x : Π j, F.obj j`\nwhich are \"coherent\": `∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j'`.\n-/\n@[ext]\nnoncomputable\ndef limit.mk (F : J ⥤ Type u) (x : Π j, F.obj j) (h : ∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j') :\n  (limit F : Type u) :=\n(limit_equiv_sections F).symm ⟨x, h⟩\n\n@[simp]\nlemma limit.π_mk\n  (F : J ⥤ Type u) (x : Π j, F.obj j) (h : ∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j') (j) :\n  limit.π F j (limit.mk F x h) = x j :=\nby { dsimp [limit.mk], simp, }\n\n-- PROJECT: prove this for concrete categories where the forgetful functor preserves limits\n@[ext]\nlemma limit_ext (F : J ⥤ Type u) (x y : limit F) (w : ∀ j, limit.π F j x = limit.π F j y) :\n  x = y :=\nbegin\n  apply (limit_equiv_sections F).injective,\n  ext j,\n  simp [w j],\nend\n\nlemma limit_ext_iff (F : J ⥤ Type u) (x y : limit F) :\n  x = y ↔ (∀ j, limit.π F j x = limit.π F j y) :=\n⟨λ t _, t ▸ rfl, limit_ext _ _ _⟩\n\n-- TODO: are there other limits lemmas that should have `_apply` versions?\n-- Can we generate these like with `@[reassoc]`?\n-- PROJECT: prove these for any concrete category where the forgetful functor preserves limits?\n\n@[simp]\nlemma limit.w_apply {F : J ⥤ Type u} {j j' : J} {x : limit F} (f : j ⟶ j') :\n  F.map f (limit.π F j x) = limit.π F j' x :=\ncongr_fun (limit.w F f) x\n\n@[simp]\nlemma limit.lift_π_apply (F : J ⥤ Type u) (s : cone F) (j : J) (x : s.X) :\n  limit.π F j (limit.lift F s x) = s.π.app j x :=\ncongr_fun (limit.lift_π s j) x\n\n@[simp]\nlemma limit.map_π_apply {F G : J ⥤ Type u} (α : F ⟶ G) (j : J) (x) :\n  limit.π G j (lim_map α x) = α.app j (limit.π F j x) :=\ncongr_fun (lim_map_π α j) x\n\n/--\nThe relation defining the quotient type which implements the colimit of a functor `F : J ⥤ Type u`.\nSee `category_theory.limits.types.quot`.\n-/\ndef quot.rel (F : J ⥤ Type u) : (Σ j, F.obj j) → (Σ j, F.obj j) → Prop :=\n(λ p p', ∃ f : p.1 ⟶ p'.1, p'.2 = F.map f p.2)\n\n/--\nA quotient type implementing the colimit of a functor `F : J ⥤ Type u`,\nas pairs `⟨j, x⟩` where `x : F.obj j`, modulo the equivalence relation generated by\n`⟨j, x⟩ ~ ⟨j', x'⟩` whenever there is a morphism `f : j ⟶ j'` so `F.map f x = x'`.\n-/\n@[nolint has_inhabited_instance]\ndef quot (F : J ⥤ Type u) : Type u :=\n@quot (Σ j, F.obj j) (quot.rel F)\n\n/--\n(internal implementation) the colimit cocone of a functor,\nimplemented as a quotient of a sigma type\n-/\ndef colimit_cocone (F : J ⥤ Type u) : cocone F :=\n{ X := quot F,\n  ι :=\n  { app := λ j x, quot.mk _ ⟨j, x⟩,\n    naturality' := λ j j' f, funext $ λ x, eq.symm (quot.sound ⟨f, rfl⟩) } }\n\nlocal attribute [elab_with_expected_type] quot.lift\n\n/-- (internal implementation) the fact that the proposed colimit cocone is the colimit -/\ndef colimit_cocone_is_colimit (F : J ⥤ Type u) : is_colimit (colimit_cocone F) :=\n{ desc := λ s, quot.lift (λ (p : Σ j, F.obj j), s.ι.app p.1 p.2)\n    (assume ⟨j, x⟩ ⟨j', x'⟩ ⟨f, hf⟩, by rw hf; exact (congr_fun (cocone.w s f) x).symm) }\n\n/--\nThe category of types has all colimits.\n\nSee https://stacks.math.columbia.edu/tag/002U.\n-/\ninstance : has_colimits (Type u) :=\n{ has_colimits_of_shape := λ J 𝒥, by exactI\n  { has_colimit := λ F, has_colimit.mk\n    { cocone := colimit_cocone F, is_colimit := colimit_cocone_is_colimit F } } }\n\n/--\nThe equivalence between the abstract colimit of `F` in `Type u`\nand the \"concrete\" definition as a quotient.\n-/\nnoncomputable\ndef colimit_equiv_quot (F : J ⥤ Type u) : (colimit F : Type u) ≃ quot F :=\n(is_colimit.cocone_point_unique_up_to_iso\n  (colimit.is_colimit F)\n  (colimit_cocone_is_colimit F)).to_equiv\n\n@[simp]\nlemma colimit_equiv_quot_symm_apply (F : J ⥤ Type u) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F).symm (quot.mk _ ⟨j, x⟩) = colimit.ι F j x :=\nrfl\n\n@[simp]\nlemma colimit_equiv_quot_apply (F : J ⥤ Type u) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F) (colimit.ι F j x) = quot.mk _ ⟨j, x⟩ :=\nbegin\n  apply (colimit_equiv_quot F).symm.injective,\n  simp,\nend\n\n@[simp]\nlemma colimit.w_apply {F : J ⥤ Type u} {j j' : J} {x : F.obj j} (f : j ⟶ j') :\n  colimit.ι F j' (F.map f x) = colimit.ι F j x :=\ncongr_fun (colimit.w F f) x\n\n@[simp]\nlemma colimit.ι_desc_apply (F : J ⥤ Type u) (s : cocone F) (j : J) (x : F.obj j) :\n  colimit.desc F s (colimit.ι F j x) = s.ι.app j x :=\ncongr_fun (colimit.ι_desc s j) x\n\n@[simp]\nlemma colimit.ι_map_apply {F G : J ⥤ Type u} (α : F ⟶ G) (j : J) (x) :\n  colim.map α (colimit.ι F j x) = colimit.ι G j (α.app j x) :=\ncongr_fun (colimit.ι_map α j) x\n\nlemma colimit_sound\n  {F : J ⥤ Type u} {j j' : J} {x : F.obj j} {x' : F.obj j'} (f : j ⟶ j') (w : F.map f x = x') :\n  colimit.ι F j x = colimit.ι F j' x' :=\nbegin\n  rw [←w],\n  simp,\nend\n\nlemma colimit_sound'\n  {F : J ⥤ Type u} {j j' : J} {x : F.obj j} {x' : F.obj j'} {j'' : J} (f : j ⟶ j'') (f' : j' ⟶ j'')\n  (w : F.map f x = F.map f' x') :\n  colimit.ι F j x = colimit.ι F j' x' :=\nbegin\n  rw [←colimit.w _ f, ←colimit.w _ f'],\n  rw [types_comp_apply, types_comp_apply, w],\nend\n\nlemma colimit_eq {F : J ⥤ Type u } {j j' : J} {x : F.obj j} {x' : F.obj j'}\n  (w : colimit.ι F j x = colimit.ι F j' x') : eqv_gen (quot.rel F) ⟨j, x⟩ ⟨j', x'⟩ :=\nbegin\n  apply quot.eq.1,\n  simpa using congr_arg (colimit_equiv_quot F) w,\nend\n\nlemma jointly_surjective (F : J ⥤ Type u) {t : cocone F} (h : is_colimit t)\n  (x : t.X) : ∃ j y, t.ι.app j y = x :=\nbegin\n  suffices : (λ (x : t.X), ulift.up (∃ j y, t.ι.app j y = x)) = (λ _, ulift.up true),\n  { have := congr_fun this x,\n    have H := congr_arg ulift.down this,\n    dsimp at H,\n    rwa eq_true at H },\n  refine h.hom_ext _,\n  intro j, ext y,\n  erw iff_true,\n  exact ⟨j, y, rfl⟩\nend\n\n/-- A variant of `jointly_surjective` for `x : colimit F`. -/\nlemma jointly_surjective' {F : J ⥤ Type u}\n  (x : colimit F) : ∃ j y, colimit.ι F j y = x :=\njointly_surjective F (colimit.is_colimit _) x\n\nnamespace filtered_colimit\n/- For filtered colimits of types, we can give an explicit description\n  of the equivalence relation generated by the relation used to form\n  the colimit.  -/\n\nvariables (F : J ⥤ Type u)\n\n/--\nAn alternative relation on `Σ j, F.obj j`,\nwhich generates the same equivalence relation as we use to define the colimit in `Type` above,\nbut that is more convenient when working with filtered colimits.\n\nElements in `F.obj j` and `F.obj j'` are equivalent if there is some `k : J` to the right\nwhere their images are equal.\n-/\nprotected def r (x y : Σ j, F.obj j) : Prop :=\n∃ k (f : x.1 ⟶ k) (g : y.1 ⟶ k), F.map f x.2 = F.map g y.2\n\nprotected lemma r_ge (x y : Σ j, F.obj j) :\n  (∃ f : x.1 ⟶ y.1, y.2 = F.map f x.2) → filtered_colimit.r F x y :=\nλ ⟨f, hf⟩, ⟨y.1, f, 𝟙 y.1, by simp [hf]⟩\n\nvariables (t : cocone F)\nlocal attribute [elab_simple] nat_trans.app\n\n/-- Recognizing filtered colimits of types. -/\nnoncomputable def is_colimit_of (hsurj : ∀ (x : t.X), ∃ i xi, x = t.ι.app i xi)\n  (hinj : ∀ i j xi xj, t.ι.app i xi = t.ι.app j xj →\n   ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj) : is_colimit t :=\n-- Strategy: Prove that the map from \"the\" colimit of F (defined above) to t.X\n-- is a bijection.\nbegin\n  apply is_colimit.of_iso_colimit (colimit.is_colimit F),\n  refine cocones.ext (equiv.to_iso (equiv.of_bijective _ _)) _,\n  { exact colimit.desc F t },\n  { split,\n    { show function.injective _,\n      intros a b h,\n      rcases jointly_surjective F (colimit.is_colimit F) a with ⟨i, xi, rfl⟩,\n      rcases jointly_surjective F (colimit.is_colimit F) b with ⟨j, xj, rfl⟩,\n      change (colimit.ι F i ≫ colimit.desc F t) xi = (colimit.ι F j ≫ colimit.desc F t) xj at h,\n      rw [colimit.ι_desc, colimit.ι_desc] at h,\n      rcases hinj i j xi xj h with ⟨k, f, g, h'⟩,\n      change colimit.ι F i xi = colimit.ι F j xj,\n      rw [←colimit.w F f, ←colimit.w F g],\n      change colimit.ι F k (F.map f xi) = colimit.ι F k (F.map g xj),\n      rw h' },\n    { show function.surjective _,\n      intro x,\n      rcases hsurj x with ⟨i, xi, rfl⟩,\n      use colimit.ι F i xi,\n      simp } },\n  { intro j, apply colimit.ι_desc }\nend\n\nvariables [is_filtered_or_empty J]\n\nprotected lemma r_equiv : equivalence (filtered_colimit.r F) :=\n⟨λ x, ⟨x.1, 𝟙 x.1, 𝟙 x.1, rfl⟩,\n λ x y ⟨k, f, g, h⟩, ⟨k, g, f, h.symm⟩,\n λ x y z ⟨k, f, g, h⟩ ⟨k', f', g', h'⟩,\n   let ⟨l, fl, gl, _⟩ := is_filtered_or_empty.cocone_objs k k',\n       ⟨m, n, hn⟩ := is_filtered_or_empty.cocone_maps (g ≫ fl) (f' ≫ gl) in\n   ⟨m, f ≫ fl ≫ n, g' ≫ gl ≫ n, calc\n      F.map (f ≫ fl ≫ n) x.2\n          = F.map (fl ≫ n) (F.map f x.2)  : by simp\n      ... = F.map (fl ≫ n) (F.map g y.2)  : by rw h\n      ... = F.map ((g ≫ fl) ≫ n) y.2      : by simp\n      ... = F.map ((f' ≫ gl) ≫ n) y.2     : by rw hn\n      ... = F.map (gl ≫ n) (F.map f' y.2) : by simp\n      ... = F.map (gl ≫ n) (F.map g' z.2) : by rw h'\n      ... = F.map (g' ≫ gl ≫ n) z.2       : by simp⟩⟩\n\nprotected lemma r_eq :\n  filtered_colimit.r F = eqv_gen (λ x y, ∃ f : x.1 ⟶ y.1, y.2 = F.map f x.2) :=\nbegin\n  apply le_antisymm,\n  { rintros ⟨i, x⟩ ⟨j, y⟩ ⟨k, f, g, h⟩,\n    exact eqv_gen.trans _ ⟨k, F.map f x⟩ _ (eqv_gen.rel _ _ ⟨f, rfl⟩)\n      (eqv_gen.symm _ _ (eqv_gen.rel _ _ ⟨g, h⟩)) },\n  { intros x y,\n    convert relation.eqv_gen_mono (filtered_colimit.r_ge F),\n    apply propext,\n    symmetry,\n    exact relation.eqv_gen_iff_of_equivalence (filtered_colimit.r_equiv F) }\nend\n\nlemma colimit_eq_iff_aux {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  (colimit_cocone F).ι.app i xi = (colimit_cocone F).ι.app j xj ↔\n    ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj :=\nbegin\n  change quot.mk _ _ = quot.mk _ _ ↔ _,\n  rw [quot.eq, quot.rel, ←filtered_colimit.r_eq],\n  refl\nend\n\nvariables {t} (ht : is_colimit t)\nlemma is_colimit_eq_iff {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  t.ι.app i xi = t.ι.app j xj ↔ ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj :=\nlet t' := colimit_cocone F,\n    e : t' ≅ t := is_colimit.unique_up_to_iso (colimit_cocone_is_colimit F) ht,\n    e' : t'.X ≅ t.X := (cocones.forget _).map_iso e in\nbegin\n  refine iff.trans _ (colimit_eq_iff_aux F),\n  convert e'.to_equiv.apply_eq_iff_eq; rw ←e.hom.w; refl\nend\n\nlemma colimit_eq_iff {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  colimit.ι F i xi = colimit.ι F j xj ↔ ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj :=\nis_colimit_eq_iff _ (colimit.is_colimit F)\n\nend filtered_colimit\n\nvariables {α β : Type u} (f : α ⟶ β)\n\nsection -- implementation of `has_image`\n/-- the image of a morphism in Type is just `set.range f` -/\ndef image : Type u := set.range f\n\ninstance [inhabited α] : inhabited (image f) :=\n{ default := ⟨f (default α), ⟨_, rfl⟩⟩ }\n\n/-- the inclusion of `image f` into the target -/\ndef image.ι : image f ⟶ β := subtype.val\n\ninstance : mono (image.ι f) :=\n(mono_iff_injective _).2 subtype.val_injective\n\nvariables {f}\n\n/-- the universal property for the image factorisation -/\nnoncomputable def image.lift (F' : mono_factorisation f) : image f ⟶ F'.I :=\n(λ x, F'.e (classical.indefinite_description _ x.2).1 : image f → F'.I)\n\nlemma image.lift_fac (F' : mono_factorisation f) : image.lift F' ≫ F'.m = image.ι f :=\nbegin\n  ext x,\n  change (F'.e ≫ F'.m) _ = _,\n  rw [F'.fac, (classical.indefinite_description _ x.2).2],\n  refl,\nend\nend\n\n/-- the factorisation of any morphism in Type through a mono. -/\ndef mono_factorisation : mono_factorisation f :=\n{ I := image f,\n  m := image.ι f,\n  e := set.range_factorization f }\n\n/-- the facorisation through a mono has the universal property of the image. -/\nnoncomputable def is_image : is_image (mono_factorisation f) :=\n{ lift := image.lift,\n  lift_fac' := image.lift_fac }\n\ninstance : has_image f :=\nhas_image.mk ⟨_, is_image f⟩\n\ninstance : has_images (Type u) :=\n{ has_image := by apply_instance }\n\ninstance : has_image_maps (Type u) :=\n{ has_image_map := λ f g st, has_image_map.transport st (mono_factorisation f.hom) (is_image g.hom)\n    (λ x, ⟨st.right x.1, ⟨st.left (classical.some x.2),\n      begin\n        have p := st.w,\n        replace p := congr_fun p (classical.some x.2),\n        simp only [functor.id_map, types_comp_apply, subtype.val_eq_coe] at p,\n        erw [p, classical.some_spec x.2],\n      end⟩⟩) rfl }\n\nend category_theory.limits.types\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/types.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.49651940098063363}}
{"text": "inductive Vec (α : Type u) : Nat → Type u where\n  | nil  : Vec α 0\n  | cons : α → Vec α n → Vec α (n + 1)\n\ntheorem ex1 {a b c d x : Nat} (h : Vec.cons a (Vec.cons b Vec.nil) = Vec.cons x (Vec.cons 0 Vec.nil)) : a = x + b := by\n  simp_all\n\ntheorem ex2 {a b c d x : Nat} (h : [a, b] = [x, 0]) : a = x + b := by\n  simp_all\n\ntheorem ex3 {a b c d x : Nat} (h : Array.mk [a, b] = Array.mk [x, 0]) : a = x + b := by\n  simp_all\n\ntheorem ex4 {a b c d x : Nat} (h : (Array.mk [a, b], c)  = (Array.mk [x, 0], d)) : a + c = x + b + d := by\n  simp_all\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/injSimp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.49648877415689463}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad, Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.control.functor.multivariate\nimport Mathlib.data.pfunctor.univariate.default\nimport Mathlib.data.sigma.default\nimport Mathlib.PostPort\n\nuniverses u l u_1 \n\nnamespace Mathlib\n\n/-!\n# Multivariate polynomial functors.\n\nMultivariate polynomial functors are used for defining M-types and W-types.\nThey map a type vector `α` to the type `Σ a : A, B a ⟹ α`, with `A : Type` and\n`B : A → typevec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `α` are positive.\n-/\n\n/--\nmultivariate polynomial functors\n-/\nstructure mvpfunctor (n : ℕ) where\n  A : Type u\n  B : A → typevec n\n\nnamespace mvpfunctor\n\n\n/-- Applying `P` to an object of `Type` -/\ndef obj {n : ℕ} (P : mvpfunctor n) (α : typevec n) := sigma fun (a : A P) => typevec.arrow (B P a) α\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map {n : ℕ} (P : mvpfunctor n) {α : typevec n} {β : typevec n} (f : typevec.arrow α β) :\n    obj P α → obj P β :=\n  fun (_x : obj P α) => sorry\n\nprotected instance inhabited {n : ℕ} : Inhabited (mvpfunctor n) :=\n  { default := mk Inhabited.default fun (_x : Inhabited.default) => Inhabited.default }\n\nprotected instance obj.inhabited {n : ℕ} (P : mvpfunctor n) {α : typevec n} [Inhabited (A P)]\n    [(i : fin2 n) → Inhabited (α i)] : Inhabited (obj P α) :=\n  { default :=\n      sigma.mk Inhabited.default\n        fun (_x : fin2 n) (_x_1 : B P Inhabited.default _x) => Inhabited.default }\n\nprotected instance obj.mvfunctor {n : ℕ} (P : mvpfunctor n) : mvfunctor (obj P) :=\n  mvfunctor.mk (map P)\n\ntheorem map_eq {n : ℕ} (P : mvpfunctor n) {α : typevec n} {β : typevec n} (g : typevec.arrow α β)\n    (a : A P) (f : typevec.arrow (B P a) α) :\n    mvfunctor.map g (sigma.mk a f) = sigma.mk a (typevec.comp g f) :=\n  rfl\n\ntheorem id_map {n : ℕ} (P : mvpfunctor n) {α : typevec n} (x : obj P α) :\n    mvfunctor.map typevec.id x = x :=\n  sigma.cases_on x\n    fun (x_fst : A P) (x_snd : typevec.arrow (B P x_fst) α) =>\n      idRhs\n        (mvfunctor.map typevec.id (sigma.mk x_fst x_snd) =\n          mvfunctor.map typevec.id (sigma.mk x_fst x_snd))\n        rfl\n\ntheorem comp_map {n : ℕ} (P : mvpfunctor n) {α : typevec n} {β : typevec n} {γ : typevec n}\n    (f : typevec.arrow α β) (g : typevec.arrow β γ) (x : obj P α) :\n    mvfunctor.map (typevec.comp g f) x = mvfunctor.map g (mvfunctor.map f x) :=\n  sorry\n\nprotected instance obj.is_lawful_mvfunctor {n : ℕ} (P : mvpfunctor n) :\n    is_lawful_mvfunctor (obj P) :=\n  is_lawful_mvfunctor.mk (id_map P) (comp_map P)\n\n/-- Constant functor where the input object does not affect the output -/\ndef const (n : ℕ) (A : Type u) : mvpfunctor n := mk A fun (a : A) (i : fin2 n) => pempty\n\n/-- Constructor for the constant functor -/\ndef const.mk (n : ℕ) {A : Type u} (x : A) {α : typevec n} : obj (const n A) α :=\n  sigma.mk x fun (i : fin2 n) (a : B (const n A) x i) => pempty.elim a\n\n/-- Destructor for the constant functor -/\ndef const.get {n : ℕ} {A : Type u} {α : typevec n} (x : obj (const n A) α) : A := sigma.fst x\n\n@[simp] theorem const.get_map {n : ℕ} {A : Type u} {α : typevec n} {β : typevec n}\n    (f : typevec.arrow α β) (x : obj (const n A) α) : const.get (mvfunctor.map f x) = const.get x :=\n  sigma.cases_on x\n    fun (x_fst : A (const n A)) (x_snd : typevec.arrow (B (const n A) x_fst) α) =>\n      Eq.refl (const.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem const.get_mk {n : ℕ} {A : Type u} {α : typevec n} (x : A) :\n    const.get (const.mk n x) = x :=\n  Eq.refl (const.get (const.mk n x))\n\n@[simp] theorem const.mk_get {n : ℕ} {A : Type u} {α : typevec n} (x : obj (const n A) α) :\n    const.mk n (const.get x) = x :=\n  sorry\n\n/-- Functor composition on polynomial functors -/\ndef comp {n : ℕ} {m : ℕ} (P : mvpfunctor n) (Q : fin2 n → mvpfunctor m) : mvpfunctor m :=\n  mk (sigma fun (a₂ : A P) => (i : fin2 n) → B P a₂ i → A (Q i))\n    fun (a : sigma fun (a₂ : A P) => (i : fin2 n) → B P a₂ i → A (Q i)) (i : fin2 m) =>\n      sigma fun (j : fin2 n) => sigma fun (b : B P (sigma.fst a) j) => B (Q j) (sigma.snd a j b) i\n\n/-- Constructor for functor composition -/\ndef comp.mk {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m}\n    (x : obj P fun (i : fin2 n) => obj (Q i) α) : obj (comp P Q) α :=\n  sigma.mk\n    (sigma.mk (sigma.fst x)\n      fun (i : fin2 n) (a : B P (sigma.fst x) i) => sigma.fst (sigma.snd x i a))\n    fun (i : fin2 m)\n      (a :\n      B (comp P Q)\n        (sigma.mk (sigma.fst x)\n          fun (i : fin2 n) (a : B P (sigma.fst x) i) => sigma.fst (sigma.snd x i a))\n        i) =>\n      sigma.snd (sigma.snd x (sigma.fst a) (sigma.fst (sigma.snd a))) i (sigma.snd (sigma.snd a))\n\n/-- Destructor for functor composition -/\ndef comp.get {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m}\n    (x : obj (comp P Q) α) : obj P fun (i : fin2 n) => obj (Q i) α :=\n  sigma.mk (sigma.fst (sigma.fst x))\n    fun (i : fin2 n) (a : B P (sigma.fst (sigma.fst x)) i) =>\n      sigma.mk (sigma.snd (sigma.fst x) i a)\n        fun (j : fin2 m) (b : B (Q i) (sigma.snd (sigma.fst x) i a) j) =>\n          sigma.snd x j (sigma.mk i (sigma.mk a b))\n\ntheorem comp.get_map {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m}\n    {β : typevec m} (f : typevec.arrow α β) (x : obj (comp P Q) α) :\n    comp.get (mvfunctor.map f x) =\n        mvfunctor.map (fun (i : fin2 n) (x : obj (Q i) α) => mvfunctor.map f x) (comp.get x) :=\n  sigma.cases_on x\n    fun (x_fst : A (comp P Q)) (x_snd : typevec.arrow (B (comp P Q) x_fst) α) =>\n      Eq.refl (comp.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem comp.get_mk {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m}\n    {α : typevec m} (x : obj P fun (i : fin2 n) => obj (Q i) α) : comp.get (comp.mk x) = x :=\n  sorry\n\n@[simp] theorem comp.mk_get {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m}\n    {α : typevec m} (x : obj (comp P Q) α) : comp.mk (comp.get x) = x :=\n  sorry\n\n/-\nlifting predicates and relations\n-/\n\ntheorem liftp_iff {n : ℕ} {P : mvpfunctor n} {α : typevec n} (p : {i : fin2 n} → α i → Prop)\n    (x : obj P α) :\n    mvfunctor.liftp p x ↔\n        ∃ (a : A P),\n          ∃ (f : typevec.arrow (B P a) α),\n            x = sigma.mk a f ∧ ∀ (i : fin2 n) (j : B P a i), p (f i j) :=\n  sorry\n\ntheorem liftp_iff' {n : ℕ} {P : mvpfunctor n} {α : typevec n} (p : {i : fin2 n} → α i → Prop)\n    (a : A P) (f : typevec.arrow (B P a) α) :\n    mvfunctor.liftp p (sigma.mk a f) ↔ ∀ (i : fin2 n) (x : B P a i), p (f i x) :=\n  sorry\n\ntheorem liftr_iff {n : ℕ} {P : mvpfunctor n} {α : typevec n} (r : {i : fin2 n} → α i → α i → Prop)\n    (x : obj P α) (y : obj P α) :\n    mvfunctor.liftr r x y ↔\n        ∃ (a : A P),\n          ∃ (f₀ : typevec.arrow (B P a) α),\n            ∃ (f₁ : typevec.arrow (B P a) α),\n              x = sigma.mk a f₀ ∧\n                y = sigma.mk a f₁ ∧ ∀ (i : fin2 n) (j : B P a i), r (f₀ i j) (f₁ i j) :=\n  sorry\n\ntheorem supp_eq {n : ℕ} {P : mvpfunctor n} {α : typevec n} (a : A P) (f : typevec.arrow (B P a) α)\n    (i : fin2 n) : mvfunctor.supp (sigma.mk a f) i = f i '' set.univ :=\n  sorry\n\nend mvpfunctor\n\n\n/-\nDecomposing an n+1-ary pfunctor.\n-/\n\nnamespace mvpfunctor\n\n\n/-- Split polynomial functor, get a n-ary functor\nfrom a `n+1`-ary functor -/\ndef drop {n : ℕ} (P : mvpfunctor (n + 1)) : mvpfunctor n :=\n  mk (A P) fun (a : A P) => typevec.drop (B P a)\n\n/-- Split polynomial functor, get a univariate functor\nfrom a `n+1`-ary functor -/\ndef last {n : ℕ} (P : mvpfunctor (n + 1)) : pfunctor :=\n  pfunctor.mk (A P) fun (a : A P) => typevec.last (B P a)\n\n/-- append arrows of a polynomial functor application -/\ndef append_contents {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {β : Type u_1} {a : A P}\n    (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → β) :\n    typevec.arrow (B P a) (α ::: β) :=\n  typevec.split_fun f' f\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/pfunctor/multivariate/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.49648876920613605}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson\n\n! This file was ported from Lean 3 source module analysis.special_functions.complex.log_deriv\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.SpecialFunctions.Complex.Log\nimport Mathbin.Analysis.SpecialFunctions.ExpDeriv\n\n/-!\n# Differentiability of the complex `log` function\n\n-/\n\n\nnoncomputable section\n\nnamespace Complex\n\nopen Set Filter\n\nopen Real Topology\n\n/-- `complex.exp` as a `local_homeomorph` with `source = {z | -π < im z < π}` and\n`target = {z | 0 < re z} ∪ {z | im z ≠ 0}`. This definition is used to prove that `complex.log`\nis complex differentiable at all points but the negative real semi-axis. -/\ndef expLocalHomeomorph : LocalHomeomorph ℂ ℂ :=\n  LocalHomeomorph.ofContinuousOpen\n    { toFun := exp\n      invFun := log\n      source := { z : ℂ | z.im ∈ Ioo (-π) π }\n      target := { z : ℂ | 0 < z.re } ∪ { z : ℂ | z.im ≠ 0 }\n      map_source' := by\n        rintro ⟨x, y⟩ ⟨h₁ : -π < y, h₂ : y < π⟩\n        refine' (not_or_of_imp fun hz => _).symm\n        obtain rfl : y = 0 := by\n          rw [exp_im] at hz\n          simpa [(Real.exp_pos _).ne', Real.sin_eq_zero_iff_of_lt_of_lt h₁ h₂] using hz\n        rw [mem_set_of_eq, ← of_real_def, exp_of_real_re]\n        exact Real.exp_pos x\n      map_target' := fun z h =>\n        suffices 0 ≤ z.re ∨ z.im ≠ 0 by\n          simpa [log_im, neg_pi_lt_arg, (arg_le_pi _).lt_iff_ne, arg_eq_pi_iff, not_and_or]\n        h.imp (fun h => le_of_lt h) id\n      left_inv' := fun x hx => log_exp hx.1 (le_of_lt hx.2)\n      right_inv' := fun x hx =>\n        exp_log <| by\n          rintro rfl\n          simpa [lt_irrefl] using hx }\n    continuous_exp.ContinuousOn isOpenMap_exp (isOpen_Ioo.Preimage continuous_im)\n#align complex.exp_local_homeomorph Complex.expLocalHomeomorph\n\ntheorem hasStrictDerivAt_log {x : ℂ} (h : 0 < x.re ∨ x.im ≠ 0) : HasStrictDerivAt log x⁻¹ x :=\n  have h0 : x ≠ 0 := by\n    rintro rfl\n    simpa [lt_irrefl] using h\n  expLocalHomeomorph.hasStrictDerivAt_symm h h0 <| by\n    simpa [exp_log h0] using has_strict_deriv_at_exp (log x)\n#align complex.has_strict_deriv_at_log Complex.hasStrictDerivAt_log\n\ntheorem hasStrictFderivAt_log_real {x : ℂ} (h : 0 < x.re ∨ x.im ≠ 0) :\n    HasStrictFderivAt log (x⁻¹ • (1 : ℂ →L[ℝ] ℂ)) x :=\n  (hasStrictDerivAt_log h).complexToReal_fderiv\n#align complex.has_strict_fderiv_at_log_real Complex.hasStrictFderivAt_log_real\n\ntheorem contDiffAt_log {x : ℂ} (h : 0 < x.re ∨ x.im ≠ 0) {n : ℕ∞} : ContDiffAt ℂ n log x :=\n  expLocalHomeomorph.contDiffAt_symm_deriv (exp_ne_zero <| log x) h (hasDerivAt_exp _)\n    contDiff_exp.ContDiffAt\n#align complex.cont_diff_at_log Complex.contDiffAt_log\n\nend Complex\n\nsection LogDeriv\n\nopen Complex Filter\n\nopen Topology\n\nvariable {α : Type _} [TopologicalSpace α] {E : Type _} [NormedAddCommGroup E] [NormedSpace ℂ E]\n\ntheorem HasStrictFderivAt.clog {f : E → ℂ} {f' : E →L[ℂ] ℂ} {x : E} (h₁ : HasStrictFderivAt f f' x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : HasStrictFderivAt (fun t => log (f t)) ((f x)⁻¹ • f') x :=\n  (hasStrictDerivAt_log h₂).comp_hasStrictFderivAt x h₁\n#align has_strict_fderiv_at.clog HasStrictFderivAt.clog\n\ntheorem HasStrictDerivAt.clog {f : ℂ → ℂ} {f' x : ℂ} (h₁ : HasStrictDerivAt f f' x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x :=\n  by\n  rw [div_eq_inv_mul]\n  exact (has_strict_deriv_at_log h₂).comp x h₁\n#align has_strict_deriv_at.clog HasStrictDerivAt.clog\n\ntheorem HasStrictDerivAt.clog_real {f : ℝ → ℂ} {x : ℝ} {f' : ℂ} (h₁ : HasStrictDerivAt f f' x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x := by\n  simpa only [div_eq_inv_mul] using (has_strict_fderiv_at_log_real h₂).comp_hasStrictDerivAt x h₁\n#align has_strict_deriv_at.clog_real HasStrictDerivAt.clog_real\n\ntheorem HasFderivAt.clog {f : E → ℂ} {f' : E →L[ℂ] ℂ} {x : E} (h₁ : HasFderivAt f f' x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : HasFderivAt (fun t => log (f t)) ((f x)⁻¹ • f') x :=\n  (hasStrictDerivAt_log h₂).HasDerivAt.comp_hasFderivAt x h₁\n#align has_fderiv_at.clog HasFderivAt.clog\n\ntheorem HasDerivAt.clog {f : ℂ → ℂ} {f' x : ℂ} (h₁ : HasDerivAt f f' x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : HasDerivAt (fun t => log (f t)) (f' / f x) x :=\n  by\n  rw [div_eq_inv_mul]\n  exact (has_strict_deriv_at_log h₂).HasDerivAt.comp x h₁\n#align has_deriv_at.clog HasDerivAt.clog\n\ntheorem HasDerivAt.clog_real {f : ℝ → ℂ} {x : ℝ} {f' : ℂ} (h₁ : HasDerivAt f f' x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : HasDerivAt (fun t => log (f t)) (f' / f x) x := by\n  simpa only [div_eq_inv_mul] using\n    (has_strict_fderiv_at_log_real h₂).HasFderivAt.comp_hasDerivAt x h₁\n#align has_deriv_at.clog_real HasDerivAt.clog_real\n\ntheorem DifferentiableAt.clog {f : E → ℂ} {x : E} (h₁ : DifferentiableAt ℂ f x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : DifferentiableAt ℂ (fun t => log (f t)) x :=\n  (h₁.HasFderivAt.clog h₂).DifferentiableAt\n#align differentiable_at.clog DifferentiableAt.clog\n\ntheorem HasFderivWithinAt.clog {f : E → ℂ} {f' : E →L[ℂ] ℂ} {s : Set E} {x : E}\n    (h₁ : HasFderivWithinAt f f' s x) (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) :\n    HasFderivWithinAt (fun t => log (f t)) ((f x)⁻¹ • f') s x :=\n  (hasStrictDerivAt_log h₂).HasDerivAt.comp_hasFderivWithinAt x h₁\n#align has_fderiv_within_at.clog HasFderivWithinAt.clog\n\ntheorem HasDerivWithinAt.clog {f : ℂ → ℂ} {f' x : ℂ} {s : Set ℂ} (h₁ : HasDerivWithinAt f f' s x)\n    (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) : HasDerivWithinAt (fun t => log (f t)) (f' / f x) s x :=\n  by\n  rw [div_eq_inv_mul]\n  exact (has_strict_deriv_at_log h₂).HasDerivAt.comp_hasDerivWithinAt x h₁\n#align has_deriv_within_at.clog HasDerivWithinAt.clog\n\ntheorem HasDerivWithinAt.clog_real {f : ℝ → ℂ} {s : Set ℝ} {x : ℝ} {f' : ℂ}\n    (h₁ : HasDerivWithinAt f f' s x) (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) :\n    HasDerivWithinAt (fun t => log (f t)) (f' / f x) s x := by\n  simpa only [div_eq_inv_mul] using\n    (has_strict_fderiv_at_log_real h₂).HasFderivAt.comp_hasDerivWithinAt x h₁\n#align has_deriv_within_at.clog_real HasDerivWithinAt.clog_real\n\ntheorem DifferentiableWithinAt.clog {f : E → ℂ} {s : Set E} {x : E}\n    (h₁ : DifferentiableWithinAt ℂ f s x) (h₂ : 0 < (f x).re ∨ (f x).im ≠ 0) :\n    DifferentiableWithinAt ℂ (fun t => log (f t)) s x :=\n  (h₁.HasFderivWithinAt.clog h₂).DifferentiableWithinAt\n#align differentiable_within_at.clog DifferentiableWithinAt.clog\n\ntheorem DifferentiableOn.clog {f : E → ℂ} {s : Set E} (h₁ : DifferentiableOn ℂ f s)\n    (h₂ : ∀ x ∈ s, 0 < (f x).re ∨ (f x).im ≠ 0) : DifferentiableOn ℂ (fun t => log (f t)) s :=\n  fun x hx => (h₁ x hx).clog (h₂ x hx)\n#align differentiable_on.clog DifferentiableOn.clog\n\ntheorem Differentiable.clog {f : E → ℂ} (h₁ : Differentiable ℂ f)\n    (h₂ : ∀ x, 0 < (f x).re ∨ (f x).im ≠ 0) : Differentiable ℂ fun t => log (f t) := fun x =>\n  (h₁ x).clog (h₂ x)\n#align differentiable.clog Differentiable.clog\n\nend LogDeriv\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Analysis/SpecialFunctions/Complex/LogDeriv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.49648876425537725}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Scott Morrison, Mario Carneiro\n\n! This file was ported from Lean 3 source module topology.category.Top.basic\n! leanprover-community/mathlib commit bcfa726826abd57587355b4b5b7e78ad6527b7e4\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.ConcreteCategory.BundledHom\nimport Mathbin.CategoryTheory.Elementwise\nimport Mathbin.Topology.ContinuousFunction.Basic\n\n/-!\n# Category instance for topological spaces\n\nWe introduce the bundled category `Top` of topological spaces together with the functors `discrete`\nand `trivial` from the category of types to `Top` which equip a type with the corresponding\ndiscrete, resp. trivial, topology. For a proof that these functors are left, resp. right adjoint\nto the forgetful functor, see `topology.category.Top.adjunctions`.\n-/\n\n\nopen CategoryTheory\n\nopen TopologicalSpace\n\nuniverse u\n\n/-- The category of topological spaces and continuous maps. -/\ndef TopCat : Type (u + 1) :=\n  Bundled TopologicalSpace\n#align Top TopCat\n\nnamespace TopCat\n\ninstance bundledHom : BundledHom @ContinuousMap :=\n  ⟨@ContinuousMap.toFun, @ContinuousMap.id, @ContinuousMap.comp, @ContinuousMap.coe_injective⟩\n#align Top.bundled_hom TopCat.bundledHom\n\nderiving instance LargeCategory, ConcreteCategory for TopCat\n\ninstance : CoeSort TopCat (Type _) :=\n  Bundled.hasCoeToSort\n\ninstance topologicalSpaceUnbundled (x : TopCat) : TopologicalSpace x :=\n  x.str\n#align Top.topological_space_unbundled TopCat.topologicalSpaceUnbundled\n\n@[simp]\ntheorem id_app (X : TopCat.{u}) (x : X) : (𝟙 X : X → X) x = x :=\n  rfl\n#align Top.id_app TopCat.id_app\n\n@[simp]\ntheorem comp_app {X Y Z : TopCat.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :\n    (f ≫ g : X → Z) x = g (f x) :=\n  rfl\n#align Top.comp_app TopCat.comp_app\n\n/-- Construct a bundled `Top` from the underlying type and the typeclass. -/\ndef of (X : Type u) [TopologicalSpace X] : TopCat :=\n  ⟨X⟩\n#align Top.of TopCat.of\n\ninstance (X : TopCat) : TopologicalSpace X :=\n  X.str\n\n@[simp]\ntheorem coe_of (X : Type u) [TopologicalSpace X] : (of X : Type u) = X :=\n  rfl\n#align Top.coe_of TopCat.coe_of\n\ninstance : Inhabited TopCat :=\n  ⟨TopCat.of Empty⟩\n\n/-- The discrete topology on any type. -/\ndef discrete : Type u ⥤ TopCat.{u} where\n  obj X := ⟨X, ⊥⟩\n  map X Y f :=\n    { toFun := f\n      continuous_toFun := continuous_bot }\n#align Top.discrete TopCat.discrete\n\ninstance {X : Type u} : DiscreteTopology (discrete.obj X) :=\n  ⟨rfl⟩\n\n/-- The trivial topology on any type. -/\ndef trivial : Type u ⥤ TopCat.{u} where\n  obj X := ⟨X, ⊤⟩\n  map X Y f :=\n    { toFun := f\n      continuous_toFun := continuous_top }\n#align Top.trivial TopCat.trivial\n\n/-- Any homeomorphisms induces an isomorphism in `Top`. -/\n@[simps]\ndef isoOfHomeo {X Y : TopCat.{u}} (f : X ≃ₜ Y) : X ≅ Y\n    where\n  Hom := ⟨f⟩\n  inv := ⟨f.symm⟩\n#align Top.iso_of_homeo TopCat.isoOfHomeo\n\n/-- Any isomorphism in `Top` induces a homeomorphism. -/\n@[simps]\ndef homeoOfIso {X Y : TopCat.{u}} (f : X ≅ Y) : X ≃ₜ Y\n    where\n  toFun := f.Hom\n  invFun := f.inv\n  left_inv x := by simp\n  right_inv x := by simp\n  continuous_toFun := f.Hom.Continuous\n  continuous_invFun := f.inv.Continuous\n#align Top.homeo_of_iso TopCat.homeoOfIso\n\n@[simp]\ntheorem of_isoOfHomeo {X Y : TopCat.{u}} (f : X ≃ₜ Y) : homeoOfIso (isoOfHomeo f) = f :=\n  by\n  ext\n  rfl\n#align Top.of_iso_of_homeo TopCat.of_isoOfHomeo\n\n@[simp]\ntheorem of_homeoOfIso {X Y : TopCat.{u}} (f : X ≅ Y) : isoOfHomeo (homeoOfIso f) = f :=\n  by\n  ext\n  rfl\n#align Top.of_homeo_of_iso TopCat.of_homeoOfIso\n\n@[simp]\ntheorem openEmbedding_iff_comp_isIso {X Y Z : TopCat} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] :\n    OpenEmbedding (f ≫ g) ↔ OpenEmbedding f :=\n  (TopCat.homeoOfIso (asIso g)).OpenEmbedding.of_comp_iff f\n#align Top.open_embedding_iff_comp_is_iso TopCat.openEmbedding_iff_comp_isIso\n\n@[simp]\ntheorem openEmbedding_iff_isIso_comp {X Y Z : TopCat} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] :\n    OpenEmbedding (f ≫ g) ↔ OpenEmbedding g :=\n  by\n  constructor\n  · intro h\n    convert h.comp (TopCat.homeoOfIso (as_iso f).symm).OpenEmbedding\n    exact congr_arg _ (is_iso.inv_hom_id_assoc f g).symm\n  · exact fun h => h.comp (TopCat.homeoOfIso (as_iso f)).OpenEmbedding\n#align Top.open_embedding_iff_is_iso_comp TopCat.openEmbedding_iff_isIso_comp\n\nend TopCat\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Category/Top/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105587468141, "lm_q2_score": 0.7461389873857265, "lm_q1q2_score": 0.49648876049911833}}
{"text": "import .rules\n\nopen psum nnf node\n\nset_option eqn_compiler.zeta true\n\ndef tableau : Π Γ : seqt, node Γ\n| Γ := \nmatch get_contra_seqt Γ with \n| inl w := contra_rule_seqt w.2\n| inr no_contra := \n  match get_and_seqt Γ with\n  | inl p := \n  let Δ := p.1.1 :: p.1.2 :: Γ.main.erase (and p.val.1 p.val.2) in \n  let inst := and_instance_seqt.cons p.2 in\n  have h : prod.measure_lex seqt_size ⟨_,_,_,_⟩ Γ, \n  begin apply split_lt_and_seqt, exact p.2 end,\n  let d_delta : node ⟨Δ, Γ.hdld,_,_⟩ := tableau (and_child Γ p.2) in \n  and_rule_seqt inst d_delta\n  | inr no_and := \n    match get_or_seqt Γ with\n    | inl p := \n    let Γ₁ := p.1.1 :: Γ.main.erase (nnf.or p.val.1 p.val.2) in \n    let Γ₂ := p.1.2 :: Γ.main.erase (nnf.or p.val.1 p.val.2) in \n    let inst := or_instance_seqt.cons p.2 in\n    have h₁ : prod.measure_lex seqt_size ⟨Γ₁, Γ.hdld,_,_⟩ Γ, \n    begin apply split_lt_or_seqt_left, exact p.2 end,\n    have h₂ : prod.measure_lex seqt_size ⟨Γ₂, Γ.hdld,_,_⟩ Γ, \n    begin apply split_lt_or_seqt_right, exact p.2 end,\n    let d_Γ₁ : node ⟨Γ₁, Γ.hdld,_,_⟩ := tableau (or_child_left Γ p.2) in \n    match d_Γ₁ with\n    | closed pr := or_rule_seqt inst (closed pr) (tableau (or_child_right Γ p.2))\n    | open_ w := open_rule_seqt inst w.2\n    end\n    | inr no_or := \n      match get_box_seqt Γ with\n      | inl p := \n      let Γ₁ := p.1 :: Γ.main.erase (nnf.box p.1) in\n      let inst := copy_instance_seqt.cons p.2 in\n      have h : prod.measure_lex seqt_size ⟨Γ₁, box p.1 :: Γ.hdld,_,_⟩ Γ, \n      begin apply copy_lt_seqt, exact p.2 end,\n      let d_delta : node ⟨Γ₁, box p.1 :: Γ.hdld,_,_⟩ := tableau (box_child Γ p.2) in\n      copy_rule_seqt inst d_delta\n      | inr no_box := \n        match get_dia_seqt Γ with\n        | inl p := \n        let ma : modal_applicable Γ := \n            {satu := {no_and := no_and, no_or := no_or},\n             no_contra_main := no_contra, \n             no_box_main := no_box,\n             v := get_var Γ.main,\n             hv := λ n, get_var_iff,\n             φ := p.1,\n             ex := p.2} in \n        let l := @dia_rule_seqt (λ Δ, prod.measure_lex seqt_size Δ Γ) \n                 (λ x h, tableau x) (unmodal_seqt Γ) \n                 (unmodal_seqt_size Γ) in\n        match l with\n        | inl w := \n          begin left, {exact unsat_of_unsat_unmodal ma w.1 w.2} end\n        | inr w := \n          begin right, split, apply sat_of_batch_sat, exact ma, exact w.2 end\n        end\n        | inr no_dia := \n        let mc : model_constructible Γ := \n          {satu := {no_and := no_and, no_or := no_or},\n           no_box_main := no_box,\n           no_contra_main := no_contra, \n           v := get_var Γ.main,\n           hv := λ n, get_var_iff,\n           no_dia := no_dia} in \n        begin right, split, apply build_model_seqt, exact mc end\n        end\n      end\n    end\n  end\nend\nusing_well_founded {rel_tac := λ _ _, `[exact ⟨_, prod.measure_lex_wf seqt_size⟩], dec_tac := `[assumption]}\n\n@[simp] def mk_seqt (Γ : list nnf) : seqt :=\n{ main := Γ,\n  hdld := [],\n  pmain := begin \n             intros v l φ h hb hall, exfalso, \n             apply list.not_mem_nil, exact hb \n           end,\n  phdld := box_only_nil }\n\ndef is_sat (Γ : list nnf) : bool :=\nmatch tableau (mk_seqt Γ) with\n| closed _ := ff\n| open_ _  := tt\nend\n\ntheorem correctness (Γ : list nnf) : is_sat Γ = tt ↔ ∃ (st : Type) (k : KT st) s, sat k s Γ := \nbegin\n  cases h : is_sat Γ,\n  constructor,\n  {intro, contradiction},\n  {intro hsat, cases eq : tableau (mk_seqt Γ), \n   rcases hsat with ⟨w, k, s, hsat⟩,\n   apply false.elim, apply a, simp, exact hsat,\n   {dsimp [is_sat] at h, dsimp at eq, rw eq at h, contradiction} },\n  {split, intro, dsimp [is_sat] at h, \n    cases eq : tableau (mk_seqt Γ),\n    { dsimp at eq, rw eq at h, contradiction },\n  { split, split, split, have := a_1.2, simp at this, exact this},\n  { simp } }\nend\n\ndef test  := [box (var 1), (neg 1)]\n\n#eval is_sat test\n", "meta": {"author": "minchaowu", "repo": "ModalTab", "sha": "9bb0bf17faf0554d907ef7bdd639648742889178", "save_path": "github-repos/lean/minchaowu-ModalTab", "path": "github-repos/lean/minchaowu-ModalTab/ModalTab-9bb0bf17faf0554d907ef7bdd639648742889178/src/KT/vanilla.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199795472731, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4964293853318798}}
{"text": "inductive fml\n| atom (i : ℕ)\n| imp (a b : fml)\n| not (a : fml)\nopen fml\n\ninfixr ` →' `:50 := imp\nlocal notation ` ¬' ` := fml.not\n\ninductive prf : fml → Type\n| axk (p q) : prf (p →' q →' p)\n| axs (p q r) : prf $ (p →' q →' r) →' (p →' q) →' (p →' r)\n| axn (p q) : prf $ (¬'q →' ¬'p) →' p →' q\n| amp (p q) : prf (p →' (p →' q) →' q) -- internal modus ponnens, i couldn't prove it, can you?\n| cn (p q r) : prf (q →' r) → prf (p →' q) → prf (p →' r)\n| mp (p q) : prf p → prf (p →' q) → prf q\n\ntheorem reflex (P : fml) : prf (P →' P) :=\n    begin\n        have R : fml, exact P,\n        let Q : fml := R →' P,\n        have HPQ : prf (P →' Q),\n            change prf (P →' (R →' P)),\n            apply prf.axk,\n        have HPQP : prf (P →' (Q →' P)),\n            apply prf.axk,\n        have HPQPP : prf ((P →' Q) →' (P →' P)),\n            apply prf.mp (P →' Q →' P),\n            exact HPQP,\n            apply prf.axs,\n        apply prf.mp (P →' Q),\n        exact HPQ,\n        exact HPQPP,\n    end\n\nlemma deduct (P Q : fml) : prf ((P →' Q) →' P →' Q) :=\n    begin\n        apply reflex,\n    end\n\nlemma deduction (P Q : fml) : prf ((P →' (P →' Q)) →' (P →' Q)) :=\n    begin\n        apply prf.mp (P →' ((P →' Q) →' Q)),\n        apply prf.amp,\n        apply prf.axs,\n    end\n\nlemma yesyes (Q : fml) : prf (¬'(¬'Q) →' Q) :=\n    begin\n        have H4213 : prf ((¬'(¬'(¬'(¬'Q))) →' ¬'(¬'Q)) →' (¬'Q →' ¬'(¬'(¬'Q)))),\n            apply prf.axn,\n        have H1320 : prf ((¬'Q →' ¬'(¬'(¬'Q))) →' (¬'(¬'Q) →' Q)),\n            apply prf.axn,\n        have H4220 : prf ((¬'(¬'(¬'(¬'Q))) →' ¬'(¬'Q)) →' (¬'(¬'Q) →' Q)),\n            apply prf.cn (¬'(¬'(¬'(¬'Q))) →' ¬'(¬'Q)) ((¬'Q →' ¬'(¬'(¬'Q)))) (¬'(¬'Q) →' Q),\n            exact H1320, exact H4213,\n        have H242 : prf (¬'(¬'Q) →' ((¬'(¬'(¬'(¬'Q)))) →'(¬'(¬'Q)))),\n            apply prf.axk,\n        have H2020 : prf ((¬' (¬' Q) →' Q) →' (¬' (¬' Q) →' Q)),\n            apply reflex,\n        have H220 : prf (¬' (¬' Q) →' (¬' (¬' Q) →' Q)),\n            apply prf.cn _ ((¬'(¬'(¬'(¬'Q)))) →'(¬'(¬'Q))),\n            exact H4220,\n            exact H242,\n        apply prf.mp (¬' (¬' Q) →' ¬' (¬' Q) →' Q),\n        exact H220,\n        apply deduction,\n    end\n\ntheorem notnot (P : fml) : prf (P →' ¬'(¬'P)) :=\n    begin\n        have H31 : prf (¬'(¬'(¬'P)) →' ¬' P),\n            apply yesyes,\n        apply prf.mp (¬' (¬' (¬' P)) →' ¬' P),\n        exact H31,\n        apply prf.axn,\n    end\n", "meta": {"author": "ImperialCollegeLondon", "repo": "M1F_room_342_questions", "sha": "63de9a6ab9c27a433039dd5530bc9b10b1d227f7", "save_path": "github-repos/lean/ImperialCollegeLondon-M1F_room_342_questions", "path": "github-repos/lean/ImperialCollegeLondon-M1F_room_342_questions/M1F_room_342_questions-63de9a6ab9c27a433039dd5530bc9b10b1d227f7/src/Logic/abhimanyu.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.4964036737549439}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang\n-/\nimport algebra.category.Module.basic\nimport ring_theory.tensor_product\n\n/-!\n# Change Of Rings\n\n## Main definitions\n\n* `category_theory.Module.restrict_scalars`: given rings `R, S` and a ring homomorphism `R ⟶ S`,\n  then `restrict_scalars : Module S ⥤ Module R` is defined by `M ↦ M` where `M : S-module` is seen\n  as `R-module` by `r • m := f r • m` and `S`-linear map `l : M ⟶ M'` is `R`-linear as well.\n\n* `category_theory.Module.extend_scalars`: given **commutative** rings `R, S` and ring homomorphism\n  `f : R ⟶ S`, then `extend_scalars : Module R ⥤ Module S` is defined by `M ↦ S ⨂ M` where the\n  module structure is defined by `s • (s' ⊗ m) := (s * s') ⊗ m` and `R`-linear map `l : M ⟶ M'`\n  is sent to `S`-linear map `s ⊗ m ↦ s ⊗ l m : S ⨂ M ⟶ S ⨂ M'`.\n\n## List of notations\nLet `R, S` be rings and `f : R →+* S`\n* if `M` is an `R`-module, `s : S` and `m : M`, then `s ⊗ₜ[R, f] m` is the pure tensor\n  `s ⊗ m : S ⊗[R, f] M`.\n-/\n\n\nnamespace category_theory.Module\n\nuniverses v u₁ u₂\n\nnamespace restrict_scalars\n\nvariables {R : Type u₁} {S : Type u₂} [ring R] [ring S] (f : R →+* S)\nvariable (M : Module.{v} S)\n\n/-- Any `S`-module M is also an `R`-module via a ring homomorphism `f : R ⟶ S` by defining\n    `r • m := f r • m` (`module.comp_hom`). This is called restriction of scalars. -/\ndef obj' : Module R :=\n{ carrier := M,\n  is_module := module.comp_hom M f }\n\n/--\nGiven an `S`-linear map `g : M → M'` between `S`-modules, `g` is also `R`-linear between `M` and\n`M'` by means of restriction of scalars.\n-/\ndef map' {M M' : Module.{v} S} (g : M ⟶ M') :\n  obj' f M ⟶ obj' f M' :=\n{ map_smul' := λ r, g.map_smul (f r), ..g }\n\nend restrict_scalars\n\n/--\nThe restriction of scalars operation is functorial. For any `f : R →+* S` a ring homomorphism,\n* an `S`-module `M` can be considered as `R`-module by `r • m = f r • m`\n* an `S`-linear map is also `R`-linear\n-/\ndef restrict_scalars {R : Type u₁} {S : Type u₂} [ring R] [ring S] (f : R →+* S) :\n  Module.{v} S ⥤ Module.{v} R :=\n{ obj := restrict_scalars.obj' f,\n  map := λ _ _, restrict_scalars.map' f,\n  map_id' := λ _, linear_map.ext $ λ m, rfl,\n  map_comp' := λ _ _ _ g h, linear_map.ext $ λ m, rfl }\n\n@[simp] lemma restrict_scalars.map_apply {R : Type u₁} {S : Type u₂} [ring R] [ring S] (f : R →+* S)\n  {M M' : Module.{v} S} (g : M ⟶ M') (x) : (restrict_scalars f).map g x = g x := rfl\n\n@[simp] lemma restrict_scalars.smul_def {R : Type u₁} {S : Type u₂} [ring R] [ring S] (f : R →+* S)\n  {M : Module.{v} S} (r : R) (m : (restrict_scalars f).obj M) : r • m = (f r • m : M) := rfl\n\nlemma restrict_scalars.smul_def' {R : Type u₁} {S : Type u₂} [ring R] [ring S] (f : R →+* S)\n  {M : Module.{v} S} (r : R) (m : M) : (r • m : (restrict_scalars f).obj M) = (f r • m : M) := rfl\n\n@[priority 100]\ninstance smul_comm_class_mk {R : Type u₁} {S : Type u₂} [ring R] [comm_ring S] (f : R →+* S)\n  (M : Type v) [add_comm_group M] [module S M] :\n  @smul_comm_class R S M ((restrict_scalars.obj' f (Module.mk M)).is_module.to_has_smul) _ :=\n{ smul_comm := λ r s m, (by simp [←mul_smul, mul_comm] : f r • s • m = s • f r • m) }\n\nnamespace extend_scalars\n\nopen tensor_product\n\nvariables {R : Type u₁} {S : Type u₂} [comm_ring R] [comm_ring S] (f : R →+* S)\n\nsection unbundled\n\nvariables (M : Type v) [add_comm_monoid M] [module R M]\n-- This notation is necessary because we need to reason about `s ⊗ₜ m` where `s : S` and `m : M`;\n-- without this notation, one need to work with `s : (restrict_scalars f).obj ⟨S⟩`.\nlocalized \"notation s `⊗ₜ[` R `,` f `]` m := @tensor_product.tmul R _ _ _ _ _\n  (module.comp_hom _ f) _ s m\" in change_of_rings\n\nend unbundled\n\nopen_locale change_of_rings\n\nvariables (M : Module.{v} R)\n\n/--\nExtension of scalars turn an `R`-module into `S`-module by M ↦ S ⨂ M\n-/\ndef obj' : Module S :=\n⟨tensor_product R ((restrict_scalars f).obj ⟨S⟩) M⟩\n\n/--\nExtension of scalars is a functor where an `R`-module `M` is sent to `S ⊗ M` and\n`l : M1 ⟶ M2` is sent to `s ⊗ m ↦ s ⊗ l m`\n-/\ndef map' {M1 M2 : Module.{v} R} (l : M1 ⟶ M2) : (obj' f M1) ⟶ (obj' f M2) :=\n-- The \"by apply\" part makes this require 75% fewer heartbeats to process (#16371).\nby apply (@linear_map.base_change R S M1 M2 _ _ ((algebra_map S _).comp f).to_algebra _ _ _ _ l)\n\nlemma map'_id {M : Module.{v} R} : map' f (𝟙 M) = 𝟙 _ :=\nlinear_map.ext $ λ (x : obj' f M),\nbegin\n  dsimp only [map', Module.id_apply],\n  induction x using tensor_product.induction_on with _ _ m s ihx ihy,\n  { simp only [map_zero], },\n  { rw [linear_map.base_change_tmul, Module.id_apply], },\n  { rw [map_add, ihx, ihy] },\nend\n\nlemma map'_comp {M₁ M₂ M₃ : Module.{v} R} (l₁₂ : M₁ ⟶ M₂) (l₂₃ : M₂ ⟶ M₃) :\n  map' f (l₁₂ ≫ l₂₃) = map' f l₁₂ ≫ map' f l₂₃ :=\nlinear_map.ext $ λ (x : obj' f M₁),\nbegin\n  dsimp only [map'],\n  induction x using tensor_product.induction_on with _ _ x y ihx ihy,\n  { refl, },\n  { refl, },\n  { simp only [map_add, ihx, ihy], },\nend\n\nend extend_scalars\n\n/--\nExtension of scalars is a functor where an `R`-module `M` is sent to `S ⊗ M` and\n`l : M1 ⟶ M2` is sent to `s ⊗ m ↦ s ⊗ l m`\n-/\ndef extend_scalars {R : Type u₁} {S : Type u₂} [comm_ring R] [comm_ring S] (f : R →+* S) :\n  Module.{v} R ⥤ Module.{max v u₂} S :=\n{ obj := λ M, extend_scalars.obj' f M,\n  map := λ M1 M2 l, extend_scalars.map' f l,\n  map_id' := λ _, extend_scalars.map'_id f,\n  map_comp' := λ _ _ _, extend_scalars.map'_comp f }\n\nnamespace extend_scalars\n\nopen_locale change_of_rings\n\nvariables {R : Type u₁} {S : Type u₂} [comm_ring R] [comm_ring S] (f : R →+* S)\n\n@[simp] protected lemma smul_tmul {M : Module.{v} R} (s s' : S) (m : M) :\n  s • (s' ⊗ₜ[R, f] m : (extend_scalars f).obj M) = (s * s') ⊗ₜ[R, f] m := rfl\n\n@[simp] lemma map_tmul {M M' : Module.{v} R} (g : M ⟶ M') (s : S) (m : M) :\n  (extend_scalars f).map g (s ⊗ₜ[R, f] m) = s ⊗ₜ[R, f] g m := rfl\n\nend extend_scalars\n\nend category_theory.Module\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/category/Module/change_of_rings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.49640366684004866}}
{"text": "import data.int.interval\nimport linear_algebra.free_module.finite.basic\nimport ring_theory.finiteness\nimport topology.continuous_function.algebra\n\nimport for_mathlib.nnrat\nimport for_mathlib.rational_cones\n\n/-!\n\n# Gordan's Lemma\n\n-/\n\nuniverse u\nvariables {Λ : Type u} [add_comm_group Λ]\nvariable {ι : Type*}\n\nopen_locale big_operators nnrat\n\ndef explicit_dual_set (l : ι → Λ) : submodule ℕ (Λ →+ ℤ) :=\n{ carrier := {x | ∀ i, 0 ≤ x (l i)},\n  zero_mem' := λ i, le_rfl,\n  add_mem' := λ x y hx hy i, add_nonneg (hx i) (hy i),\n  smul_mem' := λ n x hx i, nsmul_nonneg (hx i) n }\n\nlemma mem_explicit_dual_set (l : ι → Λ) (x : Λ →+ ℤ) :\n  x ∈ explicit_dual_set l ↔ ∀ i, 0 ≤ x (l i) := iff.rfl\n\ndef dual_finset (S : finset Λ) : submodule ℕ (Λ →+ ℤ) :=\nexplicit_dual_set (coe : (S : set Λ) → Λ)\n\nlemma mem_dual_finset (S : finset Λ) (l : Λ →+ ℤ) :\n  l ∈ dual_finset S ↔ ∀ x ∈ S, 0 ≤ l x :=\nbegin\n  rw [dual_finset, mem_explicit_dual_set],\n  simp\nend\n\nlemma dual_finset_antimono {S T : finset Λ} (hST : S ⊆ T) :\n  dual_finset T ≤ dual_finset S :=\nbegin\n  rintro φ hφ ⟨i, his : i ∈ S⟩,\n  exact hφ ⟨i, hST his⟩,\nend\n\nlemma explicit_dual_set_eq_dual_finset [decidable_eq Λ] [fintype ι] (l : ι → Λ) :\n  explicit_dual_set l = dual_finset (finset.image l finset.univ) :=\nbegin\n  ext φ,\n  split,\n  { rintro hφ ⟨t, ht : t ∈ finset.image _ _⟩,\n    rw finset.mem_image at ht,\n    rcases ht with ⟨i, -, rfl⟩,\n    exact hφ i },\n  { rintro hφ i,\n    refine hφ ⟨l i, (_ : l i ∈ finset.image _ _)⟩,\n    rw finset.mem_image,\n    exact ⟨i, finset.mem_univ _, rfl⟩ }\nend\n\ndef intersect_halfspaces (l : ι → Λ →+ ℤ) : submodule ℕ Λ :=\n{ carrier := {x | ∀ i, 0 ≤ l i x},\n  zero_mem' := λ i, by simp only [add_monoid_hom.map_zero],\n  add_mem' := λ x y hx hy i,\n  begin\n    simp only [add_monoid_hom.map_add],\n    apply add_nonneg (hx i) (hy i)\n  end,\n  smul_mem' := λ c x hx i,\n  begin\n    simp only [nsmul_eq_mul, add_monoid_hom.map_nsmul],\n    apply mul_nonneg (int.coe_zero_le c) (hx i),\n  end }\n\nlemma mem_intersect_halfspaces (l : ι → Λ →+ ℤ) (x : Λ) :\n  x ∈ intersect_halfspaces l ↔ ∀ i, 0 ≤ l i x := iff.rfl\n\ndef intersect_halfspaces_set (s : set (Λ →+ ℤ)) : submodule ℕ Λ :=\nintersect_halfspaces (coe : (s : set (Λ →+ ℤ)) → (Λ →+ ℤ))\n\nlemma mem_intersect_halfspaces_set (S : set (Λ →+ ℤ)) (x : Λ) :\n  x ∈ intersect_halfspaces_set S ↔ ∀ (f : Λ →+ ℤ), f ∈ S → 0 ≤ f x :=\nbegin\n  rw [intersect_halfspaces_set, mem_intersect_halfspaces],\n  simp\nend\n\nvariables {α : Type*}\n\ndef to_rational_point : (α → ℤ) →ₗ[ℤ] (α → ℚ) :=\n{ to_fun := λ f x, f x,\n  map_add' := λ f g, by { ext1 x, simp only [int.cast_add, pi.add_apply] },\n  map_smul' := λ m f, by { ext1 x, simp only [zsmul_eq_mul, pi.mul_apply, int.cast_mul, eq_int_cast,\n    mul_eq_mul_right_iff, int.cast_eq_zero], left, refl } }\n\n@[simp] lemma to_rational_point_apply (x : α → ℤ) (i : α) :\n  to_rational_point x i = x i := rfl\n\nlemma to_rational_point_injective : function.injective (to_rational_point : (α → ℤ) → (α → ℚ)) :=\nbegin\n  intros x y h,\n  ext i,\n  rw function.funext_iff at h,\n  specialize h i,\n  simpa using h\nend\n\ndef lattice_restrict (S : submodule ℚ≥0 (α → ℚ)) : submodule ℕ (α → ℤ) :=\n{ carrier := to_rational_point ⁻¹' (S : set (α → ℚ)),\n  zero_mem' :=\n    by simp only [linear_map.map_zero, set.mem_preimage, set_like.mem_coe, submodule.zero_mem],\n  add_mem' := λ a b (ha : to_rational_point a ∈ S) (hb : to_rational_point b ∈ S),\n  begin\n    change to_rational_point (a + b) ∈ S,\n    simp only [linear_map.map_add],\n    apply S.add_mem ha hb,\n  end,\n  smul_mem' := λ c x (hx : to_rational_point x ∈ S),\n  begin\n    change to_rational_point (c • x) ∈ S,\n    rw linear_map.map_smul_of_tower,\n    exact submodule.smul_of_tower_mem S c hx,\n  end }\n\nlemma mem_lattice_restrict (S : submodule (ℚ≥0) (α → ℚ)) (x : α → ℤ) :\n  x ∈ lattice_restrict S ↔ to_rational_point x ∈ S :=\niff.rfl\n\ndef is_integer (x : ℚ) := ∃ (z : ℤ), x = z\ndef is_integer_point (x : α → ℚ) := ∀ a, is_integer (x a)\n\ndef floor_point (x : α → ℚ) : α → ℤ := λ i, ⌊x i⌋\nlemma floor_point_eq_of_is_integer_point (x : α → ℚ) (hx : is_integer_point x) :\n  (λ i, floor_point x i : α → ℚ) = x :=\nbegin\n  ext1 i,\n  obtain ⟨z, hz⟩ := hx i,\n  simp [floor_point, hz],\nend\n\nlemma exists_scalings {ι : Type*} (s : finset ι) (v : ι → ℚ) :\n  ∃ (n : ℕ), 0 < n ∧ ∀ i ∈ s, is_integer (n • v i) :=\nbegin\n  classical,\n  apply finset.induction_on s,\n  { exact ⟨1, by norm_num, by simp⟩ },\n  { rintro x s hx ⟨m, hm₁, hm₂⟩,\n    refine ⟨m * (v x).denom, mul_pos hm₁ (v x).pos, _⟩,\n    simp only [forall_eq_or_imp, nsmul_eq_mul, finset.mem_insert, nat.cast_mul],\n    refine ⟨⟨m * (v x).num, _⟩, _⟩,\n    { push_cast,\n      rw mul_assoc,\n      norm_cast,\n      rw [mul_comm ((v x).denom : ℚ), rat.mul_denom_eq_num],\n      norm_cast },\n    intros y hy,\n    obtain ⟨z, hz⟩ := hm₂ y hy,\n    rw mul_right_comm,\n    refine ⟨z * (v x).denom, _⟩,\n    push_cast,\n    rw ←hz,\n    simp }\nend\n\nlemma point_exists_scaling {α : Type*} [fintype α] (x : α → ℚ) :\n  ∃ (n : ℕ), 0 < n ∧ is_integer_point ((n) • x) :=\nlet ⟨m, hm₁, hm₂⟩ := exists_scalings finset.univ x in ⟨m, hm₁, λ a, by simpa using hm₂ a⟩\n\nopen_locale classical\n\nnoncomputable def scale_factor {α : Type*} [fintype α] (x : α → ℚ) : ℕ :=\nnat.find (point_exists_scaling x)\n\nlemma scale_factor_pos {α : Type*} [fintype α] (x : α → ℚ) : 0 < scale_factor x :=\n(nat.find_spec (point_exists_scaling x)).1\n\nlemma rat_scale_factor_ne_zero {α : Type*} [fintype α] (x : α → ℚ) :\n  (scale_factor x : ℚ) ≠ 0 :=\nbegin\n  norm_cast,\n  apply (scale_factor_pos x).ne',\nend\n\nnoncomputable def scale_up {α : Type*} [fintype α] (x : α → ℚ) : α → ℤ :=\nfloor_point (scale_factor x • x)\n\nlemma scale_up_is {α : Type*} [fintype α] (x : α → ℚ) :\n  (λ (i : α), ↑(scale_up x i)) = scale_factor x • x :=\nfloor_point_eq_of_is_integer_point _ (nat.find_spec (point_exists_scaling x)).2\n\nlemma scale_up_coord {α : Type*} [fintype α] (x : α → ℚ) (a : α) :\n  (scale_up x a : ℚ) = scale_factor x * x a :=\nbegin\n  suffices : (scale_up x a : ℚ) = (scale_factor x • x) a,\n  { simpa using this },\n  rw ←scale_up_is,\nend\n\nlemma to_rational_point_scale_up {α : Type*} [fintype α] (x : α → ℚ) :\n  to_rational_point (scale_up x) = scale_factor x • x :=\nbegin\n  ext1 i,\n  simp only [scale_up_coord, to_rational_point_apply, nsmul_eq_mul, pi.mul_apply, mul_eq_mul_right_iff],\n  left, refl,\nend\n\nexample {a b : ℤ} : (a : ℚ) = b → a = b :=\nλ h, (rat.coe_int_inj a b).mp h\n\nnoncomputable def upgrade_functional {α : Type*} [fintype α] (f : (α → ℤ) →+ ℤ) : (α → ℚ) →ₗ[ℚ] ℚ :=\n{ to_fun := λ g, (f (scale_up g) : ℚ) / scale_factor g,\n  map_add' := λ g₁ g₂,\n  begin\n    field_simp [rat_scale_factor_ne_zero],\n    norm_cast,\n    suffices : f ((scale_factor g₁ * scale_factor g₂) • scale_up (g₁ + g₂)) =\n      f (scale_factor (g₁ + g₂) • (scale_factor g₂ • scale_up g₁ + scale_factor g₁ • scale_up g₂)),\n    { simp only [add_monoid_hom.map_nsmul, add_monoid_hom.map_add] at this,\n      simp only [nsmul_eq_mul, mul_comm _ (f _)] at this,\n      rw this,\n      apply mul_comm },\n    congr' 1,\n    ext1 a,\n    simp only [pi.add_apply, pi.smul_apply],\n    simp only [nsmul_eq_mul, int.coe_nat_mul, mul_add],\n    rw ←rat.coe_int_inj,\n    push_cast,\n    simp only [scale_up_coord, pi.add_apply],\n    ring!,\n  end,\n  map_smul' := λ m x,\n  begin\n    simp only [algebra.id.smul_eq_mul],\n    rw ←rat.num_div_denom m,\n    field_simp [rat_scale_factor_ne_zero, m.pos.ne', -rat.num_div_denom],\n    simp only [rat.num_div_denom],\n    norm_cast,\n    suffices :\n      f ((m.denom * scale_factor x) • scale_up (m • x)) =\n        f ((scale_factor (m • x) * m.num : ℤ) • scale_up x),\n    { simp only [add_monoid_hom.map_zsmul, add_monoid_hom.map_nsmul] at this,\n      simp only [int.coe_nat_mul],\n      simp only [algebra.id.smul_eq_mul, rat.num_div_denom, nsmul_eq_mul, int.coe_nat_mul] at this,\n      rw [mul_comm (f _), this, mul_comm _ m.num, mul_right_comm] },\n    congr' 1,\n    ext1 a,\n    simp only [pi.smul_apply],\n    simp only [algebra.id.smul_eq_mul, nsmul_eq_mul, int.coe_nat_mul],\n    rw ←rat.coe_int_inj,\n    push_cast,\n    simp only [scale_up_coord, pi.smul_apply, algebra.id.smul_eq_mul, ←rat.mul_denom_eq_num],\n    ring!,\n  end }.\n\nlemma upgrade_id {α : Type*} [fintype α] (f : (α → ℤ) →+ ℤ) (g : α → ℤ) :\n  upgrade_functional f (to_rational_point g) = f g :=\nbegin\n  dsimp [upgrade_functional, to_rational_point],\n  rw div_eq_iff (rat_scale_factor_ne_zero _),\n  norm_cast,\n  rw [mul_comm, ←nsmul_eq_mul, ←add_monoid_hom.map_nsmul],\n  congr' 1,\n  ext a,\n  simp only [nsmul_eq_mul, pi.mul_apply],\n  rw ←rat.coe_int_inj,\n  rw scale_up_coord,\n  norm_cast,\nend\n\nsection\n\nlemma finitely_generated_iff_integrally_generated [fintype α] (C : submodule (ℚ≥0) (α → ℚ)) :\n  C.fg ↔ ∃ S : finset (α → ℤ), submodule.span (ℚ≥0) (S.image to_rational_point : set (α → ℚ)) = C :=\nbegin\n  split,\n  { rintro ⟨S, rfl⟩,\n    refine ⟨S.image scale_up, _⟩,\n    apply le_antisymm,\n    { rw submodule.span_le,\n      intros x,\n      simp only [to_rational_point_scale_up, and_imp, set.mem_image, finset.mem_coe,\n        exists_exists_and_eq_and, set_like.mem_coe, exists_imp_distrib, finset.coe_image],\n      rintro y hy rfl,\n      have : y ∈ submodule.span (ℚ≥0) (S : set (α → ℚ)) := submodule.subset_span hy,\n      have z := submodule.smul_mem _ (scale_factor y : ℚ≥0) this,\n      convert z using 1,\n      ext1 i,\n      simp only [nsmul_eq_mul, pi.smul_apply],\n      refl, },\n    { rw submodule.span_le,\n      intros x,\n      simp only [set_like.mem_coe, finset.mem_coe, finset.coe_image, ←set.image_comp],\n      intro hx,\n      have : scale_factor x • x ∈ ((to_rational_point ∘ scale_up) '' (S : set (α → ℚ))),\n      { refine ⟨_, hx, _⟩,\n        simp only [nsmul_eq_mul, function.comp_app, to_rational_point_scale_up] },\n      have : scale_factor x • x ∈\n        submodule.span ℚ≥0 (to_rational_point ∘ scale_up '' (S : set (α → ℚ))) :=\n        submodule.subset_span this,\n      have hx₂ := submodule.smul_mem _ ((scale_factor x)⁻¹ : ℚ≥0) this,\n      convert hx₂ using 1,\n      ext1 i,\n      simp only [nsmul_eq_mul, pi.mul_apply, pi.smul_apply],\n      change _ = _ * (_ * _),\n      simp,\n      rw ←mul_assoc,\n      convert (one_mul (x i)).symm,\n      convert inv_mul_cancel _,\n      apply rat_scale_factor_ne_zero } },\n  { rintro ⟨S, rfl⟩,\n    refine ⟨_, rfl⟩ }\nend.\n\nlemma finitely_generated_iff_integrally_generated_type {α : Type u} [fintype α]\n  (C : submodule (ℚ≥0) (α → ℚ)) :\n  C.fg ↔ ∃ (ι : Type u) (s : finset ι) (v : ι → α → ℤ) (hv : function.injective v),\n    submodule.span (ℚ≥0) (s.image (λ i, to_rational_point (v i)) : set (α → ℚ)) = C :=\nbegin\n  rw finitely_generated_iff_integrally_generated,\n  split,\n  { rintro ⟨S, rfl⟩,\n    refine ⟨_, S, id, λ _ _ h, h, rfl⟩ },\n  { rintro ⟨ι, s, v, _, rfl⟩,\n    refine ⟨s.image v, _⟩,\n    rw finset.image_image }\nend\n\nlemma bounded_lattice_thing [fintype α] {k : α → ℕ} (C : set (α → ℤ))\n  (hC : ∀ (x : α → ℤ) i, x ∈ C → int.nat_abs (x i) ≤ k i) : C.finite :=\nbegin\n  classical,\n  let C' : finset (α → ℤ) :=\n    (finset.univ.pi (λ i, finset.Ico (-(k i : ℤ)) (k i+1))).image (λ f a, f a (finset.mem_univ _)),\n  have : C ⊆ C',\n  { intros x hx,\n    simp only [set.mem_image, finset.mem_univ, finset.mem_pi, forall_true_left, finset.mem_coe,\n      finset.mem_Ico, finset.coe_image],\n    refine ⟨λ a _, x a, λ a, _, _⟩,\n    { have : abs (x a) ≤ k a,\n      { rw int.abs_eq_nat_abs,\n        exact_mod_cast hC x a hx },\n      rw abs_le at this,\n      refine ⟨this.1, _⟩,\n      rw int.lt_add_one_iff,\n      apply this.2 },\n    refl },\n  apply set.finite.subset _ this,\n  exact finset.finite_to_set C',\nend\n\nlemma finset.sum_nat_abs_le {ι : Type*} (s : finset ι) (f : ι → ℤ) :\n  (∑ i in s, f i).nat_abs ≤ ∑ i in s, (f i).nat_abs :=\nfinset.le_sum_of_subadditive _ rfl int.nat_abs_add_le _ _\n\nlemma floor_add_floor_le {α : Type*} [linear_ordered_ring α] [floor_ring α] (x y : α) :\n  ⌊x⌋ + ⌊y⌋ ≤ ⌊x + y⌋ :=\nbegin\n  rw [int.le_floor, int.cast_add],\n  apply add_le_add (int.floor_le x) (int.floor_le y),\nend\n\nlemma finset.floor_le {α : Type*} [linear_ordered_ring α] [floor_ring α] {ι : Type*} (s : finset ι)\n  (f : ι → α) :\n  ∑ i in s, ⌊f i⌋ ≤ ⌊∑ i in s, f i⌋ :=\nbegin\n  apply finset.induction_on s,\n  { simp },\n  { intros i s hi ih,\n    rw [finset.sum_insert hi, finset.sum_insert hi],\n    apply le_trans (add_le_add_left ih _) (floor_add_floor_le _ _) }\nend\n\nlemma ceil_add_le {α : Type*} [linear_ordered_ring α] [floor_ring α] (x y : α) :\n  ⌈x + y⌉ ≤ ⌈x⌉ + ⌈y⌉ :=\nbegin\n  rw [int.ceil_le, int.cast_add],\n  apply add_le_add (int.le_ceil x) (int.le_ceil y),\nend\n\nlemma finset.le_ceil {α : Type*} [linear_ordered_ring α] [floor_ring α] {ι : Type*} (s : finset ι)\n  (f : ι → α) :\n  ⌈∑ i in s, f i⌉ ≤ ∑ i in s, ⌈f i⌉ :=\nfinset.le_sum_of_subadditive _ (by simp) ceil_add_le _ _\n\nlemma nat_abs_lt_nat_abs_of_nonneg_of_lt {a b : ℤ} (w₁ : 0 ≤ a) (w₂ : a < b) :\n  a.nat_abs < b.nat_abs :=\nbegin\n  lift b to ℕ using le_trans w₁ (le_of_lt w₂),\n  lift a to ℕ using w₁,\n  simpa using w₂,\nend\n\nlemma int.coe_sum {α : Type*} (f : α → ℕ) (s : finset α) :\n  ∑ (x : α) in s, (f x : ℤ) = (↑∑ i in s, f i : ℤ) :=\nbegin\n  apply finset.induction_on s,\n  { simp },\n  { intros i t hi ih,\n    simp only [finset.sum_insert hi, ih],\n    simp }\nend\n\nlemma finset.mem_span_iff {R M : Type*} [ring R] [add_comm_monoid M] [module R M] (S : finset M)\n  (x : M) :\n  x ∈ submodule.span R (S : set M) ↔ ∃ (w : M → R), ∑ i in S, w i • i = x :=\nbegin\n  exact mem_span_finset\nend\n\nset_option pp.proofs true\n\nlemma missing [fintype α] (w : α → ℤ) (n : ℕ) :\n  to_rational_point (n • w) = (n : ℚ≥0) • to_rational_point w :=\nbegin\n  simp only [nsmul_eq_mul],\n  induction n,\n  { simp },\n  { simp [add_smul, ←n_ih, add_mul],  },\nend\n\nlemma my_result [fintype α] (C : submodule (ℚ≥0) (α → ℚ)) (hC : C.fg) :\n  (lattice_restrict C).fg :=\nbegin\n  rw finitely_generated_iff_integrally_generated_type at hC,\n  rcases hC with ⟨ι, s, w, hw, rfl⟩,\n  let B := {x : α → ℤ |\n                ∃ w' : ι → ℚ≥0, (∀ (i ∈ s), w' i < 1) ∧\n                ∑ i in s, w' i • to_rational_point (w i) = to_rational_point x},\n  let k : α → ℕ := λ a, ∑ i in s, int.nat_abs (w i a),\n  have : ∀ (x : α → ℤ) a, x ∈ B → int.nat_abs (x a) ≤ k a,\n  { rintro x a ⟨w', hw', hw''⟩,\n    have hw''' : (∑ (i : ι) in s, w' i • to_rational_point (w i)) a = to_rational_point x a,\n    { rw hw'' },\n    simp only [finset.sum_apply, algebra.id.smul_eq_mul, to_rational_point_apply,\n      pi.smul_apply] at hw''',\n    change ∑ (c : ι) in s, (w' c : ℚ) * (w c a) = x a at hw''',\n    clear hw'',\n    have : abs (∑ (c : ι) in s, (w' c : ℚ) * w c a) ≤ ∑ (c : ι) in s, abs (w c a),\n    { apply le_trans (finset.abs_sum_le_sum_abs _ _) _,\n      apply finset.sum_le_sum,\n      intros i hi,\n      rw abs_mul,\n      apply mul_le_of_le_one_left,\n      exact abs_nonneg (w i a),\n      rw abs_le,\n      refine ⟨_, (hw' i hi).le⟩,\n      apply le_trans (show (-1 : ℚ) ≤ 0, by norm_num) (w' i).2 },\n    rw hw''' at this,\n    norm_cast at this,\n    simp only [int.abs_eq_nat_abs] at this,\n    rw int.coe_sum at this,\n    norm_cast at this,\n    apply this },\n  let B' := set.finite.to_finset (bounded_lattice_thing _ this),\n  refine ⟨B' ∪ s.image w, _⟩,\n  apply le_antisymm,\n  { rw submodule.span_le,\n    simp only [set.union_subset_iff, finset.coe_union, set.finite.coe_to_finset],\n    split,\n    { rintro x ⟨w', hw', hw''⟩,\n      change to_rational_point x ∈ _,\n      rw ←hw'',\n      simp only [set_like.mem_coe],\n      refine submodule.sum_smul_mem _ _ _,\n      intros i hi,\n      apply submodule.subset_span,\n      simp only [set.mem_image, finset.mem_coe, finset.coe_image],\n      refine ⟨_, hi, rfl⟩ },\n    { simp only [set.image_subset_iff, finset.coe_image],\n      intros x hx,\n      change to_rational_point (w x) ∈ _,\n      apply submodule.subset_span,\n      refine ⟨_, hx, rfl⟩ } },\n  { rintro x (hx : to_rational_point _ ∈ _),\n    simp only [set_like.mem_coe, mem_span_finset] at hx,\n    rcases hx with ⟨f, hf⟩,\n    rw finset.sum_image at hf,\n    { simp only [finset.coe_union, set.finite.coe_to_finset, finset.coe_image],\n      let f' : ι → ℚ≥0 := λ i, f (to_rational_point (w i)),\n      let ns : ι → ℕ := λ i, (⌊(f' i : ℚ)⌋).nat_abs,\n      let g' : ι → ℚ≥0 := λ i, f' i - ns i,\n      have ns' : ∀ i, (ns i : ℤ) = ⌊(f' i : ℚ)⌋,\n      { intro i,\n        change (int.nat_abs _ : ℤ) = _,\n        rw [←int.abs_eq_nat_abs, abs_of_nonneg],\n        rw [int.floor_nonneg],\n        apply (f' i).2 },\n      have hg' : ∀ i, (g' i : ℚ) = f' i - ns i,\n      { intros i,\n        change max _ _ = _,\n        simp only [nnrat.coe_nat_cast],\n        rw max_eq_left,\n        rw sub_nonneg,\n        change (int.nat_abs _ : ℚ) ≤ _,\n        suffices : ((int.nat_abs ⌊(f' i : ℚ)⌋ : ℤ) : ℚ) ≤ f' i,\n        { simpa using this },\n        rw ns',\n        apply int.floor_le },\n      change ∑ x in s, f' x • to_rational_point (w x) = to_rational_point x at hf,\n      -- have :  ≤ ↑(f' i) - ↑(ns i)\n      have : ∀ i, (ns i : ℚ≥0) + g' i = f' i,\n      { intro i,\n        apply nnrat.coe_injective,\n        rw [nnrat.coe_add, hg'],\n        simp },\n      simp_rw [←this, add_smul, finset.sum_add_distrib] at hf,\n      let x_floors := ∑ (x : ι) in s, ns x • w x,\n      have : x - x_floors ∈ B,\n      { refine ⟨g', _, _⟩,\n        { intros i hi,\n          rw ←nnrat.coe_lt_coe,\n          rw hg',\n          simp only [nnrat.coe_one],\n          suffices : (f' i : ℚ) - ((ns i : ℤ) : ℚ) < 1,\n          { simpa using this },\n          rw ns',\n          apply int.fract_lt_one },\n        rw linear_map.map_sub,\n        rw linear_map.map_sum,\n        rw eq_sub_iff_add_eq',\n        rw ←hf,\n        congr' 1,\n        apply finset.sum_congr rfl,\n        intros i hi,\n        apply missing },\n      { have : x = x - x_floors + x_floors,\n        { simp },\n        rw this,\n        refine submodule.add_mem _ _ _,\n        { apply submodule.subset_span,\n          left,\n          apply ‹x - x_floors ∈ B› },\n        apply submodule.sum_smul_mem _ ns _,\n        intros i hi,\n        apply submodule.subset_span,\n        right,\n        refine ⟨_, hi, rfl⟩ } },\n    intros x hx y hy t,\n    apply hw,\n    apply to_rational_point_injective t, }\nend\n\nend\n\n-- instance {α : Type*} [fintype α] : finite_dimensional ℚ (α → ℚ) :=\n-- @is_noetherian_pi _ _ _ _ _ _ _ (λ i, infer_instance)\n\nlemma finset_Gordan_aux_pi {α : Type*} [fintype α] (S : finset ((α → ℤ) →+ ℤ)) :\n  (intersect_halfspaces_set (S : set ((α → ℤ) →+ ℤ))).fg  :=\nbegin\n  classical,\n  let S' : finset ((α → ℚ) →ₗ[ℚ] ℚ) := S.image upgrade_functional,\n  suffices : lattice_restrict (set_down_one (S' : set ((α → ℚ) →ₗ[ℚ] ℚ))) =\n              intersect_halfspaces_set (S : set ((α → ℤ) →+ ℤ)),\n  { rw ←this,\n    apply my_result,\n    rw ←fg_iff_is_polyhedral_cone,\n    rw is_polyhedral_cone_iff_finset,\n    refine ⟨_, rfl⟩ },\n  ext x,\n  simp [mem_lattice_restrict, mem_intersect_halfspaces_set, upgrade_id],\nend\n\n/-- A finset version of Gordan's Lemma. -/\nlemma finset_Gordan_aux [module.finite ℤ Λ] [module.free ℤ Λ] (S : finset (Λ →+ ℤ)) :\n  (intersect_halfspaces_set (S : set (Λ →+ ℤ))).fg :=\nbegin\n  classical,\n  have e := linear_equiv.restrict_scalars ℕ (module.free.choose_basis ℤ Λ).equiv_fun,\n    -- deliberately forget the data here, it makes the simp at the end easier\n  let e' : (Λ →+ ℤ) → (module.free.choose_basis_index ℤ Λ → ℤ) →+ ℤ :=\n    λ f, f.comp e.symm.to_linear_map.to_add_monoid_hom,\n  let L := (intersect_halfspaces_set ↑(S.image e')).map\n    (e.symm : (module.free.choose_basis_index ℤ Λ → ℤ) →ₗ[ℕ] Λ),\n  have : L.fg := submodule.fg.map _ (finset_Gordan_aux_pi (S.image e')),\n  suffices : L = intersect_halfspaces_set (S : set (Λ →+ ℤ)),\n  { rwa ←this },\n  ext x,\n  simp [mem_intersect_halfspaces_set, linear_equiv.symm_apply_eq],\nend\n\n/-- A finset version of Gordan's Lemma. -/\nlemma finset_Gordan [module.finite ℤ Λ] [module.free ℤ Λ] (S : finset Λ) :\n  (dual_finset S).fg :=\nbegin\n  classical,\n  let S' : finset ((Λ →+ ℤ) →+ ℤ) := S.image add_monoid_hom.eval,\n  letI := module.free.add_monoid_hom Λ ℤ, --RB: not sure why this is needed\n  have := finset_Gordan_aux S',\n  convert this using 1,\n  ext x,\n  simp [mem_dual_finset, mem_intersect_halfspaces_set],\nend\n\n/-- A fintype version of Gordan's Lemma. -/\nlemma explicit_gordan [module.finite ℤ Λ] [module.free ℤ Λ] [fintype ι] (l : ι → Λ) :\n  (explicit_dual_set l).fg :=\nbegin\n  classical,\n  rw explicit_dual_set_eq_dual_finset,\n  apply finset_Gordan,\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/Gordan.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115012, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.49640365471468656}}
{"text": "/-\nCopyright (c) 2020 Aaron Anderson, Jalex Stark. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Aaron Anderson, Jalex Stark.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.matrix.char_p\nimport Mathlib.linear_algebra.char_poly.basic\nimport Mathlib.linear_algebra.matrix\nimport Mathlib.ring_theory.polynomial.basic\nimport Mathlib.algebra.polynomial.big_operators\nimport Mathlib.group_theory.perm.cycles\nimport Mathlib.field_theory.finite.basic\nimport Mathlib.PostPort\n\nuniverses u v u_1 \n\nnamespace Mathlib\n\n/-!\n# Characteristic polynomials\n\nWe give methods for computing coefficients of the characteristic polynomial.\n\n## Main definitions\n\n- `char_poly_degree_eq_dim` proves that the degree of the characteristic polynomial\n  over a nonzero ring is the dimension of the matrix\n- `det_eq_sign_char_poly_coeff` proves that the determinant is the constant term of the characteristic\n  polynomial, up to sign.\n- `trace_eq_neg_char_poly_coeff` proves that the trace is the negative of the (d-1)th coefficient of the\n  characteristic polynomial, where d is the dimension of the matrix.\n  For a nonzero ring, this is the second-highest coefficient.\n\n-/\n\ntheorem char_matrix_apply_nat_degree {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] {M : matrix n n R} [nontrivial R] (i : n) (j : n) : polynomial.nat_degree (char_matrix M i j) = ite (i = j) 1 0 := sorry\n\ntheorem char_matrix_apply_nat_degree_le {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] {M : matrix n n R} (i : n) (j : n) : polynomial.nat_degree (char_matrix M i j) ≤ ite (i = j) 1 0 := sorry\n\ntheorem char_poly_sub_diagonal_degree_lt {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (M : matrix n n R) : polynomial.degree (char_poly M - finset.prod finset.univ fun (i : n) => polynomial.X - coe_fn polynomial.C (M i i)) <\n  ↑(fintype.card n - 1) := sorry\n\ntheorem char_poly_coeff_eq_prod_coeff_of_le {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (M : matrix n n R) {k : ℕ} (h : fintype.card n - 1 ≤ k) : polynomial.coeff (char_poly M) k =\n  polynomial.coeff (finset.prod finset.univ fun (i : n) => polynomial.X - coe_fn polynomial.C (M i i)) k := sorry\n\ntheorem det_of_card_zero {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (h : fintype.card n = 0) (M : matrix n n R) : matrix.det M = 1 := sorry\n\ntheorem char_poly_degree_eq_dim {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] [nontrivial R] (M : matrix n n R) : polynomial.degree (char_poly M) = ↑(fintype.card n) := sorry\n\ntheorem char_poly_nat_degree_eq_dim {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] [nontrivial R] (M : matrix n n R) : polynomial.nat_degree (char_poly M) = fintype.card n :=\n  polynomial.nat_degree_eq_of_degree_eq_some (char_poly_degree_eq_dim M)\n\ntheorem char_poly_monic {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (M : matrix n n R) : polynomial.monic (char_poly M) := sorry\n\ntheorem trace_eq_neg_char_poly_coeff {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] [Nonempty n] (M : matrix n n R) : coe_fn (matrix.trace n R R) M = -polynomial.coeff (char_poly M) (fintype.card n - 1) := sorry\n\n-- I feel like this should use polynomial.alg_hom_eval₂_algebra_map\n\ntheorem mat_poly_equiv_eval {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (M : matrix n n (polynomial R)) (r : R) (i : n) (j : n) : polynomial.eval (coe_fn (matrix.scalar n) r) (coe_fn mat_poly_equiv M) i j = polynomial.eval r (M i j) := sorry\n\ntheorem eval_det {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (M : matrix n n (polynomial R)) (r : R) : polynomial.eval r (matrix.det M) = matrix.det (polynomial.eval (coe_fn (matrix.scalar n) r) (coe_fn mat_poly_equiv M)) := sorry\n\ntheorem det_eq_sign_char_poly_coeff {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (M : matrix n n R) : matrix.det M = (-1) ^ fintype.card n * polynomial.coeff (char_poly M) 0 := sorry\n\n@[simp] theorem finite_field.char_poly_pow_card {n : Type v} [DecidableEq n] [fintype n] {K : Type u_1} [field K] [fintype K] (M : matrix n n K) : char_poly (M ^ fintype.card K) = char_poly M := sorry\n\n@[simp] theorem zmod.char_poly_pow_card {n : Type v} [DecidableEq n] [fintype n] {p : ℕ} [fact (nat.prime p)] (M : matrix n n (zmod p)) : char_poly (M ^ p) = char_poly M :=\n  eq.mp (Eq._oldrec (Eq.refl (char_poly (M ^ fintype.card (zmod p)) = char_poly M)) (zmod.card p))\n    (finite_field.char_poly_pow_card M)\n\ntheorem finite_field.trace_pow_card {n : Type v} [DecidableEq n] [fintype n] {K : Type u_1} [field K] [fintype K] [Nonempty n] (M : matrix n n K) : coe_fn (matrix.trace n K K) (M ^ fintype.card K) = coe_fn (matrix.trace n K K) M ^ fintype.card K := sorry\n\ntheorem zmod.trace_pow_card {n : Type v} [DecidableEq n] [fintype n] {p : ℕ} [fact (nat.prime p)] [Nonempty n] (M : matrix n n (zmod p)) : coe_fn (matrix.trace n (zmod p) (zmod p)) (M ^ p) = coe_fn (matrix.trace n (zmod p) (zmod p)) M ^ p := sorry\n\nnamespace matrix\n\n\ntheorem is_integral {R : Type u} [comm_ring R] {n : Type v} [DecidableEq n] [fintype n] (M : matrix n n R) : is_integral R M :=\n  Exists.intro (char_poly M) { left := char_poly_monic M, right := aeval_self_char_poly M }\n\ntheorem min_poly_dvd_char_poly {n : Type v} [DecidableEq n] [fintype n] {K : Type u_1} [field K] (M : matrix n n K) : minpoly K M ∣ char_poly M :=\n  minpoly.dvd K M (aeval_self_char_poly M)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/char_poly/coeff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.49627554965388193}}
{"text": "import data.fin order.basic tactic.split_ifs\nimport category_theory.base\n\nopen category_theory\n\ndef simplex_category := ℕ\n\nlocal notation `Δ` := simplex_category\nlocal notation `[`n`]` := fin (n + 1)\n\ninstance : has_coe_to_sort (Δ) :=\n{S := Type, coe := λ n, [n]}\n\n/- Nota bene: We will abuse the notation (n : Δ)\n   to denote what a mathematician would call [n].\n-/\n\n/- This defines the set of monotone maps. The best solution\n   is probably to rename `monotone` to `is_monotone,\n   so that we can use `monotone` instead of the following\n   `order_preserving_map`.\n-/\ndef order_preserving_map (m n : Δ) :=\n{f : m → n // monotone f}\n\ninstance {m n : Δ} : has_coe_to_fun (order_preserving_map m n) :=\n{ F := λ _, m → n, coe := λ f, f.val }\n\ninstance : category Δ :=\n{ hom := order_preserving_map, --λ m n : Δ, {f : m → n // monotone f},\n  id := λ X, ⟨id, monotone_id⟩,\n  comp := λ _ _ _ f g, ⟨g.val ∘ f.val, g.2.comp f.2⟩ }\n\nnamespace simplex_category\n\nprotected lemma hom_eq2 {m n : Δ} {f g : m ⟶ n} : f = g ↔ f.val = g.val := by cases f; cases g; simp\n\nvariables {n : Δ}\n\n/-- The i-th face map from [n] to [n+1] -/\ndef δ (i : [n+1]) : n ⟶ ((n + 1) : ℕ) :=\n⟨λ a, if h : i.val ≤ a.val then a.succ else a.cast_succ,\n  begin\n    intros a b H,\n    dsimp,\n    split_ifs with ha hb,\n    { show a.succ.val ≤ b.succ.val,\n      simpa using nat.succ_le_succ H },\n    { exfalso,\n      exact hb (nat.le_trans ha H) },\n    { show a.val ≤ b.succ.val,\n      simpa using nat.le_trans H (nat.le_succ b) },\n    { exact H }\n  end⟩\n\n/-- The i-th degeneracy map from [n+1] to [n] -/\ndef σ (i : [n]) : @has_hom.hom Δ _ ((n + 1) : ℕ) n :=\n⟨λ a, if h : a.val ≤ i.val\n    then ⟨a.val, lt_of_le_of_lt h i.is_lt⟩\n    else ⟨a.val.pred,\n      (nat.sub_lt_right_iff_lt_add (lt_of_le_of_lt i.val.zero_le (not_le.mp h))).mpr a.is_lt⟩,\n  begin\n    intros a b H,\n    dsimp,\n    split_ifs with ha hb,\n    { exact H },\n    { simp at hb,\n      have hb' : i.val ≤ nat.pred b.val :=\n      begin\n        rw ←nat.pred_succ i.val,\n        exact nat.pred_le_pred hb\n      end,\n      exact nat.le_trans ha hb' },\n    { exfalso,\n      exact ha (nat.le_trans H h) },\n    { exact nat.pred_le_pred H }\n  end⟩\n\nlemma simplicial_identity₁ {i j : [n+1]} (H : i ≤ j) : δ i ≫ δ j.succ = δ j ≫ δ i.cast_succ :=\nbegin\n  rw simplex_category.hom_eq2,\n  dsimp [category_struct.comp, function.comp, δ],\n  funext a,\n  by_cases hja : (j.val ≤ a.val),\n  { have hja' : ((fin.succ j).val ≤ (fin.succ a).val) := by simp; exact nat.succ_le_succ hja,\n    have hia : ((fin.cast_succ i).val ≤ (fin.succ a).val) := by simp; exact nat.le_trans H (nat.le_trans hja (nat.le_succ a.val)),\n    erw [dif_pos hja, dif_pos (nat.le_trans H hja), dif_pos hja', dif_pos hia] },\n  { rw [dif_neg hja],\n    by_cases hia : (i.val ≤ a.val),\n    { have hia' : ((fin.cast_succ i).val ≤ (fin.cast_succ a).val) := hia,\n      have hja' : ¬(j.succ.val ≤ a.succ.val) := by simp at *; exact nat.succ_le_succ hja,\n      erw [dif_pos hia, dif_pos hia', dif_neg hja'],\n      apply fin.eq_of_veq,\n      simp },\n    { have hja' : ¬(j.succ.val ≤ a.cast_succ.val) := by simp at *; exact nat.le_trans hja (nat.le_succ j.val),\n      have hia' : ¬((fin.cast_succ i).val ≤ (fin.cast_succ a).val) := by unfold fin.cast_succ; exact hia,\n      erw [dif_neg hia, dif_neg hja', dif_neg hia'] } }\nend\n\n-- lemma simplicial_identity₂ {i : [n+1]} {j : [n]} (H : i ≤ j.raise) : δ i.raise ≫ σ j.succ = σ j ≫ δ i := sorry\n-- lemma simplicial_identity₃\n-- lemma simplicial_identity₄\n-- lemma simplicial_identity₅\n\nend simplex_category\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/category_theory/simplex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.49627554965388193}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module number_theory.zsqrtd.basic\n! leanprover-community/mathlib commit 97eab48559068f3d6313da387714ef25768fb730\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Associated\nimport Mathbin.RingTheory.Int.Basic\nimport Mathbin.Tactic.Ring\nimport Mathbin.Algebra.Star.Unitary\n\n/-! # ℤ[√d]\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe ring of integers adjoined with a square root of `d : ℤ`.\n\nAfter defining the norm, we show that it is a linearly ordered commutative ring,\nas well as an integral domain.\n\nWe provide the universal property, that ring homomorphisms `ℤ√d →+* R` correspond\nto choices of square roots of `d` in `R`.\n\n-/\n\n\n#print Zsqrtd /-\n/-- The ring of integers adjoined with a square root of `d`.\n  These have the form `a + b √d` where `a b : ℤ`. The components\n  are called `re` and `im` by analogy to the negative `d` case. -/\nstructure Zsqrtd (d : ℤ) where\n  re : ℤ\n  im : ℤ\n#align zsqrtd Zsqrtd\n-/\n\n-- mathport name: «exprℤ√ »\nprefix:100 \"ℤ√\" => Zsqrtd\n\nnamespace Zsqrtd\n\nsection\n\nparameter {d : ℤ}\n\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic tactic.mk_dec_eq_instance -/\ninstance : DecidableEq (ℤ√d) := by\n  run_tac\n    tactic.mk_dec_eq_instance\n\n#print Zsqrtd.ext /-\ntheorem ext : ∀ {z w : ℤ√d}, z = w ↔ z.re = w.re ∧ z.im = w.im\n  | ⟨x, y⟩, ⟨x', y'⟩ =>\n    ⟨fun h => by injection h <;> constructor <;> assumption, fun ⟨h₁, h₂⟩ => by\n      congr <;> assumption⟩\n#align zsqrtd.ext Zsqrtd.ext\n-/\n\n#print Zsqrtd.ofInt /-\n/-- Convert an integer to a `ℤ√d` -/\ndef ofInt (n : ℤ) : ℤ√d :=\n  ⟨n, 0⟩\n#align zsqrtd.of_int Zsqrtd.ofInt\n-/\n\n#print Zsqrtd.ofInt_re /-\ntheorem ofInt_re (n : ℤ) : (of_int n).re = n :=\n  rfl\n#align zsqrtd.of_int_re Zsqrtd.ofInt_re\n-/\n\n#print Zsqrtd.ofInt_im /-\ntheorem ofInt_im (n : ℤ) : (of_int n).im = 0 :=\n  rfl\n#align zsqrtd.of_int_im Zsqrtd.ofInt_im\n-/\n\n/-- The zero of the ring -/\ninstance : Zero (ℤ√d) :=\n  ⟨of_int 0⟩\n\n#print Zsqrtd.zero_re /-\n@[simp]\ntheorem zero_re : (0 : ℤ√d).re = 0 :=\n  rfl\n#align zsqrtd.zero_re Zsqrtd.zero_re\n-/\n\n#print Zsqrtd.zero_im /-\n@[simp]\ntheorem zero_im : (0 : ℤ√d).im = 0 :=\n  rfl\n#align zsqrtd.zero_im Zsqrtd.zero_im\n-/\n\ninstance : Inhabited (ℤ√d) :=\n  ⟨0⟩\n\n/-- The one of the ring -/\ninstance : One (ℤ√d) :=\n  ⟨of_int 1⟩\n\n#print Zsqrtd.one_re /-\n@[simp]\ntheorem one_re : (1 : ℤ√d).re = 1 :=\n  rfl\n#align zsqrtd.one_re Zsqrtd.one_re\n-/\n\n#print Zsqrtd.one_im /-\n@[simp]\ntheorem one_im : (1 : ℤ√d).im = 0 :=\n  rfl\n#align zsqrtd.one_im Zsqrtd.one_im\n-/\n\n#print Zsqrtd.sqrtd /-\n/-- The representative of `√d` in the ring -/\ndef sqrtd : ℤ√d :=\n  ⟨0, 1⟩\n#align zsqrtd.sqrtd Zsqrtd.sqrtd\n-/\n\n#print Zsqrtd.sqrtd_re /-\n@[simp]\ntheorem sqrtd_re : (sqrtd : ℤ√d).re = 0 :=\n  rfl\n#align zsqrtd.sqrtd_re Zsqrtd.sqrtd_re\n-/\n\n#print Zsqrtd.sqrtd_im /-\n@[simp]\ntheorem sqrtd_im : (sqrtd : ℤ√d).im = 1 :=\n  rfl\n#align zsqrtd.sqrtd_im Zsqrtd.sqrtd_im\n-/\n\n/-- Addition of elements of `ℤ√d` -/\ninstance : Add (ℤ√d) :=\n  ⟨fun z w => ⟨z.1 + w.1, z.2 + w.2⟩⟩\n\n#print Zsqrtd.add_def /-\n@[simp]\ntheorem add_def (x y x' y' : ℤ) : (⟨x, y⟩ + ⟨x', y'⟩ : ℤ√d) = ⟨x + x', y + y'⟩ :=\n  rfl\n#align zsqrtd.add_def Zsqrtd.add_def\n-/\n\n#print Zsqrtd.add_re /-\n@[simp]\ntheorem add_re (z w : ℤ√d) : (z + w).re = z.re + w.re :=\n  rfl\n#align zsqrtd.add_re Zsqrtd.add_re\n-/\n\n#print Zsqrtd.add_im /-\n@[simp]\ntheorem add_im (z w : ℤ√d) : (z + w).im = z.im + w.im :=\n  rfl\n#align zsqrtd.add_im Zsqrtd.add_im\n-/\n\n#print Zsqrtd.bit0_re /-\n@[simp]\ntheorem bit0_re (z) : (bit0 z : ℤ√d).re = bit0 z.re :=\n  rfl\n#align zsqrtd.bit0_re Zsqrtd.bit0_re\n-/\n\n#print Zsqrtd.bit0_im /-\n@[simp]\ntheorem bit0_im (z) : (bit0 z : ℤ√d).im = bit0 z.im :=\n  rfl\n#align zsqrtd.bit0_im Zsqrtd.bit0_im\n-/\n\n#print Zsqrtd.bit1_re /-\n@[simp]\ntheorem bit1_re (z) : (bit1 z : ℤ√d).re = bit1 z.re :=\n  rfl\n#align zsqrtd.bit1_re Zsqrtd.bit1_re\n-/\n\n#print Zsqrtd.bit1_im /-\n@[simp]\ntheorem bit1_im (z) : (bit1 z : ℤ√d).im = bit0 z.im := by simp [bit1]\n#align zsqrtd.bit1_im Zsqrtd.bit1_im\n-/\n\n/-- Negation in `ℤ√d` -/\ninstance : Neg (ℤ√d) :=\n  ⟨fun z => ⟨-z.1, -z.2⟩⟩\n\n#print Zsqrtd.neg_re /-\n@[simp]\ntheorem neg_re (z : ℤ√d) : (-z).re = -z.re :=\n  rfl\n#align zsqrtd.neg_re Zsqrtd.neg_re\n-/\n\n#print Zsqrtd.neg_im /-\n@[simp]\ntheorem neg_im (z : ℤ√d) : (-z).im = -z.im :=\n  rfl\n#align zsqrtd.neg_im Zsqrtd.neg_im\n-/\n\n/-- Multiplication in `ℤ√d` -/\ninstance : Mul (ℤ√d) :=\n  ⟨fun z w => ⟨z.1 * w.1 + d * z.2 * w.2, z.1 * w.2 + z.2 * w.1⟩⟩\n\n#print Zsqrtd.mul_re /-\n@[simp]\ntheorem mul_re (z w : ℤ√d) : (z * w).re = z.re * w.re + d * z.im * w.im :=\n  rfl\n#align zsqrtd.mul_re Zsqrtd.mul_re\n-/\n\n#print Zsqrtd.mul_im /-\n@[simp]\ntheorem mul_im (z w : ℤ√d) : (z * w).im = z.re * w.im + z.im * w.re :=\n  rfl\n#align zsqrtd.mul_im Zsqrtd.mul_im\n-/\n\ninstance : AddCommGroup (ℤ√d) := by\n  refine_struct\n          { add := (· + ·)\n            zero := (0 : ℤ√d)\n            sub := fun a b => a + -b\n            neg := Neg.neg\n            zsmul := @zsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩ ⟨Neg.neg⟩\n            nsmul := @nsmulRec (ℤ√d) ⟨0⟩ ⟨(· + ·)⟩ } <;>\n        intros <;>\n      try rfl <;>\n    simp [ext, add_comm, add_left_comm]\n\ninstance : AddGroupWithOne (ℤ√d) :=\n  { Zsqrtd.addCommGroup with\n    natCast := fun n => of_int n\n    intCast := of_int\n    one := 1 }\n\ninstance : CommRing (ℤ√d) := by\n  refine_struct\n          { Zsqrtd.addGroupWithOne with\n            add := (· + ·)\n            zero := (0 : ℤ√d)\n            mul := (· * ·)\n            one := 1\n            npow := @npowRec (ℤ√d) ⟨1⟩ ⟨(· * ·)⟩ } <;>\n        intros <;>\n      try rfl <;>\n    simp [ext, add_mul, mul_add, add_comm, add_left_comm, mul_comm, mul_left_comm]\n\ninstance : AddMonoid (ℤ√d) := by infer_instance\n\ninstance : Monoid (ℤ√d) := by infer_instance\n\ninstance : CommMonoid (ℤ√d) := by infer_instance\n\ninstance : CommSemigroup (ℤ√d) := by infer_instance\n\ninstance : Semigroup (ℤ√d) := by infer_instance\n\ninstance : AddCommSemigroup (ℤ√d) := by infer_instance\n\ninstance : AddSemigroup (ℤ√d) := by infer_instance\n\ninstance : CommSemiring (ℤ√d) := by infer_instance\n\ninstance : Semiring (ℤ√d) := by infer_instance\n\ninstance : Ring (ℤ√d) := by infer_instance\n\ninstance : Distrib (ℤ√d) := by infer_instance\n\n/-- Conjugation in `ℤ√d`. The conjugate of `a + b √d` is `a - b √d`. -/\ninstance : Star (ℤ√d) where unit z := ⟨z.1, -z.2⟩\n\n#print Zsqrtd.star_mk /-\n@[simp]\ntheorem star_mk (x y : ℤ) : star (⟨x, y⟩ : ℤ√d) = ⟨x, -y⟩ :=\n  rfl\n#align zsqrtd.star_mk Zsqrtd.star_mk\n-/\n\n#print Zsqrtd.star_re /-\n@[simp]\ntheorem star_re (z : ℤ√d) : (star z).re = z.re :=\n  rfl\n#align zsqrtd.star_re Zsqrtd.star_re\n-/\n\n#print Zsqrtd.star_im /-\n@[simp]\ntheorem star_im (z : ℤ√d) : (star z).im = -z.im :=\n  rfl\n#align zsqrtd.star_im Zsqrtd.star_im\n-/\n\ninstance : StarRing (ℤ√d)\n    where\n  star_involutive x := ext.mpr ⟨rfl, neg_neg _⟩\n  star_mul a b := ext.mpr ⟨by simp <;> ring, by simp <;> ring⟩\n  star_add a b := ext.mpr ⟨rfl, neg_add _ _⟩\n\ninstance : Nontrivial (ℤ√d) :=\n  ⟨⟨0, 1, by decide⟩⟩\n\n#print Zsqrtd.coe_nat_re /-\n@[simp]\ntheorem coe_nat_re (n : ℕ) : (n : ℤ√d).re = n :=\n  rfl\n#align zsqrtd.coe_nat_re Zsqrtd.coe_nat_re\n-/\n\n#print Zsqrtd.coe_nat_im /-\n@[simp]\ntheorem coe_nat_im (n : ℕ) : (n : ℤ√d).im = 0 :=\n  rfl\n#align zsqrtd.coe_nat_im Zsqrtd.coe_nat_im\n-/\n\n#print Zsqrtd.coe_nat_val /-\ntheorem coe_nat_val (n : ℕ) : (n : ℤ√d) = ⟨n, 0⟩ :=\n  rfl\n#align zsqrtd.coe_nat_val Zsqrtd.coe_nat_val\n-/\n\n/- warning: zsqrtd.coe_int_re -> Zsqrtd.coe_int_re is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Int), Eq.{1} Int (Zsqrtd.re d ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n)) n\nbut is expected to have type\n  forall {d : Int} (n : Int), Eq.{1} Int (Zsqrtd.re d (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n)) n\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_re Zsqrtd.coe_int_reₓ'. -/\n@[simp]\ntheorem coe_int_re (n : ℤ) : (n : ℤ√d).re = n := by cases n <;> rfl\n#align zsqrtd.coe_int_re Zsqrtd.coe_int_re\n\n/- warning: zsqrtd.coe_int_im -> Zsqrtd.coe_int_im is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Int), Eq.{1} Int (Zsqrtd.im d ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n)) (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))\nbut is expected to have type\n  forall {d : Int} (n : Int), Eq.{1} Int (Zsqrtd.im d (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n)) (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_im Zsqrtd.coe_int_imₓ'. -/\n@[simp]\ntheorem coe_int_im (n : ℤ) : (n : ℤ√d).im = 0 := by cases n <;> rfl\n#align zsqrtd.coe_int_im Zsqrtd.coe_int_im\n\n/- warning: zsqrtd.coe_int_val -> Zsqrtd.coe_int_val is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Int), Eq.{1} (Zsqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n) (Zsqrtd.mk d n (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))))\nbut is expected to have type\n  forall {d : Int} (n : Int), Eq.{1} (Zsqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n) (Zsqrtd.mk d n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_val Zsqrtd.coe_int_valₓ'. -/\ntheorem coe_int_val (n : ℤ) : (n : ℤ√d) = ⟨n, 0⟩ := by simp [ext]\n#align zsqrtd.coe_int_val Zsqrtd.coe_int_val\n\ninstance : CharZero (ℤ√d) where cast_injective m n := by simp [ext]\n\n/- warning: zsqrtd.of_int_eq_coe -> Zsqrtd.ofInt_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Int), Eq.{1} (Zsqrtd d) (Zsqrtd.ofInt d n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n)\nbut is expected to have type\n  forall {d : Int} (n : Int), Eq.{1} (Zsqrtd d) (Zsqrtd.ofInt d n) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.of_int_eq_coe Zsqrtd.ofInt_eq_coeₓ'. -/\n@[simp]\ntheorem ofInt_eq_coe (n : ℤ) : (of_int n : ℤ√d) = n := by simp [ext, of_int_re, of_int_im]\n#align zsqrtd.of_int_eq_coe Zsqrtd.ofInt_eq_coe\n\n/- warning: zsqrtd.smul_val -> Zsqrtd.smul_val is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Int) (x : Int) (y : Int), Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n) (Zsqrtd.mk d x y)) (Zsqrtd.mk d (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) n x) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) n y))\nbut is expected to have type\n  forall {d : Int} (n : Int) (x : Int) (y : Int), Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n) (Zsqrtd.mk d x y)) (Zsqrtd.mk d (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) n x) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) n y))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.smul_val Zsqrtd.smul_valₓ'. -/\n@[simp]\ntheorem smul_val (n x y : ℤ) : (n : ℤ√d) * ⟨x, y⟩ = ⟨n * x, n * y⟩ := by simp [ext]\n#align zsqrtd.smul_val Zsqrtd.smul_val\n\n/- warning: zsqrtd.smul_re -> Zsqrtd.smul_re is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (a : Int) (b : Zsqrtd d), Eq.{1} Int (Zsqrtd.re d (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) a) b)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a (Zsqrtd.re d b))\nbut is expected to have type\n  forall {d : Int} (a : Int) (b : Zsqrtd d), Eq.{1} Int (Zsqrtd.re d (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) a) b)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a (Zsqrtd.re d b))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.smul_re Zsqrtd.smul_reₓ'. -/\ntheorem smul_re (a : ℤ) (b : ℤ√d) : (↑a * b).re = a * b.re := by simp\n#align zsqrtd.smul_re Zsqrtd.smul_re\n\n/- warning: zsqrtd.smul_im -> Zsqrtd.smul_im is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (a : Int) (b : Zsqrtd d), Eq.{1} Int (Zsqrtd.im d (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) a) b)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) a (Zsqrtd.im d b))\nbut is expected to have type\n  forall {d : Int} (a : Int) (b : Zsqrtd d), Eq.{1} Int (Zsqrtd.im d (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) a) b)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) a (Zsqrtd.im d b))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.smul_im Zsqrtd.smul_imₓ'. -/\ntheorem smul_im (a : ℤ) (b : ℤ√d) : (↑a * b).im = a * b.im := by simp\n#align zsqrtd.smul_im Zsqrtd.smul_im\n\n#print Zsqrtd.muld_val /-\n@[simp]\ntheorem muld_val (x y : ℤ) : sqrtd * ⟨x, y⟩ = ⟨d * y, x⟩ := by simp [ext]\n#align zsqrtd.muld_val Zsqrtd.muld_val\n-/\n\n/- warning: zsqrtd.dmuld -> Zsqrtd.dmuld is a dubious translation:\nlean 3 declaration is\n  forall {d : Int}, Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) (Zsqrtd.sqrtd d) (Zsqrtd.sqrtd d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) d)\nbut is expected to have type\n  forall {d : Int}, Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Zsqrtd.sqrtd d) (Zsqrtd.sqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) d)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.dmuld Zsqrtd.dmuldₓ'. -/\n@[simp]\ntheorem dmuld : sqrtd * sqrtd = d := by simp [ext]\n#align zsqrtd.dmuld Zsqrtd.dmuld\n\n/- warning: zsqrtd.smuld_val -> Zsqrtd.smuld_val is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Int) (x : Int) (y : Int), Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) (Zsqrtd.sqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n)) (Zsqrtd.mk d x y)) (Zsqrtd.mk d (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) d n) y) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) n x))\nbut is expected to have type\n  forall {d : Int} (n : Int) (x : Int) (y : Int), Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Zsqrtd.sqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n)) (Zsqrtd.mk d x y)) (Zsqrtd.mk d (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) d n) y) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) n x))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.smuld_val Zsqrtd.smuld_valₓ'. -/\n@[simp]\ntheorem smuld_val (n x y : ℤ) : sqrtd * (n : ℤ√d) * ⟨x, y⟩ = ⟨d * n * y, n * x⟩ := by simp [ext]\n#align zsqrtd.smuld_val Zsqrtd.smuld_val\n\n/- warning: zsqrtd.decompose -> Zsqrtd.decompose is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {x : Int} {y : Int}, Eq.{1} (Zsqrtd d) (Zsqrtd.mk d x y) (HAdd.hAdd.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHAdd.{0} (Zsqrtd d) (Zsqrtd.hasAdd d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) x) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) (Zsqrtd.sqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) y)))\nbut is expected to have type\n  forall {d : Int} {x : Int} {y : Int}, Eq.{1} (Zsqrtd d) (Zsqrtd.mk d x y) (HAdd.hAdd.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHAdd.{0} (Zsqrtd d) (Zsqrtd.instAddZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) x) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Zsqrtd.sqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) y)))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.decompose Zsqrtd.decomposeₓ'. -/\ntheorem decompose {x y : ℤ} : (⟨x, y⟩ : ℤ√d) = x + sqrtd * y := by simp [ext]\n#align zsqrtd.decompose Zsqrtd.decompose\n\n/- warning: zsqrtd.mul_star -> Zsqrtd.mul_star is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {x : Int} {y : Int}, Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) (Zsqrtd.mk d x y) (Star.star.{0} (Zsqrtd d) (Zsqrtd.hasStar d) (Zsqrtd.mk d x y))) (HSub.hSub.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHSub.{0} (Zsqrtd d) (SubNegMonoid.toHasSub.{0} (Zsqrtd d) (AddGroup.toSubNegMonoid.{0} (Zsqrtd d) (AddGroupWithOne.toAddGroup.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) x) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) x)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) y)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) y)))\nbut is expected to have type\n  forall {d : Int} {x : Int} {y : Int}, Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Zsqrtd.mk d x y) (Star.star.{0} (Zsqrtd d) (Zsqrtd.instStarZsqrtd d) (Zsqrtd.mk d x y))) (HSub.hSub.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHSub.{0} (Zsqrtd d) (Ring.toSub.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) x) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) x)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) y)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) y)))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.mul_star Zsqrtd.mul_starₓ'. -/\ntheorem mul_star {x y : ℤ} : (⟨x, y⟩ * star ⟨x, y⟩ : ℤ√d) = x * x - d * y * y := by\n  simp [ext, sub_eq_add_neg, mul_comm]\n#align zsqrtd.mul_star Zsqrtd.mul_star\n\n/- warning: zsqrtd.coe_int_add -> Zsqrtd.coe_int_add is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (m : Int) (n : Int), Eq.{1} (Zsqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) m n)) (HAdd.hAdd.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHAdd.{0} (Zsqrtd d) (Zsqrtd.hasAdd d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n))\nbut is expected to have type\n  forall {d : Int} (m : Int) (n : Int), Eq.{1} (Zsqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) m n)) (HAdd.hAdd.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHAdd.{0} (Zsqrtd d) (Zsqrtd.instAddZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) m) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_add Zsqrtd.coe_int_addₓ'. -/\nprotected theorem coe_int_add (m n : ℤ) : (↑(m + n) : ℤ√d) = ↑m + ↑n :=\n  (Int.castRingHom _).map_add _ _\n#align zsqrtd.coe_int_add Zsqrtd.coe_int_add\n\n/- warning: zsqrtd.coe_int_sub -> Zsqrtd.coe_int_sub is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (m : Int) (n : Int), Eq.{1} (Zsqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) m n)) (HSub.hSub.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHSub.{0} (Zsqrtd d) (SubNegMonoid.toHasSub.{0} (Zsqrtd d) (AddGroup.toSubNegMonoid.{0} (Zsqrtd d) (AddGroupWithOne.toAddGroup.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n))\nbut is expected to have type\n  forall {d : Int} (m : Int) (n : Int), Eq.{1} (Zsqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) m n)) (HSub.hSub.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHSub.{0} (Zsqrtd d) (Ring.toSub.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) m) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_sub Zsqrtd.coe_int_subₓ'. -/\nprotected theorem coe_int_sub (m n : ℤ) : (↑(m - n) : ℤ√d) = ↑m - ↑n :=\n  (Int.castRingHom _).map_sub _ _\n#align zsqrtd.coe_int_sub Zsqrtd.coe_int_sub\n\n/- warning: zsqrtd.coe_int_mul -> Zsqrtd.coe_int_mul is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (m : Int) (n : Int), Eq.{1} (Zsqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) m n)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n))\nbut is expected to have type\n  forall {d : Int} (m : Int) (n : Int), Eq.{1} (Zsqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) m n)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) m) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_mul Zsqrtd.coe_int_mulₓ'. -/\nprotected theorem coe_int_mul (m n : ℤ) : (↑(m * n) : ℤ√d) = ↑m * ↑n :=\n  (Int.castRingHom _).map_mul _ _\n#align zsqrtd.coe_int_mul Zsqrtd.coe_int_mul\n\n/- warning: zsqrtd.coe_int_inj -> Zsqrtd.coe_int_inj is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {m : Int} {n : Int}, (Eq.{1} (Zsqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n)) -> (Eq.{1} Int m n)\nbut is expected to have type\n  forall {d : Int} {m : Int} {n : Int}, (Eq.{1} (Zsqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) m) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n)) -> (Eq.{1} Int m n)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_inj Zsqrtd.coe_int_injₓ'. -/\nprotected theorem coe_int_inj {m n : ℤ} (h : (↑m : ℤ√d) = ↑n) : m = n := by\n  simpa using congr_arg re h\n#align zsqrtd.coe_int_inj Zsqrtd.coe_int_inj\n\n/- warning: zsqrtd.coe_int_dvd_iff -> Zsqrtd.coe_int_dvd_iff is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (z : Int) (a : Zsqrtd d), Iff (Dvd.Dvd.{0} (Zsqrtd d) (semigroupDvd.{0} (Zsqrtd d) (Zsqrtd.semigroup d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) z) a) (And (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) z (Zsqrtd.re d a)) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) z (Zsqrtd.im d a)))\nbut is expected to have type\n  forall {d : Int} (z : Int) (a : Zsqrtd d), Iff (Dvd.dvd.{0} (Zsqrtd d) (semigroupDvd.{0} (Zsqrtd d) (Zsqrtd.instSemigroupZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) z) a) (And (Dvd.dvd.{0} Int Int.instDvdInt z (Zsqrtd.re d a)) (Dvd.dvd.{0} Int Int.instDvdInt z (Zsqrtd.im d a)))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_dvd_iff Zsqrtd.coe_int_dvd_iffₓ'. -/\ntheorem coe_int_dvd_iff (z : ℤ) (a : ℤ√d) : ↑z ∣ a ↔ z ∣ a.re ∧ z ∣ a.im :=\n  by\n  constructor\n  · rintro ⟨x, rfl⟩\n    simp only [add_zero, coe_int_re, MulZeroClass.zero_mul, mul_im, dvd_mul_right, and_self_iff,\n      mul_re, MulZeroClass.mul_zero, coe_int_im]\n  · rintro ⟨⟨r, hr⟩, ⟨i, hi⟩⟩\n    use ⟨r, i⟩\n    rw [smul_val, ext]\n    exact ⟨hr, hi⟩\n#align zsqrtd.coe_int_dvd_iff Zsqrtd.coe_int_dvd_iff\n\n/- warning: zsqrtd.coe_int_dvd_coe_int -> Zsqrtd.coe_int_dvd_coe_int is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (a : Int) (b : Int), Iff (Dvd.Dvd.{0} (Zsqrtd d) (semigroupDvd.{0} (Zsqrtd d) (Zsqrtd.semigroup d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) a) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) b)) (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b)\nbut is expected to have type\n  forall {d : Int} (a : Int) (b : Int), Iff (Dvd.dvd.{0} (Zsqrtd d) (semigroupDvd.{0} (Zsqrtd d) (Zsqrtd.instSemigroupZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) a) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) b)) (Dvd.dvd.{0} Int Int.instDvdInt a b)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coe_int_dvd_coe_int Zsqrtd.coe_int_dvd_coe_intₓ'. -/\n@[simp, norm_cast]\ntheorem coe_int_dvd_coe_int (a b : ℤ) : (a : ℤ√d) ∣ b ↔ a ∣ b :=\n  by\n  rw [coe_int_dvd_iff]\n  constructor\n  · rintro ⟨hre, -⟩\n    rwa [coe_int_re] at hre\n  · rw [coe_int_re, coe_int_im]\n    exact fun hc => ⟨hc, dvd_zero a⟩\n#align zsqrtd.coe_int_dvd_coe_int Zsqrtd.coe_int_dvd_coe_int\n\n/- warning: zsqrtd.eq_of_smul_eq_smul_left -> Zsqrtd.eq_of_smul_eq_smul_left is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {a : Int} {b : Zsqrtd d} {c : Zsqrtd d}, (Ne.{1} Int a (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) a) b) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) a) c)) -> (Eq.{1} (Zsqrtd d) b c)\nbut is expected to have type\n  forall {d : Int} {a : Int} {b : Zsqrtd d} {c : Zsqrtd d}, (Ne.{1} Int a (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Eq.{1} (Zsqrtd d) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) a) b) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) a) c)) -> (Eq.{1} (Zsqrtd d) b c)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.eq_of_smul_eq_smul_left Zsqrtd.eq_of_smul_eq_smul_leftₓ'. -/\nprotected theorem eq_of_smul_eq_smul_left {a : ℤ} {b c : ℤ√d} (ha : a ≠ 0) (h : ↑a * b = a * c) :\n    b = c := by\n  rw [ext] at h⊢\n  apply And.imp _ _ h <;> · simpa only [smul_re, smul_im] using mul_left_cancel₀ ha\n#align zsqrtd.eq_of_smul_eq_smul_left Zsqrtd.eq_of_smul_eq_smul_left\n\nsection Gcd\n\n#print Zsqrtd.gcd_eq_zero_iff /-\ntheorem gcd_eq_zero_iff (a : ℤ√d) : Int.gcd a.re a.im = 0 ↔ a = 0 := by\n  simp only [Int.gcd_eq_zero_iff, ext, eq_self_iff_true, zero_im, zero_re]\n#align zsqrtd.gcd_eq_zero_iff Zsqrtd.gcd_eq_zero_iff\n-/\n\n#print Zsqrtd.gcd_pos_iff /-\ntheorem gcd_pos_iff (a : ℤ√d) : 0 < Int.gcd a.re a.im ↔ a ≠ 0 :=\n  pos_iff_ne_zero.trans <| not_congr a.gcd_eq_zero_iff\n#align zsqrtd.gcd_pos_iff Zsqrtd.gcd_pos_iff\n-/\n\n/- warning: zsqrtd.coprime_of_dvd_coprime -> Zsqrtd.coprime_of_dvd_coprime is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {a : Zsqrtd d} {b : Zsqrtd d}, (IsCoprime.{0} Int Int.commSemiring (Zsqrtd.re d a) (Zsqrtd.im d a)) -> (Dvd.Dvd.{0} (Zsqrtd d) (semigroupDvd.{0} (Zsqrtd d) (Zsqrtd.semigroup d)) b a) -> (IsCoprime.{0} Int Int.commSemiring (Zsqrtd.re d b) (Zsqrtd.im d b))\nbut is expected to have type\n  forall {d : Int} {a : Zsqrtd d} {b : Zsqrtd d}, (IsCoprime.{0} Int Int.instCommSemiringInt (Zsqrtd.re d a) (Zsqrtd.im d a)) -> (Dvd.dvd.{0} (Zsqrtd d) (semigroupDvd.{0} (Zsqrtd d) (Zsqrtd.instSemigroupZsqrtd d)) b a) -> (IsCoprime.{0} Int Int.instCommSemiringInt (Zsqrtd.re d b) (Zsqrtd.im d b))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.coprime_of_dvd_coprime Zsqrtd.coprime_of_dvd_coprimeₓ'. -/\ntheorem coprime_of_dvd_coprime {a b : ℤ√d} (hcoprime : IsCoprime a.re a.im) (hdvd : b ∣ a) :\n    IsCoprime b.re b.im := by\n  apply isCoprime_of_dvd\n  · rintro ⟨hre, him⟩\n    obtain rfl : b = 0 := by\n      simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re]\n    rw [zero_dvd_iff] at hdvd\n    simpa only [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] using hcoprime\n  · intro z hz hznezero hzdvdu hzdvdv\n    apply hz\n    obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im :=\n      by\n      rw [← coe_int_dvd_iff]\n      apply dvd_trans _ hdvd\n      rw [coe_int_dvd_iff]\n      exact ⟨hzdvdu, hzdvdv⟩\n    exact hcoprime.is_unit_of_dvd' ha hb\n#align zsqrtd.coprime_of_dvd_coprime Zsqrtd.coprime_of_dvd_coprime\n\n/- warning: zsqrtd.exists_coprime_of_gcd_pos -> Zsqrtd.exists_coprime_of_gcd_pos is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {a : Zsqrtd d}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) (Int.gcd (Zsqrtd.re d a) (Zsqrtd.im d a))) -> (Exists.{1} (Zsqrtd d) (fun (b : Zsqrtd d) => And (Eq.{1} (Zsqrtd d) a (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (Int.gcd (Zsqrtd.re d a) (Zsqrtd.im d a)))) b)) (IsCoprime.{0} Int Int.commSemiring (Zsqrtd.re d b) (Zsqrtd.im d b))))\nbut is expected to have type\n  forall {d : Int} {a : Zsqrtd d}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (Int.gcd (Zsqrtd.re d a) (Zsqrtd.im d a))) -> (Exists.{1} (Zsqrtd d) (fun (b : Zsqrtd d) => And (Eq.{1} (Zsqrtd d) a (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) (Nat.cast.{0} Int instNatCastInt (Int.gcd (Zsqrtd.re d a) (Zsqrtd.im d a)))) b)) (IsCoprime.{0} Int Int.instCommSemiringInt (Zsqrtd.re d b) (Zsqrtd.im d b))))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.exists_coprime_of_gcd_pos Zsqrtd.exists_coprime_of_gcd_posₓ'. -/\ntheorem exists_coprime_of_gcd_pos {a : ℤ√d} (hgcd : 0 < Int.gcd a.re a.im) :\n    ∃ b : ℤ√d, a = ((Int.gcd a.re a.im : ℤ) : ℤ√d) * b ∧ IsCoprime b.re b.im :=\n  by\n  obtain ⟨re, im, H1, Hre, Him⟩ := Int.exists_gcd_one hgcd\n  rw [mul_comm] at Hre Him\n  refine' ⟨⟨re, im⟩, _, _⟩\n  · rw [smul_val, ext, ← Hre, ← Him]\n    constructor <;> rfl\n  · rw [← Int.gcd_eq_one_iff_coprime, H1]\n#align zsqrtd.exists_coprime_of_gcd_pos Zsqrtd.exists_coprime_of_gcd_pos\n\nend Gcd\n\n#print Zsqrtd.SqLe /-\n/-- Read `sq_le a c b d` as `a √c ≤ b √d` -/\ndef SqLe (a c b d : ℕ) : Prop :=\n  c * a * a ≤ d * b * b\n#align zsqrtd.sq_le Zsqrtd.SqLe\n-/\n\n#print Zsqrtd.sqLe_of_le /-\ntheorem sqLe_of_le {c d x y z w : ℕ} (xz : z ≤ x) (yw : y ≤ w) (xy : SqLe x c y d) : SqLe z c w d :=\n  le_trans (mul_le_mul (Nat.mul_le_mul_left _ xz) xz (Nat.zero_le _) (Nat.zero_le _)) <|\n    le_trans xy (mul_le_mul (Nat.mul_le_mul_left _ yw) yw (Nat.zero_le _) (Nat.zero_le _))\n#align zsqrtd.sq_le_of_le Zsqrtd.sqLe_of_le\n-/\n\n#print Zsqrtd.sqLe_add_mixed /-\ntheorem sqLe_add_mixed {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) :\n    c * (x * z) ≤ d * (y * w) :=\n  Nat.mul_self_le_mul_self_iff.2 <| by\n    simpa [mul_comm, mul_left_comm] using mul_le_mul xy zw (Nat.zero_le _) (Nat.zero_le _)\n#align zsqrtd.sq_le_add_mixed Zsqrtd.sqLe_add_mixed\n-/\n\n#print Zsqrtd.sqLe_add /-\ntheorem sqLe_add {c d x y z w : ℕ} (xy : SqLe x c y d) (zw : SqLe z c w d) :\n    SqLe (x + z) c (y + w) d := by\n  have xz := sq_le_add_mixed xy zw\n  simp [sq_le, mul_assoc] at xy zw\n  simp [sq_le, mul_add, mul_comm, mul_left_comm, add_le_add, *]\n#align zsqrtd.sq_le_add Zsqrtd.sqLe_add\n-/\n\n#print Zsqrtd.sqLe_cancel /-\ntheorem sqLe_cancel {c d x y z w : ℕ} (zw : SqLe y d x c) (h : SqLe (x + z) c (y + w) d) :\n    SqLe z c w d := by\n  apply le_of_not_gt\n  intro l\n  refine' not_le_of_gt _ h\n  simp [sq_le, mul_add, mul_comm, mul_left_comm, add_assoc]\n  have hm := sq_le_add_mixed zw (le_of_lt l)\n  simp [sq_le, mul_assoc] at l zw\n  exact\n    lt_of_le_of_lt (add_le_add_right zw _)\n      (add_lt_add_left (add_lt_add_of_le_of_lt hm (add_lt_add_of_le_of_lt hm l)) _)\n#align zsqrtd.sq_le_cancel Zsqrtd.sqLe_cancel\n-/\n\n#print Zsqrtd.sqLe_smul /-\ntheorem sqLe_smul {c d x y : ℕ} (n : ℕ) (xy : SqLe x c y d) : SqLe (n * x) c (n * y) d := by\n  simpa [sq_le, mul_left_comm, mul_assoc] using Nat.mul_le_mul_left (n * n) xy\n#align zsqrtd.sq_le_smul Zsqrtd.sqLe_smul\n-/\n\n#print Zsqrtd.sqLe_mul /-\ntheorem sqLe_mul {d x y z w : ℕ} :\n    (SqLe x 1 y d → SqLe z 1 w d → SqLe (x * w + y * z) d (x * z + d * y * w) 1) ∧\n      (SqLe x 1 y d → SqLe w d z 1 → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧\n        (SqLe y d x 1 → SqLe z 1 w d → SqLe (x * z + d * y * w) 1 (x * w + y * z) d) ∧\n          (SqLe y d x 1 → SqLe w d z 1 → SqLe (x * w + y * z) d (x * z + d * y * w) 1) :=\n  by\n  refine' ⟨_, _, _, _⟩ <;>\n    · intro xy zw\n      have :=\n        Int.mul_nonneg (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le xy))\n          (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le zw))\n      refine' Int.le_of_ofNat_le_ofNat (le_of_sub_nonneg _)\n      convert this\n      simp only [one_mul, Int.ofNat_add, Int.ofNat_mul]\n      ring\n#align zsqrtd.sq_le_mul Zsqrtd.sqLe_mul\n-/\n\n#print Zsqrtd.Nonnegg /-\n/-- \"Generalized\" `nonneg`. `nonnegg c d x y` means `a √c + b √d ≥ 0`;\n  we are interested in the case `c = 1` but this is more symmetric -/\ndef Nonnegg (c d : ℕ) : ℤ → ℤ → Prop\n  | (a : ℕ), (b : ℕ) => True\n  | (a : ℕ), -[b+1] => SqLe (b + 1) c a d\n  | -[a+1], (b : ℕ) => SqLe (a + 1) d b c\n  | -[a+1], -[b+1] => False\n#align zsqrtd.nonnegg Zsqrtd.Nonnegg\n-/\n\n#print Zsqrtd.nonnegg_comm /-\ntheorem nonnegg_comm {c d : ℕ} {x y : ℤ} : Nonnegg c d x y = Nonnegg d c y x := by\n  induction x <;> induction y <;> rfl\n#align zsqrtd.nonnegg_comm Zsqrtd.nonnegg_comm\n-/\n\n#print Zsqrtd.nonnegg_neg_pos /-\ntheorem nonnegg_neg_pos {c d} : ∀ {a b : ℕ}, Nonnegg c d (-a) b ↔ SqLe a d b c\n  | 0, b => ⟨by simp [sq_le, Nat.zero_le], fun a => trivial⟩\n  | a + 1, b => by rw [← Int.negSucc_coe] <;> rfl\n#align zsqrtd.nonnegg_neg_pos Zsqrtd.nonnegg_neg_pos\n-/\n\n#print Zsqrtd.nonnegg_pos_neg /-\ntheorem nonnegg_pos_neg {c d} {a b : ℕ} : Nonnegg c d a (-b) ↔ SqLe b c a d := by\n  rw [nonnegg_comm] <;> exact nonnegg_neg_pos\n#align zsqrtd.nonnegg_pos_neg Zsqrtd.nonnegg_pos_neg\n-/\n\n#print Zsqrtd.nonnegg_cases_right /-\ntheorem nonnegg_cases_right {c d} {a : ℕ} :\n    ∀ {b : ℤ}, (∀ x : ℕ, b = -x → SqLe x c a d) → Nonnegg c d a b\n  | (b : Nat), h => trivial\n  | -[b+1], h => h (b + 1) rfl\n#align zsqrtd.nonnegg_cases_right Zsqrtd.nonnegg_cases_right\n-/\n\n#print Zsqrtd.nonnegg_cases_left /-\ntheorem nonnegg_cases_left {c d} {b : ℕ} {a : ℤ} (h : ∀ x : ℕ, a = -x → SqLe x d b c) :\n    Nonnegg c d a b :=\n  cast nonnegg_comm (nonnegg_cases_right h)\n#align zsqrtd.nonnegg_cases_left Zsqrtd.nonnegg_cases_left\n-/\n\nsection Norm\n\n#print Zsqrtd.norm /-\n/-- The norm of an element of `ℤ[√d]`. -/\ndef norm (n : ℤ√d) : ℤ :=\n  n.re * n.re - d * n.im * n.im\n#align zsqrtd.norm Zsqrtd.norm\n-/\n\n#print Zsqrtd.norm_def /-\ntheorem norm_def (n : ℤ√d) : n.norm = n.re * n.re - d * n.im * n.im :=\n  rfl\n#align zsqrtd.norm_def Zsqrtd.norm_def\n-/\n\n#print Zsqrtd.norm_zero /-\n@[simp]\ntheorem norm_zero : norm 0 = 0 := by simp [norm]\n#align zsqrtd.norm_zero Zsqrtd.norm_zero\n-/\n\n#print Zsqrtd.norm_one /-\n@[simp]\ntheorem norm_one : norm 1 = 1 := by simp [norm]\n#align zsqrtd.norm_one Zsqrtd.norm_one\n-/\n\n/- warning: zsqrtd.norm_int_cast -> Zsqrtd.norm_int_cast is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Int), Eq.{1} Int (Zsqrtd.norm d ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) n)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) n n)\nbut is expected to have type\n  forall {d : Int} (n : Int), Eq.{1} Int (Zsqrtd.norm d (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) n)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) n n)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.norm_int_cast Zsqrtd.norm_int_castₓ'. -/\n@[simp]\ntheorem norm_int_cast (n : ℤ) : norm n = n * n := by simp [norm]\n#align zsqrtd.norm_int_cast Zsqrtd.norm_int_cast\n\n#print Zsqrtd.norm_nat_cast /-\n@[simp]\ntheorem norm_nat_cast (n : ℕ) : norm n = n * n :=\n  norm_int_cast n\n#align zsqrtd.norm_nat_cast Zsqrtd.norm_nat_cast\n-/\n\n#print Zsqrtd.norm_mul /-\n@[simp]\ntheorem norm_mul (n m : ℤ√d) : norm (n * m) = norm n * norm m :=\n  by\n  simp only [norm, mul_im, mul_re]\n  ring\n#align zsqrtd.norm_mul Zsqrtd.norm_mul\n-/\n\n/- warning: zsqrtd.norm_monoid_hom -> Zsqrtd.normMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {d : Int}, MonoidHom.{0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.ring))))\nbut is expected to have type\n  forall {d : Int}, MonoidHom.{0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt))))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.norm_monoid_hom Zsqrtd.normMonoidHomₓ'. -/\n/-- `norm` as a `monoid_hom`. -/\ndef normMonoidHom : ℤ√d →* ℤ where\n  toFun := norm\n  map_mul' := norm_mul\n  map_one' := norm_one\n#align zsqrtd.norm_monoid_hom Zsqrtd.normMonoidHom\n\n/- warning: zsqrtd.norm_eq_mul_conj -> Zsqrtd.norm_eq_mul_conj is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (n : Zsqrtd d), Eq.{1} (Zsqrtd d) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int (Zsqrtd d) (HasLiftT.mk.{1, 1} Int (Zsqrtd d) (CoeTCₓ.coe.{1, 1} Int (Zsqrtd d) (Int.castCoe.{0} (Zsqrtd d) (AddGroupWithOne.toHasIntCast.{0} (Zsqrtd d) (Zsqrtd.addGroupWithOne d))))) (Zsqrtd.norm d n)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.hasMul d)) n (Star.star.{0} (Zsqrtd d) (Zsqrtd.hasStar d) n))\nbut is expected to have type\n  forall {d : Int} (n : Zsqrtd d), Eq.{1} (Zsqrtd d) (Int.cast.{0} (Zsqrtd d) (Ring.toIntCast.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)) (Zsqrtd.norm d n)) (HMul.hMul.{0, 0, 0} (Zsqrtd d) (Zsqrtd d) (Zsqrtd d) (instHMul.{0} (Zsqrtd d) (Zsqrtd.instMulZsqrtd d)) n (Star.star.{0} (Zsqrtd d) (Zsqrtd.instStarZsqrtd d) n))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.norm_eq_mul_conj Zsqrtd.norm_eq_mul_conjₓ'. -/\ntheorem norm_eq_mul_conj (n : ℤ√d) : (norm n : ℤ√d) = n * star n := by\n  cases n <;> simp [norm, star, Zsqrtd.ext, mul_comm, sub_eq_add_neg]\n#align zsqrtd.norm_eq_mul_conj Zsqrtd.norm_eq_mul_conj\n\n#print Zsqrtd.norm_neg /-\n@[simp]\ntheorem norm_neg (x : ℤ√d) : (-x).norm = x.norm :=\n  coe_int_inj <| by simp only [norm_eq_mul_conj, star_neg, neg_mul, mul_neg, neg_neg]\n#align zsqrtd.norm_neg Zsqrtd.norm_neg\n-/\n\n#print Zsqrtd.norm_conj /-\n@[simp]\ntheorem norm_conj (x : ℤ√d) : (star x).norm = x.norm :=\n  coe_int_inj <| by simp only [norm_eq_mul_conj, star_star, mul_comm]\n#align zsqrtd.norm_conj Zsqrtd.norm_conj\n-/\n\n#print Zsqrtd.norm_nonneg /-\ntheorem norm_nonneg (hd : d ≤ 0) (n : ℤ√d) : 0 ≤ n.norm :=\n  add_nonneg (mul_self_nonneg _)\n    (by\n      rw [mul_assoc, neg_mul_eq_neg_mul] <;> exact mul_nonneg (neg_nonneg.2 hd) (mul_self_nonneg _))\n#align zsqrtd.norm_nonneg Zsqrtd.norm_nonneg\n-/\n\n/- warning: zsqrtd.norm_eq_one_iff -> Zsqrtd.norm_eq_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {x : Zsqrtd d}, Iff (Eq.{1} Nat (Int.natAbs (Zsqrtd.norm d x)) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (IsUnit.{0} (Zsqrtd d) (Zsqrtd.monoid d) x)\nbut is expected to have type\n  forall {d : Int} {x : Zsqrtd d}, Iff (Eq.{1} Nat (Int.natAbs (Zsqrtd.norm d x)) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (IsUnit.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) x)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.norm_eq_one_iff Zsqrtd.norm_eq_one_iffₓ'. -/\ntheorem norm_eq_one_iff {x : ℤ√d} : x.norm.natAbs = 1 ↔ IsUnit x :=\n  ⟨fun h =>\n    isUnit_iff_dvd_one.2 <|\n      (le_total 0 (norm x)).casesOn\n        (fun hx =>\n          show x ∣ 1 from\n            ⟨star x, by\n              rwa [← Int.coe_nat_inj', Int.natAbs_of_nonneg hx, ← @Int.cast_inj (ℤ√d) _ _,\n                norm_eq_mul_conj, eq_comm] at h⟩)\n        fun hx =>\n        show x ∣ 1 from\n          ⟨-star x, by\n            rwa [← Int.coe_nat_inj', Int.ofNat_natAbs_of_nonpos hx, ← @Int.cast_inj (ℤ√d) _ _,\n              Int.cast_neg, norm_eq_mul_conj, neg_mul_eq_mul_neg, eq_comm] at h⟩,\n    fun h => by\n    let ⟨y, hy⟩ := isUnit_iff_dvd_one.1 h\n    have := congr_arg (Int.natAbs ∘ norm) hy\n    rw [Function.comp_apply, Function.comp_apply, norm_mul, Int.natAbs_mul, norm_one,\n      Int.natAbs_one, eq_comm, Nat.mul_eq_one_iff] at this\n    exact this.1⟩\n#align zsqrtd.norm_eq_one_iff Zsqrtd.norm_eq_one_iff\n\n/- warning: zsqrtd.is_unit_iff_norm_is_unit -> Zsqrtd.isUnit_iff_norm_isUnit is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} (z : Zsqrtd d), Iff (IsUnit.{0} (Zsqrtd d) (Zsqrtd.monoid d) z) (IsUnit.{0} Int Int.monoid (Zsqrtd.norm d z))\nbut is expected to have type\n  forall {d : Int} (z : Zsqrtd d), Iff (IsUnit.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) z) (IsUnit.{0} Int Int.instMonoidInt (Zsqrtd.norm d z))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.is_unit_iff_norm_is_unit Zsqrtd.isUnit_iff_norm_isUnitₓ'. -/\ntheorem isUnit_iff_norm_isUnit {d : ℤ} (z : ℤ√d) : IsUnit z ↔ IsUnit z.norm := by\n  rw [Int.isUnit_iff_natAbs_eq, norm_eq_one_iff]\n#align zsqrtd.is_unit_iff_norm_is_unit Zsqrtd.isUnit_iff_norm_isUnit\n\n/- warning: zsqrtd.norm_eq_one_iff' -> Zsqrtd.norm_eq_one_iff' is a dubious translation:\nlean 3 declaration is\n  forall {d : Int}, (LE.le.{0} Int Int.hasLe d (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (forall (z : Zsqrtd d), Iff (Eq.{1} Int (Zsqrtd.norm d z) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (IsUnit.{0} (Zsqrtd d) (Zsqrtd.monoid d) z))\nbut is expected to have type\n  forall {d : Int}, (LE.le.{0} Int Int.instLEInt d (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (forall (z : Zsqrtd d), Iff (Eq.{1} Int (Zsqrtd.norm d z) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (IsUnit.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) z))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.norm_eq_one_iff' Zsqrtd.norm_eq_one_iff'ₓ'. -/\ntheorem norm_eq_one_iff' {d : ℤ} (hd : d ≤ 0) (z : ℤ√d) : z.norm = 1 ↔ IsUnit z := by\n  rw [← norm_eq_one_iff, ← Int.coe_nat_inj', Int.natAbs_of_nonneg (norm_nonneg hd z), Int.ofNat_one]\n#align zsqrtd.norm_eq_one_iff' Zsqrtd.norm_eq_one_iff'\n\n#print Zsqrtd.norm_eq_zero_iff /-\ntheorem norm_eq_zero_iff {d : ℤ} (hd : d < 0) (z : ℤ√d) : z.norm = 0 ↔ z = 0 :=\n  by\n  constructor\n  · intro h\n    rw [ext, zero_re, zero_im]\n    rw [norm_def, sub_eq_add_neg, mul_assoc] at h\n    have left := mul_self_nonneg z.re\n    have right := neg_nonneg.mpr (mul_nonpos_of_nonpos_of_nonneg hd.le (mul_self_nonneg z.im))\n    obtain ⟨ha, hb⟩ := (add_eq_zero_iff' left right).mp h\n    constructor <;> apply eq_zero_of_mul_self_eq_zero\n    · exact ha\n    · rw [neg_eq_zero, mul_eq_zero] at hb\n      exact hb.resolve_left hd.ne\n  · rintro rfl\n    exact norm_zero\n#align zsqrtd.norm_eq_zero_iff Zsqrtd.norm_eq_zero_iff\n-/\n\n/- warning: zsqrtd.norm_eq_of_associated -> Zsqrtd.norm_eq_of_associated is a dubious translation:\nlean 3 declaration is\n  forall {d : Int}, (LE.le.{0} Int Int.hasLe d (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (forall {x : Zsqrtd d} {y : Zsqrtd d}, (Associated.{0} (Zsqrtd d) (Zsqrtd.monoid d) x y) -> (Eq.{1} Int (Zsqrtd.norm d x) (Zsqrtd.norm d y)))\nbut is expected to have type\n  forall {d : Int}, (LE.le.{0} Int Int.instLEInt d (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (forall {x : Zsqrtd d} {y : Zsqrtd d}, (Associated.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) x y) -> (Eq.{1} Int (Zsqrtd.norm d x) (Zsqrtd.norm d y)))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.norm_eq_of_associated Zsqrtd.norm_eq_of_associatedₓ'. -/\ntheorem norm_eq_of_associated {d : ℤ} (hd : d ≤ 0) {x y : ℤ√d} (h : Associated x y) :\n    x.norm = y.norm := by\n  obtain ⟨u, rfl⟩ := h\n  rw [norm_mul, (norm_eq_one_iff' hd _).mpr u.is_unit, mul_one]\n#align zsqrtd.norm_eq_of_associated Zsqrtd.norm_eq_of_associated\n\nend Norm\n\nend\n\nsection\n\nparameter {d : ℕ}\n\n#print Zsqrtd.Nonneg /-\n/-- Nonnegativity of an element of `ℤ√d`. -/\ndef Nonneg : ℤ√d → Prop\n  | ⟨a, b⟩ => Nonnegg d 1 a b\n#align zsqrtd.nonneg Zsqrtd.Nonneg\n-/\n\ninstance : LE (ℤ√d) :=\n  ⟨fun a b => nonneg (b - a)⟩\n\ninstance : LT (ℤ√d) :=\n  ⟨fun a b => ¬b ≤ a⟩\n\n#print Zsqrtd.decidableNonnegg /-\ninstance decidableNonnegg (c d a b) : Decidable (Nonnegg c d a b) := by\n  cases a <;> cases b <;> repeat' rw [Int.ofNat_eq_coe] <;> unfold nonnegg sq_le <;> infer_instance\n#align zsqrtd.decidable_nonnegg Zsqrtd.decidableNonnegg\n-/\n\n#print Zsqrtd.decidableNonneg /-\ninstance decidableNonneg : ∀ a : ℤ√d, Decidable (nonneg a)\n  | ⟨a, b⟩ => Zsqrtd.decidableNonnegg _ _ _ _\n#align zsqrtd.decidable_nonneg Zsqrtd.decidableNonneg\n-/\n\n/- warning: zsqrtd.decidable_le -> Zsqrtd.decidableLE is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat}, DecidableRel.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d))\nbut is expected to have type\n  forall {d : Nat}, DecidableRel.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (fun (x._@.Mathlib.NumberTheory.Zsqrtd.Basic._hyg.7392 : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (x._@.Mathlib.NumberTheory.Zsqrtd.Basic._hyg.7394 : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) => LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) x._@.Mathlib.NumberTheory.Zsqrtd.Basic._hyg.7392 x._@.Mathlib.NumberTheory.Zsqrtd.Basic._hyg.7394)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.decidable_le Zsqrtd.decidableLEₓ'. -/\ninstance decidableLE : @DecidableRel (ℤ√d) (· ≤ ·) := fun _ _ => decidable_nonneg _\n#align zsqrtd.decidable_le Zsqrtd.decidableLE\n\n#print Zsqrtd.nonneg_cases /-\ntheorem nonneg_cases : ∀ {a : ℤ√d}, nonneg a → ∃ x y : ℕ, a = ⟨x, y⟩ ∨ a = ⟨x, -y⟩ ∨ a = ⟨-x, y⟩\n  | ⟨(x : ℕ), (y : ℕ)⟩, h => ⟨x, y, Or.inl rfl⟩\n  | ⟨(x : ℕ), -[y+1]⟩, h => ⟨x, y + 1, Or.inr <| Or.inl rfl⟩\n  | ⟨-[x+1], (y : ℕ)⟩, h => ⟨x + 1, y, Or.inr <| Or.inr rfl⟩\n  | ⟨-[x+1], -[y+1]⟩, h => False.elim h\n#align zsqrtd.nonneg_cases Zsqrtd.nonneg_cases\n-/\n\n#print Zsqrtd.nonneg_add_lem /-\ntheorem nonneg_add_lem {x y z w : ℕ} (xy : nonneg ⟨x, -y⟩) (zw : nonneg ⟨-z, w⟩) :\n    nonneg (⟨x, -y⟩ + ⟨-z, w⟩) :=\n  have : nonneg ⟨Int.subNatNat x z, Int.subNatNat w y⟩ :=\n    Int.subNatNat_elim x z\n      (fun m n i => SqLe y d m 1 → SqLe n 1 w d → nonneg ⟨i, Int.subNatNat w y⟩)\n      (fun j k =>\n        Int.subNatNat_elim w y\n          (fun m n i => SqLe n d (k + j) 1 → SqLe k 1 m d → nonneg ⟨Int.ofNat j, i⟩)\n          (fun m n xy zw => trivial) fun m n xy zw => sqLe_cancel zw xy)\n      (fun j k =>\n        Int.subNatNat_elim w y\n          (fun m n i => SqLe n d k 1 → SqLe (k + j + 1) 1 m d → nonneg ⟨-[j+1], i⟩)\n          (fun m n xy zw => sqLe_cancel xy zw) fun m n xy zw =>\n          let t := Nat.le_trans zw (sqLe_of_le (Nat.le_add_right n (m + 1)) le_rfl xy)\n          have : k + j + 1 ≤ k :=\n            Nat.mul_self_le_mul_self_iff.2 (by repeat' rw [one_mul] at t <;> exact t)\n          absurd this (not_le_of_gt <| Nat.succ_le_succ <| Nat.le_add_right _ _))\n      (nonnegg_pos_neg.1 xy) (nonnegg_neg_pos.1 zw)\n  show nonneg ⟨_, _⟩ by\n    rw [neg_add_eq_sub] <;> rwa [Int.subNatNat_eq_coe, Int.subNatNat_eq_coe] at this\n#align zsqrtd.nonneg_add_lem Zsqrtd.nonneg_add_lem\n-/\n\n#print Zsqrtd.Nonneg.add /-\ntheorem Nonneg.add {a b : ℤ√d} (ha : nonneg a) (hb : nonneg b) : nonneg (a + b) :=\n  by\n  rcases nonneg_cases ha with ⟨x, y, rfl | rfl | rfl⟩ <;>\n    rcases nonneg_cases hb with ⟨z, w, rfl | rfl | rfl⟩\n  · trivial\n  · refine' nonnegg_cases_right fun i h => sq_le_of_le _ _ (nonnegg_pos_neg.1 hb)\n    · exact Int.ofNat_le.1 (le_of_neg_le_neg (@Int.le.intro _ _ y (by simp [add_comm, *])))\n    · apply Nat.le_add_left\n  · refine' nonnegg_cases_left fun i h => sq_le_of_le _ _ (nonnegg_neg_pos.1 hb)\n    · exact Int.ofNat_le.1 (le_of_neg_le_neg (@Int.le.intro _ _ x (by simp [add_comm, *])))\n    · apply Nat.le_add_left\n  · refine' nonnegg_cases_right fun i h => sq_le_of_le _ _ (nonnegg_pos_neg.1 ha)\n    · exact Int.ofNat_le.1 (le_of_neg_le_neg (@Int.le.intro _ _ w (by simp [*])))\n    · apply Nat.le_add_right\n  ·\n    simpa [add_comm] using\n      nonnegg_pos_neg.2 (sq_le_add (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb))\n  · exact nonneg_add_lem ha hb\n  · refine' nonnegg_cases_left fun i h => sq_le_of_le _ _ (nonnegg_neg_pos.1 ha)\n    · exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro h))\n    · apply Nat.le_add_right\n  · dsimp\n    rw [add_comm, add_comm ↑y]\n    exact nonneg_add_lem hb ha\n  ·\n    simpa [add_comm] using\n      nonnegg_neg_pos.2 (sq_le_add (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb))\n#align zsqrtd.nonneg.add Zsqrtd.Nonneg.add\n-/\n\n/- warning: zsqrtd.nonneg_iff_zero_le -> Zsqrtd.nonneg_iff_zero_le is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} {a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)}, Iff (Zsqrtd.Nonneg d a) (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (Zero.zero.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasZero ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))) a)\nbut is expected to have type\n  forall {d : Nat} {a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)}, Iff (Zsqrtd.Nonneg d a) (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) 0 (Zero.toOfNat0.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instZeroZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) a)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.nonneg_iff_zero_le Zsqrtd.nonneg_iff_zero_leₓ'. -/\ntheorem nonneg_iff_zero_le {a : ℤ√d} : nonneg a ↔ 0 ≤ a :=\n  show _ ↔ nonneg _ by simp\n#align zsqrtd.nonneg_iff_zero_le Zsqrtd.nonneg_iff_zero_le\n\n/- warning: zsqrtd.le_of_le_le -> Zsqrtd.le_of_le_le is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} {x : Int} {y : Int} {z : Int} {w : Int}, (LE.le.{0} Int Int.hasLe x z) -> (LE.le.{0} Int Int.hasLe y w) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) (Zsqrtd.mk ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d) x y) (Zsqrtd.mk ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d) z w))\nbut is expected to have type\n  forall {d : Nat} {x : Int} {y : Int} {z : Int} {w : Int}, (LE.le.{0} Int Int.instLEInt x z) -> (LE.le.{0} Int Int.instLEInt y w) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) (Zsqrtd.mk (Nat.cast.{0} Int instNatCastInt d) x y) (Zsqrtd.mk (Nat.cast.{0} Int instNatCastInt d) z w))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.le_of_le_le Zsqrtd.le_of_le_leₓ'. -/\ntheorem le_of_le_le {x y z w : ℤ} (xz : x ≤ z) (yw : y ≤ w) : (⟨x, y⟩ : ℤ√d) ≤ ⟨z, w⟩ :=\n  show nonneg ⟨z - x, w - y⟩ from\n    match z - x, w - y, Int.le.dest_sub xz, Int.le.dest_sub yw with\n    | _, _, ⟨a, rfl⟩, ⟨b, rfl⟩ => trivial\n#align zsqrtd.le_of_le_le Zsqrtd.le_of_le_le\n\n#print Zsqrtd.nonneg_total /-\nprotected theorem nonneg_total : ∀ a : ℤ√d, nonneg a ∨ nonneg (-a)\n  | ⟨(x : ℕ), (y : ℕ)⟩ => Or.inl trivial\n  | ⟨-[x+1], -[y+1]⟩ => Or.inr trivial\n  | ⟨0, -[y+1]⟩ => Or.inr trivial\n  | ⟨-[x+1], 0⟩ => Or.inr trivial\n  | ⟨(x + 1 : ℕ), -[y+1]⟩ => Nat.le_total\n  | ⟨-[x+1], (y + 1 : ℕ)⟩ => Nat.le_total\n#align zsqrtd.nonneg_total Zsqrtd.nonneg_total\n-/\n\n/- warning: zsqrtd.le_total -> Zsqrtd.le_total is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} (a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), Or (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) a b) (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) b a)\nbut is expected to have type\n  forall {d : Nat} (a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), Or (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) a b) (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) b a)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.le_total Zsqrtd.le_totalₓ'. -/\nprotected theorem le_total (a b : ℤ√d) : a ≤ b ∨ b ≤ a :=\n  by\n  have t := (b - a).nonneg_total\n  rwa [neg_sub] at t\n#align zsqrtd.le_total Zsqrtd.le_total\n\ninstance : Preorder (ℤ√d) where\n  le := (· ≤ ·)\n  le_refl a := show nonneg (a - a) by simp only [sub_self]\n  le_trans a b c hab hbc := by simpa [sub_add_sub_cancel'] using hab.add hbc\n  lt := (· < ·)\n  lt_iff_le_not_le a b := (and_iff_right_of_imp (Zsqrtd.le_total _ _).resolve_left).symm\n\n/- warning: zsqrtd.le_arch -> Zsqrtd.le_arch is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} (a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), Exists.{1} Nat (fun (n : Nat) => LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) a ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (HasLiftT.mk.{1, 1} Nat (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (CoeTCₓ.coe.{1, 1} Nat (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Nat.castCoe.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (AddMonoidWithOne.toNatCast.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (AddGroupWithOne.toAddMonoidWithOne.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.addGroupWithOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))))) n))\nbut is expected to have type\n  forall {d : Nat} (a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), Exists.{1} Nat (fun (n : Nat) => LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) a (Nat.cast.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (NonAssocRing.toNatCast.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Ring.toNonAssocRing.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instRingZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) n))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.le_arch Zsqrtd.le_archₓ'. -/\ntheorem le_arch (a : ℤ√d) : ∃ n : ℕ, a ≤ n :=\n  by\n  let ⟨x, y, (h : a ≤ ⟨x, y⟩)⟩ :=\n    show ∃ x y : ℕ, nonneg (⟨x, y⟩ + -a) from\n      match -a with\n      | ⟨Int.ofNat x, Int.ofNat y⟩ => ⟨0, 0, trivial⟩\n      | ⟨Int.ofNat x, -[y+1]⟩ => ⟨0, y + 1, by simp [Int.negSucc_coe, add_assoc]⟩\n      | ⟨-[x+1], Int.ofNat y⟩ => ⟨x + 1, 0, by simp [Int.negSucc_coe, add_assoc]⟩\n      | ⟨-[x+1], -[y+1]⟩ => ⟨x + 1, y + 1, by simp [Int.negSucc_coe, add_assoc]⟩\n  refine' ⟨x + d * y, h.trans _⟩\n  change nonneg ⟨↑x + d * y - ↑x, 0 - ↑y⟩\n  cases' y with y\n  · simp\n  have h : ∀ y, sq_le y d (d * y) 1 := fun y => by\n    simpa [sq_le, mul_comm, mul_left_comm] using Nat.mul_le_mul_right (y * y) (Nat.le_mul_self d)\n  rw [show (x : ℤ) + d * Nat.succ y - x = d * Nat.succ y by simp]\n  exact h (y + 1)\n#align zsqrtd.le_arch Zsqrtd.le_arch\n\n/- warning: zsqrtd.add_le_add_left -> Zsqrtd.add_le_add_left is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} (a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) a b) -> (forall (c : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) (HAdd.hAdd.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHAdd.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasAdd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) c a) (HAdd.hAdd.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHAdd.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasAdd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) c b))\nbut is expected to have type\n  forall {d : Nat} (a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) a b) -> (forall (c : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) (HAdd.hAdd.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHAdd.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instAddZsqrtd (Nat.cast.{0} Int instNatCastInt d))) c a) (HAdd.hAdd.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHAdd.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instAddZsqrtd (Nat.cast.{0} Int instNatCastInt d))) c b))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.add_le_add_left Zsqrtd.add_le_add_leftₓ'. -/\nprotected theorem add_le_add_left (a b : ℤ√d) (ab : a ≤ b) (c : ℤ√d) : c + a ≤ c + b :=\n  show nonneg _ by rw [add_sub_add_left_eq_sub] <;> exact ab\n#align zsqrtd.add_le_add_left Zsqrtd.add_le_add_left\n\n/- warning: zsqrtd.le_of_add_le_add_left -> Zsqrtd.le_of_add_le_add_left is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} (a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (c : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) (HAdd.hAdd.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHAdd.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasAdd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) c a) (HAdd.hAdd.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHAdd.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasAdd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) c b)) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) a b)\nbut is expected to have type\n  forall {d : Nat} (a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (c : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) (HAdd.hAdd.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHAdd.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instAddZsqrtd (Nat.cast.{0} Int instNatCastInt d))) c a) (HAdd.hAdd.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHAdd.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instAddZsqrtd (Nat.cast.{0} Int instNatCastInt d))) c b)) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) a b)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.le_of_add_le_add_left Zsqrtd.le_of_add_le_add_leftₓ'. -/\nprotected theorem le_of_add_le_add_left (a b c : ℤ√d) (h : c + a ≤ c + b) : a ≤ b := by\n  simpa using Zsqrtd.add_le_add_left _ _ h (-c)\n#align zsqrtd.le_of_add_le_add_left Zsqrtd.le_of_add_le_add_left\n\n/- warning: zsqrtd.add_lt_add_left -> Zsqrtd.add_lt_add_left is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} (a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), (LT.lt.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLt d) a b) -> (forall (c : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), LT.lt.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLt d) (HAdd.hAdd.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHAdd.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasAdd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) c a) (HAdd.hAdd.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHAdd.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasAdd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) c b))\nbut is expected to have type\n  forall {d : Nat} (a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), (LT.lt.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLTZsqrtdCastIntInstNatCastInt d) a b) -> (forall (c : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), LT.lt.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLTZsqrtdCastIntInstNatCastInt d) (HAdd.hAdd.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHAdd.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instAddZsqrtd (Nat.cast.{0} Int instNatCastInt d))) c a) (HAdd.hAdd.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHAdd.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instAddZsqrtd (Nat.cast.{0} Int instNatCastInt d))) c b))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.add_lt_add_left Zsqrtd.add_lt_add_leftₓ'. -/\nprotected theorem add_lt_add_left (a b : ℤ√d) (h : a < b) (c) : c + a < c + b := fun h' =>\n  h (Zsqrtd.le_of_add_le_add_left _ _ _ h')\n#align zsqrtd.add_lt_add_left Zsqrtd.add_lt_add_left\n\n#print Zsqrtd.nonneg_smul /-\ntheorem nonneg_smul {a : ℤ√d} {n : ℕ} (ha : nonneg a) : nonneg (n * a) := by\n  simp (config := { singlePass := true }) only [← Int.cast_ofNat] <;>\n    exact\n      match a, nonneg_cases ha, ha with\n      | _, ⟨x, y, Or.inl rfl⟩, ha => by rw [smul_val] <;> trivial\n      | _, ⟨x, y, Or.inr <| Or.inl rfl⟩, ha => by\n        rw [smul_val] <;> simpa using nonnegg_pos_neg.2 (sq_le_smul n <| nonnegg_pos_neg.1 ha)\n      | _, ⟨x, y, Or.inr <| Or.inr rfl⟩, ha => by\n        rw [smul_val] <;> simpa using nonnegg_neg_pos.2 (sq_le_smul n <| nonnegg_neg_pos.1 ha)\n#align zsqrtd.nonneg_smul Zsqrtd.nonneg_smul\n-/\n\n#print Zsqrtd.nonneg_muld /-\ntheorem nonneg_muld {a : ℤ√d} (ha : nonneg a) : nonneg (sqrtd * a) := by\n  refine'\n    match a, nonneg_cases ha, ha with\n    | _, ⟨x, y, Or.inl rfl⟩, ha => trivial\n    | _, ⟨x, y, Or.inr <| Or.inl rfl⟩, ha => by\n      simp <;> apply nonnegg_neg_pos.2 <;>\n        simpa [sq_le, mul_comm, mul_left_comm] using Nat.mul_le_mul_left d (nonnegg_pos_neg.1 ha)\n    | _, ⟨x, y, Or.inr <| Or.inr rfl⟩, ha => by\n      simp <;> apply nonnegg_pos_neg.2 <;>\n        simpa [sq_le, mul_comm, mul_left_comm] using Nat.mul_le_mul_left d (nonnegg_neg_pos.1 ha)\n#align zsqrtd.nonneg_muld Zsqrtd.nonneg_muld\n-/\n\n#print Zsqrtd.nonneg_mul_lem /-\ntheorem nonneg_mul_lem {x y : ℕ} {a : ℤ√d} (ha : nonneg a) : nonneg (⟨x, y⟩ * a) :=\n  by\n  have : (⟨x, y⟩ * a : ℤ√d) = x * a + sqrtd * (y * a) := by\n    rw [decompose, right_distrib, mul_assoc] <;> rfl\n  rw [this] <;> exact (nonneg_smul ha).add (nonneg_muld <| nonneg_smul ha)\n#align zsqrtd.nonneg_mul_lem Zsqrtd.nonneg_mul_lem\n-/\n\n#print Zsqrtd.nonneg_mul /-\ntheorem nonneg_mul {a b : ℤ√d} (ha : nonneg a) (hb : nonneg b) : nonneg (a * b) :=\n  match a, b, nonneg_cases ha, nonneg_cases hb, ha, hb with\n  | _, _, ⟨x, y, Or.inl rfl⟩, ⟨z, w, Or.inl rfl⟩, ha, hb => trivial\n  | _, _, ⟨x, y, Or.inl rfl⟩, ⟨z, w, Or.inr <| Or.inr rfl⟩, ha, hb => nonneg_mul_lem hb\n  | _, _, ⟨x, y, Or.inl rfl⟩, ⟨z, w, Or.inr <| Or.inl rfl⟩, ha, hb => nonneg_mul_lem hb\n  | _, _, ⟨x, y, Or.inr <| Or.inr rfl⟩, ⟨z, w, Or.inl rfl⟩, ha, hb => by\n    rw [mul_comm] <;> exact nonneg_mul_lem ha\n  | _, _, ⟨x, y, Or.inr <| Or.inl rfl⟩, ⟨z, w, Or.inl rfl⟩, ha, hb => by\n    rw [mul_comm] <;> exact nonneg_mul_lem ha\n  | _, _, ⟨x, y, Or.inr <| Or.inr rfl⟩, ⟨z, w, Or.inr <| Or.inr rfl⟩, ha, hb => by\n    rw [calc\n          (⟨-x, y⟩ * ⟨-z, w⟩ : ℤ√d) = ⟨_, _⟩ := rfl\n          _ = ⟨x * z + d * y * w, -(x * w + y * z)⟩ := by simp [add_comm]\n          ] <;>\n      exact nonnegg_pos_neg.2 (sq_le_mul.left (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb))\n  | _, _, ⟨x, y, Or.inr <| Or.inr rfl⟩, ⟨z, w, Or.inr <| Or.inl rfl⟩, ha, hb => by\n    rw [calc\n          (⟨-x, y⟩ * ⟨z, -w⟩ : ℤ√d) = ⟨_, _⟩ := rfl\n          _ = ⟨-(x * z + d * y * w), x * w + y * z⟩ := by simp [add_comm]\n          ] <;>\n      exact nonnegg_neg_pos.2 (sq_le_mul.right.left (nonnegg_neg_pos.1 ha) (nonnegg_pos_neg.1 hb))\n  | _, _, ⟨x, y, Or.inr <| Or.inl rfl⟩, ⟨z, w, Or.inr <| Or.inr rfl⟩, ha, hb => by\n    rw [calc\n          (⟨x, -y⟩ * ⟨-z, w⟩ : ℤ√d) = ⟨_, _⟩ := rfl\n          _ = ⟨-(x * z + d * y * w), x * w + y * z⟩ := by simp [add_comm]\n          ] <;>\n      exact\n        nonnegg_neg_pos.2 (sq_le_mul.right.right.left (nonnegg_pos_neg.1 ha) (nonnegg_neg_pos.1 hb))\n  | _, _, ⟨x, y, Or.inr <| Or.inl rfl⟩, ⟨z, w, Or.inr <| Or.inl rfl⟩, ha, hb => by\n    rw [calc\n          (⟨x, -y⟩ * ⟨z, -w⟩ : ℤ√d) = ⟨_, _⟩ := rfl\n          _ = ⟨x * z + d * y * w, -(x * w + y * z)⟩ := by simp [add_comm]\n          ] <;>\n      exact\n        nonnegg_pos_neg.2\n          (sq_le_mul.right.right.right (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb))\n#align zsqrtd.nonneg_mul Zsqrtd.nonneg_mul\n-/\n\n/- warning: zsqrtd.mul_nonneg -> Zsqrtd.mul_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} (a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (Zero.zero.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasZero ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))) a) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (Zero.zero.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasZero ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))) b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (Zero.zero.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasZero ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))) (HMul.hMul.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHMul.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasMul ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) a b))\nbut is expected to have type\n  forall {d : Nat} (a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) 0 (Zero.toOfNat0.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instZeroZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) a) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) 0 (Zero.toOfNat0.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instZeroZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) b) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) 0 (Zero.toOfNat0.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instZeroZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) (HMul.hMul.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHMul.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instMulZsqrtd (Nat.cast.{0} Int instNatCastInt d))) a b))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.mul_nonneg Zsqrtd.mul_nonnegₓ'. -/\nprotected theorem mul_nonneg (a b : ℤ√d) : 0 ≤ a → 0 ≤ b → 0 ≤ a * b := by\n  repeat' rw [← nonneg_iff_zero_le] <;> exact nonneg_mul\n#align zsqrtd.mul_nonneg Zsqrtd.mul_nonneg\n\n#print Zsqrtd.not_sqLe_succ /-\ntheorem not_sqLe_succ (c d y) (h : 0 < c) : ¬SqLe (y + 1) c 0 d :=\n  not_le_of_gt <| mul_pos (mul_pos h <| Nat.succ_pos _) <| Nat.succ_pos _\n#align zsqrtd.not_sq_le_succ Zsqrtd.not_sqLe_succ\n-/\n\n#print Zsqrtd.Nonsquare /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`ns] [] -/\n/-- A nonsquare is a natural number that is not equal to the square of an\n  integer. This is implemented as a typeclass because it's a necessary condition\n  for much of the Pell equation theory. -/\nclass Nonsquare (x : ℕ) : Prop where\n  ns : ∀ n : ℕ, x ≠ n * n\n#align zsqrtd.nonsquare Zsqrtd.Nonsquare\n-/\n\nparameter [dnsq : Nonsquare d]\n\ninclude dnsq\n\n#print Zsqrtd.d_pos /-\ntheorem d_pos : 0 < d :=\n  lt_of_le_of_ne (Nat.zero_le _) <| Ne.symm <| Nonsquare.ns d 0\n#align zsqrtd.d_pos Zsqrtd.d_pos\n-/\n\n#print Zsqrtd.divides_sq_eq_zero /-\ntheorem divides_sq_eq_zero {x y} (h : x * x = d * y * y) : x = 0 ∧ y = 0 :=\n  let g := x.gcd y\n  Or.elim g.eq_zero_or_pos\n    (fun H => ⟨Nat.eq_zero_of_gcd_eq_zero_left H, Nat.eq_zero_of_gcd_eq_zero_right H⟩) fun gpos =>\n    False.elim <|\n      by\n      let ⟨m, n, co, (hx : x = m * g), (hy : y = n * g)⟩ := Nat.exists_coprime gpos\n      rw [hx, hy] at h\n      have : m * m = d * (n * n) :=\n        mul_left_cancel₀ (mul_pos gpos gpos).ne' (by simpa [mul_comm, mul_left_comm] using h)\n      have co2 :=\n        let co1 := co.mul_right co\n        co1.mul co1\n      exact\n        nonsquare.ns d m\n          (Nat.dvd_antisymm (by rw [this] <;> apply dvd_mul_right) <|\n            co2.dvd_of_dvd_mul_right <| by simp [this])\n#align zsqrtd.divides_sq_eq_zero Zsqrtd.divides_sq_eq_zero\n-/\n\n#print Zsqrtd.divides_sq_eq_zero_z /-\ntheorem divides_sq_eq_zero_z {x y : ℤ} (h : x * x = d * y * y) : x = 0 ∧ y = 0 := by\n  rw [mul_assoc, ← Int.natAbs_mul_self, ← Int.natAbs_mul_self, ← Int.ofNat_mul, ← mul_assoc] at\n      h <;>\n    exact\n      let ⟨h1, h2⟩ := divides_sq_eq_zero (Int.ofNat.inj h)\n      ⟨Int.eq_zero_of_natAbs_eq_zero h1, Int.eq_zero_of_natAbs_eq_zero h2⟩\n#align zsqrtd.divides_sq_eq_zero_z Zsqrtd.divides_sq_eq_zero_z\n-/\n\n#print Zsqrtd.not_divides_sq /-\ntheorem not_divides_sq (x y) : (x + 1) * (x + 1) ≠ d * (y + 1) * (y + 1) := fun e => by\n  have t := (divides_sq_eq_zero e).left <;> contradiction\n#align zsqrtd.not_divides_sq Zsqrtd.not_divides_sq\n-/\n\n#print Zsqrtd.nonneg_antisymm /-\ntheorem nonneg_antisymm : ∀ {a : ℤ√d}, nonneg a → nonneg (-a) → a = 0\n  | ⟨0, 0⟩, xy, yx => rfl\n  | ⟨-[x+1], -[y+1]⟩, xy, yx => False.elim xy\n  | ⟨(x + 1 : Nat), (y + 1 : Nat)⟩, xy, yx => False.elim yx\n  | ⟨-[x+1], 0⟩, xy, yx => absurd xy (not_sqLe_succ _ _ _ (by decide))\n  | ⟨(x + 1 : Nat), 0⟩, xy, yx => absurd yx (not_sqLe_succ _ _ _ (by decide))\n  | ⟨0, -[y+1]⟩, xy, yx => absurd xy (not_sqLe_succ _ _ _ d_pos)\n  | ⟨0, (y + 1 : Nat)⟩, _, yx => absurd yx (not_sqLe_succ _ _ _ d_pos)\n  | ⟨(x + 1 : Nat), -[y+1]⟩, (xy : sq_le _ _ _ _), (yx : sq_le _ _ _ _) =>\n    by\n    let t := le_antisymm yx xy\n    rw [one_mul] at t <;> exact absurd t (not_divides_sq _ _)\n  | ⟨-[x+1], (y + 1 : Nat)⟩, (xy : sq_le _ _ _ _), (yx : sq_le _ _ _ _) =>\n    by\n    let t := le_antisymm xy yx\n    rw [one_mul] at t <;> exact absurd t (not_divides_sq _ _)\n#align zsqrtd.nonneg_antisymm Zsqrtd.nonneg_antisymm\n-/\n\n/- warning: zsqrtd.le_antisymm -> Zsqrtd.le_antisymm is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} [dnsq : Zsqrtd.Nonsquare d] {a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)} {b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)}, (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) a b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLe d) b a) -> (Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) a b)\nbut is expected to have type\n  forall {d : Nat} [dnsq : Zsqrtd.Nonsquare d] {a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)} {b : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)}, (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) a b) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt d) b a) -> (Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) a b)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.le_antisymm Zsqrtd.le_antisymmₓ'. -/\ntheorem le_antisymm {a b : ℤ√d} (ab : a ≤ b) (ba : b ≤ a) : a = b :=\n  eq_of_sub_eq_zero <| nonneg_antisymm ba (by rw [neg_sub] <;> exact ab)\n#align zsqrtd.le_antisymm Zsqrtd.le_antisymm\n\ninstance : LinearOrder (ℤ√d) :=\n  { Zsqrtd.preorder with\n    le_antisymm := @Zsqrtd.le_antisymm\n    le_total := Zsqrtd.le_total\n    decidableLe := Zsqrtd.decidableLE }\n\n#print Zsqrtd.eq_zero_or_eq_zero_of_mul_eq_zero /-\nprotected theorem eq_zero_or_eq_zero_of_mul_eq_zero : ∀ {a b : ℤ√d}, a * b = 0 → a = 0 ∨ b = 0\n  | ⟨x, y⟩, ⟨z, w⟩, h => by\n    injection h with h1 h2 <;>\n      exact\n        have h1 : x * z = -(d * y * w) := eq_neg_of_add_eq_zero_left h1\n        have h2 : x * w = -(y * z) := eq_neg_of_add_eq_zero_left h2\n        have fin : x * x = d * y * y → (⟨x, y⟩ : ℤ√d) = 0 := fun e =>\n          match x, y, divides_sq_eq_zero_z e with\n          | _, _, ⟨rfl, rfl⟩ => rfl\n        if z0 : z = 0 then\n          if w0 : w = 0 then\n            Or.inr\n              (match z, w, z0, w0 with\n              | _, _, rfl, rfl => rfl)\n          else\n            Or.inl <|\n              Fin <|\n                mul_right_cancel₀ w0 <|\n                  calc\n                    x * x * w = -y * (x * z) := by simp [h2, mul_assoc, mul_left_comm]\n                    _ = d * y * y * w := by simp [h1, mul_assoc, mul_left_comm]\n                    \n        else\n          Or.inl <|\n            Fin <|\n              mul_right_cancel₀ z0 <|\n                calc\n                  x * x * z = d * -y * (x * w) := by simp [h1, mul_assoc, mul_left_comm]\n                  _ = d * y * y * z := by simp [h2, mul_assoc, mul_left_comm]\n                  \n#align zsqrtd.eq_zero_or_eq_zero_of_mul_eq_zero Zsqrtd.eq_zero_or_eq_zero_of_mul_eq_zero\n-/\n\ninstance : NoZeroDivisors (ℤ√d)\n    where eq_zero_or_eq_zero_of_mul_eq_zero := @Zsqrtd.eq_zero_or_eq_zero_of_mul_eq_zero\n\ninstance : IsDomain (ℤ√d) :=\n  NoZeroDivisors.to_isDomain _\n\n/- warning: zsqrtd.mul_pos -> Zsqrtd.mul_pos is a dubious translation:\nlean 3 declaration is\n  forall {d : Nat} [dnsq : Zsqrtd.Nonsquare d] (a : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)), (LT.lt.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLt d) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (Zero.zero.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasZero ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))) a) -> (LT.lt.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLt d) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (Zero.zero.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasZero ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))) b) -> (LT.lt.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasLt d) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) 0 (Zero.zero.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasZero ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))))) (HMul.hMul.{0, 0, 0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (instHMul.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (Zsqrtd.hasMul ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d))) a b))\nbut is expected to have type\n  forall {d : Nat} [dnsq : Zsqrtd.Nonsquare d] (a : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt d)), (LT.lt.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLTZsqrtdCastIntInstNatCastInt d) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) 0 (Zero.toOfNat0.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instZeroZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) a) -> (LT.lt.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLTZsqrtdCastIntInstNatCastInt d) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) 0 (Zero.toOfNat0.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instZeroZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) b) -> (LT.lt.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instLTZsqrtdCastIntInstNatCastInt d) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) 0 (Zero.toOfNat0.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instZeroZsqrtd (Nat.cast.{0} Int instNatCastInt d)))) (HMul.hMul.{0, 0, 0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (instHMul.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt d)) (Zsqrtd.instMulZsqrtd (Nat.cast.{0} Int instNatCastInt d))) a b))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.mul_pos Zsqrtd.mul_posₓ'. -/\nprotected theorem mul_pos (a b : ℤ√d) (a0 : 0 < a) (b0 : 0 < b) : 0 < a * b := fun ab =>\n  Or.elim\n    (eq_zero_or_eq_zero_of_mul_eq_zero\n      (le_antisymm ab (mul_nonneg _ _ (le_of_lt a0) (le_of_lt b0))))\n    (fun e => ne_of_gt a0 e) fun e => ne_of_gt b0 e\n#align zsqrtd.mul_pos Zsqrtd.mul_pos\n\ninstance : LinearOrderedCommRing (ℤ√d) :=\n  { Zsqrtd.commRing, Zsqrtd.linearOrder,\n    Zsqrtd.nontrivial with\n    add_le_add_left := @Zsqrtd.add_le_add_left\n    mul_pos := @Zsqrtd.mul_pos\n    zero_le_one := by decide }\n\ninstance : LinearOrderedRing (ℤ√d) := by infer_instance\n\ninstance : OrderedRing (ℤ√d) := by infer_instance\n\nend\n\n#print Zsqrtd.norm_eq_zero /-\ntheorem norm_eq_zero {d : ℤ} (h_nonsquare : ∀ n : ℤ, d ≠ n * n) (a : ℤ√d) : norm a = 0 ↔ a = 0 :=\n  by\n  refine' ⟨fun ha => ext.mpr _, fun h => by rw [h, norm_zero]⟩\n  delta norm at ha\n  rw [sub_eq_zero] at ha\n  by_cases h : 0 ≤ d\n  · obtain ⟨d', rfl⟩ := Int.eq_ofNat_of_zero_le h\n    haveI : nonsquare d' := ⟨fun n h => h_nonsquare n <| by exact_mod_cast h⟩\n    exact divides_sq_eq_zero_z ha\n  · push_neg  at h\n    suffices a.re * a.re = 0 by\n      rw [eq_zero_of_mul_self_eq_zero this] at ha⊢\n      simpa only [true_and_iff, or_self_right, zero_re, zero_im, eq_self_iff_true, zero_eq_mul,\n        MulZeroClass.mul_zero, mul_eq_zero, h.ne, false_or_iff, or_self_iff] using ha\n    apply _root_.le_antisymm _ (mul_self_nonneg _)\n    rw [ha, mul_assoc]\n    exact mul_nonpos_of_nonpos_of_nonneg h.le (mul_self_nonneg _)\n#align zsqrtd.norm_eq_zero Zsqrtd.norm_eq_zero\n-/\n\nvariable {R : Type}\n\n/- warning: zsqrtd.hom_ext -> Zsqrtd.hom_ext is a dubious translation:\nlean 3 declaration is\n  forall {R : Type} [_inst_1 : Ring.{0} R] {d : Int} (f : RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (g : RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))), (Eq.{1} R (coeFn.{1, 1} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (fun (_x : RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) => (Zsqrtd d) -> R) (RingHom.hasCoeToFun.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) f (Zsqrtd.sqrtd d)) (coeFn.{1, 1} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (fun (_x : RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) => (Zsqrtd d) -> R) (RingHom.hasCoeToFun.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) g (Zsqrtd.sqrtd d))) -> (Eq.{1} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) f g)\nbut is expected to have type\n  forall {R : Type} [_inst_1 : Ring.{0} R] {d : Int} (f : RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (g : RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))), (Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Zsqrtd d) => R) (Zsqrtd.sqrtd d)) (FunLike.coe.{1, 1, 1} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) (fun (_x : Zsqrtd d) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Zsqrtd d) => R) _x) (MulHomClass.toFunLike.{0, 0, 0} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) R (NonUnitalNonAssocSemiring.toMul.{0} (Zsqrtd d) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))))) (NonUnitalNonAssocSemiring.toMul.{0} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} R (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{0, 0, 0} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} R (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{0, 0, 0} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1)) (RingHom.instRingHomClassRingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1)))))) f (Zsqrtd.sqrtd d)) (FunLike.coe.{1, 1, 1} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) (fun (_x : Zsqrtd d) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Zsqrtd d) => R) _x) (MulHomClass.toFunLike.{0, 0, 0} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) R (NonUnitalNonAssocSemiring.toMul.{0} (Zsqrtd d) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))))) (NonUnitalNonAssocSemiring.toMul.{0} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} R (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{0, 0, 0} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} R (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{0, 0, 0} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1)) (RingHom.instRingHomClassRingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1)))))) g (Zsqrtd.sqrtd d))) -> (Eq.{1} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R _inst_1))) f g)\nCase conversion may be inaccurate. Consider using '#align zsqrtd.hom_ext Zsqrtd.hom_extₓ'. -/\n@[ext]\ntheorem hom_ext [Ring R] {d : ℤ} (f g : ℤ√d →+* R) (h : f sqrtd = g sqrtd) : f = g :=\n  by\n  ext ⟨x_re, x_im⟩\n  simp [decompose, h]\n#align zsqrtd.hom_ext Zsqrtd.hom_ext\n\nvariable [CommRing R]\n\n/- warning: zsqrtd.lift -> Zsqrtd.lift is a dubious translation:\nlean 3 declaration is\n  forall {R : Type} [_inst_1 : CommRing.{0} R] {d : Int}, Equiv.{1, 1} (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (Distrib.toHasMul.{0} R (Ring.toDistrib.{0} R (CommRing.toRing.{0} R _inst_1)))) r r) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int R (HasLiftT.mk.{1, 1} Int R (CoeTCₓ.coe.{1, 1} Int R (Int.castCoe.{0} R (AddGroupWithOne.toHasIntCast.{0} R (AddCommGroupWithOne.toAddGroupWithOne.{0} R (Ring.toAddCommGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1))))))) d))) (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))\nbut is expected to have type\n  forall {R : Type} [_inst_1 : CommRing.{0} R] {d : Int}, Equiv.{1, 1} (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.lift Zsqrtd.liftₓ'. -/\n/-- The unique `ring_hom` from `ℤ√d` to a ring `R`, constructed by replacing `√d` with the provided\nroot. Conversely, this associates to every mapping `ℤ√d →+* R` a value of `√d` in `R`. -/\n@[simps]\ndef lift {d : ℤ} : { r : R // r * r = ↑d } ≃ (ℤ√d →+* R)\n    where\n  toFun r :=\n    { toFun := fun a => a.1 + a.2 * (r : R)\n      map_zero' := by simp\n      map_add' := fun a b => by\n        simp\n        ring\n      map_one' := by simp\n      map_mul' := fun a b =>\n        by\n        have :\n          (a.re + a.im * r : R) * (b.re + b.im * r) =\n            a.re * b.re + (a.re * b.im + a.im * b.re) * r + a.im * b.im * (r * r) :=\n          by ring\n        simp [this, r.prop]\n        ring }\n  invFun f := ⟨f sqrtd, by rw [← f.map_mul, dmuld, map_intCast]⟩\n  left_inv r := by\n    ext\n    simp\n  right_inv f := by\n    ext\n    simp\n#align zsqrtd.lift Zsqrtd.lift\n\n/- warning: zsqrtd.lift_injective -> Zsqrtd.lift_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type} [_inst_1 : CommRing.{0} R] [_inst_2 : CharZero.{0} R (AddGroupWithOne.toAddMonoidWithOne.{0} R (AddCommGroupWithOne.toAddGroupWithOne.{0} R (Ring.toAddCommGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1))))] {d : Int} (r : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (Distrib.toHasMul.{0} R (Ring.toDistrib.{0} R (CommRing.toRing.{0} R _inst_1)))) r r) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int R (HasLiftT.mk.{1, 1} Int R (CoeTCₓ.coe.{1, 1} Int R (Int.castCoe.{0} R (AddGroupWithOne.toHasIntCast.{0} R (AddCommGroupWithOne.toAddGroupWithOne.{0} R (Ring.toAddCommGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1))))))) d))), (forall (n : Int), Ne.{1} Int d (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) n n)) -> (Function.Injective.{1, 1} (Zsqrtd d) R (coeFn.{1, 1} (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) (fun (_x : RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) => (Zsqrtd d) -> R) (RingHom.hasCoeToFun.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) (coeFn.{1, 1} (Equiv.{1, 1} (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (Distrib.toHasMul.{0} R (Ring.toDistrib.{0} R (CommRing.toRing.{0} R _inst_1)))) r r) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int R (HasLiftT.mk.{1, 1} Int R (CoeTCₓ.coe.{1, 1} Int R (Int.castCoe.{0} R (AddGroupWithOne.toHasIntCast.{0} R (AddCommGroupWithOne.toAddGroupWithOne.{0} R (Ring.toAddCommGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1))))))) d))) (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) (fun (_x : Equiv.{1, 1} (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (Distrib.toHasMul.{0} R (Ring.toDistrib.{0} R (CommRing.toRing.{0} R _inst_1)))) r r) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int R (HasLiftT.mk.{1, 1} Int R (CoeTCₓ.coe.{1, 1} Int R (Int.castCoe.{0} R (AddGroupWithOne.toHasIntCast.{0} R (AddCommGroupWithOne.toAddGroupWithOne.{0} R (Ring.toAddCommGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1))))))) d))) (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) => (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (Distrib.toHasMul.{0} R (Ring.toDistrib.{0} R (CommRing.toRing.{0} R _inst_1)))) r r) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int R (HasLiftT.mk.{1, 1} Int R (CoeTCₓ.coe.{1, 1} Int R (Int.castCoe.{0} R (AddGroupWithOne.toHasIntCast.{0} R (AddCommGroupWithOne.toAddGroupWithOne.{0} R (Ring.toAddCommGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1))))))) d))) -> (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) (Equiv.hasCoeToFun.{1, 1} (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (Distrib.toHasMul.{0} R (Ring.toDistrib.{0} R (CommRing.toRing.{0} R _inst_1)))) r r) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int R (HasLiftT.mk.{1, 1} Int R (CoeTCₓ.coe.{1, 1} Int R (Int.castCoe.{0} R (AddGroupWithOne.toHasIntCast.{0} R (AddCommGroupWithOne.toAddGroupWithOne.{0} R (Ring.toAddCommGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1))))))) d))) (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) (Zsqrtd.lift R _inst_1 d) r)))\nbut is expected to have type\n  forall {R : Type} [_inst_1 : CommRing.{0} R] [_inst_2 : CharZero.{0} R (AddGroupWithOne.toAddMonoidWithOne.{0} R (Ring.toAddGroupWithOne.{0} R (CommRing.toRing.{0} R _inst_1)))] {d : Int} (r : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))), (forall (n : Int), Ne.{1} Int d (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) n n)) -> (Function.Injective.{1, 1} (Zsqrtd d) R (FunLike.coe.{1, 1, 1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) => RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) r) (Zsqrtd d) (fun (_x : Zsqrtd d) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Zsqrtd d) => R) _x) (MulHomClass.toFunLike.{0, 0, 0} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) => RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) r) (Zsqrtd d) R (NonUnitalNonAssocSemiring.toMul.{0} (Zsqrtd d) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))))) (NonUnitalNonAssocSemiring.toMul.{0} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} R (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) (NonUnitalRingHomClass.toMulHomClass.{0, 0, 0} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) => RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) r) (Zsqrtd d) R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} R (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) (RingHomClass.toNonUnitalRingHomClass.{0, 0, 0} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) => RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) r) (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))) (RingHom.instRingHomClassRingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))))) (FunLike.coe.{1, 1, 1} (Equiv.{1, 1} (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) (fun (_x : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) => RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1)))) _x) (Equiv.instFunLikeEquiv.{1, 1} (Subtype.{1} R (fun (r : R) => Eq.{1} R (HMul.hMul.{0, 0, 0} R R R (instHMul.{0} R (NonUnitalNonAssocRing.toMul.{0} R (NonAssocRing.toNonUnitalNonAssocRing.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) r r) (Int.cast.{0} R (Ring.toIntCast.{0} R (CommRing.toRing.{0} R _inst_1)) d))) (RingHom.{0, 0} (Zsqrtd d) R (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))) (NonAssocRing.toNonAssocSemiring.{0} R (Ring.toNonAssocRing.{0} R (CommRing.toRing.{0} R _inst_1))))) (Zsqrtd.lift R _inst_1 d) r)))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.lift_injective Zsqrtd.lift_injectiveₓ'. -/\n/-- `lift r` is injective if `d` is non-square, and R has characteristic zero (that is, the map from\n`ℤ` into `R` is injective). -/\ntheorem lift_injective [CharZero R] {d : ℤ} (r : { r : R // r * r = ↑d })\n    (hd : ∀ n : ℤ, d ≠ n * n) : Function.Injective (lift r) :=\n  (injective_iff_map_eq_zero (lift r)).mpr fun a ha =>\n    by\n    have h_inj : Function.Injective (coe : ℤ → R) := Int.cast_injective\n    suffices lift r a.norm = 0\n      by\n      simp only [coe_int_re, add_zero, lift_apply_apply, coe_int_im, Int.cast_zero,\n        MulZeroClass.zero_mul] at this\n      rwa [← Int.cast_zero, h_inj.eq_iff, norm_eq_zero hd] at this\n    rw [norm_eq_mul_conj, RingHom.map_mul, ha, MulZeroClass.zero_mul]\n#align zsqrtd.lift_injective Zsqrtd.lift_injective\n\n/- warning: zsqrtd.norm_eq_one_iff_mem_unitary -> Zsqrtd.norm_eq_one_iff_mem_unitary is a dubious translation:\nlean 3 declaration is\n  forall {d : Int} {a : Zsqrtd d}, Iff (Eq.{1} Int (Zsqrtd.norm d a) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (Membership.Mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (SetLike.hasMem.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (Zsqrtd d) (Submonoid.setLike.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d)))) a (unitary.{0} (Zsqrtd d) (Zsqrtd.monoid d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.starRing d))))\nbut is expected to have type\n  forall {d : Int} {a : Zsqrtd d}, Iff (Eq.{1} Int (Zsqrtd.norm d a) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (Membership.mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (SetLike.instMembership.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (Zsqrtd d) (Submonoid.instSetLikeSubmonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d)))) a (unitary.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.instStarRingZsqrtdToNonUnitalSemiringToNonUnitalRingToNonUnitalCommRingCommRing d))))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.norm_eq_one_iff_mem_unitary Zsqrtd.norm_eq_one_iff_mem_unitaryₓ'. -/\n/-- An element of `ℤ√d` has norm equal to `1` if and only if it is contained in the submonoid\nof unitary elements. -/\ntheorem norm_eq_one_iff_mem_unitary {d : ℤ} {a : ℤ√d} : a.norm = 1 ↔ a ∈ unitary (ℤ√d) :=\n  by\n  rw [unitary.mem_iff_self_mul_star, ← norm_eq_mul_conj]\n  norm_cast\n#align zsqrtd.norm_eq_one_iff_mem_unitary Zsqrtd.norm_eq_one_iff_mem_unitary\n\n/- warning: zsqrtd.mker_norm_eq_unitary -> Zsqrtd.mker_norm_eq_unitary is a dubious translation:\nlean 3 declaration is\n  forall {d : Int}, Eq.{1} (Submonoid.{0} (Zsqrtd d) (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d)))))) (MonoidHom.mker.{0, 0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.ring)))) (MonoidHom.{0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.ring))))) (MonoidHom.monoidHomClass.{0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.ring d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.ring))))) (Zsqrtd.normMonoidHom d)) (unitary.{0} (Zsqrtd d) (Zsqrtd.monoid d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.starRing d)))\nbut is expected to have type\n  forall {d : Int}, Eq.{1} (Submonoid.{0} (Zsqrtd d) (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d)))))) (MonoidHom.mker.{0, 0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)))) (MonoidHom.{0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt))))) (MonoidHom.monoidHomClass.{0, 0} (Zsqrtd d) Int (MulZeroOneClass.toMulOneClass.{0} (Zsqrtd d) (NonAssocSemiring.toMulZeroOneClass.{0} (Zsqrtd d) (NonAssocRing.toNonAssocSemiring.{0} (Zsqrtd d) (Ring.toNonAssocRing.{0} (Zsqrtd d) (Zsqrtd.instRingZsqrtd d))))) (MulZeroOneClass.toMulOneClass.{0} Int (NonAssocSemiring.toMulZeroOneClass.{0} Int (NonAssocRing.toNonAssocSemiring.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt))))) (Zsqrtd.normMonoidHom d)) (unitary.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.instStarRingZsqrtdToNonUnitalSemiringToNonUnitalRingToNonUnitalCommRingCommRing d)))\nCase conversion may be inaccurate. Consider using '#align zsqrtd.mker_norm_eq_unitary Zsqrtd.mker_norm_eq_unitaryₓ'. -/\n/-- The kernel of the norm map on `ℤ√d` equals the submonoid of unitary elements. -/\ntheorem mker_norm_eq_unitary {d : ℤ} : (@normMonoidHom d).mker = unitary (ℤ√d) :=\n  Submonoid.ext fun x => norm_eq_one_iff_mem_unitary\n#align zsqrtd.mker_norm_eq_unitary Zsqrtd.mker_norm_eq_unitary\n\nend Zsqrtd\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/NumberTheory/Zsqrtd/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4962755424893599}}
{"text": "-- Copyright © 2019 François G. Dorais. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n\nimport .basic\nimport .monoid\nimport .group\nimport .action\n\nnamespace algebra\n\n/- \nsignature command cannot handle operation parameters, \nso we define category_sig manually; category_hom is missing.\n-/\nstructure category_sig {α : Type*} (β : α → α → Type*) :=\n(op (a b c : α) : β a b → β b c → β a c)\n(id (a : α) : β a a)\n\nnamespace category_sig\nvariables {α : Type*} {β : α → α → Type*} (s : category_sig β)\n\n@[signature_instance]\ndefinition to_monoid (a : α) : monoid_sig (β a a) :=\n{ op := s.op a a a\n, id := s.id a\n}\n\n@[signature_instance]\ndefinition to_left_action (a b : α) : left_action_sig (β a a) (β a b) :=\n{ act := s.op a a b\n}\n\n@[signature_instance]\ndefinition to_right_action (a b : α) : right_action_sig (β a a) (β b a) :=\n{ act := s.op b a a\n}\n\nend category_sig\n\n/- TODO: fix theory attribute to handle parameters correctly -/\nclass category {α : Type*} {β : α → α → Type*} (s : category_sig β) : Prop := intro ::\n(assoc (a b c d) : identity.op_compatibility (s.op a c d) (s.op a b c) (s.op a b d) (s.op b c d))\n(left_identity (a b) : identity.op_left_identity (s.op a a b) (s.id a))\n(right_identity (a b) : identity.op_right_identity (s.op a b b) (s.id b))\n\nattribute [identity_instance] category.assoc\nattribute [identity_instance] category.left_identity\nattribute [identity_instance] category.right_identity\n\nnamespace category\nvariables {α : Type*} {β : α → α → Type*} (s : category_sig β) [i : category s]\n\ndefinition infer \n[Π (a b c d), class.op_compatibility (s.op a c d) (s.op a b c) (s.op a b d) (s.op b c d)]\n[Π (a b), class.op_left_identity (s.op a a b) (s.id a)]\n[Π (a b), class.op_right_identity (s.op a b b) (s.id b)] : category s :=\ncategory.intro\n(λ _ _ _ _, op_compatibility _ _ _ _)\n(λ _ _, op_left_identity _ _)\n(λ _ _, op_right_identity _ _)\n\ninclude i\n\ninstance to_monoid (a : α) : monoid (s.to_monoid a) := monoid.infer _\n\ninstance to_left_monoid_action (a b : α) : left_monoid_action (s.to_monoid a) (s.to_left_action a b) := left_monoid_action.infer _ _\n\ninstance to_right_monoid_action (a b : α) : right_monoid_action (s.to_monoid a) (s.to_right_action a b) := right_monoid_action.infer _ _\n\nend category\n\nend algebra\n\n/- move to monoid when ready -/\nnamespace algebra\n\nnamespace monoid_sig\nvariables {α : Type*} (s : monoid_sig α)\n\n@[signature_instance]\ndefinition to_category : category_sig (λ (_ _ : unit), α) :=\n{ op := λ _ _ _, s.op\n, id := λ _, s.id\n}\n\nend monoid_sig\n\nnamespace monoid\nvariables {α : Type*} (s : monoid_sig α) [monoid s]\n\n@[identity_instance]\ntheorem to_category_compatibility (a b c d : unit) : identity.op_compatibility (s.to_category.op a c d) (s.to_category.op a b c) (s.to_category.op a b d) (s.to_category.op b c d) :=\nshow identity.op_compatibility s.op s.op s.op s.op, from op_associative s.op\n\n@[identity_instance]\ntheorem to_category_left_identity (a b : unit) : identity.op_left_identity (s.to_category.op a a b) (s.to_category.id a) :=\nshow identity.op_left_identity s.op s.id, from op_left_identity s.op s.id\n\n@[identity_instance]\ntheorem to_category_right_identity (a b : unit) : identity.op_right_identity (s.to_category.op a b b) (s.to_category.id b) :=\nshow identity.op_right_identity s.op s.id, from op_right_identity s.op s.id\n\ninstance to_category : category s.to_category := category.infer _\n\nend monoid\n\nend algebra", "meta": {"author": "fgdorais", "repo": "lean-universal", "sha": "9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1", "save_path": "github-repos/lean/fgdorais-lean-universal", "path": "github-repos/lean/fgdorais-lean-universal/lean-universal-9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1/src/algebra/theories/category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.4962755343413917}}
{"text": "/- Introduces typing contexts, which are lists of assumptions with associated\n   multiplicities from an arbitrary semiring. -/\n\nimport tactic.ring\nimport tactic.abel\nimport algebra\n\nimport metastuff\n\n\n/- In the QTT paper, this would be a \"pre-precontext\". -/\n@[reducible]\ndef precontext (τ: Type) := list τ\n\n/- In the QTT paper, this is the \"precontext\".\n   τ is the Lean Type representing types of the embedded language.\n   mult is the Lean Type representing elements of an arbitrary semiring,\n   which describe the multiplicity of resources (how many times a resource\n   can or will be used). -/\ninductive context {τ mult: Type}: precontext τ → Type\n| nil: context []\n-- \"You have a dependent pi (n) after a recursive arg (_ : context ns)\n-- and Lean doesn't like this.\"\n| cons {γ: precontext τ} (π: mult) (T: τ): context γ → context (T::γ)\n\nnotation `⟦`π`⬝`T`⟧::`Γ:90 := context.cons π T Γ\n\n/- Indexes an assumption in the typing context. -/\ninductive debrujin_idx {τ: Type}: precontext τ → τ → Type\ninfix ` ∋ `:55 := debrujin_idx\n| ZVar: Π {γ: precontext τ} {T: τ},\n  ----------\n  (T::γ) ∋ T\n| SVar: Π {γ: precontext τ} {T U: τ},\n  γ ∋ T\n  ----------\n→ (U::γ) ∋ T\ninfix ` ∋ `:55 := debrujin_idx\n\nnamespace context\n\nvariable {τ: Type}\nvariables {mult: Type} [semiring mult]\n\ndef zeros: Π (γ: precontext τ), @context τ mult γ\n| [] := nil\n| (T::δ) := ⟦0⬝T⟧::(zeros δ)\n\ninstance {γ: precontext τ} : has_zero (@context τ mult γ) :=\n  ⟨zeros γ⟩\n\n@[unfold_] lemma zeros_cons {γ: precontext τ} {T: τ}\n  : (0: @context τ mult (T::γ)) = ⟦(0: mult)⬝T⟧::(0: @context τ mult γ) := by refl\n\nprotected def add: Π {γ}, @context τ mult γ → @context τ mult γ → @context τ mult γ\n| _ nil nil := nil\n| _ (⟦π₁⬝T⟧::Γ₁) (⟦π₂⬝.(T)⟧::Γ₂) := ⟦(π₁+π₂)⬝T⟧::(add Γ₁ Γ₂)\n\ninstance {γ: precontext τ} : has_add (@context τ mult γ) :=\n  ⟨context.add⟩\n\n@[simp] lemma add_nil\n  : (nil: @context τ mult []) + nil = nil := by refl\n\n@[unfold_] lemma add_cons {γ} {Γ₁ Γ₂: @context τ mult γ} {π₁ π₂: mult} {T: τ}\n  : ⟦π₁⬝T⟧::Γ₁ + ⟦π₂⬝T⟧::Γ₂ = ⟦(π₁+π₂)⬝T⟧::(Γ₁ + Γ₂) := by refl\n\n/- addition makes a commutative monoid -/\n\n@[simp] lemma zero_add\n  : ∀ {γ} {Γ: @context τ mult γ},\n    0 + Γ = Γ :=\nbegin\n  intros,\n  induction Γ with γ π T Γ ih,\n  { refl },\n  { unfold has_zero.zero zeros at *,\n    simp * with unfold_, show π+0=π,\n    abel },\nend\n\n@[simp] lemma add_zero\n  : ∀ {γ} {Γ: @context τ mult γ},\n    Γ + 0 = Γ :=\nbegin\n  intros,\n  induction Γ with γ π T Γ ih,\n  { refl },\n  { unfold has_zero.zero zeros at *,\n    simp * with unfold_, show π+0=π,\n    abel },\nend\n\nlemma add_comm\n  : ∀ {γ} {Γ₁ Γ₂: @context τ mult γ},\n    Γ₁ + Γ₂ = Γ₂ + Γ₁ :=\nbegin\n  intros,\n  induction Γ₁ with γ₁ π₁ T₁ Γ₁ ih₁,\n  { cases Γ₂, refl },\n  { cases Γ₂ with _ π₂,\n    simp * with unfold_ },\nend\n\nlemma add_assoc\n  : ∀ {γ} {Γ₁ Γ₂ Γ₃: @context τ mult γ},\n    (Γ₁ + Γ₂) + Γ₃ = Γ₁ + (Γ₂ + Γ₃) :=\nbegin\n  intros,\n  induction Γ₁ with γ₁ π₁ T₁ Γ₁ ih₁,\n  { cases Γ₂, cases Γ₃, refl },\n  { cases Γ₂ with _ π₂,\n    cases Γ₃ with _ π₃,\n    simp * with unfold_ },\nend\n\ninstance [h: semiring mult] {γ: precontext τ} : add_comm_monoid (@context τ mult γ) :=\n{ add := context.add,\n  zero := zeros γ,\n  zero_add := @zero_add τ mult h γ,\n  add_zero := @add_zero τ mult h γ,\n  add_comm := @add_comm τ mult h γ,\n  add_assoc := @add_assoc τ mult h γ }\n\nprotected def smul: Π {γ}, mult → @context τ mult γ → @context τ mult γ\n| _ π nil := nil\n| _ π (⟦π'⬝T⟧::Γ) := ⟦(π*π')⬝T⟧::(smul π Γ)\n\ninstance {γ: precontext τ} : has_scalar mult (@context τ mult γ) :=\n  ⟨context.smul⟩\n\n@[simp] lemma smul_nil {π: mult}\n  : π • (nil: @context τ mult []) = nil := by refl\n\n@[unfold_] lemma smul_cons {γ} {Γ: @context τ mult γ} {π π': mult} {T: τ}\n  : π • ⟦π'⬝T⟧::Γ = ⟦(π*π')⬝T⟧::(π • Γ) := by refl\n\n/- scalar multiplication (mult • context) makes a semimodule -/\n\n@[simp] lemma one_smul\n  : ∀ {γ} {Γ: @context τ mult γ},\n    ((1: mult) • Γ: @context τ mult γ) = Γ :=\nbegin\n  intros,\n  induction Γ with γ π T Δ ih,\n  { refl },\n  { simp * with unfold_ },\nend\n\n@[simp] lemma zero_smul\n  : ∀ {γ} {Γ: @context τ mult γ},\n    ((0: mult) • Γ: @context τ mult γ) = 0 :=\nbegin\n  intros,\n  induction Γ with γ π T Γ ih,\n  { refl },\n  { simp * with unfold_ },\nend\n\n@[simp] lemma smul_zero\n  : ∀ {γ} {π: mult},\n    (π • 0: @context τ mult γ) = 0 :=\nbegin\n  intros,\n  induction γ with T γ ih,\n  { refl },\n  { unfold has_zero.zero zeros,\n    unfold has_zero.zero zeros at ih,\n    simp * with unfold_,\n    show π*0=0, simp * },\nend\n\n@[sop_form] lemma smul_add\n  : ∀ {γ} {π: mult} {Γ₁ Γ₂: @context τ mult γ},\n    π • (Γ₁ + Γ₂) = π•Γ₁ + π•Γ₂ :=\nbegin\n  intros,\n  induction Γ₁ with γ₁ π₁ T₁ Γ₁ ih₁,\n  { cases Γ₂, refl },\n  { cases Γ₂ with _ π₂,\n    simp [*, left_distrib] with unfold_ },\nend\n\n@[sop_form] lemma add_smul\n  : ∀ {γ} {π₁ π₂: mult} {Γ: @context τ mult γ},\n    (π₁ + π₂) • Γ = π₁•Γ + π₂•Γ :=\nbegin\n  intros,\n  induction Γ with γ π T Γ ih,\n  { refl },\n  { simp [*, right_distrib] with unfold_ },\nend\n\nlemma mul_smul\n  : ∀ {γ} {π π': mult} {Γ: @context τ mult γ},\n    (π * π') • Γ = π • (π' • Γ) :=\nbegin\n  intros, induction Γ with γ π T Γ ih,\n  { refl },\n  { simp [*, mul_assoc] with unfold_ },\nend\n\ninstance [h: semiring mult] {γ: precontext τ} : semimodule mult (@context τ mult γ) :=\n{ one_smul := @one_smul τ mult h γ,\n  zero_smul := @zero_smul τ mult h γ,\n  smul_zero := @smul_zero τ mult h γ,\n  smul_add := @smul_add τ mult h γ,\n  add_smul := @add_smul τ mult h γ,\n  mul_smul := @mul_smul τ mult h γ }\n\nend context\n", "meta": {"author": "Vtec234", "repo": "lean-sesh", "sha": "d11d7bb0599406e27d3a4d26242aec13d639ecf7", "save_path": "github-repos/lean/Vtec234-lean-sesh", "path": "github-repos/lean/Vtec234-lean-sesh/lean-sesh-d11d7bb0599406e27d3a4d26242aec13d639ecf7/src/qtt/context.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833789613196, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4962258851256617}}
{"text": "import tactic\n\n\n/--\n  Specialized version of function.update.\n-/\ndef function.update_ite\n  {α β : Type}\n  [decidable_eq α]\n  (f : α → β)\n  (a' : α) (b : β) (a : α) :=\n  if a = a' then b else f a\n\n\nlemma function.update_ite_comp\n  {α α' β : Sort*}\n  [decidable_eq α]\n  (f : α' → β)\n  (g : α → α')\n  (i : α)\n  (v : α') :\n  f ∘ (function.update_ite g i v) =\n    function.update_ite (f ∘ g) i (f v) :=\nbegin\n  funext,\n  simp only [function.comp_app],\n  unfold function.update_ite,\n  split_ifs; refl,\nend\n\n\n@[simp]\nlemma function.update_ite_idem\n  {α β : Type}\n  [decidable_eq α]\n  (f : α → β)\n  (a : α)\n  (x y : β)  :\n  function.update_ite (function.update_ite f a x) a y =\n    function.update_ite f a y :=\nbegin\n  funext,\n  unfold function.update_ite,\n  split_ifs,\n  {\n    refl,\n  },\n  {\n    refl,\n  }\nend\n\n\nlemma function.update_ite_id\n  {α : Type}\n  [decidable_eq α]\n  (x : α) :\n  function.update_ite (id : α → α) x x = id :=\nbegin\n  funext,\n  unfold function.update_ite,\n  split_ifs,\n  {\n    subst h,\n    simp only [id.def],\n  },\n  {\n    refl,\n  }\nend\n\n\nlemma function.update_ite_not_mem_list\n  {α β : Type}\n  [decidable_eq α]\n  (l : list α)\n  (f : α → β)\n  (a : α)\n  (b : β)\n  (h1 : a ∉ l) :\n  l.map (function.update_ite f a b) = l.map f :=\nbegin\n  induction l,\n  case list.nil\n  {\n    simp only [list.map_nil],\n  },\n  case list.cons : l_hd l_tl l_ih\n  {\n    simp only [list.mem_cons_iff] at h1,\n    push_neg at h1,\n    dsimp at h1,\n    cases h1,\n\n    simp only [list.map],\n    split,\n    {\n      unfold function.update_ite,\n      split_ifs; tauto,\n    },\n    {\n      exact l_ih h1_right,\n    }\n  },\nend\n\n\nlemma function.update_ite_not_mem_set\n  {α β : Type}\n  [decidable_eq α] [decidable_eq β]\n  (S : finset α)\n  (f : α → β)\n  (a : α)\n  (b : β)\n  (h1 : a ∉ S) :\n  finset.image (function.update_ite f a b) S = finset.image f S :=\nbegin\n  induction S using finset.induction_on,\n  case h₁\n  {\n    simp only [finset.image_empty],\n  },\n  case h₂ : S_a S_S S_1 S_ih\n  {\n    simp only [finset.mem_insert] at h1,\n    push_neg at h1,\n    dsimp at h1,\n    cases h1,\n\n\n    simp only [finset.image_insert],\n    congr' 1,\n    {\n      unfold function.update_ite,\n      split_ifs; tauto,\n    },\n    {\n      exact S_ih h1_right,\n    }\n  },\nend\n", "meta": {"author": "pthomas505", "repo": "lean3", "sha": "eb449be2b9a92becda4be38aac76e080194e3f7c", "save_path": "github-repos/lean/pthomas505-lean3", "path": "github-repos/lean/pthomas505-lean3/lean3-eb449be2b9a92becda4be38aac76e080194e3f7c/src/metalogic/fol/function_update_ite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.4960919970579166}}
{"text": "import Pauline.Notation\nimport Pauline.Statics\n\nopen Pauline\n\ndef program := [sml|\n\n  val loop = fn L => loop L\n\n  fun div (n : int, d : int) : int =\n    if n < d\n    then 0\n    else 1 + div (n-d, d)\n\n]\n\ndef program_ctx : Context := sorry\ndef program_state : State := sorry\n\ntheorem div_tc\n  : [smlprop|\n      program_ctx ⊢ div : int * int -> int\n    ]\n  := by\n  sorry\n\ntheorem div_thm\n  : ∀ n d : Nat, d > 0 → ∃ q r : Nat,\n    r < d ∧\n    n = q * d + r ∧\n    [smlprop|\n      program_state ⊢ div (↑n, ↑d) ==>* program_state ⊢ ↑q\n    ]\n  := by\n  intro n d h_d\n  induction n using Nat.strongInductionOn\n  case ind n ih =>\n  if h : n < d then\n    refine ⟨0, n, h, by simp, ?_⟩\n    (calc\n      (program_state, [sml_exp| div (↑n, ↑d)])\n        ==>* (program_state, [sml_exp| 0 ]) := by sorry\n      _ ==>* (program_state, [sml_exp| ↑0 ]) := ⟨0, rfl, rfl⟩\n    )\n  else\n    have : n - d < n := Nat.sub_lt (Nat.lt_of_lt_of_le h_d (Nat.ge_of_not_lt h)) h_d\n    have ⟨q,r,hr,hn,steps⟩ := ih (n-d) this\n    have : n = (1+q) * d + r := by\n      rw [Nat.add_mul, Nat.add_assoc, ←hn, Nat.one_mul, Nat.add_comm, Nat.sub_add_cancel (Nat.ge_of_not_lt h)]\n    refine ⟨_, _, hr, this, ?_⟩\n    (calc\n             (program_state, [sml_exp| div (↑n, ↑d)])\n        ==>* (program_state, [sml_exp| 1 + div (↑n-↑d,↑d)]) := by sorry\n      _ ==>* (program_state, [sml_exp| 1 + ↑q ])            := by sorry -- ih\n      _ ==>* (program_state, [sml_exp| ↑(1+q) ])            := by sorry\n    )\n", "meta": {"author": "JamesGallicchio", "repo": "pauline", "sha": "b955641fd085964c363d60d8a6ca3cbba741d8f0", "save_path": "github-repos/lean/JamesGallicchio-pauline", "path": "github-repos/lean/JamesGallicchio-pauline/pauline-b955641fd085964c363d60d8a6ca3cbba741d8f0/Main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4960919939897151}}
{"text": "/- ACL and MIdFF, Lean 2022 meeting at Icerm -/\nimport ring_theory.power_series.basic\nimport algebra_lemmas\nimport combinatorics_lemmas\nimport data.nat.choose.multinomial\n\n/-! # Divided powers \n\nLet `A` be a commutative ring and `I` be an ideal of `A`. \nA *divided power* structure on `I` is the datum of operations `div_pow : ℕ → I → A` \nsatisfying relations that model the intuitive formula `div_pow n a = a ^ n / n.factorial` and\ncollected by the structure `divided_powers`.\nTo avoid coercions, we rather consider `div_pow : ℕ → A → A`, extended by 0.\n\n## References \n\n* P. Berthelot (1974), *Cohomologie cristalline des schémas de caractéristique $p$ > 0*, \nLectures notes in mathematics 407, Springer-Verlag.\n\n* P. Berthelot and A. Ogus (1978), *Notes on crystalline cohomology*, \nPrinceton University Press.\n\n* N. Roby (1963). « Lois polynomes et lois formelles en théorie des modules ». Annales scientifiques de l’École Normale Supérieure 80 (3): 213‑348. https://doi.org/10.24033/asens.1124.\n\n* N. Roby (1968), *Construction de certaines algèbres à puissances divisées*, \nBulletin de la Société Mathématique de France, Tome 96, p. 97-113. \ndoi: https://doi.org/10.24033/bsmf.1661\n\n* N. Roby (1966), *Sur l'algèbre des puissances divisées d'un module et le module de ses \ndifférentielles*, Annales scientifiques de l'École Normale Supérieure, Série 3, Tome 83,no. 2, \np. 75-89. \ndoi: https://doi.org/10.24033/asens.1148\n\n-/\n\nsection divided_powers_definition\n\n\n\n\n/-- The divided power structure on an ideal I of a commutative ring A -/\n@[ext] structure divided_powers {A : Type*} [comm_ring A] (I : ideal A) := \n(dpow : ℕ → A → A)\n(dpow_null : ∀ {n x} (hx : x ∉ I), dpow n x = 0)\n(dpow_zero : ∀ {x} (hx : x ∈ I), dpow 0 x = 1)\n(dpow_one : ∀ {x} (hx : x ∈ I), dpow 1 x = x)\n(dpow_mem : ∀ {n} (hn : n ≠ 0) {x} (hx : x ∈ I), dpow n x ∈ I)\n(dpow_add : ∀ n {x y} (hx : x ∈ I) (hy : y ∈ I) , dpow n (x + y)\n  = finset.sum (finset.range (n + 1)) (λ k, (dpow k x) * (dpow (n - k) y)))\n(dpow_smul : ∀ n {a : A} {x} (hx : x ∈ I), dpow n (a * x) = (a ^ n) * (dpow n x))\n(dpow_mul : ∀ m n {x} (hx : x ∈ I), (dpow m x) * (dpow n x) = (nat.choose (m+n) m) * dpow (m + n) x)\n(dpow_comp : ∀ m {n} (hn : n ≠ 0) {x} (hx : x ∈ I),\n  dpow m (dpow n x) = (mchoose m n) * dpow (m * n) x)\n\ninstance {A : Type*} [comm_ring A] (I : ideal A) :\n  has_coe_to_fun (divided_powers I) (λ _, ℕ → A → A) :=\n⟨λ hI, hI.dpow⟩\n\nstructure pd_ring (A : Type*) extends comm_ring A := \n(pd_ideal : ideal A)\n(divided_powers : divided_powers pd_ideal)\n\nend divided_powers_definition\n\nnamespace divided_powers\n\nsection basic_lemmas\n\nvariables {A : Type*} [comm_ring A] {I : ideal A}\n\ndef dpow_exp (hI : divided_powers I) (a : A) := power_series.mk (λ n, hI.dpow n a)\n\nlemma add_dpow_exp (hI : divided_powers I) {a b : A} (ha : a ∈ I) (hb : b ∈ I) :\n  hI.dpow_exp (a + b) = hI.dpow_exp (a) * hI.dpow_exp (b) :=\nbegin   \n  simp only [dpow_exp],\n  ext,\n  simp only [power_series.coeff_mk, power_series.coeff_mul],\n  rw [hI.dpow_add n ha hb, finset.nat.sum_antidiagonal_eq_sum_range_succ_mk], \nend\n\nlemma eq_of_eq_on_ideal (hI : divided_powers I) (hI' : divided_powers I) \n  (h_eq : ∀ (n : ℕ) {x : A} (hx : x ∈ I), hI.dpow n x = hI'.dpow n x ) : hI = hI' :=\nbegin\n  ext n x,\n  by_cases hx : x ∈ I,\n  { exact h_eq n hx },\n  { rw [hI.dpow_null hx, hI'.dpow_null hx] }\nend\n\n/- noncomputable\ndef dpow_of_dpow_exp (I : ideal A) (ε : I → power_series A) : \n  ℕ → A → A := λ n,\n  function.extend \n    (λ (a : I), a.val) \n    (λ a, power_series.coeff A n (ε a))\n    (λ (a :A) , (0 : A))\n\n-- Golfed version of definition\nnoncomputable def dpow_of_dpow_exp (I : ideal A) (ε : I → power_series A) : ℕ → A → A := \nλ n, function.extend (λ (a : I), (a : A)) (λ (a : I), power_series.coeff A n (ε a)) 0\n\ndef divided_powers_of_dpow_exp (I : ideal A) (ε : I → power_series A)\n  (hε_add : ∀ (a b : I), ε(a + b) = ε(a) * ε(b))\n  (hε_zero : ε(0) = 1) -/\n\n\nvariable (hI : divided_powers I)\n\n/- Rewriting lemmas -/\nlemma dpow_smul' (n : ℕ) {a : A} {x : A} (hx : x ∈ I) :\n  hI.dpow n (a • x) = (a ^ n) • (hI.dpow n x) :=\nby simp only [smul_eq_mul, hI.dpow_smul, hx]\n\nlemma factorial_mul_dpow_eq_pow (n : ℕ) (x : A) (hx : x ∈ I) :\n  (n.factorial : A) * (hI.dpow n x) = x^n :=\nbegin\n  induction n with n ih,\n  { rw [nat.nat_zero_eq_zero, nat.factorial_zero, nat.cast_one, one_mul, pow_zero,\n      hI.dpow_zero hx], },\n  { rw [nat.factorial_succ, mul_comm (n + 1), ← (n + 1).choose_one_right,\n  ← nat.choose_symm_add, nat.cast_mul, nat.succ_eq_add_one, mul_assoc, \n  ← hI.dpow_mul n 1 hx, ← mul_assoc, ih, hI.dpow_one hx, pow_succ'], }\nend\n\nlemma dpow_eval_zero {n : ℕ} (hn : n ≠ 0) : hI.dpow n 0 = 0 := \nby rw [← mul_zero (0 : A), hI.dpow_smul n I.zero_mem, zero_pow' n hn, zero_mul, zero_mul]\n\n/-- Proposition 1.2.7 of [B74], part (i). -/\nlemma nilpotent_of_pd_ideal_mem (hI : divided_powers I) {n : ℕ} (hn : n ≠ 0)\n  (hnI : ∀ {y : A}(hy : y ∈ I), n • y = 0) {x : A} (hx : x ∈ I) : x^n = 0 := \nbegin\n  have h_fac: (n.factorial : A) * hI.dpow n x = n • ((n-1).factorial : A) * hI.dpow n x,\n  { rw [nsmul_eq_mul, ← nat.cast_mul, nat.mul_factorial_pred (nat.pos_of_ne_zero hn)] },\n  rw [← factorial_mul_dpow_eq_pow hI _ _ hx, h_fac, smul_mul_assoc],\n  exact hnI (I.mul_mem_left ((n - 1).factorial : A) (hI.dpow_mem hn hx))\nend\n\n/-- If J is another ideal of A with divided powers, \nthen the divided powers of I and J coincide on I • J \n(Berthelot, 1.6.1 (ii))-/\nlemma coincide_on_smul {J : ideal A} (hJ : divided_powers J) {n : ℕ} {a : A} (ha : a ∈ I • J) : \n  hI.dpow n a = hJ.dpow n a :=\nbegin\n  revert n,\n  apply submodule.smul_induction_on' ha,\n  { intros a ha b hb n, \n    rw [algebra.id.smul_eq_mul, hJ.dpow_smul n hb, mul_comm a b, hI.dpow_smul n ha, \n      ← hJ.factorial_mul_dpow_eq_pow n b hb, ← hI.factorial_mul_dpow_eq_pow n a ha],\n    ring, },\n  { intros x hx y hy hx' hy' n, \n    rw [hI.dpow_add n (ideal.mul_le_right hx) (ideal.mul_le_right hy), \n      hJ.dpow_add n (ideal.mul_le_left hx) (ideal.mul_le_left hy)], \n    apply finset.sum_congr rfl,\n    intros k hk,\n    rw [hx', hy'], },\nend\n\nopen finset\n\n/- Rob65, formula (III')-/\n/-- A product of divided powers is a multinomial coefficient times the divided power-/\nlemma mul_dpow {ι : Type*} [decidable_eq ι] {s : finset ι} (n : ι → ℕ) {a : A} (ha : a ∈ I):\n  s.prod (λ i, hI.dpow (n i) a) = (nat.multinomial s n) * hI.dpow (s.sum n) a := \nbegin\n  revert s,\n  apply finset.induction,\n  -- case : s = ∅ \n  simp only [prod_empty, nat.multinomial_nil, algebra_map.coe_one, sum_empty, one_mul, hI.dpow_zero ha],\n  -- inductive step\n  intros i s hi hrec,\n  rw finset.prod_insert hi, rw hrec, \n  rw ←mul_assoc, \n  nth_rewrite 1 [mul_comm], \n  rw mul_assoc,\n  rw dpow_mul _ _ _ ha, \n  rw ← finset.sum_insert hi, \n  rw ← mul_assoc,\n  apply congr_arg2 _ _ rfl, \n  rw [nat.multinomial_insert _ _ hi, mul_comm, nat.cast_mul, finset.sum_insert hi], \nend\n\n-- Also : can it be used to deduce dpow_comp from the rest?\n/-- A generic “multinomial” theorem for divided powers — but without multinomial coefficients \n  — using only dpow_zero, dpow_add and dpow_eval_zero  -/\nlemma sum_dpow_aux (dpow : ℕ → A → A) (dpow_zero : ∀ {x} (hx : x ∈ I), dpow 0 x = 1)\n  (dpow_add : ∀ n {x y} (hx : x ∈ I) (hy : y ∈ I) , dpow n (x + y) =\n    finset.sum (finset.range (n + 1)) (λ k, (dpow k x) * (dpow (n - k) y)))\n  (dpow_eval_zero : ∀ {n : ℕ} (hn : n ≠ 0), dpow n 0 = 0) {ι : Type*} [decidable_eq ι]\n  {s : finset ι} {x : ι → A} (hx : ∀ i ∈ s, x i ∈ I) : \n  ∀ (n : ℕ), dpow n (s.sum x) = \n    (finset.sym s n).sum (λ k, s.prod (λ i, dpow (multiset.count i k) (x i))) := \nbegin\n  induction s using finset.induction with a s ha ih,\n  { rw sum_empty,\n    rintro (_ | n),\n    { rw [dpow_zero (I.zero_mem), sum_unique_nonempty, prod_empty],\n      exact univ_nonempty },\n    { rw [dpow_eval_zero (nat.succ_ne_zero n), sym_empty, sum_empty], }},\n  { have hx' : ∀ i, i ∈ s → x i ∈ I := \n    λ i hi, hx i (finset.mem_insert_of_mem hi), \n    intro n,\n    simp_rw [sum_insert ha, \n      dpow_add n (hx a (finset.mem_insert_self a s)) \n        (I.sum_mem (λ i, hx' i)),\n      sum_range, ih hx', mul_sum, sum_sigma'], \n\n    refine (sum_bij' \n      (λ m _, sym.filter_ne a m) \n      (λ m hm, finset.mem_sigma.2 ⟨mem_univ _, _⟩)\n      (λ m hm, _) \n      (λ m _, m.2.fill a m.1)\n      _ \n      (λ m _, m.fill_filter_ne a) \n      -- explicit arguments above rather than m.fill_filter_ne a\n      -- adjust once multinomial has been incorporated to mathlib\n      (λ m hm, _)).symm,\n    \n  -- #3\n    { convert sym_filter_ne_mem a hm, rw erase_insert ha },\n  -- #4\n    { dsimp only [sym.filter_ne, fin.coe_mk],\n      rw finset.prod_insert ha, \n      apply congr_arg2 _ rfl, \n      apply finset.prod_congr rfl,\n      intros i hi, simp only [subtype.val_eq_coe, sym.mk_coe], \n      apply congr_arg2 _ _ rfl,\n      rw multiset.count_filter,\n      rw if_pos _, \n      intro hi', apply ha, rw hi', exact hi, },\n      \n    { exact λ m hm, sym_fill_mem a (mem_sigma.1 hm).2 },\n    { exact sym.filter_ne_fill a m (mt (mem_sym_iff.1 (mem_sigma.1 hm).2 a) ha) }},\nend\n\n/-- A “multinomial” theorem for divided powers — without multinomial coefficients -/\nlemma sum_dpow {ι : Type*} [decidable_eq ι] {s : finset ι} {x : ι → A} (hx : ∀ i ∈ s, x i ∈ I) :\n  ∀ (n : ℕ), hI.dpow n (s.sum x) = \n    (finset.sym s n).sum (λ k, s.prod (λ i, hI.dpow (multiset.count i k) (x i))) :=\nsum_dpow_aux hI.dpow (λ x hx, hI.dpow_zero hx) \n  (λ n x y hx hy, hI.dpow_add n hx hy) (λ n hn, hI.dpow_eval_zero hn) hx\n\nlemma prod_dpow_self {ι : Type*} [decidable_eq ι] {s : finset ι} {n : ι → ℕ} (a : A) (ha : a ∈ I) :\n  s.prod (λ i, hI.dpow (n i) a) = nat.multinomial s n * hI.dpow (s.sum n) a :=\nbegin\n  induction s using finset.induction with i s hi ih,\n  { rw [finset.prod_empty, finset.sum_empty, hI.dpow_zero ha, nat.multinomial_nil, \n      nat.cast_one, mul_one] },\n  { rw [finset.prod_insert hi, ih, ← mul_assoc, mul_comm (hI.dpow _ a), mul_assoc,\n      hI.dpow_mul _ _ ha, ← finset.sum_insert hi, ← mul_assoc],\n    apply congr_arg2 _ _ rfl,\n    rw [mul_comm, nat.multinomial_insert s n hi, finset.sum_insert hi, nat.cast_mul], },\nend\n\nend basic_lemmas\n\nsection divided_powers_morphisms\n\n/-- Compatibility of a ring morphism with pd-structures -/\ndef is_pd_morphism {A B : Type*} [comm_ring A] [comm_ring B] {I : ideal A} {J : ideal B}\n  (hI : divided_powers I) (hJ : divided_powers J) (f : A →+* B) : Prop :=\n(I.map f) ≤ J ∧  ∀ (n : ℕ) (a ∈ I), hJ.dpow n (f a) = f (hI.dpow n a)\n\n/-- The structure of a pd_morphism between rings endowed with pd-rings -/\nstructure pd_morphism {A B : Type*} [comm_ring A] [comm_ring B] {I : ideal A} {J : ideal B }\n  (hI : divided_powers I) (hJ : divided_powers J) :=\n(to_ring_hom : A →+* B)\n(ideal_comp : I.map to_ring_hom ≤ J)\n(dpow_comp : ∀ (n : ℕ) (a ∈ I), \n  hJ.dpow n (to_ring_hom a) = to_ring_hom (hI.dpow n a))\n\n/- Roby65, Proposition 2. (TODO: rename?)-/\ndef pd_morphism_ideal {A B : Type*} [comm_ring A] [comm_ring B] {I : ideal A} {J : ideal B}\n  (hI : divided_powers I) (hJ : divided_powers J) {f : A →+* B} (hf : I.map f ≤ J) : \n  ideal A := \n{ carrier   := {x ∈ I | ∀ (n : ℕ), f (hI.dpow n (x : A)) = (hJ.dpow n (f (x : A)))},\n  add_mem'  := λ x y hx hy,\n  begin\n    simp only [set.mem_sep_iff, set_like.mem_coe] at hx hy ⊢,\n    refine ⟨I.add_mem hx.1 hy.1, _⟩,\n    intros n,\n    rw [hI.dpow_add _ hx.1 hy.1, map_add,\n      hJ.dpow_add _ (hf ( ideal.mem_map_of_mem f hx.1)) (hf ( ideal.mem_map_of_mem f hy.1)),\n      map_sum], \n    apply congr_arg,\n    ext k,\n    rw [map_mul, hx.2 k, hy.2 (n - k)]\n  end,\n  zero_mem' := begin\n    simp only [set.mem_sep_iff, set_like.mem_coe, submodule.zero_mem, map_zero, true_and],\n    intro n,\n    cases n,\n    { rw [hI.dpow_zero I.zero_mem, hJ.dpow_zero J.zero_mem, map_one] },\n    { rw [hI.dpow_eval_zero n.succ_ne_zero,hJ.dpow_eval_zero n.succ_ne_zero, map_zero] }\n  end,\n  smul_mem' := λ r x hx,\n  begin\n    simp only [set.mem_sep_iff, set_like.mem_coe] at hx ⊢,\n    refine ⟨I.smul_mem r hx.1, _⟩,\n    intros n,\n    rw [smul_eq_mul, hI.dpow_smul _ hx.1, map_mul, map_mul, map_pow,\n      hJ.dpow_smul _ (hf ( ideal.mem_map_of_mem f hx.1)), hx.2 n],\n  end }\n\n/- Roby65, Proposition 3.  (TODO: rename?) -/\ndef pd_morphism_from_gens {A B : Type*} [comm_ring A] [comm_ring B] {I : ideal A} {J : ideal B}\n  (hI : divided_powers I) (hJ : divided_powers J) {f : A →+* B} {S : set A} (hS : ideal.span S = I)\n  (hf : I.map f ≤ J) (h : ∀ (x : S) (n : ℕ), f (hI.dpow n x) = hJ.dpow n (f x)) : \n  pd_morphism hI hJ := \n{ to_ring_hom := f,\n  ideal_comp  := hf,\n  dpow_comp   := λ n x hx,\n  begin\n    have hS' : S ⊆ (pd_morphism_ideal hI hJ hf),\n    { intros y hy,\n      simp only [set_like.mem_coe, pd_morphism_ideal, submodule.mem_mk, set.mem_sep_iff,\n        set_like.mem_coe], \n      split,\n      rw ←hS, \n      exact ideal.subset_span hy, \n      exact h ⟨y, hy⟩ },\n    rw [← ideal.span_le, hS] at hS',\n    exact ((hS' hx).2 n).symm,\n  end }\n\nlemma pd_morphism_from_gens_coe {A B : Type*} [comm_ring A] [comm_ring B] {I : ideal A} {J : ideal B}\n  (hI : divided_powers I) (hJ : divided_powers J) {f : A →+* B} {S : set A} (hS : ideal.span S = I)\n  (hf : I.map f ≤ J) (h : ∀ (x : S) (n : ℕ), f (hI.dpow n x) = hJ.dpow n (f x)) : \n  (pd_morphism_from_gens hI hJ hS hf h).to_ring_hom = f :=\nrfl\n\n/- Roby65, corollary after proposition 3 -/\nexample {A : Type*} [comm_ring A] {I : ideal A} (hI hI' : divided_powers I) {S : set A} (hS : ideal.span S = I) (hdp : ∀ (n : ℕ) (a ∈ S), hI.dpow n a = hI'.dpow n a) : hI = hI' :=\nbegin\n  suffices : I.map (ring_hom.id A) ≤ I, \n  let pd_id := pd_morphism_from_gens hI hI' hS this _,\n  ext n a,\n  by_cases ha : a ∈ I,\n  have := pd_id.dpow_comp n a ha, \n  suffices pd_id_id : ∀ (x : A), pd_id.to_ring_hom x = x,\n  simp only [pd_id_id] at this,  exact this.symm, \n  { intro x,refl, },\n  sorry,\n  sorry,\n  sorry,\nend\n\n\n-- For the moment, the notation does not work\n-- notation `p(` A `,` I, `,` hI `)` →ₚ  `(` B `,` J, `,` hJ `)` := pd_morphism hI hJ\n-- Also, we expect a `pd` subscript\n\n/- TODO : identity, composition… -/\n\nend divided_powers_morphisms\n\nend divided_powers\n\n/- Comparison with Berthelot, Coho. cristalline\n\n1.1 : done\n1.2.1 : follows from 1.2.7 - done (for ℚ-algebras).\n1.2.2 (*) : To be added\n1.2.4 : To be added if Cohen/Witt vectors rings exist\n1.2.7 (M) : done\n1.3 (pd -morphism) : done\n1.3.1 : To be added (needs colimits of rings)\n\n1.4 : To be added, but difficult\n1.5.: depends on 1.4  \n\n1.6 : sub-pd-ideal : done\n1.6.1 Done !\n1.6.2 : Done : dpow_quot]\n1.6.4 (A) : to be added\n(should we add the remark on page 33)\n1.6.5 (A): to be added\n\n1.7 : tensor product, see Roby\n\n1.8 (M). Done! \n\n\nPRs : \n (M) : ring_inverse, tsub_tsub - DONE\n (A) : submodule_induction, function.extend_apply_first - DONE\n\nDelete obsolete versions\n (A) : rewrite_4_sums -- Done, I think, but how could we simplify these lemmas?\n\n(A) Simplify, \n  remove not_eq_or_aux (see REMOVE or MOVE) -- DONE\n  Prove uniqueness of pd-structure when possible\n    (ideal_add [Done], dpow_quot [Done])\n(M) Complete the lattice structure\n\n-/\n\nexample (M : Type*) [add_monoid M] : add_monoid (with_top M) := by refine with_top.add_monoid\n\n/- Roby (1965):\n - Pregraded algebra (using mathlib's graded_algebra) - with_top unit (later, if needed)\n - Tensor product of graded algebras is a graded algebra\n - Add III' explicitly.\n - Proposition 1 -- I think this is essentially Lemma 3.6 of [BO].\n - Proposition 2\n - Proposition 3\n\n I just noticed that we are using dp and pd in different names, we should pick a convention.\n-/\n\n/- \nIdea of generalizing the theory to more general divisors systems\nmodeling x^n/n!, x^n/p^n, etc.\nbut it is not clear what to consider\nAlso, not clear it can really be done…\n\nstructure divisor_system {R : Type*} [comm_ring R] := \n(dpow_choose : ℕ → ℕ → R)\n(dpow_mchoose : ℕ → ℕ → R)\n-- (conditions : Prop)\nTwo options :\n1) dpow n x = x^n/(c n)\nExamples : c n = n.factorial,  c n = p ^ n\n2) dpow n x = x ^ n / (d 1 * d 2 * ... * d n)\nExamples : d n = n,  d n = p\n\ndpow n (x + y) = (x+y)^n / c n\n = sum  (n.choose k) x ^(n -k) y ^k / c n\n = sum [(n.choose k) (c k) (c (n-k)) / c n] dpow (n - k) x * dpow k y \n\n  Case 1 : dpow_choose n k = 1 ;  case 2 : dpow_choose n k = choose\n\ndpow m x * dpow n x = x ^ m * x ^ n / c m * c n\n  = dpow (m + n) x * (c (n+m) / c m * c n)\n\n   Case 1 : coeff = (n+m).choose m ; Case 2 :  = 1\n\ndpow m (dpow n x) = (x ^n / c n) ^ m / c m = x ^ (m n) / ((c n ^ m) * c m)\n = [ ] * dpow (m n) x\n  with [ ] = c (m n)/ (c n)^m (c m)\n\n  Case 1 : [ ] = mchoose m n, case 2 : p^ (-m)\n\n-/\n", "meta": {"author": "AntoineChambert-Loir", "repo": "divided_powers", "sha": "86b6f8716590d38e63ed11d34c0140de8ae2af7d", "save_path": "github-repos/lean/AntoineChambert-Loir-divided_powers", "path": "github-repos/lean/AntoineChambert-Loir-divided_powers/divided_powers-86b6f8716590d38e63ed11d34c0140de8ae2af7d/src/divided_powers/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.49609198440227315}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.instances.real_vector_space\nimport Mathlib.analysis.normed_space.add_torsor\nimport Mathlib.linear_algebra.affine_space.midpoint\nimport Mathlib.analysis.normed_space.linear_isometry\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Mazur-Ulam Theorem\n\nMazur-Ulam theorem states that an isometric bijection between two normed affine spaces over `ℝ` is\naffine. We formalize it in three definitions:\n\n* `isometric.to_real_linear_isometry_equiv_of_map_zero` : given `E ≃ᵢ F` sending `0` to `0`,\n  returns `E ≃ₗᵢ[ℝ] F` with the same `to_fun` and `inv_fun`;\n* `isometric.to_real_linear_isometry_equiv` : given `f : E ≃ᵢ F`,\n  returns `g : E ≃ₗᵢ[ℝ] F` with `g x = f x - f 0`.\n* `isometric.to_affine_equiv` : given `PE ≃ᵢ PF`, returns `g : PE ≃ᵃ[ℝ] PF` with the same\n  `to_equiv`.\n\nThe formalization is based on [Jussi Väisälä, *A Proof of the Mazur-Ulam Theorem*][Vaisala_2003].\n\n## Tags\n\nisometry, affine map, linear map\n-/\n\nnamespace isometric\n\n\n/-- If an isometric self-homeomorphism of a normed vector space over `ℝ` fixes `x` and `y`,\nthen it fixes the midpoint of `[x, y]`. This is a lemma for a more general Mazur-Ulam theorem,\nsee below. -/\ntheorem midpoint_fixed {E : Type u_1} {PE : Type u_2} [normed_group E] [normed_space ℝ E]\n    [metric_space PE] [normed_add_torsor E PE] {x : PE} {y : PE} (e : PE ≃ᵢ PE) :\n    coe_fn e x = x → coe_fn e y = y → coe_fn e (midpoint ℝ x y) = midpoint ℝ x y :=\n  sorry\n\n/-- A bijective isometry sends midpoints to midpoints. -/\ntheorem map_midpoint {E : Type u_1} {PE : Type u_2} [normed_group E] [normed_space ℝ E]\n    [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F]\n    [normed_space ℝ F] [metric_space PF] [normed_add_torsor F PF] (f : PE ≃ᵢ PF) (x : PE) (y : PE) :\n    coe_fn f (midpoint ℝ x y) = midpoint ℝ (coe_fn f x) (coe_fn f y) :=\n  sorry\n\n/-!\nSince `f : PE ≃ᵢ PF` sends midpoints to midpoints, it is an affine map.\nWe define a conversion to a `continuous_linear_equiv` first, then a conversion to an `affine_map`.\n-/\n\n/-- Mazur-Ulam Theorem: if `f` is an isometric bijection between two normed vector spaces\nover `ℝ` and `f 0 = 0`, then `f` is a linear equivalence. -/\ndef to_real_linear_isometry_equiv_of_map_zero {E : Type u_1} [normed_group E] [normed_space ℝ E]\n    {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (h0 : coe_fn f 0 = 0) :\n    linear_isometry_equiv ℝ E F :=\n  linear_isometry_equiv.mk\n    (linear_equiv.mk\n      (linear_map.to_fun\n        (continuous_linear_map.to_linear_map\n          (add_monoid_hom.to_real_linear_map (add_monoid_hom.of_map_midpoint ℝ ℝ (⇑f) h0 sorry)\n            sorry)))\n      sorry sorry (equiv.inv_fun (to_equiv f)) sorry sorry)\n    sorry\n\n@[simp] theorem coe_to_real_linear_equiv_of_map_zero {E : Type u_1} [normed_group E]\n    [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F)\n    (h0 : coe_fn f 0 = 0) : ⇑(to_real_linear_isometry_equiv_of_map_zero f h0) = ⇑f :=\n  rfl\n\n@[simp] theorem coe_to_real_linear_equiv_of_map_zero_symm {E : Type u_1} [normed_group E]\n    [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F)\n    (h0 : coe_fn f 0 = 0) :\n    ⇑(linear_isometry_equiv.symm (to_real_linear_isometry_equiv_of_map_zero f h0)) =\n        ⇑(isometric.symm f) :=\n  rfl\n\n/-- Mazur-Ulam Theorem: if `f` is an isometric bijection between two normed vector spaces\nover `ℝ`, then `x ↦ f x - f 0` is a linear equivalence. -/\ndef to_real_linear_isometry_equiv {E : Type u_1} [normed_group E] [normed_space ℝ E] {F : Type u_3}\n    [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) : linear_isometry_equiv ℝ E F :=\n  to_real_linear_isometry_equiv_of_map_zero\n    (isometric.trans f (isometric.symm (isometric.add_right (coe_fn f 0)))) sorry\n\n@[simp] theorem to_real_linear_equiv_apply {E : Type u_1} [normed_group E] [normed_space ℝ E]\n    {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (x : E) :\n    coe_fn (to_real_linear_isometry_equiv f) x = coe_fn f x - coe_fn f 0 :=\n  Eq.symm (sub_eq_add_neg (coe_fn f x) (coe_fn f 0))\n\n@[simp] theorem to_real_linear_isometry_equiv_symm_apply {E : Type u_1} [normed_group E]\n    [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (y : F) :\n    coe_fn (linear_isometry_equiv.symm (to_real_linear_isometry_equiv f)) y =\n        coe_fn (isometric.symm f) (y + coe_fn f 0) :=\n  rfl\n\n/-- Convert an isometric equivalence between two affine spaces to an `affine_map`. -/\ndef to_affine_equiv {E : Type u_1} {PE : Type u_2} [normed_group E] [normed_space ℝ E]\n    [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F]\n    [normed_space ℝ F] [metric_space PF] [normed_add_torsor F PF] (f : PE ≃ᵢ PF) :\n    affine_equiv ℝ PE PF :=\n  affine_equiv.mk' (to_equiv f)\n    (linear_isometry_equiv.to_linear_equiv\n      (to_real_linear_isometry_equiv\n        (isometric.trans (vadd_const (classical.arbitrary PE))\n          (isometric.trans f (isometric.symm (vadd_const (coe_fn f (classical.arbitrary PE))))))))\n    (classical.arbitrary PE) sorry\n\n@[simp] theorem coe_to_affine_equiv {E : Type u_1} {PE : Type u_2} [normed_group E]\n    [normed_space ℝ E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4}\n    [normed_group F] [normed_space ℝ F] [metric_space PF] [normed_add_torsor F PF] (f : PE ≃ᵢ PF) :\n    ⇑(to_affine_equiv f) = ⇑f :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/mazur_ulam_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4960919813340715}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.punit\nimport Mathlib.category_theory.comma\nimport Mathlib.category_theory.is_connected\nimport Mathlib.category_theory.limits.yoneda\nimport Mathlib.category_theory.limits.types\nimport Mathlib.PostPort\n\nuniverses v u \n\nnamespace Mathlib\n\n/-!\n# Cofinal functors\n\nA functor `F : C ⥤ D` is cofinal if for every `d : D`,\nthe comma category of morphisms `d ⟶ F.obj c` is connected.\n\nWe prove the following three statements are equivalent:\n1. `F : C ⥤ D` is cofinal.\n2. Every functor `G : D ⥤ E` has a colimit if and only if `F ⋙ G` does,\n   and these colimits are isomorphic via `colimit.pre G F`.\n3. `colimit (F ⋙ coyoneda.obj (op d)) ≅ punit`.\n\nStarting at 1. we show (in `cocones_equiv`) that\nthe categories of cocones over `G : D ⥤ E` and over `F ⋙ G` are equivalent.\n(In fact, via an equivalence which does not change the cocone point.)\nThis readily implies 2., as `comp_has_colimit`, `has_colimit_of_comp`, and `colimit_iso`.\n\nFrom 2. we can specialize to `G = coyoneda.obj (op d)` to obtain 3., as `colimit_comp_coyoneda_iso`.\n\nFrom 3., we prove 1. directly in `cofinal_of_colimit_comp_coyoneda_iso_punit`.\n\nWe also show these conditions imply:\n4. Every functor `H : Dᵒᵖ ⥤ E` has a limit if and only if `F.op ⋙ H` does,\n   and these limits are isomorphic via `limit.pre H F.op`.\n\n\n## Naming\nThere is some discrepancy in the literature about naming; some say 'final' instead of 'cofinal'.\nThe explanation for this is that the 'co' prefix here is *not* the usual category-theoretic one\nindicating duality, but rather indicating the sense of \"along with\".\n\nWhile the trend seems to be towards using 'final', for now we go with the bulk of the literature\nand use 'cofinal'.\n\n## References\n* https://stacks.math.columbia.edu/tag/09WN\n* https://ncatlab.org/nlab/show/final+functor\n* Borceux, Handbook of Categorical Algebra I, Section 2.11.\n  (Note he reverses the roles of definition and main result relative to here!)\n-/\n\nnamespace category_theory\n\n\n/--\nA functor `F : C ⥤ D` is cofinal if for every `d : D`, the comma category of morphisms `d ⟶ F.obj c`\nis connected.\n\nSee https://stacks.math.columbia.edu/tag/04E6\n-/\ndef cofinal {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) :=\n  ∀ (d : D), is_connected (comma (functor.from_punit d) F)\n\nprotected instance comma.is_connected {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [ℱ : cofinal F] (d : D) : is_connected (comma (functor.from_punit d) F) :=\n  ℱ d\n\nnamespace cofinal\n\n\nprotected instance category_theory.comma.nonempty {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] (d : D) : Nonempty (comma (functor.from_punit d) F) :=\n  is_connected.is_nonempty\n\n/--\nWhen `F : C ⥤ D` is cofinal, we denote by `lift F d` an arbitrary choice of object in `C` such that\nthere exists a morphism `d ⟶ F.obj (lift F d)`.\n-/\ndef lift {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] (d : D) : C :=\n  comma.right (classical.arbitrary (comma (functor.from_punit d) F))\n\n/--\nWhen `F : C ⥤ D` is cofinal, we denote by `hom_to_lift` an arbitrary choice of morphism\n`d ⟶ F.obj (lift F d)`.\n-/\ndef hom_to_lift {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] (d : D) : d ⟶ functor.obj F (lift F d) :=\n  comma.hom (classical.arbitrary (comma (functor.from_punit d) F))\n\n/--\nWe provide an induction principle for reasoning about `lift` and `hom_to_lift`.\nWe want to perform some construction (usually just a proof) about\nthe particular choices `lift F d` and `hom_to_lift F d`,\nit suffices to perform that construction for some other pair of choices\n(denoted `X₀ : C` and `k₀ : d ⟶ F.obj X₀` below),\nand to show that how to transport such a construction\n*both* directions along a morphism between such choices.\n-/\ntheorem induction {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {d : D} (Z : (X : C) → (d ⟶ functor.obj F X) → Prop) (h₁ : ∀ (X₁ X₂ : C) (k₁ : d ⟶ functor.obj F X₁) (k₂ : d ⟶ functor.obj F X₂) (f : X₁ ⟶ X₂),\n  k₁ ≫ functor.map F f = k₂ → Z X₁ k₁ → Z X₂ k₂) (h₂ : ∀ (X₁ X₂ : C) (k₁ : d ⟶ functor.obj F X₁) (k₂ : d ⟶ functor.obj F X₂) (f : X₁ ⟶ X₂),\n  k₁ ≫ functor.map F f = k₂ → Z X₂ k₂ → Z X₁ k₁) {X₀ : C} {k₀ : d ⟶ functor.obj F X₀} (z : Z X₀ k₀) : Z (lift F d) (hom_to_lift F d) := sorry\n\n/--\nGiven a cocone over `F ⋙ G`, we can construct a `cocone G` with the same cocone point.\n-/\n@[simp] theorem extend_cocone_map_hom {C : Type v} [small_category C] {D : Type v} [small_category D] {F : C ⥤ D} [cofinal F] {E : Type u} [category E] {G : D ⥤ E} (X : limits.cocone (F ⋙ G)) (Y : limits.cocone (F ⋙ G)) (f : X ⟶ Y) : limits.cocone_morphism.hom (functor.map extend_cocone f) = limits.cocone_morphism.hom f :=\n  Eq.refl (limits.cocone_morphism.hom (functor.map extend_cocone f))\n\n@[simp] theorem colimit_cocone_comp_aux {C : Type v} [small_category C] {D : Type v} [small_category D] {F : C ⥤ D} [cofinal F] {E : Type u} [category E] {G : D ⥤ E} (s : limits.cocone (F ⋙ G)) (j : C) : functor.map G (hom_to_lift F (functor.obj F j)) ≫ nat_trans.app (limits.cocone.ι s) (lift F (functor.obj F j)) =\n  nat_trans.app (limits.cocone.ι s) j := sorry\n\n/-- An auxilliary construction for `extend_cone`, moving `op` around. -/\ndef extend_cone_cone_to_cocone {C : Type v} [small_category C] {D : Type v} [small_category D] {E : Type u} [category E] {F : C ⥤ D} {H : Dᵒᵖ ⥤ E} (c : limits.cone (functor.op F ⋙ H)) : limits.cocone (F ⋙ functor.right_op H) :=\n  limits.cocone.mk (opposite.op (limits.cone.X c))\n    (nat_trans.mk fun (j : C) => has_hom.hom.op (nat_trans.app (limits.cone.π c) (opposite.op j)))\n\n/-- An auxilliary construction for `extend_cone`, moving `op` around. -/\ndef extend_cone_cocone_to_cone {D : Type v} [small_category D] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} (c : limits.cocone (functor.right_op H)) : limits.cone H :=\n  limits.cone.mk (opposite.unop (limits.cocone.X c))\n    (nat_trans.mk fun (j : Dᵒᵖ) => has_hom.hom.unop (nat_trans.app (limits.cocone.ι c) (opposite.unop j)))\n\n/--\nGiven a cone over `F.op ⋙ H`, we can construct a `cone H` with the same cone point.\n-/\n@[simp] theorem extend_cone_map_hom {C : Type v} [small_category C] {D : Type v} [small_category D] {F : C ⥤ D} [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} (X : limits.cone (functor.op F ⋙ H)) (Y : limits.cone (functor.op F ⋙ H)) (f : X ⟶ Y) : limits.cone_morphism.hom (functor.map extend_cone f) = limits.cone_morphism.hom f :=\n  Eq.refl (limits.cone_morphism.hom (functor.map extend_cone f))\n\n@[simp] theorem limit_cone_comp_aux {C : Type v} [small_category C] {D : Type v} [small_category D] {F : C ⥤ D} [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} (s : limits.cone (functor.op F ⋙ H)) (j : Cᵒᵖ) : nat_trans.app (limits.cone.π s) (opposite.op (lift F (functor.obj F (opposite.unop j)))) ≫\n    functor.map H (has_hom.hom.op (hom_to_lift F (functor.obj F (opposite.unop j)))) =\n  nat_trans.app (limits.cone.π s) j :=\n  has_hom.hom.op_inj (colimit_cocone_comp_aux (extend_cone_cone_to_cocone s) (opposite.unop j))\n\n/--\nIf `F` is cofinal,\nthe category of cocones on `F ⋙ G` is equivalent to the category of cocones on `G`,\nfor any `G : D ⥤ E`.\n-/\n@[simp] theorem cocones_equiv_unit_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] (G : D ⥤ E) : equivalence.unit_iso (cocones_equiv F G) =\n  nat_iso.of_components\n    (fun (c : limits.cocone (F ⋙ G)) =>\n      limits.cocones.ext (iso.refl (limits.cocone.X (functor.obj 𝟭 c))) (cocones_equiv._proof_1 F G c))\n    (cocones_equiv._proof_2 F G) :=\n  Eq.refl (equivalence.unit_iso (cocones_equiv F G))\n\n/--\nIf `F` is cofinal,\nthe category of cones on `F.op ⋙ H` is equivalent to the category of cones on `H`,\nfor any `H : Dᵒᵖ ⥤ E`.\n-/\n@[simp] theorem cones_equiv_counit_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] (H : Dᵒᵖ ⥤ E) : equivalence.counit_iso (cones_equiv F H) =\n  nat_iso.of_components\n    (fun (c : limits.cone H) =>\n      limits.cones.ext (iso.refl (limits.cone.X (functor.obj (limits.cones.whiskering (functor.op F) ⋙ extend_cone) c)))\n        (cones_equiv._proof_3 F H c))\n    (cones_equiv._proof_4 F H) :=\n  Eq.refl (equivalence.counit_iso (cones_equiv F H))\n\n-- We could have done this purely formally in terms of `cocones_equiv`,\n\n-- without having defined `extend_cone` at all,\n\n-- but it comes at the cost of moving a *lot* of opposites around:\n\n-- (((cones.functoriality_equivalence _ (op_op_equivalence E)).symm.trans\n\n--   ((((cocone_equivalence_op_cone_op _).symm.trans\n\n--     (cocones_equiv F (unop_unop _ ⋙ H.op))).trans\n\n--     (cocone_equivalence_op_cone_op _)).unop)).trans\n\n--   (cones.functoriality_equivalence _ (op_op_equivalence E))).trans\n\n--   (cones.postcompose_equivalence (nat_iso.of_components (λ X, iso.refl _) (by tidy) :\n\n--     H ≅ (unop_unop D ⋙ H.op).op ⋙ (op_op_equivalence E).functor)).symm\n\n/--\nWhen `F : C ⥤ D` is cofinal, and `t : cocone G` for some `G : D ⥤ E`,\n`t.whisker F` is a colimit cocone exactly when `t` is.\n-/\ndef is_colimit_whisker_equiv {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} (t : limits.cocone G) : limits.is_colimit (limits.cocone.whisker F t) ≃ limits.is_colimit t :=\n  limits.is_colimit.of_cocone_equiv (equivalence.symm (cocones_equiv F G))\n\n/--\nWhen `F : C ⥤ D` is cofinal, and `t : cone H` for some `H : Dᵒᵖ ⥤ E`,\n`t.whisker F.op` is a limit cone exactly when `t` is.\n-/\ndef is_limit_whisker_equiv {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} (t : limits.cone H) : limits.is_limit (limits.cone.whisker (functor.op F) t) ≃ limits.is_limit t :=\n  limits.is_limit.of_cone_equiv (equivalence.symm (cones_equiv F H))\n\n/--\nWhen `F` is cofinal, and `t : cocone (F ⋙ G)`,\n`extend_cocone.obj t` is a colimit coconne exactly when `t` is.\n-/\ndef is_colimit_extend_cocone_equiv {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} (t : limits.cocone (F ⋙ G)) : limits.is_colimit (functor.obj extend_cocone t) ≃ limits.is_colimit t :=\n  limits.is_colimit.of_cocone_equiv (cocones_equiv F G)\n\n/--\nWhen `F` is cofinal, and `t : cone (F.op ⋙ H)`,\n`extend_cone.obj t` is a limit conne exactly when `t` is.\n-/\ndef is_limit_extend_cone_equiv {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} (t : limits.cone (functor.op F ⋙ H)) : limits.is_limit (functor.obj extend_cone t) ≃ limits.is_limit t :=\n  limits.is_limit.of_cone_equiv (cones_equiv F H)\n\n/-- Given a colimit cocone over `G : D ⥤ E` we can construct a colimit cocone over `F ⋙ G`. -/\n@[simp] theorem colimit_cocone_comp_cocone {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} (t : limits.colimit_cocone G) : limits.colimit_cocone.cocone (colimit_cocone_comp F t) = limits.cocone.whisker F (limits.colimit_cocone.cocone t) :=\n  Eq.refl (limits.colimit_cocone.cocone (colimit_cocone_comp F t))\n\n/-- Given a limit cone over `H : Dᵒᵖ ⥤ E` we can construct a limit cone over `F.op ⋙ H`. -/\n@[simp] theorem limit_cone_comp_cone {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} (t : limits.limit_cone H) : limits.limit_cone.cone (limit_cone_comp F t) = limits.cone.whisker (functor.op F) (limits.limit_cone.cone t) :=\n  Eq.refl (limits.limit_cone.cone (limit_cone_comp F t))\n\nprotected instance comp_has_colimit {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} [limits.has_colimit G] : limits.has_colimit (F ⋙ G) :=\n  limits.has_colimit.mk (colimit_cocone_comp F (limits.get_colimit_cocone G))\n\nprotected instance comp_has_limit {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} [limits.has_limit H] : limits.has_limit (functor.op F ⋙ H) :=\n  limits.has_limit.mk (limit_cone_comp F (limits.get_limit_cone H))\n\ntheorem colimit_pre_is_iso_aux {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} {t : limits.cocone G} (P : limits.is_colimit t) : limits.is_colimit.desc (coe_fn (equiv.symm (is_colimit_whisker_equiv F t)) P) (limits.cocone.whisker F t) = 𝟙 := sorry\n\nprotected instance colimit_pre_is_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} [limits.has_colimit G] : is_iso (limits.colimit.pre G F) :=\n  eq.mpr sorry (eq.mpr sorry (id is_iso.comp_is_iso))\n\ntheorem limit_pre_is_iso_aux {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} {t : limits.cone H} (P : limits.is_limit t) : limits.is_limit.lift (coe_fn (equiv.symm (is_limit_whisker_equiv F t)) P) (limits.cone.whisker (functor.op F) t) = 𝟙 := sorry\n\nprotected instance limit_pre_is_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} [limits.has_limit H] : is_iso (limits.limit.pre H (functor.op F)) :=\n  eq.mpr sorry (eq.mpr sorry (id is_iso.comp_is_iso))\n\n/--\nWhen `F : C ⥤ D` is cofinal, and `G : D ⥤ E` has a colimit, then `F ⋙ G` has a colimit also and\n`colimit (F ⋙ G) ≅ colimit G`\n\nhttps://stacks.math.columbia.edu/tag/04E7\n-/\ndef colimit_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] (G : D ⥤ E) [limits.has_colimit G] : limits.colimit (F ⋙ G) ≅ limits.colimit G :=\n  as_iso (limits.colimit.pre G F)\n\n/--\nWhen `F : C ⥤ D` is cofinal, and `H : Dᵒᵖ ⥤ E` has a limit, then `F.op ⋙ H` has a limit also and\n`limit (F.op ⋙ H) ≅ limit H`\n\nhttps://stacks.math.columbia.edu/tag/04E7\n-/\ndef limit_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] (H : Dᵒᵖ ⥤ E) [limits.has_limit H] : limits.limit (functor.op F ⋙ H) ≅ limits.limit H :=\n  iso.symm (as_iso (limits.limit.pre H (functor.op F)))\n\n/-- Given a colimit cocone over `F ⋙ G` we can construct a colimit cocone over `G`. -/\n@[simp] theorem colimit_cocone_of_comp_is_colimit {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} (t : limits.colimit_cocone (F ⋙ G)) : limits.colimit_cocone.is_colimit (colimit_cocone_of_comp F t) =\n  coe_fn (equiv.symm (is_colimit_extend_cocone_equiv F (limits.colimit_cocone.cocone t)))\n    (limits.colimit_cocone.is_colimit t) :=\n  Eq.refl (limits.colimit_cocone.is_colimit (colimit_cocone_of_comp F t))\n\n/-- Given a limit cone over `F.op ⋙ H` we can construct a limit cone over `H`. -/\n@[simp] theorem limit_cone_of_comp_is_limit {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} (t : limits.limit_cone (functor.op F ⋙ H)) : limits.limit_cone.is_limit (limit_cone_of_comp F t) =\n  coe_fn (equiv.symm (is_limit_extend_cone_equiv F (limits.limit_cone.cone t))) (limits.limit_cone.is_limit t) :=\n  Eq.refl (limits.limit_cone.is_limit (limit_cone_of_comp F t))\n\n/--\nWhen `F` is cofinal, and `F ⋙ G` has a colimit, then `G` has a colimit also.\n\nWe can't make this an instance, because `F` is not determined by the goal.\n(Even if this weren't a problem, it would cause a loop with `comp_has_colimit`.)\n-/\ntheorem has_colimit_of_comp {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} [limits.has_colimit (F ⋙ G)] : limits.has_colimit G :=\n  limits.has_colimit.mk (colimit_cocone_of_comp F (limits.get_colimit_cocone (F ⋙ G)))\n\n/--\nWhen `F` is cofinal, and `F.op ⋙ H` has a limit, then `H` has a limit also.\n\nWe can't make this an instance, because `F` is not determined by the goal.\n(Even if this weren't a problem, it would cause a loop with `comp_has_limit`.)\n-/\ntheorem has_limit_of_comp {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} [limits.has_limit (functor.op F ⋙ H)] : limits.has_limit H :=\n  limits.has_limit.mk (limit_cone_of_comp F (limits.get_limit_cone (functor.op F ⋙ H)))\n\n/--\nWhen `F` is cofinal, and `F ⋙ G` has a colimit, then `G` has a colimit also and\n`colimit (F ⋙ G) ≅ colimit G`\n\nhttps://stacks.math.columbia.edu/tag/04E7\n-/\ndef colimit_iso' {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {G : D ⥤ E} [limits.has_colimit (F ⋙ G)] : limits.colimit (F ⋙ G) ≅ limits.colimit G :=\n  as_iso (limits.colimit.pre G F)\n\n/--\nWhen `F` is cofinal, and `F.op ⋙ H` has a limit, then `H` has a limit also and\n`limit (F.op ⋙ H) ≅ limit H`\n\nhttps://stacks.math.columbia.edu/tag/04E7\n-/\ndef limit_iso' {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] {E : Type u} [category E] {H : Dᵒᵖ ⥤ E} [limits.has_limit (functor.op F ⋙ H)] : limits.limit (functor.op F ⋙ H) ≅ limits.limit H :=\n  iso.symm (as_iso (limits.limit.pre H (functor.op F)))\n\n/--\nIf the universal morphism `colimit (F ⋙ coyoneda.obj (op d)) ⟶ colimit (coyoneda.obj (op d))`\nis an isomorphism (as it always is when `F` is cofinal),\nthen `colimit (F ⋙ coyoneda.obj (op d)) ≅ punit`\n(simply because `colimit (coyoneda.obj (op d)) ≅ punit`).\n-/\ndef colimit_comp_coyoneda_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] (d : D) [is_iso (limits.colimit.pre (functor.obj coyoneda (opposite.op d)) F)] : limits.colimit (F ⋙ functor.obj coyoneda (opposite.op d)) ≅ PUnit :=\n  as_iso (limits.colimit.pre (functor.obj coyoneda (opposite.op d)) F) ≪≫ coyoneda.colimit_coyoneda_iso (opposite.op d)\n\ntheorem zigzag_of_eqv_gen_quot_rel {C : Type v} [small_category C] {D : Type v} [small_category D] {F : C ⥤ D} {d : D} {f₁ : sigma fun (X : C) => d ⟶ functor.obj F X} {f₂ : sigma fun (X : C) => d ⟶ functor.obj F X} (t : eqv_gen (limits.types.quot.rel (F ⋙ functor.obj coyoneda (opposite.op d))) f₁ f₂) : zigzag (comma.mk (sigma.snd f₁)) (comma.mk (sigma.snd f₂)) := sorry\n\n/--\nIf `colimit (F ⋙ coyoneda.obj (op d)) ≅ punit` for all `d : D`, then `F` is cofinal.\n-/\ntheorem cofinal_of_colimit_comp_coyoneda_iso_punit {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C ⥤ D) [cofinal F] (I : (d : D) → limits.colimit (F ⋙ functor.obj coyoneda (opposite.op d)) ≅ PUnit) : cofinal F := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/cofinal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.7025300698514778, "lm_q1q2_score": 0.4958352136017158}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport algebra.group.defs\nimport data.equiv.basic\nimport logic.nontrivial\n\n/-!\n# Multiplicative opposite and algebraic operations on it\n\nIn this file we define `mul_opposite α = αᵐᵒᵖ` to be the multiplicative opposite of `α`. It inherits\nall additive algebraic structures on `α` (in other files), and reverses the order of multipliers in\nmultiplicative structures, i.e., `op (x * y) = op y * op x`, where `mul_opposite.op` is the\ncanonical map from `α` to `αᵐᵒᵖ`.\n\nWe also define `add_opposite α = αᵃᵒᵖ` to be the additive opposite of `α`. It inherits all\nmultiplicative algebraic structures on `α` (in other files), and reverses the order of summands in\nadditive structures, i.e. `op (x + y) = op y + op x`, where `add_opposite.op` is the canonical map\nfrom `α` to `αᵃᵒᵖ`.\n\n## Notation\n\n* `αᵐᵒᵖ = mul_opposite α`\n* `αᵃᵒᵖ = add_opposite α`\n\n## Tags\n\nmultiplicative opposite, additive opposite\n-/\n\nuniverses u v\nopen function\n\n/-- Multiplicative opposite of a type. This type inherits all additive structures on `α` and\nreverses left and right in multiplication.-/\n@[to_additive \"Additive opposite of a type. This type inherits all multiplicative structures on\n`α` and reverses left and right in addition.\"]\ndef mul_opposite (α : Type u) : Type u := α\n\npostfix `ᵐᵒᵖ`:std.prec.max_plus := mul_opposite\npostfix `ᵃᵒᵖ`:std.prec.max_plus := add_opposite\n\nvariables {α : Type u}\n\nnamespace mul_opposite\n\n/-- The element of `mul_opposite α` that represents `x : α`. -/\n@[pp_nodot, to_additive \"The element of `αᵃᵒᵖ` that represents `x : α`.\"]\ndef op : α → αᵐᵒᵖ := id\n\n/-- The element of `α` represented by `x : αᵐᵒᵖ`. -/\n@[pp_nodot, to_additive \"The element of `α` represented by `x : αᵃᵒᵖ`.\"]\ndef unop : αᵐᵒᵖ → α := id\n\nattribute [pp_nodot] add_opposite.op add_opposite.unop\n\n@[simp, to_additive] lemma unop_op (x : α) : unop (op x) = x := rfl\n@[simp, to_additive] lemma op_unop (x : αᵐᵒᵖ) : op (unop x) = x := rfl\n@[simp, to_additive] lemma op_comp_unop : (op : α → αᵐᵒᵖ) ∘ unop = id := rfl\n@[simp, to_additive] lemma unop_comp_op : (unop : αᵐᵒᵖ → α) ∘ op = id := rfl\n\nattribute [irreducible] mul_opposite\n\n/-- A recursor for `mul_opposite`. Use as `induction x using mul_opposite.rec`. -/\n@[simp, to_additive \"A recursor for `add_opposite`. Use as `induction x using add_opposite.rec`.\"]\nprotected def rec {F : Π (X : αᵐᵒᵖ), Sort v} (h : Π X, F (op X)) : Π X, F X :=\nλ X, h (unop X)\n\n/-- The canonical bijection between `α` and `αᵐᵒᵖ`. -/\n@[to_additive \"The canonical bijection between `α` and `αᵃᵒᵖ`.\",\n  simps apply symm_apply { fully_applied := ff }]\ndef op_equiv : α ≃ αᵐᵒᵖ := ⟨op, unop, unop_op, op_unop⟩\n\n@[to_additive] lemma op_bijective : bijective (op : α → αᵐᵒᵖ) := op_equiv.bijective\n@[to_additive] lemma unop_bijective : bijective (unop : αᵐᵒᵖ → α) := op_equiv.symm.bijective\n@[to_additive] lemma op_injective : injective (op : α → αᵐᵒᵖ) := op_bijective.injective\n@[to_additive] lemma op_surjective : surjective (op : α → αᵐᵒᵖ) := op_bijective.surjective\n@[to_additive] lemma unop_injective : injective (unop : αᵐᵒᵖ → α) := unop_bijective.injective\n@[to_additive] lemma unop_surjective : surjective (unop : αᵐᵒᵖ → α) := unop_bijective.surjective\n\n@[simp, to_additive] lemma op_inj {x y : α} : op x = op y ↔ x = y := op_injective.eq_iff\n@[simp, to_additive] lemma unop_inj {x y : αᵐᵒᵖ} : unop x = unop y ↔ x = y := unop_injective.eq_iff\n\nvariable (α)\n\n@[to_additive] instance [nontrivial α] : nontrivial αᵐᵒᵖ := op_injective.nontrivial\n@[to_additive] instance [inhabited α] : inhabited αᵐᵒᵖ := ⟨op default⟩\n@[to_additive] instance [subsingleton α] : subsingleton αᵐᵒᵖ := unop_injective.subsingleton\n@[to_additive] instance [unique α] : unique αᵐᵒᵖ := unique.mk' _\n@[to_additive] instance [is_empty α] : is_empty αᵐᵒᵖ := function.is_empty unop\n\ninstance [has_zero α] : has_zero αᵐᵒᵖ := { zero := op 0 }\n\n@[to_additive] instance [has_one α] : has_one αᵐᵒᵖ := { one := op 1 }\n\ninstance [has_add α] : has_add αᵐᵒᵖ :=\n{ add := λ x y, op (unop x + unop y) }\n\ninstance [has_sub α] : has_sub αᵐᵒᵖ :=\n{ sub := λ x y, op (unop x - unop y) }\n\ninstance [has_neg α] : has_neg αᵐᵒᵖ :=\n{ neg := λ x, op $ -(unop x) }\n\n@[to_additive] instance [has_mul α] : has_mul αᵐᵒᵖ :=\n{ mul := λ x y, op (unop y * unop x) }\n\n@[to_additive] instance [has_inv α] : has_inv αᵐᵒᵖ :=\n{ inv := λ x, op $ (unop x)⁻¹ }\n\n@[to_additive] instance (R : Type*) [has_scalar R α] : has_scalar R αᵐᵒᵖ :=\n{ smul := λ c x, op (c • unop x) }\n\nsection\nvariables (α)\n\n@[simp] lemma op_zero [has_zero α] : op (0 : α) = 0 := rfl\n@[simp] \n\n@[simp, to_additive] lemma op_one [has_one α] : op (1 : α) = 1 := rfl\n@[simp, to_additive] lemma unop_one [has_one α] : unop (1 : αᵐᵒᵖ) = 1 := rfl\n\nvariable {α}\n\n@[simp] lemma op_add [has_add α] (x y : α) : op (x + y) = op x + op y := rfl\n@[simp] lemma unop_add [has_add α] (x y : αᵐᵒᵖ) : unop (x + y) = unop x + unop y := rfl\n\n@[simp] lemma op_neg [has_neg α] (x : α) : op (-x) = -op x := rfl\n@[simp] lemma unop_neg [has_neg α] (x : αᵐᵒᵖ) : unop (-x) = -unop x := rfl\n\n@[simp, to_additive] lemma op_mul [has_mul α] (x y : α) : op (x * y) = op y * op x := rfl\n@[simp, to_additive] lemma unop_mul [has_mul α] (x y : αᵐᵒᵖ) : unop (x * y) = unop y * unop x := rfl\n\n@[simp, to_additive] lemma op_inv [has_inv α] (x : α) : op (x⁻¹) = (op x)⁻¹ := rfl\n@[simp, to_additive] lemma unop_inv [has_inv α] (x : αᵐᵒᵖ) : unop (x⁻¹) = (unop x)⁻¹ := rfl\n\n@[simp] lemma op_sub [has_sub α] (x y : α) : op (x - y) = op x - op y := rfl\n@[simp] lemma unop_sub [has_sub α] (x y : αᵐᵒᵖ) : unop (x - y) = unop x - unop y := rfl\n\n@[simp, to_additive] lemma op_smul {R : Type*} [has_scalar R α] (c : R) (a : α) :\n  op (c • a) = c • op a := rfl\n\n@[simp, to_additive] lemma unop_smul {R : Type*} [has_scalar R α] (c : R) (a : αᵐᵒᵖ) :\n  unop (c • a) = c • unop a := rfl\n\nend\n\nvariable {α}\n\n@[simp] lemma unop_eq_zero_iff [has_zero α] (a : αᵐᵒᵖ) : a.unop = (0 : α) ↔ a = (0 : αᵐᵒᵖ) :=\nunop_injective.eq_iff' rfl\n\n@[simp] lemma op_eq_zero_iff [has_zero α] (a : α) : op a = (0 : αᵐᵒᵖ) ↔ a = (0 : α) :=\nop_injective.eq_iff' rfl\n\nlemma unop_ne_zero_iff [has_zero α] (a : αᵐᵒᵖ) : a.unop ≠ (0 : α) ↔ a ≠ (0 : αᵐᵒᵖ) :=\nnot_congr $ unop_eq_zero_iff a\n\nlemma op_ne_zero_iff [has_zero α] (a : α) : op a ≠ (0 : αᵐᵒᵖ) ↔ a ≠ (0 : α) :=\nnot_congr $ op_eq_zero_iff a\n\n@[simp, to_additive] lemma unop_eq_one_iff [has_one α] (a : αᵐᵒᵖ) : a.unop = 1 ↔ a = 1 :=\nunop_injective.eq_iff' rfl\n\n@[simp, to_additive] lemma op_eq_one_iff [has_one α] (a : α) : op a = 1 ↔ a = 1 :=\nop_injective.eq_iff' rfl\n\nend mul_opposite\n\nnamespace add_opposite\n\ninstance [has_one α] : has_one αᵃᵒᵖ := { one := op 1 }\n\n@[simp] lemma op_one [has_one α] : op (1 : α) = 1 := rfl\n@[simp] lemma unop_one [has_one α] : unop 1 = (1 : α) := rfl\n\n@[simp] lemma op_eq_one_iff [has_one α] {a : α} : op a = 1 ↔ a = 1 := op_injective.eq_iff' op_one\n\n@[simp] lemma unop_eq_one_iff [has_one α] {a : αᵃᵒᵖ} : unop a = 1 ↔ a = 1 :=\nunop_injective.eq_iff' unop_one\n\ninstance [has_mul α] : has_mul αᵃᵒᵖ := { mul := λ a b, op (unop a * unop b) }\n\n@[simp] lemma op_mul [has_mul α] (a b : α) : op (a * b) = op a * op b := rfl\n@[simp] lemma unop_mul [has_mul α] (a b : αᵃᵒᵖ) : unop (a * b) = unop a * unop b := rfl\n\ninstance [has_inv α] : has_inv αᵃᵒᵖ := { inv := λ a, op (unop a)⁻¹ }\n\n@[simp] lemma op_inv [has_inv α] (a : α) : op a⁻¹ = (op a)⁻¹ := rfl\n@[simp] lemma unop_inv [has_inv α] (a : αᵃᵒᵖ) : unop a⁻¹ = (unop a)⁻¹ := rfl\n\ninstance [has_div α] : has_div αᵃᵒᵖ := { div := λ a b, op (unop a / unop b) }\n\n@[simp] lemma op_div [has_div α] (a b : α) : op (a / b) = op a / op b := rfl\n@[simp] lemma unop_div [has_div α] (a b : α) : unop (a / b) = unop a / unop b := rfl\n\nend add_opposite\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebra/opposites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4958352092540892}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nLift filters along filter and set functions.\n-/\nimport order.filter.basic\n\nopen lattice set\n\nlocal attribute [instance] classical.prop_decidable\n\nnamespace filter\nvariables {α : Type*} {β : Type*} {γ : Type*} {ι : Sort*}\n\nsection lift\n\n/-- A variant on `bind` using a function `g` taking a set instead of a member of `α`.\nThis is essentially a push-forward along a function mapping each set to a filter. -/\nprotected def lift (f : filter α) (g : set α → filter β) :=\n⨅s ∈ f.sets, g s\n\nvariables {f f₁ f₂ : filter α} {g g₁ g₂ : set α → filter β}\n\nlemma lift_sets_eq (hg : monotone g) : (f.lift g).sets = (⋃t∈f.sets, (g t).sets) :=\ninfi_sets_eq'\n  (assume s hs t ht, ⟨s ∩ t, inter_mem_sets hs ht,\n    hg $ inter_subset_left s t, hg $ inter_subset_right s t⟩)\n  ⟨univ, univ_mem_sets⟩\n\nlemma mem_lift {s : set β} {t : set α} (ht : t ∈ f.sets) (hs : s ∈ (g t).sets) :\n  s ∈ (f.lift g).sets :=\nle_principal_iff.mp $ show f.lift g ≤ principal s,\n  from infi_le_of_le t $ infi_le_of_le ht $ le_principal_iff.mpr hs\n\nlemma mem_lift_sets (hg : monotone g) {s : set β} :\n  s ∈ (f.lift g).sets ↔ (∃t∈f.sets, s ∈ (g t).sets) :=\nby rw [lift_sets_eq hg]; simp only [mem_Union]\n\nlemma lift_le {f : filter α} {g : set α → filter β} {h : filter β} {s : set α}\n  (hs : s ∈ f.sets) (hg : g s ≤ h) : f.lift g ≤ h :=\ninfi_le_of_le s $ infi_le_of_le hs $ hg\n\nlemma le_lift {f : filter α} {g : set α → filter β} {h : filter β}\n  (hh : ∀s∈f.sets, h ≤ g s) : h ≤ f.lift g :=\nle_infi $ assume s, le_infi $ assume hs, hh s hs\n\nlemma lift_mono (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : f₁.lift g₁ ≤ f₂.lift g₂ :=\ninfi_le_infi $ assume s, infi_le_infi2 $ assume hs, ⟨hf hs, hg s⟩\n\nlemma lift_mono' (hg : ∀s∈f.sets, g₁ s ≤ g₂ s) : f.lift g₁ ≤ f.lift g₂ :=\ninfi_le_infi $ assume s, infi_le_infi $ assume hs, hg s hs\n\nlemma map_lift_eq {m : β → γ} (hg : monotone g) : map m (f.lift g) = f.lift (map m ∘ g) :=\nhave monotone (map m ∘ g),\n  from monotone_comp hg monotone_map,\nfilter_eq $ set.ext $\n  by simp only [mem_lift_sets, hg, @mem_lift_sets _ _ f _ this, exists_prop, forall_const, mem_map, iff_self, function.comp_app]\n\nlemma comap_lift_eq {m : γ → β} (hg : monotone g) : comap m (f.lift g) = f.lift (comap m ∘ g) :=\nhave monotone (comap m ∘ g),\n  from monotone_comp hg monotone_comap,\nfilter_eq $ set.ext begin\n  simp only [hg, @mem_lift_sets _ _ f _ this, comap, mem_lift_sets, mem_set_of_eq, exists_prop,\n    function.comp_apply],\n  exact λ s,\n   ⟨λ ⟨b, ⟨a, ha, hb⟩, hs⟩, ⟨a, ha, b, hb, hs⟩,\n    λ ⟨a, ha, b, hb, hs⟩, ⟨b, ⟨a, ha, hb⟩, hs⟩⟩\nend\n\ntheorem comap_lift_eq2 {m : β → α} {g : set β → filter γ} (hg : monotone g) :\n  (comap m f).lift g = f.lift (g ∘ preimage m) :=\nle_antisymm\n  (le_infi $ assume s, le_infi $ assume hs,\n    infi_le_of_le (preimage m s) $ infi_le _ ⟨s, hs, subset.refl _⟩)\n  (le_infi $ assume s, le_infi $ assume ⟨s', hs', (h_sub : preimage m s' ⊆ s)⟩,\n    infi_le_of_le s' $ infi_le_of_le hs' $ hg h_sub)\n\nlemma map_lift_eq2 {g : set β → filter γ} {m : α → β} (hg : monotone g) :\n  (map m f).lift g = f.lift (g ∘ image m) :=\nle_antisymm\n  (infi_le_infi2 $ assume s, ⟨image m s,\n    infi_le_infi2 $ assume hs, ⟨\n      f.sets_of_superset hs $ assume a h, mem_image_of_mem _ h,\n      le_refl _⟩⟩)\n  (infi_le_infi2 $ assume t, ⟨preimage m t,\n    infi_le_infi2 $ assume ht, ⟨ht,\n      hg $ assume x, assume h : x ∈ m '' preimage m t,\n        let ⟨y, hy, h_eq⟩ := h in\n        show x ∈ t, from h_eq ▸ hy⟩⟩)\n\nlemma lift_comm {g : filter β} {h : set α → set β → filter γ} :\n  f.lift (λs, g.lift (h s)) = g.lift (λt, f.lift (λs, h s t)) :=\nle_antisymm\n  (le_infi $ assume i, le_infi $ assume hi, le_infi $ assume j, le_infi $ assume hj,\n    infi_le_of_le j $ infi_le_of_le hj $ infi_le_of_le i $ infi_le _ hi)\n  (le_infi $ assume i, le_infi $ assume hi, le_infi $ assume j, le_infi $ assume hj,\n    infi_le_of_le j $ infi_le_of_le hj $ infi_le_of_le i $ infi_le _ hi)\n\nlemma lift_assoc {h : set β → filter γ} (hg : monotone g)  :\n  (f.lift g).lift h = f.lift (λs, (g s).lift h) :=\nle_antisymm\n  (le_infi $ assume s, le_infi $ assume hs, le_infi $ assume t, le_infi $ assume ht,\n    infi_le_of_le t $ infi_le _ $ (mem_lift_sets hg).mpr ⟨_, hs, ht⟩)\n  (le_infi $ assume t, le_infi $ assume ht,\n    let ⟨s, hs, h'⟩ := (mem_lift_sets hg).mp ht in\n    infi_le_of_le s $ infi_le_of_le hs $ infi_le_of_le t $ infi_le _ h')\n\nlemma lift_lift_same_le_lift {g : set α → set α → filter β} :\n  f.lift (λs, f.lift (g s)) ≤ f.lift (λs, g s s) :=\nle_infi $ assume s, le_infi $ assume hs, infi_le_of_le s $ infi_le_of_le hs $ infi_le_of_le s $ infi_le _ hs\n\nlemma lift_lift_same_eq_lift {g : set α → set α → filter β}\n  (hg₁ : ∀s, monotone (λt, g s t)) (hg₂ : ∀t, monotone (λs, g s t)):\n  f.lift (λs, f.lift (g s)) = f.lift (λs, g s s) :=\nle_antisymm\n  lift_lift_same_le_lift\n  (le_infi $ assume s, le_infi $ assume hs, le_infi $ assume t, le_infi $ assume ht,\n    infi_le_of_le (s ∩ t) $\n    infi_le_of_le (inter_mem_sets hs ht) $\n    calc g (s ∩ t) (s ∩ t) ≤ g s (s ∩ t) : hg₂ (s ∩ t) (inter_subset_left _ _)\n      ... ≤ g s t                        : hg₁ s (inter_subset_right _ _))\n\nlemma lift_principal {s : set α} (hg : monotone g) :\n  (principal s).lift g = g s :=\nle_antisymm\n  (infi_le_of_le s $ infi_le _ $ subset.refl _)\n  (le_infi $ assume t, le_infi $ assume hi, hg hi)\n\ntheorem monotone_lift [preorder γ] {f : γ → filter α} {g : γ → set α → filter β}\n  (hf : monotone f) (hg : monotone g) : monotone (λc, (f c).lift (g c)) :=\nassume a b h, lift_mono (hf h) (hg h)\n\nlemma lift_neq_bot_iff (hm : monotone g) : (f.lift g ≠ ⊥) ↔ (∀s∈f.sets, g s ≠ ⊥) :=\nclassical.by_cases\n  (assume hn : nonempty β,\n    calc f.lift g ≠ ⊥ ↔ (⨅s : { s // s ∈ f.sets}, g s.val) ≠ ⊥ :\n      by simp only [filter.lift, infi_subtype, iff_self, ne.def]\n      ... ↔ (∀s:{ s // s ∈ f.sets}, g s.val ≠ ⊥) :\n        infi_neq_bot_iff_of_directed hn\n          (assume ⟨a, ha⟩ ⟨b, hb⟩, ⟨⟨a ∩ b, inter_mem_sets ha hb⟩,\n            hm $ inter_subset_left _ _, hm $ inter_subset_right _ _⟩)\n      ... ↔ (∀s∈f.sets, g s ≠ ⊥) : ⟨assume h s hs, h ⟨s, hs⟩, assume h ⟨s, hs⟩, h s hs⟩)\n  (assume hn : ¬ nonempty β,\n    have h₁ : f.lift g = ⊥, from filter_eq_bot_of_not_nonempty hn,\n    have h₂ : ∀s, g s = ⊥, from assume s, filter_eq_bot_of_not_nonempty hn,\n    calc (f.lift g ≠ ⊥) ↔ false : by simp only [h₁, iff_self, eq_self_iff_true, not_true, ne.def]\n      ... ↔ (∀s∈f.sets, false) : ⟨false.elim, assume h, h univ univ_mem_sets⟩\n      ... ↔ (∀s∈f.sets, g s ≠ ⊥) : by simp only [h₂, iff_self, eq_self_iff_true, not_true, ne.def])\n\n@[simp] lemma lift_const {f : filter α} {g : filter β} : f.lift (λx, g) = g :=\nle_antisymm (lift_le univ_mem_sets $ le_refl g) (le_lift $ assume s hs, le_refl g)\n\n@[simp] lemma lift_inf {f : filter α} {g h : set α → filter β} :\n  f.lift (λx, g x ⊓ h x) = f.lift g ⊓ f.lift h :=\nby simp only [filter.lift, infi_inf_eq, eq_self_iff_true]\n\n@[simp] lemma lift_principal2 {f : filter α} : f.lift principal = f :=\nle_antisymm\n  (assume s hs, mem_lift hs (mem_principal_self s))\n  (le_infi $ assume s, le_infi $ assume hs, by simp only [hs, le_principal_iff])\n\nlemma lift_infi {f : ι → filter α} {g : set α → filter β}\n  (hι : nonempty ι) (hg : ∀{s t}, g s ⊓ g t = g (s ∩ t)) : (infi f).lift g = (⨅i, (f i).lift g) :=\nle_antisymm\n  (le_infi $ assume i, lift_mono (infi_le _ _) (le_refl _))\n  (assume s,\n    have g_mono : monotone g,\n      from assume s t h, le_of_inf_eq $ eq.trans hg $ congr_arg g $ inter_eq_self_of_subset_left h,\n    have ∀t∈(infi f).sets, (⨅ (i : ι), filter.lift (f i) g) ≤ g t,\n      from assume t ht, infi_sets_induct ht\n        (let ⟨i⟩ := hι in infi_le_of_le i $ infi_le_of_le univ $ infi_le _ univ_mem_sets)\n        (assume i s₁ s₂ hs₁ hs₂,\n          @hg s₁ s₂ ▸ le_inf (infi_le_of_le i $ infi_le_of_le s₁ $ infi_le _ hs₁) hs₂)\n        (assume s₁ s₂ hs₁ hs₂, le_trans hs₂ $ g_mono hs₁),\n    begin\n      rw [lift_sets_eq g_mono],\n      simp only [mem_Union, exists_imp_distrib],\n      exact assume t ht hs, this t ht hs\n    end)\n\nend lift\n\nsection lift'\n/-- Specialize `lift` to functions `set α → set β`. This can be viewed as a generalization of `map`.\nThis is essentially a push-forward along a function mapping each set to a set. -/\nprotected def lift' (f : filter α) (h : set α → set β) :=\nf.lift (principal ∘ h)\n\nvariables {f f₁ f₂ : filter α} {h h₁ h₂ : set α → set β}\n\nlemma mem_lift' {t : set α} (ht : t ∈ f.sets) : h t ∈ (f.lift' h).sets :=\nle_principal_iff.mp $ show f.lift' h ≤ principal (h t),\n  from infi_le_of_le t $ infi_le_of_le ht $ le_refl _\n\nlemma mem_lift'_sets (hh : monotone h) {s : set β} : s ∈ (f.lift' h).sets ↔ (∃t∈f.sets, h t ⊆ s) :=\nhave monotone (principal ∘ h),\n  from assume a b h, principal_mono.mpr $ hh h,\nby simp only [filter.lift', @mem_lift_sets α β f _ this, exists_prop, iff_self, mem_principal_sets, function.comp_app]\n\nlemma lift'_le {f : filter α} {g : set α → set β} {h : filter β} {s : set α}\n  (hs : s ∈ f.sets) (hg : principal (g s) ≤ h) : f.lift' g ≤ h :=\nlift_le hs hg\n\nlemma lift'_mono (hf : f₁ ≤ f₂) (hh : h₁ ≤ h₂) : f₁.lift' h₁ ≤ f₂.lift' h₂ :=\nlift_mono hf $ assume s, principal_mono.mpr $ hh s\n\nlemma lift'_mono' (hh : ∀s∈f.sets, h₁ s ⊆ h₂ s) : f.lift' h₁ ≤ f.lift' h₂ :=\ninfi_le_infi $ assume s, infi_le_infi $ assume hs, principal_mono.mpr $ hh s hs\n\nlemma lift'_cong (hh : ∀s∈f.sets, h₁ s = h₂ s) : f.lift' h₁ = f.lift' h₂ :=\nle_antisymm (lift'_mono' $ assume s hs, le_of_eq $ hh s hs) (lift'_mono' $ assume s hs, le_of_eq $ (hh s hs).symm)\n\nlemma map_lift'_eq {m : β → γ} (hh : monotone h) : map m (f.lift' h) = f.lift' (image m ∘ h) :=\ncalc map m (f.lift' h) = f.lift (map m ∘ principal ∘ h) :\n    map_lift_eq $ monotone_comp hh monotone_principal\n  ... = f.lift' (image m ∘ h) : by simp only [(∘), filter.lift', map_principal, eq_self_iff_true]\n\nlemma map_lift'_eq2 {g : set β → set γ} {m : α → β} (hg : monotone g) :\n  (map m f).lift' g = f.lift' (g ∘ image m) :=\nmap_lift_eq2 $ monotone_comp hg monotone_principal\n\ntheorem comap_lift'_eq {m : γ → β} (hh : monotone h) :\n  comap m (f.lift' h) = f.lift' (preimage m ∘ h) :=\ncalc comap m (f.lift' h) = f.lift (comap m ∘ principal ∘ h) :\n    comap_lift_eq $ monotone_comp hh monotone_principal\n  ... = f.lift' (preimage m ∘ h) : by simp only [(∘), filter.lift', comap_principal, eq_self_iff_true]\n\ntheorem comap_lift'_eq2 {m : β → α} {g : set β → set γ} (hg : monotone g) :\n  (comap m f).lift' g = f.lift' (g ∘ preimage m) :=\ncomap_lift_eq2 $ monotone_comp hg monotone_principal\n\nlemma lift'_principal {s : set α} (hh : monotone h) :\n  (principal s).lift' h = principal (h s) :=\nlift_principal $ monotone_comp hh monotone_principal\n\nlemma principal_le_lift' {t : set β} (hh : ∀s∈f.sets, t ⊆ h s) :\n  principal t ≤ f.lift' h :=\nle_infi $ assume s, le_infi $ assume hs, principal_mono.mpr (hh s hs)\n\ntheorem monotone_lift' [preorder γ] {f : γ → filter α} {g : γ → set α → set β}\n  (hf : monotone f) (hg : monotone g) : monotone (λc, (f c).lift' (g c)) :=\nassume a b h, lift'_mono (hf h) (hg h)\n\nlemma lift_lift'_assoc {g : set α → set β} {h : set β → filter γ}\n  (hg : monotone g) (hh : monotone h) :\n  (f.lift' g).lift h = f.lift (λs, h (g s)) :=\ncalc (f.lift' g).lift h = f.lift (λs, (principal (g s)).lift h) :\n    lift_assoc (monotone_comp hg monotone_principal)\n  ... = f.lift (λs, h (g s)) : by simp only [lift_principal, hh, eq_self_iff_true]\n\nlemma lift'_lift'_assoc {g : set α → set β} {h : set β → set γ}\n  (hg : monotone g) (hh : monotone h) :\n  (f.lift' g).lift' h = f.lift' (λs, h (g s)) :=\nlift_lift'_assoc hg (monotone_comp hh monotone_principal)\n\nlemma lift'_lift_assoc {g : set α → filter β} {h : set β → set γ}\n  (hg : monotone g) : (f.lift g).lift' h = f.lift (λs, (g s).lift' h) :=\nlift_assoc hg\n\nlemma lift_lift'_same_le_lift' {g : set α → set α → set β} :\n  f.lift (λs, f.lift' (g s)) ≤ f.lift' (λs, g s s) :=\nlift_lift_same_le_lift\n\nlemma lift_lift'_same_eq_lift' {g : set α → set α → set β}\n  (hg₁ : ∀s, monotone (λt, g s t)) (hg₂ : ∀t, monotone (λs, g s t)):\n  f.lift (λs, f.lift' (g s)) = f.lift' (λs, g s s) :=\nlift_lift_same_eq_lift\n  (assume s, monotone_comp monotone_id $ monotone_comp (hg₁ s) monotone_principal)\n  (assume t, monotone_comp (hg₂ t) monotone_principal)\n\nlemma lift'_inf_principal_eq {h : set α → set β} {s : set β} :\n  f.lift' h ⊓ principal s = f.lift' (λt, h t ∩ s) :=\nle_antisymm\n  (le_infi $ assume t, le_infi $ assume ht,\n    calc filter.lift' f h ⊓ principal s ≤ principal (h t) ⊓ principal s :\n        inf_le_inf (infi_le_of_le t $ infi_le _ ht) (le_refl _)\n      ... = _ : by simp only [principal_eq_iff_eq, inf_principal, eq_self_iff_true, function.comp_app])\n  (le_inf\n    (le_infi $ assume t, le_infi $ assume ht,\n      infi_le_of_le t $ infi_le_of_le ht $\n      by simp only [le_principal_iff, inter_subset_left, mem_principal_sets, function.comp_app]; exact inter_subset_right _ _)\n    (infi_le_of_le univ $ infi_le_of_le univ_mem_sets $\n    by simp only [le_principal_iff, inter_subset_right, mem_principal_sets, function.comp_app]; exact inter_subset_left _ _))\n\nlemma lift'_neq_bot_iff (hh : monotone h) : (f.lift' h ≠ ⊥) ↔ (∀s∈f.sets, h s ≠ ∅) :=\ncalc (f.lift' h ≠ ⊥) ↔ (∀s∈f.sets, principal (h s) ≠ ⊥) :\n    lift_neq_bot_iff (monotone_comp hh monotone_principal)\n  ... ↔ (∀s∈f.sets, h s ≠ ∅) : by simp only [principal_eq_bot_iff, iff_self, ne.def, principal_eq_bot_iff]\n\n@[simp] lemma lift'_id {f : filter α} : f.lift' id = f :=\nlift_principal2\n\nlemma le_lift' {f : filter α} {h : set α → set β} {g : filter β}\n  (h_le : ∀s∈f.sets, h s ∈ g.sets) : g ≤ f.lift' h :=\nle_infi $ assume s, le_infi $ assume hs, by simp only [h_le, le_principal_iff, function.comp_app]; exact h_le s hs\n\nlemma lift_infi' {f : ι → filter α} {g : set α → filter β}\n  (hι : nonempty ι) (hf : directed (≥) f) (hg : monotone g) : (infi f).lift g = (⨅i, (f i).lift g) :=\nle_antisymm\n  (le_infi $ assume i, lift_mono (infi_le _ _) (le_refl _))\n  (assume s,\n  begin\n    rw [lift_sets_eq hg],\n    simp only [mem_Union, exists_imp_distrib, infi_sets_eq hf hι],\n    exact assume t i ht hs, mem_infi_sets i $ mem_lift ht hs\n  end)\n\nlemma lift'_infi {f : ι → filter α} {g : set α → set β}\n  (hι : nonempty ι) (hg : ∀{s t}, g s ∩ g t = g (s ∩ t)) : (infi f).lift' g = (⨅i, (f i).lift' g) :=\nlift_infi hι $ by simp only [principal_eq_iff_eq, inf_principal, function.comp_app]; apply assume s t, hg\n\ntheorem comap_eq_lift' {f : filter β} {m : α → β} :\n  comap m f = f.lift' (preimage m) :=\nfilter_eq $ set.ext $ by simp only [mem_lift'_sets, monotone_preimage, comap, exists_prop, forall_const, iff_self, mem_set_of_eq]\n\nend lift'\n\nsection prod\nvariables {f : filter α}\n\nlemma prod_def {f : filter α} {g : filter β} : f.prod g = (f.lift $ λs, g.lift' $ set.prod s) :=\nhave ∀(s:set α) (t : set β),\n    principal (set.prod s t) = (principal s).comap prod.fst ⊓ (principal t).comap prod.snd,\n  by simp only [principal_eq_iff_eq, comap_principal, inf_principal]; intros; refl,\nbegin\n  simp only [filter.lift', function.comp, this, -comap_principal, lift_inf, lift_const, lift_inf],\n  rw [← comap_lift_eq monotone_principal, ← comap_lift_eq monotone_principal],\n  simp only [filter.prod, lift_principal2, eq_self_iff_true]\nend\n\nlemma prod_same_eq : filter.prod f f = f.lift' (λt, set.prod t t) :=\nby rw [prod_def];\nfrom lift_lift'_same_eq_lift'\n  (assume s, set.monotone_prod monotone_const monotone_id)\n  (assume t, set.monotone_prod monotone_id monotone_const)\n\nlemma mem_prod_same_iff {s : set (α×α)} :\n  s ∈ (filter.prod f f).sets ↔ (∃t∈f.sets, set.prod t t ⊆ s) :=\nby rw [prod_same_eq, mem_lift'_sets]; exact set.monotone_prod monotone_id monotone_id\n\nlemma tendsto_prod_self_iff {f : α × α → β} {x : filter α} {y : filter β} :\n  filter.tendsto f (filter.prod x x) y ↔\n  ∀ W ∈ y.sets, ∃ U ∈ x.sets, ∀ (x x' : α), x ∈ U → x' ∈ U → f (x, x') ∈ W :=\nby simp only [tendsto_def, mem_prod_same_iff, prod_sub_preimage_iff, exists_prop, iff_self]\n\nvariables {α₁ : Type*} {α₂ : Type*} {β₁ : Type*} {β₂ : Type*}\n\nlemma prod_lift_lift\n  {f₁ : filter α₁} {f₂ : filter α₂} {g₁ : set α₁ → filter β₁} {g₂ : set α₂ → filter β₂}\n  (hg₁ : monotone g₁) (hg₂ : monotone g₂) :\n  filter.prod (f₁.lift g₁) (f₂.lift g₂) = f₁.lift (λs, f₂.lift (λt, filter.prod (g₁ s) (g₂ t))) :=\nbegin\n  simp only [prod_def],\n  rw [lift_assoc],\n  apply congr_arg, funext x,\n  rw [lift_comm],\n  apply congr_arg, funext y,\n  rw [lift'_lift_assoc],\n  exact hg₂,\n  exact hg₁\nend\n\nlemma prod_lift'_lift'\n  {f₁ : filter α₁} {f₂ : filter α₂} {g₁ : set α₁ → set β₁} {g₂ : set α₂ → set β₂}\n  (hg₁ : monotone g₁) (hg₂ : monotone g₂) :\n  filter.prod (f₁.lift' g₁) (f₂.lift' g₂) = f₁.lift (λs, f₂.lift' (λt, set.prod (g₁ s) (g₂ t))) :=\nbegin\n  rw [prod_def, lift_lift'_assoc],\n  apply congr_arg, funext x,\n  rw [lift'_lift'_assoc],\n  exact hg₂,\n  exact set.monotone_prod monotone_const monotone_id,\n  exact hg₁,\n  exact (monotone_lift' monotone_const $ monotone_lam $\n    assume x, set.monotone_prod monotone_id monotone_const)\nend\n\nend prod\n\nend filter\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/order/filter/lift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.49583520055883606}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.module.basic\nimport Mathlib.algebra.ring.pi\nimport Mathlib.PostPort\n\nuniverses u v u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Pi instances for module and multiplicative actions\n\nThis file defines instances for module, mul_action and related structures on Pi Types\n-/\n\nnamespace pi\n\n\nprotected instance has_scalar {I : Type u} {f : I → Type v} {α : Type u_1} [(i : I) → has_scalar α (f i)] : has_scalar α ((i : I) → f i) :=\n  has_scalar.mk fun (s : α) (x : (i : I) → f i) (i : I) => s • x i\n\n@[simp] theorem smul_apply {I : Type u} {f : I → Type v} (x : (i : I) → f i) (i : I) {α : Type u_1} [(i : I) → has_scalar α (f i)] (s : α) : has_scalar.smul s x i = s • x i :=\n  rfl\n\nprotected instance has_scalar' {I : Type u} {f : I → Type v} {g : I → Type u_1} [(i : I) → has_scalar (f i) (g i)] : has_scalar ((i : I) → f i) ((i : I) → g i) :=\n  has_scalar.mk fun (s : (i : I) → f i) (x : (i : I) → g i) (i : I) => s i • x i\n\n@[simp] theorem smul_apply' {I : Type u} {f : I → Type v} (i : I) {g : I → Type u_1} [(i : I) → has_scalar (f i) (g i)] (s : (i : I) → f i) (x : (i : I) → g i) : has_scalar.smul s x i = s i • x i :=\n  rfl\n\nprotected instance is_scalar_tower {I : Type u} {f : I → Type v} {α : Type u_1} {β : Type u_2} [has_scalar α β] [(i : I) → has_scalar β (f i)] [(i : I) → has_scalar α (f i)] [∀ (i : I), is_scalar_tower α β (f i)] : is_scalar_tower α β ((i : I) → f i) :=\n  is_scalar_tower.mk fun (x : α) (y : β) (z : (i : I) → f i) => funext fun (i : I) => smul_assoc x y (z i)\n\nprotected instance is_scalar_tower' {I : Type u} {f : I → Type v} {g : I → Type u_1} {α : Type u_2} [(i : I) → has_scalar α (f i)] [(i : I) → has_scalar (f i) (g i)] [(i : I) → has_scalar α (g i)] [∀ (i : I), is_scalar_tower α (f i) (g i)] : is_scalar_tower α ((i : I) → f i) ((i : I) → g i) :=\n  is_scalar_tower.mk fun (x : α) (y : (i : I) → f i) (z : (i : I) → g i) => funext fun (i : I) => smul_assoc x (y i) (z i)\n\nprotected instance is_scalar_tower'' {I : Type u} {f : I → Type v} {g : I → Type u_1} {h : I → Type u_2} [(i : I) → has_scalar (f i) (g i)] [(i : I) → has_scalar (g i) (h i)] [(i : I) → has_scalar (f i) (h i)] [∀ (i : I), is_scalar_tower (f i) (g i) (h i)] : is_scalar_tower ((i : I) → f i) ((i : I) → g i) ((i : I) → h i) :=\n  is_scalar_tower.mk\n    fun (x : (i : I) → f i) (y : (i : I) → g i) (z : (i : I) → h i) => funext fun (i : I) => smul_assoc (x i) (y i) (z i)\n\nprotected instance mul_action {I : Type u} {f : I → Type v} (α : Type u_1) {m : monoid α} [(i : I) → mul_action α (f i)] : mul_action α ((i : I) → f i) :=\n  mul_action.mk sorry sorry\n\nprotected instance mul_action' {I : Type u} {f : I → Type v} {g : I → Type u_1} {m : (i : I) → monoid (f i)} [(i : I) → mul_action (f i) (g i)] : mul_action ((i : I) → f i) ((i : I) → g i) :=\n  mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action {I : Type u} {f : I → Type v} (α : Type u_1) {m : monoid α} {n : (i : I) → add_monoid (f i)} [(i : I) → distrib_mul_action α (f i)] : distrib_mul_action α ((i : I) → f i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action' {I : Type u} {f : I → Type v} {g : I → Type u_1} {m : (i : I) → monoid (f i)} {n : (i : I) → add_monoid (g i)} [(i : I) → distrib_mul_action (f i) (g i)] : distrib_mul_action ((i : I) → f i) ((i : I) → g i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance semimodule (I : Type u) (f : I → Type v) (α : Type u_1) {r : semiring α} {m : (i : I) → add_comm_monoid (f i)} [(i : I) → semimodule α (f i)] : semimodule α ((i : I) → f i) :=\n  semimodule.mk sorry sorry\n\nprotected instance semimodule' {I : Type u} {f : I → Type v} {g : I → Type u_1} {r : (i : I) → semiring (f i)} {m : (i : I) → add_comm_monoid (g i)} [(i : I) → semimodule (f i) (g i)] : semimodule ((i : I) → f i) ((i : I) → g i) :=\n  semimodule.mk sorry sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/module/pi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.49583520051073743}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.mv_polynomial.rename\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_4 u_3 \n\nnamespace Mathlib\n\n/-!\n# `comap` operation on `mv_polynomial`\n\nThis file defines the `comap` function on `mv_polynomial`.\n\n`mv_polynomial.comap` is a low-tech example of a map of \"algebraic varieties,\" modulo the fact that\n`mathlib` does not yet define varieties.\n\n## Notation\n\nAs in other polynomial files, we typically use the notation:\n\n+ `σ : Type*` (indexing the variables)\n\n+ `R : Type*` `[comm_semiring R]` (the coefficients)\n\n-/\n\nnamespace mv_polynomial\n\n\n/--\nGiven an algebra hom `f : mv_polynomial σ R →ₐ[R] mv_polynomial τ R`\nand a variable evaluation `v : τ → R`,\n`comap f v` produces a variable evaluation `σ → R`.\n-/\ndef comap {σ : Type u_1} {τ : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial σ R) (mv_polynomial τ R)) : (τ → R) → σ → R :=\n  fun (x : τ → R) (i : σ) => coe_fn (aeval x) (coe_fn f (X i))\n\n@[simp] theorem comap_apply {σ : Type u_1} {τ : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial σ R) (mv_polynomial τ R)) (x : τ → R) (i : σ) :\n    comap f x i = coe_fn (aeval x) (coe_fn f (X i)) :=\n  rfl\n\n@[simp] theorem comap_id_apply {σ : Type u_1} {R : Type u_4} [comm_semiring R] (x : σ → R) :\n    comap (alg_hom.id R (mv_polynomial σ R)) x = x :=\n  sorry\n\ntheorem comap_id (σ : Type u_1) (R : Type u_4) [comm_semiring R] :\n    comap (alg_hom.id R (mv_polynomial σ R)) = id :=\n  funext fun (x : σ → R) => comap_id_apply x\n\ntheorem comap_comp_apply {σ : Type u_1} {τ : Type u_2} {υ : Type u_3} {R : Type u_4}\n    [comm_semiring R] (f : alg_hom R (mv_polynomial σ R) (mv_polynomial τ R))\n    (g : alg_hom R (mv_polynomial τ R) (mv_polynomial υ R)) (x : υ → R) :\n    comap (alg_hom.comp g f) x = comap f (comap g x) :=\n  sorry\n\ntheorem comap_comp {σ : Type u_1} {τ : Type u_2} {υ : Type u_3} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial σ R) (mv_polynomial τ R))\n    (g : alg_hom R (mv_polynomial τ R) (mv_polynomial υ R)) :\n    comap (alg_hom.comp g f) = comap f ∘ comap g :=\n  funext fun (x : υ → R) => comap_comp_apply f g x\n\ntheorem comap_eq_id_of_eq_id {σ : Type u_1} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial σ R) (mv_polynomial σ R))\n    (hf : ∀ (φ : mv_polynomial σ R), coe_fn f φ = φ) (x : σ → R) : comap f x = x :=\n  sorry\n\ntheorem comap_rename {σ : Type u_1} {τ : Type u_2} {R : Type u_4} [comm_semiring R] (f : σ → τ)\n    (x : τ → R) : comap (rename f) x = x ∘ f :=\n  sorry\n\n/--\nIf two polynomial types over the same coefficient ring `R` are equivalent,\nthere is a bijection between the types of functions from their variable types to `R`.\n-/\ndef comap_equiv {σ : Type u_1} {τ : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_equiv R (mv_polynomial σ R) (mv_polynomial τ R)) : (τ → R) ≃ (σ → R) :=\n  equiv.mk (comap ↑f) (comap ↑(alg_equiv.symm f)) sorry sorry\n\n@[simp] theorem comap_equiv_coe {σ : Type u_1} {τ : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_equiv R (mv_polynomial σ R) (mv_polynomial τ R)) : ⇑(comap_equiv f) = comap ↑f :=\n  rfl\n\n@[simp] theorem comap_equiv_symm_coe {σ : Type u_1} {τ : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_equiv R (mv_polynomial σ R) (mv_polynomial τ R)) :\n    ⇑(equiv.symm (comap_equiv f)) = comap ↑(alg_equiv.symm f) :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/mv_polynomial/comap_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.49583519611501214}}
{"text": "import data.real.basic\nimport data.real.basic tactic.norm_num\nimport data.nat.basic algebra.group_power\n--\\medskip\\noindent{\\bf Q0804.} For each of the following binary relations on a set~$S$,\n-- figure out whether or not the relation is reflexive. Then figure out whether or not\n--  it is symmetric. Finally figure out whether or not the relation is transitive.\n\n-- intro, exact, assume, cases, split, left, right, norm_num, by refl, by le_refl, rw, unfold, by contradiction, have, let\ndefinition S5 := {x : ℕ | x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4}\ndefinition S6 := {x : ℕ | false}\n\ndefinition r1 (a b : ℝ) : Prop := a ≤ b\ndefinition r2 (a b : ℤ) : Prop := ∃ k, a - b = k ^ 2\ndefinition r3 (a b : ℝ) : Prop := a = b ^ 2\ndefinition r4 (a b : ℤ) : Prop := a + b = 0\n\ndefinition r5 (a b : S5) : Prop := (a : ℕ) = 1 ∧ (b : ℕ) = 3\ndefinition r6 (a b : S6) : Prop := true\n\n\n\ninstance nat.decidable_bex_lt (n : nat) (P : Π k < n, Prop) :\n  ∀ [H : ∀ n h, decidable (P n h)], decidable (∃ k h, P k h) :=\nbegin\n  induction n with n IH; intro; resetI,\n  { exact is_false (λ ⟨_, h, _⟩, nat.not_lt_zero _ h) },\n  cases IH (λ k h, P k (nat.lt_succ_of_lt h)) with h,\n  { by_cases p : P n (nat.lt_succ_self n),\n    { exact is_true ⟨n, nat.lt_succ_self n, p⟩ },\n    { apply is_false,\n      intro hk,\n      rcases hk with ⟨k, hk1, hk2⟩,\n      cases nat.lt_succ_iff_lt_or_eq.1 hk1 with hk hk,\n      { exact h ⟨k, hk, hk2⟩ },\n      { subst hk, exact p hk2 } } },\n  apply is_true,\n  rcases h with ⟨k, hk1, hk2⟩,\n  exact ⟨k, nat.lt_succ_of_lt hk1, hk2⟩\nend\n\ninstance nat.decidable_bex_le (n : nat) (P : Π k ≤ n, Prop)\n  [Π n h, decidable (P n h)] : decidable (∃ k h, P k h) :=\ndecidable_of_iff (∃ k < n + 1, P k (nat.le_of_lt_succ H))\n⟨λ ⟨k, h1, h2⟩, ⟨k, nat.le_of_lt_succ h1, h2⟩,\nλ ⟨k, h1, h2⟩, ⟨k, nat.lt_succ_of_le h1, h2⟩⟩\n\ninstance decidable_mul_self_nat (n : ℕ) : decidable (∃ k, k * k = n) :=\ndecidable_of_iff (∃ k ≤ n, k * k = n)\n⟨λ ⟨k, h1, h2⟩, ⟨k, h2⟩, λ ⟨k, h1⟩, ⟨k, h1 ▸ nat.le_mul_self k, h1⟩⟩\n\ninstance decidable_sqr_nat (n : ℕ) : decidable (∃ k, k^2 = n) :=\ndecidable_of_iff (∃ k, k * k = n)\n⟨λ ⟨k, h⟩, ⟨k, by rwa [nat.pow_two]⟩, λ ⟨k, h⟩, ⟨k, by rwa [nat.pow_two] at h⟩⟩\n\ninstance decidable_mul_self_int : Π (n : ℤ), decidable (∃ k, k * k = n)\n| (int.of_nat n) := decidable_of_iff (∃ k, k * k = n)\n    ⟨λ ⟨k, hk⟩, ⟨k, by rw [← int.coe_nat_mul, hk]; refl⟩,\n    λ ⟨k, hk⟩, ⟨int.nat_abs k, by rw [← int.nat_abs_mul, hk]; refl⟩⟩\n| -[1+ n] := is_false $ λ ⟨k, h1⟩, not_lt_of_ge (mul_self_nonneg k) $\n    h1.symm ▸ int.neg_succ_of_nat_lt_zero n\n\ninstance decidable_sqr_int (n : ℤ) : decidable (∃ k, k^2 = n) :=\ndecidable_of_iff (∃ k, k * k = n)\n⟨λ ⟨k, h⟩, ⟨k, by rwa [pow_two]⟩, λ ⟨k, h⟩, ⟨k, by rwa [pow_two] at h⟩⟩\n\ntheorem what_i_need: ¬ (∃ n : ℤ ,  n ^ 2 = 2 ) := dec_trivial\ntheorem what_i_need_2: ¬ (∃ n : ℤ ,  n ^ 2 = -1 ) := dec_trivial\n\n\n--nstance h (m : ℤ) : decidable (∃ n : ℤ, n ^ 2 = m) :=\n--decidable_of_iff (0 ≤ m ∧ m.nat_abs.sqrt ^ 2 = m.nat_abs)\n--⟨λ h, ⟨nat.sqrt m.nat_abs, by rw [← int.coe_nat_pow, h.2, int.nat_abs_of_nonneg h.1]⟩,\n--λ ⟨s, hs⟩, ⟨hs ▸ (pow_two_nonneg _), by rw [← hs, pow_two, int.nat_abs_mul, nat.sqrt_eq, nat.pow_two]⟩⟩\n--#eval (¬ ∃ n : ℤ, n ^ 2 = 2 : bool)\n--lemma two_not_square : ¬ ∃ n : ℤ, n ^ 2 = 2 := tactic.exact_dec_trivial\n\n\ntheorem Q1r : reflexive r1 := begin\nunfold reflexive r1,\nintro HP,\napply le_refl,\nend\ntheorem Q1s : ¬ (symmetric r1) := begin\nunfold symmetric r1,\nintro HP,\nhave h2: (0:ℝ ) ≤ (1:ℝ), by norm_num,\nhave h3:= HP h2,\nhave h4: ¬((1:ℝ) ≤ (0:ℝ)), by norm_num,\nexact h4 h3,\nend\ntheorem Q1t : transitive r1 := begin\nunfold transitive r1,\nintro a,\nintro b,\nintro c,\nassume h1 : a ≤ b,\nassume h2 : b ≤ c,\napply le_trans,\nassumption,\nassumption,\nend\n\n\ntheorem Q2r : (reflexive r2) := begin\nunfold reflexive r2,\nintro a,\nhave h1 : a - a = 0, norm_num,\nhave h2 : (0 : ℤ) = (0 : ℤ) * (0 : ℤ), norm_num,\nexistsi (0 : ℤ),\nexact h2,\nend\ntheorem Q2s : ¬ (symmetric r2) := begin\nunfold symmetric r2,\nintro HP,\nhave h1 : (1: ℤ )-(0: ℤ ) = 1^2, by norm_num,\nhave h4 := HP(exists.intro(1: ℤ ) h1),\nsimp at h4,\napply what_i_need_2,\n  cases h4 with z hz,\n  existsi z,\n  rwa eq_comm,\nend\ntheorem Q2t : ¬ (transitive r2) := begin\nunfold transitive r2,\nintro HP,\nhave h1: (2:ℤ ) - (1:ℤ ) = 1^2, by refl,\nhave h2: (1:ℤ ) - (0:ℤ ) = 1^2, by refl,\nhave h3: (2:ℤ ) - (0:ℤ ) = 2, by norm_num,\nhave h4 := HP (exists.intro (1: ℤ ) h1)(exists.intro(1:ℤ ) h2),\napply what_i_need,\nsimp at h4,\ncases h4 with z hz,\nexistsi z,\nrw hz,\nend\n\n\ntheorem Q3r : ¬ (reflexive r3) := begin\nunfold reflexive r3,\nintro HP,\nlet x := (2 :ℝ ),\nhave h1 : (2 : ℝ ) ≠ (2:ℝ )^2, by norm_num,\nhave h2 := HP(2: ℝ ),\napply h1,\nexact h2,\nend\ntheorem Q3s : ¬ (symmetric r3) := begin\nunfold symmetric r3,\nintro HP,\nlet a := (4: ℝ ),\nlet b := (2: ℝ ),\nhave h1 : a = b^2, by refl,\nhave h2 : a^2 = 16, by refl,\nhave h3 : (2 : ℝ) ≠ 16, by norm_num,\nhave h4 := HP h1,\nhave h5 : b= 2, by refl,\nrw h2 at h4, \napply h3,\nexact h4,\nend\ntheorem Q3t : ¬ (transitive r3) := begin\nunfold transitive r3,\nintro HP,\nhave h1: (16: ℝ ) = (4: ℝ )^2, by refl,\nhave h2: (4:ℝ ) = (2:ℝ )^2, by refl,\nhave h3: (16: ℝ ) ≠ (2:ℝ )^2, by norm_num,\nhave h4 := HP h1 h2,\napply h3,\nexact h4, \nend\n\ntheorem Q4r : ¬ (reflexive r4) := begin\nunfold reflexive r4,\nintro HP,\nhave h1 : (1:ℤ )+ (1:ℤ ) ≠ (0:ℤ ), by norm_num,\nhave h2 := HP(1:ℤ ),\napply h1,\nexact h2,\nend\ntheorem Q4s : (symmetric r4) := begin\nunfold symmetric r4,\nintro HP,\nintro a,\nintro b,\nrw add_comm a HP,\nexact b,\nend\ntheorem Q4t : ¬ (transitive r4) := begin\n\nunfold transitive r4,\nintro HP,\nlet a:= (1:ℤ) , \nlet b:= (-1: ℤ ),\nlet c:= (1: ℤ ),\nhave h1 : a + b = 0, by refl,\nhave h2 : b + c = 0, by refl,\nhave h3 : a + c = 2, by refl,\nhave h4 := HP h1 h2,\nrw h3 at h4, norm_num at h4,\nend\n\n\n\ntheorem Q5r :  ¬ (reflexive r5) := begin\nunfold reflexive r5,\nintro HP,\ndunfold S5 at HP,\nhave h1 : (2:ℕ ) ∈ {x : ℕ | x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4}, by norm_num,\nhave h2 : (2 : ℕ ) ≠ (1 : ℕ ), by norm_num,\nhave h3 : (2 : ℕ ) ≠ (3 : ℕ ), by norm_num,\nhave h4 := HP ⟨2, by simp⟩,\napply h2,\nexact h4.left,\nend\ntheorem Q5s : ¬ (symmetric r5) := begin\nunfold symmetric r5,\nintro HP,\ndunfold S5 at HP,\nhave h1 : (1 :ℕ ) ∈ {x : ℕ | x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4}, by norm_num,\nhave h2 : (3 :ℕ ) ∈ {x : ℕ | x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4}, by norm_num,\nhave h3 : (1 :ℕ ) ≠ (3 :ℕ ), by norm_num,\nhave := @HP ⟨(1 : ℕ), by simp⟩ ⟨3, by simp⟩ ⟨rfl, rfl⟩,\napply h3,\nexact this.right,\nend\ntheorem Q5t : (transitive r5) := begin\nunfold transitive r5,\nhave h1 : (1 :ℕ ) ∈ {x : ℕ | x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4}, by norm_num,\nhave h2 : (3 :ℕ ) ∈ {x : ℕ | x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4}, by norm_num,\nhave h3 : (1 :ℕ ) ≠ (3 :ℕ ), by norm_num,\nhave h4 : (3 :ℕ ) ≠ (1 :ℕ ), by norm_num,\nfinish,\nend\n\n\n\ntheorem Q6r : (reflexive r6) := begin\nunfold reflexive r6,\ndunfold S6,\nsimp,\nend\ntheorem Q6s : (symmetric r6) := begin\nunfold symmetric r6,\ndunfold S6,\nsimp,\nend\ntheorem Q6t : (transitive r6) := begin\nunfold transitive r6,\ndunfold S6,\nsimp,\nend\n\n", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/M1F/problem_bank/PB0804/Q0804.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.4958351829759348}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Kevin Buzzard, Scott Morrison, Johan Commelin, Chris Hughes,\n  Johannes Hölzl, Yury Kudryashov\n\n! This file was ported from Lean 3 source module algebra.hom.group\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.NeZero\nimport Mathbin.Algebra.Group.Basic\nimport Mathbin.Algebra.GroupWithZero.Defs\nimport Mathbin.Data.FunLike.Basic\n\n/-!\n# Monoid and group homomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the bundled structures for monoid and group homomorphisms. Namely, we define\n`monoid_hom` (resp., `add_monoid_hom`) to be bundled homomorphisms between multiplicative (resp.,\nadditive) monoids or groups.\n\nWe also define coercion to a function, and  usual operations: composition, identity homomorphism,\npointwise multiplication and pointwise inversion.\n\nThis file also defines the lesser-used (and notation-less) homomorphism types which are used as\nbuilding blocks for other homomorphisms:\n\n* `zero_hom`\n* `one_hom`\n* `add_hom`\n* `mul_hom`\n* `monoid_with_zero_hom`\n\n## Notations\n\n* `→+`: Bundled `add_monoid` homs. Also use for `add_group` homs.\n* `→*`: Bundled `monoid` homs. Also use for `group` homs.\n* `→*₀`: Bundled `monoid_with_zero` homs. Also use for `group_with_zero` homs.\n* `→ₙ*`: Bundled `semigroup` homs.\n\n## Implementation notes\n\nThere's a coercion from bundled homs to fun, and the canonical\nnotation is to use the bundled hom as a function via this coercion.\n\nThere is no `group_hom` -- the idea is that `monoid_hom` is used.\nThe constructor for `monoid_hom` needs a proof of `map_one` as well\nas `map_mul`; a separate constructor `monoid_hom.mk'` will construct\ngroup homs (i.e. monoid homs between groups) given only a proof\nthat multiplication is preserved,\n\nImplicit `{}` brackets are often used instead of type class `[]` brackets.  This is done when the\ninstances can be inferred because they are implicit arguments to the type `monoid_hom`.  When they\ncan be inferred from the type it is faster to use this method than to use type class inference.\n\nHistorically this file also included definitions of unbundled homomorphism classes; they were\ndeprecated and moved to `deprecated/group`.\n\n## Tags\n\nmonoid_hom, add_monoid_hom\n\n-/\n\n\nvariable {α β M N P : Type _}\n\n-- monoids\nvariable {G : Type _} {H : Type _}\n\n-- groups\nvariable {F : Type _}\n\n-- homs\n-- for easy multiple inheritance\nsection Zero\n\n#print ZeroHom /-\n/-- `zero_hom M N` is the type of functions `M → N` that preserve zero.\n\nWhen possible, instead of parametrizing results over `(f : zero_hom M N)`,\nyou should parametrize over `(F : Type*) [zero_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to also extend `zero_hom_class`.\n-/\nstructure ZeroHom (M : Type _) (N : Type _) [Zero M] [Zero N] where\n  toFun : M → N\n  map_zero' : to_fun 0 = 0\n#align zero_hom ZeroHom\n-/\n\n#print ZeroHomClass /-\n/-- `zero_hom_class F M N` states that `F` is a type of zero-preserving homomorphisms.\n\nYou should extend this typeclass when you extend `zero_hom`.\n-/\nclass ZeroHomClass (F : Type _) (M N : outParam <| Type _) [Zero M] [Zero N] extends\n  FunLike F M fun _ => N where\n  map_zero : ∀ f : F, f 0 = 0\n#align zero_hom_class ZeroHomClass\n-/\n\n-- Instances and lemmas are defined below through `@[to_additive]`.\nend Zero\n\nnamespace NeZero\n\n/- warning: ne_zero.of_map -> NeZero.of_map is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {R : Type.{u2}} {M : Type.{u3}} [_inst_1 : Zero.{u2} R] [_inst_2 : Zero.{u3} M] [_inst_3 : ZeroHomClass.{u1, u2, u3} F R M _inst_1 _inst_2] (f : F) {r : R} [_inst_4 : NeZero.{u3} M _inst_2 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => R -> M) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F R (fun (_x : R) => M) (ZeroHomClass.toFunLike.{u1, u2, u3} F R M _inst_1 _inst_2 _inst_3)) f r)], NeZero.{u2} R _inst_1 r\nbut is expected to have type\n  forall {F : Type.{u1}} {R : Type.{u3}} {M : Type.{u2}} [_inst_1 : Zero.{u3} R] [_inst_2 : Zero.{u2} M] [_inst_3 : ZeroHomClass.{u1, u3, u2} F R M _inst_1 _inst_2] (f : F) {r : R} [_inst_4 : NeZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : R) => M) r) _inst_2 (FunLike.coe.{succ u1, succ u3, succ u2} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : R) => M) _x) (ZeroHomClass.toFunLike.{u1, u3, u2} F R M _inst_1 _inst_2 _inst_3) f r)], NeZero.{u3} R _inst_1 r\nCase conversion may be inaccurate. Consider using '#align ne_zero.of_map NeZero.of_mapₓ'. -/\ntheorem of_map {R M} [Zero R] [Zero M] [ZeroHomClass F R M] (f : F) {r : R} [NeZero (f r)] :\n    NeZero r :=\n  ⟨fun h => ne (f r) <| by convert ZeroHomClass.map_zero f⟩\n#align ne_zero.of_map NeZero.of_map\n\n/- warning: ne_zero.of_injective -> NeZero.of_injective is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {R : Type.{u2}} {M : Type.{u3}} [_inst_1 : Zero.{u2} R] {r : R} [_inst_2 : NeZero.{u2} R _inst_1 r] [_inst_3 : Zero.{u3} M] [_inst_4 : ZeroHomClass.{u1, u2, u3} F R M _inst_1 _inst_3] {f : F}, (Function.Injective.{succ u2, succ u3} R M (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => R -> M) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F R (fun (_x : R) => M) (ZeroHomClass.toFunLike.{u1, u2, u3} F R M _inst_1 _inst_3 _inst_4)) f)) -> (NeZero.{u3} M _inst_3 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => R -> M) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F R (fun (_x : R) => M) (ZeroHomClass.toFunLike.{u1, u2, u3} F R M _inst_1 _inst_3 _inst_4)) f r))\nbut is expected to have type\n  forall {F : Type.{u1}} {R : Type.{u3}} {M : Type.{u2}} [_inst_1 : Zero.{u3} R] {r : R} [_inst_2 : NeZero.{u3} R _inst_1 r] [_inst_3 : Zero.{u2} M] [_inst_4 : ZeroHomClass.{u1, u3, u2} F R M _inst_1 _inst_3] {f : F}, (Function.Injective.{succ u3, succ u2} R M (FunLike.coe.{succ u1, succ u3, succ u2} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : R) => M) _x) (ZeroHomClass.toFunLike.{u1, u3, u2} F R M _inst_1 _inst_3 _inst_4) f)) -> (NeZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : R) => M) r) _inst_3 (FunLike.coe.{succ u1, succ u3, succ u2} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : R) => M) _x) (ZeroHomClass.toFunLike.{u1, u3, u2} F R M _inst_1 _inst_3 _inst_4) f r))\nCase conversion may be inaccurate. Consider using '#align ne_zero.of_injective NeZero.of_injectiveₓ'. -/\ntheorem of_injective {R M} [Zero R] {r : R} [NeZero r] [Zero M] [ZeroHomClass F R M] {f : F}\n    (hf : Function.Injective f) : NeZero (f r) :=\n  ⟨by\n    rw [← ZeroHomClass.map_zero f]\n    exact hf.ne (Ne r)⟩\n#align ne_zero.of_injective NeZero.of_injective\n\nend NeZero\n\nsection Add\n\n#print AddHom /-\n/-- `add_hom M N` is the type of functions `M → N` that preserve addition.\n\nWhen possible, instead of parametrizing results over `(f : add_hom M N)`,\nyou should parametrize over `(F : Type*) [add_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `add_hom_class`.\n-/\nstructure AddHom (M : Type _) (N : Type _) [Add M] [Add N] where\n  toFun : M → N\n  map_add' : ∀ x y, to_fun (x + y) = to_fun x + to_fun y\n#align add_hom AddHom\n-/\n\n#print AddHomClass /-\n/-- `add_hom_class F M N` states that `F` is a type of addition-preserving homomorphisms.\nYou should declare an instance of this typeclass when you extend `add_hom`.\n-/\nclass AddHomClass (F : Type _) (M N : outParam <| Type _) [Add M] [Add N] extends\n  FunLike F M fun _ => N where\n  map_add : ∀ (f : F) (x y : M), f (x + y) = f x + f y\n#align add_hom_class AddHomClass\n-/\n\n-- Instances and lemmas are defined below through `@[to_additive]`.\nend Add\n\nsection add_zero\n\n#print AddMonoidHom /-\n/-- `M →+ N` is the type of functions `M → N` that preserve the `add_zero_class` structure.\n\n`add_monoid_hom` is also used for group homomorphisms.\n\nWhen possible, instead of parametrizing results over `(f : M →+ N)`,\nyou should parametrize over `(F : Type*) [add_monoid_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `add_monoid_hom_class`.\n-/\nstructure AddMonoidHom (M : Type _) (N : Type _) [AddZeroClass M] [AddZeroClass N] extends\n  ZeroHom M N, AddHom M N\n#align add_monoid_hom AddMonoidHom\n-/\n\nattribute [nolint doc_blame] AddMonoidHom.toAddHom\n\nattribute [nolint doc_blame] AddMonoidHom.toZeroHom\n\n-- mathport name: «expr →+ »\ninfixr:25 \" →+ \" => AddMonoidHom\n\n#print AddMonoidHomClass /-\n/-- `add_monoid_hom_class F M N` states that `F` is a type of `add_zero_class`-preserving\nhomomorphisms.\n\nYou should also extend this typeclass when you extend `add_monoid_hom`.\n-/\nclass AddMonoidHomClass (F : Type _) (M N : outParam <| Type _) [AddZeroClass M]\n  [AddZeroClass N] extends AddHomClass F M N, ZeroHomClass F M N\n#align add_monoid_hom_class AddMonoidHomClass\n-/\n\n-- Instances and lemmas are defined below through `@[to_additive]`.\nend add_zero\n\nsection One\n\nvariable [One M] [One N]\n\n#print OneHom /-\n/-- `one_hom M N` is the type of functions `M → N` that preserve one.\n\nWhen possible, instead of parametrizing results over `(f : one_hom M N)`,\nyou should parametrize over `(F : Type*) [one_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to also extend `one_hom_class`.\n-/\n@[to_additive]\nstructure OneHom (M : Type _) (N : Type _) [One M] [One N] where\n  toFun : M → N\n  map_one' : to_fun 1 = 1\n#align one_hom OneHom\n#align zero_hom ZeroHom\n-/\n\n#print OneHomClass /-\n/-- `one_hom_class F M N` states that `F` is a type of one-preserving homomorphisms.\nYou should extend this typeclass when you extend `one_hom`.\n-/\n@[to_additive]\nclass OneHomClass (F : Type _) (M N : outParam <| Type _) [One M] [One N] extends\n  FunLike F M fun _ => N where\n  map_one : ∀ f : F, f 1 = 1\n#align one_hom_class OneHomClass\n#align zero_hom_class ZeroHomClass\n-/\n\n#print OneHom.oneHomClass /-\n@[to_additive]\ninstance OneHom.oneHomClass : OneHomClass (OneHom M N) M N\n    where\n  coe := OneHom.toFun\n  coe_injective' f g h := by cases f <;> cases g <;> congr\n  map_one := OneHom.map_one'\n#align one_hom.one_hom_class OneHom.oneHomClass\n#align zero_hom.zero_hom_class ZeroHom.zeroHomClass\n-/\n\n/- warning: map_one -> map_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : OneHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F), Eq.{succ u2} N (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (OneHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M _inst_1)))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N _inst_2)))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] [_inst_3 : OneHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) _inst_2))\nCase conversion may be inaccurate. Consider using '#align map_one map_oneₓ'. -/\n@[simp, to_additive]\ntheorem map_one [OneHomClass F M N] (f : F) : f 1 = 1 :=\n  OneHomClass.map_one f\n#align map_one map_one\n#align map_zero map_zero\n\n/- warning: map_eq_one_iff -> map_eq_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : OneHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F), (Function.Injective.{succ u1, succ u2} M N (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (OneHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f)) -> (forall {x : M}, Iff (Eq.{succ u2} N (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (OneHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f x) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N _inst_2)))) (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M _inst_1)))))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] [_inst_3 : OneHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F), (Function.Injective.{succ u2, succ u1} M N (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f)) -> (forall {x : M}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) _inst_2))) (Eq.{succ u2} M x (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align map_eq_one_iff map_eq_one_iffₓ'. -/\n@[to_additive]\ntheorem map_eq_one_iff [OneHomClass F M N] (f : F) (hf : Function.Injective f) {x : M} :\n    f x = 1 ↔ x = 1 :=\n  hf.eq_iff' (map_one f)\n#align map_eq_one_iff map_eq_one_iff\n#align map_eq_zero_iff map_eq_zero_iff\n\n/- warning: map_ne_one_iff -> map_ne_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {F : Type.{u3}} [_inst_3 : One.{u1} R] [_inst_4 : One.{u2} S] [_inst_5 : OneHomClass.{u3, u1, u2} F R S _inst_3 _inst_4] (f : F), (Function.Injective.{succ u1, succ u2} R S (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => R -> S) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F R (fun (_x : R) => S) (OneHomClass.toFunLike.{u3, u1, u2} F R S _inst_3 _inst_4 _inst_5)) f)) -> (forall {x : R}, Iff (Ne.{succ u2} S (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => R -> S) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F R (fun (_x : R) => S) (OneHomClass.toFunLike.{u3, u1, u2} F R S _inst_3 _inst_4 _inst_5)) f x) (OfNat.ofNat.{u2} S 1 (OfNat.mk.{u2} S 1 (One.one.{u2} S _inst_4)))) (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R _inst_3)))))\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u2}} {F : Type.{u1}} [_inst_3 : One.{u3} R] [_inst_4 : One.{u2} S] [_inst_5 : OneHomClass.{u1, u3, u2} F R S _inst_3 _inst_4] (f : F), (Function.Injective.{succ u3, succ u2} R S (FunLike.coe.{succ u1, succ u3, succ u2} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) _x) (OneHomClass.toFunLike.{u1, u3, u2} F R S _inst_3 _inst_4 _inst_5) f)) -> (forall {x : R}, Iff (Ne.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) x) (FunLike.coe.{succ u1, succ u3, succ u2} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) _x) (OneHomClass.toFunLike.{u1, u3, u2} F R S _inst_3 _inst_4 _inst_5) f x) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) x) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) x) _inst_4))) (Ne.{succ u3} R x (OfNat.ofNat.{u3} R 1 (One.toOfNat1.{u3} R _inst_3))))\nCase conversion may be inaccurate. Consider using '#align map_ne_one_iff map_ne_one_iffₓ'. -/\n@[to_additive]\ntheorem map_ne_one_iff {R S F : Type _} [One R] [One S] [OneHomClass F R S] (f : F)\n    (hf : Function.Injective f) {x : R} : f x ≠ 1 ↔ x ≠ 1 :=\n  (map_eq_one_iff f hf).Not\n#align map_ne_one_iff map_ne_one_iff\n#align map_ne_zero_iff map_ne_zero_iff\n\n/- warning: ne_one_of_map -> ne_one_of_map is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {F : Type.{u3}} [_inst_3 : One.{u1} R] [_inst_4 : One.{u2} S] [_inst_5 : OneHomClass.{u3, u1, u2} F R S _inst_3 _inst_4] {f : F} {x : R}, (Ne.{succ u2} S (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => R -> S) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F R (fun (_x : R) => S) (OneHomClass.toFunLike.{u3, u1, u2} F R S _inst_3 _inst_4 _inst_5)) f x) (OfNat.ofNat.{u2} S 1 (OfNat.mk.{u2} S 1 (One.one.{u2} S _inst_4)))) -> (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R _inst_3))))\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u2}} {F : Type.{u1}} [_inst_3 : One.{u3} R] [_inst_4 : One.{u2} S] [_inst_5 : OneHomClass.{u1, u3, u2} F R S _inst_3 _inst_4] {f : F} {x : R}, (Ne.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) x) (FunLike.coe.{succ u1, succ u3, succ u2} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) _x) (OneHomClass.toFunLike.{u1, u3, u2} F R S _inst_3 _inst_4 _inst_5) f x) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) x) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : R) => S) x) _inst_4))) -> (Ne.{succ u3} R x (OfNat.ofNat.{u3} R 1 (One.toOfNat1.{u3} R _inst_3)))\nCase conversion may be inaccurate. Consider using '#align ne_one_of_map ne_one_of_mapₓ'. -/\n@[to_additive]\ntheorem ne_one_of_map {R S F : Type _} [One R] [One S] [OneHomClass F R S] {f : F} {x : R}\n    (hx : f x ≠ 1) : x ≠ 1 :=\n  ne_of_apply_ne f <| ne_of_ne_of_eq hx (map_one f).symm\n#align ne_one_of_map ne_one_of_map\n#align ne_zero_of_map ne_zero_of_map\n\n@[to_additive]\ninstance [OneHomClass F M N] : CoeTC F (OneHom M N) :=\n  ⟨fun f =>\n    { toFun := f\n      map_one' := map_one f }⟩\n\n/- warning: one_hom.coe_coe -> OneHom.coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : OneHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u1) (succ u2)} ((fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (OneHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (OneHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (OneHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (FunLike.hasCoeToFun.{max (succ u2) (succ u1), succ u1, succ u2} (OneHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => N) (OneHomClass.toFunLike.{max u2 u1, u1, u2} (OneHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u1, u2} M N _inst_1 _inst_2))) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (OneHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (OneHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (OneHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (OneHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] [_inst_3 : OneHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) (OneHomClass.toOneHom.{u2, u1, u3} M N F _inst_1 _inst_2 _inst_3 f)) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f)\nCase conversion may be inaccurate. Consider using '#align one_hom.coe_coe OneHom.coe_coeₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_coe [OneHomClass F M N] (f : F) : ((f : OneHom M N) : M → N) = f :=\n  rfl\n#align one_hom.coe_coe OneHom.coe_coe\n#align zero_hom.coe_coe ZeroHom.coe_coe\n\nend One\n\nsection Mul\n\nvariable [Mul M] [Mul N]\n\n#print MulHom /-\n/-- `M →ₙ* N` is the type of functions `M → N` that preserve multiplication. The `ₙ` in the notation\nstands for \"non-unital\" because it is intended to match the notation for `non_unital_alg_hom` and\n`non_unital_ring_hom`, so a `mul_hom` is a non-unital monoid hom.\n\nWhen possible, instead of parametrizing results over `(f : M →ₙ* N)`,\nyou should parametrize over `(F : Type*) [mul_hom_class F M N] (f : F)`.\nWhen you extend this structure, make sure to extend `mul_hom_class`.\n-/\n@[to_additive]\nstructure MulHom (M : Type _) (N : Type _) [Mul M] [Mul N] where\n  toFun : M → N\n  map_mul' : ∀ x y, to_fun (x * y) = to_fun x * to_fun y\n#align mul_hom MulHom\n#align add_hom AddHom\n-/\n\n-- mathport name: «expr →ₙ* »\ninfixr:25 \" →ₙ* \" => MulHom\n\n#print MulHomClass /-\n/-- `mul_hom_class F M N` states that `F` is a type of multiplication-preserving homomorphisms.\n\nYou should declare an instance of this typeclass when you extend `mul_hom`.\n-/\n@[to_additive]\nclass MulHomClass (F : Type _) (M N : outParam <| Type _) [Mul M] [Mul N] extends\n  FunLike F M fun _ => N where\n  map_mul : ∀ (f : F) (x y : M), f (x * y) = f x * f y\n#align mul_hom_class MulHomClass\n#align add_hom_class AddHomClass\n-/\n\n#print MulHom.mulHomClass /-\n@[to_additive]\ninstance MulHom.mulHomClass : MulHomClass (M →ₙ* N) M N\n    where\n  coe := MulHom.toFun\n  coe_injective' f g h := by cases f <;> cases g <;> congr\n  map_mul := MulHom.map_mul'\n#align mul_hom.mul_hom_class MulHom.mulHomClass\n#align add_hom.add_hom_class AddHom.addHomClass\n-/\n\n/- warning: map_mul -> map_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : MulHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F) (x : M) (y : M), Eq.{succ u2} N (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M _inst_1) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N _inst_2) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f x) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f y))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] [_inst_3 : MulHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F) (x : M) (y : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M _inst_1) x y)) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M _inst_1) x y)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) y) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) _inst_2) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f x) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f y))\nCase conversion may be inaccurate. Consider using '#align map_mul map_mulₓ'. -/\n@[simp, to_additive]\ntheorem map_mul [MulHomClass F M N] (f : F) (x y : M) : f (x * y) = f x * f y :=\n  MulHomClass.map_mul f x y\n#align map_mul map_mul\n#align map_add map_add\n\n@[to_additive]\ninstance [MulHomClass F M N] : CoeTC F (M →ₙ* N) :=\n  ⟨fun f =>\n    { toFun := f\n      map_mul' := map_mul f }⟩\n\n/- warning: mul_hom.coe_coe -> MulHom.coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : MulHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u1) (succ u2)} ((fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (MulHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (MulHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (MulHom.{u1, u2} M N _inst_1 _inst_2) (MulHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (FunLike.hasCoeToFun.{max (succ u2) (succ u1), succ u1, succ u2} (MulHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => N) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MulHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u1, u2} M N _inst_1 _inst_2))) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (MulHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (MulHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (MulHom.{u1, u2} M N _inst_1 _inst_2) (MulHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] [_inst_3 : MulHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) (MulHomClass.toMulHom.{u2, u1, u3} M N F _inst_1 _inst_2 _inst_3 f)) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f)\nCase conversion may be inaccurate. Consider using '#align mul_hom.coe_coe MulHom.coe_coeₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_coe [MulHomClass F M N] (f : F) : ((f : MulHom M N) : M → N) = f :=\n  rfl\n#align mul_hom.coe_coe MulHom.coe_coe\n#align add_hom.coe_coe AddHom.coe_coe\n\nend Mul\n\nsection mul_one\n\nvariable [MulOneClass M] [MulOneClass N]\n\n#print MonoidHom /-\n/-- `M →* N` is the type of functions `M → N` that preserve the `monoid` structure.\n`monoid_hom` is also used for group homomorphisms.\n\nWhen possible, instead of parametrizing results over `(f : M →+ N)`,\nyou should parametrize over `(F : Type*) [monoid_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `monoid_hom_class`.\n-/\n@[to_additive]\nstructure MonoidHom (M : Type _) (N : Type _) [MulOneClass M] [MulOneClass N] extends OneHom M N,\n  M →ₙ* N\n#align monoid_hom MonoidHom\n#align add_monoid_hom AddMonoidHom\n-/\n\nattribute [nolint doc_blame] MonoidHom.toMulHom\n\nattribute [nolint doc_blame] MonoidHom.toOneHom\n\n-- mathport name: «expr →* »\ninfixr:25 \" →* \" => MonoidHom\n\n#print MonoidHomClass /-\n/-- `monoid_hom_class F M N` states that `F` is a type of `monoid`-preserving homomorphisms.\nYou should also extend this typeclass when you extend `monoid_hom`. -/\n@[to_additive\n      \"`add_monoid_hom_class F M N` states that `F` is a type of `add_monoid`-preserving homomorphisms.\\nYou should also extend this typeclass when you extend `add_monoid_hom`.\"]\nclass MonoidHomClass (F : Type _) (M N : outParam <| Type _) [MulOneClass M] [MulOneClass N] extends\n  MulHomClass F M N, OneHomClass F M N\n#align monoid_hom_class MonoidHomClass\n#align add_monoid_hom_class AddMonoidHomClass\n-/\n\n#print MonoidHom.monoidHomClass /-\n@[to_additive]\ninstance MonoidHom.monoidHomClass : MonoidHomClass (M →* N) M N\n    where\n  coe := MonoidHom.toFun\n  coe_injective' f g h := by cases f <;> cases g <;> congr\n  map_mul := MonoidHom.map_mul'\n  map_one := MonoidHom.map_one'\n#align monoid_hom.monoid_hom_class MonoidHom.monoidHomClass\n#align add_monoid_hom.add_monoid_hom_class AddMonoidHom.addMonoidHomClass\n-/\n\n@[to_additive]\ninstance [MonoidHomClass F M N] : CoeTC F (M →* N) :=\n  ⟨fun f =>\n    { toFun := f\n      map_one' := map_one f\n      map_mul' := map_mul f }⟩\n\n/- warning: monoid_hom.coe_coe -> MonoidHom.coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MonoidHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (FunLike.hasCoeToFun.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => N) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u1, u2} M N _inst_1 _inst_2)))) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3))) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] [_inst_3 : MonoidHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) (MonoidHomClass.toMonoidHom.{u2, u1, u3} M N F _inst_1 _inst_2 _inst_3 f)) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3)) f)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_coe MonoidHom.coe_coeₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_coe [MonoidHomClass F M N] (f : F) : ((f : M →* N) : M → N) = f :=\n  rfl\n#align monoid_hom.coe_coe MonoidHom.coe_coe\n#align add_monoid_hom.coe_coe AddMonoidHom.coe_coe\n\n/- warning: map_mul_eq_one -> map_mul_eq_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MonoidHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F) {a : M} {b : M}, (Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) a b) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))) -> (Eq.{succ u2} N (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N _inst_2)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3))) f a) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3))) f b)) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N _inst_2)))))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] [_inst_3 : MonoidHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F) {a : M} {b : M}, (Eq.{succ u2} M (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M _inst_1)) a b) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M _inst_1)))) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2)) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3)) f a) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3)) f b)) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (MulOneClass.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2))))\nCase conversion may be inaccurate. Consider using '#align map_mul_eq_one map_mul_eq_oneₓ'. -/\n@[to_additive]\ntheorem map_mul_eq_one [MonoidHomClass F M N] (f : F) {a b : M} (h : a * b = 1) : f a * f b = 1 :=\n  by rw [← map_mul, h, map_one]\n#align map_mul_eq_one map_mul_eq_one\n#align map_add_eq_zero map_add_eq_zero\n\n/- warning: map_div' -> map_div' is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : DivInvMonoid.{u1} G] [_inst_4 : DivInvMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))] (f : F), (forall (a : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G _inst_3) a)) (Inv.inv.{u2} H (DivInvMonoid.toHasInv.{u2} H _inst_4) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f a))) -> (forall (a : G) (b : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G _inst_3)) a b)) (HDiv.hDiv.{u2, u2, u2} H H H (instHDiv.{u2} H (DivInvMonoid.toHasDiv.{u2} H _inst_4)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f a) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f b)))\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : DivInvMonoid.{u3} G] [_inst_4 : DivInvMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))] (f : F), (forall (a : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (Inv.inv.{u3} G (DivInvMonoid.toInv.{u3} G _inst_3) a)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f (Inv.inv.{u3} G (DivInvMonoid.toInv.{u3} G _inst_3) a)) (Inv.inv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivInvMonoid.toInv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f a))) -> (forall (a : G) (b : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HDiv.hDiv.{u3, u3, u3} G G G (instHDiv.{u3} G (DivInvMonoid.toDiv.{u3} G _inst_3)) a b)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f (HDiv.hDiv.{u3, u3, u3} G G G (instHDiv.{u3} G (DivInvMonoid.toDiv.{u3} G _inst_3)) a b)) (HDiv.hDiv.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (instHDiv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivInvMonoid.toDiv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f a) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f b)))\nCase conversion may be inaccurate. Consider using '#align map_div' map_div'ₓ'. -/\n@[to_additive]\ntheorem map_div' [DivInvMonoid G] [DivInvMonoid H] [MonoidHomClass F G H] (f : F)\n    (hf : ∀ a, f a⁻¹ = (f a)⁻¹) (a b : G) : f (a / b) = f a / f b := by\n  rw [div_eq_mul_inv, div_eq_mul_inv, map_mul, hf]\n#align map_div' map_div'\n#align map_sub' map_sub'\n\n/- warning: map_inv -> map_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : Group.{u1} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (a : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)) a)) (Inv.inv.{u2} H (DivInvMonoid.toHasInv.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f a))\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : Group.{u3} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (a : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (Inv.inv.{u3} G (InvOneClass.toInv.{u3} G (DivInvOneMonoid.toInvOneClass.{u3} G (DivisionMonoid.toDivInvOneMonoid.{u3} G (Group.toDivisionMonoid.{u3} G _inst_3)))) a)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f (Inv.inv.{u3} G (InvOneClass.toInv.{u3} G (DivInvOneMonoid.toInvOneClass.{u3} G (DivisionMonoid.toDivInvOneMonoid.{u3} G (Group.toDivisionMonoid.{u3} G _inst_3)))) a)) (Inv.inv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (InvOneClass.toInv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivInvOneMonoid.toInvOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivisionMonoid.toDivInvOneMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4))) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f a))\nCase conversion may be inaccurate. Consider using '#align map_inv map_invₓ'. -/\n/-- Group homomorphisms preserve inverse. -/\n@[simp, to_additive \"Additive group homomorphisms preserve negation.\"]\ntheorem map_inv [Group G] [DivisionMonoid H] [MonoidHomClass F G H] (f : F) (a : G) :\n    f a⁻¹ = (f a)⁻¹ :=\n  eq_inv_of_mul_eq_one_left <| map_mul_eq_one f <| inv_mul_self _\n#align map_inv map_inv\n#align map_neg map_neg\n\n/- warning: map_mul_inv -> map_mul_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : Group.{u1} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (a : G) (b : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) a (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)) b))) (HMul.hMul.{u2, u2, u2} H H H (instHMul.{u2} H (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))))) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f a) (Inv.inv.{u2} H (DivInvMonoid.toHasInv.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f b)))\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : Group.{u3} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (a : G) (b : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HMul.hMul.{u3, u3, u3} G G G (instHMul.{u3} G (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))))) a (Inv.inv.{u3} G (InvOneClass.toInv.{u3} G (DivInvOneMonoid.toInvOneClass.{u3} G (DivisionMonoid.toDivInvOneMonoid.{u3} G (Group.toDivisionMonoid.{u3} G _inst_3)))) b))) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f (HMul.hMul.{u3, u3, u3} G G G (instHMul.{u3} G (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))))) a (Inv.inv.{u3} G (InvOneClass.toInv.{u3} G (DivInvOneMonoid.toInvOneClass.{u3} G (DivisionMonoid.toDivInvOneMonoid.{u3} G (Group.toDivisionMonoid.{u3} G _inst_3)))) b))) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (MulOneClass.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (Monoid.toMulOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivInvMonoid.toMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivisionMonoid.toDivInvMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4))))) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f a) (Inv.inv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) b) (InvOneClass.toInv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) b) (DivInvOneMonoid.toInvOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) b) (DivisionMonoid.toDivInvOneMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) b) _inst_4))) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f b)))\nCase conversion may be inaccurate. Consider using '#align map_mul_inv map_mul_invₓ'. -/\n/-- Group homomorphisms preserve division. -/\n@[simp, to_additive \"Additive group homomorphisms preserve subtraction.\"]\ntheorem map_mul_inv [Group G] [DivisionMonoid H] [MonoidHomClass F G H] (f : F) (a b : G) :\n    f (a * b⁻¹) = f a * (f b)⁻¹ := by rw [map_mul, map_inv]\n#align map_mul_inv map_mul_inv\n#align map_add_neg map_add_neg\n\n/- warning: map_div -> map_div is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : Group.{u1} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (a : G) (b : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) a b)) (HDiv.hDiv.{u2, u2, u2} H H H (instHDiv.{u2} H (DivInvMonoid.toHasDiv.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f a) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f b))\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : Group.{u3} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (a : G) (b : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HDiv.hDiv.{u3, u3, u3} G G G (instHDiv.{u3} G (DivInvMonoid.toDiv.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) a b)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f (HDiv.hDiv.{u3, u3, u3} G G G (instHDiv.{u3} G (DivInvMonoid.toDiv.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) a b)) (HDiv.hDiv.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (instHDiv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivInvMonoid.toDiv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (DivisionMonoid.toDivInvMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4))) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f a) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f b))\nCase conversion may be inaccurate. Consider using '#align map_div map_divₓ'. -/\n/-- Group homomorphisms preserve division. -/\n@[simp, to_additive \"Additive group homomorphisms preserve subtraction.\"]\ntheorem map_div [Group G] [DivisionMonoid H] [MonoidHomClass F G H] (f : F) :\n    ∀ a b, f (a / b) = f a / f b :=\n  map_div' _ <| map_inv f\n#align map_div map_div\n#align map_sub map_sub\n\n/- warning: map_pow -> map_pow is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : Monoid.{u1} G] [_inst_4 : Monoid.{u2} H] [_inst_5 : MonoidHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G _inst_3) (Monoid.toMulOneClass.{u2} H _inst_4)] (f : F) (a : G) (n : Nat), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G _inst_3)) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H _inst_4)) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G _inst_3) (Monoid.toMulOneClass.{u2} H _inst_4) _inst_5))) f (HPow.hPow.{u1, 0, u1} G Nat G (instHPow.{u1, 0} G Nat (Monoid.Pow.{u1} G _inst_3)) a n)) (HPow.hPow.{u2, 0, u2} H Nat H (instHPow.{u2, 0} H Nat (Monoid.Pow.{u2} H _inst_4)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G _inst_3)) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H _inst_4)) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G _inst_3) (Monoid.toMulOneClass.{u2} H _inst_4) _inst_5))) f a) n)\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : Monoid.{u3} G] [_inst_4 : Monoid.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G _inst_3) (Monoid.toMulOneClass.{u2} H _inst_4)] (f : F) (a : G) (n : Nat), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HPow.hPow.{u3, 0, u3} G Nat G (instHPow.{u3, 0} G Nat (Monoid.Pow.{u3} G _inst_3)) a n)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G _inst_3)) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H _inst_4)) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G _inst_3) (Monoid.toMulOneClass.{u2} H _inst_4) _inst_5)) f (HPow.hPow.{u3, 0, u3} G Nat G (instHPow.{u3, 0} G Nat (Monoid.Pow.{u3} G _inst_3)) a n)) (HPow.hPow.{u2, 0, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) Nat ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (instHPow.{u2, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) Nat (Monoid.Pow.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G _inst_3)) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H _inst_4)) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G _inst_3) (Monoid.toMulOneClass.{u2} H _inst_4) _inst_5)) f a) n)\nCase conversion may be inaccurate. Consider using '#align map_pow map_powₓ'. -/\n-- to_additive puts the arguments in the wrong order, so generate an auxiliary lemma, then\n-- swap its arguments.\n@[to_additive map_nsmul.aux, simp]\ntheorem map_pow [Monoid G] [Monoid H] [MonoidHomClass F G H] (f : F) (a : G) :\n    ∀ n : ℕ, f (a ^ n) = f a ^ n\n  | 0 => by rw [pow_zero, pow_zero, map_one]\n  | n + 1 => by rw [pow_succ, pow_succ, map_mul, map_pow]\n#align map_pow map_pow\n#align map_nsmul map_nsmul\n\n/- warning: map_nsmul -> map_nsmul is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : AddMonoid.{u1} G] [_inst_4 : AddMonoid.{u2} H] [_inst_5 : AddMonoidHomClass.{u3, u1, u2} F G H (AddMonoid.toAddZeroClass.{u1} G _inst_3) (AddMonoid.toAddZeroClass.{u2} H _inst_4)] (f : F) (n : Nat) (a : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (AddHomClass.toFunLike.{u3, u1, u2} F G H (AddZeroClass.toHasAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G _inst_3)) (AddZeroClass.toHasAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H _inst_4)) (AddMonoidHomClass.toAddHomClass.{u3, u1, u2} F G H (AddMonoid.toAddZeroClass.{u1} G _inst_3) (AddMonoid.toAddZeroClass.{u2} H _inst_4) _inst_5))) f (SMul.smul.{0, u1} Nat G (AddMonoid.SMul.{u1} G _inst_3) n a)) (SMul.smul.{0, u2} Nat H (AddMonoid.SMul.{u2} H _inst_4) n (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (AddHomClass.toFunLike.{u3, u1, u2} F G H (AddZeroClass.toHasAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G _inst_3)) (AddZeroClass.toHasAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H _inst_4)) (AddMonoidHomClass.toAddHomClass.{u3, u1, u2} F G H (AddMonoid.toAddZeroClass.{u1} G _inst_3) (AddMonoid.toAddZeroClass.{u2} H _inst_4) _inst_5))) f a))\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : AddMonoid.{u3} G] [_inst_4 : AddMonoid.{u2} H] [_inst_5 : AddMonoidHomClass.{u1, u3, u2} F G H (AddMonoid.toAddZeroClass.{u3} G _inst_3) (AddMonoid.toAddZeroClass.{u2} H _inst_4)] (f : F) (n : Nat) (a : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HSMul.hSMul.{0, u3, u3} Nat G G (instHSMul.{0, u3} Nat G (AddMonoid.SMul.{u3} G _inst_3)) n a)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (AddHomClass.toFunLike.{u1, u3, u2} F G H (AddZeroClass.toAdd.{u3} G (AddMonoid.toAddZeroClass.{u3} G _inst_3)) (AddZeroClass.toAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H _inst_4)) (AddMonoidHomClass.toAddHomClass.{u1, u3, u2} F G H (AddMonoid.toAddZeroClass.{u3} G _inst_3) (AddMonoid.toAddZeroClass.{u2} H _inst_4) _inst_5)) f (HSMul.hSMul.{0, u3, u3} Nat G G (instHSMul.{0, u3} Nat G (AddMonoid.SMul.{u3} G _inst_3)) n a)) (HSMul.hSMul.{0, u2, u2} Nat ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (instHSMul.{0, u2} Nat ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (AddMonoid.SMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4)) n (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (AddHomClass.toFunLike.{u1, u3, u2} F G H (AddZeroClass.toAdd.{u3} G (AddMonoid.toAddZeroClass.{u3} G _inst_3)) (AddZeroClass.toAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H _inst_4)) (AddMonoidHomClass.toAddHomClass.{u1, u3, u2} F G H (AddMonoid.toAddZeroClass.{u3} G _inst_3) (AddMonoid.toAddZeroClass.{u2} H _inst_4) _inst_5)) f a))\nCase conversion may be inaccurate. Consider using '#align map_nsmul map_nsmulₓ'. -/\n@[simp]\ntheorem map_nsmul [AddMonoid G] [AddMonoid H] [AddMonoidHomClass F G H] (f : F) (n : ℕ) (a : G) :\n    f (n • a) = n • f a :=\n  map_nsmul.aux f a n\n#align map_nsmul map_nsmul\n\nattribute [to_additive_reorder 8, to_additive] map_pow\n\n/- warning: map_zpow' -> map_zpow' is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : DivInvMonoid.{u1} G] [_inst_4 : DivInvMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))] (f : F), (forall (x : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G _inst_3) x)) (Inv.inv.{u2} H (DivInvMonoid.toHasInv.{u2} H _inst_4) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f x))) -> (forall (a : G) (n : Int), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G _inst_3)) a n)) (HPow.hPow.{u2, 0, u2} H Int H (instHPow.{u2, 0} H Int (DivInvMonoid.Pow.{u2} H _inst_4)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5))) f a) n))\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : DivInvMonoid.{u3} G] [_inst_4 : DivInvMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))] (f : F), (forall (x : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (Inv.inv.{u3} G (DivInvMonoid.toInv.{u3} G _inst_3) x)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f (Inv.inv.{u3} G (DivInvMonoid.toInv.{u3} G _inst_3) x)) (Inv.inv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) x) (DivInvMonoid.toInv.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) x) _inst_4) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f x))) -> (forall (a : G) (n : Int), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HPow.hPow.{u3, 0, u3} G Int G (instHPow.{u3, 0} G Int (DivInvMonoid.Pow.{u3} G _inst_3)) a n)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f (HPow.hPow.{u3, 0, u3} G Int G (instHPow.{u3, 0} G Int (DivInvMonoid.Pow.{u3} G _inst_3)) a n)) (HPow.hPow.{u2, 0, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) Int ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (instHPow.{u2, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) Int (DivInvMonoid.Pow.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G _inst_3)) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H _inst_4)) _inst_5)) f a) n))\nCase conversion may be inaccurate. Consider using '#align map_zpow' map_zpow'ₓ'. -/\n@[to_additive]\ntheorem map_zpow' [DivInvMonoid G] [DivInvMonoid H] [MonoidHomClass F G H] (f : F)\n    (hf : ∀ x : G, f x⁻¹ = (f x)⁻¹) (a : G) : ∀ n : ℤ, f (a ^ n) = f a ^ n\n  | (n : ℕ) => by rw [zpow_ofNat, map_pow, zpow_ofNat]\n  | -[n+1] => by rw [zpow_negSucc, hf, map_pow, ← zpow_negSucc]\n#align map_zpow' map_zpow'\n#align map_zsmul' map_zsmul'\n\n/- warning: map_zpow -> map_zpow is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : Group.{u1} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (g : G) (n : Int), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) g n)) (HPow.hPow.{u2, 0, u2} H Int H (instHPow.{u2, 0} H Int (DivInvMonoid.Pow.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u3, u1, u2} F G H (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5))) f g) n)\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : Group.{u3} G] [_inst_4 : DivisionMonoid.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))] (f : F) (g : G) (n : Int), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HPow.hPow.{u3, 0, u3} G Int G (instHPow.{u3, 0} G Int (DivInvMonoid.Pow.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) g n)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f (HPow.hPow.{u3, 0, u3} G Int G (instHPow.{u3, 0} G Int (DivInvMonoid.Pow.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) g n)) (HPow.hPow.{u2, 0, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) Int ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) (instHPow.{u2, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) Int (DivInvMonoid.Pow.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) (DivisionMonoid.toDivInvMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) _inst_4))) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (DivisionMonoid.toDivInvMonoid.{u2} H _inst_4))) _inst_5)) f g) n)\nCase conversion may be inaccurate. Consider using '#align map_zpow map_zpowₓ'. -/\n-- to_additive puts the arguments in the wrong order, so generate an auxiliary lemma, then\n-- swap its arguments.\n/-- Group homomorphisms preserve integer power. -/\n@[to_additive map_zsmul.aux, simp]\ntheorem map_zpow [Group G] [DivisionMonoid H] [MonoidHomClass F G H] (f : F) (g : G) (n : ℤ) :\n    f (g ^ n) = f g ^ n :=\n  map_zpow' f (map_inv f) g n\n#align map_zpow map_zpow\n#align map_zsmul map_zsmul\n\n/- warning: map_zsmul -> map_zsmul is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {H : Type.{u2}} {F : Type.{u3}} [_inst_3 : AddGroup.{u1} G] [_inst_4 : SubtractionMonoid.{u2} H] [_inst_5 : AddMonoidHomClass.{u3, u1, u2} F G H (AddMonoid.toAddZeroClass.{u1} G (SubNegMonoid.toAddMonoid.{u1} G (AddGroup.toSubNegMonoid.{u1} G _inst_3))) (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4)))] (f : F) (n : Int) (g : G), Eq.{succ u2} H (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (AddHomClass.toFunLike.{u3, u1, u2} F G H (AddZeroClass.toHasAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (SubNegMonoid.toAddMonoid.{u1} G (AddGroup.toSubNegMonoid.{u1} G _inst_3)))) (AddZeroClass.toHasAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4)))) (AddMonoidHomClass.toAddHomClass.{u3, u1, u2} F G H (AddMonoid.toAddZeroClass.{u1} G (SubNegMonoid.toAddMonoid.{u1} G (AddGroup.toSubNegMonoid.{u1} G _inst_3))) (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4))) _inst_5))) f (SMul.smul.{0, u1} Int G (SubNegMonoid.SMulInt.{u1} G (AddGroup.toSubNegMonoid.{u1} G _inst_3)) n g)) (SMul.smul.{0, u2} Int H (SubNegMonoid.SMulInt.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4)) n (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F G (fun (_x : G) => H) (AddHomClass.toFunLike.{u3, u1, u2} F G H (AddZeroClass.toHasAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (SubNegMonoid.toAddMonoid.{u1} G (AddGroup.toSubNegMonoid.{u1} G _inst_3)))) (AddZeroClass.toHasAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4)))) (AddMonoidHomClass.toAddHomClass.{u3, u1, u2} F G H (AddMonoid.toAddZeroClass.{u1} G (SubNegMonoid.toAddMonoid.{u1} G (AddGroup.toSubNegMonoid.{u1} G _inst_3))) (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4))) _inst_5))) f g))\nbut is expected to have type\n  forall {G : Type.{u3}} {H : Type.{u2}} {F : Type.{u1}} [_inst_3 : AddGroup.{u3} G] [_inst_4 : SubtractionMonoid.{u2} H] [_inst_5 : AddMonoidHomClass.{u1, u3, u2} F G H (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G _inst_3))) (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4)))] (f : F) (n : Int) (g : G), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) (HSMul.hSMul.{0, u3, u3} Int G G (instHSMul.{0, u3} Int G (SubNegMonoid.SMulInt.{u3} G (AddGroup.toSubNegMonoid.{u3} G _inst_3))) n g)) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (AddHomClass.toFunLike.{u1, u3, u2} F G H (AddZeroClass.toAdd.{u3} G (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G _inst_3)))) (AddZeroClass.toAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4)))) (AddMonoidHomClass.toAddHomClass.{u1, u3, u2} F G H (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G _inst_3))) (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4))) _inst_5)) f (HSMul.hSMul.{0, u3, u3} Int G G (instHSMul.{0, u3} Int G (SubNegMonoid.SMulInt.{u3} G (AddGroup.toSubNegMonoid.{u3} G _inst_3))) n g)) (HSMul.hSMul.{0, u2, u2} Int ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) (instHSMul.{0, u2} Int ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) (SubNegMonoid.SMulInt.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) (SubtractionMonoid.toSubNegMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) g) _inst_4))) n (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (AddHomClass.toFunLike.{u1, u3, u2} F G H (AddZeroClass.toAdd.{u3} G (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G _inst_3)))) (AddZeroClass.toAdd.{u2} H (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4)))) (AddMonoidHomClass.toAddHomClass.{u1, u3, u2} F G H (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G _inst_3))) (AddMonoid.toAddZeroClass.{u2} H (SubNegMonoid.toAddMonoid.{u2} H (SubtractionMonoid.toSubNegMonoid.{u2} H _inst_4))) _inst_5)) f g))\nCase conversion may be inaccurate. Consider using '#align map_zsmul map_zsmulₓ'. -/\n/-- Additive group homomorphisms preserve integer scaling. -/\ntheorem map_zsmul [AddGroup G] [SubtractionMonoid H] [AddMonoidHomClass F G H] (f : F) (n : ℤ)\n    (g : G) : f (n • g) = n • f g :=\n  map_zsmul.aux f g n\n#align map_zsmul map_zsmul\n\nattribute [to_additive_reorder 8, to_additive] map_zpow\n\nend mul_one\n\nsection MulZeroOne\n\nvariable [MulZeroOneClass M] [MulZeroOneClass N]\n\n#print MonoidWithZeroHom /-\n/-- `M →*₀ N` is the type of functions `M → N` that preserve\nthe `monoid_with_zero` structure.\n\n`monoid_with_zero_hom` is also used for group homomorphisms.\n\nWhen possible, instead of parametrizing results over `(f : M →*₀ N)`,\nyou should parametrize over `(F : Type*) [monoid_with_zero_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `monoid_with_zero_hom_class`.\n-/\nstructure MonoidWithZeroHom (M : Type _) (N : Type _) [MulZeroOneClass M]\n  [MulZeroOneClass N] extends ZeroHom M N, MonoidHom M N\n#align monoid_with_zero_hom MonoidWithZeroHom\n-/\n\nattribute [nolint doc_blame] MonoidWithZeroHom.toMonoidHom\n\nattribute [nolint doc_blame] MonoidWithZeroHom.toZeroHom\n\n-- mathport name: «expr →*₀ »\ninfixr:25 \" →*₀ \" => MonoidWithZeroHom\n\n#print MonoidWithZeroHomClass /-\n/-- `monoid_with_zero_hom_class F M N` states that `F` is a type of\n`monoid_with_zero`-preserving homomorphisms.\n\nYou should also extend this typeclass when you extend `monoid_with_zero_hom`.\n-/\nclass MonoidWithZeroHomClass (F : Type _) (M N : outParam <| Type _) [MulZeroOneClass M]\n  [MulZeroOneClass N] extends MonoidHomClass F M N, ZeroHomClass F M N\n#align monoid_with_zero_hom_class MonoidWithZeroHomClass\n-/\n\n#print MonoidWithZeroHom.monoidWithZeroHomClass /-\ninstance MonoidWithZeroHom.monoidWithZeroHomClass : MonoidWithZeroHomClass (M →*₀ N) M N\n    where\n  coe := MonoidWithZeroHom.toFun\n  coe_injective' f g h := by cases f <;> cases g <;> congr\n  map_mul := MonoidWithZeroHom.map_mul'\n  map_one := MonoidWithZeroHom.map_one'\n  map_zero := MonoidWithZeroHom.map_zero'\n#align monoid_with_zero_hom.monoid_with_zero_hom_class MonoidWithZeroHom.monoidWithZeroHomClass\n-/\n\ninstance [MonoidWithZeroHomClass F M N] : CoeTC F (M →*₀ N) :=\n  ⟨fun f =>\n    { toFun := f\n      map_one' := map_one f\n      map_zero' := map_zero f\n      map_mul' := map_mul f }⟩\n\n/- warning: monoid_with_zero_hom.coe_coe -> MonoidWithZeroHom.coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MonoidWithZeroHomClass.{u3, u1, u2} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (MonoidWithZeroHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (FunLike.hasCoeToFun.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => N) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) M N (MulOneClass.toHasMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M _inst_1)) (MulOneClass.toHasMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u1} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u1, u2} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u2} M N _inst_1 _inst_2))))) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) F (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} F (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} F (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (MonoidWithZeroHom.hasCoeT.{u1, u2, u3} M N F _inst_1 _inst_2 _inst_3))) f)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N (MulOneClass.toHasMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M _inst_1)) (MulOneClass.toHasMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F M N (MulZeroOneClass.toMulOneClass.{u1} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{u3, u1, u2} F M N _inst_1 _inst_2 _inst_3)))) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {F : Type.{u3}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] [_inst_3 : MonoidWithZeroHomClass.{u3, u2, u1} F M N _inst_1 _inst_2] (f : F), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) (MonoidWithZeroHomClass.toMonoidWithZeroHom.{u2, u1, u3} M N F _inst_1 _inst_2 _inst_3 f)) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{u3, u2, u1} F M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.coe_coe MonoidWithZeroHom.coe_coeₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_coe [MonoidWithZeroHomClass F M N] (f : F) :\n    ((f : M →*₀ N) : M → N) = f :=\n  rfl\n#align monoid_with_zero_hom.coe_coe MonoidWithZeroHom.coe_coe\n\nend MulZeroOne\n\n-- completely uninteresting lemmas about coercion to function, that all homs need\nsection Coes\n\n/-! Bundled morphisms can be down-cast to weaker bundlings -/\n\n\n/- warning: monoid_hom.has_coe_to_one_hom -> MonoidHom.coeToOneHom is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : MulOneClass.{u1} M} {mN : MulOneClass.{u2} N}, Coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N mM mN) (OneHom.{u1, u2} M N (MulOneClass.toHasOne.{u1} M mM) (MulOneClass.toHasOne.{u2} N mN))\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : MulOneClass.{u1} M} {mN : MulOneClass.{u2} N}, Coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N mM mN) (OneHom.{u1, u2} M N (MulOneClass.toOne.{u1} M mM) (MulOneClass.toOne.{u2} N mN))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.has_coe_to_one_hom MonoidHom.coeToOneHomₓ'. -/\n@[to_additive]\ninstance MonoidHom.coeToOneHom {mM : MulOneClass M} {mN : MulOneClass N} :\n    Coe (M →* N) (OneHom M N) :=\n  ⟨MonoidHom.toOneHom⟩\n#align monoid_hom.has_coe_to_one_hom MonoidHom.coeToOneHom\n#align add_monoid_hom.has_coe_to_zero_hom AddMonoidHom.coeToZeroHom\n\n/- warning: monoid_hom.has_coe_to_mul_hom -> MonoidHom.coeToMulHom is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : MulOneClass.{u1} M} {mN : MulOneClass.{u2} N}, Coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N mM mN) (MulHom.{u1, u2} M N (MulOneClass.toHasMul.{u1} M mM) (MulOneClass.toHasMul.{u2} N mN))\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : MulOneClass.{u1} M} {mN : MulOneClass.{u2} N}, Coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N mM mN) (MulHom.{u1, u2} M N (MulOneClass.toMul.{u1} M mM) (MulOneClass.toMul.{u2} N mN))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.has_coe_to_mul_hom MonoidHom.coeToMulHomₓ'. -/\n@[to_additive]\ninstance MonoidHom.coeToMulHom {mM : MulOneClass M} {mN : MulOneClass N} : Coe (M →* N) (M →ₙ* N) :=\n  ⟨MonoidHom.toMulHom⟩\n#align monoid_hom.has_coe_to_mul_hom MonoidHom.coeToMulHom\n#align add_monoid_hom.has_coe_to_add_hom AddMonoidHom.coeToAddHom\n\n#print MonoidWithZeroHom.coeToMonoidHom /-\ninstance MonoidWithZeroHom.coeToMonoidHom {mM : MulZeroOneClass M} {mN : MulZeroOneClass N} :\n    Coe (M →*₀ N) (M →* N) :=\n  ⟨MonoidWithZeroHom.toMonoidHom⟩\n#align monoid_with_zero_hom.has_coe_to_monoid_hom MonoidWithZeroHom.coeToMonoidHom\n-/\n\n/- warning: monoid_with_zero_hom.has_coe_to_zero_hom -> MonoidWithZeroHom.coeToZeroHom is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : MulZeroOneClass.{u1} M} {mN : MulZeroOneClass.{u2} N}, Coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N mM mN) (ZeroHom.{u1, u2} M N (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M mM)) (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N mN)))\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : MulZeroOneClass.{u1} M} {mN : MulZeroOneClass.{u2} N}, Coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N mM mN) (ZeroHom.{u1, u2} M N (MulZeroOneClass.toZero.{u1} M mM) (MulZeroOneClass.toZero.{u2} N mN))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.has_coe_to_zero_hom MonoidWithZeroHom.coeToZeroHomₓ'. -/\ninstance MonoidWithZeroHom.coeToZeroHom {mM : MulZeroOneClass M} {mN : MulZeroOneClass N} :\n    Coe (M →*₀ N) (ZeroHom M N) :=\n  ⟨MonoidWithZeroHom.toZeroHom⟩\n#align monoid_with_zero_hom.has_coe_to_zero_hom MonoidWithZeroHom.coeToZeroHom\n\n/-! The simp-normal form of morphism coercion is `f.to_..._hom`. This choice is primarily because\nthis is the way things were before the above coercions were introduced. Bundled morphisms defined\nelsewhere in Mathlib may choose `↑f` as their simp-normal form instead. -/\n\n\n@[simp, to_additive]\ntheorem MonoidHom.coe_eq_toOneHom {mM : MulOneClass M} {mN : MulOneClass N} (f : M →* N) :\n    (f : OneHom M N) = f.toOneHom :=\n  rfl\n#align monoid_hom.coe_eq_to_one_hom MonoidHom.coe_eq_toOneHom\n#align add_monoid_hom.coe_eq_to_zero_hom AddMonoidHom.coe_eq_to_zero_hom\n\n@[simp, to_additive]\ntheorem MonoidHom.coe_eq_toMulHom {mM : MulOneClass M} {mN : MulOneClass N} (f : M →* N) :\n    (f : M →ₙ* N) = f.toMulHom :=\n  rfl\n#align monoid_hom.coe_eq_to_mul_hom MonoidHom.coe_eq_toMulHom\n#align add_monoid_hom.coe_eq_to_add_hom AddMonoidHom.coe_eq_to_add_hom\n\n@[simp]\ntheorem MonoidWithZeroHom.coe_eq_toMonoidHom {mM : MulZeroOneClass M} {mN : MulZeroOneClass N}\n    (f : M →*₀ N) : (f : M →* N) = f.toMonoidHom :=\n  rfl\n#align monoid_with_zero_hom.coe_eq_to_monoid_hom MonoidWithZeroHom.coe_eq_toMonoidHom\n\n@[simp]\ntheorem MonoidWithZeroHom.coe_eq_toZeroHom {mM : MulZeroOneClass M} {mN : MulZeroOneClass N}\n    (f : M →*₀ N) : (f : ZeroHom M N) = f.toZeroHom :=\n  rfl\n#align monoid_with_zero_hom.coe_eq_to_zero_hom MonoidWithZeroHom.coe_eq_toZeroHom\n\n-- Fallback `has_coe_to_fun` instances to help the elaborator\n@[to_additive]\ninstance {mM : One M} {mN : One N} : CoeFun (OneHom M N) fun _ => M → N :=\n  ⟨OneHom.toFun⟩\n\n@[to_additive]\ninstance {mM : Mul M} {mN : Mul N} : CoeFun (M →ₙ* N) fun _ => M → N :=\n  ⟨MulHom.toFun⟩\n\n@[to_additive]\ninstance {mM : MulOneClass M} {mN : MulOneClass N} : CoeFun (M →* N) fun _ => M → N :=\n  ⟨MonoidHom.toFun⟩\n\ninstance {mM : MulZeroOneClass M} {mN : MulZeroOneClass N} : CoeFun (M →*₀ N) fun _ => M → N :=\n  ⟨MonoidWithZeroHom.toFun⟩\n\n-- these must come after the coe_to_fun definitions\ninitialize_simps_projections ZeroHom (toFun → apply)\n\ninitialize_simps_projections AddHom (toFun → apply)\n\ninitialize_simps_projections AddMonoidHom (toFun → apply)\n\ninitialize_simps_projections OneHom (toFun → apply)\n\ninitialize_simps_projections MulHom (toFun → apply)\n\ninitialize_simps_projections MonoidHom (toFun → apply)\n\ninitialize_simps_projections MonoidWithZeroHom (toFun → apply)\n\n/- warning: one_hom.to_fun_eq_coe -> OneHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (f : OneHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (M -> N) (OneHom.toFun.{u1, u2} M N _inst_1 _inst_2 f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (f : OneHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (M -> N) (OneHom.toFun.{u2, u1} M N _inst_1 _inst_2 f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f)\nCase conversion may be inaccurate. Consider using '#align one_hom.to_fun_eq_coe OneHom.toFun_eq_coeₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.toFun_eq_coe [One M] [One N] (f : OneHom M N) : f.toFun = f :=\n  rfl\n#align one_hom.to_fun_eq_coe OneHom.toFun_eq_coe\n#align zero_hom.to_fun_eq_coe ZeroHom.toFun_eq_coe\n\n/- warning: mul_hom.to_fun_eq_coe -> MulHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] (f : MulHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (M -> N) (MulHom.toFun.{u1, u2} M N _inst_1 _inst_2 f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] (f : MulHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (M -> N) (MulHom.toFun.{u2, u1} M N _inst_1 _inst_2 f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f)\nCase conversion may be inaccurate. Consider using '#align mul_hom.to_fun_eq_coe MulHom.toFun_eq_coeₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.toFun_eq_coe [Mul M] [Mul N] (f : M →ₙ* N) : f.toFun = f :=\n  rfl\n#align mul_hom.to_fun_eq_coe MulHom.toFun_eq_coe\n#align add_hom.to_fun_eq_coe AddHom.toFun_eq_coe\n\n/- warning: monoid_hom.to_fun_eq_coe -> MonoidHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (M -> N) (MonoidHom.toFun.{u1, u2} M N _inst_1 _inst_2 f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (M -> N) (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (MonoidHom.toOneHom.{u2, u1} M N _inst_1 _inst_2 f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.to_fun_eq_coe MonoidHom.toFun_eq_coeₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.toFun_eq_coe [MulOneClass M] [MulOneClass N] (f : M →* N) : f.toFun = f :=\n  rfl\n#align monoid_hom.to_fun_eq_coe MonoidHom.toFun_eq_coe\n#align add_monoid_hom.to_fun_eq_coe AddMonoidHom.toFun_eq_coe\n\n@[simp]\ntheorem MonoidWithZeroHom.toFun_eq_coe [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) :\n    f.toFun = f :=\n  rfl\n#align monoid_with_zero_hom.to_fun_eq_coe MonoidWithZeroHom.toFun_eq_coe\n\n/- warning: one_hom.coe_mk -> OneHom.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (f : M -> N) (h1 : Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M _inst_1)))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N _inst_2)))), Eq.{max (succ u1) (succ u2)} ((fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.mk.{u1, u2} M N _inst_1 _inst_2 f h1)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) (OneHom.mk.{u1, u2} M N _inst_1 _inst_2 f h1)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (f : M -> N) (h1 : Eq.{succ u1} N (f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N _inst_2))), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) (OneHom.mk.{u2, u1} M N _inst_1 _inst_2 f h1)) f\nCase conversion may be inaccurate. Consider using '#align one_hom.coe_mk OneHom.coe_mkₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_mk [One M] [One N] (f : M → N) (h1) : (OneHom.mk f h1 : M → N) = f :=\n  rfl\n#align one_hom.coe_mk OneHom.coe_mk\n#align zero_hom.coe_mk ZeroHom.coe_mk\n\n/- warning: mul_hom.coe_mk -> MulHom.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] (f : M -> N) (hmul : forall (x : M) (y : M), Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M _inst_1) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N _inst_2) (f x) (f y))), Eq.{max (succ u1) (succ u2)} ((fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.mk.{u1, u2} M N _inst_1 _inst_2 f hmul)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) (MulHom.mk.{u1, u2} M N _inst_1 _inst_2 f hmul)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] (f : M -> N) (hmul : forall (x : M) (y : M), Eq.{succ u1} N (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M _inst_1) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N _inst_2) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) (MulHom.mk.{u2, u1} M N _inst_1 _inst_2 f hmul)) f\nCase conversion may be inaccurate. Consider using '#align mul_hom.coe_mk MulHom.coe_mkₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_mk [Mul M] [Mul N] (f : M → N) (hmul) : (MulHom.mk f hmul : M → N) = f :=\n  rfl\n#align mul_hom.coe_mk MulHom.coe_mk\n#align add_hom.coe_mk AddHom.coe_mk\n\n/- warning: monoid_hom.coe_mk -> MonoidHom.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : M -> N) (h1 : Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N _inst_2))))) (hmul : forall (x : M) (y : M), Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N _inst_2)) (f x) (f y))), Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.mk.{u1, u2} M N _inst_1 _inst_2 f h1 hmul)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.mk.{u1, u2} M N _inst_1 _inst_2 f h1 hmul)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : OneHom.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2)) (h1 : forall (x : M) (y : M), Eq.{succ u1} N (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M _inst_1)) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N (MulOneClass.toMul.{u1} N _inst_2)) (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) f x) (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) f y))), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (a : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (MulHomClass.toFunLike.{max u1 u2, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u1 u2, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) (MonoidHom.mk.{u2, u1} M N _inst_1 _inst_2 f h1)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2)) M (fun (a : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) a) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2)) M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (OneHom.oneHomClass.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_mk MonoidHom.coe_mkₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_mk [MulOneClass M] [MulOneClass N] (f : M → N) (h1 hmul) :\n    (MonoidHom.mk f h1 hmul : M → N) = f :=\n  rfl\n#align monoid_hom.coe_mk MonoidHom.coe_mk\n#align add_monoid_hom.coe_mk AddMonoidHom.coe_mk\n\n/- warning: monoid_with_zero_hom.coe_mk -> MonoidWithZeroHom.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : M -> N) (h0 : Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 0 (OfNat.mk.{u2} N 0 (Zero.zero.{u2} N (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2)))))) (h1 : Eq.{succ u2} N (f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)))))) (hmul : forall (x : M) (y : M), Eq.{succ u2} N (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M _inst_1))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2))) (f x) (f y))), Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.mk.{u1, u2} M N _inst_1 _inst_2 f h0 h1 hmul)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) (MonoidWithZeroHom.mk.{u1, u2} M N _inst_1 _inst_2 f h0 h1 hmul)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : ZeroHom.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2)) (h0 : Eq.{succ u1} N (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (MulOneClass.toOne.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2))))) (h1 : forall (x : M) (y : M), Eq.{succ u1} N (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2))) (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) f x) (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) f y))), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (a : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (MulHomClass.toFunLike.{max u1 u2, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u1 u2, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u1 u2, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) (MonoidWithZeroHom.mk.{u2, u1} M N _inst_1 _inst_2 f h0 h1)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (ZeroHom.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2)) M (fun (a : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : M) => N) a) (ZeroHomClass.toFunLike.{max u2 u1, u2, u1} (ZeroHom.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2)) M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (ZeroHom.zeroHomClass.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.coe_mk MonoidWithZeroHom.coe_mkₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_mk [MulZeroOneClass M] [MulZeroOneClass N] (f : M → N) (h0 h1 hmul) :\n    (MonoidWithZeroHom.mk f h0 h1 hmul : M → N) = f :=\n  rfl\n#align monoid_with_zero_hom.coe_mk MonoidWithZeroHom.coe_mk\n\n/- warning: monoid_hom.to_one_hom_coe -> MonoidHom.toOneHom_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} ((fun (_x : OneHom.{u1, u2} M N (MulOneClass.toHasOne.{u1} M _inst_1) (MulOneClass.toHasOne.{u2} N _inst_2)) => M -> N) (MonoidHom.toOneHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N (MulOneClass.toHasOne.{u1} M _inst_1) (MulOneClass.toHasOne.{u2} N _inst_2)) (fun (_x : OneHom.{u1, u2} M N (MulOneClass.toHasOne.{u1} M _inst_1) (MulOneClass.toHasOne.{u2} N _inst_2)) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N (MulOneClass.toHasOne.{u1} M _inst_1) (MulOneClass.toHasOne.{u2} N _inst_2)) (MonoidHom.toOneHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2)) M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (OneHom.oneHomClass.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2))) (MonoidHom.toOneHom.{u2, u1} M N _inst_1 _inst_2 f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.to_one_hom_coe MonoidHom.toOneHom_coeₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.toOneHom_coe [MulOneClass M] [MulOneClass N] (f : M →* N) :\n    (f.toOneHom : M → N) = f :=\n  rfl\n#align monoid_hom.to_one_hom_coe MonoidHom.toOneHom_coe\n#align add_monoid_hom.to_zero_hom_coe AddMonoidHom.toZeroHom_coe\n\n/- warning: monoid_hom.to_mul_hom_coe -> MonoidHom.toMulHom_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} ((fun (_x : MulHom.{u1, u2} M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2)) => M -> N) (MonoidHom.toMulHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2)) (fun (_x : MulHom.{u1, u2} M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2)) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2)) (MonoidHom.toMulHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (M -> N) (MulHom.toFun.{u2, u1} M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHom.toMulHom.{u2, u1} M N _inst_1 _inst_2 f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.to_mul_hom_coe MonoidHom.toMulHom_coeₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.toMulHom_coe [MulOneClass M] [MulOneClass N] (f : M →* N) :\n    (f.toMulHom : M → N) = f :=\n  rfl\n#align monoid_hom.to_mul_hom_coe MonoidHom.toMulHom_coe\n#align add_monoid_hom.to_add_hom_coe AddMonoidHom.toAddHom_coe\n\n/- warning: monoid_with_zero_hom.to_zero_hom_coe -> MonoidWithZeroHom.toZeroHom_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} ((fun (_x : ZeroHom.{u1, u2} M N (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)) (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2))) => M -> N) (MonoidWithZeroHom.toZeroHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (ZeroHom.{u1, u2} M N (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)) (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2))) (fun (_x : ZeroHom.{u1, u2} M N (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)) (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2))) => M -> N) (ZeroHom.hasCoeToFun.{u1, u2} M N (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)) (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2))) (MonoidWithZeroHom.toZeroHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (ZeroHom.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.124 : M) => N) _x) (ZeroHomClass.toFunLike.{max u2 u1, u2, u1} (ZeroHom.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2)) M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (ZeroHom.zeroHomClass.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2))) (MonoidWithZeroHom.toZeroHom.{u2, u1} M N _inst_1 _inst_2 f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.to_zero_hom_coe MonoidWithZeroHom.toZeroHom_coeₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.toZeroHom_coe [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) :\n    (f.toZeroHom : M → N) = f :=\n  rfl\n#align monoid_with_zero_hom.to_zero_hom_coe MonoidWithZeroHom.toZeroHom_coe\n\n/- warning: monoid_with_zero_hom.to_monoid_hom_coe -> MonoidWithZeroHom.toMonoidHom_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) => M -> N) (MonoidWithZeroHom.toMonoidHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (fun (_x : MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MonoidWithZeroHom.toMonoidHom.{u1, u2} M N _inst_1 _inst_2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (M -> N) (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toOne.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHom.toOneHom.{u2, u1} M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHom.toMonoidHom.{u2, u1} M N _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.to_monoid_hom_coe MonoidWithZeroHom.toMonoidHom_coeₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.toMonoidHom_coe [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) :\n    (f.toMonoidHom : M → N) = f :=\n  rfl\n#align monoid_with_zero_hom.to_monoid_hom_coe MonoidWithZeroHom.toMonoidHom_coe\n\n/- warning: one_hom.ext -> OneHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] {{f : OneHom.{u1, u2} M N _inst_1 _inst_2}} {{g : OneHom.{u1, u2} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x)) -> (Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] {{f : OneHom.{u2, u1} M N _inst_1 _inst_2}} {{g : OneHom.{u2, u1} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) g x)) -> (Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align one_hom.ext OneHom.extₓ'. -/\n@[ext, to_additive]\ntheorem OneHom.ext [One M] [One N] ⦃f g : OneHom M N⦄ (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext _ _ h\n#align one_hom.ext OneHom.ext\n#align zero_hom.ext ZeroHom.ext\n\n/- warning: mul_hom.ext -> MulHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] {{f : MulHom.{u1, u2} M N _inst_1 _inst_2}} {{g : MulHom.{u1, u2} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x)) -> (Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] {{f : MulHom.{u2, u1} M N _inst_1 _inst_2}} {{g : MulHom.{u2, u1} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) g x)) -> (Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align mul_hom.ext MulHom.extₓ'. -/\n@[ext, to_additive]\ntheorem MulHom.ext [Mul M] [Mul N] ⦃f g : M →ₙ* N⦄ (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext _ _ h\n#align mul_hom.ext MulHom.ext\n#align add_hom.ext AddHom.ext\n\n/- warning: monoid_hom.ext -> MonoidHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] {{f : MonoidHom.{u1, u2} M N _inst_1 _inst_2}} {{g : MonoidHom.{u1, u2} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x)) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] {{f : MonoidHom.{u2, u1} M N _inst_1 _inst_2}} {{g : MonoidHom.{u2, u1} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) g x)) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.ext MonoidHom.extₓ'. -/\n@[ext, to_additive]\ntheorem MonoidHom.ext [MulOneClass M] [MulOneClass N] ⦃f g : M →* N⦄ (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext _ _ h\n#align monoid_hom.ext MonoidHom.ext\n#align add_monoid_hom.ext AddMonoidHom.ext\n\n/- warning: monoid_with_zero_hom.ext -> MonoidWithZeroHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] {{f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}} {{g : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x)) -> (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] {{f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2}} {{g : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2}}, (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) g x)) -> (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.ext MonoidWithZeroHom.extₓ'. -/\n@[ext]\ntheorem MonoidWithZeroHom.ext [MulZeroOneClass M] [MulZeroOneClass N] ⦃f g : M →*₀ N⦄\n    (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext _ _ h\n#align monoid_with_zero_hom.ext MonoidWithZeroHom.ext\n\nsection Deprecated\n\n/- warning: one_hom.congr_fun -> OneHom.congr_fun is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] {f : OneHom.{u1, u2} M N _inst_1 _inst_2} {g : OneHom.{u1, u2} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] {f : OneHom.{u2, u1} M N _inst_1 _inst_2} {g : OneHom.{u2, u1} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) g x))\nCase conversion may be inaccurate. Consider using '#align one_hom.congr_fun OneHom.congr_funₓ'. -/\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_fun` instead.\"]\ntheorem OneHom.congr_fun [One M] [One N] {f g : OneHom M N} (h : f = g) (x : M) : f x = g x :=\n  FunLike.congr_fun h x\n#align one_hom.congr_fun OneHom.congr_fun\n#align zero_hom.congr_fun ZeroHom.congr_fun\n\n/- warning: mul_hom.congr_fun -> MulHom.congr_fun is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] {f : MulHom.{u1, u2} M N _inst_1 _inst_2} {g : MulHom.{u1, u2} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] {f : MulHom.{u2, u1} M N _inst_1 _inst_2} {g : MulHom.{u2, u1} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) g x))\nCase conversion may be inaccurate. Consider using '#align mul_hom.congr_fun MulHom.congr_funₓ'. -/\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_fun` instead.\"]\ntheorem MulHom.congr_fun [Mul M] [Mul N] {f g : M →ₙ* N} (h : f = g) (x : M) : f x = g x :=\n  FunLike.congr_fun h x\n#align mul_hom.congr_fun MulHom.congr_fun\n#align add_hom.congr_fun AddHom.congr_fun\n\n/- warning: monoid_hom.congr_fun -> MonoidHom.congr_fun is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] {f : MonoidHom.{u1, u2} M N _inst_1 _inst_2} {g : MonoidHom.{u1, u2} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] {f : MonoidHom.{u2, u1} M N _inst_1 _inst_2} {g : MonoidHom.{u2, u1} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) g x))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.congr_fun MonoidHom.congr_funₓ'. -/\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_fun` instead.\"]\ntheorem MonoidHom.congr_fun [MulOneClass M] [MulOneClass N] {f g : M →* N} (h : f = g) (x : M) :\n    f x = g x :=\n  FunLike.congr_fun h x\n#align monoid_hom.congr_fun MonoidHom.congr_fun\n#align add_monoid_hom.congr_fun AddMonoidHom.congr_fun\n\n/- warning: monoid_with_zero_hom.congr_fun -> MonoidWithZeroHom.congr_fun is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] {f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2} {g : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] {f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2} {g : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2}, (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) f g) -> (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) g x))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.congr_fun MonoidWithZeroHom.congr_funₓ'. -/\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\ntheorem MonoidWithZeroHom.congr_fun [MulZeroOneClass M] [MulZeroOneClass N] {f g : M →*₀ N}\n    (h : f = g) (x : M) : f x = g x :=\n  FunLike.congr_fun h x\n#align monoid_with_zero_hom.congr_fun MonoidWithZeroHom.congr_fun\n\n/- warning: one_hom.congr_arg -> OneHom.congr_arg is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (f : OneHom.{u1, u2} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u1} M x y) -> (Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (f : OneHom.{u2, u1} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u2} M x y) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f y))\nCase conversion may be inaccurate. Consider using '#align one_hom.congr_arg OneHom.congr_argₓ'. -/\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_arg` instead.\"]\ntheorem OneHom.congr_arg [One M] [One N] (f : OneHom M N) {x y : M} (h : x = y) : f x = f y :=\n  FunLike.congr_arg f h\n#align one_hom.congr_arg OneHom.congr_arg\n#align zero_hom.congr_arg ZeroHom.congr_arg\n\n/- warning: mul_hom.congr_arg -> MulHom.congr_arg is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] (f : MulHom.{u1, u2} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u1} M x y) -> (Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] (f : MulHom.{u2, u1} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u2} M x y) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f y))\nCase conversion may be inaccurate. Consider using '#align mul_hom.congr_arg MulHom.congr_argₓ'. -/\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_arg` instead.\"]\ntheorem MulHom.congr_arg [Mul M] [Mul N] (f : M →ₙ* N) {x y : M} (h : x = y) : f x = f y :=\n  FunLike.congr_arg f h\n#align mul_hom.congr_arg MulHom.congr_arg\n#align add_hom.congr_arg AddHom.congr_arg\n\n/- warning: monoid_hom.congr_arg -> MonoidHom.congr_arg is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u1} M x y) -> (Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u2} M x y) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f y))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.congr_arg MonoidHom.congr_argₓ'. -/\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_arg` instead.\"]\ntheorem MonoidHom.congr_arg [MulOneClass M] [MulOneClass N] (f : M →* N) {x y : M} (h : x = y) :\n    f x = f y :=\n  FunLike.congr_arg f h\n#align monoid_hom.congr_arg MonoidHom.congr_arg\n#align add_monoid_hom.congr_arg AddMonoidHom.congr_arg\n\n/- warning: monoid_with_zero_hom.congr_arg -> MonoidWithZeroHom.congr_arg is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u1} M x y) -> (Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) {x : M} {y : M}, (Eq.{succ u2} M x y) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f y))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.congr_arg MonoidWithZeroHom.congr_argₓ'. -/\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\ntheorem MonoidWithZeroHom.congr_arg [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) {x y : M}\n    (h : x = y) : f x = f y :=\n  FunLike.congr_arg f h\n#align monoid_with_zero_hom.congr_arg MonoidWithZeroHom.congr_arg\n\n/- warning: one_hom.coe_inj -> OneHom.coe_inj is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] {{f : OneHom.{u1, u2} M N _inst_1 _inst_2}} {{g : OneHom.{u1, u2} M N _inst_1 _inst_2}}, (Eq.{max (succ u1) (succ u2)} ((fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g)) -> (Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] {{f : OneHom.{u2, u1} M N _inst_1 _inst_2}} {{g : OneHom.{u2, u1} M N _inst_1 _inst_2}}, (Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) g)) -> (Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align one_hom.coe_inj OneHom.coe_injₓ'. -/\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\n@[to_additive \"Deprecated: use `fun_like.coe_injective` instead.\"]\ntheorem OneHom.coe_inj [One M] [One N] ⦃f g : OneHom M N⦄ (h : (f : M → N) = g) : f = g :=\n  FunLike.coe_injective h\n#align one_hom.coe_inj OneHom.coe_inj\n#align zero_hom.coe_inj ZeroHom.coe_inj\n\n/- warning: mul_hom.coe_inj -> MulHom.coe_inj is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] {{f : MulHom.{u1, u2} M N _inst_1 _inst_2}} {{g : MulHom.{u1, u2} M N _inst_1 _inst_2}}, (Eq.{max (succ u1) (succ u2)} ((fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g)) -> (Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] {{f : MulHom.{u2, u1} M N _inst_1 _inst_2}} {{g : MulHom.{u2, u1} M N _inst_1 _inst_2}}, (Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) g)) -> (Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align mul_hom.coe_inj MulHom.coe_injₓ'. -/\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\n@[to_additive \"Deprecated: use `fun_like.coe_injective` instead.\"]\ntheorem MulHom.coe_inj [Mul M] [Mul N] ⦃f g : M →ₙ* N⦄ (h : (f : M → N) = g) : f = g :=\n  FunLike.coe_injective h\n#align mul_hom.coe_inj MulHom.coe_inj\n#align add_hom.coe_inj AddHom.coe_inj\n\n/- warning: monoid_hom.coe_inj -> MonoidHom.coe_inj is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] {{f : MonoidHom.{u1, u2} M N _inst_1 _inst_2}} {{g : MonoidHom.{u1, u2} M N _inst_1 _inst_2}}, (Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g)) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] {{f : MonoidHom.{u2, u1} M N _inst_1 _inst_2}} {{g : MonoidHom.{u2, u1} M N _inst_1 _inst_2}}, (Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) g)) -> (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_inj MonoidHom.coe_injₓ'. -/\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\n@[to_additive \"Deprecated: use `fun_like.coe_injective` instead.\"]\ntheorem MonoidHom.coe_inj [MulOneClass M] [MulOneClass N] ⦃f g : M →* N⦄ (h : (f : M → N) = g) :\n    f = g :=\n  FunLike.coe_injective h\n#align monoid_hom.coe_inj MonoidHom.coe_inj\n#align add_monoid_hom.coe_inj AddMonoidHom.coe_inj\n\n/- warning: monoid_with_zero_hom.coe_inj -> MonoidWithZeroHom.coe_inj is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] {{f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}} {{g : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}}, (Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g)) -> (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] {{f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2}} {{g : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2}}, (Eq.{max (succ u2) (succ u1)} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) g)) -> (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.coe_inj MonoidWithZeroHom.coe_injₓ'. -/\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\ntheorem MonoidWithZeroHom.coe_inj [MulZeroOneClass M] [MulZeroOneClass N] ⦃f g : M →*₀ N⦄\n    (h : (f : M → N) = g) : f = g :=\n  FunLike.coe_injective h\n#align monoid_with_zero_hom.coe_inj MonoidWithZeroHom.coe_inj\n\n/- warning: one_hom.ext_iff -> OneHom.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] {f : OneHom.{u1, u2} M N _inst_1 _inst_2} {g : OneHom.{u1, u2} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] {f : OneHom.{u2, u1} M N _inst_1 _inst_2} {g : OneHom.{u2, u1} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) g x))\nCase conversion may be inaccurate. Consider using '#align one_hom.ext_iff OneHom.ext_iffₓ'. -/\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\n@[to_additive \"Deprecated: use `fun_like.ext_iff` instead.\"]\ntheorem OneHom.ext_iff [One M] [One N] {f g : OneHom M N} : f = g ↔ ∀ x, f x = g x :=\n  FunLike.ext_iff\n#align one_hom.ext_iff OneHom.ext_iff\n#align zero_hom.ext_iff ZeroHom.ext_iff\n\n/- warning: mul_hom.ext_iff -> MulHom.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] {f : MulHom.{u1, u2} M N _inst_1 _inst_2} {g : MulHom.{u1, u2} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] {f : MulHom.{u2, u1} M N _inst_1 _inst_2} {g : MulHom.{u2, u1} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) g x))\nCase conversion may be inaccurate. Consider using '#align mul_hom.ext_iff MulHom.ext_iffₓ'. -/\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\n@[to_additive \"Deprecated: use `fun_like.ext_iff` instead.\"]\ntheorem MulHom.ext_iff [Mul M] [Mul N] {f g : M →ₙ* N} : f = g ↔ ∀ x, f x = g x :=\n  FunLike.ext_iff\n#align mul_hom.ext_iff MulHom.ext_iff\n#align add_hom.ext_iff AddHom.ext_iff\n\n/- warning: monoid_hom.ext_iff -> MonoidHom.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] {f : MonoidHom.{u1, u2} M N _inst_1 _inst_2} {g : MonoidHom.{u1, u2} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] {f : MonoidHom.{u2, u1} M N _inst_1 _inst_2} {g : MonoidHom.{u2, u1} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) g x))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.ext_iff MonoidHom.ext_iffₓ'. -/\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\n@[to_additive \"Deprecated: use `fun_like.ext_iff` instead.\"]\ntheorem MonoidHom.ext_iff [MulOneClass M] [MulOneClass N] {f g : M →* N} : f = g ↔ ∀ x, f x = g x :=\n  FunLike.ext_iff\n#align monoid_hom.ext_iff MonoidHom.ext_iff\n#align add_monoid_hom.ext_iff AddMonoidHom.ext_iff\n\n/- warning: monoid_with_zero_hom.ext_iff -> MonoidWithZeroHom.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] {f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2} {g : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] {f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2} {g : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2}, Iff (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) f g) (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) g x))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.ext_iff MonoidWithZeroHom.ext_iffₓ'. -/\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\ntheorem MonoidWithZeroHom.ext_iff [MulZeroOneClass M] [MulZeroOneClass N] {f g : M →*₀ N} :\n    f = g ↔ ∀ x, f x = g x :=\n  FunLike.ext_iff\n#align monoid_with_zero_hom.ext_iff MonoidWithZeroHom.ext_iff\n\nend Deprecated\n\n/- warning: one_hom.mk_coe -> OneHom.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (f : OneHom.{u1, u2} M N _inst_1 _inst_2) (h1 : Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M _inst_1)))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N _inst_2)))), Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.mk.{u1, u2} M N _inst_1 _inst_2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) h1) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (f : OneHom.{u2, u1} M N _inst_1 _inst_2) (h1 : Eq.{succ u1} N (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N _inst_2))), Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N _inst_1 _inst_2) (OneHom.mk.{u2, u1} M N _inst_1 _inst_2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f) h1) f\nCase conversion may be inaccurate. Consider using '#align one_hom.mk_coe OneHom.mk_coeₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.mk_coe [One M] [One N] (f : OneHom M N) (h1) : OneHom.mk f h1 = f :=\n  OneHom.ext fun _ => rfl\n#align one_hom.mk_coe OneHom.mk_coe\n#align zero_hom.mk_coe ZeroHom.mk_coe\n\n/- warning: mul_hom.mk_coe -> MulHom.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] (f : MulHom.{u1, u2} M N _inst_1 _inst_2) (hmul : forall (x : M) (y : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M _inst_1) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N _inst_2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y))), Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (MulHom.mk.{u1, u2} M N _inst_1 _inst_2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) hmul) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] (f : MulHom.{u2, u1} M N _inst_1 _inst_2) (hmul : forall (x : M) (y : M), Eq.{succ u1} N (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M _inst_1) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N _inst_2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f y))), Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N _inst_1 _inst_2) (MulHom.mk.{u2, u1} M N _inst_1 _inst_2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f) hmul) f\nCase conversion may be inaccurate. Consider using '#align mul_hom.mk_coe MulHom.mk_coeₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.mk_coe [Mul M] [Mul N] (f : M →ₙ* N) (hmul) : MulHom.mk f hmul = f :=\n  MulHom.ext fun _ => rfl\n#align mul_hom.mk_coe MulHom.mk_coe\n#align add_hom.mk_coe AddHom.mk_coe\n\n/- warning: monoid_hom.mk_coe -> MonoidHom.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2) (h1 : Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N _inst_2))))) (hmul : forall (x : M) (y : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N _inst_2)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y))), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.mk.{u1, u2} M N _inst_1 _inst_2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) h1 hmul) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2) (h1 : forall (x : M) (y : M), Eq.{succ u1} N (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (OneHomClass.toOneHom.{u2, u1, max u2 u1} M N (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (MonoidHomClass.toOneHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2)) f) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M _inst_1)) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N (MulOneClass.toMul.{u1} N _inst_2)) (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (OneHomClass.toOneHom.{u2, u1, max u2 u1} M N (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (MonoidHomClass.toOneHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2)) f) x) (OneHom.toFun.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (OneHomClass.toOneHom.{u2, u1, max u2 u1} M N (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (MonoidHomClass.toOneHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2)) f) y))), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MonoidHom.mk.{u2, u1} M N _inst_1 _inst_2 (OneHomClass.toOneHom.{u2, u1, max u2 u1} M N (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2) (MonoidHomClass.toOneHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2)) f) h1) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.mk_coe MonoidHom.mk_coeₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.mk_coe [MulOneClass M] [MulOneClass N] (f : M →* N) (h1 hmul) :\n    MonoidHom.mk f h1 hmul = f :=\n  MonoidHom.ext fun _ => rfl\n#align monoid_hom.mk_coe MonoidHom.mk_coe\n#align add_monoid_hom.mk_coe AddMonoidHom.mk_coe\n\n/- warning: monoid_with_zero_hom.mk_coe -> MonoidWithZeroHom.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (h0 : Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 0 (OfNat.mk.{u2} N 0 (Zero.zero.{u2} N (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2)))))) (h1 : Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)))))) (hmul : forall (x : M) (y : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M _inst_1))) x y)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y))), Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (MonoidWithZeroHom.mk.{u1, u2} M N _inst_1 _inst_2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f) h0 h1 hmul) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (h0 : Eq.{succ u1} N (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (ZeroHomClass.toZeroHom.{u2, u1, max u2 u1} M N (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (MonoidWithZeroHomClass.toZeroHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)) f) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (MulOneClass.toOne.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2))))) (h1 : forall (x : M) (y : M), Eq.{succ u1} N (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (ZeroHomClass.toZeroHom.{u2, u1, max u2 u1} M N (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (MonoidWithZeroHomClass.toZeroHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)) f) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} N N N (instHMul.{u1} N (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2))) (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (ZeroHomClass.toZeroHom.{u2, u1, max u2 u1} M N (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (MonoidWithZeroHomClass.toZeroHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)) f) x) (ZeroHom.toFun.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (ZeroHomClass.toZeroHom.{u2, u1, max u2 u1} M N (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (MonoidWithZeroHomClass.toZeroHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)) f) y))), Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MonoidWithZeroHom.mk.{u2, u1} M N _inst_1 _inst_2 (ZeroHomClass.toZeroHom.{u2, u1, max u2 u1} M N (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2) (MonoidWithZeroHomClass.toZeroHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)) f) h0 h1) f\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.mk_coe MonoidWithZeroHom.mk_coeₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.mk_coe [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N)\n    (h0 h1 hmul) : MonoidWithZeroHom.mk f h0 h1 hmul = f :=\n  MonoidWithZeroHom.ext fun _ => rfl\n#align monoid_with_zero_hom.mk_coe MonoidWithZeroHom.mk_coe\n\nend Coes\n\n#print OneHom.copy /-\n/-- Copy of a `one_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\n@[to_additive\n      \"Copy of a `zero_hom` with a new `to_fun` equal to the old one. Useful to fix\\ndefinitional equalities.\"]\nprotected def OneHom.copy {hM : One M} {hN : One N} (f : OneHom M N) (f' : M → N) (h : f' = f) :\n    OneHom M N where\n  toFun := f'\n  map_one' := h.symm ▸ f.map_one'\n#align one_hom.copy OneHom.copy\n#align zero_hom.copy ZeroHom.copy\n-/\n\n/- warning: one_hom.coe_copy -> OneHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : One.{u1} M} {hN : One.{u2} N} (f : OneHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N hM hN) (fun (_x : OneHom.{u1, u2} M N hM hN) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u1) (succ u2)} (M -> N) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N hM hN) (fun (_x : OneHom.{u1, u2} M N hM hN) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N hM hN) (OneHom.copy.{u1, u2} M N hM hN f f' h)) f'\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : One.{u2} M} {hN : One.{u1} N} (f : OneHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N hM hN) M N hM hN (OneHom.oneHomClass.{u2, u1} M N hM hN)) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N hM hN) M N hM hN (OneHom.oneHomClass.{u2, u1} M N hM hN)) (OneHom.copy.{u2, u1} M N hM hN f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align one_hom.coe_copy OneHom.coe_copyₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_copy {hM : One M} {hN : One N} (f : OneHom M N) (f' : M → N) (h : f' = f) :\n    ⇑(f.copy f' h) = f' :=\n  rfl\n#align one_hom.coe_copy OneHom.coe_copy\n#align zero_hom.coe_copy ZeroHom.coe_copy\n\n/- warning: one_hom.coe_copy_eq -> OneHom.coe_copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : One.{u1} M} {hN : One.{u2} N} (f : OneHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N hM hN) (fun (_x : OneHom.{u1, u2} M N hM hN) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N hM hN) (OneHom.copy.{u1, u2} M N hM hN f f' h) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : One.{u2} M} {hN : One.{u1} N} (f : OneHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N hM hN) M N hM hN (OneHom.oneHomClass.{u2, u1} M N hM hN)) f)), Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N hM hN) (OneHom.copy.{u2, u1} M N hM hN f f' h) f\nCase conversion may be inaccurate. Consider using '#align one_hom.coe_copy_eq OneHom.coe_copy_eqₓ'. -/\n@[to_additive]\ntheorem OneHom.coe_copy_eq {hM : One M} {hN : One N} (f : OneHom M N) (f' : M → N) (h : f' = f) :\n    f.copy f' h = f :=\n  FunLike.ext' h\n#align one_hom.coe_copy_eq OneHom.coe_copy_eq\n#align zero_hom.coe_copy_eq ZeroHom.coe_copy_eq\n\n#print MulHom.copy /-\n/-- Copy of a `mul_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\n@[to_additive\n      \"Copy of an `add_hom` with a new `to_fun` equal to the old one. Useful to fix\\ndefinitional equalities.\"]\nprotected def MulHom.copy {hM : Mul M} {hN : Mul N} (f : M →ₙ* N) (f' : M → N) (h : f' = f) :\n    M →ₙ* N where\n  toFun := f'\n  map_mul' := h.symm ▸ f.map_mul'\n#align mul_hom.copy MulHom.copy\n#align add_hom.copy AddHom.copy\n-/\n\n/- warning: mul_hom.coe_copy -> MulHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : Mul.{u1} M} {hN : Mul.{u2} N} (f : MulHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N hM hN) (fun (_x : MulHom.{u1, u2} M N hM hN) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u1) (succ u2)} (M -> N) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N hM hN) (fun (_x : MulHom.{u1, u2} M N hM hN) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N hM hN) (MulHom.copy.{u1, u2} M N hM hN f f' h)) f'\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : Mul.{u2} M} {hN : Mul.{u1} N} (f : MulHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N hM hN) M N hM hN (MulHom.mulHomClass.{u2, u1} M N hM hN)) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N hM hN) M N hM hN (MulHom.mulHomClass.{u2, u1} M N hM hN)) (MulHom.copy.{u2, u1} M N hM hN f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align mul_hom.coe_copy MulHom.coe_copyₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_copy {hM : Mul M} {hN : Mul N} (f : M →ₙ* N) (f' : M → N) (h : f' = f) :\n    ⇑(f.copy f' h) = f' :=\n  rfl\n#align mul_hom.coe_copy MulHom.coe_copy\n#align add_hom.coe_copy AddHom.coe_copy\n\n/- warning: mul_hom.coe_copy_eq -> MulHom.coe_copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : Mul.{u1} M} {hN : Mul.{u2} N} (f : MulHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N hM hN) (fun (_x : MulHom.{u1, u2} M N hM hN) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N hM hN) (MulHom.copy.{u1, u2} M N hM hN f f' h) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : Mul.{u2} M} {hN : Mul.{u1} N} (f : MulHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N hM hN) M N hM hN (MulHom.mulHomClass.{u2, u1} M N hM hN)) f)), Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N hM hN) (MulHom.copy.{u2, u1} M N hM hN f f' h) f\nCase conversion may be inaccurate. Consider using '#align mul_hom.coe_copy_eq MulHom.coe_copy_eqₓ'. -/\n@[to_additive]\ntheorem MulHom.coe_copy_eq {hM : Mul M} {hN : Mul N} (f : M →ₙ* N) (f' : M → N) (h : f' = f) :\n    f.copy f' h = f :=\n  FunLike.ext' h\n#align mul_hom.coe_copy_eq MulHom.coe_copy_eq\n#align add_hom.coe_copy_eq AddHom.coe_copy_eq\n\n/- warning: monoid_hom.copy -> MonoidHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulOneClass.{u1} M} {hN : MulOneClass.{u2} N} (f : MonoidHom.{u1, u2} M N hM hN) (f' : M -> N), (Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N hM hN) (fun (_x : MonoidHom.{u1, u2} M N hM hN) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N hM hN) f)) -> (MonoidHom.{u1, u2} M N hM hN)\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulOneClass.{u1} M} {hN : MulOneClass.{u2} N} (f : MonoidHom.{u1, u2} M N hM hN) (f' : M -> N), (Eq.{max (succ u1) (succ u2)} (M -> N) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N hM hN) M N (MulOneClass.toMul.{u1} M hM) (MulOneClass.toMul.{u2} N hN) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N hM hN) M N hM hN (MonoidHom.monoidHomClass.{u1, u2} M N hM hN))) f)) -> (MonoidHom.{u1, u2} M N hM hN)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.copy MonoidHom.copyₓ'. -/\n/-- Copy of a `monoid_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\n@[to_additive\n      \"Copy of an `add_monoid_hom` with a new `to_fun` equal to the old one. Useful to fix\\ndefinitional equalities.\"]\nprotected def MonoidHom.copy {hM : MulOneClass M} {hN : MulOneClass N} (f : M →* N) (f' : M → N)\n    (h : f' = f) : M →* N :=\n  { f.toOneHom.copy f' h, f.toMulHom.copy f' h with }\n#align monoid_hom.copy MonoidHom.copy\n#align add_monoid_hom.copy AddMonoidHom.copy\n\n/- warning: monoid_hom.coe_copy -> MonoidHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulOneClass.{u1} M} {hN : MulOneClass.{u2} N} (f : MonoidHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N hM hN) (fun (_x : MonoidHom.{u1, u2} M N hM hN) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u1) (succ u2)} (M -> N) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N hM hN) (fun (_x : MonoidHom.{u1, u2} M N hM hN) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N hM hN) (MonoidHom.copy.{u1, u2} M N hM hN f f' h)) f'\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : MulOneClass.{u2} M} {hN : MulOneClass.{u1} N} (f : MonoidHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N hM hN) M N (MulOneClass.toMul.{u2} M hM) (MulOneClass.toMul.{u1} N hN) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N hM hN) M N hM hN (MonoidHom.monoidHomClass.{u2, u1} M N hM hN))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N hM hN) M N (MulOneClass.toMul.{u2} M hM) (MulOneClass.toMul.{u1} N hN) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N hM hN) M N hM hN (MonoidHom.monoidHomClass.{u2, u1} M N hM hN))) (MonoidHom.copy.{u2, u1} M N hM hN f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_copy MonoidHom.coe_copyₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_copy {hM : MulOneClass M} {hN : MulOneClass N} (f : M →* N) (f' : M → N)\n    (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align monoid_hom.coe_copy MonoidHom.coe_copy\n#align add_monoid_hom.coe_copy AddMonoidHom.coe_copy\n\n/- warning: monoid_hom.copy_eq -> MonoidHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulOneClass.{u1} M} {hN : MulOneClass.{u2} N} (f : MonoidHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N hM hN) (fun (_x : MonoidHom.{u1, u2} M N hM hN) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N hM hN) (MonoidHom.copy.{u1, u2} M N hM hN f f' h) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : MulOneClass.{u2} M} {hN : MulOneClass.{u1} N} (f : MonoidHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N hM hN) M N (MulOneClass.toMul.{u2} M hM) (MulOneClass.toMul.{u1} N hN) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N hM hN) M N hM hN (MonoidHom.monoidHomClass.{u2, u1} M N hM hN))) f)), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N hM hN) (MonoidHom.copy.{u2, u1} M N hM hN f f' h) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.copy_eq MonoidHom.copy_eqₓ'. -/\n@[to_additive]\ntheorem MonoidHom.copy_eq {hM : MulOneClass M} {hN : MulOneClass N} (f : M →* N) (f' : M → N)\n    (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align monoid_hom.copy_eq MonoidHom.copy_eq\n#align add_monoid_hom.copy_eq AddMonoidHom.copy_eq\n\n/- warning: monoid_with_zero_hom.copy -> MonoidWithZeroHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulZeroOneClass.{u1} M} {hN : MulZeroOneClass.{u2} N} (f : MonoidWithZeroHom.{u1, u2} M N hM hN) (f' : M -> N), (Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N hM hN) (fun (_x : MonoidWithZeroHom.{u1, u2} M N hM hN) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N hM hN) f)) -> (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN))\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulZeroOneClass.{u1} M} {hN : MulZeroOneClass.{u2} N} (f : MonoidWithZeroHom.{u1, u2} M N hM hN) (f' : M -> N), (Eq.{max (succ u1) (succ u2)} (M -> N) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidWithZeroHom.{u1, u2} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidWithZeroHom.{u1, u2} M N hM hN) M N (MulOneClass.toMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M hM)) (MulOneClass.toMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N hN)) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidWithZeroHom.{u1, u2} M N hM hN) M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN) (MonoidWithZeroHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (MonoidWithZeroHom.{u1, u2} M N hM hN) M N hM hN (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u2} M N hM hN)))) f)) -> (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.copy MonoidWithZeroHom.copyₓ'. -/\n/-- Copy of a `monoid_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\nprotected def MonoidWithZeroHom.copy {hM : MulZeroOneClass M} {hN : MulZeroOneClass N} (f : M →*₀ N)\n    (f' : M → N) (h : f' = f) : M →* N :=\n  { f.toZeroHom.copy f' h, f.toMonoidHom.copy f' h with }\n#align monoid_with_zero_hom.copy MonoidWithZeroHom.copy\n\n/- warning: monoid_with_zero_hom.coe_copy -> MonoidWithZeroHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulZeroOneClass.{u1} M} {hN : MulZeroOneClass.{u2} N} (f : MonoidWithZeroHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N hM hN) (fun (_x : MonoidWithZeroHom.{u1, u2} M N hM hN) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u1) (succ u2)} (M -> N) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN)) (fun (_x : MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN)) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN)) (MonoidWithZeroHom.copy.{u1, u2} M N hM hN f f' h)) f'\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : MulZeroOneClass.{u2} M} {hN : MulZeroOneClass.{u1} N} (f : MonoidWithZeroHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M hM)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N hN)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M N hM hN (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N hM hN)))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN)) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M hM)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N hN)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN)) M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN) (MonoidHom.monoidHomClass.{u2, u1} M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN)))) (MonoidWithZeroHom.copy.{u2, u1} M N hM hN f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.coe_copy MonoidWithZeroHom.coe_copyₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_copy {hM : MulZeroOneClass M} {hN : MulZeroOneClass N} (f : M →*₀ N)\n    (f' : M → N) (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align monoid_with_zero_hom.coe_copy MonoidWithZeroHom.coe_copy\n\n/- warning: monoid_with_zero_hom.copy_eq -> MonoidWithZeroHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {hM : MulZeroOneClass.{u1} M} {hN : MulZeroOneClass.{u2} N} (f : MonoidWithZeroHom.{u1, u2} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u1) (succ u2)} (M -> N) f' (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N hM hN) (fun (_x : MonoidWithZeroHom.{u1, u2} M N hM hN) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N hM hN) f)), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN)) (MonoidWithZeroHom.copy.{u1, u2} M N hM hN f f' h) ((fun (a : Sort.{max (succ u2) (succ u1)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u2) (succ u1), max (succ u2) (succ u1)} a b] => self.0) (MonoidWithZeroHom.{u1, u2} M N hM hN) (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN)) (HasLiftT.mk.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N hM hN) (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN)) (CoeTCₓ.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N hM hN) (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN)) (MonoidHom.hasCoeT.{u1, u2, max u2 u1} M N (MonoidWithZeroHom.{u1, u2} M N hM hN) (MulZeroOneClass.toMulOneClass.{u1} M hM) (MulZeroOneClass.toMulOneClass.{u2} N hN) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u1, u2} (MonoidWithZeroHom.{u1, u2} M N hM hN) M N hM hN (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u2} M N hM hN))))) f)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {hM : MulZeroOneClass.{u2} M} {hN : MulZeroOneClass.{u1} N} (f : MonoidWithZeroHom.{u2, u1} M N hM hN) (f' : M -> N) (h : Eq.{max (succ u2) (succ u1)} (M -> N) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M hM)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N hN)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M N hM hN (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N hM hN)))) f)), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN)) (MonoidWithZeroHom.copy.{u2, u1} M N hM hN f f' h) (MonoidHomClass.toMonoidHom.{u2, u1, max u2 u1} M N (MonoidWithZeroHom.{u2, u1} M N hM hN) (MulZeroOneClass.toMulOneClass.{u2} M hM) (MulZeroOneClass.toMulOneClass.{u1} N hN) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N hM hN) M N hM hN (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N hM hN)) f)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.copy_eq MonoidWithZeroHom.copy_eqₓ'. -/\ntheorem MonoidWithZeroHom.copy_eq {hM : MulZeroOneClass M} {hN : MulZeroOneClass N} (f : M →*₀ N)\n    (f' : M → N) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align monoid_with_zero_hom.copy_eq MonoidWithZeroHom.copy_eq\n\n/- warning: one_hom.map_one -> OneHom.map_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (f : OneHom.{u1, u2} M N _inst_1 _inst_2), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M _inst_1)))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N _inst_2)))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (f : OneHom.{u2, u1} M N _inst_1 _inst_2), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M _inst_1))) _inst_2))\nCase conversion may be inaccurate. Consider using '#align one_hom.map_one OneHom.map_oneₓ'. -/\n@[to_additive]\nprotected theorem OneHom.map_one [One M] [One N] (f : OneHom M N) : f 1 = 1 :=\n  f.map_one'\n#align one_hom.map_one OneHom.map_one\n#align zero_hom.map_zero ZeroHom.map_zero\n\n/- warning: monoid_hom.map_one -> MonoidHom.map_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M _inst_1))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N _inst_2))))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M _inst_1)))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M _inst_1)))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M _inst_1)))) (MulOneClass.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M _inst_1)))) _inst_2)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_one MonoidHom.map_oneₓ'. -/\n/-- If `f` is a monoid homomorphism then `f 1 = 1`. -/\n@[to_additive]\nprotected theorem MonoidHom.map_one [MulOneClass M] [MulOneClass N] (f : M →* N) : f 1 = 1 :=\n  f.map_one'\n#align monoid_hom.map_one MonoidHom.map_one\n#align add_monoid_hom.map_zero AddMonoidHom.map_zero\n\n/- warning: monoid_with_zero_hom.map_one -> MonoidWithZeroHom.map_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)))))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) (MulOneClass.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (MulOneClass.toOne.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1))))) _inst_2))))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.map_one MonoidWithZeroHom.map_oneₓ'. -/\nprotected theorem MonoidWithZeroHom.map_one [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) :\n    f 1 = 1 :=\n  f.map_one'\n#align monoid_with_zero_hom.map_one MonoidWithZeroHom.map_one\n\n/-- If `f` is an additive monoid homomorphism then `f 0 = 0`. -/\nadd_decl_doc AddMonoidHom.map_zero\n\n/- warning: monoid_with_zero_hom.map_zero -> MonoidWithZeroHom.map_zero is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u2} N 0 (OfNat.mk.{u2} N 0 (Zero.zero.{u2} N (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2)))))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 0 (Zero.toOfNat0.{u2} M (MulZeroOneClass.toZero.{u2} M _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f (OfNat.ofNat.{u2} M 0 (Zero.toOfNat0.{u2} M (MulZeroOneClass.toZero.{u2} M _inst_1)))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 0 (Zero.toOfNat0.{u2} M (MulZeroOneClass.toZero.{u2} M _inst_1)))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 0 (Zero.toOfNat0.{u2} M (MulZeroOneClass.toZero.{u2} M _inst_1)))) (MulZeroOneClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (OfNat.ofNat.{u2} M 0 (Zero.toOfNat0.{u2} M (MulZeroOneClass.toZero.{u2} M _inst_1)))) _inst_2)))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.map_zero MonoidWithZeroHom.map_zeroₓ'. -/\nprotected theorem MonoidWithZeroHom.map_zero [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) :\n    f 0 = 0 :=\n  f.map_zero'\n#align monoid_with_zero_hom.map_zero MonoidWithZeroHom.map_zero\n\n/- warning: mul_hom.map_mul -> MulHom.map_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] (f : MulHom.{u1, u2} M N _inst_1 _inst_2) (a : M) (b : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M _inst_1) a b)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N _inst_2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f a) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f b))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] (f : MulHom.{u2, u1} M N _inst_1 _inst_2) (a : M) (b : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M _inst_1) a b)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M _inst_1) a b)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u2, u1} M N _inst_1 _inst_2)) f b))\nCase conversion may be inaccurate. Consider using '#align mul_hom.map_mul MulHom.map_mulₓ'. -/\n@[to_additive]\nprotected theorem MulHom.map_mul [Mul M] [Mul N] (f : M →ₙ* N) (a b : M) : f (a * b) = f a * f b :=\n  f.map_mul' a b\n#align mul_hom.map_mul MulHom.map_mul\n#align add_hom.map_add AddHom.map_add\n\n/- warning: monoid_hom.map_mul -> MonoidHom.map_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2) (a : M) (b : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M _inst_1)) a b)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N _inst_2)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f a) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f b))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2) (a : M) (b : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M _inst_1)) a b)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M _inst_1)) a b)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) f b))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_mul MonoidHom.map_mulₓ'. -/\n/-- If `f` is a monoid homomorphism then `f (a * b) = f a * f b`. -/\n@[to_additive]\nprotected theorem MonoidHom.map_mul [MulOneClass M] [MulOneClass N] (f : M →* N) (a b : M) :\n    f (a * b) = f a * f b :=\n  f.map_mul' a b\n#align monoid_hom.map_mul MonoidHom.map_mul\n#align add_monoid_hom.map_add AddMonoidHom.map_add\n\n/- warning: monoid_with_zero_hom.map_mul -> MonoidWithZeroHom.map_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (a : M) (b : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1))) a b)) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulZeroClass.toHasMul.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f a) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f b))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (a : M) (b : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulZeroClass.toMul.{u2} M (MulZeroOneClass.toMulZeroClass.{u2} M _inst_1))) a b)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulZeroClass.toMul.{u2} M (MulZeroOneClass.toMulZeroClass.{u2} M _inst_1))) a b)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (MulZeroClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (MulZeroOneClass.toMulZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M (MulZeroOneClass.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} M N _inst_1 _inst_2)))) f b))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.map_mul MonoidWithZeroHom.map_mulₓ'. -/\nprotected theorem MonoidWithZeroHom.map_mul [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N)\n    (a b : M) : f (a * b) = f a * f b :=\n  f.map_mul' a b\n#align monoid_with_zero_hom.map_mul MonoidWithZeroHom.map_mul\n\n/-- If `f` is an additive monoid homomorphism then `f (a + b) = f a + f b`. -/\nadd_decl_doc AddMonoidHom.map_add\n\nnamespace MonoidHom\n\nvariable {mM : MulOneClass M} {mN : MulOneClass N} [MonoidHomClass F M N]\n\ninclude mM mN\n\n/- warning: monoid_hom.map_exists_right_inv -> MonoidHom.map_exists_right_inv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} {mM : MulOneClass.{u1} M} {mN : MulOneClass.{u2} N} [_inst_1 : MonoidHomClass.{u3, u1, u2} F M N mM mN] (f : F) {x : M}, (Exists.{succ u1} M (fun (y : M) => Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M mM)) x y) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M mM)))))) -> (Exists.{succ u2} N (fun (y : N) => Eq.{succ u2} N (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N mN)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N (MulOneClass.toHasMul.{u1} M mM) (MulOneClass.toHasMul.{u2} N mN) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F M N mM mN _inst_1))) f x) y) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N mN))))))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {F : Type.{u1}} {mM : MulOneClass.{u3} M} {mN : MulOneClass.{u2} N} [_inst_1 : MonoidHomClass.{u1, u3, u2} F M N mM mN] (f : F) {x : M}, (Exists.{succ u3} M (fun (y : M) => Eq.{succ u3} M (HMul.hMul.{u3, u3, u3} M M M (instHMul.{u3} M (MulOneClass.toMul.{u3} M mM)) x y) (OfNat.ofNat.{u3} M 1 (One.toOfNat1.{u3} M (MulOneClass.toOne.{u3} M mM))))) -> (Exists.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (fun (y : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) => Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) mN)) (FunLike.coe.{succ u1, succ u3, succ u2} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u1, u3, u2} F M N (MulOneClass.toMul.{u3} M mM) (MulOneClass.toMul.{u2} N mN) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F M N mM mN _inst_1)) f x) y) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) mN)))))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_exists_right_inv MonoidHom.map_exists_right_invₓ'. -/\n/-- Given a monoid homomorphism `f : M →* N` and an element `x : M`, if `x` has a right inverse,\nthen `f x` has a right inverse too. For elements invertible on both sides see `is_unit.map`. -/\n@[to_additive\n      \"Given an add_monoid homomorphism `f : M →+ N` and an element `x : M`, if `x` has\\na right inverse, then `f x` has a right inverse too.\"]\ntheorem map_exists_right_inv (f : F) {x : M} (hx : ∃ y, x * y = 1) : ∃ y, f x * y = 1 :=\n  let ⟨y, hy⟩ := hx\n  ⟨f y, map_mul_eq_one f hy⟩\n#align monoid_hom.map_exists_right_inv MonoidHom.map_exists_right_inv\n#align add_monoid_hom.map_exists_right_neg AddMonoidHom.map_exists_right_neg\n\n/- warning: monoid_hom.map_exists_left_inv -> MonoidHom.map_exists_left_inv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {F : Type.{u3}} {mM : MulOneClass.{u1} M} {mN : MulOneClass.{u2} N} [_inst_1 : MonoidHomClass.{u3, u1, u2} F M N mM mN] (f : F) {x : M}, (Exists.{succ u1} M (fun (y : M) => Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M mM)) y x) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M mM)))))) -> (Exists.{succ u2} N (fun (y : N) => Eq.{succ u2} N (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N mN)) y (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u3, u1, u2} F M N (MulOneClass.toHasMul.{u1} M mM) (MulOneClass.toHasMul.{u2} N mN) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F M N mM mN _inst_1))) f x)) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N mN))))))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {F : Type.{u1}} {mM : MulOneClass.{u3} M} {mN : MulOneClass.{u2} N} [_inst_1 : MonoidHomClass.{u1, u3, u2} F M N mM mN] (f : F) {x : M}, (Exists.{succ u3} M (fun (y : M) => Eq.{succ u3} M (HMul.hMul.{u3, u3, u3} M M M (instHMul.{u3} M (MulOneClass.toMul.{u3} M mM)) y x) (OfNat.ofNat.{u3} M 1 (One.toOfNat1.{u3} M (MulOneClass.toOne.{u3} M mM))))) -> (Exists.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (fun (y : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) => Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) mN)) y (FunLike.coe.{succ u1, succ u3, succ u2} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u1, u3, u2} F M N (MulOneClass.toMul.{u3} M mM) (MulOneClass.toMul.{u2} N mN) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F M N mM mN _inst_1)) f x)) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) mN)))))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_exists_left_inv MonoidHom.map_exists_left_invₓ'. -/\n/-- Given a monoid homomorphism `f : M →* N` and an element `x : M`, if `x` has a left inverse,\nthen `f x` has a left inverse too. For elements invertible on both sides see `is_unit.map`. -/\n@[to_additive\n      \"Given an add_monoid homomorphism `f : M →+ N` and an element `x : M`, if `x` has\\na left inverse, then `f x` has a left inverse too. For elements invertible on both sides see\\n`is_add_unit.map`.\"]\ntheorem map_exists_left_inv (f : F) {x : M} (hx : ∃ y, y * x = 1) : ∃ y, y * f x = 1 :=\n  let ⟨y, hy⟩ := hx\n  ⟨f y, map_mul_eq_one f hy⟩\n#align monoid_hom.map_exists_left_inv MonoidHom.map_exists_left_inv\n#align add_monoid_hom.map_exists_left_neg AddMonoidHom.map_exists_left_neg\n\nend MonoidHom\n\nsection DivisionCommMonoid\n\nvariable [DivisionCommMonoid α]\n\n#print invMonoidHom /-\n/-- Inversion on a commutative group, considered as a monoid homomorphism. -/\n@[to_additive\n      \"Negation on a commutative additive group, considered as an additive monoid\\nhomomorphism.\"]\ndef invMonoidHom : α →* α where\n  toFun := Inv.inv\n  map_one' := inv_one\n  map_mul' := mul_inv\n#align inv_monoid_hom invMonoidHom\n#align neg_add_monoid_hom negAddMonoidHom\n-/\n\n/- warning: coe_inv_monoid_hom -> coe_invMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} α], Eq.{succ u1} ((fun (_x : MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) => α -> α) (invMonoidHom.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (fun (_x : MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) => α -> α) (MonoidHom.hasCoeToFun.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (invMonoidHom.{u1} α _inst_1)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} α], Eq.{succ u1} (forall (a : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) α α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (MonoidHom.monoidHomClass.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))))) (invMonoidHom.{u1} α _inst_1)) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align coe_inv_monoid_hom coe_invMonoidHomₓ'. -/\n@[simp]\ntheorem coe_invMonoidHom : (invMonoidHom : α → α) = Inv.inv :=\n  rfl\n#align coe_inv_monoid_hom coe_invMonoidHom\n\n/- warning: inv_monoid_hom_apply -> invMonoidHom_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} α] (a : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (fun (_x : MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) => α -> α) (MonoidHom.hasCoeToFun.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (invMonoidHom.{u1} α _inst_1) a) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} α] (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) α α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))) α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (MonoidHom.monoidHomClass.{u1, u1} α α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (DivisionMonoid.toDivInvMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1))))))) (invMonoidHom.{u1} α _inst_1) a) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (DivisionCommMonoid.toDivisionMonoid.{u1} α _inst_1)))) a)\nCase conversion may be inaccurate. Consider using '#align inv_monoid_hom_apply invMonoidHom_applyₓ'. -/\n@[simp]\ntheorem invMonoidHom_apply (a : α) : invMonoidHom a = a⁻¹ :=\n  rfl\n#align inv_monoid_hom_apply invMonoidHom_apply\n\nend DivisionCommMonoid\n\n#print OneHom.id /-\n/-- The identity map from a type with 1 to itself. -/\n@[to_additive, simps]\ndef OneHom.id (M : Type _) [One M] : OneHom M M\n    where\n  toFun x := x\n  map_one' := rfl\n#align one_hom.id OneHom.id\n#align zero_hom.id ZeroHom.id\n-/\n\n#print MulHom.id /-\n/-- The identity map from a type with multiplication to itself. -/\n@[to_additive, simps]\ndef MulHom.id (M : Type _) [Mul M] : M →ₙ* M\n    where\n  toFun x := x\n  map_mul' _ _ := rfl\n#align mul_hom.id MulHom.id\n#align add_hom.id AddHom.id\n-/\n\n#print MonoidHom.id /-\n/-- The identity map from a monoid to itself. -/\n@[to_additive, simps]\ndef MonoidHom.id (M : Type _) [MulOneClass M] : M →* M\n    where\n  toFun x := x\n  map_one' := rfl\n  map_mul' _ _ := rfl\n#align monoid_hom.id MonoidHom.id\n#align add_monoid_hom.id AddMonoidHom.id\n-/\n\n#print MonoidWithZeroHom.id /-\n/-- The identity map from a monoid_with_zero to itself. -/\n@[simps]\ndef MonoidWithZeroHom.id (M : Type _) [MulZeroOneClass M] : M →*₀ M\n    where\n  toFun x := x\n  map_zero' := rfl\n  map_one' := rfl\n  map_mul' _ _ := rfl\n#align monoid_with_zero_hom.id MonoidWithZeroHom.id\n-/\n\n/-- The identity map from an type with zero to itself. -/\nadd_decl_doc ZeroHom.id\n\n/-- The identity map from an type with addition to itself. -/\nadd_decl_doc AddHom.id\n\n/-- The identity map from an additive monoid to itself. -/\nadd_decl_doc AddMonoidHom.id\n\n#print OneHom.comp /-\n/-- Composition of `one_hom`s as a `one_hom`. -/\n@[to_additive]\ndef OneHom.comp [One M] [One N] [One P] (hnp : OneHom N P) (hmn : OneHom M N) : OneHom M P\n    where\n  toFun := hnp ∘ hmn\n  map_one' := by simp\n#align one_hom.comp OneHom.comp\n#align zero_hom.comp ZeroHom.comp\n-/\n\n#print MulHom.comp /-\n/-- Composition of `mul_hom`s as a `mul_hom`. -/\n@[to_additive]\ndef MulHom.comp [Mul M] [Mul N] [Mul P] (hnp : N →ₙ* P) (hmn : M →ₙ* N) : M →ₙ* P\n    where\n  toFun := hnp ∘ hmn\n  map_mul' := by simp\n#align mul_hom.comp MulHom.comp\n#align add_hom.comp AddHom.comp\n-/\n\n#print MonoidHom.comp /-\n/-- Composition of monoid morphisms as a monoid morphism. -/\n@[to_additive]\ndef MonoidHom.comp [MulOneClass M] [MulOneClass N] [MulOneClass P] (hnp : N →* P) (hmn : M →* N) :\n    M →* P where\n  toFun := hnp ∘ hmn\n  map_one' := by simp\n  map_mul' := by simp\n#align monoid_hom.comp MonoidHom.comp\n#align add_monoid_hom.comp AddMonoidHom.comp\n-/\n\n#print MonoidWithZeroHom.comp /-\n/-- Composition of `monoid_with_zero_hom`s as a `monoid_with_zero_hom`. -/\ndef MonoidWithZeroHom.comp [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    (hnp : N →*₀ P) (hmn : M →*₀ N) : M →*₀ P\n    where\n  toFun := hnp ∘ hmn\n  map_zero' := by simp\n  map_one' := by simp\n  map_mul' := by simp\n#align monoid_with_zero_hom.comp MonoidWithZeroHom.comp\n-/\n\n/-- Composition of `zero_hom`s as a `zero_hom`. -/\nadd_decl_doc ZeroHom.comp\n\n/-- Composition of `add_hom`s as a `add_hom`. -/\nadd_decl_doc AddHom.comp\n\n/-- Composition of additive monoid morphisms as an additive monoid morphism. -/\nadd_decl_doc AddMonoidHom.comp\n\n/- warning: one_hom.coe_comp -> OneHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u3} P] (g : OneHom.{u2, u3} N P _inst_2 _inst_3) (f : OneHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (M -> P) (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (OneHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : OneHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (OneHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u1, succ u2, succ u3} M N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (OneHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : OneHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (OneHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : One.{u3} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u1} P] (g : OneHom.{u2, u1} N P _inst_2 _inst_3) (f : OneHom.{u3, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (M -> P) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => P) _x) (OneHomClass.toFunLike.{max u3 u1, u3, u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (OneHom.oneHomClass.{u3, u1} M P _inst_1 _inst_3)) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u3, succ u2, succ u1} M N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : N) => P) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (OneHom.oneHomClass.{u2, u1} N P _inst_2 _inst_3)) g) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u3 u2, u3, u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u3, u2} M N _inst_1 _inst_2)) f))\nCase conversion may be inaccurate. Consider using '#align one_hom.coe_comp OneHom.coe_compₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_comp [One M] [One N] [One P] (g : OneHom N P) (f : OneHom M N) :\n    ⇑(g.comp f) = g ∘ f :=\n  rfl\n#align one_hom.coe_comp OneHom.coe_comp\n#align zero_hom.coe_comp ZeroHom.coe_comp\n\n/- warning: mul_hom.coe_comp -> MulHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u3} P] (g : MulHom.{u2, u3} N P _inst_2 _inst_3) (f : MulHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (M -> P) (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (MulHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : MulHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (MulHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u1, succ u2, succ u3} M N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MulHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MulHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MulHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : Mul.{u3} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u1} P] (g : MulHom.{u2, u1} N P _inst_2 _inst_3) (f : MulHom.{u3, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (M -> P) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (MulHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (MulHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (MulHom.mulHomClass.{u3, u1} M P _inst_1 _inst_3)) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u3, succ u2, succ u1} M N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MulHom.mulHomClass.{u2, u1} N P _inst_2 _inst_3)) g) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MulHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MulHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u3, u2} M N _inst_1 _inst_2)) f))\nCase conversion may be inaccurate. Consider using '#align mul_hom.coe_comp MulHom.coe_compₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_comp [Mul M] [Mul N] [Mul P] (g : N →ₙ* P) (f : M →ₙ* N) : ⇑(g.comp f) = g ∘ f :=\n  rfl\n#align mul_hom.coe_comp MulHom.coe_comp\n#align add_hom.coe_comp AddHom.coe_comp\n\n/- warning: monoid_hom.coe_comp -> MonoidHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u3} P] (g : MonoidHom.{u2, u3} N P _inst_2 _inst_3) (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (M -> P) (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (MonoidHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (MonoidHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u1, succ u2, succ u3} M N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MonoidHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MonoidHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MonoidHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulOneClass.{u3} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u1} P] (g : MonoidHom.{u2, u1} N P _inst_2 _inst_3) (f : MonoidHom.{u3, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (M -> P) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) M P (MulOneClass.toMul.{u3} M _inst_1) (MulOneClass.toMul.{u1} P _inst_3) (MonoidHomClass.toMulHomClass.{max u3 u1, u3, u1} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u3, u1} M P _inst_1 _inst_3))) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u3, succ u2, succ u1} M N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N P (MulOneClass.toMul.{u2} N _inst_2) (MulOneClass.toMul.{u1} P _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} N P _inst_2 _inst_3))) g) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u3} M _inst_1) (MulOneClass.toMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u3 u2, u3, u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u3, u2} M N _inst_1 _inst_2))) f))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_comp MonoidHom.coe_compₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_comp [MulOneClass M] [MulOneClass N] [MulOneClass P] (g : N →* P)\n    (f : M →* N) : ⇑(g.comp f) = g ∘ f :=\n  rfl\n#align monoid_hom.coe_comp MonoidHom.coe_comp\n#align add_monoid_hom.coe_comp AddMonoidHom.coe_comp\n\n/- warning: monoid_with_zero_hom.coe_comp -> MonoidWithZeroHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u3} P] (g : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (M -> P) (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (MonoidWithZeroHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : MonoidWithZeroHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (MonoidWithZeroHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u1, succ u2, succ u3} M N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MonoidWithZeroHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulZeroOneClass.{u3} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u1} P] (g : MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) (f : MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (M -> P) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M P (MulOneClass.toMul.{u3} M (MulZeroOneClass.toMulOneClass.{u3} M _inst_1)) (MulOneClass.toMul.{u1} P (MulZeroOneClass.toMulOneClass.{u1} P _inst_3)) (MonoidHomClass.toMulHomClass.{max u3 u1, u3, u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M P (MulZeroOneClass.toMulOneClass.{u3} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} P _inst_3) (MonoidWithZeroHomClass.toMonoidHomClass.{max u3 u1, u3, u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (MonoidWithZeroHom.monoidWithZeroHomClass.{u3, u1} M P _inst_1 _inst_3)))) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f)) (Function.comp.{succ u3, succ u2, succ u1} M N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P (MulOneClass.toMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MulOneClass.toMul.{u1} P (MulZeroOneClass.toMulOneClass.{u1} P _inst_3)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MulZeroOneClass.toMulOneClass.{u1} P _inst_3) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} N P _inst_2 _inst_3)))) g) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u3} M (MulZeroOneClass.toMulOneClass.{u3} M _inst_1)) (MulOneClass.toMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u3} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u3, u2} M N _inst_1 _inst_2)))) f))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.coe_comp MonoidWithZeroHom.coe_compₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_comp [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    (g : N →*₀ P) (f : M →*₀ N) : ⇑(g.comp f) = g ∘ f :=\n  rfl\n#align monoid_with_zero_hom.coe_comp MonoidWithZeroHom.coe_comp\n\n/- warning: one_hom.comp_apply -> OneHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u3} P] (g : OneHom.{u2, u3} N P _inst_2 _inst_3) (f : OneHom.{u1, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u3} P (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (OneHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : OneHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (OneHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f) x) (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (OneHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : OneHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (OneHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : One.{u3} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u1} P] (g : OneHom.{u2, u1} N P _inst_2 _inst_3) (f : OneHom.{u3, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => P) x) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => P) _x) (OneHomClass.toFunLike.{max u3 u1, u3, u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (OneHom.oneHomClass.{u3, u1} M P _inst_1 _inst_3)) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : N) => P) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (OneHom.oneHomClass.{u2, u1} N P _inst_2 _inst_3)) g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u3 u2, u3, u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u3, u2} M N _inst_1 _inst_2)) f x))\nCase conversion may be inaccurate. Consider using '#align one_hom.comp_apply OneHom.comp_applyₓ'. -/\n@[to_additive]\ntheorem OneHom.comp_apply [One M] [One N] [One P] (g : OneHom N P) (f : OneHom M N) (x : M) :\n    g.comp f x = g (f x) :=\n  rfl\n#align one_hom.comp_apply OneHom.comp_apply\n#align zero_hom.comp_apply ZeroHom.comp_apply\n\n/- warning: mul_hom.comp_apply -> MulHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u3} P] (g : MulHom.{u2, u3} N P _inst_2 _inst_3) (f : MulHom.{u1, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u3} P (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (MulHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : MulHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (MulHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f) x) (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MulHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MulHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MulHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : Mul.{u3} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u1} P] (g : MulHom.{u2, u1} N P _inst_2 _inst_3) (f : MulHom.{u3, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) x) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (MulHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (MulHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (MulHom.mulHomClass.{u3, u1} M P _inst_1 _inst_3)) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MulHom.mulHomClass.{u2, u1} N P _inst_2 _inst_3)) g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MulHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MulHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u3, u2} M N _inst_1 _inst_2)) f x))\nCase conversion may be inaccurate. Consider using '#align mul_hom.comp_apply MulHom.comp_applyₓ'. -/\n@[to_additive]\ntheorem MulHom.comp_apply [Mul M] [Mul N] [Mul P] (g : N →ₙ* P) (f : M →ₙ* N) (x : M) :\n    g.comp f x = g (f x) :=\n  rfl\n#align mul_hom.comp_apply MulHom.comp_apply\n#align add_hom.comp_apply AddHom.comp_apply\n\n/- warning: monoid_hom.comp_apply -> MonoidHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u3} P] (g : MonoidHom.{u2, u3} N P _inst_2 _inst_3) (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u3} P (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (MonoidHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : MonoidHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (MonoidHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f) x) (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MonoidHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MonoidHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MonoidHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulOneClass.{u3} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u1} P] (g : MonoidHom.{u2, u1} N P _inst_2 _inst_3) (f : MonoidHom.{u3, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) x) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) M P (MulOneClass.toMul.{u3} M _inst_1) (MulOneClass.toMul.{u1} P _inst_3) (MonoidHomClass.toMulHomClass.{max u3 u1, u3, u1} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (MonoidHom.monoidHomClass.{u3, u1} M P _inst_1 _inst_3))) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N P (MulOneClass.toMul.{u2} N _inst_2) (MulOneClass.toMul.{u1} P _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} N P _inst_2 _inst_3))) g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u3} M _inst_1) (MulOneClass.toMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u3 u2, u3, u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u3, u2} M N _inst_1 _inst_2))) f x))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_apply MonoidHom.comp_applyₓ'. -/\n@[to_additive]\ntheorem MonoidHom.comp_apply [MulOneClass M] [MulOneClass N] [MulOneClass P] (g : N →* P)\n    (f : M →* N) (x : M) : g.comp f x = g (f x) :=\n  rfl\n#align monoid_hom.comp_apply MonoidHom.comp_apply\n#align add_monoid_hom.comp_apply AddMonoidHom.comp_apply\n\n/- warning: monoid_with_zero_hom.comp_apply -> MonoidWithZeroHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u3} P] (g : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u3} P (coeFn.{max (succ u3) (succ u1), max (succ u1) (succ u3)} (MonoidWithZeroHom.{u1, u3} M P _inst_1 _inst_3) (fun (_x : MonoidWithZeroHom.{u1, u3} M P _inst_1 _inst_3) => M -> P) (MonoidWithZeroHom.hasCoeToFun.{u1, u3} M P _inst_1 _inst_3) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f) x) (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MonoidWithZeroHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulZeroOneClass.{u3} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u1} P] (g : MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) (f : MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) x) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => P) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M P (MulOneClass.toMul.{u3} M (MulZeroOneClass.toMulOneClass.{u3} M _inst_1)) (MulOneClass.toMul.{u1} P (MulZeroOneClass.toMulOneClass.{u1} P _inst_3)) (MonoidHomClass.toMulHomClass.{max u3 u1, u3, u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M P (MulZeroOneClass.toMulOneClass.{u3} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} P _inst_3) (MonoidWithZeroHomClass.toMonoidHomClass.{max u3 u1, u3, u1} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) M P _inst_1 _inst_3 (MonoidWithZeroHom.monoidWithZeroHomClass.{u3, u1} M P _inst_1 _inst_3)))) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P (MulOneClass.toMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MulOneClass.toMul.{u1} P (MulZeroOneClass.toMulOneClass.{u1} P _inst_3)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MulZeroOneClass.toMulOneClass.{u1} P _inst_3) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} N P _inst_2 _inst_3)))) g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u3} M (MulZeroOneClass.toMulOneClass.{u3} M _inst_1)) (MulOneClass.toMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u3} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u3, u2} M N _inst_1 _inst_2)))) f x))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.comp_apply MonoidWithZeroHom.comp_applyₓ'. -/\ntheorem MonoidWithZeroHom.comp_apply [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    (g : N →*₀ P) (f : M →*₀ N) (x : M) : g.comp f x = g (f x) :=\n  rfl\n#align monoid_with_zero_hom.comp_apply MonoidWithZeroHom.comp_apply\n\n/- warning: one_hom.comp_assoc -> OneHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} {Q : Type.{u4}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u3} P] [_inst_4 : One.{u4} Q] (f : OneHom.{u1, u2} M N _inst_1 _inst_2) (g : OneHom.{u2, u3} N P _inst_2 _inst_3) (h : OneHom.{u3, u4} P Q _inst_3 _inst_4), Eq.{max (succ u4) (succ u1)} (OneHom.{u1, u4} M Q _inst_1 _inst_4) (OneHom.comp.{u1, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (OneHom.comp.{u2, u3, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (OneHom.comp.{u1, u3, u4} M P Q _inst_1 _inst_3 _inst_4 h (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} {Q : Type.{u4}} [_inst_1 : One.{u3} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u1} P] [_inst_4 : One.{u4} Q] (f : OneHom.{u3, u2} M N _inst_1 _inst_2) (g : OneHom.{u2, u1} N P _inst_2 _inst_3) (h : OneHom.{u1, u4} P Q _inst_3 _inst_4), Eq.{max (succ u3) (succ u4)} (OneHom.{u3, u4} M Q _inst_1 _inst_4) (OneHom.comp.{u3, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (OneHom.comp.{u2, u1, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (OneHom.comp.{u3, u1, u4} M P Q _inst_1 _inst_3 _inst_4 h (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f))\nCase conversion may be inaccurate. Consider using '#align one_hom.comp_assoc OneHom.comp_assocₓ'. -/\n/-- Composition of monoid homomorphisms is associative. -/\n@[to_additive \"Composition of additive monoid homomorphisms is associative.\"]\ntheorem OneHom.comp_assoc {Q : Type _} [One M] [One N] [One P] [One Q] (f : OneHom M N)\n    (g : OneHom N P) (h : OneHom P Q) : (h.comp g).comp f = h.comp (g.comp f) :=\n  rfl\n#align one_hom.comp_assoc OneHom.comp_assoc\n#align zero_hom.comp_assoc ZeroHom.comp_assoc\n\n/- warning: mul_hom.comp_assoc -> MulHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} {Q : Type.{u4}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u3} P] [_inst_4 : Mul.{u4} Q] (f : MulHom.{u1, u2} M N _inst_1 _inst_2) (g : MulHom.{u2, u3} N P _inst_2 _inst_3) (h : MulHom.{u3, u4} P Q _inst_3 _inst_4), Eq.{max (succ u4) (succ u1)} (MulHom.{u1, u4} M Q _inst_1 _inst_4) (MulHom.comp.{u1, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (MulHom.comp.{u2, u3, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (MulHom.comp.{u1, u3, u4} M P Q _inst_1 _inst_3 _inst_4 h (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} {Q : Type.{u4}} [_inst_1 : Mul.{u3} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u1} P] [_inst_4 : Mul.{u4} Q] (f : MulHom.{u3, u2} M N _inst_1 _inst_2) (g : MulHom.{u2, u1} N P _inst_2 _inst_3) (h : MulHom.{u1, u4} P Q _inst_3 _inst_4), Eq.{max (succ u3) (succ u4)} (MulHom.{u3, u4} M Q _inst_1 _inst_4) (MulHom.comp.{u3, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (MulHom.comp.{u2, u1, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (MulHom.comp.{u3, u1, u4} M P Q _inst_1 _inst_3 _inst_4 h (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f))\nCase conversion may be inaccurate. Consider using '#align mul_hom.comp_assoc MulHom.comp_assocₓ'. -/\n@[to_additive]\ntheorem MulHom.comp_assoc {Q : Type _} [Mul M] [Mul N] [Mul P] [Mul Q] (f : M →ₙ* N) (g : N →ₙ* P)\n    (h : P →ₙ* Q) : (h.comp g).comp f = h.comp (g.comp f) :=\n  rfl\n#align mul_hom.comp_assoc MulHom.comp_assoc\n#align add_hom.comp_assoc AddHom.comp_assoc\n\n/- warning: monoid_hom.comp_assoc -> MonoidHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} {Q : Type.{u4}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u3} P] [_inst_4 : MulOneClass.{u4} Q] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2) (g : MonoidHom.{u2, u3} N P _inst_2 _inst_3) (h : MonoidHom.{u3, u4} P Q _inst_3 _inst_4), Eq.{max (succ u4) (succ u1)} (MonoidHom.{u1, u4} M Q _inst_1 _inst_4) (MonoidHom.comp.{u1, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (MonoidHom.comp.{u2, u3, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (MonoidHom.comp.{u1, u3, u4} M P Q _inst_1 _inst_3 _inst_4 h (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} {Q : Type.{u4}} [_inst_1 : MulOneClass.{u3} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u1} P] [_inst_4 : MulOneClass.{u4} Q] (f : MonoidHom.{u3, u2} M N _inst_1 _inst_2) (g : MonoidHom.{u2, u1} N P _inst_2 _inst_3) (h : MonoidHom.{u1, u4} P Q _inst_3 _inst_4), Eq.{max (succ u3) (succ u4)} (MonoidHom.{u3, u4} M Q _inst_1 _inst_4) (MonoidHom.comp.{u3, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (MonoidHom.comp.{u2, u1, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (MonoidHom.comp.{u3, u1, u4} M P Q _inst_1 _inst_3 _inst_4 h (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_assoc MonoidHom.comp_assocₓ'. -/\n@[to_additive]\ntheorem MonoidHom.comp_assoc {Q : Type _} [MulOneClass M] [MulOneClass N] [MulOneClass P]\n    [MulOneClass Q] (f : M →* N) (g : N →* P) (h : P →* Q) :\n    (h.comp g).comp f = h.comp (g.comp f) :=\n  rfl\n#align monoid_hom.comp_assoc MonoidHom.comp_assoc\n#align add_monoid_hom.comp_assoc AddMonoidHom.comp_assoc\n\n/- warning: monoid_with_zero_hom.comp_assoc -> MonoidWithZeroHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} {Q : Type.{u4}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u3} P] [_inst_4 : MulZeroOneClass.{u4} Q] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (g : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) (h : MonoidWithZeroHom.{u3, u4} P Q _inst_3 _inst_4), Eq.{max (succ u4) (succ u1)} (MonoidWithZeroHom.{u1, u4} M Q _inst_1 _inst_4) (MonoidWithZeroHom.comp.{u1, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (MonoidWithZeroHom.comp.{u2, u3, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (MonoidWithZeroHom.comp.{u1, u3, u4} M P Q _inst_1 _inst_3 _inst_4 h (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} {Q : Type.{u4}} [_inst_1 : MulZeroOneClass.{u3} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u1} P] [_inst_4 : MulZeroOneClass.{u4} Q] (f : MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) (g : MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) (h : MonoidWithZeroHom.{u1, u4} P Q _inst_3 _inst_4), Eq.{max (succ u3) (succ u4)} (MonoidWithZeroHom.{u3, u4} M Q _inst_1 _inst_4) (MonoidWithZeroHom.comp.{u3, u2, u4} M N Q _inst_1 _inst_2 _inst_4 (MonoidWithZeroHom.comp.{u2, u1, u4} N P Q _inst_2 _inst_3 _inst_4 h g) f) (MonoidWithZeroHom.comp.{u3, u1, u4} M P Q _inst_1 _inst_3 _inst_4 h (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.comp_assoc MonoidWithZeroHom.comp_assocₓ'. -/\ntheorem MonoidWithZeroHom.comp_assoc {Q : Type _} [MulZeroOneClass M] [MulZeroOneClass N]\n    [MulZeroOneClass P] [MulZeroOneClass Q] (f : M →*₀ N) (g : N →*₀ P) (h : P →*₀ Q) :\n    (h.comp g).comp f = h.comp (g.comp f) :=\n  rfl\n#align monoid_with_zero_hom.comp_assoc MonoidWithZeroHom.comp_assoc\n\n/- warning: one_hom.cancel_right -> OneHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u3} P] {g₁ : OneHom.{u2, u3} N P _inst_2 _inst_3} {g₂ : OneHom.{u2, u3} N P _inst_2 _inst_3} {f : OneHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u1, succ u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (OneHom.{u1, u3} M P _inst_1 _inst_3) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₁ f) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u3) (succ u2)} (OneHom.{u2, u3} N P _inst_2 _inst_3) g₁ g₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : One.{u3} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u1} P] {g₁ : OneHom.{u2, u1} N P _inst_2 _inst_3} {g₂ : OneHom.{u2, u1} N P _inst_2 _inst_3} {f : OneHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u3, succ u2} M N (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u3 u2, u3, u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u3, u2} M N _inst_1 _inst_2)) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (OneHom.{u3, u1} M P _inst_1 _inst_3) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₁ f) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} N P _inst_2 _inst_3) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align one_hom.cancel_right OneHom.cancel_rightₓ'. -/\n@[to_additive]\ntheorem OneHom.cancel_right [One M] [One N] [One P] {g₁ g₂ : OneHom N P} {f : OneHom M N}\n    (hf : Function.Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => OneHom.ext <| hf.forall.2 (OneHom.ext_iff.1 h), fun h => h ▸ rfl⟩\n#align one_hom.cancel_right OneHom.cancel_right\n#align zero_hom.cancel_right ZeroHom.cancel_right\n\n/- warning: mul_hom.cancel_right -> MulHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u3} P] {g₁ : MulHom.{u2, u3} N P _inst_2 _inst_3} {g₂ : MulHom.{u2, u3} N P _inst_2 _inst_3} {f : MulHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u1, succ u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MulHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MulHom.{u1, u3} M P _inst_1 _inst_3) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₁ f) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u3) (succ u2)} (MulHom.{u2, u3} N P _inst_2 _inst_3) g₁ g₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : Mul.{u3} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u1} P] {g₁ : MulHom.{u2, u1} N P _inst_2 _inst_3} {g₂ : MulHom.{u2, u1} N P _inst_2 _inst_3} {f : MulHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u3, succ u2} M N (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MulHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MulHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MulHom.mulHomClass.{u3, u2} M N _inst_1 _inst_2)) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MulHom.{u3, u1} M P _inst_1 _inst_3) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₁ f) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} N P _inst_2 _inst_3) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align mul_hom.cancel_right MulHom.cancel_rightₓ'. -/\n@[to_additive]\ntheorem MulHom.cancel_right [Mul M] [Mul N] [Mul P] {g₁ g₂ : N →ₙ* P} {f : M →ₙ* N}\n    (hf : Function.Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => MulHom.ext <| hf.forall.2 (MulHom.ext_iff.1 h), fun h => h ▸ rfl⟩\n#align mul_hom.cancel_right MulHom.cancel_right\n#align add_hom.cancel_right AddHom.cancel_right\n\n/- warning: monoid_hom.cancel_right -> MonoidHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u3} P] {g₁ : MonoidHom.{u2, u3} N P _inst_2 _inst_3} {g₂ : MonoidHom.{u2, u3} N P _inst_2 _inst_3} {f : MonoidHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u1, succ u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M P _inst_1 _inst_3) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₁ f) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u3) (succ u2)} (MonoidHom.{u2, u3} N P _inst_2 _inst_3) g₁ g₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulOneClass.{u3} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u1} P] {g₁ : MonoidHom.{u2, u1} N P _inst_2 _inst_3} {g₂ : MonoidHom.{u2, u1} N P _inst_2 _inst_3} {f : MonoidHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u3, succ u2} M N (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u3} M _inst_1) (MulOneClass.toMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u3 u2, u3, u2} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u3, u2} M N _inst_1 _inst_2))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₁ f) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.cancel_right MonoidHom.cancel_rightₓ'. -/\n@[to_additive]\ntheorem MonoidHom.cancel_right [MulOneClass M] [MulOneClass N] [MulOneClass P] {g₁ g₂ : N →* P}\n    {f : M →* N} (hf : Function.Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => MonoidHom.ext <| hf.forall.2 (MonoidHom.ext_iff.1 h), fun h => h ▸ rfl⟩\n#align monoid_hom.cancel_right MonoidHom.cancel_right\n#align add_monoid_hom.cancel_right AddMonoidHom.cancel_right\n\n/- warning: monoid_with_zero_hom.cancel_right -> MonoidWithZeroHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u3} P] {g₁ : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3} {g₂ : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3} {f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u1, succ u2} M N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidWithZeroHom.{u1, u3} M P _inst_1 _inst_3) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₁ f) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u3) (succ u2)} (MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) g₁ g₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulZeroOneClass.{u3} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u1} P] {g₁ : MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3} {g₂ : MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3} {f : MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Surjective.{succ u3, succ u2} M N (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u3} M (MulZeroOneClass.toMulOneClass.{u3} M _inst_1)) (MulOneClass.toMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N (MulZeroOneClass.toMulOneClass.{u3} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MonoidWithZeroHomClass.toMonoidHomClass.{max u3 u2, u3, u2} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidWithZeroHom.monoidWithZeroHomClass.{u3, u2} M N _inst_1 _inst_2)))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₁ f) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.cancel_right MonoidWithZeroHom.cancel_rightₓ'. -/\ntheorem MonoidWithZeroHom.cancel_right [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    {g₁ g₂ : N →*₀ P} {f : M →*₀ N} (hf : Function.Surjective f) :\n    g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => MonoidWithZeroHom.ext <| hf.forall.2 (MonoidWithZeroHom.ext_iff.1 h), fun h => h ▸ rfl⟩\n#align monoid_with_zero_hom.cancel_right MonoidWithZeroHom.cancel_right\n\n/- warning: one_hom.cancel_left -> OneHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u3} P] {g : OneHom.{u2, u3} N P _inst_2 _inst_3} {f₁ : OneHom.{u1, u2} M N _inst_1 _inst_2} {f₂ : OneHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u3} N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (OneHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : OneHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (OneHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (OneHom.{u1, u3} M P _inst_1 _inst_3) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₁) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) f₁ f₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : One.{u3} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u1} P] {g : OneHom.{u2, u1} N P _inst_2 _inst_3} {f₁ : OneHom.{u3, u2} M N _inst_1 _inst_2} {f₂ : OneHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u1} N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : N) => P) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (OneHom.oneHomClass.{u2, u1} N P _inst_2 _inst_3)) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (OneHom.{u3, u1} M P _inst_1 _inst_3) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₁) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u3) (succ u2)} (OneHom.{u3, u2} M N _inst_1 _inst_2) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align one_hom.cancel_left OneHom.cancel_leftₓ'. -/\n@[to_additive]\ntheorem OneHom.cancel_left [One M] [One N] [One P] {g : OneHom N P} {f₁ f₂ : OneHom M N}\n    (hg : Function.Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => OneHom.ext fun x => hg <| by rw [← OneHom.comp_apply, h, OneHom.comp_apply], fun h =>\n    h ▸ rfl⟩\n#align one_hom.cancel_left OneHom.cancel_left\n#align zero_hom.cancel_left ZeroHom.cancel_left\n\n/- warning: mul_hom.cancel_left -> MulHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u3} P] {g : MulHom.{u2, u3} N P _inst_2 _inst_3} {f₁ : MulHom.{u1, u2} M N _inst_1 _inst_2} {f₂ : MulHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u3} N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MulHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MulHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MulHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MulHom.{u1, u3} M P _inst_1 _inst_3) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₁) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) f₁ f₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : Mul.{u3} M] [_inst_2 : Mul.{u2} N] [_inst_3 : Mul.{u1} P] {g : MulHom.{u2, u1} N P _inst_2 _inst_3} {f₁ : MulHom.{u3, u2} M N _inst_1 _inst_2} {f₂ : MulHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u1} N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MulHom.mulHomClass.{u2, u1} N P _inst_2 _inst_3)) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MulHom.{u3, u1} M P _inst_1 _inst_3) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₁) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u3) (succ u2)} (MulHom.{u3, u2} M N _inst_1 _inst_2) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align mul_hom.cancel_left MulHom.cancel_leftₓ'. -/\n@[to_additive]\ntheorem MulHom.cancel_left [Mul M] [Mul N] [Mul P] {g : N →ₙ* P} {f₁ f₂ : M →ₙ* N}\n    (hg : Function.Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => MulHom.ext fun x => hg <| by rw [← MulHom.comp_apply, h, MulHom.comp_apply], fun h =>\n    h ▸ rfl⟩\n#align mul_hom.cancel_left MulHom.cancel_left\n#align add_hom.cancel_left AddHom.cancel_left\n\n/- warning: monoid_hom.cancel_left -> MonoidHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u3} P] {g : MonoidHom.{u2, u3} N P _inst_2 _inst_3} {f₁ : MonoidHom.{u1, u2} M N _inst_1 _inst_2} {f₂ : MonoidHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u3} N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MonoidHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MonoidHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MonoidHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M P _inst_1 _inst_3) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₁) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) f₁ f₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulOneClass.{u3} M] [_inst_2 : MulOneClass.{u2} N] [_inst_3 : MulOneClass.{u1} P] {g : MonoidHom.{u2, u1} N P _inst_2 _inst_3} {f₁ : MonoidHom.{u3, u2} M N _inst_1 _inst_2} {f₂ : MonoidHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u1} N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N P (MulOneClass.toMul.{u2} N _inst_2) (MulOneClass.toMul.{u1} P _inst_3) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MonoidHom.monoidHomClass.{u2, u1} N P _inst_2 _inst_3))) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M P _inst_1 _inst_3) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₁) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u3) (succ u2)} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.cancel_left MonoidHom.cancel_leftₓ'. -/\n@[to_additive]\ntheorem MonoidHom.cancel_left [MulOneClass M] [MulOneClass N] [MulOneClass P] {g : N →* P}\n    {f₁ f₂ : M →* N} (hg : Function.Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => MonoidHom.ext fun x => hg <| by rw [← MonoidHom.comp_apply, h, MonoidHom.comp_apply],\n    fun h => h ▸ rfl⟩\n#align monoid_hom.cancel_left MonoidHom.cancel_left\n#align add_monoid_hom.cancel_left AddMonoidHom.cancel_left\n\n/- warning: monoid_with_zero_hom.cancel_left -> MonoidWithZeroHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u3} P] {g : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3} {f₁ : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2} {f₂ : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u3} N P (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) (fun (_x : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) => N -> P) (MonoidWithZeroHom.hasCoeToFun.{u2, u3} N P _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidWithZeroHom.{u1, u3} M P _inst_1 _inst_3) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₁) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) f₁ f₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : MulZeroOneClass.{u3} M] [_inst_2 : MulZeroOneClass.{u2} N] [_inst_3 : MulZeroOneClass.{u1} P] {g : MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3} {f₁ : MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2} {f₂ : MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2}, (Function.Injective.{succ u2, succ u1} N P (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N) => P) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P (MulOneClass.toMul.{u2} N (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MulOneClass.toMul.{u1} P (MulZeroOneClass.toMulOneClass.{u1} P _inst_3)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P (MulZeroOneClass.toMulOneClass.{u2} N _inst_2) (MulZeroOneClass.toMulOneClass.{u1} P _inst_3) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) N P _inst_2 _inst_3 (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} N P _inst_2 _inst_3)))) g)) -> (Iff (Eq.{max (succ u3) (succ u1)} (MonoidWithZeroHom.{u3, u1} M P _inst_1 _inst_3) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₁) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u3) (succ u2)} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.cancel_left MonoidWithZeroHom.cancel_leftₓ'. -/\ntheorem MonoidWithZeroHom.cancel_left [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    {g : N →*₀ P} {f₁ f₂ : M →*₀ N} (hg : Function.Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h =>\n    MonoidWithZeroHom.ext fun x =>\n      hg <| by rw [← MonoidWithZeroHom.comp_apply, h, MonoidWithZeroHom.comp_apply],\n    fun h => h ▸ rfl⟩\n#align monoid_with_zero_hom.cancel_left MonoidWithZeroHom.cancel_left\n\n/- warning: monoid_hom.to_one_hom_injective -> MonoidHom.toOneHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.{u1, u2} M N (MulOneClass.toHasOne.{u1} M _inst_1) (MulOneClass.toHasOne.{u2} N _inst_2)) (MonoidHom.toOneHom.{u1, u2} M N _inst_1 _inst_2)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (OneHom.{u2, u1} M N (MulOneClass.toOne.{u2} M _inst_1) (MulOneClass.toOne.{u1} N _inst_2)) (MonoidHom.toOneHom.{u2, u1} M N _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.to_one_hom_injective MonoidHom.toOneHom_injectiveₓ'. -/\n@[to_additive]\ntheorem MonoidHom.toOneHom_injective [MulOneClass M] [MulOneClass N] :\n    Function.Injective (MonoidHom.toOneHom : (M →* N) → OneHom M N) := fun f g h =>\n  MonoidHom.ext <| OneHom.ext_iff.mp h\n#align monoid_hom.to_one_hom_injective MonoidHom.toOneHom_injective\n#align add_monoid_hom.to_zero_hom_injective AddMonoidHom.toZeroHom_injective\n\n/- warning: monoid_hom.to_mul_hom_injective -> MonoidHom.toMulHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (MulHom.{u1, u2} M N (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u2} N _inst_2)) (MonoidHom.toMulHom.{u1, u2} M N _inst_1 _inst_2)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MulHom.{u2, u1} M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2)) (MonoidHom.toMulHom.{u2, u1} M N _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.to_mul_hom_injective MonoidHom.toMulHom_injectiveₓ'. -/\n@[to_additive]\ntheorem MonoidHom.toMulHom_injective [MulOneClass M] [MulOneClass N] :\n    Function.Injective (MonoidHom.toMulHom : (M →* N) → M →ₙ* N) := fun f g h =>\n  MonoidHom.ext <| MulHom.ext_iff.mp h\n#align monoid_hom.to_mul_hom_injective MonoidHom.toMulHom_injective\n#align add_monoid_hom.to_add_hom_injective AddMonoidHom.toAddHom_injective\n\n/- warning: monoid_with_zero_hom.to_monoid_hom_injective -> MonoidWithZeroHom.toMonoidHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.{u1, u2} M N (MulZeroOneClass.toMulOneClass.{u1} M _inst_1) (MulZeroOneClass.toMulOneClass.{u2} N _inst_2)) (MonoidWithZeroHom.toMonoidHom.{u1, u2} M N _inst_1 _inst_2)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MonoidHom.{u2, u1} M N (MulZeroOneClass.toMulOneClass.{u2} M _inst_1) (MulZeroOneClass.toMulOneClass.{u1} N _inst_2)) (MonoidWithZeroHom.toMonoidHom.{u2, u1} M N _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.to_monoid_hom_injective MonoidWithZeroHom.toMonoidHom_injectiveₓ'. -/\ntheorem MonoidWithZeroHom.toMonoidHom_injective [MulZeroOneClass M] [MulZeroOneClass N] :\n    Function.Injective (MonoidWithZeroHom.toMonoidHom : (M →*₀ N) → M →* N) := fun f g h =>\n  MonoidWithZeroHom.ext <| MonoidHom.ext_iff.mp h\n#align monoid_with_zero_hom.to_monoid_hom_injective MonoidWithZeroHom.toMonoidHom_injective\n\n/- warning: monoid_with_zero_hom.to_zero_hom_injective -> MonoidWithZeroHom.toZeroHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (ZeroHom.{u1, u2} M N (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M _inst_1)) (MulZeroClass.toHasZero.{u2} N (MulZeroOneClass.toMulZeroClass.{u2} N _inst_2))) (MonoidWithZeroHom.toZeroHom.{u1, u2} M N _inst_1 _inst_2)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (ZeroHom.{u2, u1} M N (MulZeroOneClass.toZero.{u2} M _inst_1) (MulZeroOneClass.toZero.{u1} N _inst_2)) (MonoidWithZeroHom.toZeroHom.{u2, u1} M N _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.to_zero_hom_injective MonoidWithZeroHom.toZeroHom_injectiveₓ'. -/\ntheorem MonoidWithZeroHom.toZeroHom_injective [MulZeroOneClass M] [MulZeroOneClass N] :\n    Function.Injective (MonoidWithZeroHom.toZeroHom : (M →*₀ N) → ZeroHom M N) := fun f g h =>\n  MonoidWithZeroHom.ext <| ZeroHom.ext_iff.mp h\n#align monoid_with_zero_hom.to_zero_hom_injective MonoidWithZeroHom.toZeroHom_injective\n\n/- warning: one_hom.comp_id -> OneHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (f : OneHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.comp.{u1, u1, u2} M M N _inst_1 _inst_1 _inst_2 f (OneHom.id.{u1} M _inst_1)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (f : OneHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N _inst_1 _inst_2) (OneHom.comp.{u2, u2, u1} M M N _inst_1 _inst_1 _inst_2 f (OneHom.id.{u2} M _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align one_hom.comp_id OneHom.comp_idₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.comp_id [One M] [One N] (f : OneHom M N) : f.comp (OneHom.id M) = f :=\n  OneHom.ext fun x => rfl\n#align one_hom.comp_id OneHom.comp_id\n#align zero_hom.comp_id ZeroHom.comp_id\n\n/- warning: mul_hom.comp_id -> MulHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] (f : MulHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (MulHom.comp.{u1, u1, u2} M M N _inst_1 _inst_1 _inst_2 f (MulHom.id.{u1} M _inst_1)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] (f : MulHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N _inst_1 _inst_2) (MulHom.comp.{u2, u2, u1} M M N _inst_1 _inst_1 _inst_2 f (MulHom.id.{u2} M _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align mul_hom.comp_id MulHom.comp_idₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.comp_id [Mul M] [Mul N] (f : M →ₙ* N) : f.comp (MulHom.id M) = f :=\n  MulHom.ext fun x => rfl\n#align mul_hom.comp_id MulHom.comp_id\n#align add_hom.comp_id AddHom.comp_id\n\n/- warning: monoid_hom.comp_id -> MonoidHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.comp.{u1, u1, u2} M M N _inst_1 _inst_1 _inst_2 f (MonoidHom.id.{u1} M _inst_1)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MonoidHom.comp.{u2, u2, u1} M M N _inst_1 _inst_1 _inst_2 f (MonoidHom.id.{u2} M _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_id MonoidHom.comp_idₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.comp_id [MulOneClass M] [MulOneClass N] (f : M →* N) :\n    f.comp (MonoidHom.id M) = f :=\n  MonoidHom.ext fun x => rfl\n#align monoid_hom.comp_id MonoidHom.comp_id\n#align add_monoid_hom.comp_id AddMonoidHom.comp_id\n\n/- warning: monoid_with_zero_hom.comp_id -> MonoidWithZeroHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (MonoidWithZeroHom.comp.{u1, u1, u2} M M N _inst_1 _inst_1 _inst_2 f (MonoidWithZeroHom.id.{u1} M _inst_1)) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MonoidWithZeroHom.comp.{u2, u2, u1} M M N _inst_1 _inst_1 _inst_2 f (MonoidWithZeroHom.id.{u2} M _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.comp_id MonoidWithZeroHom.comp_idₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.comp_id [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) :\n    f.comp (MonoidWithZeroHom.id M) = f :=\n  MonoidWithZeroHom.ext fun x => rfl\n#align monoid_with_zero_hom.comp_id MonoidWithZeroHom.comp_id\n\n/- warning: one_hom.id_comp -> OneHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (f : OneHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.comp.{u1, u2, u2} M N N _inst_1 _inst_2 _inst_2 (OneHom.id.{u2} N _inst_2) f) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (f : OneHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} M N _inst_1 _inst_2) (OneHom.comp.{u2, u1, u1} M N N _inst_1 _inst_2 _inst_2 (OneHom.id.{u1} N _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align one_hom.id_comp OneHom.id_compₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.id_comp [One M] [One N] (f : OneHom M N) : (OneHom.id N).comp f = f :=\n  OneHom.ext fun x => rfl\n#align one_hom.id_comp OneHom.id_comp\n#align zero_hom.id_comp ZeroHom.id_comp\n\n/- warning: mul_hom.id_comp -> MulHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] (f : MulHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) (MulHom.comp.{u1, u2, u2} M N N _inst_1 _inst_2 _inst_2 (MulHom.id.{u2} N _inst_2) f) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] (f : MulHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} M N _inst_1 _inst_2) (MulHom.comp.{u2, u1, u1} M N N _inst_1 _inst_2 _inst_2 (MulHom.id.{u1} N _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align mul_hom.id_comp MulHom.id_compₓ'. -/\n@[simp, to_additive]\ntheorem MulHom.id_comp [Mul M] [Mul N] (f : M →ₙ* N) : (MulHom.id N).comp f = f :=\n  MulHom.ext fun x => rfl\n#align mul_hom.id_comp MulHom.id_comp\n#align add_hom.id_comp AddHom.id_comp\n\n/- warning: monoid_hom.id_comp -> MonoidHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.comp.{u1, u2, u2} M N N _inst_1 _inst_2 _inst_2 (MonoidHom.id.{u2} N _inst_2) f) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (f : MonoidHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (MonoidHom.comp.{u2, u1, u1} M N N _inst_1 _inst_2 _inst_2 (MonoidHom.id.{u1} N _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.id_comp MonoidHom.id_compₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.id_comp [MulOneClass M] [MulOneClass N] (f : M →* N) :\n    (MonoidHom.id N).comp f = f :=\n  MonoidHom.ext fun x => rfl\n#align monoid_hom.id_comp MonoidHom.id_comp\n#align add_monoid_hom.id_comp AddMonoidHom.id_comp\n\n/- warning: monoid_with_zero_hom.id_comp -> MonoidWithZeroHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulZeroOneClass.{u1} M] [_inst_2 : MulZeroOneClass.{u2} N] (f : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) (MonoidWithZeroHom.comp.{u1, u2, u2} M N N _inst_1 _inst_2 _inst_2 (MonoidWithZeroHom.id.{u2} N _inst_2) f) f\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulZeroOneClass.{u2} M] [_inst_2 : MulZeroOneClass.{u1} N] (f : MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} M N _inst_1 _inst_2) (MonoidWithZeroHom.comp.{u2, u1, u1} M N N _inst_1 _inst_2 _inst_2 (MonoidWithZeroHom.id.{u1} N _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.id_comp MonoidWithZeroHom.id_compₓ'. -/\n@[simp]\ntheorem MonoidWithZeroHom.id_comp [MulZeroOneClass M] [MulZeroOneClass N] (f : M →*₀ N) :\n    (MonoidWithZeroHom.id N).comp f = f :=\n  MonoidWithZeroHom.ext fun x => rfl\n#align monoid_with_zero_hom.id_comp MonoidWithZeroHom.id_comp\n\n/- warning: monoid_hom.map_pow -> MonoidHom.map_pow is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Monoid.{u2} N] (f : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) (a : M) (n : Nat), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) f (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n)) (HPow.hPow.{u2, 0, u2} N Nat N (instHPow.{u2, 0} N Nat (Monoid.Pow.{u2} N _inst_2)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M _inst_1) (Monoid.toMulOneClass.{u2} N _inst_2)) f a) n)\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Monoid.{u2} M] [_inst_2 : Monoid.{u1} N] (f : MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) (a : M) (n : Nat), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (HPow.hPow.{u2, 0, u2} M Nat M (instHPow.{u2, 0} M Nat (Monoid.Pow.{u2} M _inst_1)) a n)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)))) f (HPow.hPow.{u2, 0, u2} M Nat M (instHPow.{u2, 0} M Nat (Monoid.Pow.{u2} M _inst_1)) a n)) (HPow.hPow.{u1, 0, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) Nat ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (instHPow.{u1, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) Nat (Monoid.Pow.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)) M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M _inst_1) (Monoid.toMulOneClass.{u1} N _inst_2)))) f a) n)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_pow MonoidHom.map_powₓ'. -/\n@[to_additive AddMonoidHom.map_nsmul]\nprotected theorem MonoidHom.map_pow [Monoid M] [Monoid N] (f : M →* N) (a : M) (n : ℕ) :\n    f (a ^ n) = f a ^ n :=\n  map_pow f a n\n#align monoid_hom.map_pow MonoidHom.map_pow\n#align add_monoid_hom.map_nsmul AddMonoidHom.map_nsmul\n\n/- warning: monoid_hom.map_zpow' -> MonoidHom.map_zpow' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : DivInvMonoid.{u1} M] [_inst_2 : DivInvMonoid.{u2} N] (f : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))), (forall (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) f (Inv.inv.{u1} M (DivInvMonoid.toHasInv.{u1} M _inst_1) x)) (Inv.inv.{u2} N (DivInvMonoid.toHasInv.{u2} N _inst_2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) f x))) -> (forall (a : M) (n : Int), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) f (HPow.hPow.{u1, 0, u1} M Int M (instHPow.{u1, 0} M Int (DivInvMonoid.Pow.{u1} M _inst_1)) a n)) (HPow.hPow.{u2, 0, u2} N Int N (instHPow.{u2, 0} N Int (DivInvMonoid.Pow.{u2} N _inst_2)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) (fun (_x : MonoidHom.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1)) (Monoid.toMulOneClass.{u2} N (DivInvMonoid.toMonoid.{u2} N _inst_2))) f a) n))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : DivInvMonoid.{u2} M] [_inst_2 : DivInvMonoid.{u1} N] (f : MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))), (forall (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (Inv.inv.{u2} M (DivInvMonoid.toInv.{u2} M _inst_1) x)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1))) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2)) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))))) f (Inv.inv.{u2} M (DivInvMonoid.toInv.{u2} M _inst_1) x)) (Inv.inv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (DivInvMonoid.toInv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) _inst_2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1))) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2)) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))))) f x))) -> (forall (a : M) (n : Int), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) (HPow.hPow.{u2, 0, u2} M Int M (instHPow.{u2, 0} M Int (DivInvMonoid.Pow.{u2} M _inst_1)) a n)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1))) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2)) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))))) f (HPow.hPow.{u2, 0, u2} M Int M (instHPow.{u2, 0} M Int (DivInvMonoid.Pow.{u2} M _inst_1)) a n)) (HPow.hPow.{u1, 0, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) Int ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) (instHPow.{u1, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) Int (DivInvMonoid.Pow.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1))) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))) M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2)) (MonoidHom.monoidHomClass.{u2, u1} M N (Monoid.toMulOneClass.{u2} M (DivInvMonoid.toMonoid.{u2} M _inst_1)) (Monoid.toMulOneClass.{u1} N (DivInvMonoid.toMonoid.{u1} N _inst_2))))) f a) n))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_zpow' MonoidHom.map_zpow'ₓ'. -/\n@[to_additive]\nprotected theorem MonoidHom.map_zpow' [DivInvMonoid M] [DivInvMonoid N] (f : M →* N)\n    (hf : ∀ x, f x⁻¹ = (f x)⁻¹) (a : M) (n : ℤ) : f (a ^ n) = f a ^ n :=\n  map_zpow' f hf a n\n#align monoid_hom.map_zpow' MonoidHom.map_zpow'\n#align add_monoid_hom.map_zsmul' AddMonoidHom.map_zsmul'\n\nsection End\n\nnamespace Monoid\n\nvariable (M) [MulOneClass M]\n\n#print Monoid.End /-\n/-- The monoid of endomorphisms. -/\nprotected def End :=\n  M →* M\n#align monoid.End Monoid.End\n-/\n\nnamespace End\n\ninstance : Monoid (Monoid.End M) where\n  mul := MonoidHom.comp\n  one := MonoidHom.id M\n  mul_assoc _ _ _ := MonoidHom.comp_assoc _ _ _\n  mul_one := MonoidHom.comp_id\n  one_mul := MonoidHom.id_comp\n\ninstance : Inhabited (Monoid.End M) :=\n  ⟨1⟩\n\ninstance : MonoidHomClass (Monoid.End M) M M :=\n  MonoidHom.monoidHomClass\n\nend End\n\n/- warning: monoid.coe_one -> Monoid.coe_one is a dubious translation:\nlean 3 declaration is\n  forall (M : Type.{u1}) [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} ((fun (_x : Monoid.End.{u1} M _inst_1) => M -> M) (OfNat.ofNat.{u1} (Monoid.End.{u1} M _inst_1) 1 (OfNat.mk.{u1} (Monoid.End.{u1} M _inst_1) 1 (One.one.{u1} (Monoid.End.{u1} M _inst_1) (MulOneClass.toHasOne.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.toMulOneClass.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.monoid.{u1} M _inst_1))))))) (coeFn.{succ u1, succ u1} (Monoid.End.{u1} M _inst_1) (fun (_x : Monoid.End.{u1} M _inst_1) => M -> M) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => M) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.monoidHomClass.{u1} M _inst_1)))) (OfNat.ofNat.{u1} (Monoid.End.{u1} M _inst_1) 1 (OfNat.mk.{u1} (Monoid.End.{u1} M _inst_1) 1 (One.one.{u1} (Monoid.End.{u1} M _inst_1) (MulOneClass.toHasOne.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.toMulOneClass.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.monoid.{u1} M _inst_1))))))) (id.{succ u1} M)\nbut is expected to have type\n  forall (M : Type.{u1}) [_inst_1 : MulOneClass.{u1} M], Eq.{succ u1} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) _x) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.instMonoidHomClassEnd.{u1} M _inst_1))) (OfNat.ofNat.{u1} (Monoid.End.{u1} M _inst_1) 1 (One.toOfNat1.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.toOne.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.instMonoidEnd.{u1} M _inst_1))))) (id.{succ u1} M)\nCase conversion may be inaccurate. Consider using '#align monoid.coe_one Monoid.coe_oneₓ'. -/\n@[simp]\ntheorem coe_one : ((1 : Monoid.End M) : M → M) = id :=\n  rfl\n#align monoid.coe_one Monoid.coe_one\n\n/- warning: monoid.coe_mul -> Monoid.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall (M : Type.{u1}) [_inst_1 : MulOneClass.{u1} M] (f : Monoid.End.{u1} M _inst_1) (g : Monoid.End.{u1} M _inst_1), Eq.{succ u1} ((fun (_x : Monoid.End.{u1} M _inst_1) => M -> M) (HMul.hMul.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.{u1} M _inst_1) (Monoid.End.{u1} M _inst_1) (instHMul.{u1} (Monoid.End.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.toMulOneClass.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.monoid.{u1} M _inst_1)))) f g)) (coeFn.{succ u1, succ u1} (Monoid.End.{u1} M _inst_1) (fun (_x : Monoid.End.{u1} M _inst_1) => M -> M) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => M) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.monoidHomClass.{u1} M _inst_1)))) (HMul.hMul.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.{u1} M _inst_1) (Monoid.End.{u1} M _inst_1) (instHMul.{u1} (Monoid.End.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.toMulOneClass.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.monoid.{u1} M _inst_1)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} M M M (coeFn.{succ u1, succ u1} (Monoid.End.{u1} M _inst_1) (fun (_x : Monoid.End.{u1} M _inst_1) => M -> M) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => M) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.monoidHomClass.{u1} M _inst_1)))) f) (coeFn.{succ u1, succ u1} (Monoid.End.{u1} M _inst_1) (fun (_x : Monoid.End.{u1} M _inst_1) => M -> M) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => M) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toHasMul.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.monoidHomClass.{u1} M _inst_1)))) g))\nbut is expected to have type\n  forall (M : Type.{u1}) [_inst_1 : MulOneClass.{u1} M] (f : Monoid.End.{u1} M _inst_1) (g : Monoid.End.{u1} M _inst_1), Eq.{succ u1} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) _x) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.instMonoidHomClassEnd.{u1} M _inst_1))) (HMul.hMul.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.{u1} M _inst_1) (Monoid.End.{u1} M _inst_1) (instHMul.{u1} (Monoid.End.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.toMulOneClass.{u1} (Monoid.End.{u1} M _inst_1) (Monoid.End.instMonoidEnd.{u1} M _inst_1)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} M M M (FunLike.coe.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) _x) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.instMonoidHomClassEnd.{u1} M _inst_1))) f) (FunLike.coe.{succ u1, succ u1, succ u1} (Monoid.End.{u1} M _inst_1) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) _x) (MulHomClass.toFunLike.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u1} M _inst_1) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (Monoid.End.{u1} M _inst_1) M M _inst_1 _inst_1 (Monoid.End.instMonoidHomClassEnd.{u1} M _inst_1))) g))\nCase conversion may be inaccurate. Consider using '#align monoid.coe_mul Monoid.coe_mulₓ'. -/\n@[simp]\ntheorem coe_mul (f g) : ((f * g : Monoid.End M) : M → M) = f ∘ g :=\n  rfl\n#align monoid.coe_mul Monoid.coe_mul\n\nend Monoid\n\nnamespace AddMonoid\n\nvariable (A : Type _) [AddZeroClass A]\n\n#print AddMonoid.End /-\n/-- The monoid of endomorphisms. -/\nprotected def End :=\n  A →+ A\n#align add_monoid.End AddMonoid.End\n-/\n\nnamespace End\n\ninstance : Monoid (AddMonoid.End A)\n    where\n  mul := AddMonoidHom.comp\n  one := AddMonoidHom.id A\n  mul_assoc _ _ _ := AddMonoidHom.comp_assoc _ _ _\n  mul_one := AddMonoidHom.comp_id\n  one_mul := AddMonoidHom.id_comp\n\ninstance : Inhabited (AddMonoid.End A) :=\n  ⟨1⟩\n\ninstance : AddMonoidHomClass (AddMonoid.End A) A A :=\n  AddMonoidHom.addMonoidHomClass\n\nend End\n\n/- warning: add_monoid.coe_one -> AddMonoid.coe_one is a dubious translation:\nlean 3 declaration is\n  forall (A : Type.{u1}) [_inst_1 : AddZeroClass.{u1} A], Eq.{succ u1} ((fun (_x : AddMonoid.End.{u1} A _inst_1) => A -> A) (OfNat.ofNat.{u1} (AddMonoid.End.{u1} A _inst_1) 1 (OfNat.mk.{u1} (AddMonoid.End.{u1} A _inst_1) 1 (One.one.{u1} (AddMonoid.End.{u1} A _inst_1) (MulOneClass.toHasOne.{u1} (AddMonoid.End.{u1} A _inst_1) (Monoid.toMulOneClass.{u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.monoid.{u1} A _inst_1))))))) (coeFn.{succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) (fun (_x : AddMonoid.End.{u1} A _inst_1) => A -> A) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => A) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.addMonoidHomClass.{u1} A _inst_1)))) (OfNat.ofNat.{u1} (AddMonoid.End.{u1} A _inst_1) 1 (OfNat.mk.{u1} (AddMonoid.End.{u1} A _inst_1) 1 (One.one.{u1} (AddMonoid.End.{u1} A _inst_1) (MulOneClass.toHasOne.{u1} (AddMonoid.End.{u1} A _inst_1) (Monoid.toMulOneClass.{u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.monoid.{u1} A _inst_1))))))) (id.{succ u1} A)\nbut is expected to have type\n  forall (A : Type.{u1}) [_inst_1 : AddZeroClass.{u1} A], Eq.{succ u1} (forall (a : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => A) a) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => A) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toAdd.{u1} A _inst_1) (AddZeroClass.toAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.instAddMonoidHomClassEnd.{u1} A _inst_1))) (OfNat.ofNat.{u1} (AddMonoid.End.{u1} A _inst_1) 1 (One.toOfNat1.{u1} (AddMonoid.End.{u1} A _inst_1) (Monoid.toOne.{u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.monoid.{u1} A _inst_1))))) (id.{succ u1} A)\nCase conversion may be inaccurate. Consider using '#align add_monoid.coe_one AddMonoid.coe_oneₓ'. -/\n@[simp]\ntheorem coe_one : ((1 : AddMonoid.End A) : A → A) = id :=\n  rfl\n#align add_monoid.coe_one AddMonoid.coe_one\n\n/- warning: add_monoid.coe_mul -> AddMonoid.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall (A : Type.{u1}) [_inst_1 : AddZeroClass.{u1} A] (f : AddMonoid.End.{u1} A _inst_1) (g : AddMonoid.End.{u1} A _inst_1), Eq.{succ u1} ((fun (_x : AddMonoid.End.{u1} A _inst_1) => A -> A) (HMul.hMul.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.{u1} A _inst_1) (instHMul.{u1} (AddMonoid.End.{u1} A _inst_1) (MulOneClass.toHasMul.{u1} (AddMonoid.End.{u1} A _inst_1) (Monoid.toMulOneClass.{u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.monoid.{u1} A _inst_1)))) f g)) (coeFn.{succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) (fun (_x : AddMonoid.End.{u1} A _inst_1) => A -> A) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => A) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.addMonoidHomClass.{u1} A _inst_1)))) (HMul.hMul.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.{u1} A _inst_1) (instHMul.{u1} (AddMonoid.End.{u1} A _inst_1) (MulOneClass.toHasMul.{u1} (AddMonoid.End.{u1} A _inst_1) (Monoid.toMulOneClass.{u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.monoid.{u1} A _inst_1)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} A A A (coeFn.{succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) (fun (_x : AddMonoid.End.{u1} A _inst_1) => A -> A) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => A) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.addMonoidHomClass.{u1} A _inst_1)))) f) (coeFn.{succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) (fun (_x : AddMonoid.End.{u1} A _inst_1) => A -> A) (FunLike.hasCoeToFun.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => A) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddZeroClass.toHasAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.addMonoidHomClass.{u1} A _inst_1)))) g))\nbut is expected to have type\n  forall (A : Type.{u1}) [_inst_1 : AddZeroClass.{u1} A] (f : AddMonoid.End.{u1} A _inst_1) (g : AddMonoid.End.{u1} A _inst_1), Eq.{succ u1} (forall (a : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => A) a) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => A) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toAdd.{u1} A _inst_1) (AddZeroClass.toAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.instAddMonoidHomClassEnd.{u1} A _inst_1))) (HMul.hMul.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.{u1} A _inst_1) (instHMul.{u1} (AddMonoid.End.{u1} A _inst_1) (MulOneClass.toMul.{u1} (AddMonoid.End.{u1} A _inst_1) (Monoid.toMulOneClass.{u1} (AddMonoid.End.{u1} A _inst_1) (AddMonoid.End.monoid.{u1} A _inst_1)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} A A A (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => A) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toAdd.{u1} A _inst_1) (AddZeroClass.toAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.instAddMonoidHomClassEnd.{u1} A _inst_1))) f) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoid.End.{u1} A _inst_1) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => A) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A (AddZeroClass.toAdd.{u1} A _inst_1) (AddZeroClass.toAdd.{u1} A _inst_1) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoid.End.{u1} A _inst_1) A A _inst_1 _inst_1 (AddMonoid.End.instAddMonoidHomClassEnd.{u1} A _inst_1))) g))\nCase conversion may be inaccurate. Consider using '#align add_monoid.coe_mul AddMonoid.coe_mulₓ'. -/\n@[simp]\ntheorem coe_mul (f g) : ((f * g : AddMonoid.End A) : A → A) = f ∘ g :=\n  rfl\n#align add_monoid.coe_mul AddMonoid.coe_mul\n\nend AddMonoid\n\nend End\n\n/-- `1` is the homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [One M] [One N] : One (OneHom M N) :=\n  ⟨⟨fun _ => 1, rfl⟩⟩\n\n/-- `1` is the multiplicative homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [Mul M] [MulOneClass N] : One (M →ₙ* N) :=\n  ⟨⟨fun _ => 1, fun _ _ => (one_mul 1).symm⟩⟩\n\n/-- `1` is the monoid homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [MulOneClass M] [MulOneClass N] : One (M →* N) :=\n  ⟨⟨fun _ => 1, rfl, fun _ _ => (one_mul 1).symm⟩⟩\n\n/-- `0` is the homomorphism sending all elements to `0`. -/\nadd_decl_doc ZeroHom.hasZero\n\n/-- `0` is the additive homomorphism sending all elements to `0`. -/\nadd_decl_doc AddHom.hasZero\n\n/-- `0` is the additive monoid homomorphism sending all elements to `0`. -/\nadd_decl_doc AddMonoidHom.hasZero\n\n/- warning: one_hom.one_apply -> OneHom.one_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (OneHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : OneHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (OneHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) (OfNat.ofNat.{max u2 u1} (OneHom.{u1, u2} M N _inst_1 _inst_2) 1 (OfNat.mk.{max u2 u1} (OneHom.{u1, u2} M N _inst_1 _inst_2) 1 (One.one.{max u2 u1} (OneHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.hasOne.{u1, u2} M N _inst_1 _inst_2)))) x) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N _inst_2)))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : One.{u2} M] [_inst_2 : One.{u1} N] (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) _x) (OneHomClass.toFunLike.{max u2 u1, u2, u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (OneHom.oneHomClass.{u2, u1} M N _inst_1 _inst_2)) (OfNat.ofNat.{max u2 u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) 1 (One.toOfNat1.{max u2 u1} (OneHom.{u2, u1} M N _inst_1 _inst_2) (instOneOneHom.{u2, u1} M N _inst_1 _inst_2))) x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) x) _inst_2))\nCase conversion may be inaccurate. Consider using '#align one_hom.one_apply OneHom.one_applyₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.one_apply [One M] [One N] (x : M) : (1 : OneHom M N) x = 1 :=\n  rfl\n#align one_hom.one_apply OneHom.one_apply\n#align zero_hom.zero_apply ZeroHom.zero_apply\n\n/- warning: monoid_hom.one_apply -> MonoidHom.one_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) (OfNat.ofNat.{max u2 u1} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) 1 (OfNat.mk.{max u2 u1} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) 1 (One.one.{max u2 u1} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (MonoidHom.hasOne.{u1, u2} M N _inst_1 _inst_2)))) x) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N _inst_2))))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : MulOneClass.{u2} M] [_inst_2 : MulOneClass.{u1} N] (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u2} M _inst_1) (MulOneClass.toMul.{u1} N _inst_2) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u2, u1} M N _inst_1 _inst_2))) (OfNat.ofNat.{max u2 u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) 1 (One.toOfNat1.{max u2 u1} (MonoidHom.{u2, u1} M N _inst_1 _inst_2) (instOneMonoidHom.{u2, u1} M N _inst_1 _inst_2))) x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) _inst_2)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.one_apply MonoidHom.one_applyₓ'. -/\n@[simp, to_additive]\ntheorem MonoidHom.one_apply [MulOneClass M] [MulOneClass N] (x : M) : (1 : M →* N) x = 1 :=\n  rfl\n#align monoid_hom.one_apply MonoidHom.one_apply\n#align add_monoid_hom.zero_apply AddMonoidHom.zero_apply\n\n/- warning: one_hom.one_comp -> OneHom.one_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u3} P] (f : OneHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (OneHom.{u1, u3} M P _inst_1 _inst_3) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 (OfNat.ofNat.{max u3 u2} (OneHom.{u2, u3} N P _inst_2 _inst_3) 1 (OfNat.mk.{max u3 u2} (OneHom.{u2, u3} N P _inst_2 _inst_3) 1 (One.one.{max u3 u2} (OneHom.{u2, u3} N P _inst_2 _inst_3) (OneHom.hasOne.{u2, u3} N P _inst_2 _inst_3)))) f) (OfNat.ofNat.{max u3 u1} (OneHom.{u1, u3} M P _inst_1 _inst_3) 1 (OfNat.mk.{max u3 u1} (OneHom.{u1, u3} M P _inst_1 _inst_3) 1 (One.one.{max u3 u1} (OneHom.{u1, u3} M P _inst_1 _inst_3) (OneHom.hasOne.{u1, u3} M P _inst_1 _inst_3))))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : One.{u3} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u1} P] (f : OneHom.{u3, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (OneHom.{u3, u1} M P _inst_1 _inst_3) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 (OfNat.ofNat.{max u2 u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) 1 (One.toOfNat1.{max u2 u1} (OneHom.{u2, u1} N P _inst_2 _inst_3) (instOneOneHom.{u2, u1} N P _inst_2 _inst_3))) f) (OfNat.ofNat.{max u3 u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) 1 (One.toOfNat1.{max u3 u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) (instOneOneHom.{u3, u1} M P _inst_1 _inst_3)))\nCase conversion may be inaccurate. Consider using '#align one_hom.one_comp OneHom.one_compₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.one_comp [One M] [One N] [One P] (f : OneHom M N) : (1 : OneHom N P).comp f = 1 :=\n  rfl\n#align one_hom.one_comp OneHom.one_comp\n#align zero_hom.zero_comp ZeroHom.zero_comp\n\n/- warning: one_hom.comp_one -> OneHom.comp_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : One.{u1} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u3} P] (f : OneHom.{u2, u3} N P _inst_2 _inst_3), Eq.{max (succ u3) (succ u1)} (OneHom.{u1, u3} M P _inst_1 _inst_3) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 f (OfNat.ofNat.{max u2 u1} (OneHom.{u1, u2} M N _inst_1 _inst_2) 1 (OfNat.mk.{max u2 u1} (OneHom.{u1, u2} M N _inst_1 _inst_2) 1 (One.one.{max u2 u1} (OneHom.{u1, u2} M N _inst_1 _inst_2) (OneHom.hasOne.{u1, u2} M N _inst_1 _inst_2))))) (OfNat.ofNat.{max u3 u1} (OneHom.{u1, u3} M P _inst_1 _inst_3) 1 (OfNat.mk.{max u3 u1} (OneHom.{u1, u3} M P _inst_1 _inst_3) 1 (One.one.{max u3 u1} (OneHom.{u1, u3} M P _inst_1 _inst_3) (OneHom.hasOne.{u1, u3} M P _inst_1 _inst_3))))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : One.{u3} M] [_inst_2 : One.{u2} N] [_inst_3 : One.{u1} P] (f : OneHom.{u2, u1} N P _inst_2 _inst_3), Eq.{max (succ u3) (succ u1)} (OneHom.{u3, u1} M P _inst_1 _inst_3) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 f (OfNat.ofNat.{max u3 u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) 1 (One.toOfNat1.{max u3 u2} (OneHom.{u3, u2} M N _inst_1 _inst_2) (instOneOneHom.{u3, u2} M N _inst_1 _inst_2)))) (OfNat.ofNat.{max u3 u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) 1 (One.toOfNat1.{max u3 u1} (OneHom.{u3, u1} M P _inst_1 _inst_3) (instOneOneHom.{u3, u1} M P _inst_1 _inst_3)))\nCase conversion may be inaccurate. Consider using '#align one_hom.comp_one OneHom.comp_oneₓ'. -/\n@[simp, to_additive]\ntheorem OneHom.comp_one [One M] [One N] [One P] (f : OneHom N P) : f.comp (1 : OneHom M N) = 1 :=\n  by\n  ext\n  simp only [OneHom.map_one, OneHom.coe_comp, Function.comp_apply, OneHom.one_apply]\n#align one_hom.comp_one OneHom.comp_one\n#align zero_hom.comp_zero ZeroHom.comp_zero\n\n@[to_additive]\ninstance [One M] [One N] : Inhabited (OneHom M N) :=\n  ⟨1⟩\n\n@[to_additive]\ninstance [Mul M] [MulOneClass N] : Inhabited (M →ₙ* N) :=\n  ⟨1⟩\n\n@[to_additive]\ninstance [MulOneClass M] [MulOneClass N] : Inhabited (M →* N) :=\n  ⟨1⟩\n\n-- unlike the other homs, `monoid_with_zero_hom` does not have a `1` or `0`\ninstance [MulZeroOneClass M] : Inhabited (M →*₀ M) :=\n  ⟨MonoidWithZeroHom.id M⟩\n\nnamespace MulHom\n\n/-- Given two mul morphisms `f`, `g` to a commutative semigroup, `f * g` is the mul morphism\nsending `x` to `f x * g x`. -/\n@[to_additive]\ninstance [Mul M] [CommSemigroup N] : Mul (M →ₙ* N) :=\n  ⟨fun f g =>\n    { toFun := fun m => f m * g m\n      map_mul' := by\n        intros ; show f (x * y) * g (x * y) = f x * g x * (f y * g y)\n        rw [f.map_mul, g.map_mul, ← mul_assoc, ← mul_assoc, mul_right_comm (f x)] }⟩\n\n/-- Given two additive morphisms `f`, `g` to an additive commutative semigroup, `f + g` is the\nadditive morphism sending `x` to `f x + g x`. -/\nadd_decl_doc AddHom.hasAdd\n\n/- warning: mul_hom.mul_apply -> MulHom.mul_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : Mul.{u1} M} {mN : CommSemigroup.{u2} N} (f : MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (g : MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (fun (_x : MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (instHMul.{max u2 u1} (MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (MulHom.hasMul.{u1, u2} M N mM mN)) f g) x) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (fun (_x : MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) (fun (_x : MulHom.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) => M -> N) (MulHom.hasCoeToFun.{u1, u2} M N mM (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N mN))) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {mM : Mul.{u2} M} {mN : CommSemigroup.{u1} N} (f : MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) (g : MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN)) (MulHom.mulHomClass.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN)))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) (instHMul.{max u2 u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) (MulHom.instMulMulHomToMulToSemigroup.{u2, u1} M N mM mN)) f g) x) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (Semigroup.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (CommSemigroup.toSemigroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) mN))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN)) (MulHom.mulHomClass.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN))) M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN)) (MulHom.mulHomClass.{u2, u1} M N mM (Semigroup.toMul.{u1} N (CommSemigroup.toSemigroup.{u1} N mN)))) g x))\nCase conversion may be inaccurate. Consider using '#align mul_hom.mul_apply MulHom.mul_applyₓ'. -/\n@[simp, to_additive]\ntheorem mul_apply {M N} {mM : Mul M} {mN : CommSemigroup N} (f g : M →ₙ* N) (x : M) :\n    (f * g) x = f x * g x :=\n  rfl\n#align mul_hom.mul_apply MulHom.mul_apply\n#align add_hom.add_apply AddHom.add_apply\n\n/- warning: mul_hom.mul_comp -> MulHom.mul_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : Mul.{u2} N] [_inst_3 : CommSemigroup.{u3} P] (g₁ : MulHom.{u2, u3} N P _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (g₂ : MulHom.{u2, u3} N P _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (f : MulHom.{u1, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3)) (HMul.hMul.{max u3 u2, max u3 u2, max u3 u2} (MulHom.{u2, u3} N P _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.{u2, u3} N P _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.{u2, u3} N P _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (instHMul.{max u3 u2} (MulHom.{u2, u3} N P _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.hasMul.{u2, u3} N P _inst_2 _inst_3)) g₁ g₂) f) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (instHMul.{max u3 u1} (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.hasMul.{u1, u3} M P _inst_1 _inst_3)) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3)) g₁ f) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3)) g₂ f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : Mul.{u3} M] [_inst_2 : Mul.{u2} N] [_inst_3 : CommSemigroup.{u1} P] (g₁ : MulHom.{u2, u1} N P _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (g₂ : MulHom.{u2, u1} N P _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (f : MulHom.{u3, u2} M N _inst_1 _inst_2), Eq.{max (succ u3) (succ u1)} (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3)) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MulHom.{u2, u1} N P _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.{u2, u1} N P _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.{u2, u1} N P _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (instHMul.{max u2 u1} (MulHom.{u2, u1} N P _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.instMulMulHomToMulToSemigroup.{u2, u1} N P _inst_2 _inst_3)) g₁ g₂) f) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (instHMul.{max u3 u1} (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.instMulMulHomToMulToSemigroup.{u3, u1} M P _inst_1 _inst_3)) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3)) g₁ f) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3)) g₂ f))\nCase conversion may be inaccurate. Consider using '#align mul_hom.mul_comp MulHom.mul_compₓ'. -/\n@[to_additive]\ntheorem mul_comp [Mul M] [Mul N] [CommSemigroup P] (g₁ g₂ : N →ₙ* P) (f : M →ₙ* N) :\n    (g₁ * g₂).comp f = g₁.comp f * g₂.comp f :=\n  rfl\n#align mul_hom.mul_comp MulHom.mul_comp\n#align add_hom.add_comp AddHom.add_comp\n\n/- warning: mul_hom.comp_mul -> MulHom.comp_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_1 : Mul.{u1} M] [_inst_2 : CommSemigroup.{u2} N] [_inst_3 : CommSemigroup.{u3} P] (g : MulHom.{u2, u3} N P (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (f₁ : MulHom.{u1, u2} M N _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (f₂ : MulHom.{u1, u2} M N _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))), Eq.{max (succ u3) (succ u1)} (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.comp.{u1, u2, u3} M N P _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3)) g (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MulHom.{u1, u2} M N _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (MulHom.{u1, u2} M N _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (MulHom.{u1, u2} M N _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (instHMul.{max u2 u1} (MulHom.{u1, u2} M N _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (MulHom.hasMul.{u1, u2} M N _inst_1 _inst_2)) f₁ f₂)) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (instHMul.{max u3 u1} (MulHom.{u1, u3} M P _inst_1 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (MulHom.hasMul.{u1, u3} M P _inst_1 _inst_3)) (MulHom.comp.{u1, u2, u3} M N P _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3)) g f₁) (MulHom.comp.{u1, u2, u3} M N P _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3)) g f₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_1 : Mul.{u3} M] [_inst_2 : CommSemigroup.{u2} N] [_inst_3 : CommSemigroup.{u1} P] (g : MulHom.{u2, u1} N P (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (f₁ : MulHom.{u3, u2} M N _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (f₂ : MulHom.{u3, u2} M N _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))), Eq.{max (succ u3) (succ u1)} (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.comp.{u3, u2, u1} M N P _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3)) g (HMul.hMul.{max u3 u2, max u3 u2, max u3 u2} (MulHom.{u3, u2} M N _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (MulHom.{u3, u2} M N _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (MulHom.{u3, u2} M N _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (instHMul.{max u3 u2} (MulHom.{u3, u2} M N _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (MulHom.instMulMulHomToMulToSemigroup.{u3, u2} M N _inst_1 _inst_2)) f₁ f₂)) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (instHMul.{max u3 u1} (MulHom.{u3, u1} M P _inst_1 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (MulHom.instMulMulHomToMulToSemigroup.{u3, u1} M P _inst_1 _inst_3)) (MulHom.comp.{u3, u2, u1} M N P _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3)) g f₁) (MulHom.comp.{u3, u2, u1} M N P _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2)) (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3)) g f₂))\nCase conversion may be inaccurate. Consider using '#align mul_hom.comp_mul MulHom.comp_mulₓ'. -/\n@[to_additive]\ntheorem comp_mul [Mul M] [CommSemigroup N] [CommSemigroup P] (g : N →ₙ* P) (f₁ f₂ : M →ₙ* N) :\n    g.comp (f₁ * f₂) = g.comp f₁ * g.comp f₂ := by\n  ext\n  simp only [mul_apply, Function.comp_apply, map_mul, coe_comp]\n#align mul_hom.comp_mul MulHom.comp_mul\n#align add_hom.comp_add AddHom.comp_add\n\nend MulHom\n\nnamespace MonoidHom\n\nvariable [mM : MulOneClass M] [mN : MulOneClass N] [mP : MulOneClass P]\n\nvariable [Group G] [CommGroup H]\n\n/-- Given two monoid morphisms `f`, `g` to a commutative monoid, `f * g` is the monoid morphism\nsending `x` to `f x * g x`. -/\n@[to_additive]\ninstance {M N} {mM : MulOneClass M} [CommMonoid N] : Mul (M →* N) :=\n  ⟨fun f g =>\n    { toFun := fun m => f m * g m\n      map_one' := show f 1 * g 1 = 1 by simp\n      map_mul' := by\n        intros ; show f (x * y) * g (x * y) = f x * g x * (f y * g y)\n        rw [f.map_mul, g.map_mul, ← mul_assoc, ← mul_assoc, mul_right_comm (f x)] }⟩\n\n/-- Given two additive monoid morphisms `f`, `g` to an additive commutative monoid, `f + g` is the\nadditive monoid morphism sending `x` to `f x + g x`. -/\nadd_decl_doc AddMonoidHom.hasAdd\n\n/- warning: monoid_hom.mul_apply -> MonoidHom.mul_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {mM : MulOneClass.{u1} M} {mN : CommMonoid.{u2} N} (f : MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (g : MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (x : M), Eq.{succ u2} N (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (fun (_x : MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (instHMul.{max u2 u1} (MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (MonoidHom.hasMul.{u1, u2} M N mM mN)) f g) x) (HMul.hMul.{u2, u2, u2} N N N (instHMul.{u2} N (MulOneClass.toHasMul.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN)))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (fun (_x : MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) (fun (_x : MonoidHom.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N mM (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N mN))) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {N : Type.{u1}} {mM : MulOneClass.{u2} M} {mN : CommMonoid.{u1} N} (f : MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (g : MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M N (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN)) (MonoidHom.monoidHomClass.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (instHMul.{max u2 u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (MonoidHom.mul.{u2, u1} M N mM mN)) f g) x) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (Monoid.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (CommMonoid.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) mN)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M N (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN)) (MonoidHom.monoidHomClass.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M N (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} N (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))) M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN)) (MonoidHom.monoidHomClass.{u2, u1} M N mM (Monoid.toMulOneClass.{u1} N (CommMonoid.toMonoid.{u1} N mN))))) g x))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.mul_apply MonoidHom.mul_applyₓ'. -/\n@[simp, to_additive]\ntheorem mul_apply {M N} {mM : MulOneClass M} {mN : CommMonoid N} (f g : M →* N) (x : M) :\n    (f * g) x = f x * g x :=\n  rfl\n#align monoid_hom.mul_apply MonoidHom.mul_apply\n#align add_monoid_hom.add_apply AddMonoidHom.add_apply\n\n/- warning: monoid_hom.one_comp -> MonoidHom.one_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_3 : MulOneClass.{u1} M] [_inst_4 : MulOneClass.{u2} N] [_inst_5 : MulOneClass.{u3} P] (f : MonoidHom.{u1, u2} M N _inst_3 _inst_4), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 _inst_4 _inst_5 (OfNat.ofNat.{max u3 u2} (MonoidHom.{u2, u3} N P _inst_4 _inst_5) 1 (OfNat.mk.{max u3 u2} (MonoidHom.{u2, u3} N P _inst_4 _inst_5) 1 (One.one.{max u3 u2} (MonoidHom.{u2, u3} N P _inst_4 _inst_5) (MonoidHom.hasOne.{u2, u3} N P _inst_4 _inst_5)))) f) (OfNat.ofNat.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) 1 (OfNat.mk.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) 1 (One.one.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) (MonoidHom.hasOne.{u1, u3} M P _inst_3 _inst_5))))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_3 : MulOneClass.{u3} M] [_inst_4 : MulOneClass.{u2} N] [_inst_5 : MulOneClass.{u1} P] (f : MonoidHom.{u3, u2} M N _inst_3 _inst_4), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M P _inst_3 _inst_5) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 _inst_4 _inst_5 (OfNat.ofNat.{max u2 u1} (MonoidHom.{u2, u1} N P _inst_4 _inst_5) 1 (One.toOfNat1.{max u2 u1} (MonoidHom.{u2, u1} N P _inst_4 _inst_5) (instOneMonoidHom.{u2, u1} N P _inst_4 _inst_5))) f) (OfNat.ofNat.{max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 _inst_5) 1 (One.toOfNat1.{max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 _inst_5) (instOneMonoidHom.{u3, u1} M P _inst_3 _inst_5)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.one_comp MonoidHom.one_compₓ'. -/\n@[simp, to_additive]\ntheorem one_comp [MulOneClass M] [MulOneClass N] [MulOneClass P] (f : M →* N) :\n    (1 : N →* P).comp f = 1 :=\n  rfl\n#align monoid_hom.one_comp MonoidHom.one_comp\n#align add_monoid_hom.zero_comp AddMonoidHom.zero_comp\n\n/- warning: monoid_hom.comp_one -> MonoidHom.comp_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_3 : MulOneClass.{u1} M] [_inst_4 : MulOneClass.{u2} N] [_inst_5 : MulOneClass.{u3} P] (f : MonoidHom.{u2, u3} N P _inst_4 _inst_5), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 _inst_4 _inst_5 f (OfNat.ofNat.{max u2 u1} (MonoidHom.{u1, u2} M N _inst_3 _inst_4) 1 (OfNat.mk.{max u2 u1} (MonoidHom.{u1, u2} M N _inst_3 _inst_4) 1 (One.one.{max u2 u1} (MonoidHom.{u1, u2} M N _inst_3 _inst_4) (MonoidHom.hasOne.{u1, u2} M N _inst_3 _inst_4))))) (OfNat.ofNat.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) 1 (OfNat.mk.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) 1 (One.one.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 _inst_5) (MonoidHom.hasOne.{u1, u3} M P _inst_3 _inst_5))))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_3 : MulOneClass.{u3} M] [_inst_4 : MulOneClass.{u2} N] [_inst_5 : MulOneClass.{u1} P] (f : MonoidHom.{u2, u1} N P _inst_4 _inst_5), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M P _inst_3 _inst_5) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 _inst_4 _inst_5 f (OfNat.ofNat.{max u3 u2} (MonoidHom.{u3, u2} M N _inst_3 _inst_4) 1 (One.toOfNat1.{max u3 u2} (MonoidHom.{u3, u2} M N _inst_3 _inst_4) (instOneMonoidHom.{u3, u2} M N _inst_3 _inst_4)))) (OfNat.ofNat.{max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 _inst_5) 1 (One.toOfNat1.{max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 _inst_5) (instOneMonoidHom.{u3, u1} M P _inst_3 _inst_5)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_one MonoidHom.comp_oneₓ'. -/\n@[simp, to_additive]\ntheorem comp_one [MulOneClass M] [MulOneClass N] [MulOneClass P] (f : N →* P) :\n    f.comp (1 : M →* N) = 1 := by\n  ext\n  simp only [map_one, coe_comp, Function.comp_apply, one_apply]\n#align monoid_hom.comp_one MonoidHom.comp_one\n#align add_monoid_hom.comp_zero AddMonoidHom.comp_zero\n\n/- warning: monoid_hom.mul_comp -> MonoidHom.mul_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_3 : MulOneClass.{u1} M] [_inst_4 : MulOneClass.{u2} N] [_inst_5 : CommMonoid.{u3} P] (g₁ : MonoidHom.{u2, u3} N P _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (g₂ : MonoidHom.{u2, u3} N P _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (f : MonoidHom.{u1, u2} M N _inst_3 _inst_4), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5)) (HMul.hMul.{max u3 u2, max u3 u2, max u3 u2} (MonoidHom.{u2, u3} N P _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.{u2, u3} N P _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.{u2, u3} N P _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (instHMul.{max u3 u2} (MonoidHom.{u2, u3} N P _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.hasMul.{u2, u3} N P _inst_4 _inst_5)) g₁ g₂) f) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (instHMul.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.hasMul.{u1, u3} M P _inst_3 _inst_5)) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5)) g₁ f) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5)) g₂ f))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_3 : MulOneClass.{u3} M] [_inst_4 : MulOneClass.{u2} N] [_inst_5 : CommMonoid.{u1} P] (g₁ : MonoidHom.{u2, u1} N P _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (g₂ : MonoidHom.{u2, u1} N P _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (f : MonoidHom.{u3, u2} M N _inst_3 _inst_4), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5)) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MonoidHom.{u2, u1} N P _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.{u2, u1} N P _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.{u2, u1} N P _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (instHMul.{max u2 u1} (MonoidHom.{u2, u1} N P _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.mul.{u2, u1} N P _inst_4 _inst_5)) g₁ g₂) f) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (instHMul.{max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.mul.{u3, u1} M P _inst_3 _inst_5)) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5)) g₁ f) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5)) g₂ f))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.mul_comp MonoidHom.mul_compₓ'. -/\n@[to_additive]\ntheorem mul_comp [MulOneClass M] [MulOneClass N] [CommMonoid P] (g₁ g₂ : N →* P) (f : M →* N) :\n    (g₁ * g₂).comp f = g₁.comp f * g₂.comp f :=\n  rfl\n#align monoid_hom.mul_comp MonoidHom.mul_comp\n#align add_monoid_hom.add_comp AddMonoidHom.add_comp\n\n/- warning: monoid_hom.comp_mul -> MonoidHom.comp_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {P : Type.{u3}} [_inst_3 : MulOneClass.{u1} M] [_inst_4 : CommMonoid.{u2} N] [_inst_5 : CommMonoid.{u3} P] (g : MonoidHom.{u2, u3} N P (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (f₁ : MonoidHom.{u1, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (f₂ : MonoidHom.{u1, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5)) g (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (MonoidHom.{u1, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (MonoidHom.{u1, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (MonoidHom.{u1, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (instHMul.{max u2 u1} (MonoidHom.{u1, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (MonoidHom.hasMul.{u1, u2} M N _inst_3 _inst_4)) f₁ f₂)) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (instHMul.{max u3 u1} (MonoidHom.{u1, u3} M P _inst_3 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (MonoidHom.hasMul.{u1, u3} M P _inst_3 _inst_5)) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5)) g f₁) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5)) g f₂))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {P : Type.{u1}} [_inst_3 : MulOneClass.{u3} M] [_inst_4 : CommMonoid.{u2} N] [_inst_5 : CommMonoid.{u1} P] (g : MonoidHom.{u2, u1} N P (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (f₁ : MonoidHom.{u3, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (f₂ : MonoidHom.{u3, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5)) g (HMul.hMul.{max u3 u2, max u3 u2, max u3 u2} (MonoidHom.{u3, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (MonoidHom.{u3, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (MonoidHom.{u3, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (instHMul.{max u3 u2} (MonoidHom.{u3, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (MonoidHom.mul.{u3, u2} M N _inst_3 _inst_4)) f₁ f₂)) (HMul.hMul.{max u3 u1, max u3 u1, max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (instHMul.{max u3 u1} (MonoidHom.{u3, u1} M P _inst_3 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (MonoidHom.mul.{u3, u1} M P _inst_3 _inst_5)) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5)) g f₁) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4)) (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5)) g f₂))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_mul MonoidHom.comp_mulₓ'. -/\n@[to_additive]\ntheorem comp_mul [MulOneClass M] [CommMonoid N] [CommMonoid P] (g : N →* P) (f₁ f₂ : M →* N) :\n    g.comp (f₁ * f₂) = g.comp f₁ * g.comp f₂ := by\n  ext\n  simp only [mul_apply, Function.comp_apply, map_mul, coe_comp]\n#align monoid_hom.comp_mul MonoidHom.comp_mul\n#align add_monoid_hom.comp_add AddMonoidHom.comp_add\n\n/- warning: monoid_hom.map_inv -> MonoidHom.map_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_3 : Group.{u1} α] [_inst_4 : DivisionMonoid.{u2} β] (f : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (a : α), Eq.{succ u2} β (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a)) (Inv.inv.{u2} β (DivInvMonoid.toHasInv.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_3 : Group.{u2} α] [_inst_4 : DivisionMonoid.{u1} β] (f : MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (Inv.inv.{u2} α (InvOneClass.toInv.{u2} α (DivInvOneMonoid.toInvOneClass.{u2} α (DivisionMonoid.toDivInvOneMonoid.{u2} α (Group.toDivisionMonoid.{u2} α _inst_3)))) a)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f (Inv.inv.{u2} α (InvOneClass.toInv.{u2} α (DivInvOneMonoid.toInvOneClass.{u2} α (DivisionMonoid.toDivInvOneMonoid.{u2} α (Group.toDivisionMonoid.{u2} α _inst_3)))) a)) (Inv.inv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (InvOneClass.toInv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (DivInvOneMonoid.toInvOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (DivisionMonoid.toDivInvOneMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f a))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_inv MonoidHom.map_invₓ'. -/\n/-- Group homomorphisms preserve inverse. -/\n@[to_additive \"Additive group homomorphisms preserve negation.\"]\nprotected theorem map_inv [Group α] [DivisionMonoid β] (f : α →* β) (a : α) : f a⁻¹ = (f a)⁻¹ :=\n  map_inv f _\n#align monoid_hom.map_inv MonoidHom.map_inv\n#align add_monoid_hom.map_neg AddMonoidHom.map_neg\n\n/- warning: monoid_hom.map_zpow -> MonoidHom.map_zpow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_3 : Group.{u1} α] [_inst_4 : DivisionMonoid.{u2} β] (f : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (g : α) (n : Int), Eq.{succ u2} β (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) g n)) (HPow.hPow.{u2, 0, u2} β Int β (instHPow.{u2, 0} β Int (DivInvMonoid.Pow.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f g) n)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_3 : Group.{u2} α] [_inst_4 : DivisionMonoid.{u1} β] (f : MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (g : α) (n : Int), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (HPow.hPow.{u2, 0, u2} α Int α (instHPow.{u2, 0} α Int (DivInvMonoid.Pow.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) g n)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f (HPow.hPow.{u2, 0, u2} α Int α (instHPow.{u2, 0} α Int (DivInvMonoid.Pow.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) g n)) (HPow.hPow.{u1, 0, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) Int ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (instHPow.{u1, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) Int (DivInvMonoid.Pow.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (DivisionMonoid.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f g) n)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_zpow MonoidHom.map_zpowₓ'. -/\n/-- Group homomorphisms preserve integer power. -/\n@[to_additive \"Additive group homomorphisms preserve integer scaling.\"]\nprotected theorem map_zpow [Group α] [DivisionMonoid β] (f : α →* β) (g : α) (n : ℤ) :\n    f (g ^ n) = f g ^ n :=\n  map_zpow f g n\n#align monoid_hom.map_zpow MonoidHom.map_zpow\n#align add_monoid_hom.map_zsmul AddMonoidHom.map_zsmul\n\n/- warning: monoid_hom.map_div -> MonoidHom.map_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_3 : Group.{u1} α] [_inst_4 : DivisionMonoid.{u2} β] (f : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (g : α) (h : α), Eq.{succ u2} β (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) g h)) (HDiv.hDiv.{u2, u2, u2} β β β (instHDiv.{u2} β (DivInvMonoid.toHasDiv.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f g) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f h))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_3 : Group.{u2} α] [_inst_4 : DivisionMonoid.{u1} β] (f : MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (g : α) (h : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (HDiv.hDiv.{u2, u2, u2} α α α (instHDiv.{u2} α (DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) g h)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f (HDiv.hDiv.{u2, u2, u2} α α α (instHDiv.{u2} α (DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) g h)) (HDiv.hDiv.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) h) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (instHDiv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (DivInvMonoid.toDiv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (DivisionMonoid.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f g) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f h))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_div MonoidHom.map_divₓ'. -/\n/-- Group homomorphisms preserve division. -/\n@[to_additive \"Additive group homomorphisms preserve subtraction.\"]\nprotected theorem map_div [Group α] [DivisionMonoid β] (f : α →* β) (g h : α) :\n    f (g / h) = f g / f h :=\n  map_div f g h\n#align monoid_hom.map_div MonoidHom.map_div\n#align add_monoid_hom.map_sub AddMonoidHom.map_sub\n\n/- warning: monoid_hom.map_mul_inv -> MonoidHom.map_mul_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_3 : Group.{u1} α] [_inst_4 : DivisionMonoid.{u2} β] (f : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (g : α) (h : α), Eq.{succ u2} β (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))))) g (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) h))) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4))))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f g) (Inv.inv.{u2} β (DivInvMonoid.toHasInv.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (DivisionMonoid.toDivInvMonoid.{u2} β _inst_4)))) f h)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_3 : Group.{u2} α] [_inst_4 : DivisionMonoid.{u1} β] (f : MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (g : α) (h : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))))) g (Inv.inv.{u2} α (InvOneClass.toInv.{u2} α (DivInvOneMonoid.toInvOneClass.{u2} α (DivisionMonoid.toDivInvOneMonoid.{u2} α (Group.toDivisionMonoid.{u2} α _inst_3)))) h))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))))) g (Inv.inv.{u2} α (InvOneClass.toInv.{u2} α (DivInvOneMonoid.toInvOneClass.{u2} α (DivisionMonoid.toDivInvOneMonoid.{u2} α (Group.toDivisionMonoid.{u2} α _inst_3)))) h))) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) h) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (Monoid.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (DivInvMonoid.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) (DivisionMonoid.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) g) _inst_4))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f g) (Inv.inv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) h) (InvOneClass.toInv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) h) (DivInvOneMonoid.toInvOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) h) (DivisionMonoid.toDivInvOneMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) h) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3)))) (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))) α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} α β (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_3))) (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (DivisionMonoid.toDivInvMonoid.{u1} β _inst_4)))))) f h)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_mul_inv MonoidHom.map_mul_invₓ'. -/\n/-- Group homomorphisms preserve division. -/\n@[to_additive \"Additive group homomorphisms preserve subtraction.\"]\nprotected theorem map_mul_inv [Group α] [DivisionMonoid β] (f : α →* β) (g h : α) :\n    f (g * h⁻¹) = f g * (f h)⁻¹ :=\n  map_mul_inv f g h\n#align monoid_hom.map_mul_inv MonoidHom.map_mul_inv\n#align add_monoid_hom.map_add_neg AddMonoidHom.map_add_neg\n\n/- warning: injective_iff_map_eq_one -> injective_iff_map_eq_one is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {G : Type.{u2}} {H : Type.{u3}} [_inst_3 : Group.{u2} G] [_inst_4 : MulOneClass.{u3} H] [_inst_5 : MonoidHomClass.{u1, u2, u3} F G H (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3))) _inst_4] (f : F), Iff (Function.Injective.{succ u2, succ u3} G H (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u1, u2, u3} F G H (MulOneClass.toHasMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3)))) (MulOneClass.toHasMul.{u3} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F G H (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3))) _inst_4 _inst_5))) f)) (forall (a : G), (Eq.{succ u3} H (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u1, u2, u3} F G H (MulOneClass.toHasMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3)))) (MulOneClass.toHasMul.{u3} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F G H (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3))) _inst_4 _inst_5))) f a) (OfNat.ofNat.{u3} H 1 (OfNat.mk.{u3} H 1 (One.one.{u3} H (MulOneClass.toHasOne.{u3} H _inst_4))))) -> (Eq.{succ u2} G a (OfNat.ofNat.{u2} G 1 (OfNat.mk.{u2} G 1 (One.one.{u2} G (MulOneClass.toHasOne.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3)))))))))\nbut is expected to have type\n  forall {F : Type.{u1}} {G : Type.{u3}} {H : Type.{u2}} [_inst_3 : Group.{u3} G] [_inst_4 : MulOneClass.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) _inst_4] (f : F), Iff (Function.Injective.{succ u3, succ u2} G H (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) _inst_4 _inst_5)) f)) (forall (a : G), (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) _inst_4 _inst_5)) f a) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (MulOneClass.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4)))) -> (Eq.{succ u3} G a (OfNat.ofNat.{u3} G 1 (One.toOfNat1.{u3} G (InvOneClass.toOne.{u3} G (DivInvOneMonoid.toInvOneClass.{u3} G (DivisionMonoid.toDivInvOneMonoid.{u3} G (Group.toDivisionMonoid.{u3} G _inst_3))))))))\nCase conversion may be inaccurate. Consider using '#align injective_iff_map_eq_one injective_iff_map_eq_oneₓ'. -/\n/-- A homomorphism from a group to a monoid is injective iff its kernel is trivial.\nFor the iff statement on the triviality of the kernel, see `injective_iff_map_eq_one'`.  -/\n@[to_additive\n      \"A homomorphism from an additive group to an additive monoid is injective iff\\nits kernel is trivial. For the iff statement on the triviality of the kernel,\\nsee `injective_iff_map_eq_zero'`.\"]\ntheorem injective_iff_map_eq_one {G H} [Group G] [MulOneClass H] [MonoidHomClass F G H] (f : F) :\n    Function.Injective f ↔ ∀ a, f a = 1 → a = 1 :=\n  ⟨fun h x => (map_eq_one_iff f h).mp, fun h x y hxy =>\n    mul_inv_eq_one.1 <| h _ <| by rw [map_mul, hxy, ← map_mul, mul_inv_self, map_one]⟩\n#align injective_iff_map_eq_one injective_iff_map_eq_one\n#align injective_iff_map_eq_zero injective_iff_map_eq_zero\n\n/- warning: injective_iff_map_eq_one' -> injective_iff_map_eq_one' is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {G : Type.{u2}} {H : Type.{u3}} [_inst_3 : Group.{u2} G] [_inst_4 : MulOneClass.{u3} H] [_inst_5 : MonoidHomClass.{u1, u2, u3} F G H (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3))) _inst_4] (f : F), Iff (Function.Injective.{succ u2, succ u3} G H (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u1, u2, u3} F G H (MulOneClass.toHasMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3)))) (MulOneClass.toHasMul.{u3} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F G H (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3))) _inst_4 _inst_5))) f)) (forall (a : G), Iff (Eq.{succ u3} H (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => G -> H) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F G (fun (_x : G) => H) (MulHomClass.toFunLike.{u1, u2, u3} F G H (MulOneClass.toHasMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3)))) (MulOneClass.toHasMul.{u3} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F G H (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3))) _inst_4 _inst_5))) f a) (OfNat.ofNat.{u3} H 1 (OfNat.mk.{u3} H 1 (One.one.{u3} H (MulOneClass.toHasOne.{u3} H _inst_4))))) (Eq.{succ u2} G a (OfNat.ofNat.{u2} G 1 (OfNat.mk.{u2} G 1 (One.one.{u2} G (MulOneClass.toHasOne.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_3)))))))))\nbut is expected to have type\n  forall {F : Type.{u1}} {G : Type.{u3}} {H : Type.{u2}} [_inst_3 : Group.{u3} G] [_inst_4 : MulOneClass.{u2} H] [_inst_5 : MonoidHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) _inst_4] (f : F), Iff (Function.Injective.{succ u3, succ u2} G H (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) _inst_4 _inst_5)) f)) (forall (a : G), Iff (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (FunLike.coe.{succ u1, succ u3, succ u2} F G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{u1, u3, u2} F G H (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3)))) (MulOneClass.toMul.{u2} H _inst_4) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F G H (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_3))) _inst_4 _inst_5)) f a) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) (MulOneClass.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) a) _inst_4)))) (Eq.{succ u3} G a (OfNat.ofNat.{u3} G 1 (One.toOfNat1.{u3} G (InvOneClass.toOne.{u3} G (DivInvOneMonoid.toInvOneClass.{u3} G (DivisionMonoid.toDivInvOneMonoid.{u3} G (Group.toDivisionMonoid.{u3} G _inst_3))))))))\nCase conversion may be inaccurate. Consider using '#align injective_iff_map_eq_one' injective_iff_map_eq_one'ₓ'. -/\n/-- A homomorphism from a group to a monoid is injective iff its kernel is trivial,\nstated as an iff on the triviality of the kernel.\nFor the implication, see `injective_iff_map_eq_one`. -/\n@[to_additive\n      \"A homomorphism from an additive group to an additive monoid is injective iff its\\nkernel is trivial, stated as an iff on the triviality of the kernel. For the implication, see\\n`injective_iff_map_eq_zero`.\"]\ntheorem injective_iff_map_eq_one' {G H} [Group G] [MulOneClass H] [MonoidHomClass F G H] (f : F) :\n    Function.Injective f ↔ ∀ a, f a = 1 ↔ a = 1 :=\n  (injective_iff_map_eq_one f).trans <|\n    forall_congr' fun a => ⟨fun h => ⟨h, fun H => H.symm ▸ map_one f⟩, Iff.mp⟩\n#align injective_iff_map_eq_one' injective_iff_map_eq_one'\n#align injective_iff_map_eq_zero' injective_iff_map_eq_zero'\n\ninclude mM\n\n/- warning: monoid_hom.mk' -> MonoidHom.mk' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {G : Type.{u2}} [mM : MulOneClass.{u1} M] [_inst_1 : Group.{u2} G] (f : M -> G), (forall (a : M) (b : M), Eq.{succ u2} G (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M mM)) a b)) (HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G (MulOneClass.toHasMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))))) (f a) (f b))) -> (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))))\nbut is expected to have type\n  forall {M : Type.{u1}} {G : Type.{u2}} [mM : Group.{u2} G] [_inst_1 : MulOneClass.{u1} M] (f : M -> G), (forall (a : M) (b : M), Eq.{succ u2} G (f (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M _inst_1)) a b)) (HMul.hMul.{u2, u2, u2} G G G (instHMul.{u2} G (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G mM))))) (f a) (f b))) -> (MonoidHom.{u1, u2} M G _inst_1 (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G mM))))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.mk' MonoidHom.mk'ₓ'. -/\n/-- Makes a group homomorphism from a proof that the map preserves multiplication. -/\n@[to_additive \"Makes an additive group homomorphism from a proof that the map preserves addition.\",\n  simps (config := { fullyApplied := false })]\ndef mk' (f : M → G) (map_mul : ∀ a b : M, f (a * b) = f a * f b) : M →* G\n    where\n  toFun := f\n  map_mul' := map_mul\n  map_one' := mul_left_eq_self.1 <| by rw [← map_mul, mul_one]\n#align monoid_hom.mk' MonoidHom.mk'\n#align add_monoid_hom.mk' AddMonoidHom.mk'\n\nomit mM\n\n/- warning: monoid_hom.of_map_mul_inv -> MonoidHom.ofMapMulInv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H), (forall (a : G) (b : G), Eq.{succ u2} H (f (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) b))) (HMul.hMul.{u2, u2, u2} H H H (instHMul.{u2} H (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))) (f a) (Inv.inv.{u2} H (DivInvMonoid.toHasInv.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)) (f b)))) -> (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H), (forall (a : G) (b : G), Eq.{succ u2} H (f (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))) b))) (HMul.hMul.{u2, u2, u2} H H H (instHMul.{u2} H (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))) (f a) (Inv.inv.{u2} H (InvOneClass.toInv.{u2} H (DivInvOneMonoid.toInvOneClass.{u2} H (DivisionMonoid.toDivInvOneMonoid.{u2} H (Group.toDivisionMonoid.{u2} H _inst_3)))) (f b)))) -> (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.of_map_mul_inv MonoidHom.ofMapMulInvₓ'. -/\n/-- Makes a group homomorphism from a proof that the map preserves right division `λ x y, x * y⁻¹`.\nSee also `monoid_hom.of_map_div` for a version using `λ x y, x / y`.\n-/\n@[to_additive\n      \"Makes an additive group homomorphism from a proof that the map preserves\\nthe operation `λ a b, a + -b`. See also `add_monoid_hom.of_map_sub` for a version using\\n`λ a b, a - b`.\"]\ndef ofMapMulInv {H : Type _} [Group H] (f : G → H)\n    (map_div : ∀ a b : G, f (a * b⁻¹) = f a * (f b)⁻¹) : G →* H :=\n  mk' f fun x y =>\n    calc\n      f (x * y) = f x * (f <| 1 * 1⁻¹ * y⁻¹)⁻¹ := by\n        simp only [one_mul, inv_one, ← map_div, inv_inv]\n      _ = f x * f y := by\n        simp only [map_div]\n        simp only [mul_right_inv, one_mul, inv_inv]\n      \n#align monoid_hom.of_map_mul_inv MonoidHom.ofMapMulInv\n#align add_monoid_hom.of_map_add_neg AddMonoidHom.ofMapAddNeg\n\n/- warning: monoid_hom.coe_of_map_mul_inv -> MonoidHom.coe_of_map_mul_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H) (map_div : forall (a : G) (b : G), Eq.{succ u2} H (f (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) b))) (HMul.hMul.{u2, u2, u2} H H H (instHMul.{u2} H (MulOneClass.toHasMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))) (f a) (Inv.inv.{u2} H (DivInvMonoid.toHasInv.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)) (f b)))), Eq.{max (succ u1) (succ u2)} (G -> H) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) (fun (_x : MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) => G -> H) (MonoidHom.hasCoeToFun.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) (MonoidHom.ofMapMulInv.{u1, u2} G _inst_1 H _inst_3 f map_div)) f\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H) (map_div : forall (a : G) (b : G), Eq.{succ u2} H (f (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))) b))) (HMul.hMul.{u2, u2, u2} H H H (instHMul.{u2} H (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))) (f a) (Inv.inv.{u2} H (InvOneClass.toInv.{u2} H (DivInvOneMonoid.toInvOneClass.{u2} H (DivisionMonoid.toDivInvOneMonoid.{u2} H (Group.toDivisionMonoid.{u2} H _inst_3)))) (f b)))), Eq.{max (succ u1) (succ u2)} (G -> H) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) G H (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))) (MonoidHom.monoidHomClass.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))))) (MonoidHom.ofMapMulInv.{u1, u2} G _inst_1 H _inst_3 f map_div)) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_of_map_mul_inv MonoidHom.coe_of_map_mul_invₓ'. -/\n@[simp, to_additive]\ntheorem coe_of_map_mul_inv {H : Type _} [Group H] (f : G → H)\n    (map_div : ∀ a b : G, f (a * b⁻¹) = f a * (f b)⁻¹) : ⇑(ofMapMulInv f map_div) = f :=\n  rfl\n#align monoid_hom.coe_of_map_mul_inv MonoidHom.coe_of_map_mul_inv\n#align add_monoid_hom.coe_of_map_add_neg AddMonoidHom.coe_of_map_add_neg\n\n/- warning: monoid_hom.of_map_div -> MonoidHom.ofMapDiv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H), (forall (x : G) (y : G), Eq.{succ u2} H (f (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) x y)) (HDiv.hDiv.{u2, u2, u2} H H H (instHDiv.{u2} H (DivInvMonoid.toHasDiv.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))) (f x) (f y))) -> (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H), (forall (x : G) (y : G), Eq.{succ u2} H (f (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) x y)) (HDiv.hDiv.{u2, u2, u2} H H H (instHDiv.{u2} H (DivInvMonoid.toDiv.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))) (f x) (f y))) -> (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.of_map_div MonoidHom.ofMapDivₓ'. -/\n/-- Define a morphism of additive groups given a map which respects ratios. -/\n@[to_additive \"Define a morphism of additive groups given a map which respects difference.\"]\ndef ofMapDiv {H : Type _} [Group H] (f : G → H) (hf : ∀ x y, f (x / y) = f x / f y) : G →* H :=\n  ofMapMulInv f (by simpa only [div_eq_mul_inv] using hf)\n#align monoid_hom.of_map_div MonoidHom.ofMapDiv\n#align add_monoid_hom.of_map_sub AddMonoidHom.ofMapSub\n\n/- warning: monoid_hom.coe_of_map_div -> MonoidHom.coe_of_map_div is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H) (hf : forall (x : G) (y : G), Eq.{succ u2} H (f (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) x y)) (HDiv.hDiv.{u2, u2, u2} H H H (instHDiv.{u2} H (DivInvMonoid.toHasDiv.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))) (f x) (f y))), Eq.{max (succ u1) (succ u2)} (G -> H) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) (fun (_x : MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) => G -> H) (MonoidHom.hasCoeToFun.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) (MonoidHom.ofMapDiv.{u1, u2} G _inst_1 H _inst_3 f hf)) f\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {H : Type.{u2}} [_inst_3 : Group.{u2} H] (f : G -> H) (hf : forall (x : G) (y : G), Eq.{succ u2} H (f (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) x y)) (HDiv.hDiv.{u2, u2, u2} H H H (instHDiv.{u2} H (DivInvMonoid.toDiv.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))) (f x) (f y))), Eq.{max (succ u1) (succ u2)} (G -> H) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) G (fun (_x : G) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G) => H) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) G H (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MulOneClass.toMul.{u2} H (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))) G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3))) (MonoidHom.monoidHomClass.{u1, u2} G H (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Monoid.toMulOneClass.{u2} H (DivInvMonoid.toMonoid.{u2} H (Group.toDivInvMonoid.{u2} H _inst_3)))))) (MonoidHom.ofMapDiv.{u1, u2} G _inst_1 H _inst_3 f hf)) f\nCase conversion may be inaccurate. Consider using '#align monoid_hom.coe_of_map_div MonoidHom.coe_of_map_divₓ'. -/\n@[simp, to_additive]\ntheorem coe_of_map_div {H : Type _} [Group H] (f : G → H) (hf : ∀ x y, f (x / y) = f x / f y) :\n    ⇑(ofMapDiv f hf) = f :=\n  rfl\n#align monoid_hom.coe_of_map_div MonoidHom.coe_of_map_div\n#align add_monoid_hom.coe_of_map_sub AddMonoidHom.coe_of_map_sub\n\n/-- If `f` is a monoid homomorphism to a commutative group, then `f⁻¹` is the homomorphism sending\n`x` to `(f x)⁻¹`. -/\n@[to_additive]\ninstance {M G} [MulOneClass M] [CommGroup G] : Inv (M →* G) :=\n  ⟨fun f => mk' (fun g => (f g)⁻¹) fun a b => by rw [← mul_inv, f.map_mul]⟩\n\n/-- If `f` is an additive monoid homomorphism to an additive commutative group, then `-f` is the\nhomomorphism sending `x` to `-(f x)`. -/\nadd_decl_doc AddMonoidHom.hasNeg\n\n/- warning: monoid_hom.inv_apply -> MonoidHom.inv_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {G : Type.{u2}} {mM : MulOneClass.{u1} M} {gG : CommGroup.{u2} G} (f : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (x : M), Eq.{succ u2} G (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (fun (_x : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) => M -> G) (MonoidHom.hasCoeToFun.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (Inv.inv.{max u2 u1} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (MonoidHom.hasInv.{u1, u2} M G mM gG) f) x) (Inv.inv.{u2} G (DivInvMonoid.toHasInv.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (fun (_x : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) => M -> G) (MonoidHom.hasCoeToFun.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) f x))\nbut is expected to have type\n  forall {M : Type.{u2}} {G : Type.{u1}} {mM : MulOneClass.{u2} M} {gG : CommGroup.{u1} G} (f : MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG)))) (MonoidHom.monoidHomClass.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))))) (Inv.inv.{max u2 u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHom.instInvMonoidHomToMulOneClassToMonoidToDivInvMonoidToGroup.{u2, u1} M G mM gG) f) x) (Inv.inv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (InvOneClass.toInv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (DivInvOneMonoid.toInvOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (DivisionMonoid.toDivInvOneMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (DivisionCommMonoid.toDivisionMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (CommGroup.toDivisionCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) gG))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG)))) (MonoidHom.monoidHomClass.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))))) f x))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.inv_apply MonoidHom.inv_applyₓ'. -/\n@[simp, to_additive]\ntheorem inv_apply {M G} {mM : MulOneClass M} {gG : CommGroup G} (f : M →* G) (x : M) :\n    f⁻¹ x = (f x)⁻¹ :=\n  rfl\n#align monoid_hom.inv_apply MonoidHom.inv_apply\n#align add_monoid_hom.neg_apply AddMonoidHom.neg_apply\n\n/- warning: monoid_hom.inv_comp -> MonoidHom.inv_comp is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} {A : Type.{u3}} {mM : MulOneClass.{u1} M} {gN : MulOneClass.{u2} N} {gA : CommGroup.{u3} A} (φ : MonoidHom.{u2, u3} N A gN (Monoid.toMulOneClass.{u3} A (DivInvMonoid.toMonoid.{u3} A (Group.toDivInvMonoid.{u3} A (CommGroup.toGroup.{u3} A gA))))) (ψ : MonoidHom.{u1, u2} M N mM gN), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M A mM (Monoid.toMulOneClass.{u3} A (DivInvMonoid.toMonoid.{u3} A (Group.toDivInvMonoid.{u3} A (CommGroup.toGroup.{u3} A gA))))) (MonoidHom.comp.{u1, u2, u3} M N A mM gN (Monoid.toMulOneClass.{u3} A (DivInvMonoid.toMonoid.{u3} A (Group.toDivInvMonoid.{u3} A (CommGroup.toGroup.{u3} A gA)))) (Inv.inv.{max u3 u2} (MonoidHom.{u2, u3} N A gN (Monoid.toMulOneClass.{u3} A (DivInvMonoid.toMonoid.{u3} A (Group.toDivInvMonoid.{u3} A (CommGroup.toGroup.{u3} A gA))))) (MonoidHom.hasInv.{u2, u3} N A gN gA) φ) ψ) (Inv.inv.{max u3 u1} (MonoidHom.{u1, u3} M A mM (Monoid.toMulOneClass.{u3} A (DivInvMonoid.toMonoid.{u3} A (Group.toDivInvMonoid.{u3} A (CommGroup.toGroup.{u3} A gA))))) (MonoidHom.hasInv.{u1, u3} M A mM gA) (MonoidHom.comp.{u1, u2, u3} M N A mM gN (Monoid.toMulOneClass.{u3} A (DivInvMonoid.toMonoid.{u3} A (Group.toDivInvMonoid.{u3} A (CommGroup.toGroup.{u3} A gA)))) φ ψ))\nbut is expected to have type\n  forall {M : Type.{u3}} {N : Type.{u2}} {A : Type.{u1}} {mM : MulOneClass.{u3} M} {gN : MulOneClass.{u2} N} {gA : CommGroup.{u1} A} (φ : MonoidHom.{u2, u1} N A gN (Monoid.toMulOneClass.{u1} A (DivInvMonoid.toMonoid.{u1} A (Group.toDivInvMonoid.{u1} A (CommGroup.toGroup.{u1} A gA))))) (ψ : MonoidHom.{u3, u2} M N mM gN), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M A mM (Monoid.toMulOneClass.{u1} A (DivInvMonoid.toMonoid.{u1} A (Group.toDivInvMonoid.{u1} A (CommGroup.toGroup.{u1} A gA))))) (MonoidHom.comp.{u3, u2, u1} M N A mM gN (Monoid.toMulOneClass.{u1} A (DivInvMonoid.toMonoid.{u1} A (Group.toDivInvMonoid.{u1} A (CommGroup.toGroup.{u1} A gA)))) (Inv.inv.{max u2 u1} (MonoidHom.{u2, u1} N A gN (Monoid.toMulOneClass.{u1} A (DivInvMonoid.toMonoid.{u1} A (Group.toDivInvMonoid.{u1} A (CommGroup.toGroup.{u1} A gA))))) (MonoidHom.instInvMonoidHomToMulOneClassToMonoidToDivInvMonoidToGroup.{u2, u1} N A gN gA) φ) ψ) (Inv.inv.{max u1 u3} (MonoidHom.{u3, u1} M A mM (Monoid.toMulOneClass.{u1} A (DivInvMonoid.toMonoid.{u1} A (Group.toDivInvMonoid.{u1} A (CommGroup.toGroup.{u1} A gA))))) (MonoidHom.instInvMonoidHomToMulOneClassToMonoidToDivInvMonoidToGroup.{u3, u1} M A mM gA) (MonoidHom.comp.{u3, u2, u1} M N A mM gN (Monoid.toMulOneClass.{u1} A (DivInvMonoid.toMonoid.{u1} A (Group.toDivInvMonoid.{u1} A (CommGroup.toGroup.{u1} A gA)))) φ ψ))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.inv_comp MonoidHom.inv_compₓ'. -/\n@[simp, to_additive]\ntheorem inv_comp {M N A} {mM : MulOneClass M} {gN : MulOneClass N} {gA : CommGroup A} (φ : N →* A)\n    (ψ : M →* N) : φ⁻¹.comp ψ = (φ.comp ψ)⁻¹ := by\n  ext\n  simp only [Function.comp_apply, inv_apply, coe_comp]\n#align monoid_hom.inv_comp MonoidHom.inv_comp\n#align add_monoid_hom.neg_comp AddMonoidHom.neg_comp\n\n/- warning: monoid_hom.comp_inv -> MonoidHom.comp_inv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {mM : MulOneClass.{u1} M} {mA : CommGroup.{u2} A} {mB : CommGroup.{u3} B} (φ : MonoidHom.{u2, u3} A B (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA)))) (Monoid.toMulOneClass.{u3} B (DivInvMonoid.toMonoid.{u3} B (Group.toDivInvMonoid.{u3} B (CommGroup.toGroup.{u3} B mB))))) (ψ : MonoidHom.{u1, u2} M A mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA))))), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u1, u3} M B mM (Monoid.toMulOneClass.{u3} B (DivInvMonoid.toMonoid.{u3} B (Group.toDivInvMonoid.{u3} B (CommGroup.toGroup.{u3} B mB))))) (MonoidHom.comp.{u1, u2, u3} M A B mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA)))) (Monoid.toMulOneClass.{u3} B (DivInvMonoid.toMonoid.{u3} B (Group.toDivInvMonoid.{u3} B (CommGroup.toGroup.{u3} B mB)))) φ (Inv.inv.{max u2 u1} (MonoidHom.{u1, u2} M A mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA))))) (MonoidHom.hasInv.{u1, u2} M A mM mA) ψ)) (Inv.inv.{max u3 u1} (MonoidHom.{u1, u3} M B mM (Monoid.toMulOneClass.{u3} B (DivInvMonoid.toMonoid.{u3} B (Group.toDivInvMonoid.{u3} B (CommGroup.toGroup.{u3} B mB))))) (MonoidHom.hasInv.{u1, u3} M B mM mB) (MonoidHom.comp.{u1, u2, u3} M A B mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA)))) (Monoid.toMulOneClass.{u3} B (DivInvMonoid.toMonoid.{u3} B (Group.toDivInvMonoid.{u3} B (CommGroup.toGroup.{u3} B mB)))) φ ψ))\nbut is expected to have type\n  forall {M : Type.{u3}} {A : Type.{u2}} {B : Type.{u1}} {mM : MulOneClass.{u3} M} {mA : CommGroup.{u2} A} {mB : CommGroup.{u1} B} (φ : MonoidHom.{u2, u1} A B (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA)))) (Monoid.toMulOneClass.{u1} B (DivInvMonoid.toMonoid.{u1} B (Group.toDivInvMonoid.{u1} B (CommGroup.toGroup.{u1} B mB))))) (ψ : MonoidHom.{u3, u2} M A mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA))))), Eq.{max (succ u3) (succ u1)} (MonoidHom.{u3, u1} M B mM (Monoid.toMulOneClass.{u1} B (DivInvMonoid.toMonoid.{u1} B (Group.toDivInvMonoid.{u1} B (CommGroup.toGroup.{u1} B mB))))) (MonoidHom.comp.{u3, u2, u1} M A B mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA)))) (Monoid.toMulOneClass.{u1} B (DivInvMonoid.toMonoid.{u1} B (Group.toDivInvMonoid.{u1} B (CommGroup.toGroup.{u1} B mB)))) φ (Inv.inv.{max u2 u3} (MonoidHom.{u3, u2} M A mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA))))) (MonoidHom.instInvMonoidHomToMulOneClassToMonoidToDivInvMonoidToGroup.{u3, u2} M A mM mA) ψ)) (Inv.inv.{max u1 u3} (MonoidHom.{u3, u1} M B mM (Monoid.toMulOneClass.{u1} B (DivInvMonoid.toMonoid.{u1} B (Group.toDivInvMonoid.{u1} B (CommGroup.toGroup.{u1} B mB))))) (MonoidHom.instInvMonoidHomToMulOneClassToMonoidToDivInvMonoidToGroup.{u3, u1} M B mM mB) (MonoidHom.comp.{u3, u2, u1} M A B mM (Monoid.toMulOneClass.{u2} A (DivInvMonoid.toMonoid.{u2} A (Group.toDivInvMonoid.{u2} A (CommGroup.toGroup.{u2} A mA)))) (Monoid.toMulOneClass.{u1} B (DivInvMonoid.toMonoid.{u1} B (Group.toDivInvMonoid.{u1} B (CommGroup.toGroup.{u1} B mB)))) φ ψ))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_inv MonoidHom.comp_invₓ'. -/\n@[simp, to_additive]\ntheorem comp_inv {M A B} {mM : MulOneClass M} {mA : CommGroup A} {mB : CommGroup B} (φ : A →* B)\n    (ψ : M →* A) : φ.comp ψ⁻¹ = (φ.comp ψ)⁻¹ := by\n  ext\n  simp only [Function.comp_apply, inv_apply, map_inv, coe_comp]\n#align monoid_hom.comp_inv MonoidHom.comp_inv\n#align add_monoid_hom.comp_neg AddMonoidHom.comp_neg\n\n/-- If `f` and `g` are monoid homomorphisms to a commutative group, then `f / g` is the homomorphism\nsending `x` to `(f x) / (g x)`. -/\n@[to_additive]\ninstance {M G} [MulOneClass M] [CommGroup G] : Div (M →* G) :=\n  ⟨fun f g =>\n    mk' (fun x => f x / g x) fun a b => by\n      simp [div_eq_mul_inv, mul_assoc, mul_left_comm, mul_comm]⟩\n\n/-- If `f` and `g` are monoid homomorphisms to an additive commutative group, then `f - g`\nis the homomorphism sending `x` to `(f x) - (g x)`. -/\nadd_decl_doc AddMonoidHom.hasSub\n\n/- warning: monoid_hom.div_apply -> MonoidHom.div_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {G : Type.{u2}} {mM : MulOneClass.{u1} M} {gG : CommGroup.{u2} G} (f : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (g : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (x : M), Eq.{succ u2} G (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (fun (_x : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) => M -> G) (MonoidHom.hasCoeToFun.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (instHDiv.{max u2 u1} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (MonoidHom.hasDiv.{u1, u2} M G mM gG)) f g) x) (HDiv.hDiv.{u2, u2, u2} G G G (instHDiv.{u2} G (DivInvMonoid.toHasDiv.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG)))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (fun (_x : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) => M -> G) (MonoidHom.hasCoeToFun.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) (fun (_x : MonoidHom.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) => M -> G) (MonoidHom.hasCoeToFun.{u1, u2} M G mM (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G (CommGroup.toGroup.{u2} G gG))))) g x))\nbut is expected to have type\n  forall {M : Type.{u2}} {G : Type.{u1}} {mM : MulOneClass.{u2} M} {gG : CommGroup.{u1} G} (f : MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (g : MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG)))) (MonoidHom.monoidHomClass.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))))) (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (instHDiv.{max u2 u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHom.instDivMonoidHomToMulOneClassToMonoidToDivInvMonoidToGroup.{u2, u1} M G mM gG)) f g) x) (HDiv.hDiv.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (instHDiv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (DivInvMonoid.toDiv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (Group.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) (CommGroup.toGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) x) gG)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG)))) (MonoidHom.monoidHomClass.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G (MulOneClass.toMul.{u2} M mM) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))) M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG)))) (MonoidHom.monoidHomClass.{u2, u1} M G mM (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G gG))))))) g x))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.div_apply MonoidHom.div_applyₓ'. -/\n@[simp, to_additive]\ntheorem div_apply {M G} {mM : MulOneClass M} {gG : CommGroup G} (f g : M →* G) (x : M) :\n    (f / g) x = f x / g x :=\n  rfl\n#align monoid_hom.div_apply MonoidHom.div_apply\n#align add_monoid_hom.sub_apply AddMonoidHom.sub_apply\n\nend MonoidHom\n\n/-- Given two monoid with zero morphisms `f`, `g` to a commutative monoid, `f * g` is the monoid\nwith zero morphism sending `x` to `f x * g x`. -/\ninstance {M N} {hM : MulZeroOneClass M} [CommMonoidWithZero N] : Mul (M →*₀ N) :=\n  ⟨fun f g =>\n    { (f * g : M →* N) with\n      toFun := fun a => f a * g a\n      map_zero' := by rw [map_zero, MulZeroClass.zero_mul] }⟩\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Hom/Group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934765, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.49578477280183275}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport algebra.group.defs\nimport logic.equiv.basic\nimport logic.nontrivial\n\n/-!\n# Multiplicative opposite and algebraic operations on it\n\nIn this file we define `mul_opposite α = αᵐᵒᵖ` to be the multiplicative opposite of `α`. It inherits\nall additive algebraic structures on `α` (in other files), and reverses the order of multipliers in\nmultiplicative structures, i.e., `op (x * y) = op y * op x`, where `mul_opposite.op` is the\ncanonical map from `α` to `αᵐᵒᵖ`.\n\nWe also define `add_opposite α = αᵃᵒᵖ` to be the additive opposite of `α`. It inherits all\nmultiplicative algebraic structures on `α` (in other files), and reverses the order of summands in\nadditive structures, i.e. `op (x + y) = op y + op x`, where `add_opposite.op` is the canonical map\nfrom `α` to `αᵃᵒᵖ`.\n\n## Notation\n\n* `αᵐᵒᵖ = mul_opposite α`\n* `αᵃᵒᵖ = add_opposite α`\n\n## Tags\n\nmultiplicative opposite, additive opposite\n-/\n\nuniverses u v\nopen function\n\n/-- Multiplicative opposite of a type. This type inherits all additive structures on `α` and\nreverses left and right in multiplication.-/\n@[to_additive \"Additive opposite of a type. This type inherits all multiplicative structures on\n`α` and reverses left and right in addition.\"]\ndef mul_opposite (α : Type u) : Type u := α\n\npostfix `ᵐᵒᵖ`:std.prec.max_plus := mul_opposite\npostfix `ᵃᵒᵖ`:std.prec.max_plus := add_opposite\n\nvariables {α : Type u}\n\nnamespace mul_opposite\n\n/-- The element of `mul_opposite α` that represents `x : α`. -/\n@[pp_nodot, to_additive \"The element of `αᵃᵒᵖ` that represents `x : α`.\"]\ndef op : α → αᵐᵒᵖ := id\n\n/-- The element of `α` represented by `x : αᵐᵒᵖ`. -/\n@[pp_nodot, to_additive \"The element of `α` represented by `x : αᵃᵒᵖ`.\"]\ndef unop : αᵐᵒᵖ → α := id\n\nattribute [pp_nodot] add_opposite.op add_opposite.unop\n\n@[simp, to_additive] lemma unop_op (x : α) : unop (op x) = x := rfl\n@[simp, to_additive] lemma op_unop (x : αᵐᵒᵖ) : op (unop x) = x := rfl\n@[simp, to_additive] lemma op_comp_unop : (op : α → αᵐᵒᵖ) ∘ unop = id := rfl\n@[simp, to_additive] lemma unop_comp_op : (unop : αᵐᵒᵖ → α) ∘ op = id := rfl\n\nattribute [irreducible] mul_opposite\n\n/-- A recursor for `mul_opposite`. Use as `induction x using mul_opposite.rec`. -/\n@[simp, to_additive \"A recursor for `add_opposite`. Use as `induction x using add_opposite.rec`.\"]\nprotected def rec {F : Π (X : αᵐᵒᵖ), Sort v} (h : Π X, F (op X)) : Π X, F X :=\nλ X, h (unop X)\n\n/-- The canonical bijection between `α` and `αᵐᵒᵖ`. -/\n@[to_additive \"The canonical bijection between `α` and `αᵃᵒᵖ`.\",\n  simps apply symm_apply { fully_applied := ff }]\ndef op_equiv : α ≃ αᵐᵒᵖ := ⟨op, unop, unop_op, op_unop⟩\n\n@[to_additive] lemma op_bijective : bijective (op : α → αᵐᵒᵖ) := op_equiv.bijective\n@[to_additive] lemma unop_bijective : bijective (unop : αᵐᵒᵖ → α) := op_equiv.symm.bijective\n@[to_additive] lemma op_injective : injective (op : α → αᵐᵒᵖ) := op_bijective.injective\n@[to_additive] lemma op_surjective : surjective (op : α → αᵐᵒᵖ) := op_bijective.surjective\n@[to_additive] lemma unop_injective : injective (unop : αᵐᵒᵖ → α) := unop_bijective.injective\n@[to_additive] lemma unop_surjective : surjective (unop : αᵐᵒᵖ → α) := unop_bijective.surjective\n\n@[simp, to_additive] lemma op_inj {x y : α} : op x = op y ↔ x = y := op_injective.eq_iff\n@[simp, to_additive] lemma unop_inj {x y : αᵐᵒᵖ} : unop x = unop y ↔ x = y := unop_injective.eq_iff\n\nvariable (α)\n\n@[to_additive] instance [nontrivial α] : nontrivial αᵐᵒᵖ := op_injective.nontrivial\n@[to_additive] instance [inhabited α] : inhabited αᵐᵒᵖ := ⟨op default⟩\n@[to_additive] instance [subsingleton α] : subsingleton αᵐᵒᵖ := unop_injective.subsingleton\n@[to_additive] instance [unique α] : unique αᵐᵒᵖ := unique.mk' _\n@[to_additive] instance [is_empty α] : is_empty αᵐᵒᵖ := function.is_empty unop\n\ninstance [has_zero α] : has_zero αᵐᵒᵖ := { zero := op 0 }\n\n@[to_additive] instance [has_one α] : has_one αᵐᵒᵖ := { one := op 1 }\n\ninstance [has_add α] : has_add αᵐᵒᵖ :=\n{ add := λ x y, op (unop x + unop y) }\n\ninstance [has_sub α] : has_sub αᵐᵒᵖ :=\n{ sub := λ x y, op (unop x - unop y) }\n\ninstance [has_neg α] : has_neg αᵐᵒᵖ :=\n{ neg := λ x, op $ -(unop x) }\n\ninstance [has_involutive_neg α] : has_involutive_neg αᵐᵒᵖ :=\n{ neg_neg := λ a, unop_injective $ neg_neg _,\n  ..mul_opposite.has_neg α }\n\n@[to_additive] instance [has_mul α] : has_mul αᵐᵒᵖ :=\n{ mul := λ x y, op (unop y * unop x) }\n\n@[to_additive] instance [has_inv α] : has_inv αᵐᵒᵖ :=\n{ inv := λ x, op $ (unop x)⁻¹ }\n\n@[to_additive] instance [has_involutive_inv α] : has_involutive_inv αᵐᵒᵖ :=\n{ inv_inv := λ a, unop_injective $ inv_inv _,\n  ..mul_opposite.has_inv α }\n\n@[to_additive] instance (R : Type*) [has_scalar R α] : has_scalar R αᵐᵒᵖ :=\n{ smul := λ c x, op (c • unop x) }\n\nsection\nvariables (α)\n\n@[simp] lemma op_zero [has_zero α] : op (0 : α) = 0 := rfl\n@[simp] \n\n@[simp, to_additive] lemma op_one [has_one α] : op (1 : α) = 1 := rfl\n@[simp, to_additive] lemma unop_one [has_one α] : unop (1 : αᵐᵒᵖ) = 1 := rfl\n\nvariable {α}\n\n@[simp] lemma op_add [has_add α] (x y : α) : op (x + y) = op x + op y := rfl\n@[simp] lemma unop_add [has_add α] (x y : αᵐᵒᵖ) : unop (x + y) = unop x + unop y := rfl\n\n@[simp] lemma op_neg [has_neg α] (x : α) : op (-x) = -op x := rfl\n@[simp] lemma unop_neg [has_neg α] (x : αᵐᵒᵖ) : unop (-x) = -unop x := rfl\n\n@[simp, to_additive] lemma op_mul [has_mul α] (x y : α) : op (x * y) = op y * op x := rfl\n@[simp, to_additive] lemma unop_mul [has_mul α] (x y : αᵐᵒᵖ) : unop (x * y) = unop y * unop x := rfl\n\n@[simp, to_additive] lemma op_inv [has_inv α] (x : α) : op (x⁻¹) = (op x)⁻¹ := rfl\n@[simp, to_additive] lemma unop_inv [has_inv α] (x : αᵐᵒᵖ) : unop (x⁻¹) = (unop x)⁻¹ := rfl\n\n@[simp] lemma op_sub [has_sub α] (x y : α) : op (x - y) = op x - op y := rfl\n@[simp] lemma unop_sub [has_sub α] (x y : αᵐᵒᵖ) : unop (x - y) = unop x - unop y := rfl\n\n@[simp, to_additive] lemma op_smul {R : Type*} [has_scalar R α] (c : R) (a : α) :\n  op (c • a) = c • op a := rfl\n\n@[simp, to_additive] lemma unop_smul {R : Type*} [has_scalar R α] (c : R) (a : αᵐᵒᵖ) :\n  unop (c • a) = c • unop a := rfl\n\nend\n\nvariable {α}\n\n@[simp] lemma unop_eq_zero_iff [has_zero α] (a : αᵐᵒᵖ) : a.unop = (0 : α) ↔ a = (0 : αᵐᵒᵖ) :=\nunop_injective.eq_iff' rfl\n\n@[simp] lemma op_eq_zero_iff [has_zero α] (a : α) : op a = (0 : αᵐᵒᵖ) ↔ a = (0 : α) :=\nop_injective.eq_iff' rfl\n\nlemma unop_ne_zero_iff [has_zero α] (a : αᵐᵒᵖ) : a.unop ≠ (0 : α) ↔ a ≠ (0 : αᵐᵒᵖ) :=\nnot_congr $ unop_eq_zero_iff a\n\nlemma op_ne_zero_iff [has_zero α] (a : α) : op a ≠ (0 : αᵐᵒᵖ) ↔ a ≠ (0 : α) :=\nnot_congr $ op_eq_zero_iff a\n\n@[simp, to_additive] lemma unop_eq_one_iff [has_one α] (a : αᵐᵒᵖ) : a.unop = 1 ↔ a = 1 :=\nunop_injective.eq_iff' rfl\n\n@[simp, to_additive] lemma op_eq_one_iff [has_one α] (a : α) : op a = 1 ↔ a = 1 :=\nop_injective.eq_iff' rfl\n\nend mul_opposite\n\nnamespace add_opposite\n\ninstance [has_one α] : has_one αᵃᵒᵖ := { one := op 1 }\n\n@[simp] lemma op_one [has_one α] : op (1 : α) = 1 := rfl\n@[simp] lemma unop_one [has_one α] : unop 1 = (1 : α) := rfl\n\n@[simp] lemma op_eq_one_iff [has_one α] {a : α} : op a = 1 ↔ a = 1 := op_injective.eq_iff' op_one\n\n@[simp] lemma unop_eq_one_iff [has_one α] {a : αᵃᵒᵖ} : unop a = 1 ↔ a = 1 :=\nunop_injective.eq_iff' unop_one\n\ninstance [has_mul α] : has_mul αᵃᵒᵖ := { mul := λ a b, op (unop a * unop b) }\n\n@[simp] lemma op_mul [has_mul α] (a b : α) : op (a * b) = op a * op b := rfl\n@[simp] lemma unop_mul [has_mul α] (a b : αᵃᵒᵖ) : unop (a * b) = unop a * unop b := rfl\n\ninstance [has_inv α] : has_inv αᵃᵒᵖ := { inv := λ a, op (unop a)⁻¹ }\n\ninstance [has_involutive_inv α] : has_involutive_inv αᵃᵒᵖ :=\n{ inv_inv := λ a, unop_injective $ inv_inv _,\n  ..add_opposite.has_inv }\n\n@[simp] lemma op_inv [has_inv α] (a : α) : op a⁻¹ = (op a)⁻¹ := rfl\n@[simp] lemma unop_inv [has_inv α] (a : αᵃᵒᵖ) : unop a⁻¹ = (unop a)⁻¹ := rfl\n\ninstance [has_div α] : has_div αᵃᵒᵖ := { div := λ a b, op (unop a / unop b) }\n\n@[simp] lemma op_div [has_div α] (a b : α) : op (a / b) = op a / op b := rfl\n@[simp] lemma unop_div [has_div α] (a b : α) : unop (a / b) = unop a / unop b := rfl\n\nend add_opposite\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/opposites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.49578475961507906}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.propext\nimport Mathlib.Lean3Lib.init.classical\n \n\nuniverses u \n\nnamespace Mathlib\n\n/- Lemmas use by the congruence closure module -/\n\ntheorem iff_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a ↔ b) = b :=\n  Eq.symm h ▸ propext (true_iff b)\n\ntheorem iff_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a ↔ b) = a :=\n  Eq.symm h ▸ propext (iff_true a)\n\ntheorem iff_eq_true_of_eq {a : Prop} {b : Prop} (h : a = b) : (a ↔ b) = True :=\n  h ▸ propext (iff_self a)\n\ntheorem and_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a ∧ b) = b :=\n  Eq.symm h ▸ propext (true_and b)\n\ntheorem and_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a ∧ b) = a :=\n  Eq.symm h ▸ propext (and_true a)\n\ntheorem and_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a ∧ b) = False :=\n  Eq.symm h ▸ propext (false_and b)\n\ntheorem and_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a ∧ b) = False :=\n  Eq.symm h ▸ propext (and_false a)\n\ntheorem and_eq_of_eq {a : Prop} {b : Prop} (h : a = b) : (a ∧ b) = a :=\n  h ▸ propext (and_self a)\n\ntheorem or_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a ∨ b) = True :=\n  Eq.symm h ▸ propext (true_or b)\n\ntheorem or_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a ∨ b) = True :=\n  Eq.symm h ▸ propext (or_true a)\n\ntheorem or_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a ∨ b) = b :=\n  Eq.symm h ▸ propext (false_or b)\n\ntheorem or_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a ∨ b) = a :=\n  Eq.symm h ▸ propext (or_false a)\n\ntheorem or_eq_of_eq {a : Prop} {b : Prop} (h : a = b) : (a ∨ b) = a :=\n  h ▸ propext (or_self a)\n\ntheorem imp_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a → b) = b :=\n  Eq.symm h ▸ propext { mp := fun (h : True → b) => h trivial, mpr := fun (h₁ : b) (h₂ : True) => h₁ }\n\ntheorem imp_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a → b) = True :=\n  Eq.symm h ▸ propext { mp := fun (h : a → True) => trivial, mpr := fun (h₁ : True) (h₂ : a) => h₁ }\n\ntheorem imp_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a → b) = True :=\n  Eq.symm h ▸ propext { mp := fun (h : False → b) => trivial, mpr := fun (h₁ : True) (h₂ : False) => false.elim h₂ }\n\ntheorem imp_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a → b) = (¬a) :=\n  Eq.symm h ▸ propext { mp := fun (h : a → False) => h, mpr := fun (hna : ¬a) (ha : a) => hna ha }\n\n/- Remark: the congruence closure module will only use the following lemma is\n   cc_config.em is tt. -/\n\ntheorem not_imp_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (¬a → b) = a := sorry\n\ntheorem imp_eq_true_of_eq {a : Prop} {b : Prop} (h : a = b) : (a → b) = True :=\n  h ▸ propext { mp := fun (h : a → a) => trivial, mpr := fun (h : True) (ha : a) => ha }\n\ntheorem not_eq_of_eq_true {a : Prop} (h : a = True) : (¬a) = False :=\n  Eq.symm h ▸ propext not_true_iff\n\ntheorem not_eq_of_eq_false {a : Prop} (h : a = False) : (¬a) = True :=\n  Eq.symm h ▸ propext not_false_iff\n\ntheorem false_of_a_eq_not_a {a : Prop} (h : a = (¬a)) : False :=\n  (fun (this : ¬a) => absurd (eq.mpr h this) this) fun (ha : a) => absurd ha (eq.mp h ha)\n\ntheorem if_eq_of_eq_true {c : Prop} [d : Decidable c] {α : Sort u} (t : α) (e : α) (h : c = True) : ite c t e = t :=\n  if_pos (of_eq_true h)\n\ntheorem if_eq_of_eq_false {c : Prop} [d : Decidable c] {α : Sort u} (t : α) (e : α) (h : c = False) : ite c t e = e :=\n  if_neg (not_of_eq_false h)\n\ntheorem if_eq_of_eq (c : Prop) [d : Decidable c] {α : Sort u} {t : α} {e : α} (h : t = e) : ite c t e = t := sorry\n\ntheorem eq_true_of_and_eq_true_left {a : Prop} {b : Prop} (h : (a ∧ b) = True) : a = True :=\n  eq_true_intro (and.left (of_eq_true h))\n\ntheorem eq_true_of_and_eq_true_right {a : Prop} {b : Prop} (h : (a ∧ b) = True) : b = True :=\n  eq_true_intro (and.right (of_eq_true h))\n\ntheorem eq_false_of_or_eq_false_left {a : Prop} {b : Prop} (h : (a ∨ b) = False) : a = False :=\n  eq_false_intro fun (ha : a) => false.elim (eq.mp h (Or.inl ha))\n\ntheorem eq_false_of_or_eq_false_right {a : Prop} {b : Prop} (h : (a ∨ b) = False) : b = False :=\n  eq_false_intro fun (hb : b) => false.elim (eq.mp h (Or.inr hb))\n\ntheorem eq_false_of_not_eq_true {a : Prop} (h : (¬a) = True) : a = False :=\n  eq_false_intro fun (ha : a) => absurd ha (eq.mpr h trivial)\n\n/- Remark: the congruence closure module will only use the following lemma is\n   cc_config.em is tt. -/\n\ntheorem eq_true_of_not_eq_false {a : Prop} (h : (¬a) = False) : a = True :=\n  eq_true_intro (classical.by_contradiction fun (hna : ¬a) => eq.mp h hna)\n\ntheorem ne_of_eq_of_ne {α : Sort u} {a : α} {b : α} {c : α} (h₁ : a = b) (h₂ : b ≠ c) : a ≠ c :=\n  Eq.symm h₁ ▸ h₂\n\ntheorem ne_of_ne_of_eq {α : Sort u} {a : α} {b : α} {c : α} (h₁ : a ≠ b) (h₂ : b = c) : a ≠ c :=\n  h₂ ▸ h₁\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/cc_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.49578475932652116}}
{"text": "-- Copyright 2022-2023 VMware, Inc.\n-- SPDX-License-Identifier: BSD-2-Clause\n\nimport tactic.omega.main\nimport tactic.linarith\nimport tactic.split_ifs\n\n/-!\n\n# Streams\n\nDefinition of streams and some basic properties. We don't use mathlib streams\nbecause we hardly need any definitions from it.\n\nA stream over a type `a` is a `ℕ → a`.\n\nDefines agree_upto n s s', usually written with the notation s ==n== s', which\nsays that s and s' agree on all indices in 0..n (inclusive).\n\n-/\n\nuniverses u v.\n\n/-- A stream is an infinite sequence of elements from `a`.\n\nThe indices usually use the metavariable `t`, meant to represent (a discrete\nnotion of) time.\n -/\ndef stream (a: Type u) : Type u := ℕ → a.\n\nvariable {a : Type u}.\n\n/-- s₁ ==n== s₂ says that streams s₁ and s₂ are equal up to (and including) time\n`n`. -/\ndef agree_upto (n: ℕ) (s₁ s₂: stream a) := ∀ t ≤ n, s₁ t = s₂ t.\n\nnotation s ` ==` n `== ` s':35 := agree_upto n s s'.\n\ninstance stream_po [partial_order a] : partial_order (stream a) :=\n  by { unfold stream, apply_instance }.\n\n@[ext]\nlemma stream_le_ext [partial_order a] (s1 s2: stream a) :\n  s1 ≤ s2 = (∀ t, s1 t ≤ s2 t) := rfl.\n\ninstance stream_zero [has_zero a] : has_zero (stream a) := ⟨λ (_: ℕ), 0⟩.\n\n@[refl]\nlemma agree_refl (n: ℕ) : ∀ (s: stream a), s ==n== s :=\nbegin\n  unfold agree_upto,\n  intros s i _,\n  refl,\nend\n\n@[symm]\nlemma agree_symm (n: ℕ) : ∀ (s1 s2: stream a), s1 ==n== s2 → s2 ==n== s1 :=\nbegin\n  unfold agree_upto,\n  intros s1 s2 h12 i hle,\n  rw [h12]; assumption,\nend\n\n@[trans]\nlemma agree_trans {n: ℕ} : ∀ (s1 s2 s3: stream a), s1 ==n== s2 → s2 ==n== s3 → s1 ==n== s3 :=\nbegin\n  unfold agree_upto,\n  intros s1 s2 s3 h12 h23 i hle,\n  rw [h12, h23]; assumption,\nend\n\n-- TODO: these don't seem to do anything (don't help with rewriting)\ninstance agree_upto_refl (n: ℕ) : is_refl (stream a) (agree_upto n) := ⟨agree_refl n⟩.\ninstance agree_upto_symm (n: ℕ) : is_symm (stream a) (agree_upto n) := ⟨agree_symm n⟩.\ninstance agree_upto_trans (n: ℕ) : is_trans (stream a) (agree_upto n) := ⟨agree_trans⟩.\ninstance agree_upto_preorder (n: ℕ) : is_preorder (stream a) (agree_upto n) := ⟨⟩.\ninstance agree_upto_equiv (n: ℕ) : is_equiv (stream a) (agree_upto n) := ⟨⟩.\n\ntheorem agree_everywhere_eq (s s': stream a) :\n  s = s' ↔ (∀ n, s ==n== s') :=\nbegin\n  split,\n  { intros h n,\n    rw h, },\n  { intros h,\n    funext n,\n    apply (h n), omega,\n   }\nend\n\nlemma agree_upto_weaken {s s': stream a} (n n': ℕ) :\n  s ==n== s' →\n  n' ≤ n →\n  s ==n'== s' :=\nbegin\n  intros heq hle,\n  intros i hle_i,\n  apply heq, omega,\nend\n\nlemma agree_upto_weaken1 {s s': stream a} (n: ℕ) :\n  s ==n.succ== s' →\n  s ==n== s' :=\nbegin\n  intros heq,\n  apply (agree_upto_weaken n.succ), assumption, omega,\nend\n\nlemma agree_upto_0 (s s': stream a) :\n  s ==0== s' ↔ s 0 = s' 0 :=\nbegin\n  unfold agree_upto,\n  split,\n  { intros hagree,\n    apply (hagree 0),\n    omega, },\n  { intros h0 t hle,\n    have h: (t = 0) := by omega,\n    cc, }\nend\n\nlemma agree_upto_extend (n: nat) (s s': stream a) :\n  s ==n== s' → s n.succ = s' n.succ → s ==n.succ== s' :=\nbegin\n  intros hagree heq,\n  intros i hle,\n  have h: (i ≤ n ∨ i = n.succ) := by omega,\n  cases h,\n  { apply hagree, assumption, },\n  { subst i, assumption, }\nend\n\n-- We don't use this theory because everything is based on [agree_upto], but\n-- formalize a little bit from the paper.\nnamespace cutting.\n\nvariables [has_zero a].\n\n/-- Construct a stream that matches `s` up to time `t` and is 0 afterward. -/\ndef cut (s: stream a) (t: ℕ) : stream a :=\n  λ i, if (i < t) then s i else 0.\n\nlemma cut_at_0 (s: stream a) : cut s 0 = 0 :=\nbegin\n  ext n,\n  unfold cut, rw if_neg, simp,\n  omega,\nend\n\nlemma cut_0 : cut (0 : stream a) = 0 :=\nbegin\n  ext n,\n  unfold cut, split_ifs; refl,\nend\n\ntheorem cut_cut (s: stream a) (t1 t2: ℕ) :\n  cut (cut s t1) t2 = cut s (min t1 t2) :=\nbegin\n  funext i, simp [cut],\n  split_ifs; try { simp },\n  tauto,\n  { exfalso, linarith, },\n  { exfalso, linarith, },\nend\n\ntheorem cut_comm (s: stream a) (t1 t2: ℕ) :\n  cut (cut s t1) t2 = cut (cut s t2) t1 :=\nbegin\n  rw [cut_cut, cut_cut],\n  rw min_comm,\nend\n\ntheorem cut_idem (s: stream a) (t: ℕ) :\n  cut (cut s t) t = cut s t :=\nbegin\n  rw cut_cut, simp,\nend\n\n/-- Relate [agree_upto] to equality on [cut]. -/\ntheorem agree_upto_cut (s1 s2: stream a) (n: ℕ) :\n  s1 ==n== s2 ↔ cut s1 n.succ = cut s2 n.succ :=\nbegin\n  split,\n  { intros heq,\n    funext t, simp [cut],\n    split_ifs; try { refl },\n    apply heq, omega, },\n  { intros heq,\n    intros t hle, simp [cut] at heq,\n    have h := congr_fun heq t, simp at h,\n    split_ifs at *,\n    { assumption, },\n    { exfalso, apply h_1, omega, },\n  },\nend\n\nlemma cut_agree_succ (s1 s2: stream a) (t: ℕ) :\n  cut s1 t = cut s2 t →\n  s1 t = s2 t →\n  cut s1 t.succ = cut s2 t.succ :=\nbegin\n  cases t,\n  { intros _hcut heq,\n    ext n,\n    unfold cut, split_ifs, swap, refl,\n    have heq : n = 0 := by omega,\n    subst n, assumption,\n  },\n  repeat { rw<- agree_upto_cut },\n  apply agree_upto_extend,\nend\n\ntheorem agree_with_cut (s: stream a) (n: ℕ) :\n  s ==n== cut s n.succ :=\nbegin\n  rw [agree_upto_cut, cut_idem],\nend\n\nend cutting.\n\n-- #lint only doc_blame simp_nf\n", "meta": {"author": "tchajed", "repo": "database-stream-processing-theory", "sha": "c4c3b7ced9f964f3ea17db77958df78f2d761509", "save_path": "github-repos/lean/tchajed-database-stream-processing-theory", "path": "github-repos/lean/tchajed-database-stream-processing-theory/database-stream-processing-theory-c4c3b7ced9f964f3ea17db77958df78f2d761509/src/stream.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.782662489091802, "lm_q1q2_score": 0.495746453586393}}
{"text": "import algebra.field\nimport gtm106.weierstrass_equation.basic\nimport gtm106.weierstrass_equation.point\nimport gtm106.weierstrass_equation.group_law.basic\nimport tactic\n\nnamespace weierstrass_equation\n\nnamespace affine_point\n\n-- copied from [Fri17] An elementary proof of the group law for elliptic curves\n\nlemma add.assoc.lemma_2_3\n{K : Type*} [field K] {E : weierstrass_equation K}\n(P : affine_plane_point K)\n(h : E.affine_point_on_curve P)\n(hnot2tors : neg_of_double_of_affine_plane_point.C E P ≠ 0)\n(h2not2tors : neg_of_double_of_affine_plane_point.C E (E.double_of_affine_plane_point P) ≠ 0)\n(hx31 : (E.add_of_affine_plane_point (E.double_of_affine_plane_point P) P).x - P.x ≠ 0)\n(hx21 : (E.double_of_affine_plane_point P).x - P.x ≠ 0)\n: (E.double_of_affine_plane_point (E.double_of_affine_plane_point P))\n= E.add_of_affine_plane_point P (E.add_of_affine_plane_point P (E.double_of_affine_plane_point P)) :=\nbegin\n  sorry,\nend\n\nend affine_point\n\nend weierstrass_equation\n", "meta": {"author": "acmepjz", "repo": "my-lean-test", "sha": "fd1bb144adc9ccd23794a867a2dd2cf57648b089", "save_path": "github-repos/lean/acmepjz-my-lean-test", "path": "github-repos/lean/acmepjz-my-lean-test/my-lean-test-fd1bb144adc9ccd23794a867a2dd2cf57648b089/gtm106/weierstrass_equation/group_law/add_assoc_lemma_2_3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8757870046160258, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.49571167749654427}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nRelator for functions, pairs, sums, and lists.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.reserved_notation\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ u_1 u_2 \n\nnamespace Mathlib\n\nnamespace relator\n\n\n/- TODO(johoelzl):\n * should we introduce relators of datatypes as recursive function or as inductive\npredicate? For now we stick to the recursor approach.\n * relation lift for datatypes, Π, Σ, set, and subtype types\n * proof composition and identity laws\n * implement method to derive relators from datatype\n-/\n\ndef lift_fun {α : Sort u₁} {β : Sort u₂} {γ : Sort v₁} {δ : Sort v₂} (R : α → β → Prop) (S : γ → δ → Prop) (f : α → γ) (g : β → δ) :=\n  ∀ {a : α} {b : β}, R a b → S (f a) (g b)\n\ninfixr:40 \" ⇒ \" => Mathlib.relator.lift_fun\n\ndef right_total {α : Type u₁} {β : outParam (Type u₂)} (R : outParam (α → β → Prop)) :=\n  ∀ (b : β), ∃ (a : α), R a b\n\ndef left_total {α : Type u₁} {β : outParam (Type u₂)} (R : outParam (α → β → Prop)) :=\n  ∀ (a : α), ∃ (b : β), R a b\n\ndef bi_total {α : Type u₁} {β : outParam (Type u₂)} (R : outParam (α → β → Prop)) :=\n  left_total R ∧ right_total R\n\ndef left_unique {α : Type u₁} {β : Type u₂} (R : α → β → Prop) :=\n  ∀ {a : α} {b : β} {c : α}, R a b → R c b → a = c\n\ndef right_unique {α : Type u₁} {β : Type u₂} (R : α → β → Prop) :=\n  ∀ {a : α} {b c : β}, R a b → R a c → b = c\n\ntheorem rel_forall_of_right_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop) [t : right_total R] : lift_fun (R ⇒ implies) implies (fun (p : α → Prop) => ∀ (i : α), p i) fun (q : β → Prop) => ∀ (i : β), q i :=\n  fun (p : α → Prop) (q : β → Prop) (Hrel : lift_fun R implies p q) (H : ∀ (i : α), p i) (b : β) =>\n    exists.elim (t b) fun (a : α) (Rab : R a b) => Hrel Rab (H a)\n\ntheorem rel_exists_of_left_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop) [t : left_total R] : lift_fun (R ⇒ implies) implies (fun (p : α → Prop) => ∃ (i : α), p i) fun (q : β → Prop) => ∃ (i : β), q i := sorry\n\ntheorem rel_forall_of_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop) [t : bi_total R] : lift_fun (R ⇒ Iff) Iff (fun (p : α → Prop) => ∀ (i : α), p i) fun (q : β → Prop) => ∀ (i : β), q i := sorry\n\ntheorem rel_exists_of_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop) [t : bi_total R] : lift_fun (R ⇒ Iff) Iff (fun (p : α → Prop) => ∃ (i : α), p i) fun (q : β → Prop) => ∃ (i : β), q i := sorry\n\ntheorem left_unique_of_rel_eq {α : Type u₁} {β : Type u₂} (R : α → β → Prop) {eq' : β → β → Prop} (he : lift_fun R (R ⇒ Iff) Eq eq') : left_unique R :=\n  fun {a : α} {b : β} {c : α} (ᾰ : R a b) (ᾰ_1 : R c b) =>\n    idRhs (a = c) ((fun (this : eq' b b) => iff.mpr (he ᾰ ᾰ_1) this) (iff.mp (he ᾰ ᾰ) rfl))\n\ntheorem rel_imp : lift_fun Iff (Iff ⇒ Iff) implies implies :=\n  fun (p q : Prop) (h : p ↔ q) (r s : Prop) (l : r ↔ s) => imp_congr h l\n\ntheorem rel_not : lift_fun Iff Iff Not Not :=\n  fun (p q : Prop) (h : p ↔ q) => not_congr h\n\n-- (this is an instance is always applies, since the relation is an out-param)\n\nprotected instance bi_total_eq {α : Type u₁} : bi_total Eq :=\n  { left := fun (a : α) => Exists.intro a rfl, right := fun (a : α) => Exists.intro a rfl }\n\ndef bi_unique {α : Type u_1} {β : Type u_2} (r : α → β → Prop) :=\n  left_unique r ∧ right_unique r\n\ntheorem left_unique_flip {α : Type u_1} {β : Type u_2} {r : α → β → Prop} (h : left_unique r) : right_unique (flip r) :=\n  fun {a : β} {b c : α} (ᾰ : flip r a b) (ᾰ_1 : flip r a c) => idRhs (b = c) (h ᾰ ᾰ_1)\n\ntheorem rel_and : lift_fun Iff (Iff ⇒ Iff) And And :=\n  fun (a b : Prop) (h₁ : a ↔ b) (c d : Prop) (h₂ : c ↔ d) => and_congr h₁ h₂\n\ntheorem rel_or : lift_fun Iff (Iff ⇒ Iff) Or Or :=\n  fun (a b : Prop) (h₁ : a ↔ b) (c d : Prop) (h₂ : c ↔ d) => or_congr h₁ h₂\n\ntheorem rel_iff : lift_fun Iff (Iff ⇒ Iff) Iff Iff :=\n  fun (a b : Prop) (h₁ : a ↔ b) (c d : Prop) (h₂ : c ↔ d) => iff_congr h₁ h₂\n\ntheorem rel_eq {α : Type u_1} {β : Type u_2} {r : α → β → Prop} (hr : bi_unique r) : lift_fun r (r ⇒ Iff) Eq Eq :=\n  fun (a : α) (b : β) (h₁ : r a b) (c : α) (d : β) (h₂ : r c d) =>\n    { mp := fun (h : a = c) => Eq._oldrec (fun (h₂ : r a d) => and.right hr a b d h₁ h₂) h h₂,\n      mpr := fun (h : b = d) => Eq._oldrec (fun (h₂ : r c b) => and.left hr a b c h₁ h₂) h h₂ }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/logic/relator.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.4956839264799733}}
{"text": "/-\nCopyright (c) 2021 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.jacobson\nimport Mathlib.field_theory.algebraic_closure\nimport Mathlib.field_theory.mv_polynomial\nimport Mathlib.algebraic_geometry.prime_spectrum\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Nullstellensatz\nThis file establishes a version of Hilbert's classical Nullstellensatz for `mv_polynomial`s.\nThe main statement of the theorem is `vanishing_ideal_zero_locus_eq_radical`.\n\nThe statement is in terms of new definitions `vanishing_ideal` and `zero_locus`.\nMathlib already has versions of these in terms of the prime spectrum of a ring,\n  but those are not well-suited for expressing this result.\nSuggestions for better ways to state this theorem or organize things are welcome.\n\nThe machinery around `vanishing_ideal` and `zero_locus` is also minimal, I only added lemmas\n  directly needed in this proof, since I'm not sure if they are the right approach.\n-/\n\nnamespace mv_polynomial\n\n\n/-- Set of points that are zeroes of all polynomials in an ideal -/\ndef zero_locus {k : Type u_1} [field k] {σ : Type u_2} (I : ideal (mv_polynomial σ k)) : set (σ → k) :=\n  set_of fun (x : σ → k) => ∀ (p : mv_polynomial σ k), p ∈ I → coe_fn (eval x) p = 0\n\n@[simp] theorem mem_zero_locus_iff {k : Type u_1} [field k] {σ : Type u_2} {I : ideal (mv_polynomial σ k)} {x : σ → k} : x ∈ zero_locus I ↔ ∀ (p : mv_polynomial σ k), p ∈ I → coe_fn (eval x) p = 0 :=\n  iff.rfl\n\ntheorem zero_locus_anti_mono {k : Type u_1} [field k] {σ : Type u_2} {I : ideal (mv_polynomial σ k)} {J : ideal (mv_polynomial σ k)} (h : I ≤ J) : zero_locus J ≤ zero_locus I :=\n  fun (x : σ → k) (hx : x ∈ zero_locus J) (p : mv_polynomial σ k) (hp : p ∈ I) => hx p (h hp)\n\ntheorem zero_locus_bot {k : Type u_1} [field k] {σ : Type u_2} : zero_locus ⊥ = ⊤ :=\n  iff.mpr eq_top_iff\n    fun (x : σ → k) (hx : x ∈ ⊤) (p : mv_polynomial σ k) (hp : p ∈ ⊥) =>\n      trans (congr_arg (⇑(eval x)) (iff.mp ideal.mem_bot hp)) (ring_hom.map_zero (eval x))\n\ntheorem zero_locus_top {k : Type u_1} [field k] {σ : Type u_2} : zero_locus ⊤ = ⊥ :=\n  iff.mpr eq_bot_iff\n    fun (x : σ → k) (hx : x ∈ zero_locus ⊤) => one_ne_zero (ring_hom.map_one (eval x) ▸ hx 1 submodule.mem_top)\n\n/-- Ideal of polynomials with common zeroes at all elements of a set -/\ndef vanishing_ideal {k : Type u_1} [field k] {σ : Type u_2} (V : set (σ → k)) : ideal (mv_polynomial σ k) :=\n  submodule.mk (set_of fun (p : mv_polynomial σ k) => ∀ (x : σ → k), x ∈ V → coe_fn (eval x) p = 0) sorry sorry sorry\n\n@[simp] theorem mem_vanishing_ideal_iff {k : Type u_1} [field k] {σ : Type u_2} {V : set (σ → k)} {p : mv_polynomial σ k} : p ∈ vanishing_ideal V ↔ ∀ (x : σ → k), x ∈ V → coe_fn (eval x) p = 0 :=\n  iff.rfl\n\ntheorem vanishing_ideal_anti_mono {k : Type u_1} [field k] {σ : Type u_2} {A : set (σ → k)} {B : set (σ → k)} (h : A ≤ B) : vanishing_ideal B ≤ vanishing_ideal A :=\n  fun (p : mv_polynomial σ k) (hp : p ∈ vanishing_ideal B) (x : σ → k) (hx : x ∈ A) => hp x (h hx)\n\ntheorem vanishing_ideal_empty {k : Type u_1} [field k] {σ : Type u_2} : vanishing_ideal ∅ = ⊤ :=\n  le_antisymm le_top fun (p : mv_polynomial σ k) (hp : p ∈ ⊤) (x : σ → k) (hx : x ∈ ∅) => absurd hx (set.not_mem_empty x)\n\ntheorem le_vanishing_ideal_zero_locus {k : Type u_1} [field k] {σ : Type u_2} (I : ideal (mv_polynomial σ k)) : I ≤ vanishing_ideal (zero_locus I) :=\n  fun (p : mv_polynomial σ k) (hp : p ∈ I) (x : σ → k) (hx : x ∈ zero_locus I) => hx p hp\n\ntheorem zero_locus_vanishing_ideal_le {k : Type u_1} [field k] {σ : Type u_2} (V : set (σ → k)) : V ≤ zero_locus (vanishing_ideal V) :=\n  fun (V_1 : σ → k) (hV : V_1 ∈ V) (p : mv_polynomial σ k) (hp : p ∈ vanishing_ideal V) => hp V_1 hV\n\ntheorem zero_locus_vanishing_ideal_galois_connection {k : Type u_1} [field k] {σ : Type u_2} : galois_connection zero_locus vanishing_ideal :=\n  fun (I : ideal (mv_polynomial σ k)) (V : order_dual (set (σ → k))) =>\n    { mp := fun (h : zero_locus I ≤ V) => le_trans (le_vanishing_ideal_zero_locus I) (vanishing_ideal_anti_mono h),\n      mpr := fun (h : I ≤ vanishing_ideal V) => le_trans (zero_locus_anti_mono h) (zero_locus_vanishing_ideal_le V) }\n\ntheorem mem_vanishing_ideal_singleton_iff {k : Type u_1} [field k] {σ : Type u_2} (x : σ → k) (p : mv_polynomial σ k) : p ∈ vanishing_ideal (singleton x) ↔ coe_fn (eval x) p = 0 :=\n  { mp := fun (h : p ∈ vanishing_ideal (singleton x)) => h x rfl,\n    mpr := fun (hpx : coe_fn (eval x) p = 0) (y : σ → k) (hy : y ∈ singleton x) => Eq.symm hy ▸ hpx }\n\nprotected instance vanishing_ideal_singleton_is_maximal {k : Type u_1} [field k] {σ : Type u_2} {x : σ → k} : ideal.is_maximal (vanishing_ideal (singleton x)) := sorry\n\ntheorem radical_le_vanishing_ideal_zero_locus {k : Type u_1} [field k] {σ : Type u_2} (I : ideal (mv_polynomial σ k)) : ideal.radical I ≤ vanishing_ideal (zero_locus I) := sorry\n\n/-- The point in the prime spectrum assosiated to a given point -/\ndef point_to_point {k : Type u_1} [field k] {σ : Type u_2} (x : σ → k) : prime_spectrum (mv_polynomial σ k) :=\n  { val := vanishing_ideal (singleton x), property := sorry }\n\n@[simp] theorem vanishing_ideal_point_to_point {k : Type u_1} [field k] {σ : Type u_2} (V : set (σ → k)) : prime_spectrum.vanishing_ideal (point_to_point '' V) = vanishing_ideal V := sorry\n\ntheorem point_to_point_zero_locus_le {k : Type u_1} [field k] {σ : Type u_2} (I : ideal (mv_polynomial σ k)) : point_to_point '' zero_locus I ≤ prime_spectrum.zero_locus ↑I := sorry\n\ntheorem is_maximal_iff_eq_vanishing_ideal_singleton {k : Type u_1} [field k] {σ : Type u_2} [is_alg_closed k] [fintype σ] (I : ideal (mv_polynomial σ k)) : ideal.is_maximal I ↔ ∃ (x : σ → k), I = vanishing_ideal (singleton x) := sorry\n\n/-- Main statement of the Nullstellensatz -/\n@[simp] theorem vanishing_ideal_zero_locus_eq_radical {k : Type u_1} [field k] {σ : Type u_2} [is_alg_closed k] [fintype σ] (I : ideal (mv_polynomial σ k)) : vanishing_ideal (zero_locus I) = ideal.radical I := sorry\n\n@[simp] theorem is_prime.vanishing_ideal_zero_locus {k : Type u_1} [field k] {σ : Type u_2} [is_alg_closed k] [fintype σ] (P : ideal (mv_polynomial σ k)) [h : ideal.is_prime P] : vanishing_ideal (zero_locus P) = P :=\n  trans (vanishing_ideal_zero_locus_eq_radical P) (ideal.is_prime.radical h)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/nullstellensatz.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.49568392246932025}}
{"text": "import tactic.norm_cast\n\nconstant cardinal : Type\n@[instance] constant cardinal.has_zero : has_zero cardinal\n@[instance] constant cardinal.has_one : has_one cardinal\n@[instance] constant cardinal.has_add : has_add cardinal\nconstant cardinal.succ : cardinal → cardinal\n\n@[instance] constant cardinal.has_coe_from_nat : has_coe ℕ cardinal\n\n@[norm_cast] axiom coe_zero : ((0 : ℕ) : cardinal) = 0\n@[norm_cast] axiom coe_one : ((1 : ℕ) : cardinal) = 1\n@[norm_cast] axiom coe_add {a b : ℕ} : ((a + b : ℕ) : cardinal) = a + b\n@[norm_cast] lemma coe_bit0 {a : ℕ} : ((bit0 a : ℕ) : cardinal) = bit0 a := coe_add\n@[norm_cast] lemma coe_bit1 {a : ℕ} : ((bit1 a : ℕ) : cardinal) = bit1 a :=\nby unfold bit1; norm_cast\n@[norm_cast, priority 900] axiom coe_succ {n : ℕ} : (n.succ : cardinal) = cardinal.succ n\n\nexample : cardinal.succ 0 = 1 := by norm_cast\nexample : cardinal.succ 1 = 2 := by norm_cast\nexample : cardinal.succ 2 = 3 := by norm_cast\nexample : cardinal.succ 3 = 4 := by norm_cast\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/norm_cast_cardinal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.49568391797785494}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Yaël Dillies, Bhavik Mehta\n\n! This file was ported from Lean 3 source module data.finset.sigma\n! leanprover-community/mathlib commit 9003f28797c0664a49e4179487267c494477d853\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Finset.Lattice\nimport Mathlib.Data.Set.Sigma\n\n/-!\n# Finite sets in a sigma type\n\nThis file defines a few `Finset` constructions on `Σ i, α i`.\n\n## Main declarations\n\n* `Finset.sigma`: Given a finset `s` in `ι` and finsets `t i` in each `α i`, `s.sigma t` is the\n  finset of the dependent sum `Σ i, α i`\n* `Finset.sigmaLift`: Lifts maps `α i → β i → Finset (γ i)` to a map\n  `Σ i, α i → Σ i, β i → Finset (Σ i, γ i)`.\n\n## TODO\n\n`Finset.sigmaLift` can be generalized to any alternative functor. But to make the generalization\nworth it, we must first refactor the functor library so that the `alternative` instance for `Finset`\nis computable and universe-polymorphic.\n-/\n\n\nopen Function Multiset\n\nvariable {ι : Type _}\n\nnamespace Finset\n\nsection Sigma\n\nvariable {α : ι → Type _} {β : Type _} (s s₁ s₂ : Finset ι) (t t₁ t₂ : ∀ i, Finset (α i))\n\n/-- `s.sigma t` is the finset of dependent pairs `⟨i, a⟩` such that `i ∈ s` and `a ∈ t i`. -/\nprotected def sigma : Finset (Σi, α i) :=\n  ⟨_, s.nodup.sigma fun i => (t i).nodup⟩\n#align finset.sigma Finset.sigma\n\nvariable {s s₁ s₂ t t₁ t₂}\n\n@[simp]\ntheorem mem_sigma {a : Σi, α i} : a ∈ s.sigma t ↔ a.1 ∈ s ∧ a.2 ∈ t a.1 :=\n  Multiset.mem_sigma\n#align finset.mem_sigma Finset.mem_sigma\n\n@[simp, norm_cast]\ntheorem coe_sigma (s : Finset ι) (t : ∀ i, Finset (α i)) :\n    (s.sigma t : Set (Σi, α i)) = (s : Set ι).Sigma fun i => (t i : Set (α i)) :=\n  Set.ext fun _ => mem_sigma\n#align finset.coe_sigma Finset.coe_sigma\n\n@[simp]\ntheorem sigma_nonempty : (s.sigma t).Nonempty ↔ ∃ i ∈ s, (t i).Nonempty := by simp [Finset.Nonempty]\n#align finset.sigma_nonempty Finset.sigma_nonempty\n\n@[simp]\ntheorem sigma_eq_empty : s.sigma t = ∅ ↔ ∀ i ∈ s, t i = ∅ := by\n  simp only [← not_nonempty_iff_eq_empty, sigma_nonempty, not_exists, not_and]\n#align finset.sigma_eq_empty Finset.sigma_eq_empty\n\n@[mono]\ntheorem sigma_mono (hs : s₁ ⊆ s₂) (ht : ∀ i, t₁ i ⊆ t₂ i) : s₁.sigma t₁ ⊆ s₂.sigma t₂ :=\n  fun ⟨i, _⟩ h =>\n  let ⟨hi, ha⟩ := mem_sigma.1 h\n  mem_sigma.2 ⟨hs hi, ht i ha⟩\n#align finset.sigma_mono Finset.sigma_mono\n\ntheorem pairwiseDisjoint_map_sigmaMk :\n    (s : Set ι).PairwiseDisjoint fun i => (t i).map (Embedding.sigmaMk i) := by\n  intro i _ j _ hij\n  rw [Function.onFun, disjoint_left]\n  simp_rw [mem_map, Function.Embedding.sigmaMk_apply]\n  rintro _ ⟨y, _, rfl⟩ ⟨z, _, hz'⟩\n  exact hij (congr_arg Sigma.fst hz'.symm)\n#align finset.pairwise_disjoint_map_sigma_mk Finset.pairwiseDisjoint_map_sigmaMk\n\n@[simp]\ntheorem disjUnionᵢ_map_sigma_mk :\n    s.disjUnionᵢ (fun i => (t i).map (Embedding.sigmaMk i)) pairwiseDisjoint_map_sigmaMk =\n      s.sigma t :=\n  rfl\n#align finset.disj_Union_map_sigma_mk Finset.disjUnionᵢ_map_sigma_mk\n\ntheorem sigma_eq_bunionᵢ [DecidableEq (Σi, α i)] (s : Finset ι) (t : ∀ i, Finset (α i)) :\n    s.sigma t = s.bunionᵢ fun i => (t i).map <| Embedding.sigmaMk i := by\n  ext ⟨x, y⟩\n  simp [and_left_comm]\n#align finset.sigma_eq_bUnion Finset.sigma_eq_bunionᵢ\n\nvariable (s t) (f : (Σi, α i) → β)\n\ntheorem sup_sigma [SemilatticeSup β] [OrderBot β] :\n    (s.sigma t).sup f = s.sup fun i => (t i).sup fun b => f ⟨i, b⟩ :=\n  by\n  simp only [le_antisymm_iff, Finset.sup_le_iff, mem_sigma, and_imp, Sigma.forall]\n  exact\n    ⟨fun i a hi ha => (le_sup hi).trans' <| le_sup (f := fun a => f ⟨i, a⟩) ha, fun i hi a ha =>\n      le_sup <| mem_sigma.2 ⟨hi, ha⟩⟩\n#align finset.sup_sigma Finset.sup_sigma\n\ntheorem inf_sigma [SemilatticeInf β] [OrderTop β] :\n    (s.sigma t).inf f = s.inf fun i => (t i).inf fun b => f ⟨i, b⟩ :=\n  @sup_sigma _ _ βᵒᵈ _ _ _ _ _\n#align finset.inf_sigma Finset.inf_sigma\n\nend Sigma\n\nsection SigmaLift\n\nvariable {α β γ : ι → Type _} [DecidableEq ι]\n\n/-- Lifts maps `α i → β i → Finset (γ i)` to a map `Σ i, α i → Σ i, β i → Finset (Σ i, γ i)`. -/\ndef sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α) (b : Sigma β) :\n    Finset (Sigma γ) :=\n  dite (a.1 = b.1) (fun h => (f (h ▸ a.2) b.2).map <| Embedding.sigmaMk _) fun _ => ∅\n#align finset.sigma_lift Finset.sigmaLift\n\ntheorem mem_sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α) (b : Sigma β)\n    (x : Sigma γ) :\n    x ∈ sigmaLift f a b ↔ ∃ (ha : a.1 = x.1)(hb : b.1 = x.1), x.2 ∈ f (ha ▸ a.2) (hb ▸ b.2) :=\n  by\n  obtain ⟨⟨i, a⟩, j, b⟩ := a, b\n  obtain rfl | h := Decidable.eq_or_ne i j\n  · constructor\n    · simp_rw [sigmaLift, dif_pos rfl, mem_map, Embedding.sigmaMk_apply]\n      simp only [dite_eq_ite, ite_true, mem_map, Embedding.sigmaMk_apply, forall_exists_index,\n        and_imp]\n      rintro x hx rfl\n      exact ⟨rfl, rfl, hx⟩\n    · rintro ⟨⟨⟩, ⟨⟩, hx⟩\n      rw [sigmaLift, dif_pos rfl, mem_map]\n      exact ⟨_, hx, by simp [Sigma.ext_iff]⟩\n  · rw [sigmaLift, dif_neg h]\n    refine' iff_of_false (not_mem_empty _) _\n    rintro ⟨⟨⟩, ⟨⟩, _⟩\n    exact h rfl\n#align finset.mem_sigma_lift Finset.mem_sigmaLift\n\ntheorem mk_mem_sigmaLift (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (i : ι) (a : α i) (b : β i)\n    (x : γ i) : (⟨i, x⟩ : Sigma γ) ∈ sigmaLift f ⟨i, a⟩ ⟨i, b⟩ ↔ x ∈ f a b :=\n  by\n  rw [sigmaLift, dif_pos rfl, mem_map]\n  refine' ⟨_, fun hx => ⟨_, hx, rfl⟩⟩\n  rintro ⟨x, hx, _, rfl⟩\n  exact hx\n#align finset.mk_mem_sigma_lift Finset.mk_mem_sigmaLift\n\ntheorem not_mem_sigmaLift_of_ne_left (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) (a : Sigma α)\n    (b : Sigma β) (x : Sigma γ) (h : a.1 ≠ x.1) : x ∉ sigmaLift f a b := by\n  rw [mem_sigmaLift]\n  exact fun H => h H.fst\n#align finset.not_mem_sigma_lift_of_ne_left Finset.not_mem_sigmaLift_of_ne_left\n\ntheorem not_mem_sigmaLift_of_ne_right (f : ∀ ⦃i⦄, α i → β i → Finset (γ i)) {a : Sigma α}\n    (b : Sigma β) {x : Sigma γ} (h : b.1 ≠ x.1) : x ∉ sigmaLift f a b := by\n  rw [mem_sigmaLift]\n  exact fun H => h H.snd.fst\n#align finset.not_mem_sigma_lift_of_ne_right Finset.not_mem_sigmaLift_of_ne_right\n\nvariable {f g : ∀ ⦃i⦄, α i → β i → Finset (γ i)} {a : Σi, α i} {b : Σi, β i}\n\ntheorem sigmaLift_nonempty :\n    (sigmaLift f a b).Nonempty ↔ ∃ h : a.1 = b.1, (f (h ▸ a.2) b.2).Nonempty := by\n  simp_rw [nonempty_iff_ne_empty, sigmaLift]\n  split_ifs with h <;> simp [h]\n#align finset.sigma_lift_nonempty Finset.sigmaLift_nonempty\n\ntheorem sigmaLift_eq_empty : sigmaLift f a b = ∅ ↔ ∀ h : a.1 = b.1, f (h ▸ a.2) b.2 = ∅ := by\n  simp_rw [nonempty_iff_ne_empty, sigmaLift]\n  split_ifs with h\n  . simp [h, forall_prop_of_true h]\n  . simp [h, forall_prop_of_false h]\n#align finset.sigma_lift_eq_empty Finset.sigmaLift_eq_empty\n\ntheorem sigmaLift_mono (h : ∀ ⦃i⦄ ⦃a : α i⦄ ⦃b : β i⦄, f a b ⊆ g a b) (a : Σi, α i) (b : Σi, β i) :\n    sigmaLift f a b ⊆ sigmaLift g a b := by\n  rintro x hx\n  rw [mem_sigmaLift] at hx⊢\n  obtain ⟨ha, hb, hx⟩ := hx\n  exact ⟨ha, hb, h hx⟩\n#align finset.sigma_lift_mono Finset.sigmaLift_mono\n\nvariable (f a b)\n\ntheorem card_sigmaLift :\n    (sigmaLift f a b).card = dite (a.1 = b.1) (fun h => (f (h ▸ a.2) b.2).card) fun _ => 0 := by\n  simp_rw [nonempty_iff_ne_empty, sigmaLift]\n  split_ifs with h <;> simp [h]\n#align finset.card_sigma_lift Finset.card_sigmaLift\n\nend SigmaLift\n\nend Finset\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Finset/Sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6959583250334527, "lm_q1q2_score": 0.49568391797785494}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Floris van Doorn\n-/\nimport algebra.module.basic\nimport data.set.pairwise.lattice\nimport data.set.pointwise.basic\nimport tactic.by_contra\n\n/-!\n# Pointwise operations of sets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines pointwise algebraic operations on sets.\n\n## Main declarations\n\nFor sets `s` and `t` and scalar `a`:\n* `s • t`: Scalar multiplication, set of all `x • y` where `x ∈ s` and `y ∈ t`.\n* `s +ᵥ t`: Scalar addition, set of all `x +ᵥ y` where `x ∈ s` and `y ∈ t`.\n* `s -ᵥ t`: Scalar subtraction, set of all `x -ᵥ y` where `x ∈ s` and `y ∈ t`.\n* `a • s`: Scaling, set of all `a • x` where `x ∈ s`.\n* `a +ᵥ s`: Translation, set of all `a +ᵥ x` where `x ∈ s`.\n\nFor `α` a semigroup/monoid, `set α` is a semigroup/monoid.\n\nAppropriate definitions and results are also transported to the additive theory via `to_additive`.\n\n## Implementation notes\n\n* We put all instances in the locale `pointwise`, so that these instances are not available by\n  default. Note that we do not mark them as reducible (as argued by note [reducible non-instances])\n  since we expect the locale to be open whenever the instances are actually used (and making the\n  instances reducible changes the behavior of `simp`.\n\n-/\n\nopen function mul_opposite\n\nvariables {F α β γ : Type*}\n\nnamespace set\n\nopen_locale pointwise\n\n/-! ### Translation/scaling of sets -/\n\nsection smul\n\n/-- The dilation of set `x • s` is defined as `{x • y | y ∈ s}` in locale `pointwise`. -/\n@[to_additive \"The translation of set `x +ᵥ s` is defined as `{x +ᵥ y | y ∈ s}` in\nlocale `pointwise`.\"]\nprotected def has_smul_set [has_smul α β] : has_smul α (set β) :=\n⟨λ a, image (has_smul.smul a)⟩\n\n/-- The pointwise scalar multiplication of sets `s • t` is defined as `{x • y | x ∈ s, y ∈ t}` in\nlocale `pointwise`. -/\n@[to_additive \"The pointwise scalar addition of sets `s +ᵥ t` is defined as\n`{x +ᵥ y | x ∈ s, y ∈ t}` in locale `pointwise`.\"]\nprotected def has_smul [has_smul α β] : has_smul (set α) (set β) :=\n⟨image2 has_smul.smul⟩\n\nlocalized \"attribute [instance] set.has_smul_set set.has_smul\" in pointwise\nlocalized \"attribute [instance] set.has_vadd_set set.has_vadd\" in pointwise\n\nsection has_smul\nvariables {ι : Sort*} {κ : ι → Sort*} [has_smul α β] {s s₁ s₂ : set α} {t t₁ t₂ u : set β} {a : α}\n  {b : β}\n\n@[simp, to_additive]\nlemma image2_smul : image2 has_smul.smul s t = s • t := rfl\n\n@[to_additive add_image_prod]\nlemma image_smul_prod : (λ x : α × β, x.fst • x.snd) '' s ×ˢ t = s • t := image_prod _\n\n@[to_additive]\nlemma mem_smul : b ∈ s • t ↔ ∃ x y, x ∈ s ∧ y ∈ t ∧ x • y = b := iff.rfl\n\n@[to_additive] lemma smul_mem_smul : a ∈ s → b ∈ t → a • b ∈ s • t := mem_image2_of_mem\n\n@[simp, to_additive] lemma empty_smul : (∅ : set α) • t = ∅ := image2_empty_left\n@[simp, to_additive] lemma smul_empty : s • (∅ : set β) = ∅ := image2_empty_right\n@[simp, to_additive] lemma smul_eq_empty : s • t = ∅ ↔ s = ∅ ∨ t = ∅ := image2_eq_empty_iff\n@[simp, to_additive] lemma smul_nonempty : (s • t).nonempty ↔ s.nonempty ∧ t.nonempty :=\nimage2_nonempty_iff\n@[to_additive] lemma nonempty.smul : s.nonempty → t.nonempty → (s • t).nonempty := nonempty.image2\n@[to_additive] lemma nonempty.of_smul_left : (s • t).nonempty → s.nonempty :=\nnonempty.of_image2_left\n@[to_additive] lemma nonempty.of_smul_right : (s • t).nonempty → t.nonempty :=\nnonempty.of_image2_right\n@[simp, to_additive] lemma smul_singleton : s • {b} = (• b) '' s := image2_singleton_right\n@[simp, to_additive] lemma singleton_smul : ({a} : set α) • t = a • t := image2_singleton_left\n@[simp, to_additive] lemma singleton_smul_singleton : ({a} : set α) • ({b} : set β) = {a • b} :=\nimage2_singleton\n\n@[to_additive, mono] lemma smul_subset_smul : s₁ ⊆ s₂ → t₁ ⊆ t₂ → s₁ • t₁ ⊆ s₂ • t₂ := image2_subset\n@[to_additive] lemma smul_subset_smul_left : t₁ ⊆ t₂ → s • t₁ ⊆ s • t₂ := image2_subset_left\n@[to_additive] lemma smul_subset_smul_right : s₁ ⊆ s₂ → s₁ • t ⊆ s₂ • t := image2_subset_right\n@[to_additive] lemma smul_subset_iff : s • t ⊆ u ↔ ∀ (a ∈ s) (b ∈ t), a • b ∈ u := image2_subset_iff\n\nattribute [mono] vadd_subset_vadd\n\n@[to_additive] lemma union_smul : (s₁ ∪ s₂) • t = s₁ • t ∪ s₂ • t := image2_union_left\n@[to_additive] lemma smul_union : s • (t₁ ∪ t₂) = s • t₁ ∪ s • t₂ := image2_union_right\n@[to_additive] lemma inter_smul_subset : (s₁ ∩ s₂) • t ⊆ s₁ • t ∩ s₂ • t := image2_inter_subset_left\n@[to_additive] lemma smul_inter_subset : s • (t₁ ∩ t₂) ⊆ s • t₁ ∩ s • t₂ :=\nimage2_inter_subset_right\n@[to_additive] lemma inter_smul_union_subset_union :\n  (s₁ ∩ s₂) • (t₁ ∪ t₂) ⊆ (s₁ • t₁) ∪ (s₂ • t₂) :=\nimage2_inter_union_subset_union\n@[to_additive] lemma union_smul_inter_subset_union :\n  (s₁ ∪ s₂) • (t₁ ∩ t₂) ⊆ (s₁ • t₁) ∪ (s₂ • t₂) :=\nimage2_union_inter_subset_union\n\n@[to_additive] lemma Union_smul_left_image : (⋃ a ∈ s, a • t) = s • t := Union_image_left _\n@[to_additive] lemma Union_smul_right_image : (⋃ a ∈ t, (• a) '' s) = s • t := Union_image_right _\n\n@[to_additive] lemma Union_smul (s : ι → set α) (t : set β) : (⋃ i, s i) • t = ⋃ i, s i • t :=\nimage2_Union_left _ _ _\n@[to_additive] lemma smul_Union (s : set α) (t : ι → set β) : s • (⋃ i, t i) = ⋃ i, s • t i :=\nimage2_Union_right _ _ _\n\n@[to_additive]\nlemma Union₂_smul (s : Π i, κ i → set α) (t : set β) : (⋃ i j, s i j) • t = ⋃ i j, s i j • t :=\nimage2_Union₂_left _ _ _\n\n@[to_additive]\n\n\n@[to_additive]\nlemma Inter_smul_subset (s : ι → set α) (t : set β) : (⋂ i, s i) • t ⊆ ⋂ i, s i • t :=\nimage2_Inter_subset_left _ _ _\n\n@[to_additive]\nlemma smul_Inter_subset (s : set α) (t : ι → set β) : s • (⋂ i, t i) ⊆ ⋂ i, s • t i :=\nimage2_Inter_subset_right _ _ _\n\n@[to_additive]\nlemma Inter₂_smul_subset (s : Π i, κ i → set α) (t : set β) :\n  (⋂ i j, s i j) • t ⊆ ⋂ i j, s i j • t :=\nimage2_Inter₂_subset_left _ _ _\n\n@[to_additive]\nlemma smul_Inter₂_subset (s : set α) (t : Π i, κ i → set β) :\n  s • (⋂ i j, t i j) ⊆ ⋂ i j, s • t i j :=\nimage2_Inter₂_subset_right _ _ _\n\n@[to_additive] lemma smul_set_subset_smul {s : set α} : a ∈ s → a • t ⊆ s • t :=\nimage_subset_image2_right\n\n@[simp, to_additive] lemma bUnion_smul_set (s : set α) (t : set β) :\n  (⋃ a ∈ s, a • t) = s • t :=\nUnion_image_left _\n\nend has_smul\n\nsection has_smul_set\nvariables {ι : Sort*} {κ : ι → Sort*} [has_smul α β] {s t t₁ t₂ : set β} {a : α} {b : β} {x y : β}\n\n@[simp, to_additive] lemma image_smul : (λ x, a • x) '' t = a • t := rfl\n\n@[to_additive] lemma mem_smul_set : x ∈ a • t ↔ ∃ y, y ∈ t ∧ a • y = x := iff.rfl\n\n@[to_additive] lemma smul_mem_smul_set : b ∈ s → a • b ∈ a • s := mem_image_of_mem _\n\n@[simp, to_additive] lemma smul_set_empty : a • (∅ : set β) = ∅ := image_empty _\n@[simp, to_additive] lemma smul_set_eq_empty : a • s = ∅ ↔ s = ∅ := image_eq_empty\n@[simp, to_additive] lemma smul_set_nonempty : (a • s).nonempty ↔ s.nonempty := nonempty_image_iff\n\n@[simp, to_additive] lemma smul_set_singleton : a • ({b} : set β) = {a • b} := image_singleton\n\n@[to_additive] lemma smul_set_mono : s ⊆ t → a • s ⊆ a • t := image_subset _\n@[to_additive] lemma smul_set_subset_iff : a • s ⊆ t ↔ ∀ ⦃b⦄, b ∈ s → a • b ∈ t := image_subset_iff\n\n@[to_additive] lemma smul_set_union : a • (t₁ ∪ t₂) = a • t₁ ∪ a • t₂ := image_union _ _ _\n\n@[to_additive]\nlemma smul_set_inter_subset : a • (t₁ ∩ t₂) ⊆ a • t₁ ∩ (a • t₂) := image_inter_subset _ _ _\n\n@[to_additive]\nlemma smul_set_Union (a : α) (s : ι → set β) : a • (⋃ i, s i) = ⋃ i, a • s i := image_Union\n\n@[to_additive]\nlemma smul_set_Union₂ (a : α) (s : Π i, κ i → set β) : a • (⋃ i j, s i j) = ⋃ i j, a • s i j :=\nimage_Union₂ _ _\n\n@[to_additive]\nlemma smul_set_Inter_subset (a : α) (t : ι → set β) : a • (⋂ i, t i) ⊆ ⋂ i, a • t i :=\nimage_Inter_subset _ _\n\n@[to_additive]\nlemma smul_set_Inter₂_subset (a : α) (t : Π i, κ i → set β) :\n  a • (⋂ i j, t i j) ⊆ ⋂ i j, a • t i j :=\nimage_Inter₂_subset _ _\n\n@[to_additive] lemma nonempty.smul_set : s.nonempty → (a • s).nonempty := nonempty.image _\n\nend has_smul_set\n\nsection has_mul\nvariables [has_mul α] {s t u : set α} {a : α}\n\n@[to_additive] lemma op_smul_set_subset_mul : a ∈ t → op a • s ⊆ s * t := image_subset_image2_left\n\n@[simp, to_additive] lemma bUnion_op_smul_set (s t : set α) : (⋃ a ∈ t, op a • s) = s * t :=\nUnion_image_right _\n\n@[to_additive] lemma mul_subset_iff_left : s * t ⊆ u ↔ ∀ a ∈ s, a • t ⊆ u := image2_subset_iff_left\n@[to_additive] lemma mul_subset_iff_right : s * t ⊆ u ↔ ∀ b ∈ t, op b • s ⊆ u :=\nimage2_subset_iff_right\n\nend has_mul\n\nvariables {s s₁ s₂ : set α} {t t₁ t₂ : set β} {a : α} {b : β}\n\n@[to_additive]\ntheorem range_smul_range {ι κ : Type*} [has_smul α β] (b : ι → α) (c : κ → β) :\n  range b • range c = range (λ p : ι × κ, b p.1 • c p.2) :=\next $ λ x, ⟨λ hx, let ⟨p, q, ⟨i, hi⟩, ⟨j, hj⟩, hpq⟩ := set.mem_smul.1 hx in\n  ⟨(i, j), hpq ▸ hi ▸ hj ▸ rfl⟩,\nλ ⟨⟨i, j⟩, h⟩, set.mem_smul.2 ⟨b i, c j, ⟨i, rfl⟩, ⟨j, rfl⟩, h⟩⟩\n\n@[to_additive] lemma smul_set_range [has_smul α β] {ι : Sort*} {f : ι → β} :\n  a • range f = range (λ i, a • f i) := (range_comp _ _).symm\n\n@[to_additive]\ninstance smul_comm_class_set [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :\n  smul_comm_class α β (set γ) :=\n⟨λ _ _, commute.set_image $ smul_comm _ _⟩\n\n@[to_additive]\ninstance smul_comm_class_set' [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :\n  smul_comm_class α (set β) (set γ) :=\n⟨λ _ _ _, image_image2_distrib_right $ smul_comm _⟩\n\n@[to_additive]\ninstance smul_comm_class_set'' [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :\n  smul_comm_class (set α) β (set γ) :=\nby haveI := smul_comm_class.symm α β γ; exact smul_comm_class.symm _ _ _\n\n@[to_additive]\ninstance smul_comm_class [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :\n  smul_comm_class (set α) (set β) (set γ) :=\n⟨λ _ _ _, image2_left_comm smul_comm⟩\n\n@[to_additive]\ninstance is_scalar_tower [has_smul α β] [has_smul α γ] [has_smul β γ] [is_scalar_tower α β γ] :\n  is_scalar_tower α β (set γ) :=\n{ smul_assoc := λ a b T, by simp only [←image_smul, image_image, smul_assoc] }\n\n@[to_additive]\ninstance is_scalar_tower' [has_smul α β] [has_smul α γ] [has_smul β γ] [is_scalar_tower α β γ] :\n  is_scalar_tower α (set β) (set γ) :=\n⟨λ _ _ _, image2_image_left_comm $ smul_assoc _⟩\n\n@[to_additive]\ninstance is_scalar_tower'' [has_smul α β] [has_smul α γ] [has_smul β γ] [is_scalar_tower α β γ] :\n  is_scalar_tower (set α) (set β) (set γ) :=\n{ smul_assoc := λ T T' T'', image2_assoc smul_assoc }\n\n@[to_additive]\ninstance is_central_scalar [has_smul α β] [has_smul αᵐᵒᵖ β] [is_central_scalar α β] :\n  is_central_scalar α (set β) :=\n⟨λ a S, congr_arg (λ f, f '' S) $ by exact funext (λ _, op_smul_eq_smul _ _)⟩\n\n/-- A multiplicative action of a monoid `α` on a type `β` gives a multiplicative action of `set α`\non `set β`. -/\n@[to_additive \"An additive action of an additive monoid `α` on a type `β` gives an additive action\nof `set α` on `set β`\"]\nprotected def mul_action [monoid α] [mul_action α β] : mul_action (set α) (set β) :=\n{ mul_smul := λ _ _ _, image2_assoc mul_smul,\n  one_smul := λ s, image2_singleton_left.trans $ by simp_rw [one_smul, image_id'] }\n\n/-- A multiplicative action of a monoid on a type `β` gives a multiplicative action on `set β`. -/\n@[to_additive \"An additive action of an additive monoid on a type `β` gives an additive action\non `set β`.\"]\nprotected def mul_action_set [monoid α] [mul_action α β] : mul_action α (set β) :=\n{ mul_smul := by { intros, simp only [← image_smul, image_image, ← mul_smul] },\n  one_smul := by { intros, simp only [← image_smul, one_smul, image_id'] } }\n\nlocalized \"attribute [instance] set.mul_action_set set.add_action_set\n  set.mul_action set.add_action\" in pointwise\n\n/-- A distributive multiplicative action of a monoid on an additive monoid `β` gives a distributive\nmultiplicative action on `set β`. -/\nprotected def distrib_mul_action_set [monoid α] [add_monoid β] [distrib_mul_action α β] :\n  distrib_mul_action α (set β) :=\n{ smul_add := λ _ _ _, image_image2_distrib $ smul_add _,\n  smul_zero := λ _, image_singleton.trans $ by rw [smul_zero, singleton_zero] }\n\n/-- A multiplicative action of a monoid on a monoid `β` gives a multiplicative action on `set β`. -/\nprotected def mul_distrib_mul_action_set [monoid α] [monoid β] [mul_distrib_mul_action α β] :\n  mul_distrib_mul_action α (set β) :=\n{ smul_mul := λ _ _ _, image_image2_distrib $ smul_mul' _,\n  smul_one := λ _, image_singleton.trans $ by rw [smul_one, singleton_one] }\n\nlocalized \"attribute [instance] set.distrib_mul_action_set set.mul_distrib_mul_action_set\"\n  in pointwise\n\ninstance [has_zero α] [has_zero β] [has_smul α β] [no_zero_smul_divisors α β] :\n  no_zero_smul_divisors (set α) (set β) :=\n⟨λ s t h, begin\n  by_contra' H,\n  have hst : (s • t).nonempty := h.symm.subst zero_nonempty,\n  simp_rw [←hst.of_smul_left.subset_zero_iff, ←hst.of_smul_right.subset_zero_iff, not_subset,\n    mem_zero] at H,\n  obtain ⟨⟨a, hs, ha⟩, b, ht, hb⟩ := H,\n  exact (eq_zero_or_eq_zero_of_smul_eq_zero $ h.subset $ smul_mem_smul hs ht).elim ha hb,\nend⟩\n\ninstance no_zero_smul_divisors_set [has_zero α] [has_zero β] [has_smul α β]\n  [no_zero_smul_divisors α β] : no_zero_smul_divisors α (set β) :=\n⟨λ a s h, begin\n  by_contra' H,\n  have hst : (a • s).nonempty := h.symm.subst zero_nonempty,\n  simp_rw [←hst.of_image.subset_zero_iff, not_subset, mem_zero] at H,\n  obtain ⟨ha, b, ht, hb⟩ := H,\n  exact (eq_zero_or_eq_zero_of_smul_eq_zero $ h.subset $ smul_mem_smul_set ht).elim ha hb,\nend⟩\n\ninstance [has_zero α] [has_mul α] [no_zero_divisors α] : no_zero_divisors (set α) :=\n⟨λ s t h, eq_zero_or_eq_zero_of_smul_eq_zero h⟩\n\nend smul\n\nsection vsub\nvariables {ι : Sort*} {κ : ι → Sort*} [has_vsub α β] {s s₁ s₂ t t₁ t₂ : set β} {u : set α} {a : α}\n  {b c : β}\ninclude α\n\ninstance has_vsub : has_vsub (set α) (set β) := ⟨image2 (-ᵥ)⟩\n\n@[simp] lemma image2_vsub : (image2 has_vsub.vsub s t : set α) = s -ᵥ t := rfl\n\nlemma image_vsub_prod : (λ x : β × β, x.fst -ᵥ x.snd) '' s ×ˢ t = s -ᵥ t := image_prod _\n\nlemma mem_vsub : a ∈ s -ᵥ t ↔ ∃ x y, x ∈ s ∧ y ∈ t ∧ x -ᵥ y = a := iff.rfl\n\nlemma vsub_mem_vsub (hb : b ∈ s) (hc : c ∈ t) : b -ᵥ c ∈ s -ᵥ t := mem_image2_of_mem hb hc\n\n@[simp] lemma empty_vsub (t : set β) : ∅ -ᵥ t = ∅ := image2_empty_left\n@[simp] lemma vsub_empty (s : set β) : s -ᵥ ∅ = ∅ := image2_empty_right\n@[simp] lemma vsub_eq_empty : s -ᵥ t = ∅ ↔ s = ∅ ∨ t = ∅ := image2_eq_empty_iff\n@[simp] lemma vsub_nonempty : (s -ᵥ t : set α).nonempty ↔ s.nonempty ∧ t.nonempty :=\nimage2_nonempty_iff\nlemma nonempty.vsub : s.nonempty → t.nonempty → (s -ᵥ t : set α).nonempty := nonempty.image2\nlemma nonempty.of_vsub_left : (s -ᵥ t :set α).nonempty → s.nonempty := nonempty.of_image2_left\nlemma nonempty.of_vsub_right : (s -ᵥ t : set α).nonempty → t.nonempty := nonempty.of_image2_right\n@[simp] lemma vsub_singleton (s : set β) (b : β) : s -ᵥ {b} = (-ᵥ b) '' s := image2_singleton_right\n@[simp] lemma singleton_vsub (t : set β) (b : β) : {b} -ᵥ t = ((-ᵥ) b) '' t := image2_singleton_left\n@[simp] lemma singleton_vsub_singleton : ({b} : set β) -ᵥ {c} = {b -ᵥ c} := image2_singleton\n\n@[mono] lemma vsub_subset_vsub : s₁ ⊆ s₂ → t₁ ⊆ t₂ → s₁ -ᵥ t₁ ⊆ s₂ -ᵥ t₂ := image2_subset\nlemma vsub_subset_vsub_left : t₁ ⊆ t₂ → s -ᵥ t₁ ⊆ s -ᵥ t₂ := image2_subset_left\nlemma vsub_subset_vsub_right : s₁ ⊆ s₂ → s₁ -ᵥ t ⊆ s₂ -ᵥ t := image2_subset_right\nlemma vsub_subset_iff : s -ᵥ t ⊆ u ↔ ∀ (x ∈ s) (y ∈ t), x -ᵥ y ∈ u := image2_subset_iff\nlemma vsub_self_mono (h : s ⊆ t) : s -ᵥ s ⊆ t -ᵥ t := vsub_subset_vsub h h\n\nlemma union_vsub : (s₁ ∪ s₂) -ᵥ t = s₁ -ᵥ t ∪ (s₂ -ᵥ t) := image2_union_left\nlemma vsub_union : s -ᵥ (t₁ ∪ t₂) = s -ᵥ t₁ ∪ (s -ᵥ t₂) := image2_union_right\nlemma inter_vsub_subset : s₁ ∩ s₂ -ᵥ t ⊆ (s₁ -ᵥ t) ∩ (s₂ -ᵥ t) := image2_inter_subset_left\nlemma vsub_inter_subset : s -ᵥ t₁ ∩ t₂ ⊆ (s -ᵥ t₁) ∩ (s -ᵥ t₂) := image2_inter_subset_right\nlemma inter_vsub_union_subset_union : (s₁ ∩ s₂) -ᵥ (t₁ ∪ t₂) ⊆ (s₁ -ᵥ t₁) ∪ (s₂ -ᵥ t₂) :=\nimage2_inter_union_subset_union\nlemma union_vsub_inter_subset_union : (s₁ ∪ s₂) -ᵥ (t₁ ∩ t₂) ⊆ (s₁ -ᵥ t₁) ∪ (s₂ -ᵥ t₂) :=\nimage2_union_inter_subset_union\n\nlemma Union_vsub_left_image : (⋃ a ∈ s, ((-ᵥ) a) '' t) = s -ᵥ t := Union_image_left _\nlemma Union_vsub_right_image : (⋃ a ∈ t, (-ᵥ a) '' s) = s -ᵥ t := Union_image_right _\n\nlemma Union_vsub (s : ι → set β) (t : set β) : (⋃ i, s i) -ᵥ t = ⋃ i, s i -ᵥ t :=\nimage2_Union_left _ _ _\nlemma vsub_Union (s : set β) (t : ι → set β) : s -ᵥ (⋃ i, t i) = ⋃ i, s -ᵥ t i :=\nimage2_Union_right _ _ _\n\nlemma Union₂_vsub (s : Π i, κ i → set β) (t : set β) : (⋃ i j, s i j) -ᵥ t = ⋃ i j, s i j -ᵥ t :=\nimage2_Union₂_left _ _ _\n\nlemma vsub_Union₂ (s : set β) (t : Π i, κ i → set β) : s -ᵥ (⋃ i j, t i j) = ⋃ i j, s -ᵥ t i j :=\nimage2_Union₂_right _ _ _\n\nlemma Inter_vsub_subset (s : ι → set β) (t : set β) : (⋂ i, s i) -ᵥ t ⊆ ⋂ i, s i -ᵥ t :=\nimage2_Inter_subset_left _ _ _\n\nlemma vsub_Inter_subset (s : set β) (t : ι → set β) : s -ᵥ (⋂ i, t i) ⊆ ⋂ i, s -ᵥ t i :=\nimage2_Inter_subset_right _ _ _\n\nlemma Inter₂_vsub_subset (s : Π i, κ i → set β) (t : set β) :\n  (⋂ i j, s i j) -ᵥ t ⊆ ⋂ i j, s i j -ᵥ t :=\nimage2_Inter₂_subset_left _ _ _\n\nlemma vsub_Inter₂_subset (s : set β) (t : Π i, κ i → set β) :\n  s -ᵥ (⋂ i j, t i j) ⊆ ⋂ i j, s -ᵥ t i j :=\nimage2_Inter₂_subset_right _ _ _\n\n\nend vsub\n\nopen_locale pointwise\n\n@[to_additive] lemma image_smul_comm [has_smul α β] [has_smul α γ] (f : β → γ) (a : α) (s : set β) :\n  (∀ b, f (a • b) = a • f b) → f '' (a • s) = a • f '' s :=\nimage_comm\n\n@[to_additive] lemma image_smul_distrib [mul_one_class α] [mul_one_class β] [monoid_hom_class F α β]\n  (f : F) (a : α) (s : set α) :\n  f '' (a • s) = f a • f '' s :=\nimage_comm $ map_mul _ _\n\nsection has_smul\nvariables[has_smul αᵐᵒᵖ β] [has_smul β γ] [has_smul α γ]\n\n-- TODO: replace hypothesis and conclusion with a typeclass\n@[to_additive] lemma op_smul_set_smul_eq_smul_smul_set (a : α) (s : set β) (t : set γ)\n  (h : ∀ (a : α) (b : β) (c : γ), (op a • b) • c = b • a • c) :\n  (op a • s) • t = s • a • t :=\nby { ext, simp [mem_smul, mem_smul_set, h] }\n\nend has_smul\n\nsection smul_with_zero\nvariables [has_zero α] [has_zero β] [smul_with_zero α β] {s : set α} {t : set β}\n\n/-!\nNote that we have neither `smul_with_zero α (set β)` nor `smul_with_zero (set α) (set β)`\nbecause `0 * ∅ ≠ 0`.\n-/\n\nlemma smul_zero_subset (s : set α) : s • (0 : set β) ⊆ 0 := by simp [subset_def, mem_smul]\nlemma zero_smul_subset (t : set β) : (0 : set α) • t ⊆ 0 := by simp [subset_def, mem_smul]\n\nlemma nonempty.smul_zero (hs : s.nonempty) : s • (0 : set β) = 0 :=\ns.smul_zero_subset.antisymm $ by simpa [mem_smul] using hs\n\nlemma nonempty.zero_smul (ht : t.nonempty) : (0 : set α) • t = 0 :=\nt.zero_smul_subset.antisymm $ by simpa [mem_smul] using ht\n\n/-- A nonempty set is scaled by zero to the singleton set containing 0. -/\nlemma zero_smul_set {s : set β} (h : s.nonempty) : (0 : α) • s = (0 : set β) :=\nby simp only [← image_smul, image_eta, zero_smul, h.image_const, singleton_zero]\n\nlemma zero_smul_set_subset (s : set β) : (0 : α) • s ⊆ 0 :=\nimage_subset_iff.2 $ λ x _, zero_smul α x\n\nlemma subsingleton_zero_smul_set (s : set β) : ((0 : α) • s).subsingleton :=\nsubsingleton_singleton.anti $ zero_smul_set_subset s\n\nlemma zero_mem_smul_set {t : set β} {a : α} (h : (0 : β) ∈ t) : (0 : β) ∈ a • t :=\n⟨0, h, smul_zero _⟩\n\nvariables [no_zero_smul_divisors α β] {a : α}\n\nlemma zero_mem_smul_iff : (0 : β) ∈ s • t ↔ (0 : α) ∈ s ∧ t.nonempty ∨ (0 : β) ∈ t ∧ s.nonempty :=\nbegin\n  split,\n  { rintro ⟨a, b, ha, hb, h⟩,\n    obtain rfl | rfl := eq_zero_or_eq_zero_of_smul_eq_zero h,\n    { exact or.inl ⟨ha, b, hb⟩ },\n    { exact or.inr ⟨hb, a, ha⟩ } },\n  { rintro (⟨hs, b, hb⟩ | ⟨ht, a, ha⟩),\n    { exact ⟨0, b, hs, hb, zero_smul _ _⟩ },\n    { exact ⟨a, 0, ha, ht, smul_zero _⟩ } }\nend\n\nlemma zero_mem_smul_set_iff (ha : a ≠ 0) : (0 : β) ∈ a • t ↔ (0 : β) ∈ t :=\nbegin\n  refine ⟨_, zero_mem_smul_set⟩,\n  rintro ⟨b, hb, h⟩,\n  rwa (eq_zero_or_eq_zero_of_smul_eq_zero h).resolve_left ha at hb,\nend\n\nend smul_with_zero\n\nsection semigroup\nvariables [semigroup α]\n\n@[to_additive] lemma op_smul_set_mul_eq_mul_smul_set (a : α) (s : set α) (t : set α) :\n  (op a • s) * t = s * a • t :=\nop_smul_set_smul_eq_smul_smul_set _ _ _ $ λ _ _ _, mul_assoc _ _ _\n\nend semigroup\n\nsection left_cancel_semigroup\nvariables [left_cancel_semigroup α] {s t : set α}\n\n@[to_additive] lemma pairwise_disjoint_smul_iff :\n  s.pairwise_disjoint (• t) ↔ (s ×ˢ t).inj_on (λ p, p.1 * p.2) :=\npairwise_disjoint_image_right_iff $ λ _ _, mul_right_injective _\n\nend left_cancel_semigroup\n\nsection group\nvariables [group α] [mul_action α β] {s t A B : set β} {a : α} {x : β}\n\n@[simp, to_additive]\nlemma smul_mem_smul_set_iff : a • x ∈ a • s ↔ x ∈ s := (mul_action.injective _).mem_set_image\n\n@[to_additive]\nlemma mem_smul_set_iff_inv_smul_mem : x ∈ a • A ↔ a⁻¹ • x ∈ A :=\nshow x ∈ mul_action.to_perm a '' A ↔ _, from mem_image_equiv\n\n@[to_additive]\nlemma mem_inv_smul_set_iff : x ∈ a⁻¹ • A ↔ a • x ∈ A :=\nby simp only [← image_smul, mem_image, inv_smul_eq_iff, exists_eq_right]\n\n@[to_additive]\nlemma preimage_smul (a : α) (t : set β) : (λ x, a • x) ⁻¹' t = a⁻¹ • t :=\n((mul_action.to_perm a).symm.image_eq_preimage _).symm\n\n@[to_additive]\nlemma preimage_smul_inv (a : α) (t : set β) : (λ x, a⁻¹ • x) ⁻¹' t = a • t :=\npreimage_smul (to_units a)⁻¹ t\n\n@[simp, to_additive]\nlemma set_smul_subset_set_smul_iff : a • A ⊆ a • B ↔ A ⊆ B :=\nimage_subset_image_iff $ mul_action.injective _\n\n@[to_additive]\nlemma set_smul_subset_iff : a • A ⊆ B ↔ A ⊆ a⁻¹ • B :=\n(image_subset_iff).trans $ iff_of_eq $ congr_arg _ $\n  preimage_equiv_eq_image_symm _ $ mul_action.to_perm _\n\n@[to_additive]\nlemma subset_set_smul_iff : A ⊆ a • B ↔ a⁻¹ • A ⊆ B :=\niff.symm $ (image_subset_iff).trans $ iff.symm $ iff_of_eq $ congr_arg _ $\n  image_equiv_eq_preimage_symm _ $ mul_action.to_perm _\n\n@[to_additive] lemma smul_set_inter : a • (s ∩ t) = a • s ∩ a • t :=\nimage_inter $ mul_action.injective a\n\n@[to_additive] lemma smul_set_sdiff : a • (s \\ t) = a • s \\ a • t :=\nimage_diff (mul_action.injective a) _ _\n\n@[to_additive] lemma smul_set_symm_diff : a • (s ∆ t) = (a • s) ∆ (a • t) :=\nimage_symm_diff (mul_action.injective a) _ _\n\n@[simp, to_additive] lemma smul_set_univ : a • (univ : set β) = univ :=\nimage_univ_of_surjective $ mul_action.surjective a\n\n@[simp, to_additive] lemma smul_univ {s : set α} (hs : s.nonempty) : s • (univ : set β) = univ :=\nlet ⟨a, ha⟩ := hs in eq_univ_of_forall $ λ b, ⟨a, a⁻¹ • b, ha, trivial, smul_inv_smul _ _⟩\n\n@[to_additive]\nlemma smul_inter_ne_empty_iff {s t : set α} {x : α} :\n  x • s ∩ t ≠ ∅ ↔ ∃ a b, (a ∈ t ∧ b ∈ s) ∧ a * b⁻¹ = x :=\nbegin\n  rw ←nonempty_iff_ne_empty,\n  split,\n  { rintros ⟨a, h, ha⟩,\n    obtain ⟨b, hb, rfl⟩ := mem_smul_set.mp h,\n    exact ⟨x • b, b, ⟨ha, hb⟩, by simp⟩, },\n  { rintros ⟨a, b, ⟨ha, hb⟩, rfl⟩,\n    exact ⟨a, mem_inter (mem_smul_set.mpr ⟨b, hb, by simp⟩) ha⟩, },\nend\n\n@[to_additive]\nlemma smul_inter_ne_empty_iff' {s t : set α} {x : α} :\n  x • s ∩ t ≠ ∅ ↔ ∃ a b, (a ∈ t ∧ b ∈ s) ∧ a / b = x :=\nby simp_rw [smul_inter_ne_empty_iff, div_eq_mul_inv]\n\n@[to_additive]\nlemma op_smul_inter_ne_empty_iff {s t : set α} {x : αᵐᵒᵖ} :\n  x • s ∩ t ≠ ∅ ↔ ∃ a b, (a ∈ s ∧ b ∈ t) ∧ a⁻¹ * b = mul_opposite.unop x :=\nbegin\n  rw ←nonempty_iff_ne_empty,\n  split,\n  { rintros ⟨a, h, ha⟩,\n    obtain ⟨b, hb, rfl⟩ := mem_smul_set.mp h,\n    exact ⟨b, x • b, ⟨hb, ha⟩, by simp⟩, },\n  { rintros ⟨a, b, ⟨ha, hb⟩, H⟩,\n    have : mul_opposite.op (a⁻¹ * b) = x := congr_arg mul_opposite.op H,\n    exact ⟨b, mem_inter (mem_smul_set.mpr ⟨a, ha, by simp [← this]⟩) hb⟩, },\nend\n\n@[simp, to_additive] lemma Union_inv_smul :\n  (⋃ (g : α), g⁻¹ • s) = (⋃ (g : α), g • s) :=\nfunction.surjective.supr_congr _ inv_surjective $ λ g, rfl\n\n@[to_additive]\nlemma Union_smul_eq_set_of_exists {s : set β} :\n  (⋃ (g : α), g • s) = {a | ∃ (g : α), g • a ∈ s} :=\nby simp_rw [← Union_set_of, ← Union_inv_smul, ← preimage_smul, preimage]\n\nend group\n\nsection group_with_zero\nvariables [group_with_zero α] [mul_action α β] {s t : set β} {a : α}\n\n@[simp] lemma smul_mem_smul_set_iff₀ (ha : a ≠ 0) (A : set β)\n  (x : β) : a • x ∈ a • A ↔ x ∈ A :=\nshow units.mk0 a ha • _ ∈ _ ↔ _, from smul_mem_smul_set_iff\n\nlemma mem_smul_set_iff_inv_smul_mem₀ (ha : a ≠ 0) (A : set β) (x : β) :\n  x ∈ a • A ↔ a⁻¹ • x ∈ A :=\nshow _ ∈ units.mk0 a ha • _ ↔ _, from mem_smul_set_iff_inv_smul_mem\n\nlemma mem_inv_smul_set_iff₀ (ha : a ≠ 0) (A : set β) (x : β) : x ∈ a⁻¹ • A ↔ a • x ∈ A :=\nshow _ ∈ (units.mk0 a ha)⁻¹ • _ ↔ _, from mem_inv_smul_set_iff\n\nlemma preimage_smul₀ (ha : a ≠ 0) (t : set β) : (λ x, a • x) ⁻¹' t = a⁻¹ • t :=\npreimage_smul (units.mk0 a ha) t\n\nlemma preimage_smul_inv₀ (ha : a ≠ 0) (t : set β) :\n  (λ x, a⁻¹ • x) ⁻¹' t = a • t :=\npreimage_smul ((units.mk0 a ha)⁻¹) t\n\n@[simp] lemma set_smul_subset_set_smul_iff₀ (ha : a ≠ 0) {A B : set β} :\n  a • A ⊆ a • B ↔ A ⊆ B :=\nshow units.mk0 a ha • _ ⊆ _ ↔ _, from set_smul_subset_set_smul_iff\n\nlemma set_smul_subset_iff₀ (ha : a ≠ 0) {A B : set β} : a • A ⊆ B ↔ A ⊆ a⁻¹ • B :=\nshow units.mk0 a ha • _ ⊆ _ ↔ _, from set_smul_subset_iff\n\nlemma subset_set_smul_iff₀ (ha : a ≠ 0) {A B : set β} : A ⊆ a • B ↔ a⁻¹ • A ⊆ B :=\nshow _ ⊆ units.mk0 a ha • _ ↔ _, from subset_set_smul_iff\n\nlemma smul_set_inter₀ (ha : a ≠ 0) : a • (s ∩ t) = a • s ∩ a • t :=\nshow units.mk0 a ha • _ = _, from smul_set_inter\n\nlemma smul_set_sdiff₀ (ha : a ≠ 0) : a • (s \\ t) = a • s \\ a • t :=\nimage_diff (mul_action.injective₀ ha) _ _\n\nlemma smul_set_symm_diff₀ (ha : a ≠ 0) : a • (s ∆ t) = (a • s) ∆ (a • t) :=\nimage_symm_diff (mul_action.injective₀ ha) _ _\n\nlemma smul_set_univ₀ (ha : a ≠ 0) : a • (univ : set β) = univ :=\nimage_univ_of_surjective $ mul_action.surjective₀ ha\n\nlemma smul_univ₀ {s : set α} (hs : ¬ s ⊆ 0) : s • (univ : set β) = univ :=\nlet ⟨a, ha, ha₀⟩ := not_subset.1 hs in eq_univ_of_forall $ λ b,\n  ⟨a, a⁻¹ • b, ha, trivial, smul_inv_smul₀ ha₀ _⟩\n\nlemma smul_univ₀' {s : set α} (hs : s.nontrivial) : s • (univ : set β) = univ :=\nsmul_univ₀ hs.not_subset_singleton\n\nend group_with_zero\n\nsection monoid\nvariables [monoid α] [add_group β] [distrib_mul_action α β] (a : α) (s : set α) (t : set β)\n\n@[simp] lemma smul_set_neg : a • -t = -(a • t) :=\nby simp_rw [←image_smul, ←image_neg, image_image, smul_neg]\n\n@[simp] protected lemma smul_neg : s • -t = -(s • t) :=\nby { simp_rw ←image_neg, exact image_image2_right_comm smul_neg }\n\nend monoid\n\nsection ring\nvariables [ring α] [add_comm_group β] [module α β] (a : α) (s : set α) (t : set β)\n\n@[simp] lemma neg_smul_set : -a • t = -(a • t) :=\nby simp_rw [←image_smul, ←image_neg, image_image, neg_smul]\n\n@[simp] protected lemma neg_smul : -s • t = -(s • t) :=\nby { simp_rw ←image_neg, exact image2_image_left_comm neg_smul }\n\nend ring\n\nend set\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/set/pointwise/smul.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6959583250334525, "lm_q1q2_score": 0.49568391797785477}}
{"text": "import GMLInit.Logic.Basic\n\nvariable {a b : Prop}\n\ndef Implies (a b : Prop) : Prop := a → b\n\n/-- constructor for `Implies`\n\n  Note: This is a fake constructor -- `Implies` is not an inductive type. Cannot be used for pattern matching.\n-/\nprotected def Implies.intro : (a → b) → Implies a b := id\n\n/-- recursor for `Implies`\n\n  Note: This is a fake recursor -- `Implies` is not an inductive type.\n-/\nprotected def Implies.rec.{u} {motive : (a → b) → Sort u} : (a → (h : b) → motive (λ _ => h)) → (t : a → b) → a → motive t :=\n  λ h t ha => h ha (t ha)\n\nprotected def Implies.recOn.{u} {motive : (a → b) → Sort u} (t : a → b) := Implies.rec (motive:=motive) (t:=t)\n\nprotected def Implies.casesOn.{u} {motive : (a → b) → Sort u} := Implies.recOn (motive := motive)\n\n/-- eliminator for `Implies` -/\nprotected def Implies.elim.{u} {motive : Sort u} := Implies.recOn (motive := λ _ : a → b => motive)\n\n/-- modus ponens -/\nprotected abbrev Implies.mp : Implies a b → a → b := id\n\n/-- modus tollens -/\nprotected abbrev Implies.mt : Implies a b → ¬b → ¬a := mt\n\n/- constructor for `Not`\n\n  Note: This is a fake constructor -- `Not` is not an inductive type. Cannot be used for pattern matching.\n-/\n-- assert def Not.intro : (a → False) → ¬a := id\n\n/-- recursor for `Not`\n\n  Note: This is a fake recursor -- `Not` is not an inductive type.\n-/\n@[eliminator] protected def Not.rec.{u} {motive : ¬a → Sort u} (t : ¬a) : a → motive t :=\n  λ h => False.casesOn (motive := λ _ => motive t) (t h)\n\nprotected def Not.recOn.{u} {motive : ¬a → Sort u} (t : ¬a) := Not.rec (motive:=motive) t\n\nprotected def Not.casesOn.{u} {motive : ¬p → Sort u} := Not.recOn (motive:=motive)\n\n/- eliminator for `Not`\n\n  This is a fake eliminator -- `Not` is not an inductive type.\n-/\n-- assert def Not.elim.{u} {motive : Sort u} := Not.casesOn (motive := λ _ : ¬a => motive)\n\n/- eliminator for `And` -/\n-- assert def And.elim.{u} {motive : Sort u} := And.casesOn (motive := λ _ : a ∧ b => motive)\n\n/- eliminator for `Iff` -/\n-- assert def Iff.elim.{u} {motive : Sort u} := Iff.casesOn (motive := λ _ : a ↔ b => motive)\n\ntheorem Iff.eq_implies_and_implies (a b : Prop) : (a ↔ b) = ((a → b) ∧ (b → a)) :=\n  propext (iff_iff_implies_and_implies a b)\n\nprotected def Iff.mt : (a ↔ b) → (¬b ↔ ¬a)\n| Iff.intro hab hba => Iff.intro (mt hab) (mt hba)\n\n/-- large recursor for `Or`\n\n  Note: In order to eliminate into sorts other than `Prop`, we must assume that the propositions are decidable.\n-/\nprotected def Or.recLarge.{u} {motive : a ∨ b → Sort u} : [Decidable a] → [Decidable b] →\n  (inl : (h : a) → motive (Or.inl h)) → (inr : (h : b) → motive (Or.inr h)) → (t : a ∨ b) → motive t\n| Decidable.isTrue ha, _, h, _, _ => h ha\n| _, Decidable.isTrue hb, _, h, _ => h hb\n| Decidable.isFalse ha, Decidable.isFalse hb, _, _, t =>\n  absurd t λ | Or.inl h => ha h | Or.inr h => hb h\n\nprotected def Or.recLargeOn.{u} [Decidable a] [Decidable b] {motive : a ∨ b → Sort u} (t : a ∨ b) :=\n  Or.recLarge (motive:=motive) (t:=t)\n\nprotected def Or.casesLargeOn.{u} [Decidable a] [Decidable b] {motive : a ∨ b → Sort u} :=\n  Or.recLargeOn (motive:=motive)\n\n/-- large eliminator for `Or`\n\n  Note: In order to eliminate into sorts other than `Prop`, we must assume that the propositions are decidable.\n-/\nprotected def Or.elimLarge.{u} [Decidable a] [Decidable b] {motive : Sort u} := Or.recLargeOn (motive := λ _ : a ∨ b => motive)\n\n/-- modus tollendo ponens -/\ntheorem Or.mtp : a ∨ b → ¬b → a :=\n  λ t => Or.elim t (λ h _ => h) absurd\n\n/-- modus tollendo ponens (reversed) -/\ntheorem Or.mtpr : a ∨ b → ¬a → b :=\n  λ t => Or.elim t absurd (λ h _ => h)\n\n/-- `NOr` connective: `¬(a ∨ b)` -/\ndef NOr (a b : Prop) : Prop := ¬(a ∨ b)\n\nprotected def NOr.eq_def (a b : Prop) : NOr a b = ¬(a ∨ b) := rfl\n\n/-- constructor for `NOr`\n\n  Note: This is a fake constructor -- `NOr` is not an inductive type.\n-/\nprotected def NOr.intro : ¬a → ¬b → NOr a b\n| hn, _, Or.inl h => hn h\n| _, hn, Or.inr h => hn h\n\n/-- recursor for `NAnd`\n\n  Note: This is a fake recursor -- `NOr` is not an inductive type.\n-/\n@[eliminator] protected def NOr.rec.{u} {motive : NOr a b → Sort u} : (intro : (na : ¬a) → (nb : ¬b) → motive (NOr.intro na nb)) → (t : NOr a b) → motive t :=\n  λ h t => h (λ ha => t (Or.inl ha)) (λ hb => t (Or.inr hb))\n\n/-- recursor for `NAnd`\n\n  See `NAnd.rec`.\n-/\nprotected def NOr.recOn.{u} {motive : NOr a b → Sort u} (t : NOr a b) := NOr.rec (motive:=motive) (t:=t)\n\n/-- recursor for `NAnd`\n\n  Note: This is a fake recursor -- `NOr` is not an inductive type.\n-/\nprotected def NOr.casesOn.{u} {motive : NOr a b → Sort u} := NOr.recOn (motive:=motive)\n\n/-- eliminator for `NOr`\n\n  Note: This is a fake eliminator -- `NOr` is not an inductive type.\n-/\nprotected def NOr.elim.{u} {motive : Sort u} (t : NOr a b) : (intro : ¬a → ¬b → motive) → motive :=\n  NOr.recOn (motive := λ _ => motive) t\n\n/-- left projection for `NOr` -/\nprotected def NOr.left : NOr a b → ¬a :=\n  λ h => NOr.elim h (λ ha _ => ha)\n\n/-- right projection for `NOr` -/\nprotected def NOr.right : NOr a b → ¬b :=\n  λ h => NOr.elim h (λ _ hb => hb)\n\ntheorem nor_of_not_and_not : ¬a ∧ ¬b → ¬(a ∨ b)\n| And.intro ha hb => NOr.intro ha hb\n\ntheorem not_and_not_of_nor : ¬(a ∨ b) → ¬a ∧ ¬b :=\n  λ h => And.intro (λ ha => h (Or.inl ha)) (λ hb => h (Or.inr hb))\n\ntheorem nor_iff_not_and_not (a b : Prop) : ¬(a ∨ b) ↔ ¬a ∧ ¬b :=\n  Iff.intro not_and_not_of_nor nor_of_not_and_not\n\ntheorem NOr.eq_not_and_not (a b : Prop) : NOr a b = (¬a ∧ ¬b) :=\n  propext (nor_iff_not_and_not a b)\n\n/-- de Morgan's law for `Or` -/\nprotected theorem Or.deMorgan : ¬(a ∨ b) ↔ ¬a ∧ ¬b := nor_iff_not_and_not a b\n\n/-- `NAnd` connective: `¬(a ∧ b)` -/\ndef NAnd (a b : Prop) : Prop := ¬(a ∧ b)\n\nprotected def NAnd.eq_def (a b : Prop) : NAnd a b = ¬(a ∧ b) := rfl\n\n/-- left constructor for `NAnd`\n\n  Note: This is a fake constructor -- `NAnd` is not an inductive type. Cannot be used for pattern matching.\n-/\nprotected def NAnd.inl : ¬a → NAnd a b\n| hn, And.intro h _ => hn h\n\n/-- right constructor for `NAnd`\n\n  Note: This is a fake constructor -- `NAnd` is not an inductive type. Cannot be used for pattern matching.\n-/\nprotected def NAnd.inr : ¬b → NAnd a b\n| hn, And.intro _ h => hn h\n\n/-- recursor for `NAnd`\n\n  Only valid for weakly complemented propositions.\n  Can only eliminate intro `Prop`, see `NAnd.recLarge` to eliminate into other sorts.\n\n  Note: This is a fake recursor -- `NAnd` is not an inductive type.\n-/\n@[eliminator] protected def NAnd.rec {motive : NAnd a b → Prop} : [WeaklyComplemented a] → [WeaklyComplemented b] →\n  (inl : (h : ¬a) → motive (NAnd.inl h)) → (inr : (h : ¬b) → motive (NAnd.inr h)) → (t : NAnd a b) → motive t\n| WeaklyComplemented.isFalse ha, _, h, _, _ => h ha\n| _, WeaklyComplemented.isFalse hb, _, h, _ => h hb\n| WeaklyComplemented.isIrrefutable ha, WeaklyComplemented.isIrrefutable hb, _, _, t =>\n  absurd t λ h => ha λ ha => hb λ hb => h (And.intro ha hb)\n\n/-- recursor for `NAnd`\n\n  See `NAnd.rec`.\n-/\nprotected def NAnd.recOn {motive : NAnd a b → Prop} (t : NAnd a b) [WeaklyComplemented a] [WeaklyComplemented b] := NAnd.rec (motive:=motive) (t:=t)\n\n/-- recursor for `NAnd`\n\n  See `NAnd.rec`.\n-/\nprotected def NAnd.casesOn {motive : NAnd a b → Prop} := NAnd.recOn (motive:=motive)\n\n/-- eliminator for `NAnd`\n\n  Can only eliminate intro `Prop`, see `NAnd.elimLarge` to eliminate into other sorts.\n\n  Note: This is a fake eliminator -- `NAnd` is not an inductive type.\n-/\nprotected def NAnd.elim {motive : Prop} := NAnd.recOn (motive := λ _ : NAnd a b => motive)\n\n/-- large recursor for `NAnd`\n\n  In order to eliminate into sorts other than `Prop`, we must assume that the propositions are weakly decidable.\n\n  Note: This is a fake recursor -- `NAnd` is not an inductive type.\n-/\nprotected def NAnd.recLarge.{u} {motive : NAnd a b → Sort u} : [WeaklyDecidable a] → [WeaklyDecidable b] →\n  (inl : (h : ¬a) → motive (NAnd.inl h)) → (inr : (h : ¬b) → motive (NAnd.inr h)) → (t : NAnd a b) → motive t\n| WeaklyDecidable.isFalse ha, _, h, _, _ => h ha\n| _, WeaklyDecidable.isFalse hb, _, h, _ => h hb\n| WeaklyDecidable.isIrrefutable ha, WeaklyDecidable.isIrrefutable hb, _, _, t =>\n  absurd t λ h => ha λ ha => hb λ hb => h (And.intro ha hb)\n\nprotected def NAnd.recLargeOn.{u} {motive : NAnd a b → Sort u} (t : NAnd a b) [WeaklyDecidable a] [WeaklyDecidable b] := NAnd.recLarge (motive:=motive) (t:=t)\n\nprotected def NAnd.casesLargeOn.{u} {motive : NAnd a b → Sort u} := NAnd.recLargeOn (motive:=motive)\n\n/-- large eliminator for `NAnd`\n\n  In order to eliminate into sorts other than `Prop`, we must assume that the propositions are weakly decidable.\n\n  Note: This is a fake eliminator -- `NAnd` is not an inductive type.\n-/\nprotected def NAnd.elimLarge.{u} {motive : Sort u} := NAnd.recLargeOn (motive := λ _ : NAnd a b => motive)\n\ntheorem nand_of_not_or_not : ¬a ∨ ¬b → ¬(a ∧ b)\n| Or.inl h => NAnd.inl h\n| Or.inr h => NAnd.inr h\n\ntheorem not_or_not_of_nand [WeaklyComplemented a] [WeaklyComplemented b] : ¬(a ∧ b) → ¬a ∨ ¬b :=\n  λ h => NAnd.elim h Or.inl Or.inr\n\ntheorem nand_iff_not_or_not (a b : Prop) [WeaklyComplemented a] [WeaklyComplemented b] : ¬(a ∧ b) ↔ ¬a ∨ ¬b :=\n  Iff.intro not_or_not_of_nand nand_of_not_or_not\n\ntheorem NAnd.eq_not_or_not (a b : Prop) [WeaklyComplemented a] [WeaklyComplemented b] : NAnd a b = (¬a ∨ ¬b) :=\n  propext (nand_iff_not_or_not a b)\n\n/-- de Morgan's law for `Or`\n\n  Only valid for weakly complemented propositions.\n-/\nprotected theorem And.deMorgan [WeaklyComplemented a] [WeaklyComplemented b] : ¬(a ∧ b) ↔ ¬a ∨ ¬b := nand_iff_not_or_not a b\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Logic/Connectives.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.4956839137267956}}
{"text": "import Euclid.tarski_1\nopen classical set\nnamespace Euclidean_plane\nvariables {point : Type} [Euclidean_plane point]\n\nlocal attribute [instance] prop_decidable\n\ntheorem six9 {a b p : point} : b ∈ ray p a → ray p a = ray p b :=\nbegin\nintro h,\next,\nsplit,\n  intro h1,\n  cases h with h h2,\n  cases h2 with h2 h3,\n  cases h1 with h1 h4,\n  cases h4 with h4 h5,\n  split,\n    exact h2,\n  split,\n    exact h4,\n  cases h3,\n    cases h5,\n      exact five1 h.symm h3 h5,\n    right,\n    exact three6b h5 h3,\n  cases h5,\n    left,\n    exact three6b h3 h5,\n  exact five3 h3 h5,\nintro h1,\ncases h with h h2,\ncases h2 with h2 h3,\ncases h1 with h1 h4,\ncases h4 with h4 h5,\nsplit,\n  exact h,\nsplit,\nexact h4,\ncases h3,\n  cases h5,\n    left,\n    exact three6b h3 h5,\n  exact five3 h3 h5,\ncases h5,\n  exact five1 h2.symm h3 h5,\nright,\nexact three6b h5 h3\nend\n\ntheorem six10 {a b c p q r : point} : sided a b c → sided p q r → eqd a b p q → eqd a c p r → cong a b c p q r :=\nbegin\nintro h,\nrevert p q r,\nwlog h4 : distle a b a c,\n    exact (five10 a b a c),\n  introv h1 h2 h3,\n  repeat {split};\n  try {assumption},\n  have h5 : distle p q p r,\n    exact five6 h4 h2 h3,  \n  have h6 : B a b c,\n    exact (six12 h).1 h4,\n  have h7 : B p q r,\n    exact (six12 h1).1 h5,\n  exact (four3 h6.symm h7.symm h3.flip h2.flip).flip,\nhave h1 := this h.symm a_1.symm a_3 a_2,\nrepeat {split},\n    exact h1.2.2,\n  exact h1.2.1.flip,\nexact h1.1\nend\n\ntheorem six10a {a b c a' b' c' : point} : sided a b c → cong a b c a' b' c' → sided a' b' c' :=\nbegin\nintro h,\nrevert a' b' c',\nwlog h1 : B a b c := (h.2.2) using b c,\n  introv h2,\n  split,\n    intro h_1,\n    subst b',\n    exact h.1.symm (id_eqd h2.1),\n  split,\n    intro h_1,\n    subst c',\n    exact h.2.1.symm (id_eqd h2.2.2),\n  exact or.inl (four6 h1 h2),\napply (this h.symm _).symm,\nexact ⟨a_1.2.2, a_1.2.1.flip, a_1.1⟩\nend\n\ndef l (a b : point) : set point := {x | col a b x}\n\ndef line (k : set point) : Prop := ∃ a b, a ≠ b ∧ k = l a b\n\nlemma six14 {a b : point} : a ≠ b → line (l a b) :=\nbegin\nintro h,\nexistsi a,\nexistsi b,\nsplit,\n  exact h,\nrefl\nend\n\ntheorem six15 {p q r : point} : p ≠ q → p ≠ r → B q p r → l p q = ray p q ∪ {p} ∪ ray p r :=\nbegin\nintros h h1 h2,\next,\nsplit,\n  intro h3,\n  cases em (x = p),\n    left, right,\n    rw h_1,\n    simp,\n  cases h3,\n    left, left,\n    split,\n      exact h.symm,\n    split,\n      exact h_1,\n    left,\n    exact h3,\n    cases h3,\n    left, left,\n    split,\n      exact h.symm,\n    split,\n      exact h_1,\n    right,\n    exact h3.symm,\n  right,\n  split,\n    exact h1.symm,\n  split,\n    exact h_1,\n  exact five2 h.symm h2 h3.symm,\nintro h3,\ncases h3,\n  cases h3,\n    cases h3 with h3 h4,\n    cases h4 with h4 h5,\n    cases h5,\n      left,\n      exact h5,\n    right, left,\n    exact h5.symm,\n  have : x = p,\n    simpa using h3,\n  right, left,\n  rw this,\n  exact three1 q p,\ncases h3 with h3 h4,\ncases h4 with h4 h5,\nright, right,\ncases h5,\n  exact (three7b h2 h5 h1).symm,\nexact (three5a h2 h5).symm\nend\n\ntheorem six16 {p q r : point} : p ≠ q → p ≠ r → r ∈ l p q → l p q = l p r :=\nbegin\nintros h h1 h2,\next,\nsplit,\n  intro h3,\n  exact five4 h h2 h3,\nintro h3,\nhave : col p r q,\n  exact (four11 h2).1,\nexact five4 h1 this h3\nend\n\ntheorem six16a {p q r : point} : sided p q r → l p q = l p r :=\nλ h, six16 h.1.symm h.2.1.symm (four11 (six4.1 h).1).2.1\n\ntheorem six17 (p q : point) : l p q = l q p :=\nbegin\next,\nsplit,\n  intro h1,\n  exact (four11 h1).2.1,\nintro h1,\nexact (four11 h1).2.1\nend\n\ntheorem line.symm {a b : point} (h : line (l a b)) : line (l b a) := (six17 a b) ▸ h\n\n@[simp] theorem six17a (p q : point) : p ∈ l p q := (four11 (four12 p q)).1\n\n@[simp] theorem six17b (p q : point) : q ∈ l p q := (four11 (four12 q p)).2.2.2.1\n\ntheorem six18 {a b : point} {L : set point} : line L → a ≠ b → a ∈ L → b ∈ L → L = l a b :=\nbegin\nintros h h1 h2 h3,\ncases h with p hp,\ncases hp with q hq,\nrw hq.2 at *,\ncases em (a = p),\n  rw h at *,\n  exact six16 hq.1 h1 h3,\nhave ha : l p q = l p a,\n  exact six16 hq.1 (ne.symm h) h2,\nrw ha at *,\nrw six17 p a at *,\nexact six16 h h1 h3\nend\n\ntheorem six18a {a p q : point} : a ∉ l p q → a ≠ p ∧ a ≠ q :=\nbegin\nintro h,\nsplit,\n  intro h1,\n  subst a,\n  apply h,\n  simp,\nintro h1,\nsubst a,\nsimpa using h\nend\n\ntheorem six19 {a b : point} : a ≠ b → ∃! L : set point, line L ∧ a ∈ L ∧ b ∈ L :=\nbegin\nintro h,\nexistsi l a b,\nsplit,\n  split,\n    existsi a,\n    existsi b,\n    split,\n      exact h,\n    refl,\n  split;\n  simp,\nintros y hy,\nexact six18 hy.1 h hy.2.1 hy.2.2\nend\n\ntheorem six20 {a b c : point} {A : set point} : line A → a ∈ A → b ∈ A → a ≠ b → col a b c → c ∈ A :=\nbegin\nintros h h1 h2 h3 h4,\nsuffices : A = l a b,\n  subst A,\n  exact h4,\nexact six18 h h3 h1 h2\nend\n\ntheorem six21 {a b : point} {A B : set point} : a ≠ b → line A → line B → a ∈ A → a ∈ B → b ∈ A → b ∈ B → A = B :=\nbegin\nintros h h1 h2 h3 h4 h5 h6,\napply unique_of_exists_unique (six19 h),\n  repeat {split, assumption},\n  assumption,\nassumption\nend\n\ndef is (x : point) (A B : set point) : Prop := line A ∧ line B ∧ A ≠ B ∧ x ∈ A ∧ x ∈ B\n\ntheorem six21a {x y : point} {A B : set point} : line A → line B → A ≠ B → x ∈ A → x ∈ B → y ∈ A → y ∈ B → x = y :=\nλ h h1 h2 h3 h4 h5 h6, classical.by_contradiction (λ h_1,\nh2 (six21 h_1 h h1 h3 h4 h5 h6))\n\ntheorem six22 {x : point} {A : set point} : line A → x ∈ A → ∃ y, x ≠ y ∧ A = l x y :=\nbegin\nintros h h1,\nhave h2 := h,\ncases h with u hu,\ncases hu with v hv,\ncases em (u = x),\n  rw h at *,\n  constructor,\n  exact hv,\nconstructor,\nsplit,\n  exact ne.symm h,\nhave : u ∈ A,\n  rw hv.2,\n  simp,\nexact six18 h2 (ne.symm h) h1 this\nend\n\ntheorem six23 {a b c : point} : col a b c ↔ ∃ (L : set point), line L ∧ a ∈ L ∧ b ∈ L ∧ c ∈ L :=\nbegin\nsplit,\n  intro h,\n  cases em (a = b),\n    rw h_1 at *,\n    cases em (b = c),\n      rw h_2 at *,\n      cases three14 c c with p hp,\n      existsi l c p,\n      split,\n        exact six14 hp.2,\n      simp,\n    existsi l b c,\n    split,\n      exact six14 h_2,\n    simp,\n  existsi l a b,\n  split,\n    exact six14 h_1,\n  simpa using h,\nintro h,\ncases h with L h,\ncases em (a = b),\n  rw h_1,\n  exact four12 b c,\nhave : L = l a b,\n  exact six18 h.1 h_1 h.2.1 h.2.2.1,\nrw this at *,\nexact h.2.2.2\nend\n\ntheorem six24 : ¬col (P1 : point) P2 P3 :=\nbegin\nhave h := two_dim point,\nintro h1,\ncases h1,\n  exact h.1 h1,\ncases h1,\n  exact h.2.1 h1,\nexact h.2.2 h1\nend\n\ntheorem six25 {a b : point} : a ≠ b → ∃ c, ¬col a b c :=\nbegin\nintro h1,\nby_contradiction h2,\nrw not_exists at h2,\nsimp at h2,\napply @six24 point,\napply six23.2,\nexact ⟨l a b, six14 h1, h2 P1, h2 P2, h2 P3⟩\nend\n\nlemma six13a (a : point) : ¬line (l a a) :=\nbegin\nintro h,\ncases h with p hp,\ncases hp with q hq,\ncases six25 hq.1 with r hr,\napply hr,\nsuffices : r ∈ l a a,\n  rw hq.2 at this,\n  exact this,\nleft,\nexact three3 a r\nend\n\nlemma six13 {a b : point} : line (l a b) → a ≠ b := \nbegin\nintros h h1,\nsubst b,\napply six13a a,\nexact h\nend\n\ndef tri (a b c : point) : Prop := a ≠ b ∧ b ≠ c ∧ a ≠ c\n\ntheorem six26 {a b c : point} : ¬col a b c → tri a b c :=\nbegin\nintro h,\nsplit,\n  intro h,\n  rw h at *,\n  exact h (four12 b c),\nsplit,\n  intro h,\n  rw h at *,\n  exact h (four11 (four12 c a)).2.2.2.1,\nintro h,\nrw h at *,\nexact h (four11 (four12 c b)).1\nend\n\ntheorem six27 {a b c : point} {A : set point} : line A → a ∈ A → c ∈ A → B a b c → b ∈ A :=\nbegin\nintros h h1 h2 h3,\ncases em (a = c),\n  rw h_1 at h3,\n  have : c = b,\n    exact bet_same h3,\n  rwa this at h2,\nhave h4 := six18 h h_1 h1 h2,\nrw h4,\nright, left,\nexact h3.symm\nend\n\ntheorem six28 {a b c :point} : ¬col a b c → is a (l a b) (l a c) :=\nbegin\nintro h,\nsplit,\n  exact six14 (six26 h).1,\nsplit,\n  exact six14 (six26 h).2.2,\nsplit,\n  intro h1,\n  have h2 : c ∈ l a b,\n    rw h1,\n    simp,\n  contradiction,\nsimp\nend\n\n-- middle points\n\ndef M (a m b : point) : Prop := B a m b ∧ eqd m a m b \n\ntheorem M.symm {a b m : point} : M a m b → M b m a :=\nbegin\nintro h,\nsplit,\n  exact h.1.symm,\nexact h.2.symm\nend\n\ntheorem seven3 {a m : point} : M a m a ↔ a = m :=\nbegin\nsplit,\n  intro h,\n  exact bet_same h.1,\nintro h,\nrw h at *,\nsplit,\n  exact three1 m m,\nexact eqd.refl m m\nend\n\ntheorem seven4 (a p : point) : ∃! q, M p a q :=\nbegin\ncases em (a = p),\n  rw h,\n  existsi p,\n  split,\n    apply seven3.2,\n    refl,\n  intros y hy,\n  cases hy with h1 h2,\n  exact id_eqd h2.symm.flip,\ncases seg_cons a a p p with q hq,\napply exists_unique.intro,\nexact ⟨hq.1, hq.2.symm⟩,\nintros y hy,\napply unique_of_exists_unique (two12 a a p p (ne.symm h)),\nexact ⟨hy.1, hy.2.symm⟩,\nexact hq\nend\n\nnoncomputable def S (a p : point) : point := classical.some (seven4 a p)\n\ntheorem seven5 (a p : point) : M p a (S a p) := (classical.some_spec (seven4 a p)).1\n\ntheorem seven6 {a p q : point} : M p a q → q = S a p :=\nbegin\nintro h,\nexact unique_of_exists_unique (seven4 a p) h (classical.some_spec (seven4 a p)).1\nend\n\n@[simp] theorem seven7 (a p : point) : S a (S a p) = p :=\nbegin\ncases seven5 a p with h1 h2,\ngeneralize hq : S a p = q,\nrw hq at *,\ncases seven5 a q with h3 h4,\ngeneralize hr : S a q = r,\nrw hr at *,\ncases em (q = a),\n  rw h at *,\n  have ha : a = r,\n    exact id_eqd h4.symm,\n  rw ha at *,\n  exact id_eqd h2,\napply unique_of_exists_unique (two12 a a p q h),\n  split,\n    exact h3,\n  exact (eqd.trans h2 h4).symm,\nsplit,\n  exact h1.symm,\nexact eqd.refl a p\nend\n\ntheorem seven8 (a p : point) : ∃! q, S a q = p :=\nbegin\nexistsi S a p,\nsplit,\n  exact seven7 a p,\nintros q h,\nrw ←h,\nexact (seven7 a q).symm\nend\n\ntheorem seven9 {a p q : point} : S a p = S a q → p = q :=\nbegin\nintro h,\napply unique_of_exists_unique (seven8 a (S a p)),\n  simp,\nrw ←h\nend\n\ntheorem seven9a {a b : point} (p : point) : a ≠ b → S p a ≠ S p b :=\nbegin\nintros h h1,\nexact h (seven9 h1)\nend\n\ntheorem seven10 {a p : point} : S a p = p ↔ p = a :=\nbegin\nsplit,\n  intro h,\n  have : M p a (S a p),\n    exact seven5 a p,\n  rw h at *,\n  exact seven3.1 this,\nintro h,\nrw h,\nhave : M a a (S a a),\n  exact seven5 a a,\ncases this with h1 h2,\nexact id_eqd h2.symm.flip\nend\n\n@[simp] theorem seven11 (a : point) : S a a = a :=\nbegin\napply seven10.2,\nrefl\nend\n\ntheorem seven12a {a p : point} : a ≠ p → a ≠ S a p :=\nbegin\nintros h h1,\napply h,\nhave h2 : S a a = a,\n  exact seven11 a,\nexact seven9 (eq.trans h2 h1)\nend\n\ntheorem seven12b {a p : point} : a ≠ p → p ≠ S a p :=\nλ h h1, h.symm (seven10.1 h1.symm)\n\ntheorem seven13 (a p q : point) : eqd p q (S a p) (S a q) :=\nbegin\nhave hp : M p a (S a p),\n  exact seven5 a p,\nhave hq : M q a (S a q),\n  exact seven5 a q,\ngeneralize hp' : S a p = p',\ngeneralize hq' : S a q = q',\nrw hp' at *,\nrw hq' at *,\ncases em (p = a),\n  have : S a p = p,\n    exact seven10.2 h,\n  rw h at *,\n  rw this at *,\n  rw ←hp' at *,\n  exact hq.2,\ncases seg_cons p q a p' with x hx,\ncases seg_cons p' q a x with x' hx',\ncases seg_cons q p a q' with y hy,\ncases seg_cons q' p a y with y' hy',\nhave h1 : B a p x,\n  exact three6a hp.1.symm hx.1,\nhave h2 : B p p' x',\n  exact three6a hx.1.symm hx'.1,\nhave h3 : B a p' x',\n  exact three6a hp.1 h2,\nhave h4 : B a q y,\n  exact three6a hq.1.symm hy.1,\nhave h5 : B q q' y',\n  exact three6a hy.1.symm hy'.1,\nhave h6 : B a q' y',\n  exact three6a hq.1 h5,\nhave h7 : eqd a x y a,\n  exact two11 h1 h4.symm hy.2.symm.flip hx.2,\nhave h8 : eqd a x a x',\n  exact two11 h1 h3 hp.2 (eqd.trans hx.2 hx'.2.symm),\nhave h9 : eqd a x y' a,\n  exact two11 h1 h6.symm hy'.2.symm.flip (eqd.trans hx.2 hq.2.flip),\nhave h10 : B x a p',\n      exact three5b hx.1.symm hp.1,\nhave h11 : B y a q',\n      exact three5b hy.1.symm hq.1,\nhave h12 : afs x a x' y' y' a y x,\n  repeat {split},\n    exact three6b h10 hx'.1,\n    exact (three6b h11 hy'.1).symm,\n    exact two4 h9,\n    exact two5 (eqd.trans h8.symm h7),\n    exact two5 (eqd.refl x y'),\n  exact two4 h9.symm,\nhave h13 : x ≠ a,\n  intro h_1,\n  rw h_1 at h1,\n  exact h (bet_same h1).symm,\nhave h14 : eqd x' y' y x,\n  exact afive_seg h12 h13,\nhave h15 : ifs y q a x y' q' a x',\n  repeat {split},\n    exact h4.symm,\n    exact h6.symm,\n    exact eqd.trans h7.symm h9,\n    exact hq.2.flip,\n    exact two5 h14.symm,\n  exact h8,\nhave h16 := four2 h15,\nhave h17 : ifs x p a q x' p' a q',\n  repeat {split},\n    exact h1.symm,\n    exact h3.symm,\n    exact h8.flip,\n    exact hp.2.flip,\n    exact h16.flip,\n  exact hq.2,\nexact four2 h17\nend\n\ntheorem seven15 (a : point) {p q r : point} : B p q r ↔ B (S a p) (S a q) (S a r) :=\nbegin\nsplit,\n  intro h,\n  apply four6 h,\n  repeat {split};\n  exact seven13 a _ _, \nintro h,\nrw ←(seven7 a p),\nrw ←(seven7 a q),\nrw ←(seven7 a r),\napply four6 h,\nrepeat {split};\nexact seven13 a _ _, \nend\n\ntheorem seven16 (a : point) {p q r s : point}: eqd p q r s ↔ eqd (S a p) (S a q) (S a r) (S a s) :=\nbegin\nsplit,\n  intro h,\n  exact (seven13 a p q).symm.trans (h.trans (seven13 a r s)),\nintro h,\nhave h1 := eqd.trans (seven13 a (S a p) (S a q)).symm (eqd.trans h (seven13 a (S a r) (S a s))),\nsimpa using h1\nend\n\ntheorem seven16a (a : point) {p q r : point} : cong p q r (S a p) (S a q) (S a r) :=\nbegin\nrepeat {split};\nexact seven13 a _ _\nend\n\ntheorem seven14 (a : point) {p q r : point} : M p q r ↔ M (S a p) (S a q) (S a r) :=\nbegin\nsplit,\n  intro h,\n  cases h with h h1,\n  split,\n    exact (seven15 a).1 h,\n  exact (seven16 a).1 h1,\nintro h,\ncases h with h h1,\nsplit,\n  exact (seven15 a).2 h,\nexact (seven16 a).2 h1\nend\n\ntheorem S_of_col {p q r : point} (a : point) : col p q r ↔ col (S a p) (S a q) (S a r) :=\nbegin\nsplit,\n  intro h,\n  unfold col,\n  repeat {cases h};\n  simp [(seven15 a).1 h],\nintro h,\nunfold col,\nrepeat {cases h};\nsimp [(seven15 a).2 h]\nend\n\ntheorem seven17 {a b p q : point} : M p a q → M p b q → a = b :=\nbegin\nintros h h1,\nhave h2 := seven6 h,\nhave h3 := seven13 a q b,\nhave h4 := seven7 a p,\nrwa ←h2 at h4,\nrw h4 at h3,\nhave h6 : eqd p b p (S a b),\n  exact eqd.trans h1.2.flip h3,\nhave h7 := seven13 a p b,\nrw ←h2 at h7,\nhave h8 : eqd q b q (S a b),\n  exact eqd.trans h1.2.symm.flip h7,\nhave h9 : b = (S a b),\n  exact four19 h1.1 h6 h8.flip,\nexact (seven10.1 h9.symm).symm\nend\n\ntheorem seven18 {a b p : point} : S a p = S b p → a = b :=\nbegin\nintro h,\ngeneralize h1 : S a p = q,\nhave h2 := seven5 a p,\nrw h1 at h2,\nhave h3 := seven5 b p,\nrw (eq.trans h.symm h1) at h3,\nexact seven17 h2 h3\nend\n\ntheorem seven18a {a b p : point} : a ≠ b → S a p ≠ S b p:=\nλ h h1, h (seven18 h1)\n\ntheorem seven19 {a b p : point} : S a (S b p) = S b (S a p) ↔ a = b :=\nbegin\nsplit,\n  intro h,\n  generalize h1 : S a p = q,\n  have h2 := seven5 a p,\n  rw h1 at *,\n  have h3 := seven5 a (S b p),\n  rw h at h3,\n  cases h3 with h3 h4,\n  have h5 := (seven15 b).1 h3,\n  have h6 := (seven16 b).1 h4,\n  rw seven7 b p at *,\n  rw seven7 b q at *,\n  have h7 : M p (S b a) q,\n    split;\n    assumption,\n  have h8 : a = (S b a),\n    exact seven17 h2 h7,\n  exact seven10.1 h8.symm,\nintro h,\nrw h\nend\n\ntheorem seven20 {a m b : point} : col a m b → eqd m a m b → a = b ∨ M a m b :=\nbegin\nintros h h1,\ncases h,\n  right,\n  split;\n  assumption,\ncases h,\n  left,\n  have h2 := three3 b m,\n  have h3 : eqd a b b b,\n    exact four3 h.symm h2 h1.flip (eqd.refl b m),\n  exact id_eqd h3,\nleft,\nhave h2 := three3 a m,\nhave h3 : eqd b a a a,\n  exact four3 h h2 h1.symm.flip (eqd.refl a m),\nexact id_eqd h3.flip\nend\n\ntheorem seven21 {a b c d p : point} : ¬col a b c → b ≠ d → eqd a b c d → eqd b c d a → \ncol a p c → col b p d → M a p c ∧ M b p d :=\nbegin\nintros h h1 h2 h3 h4 h5,\ncases four14 (four11 h5).1 (two5 (eqd.refl b d)) with q hq,\nhave h6 := four13 (four11 h5).1 hq,\nhave h7 : fs b d p a d b q c,\n  split,\n    exact (four11 h5).1,\n  split,\n    exact hq,\n  split,\n    exact h2.flip,\n  exact h3.symm,\nhave h8 : fs b d p c d b q a,\n  split,\n    exact (four11 h5).1,\n  split,\n    exact hq,\n  split,\n    exact h3,\n  exact h2.symm.flip,\nhave h9 := four16 h7 h1,\nhave h10 := four16 h8 h1,\nhave h11 : cong a p c c q a,\nsplit,\n  exact h9.flip,\nsplit,\n  exact h10,\nexact two5 (eqd.refl a c),\nhave h12 : p = q,\n  suffices : l a c ≠ l b d,\n    apply six21a (six14 (six26 h).2.2) (six14 h1) this (four11 h4).1 (four11 h5).1 (four11 (four13 h4 h11)).2.2.2.1 (four11 h6).2.1,\n  intro h_1,\n  suffices : b ∉ l a c,\n    simpa [h_1, (six17a b d)] using this,\n  exact (four10 h).1,\nsubst q,\nsplit,\n  cases seven20 h4 h9,\n    exact ((six26 h).2.2 h_1).elim,\n  assumption,\ncases seven20 h5 (hq.2.2).flip,\n  contradiction,\nassumption\nend\n\ndef hourglass (a b c p q m n : point) : Prop := B a c p ∧ B b c q ∧ eqd c a c b ∧ eqd c p c q ∧ \nM a m b ∧ M p n q\n\nlemma seven23 {a b c p q m n : point} : hourglass a b c p q m n → distle c a c q → B m c n :=\nbegin\nintros h h_1,\ncases h with h h1,\ncases h1 with h1 h2,\ncases h2 with h2 h3,\ncases h3 with h3 h4,\ncases h4 with h4 h5,\ncases em (p = c),\n  rw h_2 at *,\n  have h_3 : q = c,\n    exact id_eqd h3.symm.flip,\n  rw h_3 at *,\n  have h_4 : c = n,\n    exact seven3.1 h5,\n  rw h_4 at *,\n  exact three1 m n,\ngeneralize h6 : S c p = a',\ngeneralize h7 : S c q = b',\ngeneralize h8 : S c n = m',\nhave h9 : M a' m' b',\n  have h_3 := (seven14 c).1 h5,\n  rwa [h6, h7, h8] at h_3,\nhave h10 : M p c a',\n  have h10 := seven5 c p,\n  rwa h6 at h10,\nhave h11 : M q c b',\n  have h11 := seven5 c q,\n  rwa h7 at h11,\nhave h12 : M n c m',\n  have h12 := seven5 c n,\n  rwa h8 at h12,\nhave h13 : distle c a c a',\n  exact five6 h_1 (eqd.refl c a) (eqd.trans h3.symm h10.2),\ncases em (a = c),\n  rw h_3 at *,\n  have : b = c,\n    exact id_eqd h2.symm.flip,\n  rw this at *,\n  have : c = m,\n    exact seven3.1 h4,\n  rw this,\n  exact three3 m n,\nhave h_4 : a' ≠ c,\n  intro h_4,\n  rw h_4 at *,\n  have : eqd c a c c,\n    exact five9 h13 (five11 c c a),\n  exact h_3 (id_eqd this.flip),\nhave h14 : sided c a a',\n  apply six3.2,\n  split,\n    exact h_3,\n  split,\n    exact h_4,\n  existsi p,\n  split,\n    exact h_2,\n  split,\n    exact h,\n  exact h10.1.symm,\nhave h15 : B c a a',\n  exact (six12 h14).1 h13,\nhave h16 : distle c b c b',\n  exact five6 h_1 h2 h11.2,\nhave h_5 : q ≠ c,\n  intro h_5,\n  rw h_5 at *,\n  exact h_2 (id_eqd h3.flip),\ncases em (b = c),\n  rw h_6 at *,\n  have : a = c,\n   exact id_eqd h2.flip,\n  rw this at *,\n  have : c = m,\n    exact seven3.1 h4,\n  rw this,\n  exact three3 m n,\nhave h_7 : b' ≠ c,\n  intro h_7,\n  rw h_7 at *,\n  have : eqd c b c c,\n    exact five9 h16 (five11 c c b),\n  exact h_6 (id_eqd this.flip),\nhave h17 : sided c b b',\n  apply six3.2,\n  split,\n    exact h_6,\n  split,\n    exact h_7,\n  existsi q,\n  split,\n    exact h_5,\n  split,\n    exact h1,\n  exact h11.1.symm,\nhave h18 : B c b b',\n  exact (six12 h17).1 h16,\ncases three17 h15.symm h18.symm h9.1 with r hr,\nhave h19 : B r c n,\n  exact three6a hr.1 h12.1.symm,\nsuffices : r = m,\n  rwa this at h19,\nhave h20 : ifs a' a c m' b' b c m',\n  repeat {split},\n    exact h15.symm,\n    exact h18.symm,\n    exact eqd.trans h10.2.symm.flip (eqd.trans h3.flip h11.2.flip),\n    exact h2.flip,\n    exact h9.2.flip,\n  exact eqd.refl c m',\nhave h20 := four2 h20,\nhave h21 : col m' c r,\n  right, left,\n  exact hr.1.symm,\nhave h22 : eqd r a r b,\n  cases em (m' = c),\n    rw h_8 at *,\n    have : c = r,\n      exact bet_same hr.1,\n    rw this at *,\n    exact h20.flip,\n  exact four17 h_8 h21 h20.flip h2,\nhave h23 : M a r b,\n  split,\n    exact hr.2,\n  exact h22,\nexact seven17 h23 h4\nend\n\ntheorem seven22 {a b c p q m n : point} : hourglass a b c p q m n → B m c n :=\nbegin\nintro h,\ncases five10 c a c q,\n  exact seven23 h h_1,\ncases h with h h1,\ncases h1 with h1 h2,\ncases h2 with h2 h3,\ncases h3 with h3 h4,\ncases h4 with h4 h5,\nhave h6 : hourglass q p c b a n m,\n  repeat {split},\n    exact h1.symm,\n    exact h.symm,\n    exact h3.symm,\n    exact h2.symm,\n    exact h5.1.symm,\n    exact h5.2.symm,\n    exact h4.1.symm,\n  exact h4.2.symm,\nexact (seven23 h6 h_1).symm\nend\n\ntheorem seven24 {a p : point} {A : set point} : line A → a ∈ A → (p ∈ A ↔ (S a p) ∈ A) :=\nbegin\nintros h h1,\nsplit,\n  intro h2,\n  cases em (a = p),\n    have h3 := seven10.2 h_1.symm,\n    rwa h3,\n  have h3 := six18 h h_1 h1 h2,\n  rw h3,\n  have h4 := seven5 a p,\n  right, right,\n  exact h4.1.symm,\nintro h2,\ncases em (a = (S a p)),\n  have h3 := seven10.2 h_1.symm,\n  rw ←seven7 a p,\n  rwa h3,\nhave h3 := six18 h h_1 h1 h2,\nrw h3,\nhave h4 := seven5 a p,\nright, right,\nexact h4.1\nend\n\ntheorem seven25 {a b c : point} : eqd c a c b → ∃ x, M a x b :=\nbegin\nintro h,\ncases em (col a c b),\n  cases seven20 h_1 h,\n    rw h_2 at *,\n    existsi b,\n    split,\n      exact three1 b b,\n    exact eqd.refl b b,\n  constructor, exact h_2,\ncases three14 c a with p hp,\ncases seg_cons b a p c with q hq,\ncases pasch hp.1.symm hq.1.symm with r hr,\ncases pasch hp.1 hr.2 with x hx,\nexistsi x,\nsuffices : eqd x a x b,\n  split,\n    exact hx.1,\n  exact this,\nsuffices : eqd r a r b,\n  have h1 : col c r x,\n    right, left,\n    exact hx.2,\n  cases em (c = r),\n    rw h_2 at hx,\n    have : r = x,\n      exact bet_same hx.2,\n    rw this at *,\n    exact this,\n  exact four17 h_2 h1 h this,\nhave h1 : afs c a p b c b q a,\n  repeat {split},\n    exact hp.1,\n    exact hq.1,\n    exact h,\n    exact hq.2.symm,\n    exact h.symm,\n  exact two5 (eqd.refl a b),\nhave h2 : eqd p b q a,\n  exact afive_seg h1 (six26 h_1).1.symm,\ncases four5 hr.2 h2.flip with r' hr',\nhave h3 : ifs b r p a a r' q b,\n  repeat {split},\n    exact hr.2,\n    exact hr'.1,\n    exact hr'.2.2.2,\n    exact hr'.2.2.1,\n    exact two4 (eqd.refl a b),\n  exact hq.2.symm.flip,\nhave h4 : ifs b r p q a r' q p,\n  repeat {split},\n    exact hr.2,\n    exact hr'.1,\n    exact hr'.2.2.2,\n    exact hr'.2.2.1,\n    exact hq.2,\n  exact two5 (eqd.refl p q),\nhave h5 := four2 h3,\nhave h6 := four2 h4,\nhave h7 : cong a r q b r' p,\n  split,\n    exact h5.flip,\n  split,\n    exact h6,\n  exact h2.symm.flip,\nhave h8 : col a r q,\n  left, exact hr.1,\nhave h9 := four13 h8 h7,\nhave h_2 : a ≠ q,\n  intro h_2,\n  rw ←h_2 at *,\n  have : col a c b,\n    right, left,\n    exact hq.1,\n  exact h_1 this,\nhave h_3 : b ≠ p,\n  intro h_3,\n  rw ←h_3 at *,\n  have : col a c b,\n    right, right,\n    exact hp.1.symm,\n  exact h_1 this,\nhave h10 : l a q ≠ l b p,\n  intro h_4,\n  suffices : a ∈ l b p,\n    have h_6 : col a p c,\n      right, right,\n      exact hp.1,\n    exact h_1 (five4 hp.2 h_6 (four11 this).2.2.2.2),\n  rw ←h_4,\n  simp,\nhave h11 : col b p r,\n  right, left,\n  exact hr.2.symm,\n  have h12 : col a q r',\n    right, left,\n    exact hr'.1.symm,\nsuffices : r' = r,\n  rwa this at h5,\nexact six21a (six14 h_2) (six14 h_3) h10 h12 (four11 h9).1 (four11 h8).1 h11\nend\n\nend Euclidean_plane\n", "meta": {"author": "ImperialCollegeLondon", "repo": "xena-UROP-2018", "sha": "b111fb87f343cf79eca3b886f99ee15c1dd9884b", "save_path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018", "path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018/xena-UROP-2018-b111fb87f343cf79eca3b886f99ee15c1dd9884b/src/Euclid_old/tarski_2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4956148078086191}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad, Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.pfunctor.multivariate.basic\nimport Mathlib.data.qpf.multivariate.basic\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\n/-!\n# The composition of QPFs is itself a QPF\n\nWe define composition between one `n`-ary functor and `n` `m`-ary functors\nand show that it preserves the QPF structure\n-/\n\nnamespace mvqpf\n\n\n/-- Composition of an `n`-ary functor with `n` `m`-ary\nfunctors gives us one `m`-ary functor -/\ndef comp {n : ℕ} {m : ℕ} (F : typevec n → Type u_1) (G : fin2 n → typevec m → Type u) (v : typevec m) :=\n  F fun (i : fin2 n) => G i v\n\nnamespace comp\n\n\nprotected instance inhabited {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} {G : fin2 n → typevec m → Type u} {α : typevec m} [I : Inhabited (F fun (i : fin2 n) => G i α)] : Inhabited (comp F G α) :=\n  I\n\n/-- Constructor for functor composition -/\nprotected def mk {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} {G : fin2 n → typevec m → Type u} {α : typevec m} (x : F fun (i : fin2 n) => G i α) : comp F G α :=\n  x\n\n/-- Destructor for functor composition -/\nprotected def get {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} {G : fin2 n → typevec m → Type u} {α : typevec m} (x : comp F G α) : F fun (i : fin2 n) => G i α :=\n  x\n\n@[simp] protected theorem mk_get {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} {G : fin2 n → typevec m → Type u} {α : typevec m} (x : comp F G α) : comp.mk (comp.get x) = x :=\n  rfl\n\n@[simp] protected theorem get_mk {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} {G : fin2 n → typevec m → Type u} {α : typevec m} (x : F fun (i : fin2 n) => G i α) : comp.get (comp.mk x) = x :=\n  rfl\n\n/-- map operation defined on a vector of functors -/\nprotected def map' {n : ℕ} {m : ℕ} {G : fin2 n → typevec m → Type u} [fG : (i : fin2 n) → mvfunctor (G i)] {α : typevec m} {β : typevec m} (f : typevec.arrow α β) : typevec.arrow (fun (i : fin2 n) => G i α) fun (i : fin2 n) => G i β :=\n  fun (i : fin2 n) => mvfunctor.map f\n\n/-- The composition of functors is itself functorial -/\nprotected def map {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} [fF : mvfunctor F] {G : fin2 n → typevec m → Type u} [fG : (i : fin2 n) → mvfunctor (G i)] {α : typevec m} {β : typevec m} (f : typevec.arrow α β) : comp F G α → comp F G β :=\n  mvfunctor.map fun (i : fin2 n) => mvfunctor.map f\n\nprotected instance mvfunctor {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} [fF : mvfunctor F] {G : fin2 n → typevec m → Type u} [fG : (i : fin2 n) → mvfunctor (G i)] : mvfunctor (comp F G) :=\n  mvfunctor.mk fun (α β : typevec m) => comp.map\n\ntheorem map_mk {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} [fF : mvfunctor F] {G : fin2 n → typevec m → Type u} [fG : (i : fin2 n) → mvfunctor (G i)] {α : typevec m} {β : typevec m} (f : typevec.arrow α β) (x : F fun (i : fin2 n) => G i α) : mvfunctor.map f (comp.mk x) = comp.mk (mvfunctor.map (fun (i : fin2 n) (x : G i α) => mvfunctor.map f x) x) :=\n  rfl\n\ntheorem get_map {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} [fF : mvfunctor F] {G : fin2 n → typevec m → Type u} [fG : (i : fin2 n) → mvfunctor (G i)] {α : typevec m} {β : typevec m} (f : typevec.arrow α β) (x : comp F G α) : comp.get (mvfunctor.map f x) = mvfunctor.map (fun (i : fin2 n) (x : G i α) => mvfunctor.map f x) (comp.get x) :=\n  rfl\n\nprotected instance mvqpf {n : ℕ} {m : ℕ} {F : typevec n → Type u_1} [fF : mvfunctor F] [q : mvqpf F] {G : fin2 n → typevec m → Type u} [fG : (i : fin2 n) → mvfunctor (G i)] [q' : (i : fin2 n) → mvqpf (G i)] : mvqpf (comp F G) :=\n  mk (mvpfunctor.comp (P F) fun (i : fin2 n) => P (G i))\n    (fun (α : typevec m) => comp.mk ∘ (mvfunctor.map fun (i : fin2 n) => abs) ∘ abs ∘ mvpfunctor.comp.get)\n    (fun (α : typevec m) => mvpfunctor.comp.mk ∘ repr ∘ (mvfunctor.map fun (i : fin2 n) => repr) ∘ comp.get) sorry sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/qpf/multivariate/constructions/comp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4956148000440232}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.functor.basic\n\n/-!\n# Unbundled functors, as a typeclass decorating the object-level function.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\nnamespace category_theory\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\n/-- A unbundled functor. -/\n-- Perhaps in the future we could redefine `functor` in terms of this, but that isn't the\n-- immediate plan.\nclass functorial (F : C → D) : Type (max v₁ v₂ u₁ u₂) :=\n(map       : Π {X Y : C}, (X ⟶ Y) → ((F X) ⟶ (F Y)))\n(map_id'   : ∀ (X : C), map (𝟙 X) = 𝟙 (F X) . obviously)\n(map_comp' : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = (map f) ≫ (map g) . obviously)\n\n/--\nIf `F : C → D` (just a function) has `[functorial F]`,\nwe can write `map F f : F X ⟶ F Y` for the action of `F` on a morphism `f : X ⟶ Y`.\n-/\ndef map (F : C → D) [functorial.{v₁ v₂} F] {X Y : C} (f : X ⟶ Y) : F X ⟶ F Y :=\nfunctorial.map.{v₁ v₂} f\n\n@[simp] lemma map_as_map {F : C → D} [functorial.{v₁ v₂} F] {X Y : C} {f : X ⟶ Y} :\n  functorial.map.{v₁ v₂} f = map F f := rfl\n\n@[simp] lemma functorial.map_id {F : C → D} [functorial.{v₁ v₂} F] {X : C} :\n  map F (𝟙 X) = 𝟙 (F X) := functorial.map_id' X\n\n@[simp] lemma functorial.map_comp\n  {F : C → D} [functorial.{v₁ v₂} F] {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} :\n  map F (f ≫ g) = map F f ≫ map F g := functorial.map_comp' f g\n\nnamespace functor\n\n/--\nBundle a functorial function as a functor.\n-/\ndef of (F : C → D) [I : functorial.{v₁ v₂} F] : C ⥤ D :=\n{ obj := F,\n  ..I }\n\nend functor\n\ninstance (F : C ⥤ D) : functorial.{v₁ v₂} (F.obj) := { .. F }\n\n@[simp]\nlemma map_functorial_obj (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) : map F.obj f = F.map f := rfl\n\ninstance functorial_id : functorial.{v₁ v₁} (id : C → C) :=\n{ map := λ X Y f, f }\n\nsection\nvariables {E : Type u₃} [category.{v₃} E]\n\n/--\n`G ∘ F` is a functorial if both `F` and `G` are.\n-/\n-- This is no longer viable as an instance in Lean 3.7,\n-- #lint reports an instance loop\n-- Will this be a problem?\ndef functorial_comp (F : C → D) [functorial.{v₁ v₂} F] (G : D → E) [functorial.{v₂ v₃} G] :\n  functorial.{v₁ v₃} (G ∘ F) :=\n{ ..(functor.of F ⋙ functor.of G) }\n\nend\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/functor/functorial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.6723316860482762, "lm_q1q2_score": 0.49561479812898784}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.limits.shapes.biproducts\nimport category_theory.limits.preserves.shapes.zero\n\n/-!\n# Preservation of biproducts\n\nWe define the image of a (binary) bicone under a functor that preserves zero morphisms and define\nclasses `preserves_biproduct` and `preserves_binary_biproduct`. We then\n\n* show that a functor that preserves biproducts of a two-element type preserves binary biproducts,\n* give the canonical isomorphism between the image of a biproduct and the biproduct of the images,\n* show that in a preadditive category, a functor preserves a biproduct if and only if it preserves\n  the corresponding product if and only if it preserves the corresponding coproduct.\n\n-/\n\nuniverses v u u₂\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u} [category.{v} C] {D : Type u₂} [category.{v} D]\n\nsection has_zero_morphisms\nvariables [has_zero_morphisms C] [has_zero_morphisms D]\n\nnamespace functor\n\nsection map\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type v}\n\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef map_bicone {f : J → C} (b : bicone f) : bicone (F.obj ∘ f) :=\n{ X := F.obj b.X,\n  π := λ j, F.map (b.π j),\n  ι := λ j, F.map (b.ι j),\n  ι_π := λ j j',\n  begin\n    rw ← F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_ι_π_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_ι_π_ne _ h, F.map_zero] }\n  end }\n\nend bicone\n\n/-- The image of a binary bicone under a functor. -/\n@[simps]\ndef map_binary_bicone {X Y : C} (b : binary_bicone X Y) : binary_bicone (F.obj X) (F.obj Y) :=\n{ X := F.obj b.X,\n  fst := F.map b.fst,\n  snd := F.map b.snd,\n  inl := F.map b.inl,\n  inr := F.map b.inr,\n  inl_fst' := by rw [← F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [← F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [← F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [← F.map_comp, b.inr_snd, F.map_id] }\n\nend map\n\nend functor\n\nopen category_theory.functor\n\nnamespace limits\n\nsection bicone\nvariables {J : Type v}\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\nclass preserves_biproduct (f : J → C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : bicone f}, b.is_bilimit → (F.map_bicone b).is_bilimit)\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\ndef is_bilimit_of_preserves {f : J → C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_biproduct f F] {b : bicone f} (hb : b.is_bilimit) : (F.map_bicone b).is_bilimit :=\npreserves_biproduct.preserves hb\n\nvariables (J)\n\n/-- A functor `F` preserves biproducts of shape `J` if it preserves biproducts of `f` for every\n    `f : J → C`. -/\nclass preserves_biproducts_of_shape (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {f : J → C}, preserves_biproduct f F)\n\nattribute [instance, priority 100] preserves_biproducts_of_shape.preserves\n\nend bicone\n\n/-- A functor `F` preserves finite biproducts if it preserves biproducts of shape `J` whenever\n    `J` is a fintype. -/\nclass preserves_finite_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type v} [fintype J], preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_finite_biproducts.preserves\n\n/-- A functor `F` preserves biproducts if it preserves biproducts of any (small) shape `J`. -/\nclass preserves_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type v}, preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_biproducts.preserves\n\n@[priority 100]\ninstance preserves_finite_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts F] : preserves_finite_biproducts F :=\n{ preserves := λ J _, infer_instance }\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\nclass preserves_binary_biproduct (X Y : C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : binary_bicone X Y}, b.is_bilimit → (F.map_binary_bicone b).is_bilimit)\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\ndef is_binary_bilimit_of_preserves {X Y : C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_binary_biproduct X Y F] {b : binary_bicone X Y} (hb : b.is_bilimit) :\n  (F.map_binary_bicone b).is_bilimit :=\npreserves_binary_biproduct.preserves hb\n\n/-- A functor `F` preserves binary biproducts if it preserves the binary biproduct of `X` and `Y`\n    for all `X` and `Y`. -/\nclass preserves_binary_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {X Y : C}, preserves_binary_biproduct X Y F . tactic.apply_instance)\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_biproduct (F : C ⥤ D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair_function X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb,\n  { is_limit := is_limit.of_iso_limit\n      ((is_limit.postcompose_hom_equiv (by exact diagram_iso_pair _) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_limit)) $\n      cones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy, }),\n    is_colimit := is_colimit.of_iso_colimit\n      ((is_colimit.precompose_inv_equiv (by exact diagram_iso_pair _ ) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_colimit)) $\n      cocones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy, }) } }\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape walking_pair.{v} F] :\n  preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_biproduct F X Y }\n\nattribute [instance, priority 100] preserves_binary_biproducts.preserves\n\nend limits\n\nopen category_theory.limits\n\nnamespace functor\n\nsection bicone\nvariables {J : Type v} (F : C ⥤ D) [preserves_zero_morphisms F] (f : J → C)\n  [has_biproduct f] [preserves_biproduct f F]\n\ninstance has_biproduct_of_preserves : has_biproduct (F.obj ∘ f) :=\nhas_biproduct.mk\n{ bicone := F.map_bicone (biproduct.bicone f),\n  is_bilimit := preserves_biproduct.preserves (biproduct.is_bilimit _) }\n\n/-- If `F` preserves a biproduct, we get a definitionally nice isomorphism\n    `F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f)`. -/\n@[simp]\ndef map_biproduct : F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (λ j, F.map (biproduct.π f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (λ j, F.map (biproduct.ι f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C ⥤ D) [preserves_zero_morphisms F] (X Y : C) [has_binary_biproduct X Y]\n  [preserves_binary_biproduct X Y F]\n\ninstance has_binary_biproduct_of_preserves : has_binary_biproduct (F.obj X) (F.obj Y) :=\nhas_binary_biproduct.mk\n{ bicone := F.map_binary_bicone (binary_biproduct.bicone X Y),\n  is_bilimit := preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _) }\n\n/-- If `F` preserves a binary biproduct, we get a definitionally nice isomorphism\n    `F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y :=\nbiprod.unique_up_to_iso _ _\n  (preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _))\n\nlemma map_biprod_hom : (map_biprod F X Y).hom = biprod.lift (F.map biprod.fst) (F.map biprod.snd) :=\nrfl\n\nlemma map_biprod_inv : (map_biprod F X Y).inv = biprod.desc (F.map biprod.inl) (F.map biprod.inr) :=\nrfl\n\nend functor\n\nnamespace limits\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type v} (f : J → C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : Π j, W ⟶ f j) :\n  F.map (biproduct.lift g) ≫ (F.map_biproduct f).hom = biproduct.lift (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).inv ≫ F.map (biproduct.desc g) = biproduct.desc (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).hom ≫ biproduct.desc (λ j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [← biproduct.map_biproduct_inv_map_desc, iso.hom_inv_id_assoc]\n\nend bicone\n\nsection binary_bicone\nvariables (X Y : C) [has_binary_biproduct X Y] [preserves_binary_biproduct X Y F] {W : C}\n\nlemma biprod.map_lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  F.map (biprod.lift f g) ≫ (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  biprod.lift (F.map f) (F.map g) ≫ (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [← biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X ⟶ W) (g : Y ⟶ W) :\n  (F.map_biprod X Y).inv ≫ F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X ⟶ W) (g : Y ⟶ W) :\n (F.map_biprod X Y).hom ≫ biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [← biprod.map_biprod_inv_map_desc, iso.hom_inv_id_assoc]\n\nend binary_bicone\n\nend limits\n\nend has_zero_morphisms\n\nopen category_theory.functor\n\nsection preadditive\nvariables [preadditive C] [preadditive D] (F : C ⥤ D) [preserves_zero_morphisms F]\n\nnamespace limits\n\nsection fintype\nvariables {J : Type v} [fintype J]\n\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite products. -/\ndef preserves_product_of_preserves_biproduct {f : J → C} [preserves_biproduct f F] :\n  preserves_limit (discrete.functor f) F :=\n{ preserves := λ c hc, is_limit.of_iso_limit\n  ((is_limit.postcompose_inv_equiv (discrete.comp_nat_iso_discrete _ _) _).symm\n    (is_bilimit_of_preserves F (bicone_is_bilimit_of_limit_cone_of_is_limit hc)).is_limit) $\n  cones.ext (iso.refl _) (by tidy) }\n\nsection\nlocal attribute [instance] preserves_product_of_preserves_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite products. -/\ndef preserves_products_of_shape_of_preserves_biproducts_of_shape\n  [preserves_biproducts_of_shape J F] : preserves_limits_of_shape (discrete J) F :=\n{ preserves_limit := λ f, preserves_limit_of_iso_diagram _ discrete.nat_iso_functor.symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite products\n    preserves finite biproducts. -/\ndef preserves_biproduct_of_preserves_product {f : J → C} [preserves_limit (discrete.functor f) F] :\n  preserves_biproduct f F :=\n{ preserves := λ b hb, is_bilimit_of_is_limit _ $\n    is_limit.of_iso_limit ((is_limit.postcompose_hom_equiv (discrete.comp_nat_iso_discrete _ _)\n      (F.map_cone b.to_cone)).symm (is_limit_of_preserves F hb.is_limit)) $\n      cones.ext (iso.refl _) (by tidy) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite products\n    preserves finite biproducts. -/\ndef preserves_biproducts_of_shape_of_preserves_products_of_shape\n  [preserves_limits_of_shape (discrete J) F] : preserves_biproducts_of_shape J F :=\n{ preserves := λ f, preserves_biproduct_of_preserves_product F }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite coproducts. -/\ndef preserves_coproduct_of_preserves_biproduct {f : J → C} [preserves_biproduct f F] :\n  preserves_colimit (discrete.functor f) F :=\n{ preserves := λ c hc, is_colimit.of_iso_colimit\n    ((is_colimit.precompose_hom_equiv (discrete.comp_nat_iso_discrete _ _) _).symm\n      (is_bilimit_of_preserves F\n        (bicone_is_bilimit_of_colimit_cocone_of_is_colimit hc)).is_colimit) $\n    cocones.ext (iso.refl _) (by tidy) }\n\nsection\nlocal attribute [instance] preserves_coproduct_of_preserves_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite coproducts. -/\ndef preserves_coproducts_of_shape_of_preserves_biproducts_of_shape\n  [preserves_biproducts_of_shape J F] : preserves_colimits_of_shape (discrete J) F :=\n{ preserves_colimit := λ f, preserves_colimit_of_iso_diagram _ discrete.nat_iso_functor.symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts\n    preserves finite biproducts. -/\ndef preserves_biproduct_of_preserves_coproduct {f : J → C}\n  [preserves_colimit (discrete.functor f) F] : preserves_biproduct f F :=\n{ preserves := λ b hb, is_bilimit_of_is_colimit _ $\n    is_colimit.of_iso_colimit ((is_colimit.precompose_inv_equiv (discrete.comp_nat_iso_discrete _ _)\n      (F.map_cocone b.to_cocone)).symm (is_colimit_of_preserves F hb.is_colimit)) $\n      cocones.ext (iso.refl _) (by tidy) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts\n    preserves finite biproducts. -/\ndef preserves_biproducts_of_shape_of_preserves_coproducts_of_shape\n  [preserves_colimits_of_shape (discrete J) F] : preserves_biproducts_of_shape J F :=\n{ preserves := λ f, preserves_biproduct_of_preserves_coproduct F }\n\nend fintype\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary products. -/\ndef preserves_binary_product_of_preserves_binary_biproduct {X Y : C}\n  [preserves_binary_biproduct X Y F] : preserves_limit (pair X Y) F :=\n{ preserves := λ c hc, is_limit.of_iso_limit\n    ((is_limit.postcompose_inv_equiv (by exact diagram_iso_pair _) _).symm\n      (is_binary_bilimit_of_preserves F\n        (binary_bicone_is_bilimit_of_limit_cone_of_is_limit hc)).is_limit) $\n    cones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\nsection\nlocal attribute [instance] preserves_binary_product_of_preserves_binary_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary products. -/\ndef preserves_binary_products_of_preserves_binary_biproducts\n  [preserves_binary_biproducts F] : preserves_limits_of_shape (discrete walking_pair.{v}) F :=\n{ preserves_limit := λ K, preserves_limit_of_iso_diagram _ (diagram_iso_pair _).symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary products\n    preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_binary_product {X Y : C}\n  [preserves_limit (pair X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb, is_binary_bilimit_of_is_limit _ $\n    is_limit.of_iso_limit ((is_limit.postcompose_hom_equiv (by exact diagram_iso_pair _)\n      (F.map_cone b.to_cone)).symm (is_limit_of_preserves F hb.is_limit)) $\n        cones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary products\n    preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_binary_products\n  [preserves_limits_of_shape (discrete walking_pair.{v}) F] : preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_binary_product F }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary coproducts. -/\ndef preserves_binary_coproduct_of_preserves_binary_biproduct {X Y : C}\n  [preserves_binary_biproduct X Y F] : preserves_colimit (pair X Y) F :=\n{ preserves := λ c hc, is_colimit.of_iso_colimit\n    ((is_colimit.precompose_hom_equiv (by exact diagram_iso_pair _) _).symm\n      (is_binary_bilimit_of_preserves F\n        (binary_bicone_is_bilimit_of_colimit_cocone_of_is_colimit hc)).is_colimit) $\n      cocones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\nsection\nlocal attribute [instance] preserves_binary_coproduct_of_preserves_binary_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary coproducts. -/\ndef preserves_binary_coproducts_of_preserves_binary_biproducts\n  [preserves_binary_biproducts F] : preserves_colimits_of_shape (discrete walking_pair.{v}) F :=\n{ preserves_colimit := λ K, preserves_colimit_of_iso_diagram _ (diagram_iso_pair _).symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts\n    preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_binary_coproduct {X Y : C}\n  [preserves_colimit (pair X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb, is_binary_bilimit_of_is_colimit _ $\n    is_colimit.of_iso_colimit ((is_colimit.precompose_inv_equiv (by exact diagram_iso_pair _)\n      (F.map_cocone b.to_cocone)).symm (is_colimit_of_preserves F hb.is_colimit)) $\n        cocones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts\n    preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_binary_coproducts\n  [preserves_colimits_of_shape (discrete walking_pair.{v}) F] : preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_binary_coproduct F }\n\nend limits\n\nend preadditive\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/preserves/shapes/biproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6723316860482762, "lm_q1q2_score": 0.4956147903643921}}
{"text": "import SciLean.Operators\n\nnamespace SciLean\n\nvariable  {X Y Z W : Type} [Vec X] [Vec Y] [Vec Z] [Vec W]\n\n\nstructure HArray (Ts : List Type) where\n  data : Array (Sigma (λ T : Type => T))\n  h_len : Ts.length = data.size\n  typed : ∀ i : Fin Ts.length, (data.get (h_len ▸ i)).1 = Ts.get i\n\nnamespace HArray\n\n  variable {n} {Ts : List Type}\n\n  def get (u : HArray Ts) (i : Fin Ts.length) : Ts.get i\n    := u.typed i ▸ (u.data.get (u.h_len ▸ i)).2\n\n  def getOp (self : HArray Ts) (idx : Fin Ts.length) : Ts.get idx\n    := self.typed idx ▸ (self.data.get (self.h_len ▸ idx)).2\n\n  def set (u : HArray Ts) (i : Fin Ts.length) (x : Ts.get i) : HArray Ts\n    := ⟨u.data.set (u.h_len ▸ i) (⟨_, x⟩), sorry, sorry⟩\n\nend HArray\n\nclass HCurryType (n : Nat) (F : Type) where\n  Xs : List Type\n  Y  : Type\n\nattribute [reducible] HCurryType.Xs HCurryType.Y\n\n@[reducible]\ninstance : HCurryType 0 Y where\n  Xs := []\n  Y := Y\n\n@[reducible]\ninstance {X Y : Type} [t : HCurryType n Y] : HCurryType (n + 1) (X → Y) where\n  Xs := X::t.Xs\n  Y := t.Y\n\nclass HCurry (i : Nat) (Xs' Xs : List Type) (Y : Type) where\n  index_valid : Xs'.length + i = Xs.length\n  types_valid : ∀ j, i + j < Xs.length → Xs'.get ⟨j, sorry⟩ = Xs.get ⟨i + j, sorry⟩\n  F : Type\n  uncurry : F → (HArray Xs → Y)\n\nattribute [reducible] HCurry.F HCurry.uncurry\n\n@[reducible]\ninstance (Xs : List Type) (Y : Type) : HCurry n [] Xs Y where\n  index_valid := sorry\n  types_valid := sorry\n  F := Y\n  uncurry := λ y xs => y\n\n@[reducible]\ninstance [c : HCurry (i+1) (Xs') Xs Y] : HCurry (i) (X'::Xs') Xs Y where\n  index_valid := sorry\n  types_valid := sorry\n  F := X' → c.F\n  uncurry := λ f xs => \n    let h : (Xs.get ⟨i,sorry⟩ = X') := sorry\n    let xi : X' := (h ▸ xs[⟨i,sorry⟩])\n    c.uncurry (f xi) xs\n\ndef huncurry (n : Nat) {F : Type} [HCurryType n F] \n  [ci : HCurry 0 (HCurryType.Xs n F) (HCurryType.Xs n F) (HCurryType.Y n F)] \n  (f : F) := \n    let h : F = ci.F := sorry\n    ci.uncurry (h ▸ f)\n\n\nexample : huncurry 3 (λ (i j k : Nat) => i + j) \n          = \n          λ xs => xs[#0] + xs[#1] := \nby rfl\n\nexample : huncurry 2 (λ (i j k : Nat) => i + j) \n          = \n          λ xs k => xs[#0] + xs[#1] := \nby rfl \n\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Data/HArray.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056322076481139, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4955345869369528}}
{"text": "import data.set\n\nvariables {α β: Type}\n\ndef Property (α : Type) : Type := α → Prop \n\nstructure Claim (α : Type) := make :: (X : set α) (P : Property α)\n\n@[instance] def claim_default {α : Type} : inhabited (Claim α) := \n⟨Claim.make ∅ (λ x, true)⟩ \n\nnamespace list \n\ndef All {α : Type} (pred : α → Prop) : list α → Prop\n| [] := true \n| (h::t) := pred h ∧ All t\n\nend list \n\n@[reducible]\ndef meaning {α : Type} (C : Claim α) : Prop := \n∀ x ∈ C.X, C.P x \n\nnotation ⟦C⟧ := meaning C \n\nstructure Strategy (α : Type) :=\n(parent : Claim α) (decomp : Claim α → list (Claim α))\n\n@[instance] def strat_default {α : Type} : inhabited (Strategy α) := \n⟨Strategy.mk (default) (λ c, [])⟩\n\n\n\ndef deductive (α : Type) (S : Strategy α) : Prop := \nlet subclaims := (S.decomp) S.parent in \n(∀ clm ∈ subclaims, ⟦clm⟧) →  ⟦S.parent⟧ \n\nnamespace Strategy\n\ndef subclaims {α : Type} (S : Strategy α) : list (Claim α) := \n  S.decomp S.parent \nend Strategy \n\nnamespace property \n\n@[reducible]\ndef decomposition \n(Ps : list (Property α)) \n(Clm : Claim α) : list (Claim α) := \nlist.map (Claim.make Clm.X) Ps\n\nstructure input (α : Type) :=\n(Clm : Claim α)\n(Props : list (Property α))\n\n@[instance] def input_default {α : Type} : inhabited (input α) := \n⟨input.mk (default) []⟩\n\nnamespace input \n\n@[reducible]\ndef length (Γ : input α) : ℕ := Γ.Props.length\n\nlemma len_decomp (Γ : input α) : \nΓ.length = (decomposition Γ.Props Γ.Clm).length := \nby {rw decomposition, simp}\n\n@[reducible]\ndef subsets (Γ : input α) : fin (Γ.length) → set α := \nλ i, set_of (Γ.Props.nth_le i.1 i.2)\n\nend input\n\n\n\ndef justified\n(Γ : input α) : Prop :=\n(⋂ i, Γ.subsets i) ⊆ {x | Γ.Clm.P x}\n\n\n@[reducible]\ndef strategy (Γ : input α) : Strategy α := \n{ parent := Γ.Clm, \n  decomp := λ C, list.map (Claim.make C.X)  Γ.Props }  \n\n\n\ntheorem deductive_of_justfd\n: Π {Γ : property.input α},\njustified Γ → deductive α (property.strategy Γ) :=  \nbegin \n  intro Γ,\n  rw [justified,deductive, meaning,strategy], \n  simp only [fin.val_eq_coe],\n  intros H1 H2 x xMem, apply H1,\n  simp only [set.mem_Inter, set.mem_set_of_eq],\n  intro i, \n  replace H2 := H2 ((decomposition Γ.Props Γ.Clm).nth_le i.1 (fin.cast (input.len_decomp Γ) i).2),\n  simp at H2, apply H2, \n  apply list.nth_le_mem, assumption,\nend \n\nend property \n\n\n\n\n/-\nnamespace domain \n\n@[reducible]\ndef to_claim {α : Type}\n(P : Property α) (X : set α) : Claim α := \nClaim.mk X P\n\n@[reducible]\ndef preimages {α β: Type} \n(f : α → β)\n(Clm : Claim α)\n(bs : list (set β)) : list (set α) := \nlist.map (set.preimage f) bs\n\n@[reducible]\ndef decomposition {α β: Type} \n(f : α → β)\n(sets_range : list (set β))\n(Clm : Claim α) : list (Claim α) :=\n(preimages f Clm sets_range).map (to_claim Clm.P)\n\nstructure auxiliary (α β : Type) :=\n(Clm : Claim α)\n(f : α → β)\n(range_sets : list (set β))\n\ndef set_of_list : list α → set α \n| [] := ∅ \n| (h::t) := {h} ∪ set_of_list t\n\ndef complete (Γ : auxiliary α β) : Prop := \n ∀ b : β, ∃ s ∈ Γ.range_sets, b ∈ s\n\ndef to_strategy (Γ : auxiliary α β) : strategy α := \nstrategy.mk (Γ.Clm) (domain.decomposition Γ.f Γ.range_sets)\n\ntheorem deductive_of_justfd_comp (Γ : auxiliary α β) : complete Γ →  deductive α (to_strategy Γ) :=\nbegin \n  rw [complete, deductive, meaning, to_strategy], \n  simp only [fin.val_eq_coe],\n  intros H1 H2 x xMem,\n  unfold decomposition at H2,simp at H2,\n  unfold to_claim at H2,\n  have H3 : ∃ s ∈ Γ.range_sets, Γ.f x ∈ s, from H1 (Γ.f x),\n  rcases H3 with ⟨s,H3,H4⟩,\n  replace H2 := H2 s H3,\n  apply H2, assumption,\nend \n\nend domain\n-/", "meta": {"author": "loganrjmurphy", "repo": "ForeMoSt", "sha": "c7affc7c8971562520d2775ac48fe4f188f84b02", "save_path": "github-repos/lean/loganrjmurphy-ForeMoSt", "path": "github-repos/lean/loganrjmurphy-ForeMoSt/ForeMoSt-c7affc7c8971562520d2775ac48fe4f188f84b02/src/justification.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.49553457545519475}}
{"text": "import tactic\n\n\n-- freely adjoining a unary function to a group\ninductive adjoin_fun' (G : Type) [group G] : Type\n| of_group (g : G) : adjoin_fun'\n| u (g : adjoin_fun') : adjoin_fun'\n| mul (g h : adjoin_fun') : adjoin_fun'\n| inv (g : adjoin_fun') : adjoin_fun'\n\nvariables {G : Type} [group G]\n\nsection\n\nlocal notation x `*` y := adjoin_fun'.mul x y\nlocal notation x`⁻¹` := adjoin_fun'.inv x\nlocal notation `o` := adjoin_fun'.of_group 1\n\nopen adjoin_fun'\n\ninductive rel : adjoin_fun' G → adjoin_fun' G → Prop\n| mul_assoc (x y z) : rel (x * y * z) (x * (y * z))\n| mul_inv (x) : rel (x * x⁻¹) o\n| inv_mul (x) : rel (x⁻¹ * x) o\n| mul_one (x) : rel (x * o) x\n| one_mul (x) : rel (o * x) x\n| is_hom (x y : G) : rel (of_group (has_mul.mul x y)) (of_group x * of_group y)\n| mul {a₁ a₂ b₁ b₂} : rel a₁ b₁ → rel a₂ b₂ → rel (a₁ * a₂) (b₁ * b₂)\n| u {a b} : rel a b → rel (u a) (u b)\n| inv {a b} : rel a b → rel (a⁻¹) (b⁻¹)\n| refl (x) : rel x x\n| symm (x y) : rel x y → rel y x\n| trans (x y z) : rel x y → rel y z → rel x z\n\n\nvariable (G)\n\ninstance rel_setoid : setoid (adjoin_fun' G) :=\n{ r := rel, iseqv := ⟨rel.refl, rel.symm, rel.trans⟩ } \n\ndef adjoin_fun : Type := quotient (rel_setoid G)\n\ninstance : group (adjoin_fun G) :=\n{ mul := λ x y, quotient.lift_on₂ x y (λ x y, quotient.mk (x * y)) \n      (λ a₁ a₂ b₁ b₂ h₁ h₂, quotient.sound (rel.mul h₁ h₂)),\n  one := quotient.mk o,\n  inv := λ x, quotient.lift_on x (λ x, quotient.mk (x⁻¹)) \n    (λ a b h, quotient.sound (rel.inv h)),\n  mul_assoc := λ x y z, quotient.induction_on₃ x y z\n    (λ x y z, quotient.sound (rel.mul_assoc _ _ _)),\n  mul_one := λ x, quotient.induction_on x \n    (λ x, quotient.sound (rel.mul_one _)),\n  one_mul := λ x, quotient.induction_on x\n    (λ x, quotient.sound (rel.one_mul x)),\n  mul_left_inv := λ x, @quotient.induction_on (adjoin_fun' G)\n    (rel_setoid G) (λ x : adjoin_fun G, \n      quotient.lift_on₂ (quotient.lift_on x (λ x, quotient.mk (x⁻¹))\n      (λ a b h, quotient.sound (rel.inv h))) (x) (λ x y, quotient.mk (x * y))\n      (λ a₁ a₂ b₁ b₂ h₁ h₂, quotient.sound (rel.mul h₁ h₂)) = ⟦o⟧) _ \n      (λ x, quotient.sound (rel.inv_mul _)) }\n\nvariable {G}\n\ndef of_group : G →* adjoin_fun G :=\nmonoid_hom.mk' \n  (λ x, ⟦of_group x⟧)\n  (λ x y, quotient.sound (rel.is_hom _ _))\n\ndef u : adjoin_fun G → adjoin_fun G :=\nλ x, quotient.lift_on' x (λ x, ⟦adjoin_fun'.u x⟧) \n  (λ a b h, quotient.sound (rel.u h))\n\nend\n\ndef UMP {H : Type} [group H] (f : G →* H) \n  (u : adjoin_fun G → H → H) : adjoin_fun G →* H :=\nmonoid_hom.mk' \n  (λ g, quotient.lift_on g \n    (λ g, show H, from adjoin_fun'.rec_on g \n      f\n      (λ g h, u ⟦g⟧ h)\n      (λ _ _, (*))\n      (λ _ h, h⁻¹)) \n    (λ x y hxy, begin \n      induction hxy; simp [*, mul_assoc] at *,\n      rw [show ⟦hxy_a⟧ = ⟦hxy_b⟧, from quotient.sound hxy_ᾰ],\n    end))\n  (λ x y, quotient.induction_on₂ x y (λ x y, rfl))\n\nexample {A : Type} : (ℕ → A) ≃ (A × (ℕ → A → A)) :=\n{ to_fun := λ f, (f 0, λ n _, f n.succ),\n  inv_fun := λ x n, nat.rec_on n x.1 x.2,\n  left_inv := λ f, begin\n    dsimp,\n    ext n,\n    cases n,\n    { refl },\n    { refl },\n  end,\n  right_inv := begin\n    rintros ⟨a, f⟩,\n    ext1,\n    { refl },\n    { ext n,\n      dsimp, }\n    \n  end }\n\ndef UMP' {H : Type} [group H] (f : adjoin_fun G →* H) : (G →* H) × (adjoin_fun G → H → H) :=\n⟨f.comp of_group, λ g h, f (u g)⟩", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/parametricity/group_with_function.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478255, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4955345697143154}}
{"text": "/-\nCopyright (c) 2021 Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard\n-/\n\nimport data.rat.defs\nimport tactic.norm_num\n\n/-!\n# The category of elliptic curves (over a field or a PID)\n\nWe give a working definition of elliptic curves which is mathematically accurate\nin many cases, and also good for computation.\n\n## Mathematical background\n\nLet `S` be a scheme. The actual category of elliptic curves over `S` is a large category,\nwhose objects are schemes `E` equipped with a map `E → S`, a section `S → E`, and some\naxioms (the map is smooth and proper and the fibres are geometrically connected group varieties\nof dimension 1). In the special case where `S` is `Spec R` for some commutative ring `R`\nwhose Picard group is trivial (this includes all fields, all principal ideal domains, and many\nother commutative rings) then it can be shown (using rather a lot of algebro-geometric machinery)\nthat every elliptic curve is, up to isomorphism, a projective plane cubic defined by\nthe equation `y^2+a₁xy+a₃y=x^3+a₂x^2+a₄x+a₆`, with `aᵢ : R`, and such that the discriminant\nof the aᵢ is a unit in `R`.\n\nSome more details of the construction can be found on pages 66-69 of\n[N. Katz and B. Mazur, *Arithmetic moduli of elliptic curves*][katz_mazur] or pages\n53-56 of [P. Deligne, *Courbes elliptiques: formulaire d'après J. Tate*][deligne_formulaire].\n\n## Warning\n\nThe definition in this file makes sense for all commutative rings `R`, but it only gives\na type which can be beefed up to a category which is equivalent to the category of elliptic\ncurves over `Spec R` in the case that `R` has trivial Picard group or, slightly more generally,\nwhen the 12-torsion of Pic(R) is trivial. The issue is that for a general ring R, there\nmight be elliptic curves over Spec(R) in the sense of algebraic geometry which are not\nglobally defined by a cubic equation valid over the entire base.\n\n## TODO\n\nDefine the R-points (or even A-points if A is an R-algebra). Care will be needed\nat infinity if R is not a field. Define the group law on the R-points. (hard) prove associativity.\n\n-/\n\n/-- The discriminant of the plane cubic `Y^2+a1*X*Y+a3*Y=X^3+a2*X^2+a4*X+a6`. If `R` is a field\nthen this polynomial vanishes iff the cubic curve cut out by this equation is singular. -/\ndef EllipticCurve.disc_aux {R : Type*} [comm_ring R] (a1 a2 a3 a4 a6 : R) : R :=\n-432*a6^2 + ((288*a2 + 72*a1^2)*a4 + (-216*a3^2 + (144*a1*a2 + 36*a1^3)*a3 + (-64*a2^3 -\n48*a1^2*a2^2 - 12*a1^4*a2 - a1^6)))*a6 + (-64*a4^3 + (-96*a1*a3 + (16*a2^2 + 8*a1^2*a2 + a1^4))*a4^2\n+ ((72*a2 - 30*a1^2)*a3^2 + (16*a1*a2^2 + 8*a1^3*a2 + a1^5)*a3)*a4 + (-27*a3^4 + (36*a1*a2 +\na1^3)*a3^3 + (-16*a2^3 - 8*a1^2*a2^2 - a1^4*a2)*a3^2))\n\n-- If Pic(R)[12]=0 then this definition is mathematically correct\n/-- The category of elliptic curves over `R` (note that this definition is only mathematically\ncorrect for certain rings, for example if `R` is a field or a PID). -/\nstructure EllipticCurve (R : Type*) [comm_ring R] :=\n(a1 a2 a3 a4 a6 : R)\n(disc_unit : Rˣ)\n(disc_unit_eq : (disc_unit : R) = EllipticCurve.disc_aux a1 a2 a3 a4 a6)\n\nnamespace EllipticCurve\n\ninstance : inhabited (EllipticCurve ℚ) := ⟨⟨0,0,1,-1,0, ⟨37, 37⁻¹, by norm_num, by norm_num⟩,\n  show (37 : ℚ) = _ + _, by norm_num⟩⟩\n\nvariables {R : Type*} [comm_ring R] (E : EllipticCurve R)\n\n/-- The discriminant of an elliptic curve. Sometimes only defined up to sign in the literature;\n  we choose the sign used by the LMFDB. See\n  [the LMFDB page on discriminants](https://www.lmfdb.org/knowledge/show/ec.discriminant)\n  for more discussion. -/\ndef disc : R := disc_aux E.a1 E.a2 E.a3 E.a4 E.a6\n\nlemma disc_is_unit : is_unit E.disc :=\nbegin\n  convert units.is_unit E.disc_unit,\n  exact E.disc_unit_eq.symm\nend\n\n/-- The j-invariant of an elliptic curve. -/\ndef j := (-48*E.a4 + (-24*E.a1*E.a3 + (16*E.a2^2 + 8*E.a1^2*E.a2 + E.a1^4)))^3 *\n  (E.disc_unit⁻¹ : Rˣ)\n\nend EllipticCurve\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebraic_geometry/EllipticCurve.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478255, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4955345697143154}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=irrational_orbit_density (α : ℝ) (h1 : ¬ is_rational α) : dense_set {r | ∃ i : ℤ, r = i*α} :=\nbegin\n  --Let $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  --If this were not true, then $i \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor$, which yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$.\n  have h2 : α ≠ i*α := sorry,\n  have h3 : ∀ (i j : ℤ), i ≠ j → i*α ≠ j*α, from sorry,\n  have h4 : ∀ (i j : ℤ), i ≠ j → ¬ (i*α = j*α), from sorry,\n\n  -- Hence\n  let S := {r | ∃ (i : ℤ), r = i*α},\n  have h5 : S ⊆ {r | ∃ (i : ℤ), r = i*α}, from subset.refl S,\n  have h6 : S = {r | ∃ (i : ℤ), r = i*α}, from set.subset.antisymm h5 h5,\n\n  -- Consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n  have h7 : ∀ (y : ℝ) (ε), y ∈ Icc 0 1 → ε > 0 → ∃ x, x ∈ S ∧ ∃ (N : ℤ), ↑N*(x - x) ≤ y ∧ y < ↑(N+1)*(x - x) ∧ ↑N*(x - x) - y < ε, from sorry,\n\n  -- $S$ has a limit point in $[0, 1]$.\n  have h8 : ∀ (y : ℝ), y ∈ Icc 0 1 → ∃! (x : ℝ), x ∈ S ∧ dist x y < ε, from sorry,\n\n  -- One can thus find pairs of elements of $S$ that are arbitrarily close.\n  have h9 : ∀ (u : ℝ), ∃ y, y ∈ S ∧ dist u y ≤ dist u y, from sorry,\n  have h10 : ∀ (y : ℝ) (ε), y ∈ Icc 0 1 → ε > 0 → ∃ x, x ∈ S ∧ dist x y < ε, from sorry,\n\n  -- Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n  have h11 : ∀ (x y : ℝ), x ∈ S ∧ y ∈ S → ∃ x', x' ∈ S ∧ ∃ (n : ℤ) ∈ set.range (λ (n : ℤ), (n : ℤ)), n*(x - y) = x', from sorry,\n  have h12 : ∀ (y : ℝ) (ε), y ∈ Icc 0 1 → ε > 0 → ∃ x, x ∈ S ∧ dist x y < ε, from sorry,\n\n  -- By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h13 : ∀ (y : ℝ), y ∈ Icc 0 1 → ∃! (x : ℝ), x ∈ S ∧ dist x y < ε, from sorry,\n  have h14 : ∀ (y : ℝ) (ε), y ∈ Icc 0 1 → ε > 0 → ∃ x, x ∈ S ∧ dist x y < ε, from sorry,\n\n  -- It follows that $0$ is a limit point of $S$.\n  have h15 : ∀ (y : ℝ) (ε), y ∈ Icc 0 1 → ε > 0 → ∃ x, x ∈ S ∧ dist x y < ε, from sorry,\n\n  sorry,\nend\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit : ∀ α : ℚ, α.irrational → ∃ S : set ℝ, (∀ i : ℤ, i ∈ ℤ → (i : ℚ) = ℚ.of_int i ∧ ℚ.of_int i * α ∈ ℝ) ∧ (∃ N : ℕ, ∀ i : ℤ, (i ∈ ℤ ∧ ℤ.pos_of_nat N ≤ i) → ℚ.of_int i ∈ S) ∧ (∃ N1 : ℕ, ∀ i : ℤ, (i ∈ ℤ ∧ i ≤ ℤ.neg_succ_of_nat N1) → ℚ.of_int i ∈ S) :=\nbegin\n  assume α h1,\n  let S : set ℝ := (λ a : ℤ, ℤ.to_rat a * α),\n  have h2 : ∀ (i : ℤ), i ∈ ℤ → ℤ.to_rat i * α ∈ ℝ, from sorry,\n  have h3 : ∃ N : ℕ, ∀ i : ℤ, (i ∈ ℤ ∧ ℤ.pos_of_nat N ≤ i) → ℚ.of_int i ∈ S, from sorry,\n  have h4 : ∃ N1 : ℕ, ∀ i : ℤ, (i ∈ ℤ ∧ i ≤ ℤ.neg_succ_of_nat N1) → ℚ.of_int i ∈ S, from sorry,\n  use {α : ℤ | (α ∈ ℤ ∧ ℤ.to_rat α * α ∈ ℝ)},\n  have h5 : ∀ i : ℤ, i ∈ ℤ → (i : ℚ) = ℚ.of_int i ∧ ℚ.of_int i * α ∈ ℝ, from sorry,\n  have h6 : ∃ N : ℕ, ∀ i : ℤ, (i ∈ ℤ ∧ ℤ.pos_of_nat N ≤ i) → ℚ.of_int i ∈ S, from sorry,\n  have h7 : ∃ N1 : ℕ, ∀ i : ℤ, (i ∈ ℤ ∧ i ≤ ℤ.neg_succ_of_nat N1) → ℚ.of_int i ∈ S, from sorry,\n  sorry,\nend\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_irrational_orbit (a : ℝ) (h1 : ¬ is_rat a) : \n(∀ i j : ℤ, i ≠ j → ((a*i) - (floor (a*i))) ≠ ((a*j) -(floor (a*j)))):= \nbegin\n  assume (hi : ∀ i j : ℤ, i ≠ j → ((a*i) - (floor (a*i))) ≠ ((a*j) -(floor (a*j)))),\n\n  sorry,\nend\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : α ≠ 0) : ∃ N : ℕ, ∀ (x : ℝ) (hx : 0 ≤ x ∧ x < 1), ∃ n ≥ N, ∃₁ (i : ℤ), ∃ (j : ℤ), i < j ∧ i = n*N ∧ j = n*N + 1 ∧ (x - i*α)*(x - j*α) < 0 :=\nbegin\n  --Let $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n  have h1 : ∀ (i1 i2 : ℤ), ¬ ((i1 ≠ i2) ∧ (i1 * α - i1 : ℤ) * α = (i2 * α - i2 : ℤ) * α),\n  from sorry,\n  \n  --Let $S$ be the set $\\{\\{i \\alpha\\} \\mid \\forall i \\in \\mathbb{Z}\\}$\n  let S : set ℝ := sorry,\n  \n  -- $S$ is an infinite subset of $\\left[0,1\\right]$\n  have h2 : ∀ x : ℝ, x ∈ S → 0 ≤ x ∧ x < 1, from sorry,\n  have h3 : infinite S, from sorry,\n  \n  --By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h4 : ∃ x : ℝ, x ∈  ['0,1] ∧ ∀ ε > 0, ∃ y ∈ S, y ≠ x ∧ abs (y - x) < ε,\n  from sorry,\n  \n  --one can thus find pairs of elements of $S$ that are arbitrarily close.\n  --Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n  have h5 : ∃ x : ℝ, x ∈  ['0,1] ∧ ∀ ε > 0, ∃ y ∈ S, y ≠ x ∧ abs (y - x) < ε ∧ 0 ∈ S,\n  from sorry,\n  \n  --To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n  have h6 : ∀ (y : ℝ) (ε : ℝ) (hy : 0 ≤ y ∧ y < 1) (hε : ε > 0), ∃ (x : ℝ), x ∈ S ∧ x ≠ 0 ∧ abs (x - 0) < ε ∧ 0 ∈ S ∧ \n    ∃ N : ℕ, ∃ n ≥ N,\n      ∃ (i : ℤ), ∃ (j : ℤ), i < j ∧ i = n*N ∧ j = n*N + 1 ∧ (y - i*α)*(y - j*α) < 0,\n  from sorry,\n  show ∃ N : ℕ, ∀ (x : ℝ) (hx : 0 ≤ x ∧ x < 1), ∃ n ≥ N, ∃₁ (i : ℤ), ∃ (j : ℤ), i < j ∧ i = n*N ∧ j = n*N + 1 ∧ (x - i*α)*(x - j*α) < 0, \n  from sorry,\nend\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) : ¬ is_rational α → ∀ a : ℤ, ∃ b : ℤ, ∀ c : ℤ, a ≠ c → b * α ≠ c * α := \nbegin\n    assume (h1 : ¬ is_rational α) (a : ℤ),\n    have h5 : ∀ a b : ℤ, a ≠ b → ¬ (a / b : ℝ) = α, from sorry,\n    have h2 : ∀ n : ℤ, ∃ m : ℤ, ((n / (m : ℕ) : ℝ) : ℝ) ≠ α, from sorry,\n\n    have h3 : ∀ m n : ℤ, n ≠ 0 → m ≠ n * m, from sorry,\n    \n    have h4 : ∀ m n : ℤ, ∃ (p : ℤ), (p ≠ m) ∧ (p ≠ n * m), from sorry,\n\n    sorry,\nend\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : α ∉ ℚ) : \n∀ ε > 0, ∃ (n : ℕ), ∃ (m : ℤ), |((n : ℕ) : ℝ) * α + (m : ℤ) | < ε :=\nbegin\n  --Let $\\alpha$ be an irrational number. \n  have h1 : (α ∈ ℚ) → false, from sorry,\n  have h2 : (α ∉ ℚ) := sorry,\n\n  --Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  have h3 : (∀ (i j : ℤ) (hi : i ≠ j), ((i : ℝ) * α) % 1 ≠ ((j : ℝ) * α) % 1) := sorry,\n\n  --If this were not true, then $\\{i \\alpha\\} = \\{j \\alpha\\}$ \n  have h4 : (∀ (i j : ℤ) (hi : i ≠ j), ((i : ℝ) * α) % 1 = ((j : ℝ) * α) % 1) → false, \n  from sorry,\n\n  --which yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$.\n  have h5 : (∀ (i j : ℤ) (hi : i ≠ j), (((i : ℝ) * α) % 1 = ((j : ℝ) * α) % 1) → (α ∈ ℚ)) → false, \n  from sorry,\n\n  --Hence, $S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$ is an infinite subset of $\\left[0,1\\right]$.\n  have h6 := sorry,\n  have h7 := sorry,\n  have h8 : (∀ i : ℤ, (i : ℝ) * α ∈ {n | 0 ≤ n ∧ n < 1}), from sorry,\n  have h9 := sorry,\n  have h10 := sorry,\n\n  --By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close.\n  have h11 := sorry,\n  have h12 := sorry,\n  have h13 := sorry,\n  \n  --Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n  have h14 := sorry,\n  have h15 := sorry,\n  \n  --To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$.\n  have h16 := sorry,\n  have h17 := sorry,\n  have h18 := sorry,\n  have h19 := sorry,\n\n  --Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point)\n  have h20 := sorry,\n  have h21 := sorry,\n  have h22 := sorry,\n\n  --and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n  have h23 := sorry,\n  have h24 := sorry,\n  have h25 := sorry,\n  have h26 := sorry,\n\n  --That is, $\\forall \\epsilon > 0, \\exists N: \\exists m: |((N : ℕ) : ℝ) * α + (m : ℤ) | < ε$\n  have h27 := sorry,\n  have h28 := sorry,\n  have h29 := sorry,\n\n  have h30 : ∃ (n : ℕ), ∃ (m : ℤ), |((n : ℕ) : ℝ) * α + (m : ℤ) | < ε, from sorry,\n\n  show ∀ ε > 0, ∃ (n : ℕ), ∃ (m : ℤ), |((n : ℕ) : ℝ) * α + (m : ℤ) | < ε, \n  from sorry,\nend\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) :\nlet orbit : ℤ → ℝ := λ i : ℤ, (i * α) % 1 in\n(∀ i j : ℤ, i ≠ j → (orbit i) ≠ (orbit j)) ∧ (∃ l : ℝ, l ∈ orbit '' (range (1 : ℤ)), ∀ y : ℝ, y ∈ Icc (0 : ℝ) (1 : ℝ) → ∃ i : ℤ, |y - (orbit i)| < 1) :=\nbegin\n  --If $\\alpha$ is an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$\n  assume h1 : ∀ i j : ℤ, i ≠ j → ((i * α) % 1) ≠ ((j * α) % 1),\n  --If this were not true, then $i \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor$,\n  have h2 : ∀ i j : ℤ, i ≠ j → ¬ (i * α - floor (i * α) = ((j * α) % 1) ∧ ((i * α) % 1) = ((j * α) % 1) ∧ (j * α - floor (j * α) = ((j * α) % 1)):= \n  begin\n    assume (i j : ℤ) (h2 : i ≠ j) (h3 : i * α - floor (i * α) = ((j * α) % 1) ∧ ((i * α) % 1) = ((j * α) % 1) ∧ (j * α - floor (j * α) = ((j * α) % 1)),\n    have h3 : i * α - floor (i * α) = ((j * α) % 1), from sorry,\n    have h4 : ((i * α) % 1) = ((j * α) % 1), from sorry,\n    have h5 : j * α - floor (j * α) = ((j * α) % 1), from sorry,\n    have h6 : i * α - floor (i * α) = (j * α - floor (j * α)), from sorry,\n    have h7 : i * α = j * α, from sorry,\n    have h8 : α = j / i, by {\n      rw ← @int.cast_mul ℝ _ _ i j at h7,\n      rw ← @int.cast_mul ℝ _ _ j i at h7,\n      exact h7,\n    },\n    have h9 : α ∈ ℚ,\n    by {\n      apply @rat.mk_eq_div_of_eq _ _ j i,\n      simpa [h8],\n    },\n    show false,\n    from sorry,\n  end,\n  have h3 : ∀ i j : ℤ, i ≠ j → ¬ (i * α - floor (i * α) = ((j * α) % 1)), from sorry,\n  have h4 : ∀ i j : ℤ, i ≠ j → ¬ ((i * α) % 1) = ((j * α) % 1)), from sorry,\n  have h5 : ∀ i j : ℤ, i ≠ j → ¬ (j * α - floor (j * α) = ((j * α) % 1)), from sorry,\n  have h6 : ∀ i j : ℤ, i ≠ j → ¬ (i * α - floor (i * α) = (j * α - floor (j * α))), from sorry,\n  have h7 : ∀ i j : ℤ, i ≠ j → ¬ (i * α = j * α), from sorry,\n  have h8 : ∀ i j : ℤ, i ≠ j → ¬ (α = j / i), from sorry,\n  have h9 : ∀ i j : ℤ, i ≠ j → ¬ (α ∈ ℚ), from sorry,\n\n  --$i \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor$,\n  --which yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$.\n  have h10 : ∀ i j : ℤ, i ≠ j → ¬ (α = (floor (i * α) - floor (j * α)) / (i - j)), from sorry,\n  have h11 : ∀ i j : ℤ, i ≠ j → ¬ ((α = (floor (i * α) - floor (j * α)) / (i - j)) ∧ α ∈ ℚ), from sorry,\n  have h12 : ∀ i j : ℤ, i ≠ j → ¬ α ∈ ℚ, from sorry,\n  \n  \n  --Hence, $S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$ is an infinite subset of $\\left[0,1\\right]$.\n  have h13 : (∃ i : ℤ, ((i * α) % 1) ∈ Icc (0 : ℝ) (1 : ℝ)),\n  from sorry,\n  \n  have h14 : (∃ S : set (ℝ), S = {((i * α) % 1) | i : ℤ} ∧ S ≠ ∅ ∧ ∀ x, x ∈ Icc (0 : ℝ) (1 : ℝ) → ∃ i : ℤ, ((i * α) % 1) = x),\n  from sorry,\n  \n  have h15 : (∃ S : set (ℝ), S = {((i * α) % 1) | i : ℤ} ∧ S ≠ ∅),\n  from sorry,\n  \n  have h16 : (∃ S : set (ℝ), S = {((i * α) % 1) | i : ℤ} ∧ S ≠ ∅ ∧ ∀ x, x ∈ Icc (0 : ℝ) (1 : ℝ) → ∃ i : ℤ, ((i * α) % 1) = x),\n  from sorry,\n  \n  have h17 : \n  --By the Bolzano-Weierstrass theorem, S has a limit point in [0, 1]\n  have h18 : ∃ l : ℝ, l ∈ orbit '' (range (1 : ℤ)), l ∈ Icc (0 : ℝ) (1 : ℝ) ∧ ∀ ε > 0, ∃ i : ℤ, i ∈ range (1 : ℤ) ∧ |l - (orbit i)| < ε,\n  from sorry,\n  \n  --One can thus find pairs of elements of $S$ that are arbitrarily close.\n  --Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n  have h19 : ∃ l : ℝ, l ∈ orbit '' (range (1 : ℤ)), l ∈ Icc (0 : ℝ) (1 : ℝ) ∧ ∀ ε > 0, ∃ i : ℤ, i ∈ range (1) ∧ |l - (orbit i)| < ε ∧ (∀ j : ℤ, j ∈ range (1) → |(orbit i) - (orbit j)| < ε),\n  from sorry,\n  \n  --To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. \n  have h20 : ∀ y : ℝ, y ∈ Icc (0 : ℝ) (1 : ℝ) → ∀ ε > 0, ∃ i : ℤ, i ∈ range (1) ∧ |y - (orbit i)| < ε ∧ (∀ j\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit {α : Type*} [linear_ordered_field α] (α : α) (h1 : α.irrational) : \n∀ ε > 0, ∃ x : α, 0 ≤ x ∧ x < ε :=\nbegin\n  assume (ε : α) (hε : ε > 0),\n  use 0,\n  show 0 ≤ 0 ∧ 0 < ε, from sorry,\nend\n\n--OUTPUT 9\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_irrational_orbit (α : ℝ) (h1 : irrational α) : \n∀ ε > 0, ∃ (m : ℤ), |m * α - ⌊m * α⌋| < ε :=\nbegin\n  assume ε h2,\n  have h3 : ∃ N : ℕ, ∀ (n : ℕ) (h4 : n > N), (n : ℕ) * α - ⌊(n : ℕ) * α⌋ < ε, from sorry,\n  cases h3 with N h4,\n  cases exists_lt_of_lt_add_one (h4 N (lt_succ_self N)) with m h5,\n  cases exists_eq_mul_left_of_ne_zero (and.right h5) with n h6,\n  use n,\n  have h7 : (n : ℕ) > N, begin rw h6, exact and.left h6, end,\n  have h8 : (n : ℕ) * α - ⌊(n : ℕ) * α⌋ < ε, from h4 _ h7,\n  rw h6 at h8,\n  apply abs_lt.1,\n  dsimp at h8,\n  exact h8,\nend\n\n--OUTPUT 10\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) [irrational α] : ∃ a ∈ ℤ, (a : ℝ) = α :=\nbegin\n    -- We need to show that $\\exists a ∈ ℤ, (a : ℝ) = α$.\n    -- We suppose that there doesn't exist $a ∈ ℤ, (a : ℝ) = α$ and derive a contradiction.\n\n    -- Assume there does not exist an integer $a$ such that $(a : ℝ) = α$.\n    assume h : ∀ a : ℤ, (a : ℝ) ≠ α,\n\n    -- We consider the set $A := \\{(a : ℝ) \\mid a ∈ ℤ\\}$.\n    let A := {(a : ℝ) | a ∈ ℤ},\n\n    -- We show that $\\forall x ∈ ℝ, ∃ y ∈ A, y = α$.\n    suffices h1 : ∀ x : ℝ, ∃ y ∈ A, y = α, by use (h1 α),\n\n    -- Assume there exists $x ∈ ℝ$ such that $\\forall y ∈ A, y ≠ α$.\n    assume h2 : ∃ x : ℝ, ∀ y ∈ A, y ≠ α,\n\n    -- We consider the set $A_0 := \\{x ∈ ℝ \\mid ∀ y ∈ A, y ≠ α\\}$.\n    let A0 := {x : ℝ | ∀ y ∈ A, y ≠ α},\n\n    -- We show that $A0 ≠ ∅$.\n    suffices h3 : A0 ≠ ∅, by use h3,\n\n    -- We show that if $x ∈ A0$, then $x ≠ α$.\n    suffices h4 : ∀ x : ℝ, x ∈ A0 → x ≠ α,\n\n    -- We show that if $x = α$, then $x ∉ A0$.\n    suffices h5 : ∀ x : ℝ, x = α → x ∉ A0,\n\n    -- Hence, supposing $A0 = ∅$, we derive a contradiction.\n    suffices h6 : A0 = ∅, from absurd h2 ⟨α, h5, h6⟩,\n\n    -- Assume $x = α$.\n    assume h7 : ∀ x : ℝ, x = α → x ∉ A0,\n\n    -- Assume $x ∈ A0$.\n    assume h8 : ∀ x : ℝ, x ∈ A0 → x ≠ α,\n\n    -- We show that $∃ y ∈ A, y = α$\n    suffices h9 : ∃ y ∈ A, y = α, by use h9,\n\n    -- We show that if $y ∈ A$, then $y = α$.\n    suffices h10 : ∀ y : ℝ, y ∈ A → y = α,\n\n    -- We consider the set $A_1 := \\{y ∈ ℝ \\mid y ∈ A → y = α\\}$.\n    let A1 := {y : ℝ | y ∈ A → y = α},\n\n    -- We show that $A1 ≠ ∅$.\n    suffices h11 : A1 ≠ ∅, by use h11,\n\n    -- We show that if $y ∈ A1$, then $y ∈ A$.\n    suffices h12 : ∀ y : ℝ, y ∈ A1 → y ∈ A,\n\n    -- We show that if $y ∈ A$, then $y ∈ A1$.\n    suffices h13 : ∀ y : ℝ, y ∈ A → y ∈ A1,\n\n    -- Hence, supposing $A1 = ∅$, we derive a contradiction.\n    suffices h14 : A1 = ∅, from absurd h10 ⟨α, h13, h14⟩,\n\n    -- Assume $y ∈ A$.\n    assume h15 : ∀ y : ℝ, y ∈ A → y ∈ A1,\n\n    -- Assume $y ∈ A1$.\n    assume h16 : ∀ y : ℝ, y ∈ A1 → y ∈ A,\n\n    -- We show that $∃ y ∈ A, y = α$\n    suffices h17 : ∃ y ∈ A, y = α, by use h17,\n\n    -- We show that if $y ∈ A$, then $y = α$.\n    suffices h18 : ∀ y : ℝ, y ∈ A → y = α,\n\n    -- We consider the set $A_2 := \\{y ∈ ℝ \\mid y ∈ A → y = α\\}$.\n    let A2 := {y : ℝ | y ∈ A → y = α},\n\n    -- We show that $A2 ≠ ∅$.\n    suffices h19 : A2 ≠ ∅, by use h19,\n\n    -- We show that if $y ∈ A2$, then $y ∈ A$.\n    suffices h20 : ∀ y : ℝ, y ∈ A2 → y ∈ A,\n\n    -- We show that if $y ∈ A$, then $y ∈ A2$.\n    suffices h21 : ∀ y : ℝ, y ∈ A → y ∈ A2,\n\n    -- Hence, supposing $A2 = ∅$, we derive a contradiction.\n    suffices h22 : A2 = ∅, from absurd h18 ⟨α, h21, h22⟩,\n\n    -- Assume $y ∈ A$.\n    assume h23 : ∀ y : ℝ, y ∈ A → y ∈ A2,\n\n    -- Assume $y ∈ A2$.\n    assume h24 : ∀ y : ℝ, y ∈ A2 → y ∈ A,\n\n    -- We show that $∃ y ∈ A, y = α$\n    suffices h25 : ∃ y ∈ A, y = α, by use h25,\n\n    -- We show that if $y ∈ A$, then $y = α$.\n    suffices h26 : ∀ y : ℝ, y ∈ A → y = α,\n\n    -- We consider the set $A_3 := \\{y ∈ ℝ \\mid y ∈ A → y = α\\}$.\n    let A3 := {y : ℝ | y ∈ A → y = α},\n\n    -- We show that $A3 ≠ ∅$.\n    suffices h27 : A3 ≠ ∅, by use h27,\n\n    -- We show that if $y ∈ A3$, then $y ∈ A$.\n    suffices h28 : ∀ y : ℝ, y ∈ A3 → y ∈ A,\n\n    -- We show that if $y ∈ A$, then $y ∈ A3$.\n    suffices h29 : ∀ y : ℝ, y ∈ A → y ∈ A3,\n\n    -- Hence, supposing $A3 = ∅$, we derive a contradiction.\n    suffices h30 : A3 = ∅, from absurd h26 ⟨α, h29, h30⟩,\n\n    -- Assume $y ∈ A$.\n    assume h31 : ∀ y : ℝ, y ∈ A → y ∈ A3,\n\n    -- Assume $y ∈ A3$.\n    assume h32 : ∀ y : ℝ, y ∈ A3 → y ∈ A,\n\n    -- We show that $∃ y ∈ A, y = α$\n    suffices h33 : ∃ y ∈ A, y = α, by use h33,\n\n    -- We show that if $y ∈ A$, then $y = α$.\n    suffices h34 : ∀ y : ℝ, y ∈ A → y = α,\n\n    -- We consider the set $A_4 := \\{y ∈ ℝ \\mid y ∈ A → y = α\\}$.\n    let A4 := {y : ℝ | y ∈ A → y = α},\n\n    -- We show that $A4 ≠ ∅$.\n    suffices h35 : A4 ≠ ∅, by use h35,\n\n    -- We show that if $y ∈ A4$, then $y ∈ A$.\n    suffices h36 : ∀ y :\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from sorry,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from sorry,\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by sorry\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by sorry\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by sorry\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n      have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n      show e = (1 : G), from sorry,     \n    },\n    sorry,\n  }\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n  from sorry,\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : ε > 0),\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that $\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n  cases h2 ε h7 with N1 h8,\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that $\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n  cases h3 ε h7 with N2 h9,\n  \n  --Let $N = \\max \\set {N_1, N_2}$.\n  let N := max N1 N2,\n  use N,\n\n  --Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n  have h10 : ∀ n > N, n > N1 ∧ n > N2 := sorry,\n  \n  --$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n  --$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n  --$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n  --So $\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n  from sorry,\n    \n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n  from sorry,\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  ∀ (n : ℕ), n > N → |x n - l| < ε, \n  from sorry,\nend\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n\nTo show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n\nQED\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline_with_comments-Natural-Language-Proof-Translation/lean_proof_outline_with_comments-4_few_shot_temperature_0.8_max_tokens_2000_n_10/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478254, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.49553456971431536}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Mario Carneiro\n\n! This file was ported from Lean 3 source module logic.equiv.basic\n! leanprover-community/mathlib commit d2d8742b0c21426362a9dacebc6005db895ca963\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Logic.Equiv.Defs\nimport Mathbin.Data.Option.Basic\nimport Mathbin.Data.Prod.Basic\nimport Mathbin.Data.Sigma.Basic\nimport Mathbin.Data.Subtype\nimport Mathbin.Data.Sum.Basic\nimport Mathbin.Logic.Function.Conjugate\n\n/-!\n# Equivalence between types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we continue the work on equivalences begun in `logic/equiv/defs.lean`, defining\n\n* canonical isomorphisms between various types: e.g.,\n\n  - `equiv.sum_equiv_sigma_bool` is the canonical equivalence between the sum of two types `α ⊕ β`\n    and the sigma-type `Σ b : bool, cond b α β`;\n\n  - `equiv.prod_sum_distrib : α × (β ⊕ γ) ≃ (α × β) ⊕ (α × γ)` shows that type product and type sum\n    satisfy the distributive law up to a canonical equivalence;\n\n* operations on equivalences: e.g.,\n\n  - `equiv.prod_congr ea eb : α₁ × β₁ ≃ α₂ × β₂`: combine two equivalences `ea : α₁ ≃ α₂` and\n    `eb : β₁ ≃ β₂` using `prod.map`.\n\n  More definitions of this kind can be found in other files. E.g., `data/equiv/transfer_instance`\n  does it for many algebraic type classes like `group`, `module`, etc.\n\n## Tags\n\nequivalence, congruence, bijective map\n-/\n\n\nopen Function\n\nuniverse u v w z\n\nvariable {α : Sort u} {β : Sort v} {γ : Sort w}\n\nnamespace Equiv\n\n#print Equiv.pprodEquivProd /-\n/-- `pprod α β` is equivalent to `α × β` -/\n@[simps apply symm_apply]\ndef pprodEquivProd {α β : Type _} : PProd α β ≃ α × β\n    where\n  toFun x := (x.1, x.2)\n  invFun x := ⟨x.1, x.2⟩\n  left_inv := fun ⟨x, y⟩ => rfl\n  right_inv := fun ⟨x, y⟩ => rfl\n#align equiv.pprod_equiv_prod Equiv.pprodEquivProd\n-/\n\n#print Equiv.pprodCongr /-\n/-- Product of two equivalences, in terms of `pprod`. If `α ≃ β` and `γ ≃ δ`, then\n`pprod α γ ≃ pprod β δ`. -/\n@[congr, simps apply]\ndef pprodCongr {δ : Sort z} (e₁ : α ≃ β) (e₂ : γ ≃ δ) : PProd α γ ≃ PProd β δ\n    where\n  toFun x := ⟨e₁ x.1, e₂ x.2⟩\n  invFun x := ⟨e₁.symm x.1, e₂.symm x.2⟩\n  left_inv := fun ⟨x, y⟩ => by simp\n  right_inv := fun ⟨x, y⟩ => by simp\n#align equiv.pprod_congr Equiv.pprodCongr\n-/\n\n/- warning: equiv.pprod_prod -> Equiv.pprodProd is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Sort.{u1}} {β₁ : Sort.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{u1, succ u3} α₁ α₂) -> (Equiv.{u2, succ u4} β₁ β₂) -> (Equiv.{max 1 u1 u2, max (succ u3) (succ u4)} (PProd.{u1, u2} α₁ β₁) (Prod.{u3, u4} α₂ β₂))\nbut is expected to have type\n  forall {α₁ : Sort.{u1}} {β₁ : Type.{u2}} {α₂ : Sort.{u3}} {β₂ : Type.{u4}}, (Equiv.{u1, succ u2} α₁ β₁) -> (Equiv.{u3, succ u4} α₂ β₂) -> (Equiv.{max (max 1 u3) u1, max (succ u4) (succ u2)} (PProd.{u1, u3} α₁ α₂) (Prod.{u2, u4} β₁ β₂))\nCase conversion may be inaccurate. Consider using '#align equiv.pprod_prod Equiv.pprodProdₓ'. -/\n/-- Combine two equivalences using `pprod` in the domain and `prod` in the codomain. -/\n@[simps apply symm_apply]\ndef pprodProd {α₁ β₁ : Sort _} {α₂ β₂ : Type _} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) :\n    PProd α₁ β₁ ≃ α₂ × β₂ :=\n  (ea.pprodCongr eb).trans pprodEquivProd\n#align equiv.pprod_prod Equiv.pprodProd\n\n/- warning: equiv.prod_pprod -> Equiv.prodPProd is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Sort.{u3}} {β₂ : Sort.{u4}}, (Equiv.{succ u1, u3} α₁ α₂) -> (Equiv.{succ u2, u4} β₁ β₂) -> (Equiv.{max (succ u1) (succ u2), max 1 u3 u4} (Prod.{u1, u2} α₁ β₁) (PProd.{u3, u4} α₂ β₂))\nbut is expected to have type\n  forall {α₁ : Type.{u1}} {β₁ : Sort.{u2}} {α₂ : Type.{u3}} {β₂ : Sort.{u4}}, (Equiv.{succ u1, u2} α₁ β₁) -> (Equiv.{succ u3, u4} α₂ β₂) -> (Equiv.{max (succ u3) (succ u1), max (max 1 u4) u2} (Prod.{u1, u3} α₁ α₂) (PProd.{u2, u4} β₁ β₂))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_pprod Equiv.prodPProdₓ'. -/\n/-- Combine two equivalences using `pprod` in the codomain and `prod` in the domain. -/\n@[simps apply symm_apply]\ndef prodPProd {α₁ β₁ : Type _} {α₂ β₂ : Sort _} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) :\n    α₁ × β₁ ≃ PProd α₂ β₂ :=\n  (ea.symm.pprodProd eb.symm).symm\n#align equiv.prod_pprod Equiv.prodPProd\n\n#print Equiv.pprodEquivProdPLift /-\n/-- `pprod α β` is equivalent to `plift α × plift β` -/\n@[simps apply symm_apply]\ndef pprodEquivProdPLift {α β : Sort _} : PProd α β ≃ PLift α × PLift β :=\n  Equiv.plift.symm.pprodProd Equiv.plift.symm\n#align equiv.pprod_equiv_prod_plift Equiv.pprodEquivProdPLift\n-/\n\n/- warning: equiv.prod_congr -> Equiv.prodCongr is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{succ u1, succ u3} α₁ α₂) -> (Equiv.{succ u2, succ u4} β₁ β₂) -> (Equiv.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Prod.{u1, u2} α₁ β₁) (Prod.{u3, u4} α₂ β₂))\nbut is expected to have type\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{succ u1, succ u2} α₁ β₁) -> (Equiv.{succ u3, succ u4} α₂ β₂) -> (Equiv.{max (succ u3) (succ u1), max (succ u4) (succ u2)} (Prod.{u1, u3} α₁ α₂) (Prod.{u2, u4} β₁ β₂))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr Equiv.prodCongrₓ'. -/\n/-- Product of two equivalences. If `α₁ ≃ α₂` and `β₁ ≃ β₂`, then `α₁ × β₁ ≃ α₂ × β₂`. This is\n`prod.map` as an equivalence. -/\n@[congr, simps (config := { fullyApplied := false }) apply]\ndef prodCongr {α₁ β₁ α₂ β₂ : Type _} (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) : α₁ × β₁ ≃ α₂ × β₂ :=\n  ⟨Prod.map e₁ e₂, Prod.map e₁.symm e₂.symm, fun ⟨a, b⟩ => by simp, fun ⟨a, b⟩ => by simp⟩\n#align equiv.prod_congr Equiv.prodCongr\n\n/- warning: equiv.prod_congr_symm -> Equiv.prodCongr_symm is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}} (e₁ : Equiv.{succ u1, succ u3} α₁ α₂) (e₂ : Equiv.{succ u2, succ u4} β₁ β₂), Eq.{max 1 (max (max (succ u3) (succ u4)) (succ u1) (succ u2)) (max (succ u1) (succ u2)) (succ u3) (succ u4)} (Equiv.{max (succ u3) (succ u4), max (succ u1) (succ u2)} (Prod.{u3, u4} α₂ β₂) (Prod.{u1, u2} α₁ β₁)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Prod.{u1, u2} α₁ β₁) (Prod.{u3, u4} α₂ β₂) (Equiv.prodCongr.{u1, u2, u3, u4} α₁ β₁ α₂ β₂ e₁ e₂)) (Equiv.prodCongr.{u3, u4, u1, u2} α₂ β₂ α₁ β₁ (Equiv.symm.{succ u1, succ u3} α₁ α₂ e₁) (Equiv.symm.{succ u2, succ u4} β₁ β₂ e₂))\nbut is expected to have type\n  forall {α₁ : Type.{u4}} {β₁ : Type.{u3}} {α₂ : Type.{u2}} {β₂ : Type.{u1}} (e₁ : Equiv.{succ u4, succ u3} α₁ β₁) (e₂ : Equiv.{succ u2, succ u1} α₂ β₂), Eq.{max (max (max (succ u1) (succ u2)) (succ u3)) (succ u4)} (Equiv.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Prod.{u3, u1} β₁ β₂) (Prod.{u4, u2} α₁ α₂)) (Equiv.symm.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Prod.{u4, u2} α₁ α₂) (Prod.{u3, u1} β₁ β₂) (Equiv.prodCongr.{u4, u3, u2, u1} α₁ β₁ α₂ β₂ e₁ e₂)) (Equiv.prodCongr.{u3, u4, u1, u2} β₁ α₁ β₂ α₂ (Equiv.symm.{succ u4, succ u3} α₁ β₁ e₁) (Equiv.symm.{succ u2, succ u1} α₂ β₂ e₂))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_symm Equiv.prodCongr_symmₓ'. -/\n@[simp]\ntheorem prodCongr_symm {α₁ β₁ α₂ β₂ : Type _} (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) :\n    (prodCongr e₁ e₂).symm = prodCongr e₁.symm e₂.symm :=\n  rfl\n#align equiv.prod_congr_symm Equiv.prodCongr_symm\n\n#print Equiv.prodComm /-\n/-- Type product is commutative up to an equivalence: `α × β ≃ β × α`. This is `prod.swap` as an\nequivalence.-/\ndef prodComm (α β : Type _) : α × β ≃ β × α :=\n  ⟨Prod.swap, Prod.swap, Prod.swap_swap, Prod.swap_swap⟩\n#align equiv.prod_comm Equiv.prodComm\n-/\n\n/- warning: equiv.coe_prod_comm -> Equiv.coe_prodComm is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) (β : Type.{u2}), Eq.{max (max (succ u1) (succ u2)) (succ u2) (succ u1)} ((Prod.{u1, u2} α β) -> (Prod.{u2, u1} β α)) (coeFn.{max 1 (max (max (succ u1) (succ u2)) (succ u2) (succ u1)) (max (succ u2) (succ u1)) (succ u1) (succ u2), max (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} α β) (Prod.{u2, u1} β α)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} α β) (Prod.{u2, u1} β α)) => (Prod.{u1, u2} α β) -> (Prod.{u2, u1} β α)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} α β) (Prod.{u2, u1} β α)) (Equiv.prodComm.{u1, u2} α β)) (Prod.swap.{u1, u2} α β)\nbut is expected to have type\n  forall (α : Type.{u2}) (β : Type.{u1}), Eq.{max (succ u1) (succ u2)} (forall (ᾰ : Prod.{u2, u1} α β), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Prod.{u1, u2} β α) ᾰ) (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u2, u1} α β) (Prod.{u1, u2} β α)) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Prod.{u1, u2} β α) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} α β) (Prod.{u1, u2} β α)) (Equiv.prodComm.{u2, u1} α β)) (Prod.swap.{u2, u1} α β)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_prod_comm Equiv.coe_prodCommₓ'. -/\n@[simp]\ntheorem coe_prodComm (α β : Type _) : ⇑(prodComm α β) = Prod.swap :=\n  rfl\n#align equiv.coe_prod_comm Equiv.coe_prodComm\n\n/- warning: equiv.prod_comm_apply -> Equiv.prodComm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (x : Prod.{u1, u2} α β), Eq.{max (succ u2) (succ u1)} (Prod.{u2, u1} β α) (coeFn.{max 1 (max (max (succ u1) (succ u2)) (succ u2) (succ u1)) (max (succ u2) (succ u1)) (succ u1) (succ u2), max (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} α β) (Prod.{u2, u1} β α)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} α β) (Prod.{u2, u1} β α)) => (Prod.{u1, u2} α β) -> (Prod.{u2, u1} β α)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} α β) (Prod.{u2, u1} β α)) (Equiv.prodComm.{u1, u2} α β) x) (Prod.swap.{u1, u2} α β x)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (x : Prod.{u2, u1} α β), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Prod.{u1, u2} β α) x) (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u2, u1} α β) (Prod.{u1, u2} β α)) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Prod.{u1, u2} β α) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} α β) (Prod.{u1, u2} β α)) (Equiv.prodComm.{u2, u1} α β) x) (Prod.swap.{u2, u1} α β x)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comm_apply Equiv.prodComm_applyₓ'. -/\n@[simp]\ntheorem prodComm_apply {α β : Type _} (x : α × β) : prodComm α β x = x.symm :=\n  rfl\n#align equiv.prod_comm_apply Equiv.prodComm_apply\n\n/- warning: equiv.prod_comm_symm -> Equiv.prodComm_symm is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) (β : Type.{u2}), Eq.{max 1 (max (max (succ u2) (succ u1)) (succ u1) (succ u2)) (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (Prod.{u2, u1} β α) (Prod.{u1, u2} α β)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} α β) (Prod.{u2, u1} β α) (Equiv.prodComm.{u1, u2} α β)) (Equiv.prodComm.{u2, u1} β α)\nbut is expected to have type\n  forall (α : Type.{u2}) (β : Type.{u1}), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} β α) (Prod.{u2, u1} α β)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} α β) (Prod.{u1, u2} β α) (Equiv.prodComm.{u2, u1} α β)) (Equiv.prodComm.{u1, u2} β α)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comm_symm Equiv.prodComm_symmₓ'. -/\n@[simp]\ntheorem prodComm_symm (α β) : (prodComm α β).symm = prodComm β α :=\n  rfl\n#align equiv.prod_comm_symm Equiv.prodComm_symm\n\n#print Equiv.prodAssoc /-\n/-- Type product is associative up to an equivalence. -/\n@[simps]\ndef prodAssoc (α β γ : Sort _) : (α × β) × γ ≃ α × β × γ :=\n  ⟨fun p => (p.1.1, p.1.2, p.2), fun p => ((p.1, p.2.1), p.2.2), fun ⟨⟨a, b⟩, c⟩ => rfl,\n    fun ⟨a, ⟨b, c⟩⟩ => rfl⟩\n#align equiv.prod_assoc Equiv.prodAssoc\n-/\n\n#print Equiv.curry /-\n/-- Functions on `α × β` are equivalent to functions `α → β → γ`. -/\n@[simps (config := { fullyApplied := false })]\ndef curry (α β γ : Type _) : (α × β → γ) ≃ (α → β → γ)\n    where\n  toFun := curry\n  invFun := uncurry\n  left_inv := uncurry_curry\n  right_inv := curry_uncurry\n#align equiv.curry Equiv.curry\n-/\n\nsection\n\n/- warning: equiv.prod_punit -> Equiv.prodPUnit is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u2}), Equiv.{max (succ u2) (succ u1), succ u2} (Prod.{u2, u1} α PUnit.{succ u1}) α\nbut is expected to have type\n  forall (α : Type.{u1}), Equiv.{max (succ u2) (succ u1), succ u1} (Prod.{u1, u2} α PUnit.{succ u2}) α\nCase conversion may be inaccurate. Consider using '#align equiv.prod_punit Equiv.prodPUnitₓ'. -/\n/-- `punit` is a right identity for type product up to an equivalence. -/\n@[simps]\ndef prodPUnit (α : Type _) : α × PUnit.{u + 1} ≃ α :=\n  ⟨fun p => p.1, fun a => (a, PUnit.unit), fun ⟨_, PUnit.unit⟩ => rfl, fun a => rfl⟩\n#align equiv.prod_punit Equiv.prodPUnit\n\n/- warning: equiv.punit_prod -> Equiv.punitProd is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u2}), Equiv.{max (succ u1) (succ u2), succ u2} (Prod.{u1, u2} PUnit.{succ u1} α) α\nbut is expected to have type\n  forall (α : Type.{u1}), Equiv.{max (succ u1) (succ u2), succ u1} (Prod.{u2, u1} PUnit.{succ u2} α) α\nCase conversion may be inaccurate. Consider using '#align equiv.punit_prod Equiv.punitProdₓ'. -/\n/-- `punit` is a left identity for type product up to an equivalence. -/\n@[simps]\ndef punitProd (α : Type _) : PUnit.{u + 1} × α ≃ α :=\n  calc\n    PUnit × α ≃ α × PUnit := prodComm _ _\n    _ ≃ α := prodPUnit _\n    \n#align equiv.punit_prod Equiv.punitProd\n\n/- warning: equiv.prod_unique -> Equiv.prodUnique is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u_1}) (β : Type.{u_2}) [_inst_1 : Unique.{succ u_2} β], Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α\nbut is expected to have type\n  forall (α : Type.{u_1}) (β : Type.{u_2}) [_inst_1 : Unique.{succ u_2} β], Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_1, u_2} α β) α\nCase conversion may be inaccurate. Consider using '#align equiv.prod_unique Equiv.prodUniqueₓ'. -/\n/-- Any `unique` type is a right identity for type product up to equivalence. -/\ndef prodUnique (α β : Type _) [Unique β] : α × β ≃ α :=\n  ((Equiv.refl α).prodCongr <| equivPUnit β).trans <| prodPUnit α\n#align equiv.prod_unique Equiv.prodUnique\n\n/- warning: equiv.coe_prod_unique -> Equiv.coe_prodUnique is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_2} β], Eq.{max (succ u_1) (succ u_2)} ((Prod.{u_1, u_2} α β) -> α) (coeFn.{max 1 (succ u_1) (succ u_2), max (succ u_1) (succ u_2)} (Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α) (fun (_x : Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α) => (Prod.{u_1, u_2} α β) -> α) (Equiv.hasCoeToFun.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α) (Equiv.prodUnique.{u_1, u_2, u_3} α β _inst_1)) (Prod.fst.{u_1, u_2} α β)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_1} α], Eq.{max (succ u_1) (succ u_2)} (forall (ᾰ : Prod.{u_2, u_1} β α), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} β α) => β) ᾰ) (FunLike.coe.{max (succ u_1) (succ u_2), max (succ u_1) (succ u_2), succ u_2} (Equiv.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} β α) β) (Prod.{u_2, u_1} β α) (fun (_x : Prod.{u_2, u_1} β α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} β α) => β) _x) (Equiv.instFunLikeEquiv.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} β α) β) (Equiv.prodUnique.{u_2, u_1} β α _inst_1)) (Prod.fst.{u_2, u_1} β α)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_prod_unique Equiv.coe_prodUniqueₓ'. -/\n@[simp]\ntheorem coe_prodUnique {α β : Type _} [Unique β] : ⇑(prodUnique α β) = Prod.fst :=\n  rfl\n#align equiv.coe_prod_unique Equiv.coe_prodUnique\n\n/- warning: equiv.prod_unique_apply -> Equiv.prodUnique_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_2} β] (x : Prod.{u_1, u_2} α β), Eq.{succ u_1} α (coeFn.{max 1 (succ u_1) (succ u_2), max (succ u_1) (succ u_2)} (Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α) (fun (_x : Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α) => (Prod.{u_1, u_2} α β) -> α) (Equiv.hasCoeToFun.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α) (Equiv.prodUnique.{u_1, u_2, u_3} α β _inst_1) x) (Prod.fst.{u_1, u_2} α β x)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_1} α] (x : Prod.{u_2, u_1} β α), Eq.{succ u_2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} β α) => β) x) (FunLike.coe.{max (succ u_1) (succ u_2), max (succ u_1) (succ u_2), succ u_2} (Equiv.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} β α) β) (Prod.{u_2, u_1} β α) (fun (_x : Prod.{u_2, u_1} β α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} β α) => β) _x) (Equiv.instFunLikeEquiv.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} β α) β) (Equiv.prodUnique.{u_2, u_1} β α _inst_1) x) (Prod.fst.{u_2, u_1} β α x)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_unique_apply Equiv.prodUnique_applyₓ'. -/\ntheorem prodUnique_apply {α β : Type _} [Unique β] (x : α × β) : prodUnique α β x = x.1 :=\n  rfl\n#align equiv.prod_unique_apply Equiv.prodUnique_apply\n\n/- warning: equiv.prod_unique_symm_apply -> Equiv.prodUnique_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_2} β] (x : α), Eq.{max (succ u_1) (succ u_2)} (Prod.{u_1, u_2} α β) (coeFn.{max 1 (succ u_1) (succ u_2), max (succ u_1) (succ u_2)} (Equiv.{succ u_1, max (succ u_1) (succ u_2)} α (Prod.{u_1, u_2} α β)) (fun (_x : Equiv.{succ u_1, max (succ u_1) (succ u_2)} α (Prod.{u_1, u_2} α β)) => α -> (Prod.{u_1, u_2} α β)) (Equiv.hasCoeToFun.{succ u_1, max (succ u_1) (succ u_2)} α (Prod.{u_1, u_2} α β)) (Equiv.symm.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} α β) α (Equiv.prodUnique.{u_1, u_2, u_3} α β _inst_1)) x) (Prod.mk.{u_1, u_2} α β x (Inhabited.default.{succ u_2} β (Unique.inhabited.{succ u_2} β _inst_1)))\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_1} α] (x : β), Eq.{max (succ u_1) (succ u_2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => Prod.{u_2, u_1} β α) x) (FunLike.coe.{max (succ u_1) (succ u_2), succ u_2, max (succ u_1) (succ u_2)} (Equiv.{succ u_2, max (succ u_1) (succ u_2)} β (Prod.{u_2, u_1} β α)) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => Prod.{u_2, u_1} β α) _x) (Equiv.instFunLikeEquiv.{succ u_2, max (succ u_1) (succ u_2)} β (Prod.{u_2, u_1} β α)) (Equiv.symm.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} β α) β (Equiv.prodUnique.{u_2, u_1} β α _inst_1)) x) (Prod.mk.{u_2, u_1} β α x (Inhabited.default.{succ u_1} α (Unique.instInhabited.{succ u_1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_unique_symm_apply Equiv.prodUnique_symm_applyₓ'. -/\n@[simp]\ntheorem prodUnique_symm_apply {α β : Type _} [Unique β] (x : α) :\n    (prodUnique α β).symm x = (x, default) :=\n  rfl\n#align equiv.prod_unique_symm_apply Equiv.prodUnique_symm_apply\n\n/- warning: equiv.unique_prod -> Equiv.uniqueProd is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u_1}) (β : Type.{u_2}) [_inst_1 : Unique.{succ u_2} β], Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α\nbut is expected to have type\n  forall (α : Type.{u_1}) (β : Type.{u_2}) [_inst_1 : Unique.{succ u_2} β], Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_2, u_1} β α) α\nCase conversion may be inaccurate. Consider using '#align equiv.unique_prod Equiv.uniqueProdₓ'. -/\n/-- Any `unique` type is a left identity for type product up to equivalence. -/\ndef uniqueProd (α β : Type _) [Unique β] : β × α ≃ α :=\n  ((equivPUnit β).prodCongr <| Equiv.refl α).trans <| punitProd α\n#align equiv.unique_prod Equiv.uniqueProd\n\n/- warning: equiv.coe_unique_prod -> Equiv.coe_uniqueProd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_2} β], Eq.{max (succ u_2) (succ u_1)} ((Prod.{u_2, u_1} β α) -> α) (coeFn.{max 1 (succ u_2) (succ u_1), max (succ u_2) (succ u_1)} (Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α) (fun (_x : Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α) => (Prod.{u_2, u_1} β α) -> α) (Equiv.hasCoeToFun.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α) (Equiv.uniqueProd.{u_1, u_2, u_3} α β _inst_1)) (Prod.snd.{u_2, u_1} β α)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_1} α], Eq.{max (succ u_2) (succ u_1)} (forall (ᾰ : Prod.{u_1, u_2} α β), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} α β) => β) ᾰ) (FunLike.coe.{max (succ u_2) (succ u_1), max (succ u_2) (succ u_1), succ u_2} (Equiv.{max (succ u_2) (succ u_1), succ u_2} (Prod.{u_1, u_2} α β) β) (Prod.{u_1, u_2} α β) (fun (_x : Prod.{u_1, u_2} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} α β) => β) _x) (Equiv.instFunLikeEquiv.{max (succ u_2) (succ u_1), succ u_2} (Prod.{u_1, u_2} α β) β) (Equiv.uniqueProd.{u_2, u_1} β α _inst_1)) (Prod.snd.{u_1, u_2} α β)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_unique_prod Equiv.coe_uniqueProdₓ'. -/\n@[simp]\ntheorem coe_uniqueProd {α β : Type _} [Unique β] : ⇑(uniqueProd α β) = Prod.snd :=\n  rfl\n#align equiv.coe_unique_prod Equiv.coe_uniqueProd\n\n/- warning: equiv.unique_prod_apply -> Equiv.uniqueProd_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_2} β] (x : Prod.{u_2, u_1} β α), Eq.{succ u_1} α (coeFn.{max 1 (succ u_2) (succ u_1), max (succ u_2) (succ u_1)} (Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α) (fun (_x : Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α) => (Prod.{u_2, u_1} β α) -> α) (Equiv.hasCoeToFun.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α) (Equiv.uniqueProd.{u_1, u_2, u_3} α β _inst_1) x) (Prod.snd.{u_2, u_1} β α x)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_1} α] (x : Prod.{u_1, u_2} α β), Eq.{succ u_2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} α β) => β) x) (FunLike.coe.{max (succ u_2) (succ u_1), max (succ u_2) (succ u_1), succ u_2} (Equiv.{max (succ u_2) (succ u_1), succ u_2} (Prod.{u_1, u_2} α β) β) (Prod.{u_1, u_2} α β) (fun (_x : Prod.{u_1, u_2} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} α β) => β) _x) (Equiv.instFunLikeEquiv.{max (succ u_2) (succ u_1), succ u_2} (Prod.{u_1, u_2} α β) β) (Equiv.uniqueProd.{u_2, u_1} β α _inst_1) x) (Prod.snd.{u_1, u_2} α β x)\nCase conversion may be inaccurate. Consider using '#align equiv.unique_prod_apply Equiv.uniqueProd_applyₓ'. -/\ntheorem uniqueProd_apply {α β : Type _} [Unique β] (x : β × α) : uniqueProd α β x = x.2 :=\n  rfl\n#align equiv.unique_prod_apply Equiv.uniqueProd_apply\n\n/- warning: equiv.unique_prod_symm_apply -> Equiv.uniqueProd_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_2} β] (x : α), Eq.{max (succ u_2) (succ u_1)} (Prod.{u_2, u_1} β α) (coeFn.{max 1 (succ u_2) (succ u_1), max (succ u_2) (succ u_1)} (Equiv.{succ u_1, max (succ u_2) (succ u_1)} α (Prod.{u_2, u_1} β α)) (fun (_x : Equiv.{succ u_1, max (succ u_2) (succ u_1)} α (Prod.{u_2, u_1} β α)) => α -> (Prod.{u_2, u_1} β α)) (Equiv.hasCoeToFun.{succ u_1, max (succ u_2) (succ u_1)} α (Prod.{u_2, u_1} β α)) (Equiv.symm.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} β α) α (Equiv.uniqueProd.{u_1, u_2, u_3} α β _inst_1)) x) (Prod.mk.{u_2, u_1} β α (Inhabited.default.{succ u_2} β (Unique.inhabited.{succ u_2} β _inst_1)) x)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : Unique.{succ u_1} α] (x : β), Eq.{max (succ u_1) (succ u_2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => Prod.{u_1, u_2} α β) x) (FunLike.coe.{max (succ u_1) (succ u_2), succ u_2, max (succ u_1) (succ u_2)} (Equiv.{succ u_2, max (succ u_1) (succ u_2)} β (Prod.{u_1, u_2} α β)) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => Prod.{u_1, u_2} α β) _x) (Equiv.instFunLikeEquiv.{succ u_2, max (succ u_1) (succ u_2)} β (Prod.{u_1, u_2} α β)) (Equiv.symm.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_1, u_2} α β) β (Equiv.uniqueProd.{u_2, u_1} β α _inst_1)) x) (Prod.mk.{u_1, u_2} α β (Inhabited.default.{succ u_1} α (Unique.instInhabited.{succ u_1} α _inst_1)) x)\nCase conversion may be inaccurate. Consider using '#align equiv.unique_prod_symm_apply Equiv.uniqueProd_symm_applyₓ'. -/\n@[simp]\ntheorem uniqueProd_symm_apply {α β : Type _} [Unique β] (x : α) :\n    (uniqueProd α β).symm x = (default, x) :=\n  rfl\n#align equiv.unique_prod_symm_apply Equiv.uniqueProd_symm_apply\n\n#print Equiv.prodEmpty /-\n/-- `empty` type is a right absorbing element for type product up to an equivalence. -/\ndef prodEmpty (α : Type _) : α × Empty ≃ Empty :=\n  equivEmpty _\n#align equiv.prod_empty Equiv.prodEmpty\n-/\n\n#print Equiv.emptyProd /-\n/-- `empty` type is a left absorbing element for type product up to an equivalence. -/\ndef emptyProd (α : Type _) : Empty × α ≃ Empty :=\n  equivEmpty _\n#align equiv.empty_prod Equiv.emptyProd\n-/\n\n#print Equiv.prodPEmpty /-\n/-- `pempty` type is a right absorbing element for type product up to an equivalence. -/\ndef prodPEmpty (α : Type _) : α × PEmpty ≃ PEmpty :=\n  equivPEmpty _\n#align equiv.prod_pempty Equiv.prodPEmpty\n-/\n\n#print Equiv.pemptyProd /-\n/-- `pempty` type is a left absorbing element for type product up to an equivalence. -/\ndef pemptyProd (α : Type _) : PEmpty × α ≃ PEmpty :=\n  equivPEmpty _\n#align equiv.pempty_prod Equiv.pemptyProd\n-/\n\nend\n\nsection\n\nopen Sum\n\n#print Equiv.psumEquivSum /-\n/-- `psum` is equivalent to `sum`. -/\ndef psumEquivSum (α β : Type _) : PSum α β ≃ Sum α β\n    where\n  toFun s := PSum.casesOn s inl inr\n  invFun := Sum.elim PSum.inl PSum.inr\n  left_inv s := by cases s <;> rfl\n  right_inv s := by cases s <;> rfl\n#align equiv.psum_equiv_sum Equiv.psumEquivSum\n-/\n\n/- warning: equiv.sum_congr -> Equiv.sumCongr is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{succ u1, succ u3} α₁ α₂) -> (Equiv.{succ u2, succ u4} β₁ β₂) -> (Equiv.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} α₁ β₁) (Sum.{u3, u4} α₂ β₂))\nbut is expected to have type\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{succ u1, succ u2} α₁ β₁) -> (Equiv.{succ u3, succ u4} α₂ β₂) -> (Equiv.{max (succ u3) (succ u1), max (succ u4) (succ u2)} (Sum.{u1, u3} α₁ α₂) (Sum.{u2, u4} β₁ β₂))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr Equiv.sumCongrₓ'. -/\n/-- If `α ≃ α'` and `β ≃ β'`, then `α ⊕ β ≃ α' ⊕ β'`. This is `sum.map` as an equivalence. -/\n@[simps apply]\ndef sumCongr {α₁ β₁ α₂ β₂ : Type _} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) : Sum α₁ β₁ ≃ Sum α₂ β₂ :=\n  ⟨Sum.map ea eb, Sum.map ea.symm eb.symm, fun x => by simp, fun x => by simp⟩\n#align equiv.sum_congr Equiv.sumCongr\n\n#print Equiv.psumCongr /-\n/-- If `α ≃ α'` and `β ≃ β'`, then `psum α β ≃ psum α' β'`. -/\ndef psumCongr {δ : Sort z} (e₁ : α ≃ β) (e₂ : γ ≃ δ) : PSum α γ ≃ PSum β δ\n    where\n  toFun x := PSum.casesOn x (PSum.inl ∘ e₁) (PSum.inr ∘ e₂)\n  invFun x := PSum.casesOn x (PSum.inl ∘ e₁.symm) (PSum.inr ∘ e₂.symm)\n  left_inv := by rintro (x | x) <;> simp\n  right_inv := by rintro (x | x) <;> simp\n#align equiv.psum_congr Equiv.psumCongr\n-/\n\n/- warning: equiv.psum_sum -> Equiv.psumSum is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Sort.{u1}} {β₁ : Sort.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{u1, succ u3} α₁ α₂) -> (Equiv.{u2, succ u4} β₁ β₂) -> (Equiv.{max 1 u1 u2, max (succ u3) (succ u4)} (PSum.{u1, u2} α₁ β₁) (Sum.{u3, u4} α₂ β₂))\nbut is expected to have type\n  forall {α₁ : Sort.{u1}} {β₁ : Type.{u2}} {α₂ : Sort.{u3}} {β₂ : Type.{u4}}, (Equiv.{u1, succ u2} α₁ β₁) -> (Equiv.{u3, succ u4} α₂ β₂) -> (Equiv.{max (max 1 u3) u1, max (succ u4) (succ u2)} (PSum.{u1, u3} α₁ α₂) (Sum.{u2, u4} β₁ β₂))\nCase conversion may be inaccurate. Consider using '#align equiv.psum_sum Equiv.psumSumₓ'. -/\n/-- Combine two `equiv`s using `psum` in the domain and `sum` in the codomain. -/\ndef psumSum {α₁ β₁ : Sort _} {α₂ β₂ : Type _} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) :\n    PSum α₁ β₁ ≃ Sum α₂ β₂ :=\n  (ea.psumCongr eb).trans (psumEquivSum _ _)\n#align equiv.psum_sum Equiv.psumSum\n\n/- warning: equiv.sum_psum -> Equiv.sumPSum is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Sort.{u3}} {β₂ : Sort.{u4}}, (Equiv.{succ u1, u3} α₁ α₂) -> (Equiv.{succ u2, u4} β₁ β₂) -> (Equiv.{max (succ u1) (succ u2), max 1 u3 u4} (Sum.{u1, u2} α₁ β₁) (PSum.{u3, u4} α₂ β₂))\nbut is expected to have type\n  forall {α₁ : Type.{u1}} {β₁ : Sort.{u2}} {α₂ : Type.{u3}} {β₂ : Sort.{u4}}, (Equiv.{succ u1, u2} α₁ β₁) -> (Equiv.{succ u3, u4} α₂ β₂) -> (Equiv.{max (succ u3) (succ u1), max (max 1 u4) u2} (Sum.{u1, u3} α₁ α₂) (PSum.{u2, u4} β₁ β₂))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_psum Equiv.sumPSumₓ'. -/\n/-- Combine two `equiv`s using `sum` in the domain and `psum` in the codomain. -/\ndef sumPSum {α₁ β₁ : Type _} {α₂ β₂ : Sort _} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) :\n    Sum α₁ β₁ ≃ PSum α₂ β₂ :=\n  (ea.symm.psumSum eb.symm).symm\n#align equiv.sum_psum Equiv.sumPSum\n\n/- warning: equiv.sum_congr_trans -> Equiv.sumCongr_trans is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {α₂ : Type.{u2}} {β₁ : Type.{u3}} {β₂ : Type.{u4}} {γ₁ : Type.{u5}} {γ₂ : Type.{u6}} (e : Equiv.{succ u1, succ u3} α₁ β₁) (f : Equiv.{succ u2, succ u4} α₂ β₂) (g : Equiv.{succ u3, succ u5} β₁ γ₁) (h : Equiv.{succ u4, succ u6} β₂ γ₂), Eq.{max 1 (max (max (succ u1) (succ u2)) (succ u5) (succ u6)) (max (succ u5) (succ u6)) (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u5) (succ u6)} (Sum.{u1, u2} α₁ α₂) (Sum.{u5, u6} γ₁ γ₂)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u3) (succ u4), max (succ u5) (succ u6)} (Sum.{u1, u2} α₁ α₂) (Sum.{u3, u4} β₁ β₂) (Sum.{u5, u6} γ₁ γ₂) (Equiv.sumCongr.{u1, u2, u3, u4} α₁ α₂ β₁ β₂ e f) (Equiv.sumCongr.{u3, u4, u5, u6} β₁ β₂ γ₁ γ₂ g h)) (Equiv.sumCongr.{u1, u2, u5, u6} α₁ α₂ γ₁ γ₂ (Equiv.trans.{succ u1, succ u3, succ u5} α₁ β₁ γ₁ e g) (Equiv.trans.{succ u2, succ u4, succ u6} α₂ β₂ γ₂ f h))\nbut is expected to have type\n  forall {α₁ : Type.{u6}} {α₂ : Type.{u5}} {β₁ : Type.{u4}} {β₂ : Type.{u3}} {γ₁ : Type.{u2}} {γ₂ : Type.{u1}} (e : Equiv.{succ u6, succ u5} α₁ α₂) (f : Equiv.{succ u4, succ u3} β₁ β₂) (g : Equiv.{succ u5, succ u2} α₂ γ₁) (h : Equiv.{succ u3, succ u1} β₂ γ₂), Eq.{max (max (max (succ u4) (succ u6)) (succ u1)) (succ u2)} (Equiv.{max (succ u4) (succ u6), max (succ u1) (succ u2)} (Sum.{u6, u4} α₁ β₁) (Sum.{u2, u1} γ₁ γ₂)) (Equiv.trans.{max (succ u4) (succ u6), max (succ u3) (succ u5), max (succ u1) (succ u2)} (Sum.{u6, u4} α₁ β₁) (Sum.{u5, u3} α₂ β₂) (Sum.{u2, u1} γ₁ γ₂) (Equiv.sumCongr.{u6, u5, u4, u3} α₁ α₂ β₁ β₂ e f) (Equiv.sumCongr.{u5, u2, u3, u1} α₂ γ₁ β₂ γ₂ g h)) (Equiv.sumCongr.{u6, u2, u4, u1} α₁ γ₁ β₁ γ₂ (Equiv.trans.{succ u6, succ u5, succ u2} α₁ α₂ γ₁ e g) (Equiv.trans.{succ u4, succ u3, succ u1} β₁ β₂ γ₂ f h))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr_trans Equiv.sumCongr_transₓ'. -/\n@[simp]\ntheorem sumCongr_trans {α₁ α₂ β₁ β₂ γ₁ γ₂ : Sort _} (e : α₁ ≃ β₁) (f : α₂ ≃ β₂) (g : β₁ ≃ γ₁)\n    (h : β₂ ≃ γ₂) :\n    (Equiv.sumCongr e f).trans (Equiv.sumCongr g h) = Equiv.sumCongr (e.trans g) (f.trans h) :=\n  by\n  ext i\n  cases i <;> rfl\n#align equiv.sum_congr_trans Equiv.sumCongr_trans\n\n/- warning: equiv.sum_congr_symm -> Equiv.sumCongr_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (e : Equiv.{succ u1, succ u2} α β) (f : Equiv.{succ u3, succ u4} γ δ), Eq.{max 1 (max (max (succ u2) (succ u4)) (succ u1) (succ u3)) (max (succ u1) (succ u3)) (succ u2) (succ u4)} (Equiv.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Sum.{u2, u4} β δ) (Sum.{u1, u3} α γ)) (Equiv.symm.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u1, u3} α γ) (Sum.{u2, u4} β δ) (Equiv.sumCongr.{u1, u3, u2, u4} α γ β δ e f)) (Equiv.sumCongr.{u2, u4, u1, u3} β δ α γ (Equiv.symm.{succ u1, succ u2} α β e) (Equiv.symm.{succ u3, succ u4} γ δ f))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u3}} {γ : Type.{u2}} {δ : Type.{u1}} (e : Equiv.{succ u4, succ u3} α β) (f : Equiv.{succ u2, succ u1} γ δ), Eq.{max (max (max (succ u1) (succ u2)) (succ u3)) (succ u4)} (Equiv.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u3, u1} β δ) (Sum.{u4, u2} α γ)) (Equiv.symm.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Sum.{u4, u2} α γ) (Sum.{u3, u1} β δ) (Equiv.sumCongr.{u4, u3, u2, u1} α β γ δ e f)) (Equiv.sumCongr.{u3, u4, u1, u2} β α δ γ (Equiv.symm.{succ u4, succ u3} α β e) (Equiv.symm.{succ u2, succ u1} γ δ f))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr_symm Equiv.sumCongr_symmₓ'. -/\n@[simp]\ntheorem sumCongr_symm {α β γ δ : Sort _} (e : α ≃ β) (f : γ ≃ δ) :\n    (Equiv.sumCongr e f).symm = Equiv.sumCongr e.symm f.symm :=\n  rfl\n#align equiv.sum_congr_symm Equiv.sumCongr_symm\n\n/- warning: equiv.sum_congr_refl -> Equiv.sumCongr_refl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}}, Eq.{max 1 (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (Equiv.sumCongr.{u1, u2, u1, u2} α β α β (Equiv.refl.{succ u1} α) (Equiv.refl.{succ u2} β)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}}, Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (Sum.{u2, u1} α β)) (Equiv.sumCongr.{u2, u2, u1, u1} α α β β (Equiv.refl.{succ u2} α) (Equiv.refl.{succ u1} β)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr_refl Equiv.sumCongr_reflₓ'. -/\n@[simp]\ntheorem sumCongr_refl {α β : Sort _} :\n    Equiv.sumCongr (Equiv.refl α) (Equiv.refl β) = Equiv.refl (Sum α β) :=\n  by\n  ext i\n  cases i <;> rfl\n#align equiv.sum_congr_refl Equiv.sumCongr_refl\n\nnamespace Perm\n\n#print Equiv.Perm.sumCongr /-\n/-- Combine a permutation of `α` and of `β` into a permutation of `α ⊕ β`. -/\n@[reducible]\ndef sumCongr {α β : Type _} (ea : Equiv.Perm α) (eb : Equiv.Perm β) : Equiv.Perm (Sum α β) :=\n  Equiv.sumCongr ea eb\n#align equiv.perm.sum_congr Equiv.Perm.sumCongr\n-/\n\n/- warning: equiv.perm.sum_congr_apply -> Equiv.Perm.sumCongr_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (ea : Equiv.Perm.{succ u1} α) (eb : Equiv.Perm.{succ u2} β) (x : Sum.{u1, u2} α β), Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) => (Sum.{u1, u2} α β) -> (Sum.{u1, u2} α β)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (Equiv.Perm.sumCongr.{u1, u2} α β ea eb) x) (Sum.map.{u1, u2, u1, u2} α α β β (coeFn.{succ u1, succ u1} (Equiv.Perm.{succ u1} α) (fun (_x : Equiv.{succ u1, succ u1} α α) => α -> α) (Equiv.hasCoeToFun.{succ u1, succ u1} α α) ea) (coeFn.{succ u2, succ u2} (Equiv.Perm.{succ u2} β) (fun (_x : Equiv.{succ u2, succ u2} β β) => β -> β) (Equiv.hasCoeToFun.{succ u2, succ u2} β β) eb) x)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (ea : Equiv.Perm.{succ u2} α) (eb : Equiv.Perm.{succ u1} β) (x : Sum.{u2, u1} α β), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α β) => Sum.{u2, u1} α β) x) (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β)) (Sum.{u2, u1} α β) (fun (_x : Sum.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α β) => Sum.{u2, u1} α β) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (Sum.{u2, u1} α β)) (Equiv.Perm.sumCongr.{u2, u1} α β ea eb) x) (Sum.map.{u2, u1, u2, u1} α α β β (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.Perm.{succ u2} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} α α) ea) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.Perm.{succ u1} β) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} β β) eb) x)\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_apply Equiv.Perm.sumCongr_applyₓ'. -/\n@[simp]\ntheorem sumCongr_apply {α β : Type _} (ea : Equiv.Perm α) (eb : Equiv.Perm β) (x : Sum α β) :\n    sumCongr ea eb x = Sum.map (⇑ea) (⇑eb) x :=\n  Equiv.sumCongr_apply ea eb x\n#align equiv.perm.sum_congr_apply Equiv.Perm.sumCongr_apply\n\n/- warning: equiv.perm.sum_congr_trans -> Equiv.Perm.sumCongr_trans is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (e : Equiv.Perm.{succ u1} α) (f : Equiv.Perm.{succ u2} β) (g : Equiv.Perm.{succ u1} α) (h : Equiv.Perm.{succ u2} β), Eq.{max 1 (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Equiv.Perm.sumCongr.{u1, u2} α β e f) (Equiv.Perm.sumCongr.{u1, u2} α β g h)) (Equiv.Perm.sumCongr.{u1, u2} α β (Equiv.trans.{succ u1, succ u1, succ u1} α α α e g) (Equiv.trans.{succ u2, succ u2, succ u2} β β β f h))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (e : Equiv.Perm.{succ u2} α) (f : Equiv.Perm.{succ u1} β) (g : Equiv.Perm.{succ u2} α) (h : Equiv.Perm.{succ u1} β), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (Sum.{u2, u1} α β)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (Sum.{u2, u1} α β) (Sum.{u2, u1} α β) (Equiv.Perm.sumCongr.{u2, u1} α β e f) (Equiv.Perm.sumCongr.{u2, u1} α β g h)) (Equiv.Perm.sumCongr.{u2, u1} α β (Equiv.trans.{succ u2, succ u2, succ u2} α α α e g) (Equiv.trans.{succ u1, succ u1, succ u1} β β β f h))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_trans Equiv.Perm.sumCongr_transₓ'. -/\n@[simp]\ntheorem sumCongr_trans {α β : Sort _} (e : Equiv.Perm α) (f : Equiv.Perm β) (g : Equiv.Perm α)\n    (h : Equiv.Perm β) : (sumCongr e f).trans (sumCongr g h) = sumCongr (e.trans g) (f.trans h) :=\n  Equiv.sumCongr_trans e f g h\n#align equiv.perm.sum_congr_trans Equiv.Perm.sumCongr_trans\n\n/- warning: equiv.perm.sum_congr_symm -> Equiv.Perm.sumCongr_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (e : Equiv.Perm.{succ u1} α) (f : Equiv.Perm.{succ u2} β), Eq.{max 1 (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Equiv.Perm.sumCongr.{u1, u2} α β e f)) (Equiv.Perm.sumCongr.{u1, u2} α β (Equiv.symm.{succ u1, succ u1} α α e) (Equiv.symm.{succ u2, succ u2} β β f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (e : Equiv.Perm.{succ u2} α) (f : Equiv.Perm.{succ u1} β), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (Sum.{u2, u1} α β)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (Sum.{u2, u1} α β) (Equiv.Perm.sumCongr.{u2, u1} α β e f)) (Equiv.Perm.sumCongr.{u2, u1} α β (Equiv.symm.{succ u2, succ u2} α α e) (Equiv.symm.{succ u1, succ u1} β β f))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_symm Equiv.Perm.sumCongr_symmₓ'. -/\n@[simp]\ntheorem sumCongr_symm {α β : Sort _} (e : Equiv.Perm α) (f : Equiv.Perm β) :\n    (sumCongr e f).symm = sumCongr e.symm f.symm :=\n  Equiv.sumCongr_symm e f\n#align equiv.perm.sum_congr_symm Equiv.Perm.sumCongr_symm\n\n/- warning: equiv.perm.sum_congr_refl -> Equiv.Perm.sumCongr_refl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}}, Eq.{max 1 (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)) (Equiv.Perm.sumCongr.{u1, u2} α β (Equiv.refl.{succ u1} α) (Equiv.refl.{succ u2} β)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}}, Eq.{max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β)) (Equiv.Perm.sumCongr.{u2, u1} α β (Equiv.refl.{succ u2} α) (Equiv.refl.{succ u1} β)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_refl Equiv.Perm.sumCongr_reflₓ'. -/\n@[simp]\ntheorem sumCongr_refl {α β : Sort _} :\n    sumCongr (Equiv.refl α) (Equiv.refl β) = Equiv.refl (Sum α β) :=\n  Equiv.sumCongr_refl\n#align equiv.perm.sum_congr_refl Equiv.Perm.sumCongr_refl\n\nend Perm\n\n#print Equiv.boolEquivPUnitSumPUnit /-\n/-- `bool` is equivalent the sum of two `punit`s. -/\ndef boolEquivPUnitSumPUnit : Bool ≃ Sum PUnit.{u + 1} PUnit.{v + 1} :=\n  ⟨fun b => cond b (inr PUnit.unit) (inl PUnit.unit), Sum.elim (fun _ => false) fun _ => true,\n    fun b => by cases b <;> rfl, fun s => by rcases s with (⟨⟨⟩⟩ | ⟨⟨⟩⟩) <;> rfl⟩\n#align equiv.bool_equiv_punit_sum_punit Equiv.boolEquivPUnitSumPUnit\n-/\n\n#print Equiv.sumComm /-\n/-- Sum of types is commutative up to an equivalence. This is `sum.swap` as an equivalence. -/\n@[simps (config := { fullyApplied := false }) apply]\ndef sumComm (α β : Type _) : Sum α β ≃ Sum β α :=\n  ⟨Sum.swap, Sum.swap, Sum.swap_swap, Sum.swap_swap⟩\n#align equiv.sum_comm Equiv.sumComm\n-/\n\n/- warning: equiv.sum_comm_symm -> Equiv.sumComm_symm is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) (β : Type.{u2}), Eq.{max 1 (max (max (succ u2) (succ u1)) (succ u1) (succ u2)) (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (Sum.{u2, u1} β α) (Sum.{u1, u2} α β)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Sum.{u1, u2} α β) (Sum.{u2, u1} β α) (Equiv.sumComm.{u1, u2} α β)) (Equiv.sumComm.{u2, u1} β α)\nbut is expected to have type\n  forall (α : Type.{u2}) (β : Type.{u1}), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} β α) (Sum.{u2, u1} α β)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (Sum.{u1, u2} β α) (Equiv.sumComm.{u2, u1} α β)) (Equiv.sumComm.{u1, u2} β α)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_comm_symm Equiv.sumComm_symmₓ'. -/\n@[simp]\ntheorem sumComm_symm (α β) : (sumComm α β).symm = sumComm β α :=\n  rfl\n#align equiv.sum_comm_symm Equiv.sumComm_symm\n\n#print Equiv.sumAssoc /-\n/-- Sum of types is associative up to an equivalence. -/\ndef sumAssoc (α β γ : Type _) : Sum (Sum α β) γ ≃ Sum α (Sum β γ) :=\n  ⟨Sum.elim (Sum.elim Sum.inl (Sum.inr ∘ Sum.inl)) (Sum.inr ∘ Sum.inr),\n    Sum.elim (Sum.inl ∘ Sum.inl) <| Sum.elim (Sum.inl ∘ Sum.inr) Sum.inr, by\n    rintro (⟨_ | _⟩ | _) <;> rfl, by rintro (_ | ⟨_ | _⟩) <;> rfl⟩\n#align equiv.sum_assoc Equiv.sumAssoc\n-/\n\n/- warning: equiv.sum_assoc_apply_inl_inl -> Equiv.sumAssoc_apply_inl_inl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : α), Eq.{max (succ u1) (succ (max u2 u3))} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (coeFn.{max 1 (max (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3))) (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3), max (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3))} (Equiv.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (fun (_x : Equiv.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) => (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) -> (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.sumAssoc.{u1, u2, u3} α β γ) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inl.{u1, u2} α β a))) (Sum.inl.{u1, max u2 u3} α (Sum.{u2, u3} β γ) a)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : α), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} α β) γ (Sum.inl.{u3, u2} α β a))) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (fun (_x : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Equiv.sumAssoc.{u3, u2, u1} α β γ) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} α β) γ (Sum.inl.{u3, u2} α β a))) (Sum.inl.{u3, max u1 u2} α (Sum.{u2, u1} β γ) a)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_apply_inl_inl Equiv.sumAssoc_apply_inl_inlₓ'. -/\n@[simp]\ntheorem sumAssoc_apply_inl_inl {α β γ} (a) : sumAssoc α β γ (inl (inl a)) = inl a :=\n  rfl\n#align equiv.sum_assoc_apply_inl_inl Equiv.sumAssoc_apply_inl_inl\n\n/- warning: equiv.sum_assoc_apply_inl_inr -> Equiv.sumAssoc_apply_inl_inr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (b : β), Eq.{max (succ u1) (succ (max u2 u3))} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (coeFn.{max 1 (max (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3))) (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3), max (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3))} (Equiv.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (fun (_x : Equiv.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) => (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) -> (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.sumAssoc.{u1, u2, u3} α β γ) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inr.{u1, u2} α β b))) (Sum.inr.{u1, max u2 u3} α (Sum.{u2, u3} β γ) (Sum.inl.{u2, u3} β γ b))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (b : β), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} α β) γ (Sum.inr.{u3, u2} α β b))) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (fun (_x : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Equiv.sumAssoc.{u3, u2, u1} α β γ) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} α β) γ (Sum.inr.{u3, u2} α β b))) (Sum.inr.{u3, max u1 u2} α (Sum.{u2, u1} β γ) (Sum.inl.{u2, u1} β γ b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_apply_inl_inr Equiv.sumAssoc_apply_inl_inrₓ'. -/\n@[simp]\ntheorem sumAssoc_apply_inl_inr {α β γ} (b) : sumAssoc α β γ (inl (inr b)) = inr (inl b) :=\n  rfl\n#align equiv.sum_assoc_apply_inl_inr Equiv.sumAssoc_apply_inl_inr\n\n/- warning: equiv.sum_assoc_apply_inr -> Equiv.sumAssoc_apply_inr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (c : γ), Eq.{max (succ u1) (succ (max u2 u3))} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (coeFn.{max 1 (max (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3))) (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3), max (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3))} (Equiv.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (fun (_x : Equiv.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) => (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) -> (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.sumAssoc.{u1, u2, u3} α β γ) (Sum.inr.{max u1 u2, u3} (Sum.{u1, u2} α β) γ c)) (Sum.inr.{u1, max u2 u3} α (Sum.{u2, u3} β γ) (Sum.inr.{u2, u3} β γ c))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (c : γ), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.inr.{max u2 u3, u1} (Sum.{u3, u2} α β) γ c)) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (fun (_x : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) => Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Equiv.sumAssoc.{u3, u2, u1} α β γ) (Sum.inr.{max u2 u3, u1} (Sum.{u3, u2} α β) γ c)) (Sum.inr.{u3, max u1 u2} α (Sum.{u2, u1} β γ) (Sum.inr.{u2, u1} β γ c))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_apply_inr Equiv.sumAssoc_apply_inrₓ'. -/\n@[simp]\ntheorem sumAssoc_apply_inr {α β γ} (c) : sumAssoc α β γ (inr c) = inr (inr c) :=\n  rfl\n#align equiv.sum_assoc_apply_inr Equiv.sumAssoc_apply_inr\n\n/- warning: equiv.sum_assoc_symm_apply_inl -> Equiv.sumAssoc_symm_apply_inl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : α), Eq.{max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (coeFn.{max 1 (max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)) (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3)), max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) => (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) -> (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Equiv.sumAssoc.{u1, u2, u3} α β γ)) (Sum.inl.{u1, max u2 u3} α (Sum.{u2, u3} β γ) a)) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inl.{u1, u2} α β a))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : α), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.inl.{u3, max u1 u2} α (Sum.{u2, u1} β γ) a)) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ)) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (fun (_x : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ)) (Equiv.symm.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Equiv.sumAssoc.{u3, u2, u1} α β γ)) (Sum.inl.{u3, max u1 u2} α (Sum.{u2, u1} β γ) a)) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} α β) γ (Sum.inl.{u3, u2} α β a))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_symm_apply_inl Equiv.sumAssoc_symm_apply_inlₓ'. -/\n@[simp]\ntheorem sumAssoc_symm_apply_inl {α β γ} (a) : (sumAssoc α β γ).symm (inl a) = inl (inl a) :=\n  rfl\n#align equiv.sum_assoc_symm_apply_inl Equiv.sumAssoc_symm_apply_inl\n\n/- warning: equiv.sum_assoc_symm_apply_inr_inl -> Equiv.sumAssoc_symm_apply_inr_inl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (b : β), Eq.{max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (coeFn.{max 1 (max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)) (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3)), max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) => (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) -> (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Equiv.sumAssoc.{u1, u2, u3} α β γ)) (Sum.inr.{u1, max u2 u3} α (Sum.{u2, u3} β γ) (Sum.inl.{u2, u3} β γ b))) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inr.{u1, u2} α β b))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (b : β), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.inr.{u3, max u1 u2} α (Sum.{u2, u1} β γ) (Sum.inl.{u2, u1} β γ b))) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ)) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (fun (_x : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ)) (Equiv.symm.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Equiv.sumAssoc.{u3, u2, u1} α β γ)) (Sum.inr.{u3, max u1 u2} α (Sum.{u2, u1} β γ) (Sum.inl.{u2, u1} β γ b))) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} α β) γ (Sum.inr.{u3, u2} α β b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_symm_apply_inr_inl Equiv.sumAssoc_symm_apply_inr_inlₓ'. -/\n@[simp]\ntheorem sumAssoc_symm_apply_inr_inl {α β γ} (b) :\n    (sumAssoc α β γ).symm (inr (inl b)) = inl (inr b) :=\n  rfl\n#align equiv.sum_assoc_symm_apply_inr_inl Equiv.sumAssoc_symm_apply_inr_inl\n\n/- warning: equiv.sum_assoc_symm_apply_inr_inr -> Equiv.sumAssoc_symm_apply_inr_inr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (c : γ), Eq.{max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (coeFn.{max 1 (max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)) (max (succ (max u1 u2)) (succ u3)) (succ u1) (succ (max u2 u3)), max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) => (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) -> (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Equiv.sumAssoc.{u1, u2, u3} α β γ)) (Sum.inr.{u1, max u2 u3} α (Sum.{u2, u3} β γ) (Sum.inr.{u2, u3} β γ c))) (Sum.inr.{max u1 u2, u3} (Sum.{u1, u2} α β) γ c)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (c : γ), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.inr.{u3, max u1 u2} α (Sum.{u2, u1} β γ) (Sum.inr.{u2, u1} β γ c))) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ)) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (fun (_x : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ)) (Equiv.symm.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{max u2 u3, u1} (Sum.{u3, u2} α β) γ) (Sum.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Equiv.sumAssoc.{u3, u2, u1} α β γ)) (Sum.inr.{u3, max u1 u2} α (Sum.{u2, u1} β γ) (Sum.inr.{u2, u1} β γ c))) (Sum.inr.{max u2 u3, u1} (Sum.{u3, u2} α β) γ c)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_symm_apply_inr_inr Equiv.sumAssoc_symm_apply_inr_inrₓ'. -/\n@[simp]\ntheorem sumAssoc_symm_apply_inr_inr {α β γ} (c) : (sumAssoc α β γ).symm (inr (inr c)) = inr c :=\n  rfl\n#align equiv.sum_assoc_symm_apply_inr_inr Equiv.sumAssoc_symm_apply_inr_inr\n\n#print Equiv.sumEmpty /-\n/-- Sum with `empty` is equivalent to the original type. -/\n@[simps symm_apply]\ndef sumEmpty (α β : Type _) [IsEmpty β] : Sum α β ≃ α :=\n  ⟨Sum.elim id isEmptyElim, inl, fun s =>\n    by\n    rcases s with (_ | x)\n    rfl\n    exact isEmptyElim x, fun a => rfl⟩\n#align equiv.sum_empty Equiv.sumEmpty\n-/\n\n/- warning: equiv.sum_empty_apply_inl -> Equiv.sumEmpty_apply_inl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : IsEmpty.{succ u2} β] (a : α), Eq.{succ u1} α (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α β) α) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α β) α) => (Sum.{u1, u2} α β) -> α) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α β) α) (Equiv.sumEmpty.{u1, u2} α β _inst_1) (Sum.inl.{u1, u2} α β a)) a\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : IsEmpty.{succ u2} α] (a : β), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u1, u2} β α) => β) (Sum.inl.{u1, u2} β α a)) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), succ u1} (Equiv.{max (succ u2) (succ u1), succ u1} (Sum.{u1, u2} β α) β) (Sum.{u1, u2} β α) (fun (_x : Sum.{u1, u2} β α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u1, u2} β α) => β) _x) (Equiv.instFunLikeEquiv.{max (succ u2) (succ u1), succ u1} (Sum.{u1, u2} β α) β) (Equiv.sumEmpty.{u1, u2} β α _inst_1) (Sum.inl.{u1, u2} β α a)) a\nCase conversion may be inaccurate. Consider using '#align equiv.sum_empty_apply_inl Equiv.sumEmpty_apply_inlₓ'. -/\n@[simp]\ntheorem sumEmpty_apply_inl {α β : Type _} [IsEmpty β] (a : α) : sumEmpty α β (Sum.inl a) = a :=\n  rfl\n#align equiv.sum_empty_apply_inl Equiv.sumEmpty_apply_inl\n\n#print Equiv.emptySum /-\n/-- The sum of `empty` with any `Sort*` is equivalent to the right summand. -/\n@[simps symm_apply]\ndef emptySum (α β : Type _) [IsEmpty α] : Sum α β ≃ β :=\n  (sumComm _ _).trans <| sumEmpty _ _\n#align equiv.empty_sum Equiv.emptySum\n-/\n\n/- warning: equiv.empty_sum_apply_inr -> Equiv.emptySum_apply_inr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : IsEmpty.{succ u1} α] (b : β), Eq.{succ u2} β (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u2} (Sum.{u1, u2} α β) β) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u2} (Sum.{u1, u2} α β) β) => (Sum.{u1, u2} α β) -> β) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u2} (Sum.{u1, u2} α β) β) (Equiv.emptySum.{u1, u2} α β _inst_1) (Sum.inr.{u1, u2} α β b)) b\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : IsEmpty.{succ u2} α] (b : β), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α β) => β) (Sum.inr.{u2, u1} α β b)) (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), succ u1} (Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u2, u1} α β) β) (Sum.{u2, u1} α β) (fun (_x : Sum.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α β) => β) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), succ u1} (Sum.{u2, u1} α β) β) (Equiv.emptySum.{u2, u1} α β _inst_1) (Sum.inr.{u2, u1} α β b)) b\nCase conversion may be inaccurate. Consider using '#align equiv.empty_sum_apply_inr Equiv.emptySum_apply_inrₓ'. -/\n@[simp]\ntheorem emptySum_apply_inr {α β : Type _} [IsEmpty α] (b : β) : emptySum α β (Sum.inr b) = b :=\n  rfl\n#align equiv.empty_sum_apply_inr Equiv.emptySum_apply_inr\n\n/- warning: equiv.option_equiv_sum_punit -> Equiv.optionEquivSumPUnit is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u2}), Equiv.{succ u2, max (succ u2) (succ u1)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1})\nbut is expected to have type\n  forall (α : Type.{u1}), Equiv.{succ u1, max (succ u2) (succ u1)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit Equiv.optionEquivSumPUnitₓ'. -/\n/-- `option α` is equivalent to `α ⊕ punit` -/\ndef optionEquivSumPUnit (α : Type _) : Option α ≃ Sum α PUnit.{u + 1} :=\n  ⟨fun o => o.elim (inr PUnit.unit) inl, fun s => s.elim some fun _ => none, fun o => by\n    cases o <;> rfl, fun s => by rcases s with (_ | ⟨⟨⟩⟩) <;> rfl⟩\n#align equiv.option_equiv_sum_punit Equiv.optionEquivSumPUnit\n\n/- warning: equiv.option_equiv_sum_punit_none -> Equiv.optionEquivSumPUnit_none is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}}, Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α PUnit.{succ u2}) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) (fun (_x : Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) => (Option.{u1} α) -> (Sum.{u1, u2} α PUnit.{succ u2})) (Equiv.hasCoeToFun.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) (Equiv.optionEquivSumPUnit.{u2, u1} α) (Option.none.{u1} α)) (Sum.inr.{u1, u2} α PUnit.{succ u2} PUnit.unit.{succ u2})\nbut is expected to have type\n  forall {α : Type.{u2}}, Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Sum.{u2, u1} α PUnit.{succ u1}) (Option.none.{u2} α)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, max (succ u1) (succ u2)} (Equiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1})) (Option.{u2} α) (fun (_x : Option.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Sum.{u2, u1} α PUnit.{succ u1}) _x) (Equiv.instFunLikeEquiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1})) (Equiv.optionEquivSumPUnit.{u2, u1} α) (Option.none.{u2} α)) (Sum.inr.{u2, u1} α PUnit.{succ u1} PUnit.unit.{succ u1})\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_none Equiv.optionEquivSumPUnit_noneₓ'. -/\n@[simp]\ntheorem optionEquivSumPUnit_none {α} : optionEquivSumPUnit α none = Sum.inr PUnit.unit :=\n  rfl\n#align equiv.option_equiv_sum_punit_none Equiv.optionEquivSumPUnit_none\n\n/- warning: equiv.option_equiv_sum_punit_some -> Equiv.optionEquivSumPUnit_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : α), Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α PUnit.{succ u2}) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) (fun (_x : Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) => (Option.{u1} α) -> (Sum.{u1, u2} α PUnit.{succ u2})) (Equiv.hasCoeToFun.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) (Equiv.optionEquivSumPUnit.{u2, u1} α) (Option.some.{u1} α a)) (Sum.inl.{u1, u2} α PUnit.{succ u2} a)\nbut is expected to have type\n  forall {α : Type.{u2}} (a : α), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Sum.{u2, u1} α PUnit.{succ u1}) (Option.some.{u2} α a)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, max (succ u1) (succ u2)} (Equiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1})) (Option.{u2} α) (fun (_x : Option.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Sum.{u2, u1} α PUnit.{succ u1}) _x) (Equiv.instFunLikeEquiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1})) (Equiv.optionEquivSumPUnit.{u2, u1} α) (Option.some.{u2} α a)) (Sum.inl.{u2, u1} α PUnit.{succ u1} a)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_some Equiv.optionEquivSumPUnit_someₓ'. -/\n@[simp]\ntheorem optionEquivSumPUnit_some {α} (a) : optionEquivSumPUnit α (some a) = Sum.inl a :=\n  rfl\n#align equiv.option_equiv_sum_punit_some Equiv.optionEquivSumPUnit_some\n\n/- warning: equiv.option_equiv_sum_punit_coe -> Equiv.optionEquivSumPUnit_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : α), Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α PUnit.{succ u2}) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) (fun (_x : Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) => (Option.{u1} α) -> (Sum.{u1, u2} α PUnit.{succ u2})) (Equiv.hasCoeToFun.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2})) (Equiv.optionEquivSumPUnit.{u2, u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (Option.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (Option.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (Option.{u1} α) (coeOption.{u1} α))) a)) (Sum.inl.{u1, u2} α PUnit.{succ u2} a)\nbut is expected to have type\n  forall {α : Type.{u2}} (a : α), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Sum.{u2, u1} α PUnit.{succ u1}) (Option.some.{u2} α a)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, max (succ u1) (succ u2)} (Equiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1})) (Option.{u2} α) (fun (_x : Option.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Sum.{u2, u1} α PUnit.{succ u1}) _x) (Equiv.instFunLikeEquiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1})) (Equiv.optionEquivSumPUnit.{u2, u1} α) (Option.some.{u2} α a)) (Sum.inl.{u2, u1} α PUnit.{succ u1} a)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_coe Equiv.optionEquivSumPUnit_coeₓ'. -/\n@[simp]\ntheorem optionEquivSumPUnit_coe {α} (a : α) : optionEquivSumPUnit α a = Sum.inl a :=\n  rfl\n#align equiv.option_equiv_sum_punit_coe Equiv.optionEquivSumPUnit_coe\n\n/- warning: equiv.option_equiv_sum_punit_symm_inl -> Equiv.optionEquivSumPUnit_symm_inl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Option.{u1} α) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α PUnit.{succ u2}) (Option.{u1} α)) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α PUnit.{succ u2}) (Option.{u1} α)) => (Sum.{u1, u2} α PUnit.{succ u2}) -> (Option.{u1} α)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α PUnit.{succ u2}) (Option.{u1} α)) (Equiv.symm.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2}) (Equiv.optionEquivSumPUnit.{u2, u1} α)) (Sum.inl.{u1, u2} α PUnit.{succ u2} a)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (Option.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (Option.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (Option.{u1} α) (coeOption.{u1} α))) a)\nbut is expected to have type\n  forall {α : Type.{u2}} (a : α), Eq.{succ u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α PUnit.{succ u1}) => Option.{u2} α) (Sum.inl.{u2, u1} α PUnit.{succ u1} a)) (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), succ u2} (Equiv.{max (succ u1) (succ u2), succ u2} (Sum.{u2, u1} α PUnit.{succ u1}) (Option.{u2} α)) (Sum.{u2, u1} α PUnit.{succ u1}) (fun (_x : Sum.{u2, u1} α PUnit.{succ u1}) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α PUnit.{succ u1}) => Option.{u2} α) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), succ u2} (Sum.{u2, u1} α PUnit.{succ u1}) (Option.{u2} α)) (Equiv.symm.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1}) (Equiv.optionEquivSumPUnit.{u2, u1} α)) (Sum.inl.{u2, u1} α PUnit.{succ u1} a)) (Option.some.{u2} α a)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_symm_inl Equiv.optionEquivSumPUnit_symm_inlₓ'. -/\n@[simp]\ntheorem optionEquivSumPUnit_symm_inl {α} (a) : (optionEquivSumPUnit α).symm (Sum.inl a) = a :=\n  rfl\n#align equiv.option_equiv_sum_punit_symm_inl Equiv.optionEquivSumPUnit_symm_inl\n\n/- warning: equiv.option_equiv_sum_punit_symm_inr -> Equiv.optionEquivSumPUnit_symm_inr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : PUnit.{succ u2}), Eq.{succ u1} (Option.{u1} α) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α PUnit.{succ u2}) (Option.{u1} α)) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α PUnit.{succ u2}) (Option.{u1} α)) => (Sum.{u1, u2} α PUnit.{succ u2}) -> (Option.{u1} α)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} α PUnit.{succ u2}) (Option.{u1} α)) (Equiv.symm.{succ u1, max (succ u1) (succ u2)} (Option.{u1} α) (Sum.{u1, u2} α PUnit.{succ u2}) (Equiv.optionEquivSumPUnit.{u2, u1} α)) (Sum.inr.{u1, u2} α PUnit.{succ u2} a)) (Option.none.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u2}} (a : PUnit.{succ u1}), Eq.{succ u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α PUnit.{succ u1}) => Option.{u2} α) (Sum.inr.{u2, u1} α PUnit.{succ u1} a)) (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), succ u2} (Equiv.{max (succ u1) (succ u2), succ u2} (Sum.{u2, u1} α PUnit.{succ u1}) (Option.{u2} α)) (Sum.{u2, u1} α PUnit.{succ u1}) (fun (_x : Sum.{u2, u1} α PUnit.{succ u1}) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} α PUnit.{succ u1}) => Option.{u2} α) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), succ u2} (Sum.{u2, u1} α PUnit.{succ u1}) (Option.{u2} α)) (Equiv.symm.{succ u2, max (succ u1) (succ u2)} (Option.{u2} α) (Sum.{u2, u1} α PUnit.{succ u1}) (Equiv.optionEquivSumPUnit.{u2, u1} α)) (Sum.inr.{u2, u1} α PUnit.{succ u1} a)) (Option.none.{u2} α)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_symm_inr Equiv.optionEquivSumPUnit_symm_inrₓ'. -/\n@[simp]\ntheorem optionEquivSumPUnit_symm_inr {α} (a) : (optionEquivSumPUnit α).symm (Sum.inr a) = none :=\n  rfl\n#align equiv.option_equiv_sum_punit_symm_inr Equiv.optionEquivSumPUnit_symm_inr\n\n#print Equiv.optionIsSomeEquiv /-\n/-- The set of `x : option α` such that `is_some x` is equivalent to `α`. -/\n@[simps]\ndef optionIsSomeEquiv (α : Type _) : { x : Option α // x.isSome } ≃ α\n    where\n  toFun o := Option.get o.2\n  invFun x := ⟨some x, by decide⟩\n  left_inv o := Subtype.eq <| Option.some_get _\n  right_inv x := Option.get_some _ _\n#align equiv.option_is_some_equiv Equiv.optionIsSomeEquiv\n-/\n\n#print Equiv.piOptionEquivProd /-\n/-- The product over `option α` of `β a` is the binary product of the\nproduct over `α` of `β (some α)` and `β none` -/\n@[simps]\ndef piOptionEquivProd {α : Type _} {β : Option α → Type _} :\n    (∀ a : Option α, β a) ≃ β none × ∀ a : α, β (some a)\n    where\n  toFun f := (f none, fun a => f (some a))\n  invFun x a := Option.casesOn a x.fst x.snd\n  left_inv f := funext fun a => by cases a <;> rfl\n  right_inv x := by simp\n#align equiv.pi_option_equiv_prod Equiv.piOptionEquivProd\n-/\n\n#print Equiv.sumEquivSigmaBool /-\n/-- `α ⊕ β` is equivalent to a `sigma`-type over `bool`. Note that this definition assumes `α` and\n`β` to be types from the same universe, so it cannot by used directly to transfer theorems about\nsigma types to theorems about sum types. In many cases one can use `ulift` to work around this\ndifficulty. -/\ndef sumEquivSigmaBool (α β : Type u) : Sum α β ≃ Σb : Bool, cond b α β :=\n  ⟨fun s => s.elim (fun x => ⟨true, x⟩) fun x => ⟨false, x⟩, fun s =>\n    match s with\n    | ⟨tt, a⟩ => inl a\n    | ⟨ff, b⟩ => inr b,\n    fun s => by cases s <;> rfl, fun s => by rcases s with ⟨_ | _, _⟩ <;> rfl⟩\n#align equiv.sum_equiv_sigma_bool Equiv.sumEquivSigmaBool\n-/\n\n#print Equiv.sigmaFiberEquiv /-\n-- See also `equiv.sigma_preimage_equiv`.\n/-- `sigma_fiber_equiv f` for `f : α → β` is the natural equivalence between\nthe type of all fibres of `f` and the total space `α`. -/\n@[simps]\ndef sigmaFiberEquiv {α β : Type _} (f : α → β) : (Σy : β, { x // f x = y }) ≃ α :=\n  ⟨fun x => ↑x.2, fun x => ⟨f x, x, rfl⟩, fun ⟨y, x, rfl⟩ => rfl, fun x => rfl⟩\n#align equiv.sigma_fiber_equiv Equiv.sigmaFiberEquiv\n-/\n\nend\n\nsection SumCompl\n\n#print Equiv.sumCompl /-\n/-- For any predicate `p` on `α`,\nthe sum of the two subtypes `{a // p a}` and its complement `{a // ¬ p a}`\nis naturally equivalent to `α`.\n\nSee `subtype_or_equiv` for sum types over subtypes `{x // p x}` and `{x // q x}`\nthat are not necessarily `is_compl p q`.  -/\ndef sumCompl {α : Type _} (p : α → Prop) [DecidablePred p] : Sum { a // p a } { a // ¬p a } ≃ α\n    where\n  toFun := Sum.elim coe coe\n  invFun a := if h : p a then Sum.inl ⟨a, h⟩ else Sum.inr ⟨a, h⟩\n  left_inv := by rintro (⟨x, hx⟩ | ⟨x, hx⟩) <;> dsimp <;> [rw [dif_pos], rw [dif_neg]]\n  right_inv a := by\n    dsimp\n    split_ifs <;> rfl\n#align equiv.sum_compl Equiv.sumCompl\n-/\n\n#print Equiv.sumCompl_apply_inl /-\n@[simp]\ntheorem sumCompl_apply_inl {α : Type _} (p : α → Prop) [DecidablePred p] (x : { a // p a }) :\n    sumCompl p (Sum.inl x) = x :=\n  rfl\n#align equiv.sum_compl_apply_inl Equiv.sumCompl_apply_inl\n-/\n\n#print Equiv.sumCompl_apply_inr /-\n@[simp]\ntheorem sumCompl_apply_inr {α : Type _} (p : α → Prop) [DecidablePred p] (x : { a // ¬p a }) :\n    sumCompl p (Sum.inr x) = x :=\n  rfl\n#align equiv.sum_compl_apply_inr Equiv.sumCompl_apply_inr\n-/\n\n#print Equiv.sumCompl_apply_symm_of_pos /-\n@[simp]\ntheorem sumCompl_apply_symm_of_pos {α : Type _} (p : α → Prop) [DecidablePred p] (a : α) (h : p a) :\n    (sumCompl p).symm a = Sum.inl ⟨a, h⟩ :=\n  dif_pos h\n#align equiv.sum_compl_apply_symm_of_pos Equiv.sumCompl_apply_symm_of_pos\n-/\n\n#print Equiv.sumCompl_apply_symm_of_neg /-\n@[simp]\ntheorem sumCompl_apply_symm_of_neg {α : Type _} (p : α → Prop) [DecidablePred p] (a : α)\n    (h : ¬p a) : (sumCompl p).symm a = Sum.inr ⟨a, h⟩ :=\n  dif_neg h\n#align equiv.sum_compl_apply_symm_of_neg Equiv.sumCompl_apply_symm_of_neg\n-/\n\n#print Equiv.subtypeCongr /-\n/-- Combines an `equiv` between two subtypes with an `equiv` between their complements to form a\n  permutation. -/\ndef subtypeCongr {α : Type _} {p q : α → Prop} [DecidablePred p] [DecidablePred q]\n    (e : { x // p x } ≃ { x // q x }) (f : { x // ¬p x } ≃ { x // ¬q x }) : Perm α :=\n  (sumCompl p).symm.trans ((sumCongr e f).trans (sumCompl q))\n#align equiv.subtype_congr Equiv.subtypeCongr\n-/\n\nopen Equiv\n\nvariable {ε : Type _} {p : ε → Prop} [DecidablePred p]\n\nvariable (ep ep' : Perm { a // p a }) (en en' : Perm { a // ¬p a })\n\n#print Equiv.Perm.subtypeCongr /-\n/-- Combining permutations on `ε` that permute only inside or outside the subtype\nsplit induced by `p : ε → Prop` constructs a permutation on `ε`. -/\ndef Perm.subtypeCongr : Equiv.Perm ε :=\n  permCongr (sumCompl p) (sumCongr ep en)\n#align equiv.perm.subtype_congr Equiv.Perm.subtypeCongr\n-/\n\n#print Equiv.Perm.subtypeCongr.apply /-\ntheorem Perm.subtypeCongr.apply (a : ε) :\n    ep.subtypeCongr en a = if h : p a then ep ⟨a, h⟩ else en ⟨a, h⟩ := by\n  by_cases h : p a <;> simp [perm.subtype_congr, h]\n#align equiv.perm.subtype_congr.apply Equiv.Perm.subtypeCongr.apply\n-/\n\n#print Equiv.Perm.subtypeCongr.left_apply /-\n@[simp]\ntheorem Perm.subtypeCongr.left_apply {a : ε} (h : p a) : ep.subtypeCongr en a = ep ⟨a, h⟩ := by\n  simp [perm.subtype_congr.apply, h]\n#align equiv.perm.subtype_congr.left_apply Equiv.Perm.subtypeCongr.left_apply\n-/\n\n#print Equiv.Perm.subtypeCongr.left_apply_subtype /-\n@[simp]\ntheorem Perm.subtypeCongr.left_apply_subtype (a : { a // p a }) : ep.subtypeCongr en a = ep a :=\n  by\n  convert perm.subtype_congr.left_apply _ _ a.property\n  simp\n#align equiv.perm.subtype_congr.left_apply_subtype Equiv.Perm.subtypeCongr.left_apply_subtype\n-/\n\n#print Equiv.Perm.subtypeCongr.right_apply /-\n@[simp]\ntheorem Perm.subtypeCongr.right_apply {a : ε} (h : ¬p a) : ep.subtypeCongr en a = en ⟨a, h⟩ := by\n  simp [perm.subtype_congr.apply, h]\n#align equiv.perm.subtype_congr.right_apply Equiv.Perm.subtypeCongr.right_apply\n-/\n\n#print Equiv.Perm.subtypeCongr.right_apply_subtype /-\n@[simp]\ntheorem Perm.subtypeCongr.right_apply_subtype (a : { a // ¬p a }) : ep.subtypeCongr en a = en a :=\n  by\n  convert perm.subtype_congr.right_apply _ _ a.property\n  simp\n#align equiv.perm.subtype_congr.right_apply_subtype Equiv.Perm.subtypeCongr.right_apply_subtype\n-/\n\n#print Equiv.Perm.subtypeCongr.refl /-\n@[simp]\ntheorem Perm.subtypeCongr.refl :\n    Perm.subtypeCongr (Equiv.refl { a // p a }) (Equiv.refl { a // ¬p a }) = Equiv.refl ε :=\n  by\n  ext x\n  by_cases h : p x <;> simp [h]\n#align equiv.perm.subtype_congr.refl Equiv.Perm.subtypeCongr.refl\n-/\n\n#print Equiv.Perm.subtypeCongr.symm /-\n@[simp]\ntheorem Perm.subtypeCongr.symm : (ep.subtypeCongr en).symm = Perm.subtypeCongr ep.symm en.symm :=\n  by\n  ext x\n  by_cases h : p x\n  · have : p (ep.symm ⟨x, h⟩) := Subtype.property _\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this]\n  · have : ¬p (en.symm ⟨x, h⟩) := Subtype.property (en.symm _)\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this]\n#align equiv.perm.subtype_congr.symm Equiv.Perm.subtypeCongr.symm\n-/\n\n#print Equiv.Perm.subtypeCongr.trans /-\n@[simp]\ntheorem Perm.subtypeCongr.trans :\n    (ep.subtypeCongr en).trans (ep'.subtypeCongr en') =\n      Perm.subtypeCongr (ep.trans ep') (en.trans en') :=\n  by\n  ext x\n  by_cases h : p x\n  · have : p (ep ⟨x, h⟩) := Subtype.property _\n    simp [perm.subtype_congr.apply, h, this]\n  · have : ¬p (en ⟨x, h⟩) := Subtype.property (en _)\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this]\n#align equiv.perm.subtype_congr.trans Equiv.Perm.subtypeCongr.trans\n-/\n\nend SumCompl\n\nsection SubtypePreimage\n\nvariable (p : α → Prop) [DecidablePred p] (x₀ : { a // p a } → β)\n\n#print Equiv.subtypePreimage /-\n/-- For a fixed function `x₀ : {a // p a} → β` defined on a subtype of `α`,\nthe subtype of functions `x : α → β` that agree with `x₀` on the subtype `{a // p a}`\nis naturally equivalent to the type of functions `{a // ¬ p a} → β`. -/\n@[simps]\ndef subtypePreimage : { x : α → β // x ∘ coe = x₀ } ≃ ({ a // ¬p a } → β)\n    where\n  toFun (x : { x : α → β // x ∘ coe = x₀ }) a := (x : α → β) a\n  invFun x := ⟨fun a => if h : p a then x₀ ⟨a, h⟩ else x ⟨a, h⟩, funext fun ⟨a, h⟩ => dif_pos h⟩\n  left_inv := fun ⟨x, hx⟩ =>\n    Subtype.val_injective <|\n      funext fun a => by\n        dsimp\n        split_ifs <;> [rw [← hx], skip] <;> rfl\n  right_inv x :=\n    funext fun ⟨a, h⟩ =>\n      show dite (p a) _ _ = _ by\n        dsimp\n        rw [dif_neg h]\n#align equiv.subtype_preimage Equiv.subtypePreimage\n-/\n\n/- warning: equiv.subtype_preimage_symm_apply_coe_pos -> Equiv.subtypePreimage_symm_apply_coe_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (p : α -> Prop) [_inst_1 : DecidablePred.{u1} α p] (x₀ : (Subtype.{u1} α (fun (a : α) => p a)) -> β) (x : (Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (a : α) (h : p a), Eq.{u2} β ((fun (a : Sort.{max 1 (imax u1 u2)}) (b : Sort.{imax u1 u2}) [self : HasLiftT.{max 1 (imax u1 u2), imax u1 u2} a b] => self.0) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (HasLiftT.mk.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (CoeTCₓ.coe.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (coeBase.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (coeSubtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))))) (coeFn.{max 1 (max (imax (max 1 u1) u2) 1 (imax u1 u2)) (imax (max 1 (imax u1 u2)) (max 1 u1) u2), max (imax (max 1 u1) u2) 1 (imax u1 u2)} (Equiv.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) (fun (_x : Equiv.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) => ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) -> (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) (Equiv.hasCoeToFun.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) (Equiv.symm.{max 1 (imax u1 u2), imax (max 1 u1) u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Equiv.subtypePreimage.{u1, u2} α β p (fun (a : α) => _inst_1 a) x₀)) x) a) (x₀ (Subtype.mk.{u1} α (fun (a : α) => p a) a h))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{u2} α p] (x₀ : (Subtype.{u2} α (fun (a : α) => p a)) -> β) (x : (Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (a : α) (h : p a), Eq.{u1} β (Subtype.val.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀) (FunLike.coe.{max (max 1 (imax u2 u1)) (imax (max 1 u2) u1), imax (max 1 u2) u1, max 1 (imax u2 u1)} (Equiv.{imax (max 1 u2) u1, max 1 (imax u2 u1)} ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀))) ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (fun (_x : (Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) => Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀)) _x) (Equiv.instFunLikeEquiv.{imax (max 1 u2) u1, max 1 (imax u2 u1)} ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀))) (Equiv.symm.{max 1 (imax u2 u1), imax (max 1 u2) u1} (Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀)) ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (Equiv.subtypePreimage.{u2, u1} α β p (fun (a : α) => _inst_1 a) x₀)) x) a) (x₀ (Subtype.mk.{u2} α (fun (a : α) => p a) a h))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_preimage_symm_apply_coe_pos Equiv.subtypePreimage_symm_apply_coe_posₓ'. -/\ntheorem subtypePreimage_symm_apply_coe_pos (x : { a // ¬p a } → β) (a : α) (h : p a) :\n    ((subtypePreimage p x₀).symm x : α → β) a = x₀ ⟨a, h⟩ :=\n  dif_pos h\n#align equiv.subtype_preimage_symm_apply_coe_pos Equiv.subtypePreimage_symm_apply_coe_pos\n\n/- warning: equiv.subtype_preimage_symm_apply_coe_neg -> Equiv.subtypePreimage_symm_apply_coe_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (p : α -> Prop) [_inst_1 : DecidablePred.{u1} α p] (x₀ : (Subtype.{u1} α (fun (a : α) => p a)) -> β) (x : (Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (a : α) (h : Not (p a)), Eq.{u2} β ((fun (a : Sort.{max 1 (imax u1 u2)}) (b : Sort.{imax u1 u2}) [self : HasLiftT.{max 1 (imax u1 u2), imax u1 u2} a b] => self.0) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (HasLiftT.mk.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (CoeTCₓ.coe.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (coeBase.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) (α -> β) (coeSubtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))))) (coeFn.{max 1 (max (imax (max 1 u1) u2) 1 (imax u1 u2)) (imax (max 1 (imax u1 u2)) (max 1 u1) u2), max (imax (max 1 u1) u2) 1 (imax u1 u2)} (Equiv.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) (fun (_x : Equiv.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) => ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) -> (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) (Equiv.hasCoeToFun.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀))) (Equiv.symm.{max 1 (imax u1 u2), imax (max 1 u1) u2} (Subtype.{imax u1 u2} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} α (fun (a : α) => p a)) α β x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (a : α) => p a)) α (coeSubtype.{u1} α (fun (a : α) => p a))))))) x₀)) ((Subtype.{u1} α (fun (a : α) => Not (p a))) -> β) (Equiv.subtypePreimage.{u1, u2} α β p (fun (a : α) => _inst_1 a) x₀)) x) a) (x (Subtype.mk.{u1} α (fun (a : α) => Not (p a)) a h))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (p : α -> Prop) [_inst_1 : DecidablePred.{u2} α p] (x₀ : (Subtype.{u2} α (fun (a : α) => p a)) -> β) (x : (Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (a : α) (h : Not (p a)), Eq.{u1} β (Subtype.val.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀) (FunLike.coe.{max (max 1 (imax u2 u1)) (imax (max 1 u2) u1), imax (max 1 u2) u1, max 1 (imax u2 u1)} (Equiv.{imax (max 1 u2) u1, max 1 (imax u2 u1)} ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀))) ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (fun (_x : (Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) => Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀)) _x) (Equiv.instFunLikeEquiv.{imax (max 1 u2) u1, max 1 (imax u2 u1)} ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀))) (Equiv.symm.{max 1 (imax u2 u1), imax (max 1 u2) u1} (Subtype.{imax u2 u1} (α -> β) (fun (x : α -> β) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} α (fun (a : α) => p a)) -> β) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} α (fun (a : α) => p a)) α β x (Subtype.val.{u2} α (fun (a : α) => p a))) x₀)) ((Subtype.{u2} α (fun (a : α) => Not (p a))) -> β) (Equiv.subtypePreimage.{u2, u1} α β p (fun (a : α) => _inst_1 a) x₀)) x) a) (x (Subtype.mk.{u2} α (fun (a : α) => Not (p a)) a h))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_preimage_symm_apply_coe_neg Equiv.subtypePreimage_symm_apply_coe_negₓ'. -/\ntheorem subtypePreimage_symm_apply_coe_neg (x : { a // ¬p a } → β) (a : α) (h : ¬p a) :\n    ((subtypePreimage p x₀).symm x : α → β) a = x ⟨a, h⟩ :=\n  dif_neg h\n#align equiv.subtype_preimage_symm_apply_coe_neg Equiv.subtypePreimage_symm_apply_coe_neg\n\nend SubtypePreimage\n\nsection\n\n#print Equiv.piCongrRight /-\n/-- A family of equivalences `Π a, β₁ a ≃ β₂ a` generates an equivalence between `Π a, β₁ a` and\n`Π a, β₂ a`. -/\ndef piCongrRight {α} {β₁ β₂ : α → Sort _} (F : ∀ a, β₁ a ≃ β₂ a) : (∀ a, β₁ a) ≃ ∀ a, β₂ a :=\n  ⟨fun H a => F a (H a), fun H a => (F a).symm (H a), fun H => funext <| by simp, fun H =>\n    funext <| by simp⟩\n#align equiv.Pi_congr_right Equiv.piCongrRight\n-/\n\n#print Equiv.piComm /-\n/-- Given `φ : α → β → Sort*`, we have an equivalence between `Π a b, φ a b` and `Π b a, φ a b`.\nThis is `function.swap` as an `equiv`. -/\n@[simps apply]\ndef piComm {α β} (φ : α → β → Sort _) : (∀ a b, φ a b) ≃ ∀ b a, φ a b :=\n  ⟨swap, swap, fun x => rfl, fun y => rfl⟩\n#align equiv.Pi_comm Equiv.piComm\n-/\n\n/- warning: equiv.Pi_comm_symm -> Equiv.piComm_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {φ : α -> β -> Sort.{u3}}, Eq.{max 1 (imax (imax u2 u1 u3) u1 u2 u3) (imax (imax u1 u2 u3) u2 u1 u3)} (Equiv.{imax u2 u1 u3, imax u1 u2 u3} (forall (b : β) (a : α), φ a b) (forall (a : α) (b : β), φ a b)) (Equiv.symm.{imax u1 u2 u3, imax u2 u1 u3} (forall (a : α) (b : β), φ a b) (forall (b : β) (a : α), φ a b) (Equiv.piComm.{u1, u2, u3} α β φ)) (Equiv.piComm.{u2, u1, u3} β α (Function.swap.{u1, u2, succ u3} α β (fun (ᾰ : α) (ᾰ : β) => Sort.{u3}) φ))\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {φ : α -> β -> Sort.{u1}}, Eq.{max (max 1 (imax u3 u2 u1)) (imax u2 u3 u1)} (Equiv.{imax u2 u3 u1, imax u3 u2 u1} (forall (b : β) (a : α), φ a b) (forall (a : α) (b : β), φ a b)) (Equiv.symm.{imax u3 u2 u1, imax u2 u3 u1} (forall (a : α) (b : β), φ a b) (forall (b : β) (a : α), φ a b) (Equiv.piComm.{u3, u2, u1} α β φ)) (Equiv.piComm.{u2, u3, u1} β α (Function.swap.{u3, u2, succ u1} α β (fun (ᾰ : α) (ᾰ : β) => Sort.{u1}) φ))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_comm_symm Equiv.piComm_symmₓ'. -/\n@[simp]\ntheorem piComm_symm {α β} {φ : α → β → Sort _} : (piComm φ).symm = (piComm <| swap φ) :=\n  rfl\n#align equiv.Pi_comm_symm Equiv.piComm_symm\n\n#print Equiv.piCurry /-\n/-- Dependent `curry` equivalence: the type of dependent functions on `Σ i, β i` is equivalent\nto the type of dependent functions of two arguments (i.e., functions to the space of functions).\n\nThis is `sigma.curry` and `sigma.uncurry` together as an equiv. -/\ndef piCurry {α} {β : α → Sort _} (γ : ∀ a, β a → Sort _) : (∀ x : Σi, β i, γ x.1 x.2) ≃ ∀ a b, γ a b\n    where\n  toFun := Sigma.curry\n  invFun := Sigma.uncurry\n  left_inv := Sigma.uncurry_curry\n  right_inv := Sigma.curry_uncurry\n#align equiv.Pi_curry Equiv.piCurry\n-/\n\nend\n\nsection ProdCongr\n\nvariable {α₁ β₁ β₂ : Type _} (e : α₁ → β₁ ≃ β₂)\n\n#print Equiv.prodCongrLeft /-\n/-- A family of equivalences `Π (a : α₁), β₁ ≃ β₂` generates an equivalence\nbetween `β₁ × α₁` and `β₂ × α₁`. -/\ndef prodCongrLeft : β₁ × α₁ ≃ β₂ × α₁\n    where\n  toFun ab := ⟨e ab.2 ab.1, ab.2⟩\n  invFun ab := ⟨(e ab.2).symm ab.1, ab.2⟩\n  left_inv := by\n    rintro ⟨a, b⟩\n    simp\n  right_inv := by\n    rintro ⟨a, b⟩\n    simp\n#align equiv.prod_congr_left Equiv.prodCongrLeft\n-/\n\n/- warning: equiv.prod_congr_left_apply -> Equiv.prodCongrLeft_apply is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {β₂ : Type.{u3}} (e : α₁ -> (Equiv.{succ u2, succ u3} β₁ β₂)) (b : β₁) (a : α₁), Eq.{max (succ u3) (succ u1)} (Prod.{u3, u1} β₂ α₁) (coeFn.{max 1 (max (max (succ u2) (succ u1)) (succ u3) (succ u1)) (max (succ u3) (succ u1)) (succ u2) (succ u1), max (max (succ u2) (succ u1)) (succ u3) (succ u1)} (Equiv.{max (succ u2) (succ u1), max (succ u3) (succ u1)} (Prod.{u2, u1} β₁ α₁) (Prod.{u3, u1} β₂ α₁)) (fun (_x : Equiv.{max (succ u2) (succ u1), max (succ u3) (succ u1)} (Prod.{u2, u1} β₁ α₁) (Prod.{u3, u1} β₂ α₁)) => (Prod.{u2, u1} β₁ α₁) -> (Prod.{u3, u1} β₂ α₁)) (Equiv.hasCoeToFun.{max (succ u2) (succ u1), max (succ u3) (succ u1)} (Prod.{u2, u1} β₁ α₁) (Prod.{u3, u1} β₂ α₁)) (Equiv.prodCongrLeft.{u1, u2, u3} α₁ β₁ β₂ e) (Prod.mk.{u2, u1} β₁ α₁ b a)) (Prod.mk.{u3, u1} β₂ α₁ (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} β₁ β₂) (fun (_x : Equiv.{succ u2, succ u3} β₁ β₂) => β₁ -> β₂) (Equiv.hasCoeToFun.{succ u2, succ u3} β₁ β₂) (e a) b) a)\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {β₁ : Type.{u1}} {β₂ : Type.{u3}} (e : α₁ -> (Equiv.{succ u1, succ u3} β₁ β₂)) (b : β₁) (a : α₁), Eq.{max (succ u3) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u1, u2} β₁ α₁) => Prod.{u3, u2} β₂ α₁) (Prod.mk.{u1, u2} β₁ α₁ b a)) (FunLike.coe.{max (max (succ u3) (succ u1)) (succ u2), max (succ u1) (succ u2), max (succ u3) (succ u2)} (Equiv.{max (succ u2) (succ u1), max (succ u2) (succ u3)} (Prod.{u1, u2} β₁ α₁) (Prod.{u3, u2} β₂ α₁)) (Prod.{u1, u2} β₁ α₁) (fun (_x : Prod.{u1, u2} β₁ α₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u1, u2} β₁ α₁) => Prod.{u3, u2} β₂ α₁) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u3) (succ u2)} (Prod.{u1, u2} β₁ α₁) (Prod.{u3, u2} β₂ α₁)) (Equiv.prodCongrLeft.{u2, u1, u3} α₁ β₁ β₂ e) (Prod.mk.{u1, u2} β₁ α₁ b a)) (Prod.mk.{u3, u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β₁) => β₂) b) α₁ (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (Equiv.{succ u1, succ u3} β₁ β₂) β₁ (fun (_x : β₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β₁) => β₂) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u3} β₁ β₂) (e a) b) a)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_left_apply Equiv.prodCongrLeft_applyₓ'. -/\n@[simp]\ntheorem prodCongrLeft_apply (b : β₁) (a : α₁) : prodCongrLeft e (b, a) = (e a b, a) :=\n  rfl\n#align equiv.prod_congr_left_apply Equiv.prodCongrLeft_apply\n\n/- warning: equiv.prod_congr_refl_right -> Equiv.prodCongr_refl_right is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {β₂ : Type.{u3}} (e : Equiv.{succ u2, succ u3} β₁ β₂), Eq.{max 1 (max (max (succ u2) (succ u1)) (succ u3) (succ u1)) (max (succ u3) (succ u1)) (succ u2) (succ u1)} (Equiv.{max (succ u2) (succ u1), max (succ u3) (succ u1)} (Prod.{u2, u1} β₁ α₁) (Prod.{u3, u1} β₂ α₁)) (Equiv.prodCongr.{u2, u1, u3, u1} β₁ α₁ β₂ α₁ e (Equiv.refl.{succ u1} α₁)) (Equiv.prodCongrLeft.{u1, u2, u3} α₁ β₁ β₂ (fun (_x : α₁) => e))\nbut is expected to have type\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u3}} {β₂ : Type.{u2}} (e : Equiv.{succ u3, succ u2} β₁ β₂), Eq.{max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ u1) (succ u3), max (succ u1) (succ u2)} (Prod.{u3, u1} β₁ α₁) (Prod.{u2, u1} β₂ α₁)) (Equiv.prodCongr.{u3, u2, u1, u1} β₁ β₂ α₁ α₁ e (Equiv.refl.{succ u1} α₁)) (Equiv.prodCongrLeft.{u1, u3, u2} α₁ β₁ β₂ (fun (_x : α₁) => e))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_refl_right Equiv.prodCongr_refl_rightₓ'. -/\ntheorem prodCongr_refl_right (e : β₁ ≃ β₂) :\n    prodCongr e (Equiv.refl α₁) = prodCongrLeft fun _ => e :=\n  by\n  ext ⟨a, b⟩ : 1\n  simp\n#align equiv.prod_congr_refl_right Equiv.prodCongr_refl_right\n\n#print Equiv.prodCongrRight /-\n/-- A family of equivalences `Π (a : α₁), β₁ ≃ β₂` generates an equivalence\nbetween `α₁ × β₁` and `α₁ × β₂`. -/\ndef prodCongrRight : α₁ × β₁ ≃ α₁ × β₂\n    where\n  toFun ab := ⟨ab.1, e ab.1 ab.2⟩\n  invFun ab := ⟨ab.1, (e ab.1).symm ab.2⟩\n  left_inv := by\n    rintro ⟨a, b⟩\n    simp\n  right_inv := by\n    rintro ⟨a, b⟩\n    simp\n#align equiv.prod_congr_right Equiv.prodCongrRight\n-/\n\n/- warning: equiv.prod_congr_right_apply -> Equiv.prodCongrRight_apply is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {β₂ : Type.{u3}} (e : α₁ -> (Equiv.{succ u2, succ u3} β₁ β₂)) (a : α₁) (b : β₁), Eq.{max (succ u1) (succ u3)} (Prod.{u1, u3} α₁ β₂) (coeFn.{max 1 (max (max (succ u1) (succ u2)) (succ u1) (succ u3)) (max (succ u1) (succ u3)) (succ u1) (succ u2), max (max (succ u1) (succ u2)) (succ u1) (succ u3)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u3} α₁ β₂)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u3} α₁ β₂)) => (Prod.{u1, u2} α₁ β₁) -> (Prod.{u1, u3} α₁ β₂)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u3} α₁ β₂)) (Equiv.prodCongrRight.{u1, u2, u3} α₁ β₁ β₂ e) (Prod.mk.{u1, u2} α₁ β₁ a b)) (Prod.mk.{u1, u3} α₁ β₂ a (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} β₁ β₂) (fun (_x : Equiv.{succ u2, succ u3} β₁ β₂) => β₁ -> β₂) (Equiv.hasCoeToFun.{succ u2, succ u3} β₁ β₂) (e a) b))\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {β₁ : Type.{u1}} {β₂ : Type.{u3}} (e : α₁ -> (Equiv.{succ u1, succ u3} β₁ β₂)) (a : α₁) (b : β₁), Eq.{max (succ u3) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α₁ β₁) => Prod.{u2, u3} α₁ β₂) (Prod.mk.{u2, u1} α₁ β₁ a b)) (FunLike.coe.{max (max (succ u3) (succ u1)) (succ u2), max (succ u1) (succ u2), max (succ u3) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u3) (succ u2)} (Prod.{u2, u1} α₁ β₁) (Prod.{u2, u3} α₁ β₂)) (Prod.{u2, u1} α₁ β₁) (fun (_x : Prod.{u2, u1} α₁ β₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α₁ β₁) => Prod.{u2, u3} α₁ β₂) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u3) (succ u2)} (Prod.{u2, u1} α₁ β₁) (Prod.{u2, u3} α₁ β₂)) (Equiv.prodCongrRight.{u2, u1, u3} α₁ β₁ β₂ e) (Prod.mk.{u2, u1} α₁ β₁ a b)) (Prod.mk.{u2, u3} α₁ ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β₁) => β₂) b) a (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (Equiv.{succ u1, succ u3} β₁ β₂) β₁ (fun (_x : β₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β₁) => β₂) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u3} β₁ β₂) (e a) b))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_right_apply Equiv.prodCongrRight_applyₓ'. -/\n@[simp]\ntheorem prodCongrRight_apply (a : α₁) (b : β₁) : prodCongrRight e (a, b) = (a, e a b) :=\n  rfl\n#align equiv.prod_congr_right_apply Equiv.prodCongrRight_apply\n\n/- warning: equiv.prod_congr_refl_left -> Equiv.prodCongr_refl_left is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {β₂ : Type.{u3}} (e : Equiv.{succ u2, succ u3} β₁ β₂), Eq.{max 1 (max (max (succ u1) (succ u2)) (succ u1) (succ u3)) (max (succ u1) (succ u3)) (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u3} α₁ β₂)) (Equiv.prodCongr.{u1, u2, u1, u3} α₁ β₁ α₁ β₂ (Equiv.refl.{succ u1} α₁) e) (Equiv.prodCongrRight.{u1, u2, u3} α₁ β₁ β₂ (fun (_x : α₁) => e))\nbut is expected to have type\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u3}} {β₂ : Type.{u2}} (e : Equiv.{succ u3, succ u2} β₁ β₂), Eq.{max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (succ u3) (succ u1), max (succ u2) (succ u1)} (Prod.{u1, u3} α₁ β₁) (Prod.{u1, u2} α₁ β₂)) (Equiv.prodCongr.{u1, u1, u3, u2} α₁ α₁ β₁ β₂ (Equiv.refl.{succ u1} α₁) e) (Equiv.prodCongrRight.{u1, u3, u2} α₁ β₁ β₂ (fun (_x : α₁) => e))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_refl_left Equiv.prodCongr_refl_leftₓ'. -/\ntheorem prodCongr_refl_left (e : β₁ ≃ β₂) :\n    prodCongr (Equiv.refl α₁) e = prodCongrRight fun _ => e :=\n  by\n  ext ⟨a, b⟩ : 1\n  simp\n#align equiv.prod_congr_refl_left Equiv.prodCongr_refl_left\n\n#print Equiv.prodCongrLeft_trans_prodComm /-\n@[simp]\ntheorem prodCongrLeft_trans_prodComm :\n    (prodCongrLeft e).trans (prodComm _ _) = (prodComm _ _).trans (prodCongrRight e) :=\n  by\n  ext ⟨a, b⟩ : 1\n  simp\n#align equiv.prod_congr_left_trans_prod_comm Equiv.prodCongrLeft_trans_prodComm\n-/\n\n#print Equiv.prodCongrRight_trans_prodComm /-\n@[simp]\ntheorem prodCongrRight_trans_prodComm :\n    (prodCongrRight e).trans (prodComm _ _) = (prodComm _ _).trans (prodCongrLeft e) :=\n  by\n  ext ⟨a, b⟩ : 1\n  simp\n#align equiv.prod_congr_right_trans_prod_comm Equiv.prodCongrRight_trans_prodComm\n-/\n\n#print Equiv.sigmaCongrRight_sigmaEquivProd /-\ntheorem sigmaCongrRight_sigmaEquivProd :\n    (sigmaCongrRight e).trans (sigmaEquivProd α₁ β₂) =\n      (sigmaEquivProd α₁ β₁).trans (prodCongrRight e) :=\n  by\n  ext ⟨a, b⟩ : 1\n  simp\n#align equiv.sigma_congr_right_sigma_equiv_prod Equiv.sigmaCongrRight_sigmaEquivProd\n-/\n\n/- warning: equiv.sigma_equiv_prod_sigma_congr_right -> Equiv.sigmaEquivProd_sigmaCongrRight is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {β₂ : Type.{u3}} (e : α₁ -> (Equiv.{succ u2, succ u3} β₁ β₂)), Eq.{max 1 (max (max (succ u1) (succ u2)) (succ u1) (succ u3)) (max (succ u1) (succ u3)) (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} α₁ β₁) (Sigma.{u1, u3} α₁ (fun (a : α₁) => β₂))) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} α₁ β₁) (Sigma.{u1, u2} α₁ (fun (_x : α₁) => β₁)) (Sigma.{u1, u3} α₁ (fun (a : α₁) => β₂)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u1, u2} α₁ (fun (_x : α₁) => β₁)) (Prod.{u1, u2} α₁ β₁) (Equiv.sigmaEquivProd.{u1, u2} α₁ β₁)) (Equiv.sigmaCongrRight.{u1, u2, u3} α₁ (fun (_x : α₁) => β₁) (fun (ᾰ : α₁) => β₂) e)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u3), max (succ u1) (succ u3)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u3} α₁ β₂) (Sigma.{u1, u3} α₁ (fun (a : α₁) => β₂)) (Equiv.prodCongrRight.{u1, u2, u3} α₁ β₁ β₂ e) (Equiv.symm.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (Sigma.{u1, u3} α₁ (fun (_x : α₁) => β₂)) (Prod.{u1, u3} α₁ β₂) (Equiv.sigmaEquivProd.{u1, u3} α₁ β₂)))\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {β₁ : Type.{u3}} {β₂ : Type.{u1}} (e : α₁ -> (Equiv.{succ u3, succ u1} β₁ β₂)), Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Equiv.{max (succ u3) (succ u2), max (succ u2) (succ u1)} (Prod.{u2, u3} α₁ β₁) (Sigma.{u2, u1} α₁ (fun (a : α₁) => β₂))) (Equiv.trans.{max (succ u3) (succ u2), max (succ u3) (succ u2), max (succ u2) (succ u1)} (Prod.{u2, u3} α₁ β₁) (Sigma.{u2, u3} α₁ (fun (_x : α₁) => β₁)) (Sigma.{u2, u1} α₁ (fun (a : α₁) => β₂)) (Equiv.symm.{max (succ u3) (succ u2), max (succ u3) (succ u2)} (Sigma.{u2, u3} α₁ (fun (_x : α₁) => β₁)) (Prod.{u2, u3} α₁ β₁) (Equiv.sigmaEquivProd.{u2, u3} α₁ β₁)) (Equiv.sigmaCongrRight.{u2, u3, u1} α₁ (fun (_x : α₁) => β₁) (fun (ᾰ : α₁) => β₂) e)) (Equiv.trans.{max (succ u3) (succ u2), max (succ u2) (succ u1), max (succ u2) (succ u1)} (Prod.{u2, u3} α₁ β₁) (Prod.{u2, u1} α₁ β₂) (Sigma.{u2, u1} α₁ (fun (a : α₁) => β₂)) (Equiv.prodCongrRight.{u2, u3, u1} α₁ β₁ β₂ e) (Equiv.symm.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (Sigma.{u2, u1} α₁ (fun (_x : α₁) => β₂)) (Prod.{u2, u1} α₁ β₂) (Equiv.sigmaEquivProd.{u2, u1} α₁ β₂)))\nCase conversion may be inaccurate. Consider using '#align equiv.sigma_equiv_prod_sigma_congr_right Equiv.sigmaEquivProd_sigmaCongrRightₓ'. -/\ntheorem sigmaEquivProd_sigmaCongrRight :\n    (sigmaEquivProd α₁ β₁).symm.trans (sigmaCongrRight e) =\n      (prodCongrRight e).trans (sigmaEquivProd α₁ β₂).symm :=\n  by\n  ext ⟨a, b⟩ : 1\n  simp\n#align equiv.sigma_equiv_prod_sigma_congr_right Equiv.sigmaEquivProd_sigmaCongrRight\n\n/- warning: equiv.of_fiber_equiv -> Equiv.ofFiberEquiv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> γ} {g : β -> γ}, (forall (c : γ), Equiv.{succ u1, succ u2} (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u3} γ (f a) c)) (Subtype.{succ u2} β (fun (b : β) => Eq.{succ u3} γ (g b) c))) -> (Equiv.{succ u1, succ u2} α β)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> β} {g : γ -> β}, (forall (c : β), Equiv.{succ u1, succ u3} (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) c)) (Subtype.{succ u3} γ (fun (b : γ) => Eq.{succ u2} β (g b) c))) -> (Equiv.{succ u1, succ u3} α γ)\nCase conversion may be inaccurate. Consider using '#align equiv.of_fiber_equiv Equiv.ofFiberEquivₓ'. -/\n-- See also `equiv.of_preimage_equiv`.\n/-- A family of equivalences between fibers gives an equivalence between domains. -/\n@[simps]\ndef ofFiberEquiv {α β γ : Type _} {f : α → γ} {g : β → γ}\n    (e : ∀ c, { a // f a = c } ≃ { b // g b = c }) : α ≃ β :=\n  (sigmaFiberEquiv f).symm.trans <| (Equiv.sigmaCongrRight e).trans (sigmaFiberEquiv g)\n#align equiv.of_fiber_equiv Equiv.ofFiberEquiv\n\n/- warning: equiv.of_fiber_equiv_map -> Equiv.ofFiberEquiv_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> γ} {g : β -> γ} (e : forall (c : γ), Equiv.{succ u1, succ u2} (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u3} γ (f a) c)) (Subtype.{succ u2} β (fun (b : β) => Eq.{succ u3} γ (g b) c))) (a : α), Eq.{succ u3} γ (g (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} α β) (fun (_x : Equiv.{succ u1, succ u2} α β) => α -> β) (Equiv.hasCoeToFun.{succ u1, succ u2} α β) (Equiv.ofFiberEquiv.{u1, u2, u3} α β γ (fun (a : α) => f a) (fun (b : β) => g b) e) a)) (f a)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} {f : α -> γ} {g : β -> γ} (e : forall (c : γ), Equiv.{succ u3, succ u2} (Subtype.{succ u3} α (fun (a : α) => Eq.{succ u1} γ (f a) c)) (Subtype.{succ u2} β (fun (b : β) => Eq.{succ u1} γ (g b) c))) (a : α), Eq.{succ u1} γ (g (FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u2} (Equiv.{succ u3, succ u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} α β) (Equiv.ofFiberEquiv.{u3, u1, u2} α γ β (fun (a : α) => f a) (fun (b : β) => g b) e) a)) (f a)\nCase conversion may be inaccurate. Consider using '#align equiv.of_fiber_equiv_map Equiv.ofFiberEquiv_mapₓ'. -/\ntheorem ofFiberEquiv_map {α β γ} {f : α → γ} {g : β → γ}\n    (e : ∀ c, { a // f a = c } ≃ { b // g b = c }) (a : α) : g (ofFiberEquiv e a) = f a :=\n  (_ : { b // g b = _ }).Prop\n#align equiv.of_fiber_equiv_map Equiv.ofFiberEquiv_map\n\n/- warning: equiv.prod_shear -> Equiv.prodShear is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{succ u1, succ u3} α₁ α₂) -> (α₁ -> (Equiv.{succ u2, succ u4} β₁ β₂)) -> (Equiv.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Prod.{u1, u2} α₁ β₁) (Prod.{u3, u4} α₂ β₂))\nbut is expected to have type\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} {α₂ : Type.{u3}} {β₂ : Type.{u4}}, (Equiv.{succ u1, succ u4} α₁ β₂) -> (α₁ -> (Equiv.{succ u2, succ u3} β₁ α₂)) -> (Equiv.{max (succ u2) (succ u1), max (succ u3) (succ u4)} (Prod.{u1, u2} α₁ β₁) (Prod.{u4, u3} β₂ α₂))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_shear Equiv.prodShearₓ'. -/\n/-- A variation on `equiv.prod_congr` where the equivalence in the second component can depend\n  on the first component. A typical example is a shear mapping, explaining the name of this\n  declaration. -/\n@[simps (config := { fullyApplied := false })]\ndef prodShear {α₁ β₁ α₂ β₂ : Type _} (e₁ : α₁ ≃ α₂) (e₂ : α₁ → β₁ ≃ β₂) : α₁ × β₁ ≃ α₂ × β₂\n    where\n  toFun := fun x : α₁ × β₁ => (e₁ x.1, e₂ x.1 x.2)\n  invFun := fun y : α₂ × β₂ => (e₁.symm y.1, (e₂ <| e₁.symm y.1).symm y.2)\n  left_inv := by\n    rintro ⟨x₁, y₁⟩\n    simp only [symm_apply_apply]\n  right_inv := by\n    rintro ⟨x₁, y₁⟩\n    simp only [apply_symm_apply]\n#align equiv.prod_shear Equiv.prodShear\n\nend ProdCongr\n\nnamespace Perm\n\nvariable {α₁ β₁ β₂ : Type _} [DecidableEq α₁] (a : α₁) (e : Perm β₁)\n\n#print Equiv.Perm.prodExtendRight /-\n/-- `prod_extend_right a e` extends `e : perm β` to `perm (α × β)` by sending `(a, b)` to\n`(a, e b)` and keeping the other `(a', b)` fixed. -/\ndef prodExtendRight : Perm (α₁ × β₁)\n    where\n  toFun ab := if ab.fst = a then (a, e ab.snd) else ab\n  invFun ab := if ab.fst = a then (a, e.symm ab.snd) else ab\n  left_inv := by\n    rintro ⟨k', x⟩\n    dsimp only\n    split_ifs with h <;> simp [h]\n  right_inv := by\n    rintro ⟨k', x⟩\n    dsimp only\n    split_ifs with h <;> simp [h]\n#align equiv.perm.prod_extend_right Equiv.Perm.prodExtendRight\n-/\n\n#print Equiv.Perm.prodExtendRight_apply_eq /-\n@[simp]\ntheorem prodExtendRight_apply_eq (b : β₁) : prodExtendRight a e (a, b) = (a, e b) :=\n  if_pos rfl\n#align equiv.perm.prod_extend_right_apply_eq Equiv.Perm.prodExtendRight_apply_eq\n-/\n\n/- warning: equiv.perm.prod_extend_right_apply_ne -> Equiv.Perm.prodExtendRight_apply_ne is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α₁] (e : Equiv.Perm.{succ u2} β₁) {a : α₁} {a' : α₁}, (Ne.{succ u1} α₁ a' a) -> (forall (b : β₁), Eq.{max (succ u1) (succ u2)} (Prod.{u1, u2} α₁ β₁) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Prod.{u1, u2} α₁ β₁)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u2} α₁ β₁)) => (Prod.{u1, u2} α₁ β₁) -> (Prod.{u1, u2} α₁ β₁)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u2} α₁ β₁)) (Equiv.Perm.prodExtendRight.{u1, u2} α₁ β₁ (fun (a : α₁) (b : α₁) => _inst_1 a b) a e) (Prod.mk.{u1, u2} α₁ β₁ a' b)) (Prod.mk.{u1, u2} α₁ β₁ a' b))\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {β₁ : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α₁] (e : Equiv.Perm.{succ u1} β₁) {a : α₁} {a' : α₁}, (Ne.{succ u2} α₁ a' a) -> (forall (b : β₁), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α₁ β₁) => Prod.{u2, u1} α₁ β₁) (Prod.mk.{u2, u1} α₁ β₁ a' b)) (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Prod.{u2, u1} α₁ β₁)) (Prod.{u2, u1} α₁ β₁) (fun (_x : Prod.{u2, u1} α₁ β₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α₁ β₁) => Prod.{u2, u1} α₁ β₁) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} α₁ β₁) (Prod.{u2, u1} α₁ β₁)) (Equiv.Perm.prodExtendRight.{u2, u1} α₁ β₁ (fun (a : α₁) (b : α₁) => _inst_1 a b) a e) (Prod.mk.{u2, u1} α₁ β₁ a' b)) (Prod.mk.{u2, u1} α₁ β₁ a' b))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.prod_extend_right_apply_ne Equiv.Perm.prodExtendRight_apply_neₓ'. -/\ntheorem prodExtendRight_apply_ne {a a' : α₁} (h : a' ≠ a) (b : β₁) :\n    prodExtendRight a e (a', b) = (a', b) :=\n  if_neg h\n#align equiv.perm.prod_extend_right_apply_ne Equiv.Perm.prodExtendRight_apply_ne\n\n#print Equiv.Perm.eq_of_prodExtendRight_ne /-\ntheorem eq_of_prodExtendRight_ne {e : Perm β₁} {a a' : α₁} {b : β₁}\n    (h : prodExtendRight a e (a', b) ≠ (a', b)) : a' = a :=\n  by\n  contrapose! h\n  exact prod_extend_right_apply_ne _ h _\n#align equiv.perm.eq_of_prod_extend_right_ne Equiv.Perm.eq_of_prodExtendRight_ne\n-/\n\n/- warning: equiv.perm.fst_prod_extend_right -> Equiv.Perm.fst_prodExtendRight is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α₁] (a : α₁) (e : Equiv.Perm.{succ u2} β₁) (ab : Prod.{u1, u2} α₁ β₁), Eq.{succ u1} α₁ (Prod.fst.{u1, u2} α₁ β₁ (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Prod.{u1, u2} α₁ β₁)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u2} α₁ β₁)) => (Prod.{u1, u2} α₁ β₁) -> (Prod.{u1, u2} α₁ β₁)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} α₁ β₁) (Prod.{u1, u2} α₁ β₁)) (Equiv.Perm.prodExtendRight.{u1, u2} α₁ β₁ (fun (a : α₁) (b : α₁) => _inst_1 a b) a e) ab)) (Prod.fst.{u1, u2} α₁ β₁ ab)\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {β₁ : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α₁] (a : α₁) (e : Equiv.Perm.{succ u1} β₁) (ab : Prod.{u2, u1} α₁ β₁), Eq.{succ u2} α₁ (Prod.fst.{u2, u1} α₁ β₁ (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Prod.{u2, u1} α₁ β₁)) (Prod.{u2, u1} α₁ β₁) (fun (_x : Prod.{u2, u1} α₁ β₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α₁ β₁) => Prod.{u2, u1} α₁ β₁) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} α₁ β₁) (Prod.{u2, u1} α₁ β₁)) (Equiv.Perm.prodExtendRight.{u2, u1} α₁ β₁ (fun (a : α₁) (b : α₁) => _inst_1 a b) a e) ab)) (Prod.fst.{u2, u1} α₁ β₁ ab)\nCase conversion may be inaccurate. Consider using '#align equiv.perm.fst_prod_extend_right Equiv.Perm.fst_prodExtendRightₓ'. -/\n@[simp]\ntheorem fst_prodExtendRight (ab : α₁ × β₁) : (prodExtendRight a e ab).fst = ab.fst :=\n  by\n  rw [prod_extend_right, [anonymous]]\n  split_ifs with h\n  · rw [h]\n  · rfl\n#align equiv.perm.fst_prod_extend_right Equiv.Perm.fst_prodExtendRight\n\nend Perm\n\nsection\n\n#print Equiv.arrowProdEquivProdArrow /-\n/-- The type of functions to a product `α × β` is equivalent to the type of pairs of functions\n`γ → α` and `γ → β`. -/\ndef arrowProdEquivProdArrow (α β γ : Type _) : (γ → α × β) ≃ (γ → α) × (γ → β) :=\n  ⟨fun f => (fun c => (f c).1, fun c => (f c).2), fun p c => (p.1 c, p.2 c), fun f =>\n    funext fun c => Prod.mk.eta, fun p => by\n    cases p\n    rfl⟩\n#align equiv.arrow_prod_equiv_prod_arrow Equiv.arrowProdEquivProdArrow\n-/\n\nopen Sum\n\n#print Equiv.sumArrowEquivProdArrow /-\n/-- The type of functions on a sum type `α ⊕ β` is equivalent to the type of pairs of functions\non `α` and on `β`. -/\ndef sumArrowEquivProdArrow (α β γ : Type _) : (Sum α β → γ) ≃ (α → γ) × (β → γ) :=\n  ⟨fun f => (f ∘ inl, f ∘ inr), fun p => Sum.elim p.1 p.2, fun f => by ext ⟨⟩ <;> rfl, fun p =>\n    by\n    cases p\n    rfl⟩\n#align equiv.sum_arrow_equiv_prod_arrow Equiv.sumArrowEquivProdArrow\n-/\n\n/- warning: equiv.sum_arrow_equiv_prod_arrow_apply_fst -> Equiv.sumArrowEquivProdArrow_apply_fst is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : (Sum.{u1, u2} α β) -> γ) (a : α), Eq.{succ u3} γ (Prod.fst.{max u1 u3, max u2 u3} (α -> γ) (β -> γ) (coeFn.{max 1 (max (max (max (succ u1) (succ u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))) (max (succ (max u1 u3)) (succ (max u2 u3))) (max (succ u1) (succ u2)) (succ u3), max (max (max (succ u1) (succ u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))} (Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) (fun (_x : Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) => ((Sum.{u1, u2} α β) -> γ) -> (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) (Equiv.hasCoeToFun.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} α β γ) f) a) (f (Sum.inl.{u1, u2} α β a))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (f : (Sum.{u3, u2} α β) -> γ) (a : α), Eq.{succ u1} γ (Prod.fst.{max u3 u1, max u2 u1} (α -> γ) (β -> γ) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (max (succ u3) (succ u2)) (succ u1), max (succ (max u2 u1)) (succ (max u3 u1))} ((Sum.{u3, u2} α β) -> γ) (Prod.{max u3 u1, max u2 u1} (α -> γ) (β -> γ))) ((Sum.{u3, u2} α β) -> γ) (fun (_x : (Sum.{u3, u2} α β) -> γ) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Sum.{u3, u2} α β) -> γ) => Prod.{max u3 u1, max u2 u1} (α -> γ) (β -> γ)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u3, u2} α β) -> γ) (Prod.{max u3 u1, max u2 u1} (α -> γ) (β -> γ))) (Equiv.sumArrowEquivProdArrow.{u3, u2, u1} α β γ) f) a) (f (Sum.inl.{u3, u2} α β a))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_arrow_equiv_prod_arrow_apply_fst Equiv.sumArrowEquivProdArrow_apply_fstₓ'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_apply_fst {α β γ} (f : Sum α β → γ) (a : α) :\n    (sumArrowEquivProdArrow α β γ f).1 a = f (inl a) :=\n  rfl\n#align equiv.sum_arrow_equiv_prod_arrow_apply_fst Equiv.sumArrowEquivProdArrow_apply_fst\n\n/- warning: equiv.sum_arrow_equiv_prod_arrow_apply_snd -> Equiv.sumArrowEquivProdArrow_apply_snd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : (Sum.{u1, u2} α β) -> γ) (b : β), Eq.{succ u3} γ (Prod.snd.{max u1 u3, max u2 u3} (α -> γ) (β -> γ) (coeFn.{max 1 (max (max (max (succ u1) (succ u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))) (max (succ (max u1 u3)) (succ (max u2 u3))) (max (succ u1) (succ u2)) (succ u3), max (max (max (succ u1) (succ u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))} (Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) (fun (_x : Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) => ((Sum.{u1, u2} α β) -> γ) -> (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) (Equiv.hasCoeToFun.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ))) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} α β γ) f) b) (f (Sum.inr.{u1, u2} α β b))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (f : (Sum.{u3, u2} α β) -> γ) (b : β), Eq.{succ u1} γ (Prod.snd.{max u3 u1, max u2 u1} (α -> γ) (β -> γ) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (max (succ u3) (succ u2)) (succ u1), max (succ (max u2 u1)) (succ (max u3 u1))} ((Sum.{u3, u2} α β) -> γ) (Prod.{max u3 u1, max u2 u1} (α -> γ) (β -> γ))) ((Sum.{u3, u2} α β) -> γ) (fun (_x : (Sum.{u3, u2} α β) -> γ) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Sum.{u3, u2} α β) -> γ) => Prod.{max u3 u1, max u2 u1} (α -> γ) (β -> γ)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u3, u2} α β) -> γ) (Prod.{max u3 u1, max u2 u1} (α -> γ) (β -> γ))) (Equiv.sumArrowEquivProdArrow.{u3, u2, u1} α β γ) f) b) (f (Sum.inr.{u3, u2} α β b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_arrow_equiv_prod_arrow_apply_snd Equiv.sumArrowEquivProdArrow_apply_sndₓ'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_apply_snd {α β γ} (f : Sum α β → γ) (b : β) :\n    (sumArrowEquivProdArrow α β γ f).2 b = f (inr b) :=\n  rfl\n#align equiv.sum_arrow_equiv_prod_arrow_apply_snd Equiv.sumArrowEquivProdArrow_apply_snd\n\n/- warning: equiv.sum_arrow_equiv_prod_arrow_symm_apply_inl -> Equiv.sumArrowEquivProdArrow_symm_apply_inl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> γ) (g : β -> γ) (a : α), Eq.{succ u3} γ (coeFn.{max 1 (max (max (succ (max u1 u3)) (succ (max u2 u3))) (max (succ u1) (succ u2)) (succ u3)) (max (max (succ u1) (succ u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ (max u1 u3)) (succ (max u2 u3))) (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) ((Sum.{u1, u2} α β) -> γ)) (fun (_x : Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) ((Sum.{u1, u2} α β) -> γ)) => (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) -> (Sum.{u1, u2} α β) -> γ) (Equiv.hasCoeToFun.{max (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) ((Sum.{u1, u2} α β) -> γ)) (Equiv.symm.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} α β γ)) (Prod.mk.{max u1 u3, max u2 u3} (α -> γ) (β -> γ) f g) (Sum.inl.{u1, u2} α β a)) (f a)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (f : α -> β) (g : γ -> β) (a : α), Eq.{succ u2} β (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Equiv.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) ((Sum.{u3, u1} α γ) -> β)) (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) (fun (_x : Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) => (Sum.{u3, u1} α γ) -> β) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) ((Sum.{u3, u1} α γ) -> β)) (Equiv.symm.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} ((Sum.{u3, u1} α γ) -> β) (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) (Equiv.sumArrowEquivProdArrow.{u3, u1, u2} α γ β)) (Prod.mk.{max u2 u3, max u2 u1} (α -> β) (γ -> β) f g) (Sum.inl.{u3, u1} α γ a)) (f a)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_arrow_equiv_prod_arrow_symm_apply_inl Equiv.sumArrowEquivProdArrow_symm_apply_inlₓ'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_symm_apply_inl {α β γ} (f : α → γ) (g : β → γ) (a : α) :\n    ((sumArrowEquivProdArrow α β γ).symm (f, g)) (inl a) = f a :=\n  rfl\n#align equiv.sum_arrow_equiv_prod_arrow_symm_apply_inl Equiv.sumArrowEquivProdArrow_symm_apply_inl\n\n/- warning: equiv.sum_arrow_equiv_prod_arrow_symm_apply_inr -> Equiv.sumArrowEquivProdArrow_symm_apply_inr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> γ) (g : β -> γ) (b : β), Eq.{succ u3} γ (coeFn.{max 1 (max (max (succ (max u1 u3)) (succ (max u2 u3))) (max (succ u1) (succ u2)) (succ u3)) (max (max (succ u1) (succ u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ (max u1 u3)) (succ (max u2 u3))) (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) ((Sum.{u1, u2} α β) -> γ)) (fun (_x : Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) ((Sum.{u1, u2} α β) -> γ)) => (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) -> (Sum.{u1, u2} α β) -> γ) (Equiv.hasCoeToFun.{max (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) ((Sum.{u1, u2} α β) -> γ)) (Equiv.symm.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} α β) -> γ) (Prod.{max u1 u3, max u2 u3} (α -> γ) (β -> γ)) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} α β γ)) (Prod.mk.{max u1 u3, max u2 u3} (α -> γ) (β -> γ) f g) (Sum.inr.{u1, u2} α β b)) (g b)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (f : α -> β) (g : γ -> β) (b : γ), Eq.{succ u2} β (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Equiv.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) ((Sum.{u3, u1} α γ) -> β)) (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) (fun (_x : Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) => (Sum.{u3, u1} α γ) -> β) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) ((Sum.{u3, u1} α γ) -> β)) (Equiv.symm.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} ((Sum.{u3, u1} α γ) -> β) (Prod.{max u3 u2, max u1 u2} (α -> β) (γ -> β)) (Equiv.sumArrowEquivProdArrow.{u3, u1, u2} α γ β)) (Prod.mk.{max u2 u3, max u2 u1} (α -> β) (γ -> β) f g) (Sum.inr.{u3, u1} α γ b)) (g b)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_arrow_equiv_prod_arrow_symm_apply_inr Equiv.sumArrowEquivProdArrow_symm_apply_inrₓ'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_symm_apply_inr {α β γ} (f : α → γ) (g : β → γ) (b : β) :\n    ((sumArrowEquivProdArrow α β γ).symm (f, g)) (inr b) = g b :=\n  rfl\n#align equiv.sum_arrow_equiv_prod_arrow_symm_apply_inr Equiv.sumArrowEquivProdArrow_symm_apply_inr\n\n#print Equiv.sumProdDistrib /-\n/-- Type product is right distributive with respect to type sum up to an equivalence. -/\ndef sumProdDistrib (α β γ : Sort _) : Sum α β × γ ≃ Sum (α × γ) (β × γ) :=\n  ⟨fun p => p.1.map (fun x => (x, p.2)) fun x => (x, p.2), fun s =>\n    s.elim (Prod.map inl id) (Prod.map inr id), by rintro ⟨_ | _, _⟩ <;> rfl, by\n    rintro (⟨_, _⟩ | ⟨_, _⟩) <;> rfl⟩\n#align equiv.sum_prod_distrib Equiv.sumProdDistrib\n-/\n\n/- warning: equiv.sum_prod_distrib_apply_left -> Equiv.sumProdDistrib_apply_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : α) (c : γ), Eq.{max (succ (max u1 u3)) (succ (max u2 u3))} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (coeFn.{max 1 (max (max (succ (max u1 u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))) (max (succ (max u1 u3)) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3), max (max (succ (max u1 u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))} (Equiv.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) (fun (_x : Equiv.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) => (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) -> (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) (Equiv.sumProdDistrib.{u1, u2, u3} α β γ) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inl.{u1, u2} α β a) c)) (Sum.inl.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ) (Prod.mk.{u1, u3} α γ a c))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : α) (c : β), Eq.{max (max (succ u2) (succ u1)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) => Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) (Prod.mk.{max u1 u3, u2} (Sum.{u3, u1} α γ) β (Sum.inl.{u3, u1} α γ a) c)) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Equiv.{max (succ u2) (succ (max u1 u3)), max (succ (max u2 u1)) (succ (max u2 u3))} (Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β))) (Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) (fun (_x : Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) => Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β))) (Equiv.sumProdDistrib.{u3, u1, u2} α γ β) (Prod.mk.{max u1 u3, u2} (Sum.{u3, u1} α γ) β (Sum.inl.{u3, u1} α γ a) c)) (Sum.inl.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β) (Prod.mk.{u3, u2} α β a c))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_apply_left Equiv.sumProdDistrib_apply_leftₓ'. -/\n@[simp]\ntheorem sumProdDistrib_apply_left {α β γ} (a : α) (c : γ) :\n    sumProdDistrib α β γ (Sum.inl a, c) = Sum.inl (a, c) :=\n  rfl\n#align equiv.sum_prod_distrib_apply_left Equiv.sumProdDistrib_apply_left\n\n/- warning: equiv.sum_prod_distrib_apply_right -> Equiv.sumProdDistrib_apply_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (b : β) (c : γ), Eq.{max (succ (max u1 u3)) (succ (max u2 u3))} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (coeFn.{max 1 (max (max (succ (max u1 u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))) (max (succ (max u1 u3)) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3), max (max (succ (max u1 u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3))} (Equiv.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) (fun (_x : Equiv.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) => (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) -> (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ))) (Equiv.sumProdDistrib.{u1, u2, u3} α β γ) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inr.{u1, u2} α β b) c)) (Sum.inr.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ) (Prod.mk.{u2, u3} β γ b c))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (b : α) (c : β), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) => Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) (Prod.mk.{max u3 u1, u2} (Sum.{u1, u3} γ α) β (Sum.inr.{u1, u3} γ α b) c)) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (succ u2) (succ (max u3 u1)), max (succ (max u2 u3)) (succ (max u2 u1))} (Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β))) (Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) (fun (_x : Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) => Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β))) (Equiv.sumProdDistrib.{u1, u3, u2} γ α β) (Prod.mk.{max u3 u1, u2} (Sum.{u1, u3} γ α) β (Sum.inr.{u1, u3} γ α b) c)) (Sum.inr.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β) (Prod.mk.{u3, u2} α β b c))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_apply_right Equiv.sumProdDistrib_apply_rightₓ'. -/\n@[simp]\ntheorem sumProdDistrib_apply_right {α β γ} (b : β) (c : γ) :\n    sumProdDistrib α β γ (Sum.inr b, c) = Sum.inr (b, c) :=\n  rfl\n#align equiv.sum_prod_distrib_apply_right Equiv.sumProdDistrib_apply_right\n\n/- warning: equiv.sum_prod_distrib_symm_apply_left -> Equiv.sumProdDistrib_symm_apply_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : Prod.{u1, u3} α γ), Eq.{max (succ (max u1 u2)) (succ u3)} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (coeFn.{max 1 (max (max (succ (max u1 u3)) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)) (max (succ (max u1 u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ (max u1 u3)) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)} (Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (fun (_x : Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) => (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) -> (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.hasCoeToFun.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Equiv.sumProdDistrib.{u1, u2, u3} α β γ)) (Sum.inl.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ) a)) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inl.{u1, u2} α β (Prod.fst.{u1, u3} α γ a)) (Prod.snd.{u1, u3} α γ a))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : Prod.{u3, u2} α β), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) => Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) (Sum.inl.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β) a)) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) (Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β)) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) (fun (_x : Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) => Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) (Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β)) (Equiv.symm.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Prod.{max u1 u3, u2} (Sum.{u3, u1} α γ) β) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β)) (Equiv.sumProdDistrib.{u3, u1, u2} α γ β)) (Sum.inl.{max u2 u3, max u2 u1} (Prod.{u3, u2} α β) (Prod.{u1, u2} γ β) a)) (Prod.mk.{max u1 u3, u2} (Sum.{u3, u1} α γ) β (Sum.inl.{u3, u1} α γ (Prod.fst.{u3, u2} α β a)) (Prod.snd.{u3, u2} α β a))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_symm_apply_left Equiv.sumProdDistrib_symm_apply_leftₓ'. -/\n@[simp]\ntheorem sumProdDistrib_symm_apply_left {α β γ} (a : α × γ) :\n    (sumProdDistrib α β γ).symm (inl a) = (inl a.1, a.2) :=\n  rfl\n#align equiv.sum_prod_distrib_symm_apply_left Equiv.sumProdDistrib_symm_apply_left\n\n/- warning: equiv.sum_prod_distrib_symm_apply_right -> Equiv.sumProdDistrib_symm_apply_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (b : Prod.{u2, u3} β γ), Eq.{max (succ (max u1 u2)) (succ u3)} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (coeFn.{max 1 (max (max (succ (max u1 u3)) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)) (max (succ (max u1 u2)) (succ u3)) (succ (max u1 u3)) (succ (max u2 u3)), max (max (succ (max u1 u3)) (succ (max u2 u3))) (succ (max u1 u2)) (succ u3)} (Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (fun (_x : Equiv.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) => (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) -> (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.hasCoeToFun.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{max u1 u2, u3} (Sum.{u1, u2} α β) γ) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ)) (Equiv.sumProdDistrib.{u1, u2, u3} α β γ)) (Sum.inr.{max u1 u3, max u2 u3} (Prod.{u1, u3} α γ) (Prod.{u2, u3} β γ) b)) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} α β) γ (Sum.inr.{u1, u2} α β (Prod.fst.{u2, u3} β γ b)) (Prod.snd.{u2, u3} β γ b))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (b : Prod.{u3, u2} α β), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) => Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) (Sum.inr.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β) b)) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) (Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β)) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) (fun (_x : Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) => Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) (Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β)) (Equiv.symm.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Prod.{max u3 u1, u2} (Sum.{u1, u3} γ α) β) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β)) (Equiv.sumProdDistrib.{u1, u3, u2} γ α β)) (Sum.inr.{max u2 u1, max u2 u3} (Prod.{u1, u2} γ β) (Prod.{u3, u2} α β) b)) (Prod.mk.{max u3 u1, u2} (Sum.{u1, u3} γ α) β (Sum.inr.{u1, u3} γ α (Prod.fst.{u3, u2} α β b)) (Prod.snd.{u3, u2} α β b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_symm_apply_right Equiv.sumProdDistrib_symm_apply_rightₓ'. -/\n@[simp]\ntheorem sumProdDistrib_symm_apply_right {α β γ} (b : β × γ) :\n    (sumProdDistrib α β γ).symm (inr b) = (inr b.1, b.2) :=\n  rfl\n#align equiv.sum_prod_distrib_symm_apply_right Equiv.sumProdDistrib_symm_apply_right\n\n#print Equiv.prodSumDistrib /-\n/-- Type product is left distributive with respect to type sum up to an equivalence. -/\ndef prodSumDistrib (α β γ : Sort _) : α × Sum β γ ≃ Sum (α × β) (α × γ) :=\n  calc\n    α × Sum β γ ≃ Sum β γ × α := prodComm _ _\n    _ ≃ Sum (β × α) (γ × α) := (sumProdDistrib _ _ _)\n    _ ≃ Sum (α × β) (α × γ) := sumCongr (prodComm _ _) (prodComm _ _)\n    \n#align equiv.prod_sum_distrib Equiv.prodSumDistrib\n-/\n\n/- warning: equiv.prod_sum_distrib_apply_left -> Equiv.prodSumDistrib_apply_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : α) (b : β), Eq.{max (succ (max u1 u2)) (succ (max u1 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (coeFn.{max 1 (max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ (max u1 u3))) (max (succ (max u1 u2)) (succ (max u1 u3))) (succ u1) (succ (max u2 u3)), max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ (max u1 u3))} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) => (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) -> (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) (Equiv.prodSumDistrib.{u1, u2, u3} α β γ) (Prod.mk.{u1, max u2 u3} α (Sum.{u2, u3} β γ) a (Sum.inl.{u2, u3} β γ b))) (Sum.inl.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ) (Prod.mk.{u1, u2} α β a b))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : α) (b : β), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) (Prod.mk.{u3, max u1 u2} α (Sum.{u2, u1} β γ) a (Sum.inl.{u2, u1} β γ b))) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ (max u1 u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} (Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ))) (Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (fun (_x : Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) => Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ))) (Equiv.prodSumDistrib.{u3, u2, u1} α β γ) (Prod.mk.{u3, max u1 u2} α (Sum.{u2, u1} β γ) a (Sum.inl.{u2, u1} β γ b))) (Sum.inl.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ) (Prod.mk.{u3, u2} α β a b))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_apply_left Equiv.prodSumDistrib_apply_leftₓ'. -/\n@[simp]\ntheorem prodSumDistrib_apply_left {α β γ} (a : α) (b : β) :\n    prodSumDistrib α β γ (a, Sum.inl b) = Sum.inl (a, b) :=\n  rfl\n#align equiv.prod_sum_distrib_apply_left Equiv.prodSumDistrib_apply_left\n\n/- warning: equiv.prod_sum_distrib_apply_right -> Equiv.prodSumDistrib_apply_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : α) (c : γ), Eq.{max (succ (max u1 u2)) (succ (max u1 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (coeFn.{max 1 (max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ (max u1 u3))) (max (succ (max u1 u2)) (succ (max u1 u3))) (succ u1) (succ (max u2 u3)), max (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ (max u1 u3))} (Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) => (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) -> (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ))) (Equiv.prodSumDistrib.{u1, u2, u3} α β γ) (Prod.mk.{u1, max u2 u3} α (Sum.{u2, u3} β γ) a (Sum.inr.{u2, u3} β γ c))) (Sum.inr.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ) (Prod.mk.{u1, u3} α γ a c))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : α) (c : β), Eq.{max (max (succ u2) (succ u1)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) => Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) (Prod.mk.{u3, max u2 u1} α (Sum.{u1, u2} γ β) a (Sum.inr.{u1, u2} γ β c))) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Equiv.{max (succ (max u2 u1)) (succ u3), max (succ (max u2 u3)) (succ (max u1 u3))} (Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β))) (Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) (fun (_x : Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) => Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β))) (Equiv.prodSumDistrib.{u3, u1, u2} α γ β) (Prod.mk.{u3, max u2 u1} α (Sum.{u1, u2} γ β) a (Sum.inr.{u1, u2} γ β c))) (Sum.inr.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β) (Prod.mk.{u3, u2} α β a c))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_apply_right Equiv.prodSumDistrib_apply_rightₓ'. -/\n@[simp]\ntheorem prodSumDistrib_apply_right {α β γ} (a : α) (c : γ) :\n    prodSumDistrib α β γ (a, Sum.inr c) = Sum.inr (a, c) :=\n  rfl\n#align equiv.prod_sum_distrib_apply_right Equiv.prodSumDistrib_apply_right\n\n/- warning: equiv.prod_sum_distrib_symm_apply_left -> Equiv.prodSumDistrib_symm_apply_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : Prod.{u1, u2} α β), Eq.{max (succ u1) (succ (max u2 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (coeFn.{max 1 (max (max (succ (max u1 u2)) (succ (max u1 u3))) (succ u1) (succ (max u2 u3))) (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ (max u1 u3)), max (max (succ (max u1 u2)) (succ (max u1 u3))) (succ u1) (succ (max u2 u3))} (Equiv.{max (succ (max u1 u2)) (succ (max u1 u3)), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (fun (_x : Equiv.{max (succ (max u1 u2)) (succ (max u1 u3)), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) => (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) -> (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ (max u1 u3)), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.symm.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Equiv.prodSumDistrib.{u1, u2, u3} α β γ)) (Sum.inl.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ) a)) (Prod.mk.{u1, max u2 u3} α (Sum.{u2, u3} β γ) (Prod.fst.{u1, u2} α β a) (Sum.inl.{u2, u3} β γ (Prod.snd.{u1, u2} α β a)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : Prod.{u3, u2} α β), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) => Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.inl.{max u2 u3, max u3 u1} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ) a)) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) (Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) (fun (_x : Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) => Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) (Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ))) (Equiv.symm.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Prod.{u3, max u1 u2} α (Sum.{u2, u1} β γ)) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ)) (Equiv.prodSumDistrib.{u3, u2, u1} α β γ)) (Sum.inl.{max u2 u3, max u3 u1} (Prod.{u3, u2} α β) (Prod.{u3, u1} α γ) a)) (Prod.mk.{u3, max u1 u2} α (Sum.{u2, u1} β γ) (Prod.fst.{u3, u2} α β a) (Sum.inl.{u2, u1} β γ (Prod.snd.{u3, u2} α β a)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_symm_apply_left Equiv.prodSumDistrib_symm_apply_leftₓ'. -/\n@[simp]\ntheorem prodSumDistrib_symm_apply_left {α β γ} (a : α × β) :\n    (prodSumDistrib α β γ).symm (inl a) = (a.1, inl a.2) :=\n  rfl\n#align equiv.prod_sum_distrib_symm_apply_left Equiv.prodSumDistrib_symm_apply_left\n\n/- warning: equiv.prod_sum_distrib_symm_apply_right -> Equiv.prodSumDistrib_symm_apply_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (a : Prod.{u1, u3} α γ), Eq.{max (succ u1) (succ (max u2 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (coeFn.{max 1 (max (max (succ (max u1 u2)) (succ (max u1 u3))) (succ u1) (succ (max u2 u3))) (max (succ u1) (succ (max u2 u3))) (succ (max u1 u2)) (succ (max u1 u3)), max (max (succ (max u1 u2)) (succ (max u1 u3))) (succ u1) (succ (max u2 u3))} (Equiv.{max (succ (max u1 u2)) (succ (max u1 u3)), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (fun (_x : Equiv.{max (succ (max u1 u2)) (succ (max u1 u3)), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) => (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) -> (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ (max u1 u3)), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ))) (Equiv.symm.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} α (Sum.{u2, u3} β γ)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ)) (Equiv.prodSumDistrib.{u1, u2, u3} α β γ)) (Sum.inr.{max u1 u2, max u1 u3} (Prod.{u1, u2} α β) (Prod.{u1, u3} α γ) a)) (Prod.mk.{u1, max u2 u3} α (Sum.{u2, u3} β γ) (Prod.fst.{u1, u3} α γ a) (Sum.inr.{u2, u3} β γ (Prod.snd.{u1, u3} α γ a)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (a : Prod.{u3, u2} α β), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) => Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) (Sum.inr.{max u3 u1, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β) a)) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) (Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β))) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) (fun (_x : Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) => Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) (Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β))) (Equiv.symm.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Prod.{u3, max u2 u1} α (Sum.{u1, u2} γ β)) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β)) (Equiv.prodSumDistrib.{u3, u1, u2} α γ β)) (Sum.inr.{max u3 u1, max u2 u3} (Prod.{u3, u1} α γ) (Prod.{u3, u2} α β) a)) (Prod.mk.{u3, max u2 u1} α (Sum.{u1, u2} γ β) (Prod.fst.{u3, u2} α β a) (Sum.inr.{u1, u2} γ β (Prod.snd.{u3, u2} α β a)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_symm_apply_right Equiv.prodSumDistrib_symm_apply_rightₓ'. -/\n@[simp]\ntheorem prodSumDistrib_symm_apply_right {α β γ} (a : α × γ) :\n    (prodSumDistrib α β γ).symm (inr a) = (a.1, inr a.2) :=\n  rfl\n#align equiv.prod_sum_distrib_symm_apply_right Equiv.prodSumDistrib_symm_apply_right\n\n#print Equiv.sigmaSumDistrib /-\n/-- An indexed sum of disjoint sums of types is equivalent to the sum of the indexed sums. -/\n@[simps]\ndef sigmaSumDistrib {ι : Type _} (α β : ι → Type _) :\n    (Σi, Sum (α i) (β i)) ≃ Sum (Σi, α i) (Σi, β i) :=\n  ⟨fun p => p.2.map (Sigma.mk p.1) (Sigma.mk p.1),\n    Sum.elim (Sigma.map id fun _ => Sum.inl) (Sigma.map id fun _ => Sum.inr), fun p => by\n    rcases p with ⟨i, a | b⟩ <;> rfl, fun p => by rcases p with (⟨i, a⟩ | ⟨i, b⟩) <;> rfl⟩\n#align equiv.sigma_sum_distrib Equiv.sigmaSumDistrib\n-/\n\n#print Equiv.sigmaProdDistrib /-\n/-- The product of an indexed sum of types (formally, a `sigma`-type `Σ i, α i`) by a type `β` is\nequivalent to the sum of products `Σ i, (α i × β)`. -/\ndef sigmaProdDistrib {ι : Type _} (α : ι → Type _) (β : Type _) : (Σi, α i) × β ≃ Σi, α i × β :=\n  ⟨fun p => ⟨p.1.1, (p.1.2, p.2)⟩, fun p => (⟨p.1, p.2.1⟩, p.2.2), fun p =>\n    by\n    rcases p with ⟨⟨_, _⟩, _⟩\n    rfl, fun p => by\n    rcases p with ⟨_, ⟨_, _⟩⟩\n    rfl⟩\n#align equiv.sigma_prod_distrib Equiv.sigmaProdDistrib\n-/\n\n#print Equiv.sigmaNatSucc /-\n/-- An equivalence that separates out the 0th fiber of `(Σ (n : ℕ), f n)`. -/\ndef sigmaNatSucc (f : ℕ → Type u) : (Σn, f n) ≃ Sum (f 0) (Σn, f (n + 1)) :=\n  ⟨fun x =>\n    @Sigma.casesOn ℕ f (fun _ => Sum (f 0) (Σn, f (n + 1))) x fun n =>\n      @Nat.casesOn (fun i => f i → Sum (f 0) (Σn : ℕ, f (n + 1))) n (fun x : f 0 => Sum.inl x)\n        fun (n : ℕ) (x : f n.succ) => Sum.inr ⟨n, x⟩,\n    Sum.elim (Sigma.mk 0) (Sigma.map Nat.succ fun _ => id), by rintro ⟨n | n, x⟩ <;> rfl, by\n    rintro (x | ⟨n, x⟩) <;> rfl⟩\n#align equiv.sigma_nat_succ Equiv.sigmaNatSucc\n-/\n\n#print Equiv.boolProdEquivSum /-\n/-- The product `bool × α` is equivalent to `α ⊕ α`. -/\n@[simps]\ndef boolProdEquivSum (α : Type u) : Bool × α ≃ Sum α α\n    where\n  toFun p := cond p.1 (inr p.2) (inl p.2)\n  invFun := Sum.elim (Prod.mk false) (Prod.mk true)\n  left_inv := by rintro ⟨_ | _, _⟩ <;> rfl\n  right_inv := by rintro (_ | _) <;> rfl\n#align equiv.bool_prod_equiv_sum Equiv.boolProdEquivSum\n-/\n\n#print Equiv.boolArrowEquivProd /-\n/-- The function type `bool → α` is equivalent to `α × α`. -/\n@[simps]\ndef boolArrowEquivProd (α : Type u) : (Bool → α) ≃ α × α\n    where\n  toFun f := (f true, f false)\n  invFun p b := cond b p.1 p.2\n  left_inv f := funext <| Bool.forall_bool.2 ⟨rfl, rfl⟩\n  right_inv := fun ⟨x, y⟩ => rfl\n#align equiv.bool_arrow_equiv_prod Equiv.boolArrowEquivProd\n-/\n\nend\n\nsection\n\nopen Sum Nat\n\n#print Equiv.natEquivNatSumPUnit /-\n/-- The set of natural numbers is equivalent to `ℕ ⊕ punit`. -/\ndef natEquivNatSumPUnit : ℕ ≃ Sum ℕ PUnit.{u + 1}\n    where\n  toFun n := Nat.casesOn n (inr PUnit.unit) inl\n  invFun := Sum.elim Nat.succ fun _ => 0\n  left_inv n := by cases n <;> rfl\n  right_inv := by rintro (_ | _ | _) <;> rfl\n#align equiv.nat_equiv_nat_sum_punit Equiv.natEquivNatSumPUnit\n-/\n\n#print Equiv.natSumPUnitEquivNat /-\n/-- `ℕ ⊕ punit` is equivalent to `ℕ`. -/\ndef natSumPUnitEquivNat : Sum ℕ PUnit.{u + 1} ≃ ℕ :=\n  natEquivNatSumPUnit.symm\n#align equiv.nat_sum_punit_equiv_nat Equiv.natSumPUnitEquivNat\n-/\n\n#print Equiv.intEquivNatSumNat /-\n/-- The type of integer numbers is equivalent to `ℕ ⊕ ℕ`. -/\ndef intEquivNatSumNat : ℤ ≃ Sum ℕ ℕ\n    where\n  toFun z := Int.casesOn z inl inr\n  invFun := Sum.elim coe Int.negSucc\n  left_inv := by rintro (m | n) <;> rfl\n  right_inv := by rintro (m | n) <;> rfl\n#align equiv.int_equiv_nat_sum_nat Equiv.intEquivNatSumNat\n-/\n\nend\n\n#print Equiv.listEquivOfEquiv /-\n/-- An equivalence between `α` and `β` generates an equivalence between `list α` and `list β`. -/\ndef listEquivOfEquiv {α β : Type _} (e : α ≃ β) : List α ≃ List β\n    where\n  toFun := List.map e\n  invFun := List.map e.symm\n  left_inv l := by rw [List.map_map, e.symm_comp_self, List.map_id]\n  right_inv l := by rw [List.map_map, e.self_comp_symm, List.map_id]\n#align equiv.list_equiv_of_equiv Equiv.listEquivOfEquiv\n-/\n\n#print Equiv.uniqueCongr /-\n/-- If `α` is equivalent to `β`, then `unique α` is equivalent to `unique β`. -/\ndef uniqueCongr (e : α ≃ β) : Unique α ≃ Unique β\n    where\n  toFun h := @Equiv.unique _ _ h e.symm\n  invFun h := @Equiv.unique _ _ h e\n  left_inv _ := Subsingleton.elim _ _\n  right_inv _ := Subsingleton.elim _ _\n#align equiv.unique_congr Equiv.uniqueCongr\n-/\n\n/- warning: equiv.is_empty_congr -> Equiv.isEmpty_congr is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}}, (Equiv.{u1, u2} α β) -> (Iff (IsEmpty.{u1} α) (IsEmpty.{u2} β))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}}, (Equiv.{u2, u1} α β) -> (Iff (IsEmpty.{u2} α) (IsEmpty.{u1} β))\nCase conversion may be inaccurate. Consider using '#align equiv.is_empty_congr Equiv.isEmpty_congrₓ'. -/\n/-- If `α` is equivalent to `β`, then `is_empty α` is equivalent to `is_empty β`. -/\ntheorem isEmpty_congr (e : α ≃ β) : IsEmpty α ↔ IsEmpty β :=\n  ⟨fun h => @Function.isEmpty _ _ h e.symm, fun h => @Function.isEmpty _ _ h e⟩\n#align equiv.is_empty_congr Equiv.isEmpty_congr\n\n/- warning: equiv.is_empty -> Equiv.isEmpty is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}}, (Equiv.{u1, u2} α β) -> (forall [_inst_1 : IsEmpty.{u2} β], IsEmpty.{u1} α)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}}, (Equiv.{u2, u1} α β) -> (forall [_inst_1 : IsEmpty.{u1} β], IsEmpty.{u2} α)\nCase conversion may be inaccurate. Consider using '#align equiv.is_empty Equiv.isEmptyₓ'. -/\nprotected theorem isEmpty (e : α ≃ β) [IsEmpty β] : IsEmpty α :=\n  e.isEmpty_congr.mpr ‹_›\n#align equiv.is_empty Equiv.isEmpty\n\nsection\n\nopen Subtype\n\n#print Equiv.subtypeEquiv /-\n/-- If `α` is equivalent to `β` and the predicates `p : α → Prop` and `q : β → Prop` are equivalent\nat corresponding points, then `{a // p a}` is equivalent to `{b // q b}`.\nFor the statement where `α = β`, that is, `e : perm α`, see `perm.subtype_perm`. -/\ndef subtypeEquiv {p : α → Prop} {q : β → Prop} (e : α ≃ β) (h : ∀ a, p a ↔ q (e a)) :\n    { a : α // p a } ≃ { b : β // q b }\n    where\n  toFun a := ⟨e a, (h _).mp a.Prop⟩\n  invFun b := ⟨e.symm b, (h _).mpr ((e.apply_symm_apply b).symm ▸ b.Prop)⟩\n  left_inv a := Subtype.ext <| by simp\n  right_inv b := Subtype.ext <| by simp\n#align equiv.subtype_equiv Equiv.subtypeEquiv\n-/\n\n#print Equiv.subtypeEquiv_refl /-\n@[simp]\ntheorem subtypeEquiv_refl {p : α → Prop} (h : ∀ a, p a ↔ p (Equiv.refl _ a) := fun a => Iff.rfl) :\n    (Equiv.refl α).subtypeEquiv h = Equiv.refl { a : α // p a } :=\n  by\n  ext\n  rfl\n#align equiv.subtype_equiv_refl Equiv.subtypeEquiv_refl\n-/\n\n/- warning: equiv.subtype_equiv_symm -> Equiv.subtypeEquiv_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : α -> Prop} {q : β -> Prop} (e : Equiv.{u1, u2} α β) (h : forall (a : α), Iff (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a))), Eq.{max 1 (max (max 1 u2) 1 u1) (max 1 u1) 1 u2} (Equiv.{max 1 u2, max 1 u1} (Subtype.{u2} β (fun (b : β) => q b)) (Subtype.{u1} α (fun (a : α) => p a))) (Equiv.symm.{max 1 u1, max 1 u2} (Subtype.{u1} α (fun (a : α) => p a)) (Subtype.{u2} β (fun (b : β) => q b)) (Equiv.subtypeEquiv.{u1, u2} α β (fun (a : α) => p a) q e h)) (Equiv.subtypeEquiv.{u2, u1} β α (fun (b : β) => q b) (fun (a : α) => p a) (Equiv.symm.{u1, u2} α β e) (fun (a : β) => Eq.mpr.{0} (Iff (q a) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a))) (Iff (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a))) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a))) ((fun (a : Prop) (a_1 : Prop) (e_1 : Eq.{1} Prop a a_1) (b : Prop) (b_1 : Prop) (e_2 : Eq.{1} Prop b b_1) => congr.{1, 1} Prop Prop (Iff a) (Iff a_1) b b_1 (congr_arg.{1, 1} Prop (Prop -> Prop) a a_1 Iff e_1) e_2) (q a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a))) ((fun (ᾰ : β) (ᾰ_1 : β) (e_1 : Eq.{u2} β ᾰ ᾰ_1) => congr_arg.{u2, 1} β Prop ᾰ ᾰ_1 q e_1) a (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a)) (Eq.symm.{u2} β (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a)) a (Equiv.apply_symm_apply.{u1, u2} α β e a))) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a)) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a)) (rfl.{1} Prop (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a)))) (Iff.symm (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a)) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a))) (h (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a)))))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {p : α -> Prop} {q : β -> Prop} (e : Equiv.{u2, u1} α β) (h : forall (a : α), Iff (p a) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) e a))), Eq.{max (max 1 u2) u1} (Equiv.{max 1 u1, max 1 u2} (Subtype.{u1} β (fun (b : β) => q b)) (Subtype.{u2} α (fun (a : α) => p a))) (Equiv.symm.{max 1 u2, max 1 u1} (Subtype.{u2} α (fun (a : α) => p a)) (Subtype.{u1} β (fun (b : β) => q b)) (Equiv.subtypeEquiv.{u2, u1} α β (fun (a : α) => p a) q e h)) (Equiv.subtypeEquiv.{u1, u2} β α (fun (b : β) => q b) (fun (a : α) => p a) (Equiv.symm.{u2, u1} α β e) (fun (a : β) => Eq.mpr.{0} (Iff (q a) (p (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) (Iff (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) (p (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) (eq_of_heq.{1} Prop (Iff (q a) (p (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) (Iff (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) (p (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) ((fun (a : Prop) (a' : Prop) (e'_1 : Eq.{1} Prop a a') (b : Prop) => Eq.casesOn.{0, 1} Prop a (fun (a._@.Init.Prelude._hyg.170 : Prop) (x : Eq.{1} Prop a a._@.Init.Prelude._hyg.170) => (Eq.{1} Prop a' a._@.Init.Prelude._hyg.170) -> (HEq.{0} (Eq.{1} Prop a a') e'_1 (Eq.{1} Prop a a._@.Init.Prelude._hyg.170) x) -> (HEq.{1} Prop (Iff a b) Prop (Iff a' b))) a' e'_1 (fun (h._@.Mathlib.Logic.Equiv.Basic._hyg.9722 : Eq.{1} Prop a' a) => Eq.ndrec.{0, 1} Prop a (fun (a'._@.Mathlib.Logic.Equiv.Basic._hyg.9719 : Prop) => forall (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 : Eq.{1} Prop a a'._@.Mathlib.Logic.Equiv.Basic._hyg.9719), (HEq.{0} (Eq.{1} Prop a a'._@.Mathlib.Logic.Equiv.Basic._hyg.9719) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 (Eq.{1} Prop a a) (Eq.refl.{1} Prop a)) -> (HEq.{1} Prop (Iff a b) Prop (Iff a'._@.Mathlib.Logic.Equiv.Basic._hyg.9719 b))) (fun (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 : Eq.{1} Prop a a) (h._@.Mathlib.Logic.Equiv.Basic._hyg.9723 : HEq.{0} (Eq.{1} Prop a a) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 (Eq.{1} Prop a a) (Eq.refl.{1} Prop a)) => Eq.ndrec.{0, 0} (Eq.{1} Prop a a) (Eq.refl.{1} Prop a) (fun (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 : Eq.{1} Prop a a) => HEq.{1} Prop (Iff a b) Prop (Iff a b)) (HEq.refl.{1} Prop (Iff a b)) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 (Eq.symm.{0} (Eq.{1} Prop a a) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 (Eq.refl.{1} Prop a) (eq_of_heq.{0} (Eq.{1} Prop a a) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9720 (Eq.refl.{1} Prop a) h._@.Mathlib.Logic.Equiv.Basic._hyg.9723))) a' (Eq.symm.{1} Prop a' a h._@.Mathlib.Logic.Equiv.Basic._hyg.9722) e'_1) (Eq.refl.{1} Prop a') (HEq.refl.{0} (Eq.{1} Prop a a') e'_1)) (q a) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) (eq_of_heq.{1} Prop (q a) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) ((fun (a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 : β) (a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 : β) (e'_1 : Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668) => Eq.casesOn.{0, u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 (fun (a._@.Init.Prelude._hyg.170 : β) (x : Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Init.Prelude._hyg.170) => (Eq.{u1} β a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Init.Prelude._hyg.170) -> (HEq.{0} (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668) e'_1 (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Init.Prelude._hyg.170) x) -> (HEq.{1} Prop (q a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) Prop (q a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668))) a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 e'_1 (fun (h._@.Mathlib.Logic.Equiv.Basic._hyg.9730 : Eq.{u1} β a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) => Eq.ndrec.{0, u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 (fun (a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668.9728 : β) => forall (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 : Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668.9728), (HEq.{0} (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668.9728) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (Eq.refl.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668)) -> (HEq.{1} Prop (q a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) Prop (q a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668.9728))) (fun (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 : Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (h._@.Mathlib.Logic.Equiv.Basic._hyg.9731 : HEq.{0} (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (Eq.refl.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668)) => Eq.ndrec.{0, 0} (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (Eq.refl.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (fun (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 : Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) => HEq.{1} Prop (q a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) Prop (q a._@.Mathlib.Logic.Equiv.Basic._hyg.9668)) (HEq.refl.{1} Prop (q a._@.Mathlib.Logic.Equiv.Basic._hyg.9668)) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 (Eq.symm.{0} (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 (Eq.refl.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (eq_of_heq.{0} (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 (Eq.refl.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) h._@.Mathlib.Logic.Equiv.Basic._hyg.9731))) a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 (Eq.symm.{u1} β a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 h._@.Mathlib.Logic.Equiv.Basic._hyg.9730) e'_1) (Eq.refl.{u1} β a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (HEq.refl.{0} (Eq.{u1} β a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668) e'_1)) a (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a)) (Eq.symm.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a)) (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a)) a (Equiv.apply_symm_apply.{u2, u1} α β e a)))) (p (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a)))) (Iff.symm (p (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a)) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a))) (h (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β e) a)))))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_symm Equiv.subtypeEquiv_symmₓ'. -/\n@[simp]\ntheorem subtypeEquiv_symm {p : α → Prop} {q : β → Prop} (e : α ≃ β) (h : ∀ a : α, p a ↔ q (e a)) :\n    (e.subtypeEquiv h).symm =\n      e.symm.subtypeEquiv fun a => by\n        convert(h <| e.symm a).symm\n        exact (e.apply_symm_apply a).symm :=\n  rfl\n#align equiv.subtype_equiv_symm Equiv.subtypeEquiv_symm\n\n/- warning: equiv.subtype_equiv_trans -> Equiv.subtypeEquiv_trans is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {p : α -> Prop} {q : β -> Prop} {r : γ -> Prop} (e : Equiv.{u1, u2} α β) (f : Equiv.{u2, u3} β γ) (h : forall (a : α), Iff (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a))) (h' : forall (b : β), Iff (q b) (r (coeFn.{max 1 (imax u2 u3) (imax u3 u2), imax u2 u3} (Equiv.{u2, u3} β γ) (fun (_x : Equiv.{u2, u3} β γ) => β -> γ) (Equiv.hasCoeToFun.{u2, u3} β γ) f b))), Eq.{max 1 (max (max 1 u1) 1 u3) (max 1 u3) 1 u1} (Equiv.{max 1 u1, max 1 u3} (Subtype.{u1} α (fun (a : α) => p a)) (Subtype.{u3} γ (fun (b : γ) => r b))) (Equiv.trans.{max 1 u1, max 1 u2, max 1 u3} (Subtype.{u1} α (fun (a : α) => p a)) (Subtype.{u2} β (fun (b : β) => q b)) (Subtype.{u3} γ (fun (b : γ) => r b)) (Equiv.subtypeEquiv.{u1, u2} α β (fun (a : α) => p a) q e h) (Equiv.subtypeEquiv.{u2, u3} β γ (fun (b : β) => q b) r f h')) (Equiv.subtypeEquiv.{u1, u3} α γ (fun (a : α) => p a) (fun (b : γ) => r b) (Equiv.trans.{u1, u2, u3} α β γ e f) (fun (a : α) => Iff.trans (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a)) (r (coeFn.{max 1 (imax u1 u3) (imax u3 u1), imax u1 u3} (Equiv.{u1, u3} α γ) (fun (_x : Equiv.{u1, u3} α γ) => α -> γ) (Equiv.hasCoeToFun.{u1, u3} α γ) (Equiv.trans.{u1, u2, u3} α β γ e f) a)) (h a) (h' (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a))))\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {γ : Sort.{u1}} {p : α -> Prop} {q : β -> Prop} {r : γ -> Prop} (e : Equiv.{u3, u2} α β) (f : Equiv.{u2, u1} β γ) (h : forall (a : α), Iff (p a) (q (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u2} α β) e a))) (h' : forall (b : β), Iff (q b) (r (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} β γ) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => γ) _x) (Equiv.instFunLikeEquiv.{u2, u1} β γ) f b))), Eq.{max (max 1 u3) u1} (Equiv.{max 1 u3, max 1 u1} (Subtype.{u3} α (fun (a : α) => p a)) (Subtype.{u1} γ (fun (b : γ) => r b))) (Equiv.trans.{max 1 u3, max 1 u2, max 1 u1} (Subtype.{u3} α (fun (a : α) => p a)) (Subtype.{u2} β (fun (b : β) => q b)) (Subtype.{u1} γ (fun (b : γ) => r b)) (Equiv.subtypeEquiv.{u3, u2} α β (fun (a : α) => p a) q e h) (Equiv.subtypeEquiv.{u2, u1} β γ (fun (b : β) => q b) r f h')) (Equiv.subtypeEquiv.{u3, u1} α γ (fun (a : α) => p a) r (Equiv.trans.{u3, u2, u1} α β γ e f) (fun (a : α) => Iff.trans (p a) (q (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u2} α β) e a)) (r (FunLike.coe.{max (max 1 u3) u1, u3, u1} (Equiv.{u3, u1} α γ) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => γ) _x) (Equiv.instFunLikeEquiv.{u3, u1} α γ) (Equiv.trans.{u3, u2, u1} α β γ e f) a)) (h a) (h' (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u2} α β) e a))))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_trans Equiv.subtypeEquiv_transₓ'. -/\n@[simp]\ntheorem subtypeEquiv_trans {p : α → Prop} {q : β → Prop} {r : γ → Prop} (e : α ≃ β) (f : β ≃ γ)\n    (h : ∀ a : α, p a ↔ q (e a)) (h' : ∀ b : β, q b ↔ r (f b)) :\n    (e.subtypeEquiv h).trans (f.subtypeEquiv h') =\n      (e.trans f).subtypeEquiv fun a => (h a).trans (h' <| e a) :=\n  rfl\n#align equiv.subtype_equiv_trans Equiv.subtypeEquiv_trans\n\n/- warning: equiv.subtype_equiv_apply -> Equiv.subtypeEquiv_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : α -> Prop} {q : β -> Prop} (e : Equiv.{u1, u2} α β) (h : forall (a : α), Iff (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a))) (x : Subtype.{u1} α (fun (x : α) => p x)), Eq.{max 1 u2} (Subtype.{u2} β (fun (b : β) => q b)) (coeFn.{max 1 (max (max 1 u1) 1 u2) (max 1 u2) 1 u1, max (max 1 u1) 1 u2} (Equiv.{max 1 u1, max 1 u2} (Subtype.{u1} α (fun (a : α) => (fun (a : α) => p a) a)) (Subtype.{u2} β (fun (b : β) => q b))) (fun (_x : Equiv.{max 1 u1, max 1 u2} (Subtype.{u1} α (fun (a : α) => (fun (a : α) => p a) a)) (Subtype.{u2} β (fun (b : β) => q b))) => (Subtype.{u1} α (fun (a : α) => (fun (a : α) => p a) a)) -> (Subtype.{u2} β (fun (b : β) => q b))) (Equiv.hasCoeToFun.{max 1 u1, max 1 u2} (Subtype.{u1} α (fun (a : α) => (fun (a : α) => p a) a)) (Subtype.{u2} β (fun (b : β) => q b))) (Equiv.subtypeEquiv.{u1, u2} α β (fun (a : α) => p a) q e h) x) (Subtype.mk.{u2} β (fun (b : β) => q b) (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (x : α) => p x)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeSubtype.{u1} α (fun (x : α) => p x))))) x)) (Iff.mp (p ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (x : α) => p x)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeSubtype.{u1} α (fun (x : α) => p x))))) x)) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (x : α) => p x)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeSubtype.{u1} α (fun (x : α) => p x))))) x))) (h ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} α (fun (x : α) => p x)) α (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeBase.{max 1 u1, u1} (Subtype.{u1} α (fun (x : α) => p x)) α (coeSubtype.{u1} α (fun (x : α) => p x))))) x)) (Subtype.property.{u1} α (fun (x : α) => p x) x)))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {p : α -> Prop} {q : β -> Prop} (e : Equiv.{u2, u1} α β) (h : forall (a : α), Iff (p a) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) e a))) (x : Subtype.{u2} α (fun (x : α) => p x)), Eq.{max 1 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{u2} α (fun (a : α) => p a)) => Subtype.{u1} β (fun (b : β) => q b)) x) (FunLike.coe.{max (max 1 u2) u1, max 1 u2, max 1 u1} (Equiv.{max 1 u2, max 1 u1} (Subtype.{u2} α (fun (a : α) => p a)) (Subtype.{u1} β (fun (b : β) => q b))) (Subtype.{u2} α (fun (a : α) => p a)) (fun (_x : Subtype.{u2} α (fun (a : α) => p a)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{u2} α (fun (a : α) => p a)) => Subtype.{u1} β (fun (b : β) => q b)) _x) (Equiv.instFunLikeEquiv.{max 1 u2, max 1 u1} (Subtype.{u2} α (fun (a : α) => p a)) (Subtype.{u1} β (fun (b : β) => q b))) (Equiv.subtypeEquiv.{u2, u1} α β (fun (a : α) => p a) q e h) x) (Subtype.mk.{u1} β (fun (b : β) => q b) (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (Subtype.val.{u2} α (fun (x : α) => p x) x)) (Iff.mp (p (Subtype.val.{u2} α (fun (x : α) => p x) x)) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) e (Subtype.val.{u2} α (fun (x : α) => p x) x))) (h (Subtype.val.{u2} α (fun (x : α) => p x) x)) (Subtype.property.{u2} α (fun (x : α) => p x) x)))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_apply Equiv.subtypeEquiv_applyₓ'. -/\n@[simp]\ntheorem subtypeEquiv_apply {p : α → Prop} {q : β → Prop} (e : α ≃ β) (h : ∀ a : α, p a ↔ q (e a))\n    (x : { x // p x }) : e.subtypeEquiv h x = ⟨e x, (h _).1 x.2⟩ :=\n  rfl\n#align equiv.subtype_equiv_apply Equiv.subtypeEquiv_apply\n\n#print Equiv.subtypeEquivRight /-\n/-- If two predicates `p` and `q` are pointwise equivalent, then `{x // p x}` is equivalent to\n`{x // q x}`. -/\n@[simps]\ndef subtypeEquivRight {p q : α → Prop} (e : ∀ x, p x ↔ q x) : { x // p x } ≃ { x // q x } :=\n  subtypeEquiv (Equiv.refl _) e\n#align equiv.subtype_equiv_right Equiv.subtypeEquivRight\n-/\n\n/- warning: equiv.subtype_equiv_of_subtype -> Equiv.subtypeEquivOfSubtype is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : β -> Prop} (e : Equiv.{u1, u2} α β), Equiv.{max 1 u1, max 1 u2} (Subtype.{u1} α (fun (a : α) => p (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a))) (Subtype.{u2} β (fun (b : β) => p b))\nbut is expected to have type\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : α -> Prop} (e : Equiv.{u2, u1} β α), Equiv.{max 1 u2, max 1 u1} (Subtype.{u2} β (fun (a : β) => p (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Equiv.{u2, u1} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u1} β α) e a))) (Subtype.{u1} α (fun (b : α) => p b))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_of_subtype Equiv.subtypeEquivOfSubtypeₓ'. -/\n/-- If `α ≃ β`, then for any predicate `p : β → Prop` the subtype `{a // p (e a)}` is equivalent\nto the subtype `{b // p b}`. -/\ndef subtypeEquivOfSubtype {p : β → Prop} (e : α ≃ β) : { a : α // p (e a) } ≃ { b : β // p b } :=\n  subtypeEquiv e <| by simp\n#align equiv.subtype_equiv_of_subtype Equiv.subtypeEquivOfSubtype\n\n#print Equiv.subtypeEquivOfSubtype' /-\n/-- If `α ≃ β`, then for any predicate `p : α → Prop` the subtype `{a // p a}` is equivalent\nto the subtype `{b // p (e.symm b)}`. This version is used by `equiv_rw`. -/\ndef subtypeEquivOfSubtype' {p : α → Prop} (e : α ≃ β) :\n    { a : α // p a } ≃ { b : β // p (e.symm b) } :=\n  e.symm.subtypeEquivOfSubtype.symm\n#align equiv.subtype_equiv_of_subtype' Equiv.subtypeEquivOfSubtype'\n-/\n\n#print Equiv.subtypeEquivProp /-\n/-- If two predicates are equal, then the corresponding subtypes are equivalent. -/\ndef subtypeEquivProp {α : Sort _} {p q : α → Prop} (h : p = q) : Subtype p ≃ Subtype q :=\n  subtypeEquiv (Equiv.refl α) fun a => h ▸ Iff.rfl\n#align equiv.subtype_equiv_prop Equiv.subtypeEquivProp\n-/\n\n#print Equiv.subtypeSubtypeEquivSubtypeExists /-\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. This\nversion allows the “inner” predicate to depend on `h : p a`. -/\n@[simps]\ndef subtypeSubtypeEquivSubtypeExists {α : Sort u} (p : α → Prop) (q : Subtype p → Prop) :\n    Subtype q ≃ { a : α // ∃ h : p a, q ⟨a, h⟩ } :=\n  ⟨fun a =>\n    ⟨a, a.1.2, by\n      rcases a with ⟨⟨a, hap⟩, haq⟩\n      exact haq⟩,\n    fun a => ⟨⟨a, a.2.fst⟩, a.2.snd⟩, fun ⟨⟨a, ha⟩, h⟩ => rfl, fun ⟨a, h₁, h₂⟩ => rfl⟩\n#align equiv.subtype_subtype_equiv_subtype_exists Equiv.subtypeSubtypeEquivSubtypeExists\n-/\n\n/- warning: equiv.subtype_subtype_equiv_subtype_inter -> Equiv.subtypeSubtypeEquivSubtypeInter is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} (p : α -> Prop) (q : α -> Prop), Equiv.{max 1 u1, max 1 u1} (Subtype.{max 1 u1} (Subtype.{u1} α p) (fun (x : Subtype.{u1} α p) => q (Subtype.val.{u1} α p x))) (Subtype.{u1} α (fun (x : α) => And (p x) (q x)))\nbut is expected to have type\n  forall {α : Type.{u1}} (p : α -> Prop) (q : α -> Prop), Equiv.{succ u1, succ u1} (Subtype.{succ u1} (Subtype.{succ u1} α p) (fun (x : Subtype.{succ u1} α p) => q (Subtype.val.{succ u1} α p x))) (Subtype.{succ u1} α (fun (x : α) => And (p x) (q x)))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_subtype_equiv_subtype_inter Equiv.subtypeSubtypeEquivSubtypeInterₓ'. -/\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. -/\n@[simps]\ndef subtypeSubtypeEquivSubtypeInter {α : Sort u} (p q : α → Prop) :\n    { x : Subtype p // q x.1 } ≃ Subtype fun x => p x ∧ q x :=\n  (subtypeSubtypeEquivSubtypeExists p _).trans <| subtypeEquivRight fun x => exists_prop\n#align equiv.subtype_subtype_equiv_subtype_inter Equiv.subtypeSubtypeEquivSubtypeInter\n\n#print Equiv.subtypeSubtypeEquivSubtype /-\n/-- If the outer subtype has more restrictive predicate than the inner one,\nthen we can drop the latter. -/\n@[simps]\ndef subtypeSubtypeEquivSubtype {α : Type u} {p q : α → Prop} (h : ∀ {x}, q x → p x) :\n    { x : Subtype p // q x.1 } ≃ Subtype q :=\n  (subtypeSubtypeEquivSubtypeInter p _).trans <| subtypeEquivRight fun x => and_iff_right_of_imp h\n#align equiv.subtype_subtype_equiv_subtype Equiv.subtypeSubtypeEquivSubtype\n-/\n\n#print Equiv.subtypeUnivEquiv /-\n/-- If a proposition holds for all elements, then the subtype is\nequivalent to the original type. -/\n@[simps apply symm_apply]\ndef subtypeUnivEquiv {α : Type u} {p : α → Prop} (h : ∀ x, p x) : Subtype p ≃ α :=\n  ⟨fun x => x, fun x => ⟨x, h x⟩, fun x => Subtype.eq rfl, fun x => rfl⟩\n#align equiv.subtype_univ_equiv Equiv.subtypeUnivEquiv\n-/\n\n/- warning: equiv.subtype_sigma_equiv -> Equiv.subtypeSigmaEquiv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (p : α -> Type.{u2}) (q : α -> Prop), Equiv.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (Sigma.{u1, u2} α p) (fun (y : Sigma.{u1, u2} α p) => q (Sigma.fst.{u1, u2} α p y))) (Sigma.{u1, u2} (Subtype.{succ u1} α q) (fun (x : Subtype.{succ u1} α q) => p (Subtype.val.{succ u1} α q x)))\nbut is expected to have type\n  forall {α : Type.{u2}} (p : α -> Type.{u1}) (q : α -> Prop), Equiv.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (Sigma.{u2, u1} α p) (fun (y : Sigma.{u2, u1} α p) => q (Sigma.fst.{u2, u1} α p y))) (Sigma.{u2, u1} (Subtype.{succ u2} α q) (fun (x : Subtype.{succ u2} α q) => p (Subtype.val.{succ u2} α q x)))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_sigma_equiv Equiv.subtypeSigmaEquivₓ'. -/\n/-- A subtype of a sigma-type is a sigma-type over a subtype. -/\ndef subtypeSigmaEquiv {α : Type u} (p : α → Type v) (q : α → Prop) :\n    { y : Sigma p // q y.1 } ≃ Σx : Subtype q, p x.1 :=\n  ⟨fun x => ⟨⟨x.1.1, x.2⟩, x.1.2⟩, fun x => ⟨⟨x.1.1, x.2⟩, x.1.2⟩, fun ⟨⟨x, h⟩, y⟩ => rfl,\n    fun ⟨⟨x, y⟩, h⟩ => rfl⟩\n#align equiv.subtype_sigma_equiv Equiv.subtypeSigmaEquiv\n\n/- warning: equiv.sigma_subtype_equiv_of_subset -> Equiv.sigmaSubtypeEquivOfSubset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (p : α -> Type.{u2}) (q : α -> Prop), (forall (x : α), (p x) -> (q x)) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u1, u2} (Subtype.{succ u1} α q) (fun (x : Subtype.{succ u1} α q) => p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} α q) α (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} α q) α (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} α q) α (coeBase.{succ u1, succ u1} (Subtype.{succ u1} α q) α (coeSubtype.{succ u1} α (fun (x : α) => q x))))) x))) (Sigma.{u1, u2} α (fun (x : α) => p x)))\nbut is expected to have type\n  forall {α : Type.{u2}} (p : α -> Type.{u1}) (q : α -> Prop), (forall (x : α), (p x) -> (q x)) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u2, u1} (Subtype.{succ u2} α q) (fun (x : Subtype.{succ u2} α q) => p (Subtype.val.{succ u2} α q x))) (Sigma.{u2, u1} α (fun (x : α) => p x)))\nCase conversion may be inaccurate. Consider using '#align equiv.sigma_subtype_equiv_of_subset Equiv.sigmaSubtypeEquivOfSubsetₓ'. -/\n/-- A sigma type over a subtype is equivalent to the sigma set over the original type,\nif the fiber is empty outside of the subset -/\ndef sigmaSubtypeEquivOfSubset {α : Type u} (p : α → Type v) (q : α → Prop) (h : ∀ x, p x → q x) :\n    (Σx : Subtype q, p x) ≃ Σx : α, p x :=\n  (subtypeSigmaEquiv p q).symm.trans <| subtypeUnivEquiv fun x => h x.1 x.2\n#align equiv.sigma_subtype_equiv_of_subset Equiv.sigmaSubtypeEquivOfSubset\n\n#print Equiv.sigmaSubtypeFiberEquiv /-\n/-- If a predicate `p : β → Prop` is true on the range of a map `f : α → β`, then\n`Σ y : {y // p y}, {x // f x = y}` is equivalent to `α`. -/\ndef sigmaSubtypeFiberEquiv {α : Type u} {β : Type v} (f : α → β) (p : β → Prop) (h : ∀ x, p (f x)) :\n    (Σy : Subtype p, { x : α // f x = y }) ≃ α :=\n  calc\n    _ ≃ Σy : β, { x : α // f x = y } := sigmaSubtypeEquivOfSubset _ p fun y ⟨x, h'⟩ => h' ▸ h x\n    _ ≃ α := sigmaFiberEquiv f\n    \n#align equiv.sigma_subtype_fiber_equiv Equiv.sigmaSubtypeFiberEquiv\n-/\n\n#print Equiv.sigmaSubtypeFiberEquivSubtype /-\n/-- If for each `x` we have `p x ↔ q (f x)`, then `Σ y : {y // q y}, f ⁻¹' {y}` is equivalent\nto `{x // p x}`. -/\ndef sigmaSubtypeFiberEquivSubtype {α : Type u} {β : Type v} (f : α → β) {p : α → Prop}\n    {q : β → Prop} (h : ∀ x, p x ↔ q (f x)) : (Σy : Subtype q, { x : α // f x = y }) ≃ Subtype p :=\n  calc\n    (Σy : Subtype q, { x : α // f x = y }) ≃\n        Σy : Subtype q, { x : Subtype p // Subtype.mk (f x) ((h x).1 x.2) = y } :=\n      by\n      apply sigma_congr_right\n      intro y\n      symm\n      refine' (subtype_subtype_equiv_subtype_exists _ _).trans (subtype_equiv_right _)\n      intro x\n      exact\n        ⟨fun ⟨hp, h'⟩ => congr_arg Subtype.val h', fun h' =>\n          ⟨(h x).2 (h'.symm ▸ y.2), Subtype.eq h'⟩⟩\n    _ ≃ Subtype p := sigmaFiberEquiv fun x : Subtype p => (⟨f x, (h x).1 x.property⟩ : Subtype q)\n    \n#align equiv.sigma_subtype_fiber_equiv_subtype Equiv.sigmaSubtypeFiberEquivSubtype\n-/\n\n/- warning: equiv.sigma_option_equiv_of_some -> Equiv.sigmaOptionEquivOfSome is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (p : (Option.{u1} α) -> Type.{u2}), ((p (Option.none.{u1} α)) -> False) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u1, u2} (Option.{u1} α) (fun (x : Option.{u1} α) => p x)) (Sigma.{u1, u2} α (fun (x : α) => p (Option.some.{u1} α x))))\nbut is expected to have type\n  forall {α : Type.{u2}} (p : (Option.{u2} α) -> Type.{u1}), ((p (Option.none.{u2} α)) -> False) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u2, u1} (Option.{u2} α) (fun (x : Option.{u2} α) => p x)) (Sigma.{u2, u1} α (fun (x : α) => p (Option.some.{u2} α x))))\nCase conversion may be inaccurate. Consider using '#align equiv.sigma_option_equiv_of_some Equiv.sigmaOptionEquivOfSomeₓ'. -/\n/-- A sigma type over an `option` is equivalent to the sigma set over the original type,\nif the fiber is empty at none. -/\ndef sigmaOptionEquivOfSome {α : Type u} (p : Option α → Type v) (h : p none → False) :\n    (Σx : Option α, p x) ≃ Σx : α, p (some x) :=\n  haveI h' : ∀ x, p x → x.isSome := by\n    intro x\n    cases x\n    · intro n\n      exfalso\n      exact h n\n    · intro s\n      exact rfl\n  (sigma_subtype_equiv_of_subset _ _ h').symm.trans (sigma_congr_left' (option_is_some_equiv α))\n#align equiv.sigma_option_equiv_of_some Equiv.sigmaOptionEquivOfSome\n\n#print Equiv.piEquivSubtypeSigma /-\n/-- The `pi`-type `Π i, π i` is equivalent to the type of sections `f : ι → Σ i, π i` of the\n`sigma` type such that for all `i` we have `(f i).fst = i`. -/\ndef piEquivSubtypeSigma (ι : Type _) (π : ι → Type _) :\n    (∀ i, π i) ≃ { f : ι → Σi, π i // ∀ i, (f i).1 = i } :=\n  ⟨fun f => ⟨fun i => ⟨i, f i⟩, fun i => rfl⟩, fun f i => by rw [← f.2 i]; exact (f.1 i).2, fun f =>\n    funext fun i => rfl, fun ⟨f, hf⟩ =>\n    Subtype.eq <|\n      funext fun i =>\n        Sigma.eq (hf i).symm <| eq_of_hEq <| rec_heq_of_heq _ <| rec_heq_of_heq _ <| HEq.refl _⟩\n#align equiv.pi_equiv_subtype_sigma Equiv.piEquivSubtypeSigma\n-/\n\n/- warning: equiv.subtype_pi_equiv_pi -> Equiv.subtypePiEquivPi is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : α -> Sort.{u2}} {p : forall (a : α), (β a) -> Prop}, Equiv.{max 1 (imax u1 u2), max u1 1 u2} (Subtype.{imax u1 u2} (forall (a : α), β a) (fun (f : forall (a : α), β a) => forall (a : α), p a (f a))) (forall (a : α), Subtype.{u2} (β a) (fun (b : β a) => p a b))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : α -> Sort.{u1}} {p : forall (a : α), (β a) -> Prop}, Equiv.{max 1 (imax u2 u1), max (max 1 u1) u2} (Subtype.{imax u2 u1} (forall (a : α), β a) (fun (f : forall (a : α), β a) => forall (a : α), p a (f a))) (forall (a : α), Subtype.{u1} (β a) (fun (b : β a) => p a b))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_pi_equiv_pi Equiv.subtypePiEquivPiₓ'. -/\n/-- The set of functions `f : Π a, β a` such that for all `a` we have `p a (f a)` is equivalent\nto the set of functions `Π a, {b : β a // p a b}`. -/\ndef subtypePiEquivPi {α : Sort u} {β : α → Sort v} {p : ∀ a, β a → Prop} :\n    { f : ∀ a, β a // ∀ a, p a (f a) } ≃ ∀ a, { b : β a // p a b } :=\n  ⟨fun f a => ⟨f.1 a, f.2 a⟩, fun f => ⟨fun a => (f a).1, fun a => (f a).2⟩,\n    by\n    rintro ⟨f, h⟩\n    rfl, by\n    rintro f\n    funext a\n    exact Subtype.ext_val rfl⟩\n#align equiv.subtype_pi_equiv_pi Equiv.subtypePiEquivPi\n\n#print Equiv.subtypeProdEquivProd /-\n/-- A subtype of a product defined by componentwise conditions\nis equivalent to a product of subtypes. -/\ndef subtypeProdEquivProd {α : Type u} {β : Type v} {p : α → Prop} {q : β → Prop} :\n    { c : α × β // p c.1 ∧ q c.2 } ≃ { a // p a } × { b // q b } :=\n  ⟨fun x => ⟨⟨x.1.1, x.2.1⟩, ⟨x.1.2, x.2.2⟩⟩, fun x => ⟨⟨x.1.1, x.2.1⟩, ⟨x.1.2, x.2.2⟩⟩,\n    fun ⟨⟨_, _⟩, ⟨_, _⟩⟩ => rfl, fun ⟨⟨_, _⟩, ⟨_, _⟩⟩ => rfl⟩\n#align equiv.subtype_prod_equiv_prod Equiv.subtypeProdEquivProd\n-/\n\n#print Equiv.subtypeProdEquivSigmaSubtype /-\n/-- A subtype of a `prod` is equivalent to a sigma type whose fibers are subtypes. -/\ndef subtypeProdEquivSigmaSubtype {α β : Type _} (p : α → β → Prop) :\n    { x : α × β // p x.1 x.2 } ≃ Σa, { b : β // p a b }\n    where\n  toFun x := ⟨x.1.1, x.1.2, x.Prop⟩\n  invFun x := ⟨⟨x.1, x.2⟩, x.2.Prop⟩\n  left_inv x := by ext <;> rfl\n  right_inv := fun ⟨a, b, pab⟩ => rfl\n#align equiv.subtype_prod_equiv_sigma_subtype Equiv.subtypeProdEquivSigmaSubtype\n-/\n\n#print Equiv.piEquivPiSubtypeProd /-\n/-- The type `Π (i : α), β i` can be split as a product by separating the indices in `α`\ndepending on whether they satisfy a predicate `p` or not. -/\n@[simps]\ndef piEquivPiSubtypeProd {α : Type _} (p : α → Prop) (β : α → Type _) [DecidablePred p] :\n    (∀ i : α, β i) ≃ (∀ i : { x // p x }, β i) × ∀ i : { x // ¬p x }, β i\n    where\n  toFun f := (fun x => f x, fun x => f x)\n  invFun f x := if h : p x then f.1 ⟨x, h⟩ else f.2 ⟨x, h⟩\n  right_inv := by\n    rintro ⟨f, g⟩\n    ext1 <;>\n      · ext y\n        rcases y with ⟨⟩\n        simp only [y_property, dif_pos, dif_neg, not_false_iff, Subtype.coe_mk]\n        rfl\n  left_inv f := by\n    ext x\n    by_cases h : p x <;>\n      · simp only [h, dif_neg, dif_pos, not_false_iff]\n        rfl\n#align equiv.pi_equiv_pi_subtype_prod Equiv.piEquivPiSubtypeProd\n-/\n\n#print Equiv.piSplitAt /-\n/-- A product of types can be split as the binary product of one of the types and the product\n  of all the remaining types. -/\n@[simps]\ndef piSplitAt {α : Type _} [DecidableEq α] (i : α) (β : α → Type _) :\n    (∀ j, β j) ≃ β i × ∀ j : { j // j ≠ i }, β j\n    where\n  toFun f := ⟨f i, fun j => f j⟩\n  invFun f j := if h : j = i then h.symm.rec f.1 else f.2 ⟨j, h⟩\n  right_inv f := by\n    ext\n    exacts[dif_pos rfl, (dif_neg x.2).trans (by cases x <;> rfl)]\n  left_inv f := by\n    ext\n    dsimp only\n    split_ifs\n    · subst h\n    · rfl\n#align equiv.pi_split_at Equiv.piSplitAt\n-/\n\n#print Equiv.funSplitAt /-\n/-- A product of copies of a type can be split as the binary product of one copy and the product\n  of all the remaining copies. -/\n@[simps]\ndef funSplitAt {α : Type _} [DecidableEq α] (i : α) (β : Type _) :\n    (α → β) ≃ β × ({ j // j ≠ i } → β) :=\n  piSplitAt i _\n#align equiv.fun_split_at Equiv.funSplitAt\n-/\n\nend\n\nsection SubtypeEquivCodomain\n\nvariable {X : Type _} {Y : Type _} [DecidableEq X] {x : X}\n\n/- warning: equiv.subtype_equiv_codomain -> Equiv.subtypeEquivCodomain is a dubious translation:\nlean 3 declaration is\n  forall {X : Type.{u1}} {Y : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} X] {x : X} (f : (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y), Equiv.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y\nbut is expected to have type\n  forall {X : Sort.{u1}} [Y : DecidableEq.{u1} X] {_inst_1 : X} {x : Sort.{u2}} (f : (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x), Equiv.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_codomain Equiv.subtypeEquivCodomainₓ'. -/\n/-- The type of all functions `X → Y` with prescribed values for all `x' ≠ x`\nis equivalent to the codomain `Y`. -/\ndef subtypeEquivCodomain (f : { x' // x' ≠ x } → Y) : { g : X → Y // g ∘ coe = f } ≃ Y :=\n  (subtypePreimage _ f).trans <|\n    @funUnique { x' // ¬x' ≠ x } _ <|\n      show Unique { x' // ¬x' ≠ x } from\n        @Equiv.unique _ _\n          (show Unique { x' // x' = x } from\n            { default := ⟨x, rfl⟩\n              uniq := fun ⟨x', h⟩ => Subtype.val_injective h })\n          (subtypeEquivRight fun a => Classical.not_not)\n#align equiv.subtype_equiv_codomain Equiv.subtypeEquivCodomain\n\n/- warning: equiv.coe_subtype_equiv_codomain -> Equiv.coe_subtypeEquivCodomain is a dubious translation:\nlean 3 declaration is\n  forall {X : Type.{u1}} {Y : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} X] {x : X} (f : (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y), Eq.{max (max 1 (succ u1) (succ u2)) (succ u2)} ((fun (_x : Equiv.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y) => (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) -> Y) (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f)) (coeFn.{max 1 (max (max 1 (succ u1) (succ u2)) (succ u2)) (succ u2) 1 (succ u1) (succ u2), max (max 1 (succ u1) (succ u2)) (succ u2)} (Equiv.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y) (fun (_x : Equiv.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y) => (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) -> Y) (Equiv.hasCoeToFun.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y) (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f)) (fun (g : Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) => (fun (a : Sort.{max 1 (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (HasLiftT.mk.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (CoeTCₓ.coe.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeBase.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeSubtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))))) g x)\nbut is expected to have type\n  forall {X : Sort.{u1}} [Y : DecidableEq.{u1} X] {_inst_1 : X} {x : Sort.{u2}} (f : (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x), Eq.{imax (max 1 (imax u1 u2)) u2} (forall (a : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) => x) a) (FunLike.coe.{max (max 1 u2) (imax u1 u2), max 1 (imax u1 u2), u2} (Equiv.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x) (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) (fun (_x : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) => x) _x) (Equiv.instFunLikeEquiv.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x) (Equiv.subtypeEquivCodomain.{u1, u2} X (fun (a : X) (b : X) => Y a b) _inst_1 x f)) (fun (g : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) => Subtype.val.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f) g _inst_1)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_subtype_equiv_codomain Equiv.coe_subtypeEquivCodomainₓ'. -/\n@[simp]\ntheorem coe_subtypeEquivCodomain (f : { x' // x' ≠ x } → Y) :\n    (subtypeEquivCodomain f : { g : X → Y // g ∘ coe = f } → Y) = fun g => (g : X → Y) x :=\n  rfl\n#align equiv.coe_subtype_equiv_codomain Equiv.coe_subtypeEquivCodomain\n\n/- warning: equiv.subtype_equiv_codomain_apply -> Equiv.subtypeEquivCodomain_apply is a dubious translation:\nlean 3 declaration is\n  forall {X : Type.{u1}} {Y : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} X] {x : X} (f : (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (g : Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)), Eq.{succ u2} Y (coeFn.{max 1 (max (max 1 (succ u1) (succ u2)) (succ u2)) (succ u2) 1 (succ u1) (succ u2), max (max 1 (succ u1) (succ u2)) (succ u2)} (Equiv.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y) (fun (_x : Equiv.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y) => (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) -> Y) (Equiv.hasCoeToFun.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y) (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f) g) ((fun (a : Sort.{max 1 (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (HasLiftT.mk.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (CoeTCₓ.coe.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeBase.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeSubtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))))) g x)\nbut is expected to have type\n  forall {X : Sort.{u1}} [Y : DecidableEq.{u1} X] {_inst_1 : X} {x : Sort.{u2}} (f : (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (g : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)), Eq.{u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) => x) g) (FunLike.coe.{max (max 1 u2) (imax u1 u2), max 1 (imax u1 u2), u2} (Equiv.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x) (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) (fun (_x : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) => x) _x) (Equiv.instFunLikeEquiv.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x) (Equiv.subtypeEquivCodomain.{u1, u2} X (fun (a : X) (b : X) => Y a b) _inst_1 x f) g) (Subtype.val.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f) g _inst_1)\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_codomain_apply Equiv.subtypeEquivCodomain_applyₓ'. -/\n@[simp]\ntheorem subtypeEquivCodomain_apply (f : { x' // x' ≠ x } → Y) (g : { g : X → Y // g ∘ coe = f }) :\n    subtypeEquivCodomain f g = (g : X → Y) x :=\n  rfl\n#align equiv.subtype_equiv_codomain_apply Equiv.subtypeEquivCodomain_apply\n\n/- warning: equiv.coe_subtype_equiv_codomain_symm -> Equiv.coe_subtypeEquivCodomain_symm is a dubious translation:\nlean 3 declaration is\n  forall {X : Type.{u1}} {Y : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} X] {x : X} (f : (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y), Eq.{max (succ u2) 1 (succ u1) (succ u2)} ((fun (_x : Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) => Y -> (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.symm.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f))) (coeFn.{max 1 (max (succ u2) 1 (succ u1) (succ u2)) (max 1 (succ u1) (succ u2)) (succ u2), max (succ u2) 1 (succ u1) (succ u2)} (Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (fun (_x : Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) => Y -> (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.hasCoeToFun.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.symm.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f))) (fun (y : Y) => Subtype.mk.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f) (fun (x' : X) => dite.{succ u2} Y (Ne.{succ u1} X x' x) (Ne.decidable.{succ u1} X (fun (a : X) (b : X) => _inst_1 a b) x' x) (fun (h : Ne.{succ u1} X x' x) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x' h)) (fun (h : Not (Ne.{succ u1} X x' x)) => y)) (funext.{succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) (fun (x : Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) => Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y (fun (x' : X) => dite.{succ u2} Y (Ne.{succ u1} X x' x) (Ne.decidable.{succ u1} X (fun (a : X) (b : X) => _inst_1 a b) x' x) (fun (h : Ne.{succ u1} X x' x) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x' h)) (fun (h : Not (Ne.{succ u1} X x' x)) => y)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f (fun (x' : Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) => id.{0} (Eq.{succ u2} Y (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y (fun (x' : X) => dite.{succ u2} Y (Ne.{succ u1} X x' x) (Ne.decidable.{succ u1} X (fun (a : X) (b : X) => _inst_1 a b) x' x) (fun (h : Ne.{succ u1} X x' x) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x' h)) (fun (h : Not (Ne.{succ u1} X x' x)) => y)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)))))) x') (f x')) (Eq.mpr.{0} (Eq.{succ u2} Y (dite.{succ u2} Y (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) (Ne.decidable.{succ u1} X _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x) (fun (h : Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') h)) (fun (h : Not (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x))) => y)) (f x')) (Eq.{succ u2} Y (f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x'))) (f x')) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Eq.{succ u2} Y (dite.{succ u2} Y (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) (Ne.decidable.{succ u1} X _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x) (fun (h : Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') h)) (fun (h : Not (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x))) => y)) (f x')) (Eq.{succ u2} Y (f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x'))) (f x'))) (Eq.ndrec.{0, succ u2} Y (dite.{succ u2} Y (Ne.{succ u1} X (Subtype.val.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x') x) (Ne.decidable.{succ u1} X (fun (a : X) (b : X) => _inst_1 a b) (Subtype.val.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x') x) (fun (h : Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') h)) (fun (h : Not (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x))) => y)) (fun (_a : Y) => Eq.{1} Prop (Eq.{succ u2} Y (dite.{succ u2} Y (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) (Ne.decidable.{succ u1} X _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x) (fun (h : Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') h)) (fun (h : Not (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x))) => y)) (f x')) (Eq.{succ u2} Y _a (f x'))) (rfl.{1} Prop (Eq.{succ u2} Y (dite.{succ u2} Y (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) (Ne.decidable.{succ u1} X _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x) (fun (h : Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') h)) (fun (h : Not (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x))) => y)) (f x'))) (f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x'))) (dif_pos.{succ u2} (Ne.{succ u1} X (Subtype.val.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x') x) (Ne.decidable.{succ u1} X (fun (a : X) (b : X) => _inst_1 a b) (Subtype.val.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x') x) (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x') Y (fun (h : Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x)) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') h)) (fun (h : Not (Not (Eq.{succ u1} X ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') x))) => y)))) (Eq.mpr.{0} (Eq.{succ u2} Y (f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x'))) (f x')) (Eq.{succ u2} Y (f x') (f x')) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Eq.{succ u2} Y (f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x'))) (f x')) (Eq.{succ u2} Y (f x') (f x'))) (Eq.ndrec.{0, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (a : X) => Not (Eq.{succ u1} X a x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (a : X) => Not (Eq.{succ u1} X a x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (a : X) => Not (Eq.{succ u1} X a x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (a : X) => Not (Eq.{succ u1} X a x))) X (coeSubtype.{succ u1} X (fun (a : X) => Not (Eq.{succ u1} X a x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x')) (fun (_a : Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) => Eq.{1} Prop (Eq.{succ u2} Y (f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x'))) (f x')) (Eq.{succ u2} Y (f _a) (f x'))) (rfl.{1} Prop (Eq.{succ u2} Y (f (Subtype.mk.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x))) X (coeSubtype.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)))))) x') (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x'))) (f x'))) x' (Subtype.coe_eta.{succ u1} X (fun (x' : X) => Not (Eq.{succ u1} X x' x)) x' (Subtype.property.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x')))) (rfl.{succ u2} Y (f x')))))))\nbut is expected to have type\n  forall {X : Sort.{u1}} [Y : DecidableEq.{u1} X] {_inst_1 : X} {x : Sort.{u2}} (f : (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x), Eq.{max (max 1 u2) (imax u1 u2)} (forall (a : x), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : x) => Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) a) (FunLike.coe.{max (max 1 u2) (imax u1 u2), u2, max 1 (imax u1 u2)} (Equiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) x (fun (_x : x) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : x) => Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) _x) (Equiv.instFunLikeEquiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) (Equiv.symm.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x (Equiv.subtypeEquivCodomain.{u1, u2} X (fun (a : X) (b : X) => Y a b) _inst_1 x f))) (fun (y : x) => Subtype.mk.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f) (fun (x' : X) => dite.{u2} x (Ne.{u1} X x' _inst_1) (instDecidableNot (Eq.{u1} X x' _inst_1) (Y x' _inst_1)) (fun (h : Ne.{u1} X x' _inst_1) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' h)) (fun (h : Not (Ne.{u1} X x' _inst_1)) => y)) (funext.{max 1 u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) (fun (x_1 : Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) => x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x (fun (x' : X) => dite.{u2} x (Ne.{u1} X x' _inst_1) (instDecidableNot (Eq.{u1} X x' _inst_1) (Y x' _inst_1)) (fun (h : Ne.{u1} X x' _inst_1) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' h)) (fun (h : Not (Ne.{u1} X x' _inst_1)) => y)) (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f (fun (x' : Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) => Eq.mpr.{0} (Eq.{u2} x (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x (fun (x' : X) => dite.{u2} x (Ne.{u1} X x' _inst_1) (instDecidableNot (Eq.{u1} X x' _inst_1) (Y x' _inst_1)) (fun (h : Ne.{u1} X x' _inst_1) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' h)) (fun (h : Not (Ne.{u1} X x' _inst_1)) => y)) (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) x') (f x')) ((Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) -> (Eq.{u2} x y (f x'))) (id.{0} (Eq.{1} Prop (Eq.{u2} x (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x (fun (x' : X) => dite.{u2} x (Ne.{u1} X x' _inst_1) (instDecidableNot (Eq.{u1} X x' _inst_1) (Y x' _inst_1)) (fun (h : Ne.{u1} X x' _inst_1) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' h)) (fun (h : Not (Ne.{u1} X x' _inst_1)) => y)) (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) x') (f x')) ((Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) -> (Eq.{u2} x y (f x')))) (Eq.trans.{1} Prop (Eq.{u2} x (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y)) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) x') (f x')) (Eq.{u2} x (dite.{u2} x (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Y (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (fun (h : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => y) (fun (h : Not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) => f x')) (f x')) ((Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) -> (Eq.{u2} x y (f x'))) (congrFun.{u2, 1} x (fun (a._@.Init.Prelude._hyg.170 : x) => Prop) (Eq.{u2} x (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y)) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) x')) (Eq.{u2} x (dite.{u2} x (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Y (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (fun (h : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => y) (fun (h : Not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) => f x'))) (congrArg.{u2, max 1 u2} x (x -> Prop) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y)) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) x') (dite.{u2} x (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Y (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (fun (h : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => y) (fun (h : Not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) => f x')) (Eq.{u2} x) (Eq.trans.{u2} x (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y)) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) x') (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1) (fun (h : Eq.{u1} X x_1 _inst_1) => y) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h))) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) x') (dite.{u2} x (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Y (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (fun (h : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => y) (fun (h : Not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) => f x')) (congrFun.{max 1 u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) (fun (a._@.Init.Prelude._hyg.25 : Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) => x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y)) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)))) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1) (fun (h : Eq.{u1} X x_1 _inst_1) => y) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h))) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)))) (congrFun.{imax (max 1 u1) u1, imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) -> X) (fun (g : (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) -> X) => (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y))) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x (fun (x_1 : X) => dite.{u2} x (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1) (fun (h : Eq.{u1} X x_1 _inst_1) => y) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)))) (congrArg.{imax u1 u2, imax (imax (max 1 u1) u1) (max 1 u1) u2} (X -> x) (((Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) -> X) -> (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) -> x) (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y)) (fun (x_1 : X) => dite.{u2} x (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1) (fun (h : Eq.{u1} X x_1 _inst_1) => y) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h))) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1))) X x) (funext.{u1, u2} X (fun (x_1 : X) => x) (fun (x_1 : X) => dite.{u2} x (Not (Eq.{u1} X x_1 _inst_1)) (instDecidableNot (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1)) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h)) (fun (h : Not (Not (Eq.{u1} X x_1 _inst_1))) => y)) (fun (x_1 : X) => dite.{u2} x (Eq.{u1} X x_1 _inst_1) (Y x_1 _inst_1) (fun (h : Eq.{u1} X x_1 _inst_1) => y) (fun (h : Not (Eq.{u1} X x_1 _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x_1 h))) (fun (x' : X) => dite_not.{u2} x (Eq.{u1} X x' _inst_1) (Y x' _inst_1) (fun (h : Not (Eq.{u1} X x' _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' h)) (fun (h : Not (Not (Eq.{u1} X x' _inst_1))) => y)))) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)))) x') (dite_congr.{u2} (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) x (Y (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Y (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (fun (h : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => y) (fun (h : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => y) (fun (h : Not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') h)) (fun (h : Not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) => f x') (Eq.refl.{1} Prop (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) (fun (h : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => Eq.refl.{u2} x y) (fun (h : Not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) => congrArg.{max 1 u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) x (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) (Subtype.val.{u1} X (fun (a : X) => Ne.{u1} X a _inst_1) x') (Eq.mpr_not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Eq.refl.{1} Prop (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) h)) x' f (Subtype.coe_eta.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' (Eq.mpr_not (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Eq.refl.{1} Prop (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1)) h)))))) (f x')) (Mathlib.Logic.Equiv.Basic._auxLemma.3.{u2} x (Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) (Y (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) y (f x')))) (fun (w : Eq.{u1} X (Subtype.val.{u1} X (fun (x' : X) => Not (Eq.{u1} X x' _inst_1)) x') _inst_1) => False.elim.{0} (Eq.{u2} x y (f x')) (Subtype.property.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' w)))))\nCase conversion may be inaccurate. Consider using '#align equiv.coe_subtype_equiv_codomain_symm Equiv.coe_subtypeEquivCodomain_symmₓ'. -/\ntheorem coe_subtypeEquivCodomain_symm (f : { x' // x' ≠ x } → Y) :\n    ((subtypeEquivCodomain f).symm : Y → { g : X → Y // g ∘ coe = f }) = fun y =>\n      ⟨fun x' => if h : x' ≠ x then f ⟨x', h⟩ else y,\n        by\n        funext x'\n        dsimp\n        erw [dif_pos x'.2, Subtype.coe_eta]⟩ :=\n  rfl\n#align equiv.coe_subtype_equiv_codomain_symm Equiv.coe_subtypeEquivCodomain_symm\n\n/- warning: equiv.subtype_equiv_codomain_symm_apply -> Equiv.subtypeEquivCodomain_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {X : Type.{u1}} {Y : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} X] {x : X} (f : (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (y : Y) (x' : X), Eq.{succ u2} Y ((fun (a : Sort.{max 1 (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (HasLiftT.mk.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (CoeTCₓ.coe.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeBase.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeSubtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))))) (coeFn.{max 1 (max (succ u2) 1 (succ u1) (succ u2)) (max 1 (succ u1) (succ u2)) (succ u2), max (succ u2) 1 (succ u1) (succ u2)} (Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (fun (_x : Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) => Y -> (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.hasCoeToFun.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.symm.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f)) y) x') (dite.{succ u2} Y (Ne.{succ u1} X x' x) (Ne.decidable.{succ u1} X (fun (a : X) (b : X) => _inst_1 a b) x' x) (fun (h : Ne.{succ u1} X x' x) => f (Subtype.mk.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x' h)) (fun (h : Not (Ne.{succ u1} X x' x)) => y))\nbut is expected to have type\n  forall {X : Sort.{u1}} [Y : DecidableEq.{u1} X] {_inst_1 : X} {x : Sort.{u2}} (f : (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (y : x) (x' : X), Eq.{u2} x (Subtype.val.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f) (FunLike.coe.{max (max 1 u2) (imax u1 u2), u2, max 1 (imax u1 u2)} (Equiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) x (fun (_x : x) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : x) => Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) _x) (Equiv.instFunLikeEquiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) (Equiv.symm.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x (Equiv.subtypeEquivCodomain.{u1, u2} X (fun (a : X) (b : X) => Y a b) _inst_1 x f)) y) x') (dite.{u2} x (Ne.{u1} X x' _inst_1) (instDecidableNot (Eq.{u1} X x' _inst_1) (Y x' _inst_1)) (fun (h : Ne.{u1} X x' _inst_1) => f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' h)) (fun (h : Not (Ne.{u1} X x' _inst_1)) => y))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_codomain_symm_apply Equiv.subtypeEquivCodomain_symm_applyₓ'. -/\n@[simp]\ntheorem subtypeEquivCodomain_symm_apply (f : { x' // x' ≠ x } → Y) (y : Y) (x' : X) :\n    ((subtypeEquivCodomain f).symm y : X → Y) x' = if h : x' ≠ x then f ⟨x', h⟩ else y :=\n  rfl\n#align equiv.subtype_equiv_codomain_symm_apply Equiv.subtypeEquivCodomain_symm_apply\n\n/- warning: equiv.subtype_equiv_codomain_symm_apply_eq -> Equiv.subtypeEquivCodomain_symm_apply_eq is a dubious translation:\nlean 3 declaration is\n  forall {X : Type.{u1}} {Y : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} X] {x : X} (f : (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (y : Y), Eq.{succ u2} Y ((fun (a : Sort.{max 1 (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (HasLiftT.mk.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (CoeTCₓ.coe.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeBase.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeSubtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))))) (coeFn.{max 1 (max (succ u2) 1 (succ u1) (succ u2)) (max 1 (succ u1) (succ u2)) (succ u2), max (succ u2) 1 (succ u1) (succ u2)} (Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (fun (_x : Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) => Y -> (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.hasCoeToFun.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.symm.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f)) y) x) y\nbut is expected to have type\n  forall {X : Sort.{u1}} [Y : DecidableEq.{u1} X] {_inst_1 : X} {x : Sort.{u2}} (f : (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (y : x), Eq.{u2} x (Subtype.val.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f) (FunLike.coe.{max (max 1 u2) (imax u1 u2), u2, max 1 (imax u1 u2)} (Equiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) x (fun (_x : x) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : x) => Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) _x) (Equiv.instFunLikeEquiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) (Equiv.symm.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x (Equiv.subtypeEquivCodomain.{u1, u2} X (fun (a : X) (b : X) => Y a b) _inst_1 x f)) y) _inst_1) y\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_codomain_symm_apply_eq Equiv.subtypeEquivCodomain_symm_apply_eqₓ'. -/\n@[simp]\ntheorem subtypeEquivCodomain_symm_apply_eq (f : { x' // x' ≠ x } → Y) (y : Y) :\n    ((subtypeEquivCodomain f).symm y : X → Y) x = y :=\n  dif_neg (Classical.not_not.mpr rfl)\n#align equiv.subtype_equiv_codomain_symm_apply_eq Equiv.subtypeEquivCodomain_symm_apply_eq\n\n/- warning: equiv.subtype_equiv_codomain_symm_apply_ne -> Equiv.subtypeEquivCodomain_symm_apply_ne is a dubious translation:\nlean 3 declaration is\n  forall {X : Type.{u1}} {Y : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} X] {x : X} (f : (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (y : Y) (x' : X) (h : Ne.{succ u1} X x' x), Eq.{succ u2} Y ((fun (a : Sort.{max 1 (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (HasLiftT.mk.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (CoeTCₓ.coe.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeBase.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) (X -> Y) (coeSubtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))))) (coeFn.{max 1 (max (succ u2) 1 (succ u1) (succ u2)) (max 1 (succ u1) (succ u2)) (succ u2), max (succ u2) 1 (succ u1) (succ u2)} (Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (fun (_x : Equiv.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) => Y -> (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.hasCoeToFun.{succ u2, max 1 (succ u1) (succ u2)} Y (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f))) (Equiv.symm.{max 1 (succ u1) (succ u2), succ u2} (Subtype.{max (succ u1) (succ u2)} (X -> Y) (fun (g : X -> Y) => Eq.{max (succ u1) (succ u2)} ((Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) -> Y) (Function.comp.{succ u1, succ u1, succ u2} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X Y g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeBase.{succ u1, succ u1} (Subtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x)) X (coeSubtype.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x))))))) f)) Y (Equiv.subtypeEquivCodomain.{u1, u2} X Y (fun (a : X) (b : X) => _inst_1 a b) x f)) y) x') (f (Subtype.mk.{succ u1} X (fun (x' : X) => Ne.{succ u1} X x' x) x' h))\nbut is expected to have type\n  forall {X : Sort.{u1}} [Y : DecidableEq.{u1} X] {_inst_1 : X} {x : Sort.{u2}} (f : (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (y : x) (x' : X) (h : Ne.{u1} X x' _inst_1), Eq.{u2} x (Subtype.val.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f) (FunLike.coe.{max (max 1 u2) (imax u1 u2), u2, max 1 (imax u1 u2)} (Equiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) x (fun (_x : x) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : x) => Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) _x) (Equiv.instFunLikeEquiv.{u2, max 1 (imax u1 u2)} x (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f))) (Equiv.symm.{max 1 (imax u1 u2), u2} (Subtype.{imax u1 u2} (X -> x) (fun (g : X -> x) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) -> x) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1)) X x g (Subtype.val.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1))) f)) x (Equiv.subtypeEquivCodomain.{u1, u2} X (fun (a : X) (b : X) => Y a b) _inst_1 x f)) y) x') (f (Subtype.mk.{u1} X (fun (x' : X) => Ne.{u1} X x' _inst_1) x' h))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_codomain_symm_apply_ne Equiv.subtypeEquivCodomain_symm_apply_neₓ'. -/\ntheorem subtypeEquivCodomain_symm_apply_ne (f : { x' // x' ≠ x } → Y) (y : Y) (x' : X)\n    (h : x' ≠ x) : ((subtypeEquivCodomain f).symm y : X → Y) x' = f ⟨x', h⟩ :=\n  dif_pos h\n#align equiv.subtype_equiv_codomain_symm_apply_ne Equiv.subtypeEquivCodomain_symm_apply_ne\n\nend SubtypeEquivCodomain\n\n#print Equiv.ofBijective /-\n/-- If `f` is a bijective function, then its domain is equivalent to its codomain. -/\n@[simps apply]\nnoncomputable def ofBijective (f : α → β) (hf : Bijective f) : α ≃ β\n    where\n  toFun := f\n  invFun := Function.surjInv hf.Surjective\n  left_inv := Function.leftInverse_surjInv hf\n  right_inv := Function.rightInverse_surjInv _\n#align equiv.of_bijective Equiv.ofBijective\n-/\n\n/- warning: equiv.of_bijective_apply_symm_apply -> Equiv.ofBijective_apply_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (f : α -> β) (hf : Function.Bijective.{u1, u2} α β f) (x : β), Eq.{u2} β (f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β (Equiv.ofBijective.{u1, u2} α β f hf)) x)) x\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (f : α -> β) (hf : Function.Bijective.{u2, u1} α β f) (x : β), Eq.{u1} β (f (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β (Equiv.ofBijective.{u2, u1} α β f hf)) x)) x\nCase conversion may be inaccurate. Consider using '#align equiv.of_bijective_apply_symm_apply Equiv.ofBijective_apply_symm_applyₓ'. -/\ntheorem ofBijective_apply_symm_apply (f : α → β) (hf : Bijective f) (x : β) :\n    f ((ofBijective f hf).symm x) = x :=\n  (ofBijective f hf).apply_symm_apply x\n#align equiv.of_bijective_apply_symm_apply Equiv.ofBijective_apply_symm_apply\n\n/- warning: equiv.of_bijective_symm_apply_apply -> Equiv.ofBijective_symm_apply_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (f : α -> β) (hf : Function.Bijective.{u1, u2} α β f) (x : α), Eq.{u1} α (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β (Equiv.ofBijective.{u1, u2} α β f hf)) (f x)) x\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (f : α -> β) (hf : Function.Bijective.{u2, u1} α β f) (x : α), Eq.{u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) (f x)) (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β (Equiv.ofBijective.{u2, u1} α β f hf)) (f x)) x\nCase conversion may be inaccurate. Consider using '#align equiv.of_bijective_symm_apply_apply Equiv.ofBijective_symm_apply_applyₓ'. -/\n@[simp]\ntheorem ofBijective_symm_apply_apply (f : α → β) (hf : Bijective f) (x : α) :\n    (ofBijective f hf).symm (f x) = x :=\n  (ofBijective f hf).symm_apply_apply x\n#align equiv.of_bijective_symm_apply_apply Equiv.ofBijective_symm_apply_apply\n\ninstance : CanLift (α → β) (α ≃ β) coeFn Bijective where prf f hf := ⟨ofBijective f hf, rfl⟩\n\nsection\n\nvariable {α' β' : Type _} (e : Perm α') {p : β' → Prop} [DecidablePred p] (f : α' ≃ Subtype p)\n\n#print Equiv.Perm.extendDomain /-\n/-- Extend the domain of `e : equiv.perm α` to one that is over `β` via `f : α → subtype p`,\nwhere `p : β → Prop`, permuting only the `b : β` that satisfy `p b`.\nThis can be used to extend the domain across a function `f : α → β`,\nkeeping everything outside of `set.range f` fixed. For this use-case `equiv` given by `f` can\nbe constructed by `equiv.of_left_inverse'` or `equiv.of_left_inverse` when there is a known\ninverse, or `equiv.of_injective` in the general case.`.\n-/\ndef Perm.extendDomain : Perm β' :=\n  (permCongr f e).subtypeCongr (Equiv.refl _)\n#align equiv.perm.extend_domain Equiv.Perm.extendDomain\n-/\n\n#print Equiv.Perm.extendDomain_apply_image /-\n@[simp]\ntheorem Perm.extendDomain_apply_image (a : α') : e.extendDomain f (f a) = f (e a) := by\n  simp [perm.extend_domain]\n#align equiv.perm.extend_domain_apply_image Equiv.Perm.extendDomain_apply_image\n-/\n\n#print Equiv.Perm.extendDomain_apply_subtype /-\ntheorem Perm.extendDomain_apply_subtype {b : β'} (h : p b) :\n    e.extendDomain f b = f (e (f.symm ⟨b, h⟩)) := by simp [perm.extend_domain, h]\n#align equiv.perm.extend_domain_apply_subtype Equiv.Perm.extendDomain_apply_subtype\n-/\n\n#print Equiv.Perm.extendDomain_apply_not_subtype /-\ntheorem Perm.extendDomain_apply_not_subtype {b : β'} (h : ¬p b) : e.extendDomain f b = b := by\n  simp [perm.extend_domain, h]\n#align equiv.perm.extend_domain_apply_not_subtype Equiv.Perm.extendDomain_apply_not_subtype\n-/\n\n#print Equiv.Perm.extendDomain_refl /-\n@[simp]\ntheorem Perm.extendDomain_refl : Perm.extendDomain (Equiv.refl _) f = Equiv.refl _ := by\n  simp [perm.extend_domain]\n#align equiv.perm.extend_domain_refl Equiv.Perm.extendDomain_refl\n-/\n\n#print Equiv.Perm.extendDomain_symm /-\n@[simp]\ntheorem Perm.extendDomain_symm : (e.extendDomain f).symm = Perm.extendDomain e.symm f :=\n  rfl\n#align equiv.perm.extend_domain_symm Equiv.Perm.extendDomain_symm\n-/\n\n/- warning: equiv.perm.extend_domain_trans -> Equiv.Perm.extendDomain_trans is a dubious translation:\nlean 3 declaration is\n  forall {α' : Type.{u1}} {β' : Type.{u2}} {p : β' -> Prop} [_inst_1 : DecidablePred.{succ u2} β' p] (f : Equiv.{succ u1, succ u2} α' (Subtype.{succ u2} β' p)) (e : Equiv.Perm.{succ u1} α') (e' : Equiv.Perm.{succ u1} α'), Eq.{succ u2} (Equiv.{succ u2, succ u2} β' β') (Equiv.trans.{succ u2, succ u2, succ u2} β' β' β' (Equiv.Perm.extendDomain.{u1, u2} α' β' e p (fun (a : β') => _inst_1 a) f) (Equiv.Perm.extendDomain.{u1, u2} α' β' e' p (fun (a : β') => _inst_1 a) f)) (Equiv.Perm.extendDomain.{u1, u2} α' β' (Equiv.trans.{succ u1, succ u1, succ u1} α' α' α' e e') p (fun (a : β') => _inst_1 a) f)\nbut is expected to have type\n  forall {α' : Type.{u2}} {β' : Type.{u1}} {p : β' -> Prop} [_inst_1 : DecidablePred.{succ u1} β' p] (f : Equiv.{succ u2, succ u1} α' (Subtype.{succ u1} β' p)) (e : Equiv.Perm.{succ u2} α') (e' : Equiv.Perm.{succ u2} α'), Eq.{succ u1} (Equiv.{succ u1, succ u1} β' β') (Equiv.trans.{succ u1, succ u1, succ u1} β' β' β' (Equiv.Perm.extendDomain.{u2, u1} α' β' e p (fun (a : β') => _inst_1 a) f) (Equiv.Perm.extendDomain.{u2, u1} α' β' e' p (fun (a : β') => _inst_1 a) f)) (Equiv.Perm.extendDomain.{u2, u1} α' β' (Equiv.trans.{succ u2, succ u2, succ u2} α' α' α' e e') p (fun (a : β') => _inst_1 a) f)\nCase conversion may be inaccurate. Consider using '#align equiv.perm.extend_domain_trans Equiv.Perm.extendDomain_transₓ'. -/\ntheorem Perm.extendDomain_trans (e e' : Perm α') :\n    (e.extendDomain f).trans (e'.extendDomain f) = Perm.extendDomain (e.trans e') f := by\n  simp [perm.extend_domain, perm_congr_trans]\n#align equiv.perm.extend_domain_trans Equiv.Perm.extendDomain_trans\n\nend\n\n#print Equiv.subtypeQuotientEquivQuotientSubtype /-\n/-- Subtype of the quotient is equivalent to the quotient of the subtype. Let `α` be a setoid with\nequivalence relation `~`. Let `p₂` be a predicate on the quotient type `α/~`, and `p₁` be the lift\nof this predicate to `α`: `p₁ a ↔ p₂ ⟦a⟧`. Let `~₂` be the restriction of `~` to `{x // p₁ x}`.\nThen `{x // p₂ x}` is equivalent to the quotient of `{x // p₁ x}` by `~₂`. -/\ndef subtypeQuotientEquivQuotientSubtype (p₁ : α → Prop) [s₁ : Setoid α] [s₂ : Setoid (Subtype p₁)]\n    (p₂ : Quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧)\n    (h : ∀ x y : Subtype p₁, @Setoid.r _ s₂ x y ↔ (x : α) ≈ y) : { x // p₂ x } ≃ Quotient s₂\n    where\n  toFun a :=\n    Quotient.hrecOn a.1 (fun a h => ⟦⟨a, (hp₂ _).2 h⟩⟧)\n      (fun a b hab =>\n        hfunext (by rw [Quotient.sound hab]) fun h₁ h₂ _ =>\n          hEq_of_eq (Quotient.sound ((h _ _).2 hab)))\n      a.2\n  invFun a :=\n    Quotient.liftOn a (fun a => (⟨⟦a.1⟧, (hp₂ _).1 a.2⟩ : { x // p₂ x })) fun a b hab =>\n      Subtype.ext_val (Quotient.sound ((h _ _).1 hab))\n  left_inv := fun ⟨a, ha⟩ => Quotient.inductionOn a (fun a ha => rfl) ha\n  right_inv a := Quotient.inductionOn a fun ⟨a, ha⟩ => rfl\n#align equiv.subtype_quotient_equiv_quotient_subtype Equiv.subtypeQuotientEquivQuotientSubtype\n-/\n\n#print Equiv.subtypeQuotientEquivQuotientSubtype_mk /-\n@[simp]\ntheorem subtypeQuotientEquivQuotientSubtype_mk (p₁ : α → Prop) [s₁ : Setoid α]\n    [s₂ : Setoid (Subtype p₁)] (p₂ : Quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧)\n    (h : ∀ x y : Subtype p₁, @Setoid.r _ s₂ x y ↔ (x : α) ≈ y) (x hx) :\n    subtypeQuotientEquivQuotientSubtype p₁ p₂ hp₂ h ⟨⟦x⟧, hx⟩ = ⟦⟨x, (hp₂ _).2 hx⟩⟧ :=\n  rfl\n#align equiv.subtype_quotient_equiv_quotient_subtype_mk Equiv.subtypeQuotientEquivQuotientSubtype_mk\n-/\n\n#print Equiv.subtypeQuotientEquivQuotientSubtype_symm_mk /-\n@[simp]\ntheorem subtypeQuotientEquivQuotientSubtype_symm_mk (p₁ : α → Prop) [s₁ : Setoid α]\n    [s₂ : Setoid (Subtype p₁)] (p₂ : Quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧)\n    (h : ∀ x y : Subtype p₁, @Setoid.r _ s₂ x y ↔ (x : α) ≈ y) (x) :\n    (subtypeQuotientEquivQuotientSubtype p₁ p₂ hp₂ h).symm ⟦x⟧ = ⟨⟦x⟧, (hp₂ _).1 x.Prop⟩ :=\n  rfl\n#align equiv.subtype_quotient_equiv_quotient_subtype_symm_mk Equiv.subtypeQuotientEquivQuotientSubtype_symm_mk\n-/\n\nsection Swap\n\nvariable [DecidableEq α]\n\n#print Equiv.swapCore /-\n/-- A helper function for `equiv.swap`. -/\ndef swapCore (a b r : α) : α :=\n  if r = a then b else if r = b then a else r\n#align equiv.swap_core Equiv.swapCore\n-/\n\n#print Equiv.swapCore_self /-\ntheorem swapCore_self (r a : α) : swapCore a a r = r :=\n  by\n  unfold swap_core\n  split_ifs <;> cc\n#align equiv.swap_core_self Equiv.swapCore_self\n-/\n\n#print Equiv.swapCore_swapCore /-\ntheorem swapCore_swapCore (r a b : α) : swapCore a b (swapCore a b r) = r :=\n  by\n  unfold swap_core\n  split_ifs <;> cc\n#align equiv.swap_core_swap_core Equiv.swapCore_swapCore\n-/\n\n#print Equiv.swapCore_comm /-\ntheorem swapCore_comm (r a b : α) : swapCore a b r = swapCore b a r :=\n  by\n  unfold swap_core\n  split_ifs <;> cc\n#align equiv.swap_core_comm Equiv.swapCore_comm\n-/\n\n#print Equiv.swap /-\n/-- `swap a b` is the permutation that swaps `a` and `b` and\n  leaves other values as is. -/\ndef swap (a b : α) : Perm α :=\n  ⟨swapCore a b, swapCore a b, fun r => swapCore_swapCore r a b, fun r => swapCore_swapCore r a b⟩\n#align equiv.swap Equiv.swap\n-/\n\n#print Equiv.swap_self /-\n@[simp]\ntheorem swap_self (a : α) : swap a a = Equiv.refl _ :=\n  ext fun r => swapCore_self r a\n#align equiv.swap_self Equiv.swap_self\n-/\n\n#print Equiv.swap_comm /-\ntheorem swap_comm (a b : α) : swap a b = swap b a :=\n  ext fun r => swapCore_comm r _ _\n#align equiv.swap_comm Equiv.swap_comm\n-/\n\n#print Equiv.swap_apply_def /-\ntheorem swap_apply_def (a b x : α) : swap a b x = if x = a then b else if x = b then a else x :=\n  rfl\n#align equiv.swap_apply_def Equiv.swap_apply_def\n-/\n\n#print Equiv.swap_apply_left /-\n@[simp]\ntheorem swap_apply_left (a b : α) : swap a b a = b :=\n  if_pos rfl\n#align equiv.swap_apply_left Equiv.swap_apply_left\n-/\n\n#print Equiv.swap_apply_right /-\n@[simp]\ntheorem swap_apply_right (a b : α) : swap a b b = a := by\n  by_cases h : b = a <;> simp [swap_apply_def, h]\n#align equiv.swap_apply_right Equiv.swap_apply_right\n-/\n\n#print Equiv.swap_apply_of_ne_of_ne /-\ntheorem swap_apply_of_ne_of_ne {a b x : α} : x ≠ a → x ≠ b → swap a b x = x := by\n  simp (config := { contextual := true }) [swap_apply_def]\n#align equiv.swap_apply_of_ne_of_ne Equiv.swap_apply_of_ne_of_ne\n-/\n\n#print Equiv.swap_swap /-\n@[simp]\ntheorem swap_swap (a b : α) : (swap a b).trans (swap a b) = Equiv.refl _ :=\n  ext fun x => swapCore_swapCore _ _ _\n#align equiv.swap_swap Equiv.swap_swap\n-/\n\n#print Equiv.symm_swap /-\n@[simp]\ntheorem symm_swap (a b : α) : (swap a b).symm = swap a b :=\n  rfl\n#align equiv.symm_swap Equiv.symm_swap\n-/\n\n#print Equiv.swap_eq_refl_iff /-\n@[simp]\ntheorem swap_eq_refl_iff {x y : α} : swap x y = Equiv.refl _ ↔ x = y :=\n  by\n  refine' ⟨fun h => (Equiv.refl _).Injective _, fun h => h ▸ swap_self _⟩\n  rw [← h, swap_apply_left, h, refl_apply]\n#align equiv.swap_eq_refl_iff Equiv.swap_eq_refl_iff\n-/\n\n#print Equiv.swap_comp_apply /-\ntheorem swap_comp_apply {a b x : α} (π : Perm α) :\n    π.trans (swap a b) x = if π x = a then b else if π x = b then a else π x :=\n  by\n  cases π\n  rfl\n#align equiv.swap_comp_apply Equiv.swap_comp_apply\n-/\n\n#print Equiv.swap_eq_update /-\ntheorem swap_eq_update (i j : α) : (Equiv.swap i j : α → α) = update (update id j i) i j :=\n  funext fun x => by rw [update_apply _ i j, update_apply _ j i, Equiv.swap_apply_def, id.def]\n#align equiv.swap_eq_update Equiv.swap_eq_update\n-/\n\n/- warning: equiv.comp_swap_eq_update -> Equiv.comp_swap_eq_update is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] (i : α) (j : α) (f : α -> β), Eq.{imax u1 u2} (α -> β) (Function.comp.{u1, u1, u2} α α β f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} α) (fun (_x : Equiv.{u1, u1} α α) => α -> α) (Equiv.hasCoeToFun.{u1, u1} α α) (Equiv.swap.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i j))) (Function.update.{u1, u2} α (fun (ᾰ : α) => β) (fun (a : α) (b : α) => _inst_1 a b) (Function.update.{u1, u2} α (fun (a : α) => β) (fun (a : α) (b : α) => _inst_1 a b) f j (f i)) i (f j))\nbut is expected to have type\n  forall {α : Sort.{u1}} [β : DecidableEq.{u1} α] {_inst_1 : Sort.{u2}} (i : α) (j : α) (f : α -> _inst_1), Eq.{imax u1 u2} (α -> _inst_1) (Function.comp.{u1, u1, u2} α α _inst_1 f (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{u1, u1} α α) (Equiv.swap.{u1} α (fun (a : α) (b : α) => β a b) i j))) (Function.update.{u1, u2} α (fun (ᾰ : α) => _inst_1) (fun (a : α) (b : α) => β a b) (Function.update.{u1, u2} α (fun (a : α) => _inst_1) (fun (a : α) (b : α) => β a b) f j (f i)) i (f j))\nCase conversion may be inaccurate. Consider using '#align equiv.comp_swap_eq_update Equiv.comp_swap_eq_updateₓ'. -/\ntheorem comp_swap_eq_update (i j : α) (f : α → β) :\n    f ∘ Equiv.swap i j = update (update f j (f i)) i (f j) := by\n  rw [swap_eq_update, comp_update, comp_update, comp.right_id]\n#align equiv.comp_swap_eq_update Equiv.comp_swap_eq_update\n\n/- warning: equiv.symm_trans_swap_trans -> Equiv.symm_trans_swap_trans is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] [_inst_2 : DecidableEq.{u2} β] (a : α) (b : α) (e : Equiv.{u1, u2} α β), Eq.{max 1 u2} (Equiv.{u2, u2} β β) (Equiv.trans.{u2, u1, u2} β α β (Equiv.trans.{u2, u1, u1} β α α (Equiv.symm.{u1, u2} α β e) (Equiv.swap.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a b)) e) (Equiv.swap.{u2} β (fun (a : β) (b : β) => _inst_2 a b) (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a) (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e b))\nbut is expected to have type\n  forall {α : Sort.{u1}} [β : DecidableEq.{u1} α] {_inst_1 : Sort.{u2}} [_inst_2 : DecidableEq.{u2} _inst_1] (a : α) (b : α) (e : Equiv.{u1, u2} α _inst_1), Eq.{max 1 u2} (Equiv.{u2, u2} _inst_1 _inst_1) (Equiv.trans.{u2, u1, u2} _inst_1 α _inst_1 (Equiv.trans.{u2, u1, u1} _inst_1 α α (Equiv.symm.{u1, u2} α _inst_1 e) (Equiv.swap.{u1} α (fun (a : α) (b : α) => β a b) a b)) e) (Equiv.swap.{u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => _inst_1) a) (fun (a : _inst_1) (b : _inst_1) => _inst_2 a b) (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} α _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => _inst_1) _x) (Equiv.instFunLikeEquiv.{u1, u2} α _inst_1) e a) (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} α _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => _inst_1) _x) (Equiv.instFunLikeEquiv.{u1, u2} α _inst_1) e b))\nCase conversion may be inaccurate. Consider using '#align equiv.symm_trans_swap_trans Equiv.symm_trans_swap_transₓ'. -/\n@[simp]\ntheorem symm_trans_swap_trans [DecidableEq β] (a b : α) (e : α ≃ β) :\n    (e.symm.trans (swap a b)).trans e = swap (e a) (e b) :=\n  Equiv.ext fun x =>\n    by\n    have : ∀ a, e.symm x = a ↔ x = e a := fun a =>\n      by\n      rw [@eq_comm _ (e.symm x)]\n      constructor <;> intros <;> simp_all\n    simp [swap_apply_def, this]\n    split_ifs <;> simp\n#align equiv.symm_trans_swap_trans Equiv.symm_trans_swap_trans\n\n/- warning: equiv.trans_swap_trans_symm -> Equiv.trans_swap_trans_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] [_inst_2 : DecidableEq.{u2} β] (a : β) (b : β) (e : Equiv.{u1, u2} α β), Eq.{max 1 u1} (Equiv.{u1, u1} α α) (Equiv.trans.{u1, u2, u1} α β α (Equiv.trans.{u1, u2, u2} α β β e (Equiv.swap.{u2} β (fun (a : β) (b : β) => _inst_2 a b) a b)) (Equiv.symm.{u1, u2} α β e)) (Equiv.swap.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) a) (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))\nbut is expected to have type\n  forall {α : Sort.{u1}} [β : DecidableEq.{u1} α] {_inst_1 : Sort.{u2}} [_inst_2 : DecidableEq.{u2} _inst_1] (a : _inst_1) (b : _inst_1) (e : Equiv.{u1, u2} α _inst_1), Eq.{max 1 u1} (Equiv.{u1, u1} α α) (Equiv.trans.{u1, u2, u1} α _inst_1 α (Equiv.trans.{u1, u2, u2} α _inst_1 _inst_1 e (Equiv.swap.{u2} _inst_1 (fun (a : _inst_1) (b : _inst_1) => _inst_2 a b) a b)) (Equiv.symm.{u1, u2} α _inst_1 e)) (Equiv.swap.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : _inst_1) => α) a) (fun (a : α) (b : α) => β a b) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Equiv.{u2, u1} _inst_1 α) _inst_1 (fun (_x : _inst_1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : _inst_1) => α) _x) (Equiv.instFunLikeEquiv.{u2, u1} _inst_1 α) (Equiv.symm.{u1, u2} α _inst_1 e) a) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Equiv.{u2, u1} _inst_1 α) _inst_1 (fun (_x : _inst_1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : _inst_1) => α) _x) (Equiv.instFunLikeEquiv.{u2, u1} _inst_1 α) (Equiv.symm.{u1, u2} α _inst_1 e) b))\nCase conversion may be inaccurate. Consider using '#align equiv.trans_swap_trans_symm Equiv.trans_swap_trans_symmₓ'. -/\n@[simp]\ntheorem trans_swap_trans_symm [DecidableEq β] (a b : β) (e : α ≃ β) :\n    (e.trans (swap a b)).trans e.symm = swap (e.symm a) (e.symm b) :=\n  symm_trans_swap_trans a b e.symm\n#align equiv.trans_swap_trans_symm Equiv.trans_swap_trans_symm\n\n#print Equiv.swap_apply_self /-\n@[simp]\ntheorem swap_apply_self (i j a : α) : swap i j (swap i j a) = a := by\n  rw [← Equiv.trans_apply, Equiv.swap_swap, Equiv.refl_apply]\n#align equiv.swap_apply_self Equiv.swap_apply_self\n-/\n\n/- warning: equiv.apply_swap_eq_self -> Equiv.apply_swap_eq_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] {v : α -> β} {i : α} {j : α}, (Eq.{u2} β (v i) (v j)) -> (forall (k : α), Eq.{u2} β (v (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} α) (fun (_x : Equiv.{u1, u1} α α) => α -> α) (Equiv.hasCoeToFun.{u1, u1} α α) (Equiv.swap.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i j) k)) (v k))\nbut is expected to have type\n  forall {α : Sort.{u1}} [β : DecidableEq.{u1} α] {_inst_1 : Sort.{u2}} {v : α -> _inst_1} {i : α} {j : α}, (Eq.{u2} _inst_1 (v i) (v j)) -> (forall (k : α), Eq.{u2} _inst_1 (v (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{u1, u1} α α) (Equiv.swap.{u1} α (fun (a : α) (b : α) => β a b) i j) k)) (v k))\nCase conversion may be inaccurate. Consider using '#align equiv.apply_swap_eq_self Equiv.apply_swap_eq_selfₓ'. -/\n/-- A function is invariant to a swap if it is equal at both elements -/\ntheorem apply_swap_eq_self {v : α → β} {i j : α} (hv : v i = v j) (k : α) : v (swap i j k) = v k :=\n  by\n  by_cases hi : k = i; · rw [hi, swap_apply_left, hv]\n  by_cases hj : k = j; · rw [hj, swap_apply_right, hv]\n  rw [swap_apply_of_ne_of_ne hi hj]\n#align equiv.apply_swap_eq_self Equiv.apply_swap_eq_self\n\n#print Equiv.swap_apply_eq_iff /-\ntheorem swap_apply_eq_iff {x y z w : α} : swap x y z = w ↔ z = swap x y w := by\n  rw [apply_eq_iff_eq_symm_apply, symm_swap]\n#align equiv.swap_apply_eq_iff Equiv.swap_apply_eq_iff\n-/\n\n#print Equiv.swap_apply_ne_self_iff /-\ntheorem swap_apply_ne_self_iff {a b x : α} : swap a b x ≠ x ↔ a ≠ b ∧ (x = a ∨ x = b) :=\n  by\n  by_cases hab : a = b\n  · simp [hab]\n  by_cases hax : x = a\n  · simp [hax, eq_comm]\n  by_cases hbx : x = b\n  · simp [hbx]\n  simp [hab, hax, hbx, swap_apply_of_ne_of_ne]\n#align equiv.swap_apply_ne_self_iff Equiv.swap_apply_ne_self_iff\n-/\n\nnamespace Perm\n\n/- warning: equiv.perm.sum_congr_swap_refl -> Equiv.Perm.sumCongr_swap_refl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_2 : DecidableEq.{succ u1} α] [_inst_3 : DecidableEq.{succ u2} β] (i : α) (j : α), Eq.{max 1 (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)) (Equiv.Perm.sumCongr.{u1, u2} α β (Equiv.swap.{succ u1} α (fun (a : α) (b : α) => _inst_2 a b) i j) (Equiv.refl.{succ u2} β)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => Sum.decidableEq.{u1, u2} α (fun (a : α) (b : α) => _inst_2 a b) β (fun (a : β) (b : β) => _inst_3 a b) a b) (Sum.inl.{u1, u2} α β i) (Sum.inl.{u1, u2} α β j))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_2 : DecidableEq.{succ u2} α] [_inst_3 : DecidableEq.{succ u1} β] (i : α) (j : α), Eq.{max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β)) (Equiv.Perm.sumCongr.{u2, u1} α β (Equiv.swap.{succ u2} α (fun (a : α) (b : α) => _inst_2 a b) i j) (Equiv.refl.{succ u1} β)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (fun (a : Sum.{u2, u1} α β) (b : Sum.{u2, u1} α β) => Sum.instDecidableEqSum.{u2, u1} α β (fun (a : α) (b : α) => _inst_2 a b) (fun (a : β) (b : β) => _inst_3 a b) a b) (Sum.inl.{u2, u1} α β i) (Sum.inl.{u2, u1} α β j))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_swap_refl Equiv.Perm.sumCongr_swap_reflₓ'. -/\n@[simp]\ntheorem sumCongr_swap_refl {α β : Sort _} [DecidableEq α] [DecidableEq β] (i j : α) :\n    Equiv.Perm.sumCongr (Equiv.swap i j) (Equiv.refl β) = Equiv.swap (Sum.inl i) (Sum.inl j) :=\n  by\n  ext x\n  cases x\n  · simp [Sum.map, swap_apply_def]\n    split_ifs <;> rfl\n  · simp [Sum.map, swap_apply_of_ne_of_ne]\n#align equiv.perm.sum_congr_swap_refl Equiv.Perm.sumCongr_swap_refl\n\n/- warning: equiv.perm.sum_congr_refl_swap -> Equiv.Perm.sumCongr_refl_swap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_2 : DecidableEq.{succ u1} α] [_inst_3 : DecidableEq.{succ u2} β] (i : β) (j : β), Eq.{max 1 (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)) (Equiv.Perm.sumCongr.{u1, u2} α β (Equiv.refl.{succ u1} α) (Equiv.swap.{succ u2} β (fun (a : β) (b : β) => _inst_3 a b) i j)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => Sum.decidableEq.{u1, u2} α (fun (a : α) (b : α) => _inst_2 a b) β (fun (a : β) (b : β) => _inst_3 a b) a b) (Sum.inr.{u1, u2} α β i) (Sum.inr.{u1, u2} α β j))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_2 : DecidableEq.{succ u2} α] [_inst_3 : DecidableEq.{succ u1} β] (i : β) (j : β), Eq.{max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β)) (Equiv.Perm.sumCongr.{u2, u1} α β (Equiv.refl.{succ u2} α) (Equiv.swap.{succ u1} β (fun (a : β) (b : β) => _inst_3 a b) i j)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β) (fun (a : Sum.{u2, u1} α β) (b : Sum.{u2, u1} α β) => Sum.instDecidableEqSum.{u2, u1} α β (fun (a : α) (b : α) => _inst_2 a b) (fun (a : β) (b : β) => _inst_3 a b) a b) (Sum.inr.{u2, u1} α β i) (Sum.inr.{u2, u1} α β j))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_refl_swap Equiv.Perm.sumCongr_refl_swapₓ'. -/\n@[simp]\ntheorem sumCongr_refl_swap {α β : Sort _} [DecidableEq α] [DecidableEq β] (i j : β) :\n    Equiv.Perm.sumCongr (Equiv.refl α) (Equiv.swap i j) = Equiv.swap (Sum.inr i) (Sum.inr j) :=\n  by\n  ext x\n  cases x\n  · simp [Sum.map, swap_apply_of_ne_of_ne]\n  · simp [Sum.map, swap_apply_def]\n    split_ifs <;> rfl\n#align equiv.perm.sum_congr_refl_swap Equiv.Perm.sumCongr_refl_swap\n\nend Perm\n\n/- warning: equiv.set_value -> Equiv.setValue is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α], (Equiv.{u1, u2} α β) -> α -> β -> (Equiv.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Sort.{u1}} [β : DecidableEq.{u1} α] {_inst_1 : Sort.{u2}}, (Equiv.{u1, u2} α _inst_1) -> α -> _inst_1 -> (Equiv.{u1, u2} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align equiv.set_value Equiv.setValueₓ'. -/\n/-- Augment an equivalence with a prescribed mapping `f a = b` -/\ndef setValue (f : α ≃ β) (a : α) (b : β) : α ≃ β :=\n  (swap a (f.symm b)).trans f\n#align equiv.set_value Equiv.setValue\n\n/- warning: equiv.set_value_eq -> Equiv.setValue_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] (f : Equiv.{u1, u2} α β) (a : α) (b : β), Eq.{u2} β (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) (Equiv.setValue.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) f a b) a) b\nbut is expected to have type\n  forall {α : Sort.{u1}} [β : DecidableEq.{u1} α] {_inst_1 : Sort.{u2}} (f : Equiv.{u1, u2} α _inst_1) (a : α) (b : _inst_1), Eq.{u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => _inst_1) a) (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} α _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => _inst_1) _x) (Equiv.instFunLikeEquiv.{u1, u2} α _inst_1) (Equiv.setValue.{u1, u2} α (fun (a : α) (b : α) => β a b) _inst_1 f a b) a) b\nCase conversion may be inaccurate. Consider using '#align equiv.set_value_eq Equiv.setValue_eqₓ'. -/\n@[simp]\ntheorem setValue_eq (f : α ≃ β) (a : α) (b : β) : setValue f a b a = b :=\n  by\n  dsimp [set_value]\n  simp [swap_apply_left]\n#align equiv.set_value_eq Equiv.setValue_eq\n\nend Swap\n\nend Equiv\n\nnamespace Function.Involutive\n\n#print Function.Involutive.toPerm /-\n/-- Convert an involutive function `f` to a permutation with `to_fun = inv_fun = f`. -/\ndef toPerm (f : α → α) (h : Involutive f) : Equiv.Perm α :=\n  ⟨f, f, h.LeftInverse, h.RightInverse⟩\n#align function.involutive.to_perm Function.Involutive.toPerm\n-/\n\n#print Function.Involutive.coe_toPerm /-\n@[simp]\ntheorem coe_toPerm {f : α → α} (h : Involutive f) : (h.toPerm f : α → α) = f :=\n  rfl\n#align function.involutive.coe_to_perm Function.Involutive.coe_toPerm\n-/\n\n#print Function.Involutive.toPerm_symm /-\n@[simp]\ntheorem toPerm_symm {f : α → α} (h : Involutive f) : (h.toPerm f).symm = h.toPerm f :=\n  rfl\n#align function.involutive.to_perm_symm Function.Involutive.toPerm_symm\n-/\n\n#print Function.Involutive.toPerm_involutive /-\ntheorem toPerm_involutive {f : α → α} (h : Involutive f) : Involutive (h.toPerm f) :=\n  h\n#align function.involutive.to_perm_involutive Function.Involutive.toPerm_involutive\n-/\n\nend Function.Involutive\n\n#print PLift.eq_up_iff_down_eq /-\ntheorem PLift.eq_up_iff_down_eq {x : PLift α} {y : α} : x = PLift.up y ↔ x.down = y :=\n  Equiv.plift.eq_symm_apply\n#align plift.eq_up_iff_down_eq PLift.eq_up_iff_down_eq\n-/\n\n/- warning: function.injective.map_swap -> Function.Injective.map_swap is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] [_inst_2 : DecidableEq.{u2} β] {f : α -> β}, (Function.Injective.{u1, u2} α β f) -> (forall (x : α) (y : α) (z : α), Eq.{u2} β (f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} α) (fun (_x : Equiv.{u1, u1} α α) => α -> α) (Equiv.hasCoeToFun.{u1, u1} α α) (Equiv.swap.{u1} α (fun (a : α) (b : α) => _inst_1 a b) x y) z)) (coeFn.{max 1 u2, u2} (Equiv.Perm.{u2} β) (fun (_x : Equiv.{u2, u2} β β) => β -> β) (Equiv.hasCoeToFun.{u2, u2} β β) (Equiv.swap.{u2} β (fun (a : β) (b : β) => _inst_2 a b) (f x) (f y)) (f z)))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : DecidableEq.{u2} α] [_inst_2 : DecidableEq.{u1} β] {f : α -> β}, (Function.Injective.{u2, u1} α β f) -> (forall (x : α) (y : α) (z : α), Eq.{u1} β (f (FunLike.coe.{max 1 u2, u2, u2} (Equiv.Perm.{u2} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{u2, u2} α α) (Equiv.swap.{u2} α (fun (a : α) (b : α) => _inst_1 a b) x y) z)) (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} β) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => β) _x) (Equiv.instFunLikeEquiv.{u1, u1} β β) (Equiv.swap.{u1} β (fun (a : β) (b : β) => _inst_2 a b) (f x) (f y)) (f z)))\nCase conversion may be inaccurate. Consider using '#align function.injective.map_swap Function.Injective.map_swapₓ'. -/\ntheorem Function.Injective.map_swap {α β : Sort _} [DecidableEq α] [DecidableEq β] {f : α → β}\n    (hf : Function.Injective f) (x y z : α) : f (Equiv.swap x y z) = Equiv.swap (f x) (f y) (f z) :=\n  by\n  conv_rhs => rw [Equiv.swap_apply_def]\n  split_ifs with h₁ h₂\n  · rw [hf h₁, Equiv.swap_apply_left]\n  · rw [hf h₂, Equiv.swap_apply_right]\n  · rw [Equiv.swap_apply_of_ne_of_ne (mt (congr_arg f) h₁) (mt (congr_arg f) h₂)]\n#align function.injective.map_swap Function.Injective.map_swap\n\nnamespace Equiv\n\nsection\n\nvariable (P : α → Sort w) (e : α ≃ β)\n\n#print Equiv.piCongrLeft' /-\n/-- Transport dependent functions through an equivalence of the base space.\n-/\n@[simps]\ndef piCongrLeft' : (∀ a, P a) ≃ ∀ b, P (e.symm b)\n    where\n  toFun f x := f (e.symm x)\n  invFun f x := by rw [← e.symm_apply_apply x]; exact f (e x)\n  left_inv f :=\n    funext fun x =>\n      eq_of_hEq\n        ((eq_rec_hEq _ _).trans\n          (by\n            dsimp\n            rw [e.symm_apply_apply]))\n  right_inv f := funext fun x => eq_of_hEq ((eq_rec_hEq _ _).trans (by rw [e.apply_symm_apply]))\n#align equiv.Pi_congr_left' Equiv.piCongrLeft'\n-/\n\nend\n\nsection\n\nvariable (P : β → Sort w) (e : α ≃ β)\n\n/- warning: equiv.Pi_congr_left -> Equiv.piCongrLeft is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (P : β -> Sort.{u3}) (e : Equiv.{u1, u2} α β), Equiv.{imax u1 u3, imax u2 u3} (forall (a : α), P (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) e a)) (forall (b : β), P b)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u3}} (P : α -> Sort.{u1}) (e : Equiv.{u3, u2} β α), Equiv.{imax u3 u1, imax u2 u1} (forall (a : β), P (FunLike.coe.{max (max 1 u2) u3, u3, u2} (Equiv.{u3, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u3, u2} β α) e a)) (forall (b : α), P b)\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr_left Equiv.piCongrLeftₓ'. -/\n/-- Transporting dependent functions through an equivalence of the base,\nexpressed as a \"simplification\".\n-/\ndef piCongrLeft : (∀ a, P (e a)) ≃ ∀ b, P b :=\n  (piCongrLeft' P e.symm).symm\n#align equiv.Pi_congr_left Equiv.piCongrLeft\n\nend\n\nsection\n\nvariable {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β) (h₂ : ∀ a : α, W a ≃ Z (h₁ a))\n\n/- warning: equiv.Pi_congr -> Equiv.piCongr is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u1, u2} α β), (forall (a : α), Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a))) -> (Equiv.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), Z b))\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u4}} {W : α -> Sort.{u1}} {Z : β -> Sort.{u2}} (h₁ : Equiv.{u3, u4} α β), (forall (a : α), Equiv.{u1, u2} (W a) (Z (FunLike.coe.{max (max 1 u3) u4, u3, u4} (Equiv.{u3, u4} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u4} α β) h₁ a))) -> (Equiv.{imax u3 u1, imax u4 u2} (forall (a : α), W a) (forall (b : β), Z b))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr Equiv.piCongrₓ'. -/\n/-- Transport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibers.\n-/\ndef piCongr : (∀ a, W a) ≃ ∀ b, Z b :=\n  (Equiv.piCongrRight h₂).trans (Equiv.piCongrLeft _ h₁)\n#align equiv.Pi_congr Equiv.piCongr\n\n#print Equiv.coe_piCongr_symm /-\n@[simp]\ntheorem coe_piCongr_symm :\n    ((h₁.piCongr h₂).symm : (∀ b, Z b) → ∀ a, W a) = fun f a => (h₂ a).symm (f (h₁ a)) :=\n  rfl\n#align equiv.coe_Pi_congr_symm Equiv.coe_piCongr_symm\n-/\n\n/- warning: equiv.Pi_congr_symm_apply -> Equiv.piCongr_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u1, u2} α β) (h₂ : forall (a : α), Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a))) (f : forall (b : β), Z b), Eq.{imax u1 u3} (forall (a : α), W a) (coeFn.{max 1 (imax (imax u2 u4) u1 u3) (imax (imax u1 u3) u2 u4), imax (imax u2 u4) u1 u3} (Equiv.{imax u2 u4, imax u1 u3} (forall (b : β), Z b) (forall (a : α), W a)) (fun (_x : Equiv.{imax u2 u4, imax u1 u3} (forall (b : β), Z b) (forall (a : α), W a)) => (forall (b : β), Z b) -> (forall (a : α), W a)) (Equiv.hasCoeToFun.{imax u2 u4, imax u1 u3} (forall (b : β), Z b) (forall (a : α), W a)) (Equiv.symm.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), Z b) (Equiv.piCongr.{u1, u2, u3, u4} α β (fun (a : α) => W a) Z h₁ h₂)) f) (fun (a : α) => coeFn.{max 1 (imax u4 u3) (imax u3 u4), imax u4 u3} (Equiv.{u4, u3} (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)) (W a)) (fun (_x : Equiv.{u4, u3} (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)) (W a)) => (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)) -> (W a)) (Equiv.hasCoeToFun.{u4, u3} (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)) (W a)) (Equiv.symm.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)) (h₂ a)) (f (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u2, u1} α β) (h₂ : forall (a : α), Equiv.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a))) (f : forall (b : β), Z b), Eq.{imax u2 u3} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : β), Z b) => forall (a : α), W a) f) (FunLike.coe.{max (max 1 (imax u2 u3)) (imax u1 u4), imax u1 u4, imax u2 u3} (Equiv.{imax u1 u4, imax u2 u3} (forall (b : β), Z b) (forall (a : α), W a)) (forall (b : β), Z b) (fun (_x : forall (b : β), Z b) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : β), Z b) => forall (a : α), W a) _x) (Equiv.instFunLikeEquiv.{imax u1 u4, imax u2 u3} (forall (b : β), Z b) (forall (a : α), W a)) (Equiv.symm.{imax u2 u3, imax u1 u4} (forall (a : α), W a) (forall (b : β), Z b) (Equiv.piCongr.{u3, u4, u2, u1} α β (fun (a : α) => W a) Z h₁ h₂)) f) (fun (a : α) => FunLike.coe.{max (max 1 u3) u4, u4, u3} (Equiv.{u4, u3} (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) (W a)) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) (fun (_x : Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) => W a) _x) (Equiv.instFunLikeEquiv.{u4, u3} (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) (W a)) (Equiv.symm.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) (h₂ a)) (f (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr_symm_apply Equiv.piCongr_symm_applyₓ'. -/\ntheorem piCongr_symm_apply (f : ∀ b, Z b) :\n    (h₁.piCongr h₂).symm f = fun a => (h₂ a).symm (f (h₁ a)) :=\n  rfl\n#align equiv.Pi_congr_symm_apply Equiv.piCongr_symm_apply\n\n/- warning: equiv.Pi_congr_apply_apply -> Equiv.piCongr_apply_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u1, u2} α β) (h₂ : forall (a : α), Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a))) (f : forall (a : α), W a) (a : α), Eq.{u4} (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)) (coeFn.{max 1 (imax (imax u1 u3) u2 u4) (imax (imax u2 u4) u1 u3), imax (imax u1 u3) u2 u4} (Equiv.{imax u1 u3, imax u2 u4} (forall (a : α), (fun (a : α) => W a) a) (forall (b : β), Z b)) (fun (_x : Equiv.{imax u1 u3, imax u2 u4} (forall (a : α), (fun (a : α) => W a) a) (forall (b : β), Z b)) => (forall (a : α), (fun (a : α) => W a) a) -> (forall (b : β), Z b)) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u4} (forall (a : α), (fun (a : α) => W a) a) (forall (b : β), Z b)) (Equiv.piCongr.{u1, u2, u3, u4} α β (fun (a : α) => W a) Z h₁ h₂) f (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a)) (coeFn.{max 1 (imax u3 u4) (imax u4 u3), imax u3 u4} (Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a))) (fun (_x : Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a))) => (W a) -> (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a))) (Equiv.hasCoeToFun.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} α β) (fun (_x : Equiv.{u1, u2} α β) => α -> β) (Equiv.hasCoeToFun.{u1, u2} α β) h₁ a))) (h₂ a) (f a))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u2, u1} α β) (h₂ : forall (a : α), Equiv.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a))) (f : forall (a : α), W a) (a : α), Eq.{u4} (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) (FunLike.coe.{max (max 1 (imax u2 u3)) (imax u1 u4), imax u2 u3, imax u1 u4} (Equiv.{imax u2 u3, imax u1 u4} (forall (a : α), W a) (forall (b : β), Z b)) (forall (a : α), W a) (fun (_x : forall (a : α), W a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : α), W a) => forall (b : β), Z b) _x) (Equiv.instFunLikeEquiv.{imax u2 u3, imax u1 u4} (forall (a : α), W a) (forall (b : β), Z b)) (Equiv.piCongr.{u3, u4, u2, u1} α β (fun (a : α) => W a) Z h₁ h₂) f (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) (FunLike.coe.{max (max 1 u3) u4, u3, u4} (Equiv.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a))) (W a) (fun (_x : W a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : W a) => Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) a) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a)) _x) (Equiv.instFunLikeEquiv.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u2, u1} α β) h₁ a))) (h₂ a) (f a))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr_apply_apply Equiv.piCongr_apply_applyₓ'. -/\n@[simp]\ntheorem piCongr_apply_apply (f : ∀ a, W a) (a : α) : h₁.piCongr h₂ f (h₁ a) = h₂ a (f a) :=\n  by\n  change cast _ ((h₂ (h₁.symm (h₁ a))) (f (h₁.symm (h₁ a)))) = (h₂ a) (f a)\n  generalize_proofs hZa\n  revert hZa\n  rw [h₁.symm_apply_apply a]\n  simp\n#align equiv.Pi_congr_apply_apply Equiv.piCongr_apply_apply\n\nend\n\nsection\n\nvariable {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β) (h₂ : ∀ b : β, W (h₁.symm b) ≃ Z b)\n\n/- warning: equiv.Pi_congr' -> Equiv.piCongr' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u1, u2} α β), (forall (b : β), Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (Z b)) -> (Equiv.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), Z b))\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u4}} {W : α -> Sort.{u1}} {Z : β -> Sort.{u2}} (h₁ : Equiv.{u3, u4} α β), (forall (b : β), Equiv.{u1, u2} (W (FunLike.coe.{max (max 1 u3) u4, u4, u3} (Equiv.{u4, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u4, u3} β α) (Equiv.symm.{u3, u4} α β h₁) b)) (Z b)) -> (Equiv.{imax u3 u1, imax u4 u2} (forall (a : α), W a) (forall (b : β), Z b))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr' Equiv.piCongr'ₓ'. -/\n/-- Transport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibres.\n-/\ndef piCongr' : (∀ a, W a) ≃ ∀ b, Z b :=\n  (piCongr h₁.symm fun b => (h₂ b).symm).symm\n#align equiv.Pi_congr' Equiv.piCongr'\n\n/- warning: equiv.coe_Pi_congr' -> Equiv.coe_piCongr' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u1, u2} α β) (h₂ : forall (b : β), Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (Z b)), Eq.{imax (imax u1 u3) u2 u4} ((fun (_x : Equiv.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), (fun (b : β) => Z b) b)) => (forall (a : α), W a) -> (forall (b : β), (fun (b : β) => Z b) b)) (Equiv.piCongr'.{u1, u2, u3, u4} α β W (fun (b : β) => Z b) h₁ h₂)) (coeFn.{max 1 (imax (imax u1 u3) u2 u4) (imax (imax u2 u4) u1 u3), imax (imax u1 u3) u2 u4} (Equiv.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), (fun (b : β) => Z b) b)) (fun (_x : Equiv.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), (fun (b : β) => Z b) b)) => (forall (a : α), W a) -> (forall (b : β), (fun (b : β) => Z b) b)) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), (fun (b : β) => Z b) b)) (Equiv.piCongr'.{u1, u2, u3, u4} α β W (fun (b : β) => Z b) h₁ h₂)) (fun (f : forall (a : α), W a) (b : β) => coeFn.{max 1 (imax u3 u4) (imax u4 u3), imax u3 u4} (Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (Z b)) (fun (_x : Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (Z b)) => (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) -> (Z b)) (Equiv.hasCoeToFun.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (Z b)) (h₂ b) (f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u2, u1} α β) (h₂ : forall (b : β), Equiv.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (Z b)), Eq.{imax (imax u2 u3) u1 u4} (forall (a : forall (a : α), W a), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : α), W a) => forall (b : β), Z b) a) (FunLike.coe.{max (max 1 (imax u2 u3)) (imax u1 u4), imax u2 u3, imax u1 u4} (Equiv.{imax u2 u3, imax u1 u4} (forall (a : α), W a) (forall (b : β), Z b)) (forall (a : α), W a) (fun (_x : forall (a : α), W a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : α), W a) => forall (b : β), Z b) _x) (Equiv.instFunLikeEquiv.{imax u2 u3, imax u1 u4} (forall (a : α), W a) (forall (b : β), Z b)) (Equiv.piCongr'.{u3, u4, u2, u1} α β W (fun (b : β) => Z b) h₁ h₂)) (fun (f : forall (a : α), W a) (b : β) => FunLike.coe.{max (max 1 u3) u4, u3, u4} (Equiv.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (Z b)) (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (fun (_x : W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) => Z b) _x) (Equiv.instFunLikeEquiv.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (Z b)) (h₂ b) (f (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)))\nCase conversion may be inaccurate. Consider using '#align equiv.coe_Pi_congr' Equiv.coe_piCongr'ₓ'. -/\n@[simp]\ntheorem coe_piCongr' :\n    (h₁.piCongr' h₂ : (∀ a, W a) → ∀ b, Z b) = fun f b => h₂ b <| f <| h₁.symm b :=\n  rfl\n#align equiv.coe_Pi_congr' Equiv.coe_piCongr'\n\n#print Equiv.piCongr'_apply /-\ntheorem piCongr'_apply (f : ∀ a, W a) : h₁.piCongr' h₂ f = fun b => h₂ b <| f <| h₁.symm b :=\n  rfl\n#align equiv.Pi_congr'_apply Equiv.piCongr'_apply\n-/\n\n/- warning: equiv.Pi_congr'_symm_apply_symm_apply -> Equiv.piCongr'_symm_apply_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u1, u2} α β) (h₂ : forall (b : β), Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (Z b)) (f : forall (b : β), Z b) (b : β), Eq.{u3} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (coeFn.{max 1 (imax (imax u2 u4) u1 u3) (imax (imax u1 u3) u2 u4), imax (imax u2 u4) u1 u3} (Equiv.{imax u2 u4, imax u1 u3} (forall (b : β), Z b) (forall (a : α), W a)) (fun (_x : Equiv.{imax u2 u4, imax u1 u3} (forall (b : β), Z b) (forall (a : α), W a)) => (forall (b : β), Z b) -> (forall (a : α), W a)) (Equiv.hasCoeToFun.{imax u2 u4, imax u1 u3} (forall (b : β), Z b) (forall (a : α), W a)) (Equiv.symm.{imax u1 u3, imax u2 u4} (forall (a : α), W a) (forall (b : β), Z b) (Equiv.piCongr'.{u1, u2, u3, u4} α β W (fun (b : β) => Z b) h₁ h₂)) f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (coeFn.{max 1 (imax u4 u3) (imax u3 u4), imax u4 u3} (Equiv.{u4, u3} (Z b) (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b))) (fun (_x : Equiv.{u4, u3} (Z b) (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b))) => (Z b) -> (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b))) (Equiv.hasCoeToFun.{u4, u3} (Z b) (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b))) (Equiv.symm.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β h₁) b)) (Z b) (h₂ b)) (f b))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {W : α -> Sort.{u3}} {Z : β -> Sort.{u4}} (h₁ : Equiv.{u2, u1} α β) (h₂ : forall (b : β), Equiv.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (Z b)) (f : forall (b : β), Z b) (b : β), Eq.{u3} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (FunLike.coe.{max (max 1 (imax u2 u3)) (imax u1 u4), imax u1 u4, imax u2 u3} (Equiv.{imax u1 u4, imax u2 u3} (forall (b : β), Z b) (forall (a : α), W a)) (forall (b : β), Z b) (fun (_x : forall (b : β), Z b) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : β), Z b) => forall (a : α), W a) _x) (Equiv.instFunLikeEquiv.{imax u1 u4, imax u2 u3} (forall (b : β), Z b) (forall (a : α), W a)) (Equiv.symm.{imax u2 u3, imax u1 u4} (forall (a : α), W a) (forall (b : β), Z b) (Equiv.piCongr'.{u3, u4, u2, u1} α β W (fun (b : β) => Z b) h₁ h₂)) f (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (FunLike.coe.{max (max 1 u3) u4, u4, u3} (Equiv.{u4, u3} (Z b) (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b))) (Z b) (fun (_x : Z b) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Z b) => W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) _x) (Equiv.instFunLikeEquiv.{u4, u3} (Z b) (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b))) (Equiv.symm.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u1, u2} β α) (Equiv.symm.{u2, u1} α β h₁) b)) (Z b) (h₂ b)) (f b))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr'_symm_apply_symm_apply Equiv.piCongr'_symm_apply_symm_applyₓ'. -/\n@[simp]\ntheorem piCongr'_symm_apply_symm_apply (f : ∀ b, Z b) (b : β) :\n    (h₁.piCongr' h₂).symm f (h₁.symm b) = (h₂ b).symm (f b) :=\n  by\n  change cast _ ((h₂ (h₁ (h₁.symm b))).symm (f (h₁ (h₁.symm b)))) = (h₂ b).symm (f b)\n  generalize_proofs hWb\n  revert hWb\n  generalize hb : h₁ (h₁.symm b) = b'\n  rw [h₁.apply_symm_apply b] at hb\n  subst hb\n  simp\n#align equiv.Pi_congr'_symm_apply_symm_apply Equiv.piCongr'_symm_apply_symm_apply\n\nend\n\nsection BinaryOp\n\nvariable {α₁ β₁ : Type _} (e : α₁ ≃ β₁) (f : α₁ → α₁ → α₁)\n\n/- warning: equiv.semiconj_conj -> Equiv.semiconj_conj is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} (e : Equiv.{succ u1, succ u2} α₁ β₁) (f : α₁ -> α₁), Function.Semiconj.{u1, u2} α₁ β₁ (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} α₁ β₁) (fun (_x : Equiv.{succ u1, succ u2} α₁ β₁) => α₁ -> β₁) (Equiv.hasCoeToFun.{succ u1, succ u2} α₁ β₁) e) f (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} (α₁ -> α₁) (β₁ -> β₁)) (fun (_x : Equiv.{succ u1, succ u2} (α₁ -> α₁) (β₁ -> β₁)) => (α₁ -> α₁) -> β₁ -> β₁) (Equiv.hasCoeToFun.{succ u1, succ u2} (α₁ -> α₁) (β₁ -> β₁)) (Equiv.conj.{succ u1, succ u2} α₁ β₁ e) f)\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {β₁ : Type.{u1}} (e : Equiv.{succ u2, succ u1} α₁ β₁) (f : α₁ -> α₁), Function.Semiconj.{u2, u1} α₁ β₁ (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} α₁ β₁) α₁ (fun (_x : α₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α₁) => β₁) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} α₁ β₁) e) f (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} (α₁ -> α₁) (β₁ -> β₁)) (α₁ -> α₁) (fun (_x : α₁ -> α₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α₁ -> α₁) => β₁ -> β₁) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} (α₁ -> α₁) (β₁ -> β₁)) (Equiv.conj.{succ u2, succ u1} α₁ β₁ e) f)\nCase conversion may be inaccurate. Consider using '#align equiv.semiconj_conj Equiv.semiconj_conjₓ'. -/\ntheorem semiconj_conj (f : α₁ → α₁) : Semiconj e f (e.conj f) := fun x => by simp\n#align equiv.semiconj_conj Equiv.semiconj_conj\n\n/- warning: equiv.semiconj₂_conj -> Equiv.semiconj₂_conj is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {β₁ : Type.{u2}} (e : Equiv.{succ u1, succ u2} α₁ β₁) (f : α₁ -> α₁ -> α₁), Function.Semiconj₂.{u1, u2} α₁ β₁ (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} α₁ β₁) (fun (_x : Equiv.{succ u1, succ u2} α₁ β₁) => α₁ -> β₁) (Equiv.hasCoeToFun.{succ u1, succ u2} α₁ β₁) e) f (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} (α₁ -> α₁ -> α₁) (β₁ -> β₁ -> β₁)) (fun (_x : Equiv.{succ u1, succ u2} (α₁ -> α₁ -> α₁) (β₁ -> β₁ -> β₁)) => (α₁ -> α₁ -> α₁) -> β₁ -> β₁ -> β₁) (Equiv.hasCoeToFun.{succ u1, succ u2} (α₁ -> α₁ -> α₁) (β₁ -> β₁ -> β₁)) (Equiv.arrowCongr.{succ u1, succ u1, succ u2, succ u2} α₁ (α₁ -> α₁) β₁ (β₁ -> β₁) e (Equiv.conj.{succ u1, succ u2} α₁ β₁ e)) f)\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {β₁ : Type.{u1}} (e : Equiv.{succ u2, succ u1} α₁ β₁) (f : α₁ -> α₁ -> α₁), Function.Semiconj₂.{u2, u1} α₁ β₁ (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} α₁ β₁) α₁ (fun (_x : α₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α₁) => β₁) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} α₁ β₁) e) f (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} (α₁ -> α₁ -> α₁) (β₁ -> β₁ -> β₁)) (α₁ -> α₁ -> α₁) (fun (_x : α₁ -> α₁ -> α₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α₁ -> α₁ -> α₁) => β₁ -> β₁ -> β₁) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} (α₁ -> α₁ -> α₁) (β₁ -> β₁ -> β₁)) (Equiv.arrowCongr.{succ u2, succ u2, succ u1, succ u1} α₁ (α₁ -> α₁) β₁ (β₁ -> β₁) e (Equiv.conj.{succ u2, succ u1} α₁ β₁ e)) f)\nCase conversion may be inaccurate. Consider using '#align equiv.semiconj₂_conj Equiv.semiconj₂_conjₓ'. -/\ntheorem semiconj₂_conj : Semiconj₂ e f (e.arrowCongr e.conj f) := fun x y => by simp\n#align equiv.semiconj₂_conj Equiv.semiconj₂_conj\n\ninstance [IsAssociative α₁ f] : IsAssociative β₁ (e.arrowCongr (e.arrowCongr e) f) :=\n  (e.semiconj₂_conj f).isAssociative_right e.Surjective\n\ninstance [IsIdempotent α₁ f] : IsIdempotent β₁ (e.arrowCongr (e.arrowCongr e) f) :=\n  (e.semiconj₂_conj f).isIdempotent_right e.Surjective\n\ninstance [IsLeftCancel α₁ f] : IsLeftCancel β₁ (e.arrowCongr (e.arrowCongr e) f) :=\n  ⟨e.Surjective.forall₃.2 fun x y z => by simpa using @IsLeftCancel.left_cancel _ f _ x y z⟩\n\ninstance [IsRightCancel α₁ f] : IsRightCancel β₁ (e.arrowCongr (e.arrowCongr e) f) :=\n  ⟨e.Surjective.forall₃.2 fun x y z => by simpa using @IsRightCancel.right_cancel _ f _ x y z⟩\n\nend BinaryOp\n\nend Equiv\n\n/- warning: function.injective.swap_apply -> Function.Injective.swap_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] [_inst_2 : DecidableEq.{u2} β] {f : α -> β}, (Function.Injective.{u1, u2} α β f) -> (forall (x : α) (y : α) (z : α), Eq.{u2} β (coeFn.{max 1 u2, u2} (Equiv.Perm.{u2} β) (fun (_x : Equiv.{u2, u2} β β) => β -> β) (Equiv.hasCoeToFun.{u2, u2} β β) (Equiv.swap.{u2} β (fun (a : β) (b : β) => _inst_2 a b) (f x) (f y)) (f z)) (f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} α) (fun (_x : Equiv.{u1, u1} α α) => α -> α) (Equiv.hasCoeToFun.{u1, u1} α α) (Equiv.swap.{u1} α (fun (a : α) (b : α) => _inst_1 a b) x y) z)))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : DecidableEq.{u2} α] [_inst_2 : DecidableEq.{u1} β] {f : α -> β}, (Function.Injective.{u2, u1} α β f) -> (forall (x : α) (y : α) (z : α), Eq.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => β) (f z)) (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} β) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => β) _x) (Equiv.instFunLikeEquiv.{u1, u1} β β) (Equiv.swap.{u1} β (fun (a : β) (b : β) => _inst_2 a b) (f x) (f y)) (f z)) (f (FunLike.coe.{max 1 u2, u2, u2} (Equiv.Perm.{u2} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{u2, u2} α α) (Equiv.swap.{u2} α (fun (a : α) (b : α) => _inst_1 a b) x y) z)))\nCase conversion may be inaccurate. Consider using '#align function.injective.swap_apply Function.Injective.swap_applyₓ'. -/\ntheorem Function.Injective.swap_apply [DecidableEq α] [DecidableEq β] {f : α → β}\n    (hf : Function.Injective f) (x y z : α) : Equiv.swap (f x) (f y) (f z) = f (Equiv.swap x y z) :=\n  by\n  by_cases hx : z = x; · simp [hx]\n  by_cases hy : z = y; · simp [hy]\n  rw [Equiv.swap_apply_of_ne_of_ne hx hy, Equiv.swap_apply_of_ne_of_ne (hf.ne hx) (hf.ne hy)]\n#align function.injective.swap_apply Function.Injective.swap_apply\n\n/- warning: function.injective.swap_comp -> Function.Injective.swap_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] [_inst_2 : DecidableEq.{u2} β] {f : α -> β}, (Function.Injective.{u1, u2} α β f) -> (forall (x : α) (y : α), Eq.{imax u1 u2} (α -> β) (Function.comp.{u1, u2, u2} α β β (coeFn.{max 1 u2, u2} (Equiv.Perm.{u2} β) (fun (_x : Equiv.{u2, u2} β β) => β -> β) (Equiv.hasCoeToFun.{u2, u2} β β) (Equiv.swap.{u2} β (fun (a : β) (b : β) => _inst_2 a b) (f x) (f y))) f) (Function.comp.{u1, u1, u2} α α β f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} α) (fun (_x : Equiv.{u1, u1} α α) => α -> α) (Equiv.hasCoeToFun.{u1, u1} α α) (Equiv.swap.{u1} α (fun (a : α) (b : α) => _inst_1 a b) x y))))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : DecidableEq.{u2} α] [_inst_2 : DecidableEq.{u1} β] {f : α -> β}, (Function.Injective.{u2, u1} α β f) -> (forall (x : α) (y : α), Eq.{imax u2 u1} (α -> β) (Function.comp.{u2, u1, u1} α β β (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} β) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => β) _x) (Equiv.instFunLikeEquiv.{u1, u1} β β) (Equiv.swap.{u1} β (fun (a : β) (b : β) => _inst_2 a b) (f x) (f y))) f) (Function.comp.{u2, u2, u1} α α β f (FunLike.coe.{max 1 u2, u2, u2} (Equiv.Perm.{u2} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{u2, u2} α α) (Equiv.swap.{u2} α (fun (a : α) (b : α) => _inst_1 a b) x y))))\nCase conversion may be inaccurate. Consider using '#align function.injective.swap_comp Function.Injective.swap_compₓ'. -/\ntheorem Function.Injective.swap_comp [DecidableEq α] [DecidableEq β] {f : α → β}\n    (hf : Function.Injective f) (x y : α) : Equiv.swap (f x) (f y) ∘ f = f ∘ Equiv.swap x y :=\n  funext fun z => hf.swap_apply _ _ _\n#align function.injective.swap_comp Function.Injective.swap_comp\n\n#print subsingletonProdSelfEquiv /-\n/-- If `α` is a subsingleton, then it is equivalent to `α × α`. -/\ndef subsingletonProdSelfEquiv {α : Type _} [Subsingleton α] : α × α ≃ α\n    where\n  toFun p := p.1\n  invFun a := (a, a)\n  left_inv p := Subsingleton.elim _ _\n  right_inv p := Subsingleton.elim _ _\n#align subsingleton_prod_self_equiv subsingletonProdSelfEquiv\n-/\n\n#print equivOfSubsingletonOfSubsingleton /-\n/-- To give an equivalence between two subsingleton types, it is sufficient to give any two\n    functions between them. -/\ndef equivOfSubsingletonOfSubsingleton [Subsingleton α] [Subsingleton β] (f : α → β) (g : β → α) :\n    α ≃ β where\n  toFun := f\n  invFun := g\n  left_inv _ := Subsingleton.elim _ _\n  right_inv _ := Subsingleton.elim _ _\n#align equiv_of_subsingleton_of_subsingleton equivOfSubsingletonOfSubsingleton\n-/\n\n/- warning: equiv.punit_of_nonempty_of_subsingleton -> Equiv.punitOfNonemptyOfSubsingleton is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u2}} [h : Nonempty.{u2} α] [_inst_1 : Subsingleton.{u2} α], Equiv.{u2, u1} α PUnit.{u1}\nbut is expected to have type\n  forall {α : Sort.{u1}} [h : Nonempty.{u1} α] [_inst_1 : Subsingleton.{u1} α], Equiv.{u1, u2} α PUnit.{u2}\nCase conversion may be inaccurate. Consider using '#align equiv.punit_of_nonempty_of_subsingleton Equiv.punitOfNonemptyOfSubsingletonₓ'. -/\n/-- A nonempty subsingleton type is (noncomputably) equivalent to `punit`. -/\nnoncomputable def Equiv.punitOfNonemptyOfSubsingleton {α : Sort _} [h : Nonempty α]\n    [Subsingleton α] : α ≃ PUnit.{v} :=\n  equivOfSubsingletonOfSubsingleton (fun _ => PUnit.unit) fun _ => h.some\n#align equiv.punit_of_nonempty_of_subsingleton Equiv.punitOfNonemptyOfSubsingleton\n\n#print uniqueUniqueEquiv /-\n/-- `unique (unique α)` is equivalent to `unique α`. -/\ndef uniqueUniqueEquiv : Unique (Unique α) ≃ Unique α :=\n  equivOfSubsingletonOfSubsingleton (fun h => h.default) fun h =>\n    { default := h\n      uniq := fun _ => Subsingleton.elim _ _ }\n#align unique_unique_equiv uniqueUniqueEquiv\n-/\n\nnamespace Function\n\n/- warning: function.update_comp_equiv -> Function.update_comp_equiv is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {α' : Sort.{u3}} [_inst_1 : DecidableEq.{u3} α'] [_inst_2 : DecidableEq.{u1} α] (f : α -> β) (g : Equiv.{u3, u1} α' α) (a : α) (v : β), Eq.{imax u3 u2} (α' -> β) (Function.comp.{u3, u1, u2} α' α β (Function.update.{u1, u2} α (fun (ᾰ : α) => β) (fun (a : α) (b : α) => _inst_2 a b) f a v) (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} α' α) (fun (_x : Equiv.{u3, u1} α' α) => α' -> α) (Equiv.hasCoeToFun.{u3, u1} α' α) g)) (Function.update.{u3, u2} α' (fun (ᾰ : α') => β) (fun (a : α') (b : α') => _inst_1 a b) (Function.comp.{u3, u1, u2} α' α β f (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} α' α) (fun (_x : Equiv.{u3, u1} α' α) => α' -> α) (Equiv.hasCoeToFun.{u3, u1} α' α) g)) (coeFn.{max 1 (imax u1 u3) (imax u3 u1), imax u1 u3} (Equiv.{u1, u3} α α') (fun (_x : Equiv.{u1, u3} α α') => α -> α') (Equiv.hasCoeToFun.{u1, u3} α α') (Equiv.symm.{u3, u1} α' α g) a) v)\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {α' : Sort.{u1}} [_inst_1 : DecidableEq.{u3} α] [_inst_2 : DecidableEq.{u2} β] (f : β -> α') (g : Equiv.{u3, u2} α β) (a : β) (v : α'), Eq.{imax u3 u1} (α -> α') (Function.comp.{u3, u2, u1} α β α' (Function.update.{u2, u1} β (fun (ᾰ : β) => α') (fun (a : β) (b : β) => _inst_2 a b) f a v) (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u2} α β) g)) (Function.update.{u3, u1} α (fun (ᾰ : α) => α') (fun (a : α) (b : α) => _inst_1 a b) (Function.comp.{u3, u2, u1} α β α' f (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u2} α β) g)) (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β g) a) v)\nCase conversion may be inaccurate. Consider using '#align function.update_comp_equiv Function.update_comp_equivₓ'. -/\ntheorem update_comp_equiv {α β α' : Sort _} [DecidableEq α'] [DecidableEq α] (f : α → β)\n    (g : α' ≃ α) (a : α) (v : β) : update f a v ∘ g = update (f ∘ g) (g.symm a) v := by\n  rw [← update_comp_eq_of_injective _ g.injective, g.apply_symm_apply]\n#align function.update_comp_equiv Function.update_comp_equiv\n\n/- warning: function.update_apply_equiv_apply -> Function.update_apply_equiv_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {α' : Sort.{u3}} [_inst_1 : DecidableEq.{u3} α'] [_inst_2 : DecidableEq.{u1} α] (f : α -> β) (g : Equiv.{u3, u1} α' α) (a : α) (v : β) (a' : α'), Eq.{u2} β (Function.update.{u1, u2} α (fun (ᾰ : α) => β) (fun (a : α) (b : α) => _inst_2 a b) f a v (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} α' α) (fun (_x : Equiv.{u3, u1} α' α) => α' -> α) (Equiv.hasCoeToFun.{u3, u1} α' α) g a')) (Function.update.{u3, u2} α' (fun (ᾰ : α') => β) (fun (a : α') (b : α') => _inst_1 a b) (Function.comp.{u3, u1, u2} α' α β f (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} α' α) (fun (_x : Equiv.{u3, u1} α' α) => α' -> α) (Equiv.hasCoeToFun.{u3, u1} α' α) g)) (coeFn.{max 1 (imax u1 u3) (imax u3 u1), imax u1 u3} (Equiv.{u1, u3} α α') (fun (_x : Equiv.{u1, u3} α α') => α -> α') (Equiv.hasCoeToFun.{u1, u3} α α') (Equiv.symm.{u3, u1} α' α g) a) v a')\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {α' : Sort.{u1}} [_inst_1 : DecidableEq.{u3} α] [_inst_2 : DecidableEq.{u2} β] (f : β -> α') (g : Equiv.{u3, u2} α β) (a : β) (v : α') (a' : α), Eq.{u1} α' (Function.update.{u2, u1} β (fun (ᾰ : β) => α') (fun (a : β) (b : β) => _inst_2 a b) f a v (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u2} α β) g a')) (Function.update.{u3, u1} α (fun (ᾰ : α) => α') (fun (a : α) (b : α) => _inst_1 a b) (Function.comp.{u3, u2, u1} α β α' f (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{u3, u2} α β) g)) (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β g) a) v a')\nCase conversion may be inaccurate. Consider using '#align function.update_apply_equiv_apply Function.update_apply_equiv_applyₓ'. -/\ntheorem update_apply_equiv_apply {α β α' : Sort _} [DecidableEq α'] [DecidableEq α] (f : α → β)\n    (g : α' ≃ α) (a : α) (v : β) (a' : α') : update f a v (g a') = update (f ∘ g) (g.symm a) v a' :=\n  congr_fun (update_comp_equiv f g a v) a'\n#align function.update_apply_equiv_apply Function.update_apply_equiv_apply\n\n/- warning: function.Pi_congr_left'_update -> Function.piCongrLeft'_update is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] [_inst_2 : DecidableEq.{u2} β] (P : α -> Sort.{u3}) (e : Equiv.{u1, u2} α β) (f : forall (a : α), P a) (b : β) (x : P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)), Eq.{imax u2 u3} (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (coeFn.{max 1 (imax (imax u1 u3) u2 u3) (imax (imax u2 u3) u1 u3), imax (imax u1 u3) u2 u3} (Equiv.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) (fun (_x : Equiv.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) => (forall (a : α), P a) -> (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) (Equiv.piCongrLeft'.{u1, u2, u3} α β P e) (Function.update.{u1, u3} α (fun (a : α) => P a) (fun (a : α) (b : α) => _inst_1 a b) f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b) x)) (Function.update.{u2, u3} β (fun (b : β) => P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (fun (a : β) (b : β) => _inst_2 a b) (coeFn.{max 1 (imax (imax u1 u3) u2 u3) (imax (imax u2 u3) u1 u3), imax (imax u1 u3) u2 u3} (Equiv.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) (fun (_x : Equiv.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) => (forall (a : α), P a) -> (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b))) (Equiv.piCongrLeft'.{u1, u2, u3} α β P e) f) b x)\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u3} α] [_inst_2 : DecidableEq.{u2} β] (P : α -> Sort.{u1}) (e : Equiv.{u3, u2} α β) (f : forall (a : α), P a) (b : β) (x : P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)), Eq.{imax u2 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : α), P a) => forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (Function.update.{u3, u1} α (fun (a : α) => P a) (fun (a : α) (b : α) => _inst_1 a b) f (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b) x)) (FunLike.coe.{max (max 1 (imax u3 u1)) (imax u2 u1), imax u3 u1, imax u2 u1} (Equiv.{imax u3 u1, imax u2 u1} (forall (a : α), P a) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b))) (forall (a : α), P a) (fun (_x : forall (a : α), P a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : α), P a) => forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) _x) (Equiv.instFunLikeEquiv.{imax u3 u1, imax u2 u1} (forall (a : α), P a) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b))) (Equiv.piCongrLeft'.{u3, u2, u1} α β P e) (Function.update.{u3, u1} α (fun (a : α) => P a) (fun (a : α) (b : α) => _inst_1 a b) f (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b) x)) (Function.update.{u2, u1} β (fun (b : β) => P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (fun (a : β) (b : β) => _inst_2 a b) (FunLike.coe.{max (max 1 (imax u3 u1)) (imax u2 u1), imax u3 u1, imax u2 u1} (Equiv.{imax u3 u1, imax u2 u1} (forall (a : α), P a) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b))) (forall (a : α), P a) (fun (_x : forall (a : α), P a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : α), P a) => forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) _x) (Equiv.instFunLikeEquiv.{imax u3 u1, imax u2 u1} (forall (a : α), P a) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b))) (Equiv.piCongrLeft'.{u3, u2, u1} α β P e) f) b x)\nCase conversion may be inaccurate. Consider using '#align function.Pi_congr_left'_update Function.piCongrLeft'_updateₓ'. -/\ntheorem piCongrLeft'_update [DecidableEq α] [DecidableEq β] (P : α → Sort _) (e : α ≃ β)\n    (f : ∀ a, P a) (b : β) (x : P (e.symm b)) :\n    e.piCongrLeft' P (update f (e.symm b) x) = update (e.piCongrLeft' P f) b x :=\n  by\n  ext b'\n  rcases eq_or_ne b' b with (rfl | h)\n  · simp\n  · simp [h]\n#align function.Pi_congr_left'_update Function.piCongrLeft'_update\n\n/- warning: function.Pi_congr_left'_symm_update -> Function.piCongrLeft'_symm_update is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u1} α] [_inst_2 : DecidableEq.{u2} β] (P : α -> Sort.{u3}) (e : Equiv.{u1, u2} α β) (f : forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (b : β) (x : P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)), Eq.{imax u1 u3} (forall (a : α), P a) (coeFn.{max 1 (imax (imax u2 u3) u1 u3) (imax (imax u1 u3) u2 u3), imax (imax u2 u3) u1 u3} (Equiv.{imax u2 u3, imax u1 u3} (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (forall (a : α), P a)) (fun (_x : Equiv.{imax u2 u3, imax u1 u3} (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (forall (a : α), P a)) => (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) -> (forall (a : α), P a)) (Equiv.hasCoeToFun.{imax u2 u3, imax u1 u3} (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (forall (a : α), P a)) (Equiv.symm.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (Equiv.piCongrLeft'.{u1, u2, u3} α β P e)) (Function.update.{u2, u3} β (fun (b : β) => P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (fun (a : β) (b : β) => _inst_2 a b) f b x)) (Function.update.{u1, u3} α (fun (a : α) => P a) (fun (a : α) (b : α) => _inst_1 a b) (coeFn.{max 1 (imax (imax u2 u3) u1 u3) (imax (imax u1 u3) u2 u3), imax (imax u2 u3) u1 u3} (Equiv.{imax u2 u3, imax u1 u3} (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (forall (a : α), P a)) (fun (_x : Equiv.{imax u2 u3, imax u1 u3} (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (forall (a : α), P a)) => (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) -> (forall (a : α), P a)) (Equiv.hasCoeToFun.{imax u2 u3, imax u1 u3} (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (forall (a : α), P a)) (Equiv.symm.{imax u1 u3, imax u2 u3} (forall (a : α), P a) (forall (b : β), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b)) (Equiv.piCongrLeft'.{u1, u2, u3} α β P e)) f) (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} β α) (fun (_x : Equiv.{u2, u1} β α) => β -> α) (Equiv.hasCoeToFun.{u2, u1} β α) (Equiv.symm.{u1, u2} α β e) b) x)\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} [_inst_1 : DecidableEq.{u3} α] [_inst_2 : DecidableEq.{u2} β] (P : α -> Sort.{u1}) (e : Equiv.{u3, u2} α β) (f : forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (b : β) (x : P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)), Eq.{imax u3 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) => forall (a : α), P a) (Function.update.{u2, u1} β (fun (b : β) => P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (fun (a : β) (b : β) => _inst_2 a b) f b x)) (FunLike.coe.{max (max 1 (imax u3 u1)) (imax u2 u1), imax u2 u1, imax u3 u1} (Equiv.{imax u2 u1, imax u3 u1} (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (forall (a : α), P a)) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (fun (_x : forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) => forall (a : α), P a) _x) (Equiv.instFunLikeEquiv.{imax u2 u1, imax u3 u1} (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (forall (a : α), P a)) (Equiv.symm.{imax u3 u1, imax u2 u1} (forall (a : α), P a) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (Equiv.piCongrLeft'.{u3, u2, u1} α β P e)) (Function.update.{u2, u1} β (fun (b : β) => P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (fun (a : β) (b : β) => _inst_2 a b) f b x)) (Function.update.{u3, u1} α (fun (a : α) => P a) (fun (a : α) (b : α) => _inst_1 a b) (FunLike.coe.{max (max 1 (imax u3 u1)) (imax u2 u1), imax u2 u1, imax u3 u1} (Equiv.{imax u2 u1, imax u3 u1} (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (forall (a : α), P a)) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (fun (_x : forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (a : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) a) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) => forall (a : α), P a) _x) (Equiv.instFunLikeEquiv.{imax u2 u1, imax u3 u1} (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (forall (a : α), P a)) (Equiv.symm.{imax u3 u1, imax u2 u1} (forall (a : α), P a) (forall (b : β), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b)) (Equiv.piCongrLeft'.{u3, u2, u1} α β P e)) f) (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{u2, u3} β α) (Equiv.symm.{u3, u2} α β e) b) x)\nCase conversion may be inaccurate. Consider using '#align function.Pi_congr_left'_symm_update Function.piCongrLeft'_symm_updateₓ'. -/\ntheorem piCongrLeft'_symm_update [DecidableEq α] [DecidableEq β] (P : α → Sort _) (e : α ≃ β)\n    (f : ∀ b, P (e.symm b)) (b : β) (x : P (e.symm b)) :\n    (e.piCongrLeft' P).symm (update f b x) = update ((e.piCongrLeft' P).symm f) (e.symm b) x := by\n  simp [(e.Pi_congr_left' P).symm_apply_eq, Pi_congr_left'_update]\n#align function.Pi_congr_left'_symm_update Function.piCongrLeft'_symm_update\n\nend Function\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Logic/Equiv/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.4955327036268931}}
{"text": "import compiler\nimport well_formedness\n\nnamespace rc_correctness\n\nopen rc_correctness.expr\nopen rc_correctness.fn_body\nopen rc_correctness.lin_type\n\nlemma not_𝔹_iff_𝕆 {τ : lin_type} : τ ≠ 𝔹 ↔ τ = 𝕆 :=\nbegin\n  cases τ; \n  split; intro h; contradiction <|> refl\nend\n\nlemma not_𝕆_iff_𝔹 {τ : lin_type} : τ ≠ 𝕆 ↔ τ = 𝔹 :=\nbegin\n  cases τ; \n  split; intro h; contradiction <|> refl\nend\n\nsection FV_wf\n  open finset\n  open list\n\n  theorem FV_sub_wf_context {δ : program} {β : const → var → lin_type} {Γ : finset var} {F : fn_body} \n    (h : β; δ; Γ ⊢ F) : \n    FV F ⊆ Γ :=\n  begin\n    with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing Γ };\n    simp only [subset_iff],\n    case ret : x {\n      intros y h₁, \n      simp only [FV, finset.mem_singleton, insert_empty_eq_singleton] at h₁,\n      cases h,\n      rwa h₁\n    },\n    case «let» : x e F ih {\n      intros y h₁, \n      simp only [FV, mem_erase, finset.mem_union] at h₁,\n      cases h₁,\n      { cases h;\n        simp only [FV_expr, mem_to_finset, mem_insert, \n                  finset.mem_singleton, has_insert_eq_insert, insert_empty_eq_singleton] at h₁;\n        try { simp only [subset_iff, mem_to_finset] at h_ys_def };\n        try { exact h_ys_def h₁ };\n        try { rwa h₁ },\n        cases h₁; rwa h₁ },\n      { cases h₁,\n        cases h; \n        { replace ih := subset_iff.mp (ih h_F_wf) h₁_right,\n          rw mem_insert at ih,\n          cases ih,\n          { contradiction },\n          { assumption } } }\n    },\n    case «case» : x Fs ih {\n      intros y h₁, \n      simp only [FV, mem_insert, finset.mem_join] at h₁,\n      cases h,\n      cases h₁, \n      { rwa h₁ },\n      rw map_wf_eq_map at h₁,\n      simp only [exists_prop, list.mem_map] at h₁,\n      rcases h₁ with ⟨l, ⟨⟨a, ⟨a_in_Fs, FV_a_eq_l⟩⟩, y_in_l⟩⟩,\n      rw ←FV_a_eq_l at y_in_l,\n      have a_wf : (β; δ; Γ ⊢ a), from h_Fs_wf a a_in_Fs,\n      have FV_a_sub_Γ : FV a ⊆ Γ, from ih a a_in_Fs a_wf,\n      exact subset_iff.mp FV_a_sub_Γ y_in_l\n    },\n    all_goals {\n      intros x F ih Γ h y h₁,\n      cases h\n    }\n  end\nend FV_wf\n\nsection FV_C\n  open finset\n\n  lemma FV_inc_𝕆_var_eq_FV {x : var} {F : fn_body} (V : finset var) (βₗ : var → lin_type) \n    (h : x ∈ FV F) :\n    FV (inc_𝕆_var x V F βₗ) = FV F :=\n  begin\n    unfold inc_𝕆_var,\n    split_ifs,\n    { refl },\n    unfold FV,\n    exact insert_eq_of_mem h\n  end\n\n  lemma FV_sub_FV_dec_𝕆 (ys : list var) (F : fn_body) (βₗ : var → lin_type) \n    : FV F ⊆ FV (dec_𝕆 ys F βₗ) :=\n  begin\n    apply subset_iff.mpr,\n    intros x h,\n    unfold dec_𝕆 dec_𝕆_var,\n    induction ys,\n    { simpa only [list.foldr_nil] },\n    simp only [list.foldr_cons],\n    split_ifs,\n    { simp only [FV, mem_insert],\n      exact or.inr ys_ih },\n    { exact ys_ih }\n  end\n\n  lemma FV_dec_𝕆_filter (ys : list var) (F : fn_body) (βₗ : var → lin_type) \n    : FV (dec_𝕆 ys F βₗ) = ys.to_finset.filter (λ y, βₗ y = 𝕆 ∧ y ∉ FV F) ∪ FV F :=\n  begin\n    induction ys,\n    { simp only [dec_𝕆, filter_empty, finset.empty_union, list.to_finset_nil, list.foldr_nil] },\n    simp only [dec_𝕆, dec_𝕆_var, filter_insert, list.foldr_cons, list.to_finset_cons] at *,\n    split_ifs;\n    try { simp only [FV, insert_union] }, \n    { rw ys_ih },\n    { simp only [not_and, not_not] at h_1,\n      have ys_hd_in_FV, from h_1 h.left,\n      have : \n        FV (list.foldr (λ (x : var) (acc : fn_body), \n          ite (βₗ x = 𝕆 ∧ x ∉ FV acc) (dec x; acc) acc) \n          F ys_tl) = FV (dec_𝕆 ys_tl F βₗ), from rfl,\n      rw this at h,\n      exact absurd (subset_iff.mp (FV_sub_FV_dec_𝕆 ys_tl F βₗ) ys_hd_in_FV) h.right },\n    { simp only [not_and, not_not] at h,\n      have ys_hd_in_FV, from h h_1.left,\n      rw ys_ih at *,\n      rw insert_eq_of_mem ys_hd_in_FV },\n    { rw ys_ih }\n  end\n\n  lemma FV_dec_𝕆_sub_vars_FV (vars : list var) (F : fn_body) (βₗ : var → lin_type) \n  : FV (dec_𝕆 vars F βₗ) ⊆ vars.to_finset ∪ FV F :=\n  begin\n    simp only [FV_dec_𝕆_filter, subset_iff, mem_union, mem_filter, list.mem_to_finset], \n    intros x h,\n    cases h,\n    { exact or.inl h.left },\n    { exact or.inr h }\n  end\n                           \n\n  lemma FV_dec_eq_FV {e : expr} {x z : var} {F : fn_body} \n    (h : x ∈ FV_expr e ∪ erase (FV F) z) : \n    FV_expr e ∪ erase (FV (dec x; F)) z = FV_expr e ∪ erase (FV F) z :=\n  begin\n    unfold FV, \n    have hem : x = z ∨ x ≠ z, from dec_em (x = z),\n    cases hem,\n    { rw hem,\n      rw erase_insert_eq_erase },\n    { rw erase_insert_eq_insert_erase _ hem,\n      simp only [union_insert],\n      exact insert_eq_of_mem h }\n  end\n\n  lemma FV_Capp_eq_FV {xs : list (var × lin_type)} {z : var} {e : expr} {F1 F2 : fn_body} (βₗ : var → lin_type)\n    (heq : FV F1 = FV F2) (h : ∀ xτ ∈ xs, (xτ : var × lin_type).1 ∈ FV (z ≔ e; F1)) : \n    FV (C_app xs (z ≔ e; F1) βₗ) = FV (z ≔ e; F2) :=\n  begin\n    induction xs generalizing F1 F2,\n    { simp only [FV, C_app],\n      rw heq },\n    cases xs_hd with x τ,\n    simp only [list.mem_cons_iff, list.forall_mem_cons'] at h,\n    cases h with x_in_FV h,\n    simp only [C_app, FV] at *, \n    cases τ,\n    { rw if_pos rfl,\n      unfold inc_𝕆_var, \n      split_ifs,\n      { exact xs_ih heq h },\n      unfold FV,\n      rw xs_ih heq h,\n      rw heq at x_in_FV,\n      exact insert_eq_of_mem x_in_FV }, \n    { simp only [dec_𝕆_var, if_false], \n      split_ifs,\n      { suffices h2 : ∀ (xτ : var × lin_type), xτ ∈ xs_tl → xτ.fst ∈ FV_expr e ∪ erase (FV (dec x; F1)) z,\n        { have h3 : FV (dec x; F1) = FV (dec x; F2), from by\n          { unfold FV, rw heq },\n          rw xs_ih h3 h2, \n          rw heq at x_in_FV,\n          exact FV_dec_eq_FV x_in_FV },\n        { intros yτ yτ_in_tl,\n          have y_in_FV, from h yτ yτ_in_tl,\n          rwa FV_dec_eq_FV x_in_FV } },\n      { exact xs_ih heq h } }\n  end\n\n  theorem FV_C_eq_FV (β : const → var → lin_type) (F : fn_body) (βₗ : var → lin_type) : FV (C β F βₗ) = FV F :=\n  begin\n    with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing βₗ },\n    case ret : x {\n      unfold FV C inc_𝕆_var, \n      split_ifs;\n      simp only [FV, insert_eq_of_mem, insert_empty_eq_singleton, mem_singleton]\n    },\n    case «case» : x Fs ih {\n      unfold C FV, \n      repeat { rw list.map_wf_eq_map },\n      simp only [list.map_map],\n      ext,\n      apply iff.intro,\n      { intro h, \n        apply mem_insert.mpr, \n        replace h := mem_insert.mp h,\n        cases h,\n        { exact or.inl h },\n        { rw mem_join at h, \n          rcases h with ⟨S, h, a_in_S⟩, \n          simp only [list.mem_map, function.comp_app] at h,\n          rcases h with ⟨b, b_in_Fs, h⟩, \n          rw ←h at a_in_S,\n          have h2, from FV_dec_𝕆_sub_vars_FV (sort var_le (insert x (join (list.map FV Fs)))) (C β b βₗ) βₗ,\n          rw sort_to_finset _ at h2,\n          have h3, from mem_of_subset h2 a_in_S,\n          simp only [mem_union, mem_insert] at h3, \n          rcases h3 with ⟨l, m, r⟩,\n          { exact or.inl h3 },\n          { exact or.inr h3 },\n          rw ih b b_in_Fs βₗ at h3,\n          simp only [exists_prop, list.mem_map, mem_join],\n          exact or.inr ⟨FV b, ⟨⟨b, ⟨b_in_Fs, rfl⟩⟩, h3⟩⟩ } },\n      { intro h,\n        apply mem_insert.mpr, \n        replace h := mem_insert.mp h,\n        cases h,\n        { exact or.inl h },\n        { rw mem_join at h, \n          rcases h with ⟨S, h, a_in_S⟩, \n          rw list.mem_map at h,\n          rcases h with ⟨b, ⟨b_in_Fs, FV_b_eq_S⟩⟩,\n          apply or.inr,\n          simp only [mem_join, exists_prop, list.mem_map, function.comp_app],\n          apply exists.intro (FV (dec_𝕆 (sort var_le (insert x (join (list.map FV Fs)))) (C β b βₗ) βₗ)),\n          apply and.intro,\n          { exact ⟨b, ⟨b_in_Fs, rfl⟩⟩ },\n          rw ←ih b b_in_Fs βₗ at FV_b_eq_S,\n          rw ←FV_b_eq_S at a_in_S,\n          have h, from FV_sub_FV_dec_𝕆 (sort var_le (insert x (join (list.map FV Fs)))) (C β b βₗ) βₗ,\n          exact mem_of_subset h a_in_S } }\n    },\n    case «let» : x e F ih {\n      induction e;\n      unfold C;\n      try {\n        apply FV_Capp_eq_FV βₗ (ih (βₗ[x↦𝕆])),\n        intros xτ h\n      };\n      try {\n        rw list.mem_map at h,\n        apply Exists.rec_on h,\n        intros x h_h,\n        apply and.rec_on h_h, \n        intros x_in_ys xτ_def, \n        cases xτ,\n        rw ←xτ_def,\n        simp only [FV, FV_expr, mem_union, mem_insert, insert_union, list.mem_to_finset, mem_erase]\n      },\n      { exact or.inl x_in_ys },\n      { exact or.inl x_in_ys },\n      { simp only [list.mem_cons_iff, list.mem_singleton] at h,\n        simp only [FV, FV_expr, mem_union, mem_insert, insert_union, \n                  has_insert_eq_insert, insert_empty_eq_singleton, mem_singleton], \n        cases h;\n        rw h,\n        { exact or.inr (or.inl rfl) },\n        { exact or.inl (rfl) } },\n      { exact or.inl x_in_ys }, \n      { simp only [FV, C, dec_𝕆_var, FV_expr, insert_empty_eq_singleton], \n        split_ifs; \n        simp only [FV, erase_insert_eq_erase, FV_expr, insert_empty_eq_singleton],\n        { rw ih (βₗ[x↦𝕆]) at *,\n          have hem : e_x = x ∨ e_x ≠ x, from dec_em (e_x = x),\n          cases hem,\n          { rw hem at *,\n            rw erase_insert_eq_erase, },\n          { rw erase_insert_eq_insert_erase _ hem,\n            simp } },\n        { rw ih (βₗ[x↦𝕆]) },\n        { rw ih (βₗ[x↦𝔹]) } },\n    },\n    all_goals { intros x F ih βₗ, simp only [FV, C] }\n  end\nend FV_C\n\nsection sandwich\n  open finset\n\n  lemma wf_sandwich {β : const → var → lin_type} {δ : program} {Γ Γ' Γ'' : finset var} {F : fn_body} \n    (Γ_sub_Γ' : Γ ⊆ Γ') (Γ'_sub_Γ'' : Γ' ⊆ Γ'') (hΓ : β; δ; Γ ⊢ F) (hΓ'' : β; δ; Γ'' ⊢ F)\n    : β; δ; Γ' ⊢ F :=\n  begin\n    with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing Γ Γ' Γ'' },\n    case ret : x {\n      apply fn_body_wf.ret,\n      cases hΓ,\n      exact subset_iff.mp Γ_sub_Γ' hΓ_x_def\n    },\n    case «let» : x e F ih {\n      cases e;\n      cases hΓ;\n      cases hΓ'';\n      let h1 := insert_subset_insert x Γ_sub_Γ';\n      let h2 := insert_subset_insert x Γ'_sub_Γ'',\n      any_goals { \n        apply fn_body_wf.let_const_app_full \n        <|> apply fn_body_wf.let_const_app_part\n        <|> apply fn_body_wf.let_var_app\n        <|> apply fn_body_wf.let_ctor\n        <|> apply fn_body_wf.let_proj },\n      any_goals { assumption },\n      any_goals {\n        transitivity,\n        { exact hΓ_ys_def },\n        { assumption }\n      },\n      any_goals {\n        intro h,\n        have h', from subset_iff.mp Γ'_sub_Γ'' h,\n        contradiction\n      },\n      any_goals { exact ih h1 h2 hΓ_F_wf hΓ''_F_wf },\n      any_goals { exact subset_iff.mp Γ_sub_Γ' hΓ_x_def },\n      any_goals { exact subset_iff.mp Γ_sub_Γ' hΓ_y_in_Γ }\n    },\n    case «case» : x Fs ih {\n      cases hΓ,\n      cases hΓ'',\n      apply fn_body_wf.case,\n      { exact subset_iff.mp Γ_sub_Γ' hΓ_x_def },\n      intros F F_in_Fs,\n      exact ih F F_in_Fs Γ_sub_Γ' Γ'_sub_Γ'' (hΓ_Fs_wf F F_in_Fs) (hΓ''_Fs_wf F F_in_Fs)\n    },\n    case «inc» : x F ih {\n      cases hΓ\n    },\n    case «dec» : x F ih {\n      cases hΓ\n    }\n  end\n\n  lemma FV_wf {β : const → var → lin_type} {δ : program} {Γ : finset var} {F : fn_body} (h : β; δ; Γ ⊢ F)\n    : β; δ; FV F ⊢ F :=\n  begin\n    induction h,\n    { apply fn_body_wf.ret,\n      simp only [FV, insert_empty_eq_singleton, mem_singleton] },\n    any_goals {\n      apply fn_body_wf.let_const_app_full\n      <|> apply fn_body_wf.let_const_app_part\n      <|> apply fn_body_wf.let_var_app\n      <|> apply fn_body_wf.let_ctor\n      <|> apply fn_body_wf.let_proj\n    },\n    any_goals { simp [FV, FV_expr, subset_union_left, not_or_distrib] },\n    any_goals { \n      intro h,\n      simp only [subset_iff, list.mem_to_finset] at h_ys_def,\n      have : h_z ∈ h_Γ, from h_ys_def h,\n      contradiction \n    },\n    any_goals { split },\n    any_goals { \n      intro h,\n      rw h at h_z_undef,\n      contradiction \n    },\n    any_goals { apply wf_sandwich _ _ h_ih h_F_wf },\n    any_goals { \n      simp only [subset_iff, mem_union, mem_insert, mem_erase],\n      intros x x_in_FV,\n      by_cases eq : x = h_z,\n      { exact or.inl eq },\n      { repeat { apply or.inr },\n        exact ⟨eq, x_in_FV⟩ } \n    },\n    any_goals { \n      apply insert_subset_insert,\n      simp only [subset_iff, mem_union, list.mem_to_finset, mem_erase, mem_insert, mem_singleton],\n      intros x h,\n      repeat { cases h }\n    },\n    any_goals { \n      simp only [subset_iff, list.mem_to_finset] at h_ys_def,\n      exact h_ys_def h \n    },\n    any_goals { \n      cases mem_insert.mp (subset_iff.mp (FV_sub_wf_context h_F_wf) h_right), \n      { contradiction },\n      { assumption } \n    }, \n    any_goals { assumption },\n    { apply fn_body_wf.case,\n      { exact mem_insert_self h_x _ },\n      intros F F_in_Fs,\n      apply wf_sandwich _ _ (h_ih F F_in_Fs) (h_Fs_wf F F_in_Fs);\n      simp only [subset_iff, list.map_wf_eq_map, exists_prop, mem_join, mem_insert, list.mem_map], \n      { intros x x_in_FV, \n        apply or.inr,\n        use FV F, \n        use F,\n        { exact ⟨F_in_Fs, rfl⟩ },\n        { assumption } },\n      { intros x h,\n        cases h,\n        { rwa h },\n        rcases h with ⟨S, ⟨⟨a, ⟨a_in_Fs, a_def⟩⟩, x_in_S⟩⟩,\n        rw ←a_def at x_in_S,\n        exact subset_iff.mp (FV_sub_wf_context (h_Fs_wf a a_in_Fs)) x_in_S } }\n  end\n\n  lemma wf_FV_sandwich {β : const → var → lin_type} {δ : program} {Γ Γ' : finset var} {F : fn_body} \n    (Γ'_low : FV F ⊆ Γ') (Γ'_high : Γ' ⊆ Γ) (h : β; δ; Γ ⊢ F)\n    : β; δ; Γ' ⊢ F := wf_sandwich Γ'_low Γ'_high (FV_wf h) h\nend sandwich\n\nlemma vars_sub_FV_dec_𝕆 (ys : list var) (F : fn_body) (βₗ : var → lin_type) \n  : ∀ y ∈ ys, βₗ y = 𝕆 → y ∈ FV (dec_𝕆 ys F βₗ) :=\nbegin\n  intros y y_in_ys y𝕆,\n  rw FV_dec_𝕆_filter,\n  simp only [list.mem_to_finset, finset.mem_union, finset.mem_filter],\n  by_cases y ∈ FV F,\n  { exact or.inr h },\n  { exact or.inl ⟨y_in_ys, y𝕆, h⟩ }\nend\n\nlemma dec_𝕆_eq_dec_𝕆'_of_nodup {ys : list var} (F : fn_body) (βₗ : var → lin_type)\n  (d : list.nodup ys) : dec_𝕆 ys F βₗ = dec_𝕆' ys F βₗ :=\nbegin\n  unfold dec_𝕆 dec_𝕆_var dec_𝕆',\n  induction ys,\n  { simp only [list.foldr_nil] },\n  cases list.nodup_cons.mp d with ys_hd_not_in_ys_tl nodup_ys_tl,\n  simp only [list.foldr_cons],\n  split_ifs,\n  { exact ⟨rfl, ys_ih nodup_ys_tl⟩ },\n  { simp only [not_and, not_not] at h_1,\n    have g1, from h.right,\n    have g2, from finset.subset_iff.mp (FV_sub_FV_dec_𝕆 ys_tl F βₗ) (h_1 h.left),\n    contradiction },\n  { simp only [not_and, not_not] at h,\n    have g1, from h_1.right,\n    have g2, from finset.subset_iff.mp (FV_dec_𝕆_sub_vars_FV ys_tl F βₗ) (h h_1.left),\n    simp only [list.mem_to_finset, finset.mem_union] at g2,\n    cases g2; contradiction },\n  { exact ys_ih nodup_ys_tl }\nend\n\nopen multiset (hiding coe_sort)\n\nlemma inductive_dec' {β : const → var → lin_type} {ys : list var} {y𝕆 y𝔹 : multiset var} {F : fn_body} {βₗ : var → lin_type}\n  (ys_sub_vars : ↑ys ⊆ y𝕆 + y𝔹) (d : list.nodup ys)\n  (y𝕆_𝕆 : ∀ y ∈ y𝕆, βₗ y = 𝕆) (y𝔹_𝔹 : ∀ y ∈ y𝔹, βₗ y = 𝔹) (nd_y𝕆 : nodup y𝕆) (nd_y𝔹 : nodup y𝔹)\n  (h : β; (filter (λ y, y ∉ ys ∨ y ∈ FV F) y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹) ⊩ F ∷ 𝕆)\n  : β; (y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹) ⊩ dec_𝕆 ys F βₗ ∷ 𝕆 :=\nbegin\n  have h_congr : ∀ {ys_hd : var} {ys_tl : list var} {ys' : multiset var} \n    (f : ∀ y ∈ ys', y ∉ ys_tl → ¬y = ys_hd ∧ y ∉ ys_tl ∨ y ∈ FV F), \n    ∀ y ∈ ys', y ∉ (ys_hd :: ys_tl : list var) ∨ y ∈ FV F ↔ y ∉ ys_tl ∨ y ∈ FV F,\n  { intros ys_hd ys_tl ys' f y y_in_ys',\n    rw [list.mem_cons_iff, not_or_distrib],\n    exact ⟨λ h', h'.elim (λ h'', or.inl h''.right) (λ h'', or.inr h''), \n           λ h', h'.elim (λ h'', f y y_in_ys' h'') (λ h'', or.inr h'')⟩ },\n  rw dec_𝕆_eq_dec_𝕆'_of_nodup F βₗ d,\n  induction ys generalizing y𝕆 y𝔹,\n  { rw [dec_𝕆', list.foldr_nil], \n    simp only [list.not_mem_nil, true_or, not_false_iff, filter_true] at h, \n    assumption },\n  cases list.nodup_cons.mp d with ys_hd_not_in_ys_tl nodup_ys_tl, \n  rw ←cons_coe at ys_sub_vars,\n  simp only [cons_subset, mem_add] at ys_sub_vars,\n  cases ys_sub_vars with ys_hd_def ys_tl_sub_vars,\n  rw [dec_𝕆', list.foldr_cons], \n  split_ifs,\n  { cases ys_hd_def, swap,\n    { rw y𝔹_𝔹 ys_hd ys_hd_def at h_1,\n      simp only [false_and] at h_1,\n      contradiction },\n    cases exists_cons_of_mem ys_hd_def with y𝕆' y𝕆_def,\n    rw [y𝕆_def, map_cons, cons_add],\n    apply linear.dec,\n    apply ys_ih,\n    { assumption },\n    { rw y𝕆_def at ys_tl_sub_vars,\n      rw subset_iff at ys_tl_sub_vars ⊢,\n      intros x x_in_tl,\n      let := ys_tl_sub_vars x_in_tl,\n      simp only [mem_add, mem_cons] at this,\n      repeat { cases this },\n      { contradiction },\n      { exact mem_add.mpr (or.inl this) },\n      { exact mem_add.mpr (or.inr this) } },\n    { simp only [y𝕆_def, mem_cons] at y𝕆_𝕆,\n      intros y y_in_y𝕆',\n      exact y𝕆_𝕆 y (or.inr y_in_y𝕆') },\n    { assumption }, \n    { simp only [y𝕆_def, nodup_cons] at nd_y𝕆,\n      exact nd_y𝕆.right },\n    { assumption },\n    { rw y𝕆_def at h nd_y𝕆,\n      rw filter_cons_of_neg at h, swap,\n      { simp, exact h_1.right },\n      rw nodup_cons at nd_y𝕆,\n      have : ∀ y ∈ y𝕆', y ∉ ys_tl → ¬y = ys_hd ∧ y ∉ ys_tl ∨ y ∈ FV F,\n      { intros y y_in_y𝕆' h',\n        apply or.inl (and.intro _ h'),\n        intro h',\n        rw h' at y_in_y𝕆',\n        exact absurd y_in_y𝕆' nd_y𝕆.left },\n      rwa filter_congr (h_congr this) at h } },\n  apply ys_ih,\n  any_goals { assumption },\n  rw not_and_distrib at h_1,\n  cases h_1,\n  { rw [←ne.def, not_𝕆_iff_𝔹] at h_1,\n    cases ys_hd_def,\n    { rw y𝕆_𝕆 ys_hd ys_hd_def at h_1,\n      contradiction },\n    have : ∀ y ∈ y𝕆, y ∉ ys_tl → ¬y = ys_hd ∧ y ∉ ys_tl ∨ y ∈ FV F,\n    { intros y y_in_y𝕆 h',\n      apply or.inl (and.intro _ h'),\n      intro h'',\n      rw h'' at y_in_y𝕆,\n      rw y𝕆_𝕆 ys_hd y_in_y𝕆 at h_1,\n      contradiction },\n    rwa filter_congr (h_congr this) at h },\n  { have : ∀ y ∈ y𝕆, y ∉ ys_tl → ¬y = ys_hd ∧ y ∉ ys_tl ∨ y ∈ FV F,\n    { intros y y_in_y𝕆 h',\n      rw not_not at h_1,\n      by_cases h'' : y = ys_hd,\n      { rw h'',\n        exact or.inr h_1 },\n      { exact or.inl ⟨h'', h'⟩ } },\n    rwa filter_congr (h_congr this) at h }\nend\n\nlemma inductive_dec {β : const → var → lin_type} {ys : list var} {y𝕆 y𝔹 : multiset var} {F : fn_body} {βₗ : var → lin_type}\n  (y𝕆_sub_ys : y𝕆 ⊆ ↑ys) (ys_sub_vars : ↑ys ⊆ y𝕆 + y𝔹) (d : list.nodup ys)\n  (y𝕆_𝕆 : ∀ y ∈ y𝕆, βₗ y = 𝕆) (y𝔹_𝔹 : ∀ y ∈ y𝔹, βₗ y = 𝔹) (nd_y𝕆 : nodup y𝕆) (nd_y𝔹 : nodup y𝔹)\n  (h : β; (filter (λ y, y ∈ FV F) y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹) ⊩ F ∷ 𝕆)\n  : β; (y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹) ⊩ dec_𝕆 ys F βₗ ∷ 𝕆 :=\nbegin\n  have : ∀ y ∈ y𝕆, y ∈ FV F ↔ y ∉ ys ∨ y ∈ FV F,\n  { intros y y_in_y𝕆,\n    split; intro h',\n    { exact or.inr h' },\n    { cases h', \n      { exact absurd (y𝕆_sub_ys y_in_y𝕆) h' },\n      { assumption } } },\n  rw filter_congr this at h,\n  exact inductive_dec' ys_sub_vars d y𝕆_𝕆 y𝔹_𝔹 nd_y𝕆 nd_y𝔹 h\nend\n\nlemma inductive_weakening {β : const → var → lin_type} {ys : multiset typed_var} {y𝔹 : multiset var} \n  {r : rc} {τ : lin_type} \n  (h : β; ys ⊩ r ∷ τ)\n  : β; ys + (y𝔹 {∶} 𝔹) ⊩ r ∷ τ :=\nbegin\n  apply multiset.induction_on y𝔹,\n  { simp only [map_zero, add_zero], \n    assumption },\n  intros a s ih,\n  simp only [map_cons, add_cons],\n  apply linear.weaken,\n  assumption\nend\n\ntheorem C_app_rc_insertion_correctness {β : const → var → lin_type} {βₗ : var → lin_type} {δ : program}\n  {y : var} {e : expr} {F : fn_body} {y𝕆 y𝔹 : multiset var} {Γ : list (var × lin_type)}\n  (ih : ∀ (βₗ : var → lin_type),\n    nodup y𝕆 →\n    nodup y𝔹 →\n    (∀ (y : var), y ∈ y𝕆 → βₗ y = 𝕆) →\n    (∀ (y : var), y ∈ y𝔹 → βₗ y = 𝔹) →\n    (β; δ; to_finset y𝕆 ∪ to_finset y𝔹 ⊢ F) →\n    (∀ ⦃x : var⦄, x ∈ y𝕆 → x ∈ FV F) →\n    (β; (y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹) ⊩ ↑(C β F βₗ) ∷ 𝕆))\n  (nd_y𝕆 : nodup y𝕆) (nd_y𝔹 : nodup y𝔹)\n  (y𝕆_𝕆 : ∀ (y : var), y ∈ y𝕆 → βₗ y = 𝕆)\n  (y𝔹_𝔹 : ∀ (y : var), y ∈ y𝔹 → βₗ y = 𝔹)\n  (wf : β; δ; to_finset y𝕆 ∪ to_finset y𝔹 ⊢ (y ≔ e; F))\n  (y𝕆_free : ∀ ⦃x : var⦄, x ∈ y𝕆 → x ∈ FV (y ≔ e; F))\n  (ty : β; (Γ.map (λ (yτ : var × lin_type), yτ.1 ∶ yτ.2)) ⊩ e ∷ 𝕆)\n  : (β; (y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹) ⊩ ↑(C_app Γ (y ≔ e; C β F (βₗ[y↦𝕆])) βₗ) ∷ 𝕆) :=\nbegin\n  sorry\nend\n\n\n\ntheorem rc_insertion_correctness' {β : const → var → lin_type} {δ : program} {c : const}\n  {y𝕆 y𝔹 : multiset var}\n  (nd_y𝕆 : nodup y𝕆) (nd_y𝔹 : nodup y𝔹)\n  (y𝕆_𝕆 : ∀ y ∈ y𝕆, β c y = 𝕆) (y𝔹_𝔹 : ∀ y ∈ y𝔹, β c y = 𝔹)\n  (y𝕆_sub_FV : y𝕆.to_finset ⊆ FV (δ c).F) (wf : β; δ; y𝕆.to_finset ∪ y𝔹.to_finset ⊢ (δ c).F)\n  : β; (y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹) ⊩ C β ((δ c).F) (β c) ∷ 𝕆 :=\nbegin\n  generalize h : β c = βₗ, \n  rw h at *,\n  clear h,\n  simp only [finset.subset_iff, mem_to_finset] at y𝕆_sub_FV,\n  generalize h : (δ c).F = F,\n  rw h at *,\n  clear h,\n  with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing y𝕆 y𝔹 βₗ },\n  case ret : x {\n    unfold C,\n    unfold FV at y𝕆_sub_FV,\n    cases wf,\n    simp only [mem_union, ndunion_eq_union, to_finset_val, nodup_erase_dup, mem_erase_dup, finset.mem_mk] at wf_x_def,\n    unfold inc_𝕆_var,\n    cases wf_x_def,\n    { have : βₗ x = 𝕆 ∧ x ∉ finset.empty, from ⟨y𝕆_𝕆 x wf_x_def, finset.not_mem_empty x⟩,\n      rw if_pos this,\n      have : y𝕆 = x :: 0,\n      { rw nodup_ext nd_y𝕆 (nodup_singleton x),\n        intro a,\n        split;\n        intro h,\n        { exact y𝕆_sub_FV h },\n        { rw mem_singleton at h,\n          rwa h } },\n      rw this,\n      simp only [finset.singleton_val, finset.insert_empty_eq_singleton, zero_add, map_cons, cons_add, map_zero],\n      rw ←singleton_add,\n      apply inductive_weakening,\n      apply linear.ret },\n    { have : ¬(βₗ x = 𝕆 ∧ x ∉ finset.empty),\n      { simp only [not_and], \n        intro h,\n        rw y𝔹_𝔹 x wf_x_def at h, \n        simp only [] at h, \n        contradiction },\n      rw if_neg this,\n      apply linear.inc_𝔹,\n      { apply mem_add.mpr,\n        apply or.inr,\n        exact mem_map_of_mem _ wf_x_def },\n      have : y𝕆 = ∅,\n      { apply eq_zero_of_forall_not_mem,\n        simp only [finset.insert_empty_eq_singleton, finset.mem_singleton] at y𝕆_sub_FV,\n        intros y y_in_y𝕆, \n        have x_in_y𝕆, from (y𝕆_sub_FV y_in_y𝕆).subst y_in_y𝕆,\n        have dj : multiset.disjoint y𝕆 y𝔹,\n        { rw disjoint_iff_ne,\n          intros a a_in_y𝕆 b b_in_y𝔹 h,\n          rw h at a_in_y𝕆,\n          let := y𝕆_𝕆 b a_in_y𝕆,\n          rw y𝔹_𝔹 b b_in_y𝔹 at this,\n          contradiction },\n        let := disjoint_right.mp dj wf_x_def,\n        contradiction }, \n      simp only [this, empty_eq_zero, zero_add, map_zero],\n      rw ←singleton_add,\n      apply inductive_weakening,\n      apply linear.ret } \n  },\n  case «let» : y e F ih {\n    with_cases { cases e },\n    case rc_correctness.expr.proj : i x wf {\n      unfold C,\n      split_ifs,\n      { have x_in_y𝕆 : x ∈ y𝕆,\n        { let := subset_iff.mp (FV_sub_wf_context wf),\n          simp only [FV, FV_expr, mem_union, finset.singleton_val, to_finset_val,\n            finset.insert_empty_eq_singleton, mem_erase_dup, finset.erase_val,\n            finset.union_val, mem_singleton] at this, \n          have h : x ∈ y𝕆 ∨ x ∈ y𝔹, from this (or.inl rfl),\n          cases h,\n          { assumption },\n          { rw y𝔹_𝔹 x h_1 at h,\n            contradiction } },\n        apply linear.proj_𝕆,\n        { simpa },\n        unfold dec_𝕆_var,\n        split_ifs,\n        { rcases exists_cons_of_mem x_in_y𝕆 with ⟨y𝕆', y𝕆_def⟩,\n          rw y𝕆_def at *,\n          simp only [map_cons, cons_add],\n          rw cons_swap,\n          apply linear.dec,\n          rw ←cons_add,\n          rw ←map_cons (∶ 𝕆),\n          apply ih,\n          any_goals { assumption },\n          { cases wf,\n            simp only [not_or_distrib, mem_ndinsert, mem_ndunion, to_finset_val,\n              mem_erase_dup, to_finset_cons, finset.insert_val, finset.mem_mk] at wf_z_undef,\n            simp only [nodup_cons] at ⊢ nd_y𝕆,\n            exact ⟨wf_z_undef.left.right, nd_y𝕆.right⟩ },\n          { simp only [mem_cons],\n            intros z z_in_y𝕆',\n            cases z_in_y𝕆',\n            { rw z_in_y𝕆',\n              rw function.update_same },\n            { by_cases z = y,\n              { rw [h, function.update_same] },\n              { rw function.update_noteq,\n                { exact y𝕆_𝕆 z (mem_cons_of_mem z_in_y𝕆') },\n                { assumption } } } },\n          { intros z z_in_y𝔹,\n            by_cases z = y,\n            { cases wf,\n              simp [not_or_distrib] at wf_z_undef,\n              rw h at z_in_y𝔹,\n              exact absurd z_in_y𝔹 wf_z_undef.right },\n            { rw function.update_noteq,\n              { exact y𝔹_𝔹 z z_in_y𝔹 },\n              { assumption } } },\n          { cases wf,\n            apply wf_FV_sandwich _ _ wf_F_wf,\n            { let := FV_sub_wf_context wf_F_wf,\n              rw finset.subset_iff at ⊢ this,\n              simp only [mem_ndinsert, mem_ndunion, to_finset_val, finset.insert_union, finset.mem_union,\n                finset.mem_insert, mem_erase_dup, to_finset_cons, finset.insert_val, finset.mem_mk, mem_to_finset] at ⊢ this,\n              intros z z_in_FV,\n              have h', from this z_in_FV,\n              repeat { cases h' },\n              { exact or.inl rfl },\n              { rw FV_C_eq_FV at h_1,\n                exact absurd z_in_FV h_1.right },\n              { exact or.inr (or.inl h') },\n              { exact or.inr (or.inr h') } },\n            { rw finset.subset_iff,\n              simp only [mem_ndinsert, mem_ndunion, to_finset_val, finset.insert_union, finset.mem_union, finset.mem_insert,\n                mem_erase_dup, to_finset_cons, finset.insert_val, finset.mem_mk, mem_to_finset],\n              intros y h',\n              repeat { cases h' },\n              { exact or.inl rfl },\n              { exact or.inr (or.inl (or.inr h')) },\n              { exact or.inr (or.inr h') } } },\n          { cases wf,\n            simp only [FV, FV_expr, mem_cons, finset.insert_empty_eq_singleton, finset.mem_union, \n              finset.mem_singleton, finset.mem_erase] at ⊢ y𝕆_sub_FV,\n            intros z h',\n            cases h',\n            { rwa h' },\n            have h'', from y𝕆_sub_FV (or.inr h'),\n            cases h'',\n            { rw h'' at h',\n              rw nodup_cons at nd_y𝕆,\n              exact absurd h' nd_y𝕆.left },\n            { exact h''.right } } },\n        simp only [not_and_distrib, not_not] at h_1, \n        rw [←ne.def, not_𝕆_iff_𝔹] at h_1,\n        cases h_1,\n        { rw h at h_1, contradiction },\n        rw ←cons_add,\n        rw ←map_cons (∶ 𝕆), \n        apply ih,\n        any_goals { assumption },\n        { cases wf,\n          simp only [nodup_cons],\n          simp only [not_or_distrib, mem_union, ndunion_eq_union, to_finset_val,\n            nodup_erase_dup, mem_erase_dup, finset.mem_mk] at wf_z_undef,\n          exact ⟨wf_z_undef.left, nd_y𝕆⟩ },\n        { simp only [mem_cons],\n          intros z h',\n          cases h',\n          { rw h', rw function.update_same },\n          { by_cases eq : y = z,\n            { rw eq, rw function.update_same },\n            rw function.update_noteq,\n            { exact y𝕆_𝕆 z h' },\n            symmetry,\n            assumption } },\n        { intros z z_in_y𝔹,\n          by_cases z = y,\n          { cases wf,\n            simp only [not_or_distrib, mem_union, ndunion_eq_union, to_finset_val, nodup_erase_dup,\n              mem_erase_dup, finset.mem_mk] at wf_z_undef,\n            rw h at z_in_y𝔹,\n            exact absurd z_in_y𝔹 wf_z_undef.right },\n          { rw function.update_noteq,\n            { exact y𝔹_𝔹 z z_in_y𝔹 },\n            { assumption } } },\n        { cases wf,\n          apply wf_FV_sandwich _ _ wf_F_wf,\n          { let := FV_sub_wf_context wf_F_wf,\n            rw finset.subset_iff at ⊢ this,\n            simp only [mem_union, ndunion_eq_union, to_finset_val, nodup_erase_dup, finset.insert_union,\n              finset.mem_union, finset.mem_insert, mem_erase_dup, to_finset_cons, finset.mem_mk, mem_to_finset] at ⊢ this,\n            assumption },\n          { rw finset.subset_iff,\n            simp only [multiset.mem_erase_dup, multiset.mem_union, multiset.nodup_erase_dup, imp_self,\n              multiset.to_finset_val, multiset.mem_to_finset, multiset.to_finset_cons, finset.insert_union,\n              finset.mem_union, finset.mem_insert, finset.mem_mk, multiset.ndunion_eq_union, forall_true_iff] } },\n        { cases wf,\n          simp only [mem_cons],\n          simp only [FV, FV_expr, finset.insert_empty_eq_singleton, finset.mem_union,\n            finset.mem_singleton, finset.mem_erase] at y𝕆_sub_FV,\n          intros z h',\n          cases h',\n          { rwa h' },\n          have h'', from y𝕆_sub_FV h',\n          cases h'',\n          { rw h'',\n            rwa FV_C_eq_FV at h_1 },\n          { exact h''.right } } },\n      rw [←ne.def, not_𝕆_iff_𝔹] at h,\n      have x_in_y𝔹 : x ∈ y𝔹,\n      { let := subset_iff.mp (FV_sub_wf_context wf),\n        simp only [FV, FV_expr, mem_union, finset.singleton_val, to_finset_val,\n          finset.insert_empty_eq_singleton, mem_erase_dup, finset.erase_val,\n          finset.union_val, mem_singleton] at this, \n        have h : x ∈ y𝕆 ∨ x ∈ y𝔹, from this (or.inl rfl),\n        cases h,\n        { rw y𝕆_𝕆 x h_1 at h,\n          contradiction },\n        { assumption } },\n      apply linear.proj_𝔹,\n      { simpa },\n      rw [add_comm, ←cons_add, add_comm, ←map_cons (∶ 𝔹)],\n      apply ih,\n      any_goals { assumption },\n      { cases wf,\n        simp only [nodup_cons],\n        simp only [not_or_distrib, mem_union, ndunion_eq_union, to_finset_val,\n          nodup_erase_dup, mem_erase_dup, finset.mem_mk] at wf_z_undef,\n        exact ⟨wf_z_undef.right, nd_y𝔹⟩ },\n      { intros z z_in_y𝕆,\n        by_cases z = y,\n        { cases wf,\n          simp only [not_or_distrib, mem_union, ndunion_eq_union, to_finset_val,\n            nodup_erase_dup, mem_erase_dup, finset.mem_mk] at wf_z_undef,\n          rw h at z_in_y𝕆,\n          exact absurd z_in_y𝕆 wf_z_undef.left },\n        { rw function.update_noteq,\n          { exact y𝕆_𝕆 z z_in_y𝕆 },\n          { assumption } } },\n      { simp only [mem_cons],\n        intros z h',\n        cases h',\n        { rw h', rw function.update_same },\n        { by_cases eq : y = z,\n          { rw eq, rw function.update_same },\n          rw function.update_noteq,\n          { exact y𝔹_𝔹 z h' },\n          symmetry,\n          assumption } },\n      { cases wf,\n        apply wf_FV_sandwich _ _ wf_F_wf,\n        { let := FV_sub_wf_context wf_F_wf,\n          rw finset.subset_iff at ⊢ this,\n          simp only [mem_union, ndunion_eq_union, to_finset_val, nodup_erase_dup, finset.mem_union, finset.union_insert,\n            finset.mem_insert, mem_erase_dup, to_finset_cons, finset.mem_mk, mem_to_finset] at ⊢ this,\n          assumption },\n        { rw finset.subset_iff,\n          simp only [mem_erase_dup,mem_union, nodup_erase_dup, imp_self, to_finset_val, mem_to_finset, to_finset_cons,\n            finset.mem_union, finset.union_insert, finset.mem_insert, finset.mem_mk, ndunion_eq_union, forall_true_iff] } },\n      { simp only [FV, FV_expr, finset.insert_empty_eq_singleton, finset.mem_union, finset.mem_singleton, finset.mem_erase] at y𝕆_sub_FV,\n        intros z z_in_y𝕆,\n        have h', from y𝕆_sub_FV z_in_y𝕆,\n        cases h',\n        { rw h' at z_in_y𝕆,\n          rw y𝕆_𝕆 x z_in_y𝕆 at h,\n          contradiction },\n        { exact h'.right } } \n    }, \n    case rc_correctness.expr.const_app_full : c' ys {\n      unfold C,\n      apply C_app_rc_insertion_correctness ih nd_y𝕆 nd_y𝔹 y𝕆_𝕆 y𝔹_𝔹 wf y𝕆_sub_FV,\n      simp only [list.map_map],\n      have : ∀ y ∈ ys, ((λ (yτ : var × lin_type), yτ.fst ∶ yτ.snd) ∘ (λ (y : var), (y, β c' y))) y = (λ (y : var), y ∶ β c' y) y,\n      { intros y' y'_in_ys, \n        refl },\n      rw list.map_congr this,\n      exact linear.const_app_full β ys c'\n    },\n    case rc_correctness.expr.const_app_part : c' ys {\n      unfold C,\n      have : ∀ y ∈ ys, (y, β c' y) = (y, 𝕆),\n      { cases wf,\n        intros y' y'_in_ys,\n        have not_𝔹, from wf_no_𝔹_var y',\n        rw not_𝔹_iff_𝕆 at not_𝔹,\n        rw not_𝔹 },\n      rw list.map_congr this,\n      apply C_app_rc_insertion_correctness ih nd_y𝕆 nd_y𝔹 y𝕆_𝕆 y𝔹_𝔹 wf y𝕆_sub_FV,\n      rw list.map_map,\n      have : ∀ y ∈ ys, ((λ (yτ : var × lin_type), yτ.fst ∶ yτ.snd) ∘ (λ (y : var), (y, 𝕆))) y = (λ (y : var), y ∶ 𝕆) y,\n      { intros y' y'_in_ys, \n        refl },\n      rw list.map_congr this,\n      exact linear.const_app_part β ys c'\n    },\n    case rc_correctness.expr.var_app : x z {\n      unfold C,\n      apply C_app_rc_insertion_correctness ih nd_y𝕆 nd_y𝔹 y𝕆_𝕆 y𝔹_𝔹 wf y𝕆_sub_FV,\n      simp only [list.map],\n      exact linear.var_app β x z\n    },\n    case rc_correctness.expr.ctor : i ys {\n      unfold C,\n      apply C_app_rc_insertion_correctness ih nd_y𝕆 nd_y𝔹 y𝕆_𝕆 y𝔹_𝔹 wf y𝕆_sub_FV,\n      rw list.map_map,\n      have : ∀ y ∈ ys, ((λ (yτ : var × lin_type), yτ.fst ∶ yτ.snd) ∘ (λ (y : var), (y, 𝕆))) y = (λ (y : var), y ∶ 𝕆) y,\n      { intros y' y'_in_ys, \n        refl },\n      rw list.map_congr this,\n      exact linear.ctor_app β ys i\n    }\n  },\n  case «case» : x Fs ih {\n    unfold C,\n    have FV_sub_y𝕆_y𝔹 : (FV (case x of Fs)).val ⊆ y𝕆 + y𝔹,\n    { let := FV_sub_wf_context wf,\n      rw finset.subset_def at this,\n      rw subset_iff at ⊢ this,\n      simp only [mem_union, to_finset_val, mem_add, mem_erase_dup, finset.union_val] at ⊢ this,\n      assumption },\n    cases wf,\n    simp only [mem_union, ndunion_eq_union, to_finset_val, nodup_erase_dup, mem_erase_dup, finset.mem_mk] at wf_x_def,\n    cases wf_x_def,\n    apply linear.case_𝕆, \n    { simpa },\n    swap,\n    apply linear.case_𝔹,\n    { simpa },\n    all_goals { \n      intros F' h,\n      rw list.map_wf_eq_map at h, \n      rw list.mem_map at h,\n      rcases h with ⟨F, ⟨F_in_Fs, F'_def⟩⟩, \n      rw ←F'_def,\n      apply inductive_dec,\n      any_goals { assumption },\n      { rw subset_iff,\n        rw finset.sort_eq,\n        intros y y_in_y𝕆,\n        exact y𝕆_sub_FV y_in_y𝕆 },\n      { simp only [finset.sort_eq],\n        assumption },\n      { exact finset.sort_nodup var_le (FV (case x of Fs)) },\n      apply ih,\n      any_goals { assumption },\n      { apply nodup_filter, \n        assumption },\n      { simp only [and_imp, mem_filter, finset.mem_sort],\n        intros y y_in_y𝕆 h,\n        exact y𝕆_𝕆 y y_in_y𝕆 },\n      { have wf, from wf_Fs_wf F F_in_Fs,\n        apply wf_FV_sandwich _ _ wf,\n        { rw finset.subset_iff,\n          rw subset_iff at FV_sub_y𝕆_y𝔹,\n          simp only [FV, list.map_wf_eq_map, mem_ndinsert, mem_add, finset.insert_val] at FV_sub_y𝕆_y𝔹, \n          simp [FV, list.map_wf_eq_map, not_or_distrib],\n          intros y y_in_FV,\n          replace FV_sub_y𝕆_y𝔹 := @FV_sub_y𝕆_y𝔹 y,\n          rw ←finset.mem_def at FV_sub_y𝕆_y𝔹,\n          simp only [exists_prop, list.mem_map, finset.mem_join] at FV_sub_y𝕆_y𝔹,\n          rw FV_C_eq_FV,\n          have : ∃ (S : finset var), (∃ (a : fn_body), a ∈ Fs ∧ FV a = S) ∧ y ∈ S,\n          { use FV F, apply and.intro _ y_in_FV, use F, exact ⟨F_in_Fs, rfl⟩ },\n          have : y ∈ y𝕆 ∨ y ∈ y𝔹, from FV_sub_y𝕆_y𝔹 (or.inr this),\n          cases this,\n          { exact or.inr ⟨this_1, y_in_FV⟩ },\n          { exact or.inl this_1 } },\n        { rw finset.subset_iff,\n          simp only [mem_union, ndunion_eq_union, mem_filter, to_finset_val,\n            nodup_erase_dup, finset.mem_union, mem_erase_dup, finset.mem_mk, mem_to_finset],\n          intros y h,\n          cases h,\n          { exact or.inl (h.left) },\n          { exact or.inr h } } },\n      { simp only [and_imp, mem_filter, FV_C_eq_FV, imp_self, forall_true_iff] } \n    }\n  },\n  case «inc» : x F ih {\n    cases wf\n  },\n  case «dec» : x F ih {\n    cases wf\n  }\nend\n\ntheorem rc_insertion_correctness (β : const → var → lin_type) (δ : program) (wf : β ⊢ δ) : β ⊩ C_prog β δ :=\nbegin\n  cases wf,\n  split,\n  intro c,\n  replace wf_const_wf := wf_const_wf c,\n  cases wf_const_wf,\n  rename wf_const_wf_F_wf wf,\n  split,\n  simp only [C_prog],\n  let ys := (δ c).ys,\n  let Γ := (↑(list.map (λ (y : var), y ∶ β c y) ys) : multiset typed_var),\n  let y𝕆 := filter (λ y, β c y = 𝕆) ys,\n  let y𝔹 := filter (λ y, β c y = 𝔹) ys,\n  obtain ⟨y𝕆_𝕆, y𝔹_𝔹⟩ \n    : (∀ y ∈ y𝕆, β c y = 𝕆) ∧ (∀ y ∈ y𝔹, β c y = 𝔹),\n  { repeat { split }; { intros y h, rw (mem_filter.mp h).right } },\n  obtain ⟨y𝕆_sub_ys, y𝔹_sub_ys⟩ : (y𝕆 ⊆ ys ∧ y𝔹 ⊆ ys),\n  { repeat { split }; simp only [filter_subset] },\n  obtain ⟨ys_𝕆_sub_y𝕆, ys_𝔹_sub_y𝔹⟩\n    : (∀ y ∈ ys, β c y = 𝕆 → y ∈ y𝕆) ∧ (∀ y ∈ ys, β c y = 𝔹 → y ∈ y𝔹),\n  { repeat { split };\n    { intros y y_in_ys y_ty, \n      simp only [mem_filter, mem_coe], try { rw ←coe_eq_coe }, exact ⟨y_in_ys, y_ty⟩ } },\n  obtain ⟨nd_y𝕆, nd_y𝔹⟩ : multiset.nodup y𝕆 ∧ multiset.nodup y𝔹,\n  { split; exact nodup_filter _ (coe_nodup.mpr wf_const_wf_nd_ys) },\n  have ys_subdiv : ↑ys = y𝕆 + y𝔹,\n  { have : ∀ y ∈ (↑ys : multiset var), β c y = 𝔹 ↔ β c y ≠ 𝕆, \n    { intros y y_in_ys,\n      split; intro h; cases β c y; simp at h ⊢; assumption },\n    simp only [y𝕆, y𝔹],\n    rw filter_congr this,\n    exact (filter_add_not ↑ys).symm },\n  have Γ_subdiv : ↑(list.map (λ (y : var), y ∶ β c y) ys) = (y𝕆 {∶} 𝕆) + (y𝔹 {∶} 𝔹),\n  { have : ↑(list.map (λ (y : var), y ∶ β c y) ys) = map (λ (y : var), y ∶ β c y) ↑ys, \n      from rfl,\n    rw this,\n    rw ys_subdiv,\n    simp only [map_add],  \n    have : ∀ (τ : lin_type) (yτ : multiset var), (∀ y ∈ yτ, β c y = τ) →\n      ∀ y ∈ yτ, (y ∶ β c y) = (y ∶ τ), \n    { intros τ yτ h y y_in_yτ, \n      rw h y y_in_yτ },\n    simp only [map_congr (this 𝕆 y𝕆 y𝕆_𝕆), map_congr (this 𝔹 y𝔹 y𝔹_𝔹)] },\n  have y𝕆_sub_FV : y𝕆.to_finset ⊆ FV (dec_𝕆 ((δ c).ys) (C β ((δ c).F) (β c)) (β c)), \n  { rw finset.subset_iff,\n    intros y y_in_y𝕆,\n    simp only [mem_filter, mem_coe, mem_to_finset] at y_in_y𝕆,\n    exact vars_sub_FV_dec_𝕆 ys (C β ((δ c).F) (β c)) (β c) y y_in_y𝕆.left y_in_y𝕆.right },\n  rw Γ_subdiv,\n  unfold list.to_finset at wf,\n  rw ys_subdiv at wf,\n  have : ↑ys ⊆ y𝕆 + y𝔹, { rw ys_subdiv, exact subset.refl _ },\n  apply inductive_dec y𝕆_sub_ys this wf_const_wf_nd_ys y𝕆_𝕆 y𝔹_𝔹 nd_y𝕆 nd_y𝔹, \n  let y𝕆' := filter (λ (y : var), y ∈ FV (C β ((δ c).F) (β c))) y𝕆,\n  have y𝕆'_𝕆 : ∀ y ∈ y𝕆', β c y = 𝕆,\n  { simp only [and_imp, mem_filter, mem_coe], \n    intros y y_in_ys y_𝕆 y_in_FV,\n    assumption },\n  have nd_y𝕆' : nodup y𝕆', from nodup_filter _ nd_y𝕆,\n  have y𝕆'_sub_y𝕆 : y𝕆' ⊆ y𝕆, from filter_subset y𝕆,\n  have y𝕆'_sub_FV : y𝕆'.to_finset ⊆ FV (δ c).F,\n  { rw finset.subset_iff, rw finset.subset_iff at y𝕆_sub_FV, rw subset_iff at y𝕆'_sub_y𝕆,\n    simp only [mem_to_finset], simp only [mem_to_finset] at y𝕆_sub_FV,\n    rw FV_dec_𝕆_filter at y𝕆_sub_FV, \n    intros x x_in_y𝕆',\n    have h, from y𝕆_sub_FV (y𝕆'_sub_y𝕆 x_in_y𝕆'),\n    simp only [mem_filter, mem_coe] at x_in_y𝕆',\n    simp only [list.mem_to_finset, finset.mem_union, finset.mem_filter] at h,\n    cases h,\n    { exact absurd x_in_y𝕆'.right h.right.right },\n    rwa FV_C_eq_FV at h },\n  have wf' : (β; δ; to_finset y𝕆' ∪ to_finset y𝔹 ⊢ (δ c).F),\n  { rw to_finset_add at wf,\n    have h1 : FV (δ c).F ⊆ to_finset y𝕆' ∪ to_finset y𝔹,\n    { have : FV (δ c).F ⊆ to_finset y𝕆 ∪ to_finset y𝔹, from FV_sub_wf_context wf,\n      rw finset.subset_iff at this,\n      rw finset.subset_iff,\n      intros x x_in_FV,\n      let := this x_in_FV,\n      simp only [mem_filter, mem_coe, finset.mem_union, mem_to_finset] at this ⊢, \n      cases this,\n      { rw FV_C_eq_FV,\n        exact or.inl ⟨this_1, x_in_FV ⟩ },\n      { exact or.inr this_1 } },\n    have h2 : to_finset y𝕆' ∪ to_finset y𝔹 ⊆ to_finset y𝕆 ∪ to_finset y𝔹,\n    { rw subset_iff at y𝕆'_sub_y𝕆,\n      simp only [finset.subset_iff, finset.mem_union, mem_to_finset], \n      intros x h,\n      cases h,\n      { exact or.inl (y𝕆'_sub_y𝕆 h) },\n      { exact or.inr h } },\n    exact wf_FV_sandwich h1 h2 wf },\n  exact rc_insertion_correctness' nd_y𝕆' nd_y𝔹 y𝕆'_𝕆 y𝔹_𝔹 y𝕆'_sub_FV wf'\nend\n\nend rc_correctness\n", "meta": {"author": "mhuisi", "repo": "rc-correctness", "sha": "2b7878ac594ba285b0b5cdabe96f41c6e3bbcc87", "save_path": "github-repos/lean/mhuisi-rc-correctness", "path": "github-repos/lean/mhuisi-rc-correctness/rc-correctness-2b7878ac594ba285b0b5cdabe96f41c6e3bbcc87/src/theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.4955326994242676}}
{"text": "import to_mathlib\nimport data.fin.basic\nimport Rings.ToMathlib.fin\n\nnamespace dvector\n\nvariables {α : Type*} {n : ℕ}\n\n\nlemma nil_append (as : dvector α n) :\n  dvector.append dvector.nil as = as :=\nby simp\n\n/-- Converts a dvector into an n-ary tuple -/\n@[simp] def fin_val (as : dvector α n) : fin n → α :=\nλ k, dvector.nth' as k\n @[simp] lemma cons_nth'_succ_eq_nth' {n} {x : α} {as : dvector α n} {k : fin n} :\n(dvector.cons x as).nth' (k.succ) = as.nth' k :=\nbegin\n  unfold dvector.nth',\n  simp,\nend\n\n/-- x_val is the same data as concatenation of dvectors -/\nlemma fin_val_eq_x_val {x : α} {as : dvector α n} :\n  fin_val (dvector.cons x as) = fin.x_val x (fin_val as) :=\nfunext (\n  @fin.cases n\n  (λ k, fin_val (dvector.cons x as) k = fin.x_val x (fin_val as) k)\n  rfl\n  (λ k, begin unfold fin_val, simp, end)\n  )\n\nlemma nth_eq_succ_nth : Π {k n : ℕ} {as : dvector α (n + 1)} {h : k < n},\nas.nth k (lt_trans h (by simp)) = (dvector.remove_mth (n + 2) as).nth k h\n| k nat.zero (dvector.cons a _) h := by {exfalso, simpa using h}\n| nat.zero (nat.succ n) (dvector.cons a as) h := by simp\n| (nat.succ k) (nat.succ n) (dvector.cons a as) h :=\n  by {simpa using nth_eq_succ_nth}\n\ndef of_list : Π (as : list α), dvector α (list.length as)\n| list.nil := dvector.nil\n| (list.cons a as) := dvector.cons a (of_list as)\n\ndef reverse : Π {n : ℕ} (v : dvector α n),\n  dvector α n\n| nat.zero _ := dvector.nil\n| (nat.succ n) (dvector.cons a v) := dvector.concat (reverse v) a\n\n/-- if you append and take nth its the same as just taking nth for small n-/\nlemma nth_append_small : Π {xl yl : ℕ}\n  {xs : dvector α xl} {ys : dvector α yl} {n : ℕ} (h : n < xl),\n  (dvector.append xs ys).nth n (nat.lt_of_lt_of_le h (nat.le_add_left _ _))\n  = xs.nth n h\n| 0             yl xs                  ys n h := by simpa using h\n| (nat.succ xl) yl (dvector.cons x xs) ys 0 h := by simp\n| (nat.succ xl) yl (dvector.cons x xs) ys (nat.succ n) h :=\nbegin\n  simp only [dvector.nth, dvector.append],\n  rw ← (@nth_append_small xl yl xs ys n (nat.succ_lt_succ_iff.1 h)),\n  refl,\nend\n\n/-- if you append and take nth its the same as just taking n - kth for big n-/\nlemma nth_append_big : Π {xl yl : ℕ}\n  {xs : dvector α xl} {ys : dvector α yl} {n : ℕ}\n  (hbig : xl ≤ n) (h : n < yl + xl),\n  (dvector.append xs ys).nth n h\n  = ys.nth (n - xl) ((tsub_lt_iff_right hbig).2 h)\n| 0             yl nil                 ys n hbig h := by simpa\n| (nat.succ xl) yl (dvector.cons x xs) ys 0 hbig h :=\nbegin\n  exfalso,\n  exact nat.not_succ_le_zero _ hbig,\nend\n| (nat.succ xl) yl (dvector.cons x xs) ys (nat.succ n) hbig h :=\nbegin\n  simp only [nat.succ_sub_succ_eq_sub, dvector.append, dvector.nth],\n  apply nth_append_big (nat.le_of_succ_le_succ hbig),\nend\n\nlemma nth_cast : Π {xl yl k : ℕ}\n  {xs : dvector α xl}\n  (heq : xl = yl) (hk : k < yl),\n  (dvector.cast heq xs).nth k hk = xs.nth k (by simp [heq, hk])\n| 0             yl            k nil          heq hk :=\n  (k.not_lt_zero (by simp [heq, hk])).elim\n| (nat.succ xl) 0             k (cons x xs) heq hk :=\n  (nat.succ_ne_zero _ heq).elim\n| (nat.succ xl) (nat.succ yl) k (cons x xs) heq hk :=\nbegin\n  rw dvector.cast_cons heq x xs,\n  induction k with k hk,\n  {simp},\n  rw dvector.nth_cons _ _ _ (nat.lt_of_succ_lt_succ hk),\n  exact nth_cast (nat.succ_injective heq) (nat.lt_of_succ_lt_succ hk),\nend\n\nlemma nth_of_list : Π (l : list α) (k : ℕ) (h : k < l.length),\n  (dvector.of_list l).nth k h = list.nth_le l k h\n| list.nil k h :=\nbegin\n  exfalso,\n  rw list.length at h,\n  exact nat.not_lt_zero _ h,\nend\n| (a :: l) k h :=\nbegin\n  rw of_list,\n  induction k with k hk,\n  {rw [dvector.nth, list.nth_le]},\n  {simpa [dvector.nth, list.nth_le, nth_of_list l]},\nend\n\ndef of_fn : (fin n → α) → dvector α n :=\nλ f, dvector.cast (list.length_of_fn _) (dvector.of_list (list.of_fn f))\n\nlemma nth_of_fn (as : fin n → α) (k : ℕ) (hk : k < n) :\n  (dvector.of_fn as).nth k hk = as ⟨ k , hk ⟩ :=\nby rw [of_fn, nth_cast, nth_of_list, list.nth_le_of_fn']\n\nlemma nth'_of_fn (as : fin n → α) (k : fin n) :\n  (dvector.of_fn as).nth' k = as k :=\nby simp only [dvector.nth', nth_of_fn, fin.val_eq_coe, fin.eta]\n\nlemma nth'_of_fn1 (as : fin n → α) :\n  (dvector.of_fn as).nth' = as :=\nfunext $ nth'_of_fn as\n--by rw [of_fn, nth_cast, nth_of_list, list.nth_le_of_fn']\n\ndef to_list : Π {n : ℕ},\n  dvector α n → list α\n| 0            as := []\n| (nat.succ n) (dvector.cons a as) := list.cons a (to_list as)\n\nlemma to_list_length : Π {n : ℕ} {as : dvector α n},\n  list.length (to_list as) = n\n| 0            as := rfl\n| (nat.succ n) (dvector.cons a as) :=\nby simp only [to_list, list.length_cons, @to_list_length n as]\n\nlemma ith_chunk_aux {n m : ℕ} (i : fin n) (k : fin m) :\n  i.val * m + ↑k < n * m :=\nbegin\n  induction n with n hn,\n  { apply fin_zero_elim i },\n  {\n    rw nat.succ_mul,\n    cases fin.lt_or_eq_nat i with hi hi,\n    {\n      apply add_lt_add _ k.2,\n      apply lt_of_le_of_lt _ (hn ⟨ i.1 , hi ⟩),\n      apply le_add_right,\n      apply le_of_eq,\n      refl,\n    },\n    { rw [fin.val_eq_coe, hi, add_lt_add_iff_left],\n      exact k.2, }\n  }\nend\n\ndef ith_chunk {n m : ℕ} (i : fin n) (xs : dvector α (n * m)) :\n  dvector α m :=\n  of_fn (λ k, dvector.nth xs (i.1 * m + k) (dvector.ith_chunk_aux i k))\n\nlemma nth'_eq {α} {n} (ys : dvector α n) :\n  (λ (i : fin n), ys.nth i i.2) = ys.nth' :=\nbegin\n  funext, rw dvector.nth', refl,\nend\n\nlemma ith_chunk_nth {n m : ℕ} (i : fin n) (xs : dvector α (n * m))\n  (l : ℕ) (hl : l < m) :\n  dvector.nth (dvector.ith_chunk i xs) l hl =\n  xs.nth (i.1 * m + l) (dvector.ith_chunk_aux i ⟨ l , hl ⟩) :=\nby simpa only [dvector.ith_chunk, dvector.nth_of_fn]\n\nlemma nth_remove_mth_big_m : Π {n m} (xs : dvector α (n+1)) {k : ℕ}\n  (hk : k < n) (hm : k < m),\n  (dvector.remove_mth m xs).nth k hk\n  =\n  xs.nth k (lt_trans hk (nat.lt_succ_self _))\n| 0 _ _ k hk hm := false.elim (nat.not_lt_zero _ hk)\n| n 0 (dvector.cons y ys) k hk hm := false.elim (nat.not_lt_zero _ hm)\n| (n+1) (m+1) (dvector.cons y ys) 0 hk hm :=\nbegin\n  simp only [dvector.remove_mth, dvector.nth],\nend\n| (n+1) (m+1) (dvector.cons y ys) (k+1) hk hm :=\nbegin\n  rw [dvector.remove_mth,\n    dvector.nth_cons y (dvector.remove_mth m ys) _ (nat.succ_lt_succ_iff.mp hk),\n    dvector.nth_cons y ys _ (lt_trans (nat.lt_succ_self _) hk)],\n  apply nth_remove_mth_big_m,\n  rw ← nat.succ_lt_succ_iff,\n  exact hm,\nend\n\nlemma ext : Π {as bs : dvector α n},\n  as = bs ↔ ∀ (i : fin n), as.nth' i = bs.nth' i :=\nbegin\n  intros as bs,\n  induction as with n a as hind, cases bs,\n  { simp only [implies_true_iff, eq_self_iff_true] },\n  {\n    cases bs with _ b bs,\n    split,\n    {\n      intros heq i, rw heq,\n    },\n    {\n      intros heq,\n      simp only,\n      split,\n      {\n        specialize heq 0,\n        simp [dvector.nth', fin.val_zero', dvector.nth] at heq,\n        exact heq,\n      },\n      {\n        rw hind,\n        intro i,\n        specialize heq ⟨ i + 1 , nat.succ_lt_succ i.2 ⟩,\n        simp [dvector.nth', dvector.nth] at heq,\n        simp only [dvector.nth'],\n        convert heq,\n      },\n    },\n  },\nend\n\n\nlemma of_fn_eq_cons_of_fn_succ {f : ℕ → α} :\n  of_fn (λ i : fin (n+1), f i) =\n  cons (f 0) (of_fn (λ (i : fin n), f (i + 1))) :=\nbegin\n  rw ext,\n  intro i,\n  cases i with i hi,\n  cases i with i hind,\n  { simp only [nth'_of_fn, fin.mk_zero, fin.coe_eq_cast_succ,\n      fin.coe_succ_eq_succ],\n    simpa only [dvector.nth', fin.val_zero', dvector.nth], },\n  {\n    simp only [nth'_of_fn, dvector.nth', dvector.nth, nth_of_fn],\n    congr1,\n  },\nend\n\nlemma remove_mth_of_fn_last_aux (i : fin n) :\n  ((i : fin n.succ) : fin n.succ.succ) = (i : fin n.succ.succ) :=\nbegin\n  cases i with i hi,\n  simp only [fin.coe_eq_cast_succ, fin.cast_succ_mk, fin.coe_mk, coe_coe],\n  ext1,\n  simp only [fin.coe_of_nat_eq_mod],\n  rw nat.mod_eq_of_lt (lt_trans hi (nat.lt_succ_self _)),\nend\n\nlemma remove_mth_of_fn_last {n : ℕ} : Π {f : ℕ → α},\n  dvector.remove_mth n (of_fn (λ (i : fin (n+1)), f i))\n  =\n  dvector.of_fn (λ i : fin n, f i) :=\nbegin\n  induction n with n hn,\n  {intro f, refl},\n  {\n    intro f,\n    have hrw : (of_fn (λ (i : fin (n+2)), f i))\n      = cons (f 0) (of_fn (λ i : fin n.succ, f (i + 1))) :=\n    of_fn_eq_cons_of_fn_succ,\n    have hrw1 : of_fn (λ (i : fin n.succ), f i)\n      = cons (f 0) (of_fn (λ i : fin n, f (i + 1))) :=\n    of_fn_eq_cons_of_fn_succ,\n    rw hrw,\n    rw [dvector.remove_mth],\n    rw hrw1,\n    congr1,\n    rw @hn (λ n, f (n + 1)),\n  },\nend\n\nsection ulift\n\ndef ulift_up {α} {n} : dvector α n → dvector (ulift α) n :=\n  dvector.map ulift.up\n\ndef ulift_down {α} {n} : dvector (ulift α) n → dvector α n :=\n  dvector.map ulift.down\n\nend ulift\n\n@[simp] protected lemma map_id' : ∀{n : ℕ} (xs : dvector α n), xs.map id = xs\n| _ dvector.nil      := rfl\n| _ (dvector.cons x xs) := by { dsimp, simp* }\n\n@[simp] protected lemma map_comp {β γ : Type*} :\n∀{n : ℕ} (xs : dvector α n) (g : α → β) (f : β → γ),\n  xs.map (f ∘ g) = (xs.map g).map f\n| _ dvector.nil  g f    := rfl\n| _ (dvector.cons x xs) g f := by simp\n\nlemma pmem_nth {xs : dvector α n} {k : ℕ} (hk : k < n) :\n  dvector.pmem (xs.nth k hk) xs :=\nbegin\n  induction xs with m a xs hind generalizing k,\n  { exfalso, apply nat.not_lt_zero _ hk, },\n  { cases k with k,\n    { exact psum.inl rfl },\n    { dsimp only [dvector.nth, dvector.pmem],\n      apply psum.inr,\n      apply hind }},\nend\n\nlemma pmem_nth' {xs : dvector α n} {k : fin n} :\n  dvector.pmem (xs.nth' k) xs := pmem_nth _\n\n\nlemma cast_nil {α} (h : 0 = 0) : (dvector.cast h dvector.nil : dvector α 0) = dvector.nil :=\nby refl\n\nlemma of_fn_zero {α : Type*} (f : fin 0 → α) : dvector.of_fn f = dvector.nil := rfl\n\nlemma of_fn_eq_cons_of_fn_succ' {α : Type*} {n : ℕ} {f : fin n.succ → α} :\n  dvector.of_fn f = dvector.cons (f 0) (dvector.of_fn (λ (i : fin n), f (i + 1))) :=\nbegin\n  set g : ℕ → α := λ k, ite (k < n.succ) (f k) (f 0) with hg,\n  have hrw1 : dvector.of_fn f = dvector.of_fn (λ k, g k),\n  { congr, ext x, rw hg, simp only [fin.coe_coe_eq_self],\n    by_cases hx : (x : ℕ) < n.succ,\n    { simp [if_pos hx] },\n    { exfalso, apply hx x.2 }},\n  rw hrw1,\n  rw dvector.of_fn_eq_cons_of_fn_succ,\n  congr,\n  ext,\n  rw hg,\n  simp only [fin.coe_coe_eq_self],\n  by_cases hx : (x : ℕ) + 1 < n.succ,\n  { simp only [if_pos hx], congr },\n  { exfalso, apply hx, apply nat.succ_lt_succ x.2 }\nend\n\n\n\nend dvector\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/src/Rings/ToMathlib/dvector.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.49553269942426753}}
{"text": "/-\nCopyright (c) 2020 Thomas Browning and Patrick Lutz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Thomas Browning and Patrick Lutz\n-/\n\nimport field_theory.intermediate_field\nimport field_theory.minpoly\nimport field_theory.splitting_field\nimport field_theory.minpoly\nimport field_theory.separable\nimport ring_theory.adjoin_root\nimport ring_theory.power_basis\n\n/-!\n# Adjoining Elements to Fields\n\nIn this file we introduce the notion of adjoining elements to fields.\nThis isn't quite the same as adjoining elements to rings.\nFor example, `algebra.adjoin K {x}` might not include `x⁻¹`.\n\n## Main results\n\n- `adjoin_adjoin_left`: adjoining S and then T is the same as adjoining `S ∪ T`.\n- `bot_eq_top_of_dim_adjoin_eq_one`: if `F⟮x⟯` has dimension `1` over `F` for every `x`\n  in `E` then `F = E`\n\n## Notation\n\n - `F⟮α⟯`: adjoin a single element `α` to `F`.\n-/\n\nopen finite_dimensional polynomial\nopen_locale classical\n\nnamespace intermediate_field\n\nsection adjoin_def\nvariables (F : Type*) [field F] {E : Type*} [field E] [algebra F E] (S : set E)\n\n/-- `adjoin F S` extends a field `F` by adjoining a set `S ⊆ E`. -/\ndef adjoin : intermediate_field F E :=\n{ algebra_map_mem' := λ x, subfield.subset_closure (or.inl (set.mem_range_self x)),\n  ..subfield.closure (set.range (algebra_map F E) ∪ S) }\n\nend adjoin_def\n\nsection lattice\nvariables {F : Type*} [field F] {E : Type*} [field E] [algebra F E]\n\n@[simp] lemma adjoin_le_iff {S : set E} {T : intermediate_field F E} : adjoin F S ≤ T ↔ S ≤ T :=\n⟨λ H, le_trans (le_trans (set.subset_union_right _ _) subfield.subset_closure) H,\n  λ H, (@subfield.closure_le E _ (set.range (algebra_map F E) ∪ S) T.to_subfield).mpr\n  (set.union_subset (intermediate_field.set_range_subset T) H)⟩\n\nlemma gc : galois_connection (adjoin F : set E → intermediate_field F E) coe := λ _ _, adjoin_le_iff\n\n/-- Galois insertion between `adjoin` and `coe`. -/\ndef gi : galois_insertion (adjoin F : set E → intermediate_field F E) coe :=\n{ choice := λ S _, adjoin F S,\n  gc := intermediate_field.gc,\n  le_l_u := λ S, (intermediate_field.gc (S : set E) (adjoin F S)).1 $ le_refl _,\n  choice_eq := λ _ _, rfl }\n\ninstance : complete_lattice (intermediate_field F E) :=\ngalois_insertion.lift_complete_lattice intermediate_field.gi\n\ninstance : inhabited (intermediate_field F E) := ⟨⊤⟩\n\nlemma mem_bot {x : E} : x ∈ (⊥ : intermediate_field F E) ↔ x ∈ set.range (algebra_map F E) :=\nbegin\n  suffices : set.range (algebra_map F E) = (⊥ : intermediate_field F E),\n  { rw this, refl },\n  { change set.range (algebra_map F E) = subfield.closure (set.range (algebra_map F E) ∪ ∅),\n    simp [←set.image_univ, ←ring_hom.map_field_closure] }\nend\n\nlemma mem_top {x : E} : x ∈ (⊤ : intermediate_field F E) :=\nsubfield.subset_closure $ or.inr trivial\n\n@[simp] lemma bot_to_subalgebra : (⊥ : intermediate_field F E).to_subalgebra = ⊥ :=\nby { ext, rw [mem_to_subalgebra, algebra.mem_bot, mem_bot] }\n\n@[simp] lemma top_to_subalgebra : (⊤ : intermediate_field F E).to_subalgebra = ⊤ :=\nby { ext, rw [mem_to_subalgebra, iff_true_right algebra.mem_top], exact mem_top }\n\n/--  Construct an algebra isomorphism from an equality of subalgebras -/\ndef subalgebra.equiv_of_eq {X Y : subalgebra F E} (h : X = Y) : X ≃ₐ[F] Y :=\nby refine { to_fun := λ x, ⟨x, _⟩, inv_fun := λ x, ⟨x, _⟩, .. }; tidy\n\n/-- The bottom intermediate_field is isomorphic to the field. -/\nnoncomputable def bot_equiv : (⊥ : intermediate_field F E) ≃ₐ[F] F :=\n(subalgebra.equiv_of_eq bot_to_subalgebra).trans (algebra.bot_equiv F E)\n\n@[simp] lemma bot_equiv_def (x : F) :\n  bot_equiv (algebra_map F (⊥ : intermediate_field F E) x) = x :=\nalg_equiv.commutes bot_equiv x\n\nnoncomputable instance algebra_over_bot : algebra (⊥ : intermediate_field F E) F :=\n  ring_hom.to_algebra intermediate_field.bot_equiv.to_alg_hom.to_ring_hom\n\ninstance is_scalar_tower_over_bot : is_scalar_tower (⊥ : intermediate_field F E) F E :=\nis_scalar_tower.of_algebra_map_eq\nbegin\n  intro x,\n  let ϕ := algebra.of_id F (⊥ : subalgebra F E),\n  let ψ := alg_equiv.of_bijective ϕ ((algebra.bot_equiv F E).symm.bijective),\n  change (↑x : E) = ↑(ψ (ψ.symm ⟨x, _⟩)),\n  rw alg_equiv.apply_symm_apply ψ ⟨x, _⟩,\n  refl\nend\n\n/-- The top intermediate_field is isomorphic to the field. -/\nnoncomputable def top_equiv : (⊤ : intermediate_field F E) ≃ₐ[F] E :=\n(subalgebra.equiv_of_eq top_to_subalgebra).trans algebra.top_equiv\n\n@[simp] lemma top_equiv_def (x : (⊤ : intermediate_field F E)) : top_equiv x = ↑x :=\nbegin\n  suffices : algebra.to_top (top_equiv x) = algebra.to_top (x : E),\n  { rwa subtype.ext_iff at this },\n  exact alg_equiv.apply_symm_apply (alg_equiv.of_bijective algebra.to_top\n    ⟨λ _ _, subtype.mk.inj, λ x, ⟨x.val, by { ext, refl }⟩⟩ : E ≃ₐ[F] (⊤ : subalgebra F E))\n    (subalgebra.equiv_of_eq top_to_subalgebra x),\nend\n\n@[simp] lemma coe_bot_eq_self (K : intermediate_field F E) : ↑(⊥ : intermediate_field K E) = K :=\nby { ext, rw [mem_lift2, mem_bot], exact set.ext_iff.mp subtype.range_coe x }\n\n@[simp] lemma coe_top_eq_top (K : intermediate_field F E) :\n  ↑(⊤ : intermediate_field K E) = (⊤ : intermediate_field F E) :=\nintermediate_field.ext'_iff.mpr (set.ext_iff.mpr (λ _, iff_of_true mem_top mem_top))\n\nend lattice\n\nsection adjoin_def\nvariables (F : Type*) [field F] {E : Type*} [field E] [algebra F E] (S : set E)\n\nlemma adjoin_eq_range_algebra_map_adjoin :\n  (adjoin F S : set E) = set.range (algebra_map (adjoin F S) E) := (subtype.range_coe).symm\n\nlemma adjoin.algebra_map_mem (x : F) : algebra_map F E x ∈ adjoin F S :=\nintermediate_field.algebra_map_mem (adjoin F S) x\n\nlemma adjoin.range_algebra_map_subset : set.range (algebra_map F E) ⊆ adjoin F S :=\nbegin\n  intros x hx,\n  cases hx with f hf,\n  rw ← hf,\n  exact adjoin.algebra_map_mem F S f,\nend\n\ninstance adjoin.field_coe : has_coe_t F (adjoin F S) :=\n{coe := λ x, ⟨algebra_map F E x, adjoin.algebra_map_mem F S x⟩}\n\nlemma subset_adjoin : S ⊆ adjoin F S :=\nλ x hx, subfield.subset_closure (or.inr hx)\n\ninstance adjoin.set_coe : has_coe_t S (adjoin F S) :=\n{coe := λ x, ⟨x,subset_adjoin F S (subtype.mem x)⟩}\n\n@[mono] lemma adjoin.mono (T : set E) (h : S ⊆ T) : adjoin F S ≤ adjoin F T :=\ngalois_connection.monotone_l gc h\n\nlemma adjoin_contains_field_as_subfield (F : subfield E) : (F : set E) ⊆ adjoin F S :=\nλ x hx, adjoin.algebra_map_mem F S ⟨x, hx⟩\n\nlemma subset_adjoin_of_subset_left {F : subfield E} {T : set E} (HT : T ⊆ F) : T ⊆ adjoin F S :=\nλ x hx, (adjoin F S).algebra_map_mem ⟨x, HT hx⟩\n\nlemma subset_adjoin_of_subset_right {T : set E} (H : T ⊆ S) : T ⊆ adjoin F S :=\nλ x hx, subset_adjoin F S (H hx)\n\n@[simp] lemma adjoin_empty (F E : Type*) [field F] [field E] [algebra F E] :\n  adjoin F (∅ : set E) = ⊥ :=\neq_bot_iff.mpr (adjoin_le_iff.mpr (set.empty_subset _))\n\n/-- If `K` is a field with `F ⊆ K` and `S ⊆ K` then `adjoin F S ≤ K`. -/\nlemma adjoin_le_subfield {K : subfield E} (HF : set.range (algebra_map F E) ⊆ K)\n  (HS : S ⊆ K) : (adjoin F S).to_subfield ≤ K :=\nbegin\n  apply subfield.closure_le.mpr,\n  rw set.union_subset_iff,\n  exact ⟨HF, HS⟩,\nend\n\nlemma adjoin_subset_adjoin_iff {F' : Type*} [field F'] [algebra F' E]\n  {S S' : set E} : (adjoin F S : set E) ⊆ adjoin F' S' ↔\n  set.range (algebra_map F E) ⊆ adjoin F' S' ∧ S ⊆ adjoin F' S' :=\n⟨λ h, ⟨trans (adjoin.range_algebra_map_subset _ _) h, trans (subset_adjoin _ _) h⟩,\n  λ ⟨hF, hS⟩, subfield.closure_le.mpr (set.union_subset hF hS)⟩\n\n/-- `F[S][T] = F[S ∪ T]` -/\nlemma adjoin_adjoin_left (T : set E) : ↑(adjoin (adjoin F S) T) = adjoin F (S ∪ T) :=\nbegin\n  rw intermediate_field.ext'_iff,\n  change ↑(adjoin (adjoin F S) T) = _,\n  apply set.eq_of_subset_of_subset; rw adjoin_subset_adjoin_iff; split,\n  { rintros _ ⟨⟨x, hx⟩, rfl⟩, exact adjoin.mono _ _ _ (set.subset_union_left _ _) hx },\n  { exact subset_adjoin_of_subset_right _ _ (set.subset_union_right _ _) },\n  { exact subset_adjoin_of_subset_left _ (adjoin.range_algebra_map_subset _ _) },\n  { exact set.union_subset\n            (subset_adjoin_of_subset_left _ (subset_adjoin _ _))\n            (subset_adjoin _ _) },\nend\n\n@[simp] lemma adjoin_insert_adjoin (x : E) :\n  adjoin F (insert x (adjoin F S : set E)) = adjoin F (insert x S) :=\nle_antisymm\n  (adjoin_le_iff.mpr (set.insert_subset.mpr ⟨subset_adjoin _ _ (set.mem_insert _ _),\n   adjoin_le_iff.mpr (subset_adjoin_of_subset_right _ _ (set.subset_insert _ _))⟩))\n  (adjoin.mono _ _ _ (set.insert_subset_insert (subset_adjoin _ _)))\n\n/-- `F[S][T] = F[T][S]` -/\nlemma adjoin_adjoin_comm (T : set E) :\n  ↑(adjoin (adjoin F S) T) = (↑(adjoin (adjoin F T) S) : (intermediate_field F E)) :=\nby rw [adjoin_adjoin_left, adjoin_adjoin_left, set.union_comm]\n\nlemma adjoin_map {E' : Type*} [field E'] [algebra F E'] (f : E →ₐ[F] E') :\n  (adjoin F S).map f = adjoin F (f '' S) :=\nbegin\n  ext x,\n  show x ∈ (subfield.closure (set.range (algebra_map F E) ∪ S)).map (f : E →+* E') ↔\n       x ∈ subfield.closure (set.range (algebra_map F E') ∪ f '' S),\n  rw [ring_hom.map_field_closure, set.image_union, ← set.range_comp, ← ring_hom.coe_comp,\n      f.comp_algebra_map],\n  refl,\nend\n\nlemma algebra_adjoin_le_adjoin : algebra.adjoin F S ≤ (adjoin F S).to_subalgebra :=\nalgebra.adjoin_le (subset_adjoin _ _)\n\nlemma adjoin_eq_algebra_adjoin (inv_mem : ∀ x ∈ algebra.adjoin F S, x⁻¹ ∈ algebra.adjoin F S) :\n  (adjoin F S).to_subalgebra = algebra.adjoin F S :=\nle_antisymm\n  (show adjoin F S ≤\n      { neg_mem' := λ x, (algebra.adjoin F S).neg_mem, inv_mem' := inv_mem, .. algebra.adjoin F S},\n    from adjoin_le_iff.mpr (algebra.subset_adjoin))\n  (algebra_adjoin_le_adjoin _ _)\n\nlemma eq_adjoin_of_eq_algebra_adjoin (K : intermediate_field F E)\n  (h : K.to_subalgebra = algebra.adjoin F S) : K = adjoin F S :=\nbegin\n  apply to_subalgebra_injective,\n  rw h,\n  refine (adjoin_eq_algebra_adjoin _ _ _).symm,\n  intros x,\n  convert K.inv_mem,\n  rw ← h,\n  refl\nend\n\n@[elab_as_eliminator]\nlemma adjoin_induction {s : set E} {p : E → Prop} {x} (h : x ∈ adjoin F s)\n  (Hs : ∀ x ∈ s, p x) (Hmap : ∀ x, p (algebra_map F E x))\n  (Hadd : ∀ x y, p x → p y → p (x + y))\n  (Hneg : ∀ x, p x → p (-x))\n  (Hinv : ∀ x, p x → p x⁻¹)\n  (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=\nsubfield.closure_induction h (λ x hx, or.cases_on hx (λ ⟨x, hx⟩, hx ▸ Hmap x) (Hs x))\n  ((algebra_map F E).map_one ▸ Hmap 1)\n  Hadd Hneg Hinv Hmul\n\n/--\nVariation on `set.insert` to enable good notation for adjoining elements to fields.\nUsed to preferentially use `singleton` rather than `insert` when adjoining one element.\n-/\n--this definition of notation is courtesy of Kyle Miller on zulip\nclass insert {α : Type*} (s : set α) :=\n(insert : α → set α)\n\n@[priority 1000]\ninstance insert_empty {α : Type*} : insert (∅ : set α) :=\n{ insert := λ x, @singleton _ _ set.has_singleton x }\n\n@[priority 900]\ninstance insert_nonempty {α : Type*} (s : set α) : insert s :=\n{ insert := λ x, set.insert x s }\n\nnotation K`⟮`:std.prec.max_plus l:(foldr `, ` (h t, insert.insert t h) ∅) `⟯` := adjoin K l\n\nsection adjoin_simple\nvariables (α : E)\n\nlemma mem_adjoin_simple_self : α ∈ F⟮α⟯ :=\nsubset_adjoin F {α} (set.mem_singleton α)\n\n/-- generator of `F⟮α⟯` -/\ndef adjoin_simple.gen : F⟮α⟯ := ⟨α, mem_adjoin_simple_self F α⟩\n\n@[simp] lemma adjoin_simple.algebra_map_gen : algebra_map F⟮α⟯ E (adjoin_simple.gen F α) = α := rfl\n\nlemma adjoin_simple_adjoin_simple (β : E) : ↑F⟮α⟯⟮β⟯ = F⟮α, β⟯ :=\nadjoin_adjoin_left _ _ _\n\nlemma adjoin_simple_comm (β : E) : ↑F⟮α⟯⟮β⟯ = (↑F⟮β⟯⟮α⟯ : intermediate_field F E) :=\nadjoin_adjoin_comm _ _ _\n\n-- TODO: develop the API for `subalgebra.is_field_of_algebraic` so it can be used here\nlemma adjoin_simple_to_subalgebra_of_integral (hα : is_integral F α) :\n  (F⟮α⟯).to_subalgebra = algebra.adjoin F {α} :=\nbegin\n  apply adjoin_eq_algebra_adjoin,\n  intros x hx,\n  by_cases x = 0,\n  { rw [h, inv_zero], exact subalgebra.zero_mem (algebra.adjoin F {α}) },\n\n  let ϕ := alg_equiv.adjoin_singleton_equiv_adjoin_root_minpoly F α,\n  haveI := minpoly.irreducible hα,\n  suffices : ϕ ⟨x, hx⟩ * (ϕ ⟨x, hx⟩)⁻¹ = 1,\n  { convert subtype.mem (ϕ.symm (ϕ ⟨x, hx⟩)⁻¹),\n    refine (eq_inv_of_mul_right_eq_one _).symm,\n    apply_fun ϕ.symm at this,\n    rw [alg_equiv.map_one, alg_equiv.map_mul, alg_equiv.symm_apply_apply] at this,\n    rw [←subsemiring.coe_one, ←this, subsemiring.coe_mul, subtype.coe_mk] },\n\n  rw mul_inv_cancel (mt (λ key, _) h),\n  rw ← ϕ.map_zero at key,\n  change ↑(⟨x, hx⟩ : algebra.adjoin F {α}) = _,\n  rw [ϕ.injective key, submodule.coe_zero]\nend\n\nend adjoin_simple\nend adjoin_def\n\nsection adjoin_intermediate_field_lattice\nvariables {F : Type*} [field F] {E : Type*} [field E] [algebra F E] {α : E} {S : set E}\n\n@[simp] lemma adjoin_eq_bot_iff : adjoin F S = ⊥ ↔ S ⊆ (⊥ : intermediate_field F E) :=\nby { rw [eq_bot_iff, adjoin_le_iff], refl, }\n\n@[simp] lemma adjoin_simple_eq_bot_iff : F⟮α⟯ = ⊥ ↔ α ∈ (⊥ : intermediate_field F E) :=\nby { rw adjoin_eq_bot_iff, exact set.singleton_subset_iff }\n\n@[simp] lemma adjoin_zero : F⟮(0 : E)⟯ = ⊥ :=\nadjoin_simple_eq_bot_iff.mpr (zero_mem ⊥)\n\n@[simp] lemma adjoin_one : F⟮(1 : E)⟯ = ⊥ :=\nadjoin_simple_eq_bot_iff.mpr (one_mem ⊥)\n\n@[simp] lemma adjoin_int (n : ℤ) : F⟮(n : E)⟯ = ⊥ :=\nadjoin_simple_eq_bot_iff.mpr (coe_int_mem ⊥ n)\n\n@[simp] lemma adjoin_nat (n : ℕ) : F⟮(n : E)⟯ = ⊥ :=\nadjoin_simple_eq_bot_iff.mpr (coe_int_mem ⊥ n)\n\nsection adjoin_dim\nopen finite_dimensional vector_space\n\nvariables {K L : intermediate_field F E}\n\n@[simp] lemma dim_eq_one_iff : dim F K = 1 ↔ K = ⊥ :=\nby rw [← to_subalgebra_eq_iff, ← dim_eq_dim_subalgebra,\n  subalgebra.dim_eq_one_iff, bot_to_subalgebra]\n\n@[simp] lemma findim_eq_one_iff : findim F K = 1 ↔ K = ⊥ :=\nby rw [← to_subalgebra_eq_iff, ← findim_eq_findim_subalgebra,\n  subalgebra.findim_eq_one_iff, bot_to_subalgebra]\n\nlemma dim_adjoin_eq_one_iff : dim F (adjoin F S) = 1 ↔ S ⊆ (⊥ : intermediate_field F E) :=\niff.trans dim_eq_one_iff adjoin_eq_bot_iff\n\nlemma dim_adjoin_simple_eq_one_iff : dim F F⟮α⟯ = 1 ↔ α ∈ (⊥ : intermediate_field F E) :=\nby { rw dim_adjoin_eq_one_iff, exact set.singleton_subset_iff }\n\nlemma findim_adjoin_eq_one_iff : findim F (adjoin F S) = 1 ↔ S ⊆ (⊥ : intermediate_field F E) :=\niff.trans findim_eq_one_iff adjoin_eq_bot_iff\n\nlemma findim_adjoin_simple_eq_one_iff : findim F F⟮α⟯ = 1 ↔ α ∈ (⊥ : intermediate_field F E) :=\nby { rw [findim_adjoin_eq_one_iff], exact set.singleton_subset_iff }\n\n/-- If `F⟮x⟯` has dimension `1` over `F` for every `x ∈ E` then `F = E`. -/\nlemma bot_eq_top_of_dim_adjoin_eq_one (h : ∀ x : E, dim F F⟮x⟯ = 1) :\n  (⊥ : intermediate_field F E) = ⊤ :=\nbegin\n  ext,\n  rw iff_true_right intermediate_field.mem_top,\n  exact dim_adjoin_simple_eq_one_iff.mp (h x),\nend\n\nlemma bot_eq_top_of_findim_adjoin_eq_one (h : ∀ x : E, findim F F⟮x⟯ = 1) :\n  (⊥ : intermediate_field F E) = ⊤ :=\nbegin\n  ext,\n  rw iff_true_right intermediate_field.mem_top,\n  exact findim_adjoin_simple_eq_one_iff.mp (h x),\nend\n\nlemma subsingleton_of_dim_adjoin_eq_one (h : ∀ x : E, dim F F⟮x⟯ = 1) :\n  subsingleton (intermediate_field F E) :=\nsubsingleton_of_bot_eq_top (bot_eq_top_of_dim_adjoin_eq_one h)\n\nlemma subsingleton_of_findim_adjoin_eq_one (h : ∀ x : E, findim F F⟮x⟯ = 1) :\n  subsingleton (intermediate_field F E) :=\nsubsingleton_of_bot_eq_top (bot_eq_top_of_findim_adjoin_eq_one h)\n\n/-- If `F⟮x⟯` has dimension `≤1` over `F` for every `x ∈ E` then `F = E`. -/\nlemma bot_eq_top_of_findim_adjoin_le_one [finite_dimensional F E]\n  (h : ∀ x : E, findim F F⟮x⟯ ≤ 1) : (⊥ : intermediate_field F E) = ⊤ :=\nbegin\n  apply bot_eq_top_of_findim_adjoin_eq_one,\n  exact λ x, by linarith [h x, show 0 < findim F F⟮x⟯, from findim_pos],\nend\n\nlemma subsingleton_of_findim_adjoin_le_one [finite_dimensional F E]\n  (h : ∀ x : E, findim F F⟮x⟯ ≤ 1) : subsingleton (intermediate_field F E) :=\nsubsingleton_of_bot_eq_top (bot_eq_top_of_findim_adjoin_le_one h)\n\nend adjoin_dim\nend adjoin_intermediate_field_lattice\n\nsection adjoin_integral_element\n\nvariables (F : Type*) [field F] {E : Type*} [field E] [algebra F E] {α : E}\nvariables {K : Type*} [field K] [algebra F K]\n\nlemma aeval_gen_minpoly (α : E) :\n  aeval (adjoin_simple.gen F α) (minpoly F α) = 0 :=\nbegin\n  ext,\n  convert minpoly.aeval F α,\n  conv in (aeval α) { rw [← adjoin_simple.algebra_map_gen F α] },\n  exact is_scalar_tower.algebra_map_aeval F F⟮α⟯ E _ _\nend\n\n/-- algebra isomorphism between `adjoin_root` and `F⟮α⟯` -/\nnoncomputable def adjoin_root_equiv_adjoin (h : is_integral F α) :\n  adjoin_root (minpoly F α) ≃ₐ[F] F⟮α⟯ :=\nalg_equiv.of_bijective (alg_hom.mk (adjoin_root.lift (algebra_map F F⟮α⟯)\n  (adjoin_simple.gen F α) (aeval_gen_minpoly F α)) (ring_hom.map_one _)\n  (λ x y, ring_hom.map_mul _ x y) (ring_hom.map_zero _) (λ x y, ring_hom.map_add _ x y)\n  (by { exact λ _, adjoin_root.lift_of })) (begin\n    set f := adjoin_root.lift _ _ (aeval_gen_minpoly F α),\n    haveI := minpoly.irreducible h,\n    split,\n    { exact ring_hom.injective f },\n    { suffices : F⟮α⟯.to_subfield ≤ ring_hom.field_range ((F⟮α⟯.to_subfield.subtype).comp f),\n      { exact λ x, Exists.cases_on (this (subtype.mem x)) (λ y hy, ⟨y, subtype.ext hy.2⟩) },\n      exact subfield.closure_le.mpr (set.union_subset (λ x hx, Exists.cases_on hx (λ y hy, ⟨y,\n        ⟨subfield.mem_top y, by { rw [ring_hom.comp_apply, adjoin_root.lift_of], exact hy }⟩⟩))\n        (set.singleton_subset_iff.mpr ⟨adjoin_root.root (minpoly F α),\n        ⟨subfield.mem_top (adjoin_root.root (minpoly F α)),\n        by { rw [ring_hom.comp_apply, adjoin_root.lift_root], refl }⟩⟩)) } end)\n\nlemma adjoin_root_equiv_adjoin_apply_root (h : is_integral F α) :\n  adjoin_root_equiv_adjoin F h (adjoin_root.root (minpoly F α)) =\n    adjoin_simple.gen F α :=\nbegin\n  refine adjoin_root.lift_root,\n  { exact minpoly F α },\n  { exact aeval_gen_minpoly F α }\nend\n\n/-- Algebra homomorphism `F⟮α⟯ →ₐ[F] K` are in bijection with the set of roots\nof `minpoly α` in `K`. -/\nnoncomputable def alg_hom_adjoin_integral_equiv (h : is_integral F α) :\n  (F⟮α⟯ →ₐ[F] K) ≃ {x // x ∈ ((minpoly F α).map (algebra_map F K)).roots} :=\nlet ϕ := adjoin_root_equiv_adjoin F h,\n  swap1 : (F⟮α⟯ →ₐ[F] K) ≃ (adjoin_root (minpoly F α) →ₐ[F] K) :=\n  { to_fun := λ f, f.comp ϕ.to_alg_hom,\n    inv_fun := λ f, f.comp ϕ.symm.to_alg_hom,\n    left_inv := λ _, by { ext, simp only [alg_equiv.coe_alg_hom,\n      alg_equiv.to_alg_hom_eq_coe, alg_hom.comp_apply, alg_equiv.apply_symm_apply]},\n    right_inv := λ _, by { ext, simp only [alg_equiv.symm_apply_apply,\n      alg_equiv.coe_alg_hom, alg_equiv.to_alg_hom_eq_coe, alg_hom.comp_apply] } },\n  swap2 := adjoin_root.equiv F K (minpoly F α) (minpoly.ne_zero h) in\nswap1.trans swap2\n\n/-- Fintype of algebra homomorphism `F⟮α⟯ →ₐ[F] K` -/\nnoncomputable def fintype_of_alg_hom_adjoin_integral (h : is_integral F α) :\n  fintype (F⟮α⟯ →ₐ[F] K) :=\nfintype.of_equiv _ (alg_hom_adjoin_integral_equiv F h).symm\n\nlemma card_alg_hom_adjoin_integral (h : is_integral F α) (h_sep : (minpoly F α).separable)\n  (h_splits : (minpoly F α).splits (algebra_map F K)) :\n  @fintype.card (F⟮α⟯ →ₐ[F] K) (fintype_of_alg_hom_adjoin_integral F h) =\n    (minpoly F α).nat_degree :=\nbegin\n  let s := ((minpoly F α).map (algebra_map F K)).roots.to_finset,\n  have H := λ x, multiset.mem_to_finset,\n  rw [fintype.card_congr (alg_hom_adjoin_integral_equiv F h), fintype.card_of_subtype s H,\n      nat_degree_eq_card_roots h_splits, multiset.to_finset_card_of_nodup],\n  exact nodup_roots ((separable_map (algebra_map F K)).mpr h_sep),\nend\n\nend adjoin_integral_element\n\nsection induction\n\nvariables {F : Type*} [field F] {E : Type*} [field E] [algebra F E]\n\n/-- An intermediate field `S` is finitely generated if there exists `t : finset E` such that\n`intermediate_field.adjoin F t = S`. -/\ndef fg (S : intermediate_field F E) : Prop := ∃ (t : finset E), adjoin F ↑t = S\n\nlemma fg_adjoin_finset (t : finset E) : (adjoin F (↑t : set E)).fg :=\n⟨t, rfl⟩\n\ntheorem fg_def {S : intermediate_field F E} : S.fg ↔ ∃ t : set E, set.finite t ∧ adjoin F t = S :=\n⟨λ ⟨t, ht⟩, ⟨↑t, set.finite_mem_finset t, ht⟩,\n λ ⟨t, ht1, ht2⟩, ⟨ht1.to_finset, by rwa set.finite.coe_to_finset⟩⟩\n\ntheorem fg_bot : (⊥ : intermediate_field F E).fg :=\n⟨∅, adjoin_empty F E⟩\n\nlemma fg_of_fg_to_subalgebra (S : intermediate_field F E)\n  (h : S.to_subalgebra.fg) : S.fg :=\nbegin\n  cases h with t ht,\n  exact ⟨t, (eq_adjoin_of_eq_algebra_adjoin _ _ _ ht.symm).symm⟩\nend\n\nlemma fg_of_noetherian (S : intermediate_field F E)\n  [is_noetherian F E] : S.fg :=\nS.fg_of_fg_to_subalgebra S.to_subalgebra.fg_of_noetherian\n\nlemma induction_on_adjoin_finset (S : finset E) (P : intermediate_field F E → Prop) (base : P ⊥)\n  (ih : ∀ (K : intermediate_field F E) (x ∈ S), P K → P ↑K⟮x⟯) : P (adjoin F ↑S) :=\nbegin\n  apply finset.induction_on' S,\n  { exact base },\n  { intros a s h1 _ _ h4,\n    rw [finset.coe_insert, set.insert_eq, set.union_comm, ←adjoin_adjoin_left],\n    exact ih (adjoin F s) a h1 h4 }\nend\n\nlemma induction_on_adjoin_fg (P : intermediate_field F E → Prop)\n  (base : P ⊥) (ih : ∀ (K : intermediate_field F E) (x : E), P K → P ↑K⟮x⟯)\n  (K : intermediate_field F E) (hK : K.fg) : P K :=\nbegin\n  obtain ⟨S, rfl⟩ := hK,\n  exact induction_on_adjoin_finset S P base (λ K x _ hK, ih K x hK),\nend\n\nlemma induction_on_adjoin [fd : finite_dimensional F E] (P : intermediate_field F E → Prop)\n  (base : P ⊥) (ih : ∀ (K : intermediate_field F E) (x : E), P K → P ↑K⟮x⟯)\n  (K : intermediate_field F E) : P K :=\ninduction_on_adjoin_fg P base ih K K.fg_of_noetherian\n\nend induction\n\nsection alg_hom_mk_adjoin_splits\n\nvariables (F E K : Type*) [field F] [field E] [field K] [algebra F E] [algebra F K] {S : set E}\n\n/-- Lifts `L → K` of `F → K` -/\ndef lifts := Σ (L : intermediate_field F E), (L →ₐ[F] K)\n\nvariables {F E K}\n\nnoncomputable instance : order_bot (lifts F E K) :=\n{ le := λ x y, x.1 ≤ y.1 ∧ (∀ (s : x.1) (t : y.1), (s : E) = t → x.2 s = y.2 t),\n  le_refl := λ x, ⟨le_refl x.1, λ s t hst, congr_arg x.2 (subtype.ext hst)⟩,\n  le_trans := λ x y z hxy hyz, ⟨le_trans hxy.1 hyz.1, λ s u hsu, eq.trans\n    (hxy.2 s ⟨s, hxy.1 s.mem⟩ rfl) (hyz.2 ⟨s, hxy.1 s.mem⟩ u hsu)⟩,\n  le_antisymm :=\n  begin\n    rintros ⟨x1, x2⟩ ⟨y1, y2⟩ ⟨hxy1, hxy2⟩ ⟨hyx1, hyx2⟩,\n    have : x1 = y1 := le_antisymm hxy1 hyx1,\n    subst this,\n    congr,\n    exact alg_hom.ext (λ s, hxy2 s s rfl),\n  end,\n  bot := ⟨⊥, (algebra.of_id F K).comp bot_equiv.to_alg_hom⟩,\n  bot_le := λ x, ⟨bot_le, λ s t hst,\n  begin\n    cases intermediate_field.mem_bot.mp s.mem with u hu,\n    rw [show s = (algebra_map F _) u, from subtype.ext hu.symm, alg_hom.commutes],\n    rw [show t = (algebra_map F _) u, from subtype.ext (eq.trans hu hst).symm, alg_hom.commutes],\n  end⟩ }\n\nnoncomputable instance : inhabited (lifts F E K) := ⟨⊥⟩\n\nlemma lifts.eq_of_le {x y : lifts F E K} (hxy : x ≤ y) (s : x.1) :\n  x.2 s = y.2 ⟨s, hxy.1 s.mem⟩ := hxy.2 s ⟨s, hxy.1 s.mem⟩ rfl\n\nlemma lifts.exists_max_two {c : set (lifts F E K)} {x y : lifts F E K} (hc : zorn.chain (≤) c)\n  (hx : x ∈ set.insert ⊥ c) (hy : y ∈ set.insert ⊥ c) :\n  ∃ z : lifts F E K, z ∈ set.insert ⊥ c ∧ x ≤ z ∧ y ≤ z :=\nbegin\n  cases (zorn.chain_insert hc (λ _ _ _, or.inl bot_le)).total_of_refl hx hy with hxy hyx,\n  { exact ⟨y, hy, hxy, le_refl y⟩ },\n  { exact ⟨x, hx, le_refl x, hyx⟩ },\nend\n\nlemma lifts.exists_max_three {c : set (lifts F E K)} {x y z : lifts F E K} (hc : zorn.chain (≤) c)\n  (hx : x ∈ set.insert ⊥ c) (hy : y ∈ set.insert ⊥ c) (hz : z ∈ set.insert ⊥ c) :\n  ∃ w  : lifts F E K, w ∈ set.insert ⊥ c ∧ x ≤ w ∧ y ≤ w ∧ z ≤ w :=\nbegin\n  obtain ⟨v, hv, hxv, hyv⟩ := lifts.exists_max_two hc hx hy,\n  obtain ⟨w, hw, hzw, hvw⟩ := lifts.exists_max_two hc hz hv,\n  exact ⟨w, hw, le_trans hxv hvw, le_trans hyv hvw, hzw⟩,\nend\n\n/-- An upper bound on a chain of lifts -/\ndef lifts.upper_bound_intermediate_field {c : set (lifts F E K)} (hc : zorn.chain (≤) c) :\n  intermediate_field F E :=\n{ carrier := λ s, ∃ x : (lifts F E K), x ∈ set.insert ⊥ c ∧ (s ∈ x.1 : Prop),\n  zero_mem' := ⟨⊥, set.mem_insert ⊥ c, zero_mem ⊥⟩,\n  one_mem' := ⟨⊥, set.mem_insert ⊥ c, one_mem ⊥⟩,\n  neg_mem' := by { rintros _ ⟨x, y, h⟩, exact ⟨x, ⟨y, x.1.neg_mem h⟩⟩ },\n  inv_mem' := by { rintros _ ⟨x, y, h⟩, exact ⟨x, ⟨y, x.1.inv_mem h⟩⟩ },\n  add_mem' := by\n  { rintros _ _ ⟨x, hx, ha⟩ ⟨y, hy, hb⟩,\n    obtain ⟨z, hz, hxz, hyz⟩ := lifts.exists_max_two hc hx hy,\n    exact ⟨z, hz, z.1.add_mem (hxz.1 ha) (hyz.1 hb)⟩ },\n  mul_mem' := by\n  { rintros _ _ ⟨x, hx, ha⟩ ⟨y, hy, hb⟩,\n    obtain ⟨z, hz, hxz, hyz⟩ := lifts.exists_max_two hc hx hy,\n    exact ⟨z, hz, z.1.mul_mem (hxz.1 ha) (hyz.1 hb)⟩ },\n  algebra_map_mem' := λ s, ⟨⊥, set.mem_insert ⊥ c, algebra_map_mem ⊥ s⟩ }\n\n/-- The lift on the upper bound on a chain of lifts -/\nnoncomputable def lifts.upper_bound_alg_hom {c : set (lifts F E K)} (hc : zorn.chain (≤) c) :\n  lifts.upper_bound_intermediate_field hc →ₐ[F] K :=\n{ to_fun := λ s, (classical.some s.mem).2 ⟨s, (classical.some_spec s.mem).2⟩,\n  map_zero' := alg_hom.map_zero _,\n  map_one' := alg_hom.map_one _,\n  map_add' := λ s t, begin\n    obtain ⟨w, hw, hxw, hyw, hzw⟩ := lifts.exists_max_three hc\n      (classical.some_spec s.mem).1 (classical.some_spec t.mem).1\n      (classical.some_spec (s + t).mem).1,\n    rw [lifts.eq_of_le hxw, lifts.eq_of_le hyw, lifts.eq_of_le hzw, ←w.2.map_add],\n    refl,\n  end,\n  map_mul' := λ s t, begin\n    obtain ⟨w, hw, hxw, hyw, hzw⟩ := lifts.exists_max_three hc\n      (classical.some_spec s.mem).1 (classical.some_spec t.mem).1\n      (classical.some_spec (s * t).mem).1,\n    rw [lifts.eq_of_le hxw, lifts.eq_of_le hyw, lifts.eq_of_le hzw, ←w.2.map_mul],\n    refl,\n  end,\n  commutes' := λ _, alg_hom.commutes _ _ }\n\n/-- An upper bound on a chain of lifts -/\nnoncomputable def lifts.upper_bound {c : set (lifts F E K)} (hc : zorn.chain (≤) c) :\n  lifts F E K :=\n⟨lifts.upper_bound_intermediate_field hc, lifts.upper_bound_alg_hom hc⟩\n\nlemma lifts.exists_upper_bound (c : set (lifts F E K)) (hc : zorn.chain (≤) c) :\n  ∃ ub, ∀ a ∈ c, a ≤ ub :=\n⟨lifts.upper_bound hc,\nbegin\n  intros x hx,\n  split,\n  { exact λ s hs, ⟨x, set.mem_insert_of_mem ⊥ hx, hs⟩ },\n  { intros s t hst,\n    change x.2 s = (classical.some t.mem).2 ⟨t, (classical.some_spec t.mem).2⟩,\n    obtain ⟨z, hz, hxz, hyz⟩ := lifts.exists_max_two hc (set.mem_insert_of_mem ⊥ hx)\n      (classical.some_spec t.mem).1,\n    rw [lifts.eq_of_le hxz, lifts.eq_of_le hyz],\n    exact congr_arg z.2 (subtype.ext hst) },\nend⟩\n\n/-- Extend a lift `x : lifts F E K` to an element `s : E` whose conjugates are all in `K` -/\nnoncomputable def lifts.lift_of_splits (x : lifts F E K) {s : E} (h1 : is_integral F s)\n  (h2 : (minpoly F s).splits (algebra_map F K)) : lifts F E K :=\nlet h3 : is_integral x.1 s := is_integral_of_is_scalar_tower s h1 in\nlet key : (minpoly x.1 s).splits x.2.to_ring_hom :=\n  splits_of_splits_of_dvd _ (map_ne_zero (minpoly.ne_zero h1))\n  ((splits_map_iff _ _).mpr (by {convert h2, exact ring_hom.ext (λ y, x.2.commutes y)}))\n  (minpoly.dvd_map_of_is_scalar_tower _ _ _) in\n⟨↑x.1⟮s⟯, (@alg_hom_equiv_sigma F x.1 (↑x.1⟮s⟯ : intermediate_field F E) K _ _ _ _ _ _ _\n  (intermediate_field.algebra x.1⟮s⟯) (is_scalar_tower.of_algebra_map_eq (λ _, rfl))).inv_fun\n  ⟨x.2, (@alg_hom_adjoin_integral_equiv x.1 _ E _ _ s K _ x.2.to_ring_hom.to_algebra\n  h3).inv_fun ⟨root_of_splits x.2.to_ring_hom key (ne_of_gt (minpoly.degree_pos h3)), by {\n  simp_rw [mem_roots (map_ne_zero (minpoly.ne_zero h3)), is_root, ←eval₂_eq_eval_map],\n  exact map_root_of_splits x.2.to_ring_hom key (ne_of_gt (minpoly.degree_pos h3)) }⟩⟩⟩\n\nlemma lifts.le_lifts_of_splits (x : lifts F E K) {s : E} (h1 : is_integral F s)\n  (h2 : (minpoly F s).splits (algebra_map F K)) : x ≤ x.lift_of_splits h1 h2 :=\n⟨λ z hz, algebra_map_mem x.1⟮s⟯ ⟨z, hz⟩, λ t u htu, eq.symm begin\n  rw [←(show algebra_map x.1 x.1⟮s⟯ t = u, from subtype.ext htu)],\n  letI : algebra x.1 K := x.2.to_ring_hom.to_algebra,\n  exact (alg_hom.commutes _ t),\nend⟩\n\nlemma lifts.mem_lifts_of_splits (x : lifts F E K) {s : E} (h1 : is_integral F s)\n  (h2 : (minpoly F s).splits (algebra_map F K)) : s ∈ (x.lift_of_splits h1 h2).1 :=\nmem_adjoin_simple_self x.1 s\n\nlemma lifts.exists_lift_of_splits (x : lifts F E K) {s : E} (h1 : is_integral F s)\n  (h2 : (minpoly F s).splits (algebra_map F K)) : ∃ y, x ≤ y ∧ s ∈ y.1 :=\n⟨x.lift_of_splits h1 h2, x.le_lifts_of_splits h1 h2, x.mem_lifts_of_splits h1 h2⟩\n\nlemma alg_hom_mk_adjoin_splits\n  (hK : ∀ s ∈ S, is_integral F (s : E) ∧ (minpoly F s).splits (algebra_map F K)) :\n  nonempty (adjoin F S →ₐ[F] K) :=\nbegin\n  obtain ⟨x : lifts F E K, hx⟩ := zorn.zorn_partial_order lifts.exists_upper_bound,\n  refine ⟨alg_hom.mk (λ s, x.2 ⟨s, adjoin_le_iff.mpr (λ s hs, _) s.mem⟩) x.2.map_one (λ s t,\n    x.2.map_mul ⟨s, _⟩ ⟨t, _⟩) x.2.map_zero (λ s t, x.2.map_add ⟨s, _⟩ ⟨t, _⟩) x.2.commutes⟩,\n  rcases (x.exists_lift_of_splits (hK s hs).1 (hK s hs).2) with ⟨y, h1, h2⟩,\n  rwa hx y h1 at h2\nend\n\nlemma alg_hom_mk_adjoin_splits' (hS : adjoin F S = ⊤)\n  (hK : ∀ x ∈ S, is_integral F (x : E) ∧ (minpoly F x).splits (algebra_map F K)) :\n  nonempty (E →ₐ[F] K) :=\nbegin\n  cases alg_hom_mk_adjoin_splits hK with ϕ,\n  rw hS at ϕ,\n  exact ⟨ϕ.comp top_equiv.symm.to_alg_hom⟩,\nend\n\nend alg_hom_mk_adjoin_splits\n\nend intermediate_field\n\nsection power_basis\n\nnamespace intermediate_field\n\nvariables {K L : Type*} [field K] [field L] [algebra K L]\n\nlemma power_basis_is_basis {x : L} (hx : is_integral K x) :\n  is_basis K (λ (i : fin (minpoly K x).nat_degree), (adjoin_simple.gen K x ^ (i : ℕ))) :=\nbegin\n  let ϕ := (adjoin_root_equiv_adjoin K hx).to_linear_equiv,\n  have key : ϕ (adjoin_root.root (minpoly K x)) = adjoin_simple.gen K x,\n  { exact intermediate_field.adjoin_root_equiv_adjoin_apply_root K hx },\n  suffices : ϕ ∘ (λ (i : fin (minpoly K x).nat_degree),\n    adjoin_root.root (minpoly K x) ^ (i.val)) =\n      (λ (i : fin (minpoly K x).nat_degree),\n        (adjoin_simple.gen K x) ^ ↑i),\n  { rw ← this, exact linear_equiv.is_basis\n    (adjoin_root.power_basis_is_basis (minpoly.ne_zero hx)) ϕ },\n  ext y,\n  rw [function.comp_app, fin.val_eq_coe, alg_equiv.to_linear_equiv_apply, alg_equiv.map_pow],\n  rw intermediate_field.adjoin_root_equiv_adjoin_apply_root K hx,\nend\n\n/-- The power basis `1, x, ..., x ^ (d - 1)` for `K⟮x⟯`,\nwhere `d` is the degree of the minimal polynomial of `x`. -/\nnoncomputable def adjoin.power_basis {x : L} (hx : is_integral K x) :\n  power_basis K K⟮x⟯ :=\n{ gen := adjoin_simple.gen K x,\n  dim := (minpoly K x).nat_degree,\n  is_basis := power_basis_is_basis hx }\n\n@[simp] lemma adjoin.power_basis.gen_eq {x : L} (hx : is_integral K x) :\n  (adjoin.power_basis hx).gen = adjoin_simple.gen K x := rfl\n\n@[simp] lemma adjoin.power_basis.minpoly_gen_eq {x : L} (hx : is_integral K x) :\n  (adjoin.power_basis hx).minpoly_gen = minpoly K x :=\nby rw [(adjoin.power_basis hx).minpoly_gen_eq,\n       ← minpoly.eq_of_algebra_map_eq (algebra_map K⟮x⟯ L).injective\n         (adjoin.power_basis hx).is_integral_gen\n         (adjoin_simple.algebra_map_gen K x).symm]\n\nlemma adjoin.finite_dimensional {x : L} (hx : is_integral K x) : finite_dimensional K K⟮x⟯ :=\npower_basis.finite_dimensional (adjoin.power_basis hx)\n\nlemma adjoin.findim {x : L} (hx : is_integral K x) :\n  finite_dimensional.findim K K⟮x⟯ = (minpoly K x).nat_degree :=\nbegin\n  rw power_basis.findim (adjoin.power_basis hx),\n  refl,\nend\n\nend intermediate_field\n\nnamespace power_basis\n\nvariables {K L : Type*} [field K] [field L] [algebra K L]\n\nopen intermediate_field\n\n/-- `pb.equiv_adjoin_simple` is the equivalence between `K⟮pb.gen⟯` and `L` itself. -/\nnoncomputable def equiv_adjoin_simple (pb : power_basis K L) :\n  K⟮pb.gen⟯ ≃ₐ[K] L :=\n(adjoin.power_basis pb.is_integral_gen).equiv pb\n  (by rw [adjoin.power_basis.minpoly_gen_eq, pb.minpoly_gen_eq])\n\n@[simp]\nlemma equiv_adjoin_simple_aeval (pb : power_basis K L) (f : polynomial K) :\n  pb.equiv_adjoin_simple (aeval (adjoin_simple.gen K pb.gen) f) = aeval pb.gen f :=\nequiv_aeval _ pb _ f\n\n@[simp]\nlemma equiv_adjoin_simple_gen (pb : power_basis K L) :\n  pb.equiv_adjoin_simple (adjoin_simple.gen K pb.gen) = pb.gen :=\nequiv_gen _ pb _\n\n@[simp]\nlemma equiv_adjoin_simple_symm_aeval (pb : power_basis K L) (f : polynomial K) :\n  pb.equiv_adjoin_simple.symm (aeval pb.gen f) = aeval (adjoin_simple.gen K pb.gen) f :=\nby rw [equiv_adjoin_simple, equiv_symm, equiv_aeval, adjoin.power_basis.gen_eq]\n\n@[simp]\nlemma equiv_adjoin_simple_symm_gen (pb : power_basis K L) :\n  pb.equiv_adjoin_simple.symm pb.gen = (adjoin_simple.gen K pb.gen) :=\nby rw [equiv_adjoin_simple, equiv_symm, equiv_gen, adjoin.power_basis.gen_eq]\n\nend power_basis\n\nend power_basis\n", "meta": {"author": "lean-forward", "repo": "class-number", "sha": "812ff19e6fbde86f8d71689851adaa2bbae9695e", "save_path": "github-repos/lean/lean-forward-class-number", "path": "github-repos/lean/lean-forward-class-number/class-number-812ff19e6fbde86f8d71689851adaa2bbae9695e/src/adjoin.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.495532695221642}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Jeremy Avigad, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.core\n \n\nuniverses u v w l u_1 r s \n\nnamespace Mathlib\n\n@[simp] theorem opt_param_eq (α : Sort u) (default : α) : optParam α default = α :=\n  rfl\n\ndef id {α : Sort u} (a : α) : α :=\n  a\n\ndef flip {α : Sort u} {β : Sort v} {φ : Sort w} (f : α → β → φ) : β → α → φ :=\n  fun (b : β) (a : α) => f a b\n\n/- implication -/\n\ndef implies (a : Prop) (b : Prop) :=\n  a → b\n\n/-- Implication `→` is transitive. If `P → Q` and `Q → R` then `P → R`. -/\ntheorem implies.trans {p : Prop} {q : Prop} {r : Prop} (h₁ : implies p q) (h₂ : implies q r) : implies p r :=\n  fun (hp : p) => h₂ (h₁ hp)\n\ndef trivial : True :=\n  True.intro\n\n/-- We can't have `a` and `¬a`, that would be absurd!-/\ndef absurd {a : Prop} {b : Sort v} (h₁ : a) (h₂ : ¬a) : b :=\n  False._oldrec (h₂ h₁)\n\ntheorem not.intro {a : Prop} (h : a → False) : ¬a :=\n  h\n\n/-- Modus tollens. If an implication is true, then so is its contrapositive. -/\ntheorem mt {a : Prop} {b : Prop} (h₁ : a → b) (h₂ : ¬b) : ¬a :=\n  fun (ha : a) => h₂ (h₁ ha)\n\n/- not -/\n\ntheorem not_false : ¬False :=\n  id\n\ndef non_contradictory (a : Prop) :=\n  ¬¬a\n\ntheorem non_contradictory_intro {a : Prop} (ha : a) : ¬¬a :=\n  fun (hna : ¬a) => absurd ha hna\n\n/- false -/\n\ndef false.elim {C : Sort u} (h : False) : C :=\n  False._oldrec h\n\n/- eq -/\n\n-- proof irrelevance is built in\n\ntheorem proof_irrel {a : Prop} (h₁ : a) (h₂ : a) : h₁ = h₂ :=\n  rfl\n\n@[simp] theorem id.def {α : Sort u} (a : α) : id a = a :=\n  rfl\n\ndef eq.mp {α : Sort u} {β : Sort u} : α = β → α → β :=\n  eq.rec_on\n\ndef eq.mpr {α : Sort u} {β : Sort u} : α = β → β → α :=\n  fun (h₁ : α = β) (h₂ : β) => eq.rec_on sorry h₂\n\ntheorem eq.substr {α : Sort u} {p : α → Prop} {a : α} {b : α} (h₁ : b = a) : p a → p b :=\n  Eq.subst (Eq.symm h₁)\n\ntheorem congr {α : Sort u} {β : Sort v} {f₁ : α → β} {f₂ : α → β} {a₁ : α} {a₂ : α} (h₁ : f₁ = f₂) (h₂ : a₁ = a₂) : f₁ a₁ = f₂ a₂ :=\n  h₁ ▸ h₂ ▸ rfl\n\ntheorem congr_fun {α : Sort u} {β : α → Sort v} {f : (x : α) → β x} {g : (x : α) → β x} (h : f = g) (a : α) : f a = g a :=\n  h ▸ Eq.refl (f a)\n\ntheorem congr_arg {α : Sort u} {β : Sort v} {a₁ : α} {a₂ : α} (f : α → β) : a₁ = a₂ → f a₁ = f a₂ :=\n  congr rfl\n\ntheorem trans_rel_left {α : Sort u} {a : α} {b : α} {c : α} (r : α → α → Prop) (h₁ : r a b) (h₂ : b = c) : r a c :=\n  h₂ ▸ h₁\n\ntheorem trans_rel_right {α : Sort u} {a : α} {b : α} {c : α} (r : α → α → Prop) (h₁ : a = b) (h₂ : r b c) : r a c :=\n  Eq.symm h₁ ▸ h₂\n\ntheorem of_eq_true {p : Prop} (h : p = True) : p :=\n  Eq.symm h ▸ trivial\n\ntheorem not_of_eq_false {p : Prop} (h : p = False) : ¬p :=\n  fun (hp : p) => h ▸ hp\n\ndef cast {α : Sort u} {β : Sort u} (h : α = β) (a : α) : β :=\n  Eq._oldrec a h\n\ntheorem cast_proof_irrel {α : Sort u} {β : Sort u} (h₁ : α = β) (h₂ : α = β) (a : α) : cast h₁ a = cast h₂ a :=\n  rfl\n\ntheorem cast_eq {α : Sort u} (h : α = α) (a : α) : cast h a = a :=\n  rfl\n\n/- ne -/\n\ndef ne {α : Sort u} (a : α) (b : α) :=\n  ¬a = b\n\ninfixl:50 \" ≠ \" => Mathlib.ne\n\n@[simp] theorem ne.def {α : Sort u} (a : α) (b : α) : a ≠ b = (¬a = b) :=\n  rfl\n\nnamespace ne\n\n\ntheorem intro {α : Sort u} {a : α} {b : α} (h : a = b → False) : a ≠ b :=\n  h\n\ntheorem elim {α : Sort u} {a : α} {b : α} (h : a ≠ b) : a = b → False :=\n  h\n\ntheorem irrefl {α : Sort u} {a : α} (h : a ≠ a) : False :=\n  h rfl\n\ntheorem symm {α : Sort u} {a : α} {b : α} (h : a ≠ b) : b ≠ a :=\n  fun (h₁ : b = a) => h (Eq.symm h₁)\n\nend ne\n\n\ntheorem false_of_ne {α : Sort u} {a : α} : a ≠ a → False :=\n  ne.irrefl\n\ntheorem ne_false_of_self {p : Prop} : p → p ≠ False :=\n  fun (hp : p) (heq : p = False) => heq ▸ hp\n\ntheorem ne_true_of_not {p : Prop} : ¬p → p ≠ True :=\n  fun (hnp : ¬p) (heq : p = True) => Eq.subst heq hnp trivial\n\ntheorem true_ne_false : ¬True = False :=\n  ne_false_of_self trivial\n\ntheorem heq.elim {α : Sort u} {a : α} {p : α → Sort v} {b : α} (h₁ : a == b) : p a → p b :=\n  eq.rec_on (eq_of_heq h₁)\n\ntheorem heq.subst {α : Sort u} {β : Sort u} {a : α} {b : β} {p : (T : Sort u) → T → Prop} : a == b → p α a → p β b :=\n  heq.rec_on\n\ntheorem heq.symm {α : Sort u} {β : Sort u} {a : α} {b : β} (h : a == b) : b == a :=\n  heq.rec_on h (HEq.refl a)\n\ntheorem heq_of_eq {α : Sort u} {a : α} {a' : α} (h : a = a') : a == a' :=\n  h ▸ HEq.refl a\n\ntheorem heq.trans {α : Sort u} {β : Sort u} {φ : Sort u} {a : α} {b : β} {c : φ} (h₁ : a == b) (h₂ : b == c) : a == c :=\n  HEq.subst h₂ h₁\n\ntheorem heq_of_heq_of_eq {α : Sort u} {β : Sort u} {a : α} {b : β} {b' : β} (h₁ : a == b) (h₂ : b = b') : a == b' :=\n  HEq.trans h₁ (heq_of_eq h₂)\n\ntheorem heq_of_eq_of_heq {α : Sort u} {β : Sort u} {a : α} {a' : α} {b : β} (h₁ : a = a') (h₂ : a' == b) : a == b :=\n  HEq.trans (heq_of_eq h₁) h₂\n\ndef type_eq_of_heq {α : Sort u} {β : Sort u} {a : α} {b : β} (h : a == b) : α = β :=\n  heq.rec_on h (Eq.refl α)\n\ntheorem eq_rec_heq {α : Sort u} {φ : α → Sort v} {a : α} {a' : α} (h : a = a') (p : φ a) : eq.rec_on h p == p := sorry\n\ntheorem heq_of_eq_rec_left {α : Sort u} {φ : α → Sort v} {a : α} {a' : α} {p₁ : φ a} {p₂ : φ a'} (e : a = a') (h₂ : eq.rec_on e p₁ = p₂) : p₁ == p₂ := sorry\n\ntheorem heq_of_eq_rec_right {α : Sort u} {φ : α → Sort v} {a : α} {a' : α} {p₁ : φ a} {p₂ : φ a'} (e : a' = a) (h₂ : p₁ = eq.rec_on e p₂) : p₁ == p₂ := sorry\n\ntheorem of_heq_true {a : Prop} (h : a == True) : a :=\n  of_eq_true (eq_of_heq h)\n\ntheorem eq_rec_compose {α : Sort u} {β : Sort u} {φ : Sort u} (p₁ : β = φ) (p₂ : α = β) (a : α) : eq.rec_on p₁ (eq.rec_on p₂ a) = eq.rec_on (Eq.trans p₂ p₁) a := sorry\n\ntheorem cast_heq {α : Sort u} {β : Sort u} (h : α = β) (a : α) : cast h a == a := sorry\n\ninfixr:35 \" /\\ \" => Mathlib.and\n\ninfixr:35 \" ∧ \" => Mathlib.and\n\n/- and -/\n\ntheorem and.elim {a : Prop} {b : Prop} {c : Prop} (h₁ : a ∧ b) (h₂ : a → b → c) : c :=\n  And._oldrec h₂ h₁\n\ntheorem and.swap {a : Prop} {b : Prop} : a ∧ b → b ∧ a :=\n  fun (_x : a ∧ b) =>\n    (fun (_a : a ∧ b) => and.dcases_on _a fun (left : a) (right : b) => idRhs (b ∧ a) { left := right, right := left }) _x\n\ndef and.symm {a : Prop} {b : Prop} : a ∧ b → b ∧ a :=\n  and.swap\n\ninfixr:30 \" \\/ \" => Mathlib.or\n\ninfixr:30 \" ∨ \" => Mathlib.or\n\n/- or -/\n\nnamespace or\n\n\ntheorem elim {a : Prop} {b : Prop} {c : Prop} (h₁ : a ∨ b) (h₂ : a → c) (h₃ : b → c) : c :=\n  Or._oldrec h₂ h₃ h₁\n\nend or\n\n\ntheorem non_contradictory_em (a : Prop) : ¬¬(a ∨ ¬a) :=\n  fun (not_em : ¬(a ∨ ¬a)) =>\n    (fun (neg_a : ¬a) => absurd (Or.inr neg_a) not_em) fun (pos_a : a) => absurd (Or.inl pos_a) not_em\n\ndef not_not_em (a : Prop) : ¬¬(a ∨ ¬a) :=\n  non_contradictory_em\n\ntheorem or.swap {a : Prop} {b : Prop} : a ∨ b → b ∨ a :=\n  Or._oldrec Or.inr Or.inl\n\ndef or.symm {a : Prop} {b : Prop} : a ∨ b → b ∨ a :=\n  or.swap\n\n/- xor -/\n\ndef xor (a : Prop) (b : Prop) :=\n  a ∧ ¬b ∨ b ∧ ¬a\n\n/- iff -/\n\n/-- `iff P Q`, with notation `P ↔ Q`, is the proposition asserting that `P` and `Q` are equivalent,\nthat is, have the same truth value. -/\ninfixl:20 \" <-> \" => Mathlib.iff\n\ninfixl:20 \" ↔ \" => Mathlib.iff\n\ntheorem iff.elim {a : Prop} {b : Prop} {c : Prop} : ((a → b) → (b → a) → c) → (a ↔ b) → c :=\n  Iff._oldrec\n\ntheorem iff.elim_left {a : Prop} {b : Prop} : (a ↔ b) → a → b :=\n  iff.mp\n\ntheorem iff.elim_right {a : Prop} {b : Prop} : (a ↔ b) → b → a :=\n  iff.mpr\n\ntheorem iff_iff_implies_and_implies (a : Prop) (b : Prop) : a ↔ b ↔ (a → b) ∧ (b → a) :=\n  { mp := fun (h : a ↔ b) => { left := iff.mp h, right := iff.mpr h },\n    mpr := fun (h : (a → b) ∧ (b → a)) => { mp := and.left h, mpr := and.right h } }\n\ntheorem iff.refl (a : Prop) : a ↔ a :=\n  { mp := fun (h : a) => h, mpr := fun (h : a) => h }\n\ntheorem iff.rfl {a : Prop} : a ↔ a :=\n  iff.refl a\n\ntheorem iff.trans {a : Prop} {b : Prop} {c : Prop} (h₁ : a ↔ b) (h₂ : b ↔ c) : a ↔ c :=\n  { mp := fun (ha : a) => iff.mp h₂ (iff.mp h₁ ha), mpr := fun (hc : c) => iff.mpr h₁ (iff.mpr h₂ hc) }\n\ntheorem iff.symm {a : Prop} {b : Prop} (h : a ↔ b) : b ↔ a :=\n  { mp := iff.elim_right h, mpr := iff.elim_left h }\n\ntheorem iff.comm {a : Prop} {b : Prop} : a ↔ b ↔ (b ↔ a) :=\n  { mp := iff.symm, mpr := iff.symm }\n\ntheorem eq.to_iff {a : Prop} {b : Prop} (h : a = b) : a ↔ b :=\n  eq.rec_on h iff.rfl\n\ntheorem neq_of_not_iff {a : Prop} {b : Prop} : ¬(a ↔ b) → a ≠ b :=\n  fun (h₁ : ¬(a ↔ b)) (h₂ : a = b) => (fun (this : a ↔ b) => absurd this h₁) (h₂ ▸ iff.refl a)\n\ntheorem not_iff_not_of_iff {a : Prop} {b : Prop} (h₁ : a ↔ b) : ¬a ↔ ¬b :=\n  { mp := fun (hna : ¬a) (hb : b) => hna (iff.elim_right h₁ hb),\n    mpr := fun (hnb : ¬b) (ha : a) => hnb (iff.elim_left h₁ ha) }\n\ntheorem of_iff_true {a : Prop} (h : a ↔ True) : a :=\n  iff.mp (iff.symm h) trivial\n\ntheorem not_of_iff_false {a : Prop} : (a ↔ False) → ¬a :=\n  iff.mp\n\ntheorem iff_true_intro {a : Prop} (h : a) : a ↔ True :=\n  { mp := fun (hl : a) => trivial, mpr := fun (hr : True) => h }\n\ntheorem iff_false_intro {a : Prop} (h : ¬a) : a ↔ False :=\n  { mp := h, mpr := False._oldrec }\n\ntheorem not_non_contradictory_iff_absurd (a : Prop) : ¬¬¬a ↔ ¬a :=\n  { mp := fun (hl : ¬¬¬a) (ha : a) => hl (non_contradictory_intro ha), mpr := absurd }\n\ndef not_not_not_iff (a : Prop) : ¬¬¬a ↔ ¬a :=\n  not_non_contradictory_iff_absurd\n\ntheorem imp_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h₁ : a ↔ c) (h₂ : b ↔ d) : a → b ↔ c → d :=\n  { mp := fun (hab : a → b) (hc : c) => iff.mp h₂ (hab (iff.mpr h₁ hc)),\n    mpr := fun (hcd : c → d) (ha : a) => iff.mpr h₂ (hcd (iff.mp h₁ ha)) }\n\ntheorem imp_congr_ctx {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h₁ : a ↔ c) (h₂ : c → (b ↔ d)) : a → b ↔ c → d :=\n  { mp := fun (hab : a → b) (hc : c) => (fun (ha : a) => (fun (hb : b) => iff.mp (h₂ hc) hb) (hab ha)) (iff.mpr h₁ hc),\n    mpr := fun (hcd : c → d) (ha : a) => (fun (hc : c) => (fun (hd : d) => iff.mpr (h₂ hc) hd) (hcd hc)) (iff.mp h₁ ha) }\n\ntheorem imp_congr_right {a : Prop} {b : Prop} {c : Prop} (h : a → (b ↔ c)) : a → b ↔ a → c :=\n  { mp := fun (hab : a → b) (ha : a) => iff.elim_left (h ha) (hab ha),\n    mpr := fun (hab : a → c) (ha : a) => iff.elim_right (h ha) (hab ha) }\n\ntheorem not_not_intro {a : Prop} (ha : a) : ¬¬a :=\n  fun (hna : ¬a) => hna ha\n\ntheorem not_of_not_not_not {a : Prop} (h : ¬¬¬a) : ¬a :=\n  fun (ha : a) => absurd (not_not_intro ha) h\n\n@[simp] theorem not_true : ¬True ↔ False :=\n  iff_false_intro (not_not_intro trivial)\n\ndef not_true_iff : ¬True ↔ False :=\n  not_true\n\n@[simp] theorem not_false_iff : ¬False ↔ True :=\n  iff_true_intro not_false\n\ntheorem not_congr {a : Prop} {b : Prop} (h : a ↔ b) : ¬a ↔ ¬b :=\n  { mp := fun (h₁ : ¬a) (h₂ : b) => h₁ (iff.mpr h h₂), mpr := fun (h₁ : ¬b) (h₂ : a) => h₁ (iff.mp h h₂) }\n\n@[simp] theorem ne_self_iff_false {α : Sort u} (a : α) : ¬a = a ↔ False :=\n  { mp := false_of_ne, mpr := false.elim }\n\n@[simp] theorem eq_self_iff_true {α : Sort u} (a : α) : a = a ↔ True :=\n  iff_true_intro rfl\n\n@[simp] theorem heq_self_iff_true {α : Sort u} (a : α) : a == a ↔ True :=\n  iff_true_intro (HEq.refl a)\n\n@[simp] theorem iff_not_self (a : Prop) : a ↔ ¬a ↔ False :=\n  iff_false_intro fun (h : a ↔ ¬a) => (fun (h' : ¬a) => h' (iff.mpr h h')) fun (ha : a) => iff.mp h ha ha\n\n@[simp] theorem not_iff_self (a : Prop) : ¬a ↔ a ↔ False :=\n  iff_false_intro fun (h : ¬a ↔ a) => (fun (h' : ¬a) => h' (iff.mp h h')) fun (ha : a) => iff.mpr h ha ha\n\n@[simp] theorem true_iff_false : True ↔ False ↔ False :=\n  iff_false_intro fun (h : True ↔ False) => iff.mp h trivial\n\n@[simp] theorem false_iff_true : False ↔ True ↔ False :=\n  iff_false_intro fun (h : False ↔ True) => iff.mpr h trivial\n\ntheorem false_of_true_iff_false : (True ↔ False) → False :=\n  fun (h : True ↔ False) => iff.mp h trivial\n\ntheorem false_of_true_eq_false : True = False → False :=\n  fun (h : True = False) => h ▸ trivial\n\ntheorem true_eq_false_of_false : False → True = False :=\n  false.elim\n\ntheorem eq_comm {α : Sort u} {a : α} {b : α} : a = b ↔ b = a :=\n  { mp := Eq.symm, mpr := Eq.symm }\n\n/- and simp rules -/\n\ntheorem and.imp {a : Prop} {b : Prop} {c : Prop} {d : Prop} (hac : a → c) (hbd : b → d) : a ∧ b → c ∧ d := sorry\n\ndef and_implies {a : Prop} {b : Prop} {c : Prop} {d : Prop} (hac : a → c) (hbd : b → d) : a ∧ b → c ∧ d :=\n  and.imp\n\ntheorem and_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h₁ : a ↔ c) (h₂ : b ↔ d) : a ∧ b ↔ c ∧ d :=\n  { mp := and.imp (iff.mp h₁) (iff.mp h₂), mpr := and.imp (iff.mpr h₁) (iff.mpr h₂) }\n\ntheorem and_congr_right {a : Prop} {b : Prop} {c : Prop} (h : a → (b ↔ c)) : a ∧ b ↔ a ∧ c := sorry\n\ntheorem and.comm {a : Prop} {b : Prop} : a ∧ b ↔ b ∧ a :=\n  { mp := and.swap, mpr := and.swap }\n\ntheorem and_comm (a : Prop) (b : Prop) : a ∧ b ↔ b ∧ a :=\n  and.comm\n\ntheorem and.assoc {a : Prop} {b : Prop} {c : Prop} : (a ∧ b) ∧ c ↔ a ∧ b ∧ c := sorry\n\ntheorem and_assoc {c : Prop} (a : Prop) (b : Prop) : (a ∧ b) ∧ c ↔ a ∧ b ∧ c :=\n  and.assoc\n\ntheorem and.left_comm {a : Prop} {b : Prop} {c : Prop} : a ∧ b ∧ c ↔ b ∧ a ∧ c :=\n  iff.trans (iff.symm and.assoc) (iff.trans (and_congr and.comm (iff.refl c)) and.assoc)\n\ntheorem and_iff_left {a : Prop} {b : Prop} (hb : b) : a ∧ b ↔ a :=\n  { mp := and.left, mpr := fun (ha : a) => { left := ha, right := hb } }\n\ntheorem and_iff_right {a : Prop} {b : Prop} (ha : a) : a ∧ b ↔ b :=\n  { mp := and.right, mpr := And.intro ha }\n\n@[simp] theorem and_true (a : Prop) : a ∧ True ↔ a :=\n  and_iff_left trivial\n\n@[simp] theorem true_and (a : Prop) : True ∧ a ↔ a :=\n  and_iff_right trivial\n\n@[simp] theorem and_false (a : Prop) : a ∧ False ↔ False :=\n  iff_false_intro and.right\n\n@[simp] theorem false_and (a : Prop) : False ∧ a ↔ False :=\n  iff_false_intro and.left\n\n@[simp] theorem not_and_self (a : Prop) : ¬a ∧ a ↔ False :=\n  iff_false_intro fun (h : ¬a ∧ a) => and.elim h fun (h₁ : ¬a) (h₂ : a) => absurd h₂ h₁\n\n@[simp] theorem and_not_self (a : Prop) : a ∧ ¬a ↔ False :=\n  iff_false_intro\n    fun (_x : a ∧ ¬a) =>\n      (fun (_a : a ∧ ¬a) => and.dcases_on _a fun (left : a) (right : ¬a) => idRhs False (absurd left right)) _x\n\n@[simp] theorem and_self (a : Prop) : a ∧ a ↔ a :=\n  { mp := and.left, mpr := fun (h : a) => { left := h, right := h } }\n\n/- or simp rules -/\n\ntheorem or.imp {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h₂ : a → c) (h₃ : b → d) : a ∨ b → c ∨ d :=\n  Or._oldrec (fun (h : a) => Or.inl (h₂ h)) fun (h : b) => Or.inr (h₃ h)\n\ntheorem or.imp_left {a : Prop} {b : Prop} {c : Prop} (h : a → b) : a ∨ c → b ∨ c :=\n  or.imp h id\n\ntheorem or.imp_right {a : Prop} {b : Prop} {c : Prop} (h : a → b) : c ∨ a → c ∨ b :=\n  or.imp id h\n\ntheorem or_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h₁ : a ↔ c) (h₂ : b ↔ d) : a ∨ b ↔ c ∨ d :=\n  { mp := or.imp (iff.mp h₁) (iff.mp h₂), mpr := or.imp (iff.mpr h₁) (iff.mpr h₂) }\n\ntheorem or.comm {a : Prop} {b : Prop} : a ∨ b ↔ b ∨ a :=\n  { mp := or.swap, mpr := or.swap }\n\ntheorem or_comm (a : Prop) (b : Prop) : a ∨ b ↔ b ∨ a :=\n  or.comm\n\ntheorem or.assoc {a : Prop} {b : Prop} {c : Prop} : (a ∨ b) ∨ c ↔ a ∨ b ∨ c :=\n  { mp := Or._oldrec (or.imp_right Or.inl) fun (h : c) => Or.inr (Or.inr h),\n    mpr := Or._oldrec (fun (h : a) => Or.inl (Or.inl h)) (or.imp_left Or.inr) }\n\ntheorem or_assoc {c : Prop} (a : Prop) (b : Prop) : (a ∨ b) ∨ c ↔ a ∨ b ∨ c :=\n  or.assoc\n\ntheorem or.left_comm {a : Prop} {b : Prop} {c : Prop} : a ∨ b ∨ c ↔ b ∨ a ∨ c :=\n  iff.trans (iff.symm or.assoc) (iff.trans (or_congr or.comm (iff.refl c)) or.assoc)\n\ntheorem or_iff_right_of_imp {a : Prop} {b : Prop} (ha : a → b) : a ∨ b ↔ b :=\n  { mp := Or._oldrec ha id, mpr := Or.inr }\n\ntheorem or_iff_left_of_imp {a : Prop} {b : Prop} (hb : b → a) : a ∨ b ↔ a :=\n  { mp := Or._oldrec id hb, mpr := Or.inl }\n\n@[simp] theorem or_true (a : Prop) : a ∨ True ↔ True :=\n  iff_true_intro (Or.inr trivial)\n\n@[simp] theorem true_or (a : Prop) : True ∨ a ↔ True :=\n  iff_true_intro (Or.inl trivial)\n\n@[simp] theorem or_false (a : Prop) : a ∨ False ↔ a :=\n  { mp := Or._oldrec id false.elim, mpr := Or.inl }\n\n@[simp] theorem false_or (a : Prop) : False ∨ a ↔ a :=\n  iff.trans or.comm (or_false a)\n\n@[simp] theorem or_self (a : Prop) : a ∨ a ↔ a :=\n  { mp := Or._oldrec id id, mpr := Or.inl }\n\ntheorem not_or {a : Prop} {b : Prop} : ¬a → ¬b → ¬(a ∨ b) :=\n  fun (ᾰ : ¬a) (ᾰ_1 : ¬b) (ᾰ_2 : a ∨ b) =>\n    or.dcases_on ᾰ_2 (fun (ᾰ_1 : a) => idRhs False (absurd ᾰ_1 ᾰ)) fun (ᾰ_1_1 : b) => idRhs False (absurd ᾰ_1_1 ᾰ_1)\n\n/- or resolution rulse -/\n\ndef or.resolve_left {a : Prop} {b : Prop} (h : a ∨ b) (na : ¬a) : b :=\n  or.elim h (fun (ha : a) => absurd ha na) id\n\ndef or.neg_resolve_left {a : Prop} {b : Prop} (h : ¬a ∨ b) (ha : a) : b :=\n  or.elim h (fun (na : ¬a) => absurd ha na) id\n\ndef or.resolve_right {a : Prop} {b : Prop} (h : a ∨ b) (nb : ¬b) : a :=\n  or.elim h id fun (hb : b) => absurd hb nb\n\ndef or.neg_resolve_right {a : Prop} {b : Prop} (h : a ∨ ¬b) (hb : b) : a :=\n  or.elim h id fun (nb : ¬b) => absurd hb nb\n\n/- iff simp rules -/\n\n@[simp] theorem iff_true (a : Prop) : a ↔ True ↔ a :=\n  { mp := fun (h : a ↔ True) => iff.mpr h trivial, mpr := iff_true_intro }\n\n@[simp] theorem true_iff (a : Prop) : True ↔ a ↔ a :=\n  iff.trans iff.comm (iff_true a)\n\n@[simp] theorem iff_false (a : Prop) : a ↔ False ↔ ¬a :=\n  { mp := iff.mp, mpr := iff_false_intro }\n\n@[simp] theorem false_iff (a : Prop) : False ↔ a ↔ ¬a :=\n  iff.trans iff.comm (iff_false a)\n\n@[simp] theorem iff_self (a : Prop) : a ↔ a ↔ True :=\n  iff_true_intro iff.rfl\n\ntheorem iff_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h₁ : a ↔ c) (h₂ : b ↔ d) : a ↔ b ↔ (c ↔ d) :=\n  iff.trans (iff_iff_implies_and_implies a b)\n    (iff.trans (and_congr (imp_congr h₁ h₂) (imp_congr h₂ h₁)) (iff.symm (iff_iff_implies_and_implies c d)))\n\n/- implies simp rule -/\n\n@[simp] theorem implies_true_iff (α : Sort u) : α → True ↔ True :=\n  { mp := fun (h : α → True) => trivial, mpr := fun (ha : True) (h : α) => trivial }\n\n@[simp] theorem false_implies_iff (a : Prop) : False → a ↔ True :=\n  { mp := fun (h : False → a) => trivial, mpr := fun (ha : True) (h : False) => false.elim h }\n\n@[simp] theorem true_implies_iff (α : Prop) : True → α ↔ α :=\n  { mp := fun (h : True → α) => h trivial, mpr := fun (h : α) (h' : True) => h }\n\n/--\nThe existential quantifier.\n\nTo prove a goal of the form `⊢ ∃ x, p x`, you can provide a witness `y` with the tactic `existsi y`.\nIf you are working in a project that depends on mathlib, then we recommend the `use` tactic\ninstead.\nYou'll then be left with the goal `⊢ p y`.\n\nTo extract a witness `x` and proof `hx : p x` from a hypothesis `h : ∃ x, p x`,\nuse the tactic `cases h with x hx`. See also the mathlib tactics `obtain` and `rcases`.\n-/\ndef exists.intro {α : Sort u_1} {p : α → Prop} (w : α) (h : p w) : Exists p :=\n  Exists.intro\n\ntheorem exists.elim {α : Sort u} {p : α → Prop} {b : Prop} (h₁ : ∃ (x : α), p x) (h₂ : ∀ (a : α), p a → b) : b :=\n  Exists._oldrec h₂ h₁\n\n/- exists unique -/\n\ndef exists_unique {α : Sort u} (p : α → Prop) :=\n  ∃ (x : α), p x ∧ ∀ (y : α), p y → y = x\n\ntheorem exists_unique.intro {α : Sort u} {p : α → Prop} (w : α) (h₁ : p w) (h₂ : ∀ (y : α), p y → y = w) : exists_unique fun (x : α) => p x :=\n  exists.intro w { left := h₁, right := h₂ }\n\ntheorem exists_unique.elim {α : Sort u} {p : α → Prop} {b : Prop} (h₂ : exists_unique fun (x : α) => p x) (h₁ : ∀ (x : α), p x → (∀ (y : α), p y → y = x) → b) : b :=\n  exists.elim h₂ fun (w : α) (hw : (fun (x : α) => p x) w ∧ ∀ (y : α), p y → y = w) => h₁ w (and.left hw) (and.right hw)\n\ntheorem exists_unique_of_exists_of_unique {α : Type u} {p : α → Prop} (hex : ∃ (x : α), p x) (hunique : ∀ (y₁ y₂ : α), p y₁ → p y₂ → y₁ = y₂) : exists_unique fun (x : α) => p x :=\n  exists.elim hex fun (x : α) (px : p x) => exists_unique.intro x px fun (y : α) (this : p y) => hunique y x this px\n\ntheorem exists_of_exists_unique {α : Sort u} {p : α → Prop} (h : exists_unique fun (x : α) => p x) : ∃ (x : α), p x :=\n  exists.elim h fun (x : α) (hx : (fun (x : α) => p x) x ∧ ∀ (y : α), p y → y = x) => Exists.intro x (and.left hx)\n\ntheorem unique_of_exists_unique {α : Sort u} {p : α → Prop} (h : exists_unique fun (x : α) => p x) {y₁ : α} {y₂ : α} (py₁ : p y₁) (py₂ : p y₂) : y₁ = y₂ :=\n  exists_unique.elim h\n    fun (x : α) (this : p x) (unique : ∀ (y : α), p y → y = x) =>\n      (fun (this : y₁ = y₂) => this) (Eq.trans (unique y₁ py₁) (Eq.symm (unique y₂ py₂)))\n\n/- exists, forall, exists unique congruences -/\n\ntheorem forall_congr {α : Sort u} {p : α → Prop} {q : α → Prop} (h : ∀ (a : α), p a ↔ q a) : (∀ (a : α), p a) ↔ ∀ (a : α), q a :=\n  { mp := fun (p_1 : ∀ (a : α), p a) (a : α) => iff.mp (h a) (p_1 a),\n    mpr := fun (q_1 : ∀ (a : α), q a) (a : α) => iff.mpr (h a) (q_1 a) }\n\ntheorem exists_imp_exists {α : Sort u} {p : α → Prop} {q : α → Prop} (h : ∀ (a : α), p a → q a) : (∃ (a : α), p a) → ∃ (a : α), q a :=\n  fun (p_1 : ∃ (a : α), p a) => exists.elim p_1 fun (a : α) (hp : p a) => Exists.intro a (h a hp)\n\ntheorem exists_congr {α : Sort u} {p : α → Prop} {q : α → Prop} (h : ∀ (a : α), p a ↔ q a) : Exists p ↔ ∃ (a : α), q a :=\n  { mp := exists_imp_exists fun (a : α) => iff.mp (h a), mpr := exists_imp_exists fun (a : α) => iff.mpr (h a) }\n\ntheorem exists_unique_congr {α : Sort u} {p₁ : α → Prop} {p₂ : α → Prop} (h : ∀ (x : α), p₁ x ↔ p₂ x) : exists_unique p₁ ↔ exists_unique fun (x : α) => p₂ x :=\n  exists_congr fun (x : α) => and_congr (h x) (forall_congr fun (y : α) => imp_congr (h y) iff.rfl)\n\ntheorem forall_not_of_not_exists {α : Sort u} {p : α → Prop} : (¬∃ (x : α), p x) → ∀ (x : α), ¬p x :=\n  fun (hne : ¬∃ (x : α), p x) (x : α) (hp : p x) => hne (Exists.intro x hp)\n\n/- decidable -/\n\ndef decidable.to_bool (p : Prop) [h : Decidable p] : Bool :=\n  decidable.cases_on h (fun (h₁ : ¬p) => false) fun (h₂ : p) => tt\n\n@[simp] theorem to_bool_true_eq_tt (h : Decidable True) : to_bool True = tt :=\n  decidable.cases_on h (fun (h : ¬True) => false.elim (iff.mp not_true h)) fun (_x : True) => rfl\n\n@[simp] theorem to_bool_false_eq_ff (h : Decidable False) : to_bool False = false :=\n  decidable.cases_on h (fun (h : ¬False) => rfl) fun (h : False) => false.elim h\n\nprotected instance decidable.true : Decidable True :=\n  is_true trivial\n\nprotected instance decidable.false : Decidable False :=\n  is_false not_false\n\n-- We use \"dependent\" if-then-else to be able to communicate the if-then-else condition\n\n-- to the branches\n\ndef dite (c : Prop) [h : Decidable c] {α : Sort u} : (c → α) → (¬c → α) → α :=\n  fun (t : c → α) (e : ¬c → α) => decidable.rec_on h e t\n\n/- if-then-else -/\n\ndef ite (c : Prop) [h : Decidable c] {α : Sort u} (t : α) (e : α) : α :=\n  decidable.rec_on h (fun (hnc : ¬c) => e) fun (hc : c) => t\n\nnamespace decidable\n\n\ndef rec_on_true {p : Prop} [h : Decidable p] {h₁ : p → Sort u} {h₂ : ¬p → Sort u} (h₃ : p) (h₄ : h₁ h₃) : decidable.rec_on h h₂ h₁ :=\n  decidable.rec_on h (fun (h : ¬p) => False._oldrec (h h₃)) fun (h : p) => h₄\n\ndef rec_on_false {p : Prop} [h : Decidable p] {h₁ : p → Sort u} {h₂ : ¬p → Sort u} (h₃ : ¬p) (h₄ : h₂ h₃) : decidable.rec_on h h₂ h₁ :=\n  decidable.rec_on h (fun (h : ¬p) => h₄) fun (h : p) => False._oldrec (h₃ h)\n\ndef by_cases {p : Prop} {q : Sort u} [φ : Decidable p] : (p → q) → (¬p → q) → q :=\n  dite p\n\ntheorem em (p : Prop) [Decidable p] : p ∨ ¬p :=\n  by_cases Or.inl Or.inr\n\ntheorem by_contradiction {p : Prop} [Decidable p] (h : ¬p → False) : p :=\n  dite p (fun (h₁ : p) => h₁) fun (h₁ : ¬p) => False._oldrec (h h₁)\n\ntheorem of_not_not {p : Prop} [Decidable p] : ¬¬p → p :=\n  fun (hnn : ¬¬p) => by_contradiction fun (hn : ¬p) => absurd hn hnn\n\ntheorem not_not_iff (p : Prop) [Decidable p] : ¬¬p ↔ p :=\n  { mp := of_not_not, mpr := not_not_intro }\n\ntheorem not_and_iff_or_not (p : Prop) (q : Prop) [d₁ : Decidable p] [d₂ : Decidable q] : ¬(p ∧ q) ↔ ¬p ∨ ¬q := sorry\n\ntheorem not_or_iff_and_not (p : Prop) (q : Prop) [d₁ : Decidable p] [d₂ : Decidable q] : ¬(p ∨ q) ↔ ¬p ∧ ¬q := sorry\n\nend decidable\n\n\ndef decidable_of_decidable_of_iff {p : Prop} {q : Prop} (hp : Decidable p) (h : p ↔ q) : Decidable q :=\n  dite p (fun (hp : p) => is_true (iff.mp h hp)) fun (hp : ¬p) => is_false sorry\n\ndef decidable_of_decidable_of_eq {p : Prop} {q : Prop} (hp : Decidable p) (h : p = q) : Decidable q :=\n  decidable_of_decidable_of_iff hp (eq.to_iff h)\n\nprotected def or.by_cases {p : Prop} {q : Prop} [Decidable p] [Decidable q] {α : Sort u} (h : p ∨ q) (h₁ : p → α) (h₂ : q → α) : α :=\n  dite p (fun (hp : p) => h₁ hp)\n    fun (hp : ¬p) => dite q (fun (hq : q) => h₂ hq) fun (hq : ¬q) => False._oldrec (or.elim h hp hq)\n\nprotected instance and.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p ∧ q) :=\n  dite p (fun (hp : p) => dite q (fun (hq : q) => is_true { left := hp, right := hq }) fun (hq : ¬q) => is_false sorry)\n    fun (hp : ¬p) => is_false sorry\n\nprotected instance or.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p ∨ q) :=\n  dite p (fun (hp : p) => is_true (Or.inl hp))\n    fun (hp : ¬p) => dite q (fun (hq : q) => is_true (Or.inr hq)) fun (hq : ¬q) => is_false (Or._oldrec hp hq)\n\nprotected instance not.decidable {p : Prop} [Decidable p] : Decidable (¬p) :=\n  dite p (fun (hp : p) => is_false (absurd hp)) fun (hp : ¬p) => is_true hp\n\nprotected instance implies.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p → q) :=\n  dite p (fun (hp : p) => dite q (fun (hq : q) => is_true sorry) fun (hq : ¬q) => is_false sorry)\n    fun (hp : ¬p) => is_true sorry\n\nprotected instance iff.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p ↔ q) :=\n  dite p (fun (hp : p) => dite q (fun (hq : q) => is_true sorry) fun (hq : ¬q) => is_false sorry)\n    fun (hp : ¬p) => dite q (fun (hq : q) => is_false sorry) fun (hq : ¬q) => is_true sorry\n\nprotected instance xor.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (xor p q) :=\n  dite p (fun (hp : p) => dite q (fun (hq : q) => is_false sorry) fun (hq : ¬q) => is_true sorry)\n    fun (hp : ¬p) => dite q (fun (hq : q) => is_true sorry) fun (hq : ¬q) => is_false sorry\n\nprotected instance exists_prop_decidable {p : Prop} (P : p → Prop) [Dp : Decidable p] [DP : (h : p) → Decidable (P h)] : Decidable (∃ (h : p), P h) :=\n  dite p (fun (h : p) => decidable_of_decidable_of_iff (DP h) sorry) fun (h : ¬p) => is_false sorry\n\nprotected instance forall_prop_decidable {p : Prop} (P : p → Prop) [Dp : Decidable p] [DP : (h : p) → Decidable (P h)] : Decidable (∀ (h : p), P h) :=\n  dite p (fun (h : p) => decidable_of_decidable_of_iff (DP h) sorry) fun (h : ¬p) => is_true sorry\n\nprotected instance ne.decidable {α : Sort u} [DecidableEq α] (a : α) (b : α) : Decidable (a ≠ b) :=\n  implies.decidable\n\ntheorem bool.ff_ne_tt : false = tt → False :=\n  fun (ᾰ : false = tt) => eq.dcases_on ᾰ (fun (H_1 : tt = false) => bool.no_confusion H_1) (Eq.refl tt) (HEq.refl ᾰ)\n\ndef is_dec_eq {α : Sort u} (p : α → α → Bool) :=\n  ∀ {x y : α}, p x y = tt → x = y\n\ndef is_dec_refl {α : Sort u} (p : α → α → Bool) :=\n  ∀ (x : α), p x x = tt\n\nprotected instance bool.decidable_eq : DecidableEq Bool :=\n  sorry\n\ndef decidable_eq_of_bool_pred {α : Sort u} {p : α → α → Bool} (h₁ : is_dec_eq p) (h₂ : is_dec_refl p) : DecidableEq α :=\n  fun (x y : α) => dite (p x y = tt) (fun (hp : p x y = tt) => is_true (h₁ hp)) fun (hp : ¬p x y = tt) => is_false sorry\n\ntheorem decidable_eq_inl_refl {α : Sort u} [h : DecidableEq α] (a : α) : h a a = is_true (Eq.refl a) := sorry\n\ntheorem decidable_eq_inr_neg {α : Sort u} [h : DecidableEq α] {a : α} {b : α} (n : a ≠ b) : h a b = is_false n := sorry\n\n/- inhabited -/\n\ndef arbitrary (α : Sort u) [Inhabited α] : α :=\n  Inhabited.default\n\nprotected instance prop.inhabited : Inhabited Prop :=\n  { default := True }\n\nprotected instance pi.inhabited (α : Sort u) {β : α → Sort v} [(x : α) → Inhabited (β x)] : Inhabited ((x : α) → β x) :=\n  { default := fun (a : α) => Inhabited.default }\n\nprotected instance bool.inhabited : Inhabited Bool :=\n  { default := false }\n\nprotected instance true.inhabited : Inhabited True :=\n  { default := trivial }\n\nprotected def nonempty.elim {α : Sort u} {p : Prop} (h₁ : Nonempty α) (h₂ : α → p) : p :=\n  Nonempty._oldrec h₂ h₁\n\nprotected instance nonempty_of_inhabited {α : Sort u} [Inhabited α] : Nonempty α :=\n  Nonempty.intro Inhabited.default\n\ntheorem nonempty_of_exists {α : Sort u} {p : α → Prop} : (∃ (x : α), p x) → Nonempty α :=\n  fun (ᾰ : ∃ (x : α), p x) => Exists.dcases_on ᾰ fun (ᾰ_w : α) (ᾰ_h : p ᾰ_w) => idRhs (Nonempty α) (Nonempty.intro ᾰ_w)\n\n/- subsingleton -/\n\nclass inductive subsingleton (α : Sort u) \nwhere\n| intro : (∀ (a b : α), a = b) → subsingleton α\n\nprotected def subsingleton.elim {α : Sort u} [h : subsingleton α] (a : α) (b : α) : a = b :=\n  subsingleton._oldrec (fun (p : ∀ (a b : α), a = b) => p) h\n\nprotected def subsingleton.helim {α : Sort u} {β : Sort u} [h : subsingleton α] : α = β → ∀ (a : α) (b : β), a == b :=\n  fun (h_1 : α = β) => eq.rec_on h_1 fun (a b : α) => heq_of_eq (subsingleton.elim a b)\n\nprotected instance subsingleton_prop (p : Prop) : subsingleton p :=\n  subsingleton.intro fun (a b : p) => proof_irrel a b\n\nprotected instance decidable.subsingleton (p : Prop) : subsingleton (Decidable p) :=\n  subsingleton.intro fun (d₁ : Decidable p) => sorry\n\nprotected theorem rec_subsingleton {p : Prop} [h : Decidable p] {h₁ : p → Sort u} {h₂ : ¬p → Sort u} [h₃ : ∀ (h : p), subsingleton (h₁ h)] [h₄ : ∀ (h : ¬p), subsingleton (h₂ h)] : subsingleton (decidable.rec_on h h₂ h₁) := sorry\n\ntheorem if_pos {c : Prop} [h : Decidable c] (hc : c) {α : Sort u} {t : α} {e : α} : ite c t e = t := sorry\n\ntheorem if_neg {c : Prop} [h : Decidable c] (hnc : ¬c) {α : Sort u} {t : α} {e : α} : ite c t e = e := sorry\n\n@[simp] theorem if_t_t (c : Prop) [h : Decidable c] {α : Sort u} (t : α) : ite c t t = t := sorry\n\ntheorem implies_of_if_pos {c : Prop} {t : Prop} {e : Prop} [Decidable c] (h : ite c t e) : c → t :=\n  fun (hc : c) => eq.rec_on (if_pos hc) h\n\ntheorem implies_of_if_neg {c : Prop} {t : Prop} {e : Prop} [Decidable c] (h : ite c t e) : ¬c → e :=\n  fun (hnc : ¬c) => eq.rec_on (if_neg hnc) h\n\ntheorem if_ctx_congr {α : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] [dec_c : Decidable c] {x : α} {y : α} {u : α} {v : α} (h_c : b ↔ c) (h_t : c → x = u) (h_e : ¬c → y = v) : ite b x y = ite c u v := sorry\n\ntheorem if_congr {α : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] [dec_c : Decidable c] {x : α} {y : α} {u : α} {v : α} (h_c : b ↔ c) (h_t : x = u) (h_e : y = v) : ite b x y = ite c u v :=\n  if_ctx_congr h_c (fun (h : c) => h_t) fun (h : ¬c) => h_e\n\n@[simp] theorem if_true {α : Sort u} {h : Decidable True} (t : α) (e : α) : ite True t e = t :=\n  if_pos trivial\n\n@[simp] theorem if_false {α : Sort u} {h : Decidable False} (t : α) (e : α) : ite False t e = e :=\n  if_neg not_false\n\ntheorem if_ctx_congr_prop {b : Prop} {c : Prop} {x : Prop} {y : Prop} {u : Prop} {v : Prop} [dec_b : Decidable b] [dec_c : Decidable c] (h_c : b ↔ c) (h_t : c → (x ↔ u)) (h_e : ¬c → (y ↔ v)) : ite b x y ↔ ite c u v := sorry\n\ntheorem if_congr_prop {b : Prop} {c : Prop} {x : Prop} {y : Prop} {u : Prop} {v : Prop} [dec_b : Decidable b] [dec_c : Decidable c] (h_c : b ↔ c) (h_t : x ↔ u) (h_e : y ↔ v) : ite b x y ↔ ite c u v :=\n  if_ctx_congr_prop h_c (fun (h : c) => h_t) fun (h : ¬c) => h_e\n\ntheorem if_ctx_simp_congr_prop {b : Prop} {c : Prop} {x : Prop} {y : Prop} {u : Prop} {v : Prop} [dec_b : Decidable b] (h_c : b ↔ c) (h_t : c → (x ↔ u)) (h_e : ¬c → (y ↔ v)) : ite b x y ↔ ite c u v :=\n  if_ctx_congr_prop h_c h_t h_e\n\ntheorem if_simp_congr_prop {b : Prop} {c : Prop} {x : Prop} {y : Prop} {u : Prop} {v : Prop} [dec_b : Decidable b] (h_c : b ↔ c) (h_t : x ↔ u) (h_e : y ↔ v) : ite b x y ↔ ite c u v :=\n  if_ctx_simp_congr_prop h_c (fun (h : c) => h_t) fun (h : ¬c) => h_e\n\n@[simp] theorem dif_pos {c : Prop} [h : Decidable c] (hc : c) {α : Sort u} {t : c → α} {e : ¬c → α} : dite c t e = t hc := sorry\n\n@[simp] theorem dif_neg {c : Prop} [h : Decidable c] (hnc : ¬c) {α : Sort u} {t : c → α} {e : ¬c → α} : dite c t e = e hnc := sorry\n\ntheorem dif_ctx_congr {α : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] [dec_c : Decidable c] {x : b → α} {u : c → α} {y : ¬b → α} {v : ¬c → α} (h_c : b ↔ c) (h_t : ∀ (h : c), x (iff.mpr h_c h) = u h) (h_e : ∀ (h : ¬c), y (iff.mpr (not_iff_not_of_iff h_c) h) = v h) : dite b x y = dite c u v := sorry\n\ntheorem dif_ctx_simp_congr {α : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] {x : b → α} {u : c → α} {y : ¬b → α} {v : ¬c → α} (h_c : b ↔ c) (h_t : ∀ (h : c), x (iff.mpr h_c h) = u h) (h_e : ∀ (h : ¬c), y (iff.mpr (not_iff_not_of_iff h_c) h) = v h) : dite b x y = dite c u v :=\n  dif_ctx_congr h_c h_t h_e\n\n-- Remark: dite and ite are \"defally equal\" when we ignore the proofs.\n\ntheorem dif_eq_if (c : Prop) [h : Decidable c] {α : Sort u} (t : α) (e : α) : (dite c (fun (h : c) => t) fun (h : ¬c) => e) = ite c t e := sorry\n\nprotected instance ite.decidable {c : Prop} {t : Prop} {e : Prop} [d_c : Decidable c] [d_t : Decidable t] [d_e : Decidable e] : Decidable (ite c t e) :=\n  sorry\n\nprotected instance dite.decidable {c : Prop} {t : c → Prop} {e : ¬c → Prop} [d_c : Decidable c] [d_t : (h : c) → Decidable (t h)] [d_e : (h : ¬c) → Decidable (e h)] : Decidable (dite c (fun (h : c) => t h) fun (h : ¬c) => e h) :=\n  sorry\n\ndef as_true (c : Prop) [Decidable c] :=\n  ite c True False\n\ndef as_false (c : Prop) [Decidable c] :=\n  ite c False True\n\ndef of_as_true {c : Prop} [h₁ : Decidable c] (h₂ : as_true c) : c :=\n  sorry\n\n/-- Universe lifting operation -/\nstructure ulift (α : Type s) \n  up ::\nwhere (down : α)\n\nnamespace ulift\n\n\n/- Bijection between α and ulift.{v} α -/\n\ntheorem up_down {α : Type u} (b : ulift α) : up (down b) = b :=\n  cases_on b fun (b : α) => idRhs (up (down (up b)) = up (down (up b))) rfl\n\nend ulift\n\n\ntheorem ulift.down_up {α : Type u} (a : α) : ulift.down (ulift.up a) = a :=\n  rfl\n\n/-- Universe lifting operation from Sort to Type -/\nstructure plift (α : Sort u) \n  up ::\nwhere (down : α)\n\nnamespace plift\n\n\n/- Bijection between α and plift α -/\n\ntheorem up_down {α : Sort u} (b : plift α) : up (down b) = b :=\n  cases_on b fun (b : α) => idRhs (up (down (up b)) = up (down (up b))) rfl\n\nend plift\n\n\ntheorem plift.down_up {α : Sort u} (a : α) : plift.down (plift.up a) = a :=\n  rfl\n\n/- Equalities for rewriting let-expressions -/\n\ntheorem let_value_eq {α : Sort u} {β : Sort v} {a₁ : α} {a₂ : α} (b : α → β) : a₁ = a₂ →\n  (let x : α := a₁;\n    b x) =\n    let x : α := a₂;\n    b x :=\n  fun (h : a₁ = a₂) => eq.rec_on h rfl\n\ntheorem let_value_heq {α : Sort v} {β : α → Sort u} {a₁ : α} {a₂ : α} (b : (x : α) → β x) : a₁ = a₂ →\n  (let x : α := a₁;\n    b x) ==\n    let x : α := a₂;\n    b x :=\n  fun (h : a₁ = a₂) => eq.rec_on h (HEq.refl (b a₁))\n\ntheorem let_body_eq {α : Sort v} {β : α → Sort u} (a : α) {b₁ : (x : α) → β x} {b₂ : (x : α) → β x} : (∀ (x : α), b₁ x = b₂ x) →\n  (let x : α := a;\n    b₁ x) =\n    let x : α := a;\n    b₂ x :=\n  fun (h : ∀ (x : α), b₁ x = b₂ x) => h a\n\ntheorem let_eq {α : Sort v} {β : Sort u} {a₁ : α} {a₂ : α} {b₁ : α → β} {b₂ : α → β} : a₁ = a₂ →\n  (∀ (x : α), b₁ x = b₂ x) →\n    (let x : α := a₁;\n      b₁ x) =\n      let x : α := a₂;\n      b₂ x :=\n  fun (h₁ : a₁ = a₂) (h₂ : ∀ (x : α), b₁ x = b₂ x) => eq.rec_on h₁ (h₂ a₁)\n\ndef reflexive {β : Sort v} (r : β → β → Prop) :=\n  ∀ (x : β), r x x\n\ndef symmetric {β : Sort v} (r : β → β → Prop) :=\n  ∀ {x y : β}, r x y → r y x\n\ndef transitive {β : Sort v} (r : β → β → Prop) :=\n  ∀ {x y z : β}, r x y → r y z → r x z\n\ndef equivalence {β : Sort v} (r : β → β → Prop) :=\n  reflexive r ∧ symmetric r ∧ transitive r\n\ndef total {β : Sort v} (r : β → β → Prop) :=\n  ∀ (x y : β), r x y ∨ r y x\n\ndef mk_equivalence {β : Sort v} (r : β → β → Prop) (rfl : reflexive r) (symm : symmetric r) (trans : transitive r) : equivalence r :=\n  { left := rfl, right := { left := symm, right := trans } }\n\ndef irreflexive {β : Sort v} (r : β → β → Prop) :=\n  ∀ (x : β), ¬r x x\n\ndef anti_symmetric {β : Sort v} (r : β → β → Prop) :=\n  ∀ {x y : β}, r x y → r y x → x = y\n\ndef empty_relation {α : Sort u} (a₁ : α) (a₂ : α) :=\n  False\n\ndef subrelation {β : Sort v} (q : β → β → Prop) (r : β → β → Prop) :=\n  ∀ {x y : β}, q x y → r x y\n\ndef inv_image {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β) : α → α → Prop :=\n  fun (a₁ a₂ : α) => r (f a₁) (f a₂)\n\ntheorem inv_image.trans {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β) (h : transitive r) : transitive (inv_image r f) :=\n  fun (a₁ a₂ a₃ : α) (h₁ : inv_image r f a₁ a₂) (h₂ : inv_image r f a₂ a₃) => h h₁ h₂\n\ntheorem inv_image.irreflexive {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β) (h : irreflexive r) : irreflexive (inv_image r f) :=\n  fun (a : α) (h₁ : inv_image r f a a) => h (f a) h₁\n\ninductive tc {α : Sort u} (r : α → α → Prop) : α → α → Prop\nwhere\n| base : ∀ (a b : α), r a b → tc r a b\n| trans : ∀ (a b c : α), tc r a b → tc r b c → tc r a c\n\ndef commutative {α : Type u} (f : α → α → α) :=\n  ∀ (a b : α), f a b = f b a\n\ndef associative {α : Type u} (f : α → α → α) :=\n  ∀ (a b c : α), f (f a b) c = f a (f b c)\n\ndef left_identity {α : Type u} (f : α → α → α) (one : α) :=\n  ∀ (a : α), f one a = a\n\ndef right_identity {α : Type u} (f : α → α → α) (one : α) :=\n  ∀ (a : α), f a one = a\n\ndef right_inverse {α : Type u} (f : α → α → α) (inv : α → α) (one : α) :=\n  ∀ (a : α), f a (inv a) = one\n\ndef left_cancelative {α : Type u} (f : α → α → α) :=\n  ∀ (a b c : α), f a b = f a c → b = c\n\ndef right_cancelative {α : Type u} (f : α → α → α) :=\n  ∀ (a b c : α), f a b = f c b → a = c\n\ndef left_distributive {α : Type u} (f : α → α → α) (g : α → α → α) :=\n  ∀ (a b c : α), f a (g b c) = g (f a b) (f a c)\n\ndef right_distributive {α : Type u} (f : α → α → α) (g : α → α → α) :=\n  ∀ (a b c : α), f (g a b) c = g (f a c) (f b c)\n\ndef right_commutative {α : Type u} {β : Type v} (h : β → α → β) :=\n  ∀ (b : β) (a₁ a₂ : α), h (h b a₁) a₂ = h (h b a₂) a₁\n\ndef left_commutative {α : Type u} {β : Type v} (h : α → β → β) :=\n  ∀ (a₁ a₂ : α) (b : β), h a₁ (h a₂ b) = h a₂ (h a₁ b)\n\ntheorem left_comm {α : Type u} (f : α → α → α) : commutative f → associative f → left_commutative f :=\n  fun (hcomm : commutative f) (hassoc : associative f) (a b c : α) =>\n    Eq.trans (Eq.trans (Eq.symm (hassoc a b c)) (hcomm a b ▸ rfl)) (hassoc b a c)\n\ntheorem right_comm {α : Type u} (f : α → α → α) : commutative f → associative f → right_commutative f :=\n  fun (hcomm : commutative f) (hassoc : associative f) (a b c : α) =>\n    Eq.trans (Eq.trans (hassoc a b c) (hcomm b c ▸ rfl)) (Eq.symm (hassoc a c b))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/logic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.49553269454875093}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Jens Wagemaker\n\n! This file was ported from Lean 3 source module algebra.gcd_monoid.basic\n! leanprover-community/mathlib commit baba818b9acea366489e8ba32d2cc0fcaf50a1f7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Associated\nimport Mathbin.Algebra.GroupPower.Lemmas\nimport Mathbin.Algebra.Ring.Regular\n\n/-!\n# Monoids with normalization functions, `gcd`, and `lcm`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines extra structures on `cancel_comm_monoid_with_zero`s, including `is_domain`s.\n\n## Main Definitions\n\n* `normalization_monoid`\n* `gcd_monoid`\n* `normalized_gcd_monoid`\n* `gcd_monoid_of_gcd`, `gcd_monoid_of_exists_gcd`, `normalized_gcd_monoid_of_gcd`,\n  `normalized_gcd_monoid_of_exists_gcd`\n* `gcd_monoid_of_lcm`, `gcd_monoid_of_exists_lcm`, `normalized_gcd_monoid_of_lcm`,\n  `normalized_gcd_monoid_of_exists_lcm`\n\nFor the `normalized_gcd_monoid` instances on `ℕ` and `ℤ`, see `ring_theory.int.basic`.\n\n## Implementation Notes\n\n* `normalization_monoid` is defined by assigning to each element a `norm_unit` such that multiplying\nby that unit normalizes the monoid, and `normalize` is an idempotent monoid homomorphism. This\ndefinition as currently implemented does casework on `0`.\n\n* `gcd_monoid` contains the definitions of `gcd` and `lcm` with the usual properties. They are\n  both determined up to a unit.\n\n* `normalized_gcd_monoid` extends `normalization_monoid`, so the `gcd` and `lcm` are always\n  normalized. This makes `gcd`s of polynomials easier to work with, but excludes Euclidean domains,\n  and monoids without zero.\n\n* `gcd_monoid_of_gcd` and `normalized_gcd_monoid_of_gcd` noncomputably construct a `gcd_monoid`\n  (resp. `normalized_gcd_monoid`) structure just from the `gcd` and its properties.\n\n* `gcd_monoid_of_exists_gcd` and `normalized_gcd_monoid_of_exists_gcd` noncomputably construct a\n  `gcd_monoid` (resp. `normalized_gcd_monoid`) structure just from a proof that any two elements\n  have a (not necessarily normalized) `gcd`.\n\n* `gcd_monoid_of_lcm` and `normalized_gcd_monoid_of_lcm` noncomputably construct a `gcd_monoid`\n  (resp. `normalized_gcd_monoid`) structure just from the `lcm` and its properties.\n\n* `gcd_monoid_of_exists_lcm` and `normalized_gcd_monoid_of_exists_lcm` noncomputably construct a\n  `gcd_monoid` (resp. `normalized_gcd_monoid`) structure just from a proof that any two elements\n  have a (not necessarily normalized) `lcm`.\n\n## TODO\n\n* Port GCD facts about nats, definition of coprime\n* Generalize normalization monoids to commutative (cancellative) monoids with or without zero\n\n## Tags\n\ndivisibility, gcd, lcm, normalize\n-/\n\n\nvariable {α : Type _}\n\n#print NormalizationMonoid /-\n/-- Normalization monoid: multiplying with `norm_unit` gives a normal form for associated\nelements. -/\n@[protect_proj]\nclass NormalizationMonoid (α : Type _) [CancelCommMonoidWithZero α] where\n  normUnit : α → αˣ\n  normUnit_zero : norm_unit 0 = 1\n  normUnit_mul : ∀ {a b}, a ≠ 0 → b ≠ 0 → norm_unit (a * b) = norm_unit a * norm_unit b\n  normUnit_coe_units : ∀ u : αˣ, norm_unit u = u⁻¹\n#align normalization_monoid NormalizationMonoid\n-/\n\nexport NormalizationMonoid (normUnit normUnit_zero normUnit_mul normUnit_coe_units)\n\nattribute [simp] norm_unit_coe_units norm_unit_zero norm_unit_mul\n\nsection NormalizationMonoid\n\nvariable [CancelCommMonoidWithZero α] [NormalizationMonoid α]\n\n/- warning: norm_unit_one -> normUnit_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (OfNat.mk.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.one.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulOneClass.toHasOne.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Units.mulOneClass.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.toOfNat1.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (InvOneClass.toOne.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivisionCommMonoid.toDivisionMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommGroup.toDivisionCommMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Units.instCommGroupUnitsToMonoid.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align norm_unit_one normUnit_oneₓ'. -/\n@[simp]\ntheorem normUnit_one : normUnit (1 : α) = 1 :=\n  normUnit_coe_units 1\n#align norm_unit_one normUnit_one\n\n#print normalize /-\n/-- Chooses an element of each associate class, by multiplying by `norm_unit` -/\ndef normalize : α →*₀ α where\n  toFun x := x * normUnit x\n  map_zero' := by simp\n  map_one' := by rw [normUnit_one, Units.val_one, mul_one]\n  map_mul' x y :=\n    by_cases\n      (fun hx : x = 0 => by\n        rw [hx, MulZeroClass.zero_mul, MulZeroClass.zero_mul, MulZeroClass.zero_mul])\n      fun hx =>\n      by_cases\n        (fun hy : y = 0 => by\n          rw [hy, MulZeroClass.mul_zero, MulZeroClass.zero_mul, MulZeroClass.mul_zero])\n        fun hy => by\n        simp only [norm_unit_mul hx hy, Units.val_mul] <;> simp only [mul_assoc, mul_left_comm y]\n#align normalize normalize\n-/\n\n/- warning: associated_normalize -> associated_normalize is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x)\nCase conversion may be inaccurate. Consider using '#align associated_normalize associated_normalizeₓ'. -/\ntheorem associated_normalize (x : α) : Associated x (normalize x) :=\n  ⟨_, rfl⟩\n#align associated_normalize associated_normalize\n\n/- warning: normalize_associated -> normalize_associated is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x) x\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Associated.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x) x\nCase conversion may be inaccurate. Consider using '#align normalize_associated normalize_associatedₓ'. -/\ntheorem normalize_associated (x : α) : Associated (normalize x) x :=\n  (associated_normalize _).symm\n#align normalize_associated normalize_associated\n\n/- warning: associated_normalize_iff -> associated_normalize_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α} {y : α}, Iff (Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) y)) (Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x y)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α} {y : α}, Iff (Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) y)) (Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x y)\nCase conversion may be inaccurate. Consider using '#align associated_normalize_iff associated_normalize_iffₓ'. -/\ntheorem associated_normalize_iff {x y : α} : Associated x (normalize y) ↔ Associated x y :=\n  ⟨fun h => h.trans (normalize_associated y), fun h => h.trans (associated_normalize y)⟩\n#align associated_normalize_iff associated_normalize_iff\n\n/- warning: normalize_associated_iff -> normalize_associated_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α} {y : α}, Iff (Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x) y) (Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x y)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α} {y : α}, Iff (Associated.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x) y) (Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x y)\nCase conversion may be inaccurate. Consider using '#align normalize_associated_iff normalize_associated_iffₓ'. -/\ntheorem normalize_associated_iff {x y : α} : Associated (normalize x) y ↔ Associated x y :=\n  ⟨fun h => (associated_normalize _).trans h, fun h => (normalize_associated _).trans h⟩\n#align normalize_associated_iff normalize_associated_iff\n\n/- warning: associates.mk_normalize -> Associates.mk_normalize is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Eq.{succ u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x)) (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Eq.{succ u1} (Associates.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1)))) (Associates.mk.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x)) (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x)\nCase conversion may be inaccurate. Consider using '#align associates.mk_normalize Associates.mk_normalizeₓ'. -/\ntheorem Associates.mk_normalize (x : α) : Associates.mk (normalize x) = Associates.mk x :=\n  Associates.mk_eq_mk_iff_associated.2 (normalize_associated _)\n#align associates.mk_normalize Associates.mk_normalize\n\n/- warning: normalize_apply -> normalize_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (coeBase.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (Units.hasCoe.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 x)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) x (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 x)))\nCase conversion may be inaccurate. Consider using '#align normalize_apply normalize_applyₓ'. -/\n@[simp]\ntheorem normalize_apply (x : α) : normalize x = x * normUnit x :=\n  rfl\n#align normalize_apply normalize_apply\n\n/- warning: normalize_zero -> normalize_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (CommMonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) _inst_1))))\nCase conversion may be inaccurate. Consider using '#align normalize_zero normalize_zeroₓ'. -/\n@[simp]\ntheorem normalize_zero : normalize (0 : α) = 0 :=\n  normalize.map_zero\n#align normalize_zero normalize_zero\n\n/- warning: normalize_one -> normalize_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (Monoid.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align normalize_one normalize_oneₓ'. -/\n@[simp]\ntheorem normalize_one : normalize (1 : α) = 1 :=\n  normalize.map_one\n#align normalize_one normalize_one\n\n/- warning: normalize_coe_units -> normalize_coe_units is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (u : Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (coeBase.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (Units.hasCoe.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) u)) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (u : Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) (Monoid.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align normalize_coe_units normalize_coe_unitsₓ'. -/\ntheorem normalize_coe_units (u : αˣ) : normalize (u : α) = 1 := by simp\n#align normalize_coe_units normalize_coe_units\n\n/- warning: normalize_eq_zero -> normalize_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α}, Iff (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (Eq.{succ u1} α x (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))))) (Eq.{succ u1} α x (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align normalize_eq_zero normalize_eq_zeroₓ'. -/\ntheorem normalize_eq_zero {x : α} : normalize x = 0 ↔ x = 0 :=\n  ⟨fun hx => (associated_zero_iff_eq_zero x).1 <| hx ▸ associated_normalize _, by\n    rintro rfl <;> exact normalize_zero⟩\n#align normalize_eq_zero normalize_eq_zero\n\n/- warning: normalize_eq_one -> normalize_eq_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α}, Iff (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (Monoid.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))))))) (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) x)\nCase conversion may be inaccurate. Consider using '#align normalize_eq_one normalize_eq_oneₓ'. -/\ntheorem normalize_eq_one {x : α} : normalize x = 1 ↔ IsUnit x :=\n  ⟨fun hx => isUnit_iff_exists_inv.2 ⟨_, hx⟩, fun ⟨u, hu⟩ => hu ▸ normalize_coe_units u⟩\n#align normalize_eq_one normalize_eq_one\n\n/- warning: norm_unit_mul_norm_unit -> normUnit_mul_normUnit is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (coeBase.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (Units.hasCoe.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 a)))) (OfNat.ofNat.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (OfNat.mk.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.one.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulOneClass.toHasOne.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Units.mulOneClass.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (NormalizationMonoid.normUnit.{u1} α _inst_1 _inst_2 a)))) (OfNat.ofNat.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.toOfNat1.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (InvOneClass.toOne.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivisionCommMonoid.toDivisionMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommGroup.toDivisionCommMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Units.instCommGroupUnitsToMonoid.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align norm_unit_mul_norm_unit normUnit_mul_normUnitₓ'. -/\n@[simp]\ntheorem normUnit_mul_normUnit (a : α) : normUnit (a * normUnit a) = 1 :=\n  by\n  nontriviality α using Subsingleton.elim a 0\n  obtain rfl | h := eq_or_ne a 0\n  · rw [norm_unit_zero, MulZeroClass.zero_mul, norm_unit_zero]\n  · rw [norm_unit_mul h (Units.ne_zero _), norm_unit_coe_units, mul_inv_eq_one]\n#align norm_unit_mul_norm_unit normUnit_mul_normUnit\n\n/- warning: normalize_idem -> normalize_idem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (fun (_x : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))))) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1))))))) (normalize.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) _inst_1 _inst_2) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x)\nCase conversion may be inaccurate. Consider using '#align normalize_idem normalize_idemₓ'. -/\ntheorem normalize_idem (x : α) : normalize (normalize x) = normalize x := by simp\n#align normalize_idem normalize_idem\n\n/- warning: normalize_eq_normalize -> normalize_eq_normalize is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a) -> (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) b))\nCase conversion may be inaccurate. Consider using '#align normalize_eq_normalize normalize_eq_normalizeₓ'. -/\ntheorem normalize_eq_normalize {a b : α} (hab : a ∣ b) (hba : b ∣ a) : normalize a = normalize b :=\n  by\n  nontriviality α\n  rcases associated_of_dvd_dvd hab hba with ⟨u, rfl⟩\n  refine' by_cases (by rintro rfl <;> simp only [MulZeroClass.zero_mul]) fun ha : a ≠ 0 => _\n  suffices a * ↑(norm_unit a) = a * ↑u * ↑(norm_unit a) * ↑u⁻¹ by\n    simpa only [normalize_apply, mul_assoc, norm_unit_mul ha u.ne_zero, norm_unit_coe_units]\n  calc\n    a * ↑(norm_unit a) = a * ↑(norm_unit a) * ↑u * ↑u⁻¹ := (Units.mul_inv_cancel_right _ _).symm\n    _ = a * ↑u * ↑(norm_unit a) * ↑u⁻¹ := by rw [mul_right_comm a]\n    \n#align normalize_eq_normalize normalize_eq_normalize\n\n/- warning: normalize_eq_normalize_iff -> normalize_eq_normalize_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α} {y : α}, Iff (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) x) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) y)) (And (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) x y) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) y x))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {x : α} {y : α}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) y)) (And (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) x y) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) y x))\nCase conversion may be inaccurate. Consider using '#align normalize_eq_normalize_iff normalize_eq_normalize_iffₓ'. -/\ntheorem normalize_eq_normalize_iff {x y : α} : normalize x = normalize y ↔ x ∣ y ∧ y ∣ x :=\n  ⟨fun h => ⟨Units.dvd_mul_right.1 ⟨_, h.symm⟩, Units.dvd_mul_right.1 ⟨_, h⟩⟩, fun ⟨hxy, hyx⟩ =>\n    normalize_eq_normalize hxy hyx⟩\n#align normalize_eq_normalize_iff normalize_eq_normalize_iff\n\n/- warning: dvd_antisymm_of_normalize_eq -> dvd_antisymm_of_normalize_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) a) a) -> (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) b) b) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a) -> (Eq.{succ u1} α a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) a) a) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) b) b) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a) -> (Eq.{succ u1} α a b)\nCase conversion may be inaccurate. Consider using '#align dvd_antisymm_of_normalize_eq dvd_antisymm_of_normalize_eqₓ'. -/\ntheorem dvd_antisymm_of_normalize_eq {a b : α} (ha : normalize a = a) (hb : normalize b = b)\n    (hab : a ∣ b) (hba : b ∣ a) : a = b :=\n  ha ▸ hb ▸ normalize_eq_normalize hab hba\n#align dvd_antisymm_of_normalize_eq dvd_antisymm_of_normalize_eq\n\n/- warning: dvd_normalize_iff -> dvd_normalize_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, Iff (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) b)) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, Iff (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) b)) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b)\nCase conversion may be inaccurate. Consider using '#align dvd_normalize_iff dvd_normalize_iffₓ'. -/\n--can be proven by simp\ntheorem dvd_normalize_iff {a b : α} : a ∣ normalize b ↔ a ∣ b :=\n  Units.dvd_mul_right\n#align dvd_normalize_iff dvd_normalize_iff\n\n/- warning: normalize_dvd_iff -> normalize_dvd_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, Iff (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) a) b) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] {a : α} {b : α}, Iff (Dvd.dvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (semigroupDvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (SemigroupWithZero.toSemigroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MonoidWithZero.toSemigroupWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) a) b) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b)\nCase conversion may be inaccurate. Consider using '#align normalize_dvd_iff normalize_dvd_iffₓ'. -/\n--can be proven by simp\ntheorem normalize_dvd_iff {a b : α} : normalize a ∣ b ↔ a ∣ b :=\n  Units.mul_right_dvd\n#align normalize_dvd_iff normalize_dvd_iff\n\nend NormalizationMonoid\n\nnamespace Associates\n\nvariable [CancelCommMonoidWithZero α] [NormalizationMonoid α]\n\nattribute [local instance] Associated.setoid\n\n#print Associates.out /-\n/-- Maps an element of `associates` back to the normalized element of its associate class -/\nprotected def out : Associates α → α :=\n  Quotient.lift (normalize : α → α) fun a b ⟨u, hu⟩ =>\n    hu ▸ normalize_eq_normalize ⟨_, rfl⟩ (Units.mul_right_dvd.2 <| dvd_refl a)\n#align associates.out Associates.out\n-/\n\n/- warning: associates.out_mk -> Associates.out_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) a)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) a)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) a)\nCase conversion may be inaccurate. Consider using '#align associates.out_mk Associates.out_mkₓ'. -/\n@[simp]\ntheorem out_mk (a : α) : (Associates.mk a).out = normalize a :=\n  rfl\n#align associates.out_mk Associates.out_mk\n\n/- warning: associates.out_one -> Associates.out_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (OfNat.mk.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.one.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.hasOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.toOfNat1.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instOneAssociates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align associates.out_one Associates.out_oneₓ'. -/\n@[simp]\ntheorem out_one : (1 : Associates α).out = 1 :=\n  normalize_one\n#align associates.out_one Associates.out_one\n\n/- warning: associates.out_mul -> Associates.out_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (b : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (instHMul.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.hasMul.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) a b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (Associates.out.{u1} α _inst_1 _inst_2 a) (Associates.out.{u1} α _inst_1 _inst_2 b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (b : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (instHMul.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instMulAssociatesToMonoid.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) a b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (Associates.out.{u1} α _inst_1 _inst_2 a) (Associates.out.{u1} α _inst_1 _inst_2 b))\nCase conversion may be inaccurate. Consider using '#align associates.out_mul Associates.out_mulₓ'. -/\ntheorem out_mul (a b : Associates α) : (a * b).out = a.out * b.out :=\n  Quotient.induction_on₂ a b fun a b => by\n    simp only [Associates.quotient_mk_eq_mk, out_mk, mk_mul_mk, normalize.map_mul]\n#align associates.out_mul Associates.out_mul\n\n/- warning: associates.dvd_out_iff -> Associates.dvd_out_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α) (b : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Iff (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (Associates.out.{u1} α _inst_1 _inst_2 b)) (LE.le.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.preorder.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) a) b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α) (b : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Iff (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (Associates.out.{u1} α _inst_1 _inst_2 b)) (LE.le.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instPreorderAssociatesToMonoid.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) a) b)\nCase conversion may be inaccurate. Consider using '#align associates.dvd_out_iff Associates.dvd_out_iffₓ'. -/\ntheorem dvd_out_iff (a : α) (b : Associates α) : a ∣ b.out ↔ Associates.mk a ≤ b :=\n  Quotient.inductionOn b <| by\n    simp [Associates.out_mk, Associates.quotient_mk_eq_mk, mk_le_mk_iff_dvd_iff]\n#align associates.dvd_out_iff Associates.dvd_out_iff\n\n/- warning: associates.out_dvd_iff -> Associates.out_dvd_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α) (b : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Iff (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Associates.out.{u1} α _inst_1 _inst_2 b) a) (LE.le.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.preorder.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) b (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : α) (b : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Iff (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Associates.out.{u1} α _inst_1 _inst_2 b) a) (LE.le.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instPreorderAssociatesToMonoid.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) b (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) a))\nCase conversion may be inaccurate. Consider using '#align associates.out_dvd_iff Associates.out_dvd_iffₓ'. -/\ntheorem out_dvd_iff (a : α) (b : Associates α) : b.out ∣ a ↔ b ≤ Associates.mk a :=\n  Quotient.inductionOn b <| by\n    simp [Associates.out_mk, Associates.quotient_mk_eq_mk, mk_le_mk_iff_dvd_iff]\n#align associates.out_dvd_iff Associates.out_dvd_iff\n\n/- warning: associates.out_top -> Associates.out_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (Top.top.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.hasTop.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1], Eq.{succ u1} α (Associates.out.{u1} α _inst_1 _inst_2 (Top.top.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instTopAssociates.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)) (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))\nCase conversion may be inaccurate. Consider using '#align associates.out_top Associates.out_topₓ'. -/\n@[simp]\ntheorem out_top : (⊤ : Associates α).out = 0 :=\n  normalize_zero\n#align associates.out_top Associates.out_top\n\n/- warning: associates.normalize_out -> Associates.normalize_out is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) (Associates.out.{u1} α _inst_1 _inst_2 a)) (Associates.out.{u1} α _inst_1 _inst_2 a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] (a : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (Associates.out.{u1} α _inst_1 _inst_2 a)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) (Associates.out.{u1} α _inst_1 _inst_2 a)) (Associates.out.{u1} α _inst_1 _inst_2 a)\nCase conversion may be inaccurate. Consider using '#align associates.normalize_out Associates.normalize_outₓ'. -/\n@[simp]\ntheorem normalize_out (a : Associates α) : normalize a.out = a.out :=\n  Quotient.inductionOn a normalize_idem\n#align associates.normalize_out Associates.normalize_out\n\n#print Associates.mk_out /-\n@[simp]\ntheorem mk_out (a : Associates α) : Associates.mk a.out = a :=\n  Quotient.inductionOn a mk_normalize\n#align associates.mk_out Associates.mk_out\n-/\n\n#print Associates.out_injective /-\ntheorem out_injective : Function.Injective (Associates.out : _ → α) :=\n  Function.LeftInverse.injective mk_out\n#align associates.out_injective Associates.out_injective\n-/\n\nend Associates\n\n#print GCDMonoid /-\n/-- GCD monoid: a `cancel_comm_monoid_with_zero` with `gcd` (greatest common divisor) and\n`lcm` (least common multiple) operations, determined up to a unit. The type class focuses on `gcd`\nand we derive the corresponding `lcm` facts from `gcd`.\n-/\n@[protect_proj]\nclass GCDMonoid (α : Type _) [CancelCommMonoidWithZero α] where\n  gcd : α → α → α\n  lcm : α → α → α\n  gcd_dvd_left : ∀ a b, gcd a b ∣ a\n  gcd_dvd_right : ∀ a b, gcd a b ∣ b\n  dvd_gcd : ∀ {a b c}, a ∣ c → a ∣ b → a ∣ gcd c b\n  gcd_mul_lcm : ∀ a b, Associated (gcd a b * lcm a b) (a * b)\n  lcm_zero_left : ∀ a, lcm 0 a = 0\n  lcm_zero_right : ∀ a, lcm a 0 = 0\n#align gcd_monoid GCDMonoid\n-/\n\n#print NormalizedGCDMonoid /-\n/-- Normalized GCD monoid: a `cancel_comm_monoid_with_zero` with normalization and `gcd`\n(greatest common divisor) and `lcm` (least common multiple) operations. In this setting `gcd` and\n`lcm` form a bounded lattice on the associated elements where `gcd` is the infimum, `lcm` is the\nsupremum, `1` is bottom, and `0` is top. The type class focuses on `gcd` and we derive the\ncorresponding `lcm` facts from `gcd`.\n-/\nclass NormalizedGCDMonoid (α : Type _) [CancelCommMonoidWithZero α] extends NormalizationMonoid α,\n  GCDMonoid α where\n  normalize_gcd : ∀ a b, normalize (gcd a b) = gcd a b\n  normalize_lcm : ∀ a b, normalize (lcm a b) = lcm a b\n#align normalized_gcd_monoid NormalizedGCDMonoid\n-/\n\nexport GCDMonoid (gcd lcm gcd_dvd_left gcd_dvd_right dvd_gcd lcm_zero_left lcm_zero_right)\n\nattribute [simp] lcm_zero_left lcm_zero_right\n\nsection GCDMonoid\n\nvariable [CancelCommMonoidWithZero α]\n\n/- warning: normalize_gcd -> normalize_gcd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b)) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align normalize_gcd normalize_gcdₓ'. -/\n@[simp]\ntheorem normalize_gcd [NormalizedGCDMonoid α] : ∀ a b : α, normalize (gcd a b) = gcd a b :=\n  NormalizedGCDMonoid.normalize_gcd\n#align normalize_gcd normalize_gcd\n\n/- warning: gcd_mul_lcm -> gcd_mul_lcm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 a b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 a b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b)\nCase conversion may be inaccurate. Consider using '#align gcd_mul_lcm gcd_mul_lcmₓ'. -/\ntheorem gcd_mul_lcm [GCDMonoid α] : ∀ a b : α, Associated (gcd a b * lcm a b) (a * b) :=\n  GCDMonoid.gcd_mul_lcm\n#align gcd_mul_lcm gcd_mul_lcm\n\nsection Gcd\n\n#print dvd_gcd_iff /-\ntheorem dvd_gcd_iff [GCDMonoid α] (a b c : α) : a ∣ gcd b c ↔ a ∣ b ∧ a ∣ c :=\n  Iff.intro (fun h => ⟨h.trans (gcd_dvd_left _ _), h.trans (gcd_dvd_right _ _)⟩) fun ⟨hab, hac⟩ =>\n    dvd_gcd hab hac\n#align dvd_gcd_iff dvd_gcd_iff\n-/\n\n#print gcd_comm /-\ntheorem gcd_comm [NormalizedGCDMonoid α] (a b : α) : gcd a b = gcd b a :=\n  dvd_antisymm_of_normalize_eq (normalize_gcd _ _) (normalize_gcd _ _)\n    (dvd_gcd (gcd_dvd_right _ _) (gcd_dvd_left _ _))\n    (dvd_gcd (gcd_dvd_right _ _) (gcd_dvd_left _ _))\n#align gcd_comm gcd_comm\n-/\n\n#print gcd_comm' /-\ntheorem gcd_comm' [GCDMonoid α] (a b : α) : Associated (gcd a b) (gcd b a) :=\n  associated_of_dvd_dvd (dvd_gcd (gcd_dvd_right _ _) (gcd_dvd_left _ _))\n    (dvd_gcd (gcd_dvd_right _ _) (gcd_dvd_left _ _))\n#align gcd_comm' gcd_comm'\n-/\n\n#print gcd_assoc /-\ntheorem gcd_assoc [NormalizedGCDMonoid α] (m n k : α) : gcd (gcd m n) k = gcd m (gcd n k) :=\n  dvd_antisymm_of_normalize_eq (normalize_gcd _ _) (normalize_gcd _ _)\n    (dvd_gcd ((gcd_dvd_left (gcd m n) k).trans (gcd_dvd_left m n))\n      (dvd_gcd ((gcd_dvd_left (gcd m n) k).trans (gcd_dvd_right m n)) (gcd_dvd_right (gcd m n) k)))\n    (dvd_gcd\n      (dvd_gcd (gcd_dvd_left m (gcd n k)) ((gcd_dvd_right m (gcd n k)).trans (gcd_dvd_left n k)))\n      ((gcd_dvd_right m (gcd n k)).trans (gcd_dvd_right n k)))\n#align gcd_assoc gcd_assoc\n-/\n\n#print gcd_assoc' /-\ntheorem gcd_assoc' [GCDMonoid α] (m n k : α) : Associated (gcd (gcd m n) k) (gcd m (gcd n k)) :=\n  associated_of_dvd_dvd\n    (dvd_gcd ((gcd_dvd_left (gcd m n) k).trans (gcd_dvd_left m n))\n      (dvd_gcd ((gcd_dvd_left (gcd m n) k).trans (gcd_dvd_right m n)) (gcd_dvd_right (gcd m n) k)))\n    (dvd_gcd\n      (dvd_gcd (gcd_dvd_left m (gcd n k)) ((gcd_dvd_right m (gcd n k)).trans (gcd_dvd_left n k)))\n      ((gcd_dvd_right m (gcd n k)).trans (gcd_dvd_right n k)))\n#align gcd_assoc' gcd_assoc'\n-/\n\ninstance [NormalizedGCDMonoid α] : IsCommutative α gcd :=\n  ⟨gcd_comm⟩\n\ninstance [NormalizedGCDMonoid α] : IsAssociative α gcd :=\n  ⟨gcd_assoc⟩\n\n/- warning: gcd_eq_normalize -> gcd_eq_normalize is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) c) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) c) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) c))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_normalize gcd_eq_normalizeₓ'. -/\ntheorem gcd_eq_normalize [NormalizedGCDMonoid α] {a b c : α} (habc : gcd a b ∣ c)\n    (hcab : c ∣ gcd a b) : gcd a b = normalize c :=\n  normalize_gcd a b ▸ normalize_eq_normalize habc hcab\n#align gcd_eq_normalize gcd_eq_normalize\n\n/- warning: gcd_zero_left -> gcd_zero_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))))) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align gcd_zero_left gcd_zero_leftₓ'. -/\n@[simp]\ntheorem gcd_zero_left [NormalizedGCDMonoid α] (a : α) : gcd 0 a = normalize a :=\n  gcd_eq_normalize (gcd_dvd_right 0 a) (dvd_gcd (dvd_zero _) (dvd_refl a))\n#align gcd_zero_left gcd_zero_left\n\n/- warning: gcd_zero_left' -> gcd_zero_left' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))))) a) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) a) a\nCase conversion may be inaccurate. Consider using '#align gcd_zero_left' gcd_zero_left'ₓ'. -/\ntheorem gcd_zero_left' [GCDMonoid α] (a : α) : Associated (gcd 0 a) a :=\n  associated_of_dvd_dvd (gcd_dvd_right 0 a) (dvd_gcd (dvd_zero _) (dvd_refl a))\n#align gcd_zero_left' gcd_zero_left'\n\n/- warning: gcd_zero_right -> gcd_zero_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align gcd_zero_right gcd_zero_rightₓ'. -/\n@[simp]\ntheorem gcd_zero_right [NormalizedGCDMonoid α] (a : α) : gcd a 0 = normalize a :=\n  gcd_eq_normalize (gcd_dvd_left a 0) (dvd_gcd (dvd_refl a) (dvd_zero _))\n#align gcd_zero_right gcd_zero_right\n\n/- warning: gcd_zero_right' -> gcd_zero_right' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a\nCase conversion may be inaccurate. Consider using '#align gcd_zero_right' gcd_zero_right'ₓ'. -/\ntheorem gcd_zero_right' [GCDMonoid α] (a : α) : Associated (gcd a 0) a :=\n  associated_of_dvd_dvd (gcd_dvd_left a 0) (dvd_gcd (dvd_refl a) (dvd_zero _))\n#align gcd_zero_right' gcd_zero_right'\n\n/- warning: gcd_eq_zero_iff -> gcd_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α), Iff (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (And (Eq.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α), Iff (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (And (Eq.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_zero_iff gcd_eq_zero_iffₓ'. -/\n@[simp]\ntheorem gcd_eq_zero_iff [GCDMonoid α] (a b : α) : gcd a b = 0 ↔ a = 0 ∧ b = 0 :=\n  Iff.intro\n    (fun h => by\n      let ⟨ca, ha⟩ := gcd_dvd_left a b\n      let ⟨cb, hb⟩ := gcd_dvd_right a b\n      rw [h, MulZeroClass.zero_mul] at ha hb <;> exact ⟨ha, hb⟩)\n    fun ⟨ha, hb⟩ => by\n    rw [ha, hb, ← zero_dvd_iff]\n    apply dvd_gcd <;> rfl\n#align gcd_eq_zero_iff gcd_eq_zero_iff\n\n/- warning: gcd_one_left -> gcd_one_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))))) a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_left gcd_one_leftₓ'. -/\n@[simp]\ntheorem gcd_one_left [NormalizedGCDMonoid α] (a : α) : gcd 1 a = 1 :=\n  dvd_antisymm_of_normalize_eq (normalize_gcd _ _) normalize_one (gcd_dvd_left _ _) (one_dvd _)\n#align gcd_one_left gcd_one_left\n\n/- warning: gcd_one_left' -> gcd_one_left' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))))) a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_left' gcd_one_left'ₓ'. -/\n@[simp]\ntheorem gcd_one_left' [GCDMonoid α] (a : α) : Associated (gcd 1 a) 1 :=\n  associated_of_dvd_dvd (gcd_dvd_left _ _) (one_dvd _)\n#align gcd_one_left' gcd_one_left'\n\n/- warning: gcd_one_right -> gcd_one_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_right gcd_one_rightₓ'. -/\n@[simp]\ntheorem gcd_one_right [NormalizedGCDMonoid α] (a : α) : gcd a 1 = 1 :=\n  dvd_antisymm_of_normalize_eq (normalize_gcd _ _) normalize_one (gcd_dvd_right _ _) (one_dvd _)\n#align gcd_one_right gcd_one_right\n\n/- warning: gcd_one_right' -> gcd_one_right' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_right' gcd_one_right'ₓ'. -/\n@[simp]\ntheorem gcd_one_right' [GCDMonoid α] (a : α) : Associated (gcd a 1) 1 :=\n  associated_of_dvd_dvd (gcd_dvd_right _ _) (one_dvd _)\n#align gcd_one_right' gcd_one_right'\n\n#print gcd_dvd_gcd /-\ntheorem gcd_dvd_gcd [GCDMonoid α] {a b c d : α} (hab : a ∣ b) (hcd : c ∣ d) : gcd a c ∣ gcd b d :=\n  dvd_gcd ((gcd_dvd_left _ _).trans hab) ((gcd_dvd_right _ _).trans hcd)\n#align gcd_dvd_gcd gcd_dvd_gcd\n-/\n\n/- warning: gcd_same -> gcd_same is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align gcd_same gcd_sameₓ'. -/\n@[simp]\ntheorem gcd_same [NormalizedGCDMonoid α] (a : α) : gcd a a = normalize a :=\n  gcd_eq_normalize (gcd_dvd_left _ _) (dvd_gcd (dvd_refl a) (dvd_refl a))\n#align gcd_same gcd_same\n\n/- warning: gcd_mul_left -> gcd_mul_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) α ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MulZeroClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MulZeroOneClass.toMulZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) _inst_1)))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_left gcd_mul_leftₓ'. -/\n@[simp]\ntheorem gcd_mul_left [NormalizedGCDMonoid α] (a b c : α) :\n    gcd (a * b) (a * c) = normalize a * gcd b c :=\n  by_cases (by rintro rfl <;> simp only [MulZeroClass.zero_mul, gcd_zero_left, normalize_zero])\n    fun ha : a ≠ 0 =>\n    suffices gcd (a * b) (a * c) = normalize (a * gcd b c) by\n      simpa only [normalize.map_mul, normalize_gcd]\n    let ⟨d, Eq⟩ := dvd_gcd (dvd_mul_right a b) (dvd_mul_right a c)\n    gcd_eq_normalize\n      (Eq.symm ▸ mul_dvd_mul_left a <|\n        show d ∣ gcd b c from\n          dvd_gcd ((mul_dvd_mul_iff_left ha).1 <| Eq ▸ gcd_dvd_left _ _)\n            ((mul_dvd_mul_iff_left ha).1 <| Eq ▸ gcd_dvd_right _ _))\n      (dvd_gcd (mul_dvd_mul_left a <| gcd_dvd_left _ _) (mul_dvd_mul_left a <| gcd_dvd_right _ _))\n#align gcd_mul_left gcd_mul_left\n\n/- warning: gcd_mul_left' -> gcd_mul_left' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 b c))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_left' gcd_mul_left'ₓ'. -/\ntheorem gcd_mul_left' [GCDMonoid α] (a b c : α) : Associated (gcd (a * b) (a * c)) (a * gcd b c) :=\n  by\n  obtain rfl | ha := eq_or_ne a 0\n  · simp only [MulZeroClass.zero_mul, gcd_zero_left']\n  obtain ⟨d, eq⟩ := dvd_gcd (dvd_mul_right a b) (dvd_mul_right a c)\n  apply associated_of_dvd_dvd\n  · rw [Eq]\n    apply mul_dvd_mul_left\n    exact\n      dvd_gcd ((mul_dvd_mul_iff_left ha).1 <| Eq ▸ gcd_dvd_left _ _)\n        ((mul_dvd_mul_iff_left ha).1 <| Eq ▸ gcd_dvd_right _ _)\n  · exact dvd_gcd (mul_dvd_mul_left a <| gcd_dvd_left _ _) (mul_dvd_mul_left a <| gcd_dvd_right _ _)\n#align gcd_mul_left' gcd_mul_left'\n\n/- warning: gcd_mul_right -> gcd_mul_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) b c) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} α ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) b c) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_right gcd_mul_rightₓ'. -/\n@[simp]\ntheorem gcd_mul_right [NormalizedGCDMonoid α] (a b c : α) :\n    gcd (b * a) (c * a) = gcd b c * normalize a := by simp only [mul_comm, gcd_mul_left]\n#align gcd_mul_right gcd_mul_right\n\n/- warning: gcd_mul_right' -> gcd_mul_right' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 b c) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 b c) a)\nCase conversion may be inaccurate. Consider using '#align gcd_mul_right' gcd_mul_right'ₓ'. -/\n@[simp]\ntheorem gcd_mul_right' [GCDMonoid α] (a b c : α) : Associated (gcd (b * a) (c * a)) (gcd b c * a) :=\n  by simp only [mul_comm, gcd_mul_left']\n#align gcd_mul_right' gcd_mul_right'\n\n/- warning: gcd_eq_left_iff -> gcd_eq_left_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) a) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) a) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_left_iff gcd_eq_left_iffₓ'. -/\ntheorem gcd_eq_left_iff [NormalizedGCDMonoid α] (a b : α) (h : normalize a = a) :\n    gcd a b = a ↔ a ∣ b :=\n  Iff.intro (fun eq => Eq ▸ gcd_dvd_right _ _) fun hab =>\n    dvd_antisymm_of_normalize_eq (normalize_gcd _ _) h (gcd_dvd_left _ _) (dvd_gcd (dvd_refl a) hab)\n#align gcd_eq_left_iff gcd_eq_left_iff\n\n/- warning: gcd_eq_right_iff -> gcd_eq_right_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) b) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) b) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_right_iff gcd_eq_right_iffₓ'. -/\ntheorem gcd_eq_right_iff [NormalizedGCDMonoid α] (a b : α) (h : normalize b = b) :\n    gcd a b = b ↔ b ∣ a := by simpa only [gcd_comm a b] using gcd_eq_left_iff b a h\n#align gcd_eq_right_iff gcd_eq_right_iff\n\n/- warning: gcd_dvd_gcd_mul_left -> gcd_dvd_gcd_mul_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k m) n)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k m) n)\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_left gcd_dvd_gcd_mul_leftₓ'. -/\ntheorem gcd_dvd_gcd_mul_left [GCDMonoid α] (m n k : α) : gcd m n ∣ gcd (k * m) n :=\n  gcd_dvd_gcd (dvd_mul_left _ _) dvd_rfl\n#align gcd_dvd_gcd_mul_left gcd_dvd_gcd_mul_left\n\n/- warning: gcd_dvd_gcd_mul_right -> gcd_dvd_gcd_mul_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m k) n)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m k) n)\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_right gcd_dvd_gcd_mul_rightₓ'. -/\ntheorem gcd_dvd_gcd_mul_right [GCDMonoid α] (m n k : α) : gcd m n ∣ gcd (m * k) n :=\n  gcd_dvd_gcd (dvd_mul_right _ _) dvd_rfl\n#align gcd_dvd_gcd_mul_right gcd_dvd_gcd_mul_right\n\n/- warning: gcd_dvd_gcd_mul_left_right -> gcd_dvd_gcd_mul_left_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k n))\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_left_right gcd_dvd_gcd_mul_left_rightₓ'. -/\ntheorem gcd_dvd_gcd_mul_left_right [GCDMonoid α] (m n k : α) : gcd m n ∣ gcd m (k * n) :=\n  gcd_dvd_gcd dvd_rfl (dvd_mul_left _ _)\n#align gcd_dvd_gcd_mul_left_right gcd_dvd_gcd_mul_left_right\n\n/- warning: gcd_dvd_gcd_mul_right_right -> gcd_dvd_gcd_mul_right_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) n k))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) n k))\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_right_right gcd_dvd_gcd_mul_right_rightₓ'. -/\ntheorem gcd_dvd_gcd_mul_right_right [GCDMonoid α] (m n k : α) : gcd m n ∣ gcd m (n * k) :=\n  gcd_dvd_gcd dvd_rfl (dvd_mul_right _ _)\n#align gcd_dvd_gcd_mul_right_right gcd_dvd_gcd_mul_right_right\n\n#print Associated.gcd_eq_left /-\ntheorem Associated.gcd_eq_left [NormalizedGCDMonoid α] {m n : α} (h : Associated m n) (k : α) :\n    gcd m k = gcd n k :=\n  dvd_antisymm_of_normalize_eq (normalize_gcd _ _) (normalize_gcd _ _) (gcd_dvd_gcd h.Dvd dvd_rfl)\n    (gcd_dvd_gcd h.symm.Dvd dvd_rfl)\n#align associated.gcd_eq_left Associated.gcd_eq_left\n-/\n\n#print Associated.gcd_eq_right /-\ntheorem Associated.gcd_eq_right [NormalizedGCDMonoid α] {m n : α} (h : Associated m n) (k : α) :\n    gcd k m = gcd k n :=\n  dvd_antisymm_of_normalize_eq (normalize_gcd _ _) (normalize_gcd _ _) (gcd_dvd_gcd dvd_rfl h.Dvd)\n    (gcd_dvd_gcd dvd_rfl h.symm.Dvd)\n#align associated.gcd_eq_right Associated.gcd_eq_right\n-/\n\n/- warning: dvd_gcd_mul_of_dvd_mul -> dvd_gcd_mul_of_dvd_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {m : α} {n : α} {k : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k m) n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {m : α} {n : α} {k : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k m) n))\nCase conversion may be inaccurate. Consider using '#align dvd_gcd_mul_of_dvd_mul dvd_gcd_mul_of_dvd_mulₓ'. -/\ntheorem dvd_gcd_mul_of_dvd_mul [GCDMonoid α] {m n k : α} (H : k ∣ m * n) : k ∣ gcd k m * n :=\n  (dvd_gcd (dvd_mul_right _ n) H).trans (gcd_mul_right' n k m).Dvd\n#align dvd_gcd_mul_of_dvd_mul dvd_gcd_mul_of_dvd_mul\n\n/- warning: dvd_mul_gcd_of_dvd_mul -> dvd_mul_gcd_of_dvd_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {m : α} {n : α} {k : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {m : α} {n : α} {k : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k n)))\nCase conversion may be inaccurate. Consider using '#align dvd_mul_gcd_of_dvd_mul dvd_mul_gcd_of_dvd_mulₓ'. -/\ntheorem dvd_mul_gcd_of_dvd_mul [GCDMonoid α] {m n k : α} (H : k ∣ m * n) : k ∣ m * gcd k n :=\n  by\n  rw [mul_comm] at H⊢\n  exact dvd_gcd_mul_of_dvd_mul H\n#align dvd_mul_gcd_of_dvd_mul dvd_mul_gcd_of_dvd_mul\n\n/- warning: exists_dvd_and_dvd_of_dvd_mul -> exists_dvd_and_dvd_of_dvd_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {m : α} {n : α} {k : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) -> (Exists.{succ u1} α (fun (d₁ : α) => Exists.{succ u1} α (fun (d₂ : α) => And (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ m) (And (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₂ n) (Eq.{succ u1} α k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) d₁ d₂))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {m : α} {n : α} {k : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) -> (Exists.{succ u1} α (fun (d₁ : α) => Exists.{succ u1} α (fun (d₂ : α) => And (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ m) (And (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₂ n) (Eq.{succ u1} α k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) d₁ d₂))))))\nCase conversion may be inaccurate. Consider using '#align exists_dvd_and_dvd_of_dvd_mul exists_dvd_and_dvd_of_dvd_mulₓ'. -/\n/-- Represent a divisor of `m * n` as a product of a divisor of `m` and a divisor of `n`.\n\nIn other words, the nonzero elements of a `gcd_monoid` form a decomposition monoid\n(more widely known as a pre-Schreier domain in the context of rings).\n\nNote: In general, this representation is highly non-unique.\n\nSee `nat.prod_dvd_and_dvd_of_dvd_prod` for a constructive version on `ℕ`.  -/\ntheorem exists_dvd_and_dvd_of_dvd_mul [GCDMonoid α] {m n k : α} (H : k ∣ m * n) :\n    ∃ d₁ d₂, d₁ ∣ m ∧ d₂ ∣ n ∧ k = d₁ * d₂ :=\n  by\n  by_cases h0 : gcd k m = 0\n  · rw [gcd_eq_zero_iff] at h0\n    rcases h0 with ⟨rfl, rfl⟩\n    refine' ⟨0, n, dvd_refl 0, dvd_refl n, _⟩\n    simp\n  · obtain ⟨a, ha⟩ := gcd_dvd_left k m\n    refine' ⟨gcd k m, a, gcd_dvd_right _ _, _, ha⟩\n    suffices h : gcd k m * a ∣ gcd k m * n\n    · cases' h with b hb\n      use b\n      rw [mul_assoc] at hb\n      apply mul_left_cancel₀ h0 hb\n    rw [← ha]\n    exact dvd_gcd_mul_of_dvd_mul H\n#align exists_dvd_and_dvd_of_dvd_mul exists_dvd_and_dvd_of_dvd_mul\n\n/- warning: dvd_mul -> dvd_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {k : α} {m : α} {n : α}, Iff (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) (Exists.{succ u1} α (fun (d₁ : α) => Exists.{succ u1} α (fun (d₂ : α) => And (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ m) (And (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₂ n) (Eq.{succ u1} α k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) d₁ d₂))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {k : α} {m : α} {n : α}, Iff (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) (Exists.{succ u1} α (fun (d₁ : α) => Exists.{succ u1} α (fun (d₂ : α) => And (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ m) (And (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₂ n) (Eq.{succ u1} α k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) d₁ d₂))))))\nCase conversion may be inaccurate. Consider using '#align dvd_mul dvd_mulₓ'. -/\ntheorem dvd_mul [GCDMonoid α] {k m n : α} : k ∣ m * n ↔ ∃ d₁ d₂, d₁ ∣ m ∧ d₂ ∣ n ∧ k = d₁ * d₂ :=\n  by\n  refine' ⟨exists_dvd_and_dvd_of_dvd_mul, _⟩\n  rintro ⟨d₁, d₂, hy, hz, rfl⟩\n  exact mul_dvd_mul hy hz\n#align dvd_mul dvd_mul\n\n/- warning: gcd_mul_dvd_mul_gcd -> gcd_mul_dvd_mul_gcd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (k : α) (m : α) (n : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k m) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (k : α) (m : α) (n : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m n)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k m) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 k n))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_dvd_mul_gcd gcd_mul_dvd_mul_gcdₓ'. -/\ntheorem gcd_mul_dvd_mul_gcd [GCDMonoid α] (k m n : α) : gcd k (m * n) ∣ gcd k m * gcd k n :=\n  by\n  obtain ⟨m', n', hm', hn', h⟩ := exists_dvd_and_dvd_of_dvd_mul (gcd_dvd_right k (m * n))\n  replace h : gcd k (m * n) = m' * n' := h\n  rw [h]\n  have hm'n' : m' * n' ∣ k := h ▸ gcd_dvd_left _ _\n  apply mul_dvd_mul\n  · have hm'k : m' ∣ k := (dvd_mul_right m' n').trans hm'n'\n    exact dvd_gcd hm'k hm'\n  · have hn'k : n' ∣ k := (dvd_mul_left n' m').trans hm'n'\n    exact dvd_gcd hn'k hn'\n#align gcd_mul_dvd_mul_gcd gcd_mul_dvd_mul_gcd\n\n#print gcd_pow_right_dvd_pow_gcd /-\ntheorem gcd_pow_right_dvd_pow_gcd [GCDMonoid α] {a b : α} {k : ℕ} : gcd a (b ^ k) ∣ gcd a b ^ k :=\n  by\n  by_cases hg : gcd a b = 0\n  · rw [gcd_eq_zero_iff] at hg\n    rcases hg with ⟨rfl, rfl⟩\n    exact\n      (gcd_zero_left' (0 ^ k : α)).Dvd.trans\n        (pow_dvd_pow_of_dvd (gcd_zero_left' (0 : α)).symm.Dvd _)\n  · induction' k with k hk\n    · simp only [pow_zero]\n      exact (gcd_one_right' a).Dvd\n    rw [pow_succ, pow_succ]\n    trans gcd a b * gcd a (b ^ k)\n    apply gcd_mul_dvd_mul_gcd a b (b ^ k)\n    exact (mul_dvd_mul_iff_left hg).mpr hk\n#align gcd_pow_right_dvd_pow_gcd gcd_pow_right_dvd_pow_gcd\n-/\n\n#print gcd_pow_left_dvd_pow_gcd /-\ntheorem gcd_pow_left_dvd_pow_gcd [GCDMonoid α] {a b : α} {k : ℕ} : gcd (a ^ k) b ∣ gcd a b ^ k :=\n  calc\n    gcd (a ^ k) b ∣ gcd b (a ^ k) := (gcd_comm' _ _).Dvd\n    _ ∣ gcd b a ^ k := gcd_pow_right_dvd_pow_gcd\n    _ ∣ gcd a b ^ k := pow_dvd_pow_of_dvd (gcd_comm' _ _).Dvd _\n    \n#align gcd_pow_left_dvd_pow_gcd gcd_pow_left_dvd_pow_gcd\n-/\n\n/- warning: pow_dvd_of_mul_eq_pow -> pow_dvd_of_mul_eq_pow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α} {d₁ : α} {d₂ : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) -> (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c k)) -> (Eq.{succ u1} α c (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) d₁ d₂)) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ a) -> (And (Ne.{succ u1} α (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ k) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ k) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α} {d₁ : α} {d₂ : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) -> (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c k)) -> (Eq.{succ u1} α c (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) d₁ d₂)) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ a) -> (And (Ne.{succ u1} α (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ k) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d₁ k) a)))\nCase conversion may be inaccurate. Consider using '#align pow_dvd_of_mul_eq_pow pow_dvd_of_mul_eq_powₓ'. -/\ntheorem pow_dvd_of_mul_eq_pow [GCDMonoid α] {a b c d₁ d₂ : α} (ha : a ≠ 0) (hab : IsUnit (gcd a b))\n    {k : ℕ} (h : a * b = c ^ k) (hc : c = d₁ * d₂) (hd₁ : d₁ ∣ a) : d₁ ^ k ≠ 0 ∧ d₁ ^ k ∣ a :=\n  by\n  have h1 : IsUnit (gcd (d₁ ^ k) b) := by\n    apply isUnit_of_dvd_one\n    trans gcd d₁ b ^ k\n    · exact gcd_pow_left_dvd_pow_gcd\n    · apply IsUnit.dvd\n      apply IsUnit.pow\n      apply isUnit_of_dvd_one\n      apply dvd_trans _ hab.dvd\n      apply gcd_dvd_gcd hd₁ (dvd_refl b)\n  have h2 : d₁ ^ k ∣ a * b := by\n    use d₂ ^ k\n    rw [h, hc]\n    exact mul_pow d₁ d₂ k\n  rw [mul_comm] at h2\n  have h3 : d₁ ^ k ∣ a := by\n    apply (dvd_gcd_mul_of_dvd_mul h2).trans\n    rw [IsUnit.mul_left_dvd _ _ _ h1]\n  have h4 : d₁ ^ k ≠ 0 := by\n    intro hdk\n    rw [hdk] at h3\n    apply absurd (zero_dvd_iff.mp h3) ha\n  exact ⟨h4, h3⟩\n#align pow_dvd_of_mul_eq_pow pow_dvd_of_mul_eq_pow\n\n/- warning: exists_associated_pow_of_mul_eq_pow -> exists_associated_pow_of_mul_eq_pow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α}, (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c k)) -> (Exists.{succ u1} α (fun (d : α) => Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d k) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α}, (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c k)) -> (Exists.{succ u1} α (fun (d : α) => Associated.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d k) a)))\nCase conversion may be inaccurate. Consider using '#align exists_associated_pow_of_mul_eq_pow exists_associated_pow_of_mul_eq_powₓ'. -/\ntheorem exists_associated_pow_of_mul_eq_pow [GCDMonoid α] {a b c : α} (hab : IsUnit (gcd a b))\n    {k : ℕ} (h : a * b = c ^ k) : ∃ d : α, Associated (d ^ k) a :=\n  by\n  cases subsingleton_or_nontrivial α\n  · use 0\n    rw [Subsingleton.elim a (0 ^ k)]\n  by_cases ha : a = 0\n  · use 0\n    rw [ha]\n    obtain rfl | hk := k.eq_zero_or_pos\n    · exfalso\n      revert h\n      rw [ha, MulZeroClass.zero_mul, pow_zero]\n      apply zero_ne_one\n    · rw [zero_pow hk]\n  by_cases hb : b = 0\n  · use 1\n    rw [one_pow]\n    apply (associated_one_iff_is_unit.mpr hab).symm.trans\n    rw [hb]\n    exact gcd_zero_right' a\n  obtain rfl | hk := k.eq_zero_or_pos\n  · use 1\n    rw [pow_zero] at h⊢\n    use Units.mkOfMulEqOne _ _ h\n    rw [Units.val_mkOfMulEqOne, one_mul]\n  have hc : c ∣ a * b := by\n    rw [h]\n    exact dvd_pow_self _ hk.ne'\n  obtain ⟨d₁, d₂, hd₁, hd₂, hc⟩ := exists_dvd_and_dvd_of_dvd_mul hc\n  use d₁\n  obtain ⟨h0₁, ⟨a', ha'⟩⟩ := pow_dvd_of_mul_eq_pow ha hab h hc hd₁\n  rw [mul_comm] at h hc\n  rw [(gcd_comm' a b).isUnit_iff] at hab\n  obtain ⟨h0₂, ⟨b', hb'⟩⟩ := pow_dvd_of_mul_eq_pow hb hab h hc hd₂\n  rw [ha', hb', hc, mul_pow] at h\n  have h' : a' * b' = 1 := by\n    apply (mul_right_inj' h0₁).mp\n    rw [mul_one]\n    apply (mul_right_inj' h0₂).mp\n    rw [← h]\n    rw [mul_assoc, mul_comm a', ← mul_assoc _ b', ← mul_assoc b', mul_comm b']\n  use Units.mkOfMulEqOne _ _ h'\n  rw [Units.val_mkOfMulEqOne, ha']\n#align exists_associated_pow_of_mul_eq_pow exists_associated_pow_of_mul_eq_pow\n\n/- warning: exists_eq_pow_of_mul_eq_pow -> exists_eq_pow_of_mul_eq_pow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] [_inst_3 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))] {a : α} {b : α} {c : α}, (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c k)) -> (Exists.{succ u1} α (fun (d : α) => Eq.{succ u1} α a (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d k))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] [_inst_3 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))] {a : α} {b : α} {c : α}, (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (GCDMonoid.gcd.{u1} α _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c k)) -> (Exists.{succ u1} α (fun (d : α) => Eq.{succ u1} α a (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) d k))))\nCase conversion may be inaccurate. Consider using '#align exists_eq_pow_of_mul_eq_pow exists_eq_pow_of_mul_eq_powₓ'. -/\ntheorem exists_eq_pow_of_mul_eq_pow [GCDMonoid α] [Unique αˣ] {a b c : α} (hab : IsUnit (gcd a b))\n    {k : ℕ} (h : a * b = c ^ k) : ∃ d : α, a = d ^ k :=\n  let ⟨d, hd⟩ := exists_associated_pow_of_mul_eq_pow hab h\n  ⟨d, (associated_iff_eq.mp hd).symm⟩\n#align exists_eq_pow_of_mul_eq_pow exists_eq_pow_of_mul_eq_pow\n\n/- warning: gcd_greatest -> gcd_greatest is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} α] [_inst_3 : NormalizedGCDMonoid.{u1} α _inst_2] {a : α} {b : α} {d : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) d a) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) d b) -> (forall (e : α), (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) e a) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) e b) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) e d)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_2 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_2 _inst_3) a b) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) (normalize.{u1} α _inst_2 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_2 _inst_3)) d))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} α] [_inst_3 : NormalizedGCDMonoid.{u1} α _inst_2] {a : α} {b : α} {d : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) d a) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) d b) -> (forall (e : α), (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) e a) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) e b) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) e d)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_2 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_2 _inst_3) a b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))))) (normalize.{u1} α _inst_2 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_2 _inst_3)) d))\nCase conversion may be inaccurate. Consider using '#align gcd_greatest gcd_greatestₓ'. -/\ntheorem gcd_greatest {α : Type _} [CancelCommMonoidWithZero α] [NormalizedGCDMonoid α] {a b d : α}\n    (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : α, e ∣ a → e ∣ b → e ∣ d) :\n    GCDMonoid.gcd a b = normalize d :=\n  haveI h := hd _ (GCDMonoid.gcd_dvd_left a b) (GCDMonoid.gcd_dvd_right a b)\n  gcd_eq_normalize h (GCDMonoid.dvd_gcd hda hdb)\n#align gcd_greatest gcd_greatest\n\n#print gcd_greatest_associated /-\ntheorem gcd_greatest_associated {α : Type _} [CancelCommMonoidWithZero α] [GCDMonoid α] {a b d : α}\n    (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : α, e ∣ a → e ∣ b → e ∣ d) :\n    Associated d (GCDMonoid.gcd a b) :=\n  haveI h := hd _ (GCDMonoid.gcd_dvd_left a b) (GCDMonoid.gcd_dvd_right a b)\n  associated_of_dvd_dvd (GCDMonoid.dvd_gcd hda hdb) h\n#align gcd_greatest_associated gcd_greatest_associated\n-/\n\n/- warning: is_unit_gcd_of_eq_mul_gcd -> isUnit_gcd_of_eq_mul_gcd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} α] [_inst_3 : GCDMonoid.{u1} α _inst_2] {x : α} {y : α} {x' : α} {y' : α}, (Eq.{succ u1} α x (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) x')) -> (Eq.{succ u1} α y (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) y')) -> (Ne.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))))))) -> (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x' y'))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} α] [_inst_3 : GCDMonoid.{u1} α _inst_2] {x : α} {y : α} {x' : α} {y' : α}, (Eq.{succ u1} α x (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) x')) -> (Eq.{succ u1} α y (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) y')) -> (Ne.{succ u1} α (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))))) -> (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x' y'))\nCase conversion may be inaccurate. Consider using '#align is_unit_gcd_of_eq_mul_gcd isUnit_gcd_of_eq_mul_gcdₓ'. -/\ntheorem isUnit_gcd_of_eq_mul_gcd {α : Type _} [CancelCommMonoidWithZero α] [GCDMonoid α]\n    {x y x' y' : α} (ex : x = gcd x y * x') (ey : y = gcd x y * y') (h : gcd x y ≠ 0) :\n    IsUnit (gcd x' y') := by\n  rw [← associated_one_iff_isUnit]\n  refine' Associated.of_mul_left _ (Associated.refl <| gcd x y) h\n  convert(gcd_mul_left' _ _ _).symm using 1\n  rw [← ex, ← ey, mul_one]\n#align is_unit_gcd_of_eq_mul_gcd isUnit_gcd_of_eq_mul_gcd\n\n/- warning: extract_gcd -> extract_gcd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} α] [_inst_3 : GCDMonoid.{u1} α _inst_2] (x : α) (y : α), Exists.{succ u1} α (fun (x' : α) => Exists.{succ u1} α (fun (y' : α) => And (Eq.{succ u1} α x (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) x')) (And (Eq.{succ u1} α y (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) y')) (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x' y')))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} α] [_inst_3 : GCDMonoid.{u1} α _inst_2] (x : α) (y : α), Exists.{succ u1} α (fun (x' : α) => Exists.{succ u1} α (fun (y' : α) => And (Eq.{succ u1} α x (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) x')) (And (Eq.{succ u1} α y (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2)))))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x y) y')) (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_2))) (GCDMonoid.gcd.{u1} α _inst_2 _inst_3 x' y')))))\nCase conversion may be inaccurate. Consider using '#align extract_gcd extract_gcdₓ'. -/\ntheorem extract_gcd {α : Type _} [CancelCommMonoidWithZero α] [GCDMonoid α] (x y : α) :\n    ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y') :=\n  by\n  by_cases h : gcd x y = 0\n  · obtain ⟨rfl, rfl⟩ := (gcd_eq_zero_iff x y).1 h\n    simp_rw [← associated_one_iff_isUnit]\n    exact\n      ⟨1, 1, by rw [h, MulZeroClass.zero_mul], by rw [h, MulZeroClass.zero_mul], gcd_one_left' 1⟩\n  obtain ⟨x', ex⟩ := gcd_dvd_left x y\n  obtain ⟨y', ey⟩ := gcd_dvd_right x y\n  exact ⟨x', y', ex, ey, isUnit_gcd_of_eq_mul_gcd ex ey h⟩\n#align extract_gcd extract_gcd\n\nend Gcd\n\nsection Lcm\n\n#print lcm_dvd_iff /-\ntheorem lcm_dvd_iff [GCDMonoid α] {a b c : α} : lcm a b ∣ c ↔ a ∣ c ∧ b ∣ c :=\n  by\n  by_cases this : a = 0 ∨ b = 0\n  ·\n    rcases this with (rfl | rfl) <;>\n      simp (config := { contextual := true }) only [iff_def, lcm_zero_left, lcm_zero_right,\n        zero_dvd_iff, dvd_zero, eq_self_iff_true, and_true_iff, imp_true_iff]\n  · obtain ⟨h1, h2⟩ := not_or.1 this\n    have h : gcd a b ≠ 0 := fun H => h1 ((gcd_eq_zero_iff _ _).1 H).1\n    rw [← mul_dvd_mul_iff_left h, (gcd_mul_lcm a b).dvd_iff_dvd_left, ←\n      (gcd_mul_right' c a b).dvd_iff_dvd_right, dvd_gcd_iff, mul_comm b c, mul_dvd_mul_iff_left h1,\n      mul_dvd_mul_iff_right h2, and_comm']\n#align lcm_dvd_iff lcm_dvd_iff\n-/\n\n#print dvd_lcm_left /-\ntheorem dvd_lcm_left [GCDMonoid α] (a b : α) : a ∣ lcm a b :=\n  (lcm_dvd_iff.1 (dvd_refl (lcm a b))).1\n#align dvd_lcm_left dvd_lcm_left\n-/\n\n#print dvd_lcm_right /-\ntheorem dvd_lcm_right [GCDMonoid α] (a b : α) : b ∣ lcm a b :=\n  (lcm_dvd_iff.1 (dvd_refl (lcm a b))).2\n#align dvd_lcm_right dvd_lcm_right\n-/\n\n#print lcm_dvd /-\ntheorem lcm_dvd [GCDMonoid α] {a b c : α} (hab : a ∣ b) (hcb : c ∣ b) : lcm a c ∣ b :=\n  lcm_dvd_iff.2 ⟨hab, hcb⟩\n#align lcm_dvd lcm_dvd\n-/\n\n/- warning: lcm_eq_zero_iff -> lcm_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α), Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (Or (Eq.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (a : α) (b : α), Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Or (Eq.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_zero_iff lcm_eq_zero_iffₓ'. -/\n@[simp]\ntheorem lcm_eq_zero_iff [GCDMonoid α] (a b : α) : lcm a b = 0 ↔ a = 0 ∨ b = 0 :=\n  Iff.intro\n    (fun h : lcm a b = 0 =>\n      by\n      have : Associated (a * b) 0 :=\n        (gcd_mul_lcm a b).symm.trans <| by rw [h, MulZeroClass.mul_zero]\n      simpa only [associated_zero_iff_eq_zero, mul_eq_zero] )\n    (by rintro (rfl | rfl) <;> [apply lcm_zero_left, apply lcm_zero_right])\n#align lcm_eq_zero_iff lcm_eq_zero_iff\n\n/- warning: normalize_lcm -> normalize_lcm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b)) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align normalize_lcm normalize_lcmₓ'. -/\n@[simp]\ntheorem normalize_lcm [NormalizedGCDMonoid α] (a b : α) : normalize (lcm a b) = lcm a b :=\n  NormalizedGCDMonoid.normalize_lcm a b\n#align normalize_lcm normalize_lcm\n\n#print lcm_comm /-\ntheorem lcm_comm [NormalizedGCDMonoid α] (a b : α) : lcm a b = lcm b a :=\n  dvd_antisymm_of_normalize_eq (normalize_lcm _ _) (normalize_lcm _ _)\n    (lcm_dvd (dvd_lcm_right _ _) (dvd_lcm_left _ _))\n    (lcm_dvd (dvd_lcm_right _ _) (dvd_lcm_left _ _))\n#align lcm_comm lcm_comm\n-/\n\n#print lcm_comm' /-\ntheorem lcm_comm' [GCDMonoid α] (a b : α) : Associated (lcm a b) (lcm b a) :=\n  associated_of_dvd_dvd (lcm_dvd (dvd_lcm_right _ _) (dvd_lcm_left _ _))\n    (lcm_dvd (dvd_lcm_right _ _) (dvd_lcm_left _ _))\n#align lcm_comm' lcm_comm'\n-/\n\n#print lcm_assoc /-\ntheorem lcm_assoc [NormalizedGCDMonoid α] (m n k : α) : lcm (lcm m n) k = lcm m (lcm n k) :=\n  dvd_antisymm_of_normalize_eq (normalize_lcm _ _) (normalize_lcm _ _)\n    (lcm_dvd (lcm_dvd (dvd_lcm_left _ _) ((dvd_lcm_left _ _).trans (dvd_lcm_right _ _)))\n      ((dvd_lcm_right _ _).trans (dvd_lcm_right _ _)))\n    (lcm_dvd ((dvd_lcm_left _ _).trans (dvd_lcm_left _ _))\n      (lcm_dvd ((dvd_lcm_right _ _).trans (dvd_lcm_left _ _)) (dvd_lcm_right _ _)))\n#align lcm_assoc lcm_assoc\n-/\n\n#print lcm_assoc' /-\ntheorem lcm_assoc' [GCDMonoid α] (m n k : α) : Associated (lcm (lcm m n) k) (lcm m (lcm n k)) :=\n  associated_of_dvd_dvd\n    (lcm_dvd (lcm_dvd (dvd_lcm_left _ _) ((dvd_lcm_left _ _).trans (dvd_lcm_right _ _)))\n      ((dvd_lcm_right _ _).trans (dvd_lcm_right _ _)))\n    (lcm_dvd ((dvd_lcm_left _ _).trans (dvd_lcm_left _ _))\n      (lcm_dvd ((dvd_lcm_right _ _).trans (dvd_lcm_left _ _)) (dvd_lcm_right _ _)))\n#align lcm_assoc' lcm_assoc'\n-/\n\ninstance [NormalizedGCDMonoid α] : IsCommutative α lcm :=\n  ⟨lcm_comm⟩\n\ninstance [NormalizedGCDMonoid α] : IsAssociative α lcm :=\n  ⟨lcm_assoc⟩\n\n/- warning: lcm_eq_normalize -> lcm_eq_normalize is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) c) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b)) -> (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] {a : α} {b : α} {c : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) c) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b)) -> (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) c))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_normalize lcm_eq_normalizeₓ'. -/\ntheorem lcm_eq_normalize [NormalizedGCDMonoid α] {a b c : α} (habc : lcm a b ∣ c)\n    (hcab : c ∣ lcm a b) : lcm a b = normalize c :=\n  normalize_lcm a b ▸ normalize_eq_normalize habc hcab\n#align lcm_eq_normalize lcm_eq_normalize\n\n#print lcm_dvd_lcm /-\ntheorem lcm_dvd_lcm [GCDMonoid α] {a b c d : α} (hab : a ∣ b) (hcd : c ∣ d) : lcm a c ∣ lcm b d :=\n  lcm_dvd (hab.trans (dvd_lcm_left _ _)) (hcd.trans (dvd_lcm_right _ _))\n#align lcm_dvd_lcm lcm_dvd_lcm\n-/\n\n/- warning: lcm_units_coe_left -> lcm_units_coe_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (u : Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (coeBase.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (Units.hasCoe.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) u) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (u : Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_units_coe_left lcm_units_coe_leftₓ'. -/\n@[simp]\ntheorem lcm_units_coe_left [NormalizedGCDMonoid α] (u : αˣ) (a : α) : lcm (↑u) a = normalize a :=\n  lcm_eq_normalize (lcm_dvd Units.coe_dvd dvd_rfl) (dvd_lcm_right _ _)\n#align lcm_units_coe_left lcm_units_coe_left\n\n/- warning: lcm_units_coe_right -> lcm_units_coe_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (u : Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (coeBase.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (Units.hasCoe.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) u)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (u : Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a (Units.val.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) u)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_units_coe_right lcm_units_coe_rightₓ'. -/\n@[simp]\ntheorem lcm_units_coe_right [NormalizedGCDMonoid α] (a : α) (u : αˣ) : lcm a ↑u = normalize a :=\n  (lcm_comm a u).trans <| lcm_units_coe_left _ _\n#align lcm_units_coe_right lcm_units_coe_right\n\n/- warning: lcm_one_left -> lcm_one_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))))) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_one_left lcm_one_leftₓ'. -/\n@[simp]\ntheorem lcm_one_left [NormalizedGCDMonoid α] (a : α) : lcm 1 a = normalize a :=\n  lcm_units_coe_left 1 a\n#align lcm_one_left lcm_one_left\n\n/- warning: lcm_one_right -> lcm_one_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_one_right lcm_one_rightₓ'. -/\n@[simp]\ntheorem lcm_one_right [NormalizedGCDMonoid α] (a : α) : lcm a 1 = normalize a :=\n  lcm_units_coe_right a 1\n#align lcm_one_right lcm_one_right\n\n/- warning: lcm_same -> lcm_same is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_same lcm_sameₓ'. -/\n@[simp]\ntheorem lcm_same [NormalizedGCDMonoid α] (a : α) : lcm a a = normalize a :=\n  lcm_eq_normalize (lcm_dvd dvd_rfl dvd_rfl) (dvd_lcm_left _ _)\n#align lcm_same lcm_same\n\n/- warning: lcm_eq_one_iff -> lcm_eq_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (And (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (And (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_one_iff lcm_eq_one_iffₓ'. -/\n@[simp]\ntheorem lcm_eq_one_iff [NormalizedGCDMonoid α] (a b : α) : lcm a b = 1 ↔ a ∣ 1 ∧ b ∣ 1 :=\n  Iff.intro (fun eq => Eq ▸ ⟨dvd_lcm_left _ _, dvd_lcm_right _ _⟩) fun ⟨⟨c, hc⟩, ⟨d, hd⟩⟩ =>\n    show lcm (Units.mkOfMulEqOne a c hc.symm : α) (Units.mkOfMulEqOne b d hd.symm) = 1 by\n      rw [lcm_units_coe_left, normalize_coe_units]\n#align lcm_eq_one_iff lcm_eq_one_iff\n\n/- warning: lcm_mul_left -> lcm_mul_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) α ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MulZeroClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MulZeroOneClass.toMulZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) _inst_1)))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align lcm_mul_left lcm_mul_leftₓ'. -/\n@[simp]\ntheorem lcm_mul_left [NormalizedGCDMonoid α] (a b c : α) :\n    lcm (a * b) (a * c) = normalize a * lcm b c :=\n  by_cases (by rintro rfl <;> simp only [MulZeroClass.zero_mul, lcm_zero_left, normalize_zero])\n    fun ha : a ≠ 0 =>\n    suffices lcm (a * b) (a * c) = normalize (a * lcm b c) by\n      simpa only [normalize.map_mul, normalize_lcm]\n    have : a ∣ lcm (a * b) (a * c) := (dvd_mul_right _ _).trans (dvd_lcm_left _ _)\n    let ⟨d, Eq⟩ := this\n    lcm_eq_normalize\n      (lcm_dvd (mul_dvd_mul_left a (dvd_lcm_left _ _)) (mul_dvd_mul_left a (dvd_lcm_right _ _)))\n      (Eq.symm ▸\n        (mul_dvd_mul_left a <|\n          lcm_dvd ((mul_dvd_mul_iff_left ha).1 <| Eq ▸ dvd_lcm_left _ _)\n            ((mul_dvd_mul_iff_left ha).1 <| Eq ▸ dvd_lcm_right _ _)))\n#align lcm_mul_left lcm_mul_left\n\n/- warning: lcm_mul_right -> lcm_mul_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) b c) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α) (c : α), Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} α ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) b c) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a))\nCase conversion may be inaccurate. Consider using '#align lcm_mul_right lcm_mul_rightₓ'. -/\n@[simp]\ntheorem lcm_mul_right [NormalizedGCDMonoid α] (a b c : α) :\n    lcm (b * a) (c * a) = lcm b c * normalize a := by simp only [mul_comm, lcm_mul_left]\n#align lcm_mul_right lcm_mul_right\n\n/- warning: lcm_eq_left_iff -> lcm_eq_left_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) a) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) a) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_left_iff lcm_eq_left_iffₓ'. -/\ntheorem lcm_eq_left_iff [NormalizedGCDMonoid α] (a b : α) (h : normalize a = a) :\n    lcm a b = a ↔ b ∣ a :=\n  Iff.intro (fun eq => Eq ▸ dvd_lcm_right _ _) fun hab =>\n    dvd_antisymm_of_normalize_eq (normalize_lcm _ _) h (lcm_dvd (dvd_refl a) hab) (dvd_lcm_left _ _)\n#align lcm_eq_left_iff lcm_eq_left_iff\n\n/- warning: lcm_eq_right_iff -> lcm_eq_right_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} α _inst_1 _inst_2) a b) b) (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizedGCDMonoid.{u1} α _inst_1] (a : α) (b : α), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} α _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} α (GCDMonoid.lcm.{u1} α _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} α _inst_1 _inst_2) a b) b) (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_right_iff lcm_eq_right_iffₓ'. -/\ntheorem lcm_eq_right_iff [NormalizedGCDMonoid α] (a b : α) (h : normalize b = b) :\n    lcm a b = b ↔ a ∣ b := by simpa only [lcm_comm b a] using lcm_eq_left_iff b a h\n#align lcm_eq_right_iff lcm_eq_right_iff\n\n/- warning: lcm_dvd_lcm_mul_left -> lcm_dvd_lcm_mul_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k m) n)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k m) n)\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_left lcm_dvd_lcm_mul_leftₓ'. -/\ntheorem lcm_dvd_lcm_mul_left [GCDMonoid α] (m n k : α) : lcm m n ∣ lcm (k * m) n :=\n  lcm_dvd_lcm (dvd_mul_left _ _) dvd_rfl\n#align lcm_dvd_lcm_mul_left lcm_dvd_lcm_mul_left\n\n/- warning: lcm_dvd_lcm_mul_right -> lcm_dvd_lcm_mul_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m k) n)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) m k) n)\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_right lcm_dvd_lcm_mul_rightₓ'. -/\ntheorem lcm_dvd_lcm_mul_right [GCDMonoid α] (m n k : α) : lcm m n ∣ lcm (m * k) n :=\n  lcm_dvd_lcm (dvd_mul_right _ _) dvd_rfl\n#align lcm_dvd_lcm_mul_right lcm_dvd_lcm_mul_right\n\n/- warning: lcm_dvd_lcm_mul_left_right -> lcm_dvd_lcm_mul_left_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) k n))\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_left_right lcm_dvd_lcm_mul_left_rightₓ'. -/\ntheorem lcm_dvd_lcm_mul_left_right [GCDMonoid α] (m n k : α) : lcm m n ∣ lcm m (k * n) :=\n  lcm_dvd_lcm dvd_rfl (dvd_mul_left _ _)\n#align lcm_dvd_lcm_mul_left_right lcm_dvd_lcm_mul_left_right\n\n/- warning: lcm_dvd_lcm_mul_right_right -> lcm_dvd_lcm_mul_right_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) n k))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : GCDMonoid.{u1} α _inst_1] (m : α) (n : α) (k : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} α _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) n k))\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_right_right lcm_dvd_lcm_mul_right_rightₓ'. -/\ntheorem lcm_dvd_lcm_mul_right_right [GCDMonoid α] (m n k : α) : lcm m n ∣ lcm m (n * k) :=\n  lcm_dvd_lcm dvd_rfl (dvd_mul_right _ _)\n#align lcm_dvd_lcm_mul_right_right lcm_dvd_lcm_mul_right_right\n\n#print lcm_eq_of_associated_left /-\ntheorem lcm_eq_of_associated_left [NormalizedGCDMonoid α] {m n : α} (h : Associated m n) (k : α) :\n    lcm m k = lcm n k :=\n  dvd_antisymm_of_normalize_eq (normalize_lcm _ _) (normalize_lcm _ _) (lcm_dvd_lcm h.Dvd dvd_rfl)\n    (lcm_dvd_lcm h.symm.Dvd dvd_rfl)\n#align lcm_eq_of_associated_left lcm_eq_of_associated_left\n-/\n\n#print lcm_eq_of_associated_right /-\ntheorem lcm_eq_of_associated_right [NormalizedGCDMonoid α] {m n : α} (h : Associated m n) (k : α) :\n    lcm k m = lcm k n :=\n  dvd_antisymm_of_normalize_eq (normalize_lcm _ _) (normalize_lcm _ _) (lcm_dvd_lcm dvd_rfl h.Dvd)\n    (lcm_dvd_lcm dvd_rfl h.symm.Dvd)\n#align lcm_eq_of_associated_right lcm_eq_of_associated_right\n-/\n\nend Lcm\n\nnamespace GCDMonoid\n\n#print GCDMonoid.prime_of_irreducible /-\ntheorem prime_of_irreducible [GCDMonoid α] {x : α} (hi : Irreducible x) : Prime x :=\n  ⟨hi.NeZero,\n    ⟨hi.1, fun a b h => by\n      cases' gcd_dvd_left x a with y hy\n      cases' hi.is_unit_or_is_unit hy with hu hu\n      · right\n        trans gcd (x * b) (a * b)\n        apply dvd_gcd (dvd_mul_right x b) h\n        rw [(gcd_mul_right' b x a).dvd_iff_dvd_left]\n        exact (associated_unit_mul_left _ _ hu).Dvd\n      · left\n        rw [hy]\n        exact dvd_trans (associated_mul_unit_left _ _ hu).Dvd (gcd_dvd_right x a)⟩⟩\n#align gcd_monoid.prime_of_irreducible GCDMonoid.prime_of_irreducible\n-/\n\n#print GCDMonoid.irreducible_iff_prime /-\ntheorem irreducible_iff_prime [GCDMonoid α] {p : α} : Irreducible p ↔ Prime p :=\n  ⟨prime_of_irreducible, Prime.irreducible⟩\n#align gcd_monoid.irreducible_iff_prime GCDMonoid.irreducible_iff_prime\n-/\n\nend GCDMonoid\n\nend GCDMonoid\n\nsection UniqueUnit\n\nvariable [CancelCommMonoidWithZero α] [Unique αˣ]\n\n#print normalizationMonoidOfUniqueUnits /-\n-- see Note [lower instance priority]\ninstance (priority := 100) normalizationMonoidOfUniqueUnits : NormalizationMonoid α\n    where\n  normUnit x := 1\n  normUnit_zero := rfl\n  normUnit_mul x y hx hy := (mul_one 1).symm\n  normUnit_coe_units u := Subsingleton.elim _ _\n#align normalization_monoid_of_unique_units normalizationMonoidOfUniqueUnits\n-/\n\n#print uniqueNormalizationMonoidOfUniqueUnits /-\ninstance uniqueNormalizationMonoidOfUniqueUnits : Unique (NormalizationMonoid α)\n    where\n  default := normalizationMonoidOfUniqueUnits\n  uniq := fun ⟨u, _, _, _⟩ => by simpa only [(Subsingleton.elim _ _ : u = fun _ => 1)]\n#align unique_normalization_monoid_of_unique_units uniqueNormalizationMonoidOfUniqueUnits\n-/\n\n#print subsingleton_gcdMonoid_of_unique_units /-\ninstance subsingleton_gcdMonoid_of_unique_units : Subsingleton (GCDMonoid α) :=\n  ⟨fun g₁ g₂ =>\n    by\n    have hgcd : g₁.gcd = g₂.gcd := by\n      ext (a b)\n      refine' associated_iff_eq.mp (associated_of_dvd_dvd _ _) <;>\n        apply dvd_gcd (gcd_dvd_left _ _) (gcd_dvd_right _ _)\n    have hlcm : g₁.lcm = g₂.lcm := by\n      ext (a b)\n      refine' associated_iff_eq.mp (associated_of_dvd_dvd _ _) <;>\n        apply lcm_dvd_iff.2 ⟨dvd_lcm_left _ _, dvd_lcm_right _ _⟩\n    cases g₁\n    cases g₂\n    dsimp only at hgcd hlcm\n    simp only [hgcd, hlcm]⟩\n#align subsingleton_gcd_monoid_of_unique_units subsingleton_gcdMonoid_of_unique_units\n-/\n\n#print subsingleton_normalizedGCDMonoid_of_unique_units /-\ninstance subsingleton_normalizedGCDMonoid_of_unique_units : Subsingleton (NormalizedGCDMonoid α) :=\n  ⟨by\n    intro a b\n    cases' a with a_norm a_gcd\n    cases' b with b_norm b_gcd\n    have := Subsingleton.elim a_gcd b_gcd\n    subst this\n    have := Subsingleton.elim a_norm b_norm\n    subst this⟩\n#align subsingleton_normalized_gcd_monoid_of_unique_units subsingleton_normalizedGCDMonoid_of_unique_units\n-/\n\n/- warning: norm_unit_eq_one -> normUnit_eq_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))] (x : α), Eq.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (NormalizationMonoid.normUnit.{u1} α _inst_1 (normalizationMonoidOfUniqueUnits.{u1} α _inst_1 _inst_2) x) (OfNat.ofNat.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (OfNat.mk.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.one.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulOneClass.toHasOne.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Units.mulOneClass.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))] (x : α), Eq.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (NormalizationMonoid.normUnit.{u1} α _inst_1 (normalizationMonoidOfUniqueUnits.{u1} α _inst_1 _inst_2) x) (OfNat.ofNat.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) 1 (One.toOfNat1.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (InvOneClass.toOne.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (DivisionCommMonoid.toDivisionMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommGroup.toDivisionCommMonoid.{u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Units.instCommGroupUnitsToMonoid.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align norm_unit_eq_one normUnit_eq_oneₓ'. -/\n@[simp]\ntheorem normUnit_eq_one (x : α) : normUnit x = 1 :=\n  rfl\n#align norm_unit_eq_one normUnit_eq_one\n\n/- warning: normalize_eq -> normalize_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))] (x : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 (normalizationMonoidOfUniqueUnits.{u1} α _inst_1 _inst_2)) x) x\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))] (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 (normalizationMonoidOfUniqueUnits.{u1} α _inst_1 _inst_2)) x) x\nCase conversion may be inaccurate. Consider using '#align normalize_eq normalize_eqₓ'. -/\n@[simp]\ntheorem normalize_eq (x : α) : normalize x = x :=\n  mul_one x\n#align normalize_eq normalize_eq\n\n/- warning: associates_equiv_of_unique_units -> associatesEquivOfUniqueUnits is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))], MulEquiv.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (Associates.hasMul.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : Unique.{succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))], MulEquiv.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (Associates.instMulAssociatesToMonoid.{u1} α (CommMonoidWithZero.toCommMonoid.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align associates_equiv_of_unique_units associatesEquivOfUniqueUnitsₓ'. -/\n/-- If a monoid's only unit is `1`, then it is isomorphic to its associates. -/\n@[simps]\ndef associatesEquivOfUniqueUnits : Associates α ≃* α\n    where\n  toFun := Associates.out\n  invFun := Associates.mk\n  left_inv := Associates.mk_out\n  right_inv t := (Associates.out_mk _).trans <| normalize_eq _\n  map_mul' := Associates.out_mul\n#align associates_equiv_of_unique_units associatesEquivOfUniqueUnits\n\nend UniqueUnit\n\nsection IsDomain\n\nvariable [CommRing α] [IsDomain α] [NormalizedGCDMonoid α]\n\n/- warning: gcd_eq_of_dvd_sub_right -> gcd_eq_of_dvd_sub_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2)] {a : α} {b : α} {c : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (NonUnitalSemiring.toSemigroupWithZero.{u1} α (NonUnitalRing.toNonUnitalSemiring.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α (CommRing.toNonUnitalCommRing.{u1} α _inst_1)))))) a (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) b c)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) a b) (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) a c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2)] {a : α} {b : α} {c : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (NonUnitalSemiring.toSemigroupWithZero.{u1} α (NonUnitalRing.toNonUnitalSemiring.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α (CommRing.toNonUnitalCommRing.{u1} α _inst_1)))))) a (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (CommRing.toRing.{u1} α _inst_1))) b c)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) a b) (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) a c))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_of_dvd_sub_right gcd_eq_of_dvd_sub_rightₓ'. -/\ntheorem gcd_eq_of_dvd_sub_right {a b c : α} (h : a ∣ b - c) : gcd a b = gcd a c :=\n  by\n  apply dvd_antisymm_of_normalize_eq (normalize_gcd _ _) (normalize_gcd _ _) <;>\n      rw [dvd_gcd_iff] <;>\n    refine' ⟨gcd_dvd_left _ _, _⟩\n  · rcases h with ⟨d, hd⟩\n    rcases gcd_dvd_right a b with ⟨e, he⟩\n    rcases gcd_dvd_left a b with ⟨f, hf⟩\n    use e - f * d\n    rw [mul_sub, ← he, ← mul_assoc, ← hf, ← hd, sub_sub_cancel]\n  · rcases h with ⟨d, hd⟩\n    rcases gcd_dvd_right a c with ⟨e, he⟩\n    rcases gcd_dvd_left a c with ⟨f, hf⟩\n    use e + f * d\n    rw [mul_add, ← he, ← mul_assoc, ← hf, ← hd, ← add_sub_assoc, add_comm c b, add_sub_cancel]\n#align gcd_eq_of_dvd_sub_right gcd_eq_of_dvd_sub_right\n\n/- warning: gcd_eq_of_dvd_sub_left -> gcd_eq_of_dvd_sub_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2)] {a : α} {b : α} {c : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (NonUnitalSemiring.toSemigroupWithZero.{u1} α (NonUnitalRing.toNonUnitalSemiring.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α (CommRing.toNonUnitalCommRing.{u1} α _inst_1)))))) a (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) b c)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) b a) (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) c a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2)] {a : α} {b : α} {c : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (NonUnitalSemiring.toSemigroupWithZero.{u1} α (NonUnitalRing.toNonUnitalSemiring.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α (CommRing.toNonUnitalCommRing.{u1} α _inst_1)))))) a (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (CommRing.toRing.{u1} α _inst_1))) b c)) -> (Eq.{succ u1} α (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) b a) (GCDMonoid.gcd.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} α (IsDomain.toCancelCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1) _inst_2) _inst_3) c a))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_of_dvd_sub_left gcd_eq_of_dvd_sub_leftₓ'. -/\ntheorem gcd_eq_of_dvd_sub_left {a b c : α} (h : a ∣ b - c) : gcd b a = gcd c a := by\n  rw [gcd_comm _ a, gcd_comm _ a, gcd_eq_of_dvd_sub_right h]\n#align gcd_eq_of_dvd_sub_left gcd_eq_of_dvd_sub_left\n\nend IsDomain\n\nsection Constructors\n\nnoncomputable section\n\nopen Associates\n\nvariable [CancelCommMonoidWithZero α]\n\nprivate theorem map_mk_unit_aux [DecidableEq α] {f : Associates α →* α}\n    (hinv : Function.RightInverse f Associates.mk) (a : α) :\n    a * ↑(Classical.choose (associated_map_mk hinv a)) = f (Associates.mk a) :=\n  Classical.choose_spec (associated_map_mk hinv a)\n#align map_mk_unit_aux map_mk_unit_aux\n\n/- warning: normalization_monoid_of_monoid_hom_right_inverse -> normalizationMonoidOfMonoidHomRightInverse is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : DecidableEq.{succ u1} α] (f : MonoidHom.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.commMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))), (Function.RightInverse.{succ u1, succ u1} α (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.commMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (fun (_x : MonoidHom.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.commMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) => (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) -> α) (MonoidHom.hasCoeToFun.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.commMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) f) (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) -> (NormalizationMonoid.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : DecidableEq.{succ u1} α] (f : MonoidHom.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))), (Function.RightInverse.{succ u1, succ u1} α (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulOneClass.toMul.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidHom.monoidHomClass.{u1, u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) f) (Associates.mk.{u1} α (MonoidWithZero.toMonoid.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) -> (NormalizationMonoid.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align normalization_monoid_of_monoid_hom_right_inverse normalizationMonoidOfMonoidHomRightInverseₓ'. -/\n/-- Define `normalization_monoid` on a structure from a `monoid_hom` inverse to `associates.mk`. -/\ndef normalizationMonoidOfMonoidHomRightInverse [DecidableEq α] (f : Associates α →* α)\n    (hinv : Function.RightInverse f Associates.mk) : NormalizationMonoid α\n    where\n  normUnit a :=\n    if a = 0 then 1\n    else Classical.choose (Associates.mk_eq_mk_iff_associated.1 (hinv (Associates.mk a)).symm)\n  normUnit_zero := if_pos rfl\n  normUnit_mul a b ha hb :=\n    by\n    rw [if_neg (mul_ne_zero ha hb), if_neg ha, if_neg hb, Units.ext_iff, Units.val_mul]\n    suffices\n      a * b * ↑(Classical.choose (associated_map_mk hinv (a * b))) =\n        a * ↑(Classical.choose (associated_map_mk hinv a)) *\n          (b * ↑(Classical.choose (associated_map_mk hinv b)))\n      by\n      apply mul_left_cancel₀ (mul_ne_zero ha hb) _\n      simpa only [mul_assoc, mul_comm, mul_left_comm] using this\n    rw [map_mk_unit_aux hinv a, map_mk_unit_aux hinv (a * b), map_mk_unit_aux hinv b, ←\n      MonoidHom.map_mul, Associates.mk_mul_mk]\n  normUnit_coe_units u := by\n    nontriviality α\n    rw [if_neg (Units.ne_zero u), Units.ext_iff]\n    apply mul_left_cancel₀ (Units.ne_zero u)\n    rw [Units.mul_inv, map_mk_unit_aux hinv u,\n      Associates.mk_eq_mk_iff_associated.2 (associated_one_iff_isUnit.2 ⟨u, rfl⟩),\n      Associates.mk_one, MonoidHom.map_one]\n#align normalization_monoid_of_monoid_hom_right_inverse normalizationMonoidOfMonoidHomRightInverse\n\n#print gcdMonoidOfGCD /-\n/-- Define `gcd_monoid` on a structure just from the `gcd` and its properties. -/\nnoncomputable def gcdMonoidOfGCD [DecidableEq α] (gcd : α → α → α)\n    (gcd_dvd_left : ∀ a b, gcd a b ∣ a) (gcd_dvd_right : ∀ a b, gcd a b ∣ b)\n    (dvd_gcd : ∀ {a b c}, a ∣ c → a ∣ b → a ∣ gcd c b) : GCDMonoid α :=\n  { gcd\n    gcd_dvd_left\n    gcd_dvd_right\n    dvd_gcd := fun a b c => dvd_gcd\n    lcm := fun a b =>\n      if a = 0 then 0 else Classical.choose ((gcd_dvd_left a b).trans (Dvd.intro b rfl))\n    gcd_mul_lcm := fun a b => by\n      split_ifs with a0\n      · rw [MulZeroClass.mul_zero, a0, MulZeroClass.zero_mul]\n      · rw [← Classical.choose_spec ((gcd_dvd_left a b).trans (Dvd.intro b rfl))]\n    lcm_zero_left := fun a => if_pos rfl\n    lcm_zero_right := fun a => by\n      split_ifs with a0\n      · rfl\n      have h := (Classical.choose_spec ((gcd_dvd_left a 0).trans (Dvd.intro 0 rfl))).symm\n      have a0' : gcd a 0 ≠ 0 := by\n        contrapose! a0\n        rw [← associated_zero_iff_eq_zero, ← a0]\n        exact associated_of_dvd_dvd (dvd_gcd (dvd_refl a) (dvd_zero a)) (gcd_dvd_left _ _)\n      apply Or.resolve_left (mul_eq_zero.1 _) a0'\n      rw [h, MulZeroClass.mul_zero] }\n#align gcd_monoid_of_gcd gcdMonoidOfGCD\n-/\n\n/- warning: normalized_gcd_monoid_of_gcd -> normalizedGCDMonoidOfGCD is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] [_inst_3 : DecidableEq.{succ u1} α] (gcd : α -> α -> α), (forall (a : α) (b : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (gcd a b) a) -> (forall (a : α) (b : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (gcd a b) b) -> (forall {a : α} {b : α} {c : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a c) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (gcd c b))) -> (forall (a : α) (b : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) (gcd a b)) (gcd a b)) -> (NormalizedGCDMonoid.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] [_inst_3 : DecidableEq.{succ u1} α] (gcd : α -> α -> α), (forall (a : α) (b : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (gcd a b) a) -> (forall (a : α) (b : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (gcd a b) b) -> (forall {a : α} {b : α} {c : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a c) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a b) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (gcd c b))) -> (forall (a : α) (b : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (gcd a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) (gcd a b)) (gcd a b)) -> (NormalizedGCDMonoid.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align normalized_gcd_monoid_of_gcd normalizedGCDMonoidOfGCDₓ'. -/\n/-- Define `normalized_gcd_monoid` on a structure just from the `gcd` and its properties. -/\nnoncomputable def normalizedGCDMonoidOfGCD [NormalizationMonoid α] [DecidableEq α] (gcd : α → α → α)\n    (gcd_dvd_left : ∀ a b, gcd a b ∣ a) (gcd_dvd_right : ∀ a b, gcd a b ∣ b)\n    (dvd_gcd : ∀ {a b c}, a ∣ c → a ∣ b → a ∣ gcd c b)\n    (normalize_gcd : ∀ a b, normalize (gcd a b) = gcd a b) : NormalizedGCDMonoid α :=\n  { (inferInstance : NormalizationMonoid α) with\n    gcd\n    gcd_dvd_left\n    gcd_dvd_right\n    dvd_gcd := fun a b c => dvd_gcd\n    normalize_gcd\n    lcm := fun a b =>\n      if a = 0 then 0\n      else Classical.choose (dvd_normalize_iff.2 ((gcd_dvd_left a b).trans (Dvd.intro b rfl)))\n    normalize_lcm := fun a b => by\n      dsimp [normalize]\n      split_ifs with a0\n      · exact @normalize_zero α _ _\n      · have :=\n          (Classical.choose_spec\n              (dvd_normalize_iff.2 ((gcd_dvd_left a b).trans (Dvd.intro b rfl)))).symm\n        set l := Classical.choose (dvd_normalize_iff.2 ((gcd_dvd_left a b).trans (Dvd.intro b rfl)))\n        obtain rfl | hb := eq_or_ne b 0\n        · simp only [normalize_zero, MulZeroClass.mul_zero, mul_eq_zero] at this\n          obtain ha | hl := this\n          · apply (a0 _).elim\n            rw [← zero_dvd_iff, ← ha]\n            exact gcd_dvd_left _ _\n          · convert@normalize_zero α _ _\n        have h1 : gcd a b ≠ 0 := by\n          have hab : a * b ≠ 0 := mul_ne_zero a0 hb\n          contrapose! hab\n          rw [← normalize_eq_zero, ← this, hab, MulZeroClass.zero_mul]\n        have h2 : normalize (gcd a b * l) = gcd a b * l := by rw [this, normalize_idem]\n        rw [← normalize_gcd] at this\n        rwa [normalize.map_mul, normalize_gcd, mul_right_inj' h1] at h2\n    gcd_mul_lcm := fun a b => by\n      split_ifs with a0\n      · rw [MulZeroClass.mul_zero, a0, MulZeroClass.zero_mul]\n      · rw [←\n          Classical.choose_spec (dvd_normalize_iff.2 ((gcd_dvd_left a b).trans (Dvd.intro b rfl)))]\n        exact normalize_associated (a * b)\n    lcm_zero_left := fun a => if_pos rfl\n    lcm_zero_right := fun a => by\n      split_ifs with a0\n      · rfl\n      rw [← normalize_eq_zero] at a0\n      have h :=\n        (Classical.choose_spec\n            (dvd_normalize_iff.2 ((gcd_dvd_left a 0).trans (Dvd.intro 0 rfl)))).symm\n      have gcd0 : gcd a 0 = normalize a :=\n        by\n        rw [← normalize_gcd]\n        exact normalize_eq_normalize (gcd_dvd_left _ _) (dvd_gcd (dvd_refl a) (dvd_zero a))\n      rw [← gcd0] at a0\n      apply Or.resolve_left (mul_eq_zero.1 _) a0\n      rw [h, MulZeroClass.mul_zero, normalize_zero] }\n#align normalized_gcd_monoid_of_gcd normalizedGCDMonoidOfGCD\n\n#print gcdMonoidOfLCM /-\n/-- Define `gcd_monoid` on a structure just from the `lcm` and its properties. -/\nnoncomputable def gcdMonoidOfLCM [DecidableEq α] (lcm : α → α → α)\n    (dvd_lcm_left : ∀ a b, a ∣ lcm a b) (dvd_lcm_right : ∀ a b, b ∣ lcm a b)\n    (lcm_dvd : ∀ {a b c}, c ∣ a → b ∣ a → lcm c b ∣ a) : GCDMonoid α :=\n  let exists_gcd a b := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl)\n  { lcm\n    gcd := fun a b => if a = 0 then b else if b = 0 then a else Classical.choose (exists_gcd a b)\n    gcd_mul_lcm := fun a b => by\n      split_ifs\n      · rw [h, eq_zero_of_zero_dvd (dvd_lcm_left _ _), MulZeroClass.mul_zero, MulZeroClass.zero_mul]\n      · rw [h_1, eq_zero_of_zero_dvd (dvd_lcm_right _ _), MulZeroClass.mul_zero]\n      rw [mul_comm, ← Classical.choose_spec (exists_gcd a b)]\n    lcm_zero_left := fun a => eq_zero_of_zero_dvd (dvd_lcm_left _ _)\n    lcm_zero_right := fun a => eq_zero_of_zero_dvd (dvd_lcm_right _ _)\n    gcd_dvd_left := fun a b => by\n      split_ifs with h h_1\n      · rw [h]\n        apply dvd_zero\n      · exact dvd_rfl\n      have h0 : lcm a b ≠ 0 := by\n        intro con\n        have h := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl)\n        rw [Con, zero_dvd_iff, mul_eq_zero] at h\n        cases h <;> tauto\n      rw [← mul_dvd_mul_iff_left h0, ← Classical.choose_spec (exists_gcd a b), mul_comm,\n        mul_dvd_mul_iff_right h]\n      apply dvd_lcm_right\n    gcd_dvd_right := fun a b => by\n      split_ifs with h h_1\n      · exact dvd_rfl\n      · rw [h_1]\n        apply dvd_zero\n      have h0 : lcm a b ≠ 0 := by\n        intro con\n        have h := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl)\n        rw [Con, zero_dvd_iff, mul_eq_zero] at h\n        cases h <;> tauto\n      rw [← mul_dvd_mul_iff_left h0, ← Classical.choose_spec (exists_gcd a b),\n        mul_dvd_mul_iff_right h_1]\n      apply dvd_lcm_left\n    dvd_gcd := fun a b c ac ab => by\n      split_ifs\n      · exact ab\n      · exact ac\n      have h0 : lcm c b ≠ 0 := by\n        intro con\n        have h := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left c rfl)\n        rw [Con, zero_dvd_iff, mul_eq_zero] at h\n        cases h <;> tauto\n      rw [← mul_dvd_mul_iff_left h0, ← Classical.choose_spec (exists_gcd c b)]\n      rcases ab with ⟨d, rfl⟩\n      rw [mul_eq_zero] at h_1\n      push_neg  at h_1\n      rw [mul_comm a, ← mul_assoc, mul_dvd_mul_iff_right h_1.1]\n      apply lcm_dvd (Dvd.intro d rfl)\n      rw [mul_comm, mul_dvd_mul_iff_right h_1.2]\n      apply ac }\n#align gcd_monoid_of_lcm gcdMonoidOfLCM\n-/\n\n/- warning: normalized_gcd_monoid_of_lcm -> normalizedGCDMonoidOfLCM is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] [_inst_3 : DecidableEq.{succ u1} α] (lcm : α -> α -> α), (forall (a : α) (b : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (lcm a b)) -> (forall (a : α) (b : α), Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b (lcm a b)) -> (forall {a : α} {b : α} {c : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c a) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a) -> (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (lcm c b) a)) -> (forall (a : α) (b : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) => α -> α) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (normalize.{u1} α _inst_1 _inst_2) (lcm a b)) (lcm a b)) -> (NormalizedGCDMonoid.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} α] [_inst_2 : NormalizationMonoid.{u1} α _inst_1] [_inst_3 : DecidableEq.{succ u1} α] (lcm : α -> α -> α), (forall (a : α) (b : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) a (lcm a b)) -> (forall (a : α) (b : α), Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b (lcm a b)) -> (forall {a : α} {b : α} {c : α}, (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) c a) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) b a) -> (Dvd.dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (MonoidWithZero.toSemigroupWithZero.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (lcm c b) a)) -> (forall (a : α) (b : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) (lcm a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1)))) α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} α α (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} α (CommMonoidWithZero.toMonoidWithZero.{u1} α (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} α _inst_1))))))) (normalize.{u1} α _inst_1 _inst_2) (lcm a b)) (lcm a b)) -> (NormalizedGCDMonoid.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align normalized_gcd_monoid_of_lcm normalizedGCDMonoidOfLCMₓ'. -/\n/-- Define `normalized_gcd_monoid` on a structure just from the `lcm` and its properties. -/\nnoncomputable def normalizedGCDMonoidOfLCM [NormalizationMonoid α] [DecidableEq α] (lcm : α → α → α)\n    (dvd_lcm_left : ∀ a b, a ∣ lcm a b) (dvd_lcm_right : ∀ a b, b ∣ lcm a b)\n    (lcm_dvd : ∀ {a b c}, c ∣ a → b ∣ a → lcm c b ∣ a)\n    (normalize_lcm : ∀ a b, normalize (lcm a b) = lcm a b) : NormalizedGCDMonoid α :=\n  let exists_gcd a b := dvd_normalize_iff.2 (lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl))\n  { (inferInstance : NormalizationMonoid α) with\n    lcm\n    gcd := fun a b =>\n      if a = 0 then normalize b\n      else if b = 0 then normalize a else Classical.choose (exists_gcd a b)\n    gcd_mul_lcm := fun a b => by\n      split_ifs with h h_1\n      · rw [h, eq_zero_of_zero_dvd (dvd_lcm_left _ _), MulZeroClass.mul_zero, MulZeroClass.zero_mul]\n      ·\n        rw [h_1, eq_zero_of_zero_dvd (dvd_lcm_right _ _), MulZeroClass.mul_zero,\n          MulZeroClass.mul_zero]\n      rw [mul_comm, ← Classical.choose_spec (exists_gcd a b)]\n      exact normalize_associated (a * b)\n    normalize_lcm\n    normalize_gcd := fun a b => by\n      dsimp [normalize]\n      split_ifs with h h_1\n      · apply normalize_idem\n      · apply normalize_idem\n      have h0 : lcm a b ≠ 0 := by\n        intro con\n        have h := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl)\n        rw [Con, zero_dvd_iff, mul_eq_zero] at h\n        cases h <;> tauto\n      apply mul_left_cancel₀ h0\n      refine' trans _ (Classical.choose_spec (exists_gcd a b))\n      conv_lhs =>\n        congr\n        rw [← normalize_lcm a b]\n      erw [← normalize.map_mul, ← Classical.choose_spec (exists_gcd a b), normalize_idem]\n    lcm_zero_left := fun a => eq_zero_of_zero_dvd (dvd_lcm_left _ _)\n    lcm_zero_right := fun a => eq_zero_of_zero_dvd (dvd_lcm_right _ _)\n    gcd_dvd_left := fun a b => by\n      split_ifs\n      · rw [h]\n        apply dvd_zero\n      · exact (normalize_associated _).Dvd\n      have h0 : lcm a b ≠ 0 := by\n        intro con\n        have h := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl)\n        rw [Con, zero_dvd_iff, mul_eq_zero] at h\n        cases h <;> tauto\n      rw [← mul_dvd_mul_iff_left h0, ← Classical.choose_spec (exists_gcd a b), normalize_dvd_iff,\n        mul_comm, mul_dvd_mul_iff_right h]\n      apply dvd_lcm_right\n    gcd_dvd_right := fun a b => by\n      split_ifs\n      · exact (normalize_associated _).Dvd\n      · rw [h_1]\n        apply dvd_zero\n      have h0 : lcm a b ≠ 0 := by\n        intro con\n        have h := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl)\n        rw [Con, zero_dvd_iff, mul_eq_zero] at h\n        cases h <;> tauto\n      rw [← mul_dvd_mul_iff_left h0, ← Classical.choose_spec (exists_gcd a b), normalize_dvd_iff,\n        mul_dvd_mul_iff_right h_1]\n      apply dvd_lcm_left\n    dvd_gcd := fun a b c ac ab => by\n      split_ifs\n      · apply dvd_normalize_iff.2 ab\n      · apply dvd_normalize_iff.2 ac\n      have h0 : lcm c b ≠ 0 := by\n        intro con\n        have h := lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left c rfl)\n        rw [Con, zero_dvd_iff, mul_eq_zero] at h\n        cases h <;> tauto\n      rw [← mul_dvd_mul_iff_left h0, ←\n        Classical.choose_spec\n          (dvd_normalize_iff.2 (lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left c rfl))),\n        dvd_normalize_iff]\n      rcases ab with ⟨d, rfl⟩\n      rw [mul_eq_zero] at h_1\n      push_neg  at h_1\n      rw [mul_comm a, ← mul_assoc, mul_dvd_mul_iff_right h_1.1]\n      apply lcm_dvd (Dvd.intro d rfl)\n      rw [mul_comm, mul_dvd_mul_iff_right h_1.2]\n      apply ac }\n#align normalized_gcd_monoid_of_lcm normalizedGCDMonoidOfLCM\n\n#print gcdMonoidOfExistsGCD /-\n/-- Define a `gcd_monoid` structure on a monoid just from the existence of a `gcd`. -/\nnoncomputable def gcdMonoidOfExistsGCD [DecidableEq α]\n    (h : ∀ a b : α, ∃ c : α, ∀ d : α, d ∣ a ∧ d ∣ b ↔ d ∣ c) : GCDMonoid α :=\n  gcdMonoidOfGCD (fun a b => Classical.choose (h a b))\n    (fun a b => ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).1)\n    (fun a b => ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).2)\n    fun a b c ac ab => (Classical.choose_spec (h c b) a).1 ⟨ac, ab⟩\n#align gcd_monoid_of_exists_gcd gcdMonoidOfExistsGCD\n-/\n\n#print normalizedGCDMonoidOfExistsGCD /-\n/-- Define a `normalized_gcd_monoid` structure on a monoid just from the existence of a `gcd`. -/\nnoncomputable def normalizedGCDMonoidOfExistsGCD [NormalizationMonoid α] [DecidableEq α]\n    (h : ∀ a b : α, ∃ c : α, ∀ d : α, d ∣ a ∧ d ∣ b ↔ d ∣ c) : NormalizedGCDMonoid α :=\n  normalizedGCDMonoidOfGCD (fun a b => normalize (Classical.choose (h a b)))\n    (fun a b =>\n      normalize_dvd_iff.2 ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).1)\n    (fun a b =>\n      normalize_dvd_iff.2 ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).2)\n    (fun a b c ac ab => dvd_normalize_iff.2 ((Classical.choose_spec (h c b) a).1 ⟨ac, ab⟩))\n    fun a b => normalize_idem _\n#align normalized_gcd_monoid_of_exists_gcd normalizedGCDMonoidOfExistsGCD\n-/\n\n#print gcdMonoidOfExistsLCM /-\n/-- Define a `gcd_monoid` structure on a monoid just from the existence of an `lcm`. -/\nnoncomputable def gcdMonoidOfExistsLCM [DecidableEq α]\n    (h : ∀ a b : α, ∃ c : α, ∀ d : α, a ∣ d ∧ b ∣ d ↔ c ∣ d) : GCDMonoid α :=\n  gcdMonoidOfLCM (fun a b => Classical.choose (h a b))\n    (fun a b => ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).1)\n    (fun a b => ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).2)\n    fun a b c ac ab => (Classical.choose_spec (h c b) a).1 ⟨ac, ab⟩\n#align gcd_monoid_of_exists_lcm gcdMonoidOfExistsLCM\n-/\n\n#print normalizedGCDMonoidOfExistsLCM /-\n/-- Define a `normalized_gcd_monoid` structure on a monoid just from the existence of an `lcm`. -/\nnoncomputable def normalizedGCDMonoidOfExistsLCM [NormalizationMonoid α] [DecidableEq α]\n    (h : ∀ a b : α, ∃ c : α, ∀ d : α, a ∣ d ∧ b ∣ d ↔ c ∣ d) : NormalizedGCDMonoid α :=\n  normalizedGCDMonoidOfLCM (fun a b => normalize (Classical.choose (h a b)))\n    (fun a b =>\n      dvd_normalize_iff.2 ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).1)\n    (fun a b =>\n      dvd_normalize_iff.2 ((Classical.choose_spec (h a b) (Classical.choose (h a b))).2 dvd_rfl).2)\n    (fun a b c ac ab => normalize_dvd_iff.2 ((Classical.choose_spec (h c b) a).1 ⟨ac, ab⟩))\n    fun a b => normalize_idem _\n#align normalized_gcd_monoid_of_exists_lcm normalizedGCDMonoidOfExistsLCM\n-/\n\nend Constructors\n\nnamespace CommGroupWithZero\n\nvariable (G₀ : Type _) [CommGroupWithZero G₀] [DecidableEq G₀]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) : NormalizedGCDMonoid G₀\n    where\n  normUnit x := if h : x = 0 then 1 else (Units.mk0 x h)⁻¹\n  normUnit_zero := dif_pos rfl\n  normUnit_mul x y x0 y0 := Units.eq_iff.1 (by simp [x0, y0, mul_comm])\n  normUnit_coe_units u := by\n    rw [dif_neg (Units.ne_zero _), Units.mk0_val]\n    infer_instance\n  gcd a b := if a = 0 ∧ b = 0 then 0 else 1\n  lcm a b := if a = 0 ∨ b = 0 then 0 else 1\n  gcd_dvd_left a b := by\n    split_ifs with h\n    · rw [h.1]\n    · exact one_dvd _\n  gcd_dvd_right a b := by\n    split_ifs with h\n    · rw [h.2]\n    · exact one_dvd _\n  dvd_gcd a b c hac hab := by\n    split_ifs with h; · apply dvd_zero\n    cases' not_and_distrib.mp h with h h <;>\n        refine' is_unit_iff_dvd_one.mp (isUnit_of_dvd_unit _ (IsUnit.mk0 _ h)) <;>\n      assumption\n  gcd_mul_lcm a b := by\n    by_cases ha : a = 0; · simp [ha]\n    by_cases hb : b = 0; · simp [hb]\n    rw [if_neg (not_and_of_not_left _ ha), one_mul, if_neg (not_or_of_not ha hb)]\n    exact (associated_one_iff_is_unit.mpr ((IsUnit.mk0 _ ha).mul (IsUnit.mk0 _ hb))).symm\n  lcm_zero_left b := if_pos (Or.inl rfl)\n  lcm_zero_right a := if_pos (Or.inr rfl)\n  -- `split_ifs` wants to split `normalize`, so handle the cases manually\n  normalize_gcd a b := if h : a = 0 ∧ b = 0 then by simp [if_pos h] else by simp [if_neg h]\n  normalize_lcm a b := if h : a = 0 ∨ b = 0 then by simp [if_pos h] else by simp [if_neg h]\n\n/- warning: comm_group_with_zero.coe_norm_unit -> CommGroupWithZero.coe_normUnit is a dubious translation:\nlean 3 declaration is\n  forall (G₀ : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G₀] [_inst_2 : DecidableEq.{succ u1} G₀] {a : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ (CommGroupWithZero.toGroupWithZero.{u1} G₀ _inst_1))))))))) -> (Eq.{succ u1} G₀ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))))))) (NormalizationMonoid.normUnit.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (CommGroupWithZero.normalizedGcdMonoid.{u1} G₀ _inst_1 (fun (a : G₀) (b : G₀) => _inst_2 a b))) a)) (Inv.inv.{u1} G₀ (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ (CommGroupWithZero.toGroupWithZero.{u1} G₀ _inst_1))) a))\nbut is expected to have type\n  forall (G₀ : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G₀] [_inst_2 : DecidableEq.{succ u1} G₀] {a : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (CommMonoidWithZero.toZero.{u1} G₀ (CommGroupWithZero.toCommMonoidWithZero.{u1} G₀ _inst_1))))) -> (Eq.{succ u1} G₀ (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (NormalizationMonoid.normUnit.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} G₀ _inst_1 (fun (a : G₀) (b : G₀) => _inst_2 a b))) a)) (Inv.inv.{u1} G₀ (CommGroupWithZero.toInv.{u1} G₀ _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align comm_group_with_zero.coe_norm_unit CommGroupWithZero.coe_normUnitₓ'. -/\n@[simp]\ntheorem coe_normUnit {a : G₀} (h0 : a ≠ 0) : (↑(normUnit a) : G₀) = a⁻¹ := by simp [norm_unit, h0]\n#align comm_group_with_zero.coe_norm_unit CommGroupWithZero.coe_normUnit\n\n/- warning: comm_group_with_zero.normalize_eq_one -> CommGroupWithZero.normalize_eq_one is a dubious translation:\nlean 3 declaration is\n  forall (G₀ : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G₀] [_inst_2 : DecidableEq.{succ u1} G₀] {a : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ (CommGroupWithZero.toGroupWithZero.{u1} G₀ _inst_1))))))))) -> (Eq.{succ u1} G₀ (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) (fun (_x : MonoidWithZeroHom.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) => G₀ -> G₀) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) (normalize.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (CommGroupWithZero.normalizedGcdMonoid.{u1} G₀ _inst_1 (fun (a : G₀) (b : G₀) => _inst_2 a b)))) a) (OfNat.ofNat.{u1} G₀ 1 (OfNat.mk.{u1} G₀ 1 (One.one.{u1} G₀ (MulOneClass.toHasOne.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ (CommGroupWithZero.toGroupWithZero.{u1} G₀ _inst_1)))))))))\nbut is expected to have type\n  forall (G₀ : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G₀] [_inst_2 : DecidableEq.{succ u1} G₀] {a : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (CommMonoidWithZero.toZero.{u1} G₀ (CommGroupWithZero.toCommMonoidWithZero.{u1} G₀ _inst_1))))) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ (fun (_x : G₀) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ G₀ (MulOneClass.toMul.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))))) (MulOneClass.toMul.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1))))) G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} G₀ G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (CommMonoidWithZero.toMonoidWithZero.{u1} G₀ (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1)))))))) (normalize.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G₀ (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G₀ _inst_1) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} G₀ _inst_1 (fun (a : G₀) (b : G₀) => _inst_2 a b)))) a) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) (InvOneClass.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) (DivInvOneMonoid.toInvOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) (DivisionMonoid.toDivInvOneMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) (DivisionCommMonoid.toDivisionMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) (CommGroupWithZero.toDivisionCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G₀) => G₀) a) _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align comm_group_with_zero.normalize_eq_one CommGroupWithZero.normalize_eq_oneₓ'. -/\ntheorem normalize_eq_one {a : G₀} (h0 : a ≠ 0) : normalize a = 1 := by simp [normalize_apply, h0]\n#align comm_group_with_zero.normalize_eq_one CommGroupWithZero.normalize_eq_one\n\nend CommGroupWithZero\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/GcdMonoid/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.49553269101901637}}
{"text": "/-\nCopyright (c) 2022 Heather Macbeth. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Heather Macbeth\n-/\nimport analysis.complex.abs_max\nimport analysis.locally_convex.with_seminorms\nimport geometry.manifold.mfderiv\nimport topology.locally_constant.basic\n\n/-! # Holomorphic functions on complex manifolds\n\nThanks to the rigidity of complex-differentiability compared to real-differentiability, there are\nmany results about complex manifolds with no analogue for manifolds over a general normed field. For\nnow, this file contains just two (closely related) such results:\n\n## Main results\n\n* `mdifferentiable.is_locally_constant`: A complex-differentiable function on a compact complex\n  manifold is locally constant.\n* `mdifferentiable.exists_eq_const_of_compact_space`: A complex-differentiable function on a compact\n  preconnected complex manifold is constant.\n\n## TODO\n\nThere is a whole theory to develop here.  Maybe a next step would be to develop a theory of\nholomorphic vector/line bundles, including:\n* the finite-dimensionality of the space of sections of a holomorphic vector bundle\n* Siegel's theorem: for any `n + 1` formal ratios `g 0 / h 0`, `g 1 / h 1`, .... `g n / h n` of\n  sections of a fixed line bundle `L` over a complex `n`-manifold, there exists a polynomial\n  relationship `P (g 0 / h 0, g 1 / h 1, .... g n / h n) = 0`\n\nAnother direction would be to develop the relationship with sheaf theory, building the sheaves of\nholomorphic and meromorphic functions on a complex manifold and proving algebraic results about the\nstalks, such as the Weierstrass preparation theorem.\n\n-/\n\nopen_locale manifold topology\nopen complex\n\nnamespace mdifferentiable\n\nvariables {E : Type*} [normed_add_comm_group E] [normed_space ℂ E]\nvariables {F : Type*} [normed_add_comm_group F] [normed_space ℂ F] [strict_convex_space ℝ F]\n\nvariables {M : Type*} [topological_space M] [compact_space M] [charted_space E M]\n  [smooth_manifold_with_corners 𝓘(ℂ, E) M]\n\n/-- A holomorphic function on a compact complex manifold is locally constant. -/\nprotected lemma is_locally_constant {f : M → F} (hf : mdifferentiable 𝓘(ℂ, E) 𝓘(ℂ, F) f) :\n  is_locally_constant f :=\nbegin\n  haveI : locally_connected_space M := charted_space.locally_connected_space E M,\n  apply is_locally_constant.of_constant_on_preconnected_clopens,\n  intros s hs₂ hs₃ a ha b hb,\n  have hs₁ : is_compact s := hs₃.2.is_compact,\n  -- for an empty set this fact is trivial\n  rcases s.eq_empty_or_nonempty with rfl | hs',\n  { exact false.rec _ ha },\n  -- otherwise, let `p₀` be a point where the value of `f` has maximal norm\n  obtain ⟨p₀, hp₀s, hp₀⟩ := hs₁.exists_forall_ge hs' hf.continuous.norm.continuous_on,\n  -- we will show `f` agrees everywhere with `f p₀`\n  suffices : s ⊆ {r : M | f r = f p₀} ∩ s,\n  { exact (this hb).1.trans (this ha).1.symm }, clear ha hb a b,\n  refine hs₂.subset_clopen _ ⟨p₀, hp₀s, ⟨rfl, hp₀s⟩⟩,\n  -- closedness of the set of points sent to `f p₀`\n  refine ⟨_, (is_closed_singleton.preimage hf.continuous).inter hs₃.2⟩,\n  -- we will show this set is open by showing it is a neighbourhood of each of its members\n  rw is_open_iff_mem_nhds,\n  rintros p ⟨hp : f p = _, hps⟩, -- let `p` be  in this set\n  have hps' : s ∈ 𝓝 p := hs₃.1.mem_nhds hps,\n  have key₁ : (chart_at E p).symm ⁻¹' s ∈ 𝓝 (chart_at E p p),\n  { rw [← filter.mem_map, (chart_at E p).symm_map_nhds_eq (mem_chart_source E p)],\n    exact hps' },\n  have key₂ : (chart_at E p).target ∈ 𝓝 (chart_at E p p) :=\n    (local_homeomorph.open_target _).mem_nhds (mem_chart_target E p),\n  -- `f` pulled back by the chart at `p` is differentiable around `chart_at E p p`\n  have hf' : ∀ᶠ (z : E) in 𝓝 (chart_at E p p), differentiable_at ℂ (f ∘ (chart_at E p).symm) z,\n  { refine filter.eventually_of_mem key₂ (λ z hz, _),\n    have H₁ : (chart_at E p).symm z ∈ (chart_at E p).source := (chart_at E p).map_target hz,\n    have H₂ : f ((chart_at E p).symm z) ∈ (chart_at F (0:F)).source := trivial,\n    have H := (mdifferentiable_at_iff_of_mem_source H₁ H₂).mp (hf ((chart_at E p).symm z)),\n    simp only [differentiable_within_at_univ] with mfld_simps at H,\n    simpa [local_homeomorph.right_inv _ hz] using H.2, },\n  -- `f` pulled back by the chart at `p` has a local max at `chart_at E p p`\n  have hf'' : is_local_max (norm ∘ f ∘ (chart_at E p).symm) (chart_at E p p),\n  { refine filter.eventually_of_mem key₁ (λ z hz, _),\n    refine (hp₀ ((chart_at E p).symm z) hz).trans (_ : ‖f p₀‖ ≤ ‖f _‖),\n    rw [← hp, local_homeomorph.left_inv _ (mem_chart_source E p)] },\n  -- so by the maximum principle `f` is equal to `f p` near `p`\n  obtain ⟨U, hU, hUf⟩ := (complex.eventually_eq_of_is_local_max_norm hf' hf'').exists_mem,\n  have H₁ : (chart_at E p) ⁻¹' U ∈ 𝓝 p := (chart_at E p).continuous_at (mem_chart_source E p) hU,\n  have H₂ : (chart_at E p).source ∈ 𝓝 p :=\n    (local_homeomorph.open_source _).mem_nhds (mem_chart_source E p),\n  apply filter.mem_of_superset (filter.inter_mem hps' (filter.inter_mem H₁ H₂)),\n  rintros q ⟨hqs, hq : chart_at E p q ∈ _, hq'⟩,\n  refine ⟨_, hqs⟩,\n  simpa [local_homeomorph.left_inv _ hq', hp, -norm_eq_abs] using hUf (chart_at E p q) hq,\nend\n\n/-- A holomorphic function on a compact connected complex manifold is constant. -/\nlemma apply_eq_of_compact_space [preconnected_space M]\n  {f : M → F} (hf : mdifferentiable 𝓘(ℂ, E) 𝓘(ℂ, F) f) (a b : M) :\n  f a = f b :=\nhf.is_locally_constant.apply_eq_of_preconnected_space _ _\n\n/-- A holomorphic function on a compact connected complex manifold is the constant function `f ≡ v`,\nfor some value `v`. -/\nlemma exists_eq_const_of_compact_space [preconnected_space M]\n  {f : M → F} (hf : mdifferentiable 𝓘(ℂ, E) 𝓘(ℂ, F) f) :\n  ∃ v : F, f = function.const M v :=\nhf.is_locally_constant.exists_eq_const\n\nend mdifferentiable\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/geometry/manifold/complex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.49553269101901637}}
{"text": "import Monads.Functor\n\nnamespace Monads\n  /- Applicative functors allow us to apply functions that are already\n     wrapped withing the functor to other values wrapped withing the functor.\n     This allows chaining of methods like so: f <$> g <*> h <*> x. -/\n  class Applicative (f : Type u → Type v) extends Functor f where\n    /- Lift a normal value into an applicative context. -/\n    pure : α → f α\n    /- Apply a function inside an applicative to a value inside an applicative. -/\n    apply : ∀ {α β : Type u}, f (α → β) → f α → f β\n    /- Lift a funcion of arity 2 (2 parameters) to the applicative context. -/\n    liftA2 : (α → β → γ) → f α → f β → f γ := λ g x y => apply (g <$> x) y\n    /- Drop the action on the left and only return the right one. If\n       left contains e.g. a sideffect it will still be executed. -/\n    seq_right : f α → f β → f β := λ a1 a2 => apply (id <$ a1) a2\n    /- Drop the action on the right and only return the left one. If\n       right contains e.g. a sideffect it will still be executed. -/\n    seq_left : f α → f β → f α := liftA2 (Function.const β)\n\n  export Applicative (pure liftA2)\n\n  infixl:60 \" <*> \" => Monads.Applicative.apply\n  -- The arrow points at the value that is kept\n  infixl:60 \" *> \" => Monads.Applicative.seq_right\n  infixl:60 \" <* \" => Monads.Applicative.seq_left\n\n\n  /- Lawful applicatives essentially capture the same concept of modifying\n     only the contents and not the context they are captured in as a lawful\n     regular functor. -/\n  class LawfulApplicative (f : Type u → Type v) [app: Applicative f] extends LawfulFunctor f : Prop where\n    /- If the function maps values to themselves the values in the applicative\n       shall remain unchanged. -/\n    apply_id : ∀ x : f α, pure id <*> x = x\n    /- Applying a pure function to a pure value with <*> shall be the\n       same as first applying them outside of the applicative and wrapping\n       the result into it. -/\n    apply_homomorphism: ∀ (x : α) (g : α → β), pure g <*> app.pure x = pure (g x)\n    /- Applying an effectful function to a pure value should yield the same result,\n       regardless of order. -/\n    apply_interchange: ∀ {α β : Type u} (x : α) (g : f (α → β)), g <*> pure x = pure (· $ x) <*> g\n    /- A modified associativity property for <*>. -/\n    apply_comp : ∀ {α β γ: Type u} (x : f (β → γ)) (y : f (α → β)) (z : f α), pure (@Function.comp α β γ) <*> x <*> y <*> z = x <*> (y <*> z)\n    /- If there is a custom liftA2 definition it has to behave like the default one -/\n    lifta2_behaved : ∀ (g : α → β → γ) (x : f α) (y : f β), liftA2 g x y = g <$> x <*> y \n    /- If there is a custom *> definition it has to behave like the default one -/\n    seq_right_behaved : ∀ (a1 : f α) (a2 : f β), a1 *> a2 = (id <$ a1) <*> a2\n    /- If there is a custom <* definition it has to behave like the default one -/\n    seq_left_behaved : ∀ (a1 : f α) (a2 : f β), a1 <* a2 = liftA2 (Function.const β) a1 a2\n    /- This law is rather intuitive and provable with the free theorem in Haskell.\n       However I'm unsure whether it applies in lean and no formalization exists,\n       hence it will be an axiom. (Mathlib does this too). Furthermore it is shown\n       below that the right hand side is a lawful functor. -/\n    fmap_eq_pure_apply : ∀ (g : α → β) (x : f α), g <$> x = app.pure g <*> x\n\n\n  namespace LawfulApplicative\n    variable {f : Type u → Type v} [Applicative f] [LawfulApplicative f]\n    -- These 4 laws allow us to prove equality of any term involving only <*> or pure (if they are equal)\n    example {α β : Type u} {g : f (α → β)} {x : f α} : g <*> (pure id <*> x) = g <*> x := by rw [apply_id]\n    example {α β : Type u} {g : f (α → β)} {x : f α} : pure id <*> (g <*> x) = g <*> x := by rw [apply_id]\n    example {α β γ δ ε: Type u} {h : f (δ → ε)}{g : α → β → γ → δ} {x : α} { y : β} { z : γ} : h <*> (pure g <*> pure x <*> pure y <*> pure z) = h <*> pure (g x y z) := by\n      simp only [apply_homomorphism]\n\n    -- Constructing a lawful functor from a lawful applicative\n    def apply_fmap : (α → β) → f α → f β := λ g a => pure g <*> a\n\n    -- First law\n    example : ∀ {α : Type u} (x : f α), apply_fmap id x = x := by\n      intro α x\n      simp only [apply_fmap]\n      rw [apply_id]\n\n    -- Second law\n    example : ∀ {α β γ : Type u} (g : α → β) (h : β → γ) (x : f α), apply_fmap (h ∘ g) x = apply_fmap h (apply_fmap g x) := by\n      intro α β γ g h x\n      simp only [apply_fmap]\n      rw [←apply_comp]\n      rw [apply_homomorphism]\n      rw [apply_homomorphism]\n  end LawfulApplicative\nend Monads\n", "meta": {"author": "hargoniX", "repo": "lean-monads", "sha": "2e87ca7ddf394641ea1b16bcbd8c384026d68e2f", "save_path": "github-repos/lean/hargoniX-lean-monads", "path": "github-repos/lean/hargoniX-lean-monads/lean-monads-2e87ca7ddf394641ea1b16bcbd8c384026d68e2f/Monads/Applicative.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.49553269068257105}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.wf\nimport Mathlib.Lean3Lib.init.data.nat.basic\n \n\nnamespace Mathlib\n\nnamespace nat\n\n\nprotected def div (x : ℕ) : ℕ → ℕ :=\n  well_founded.fix lt_wf div.F\n\nprotected instance has_div : Div ℕ :=\n  { div := nat.div }\n\ntheorem div_def_aux (x : ℕ) (y : ℕ) : x / y = dite (0 < y ∧ y ≤ x) (fun (h : 0 < y ∧ y ≤ x) => (x - y) / y + 1) fun (h : ¬(0 < y ∧ y ≤ x)) => 0 :=\n  congr_fun (well_founded.fix_eq lt_wf div.F x) y\n\nprotected def mod (x : ℕ) : ℕ → ℕ :=\n  well_founded.fix lt_wf mod.F\n\nprotected instance has_mod : Mod ℕ :=\n  { mod := nat.mod }\n\ntheorem mod_def_aux (x : ℕ) (y : ℕ) : x % y = dite (0 < y ∧ y ≤ x) (fun (h : 0 < y ∧ y ≤ x) => (x - y) % y) fun (h : ¬(0 < y ∧ y ≤ x)) => x :=\n  congr_fun (well_founded.fix_eq lt_wf mod.F x) y\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/data/nat/div.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789040926008, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.49551219169741534}}
{"text": "/-\nCopyright (c) 2021 OpenAI. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f\n-/\nimport mathzoo.imports.miniF2F\n\nopen_locale nat rat real big_operators topological_space\n\ntheorem algebra_manipexpr_apbeq2cceqiacpbceqm2\n  (a b c : ℂ)\n  (h₀ : a + b = 2 * c)\n  (h₁ : c = complex.I) :\n  a * c + b * c = -2 :=\nbegin\n  rw [← add_mul, h₀, h₁, mul_assoc, complex.I_mul_I],\n  ring,\nend", "meta": {"author": "leanprover-community", "repo": "mathzoo", "sha": "87e9b492daeb929838706942aaa2437621b34a0e", "save_path": "github-repos/lean/leanprover-community-mathzoo", "path": "github-repos/lean/leanprover-community-mathzoo/mathzoo-87e9b492daeb929838706942aaa2437621b34a0e/src/mathzoo/misc/miniF2F/algebra/manipexpr_apbeq2cceqiacpbceqm2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104788995148792, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.49551218889867876}}
{"text": "/-\nCopyright (c) 2014 Parikshit Khanna. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro\n\n! This file was ported from Lean 3 source module data.list.defs\n! leanprover-community/mathlib commit 1fc36cc9c8264e6e81253f88be7fb2cb6c92d76a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Group.Defs\nimport Mathlib.Control.Functor\nimport Mathlib.Data.Nat.Basic\nimport Mathlib.Logic.Basic\nimport Std.Tactic.Lint.Basic\nimport Std.Data.RBMap.Basic\n\n/-!\n## Definitions on lists\n\nThis file contains various definitions on lists. It does not contain\nproofs about these definitions, those are contained in other files in `Data.List`\n-/\n\n-- Porting notes\n-- Many of the definitions in `Data.List.Defs` were already defined upstream in `Std4`\n-- These have been annotated with `#align`s\n-- To make this easier for review, the `#align`s have been placed in order of occurrence\n-- in `mathlib`\n\nnamespace List\n\nopen Function Nat\n\nsection recursor_workarounds\n/-- A computable version of `List.rec`. Workaround until Lean has native support for this. -/\ndef recC.{u_1, u} {α : Type u} {motive : List α → Sort u_1} (nil : motive [])\n  (cons : (head : α) → (tail : List α) → motive tail → motive (head :: tail)) :\n    (l : List α) → motive l\n| [] => nil\n| (x :: xs) => cons x xs (List.recC nil cons xs)\n\n@[csimp]\nlemma rec_eq_recC : @List.rec = @List.recC := by\n  ext α motive nil cons l\n  induction l with\n  | nil => rfl\n  | cons x xs ih =>\n    rw [List.recC, ←ih]\n\n/-- A computable version of `List._sizeOf_inst`. -/\ndef _sizeOf_instC.{u} (α : Type u) [SizeOf α] : SizeOf (List α) where\n  sizeOf t := List.rec 1 (fun head _ tail_ih => 1 + SizeOf.sizeOf head + tail_ih) t\n\n@[csimp]\nlemma _sizeOfinst_eq_sizeOfinstC : @List._sizeOf_inst = @List._sizeOf_instC := by\n  simp [List._sizeOf_1, List._sizeOf_instC, _sizeOf_inst]\n\nend recursor_workarounds\n\nuniverse u v w x\n\nvariable {α β γ δ ε ζ : Type _}\n\ninstance [DecidableEq α] : SDiff (List α) :=\n  ⟨List.diff⟩\n\n#align list.split_at List.splitAt\n#align list.split_on_p List.splitOnP\n#align list.split_on List.splitOn\n#align list.concat List.concat\n#align list.head' List.head?\n#align list.to_array List.toArray\n#align list.nthd List.getD\n-- porting notes: see\n-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/List.2Ehead/near/313204716\n-- for the fooI naming convention.\n/-- \"Inhabited\" `get` function: returns `default` instead of `none` in the case\n  that the index is out of bounds. -/\ndef getI [Inhabited α] (l : List α) (n : Nat) : α :=\n  getD l n default\n#align list.inth List.getI\n\n/-- \"Inhabited\" `take` function: Take `n` elements from a list `l`. If `l` has less than `n`\n  elements, append `n - length l` elements `default`. -/\ndef takeI [Inhabited α] (n : Nat) (l : List α) : List α :=\n  takeD n l default\n#align list.take' List.takeI\n\n#align list.modify_nth_tail List.modifyNthTail\n#align list.modify_head List.modifyHead\n#align list.modify_nth List.modifyNth\n#align list.modify_last List.modifyLast\n#align list.insert_nth List.insertNth\n#align list.take_while List.takeWhile\n#align list.scanl List.scanl\n#align list.scanr List.scanr\n\n/-- Product of a list.\n\n     `prod [a, b, c] = ((1 * a) * b) * c` -/\ndef prod [Mul α] [One α] : List α → α :=\n  foldl (· * ·) 1\n#align list.prod List.prod\n\n-- Later this will be tagged with `to_additive`, but this can't be done yet because of imports.\n-- dependencies.\n/-- Sum of a list.\n\n     `sum [a, b, c] = ((0 + a) + b) + c` -/\ndef sum [Add α] [Zero α] : List α → α :=\n  foldl (· + ·) 0\n#align list.sum List.sum\n\n/-- The alternating sum of a list. -/\ndef alternatingSum {G : Type _} [Zero G] [Add G] [Neg G] : List G → G\n  | [] => 0\n  | g :: [] => g\n  | g :: h :: t => g + -h + alternatingSum t\n#align list.alternating_sum List.alternatingSum\n\n/-- The alternating product of a list. -/\ndef alternatingProd {G : Type _} [One G] [Mul G] [Inv G] : List G → G\n  | [] => 1\n  | g :: [] => g\n  | g :: h :: t => g * h⁻¹ * alternatingProd t\n#align list.alternating_prod List.alternatingProd\n\n#align list.partition_map List.partitionMap\n#align list.find List.find?\n\n/-- `findM tac l` returns the first element of `l` on which `tac` succeeds, and\nfails otherwise. -/\ndef findM {α} {m : Type u → Type v} [Alternative m] (tac : α → m PUnit) : List α → m α :=\n  List.firstM <| fun a => (tac a) $> a\n#align list.mfind List.findM\n\n/-- `findM? p l` returns the first element `a` of `l` for which `p a` returns\ntrue. `findM?` short-circuits, so `p` is not necessarily run on every `a` in\n`l`. This is a monadic version of `List.find`. -/\ndef findM?'\n    {m : Type u → Type v}\n    [Monad m] {α : Type u}\n    (p : α → m (ULift Bool)) : List α → m (Option α)\n  | [] => pure none\n  | x :: xs => do\n    let ⟨px⟩ ← p x\n    if px then pure (some x) else findM?' p xs\n#align list.mbfind' List.findM?'\n\n#align list.mbfind List.findM?\n#align list.many List.anyM\n#align list.mall List.allM\n\nsection\n\nvariable {m : Type → Type v} [Monad m]\n\n/-- `orM xs` runs the actions in `xs`, returning true if any of them returns\ntrue. `orM` short-circuits, so if an action returns true, later actions are\nnot run. -/\ndef orM : List (m Bool) → m Bool :=\n  anyM id\n#align list.mbor List.orM\n\n/-- `andM xs` runs the actions in `xs`, returning true if all of them return\ntrue. `andM` short-circuits, so if an action returns false, later actions are\nnot run. -/\ndef andM : List (m Bool) → m Bool :=\n  allM id\n#align list.mband List.andM\n\nend\n\n#align list.foldr_with_index List.foldrIdx\n#align list.foldl_with_index List.foldlIdx\n#align list.find_indexes List.findIdxs\n#align list.indexes_values List.indexesValues\n#align list.indexes_of List.indexesOf\n\nsection foldIdxM\n\nvariable {m : Type v → Type w} [Monad m]\n\n/-- Monadic variant of `foldlIdx`. -/\ndef foldlIdxM {α β} (f : ℕ → β → α → m β) (b : β) (as : List α) : m β :=\n  as.foldlIdx\n    (fun i ma b => do\n      let a ← ma\n      f i a b)\n    (pure b)\n#align list.mfoldl_with_index List.foldlIdxM\n\n/-- Monadic variant of `foldrIdx`. -/\ndef foldrIdxM {α β} (f : ℕ → α → β → m β) (b : β) (as : List α) : m β :=\n  as.foldrIdx\n    (fun i a mb => do\n      let b ← mb\n      f i a b)\n    (pure b)\n#align list.mfoldr_with_index List.foldrIdxM\n\nend foldIdxM\n\n\nsection mapIdxM\n\n-- porting notes: This was defined in `mathlib` with an `Applicative`\n-- constraint on `m` and have been `#align`ed to the `Std` versions defined\n-- with a `Monad` typeclass constraint.\n-- Since all `Monad`s are `Applicative` this won't cause issues\n-- downstream & `Monad`ic code is more performant per Mario C\n-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Applicative.20variants.20of.20Monadic.20functions/near/313213172\n#align list.mmap_with_index List.mapIdxM\n\nvariable {m : Type v → Type w} [Monad m]\n\n/-- Auxiliary definition for `mapIdxM'`. -/\ndef mapIdxMAux' {α} (f : ℕ → α → m PUnit) : ℕ → List α → m PUnit\n  | _, [] => pure ⟨⟩\n  | i, a :: as => f i a *> mapIdxMAux' f (i + 1) as\n#align list.mmap_with_index'_aux List.mapIdxMAux'\n\n/-- A variant of `mapIdxM` specialised to applicative actions which\nreturn `unit`. -/\ndef mapIdxM' {α} (f : ℕ → α → m PUnit) (as : List α) : m PUnit :=\n  mapIdxMAux' f 0 as\n#align list.mmap_with_index' List.mapIdxM'\n\nend mapIdxM\n\n#align list.lookmap List.lookmap\n#align list.countp List.countp\n#align list.count List.count\n#align list.is_prefix List.isPrefix\n#align list.is_suffix List.isSuffix\n#align list.is_infix List.isInfix\n#align list.inits List.inits\n#align list.tails List.tails\n#align list.sublists' List.sublists'\n#align list.sublists List.sublists\n#align list.forall₂ List.Forall₂\n\n/-- `l.all₂ p` is equivalent to `∀ a ∈ l, p a`, but unfolds directly to a conjunction, i.e.\n`list.all₂ p [0, 1, 2] = p 0 ∧ p 1 ∧ p 2`. -/\n@[simp]\ndef All₂ (p : α → Prop) : List α → Prop\n  | [] => True\n  | x :: [] => p x\n  | x :: l => p x ∧ All₂ p l\n#align list.all₂ List.All₂\n\n#align list.transpose List.transpose\n#align list.sections List.sections\n\nsection Permutations\n\n/-- An auxiliary function for defining `permutations`. `permutationsAux2 t ts r ys f` is equal to\n`(ys ++ ts, (insert_left ys t ts).map f ++ r)`, where `insert_left ys t ts` (not explicitly\ndefined) is the list of lists of the form `insert_nth n t (ys ++ ts)` for `0 ≤ n < length ys`.\n\n    permutations_aux2 10 [4, 5, 6] [] [1, 2, 3] id =\n      ([1, 2, 3, 4, 5, 6],\n       [[10, 1, 2, 3, 4, 5, 6],\n        [1, 10, 2, 3, 4, 5, 6],\n        [1, 2, 10, 3, 4, 5, 6]]) -/\ndef permutationsAux2 (t : α) (ts : List α) (r : List β) : List α → (List α → β) → List α × List β\n  | [], _ => (ts, r)\n  | y :: ys, f =>\n    let (us, zs) := permutationsAux2 t ts r ys (fun x: List α => f (y :: x))\n    (y :: us, f (t :: y :: us) :: zs)\n#align list.permutations_aux2 List.permutationsAux2\n\n-- porting note: removed `[elab_as_elim]` per Mario C\n-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Status.20of.20data.2Elist.2Edefs.3F/near/313571979\n/-- A recursor for pairs of lists. To have `C l₁ l₂` for all `l₁`, `l₂`, it suffices to have it for\n`l₂ = []` and to be able to pour the elements of `l₁` into `l₂`. -/\ndef permutationsAux.rec {C : List α → List α → Sort v} (H0 : ∀ is, C [] is)\n    (H1 : ∀ t ts is, C ts (t :: is) → C is [] → C (t :: ts) is) : ∀ l₁ l₂, C l₁ l₂\n  | [], is => H0 is\n  | t :: ts, is =>\n      H1 t ts is (permutationsAux.rec H0 H1 ts (t :: is)) (permutationsAux.rec H0 H1 is [])\n  termination_by _ ts is => (length ts + length is, length ts)\n  decreasing_by simp_wf; simp [Nat.succ_add]; decreasing_tactic\n#align list.permutations_aux.rec List.permutationsAux.rec\n\n/-- An auxiliary function for defining `permutations`. `permutationsAux ts is` is the set of all\npermutations of `is ++ ts` that do not fix `ts`. -/\ndef permutationsAux : List α → List α → List (List α) :=\n  permutationsAux.rec (fun _ => []) fun t ts is IH1 IH2 =>\n    foldr (fun y r => (permutationsAux2 t ts r y id).2) IH1 (is :: IH2)\n#align list.permutations_aux List.permutationsAux\n\n/-- List of all permutations of `l`.\n\n     permutations [1, 2, 3] =\n       [[1, 2, 3], [2, 1, 3], [3, 2, 1],\n        [2, 3, 1], [3, 1, 2], [1, 3, 2]] -/\ndef permutations (l : List α) : List (List α) :=\n  l :: permutationsAux l []\n#align list.permutations List.permutations\n\n/-- `permutations'Aux t ts` inserts `t` into every position in `ts`, including the last.\nThis function is intended for use in specifications, so it is simpler than `permutationsAux2`,\nwhich plays roughly the same role in `permutations`.\n\nNote that `(permutationsAux2 t [] [] ts id).2` is similar to this function, but skips the last\nposition:\n\n    permutations'Aux 10 [1, 2, 3] =\n      [[10, 1, 2, 3], [1, 10, 2, 3], [1, 2, 10, 3], [1, 2, 3, 10]]\n    (permutationsAux2 10 [] [] [1, 2, 3] id).2 =\n      [[10, 1, 2, 3], [1, 10, 2, 3], [1, 2, 10, 3]] -/\n@[simp]\ndef permutations'Aux (t : α) : List α → List (List α)\n  | [] => [[t]]\n  | y :: ys => (t :: y :: ys) :: (permutations'Aux t ys).map (cons y)\n#align list.permutations'_aux List.permutations'Aux\n\n/-- List of all permutations of `l`. This version of `permutations` is less efficient but has\nsimpler definitional equations. The permutations are in a different order,\nbut are equal up to permutation, as shown by `list.permutations_perm_permutations'`.\n\n     permutations [1, 2, 3] =\n       [[1, 2, 3], [2, 1, 3], [2, 3, 1],\n        [1, 3, 2], [3, 1, 2], [3, 2, 1]] -/\n@[simp]\ndef permutations' : List α → List (List α)\n  | [] => [[]]\n  | t :: ts => (permutations' ts).bind <| permutations'Aux t\n#align list.permutations' List.permutations'\n\nend Permutations\n\n#align list.erasep List.erasePₓ -- prop -> bool\n\n/-- `extractp p l` returns a pair of an element `a` of `l` satisfying the predicate\n  `p`, and `l`, with `a` removed. If there is no such element `a` it returns `(none, l)`. -/\ndef extractp (p : α → Prop) [DecidablePred p] : List α → Option α × List α\n  | [] => (none, [])\n  | a :: l =>\n    if p a then (some a, l)\n    else\n      let (a', l') := extractp p l\n      (a', a :: l')\n#align list.extractp List.extractp\n\n#align list.revzip List.revzip\n#align list.product List.product\n/-- Notation for calculating the product of a `List`\n-/\n-- This notation binds more strongly than (pre)images, unions and intersections.\ninfixr:82 \" ×ˢ \" => List.product\n#align list.sigma List.sigma\n#align list.of_fn List.ofFn\n#align list.of_fn_nth_val List.ofFnNthVal\n#align list.disjoint List.Disjoint\n#align list.pairwise List.Pairwise\n#align list.pairwise_cons List.pairwise_cons\n#align list.decidable_pairwise List.instDecidablePairwise\n#align list.pw_filter List.pwFilter\n#align list.chain List.Chain\n#align list.chain' List.Chain'\n\nsection Chain\n\n@[simp]\ntheorem chain_cons {a b : α} {l : List α} : Chain R a (b :: l) ↔ R a b ∧ Chain R b l :=\n  ⟨fun p ↦ by cases p with | cons n p => exact ⟨n, p⟩,\n   fun ⟨n, p⟩ ↦ p.cons n⟩\n#align list.chain_cons List.chain_cons\n\ninstance decidableChain [DecidableRel R] (a : α) (l : List α) :\n    Decidable (Chain R a l) := by\n  induction l generalizing a with\n  | nil => simp only [List.Chain.nil]; infer_instance\n  | cons a as ih => haveI := ih; simp only [List.chain_cons]; infer_instance\n#align list.decidable_chain List.decidableChain\n\ninstance decidableChain' [DecidableRel R] (l : List α) : Decidable (Chain' R l) := by\n  cases l <;> dsimp only [List.Chain'] <;> infer_instance\n#align list.decidable_chain' List.decidableChain'\n\nend Chain\n\n#align list.nodup List.Nodup\n#align list.nodup_decidable List.nodupDecidable\n\n/-- `dedup l` removes duplicates from `l` (taking only the last occurrence).\n  Defined as `pwFilter (≠)`.\n\n     dedup [1, 0, 2, 2, 1] = [0, 2, 1] -/\ndef dedup [DecidableEq α] : List α → List α :=\n  pwFilter (· ≠ ·)\n#align list.dedup List.dedup\n\n/-- Greedily create a sublist of `a :: l` such that, for every two adjacent elements `a, b`,\n`R a b` holds. Mostly used with ≠; for example, `destutter' (≠) 1 [2, 2, 1, 1] = [1, 2, 1]`,\n`destutter' (≠) 1, [2, 3, 3] = [1, 2, 3]`, `destutter' (<) 1 [2, 5, 2, 3, 4, 9] = [1, 2, 5, 9]`. -/\ndef destutter' (R : α → α → Prop) [DecidableRel R] : α → List α → List α\n  | a, [] => [a]\n  | a, h :: l => if R a h then a :: destutter' R h l else destutter' R a l\n#align list.destutter' List.destutter'\n\n-- TODO: should below be \"lazily\"?\n/-- Greedily create a sublist of `l` such that, for every two adjacent elements `a, b ∈ l`,\n`R a b` holds. Mostly used with ≠; for example, `destutter (≠) [1, 2, 2, 1, 1] = [1, 2, 1]`,\n`destutter (≠) [1, 2, 3, 3] = [1, 2, 3]`, `destutter (<) [1, 2, 5, 2, 3, 4, 9] = [1, 2, 5, 9]`. -/\ndef destutter (R : α → α → Prop) [DecidableRel R] : List α → List α\n  | h :: l => destutter' R h l\n  | [] => []\n#align list.destutter List.destutter\n\n#align list.range' List.range'\n#align list.reduce_option List.reduceOption\n-- Porting note: replace ilast' by getLastD\n#align list.ilast' List.ilast'\n-- Porting note: remove last' from Std\n#align list.last' List.getLast?\n#align list.rotate List.rotate\n#align list.rotate' List.rotate'\n\n\nsection Choose\n\nvariable (p : α → Prop) [DecidablePred p] (l : List α)\n\n/-- Given a decidable predicate `p` and a proof of existence of `a ∈ l` such that `p a`,\nchoose the first element with this property. This version returns both `a` and proofs\nof `a ∈ l` and `p a`. -/\ndef chooseX : ∀ l : List α, ∀ _ : ∃ a, a ∈ l ∧ p a, { a // a ∈ l ∧ p a }\n  | [], hp => False.elim (Exists.elim hp fun a h => not_mem_nil a h.left)\n  | l :: ls, hp =>\n    if pl : p l then ⟨l, ⟨mem_cons.mpr <| Or.inl rfl, pl⟩⟩\n    else\n      let ⟨a, ⟨a_mem_ls, pa⟩⟩ :=\n        chooseX ls\n          (hp.imp fun _ ⟨o, h₂⟩ => ⟨(mem_cons.mp o).resolve_left fun e => pl <| e ▸ h₂, h₂⟩)\n      ⟨a, ⟨mem_cons.mpr <| Or.inr a_mem_ls, pa⟩⟩\n#align list.choose_x List.chooseX\n\n/-- Given a decidable predicate `p` and a proof of existence of `a ∈ l` such that `p a`,\nchoose the first element with this property. This version returns `a : α`, and properties\nare given by `choose_mem` and `choose_property`. -/\ndef choose (hp : ∃ a, a ∈ l ∧ p a) : α :=\n  chooseX p l hp\n#align list.choose List.choose\n\nend Choose\n\n#align list.mmap_filter List.filterMapM\n#align list.mmap_upper_triangle List.mapDiagM\n\n/-- `mapDiagM' f l` calls `f` on all elements in the upper triangular part of `l × l`.\nThat is, for each `e ∈ l`, it will run `f e e` and then `f e e'`\nfor each `e'` that appears after `e` in `l`.\n\nExample: suppose `l = [1, 2, 3]`. `mapDiagM' f l` will evaluate, in this order,\n`f 1 1`, `f 1 2`, `f 1 3`, `f 2 2`, `f 2 3`, `f 3 3`.\n-/\ndef mapDiagM' {m} [Monad m] {α} (f : α → α → m Unit) : List α → m Unit\n-- as ported:\n--   | [] => return ()\n--   | h :: t => (f h h >> t.mapM' (f h)) >> t.mapDiagM'\n  | [] => return ()\n  | h :: t => do\n    _ ← f h h\n    _ ← t.mapM' (f h)\n    t.mapDiagM' f\n#align list.mmap'_diag List.mapDiagM'\n\n/-- Map each element of a `List` to an action, evaluate these actions in order,\n    and collect the results.\n-/\nprotected def traverse {F : Type u → Type v} [Applicative F] {α β : Type _} (f : α → F β)\n    : List α → F (List β)\n  | [] => pure []\n  | x :: xs => List.cons <$> f x <*> List.traverse f xs\n#align list.traverse List.traverse\n\n#align list.get_rest List.getRest\n#align list.slice List.dropSlice\n\n/-- Left-biased version of `List.map₂`. `map₂Left' f as bs` applies `f` to each\npair of elements `aᵢ ∈ as` and `bᵢ ∈ bs`. If `bs` is shorter than `as`, `f` is\napplied to `none` for the remaining `aᵢ`. Returns the results of the `f`\napplications and the remaining `bs`.\n\n```\nmap₂Left' prod.mk [1, 2] ['a'] = ([(1, some 'a'), (2, none)], [])\n\nmap₂Left' prod.mk [1] ['a', 'b'] = ([(1, some 'a')], ['b'])\n```\n-/\n@[simp]\ndef map₂Left' (f : α → Option β → γ) : List α → List β → List γ × List β\n  | [], bs => ([], bs)\n  | a :: as, [] => ((a :: as).map fun a => f a none, [])\n  | a :: as, b :: bs =>\n    let rec' := map₂Left' f as bs\n    (f a (some b) :: rec'.fst, rec'.snd)\n#align list.map₂_left' List.map₂Left'\n\n/-- Right-biased version of `List.map₂`. `map₂Right' f as bs` applies `f` to each\npair of elements `aᵢ ∈ as` and `bᵢ ∈ bs`. If `as` is shorter than `bs`, `f` is\napplied to `none` for the remaining `bᵢ`. Returns the results of the `f`\napplications and the remaining `as`.\n\n```\nmap₂Right' prod.mk [1] ['a', 'b'] = ([(some 1, 'a'), (none, 'b')], [])\n\nmap₂Right' prod.mk [1, 2] ['a'] = ([(some 1, 'a')], [2])\n```\n-/\ndef map₂Right' (f : Option α → β → γ) (as : List α) (bs : List β) : List γ × List α :=\n  map₂Left' (flip f) bs as\n#align list.map₂_right' List.map₂Right'\n\n\n/-- Left-biased version of `List.map₂`. `map₂Left f as bs` applies `f` to each pair\n`aᵢ ∈ as` and `bᵢ ‌∈ bs`. If `bs` is shorter than `as`, `f` is applied to `none`\nfor the remaining `aᵢ`.\n\n```\nmap₂Left Prod.mk [1, 2] ['a'] = [(1, some 'a'), (2, none)]\n\nmap₂Left Prod.mk [1] ['a', 'b'] = [(1, some 'a')]\n\nmap₂Left f as bs = (map₂Left' f as bs).fst\n```\n-/\n@[simp]\ndef map₂Left (f : α → Option β → γ) : List α → List β → List γ\n  | [], _ => []\n  | a :: as, [] => (a :: as).map fun a => f a none\n  | a :: as, b :: bs => f a (some b) :: map₂Left f as bs\n#align list.map₂_left List.map₂Left\n\n/-- Right-biased version of `List.map₂`. `map₂Right f as bs` applies `f` to each\npair `aᵢ ∈ as` and `bᵢ ‌∈ bs`. If `as` is shorter than `bs`, `f` is applied to\n`none` for the remaining `bᵢ`.\n\n```\nmap₂Right Prod.mk [1, 2] ['a'] = [(some 1, 'a')]\n\nmap₂Right Prod.mk [1] ['a', 'b'] = [(some 1, 'a'), (none, 'b')]\n\nmap₂Right f as bs = (map₂Right' f as bs).fst\n```\n-/\ndef map₂Right (f : Option α → β → γ) (as : List α) (bs : List β) : List γ :=\n  map₂Left (flip f) bs as\n#align list.map₂_right List.map₂Right\n\n#align list.zip_right List.zipRight\n#align list.zip_left' List.zipLeft'\n#align list.zip_right' List.zipRight'\n#align list.zip_left List.zipLeft\n#align list.all_some List.allSome\n#align list.fill_nones List.fillNones\n#align list.take_list List.takeList\n#align list.to_rbmap List.toRBMap\n#align list.to_chunks_aux List.toChunksAux\n#align list.to_chunks List.toChunks\n\n-- porting notes -- was `unsafe` but removed for Lean 4 port\n-- TODO: naming is awkward...\n/-- Asynchronous version of `List.map`.\n-/\ndef mapAsyncChunked {α β} (f : α → β) (xs : List α) (chunk_size := 1024) : List β :=\n  ((xs.toChunks chunk_size).map fun xs => Task.spawn fun _ => List.map f xs).bind Task.get\n#align list.map_async_chunked List.mapAsyncChunked\n\n\n/-!\nWe add some n-ary versions of `List.zipWith` for functions with more than two arguments.\nThese can also be written in terms of `List.zip` or `List.zipWith`.\nFor example, `zipWith3 f xs ys zs` could also be written as\n`zipWith id (zipWith f xs ys) zs`\nor as\n`(zip xs $ zip ys zs).map $ λ ⟨x, y, z⟩, f x y z`.\n-/\n\n/-- Ternary version of `List.zipWith`. -/\ndef zipWith3 (f : α → β → γ → δ) : List α → List β → List γ → List δ\n  | x :: xs, y :: ys, z :: zs => f x y z :: zipWith3 f xs ys zs\n  | _, _, _ => []\n#align list.zip_with3 List.zipWith3\n\n/-- Quaternary version of `list.zipWith`. -/\ndef zipWith4 (f : α → β → γ → δ → ε) : List α → List β → List γ → List δ → List ε\n  | x :: xs, y :: ys, z :: zs, u :: us => f x y z u :: zipWith4 f xs ys zs us\n  | _, _, _, _ => []\n#align list.zip_with4 List.zipWith4\n\n/-- Quinary version of `list.zipWith`. -/\ndef zipWith5 (f : α → β → γ → δ → ε → ζ) : List α → List β → List γ → List δ → List ε → List ζ\n  | x :: xs, y :: ys, z :: zs, u :: us, v :: vs => f x y z u v :: zipWith5 f xs ys zs us vs\n  | _, _, _, _, _ => []\n#align list.zip_with5 List.zipWith5\n\n/-- Given a starting list `old`, a list of booleans and a replacement list `new`,\nread the items in `old` in succession and either replace them with the next element of `new` or\nnot, according as to whether the corresponding boolean is `true` or `false`. -/\ndef replaceIf : List α → List Bool → List α → List α\n  | l, _, [] => l\n  | [], _, _ => []\n  | l, [], _ => l\n  | n :: ns, tf :: bs, e@(c :: cs) => if tf then c :: ns.replaceIf bs cs else n :: ns.replaceIf bs e\n#align list.replace_if List.replaceIf\n\n#align list.map_with_prefix_suffix_aux List.mapWithPrefixSuffixAux\n#align list.map_with_prefix_suffix List.mapWithPrefixSuffix\n#align list.map_with_complement List.mapWithComplement\n\n\nend List\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/List/Defs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7690802476562641, "lm_q1q2_score": 0.49546080444292034}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport geometry.manifold.smooth_manifold_with_corners\nimport analysis.inner_product_space.pi_L2\n\n/-!\n# Constructing examples of manifolds over ℝ\n\nWe introduce the necessary bits to be able to define manifolds modelled over `ℝ^n`, boundaryless\nor with boundary or with corners. As a concrete example, we construct explicitly the manifold with\nboundary structure on the real interval `[x, y]`.\n\nMore specifically, we introduce\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)` for the model space\n  used to define `n`-dimensional real manifolds with boundary\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n)` for the model space used\n  to define `n`-dimensional real manifolds with corners\n\n## Notations\n\nIn the locale `manifold`, we introduce the notations\n* `𝓡 n` for the identity model with corners on `euclidean_space ℝ (fin n)`\n* `𝓡∂ n` for `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space ℝ (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M → N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (𝓡 m) (𝓡∂ n) f` (as to why the\nmodel with corners can not be implicit, see the discussion in `smooth_manifold_with_corners.lean`).\n\n## Implementation notes\n\nThe manifold structure on the interval `[x, y] = Icc x y` requires the assumption `x < y` as a\ntypeclass. We provide it as `[fact (x < y)]`.\n-/\n\nnoncomputable theory\nopen set function\nopen_locale manifold\n\n/--\nThe half-space in `ℝ^n`, used to model manifolds with boundary. We only define it when\n`1 ≤ n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : ℕ) [has_zero (fin n)] : Type :=\n{x : euclidean_space ℝ (fin n) // 0 ≤ x 0}\n\n/--\nThe quadrant in `ℝ^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : ℕ) : Type := {x : euclidean_space ℝ (fin n) // ∀i:fin n, 0 ≤ x i}\n\nsection\n/- Register class instances for euclidean half-space and quadrant, that can not be noticed\nwithout the following reducibility attribute (which is only set in this section). -/\nlocal attribute [reducible] euclidean_half_space euclidean_quadrant\nvariable {n : ℕ}\n\ninstance [has_zero (fin n)] : topological_space (euclidean_half_space n) := by apply_instance\ninstance : topological_space (euclidean_quadrant n) := by apply_instance\ninstance [has_zero (fin n)] : inhabited (euclidean_half_space n) := ⟨⟨0, le_rfl⟩⟩\ninstance : inhabited (euclidean_quadrant n) := ⟨⟨0, λ i, le_rfl⟩⟩\n\nlemma range_half_space (n : ℕ) [has_zero (fin n)] :\n  range (λx : euclidean_half_space n, x.val) = {y | 0 ≤ y 0} :=\nby simp\n\nlemma range_quadrant (n : ℕ) :\n  range (λx : euclidean_quadrant n, x.val) = {y | ∀i:fin n, 0 ≤ y i} :=\nby simp\n\nend\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_half_space n)`, used as\na model for manifolds with boundary. In the locale `manifold`, use the shortcut `𝓡∂ n`.\n-/\ndef model_with_corners_euclidean_half_space (n : ℕ) [has_zero (fin n)] :\n  model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := λx, ⟨update x 0 (max (x 0) 0), by simp [le_refl]⟩,\n  source      := univ,\n  target      := {x | 0 ≤ x 0},\n  map_source' := λx hx, x.property,\n  map_target' := λx hx, mem_univ _,\n  left_inv'   := λ ⟨xval, xprop⟩ hx, begin\n    rw [subtype.mk_eq_mk, update_eq_iff],\n    exact ⟨max_eq_left xprop, λ i _, rfl⟩\n  end,\n  right_inv'  := λx hx, update_eq_iff.2 ⟨max_eq_left hx, λ i _, rfl⟩,\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on ℝ _ :=\n      unique_diff_on.pi (fin n) (λ _, ℝ) _ _ (λ i ∈ ({0} : set (fin n)), unique_diff_on_Ici 0),\n    by simpa only [singleton_pi] using this,\n  continuous_to_fun  := continuous_subtype_val,\n  continuous_inv_fun := (continuous_id.update 0 $\n    (continuous_apply 0).max continuous_const).subtype_mk _ }\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : ℕ) :\n  model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := λx, ⟨λi, max (x i) 0, λi, by simp only [le_refl, or_true, le_max_iff]⟩,\n  source      := univ,\n  target      := {x | ∀ i, 0 ≤ x i},\n  map_source' := λx hx, by simpa only [subtype.range_val] using x.property,\n  map_target' := λx hx, mem_univ _,\n  left_inv'   := λ ⟨xval, xprop⟩ hx, by { ext i, simp only [subtype.coe_mk, xprop i, max_eq_left] },\n  right_inv' := λ x hx, by { ext1 i, simp only [hx i, max_eq_left] },\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on ℝ _ :=\n      unique_diff_on.univ_pi (fin n) (λ _, ℝ) _ (λ i, unique_diff_on_Ici 0),\n    by simpa only [pi_univ_Ici] using this,\n  continuous_to_fun  := continuous_subtype_val,\n  continuous_inv_fun := continuous.subtype_mk (continuous_pi $ λ i,\n    (continuous_id.max continuous_const).comp (continuous_apply i)) _ }\n\nlocalized \"notation (name := model_with_corners_self.euclidean) `𝓡 `n :=\n  (model_with_corners_self ℝ (euclidean_space ℝ (fin n)) :\n    model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_space ℝ (fin n)))\" in manifold\nlocalized \"notation (name := model_with_corners_euclidean_half_space.euclidean) `𝓡∂ `n :=\n  (model_with_corners_euclidean_half_space n :\n    model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n))\" in manifold\n\n/--\nThe left chart for the topological space `[x, y]`, defined on `[x,y)` and sending `x` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_left_chart (x y : ℝ) [fact (x < y)] :\n  local_homeomorph (Icc x y) (euclidean_half_space 1) :=\n{ source      := {z : Icc x y | z.val < y},\n  target      := {z : euclidean_half_space 1 | z.val 0 < y - x},\n  to_fun      := λ(z : Icc x y), ⟨λi, z.val - x, sub_nonneg.mpr z.property.1⟩,\n  inv_fun     := λz, ⟨min (z.val 0 + x) y, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y))]⟩,\n  map_source' := by simp only [imp_self, sub_lt_sub_iff_right, mem_set_of_eq, forall_true_iff],\n  map_target' :=\n    by { simp only [min_lt_iff, mem_set_of_eq], assume z hz, left,\n         dsimp [-subtype.val_eq_coe] at hz, linarith },\n  left_inv'   := begin\n    rintros ⟨z, hz⟩ h'z,\n    simp only [mem_set_of_eq, mem_Icc] at hz h'z,\n    simp only [hz, min_eq_left, sub_add_cancel]\n  end,\n  right_inv'  := begin\n    rintros ⟨z, hz⟩ h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x + z 0 ≤ y, by linarith,\n    rw subsingleton.elim i 0,\n    simp only [A, add_comm, add_sub_cancel', min_eq_left],\n  end,\n  open_source := begin\n    have : is_open {z : ℝ | z < y} := is_open_Iio,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : ℝ | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space ℝ (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (λ _, ℝ) _ 0),\n    exact this.preimage continuous_subtype_val\n  end,\n  continuous_to_fun := begin\n    apply continuous.continuous_on,\n    apply continuous.subtype_mk,\n    have : continuous (λ (z : ℝ) (i : fin 1), z - x) :=\n      continuous.sub (continuous_pi $ λi, continuous_id) continuous_const,\n    exact this.comp continuous_subtype_val,\n  end,\n  continuous_inv_fun := begin\n    apply continuous.continuous_on,\n    apply continuous.subtype_mk,\n    have A : continuous (λ z : ℝ, min (z + x) y) :=\n      (continuous_id.add continuous_const).min continuous_const,\n    have B : continuous (λz : euclidean_space ℝ (fin 1), z 0) := continuous_apply 0,\n    exact (A.comp B).comp continuous_subtype_val\n  end }\n\n/--\nThe right chart for the topological space `[x, y]`, defined on `(x,y]` and sending `y` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_right_chart (x y : ℝ) [fact (x < y)] :\n  local_homeomorph (Icc x y) (euclidean_half_space 1) :=\n{ source      := {z : Icc x y | x < z.val},\n  target      := {z : euclidean_half_space 1 | z.val 0 < y - x},\n  to_fun      := λ(z : Icc x y), ⟨λi, y - z.val, sub_nonneg.mpr z.property.2⟩,\n  inv_fun     := λz,\n    ⟨max (y - z.val 0) x, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y)), sub_eq_add_neg]⟩,\n  map_source' := by simp only [imp_self, mem_set_of_eq, sub_lt_sub_iff_left, forall_true_iff],\n  map_target' :=\n    by { simp only [lt_max_iff, mem_set_of_eq], assume z hz, left,\n         dsimp [-subtype.val_eq_coe] at hz, linarith },\n  left_inv'   := begin\n    rintros ⟨z, hz⟩ h'z,\n    simp only [mem_set_of_eq, mem_Icc] at hz h'z,\n    simp only [hz, sub_eq_add_neg, max_eq_left, add_add_neg_cancel'_right, neg_add_rev, neg_neg]\n  end,\n  right_inv'  := begin\n    rintros ⟨z, hz⟩ h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x ≤ y - z 0, by linarith,\n    rw subsingleton.elim i 0,\n    simp only [A, sub_sub_cancel, max_eq_left],\n  end,\n  open_source := begin\n    have : is_open {z : ℝ | x < z} := is_open_Ioi,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : ℝ | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space ℝ (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (λ _, ℝ) _ 0),\n    exact this.preimage continuous_subtype_val\n  end,\n  continuous_to_fun := begin\n    apply continuous.continuous_on,\n    apply continuous.subtype_mk,\n    have : continuous (λ (z : ℝ) (i : fin 1), y - z) :=\n      continuous_const.sub (continuous_pi (λi, continuous_id)),\n    exact this.comp continuous_subtype_val,\n  end,\n  continuous_inv_fun := begin\n    apply continuous.continuous_on,\n    apply continuous.subtype_mk,\n    have A : continuous (λ z : ℝ, max (y - z) x) :=\n      (continuous_const.sub continuous_id).max continuous_const,\n    have B : continuous (λz : euclidean_space ℝ (fin 1), z 0) := continuous_apply 0,\n    exact (A.comp B).comp continuous_subtype_val\n  end }\n\n/--\nCharted space structure on `[x, y]`, using only two charts taking values in\n`euclidean_half_space 1`.\n-/\ninstance Icc_manifold (x y : ℝ) [fact (x < y)] : charted_space (euclidean_half_space 1) (Icc x y) :=\n{ atlas := {Icc_left_chart x y, Icc_right_chart x y},\n  chart_at := λz, if z.val < y then Icc_left_chart x y else Icc_right_chart x y,\n  mem_chart_source := λz, begin\n    by_cases h' : z.val < y,\n    { simp only [h', if_true],\n      exact h' },\n    { simp only [h', if_false],\n      apply lt_of_lt_of_le (fact.out (x < y)),\n      simpa only [not_lt] using h'}\n  end,\n  chart_mem_atlas := λ z, by by_cases h' : (z : ℝ) < y; simp [h'] }\n\n/--\nThe manifold structure on `[x, y]` is smooth.\n-/\ninstance Icc_smooth_manifold (x y : ℝ) [fact (x < y)] :\n  smooth_manifold_with_corners (𝓡∂ 1) (Icc x y) :=\nbegin\n  have M : cont_diff_on ℝ ∞ (λz : euclidean_space ℝ (fin 1), - z + (λi, y - x)) univ,\n  { rw cont_diff_on_univ,\n    exact cont_diff_id.neg.add cont_diff_const },\n  apply smooth_manifold_with_corners_of_cont_diff_on,\n  assume e e' he he',\n  simp only [atlas, mem_singleton_iff, mem_insert_iff] at he he',\n  /- We need to check that any composition of two charts gives a `C^∞` function. Each chart can be\n  either the left chart or the right chart, leaving 4 possibilities that we handle successively.\n  -/\n  rcases he with rfl | rfl; rcases he' with rfl | rfl,\n  { -- `e = left chart`, `e' = left chart`\n    exact (mem_groupoid_of_pregroupoid.mpr (symm_trans_mem_cont_diff_groupoid _ _ _)).1 },\n  { -- `e = left chart`, `e' = right chart`\n    apply M.congr_mono _ (subset_univ _),\n    rintro _ ⟨⟨hz₁, hz₂⟩, ⟨⟨z, hz₀⟩, rfl⟩⟩,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      update_same, max_eq_left, hz₀, lt_sub_iff_add_lt] with mfld_simps at hz₁ hz₂,\n    rw [min_eq_left hz₁.le, lt_add_iff_pos_left] at hz₂,\n    ext i,\n    rw subsingleton.elim i 0,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart, *,\n      pi_Lp.add_apply, pi_Lp.neg_apply, max_eq_left, min_eq_left hz₁.le, update_same]\n      with mfld_simps,\n    abel },\n  { -- `e = right chart`, `e' = left chart`\n    apply M.congr_mono _ (subset_univ _),\n    rintro _ ⟨⟨hz₁, hz₂⟩, ⟨z, hz₀⟩, rfl⟩,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart, max_lt_iff,\n      update_same, max_eq_left hz₀] with mfld_simps at hz₁ hz₂,\n    rw lt_sub_comm at hz₁,\n    ext i,\n    rw subsingleton.elim i 0,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      pi_Lp.add_apply, pi_Lp.neg_apply, update_same, max_eq_left, hz₀, hz₁.le] with mfld_simps,\n    abel },\n  { -- `e = right chart`, `e' = right chart`\n    exact (mem_groupoid_of_pregroupoid.mpr (symm_trans_mem_cont_diff_groupoid _ _ _)).1 }\nend\n\n/-! Register the manifold structure on `Icc 0 1`, and also its zero and one. -/\nsection\n\nlocal attribute [instance] real.fact_zero_lt_one\n\ninstance : charted_space (euclidean_half_space 1) (Icc (0 : ℝ) 1) := by apply_instance\ninstance : smooth_manifold_with_corners (𝓡∂ 1) (Icc (0 : ℝ) 1) := by apply_instance\n\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/geometry/manifold/instances/real.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.49546079762345224}}
{"text": "import implementation.spec.ballot\n\n-- A proposal is a pair of a ballot with a value.\nstructure proposal (pid_t : Type) [linear_order pid_t] (value_t : Type) : Type :=\n  (bal : ballot pid_t) (val : value_t)\n\nnamespace proposal\n\nvariables {pid_t : Type} [linear_order pid_t] {value_t : Type}\n\n-- When merging proposals, we take the one with higher ballot number.\ndef merge : option (proposal pid_t value_t) → option (proposal pid_t value_t)\n                                            → option (proposal pid_t value_t)\n| none      none      := none\n| (some p₁) none      := some p₁\n| none      (some p₂) := some p₂\n| (some p₁) (some p₂) := if (p₁.bal < p₂.bal) then some p₂ else some p₁\n\n-- Gets the proposed value from an option or provides the default if no value is\n-- present.\ndef value_or_default : option (proposal pid_t value_t) → value_t → value_t\n| none     := (λ v, v)\n| (some p) := (λ _, p.val)\n\n-- The result of a merge with a some on the lhs is at least as large as the lhs.\nlemma merge_ballot_ge_left\n  (p_left : proposal pid_t value_t) (p_or : option (proposal pid_t value_t)) :\n  ∃ res, merge (some p_left) p_or = some res ∧ res.bal ≥ p_left.bal :=\nbegin\ncases p_or,\n  case none : {\n    exact ⟨p_left, by refl, le_refl p_left.bal⟩\n  },\n  case some : p_right {\n    unfold merge,\n    cases decidable.em (p_left.bal < p_right.bal),\n    { rw if_pos h,\n      exact ⟨p_right, by refl, le_of_lt h⟩ },\n    rw if_neg h,\n    exact ⟨p_left, by refl, le_refl p_left.bal⟩\n  }\nend\n\n-- The result of a merge with a some on the rhs is at least as large as the rhs.\nlemma merge_ballot_ge_right\n  (p_or : option (proposal pid_t value_t)) (p_right : proposal pid_t value_t) :\n  ∃ res, merge p_or (some p_right) = some res ∧ res.bal ≥ p_right.bal :=\nbegin\ncases p_or,\n  case none : {\n    exact ⟨p_right, by refl, le_refl p_right.bal⟩\n  },\n  case some : p_left {\n    unfold merge,\n    cases decidable.em (p_left.bal < p_right.bal),\n    { rw if_pos h,\n      exact ⟨p_right, by refl, le_refl p_right.bal⟩ },\n    rw if_neg h,\n    exact ⟨p_left, by refl, le_of_not_lt h⟩\n  }\nend\n\n-- Merging two proposals results in either the left one or the right one.\nlemma merge_is_one_of (p_or₁ p_or₂ : option (proposal pid_t value_t)) :\n  merge p_or₁ p_or₂ = p_or₁ ∨ merge p_or₁ p_or₂ = p_or₂ :=\nbegin\ncases p_or₁,\n  case none : {\n    cases p_or₂,\n      case none : { unfold merge, left, refl },\n      case some : p₂ { unfold merge, right, refl }\n  },\n  case some : p₁ {\n    cases p_or₂,\n      case none : { unfold merge, left, refl },\n      case some : p₂ {\n        unfold merge,\n        cases decidable.em (p₁.bal < p₂.bal),\n        { right, rw if_pos h },\n        left, rw if_neg h\n      }\n  },\nend\n\nend proposal\n", "meta": {"author": "gnanabite", "repo": "colocated-paxos", "sha": "f60308e27d3013665809077fe80a4b2af8a42278", "save_path": "github-repos/lean/gnanabite-colocated-paxos", "path": "github-repos/lean/gnanabite-colocated-paxos/colocated-paxos-f60308e27d3013665809077fe80a4b2af8a42278/src/implementation/spec/proposal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4954607908039841}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Mario Carneiro\n\n! This file was ported from Lean 3 source module linear_algebra.bilinear_map\n! leanprover-community/mathlib commit 87c54600fe3cdc7d32ff5b50873ac724d86aef8d\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.LinearAlgebra.Basic\n\n/-!\n# Basics on bilinear maps\n\nThis file provides basics on bilinear maps. The most general form considered are maps that are\nsemilinear in both arguments. They are of type `M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P`, where `M` and `N`\nare modules over `R` and `S` respectively, `P` is a module over both `R₂` and `S₂` with\ncommuting actions, and `ρ₁₂ : R →+* R₂` and `σ₁₂ : S →+* S₂`.\n\n## Main declarations\n\n* `LinearMap.mk₂`: a constructor for bilinear maps,\n  taking an unbundled function together with proof witnesses of bilinearity\n* `LinearMap.flip`: turns a bilinear map `M × N → P` into `N × M → P`\n* `LinearMap.lcomp` and `LinearMap.llcomp`: composition of linear maps as a bilinear map\n* `LinearMap.compl₂`: composition of a bilinear map `M × N → P` with a linear map `Q → M`\n* `LinearMap.compr₂`: composition of a bilinear map `M × N → P` with a linear map `Q → N`\n* `LinearMap.lsmul`: scalar multiplication as a bilinear map `R × M → M`\n\n## Tags\n\nbilinear\n-/\n\n\nnamespace LinearMap\n\nsection Semiring\n\n-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariable {R : Type _} [Semiring R] {S : Type _} [Semiring S]\n\nvariable {R₂ : Type _} [Semiring R₂] {S₂ : Type _} [Semiring S₂]\n\nvariable {M : Type _} {N : Type _} {P : Type _}\n\nvariable {M₂ : Type _} {N₂ : Type _} {P₂ : Type _}\n\nvariable {Nₗ : Type _} {Pₗ : Type _}\n\nvariable {M' : Type _} {N' : Type _} {P' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]\n\nvariable [AddCommMonoid M₂] [AddCommMonoid N₂] [AddCommMonoid P₂]\n\nvariable [AddCommMonoid Nₗ] [AddCommMonoid Pₗ]\n\nvariable [AddCommGroup M'] [AddCommGroup N'] [AddCommGroup P']\n\nvariable [Module R M] [Module S N] [Module R₂ P] [Module S₂ P]\n\nvariable [Module R M₂] [Module S N₂] [Module R P₂] [Module S₂ P₂]\n\nvariable [Module R Pₗ] [Module S Pₗ]\n\nvariable [Module R M'] [Module S N'] [Module R₂ P'] [Module S₂ P']\n\nvariable [SMulCommClass S₂ R₂ P] [SMulCommClass S R Pₗ] [SMulCommClass S₂ R₂ P']\n\nvariable [SMulCommClass S₂ R P₂]\n\nvariable {ρ₁₂ : R →+* R₂} {σ₁₂ : S →+* S₂}\n\nvariable (ρ₁₂ σ₁₂)\n\n/-- Create a bilinear map from a function that is semilinear in each component.\nSee `mk₂'` and `mk₂` for the linear case. -/\ndef mk₂'ₛₗ (f : M → N → P) (H1 : ∀ m₁ m₂ n, f (m₁ + m₂) n = f m₁ n + f m₂ n)\n    (H2 : ∀ (c : R) (m n), f (c • m) n = ρ₁₂ c • f m n)\n    (H3 : ∀ m n₁ n₂, f m (n₁ + n₂) = f m n₁ + f m n₂)\n    (H4 : ∀ (c : S) (m n), f m (c • n) = σ₁₂ c • f m n) : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P\n    where\n  toFun m :=\n    { toFun := f m\n      map_add' := H3 m\n      map_smul' := fun c => H4 c m }\n  map_add' m₁ m₂ := LinearMap.ext <| H1 m₁ m₂\n  map_smul' c m := LinearMap.ext <| H2 c m\n#align linear_map.mk₂'ₛₗ LinearMap.mk₂'ₛₗ\n\nvariable {ρ₁₂ σ₁₂}\n\n@[simp]\ntheorem mk₂'ₛₗ_apply (f : M → N → P) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk₂'ₛₗ ρ₁₂ σ₁₂ f H1 H2 H3 H4 : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) m n = f m n := rfl\n#align linear_map.mk₂'ₛₗ_apply LinearMap.mk₂'ₛₗ_apply\n\nvariable (R S)\n\n/-- Create a bilinear map from a function that is linear in each component.\nSee `mk₂` for the special case where both arguments come from modules over the same ring. -/\ndef mk₂' (f : M → N → Pₗ) (H1 : ∀ m₁ m₂ n, f (m₁ + m₂) n = f m₁ n + f m₂ n)\n    (H2 : ∀ (c : R) (m n), f (c • m) n = c • f m n)\n    (H3 : ∀ m n₁ n₂, f m (n₁ + n₂) = f m n₁ + f m n₂)\n    (H4 : ∀ (c : S) (m n), f m (c • n) = c • f m n) : M →ₗ[R] N →ₗ[S] Pₗ :=\n  mk₂'ₛₗ (RingHom.id R) (RingHom.id S) f H1 H2 H3 H4\n#align linear_map.mk₂' LinearMap.mk₂'\n\nvariable {R S}\n\n@[simp]\ntheorem mk₂'_apply (f : M → N → Pₗ) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk₂' R S f H1 H2 H3 H4 : M →ₗ[R] N →ₗ[S] Pₗ) m n = f m n := rfl\n#align linear_map.mk₂'_apply LinearMap.mk₂'_apply\n\ntheorem ext₂ {f g : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (H : ∀ m n, f m n = g m n) : f = g :=\n  LinearMap.ext fun m => LinearMap.ext fun n => H m n\n#align linear_map.ext₂ LinearMap.ext₂\n\ntheorem congr_fun₂ {f g : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (h : f = g) (x y) : f x y = g x y :=\n  LinearMap.congr_fun (LinearMap.congr_fun h x) y\n#align linear_map.congr_fun₂ LinearMap.congr_fun₂\n\nsection\n\nattribute [local instance] SMulCommClass.symm\n\n/-- Given a linear map from `M` to linear maps from `N` to `P`, i.e., a bilinear map from `M × N` to\n`P`, change the order of variables and get a linear map from `N` to linear maps from `M` to `P`. -/\ndef flip (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) : N →ₛₗ[σ₁₂] M →ₛₗ[ρ₁₂] P :=\n  mk₂'ₛₗ σ₁₂ ρ₁₂ (fun n m => f m n) (fun n₁ n₂ m => (f m).map_add _ _)\n    (fun c n  m  => (f m).map_smulₛₗ _ _)\n    (fun n m₁ m₂ => by simp only [map_add, add_apply])\n    (fun c n  m  => by simp only [map_smulₛₗ, smul_apply])\n#align linear_map.flip LinearMap.flip\n\nend\n\n@[simp]\ntheorem flip_apply (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (m : M) (n : N) : flip f n m = f m n := rfl\n#align linear_map.flip_apply LinearMap.flip_apply\n\nattribute [local instance] SMulCommClass.symm\n\n@[simp]\ntheorem flip_flip (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) : f.flip.flip = f :=\n  LinearMap.ext₂ fun _x _y => (f.flip.flip_apply _ _).trans (f.flip_apply _ _)\n#align linear_map.flip_flip LinearMap.flip_flip\n\nopen BigOperators\n\ntheorem flip_inj {f g : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (H : flip f = flip g) : f = g :=\n  ext₂ fun m n => show flip f n m = flip g n m by rw [H]\n#align linear_map.flip_inj LinearMap.flip_inj\n\ntheorem map_zero₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (y) : f 0 y = 0 :=\n  (flip f y).map_zero\n#align linear_map.map_zero₂ LinearMap.map_zero₂\n\ntheorem map_neg₂ (f : M' →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P') (x y) : f (-x) y = -f x y :=\n  (flip f y).map_neg _\n#align linear_map.map_neg₂ LinearMap.map_neg₂\n\ntheorem map_sub₂ (f : M' →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P') (x y z) : f (x - y) z = f x z - f y z :=\n  (flip f z).map_sub _ _\n#align linear_map.map_sub₂ LinearMap.map_sub₂\n\ntheorem map_add₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (x₁ x₂ y) : f (x₁ + x₂) y = f x₁ y + f x₂ y :=\n  (flip f y).map_add _ _\n#align linear_map.map_add₂ LinearMap.map_add₂\n\ntheorem map_smul₂ (f : M₂ →ₗ[R] N₂ →ₛₗ[σ₁₂] P₂) (r : R) (x y) : f (r • x) y = r • f x y :=\n  (flip f y).map_smul _ _\n#align linear_map.map_smul₂ LinearMap.map_smul₂\n\ntheorem map_smulₛₗ₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (r : R) (x y) : f (r • x) y = ρ₁₂ r • f x y :=\n  (flip f y).map_smulₛₗ _ _\n#align linear_map.map_smulₛₗ₂ LinearMap.map_smulₛₗ₂\n\ntheorem map_sum₂ {ι : Type _} (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (t : Finset ι) (x : ι → M) (y) :\n    f (∑ i in t, x i) y = ∑ i in t, f (x i) y :=\n  (flip f y).map_sum\n#align linear_map.map_sum₂ LinearMap.map_sum₂\n\n/-- Restricting a bilinear map in the second entry -/\ndef domRestrict₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (q : Submodule S N) : M →ₛₗ[ρ₁₂] q →ₛₗ[σ₁₂] P\n    where\n  toFun m := (f m).domRestrict q\n  map_add' m₁ m₂ := LinearMap.ext fun _ => by simp only [map_add, domRestrict_apply, add_apply]\n  map_smul' c m :=\n    LinearMap.ext fun _ => by simp only [f.map_smulₛₗ, domRestrict_apply, smul_apply]\n#align linear_map.dom_restrict₂ LinearMap.domRestrict₂\n\ntheorem domRestrict₂_apply (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (q : Submodule S N) (x : M) (y : q) :\n    f.domRestrict₂ q x y = f x y := rfl\n#align linear_map.dom_restrict₂_apply LinearMap.domRestrict₂_apply\n\n/-- Restricting a bilinear map in both components -/\ndef domRestrict₁₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (p : Submodule R M) (q : Submodule S N) :\n    p →ₛₗ[ρ₁₂] q →ₛₗ[σ₁₂] P :=\n  (f.domRestrict p).domRestrict₂ q\n#align linear_map.dom_restrict₁₂ LinearMap.domRestrict₁₂\n\ntheorem domRestrict₁₂_apply (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (p : Submodule R M) (q : Submodule S N)\n    (x : p) (y : q) : f.domRestrict₁₂ p q x y = f x y := rfl\n#align linear_map.dom_restrict₁₂_apply LinearMap.domRestrict₁₂_apply\n\nend Semiring\n\nsection CommSemiring\n\nvariable {R : Type _} [CommSemiring R] {R₂ : Type _} [CommSemiring R₂]\n\nvariable {R₃ : Type _} [CommSemiring R₃] {R₄ : Type _} [CommSemiring R₄]\n\nvariable {M : Type _} {N : Type _} {P : Type _} {Q : Type _}\n\nvariable {Mₗ : Type _} {Nₗ : Type _} {Pₗ : Type _} {Qₗ Qₗ' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]\n\nvariable [AddCommMonoid Mₗ] [AddCommMonoid Nₗ] [AddCommMonoid Pₗ]\n\nvariable [AddCommMonoid Qₗ] [AddCommMonoid Qₗ']\n\nvariable [Module R M] [Module R₂ N] [Module R₃ P] [Module R₄ Q]\n\nvariable [Module R Mₗ] [Module R Nₗ] [Module R Pₗ] [Module R Qₗ] [Module R Qₗ']\n\nvariable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃}\n\nvariable {σ₄₂ : R₄ →+* R₂} {σ₄₃ : R₄ →+* R₃}\n\nvariable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] [RingHomCompTriple σ₄₂ σ₂₃ σ₄₃]\n\nvariable (R)\n\n/-- Create a bilinear map from a function that is linear in each component.\n\nThis is a shorthand for `mk₂'` for the common case when `R = S`. -/\ndef mk₂ (f : M → Nₗ → Pₗ) (H1 : ∀ m₁ m₂ n, f (m₁ + m₂) n = f m₁ n + f m₂ n)\n    (H2 : ∀ (c : R) (m n), f (c • m) n = c • f m n)\n    (H3 : ∀ m n₁ n₂, f m (n₁ + n₂) = f m n₁ + f m n₂)\n    (H4 : ∀ (c : R) (m n), f m (c • n) = c • f m n) : M →ₗ[R] Nₗ →ₗ[R] Pₗ :=\n  mk₂' R R f H1 H2 H3 H4\n#align linear_map.mk₂ LinearMap.mk₂\n\n@[simp]\ntheorem mk₂_apply (f : M → Nₗ → Pₗ) {H1 H2 H3 H4} (m : M) (n : Nₗ) :\n    (mk₂ R f H1 H2 H3 H4 : M →ₗ[R] Nₗ →ₗ[R] Pₗ) m n = f m n := rfl\n#align linear_map.mk₂_apply LinearMap.mk₂_apply\n\nvariable {R}\n\n/-- Given a linear map from `M` to linear maps from `N` to `P`, i.e., a bilinear map `M → N → P`,\nchange the order of variables and get a linear map from `N` to linear maps from `M` to `P`. -/\ndef lflip : (M →ₛₗ[σ₁₃] N →ₛₗ[σ₂₃] P) →ₗ[R₃] N →ₛₗ[σ₂₃] M →ₛₗ[σ₁₃] P\n    where\n  toFun := flip\n  map_add' _ _ := rfl\n  map_smul' _ _ := rfl\n#align linear_map.lflip LinearMap.lflip\n\nvariable (f : M →ₛₗ[σ₁₃] N →ₛₗ[σ₂₃] P)\n\n@[simp]\ntheorem lflip_apply (m : M) (n : N) : lflip f n m = f m n := rfl\n#align linear_map.lflip_apply LinearMap.lflip_apply\n\nvariable (R Pₗ)\n\n/-- Composing a linear map `M → N` and a linear map `N → P` to form a linear map `M → P`. -/\ndef lcomp (f : M →ₗ[R] Nₗ) : (Nₗ →ₗ[R] Pₗ) →ₗ[R] M →ₗ[R] Pₗ :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcomp LinearMap.lcomp\n\nvariable {R Pₗ}\n\n@[simp]\ntheorem lcomp_apply (f : M →ₗ[R] Nₗ) (g : Nₗ →ₗ[R] Pₗ) (x : M) : lcomp _ _ f g x = g (f x) := rfl\n#align linear_map.lcomp_apply LinearMap.lcomp_apply\n\ntheorem lcomp_apply' (f : M →ₗ[R] Nₗ) (g : Nₗ →ₗ[R] Pₗ) : lcomp R Pₗ f g = g ∘ₗ f := rfl\n#align linear_map.lcomp_apply' LinearMap.lcomp_apply'\n\nvariable (P σ₂₃)\n\n/-- Composing a semilinear map `M → N` and a semilinear map `N → P` to form a semilinear map\n`M → P` is itself a linear map. -/\ndef lcompₛₗ (f : M →ₛₗ[σ₁₂] N) : (N →ₛₗ[σ₂₃] P) →ₗ[R₃] M →ₛₗ[σ₁₃] P :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcompₛₗ LinearMap.lcompₛₗ\n\nvariable {P σ₂₃}\n\n@[simp]\n\n\nvariable (R M Nₗ Pₗ)\n\n/-- Composing a linear map `M → N` and a linear map `N → P` to form a linear map `M → P`. -/\ndef llcomp : (Nₗ →ₗ[R] Pₗ) →ₗ[R] (M →ₗ[R] Nₗ) →ₗ[R] M →ₗ[R] Pₗ :=\n  flip\n    { toFun := lcomp R Pₗ\n      map_add' := fun _f _f' => ext₂ fun g _x => g.map_add _ _\n      map_smul' := fun (_c : R) _f => ext₂ fun g _x => g.map_smul _ _ }\n#align linear_map.llcomp LinearMap.llcomp\n\nvariable {R M Nₗ Pₗ}\n\nsection\n\n@[simp]\ntheorem llcomp_apply (f : Nₗ →ₗ[R] Pₗ) (g : M →ₗ[R] Nₗ) (x : M) :\n    llcomp R M Nₗ Pₗ f g x = f (g x) := rfl\n#align linear_map.llcomp_apply LinearMap.llcomp_apply\n\ntheorem llcomp_apply' (f : Nₗ →ₗ[R] Pₗ) (g : M →ₗ[R] Nₗ) : llcomp R M Nₗ Pₗ f g = f ∘ₗ g := rfl\n#align linear_map.llcomp_apply' LinearMap.llcomp_apply'\n\nend\n\n/-- Composing a linear map `Q → N` and a bilinear map `M → N → P` to\nform a bilinear map `M → Q → P`. -/\ndef compl₂ (g : Q →ₛₗ[σ₄₂] N) : M →ₛₗ[σ₁₃] Q →ₛₗ[σ₄₃] P :=\n  (lcompₛₗ _ _ g).comp f\n#align linear_map.compl₂ LinearMap.compl₂\n\n@[simp]\ntheorem compl₂_apply (g : Q →ₛₗ[σ₄₂] N) (m : M) (q : Q) : f.compl₂ g m q = f m (g q) := rfl\n#align linear_map.compl₂_apply LinearMap.compl₂_apply\n\n@[simp]\ntheorem compl₂_id : f.compl₂ LinearMap.id = f := by\n  ext\n  rw [compl₂_apply, id_coe, id.def]\n#align linear_map.compl₂_id LinearMap.compl₂_id\n\n/-- Composing linear maps `Q → M` and `Q' → N` with a bilinear map `M → N → P` to\nform a bilinear map `Q → Q' → P`. -/\ndef compl₁₂ (f : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Qₗ →ₗ[R] Mₗ) (g' : Qₗ' →ₗ[R] Nₗ) :\n    Qₗ →ₗ[R] Qₗ' →ₗ[R] Pₗ :=\n  (f.comp g).compl₂ g'\n#align linear_map.compl₁₂ LinearMap.compl₁₂\n\n@[simp]\ntheorem compl₁₂_apply (f : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Qₗ →ₗ[R] Mₗ) (g' : Qₗ' →ₗ[R] Nₗ) (x : Qₗ)\n    (y : Qₗ') : f.compl₁₂ g g' x y = f (g x) (g' y) := rfl\n#align linear_map.compl₁₂_apply LinearMap.compl₁₂_apply\n\n@[simp]\ntheorem compl₁₂_id_id (f : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ) : f.compl₁₂ LinearMap.id LinearMap.id = f := by\n  ext\n  simp_rw [compl₁₂_apply, id_coe, id.def]\n#align linear_map.compl₁₂_id_id LinearMap.compl₁₂_id_id\n\ntheorem compl₁₂_inj {f₁ f₂ : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ} {g : Qₗ →ₗ[R] Mₗ} {g' : Qₗ' →ₗ[R] Nₗ}\n    (hₗ : Function.Surjective g) (hᵣ : Function.Surjective g') :\n    f₁.compl₁₂ g g' = f₂.compl₁₂ g g' ↔ f₁ = f₂ := by\n  constructor <;> intro h\n  · -- B₁.comp l r = B₂.comp l r → B₁ = B₂\n    ext (x y)\n    cases' hₗ x with x' hx\n    subst hx\n    cases' hᵣ y with y' hy\n    subst hy\n    convert LinearMap.congr_fun₂ h x' y' using 0\n  · -- B₁ = B₂ → B₁.comp l r = B₂.comp l r\n    subst h; rfl\n#align linear_map.compl₁₂_inj LinearMap.compl₁₂_inj\n\n/-- Composing a linear map `P → Q` and a bilinear map `M → N → P` to\nform a bilinear map `M → N → Q`. -/\ndef compr₂ (f : M →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Pₗ →ₗ[R] Qₗ) : M →ₗ[R] Nₗ →ₗ[R] Qₗ :=\n  llcomp R Nₗ Pₗ Qₗ g ∘ₗ f\n#align linear_map.compr₂ LinearMap.compr₂\n\n@[simp]\ntheorem compr₂_apply (f : M →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Pₗ →ₗ[R] Qₗ) (m : M) (n : Nₗ) :\n    f.compr₂ g m n = g (f m n) := rfl\n#align linear_map.compr₂_apply LinearMap.compr₂_apply\n\nvariable (R M)\n\n/-- Scalar multiplication as a bilinear map `R → M → M`. -/\ndef lsmul : R →ₗ[R] M →ₗ[R] M :=\n  mk₂ R (· • ·) add_smul (fun _ _ _ => mul_smul _ _ _) smul_add fun r s m => by\n    simp only [smul_smul, smul_eq_mul, mul_comm]\n#align linear_map.lsmul LinearMap.lsmul\n\nvariable {R M}\n\n@[simp]\ntheorem lsmul_apply (r : R) (m : M) : lsmul R M r m = r • m := rfl\n#align linear_map.lsmul_apply LinearMap.lsmul_apply\n\nend CommSemiring\n\nsection CommRing\n\nvariable {R R₂ S S₂ M N P : Type _}\n\nvariable {Mₗ Nₗ Pₗ : Type _}\n\nvariable [CommRing R] [CommRing S] [CommRing R₂] [CommRing S₂]\n\nsection AddCommGroup\n\nvariable [AddCommGroup M] [AddCommGroup N] [AddCommGroup P]\n\nvariable [Module R M] [Module S N] [Module R₂ P] [Module S₂ P]\n\ntheorem lsmul_injective [NoZeroSMulDivisors R M] {x : R} (hx : x ≠ 0) :\n    Function.Injective (lsmul R M x) :=\n  smul_right_injective _ hx\n#align linear_map.lsmul_injective LinearMap.lsmul_injective\n\ntheorem ker_lsmul [NoZeroSMulDivisors R M] {a : R} (ha : a ≠ 0) :\n  LinearMap.ker (LinearMap.lsmul R M a) = ⊥ :=\n  LinearMap.ker_eq_bot_of_injective (LinearMap.lsmul_injective ha)\n#align linear_map.ker_lsmul LinearMap.ker_lsmul\n\nend AddCommGroup\n\nend CommRing\n\nend LinearMap\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/LinearAlgebra/BilinearMap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.49546078555065387}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.set.disjointed\nimport Mathlib.data.set.countable\nimport Mathlib.data.indicator_function\nimport Mathlib.data.equiv.encodable.lattice\nimport Mathlib.data.tprod\nimport Mathlib.order.filter.lift\nimport Mathlib.PostPort\n\nuniverses u_7 l u_1 u_2 u_3 u_6 u_4 u_8 u_5 \n\nnamespace Mathlib\n\n/-!\n# Measurable spaces and measurable functions\n\nThis file defines measurable spaces and the functions and isomorphisms\nbetween them.\n\nA measurable space is a set equipped with a σ-algebra, a collection of\nsubsets closed under complementation and countable union. A function\nbetween measurable spaces is measurable if the preimage of each\nmeasurable subset is measurable.\n\nσ-algebras on a fixed set `α` form a complete lattice. Here we order\nσ-algebras by writing `m₁ ≤ m₂` if every set which is `m₁`-measurable is\nalso `m₂`-measurable (that is, `m₁` is a subset of `m₂`). In particular, any\ncollection of subsets of `α` generates a smallest σ-algebra which\ncontains all of them. A function `f : α → β` induces a Galois connection\nbetween the lattices of σ-algebras on `α` and `β`.\n\nA measurable equivalence between measurable spaces is an equivalence\nwhich respects the σ-algebras, that is, for which both directions of\nthe equivalence are measurable functions.\n\nWe say that a filter `f` is measurably generated if every set `s ∈ f` includes a measurable\nset `t ∈ f`. This property is useful, e.g., to extract a measurable witness of `filter.eventually`.\n\n## Main statements\n\nThe main theorem of this file is Dynkin's π-λ theorem, which appears\nhere as an induction principle `induction_on_inter`. Suppose `s` is a\ncollection of subsets of `α` such that the intersection of two members\nof `s` belongs to `s` whenever it is nonempty. Let `m` be the σ-algebra\ngenerated by `s`. In order to check that a predicate `C` holds on every\nmember of `m`, it suffices to check that `C` holds on the members of `s` and\nthat `C` is preserved by complementation and *disjoint* countable\nunions.\n\n## Notation\n\n* We write `α ≃ᵐ β` for measurable equivalences between the measurable spaces `α` and `β`.\n  This should not be confused with `≃ₘ` which is used for diffeomorphisms between manifolds.\n\n## Implementation notes\n\nMeasurability of a function `f : α → β` between measurable spaces is\ndefined in terms of the Galois connection induced by f.\n\n## References\n\n* <https://en.wikipedia.org/wiki/Measurable_space>\n* <https://en.wikipedia.org/wiki/Sigma-algebra>\n* <https://en.wikipedia.org/wiki/Dynkin_system>\n\n## Tags\n\nmeasurable space, σ-algebra, measurable function, measurable equivalence, dynkin system,\nπ-λ theorem, π-system\n-/\n\n/-- A measurable space is a space equipped with a σ-algebra. -/\nclass measurable_space (α : Type u_7) \nwhere\n  is_measurable' : set α → Prop\n  is_measurable_empty : is_measurable' ∅\n  is_measurable_compl : ∀ (s : set α), is_measurable' s → is_measurable' (sᶜ)\n  is_measurable_Union : ∀ (f : ℕ → set α), (∀ (i : ℕ), is_measurable' (f i)) → is_measurable' (set.Union fun (i : ℕ) => f i)\n\nprotected instance order_dual.measurable_space {α : Type u_1} [h : measurable_space α] : measurable_space (order_dual α) :=\n  h\n\n/-- `is_measurable s` means that `s` is measurable (in the ambient measure space on `α`) -/\ndef is_measurable {α : Type u_1} [measurable_space α] : set α → Prop :=\n  measurable_space.is_measurable' _inst_1\n\n@[simp] theorem is_measurable.empty {α : Type u_1} [measurable_space α] : is_measurable ∅ :=\n  measurable_space.is_measurable_empty _inst_1\n\ntheorem is_measurable.compl {α : Type u_1} {s : set α} [measurable_space α] : is_measurable s → is_measurable (sᶜ) :=\n  measurable_space.is_measurable_compl _inst_1 s\n\ntheorem is_measurable.of_compl {α : Type u_1} {s : set α} [measurable_space α] (h : is_measurable (sᶜ)) : is_measurable s :=\n  compl_compl s ▸ is_measurable.compl h\n\n@[simp] theorem is_measurable.compl_iff {α : Type u_1} {s : set α} [measurable_space α] : is_measurable (sᶜ) ↔ is_measurable s :=\n  { mp := is_measurable.of_compl, mpr := is_measurable.compl }\n\n@[simp] theorem is_measurable.univ {α : Type u_1} [measurable_space α] : is_measurable set.univ :=\n  eq.mpr (id (Eq.refl (is_measurable set.univ)))\n    (eq.mp ((fun (ᾰ ᾰ_1 : set α) (e_2 : ᾰ = ᾰ_1) => congr_arg is_measurable e_2) (∅ᶜ) set.univ set.compl_empty)\n      (is_measurable.compl is_measurable.empty))\n\ntheorem subsingleton.is_measurable {α : Type u_1} [measurable_space α] [subsingleton α] {s : set α} : is_measurable s :=\n  subsingleton.set_cases is_measurable.empty is_measurable.univ s\n\ntheorem is_measurable.congr {α : Type u_1} [measurable_space α] {s : set α} {t : set α} (hs : is_measurable s) (h : s = t) : is_measurable t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable t)) (Eq.symm h))) hs\n\ntheorem is_measurable.bUnion_decode2 {α : Type u_1} {β : Type u_2} [measurable_space α] [encodable β] {f : β → set α} (h : ∀ (b : β), is_measurable (f b)) (n : ℕ) : is_measurable (set.Union fun (b : β) => set.Union fun (H : b ∈ encodable.decode2 β n) => f b) :=\n  encodable.Union_decode2_cases is_measurable.empty h\n\ntheorem is_measurable.Union {α : Type u_1} {β : Type u_2} [measurable_space α] [encodable β] {f : β → set α} (h : ∀ (b : β), is_measurable (f b)) : is_measurable (set.Union fun (b : β) => f b) := sorry\n\ntheorem is_measurable.bUnion {α : Type u_1} {β : Type u_2} [measurable_space α] {f : β → set α} {s : set β} (hs : set.countable s) (h : ∀ (b : β), b ∈ s → is_measurable (f b)) : is_measurable (set.Union fun (b : β) => set.Union fun (H : b ∈ s) => f b) := sorry\n\ntheorem set.finite.is_measurable_bUnion {α : Type u_1} {β : Type u_2} [measurable_space α] {f : β → set α} {s : set β} (hs : set.finite s) (h : ∀ (b : β), b ∈ s → is_measurable (f b)) : is_measurable (set.Union fun (b : β) => set.Union fun (H : b ∈ s) => f b) :=\n  is_measurable.bUnion (set.finite.countable hs) h\n\ntheorem finset.is_measurable_bUnion {α : Type u_1} {β : Type u_2} [measurable_space α] {f : β → set α} (s : finset β) (h : ∀ (b : β), b ∈ s → is_measurable (f b)) : is_measurable (set.Union fun (b : β) => set.Union fun (H : b ∈ s) => f b) :=\n  set.finite.is_measurable_bUnion (finset.finite_to_set s) h\n\ntheorem is_measurable.sUnion {α : Type u_1} [measurable_space α] {s : set (set α)} (hs : set.countable s) (h : ∀ (t : set α), t ∈ s → is_measurable t) : is_measurable (⋃₀s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (⋃₀s))) set.sUnion_eq_bUnion)) (is_measurable.bUnion hs h)\n\ntheorem set.finite.is_measurable_sUnion {α : Type u_1} [measurable_space α] {s : set (set α)} (hs : set.finite s) (h : ∀ (t : set α), t ∈ s → is_measurable t) : is_measurable (⋃₀s) :=\n  is_measurable.sUnion (set.finite.countable hs) h\n\ntheorem is_measurable.Union_Prop {α : Type u_1} [measurable_space α] {p : Prop} {f : p → set α} (hf : ∀ (b : p), is_measurable (f b)) : is_measurable (set.Union fun (b : p) => f b) := sorry\n\ntheorem is_measurable.Inter {α : Type u_1} {β : Type u_2} [measurable_space α] [encodable β] {f : β → set α} (h : ∀ (b : β), is_measurable (f b)) : is_measurable (set.Inter fun (b : β) => f b) := sorry\n\ntheorem is_measurable.Union_fintype {α : Type u_1} {β : Type u_2} [measurable_space α] [fintype β] {f : β → set α} (h : ∀ (b : β), is_measurable (f b)) : is_measurable (set.Union fun (b : β) => f b) :=\n  is_measurable.Union h\n\ntheorem is_measurable.Inter_fintype {α : Type u_1} {β : Type u_2} [measurable_space α] [fintype β] {f : β → set α} (h : ∀ (b : β), is_measurable (f b)) : is_measurable (set.Inter fun (b : β) => f b) :=\n  is_measurable.Inter h\n\ntheorem is_measurable.bInter {α : Type u_1} {β : Type u_2} [measurable_space α] {f : β → set α} {s : set β} (hs : set.countable s) (h : ∀ (b : β), b ∈ s → is_measurable (f b)) : is_measurable (set.Inter fun (b : β) => set.Inter fun (H : b ∈ s) => f b) := sorry\n\ntheorem set.finite.is_measurable_bInter {α : Type u_1} {β : Type u_2} [measurable_space α] {f : β → set α} {s : set β} (hs : set.finite s) (h : ∀ (b : β), b ∈ s → is_measurable (f b)) : is_measurable (set.Inter fun (b : β) => set.Inter fun (H : b ∈ s) => f b) :=\n  is_measurable.bInter (set.finite.countable hs) h\n\ntheorem finset.is_measurable_bInter {α : Type u_1} {β : Type u_2} [measurable_space α] {f : β → set α} (s : finset β) (h : ∀ (b : β), b ∈ s → is_measurable (f b)) : is_measurable (set.Inter fun (b : β) => set.Inter fun (H : b ∈ s) => f b) :=\n  set.finite.is_measurable_bInter (finset.finite_to_set s) h\n\ntheorem is_measurable.sInter {α : Type u_1} [measurable_space α] {s : set (set α)} (hs : set.countable s) (h : ∀ (t : set α), t ∈ s → is_measurable t) : is_measurable (⋂₀s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (⋂₀s))) set.sInter_eq_bInter)) (is_measurable.bInter hs h)\n\ntheorem set.finite.is_measurable_sInter {α : Type u_1} [measurable_space α] {s : set (set α)} (hs : set.finite s) (h : ∀ (t : set α), t ∈ s → is_measurable t) : is_measurable (⋂₀s) :=\n  is_measurable.sInter (set.finite.countable hs) h\n\ntheorem is_measurable.Inter_Prop {α : Type u_1} [measurable_space α] {p : Prop} {f : p → set α} (hf : ∀ (b : p), is_measurable (f b)) : is_measurable (set.Inter fun (b : p) => f b) := sorry\n\n@[simp] theorem is_measurable.union {α : Type u_1} [measurable_space α] {s₁ : set α} {s₂ : set α} (h₁ : is_measurable s₁) (h₂ : is_measurable s₂) : is_measurable (s₁ ∪ s₂) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (s₁ ∪ s₂))) set.union_eq_Union))\n    (is_measurable.Union (iff.mpr bool.forall_bool { left := h₂, right := h₁ }))\n\n@[simp] theorem is_measurable.inter {α : Type u_1} [measurable_space α] {s₁ : set α} {s₂ : set α} (h₁ : is_measurable s₁) (h₂ : is_measurable s₂) : is_measurable (s₁ ∩ s₂) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (s₁ ∩ s₂))) (set.inter_eq_compl_compl_union_compl s₁ s₂)))\n    (is_measurable.compl (is_measurable.union (is_measurable.compl h₁) (is_measurable.compl h₂)))\n\n@[simp] theorem is_measurable.diff {α : Type u_1} [measurable_space α] {s₁ : set α} {s₂ : set α} (h₁ : is_measurable s₁) (h₂ : is_measurable s₂) : is_measurable (s₁ \\ s₂) :=\n  is_measurable.inter h₁ (is_measurable.compl h₂)\n\n@[simp] theorem is_measurable.disjointed {α : Type u_1} [measurable_space α] {f : ℕ → set α} (h : ∀ (i : ℕ), is_measurable (f i)) (n : ℕ) : is_measurable (set.disjointed f n) :=\n  set.disjointed_induct (h n) fun (t : set α) (i : ℕ) (ht : is_measurable t) => is_measurable.diff ht (h i)\n\n@[simp] theorem is_measurable.const {α : Type u_1} [measurable_space α] (p : Prop) : is_measurable (set_of fun (a : α) => p) := sorry\n\n/-- Every set has a measurable superset. Declare this as local instance as needed. -/\ntheorem nonempty_measurable_superset {α : Type u_1} [measurable_space α] (s : set α) : Nonempty (Subtype fun (t : set α) => s ⊆ t ∧ is_measurable t) :=\n  Nonempty.intro { val := set.univ, property := { left := set.subset_univ s, right := is_measurable.univ } }\n\ntheorem measurable_space.ext {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} : (∀ (s : set α), measurable_space.is_measurable' m₁ s ↔ measurable_space.is_measurable' m₂ s) → m₁ = m₂ := sorry\n\ntheorem measurable_space.ext_iff {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} : m₁ = m₂ ↔ ∀ (s : set α), measurable_space.is_measurable' m₁ s ↔ measurable_space.is_measurable' m₂ s :=\n  { mp := fun (ᾰ : m₁ = m₂) => Eq._oldrec (fun (s : set α) => iff.refl (measurable_space.is_measurable' m₁ s)) ᾰ,\n    mpr := measurable_space.ext }\n\n/-- A typeclass mixin for `measurable_space`s such that each singleton is measurable. -/\nclass measurable_singleton_class (α : Type u_7) [measurable_space α] \nwhere\n  is_measurable_singleton : ∀ (x : α), is_measurable (singleton x)\n\ntheorem is_measurable_eq {α : Type u_1} [measurable_space α] [measurable_singleton_class α] {a : α} : is_measurable (set_of fun (x : α) => x = a) :=\n  is_measurable_singleton a\n\ntheorem is_measurable.insert {α : Type u_1} [measurable_space α] [measurable_singleton_class α] {s : set α} (hs : is_measurable s) (a : α) : is_measurable (insert a s) :=\n  is_measurable.union (is_measurable_singleton a) hs\n\n@[simp] theorem is_measurable_insert {α : Type u_1} [measurable_space α] [measurable_singleton_class α] {a : α} {s : set α} : is_measurable (insert a s) ↔ is_measurable s := sorry\n\ntheorem set.finite.is_measurable {α : Type u_1} [measurable_space α] [measurable_singleton_class α] {s : set α} (hs : set.finite s) : is_measurable s :=\n  set.finite.induction_on hs is_measurable.empty\n    fun (a : α) (s : set α) (ha : ¬a ∈ s) (hsf : set.finite s) (hsm : is_measurable s) => is_measurable.insert hsm a\n\nprotected theorem finset.is_measurable {α : Type u_1} [measurable_space α] [measurable_singleton_class α] (s : finset α) : is_measurable ↑s :=\n  set.finite.is_measurable (finset.finite_to_set s)\n\nnamespace measurable_space\n\n\nprotected instance partial_order {α : Type u_1} : partial_order (measurable_space α) :=\n  partial_order.mk (fun (m₁ m₂ : measurable_space α) => is_measurable' m₁ ≤ is_measurable' m₂)\n    (preorder.lt._default fun (m₁ m₂ : measurable_space α) => is_measurable' m₁ ≤ is_measurable' m₂) sorry sorry sorry\n\n/-- The smallest σ-algebra containing a collection `s` of basic sets -/\ninductive generate_measurable {α : Type u_1} (s : set (set α)) : set α → Prop\nwhere\n| basic : ∀ (u : set α), u ∈ s → generate_measurable s u\n| empty : generate_measurable s ∅\n| compl : ∀ (s_1 : set α), generate_measurable s s_1 → generate_measurable s (s_1ᶜ)\n| union : ∀ (f : ℕ → set α), (∀ (n : ℕ), generate_measurable s (f n)) → generate_measurable s (set.Union fun (i : ℕ) => f i)\n\n/-- Construct the smallest measure space containing a collection of basic sets -/\ndef generate_from {α : Type u_1} (s : set (set α)) : measurable_space α :=\n  mk (generate_measurable s) generate_measurable.empty generate_measurable.compl generate_measurable.union\n\ntheorem is_measurable_generate_from {α : Type u_1} {s : set (set α)} {t : set α} (ht : t ∈ s) : is_measurable' (generate_from s) t :=\n  generate_measurable.basic t ht\n\ntheorem generate_from_le {α : Type u_1} {s : set (set α)} {m : measurable_space α} (h : ∀ (t : set α), t ∈ s → is_measurable' m t) : generate_from s ≤ m := sorry\n\ntheorem generate_from_le_iff {α : Type u_1} {s : set (set α)} (m : measurable_space α) : generate_from s ≤ m ↔ s ⊆ set_of fun (t : set α) => is_measurable' m t :=\n  { mp := fun (h : generate_from s ≤ m) (u : set α) (hu : u ∈ s) => h u (is_measurable_generate_from hu),\n    mpr := fun (h : s ⊆ set_of fun (t : set α) => is_measurable' m t) => generate_from_le h }\n\n@[simp] theorem generate_from_is_measurable {α : Type u_1} [measurable_space α] : generate_from (set_of fun (s : set α) => is_measurable s) = _inst_1 :=\n  le_antisymm (generate_from_le fun (_x : set α) => id) fun (s : set α) => is_measurable_generate_from\n\n/-- If `g` is a collection of subsets of `α` such that the `σ`-algebra generated from `g` contains\nthe same sets as `g`, then `g` was already a `σ`-algebra. -/\nprotected def mk_of_closure {α : Type u_1} (g : set (set α)) (hg : (set_of fun (t : set α) => is_measurable' (generate_from g) t) = g) : measurable_space α :=\n  mk (fun (s : set α) => s ∈ g) sorry sorry sorry\n\ntheorem mk_of_closure_sets {α : Type u_1} {s : set (set α)} {hs : (set_of fun (t : set α) => is_measurable' (generate_from s) t) = s} : measurable_space.mk_of_closure s hs = generate_from s := sorry\n\n/-- We get a Galois insertion between `σ`-algebras on `α` and `set (set α)` by using `generate_from`\n  on one side and the collection of measurable sets on the other side. -/\ndef gi_generate_from {α : Type u_1} : galois_insertion generate_from fun (m : measurable_space α) => set_of fun (t : set α) => is_measurable t :=\n  galois_insertion.mk\n    (fun (g : set (set α)) (hg : (set_of fun (t : set α) => is_measurable t) ≤ g) =>\n      measurable_space.mk_of_closure g sorry)\n    sorry sorry sorry\n\nprotected instance complete_lattice {α : Type u_1} : complete_lattice (measurable_space α) :=\n  galois_insertion.lift_complete_lattice gi_generate_from\n\nprotected instance inhabited {α : Type u_1} : Inhabited (measurable_space α) :=\n  { default := ⊤ }\n\ntheorem is_measurable_bot_iff {α : Type u_1} {s : set α} : is_measurable s ↔ s = ∅ ∨ s = set.univ := sorry\n\n@[simp] theorem is_measurable_top {α : Type u_1} {s : set α} : is_measurable s :=\n  trivial\n\n@[simp] theorem is_measurable_inf {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} {s : set α} : is_measurable s ↔ is_measurable s ∧ is_measurable s :=\n  iff.rfl\n\n@[simp] theorem is_measurable_Inf {α : Type u_1} {ms : set (measurable_space α)} {s : set α} : is_measurable s ↔ ∀ (m : measurable_space α), m ∈ ms → is_measurable s := sorry\n\n@[simp] theorem is_measurable_infi {α : Type u_1} {ι : Sort u_2} {m : ι → measurable_space α} {s : set α} : is_measurable s ↔ ι → is_measurable s := sorry\n\ntheorem is_measurable_sup {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} {s : set α} : is_measurable s ↔ generate_measurable (is_measurable' m₁ ∪ is_measurable' m₂) s :=\n  iff.refl (is_measurable s)\n\ntheorem is_measurable_Sup {α : Type u_1} {ms : set (measurable_space α)} {s : set α} : is_measurable s ↔\n  generate_measurable (set_of fun (s : set α) => ∃ (m : measurable_space α), ∃ (H : m ∈ ms), is_measurable s) s := sorry\n\ntheorem is_measurable_supr {α : Type u_1} {ι : Sort u_2} {m : ι → measurable_space α} {s : set α} : is_measurable s ↔ generate_measurable (set_of fun (s : set α) => ∃ (i : ι), is_measurable s) s := sorry\n\n/-- The forward image of a measure space under a function. `map f m` contains the sets `s : set β`\n  whose preimage under `f` is measurable. -/\nprotected def map {α : Type u_1} {β : Type u_2} (f : α → β) (m : measurable_space α) : measurable_space β :=\n  mk (fun (s : set β) => is_measurable' m (f ⁻¹' s)) (is_measurable_empty m) sorry sorry\n\n@[simp] theorem map_id {α : Type u_1} {m : measurable_space α} : measurable_space.map id m = m :=\n  ext fun (s : set α) => iff.rfl\n\n@[simp] theorem map_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {m : measurable_space α} {f : α → β} {g : β → γ} : measurable_space.map g (measurable_space.map f m) = measurable_space.map (g ∘ f) m :=\n  ext fun (s : set γ) => iff.rfl\n\n/-- The reverse image of a measure space under a function. `comap f m` contains the sets `s : set α`\n  such that `s` is the `f`-preimage of a measurable set in `β`. -/\nprotected def comap {α : Type u_1} {β : Type u_2} (f : α → β) (m : measurable_space β) : measurable_space α :=\n  mk (fun (s : set α) => ∃ (s' : set β), is_measurable' m s' ∧ f ⁻¹' s' = s) sorry sorry sorry\n\n@[simp] theorem comap_id {α : Type u_1} {m : measurable_space α} : measurable_space.comap id m = m := sorry\n\n@[simp] theorem comap_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {m : measurable_space α} {f : β → α} {g : γ → β} : measurable_space.comap g (measurable_space.comap f m) = measurable_space.comap (f ∘ g) m := sorry\n\ntheorem comap_le_iff_le_map {α : Type u_1} {β : Type u_2} {m : measurable_space α} {m' : measurable_space β} {f : α → β} : measurable_space.comap f m' ≤ m ↔ m' ≤ measurable_space.map f m := sorry\n\ntheorem gc_comap_map {α : Type u_1} {β : Type u_2} (f : α → β) : galois_connection (measurable_space.comap f) (measurable_space.map f) :=\n  fun (f_1 : measurable_space β) (g : measurable_space α) => comap_le_iff_le_map\n\ntheorem map_mono {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space α} {f : α → β} (h : m₁ ≤ m₂) : measurable_space.map f m₁ ≤ measurable_space.map f m₂ :=\n  galois_connection.monotone_u (gc_comap_map f) h\n\ntheorem monotone_map {α : Type u_1} {β : Type u_2} {f : α → β} : monotone (measurable_space.map f) :=\n  fun (a b : measurable_space α) (h : a ≤ b) => map_mono h\n\ntheorem comap_mono {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space α} {g : β → α} (h : m₁ ≤ m₂) : measurable_space.comap g m₁ ≤ measurable_space.comap g m₂ :=\n  galois_connection.monotone_l (gc_comap_map g) h\n\ntheorem monotone_comap {α : Type u_1} {β : Type u_2} {g : β → α} : monotone (measurable_space.comap g) :=\n  fun (a b : measurable_space α) (h : a ≤ b) => comap_mono h\n\n@[simp] theorem comap_bot {α : Type u_1} {β : Type u_2} {g : β → α} : measurable_space.comap g ⊥ = ⊥ :=\n  galois_connection.l_bot (gc_comap_map g)\n\n@[simp] theorem comap_sup {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space α} {g : β → α} : measurable_space.comap g (m₁ ⊔ m₂) = measurable_space.comap g m₁ ⊔ measurable_space.comap g m₂ :=\n  galois_connection.l_sup (gc_comap_map g)\n\n@[simp] theorem comap_supr {α : Type u_1} {β : Type u_2} {ι : Sort u_6} {g : β → α} {m : ι → measurable_space α} : measurable_space.comap g (supr fun (i : ι) => m i) = supr fun (i : ι) => measurable_space.comap g (m i) :=\n  galois_connection.l_supr (gc_comap_map g)\n\n@[simp] theorem map_top {α : Type u_1} {β : Type u_2} {f : α → β} : measurable_space.map f ⊤ = ⊤ :=\n  galois_connection.u_top (gc_comap_map f)\n\n@[simp] theorem map_inf {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space α} {f : α → β} : measurable_space.map f (m₁ ⊓ m₂) = measurable_space.map f m₁ ⊓ measurable_space.map f m₂ :=\n  galois_connection.u_inf (gc_comap_map f)\n\n@[simp] theorem map_infi {α : Type u_1} {β : Type u_2} {ι : Sort u_6} {f : α → β} {m : ι → measurable_space α} : measurable_space.map f (infi fun (i : ι) => m i) = infi fun (i : ι) => measurable_space.map f (m i) :=\n  galois_connection.u_infi (gc_comap_map f)\n\ntheorem comap_map_le {α : Type u_1} {β : Type u_2} {m : measurable_space α} {f : α → β} : measurable_space.comap f (measurable_space.map f m) ≤ m :=\n  galois_connection.l_u_le (gc_comap_map f) m\n\ntheorem le_map_comap {α : Type u_1} {β : Type u_2} {m : measurable_space α} {g : β → α} : m ≤ measurable_space.map g (measurable_space.comap g m) :=\n  galois_connection.le_u_l (gc_comap_map g) m\n\ntheorem generate_from_le_generate_from {α : Type u_1} {s : set (set α)} {t : set (set α)} (h : s ⊆ t) : generate_from s ≤ generate_from t :=\n  galois_connection.monotone_l (galois_insertion.gc gi_generate_from) h\n\ntheorem generate_from_sup_generate_from {α : Type u_1} {s : set (set α)} {t : set (set α)} : generate_from s ⊔ generate_from t = generate_from (s ∪ t) :=\n  Eq.symm (galois_connection.l_sup (galois_insertion.gc gi_generate_from))\n\ntheorem comap_generate_from {α : Type u_1} {β : Type u_2} {f : α → β} {s : set (set β)} : measurable_space.comap f (generate_from s) = generate_from (set.preimage f '' s) := sorry\n\nend measurable_space\n\n\n/-- A function `f` between measurable spaces is measurable if the preimage of every\n  measurable set is measurable. -/\ndef measurable {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (f : α → β) :=\n  ∀ {t : set β}, is_measurable t → is_measurable (f ⁻¹' t)\n\ntheorem measurable_iff_le_map {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space β} {f : α → β} : measurable f ↔ m₂ ≤ measurable_space.map f m₁ :=\n  iff.rfl\n\ntheorem measurable.of_le_map {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space β} {f : α → β} : m₂ ≤ measurable_space.map f m₁ → measurable f :=\n  iff.mpr measurable_iff_le_map\n\ntheorem measurable_iff_comap_le {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space β} {f : α → β} : measurable f ↔ measurable_space.comap f m₂ ≤ m₁ :=\n  iff.symm measurable_space.comap_le_iff_le_map\n\ntheorem measurable.comap_le {α : Type u_1} {β : Type u_2} {m₁ : measurable_space α} {m₂ : measurable_space β} {f : α → β} : measurable f → measurable_space.comap f m₂ ≤ m₁ :=\n  iff.mp measurable_iff_comap_le\n\ntheorem measurable.mono {α : Type u_1} {β : Type u_2} {ma : measurable_space α} {ma' : measurable_space α} {mb : measurable_space β} {mb' : measurable_space β} {f : α → β} (hf : measurable f) (ha : ma ≤ ma') (hb : mb' ≤ mb) : measurable f :=\n  fun (t : set β) (ht : is_measurable t) => ha (f ⁻¹' t) (hf (hb t ht))\n\ntheorem measurable_from_top {α : Type u_1} {β : Type u_2} [measurable_space β] {f : α → β} : measurable f :=\n  fun (s : set β) (hs : is_measurable s) => trivial\n\ntheorem measurable_generate_from {α : Type u_1} {β : Type u_2} [measurable_space α] {s : set (set β)} {f : α → β} (h : ∀ (t : set β), t ∈ s → is_measurable (f ⁻¹' t)) : measurable f :=\n  measurable.of_le_map (measurable_space.generate_from_le h)\n\ntheorem measurable_id {α : Type u_1} [measurable_space α] : measurable id :=\n  fun (t : set α) => id\n\ntheorem measurable.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {g : β → γ} {f : α → β} (hg : measurable g) (hf : measurable f) : measurable (g ∘ f) :=\n  fun (t : set γ) (ht : is_measurable t) => hf (hg ht)\n\ntheorem subsingleton.measurable {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] [subsingleton α] {f : α → β} : measurable f :=\n  fun (s : set β) (hs : is_measurable s) => subsingleton.is_measurable\n\ntheorem measurable.piecewise {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {s : set α} {_x : decidable_pred s} {f : α → β} {g : α → β} (hs : is_measurable s) (hf : measurable f) (hg : measurable g) : measurable (set.piecewise s f g) := sorry\n\n/-- this is slightly different from `measurable.piecewise`. It can be used to show\n`measurable (ite (x=0) 0 1)` by\n`exact measurable.ite (is_measurable_singleton 0) measurable_const measurable_const`,\nbut replacing `measurable.ite` by `measurable.piecewise` in that example proof does not work. -/\ntheorem measurable.ite {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {p : α → Prop} {_x : decidable_pred p} {f : α → β} {g : α → β} (hp : is_measurable (set_of fun (a : α) => p a)) (hf : measurable f) (hg : measurable g) : measurable fun (x : α) => ite (p x) (f x) (g x) :=\n  measurable.piecewise hp hf hg\n\n@[simp] theorem measurable_const {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {a : α} : measurable fun (b : β) => a :=\n  fun (s : set α) (hs : is_measurable s) => is_measurable.const (a ∈ s)\n\ntheorem measurable.indicator {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] [HasZero β] {s : set α} {f : α → β} (hf : measurable f) (hs : is_measurable s) : measurable (set.indicator s f) :=\n  measurable.piecewise hs hf measurable_const\n\ntheorem measurable_zero {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] [HasZero α] : measurable 0 :=\n  measurable_const\n\ntheorem measurable_of_not_nonempty {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (h : ¬Nonempty α) (f : α → β) : measurable f := sorry\n\nprotected instance empty.measurable_space : measurable_space empty :=\n  ⊤\n\nprotected instance punit.measurable_space : measurable_space PUnit :=\n  ⊤\n\nprotected instance bool.measurable_space : measurable_space Bool :=\n  ⊤\n\nprotected instance nat.measurable_space : measurable_space ℕ :=\n  ⊤\n\nprotected instance int.measurable_space : measurable_space ℤ :=\n  ⊤\n\nprotected instance rat.measurable_space : measurable_space ℚ :=\n  ⊤\n\ntheorem measurable_to_encodable {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] [encodable α] {f : β → α} (h : ∀ (y : β), is_measurable (f ⁻¹' singleton (f y))) : measurable f := sorry\n\ntheorem measurable_unit {α : Type u_1} [measurable_space α] (f : Unit → α) : measurable f :=\n  measurable_from_top\n\ntheorem measurable_from_nat {α : Type u_1} [measurable_space α] {f : ℕ → α} : measurable f :=\n  measurable_from_top\n\ntheorem measurable_to_nat {α : Type u_1} [measurable_space α] {f : α → ℕ} : (∀ (y : α), is_measurable (f ⁻¹' singleton (f y))) → measurable f :=\n  measurable_to_encodable\n\ntheorem measurable_find_greatest' {α : Type u_1} [measurable_space α] {p : α → ℕ → Prop} {N : ℕ} (hN : ∀ (k : ℕ), k ≤ N → is_measurable (set_of fun (x : α) => nat.find_greatest (p x) N = k)) : measurable fun (x : α) => nat.find_greatest (p x) N :=\n  measurable_to_nat fun (x : α) => hN (nat.find_greatest (p x) N) nat.find_greatest_le\n\ntheorem measurable_find_greatest {α : Type u_1} [measurable_space α] {p : α → ℕ → Prop} {N : ℕ} (hN : ∀ (k : ℕ), k ≤ N → is_measurable (set_of fun (x : α) => p x k)) : measurable fun (x : α) => nat.find_greatest (p x) N := sorry\n\ntheorem measurable_find {α : Type u_1} [measurable_space α] {p : α → ℕ → Prop} (hp : ∀ (x : α), ∃ (N : ℕ), p x N) (hm : ∀ (k : ℕ), is_measurable (set_of fun (x : α) => p x k)) : measurable fun (x : α) => nat.find (hp x) := sorry\n\nprotected instance subtype.measurable_space {α : Type u_1} {p : α → Prop} [m : measurable_space α] : measurable_space (Subtype p) :=\n  measurable_space.comap coe m\n\ntheorem measurable_subtype_coe {α : Type u_1} [measurable_space α] {p : α → Prop} : measurable coe :=\n  measurable_space.le_map_comap\n\ntheorem measurable.subtype_coe {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {p : β → Prop} {f : α → Subtype p} (hf : measurable f) : measurable fun (a : α) => ↑(f a) :=\n  measurable.comp measurable_subtype_coe hf\n\ntheorem measurable.subtype_mk {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {p : β → Prop} {f : α → β} (hf : measurable f) {h : ∀ (x : α), p (f x)} : measurable fun (x : α) => { val := f x, property := h x } := sorry\n\ntheorem is_measurable.subtype_image {α : Type u_1} [measurable_space α] {s : set α} {t : set ↥s} (hs : is_measurable s) : is_measurable t → is_measurable (coe '' t) := sorry\n\ntheorem measurable_of_measurable_union_cover {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {f : α → β} (s : set α) (t : set α) (hs : is_measurable s) (ht : is_measurable t) (h : set.univ ⊆ s ∪ t) (hc : measurable fun (a : ↥s) => f ↑a) (hd : measurable fun (a : ↥t) => f ↑a) : measurable f := sorry\n\ntheorem measurable_of_measurable_on_compl_singleton {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] [measurable_singleton_class α] {f : α → β} (a : α) (hf : measurable (set.restrict f (set_of fun (x : α) => x ≠ a))) : measurable f :=\n  measurable_of_measurable_union_cover (set_of fun (x : α) => x = a) ((set_of fun (x : α) => x = a)ᶜ) is_measurable_eq\n    (is_measurable.compl is_measurable_eq)\n    (fun (x : α) (hx : x ∈ set.univ) => classical.em (x ∈ set_of fun (x : α) => x = a)) subsingleton.measurable hf\n\nprotected instance prod.measurable_space {α : Type u_1} {β : Type u_2} [m₁ : measurable_space α] [m₂ : measurable_space β] : measurable_space (α × β) :=\n  measurable_space.comap prod.fst m₁ ⊔ measurable_space.comap prod.snd m₂\n\ntheorem measurable_fst {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : measurable prod.fst :=\n  measurable.of_comap_le le_sup_left\n\ntheorem measurable.fst {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β × γ} (hf : measurable f) : measurable fun (a : α) => prod.fst (f a) :=\n  measurable.comp measurable_fst hf\n\ntheorem measurable_snd {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : measurable prod.snd :=\n  measurable.of_comap_le le_sup_right\n\ntheorem measurable.snd {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β × γ} (hf : measurable f) : measurable fun (a : α) => prod.snd (f a) :=\n  measurable.comp measurable_snd hf\n\ntheorem measurable.prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β × γ} (hf₁ : measurable fun (a : α) => prod.fst (f a)) (hf₂ : measurable fun (a : α) => prod.snd (f a)) : measurable f := sorry\n\ntheorem measurable_prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β × γ} : measurable f ↔ (measurable fun (a : α) => prod.fst (f a)) ∧ measurable fun (a : α) => prod.snd (f a) := sorry\n\ntheorem measurable.prod_mk {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β} {g : α → γ} (hf : measurable f) (hg : measurable g) : measurable fun (a : α) => (f a, g a) :=\n  measurable.prod hf hg\n\ntheorem measurable_prod_mk_left {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {x : α} : measurable (Prod.mk x) :=\n  measurable.prod_mk measurable_const measurable_id\n\ntheorem measurable_prod_mk_right {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {y : β} : measurable fun (x : α) => (x, y) :=\n  measurable.prod_mk measurable_id measurable_const\n\ntheorem measurable.of_uncurry_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β → γ} (hf : measurable (function.uncurry f)) {x : α} : measurable (f x) :=\n  measurable.comp hf measurable_prod_mk_left\n\ntheorem measurable.of_uncurry_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β → γ} (hf : measurable (function.uncurry f)) {y : β} : measurable fun (x : α) => f x y :=\n  measurable.comp hf measurable_prod_mk_right\n\ntheorem measurable_swap {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : measurable prod.swap :=\n  measurable.prod measurable_snd measurable_fst\n\ntheorem measurable_swap_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α × β → γ} : measurable (f ∘ prod.swap) ↔ measurable f := sorry\n\ntheorem is_measurable.prod {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {s : set α} {t : set β} (hs : is_measurable s) (ht : is_measurable t) : is_measurable (set.prod s t) :=\n  is_measurable.inter (measurable_fst hs) (measurable_snd ht)\n\ntheorem is_measurable_prod_of_nonempty {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {s : set α} {t : set β} (h : set.nonempty (set.prod s t)) : is_measurable (set.prod s t) ↔ is_measurable s ∧ is_measurable t := sorry\n\ntheorem is_measurable_prod {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {s : set α} {t : set β} : is_measurable (set.prod s t) ↔ is_measurable s ∧ is_measurable t ∨ s = ∅ ∨ t = ∅ := sorry\n\ntheorem is_measurable_swap_iff {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {s : set (α × β)} : is_measurable (prod.swap ⁻¹' s) ↔ is_measurable s := sorry\n\nprotected instance measurable_space.pi {δ : Type u_4} {π : δ → Type u_7} [m : (a : δ) → measurable_space (π a)] : measurable_space ((a : δ) → π a) :=\n  supr fun (a : δ) => measurable_space.comap (fun (b : (a : δ) → π a) => b a) (m a)\n\ntheorem measurable_pi_iff {α : Type u_1} {δ : Type u_4} [measurable_space α] {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] {g : α → (a : δ) → π a} : measurable g ↔ ∀ (a : δ), measurable fun (x : α) => g x a := sorry\n\ntheorem measurable_pi_apply {δ : Type u_4} {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] (a : δ) : measurable fun (f : (a : δ) → π a) => f a :=\n  measurable.of_comap_le (le_supr (fun (a : δ) => measurable_space.comap (fun (f : (a : δ) → π a) => f a) (_inst_4 a)) a)\n\ntheorem measurable.eval {α : Type u_1} {δ : Type u_4} [measurable_space α] {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] {a : δ} {g : α → (a : δ) → π a} (hg : measurable g) : measurable fun (x : α) => g x a :=\n  measurable.comp (measurable_pi_apply a) hg\n\ntheorem measurable_pi_lambda {α : Type u_1} {δ : Type u_4} [measurable_space α] {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] (f : α → (a : δ) → π a) (hf : ∀ (a : δ), measurable fun (c : α) => f c a) : measurable f :=\n  iff.mpr measurable_pi_iff hf\n\n/-- The function `update f a : π a → Π a, π a` is always measurable.\n  This doesn't require `f` to be measurable.\n  This should not be confused with the statement that `update f a x` is measurable. -/\ntheorem measurable_update {δ : Type u_4} {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] (f : (a : δ) → π a) {a : δ} : measurable (function.update f a) := sorry\n\n/- Even though we cannot use projection notation, we still keep a dot to be consistent with similar\n  lemmas, like `is_measurable.prod`. -/\n\ntheorem is_measurable.pi {δ : Type u_4} {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] {s : set δ} {t : (i : δ) → set (π i)} (hs : set.countable s) (ht : ∀ (i : δ), i ∈ s → is_measurable (t i)) : is_measurable (set.pi s t) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (set.pi s t))) (set.pi_def s t)))\n    (is_measurable.bInter hs fun (i : δ) (hi : i ∈ s) => measurable_pi_apply i (ht i hi))\n\ntheorem is_measurable.pi_univ {δ : Type u_4} {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] [encodable δ] {t : (i : δ) → set (π i)} (ht : ∀ (i : δ), is_measurable (t i)) : is_measurable (set.pi set.univ t) :=\n  is_measurable.pi (set.countable_encodable set.univ) fun (i : δ) (_x : i ∈ set.univ) => ht i\n\ntheorem is_measurable_pi_of_nonempty {δ : Type u_4} {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] {s : set δ} {t : (i : δ) → set (π i)} (hs : set.countable s) (h : set.nonempty (set.pi s t)) : is_measurable (set.pi s t) ↔ ∀ (i : δ), i ∈ s → is_measurable (t i) := sorry\n\ntheorem is_measurable_pi {δ : Type u_4} {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] {s : set δ} {t : (i : δ) → set (π i)} (hs : set.countable s) : is_measurable (set.pi s t) ↔ (∀ (i : δ), i ∈ s → is_measurable (t i)) ∨ set.pi s t = ∅ := sorry\n\ntheorem is_measurable.pi_fintype {δ : Type u_4} {π : δ → Type u_7} [(a : δ) → measurable_space (π a)] [fintype δ] {s : set δ} {t : (i : δ) → set (π i)} (ht : ∀ (i : δ), i ∈ s → is_measurable (t i)) : is_measurable (set.pi s t) :=\n  is_measurable.pi (set.countable_encodable s) ht\n\nprotected instance tprod.measurable_space {δ : Type u_4} (π : δ → Type u_1) [(x : δ) → measurable_space (π x)] (l : List δ) : measurable_space (list.tprod π l) :=\n  sorry\n\ntheorem measurable_tprod_mk {δ : Type u_4} {π : δ → Type u_7} [(x : δ) → measurable_space (π x)] (l : List δ) : measurable (list.tprod.mk l) :=\n  List.rec measurable_const\n    (fun (i : δ) (l : List δ) (ih : measurable (list.tprod.mk l)) => measurable.prod_mk (measurable_pi_apply i) ih) l\n\ntheorem measurable_tprod_elim {δ : Type u_4} {π : δ → Type u_7} [(x : δ) → measurable_space (π x)] {l : List δ} {i : δ} (hi : i ∈ l) : measurable fun (v : list.tprod π l) => list.tprod.elim v hi := sorry\n\ntheorem measurable_tprod_elim' {δ : Type u_4} {π : δ → Type u_7} [(x : δ) → measurable_space (π x)] {l : List δ} (h : ∀ (i : δ), i ∈ l) : measurable (list.tprod.elim' h) :=\n  measurable_pi_lambda (list.tprod.elim' h) fun (i : δ) => measurable_tprod_elim (h i)\n\ntheorem is_measurable.tprod {δ : Type u_4} {π : δ → Type u_7} [(x : δ) → measurable_space (π x)] (l : List δ) {s : (i : δ) → set (π i)} (hs : ∀ (i : δ), is_measurable (s i)) : is_measurable (set.tprod l s) :=\n  List.rec is_measurable.univ\n    (fun (i : δ) (l : List δ) (ih : is_measurable (set.tprod l s)) => is_measurable.prod (hs i) ih) l\n\nprotected instance sum.measurable_space {α : Type u_1} {β : Type u_2} [m₁ : measurable_space α] [m₂ : measurable_space β] : measurable_space (α ⊕ β) :=\n  measurable_space.map sum.inl m₁ ⊓ measurable_space.map sum.inr m₂\n\ntheorem measurable_inl {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : measurable sum.inl :=\n  measurable.of_le_map inf_le_left\n\ntheorem measurable_inr {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : measurable sum.inr :=\n  measurable.of_le_map inf_le_right\n\ntheorem measurable_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α ⊕ β → γ} (hl : measurable (f ∘ sum.inl)) (hr : measurable (f ∘ sum.inr)) : measurable f :=\n  measurable.of_comap_le\n    (le_inf (iff.mpr measurable_space.comap_le_iff_le_map hl) (iff.mpr measurable_space.comap_le_iff_le_map hr))\n\ntheorem measurable.sum_elim {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → γ} {g : β → γ} (hf : measurable f) (hg : measurable g) : measurable (sum.elim f g) :=\n  measurable_sum hf hg\n\ntheorem is_measurable.inl_image {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {s : set α} (hs : is_measurable s) : is_measurable (sum.inl '' s) := sorry\n\ntheorem is_measurable_range_inl {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : is_measurable (set.range sum.inl) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (set.range sum.inl))) (Eq.symm set.image_univ)))\n    (is_measurable.inl_image is_measurable.univ)\n\ntheorem is_measurable_inr_image {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] {s : set β} (hs : is_measurable s) : is_measurable (sum.inr '' s) := sorry\n\ntheorem is_measurable_range_inr {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : is_measurable (set.range sum.inr) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (set.range sum.inr))) (Eq.symm set.image_univ)))\n    (is_measurable_inr_image is_measurable.univ)\n\nprotected instance sigma.measurable_space {α : Type u_1} {β : α → Type u_2} [m : (a : α) → measurable_space (β a)] : measurable_space (sigma β) :=\n  infi fun (a : α) => measurable_space.map (sigma.mk a) (m a)\n\n/-- Equivalences between measurable spaces. Main application is the simplification of measurability\nstatements along measurable equivalences. -/\nstructure measurable_equiv (α : Type u_7) (β : Type u_8) [measurable_space α] [measurable_space β] \nextends α ≃ β\nwhere\n  measurable_to_fun : measurable (equiv.to_fun _to_equiv)\n  measurable_inv_fun : measurable (equiv.inv_fun _to_equiv)\n\ninfixl:25 \" ≃ᵐ \" => Mathlib.measurable_equiv\n\nnamespace measurable_equiv\n\n\nprotected instance has_coe_to_fun (α : Type u_1) (β : Type u_2) [measurable_space α] [measurable_space β] : has_coe_to_fun (α ≃ᵐ β) :=\n  has_coe_to_fun.mk (fun (_x : α ≃ᵐ β) => α → β) fun (e : α ≃ᵐ β) => ⇑(to_equiv e)\n\ntheorem coe_eq {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (e : α ≃ᵐ β) : ⇑e = ⇑(to_equiv e) :=\n  rfl\n\nprotected theorem measurable {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (e : α ≃ᵐ β) : measurable ⇑e :=\n  measurable_to_fun e\n\n@[simp] theorem coe_mk {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (e : α ≃ β) (h1 : measurable ⇑e) (h2 : measurable ⇑(equiv.symm e)) : ⇑(mk e h1 h2) = ⇑e :=\n  rfl\n\n/-- Any measurable space is equivalent to itself. -/\ndef refl (α : Type u_1) [measurable_space α] : α ≃ᵐ α :=\n  mk (equiv.refl α) measurable_id measurable_id\n\nprotected instance inhabited {α : Type u_1} [measurable_space α] : Inhabited (α ≃ᵐ α) :=\n  { default := refl α }\n\n/-- The composition of equivalences between measurable spaces. -/\ndef trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] (ab : α ≃ᵐ β) (bc : β ≃ᵐ γ) : α ≃ᵐ γ :=\n  mk (equiv.trans (to_equiv ab) (to_equiv bc)) sorry sorry\n\n/-- The inverse of an equivalence between measurable spaces. -/\n@[simp] theorem symm_to_equiv {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (ab : α ≃ᵐ β) : to_equiv (symm ab) = equiv.symm (to_equiv ab) :=\n  Eq.refl (to_equiv (symm ab))\n\n@[simp] theorem coe_symm_mk {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (e : α ≃ β) (h1 : measurable ⇑e) (h2 : measurable ⇑(equiv.symm e)) : ⇑(symm (mk e h1 h2)) = ⇑(equiv.symm e) :=\n  rfl\n\n@[simp] theorem symm_comp_self {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (e : α ≃ᵐ β) : ⇑(symm e) ∘ ⇑e = id :=\n  funext (equiv.left_inv (to_equiv e))\n\n@[simp] theorem self_comp_symm {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (e : α ≃ᵐ β) : ⇑e ∘ ⇑(symm e) = id :=\n  funext (equiv.right_inv (to_equiv e))\n\n/-- Equal measurable spaces are equivalent. -/\nprotected def cast {α : Type u_1} {β : Type u_1} [i₁ : measurable_space α] [i₂ : measurable_space β] (h : α = β) (hi : i₁ == i₂) : α ≃ᵐ β :=\n  mk (equiv.cast h) sorry sorry\n\nprotected theorem measurable_coe_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] {f : β → γ} (e : α ≃ᵐ β) : measurable (f ∘ ⇑e) ↔ measurable f := sorry\n\n/-- Products of equivalent measurable spaces are equivalent. -/\ndef prod_congr {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [measurable_space α] [measurable_space β] [measurable_space γ] [measurable_space δ] (ab : α ≃ᵐ β) (cd : γ ≃ᵐ δ) : α × γ ≃ᵐ β × δ :=\n  mk (equiv.prod_congr (to_equiv ab) (to_equiv cd)) sorry sorry\n\n/-- Products of measurable spaces are symmetric. -/\ndef prod_comm {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : α × β ≃ᵐ β × α :=\n  mk (equiv.prod_comm α β) sorry sorry\n\n/-- Products of measurable spaces are associative. -/\ndef prod_assoc {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] [measurable_space β] [measurable_space γ] : (α × β) × γ ≃ᵐ α × β × γ :=\n  mk (equiv.prod_assoc α β γ) sorry sorry\n\n/-- Sums of measurable spaces are symmetric. -/\ndef sum_congr {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [measurable_space α] [measurable_space β] [measurable_space γ] [measurable_space δ] (ab : α ≃ᵐ β) (cd : γ ≃ᵐ δ) : α ⊕ γ ≃ᵐ β ⊕ δ :=\n  mk (equiv.sum_congr (to_equiv ab) (to_equiv cd)) sorry sorry\n\n/-- `set.prod s t ≃ (s × t)` as measurable spaces. -/\ndef set.prod {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (s : set α) (t : set β) : ↥(set.prod s t) ≃ᵐ ↥s × ↥t :=\n  mk (equiv.set.prod s t) sorry sorry\n\n/-- `univ α ≃ α` as measurable spaces. -/\ndef set.univ (α : Type u_1) [measurable_space α] : ↥set.univ ≃ᵐ α :=\n  mk (equiv.set.univ α) sorry sorry\n\n/-- `{a} ≃ unit` as measurable spaces. -/\ndef set.singleton {α : Type u_1} [measurable_space α] (a : α) : ↥(singleton a) ≃ᵐ Unit :=\n  mk (equiv.set.singleton a) sorry sorry\n\n/-- A set is equivalent to its image under a function `f` as measurable spaces,\n  if `f` is an injective measurable function that sends measurable sets to measurable sets. -/\ndef set.image {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (f : α → β) (s : set α) (hf : function.injective f) (hfm : measurable f) (hfi : ∀ (s : set α), is_measurable s → is_measurable (f '' s)) : ↥s ≃ᵐ ↥(f '' s) :=\n  mk (equiv.set.image f s hf) sorry sorry\n\n/-- The domain of `f` is equivalent to its range as measurable spaces,\n  if `f` is an injective measurable function that sends measurable sets to measurable sets. -/\ndef set.range {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] (f : α → β) (hf : function.injective f) (hfm : measurable f) (hfi : ∀ (s : set α), is_measurable s → is_measurable (f '' s)) : α ≃ᵐ ↥(set.range f) :=\n  trans (symm (set.univ α)) (trans (set.image f set.univ hf hfm hfi) (measurable_equiv.cast sorry sorry))\n\n/-- `α` is equivalent to its image in `α ⊕ β` as measurable spaces. -/\ndef set.range_inl {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : ↥(set.range sum.inl) ≃ᵐ α :=\n  mk\n    (equiv.mk (fun (ab : ↥(set.range sum.inl)) => sorry) (fun (a : α) => { val := sum.inl a, property := sorry }) sorry\n      sorry)\n    sorry sorry\n\n/-- `β` is equivalent to its image in `α ⊕ β` as measurable spaces. -/\ndef set.range_inr {α : Type u_1} {β : Type u_2} [measurable_space α] [measurable_space β] : ↥(set.range sum.inr) ≃ᵐ β :=\n  mk\n    (equiv.mk (fun (ab : ↥(set.range sum.inr)) => sorry) (fun (b : β) => { val := sum.inr b, property := sorry }) sorry\n      sorry)\n    sorry sorry\n\n/-- Products distribute over sums (on the right) as measurable spaces. -/\ndef sum_prod_distrib (α : Type u_1) (β : Type u_2) (γ : Type u_3) [measurable_space α] [measurable_space β] [measurable_space γ] : (α ⊕ β) × γ ≃ᵐ α × γ ⊕ β × γ :=\n  mk (equiv.sum_prod_distrib α β γ) sorry sorry\n\n/-- Products distribute over sums (on the left) as measurable spaces. -/\ndef prod_sum_distrib (α : Type u_1) (β : Type u_2) (γ : Type u_3) [measurable_space α] [measurable_space β] [measurable_space γ] : α × (β ⊕ γ) ≃ᵐ α × β ⊕ α × γ :=\n  trans prod_comm (trans (sum_prod_distrib β γ α) (sum_congr prod_comm prod_comm))\n\n/-- Products distribute over sums as measurable spaces. -/\ndef sum_prod_sum (α : Type u_1) (β : Type u_2) (γ : Type u_3) (δ : Type u_4) [measurable_space α] [measurable_space β] [measurable_space γ] [measurable_space δ] : (α ⊕ β) × (γ ⊕ δ) ≃ᵐ (α × γ ⊕ α × δ) ⊕ β × γ ⊕ β × δ :=\n  trans (sum_prod_distrib α β (γ ⊕ δ)) (sum_congr (prod_sum_distrib α γ δ) (prod_sum_distrib β γ δ))\n\n/-- A family of measurable equivalences `Π a, β₁ a ≃ᵐ β₂ a` generates a measurable equivalence\n  between  `Π a, β₁ a` and `Π a, β₂ a`. -/\ndef Pi_congr_right {δ' : Type u_5} {π : δ' → Type u_7} {π' : δ' → Type u_8} [(x : δ') → measurable_space (π x)] [(x : δ') → measurable_space (π' x)] (e : (a : δ') → π a ≃ᵐ π' a) : ((a : δ') → π a) ≃ᵐ ((a : δ') → π' a) :=\n  mk (equiv.Pi_congr_right fun (a : δ') => to_equiv (e a)) sorry sorry\n\n/-- Pi-types are measurably equivalent to iterated products. -/\ndef pi_measurable_equiv_tprod {δ' : Type u_5} {π : δ' → Type u_7} [(x : δ') → measurable_space (π x)] {l : List δ'} (hnd : list.nodup l) (h : ∀ (i : δ'), i ∈ l) : ((i : δ') → π i) ≃ᵐ list.tprod π l :=\n  mk (list.tprod.pi_equiv_tprod hnd h) sorry sorry\n\nend measurable_equiv\n\n\n/-- A pi-system is a collection of subsets of `α` that is closed under intersections of sets that\n  are not disjoint. Usually it is also required that the collection is nonempty, but we don't do\n  that here. -/\ndef is_pi_system {α : Type u_1} (C : set (set α)) :=\n  ∀ (s t : set α), s ∈ C → t ∈ C → set.nonempty (s ∩ t) → s ∩ t ∈ C\n\nnamespace measurable_space\n\n\ntheorem is_pi_system_is_measurable {α : Type u_1} [measurable_space α] : is_pi_system (set_of fun (s : set α) => is_measurable s) :=\n  fun (s t : set α) (hs : s ∈ set_of fun (s : set α) => is_measurable s)\n    (ht : t ∈ set_of fun (s : set α) => is_measurable s) (_x : set.nonempty (s ∩ t)) => is_measurable.inter hs ht\n\n/-- A Dynkin system is a collection of subsets of a type `α` that contains the empty set,\n  is closed under complementation and under countable union of pairwise disjoint sets.\n  The disjointness condition is the only difference with `σ`-algebras.\n\n  The main purpose of Dynkin systems is to provide a powerful induction rule for σ-algebras\n  generated by intersection stable set systems.\n\n  A Dynkin system is also known as a \"λ-system\" or a \"d-system\".\n-/\nstructure dynkin_system (α : Type u_7) \nwhere\n  has : set α → Prop\n  has_empty : has ∅\n  has_compl : ∀ {a : set α}, has a → has (aᶜ)\n  has_Union_nat : ∀ {f : ℕ → set α}, pairwise (disjoint on f) → (∀ (i : ℕ), has (f i)) → has (set.Union fun (i : ℕ) => f i)\n\nnamespace dynkin_system\n\n\ntheorem ext {α : Type u_1} {d₁ : dynkin_system α} {d₂ : dynkin_system α} : (∀ (s : set α), has d₁ s ↔ has d₂ s) → d₁ = d₂ := sorry\n\ntheorem has_compl_iff {α : Type u_1} (d : dynkin_system α) {a : set α} : has d (aᶜ) ↔ has d a := sorry\n\ntheorem has_univ {α : Type u_1} (d : dynkin_system α) : has d set.univ := sorry\n\ntheorem has_Union {α : Type u_1} (d : dynkin_system α) {β : Type u_2} [encodable β] {f : β → set α} (hd : pairwise (disjoint on f)) (h : ∀ (i : β), has d (f i)) : has d (set.Union fun (i : β) => f i) := sorry\n\ntheorem has_union {α : Type u_1} (d : dynkin_system α) {s₁ : set α} {s₂ : set α} (h₁ : has d s₁) (h₂ : has d s₂) (h : s₁ ∩ s₂ ⊆ ∅) : has d (s₁ ∪ s₂) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (has d (s₁ ∪ s₂))) set.union_eq_Union))\n    (has_Union d (iff.mpr pairwise_disjoint_on_bool h) (iff.mpr bool.forall_bool { left := h₂, right := h₁ }))\n\ntheorem has_diff {α : Type u_1} (d : dynkin_system α) {s₁ : set α} {s₂ : set α} (h₁ : has d s₁) (h₂ : has d s₂) (h : s₂ ⊆ s₁) : has d (s₁ \\ s₂) := sorry\n\nprotected instance partial_order {α : Type u_1} : partial_order (dynkin_system α) :=\n  partial_order.mk (fun (m₁ m₂ : dynkin_system α) => has m₁ ≤ has m₂)\n    (preorder.lt._default fun (m₁ m₂ : dynkin_system α) => has m₁ ≤ has m₂) sorry sorry sorry\n\n/-- Every measurable space (σ-algebra) forms a Dynkin system -/\ndef of_measurable_space {α : Type u_1} (m : measurable_space α) : dynkin_system α :=\n  mk (is_measurable' m) (is_measurable_empty m) (is_measurable_compl m) sorry\n\ntheorem of_measurable_space_le_of_measurable_space_iff {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} : of_measurable_space m₁ ≤ of_measurable_space m₂ ↔ m₁ ≤ m₂ :=\n  iff.rfl\n\n/-- The least Dynkin system containing a collection of basic sets.\n  This inductive type gives the underlying collection of sets. -/\ninductive generate_has {α : Type u_1} (s : set (set α)) : set α → Prop\nwhere\n| basic : ∀ (t : set α), t ∈ s → generate_has s t\n| empty : generate_has s ∅\n| compl : ∀ {a : set α}, generate_has s a → generate_has s (aᶜ)\n| Union : ∀ {f : ℕ → set α},\n  pairwise (disjoint on f) → (∀ (i : ℕ), generate_has s (f i)) → generate_has s (set.Union fun (i : ℕ) => f i)\n\ntheorem generate_has_compl {α : Type u_1} {C : set (set α)} {s : set α} : generate_has C (sᶜ) ↔ generate_has C s := sorry\n\n/-- The least Dynkin system containing a collection of basic sets. -/\ndef generate {α : Type u_1} (s : set (set α)) : dynkin_system α :=\n  mk (generate_has s) generate_has.empty sorry sorry\n\ntheorem generate_has_def {α : Type u_1} {C : set (set α)} : has (generate C) = generate_has C :=\n  rfl\n\nprotected instance inhabited {α : Type u_1} : Inhabited (dynkin_system α) :=\n  { default := generate set.univ }\n\n/-- If a Dynkin system is closed under binary intersection, then it forms a `σ`-algebra. -/\ndef to_measurable_space {α : Type u_1} (d : dynkin_system α) (h_inter : ∀ (s₁ s₂ : set α), has d s₁ → has d s₂ → has d (s₁ ∩ s₂)) : measurable_space α :=\n  mk (has d) (has_empty d) sorry sorry\n\ntheorem of_measurable_space_to_measurable_space {α : Type u_1} (d : dynkin_system α) (h_inter : ∀ (s₁ s₂ : set α), has d s₁ → has d s₂ → has d (s₁ ∩ s₂)) : of_measurable_space (to_measurable_space d h_inter) = d :=\n  ext fun (s : set α) => iff.rfl\n\n/-- If `s` is in a Dynkin system `d`, we can form the new Dynkin system `{s ∩ t | t ∈ d}`. -/\ndef restrict_on {α : Type u_1} (d : dynkin_system α) {s : set α} (h : has d s) : dynkin_system α :=\n  mk (fun (t : set α) => has d (t ∩ s)) sorry sorry sorry\n\ntheorem generate_le {α : Type u_1} (d : dynkin_system α) {s : set (set α)} (h : ∀ (t : set α), t ∈ s → has d t) : generate s ≤ d := sorry\n\ntheorem generate_has_subset_generate_measurable {α : Type u_1} {C : set (set α)} {s : set α} (hs : has (generate C) s) : is_measurable' (generate_from C) s :=\n  generate_le (of_measurable_space (generate_from C)) (fun (t : set α) => is_measurable_generate_from) s hs\n\ntheorem generate_inter {α : Type u_1} {s : set (set α)} (hs : is_pi_system s) {t₁ : set α} {t₂ : set α} (ht₁ : has (generate s) t₁) (ht₂ : has (generate s) t₂) : has (generate s) (t₁ ∩ t₂) := sorry\n\n/--\n  If we have a collection of sets closed under binary intersections, then the Dynkin system it\n  generates is equal to the σ-algebra it generates.\n  This result is known as the π-λ theorem.\n  A collection of sets closed under binary intersection is called a \"π-system\" if it is non-empty.\n-/\ntheorem generate_from_eq {α : Type u_1} {s : set (set α)} (hs : is_pi_system s) : generate_from s = to_measurable_space (generate s) fun (t₁ t₂ : set α) => generate_inter hs := sorry\n\nend dynkin_system\n\n\ntheorem induction_on_inter {α : Type u_1} {C : set α → Prop} {s : set (set α)} [m : measurable_space α] (h_eq : m = generate_from s) (h_inter : is_pi_system s) (h_empty : C ∅) (h_basic : ∀ (t : set α), t ∈ s → C t) (h_compl : ∀ (t : set α), is_measurable t → C t → C (tᶜ)) (h_union : ∀ (f : ℕ → set α),\n  pairwise (disjoint on f) → (∀ (i : ℕ), is_measurable (f i)) → (∀ (i : ℕ), C (f i)) → C (set.Union fun (i : ℕ) => f i)) {t : set α} : is_measurable t → C t := sorry\n\nend measurable_space\n\n\nnamespace filter\n\n\n/-- A filter `f` is measurably generates if each `s ∈ f` includes a measurable `t ∈ f`. -/\nclass is_measurably_generated {α : Type u_1} [measurable_space α] (f : filter α) \nwhere\n  exists_measurable_subset : ∀ {s : set α}, s ∈ f → ∃ (t : set α), ∃ (H : t ∈ f), is_measurable t ∧ t ⊆ s\n\nprotected instance is_measurably_generated_bot {α : Type u_1} [measurable_space α] : is_measurably_generated ⊥ :=\n  is_measurably_generated.mk\n    fun (_x : set α) (_x_1 : _x ∈ ⊥) =>\n      Exists.intro ∅ (Exists.intro mem_bot_sets { left := is_measurable.empty, right := set.empty_subset _x })\n\nprotected instance is_measurably_generated_top {α : Type u_1} [measurable_space α] : is_measurably_generated ⊤ :=\n  is_measurably_generated.mk\n    fun (s : set α) (hs : s ∈ ⊤) =>\n      Exists.intro set.univ\n        (Exists.intro univ_mem_sets { left := is_measurable.univ, right := fun (x : α) (_x : x ∈ set.univ) => hs x })\n\ntheorem eventually.exists_measurable_mem {α : Type u_1} [measurable_space α] {f : filter α} [is_measurably_generated f] {p : α → Prop} (h : filter.eventually (fun (x : α) => p x) f) : ∃ (s : set α), ∃ (H : s ∈ f), is_measurable s ∧ ∀ (x : α), x ∈ s → p x :=\n  is_measurably_generated.exists_measurable_subset h\n\ntheorem eventually.exists_measurable_mem_of_lift' {α : Type u_1} [measurable_space α] {f : filter α} [is_measurably_generated f] {p : set α → Prop} (h : filter.eventually (fun (s : set α) => p s) (filter.lift' f set.powerset)) : ∃ (s : set α), ∃ (H : s ∈ f), is_measurable s ∧ p s := sorry\n\nprotected instance inf_is_measurably_generated {α : Type u_1} [measurable_space α] (f : filter α) (g : filter α) [is_measurably_generated f] [is_measurably_generated g] : is_measurably_generated (f ⊓ g) := sorry\n\ntheorem principal_is_measurably_generated_iff {α : Type u_1} [measurable_space α] {s : set α} : is_measurably_generated (principal s) ↔ is_measurable s := sorry\n\ntheorem Mathlib.is_measurable.principal_is_measurably_generated {α : Type u_1} [measurable_space α] {s : set α} : is_measurable s → is_measurably_generated (principal s) :=\n  iff.mpr principal_is_measurably_generated_iff\n\nprotected instance infi_is_measurably_generated {α : Type u_1} {ι : Sort u_6} [measurable_space α] {f : ι → filter α} [∀ (i : ι), is_measurably_generated (f i)] : is_measurably_generated (infi fun (i : ι) => f i) := sorry\n\nend filter\n\n\n/-- We say that a collection of sets is countably spanning if a countable subset spans the\n  whole type. This is a useful condition in various parts of measure theory. For example, it is\n  a needed condition to show that the product of two collections generate the product sigma algebra,\n  see `generate_from_prod_eq`. -/\ndef is_countably_spanning {α : Type u_1} (C : set (set α)) :=\n  ∃ (s : ℕ → set α), (∀ (n : ℕ), s n ∈ C) ∧ (set.Union fun (n : ℕ) => s n) = set.univ\n\ntheorem is_countably_spanning_is_measurable {α : Type u_1} [measurable_space α] : is_countably_spanning (set_of fun (s : set α) => is_measurable s) :=\n  Exists.intro (fun (_x : ℕ) => set.univ)\n    { left := fun (_x : ℕ) => is_measurable.univ, right := set.Union_const set.univ }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/measure_theory/measurable_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851918, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.49546078029732354}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang, Scott Morrison\n-/\nimport category_theory.abelian.injective_resolution\nimport algebra.homology.additive\nimport category_theory.limits.constructions.epi_mono\nimport category_theory.abelian.homology\nimport category_theory.abelian.exact\n\n/-!\n# Right-derived functors\n\nWe define the right-derived functors `F.right_derived n : C ⥤ D` for any additive functor `F`\nout of a category with injective resolutions.\n\nThe definition is\n```\ninjective_resolutions C ⋙ F.map_homotopy_category _ ⋙ homotopy_category.homology_functor D _ n\n```\nthat is, we pick an injective resolution (thought of as an object of the homotopy category),\nwe apply `F` objectwise, and compute `n`-th homology.\n\nWe show that these right-derived functors can be calculated\non objects using any choice of injective resolution,\nand on morphisms by any choice of lift to a cochain map between chosen injective resolutions.\n\nSimilarly we define natural transformations between right-derived functors coming from\nnatural transformations between the original additive functors,\nand show how to compute the components.\n\n## Main results\n* `category_theory.functor.right_derived_obj_injective_zero`: the `0`-th derived functor of `F` on\n  an injective object `X` is isomorphic to `F.obj X`.\n* `category_theory.functor.right_derived_obj_injective_succ`: injective objects have no higher\n  right derived functor.\n* `category_theory.nat_trans.right_derived`: the natural isomorphism between right derived functors\n  induced by natural transformation.\n\nNow, we assume `preserves_finite_limits F`, then\n* `category_theory.abelian.functor.preserves_exact_of_preserves_finite_limits_of_mono`: if `f` is\n  mono and `exact f g`, then `exact (F.map f) (F.map g)`.\n* `category_theory.abelian.functor.right_derived_zero_iso_self`: if there are enough injectives,\n  then there is a natural isomorphism `(F.right_derived 0) ≅ F`.\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\n\nnamespace category_theory\nuniverses v u\nvariables {C : Type u} [category.{v} C] {D : Type*} [category D]\nvariables [abelian C] [has_injective_resolutions C] [abelian D]\n\n/-- The right derived functors of an additive functor. -/\ndef functor.right_derived (F : C ⥤ D) [F.additive] (n : ℕ) : C ⥤ D :=\ninjective_resolutions C ⋙ F.map_homotopy_category _ ⋙ homotopy_category.homology_functor D _ n\n\n/-- We can compute a right derived functor using a chosen injective resolution. -/\n@[simps]\ndef functor.right_derived_obj_iso (F : C ⥤ D) [F.additive] (n : ℕ)\n  {X : C} (P : InjectiveResolution X) :\n  (F.right_derived n).obj X ≅\n    (homology_functor D _ n).obj ((F.map_homological_complex _).obj P.cocomplex) :=\n(homotopy_category.homology_functor D _ n).map_iso\n  (homotopy_category.iso_of_homotopy_equiv\n    (F.map_homotopy_equiv (InjectiveResolution.homotopy_equiv _ P)))\n  ≪≫ (homotopy_category.homology_factors D _ n).app _\n\n/-- The 0-th derived functor of `F` on an injective object `X` is just `F.obj X`. -/\n@[simps]\ndef functor.right_derived_obj_injective_zero (F : C ⥤ D) [F.additive]\n  (X : C) [injective X] :\n  (F.right_derived 0).obj X ≅ F.obj X :=\nF.right_derived_obj_iso 0 (InjectiveResolution.self X) ≪≫\n  (homology_functor _ _ _).map_iso ((cochain_complex.single₀_map_homological_complex F).app X) ≪≫\n  (cochain_complex.homology_functor_0_single₀ D).app (F.obj X)\n\nopen_locale zero_object\n\n/-- The higher derived functors vanish on injective objects. -/\n@[simps inv]\ndef functor.right_derived_obj_injective_succ (F : C ⥤ D) [F.additive] (n : ℕ)\n  (X : C) [injective X] :\n  (F.right_derived (n+1)).obj X ≅ 0 :=\nF.right_derived_obj_iso (n+1) (InjectiveResolution.self X) ≪≫\n  (homology_functor _ _ _).map_iso ((cochain_complex.single₀_map_homological_complex F).app X) ≪≫\n  (cochain_complex.homology_functor_succ_single₀ D n).app (F.obj X) ≪≫\n  (functor.zero_obj _).iso_zero\n/--\nWe can compute a right derived functor on a morphism using a descent of that morphism\nto a cochain map between chosen injective resolutions.\n-/\nlemma functor.right_derived_map_eq (F : C ⥤ D) [F.additive] (n : ℕ) {X Y : C} (f : Y ⟶ X)\n  {P : InjectiveResolution X} {Q : InjectiveResolution Y} (g : Q.cocomplex ⟶ P.cocomplex)\n  (w : Q.ι ≫ g = (cochain_complex.single₀ C).map f ≫ P.ι) :\n  (F.right_derived n).map f =\n  (F.right_derived_obj_iso n Q).hom ≫\n    (homology_functor D _ n).map ((F.map_homological_complex _).map g) ≫\n    (F.right_derived_obj_iso n P).inv :=\nbegin\n  dsimp only [functor.right_derived, functor.right_derived_obj_iso],\n  dsimp, simp only [category.comp_id, category.id_comp],\n  rw [←homology_functor_map, homotopy_category.homology_functor_map_factors],\n  simp only [←functor.map_comp],\n  congr' 1,\n  apply homotopy_category.eq_of_homotopy,\n  apply functor.map_homotopy,\n  apply homotopy.trans,\n  exact homotopy_category.homotopy_out_map _,\n  apply InjectiveResolution.desc_homotopy f,\n  { simp, },\n  { simp only [InjectiveResolution.homotopy_equiv_hom_ι_assoc],\n    rw [←category.assoc, w, category.assoc],\n    simp only [InjectiveResolution.homotopy_equiv_inv_ι], },\nend\n\n/-- The natural transformation between right-derived functors induced by a natural transformation.-/\n@[simps]\ndef nat_trans.right_derived {F G : C ⥤ D} [F.additive] [G.additive] (α : F ⟶ G) (n : ℕ) :\n  F.right_derived n ⟶ G.right_derived n :=\nwhisker_left (injective_resolutions C)\n  (whisker_right (nat_trans.map_homotopy_category α _)\n    (homotopy_category.homology_functor D _ n))\n\n@[simp] lemma nat_trans.right_derived_id (F : C ⥤ D) [F.additive] (n : ℕ) :\n  nat_trans.right_derived (𝟙 F) n = 𝟙 (F.right_derived n) :=\nby { simp [nat_trans.right_derived], refl, }\n\n@[simp, nolint simp_nf] lemma nat_trans.right_derived_comp\n  {F G H : C ⥤ D} [F.additive] [G.additive] [H.additive]\n  (α : F ⟶ G) (β : G ⟶ H) (n : ℕ) :\n  nat_trans.right_derived (α ≫ β) n = nat_trans.right_derived α n ≫ nat_trans.right_derived β n :=\nby simp [nat_trans.right_derived]\n\n/--\nA component of the natural transformation between right-derived functors can be computed\nusing a chosen injective resolution.\n-/\nlemma nat_trans.right_derived_eq {F G : C ⥤ D} [F.additive] [G.additive] (α : F ⟶ G) (n : ℕ)\n  {X : C} (P : InjectiveResolution X) :\n  (nat_trans.right_derived α n).app X =\n    (F.right_derived_obj_iso n P).hom ≫\n      (homology_functor D _ n).map ((nat_trans.map_homological_complex α _).app P.cocomplex) ≫\n        (G.right_derived_obj_iso n P).inv :=\nbegin\n  symmetry,\n  dsimp [nat_trans.right_derived, functor.right_derived_obj_iso],\n  simp only [category.comp_id, category.id_comp],\n  rw [←homology_functor_map, homotopy_category.homology_functor_map_factors],\n  simp only [←functor.map_comp],\n  congr' 1,\n  apply homotopy_category.eq_of_homotopy,\n  simp only [nat_trans.map_homological_complex_naturality_assoc,\n    ←functor.map_comp],\n  apply homotopy.comp_left_id,\n  rw [←functor.map_id],\n  apply functor.map_homotopy,\n  apply homotopy_equiv.homotopy_hom_inv_id,\nend\n\nend category_theory\n\nsection\n\nuniverses w v u\n\nopen category_theory.limits category_theory category_theory.functor\n\nvariables {C : Type u} [category.{w} C] {D : Type u} [category.{w} D]\nvariables (F : C ⥤ D) {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z}\n\nnamespace category_theory.abelian.functor\n\nopen category_theory.preadditive\n\nvariables [abelian C] [abelian D] [additive F]\n\n/-- If `preserves_finite_limits F` and `mono f`, then `exact (F.map f) (F.map g)` if\n`exact f g`. -/\nlemma preserves_exact_of_preserves_finite_limits_of_mono [preserves_finite_limits F] [mono f]\n  (ex : exact f g) : exact (F.map f) (F.map g) :=\nabelian.exact_of_is_kernel _ _ (by simp [← functor.map_comp, ex.w]) $\n  limits.is_limit_fork_map_of_is_limit' _ ex.w (abelian.is_limit_of_exact_of_mono _ _ ex)\n\n\n\n/-- Given `P : InjectiveResolution X`, a morphism `(F.right_derived 0).obj X ⟶ F.obj X` given\n`preserves_finite_limits F`. -/\ndef right_derived_zero_to_self_app [enough_injectives C] [preserves_finite_limits F] {X : C}\n  (P : InjectiveResolution X) :\n  (F.right_derived 0).obj X ⟶ F.obj X :=\n(right_derived_obj_iso F 0 P).hom ≫ (homology_iso_kernel_desc _ _ _).hom ≫\n  kernel.map _ _ (cokernel.desc _ (𝟙 _) (by simp)) (𝟙 _) (by { ext, simp }) ≫\n  (as_iso (kernel.lift _ _ (exact_of_map_injective_resolution F P).w)).inv\n\n/-- Given `P : InjectiveResolution X`, a morphism `F.obj X ⟶ (F.right_derived 0).obj X`. -/\ndef right_derived_zero_to_self_app_inv [enough_injectives C] {X : C}\n  (P : InjectiveResolution X) :\n  F.obj X ⟶ (F.right_derived 0).obj X :=\nhomology.lift _ _ _ (F.map (P.ι.f 0) ≫ cokernel.π _) begin\n  have : (complex_shape.up ℕ).rel 0 1 := rfl,\n  rw [category.assoc, cokernel.π_desc, homological_complex.d_from_eq _ this,\n    map_homological_complex_obj_d, ← category.assoc, ← functor.map_comp],\n  simp only [InjectiveResolution.ι_f_zero_comp_complex_d, functor.map_zero, zero_comp],\nend ≫ (right_derived_obj_iso F 0 P).inv\n\nlemma right_derived_zero_to_self_app_comp_inv [enough_injectives C] [preserves_finite_limits F]\n  {X : C} (P : InjectiveResolution X) : right_derived_zero_to_self_app F P ≫\n  right_derived_zero_to_self_app_inv F P = 𝟙 _ :=\nbegin\n  dsimp [right_derived_zero_to_self_app, right_derived_zero_to_self_app_inv],\n  rw [← category.assoc, iso.comp_inv_eq, category.id_comp, category.assoc, category.assoc,\n    ← iso.eq_inv_comp, iso.inv_hom_id],\n  ext,\n  rw [category.assoc, category.assoc, homology.lift_ι, category.id_comp,\n    homology.π'_ι, category.assoc, ←category.assoc _ _ (cokernel.π _), abelian.kernel.lift.inv,\n    ← category.assoc, ← category.assoc _ (kernel.ι _), limits.kernel.lift_ι, category.assoc,\n    category.assoc, ← category.assoc (homology_iso_kernel_desc _ _ _).hom _ _, ← homology.ι,\n    ←category.assoc, homology.π'_ι, category.assoc, ←category.assoc (cokernel.π _), cokernel.π_desc,\n    whisker_eq],\n  convert category.id_comp (cokernel.π _),\nend\n\nlemma right_derived_zero_to_self_app_inv_comp [enough_injectives C] [preserves_finite_limits F]\n  {X : C} (P : InjectiveResolution X) : right_derived_zero_to_self_app_inv F P ≫\n  right_derived_zero_to_self_app F P = 𝟙 _ :=\nbegin\n  dsimp [right_derived_zero_to_self_app, right_derived_zero_to_self_app_inv],\n  rw [← category.assoc _ (F.right_derived_obj_iso 0 P).hom,\n    category.assoc _ _ (F.right_derived_obj_iso 0 P).hom, iso.inv_hom_id, category.comp_id,\n    ← category.assoc, ← category.assoc, is_iso.comp_inv_eq, category.id_comp],\n  ext,\n  simp only [limits.kernel.lift_ι_assoc, category.assoc, limits.kernel.lift_ι, homology.lift],\n  rw [← category.assoc, ← category.assoc, category.assoc _ _ (homology_iso_kernel_desc _ _ _).hom],\n  simp,\nend\n\n/-- Given `P : InjectiveResolution X`, the isomorphism `(F.right_derived 0).obj X ≅ F.obj X` if\n`preserves_finite_limits F`. -/\ndef right_derived_zero_to_self_app_iso [enough_injectives C] [preserves_finite_limits F]\n  {X : C} (P : InjectiveResolution X) : (F.right_derived 0).obj X ≅ F.obj X :=\n{ hom := right_derived_zero_to_self_app _ P,\n  inv := right_derived_zero_to_self_app_inv _ P,\n  hom_inv_id' := right_derived_zero_to_self_app_comp_inv _ P,\n  inv_hom_id' := right_derived_zero_to_self_app_inv_comp _ P }\n\n/-- Given `P : InjectiveResolution X` and `Q : InjectiveResolution Y` and a morphism `f : X ⟶ Y`,\nnaturality of the square given by `right_derived_zero_to_self_natural`. -/\nlemma right_derived_zero_to_self_natural [enough_injectives C]\n  {X : C} {Y : C} (f : X ⟶ Y)\n  (P : InjectiveResolution X) (Q : InjectiveResolution Y) :\n  F.map f ≫ right_derived_zero_to_self_app_inv F Q =\n  right_derived_zero_to_self_app_inv F P ≫ (F.right_derived 0).map f :=\nbegin\n  dsimp [right_derived_zero_to_self_app_inv],\n  simp only [category_theory.functor.map_id, category.id_comp, ← category.assoc],\n  rw [iso.comp_inv_eq, right_derived_map_eq F 0 f (InjectiveResolution.desc f Q P) (by simp),\n    category.assoc, category.assoc, category.assoc, category.assoc, iso.inv_hom_id,\n    category.comp_id, ← category.assoc (F.right_derived_obj_iso 0 P).inv, iso.inv_hom_id,\n    category.id_comp],\n  dsimp only [homology_functor_map],\n  ext,\n  rw [category.assoc, homology.lift_ι, category.assoc, homology.map_ι,\n    ←category.assoc (homology.lift _ _ _ _ _) _ _, homology.lift_ι, category.assoc, cokernel.π_desc,\n    ←category.assoc, ← functor.map_comp, ← category.assoc, homological_complex.hom.sq_from_left,\n    map_homological_complex_map_f, ← functor.map_comp,\n    show f ≫ Q.ι.f 0 = P.ι.f 0 ≫ (InjectiveResolution.desc f Q P).f 0,\n    from homological_complex.congr_hom (InjectiveResolution.desc_commutes f Q P).symm 0],\nend\n\n/-- Given `preserves_finite_limits F`, the natural isomorphism `(F.right_derived 0) ≅ F`. -/\ndef right_derived_zero_iso_self [enough_injectives C] [preserves_finite_limits F] :\n  (F.right_derived 0) ≅ F := iso.symm $\nnat_iso.of_components (λ X, (right_derived_zero_to_self_app_iso _ (InjectiveResolution.of X)).symm)\n  (λ X Y f, right_derived_zero_to_self_natural _ _ _ _)\n\nend category_theory.abelian.functor\n\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/abelian/right_derived.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.49545350808073824}}
{"text": "import algebra.ofe.pi\n\n/-!\n# Logic of bunched implications\n-/\n\nuniverse u\n\n/--\nContains the logical connectives for bundled implications.\n-/\nclass bi_struct (ℙ : Type u) :=\n(entails : ℙ → ℙ → Prop)\n(empty : ℙ)\n(pure : Prop → ℙ)\n(and : ℙ → ℙ → ℙ)\n(or : ℙ → ℙ → ℙ)\n(implies : ℙ → ℙ → ℙ)\n(for_all (A : Type u) : (A → ℙ) → ℙ)\n(there_exists (A : Type u) : (A → ℙ) → ℙ)\n(sep : ℙ → ℙ → ℙ)\n(wand : ℙ → ℙ → ℙ)\n(persistently : ℙ → ℙ)\n(later : ℙ → ℙ)\n\ninfixr ` ⊢ `:26 := bi_struct.entails\nnotation `⌜`:1 p:200 `⌝` := bi_struct.pure p\ninfixr ` ⋀ `:35 := bi_struct.and\ninfixr ` ⋁ `:30 := bi_struct.or\ninfixr ` => `:28 := bi_struct.implies\nnotation `∀'` binders `, ` r:(scoped f, bi_struct.for_all _ f) := r\nnotation `∃'` binders `, ` r:(scoped f, bi_struct.there_exists _ f) := r\ninfixl ` ∗ `:80 := bi_struct.sep\ninfixr ` -∗ `:90 := bi_struct.wand\nprefix `▷ `:100 := bi_struct.later\n\nexport bi_struct (persistently)\n\ndef bi.empty {ℙ : Type u} [bi_struct ℙ] : ℙ := bi_struct.empty\ndef bi.true {ℙ : Type u} [bi_struct ℙ] : ℙ := ⌜true⌝\ndef bi.false {ℙ : Type u} [bi_struct ℙ] : ℙ := ⌜false⌝\n\n/-- Laws for `⊢`. -/\nclass bi_entails (ℙ : Type u) [bi_struct ℙ] :=\n(entails_preorder : is_preorder ℙ (⊢))\n(propext {P Q : ℙ} : P ⊢ Q → Q ⊢ P → P = Q)\n\n-- TODO: Is `bi_mixin_pure_ne` required given Lean's `propext`?\n\n/-- Nonexpansivity laws. -/\nclass bi_nonexpansive (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] :=\n(and_nonexpansive : is_nonexpansive (function.uncurry ((⋀) : ℙ → ℙ → ℙ)))\n(or_nonexpansive : is_nonexpansive (function.uncurry ((⋁) : ℙ → ℙ → ℙ)))\n(implies_nonexpansive : is_nonexpansive (function.uncurry ((=>) : ℙ → ℙ → ℙ)))\n(forall_nonexpansive (A : Type u) : is_nonexpansive (bi_struct.for_all A : (A → ℙ) → ℙ))\n(exists_nonexpansive (A : Type u) : is_nonexpansive (bi_struct.there_exists A : (A → ℙ) → ℙ))\n(sep_nonexpansive : is_nonexpansive (function.uncurry ((∗) : ℙ → ℙ → ℙ)))\n(wand_nonexpansive : is_nonexpansive (function.uncurry ((-∗) : ℙ → ℙ → ℙ)))\n(persistently_nonexpansive : is_nonexpansive (bi_struct.persistently : ℙ → ℙ))\n\n/-- Laws for higher-order logic. -/\nclass bi_hol (ℙ : Type u) [bi_struct ℙ] :=\n(pure_intro {p : Prop} {P : ℙ} : p → P ⊢ ⌜p⌝)\n(pure_elim {p : Prop} {P : ℙ} : (p → bi.true ⊢ P) → ⌜p⌝ ⊢ P)\n(and_intro {P Q R : ℙ} : P ⊢ Q → P ⊢ R → P ⊢ Q ⋀ R)\n(and_elim_left {P Q : ℙ} : P ⋀ Q ⊢ P)\n(and_elim_right {P Q : ℙ} : P ⋀ Q ⊢ Q)\n(or_intro_left {P Q : ℙ} : P ⊢ P ⋁ Q)\n(or_intro_right {P Q : ℙ} : Q ⊢ P ⋁ Q)\n(or_elim {P Q R : ℙ} : P ⊢ R → Q ⊢ R → P ⋁ Q ⊢ R)\n(implies_intro {P Q R : ℙ} : P ⋀ Q ⊢ R → P ⊢ Q => R)\n(implies_elim {P Q R : ℙ} : P ⊢ Q => R → P ⋀ Q ⊢ R)\n(forall_intro {A : Type u} {P : ℙ} {Q : A → ℙ} : (∀ a, P ⊢ Q a) → P ⊢ ∀' a, Q a)\n(forall_elim {A : Type u} {Φ : A → ℙ} {a : A} : (∀' a, Φ a) ⊢ Φ a)\n(exists_intro {A : Type u} {Φ : A → ℙ} {a : A} : Φ a ⊢ ∃' a, Φ a)\n(exists_elim {A : Type u} {P : ℙ} {Q : A → ℙ} : (∀ a, Q a ⊢ P) → (∃' a, Q a) ⊢ P)\n\n/-- Laws for separating conjunction. -/\nclass bi_connectives (ℙ : Type u) [bi_struct ℙ] :=\n(sep_mono {P Q R S : ℙ} : P ⊢ Q → R ⊢ S → P ∗ R ⊢ Q ∗ S)\n(empty_sep {P : ℙ} : P ⊢ bi.empty ∗ P)\n(sep_empty {P : ℙ} : P ⊢ P ∗ bi.empty)\n(sep_comm {P Q : ℙ} : P ∗ Q ⊢ Q ∗ P)\n(sep_assoc {P Q R : ℙ} : P ∗ Q ∗ R ⊢ P ∗ (Q ∗ R))\n(wand_intro {P Q R : ℙ} : P ∗ Q ⊢ R → P ⊢ Q -∗ R)\n(wand_elim {P Q R : ℙ} : P ⊢ Q -∗ R → P ∗ Q ⊢ R)\n\nclass bi_persistently (ℙ : Type u) [bi_struct ℙ] :=\n(persistently_mono {P Q : ℙ} : P ⊢ Q → persistently P ⊢ persistently Q)\n(persistently_persistently {P : ℙ} : persistently P ⊢ persistently (persistently P))\n(persistently_empty : (bi.empty : ℙ) ⊢ persistently bi.empty)\n(persistently_and {P Q : ℙ} : persistently P ⋀ persistently Q ⊢ persistently (P ⋀ Q))\n(persistently_exists {A : Type u} {Φ : A → ℙ} :\n  persistently (∃' a, Φ a) ⊢ ∃' a, persistently (Φ a))\n(persistently_sep {P Q : ℙ} : persistently (P ∗ Q) ⊢ persistently P)\n(persistently_and_sep_elim {P Q : ℙ} : persistently (P ⋀ Q) ⊢ P ∗ Q)\n\nclass bi_later (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] :=\n(later_nonexpansive : is_nonexpansive (bi_struct.later : ℙ → ℙ))\n(later_mono {P Q : ℙ} : P ⊢ Q → ▷ P ⊢ ▷ Q)\n(later_intro {P : ℙ} : P ⊢ ▷ P)\n(forall_later {A : Type u} {Φ : A → ℙ} : (∀' a, ▷ Φ a) ⊢ ▷ ∀' a, Φ a)\n(later_exists_false {A : Type u} {Φ : A → ℙ} : (▷ ∃' a, Φ a) ⊢ ▷ bi.false ⋁ (∃' a, ▷ Φ a))\n(later_sep {P Q : ℙ} : ▷ (P ∗ Q) ⊢ ▷ P ∗ ▷ Q)\n(later_sep' {P Q : ℙ} : ▷ P ∗ ▷ Q ⊢ ▷ (P ∗ Q))\n(persistently_later {P : ℙ} : ▷ persistently P ⊢ persistently ▷ P)\n(later_persistently {P : ℙ} : persistently ▷ P ⊢ ▷ persistently P)\n(later_false_em {P : ℙ} : ▷ P ⊢ ▷ bi.false ⋁ (▷ bi.false => P))\n\nclass bi (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] extends\n  bi_entails ℙ, bi_nonexpansive ℙ, bi_hol ℙ, bi_connectives ℙ, bi_persistently ℙ, bi_later ℙ\n\nnamespace bi\n\nvariables {ℙ : Type u} [ofe ℙ] [bi_struct ℙ] [bi ℙ]\nvariables {n : ℕ} {p : Prop} {A : Type u} {P Q R S : ℙ} {Φ Ψ : A → ℙ}\n\n/-!\n# Laws for `⊢`\n-/\n\n@[refl] lemma entails_refl (P : ℙ) : P ⊢ P := bi_entails.entails_preorder.1.refl P\nlemma entails_rfl {P : ℙ} : P ⊢ P := entails_refl P\n/-- The cut law. -/\n@[trans] lemma entails_trans : P ⊢ Q → Q ⊢ R → P ⊢ R := bi_entails.entails_preorder.2.trans P Q R\nlemma propext : P ⊢ Q → Q ⊢ P → P = Q := bi_entails.propext\n\nlemma propext_iff : P = Q ↔ (P ⊢ Q) ∧ (Q ⊢ P) :=\nbegin\n  split,\n  { rintro rfl, split; refl, },\n  { intro h, exact propext h.1 h.2, },\nend\n\n/-!\n# Nonexpansivity laws\n-/\n\nlemma and_eq_at : P =[n] R → Q =[n] S → (P ⋀ Q) =[n] (R ⋀ S) :=\nbegin\n  intros h₁ h₂,\n  have := bi_nonexpansive.and_nonexpansive,\n  exact @this n ⟨P, Q⟩ ⟨R, S⟩ ⟨h₁, h₂⟩,\n  apply_instance,\nend\n\nlemma or_eq_at : P =[n] R → Q =[n] S → (P ⋁ Q) =[n] (R ⋁ S) :=\nbegin\n  intros h₁ h₂,\n  have := bi_nonexpansive.or_nonexpansive,\n  exact @this n ⟨P, Q⟩ ⟨R, S⟩ ⟨h₁, h₂⟩,\n  apply_instance,\nend\n\nlemma implies_eq_at : P =[n] R → Q =[n] S → (P => Q) =[n] (R => S) :=\nbegin\n  intros h₁ h₂,\n  have := bi_nonexpansive.implies_nonexpansive,\n  exact @this n ⟨P, Q⟩ ⟨R, S⟩ ⟨h₁, h₂⟩,\n  apply_instance,\nend\n\nlemma forall_eq_at : (∀ a, Φ a =[n] Ψ a) → (∀' a, Φ a) =[n] (∀' a, Ψ a) :=\nλ h, bi_nonexpansive.forall_nonexpansive A h\n\nlemma exists_eq_at : (∀ a, Φ a =[n] Ψ a) → (∃' a, Φ a) =[n] (∃' a, Ψ a) :=\nλ h, bi_nonexpansive.exists_nonexpansive A h\n\nlemma sep_eq_at : P =[n] R → Q =[n] S → (P ∗ Q) =[n] (R ∗ S) :=\nbegin\n  intros h₁ h₂,\n  have := bi_nonexpansive.sep_nonexpansive,\n  exact @this n ⟨P, Q⟩ ⟨R, S⟩ ⟨h₁, h₂⟩,\n  apply_instance,\nend\n\nlemma wand_eq_at : P =[n] R → Q =[n] S → (P -∗ Q) =[n] (R -∗ S) :=\nbegin\n  intros h₁ h₂,\n  have := bi_nonexpansive.wand_nonexpansive,\n  exact @this n ⟨P, Q⟩ ⟨R, S⟩ ⟨h₁, h₂⟩,\n  apply_instance,\nend\n\nlemma persistently_eq_at : P =[n] Q → persistently P =[n] persistently Q :=\nλ h, bi_nonexpansive.persistently_nonexpansive h\n\n/-!\n# Higher order logic\nWe show that `bi` induces a Heyting algebra.\n-/\n\nlemma pure_intro : p → P ⊢ ⌜p⌝ := bi_hol.pure_intro\nlemma pure_elim : (p → true ⊢ P) → ⌜p⌝ ⊢ P := bi_hol.pure_elim\nlemma entails_true : P ⊢ true := pure_intro trivial\nlemma false_entails : false ⊢ P := pure_elim false.elim\n\n/-! ## Basic logical laws -/\n\nlemma and_intro : P ⊢ Q → P ⊢ R → P ⊢ Q ⋀ R := bi_hol.and_intro\nlemma and_elim_left : P ⋀ Q ⊢ P := bi_hol.and_elim_left\nlemma and_elim_right : P ⋀ Q ⊢ Q := bi_hol.and_elim_right\n\nlemma or_intro_left : P ⊢ P ⋁ Q := bi_hol.or_intro_left\nlemma or_intro_right : Q ⊢ P ⋁ Q := bi_hol.or_intro_right\nlemma or_elim : P ⊢ R → Q ⊢ R → P ⋁ Q ⊢ R := bi_hol.or_elim\n\nlemma implies_intro : P ⋀ Q ⊢ R → P ⊢ Q => R := bi_hol.implies_intro\nlemma implies_elim : P ⊢ Q => R → P ⋀ Q ⊢ R := bi_hol.implies_elim\nlemma implies_iff : P ⊢ Q => R ↔ P ⋀ Q ⊢ R := ⟨implies_elim, implies_intro⟩\n\nlemma forall_intro : (∀ a, P ⊢ Φ a) → P ⊢ ∀' a, Φ a := bi_hol.forall_intro\nlemma forall_elim (Φ : A → ℙ) (a : A) : (∀' a, Φ a) ⊢ Φ a := bi_hol.forall_elim\n\nlemma exists_intro (Φ : A → ℙ) (a : A) : Φ a ⊢ ∃' a, Φ a := bi_hol.exists_intro\nlemma exists_elim : (∀ a, Φ a ⊢ P) → (∃' a, Φ a) ⊢ P := bi_hol.exists_elim\n\n/-!\n## Heyting algebra\n\nWe show `ℙ` forms a Heyting algebra and a complete lattice.\nWe can deduce many logical laws from these typeclasses.\n-/\n\ninstance : lattice ℙ := {\n  sup := (⋁),\n  inf := (⋀),\n  le := (⊢),\n  le_refl := entails_refl,\n  le_trans := λ _ _ _, entails_trans,\n  le_antisymm := λ _ _, propext,\n  le_sup_left := λ _ _, or_intro_left,\n  le_sup_right := λ _ _, or_intro_right,\n  sup_le := λ _ _ _, or_elim,\n  inf_le_left := λ _ _, and_elim_left,\n  inf_le_right := λ _ _, and_elim_right,\n  le_inf := λ _ _ _, and_intro,\n}\n\ninstance : heyting_algebra ℙ := {\n  top := true,\n  himp := (=>),\n  le_top := λ _, entails_true,\n  le_himp_iff := λ _ _ _, implies_iff,\n  bot := false,\n  compl := λ P, P => false,\n  bot_le := λ _, false_entails,\n  himp_bot := λ _, rfl,\n  ..bi.lattice\n}\n\ninstance : complete_lattice ℙ := {\n  Sup := λ S, ∃' P : S, P,\n  le_Sup := λ S P hP, exists_intro (λ p : S, (p : ℙ)) (⟨P, hP⟩ : S),\n  Sup_le := λ S P h, exists_elim (λ Q, h Q Q.prop),\n  Inf := λ S, ∀' P : S, P,\n  Inf_le := λ S P hP, forall_elim (λ p : S, (p : ℙ)) (⟨P, hP⟩ : S),\n  le_Inf := λ S P h, forall_intro (λ Q, h Q Q.prop),\n  ..bi.heyting_algebra\n}\n\ninstance : distrib_lattice ℙ := generalized_heyting_algebra.to_distrib_lattice\n\nlemma and_or_distrib_left : (P ⋀ (Q ⋁ R)) = (P ⋀ Q ⋁ P ⋀ R) := inf_sup_left\nlemma and_or_distrib_right : ((P ⋁ Q) ⋀ R) = (P ⋀ R ⋁ Q ⋀ R) := inf_sup_right\nlemma or_and_distrib_left : (P ⋁ (Q ⋀ R)) = ((P ⋁ Q) ⋀ (P ⋁ R)) := sup_inf_left\nlemma or_and_distrib_right : ((P ⋀ Q) ⋁ R) = ((P ⋁ R) ⋀ (Q ⋁ R)) := sup_inf_right\n\n/-!\n## Bunched implication connectives\n\nWe prove facts about separating conjunction and magic wand.\n-/\n\nlemma sep_mono : P ⊢ Q → R ⊢ S → P ∗ R ⊢ Q ∗ S := bi_connectives.sep_mono\nlemma empty_sep : P ⊢ empty ∗ P := bi_connectives.empty_sep\nlemma sep_empty : P ⊢ P ∗ empty := bi_connectives.sep_empty\nlemma sep_comm : P ∗ Q = Q ∗ P := propext bi_connectives.sep_comm bi_connectives.sep_comm\nlemma sep_assoc : P ∗ Q ∗ R = P ∗ (Q ∗ R) :=\nbegin\n  refine propext bi_connectives.sep_assoc _,\n  rw sep_comm,\n  refine entails_trans bi_connectives.sep_assoc _,\n  rw sep_comm,\n  refine entails_trans bi_connectives.sep_assoc _,\n  rw sep_comm,\nend\nlemma entails_wand : (P ⊢ Q -∗ R) ↔ (P ∗ Q ⊢ R) :=\n⟨bi_connectives.wand_elim, bi_connectives.wand_intro⟩\n\n/-!\n## Persistently\n-/\n\nlemma persistently_mono : P ⊢ Q → persistently P ⊢ persistently Q :=\nbi_persistently.persistently_mono\n\nlemma persistently_persistently : persistently P ⊢ persistently (persistently P) :=\nbi_persistently.persistently_persistently\n\nlemma persistently_empty : (empty : ℙ) ⊢ persistently empty :=\nbi_persistently.persistently_empty\n\nlemma persistently_and : persistently P ⋀ persistently Q ⊢ persistently (P ⋀ Q) :=\nbi_persistently.persistently_and\n\nlemma persistently_exists : persistently (∃' a, Φ a) ⊢ ∃' a, persistently (Φ a) :=\nbi_persistently.persistently_exists\n\nlemma persistently_sep : persistently (P ∗ Q) ⊢ persistently P :=\nbi_persistently.persistently_sep\n\nlemma persistently_and_sep_elim : persistently (P ⋀ Q) ⊢ P ∗ Q :=\nbi_persistently.persistently_and_sep_elim\n\n/-!\n# Later\n-/\n\nlemma later_nonexpansive : is_nonexpansive (bi_struct.later : ℙ → ℙ) :=\nbi_later.later_nonexpansive\n\nlemma later_mono : P ⊢ Q → ▷ P ⊢ ▷ Q :=\nbi_later.later_mono\n\nlemma later_intro : P ⊢ ▷ P :=\nbi_later.later_intro\n\nlemma forall_later : (∀' a, ▷ Φ a) ⊢ ▷ ∀' a, Φ a :=\nbi_later.forall_later\n\nlemma later_exists_false : (▷ ∃' a, Φ a) ⊢ ▷ false ⋁ (∃' a, ▷ Φ a) :=\nbi_later.later_exists_false\n\nlemma later_sep : (▷ (P ∗ Q)) = (▷ P ∗ ▷ Q) :=\npropext bi_later.later_sep bi_later.later_sep'\n\nlemma persistently_later : (▷ persistently P) = (persistently ▷ P) :=\npropext bi_later.persistently_later bi_later.later_persistently\n\nlemma later_false_em : ▷ P ⊢ ▷ false ⋁ (▷ false => P) :=\nbi_later.later_false_em\n\n/-!\n# Derived connectives\n-/\n\ndef iff (P Q : ℙ) : ℙ := (P => Q) ⋀ (Q => P)\ninfixr ` <=> `:28 := iff\n\ndef wand_iff (P Q : ℙ) : ℙ := (P -∗ Q) ⋀ (Q -∗ P)\ninfixr ` ∗-∗ `:90 := wand_iff\n\nclass persistent (P : ℙ) : Prop :=\n(entails_persistently : P ⊢ persistently P)\n\ndef affinely (P : ℙ) := empty ⋀ P\n\nclass affine (P : ℙ) : Prop :=\n(entails_empty : P ⊢ empty)\n\ndef absorbingly (P : ℙ) := true ∗ P\n\nclass absorbing (P : ℙ) : Prop :=\n(absorbingly_entails : absorbingly P ⊢ P)\n\ndef intuitionistically : ℙ → ℙ := affinely ∘ persistently\nprefix `□ `:100 := intuitionistically\n\ndef persistently_if (p : Prop) [decidable p] (P : ℙ) :=\nif p then persistently P else P\n\ndef affinely_if (p : Prop) [decidable p] (P : ℙ) :=\nif p then affinely P else P\n\ndef absorbingly_if (p : Prop) [decidable p] (P : ℙ) :=\nif p then absorbingly P else P\n\ndef intuitionistically_if (p : Prop) [decidable p] (P : ℙ) :=\nif p then □ P else P\n\ndef latern : Π (n : ℕ) (P : ℙ), ℙ\n| 0 P := P\n| (n + 1) P := ▷ latern n P\n\ndef except_zero (P : ℙ) := ▷ false ⋁ P\nprefix `◇ `:100 := except_zero\n\nclass timeless (P : ℙ) : Prop :=\n(later_entails_except_zero : ▷ P ⊢ ◇ P)\n\n/-!\n# Extensions\n\nDefinitions for various extensions to the BI interface.\n-/\n\nclass bi_affine (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] [bi ℙ] : Prop :=\n(is_affine (P : ℙ) : affine P)\n\nclass bi_positive (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] [bi ℙ] : Prop :=\n(affinely_sep (P Q : ℙ) : affinely (P ∗ Q) ⊢ affinely P ∗ Q)\n\nclass bi_loeb (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] [bi ℙ] : Prop :=\n(true_entails (P : ℙ) : ▷ P ⊢ P → true ⊢ P)\n\nclass bi_later_contractive (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] [bi ℙ] : Prop :=\n(later_contractive : is_contractive (bi_struct.later : ℙ → ℙ))\n\nclass bi_persistently_forall (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] [bi ℙ] : Prop :=\n(persistently_forall {A : Type u} {Φ : A → ℙ} : (∀' a, persistently (Φ a)) ⊢ persistently ∀' a, Φ a)\n\nclass bi_pure_forall (ℙ : Type u) [ofe ℙ] [bi_struct ℙ] [bi ℙ] : Prop :=\n(pure_forall {A : Type u} {Φ : A → Prop} : (∀' a, ⌜Φ a⌝ : ℙ) ⊢ ⌜∀ a, Φ a⌝)\n\nend bi\n", "meta": {"author": "zeramorphic", "repo": "separation-logic", "sha": "51c131501cc541b3aae072957942e8ef744c4ebf", "save_path": "github-repos/lean/zeramorphic-separation-logic", "path": "github-repos/lean/zeramorphic-separation-logic/separation-logic-51c131501cc541b3aae072957942e8ef744c4ebf/src/bi/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.495453502932761}}
{"text": "import tactic \nimport data.nat.parity\nimport data.multiset.basic \n\n\nopen finset\nopen function\nopen list\n\nnamespace aux_walk\n\ndef rmv_unt_aux {A : Type} [decidable_eq A] : A → list A → list A \n  | a [] := []\n  | a (x::xs) := ite (a ∈ (x::xs)) (rmv_unt_aux a xs) (x::xs)\n  \nlemma rmv_aux_not_a {A : Type} [decidable_eq A] : ∀ a : A, ∀ l : list A,\na ∉ rmv_unt_aux a l :=\nbegin \n  intros a l,\n  induction l with x xs hxs,\n  unfold rmv_unt_aux,\n  exact not_mem_nil a,\n  unfold rmv_unt_aux,\n  split_ifs,\n  exact hxs,\n  exact h,\nend\n\nlemma rmv_aux_inf_count {A : Type} [decidable_eq A] : ∀ a b: A, ∀ l : list A,\ncount b (rmv_unt_aux a l) ≤ count b l :=\nbegin \n  intros a b l,\n  induction l with x xs hxs,\n  unfold rmv_unt_aux,\n  unfold rmv_unt_aux,\n  split_ifs,\n  transitivity (count b xs),\n  exact hxs,\n  exact count_le_count_cons b x xs,\n  refl,\nend\n\nlemma rmv_aux_smaller {A : Type} [decidable_eq A] : ∀ a: A, ∀ l : list A,\nlength (rmv_unt_aux a l) ≤ length l :=\nbegin \n  intros a l,\n  induction l with x xs hxs,\n  unfold rmv_unt_aux,\n  unfold rmv_unt_aux,\n  split_ifs,\n  transitivity (xs.length),\n  exact hxs,\n  rw length_cons,\n  linarith,\n  refl,\nend\n\nlemma rmv_aux_in {A : Type} [decidable_eq A] : ∀ a b: A, ∀ l : list A,\nb ∈ (rmv_unt_aux a l) → b ∈ l :=\nbegin \n  intros a b l,\n  induction l with x xs hxs,\n  {\n    unfold rmv_unt_aux,\n    intro hb, exact hb,\n  },\n  {\n    intro hb,\n    unfold rmv_unt_aux at hb,\n    split_ifs at hb,\n    specialize hxs hb,\n    exact mem_cons_of_mem x hxs,\n    exact hb,\n  }\nend\n\nlemma rmv_aux_suffix {A : Type} [decidable_eq A] : ∀ a : A, ∀ l : list A,\n(rmv_unt_aux a l) = l ∨ (a ::(rmv_unt_aux a l)) <:+ l :=\nbegin \n  intros a l,\n  induction l with x xs hxs,\n  {\n    left,\n    unfold rmv_unt_aux,\n  },\n  {\n    repeat {unfold rmv_unt_aux},\n    split_ifs, swap,\n    {\n      left,\n      split;refl,\n    },\n    {\n      right,\n      rw suffix_cons_iff,\n      cases hxs with hxs hxs,\n      {\n        repeat {rw hxs},\n        left,\n        congr,\n        rw mem_cons_iff at h,\n        cases h with h h, exact h,\n        induction xs with y ys hys,\n        {\n          exfalso,\n          exact not_mem_nil a h,\n        },\n        {\n          unfold rmv_unt_aux at hxs,\n          split_ifs at hxs,\n          exfalso,\n          apply_fun list.length at hxs,\n          simp at hxs,\n          have hxs' := rmv_aux_smaller a ys,\n          linarith,\n        }\n      },\n      {\n        right,\n        exact hxs,\n      }\n    }\n\n  }\nend\n\nlemma rmv_aux_eq {A : Type} [decidable_eq A] : ∀ a : A, ∀ l : list A,\n(rmv_unt_aux a l) = l ↔ (a ∉ l) :=\nbegin\n  intros a l,\n  have hal := rmv_aux_suffix a l,\n  cases hal with hal hal, swap,\n  {\n    split,\n    intro h,\n    exfalso,\n    rw h at hal,\n    replace hal := length_le_of_sublist (sublist_of_suffix hal),\n    rw length_cons at hal,\n    linarith,\n    intro h,\n    exfalso,\n    apply h,\n    replace hal := sublist_of_suffix hal,\n    replace hal := sublist.subset hal,\n    apply hal,\n    exact mem_cons_self a (rmv_unt_aux a l),\n  },\n  {\n    rw hal,\n    simp,\n    induction l with x xs hxs,\n    exact not_mem_nil a,\n    unfold rmv_unt_aux at hal,\n    split_ifs at hal, swap, exact h,\n    exfalso,\n    apply_fun list.length at hal,\n    have hal' := rmv_aux_smaller a xs,\n    rw length_cons at hal,\n    linarith,\n  }\n  \nend\n\nlemma rmv_aux_empty {A : Type} [decidable_eq A] [inhabited A] : ∀ a : A, ∀ l : list A,\n(rmv_unt_aux a l) = nil ↔ l = nil ∨ l.ilast = a :=\nbegin \n  intros a l,\n  split,\n  {\n    intro h,\n    induction l with x xs hxs,\n    {\n      left,\n      refl,\n    },\n    {\n      right,\n      unfold rmv_unt_aux at h,\n      split_ifs at h,\n      {\n        specialize hxs h,\n        cases hxs with hxs hxs,\n        rw hxs at *,\n        finish,\n      },\n      {\n        \n      }\n    }\n  }\nend\ndef rmv_unt {A : Type} [decidable_eq A] : list A → list A \n  | [] := []\n  | (x::xs) := have (rmv_unt_aux x xs).sizeof < 1 + xs.sizeof :=\n  begin \n    induction xs with y ys hys,\n    {\n      unfold rmv_unt_aux,\n      linarith,\n    },\n    {\n      unfold rmv_unt_aux,\n      split_ifs,\n      {\n        unfold list.sizeof,\n        linarith,\n      },\n      {\n        linarith,\n      }\n    }\n  end,\n  x::rmv_unt(rmv_unt_aux x xs)\n    \nlemma rmv_in {A : Type} [decidable_eq A] : ∀ b: A, ∀ l : list A,\n b ∈ (rmv_unt l) → b ∈ l  :=\nbegin \n  intros b l,\n  obtain ⟨n, hn⟩ : {n : ℕ // l.length = n} := ⟨_, rfl⟩,\n  revert l,\n  apply nat.strong_induction_on n,\n  intros m hm l hl hb,\n  induction l with x xs hxs,\n  {\n    unfold rmv_unt at hb,\n    exact hb,\n  },\n  {\n    unfold rmv_unt at hb,\n    rw mem_cons_iff at hb ⊢,\n    simp at hl,\n    cases hb with hb hb,\n    {\n      left,\n      exact hb,\n    },\n    {\n      right,\n      apply rmv_aux_in x,\n      apply hm (rmv_unt_aux x xs).length,\n      rw ← hl,\n      have hl' := rmv_aux_smaller x xs,\n      linarith,\n      refl,\n      exact hb,\n    }\n  }\nend\n\nlemma rmv_nodup {A : Type} [decidable_eq A] : ∀ l : list A,\nnodup (rmv_unt l) :=\nbegin \n  intros l,\n  obtain ⟨n, hn⟩ : {n : ℕ // l.length = n} := ⟨_, rfl⟩,\n  revert l,\n  apply nat.strong_induction_on n,\n  intros m hm l hl,\n  induction l with x xs hxs,\n  {\n    unfold rmv_unt,\n    exact nodup_nil,\n  },\n  {\n    unfold rmv_unt,\n    clear hxs,\n    rw nodup_cons,\n    split,\n    {\n      intro hx,\n      apply rmv_aux_not_a x xs,\n      apply rmv_in,\n      exact hx,\n    },\n    {\n      apply hm, swap 3,\n      exact (rmv_unt_aux x xs).length,\n      rw ← hl,\n      rw length_cons,\n      have hxs := rmv_aux_smaller x xs,\n      linarith,\n      refl,\n    }\n  }\nend\n\nlemma rmv_empty {A : Type} [decidable_eq A] : ∀ l : list A,\nl = nil ↔ rmv_unt l = nil := \nbegin \n  intro l,\n  split,\n  {\n    intro h,\n    rw h,\n    unfold rmv_unt,\n  },\n  {\n    intro h,\n    induction l with x xs hxs,\n    refl,\n    exfalso,\n    unfold rmv_unt at h,\n    contradiction,\n  }\nend\n\nlemma rmv_head {A : Type} [decidable_eq A] [inhabited A] : ∀ l : list A,\n(l ≠ nil) → (l.head = list.head (rmv_unt l)) :=\nbegin \n  intros l hl,\n  induction l with x xs hxs,\n  tauto,\n  unfold rmv_unt,\n  simp,\nend\n\nlemma rmv_last {A : Type} [decidable_eq A] [inhabited A] : ∀ l : list A,\n(l ≠ nil) → (l.ilast = list.ilast (rmv_unt l)) :=\nbegin \n  intros l hl,\n  induction l with x xs hxs,\n  tauto,\n  unfold rmv_unt,\n  by_cases hs : xs = nil,\n  {\n    rw hs,\n    unfold rmv_unt_aux rmv_unt,\n  },\n  {\n    specialize hxs hs,\n    repeat {rw ilast_eq_last'},\n    have h1 := last'_append_of_ne_nil [x] hs,\n  }\nend\nend aux_walk", "meta": {"author": "Junkyards3", "repo": "lean_graphs", "sha": "5e90348e6bed3aff69969e7b3ff84e5be59708af", "save_path": "github-repos/lean/Junkyards3-lean_graphs", "path": "github-repos/lean/Junkyards3-lean_graphs/lean_graphs-5e90348e6bed3aff69969e7b3ff84e5be59708af/aux_walk.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.49545350293276097}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.category.Group.limits\nimport Mathlib.algebra.category.Group.preadditive\nimport Mathlib.category_theory.limits.shapes.biproducts\nimport Mathlib.category_theory.limits.shapes.types\nimport Mathlib.algebra.group.pi\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\n/-!\n# The category of abelian groups has finite biproducts\n-/\n\nnamespace AddCommGroup\n\n\n/--\nConstruct limit data for a binary product in `AddCommGroup`, using `AddCommGroup.of (G × H)`.\n-/\ndef binary_product_limit_cone (G : AddCommGroup) (H : AddCommGroup) :\n    category_theory.limits.limit_cone (category_theory.limits.pair G H) :=\n  category_theory.limits.limit_cone.mk\n    (category_theory.limits.cone.mk (of (↥G × ↥H))\n      (category_theory.nat_trans.mk\n        fun (j : category_theory.discrete category_theory.limits.walking_pair) =>\n          category_theory.limits.walking_pair.cases_on j (add_monoid_hom.fst ↥G ↥H)\n            (add_monoid_hom.snd ↥G ↥H)))\n    (category_theory.limits.is_limit.mk\n      fun (s : category_theory.limits.cone (category_theory.limits.pair G H)) =>\n        add_monoid_hom.prod\n          (category_theory.nat_trans.app (category_theory.limits.cone.π s)\n            category_theory.limits.walking_pair.left)\n          (category_theory.nat_trans.app (category_theory.limits.cone.π s)\n            category_theory.limits.walking_pair.right))\n\nprotected instance has_binary_product (G : AddCommGroup) (H : AddCommGroup) :\n    category_theory.limits.has_binary_product G H :=\n  category_theory.limits.has_limit.mk (binary_product_limit_cone G H)\n\nprotected instance category_theory.limits.has_binary_biproduct (G : AddCommGroup)\n    (H : AddCommGroup) : category_theory.limits.has_binary_biproduct G H :=\n  category_theory.limits.has_binary_biproduct.of_has_binary_product G H\n\n/--\nWe verify that the biproduct in AddCommGroup is isomorphic to\nthe cartesian product of the underlying types:\n-/\ndef biprod_iso_prod (G : AddCommGroup) (H : AddCommGroup) : G ⊞ H ≅ of (↥G × ↥H) :=\n  category_theory.limits.is_limit.cone_point_unique_up_to_iso\n    (category_theory.limits.binary_biproduct.is_limit G H)\n    (category_theory.limits.limit_cone.is_limit (binary_product_limit_cone G H))\n\n-- Furthermore, our biproduct will automatically function as a coproduct.\n\nnamespace has_limit\n\n\n/--\nThe map from an arbitrary cone over a indexed family of abelian groups\nto the cartesian product of those groups.\n-/\ndef lift {J : Type u} (F : category_theory.discrete J ⥤ AddCommGroup)\n    (s : category_theory.limits.cone F) :\n    category_theory.limits.cone.X s ⟶\n        of ((j : category_theory.discrete J) → ↥(category_theory.functor.obj F j)) :=\n  add_monoid_hom.mk\n    (fun (x : ↥(category_theory.limits.cone.X s)) (j : category_theory.discrete J) =>\n      coe_fn (category_theory.nat_trans.app (category_theory.limits.cone.π s) j) x)\n    sorry sorry\n\n@[simp] theorem lift_apply {J : Type u} (F : category_theory.discrete J ⥤ AddCommGroup)\n    (s : category_theory.limits.cone F) (x : ↥(category_theory.limits.cone.X s)) (j : J) :\n    coe_fn (lift F s) x j =\n        coe_fn (category_theory.nat_trans.app (category_theory.limits.cone.π s) j) x :=\n  rfl\n\n/--\nConstruct limit data for a product in `AddCommGroup`, using `AddCommGroup.of (Π j, F.obj j)`.\n-/\ndef product_limit_cone {J : Type u} (F : category_theory.discrete J ⥤ AddCommGroup) :\n    category_theory.limits.limit_cone F :=\n  category_theory.limits.limit_cone.mk\n    (category_theory.limits.cone.mk\n      (of ((j : category_theory.discrete J) → ↥(category_theory.functor.obj F j)))\n      (category_theory.discrete.nat_trans\n        fun (j : category_theory.discrete J) =>\n          add_monoid_hom.apply\n            (fun (j : category_theory.discrete J) => ↥(category_theory.functor.obj F j)) j))\n    (category_theory.limits.is_limit.mk (lift F))\n\nend has_limit\n\n\nprotected instance category_theory.limits.has_biproduct {J : Type u} [DecidableEq J] [fintype J]\n    (f : J → AddCommGroup) : category_theory.limits.has_biproduct f :=\n  category_theory.limits.has_biproduct.of_has_product f\n\n/--\nWe verify that the biproduct we've just defined is isomorphic to the AddCommGroup structure\non the dependent function type\n-/\ndef biproduct_iso_pi {J : Type u} [DecidableEq J] [fintype J] (f : J → AddCommGroup) :\n    ⨁ f ≅ of ((j : J) → ↥(f j)) :=\n  category_theory.limits.is_limit.cone_point_unique_up_to_iso\n    (category_theory.limits.biproduct.is_limit f)\n    (category_theory.limits.limit_cone.is_limit\n      (has_limit.product_limit_cone (category_theory.discrete.functor f)))\n\nprotected instance category_theory.limits.has_finite_biproducts :\n    category_theory.limits.has_finite_biproducts AddCommGroup :=\n  category_theory.limits.has_finite_biproducts.mk\n    fun (J : Type u_1) (_x : DecidableEq J) (_x_1 : fintype J) =>\n      category_theory.limits.has_biproducts_of_shape.mk\n        fun (f : J → AddCommGroup) => category_theory.limits.has_biproduct f\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/category/Group/biproducts_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4954534958644562}}
{"text": "import to_mathlib.analysis.inner_product_space.rotation\nimport to_mathlib.analysis.inner_product_space.dual\nimport local.parametric_h_principle\n\n/-!\nThis is file proves the existence of a sphere eversion from the local verson of the h-principle.\n\nWe define the relation of immersions `R = immersion_sphere_rel ⊆ J¹(E, F)` which consist of all\n`(x, y, ϕ)` such that if `x` is outside a ball around the origin with chosen radius `R < 1` then\n`ϕ` must be injective on `(ℝ ∙ x)ᗮ` (the orthogonal complement of the span of `x`).\nWe show that `R` is open and ample.\n\nFurthermore, we define a formal solution of sphere eversion that is holonomic near `0` and `1`.\nWe have to be careful since we're not actually working on the sphere,\nbut in the ambient space `E ≃ ℝ³`.\nSee `loc_formal_eversion` for the choice and constaints of the solution.\n\nFinally, we obtain the existence of sphere eversion from the parametric local h-principle,\nproven in `local.parametric_h_principle`.\n-/\nnoncomputable theory\n\nopen metric finite_dimensional set function rel_loc filter (hiding mem_map) inner_product_space\n  submodule linear_map (ker)\nopen_locale topology real_inner_product_space\n\nsection sphere_eversion\n\nvariables\n{E : Type*} [normed_add_comm_group E] [inner_product_space ℝ E]\n{F : Type*} [normed_add_comm_group F] [inner_product_space ℝ F]\n\nlocal notation `𝕊²` := sphere (0 : E) 1\nlocal notation `dim` := finrank ℝ\nlocal notation `pr[`x`]ᗮ` := orthogonal_projection (ℝ ∙ x)ᗮ\nlocal notation (name := dot_print_only) R ` ∙ `:1000 x := submodule.span R {x}\nlocal notation (name := dot_local) R ` ∙ `:1000 x :=\n  submodule.span R (@singleton _ _ set.has_singleton x)\nlocal notation `B` := ball (0 : E) 0.9\n\n/-- A map between vector spaces is a immersion viewed as a map on the sphere, when its\nderivative at `x ∈ 𝕊²` is injective on the orthogonal complement of `x`\n(the tangent space to the sphere). Note that this implies `f` is differentiable at every point\n`x ∈ 𝕊²` since otherwise `D f x = 0`.\n-/\ndef sphere_immersion (f : E → F) : Prop :=\n∀ x ∈ 𝕊², inj_on (D f x) (ℝ ∙ x)ᗮ\n\nvariables (E F)\n\n/-- The relation of immersionsof a two-sphere into its ambient Euclidean space. -/\ndef immersion_sphere_rel : rel_loc E F :=\n{w : one_jet E F | w.1 ∉ B → inj_on w.2.2 (ℝ ∙ w.1)ᗮ }\n\nlocal notation `R` := immersion_sphere_rel E F\n\nvariables {E F}\n\n@[simp] lemma mem_loc_immersion_rel {x y φ} :\n  (⟨x, y, φ⟩ : one_jet E F) ∈ immersion_sphere_rel E F ↔ x ∉ B → inj_on φ (ℝ ∙ x)ᗮ :=\niff.rfl\n\nlemma sphere_immersion_of_sol (f : E → F) :\n  (∀ x ∈ 𝕊², (x, f x, fderiv ℝ f x) ∈ immersion_sphere_rel E F) → sphere_immersion f :=\nbegin\n  intros h x x_in,\n  have : x ∉ B,\n  { rw mem_sphere_zero_iff_norm at x_in,\n    norm_num [x_in] },\n  exact h x x_in this\nend\n\nlemma mem_slice_iff_of_not_mem {x : E} {w : F} {φ : E →L[ℝ] F} {p : dual_pair E}\n  (hx : x ∉ B) (y : F) : w ∈ slice R p (x, y, φ) ↔ inj_on (p.update φ w) (ℝ ∙ x)ᗮ :=\nbegin\n  change (x ∉ B → inj_on (p.update φ w) (ℝ ∙ x)ᗮ) ↔ inj_on (p.update φ w) (ℝ ∙ x)ᗮ,\n  simp_rw [eq_true_intro hx, true_implies_iff]\nend\n\nsection assume_finite_dimensional\n\nvariables [finite_dimensional ℝ E]\n\n-- The following is extracted from `loc_immersion_rel_open` because it is slow to typecheck\nlemma loc_immersion_rel_open_aux {x₀ : E} {y₀ : F} {φ₀ : E →L[ℝ] F} (hx₀ : x₀ ∉ B)\n  (H : inj_on φ₀ (ℝ ∙ x₀)ᗮ) :\n  ∀ᶠ (p : one_jet E F) in 𝓝 (x₀, y₀, φ₀), ⟪x₀, p.1⟫ ≠ 0 ∧\n  injective ((p.2.2.comp $ (subtypeL (ℝ ∙ p.1)ᗮ).comp pr[p.1]ᗮ).comp (ℝ ∙ x₀)ᗮ.subtypeL) :=\nbegin\n  -- This is true at (x₀, y₀, φ₀) and is an open condition because `p ↦ ⟪x₀, p.1⟫` and\n  -- `p ↦ (p.2.2.comp $ (subtypeL (ℝ ∙ p.1)ᗮ).comp pr[p.1]ᗮ).comp j₀` are continuous\n  set j₀ := subtypeL (ℝ ∙ x₀)ᗮ,\n  let f : one_jet E F → ℝ × ((ℝ ∙ x₀)ᗮ →L[ℝ] F) :=\n      λ p, (⟪x₀, p.1⟫, (p.2.2.comp $ (subtypeL (ℝ ∙ p.1)ᗮ).comp pr[p.1]ᗮ).comp j₀),\n  let P : ℝ × ((ℝ ∙ x₀)ᗮ →L[ℝ] F) → Prop :=\n      λ q, q.1 ≠ 0 ∧ injective q.2,\n  have x₀_ne : x₀ ≠ 0,\n  { refine λ hx₀', hx₀ _,\n    rw hx₀',\n    apply mem_ball_self,\n    norm_num },\n  -- The following suffices looks stupid but is much faster than using the change tactic.\n  suffices : ∀ᶠ (p : one_jet E F) in 𝓝 (x₀, y₀, φ₀), P (f p), { exact this },\n  apply continuous_at.eventually,\n  { refine (continuous_at_const.inner continuous_at_fst).prod _,\n    apply continuous_at.compL,\n    { apply continuous_at.compL,\n      exact continuous_at_snd.comp continuous_at_snd,\n      -- Faster than change.\n      suffices : continuous_at ((λ x, (ℝ ∙ x)ᗮ.subtypeL.comp pr[x]ᗮ) ∘ prod.fst) (x₀, y₀, φ₀),\n      { exact this },\n      apply continuous_at.comp _ continuous_at_fst,\n      exact continuous_at_orthogonal_projection_orthogonal x₀_ne },\n    exact continuous_at_const },\n  { exact (continuous_fst.is_open_preimage _ is_open_compl_singleton).inter\n          (continuous_snd.is_open_preimage _ continuous_linear_map.is_open_injective) },\n  { split,\n    { change ⟪x₀, x₀⟫ ≠ 0,\n      apply (inner_self_eq_zero.not).mpr x₀_ne },\n    { change injective (φ₀ ∘ (coe ∘ (pr[x₀]ᗮ ∘ coe))),\n      rw [orthogonal_projection_comp_coe, comp.right_id],\n      exact inj_on_iff_injective.mp H } }\nend\n\nlemma loc_immersion_rel_open : is_open (immersion_sphere_rel E F) :=\nbegin\n  dsimp only [immersion_sphere_rel],\n  rw is_open_iff_mem_nhds,\n  rintros ⟨x₀, y₀, φ₀⟩ (H : x₀ ∉ B → inj_on φ₀ (ℝ ∙ x₀)ᗮ),\n  change ∀ᶠ (p : one_jet E F) in 𝓝 (x₀, y₀, φ₀), _,\n  by_cases hx₀ : x₀ ∈ B,\n  { have : ∀ᶠ (p : one_jet E F) in 𝓝 (x₀, y₀, φ₀), p.1 ∈ B,\n    { rw nhds_prod_eq,\n      apply (is_open_ball.eventually_mem hx₀).prod_inl },\n    apply this.mono,\n    rintros ⟨x, y, φ⟩ (hx : x ∈ B) (Hx : x ∉ B),\n    exact (Hx hx).elim },\n  { replace H := H hx₀,\n    set j₀ := subtypeL (ℝ ∙ x₀)ᗮ,\n    let f : one_jet E F → ℝ × ((ℝ ∙ x₀)ᗮ →L[ℝ] F) :=\n      λ p, (⟪x₀, p.1⟫, (p.2.2.comp $ (subtypeL (ℝ ∙ p.1)ᗮ).comp pr[p.1]ᗮ).comp j₀),\n    let P : ℝ × ((ℝ ∙ x₀)ᗮ →L[ℝ] F) → Prop :=\n      λ q, q.1 ≠ 0 ∧ injective q.2,\n    have : ∀ᶠ (p : one_jet E F) in 𝓝 (x₀, y₀, φ₀), P (f p),\n    { exact loc_immersion_rel_open_aux hx₀ H },\n    apply this.mono, clear this,\n    rintros ⟨x, y, φ⟩ ⟨hxx₀ : ⟪x₀, x⟫ ≠ 0, Hφ⟩ (hx : x ∉ B),\n    dsimp only [P, f] at Hφ,\n    change inj_on φ (ℝ ∙ x)ᗮ,\n    have : range ((subtypeL (ℝ ∙ x)ᗮ) ∘ pr[x]ᗮ ∘ j₀) = (ℝ ∙ x)ᗮ,\n    { rw function.surjective.range_comp,\n      exact subtype.range_coe,\n      exact (orthogonal_projection_orthogonal_line_iso hxx₀).surjective },\n    rw ← this, clear this,\n    exact function.injective.inj_on_range Hφ },\nend\n\nvariables [finite_dimensional ℝ F]\n\n-- In the next lemma the assumption `dim E = n + 1` is for convenience\n-- using `finrank_orthogonal_span_singleton`. We could remove it to treat empty spheres...\nlemma loc_immersion_rel_ample (n : ℕ) [fact (dim E = n+1)] (h : finrank ℝ E ≤ finrank ℝ F) :\n  (immersion_sphere_rel E F).is_ample :=\nbegin\n  classical, -- gives a minor speedup\n  rw is_ample_iff,\n  rintro ⟨x, y, φ⟩ p h_mem,\n  by_cases hx : x ∈ B,\n  { apply ample_slice_of_forall,\n    intros w,\n    simp only [hx, mem_loc_immersion_rel, not_true, is_empty.forall_iff] },\n  have x_ne : x ≠ 0,\n  { rintro rfl,\n    apply hx,\n    apply mem_ball_self,\n    norm_num1 },\n  have hφ : inj_on φ (ℝ ∙ x)ᗮ := h_mem hx, clear h_mem,\n  let u : E := (inner_product_space.to_dual ℝ E).symm p.π,\n  have u_ne : u ≠ 0,\n  { exact (inner_product_space.to_dual ℝ E).symm.apply_ne_zero p.pi_ne_zero },\n  by_cases H : ker p.π = (ℝ ∙ x)ᗮ,\n  { have key : ∀ w, eq_on (p.update φ w) φ (ℝ ∙ x)ᗮ,\n    { intros w x,\n      rw ← H,\n      exact p.update_ker_pi φ w },\n    exact ample_slice_of_forall _ p (λ w _, hφ.congr (key w).symm) },\n  obtain ⟨v', v'_in, hv', hπv'⟩ :\n    ∃ v' : E, v' ∈ (ℝ ∙ x)ᗮ ∧ (ℝ ∙ x)ᗮ = (ker p.π ⊓ (ℝ ∙ x)ᗮ) ⊔ (ℝ ∙ v') ∧ p.π v' = 1,\n  { have ne_z : p.π (pr[x]ᗮ u) ≠ 0,\n    { rw ← to_dual_symm_apply,\n      change ¬ ⟪u, pr[x]ᗮ u⟫ = 0,\n      rw inner_projection_self_eq_zero_iff.not,\n      contrapose! H,\n      rw orthogonal_orthogonal at H,\n      rw [← orthogonal_span_to_dual_symm, span_singleton_eq_span_singleton_of_ne u_ne H],\n      apply_instance },\n    have ne_z' : (p.π $ pr[x]ᗮ u)⁻¹ ≠ 0,\n    { exact inv_ne_zero ne_z },\n    refine ⟨(p.π $ pr[x]ᗮ u)⁻¹ • pr[x]ᗮ u, (ℝ ∙ x)ᗮ.smul_mem _ (pr[x]ᗮ u).2, _, _⟩,\n    { have := orthogonal_line_inf_sup_line u x,\n      rw [← orthogonal_span_to_dual_symm p.π,\n        span_singleton_smul_eq ne_z'.is_unit],\n      exact (orthogonal_line_inf_sup_line u x).symm },\n    rw [p.π.map_smul, smul_eq_mul, inv_mul_cancel ne_z] },\n  let p' : dual_pair E := { π := p.π, v := v', pairing := hπv' },\n  apply ample_slice_of_ample_slice (show p'.π = p.π, from rfl),\n  suffices : slice R p' (x, y, φ) = (map φ (ker p.π ⊓ (ℝ ∙ x)ᗮ))ᶜ,\n  { rw [this],\n    apply ample_of_two_le_codim,\n    let Φ := φ.to_linear_map,\n    suffices : 2 ≤ dim (F ⧸ map Φ (ker p.π ⊓ (ℝ ∙ x)ᗮ)),\n    { rw ← finrank_eq_dim,\n      exact_mod_cast this },\n    apply le_of_add_le_add_right,\n    rw submodule.finrank_quotient_add_finrank (map Φ $ ker p.π ⊓ (ℝ ∙ x)ᗮ),\n    have : dim (ker p.π ⊓ (ℝ ∙ x)ᗮ : submodule ℝ E) + 1 = n,\n    { have eq := submodule.dim_sup_add_dim_inf_eq (ker p.π ⊓ (ℝ ∙ x)ᗮ) (span ℝ {v'}),\n      have eq₁ : dim (ℝ ∙ x)ᗮ = n, from finrank_orthogonal_span_singleton x_ne,\n      have eq₂ : ker p.π ⊓ (ℝ ∙ x)ᗮ ⊓ span ℝ {v'} = (⊥ : submodule ℝ E),\n      { erw [inf_left_right_swap, inf_comm, ← inf_assoc, p'.inf_eq_bot, bot_inf_eq] },\n      have eq₃ : dim (span ℝ {v'}) = 1, apply finrank_span_singleton p'.v_ne_zero,\n      rw [← hv', eq₁, eq₃, eq₂] at eq,\n      simpa only [finrank_bot] using eq.symm },\n    have : dim E = n+1, from fact.out _,\n    linarith [finrank_map_le ℝ Φ (ker p.π ⊓ (ℝ ∙ x)ᗮ)] },\n  ext w,\n  rw mem_slice_iff_of_not_mem hx y,\n  rw inj_on_iff_injective,\n  let j := (ℝ ∙ x)ᗮ.subtypeL,\n  let p'' : dual_pair (ℝ ∙ x)ᗮ := ⟨p.π.comp j, ⟨v', v'_in⟩, hπv'⟩,\n  have eq : ((ℝ ∙ x)ᗮ : set E).restrict (p'.update φ w) = (p''.update (φ.comp j) w),\n  { ext z,\n    simp only [dual_pair.update, restrict_apply, continuous_linear_map.add_apply,\n      continuous_linear_map.coe_comp', coe_subtypeL', submodule.coe_subtype, comp_app, coe_mk] },\n  have eq' : map (φ.comp j) (ker p''.π) = map φ (ker p.π ⊓ (ℝ ∙ x)ᗮ),\n  { have : map ↑j (ker p''.π) = ker p.π ⊓ (ℝ ∙ x)ᗮ,\n    { ext z,\n      simp only [mem_map, linear_map.mem_ker, continuous_linear_map.coe_comp',\n                coe_subtypeL', submodule.coe_subtype, comp_app, mem_inf],\n      split,\n      { rintros ⟨t, ht, rfl⟩,\n        rw [continuous_linear_map.coe_coe, subtypeL_apply],\n        exact ⟨ht, t.2⟩ },\n      { rintros ⟨hz, z_in⟩,\n        exact ⟨⟨z, z_in⟩, hz, rfl⟩ }, },\n    erw [← this, map_comp],\n    refl },\n  rw [eq, p''.injective_update_iff, mem_compl_iff, eq'],\n  exact iff.rfl,\n  rw ← show ((ℝ ∙ x)ᗮ : set E).restrict φ = φ.comp j, by { ext, refl },\n  exact hφ.injective\nend\n\nend assume_finite_dimensional\n\n/-- The main ingredient of the linear map in the formal eversion of the sphere. -/\ndef loc_formal_eversion_aux_φ [fact (dim E = 3)] (ω : orientation ℝ E (fin 3))\n  (t : ℝ) (x : E) : E →L[ℝ] E :=\nω.rot (t, x) - (2 * t) • (submodule.subtypeL (ℝ ∙ x) ∘L orthogonal_projection (ℝ ∙ x))\n\nsection assume_finite_dimensional\n\nvariables [fact (dim E = 3)] [finite_dimensional ℝ E] (ω : orientation ℝ E (fin 3))\n\nlemma smooth_at_loc_formal_eversion_aux_φ {p : ℝ × E} (hx : p.2 ≠ 0) :\n  cont_diff_at ℝ ∞ (uncurry (loc_formal_eversion_aux_φ ω)) p :=\nbegin\n  refine (ω.cont_diff_rot hx).sub _,\n  refine cont_diff_at.smul (cont_diff_at_const.mul cont_diff_at_fst) _,\n  exact (cont_diff_at_orthogonal_projection_singleton hx).comp p cont_diff_at_snd\nend\n\n/-- A formal eversion of `𝕊²`, viewed as a homotopy. -/\ndef loc_formal_eversion_aux : htpy_jet_sec E E :=\n{ f := λ (t : ℝ) (x : E), (1 - 2 * smooth_step t) • x,\n  φ := λ t x, smooth_step (‖x‖ ^ 2) • loc_formal_eversion_aux_φ ω (smooth_step t) x,\n  f_diff := cont_diff.smul (cont_diff_const.sub $ cont_diff_const.mul $\n    smooth_step.smooth.comp cont_diff_fst) cont_diff_snd,\n  φ_diff := begin\n    refine cont_diff_iff_cont_diff_at.mpr (λ x, _),\n    cases eq_or_ne x.2 0 with hx hx,\n    { refine cont_diff_at_const.congr_of_eventually_eq _, exact 0,\n      have : ((λ x, ‖x‖ ^ 2) ⁻¹' Iio (1/4)) ∈ 𝓝 (0 : E),\n      { refine is_open.mem_nhds _ _,\n        exact (is_open_Iio.preimage (cont_diff_norm_sq ℝ : 𝒞 ∞ _).continuous),\n        simp_rw [mem_preimage, norm_zero, zero_pow two_pos, mem_Iio],\n        norm_num },\n      have : ((λ x, smooth_step (‖x‖ ^ 2)) ⁻¹' {0}) ∈ 𝓝 (0 : E),\n      { refine mem_of_superset this _,\n        rw @preimage_comp _ _ _ _ smooth_step,\n        refine preimage_mono _,\n        intros x hx,\n        rw [mem_preimage, mem_singleton_iff, smooth_step.of_lt hx] },\n      have : ((λ p : ℝ × E, smooth_step (‖p.2‖ ^ 2)) ⁻¹' {0}) ∈ 𝓝 x,\n      { rw [← hx] at this, exact continuous_at_snd.preimage_mem_nhds this },\n      refine eventually_of_mem this _,\n      rintro ⟨t, x⟩ hx,\n      simp_rw [mem_preimage, mem_singleton_iff] at hx,\n      show smooth_step (‖x‖ ^ 2) • loc_formal_eversion_aux_φ ω (smooth_step t) x = 0,\n      simp_rw [hx, zero_smul] },\n    refine cont_diff_at.smul _ _,\n    refine (smooth_step.smooth.comp $ (cont_diff_norm_sq ℝ).comp cont_diff_snd).cont_diff_at,\n    exact (smooth_at_loc_formal_eversion_aux_φ ω\n      (show (prod.map smooth_step id x).2 ≠ 0, from hx)).comp x\n      (smooth_step.smooth.prod_map cont_diff_id).cont_diff_at,\n     end }\n\n/-- A formal eversion of `𝕊²` into its ambient Euclidean space.\nThe corresponding map `E → E` is roughly a linear homotopy from `id` at `t = 0` to `- id` at\n`t = 1`. The continuous linear maps are roughly rotations with angle `t * π`. However, we have to\nkeep track of a few complications:\n* We need the formal solution to be holonomic near `0` and `1`.\n  Therefore, we compose the above maps with a smooth step function that is constant `0` near `t = 0`\n  and constant `1` near `t = 1`.\n* We need to modify the derivative of `ω.rot` to also have the right behavior on `(ℝ ∙ x)`\n  at `t = 1` (it is the identity, but it should be `-id`). Therefore, we subtract\n  `(2 * t) • (submodule.subtypeL (ℝ ∙ x) ∘L orthogonal_projection (ℝ ∙ x))`,\n  which is `2t` times the identity on `(ℝ ∙ x)`.\n* We have to make sure the family of continuous linear map is smooth at `x = 0`. Therefore, we\n  multiply the family with a factor of `smooth_step (‖x‖ ^ 2)`.\n-/\ndef loc_formal_eversion : htpy_formal_sol (immersion_sphere_rel E E) :=\n{ is_sol := begin\n    intros t x,\n    change x ∉ B →\n      inj_on (smooth_step (‖x‖ ^ 2) • loc_formal_eversion_aux_φ ω (smooth_step t) x) (ℝ ∙ x)ᗮ,\n    intros hx,\n    have h2x : smooth_step (‖x‖ ^ 2) = 1,\n    { refine smooth_step.of_gt _,\n      rw [mem_ball, not_lt, dist_zero_right] at hx,\n      refine (show (3 : ℝ)/4 < 0.9 ^ 2, by norm_num).trans_le _,\n      rwa [sq_le_sq, show |(0.9 : ℝ)| = 0.9, by norm_num, abs_norm_eq_norm] },\n    rw [h2x, one_smul],\n    have h3x : x ≠ 0,\n    { rintro rfl, apply hx, exact mem_ball_self (by norm_num) },\n    refine (eq_on.inj_on_iff _).mpr (ω.inj_on_rot_of_ne (smooth_step t) h3x),\n    intros v hv,\n    simp_rw [loc_formal_eversion_aux_φ, continuous_linear_map.sub_apply,\n      continuous_linear_map.smul_apply, continuous_linear_map.comp_apply,\n      orthogonal_projection_mem_subspace_orthogonal_complement_eq_zero hv,\n      _root_.map_zero, smul_zero, sub_zero],\n  end,\n  .. loc_formal_eversion_aux ω }\n\n@[simp]\nlemma loc_formal_eversion_f (t : ℝ) :\n  (loc_formal_eversion ω t).f = λ x : E, ((1 : ℝ) - 2 * smooth_step t) • x :=\nrfl\n\nlemma loc_formal_eversion_φ (t : ℝ) (x : E) (v : E) :\n  (loc_formal_eversion ω t).φ x v = smooth_step (‖x‖ ^ 2) •\n    (ω.rot (smooth_step t, x) v -\n    (2 * smooth_step t) • orthogonal_projection (ℝ ∙ x) v) :=\nrfl\n\nlemma loc_formal_eversion_zero (x : E) : (loc_formal_eversion ω 0).f x = x :=\nby simp\n\nlemma loc_formal_eversion_one (x : E) : (loc_formal_eversion ω 1).f x = -x :=\nby simp [show (1 : ℝ) - 2 = -1, by norm_num]\n\nlemma loc_formal_eversion_hol_at_zero {t : ℝ} (ht : t < 1/4) {x : E}\n  (hx : smooth_step (‖x‖ ^ 2) = 1) : (loc_formal_eversion ω t).is_holonomic_at x :=\nby simp_rw [jet_sec.is_holonomic_at, loc_formal_eversion_f, continuous_linear_map.ext_iff,\n    loc_formal_eversion_φ, smooth_step.of_lt ht, hx, ω.rot_zero, mul_zero, zero_smul, sub_zero,\n    show (has_smul.smul (1 : ℝ) : E → E) = id, from funext (one_smul ℝ), fderiv_id, function.id_def,\n    eq_self_iff_true, implies_true_iff]\n\nlemma loc_formal_eversion_hol_at_one {t : ℝ} (ht : 3/4 < t) {x : E}\n  (hx : smooth_step (‖x‖ ^ 2) = 1) : (loc_formal_eversion ω t).is_holonomic_at x :=\nbegin\n  simp_rw [jet_sec.is_holonomic_at, loc_formal_eversion_f, continuous_linear_map.ext_iff,\n    loc_formal_eversion_φ, smooth_step.of_gt ht, hx],\n  intro v,\n  simp_rw [mul_one, show (1 : ℝ) - 2 = -1, by norm_num,\n    show (has_smul.smul (-1 : ℝ) : E → E) = λ x, - x, from funext (λ v, by rw [neg_smul, one_smul]),\n    fderiv_neg, fderiv_id', continuous_linear_map.neg_apply, continuous_linear_map.id_apply],\n  obtain ⟨v', hv', v, hv, rfl⟩ := submodule.exists_sum_mem_mem_orthogonal (ℝ ∙ x) v,\n  simp_rw [continuous_linear_map.map_add, ω.rot_one _ hv, ω.rot_eq_of_mem_span (1, x) hv'],\n  simp_rw [neg_add, submodule.coe_add, orthogonal_projection_eq_self_iff.mpr hv',\n    orthogonal_projection_mem_subspace_orthogonal_complement_eq_zero hv, submodule.coe_zero,\n    add_zero, two_smul, one_smul],\n  abel\nend\n\nlemma loc_formal_eversion_hol :\n  ∀ᶠ (p : ℝ × E) near {0, 1} ×ˢ 𝕊², (loc_formal_eversion ω p.1).is_holonomic_at p.2 :=\nbegin\n  have : (Iio (1/4 : ℝ) ∪ Ioi (3/4)) ×ˢ ((λ x, ‖x‖ ^ 2) ⁻¹' Ioi (3/4)) ∈\n    𝓝ˢ (({0, 1} : set ℝ) ×ˢ 𝕊²),\n  { refine (is_open.mem_nhds_set _).mpr _,\n    exact (is_open_Iio.union is_open_Ioi).prod\n      (is_open_Ioi.preimage (cont_diff_norm_sq ℝ : 𝒞 ∞ _).continuous),\n    rintro ⟨s, x⟩ ⟨hs, hx⟩,\n    refine ⟨_, _⟩,\n    simp_rw [mem_insert_iff, mem_singleton_iff] at hs,\n    rcases hs with rfl|rfl,\n    exact or.inl (show (0 : ℝ) < 1 / 4, by norm_num),\n    exact or.inr (show (3 / 4 : ℝ) < 1, by norm_num),\n    simp_rw [mem_sphere_zero_iff_norm] at hx,\n    simp_rw [mem_preimage, hx, one_pow, mem_Ioi],\n    norm_num },\n  have : (Iio (1/4 : ℝ) ∪ Ioi (3/4)) ×ˢ ((λ x, smooth_step (‖x‖ ^ 2)) ⁻¹' {1}) ∈\n    𝓝ˢ (({0, 1} : set ℝ) ×ˢ 𝕊²),\n  { refine mem_of_superset this (prod_mono subset.rfl _),\n    rw @preimage_comp _ _ _ _ smooth_step,\n    refine preimage_mono _,\n    intros x hx,\n    rw [mem_preimage, mem_singleton_iff, smooth_step.of_gt hx] },\n  refine eventually_of_mem this _,\n  rintro ⟨t, x⟩ ⟨ht|ht, hx⟩,\n  { exact loc_formal_eversion_hol_at_zero ω ht hx },\n  { exact loc_formal_eversion_hol_at_one ω ht hx }\nend\n\nend assume_finite_dimensional\n\nopen_locale unit_interval\n\ntheorem sphere_eversion_of_loc [fact (dim E = 3)] :\n  ∃ f : ℝ → E → E,\n  (𝒞 ∞ ↿f) ∧\n  (∀ x ∈ 𝕊², f 0 x = x) ∧\n  (∀ x ∈ 𝕊², f 1 x = -x) ∧\n  ∀ t ∈ I, sphere_immersion (f t) :=\nbegin\n  classical,\n  borelize E,\n  have rankE := fact.out (dim E = 3),\n  haveI : finite_dimensional ℝ E := finite_dimensional_of_finrank_eq_succ rankE,\n  let ω : orientation ℝ E (fin 3) :=\n    ((std_orthonormal_basis _ _).reindex $ fin_congr (fact.out _ : dim E = 3)).to_basis.orientation,\n  have is_closed_pair : is_closed ({0, 1} : set ℝ) :=\n  (by simp : ({0, 1} : set ℝ).finite).is_closed,\n  obtain ⟨f, h₁, h₂, h₃⟩ :=\n    (loc_formal_eversion ω).exists_sol loc_immersion_rel_open (loc_immersion_rel_ample 2 le_rfl)\n    ({0, 1} ×ˢ 𝕊²) (is_closed_pair.prod is_closed_sphere) 𝕊² (is_compact_sphere 0 1)\n    (loc_formal_eversion_hol ω),\n  refine ⟨f, h₁, _, _, _⟩,\n  { intros x hx, rw [h₂ (0, x) (mk_mem_prod (by simp) hx), loc_formal_eversion_zero] },\n  { intros x hx, rw [h₂ (1, x) (mk_mem_prod (by simp) hx), loc_formal_eversion_one] },\n  { exact λ t ht, sphere_immersion_of_sol _ (λ x hx, h₃ x hx t ht) },\nend\n\n/- Stating the full statement with all type-class arguments and no uncommon notation. -/\nexample (E : Type*) [normed_add_comm_group E] [inner_product_space ℝ E] [fact (finrank ℝ E = 3)] :\n  ∃ f : ℝ → E → E,\n  (cont_diff ℝ ⊤ (uncurry f)) ∧\n  (∀ x ∈ sphere (0 : E) 1, f 0 x = x) ∧\n  (∀ x ∈ sphere (0 : E) 1, f 1 x = -x) ∧\n  ∀ t ∈ unit_interval, sphere_immersion (f t) :=\nsphere_eversion_of_loc\n\nend sphere_eversion\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/local/sphere_eversion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.4954534926368064}}
{"text": "universes u v\n\ninductive Imf {α : Type u} {β : Type v} (f : α → β) : β → Type (max u v)\n| mk : (a : α) → Imf f (f a)\n\ndef h {α β} {f : α → β} : {b : β} → Imf f b → α\n| _, Imf.mk a => a\n\n#print h\n\ntheorem ex : ∀ {α β : Sort u} (h : α = β) (a : α), cast h a ≅ a\n  | α, _, rfl, a => HEq.refl a\n\n#print ex\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/223.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4954525502379851}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport algebra.group.type_tags\nimport algebra.hom.equiv.basic\nimport algebra.hom.ring\nimport algebra.hom.units\n\n/-!\n# Unbundled monoid and group homomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file is deprecated, and is no longer imported by anything in mathlib other than other\ndeprecated files, and test files. You should not need to import it.\n\nThis file defines predicates for unbundled monoid and group homomorphisms. Instead of using\nthis file, please use `monoid_hom`, defined in `algebra.hom.group`, with notation `→*`, for\nmorphisms between monoids or groups. For example use `φ : G →* H` to represent a group\nhomomorphism between multiplicative groups, and `ψ : A →+ B` to represent a group homomorphism\nbetween additive groups.\n\n## Main Definitions\n\n`is_monoid_hom` (deprecated), `is_group_hom` (deprecated)\n\n## Tags\n\nis_group_hom, is_monoid_hom\n\n-/\n\nuniverses u v\nvariables {α : Type u} {β : Type v}\n\n/-- Predicate for maps which preserve an addition. -/\nstructure is_add_hom {α β : Type*} [has_add α] [has_add β] (f : α → β) : Prop :=\n(map_add [] : ∀ x y, f (x + y) = f x + f y)\n\n/-- Predicate for maps which preserve a multiplication. -/\n@[to_additive]\nstructure is_mul_hom {α β : Type*} [has_mul α] [has_mul β] (f : α → β) : Prop :=\n(map_mul [] : ∀ x y, f (x * y) = f x * f y)\n\nnamespace is_mul_hom\nvariables [has_mul α] [has_mul β] {γ : Type*} [has_mul γ]\n\n/-- The identity map preserves multiplication. -/\n@[to_additive \"The identity map preserves addition\"]\nlemma id : is_mul_hom (id : α → α) := {map_mul := λ _ _, rfl}\n\n/-- The composition of maps which preserve multiplication, also preserves multiplication. -/\n@[to_additive \"The composition of addition preserving maps also preserves addition\"]\nlemma comp {f : α → β} {g : β → γ} (hf : is_mul_hom f) (hg : is_mul_hom g) : is_mul_hom (g ∘ f) :=\n{ map_mul := λ x y, by simp only [function.comp, hf.map_mul, hg.map_mul] }\n\n/-- A product of maps which preserve multiplication,\npreserves multiplication when the target is commutative. -/\n@[to_additive \"A sum of maps which preserves addition, preserves addition when the target\nis commutative.\"]\nlemma mul {α β} [semigroup α] [comm_semigroup β]\n  {f g : α → β} (hf : is_mul_hom f) (hg : is_mul_hom g) :\n  is_mul_hom (λ a, f a * g a) :=\n{ map_mul := λ a b, by simp only [hf.map_mul, hg.map_mul, mul_comm, mul_assoc, mul_left_comm] }\n\n/-- The inverse of a map which preserves multiplication,\npreserves multiplication when the target is commutative. -/\n@[to_additive \"The negation of a map which preserves addition, preserves addition when\nthe target is commutative.\"]\nlemma inv {α β} [has_mul α] [comm_group β] {f : α → β} (hf : is_mul_hom f) :\n  is_mul_hom (λ a, (f a)⁻¹) :=\n{ map_mul := λ a b, (hf.map_mul a b).symm ▸ mul_inv _ _ }\n\nend is_mul_hom\n\n/-- Predicate for add_monoid homomorphisms (deprecated -- use the bundled `monoid_hom` version). -/\nstructure is_add_monoid_hom [add_zero_class α] [add_zero_class β] (f : α → β)\n  extends is_add_hom f : Prop :=\n(map_zero [] : f 0 = 0)\n\n/-- Predicate for monoid homomorphisms (deprecated -- use the bundled `monoid_hom` version). -/\n@[to_additive]\nstructure is_monoid_hom [mul_one_class α] [mul_one_class β] (f : α → β)\n  extends is_mul_hom f : Prop :=\n(map_one [] : f 1 = 1)\n\nnamespace monoid_hom\n\nvariables {M : Type*} {N : Type*} [mM : mul_one_class M] [mN : mul_one_class N]\n\ninclude mM mN\n/-- Interpret a map `f : M → N` as a homomorphism `M →* N`. -/\n@[to_additive \"Interpret a map `f : M → N` as a homomorphism `M →+ N`.\"]\ndef of {f : M → N} (h : is_monoid_hom f) : M →* N :=\n{ to_fun := f,\n  map_one' := h.2,\n  map_mul' := h.1.1 }\n\nvariables {mM mN}\n@[simp, to_additive]\nlemma coe_of {f : M → N} (hf : is_monoid_hom f) : ⇑ (monoid_hom.of hf) = f :=\nrfl\n\n@[to_additive]\n\n\nend monoid_hom\n\nnamespace mul_equiv\n\nvariables {M : Type*} {N : Type*} [mul_one_class M] [mul_one_class N]\n\n/-- A multiplicative isomorphism preserves multiplication (deprecated). -/\n@[to_additive \"An additive isomorphism preserves addition (deprecated).\"]\ntheorem is_mul_hom (h : M ≃* N) : is_mul_hom h := ⟨h.map_mul⟩\n\n/-- A multiplicative bijection between two monoids is a monoid hom\n  (deprecated -- use `mul_equiv.to_monoid_hom`). -/\n@[to_additive \"An additive bijection between two additive monoids is an additive\nmonoid hom (deprecated). \"]\nlemma is_monoid_hom (h : M ≃* N) : is_monoid_hom h :=\n{ map_mul := h.map_mul,\n  map_one := h.map_one }\n\nend mul_equiv\n\nnamespace is_monoid_hom\nvariables [mul_one_class α] [mul_one_class β] {f : α → β} (hf : is_monoid_hom f)\n\n/-- A monoid homomorphism preserves multiplication. -/\n@[to_additive \"An additive monoid homomorphism preserves addition.\"]\nlemma map_mul (x y) : f (x * y) = f x * f y :=\nhf.map_mul x y\n\n/-- The inverse of a map which preserves multiplication,\npreserves multiplication when the target is commutative. -/\n@[to_additive \"The negation of a map which preserves addition, preserves addition\nwhen the target is commutative.\"]\nlemma inv {α β} [mul_one_class α] [comm_group β] {f : α → β} (hf : is_monoid_hom f) :\n  is_monoid_hom (λ a, (f a)⁻¹) :=\n{ map_one := hf.map_one.symm ▸ inv_one,\n  map_mul := λ a b, (hf.map_mul a b).symm ▸ mul_inv _ _ }\n\nend is_monoid_hom\n\n/-- A map to a group preserving multiplication is a monoid homomorphism. -/\n@[to_additive \"A map to an additive group preserving addition is an additive monoid\nhomomorphism.\"]\ntheorem is_mul_hom.to_is_monoid_hom [mul_one_class α] [group β] {f : α → β} (hf : is_mul_hom f) :\n  is_monoid_hom f :=\n{ map_one := mul_right_eq_self.1 $ by rw [← hf.map_mul, one_mul],\n  map_mul := hf.map_mul }\n\nnamespace is_monoid_hom\nvariables [mul_one_class α] [mul_one_class β] {f : α → β}\n\n/-- The identity map is a monoid homomorphism. -/\n@[to_additive \"The identity map is an additive monoid homomorphism.\"]\nlemma id : is_monoid_hom (@id α) := { map_one := rfl, map_mul := λ _ _, rfl }\n\n/-- The composite of two monoid homomorphisms is a monoid homomorphism. -/\n@[to_additive \"The composite of two additive monoid homomorphisms is an additive monoid\nhomomorphism.\"]\nlemma comp (hf : is_monoid_hom f) {γ} [mul_one_class γ] {g : β → γ} (hg : is_monoid_hom g) :\n  is_monoid_hom (g ∘ f) :=\n{ map_one := show g _ = 1, by rw [hf.map_one, hg.map_one],\n  ..is_mul_hom.comp hf.to_is_mul_hom hg.to_is_mul_hom }\n\nend is_monoid_hom\n\nnamespace is_add_monoid_hom\n\n/-- Left multiplication in a ring is an additive monoid morphism. -/\nlemma is_add_monoid_hom_mul_left {γ : Type*} [non_unital_non_assoc_semiring γ] (x : γ) :\n  is_add_monoid_hom (λ y : γ, x * y) :=\n{ map_zero := mul_zero x, map_add := λ y z, mul_add x y z }\n\n/-- Right multiplication in a ring is an additive monoid morphism. -/\nlemma is_add_monoid_hom_mul_right {γ : Type*} [non_unital_non_assoc_semiring γ] (x : γ) :\n  is_add_monoid_hom (λ y : γ, y * x) :=\n{ map_zero := zero_mul x, map_add := λ y z, add_mul y z x }\n\nend is_add_monoid_hom\n\n/-- Predicate for additive group homomorphism (deprecated -- use bundled `monoid_hom`). -/\nstructure is_add_group_hom [add_group α] [add_group β] (f : α → β) extends is_add_hom f : Prop\n\n/-- Predicate for group homomorphisms (deprecated -- use bundled `monoid_hom`). -/\n@[to_additive]\nstructure is_group_hom [group α] [group β] (f : α → β) extends is_mul_hom f : Prop\n\n@[to_additive]\nlemma monoid_hom.is_group_hom {G H : Type*} {_ : group G} {_ : group H} (f : G →* H) :\n  is_group_hom (f : G → H) :=\n{ map_mul := f.map_mul }\n\n@[to_additive]\nlemma mul_equiv.is_group_hom {G H : Type*} {_ : group G} {_ : group H} (h : G ≃* H) :\n  is_group_hom h := { map_mul := h.map_mul }\n\n/-- Construct `is_group_hom` from its only hypothesis. -/\n@[to_additive \"Construct `is_add_group_hom` from its only hypothesis.\"]\nlemma is_group_hom.mk' [group α] [group β] {f : α → β} (hf : ∀ x y, f (x * y) = f x * f y) :\n  is_group_hom f :=\n{ map_mul := hf }\n\nnamespace is_group_hom\nvariables [group α] [group β] {f : α → β} (hf : is_group_hom f)\nopen is_mul_hom (map_mul)\n\nlemma map_mul : ∀ (x y), f (x * y) = f x * f y := hf.to_is_mul_hom.map_mul\n\n/-- A group homomorphism is a monoid homomorphism. -/\n@[to_additive \"An additive group homomorphism is an additive monoid homomorphism.\"]\nlemma to_is_monoid_hom : is_monoid_hom f :=\nhf.to_is_mul_hom.to_is_monoid_hom\n\n/-- A group homomorphism sends 1 to 1. -/\n@[to_additive \"An additive group homomorphism sends 0 to 0.\"]\nlemma map_one : f 1 = 1 := hf.to_is_monoid_hom.map_one\n\n/-- A group homomorphism sends inverses to inverses. -/\n@[to_additive \"An additive group homomorphism sends negations to negations.\"]\ntheorem map_inv (hf : is_group_hom f) (a : α) : f a⁻¹ = (f a)⁻¹ :=\neq_inv_of_mul_eq_one_left $ by rw [← hf.map_mul, inv_mul_self, hf.map_one]\n\n@[to_additive] lemma map_div (hf : is_group_hom f) (a b : α) : f (a / b) = f a / f b :=\nby simp_rw [div_eq_mul_inv, hf.map_mul, hf.map_inv]\n\n/-- The identity is a group homomorphism. -/\n@[to_additive \"The identity is an additive group homomorphism.\"]\nlemma id : is_group_hom (@id α) := { map_mul := λ _ _, rfl}\n\n/-- The composition of two group homomorphisms is a group homomorphism. -/\n@[to_additive \"The composition of two additive group homomorphisms is an additive\ngroup homomorphism.\"]\nlemma comp (hf : is_group_hom f) {γ} [group γ] {g : β → γ} (hg : is_group_hom g) :\n  is_group_hom (g ∘ f) :=\n{ ..is_mul_hom.comp hf.to_is_mul_hom hg.to_is_mul_hom }\n\n/-- A group homomorphism is injective iff its kernel is trivial. -/\n@[to_additive \"An additive group homomorphism is injective if its kernel is trivial.\"]\nlemma injective_iff {f : α → β} (hf : is_group_hom f) :\n  function.injective f ↔ (∀ a, f a = 1 → a = 1) :=\n⟨λ h _, by rw ← hf.map_one; exact @h _ _,\n  λ h x y hxy, eq_of_div_eq_one $ h _ $ by rwa [hf.map_div, div_eq_one]⟩\n\n/-- The product of group homomorphisms is a group homomorphism if the target is commutative. -/\n@[to_additive \"The sum of two additive group homomorphisms is an additive group homomorphism\nif the target is commutative.\"]\nlemma mul {α β} [group α] [comm_group β]\n  {f g : α → β} (hf : is_group_hom f) (hg : is_group_hom g) :\n  is_group_hom (λa, f a * g a) :=\n{ map_mul := (hf.to_is_mul_hom.mul hg.to_is_mul_hom).map_mul }\n\n/-- The inverse of a group homomorphism is a group homomorphism if the target is commutative. -/\n@[to_additive \"The negation of an additive group homomorphism is an additive group homomorphism\nif the target is commutative.\"]\nlemma inv {α β} [group α] [comm_group β] {f : α → β} (hf : is_group_hom f) :\n  is_group_hom (λa, (f a)⁻¹) :=\n{ map_mul := hf.to_is_mul_hom.inv.map_mul }\n\nend is_group_hom\n\nnamespace ring_hom\n/-!\nThese instances look redundant, because `deprecated.ring` provides `is_ring_hom` for a `→+*`.\nNevertheless these are harmless, and helpful for stripping out dependencies on `deprecated.ring`.\n-/\nvariables {R : Type*} {S : Type*}\n\nsection\nvariables [non_assoc_semiring R] [non_assoc_semiring S]\n\nlemma to_is_monoid_hom (f : R →+* S) : is_monoid_hom f :=\n{ map_one := f.map_one,\n  map_mul := f.map_mul }\n\nlemma to_is_add_monoid_hom (f : R →+* S) : is_add_monoid_hom f :=\n{ map_zero := f.map_zero,\n  map_add := f.map_add }\nend\n\nsection\nvariables [ring R] [ring S]\n\nlemma to_is_add_group_hom (f : R →+* S) : is_add_group_hom f :=\n{ map_add := f.map_add }\nend\n\nend ring_hom\n\n/-- Inversion is a group homomorphism if the group is commutative. -/\n@[to_additive neg.is_add_group_hom\n\"Negation is an `add_group` homomorphism if the `add_group` is commutative.\"]\nlemma inv.is_group_hom [comm_group α] : is_group_hom (has_inv.inv : α → α) :=\n{ map_mul := mul_inv }\n\n/-- The difference of two additive group homomorphisms is an additive group\nhomomorphism if the target is commutative. -/\nlemma is_add_group_hom.sub {α β} [add_group α] [add_comm_group β]\n  {f g : α → β} (hf : is_add_group_hom f) (hg : is_add_group_hom g) :\n  is_add_group_hom (λa, f a - g a) :=\nby simpa only [sub_eq_add_neg] using hf.add hg.neg\n\nnamespace units\n\nvariables {M : Type*} {N : Type*} [monoid M] [monoid N]\n\n/-- The group homomorphism on units induced by a multiplicative morphism. -/\n@[reducible] def map' {f : M → N} (hf : is_monoid_hom f) : Mˣ →* Nˣ :=\n  map (monoid_hom.of hf)\n\n@[simp] lemma coe_map' {f : M → N} (hf : is_monoid_hom f) (x : Mˣ) :\n  ↑((map' hf : Mˣ → Nˣ) x) = f x :=\nrfl\n\nlemma coe_is_monoid_hom : is_monoid_hom (coe : Mˣ → M) := (coe_hom M).is_monoid_hom_coe\n\nend units\n\nnamespace is_unit\n\nvariables {M : Type*} {N : Type*} [monoid M] [monoid N] {x : M}\n\nlemma map' {f : M → N} (hf :is_monoid_hom f) {x : M} (h : is_unit x) :\n  is_unit (f x) :=\nh.map (monoid_hom.of hf)\n\nend is_unit\n\nlemma additive.is_add_hom [has_mul α] [has_mul β] {f : α → β} (hf : is_mul_hom f) :\n  @is_add_hom (additive α) (additive β) _ _ f :=\n{ map_add := is_mul_hom.map_mul hf }\n\nlemma multiplicative.is_mul_hom [has_add α] [has_add β] {f : α → β} (hf : is_add_hom f) :\n  @is_mul_hom (multiplicative α) (multiplicative β) _ _ f :=\n{ map_mul := is_add_hom.map_add hf }\n\n-- defeq abuse\nlemma additive.is_add_monoid_hom [mul_one_class α] [mul_one_class β] {f : α → β}\n  (hf : is_monoid_hom f) : @is_add_monoid_hom (additive α) (additive β) _ _ f :=\n{ map_zero := hf.map_one,\n  ..additive.is_add_hom hf.to_is_mul_hom }\n\nlemma multiplicative.is_monoid_hom\n  [add_zero_class α] [add_zero_class β] {f : α → β} (hf : is_add_monoid_hom f) :\n  @is_monoid_hom (multiplicative α) (multiplicative β) _ _ f :=\n{ map_one := is_add_monoid_hom.map_zero hf,\n  ..multiplicative.is_mul_hom hf.to_is_add_hom }\n\nlemma additive.is_add_group_hom [group α] [group β] {f : α → β} (hf : is_group_hom f) :\n  @is_add_group_hom (additive α) (additive β) _ _ f :=\n{ map_add := hf.to_is_mul_hom.map_mul }\n\nlemma multiplicative.is_group_hom [add_group α] [add_group β] {f : α → β}\n  (hf : is_add_group_hom f) : @is_group_hom (multiplicative α) (multiplicative β) _ _ f :=\n{ map_mul := hf.to_is_add_hom.map_add }\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/deprecated/group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4954525502379851}}
{"text": "import tactic.equiv_rw\nimport data.equiv.basic\n\nvariables {α β : Sort*}\n\nlemma equiv.exists_congr_left' {p : α → Prop} (f : α ≃ β) :\n  (∃x, p x) ↔ (∃y, p (f.symm y)) :=\n⟨λ ⟨x, h⟩, ⟨f x, by rwa f.symm_apply_apply⟩, λ ⟨y, h⟩, ⟨f.symm y, h⟩⟩\n\nlemma equiv.exists_congr_left {p : β → Prop} (f : α ≃ β) :\n  (∃x, p (f x)) ↔ (∃y, p y) :=\nf.symm.exists_congr_left'.symm\n\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/src/for_mathlib/equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.49545254435216635}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nA collection of specific limit computations.\n-/\nimport analysis.normed_space.basic\nimport topology.instances.ennreal\n\nnoncomputable theory\nlocal attribute [instance] classical.prop_decidable\n\nopen classical function lattice filter finset metric\n\nvariables {α : Type*} {β : Type*} {ι : Type*}\n\nlemma has_sum_of_absolute_convergence_real {f : ℕ → ℝ} :\n  (∃r, tendsto (λn, (range n).sum (λi, abs (f i))) at_top (nhds r)) → has_sum f\n| ⟨r, hr⟩ :=\n  begin\n    refine has_sum_of_has_sum_norm ⟨r, (is_sum_iff_tendsto_nat_of_nonneg _ _).2 _⟩,\n    exact assume i, norm_nonneg _,\n    simpa only using hr\n  end\n\nlemma tendsto_pow_at_top_at_top_of_gt_1 {r : ℝ} (h : r > 1) : tendsto (λn:ℕ, r ^ n) at_top at_top :=\ntendsto_infi.2 $ assume p, tendsto_principal.2 $\n  let ⟨n, hn⟩ := exists_nat_gt (p / (r - 1)) in\n  have hn_nn : (0:ℝ) ≤ n, from nat.cast_nonneg n,\n  have r - 1 > 0, from sub_lt_iff_lt_add.mp $ by simp; assumption,\n  have p ≤ r ^ n,\n    from calc p = (p / (r - 1)) * (r - 1) : (div_mul_cancel _ $ ne_of_gt this).symm\n      ... ≤ n * (r - 1) : mul_le_mul (le_of_lt hn) (le_refl _) (le_of_lt this) hn_nn\n      ... ≤ 1 + n * (r - 1) : le_add_of_nonneg_of_le zero_le_one (le_refl _)\n      ... = 1 + add_monoid.smul n (r - 1) : by rw [add_monoid.smul_eq_mul]\n      ... ≤ (1 + (r - 1)) ^ n : pow_ge_one_add_mul (le_of_lt this) _\n      ... ≤ r ^ n : by simp; exact le_refl _,\n  show {n | p ≤ r ^ n} ∈ at_top,\n    from mem_at_top_sets.mpr ⟨n, assume m hnm, le_trans this (pow_le_pow (le_of_lt h) hnm)⟩\n\nlemma tendsto_inverse_at_top_nhds_0 : tendsto (λr:ℝ, r⁻¹) at_top (nhds 0) :=\ntendsto_orderable_unbounded (no_top 0) (no_bot 0) $ assume l u hl hu,\n  mem_at_top_sets.mpr ⟨u⁻¹ + 1, assume b hb,\n    have u⁻¹ < b, from lt_of_lt_of_le (lt_add_of_pos_right _ zero_lt_one) hb,\n    ⟨lt_trans hl $ inv_pos $ lt_trans (inv_pos hu) this,\n    lt_of_one_div_lt_one_div hu $\n    begin\n      rw [inv_eq_one_div],\n      simp [-one_div_eq_inv, div_div_eq_mul_div, div_one],\n      simp [this]\n    end⟩⟩\n\nlemma tendsto_pow_at_top_nhds_0_of_lt_1 {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) :\n  tendsto (λn:ℕ, r^n) at_top (nhds 0) :=\nby_cases\n  (assume : r = 0, (tendsto_add_at_top_iff_nat 1).mp $ by simp [pow_succ, this, tendsto_const_nhds])\n  (assume : r ≠ 0,\n    have tendsto (λn, (r⁻¹ ^ n)⁻¹) at_top (nhds 0),\n      from (tendsto_pow_at_top_at_top_of_gt_1 $ one_lt_inv (lt_of_le_of_ne h₁ this.symm) h₂).comp\n        tendsto_inverse_at_top_nhds_0,\n    tendsto.congr' (univ_mem_sets' $ by simp *) this)\n\nlemma tendsto_pow_at_top_at_top_of_gt_1_nat {k : ℕ} (h : 1 < k) :\n  tendsto (λn:ℕ, k ^ n) at_top at_top :=\ntendsto_coe_nat_real_at_top_iff.1 $\n  have hr : 1 < (k : ℝ), by rw [← nat.cast_one, nat.cast_lt]; exact h,\n  by simpa using tendsto_pow_at_top_at_top_of_gt_1 hr\n\nlemma tendsto_inverse_at_top_nhds_0_nat : tendsto (λ n : ℕ, (n : ℝ)⁻¹) at_top (nhds 0) :=\ntendsto.comp (tendsto_coe_nat_real_at_top_iff.2 tendsto_id) tendsto_inverse_at_top_nhds_0\n\nlemma tendsto_one_div_at_top_nhds_0_nat : tendsto (λ n : ℕ, 1/(n : ℝ)) at_top (nhds 0) :=\nby simpa only [inv_eq_one_div] using tendsto_inverse_at_top_nhds_0_nat\n\nlemma tendsto_one_div_add_at_top_nhds_0_nat :\n  tendsto (λ n : ℕ, 1 / ((n : ℝ) + 1)) at_top (nhds 0) :=\nsuffices tendsto (λ n : ℕ, 1 / (↑(n + 1) : ℝ)) at_top (nhds 0), by simpa,\n(tendsto_add_at_top_iff_nat 1).2 tendsto_one_div_at_top_nhds_0_nat\n\nlemma is_sum_geometric {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) :\n  is_sum (λn:ℕ, r ^ n) (1 / (1 - r)) :=\nhave r ≠ 1, from ne_of_lt h₂,\nhave r + -1 ≠ 0,\n  by rw [←sub_eq_add_neg, ne, sub_eq_iff_eq_add]; simp; assumption,\nhave tendsto (λn, (r ^ n - 1) * (r - 1)⁻¹) at_top (nhds ((0 - 1) * (r - 1)⁻¹)),\n  from tendsto_mul\n    (tendsto_sub (tendsto_pow_at_top_nhds_0_of_lt_1 h₁ h₂) tendsto_const_nhds) tendsto_const_nhds,\n(is_sum_iff_tendsto_nat_of_nonneg (pow_nonneg h₁) _).mpr $\n  by simp [neg_inv, geom_sum, div_eq_mul_inv, *] at *\n\nlemma is_sum_geometric_two (a : ℝ) : is_sum (λn:ℕ, (a / 2) / 2 ^ n) a :=\nbegin\n  convert is_sum_mul_left (a / 2) (is_sum_geometric\n    (le_of_lt one_half_pos) one_half_lt_one),\n  { funext n, simp,\n    rw ← pow_inv; [refl, exact two_ne_zero] },\n  { norm_num, rw div_mul_cancel _ two_ne_zero }\nend\n\ndef pos_sum_of_encodable {ε : ℝ} (hε : 0 < ε)\n  (ι) [encodable ι] : {ε' : ι → ℝ // (∀ i, 0 < ε' i) ∧ ∃ c, is_sum ε' c ∧ c ≤ ε} :=\nbegin\n  let f := λ n, (ε / 2) / 2 ^ n,\n  have hf : is_sum f ε := is_sum_geometric_two _,\n  have f0 : ∀ n, 0 < f n := λ n, div_pos (half_pos hε) (pow_pos two_pos _),\n  refine ⟨f ∘ encodable.encode, λ i, f0 _, _⟩,\n  rcases has_sum_comp_of_has_sum_of_injective f (has_sum_spec hf) (@encodable.encode_injective ι _)\n    with ⟨c, hg⟩,\n  refine ⟨c, hg, is_sum_le_inj _ (@encodable.encode_injective ι _) _ _ hg hf⟩,\n  { assume i _, exact le_of_lt (f0 _) },\n  { assume n, exact le_refl _ }\nend\n\nlemma cauchy_seq_of_le_geometric [metric_space α] (r C : ℝ) (hr : r < 1) {f : ℕ → α}\n  (hu : ∀n, dist (f n) (f (n+1)) ≤ C * r^n) : cauchy_seq f :=\nbegin\n  refine cauchy_seq_of_has_sum_dist (has_sum_of_norm_bounded (λn, C * r^n) _ _),\n  { by_cases h : C = 0,\n    { simp [h, has_sum_zero] },\n    { have Cpos : C > 0,\n      { have := le_trans dist_nonneg (hu 0),\n        simp only [mul_one, pow_zero] at this,\n        exact lt_of_le_of_ne this (ne.symm h) },\n      have rnonneg: r ≥ 0,\n      { have := le_trans dist_nonneg (hu 1),\n        simp only [pow_one] at this,\n        exact nonneg_of_mul_nonneg_left this Cpos },\n      refine has_sum_mul_left C _,\n      exact has_sum_spec (@is_sum_geometric r rnonneg hr) }},\n  show ∀n, abs (dist (f n) (f (n+1))) ≤ C * r^n,\n  { assume n, rw abs_of_nonneg (dist_nonneg), exact hu n }\nend\n\nnamespace nnreal\n\ntheorem exists_pos_sum_of_encodable {ε : nnreal} (hε : 0 < ε) (ι) [encodable ι] :\n  ∃ ε' : ι → nnreal, (∀ i, 0 < ε' i) ∧ ∃c, is_sum ε' c ∧ c < ε :=\nlet ⟨a, a0, aε⟩ := dense hε in\nlet ⟨ε', hε', c, hc, hcε⟩ := pos_sum_of_encodable a0 ι in\n⟨ λi, ⟨ε' i, le_of_lt $ hε' i⟩, assume i, nnreal.coe_lt.2 $ hε' i,\n  ⟨c, is_sum_le (assume i, le_of_lt $ hε' i) is_sum_zero hc ⟩, nnreal.is_sum_coe.1 hc,\n   lt_of_le_of_lt (nnreal.coe_le.1 hcε) aε ⟩\n\nend nnreal\n\nnamespace ennreal\n\ntheorem exists_pos_sum_of_encodable {ε : ennreal} (hε : 0 < ε) (ι) [encodable ι] :\n  ∃ ε' : ι → nnreal, (∀ i, 0 < ε' i) ∧ (∑ i, (ε' i : ennreal)) < ε :=\nbegin\n  rcases dense hε with ⟨r, h0r, hrε⟩,\n  rcases lt_iff_exists_coe.1 hrε with ⟨x, rfl, hx⟩,\n  rcases nnreal.exists_pos_sum_of_encodable (coe_lt_coe.1 h0r) ι with ⟨ε', hp, c, hc, hcr⟩,\n  exact ⟨ε', hp, (ennreal.tsum_coe_eq hc).symm ▸ lt_trans (coe_lt_coe.2 hcr) hrε⟩\nend\n\nend ennreal\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/analysis/specific_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.4953311426813872}}
{"text": "inductive ty : Type\n| unit : ty\n| bool : ty\n| arrow : ty -> ty -> ty\n\ndef nm := string\n\ninductive tm : Type\n| var : nm -> tm\n| unit : tm\n| true : tm\n| false : tm\n| app : tm -> tm -> tm\n| lam : nm -> tm -> tm\n| if_then_else : tm -> tm -> tm -> tm\n\ninductive value : tm -> Prop\n| unit : value tm.unit\n| true : value tm.true\n| false : value tm.false\n| lam {x e} : value (tm.lam x e)\n\ndef subst : nm -> tm -> tm -> tm\n| x e (tm.var y) :=\n    if x = y then e else tm.var y\n| x e tm.unit :=\n    tm.unit\n| x e tm.true :=\n    tm.true\n| x e tm.false :=\n    tm.false\n| x e (tm.app e1 e2) :=\n    tm.app (subst x e e1) (subst x e e2)\n| x e (tm.lam y e') :=\n    if x = y then tm.lam y e' else tm.lam y (subst x e e')\n| x e (tm.if_then_else e' e1 e2) :=\n    tm.if_then_else (subst x e e') (subst x e e1) (subst x e e2)\n\ninductive step : tm -> tm -> Prop\n| app1 {e1 e1' e2} :\n    step e1 e1' ->\n    step (tm.app e1 e2) (tm.app e1' e2)\n| app2 {v1 e2 e2'} :\n    value v1 ->\n    step e2 e2' ->\n    step (tm.app v1 e2) (tm.app v1 e2')\n| app_beta {x e1 v2} :\n    value v2 ->\n    step (tm.app (tm.lam x e1) v2) (subst x v2 e1)\n| if_then_else {e e' e1 e2} :\n    step e e' ->\n    step (tm.if_then_else e e1 e2) (tm.if_then_else e' e1 e2)\n| if_true {e1 e2} :\n    step (tm.if_then_else tm.true e1 e2) e1\n| if_false {e1 e2} :\n    step (tm.if_then_else tm.false e1 e2) e2\n\ninductive ctx : Type\n| nil : ctx\n| cons : nm -> ty -> ctx -> ctx\n\ninductive lookup : nm -> ctx -> ty -> Prop\n| here {x A Γ} :\n    lookup x (ctx.cons x A Γ) A\n| there {x y A B Γ} :\n    x ≠ y ->\n    lookup x Γ A ->\n    lookup x (ctx.cons y B Γ) A\n\ninductive of : ctx -> tm -> ty -> Prop\n| var {x Γ A} :\n    lookup x Γ A ->\n    of Γ (tm.var x) A\n| unit {Γ} :\n    of Γ tm.unit ty.unit\n| true {Γ} :\n    of Γ tm.true ty.bool\n| false {Γ} :\n    of Γ tm.false ty.bool\n| app {Γ e1 e2 A B} :\n    of Γ e1 (ty.arrow A B) ->\n    of Γ e2 A ->\n    of Γ (tm.app e1 e2) B\n| lam {Γ x e A B} :\n    of (ctx.cons x A Γ) e B ->\n    of Γ (tm.lam x e) (ty.arrow A B)\n| if_then_else {Γ e e1 e2 A} :\n    of Γ e ty.bool ->\n    of Γ e1 A ->\n    of Γ e2 A ->\n    of Γ (tm.if_then_else e e1 e2) A\n\ntheorem substitution {Γ x A e e' A'} :\n    of Γ e A\n    -> of (ctx.cons x A Γ) e' A'\n    -> of Γ (subst x e e') A'\n:=\nbegin\n  intros H,\n  generalize ctx_cons : (ctx.cons x A Γ) = Γ',\n  intros H',\n  induction H',\n  repeat {simp},\n  case of.var {\n      rewrite <- ctx_cons at H'_a,\n      unfold subst,\n      cases H'_a,\n      case lookup.here {\n        simp,\n        assumption\n      },\n      case lookup.there {\n        by_cases (x = H'_x),\n          have H := (ne.symm H'_a_a), contradiction,\n          simp [h], apply of.var, assumption\n      }\n  },\n  case of.unit {\n      apply of.unit\n  },\n  case of.true {\n      apply of.true\n  },\n  case of.false {\n      apply of.false\n  },\n  case of.app {\n      apply of.app,\n      apply H'_ih_a ctx_cons,\n      apply H'_ih_a_1 ctx_cons\n  },\n  case of.if_then_else {\n      apply of.if_then_else,\n      apply H'_ih_a ctx_cons,\n      apply H'_ih_a_1 ctx_cons,\n      apply H'_ih_a_2 ctx_cons\n  },\n  case of.lam {\n      unfold subst,\n      by_cases (x = H'_x),\n        simp [h], apply of.lam, sorry,\n        simp [h], apply of.lam, sorry\n  },\nend\n\ntheorem preservation {e e'} :\n    step e e' ->\n    forall {Γ A}, of Γ e A ->\n    of Γ e' A\n:=\nbegin\n    intros Hstep,\n    induction Hstep,\n    repeat {intros Γ A Hof},\n    case step.app_beta {\n        cases Hof,\n        cases Hof_a,\n        apply substitution Hof_a_1 Hof_a_a\n    },\n    case step.app1 {\n        cases Hof,\n        apply of.app,\n        apply Hstep_ih Hof_a,\n        apply Hof_a_1\n    },\n    case step.app2 {\n        cases Hof,\n        apply of.app,\n        apply Hof_a,\n        apply Hstep_ih Hof_a_1\n    },\n    case step.if_then_else {\n        cases Hof,\n        apply of.if_then_else,\n        apply Hstep_ih Hof_a,\n        apply Hof_a_1,\n        apply Hof_a_2\n    },\n    case step.if_true {\n        cases Hof,\n        apply Hof_a_1\n    },\n    case step.if_false {\n        cases Hof,\n        apply Hof_a_2\n    }\nend\n\ntheorem progress {e A} :\n    of ctx.nil e A ->\n    (value e) ∨ (exists e', step e e')\n:=\nbegin\n    generalize empty : ctx.nil = Γ,\n    intros H,\n    induction H,\n    case of.var {\n        rewrite ←empty at H_a,\n        cases H_a\n    },\n    case of.unit {\n        left,\n        exact value.unit\n    },\n    case of.app {\n        cases H_ih_a empty,\n        case or.inl {\n            cases H_a,\n            case of.var\n                {rw ←empty at H_a_a, cases H_a_a},\n            case of.app\n                {cases h},\n            case of.lam {\n                cases H_ih_a_1 empty,\n                right,\n                existsi (subst H_a_x H_e2 H_a_e),\n                apply step.app_beta,\n                assumption,\n                right,\n                cases h_1,\n                existsi (tm.app (tm.lam H_a_x H_a_e) h_1_w),\n                eapply step.app2,\n                exact value.lam,\n                assumption\n            },\n            case of.if_then_else {\n                cases h\n            }\n        },\n        case or.inr {\n            cases h with e H_step,\n            right,\n            existsi (tm.app e H_e2),\n            apply step.app1,\n            assumption\n        }\n    },\n    case of.lam {\n        left,\n        exact value.lam\n    },\n    case of.true {\n        left,\n        exact value.true\n    },\n    case of.false {\n        left,\n        exact value.false\n    },\n    case of.if_then_else {\n        cases H_ih_a empty,\n        case or.inl {\n            cases H_a,\n            case of.var {\n                rw ←empty at H_a_a,\n                cases H_a_a\n            },\n            case of.true {\n                right,\n                existsi H_e1,\n                exact step.if_true\n            },\n            case of.false {\n                right,\n                existsi H_e2,\n                exact step.if_false\n            },\n            cases h,\n            cases h\n        },\n        case or.inr {\n            cases h,\n            right,\n            existsi (tm.if_then_else h_w H_e1 H_e2),\n            exact (step.if_then_else h_h),\n        }\n    }\nend\n", "meta": {"author": "tadejpetric", "repo": "tpj-coq", "sha": "dda9fb2e635f9a1302739e34d8692a4252066b76", "save_path": "github-repos/lean/tadejpetric-tpj-coq", "path": "github-repos/lean/tadejpetric-tpj-coq/tpj-coq-dda9fb2e635f9a1302739e34d8692a4252066b76/06-formalizacija-dokazov/lambda.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6893056040203136, "lm_q1q2_score": 0.4953311418166644}}
{"text": "/-\nCopyright (c) 2022 Junyan Xu. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Junyan Xu\n\n! This file was ported from Lean 3 source module data.finsupp.well_founded\n! leanprover-community/mathlib commit 290a7ba01fbcab1b64757bdaa270d28f4dcede35\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Dfinsupp.WellFounded\nimport Mathbin.Data.Finsupp.Lex\n\n/-!\n# Well-foundedness of the lexicographic and product orders on `finsupp`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n`finsupp.lex.well_founded` and the two variants that follow it essentially say that if\n`(>)` is a well order on `α`, `(<)` is well-founded on `N`, and `0` is a bottom element in `N`,\nthen the lexicographic `(<)` is well-founded on `α →₀ N`.\n\n`finsupp.lex.well_founded_lt_of_finite` says that if `α` is finite and equipped with a linear\norder and `(<)` is well-founded on `N`, then the lexicographic `(<)` is well-founded on `α →₀ N`.\n\n`finsupp.well_founded_lt` and `well_founded_lt_of_finite` state the same results for the product\norder `(<)`, but without the ordering conditions on `α`.\n\nAll results are transferred from `dfinsupp` via `finsupp.to_dfinsupp`.\n-/\n\n\nvariable {α N : Type _}\n\nnamespace Finsupp\n\nvariable [hz : Zero N] {r : α → α → Prop} {s : N → N → Prop} (hbot : ∀ ⦃n⦄, ¬s n 0)\n  (hs : WellFounded s)\n\ninclude hbot hs\n\n/- warning: finsupp.lex.acc -> Finsupp.Lex.acc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {N : Type.{u2}} [hz : Zero.{u2} N] {r : α -> α -> Prop} {s : N -> N -> Prop}, (forall {{n : N}}, Not (s n (OfNat.ofNat.{u2} N 0 (OfNat.mk.{u2} N 0 (Zero.zero.{u2} N hz))))) -> (WellFounded.{succ u2} N s) -> (forall (x : Finsupp.{u1, u2} α N hz), (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a (Finsupp.support.{u1, u2} α N hz x)) -> (Acc.{succ u1} α (Inf.inf.{u1} (α -> α -> Prop) (Pi.hasInf.{u1, u1} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.hasInf.{u1, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => SemilatticeInf.toHasInf.{0} Prop (Lattice.toSemilatticeInf.{0} Prop (ConditionallyCompleteLattice.toLattice.{0} Prop (CompleteLattice.toConditionallyCompleteLattice.{0} Prop Prop.completeLattice)))))) (HasCompl.compl.{u1} (α -> α -> Prop) (Pi.hasCompl.{u1, u1} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.hasCompl.{u1, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => Prop.hasCompl))) r) (Ne.{succ u1} α)) a)) -> (Acc.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α N hz) (Finsupp.Lex.{u1, u2} α N hz r s) x))\nbut is expected to have type\n  forall {α : Type.{u2}} {N : Type.{u1}} [hz : Zero.{u1} N] {r : α -> α -> Prop} {s : N -> N -> Prop}, (forall {{n : N}}, Not (s n (OfNat.ofNat.{u1} N 0 (Zero.toOfNat0.{u1} N hz)))) -> (WellFounded.{succ u1} N s) -> (forall (x : Finsupp.{u2, u1} α N hz), (forall (a : α), (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a (Finsupp.support.{u2, u1} α N hz x)) -> (Acc.{succ u2} α (Inf.inf.{u2} (α -> α -> Prop) (Pi.instInfForAll.{u2, u2} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.instInfForAll.{u2, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => Lattice.toInf.{0} Prop (ConditionallyCompleteLattice.toLattice.{0} Prop (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{0} Prop (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{0} Prop (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{0} Prop Prop.completeLinearOrder))))))) (HasCompl.compl.{u2} (α -> α -> Prop) (Pi.hasCompl.{u2, u2} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.hasCompl.{u2, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => Prop.hasCompl))) r) (fun (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.102 : α) (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.104 : α) => Ne.{succ u2} α x._@.Mathlib.Data.Finsupp.WellFounded._hyg.102 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.104)) a)) -> (Acc.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} α N hz) (Finsupp.Lex.{u2, u1} α N hz r s) x))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.acc Finsupp.Lex.accₓ'. -/\n/-- Transferred from `dfinsupp.lex.acc`. See the top of that file for an explanation for the\n  appearance of the relation `rᶜ ⊓ (≠)`. -/\ntheorem Lex.acc (x : α →₀ N) (h : ∀ a ∈ x.support, Acc (rᶜ ⊓ (· ≠ ·)) a) :\n    Acc (Finsupp.Lex r s) x := by\n  rw [lex_eq_inv_image_dfinsupp_lex]\n  classical\n    refine' InvImage.accessible to_dfinsupp (Dfinsupp.Lex.acc (fun a => hbot) (fun a => hs) _ _)\n    simpa only [toDfinsupp_support] using h\n#align finsupp.lex.acc Finsupp.Lex.acc\n\n/- warning: finsupp.lex.well_founded -> Finsupp.Lex.wellFounded is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {N : Type.{u2}} [hz : Zero.{u2} N] {r : α -> α -> Prop} {s : N -> N -> Prop}, (forall {{n : N}}, Not (s n (OfNat.ofNat.{u2} N 0 (OfNat.mk.{u2} N 0 (Zero.zero.{u2} N hz))))) -> (WellFounded.{succ u2} N s) -> (WellFounded.{succ u1} α (Inf.inf.{u1} (α -> α -> Prop) (Pi.hasInf.{u1, u1} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.hasInf.{u1, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => SemilatticeInf.toHasInf.{0} Prop (Lattice.toSemilatticeInf.{0} Prop (ConditionallyCompleteLattice.toLattice.{0} Prop (CompleteLattice.toConditionallyCompleteLattice.{0} Prop Prop.completeLattice)))))) (HasCompl.compl.{u1} (α -> α -> Prop) (Pi.hasCompl.{u1, u1} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.hasCompl.{u1, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => Prop.hasCompl))) r) (Ne.{succ u1} α))) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α N hz) (Finsupp.Lex.{u1, u2} α N hz r s))\nbut is expected to have type\n  forall {α : Type.{u2}} {N : Type.{u1}} [hz : Zero.{u1} N] {r : α -> α -> Prop} {s : N -> N -> Prop}, (forall {{n : N}}, Not (s n (OfNat.ofNat.{u1} N 0 (Zero.toOfNat0.{u1} N hz)))) -> (WellFounded.{succ u1} N s) -> (WellFounded.{succ u2} α (Inf.inf.{u2} (α -> α -> Prop) (Pi.instInfForAll.{u2, u2} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.instInfForAll.{u2, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => Lattice.toInf.{0} Prop (ConditionallyCompleteLattice.toLattice.{0} Prop (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{0} Prop (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{0} Prop (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{0} Prop Prop.completeLinearOrder))))))) (HasCompl.compl.{u2} (α -> α -> Prop) (Pi.hasCompl.{u2, u2} α (fun (ᾰ : α) => α -> Prop) (fun (i : α) => Pi.hasCompl.{u2, 0} α (fun (ᾰ : α) => Prop) (fun (i : α) => Prop.hasCompl))) r) (fun (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.228 : α) (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.230 : α) => Ne.{succ u2} α x._@.Mathlib.Data.Finsupp.WellFounded._hyg.228 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.230))) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} α N hz) (Finsupp.Lex.{u2, u1} α N hz r s))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded Finsupp.Lex.wellFoundedₓ'. -/\ntheorem Lex.wellFounded (hr : WellFounded <| rᶜ ⊓ (· ≠ ·)) : WellFounded (Finsupp.Lex r s) :=\n  ⟨fun x => Lex.acc hbot hs x fun a _ => hr.apply a⟩\n#align finsupp.lex.well_founded Finsupp.Lex.wellFounded\n\n/- warning: finsupp.lex.well_founded' -> Finsupp.Lex.wellFounded' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {N : Type.{u2}} [hz : Zero.{u2} N] {r : α -> α -> Prop} {s : N -> N -> Prop}, (forall {{n : N}}, Not (s n (OfNat.ofNat.{u2} N 0 (OfNat.mk.{u2} N 0 (Zero.zero.{u2} N hz))))) -> (WellFounded.{succ u2} N s) -> (forall [_inst_1 : IsTrichotomous.{u1} α r], (WellFounded.{succ u1} α (Function.swap.{succ u1, succ u1, 1} α α (fun (ᾰ : α) (ᾰ : α) => Prop) r)) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α N hz) (Finsupp.Lex.{u1, u2} α N hz r s)))\nbut is expected to have type\n  forall {α : Type.{u2}} {N : Type.{u1}} [hz : Zero.{u1} N] {r : α -> α -> Prop} {s : N -> N -> Prop}, (forall {{n : N}}, Not (s n (OfNat.ofNat.{u1} N 0 (Zero.toOfNat0.{u1} N hz)))) -> (WellFounded.{succ u1} N s) -> (forall [_inst_1 : IsTrichotomous.{u2} α r], (WellFounded.{succ u2} α (Function.swap.{succ u2, succ u2, 1} α α (fun (ᾰ : α) (ᾰ : α) => Prop) r)) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} α N hz) (Finsupp.Lex.{u2, u1} α N hz r s)))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded' Finsupp.Lex.wellFounded'ₓ'. -/\ntheorem Lex.wellFounded' [IsTrichotomous α r] (hr : WellFounded r.symm) :\n    WellFounded (Finsupp.Lex r s) :=\n  (lex_eq_invImage_dfinsupp_lex r s).symm ▸\n    InvImage.wf _ (Dfinsupp.Lex.wellFounded' (fun a => hbot) (fun a => hs) hr)\n#align finsupp.lex.well_founded' Finsupp.Lex.wellFounded'\n\nomit hbot hs\n\n/- warning: finsupp.lex.well_founded_lt -> Finsupp.Lex.wellFoundedLT is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {N : Type.{u2}} [_inst_1 : LT.{u1} α] [_inst_2 : IsTrichotomous.{u1} α (LT.lt.{u1} α _inst_1)] [hα : WellFoundedGT.{u1} α _inst_1] [_inst_3 : CanonicallyOrderedAddMonoid.{u2} N] [hN : WellFoundedLT.{u2} N (Preorder.toLT.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3))))], WellFoundedLT.{max u1 u2} (Lex.{max u1 u2} (Finsupp.{u1, u2} α N (AddZeroClass.toHasZero.{u2} N (AddMonoid.toAddZeroClass.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3))))))) (Finsupp.Lex.hasLt.{u1, u2} α N (AddZeroClass.toHasZero.{u2} N (AddMonoid.toAddZeroClass.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3))))) _inst_1 (Preorder.toLT.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {N : Type.{u2}} [_inst_1 : LT.{u1} α] [_inst_2 : IsTrichotomous.{u1} α (fun (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.381 : α) (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.383 : α) => LT.lt.{u1} α _inst_1 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.381 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.383)] [hα : WellFoundedGT.{u1} α _inst_1] [_inst_3 : CanonicallyOrderedAddMonoid.{u2} N] [hN : WellFoundedLT.{u2} N (Preorder.toLT.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3))))], WellFoundedLT.{max u2 u1} (Lex.{max u2 u1} (Finsupp.{u1, u2} α N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3)))))) (Finsupp.instLTLexFinsupp.{u1, u2} α N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3)))) _inst_1 (Preorder.toLT.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3)))))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded_lt Finsupp.Lex.wellFoundedLTₓ'. -/\ninstance Lex.wellFoundedLT [LT α] [IsTrichotomous α (· < ·)] [hα : WellFoundedGT α]\n    [CanonicallyOrderedAddMonoid N] [hN : WellFoundedLT N] : WellFoundedLT (Lex (α →₀ N)) :=\n  ⟨Lex.wellFounded' (fun n => (zero_le n).not_lt) hN.wf hα.wf⟩\n#align finsupp.lex.well_founded_lt Finsupp.Lex.wellFoundedLT\n\nvariable (r)\n\n/- warning: finsupp.lex.well_founded_of_finite -> Finsupp.Lex.wellFounded_of_finite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {N : Type.{u2}} (r : α -> α -> Prop) {s : N -> N -> Prop} [_inst_1 : IsStrictTotalOrder.{u1} α r] [_inst_2 : Finite.{succ u1} α] [_inst_3 : Zero.{u2} N], (WellFounded.{succ u2} N s) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α N _inst_3) (Finsupp.Lex.{u1, u2} α N _inst_3 r s))\nbut is expected to have type\n  forall {α : Type.{u2}} {N : Type.{u1}} (r : α -> α -> Prop) {s : N -> N -> Prop} [_inst_1 : IsStrictTotalOrder.{u2} α r] [_inst_2 : Finite.{succ u2} α] [_inst_3 : Zero.{u1} N], (WellFounded.{succ u1} N s) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} α N _inst_3) (Finsupp.Lex.{u2, u1} α N _inst_3 r s))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded_of_finite Finsupp.Lex.wellFounded_of_finiteₓ'. -/\ntheorem Lex.wellFounded_of_finite [IsStrictTotalOrder α r] [Finite α] [Zero N]\n    (hs : WellFounded s) : WellFounded (Finsupp.Lex r s) :=\n  InvImage.wf (@equivFunOnFinite α N _ _) (Pi.Lex.wellFounded r fun a => hs)\n#align finsupp.lex.well_founded_of_finite Finsupp.Lex.wellFounded_of_finite\n\n/- warning: finsupp.lex.well_founded_lt_of_finite -> Finsupp.Lex.wellFoundedLT_of_finite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {N : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : Finite.{succ u1} α] [_inst_3 : Zero.{u2} N] [_inst_4 : LT.{u2} N] [hwf : WellFoundedLT.{u2} N _inst_4], WellFoundedLT.{max u1 u2} (Lex.{max u1 u2} (Finsupp.{u1, u2} α N _inst_3)) (Finsupp.Lex.hasLt.{u1, u2} α N _inst_3 (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) _inst_4)\nbut is expected to have type\n  forall {α : Type.{u2}} {N : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : Finite.{succ u2} α] [_inst_3 : Zero.{u1} N] [_inst_4 : LT.{u1} N] [hwf : WellFoundedLT.{u1} N _inst_4], WellFoundedLT.{max u1 u2} (Lex.{max u1 u2} (Finsupp.{u2, u1} α N _inst_3)) (Finsupp.instLTLexFinsupp.{u2, u1} α N _inst_3 (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) _inst_4)\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded_lt_of_finite Finsupp.Lex.wellFoundedLT_of_finiteₓ'. -/\ntheorem Lex.wellFoundedLT_of_finite [LinearOrder α] [Finite α] [Zero N] [LT N]\n    [hwf : WellFoundedLT N] : WellFoundedLT (Lex (α →₀ N)) :=\n  ⟨Finsupp.Lex.wellFounded_of_finite (· < ·) hwf.1⟩\n#align finsupp.lex.well_founded_lt_of_finite Finsupp.Lex.wellFoundedLT_of_finite\n\n#print Finsupp.wellFoundedLT /-\nprotected theorem wellFoundedLT [Zero N] [Preorder N] [WellFoundedLT N] (hbot : ∀ n : N, ¬n < 0) :\n    WellFoundedLT (α →₀ N) :=\n  ⟨InvImage.wf toDfinsupp (Dfinsupp.wellFoundedLT fun i a => hbot a).wf⟩\n#align finsupp.well_founded_lt Finsupp.wellFoundedLT\n-/\n\n/- warning: finsupp.well_founded_lt' -> Finsupp.wellFoundedLT' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {N : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} N] [_inst_2 : WellFoundedLT.{u2} N (Preorder.toLT.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1))))], WellFoundedLT.{max u1 u2} (Finsupp.{u1, u2} α N (AddZeroClass.toHasZero.{u2} N (AddMonoid.toAddZeroClass.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1)))))) (Preorder.toLT.{max u1 u2} (Finsupp.{u1, u2} α N (AddZeroClass.toHasZero.{u2} N (AddMonoid.toAddZeroClass.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1)))))) (Finsupp.preorder.{u1, u2} α N (AddZeroClass.toHasZero.{u2} N (AddMonoid.toAddZeroClass.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1))))) (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {N : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} N] [_inst_2 : WellFoundedLT.{u2} N (Preorder.toLT.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1))))], WellFoundedLT.{max u2 u1} (Finsupp.{u1, u2} α N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1))))) (Preorder.toLT.{max u1 u2} (Finsupp.{u1, u2} α N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1))))) (Finsupp.preorder.{u1, u2} α N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1)))) (PartialOrder.toPreorder.{u2} N (OrderedAddCommMonoid.toPartialOrder.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align finsupp.well_founded_lt' Finsupp.wellFoundedLT'ₓ'. -/\ninstance wellFoundedLT' [CanonicallyOrderedAddMonoid N] [WellFoundedLT N] :\n    WellFoundedLT (α →₀ N) :=\n  Finsupp.wellFoundedLT fun a => (zero_le a).not_lt\n#align finsupp.well_founded_lt' Finsupp.wellFoundedLT'\n\n#print Finsupp.wellFoundedLT_of_finite /-\ninstance wellFoundedLT_of_finite [Finite α] [Zero N] [Preorder N] [WellFoundedLT N] :\n    WellFoundedLT (α →₀ N) :=\n  ⟨InvImage.wf equivFunOnFinite Function.wellFoundedLT.wf⟩\n#align finsupp.well_founded_lt_of_finite Finsupp.wellFoundedLT_of_finite\n-/\n\nend Finsupp\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finsupp/WellFounded.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631541, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.49526480883064916}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison, Johannes Hölzl\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.fully_faithful\nimport Mathlib.data.equiv.basic\nimport Mathlib.PostPort\n\nuniverses u v w u' u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# The category `Type`.\n\nIn this section we set up the theory so that Lean's types and functions between them\ncan be viewed as a `large_category` in our framework.\n\nLean can not transparently view a function as a morphism in this category,\nand needs a hint in order to be able to type check.\nWe provide the abbreviation `as_hom f` to guide type checking,\nas well as a corresponding notation `↾ f`. (Entered as `\\upr `.)\n\nWe provide various simplification lemmas for functors and natural transformations valued in `Type`.\n\nWe define `ulift_functor`, from `Type u` to `Type (max u v)`, and show that it is fully faithful\n(but not, of course, essentially surjective).\n\nWe prove some basic facts about the category `Type`:\n*  epimorphisms are surjections and monomorphisms are injections,\n* `iso` is both `iso` and `equiv` to `equiv` (at least within a fixed universe),\n* every type level `is_lawful_functor` gives a categorical functor `Type ⥤ Type`\n  (the corresponding fact about monads is in `src/category_theory/monad/types.lean`).\n-/\n\nnamespace category_theory\n\n\nprotected instance types : large_category (Type u) :=\n  category.mk\n\ntheorem types_hom {α : Type u} {β : Type u} : (α ⟶ β) = (α → β) :=\n  rfl\n\ntheorem types_id (X : Type u) : 𝟙 = id :=\n  rfl\n\ntheorem types_comp {X : Type u} {Y : Type u} {Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f :=\n  rfl\n\n@[simp] theorem types_id_apply (X : Type u) (x : X) : 𝟙 = x :=\n  rfl\n\n@[simp] theorem types_comp_apply {X : Type u} {Y : Type u} {Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : category_struct.comp f g x = g (f x) :=\n  rfl\n\n@[simp] theorem hom_inv_id_apply {X : Type u} {Y : Type u} (f : X ≅ Y) (x : X) : iso.inv f (iso.hom f x) = x :=\n  congr_fun (iso.hom_inv_id f) x\n\n@[simp] theorem inv_hom_id_apply {X : Type u} {Y : Type u} (f : X ≅ Y) (y : Y) : iso.hom f (iso.inv f y) = y :=\n  congr_fun (iso.inv_hom_id f) y\n\n/-- `as_hom f` helps Lean type check a function as a morphism in the category `Type`. -/\n-- Unfortunately without this wrapper we can't use `category_theory` idioms, such as `is_iso f`.\n\n-- If you don't mind some notation you can use fewer keystrokes:\n\ndef as_hom {α : Type u} {β : Type u} (f : α → β) : α ⟶ β :=\n  f\n\nprefix:200 \"↾\" => Mathlib.category_theory.as_hom\n\nnamespace functor\n\n\n/--\nThe sections of a functor `J ⥤ Type` are\nthe choices of a point `u j : F.obj j` for each `j`,\nsuch that `F.map f (u j) = u j` for every morphism `f : j ⟶ j'`.\n\nWe later use these to define limits in `Type` and in many concrete categories.\n-/\ndef sections {J : Type u} [category J] (F : J ⥤ Type w) : set ((j : J) → obj F j) :=\n  set_of fun (u : (j : J) → obj F j) => ∀ {j j' : J} (f : j ⟶ j'), map F f (u j) = u j'\n\nend functor\n\n\nnamespace functor_to_types\n\n\n@[simp] theorem map_comp_apply {C : Type u} [category C] (F : C ⥤ Type w) {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (a : functor.obj F X) : functor.map F (f ≫ g) a = functor.map F g (functor.map F f a) := sorry\n\n@[simp] theorem map_id_apply {C : Type u} [category C] (F : C ⥤ Type w) {X : C} (a : functor.obj F X) : functor.map F 𝟙 a = a := sorry\n\ntheorem naturality {C : Type u} [category C] (F : C ⥤ Type w) (G : C ⥤ Type w) {X : C} {Y : C} (σ : F ⟶ G) (f : X ⟶ Y) (x : functor.obj F X) : nat_trans.app σ Y (functor.map F f x) = functor.map G f (nat_trans.app σ X x) :=\n  congr_fun (nat_trans.naturality σ f) x\n\n@[simp] theorem comp {C : Type u} [category C] (F : C ⥤ Type w) (G : C ⥤ Type w) (H : C ⥤ Type w) {X : C} (σ : F ⟶ G) (τ : G ⟶ H) (x : functor.obj F X) : nat_trans.app (σ ≫ τ) X x = nat_trans.app τ X (nat_trans.app σ X x) :=\n  rfl\n\n@[simp] theorem hcomp {C : Type u} [category C] (F : C ⥤ Type w) (G : C ⥤ Type w) (σ : F ⟶ G) {D : Type u'} [𝒟 : category D] (I : D ⥤ C) (J : D ⥤ C) (ρ : I ⟶ J) {W : D} (x : functor.obj (I ⋙ F) W) : nat_trans.app (ρ ◫ σ) W x = functor.map G (nat_trans.app ρ W) (nat_trans.app σ (functor.obj I W) x) :=\n  rfl\n\n@[simp] theorem map_inv_map_hom_apply {C : Type u} [category C] (F : C ⥤ Type w) {X : C} {Y : C} (f : X ≅ Y) (x : functor.obj F X) : functor.map F (iso.inv f) (functor.map F (iso.hom f) x) = x :=\n  congr_fun (iso.hom_inv_id (functor.map_iso F f)) x\n\n@[simp] theorem map_hom_map_inv_apply {C : Type u} [category C] (F : C ⥤ Type w) {X : C} {Y : C} (f : X ≅ Y) (y : functor.obj F Y) : functor.map F (iso.hom f) (functor.map F (iso.inv f) y) = y :=\n  congr_fun (iso.inv_hom_id (functor.map_iso F f)) y\n\n@[simp] theorem hom_inv_id_app_apply {C : Type u} [category C] (F : C ⥤ Type w) (G : C ⥤ Type w) (α : F ≅ G) (X : C) (x : functor.obj F X) : nat_trans.app (iso.inv α) X (nat_trans.app (iso.hom α) X x) = x :=\n  congr_fun (iso.hom_inv_id_app α X) x\n\n@[simp] theorem inv_hom_id_app_apply {C : Type u} [category C] (F : C ⥤ Type w) (G : C ⥤ Type w) (α : F ≅ G) (X : C) (x : functor.obj G X) : nat_trans.app (iso.hom α) X (nat_trans.app (iso.inv α) X x) = x :=\n  congr_fun (iso.inv_hom_id_app α X) x\n\nend functor_to_types\n\n\n/--\nThe isomorphism between a `Type` which has been `ulift`ed to the same universe,\nand the original type.\n-/\ndef ulift_trivial (V : Type u) : ulift V ≅ V :=\n  iso.mk (id fun (ᾰ : ulift V) => ulift.cases_on ᾰ fun (ᾰ : V) => ᾰ) ulift.up\n\n/--\nThe functor embedding `Type u` into `Type (max u v)`.\nWrite this as `ulift_functor.{5 2}` to get `Type 2 ⥤ Type 5`.\n-/\ndef ulift_functor : Type u ⥤ Type (max u v) :=\n  functor.mk (fun (X : Type u) => ulift X) fun (X Y : Type u) (f : X ⟶ Y) (x : ulift X) => ulift.up (f (ulift.down x))\n\n@[simp] theorem ulift_functor_map {X : Type u} {Y : Type u} (f : X ⟶ Y) (x : ulift X) : functor.map ulift_functor f x = ulift.up (f (ulift.down x)) :=\n  rfl\n\nprotected instance ulift_functor_full : full ulift_functor :=\n  full.mk\n    fun (X Y : Type u) (f : functor.obj ulift_functor X ⟶ functor.obj ulift_functor Y) (x : X) =>\n      ulift.down (f (ulift.up x))\n\nprotected instance ulift_functor_faithful : faithful ulift_functor :=\n  faithful.mk\n\n/-- Any term `x` of a type `X` corresponds to a morphism `punit ⟶ X`. -/\n-- TODO We should connect this to a general story about concrete categories\n\n-- whose forgetful functor is representable.\n\ndef hom_of_element {X : Type u} (x : X) : PUnit ⟶ X :=\n  fun (_x : PUnit) => x\n\ntheorem hom_of_element_eq_iff {X : Type u} (x : X) (y : X) : hom_of_element x = hom_of_element y ↔ x = y := sorry\n\n/--\nA morphism in `Type` is a monomorphism if and only if it is injective.\n\nSee https://stacks.math.columbia.edu/tag/003C.\n-/\ntheorem mono_iff_injective {X : Type u} {Y : Type u} (f : X ⟶ Y) : mono f ↔ function.injective f := sorry\n\n/--\nA morphism in `Type` is an epimorphism if and only if it is surjective.\n\nSee https://stacks.math.columbia.edu/tag/003C.\n-/\ntheorem epi_iff_surjective {X : Type u} {Y : Type u} (f : X ⟶ Y) : epi f ↔ function.surjective f := sorry\n\n/-- `of_type_functor m` converts from Lean's `Type`-based `category` to `category_theory`. This\nallows us to use these functors in category theory. -/\ndef of_type_functor (m : Type u → Type v) [Functor m] [is_lawful_functor m] : Type u ⥤ Type v :=\n  functor.mk m fun (α β : Type u) => Functor.map\n\n@[simp] theorem of_type_functor_obj (m : Type u → Type v) [Functor m] [is_lawful_functor m] : functor.obj (of_type_functor m) = m :=\n  rfl\n\n@[simp] theorem of_type_functor_map (m : Type u → Type v) [Functor m] [is_lawful_functor m] {α : Type u} {β : Type u} (f : α → β) : functor.map (of_type_functor m) f = Functor.map f :=\n  rfl\n\nend category_theory\n\n\n-- Isomorphisms in Type and equivalences.\n\nnamespace equiv\n\n\n/--\nAny equivalence between types in the same universe gives\na categorical isomorphism between those types.\n-/\ndef to_iso {X : Type u} {Y : Type u} (e : X ≃ Y) : X ≅ Y :=\n  category_theory.iso.mk (to_fun e) (inv_fun e)\n\n@[simp] theorem to_iso_hom {X : Type u} {Y : Type u} {e : X ≃ Y} : category_theory.iso.hom (to_iso e) = ⇑e :=\n  rfl\n\n@[simp] theorem to_iso_inv {X : Type u} {Y : Type u} {e : X ≃ Y} : category_theory.iso.inv (to_iso e) = ⇑(equiv.symm e) :=\n  rfl\n\nend equiv\n\n\nnamespace category_theory.iso\n\n\n/--\nAny isomorphism between types gives an equivalence.\n-/\ndef to_equiv {X : Type u} {Y : Type u} (i : X ≅ Y) : X ≃ Y :=\n  equiv.mk (hom i) (inv i) sorry sorry\n\n@[simp] theorem to_equiv_fun {X : Type u} {Y : Type u} (i : X ≅ Y) : ⇑(to_equiv i) = hom i :=\n  rfl\n\n@[simp] theorem to_equiv_symm_fun {X : Type u} {Y : Type u} (i : X ≅ Y) : ⇑(equiv.symm (to_equiv i)) = inv i :=\n  rfl\n\n@[simp] theorem to_equiv_id (X : Type u) : to_equiv (refl X) = equiv.refl X :=\n  rfl\n\n@[simp] theorem to_equiv_comp {X : Type u} {Y : Type u} {Z : Type u} (f : X ≅ Y) (g : Y ≅ Z) : to_equiv (f ≪≫ g) = equiv.trans (to_equiv f) (to_equiv g) :=\n  rfl\n\nend category_theory.iso\n\n\nnamespace category_theory\n\n\n/-- A morphism in `Type u` is an isomorphism if and only if it is bijective. -/\ndef is_iso_equiv_bijective {X : Type u} {Y : Type u} (f : X ⟶ Y) : is_iso f ≃ function.bijective f :=\n  equiv_of_subsingleton_of_subsingleton sorry\n    fun (b : function.bijective f) => is_iso.mk (iso.inv (equiv.to_iso (equiv.of_bijective f b)))\n\nend category_theory\n\n\n-- We prove `equiv_iso_iso` and then use that to sneakily construct `equiv_equiv_iso`.\n\n-- (In this order the proofs are handled by `obviously`.)\n\n/-- Equivalences (between types in the same universe) are the same as (isomorphic to) isomorphisms\nof types. -/\n@[simp] theorem equiv_iso_iso_hom {X : Type u} {Y : Type u} (e : X ≃ Y) : category_theory.iso.hom equiv_iso_iso e = equiv.to_iso e :=\n  Eq.refl (category_theory.iso.hom equiv_iso_iso e)\n\n/-- Equivalences (between types in the same universe) are the same as (equivalent to) isomorphisms\nof types. -/\n-- We leave `X` and `Y` as explicit arguments here, because the coercions from `equiv` to a function\n\n-- won't fire without them.\n\n-- TODO: is it still true?\n\ndef equiv_equiv_iso (X : Type u) (Y : Type u) : X ≃ Y ≃ (X ≅ Y) :=\n  category_theory.iso.to_equiv equiv_iso_iso\n\n@[simp] theorem equiv_equiv_iso_hom {X : Type u} {Y : Type u} (e : X ≃ Y) : coe_fn (equiv_equiv_iso X Y) e = equiv.to_iso e :=\n  rfl\n\n@[simp] theorem equiv_equiv_iso_inv {X : Type u} {Y : Type u} (e : X ≅ Y) : coe_fn (equiv.symm (equiv_equiv_iso X Y)) e = category_theory.iso.to_equiv e :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/types.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.49516393618446775}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.group.prod\nimport Mathlib.algebra.group.type_tags\nimport Mathlib.algebra.group.pi\nimport Mathlib.algebra.pointwise\nimport Mathlib.data.equiv.basic\nimport Mathlib.data.set.finite\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 u_4 u v w \n\nnamespace Mathlib\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points.  This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `has_vadd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `has_vsub.vsub`, difference between two points in an additive torsor\n  as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\n/-- Type class for the `+ᵥ` notation. -/\nclass has_vadd (G : Type u_1) (P : Type u_2) \nwhere\n  vadd : G → P → P\n\n/-- Type class for the `-ᵥ` notation. -/\nclass has_vsub (G : outParam (Type u_1)) (P : Type u_2) \nwhere\n  vsub : P → P → G\n\ninfixl:65 \" +ᵥ \" => Mathlib.has_vadd.vadd\n\ninfixl:65 \" -ᵥ \" => Mathlib.has_vsub.vsub\n\n/-- Type class for additive monoid actions. -/\nclass add_action (G : Type u_1) (P : Type u_2) [add_monoid G] \nextends has_vadd G P\nwhere\n  zero_vadd' : ∀ (p : P), 0 +ᵥ p = p\n  vadd_assoc' : ∀ (g1 g2 : G) (p : P), g1 +ᵥ (g2 +ᵥ p) = g1 + g2 +ᵥ p\n\n/-- An `add_torsor G P` gives a structure to the nonempty type `P`,\nacted on by an `add_group G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass add_torsor (G : outParam (Type u_1)) (P : Type u_2) [outParam (add_group G)] \nextends has_vsub G P, add_action G P\nwhere\n  nonempty : Nonempty P\n  vsub_vadd' : ∀ (p1 p2 : P), p1 -ᵥ p2 +ᵥ p2 = p1\n  vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n\n/-- An `add_group G` is a torsor for itself. -/\nprotected instance add_group_is_add_torsor (G : Type u_1) [add_group G] : add_torsor G G :=\n  add_torsor.mk Add.add sorry sorry Sub.sub sub_add_cancel add_sub_cancel\n\n/-- Simplify addition for a torsor for an `add_group G` over\nitself. -/\n@[simp] theorem vadd_eq_add {G : Type u_1} [add_group G] (g1 : G) (g2 : G) : g1 +ᵥ g2 = g1 + g2 :=\n  rfl\n\n/-- Simplify subtraction for a torsor for an `add_group G` over\nitself. -/\n@[simp] theorem vsub_eq_sub {G : Type u_1} [add_group G] (g1 : G) (g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n  rfl\n\n/-- Adding the zero group element to a point gives the same point. -/\n@[simp] theorem zero_vadd (G : Type u_1) {P : Type u_2} [add_monoid G] [A : add_action G P] (p : P) : 0 +ᵥ p = p :=\n  add_action.zero_vadd' p\n\n/-- Adding two group elements to a point produces the same result as\nadding their sum. -/\ntheorem vadd_assoc {G : Type u_1} {P : Type u_2} [add_monoid G] [A : add_action G P] (g1 : G) (g2 : G) (p : P) : g1 +ᵥ (g2 +ᵥ p) = g1 + g2 +ᵥ p :=\n  add_action.vadd_assoc' g1 g2 p\n\n/-- Adding two group elements to a point produces the same result in either\norder. -/\ntheorem vadd_comm (G : Type u_1) {P : Type u_2} [add_comm_monoid G] [A : add_action G P] (p : P) (g1 : G) (g2 : G) : g1 +ᵥ (g2 +ᵥ p) = g2 +ᵥ (g1 +ᵥ p) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (g1 +ᵥ (g2 +ᵥ p) = g2 +ᵥ (g1 +ᵥ p))) (vadd_assoc g1 g2 p)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (g1 + g2 +ᵥ p = g2 +ᵥ (g1 +ᵥ p))) (vadd_assoc g2 g1 p)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (g1 + g2 +ᵥ p = g2 + g1 +ᵥ p)) (add_comm g1 g2))) (Eq.refl (g2 + g1 +ᵥ p))))\n\n/-- If the same group element added to two points produces equal results,\nthose points are equal. -/\ntheorem vadd_left_cancel {G : Type u_1} {P : Type u_2} [add_group G] [A : add_action G P] {p1 : P} {p2 : P} (g : G) (h : g +ᵥ p1 = g +ᵥ p2) : p1 = p2 := sorry\n\n@[simp] theorem vadd_left_cancel_iff {G : Type u_1} {P : Type u_2} [add_group G] [A : add_action G P] {p₁ : P} {p₂ : P} (g : G) : g +ᵥ p₁ = g +ᵥ p₂ ↔ p₁ = p₂ :=\n  { mp := vadd_left_cancel g, mpr := fun (h : p₁ = p₂) => h ▸ rfl }\n\n/-- Adding the group element `g` to a point is an injective function. -/\ntheorem vadd_left_injective {G : Type u_1} (P : Type u_2) [add_group G] [A : add_action G P] (g : G) : function.injective (has_vadd.vadd g) :=\n  fun (p1 p2 : P) => vadd_left_cancel g\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp] theorem vsub_vadd {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p1 : P) (p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n  add_torsor.vsub_vadd' p1 p2\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp] theorem vadd_vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n  add_torsor.vadd_vsub' g p\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {g1 : G} {g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (g1 = g2)) (Eq.symm (vadd_vsub g1 p))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (g1 +ᵥ p -ᵥ p = g2)) h))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (g2 +ᵥ p -ᵥ p = g2)) (vadd_vsub g2 p))) (Eq.refl g2)))\n\n@[simp] theorem vadd_right_cancel_iff {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {g1 : G} {g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n  { mp := vadd_right_cancel p, mpr := fun (h : g1 = g2) => h ▸ rfl }\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p : P) : function.injective fun (_x : G) => _x +ᵥ p :=\n  fun (g1 g2 : G) => vadd_right_cancel p\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (g : G) (p1 : P) (p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := sorry\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp] theorem vsub_self {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p : P) : p -ᵥ p = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (p -ᵥ p = 0)) (Eq.symm (zero_add (p -ᵥ p)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (0 + (p -ᵥ p) = 0)) (Eq.symm (vadd_vsub_assoc 0 p p))))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 +ᵥ p -ᵥ p = 0)) (vadd_vsub 0 p))) (Eq.refl 0)))\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {p1 : P} {p2 : P} (h : p1 -ᵥ p2 = 0) : p1 = p2 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (p1 = p2)) (Eq.symm (vsub_vadd p1 p2))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (p1 -ᵥ p2 +ᵥ p2 = p2)) h))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 +ᵥ p2 = p2)) (zero_vadd G p2))) (Eq.refl p2)))\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp] theorem vsub_eq_zero_iff_eq {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {p1 : P} {p2 : P} : p1 -ᵥ p2 = 0 ↔ p1 = p2 :=\n  { mp := eq_of_vsub_eq_zero, mpr := fun (h : p1 = p2) => h ▸ vsub_self p1 }\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp] theorem vsub_add_vsub_cancel {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p1 : P) (p2 : P) (p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := sorry\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp] theorem neg_vsub_eq_vsub_rev {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p1 : P) (p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := sorry\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p1 : P) (p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := sorry\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp] theorem vsub_sub_vsub_cancel_right {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p1 : P) (p2 : P) (p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2)) (Eq.symm (vsub_vadd_eq_vsub_sub p1 p3 (p2 -ᵥ p3)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (p1 -ᵥ (p2 -ᵥ p3 +ᵥ p3) = p1 -ᵥ p2)) (vsub_vadd p2 p3))) (Eq.refl (p1 -ᵥ p2)))\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n  { mp := fun (h : p1 = g +ᵥ p2) => Eq.symm h ▸ vadd_vsub g p2,\n    mpr := fun (h : p1 -ᵥ p2 = g) => h ▸ Eq.symm (vsub_vadd p1 p2) }\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {v₁ : G} {v₂ : G} {p₁ : P} {p₂ : P} : v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := sorry\n\nnamespace set\n\n\nprotected instance has_vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] : has_vsub (set G) (set P) :=\n  has_vsub.mk (image2 has_vsub.vsub)\n\n@[simp] theorem vsub_empty {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (s : set P) : s -ᵥ ∅ = ∅ :=\n  image2_empty_right\n\n@[simp] theorem empty_vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (s : set P) : ∅ -ᵥ s = ∅ :=\n  image2_empty_left\n\n@[simp] theorem singleton_vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (s : set P) (p : P) : singleton p -ᵥ s = has_vsub.vsub p '' s :=\n  image2_singleton_left\n\n@[simp] theorem vsub_singleton {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (s : set P) (p : P) : s -ᵥ singleton p = (fun (_x : P) => _x -ᵥ p) '' s :=\n  image2_singleton_right\n\n@[simp] theorem singleton_vsub_self {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p : P) : singleton p -ᵥ singleton p = singleton 0 := sorry\n\n/-- `vsub` of a finite set is finite. -/\ntheorem finite.vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {s : set P} {t : set P} (hs : finite s) (ht : finite t) : finite (s -ᵥ t) :=\n  finite.image2 (fun (a b : P) => a -ᵥ b) hs ht\n\n/-- Each pairwise difference is in the `vsub` set. -/\ntheorem vsub_mem_vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {s : set P} {t : set P} {ps : P} {pt : P} (hs : ps ∈ s) (ht : pt ∈ t) : ps -ᵥ pt ∈ s -ᵥ t :=\n  mem_image2_of_mem hs ht\n\n/-- `s -ᵥ t` is monotone in both arguments. -/\ntheorem vsub_subset_vsub {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {s : set P} {t : set P} {s' : set P} {t' : set P} (hs : s ⊆ s') (ht : t ⊆ t') : s -ᵥ t ⊆ s' -ᵥ t' :=\n  image2_subset hs ht\n\ntheorem vsub_self_mono {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {s : set P} {t : set P} (h : s ⊆ t) : s -ᵥ s ⊆ t -ᵥ t :=\n  vsub_subset_vsub h h\n\ntheorem vsub_subset_iff {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {s : set P} {t : set P} {u : set G} : s -ᵥ t ⊆ u ↔ ∀ (x : P), x ∈ s → ∀ (y : P), y ∈ t → x -ᵥ y ∈ u :=\n  image2_subset_iff\n\nprotected instance add_action {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] : add_action (set G) (set P) :=\n  add_action.mk (image2 has_vadd.vadd) sorry sorry\n\ntheorem vadd_subset_vadd {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {s : set G} {s' : set G} {t : set P} {t' : set P} (hs : s ⊆ s') (ht : t ⊆ t') : s +ᵥ t ⊆ s' +ᵥ t' :=\n  image2_subset hs ht\n\n@[simp] theorem vadd_singleton {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (s : set G) (p : P) : s +ᵥ singleton p = (fun (_x : G) => _x +ᵥ p) '' s :=\n  image2_singleton_right\n\n@[simp] theorem singleton_vadd {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (v : G) (s : set P) : singleton v +ᵥ s = has_vadd.vadd v '' s :=\n  image2_singleton_left\n\ntheorem finite.vadd {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {s : set G} {t : set P} (hs : finite s) (ht : finite t) : finite (s +ᵥ t) :=\n  finite.image2 (fun (a : G) (b : P) => a +ᵥ b) hs ht\n\nend set\n\n\n@[simp] theorem vadd_vsub_vadd_cancel_right {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (v₁ : G) (v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := sorry\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {p1 : P} {p2 : P} {p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 :=\n  eq.mp (Eq._oldrec (Eq.refl (p1 -ᵥ p2 = 0)) (propext vsub_eq_zero_iff_eq))\n    (eq.mp (Eq._oldrec (Eq.refl (p1 -ᵥ p - (p2 -ᵥ p) = 0)) (vsub_sub_vsub_cancel_right p1 p2 p))\n      (eq.mp (Eq._oldrec (Eq.refl (p1 -ᵥ p = p2 -ᵥ p)) (Eq.symm (propext sub_eq_zero))) h))\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp] theorem vsub_left_cancel_iff {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {p1 : P} {p2 : P} {p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n  { mp := vsub_left_cancel, mpr := fun (h : p1 = p2) => h ▸ rfl }\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p : P) : function.injective fun (_x : P) => _x -ᵥ p :=\n  fun (p2 p3 : P) => vsub_left_cancel\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {p1 : P} {p2 : P} {p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := sorry\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp] theorem vsub_right_cancel_iff {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] {p1 : P} {p2 : P} {p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n  { mp := vsub_right_cancel, mpr := fun (h : p1 = p2) => h ▸ rfl }\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective {G : Type u_1} {P : Type u_2} [add_group G] [T : add_torsor G P] (p : P) : function.injective (has_vsub.vsub p) :=\n  fun (p2 p3 : P) => vsub_right_cancel\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp] theorem vsub_sub_vsub_cancel_left {G : Type u_1} {P : Type u_2} [add_comm_group G] [add_torsor G P] (p1 : P) (p2 : P) (p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := sorry\n\n@[simp] theorem vadd_vsub_vadd_cancel_left {G : Type u_1} {P : Type u_2} [add_comm_group G] [add_torsor G P] (v : G) (p1 : P) (p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := sorry\n\ntheorem vsub_vadd_comm {G : Type u_1} {P : Type u_2} [add_comm_group G] [add_torsor G P] (p1 : P) (p2 : P) (p3 : P) : p1 -ᵥ p2 +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := sorry\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {G : Type u_1} {P : Type u_2} [add_comm_group G] [add_torsor G P] {v₁ : G} {v₂ : G} {p₁ : P} {p₂ : P} : v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂)) (propext vadd_eq_vadd_iff_neg_add_eq_vsub)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (-v₁ + v₂ = p₁ -ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂)) (neg_add_eq_sub v₁ v₂)))\n      (iff.refl (v₂ - v₁ = p₁ -ᵥ p₂)))\n\ntheorem vsub_sub_vsub_comm {G : Type u_1} {P : Type u_2} [add_comm_group G] [add_torsor G P] (p₁ : P) (p₂ : P) (p₃ : P) (p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := sorry\n\nnamespace prod\n\n\nprotected instance add_torsor {G : Type u_1} {P : Type u_2} {G' : Type u_3} {P' : Type u_4} [add_group G] [add_group G'] [add_torsor G P] [add_torsor G' P'] : add_torsor (G × G') (P × P') :=\n  add_torsor.mk (fun (v : G × G') (p : P × P') => (fst v +ᵥ fst p, snd v +ᵥ snd p)) sorry sorry\n    (fun (p₁ p₂ : P × P') => (fst p₁ -ᵥ fst p₂, snd p₁ -ᵥ snd p₂)) sorry sorry\n\n@[simp] theorem fst_vadd {G : Type u_1} {P : Type u_2} {G' : Type u_3} {P' : Type u_4} [add_group G] [add_group G'] [add_torsor G P] [add_torsor G' P'] (v : G × G') (p : P × P') : fst (v +ᵥ p) = fst v +ᵥ fst p :=\n  rfl\n\n@[simp] theorem snd_vadd {G : Type u_1} {P : Type u_2} {G' : Type u_3} {P' : Type u_4} [add_group G] [add_group G'] [add_torsor G P] [add_torsor G' P'] (v : G × G') (p : P × P') : snd (v +ᵥ p) = snd v +ᵥ snd p :=\n  rfl\n\n@[simp] theorem mk_vadd_mk {G : Type u_1} {P : Type u_2} {G' : Type u_3} {P' : Type u_4} [add_group G] [add_group G'] [add_torsor G P] [add_torsor G' P'] (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n  rfl\n\n@[simp] theorem fst_vsub {G : Type u_1} {P : Type u_2} {G' : Type u_3} {P' : Type u_4} [add_group G] [add_group G'] [add_torsor G P] [add_torsor G' P'] (p₁ : P × P') (p₂ : P × P') : fst (p₁ -ᵥ p₂) = fst p₁ -ᵥ fst p₂ :=\n  rfl\n\n@[simp] theorem snd_vsub {G : Type u_1} {P : Type u_2} {G' : Type u_3} {P' : Type u_4} [add_group G] [add_group G'] [add_torsor G P] [add_torsor G' P'] (p₁ : P × P') (p₂ : P × P') : snd (p₁ -ᵥ p₂) = snd p₁ -ᵥ snd p₂ :=\n  rfl\n\n@[simp] theorem mk_vsub_mk {G : Type u_1} {P : Type u_2} {G' : Type u_3} {P' : Type u_4} [add_group G] [add_group G'] [add_torsor G P] [add_torsor G' P'] (p₁ : P) (p₂ : P) (p₁' : P') (p₂' : P') : (p₁, p₁') -ᵥ (p₂, p₂') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n  rfl\n\nend prod\n\n\nnamespace pi\n\n\n/-- A product of `add_torsor`s is an `add_torsor`. -/\nprotected instance add_torsor {I : Type u} {fg : I → Type v} [(i : I) → add_group (fg i)] {fp : I → Type w} [T : (i : I) → add_torsor (fg i) (fp i)] : add_torsor ((i : I) → fg i) ((i : I) → fp i) :=\n  add_torsor.mk (fun (g : (i : I) → fg i) (p : (i : I) → fp i) (i : I) => g i +ᵥ p i) sorry sorry\n    (fun (p₁ p₂ : (i : I) → fp i) (i : I) => p₁ i -ᵥ p₂ i) sorry sorry\n\n/-- Addition in a product of `add_torsor`s. -/\n@[simp] theorem vadd_apply {I : Type u} {fg : I → Type v} [(i : I) → add_group (fg i)] {fp : I → Type w} [T : (i : I) → add_torsor (fg i) (fp i)] (x : (i : I) → fg i) (y : (i : I) → fp i) {i : I} : has_vadd.vadd x y i = x i +ᵥ y i :=\n  rfl\n\nend pi\n\n\nnamespace equiv\n\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vadd_const {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (p : P) : G ≃ P :=\n  mk (fun (v : G) => v +ᵥ p) (fun (p' : P) => p' -ᵥ p) sorry sorry\n\n@[simp] theorem coe_vadd_const {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (p : P) : ⇑(vadd_const p) = fun (v : G) => v +ᵥ p :=\n  rfl\n\n@[simp] theorem coe_vadd_const_symm {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (p : P) : ⇑(equiv.symm (vadd_const p)) = fun (p' : P) => p' -ᵥ p :=\n  rfl\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef const_vsub {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (p : P) : P ≃ G :=\n  mk (has_vsub.vsub p) (fun (v : G) => -v +ᵥ p) sorry sorry\n\n@[simp] theorem coe_const_vsub {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (p : P) : ⇑(const_vsub p) = has_vsub.vsub p :=\n  rfl\n\n@[simp] theorem coe_const_vsub_symm {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (p : P) : ⇑(equiv.symm (const_vsub p)) = fun (v : G) => -v +ᵥ p :=\n  rfl\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef const_vadd {G : Type u_1} (P : Type u_2) [add_group G] [add_torsor G P] (v : G) : perm P :=\n  mk (has_vadd.vadd v) (has_vadd.vadd (-v)) sorry sorry\n\n@[simp] theorem coe_const_vadd {G : Type u_1} (P : Type u_2) [add_group G] [add_torsor G P] (v : G) : ⇑(const_vadd P v) = has_vadd.vadd v :=\n  rfl\n\n@[simp] theorem const_vadd_zero (G : Type u_1) (P : Type u_2) [add_group G] [add_torsor G P] : const_vadd P 0 = 1 :=\n  ext (zero_vadd G)\n\n@[simp] theorem const_vadd_add {G : Type u_1} (P : Type u_2) [add_group G] [add_torsor G P] (v₁ : G) (v₂ : G) : const_vadd P (v₁ + v₂) = const_vadd P v₁ * const_vadd P v₂ :=\n  ext fun (p : P) => Eq.symm (vadd_assoc v₁ v₂ p)\n\n/-- `equiv.const_vadd` as a homomorphism from `multiplicative G` to `equiv.perm P` -/\ndef const_vadd_hom {G : Type u_1} (P : Type u_2) [add_group G] [add_torsor G P] : multiplicative G →* perm P :=\n  monoid_hom.mk (fun (v : multiplicative G) => const_vadd P (coe_fn multiplicative.to_add v)) (const_vadd_zero G P) sorry\n\n/-- Point reflection in `x` as a permutation. -/\ndef point_reflection {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (x : P) : perm P :=\n  equiv.trans (const_vsub x) (vadd_const x)\n\ntheorem point_reflection_apply {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (x : P) (y : P) : coe_fn (point_reflection x) y = x -ᵥ y +ᵥ x :=\n  rfl\n\n@[simp] theorem point_reflection_symm {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (x : P) : equiv.symm (point_reflection x) = point_reflection x := sorry\n\n@[simp] theorem point_reflection_self {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (x : P) : coe_fn (point_reflection x) x = x :=\n  vsub_vadd x x\n\ntheorem point_reflection_involutive {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] (x : P) : function.involutive ⇑(point_reflection x) := sorry\n\n/-- `x` is the only fixed point of `point_reflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem point_reflection_fixed_iff_of_injective_bit0 {G : Type u_1} {P : Type u_2} [add_group G] [add_torsor G P] {x : P} {y : P} (h : function.injective bit0) : coe_fn (point_reflection x) y = y ↔ y = x := sorry\n\ntheorem injective_point_reflection_left_of_injective_bit0 {G : Type u_1} {P : Type u_2} [add_comm_group G] [add_torsor G P] (h : function.injective bit0) (y : P) : function.injective fun (x : P) => coe_fn (point_reflection x) y := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/add_torsor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.49513825660558924}}
{"text": "open classical\n\nvariable p : Prop\n\nexample (h : ¬¬p) : p :=\n  by_cases\n    (assume h1 : p, h1)\n    (assume h1 : ¬p, absurd h1 h)\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0503.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.49513824424636743}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\n! This file was ported from Lean 3 source module ring_theory.polynomial.basic\n! leanprover-community/mathlib commit da420a8c6dd5bdfb85c4ced85c34388f633bc6ff\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.CharP.Basic\nimport Mathbin.Algebra.GeomSum\nimport Mathbin.Data.MvPolynomial.CommRing\nimport Mathbin.Data.MvPolynomial.Equiv\nimport Mathbin.RingTheory.Polynomial.Content\nimport Mathbin.RingTheory.UniqueFactorizationDomain\n\n/-!\n# Ring-theoretic supplement of data.polynomial.\n\n## Main results\n* `mv_polynomial.is_domain`:\n  If a ring is an integral domain, then so is its polynomial ring over finitely many variables.\n* `polynomial.is_noetherian_ring`:\n  Hilbert basis theorem, that if a ring is noetherian then so is its polynomial ring.\n* `polynomial.wf_dvd_monoid`:\n  If an integral domain is a `wf_dvd_monoid`, then so is its polynomial ring.\n* `polynomial.unique_factorization_monoid`, `mv_polynomial.unique_factorization_monoid`:\n  If an integral domain is a `unique_factorization_monoid`, then so is its polynomial ring (of any\n  number of variables).\n-/\n\n\nnoncomputable section\n\nopen Classical BigOperators Polynomial\n\nopen Finset\n\nuniverse u v w\n\nvariable {R : Type u} {S : Type _}\n\nnamespace Polynomial\n\nsection Semiring\n\nvariable [Semiring R]\n\ninstance (p : ℕ) [h : CharP R p] : CharP R[X] p :=\n  let ⟨h⟩ := h\n  ⟨fun n => by rw [← map_natCast C, ← C_0, C_inj, h]⟩\n\nvariable (R)\n\n#print Polynomial.degreeLe /-\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree ≤ `n`. -/\ndef degreeLe (n : WithBot ℕ) : Submodule R R[X] :=\n  ⨅ k : ℕ, ⨅ h : ↑k > n, (lcoeff R k).ker\n#align polynomial.degree_le Polynomial.degreeLe\n-/\n\n#print Polynomial.degreeLt /-\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degreeLt (n : ℕ) : Submodule R R[X] :=\n  ⨅ k : ℕ, ⨅ h : k ≥ n, (lcoeff R k).ker\n#align polynomial.degree_lt Polynomial.degreeLt\n-/\n\nvariable {R}\n\n#print Polynomial.mem_degreeLe /-\ntheorem mem_degreeLe {n : WithBot ℕ} {f : R[X]} : f ∈ degreeLe R n ↔ degree f ≤ n := by\n  simp only [degree_le, Submodule.mem_infᵢ, degree_le_iff_coeff_zero, LinearMap.mem_ker] <;> rfl\n#align polynomial.mem_degree_le Polynomial.mem_degreeLe\n-/\n\n/- warning: polynomial.degree_le_mono -> Polynomial.degreeLe_mono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {m : WithBot.{0} Nat} {n : WithBot.{0} Nat}, (LE.le.{0} (WithBot.{0} Nat) (Preorder.toLE.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))))) m n) -> (LE.le.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Preorder.toLE.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.partialOrder.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))))) (Polynomial.degreeLe.{u1} R _inst_1 m) (Polynomial.degreeLe.{u1} R _inst_1 n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {m : WithBot.{0} Nat} {n : WithBot.{0} Nat}, (LE.le.{0} (WithBot.{0} Nat) (Preorder.toLE.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)))) m n) -> (LE.le.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Preorder.toLE.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Submodule.completeLattice.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))))))) (Polynomial.degreeLe.{u1} R _inst_1 m) (Polynomial.degreeLe.{u1} R _inst_1 n))\nCase conversion may be inaccurate. Consider using '#align polynomial.degree_le_mono Polynomial.degreeLe_monoₓ'. -/\n@[mono]\ntheorem degreeLe_mono {m n : WithBot ℕ} (H : m ≤ n) : degreeLe R m ≤ degreeLe R n := fun f hf =>\n  mem_degreeLe.2 (le_trans (mem_degreeLe.1 hf) H)\n#align polynomial.degree_le_mono Polynomial.degreeLe_mono\n\n#print Polynomial.degreeLe_eq_span_X_pow /-\ntheorem degreeLe_eq_span_X_pow {n : ℕ} :\n    degreeLe R n = Submodule.span R ↑((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n) :=\n  by\n  apply le_antisymm\n  · intro p hp\n    replace hp := mem_degree_le.1 hp\n    rw [← Polynomial.sum_monomial_eq p, Polynomial.sum]\n    refine' Submodule.sum_mem _ fun k hk => _\n    show monomial _ _ ∈ _\n    have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk)\n    rw [← C_mul_X_pow_eq_monomial, C_mul']\n    refine'\n      Submodule.smul_mem _ _\n        (Submodule.subset_span <|\n          Finset.mem_coe.2 <|\n            Finset.mem_image.2 ⟨_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl⟩)\n  rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff]\n  intro k hk; apply mem_degree_le.2\n  exact\n    (degree_X_pow_le _).trans (WithBot.coe_le_coe.2 <| Nat.le_of_lt_succ <| Finset.mem_range.1 hk)\n#align polynomial.degree_le_eq_span_X_pow Polynomial.degreeLe_eq_span_X_pow\n-/\n\n#print Polynomial.mem_degreeLt /-\ntheorem mem_degreeLt {n : ℕ} {f : R[X]} : f ∈ degreeLt R n ↔ degree f < n :=\n  by\n  simp_rw [degree_lt, Submodule.mem_infᵢ, LinearMap.mem_ker, degree, Finset.max_eq_sup_coe,\n    Finset.sup_lt_iff (WithBot.bot_lt_coe n), mem_support_iff, WithBot.coe_lt_coe, lt_iff_not_le,\n    Ne, not_imp_not]\n  rfl\n#align polynomial.mem_degree_lt Polynomial.mem_degreeLt\n-/\n\n/- warning: polynomial.degree_lt_mono -> Polynomial.degreeLt_mono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (LE.le.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Preorder.toLE.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.partialOrder.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))))) (Polynomial.degreeLt.{u1} R _inst_1 m) (Polynomial.degreeLt.{u1} R _inst_1 n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (LE.le.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Preorder.toLE.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Submodule.completeLattice.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))))))) (Polynomial.degreeLt.{u1} R _inst_1 m) (Polynomial.degreeLt.{u1} R _inst_1 n))\nCase conversion may be inaccurate. Consider using '#align polynomial.degree_lt_mono Polynomial.degreeLt_monoₓ'. -/\n@[mono]\ntheorem degreeLt_mono {m n : ℕ} (H : m ≤ n) : degreeLt R m ≤ degreeLt R n := fun f hf =>\n  mem_degreeLt.2 (lt_of_lt_of_le (mem_degreeLt.1 hf) <| WithBot.coe_le_coe.2 H)\n#align polynomial.degree_lt_mono Polynomial.degreeLt_mono\n\n#print Polynomial.degreeLt_eq_span_X_pow /-\ntheorem degreeLt_eq_span_X_pow {n : ℕ} :\n    degreeLt R n = Submodule.span R ↑((Finset.range n).image fun n => X ^ n : Finset R[X]) :=\n  by\n  apply le_antisymm\n  · intro p hp\n    replace hp := mem_degree_lt.1 hp\n    rw [← Polynomial.sum_monomial_eq p, Polynomial.sum]\n    refine' Submodule.sum_mem _ fun k hk => _\n    show monomial _ _ ∈ _\n    have := WithBot.coe_lt_coe.1 ((Finset.sup_lt_iff <| WithBot.bot_lt_coe n).1 hp k hk)\n    rw [← C_mul_X_pow_eq_monomial, C_mul']\n    refine'\n      Submodule.smul_mem _ _\n        (Submodule.subset_span <|\n          Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 this, rfl⟩)\n  rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff]\n  intro k hk; apply mem_degree_lt.2\n  exact lt_of_le_of_lt (degree_X_pow_le _) (WithBot.coe_lt_coe.2 <| Finset.mem_range.1 hk)\n#align polynomial.degree_lt_eq_span_X_pow Polynomial.degreeLt_eq_span_X_pow\n-/\n\n#print Polynomial.degreeLtEquiv /-\n/-- The first `n` coefficients on `degree_lt n` form a linear equivalence with `fin n → R`. -/\ndef degreeLtEquiv (R) [Semiring R] (n : ℕ) : degreeLt R n ≃ₗ[R] Fin n → R\n    where\n  toFun p n := (↑p : R[X]).coeff n\n  invFun f :=\n    ⟨∑ i : Fin n, monomial i (f i),\n      (degreeLt R n).sum_mem fun i _ =>\n        mem_degreeLt.mpr\n          (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩\n  map_add' p q := by\n    ext\n    rw [Submodule.coe_add, coeff_add]\n    rfl\n  map_smul' x p := by\n    ext\n    rw [Submodule.coe_smul, coeff_smul]\n    rfl\n  left_inv := by\n    rintro ⟨p, hp⟩; ext1\n    simp only [Submodule.coe_mk]\n    by_cases hp0 : p = 0\n    · subst hp0\n      simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]\n    rw [mem_degree_lt, degree_eq_nat_degree hp0, WithBot.coe_lt_coe] at hp\n    conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range]\n  right_inv := by\n    intro f; ext i\n    simp only [finset_sum_coeff, Submodule.coe_mk]\n    rw [Finset.sum_eq_single i, coeff_monomial, if_pos rfl]\n    · rintro j - hji\n      rw [coeff_monomial, if_neg]\n      rwa [← Fin.ext_iff]\n    · intro h\n      exact (h (Finset.mem_univ _)).elim\n#align polynomial.degree_lt_equiv Polynomial.degreeLtEquiv\n-/\n\n/- warning: polynomial.degree_lt_equiv_eq_zero_iff_eq_zero -> Polynomial.degreeLtEquiv_eq_zero_iff_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {n : Nat} {p : Polynomial.{u1} R _inst_1} (hp : Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) p (Polynomial.degreeLt.{u1} R _inst_1 n)), Iff (Eq.{succ u1} ((Fin n) -> R) (coeFn.{succ u1, succ u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (ᾰ : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.Function.module.{0, u1, u1} (Fin n) R R _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toModule.{u1} R _inst_1))) (fun (_x : LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (ᾰ : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.Function.module.{0, u1, u1} (Fin n) R R _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toModule.{u1} R _inst_1))) => (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) -> (Fin n) -> R) (LinearEquiv.hasCoeToFun.{u1, u1, u1, u1} R R (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) ((Fin n) -> R) _inst_1 _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (ᾰ : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.Function.module.{0, u1, u1} (Fin n) R R _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1)) (Polynomial.degreeLtEquiv.{u1} R _inst_1 n) (Subtype.mk.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n)) p hp)) (OfNat.ofNat.{u1} ((Fin n) -> R) 0 (OfNat.mk.{u1} ((Fin n) -> R) 0 (Zero.zero.{u1} ((Fin n) -> R) (Pi.instZero.{0, u1} (Fin n) (fun (ᾰ : Fin n) => R) (fun (i : Fin n) => MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))))))) (Eq.{succ u1} (Polynomial.{u1} R _inst_1) p (OfNat.ofNat.{u1} (Polynomial.{u1} R _inst_1) 0 (OfNat.mk.{u1} (Polynomial.{u1} R _inst_1) 0 (Zero.zero.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.zero.{u1} R _inst_1)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {n : Nat} {p : Polynomial.{u1} R _inst_1} (hp : Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) p (Polynomial.degreeLt.{u1} R _inst_1 n)), Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) => (Fin n) -> R) (Subtype.mk.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n)) p hp)) (FunLike.coe.{succ u1, succ u1, succ u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (fun (_x : Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) => (Fin n) -> R) _x) (SMulHomClass.toFunLike.{u1, u1, u1, u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (SMulZeroClass.toSMul.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddMonoid.toZero.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddMonoid.toAddZeroClass.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)))) (DistribMulAction.toDistribSMul.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n))) (Module.toDistribMulAction.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)))))) (SMulZeroClass.toSMul.{u1, u1} R ((Fin n) -> R) (AddMonoid.toZero.{u1} ((Fin n) -> R) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))))) (DistribSMul.toSMulZeroClass.{u1, u1} R ((Fin n) -> R) (AddMonoid.toAddZeroClass.{u1} ((Fin n) -> R) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))))) (DistribMulAction.toDistribSMul.{u1, u1} R ((Fin n) -> R) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u1} R ((Fin n) -> R) _inst_1 (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)))))) (DistribMulActionHomClass.toSMulHomClass.{u1, u1, u1, u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n))) (Module.toDistribMulAction.{u1, u1} R ((Fin n) -> R) _inst_1 (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) (SemilinearMapClass.distribMulActionHomClass.{u1, u1, u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)) (SemilinearEquivClass.instSemilinearMapClass.{u1, u1, u1, u1, u1} R R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) _inst_1 _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u1, u1, u1, u1} R R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) _inst_1 _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1)))))) (Polynomial.degreeLtEquiv.{u1} R _inst_1 n) (Subtype.mk.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n)) p hp)) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) => (Fin n) -> R) (Subtype.mk.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n)) p hp)) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) => (Fin n) -> R) (Subtype.mk.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n)) p hp)) (Pi.instZero.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))))) (Eq.{succ u1} (Polynomial.{u1} R _inst_1) p (OfNat.ofNat.{u1} (Polynomial.{u1} R _inst_1) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.zero.{u1} R _inst_1))))\nCase conversion may be inaccurate. Consider using '#align polynomial.degree_lt_equiv_eq_zero_iff_eq_zero Polynomial.degreeLtEquiv_eq_zero_iff_eq_zeroₓ'. -/\n@[simp]\ntheorem degreeLtEquiv_eq_zero_iff_eq_zero {n : ℕ} {p : R[X]} (hp : p ∈ degreeLt R n) :\n    degreeLtEquiv _ _ ⟨p, hp⟩ = 0 ↔ p = 0 := by\n  rw [LinearEquiv.map_eq_zero_iff, Submodule.mk_eq_zero]\n#align polynomial.degree_lt_equiv_eq_zero_iff_eq_zero Polynomial.degreeLtEquiv_eq_zero_iff_eq_zero\n\n/- warning: polynomial.eval_eq_sum_degree_lt_equiv -> Polynomial.eval_eq_sum_degreeLtEquiv is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {n : Nat} {p : Polynomial.{u1} R _inst_1} (hp : Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) p (Polynomial.degreeLt.{u1} R _inst_1 n)) (x : R), Eq.{succ u1} R (Polynomial.eval.{u1} R _inst_1 x p) (Finset.sum.{u1, 0} R (Fin n) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Finset.univ.{0} (Fin n) (Fin.fintype n)) (fun (i : Fin n) => HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (ᾰ : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.Function.module.{0, u1, u1} (Fin n) R R _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toModule.{u1} R _inst_1))) (fun (_x : LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (ᾰ : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.Function.module.{0, u1, u1} (Fin n) R R _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toModule.{u1} R _inst_1))) => (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) -> (Fin n) -> R) (LinearEquiv.hasCoeToFun.{u1, u1, u1, u1} R R (coeSort.{succ u1, succ (succ u1)} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) (Polynomial.degreeLt.{u1} R _inst_1 n)) ((Fin n) -> R) _inst_1 _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (ᾰ : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.Function.module.{0, u1, u1} (Fin n) R R _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1)) (Polynomial.degreeLtEquiv.{u1} R _inst_1 n) (Subtype.mk.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n)) p hp) i) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) (Fin n) Nat (HasLiftT.mk.{1, 1} (Fin n) Nat (CoeTCₓ.coe.{1, 1} (Fin n) Nat (coeBase.{1, 1} (Fin n) Nat (Fin.coeToNat n)))) i))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {n : Nat} {p : Polynomial.{u1} R _inst_1} (hp : Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) p (Polynomial.degreeLt.{u1} R _inst_1 n)) (x : R), Eq.{succ u1} R (Polynomial.eval.{u1} R _inst_1 x p) (Finset.sum.{u1, 0} R (Fin n) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Finset.univ.{0} (Fin n) (Fin.fintype n)) (fun (i : Fin n) => HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (fun (_x : Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) => (Fin n) -> R) _x) (SMulHomClass.toFunLike.{u1, u1, u1, u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (SMulZeroClass.toSMul.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddMonoid.toZero.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddMonoid.toAddZeroClass.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)))) (DistribMulAction.toDistribSMul.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n))) (Module.toDistribMulAction.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)))))) (SMulZeroClass.toSMul.{u1, u1} R ((Fin n) -> R) (AddMonoid.toZero.{u1} ((Fin n) -> R) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))))) (DistribSMul.toSMulZeroClass.{u1, u1} R ((Fin n) -> R) (AddMonoid.toAddZeroClass.{u1} ((Fin n) -> R) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))))) (DistribMulAction.toDistribSMul.{u1, u1} R ((Fin n) -> R) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u1} R ((Fin n) -> R) _inst_1 (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)))))) (DistribMulActionHomClass.toSMulHomClass.{u1, u1, u1, u1} (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n))) (AddCommMonoid.toAddMonoid.{u1} ((Fin n) -> R) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n))) (Module.toDistribMulAction.{u1, u1} R ((Fin n) -> R) _inst_1 (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) (SemilinearMapClass.distribMulActionHomClass.{u1, u1, u1, u1} R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)) (SemilinearEquivClass.instSemilinearMapClass.{u1, u1, u1, u1, u1} R R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (LinearEquiv.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1))) _inst_1 _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u1, u1, u1, u1} R R (Subtype.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n))) ((Fin n) -> R) _inst_1 _inst_1 (Submodule.addCommMonoid.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.addCommMonoid.{0, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (Submodule.module.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (Polynomial.degreeLt.{u1} R _inst_1 n)) (Pi.module.{0, u1, u1} (Fin n) (fun (a._@.Mathlib.RingTheory.Polynomial.Basic._hyg.1130 : Fin n) => R) R _inst_1 (fun (i : Fin n) => NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (fun (i : Fin n) => Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1)))))) (Polynomial.degreeLtEquiv.{u1} R _inst_1 n) (Subtype.mk.{succ u1} (Polynomial.{u1} R _inst_1) (fun (x : Polynomial.{u1} R _inst_1) => Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R _inst_1) _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)))) x (Polynomial.degreeLt.{u1} R _inst_1 n)) p hp) i) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) x (Fin.val n i))))\nCase conversion may be inaccurate. Consider using '#align polynomial.eval_eq_sum_degree_lt_equiv Polynomial.eval_eq_sum_degreeLtEquivₓ'. -/\ntheorem eval_eq_sum_degreeLtEquiv {n : ℕ} {p : R[X]} (hp : p ∈ degreeLt R n) (x : R) :\n    p.eval x = ∑ i, degreeLtEquiv _ _ ⟨p, hp⟩ i * x ^ (i : ℕ) :=\n  by\n  simp_rw [eval_eq_sum]\n  exact (sum_fin _ (by simp_rw [MulZeroClass.zero_mul, forall_const]) (mem_degree_lt.mp hp)).symm\n#align polynomial.eval_eq_sum_degree_lt_equiv Polynomial.eval_eq_sum_degreeLtEquiv\n\n#print Polynomial.frange /-\n/-- The finset of nonzero coefficients of a polynomial. -/\ndef frange (p : R[X]) : Finset R :=\n  Finset.image (fun n => p.coeff n) p.support\n#align polynomial.frange Polynomial.frange\n-/\n\n#print Polynomial.frange_zero /-\ntheorem frange_zero : frange (0 : R[X]) = ∅ :=\n  rfl\n#align polynomial.frange_zero Polynomial.frange_zero\n-/\n\n/- warning: polynomial.mem_frange_iff -> Polynomial.mem_frange_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {p : Polynomial.{u1} R _inst_1} {c : R}, Iff (Membership.Mem.{u1, u1} R (Finset.{u1} R) (Finset.hasMem.{u1} R) c (Polynomial.frange.{u1} R _inst_1 p)) (Exists.{1} Nat (fun (n : Nat) => Exists.{0} (Membership.Mem.{0, 0} Nat (Finset.{0} Nat) (Finset.hasMem.{0} Nat) n (Polynomial.support.{u1} R _inst_1 p)) (fun (H : Membership.Mem.{0, 0} Nat (Finset.{0} Nat) (Finset.hasMem.{0} Nat) n (Polynomial.support.{u1} R _inst_1 p)) => Eq.{succ u1} R c (Polynomial.coeff.{u1} R _inst_1 p n))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {p : Polynomial.{u1} R _inst_1} {c : R}, Iff (Membership.mem.{u1, u1} R (Finset.{u1} R) (Finset.instMembershipFinset.{u1} R) c (Polynomial.frange.{u1} R _inst_1 p)) (Exists.{1} Nat (fun (n : Nat) => And (Membership.mem.{0, 0} Nat (Finset.{0} Nat) (Finset.instMembershipFinset.{0} Nat) n (Polynomial.support.{u1} R _inst_1 p)) (Eq.{succ u1} R c (Polynomial.coeff.{u1} R _inst_1 p n))))\nCase conversion may be inaccurate. Consider using '#align polynomial.mem_frange_iff Polynomial.mem_frange_iffₓ'. -/\ntheorem mem_frange_iff {p : R[X]} {c : R} : c ∈ p.frange ↔ ∃ n ∈ p.support, c = p.coeff n := by\n  simp [frange, eq_comm]\n#align polynomial.mem_frange_iff Polynomial.mem_frange_iff\n\n#print Polynomial.frange_one /-\ntheorem frange_one : frange (1 : R[X]) ⊆ {1} :=\n  by\n  simp [frange, Finset.image_subset_iff]\n  simp only [← C_1, coeff_C]\n  intro n hn\n  simp only [exists_prop, ite_eq_right_iff, not_forall] at hn\n  simp [hn]\n#align polynomial.frange_one Polynomial.frange_one\n-/\n\n/- warning: polynomial.coeff_mem_frange -> Polynomial.coeff_mem_frange is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] (p : Polynomial.{u1} R _inst_1) (n : Nat), (Ne.{succ u1} R (Polynomial.coeff.{u1} R _inst_1 p n) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))))))) -> (Membership.Mem.{u1, u1} R (Finset.{u1} R) (Finset.hasMem.{u1} R) (Polynomial.coeff.{u1} R _inst_1 p n) (Polynomial.frange.{u1} R _inst_1 p))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] (p : Polynomial.{u1} R _inst_1) (n : Nat), (Ne.{succ u1} R (Polynomial.coeff.{u1} R _inst_1 p n) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1))))) -> (Membership.mem.{u1, u1} R (Finset.{u1} R) (Finset.instMembershipFinset.{u1} R) (Polynomial.coeff.{u1} R _inst_1 p n) (Polynomial.frange.{u1} R _inst_1 p))\nCase conversion may be inaccurate. Consider using '#align polynomial.coeff_mem_frange Polynomial.coeff_mem_frangeₓ'. -/\ntheorem coeff_mem_frange (p : R[X]) (n : ℕ) (h : p.coeff n ≠ 0) : p.coeff n ∈ p.frange :=\n  by\n  simp only [frange, exists_prop, mem_support_iff, Finset.mem_image, Ne.def]\n  exact ⟨n, h, rfl⟩\n#align polynomial.coeff_mem_frange Polynomial.coeff_mem_frange\n\n#print Polynomial.geom_sum_X_comp_X_add_one_eq_sum /-\ntheorem geom_sum_X_comp_X_add_one_eq_sum (n : ℕ) :\n    (∑ i in range n, (X : R[X]) ^ i).comp (X + 1) =\n      (Finset.range n).Sum fun i : ℕ => (n.choose (i + 1) : R[X]) * X ^ i :=\n  by\n  ext i\n  trans (n.choose (i + 1) : R); swap\n  · simp only [finset_sum_coeff, ← C_eq_nat_cast, coeff_C_mul_X_pow]\n    rw [Finset.sum_eq_single i, if_pos rfl]\n    ·\n      simp (config := { contextual := true }) only [@eq_comm _ i, if_false, eq_self_iff_true,\n        imp_true_iff]\n    ·\n      simp (config := { contextual := true }) only [Nat.lt_add_one_iff, Nat.choose_eq_zero_of_lt,\n        Nat.cast_zero, Finset.mem_range, not_lt, eq_self_iff_true, if_true, imp_true_iff]\n  induction' n with n ih generalizing i\n  · simp only [geom_sum_zero, zero_comp, coeff_zero, Nat.choose_zero_succ, Nat.cast_zero]\n  simp only [geom_sum_succ', ih, add_comp, X_pow_comp, coeff_add, Nat.choose_succ_succ,\n    Nat.cast_add, coeff_X_add_one_pow]\n#align polynomial.geom_sum_X_comp_X_add_one_eq_sum Polynomial.geom_sum_X_comp_X_add_one_eq_sum\n-/\n\n#print Polynomial.Monic.geom_sum /-\ntheorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :\n    (∑ i in range n, P ^ i).Monic := by\n  nontriviality R\n  cases n; · exact (hn rfl).elim\n  rw [geom_sum_succ']\n  refine' (hP.pow _).add_of_left _\n  refine' lt_of_le_of_lt (degree_sum_le _ _) _\n  rw [Finset.sup_lt_iff]\n  · simp only [Finset.mem_range, degree_eq_nat_degree (hP.pow _).NeZero, WithBot.coe_lt_coe,\n      hP.nat_degree_pow]\n    intro k\n    exact nsmul_lt_nsmul hdeg\n  · rw [bot_lt_iff_ne_bot, Ne.def, degree_eq_bot]\n    exact (hP.pow _).NeZero\n#align polynomial.monic.geom_sum Polynomial.Monic.geom_sum\n-/\n\n#print Polynomial.Monic.geom_sum' /-\ntheorem Monic.geom_sum' {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.degree) {n : ℕ} (hn : n ≠ 0) :\n    (∑ i in range n, P ^ i).Monic :=\n  hP.geom_sum (natDegree_pos_iff_degree_pos.2 hdeg) hn\n#align polynomial.monic.geom_sum' Polynomial.Monic.geom_sum'\n-/\n\n#print Polynomial.monic_geom_sum_X /-\ntheorem monic_geom_sum_X {n : ℕ} (hn : n ≠ 0) : (∑ i in range n, (X : R[X]) ^ i).Monic :=\n  by\n  nontriviality R\n  apply monic_X.geom_sum _ hn\n  simpa only [nat_degree_X] using zero_lt_one\n#align polynomial.monic_geom_sum_X Polynomial.monic_geom_sum_X\n-/\n\nend Semiring\n\nsection Ring\n\nvariable [Ring R]\n\n/- warning: polynomial.restriction -> Polynomial.restriction is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)), Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)), Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))))\nCase conversion may be inaccurate. Consider using '#align polynomial.restriction Polynomial.restrictionₓ'. -/\n/-- Given a polynomial, return the polynomial whose coefficients are in\nthe ring closure of the original coefficients. -/\ndef restriction (p : R[X]) : Polynomial (Subring.closure (↑p.frange : Set R)) :=\n  ∑ i in p.support,\n    monomial i\n      (⟨p.coeff i,\n          if H : p.coeff i = 0 then H.symm ▸ (Subring.closure _).zero_mem\n          else Subring.subset_closure (p.coeff_mem_frange _ H)⟩ :\n        Subring.closure (↑p.frange : Set R))\n#align polynomial.restriction Polynomial.restriction\n\n#print Polynomial.coeff_restriction /-\n@[simp]\ntheorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n :=\n  by\n  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',\n    Ne.def, ite_not]\n  split_ifs\n  · rw [h]\n    rfl\n  · rfl\n#align polynomial.coeff_restriction Polynomial.coeff_restriction\n-/\n\n#print Polynomial.coeff_restriction' /-\n@[simp]\ntheorem coeff_restriction' {p : R[X]} {n : ℕ} : (coeff (restriction p) n).1 = coeff p n :=\n  coeff_restriction\n#align polynomial.coeff_restriction' Polynomial.coeff_restriction'\n-/\n\n#print Polynomial.support_restriction /-\n@[simp]\ntheorem support_restriction (p : R[X]) : support (restriction p) = support p :=\n  by\n  ext i\n  simp only [mem_support_iff, not_iff_not, Ne.def]\n  conv_rhs => rw [← coeff_restriction]\n  exact\n    ⟨fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H⟩\n#align polynomial.support_restriction Polynomial.support_restriction\n-/\n\n/- warning: polynomial.map_restriction -> Polynomial.map_restriction is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_2 : CommRing.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2))), Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2))) (Polynomial.map.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.setLike.{u1} R (CommRing.toRing.{u1} R _inst_2))) (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p)))) R (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.setLike.{u1} R (CommRing.toRing.{u1} R _inst_2))) (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p)))) (Subring.toRing.{u1} R (CommRing.toRing.{u1} R _inst_2) (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (algebraMap.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.setLike.{u1} R (CommRing.toRing.{u1} R _inst_2))) (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p)))) R (SubsemiringClass.toCommSemiring.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))) R (CommRing.toCommSemiring.{u1} R _inst_2) (Subring.setLike.{u1} R (CommRing.toRing.{u1} R _inst_2)) (SubringClass.to_subsemiringClass.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (CommRing.toRing.{u1} R _inst_2) (Subring.setLike.{u1} R (CommRing.toRing.{u1} R _inst_2)) (Subring.subringClass.{u1} R (CommRing.toRing.{u1} R _inst_2)))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (Algebra.ofSubring.{u1, u1} R R _inst_2 (CommRing.toRing.{u1} R _inst_2) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_2)) (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) (Polynomial.restriction.{u1} R (CommRing.toRing.{u1} R _inst_2) p)) p\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_2 : CommRing.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2))), Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2))) (Polynomial.map.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (SetLike.instMembership.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.instSetLikeSubring.{u1} R (CommRing.toRing.{u1} R _inst_2))) x (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) R (CommSemiring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (SetLike.instMembership.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.instSetLikeSubring.{u1} R (CommRing.toRing.{u1} R _inst_2))) x (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) (CommRing.toCommSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (SetLike.instMembership.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.instSetLikeSubring.{u1} R (CommRing.toRing.{u1} R _inst_2))) x (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) (Subring.toCommRing.{u1} R _inst_2 (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p)))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (algebraMap.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (SetLike.instMembership.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.instSetLikeSubring.{u1} R (CommRing.toRing.{u1} R _inst_2))) x (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) R (CommRing.toCommSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (SetLike.instMembership.{u1, u1} (Subring.{u1} R (CommRing.toRing.{u1} R _inst_2)) R (Subring.instSetLikeSubring.{u1} R (CommRing.toRing.{u1} R _inst_2))) x (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) (Subring.toCommRing.{u1} R _inst_2 (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) (Algebra.ofSubring.{u1, u1} R R _inst_2 (CommRing.toRing.{u1} R _inst_2) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_2)) (Subring.closure.{u1} R (CommRing.toRing.{u1} R _inst_2) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_2)) p))))) (Polynomial.restriction.{u1} R (CommRing.toRing.{u1} R _inst_2) p)) p\nCase conversion may be inaccurate. Consider using '#align polynomial.map_restriction Polynomial.map_restrictionₓ'. -/\n@[simp]\ntheorem map_restriction {R : Type u} [CommRing R] (p : R[X]) :\n    p.restriction.map (algebraMap _ _) = p :=\n  ext fun n => by rw [coeff_map, Algebra.algebraMap_ofSubring_apply, coeff_restriction]\n#align polynomial.map_restriction Polynomial.map_restriction\n\n#print Polynomial.degree_restriction /-\n@[simp]\ntheorem degree_restriction {p : R[X]} : (restriction p).degree = p.degree := by simp [degree]\n#align polynomial.degree_restriction Polynomial.degree_restriction\n-/\n\n#print Polynomial.natDegree_restriction /-\n@[simp]\ntheorem natDegree_restriction {p : R[X]} : (restriction p).natDegree = p.natDegree := by\n  simp [nat_degree]\n#align polynomial.nat_degree_restriction Polynomial.natDegree_restriction\n-/\n\n/- warning: polynomial.monic_restriction -> Polynomial.monic_restriction is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)}, Iff (Polynomial.Monic.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) (Polynomial.restriction.{u1} R _inst_1 p)) (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)}, Iff (Polynomial.Monic.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) (Polynomial.restriction.{u1} R _inst_1 p)) (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nCase conversion may be inaccurate. Consider using '#align polynomial.monic_restriction Polynomial.monic_restrictionₓ'. -/\n@[simp]\ntheorem monic_restriction {p : R[X]} : Monic (restriction p) ↔ Monic p :=\n  by\n  simp only [monic, leading_coeff, nat_degree_restriction]\n  rw [← @coeff_restriction _ _ p]\n  exact\n    ⟨fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H⟩\n#align polynomial.monic_restriction Polynomial.monic_restriction\n\n/- warning: polynomial.restriction_zero -> Polynomial.restriction_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R], Eq.{succ u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))))) (Polynomial.restriction.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) 0 (OfNat.mk.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) 0 (Zero.zero.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Polynomial.zero.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R], Eq.{succ u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))))) (Polynomial.restriction.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))))) (Polynomial.zero.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))))))\nCase conversion may be inaccurate. Consider using '#align polynomial.restriction_zero Polynomial.restriction_zeroₓ'. -/\n@[simp]\ntheorem restriction_zero : restriction (0 : R[X]) = 0 := by\n  simp only [restriction, Finset.sum_empty, support_zero]\n#align polynomial.restriction_zero Polynomial.restriction_zero\n\n/- warning: polynomial.restriction_one -> Polynomial.restriction_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R], Eq.{succ u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))))) (Polynomial.restriction.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) 1 (OfNat.mk.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) 1 (One.one.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Polynomial.hasOne.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R], Eq.{succ u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))))) (Polynomial.restriction.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))))) 1 (One.toOfNat1.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))))) (Polynomial.one.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))))))\nCase conversion may be inaccurate. Consider using '#align polynomial.restriction_one Polynomial.restriction_oneₓ'. -/\n@[simp]\ntheorem restriction_one : restriction (1 : R[X]) = 1 :=\n  ext fun i => Subtype.eq <| by rw [coeff_restriction', coeff_one, coeff_one] <;> split_ifs <;> rfl\n#align polynomial.restriction_one Polynomial.restriction_one\n\nvariable [Semiring S] {f : R →+* S} {x : S}\n\n/- warning: polynomial.eval₂_restriction -> Polynomial.eval₂_restriction is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : Semiring.{u2} S] {f : RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)} {x : S} {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)}, Eq.{succ u2} S (Polynomial.eval₂.{u1, u2} R S (Ring.toSemiring.{u1} R _inst_1) _inst_2 f x p) (Polynomial.eval₂.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) S (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) _inst_2 (RingHom.comp.{u1, u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) R S (Semiring.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))) (Subring.toRing.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)))))) (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2) f (Subring.subtype.{u1} R _inst_1 (Subring.closure.{u1} R _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p))))) x (Polynomial.restriction.{u1} R _inst_1 p))\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : Semiring.{u1} S] {f : RingHom.{u2, u1} R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S _inst_2)} {x : S} {p : Polynomial.{u2} R (Ring.toSemiring.{u2} R _inst_1)}, Eq.{succ u1} S (Polynomial.eval₂.{u2, u1} R S (Ring.toSemiring.{u2} R _inst_1) _inst_2 f x p) (Polynomial.eval₂.{u2, u1} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u2} R (Subring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subring.{u2} R _inst_1) R (Subring.instSetLikeSubring.{u2} R _inst_1)) x (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p))))) S (Ring.toSemiring.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u2} R (Subring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subring.{u2} R _inst_1) R (Subring.instSetLikeSubring.{u2} R _inst_1)) x (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p))))) (Subring.toRing.{u2} R _inst_1 (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p))))) _inst_2 (RingHom.comp.{u2, u2, u1} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u2} R (Subring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subring.{u2} R _inst_1) R (Subring.instSetLikeSubring.{u2} R _inst_1)) x (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p))))) R S (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u2} R (Subring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subring.{u2} R _inst_1) R (Subring.instSetLikeSubring.{u2} R _inst_1)) x (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p))))) (Ring.toSemiring.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u2} R (Subring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subring.{u2} R _inst_1) R (Subring.instSetLikeSubring.{u2} R _inst_1)) x (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p))))) (Subring.toRing.{u2} R _inst_1 (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p)))))) (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S _inst_2) f (Subring.subtype.{u2} R _inst_1 (Subring.closure.{u2} R _inst_1 (Finset.toSet.{u2} R (Polynomial.frange.{u2} R (Ring.toSemiring.{u2} R _inst_1) p))))) x (Polynomial.restriction.{u2} R _inst_1 p))\nCase conversion may be inaccurate. Consider using '#align polynomial.eval₂_restriction Polynomial.eval₂_restrictionₓ'. -/\ntheorem eval₂_restriction {p : R[X]} :\n    eval₂ f x p =\n      eval₂ (f.comp (Subring.subtype (Subring.closure (p.frange : Set R)))) x p.restriction :=\n  by\n  simp only [eval₂_eq_sum, Sum, support_restriction, ← @coeff_restriction _ _ p]\n  rfl\n#align polynomial.eval₂_restriction Polynomial.eval₂_restriction\n\nsection ToSubring\n\nvariable (p : R[X]) (T : Subring R)\n\n/- warning: polynomial.to_subring -> Polynomial.toSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1), (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) -> (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1), (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) -> (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)))\nCase conversion may be inaccurate. Consider using '#align polynomial.to_subring Polynomial.toSubringₓ'. -/\n/-- Given a polynomial `p` and a subring `T` that contains the coefficients of `p`,\nreturn the corresponding polynomial whose coefficients are in `T`. -/\ndef toSubring (hp : (↑p.frange : Set R) ⊆ T) : T[X] :=\n  ∑ i in p.support,\n    monomial i\n      (⟨p.coeff i, if H : p.coeff i = 0 then H.symm ▸ T.zero_mem else hp (p.coeff_mem_frange _ H)⟩ :\n        T)\n#align polynomial.to_subring Polynomial.toSubring\n\nvariable (hp : (↑p.frange : Set R) ⊆ T)\n\ninclude hp\n\n/- warning: polynomial.coeff_to_subring -> Polynomial.coeff_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) {n : Nat}, Eq.{succ u1} R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) x T))))) (Polynomial.coeff.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp) n)) (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R _inst_1) p n)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) {n : Nat}, Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) (Polynomial.coeff.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp) n)) (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R _inst_1) p n)\nCase conversion may be inaccurate. Consider using '#align polynomial.coeff_to_subring Polynomial.coeff_toSubringₓ'. -/\n@[simp]\ntheorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n :=\n  by\n  simp only [to_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',\n    Ne.def, ite_not]\n  split_ifs\n  · rw [h]\n    rfl\n  · rfl\n#align polynomial.coeff_to_subring Polynomial.coeff_toSubring\n\n/- warning: polynomial.coeff_to_subring' -> Polynomial.coeff_to_subring' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) {n : Nat}, Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) x T) (Polynomial.coeff.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp) n)) (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R _inst_1) p n)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) {n : Nat}, Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T) (Polynomial.coeff.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp) n)) (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R _inst_1) p n)\nCase conversion may be inaccurate. Consider using '#align polynomial.coeff_to_subring' Polynomial.coeff_to_subring'ₓ'. -/\n@[simp]\ntheorem coeff_to_subring' {n : ℕ} : (coeff (toSubring p T hp) n).1 = coeff p n :=\n  coeff_toSubring _ _ hp\n#align polynomial.coeff_to_subring' Polynomial.coeff_to_subring'\n\n/- warning: polynomial.support_to_subring -> Polynomial.support_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)), Eq.{1} (Finset.{0} Nat) (Polynomial.support.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.support.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)), Eq.{1} (Finset.{0} Nat) (Polynomial.support.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.support.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nCase conversion may be inaccurate. Consider using '#align polynomial.support_to_subring Polynomial.support_toSubringₓ'. -/\n@[simp]\ntheorem support_toSubring : support (toSubring p T hp) = support p :=\n  by\n  ext i\n  simp only [mem_support_iff, not_iff_not, Ne.def]\n  conv_rhs => rw [← coeff_to_subring p T hp]\n  exact\n    ⟨fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H⟩\n#align polynomial.support_to_subring Polynomial.support_toSubring\n\n/- warning: polynomial.degree_to_subring -> Polynomial.degree_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)), Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)), Eq.{1} (WithBot.{0} Nat) (Polynomial.degree.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nCase conversion may be inaccurate. Consider using '#align polynomial.degree_to_subring Polynomial.degree_toSubringₓ'. -/\n@[simp]\ntheorem degree_toSubring : (toSubring p T hp).degree = p.degree := by simp [degree]\n#align polynomial.degree_to_subring Polynomial.degree_toSubring\n\n/- warning: polynomial.nat_degree_to_subring -> Polynomial.natDegree_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)), Eq.{1} Nat (Polynomial.natDegree.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.natDegree.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)), Eq.{1} Nat (Polynomial.natDegree.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.natDegree.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nCase conversion may be inaccurate. Consider using '#align polynomial.nat_degree_to_subring Polynomial.natDegree_toSubringₓ'. -/\n@[simp]\ntheorem natDegree_toSubring : (toSubring p T hp).natDegree = p.natDegree := by simp [nat_degree]\n#align polynomial.nat_degree_to_subring Polynomial.natDegree_toSubring\n\n/- warning: polynomial.monic_to_subring -> Polynomial.monic_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)), Iff (Polynomial.Monic.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)), Iff (Polynomial.Monic.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)\nCase conversion may be inaccurate. Consider using '#align polynomial.monic_to_subring Polynomial.monic_toSubringₓ'. -/\n@[simp]\ntheorem monic_toSubring : Monic (toSubring p T hp) ↔ Monic p :=\n  by\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, ← coeff_to_subring p T hp]\n  exact\n    ⟨fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H⟩\n#align polynomial.monic_to_subring Polynomial.monic_toSubring\n\nomit hp\n\n/- warning: polynomial.to_subring_zero -> Polynomial.toSubring_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1), Eq.{succ u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.toSubring.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) T (Eq.mpr.{0} (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) True (id_tag Tactic.IdTag.simp (Eq.{1} Prop (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) True) (Eq.trans.{1} Prop (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) (EmptyCollection.emptyCollection.{u1} (Set.{u1} R) (Set.hasEmptyc.{u1} R)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) True ((fun [self : HasSubset.{u1} (Set.{u1} R)] (ᾰ : Set.{u1} R) (ᾰ_1 : Set.{u1} R) (e_2 : Eq.{succ u1} (Set.{u1} R) ᾰ ᾰ_1) (ᾰ_2 : Set.{u1} R) (ᾰ_3 : Set.{u1} R) (e_3 : Eq.{succ u1} (Set.{u1} R) ᾰ_2 ᾰ_3) => congr.{succ u1, 1} (Set.{u1} R) Prop (HasSubset.Subset.{u1} (Set.{u1} R) self ᾰ) (HasSubset.Subset.{u1} (Set.{u1} R) self ᾰ_1) ᾰ_2 ᾰ_3 (congr_arg.{succ u1, succ u1} (Set.{u1} R) ((Set.{u1} R) -> Prop) ᾰ ᾰ_1 (HasSubset.Subset.{u1} (Set.{u1} R) self) e_2) e_3) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (EmptyCollection.emptyCollection.{u1} (Set.{u1} R) (Set.hasEmptyc.{u1} R)) (Eq.trans.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} R) (Finset.hasEmptyc.{u1} R))) (EmptyCollection.emptyCollection.{u1} (Set.{u1} R) (Set.hasEmptyc.{u1} R)) ((fun [_inst_1 : HasLiftT.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R)] (ᾰ : Finset.{u1} R) (ᾰ_1 : Finset.{u1} R) (e_2 : Eq.{succ u1} (Finset.{u1} R) ᾰ ᾰ_1) => congr_arg.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) ᾰ ᾰ_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) _inst_1) e_2) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} R) (Finset.hasEmptyc.{u1} R)) (Polynomial.frange_zero.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (Finset.coe_empty.{u1} R)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T) (rfl.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T))) (propext (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) (EmptyCollection.emptyCollection.{u1} (Set.{u1} R) (Set.hasEmptyc.{u1} R)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) True ((fun {α : Type.{u1}} (s : Set.{u1} α) => iff_true_intro (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α)) s) (Set.empty_subset.{u1} α s)) R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T))))) trivial)) (OfNat.ofNat.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) 0 (OfNat.mk.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) 0 (Zero.zero.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.zero.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1), Eq.{succ u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.toSubring.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) T (of_eq_true (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (EmptyCollection.emptyCollection.{u1} (Finset.{u1} R) (Finset.instEmptyCollectionFinset.{u1} R))) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) (Eq.trans.{1} Prop (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (EmptyCollection.emptyCollection.{u1} (Finset.{u1} R) (Finset.instEmptyCollectionFinset.{u1} R))) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (EmptyCollection.emptyCollection.{u1} (Set.{u1} R) (Set.instEmptyCollectionSet.{u1} R)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) True (congrFun.{succ u1, 1} (Set.{u1} R) (fun (a._@.Std.Classes.SetNotation._hyg.7 : Set.{u1} R) => Prop) (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (EmptyCollection.emptyCollection.{u1} (Finset.{u1} R) (Finset.instEmptyCollectionFinset.{u1} R)))) (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (EmptyCollection.emptyCollection.{u1} (Set.{u1} R) (Set.instEmptyCollectionSet.{u1} R))) (congrArg.{succ u1, succ u1} (Set.{u1} R) ((Set.{u1} R) -> Prop) (Finset.toSet.{u1} R (EmptyCollection.emptyCollection.{u1} (Finset.{u1} R) (Finset.instEmptyCollectionFinset.{u1} R))) (EmptyCollection.emptyCollection.{u1} (Set.{u1} R) (Set.instEmptyCollectionSet.{u1} R)) (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R)) (Finset.coe_empty.{u1} R)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) (Mathlib.Data.Set.Basic._auxLemma.9.{u1} R (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T))))) (OfNat.ofNat.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.zero.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)))))\nCase conversion may be inaccurate. Consider using '#align polynomial.to_subring_zero Polynomial.toSubring_zeroₓ'. -/\n@[simp]\ntheorem toSubring_zero : toSubring (0 : R[X]) T (by simp [frange_zero]) = 0 :=\n  by\n  ext i\n  simp\n#align polynomial.to_subring_zero Polynomial.toSubring_zero\n\n/- warning: polynomial.to_subring_one -> Polynomial.toSubring_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1), Eq.{succ u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.toSubring.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) T (Set.Subset.trans.{u1} R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.one.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.hasOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (fun (x : R) => Membership.Mem.{u1, u1} R (Multiset.{u1} R) (Multiset.hasMem.{u1} R) x (Finset.val.{u1} R (Singleton.singleton.{u1, u1} R (Finset.{u1} R) (Finset.hasSingleton.{u1} R) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T) (Polynomial.frange_one.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Iff.mpr (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Singleton.singleton.{u1, u1} R (Finset.{u1} R) (Finset.hasSingleton.{u1} R) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)) (Finset.singleton_subset_set_iff.{u1} R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))))) (Subring.one_mem.{u1} R _inst_1 T)))) (OfNat.ofNat.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) 1 (OfNat.mk.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) 1 (One.one.{u1} (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.hasOne.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1), Eq.{succ u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.toSubring.{u1} R _inst_1 (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) T (Set.Subset.trans.{u1} R (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) 1 (One.toOfNat1.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.one.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) (fun (x : R) => Membership.mem.{u1, u1} R (Multiset.{u1} R) (Multiset.instMembershipMultiset.{u1} R) x (Finset.val.{u1} R (Singleton.singleton.{u1, u1} R (Finset.{u1} R) (Finset.instSingletonFinset.{u1} R) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T) (Polynomial.frange_one.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Iff.mpr (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Singleton.singleton.{u1, u1} R (Finset.{u1} R) (Finset.instSingletonFinset.{u1} R) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) (Finset.singleton_subset_set_iff.{u1} R (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (Subring.one_mem.{u1} R _inst_1 T)))) (OfNat.ofNat.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) 1 (One.toOfNat1.{u1} (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) (Polynomial.one.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)))))\nCase conversion may be inaccurate. Consider using '#align polynomial.to_subring_one Polynomial.toSubring_oneₓ'. -/\n@[simp]\ntheorem toSubring_one :\n    toSubring (1 : R[X]) T\n        (Set.Subset.trans frange_one <| Finset.singleton_subset_set_iff.2 T.one_mem) =\n      1 :=\n  ext fun i => Subtype.eq <| by rw [coeff_to_subring', coeff_one, coeff_one] <;> split_ifs <;> rfl\n#align polynomial.to_subring_one Polynomial.toSubring_one\n\n/- warning: polynomial.map_to_subring -> Polynomial.map_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)), Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.map.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) (Ring.toSemiring.{u1} R _inst_1) (Subring.subtype.{u1} R _inst_1 T) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) p\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (T : Subring.{u1} R _inst_1) (hp : HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) p)) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)), Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.map.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) R (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) (Ring.toSemiring.{u1} R _inst_1) (Subring.subtype.{u1} R _inst_1 T) (Polynomial.toSubring.{u1} R _inst_1 p T hp)) p\nCase conversion may be inaccurate. Consider using '#align polynomial.map_to_subring Polynomial.map_toSubringₓ'. -/\n@[simp]\ntheorem map_toSubring : (p.toSubring T hp).map (Subring.subtype T) = p :=\n  by\n  ext n\n  simp [coeff_map]\n#align polynomial.map_to_subring Polynomial.map_toSubring\n\nend ToSubring\n\nvariable (T : Subring R)\n\n/- warning: polynomial.of_subring -> Polynomial.ofSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1), (Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1), (Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align polynomial.of_subring Polynomial.ofSubringₓ'. -/\n/-- Given a polynomial whose coefficients are in some subring, return\nthe corresponding polynomial whose coefficients are in the ambient ring. -/\ndef ofSubring (p : T[X]) : R[X] :=\n  ∑ i in p.support, monomial i (p.coeff i : R)\n#align polynomial.of_subring Polynomial.ofSubring\n\n/- warning: polynomial.coeff_of_subring -> Polynomial.coeff_ofSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1) (p : Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))) (n : Nat), Eq.{succ u1} R (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Polynomial.ofSubring.{u1} R _inst_1 T p) n) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) x T))))) (Polynomial.coeff.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T)) p n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1) (p : Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))) (n : Nat), Eq.{succ u1} R (Polynomial.coeff.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Polynomial.ofSubring.{u1} R _inst_1 T p) n) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)) (Polynomial.coeff.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T)) p n))\nCase conversion may be inaccurate. Consider using '#align polynomial.coeff_of_subring Polynomial.coeff_ofSubringₓ'. -/\ntheorem coeff_ofSubring (p : T[X]) (n : ℕ) : coeff (ofSubring T p) n = (coeff p n : T) :=\n  by\n  simp only [of_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',\n    ite_eq_right_iff, Ne.def, ite_not, Classical.not_not, ite_eq_left_iff]\n  intro h\n  rw [h]\n  rfl\n#align polynomial.coeff_of_subring Polynomial.coeff_ofSubring\n\n/- warning: polynomial.frange_of_subring -> Polynomial.frange_ofSubring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1) {p : Polynomial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Ring.toSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)) T) (Subring.toRing.{u1} R _inst_1 T))}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} R) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) (Finset.Set.hasCoeT.{u1} R))) (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Polynomial.ofSubring.{u1} R _inst_1 T p))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.setLike.{u1} R _inst_1)))) T)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] (T : Subring.{u1} R _inst_1) {p : Polynomial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Ring.toSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1)) x T)) (Subring.toRing.{u1} R _inst_1 T))}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (Finset.toSet.{u1} R (Polynomial.frange.{u1} R (Ring.toSemiring.{u1} R _inst_1) (Polynomial.ofSubring.{u1} R _inst_1 T p))) (SetLike.coe.{u1, u1} (Subring.{u1} R _inst_1) R (Subring.instSetLikeSubring.{u1} R _inst_1) T)\nCase conversion may be inaccurate. Consider using '#align polynomial.frange_of_subring Polynomial.frange_ofSubringₓ'. -/\n@[simp]\ntheorem frange_ofSubring {p : T[X]} : (↑(p.ofSubring T).frange : Set R) ⊆ T :=\n  by\n  intro i hi\n  simp only [frange, Set.mem_image, mem_support_iff, Ne.def, Finset.mem_coe, Finset.coe_image] at hi\n  rcases hi with ⟨n, hn, h'n⟩\n  rw [← h'n, coeff_of_subring]\n  exact Subtype.mem (coeff p n : T)\n#align polynomial.frange_of_subring Polynomial.frange_ofSubring\n\nend Ring\n\nsection CommRing\n\nvariable [CommRing R]\n\nsection ModByMonic\n\nvariable {q : R[X]}\n\n/- warning: polynomial.mem_ker_mod_by_monic -> Polynomial.mem_ker_mod_by_monic is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) q) -> (forall {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, Iff (Membership.Mem.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (SetLike.hasMem.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) p (LinearMap.ker.{u1, u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (LinearMap.semilinearMapClass.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.modByMonicHom.{u1} R _inst_1 q))) (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commRing.{u1} R _inst_1))))))) q p))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) q) -> (forall {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, Iff (Membership.mem.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (SetLike.instMembership.{u1, u1} (Submodule.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.setLike.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) p (LinearMap.ker.{u1, u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.modByMonicHom.{u1} R _inst_1 q))) (Dvd.dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commRing.{u1} R _inst_1))))))) q p))\nCase conversion may be inaccurate. Consider using '#align polynomial.mem_ker_mod_by_monic Polynomial.mem_ker_mod_by_monicₓ'. -/\ntheorem mem_ker_mod_by_monic (hq : q.Monic) {p : R[X]} : p ∈ (modByMonicHom q).ker ↔ q ∣ p :=\n  LinearMap.mem_ker.trans (dvd_iff_modByMonic_eq_zero hq)\n#align polynomial.mem_ker_mod_by_monic Polynomial.mem_ker_mod_by_monic\n\n/- warning: polynomial.ker_mod_by_monic_hom -> Polynomial.ker_modByMonicHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) q) -> (Eq.{succ u1} (Submodule.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (LinearMap.ker.{u1, u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (LinearMap.semilinearMapClass.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddCommGroup.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toAddCommGroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.modByMonicHom.{u1} R _inst_1 q)) (Submodule.restrictScalars.{u1, u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (SMulZeroClass.toHasSmul.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.smulZeroClass.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (SMulWithZero.toSmulZeroClass.{u1, u1} R R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (MulZeroClass.toSMulWithZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) (Polynomial.isScalarTower_right.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (DistribMulAction.toDistribSMul.{u1, u1} R R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} R (NonUnitalNonAssocRing.toAddCommGroup.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (IsScalarTower.right.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (Ideal.span.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Singleton.singleton.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Set.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Set.hasSingleton.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) q))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Polynomial.Monic.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) q) -> (Eq.{succ u1} (Submodule.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (LinearMap.ker.{u1, u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u1, u1} R R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ring.toNonAssocRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.modByMonicHom.{u1} R _inst_1 q)) (Submodule.restrictScalars.{u1, u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Polynomial.module.{u1, u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (_private.Mathlib.RingTheory.Ideal.Operations.0.Ideal.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRingToNonUnitalCommRing.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_1 (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Algebra.toSMul.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (Polynomial.isScalarTower_right.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (DistribMulAction.toDistribSMul.{u1, u1} R R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Module.toDistribMulAction.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (_private.Mathlib.RingTheory.Ideal.Operations.0.Ideal.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRingToNonUnitalCommRing.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_1 (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (IsScalarTower.right.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (Ideal.span.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Singleton.singleton.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Set.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (Set.instSingletonSet.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) q))))\nCase conversion may be inaccurate. Consider using '#align polynomial.ker_mod_by_monic_hom Polynomial.ker_modByMonicHomₓ'. -/\n@[simp]\ntheorem ker_modByMonicHom (hq : q.Monic) :\n    (Polynomial.modByMonicHom q).ker = (Ideal.span {q}).restrictScalars R :=\n  Submodule.ext fun f => (mem_ker_mod_by_monic hq).trans Ideal.mem_span_singleton.symm\n#align polynomial.ker_mod_by_monic_hom Polynomial.ker_modByMonicHom\n\nend ModByMonic\n\nend CommRing\n\nend Polynomial\n\nnamespace Ideal\n\nopen Polynomial\n\nsection Semiring\n\nvariable [Semiring R]\n\n#print Ideal.ofPolynomial /-\n/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/\ndef ofPolynomial (I : Ideal R[X]) : Submodule R R[X]\n    where\n  carrier := I.carrier\n  zero_mem' := I.zero_mem\n  add_mem' _ _ := I.add_mem\n  smul_mem' c x H := by\n    rw [← C_mul']\n    exact I.mul_mem_left _ H\n#align ideal.of_polynomial Ideal.ofPolynomial\n-/\n\nvariable {I : Ideal R[X]}\n\n#print Ideal.mem_ofPolynomial /-\ntheorem mem_ofPolynomial (x) : x ∈ I.ofPolynomial ↔ x ∈ I :=\n  Iff.rfl\n#align ideal.mem_of_polynomial Ideal.mem_ofPolynomial\n-/\n\nvariable (I)\n\n#print Ideal.degreeLe /-\n/-- Given an ideal `I` of `R[X]`, make the `R`-submodule of `I`\nconsisting of polynomials of degree ≤ `n`. -/\ndef degreeLe (n : WithBot ℕ) : Submodule R R[X] :=\n  degreeLe R n ⊓ I.ofPolynomial\n#align ideal.degree_le Ideal.degreeLe\n-/\n\n#print Ideal.leadingCoeffNth /-\n/-- Given an ideal `I` of `R[X]`, make the ideal in `R` of\nleading coefficients of polynomials in `I` with degree ≤ `n`. -/\ndef leadingCoeffNth (n : ℕ) : Ideal R :=\n  (I.degreeLe n).map <| lcoeff R n\n#align ideal.leading_coeff_nth Ideal.leadingCoeffNth\n-/\n\n#print Ideal.leadingCoeff /-\n/-- Given an ideal `I` in `R[X]`, make the ideal in `R` of the\nleading coefficients in `I`. -/\ndef leadingCoeff : Ideal R :=\n  ⨆ n : ℕ, I.leadingCoeffNth n\n#align ideal.leading_coeff Ideal.leadingCoeff\n-/\n\nend Semiring\n\nsection CommSemiring\n\nvariable [CommSemiring R] [Semiring S]\n\n/- warning: ideal.polynomial_mem_ideal_of_coeff_mem_ideal -> Ideal.polynomial_mem_ideal_of_coeff_mem_ideal is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)), (forall (n : Nat), Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.coeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p n) (Ideal.comap.{u1, u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.ringHomClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.C.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) I)) -> (Membership.Mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)), (forall (n : Nat), Membership.mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.coeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p n) (Ideal.comap.{u1, u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.C.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) I)) -> (Membership.mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I)\nCase conversion may be inaccurate. Consider using '#align ideal.polynomial_mem_ideal_of_coeff_mem_ideal Ideal.polynomial_mem_ideal_of_coeff_mem_idealₓ'. -/\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself -/\ntheorem polynomial_mem_ideal_of_coeff_mem_ideal (I : Ideal R[X]) (p : R[X])\n    (hp : ∀ n : ℕ, p.coeff n ∈ I.comap (C : R →+* R[X])) : p ∈ I :=\n  sum_C_mul_X_pow_eq p ▸ Submodule.sum_mem I fun n hn => I.mul_mem_right _ (hp n)\n#align ideal.polynomial_mem_ideal_of_coeff_mem_ideal Ideal.polynomial_mem_ideal_of_coeff_mem_ideal\n\n/- warning: ideal.mem_map_C_iff -> Ideal.mem_map_C_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {I : Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)} {f : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)}, Iff (Membership.Mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) f (Ideal.map.{u1, u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.ringHomClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.C.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) I)) (forall (n : Nat), Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.coeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) f n) I)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {I : Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)} {f : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)}, Iff (Membership.mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) f (Ideal.map.{u1, u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.C.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) I)) (forall (n : Nat), Membership.mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.coeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) f n) I)\nCase conversion may be inaccurate. Consider using '#align ideal.mem_map_C_iff Ideal.mem_map_C_iffₓ'. -/\n/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : Ideal R} {f : R[X]} :\n    f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I :=\n  by\n  constructor\n  · intro hf\n    apply Submodule.span_induction hf\n    · intro f hf n\n      cases' (Set.mem_image _ _ _).mp hf with x hx\n      rw [← hx.right, coeff_C]\n      by_cases n = 0\n      · simpa [h] using hx.left\n      · simp [h]\n    · simp\n    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]\n    · refine' fun f g hg n => _\n      rw [smul_eq_mul, coeff_mul]\n      exact I.sum_mem fun c hc => I.mul_mem_left (f.coeff c.fst) (hg c.snd)\n  · intro hf\n    rw [← sum_monomial_eq f]\n    refine' (I.map C : Ideal R[X]).sum_mem fun n hn => _\n    simp [← C_mul_X_pow_eq_monomial]\n    rw [mul_comm]\n    exact (I.map C : Ideal R[X]).mul_mem_left _ (mem_map_of_mem _ (hf n))\n#align ideal.mem_map_C_iff Ideal.mem_map_C_iff\n\n/- warning: polynomial.ker_map_ring_hom -> Polynomial.ker_mapRingHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} S] (f : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)), Eq.{succ u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHom.ker.{u1, u2, max u1 u2} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u2} S _inst_2) (RingHom.{u1, u2} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} S _inst_2) (Polynomial.semiring.{u2} S _inst_2))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u2} S _inst_2) (RingHom.ringHomClass.{u1, u2} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} S _inst_2) (Polynomial.semiring.{u2} S _inst_2))) (Polynomial.mapRingHom.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) _inst_2 f)) (Ideal.map.{u1, u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.ringHomClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.C.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (RingHom.ker.{u1, u2, max u1 u2} R S (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_2 (RingHom.ringHomClass.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) f))\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Semiring.{u1} S] (f : RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S _inst_2)), Eq.{succ u2} (Submodule.{u2, u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Semiring.toModule.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (LinearMap.ker.{u2, u1, u2, u1, max u2 u1} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u1} S _inst_2) (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u1} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} S _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} S _inst_2) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u1} S _inst_2)))) (Semiring.toModule.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (Semiring.toModule.{u1} (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u1} S _inst_2)) (Polynomial.mapRingHom.{u2, u1} R S (CommSemiring.toSemiring.{u2} R _inst_1) _inst_2 f) (LinearMap.{u2, u1, u2, u1} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u1} S _inst_2) (Polynomial.mapRingHom.{u2, u1} R S (CommSemiring.toSemiring.{u2} R _inst_1) _inst_2 f) (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u1} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} S _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} S _inst_2) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u1} S _inst_2)))) (Semiring.toModule.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (Semiring.toModule.{u1} (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u1} S _inst_2))) (LinearMap.instSemilinearMapClassLinearMap.{u2, u1, u2, u1} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u1} S _inst_2) (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u1} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} S _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} S _inst_2) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u1} S _inst_2)))) (Semiring.toModule.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (Semiring.toModule.{u1} (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u1} S _inst_2)) (Polynomial.mapRingHom.{u2, u1} R S (CommSemiring.toSemiring.{u2} R _inst_1) _inst_2 f)) (RingHom.toSemilinearMap.{u2, u1} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.{u1} S _inst_2) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u1} S _inst_2) (Polynomial.mapRingHom.{u2, u1} R S (CommSemiring.toSemiring.{u2} R _inst_1) _inst_2 f))) (Ideal.map.{u2, u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (RingHom.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (CommSemiring.toSemiring.{u2} R _inst_1) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (RingHom.instRingHomClassRingHom.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Polynomial.C.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (RingHom.ker.{u2, u1, max u2 u1} R S (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_2 (RingHom.instRingHomClassRingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) f))\nCase conversion may be inaccurate. Consider using '#align polynomial.ker_map_ring_hom Polynomial.ker_mapRingHomₓ'. -/\ntheorem Polynomial.ker_mapRingHom (f : R →+* S) :\n    (Polynomial.mapRingHom f).ker = f.ker.map (C : R →+* R[X]) :=\n  by\n  ext\n  rw [mem_map_C_iff, RingHom.mem_ker, Polynomial.ext_iff]\n  simp_rw [coe_map_ring_hom, coeff_map, coeff_zero, RingHom.mem_ker]\n#align polynomial.ker_map_ring_hom Polynomial.ker_mapRingHom\n\nvariable (I : Ideal R[X])\n\n/- warning: ideal.mem_leading_coeff_nth -> Ideal.mem_leadingCoeffNth is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (n : Nat) (x : R), Iff (Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) x (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I n)) (Exists.{succ u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (fun (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => Exists.{0} (Membership.Mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I) (fun (H : Membership.Mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I) => And (LE.le.{0} (WithBot.{0} Nat) (Preorder.toLE.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))))) (Polynomial.degree.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat (WithBot.{0} Nat) (HasLiftT.mk.{1, 1} Nat (WithBot.{0} Nat) (CoeTCₓ.coe.{1, 1} Nat (WithBot.{0} Nat) (WithBot.hasCoeT.{0} Nat))) n)) (Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p) x))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (n : Nat) (x : R), Iff (Membership.mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) x (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I n)) (Exists.{succ u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (fun (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => And (Membership.mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I) (And (LE.le.{0} (WithBot.{0} Nat) (Preorder.toLE.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)))) (Polynomial.degree.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p) (Nat.cast.{0} (WithBot.{0} Nat) (Semiring.toNatCast.{0} (WithBot.{0} Nat) (OrderedSemiring.toSemiring.{0} (WithBot.{0} Nat) (OrderedCommSemiring.toOrderedSemiring.{0} (WithBot.{0} Nat) (WithBot.orderedCommSemiring.{0} Nat (fun (a : Nat) (b : Nat) => instDecidableEqNat a b) Nat.canonicallyOrderedCommSemiring Nat.nontrivial)))) n)) (Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p) x))))\nCase conversion may be inaccurate. Consider using '#align ideal.mem_leading_coeff_nth Ideal.mem_leadingCoeffNthₓ'. -/\ntheorem mem_leadingCoeffNth (n : ℕ) (x) :\n    x ∈ I.leadingCoeffNth n ↔ ∃ p ∈ I, degree p ≤ n ∧ p.leadingCoeff = x :=\n  by\n  simp only [leading_coeff_nth, degree_le, Submodule.mem_map, lcoeff_apply, Submodule.mem_inf,\n    mem_degree_le]\n  constructor\n  · rintro ⟨p, ⟨hpdeg, hpI⟩, rfl⟩\n    cases' lt_or_eq_of_le hpdeg with hpdeg hpdeg\n    · refine' ⟨0, I.zero_mem, bot_le, _⟩\n      rw [leading_coeff_zero, eq_comm]\n      exact coeff_eq_zero_of_degree_lt hpdeg\n    · refine' ⟨p, hpI, le_of_eq hpdeg, _⟩\n      rw [Polynomial.leadingCoeff, nat_degree, hpdeg]\n      rfl\n  · rintro ⟨p, hpI, hpdeg, rfl⟩\n    have : nat_degree p + (n - nat_degree p) = n :=\n      add_tsub_cancel_of_le (nat_degree_le_of_degree_le hpdeg)\n    refine' ⟨p * X ^ (n - nat_degree p), ⟨_, I.mul_mem_right _ hpI⟩, _⟩\n    · apply le_trans (degree_mul_le _ _) _\n      apply le_trans (add_le_add degree_le_nat_degree (degree_X_pow_le _)) _\n      rw [← WithBot.coe_add, this]\n      exact le_rfl\n    · rw [Polynomial.leadingCoeff, ← coeff_mul_X_pow p (n - nat_degree p), this]\n#align ideal.mem_leading_coeff_nth Ideal.mem_leadingCoeffNth\n\n/- warning: ideal.mem_leading_coeff_nth_zero -> Ideal.mem_leadingCoeffNth_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (x : R), Iff (Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) x (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))) (Membership.Mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) => R -> (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.C.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) x) I)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (x : R), Iff (Membership.mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) x (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))) (Membership.mem.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) x) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))) (Polynomial.C.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) x) I)\nCase conversion may be inaccurate. Consider using '#align ideal.mem_leading_coeff_nth_zero Ideal.mem_leadingCoeffNth_zeroₓ'. -/\ntheorem mem_leadingCoeffNth_zero (x) : x ∈ I.leadingCoeffNth 0 ↔ C x ∈ I :=\n  (mem_leadingCoeffNth _ _ _).trans\n    ⟨fun ⟨p, hpI, hpdeg, hpx⟩ => by\n      rwa [← hpx, Polynomial.leadingCoeff,\n        Nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg), ← eq_C_of_degree_le_zero hpdeg],\n      fun hx => ⟨C x, hx, degree_C_le, leadingCoeff_C x⟩⟩\n#align ideal.mem_leading_coeff_nth_zero Ideal.mem_leadingCoeffNth_zero\n\n/- warning: ideal.leading_coeff_nth_mono -> Ideal.leadingCoeffNth_mono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (LE.le.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Preorder.toLE.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (PartialOrder.toPreorder.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.partialOrder.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I m) (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (LE.le.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Preorder.toLE.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (PartialOrder.toPreorder.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.completeLattice.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))) (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I m) (Ideal.leadingCoeffNth.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I n))\nCase conversion may be inaccurate. Consider using '#align ideal.leading_coeff_nth_mono Ideal.leadingCoeffNth_monoₓ'. -/\ntheorem leadingCoeffNth_mono {m n : ℕ} (H : m ≤ n) : I.leadingCoeffNth m ≤ I.leadingCoeffNth n :=\n  by\n  intro r hr\n  simp only [SetLike.mem_coe, mem_leading_coeff_nth] at hr⊢\n  rcases hr with ⟨p, hpI, hpdeg, rfl⟩\n  refine' ⟨p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow⟩\n  refine' le_trans (degree_mul_le _ _) _\n  refine' le_trans (add_le_add hpdeg (degree_X_pow_le _)) _\n  rw [← WithBot.coe_add, add_tsub_cancel_of_le H]\n  exact le_rfl\n#align ideal.leading_coeff_nth_mono Ideal.leadingCoeffNth_mono\n\n/- warning: ideal.mem_leading_coeff -> Ideal.mem_leadingCoeff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (x : R), Iff (Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) x (Ideal.leadingCoeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I)) (Exists.{succ u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (fun (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => Exists.{0} (Membership.Mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I) (fun (H : Membership.Mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I) => Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p) x)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (I : Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (x : R), Iff (Membership.mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) x (Ideal.leadingCoeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) I)) (Exists.{succ u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (fun (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => And (Membership.mem.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) p I) (Eq.{succ u1} R (Polynomial.leadingCoeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) p) x)))\nCase conversion may be inaccurate. Consider using '#align ideal.mem_leading_coeff Ideal.mem_leadingCoeffₓ'. -/\ntheorem mem_leadingCoeff (x) : x ∈ I.leadingCoeff ↔ ∃ p ∈ I, Polynomial.leadingCoeff p = x :=\n  by\n  rw [leading_coeff, Submodule.mem_supᵢ_of_directed]\n  simp only [mem_leading_coeff_nth]\n  · constructor\n    · rintro ⟨i, p, hpI, hpdeg, rfl⟩\n      exact ⟨p, hpI, rfl⟩\n    rintro ⟨p, hpI, rfl⟩\n    exact ⟨nat_degree p, p, hpI, degree_le_nat_degree, rfl⟩\n  intro i j;\n  exact\n    ⟨i + j, I.leading_coeff_nth_mono (Nat.le_add_right _ _),\n      I.leading_coeff_nth_mono (Nat.le_add_left _ _)⟩\n#align ideal.mem_leading_coeff Ideal.mem_leadingCoeff\n\n/- warning: polynomial.coeff_prod_mem_ideal_pow_tsub -> Polynomial.coeff_prod_mem_ideal_pow_tsub is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {ι : Type.{u2}} (s : Finset.{u2} ι) (f : ι -> (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (I : Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (n : ι -> Nat), (forall (i : ι), (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) i s) -> (forall (k : Nat), Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.coeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) (f i) k) (HPow.hPow.{u1, 0, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) Nat (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (instHPow.{u1, 0} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) Nat (Monoid.Pow.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (MonoidWithZero.toMonoid.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toMonoidWithZero.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (IdemSemiring.toSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.idemSemiring.{u1, u1} R _inst_1 R (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1))))))) I (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (n i) k)))) -> (forall (k : Nat), Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Polynomial.coeff.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1) (Finset.prod.{u1, u2} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ι (CommSemiring.toCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.commSemiring.{u1} R _inst_1)) s f) k) (HPow.hPow.{u1, 0, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) Nat (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (instHPow.{u1, 0} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) Nat (Monoid.Pow.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (MonoidWithZero.toMonoid.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toMonoidWithZero.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (IdemSemiring.toSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.idemSemiring.{u1, u1} R _inst_1 R (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1))))))) I (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.sum.{0, u2} Nat ι Nat.addCommMonoid s n) k)))\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] {ι : Type.{u1}} (s : Finset.{u1} ι) (f : ι -> (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (I : Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (n : ι -> Nat), (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (forall (k : Nat), Membership.mem.{u2, u2} R (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (SetLike.instMembership.{u2, u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) R (Submodule.setLike.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Polynomial.coeff.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1) (f i) k) (HPow.hPow.{u2, 0, u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) Nat (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (instHPow.{u2, 0} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) Nat (Monoid.Pow.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (MonoidWithZero.toMonoid.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toMonoidWithZero.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (IdemSemiring.toSemiring.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.idemSemiring.{u2, u2} R _inst_1 R (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1))))))) I (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (n i) k)))) -> (forall (k : Nat), Membership.mem.{u2, u2} R (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (SetLike.instMembership.{u2, u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) R (Submodule.setLike.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Polynomial.coeff.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1) (Finset.prod.{u2, u1} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) ι (CommSemiring.toCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.commSemiring.{u2} R _inst_1)) s f) k) (HPow.hPow.{u2, 0, u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) Nat (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (instHPow.{u2, 0} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) Nat (Monoid.Pow.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (MonoidWithZero.toMonoid.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toMonoidWithZero.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (IdemSemiring.toSemiring.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.idemSemiring.{u2, u2} R _inst_1 R (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1))))))) I (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.sum.{0, u1} Nat ι Nat.addCommMonoid s n) k)))\nCase conversion may be inaccurate. Consider using '#align polynomial.coeff_prod_mem_ideal_pow_tsub Polynomial.coeff_prod_mem_ideal_pow_tsubₓ'. -/\n/-- If `I` is an ideal, and `pᵢ` is a finite family of polynomials each satisfying\n`∀ k, (pᵢ)ₖ ∈ Iⁿⁱ⁻ᵏ` for some `nᵢ`, then `p = ∏ pᵢ` also satisfies `∀ k, pₖ ∈ Iⁿ⁻ᵏ` with `n = ∑ nᵢ`.\n-/\ntheorem Polynomial.coeff_prod_mem_ideal_pow_tsub {ι : Type _} (s : Finset ι) (f : ι → R[X])\n    (I : Ideal R) (n : ι → ℕ) (h : ∀ i ∈ s, ∀ (k), (f i).coeff k ∈ I ^ (n i - k)) (k : ℕ) :\n    (s.Prod f).coeff k ∈ I ^ (s.Sum n - k) := by\n  classical\n    induction' s using Finset.induction with a s ha hs generalizing k\n    · rw [sum_empty, prod_empty, coeff_one, zero_tsub, pow_zero, Ideal.one_eq_top]\n      exact Submodule.mem_top\n    · rw [sum_insert ha, prod_insert ha, coeff_mul]\n      apply sum_mem\n      rintro ⟨i, j⟩ e\n      obtain rfl : i + j = k := nat.mem_antidiagonal.mp e\n      apply Ideal.pow_le_pow add_tsub_add_le_tsub_add_tsub\n      rw [pow_add]\n      exact\n        Ideal.mul_mem_mul (h _ (finset.mem_insert.mpr <| Or.inl rfl) _)\n          (hs (fun i hi k => h _ (finset.mem_insert.mpr <| Or.inr hi) _) j)\n#align polynomial.coeff_prod_mem_ideal_pow_tsub Polynomial.coeff_prod_mem_ideal_pow_tsub\n\nend CommSemiring\n\nsection Ring\n\nvariable [Ring R]\n\n#print Ideal.polynomial_not_isField /-\n/-- `R[X]` is never a field for any ring `R`. -/\ntheorem polynomial_not_isField : ¬IsField R[X] :=\n  by\n  nontriviality R\n  intro hR\n  obtain ⟨p, hp⟩ := hR.mul_inv_cancel X_ne_zero\n  have hp0 : p ≠ 0 := by\n    rintro rfl\n    rw [MulZeroClass.mul_zero] at hp\n    exact zero_ne_one hp\n  have := degree_lt_degree_mul_X hp0\n  rw [← X_mul, congr_arg degree hp, degree_one, Nat.WithBot.lt_zero_iff, degree_eq_bot] at this\n  exact hp0 this\n#align ideal.polynomial_not_is_field Ideal.polynomial_not_isField\n-/\n\n/- warning: ideal.eq_zero_of_constant_mem_of_maximal -> Ideal.eq_zero_of_constant_mem_of_maximal is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (I : Ideal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) [hI : Ideal.IsMaximal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) I] (x : R), (Membership.Mem.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Ideal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R _inst_1)) x) I) -> (Eq.{succ u1} R x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R], (IsField.{u1} R (Ring.toSemiring.{u1} R _inst_1)) -> (forall (I : Ideal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) [hI : Ideal.IsMaximal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) I] (x : R), (Membership.mem.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) x) (Ideal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R _inst_1)) x) I) -> (Eq.{succ u1} R x (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align ideal.eq_zero_of_constant_mem_of_maximal Ideal.eq_zero_of_constant_mem_of_maximalₓ'. -/\n/-- The only constant in a maximal ideal over a field is `0`. -/\ntheorem eq_zero_of_constant_mem_of_maximal (hR : IsField R) (I : Ideal R[X]) [hI : I.IsMaximal]\n    (x : R) (hx : C x ∈ I) : x = 0 :=\n  by\n  refine' by_contradiction fun hx0 => hI.ne_top ((eq_top_iff_one I).2 _)\n  obtain ⟨y, hy⟩ := hR.mul_inv_cancel hx0\n  convert I.mul_mem_left (C y) hx\n  rw [← C.map_mul, hR.mul_comm y x, hy, RingHom.map_one]\n#align ideal.eq_zero_of_constant_mem_of_maximal Ideal.eq_zero_of_constant_mem_of_maximal\n\nend Ring\n\nsection CommRing\n\nvariable [CommRing R]\n\n/- warning: ideal.is_prime_map_C_iff_is_prime -> Ideal.isPrime_map_C_iff_isPrime is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (P : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), Iff (Ideal.IsPrime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.map.{u1, u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.ringHomClass.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) P)) (Ideal.IsPrime.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) P)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (P : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), Iff (Ideal.IsPrime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.map.{u1, u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) P)) (Ideal.IsPrime.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) P)\nCase conversion may be inaccurate. Consider using '#align ideal.is_prime_map_C_iff_is_prime Ideal.isPrime_map_C_iff_isPrimeₓ'. -/\n/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/\ntheorem isPrime_map_C_iff_isPrime (P : Ideal R) :\n    IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) ↔ IsPrime P :=\n  by\n  -- Porting note: the following proof avoids quotient rings\n  -- It can be golfed substantially by using something like\n  -- `(quotient.is_domain_iff_prime (map C P : ideal R[X]))`\n  constructor\n  · intro H\n    have := @comap_is_prime R R[X] (R →+* R[X]) _ _ _ C (map C P) H\n    convert this using 1\n    ext x\n    simp only [mem_comap, mem_map_C_iff]\n    constructor\n    · rintro h (- | n)\n      · simpa only [coeff_C_zero] using h\n      · simp only [coeff_C_ne_zero (Nat.succ_ne_zero _), Submodule.zero_mem]\n    · intro h\n      simpa only [coeff_C_zero] using h 0\n  · intro h\n    constructor\n    · rw [Ne.def, eq_top_iff_one, mem_map_C_iff, not_forall]\n      use 0\n      rw [coeff_one_zero, ← eq_top_iff_one]\n      exact h.1\n    · intro f g\n      simp only [mem_map_C_iff]\n      contrapose!\n      rintro ⟨hf, hg⟩\n      classical\n        let m := Nat.find hf\n        let n := Nat.find hg\n        refine' ⟨m + n, _⟩\n        rw [coeff_mul, ← Finset.insert_erase ((@Finset.Nat.mem_antidiagonal _ (m, n)).mpr rfl),\n          Finset.sum_insert (Finset.not_mem_erase _ _), (P.add_mem_iff_left _).Not]\n        · apply mt h.2\n          rw [not_or]\n          exact ⟨Nat.find_spec hf, Nat.find_spec hg⟩\n        apply P.sum_mem\n        rintro ⟨i, j⟩ hij\n        rw [Finset.mem_erase, Finset.Nat.mem_antidiagonal] at hij\n        simp only [Ne.def, Prod.mk.inj_iff, not_and_or] at hij\n        obtain hi | hj : i < m ∨ j < n :=\n          by\n          rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq]\n          rintro (hmi | rfl)\n          · rw [← not_le]\n            intro hnj\n            exact (add_lt_add_of_lt_of_le hmi hnj).Ne hij.2.symm\n          ·\n            simpa only [eq_self_iff_true, not_true, false_or_iff, add_right_inj,\n              not_and_self_iff] using hij\n        · rw [mul_comm]\n          apply P.mul_mem_left\n          exact Classical.not_not.1 (Nat.find_min hf hi)\n        · apply P.mul_mem_left\n          exact Classical.not_not.1 (Nat.find_min hg hj)\n#align ideal.is_prime_map_C_iff_is_prime Ideal.isPrime_map_C_iff_isPrime\n\n/- warning: ideal.is_prime_map_C_of_is_prime -> Ideal.isPrime_map_C_of_isPrime is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {P : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Ideal.IsPrime.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) P) -> (Ideal.IsPrime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.map.{u1, u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.ringHomClass.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) P))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {P : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (Ideal.IsPrime.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) P) -> (Ideal.IsPrime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.map.{u1, u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) P))\nCase conversion may be inaccurate. Consider using '#align ideal.is_prime_map_C_of_is_prime Ideal.isPrime_map_C_of_isPrimeₓ'. -/\n/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/\ntheorem isPrime_map_C_of_isPrime {P : Ideal R} (H : IsPrime P) :\n    IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) :=\n  (isPrime_map_C_iff_isPrime P).mpr H\n#align ideal.is_prime_map_C_of_is_prime Ideal.isPrime_map_C_of_isPrime\n\n#print Ideal.is_fg_degreeLe /-\ntheorem is_fg_degreeLe [IsNoetherianRing R] (I : Ideal R[X]) (n : ℕ) :\n    Submodule.Fg (I.degreeLe n) :=\n  isNoetherian_submodule_left.1\n    (isNoetherian_of_fg_of_noetherian _ ⟨_, degreeLe_eq_span_X_pow.symm⟩) _\n#align ideal.is_fg_degree_le Ideal.is_fg_degreeLe\n-/\n\nend CommRing\n\nend Ideal\n\nvariable {σ : Type v} {M : Type w}\n\nvariable [CommRing R] [CommRing S] [AddCommGroup M] [Module R M]\n\nsection Prime\n\nvariable (σ) {r : R}\n\nnamespace Polynomial\n\n/- warning: polynomial.prime_C_iff -> Polynomial.prime_C_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {r : R}, Iff (Prime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (CommSemiring.toCommMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) => R -> (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) r)) (Prime.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) r)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {r : R}, Iff (Prime.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) r) (CommSemiring.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) r) (CommRing.toCommSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) r) (Polynomial.commRing.{u1} R _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))))) (Polynomial.C.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) r)) (Prime.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) r)\nCase conversion may be inaccurate. Consider using '#align polynomial.prime_C_iff Polynomial.prime_C_iffₓ'. -/\ntheorem prime_C_iff : Prime (C r) ↔ Prime r :=\n  ⟨comap_prime C (evalRingHom (0 : R)) fun r => eval_C, fun hr =>\n    by\n    have := hr.1\n    rw [← Ideal.span_singleton_prime] at hr⊢\n    · convert Ideal.isPrime_map_C_of_isPrime hr using 1\n      rw [Ideal.map_span, Set.image_singleton]\n    exacts[fun h => this (C_eq_zero.1 h), this]⟩\n#align polynomial.prime_C_iff Polynomial.prime_C_iff\n\nend Polynomial\n\nnamespace MvPolynomial\n\nprivate theorem prime_C_iff_of_fintype [Fintype σ] : Prime (C r : MvPolynomial σ R) ↔ Prime r :=\n  by\n  rw [(rename_equiv R (Fintype.equivFin σ)).toMulEquiv.prime_iff]\n  convert_to Prime (C r) ↔ _;\n  · congr\n    apply rename_C\n  · symm\n    induction' Fintype.card σ with d hd\n    · exact (is_empty_alg_equiv R (Fin 0)).toMulEquiv.symm.prime_iff\n    · rw [hd, ← Polynomial.prime_C_iff]\n      convert(finSuccEquiv R d).toMulEquiv.symm.prime_iff\n      rw [← fin_succ_equiv_comp_C_eq_C]\n      rfl\n#align mv_polynomial.prime_C_iff_of_fintype mv_polynomial.prime_C_iff_of_fintype\n\n/- warning: mv_polynomial.prime_C_iff -> MvPolynomial.prime_C_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} (σ : Type.{u2}) [_inst_1 : CommRing.{u1} R] {r : R}, Iff (Prime.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toCommMonoidWithZero.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))) (coeFn.{max (succ u1) (succ (max u2 u1)), max (succ u1) (succ (max u2 u1))} (RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (fun (_x : RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) => R -> (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1))) (RingHom.hasCoeToFun.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)) r)) (Prime.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) r)\nbut is expected to have type\n  forall {R : Type.{u1}} (σ : Type.{u2}) [_inst_1 : CommRing.{u1} R] {r : R}, Iff (Prime.{max u1 u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) r) (CommSemiring.toCommMonoidWithZero.{max u1 u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) r) (CommRing.toCommSemiring.{max u1 u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) r) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, max (succ u2) (succ u1)} (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) _x) (MulHomClass.toFunLike.{max u2 u1, u1, max u2 u1} (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)))))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u1, max u2 u1} (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u1, max u2 u1} (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)))) (RingHom.instRingHomClassRingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)) r)) (Prime.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) r)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.prime_C_iff MvPolynomial.prime_C_iffₓ'. -/\ntheorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=\n  ⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>\n    ⟨fun h =>\n      hr.1 <| by\n        rw [← C_inj, h]\n        simp,\n      fun h =>\n      hr.2.1 <| by\n        rw [← constant_coeff_C _ r]\n        exact h.map _,\n      fun a b hd => by\n      obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b\n      rw [← algebra_map_eq] at hd\n      have : algebraMap R _ r ∣ a' * b' :=\n        by\n        convert(kill_compl Subtype.coe_injective).toRingHom.map_dvd hd\n        simpa\n        simp\n      rw [← rename_C (coe : s → σ)]\n      let f := (rename (coe : s → σ)).toRingHom\n      exact (((prime_C_iff_of_fintype s).2 hr).2.2 a' b' this).imp f.map_dvd f.map_dvd⟩⟩\n#align mv_polynomial.prime_C_iff MvPolynomial.prime_C_iff\n\nvariable {σ}\n\n#print MvPolynomial.prime_rename_iff /-\ntheorem prime_rename_iff (s : Set σ) {p : MvPolynomial s R} :\n    Prime (rename (coe : s → σ) p) ↔ Prime p := by\n  classical\n    symm\n    let eqv :=\n      (sum_alg_equiv R _ _).symm.trans\n        (rename_equiv R <| (Equiv.sumComm (↥(sᶜ)) s).trans <| Equiv.Set.sumCompl s)\n    rw [← prime_C_iff ↥(sᶜ), eqv.to_mul_equiv.prime_iff]\n    convert Iff.rfl\n    suffices (rename coe).toRingHom = eqv.to_alg_hom.to_ring_hom.comp C by\n      apply RingHom.congr_fun this\n    · apply ring_hom_ext\n      · intro\n        dsimp [eqv]\n        erw [iter_to_sum_C_C, rename_C, rename_C]\n      · intro\n        dsimp [eqv]\n        erw [iter_to_sum_C_X, rename_X, rename_X]\n        rfl\n#align mv_polynomial.prime_rename_iff MvPolynomial.prime_rename_iff\n-/\n\nend MvPolynomial\n\nend Prime\n\nnamespace Polynomial\n\ninstance (priority := 100) {R : Type _} [CommRing R] [IsDomain R] [WfDvdMonoid R] : WfDvdMonoid R[X]\n    where wellFounded_dvdNotUnit := by\n    classical\n      refine'\n        RelHomClass.wellFounded\n          (⟨fun p : R[X] =>\n              ((if p = 0 then ⊤ else ↑p.degree : WithTop (WithBot ℕ)), p.leadingCoeff), _⟩ :\n            DvdNotUnit →r Prod.Lex (· < ·) DvdNotUnit)\n          (WellFounded.prod_lex (WithTop.wellFounded_lt <| WithBot.wellFounded_lt Nat.lt_wfRel)\n            ‹WfDvdMonoid R›.wellFounded_dvdNotUnit)\n      rintro a b ⟨ane0, ⟨c, ⟨not_unit_c, rfl⟩⟩⟩\n      rw [Polynomial.degree_mul, if_neg ane0]\n      split_ifs with hac\n      · rw [hac, Polynomial.leadingCoeff_zero]\n        apply Prod.Lex.left\n        exact lt_of_le_of_ne le_top WithTop.coe_ne_top\n      have cne0 : c ≠ 0 := right_ne_zero_of_mul hac\n      simp only [cne0, ane0, Polynomial.leadingCoeff_mul]\n      by_cases hdeg : c.degree = 0\n      · simp only [hdeg, add_zero]\n        refine' Prod.Lex.right _ ⟨_, ⟨c.leading_coeff, fun unit_c => not_unit_c _, rfl⟩⟩\n        · rwa [Ne, Polynomial.leadingCoeff_eq_zero]\n        rw [Polynomial.isUnit_iff, Polynomial.eq_C_of_degree_eq_zero hdeg]\n        use c.leading_coeff, unit_c\n        rw [Polynomial.leadingCoeff, Polynomial.natDegree_eq_of_degree_eq_some hdeg]\n      · apply Prod.Lex.left\n        rw [Polynomial.degree_eq_natDegree cne0] at *\n        rw [WithTop.coe_lt_coe, Polynomial.degree_eq_natDegree ane0, ← WithBot.coe_add,\n          WithBot.coe_lt_coe]\n        exact lt_add_of_pos_right _ (Nat.pos_of_ne_zero fun h => hdeg (h.symm ▸ WithBot.coe_zero))\n\nend Polynomial\n\n#print Polynomial.isNoetherianRing /-\n/-- Hilbert basis theorem: a polynomial ring over a noetherian ring is a noetherian ring. -/\nprotected theorem Polynomial.isNoetherianRing [IsNoetherianRing R] : IsNoetherianRing R[X] :=\n  isNoetherianRing_iff.2\n    ⟨fun I : Ideal R[X] =>\n      let M :=\n        WellFounded.min (isNoetherian_iff_wellFounded.1 (by infer_instance))\n          (Set.range I.leadingCoeffNth) ⟨_, ⟨0, rfl⟩⟩\n      have hm : M ∈ Set.range I.leadingCoeffNth := WellFounded.min_mem _ _ _\n      let ⟨N, HN⟩ := hm\n      let ⟨s, hs⟩ := I.is_fg_degreeLe N\n      have hm2 : ∀ k, I.leadingCoeffNth k ≤ M := fun k =>\n        Or.cases_on (le_or_lt k N) (fun h => HN ▸ I.leadingCoeffNth_mono h) fun h x hx =>\n          by_contradiction fun hxm =>\n            have : ¬M < I.leadingCoeffNth k := by\n              refine' WellFounded.not_lt_min (wellFounded_submodule_gt _ _) _ _ _ <;> exact ⟨k, rfl⟩\n            this ⟨HN ▸ I.leadingCoeffNth_mono (le_of_lt h), fun H => hxm (H hx)⟩\n      have hs2 : ∀ {x}, x ∈ I.degreeLe N → x ∈ Ideal.span (↑s : Set R[X]) :=\n        hs ▸ fun x hx =>\n          Submodule.span_induction hx (fun _ hx => Ideal.subset_span hx) (Ideal.zero_mem _)\n            (fun _ _ => Ideal.add_mem _) fun c f hf => f.C_mul' c ▸ Ideal.mul_mem_left _ _ hf\n      ⟨s,\n        le_antisymm\n            (Ideal.span_le.2 fun x hx =>\n              have : x ∈ I.degreeLe N := hs ▸ Submodule.subset_span hx\n              this.2) <|\n          by\n          have : Submodule.span R[X] ↑s = Ideal.span ↑s := by rfl\n          rw [this]\n          intro p hp\n          generalize hn : p.nat_degree = k\n          induction' k using Nat.strong_induction_on with k ih generalizing p\n          cases le_or_lt k N\n          · subst k\n            refine'\n              hs2\n                ⟨Polynomial.mem_degreeLe.2\n                    (le_trans Polynomial.degree_le_natDegree <| WithBot.coe_le_coe.2 h),\n                  hp⟩\n          · have hp0 : p ≠ 0 := by\n              rintro rfl\n              cases hn\n              exact Nat.not_lt_zero _ h\n            have : (0 : R) ≠ 1 := by\n              intro h\n              apply hp0\n              ext i\n              refine' (mul_one _).symm.trans _\n              rw [← h, MulZeroClass.mul_zero]\n              rfl\n            haveI : Nontrivial R := ⟨⟨0, 1, this⟩⟩\n            have : p.leading_coeff ∈ I.leading_coeff_nth N :=\n              by\n              rw [HN]\n              exact\n                hm2 k\n                  ((I.mem_leading_coeff_nth _ _).2\n                    ⟨_, hp, hn ▸ Polynomial.degree_le_natDegree, rfl⟩)\n            rw [I.mem_leading_coeff_nth] at this\n            rcases this with ⟨q, hq, hdq, hlqp⟩\n            have hq0 : q ≠ 0 := by\n              intro H\n              rw [← Polynomial.leadingCoeff_eq_zero] at H\n              rw [hlqp, Polynomial.leadingCoeff_eq_zero] at H\n              exact hp0 H\n            have h1 : p.degree = (q * Polynomial.X ^ (k - q.nat_degree)).degree :=\n              by\n              rw [Polynomial.degree_mul', Polynomial.degree_X_pow]\n              rw [Polynomial.degree_eq_natDegree hp0, Polynomial.degree_eq_natDegree hq0]\n              rw [← WithBot.coe_add, add_tsub_cancel_of_le, hn]\n              · refine' le_trans (Polynomial.natDegree_le_of_degree_le hdq) (le_of_lt h)\n              rw [Polynomial.leadingCoeff_X_pow, mul_one]\n              exact mt Polynomial.leadingCoeff_eq_zero.1 hq0\n            have h2 : p.leading_coeff = (q * Polynomial.X ^ (k - q.nat_degree)).leadingCoeff := by\n              rw [← hlqp, Polynomial.leadingCoeff_mul_X_pow]\n            have := Polynomial.degree_sub_lt h1 hp0 h2\n            rw [Polynomial.degree_eq_natDegree hp0] at this\n            rw [← sub_add_cancel p (q * Polynomial.X ^ (k - q.nat_degree))]\n            refine' (Ideal.span ↑s).add_mem _ ((Ideal.span ↑s).mul_mem_right _ _)\n            · by_cases hpq : p - q * Polynomial.X ^ (k - q.nat_degree) = 0\n              · rw [hpq]\n                exact Ideal.zero_mem _\n              refine' ih _ _ (I.sub_mem hp (I.mul_mem_right _ hq)) rfl\n              rwa [Polynomial.degree_eq_natDegree hpq, WithBot.coe_lt_coe, hn] at this\n            exact hs2 ⟨Polynomial.mem_degreeLe.2 hdq, hq⟩⟩⟩\n#align polynomial.is_noetherian_ring Polynomial.isNoetherianRing\n-/\n\nattribute [instance] Polynomial.isNoetherianRing\n\nnamespace Polynomial\n\n/- warning: polynomial.exists_irreducible_of_degree_pos -> Polynomial.exists_irreducible_of_degree_pos is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_5 : CommRing.{u1} R] [_inst_6 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))] [_inst_7 : WfDvdMonoid.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_5))] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))}, (LT.lt.{0} (WithBot.{0} Nat) (Preorder.toLT.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))))) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (OfNat.mk.{0} (WithBot.{0} Nat) 0 (Zero.zero.{0} (WithBot.{0} Nat) (WithBot.hasZero.{0} Nat Nat.hasZero)))) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5)) f)) -> (Exists.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (fun (g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) => And (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_5))) g) (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.commRing.{u1} R _inst_5))))))) g f)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_5 : CommRing.{u1} R] [_inst_6 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))] [_inst_7 : WfDvdMonoid.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_5) _inst_6))] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))}, (LT.lt.{0} (WithBot.{0} Nat) (Preorder.toLT.{0} (WithBot.{0} Nat) (WithBot.preorder.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)))) (OfNat.ofNat.{0} (WithBot.{0} Nat) 0 (Zero.toOfNat0.{0} (WithBot.{0} Nat) (WithBot.zero.{0} Nat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero)))) (Polynomial.degree.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5)) f)) -> (Exists.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (fun (g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) => And (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))))) g) (Dvd.dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.commRing.{u1} R _inst_5))))))) g f)))\nCase conversion may be inaccurate. Consider using '#align polynomial.exists_irreducible_of_degree_pos Polynomial.exists_irreducible_of_degree_posₓ'. -/\ntheorem exists_irreducible_of_degree_pos {R : Type u} [CommRing R] [IsDomain R] [WfDvdMonoid R]\n    {f : R[X]} (hf : 0 < f.degree) : ∃ g, Irreducible g ∧ g ∣ f :=\n  WfDvdMonoid.exists_irreducible_factor (fun huf => ne_of_gt hf <| degree_eq_zero_of_isUnit huf)\n    fun hf0 => not_lt_of_lt hf <| hf0.symm ▸ (@degree_zero R _).symm ▸ WithBot.bot_lt_coe _\n#align polynomial.exists_irreducible_of_degree_pos Polynomial.exists_irreducible_of_degree_pos\n\n/- warning: polynomial.exists_irreducible_of_nat_degree_pos -> Polynomial.exists_irreducible_of_natDegree_pos is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_5 : CommRing.{u1} R] [_inst_6 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))] [_inst_7 : WfDvdMonoid.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_5))] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) (Polynomial.natDegree.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5)) f)) -> (Exists.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (fun (g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) => And (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_5))) g) (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.commRing.{u1} R _inst_5))))))) g f)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_5 : CommRing.{u1} R] [_inst_6 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))] [_inst_7 : WfDvdMonoid.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_5) _inst_6))] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (Polynomial.natDegree.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5)) f)) -> (Exists.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (fun (g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) => And (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))))) g) (Dvd.dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.commRing.{u1} R _inst_5))))))) g f)))\nCase conversion may be inaccurate. Consider using '#align polynomial.exists_irreducible_of_nat_degree_pos Polynomial.exists_irreducible_of_natDegree_posₓ'. -/\ntheorem exists_irreducible_of_natDegree_pos {R : Type u} [CommRing R] [IsDomain R] [WfDvdMonoid R]\n    {f : R[X]} (hf : 0 < f.natDegree) : ∃ g, Irreducible g ∧ g ∣ f :=\n  exists_irreducible_of_degree_pos <| by\n    contrapose! hf\n    exact nat_degree_le_of_degree_le hf\n#align polynomial.exists_irreducible_of_nat_degree_pos Polynomial.exists_irreducible_of_natDegree_pos\n\n/- warning: polynomial.exists_irreducible_of_nat_degree_ne_zero -> Polynomial.exists_irreducible_of_natDegree_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_5 : CommRing.{u1} R] [_inst_6 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))] [_inst_7 : WfDvdMonoid.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_5))] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))}, (Ne.{1} Nat (Polynomial.natDegree.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5)) f) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Exists.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (fun (g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) => And (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Ring.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.ring.{u1} R (CommRing.toRing.{u1} R _inst_5))) g) (Dvd.Dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.commRing.{u1} R _inst_5))))))) g f)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_5 : CommRing.{u1} R] [_inst_6 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))] [_inst_7 : WfDvdMonoid.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R (IsDomain.toCancelCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_5) _inst_6))] {f : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))}, (Ne.{1} Nat (Polynomial.natDegree.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5)) f) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Exists.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (fun (g : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) => And (Irreducible.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.semiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))))) g) (Dvd.dvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (semigroupDvd.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (SemigroupWithZero.toSemigroup.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalSemiring.toSemigroupWithZero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalRing.toNonUnitalSemiring.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (NonUnitalCommRing.toNonUnitalRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (CommRing.toNonUnitalCommRing.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_5))) (Polynomial.commRing.{u1} R _inst_5))))))) g f)))\nCase conversion may be inaccurate. Consider using '#align polynomial.exists_irreducible_of_nat_degree_ne_zero Polynomial.exists_irreducible_of_natDegree_ne_zeroₓ'. -/\ntheorem exists_irreducible_of_natDegree_ne_zero {R : Type u} [CommRing R] [IsDomain R]\n    [WfDvdMonoid R] {f : R[X]} (hf : f.natDegree ≠ 0) : ∃ g, Irreducible g ∧ g ∣ f :=\n  exists_irreducible_of_natDegree_pos <| Nat.pos_of_ne_zero hf\n#align polynomial.exists_irreducible_of_nat_degree_ne_zero Polynomial.exists_irreducible_of_natDegree_ne_zero\n\n/- warning: polynomial.linear_independent_powers_iff_aeval -> Polynomial.linearIndependent_powers_iff_aeval is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (v : M), Iff (LinearIndependent.{0, u1, u2} Nat R M (fun (n : Nat) => coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HPow.hPow.{u2, 0, u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) Nat (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (instHPow.{u2, 0} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) Nat (Monoid.Pow.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.monoid.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) f n) v) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (forall (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), (Eq.{succ u2} M (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p) v) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_3))))))))) -> (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) 0 (OfNat.mk.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) 0 (Zero.zero.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (v : M), Iff (LinearIndependent.{0, u1, u2} Nat R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) (fun (n : Nat) => FunLike.coe.{succ u2, succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HPow.hPow.{u2, 0, u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) Nat (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (instHPow.{u2, 0} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) Nat (Monoid.Pow.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.monoid.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) f n) v) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) _inst_3) _inst_4) (forall (p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) (FunLike.coe.{succ u2, succ u2, succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) p) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p) v) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) (NegZeroClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) (SubNegZeroMonoid.toNegZeroClass.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) (SubtractionMonoid.toSubNegZeroMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) (SubtractionCommMonoid.toSubtractionMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) (AddCommGroup.toDivisionAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) v) _inst_3)))))))) -> (Eq.{succ u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) p (OfNat.ofNat.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) 0 (Zero.toOfNat0.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.zero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align polynomial.linear_independent_powers_iff_aeval Polynomial.linearIndependent_powers_iff_aevalₓ'. -/\ntheorem linearIndependent_powers_iff_aeval (f : M →ₗ[R] M) (v : M) :\n    (LinearIndependent R fun n : ℕ => (f ^ n) v) ↔ ∀ p : R[X], aeval f p v = 0 → p = 0 :=\n  by\n  rw [linearIndependent_iff]\n  simp only [Finsupp.total_apply, aeval_endomorphism, forall_iff_forall_finsupp, Sum, support,\n    coeff, of_finsupp_eq_zero]\n  exact Iff.rfl\n#align polynomial.linear_independent_powers_iff_aeval Polynomial.linearIndependent_powers_iff_aeval\n\n#print Polynomial.disjoint_ker_aeval_of_coprime /-\ntheorem disjoint_ker_aeval_of_coprime (f : M →ₗ[R] M) {p q : R[X]} (hpq : IsCoprime p q) :\n    Disjoint (aeval f p).ker (aeval f q).ker :=\n  by\n  rw [disjoint_iff_inf_le]\n  intro v hv\n  rcases hpq with ⟨p', q', hpq'⟩\n  simpa [LinearMap.mem_ker.1 (Submodule.mem_inf.1 hv).1,\n    LinearMap.mem_ker.1 (Submodule.mem_inf.1 hv).2] using\n    congr_arg (fun p : R[X] => aeval f p v) hpq'.symm\n#align polynomial.disjoint_ker_aeval_of_coprime Polynomial.disjoint_ker_aeval_of_coprime\n-/\n\n/- warning: polynomial.sup_aeval_range_eq_top_of_coprime -> Polynomial.sup_aeval_range_eq_top_of_coprime is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (IsCoprime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) p q) -> (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Sup.sup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (SemilatticeSup.toHasSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (LinearMap.range.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (RingHomSurjective.ids.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p)) (LinearMap.range.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (RingHomSurjective.ids.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) q))) (Top.top.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.hasTop.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))\nbut is expected to have type\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (IsCoprime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) p q) -> (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Sup.sup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (SemilatticeSup.toSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (LinearMap.range.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) p) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (RingHomSurjective.ids.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p)) (LinearMap.range.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) q) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (RingHomSurjective.ids.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) q))) (Top.top.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.instTopSubmodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))\nCase conversion may be inaccurate. Consider using '#align polynomial.sup_aeval_range_eq_top_of_coprime Polynomial.sup_aeval_range_eq_top_of_coprimeₓ'. -/\ntheorem sup_aeval_range_eq_top_of_coprime (f : M →ₗ[R] M) {p q : R[X]} (hpq : IsCoprime p q) :\n    (aeval f p).range ⊔ (aeval f q).range = ⊤ :=\n  by\n  rw [eq_top_iff]\n  intro v hv\n  rw [Submodule.mem_sup]\n  rcases hpq with ⟨p', q', hpq'⟩\n  use aeval f (p * p') v\n  use LinearMap.mem_range.2 ⟨aeval f p' v, by simp only [LinearMap.mul_apply, aeval_mul]⟩\n  use aeval f (q * q') v\n  use LinearMap.mem_range.2 ⟨aeval f q' v, by simp only [LinearMap.mul_apply, aeval_mul]⟩\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add] using\n    congr_arg (fun p : R[X] => aeval f p v) hpq'\n#align polynomial.sup_aeval_range_eq_top_of_coprime Polynomial.sup_aeval_range_eq_top_of_coprime\n\n/- warning: polynomial.sup_ker_aeval_le_ker_aeval_mul -> Polynomial.sup_ker_aeval_le_ker_aeval_mul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] {f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4} {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, LE.le.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Preorder.toLE.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (SetLike.partialOrder.{u2, u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) M (Submodule.setLike.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Sup.sup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (SemilatticeSup.toHasSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p)) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) q))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) p q)))\nbut is expected to have type\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] {f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4} {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, LE.le.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Preorder.toLE.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (OmegaCompletePartialOrder.toPartialOrder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (CompleteLattice.instOmegaCompletePartialOrder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Sup.sup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (SemilatticeSup.toSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) p) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p)) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) q) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) q))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) p q)) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) p q)))\nCase conversion may be inaccurate. Consider using '#align polynomial.sup_ker_aeval_le_ker_aeval_mul Polynomial.sup_ker_aeval_le_ker_aeval_mulₓ'. -/\ntheorem sup_ker_aeval_le_ker_aeval_mul {f : M →ₗ[R] M} {p q : R[X]} :\n    (aeval f p).ker ⊔ (aeval f q).ker ≤ (aeval f (p * q)).ker :=\n  by\n  intro v hv\n  rcases Submodule.mem_sup.1 hv with ⟨x, hx, y, hy, hxy⟩\n  have h_eval_x : aeval f (p * q) x = 0 := by\n    rw [mul_comm, aeval_mul, LinearMap.mul_apply, LinearMap.mem_ker.1 hx, LinearMap.map_zero]\n  have h_eval_y : aeval f (p * q) y = 0 := by\n    rw [aeval_mul, LinearMap.mul_apply, LinearMap.mem_ker.1 hy, LinearMap.map_zero]\n  rw [LinearMap.mem_ker, ← hxy, LinearMap.map_add, h_eval_x, h_eval_y, add_zero]\n#align polynomial.sup_ker_aeval_le_ker_aeval_mul Polynomial.sup_ker_aeval_le_ker_aeval_mul\n\n/- warning: polynomial.sup_ker_aeval_eq_ker_aeval_mul_of_coprime -> Polynomial.sup_ker_aeval_eq_ker_aeval_mul_of_coprime is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (IsCoprime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) p q) -> (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Sup.sup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (SemilatticeSup.toHasSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p)) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) q))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) -> (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.End.algebra.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) p q))))\nbut is expected to have type\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_3 : AddCommGroup.{u2} M] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3)] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) {p : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {q : Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))}, (IsCoprime.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.commSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) p q) -> (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Sup.sup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (SemilatticeSup.toSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) p) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) p)) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) q) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) q))) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) p q)) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) => LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (SMulZeroClass.toSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toZero.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribSMul.toSMulZeroClass.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddMonoid.toAddZeroClass.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (AddCommMonoid.toAddMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Module.toDistribMulAction.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Semiring.toNonAssocSemiring.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))) (Algebra.toModule.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Polynomial.algebraOfAlgebra.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4)))))) (Polynomial.aeval.{u1, u2} R (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4 _inst_4) (CommRing.toCommSemiring.{u1} R _inst_1) (Module.End.semiring.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) (Module.instAlgebraEndToSemiringSemiring.{u1, u2} R M (CommRing.toCommSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_3) _inst_4) f) (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHMul.{u1} (Polynomial.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Polynomial.mul'.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) p q))))\nCase conversion may be inaccurate. Consider using '#align polynomial.sup_ker_aeval_eq_ker_aeval_mul_of_coprime Polynomial.sup_ker_aeval_eq_ker_aeval_mul_of_coprimeₓ'. -/\ntheorem sup_ker_aeval_eq_ker_aeval_mul_of_coprime (f : M →ₗ[R] M) {p q : R[X]}\n    (hpq : IsCoprime p q) : (aeval f p).ker ⊔ (aeval f q).ker = (aeval f (p * q)).ker :=\n  by\n  apply le_antisymm sup_ker_aeval_le_ker_aeval_mul\n  intro v hv\n  rw [Submodule.mem_sup]\n  rcases hpq with ⟨p', q', hpq'⟩\n  have h_eval₂_qpp' :=\n    calc\n      aeval f (q * (p * p')) v = aeval f (p' * (p * q)) v := by\n        rw [mul_comm, mul_assoc, mul_comm, mul_assoc, mul_comm q p]\n      _ = 0 := by rw [aeval_mul, LinearMap.mul_apply, LinearMap.mem_ker.1 hv, LinearMap.map_zero]\n      \n  have h_eval₂_pqq' :=\n    calc\n      aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v := by rw [← mul_assoc, mul_comm]\n      _ = 0 := by rw [aeval_mul, LinearMap.mul_apply, LinearMap.mem_ker.1 hv, LinearMap.map_zero]\n      \n  rw [aeval_mul] at h_eval₂_qpp' h_eval₂_pqq'\n  refine'\n    ⟨aeval f (q * q') v, LinearMap.mem_ker.1 h_eval₂_pqq', aeval f (p * p') v,\n      LinearMap.mem_ker.1 h_eval₂_qpp', _⟩\n  rw [add_comm, mul_comm p p', mul_comm q q']\n  simpa only [map_add, map_mul, aeval_one] using congr_arg (fun p : R[X] => aeval f p v) hpq'\n#align polynomial.sup_ker_aeval_eq_ker_aeval_mul_of_coprime Polynomial.sup_ker_aeval_eq_ker_aeval_mul_of_coprime\n\nend Polynomial\n\nnamespace MvPolynomial\n\n#print MvPolynomial.isNoetherianRing_fin_0 /-\ntheorem isNoetherianRing_fin_0 [IsNoetherianRing R] : IsNoetherianRing (MvPolynomial (Fin 0) R) :=\n  isNoetherianRing_of_ringEquiv R\n    ((MvPolynomial.isEmptyRingEquiv R PEmpty).symm.trans\n      (renameEquiv R finZeroEquiv'.symm).toRingEquiv)\n#align mv_polynomial.is_noetherian_ring_fin_0 MvPolynomial.isNoetherianRing_fin_0\n-/\n\n#print MvPolynomial.isNoetherianRing_fin /-\ntheorem isNoetherianRing_fin [IsNoetherianRing R] :\n    ∀ {n : ℕ}, IsNoetherianRing (MvPolynomial (Fin n) R)\n  | 0 => isNoetherianRing_fin_0\n  | n + 1 =>\n    @isNoetherianRing_of_ringEquiv (Polynomial (MvPolynomial (Fin n) R)) _ _ _\n      (MvPolynomial.finSuccEquiv _ n).toRingEquiv.symm\n      (@Polynomial.isNoetherianRing (MvPolynomial (Fin n) R) _ is_noetherian_ring_fin)\n#align mv_polynomial.is_noetherian_ring_fin MvPolynomial.isNoetherianRing_fin\n-/\n\n#print MvPolynomial.isNoetherianRing /-\n/-- The multivariate polynomial ring in finitely many variables over a noetherian ring\nis itself a noetherian ring. -/\ninstance isNoetherianRing [Finite σ] [IsNoetherianRing R] : IsNoetherianRing (MvPolynomial σ R) :=\n  by\n  cases nonempty_fintype σ <;>\n    exact\n      @isNoetherianRing_of_ringEquiv (MvPolynomial (Fin (Fintype.card σ)) R) _ _ _\n        (rename_equiv R (Fintype.equivFin σ).symm).toRingEquiv is_noetherian_ring_fin\n#align mv_polynomial.is_noetherian_ring MvPolynomial.isNoetherianRing\n-/\n\n/- warning: mv_polynomial.no_zero_divisors_fin -> MvPolynomial.noZeroDivisors_fin is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_5 : CommSemiring.{u1} R] [_inst_6 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5)))))] (n : Nat), NoZeroDivisors.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (Distrib.toHasMul.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (NonUnitalNonAssocSemiring.toDistrib.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (Semiring.toNonAssocSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (CommSemiring.toSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (MvPolynomial.commSemiring.{u1, 0} R (Fin n) _inst_5)))))) (MulZeroClass.toHasZero.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (Semiring.toNonAssocSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (CommSemiring.toSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (MvPolynomial.commSemiring.{u1, 0} R (Fin n) _inst_5))))))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_5 : CommSemiring.{u1} R] [_inst_6 : NoZeroDivisors.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5)))) (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_5))] (n : Nat), NoZeroDivisors.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (NonUnitalNonAssocSemiring.toMul.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (Semiring.toNonAssocSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (CommSemiring.toSemiring.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (MvPolynomial.commSemiring.{u1, 0} R (Fin n) _inst_5))))) (CommMonoidWithZero.toZero.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (CommSemiring.toCommMonoidWithZero.{u1} (MvPolynomial.{0, u1} (Fin n) R _inst_5) (MvPolynomial.commSemiring.{u1, 0} R (Fin n) _inst_5)))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.no_zero_divisors_fin MvPolynomial.noZeroDivisors_finₓ'. -/\n/-- Auxiliary lemma:\nMultivariate polynomials over an integral domain\nwith variables indexed by `fin n` form an integral domain.\nThis fact is proven inductively,\nand then used to prove the general case without any finiteness hypotheses.\nSee `mv_polynomial.no_zero_divisors` for the general case. -/\ntheorem noZeroDivisors_fin (R : Type u) [CommSemiring R] [NoZeroDivisors R] :\n    ∀ n : ℕ, NoZeroDivisors (MvPolynomial (Fin n) R)\n  | 0 => (MvPolynomial.isEmptyAlgEquiv R _).Injective.NoZeroDivisors _ (map_zero _) (map_mul _)\n  | n + 1 =>\n    haveI := no_zero_divisors_fin n\n    (MvPolynomial.finSuccEquiv R n).Injective.NoZeroDivisors _ (map_zero _) (map_mul _)\n#align mv_polynomial.no_zero_divisors_fin MvPolynomial.noZeroDivisors_fin\n\n/- warning: mv_polynomial.no_zero_divisors_of_finite -> MvPolynomial.noZeroDivisors_of_finite is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (σ : Type.{u2}) [_inst_5 : CommSemiring.{u1} R] [_inst_6 : Finite.{succ u2} σ] [_inst_7 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5))))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5)))))], NoZeroDivisors.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (Distrib.toHasMul.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_5)))))) (MulZeroClass.toHasZero.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_5))))))\nbut is expected to have type\n  forall (R : Type.{u1}) (σ : Type.{u2}) [_inst_5 : CommSemiring.{u1} R] [_inst_6 : Finite.{succ u2} σ] [_inst_7 : NoZeroDivisors.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_5)))) (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_5))], NoZeroDivisors.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_5) (NonUnitalNonAssocSemiring.toMul.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_5) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_5) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_5))))) (CommMonoidWithZero.toZero.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_5) (CommSemiring.toCommMonoidWithZero.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_5)))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.no_zero_divisors_of_finite MvPolynomial.noZeroDivisors_of_finiteₓ'. -/\n/-- Auxiliary definition:\nMultivariate polynomials in finitely many variables over an integral domain form an integral domain.\nThis fact is proven by transport of structure from the `mv_polynomial.no_zero_divisors_fin`,\nand then used to prove the general case without finiteness hypotheses.\nSee `mv_polynomial.no_zero_divisors` for the general case. -/\ntheorem noZeroDivisors_of_finite (R : Type u) (σ : Type v) [CommSemiring R] [Finite σ]\n    [NoZeroDivisors R] : NoZeroDivisors (MvPolynomial σ R) :=\n  by\n  cases nonempty_fintype σ\n  haveI := no_zero_divisors_fin R (Fintype.card σ)\n  exact (rename_equiv R (Fintype.equivFin σ)).Injective.NoZeroDivisors _ (map_zero _) (map_mul _)\n#align mv_polynomial.no_zero_divisors_of_finite MvPolynomial.noZeroDivisors_of_finite\n\ninstance {R : Type u} [CommSemiring R] [NoZeroDivisors R] {σ : Type v} :\n    NoZeroDivisors (MvPolynomial σ R) :=\n  ⟨fun p q h => by\n    obtain ⟨s, p, rfl⟩ := exists_finset_rename p\n    obtain ⟨t, q, rfl⟩ := exists_finset_rename q\n    have :\n      rename (Subtype.map id (Finset.subset_union_left s t) : { x // x ∈ s } → { x // x ∈ s ∪ t })\n            p *\n          rename\n            (Subtype.map id (Finset.subset_union_right s t) : { x // x ∈ t } → { x // x ∈ s ∪ t })\n            q =\n        0 :=\n      by\n      apply rename_injective _ Subtype.val_injective\n      simpa using h\n    letI := MvPolynomial.noZeroDivisors_of_finite R { x // x ∈ s ∪ t }\n    rw [mul_eq_zero] at this\n    cases this <;> [left, right]\n    all_goals simpa using congr_arg (rename Subtype.val) this⟩\n\n/-- The multivariate polynomial ring over an integral domain is an integral domain. -/\ninstance {R : Type u} {σ : Type v} [CommRing R] [IsDomain R] : IsDomain (MvPolynomial σ R) :=\n  by\n  apply NoZeroDivisors.to_isDomain _\n  exact AddMonoidAlgebra.nontrivial\n  exact MvPolynomial.noZeroDivisors\n\n/- warning: mv_polynomial.map_mv_polynomial_eq_eval₂ -> MvPolynomial.map_mvPolynomial_eq_eval₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {σ : Type.{u2}} [_inst_1 : CommRing.{u1} R] {S : Type.{u3}} [_inst_5 : CommRing.{u3} S] [_inst_6 : Finite.{succ u2} σ] (ϕ : RingHom.{max u2 u1, u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) (p : MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)), Eq.{succ u3} S (coeFn.{max (succ (max u2 u1)) (succ u3), max (succ (max u2 u1)) (succ u3)} (RingHom.{max u2 u1, u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) (fun (_x : RingHom.{max u2 u1, u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) => (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) -> S) (RingHom.hasCoeToFun.{max u2 u1, u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) ϕ p) (MvPolynomial.eval₂.{u1, u3, u2} R S σ (CommRing.toCommSemiring.{u1} R _inst_1) (CommRing.toCommSemiring.{u3} S _inst_5) (RingHom.comp.{u1, max u2 u1, u3} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5))) ϕ (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (s : σ) => coeFn.{max (succ (max u2 u1)) (succ u3), max (succ (max u2 u1)) (succ u3)} (RingHom.{max u2 u1, u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) (fun (_x : RingHom.{max u2 u1, u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) => (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) -> S) (RingHom.hasCoeToFun.{max u2 u1, u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) ϕ (MvPolynomial.X.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1) s)) p)\nbut is expected to have type\n  forall {R : Type.{u2}} {σ : Type.{u3}} [_inst_1 : CommRing.{u2} R] {S : Type.{u1}} [_inst_5 : CommRing.{u1} S] [_inst_6 : Finite.{succ u3} σ] (ϕ : RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (p : MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) => S) p) (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (succ u2) (succ u3), succ u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (fun (_x : MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) => S) _x) (MulHomClass.toFunLike.{max (max u2 u3) u1, max u2 u3, u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonUnitalNonAssocSemiring.toMul.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))))) (NonUnitalRingHomClass.toMulHomClass.{max (max u2 u3) u1, max u2 u3, u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (RingHomClass.toNonUnitalRingHomClass.{max (max u2 u3) u1, max u2 u3, u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))) (RingHom.instRingHomClassRingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))))))) ϕ p) (MvPolynomial.eval₂.{u2, u1, u3} R S σ (CommRing.toCommSemiring.{u2} R _inst_1) (CommRing.toCommSemiring.{u1} S _inst_5) (RingHom.comp.{u2, max u2 u3, u1} R (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))) ϕ (MvPolynomial.C.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1))) (fun (s : σ) => FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (succ u2) (succ u3), succ u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (fun (_x : MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) => S) _x) (MulHomClass.toFunLike.{max (max u2 u3) u1, max u2 u3, u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonUnitalNonAssocSemiring.toMul.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))))) (NonUnitalRingHomClass.toMulHomClass.{max (max u2 u3) u1, max u2 u3, u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (RingHomClass.toNonUnitalRingHomClass.{max (max u2 u3) u1, max u2 u3, u1} (RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))) (RingHom.instRingHomClassRingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R σ _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))))))) ϕ (MvPolynomial.X.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1) s)) p)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.map_mv_polynomial_eq_eval₂ MvPolynomial.map_mvPolynomial_eq_eval₂ₓ'. -/\ntheorem map_mvPolynomial_eq_eval₂ {S : Type _} [CommRing S] [Finite σ] (ϕ : MvPolynomial σ R →+* S)\n    (p : MvPolynomial σ R) :\n    ϕ p = MvPolynomial.eval₂ (ϕ.comp MvPolynomial.C) (fun s => ϕ (MvPolynomial.X s)) p :=\n  by\n  cases nonempty_fintype σ\n  refine' trans (congr_arg ϕ (MvPolynomial.as_sum p)) _\n  rw [MvPolynomial.eval₂_eq', ϕ.map_sum]\n  congr\n  ext\n  simp only [monomial_eq, ϕ.map_pow, ϕ.map_prod, ϕ.comp_apply, ϕ.map_mul, Finsupp.prod_pow]\n#align mv_polynomial.map_mv_polynomial_eq_eval₂ MvPolynomial.map_mvPolynomial_eq_eval₂\n\n/- warning: mv_polynomial.mem_ideal_of_coeff_mem_ideal -> MvPolynomial.mem_ideal_of_coeff_mem_ideal is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {σ : Type.{u2}} [_inst_1 : CommRing.{u1} R] (I : Ideal.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (p : MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)), (forall (m : Finsupp.{u2, 0} σ Nat Nat.hasZero), Membership.Mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.coeff.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1) m p) (Ideal.comap.{u1, max u2 u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1))) (RingHom.ringHomClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)) I)) -> (Membership.Mem.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (SetLike.hasMem.{max u2 u1, max u2 u1} (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))))) (Semiring.toModule.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))))) p I)\nbut is expected to have type\n  forall {R : Type.{u1}} {σ : Type.{u2}} [_inst_1 : CommRing.{u1} R] (I : Ideal.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))) (p : MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)), (forall (m : Finsupp.{u2, 0} σ Nat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero)), Membership.mem.{u1, u1} R (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) R (Submodule.setLike.{u1, u1} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.coeff.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1) m p) (Ideal.comap.{u1, max u1 u2, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1))) (RingHom.instRingHomClassRingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)) I)) -> (Membership.mem.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))) (SetLike.instMembership.{max u1 u2, max u1 u2} (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))))) (Semiring.toModule.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))))) p I)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.mem_ideal_of_coeff_mem_ideal MvPolynomial.mem_ideal_of_coeff_mem_idealₓ'. -/\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself,\nmultivariate version. -/\ntheorem mem_ideal_of_coeff_mem_ideal (I : Ideal (MvPolynomial σ R)) (p : MvPolynomial σ R)\n    (hcoe : ∀ m : σ →₀ ℕ, p.coeff m ∈ I.comap (C : R →+* MvPolynomial σ R)) : p ∈ I :=\n  by\n  rw [as_sum p]\n  suffices ∀ m ∈ p.support, monomial m (MvPolynomial.coeff m p) ∈ I by\n    exact Submodule.sum_mem I this\n  intro m hm\n  rw [← mul_one (coeff m p), ← C_mul_monomial]\n  suffices C (coeff m p) ∈ I by exact I.mul_mem_right (monomial m 1) this\n  simpa [Ideal.mem_comap] using hcoe m\n#align mv_polynomial.mem_ideal_of_coeff_mem_ideal MvPolynomial.mem_ideal_of_coeff_mem_ideal\n\n/- warning: mv_polynomial.mem_map_C_iff -> MvPolynomial.mem_map_C_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {σ : Type.{u2}} [_inst_1 : CommRing.{u1} R] {I : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {f : MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)}, Iff (Membership.Mem.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (SetLike.hasMem.{max u2 u1, max u2 u1} (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))))) (Semiring.toModule.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1)))))) f (Ideal.map.{u1, max u2 u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R σ _inst_1))) (RingHom.ringHomClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)) I)) (forall (m : Finsupp.{u2, 0} σ Nat Nat.hasZero), Membership.Mem.{u1, u1} R (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) R (Submodule.setLike.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (MvPolynomial.coeff.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1) m f) I)\nbut is expected to have type\n  forall {R : Type.{u1}} {σ : Type.{u2}} [_inst_1 : CommRing.{u1} R] {I : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))} {f : MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)}, Iff (Membership.mem.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))) (SetLike.instMembership.{max u1 u2, max u1 u2} (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))))) (Semiring.toModule.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1)))))) f (Ideal.map.{u1, max u1 u2, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R σ _inst_1))) (RingHom.instRingHomClassRingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)) I)) (forall (m : Finsupp.{u2, 0} σ Nat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero)), Membership.mem.{u1, u1} R (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) R (Submodule.setLike.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (MvPolynomial.coeff.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1) m f) I)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.mem_map_C_iff MvPolynomial.mem_map_C_iffₓ'. -/\n/-- The push-forward of an ideal `I` of `R` to `mv_polynomial σ R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : Ideal R} {f : MvPolynomial σ R} :\n    f ∈ (Ideal.map (C : R →+* MvPolynomial σ R) I : Ideal (MvPolynomial σ R)) ↔\n      ∀ m : σ →₀ ℕ, f.coeff m ∈ I :=\n  by\n  constructor\n  · intro hf\n    apply Submodule.span_induction hf\n    · intro f hf n\n      cases' (Set.mem_image _ _ _).mp hf with x hx\n      rw [← hx.right, coeff_C]\n      by_cases n = 0\n      · simpa [h] using hx.left\n      · simp [Ne.symm h]\n    · simp\n    · exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]\n    · refine' fun f g hg n => _\n      rw [smul_eq_mul, coeff_mul]\n      exact I.sum_mem fun c hc => I.mul_mem_left (f.coeff c.fst) (hg c.snd)\n  · intro hf\n    rw [as_sum f]\n    suffices ∀ m ∈ f.support, monomial m (coeff m f) ∈ (Ideal.map C I : Ideal (MvPolynomial σ R)) by\n      exact Submodule.sum_mem _ this\n    intro m hm\n    rw [← mul_one (coeff m f), ← C_mul_monomial]\n    suffices C (coeff m f) ∈ (Ideal.map C I : Ideal (MvPolynomial σ R)) by\n      exact Ideal.mul_mem_right _ _ this\n    apply Ideal.mem_map_of_mem _\n    exact hf m\n#align mv_polynomial.mem_map_C_iff MvPolynomial.mem_map_C_iff\n\n/- warning: mv_polynomial.ker_map -> MvPolynomial.ker_map is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u3}} {σ : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_2 : CommRing.{u3} S] (f : RingHom.{u1, u3} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_2)))), Eq.{succ (max u2 u1)} (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)))) (RingHom.ker.{max u2 u1, max u2 u3, max (max u2 u1) u2 u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (RingHom.{max u2 u1, max u2 u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (MvPolynomial.commSemiring.{u3, u2} S σ (CommRing.toCommSemiring.{u3} S _inst_2))))) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (MvPolynomial.commSemiring.{u3, u2} S σ (CommRing.toCommSemiring.{u3} S _inst_2))) (RingHom.ringHomClass.{max u2 u1, max u2 u3} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ S (CommRing.toCommSemiring.{u3} S _inst_2)) (MvPolynomial.commSemiring.{u3, u2} S σ (CommRing.toCommSemiring.{u3} S _inst_2))))) (MvPolynomial.map.{u1, u3, u2} R S σ (CommRing.toCommSemiring.{u1} R _inst_1) (CommRing.toCommSemiring.{u3} S _inst_2) f)) (Ideal.map.{u1, max u2 u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))) (RingHom.ringHomClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R σ (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.ker.{u1, u3, max u1 u3} R S (RingHom.{u1, u3} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_2)))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{u3} S (CommRing.toRing.{u3} S _inst_2)) (RingHom.ringHomClass.{u1, u3} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_2)))) f))\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} {σ : Type.{u3}} [_inst_1 : CommRing.{u2} R] [_inst_2 : CommRing.{u1} S] (f : RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} S (Ring.toSemiring.{u1} S (CommRing.toRing.{u1} S _inst_2)))), Eq.{max (succ u2) (succ u3)} (Ideal.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1)))) (RingHom.ker.{max u2 u3, max u3 u1, max (max u2 u3) u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (RingHom.{max u2 u3, max u1 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (MvPolynomial.commSemiring.{u1, u3} S σ (CommRing.toCommSemiring.{u1} S _inst_2))))) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1))) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (MvPolynomial.commSemiring.{u1, u3} S σ (CommRing.toCommSemiring.{u1} S _inst_2))) (RingHom.instRingHomClassRingHom.{max u2 u3, max u3 u1} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u3, u1} σ S (CommRing.toCommSemiring.{u1} S _inst_2)) (MvPolynomial.commSemiring.{u1, u3} S σ (CommRing.toCommSemiring.{u1} S _inst_2))))) (MvPolynomial.map.{u2, u1, u3} R S σ (CommRing.toCommSemiring.{u2} R _inst_1) (CommRing.toCommSemiring.{u1} S _inst_2) f)) (Ideal.map.{u2, max u2 u3, max u2 u3} R (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.{u2, max u2 u3} R (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1))))) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1))) (RingHom.instRingHomClassRingHom.{u2, max u2 u3} R (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} σ R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1))))) (MvPolynomial.C.{u2, u3} R σ (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.ker.{u2, u1, max u2 u1} R S (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} S (Ring.toSemiring.{u1} S (CommRing.toRing.{u1} S _inst_2)))) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1)) (Ring.toSemiring.{u1} S (CommRing.toRing.{u1} S _inst_2)) (RingHom.instRingHomClassRingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} S (Ring.toSemiring.{u1} S (CommRing.toRing.{u1} S _inst_2)))) f))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.ker_map MvPolynomial.ker_mapₓ'. -/\ntheorem ker_map (f : R →+* S) :\n    (map f : MvPolynomial σ R →+* MvPolynomial σ S).ker = f.ker.map (C : R →+* MvPolynomial σ R) :=\n  by\n  ext\n  rw [MvPolynomial.mem_map_C_iff, RingHom.mem_ker, MvPolynomial.ext_iff]\n  simp_rw [coeff_map, coeff_zero, RingHom.mem_ker]\n#align mv_polynomial.ker_map MvPolynomial.ker_map\n\nend MvPolynomial\n\nsection UniqueFactorizationDomain\n\nvariable {D : Type u} [CommRing D] [IsDomain D] [UniqueFactorizationMonoid D] (σ)\n\nopen UniqueFactorizationMonoid\n\nnamespace Polynomial\n\n#print Polynomial.uniqueFactorizationMonoid /-\ninstance (priority := 100) uniqueFactorizationMonoid : UniqueFactorizationMonoid D[X] :=\n  by\n  haveI := Inhabited.default (NormalizationMonoid D)\n  haveI := to_normalized_gcd_monoid D\n  exact ufm_of_gcd_of_wfDvdMonoid\n#align polynomial.unique_factorization_monoid Polynomial.uniqueFactorizationMonoid\n-/\n\nend Polynomial\n\nnamespace MvPolynomial\n\nprivate theorem unique_factorization_monoid_of_fintype [Fintype σ] :\n    UniqueFactorizationMonoid (MvPolynomial σ D) :=\n  (renameEquiv D (Fintype.equivFin σ)).toMulEquiv.symm.UniqueFactorizationMonoid <|\n    by\n    induction' Fintype.card σ with d hd\n    · apply (is_empty_alg_equiv D (Fin 0)).toMulEquiv.symm.UniqueFactorizationMonoid\n      infer_instance\n    · apply (finSuccEquiv D d).toMulEquiv.symm.UniqueFactorizationMonoid\n      exact Polynomial.uniqueFactorizationMonoid\n#align mv_polynomial.unique_factorization_monoid_of_fintype mv_polynomial.unique_factorization_monoid_of_fintype\n\ninstance (priority := 100) : UniqueFactorizationMonoid (MvPolynomial σ D) :=\n  by\n  rw [iff_exists_prime_factors]\n  intro a ha; obtain ⟨s, a', rfl⟩ := exists_finset_rename a\n  obtain ⟨w, h, u, hw⟩ :=\n    iff_exists_prime_factors.1 (unique_factorization_monoid_of_fintype s) a' fun h =>\n      ha <| by simp [h]\n  exact\n    ⟨w.map (rename coe), fun b hb =>\n      let ⟨b', hb', he⟩ := Multiset.mem_map.1 hb\n      he ▸ (prime_rename_iff ↑s).2 (h b' hb'),\n      Units.map (@rename s σ D _ coe).toRingHom.toMonoidHom u, by\n      erw [Multiset.prod_hom, ← map_mul, hw]⟩\n\nend MvPolynomial\n\nend UniqueFactorizationDomain\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/Polynomial/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.49513822912491706}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad\n\n! This file was ported from Lean 3 source module data.int.dvd.basic\n! leanprover-community/mathlib commit e1bccd6e40ae78370f01659715d3c948716e3b7e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Int.Order.Basic\nimport Mathbin.Data.Nat.Cast.Basic\n\n/-!\n# Basic lemmas about the divisibility relation in `ℤ`.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nopen Nat\n\nnamespace Int\n\n/- warning: int.coe_nat_dvd -> Int.coe_nat_dvd is a dubious translation:\nlean 3 declaration is\n  forall {m : Nat} {n : Nat}, Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)) (Dvd.Dvd.{0} Nat Nat.hasDvd m n)\nbut is expected to have type\n  forall {m : Nat} {n : Nat}, Iff (Dvd.dvd.{0} Int Int.instDvdInt (Nat.cast.{0} Int instNatCastInt m) (Nat.cast.{0} Int instNatCastInt n)) (Dvd.dvd.{0} Nat Nat.instDvdNat m n)\nCase conversion may be inaccurate. Consider using '#align int.coe_nat_dvd Int.coe_nat_dvdₓ'. -/\n@[norm_cast]\ntheorem coe_nat_dvd {m n : ℕ} : (↑m : ℤ) ∣ ↑n ↔ m ∣ n :=\n  ⟨fun ⟨a, ae⟩ =>\n    m.eq_zero_or_pos.elim (fun m0 => by simp [m0] at ae <;> simp [ae, m0]) fun m0l =>\n      by\n      cases'\n        eq_coe_of_zero_le\n          (@nonneg_of_mul_nonneg_right ℤ _ m a (by simp [ae.symm]) (by simpa using m0l)) with\n        k e\n      subst a\n      exact ⟨k, Int.ofNat.inj ae⟩,\n    fun ⟨k, e⟩ => Dvd.intro k <| by rw [e, Int.ofNat_mul]⟩\n#align int.coe_nat_dvd Int.coe_nat_dvd\n\n/- warning: int.coe_nat_dvd_left -> Int.coe_nat_dvd_left is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {z : Int}, Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n) z) (Dvd.Dvd.{0} Nat Nat.hasDvd n (Int.natAbs z))\nbut is expected to have type\n  forall {n : Nat} {z : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt (Nat.cast.{0} Int instNatCastInt n) z) (Dvd.dvd.{0} Nat Nat.instDvdNat n (Int.natAbs z))\nCase conversion may be inaccurate. Consider using '#align int.coe_nat_dvd_left Int.coe_nat_dvd_leftₓ'. -/\ntheorem coe_nat_dvd_left {n : ℕ} {z : ℤ} : (↑n : ℤ) ∣ z ↔ n ∣ z.natAbs := by\n  rcases nat_abs_eq z with (eq | eq) <;> rw [Eq] <;> simp [← coe_nat_dvd]\n#align int.coe_nat_dvd_left Int.coe_nat_dvd_left\n\n/- warning: int.coe_nat_dvd_right -> Int.coe_nat_dvd_right is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {z : Int}, Iff (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) z ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) n)) (Dvd.Dvd.{0} Nat Nat.hasDvd (Int.natAbs z) n)\nbut is expected to have type\n  forall {n : Nat} {z : Int}, Iff (Dvd.dvd.{0} Int Int.instDvdInt z (Nat.cast.{0} Int instNatCastInt n)) (Dvd.dvd.{0} Nat Nat.instDvdNat (Int.natAbs z) n)\nCase conversion may be inaccurate. Consider using '#align int.coe_nat_dvd_right Int.coe_nat_dvd_rightₓ'. -/\ntheorem coe_nat_dvd_right {n : ℕ} {z : ℤ} : z ∣ (↑n : ℤ) ↔ z.natAbs ∣ n := by\n  rcases nat_abs_eq z with (eq | eq) <;> rw [Eq] <;> simp [← coe_nat_dvd]\n#align int.coe_nat_dvd_right Int.coe_nat_dvd_right\n\n/- warning: int.le_of_dvd -> Int.le_of_dvd is a dubious translation:\nlean 3 declaration is\n  forall {a : Int} {b : Int}, (LT.lt.{0} Int Int.hasLt (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) b) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b) -> (LE.le.{0} Int Int.hasLe a b)\nbut is expected to have type\n  forall {a : Int} {b : Int}, (LT.lt.{0} Int Int.instLTInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) b) -> (Dvd.dvd.{0} Int Int.instDvdInt a b) -> (LE.le.{0} Int Int.instLEInt a b)\nCase conversion may be inaccurate. Consider using '#align int.le_of_dvd Int.le_of_dvdₓ'. -/\ntheorem le_of_dvd {a b : ℤ} (bpos : 0 < b) (H : a ∣ b) : a ≤ b :=\n  match a, b, eq_succ_of_zero_lt bpos, H with\n  | (m : ℕ), _, ⟨n, rfl⟩, H => ofNat_le_ofNat_of_le <| Nat.le_of_dvd n.succ_pos <| coe_nat_dvd.1 H\n  | -[m+1], _, ⟨n, rfl⟩, _ => le_trans (le_of_lt <| negSucc_lt_zero _) (ofNat_zero_le _)\n#align int.le_of_dvd Int.le_of_dvd\n\n/- warning: int.eq_one_of_dvd_one -> Int.eq_one_of_dvd_one is a dubious translation:\nlean 3 declaration is\n  forall {a : Int}, (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) a) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) -> (Eq.{1} Int a (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))))\nbut is expected to have type\n  forall {a : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) a) -> (Dvd.dvd.{0} Int Int.instDvdInt a (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) -> (Eq.{1} Int a (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))\nCase conversion may be inaccurate. Consider using '#align int.eq_one_of_dvd_one Int.eq_one_of_dvd_oneₓ'. -/\ntheorem eq_one_of_dvd_one {a : ℤ} (H : 0 ≤ a) (H' : a ∣ 1) : a = 1 :=\n  match a, eq_ofNat_of_zero_le H, H' with\n  | _, ⟨n, rfl⟩, H' => congr_arg coe <| Nat.eq_one_of_dvd_one <| coe_nat_dvd.1 H'\n#align int.eq_one_of_dvd_one Int.eq_one_of_dvd_one\n\n#print Int.eq_one_of_mul_eq_one_right /-\ntheorem eq_one_of_mul_eq_one_right {a b : ℤ} (H : 0 ≤ a) (H' : a * b = 1) : a = 1 :=\n  eq_one_of_dvd_one H ⟨b, H'.symm⟩\n#align int.eq_one_of_mul_eq_one_right Int.eq_one_of_mul_eq_one_right\n-/\n\n#print Int.eq_one_of_mul_eq_one_left /-\ntheorem eq_one_of_mul_eq_one_left {a b : ℤ} (H : 0 ≤ b) (H' : a * b = 1) : b = 1 :=\n  eq_one_of_mul_eq_one_right H (by rw [mul_comm, H'])\n#align int.eq_one_of_mul_eq_one_left Int.eq_one_of_mul_eq_one_left\n-/\n\n/- warning: int.of_nat_dvd_of_dvd_nat_abs -> Int.ofNat_dvd_of_dvd_natAbs is a dubious translation:\nlean 3 declaration is\n  forall {a : Nat} {z : Int}, (Dvd.Dvd.{0} Nat Nat.hasDvd a (Int.natAbs z)) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) a) z)\nbut is expected to have type\n  forall {a : Nat} {z : Int}, (Dvd.dvd.{0} Nat Nat.instDvdNat a (Int.natAbs z)) -> (Dvd.dvd.{0} Int Int.instDvdInt (Nat.cast.{0} Int instNatCastInt a) z)\nCase conversion may be inaccurate. Consider using '#align int.of_nat_dvd_of_dvd_nat_abs Int.ofNat_dvd_of_dvd_natAbsₓ'. -/\ntheorem ofNat_dvd_of_dvd_natAbs {a : ℕ} : ∀ {z : ℤ} (haz : a ∣ z.natAbs), ↑a ∣ z\n  | Int.ofNat _, haz => Int.coe_nat_dvd.2 haz\n  | -[k+1], haz => by\n    change ↑a ∣ -(k + 1 : ℤ)\n    apply dvd_neg_of_dvd\n    apply Int.coe_nat_dvd.2\n    exact haz\n#align int.of_nat_dvd_of_dvd_nat_abs Int.ofNat_dvd_of_dvd_natAbs\n\n/- warning: int.dvd_nat_abs_of_of_nat_dvd -> Int.dvd_natAbs_of_ofNat_dvd is a dubious translation:\nlean 3 declaration is\n  forall {a : Nat} {z : Int}, (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) a) z) -> (Dvd.Dvd.{0} Nat Nat.hasDvd a (Int.natAbs z))\nbut is expected to have type\n  forall {a : Nat} {z : Int}, (Dvd.dvd.{0} Int Int.instDvdInt (Nat.cast.{0} Int instNatCastInt a) z) -> (Dvd.dvd.{0} Nat Nat.instDvdNat a (Int.natAbs z))\nCase conversion may be inaccurate. Consider using '#align int.dvd_nat_abs_of_of_nat_dvd Int.dvd_natAbs_of_ofNat_dvdₓ'. -/\ntheorem dvd_natAbs_of_ofNat_dvd {a : ℕ} : ∀ {z : ℤ} (haz : ↑a ∣ z), a ∣ z.natAbs\n  | Int.ofNat _, haz => Int.coe_nat_dvd.1 (Int.dvd_natAbs.2 haz)\n  | -[k+1], haz =>\n    have haz' : (↑a : ℤ) ∣ (↑(k + 1) : ℤ) := dvd_of_dvd_neg haz\n    Int.coe_nat_dvd.1 haz'\n#align int.dvd_nat_abs_of_of_nat_dvd Int.dvd_natAbs_of_ofNat_dvd\n\n/- warning: int.dvd_antisymm -> Int.dvd_antisymm is a dubious translation:\nlean 3 declaration is\n  forall {a : Int} {b : Int}, (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) a) -> (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) b) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) a b) -> (Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) b a) -> (Eq.{1} Int a b)\nbut is expected to have type\n  forall {a : Int} {b : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) a) -> (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) b) -> (Dvd.dvd.{0} Int Int.instDvdInt a b) -> (Dvd.dvd.{0} Int Int.instDvdInt b a) -> (Eq.{1} Int a b)\nCase conversion may be inaccurate. Consider using '#align int.dvd_antisymm Int.dvd_antisymmₓ'. -/\ntheorem dvd_antisymm {a b : ℤ} (H1 : 0 ≤ a) (H2 : 0 ≤ b) : a ∣ b → b ∣ a → a = b :=\n  by\n  rw [← abs_of_nonneg H1, ← abs_of_nonneg H2, abs_eq_nat_abs, abs_eq_nat_abs]\n  rw [coe_nat_dvd, coe_nat_dvd, coe_nat_inj']\n  apply Nat.dvd_antisymm\n#align int.dvd_antisymm Int.dvd_antisymm\n\nend Int\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Int/Dvd/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4950880248861989}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport control.random\nimport control.uliftable\n\n/-!\n# `gen` Monad\n\nThis monad is used to formulate randomized computations with a parameter\nto specify the desired size of the result.\n\nThis is a port of the Haskell QuickCheck library.\n\n## Main definitions\n  * `gen` monad\n\n## Local notation\n\n * `i .. j` : `Icc i j`, the set of values between `i` and `j` inclusively;\n\n## Tags\n\nrandom testing\n\n## References\n\n  * https://hackage.haskell.org/package/QuickCheck\n\n-/\n\nuniverses u v\n\nnamespace slim_check\n\n/-- Monad to generate random examples to test properties with.\nIt has a `nat` parameter so that the caller can decide on the\nsize of the examples. -/\n@[reducible, derive [monad, is_lawful_monad]]\ndef gen (α : Type u) := reader_t (ulift ℕ) rand α\n\nvariable (α : Type u)\n\nlocal infix ` .. `:41 := set.Icc\n\n/-- Execute a `gen` inside the `io` monad using `i` as the example\nsize and with a fresh random number generator. -/\ndef io.run_gen {α} (x : gen α) (i : ℕ) : io α :=\nio.run_rand (x.run ⟨i⟩)\n\nnamespace gen\n\nsection rand\n\n/-- Lift `random.random` to the `gen` monad. -/\ndef choose_any [random α] : gen α :=\n⟨ λ _, rand.random α ⟩\n\nvariables {α} [preorder α]\n\n/-- Lift `random.random_r` to the `gen` monad. -/\ndef choose [bounded_random α] (x y : α) (p : x ≤ y) : gen (x .. y) :=\n⟨ λ _, rand.random_r x y p ⟩\n\nend rand\n\nopen nat (hiding choose)\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat (x y : ℕ) (p : x ≤ y) : gen (x .. y) :=\nchoose x y p\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat' (x y : ℕ) (p : x < y) : gen (set.Ico x y) :=\nhave ∀ i, x < i → i ≤ y → i.pred < y,\n  from λ i h₀ h₁,\n     show i.pred.succ ≤ y,\n     by rwa succ_pred_eq_of_pos; apply lt_of_le_of_lt (nat.zero_le _) h₀,\nsubtype.map pred (λ i (h : x+1 ≤ i ∧ i ≤ y), ⟨le_pred_of_lt h.1, this _ h.1 h.2⟩) <$>\n  choose (x+1) y p\n\nopen nat\n\ninstance : uliftable gen.{u} gen.{v} :=\nreader_t.uliftable' (equiv.ulift.trans equiv.ulift.symm)\n\ninstance : has_orelse gen.{u} :=\n⟨ λ α x y, do\n  b ← uliftable.up $ choose_any bool,\n  if b.down then x else y ⟩\n\nvariable {α}\n\n/-- Get access to the size parameter of the `gen` monad. For\nreasons of universe polymorphism, it is specified in\ncontinuation passing style. -/\ndef sized (cmd : ℕ → gen α) : gen α :=\n⟨ λ ⟨sz⟩, reader_t.run (cmd sz) ⟨sz⟩ ⟩\n\n/-- Apply a function to the size parameter. -/\ndef resize (f : ℕ → ℕ) (cmd : gen α) : gen α :=\n⟨ λ ⟨sz⟩, reader_t.run cmd ⟨f sz⟩ ⟩\n\n/-- Create `n` examples using `cmd`. -/\ndef vector_of : ∀ (n : ℕ) (cmd : gen α), gen (vector α n)\n| 0 _ := return vector.nil\n| (succ n) cmd := vector.cons <$> cmd <*> vector_of n cmd\n\n/-- Create a list of examples using `cmd`. The size is controlled\nby the size parameter of `gen`. -/\ndef list_of (cmd : gen α) : gen (list α) :=\nsized $ λ sz, do\ndo ⟨ n ⟩ ← uliftable.up $ choose_nat 0 (sz + 1) dec_trivial,\n   v ← vector_of n.val cmd,\n   return v.to_list\n\nopen ulift\n\n/-- Given a list of example generators, choose one to create an example. -/\ndef one_of (xs : list (gen α)) (pos : 0 < xs.length) : gen α := do\n⟨⟨n, h, h'⟩⟩ ← uliftable.up $ choose_nat' 0 xs.length pos,\nlist.nth_le xs n h'\n\n/-- Given a list of example generators, choose one to create an example. -/\ndef elements (xs : list α) (pos : 0 < xs.length) : gen α := do\n⟨⟨n,h₀,h₁⟩⟩ ← uliftable.up $ choose_nat' 0 xs.length pos,\npure $ list.nth_le xs n h₁\n\n/--\n`freq_aux xs i _` takes a weighted list of generator and a number meant to select one of the\ngenerators.\n\nIf we consider `freq_aux [(1, gena), (3, genb), (5, genc)] 4 _`, we choose a generator by splitting\nthe interval 1-9 into 1-1, 2-4, 5-9 so that the width of each interval corresponds to one of the\nnumber in the list of generators. Then, we check which interval 4 falls into: it selects `genb`.\n-/\ndef freq_aux : Π (xs : list (ℕ+ × gen α)) i, i < (xs.map (subtype.val ∘ prod.fst)).sum → gen α\n| [] i h := false.elim (nat.not_lt_zero _ h)\n| ((i, x) :: xs) j h :=\n  if h' : j < i then x\n  else freq_aux xs (j - i)\n    (by { rw tsub_lt_iff_right (le_of_not_gt h'),\n      simpa [list.sum_cons, add_comm] using h })\n\n/--\n`freq [(1, gena), (3, genb), (5, genc)] _` will choose one of `gena`, `genb`, `genc` with\nprobabilities proportional to the number accompanying them. In this example, the sum of\nthose numbers is 9, `gena` will be chosen with probability ~1/9, `genb` with ~3/9 (i.e. 1/3)\nand `genc` with probability 5/9.\n-/\ndef freq (xs : list (ℕ+ × gen α)) (pos : 0 < xs.length) : gen α :=\nlet s := (xs.map (subtype.val ∘ prod.fst)).sum in\nhave ha : 1 ≤ s, from\n  (le_trans pos $\n    list.length_map (subtype.val ∘ prod.fst) xs ▸\n      (list.length_le_sum_of_one_le _ (λ i, by { simp, intros, assumption }))),\nhave 0 ≤ s - 1, from le_tsub_of_add_le_right ha,\nuliftable.adapt_up gen.{0} gen.{u} (choose_nat 0 (s-1) this) $ λ i,\nfreq_aux xs i.1 (by rcases i with ⟨i,h₀,h₁⟩; rwa le_tsub_iff_right at h₁; exact ha)\n\n/-- Generate a random permutation of a given list. -/\ndef permutation_of {α : Type u} : Π xs : list α, gen (subtype $ list.perm xs)\n| [] := pure ⟨[], list.perm.nil ⟩\n| (x :: xs) := do\n⟨xs',h⟩ ← permutation_of xs,\n⟨⟨n,_,h'⟩⟩ ← uliftable.up $ choose_nat 0 xs'.length dec_trivial,\npure ⟨list.insert_nth n x xs',\n  list.perm.trans (list.perm.cons _ h)\n    (list.perm_insert_nth _ _ h').symm ⟩\n\nend gen\n\nend slim_check\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/testing/slim_check/gen.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019594, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.49508802278234204}}
{"text": "lemma and_symm (P Q : Prop) : P ∧ Q → Q ∧ P :=\nbegin\nintro h,\ncases h with p q,\nsplit,\nexact q,\nexact p,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/5-advanced-proposition-world/l2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.740174350576073, "lm_q2_score": 0.6688802735722129, "lm_q1q2_score": 0.4950880221044587}}
{"text": "/-\nCopyright (c) 2020 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Aaron Anderson\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.finset.fold\nimport Mathlib.data.multiset.gcd\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# GCD and LCM operations on finsets\n\n## Main definitions\n\n- `finset.gcd` - the greatest common denominator of a `finset` of elements of a `gcd_monoid`\n- `finset.lcm` - the least common multiple of a `finset` of elements of a `gcd_monoid`\n\n## Implementation notes\n\nMany of the proofs use the lemmas `gcd.def` and `lcm.def`, which relate `finset.gcd`\nand `finset.lcm` to `multiset.gcd` and `multiset.lcm`.\n\nTODO: simplify with a tactic and `data.finset.lattice`\n\n## Tags\n\nfinset, gcd\n-/\n\nnamespace finset\n\n\n/-! ### lcm -/\n\n/-- Least common multiple of a finite set -/\ndef lcm {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α]\n    (s : finset β) (f : β → α) : α :=\n  fold lcm 1 f s\n\ntheorem lcm_def {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} : lcm s f = multiset.lcm (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem lcm_empty {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {f : β → α} : lcm ∅ f = 1 :=\n  fold_empty\n\n@[simp] theorem lcm_dvd_iff {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} {a : α} :\n    lcm s f ∣ a ↔ ∀ (b : β), b ∈ s → f b ∣ a :=\n  sorry\n\ntheorem lcm_dvd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {a : α} :\n    (∀ (b : β), b ∈ s → f b ∣ a) → lcm s f ∣ a :=\n  iff.mpr lcm_dvd_iff\n\ntheorem dvd_lcm {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {b : β} (hb : b ∈ s) : f b ∣ lcm s f :=\n  iff.mp lcm_dvd_iff (dvd_refl (lcm s f)) b hb\n\n@[simp] theorem lcm_insert {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} [DecidableEq β] {b : β} :\n    lcm (insert b s) f = lcm (f b) (lcm s f) :=\n  sorry\n\n@[simp] theorem lcm_singleton {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {f : β → α} {b : β} :\n    lcm (singleton b) f = coe_fn normalize (f b) :=\n  multiset.lcm_singleton\n\n@[simp] theorem normalize_lcm {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} :\n    coe_fn normalize (lcm s f) = lcm s f :=\n  sorry\n\ntheorem lcm_union {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} [DecidableEq β] :\n    lcm (s₁ ∪ s₂) f = lcm (lcm s₁ f) (lcm s₂ f) :=\n  sorry\n\ntheorem lcm_congr {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} {g : β → α} (hs : s₁ = s₂)\n    (hfg : ∀ (a : β), a ∈ s₂ → f a = g a) : lcm s₁ f = lcm s₂ g :=\n  Eq._oldrec (fun (hfg : ∀ (a : β), a ∈ s₁ → f a = g a) => fold_congr hfg) hs hfg\n\ntheorem lcm_mono_fun {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {g : β → α} (h : ∀ (b : β), b ∈ s → f b ∣ g b) :\n    lcm s f ∣ lcm s g :=\n  lcm_dvd fun (b : β) (hb : b ∈ s) => dvd_trans (h b hb) (dvd_lcm hb)\n\ntheorem lcm_mono {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} (h : s₁ ⊆ s₂) :\n    lcm s₁ f ∣ lcm s₂ f :=\n  lcm_dvd fun (b : β) (hb : b ∈ s₁) => dvd_lcm (h hb)\n\n/-! ### gcd -/\n\n/-- Greatest common divisor of a finite set -/\ndef gcd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α] [gcd_monoid α]\n    (s : finset β) (f : β → α) : α :=\n  fold gcd 0 f s\n\ntheorem gcd_def {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} : gcd s f = multiset.gcd (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem gcd_empty {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {f : β → α} : gcd ∅ f = 0 :=\n  fold_empty\n\ntheorem dvd_gcd_iff {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {a : α} : a ∣ gcd s f ↔ ∀ (b : β), b ∈ s → a ∣ f b :=\n  sorry\n\ntheorem gcd_dvd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {b : β} (hb : b ∈ s) : gcd s f ∣ f b :=\n  iff.mp dvd_gcd_iff (dvd_refl (gcd s f)) b hb\n\ntheorem dvd_gcd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {a : α} :\n    (∀ (b : β), b ∈ s → a ∣ f b) → a ∣ gcd s f :=\n  iff.mpr dvd_gcd_iff\n\n@[simp] theorem gcd_insert {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} [DecidableEq β] {b : β} :\n    gcd (insert b s) f = gcd (f b) (gcd s f) :=\n  sorry\n\n@[simp] theorem gcd_singleton {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {f : β → α} {b : β} :\n    gcd (singleton b) f = coe_fn normalize (f b) :=\n  multiset.gcd_singleton\n\n@[simp] theorem normalize_gcd {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} :\n    coe_fn normalize (gcd s f) = gcd s f :=\n  sorry\n\ntheorem gcd_union {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} [DecidableEq β] :\n    gcd (s₁ ∪ s₂) f = gcd (gcd s₁ f) (gcd s₂ f) :=\n  sorry\n\ntheorem gcd_congr {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} {g : β → α} (hs : s₁ = s₂)\n    (hfg : ∀ (a : β), a ∈ s₂ → f a = g a) : gcd s₁ f = gcd s₂ g :=\n  Eq._oldrec (fun (hfg : ∀ (a : β), a ∈ s₁ → f a = g a) => fold_congr hfg) hs hfg\n\ntheorem gcd_mono_fun {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {g : β → α} (h : ∀ (b : β), b ∈ s → f b ∣ g b) :\n    gcd s f ∣ gcd s g :=\n  dvd_gcd fun (b : β) (hb : b ∈ s) => dvd_trans (gcd_dvd hb) (h b hb)\n\ntheorem gcd_mono {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s₁ : finset β} {s₂ : finset β} {f : β → α} (h : s₁ ⊆ s₂) :\n    gcd s₂ f ∣ gcd s₁ f :=\n  dvd_gcd fun (b : β) (hb : b ∈ s₁) => gcd_dvd (h hb)\n\ntheorem gcd_eq_zero_iff {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α} :\n    gcd s f = 0 ↔ ∀ (x : β), x ∈ s → f x = 0 :=\n  sorry\n\ntheorem gcd_eq_gcd_filter_ne_zero {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α]\n    [nontrivial α] [gcd_monoid α] {s : finset β} {f : β → α}\n    [decidable_pred fun (x : β) => f x = 0] : gcd s f = gcd (filter (fun (x : β) => f x ≠ 0) s) f :=\n  sorry\n\ntheorem gcd_mul_left {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {a : α} :\n    (gcd s fun (x : β) => a * f x) = coe_fn normalize a * gcd s f :=\n  sorry\n\ntheorem gcd_mul_right {α : Type u_1} {β : Type u_2} [comm_cancel_monoid_with_zero α] [nontrivial α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {a : α} :\n    (gcd s fun (x : β) => f x * a) = gcd s f * coe_fn normalize a :=\n  sorry\n\nend finset\n\n\nnamespace finset\n\n\ntheorem gcd_eq_of_dvd_sub {α : Type u_1} {β : Type u_2} [nontrivial β] [integral_domain α]\n    [gcd_monoid α] {s : finset β} {f : β → α} {g : β → α} {a : α}\n    (h : ∀ (x : β), x ∈ s → a ∣ f x - g x) : gcd a (gcd s f) = gcd a (gcd s g) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/finset/gcd_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.49508801511500583}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.balanced\nimport category_theory.functor.epi_mono\nimport category_theory.functor.fully_faithful\n\n/-!\n# Functors which reflect isomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA functor `F` reflects isomorphisms if whenever `F.map f` is an isomorphism, `f` was too.\n\nIt is formalized as a `Prop` valued typeclass `reflects_isomorphisms F`.\n\nAny fully faithful functor reflects isomorphisms.\n-/\n\nopen category_theory category_theory.functor\n\nnamespace category_theory\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\nvariables {C : Type u₁} [category.{v₁} C]\n\nsection reflects_iso\nvariables {D : Type u₂} [category.{v₂} D]\nvariables {E : Type u₃} [category.{v₃} E]\n\n/--\nDefine what it means for a functor `F : C ⥤ D` to reflect isomorphisms: for any\nmorphism `f : A ⟶ B`, if `F.map f` is an isomorphism then `f` is as well.\nNote that we do not assume or require that `F` is faithful.\n-/\nclass reflects_isomorphisms (F : C ⥤ D) : Prop :=\n(reflects : Π {A B : C} (f : A ⟶ B) [is_iso (F.map f)], is_iso f)\n\n/-- If `F` reflects isos and `F.map f` is an iso, then `f` is an iso. -/\nlemma is_iso_of_reflects_iso {A B : C} (f : A ⟶ B) (F : C ⥤ D)\n  [is_iso (F.map f)] [reflects_isomorphisms F] :\n  is_iso f :=\nreflects_isomorphisms.reflects F f\n\n@[priority 100]\ninstance of_full_and_faithful (F : C ⥤ D) [full F] [faithful F] : reflects_isomorphisms F :=\n{ reflects := λ X Y f i, by exactI\n  ⟨⟨F.preimage (inv (F.map f)), ⟨F.map_injective (by simp), F.map_injective (by simp)⟩⟩⟩ }\n\ninstance (F : C ⥤ D) (G : D ⥤ E) [reflects_isomorphisms F] [reflects_isomorphisms G] :\n  reflects_isomorphisms (F ⋙ G) :=\n⟨λ _ _ f (hf : is_iso (G.map _)),\n  by { resetI, haveI := is_iso_of_reflects_iso (F.map f) G, exact is_iso_of_reflects_iso f F }⟩\n\n@[priority 100]\ninstance reflects_isomorphisms_of_reflects_monomorphisms_of_reflects_epimorphisms [balanced C]\n  (F : C ⥤ D) [reflects_monomorphisms F] [reflects_epimorphisms F] : reflects_isomorphisms F :=\n{ reflects := λ A B f hf,\n  begin\n    resetI,\n    haveI : epi f := epi_of_epi_map F infer_instance,\n    haveI : mono f := mono_of_mono_map F infer_instance,\n    exact is_iso_of_mono_of_epi f\n  end }\n\nend reflects_iso\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/functor/reflects_isomorphisms.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.49508800744766923}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.products.basic\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃ \n\nnamespace Mathlib\n\nnamespace category_theory.bifunctor\n\n\n@[simp] theorem map_id {C : Type u₁} {D : Type u₂} {E : Type u₃} [category C] [category D]\n    [category E] (F : C × D ⥤ E) (X : C) (Y : D) : functor.map F (𝟙, 𝟙) = 𝟙 :=\n  functor.map_id F (X, Y)\n\n@[simp] theorem map_id_comp {C : Type u₁} {D : Type u₂} {E : Type u₃} [category C] [category D]\n    [category E] (F : C × D ⥤ E) (W : C) {X : D} {Y : D} {Z : D} (f : X ⟶ Y) (g : Y ⟶ Z) :\n    functor.map F (𝟙, f ≫ g) = functor.map F (𝟙, f) ≫ functor.map F (𝟙, g) :=\n  sorry\n\n@[simp] theorem map_comp_id {C : Type u₁} {D : Type u₂} {E : Type u₃} [category C] [category D]\n    [category E] (F : C × D ⥤ E) (X : C) (Y : C) (Z : C) (W : D) (f : X ⟶ Y) (g : Y ⟶ Z) :\n    functor.map F (f ≫ g, 𝟙) = functor.map F (f, 𝟙) ≫ functor.map F (g, 𝟙) :=\n  sorry\n\n@[simp] theorem diagonal {C : Type u₁} {D : Type u₂} {E : Type u₃} [category C] [category D]\n    [category E] (F : C × D ⥤ E) (X : C) (X' : C) (f : X ⟶ X') (Y : D) (Y' : D) (g : Y ⟶ Y') :\n    functor.map F (𝟙, g) ≫ functor.map F (f, 𝟙) = functor.map F (f, g) :=\n  sorry\n\n@[simp] theorem diagonal' {C : Type u₁} {D : Type u₂} {E : Type u₃} [category C] [category D]\n    [category E] (F : C × D ⥤ E) (X : C) (X' : C) (f : X ⟶ X') (Y : D) (Y' : D) (g : Y ⟶ Y') :\n    functor.map F (f, 𝟙) ≫ functor.map F (𝟙, g) = functor.map F (f, g) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/products/bifunctor_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.49507936007194125}}
{"text": "/-\nCopyright (c) 2016 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport Mathlib.Logic.Basic\nimport Mathlib.Init.Data.Nat.Lemmas\nimport Mathlib.Init.Function\nimport Mathlib.Init.Set\nimport Mathlib.Init.SetNotation\nimport Mathlib.Tactic.Lint.Basic\n\nuniverse u v w\n\nnamespace Function\n\nsection\nvariable {α β γ : Sort _} {f : α → β}\n\n/-- Evaluate a function at an argument. Useful if you want to talk about the partially applied\n  `Function.eval x : (∀ x, β x) → β x`. -/\n@[reducible, simp] def eval {β : α → Sort _} (x : α) (f : ∀ x, β x) : β x := f x\n\nlemma const_def {y : β} : (λ x : α => y) = const α y := rfl\n\n@[simp] lemma const_comp {f : α → β} {c : γ} : const β c ∘ f = const α c := rfl\n\n@[simp] lemma comp_const {f : β → γ} {b : β} : f ∘ const α b = const α (f b) := rfl\n\nlemma id_def : @id α = λ x => x := rfl\n\nlemma hfunext {α α': Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : ∀a, β a} {f' : ∀a, β' a}\n  (hα : α = α') (h : ∀a a', HEq a a' → HEq (f a) (f' a')) : HEq f f' := by\n  subst hα\n  have : ∀a, HEq (f a) (f' a) := λ a => h a a (HEq.refl a)\n  have : β = β' := by funext a\n                      exact type_eq_of_heq (this a)\n  subst this\n  apply heq_of_eq\n  funext a\n  exact eq_of_heq (this a)\n\nlemma funext_iff {β : α → Sort _} {f₁ f₂ : ∀ (x : α), β x} : f₁ = f₂ ↔ (∀a, f₁ a = f₂ a) :=\nIff.intro (λ h a => h ▸ rfl) funext\n\nprotected lemma bijective.injective {f : α → β} (hf : bijective f) : injective f := hf.1\nprotected lemma bijective.surjective {f : α → β} (hf : bijective f) : surjective f := hf.2\n\ntheorem injective.eq_iff (I : injective f) {a b : α} :\n  f a = f b ↔ a = b :=\n⟨@I _ _, congr_arg f⟩\n\ntheorem injective.eq_iff' (I : injective f) {a b : α} {c : β} (h : f b = c) :\n  f a = c ↔ a = b :=\nh ▸ I.eq_iff\n\nlemma injective.ne (hf : injective f) {a₁ a₂ : α} : a₁ ≠ a₂ → f a₁ ≠ f a₂ :=\nmt (λ h => hf h)\n\nlemma injective.ne_iff (hf : injective f) {x y : α} : f x ≠ f y ↔ x ≠ y :=\n⟨mt $ congr_arg f, hf.ne⟩\n\nlemma injective.ne_iff' (hf : injective f) {x y : α} {z : β} (h : f y = z) :\n  f x ≠ z ↔ x ≠ y :=\nh ▸ hf.ne_iff\n\n/-- If the co-domain `β` of an injective function `f : α → β` has decidable equality, then\nthe domain `α` also has decidable equality. -/\ndef injective.decidable_eq [DecidableEq β] (I : injective f) : DecidableEq α :=\nλ a b => decidable_of_iff _ I.eq_iff\n\nlemma injective.of_comp {g : γ → α} (I : injective (f ∘ g)) : injective g :=\nλ {x y} h => I $ show f (g x) = f (g y) from congr_arg f h\n\nlemma injective.of_comp_iff {f : α → β} (hf : injective f) (g : γ → α) :\n  injective (f ∘ g) ↔ injective g :=\n⟨injective.of_comp, hf.comp⟩\n\nlemma injective.of_comp_iff' (f : α → β) {g : γ → α} (hg : bijective g) :\n  injective (f ∘ g) ↔ injective f :=\n⟨ λ h x y => let ⟨x', hx⟩ := hg.surjective x\n             let ⟨y', hy⟩ := hg.surjective y\n             hx ▸ hy ▸ λ hf => h hf ▸ rfl,\n  λ h => h.comp hg.injective⟩\n\nlemma injective_of_subsingleton [Subsingleton α] (f : α → β) :\n  injective f :=\nλ {a b} ab => Subsingleton.elim _ _\n\nlemma injective.dite (p : α → Prop) [DecidablePred p]\n  {f : {a : α // p a} → β} {f' : {a : α // ¬ p a} → β}\n  (hf : injective f) (hf' : injective f')\n  (im_disj : ∀ {x x' : α} {hx : p x} {hx' : ¬ p x'}, f ⟨x, hx⟩ ≠ f' ⟨x', hx'⟩) :\n  Function.injective (λ x => if h : p x then f ⟨x, h⟩ else f' ⟨x, h⟩) :=\nby intros x₁ x₂ h\n   --TODO mathlib3 uses dsimp here\n   have hrw1 : (fun (x : α) => if h : p x then f ⟨x, h⟩ else f' ⟨x, h⟩) x₁ =\n                if h : p x₁ then f ⟨x₁, h⟩ else f' ⟨x₁, h⟩ := rfl\n   have hrw2 : (fun (x : α) => if h : p x then f ⟨x, h⟩ else f' ⟨x, h⟩) x₂ =\n               if h : p x₂ then f ⟨x₂, h⟩ else f' ⟨x₂, h⟩ := rfl\n   rw [hrw1, hrw2] at h\n   exact Decidable.byCases\n     (λ (h₁ : p x₁) =>\n       Decidable.byCases\n         (λ (h₂ : p x₂) => by rw [dif_pos h₁, dif_pos h₂] at h\n                              injection (hf h)\n                              assumption)\n         (λ (h₂ : ¬ p x₂) => by rw [dif_pos h₁, dif_neg h₂] at h\n                                exact (im_disj h).elim))\n     (λ (h₁ : ¬ p x₁) =>\n       Decidable.byCases\n         (λ (h₂ : p x₂) => by rw [dif_neg h₁, dif_pos h₂] at h\n                              exact (im_disj h.symm).elim)\n         (λ (h₂ : ¬ p x₂) => by rw [dif_neg h₁, dif_neg h₂] at h\n                                injection (hf' h)\n                                assumption))\n\nlemma surjective.of_comp {g : γ → α} (S : surjective (f ∘ g)) : surjective f :=\nλ y => let ⟨x, h⟩ := S y\n       ⟨g x, h⟩\n\nlemma surjective.of_comp_iff (f : α → β) {g : γ → α} (hg : surjective g) :\n  surjective (f ∘ g) ↔ surjective f :=\n⟨surjective.of_comp, λ h => h.comp hg⟩\n\nlemma surjective.of_comp_iff' {f : α → β} (hf : bijective f) (g : γ → α) :\n  surjective (f ∘ g) ↔ surjective g :=\n⟨λ h x => let ⟨x', hx'⟩ := h (f x)\n          ⟨x', hf.injective hx'⟩, hf.surjective.comp⟩\n\ninstance decidable_eq_pfun (p : Prop) [Decidable p] (α : p → Type _)\n  [∀ hp, DecidableEq (α hp)] : DecidableEq (∀hp, α hp)\n| f, g => decidable_of_iff (∀ hp, f hp = g hp) funext_iff.symm\n\ntheorem surjective.forall {f : α → β} (hf : surjective f) {p : β → Prop} :\n  (∀ y, p y) ↔ ∀ x, p (f x) :=\n⟨λ h x => h (f x),\n λ h y => let ⟨x, hx⟩ := hf y\n          hx ▸ h x⟩\n\ntheorem surjective.forall₂ {f : α → β} (hf : surjective f) {p : β → β → Prop} :\n  (∀ y₁ y₂, p y₁ y₂) ↔ ∀ x₁ x₂, p (f x₁) (f x₂) :=\nhf.forall.trans $ forall_congr' $ λ x => hf.forall\n\ntheorem surjective.forall₃ {f : α → β} (hf : surjective f) {p : β → β → β → Prop} :\n  (∀ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∀ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\nhf.forall.trans $ forall_congr' $ λ x => hf.forall₂\n\ntheorem surjective.exists {f : α → β} (hf : surjective f) {p : β → Prop} :\n  (∃ y, p y) ↔ ∃ x, p (f x) :=\n⟨λ ⟨y, hy⟩ => let ⟨x, hx⟩ := hf y\n              ⟨x, hx.symm ▸ hy⟩,\n λ ⟨x, hx⟩ => ⟨f x, hx⟩⟩\n\ntheorem surjective.exists₂ {f : α → β} (hf : surjective f) {p : β → β → Prop} :\n  (∃ y₁ y₂, p y₁ y₂) ↔ ∃ x₁ x₂, p (f x₁) (f x₂) :=\nhf.exists.trans $ exists_congr $ λ x => hf.exists\n\ntheorem surjective.exists₃ {f : α → β} (hf : surjective f) {p : β → β → β → Prop} :\n  (∃ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∃ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\nhf.exists.trans $ exists_congr $ λ x => hf.exists₂\n\nlemma bijective_iff_exists_unique (f : α → β) : bijective f ↔\n  ∀ b : β, ∃! (a : α), f a = b :=\n⟨ λ hf b => let ⟨a, ha⟩ := hf.surjective b\n            ⟨a, ha, λ a' ha' => hf.injective (ha'.trans ha.symm)⟩,\n  λ he => ⟨\n    λ {a a'} h => unique_of_exists_unique (he (f a')) h rfl,\n    λ b => ExistsUnique.exists (he b) ⟩⟩\n\n/-- Shorthand for using projection notation with `function.bijective_iff_exists_unique`. -/\nlemma bijective.exists_unique {f : α → β} (hf : bijective f) (b : β) : ∃! (a : α), f a = b :=\n(bijective_iff_exists_unique f).mp hf b\n\nlemma bijective.of_comp_iff (f : α → β) {g : γ → α} (hg : bijective g) :\n  bijective (f ∘ g) ↔ bijective f :=\nand_congr (injective.of_comp_iff' _ hg) (surjective.of_comp_iff _ hg.surjective)\n\nlemma bijective.of_comp_iff' {f : α → β} (hf : bijective f) (g : γ → α) :\n  Function.bijective (f ∘ g) ↔ Function.bijective g :=\nand_congr (injective.of_comp_iff hf.injective _) (surjective.of_comp_iff' hf _)\n\n/-- Cantor's diagonal argument implies that there are no surjective functions from `α`\nto `Set α`. -/\ntheorem cantor_surjective {α} (f : α → Set α) : ¬ Function.surjective f\n| h => let ⟨D, e⟩ := h (λ a => ¬ f a a)\n       by have x := @iff_not_self (f D D)\n          exact (@iff_not_self (f D D)) $ iff_of_eq (congr_fun e D)\n\n/-- Cantor's diagonal argument implies that there are no injective functions from `Set α` to `α`. -/\ntheorem cantor_injective {α : Type _} (f : (Set α) → α) :\n  ¬ Function.injective f\n| i => cantor_surjective (λ a b => ∀ U, a = f U → U b) $\n       RightInverse.surjective\n         (λ U => funext $ λ a => propext ⟨λ h => h U rfl, λ h' U' e => i e ▸ h'⟩)\n\n/-- `g` is a partial inverse to `f` (an injective but not necessarily\n  surjective function) if `g y = some x` implies `f x = y`, and `g y = none`\n  implies that `y` is not in the range of `f`. -/\ndef is_partial_inv {α β} (f : α → β) (g : β → Option α) : Prop :=\n∀ x y, g y = some x ↔ f x = y\n\ntheorem is_partial_inv_left {α β} {f : α → β} {g} (H : is_partial_inv f g) (x) : g (f x) = some x :=\n(H _ _).2 rfl\n\ntheorem injective_of_partial_inv {α β} {f : α → β} {g} (H : is_partial_inv f g) : injective f :=\nλ {a b} h => Option.some.inj $ ((H _ _).2 h).symm.trans ((H _ _).2 rfl)\n\n-- TODO mathlib3 uses Mem here\ntheorem injective_of_partial_inv_right {α β} {f : α → β} {g} (H : is_partial_inv f g)\n (x y b) (h₁ : g x = some b) (h₂ : g y = some b) : x = y :=\n((H _ _).1 h₁).symm.trans ((H _ _).1 h₂)\n\ntheorem LeftInverse.comp_eq_id {f : α → β} {g : β → α} (h : LeftInverse f g) : f ∘ g = id :=\nfunext h\n\ntheorem LeftInverse_iff_comp {f : α → β} {g : β → α} : LeftInverse f g ↔ f ∘ g = id :=\n⟨LeftInverse.comp_eq_id, congr_fun⟩\n\ntheorem RightInverse.comp_eq_id {f : α → β} {g : β → α} (h : RightInverse f g) : g ∘ f = id :=\nfunext h\n\ntheorem RightInverse_iff_comp {f : α → β} {g : β → α} : RightInverse f g ↔ g ∘ f = id :=\n⟨RightInverse.comp_eq_id, congr_fun⟩\n\ntheorem LeftInverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β}\n  (hf : LeftInverse f g) (hh : LeftInverse h i) : LeftInverse (h ∘ f) (g ∘ i) :=\nλ a => show h (f (g (i a))) = a by rw [hf (i a), hh a]\n\ntheorem RightInverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β}\n  (hf : RightInverse f g) (hh : RightInverse h i) : RightInverse (h ∘ f) (g ∘ i) :=\nLeftInverse.comp hh hf\n\ntheorem LeftInverse.RightInverse {f : α → β} {g : β → α} (h : LeftInverse g f) :\n  RightInverse f g := h\n\ntheorem RightInverse.LeftInverse {f : α → β} {g : β → α} (h : RightInverse g f) :\n  LeftInverse f g := h\n\ntheorem LeftInverse.surjective {f : α → β} {g : β → α} (h : LeftInverse f g) :\n  surjective f :=\nh.RightInverse.surjective\n\ntheorem RightInverse.injective {f : α → β} {g : β → α} (h : RightInverse f g) :\n  injective f :=\nh.LeftInverse.injective\n\ntheorem LeftInverse.eq_RightInverse {f : α → β} {g₁ g₂ : β → α} (h₁ : LeftInverse g₁ f)\n  (h₂ : Function.RightInverse g₂ f) :\n  g₁ = g₂ := by\n  have h₃ : g₁ = g₁ ∘ f ∘ g₂ := by rw [h₂.comp_eq_id, comp.right_id]\n  have h₄ : g₁ ∘ f ∘ g₂ = g₂ := by rw [← comp.assoc, h₁.comp_eq_id, comp.left_id]\n  rwa [←h₄]\n\nattribute [local instance] Classical.propDecidable\n\n/-- We can use choice to construct explicitly a partial inverse for\n  a given injective function `f`. -/\nnoncomputable def partial_inv {α β} (f : α → β) (b : β) : Option α :=\nif h : ∃ a, f a = b then some (Classical.choose h) else none\n\ntheorem partial_inv_of_injective {α β} {f : α → β} (I : injective f) :\n  is_partial_inv f (partial_inv f)\n| a, b =>\n⟨λ h => have hpi: partial_inv f b = if h : ∃ a, f a = b then some (Classical.choose h) else none := rfl\n        if h' : ∃ a, f a = b\n        then by rw [hpi, dif_pos h'] at h\n                injection h with h\n                subst h\n                apply Classical.choose_spec h'\n        else by rw [hpi, dif_neg h'] at h; contradiction,\n λ e => e ▸ have h : ∃ a', f a' = f a := ⟨_, rfl⟩\n            (dif_pos h).trans (congr_arg _ (I $ Classical.choose_spec h))⟩\n\ntheorem partial_inv_left {α β} {f : α → β} (I : injective f) : ∀ x, partial_inv f (f x) = some x :=\nis_partial_inv_left (partial_inv_of_injective I)\n\nend\n\nsection inv_fun\nvariable {α : Type u} [n : Nonempty α] {β : Sort v} {f : α → β} {s : Set α} {a : α} {b : β}\nattribute [local instance] Classical.propDecidable\n\n/-- Construct the inverse for a function `f` on domain `s`. This function is a right inverse of `f`\non `f '' s`. For a computable version, see `function.injective.inv_of_mem_range`. -/\nnoncomputable def inv_fun_on (f : α → β) (s : Set α) (b : β) : α :=\nif h : ∃a, a ∈ s ∧ f a = b then Classical.choose h else Classical.choice n\n\ntheorem inv_fun_on_pos (h : ∃a∈s, f a = b) : inv_fun_on f s b ∈ s ∧ f (inv_fun_on f s b) = b :=\nby have h1 : inv_fun_on f s b =\n     if h : ∃a, a ∈ s ∧ f a = b then Classical.choose h else Classical.choice n := rfl\n   rw [dif_pos h] at h1\n   rw [h1]\n   exact Classical.choose_spec h\n\ntheorem inv_fun_on_mem (h : ∃a∈s, f a = b) : inv_fun_on f s b ∈ s := (inv_fun_on_pos h).left\n\ntheorem inv_fun_on_eq (h : ∃a∈s, f a = b) : f (inv_fun_on f s b) = b := (inv_fun_on_pos h).right\n\ntheorem inv_fun_on_eq' (h : ∀ x ∈ s, ∀ y ∈ s, f x = f y → x = y) (ha : a ∈ s) :\n  inv_fun_on f s (f a) = a :=\nhave : ∃a'∈s, f a' = f a := ⟨a, ha, rfl⟩\nh _ (inv_fun_on_mem this) _ ha (inv_fun_on_eq this)\n\ntheorem inv_fun_on_neg (h : ¬ ∃a∈s, f a = b) : inv_fun_on f s b = Classical.choice n :=\nby have h1 : inv_fun_on f s b =\n     if h : ∃a, a ∈ s ∧ f a = b then Classical.choose h else Classical.choice n := rfl\n   rwa [dif_neg h] at h1\n\n/-- The inverse of a function (which is a left inverse if `f` is injective\n  and a right inverse if `f` is surjective). -/\nnoncomputable def inv_fun (f : α → β) : β → α := inv_fun_on f Set.univ\n\ntheorem inv_fun_eq (h : ∃a, f a = b) : f (inv_fun f b) = b :=\ninv_fun_on_eq $ let ⟨a, ha⟩ := h\n                ⟨a, trivial, ha⟩\n\nlemma inv_fun_neg (h : ¬ ∃ a, f a = b) : inv_fun f b = Classical.choice n :=\nby refine inv_fun_on_neg (mt ?_ h); exact λ ⟨a, _, ha⟩ => ⟨a, ha⟩\n\ntheorem inv_fun_eq_of_injective_of_RightInverse {g : β → α}\n  (hf : injective f) (hg : RightInverse g f) : inv_fun f = g :=\nfunext $ λ b => hf (by rw [hg b]\n                       exact inv_fun_eq ⟨g b, hg b⟩)\n\nlemma RightInverse_inv_fun (hf : surjective f) : RightInverse (inv_fun f) f :=\nλ b => inv_fun_eq $ hf b\n\nlemma LeftInverse_inv_fun (hf : injective f) : LeftInverse (inv_fun f) f :=\nλ b => have : f (inv_fun f (f b)) = f b := inv_fun_eq ⟨b, rfl⟩\n       hf this\n\nlemma inv_fun_surjective (hf : injective f) : surjective (inv_fun f) :=\n(LeftInverse_inv_fun hf).surjective\n\nlemma inv_fun_comp (hf : injective f) : inv_fun f ∘ f = id := funext $ LeftInverse_inv_fun hf\n\nend inv_fun\n\nsection inv_fun\nvariable {α : Type u} [i : Nonempty α] {β : Sort v} {f : α → β}\n\nlemma injective.has_LeftInverse (hf : injective f) : has_LeftInverse f :=\n⟨inv_fun f, LeftInverse_inv_fun hf⟩\n\nlemma injective_iff_has_LeftInverse : injective f ↔ has_LeftInverse f :=\n⟨injective.has_LeftInverse, has_LeftInverse.injective⟩\n\nend inv_fun\n\nsection surj_inv\nvariable {α : Sort u} {β : Sort v} {f : α → β}\n\n/-- The inverse of a surjective function. (Unlike `inv_fun`, this does not require\n  `α` to be inhabited.) -/\nnoncomputable def surj_inv {f : α → β} (h : surjective f) (b : β) : α := Classical.choose (h b)\n\nlemma surj_inv_eq (h : surjective f) (b) : f (surj_inv h b) = b := Classical.choose_spec (h b)\n\nlemma RightInverse_surj_inv (hf : surjective f) : RightInverse (surj_inv hf) f :=\nsurj_inv_eq hf\n\nlemma LeftInverse_surj_inv (hf : bijective f) : LeftInverse (surj_inv hf.2) f :=\nRightInverse_of_injective_of_LeftInverse hf.1 (RightInverse_surj_inv hf.2)\n\nlemma surjective.has_RightInverse (hf : surjective f) : has_RightInverse f :=\n⟨_, RightInverse_surj_inv hf⟩\n\nlemma surjective_iff_has_RightInverse : surjective f ↔ has_RightInverse f :=\n⟨surjective.has_RightInverse, has_RightInverse.surjective⟩\n\nlemma bijective_iff_has_inverse : bijective f ↔ ∃ g, LeftInverse g f ∧ RightInverse g f :=\n⟨λ hf =>  ⟨_, LeftInverse_surj_inv hf, RightInverse_surj_inv hf.2⟩,\n λ ⟨g, gl, gr⟩ => ⟨gl.injective,  gr.surjective⟩⟩\n\nlemma injective_surj_inv (h : surjective f) : injective (surj_inv h) :=\n(RightInverse_surj_inv h).injective\n\nlemma surjective_to_subsingleton [na : Nonempty α] [Subsingleton β] (f : α → β) :\n  surjective f :=\nλ y => let ⟨a⟩ := na; ⟨a, Subsingleton.elim _ _⟩\n\nend surj_inv\n\nsection update\nvariable {α : Sort u} {β : α → Sort v} {α' : Sort w} [DecidableEq α] [DecidableEq α']\n\n/-- Replacing the value of a function at a given point by a given value. -/\ndef update (f : ∀a, β a) (a' : α) (v : β a') (a : α) : β a :=\nif h : a = a' then Eq.rec (motive := λ a _ => β a) v h.symm else f a\n\n/-- On non-dependent functions, `function.update` can be expressed as an `ite` -/\nlemma update_apply {β : Sort _} (f : α → β) (a' : α) (b : β) (a : α) :\n  update f a' b a = if a = a' then b else f a :=\nby have h2 : (h : a = a') → Eq.rec (motive := λ a b => β) b h.symm = b :=\n     by intro h\n        rw [eq_rec_constant]\n   have h3 : (λ h : a = a' => Eq.rec (motive := λ a b => β) b h.symm) =\n             (λ _ : a = a' =>  b) := funext h2\n   let f := λ x => dite (a = a') x (λ (_: ¬ a = a') => (f a))\n   exact congrArg f h3\n\n@[simp] lemma update_same (a : α) (v : β a) (f : ∀a, β a) : update f a v a = v :=\ndif_pos rfl\n\nlemma update_injective (f : ∀a, β a) (a' : α) : injective (update f a') :=\nby intros v v' h\n   have h' := congrFun h a'\n   rwa [update_same, update_same] at h'\n\n@[simp] lemma update_noteq {a a' : α} (h : a ≠ a') (v : β a') (f : ∀a, β a) :\n  update f a' v a = f a :=\ndif_neg h\n\nlemma forall_update_iff (f : ∀a, β a) {a : α} {b : β a} (p : ∀a, β a → Prop) :\n  (∀ x, p x (update f a b x)) ↔ p a b ∧ ∀ x, x ≠ a → p x (f x) :=\nIff.intro\n  (by intro h\n      have h1 := h a\n      have h2 : update f a b a = b := update_same _ _ _\n      rw [h2] at h1\n      refine ⟨h1, ?_⟩\n      intro x hx\n      have h3 := update_noteq hx b f\n      rw [←h3]\n      exact h x)\n  (by intro ⟨hp,h⟩ x\n      have h1 : x = a ∨ x ≠ a := Decidable.em _\n      match h1 with\n      | Or.inl he => rw [he, update_same]\n                     exact hp\n      | Or.inr hne => have h4 := update_noteq hne b f\n                      rw [h4]\n                      exact h x hne)\n\nlemma update_eq_iff {a : α} {b : β a} {f g : ∀ a, β a} :\n  update f a b = g ↔ b = g a ∧ ∀ x, x ≠ a -> f x = g x :=\nfunext_iff.trans $ forall_update_iff _ (λ x y => y = g x)\n\nlemma eq_update_iff {a : α} {b : β a} {f g : ∀ a, β a} :\n  g = update f a b ↔ g a = b ∧ ∀ x, x ≠ a -> g x = f x :=\nfunext_iff.trans $ forall_update_iff _ (λ x y => g x = y)\n\n@[simp] lemma update_eq_self (a : α) (f : ∀a, β a) : update f a (f a) = f :=\nupdate_eq_iff.2 ⟨rfl, λ _ _ => rfl⟩\n\nlemma update_comp_eq_of_forall_ne' {α'} (g : ∀ a, β a) {f : α' → α} {i : α} (a : β i)\n  (h : ∀ x, f x ≠ i) :\n  (λ j => (update g i a) (f j)) = (λ j => g (f j)) :=\nfunext $ λ x => update_noteq (h _) _ _\n\n/-- Non-dependent version of `function.update_comp_eq_of_forall_ne'` -/\nlemma update_comp_eq_of_forall_ne {α β : Sort _} (g : α' → β) {f : α → α'} {i : α'} (a : β)\n  (h : ∀ x, f x ≠ i) :\n  (update g i a) ∘ f = g ∘ f :=\nupdate_comp_eq_of_forall_ne' g a h\n\nlemma update_comp_eq_of_injective' (g : ∀a, β a) {f : α' → α} (hf : Function.injective f)\n  (i : α') (a : β (f i)) :\n  (λ j => update g (f i) a (f j)) = update (λ i => g (f i)) i a :=\neq_update_iff.2 ⟨update_same _ _ _, λ j hj => update_noteq (hf.ne hj) _ _⟩\n\n/-- Non-dependent version of `function.update_comp_eq_of_injective'` -/\nlemma update_comp_eq_of_injective {β : Sort _} (g : α' → β) {f : α → α'}\n  (hf : Function.injective f) (i : α) (a : β) :\n  (Function.update g (f i) a) ∘ f = Function.update (g ∘ f) i a :=\nupdate_comp_eq_of_injective' g hf i a\n\nlemma apply_update {ι : Sort _} [DecidableEq ι] {α β : ι → Sort _}\n  (f : ∀i, α i → β i) (g : ∀i, α i) (i : ι) (v : α i) (j : ι) :\n  f j (update g i v j) = update (λ k => f k (g k)) i (f i v) j :=\nby by_cases h : j = i\n   subst j; simp\n   simp[h]\n\nlemma comp_update {α' : Sort _} {β : Sort _} (f : α' → β) (g : α → α') (i : α) (v : α') :\n  f ∘ (update g i v) = update (f ∘ g) i (f v) :=\nfunext $ apply_update _ _ _ _\n\ntheorem update_comm {α} [DecidableEq α] {β : α → Sort _}\n  {a b : α} (h : a ≠ b) (v : β a) (w : β b) (f : ∀a, β a) :\n  update (update f a v) b w = update (update f b w) a v :=\nby funext c\n   simp only [update]\n   by_cases h₁ : c = b <;> by_cases h₂ : c = a\n   · rw [dif_pos h₁, dif_pos h₂]\n     cases h (h₂.symm.trans h₁)\n   · rw [dif_pos h₁, dif_pos h₁, dif_neg h₂]\n   · rw [dif_neg h₁, dif_neg h₁, dif_pos h₂]\n   · rw [dif_neg h₁, dif_neg h₁, dif_neg h₂]\n\n@[simp] theorem update_idem {α} [DecidableEq α] {β : α → Sort _}\n  {a : α} (v w : β a) (f : ∀a, β a) : update (update f a v) a w = update f a w :=\nby funext b\n   by_cases b = a <;> simp [update, h]\n\nend update\n\nsection extend\n\nattribute [local instance] Classical.propDecidable\n\nvariable {α β γ : Type _} {f : α → β}\n\n/-- `extend f g e'` extends a function `g : α → γ`\nalong a function `f : α → β` to a function `β → γ`,\nby using the values of `g` on the range of `f`\nand the values of an auxiliary function `e' : β → γ` elsewhere.\n\nMostly useful when `f` is injective. -/\nnoncomputable def extend (f : α → β) (g : α → γ) (e' : β → γ) : β → γ :=\nλ b => if h : ∃ a, f a = b then g (Classical.choose h) else e' b\n\nlemma extend_def (f : α → β) (g : α → γ) (e' : β → γ) (b : β) [hd : Decidable (∃ a, f a = b)] :\n  extend f g e' b = if h : ∃ a, f a = b then g (Classical.choose h) else e' b :=\n  by rw [Subsingleton.elim hd] -- align the Decidable instances implicitly used by `dite`\n     exact rfl\n\n@[simp] lemma extend_apply (hf : injective f) (g : α → γ) (e' : β → γ) (a : α) :\n  extend f g e' (f a) = g a :=\nby simp only [extend_def, dif_pos, exists_apply_eq_apply]\n   exact congr_arg g (hf $ Classical.choose_spec (exists_apply_eq_apply f a))\n\n@[simp] lemma extend_comp (hf : injective f) (g : α → γ) (e' : β → γ) :\n  extend f g e' ∘ f = g :=\nfunext $ λ a => extend_apply hf g e' a\n\nend extend\n\nlemma uncurry_def {α β γ} (f : α → β → γ) : uncurry f = (λp => f p.1 p.2) :=\nrfl\n\n@[simp] lemma uncurry_apply_pair {α β γ} (f : α → β → γ) (x : α) (y : β) :\n  uncurry f (x, y) = f x y :=\nrfl\n\n@[simp] lemma curry_apply {α β γ} (f : α × β → γ) (x : α) (y : β) :\n  curry f x y = f (x, y) :=\nrfl\n\nsection bicomp\nvariable {α β γ δ ε : Type _}\n\n/-- Compose a binary function `f` with a pair of unary functions `g` and `h`.\nIf both arguments of `f` have the same type and `g = h`, then `bicompl f g g = f on g`. -/\ndef bicompl (f : γ → δ → ε) (g : α → γ) (h : β → δ) (a b) :=\nf (g a) (h b)\n\n/-- Compose an unary function `f` with a binary function `g`. -/\ndef bicompr (f : γ → δ) (g : α → β → γ) (a b) :=\nf (g a b)\n\n-- Suggested local notation:\nlocal notation f  \" ∘₂ \" g => bicompr f g\n\nlemma uncurry_bicompr (f : α → β → γ) (g : γ → δ) :\n  uncurry (g ∘₂ f) = (g ∘ uncurry f) := rfl\n\nlemma uncurry_bicompl (f : γ → δ → ε) (g : α → γ) (h : β → δ) :\n  uncurry (bicompl f g h) = (uncurry f) ∘ (Prod.map g h) :=\nby ext ⟨x, y⟩; exact rfl\n\nend bicomp\n\nsection uncurry\n\n/-- Records a way to turn an element of `α` into a function from `β` to `γ`. The most generic use\nis to recursively uncurry. For instance `f : α → β → γ → δ` will be turned into\n`↿f : α × β × γ → δ`. One can also add instances for bundled maps. -/\nclass HasUncurry (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where\n  uncurry : α → (β → γ)\n\n/- Uncurrying operator. The most generic use is to recursively uncurry. For instance\n`f : α → β → γ → δ` will be turned into `↿f : α × β × γ → δ`. One can also add instances\nfor bundled maps. -/\nnotation:max \"↿\" x:max => HasUncurry.uncurry x\n\ninstance HasUncurry_base : HasUncurry (α → β) α β := ⟨id⟩\n\ninstance HasUncurry_induction [HasUncurry β γ δ] : HasUncurry (α → β) (α × γ) δ :=\n⟨λ f p => ↿(f p.1) p.2⟩\n\nend uncurry\n\n/-- A function is involutive, if `f ∘ f = id`. -/\ndef involutive {α} (f : α → α) : Prop := ∀ x, f (f x) = x\n\nlemma involutive_iff_iter_2_eq_id {α} {f : α → α} : involutive f ↔ (f^[2] = id) :=\nfunext_iff.symm\n\nnamespace involutive\nvariable {α : Sort u} {f : α → α} (h : involutive f)\n\n@[simp]\nlemma comp_self : f ∘ f = id := funext h\n\nprotected lemma LeftInverse : LeftInverse f f := h\nprotected lemma RightInverse : RightInverse f f := h\n\nprotected lemma injective : injective f := h.LeftInverse.injective\nprotected lemma surjective : surjective f := λ x => ⟨f x, h x⟩\nprotected lemma bijective : bijective f := ⟨h.injective, h.surjective⟩\n\n/-- Involuting an `ite` of an involuted value `x : α` negates the `Prop` condition in the `ite`. -/\nprotected lemma ite_not (P : Prop) [Decidable P] (x : α) :\n  f (ite P x (f x)) = ite (¬ P) x (f x) :=\nby rw [apply_ite f, h, ite_not]\n\n/-- An involution commutes across an equality. Compare to `function.injective.eq_iff`. -/\nprotected lemma eq_iff {x y : α} : f x = y ↔ x = f y :=\nFunction.injective.eq_iff' (involutive.injective h) (h y)\n\nend involutive\n\n/-- The property of a binary function `f : α → β → γ` being injective.\nMathematically this should be thought of as the corresponding function `α × β → γ` being injective.\n-/\n@[reducible] def injective2 {α β γ} (f : α → β → γ) : Prop :=\n∀ {a₁ a₂ b₁ b₂}, f a₁ b₁ = f a₂ b₂ → a₁ = a₂ ∧ b₁ = b₂\n\nnamespace injective2\nvariable {α β γ : Type _} (f : α → β → γ)\n\nprotected lemma left (hf : injective2 f) {a₁ a₂ b₁ b₂} (h : f a₁ b₁ = f a₂ b₂) : a₁ = a₂ :=\n(hf h).1\n\nprotected lemma right (hf : injective2 f) {a₁ a₂ b₁ b₂} (h : f a₁ b₁ = f a₂ b₂) : b₁ = b₂ :=\n(hf h).2\n\nlemma eq_iff (hf : injective2 f) {a₁ a₂ b₁ b₂} : f a₁ b₁ = f a₂ b₂ ↔ a₁ = a₂ ∧ b₁ = b₂ :=\n⟨λ h => hf h, λ⟨h1, h2⟩ => congr_arg2 f h1 h2⟩\n\nend injective2\n\nsection sometimes\nattribute [local instance] Classical.propDecidable\n\n/-- `sometimes f` evaluates to some value of `f`, if it exists. This function is especially\ninteresting in the case where `α` is a proposition, in which case `f` is necessarily a\nconstant function, so that `sometimes f = f a` for all `a`. -/\nnoncomputable def sometimes {α β} [Nonempty β] (f : α → β) : β :=\nif h : Nonempty α then f (Classical.choice h) else Classical.choice ‹_›\n\ntheorem sometimes_eq {p : Prop} {α} [Nonempty α] (f : p → α) (a : p) : sometimes f = f a :=\ndif_pos ⟨a⟩\n\ntheorem sometimes_spec {p : Prop} {α} [Nonempty α]\n  (P : α → Prop) (f : p → α) (a : p) (h : P (f a)) : P (sometimes f) :=\nby rwa [sometimes_eq]\n\nend sometimes\n\nend Function\n\n/-- `s.piecewise f g` is the function equal to `f` on the set `s`, and to `g` on its complement. -/\ndef set.piecewise {α : Type u} {β : α → Sort v} (s : Set α) (f g : ∀i, β i)\n  [∀j, Decidable (j ∈ s)] :\n  ∀i, β i :=\nλi => if i ∈ s then f i else g i\n\n-- TODO: eq_rec_on_bijective, eq_mp_bijective, eq_mpr_bijective, cast_biject, eq_rec_inj, cast_inj\n\n/-- A set of functions \"separates points\"\nif for each pair of distinct points there is a function taking different values on them. -/\ndef set.separates_points {α β : Type _} (A : Set (α → β)) : Prop :=\n∀ {x y : α}, x ≠ y → ∃ f ∈ A, (f x : β) ≠ f y\n\n-- TODO: is_symm_op.flip_eq\n", "meta": {"author": "JOSHCLUNE", "repo": "Keller_reduction", "sha": "dc392b3da352fc1ffcfbecb1d4717d05f5faed4a", "save_path": "github-repos/lean/JOSHCLUNE-Keller_reduction", "path": "github-repos/lean/JOSHCLUNE-Keller_reduction/Keller_reduction-dc392b3da352fc1ffcfbecb1d4717d05f5faed4a/Lean4_Clique/Mathlib/Mathlib/Logic/Function/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4950793590157028}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Calle Sönne, Adam Topaz\n\n! This file was ported from Lean 3 source module topology.discrete_quotient\n! leanprover-community/mathlib commit d101e93197bb5f6ea89bd7ba386b7f7dff1f3903\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Topology.Separation\nimport Mathlib.Topology.SubsetProperties\nimport Mathlib.Topology.LocallyConstant.Basic\n\n/-!\n\n# Discrete quotients of a topological space.\n\nThis file defines the type of discrete quotients of a topological space,\ndenoted `DiscreteQuotient X`. To avoid quantifying over types, we model such\nquotients as setoids whose equivalence classes are clopen.\n\n## Definitions\n1. `DiscreteQuotient X` is the type of discrete quotients of `X`.\n  It is endowed with a coercion to `Type`, which is defined as the\n  quotient associated to the setoid in question, and each such quotient\n  is endowed with the discrete topology.\n2. Given `S : DiscreteQuotient X`, the projection `X → S` is denoted\n  `S.proj`.\n3. When `X` is compact and `S : DiscreteQuotient X`, the space `S` is\n  endowed with a `Fintype` instance.\n\n## Order structure\n\nThe type `DiscreteQuotient X` is endowed with an instance of a `SemilatticeInf` with `OrderTop`.\nThe partial ordering `A ≤ B` mathematically means that `B.proj` factors through `A.proj`.\nThe top element `⊤` is the trivial quotient, meaning that every element of `X` is collapsed\nto a point. Given `h : A ≤ B`, the map `A → B` is `DiscreteQuotient.ofLe h`.\n\nWhenever `X` is a locally connected space, the type `DiscreteQuotient X` is also endowed with an\ninstance of a `OrderBot`, where the bot element `⊥` is given by the `connectedComponentSetoid`,\ni.e., `x ~ y` means that `x` and `y` belong to the same connected component. In particular, if `X`\nis a discrete topological space, then `x ~ y` is equivalent (propositionally, not definitionally) to\n`x = y`.\n\nGiven `f : C(X, Y)`, we define a predicate `DiscreteQuotient.LeComap f A B` for `A :\nDiscreteQuotient X` and `B : DiscreteQuotient Y`, asserting that `f` descends to `A → B`.  If\n`cond : DiscreteQuotient.LeComap h A B`, the function `A → B` is obtained by\n`DiscreteQuotient.map f cond`.\n\n## Theorems\n\nThe two main results proved in this file are:\n\n1. `DiscreteQuotient.eq_of_forall_proj_eq` which states that when `X` is compact, T₂, and totally\n  disconnected, any two elements of `X` are equal if their projections in `Q` agree for all\n  `Q : DiscreteQuotient X`.\n\n2. `DiscreteQuotient.exists_of_compat` which states that when `X` is compact, then any\n  system of elements of `Q` as `Q : DiscreteQuotient X` varies, which is compatible with\n  respect to `DiscreteQuotient.ofLe`, must arise from some element of `X`.\n\n## Remarks\nThe constructions in this file will be used to show that any profinite space is a limit\nof finite discrete spaces.\n-/\n\n\nopen Set Function\n\nvariable {α X Y Z : Type _} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z]\n\n/-- The type of discrete quotients of a topological space. -/\n@[ext] -- porting note: in Lean 4, uses projection to `r` instead of `Setoid`.\nstructure DiscreteQuotient (X : Type _) [TopologicalSpace X] extends Setoid X where\n  /-- For every point `x`, the set `{ y | Rel x y }` is a clopen set. -/\n  protected isOpen_setOf_rel : ∀ x, IsOpen (setOf (toSetoid.Rel x))\n#align discrete_quotient DiscreteQuotient\n\nnamespace DiscreteQuotient\n\nvariable (S : DiscreteQuotient X)\n\n-- porting note: new lemma\nlemma toSetoid_injective : Function.Injective (@toSetoid X _)\n  | ⟨_, _⟩, ⟨_, _⟩, _ => by congr\n\n/-- Construct a discrete quotient from a clopen set. -/\ndef ofClopen {A : Set X} (h : IsClopen A) : DiscreteQuotient X where\n  toSetoid := ⟨fun x y => x ∈ A ↔ y ∈ A, fun _ => Iff.rfl,  Iff.symm,  Iff.trans⟩\n  isOpen_setOf_rel x := by by_cases hx : x ∈ A <;> simp [Setoid.Rel, hx, h.1, h.2, ← compl_setOf]\n#align discrete_quotient.of_clopen DiscreteQuotient.ofClopen\n\ntheorem refl : ∀ x, S.Rel x x := S.refl'\n#align discrete_quotient.refl DiscreteQuotient.refl\n\ntheorem symm (x y : X) : S.Rel x y → S.Rel y x := S.symm'\n#align discrete_quotient.symm DiscreteQuotient.symm\n\ntheorem trans (x y z : X) : S.Rel x y → S.Rel y z → S.Rel x z := S.trans'\n#align discrete_quotient.trans DiscreteQuotient.trans\n\n/-- The setoid whose quotient yields the discrete quotient. -/\nadd_decl_doc toSetoid\n\ninstance : CoeSort (DiscreteQuotient X) (Type _) :=\n  ⟨fun S => Quotient S.toSetoid⟩\n\ninstance : TopologicalSpace S :=\n  inferInstanceAs (TopologicalSpace (Quotient S.toSetoid))\n\n/-- The projection from `X` to the given discrete quotient. -/\ndef proj : X → S := Quotient.mk''\n#align discrete_quotient.proj DiscreteQuotient.proj\n\ntheorem fiber_eq (x : X) : S.proj ⁻¹' {S.proj x} = setOf (S.Rel x) :=\n  Set.ext fun _ => eq_comm.trans Quotient.eq''\n#align discrete_quotient.fiber_eq DiscreteQuotient.fiber_eq\n\ntheorem proj_surjective : Function.Surjective S.proj :=\n  Quotient.surjective_Quotient_mk''\n#align discrete_quotient.proj_surjective DiscreteQuotient.proj_surjective\n\ntheorem proj_quotientMap : QuotientMap S.proj :=\n  quotientMap_quot_mk\n#align discrete_quotient.proj_quotient_map DiscreteQuotient.proj_quotientMap\n\ntheorem proj_continuous : Continuous S.proj :=\n  S.proj_quotientMap.continuous\n#align discrete_quotient.proj_continuous DiscreteQuotient.proj_continuous\n\ninstance : DiscreteTopology S :=\n  singletons_open_iff_discrete.1 <| S.proj_surjective.forall.2 fun x => by\n    rw [← S.proj_quotientMap.isOpen_preimage, fiber_eq]\n    exact S.isOpen_setOf_rel _\n\ntheorem proj_isLocallyConstant : IsLocallyConstant S.proj :=\n  (IsLocallyConstant.iff_continuous S.proj).2 S.proj_continuous\n#align discrete_quotient.proj_is_locally_constant DiscreteQuotient.proj_isLocallyConstant\n\ntheorem isClopen_preimage (A : Set S) : IsClopen (S.proj ⁻¹' A) :=\n  (isClopen_discrete A).preimage S.proj_continuous\n#align discrete_quotient.is_clopen_preimage DiscreteQuotient.isClopen_preimage\n\ntheorem isOpen_preimage (A : Set S) : IsOpen (S.proj ⁻¹' A) :=\n  (S.isClopen_preimage A).1\n#align discrete_quotient.is_open_preimage DiscreteQuotient.isOpen_preimage\n\ntheorem isClosed_preimage (A : Set S) : IsClosed (S.proj ⁻¹' A) :=\n  (S.isClopen_preimage A).2\n#align discrete_quotient.is_closed_preimage DiscreteQuotient.isClosed_preimage\n\ntheorem isClopen_setOf_rel (x : X) : IsClopen (setOf (S.Rel x)) := by\n  rw [← fiber_eq]\n  apply isClopen_preimage\n#align discrete_quotient.is_clopen_set_of_rel DiscreteQuotient.isClopen_setOf_rel\n\ninstance : Inf (DiscreteQuotient X) :=\n  ⟨fun S₁ S₂ => ⟨S₁.1 ⊓ S₂.1, fun x => (S₁.2 x).inter (S₂.2 x)⟩⟩\n\ninstance : SemilatticeInf (DiscreteQuotient X) :=\n  Injective.semilatticeInf toSetoid toSetoid_injective fun _ _ => rfl\n\ninstance : OrderTop (DiscreteQuotient X) where\n  top := ⟨⊤, fun _ => isOpen_univ⟩\n  le_top a := by tauto\n\ninstance : Inhabited (DiscreteQuotient X) := ⟨⊤⟩\n\ninstance inhabitedQuotient [Inhabited X] : Inhabited S := ⟨S.proj default⟩\n#align discrete_quotient.inhabited_quotient DiscreteQuotient.inhabitedQuotient\n\n-- porting note: TODO: add instances about `Nonempty (Quot _)`/`Nonempty (Quotient _)`\ninstance [Nonempty X] : Nonempty S := Nonempty.map S.proj ‹_›\n\n-- porting note: new lemma\n/-- The quotient by `⊤ : DiscreteQuotient X` is a `Subsingleton`. -/\ninstance : Subsingleton (⊤ : DiscreteQuotient X) where\n  allEq := by rintro ⟨_⟩ ⟨_⟩; exact Quotient.sound trivial\n\nsection Comap\n\nvariable (g : C(Y, Z)) (f : C(X, Y))\n\n/-- Comap a discrete quotient along a continuous map. -/\ndef comap (S : DiscreteQuotient Y) : DiscreteQuotient X where\n  toSetoid := Setoid.comap f S.1\n  isOpen_setOf_rel _ := (S.2 _).preimage f.continuous\n#align discrete_quotient.comap DiscreteQuotient.comap\n\n@[simp]\ntheorem comap_id : S.comap (ContinuousMap.id X) = S := rfl\n#align discrete_quotient.comap_id DiscreteQuotient.comap_id\n\n@[simp]\ntheorem comap_comp (S : DiscreteQuotient Z) : S.comap (g.comp f) = (S.comap g).comap f :=\n  rfl\n#align discrete_quotient.comap_comp DiscreteQuotient.comap_comp\n\n@[mono]\ntheorem comap_mono {A B : DiscreteQuotient Y} (h : A ≤ B) : A.comap f ≤ B.comap f := by tauto\n#align discrete_quotient.comap_mono DiscreteQuotient.comap_mono\n\nend Comap\n\nsection OfLe\n\nvariable {A B C : DiscreteQuotient X}\n\n/-- The map induced by a refinement of a discrete quotient. -/\ndef ofLe (h : A ≤ B) : A → B :=\n  Quotient.map' (fun x => x) h\n#align discrete_quotient.of_le DiscreteQuotient.ofLe\n\n@[simp]\ntheorem ofLe_refl : ofLe (le_refl A) = id := by\n  ext ⟨⟩\n  rfl\n#align discrete_quotient.of_le_refl DiscreteQuotient.ofLe_refl\n\ntheorem ofLe_refl_apply (a : A) : ofLe (le_refl A) a = a := by simp\n#align discrete_quotient.of_le_refl_apply DiscreteQuotient.ofLe_refl_apply\n\n@[simp]\ntheorem ofLe_ofLe (h₁ : A ≤ B) (h₂ : B ≤ C) (x : A) : ofLe h₂ (ofLe h₁ x) = ofLe (h₁.trans h₂) x :=\n  by\n  rcases x with ⟨⟩\n  rfl\n#align discrete_quotient.of_le_of_le DiscreteQuotient.ofLe_ofLe\n\n@[simp]\ntheorem ofLe_comp_ofLe (h₁ : A ≤ B) (h₂ : B ≤ C) : ofLe h₂ ∘ ofLe h₁ = ofLe (le_trans h₁ h₂) :=\n  funext <| ofLe_ofLe _ _\n#align discrete_quotient.of_le_comp_of_le DiscreteQuotient.ofLe_comp_ofLe\n\ntheorem ofLe_continuous (h : A ≤ B) : Continuous (ofLe h) :=\n  continuous_of_discreteTopology\n#align discrete_quotient.of_le_continuous DiscreteQuotient.ofLe_continuous\n\n@[simp]\ntheorem ofLe_proj (h : A ≤ B) (x : X) : ofLe h (A.proj x) = B.proj x :=\n  Quotient.sound' (B.refl _)\n#align discrete_quotient.of_le_proj DiscreteQuotient.ofLe_proj\n\n@[simp]\ntheorem ofLe_comp_proj (h : A ≤ B) : ofLe h ∘ A.proj = B.proj :=\n  funext <| ofLe_proj _\n#align discrete_quotient.of_le_comp_proj DiscreteQuotient.ofLe_comp_proj\n\nend OfLe\n\n/-- When `X` is a locally connected space, there is an `OrderBot` instance on\n`DiscreteQuotient X`. The bottom element is given by `connectedComponentSetoid X`\n-/\ninstance [LocallyConnectedSpace X] : OrderBot (DiscreteQuotient X) where\n  bot :=\n    { toSetoid := connectedComponentSetoid X\n      isOpen_setOf_rel := fun x => by\n        convert isOpen_connectedComponent (x := x)\n        ext y\n        simpa only [connectedComponentSetoid, ← connectedComponent_eq_iff_mem] using eq_comm }\n  bot_le S := fun x y (h : connectedComponent x = connectedComponent y) =>\n    (S.isClopen_setOf_rel x).connectedComponent_subset (S.refl _) <| h.symm ▸ mem_connectedComponent\n\n@[simp]\ntheorem proj_bot_eq [LocallyConnectedSpace X] {x y : X} :\n    proj ⊥ x = proj ⊥ y ↔ connectedComponent x = connectedComponent y :=\n  Quotient.eq''\n#align discrete_quotient.proj_bot_eq DiscreteQuotient.proj_bot_eq\n\ntheorem proj_bot_inj [DiscreteTopology X] {x y : X} : proj ⊥ x = proj ⊥ y ↔ x = y := by simp\n#align discrete_quotient.proj_bot_inj DiscreteQuotient.proj_bot_inj\n\ntheorem proj_bot_injective [DiscreteTopology X] : Injective (⊥ : DiscreteQuotient X).proj :=\n  fun _ _ => proj_bot_inj.1\n#align discrete_quotient.proj_bot_injective DiscreteQuotient.proj_bot_injective\n\ntheorem proj_bot_bijective [DiscreteTopology X] : Bijective (⊥ : DiscreteQuotient X).proj :=\n  ⟨proj_bot_injective, proj_surjective _⟩\n#align discrete_quotient.proj_bot_bijective DiscreteQuotient.proj_bot_bijective\n\nsection Map\n\nvariable (f : C(X, Y)) (A A' : DiscreteQuotient X) (B B' : DiscreteQuotient Y)\n\n/-- Given `f : C(X, Y)`, `DiscreteQuotient.LeComap f A B` is defined as\n`A ≤ B.comap f`. Mathematically this means that `f` descends to a morphism `A → B`. -/\ndef LeComap : Prop :=\n  A ≤ B.comap f\n#align discrete_quotient.le_comap DiscreteQuotient.LeComap\n\ntheorem leComap_id : LeComap (.id X) A A := le_rfl\n#align discrete_quotient.le_comap_id DiscreteQuotient.leComap_id\n\nvariable {A A' B B'} {f} {g : C(Y, Z)} {C : DiscreteQuotient Z}\n\n@[simp]\ntheorem leComap_id_iff : LeComap (ContinuousMap.id X) A A' ↔ A ≤ A' :=\n  Iff.rfl\n#align discrete_quotient.le_comap_id_iff DiscreteQuotient.leComap_id_iff\n\ntheorem LeComap.comp : LeComap g B C → LeComap f A B → LeComap (g.comp f) A C := by tauto\n#align discrete_quotient.le_comap.comp DiscreteQuotient.LeComap.comp\n\n@[mono]\ntheorem LeComap.mono (h : LeComap f A B) (hA : A' ≤ A) (hB : B ≤ B') : LeComap f A' B' :=\n  hA.trans <| h.trans <| comap_mono _ hB\n#align discrete_quotient.le_comap.mono DiscreteQuotient.LeComap.mono\n\n/-- Map a discrete quotient along a continuous map. -/\ndef map (f : C(X, Y)) (cond : LeComap f A B) : A → B := Quotient.map' f cond\n#align discrete_quotient.map DiscreteQuotient.map\n\ntheorem map_continuous (cond : LeComap f A B) : Continuous (map f cond) :=\n  continuous_of_discreteTopology\n#align discrete_quotient.map_continuous DiscreteQuotient.map_continuous\n\n@[simp]\ntheorem map_comp_proj (cond : LeComap f A B) : map f cond ∘ A.proj = B.proj ∘ f :=\n  rfl\n#align discrete_quotient.map_comp_proj DiscreteQuotient.map_comp_proj\n\n@[simp]\ntheorem map_proj (cond : LeComap f A B) (x : X) : map f cond (A.proj x) = B.proj (f x) :=\n  rfl\n#align discrete_quotient.map_proj DiscreteQuotient.map_proj\n\n@[simp]\ntheorem map_id : map _ (leComap_id A) = id := by ext ⟨⟩; rfl\n#align discrete_quotient.map_id DiscreteQuotient.map_id\n\n-- porting note: todo: figure out why `simpNF` says this is a bad `@[simp]` lemma\ntheorem map_comp (h1 : LeComap g B C) (h2 : LeComap f A B) :\n    map (g.comp f) (h1.comp h2) = map g h1 ∘ map f h2 := by\n  ext ⟨⟩\n  rfl\n#align discrete_quotient.map_comp DiscreteQuotient.map_comp\n\n@[simp]\ntheorem ofLe_map (cond : LeComap f A B) (h : B ≤ B') (a : A) :\n    ofLe h (map f cond a) = map f (cond.mono le_rfl h) a := by\n  rcases a with ⟨⟩\n  rfl\n#align discrete_quotient.of_le_map DiscreteQuotient.ofLe_map\n\n@[simp]\ntheorem ofLe_comp_map (cond : LeComap f A B) (h : B ≤ B') :\n    ofLe h ∘ map f cond = map f (cond.mono le_rfl h) :=\n  funext <| ofLe_map cond h\n#align discrete_quotient.of_le_comp_map DiscreteQuotient.ofLe_comp_map\n\n@[simp]\ntheorem map_ofLe (cond : LeComap f A B) (h : A' ≤ A) (c : A') :\n    map f cond (ofLe h c) = map f (cond.mono h le_rfl) c := by\n  rcases c with ⟨⟩\n  rfl\n#align discrete_quotient.map_of_le DiscreteQuotient.map_ofLe\n\n@[simp]\ntheorem map_comp_ofLe (cond : LeComap f A B) (h : A' ≤ A) :\n    map f cond ∘ ofLe h = map f (cond.mono h le_rfl) :=\n  funext <| map_ofLe cond h\n#align discrete_quotient.map_comp_of_le DiscreteQuotient.map_comp_ofLe\n\nend Map\n\n\n\ntheorem fiber_subset_ofLe {A B : DiscreteQuotient X} (h : A ≤ B) (a : A) :\n    A.proj ⁻¹' {a} ⊆ B.proj ⁻¹' {ofLe h a} := by\n  rcases A.proj_surjective a with ⟨a, rfl⟩\n  rw [fiber_eq, ofLe_proj, fiber_eq]\n  exact fun _ h' => h h'\n#align discrete_quotient.fiber_subset_of_le DiscreteQuotient.fiber_subset_ofLe\n\ntheorem exists_of_compat [CompactSpace X] (Qs : (Q : DiscreteQuotient X) → Q)\n    (compat : ∀ (A B : DiscreteQuotient X) (h : A ≤ B), ofLe h (Qs _) = Qs _) :\n    ∃ x : X, ∀ Q : DiscreteQuotient X, Q.proj x = Qs _ := by\n  have H₁ : ∀ Q₁ Q₂, Q₁ ≤ Q₂ → proj Q₁ ⁻¹' {Qs Q₁} ⊆ proj Q₂ ⁻¹' {Qs Q₂} := fun _ _ h => by\n    rw [← compat _ _ h]\n    exact fiber_subset_ofLe _ _\n  obtain ⟨x, hx⟩ : Set.Nonempty (⋂ Q, proj Q ⁻¹' {Qs Q}) :=\n    IsCompact.nonempty_interᵢ_of_directed_nonempty_compact_closed\n      (fun Q : DiscreteQuotient X => Q.proj ⁻¹' {Qs _}) (directed_of_inf H₁)\n      (fun Q => (singleton_nonempty _).preimage Q.proj_surjective)\n      (fun Q => (Q.isClosed_preimage {Qs _}).isCompact) fun Q => Q.isClosed_preimage _\n  exact ⟨x, mem_interᵢ.1 hx⟩\n#align discrete_quotient.exists_of_compat DiscreteQuotient.exists_of_compat\n\n/-- If `X` is a compact space, then any discrete quotient of `X` is finite. -/\ninstance [CompactSpace X] : Finite S := by\n  have : CompactSpace S := Quotient.compactSpace\n  rwa [← isCompact_univ_iff, isCompact_iff_finite, finite_univ_iff] at this\n\nend DiscreteQuotient\n\nnamespace LocallyConstant\n\nvariable (f : LocallyConstant X α)\n\n/-- Any locally constant function induces a discrete quotient. -/\ndef discreteQuotient : DiscreteQuotient X where\n  toSetoid := .comap f ⊥\n  isOpen_setOf_rel _ := f.isLocallyConstant _\n#align locally_constant.discrete_quotient LocallyConstant.discreteQuotient\n\n/-- The (locally constant) function from the discrete quotient associated to a locally constant\nfunction. -/\ndef lift : LocallyConstant f.discreteQuotient α :=\n  ⟨fun a => Quotient.liftOn' a f fun _ _ => id, fun _ => isOpen_discrete _⟩\n#align locally_constant.lift LocallyConstant.lift\n\n@[simp]\ntheorem lift_comp_proj : f.lift ∘ f.discreteQuotient.proj = f := rfl\n#align locally_constant.lift_comp_proj LocallyConstant.lift_comp_proj\n\nend LocallyConstant\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Topology/DiscreteQuotient.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.4950793590157027}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.category.Group.abelian\nimport category_theory.limits.shapes.images\nimport category_theory.limits.types\n\n/-!\n# The category of commutative additive groups has images.\n\nNote that we don't need to register any of the constructions here as instances, because we get them\nfrom the fact that `AddCommGroup` is an abelian category.\n-/\n\nopen category_theory\nopen category_theory.limits\n\nuniverse u\n\nnamespace AddCommGroup\n\n-- Note that because `injective_of_mono` is currently only proved in `Type 0`,\n-- we restrict to the lowest universe here for now.\nvariables {G H : AddCommGroup.{0}} (f : G ⟶ H)\n\nlocal attribute [ext] subtype.ext_val\n\nsection -- implementation details of `has_image` for AddCommGroup; use the API, not these\n/-- the image of a morphism in AddCommGroup is just the bundling of `add_monoid_hom.range f` -/\ndef image : AddCommGroup := AddCommGroup.of (add_monoid_hom.range f)\n\n/-- the inclusion of `image f` into the target -/\ndef image.ι : image f ⟶ H := f.range.subtype\n\ninstance : mono (image.ι f) := concrete_category.mono_of_injective (image.ι f) subtype.val_injective\n\n/-- the corestriction map to the image -/\ndef factor_thru_image : G ⟶ image f := f.range_restrict\n\nlemma image.fac : factor_thru_image f ≫ image.ι f = f :=\nby { ext, refl, }\n\nlocal attribute [simp] image.fac\n\nvariables {f}\n/-- the universal property for the image factorisation -/\nnoncomputable def image.lift (F' : mono_factorisation f) : image f ⟶ F'.I :=\n{ to_fun :=\n  (λ x, F'.e (classical.indefinite_description _ x.2).1 : image f → F'.I),\n  map_zero' :=\n  begin\n    haveI := F'.m_mono,\n    apply injective_of_mono F'.m,\n    change (F'.e ≫ F'.m) _ = _,\n    rw [F'.fac, add_monoid_hom.map_zero],\n    exact (classical.indefinite_description (λ y, f y = 0) _).2,\n  end,\n  map_add' :=\n  begin\n    intros x y,\n    haveI := F'.m_mono,\n    apply injective_of_mono F'.m,\n    rw [add_monoid_hom.map_add],\n    change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _,\n    rw [F'.fac],\n    rw (classical.indefinite_description (λ z, f z = _) _).2,\n    rw (classical.indefinite_description (λ z, f z = _) _).2,\n    rw (classical.indefinite_description (λ z, f z = _) _).2,\n    refl,\n  end,\n }\nlemma image.lift_fac (F' : mono_factorisation f) : image.lift F' ≫ F'.m = image.ι f :=\nbegin\n  ext x,\n  change (F'.e ≫ F'.m) _ = _,\n  rw [F'.fac, (classical.indefinite_description _ x.2).2],\n  refl,\nend\nend\n\n/-- the factorisation of any morphism in AddCommGroup through a mono. -/\ndef mono_factorisation : mono_factorisation f :=\n{ I := image f,\n  m := image.ι f,\n  e := factor_thru_image f }\n\n/-- the factorisation of any morphism in AddCommGroup through a mono has the universal property of\nthe image. -/\nnoncomputable def is_image : is_image (mono_factorisation f) :=\n{ lift := image.lift,\n  lift_fac' := image.lift_fac }\n\n/--\nThe categorical image of a morphism in `AddCommGroup`\nagrees with the usual group-theoretical range.\n-/\nnoncomputable def image_iso_range {G H : AddCommGroup.{0}} (f : G ⟶ H) :\n  limits.image f ≅ AddCommGroup.of f.range :=\nis_image.iso_ext (image.is_image f) (is_image f)\n\nend AddCommGroup\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/category/Group/images.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.4950793497483759}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module control.random\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Control.Uliftable\nimport Mathbin.Data.Bitvec.Basic\nimport Mathbin.Data.Stream.Defs\nimport Mathbin.Tactic.NormNum\n\n/-!\n# Rand Monad and Random Class\n\nThis module provides tools for formulating computations guided by randomness and for\ndefining objects that can be created randomly.\n\n## Main definitions\n  * `rand` monad for computations guided by randomness;\n  * `random` class for objects that can be generated randomly;\n    * `random` to generate one object;\n    * `random_r` to generate one object inside a range;\n    * `random_series` to generate an infinite series of objects;\n    * `random_series_r` to generate an infinite series of objects inside a range;\n  * `io.mk_generator` to create a new random number generator;\n  * `io.run_rand` to run a randomized computation inside the `io` monad;\n  * `tactic.run_rand` to run a randomized computation inside the `tactic` monad\n\n## Local notation\n\n * `i .. j` : `Icc i j`, the set of values between `i` and `j` inclusively;\n\n## Tags\n\nrandom monad io\n\n## References\n\n  * Similar library in Haskell: https://hackage.haskell.org/package/MonadRandom\n\n-/\n\n\nopen List Io Applicative\n\nuniverse u v w\n\n#print RandG /-\n/-- A monad to generate random objects using the generator type `g` -/\n@[reducible]\ndef RandG (g : Type) (α : Type u) : Type u :=\n  StateM (ULift.{u} g) α\n#align rand_g RandG\n-/\n\n#print Rand /-\n/-- A monad to generate random objects using the generator type `std_gen` -/\n@[reducible]\ndef Rand :=\n  RandG StdGen\n#align rand Rand\n-/\n\ninstance (g : Type) : Uliftable (RandG.{u} g) (RandG.{v} g) :=\n  @StateT.uliftable' _ _ _ _ _ (Equiv.ulift.trans Equiv.ulift.symm)\n\nopen ULift hiding Inhabited\n\n/-- Generate one more `ℕ` -/\ndef RandG.next {g : Type} [RandomGen g] : RandG g ℕ :=\n  ⟨Prod.map id up ∘ RandomGen.next ∘ down⟩\n#align rand_g.next RandG.next\n\n-- mathport name: «expr .. »\nlocal infixl:41 \" .. \" => Set.Icc\n\nopen Stream'\n\n#print BoundedRandom /-\n/-- `bounded_random α` gives us machinery to generate values of type `α` between certain bounds -/\nclass BoundedRandom (α : Type u) [Preorder α] where\n  randomR : ∀ (g) [RandomGen g] (x y : α), x ≤ y → RandG g (x .. y)\n#align bounded_random BoundedRandom\n-/\n\n#print Random /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`Random] [] -/\n/-- `random α` gives us machinery to generate values of type `α` -/\nclass Random (α : Type u) where\n  Random : ∀ (g : Type) [RandomGen g], RandG g α\n#align random Random\n-/\n\n/-- shift_31_left = 2^31; multiplying by it shifts the binary\nrepresentation of a number left by 31 bits, dividing by it shifts it\nright by 31 bits -/\ndef shift31Left : ℕ := by apply_normed 2 ^ 31\n#align shift_31_left shift31Left\n\nnamespace Rand\n\nopen Stream'\n\nvariable (α : Type u)\n\nvariable (g : Type) [RandomGen g]\n\n#print Rand.split /-\n/-- create a new random number generator distinct from the one stored in the state -/\ndef split : RandG g g :=\n  ⟨Prod.map id up ∘ RandomGen.split ∘ down⟩\n#align rand.split Rand.split\n-/\n\nvariable {g}\n\nsection Random\n\nvariable [Random α]\n\nexport Random (Random)\n\n/-- Generate a random value of type `α`. -/\ndef random : RandG g α :=\n  Random.random α g\n#align rand.random Rand.random\n\n/-- generate an infinite series of random values of type `α` -/\ndef randomSeries : RandG g (Stream' α) := do\n  let gen ← Uliftable.up (split g)\n  pure <| Stream'.corecState (Random.random α g) gen\n#align rand.random_series Rand.randomSeries\n\nend Random\n\nvariable {α}\n\n/-- Generate a random value between `x` and `y` inclusive. -/\ndef randomR [Preorder α] [BoundedRandom α] (x y : α) (h : x ≤ y) : RandG g (x .. y) :=\n  BoundedRandom.randomR g x y h\n#align rand.random_r Rand.randomR\n\n/-- generate an infinite series of random values of type `α` between `x` and `y` inclusive. -/\ndef randomSeriesR [Preorder α] [BoundedRandom α] (x y : α) (h : x ≤ y) :\n    RandG g (Stream' (x .. y)) := do\n  let gen ← Uliftable.up (split g)\n  pure <| corec_state (BoundedRandom.randomR g x y h) gen\n#align rand.random_series_r Rand.randomSeriesR\n\nend Rand\n\nnamespace Io\n\nprivate def accum_char (w : ℕ) (c : Char) : ℕ :=\n  c.toNat + 256 * w\n#align io.accum_char io.accum_char\n\n/-- create and seed a random number generator -/\ndef mkGenerator : Io StdGen := do\n  let seed ← Io.rand 0 shift31Left\n  return <| mkStdGen seed\n#align io.mk_generator Io.mkGenerator\n\nvariable {α : Type}\n\n/-- Run `cmd` using a randomly seeded random number generator -/\ndef runRand (cmd : Rand α) : Io α := do\n  let g ← Io.mkGenerator\n  return <| (cmd ⟨g⟩).1\n#align io.run_rand Io.runRand\n\n/-- Run `cmd` using the provided seed. -/\ndef runRandWith (seed : ℕ) (cmd : Rand α) : Io α :=\n  return <| (cmd.run ⟨mkStdGen seed⟩).1\n#align io.run_rand_with Io.runRandWith\n\nsection Random\n\nvariable [Random α]\n\n/-- randomly generate a value of type α -/\ndef random : Io α :=\n  Io.runRand (Rand.random α)\n#align io.random Io.random\n\n/-- randomly generate an infinite series of value of type α -/\ndef randomSeries : Io (Stream' α) :=\n  Io.runRand (Rand.randomSeries α)\n#align io.random_series Io.randomSeries\n\nend Random\n\nsection BoundedRandom\n\nvariable [Preorder α] [BoundedRandom α]\n\n/-- randomly generate a value of type α between `x` and `y` -/\ndef randomR (x y : α) (p : x ≤ y) : Io (x .. y) :=\n  Io.runRand (BoundedRandom.randomR _ x y p)\n#align io.random_r Io.randomR\n\n/-- randomly generate an infinite series of value of type α between `x` and `y` -/\ndef randomSeriesR (x y : α) (h : x ≤ y) : Io (Stream' <| x .. y) :=\n  Io.runRand (Rand.randomSeriesR x y h)\n#align io.random_series_r Io.randomSeriesR\n\nend BoundedRandom\n\nend Io\n\nnamespace Tactic\n\n/-- create a seeded random number generator in the `tactic` monad -/\nunsafe def mk_generator : tactic StdGen := do\n  tactic.unsafe_run_io @Io.mkGenerator\n#align tactic.mk_generator tactic.mk_generator\n\n/-- run `cmd` using the a randomly seeded random number generator\nin the tactic monad -/\nunsafe def run_rand {α : Type u} (cmd : Rand α) : tactic α := do\n  let ⟨g⟩ ← tactic.up mk_generator\n  return (cmd ⟨g⟩).1\n#align tactic.run_rand tactic.run_rand\n\nvariable {α : Type u}\n\nsection BoundedRandom\n\nvariable [Preorder α] [BoundedRandom α]\n\n/-- Generate a random value between `x` and `y` inclusive. -/\nunsafe def random_r (x y : α) (h : x ≤ y) : tactic (x .. y) :=\n  run_rand (Rand.randomR x y h)\n#align tactic.random_r tactic.random_r\n\n/-- Generate an infinite series of random values of type `α` between `x` and `y` inclusive. -/\nunsafe def random_series_r (x y : α) (h : x ≤ y) : tactic (Stream' <| x .. y) :=\n  run_rand (Rand.randomSeriesR x y h)\n#align tactic.random_series_r tactic.random_series_r\n\nend BoundedRandom\n\nsection Random\n\nvariable [Random α]\n\n/-- randomly generate a value of type α -/\nunsafe def random : tactic α :=\n  run_rand (Rand.random α)\n#align tactic.random tactic.random\n\n/-- randomly generate an infinite series of value of type α -/\nunsafe def random_series : tactic (Stream' α) :=\n  run_rand (Rand.randomSeries α)\n#align tactic.random_series tactic.random_series\n\nend Random\n\nend Tactic\n\nopen Nat (succ one_add mod_eq_of_lt zero_lt_succ add_one succ_le_succ)\n\nvariable {g : Type} [RandomGen g]\n\nopen Nat\n\nnamespace Fin\n\nvariable {n : ℕ} [NeZero n]\n\n/-- generate a `fin` randomly -/\nprotected def random : RandG g (Fin n) :=\n  ⟨fun ⟨g⟩ => Prod.map ofNat'' up <| randNat g 0 n⟩\n#align fin.random Fin.random\n\nend Fin\n\nopen Nat\n\ninstance natBoundedRandom : BoundedRandom ℕ\n    where randomR g inst x y hxy := do\n    let z ← @Fin.random g inst (succ <| y - x) _\n    pure\n        ⟨z + x, Nat.le_add_left _ _, by\n          rw [← le_tsub_iff_right hxy] <;> apply le_of_succ_le_succ z.is_lt⟩\n#align nat_bounded_random natBoundedRandom\n\n/-- This `bounded_random` interval generates integers between `x` and\n`y` by first generating a natural number between `0` and `y - x` and\nshifting the result appropriately. -/\ninstance intBoundedRandom : BoundedRandom ℤ\n    where randomR g inst x y hxy := do\n    let ⟨z, h₀, h₁⟩ ← @BoundedRandom.randomR ℕ _ _ g inst 0 (Int.natAbs <| y - x) (by decide)\n    pure\n        ⟨z + x, Int.le_add_of_nonneg_left (Int.coe_nat_nonneg _),\n          Int.add_le_of_le_sub_right <|\n            le_trans (Int.ofNat_le_ofNat_of_le h₁)\n              (le_of_eq <| Int.ofNat_natAbs_eq_of_nonneg (Int.sub_nonneg_of_le hxy))⟩\n#align int_bounded_random intBoundedRandom\n\ninstance finRandom (n : ℕ) [NeZero n] : Random (Fin n) where Random g inst := @Fin.random g inst _ _\n#align fin_random finRandom\n\ninstance finBoundedRandom (n : ℕ) : BoundedRandom (Fin n)\n    where randomR g inst (x y : Fin n) p := do\n    let ⟨r, h, h'⟩ ← @Rand.randomR ℕ g inst _ _ x.val y.val p\n    pure ⟨⟨r, lt_of_le_of_lt h' y⟩, h, h'⟩\n#align fin_bounded_random finBoundedRandom\n\n/-- A shortcut for creating a `random (fin n)` instance from\na proof that `0 < n` rather than on matching on `fin (succ n)`  -/\ndef randomFinOfPos : ∀ {n : ℕ} (h : 0 < n), Random (Fin n)\n  | succ n, _ => finRandom _\n  | 0, h => False.elim (Nat.not_lt_zero _ h)\n#align random_fin_of_pos randomFinOfPos\n\ntheorem bool_ofNat_mem_Icc_of_mem_Icc_toNat (x y : Bool) (n : ℕ) :\n    n ∈ (x.toNat .. y.toNat) → Bool.ofNat n ∈ (x .. y) :=\n  by\n  simp only [and_imp, Set.mem_Icc]; intro h₀ h₁\n  constructor <;> [have h₂ := Bool.ofNat_le_ofNat h₀, have h₂ := Bool.ofNat_le_ofNat h₁] <;>\n      rw [Bool.ofNat_toNat] at h₂ <;>\n    exact h₂\n#align bool_of_nat_mem_Icc_of_mem_Icc_to_nat bool_ofNat_mem_Icc_of_mem_Icc_toNat\n\ninstance : Random Bool\n    where Random g inst :=\n    (Bool.ofNat ∘ Subtype.val) <$> @BoundedRandom.randomR ℕ _ _ g inst 0 1 (Nat.zero_le _)\n\ninstance : BoundedRandom Bool\n    where randomR g _inst x y p :=\n    Subtype.map Bool.ofNat (bool_ofNat_mem_Icc_of_mem_Icc_toNat x y) <$>\n      @BoundedRandom.randomR ℕ _ _ g _inst x.toNat y.toNat (Bool.toNat_le_toNat p)\n\n/-- generate a random bit vector of length `n` -/\ndef Bitvec.random (n : ℕ) : RandG g (Bitvec n) :=\n  Bitvec.ofFin <$> Rand.random (Fin <| 2 ^ n)\n#align bitvec.random Bitvec.random\n\n/-- generate a random bit vector of length `n` -/\ndef Bitvec.randomR {n : ℕ} (x y : Bitvec n) (h : x ≤ y) : RandG g (x .. y) :=\n  have h' : ∀ a : Fin (2 ^ n), a ∈ (x.toFin .. y.toFin) → Bitvec.ofFin a ∈ (x .. y) :=\n    by\n    simp only [and_imp, Set.mem_Icc]; intro z h₀ h₁\n    replace h₀ := Bitvec.ofFin_le_ofFin_of_le h₀\n    replace h₁ := Bitvec.ofFin_le_ofFin_of_le h₁\n    rw [Bitvec.ofFin_toFin] at h₀ h₁; constructor <;> assumption\n  Subtype.map Bitvec.ofFin h' <$> Rand.randomR x.toFin y.toFin (Bitvec.toFin_le_toFin_of_le h)\n#align bitvec.random_r Bitvec.randomR\n\nopen Nat\n\ninstance randomBitvec (n : ℕ) : Random (Bitvec n) where Random _ inst := @Bitvec.random _ inst n\n#align random_bitvec randomBitvec\n\ninstance boundedRandomBitvec (n : ℕ) : BoundedRandom (Bitvec n)\n    where randomR _ inst x y p := @Bitvec.randomR _ inst _ _ _ p\n#align bounded_random_bitvec boundedRandomBitvec\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Control/Random.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696748, "lm_q2_score": 0.6261241842048092, "lm_q1q2_score": 0.494970150866218}}
{"text": "import Mathbin.Data.Real.Basic\nimport Mathbin.LinearAlgebra.Matrix.Default\nimport Lean\n\nattribute [-instance] coeDecidableEq\n\nmacro \"ℝ\" : term => \n  do return Lean.TSyntax.raw (← `(Real))\nmacro \"∑\" i:Lean.Parser.Term.funBinder \",\" t:term : term => \n  do return Lean.TSyntax.raw (← `(Finset.sum Finset.univ (fun $i => $t)))\nmacro \"∑\" i:Lean.Parser.Term.funBinder \"in\" s:term \",\" t:term : term => \n  do return Lean.TSyntax.raw (← `(Finset.sum $s (fun $i => $t)))\nmacro \"∏\" i:Lean.Parser.Term.funBinder \",\" t:term : term => \n  do return Lean.TSyntax.raw (← `(Finset.prod Finset.univ (fun $i => $t)))\nmacro \"∏\" i:Lean.Parser.Term.funBinder \"in\" s:term \",\" t:term : term => \n  do return Lean.TSyntax.raw (← `(Finset.prod $s (fun $i => $t)))\nmacro:75 l:term:75 \" ⬝ \" r:term:76 : term => \n  do return Lean.TSyntax.raw (← `(Matrix.mul $l $r))\nmacro:75 l:term:75 \" ⬝ᵥ \" r:term:76 : term => \n  do return Lean.TSyntax.raw (← `(Matrix.dotProduct $l $r))\nmacro:50 l:term:50 \" ∈ \" r:term:51 : term => \n  do return Lean.TSyntax.raw (← `(HasMem.Mem $l $r))\nmacro:75 l:term:75 \" • \" r:term:76 : term => \n  do return Lean.TSyntax.raw (← `(HasSmul.smul $l $r))\n\nmacro \"![\" ts:term,* \"]\" : term => do\n  let ts : Array (Lean.TSyntax _) := ts.getElems\n  let res ← ts.foldrM (init := ← `(Matrix.vecEmpty)) fun t acc =>\n      `(Matrix.vecCons $t $acc)\n  return res.raw\n\nsection Logic\n\n@[simp] theorem and_left_comm (a b c : Prop) : (a ∧ (b ∧ c)) = (b ∧ (a ∧ c)) := by rw [← and_assoc, and_comm a b, and_assoc]\n\nend Logic\n\nnamespace Nat\n\ninstance : LE ℕ := { le := Nat.le }\n\nattribute [-instance] Nat.hasSub\ninstance : Sub ℕ :=\n  ⟨Nat.sub⟩\n\nattribute [-instance] Nat.hasAdd\ninstance : Add ℕ :=\n  ⟨Nat.add⟩\n\nattribute [-instance] Nat.hasMul\ninstance : Mul ℕ :=\n  ⟨Nat.mul⟩\n\nattribute [-instance] Nat.inhabited\ninstance inhabited' : Inhabited ℕ :=\n  ⟨Nat.zero⟩\n\ninstance decidableEq' : DecidableEq ℕ\n  | zero, zero => isTrue rfl\n  | succ x, zero => isFalse fun h => Nat.noConfusion h\n  | zero, succ y => isFalse fun h => Nat.noConfusion h\n  | succ x, succ y =>\n    match Nat.decidableEq' x y with\n    | Decidable.isTrue xeqy => isTrue (xeqy ▸ Eq.refl (succ x))\n    | Decidable.isFalse xney => isFalse fun h => Nat.noConfusion h fun xeqy => absurd xeqy xney\n\nend Nat\n\nnamespace Pi\n\nattribute [-instance] Pi.hasZero\ninstance hasZero' {I : Type} {f : I → Type} [∀ i, Zero (f i)] : Zero (∀ i : I, f i) :=\n  ⟨fun _ => Zero.zero⟩\n\nattribute [-instance] Pi.hasOne\ninstance hasOne' {I : Type} {f : I → Type} [∀ i, One (f i)] : One (∀ i : I, f i) :=\n  ⟨fun _ => One.one⟩\n\nend Pi\n\nnamespace Bool\n\nattribute [-instance] Bool.inhabited\ninstance Bool.inhabited' : Inhabited Bool :=\n  ⟨false⟩\n\nend Bool\n\nnamespace Prod\n\nattribute [-instance] Prod.inhabited\ninstance Prod.inhabited' [Inhabited α] [Inhabited β] : Inhabited (Prod α β) :=\n  ⟨(default, default)⟩\n\nend Prod\n\nnamespace List\n\nattribute [-instance] List.inhabited\ninstance List.inhabited' (α : Type u) : Inhabited (List α) :=\n  ⟨List.nil⟩\n\nattribute [-instance] List.hasAppend\ninstance : Append (List α) :=\n  ⟨List.append⟩\n\nend List\n\nnamespace Lean\n\ninstance (sep) : Coe (Syntax.SepArray sep) (Array Syntax) where\n  coe := Syntax.SepArray.getElems\n\nend Lean\n\nsection LinearOrder\n\nvariable [LinearOrderₓ α]\n\ninstance (a b : α) : Decidable (a < b) :=\n  LinearOrderₓ.decidableLt a b\n\ninstance (a b : α) : Decidable (a ≤ b) :=\n  LinearOrderₓ.decidableLe a b\n\ninstance (a b : α) : Decidable (a = b) :=\n  LinearOrderₓ.decidableEq a b\n\nend LinearOrder\n\nnamespace Int\n\nattribute [-instance] Int.decidableLt\ninstance Int.decidableLt' : LT Int :=\n  ⟨Int.Lt⟩\n\nattribute [-instance] Int.linearOrder Int.hasSub\n\ninstance Int.hasZero' : Zero ℤ :=\n  ⟨ofNat 0⟩\n\ninstance Int.hasOne' : One ℤ :=\n  ⟨ofNat 1⟩\n\ninstance Int.hasSub' : Sub ℤ :=\n  ⟨Int.sub⟩\n\ninstance Int.hasSAdd' : Add ℤ :=\n  ⟨Int.add⟩\n\ninstance Decidable.true' : Decidable True :=\n  isTrue trivialₓ\n\ninstance Decidable.false' : Decidable False :=\n  isFalse not_false\n\ndef decidableNonneg' (a : ℤ) : Decidable (Nonneg a) :=\n  Int.casesOn a (fun a => Decidable.true') fun a => Decidable.false'\n\ninstance decidableLe' (a b : ℤ) : Decidable (a ≤ b) :=\n  decidableNonneg' (b - a)\n\ninstance decidableLt' (a b : ℤ) : Decidable (a < b) :=\n  decidableNonneg' (b - (a + ofNat 1))\n\ninstance decidableEq' (a b : ℤ) : Decidable (a = b) :=\nmatch a, b with\n| ofNat a, ofNat b => by rw [ofNat_eq_ofNat_iff]; apply Nat.decidableEq'\n| negSucc a, ofNat b => Decidable.isFalse λ h => by cases h\n| ofNat a, negSucc b => Decidable.isFalse λ h => by cases h\n| negSucc a, negSucc b => by rw [negSucc_ofNat_inj_iff]; apply Nat.decidableEq'\n\nend Int\n\ndef Implies.decidable' [Decidable p] [Decidable q] : Decidable (p → q) :=\n  if hp : p then if hq : q then isTrue fun h => hq else isFalse fun h : p → q => absurd (h hp) hq\n  else isTrue fun h => absurd h hp\n\nattribute [-instance] Ne.decidable\ninstance Ne.decidable' {α : Sort u} [DecidableEq α] (a b : α) : Decidable (a ≠ b) :=\n  Implies.decidable'\n", "meta": {"author": "verified-optimization", "repo": "CvxLean", "sha": "fc2996519f0fca96f5ab48a5a1479c6a8024f733", "save_path": "github-repos/lean/verified-optimization-CvxLean", "path": "github-repos/lean/verified-optimization-CvxLean/CvxLean-fc2996519f0fca96f5ab48a5a1479c6a8024f733/CvxLean/Lib/Missing/Mathlib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303087996142, "lm_q2_score": 0.6261241842048092, "lm_q1q2_score": 0.4949701446863343}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.shapes.terminal\nimport category_theory.limits.preserves.basic\n\n/-!\n# Preserving terminal object\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nConstructions to relate the notions of preserving terminal objects and reflecting terminal objects\nto concrete objects.\n\nIn particular, we show that `terminal_comparison G` is an isomorphism iff `G` preserves terminal\nobjects.\n-/\n\nuniverses w v v₁ v₂ u u₁ u₂\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u₁} [category.{v₁} C]\nvariables {D : Type u₂} [category.{v₂} D]\nvariables (G : C ⥤ D)\n\nnamespace category_theory.limits\n\nvariables (X : C)\n\nsection terminal\n\n/--\nThe map of an empty cone is a limit iff the mapped object is terminal.\n-/\ndef is_limit_map_cone_empty_cone_equiv :\n  is_limit (G.map_cone (as_empty_cone X)) ≃ is_terminal (G.obj X) :=\nis_limit_empty_cone_equiv D _ _ (eq_to_iso rfl)\n\n/-- The property of preserving terminal objects expressed in terms of `is_terminal`. -/\ndef is_terminal.is_terminal_obj [preserves_limit (functor.empty.{0} C) G]\n  (l : is_terminal X) : is_terminal (G.obj X) :=\nis_limit_map_cone_empty_cone_equiv G X (preserves_limit.preserves l)\n\n/-- The property of reflecting terminal objects expressed in terms of `is_terminal`. -/\ndef is_terminal.is_terminal_of_obj [reflects_limit (functor.empty.{0} C) G]\n  (l : is_terminal (G.obj X)) : is_terminal X :=\nreflects_limit.reflects ((is_limit_map_cone_empty_cone_equiv G X).symm l)\n\n/-- Preserving the terminal object implies preserving all limits of the empty diagram. -/\ndef preserves_limits_of_shape_pempty_of_preserves_terminal\n  [preserves_limit (functor.empty.{0} C) G] : preserves_limits_of_shape (discrete pempty) G :=\n{ preserves_limit := λ K,\n    preserves_limit_of_iso_diagram G (functor.empty_ext (functor.empty.{0} C) _) }\n\nvariables [has_terminal C]\n/--\nIf `G` preserves the terminal object and `C` has a terminal object, then the image of the terminal\nobject is terminal.\n-/\ndef is_limit_of_has_terminal_of_preserves_limit [preserves_limit (functor.empty.{0} C) G] :\n  is_terminal (G.obj (⊤_ C)) :=\nterminal_is_terminal.is_terminal_obj G (⊤_ C)\n\n/--\nIf `C` has a terminal object and `G` preserves terminal objects, then `D` has a terminal object\nalso.\nNote this property is somewhat unique to (co)limits of the empty diagram: for general `J`, if `C`\nhas limits of shape `J` and `G` preserves them, then `D` does not necessarily have limits of shape\n`J`.\n-/\nlemma has_terminal_of_has_terminal_of_preserves_limit [preserves_limit (functor.empty.{0} C) G] :\n  has_terminal D :=\n⟨λ F,\nbegin\n  haveI := has_limit.mk ⟨_, is_limit_of_has_terminal_of_preserves_limit G⟩,\n  apply has_limit_of_iso F.unique_from_empty.symm,\nend⟩\n\nvariable [has_terminal D]\n/--\nIf the terminal comparison map for `G` is an isomorphism, then `G` preserves terminal objects.\n-/\ndef preserves_terminal.of_iso_comparison\n  [i : is_iso (terminal_comparison G)] : preserves_limit (functor.empty C) G :=\nbegin\n  apply preserves_limit_of_preserves_limit_cone terminal_is_terminal,\n  apply (is_limit_map_cone_empty_cone_equiv _ _).symm _,\n  apply is_limit.of_point_iso (limit.is_limit (functor.empty.{0} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `G.obj ⊤ ⟶ ⊤`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_is_iso\n  (f : G.obj (⊤_ C) ⟶ ⊤_ D) [i : is_iso f] : preserves_limit (functor.empty C) G :=\nbegin\n  rw subsingleton.elim f (terminal_comparison G) at i,\n  exactI preserves_terminal.of_iso_comparison G,\nend\n\n/-- If there is any isomorphism `G.obj ⊤ ≅ ⊤`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_iso\n  (f : G.obj (⊤_ C) ≅ ⊤_ D) : preserves_limit (functor.empty C) G :=\npreserves_terminal_of_is_iso G f.hom\n\nvariables [preserves_limit (functor.empty.{0} C) G]\n\n/--\nIf `G` preserves terminal objects, then the terminal comparison map for `G` is an isomorphism.\n-/\ndef preserves_terminal.iso : G.obj (⊤_ C) ≅ ⊤_ D :=\n(is_limit_of_has_terminal_of_preserves_limit G).cone_point_unique_up_to_iso (limit.is_limit _)\n\n@[simp]\nlemma preserves_terminal.iso_hom : (preserves_terminal.iso G).hom = terminal_comparison G :=\nrfl\n\ninstance : is_iso (terminal_comparison G) :=\nbegin\n  rw ← preserves_terminal.iso_hom,\n  apply_instance,\nend\n\nend terminal\n\nsection initial\n\n/--\nThe map of an empty cocone is a colimit iff the mapped object is initial.\n-/\ndef is_colimit_map_cocone_empty_cocone_equiv :\n  is_colimit (G.map_cocone (as_empty_cocone.{v₁} X)) ≃ is_initial (G.obj X) :=\nis_colimit_empty_cocone_equiv D _ _ (eq_to_iso rfl)\n\n/-- The property of preserving initial objects expressed in terms of `is_initial`. -/\ndef is_initial.is_initial_obj [preserves_colimit (functor.empty.{0} C) G]\n  (l : is_initial X) : is_initial (G.obj X) :=\nis_colimit_map_cocone_empty_cocone_equiv G X (preserves_colimit.preserves l)\n\n/-- The property of reflecting initial objects expressed in terms of `is_initial`. -/\ndef is_initial.is_initial_of_obj [reflects_colimit (functor.empty.{0} C) G]\n  (l : is_initial (G.obj X)) : is_initial X :=\nreflects_colimit.reflects ((is_colimit_map_cocone_empty_cocone_equiv G X).symm l)\n\n/-- Preserving the initial object implies preserving all colimits of the empty diagram. -/\ndef preserves_colimits_of_shape_pempty_of_preserves_initial\n  [preserves_colimit (functor.empty.{0} C) G] : preserves_colimits_of_shape (discrete pempty) G :=\n{ preserves_colimit := λ K,\n    preserves_colimit_of_iso_diagram G (functor.empty_ext (functor.empty.{0} C) _) }\n\nvariables [has_initial C]\n/--\nIf `G` preserves the initial object and `C` has a initial object, then the image of the initial\nobject is initial.\n-/\ndef is_colimit_of_has_initial_of_preserves_colimit [preserves_colimit (functor.empty.{0} C) G] :\n  is_initial (G.obj (⊥_ C)) :=\ninitial_is_initial.is_initial_obj G (⊥_ C)\n\n/--\nIf `C` has a initial object and `G` preserves initial objects, then `D` has a initial object\nalso.\nNote this property is somewhat unique to colimits of the empty diagram: for general `J`, if `C`\nhas colimits of shape `J` and `G` preserves them, then `D` does not necessarily have colimits of\nshape `J`.\n-/\nlemma has_initial_of_has_initial_of_preserves_colimit [preserves_colimit (functor.empty.{0} C) G] :\n  has_initial D :=\n⟨λ F,\nbegin\n  haveI := has_colimit.mk ⟨_, is_colimit_of_has_initial_of_preserves_colimit G⟩,\n  apply has_colimit_of_iso F.unique_from_empty,\nend⟩\n\nvariable [has_initial D]\n/--\nIf the initial comparison map for `G` is an isomorphism, then `G` preserves initial objects.\n-/\ndef preserves_initial.of_iso_comparison\n  [i : is_iso (initial_comparison G)] : preserves_colimit (functor.empty C) G :=\nbegin\n  apply preserves_colimit_of_preserves_colimit_cocone initial_is_initial,\n  apply (is_colimit_map_cocone_empty_cocone_equiv _ _).symm _,\n  apply is_colimit.of_point_iso (colimit.is_colimit (functor.empty.{0} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `⊥ ⟶ G.obj ⊥`, then `G` preserves initial objects. -/\ndef preserves_initial_of_is_iso\n  (f : ⊥_ D ⟶ G.obj (⊥_ C)) [i : is_iso f] : preserves_colimit (functor.empty C) G :=\nbegin\n  rw subsingleton.elim f (initial_comparison G) at i,\n  exactI preserves_initial.of_iso_comparison G,\nend\n\n/-- If there is any isomorphism `⊥ ≅ G.obj ⊥ `, then `G` preserves initial objects. -/\ndef preserves_initial_of_iso\n  (f : ⊥_ D ≅ G.obj (⊥_ C)) : preserves_colimit (functor.empty C) G :=\npreserves_initial_of_is_iso G f.hom\n\nvariables [preserves_colimit (functor.empty.{0} C) G]\n\n/-- If `G` preserves initial objects, then the initial comparison map for `G` is an isomorphism. -/\ndef preserves_initial.iso : G.obj (⊥_ C) ≅ ⊥_ D :=\n(is_colimit_of_has_initial_of_preserves_colimit G).cocone_point_unique_up_to_iso\n  (colimit.is_colimit _)\n\n@[simp]\nlemma preserves_initial.iso_hom : (preserves_initial.iso G).inv = initial_comparison G :=\nrfl\n\ninstance : is_iso (initial_comparison G) :=\nbegin\n  rw ← preserves_initial.iso_hom,\n  apply_instance,\nend\n\nend initial\n\nend category_theory.limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/preserves/shapes/terminal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303087996143, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4949701391711951}}
{"text": "import data.list.basic\nopen list\nuniverse u\nvariables {α : Type} (x y z : α) (xs ys zs : list α)\n\ndef mk_symm (xs : list α) := xs ++ reverse xs\n\ntheorem reverse_mk_symm (xs : list α) :\n  reverse (mk_symm xs) = mk_symm xs :=\n  by simp [mk_symm]\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch5/ex0715.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8244619436290698, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.494832461219211}}
{"text": "import geometry.algebra.lie_group\n\nnamespace CMP_2020\n\nsection has_mul\n\nvariables {G : Type*} [has_mul G]\n\n/-- `left_mul g` denotes left multiplication by `g` -/\n@[to_additive \"`left_add g` denotes left addition by `g`\"]\ndef left_mul : G → G → G := λ g : G, λ x : G, g * x\n\n/-- `right_mul g` denotes right multiplication by `g` -/\n@[to_additive \"`right_add g` denotes right addition by `g`\"]\ndef right_mul : G → G → G := λ g : G, λ x : G, x * g\n\nend has_mul\n\nsection times_cont_diff\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{E : Type*} [normed_group E] [normed_space 𝕜 E]\n{F : Type*} [normed_group F] [normed_space 𝕜 F]\n{G : Type*} [normed_group G] [normed_space 𝕜 G]\n{s s₁ t u : set E} {f f₁ : E → F} {g : F → G} {x : E} {c : F}\n{b : E × F → G}\n\n/--\nThe first projection at a point in a product is `C^∞`.\n-/\nlemma times_cont_diff_at_fst {p : E × F} {n : with_top ℕ} :\n  times_cont_diff_at 𝕜 n (prod.fst : E × F → E) p :=\ntimes_cont_diff_fst.times_cont_diff_at\n\n/--\nThe first projection within a domain at a point in a product is `C^∞`.\n-/\nlemma times_cont_diff_within_at_fst {s : set (E × F)} {p : E × F} {n : with_top ℕ} :\n  times_cont_diff_within_at 𝕜 n (prod.fst : E × F → E) s p :=\ntimes_cont_diff_fst.times_cont_diff_within_at\n\nlemma times_cont_diff_add {n : with_top ℕ} : times_cont_diff 𝕜 n (λp : F × F, p.1 + p.2) :=\nbegin\n  apply is_bounded_linear_map.times_cont_diff,\n  exact is_bounded_linear_map.add is_bounded_linear_map.fst is_bounded_linear_map.snd,\nend\n\n/-- The sum of two `C^n`functions is `C^n`. -/\nlemma times_cont_diff.add {n : with_top ℕ} {f g : E → F}\n  (hf : times_cont_diff 𝕜 n f) (hg : times_cont_diff 𝕜 n g) : times_cont_diff 𝕜 n (λx, f x + g x) :=\ntimes_cont_diff_add.comp (hf.prod hg)\n\nlemma times_cont_diff_neg {n : with_top ℕ} : times_cont_diff 𝕜 n (λp : F, -p) :=\nbegin\n  apply is_bounded_linear_map.times_cont_diff,\n  exact is_bounded_linear_map.neg is_bounded_linear_map.id\nend\n\n/-- The negative of a `C^n`function is `C^n`. -/\nlemma times_cont_diff.neg {n : with_top ℕ} {f : E → F} (hf : times_cont_diff 𝕜 n f) :\n  times_cont_diff 𝕜 n (λx, -f x) :=\ntimes_cont_diff_neg.comp hf\n\nsection prod_map\nvariables {E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n{F' : Type*} [normed_group F'] [normed_space 𝕜 F']\n{n : with_top ℕ}\n\nopen set\n\n/-- The product map of two `C^n` functions within a set at a point is `C^n`\nwithin the product set at the product point. -/\nlemma times_cont_diff_within_at.prod_map'\n  {s : set E} {t : set E'} {f : E → F} {g : E' → F'} {p : E × E'}\n  (hf : times_cont_diff_within_at 𝕜 n f s p.1) (hg : times_cont_diff_within_at 𝕜 n g t p.2) :\n  times_cont_diff_within_at 𝕜 n (prod.map f g) (set.prod s t) p :=\n(hf.comp p times_cont_diff_within_at_fst (prod_subset_preimage_fst _ _)).prod\n  (hg.comp p times_cont_diff_within_at_snd (prod_subset_preimage_snd _ _))\n\nlemma times_cont_diff_within_at.prod_map\n  {s : set E} {t : set E'} {f : E → F} {g : E' → F'} {x : E} {y : E'}\n  (hf : times_cont_diff_within_at 𝕜 n f s x) (hg : times_cont_diff_within_at 𝕜 n g t y) :\n  times_cont_diff_within_at 𝕜 n (prod.map f g) (set.prod s t) (x, y) :=\ntimes_cont_diff_within_at.prod_map' hf hg\n\n/-- The product map of two `C^n` functions within a set at a point is `C^n`\nwithin the product set at the product point. -/\nlemma times_cont_diff_at.prod_map {f : E → F} {g : E' → F'} {x : E} {y : E'}\n  (hf : times_cont_diff_at 𝕜 n f x) (hg : times_cont_diff_at 𝕜 n g y) :\n  times_cont_diff_at 𝕜 n (prod.map f g) (x, y) :=\nbegin\n  rw times_cont_diff_at at *,\n  convert hf.prod_map hg,\n  simp only [univ_prod_univ]\nend\n\n/-- The product map of two `C^n` functions within a set at a point is `C^n`\nwithin the product set at the product point. -/\nlemma times_cont_diff_at.prod_map' {f : E → F} {g : E' → F'} {p : E × E'}\n  (hf : times_cont_diff_at 𝕜 n f p.1) (hg : times_cont_diff_at 𝕜 n g p.2) :\n  times_cont_diff_at 𝕜 n (prod.map f g) p :=\nby cases p; exact times_cont_diff_at.prod_map hf hg\n\n/-- The product map of two `C^n` functions is `C^n`. -/\nlemma times_cont_diff.prod_map\n  {f : E → F} {g : E' → F'}\n  (hf : times_cont_diff 𝕜 n f) (hg : times_cont_diff 𝕜 n g) :\n  times_cont_diff 𝕜 n (prod.map f g) :=\nbegin\n  rw times_cont_diff_iff_times_cont_diff_at at *,\n  exact λ ⟨x, y⟩, (hf x).prod_map (hg y)\nend\n\nend prod_map\n\nend times_cont_diff\n\nsection times_cont_mdiff\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n-- declare a smooth manifold `M` over the pair `(E, H)`.\n{E : Type*} [normed_group E] [normed_space 𝕜 E]\n{H : Type*} [topological_space H] (I : model_with_corners 𝕜 E H)\n{M : Type*} [topological_space M] [charted_space H M] [Is : smooth_manifold_with_corners I M]\n-- declare a smooth manifold `M'` over the pair `(E', H')`.\n{E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n{H' : Type*} [topological_space H'] (I' : model_with_corners 𝕜 E' H')\n{M' : Type*} [topological_space M'] [charted_space H' M'] [I's : smooth_manifold_with_corners I' M']\n-- declare a smooth manifold `N` over the pair `(F, G)`.\n{F : Type*} [normed_group F] [normed_space 𝕜 F]\n{G : Type*} [topological_space G] {J : model_with_corners 𝕜 F G}\n{N : Type*} [topological_space N] [charted_space G N] [Js : smooth_manifold_with_corners J N]\n-- declare a smooth manifold `N'` over the pair `(F', G')`.\n{F' : Type*} [normed_group F'] [normed_space 𝕜 F']\n{G' : Type*} [topological_space G'] {J' : model_with_corners 𝕜 F' G'}\n{N' : Type*} [topological_space N'] [charted_space G' N'] [J's : smooth_manifold_with_corners J' N']\n-- declare functions, sets, points and smoothness indices\n{f f₁ : M → M'} {s s₁ t : set M} {x : M} {m n : with_top ℕ}\n\n/-! ### Smoothness of standard maps associated to the product of manifolds -/\n\nsection prod_mk\n\nlemma times_cont_mdiff_within_at.prod_mk {f : M → M'} {g : M → N'}\n  (hf : times_cont_mdiff_within_at I I' n f s x) (hg : times_cont_mdiff_within_at I J' n g s x) :\n  times_cont_mdiff_within_at I (I'.prod J') n (λ x, (f x, g x)) s x :=\nbegin\n  rw times_cont_mdiff_within_at_iff at *,\n  refine ⟨hf.1.prod hg.1, (hf.2.mono _).prod (hg.2.mono _)⟩;\n  mfld_set_tac,\nend\n\nlemma times_cont_mdiff_at.prod_mk {f : M → M'} {g : M → N'}\n  (hf : times_cont_mdiff_at I I' n f x) (hg : times_cont_mdiff_at I J' n g x) :\n  times_cont_mdiff_at I (I'.prod J') n (λ x, (f x, g x)) x :=\nhf.prod_mk hg\n\nlemma times_cont_mdiff_on.prod_mk {f : M → M'} {g : M → N'}\n  (hf : times_cont_mdiff_on I I' n f s) (hg : times_cont_mdiff_on I J' n g s) :\n  times_cont_mdiff_on I (I'.prod J') n (λ x, (f x, g x)) s :=\nλ x hx, (hf x hx).prod_mk (hg x hx)\n\nlemma times_cont_mdiff.prod_mk {f : M → M'} {g : M → N'}\n  (hf : times_cont_mdiff I I' n f) (hg : times_cont_mdiff I J' n g) :\n  times_cont_mdiff I (I'.prod J') n (λ x, (f x, g x)) :=\nλ x, (hf x).prod_mk (hg x)\n\nlemma smooth_within_at.prod_mk {f : M → M'} {g : M → N'}\n  (hf : smooth_within_at I I' f s x) (hg : smooth_within_at I J' g s x) :\n  smooth_within_at I (I'.prod J') (λ x, (f x, g x)) s x :=\nhf.prod_mk hg\n\nlemma smooth_at.prod_mk {f : M → M'} {g : M → N'}\n  (hf : smooth_at I I' f x) (hg : smooth_at I J' g x) :\n  smooth_at I (I'.prod J') (λ x, (f x, g x)) x :=\nhf.prod_mk hg\n\nlemma smooth_on.prod_mk {f : M → M'} {g : M → N'}\n  (hf : smooth_on I I' f s) (hg : smooth_on I J' g s) :\n  smooth_on I (I'.prod J') (λ x, (f x, g x)) s :=\nhf.prod_mk hg\n\nlemma smooth.prod_mk {f : M → M'} {g : M → N'}\n  (hf : smooth I I' f) (hg : smooth I J' g) :\n  smooth I (I'.prod J') (λ x, (f x, g x)) :=\nhf.prod_mk hg\n\nend prod_mk\n\nsection projections\n\nlemma times_cont_mdiff_within_at_fst {s : set (M × N)} {p : M × N} :\n  times_cont_mdiff_within_at (I.prod J) I n prod.fst s p :=\nbegin\n  rw times_cont_mdiff_within_at_iff,\n  refine ⟨continuous_within_at_fst, _⟩,\n  refine times_cont_diff_within_at_fst.congr (λ y hy, _) _,\n  { simp only with mfld_simps at hy,\n    simp only [hy] with mfld_simps },\n  { simp only with mfld_simps }\nend\n\nlemma times_cont_mdiff_at_fst {p : M × N} :\n  times_cont_mdiff_at (I.prod J) I n prod.fst p :=\ntimes_cont_mdiff_within_at_fst\n\nlemma times_cont_mdiff_on_fst {s : set (M × N)} :\n  times_cont_mdiff_on (I.prod J) I n prod.fst s :=\nλ x hx, times_cont_mdiff_within_at_fst\n\nlemma times_cont_mdiff_fst :\n  times_cont_mdiff (I.prod J) I n (@prod.fst M N) :=\nλ x, times_cont_mdiff_at_fst\n\nlemma smooth_within_at_fst {s : set (M × N)} {p : M × N} :\n  smooth_within_at (I.prod J) I prod.fst s p :=\ntimes_cont_mdiff_within_at_fst\n\nlemma smooth_at_fst {p : M × N} :\n  smooth_at (I.prod J) I prod.fst p :=\ntimes_cont_mdiff_at_fst\n\nlemma smooth_on_fst {s : set (M × N)} :\n  smooth_on (I.prod J) I prod.fst s :=\ntimes_cont_mdiff_on_fst\n\nlemma smooth_fst :\n  smooth (I.prod J) I (@prod.fst M N) :=\ntimes_cont_mdiff_fst\n\nlemma times_cont_mdiff_within_at_snd {s : set (M × N)} {p : M × N} :\n  times_cont_mdiff_within_at (I.prod J) J n prod.snd s p :=\nbegin\n  rw times_cont_mdiff_within_at_iff,\n  refine ⟨continuous_within_at_snd, _⟩,\n  refine times_cont_diff_within_at_snd.congr (λ y hy, _) _,\n  { simp only with mfld_simps at hy,\n    simp only [hy] with mfld_simps },\n  { simp only with mfld_simps }\nend\n\nlemma times_cont_mdiff_at_snd {p : M × N} :\n  times_cont_mdiff_at (I.prod J) J n prod.snd p :=\ntimes_cont_mdiff_within_at_snd\n\nlemma times_cont_mdiff_on_snd {s : set (M × N)} :\n  times_cont_mdiff_on (I.prod J) J n prod.snd s :=\nλ x hx, times_cont_mdiff_within_at_snd\n\nlemma times_cont_mdiff_snd :\n  times_cont_mdiff (I.prod J) J n (@prod.snd M N) :=\nλ x, times_cont_mdiff_at_snd\n\nlemma smooth_within_at_snd {s : set (M × N)} {p : M × N} :\n  smooth_within_at (I.prod J) J prod.snd s p :=\ntimes_cont_mdiff_within_at_snd\n\nlemma smooth_at_snd {p : M × N} :\n  smooth_at (I.prod J) J prod.snd p :=\ntimes_cont_mdiff_at_snd\n\nlemma smooth_on_snd {s : set (M × N)} :\n  smooth_on (I.prod J) J prod.snd s :=\ntimes_cont_mdiff_on_snd\n\nlemma smooth_snd :\n  smooth (I.prod J) J (@prod.snd M N) :=\ntimes_cont_mdiff_snd\n\ninclude Is I's J's\n\nlemma smooth_iff_proj_smooth {f : M → M' × N'} :\n  (smooth I (I'.prod J') f) ↔ (smooth I I' (prod.fst ∘ f)) ∧ (smooth I J' (prod.snd ∘ f)) :=\nbegin\n  split,\n  { intro h, exact ⟨smooth_fst.comp h, smooth_snd.comp h⟩ },\n  { rintro ⟨h_fst, h_snd⟩, simpa only [prod.mk.eta] using h_fst.prod_mk h_snd, }\nend\n\nend projections\n\nsection prod_map\n\nvariables {g : N → N'} {r : set N} {y : N}\ninclude Is I's Js J's\n\n/-- The product map of two `C^n` functions within a set at a point is `C^n`\nwithin the product set at the product point. -/\nlemma times_cont_mdiff_within_at.prod_map' {p : M × N}\n  (hf : times_cont_mdiff_within_at I I' n f s p.1) (hg : times_cont_mdiff_within_at J J' n g r p.2) :\n  times_cont_mdiff_within_at (I.prod J) (I'.prod J') n (prod.map f g) (s.prod r) p :=\n(hf.comp p times_cont_mdiff_within_at_fst (prod_subset_preimage_fst _ _)).prod_mk $\nhg.comp p times_cont_mdiff_within_at_snd (prod_subset_preimage_snd _ _)\n\nlemma times_cont_mdiff_within_at.prod_map\n  (hf : times_cont_mdiff_within_at I I' n f s x) (hg : times_cont_mdiff_within_at J J' n g r y) :\n  times_cont_mdiff_within_at (I.prod J) (I'.prod J') n (prod.map f g) (s.prod r) (x, y) :=\ntimes_cont_mdiff_within_at.prod_map' hf hg\n\nlemma times_cont_mdiff_at.prod_map\n  (hf : times_cont_mdiff_at I I' n f x) (hg : times_cont_mdiff_at J J' n g y) :\n  times_cont_mdiff_at (I.prod J) (I'.prod J') n (prod.map f g) (x, y) :=\nbegin\n  rw ← times_cont_mdiff_within_at_univ at *,\n  convert hf.prod_map hg,\n  exact univ_prod_univ.symm\nend\n\nlemma times_cont_mdiff_at.prod_map' {p : M × N}\n  (hf : times_cont_mdiff_at I I' n f p.1) (hg : times_cont_mdiff_at J J' n g p.2) :\n  times_cont_mdiff_at (I.prod J) (I'.prod J') n (prod.map f g) p :=\nbegin\n  rcases p,\n  exact hf.prod_map hg\nend\n\nlemma times_cont_mdiff_on.prod_map\n  (hf : times_cont_mdiff_on I I' n f s) (hg : times_cont_mdiff_on J J' n g r) :\n  times_cont_mdiff_on (I.prod J) (I'.prod J') n (prod.map f g) (s.prod r) :=\n(hf.comp times_cont_mdiff_on_fst (prod_subset_preimage_fst _ _)).prod_mk $\nhg.comp (times_cont_mdiff_on_snd) (prod_subset_preimage_snd _ _)\n\nlemma times_cont_mdiff.prod_map\n  (hf : times_cont_mdiff I I' n f) (hg : times_cont_mdiff J J' n g) :\n  times_cont_mdiff (I.prod J) (I'.prod J') n (prod.map f g) :=\nbegin\n  assume p,\n  exact (hf p.1).prod_map' (hg p.2)\nend\n\nlemma smooth_within_at.prod_map\n  (hf : smooth_within_at I I' f s x) (hg : smooth_within_at J J' g r y) :\n  smooth_within_at (I.prod J) (I'.prod J') (prod.map f g) (s.prod r) (x, y) :=\nhf.prod_map hg\n\nlemma smooth_at.prod_map\n  (hf : smooth_at I I' f x) (hg : smooth_at J J' g y) :\n  smooth_at (I.prod J) (I'.prod J') (prod.map f g) (x, y) :=\nhf.prod_map hg\n\nlemma smooth_on.prod_map\n  (hf : smooth_on I I' f s) (hg : smooth_on J J' g r) :\n  smooth_on (I.prod J) (I'.prod J') (prod.map f g) (s.prod r) :=\nhf.prod_map hg\n\nlemma smooth.prod_map\n  (hf : smooth I I' f) (hg : smooth J J' g) :\n  smooth (I.prod J) (I'.prod J') (prod.map f g) :=\nhf.prod_map hg\n\nend prod_map\n\nend times_cont_mdiff\n\nsection lie_group\n\n/-\nCopyright © 2020 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Nicolò Cavalleri.\n-/\n\n/-!\n# Lie groups\nA Lie group is a group that is also a smooth manifold, in which the group operations of\nmultiplication and inversion are smooth maps. Smoothness of the group multiplication means that\nThis conversation was marked as resolved by Nicknamen\nmultiplication is a smooth mapping of the product manifold `G` × `G` into `G`.\nNote that, since a manifold here is not second-countable and Hausdorff a Lie group here is not\nguaranteed to be second-countable (even though it can be proved it is Hausdorff). Note also that Lie\ngroups here are not necessarily finite dimensional.\n## Main definitions and statements\n* `lie_add_group I G` : a Lie additive group where `G` is a manifold on the model with corners `I`.\n* `lie_group I G`     : a Lie multiplicative group where `G` is a manifold on the model with\n                        corners `I`.\n* `lie_add_group_morphism I I' G G'`  : morphism of addittive Lie groups\n* `lie_group_morphism I I' G G'`      : morphism of Lie groups\n* `lie_add_group_core I G`            : allows to define a Lie additive group without first proving\n                                        it is a topological additive group.\n* `lie_group_core I G`                : allows to define a Lie group without first proving\n                                        it is a topological group.\n* `reals_lie_group`                   : real numbers are a Lie group\n## Implementation notes\nA priori, a Lie group here is a manifold with corners.\nThe definition of Lie group cannot require `I : model_with_corners 𝕜 E E` with the same space as the\nmodel space and as the model vector space, as one might hope, beause in the product situation,\nthe model space is `model_prod E E'` and the model vector space is `E × E'`, which are not the same,\nso the definition does not apply. Hence the definition should be more general, allowing\n`I : model_with_corners 𝕜 E H`.\n-/\n\nnoncomputable theory\n\nsection lie_group\n\nset_option default_priority 100\n\n/-- A Lie (additive) group is a group and a smooth manifold at the same time in which\nthe addition and negation operations are smooth. -/\nclass lie_add_group {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space 𝕜 E] (I : model_with_corners 𝕜 E H)\n  (G : Type*) [add_group G] [topological_space G] [topological_add_group G] [charted_space H G]\n  extends smooth_manifold_with_corners I G : Prop :=\n(smooth_add : smooth (I.prod I) I (λ p : G×G, p.1 + p.2))\n(smooth_neg : smooth I I (λ a:G, -a))\n\n/-- A Lie group is a group and a smooth manifold at the same time in which\nthe multiplication and inverse operations are smooth. -/\n@[to_additive]\nclass lie_group {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space 𝕜 E] (I : model_with_corners 𝕜 E H)\n  (G : Type*) [group G] [topological_space G] [topological_group G] [charted_space H G]\n  extends smooth_manifold_with_corners I G : Prop :=\n(smooth_mul : smooth (I.prod I) I (λ p : G×G, p.1 * p.2))\n(smooth_inv : smooth I I (λ a:G, a⁻¹))\n\nsection lie_group\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{H : Type*} [topological_space H]\n{E : Type*} [normed_group E] [normed_space 𝕜 E] {I : model_with_corners 𝕜 E H}\n{F : Type*} [normed_group F] [normed_space 𝕜 F] {J : model_with_corners 𝕜 F F}\n{G : Type*} [topological_space G] [charted_space H G] [group G]\n[topological_group G] [lie_group I G]\n{E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n{H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}\n{M : Type*} [topological_space M] [charted_space H' M] [smooth_manifold_with_corners I' M]\n{E'' : Type*} [normed_group E''] [normed_space 𝕜 E'']\n{H'' : Type*} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''}\n{M' : Type*} [topological_space M'] [charted_space H'' M'] [smooth_manifold_with_corners I'' M']\n\n@[to_additive]\nlemma smooth_mul : smooth (I.prod I) I (λ p : G×G, p.1 * p.2) :=\nlie_group.smooth_mul\n\n@[to_additive]\nlemma smooth.mul {f : M → G} {g : M → G} (hf : smooth I' I f) (hg : smooth I' I g) :\n  smooth I' I (f * g) :=\nsmooth_mul.comp (hf.prod_mk hg)\n\nlocalized \"notation `L_add` := left_add\" in lie_group\n\nlocalized \"notation `R_add` := right_add\" in lie_group\n\nlocalized \"notation `L` := left_mul\" in lie_group\n\nlocalized \"notation `R` := right_mul\" in lie_group\n\n@[to_additive]\nlemma smooth_left_mul {a : G} : smooth I I (left_mul a) :=\nsmooth_mul.comp (smooth_const.prod_mk smooth_id)\n\n@[to_additive]\nlemma smooth_right_mul {a : G} : smooth I I (right_mul a) :=\nsmooth_mul.comp (smooth_id.prod_mk smooth_const)\n\n@[to_additive]\nlemma smooth_on.mul {f : M → G} {g : M → G} {s : set M}\n  (hf : smooth_on I' I f s) (hg : smooth_on I' I g s) :\n  smooth_on I' I (f * g) s :=\n(smooth_mul.comp_smooth_on (hf.prod_mk hg) : _)\n\nlemma smooth_pow : ∀ n : ℕ, smooth I I (λ a : G, a ^ n)\n| 0 := by { simp only [pow_zero], exact smooth_const }\n| (k+1) := show smooth I I (λ (a : G), a * a ^ k), from smooth_id.mul (smooth_pow _)\n\n@[to_additive]\nlemma smooth_inv : smooth I I (λ x : G, x⁻¹) :=\nlie_group.smooth_inv\n\n@[to_additive]\nlemma smooth.inv {f : M → G}\n  (hf : smooth I' I f) : smooth I' I (λx, (f x)⁻¹) :=\nsmooth_inv.comp hf\n\n@[to_additive]\nlemma smooth_on.inv {f : M → G} {s : set M}\n  (hf : smooth_on I' I f s) : smooth_on I' I (λx, (f x)⁻¹) s :=\nsmooth_inv.comp_smooth_on hf\n\nend lie_group\n\nsection prod_lie_group\n\n/- Instance of product group -/\n@[to_additive]\ninstance {𝕜 : Type*} [nondiscrete_normed_field 𝕜] {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space 𝕜 E]  {I : model_with_corners 𝕜 E H}\n  {G : Type*} [topological_space G] [charted_space H G] [group G] [topological_group G]\n  [h : lie_group I G] {E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n  {H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}\n  {G' : Type*} [topological_space G'] [charted_space H' G']\n  [group G'] [topological_group G'] [h' : lie_group I' G'] : lie_group (I.prod I') (G×G') :=\n{ smooth_mul := ((smooth_fst.comp smooth_fst).smooth.mul (smooth_fst.comp smooth_snd)).prod_mk\n    ((smooth_snd.comp smooth_fst).smooth.mul (smooth_snd.comp smooth_snd)),\n  smooth_inv := smooth_fst.inv.prod_mk smooth_snd.inv, }\n\nend prod_lie_group\n\nsection lie_add_group_morphism\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{E : Type*} [normed_group E] [normed_space 𝕜 E]\n{E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n\n/-- Morphism of additive Lie groups. -/\nstructure lie_add_group_morphism (I : model_with_corners 𝕜 E E) (I' : model_with_corners 𝕜 E' E')\n  (G : Type*) [topological_space G] [charted_space E G] [smooth_manifold_with_corners I G]\n  [add_group G] [topological_add_group G] [lie_add_group I G]\n  (G' : Type*) [topological_space G'] [charted_space E' G'] [smooth_manifold_with_corners I' G']\n  [add_group G'] [topological_add_group G'] [lie_add_group I' G'] extends add_monoid_hom G G' :=\n(smooth_to_fun : smooth I I' to_fun)\n\n/-- Morphism of Lie groups. -/\n@[to_additive]\nstructure lie_group_morphism (I : model_with_corners 𝕜 E E) (I' : model_with_corners 𝕜 E' E')\n  (G : Type*) [topological_space G] [charted_space E G] [smooth_manifold_with_corners I G] [group G]\n  [topological_group G] [lie_group I G]\n  (G' : Type*) [topological_space G'] [charted_space E' G'] [smooth_manifold_with_corners I' G']\n  [group G'] [topological_group G'] [lie_group I' G'] extends monoid_hom G G' :=\n(smooth_to_fun : smooth I I' to_fun)\n\nvariables {I : model_with_corners 𝕜 E E} {I' : model_with_corners 𝕜 E' E'}\n{G : Type*} [topological_space G] [charted_space E G] [smooth_manifold_with_corners I G]\n[group G] [topological_group G] [lie_group I G]\n{G' : Type*} [topological_space G'] [charted_space E' G'] [smooth_manifold_with_corners I' G']\n[group G'] [topological_group G'] [lie_group I' G']\n\n@[to_additive]\ninstance : has_one (lie_group_morphism I I' G G') := ⟨⟨1, smooth_const⟩⟩\nThis conversation was marked as resolved by sgouezel\n\n@[to_additive]\ninstance : inhabited (lie_group_morphism I I' G G') := ⟨1⟩\n\n@[to_additive]\ninstance : has_coe_to_fun (lie_group_morphism I I' G G') := ⟨_, λ a, a.to_fun⟩\n\nend lie_add_group_morphism\n\nend lie_group\n\nsection lie_group_core\n\n/-- Sometimes one might want to define a Lie additive group `G` without having proved previously\nthat `G` is a topological additive group. In such case it is possible to use `lie_add_group_core`\nthat does not require such instance, and then get a Lie group by invoking `to_lie_add_group`. -/\nstructure lie_add_group_core {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n  {E : Type*} [normed_group E]\n  [normed_space 𝕜 E] (I : model_with_corners 𝕜 E E)\n  (G : Type*) [add_group G] [topological_space G]\n  [charted_space E G] [smooth_manifold_with_corners I G] : Prop :=\n(smooth_add : smooth (I.prod I) I (λ p : G×G, p.1 + p.2))\n(smooth_neg : smooth I I (λ a:G, -a))\n\n/-- Sometimes one might want to define a Lie group `G` without having proved previously that `G` is\na topological group. In such case it is possible to use `lie_group_core` that does not require such\ninstance, and then get a Lie group by invoking `to_lie_group` defined below. -/\n@[to_additive]\nstructure lie_group_core {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n  {E : Type*} [normed_group E]\n  [normed_space 𝕜 E] (I : model_with_corners 𝕜 E E)\n  (G : Type*) [group G] [topological_space G]\n  [charted_space E G] [smooth_manifold_with_corners I G] : Prop :=\n(smooth_mul : smooth (I.prod I) I (λ p : G×G, p.1 * p.2))\n(smooth_inv : smooth I I (λ a:G, a⁻¹))\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{E : Type*} [normed_group E] [normed_space 𝕜 E] {I : model_with_corners 𝕜 E E}\n{F : Type*} [normed_group F] [normed_space 𝕜 F] {J : model_with_corners 𝕜 F F}\n{G : Type*} [topological_space G] [charted_space E G] [smooth_manifold_with_corners I G] [group G]\n\nnamespace lie_group_core\n\nvariables (c : lie_group_core I G)\n\n@[to_additive]\nprotected lemma to_topological_group : topological_group G :=\n{ continuous_mul := c.smooth_mul.continuous,\n  continuous_inv := c.smooth_inv.continuous, }\n\n@[to_additive]\nprotected lemma to_lie_group : @lie_group 𝕜 _ _ _ E _ _ I G _ _ c.to_topological_group _ :=\n{ smooth_mul := c.smooth_mul,\n  smooth_inv := c.smooth_inv, }\n\nend lie_group_core\n\nend lie_group_core\n\n/-! ### Real numbers are a Lie group -/\n\nsection real_numbers_lie_group\n\ninstance normed_group_lie_group {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{E : Type*} [normed_group E] [normed_space 𝕜 E] :\nlie_add_group (model_with_corners_self 𝕜 E) E :=\n{ smooth_add :=\n  begin\n    rw smooth_iff,\n    refine ⟨continuous_add, λ x y, _⟩,\n    simp only [prod.mk.eta] with mfld_simps,\n    rw times_cont_diff_on_univ,\n    exact times_cont_diff_add,\n  end,\n  smooth_neg :=\n  begin\n    rw smooth_iff,\n    refine ⟨continuous_neg, λ x y, _⟩,\n    simp only [prod.mk.eta] with mfld_simps,\n    rw times_cont_diff_on_univ,\n    exact times_cont_diff_neg,\n  end }\n\ninstance reals_lie_group : lie_add_group (model_with_corners_self ℝ ℝ) ℝ := by apply_instance\n\nend real_numbers_lie_group\n\nend lie_group\n\n\n\nend CMP_2020\n", "meta": {"author": "AnthonyBordg", "repo": "Geometry_in_Lean", "sha": "b0f11164e9f695097b5c0e404a0dc429cdc24bb8", "save_path": "github-repos/lean/AnthonyBordg-Geometry_in_Lean", "path": "github-repos/lean/AnthonyBordg-Geometry_in_Lean/Geometry_in_Lean-b0f11164e9f695097b5c0e404a0dc429cdc24bb8/Lie_theory/src/Manifold/lie_group/lie_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4947774154314378}}
{"text": "/-\nCopyright (c) 2019 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module control.monad.basic\n! leanprover-community/mathlib commit 70d50ecfd4900dd6d328da39ab7ebd516abe4025\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Logic.Equiv.Defs\nimport Mathlib.Control.SimpSet\n\n/-!\n# Monad\n\n## Attributes\n\n * ext\n * functor_norm\n * monad_norm\n\n## Implementation Details\n\nSet of rewrite rules and automation for monads in general and\n`ReaderT`, `StateT`, `ExceptT` and `OptionT` in particular.\n\nThe rewrite rules for monads are carefully chosen so that `simp with\nfunctor_norm` will not introduce monadic vocabulary in a context where\napplicatives would do just fine but will handle monadic notation\nalready present in an expression.\n\nIn a context where monadic reasoning is desired `simp with monad_norm`\nwill translate functor and applicative notation into monad notation\nand use regular `functor_norm` rules as well.\n\n## Tags\n\nfunctor, applicative, monad, simp\n\n-/\n\nattribute [ext] ReaderT.ext StateT.ext ExceptT.ext Option.ext\n\nattribute [functor_norm] bind_assoc pure_bind bind_pure\n\nattribute [monad_norm] seq_eq_bind_map\n\n\n@[monad_norm]\ntheorem map_eq_bind_pure_comp (m : Type u → Type v) [Monad m] [LawfulMonad m]\n    (f : α → β) (x : m α) : f <$> x = x >>= pure ∘ f :=\n  (bind_pure_comp f x).symm\n#align map_eq_bind_pure_comp map_eq_bind_pure_comp\n\n/-- run a `StateT` program and discard the final state -/\ndef StateT.eval {m : Type u → Type v} [Functor m] (cmd : StateT σ m α) (s : σ) : m α :=\n  Prod.fst <$> cmd.run s\n#align state_t.eval StateT.eval\n\n/-- reduce the equivalence between two state monads to the equivalence between\ntheir respective function spaces -/\ndef StateT.equiv {m₁ : Type u₀ → Type v₀} {m₂ : Type u₁ → Type v₁}\n    (F : (σ₁ → m₁ (α₁ × σ₁)) ≃ (σ₂ → m₂ (α₂ × σ₂))) : StateT σ₁ m₁ α₁ ≃ StateT σ₂ m₂ α₂ :=\n  F\n#align state_t.equiv StateT.equiv\n\n/-- reduce the equivalence between two reader monads to the equivalence between\ntheir respective function spaces -/\ndef ReaderT.equiv {m₁ : Type u₀ → Type v₀} {m₂ : Type u₁ → Type v₁}\n    (F : (ρ₁ → m₁ α₁) ≃ (ρ₂ → m₂ α₂)) : ReaderT ρ₁ m₁ α₁ ≃ ReaderT ρ₂ m₂ α₂ :=\n  F\n#align reader_t.equiv ReaderT.equiv\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Control/Monad/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4947774154314378}}
{"text": "/-\nCopyright © 2019, Oracle and/or its affiliates. All rights reserved.\n-/\n\nimport data.set\nimport analysis.complex.exponential\nimport .attributed.dvector\nimport lib.basic\nimport topology.constructions\n\nlocal attribute [instance] classical.prop_decidable\n\nopen nnreal real ennreal set lattice\nopen topological_space\nopen measure_theory\n\nlemma lc_nnreal:\n  ∀ a: nnreal, ∀ b: nnreal, a + b = 1 → a = (1:nnreal) - b :=\nassume a b h, h ▸ (nnreal.add_sub_cancel).symm\n\nlemma delta_helper:\n  ∀ δ: nnreal, δ > (0:nnreal) → (1:nnreal) - δ ≤ (1: nnreal) :=\nassume h, by simp\n\nlemma coe_pmeas:\n  ∀ a: ennreal, ∀ b: ennreal, a ≤ (1:ennreal) → b ≤ (1: ennreal) → a ≤ b → ennreal.to_nnreal a ≤ ennreal.to_nnreal b :=\nbegin\n  intros a b h₁ h₂ h₃,\n  rw [← coe_le_coe, coe_to_nnreal,coe_to_nnreal],\n  assumption,\n  rw ←ennreal.lt_top_iff_ne_top,\n  exact lt_of_le_of_lt h₂ (ennreal.lt_top_iff_ne_top.2 one_ne_top),\n  rw ←ennreal.lt_top_iff_ne_top,\n  exact lt_of_le_of_lt h₁ (ennreal.lt_top_iff_ne_top.2 one_ne_top),\nend\n\nlemma pow_preserves_order:\n  ∀ n: ℕ, ∀ a: nnreal, ∀ b: nnreal, a ≤ b → a^n ≤ b^n :=\nbegin\n  intros n a b h,\n  induction n with k ih ; try {simp},\n  simp [pow_succ], exact mul_le_mul h ih (zero_le _) (zero_le _),\nend\n\nlemma not_eq_prop:\n  ∀ A: Prop, ∀ B: Prop, (¬ (A ↔ B)) ↔ ((¬ (A → B)) ∨ (¬ (B → A))) :=\nbegin\n  intros,\n  split; intros; try {finish},\nend\n\nlemma nnreal_sub_trans:\n  ∀ a: nnreal, ∀ b: nnreal,\n  a ≥ b → 1 - a ≤ 1 - b :=\nbegin\nintros,\nrw nnreal.sub_le_iff_le_add,\nsimp,\nby_cases (b ≤ 1),\n{\n  have h: 1 + (a - b) = a + (1 - b),\n  by calc 1 + (a - b) = 1 + a - b   : by rw [←nnreal.eq_iff,nnreal.coe_add, (nnreal.coe_sub _ _ a_1), ←add_sub_assoc, nnreal.coe_sub _, nnreal.coe_add]; exact le_add_of_le_of_nonneg h (zero_le _)\n        ...     = a + 1 - b   : by rw add_comm\n        ...     = a + (1 - b) : by rw [←nnreal.eq_iff,nnreal.coe_add, (nnreal.coe_sub _ _ h), ←add_sub_assoc,nnreal.coe_sub _, nnreal.coe_add];exact le_add_of_le_of_nonneg a_1 (zero_le _),\n  rw h.symm,\n  cases b, cases a, dsimp at *, simp at *,\n},\n{\n  simp at h,\n  rw nnreal.sub_eq_zero, swap,\n  exact le_of_lt h,\n  simp,\n  transitivity b,\n  exact le_of_lt h,\n  assumption,\n}\nend\n\nlemma prod_rw {α: Type} {β: Type}:\n  ∀ P₁: α → Prop,\n  ∀ P₂: β → Prop,\n  { v : α × β | P₁ v.fst ∧ P₂ v.snd} = set.prod {x: α | P₁ x} {x: β | P₂ x} :=\nbegin\n  intros,\n  unfold set.prod,\n  rw ext_iff, intro,\n  repeat {rw mem_set_of_eq},\nend\n\nlemma dfin_1_projn {α: Type}:\n  ∀ P: α → Prop,\n  ∀ x: vec α 0,\n  (∀ (i: dfin 1), P (kth_projn x i)) ↔ P x :=\nbegin\n  intros,\n  split; intros ; try {simpa},\n  simp at *, apply a,\n  exact dfin.fz,\nend\n\nlemma dfin_1_projn' {α: Type}:\n  ∀ P: α → Prop,\n  { x: vec α 0 | ∀ (i: dfin 1), P (kth_projn x i)} = {x: α | P x} :=\nbegin\n  intros,\n  rw ext_iff, intro,\n  repeat {rw mem_set_of_eq},\n  rw dfin_1_projn,\n  trivial,\nend\n\nlemma is_measurable_simple_vec {α: Type} [measurable_space α]:\n  ∀ P: α → Prop,\n  is_measurable {x: α | P x} →\n  ∀ n,\n  is_measurable {v: vec α n | ∀ (i: dfin (nat.succ n)), P(kth_projn v i)} :=\nbegin\n  intros,\n  induction n; intros; try{rwa dfin_1_projn'},\n  dunfold vec,\n  conv { congr, congr, funext, rw dfin_succ_prop_iff_fst_and_rst, skip,},\n  have PROD := prod_rw (λ x, P x) (λ x, ∀ (i: dfin (nat.succ n_n)), P(kth_projn x i)),\n  simp at PROD,\n  rw PROD, clear PROD,\n  apply is_measurable_set_prod; try {assumption},\nend\n\n/- Move these results back to where vec was defined (../to_mathlib.lean)-/\nnoncomputable\ninstance vec_topo: ∀ n: ℕ, topological_space (vec nnreal n) :=\nbegin\n  intro,\n  induction n ; try{ dunfold vec, apply_instance},\n  unfold vec,\n  have PROD := @prod.topological_space nnreal (vec nnreal n_n) _ n_ih,\n  assumption,\nend\n\n\ninstance vec_second_countable : ∀ n:ℕ, second_countable_topology (vec nnreal n) :=\nbegin\n  intros n,\n  induction n with k ih,\n  dsimp [vec], apply_instance,\n  dsimp [vec],\n  haveI := second_countable_topology nnreal,\n  apply_instance,\nend\n\nlemma vec.measurable_space_eq_borel (n : ℕ) : vec.measurable_space n = measure_theory.borel (vec nnreal n) :=\nbegin\n  induction n with k ih,\n  refl,\n  dsimp [vec], rw ←measure_theory.borel_prod,\n  rw prod.measurable_space, rw ←ih, refl,\nend\n\nlemma is_measurable_of_continuous_vec :\n  ∀ n: ℕ,\n  ∀ f: nnreal × vec nnreal n → nnreal,\n  ∀ g: nnreal × vec nnreal n → nnreal,\n  continuous f →\n  continuous g →\n  is_measurable {p: nnreal × (vec nnreal n) | f p < g p} :=\nbegin\n  intros n f g hf hg,\n  convert measure_theory.is_measurable_of_is_open _,\n  haveI := vec_second_countable n,\n  swap,\n  change topological_space (vec nnreal (nat.succ n)), apply_instance,\n  swap,\n  exact is_open_lt hf hg, rw prod.measurable_space,\n  rw ←measure_theory.borel_prod, rw vec.measurable_space_eq_borel n, refl,\nend\n\nlemma to_nnreal_sub {r₁ r₂ : ennreal} (h₁ : r₁ < ⊤) (h₂ : r₂ < ⊤) :\n  (r₁ - r₂).to_nnreal = r₁.to_nnreal - r₂.to_nnreal :=\nby rw [← ennreal.coe_eq_coe, ennreal.coe_sub, ennreal.coe_to_nnreal (ne_top_of_lt h₂), ennreal.coe_to_nnreal (ne_top_of_lt h₁),\n  ennreal.coe_to_nnreal ((lt_top_iff_ne_top.1 (lt_of_le_of_lt (sub_le_self _ _) h₁)))]\n\nsection to_borel_space\n\n/- Move these back to borel_space.lean -/\n\nvariables {α : Type*} [linear_order α] [topological_space α] [ordered_topology α] {a b c : α}\n\nlemma is_measurable_Ioc : is_measurable (Ioc a b) :=  (is_measurable_of_is_open (is_open_lt continuous_const continuous_id)).inter (is_measurable_of_is_closed (is_closed_le continuous_id continuous_const))\n\nlemma is_measurable_Icc : is_measurable (Icc a b) := is_measurable_of_is_closed $ is_closed_Icc\n\nlemma is_measurable_Ioi : is_measurable (Ioi a) :=\nis_measurable_of_is_open $ is_open_lt continuous_const continuous_id\n\n\nend to_borel_space\n\nlemma Ioi_complement:\n  ∀ x: nnreal, Ioi x = - (Iio x ∪ {x}) :=\nbegin\n  intros,\n  rw ext_iff, intro,\n  unfold Ioi, unfold Iio,\n  simp only [mem_set_of_eq, mem_insert_iff, union_singleton, mem_compl_eq],\n  repeat {rw mem_set_of_eq},\n  split; intro,\n  { \n    push_neg, refine and.intro _ (le_of_lt a),\n    by_contradiction, simp at *,\n    rw a_1 at a,\n    have FOO: ¬ (x < x), simp,\n    contradiction,\n  },\n  {\n    push_neg at a,\n    cases a,\n    by_contradiction,\n    have FOO: ¬ (x ≤ x_1),by simp at * ; exact lt_of_le_of_ne a a_left,\n    contradiction,\n  },\nend\n\nlemma Icc_diff_Ioc:\n  ∀ a: nnreal, ∀ b: nnreal, ∀ c: nnreal,\n  a ≤ b → b ≤ c → (Icc a c \\ Icc a b) = Ioc b c :=\nbegin\n  unfold Icc, unfold Ioc,\n  introv H1 H2,\n  rw ext_iff, intro,\n  rw mem_diff,\n  repeat {rw mem_set_of_eq at *,},\n  split; intros,\n  {cases a_1, cases a_1_left, finish,},\n  {cases a_1, refine and.intro _ (by exact (not_and.2 (λ a, not_le.2 a_1_left))),\n  {\n  split ; try {assumption},\n  transitivity b,\n  assumption,\n  exact le_of_lt a_1_left,\n  },\n  },\nend\n\nlemma mono_simple {μ: probability_measure nnreal}:\n  ∀ a: nnreal, ∀ b: nnreal, a ≤ b → μ (Icc 0 a) ≤ μ (Icc 0 b) :=\nbegin\n  intros,\n  apply probability_measure.prob_mono,\n  unfold Icc,\n  rw subset_def, intros,\n  rw mem_set_of_eq at *,\n  cases a_2,\n  split,\n  assumption,\n  transitivity a; assumption,\nend\n\nlemma log_le_log_nnreal:\n  ∀ x: nnreal, ∀ y: nnreal, x > 0 → y > 0 → (x ≤ y ↔ log x ≤ log y) :=\nbegin\n  intros,\n  rw log_le_log,\n  refl, assumption, assumption,\nend\n\nlemma log_pow_nnreal:\n  ∀ x: nnreal, x > 0 → ∀ n: ℕ, log(x^n) = n * log(x) :=\nbegin\n  intros,\n  apply exp_injective,\n  rw exp_nat_mul,\n  rw exp_log,\n  rw exp_log,\n  assumption,\n  exact pow_pos a n,\nend\n\nlemma pow_coe:\n  ∀ a: nnreal, ∀ n: ℕ, a.val ^ n = (a ^ n).val :=\nbegin\n  intros,\n  induction n,\n  simp, refl,\n  have pow_nnreal: ∀ a: nnreal, ∀ n: ℕ, a ^ (nat.succ n) = a * a ^ n, intros, exact rfl,\n  rw pow_nnreal,\n  have mul_coe: ∀ a: nnreal, ∀ b: nnreal, (a * b).val = a.val * b.val, intros, refl,\n  rw mul_coe,\n  rw ← n_ih,\n  refl,\nend\n\nlemma sub_nnreal:\n  ∀ a: nnreal, ∀ b: nnreal, a ≥ b → (a - b).val = a.val - b.val :=\nbegin\n  intros a b h,\n  change (↑(a-b) = ↑a - ↑b),\n  rw nnreal.coe_sub _ _ h,\nend\n\nlemma ite_equals_union_interval:\n  ∀ θ > 0, ∀ y: nnreal, {x: nnreal | ite (to_bool(x ≤ y)) x 0 < θ} = Ico 0 θ ∪ Ioi y :=\nbegin\n  intros,\n  unfold Ico, unfold Ioi,\n  rw ext_iff, intro,\n  rw mem_union,\n  repeat {rw mem_set_of_eq},\n  split; intro,\n  {\n    split_ifs at a,\n    {left, split, tidy,},\n    {right, tidy,},\n  },\n  {\n    cases a,\n    {cases a, split_ifs; assumption,},\n    {\n    split_ifs ; try {assumption},\n    {by_contradiction,\n    have GEQ: ¬ (y < x), by simp at h ⊢ ; assumption,\n    contradiction,},\n    },\n  },\nend", "meta": {"author": "jtristan", "repo": "stump-learnable", "sha": "aa3c089f41602efa08d31ef6b41e549456186d57", "save_path": "github-repos/lean/jtristan-stump-learnable", "path": "github-repos/lean/jtristan-stump-learnable/stump-learnable-aa3c089f41602efa08d31ef6b41e549456186d57/src/lib/util.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.49477741137450804}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad\n\n! This file was ported from Lean 3 source module data.qpf.univariate.basic\n! leanprover-community/mathlib commit 14b69e9f3c16630440a2cbd46f1ddad0d561dee7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Pfunctor.Univariate.M\n\n/-!\n\n# Quotients of Polynomial Functors\n\nWe assume the following:\n\n`P`   : a polynomial functor\n`W`   : its W-type\n`M`   : its M-type\n`F`   : a functor\n\nWe define:\n\n`q`   : `qpf` data, representing `F` as a quotient of `P`\n\nThe main goal is to construct:\n\n`fix`   : the initial algebra with structure map `F fix → fix`.\n`cofix` : the final coalgebra with structure map `cofix → F cofix`\n\nWe also show that the composition of qpfs is a qpf, and that the quotient of a qpf\nis a qpf.\n\nThe present theory focuses on the univariate case for qpfs\n\n## References\n\n* [Jeremy Avigad, Mario M. Carneiro and Simon Hudon, *Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019]\n\n-/\n\n\nuniverse u\n\n/-- Quotients of polynomial functors.\n\nRoughly speaking, saying that `F` is a quotient of a polynomial functor means that for each `α`,\nelements of `F α` are represented by pairs `⟨a, f⟩`, where `a` is the shape of the object and\n`f` indexes the relevant elements of `α`, in a suitably natural manner.\n-/\nclass Qpf (F : Type u → Type u) [Functor F] where\n  p : PFunctor.{u}\n  abs : ∀ {α}, P.Obj α → F α\n  repr : ∀ {α}, F α → P.Obj α\n  abs_repr : ∀ {α} (x : F α), abs (repr x) = x\n  abs_map : ∀ {α β} (f : α → β) (p : P.Obj α), abs (f <$> p) = f <$> abs p\n#align qpf Qpf\n\nnamespace Qpf\n\nvariable {F : Type u → Type u} [Functor F] [q : Qpf F]\n\ninclude q\n\nopen Functor (Liftp Liftr)\n\n/-\nShow that every qpf is a lawful functor.\n\nNote: every functor has a field, `map_const`, and is_lawful_functor has the defining\ncharacterization. We can only propagate the assumption.\n-/\ntheorem id_map {α : Type _} (x : F α) : id <$> x = x :=\n  by\n  rw [← abs_repr x]\n  cases' repr x with a f\n  rw [← abs_map]\n  rfl\n#align qpf.id_map Qpf.id_map\n\ntheorem comp_map {α β γ : Type _} (f : α → β) (g : β → γ) (x : F α) :\n    (g ∘ f) <$> x = g <$> f <$> x := by\n  rw [← abs_repr x]\n  cases' repr x with a f\n  rw [← abs_map, ← abs_map, ← abs_map]\n  rfl\n#align qpf.comp_map Qpf.comp_map\n\ntheorem lawfulFunctor\n    (h : ∀ α β : Type u, @Functor.mapConst F _ α _ = Functor.map ∘ Function.const β) :\n    LawfulFunctor F :=\n  { mapConst_eq := h\n    id_map := @id_map F _ _\n    comp_map := @comp_map F _ _ }\n#align qpf.is_lawful_functor Qpf.lawfulFunctor\n\n/-\nLifting predicates and relations\n-/\nsection\n\nopen Functor\n\ntheorem liftp_iff {α : Type u} (p : α → Prop) (x : F α) :\n    Liftp p x ↔ ∃ a f, x = abs ⟨a, f⟩ ∧ ∀ i, p (f i) :=\n  by\n  constructor\n  · rintro ⟨y, hy⟩\n    cases' h : repr y with a f\n    use a, fun i => (f i).val\n    constructor\n    · rw [← hy, ← abs_repr y, h, ← abs_map]\n      rfl\n    intro i\n    apply (f i).property\n  rintro ⟨a, f, h₀, h₁⟩; dsimp at *\n  use abs ⟨a, fun i => ⟨f i, h₁ i⟩⟩\n  rw [← abs_map, h₀]; rfl\n#align qpf.liftp_iff Qpf.liftp_iff\n\ntheorem liftp_iff' {α : Type u} (p : α → Prop) (x : F α) :\n    Liftp p x ↔ ∃ u : q.p.Obj α, abs u = x ∧ ∀ i, p (u.snd i) :=\n  by\n  constructor\n  · rintro ⟨y, hy⟩\n    cases' h : repr y with a f\n    use ⟨a, fun i => (f i).val⟩\n    dsimp\n    constructor\n    · rw [← hy, ← abs_repr y, h, ← abs_map]\n      rfl\n    intro i\n    apply (f i).property\n  rintro ⟨⟨a, f⟩, h₀, h₁⟩; dsimp at *\n  use abs ⟨a, fun i => ⟨f i, h₁ i⟩⟩\n  rw [← abs_map, ← h₀]; rfl\n#align qpf.liftp_iff' Qpf.liftp_iff'\n\ntheorem liftr_iff {α : Type u} (r : α → α → Prop) (x y : F α) :\n    Liftr r x y ↔ ∃ a f₀ f₁, x = abs ⟨a, f₀⟩ ∧ y = abs ⟨a, f₁⟩ ∧ ∀ i, r (f₀ i) (f₁ i) :=\n  by\n  constructor\n  · rintro ⟨u, xeq, yeq⟩\n    cases' h : repr u with a f\n    use a, fun i => (f i).val.fst, fun i => (f i).val.snd\n    constructor\n    · rw [← xeq, ← abs_repr u, h, ← abs_map]\n      rfl\n    constructor\n    · rw [← yeq, ← abs_repr u, h, ← abs_map]\n      rfl\n    intro i\n    exact (f i).property\n  rintro ⟨a, f₀, f₁, xeq, yeq, h⟩\n  use abs ⟨a, fun i => ⟨(f₀ i, f₁ i), h i⟩⟩\n  dsimp; constructor\n  · rw [xeq, ← abs_map]\n    rfl\n  rw [yeq, ← abs_map]; rfl\n#align qpf.liftr_iff Qpf.liftr_iff\n\nend\n\n/-\nThink of trees in the `W` type corresponding to `P` as representatives of elements of the\nleast fixed point of `F`, and assign a canonical representative to each equivalence class\nof trees.\n-/\n/-- does recursion on `q.P.W` using `g : F α → α` rather than `g : P α → α` -/\ndef recF {α : Type _} (g : F α → α) : q.p.W → α\n  | ⟨a, f⟩ => g (abs ⟨a, fun x => recF (f x)⟩)\n#align qpf.recF Qpf.recF\n\ntheorem recF_eq {α : Type _} (g : F α → α) (x : q.p.W) : recF g x = g (abs (recF g <$> x.dest)) :=\n  by cases x <;> rfl\n#align qpf.recF_eq Qpf.recF_eq\n\ntheorem recF_eq' {α : Type _} (g : F α → α) (a : q.p.A) (f : q.p.B a → q.p.W) :\n    recF g ⟨a, f⟩ = g (abs (recF g <$> ⟨a, f⟩)) :=\n  rfl\n#align qpf.recF_eq' Qpf.recF_eq'\n\n/-- two trees are equivalent if their F-abstractions are -/\ninductive Wequiv : q.p.W → q.p.W → Prop\n  | ind (a : q.p.A) (f f' : q.p.B a → q.p.W) : (∀ x, Wequiv (f x) (f' x)) → Wequiv ⟨a, f⟩ ⟨a, f'⟩\n  |\n  abs (a : q.p.A) (f : q.p.B a → q.p.W) (a' : q.p.A) (f' : q.p.B a' → q.p.W) :\n    abs ⟨a, f⟩ = abs ⟨a', f'⟩ → Wequiv ⟨a, f⟩ ⟨a', f'⟩\n  | trans (u v w : q.p.W) : Wequiv u v → Wequiv v w → Wequiv u w\n#align qpf.Wequiv Qpf.Wequiv\n\n/-- recF is insensitive to the representation -/\ntheorem recF_eq_of_wequiv {α : Type u} (u : F α → α) (x y : q.p.W) :\n    Wequiv x y → recF u x = recF u y := by\n  cases' x with a f; cases' y with b g\n  intro h; induction h\n  case ind a f f' h ih => simp only [recF_eq', PFunctor.map_eq, Function.comp, ih]\n  case abs a f a' f' h => simp only [recF_eq', abs_map, h]\n  case trans x y z e₁ e₂ ih₁ ih₂ => exact Eq.trans ih₁ ih₂\n#align qpf.recF_eq_of_Wequiv Qpf.recF_eq_of_wequiv\n\ntheorem Wequiv.abs' (x y : q.p.W) (h : abs x.dest = abs y.dest) : Wequiv x y :=\n  by\n  cases x\n  cases y\n  apply Wequiv.abs\n  apply h\n#align qpf.Wequiv.abs' Qpf.Wequiv.abs'\n\ntheorem Wequiv.refl (x : q.p.W) : Wequiv x x := by\n  cases' x with a f <;> exact Wequiv.abs a f a f rfl\n#align qpf.Wequiv.refl Qpf.Wequiv.refl\n\ntheorem Wequiv.symm (x y : q.p.W) : Wequiv x y → Wequiv y x :=\n  by\n  cases' x with a f; cases' y with b g\n  intro h; induction h\n  case ind a f f' h ih => exact Wequiv.ind _ _ _ ih\n  case abs a f a' f' h => exact Wequiv.abs _ _ _ _ h.symm\n  case trans x y z e₁ e₂ ih₁ ih₂ => exact Qpf.Wequiv.trans _ _ _ ih₂ ih₁\n#align qpf.Wequiv.symm Qpf.Wequiv.symm\n\n/-- maps every element of the W type to a canonical representative -/\ndef wrepr : q.p.W → q.p.W :=\n  recF (PFunctor.W.mk ∘ repr)\n#align qpf.Wrepr Qpf.wrepr\n\ntheorem wrepr_equiv (x : q.p.W) : Wequiv (wrepr x) x :=\n  by\n  induction' x with a f ih\n  apply Wequiv.trans\n  · change Wequiv (Wrepr ⟨a, f⟩) (PFunctor.W.mk (Wrepr <$> ⟨a, f⟩))\n    apply Wequiv.abs'\n    have : Wrepr ⟨a, f⟩ = PFunctor.W.mk (repr (abs (Wrepr <$> ⟨a, f⟩))) := rfl\n    rw [this, PFunctor.W.dest_mk, abs_repr]\n    rfl\n  apply Wequiv.ind; exact ih\n#align qpf.Wrepr_equiv Qpf.wrepr_equiv\n\n/-- Define the fixed point as the quotient of trees under the equivalence relation `Wequiv`.\n-/\ndef wSetoid : Setoid q.p.W :=\n  ⟨Wequiv, @Wequiv.refl _ _ _, @Wequiv.symm _ _ _, @Wequiv.trans _ _ _⟩\n#align qpf.W_setoid Qpf.wSetoid\n\nattribute [local instance] W_setoid\n\n/-- inductive type defined as initial algebra of a Quotient of Polynomial Functor -/\n@[nolint has_nonempty_instance]\ndef Fix (F : Type u → Type u) [Functor F] [q : Qpf F] :=\n  Quotient (wSetoid : Setoid q.p.W)\n#align qpf.fix Qpf.Fix\n\n/-- recursor of a type defined by a qpf -/\ndef Fix.rec {α : Type _} (g : F α → α) : Fix F → α :=\n  Quot.lift (recF g) (recF_eq_of_wequiv g)\n#align qpf.fix.rec Qpf.Fix.rec\n\n/-- access the underlying W-type of a fixpoint data type -/\ndef fixToW : Fix F → q.p.W :=\n  Quotient.lift wrepr (recF_eq_of_wequiv fun x => @PFunctor.W.mk q.p (repr x))\n#align qpf.fix_to_W Qpf.fixToW\n\n/-- constructor of a type defined by a qpf -/\ndef Fix.mk (x : F (Fix F)) : Fix F :=\n  Quot.mk _ (PFunctor.W.mk (fixToW <$> repr x))\n#align qpf.fix.mk Qpf.Fix.mk\n\n/-- destructor of a type defined by a qpf -/\ndef Fix.dest : Fix F → F (Fix F) :=\n  Fix.rec (Functor.map Fix.mk)\n#align qpf.fix.dest Qpf.Fix.dest\n\ntheorem Fix.rec_eq {α : Type _} (g : F α → α) (x : F (Fix F)) :\n    Fix.rec g (Fix.mk x) = g (Fix.rec g <$> x) :=\n  by\n  have : recF g ∘ fixToW = Fix.rec g := by\n    apply funext\n    apply Quotient.ind\n    intro x\n    apply recF_eq_of_Wequiv\n    rw [fix_to_W]\n    apply Wrepr_equiv\n  conv =>\n    lhs\n    rw [fix.rec, fix.mk]\n    dsimp\n  cases' h : repr x with a f\n  rw [PFunctor.map_eq, recF_eq, ← PFunctor.map_eq, PFunctor.W.dest_mk, ← PFunctor.comp_map, abs_map,\n    ← h, abs_repr, this]\n#align qpf.fix.rec_eq Qpf.Fix.rec_eq\n\ntheorem Fix.ind_aux (a : q.p.A) (f : q.p.B a → q.p.W) :\n    Fix.mk (abs ⟨a, fun x => ⟦f x⟧⟩) = ⟦⟨a, f⟩⟧ :=\n  by\n  have : Fix.mk (abs ⟨a, fun x => ⟦f x⟧⟩) = ⟦wrepr ⟨a, f⟩⟧ :=\n    by\n    apply Quot.sound; apply Wequiv.abs'\n    rw [PFunctor.W.dest_mk, abs_map, abs_repr, ← abs_map, PFunctor.map_eq]\n    conv =>\n      rhs\n      simp only [Wrepr, recF_eq, PFunctor.W.dest_mk, abs_repr]\n    rfl\n  rw [this]\n  apply Quot.sound\n  apply Wrepr_equiv\n#align qpf.fix.ind_aux Qpf.Fix.ind_aux\n\ntheorem Fix.ind_rec {α : Type u} (g₁ g₂ : Fix F → α)\n    (h : ∀ x : F (Fix F), g₁ <$> x = g₂ <$> x → g₁ (Fix.mk x) = g₂ (Fix.mk x)) : ∀ x, g₁ x = g₂ x :=\n  by\n  apply Quot.ind\n  intro x\n  induction' x with a f ih\n  change g₁ ⟦⟨a, f⟩⟧ = g₂ ⟦⟨a, f⟩⟧\n  rw [← fix.ind_aux a f]; apply h\n  rw [← abs_map, ← abs_map, PFunctor.map_eq, PFunctor.map_eq]\n  dsimp [Function.comp]\n  congr with x; apply ih\n#align qpf.fix.ind_rec Qpf.Fix.ind_rec\n\ntheorem Fix.rec_unique {α : Type u} (g : F α → α) (h : Fix F → α)\n    (hyp : ∀ x, h (Fix.mk x) = g (h <$> x)) : Fix.rec g = h :=\n  by\n  ext x\n  apply fix.ind_rec\n  intro x hyp'\n  rw [hyp, ← hyp', fix.rec_eq]\n#align qpf.fix.rec_unique Qpf.Fix.rec_unique\n\ntheorem Fix.mk_dest (x : Fix F) : Fix.mk (Fix.dest x) = x :=\n  by\n  change (fix.mk ∘ fix.dest) x = id x\n  apply fix.ind_rec\n  intro x; dsimp\n  rw [fix.dest, fix.rec_eq, id_map, comp_map]\n  intro h; rw [h]\n#align qpf.fix.mk_dest Qpf.Fix.mk_dest\n\ntheorem Fix.dest_mk (x : F (Fix F)) : Fix.dest (Fix.mk x) = x :=\n  by\n  unfold fix.dest; rw [fix.rec_eq, ← fix.dest, ← comp_map]\n  conv =>\n    rhs\n    rw [← id_map x]\n  congr with x; apply fix.mk_dest\n#align qpf.fix.dest_mk Qpf.Fix.dest_mk\n\ntheorem Fix.ind (p : Fix F → Prop) (h : ∀ x : F (Fix F), Liftp p x → p (Fix.mk x)) : ∀ x, p x :=\n  by\n  apply Quot.ind\n  intro x\n  induction' x with a f ih\n  change p ⟦⟨a, f⟩⟧\n  rw [← fix.ind_aux a f]\n  apply h\n  rw [liftp_iff]\n  refine' ⟨_, _, rfl, _⟩\n  apply ih\n#align qpf.fix.ind Qpf.Fix.ind\n\nend Qpf\n\n/-\nConstruct the final coalgebra to a qpf.\n-/\nnamespace Qpf\n\nvariable {F : Type u → Type u} [Functor F] [q : Qpf F]\n\ninclude q\n\nopen Functor (Liftp Liftr)\n\n/-- does recursion on `q.P.M` using `g : α → F α` rather than `g : α → P α` -/\ndef corecF {α : Type _} (g : α → F α) : α → q.p.M :=\n  PFunctor.M.corec fun x => repr (g x)\n#align qpf.corecF Qpf.corecF\n\ntheorem corecF_eq {α : Type _} (g : α → F α) (x : α) :\n    PFunctor.M.dest (corecF g x) = corecF g <$> repr (g x) := by rw [corecF, PFunctor.M.dest_corec]\n#align qpf.corecF_eq Qpf.corecF_eq\n\n-- Equivalence\n/-- A pre-congruence on q.P.M *viewed as an F-coalgebra*. Not necessarily symmetric. -/\ndef IsPrecongr (r : q.p.M → q.p.M → Prop) : Prop :=\n  ∀ ⦃x y⦄, r x y → abs (Quot.mk r <$> PFunctor.M.dest x) = abs (Quot.mk r <$> PFunctor.M.dest y)\n#align qpf.is_precongr Qpf.IsPrecongr\n\n/-- The maximal congruence on q.P.M -/\ndef Mcongr : q.p.M → q.p.M → Prop := fun x y => ∃ r, IsPrecongr r ∧ r x y\n#align qpf.Mcongr Qpf.Mcongr\n\n/-- coinductive type defined as the final coalgebra of a qpf -/\ndef Cofix (F : Type u → Type u) [Functor F] [q : Qpf F] :=\n  Quot (@Mcongr F _ q)\n#align qpf.cofix Qpf.Cofix\n\ninstance [Inhabited q.p.A] : Inhabited (Cofix F) :=\n  ⟨Quot.mk _ default⟩\n\n/-- corecursor for type defined by `cofix` -/\ndef Cofix.corec {α : Type _} (g : α → F α) (x : α) : Cofix F :=\n  Quot.mk _ (corecF g x)\n#align qpf.cofix.corec Qpf.Cofix.corec\n\n/-- destructor for type defined by `cofix` -/\ndef Cofix.dest : Cofix F → F (Cofix F) :=\n  Quot.lift (fun x => Quot.mk Mcongr <$> abs (PFunctor.M.dest x))\n    (by\n      rintro x y ⟨r, pr, rxy⟩\n      dsimp\n      have : ∀ x y, r x y → Mcongr x y := by\n        intro x y h\n        exact ⟨r, pr, h⟩\n      rw [← Quot.factor_mk_eq _ _ this]\n      dsimp\n      conv =>\n        lhs\n        rw [comp_map, ← abs_map, pr rxy, abs_map, ← comp_map])\n#align qpf.cofix.dest Qpf.Cofix.dest\n\ntheorem Cofix.dest_corec {α : Type u} (g : α → F α) (x : α) :\n    Cofix.dest (Cofix.corec g x) = Cofix.corec g <$> g x :=\n  by\n  conv =>\n    lhs\n    rw [cofix.dest, cofix.corec];\n  dsimp\n  rw [corecF_eq, abs_map, abs_repr, ← comp_map]; rfl\n#align qpf.cofix.dest_corec Qpf.Cofix.dest_corec\n\nprivate theorem cofix.bisim_aux (r : Cofix F → Cofix F → Prop) (h' : ∀ x, r x x)\n    (h : ∀ x y, r x y → Quot.mk r <$> Cofix.dest x = Quot.mk r <$> Cofix.dest y) :\n    ∀ x y, r x y → x = y := by\n  intro x\n  apply Quot.inductionOn x\n  clear x\n  intro x y\n  apply Quot.inductionOn y\n  clear y\n  intro y rxy\n  apply Quot.sound\n  let r' x y := r (Quot.mk _ x) (Quot.mk _ y)\n  have : is_precongr r' := by\n    intro a b r'ab\n    have h₀ :\n      Quot.mk r <$> Quot.mk Mcongr <$> abs (PFunctor.M.dest a) =\n        Quot.mk r <$> Quot.mk Mcongr <$> abs (PFunctor.M.dest b) :=\n      h _ _ r'ab\n    have h₁ : ∀ u v : q.P.M, Mcongr u v → Quot.mk r' u = Quot.mk r' v :=\n      by\n      intro u v cuv\n      apply Quot.sound\n      dsimp [r']\n      rw [Quot.sound cuv]\n      apply h'\n    let f : Quot r → Quot r' :=\n      Quot.lift (Quot.lift (Quot.mk r') h₁)\n        (by\n          intro c; apply Quot.inductionOn c; clear c\n          intro c d; apply Quot.inductionOn d; clear d\n          intro d rcd; apply Quot.sound; apply rcd)\n    have : f ∘ Quot.mk r ∘ Quot.mk Mcongr = Quot.mk r' := rfl\n    rw [← this, PFunctor.comp_map _ _ f, PFunctor.comp_map _ _ (Quot.mk r), abs_map, abs_map,\n      abs_map, h₀]\n    rw [PFunctor.comp_map _ _ f, PFunctor.comp_map _ _ (Quot.mk r), abs_map, abs_map, abs_map]\n  refine' ⟨r', this, rxy⟩\n#align qpf.cofix.bisim_aux qpf.cofix.bisim_aux\n\ntheorem Cofix.bisim_rel (r : Cofix F → Cofix F → Prop)\n    (h : ∀ x y, r x y → Quot.mk r <$> Cofix.dest x = Quot.mk r <$> Cofix.dest y) :\n    ∀ x y, r x y → x = y := by\n  let r' (x y) := x = y ∨ r x y\n  intro x y rxy\n  apply cofix.bisim_aux r'\n  · intro x\n    left\n    rfl\n  · intro x y r'xy\n    cases r'xy\n    · rw [r'xy]\n    have : ∀ x y, r x y → r' x y := fun x y h => Or.inr h\n    rw [← Quot.factor_mk_eq _ _ this]\n    dsimp\n    rw [@comp_map _ _ q _ _ _ (Quot.mk r), @comp_map _ _ q _ _ _ (Quot.mk r)]\n    rw [h _ _ r'xy]\n  right; exact rxy\n#align qpf.cofix.bisim_rel Qpf.Cofix.bisim_rel\n\ntheorem Cofix.bisim (r : Cofix F → Cofix F → Prop)\n    (h : ∀ x y, r x y → Liftr r (Cofix.dest x) (Cofix.dest y)) : ∀ x y, r x y → x = y :=\n  by\n  apply cofix.bisim_rel\n  intro x y rxy\n  rcases(liftr_iff r _ _).mp (h x y rxy) with ⟨a, f₀, f₁, dxeq, dyeq, h'⟩\n  rw [dxeq, dyeq, ← abs_map, ← abs_map, PFunctor.map_eq, PFunctor.map_eq]\n  congr 2 with i\n  apply Quot.sound\n  apply h'\n#align qpf.cofix.bisim Qpf.Cofix.bisim\n\ntheorem Cofix.bisim' {α : Type _} (Q : α → Prop) (u v : α → Cofix F)\n    (h :\n      ∀ x,\n        Q x →\n          ∃ a f f',\n            Cofix.dest (u x) = abs ⟨a, f⟩ ∧\n              Cofix.dest (v x) = abs ⟨a, f'⟩ ∧ ∀ i, ∃ x', Q x' ∧ f i = u x' ∧ f' i = v x') :\n    ∀ x, Q x → u x = v x := fun x Qx =>\n  let R := fun w z : Cofix F => ∃ x', Q x' ∧ w = u x' ∧ z = v x'\n  Cofix.bisim R\n    (fun x y ⟨x', Qx', xeq, yeq⟩ =>\n      by\n      rcases h x' Qx' with ⟨a, f, f', ux'eq, vx'eq, h'⟩\n      rw [liftr_iff]\n      refine' ⟨a, f, f', xeq.symm ▸ ux'eq, yeq.symm ▸ vx'eq, h'⟩)\n    _ _ ⟨x, Qx, rfl, rfl⟩\n#align qpf.cofix.bisim' Qpf.Cofix.bisim'\n\nend Qpf\n\n/-\nComposition of qpfs.\n-/\nnamespace Qpf\n\nvariable {F₂ : Type u → Type u} [Functor F₂] [q₂ : Qpf F₂]\n\nvariable {F₁ : Type u → Type u} [Functor F₁] [q₁ : Qpf F₁]\n\ninclude q₂ q₁\n\n/-- composition of qpfs gives another qpf  -/\ndef comp : Qpf (Functor.Comp F₂ F₁)\n    where\n  p := PFunctor.comp q₂.p q₁.p\n  abs α := by\n    dsimp [Functor.Comp]\n    intro p\n    exact abs ⟨p.1.1, fun x => abs ⟨p.1.2 x, fun y => p.2 ⟨x, y⟩⟩⟩\n  repr α := by\n    dsimp [Functor.Comp]\n    intro y\n    refine' ⟨⟨(repr y).1, fun u => (repr ((repr y).2 u)).1⟩, _⟩\n    dsimp [PFunctor.comp]\n    intro x\n    exact (repr ((repr y).2 x.1)).snd x.2\n  abs_repr α := by\n    abstract \n      dsimp [Functor.Comp]\n      intro x\n      conv =>\n        rhs\n        rw [← abs_repr x]\n      cases' h : repr x with a f\n      dsimp\n      congr with x\n      cases' h' : repr (f x) with b g\n      dsimp; rw [← h', abs_repr]\n  abs_map α β f := by\n    abstract \n      dsimp [Functor.Comp, PFunctor.comp]\n      intro p\n      cases' p with a g; dsimp\n      cases' a with b h; dsimp\n      symm\n      trans\n      symm\n      apply abs_map\n      congr\n      rw [PFunctor.map_eq]\n      dsimp [Function.comp]\n      simp [abs_map]\n      constructor\n      rfl\n      ext x\n      rw [← abs_map]\n      rfl\n#align qpf.comp Qpf.comp\n\nend Qpf\n\n/-\nQuotients.\n\nWe show that if `F` is a qpf and `G` is a suitable quotient of `F`, then `G` is a qpf.\n-/\nnamespace Qpf\n\nvariable {F : Type u → Type u} [Functor F] [q : Qpf F]\n\nvariable {G : Type u → Type u} [Functor G]\n\nvariable {FG_abs : ∀ {α}, F α → G α}\n\nvariable {FG_repr : ∀ {α}, G α → F α}\n\n/-- Given a qpf `F` and a well-behaved surjection `FG_abs` from F α to\nfunctor G α, `G` is a qpf. We can consider `G` a quotient on `F` where\nelements `x y : F α` are in the same equivalence class if\n`FG_abs x = FG_abs y`  -/\ndef quotientQpf (FG_abs_repr : ∀ {α} (x : G α), FG_abs (FG_repr x) = x)\n    (FG_abs_map : ∀ {α β} (f : α → β) (x : F α), FG_abs (f <$> x) = f <$> FG_abs x) : Qpf G\n    where\n  p := q.p\n  abs {α} p := FG_abs (abs p)\n  repr {α} x := repr (FG_repr x)\n  abs_repr {α} x := by rw [abs_repr, FG_abs_repr]\n  abs_map {α β} f x := by rw [abs_map, FG_abs_map]\n#align qpf.quotient_qpf Qpf.quotientQpf\n\nend Qpf\n\n/-\nSupport.\n-/\nnamespace Qpf\n\nvariable {F : Type u → Type u} [Functor F] [q : Qpf F]\n\ninclude q\n\nopen Functor (Liftp Liftr supp)\n\nopen Set\n\ntheorem mem_supp {α : Type u} (x : F α) (u : α) :\n    u ∈ supp x ↔ ∀ a f, abs ⟨a, f⟩ = x → u ∈ f '' univ :=\n  by\n  rw [supp]; dsimp; constructor\n  · intro h a f haf\n    have : liftp (fun u => u ∈ f '' univ) x :=\n      by\n      rw [liftp_iff]\n      refine' ⟨a, f, haf.symm, fun i => mem_image_of_mem _ (mem_univ _)⟩\n    exact h this\n  intro h p; rw [liftp_iff]\n  rintro ⟨a, f, xeq, h'⟩\n  rcases h a f xeq.symm with ⟨i, _, hi⟩\n  rw [← hi]; apply h'\n#align qpf.mem_supp Qpf.mem_supp\n\ntheorem supp_eq {α : Type u} (x : F α) : supp x = { u | ∀ a f, abs ⟨a, f⟩ = x → u ∈ f '' univ } :=\n  by ext <;> apply mem_supp\n#align qpf.supp_eq Qpf.supp_eq\n\ntheorem has_good_supp_iff {α : Type u} (x : F α) :\n    (∀ p, Liftp p x ↔ ∀ u ∈ supp x, p u) ↔\n      ∃ a f, abs ⟨a, f⟩ = x ∧ ∀ a' f', abs ⟨a', f'⟩ = x → f '' univ ⊆ f' '' univ :=\n  by\n  constructor\n  · intro h\n    have : liftp (supp x) x := by rw [h] <;> intro u <;> exact id\n    rw [liftp_iff] at this\n    rcases this with ⟨a, f, xeq, h'⟩\n    refine' ⟨a, f, xeq.symm, _⟩\n    intro a' f' h''\n    rintro u ⟨i, _, hfi⟩\n    have : u ∈ supp x := by rw [← hfi] <;> apply h'\n    exact (mem_supp x u).mp this _ _ h''\n  rintro ⟨a, f, xeq, h⟩ p; rw [liftp_iff]; constructor\n  · rintro ⟨a', f', xeq', h'⟩ u usuppx\n    rcases(mem_supp x u).mp usuppx a' f' xeq'.symm with ⟨i, _, f'ieq⟩\n    rw [← f'ieq]\n    apply h'\n  intro h'\n  refine' ⟨a, f, xeq.symm, _⟩; intro i\n  apply h'; rw [mem_supp]\n  intro a' f' xeq'\n  apply h a' f' xeq'\n  apply mem_image_of_mem _ (mem_univ _)\n#align qpf.has_good_supp_iff Qpf.has_good_supp_iff\n\nvariable (q)\n\n/-- A qpf is said to be uniform if every polynomial functor\nrepresenting a single value all have the same range. -/\ndef IsUniform : Prop :=\n  ∀ ⦃α : Type u⦄ (a a' : q.p.A) (f : q.p.B a → α) (f' : q.p.B a' → α),\n    abs ⟨a, f⟩ = abs ⟨a', f'⟩ → f '' univ = f' '' univ\n#align qpf.is_uniform Qpf.IsUniform\n\n/-- does `abs` preserve `liftp`? -/\ndef LiftpPreservation : Prop :=\n  ∀ ⦃α⦄ (p : α → Prop) (x : q.p.Obj α), Liftp p (abs x) ↔ Liftp p x\n#align qpf.liftp_preservation Qpf.LiftpPreservation\n\n/-- does `abs` preserve `supp`? -/\ndef SuppPreservation : Prop :=\n  ∀ ⦃α⦄ (x : q.p.Obj α), supp (abs x) = supp x\n#align qpf.supp_preservation Qpf.SuppPreservation\n\nvariable (q)\n\ntheorem supp_eq_of_isUniform (h : q.IsUniform) {α : Type u} (a : q.p.A) (f : q.p.B a → α) :\n    supp (abs ⟨a, f⟩) = f '' univ := by\n  ext u; rw [mem_supp]; constructor\n  · intro h'\n    apply h' _ _ rfl\n  intro h' a' f' e\n  rw [← h _ _ _ _ e.symm]; apply h'\n#align qpf.supp_eq_of_is_uniform Qpf.supp_eq_of_isUniform\n\ntheorem liftp_iff_of_isUniform (h : q.IsUniform) {α : Type u} (x : F α) (p : α → Prop) :\n    Liftp p x ↔ ∀ u ∈ supp x, p u :=\n  by\n  rw [liftp_iff, ← abs_repr x]\n  cases' repr x with a f; constructor\n  · rintro ⟨a', f', abseq, hf⟩ u\n    rw [supp_eq_of_is_uniform h, h _ _ _ _ abseq]\n    rintro ⟨i, _, hi⟩\n    rw [← hi]\n    apply hf\n  intro h'\n  refine' ⟨a, f, rfl, fun i => h' _ _⟩\n  rw [supp_eq_of_is_uniform h]\n  exact ⟨i, mem_univ i, rfl⟩\n#align qpf.liftp_iff_of_is_uniform Qpf.liftp_iff_of_isUniform\n\ntheorem supp_map (h : q.IsUniform) {α β : Type u} (g : α → β) (x : F α) :\n    supp (g <$> x) = g '' supp x := by\n  rw [← abs_repr x]; cases' repr x with a f; rw [← abs_map, PFunctor.map_eq]\n  rw [supp_eq_of_is_uniform h, supp_eq_of_is_uniform h, image_comp]\n#align qpf.supp_map Qpf.supp_map\n\ntheorem suppPreservation_iff_uniform : q.SuppPreservation ↔ q.IsUniform :=\n  by\n  constructor\n  · intro h α a a' f f' h'\n    rw [← PFunctor.supp_eq, ← PFunctor.supp_eq, ← h, h', h]\n  · rintro h α ⟨a, f⟩\n    rwa [supp_eq_of_is_uniform, PFunctor.supp_eq]\n#align qpf.supp_preservation_iff_uniform Qpf.suppPreservation_iff_uniform\n\ntheorem suppPreservation_iff_liftpPreservation : q.SuppPreservation ↔ q.LiftpPreservation :=\n  by\n  constructor <;> intro h\n  · rintro α p ⟨a, f⟩\n    have h' := h\n    rw [supp_preservation_iff_uniform] at h'\n    dsimp only [supp_preservation, supp] at h\n    rwa [liftp_iff_of_is_uniform, supp_eq_of_is_uniform, PFunctor.liftp_iff'] <;> try assumption\n    · simp only [image_univ, mem_range, exists_imp]\n      constructor <;> intros <;> subst_vars <;> solve_by_elim\n  · rintro α ⟨a, f⟩\n    simp only [liftp_preservation] at h\n    simp only [supp, h]\n#align qpf.supp_preservation_iff_liftp_preservation Qpf.suppPreservation_iff_liftpPreservation\n\ntheorem liftpPreservation_iff_uniform : q.LiftpPreservation ↔ q.IsUniform := by\n  rw [← supp_preservation_iff_liftp_preservation, supp_preservation_iff_uniform]\n#align qpf.liftp_preservation_iff_uniform Qpf.liftpPreservation_iff_uniform\n\nend Qpf\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Qpf/Univariate/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.682573734412324, "lm_q1q2_score": 0.49477741137450804}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.constructions.filtered\n! leanprover-community/mathlib commit e4ee4e30418efcb8cf304ba76ad653aeec04ba6e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Limits.Constructions.LimitsOfProductsAndEqualizers\nimport Mathlib.CategoryTheory.Limits.Opposites\n\n/-!\n# Constructing colimits from finite colimits and filtered colimits\n\nWe construct colimits of size `w` from finite colimits and filtered colimits of size `w`. Since\n`w`-sized colimits are constructured from coequalizers and `w`-sized coproducts, it suffices to\nconstruct `w`-sized coproducts from finite coproducts and `w`-sized filtered colimits.\n\nThe idea is simple: to construct coproducts of shape `α`, we take the colimit of the filtered\ndiagram of all coproducts of finite subsets of `α`.\n\nWe also deduce the dual statement by invoking the original statement in `Cᵒᵖ`.\n-/\n\n\nuniverse w v u\n\nnoncomputable section\n\nopen CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] {α : Type w}\n\nnamespace CategoryTheory.Limits\n\nnamespace CoproductsFromFiniteFiltered\n\n/-- If `C` has finite coproducts, a functor `Discrete α ⥤ C` lifts to a functor\n    `Finset (Discrete α) ⥤ C` by taking coproducts. -/\n@[simps!]\ndef liftToFinset [HasFiniteCoproducts C] (F : Discrete α ⥤ C) : Finset (Discrete α) ⥤ C where\n  obj s := ∐ fun x : s => F.obj x\n  map {_ Y} h := Sigma.desc fun y =>\n    Sigma.ι (fun (x : { x // x ∈ Y }) => F.obj x) ⟨y, h.down.down y.2⟩\n#align category_theory.limits.coproducts_from_finite_filtered.lift_to_finset CategoryTheory.Limits.CoproductsFromFiniteFiltered.liftToFinset\n\n/-- If `C` has finite coproducts and filtered colimits, we can construct arbitrary coproducts by\n    taking the colimit of the diagram formed by the coproducts of finite sets over the indexing\n    type. -/\n@[simps!]\ndef liftToFinsetColimitCocone [HasFiniteCoproducts C] [HasFilteredColimitsOfSize.{w, w} C]\n    [DecidableEq α] (F : Discrete α ⥤ C) : ColimitCocone F where\n  cocone :=\n    { pt := colimit (liftToFinset F)\n      ι :=\n        Discrete.natTrans fun j =>\n          @Sigma.ι _ _ _ (fun x : ({j} : Finset (Discrete α)) => F.obj x) _ ⟨j, by simp⟩ ≫\n            colimit.ι (liftToFinset F) {j} }\n  isColimit :=\n    { desc := fun s =>\n        colimit.desc (liftToFinset F)\n          { pt := s.pt\n            ι := { app := fun t => Sigma.desc fun x => s.ι.app x } }\n      uniq := fun s m h => by\n        apply colimit.hom_ext\n        rintro t\n        dsimp [liftToFinset]\n        apply colimit.hom_ext\n        rintro ⟨⟨j, hj⟩⟩\n        convert h j using 1\n        . simp [← colimit.w (liftToFinset F) ⟨⟨Finset.singleton_subset_iff.2 hj⟩⟩]\n          rfl\n        . aesop_cat }\n#align category_theory.limits.coproducts_from_finite_filtered.lift_to_finset_colimit_cocone CategoryTheory.Limits.CoproductsFromFiniteFiltered.liftToFinsetColimitCocone\n\nend CoproductsFromFiniteFiltered\n\nopen CoproductsFromFiniteFiltered\n\ntheorem hasCoproducts_of_finite_and_filtered [HasFiniteCoproducts C]\n    [HasFilteredColimitsOfSize.{w, w} C] : HasCoproducts.{w} C := fun α => by\n  classical exact ⟨fun F => HasColimit.mk (liftToFinsetColimitCocone F)⟩\n#align category_theory.limits.has_coproducts_of_finite_and_filtered CategoryTheory.Limits.hasCoproducts_of_finite_and_filtered\n\ntheorem has_colimits_of_finite_and_filtered [HasFiniteColimits C]\n    [HasFilteredColimitsOfSize.{w, w} C] : HasColimitsOfSize.{w, w} C :=\n  have : HasCoproducts.{w} C := hasCoproducts_of_finite_and_filtered\n  has_colimits_of_hasCoequalizers_and_coproducts\n#align category_theory.limits.has_colimits_of_finite_and_filtered CategoryTheory.Limits.has_colimits_of_finite_and_filtered\n\ntheorem hasProducts_of_finite_and_cofiltered [HasFiniteProducts C]\n    [HasCofilteredLimitsOfSize.{w, w} C] : HasProducts.{w} C :=\n  have : HasCoproducts.{w} Cᵒᵖ := hasCoproducts_of_finite_and_filtered\n  hasProducts_of_opposite\n#align category_theory.limits.has_products_of_finite_and_cofiltered CategoryTheory.Limits.hasProducts_of_finite_and_cofiltered\n\ntheorem has_limits_of_finite_and_cofiltered [HasFiniteLimits C]\n    [HasCofilteredLimitsOfSize.{w, w} C] : HasLimitsOfSize.{w, w} C :=\n  have : HasProducts.{w} C := hasProducts_of_finite_and_cofiltered\n  has_limits_of_hasEqualizers_and_products\n#align category_theory.limits.has_limits_of_finite_and_cofiltered CategoryTheory.Limits.has_limits_of_finite_and_cofiltered\n\nend CategoryTheory.Limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Limits/Constructions/Filtered.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.494777406693894}}
{"text": "example (p q r : Prop) (hp : p) :\n    (p ∨ q ∨ r) ∧ (q ∨ p ∨ r) ∧ (q ∨ r ∨ p) :=\nbegin\n  split,\n    left,\n    assumption,\n  split,\n    right,\n    left,\n    assumption,\n  right,\n  right,\n  assumption\nend\n\nexample (p q r : Prop) (hp : p) :\n  (p ∨ q ∨ r) ∧ (q ∨ p ∨ r) ∧ (q ∨ r ∨ p) :=\nby repeat { split <|> { try {left}, assumption } <|> right }\n", "meta": {"author": "zeptometer", "repo": "LearnLean", "sha": "bb84d5dbe521127ba134d4dbf9559b294a80b9f7", "save_path": "github-repos/lean/zeptometer-LearnLean", "path": "github-repos/lean/zeptometer-LearnLean/LearnLean-bb84d5dbe521127ba134d4dbf9559b294a80b9f7/bluejam/chap5_exercise5.2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.49458343184856246}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Jakob von Raumer\n-/\nimport algebra.big_operators.basic\nimport algebra.hom.group\nimport algebra.module.basic\nimport category_theory.endomorphism\nimport category_theory.limits.shapes.kernels\n\n/-!\n# Preadditive categories\n\nA preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that\ncomposition of morphisms is linear in both variables.\n\nThis file contains a definition of preadditive category that directly encodes the definition given\nabove. The definition could also be phrased as follows: A preadditive category is a category\nenriched over the category of Abelian groups. Once the general framework to state this in Lean is\navailable, the contents of this file should become obsolete.\n\n## Main results\n\n* Definition of preadditive categories and basic properties\n* In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all\n  composable `g`.\n* A preadditive category with kernels has equalizers.\n\n## Implementation notes\n\nThe simp normal form for negation and composition is to push negations as far as possible to\nthe outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)`\nis simplified to `f ≫ g`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n\n## Tags\n\nadditive, preadditive, Hom group, Ab-category, Ab-enriched\n-/\n\nuniverses v u\n\nopen category_theory.limits\n\nopen_locale big_operators\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is\n    linear in both variables. -/\nclass preadditive :=\n(hom_group : Π P Q : C, add_comm_group (P ⟶ Q) . tactic.apply_instance)\n(add_comp' : ∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R),\n  (f + f') ≫ g = f ≫ g + f' ≫ g . obviously)\n(comp_add' : ∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R),\n  f ≫ (g + g') = f ≫ g + f ≫ g' . obviously)\n\nattribute [instance] preadditive.hom_group\nrestate_axiom preadditive.add_comp'\nrestate_axiom preadditive.comp_add'\nattribute [simp,reassoc] preadditive.add_comp\nattribute [reassoc] preadditive.comp_add -- (the linter doesn't like `simp` on this lemma)\nattribute [simp] preadditive.comp_add\n\nend category_theory\n\nopen category_theory\n\nnamespace category_theory\nnamespace preadditive\n\nsection preadditive\nopen add_monoid_hom\nvariables {C : Type u} [category.{v} C] [preadditive C]\n\nsection induced_category\nuniverses u'\nvariables {C} {D : Type u'} (F : D → C)\n\ninstance induced_category.category : preadditive.{v} (induced_category C F) :=\n{ hom_group := λ P Q, @preadditive.hom_group C _ _ (F P) (F Q),\n  add_comp' := λ P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := λ P Q R f g g', comp_add' _ _ _ _ _ _, }\n\nend induced_category\n\ninstance (X : C) : add_comm_group (End X) := by { dsimp [End], apply_instance, }\n\ninstance (X : C) : ring (End X) :=\n{ left_distrib := λ f g h, preadditive.add_comp X X X g h f,\n  right_distrib := λ f g h, preadditive.comp_add X X X h f g,\n  ..(infer_instance : add_comm_group (End X)),\n  ..(infer_instance : monoid (End X)) }\n\n/-- Composition by a fixed left argument as a group homomorphism -/\ndef left_comp {P Q : C} (R : C) (f : P ⟶ Q) : (Q ⟶ R) →+ (P ⟶ R) :=\nmk' (λ g, f ≫ g) $ λ g g', by simp\n\n/-- Composition by a fixed right argument as a group homomorphism -/\ndef right_comp (P : C) {Q R : C} (g : Q ⟶ R) : (P ⟶ Q) →+ (P ⟶ R) :=\nmk' (λ f, f ≫ g) $ λ f f', by simp\n\nvariables {P Q R : C} (f f' : P ⟶ Q) (g g' : Q ⟶ R)\n\n/-- Composition as a bilinear group homomorphism -/\ndef comp_hom : (P ⟶ Q) →+ (Q ⟶ R) →+ (P ⟶ R) :=\nadd_monoid_hom.mk' (λ f, left_comp _ f) $\n  λ f₁ f₂, add_monoid_hom.ext $ λ g, (right_comp _ g).map_add f₁ f₂\n\n@[simp, reassoc] lemma sub_comp :\n  (f - f') ≫ g = f ≫ g - f' ≫ g :=\nmap_sub (right_comp P g) f f'\n\n-- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma.\n@[reassoc, simp] lemma comp_sub :\n  f ≫ (g - g') = f ≫ g - f ≫ g' :=\nmap_sub (left_comp R f) g g'\n\n@[simp, reassoc] lemma neg_comp : (-f) ≫ g = -(f ≫ g) :=\nmap_neg (right_comp P g) f\n\n/- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma. -/\n@[reassoc, simp] lemma comp_neg : f ≫ (-g) = -(f ≫ g) :=\nmap_neg (left_comp R f) g\n\n@[reassoc] lemma neg_comp_neg : (-f) ≫ (-g) = f ≫ g :=\nby simp\n\nlemma nsmul_comp (n : ℕ) : (n • f) ≫ g = n • (f ≫ g) :=\nmap_nsmul (right_comp P g) n f\n\nlemma comp_nsmul (n : ℕ) : f ≫ (n • g) = n • (f ≫ g) :=\nmap_nsmul (left_comp R f) n g\n\nlemma zsmul_comp (n : ℤ) : (n • f) ≫ g = n • (f ≫ g) :=\nmap_zsmul (right_comp P g) n f\n\nlemma comp_zsmul (n : ℤ) : f ≫ (n • g) = n • (f ≫ g) :=\nmap_zsmul (left_comp R f) n g\n\n@[reassoc] lemma comp_sum {P Q R : C} {J : Type*} (s : finset J) (f : P ⟶ Q) (g : J → (Q ⟶ R)) :\n  f ≫ ∑ j in s, g j = ∑ j in s, f ≫ g j :=\nmap_sum (left_comp R f) _ _\n\n@[reassoc] lemma sum_comp {P Q R : C} {J : Type*} (s : finset J) (f : J → (P ⟶ Q)) (g : Q ⟶ R) :\n  (∑ j in s, f j) ≫ g  = ∑ j in s, f j ≫ g :=\nmap_sum (right_comp P g) _ _\n\ninstance {P Q : C} {f : P ⟶ Q} [epi f] : epi (-f) :=\n⟨λ R g g' H, by rwa [neg_comp, neg_comp, ←comp_neg, ←comp_neg, cancel_epi, neg_inj] at H⟩\n\ninstance {P Q : C} {f : P ⟶ Q} [mono f] : mono (-f) :=\n⟨λ R g g' H, by rwa [comp_neg, comp_neg, ←neg_comp, ←neg_comp, cancel_mono, neg_inj] at H⟩\n\n@[priority 100]\ninstance preadditive_has_zero_morphisms : has_zero_morphisms C :=\n{ has_zero := infer_instance,\n  comp_zero' := λ P Q f R, show left_comp R f 0 = 0, from map_zero _,\n  zero_comp' := λ P Q R f, show right_comp P f 0 = 0, from map_zero _ }\n\ninstance module_End_right {X Y : C} : module (End Y) (X ⟶ Y) :=\n{ smul_add := λ r f g, add_comp _ _ _ _ _ _,\n  smul_zero := λ r, zero_comp,\n  add_smul := λ r s f, comp_add _ _ _ _ _ _,\n  zero_smul := λ r, comp_zero }\n\nlemma mono_of_cancel_zero {Q R : C} (f : Q ⟶ R) (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) :\n  mono f :=\n⟨λ P g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (right_comp P f) g g').trans $ sub_eq_zero.2 hg⟩\n\nlemma mono_iff_cancel_zero {Q R : C} (f : Q ⟶ R) :\n  mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 :=\n⟨λ m P g, by exactI zero_of_comp_mono _, mono_of_cancel_zero f⟩\n\nlemma mono_of_kernel_zero {X Y : C} {f : X ⟶ Y} [has_limit (parallel_pair f 0)]\n  (w : kernel.ι f = 0) : mono f :=\nmono_of_cancel_zero f (λ P g h, by rw [←kernel.lift_ι f g h, w, limits.comp_zero])\n\nlemma epi_of_cancel_zero {P Q : C} (f : P ⟶ Q) (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) :\n  epi f :=\n⟨λ R g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (left_comp R f) g g').trans $ sub_eq_zero.2 hg⟩\n\nlemma epi_iff_cancel_zero {P Q : C} (f : P ⟶ Q) :\n  epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 :=\n⟨λ e R g, by exactI zero_of_epi_comp _, epi_of_cancel_zero f⟩\n\nlemma epi_of_cokernel_zero {X Y : C} {f : X ⟶ Y} [has_colimit (parallel_pair f 0 )]\n  (w : cokernel.π f = 0) : epi f :=\nepi_of_cancel_zero f (λ P g h, by rw [←cokernel.π_desc f g h, w, limits.zero_comp])\n\nnamespace is_iso\n\n@[simp] lemma comp_left_eq_zero [is_iso f] :\n  f ≫ g = 0 ↔ g = 0 :=\nby rw [← is_iso.eq_inv_comp, limits.comp_zero]\n\n@[simp] lemma comp_right_eq_zero [is_iso g] :\n  f ≫ g = 0 ↔ f = 0 :=\nby rw [← is_iso.eq_comp_inv, limits.zero_comp]\n\nend is_iso\n\nopen_locale zero_object\nvariables [has_zero_object C]\n\nlemma mono_of_kernel_iso_zero {X Y : C} {f : X ⟶ Y} [has_limit (parallel_pair f 0)]\n  (w : kernel f ≅ 0) : mono f :=\nmono_of_kernel_zero (zero_of_source_iso_zero _ w)\n\nlemma epi_of_cokernel_iso_zero {X Y : C} {f : X ⟶ Y} [has_colimit (parallel_pair f 0)]\n  (w : cokernel f ≅ 0) : epi f :=\nepi_of_cokernel_zero (zero_of_target_iso_zero _ w)\n\nend preadditive\n\nsection equalizers\nvariables {C : Type u} [category.{v} C] [preadditive C]\n\nsection\nvariables {X Y : C} {f : X ⟶ Y} {g : X ⟶ Y}\n\n/-- Map a kernel cone on the difference of two morphisms to the equalizer fork. -/\ndef fork_of_kernel_fork (c : kernel_fork (f - g)) : fork f g :=\nfork.of_ι c.ι $ by rw [← sub_eq_zero, ← comp_sub, c.condition]\n\n/-- Map any equalizer fork to a cone on the difference of the two morphisms. -/\ndef kernel_fork_of_fork (c : fork f g) : kernel_fork (f - g) :=\nfork.of_ι c.ι $ by rw [comp_sub, comp_zero, sub_eq_zero, c.condition]\n\n@[simp] lemma kernel_fork_of_fork_ι (c : fork f g) : (kernel_fork_of_fork c).ι = c.ι := rfl\n\n@[simp] lemma kernel_fork_of_fork_of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) :\n  (kernel_fork_of_fork (fork.of_ι ι w)) = kernel_fork.of_ι ι (by simp [w]) := rfl\n\n/-- A kernel of `f - g` is an equalizer of `f` and `g`. -/\ndef is_limit_fork_of_kernel_fork {c : kernel_fork (f - g)} (i : is_limit c) :\n  is_limit (fork_of_kernel_fork c) :=\nfork.is_limit.mk' _ $ λ s,\n  ⟨i.lift (kernel_fork_of_fork s), i.fac _ _,\n   λ m h, by apply fork.is_limit.hom_ext i; tidy⟩\n\n@[simp]\nlemma is_limit_fork_of_kernel_fork_lift {c : kernel_fork (f - g)} (i : is_limit c) (s : fork f g) :\n  (is_limit_fork_of_kernel_fork i).lift s = i.lift (kernel_fork_of_fork s) := rfl\n\n/-- An equalizer of `f` and `g` is a kernel of `f - g`. -/\ndef is_limit_kernel_fork_of_fork {c : fork f g} (i : is_limit c) :\n  is_limit (kernel_fork_of_fork c) :=\nfork.is_limit.mk' _ $ λ s,\n  ⟨i.lift (fork_of_kernel_fork s), i.fac _ _,\n    λ m h, by apply fork.is_limit.hom_ext i; tidy⟩\n\nvariables (f g)\n\n/-- A preadditive category has an equalizer for `f` and `g` if it has a kernel for `f - g`. -/\nlemma has_equalizer_of_has_kernel [has_kernel (f - g)] : has_equalizer f g :=\nhas_limit.mk { cone := fork_of_kernel_fork _,\n  is_limit := is_limit_fork_of_kernel_fork (equalizer_is_equalizer (f - g) 0) }\n\n/-- A preadditive category has a kernel for `f - g` if it has an equalizer for `f` and `g`. -/\nlemma has_kernel_of_has_equalizer [has_equalizer f g] : has_kernel (f - g) :=\nhas_limit.mk { cone := kernel_fork_of_fork (equalizer.fork f g),\n  is_limit := is_limit_kernel_fork_of_fork (limit.is_limit (parallel_pair f g)) }\n\nvariables {f g}\n\n/-- Map a cokernel cocone on the difference of two morphisms to the coequalizer cofork. -/\ndef cofork_of_cokernel_cofork (c : cokernel_cofork (f - g)) : cofork f g :=\ncofork.of_π c.π $ by rw [← sub_eq_zero, ← sub_comp, c.condition]\n\n/-- Map any coequalizer cofork to a cocone on the difference of the two morphisms. -/\ndef cokernel_cofork_of_cofork (c : cofork f g) : cokernel_cofork (f - g) :=\ncofork.of_π c.π $ by rw [sub_comp, zero_comp, sub_eq_zero, c.condition]\n\n@[simp] lemma cokernel_cofork_of_cofork_π (c : cofork f g) :\n  (cokernel_cofork_of_cofork c).π = c.π := rfl\n\n@[simp] lemma cokernel_cofork_of_cofork_of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) :\n  (cokernel_cofork_of_cofork (cofork.of_π π w)) = cokernel_cofork.of_π π (by simp [w]) := rfl\n\n/-- A cokernel of `f - g` is a coequalizer of `f` and `g`. -/\ndef is_colimit_cofork_of_cokernel_cofork {c : cokernel_cofork (f - g)} (i : is_colimit c) :\n  is_colimit (cofork_of_cokernel_cofork c) :=\ncofork.is_colimit.mk' _ $ λ s,\n  ⟨i.desc (cokernel_cofork_of_cofork s), i.fac _ _,\n    λ m h, by apply cofork.is_colimit.hom_ext i; tidy⟩\n\n@[simp]\nlemma is_colimit_cofork_of_cokernel_cofork_desc {c : cokernel_cofork (f - g)}\n  (i : is_colimit c) (s : cofork f g) :\n  (is_colimit_cofork_of_cokernel_cofork i).desc s = i.desc (cokernel_cofork_of_cofork s) := rfl\n\n/-- A coequalizer of `f` and `g` is a cokernel of `f - g`. -/\ndef is_colimit_cokernel_cofork_of_cofork {c : cofork f g} (i : is_colimit c) :\n  is_colimit (cokernel_cofork_of_cofork c) :=\ncofork.is_colimit.mk' _ $ λ s,\n  ⟨i.desc (cofork_of_cokernel_cofork s), i.fac _ _,\n    λ m h, by apply cofork.is_colimit.hom_ext i; tidy⟩\n\nvariables (f g)\n\n/-- A preadditive category has a coequalizer for `f` and `g` if it has a cokernel for `f - g`. -/\nlemma has_coequalizer_of_has_cokernel [has_cokernel (f - g)] : has_coequalizer f g :=\nhas_colimit.mk { cocone := cofork_of_cokernel_cofork _,\n  is_colimit := is_colimit_cofork_of_cokernel_cofork (coequalizer_is_coequalizer (f - g) 0) }\n\n/-- A preadditive category has a cokernel for `f - g` if it has a coequalizer for `f` and `g`. -/\nlemma has_cokernel_of_has_coequalizer [has_coequalizer f g] : has_cokernel (f - g) :=\nhas_colimit.mk { cocone := cokernel_cofork_of_cofork (coequalizer.cofork f g),\n  is_colimit := is_colimit_cokernel_cofork_of_cofork (colimit.is_colimit (parallel_pair f g)) }\n\nend\n\n/-- If a preadditive category has all kernels, then it also has all equalizers. -/\nlemma has_equalizers_of_has_kernels [has_kernels C] : has_equalizers C :=\n@has_equalizers_of_has_limit_parallel_pair _ _ (λ _ _ f g, has_equalizer_of_has_kernel f g)\n\n\n/-- If a preadditive category has all cokernels, then it also has all coequalizers. -/\nlemma has_coequalizers_of_has_cokernels [has_cokernels C] : has_coequalizers C :=\n@has_coequalizers_of_has_colimit_parallel_pair _ _ (λ _ _ f g, has_coequalizer_of_has_cokernel f g)\n\nend equalizers\n\nend preadditive\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/preadditive/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.49458341627448027}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.encodable.basic\nimport Mathlib.algebra.euclidean_domain\nimport Mathlib.data.nat.gcd\nimport Mathlib.data.int.cast\nimport Mathlib.PostPort\n\nuniverses l u \n\nnamespace Mathlib\n\n/-!\n# Basics for the Rational Numbers\n\n## Summary\n\nWe define a rational number `q` as a structure `{ num, denom, pos, cop }`, where\n- `num` is the numerator of `q`,\n- `denom` is the denominator of `q`,\n- `pos` is a proof that `denom > 0`, and\n- `cop` is a proof `num` and `denom` are coprime.\n\nWe then define the expected (discrete) field structure on `ℚ` and prove basic lemmas about it.\nMoreoever, we provide the expected casts from `ℕ` and `ℤ` into `ℚ`, i.e. `(↑n : ℚ) = n / 1`.\n\n## Main Definitions\n\n- `rat` is the structure encoding `ℚ`.\n- `rat.mk n d` constructs a rational number `q = n / d` from `n d : ℤ`.\n\n## Notations\n\n- `/.` is infix notation for `rat.mk`.\n\n## Tags\n\nrat, rationals, field, ℚ, numerator, denominator, num, denom\n-/\n\n/-- `rat`, or `ℚ`, is the type of rational numbers. It is defined\n  as the set of pairs ⟨n, d⟩ of integers such that `d` is positive and `n` and\n  `d` are coprime. This representation is preferred to the quotient\n  because without periodic reduction, the numerator and denominator can grow\n  exponentially (for example, adding 1/2 to itself repeatedly). -/\nstructure rat where\n  mk' :: (num : ℤ) (denom : ℕ) (pos : 0 < denom) (cop : nat.coprime (int.nat_abs num) denom)\n\nnotation:1024 \"ℚ\" => Mathlib.rat\n\nnamespace rat\n\n\nprotected def repr : ℚ → string := sorry\n\nprotected instance has_repr : has_repr ℚ := has_repr.mk rat.repr\n\nprotected instance has_to_string : has_to_string ℚ := has_to_string.mk rat.repr\n\nprotected instance encodable : encodable ℚ :=\n  encodable.of_equiv\n    (sigma fun (n : ℤ) => Subtype fun (d : ℕ) => 0 < d ∧ nat.coprime (int.nat_abs n) d)\n    (equiv.mk (fun (_x : ℚ) => sorry)\n      (fun\n        (_x : sigma fun (n : ℤ) => Subtype fun (d : ℕ) => 0 < d ∧ nat.coprime (int.nat_abs n) d) =>\n        sorry)\n      sorry sorry)\n\n/-- Embed an integer as a rational number -/\ndef of_int (n : ℤ) : ℚ := mk' n 1 nat.one_pos sorry\n\nprotected instance has_zero : HasZero ℚ := { zero := of_int 0 }\n\nprotected instance has_one : HasOne ℚ := { one := of_int 1 }\n\nprotected instance inhabited : Inhabited ℚ := { default := 0 }\n\n/-- Form the quotient `n / d` where `n:ℤ` and `d:ℕ+` (not necessarily coprime) -/\ndef mk_pnat (n : ℤ) : ℕ+ → ℚ := sorry\n\n/-- Form the quotient `n / d` where `n:ℤ` and `d:ℕ`. In the case `d = 0`, we\n  define `n / 0 = 0` by convention. -/\ndef mk_nat (n : ℤ) (d : ℕ) : ℚ :=\n  dite (d = 0) (fun (d0 : d = 0) => 0)\n    fun (d0 : ¬d = 0) => mk_pnat n { val := d, property := nat.pos_of_ne_zero d0 }\n\n/-- Form the quotient `n / d` where `n d : ℤ`. -/\ndef mk : ℤ → ℤ → ℚ := sorry\n\ntheorem mk_pnat_eq (n : ℤ) (d : ℕ) (h : 0 < d) : mk_pnat n { val := d, property := h } = mk n ↑d :=\n  sorry\n\ntheorem mk_nat_eq (n : ℤ) (d : ℕ) : mk_nat n d = mk n ↑d := rfl\n\n@[simp] theorem mk_zero (n : ℤ) : mk n 0 = 0 := rfl\n\n@[simp] theorem zero_mk_pnat (n : ℕ+) : mk_pnat 0 n = 0 := sorry\n\n@[simp] theorem zero_mk_nat (n : ℕ) : mk_nat 0 n = 0 := sorry\n\n@[simp] theorem zero_mk (n : ℤ) : mk 0 n = 0 := sorry\n\n@[simp] theorem mk_eq_zero {a : ℤ} {b : ℤ} (b0 : b ≠ 0) : mk a b = 0 ↔ a = 0 := sorry\n\ntheorem mk_eq {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (hb : b ≠ 0) (hd : d ≠ 0) :\n    mk a b = mk c d ↔ a * d = c * b :=\n  sorry\n\n@[simp] theorem div_mk_div_cancel_left {a : ℤ} {b : ℤ} {c : ℤ} (c0 : c ≠ 0) :\n    mk (a * c) (b * c) = mk a b :=\n  sorry\n\n@[simp] theorem num_denom {a : ℚ} : mk (num a) ↑(denom a) = a := sorry\n\ntheorem num_denom' {n : ℤ} {d : ℕ} {h : 0 < d} {c : nat.coprime (int.nat_abs n) d} :\n    mk' n d h c = mk n ↑d :=\n  Eq.symm num_denom\n\ntheorem of_int_eq_mk (z : ℤ) : of_int z = mk z 1 := num_denom'\n\ndef num_denom_cases_on {C : ℚ → Sort u} (a : ℚ)\n    (H : (n : ℤ) → (d : ℕ) → 0 < d → nat.coprime (int.nat_abs n) d → C (mk n ↑d)) : C a :=\n  sorry\n\ndef num_denom_cases_on' {C : ℚ → Sort u} (a : ℚ) (H : (n : ℤ) → (d : ℕ) → d ≠ 0 → C (mk n ↑d)) :\n    C a :=\n  num_denom_cases_on a\n    fun (n : ℤ) (d : ℕ) (h : 0 < d) (c : nat.coprime (int.nat_abs n) d) => H n d sorry\n\ntheorem num_dvd (a : ℤ) {b : ℤ} (b0 : b ≠ 0) : num (mk a b) ∣ a := sorry\n\ntheorem denom_dvd (a : ℤ) (b : ℤ) : ↑(denom (mk a b)) ∣ b := sorry\n\nprotected def add : ℚ → ℚ → ℚ := sorry\n\nprotected instance has_add : Add ℚ := { add := rat.add }\n\ntheorem lift_binop_eq (f : ℚ → ℚ → ℚ) (f₁ : ℤ → ℤ → ℤ → ℤ → ℤ) (f₂ : ℤ → ℤ → ℤ → ℤ → ℤ)\n    (fv :\n      ∀ {n₁ : ℤ} {d₁ : ℕ} {h₁ : 0 < d₁} {c₁ : nat.coprime (int.nat_abs n₁) d₁} {n₂ : ℤ} {d₂ : ℕ}\n        {h₂ : 0 < d₂} {c₂ : nat.coprime (int.nat_abs n₂) d₂},\n        f (mk' n₁ d₁ h₁ c₁) (mk' n₂ d₂ h₂ c₂) = mk (f₁ n₁ (↑d₁) n₂ ↑d₂) (f₂ n₁ (↑d₁) n₂ ↑d₂))\n    (f0 : ∀ {n₁ d₁ n₂ d₂ : ℤ}, d₁ ≠ 0 → d₂ ≠ 0 → f₂ n₁ d₁ n₂ d₂ ≠ 0) (a : ℤ) (b : ℤ) (c : ℤ) (d : ℤ)\n    (b0 : b ≠ 0) (d0 : d ≠ 0)\n    (H :\n      ∀ {n₁ d₁ n₂ d₂ : ℤ},\n        a * d₁ = n₁ * b →\n          c * d₂ = n₂ * d → f₁ n₁ d₁ n₂ d₂ * f₂ a b c d = f₁ a b c d * f₂ n₁ d₁ n₂ d₂) :\n    f (mk a b) (mk c d) = mk (f₁ a b c d) (f₂ a b c d) :=\n  sorry\n\n@[simp] theorem add_def {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n    mk a b + mk c d = mk (a * d + c * b) (b * d) :=\n  sorry\n\nprotected def neg : ℚ → ℚ := sorry\n\nprotected instance has_neg : Neg ℚ := { neg := rat.neg }\n\n@[simp] theorem neg_def {a : ℤ} {b : ℤ} : -mk a b = mk (-a) b := sorry\n\nprotected def mul : ℚ → ℚ → ℚ := sorry\n\nprotected instance has_mul : Mul ℚ := { mul := rat.mul }\n\n@[simp] theorem mul_def {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n    mk a b * mk c d = mk (a * c) (b * d) :=\n  sorry\n\nprotected def inv : ℚ → ℚ := sorry\n\nprotected instance has_inv : has_inv ℚ := has_inv.mk rat.inv\n\n@[simp] theorem inv_def {a : ℤ} {b : ℤ} : mk a b⁻¹ = mk b a := sorry\n\nprotected theorem add_zero (a : ℚ) : a + 0 = a := sorry\n\nprotected theorem zero_add (a : ℚ) : 0 + a = a := sorry\n\nprotected theorem add_comm (a : ℚ) (b : ℚ) : a + b = b + a := sorry\n\nprotected theorem add_assoc (a : ℚ) (b : ℚ) (c : ℚ) : a + b + c = a + (b + c) := sorry\n\nprotected theorem add_left_neg (a : ℚ) : -a + a = 0 := sorry\n\nprotected theorem mul_one (a : ℚ) : a * 1 = a := sorry\n\nprotected theorem one_mul (a : ℚ) : 1 * a = a := sorry\n\nprotected theorem mul_comm (a : ℚ) (b : ℚ) : a * b = b * a := sorry\n\nprotected theorem mul_assoc (a : ℚ) (b : ℚ) (c : ℚ) : a * b * c = a * (b * c) := sorry\n\nprotected theorem add_mul (a : ℚ) (b : ℚ) (c : ℚ) : (a + b) * c = a * c + b * c := sorry\n\nprotected theorem mul_add (a : ℚ) (b : ℚ) (c : ℚ) : a * (b + c) = a * b + a * c := sorry\n\nprotected theorem zero_ne_one : 0 ≠ 1 :=\n  mt (fun (h : 0 = mk 1 1) => iff.mp (mk_eq_zero one_ne_zero) (Eq.symm h)) one_ne_zero\n\nprotected theorem mul_inv_cancel (a : ℚ) : a ≠ 0 → a * (a⁻¹) = 1 := sorry\n\nprotected theorem inv_mul_cancel (a : ℚ) (h : a ≠ 0) : a⁻¹ * a = 1 :=\n  Eq.trans (rat.mul_comm (a⁻¹) a) (rat.mul_inv_cancel a h)\n\nprotected instance decidable_eq : DecidableEq ℚ :=\n  id\n    fun (_v : ℚ) =>\n      cases_on _v\n        fun (num : ℤ) (denom : ℕ) (pos : 0 < denom) (cop : nat.coprime (int.nat_abs num) denom)\n          (w : ℚ) =>\n          cases_on w\n            fun (w_num : ℤ) (w_denom : ℕ) (w_pos : 0 < w_denom)\n              (w_cop : nat.coprime (int.nat_abs w_num) w_denom) =>\n              decidable.by_cases\n                (fun (ᾰ : num = w_num) =>\n                  Eq._oldrec\n                    (fun (w_cop : nat.coprime (int.nat_abs num) w_denom) =>\n                      decidable.by_cases\n                        (fun (ᾰ : denom = w_denom) =>\n                          Eq._oldrec\n                            (fun (w_pos : 0 < denom)\n                              (w_cop : nat.coprime (int.nat_abs num) denom) => is_true sorry)\n                            ᾰ w_pos w_cop)\n                        fun (ᾰ : ¬denom = w_denom) => isFalse sorry)\n                    ᾰ w_cop)\n                fun (ᾰ : ¬num = w_num) => isFalse sorry\n\nprotected instance field : field ℚ :=\n  field.mk rat.add rat.add_assoc 0 rat.zero_add rat.add_zero rat.neg\n    (comm_ring.sub._default rat.add rat.add_assoc 0 rat.zero_add rat.add_zero rat.neg)\n    rat.add_left_neg rat.add_comm rat.mul rat.mul_assoc 1 rat.one_mul rat.mul_one rat.mul_add\n    rat.add_mul rat.mul_comm rat.inv sorry rat.mul_inv_cancel sorry\n\n/- Extra instances to short-circuit type class resolution -/\n\nprotected instance division_ring : division_ring ℚ := field.to_division_ring\n\n-- TODO(Mario): this instance slows down data.real.basic\n\nprotected instance integral_domain : integral_domain ℚ := field.to_integral_domain\n\n--instance : domain ℚ           := by apply_instance\n\nprotected instance nontrivial : nontrivial ℚ := euclidean_domain.to_nontrivial ℚ\n\n--instance : ring ℚ             := by apply_instance\n\nprotected instance comm_ring : comm_ring ℚ := euclidean_domain.to_comm_ring ℚ\n\nprotected instance comm_semiring : comm_semiring ℚ := comm_ring.to_comm_semiring\n\nprotected instance semiring : semiring ℚ := ring.to_semiring\n\nprotected instance add_comm_group : add_comm_group ℚ := ring.to_add_comm_group ℚ\n\nprotected instance add_group : add_group ℚ := add_comm_group.to_add_group ℚ\n\nprotected instance add_comm_monoid : add_comm_monoid ℚ := add_comm_group.to_add_comm_monoid ℚ\n\nprotected instance add_monoid : add_monoid ℚ := sub_neg_monoid.to_add_monoid ℚ\n\nprotected instance add_left_cancel_semigroup : add_left_cancel_semigroup ℚ :=\n  add_left_cancel_monoid.to_add_left_cancel_semigroup ℚ\n\nprotected instance add_right_cancel_semigroup : add_right_cancel_semigroup ℚ :=\n  add_right_cancel_monoid.to_add_right_cancel_semigroup ℚ\n\nprotected instance add_comm_semigroup : add_comm_semigroup ℚ :=\n  add_comm_monoid.to_add_comm_semigroup ℚ\n\nprotected instance add_semigroup : add_semigroup ℚ := add_monoid.to_add_semigroup ℚ\n\nprotected instance comm_monoid : comm_monoid ℚ := comm_semiring.to_comm_monoid ℚ\n\nprotected instance monoid : monoid ℚ := ring.to_monoid ℚ\n\nprotected instance comm_semigroup : comm_semigroup ℚ := comm_ring.to_comm_semigroup ℚ\n\nprotected instance semigroup : semigroup ℚ := monoid.to_semigroup ℚ\n\ntheorem sub_def {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n    mk a b - mk c d = mk (a * d - c * b) (b * d) :=\n  sorry\n\n@[simp] theorem denom_neg_eq_denom (q : ℚ) : denom (-q) = denom q :=\n  cases_on q\n    fun (q_num : ℤ) (q_denom : ℕ) (q_pos : 0 < q_denom)\n      (q_cop : nat.coprime (int.nat_abs q_num) q_denom) =>\n      idRhs (denom (-mk' q_num q_denom q_pos q_cop) = denom (-mk' q_num q_denom q_pos q_cop)) rfl\n\n@[simp] theorem num_neg_eq_neg_num (q : ℚ) : num (-q) = -num q :=\n  cases_on q\n    fun (q_num : ℤ) (q_denom : ℕ) (q_pos : 0 < q_denom)\n      (q_cop : nat.coprime (int.nat_abs q_num) q_denom) =>\n      idRhs (num (-mk' q_num q_denom q_pos q_cop) = num (-mk' q_num q_denom q_pos q_cop)) rfl\n\n@[simp] theorem num_zero : num 0 = 0 := rfl\n\ntheorem zero_of_num_zero {q : ℚ} (hq : num q = 0) : q = 0 := sorry\n\ntheorem zero_iff_num_zero {q : ℚ} : q = 0 ↔ num q = 0 := sorry\n\ntheorem num_ne_zero_of_ne_zero {q : ℚ} (h : q ≠ 0) : num q ≠ 0 :=\n  fun (this : num q = 0) => h (zero_of_num_zero this)\n\n@[simp] theorem num_one : num 1 = 1 := rfl\n\n@[simp] theorem denom_one : denom 1 = 1 := rfl\n\ntheorem denom_ne_zero (q : ℚ) : denom q ≠ 0 := ne_of_gt (pos q)\n\ntheorem eq_iff_mul_eq_mul {p : ℚ} {q : ℚ} : p = q ↔ num p * ↑(denom q) = num q * ↑(denom p) := sorry\n\ntheorem mk_num_ne_zero_of_ne_zero {q : ℚ} {n : ℤ} {d : ℤ} (hq : q ≠ 0) (hqnd : q = mk n d) :\n    n ≠ 0 :=\n  sorry\n\ntheorem mk_denom_ne_zero_of_ne_zero {q : ℚ} {n : ℤ} {d : ℤ} (hq : q ≠ 0) (hqnd : q = mk n d) :\n    d ≠ 0 :=\n  sorry\n\ntheorem mk_ne_zero_of_ne_zero {n : ℤ} {d : ℤ} (h : n ≠ 0) (hd : d ≠ 0) : mk n d ≠ 0 :=\n  fun (this : mk n d = 0) => h (iff.mp (mk_eq_zero hd) this)\n\ntheorem mul_num_denom (q : ℚ) (r : ℚ) : q * r = mk (num q * num r) ↑(denom q * denom r) := sorry\n\ntheorem div_num_denom (q : ℚ) (r : ℚ) : q / r = mk (num q * ↑(denom r)) (↑(denom q) * num r) :=\n  sorry\n\ntheorem num_denom_mk {q : ℚ} {n : ℤ} {d : ℤ} (hn : n ≠ 0) (hd : d ≠ 0) (qdf : q = mk n d) :\n    ∃ (c : ℤ), n = c * num q ∧ d = c * ↑(denom q) :=\n  sorry\n\ntheorem mk_pnat_num (n : ℤ) (d : ℕ+) : num (mk_pnat n d) = n / ↑(nat.gcd (int.nat_abs n) ↑d) :=\n  subtype.cases_on d\n    fun (d_val : ℕ) (d_property : 0 < d_val) =>\n      Eq.refl (num (mk_pnat n { val := d_val, property := d_property }))\n\ntheorem mk_pnat_denom (n : ℤ) (d : ℕ+) : denom (mk_pnat n d) = ↑d / nat.gcd (int.nat_abs n) ↑d :=\n  subtype.cases_on d\n    fun (d_val : ℕ) (d_property : 0 < d_val) =>\n      Eq.refl (denom (mk_pnat n { val := d_val, property := d_property }))\n\ntheorem mul_num (q₁ : ℚ) (q₂ : ℚ) :\n    num (q₁ * q₂) =\n        num q₁ * num q₂ / ↑(nat.gcd (int.nat_abs (num q₁ * num q₂)) (denom q₁ * denom q₂)) :=\n  sorry\n\ntheorem mul_denom (q₁ : ℚ) (q₂ : ℚ) :\n    denom (q₁ * q₂) =\n        denom q₁ * denom q₂ / nat.gcd (int.nat_abs (num q₁ * num q₂)) (denom q₁ * denom q₂) :=\n  sorry\n\ntheorem mul_self_num (q : ℚ) : num (q * q) = num q * num q := sorry\n\ntheorem mul_self_denom (q : ℚ) : denom (q * q) = denom q * denom q := sorry\n\ntheorem add_num_denom (q : ℚ) (r : ℚ) :\n    q + r = mk (num q * ↑(denom r) + ↑(denom q) * num r) (↑(denom q) * ↑(denom r)) :=\n  sorry\n\ntheorem coe_int_eq_mk (z : ℤ) : ↑z = mk z 1 := sorry\n\ntheorem mk_eq_div (n : ℤ) (d : ℤ) : mk n d = ↑n / ↑d := sorry\n\ntheorem exists_eq_mul_div_num_and_eq_mul_div_denom {n : ℤ} {d : ℤ} (n_ne_zero : n ≠ 0)\n    (d_ne_zero : d ≠ 0) : ∃ (c : ℤ), n = c * num (↑n / ↑d) ∧ d = c * ↑(denom (↑n / ↑d)) :=\n  num_denom_mk n_ne_zero d_ne_zero\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑n / ↑d = mk n d)) (Eq.symm (mk_eq_div n d))))\n      (Eq.refl (mk n d)))\n\ntheorem coe_int_eq_of_int (z : ℤ) : ↑z = of_int z :=\n  Eq.trans (coe_int_eq_mk z) (Eq.symm (of_int_eq_mk z))\n\n@[simp] theorem coe_int_num (n : ℤ) : num ↑n = n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (num ↑n = n)) (coe_int_eq_of_int n))) (Eq.refl (num (of_int n)))\n\n@[simp] theorem coe_int_denom (n : ℤ) : denom ↑n = 1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (denom ↑n = 1)) (coe_int_eq_of_int n)))\n    (Eq.refl (denom (of_int n)))\n\ntheorem coe_int_num_of_denom_eq_one {q : ℚ} (hq : denom q = 1) : ↑(num q) = q := sorry\n\ntheorem denom_eq_one_iff (r : ℚ) : denom r = 1 ↔ ↑(num r) = r :=\n  { mp := coe_int_num_of_denom_eq_one, mpr := fun (h : ↑(num r) = r) => h ▸ coe_int_denom (num r) }\n\nprotected instance int.can_lift : can_lift ℚ ℤ := can_lift.mk coe (fun (q : ℚ) => denom q = 1) sorry\n\ntheorem coe_nat_eq_mk (n : ℕ) : ↑n = mk (↑n) 1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (↑n = mk (↑n) 1)) (Eq.symm (int.cast_coe_nat n))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑↑n = mk (↑n) 1)) (coe_int_eq_mk ↑n))) (Eq.refl (mk (↑n) 1)))\n\n@[simp] theorem coe_nat_num (n : ℕ) : num ↑n = ↑n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (num ↑n = ↑n)) (Eq.symm (int.cast_coe_nat n))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (num ↑↑n = ↑n)) (coe_int_num ↑n))) (Eq.refl ↑n))\n\n@[simp] theorem coe_nat_denom (n : ℕ) : denom ↑n = 1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (denom ↑n = 1)) (Eq.symm (int.cast_coe_nat n))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (denom ↑↑n = 1)) (coe_int_denom ↑n))) (Eq.refl 1))\n\n-- Will be subsumed by `int.coe_inj` after we have defined\n\n-- `linear_ordered_field ℚ` (which implies characteristic zero).\n\ntheorem coe_int_inj (m : ℤ) (n : ℤ) : ↑m = ↑n ↔ m = n := sorry\n\ntheorem inv_def' {q : ℚ} : q⁻¹ = ↑(denom q) / ↑(num q) := sorry\n\n@[simp] theorem mul_denom_eq_num {q : ℚ} : q * ↑(denom q) = ↑(num q) := sorry\n\ntheorem denom_div_cast_eq_one_iff (m : ℤ) (n : ℤ) (hn : n ≠ 0) : denom (↑m / ↑n) = 1 ↔ n ∣ m :=\n  sorry\n\ntheorem num_div_eq_of_coprime {a : ℤ} {b : ℤ} (hb0 : 0 < b)\n    (h : nat.coprime (int.nat_abs a) (int.nat_abs b)) : num (↑a / ↑b) = a :=\n  sorry\n\ntheorem denom_div_eq_of_coprime {a : ℤ} {b : ℤ} (hb0 : 0 < b)\n    (h : nat.coprime (int.nat_abs a) (int.nat_abs b)) : ↑(denom (↑a / ↑b)) = b :=\n  sorry\n\ntheorem div_int_inj {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (hb0 : 0 < b) (hd0 : 0 < d)\n    (h1 : nat.coprime (int.nat_abs a) (int.nat_abs b))\n    (h2 : nat.coprime (int.nat_abs c) (int.nat_abs d)) (h : ↑a / ↑b = ↑c / ↑d) : a = c ∧ b = d :=\n  sorry\n\ntheorem coe_int_div_self (n : ℤ) : ↑(n / n) = ↑n / ↑n := sorry\n\ntheorem coe_nat_div_self (n : ℕ) : ↑(n / n) = ↑n / ↑n := coe_int_div_self ↑n\n\ntheorem coe_int_div (a : ℤ) (b : ℤ) (h : b ∣ a) : ↑(a / b) = ↑a / ↑b := sorry\n\ntheorem coe_nat_div (a : ℕ) (b : ℕ) (h : b ∣ a) : ↑(a / b) = ↑a / ↑b := sorry\n\nprotected theorem forall {p : ℚ → Prop} : (∀ (r : ℚ), p r) ↔ ∀ (a b : ℤ), p (↑a / ↑b) := sorry\n\nprotected theorem exists {p : ℚ → Prop} : (∃ (r : ℚ), p r) ↔ ∃ (a : ℤ), ∃ (b : ℤ), p (↑a / ↑b) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/rat/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.49458341108311926}}
{"text": "import hacks_and_tricks.by_exactI_hack\nimport system_of_complexes.basic\nimport facts\n\nuniverse variables v u\nnoncomputable theory\nopen opposite category_theory\nopen_locale nnreal\n\n/-!\n\n# Systems of double complexes of seminormed groups\n\nIn this file we define systems of double complexes of seminormed groups,\nas needed for Definition 9.6 of [Analytic].\n\n## Main declarations\n\n* `system_of_double_complexes`: a system of complexes of seminormed groups.\n* `admissible`: such a system is *admissible* if all maps that occur in the system\n    are norm-nonincreasing.\n\n-/\n\n/-- A system of double complexes of seminormed groups, indexed by `ℝ≥0`.\nSee also Definition 9.3 of [Analytic]. -/\n@[derive category_theory.category]\ndef system_of_double_complexes : Type (u+1) :=\nℝ≥0ᵒᵖ ⥤ (cochain_complex (cochain_complex SemiNormedGroup.{u} ℕ) ℕ)\n\nnamespace system_of_double_complexes\n\nvariables (C : system_of_double_complexes)\n\n/-- `C.X c p q` is the object $C_c^{p,q}$ in a system of double complexes `C`. -/\ndef X (c : ℝ≥0) (p q : ℕ) : SemiNormedGroup :=\n((C.obj $ op c).X p).X q\n\n/-- `C.res` is the restriction map `C.X c' p q ⟶ C.X c p q` for a system of complexes `C`,\nand nonnegative reals `c ≤ c'`. -/\ndef res {c' c : ℝ≥0} {p q : ℕ} [h : fact (c ≤ c')] :\n  C.X c' p q ⟶ C.X c p q :=\n((C.map (hom_of_le h.out).op).f p).f q\n\nvariables (c : ℝ≥0) {c₁ c₂ c₃ : ℝ≥0} (p p' q q' : ℕ)\n\n@[simp] lemma res_refl : @res C c c p q _ = 𝟙 _ :=\nbegin\n  have := (category_theory.functor.map_id C (op $ c)),\n  delta res, erw this, refl\nend\n\n@[simp] lemma norm_res_of_eq (h : c₂ = c₁) (x : C.X c₁ p q) : ∥@res C _ _ p q ⟨h.le⟩ x∥ = ∥x∥ :=\nby { cases h, rw res_refl, refl }\n\n@[simp] lemma res_comp_res (h₁ : fact (c₂ ≤ c₁)) (h₂ : fact (c₃ ≤ c₂)) :\n  @res C _ _ p q h₁ ≫ @res C _ _ p q h₂  = @res C _ _ p q ⟨h₂.out.trans h₁.out⟩ :=\nbegin\n  have := (category_theory.functor.map_comp C (hom_of_le h₁.out).op (hom_of_le h₂.out).op),\n  rw [← op_comp] at this,\n  delta res, erw this, refl,\nend\n\n@[simp] lemma res_res (h₁ : fact (c₂ ≤ c₁)) (h₂ : fact (c₃ ≤ c₂)) (x : C.X c₁ p q) :\n  @res C _ _ p q h₂ (@res C _ _ p q h₁ x) = @res C _ _ p q ⟨h₂.out.trans h₁.out⟩ x :=\nby { rw ← (C.res_comp_res p q h₁ h₂), refl }\n\n/-- `C.d` is the differential `C.X c p q ⟶ C.X c (p+1) q` for a system of double complexes `C`. -/\ndef d {c : ℝ≥0} (p p' : ℕ) {q : ℕ} : C.X c p q ⟶ C.X c p' q :=\n((C.obj $ op c).d p p').f q\n\nlemma d_eq_zero (c : ℝ≥0) (h : p + 1 ≠ p') : (C.d p p' : C.X c p q ⟶ _) = 0 :=\nby { have : (C.obj (op c)).d p p' = 0 := (C.obj $ op c).shape _ _ h, rw [d, this], refl }\n\nlemma d_eq_zero_apply (c : ℝ≥0) (h : p + 1 ≠ p') (x : C.X c p q) : (C.d p p' x) = 0 :=\nby { rw [d_eq_zero C p p' q c h], refl }\n\n@[simp] lemma d_self_apply (c : ℝ≥0) (x : C.X c p q) : (C.d p p x) = 0 :=\nd_eq_zero_apply _ _ _ _ _ p.succ_ne_self _\n\nlemma d_comp_res (h : fact (c₂ ≤ c₁)) :\n  C.d p p' ≫ @res C _ _ _ q h = @res C _ _ p q _ ≫ C.d p p' :=\ncongr_fun (congr_arg homological_complex.hom.f ((C.map (hom_of_le h.out).op).comm p p')).symm q\n\nlemma d_res (h : fact (c₂ ≤ c₁)) (x) :\n  @d C c₂ p p' q (@res C _ _ p q _ x) = @res C _ _ _ _ h (@d C c₁ p p' q x) :=\nshow (@res C _ _ p q _ ≫ C.d p p') x = (C.d p p' ≫ @res C _ _ _ _ h) x,\nby rw d_comp_res\n\n@[simp] lemma d_comp_d {c : ℝ≥0} {p p' p'' q : ℕ} :\n  @d C c p p' q ≫ C.d p' p'' = 0 :=\ncongr_fun (congr_arg homological_complex.hom.f ((C.obj $ op c).d_comp_d p p' p'')) q\n\n@[simp] lemma d_d {c : ℝ≥0} {p p' p'' q : ℕ} (x : C.X c p q) :\n  C.d p' p'' (C.d p p' x) = 0 :=\nshow (C.d _ _ ≫ C.d _ _) x = 0, by { rw d_comp_d, refl }\n\n/-- `C.d'` is the differential `C.X c p q ⟶ C.X c p (q+1)` for a system of double complexes `C`. -/\ndef d' {c : ℝ≥0} {p : ℕ} (q q' : ℕ) : C.X c p q ⟶ C.X c p q' :=\n((C.obj $ op c).X p).d q q'\n\nlemma d'_eq_zero (c : ℝ≥0) (h : q + 1 ≠ q') : (C.d' q q' : C.X c p q ⟶ _) = 0 :=\n((C.obj $ op c).X p).shape _ _ h\n\nlemma d'_eq_zero_apply (c : ℝ≥0) (h : q + 1 ≠ q') (x : C.X c p q) : (C.d' q q' x) = 0 :=\nby { rw [d'_eq_zero C p q q' c h], refl }\n\n@[simp] lemma d'_self_apply (c : ℝ≥0) (x : C.X c p q) : (C.d' q q x) = 0 :=\nd'_eq_zero_apply _ _ _ _ _ q.succ_ne_self _\n\nlemma d'_comp_res (h : fact (c₂ ≤ c₁)) :\n  @d' C c₁ p q q' ≫ @res C _ _ _ _ h = @res C _ _ p q _ ≫ @d' C c₂ p q q' :=\n(((C.map (hom_of_le h.out).op).f p).comm q q').symm\n\nlemma d'_res (h : fact (c₂ ≤ c₁)) (x) :\n  C.d' q q' (@res C _ _ p q _ x) = @res C _ _ _ _ h (C.d' q q' x) :=\nshow (@res C _ _ p q _ ≫ C.d' q q') x = (C.d' q q' ≫ @res C _ _ _ _ h) x,\nby rw d'_comp_res\n\n@[simp] lemma d'_comp_d' {c : ℝ≥0} {p q q' q'' : ℕ} :\n  @d' C c p q q' ≫ C.d' q' q'' = 0 :=\n((C.obj $ op c).X p).d_comp_d q q' q''\n\n@[simp] lemma d'_d' {c : ℝ≥0} {p q q' q'' : ℕ} (x : C.X c p q) :\n  C.d' q' q'' (C.d' q q' x) = 0 :=\nshow (C.d' _ _ ≫ C.d' _ _) x = 0, by { rw d'_comp_d', refl }\n\nlemma d'_comp_d (c : ℝ≥0) (p p' q q' : ℕ) :\n  C.d' q q' ≫ C.d p p' = C.d p p' ≫ (C.d' q q' : C.X c p' q ⟶ _) :=\n(((C.obj $ op c).d p p').comm q q').symm\n\nlemma d'_d (c : ℝ≥0) (p p' q q' : ℕ) (x : C.X c p q) :\n  C.d' q q' (C.d p p' x) = C.d p p' (C.d' q q' x) :=\nshow (C.d p p' ≫ C.d' q q') x = (C.d' q q' ≫ C.d p p') x,\nby rw [d'_comp_d]\n\n/-- Convenience definition:\nThe identity morphism of an object in the system of double complexes\nwhen it is given by different indices that are not\ndefinitionally equal. -/\ndef congr {c c' : ℝ≥0} {p p' q q' : ℕ} (hc : c = c') (hp : p = p') (hq : q = q') :\n  C.X c p q ⟶ C.X c' p' q' :=\neq_to_hom $ by { subst hc, subst hp, subst hq, }\n\n/-- The `p`-th row in a system of double complexes, as system of complexes.\n  It has object `(C.obj c).X p`over `c`. -/\ndef row (C : system_of_double_complexes.{u}) (p : ℕ) : system_of_complexes.{u} :=\nC ⋙ homological_complex.forget _ _ ⋙ pi.eval _ p\n\n@[simp] lemma row_X (C : system_of_double_complexes) (p q : ℕ) (c : ℝ≥0) :\n  C.row p c q = C.X c p q :=\nrfl\n\n@[simp] lemma row_res (C : system_of_double_complexes) (p q : ℕ) {c' c : ℝ≥0} [h : fact (c ≤ c')] :\n  @system_of_complexes.res (C.row p) _ _ q h  = @res C _ _ p q h :=\nrfl\n\n@[simp] lemma row_d (C : system_of_double_complexes) (c : ℝ≥0) (p : ℕ) :\n  (C.row p).d = @d' C c p :=\nrfl\n\n/-- The differential between rows in a system of double complexes,\nas map of system of complexes. -/\n@[simps app_f]\ndef row_map (C : system_of_double_complexes.{u}) (p p' : ℕ) :\n  C.row p ⟶ C.row p' :=\n{ app := λ c,\n  { f := λ q, (C.d p p' : C.X c.unop p q ⟶ C.X c.unop p' q),\n    comm' := λ q q' _, (C.d'_comp_d _ p p' q q').symm },\n  naturality' := λ c₁ c₂ h, (C.map h).comm p p' }\n\n@[simp] lemma row_map_apply (C : system_of_double_complexes.{u})\n  (c : ℝ≥0) (p p' q : ℕ) (x : C.X c p q) :\n  C.row_map p p' x = C.d p p' x := rfl\n\n-- -- this should be found by TC, but we first need to make `pi.eval` and `graded_object` additive\n-- instance aux : (homological_complex.forget SemiNormedGroup (complex_shape.up ℕ) ⋙\n--   pi.eval (λ (_ : ℕ), SemiNormedGroup) q).additive :=\n-- { map_zero' := λ C₁ C₂, by { dsimp, refl },\n--   map_add' := by { intros, dsimp, refl } }\n\n/-- The `q`-th column in a system of double complexes, as system of complexes. -/\n@[simps]\ndef col (C : system_of_double_complexes.{u}) (q : ℕ) : system_of_complexes.{u} :=\nC ⋙ functor.map_homological_complex (homological_complex.eval _ _ q) _\n\n@[simp] lemma col_X (C : system_of_double_complexes) (p q : ℕ) (c : ℝ≥0) :\n  C.col q c p = C.X c p q :=\nrfl\n\n@[simp] lemma col_res (C : system_of_double_complexes) (p q : ℕ) {c' c : ℝ≥0} [h : fact (c ≤ c')] :\n  (@system_of_complexes.res (C.col q) _ _ p h : C.col q c' p ⟶ C.col q c p) =\n  -- (@res C _ _ p q h : C.X c' p q ⟶ C.X c p q) :=\n  by dsimp_result { dsimp, exact (@res C _ _ p q h : C.X c' p q ⟶ C.X c p q) } :=\nrfl\n\n@[simp] lemma col_d (C : system_of_double_complexes) (c : ℝ≥0) (p p' q : ℕ) :\n  @system_of_complexes.d (C.col q) c p p' =\n  by dsimp_result { dsimp, exact @d C c p p' q } :=\nrfl\n\n/-- The differential between columns in a system of double complexes,\nas map of system of complexes. -/\ndef col_map (C : system_of_double_complexes.{u}) (q q' : ℕ) :\n  C.col q ⟶ C.col q' :=\n{ app := λ c,\n  { f := λ p, (C.d' q q' : C.X c.unop p q ⟶ C.X c.unop p q'),\n    comm' := λ p p' _, (C.d'_comp_d _ p p' q q') },\n  naturality' := λ c₁ c₂ h, by { ext p : 2, exact ((C.map h).f p).comm q q' } }\n\n/-- A system of double complexes is *admissible*\nif all the differentials and restriction maps are norm-nonincreasing.\n\nSee Definition 9.3 of [Analytic]. -/\nstructure admissible (C : system_of_double_complexes) : Prop :=\n(d_norm_noninc' : ∀ c p p' q (h : p + 1 = p'), (@d C c p p' q).norm_noninc)\n(d'_norm_noninc' : ∀ c p q q' (h : q + 1 = q'), (@d' C c p q q').norm_noninc)\n(res_norm_noninc : ∀ c' c p q h, (@res C c' c p q h).norm_noninc)\n\nnamespace admissible\n\nvariables {C}\n\nlemma d_norm_noninc (hC : C.admissible) (c : ℝ≥0) (p p' q : ℕ) :\n  (C.d p p' : C.X c p q ⟶ _).norm_noninc :=\nbegin\n  by_cases h : p + 1 = p',\n  { exact hC.d_norm_noninc' c p p' q h },\n  { rw C.d_eq_zero p p' q c h, intro v, simp }\nend\n\nlemma d'_norm_noninc (hC : C.admissible) (c : ℝ≥0) (p q q' : ℕ) :\n  (C.d' q q' : C.X c p q ⟶ _).norm_noninc :=\nbegin\n  by_cases h : q + 1 = q',\n  { exact hC.d'_norm_noninc' c p q q' h },\n  { rw C.d'_eq_zero p q q' c h, intro v, simp }\nend\n\nlemma col (hC : C.admissible) (q : ℕ) : (C.col q).admissible :=\n{ d_norm_noninc' := λ c i j h, hC.d_norm_noninc _ _ _ _,\n  res_norm_noninc := λ c i j h, hC.res_norm_noninc _ _ _ _ _ }\n\nlemma row (hC : C.admissible) (p : ℕ) : (C.row p).admissible :=\n{ d_norm_noninc' := λ c i j h, hC.d'_norm_noninc _ _ _ _,\n  res_norm_noninc := λ c i j h, hC.res_norm_noninc _ _ _ _ _ }\n\nlemma mk' (h : ∀ p, (C.row p).admissible)\n  (hd : ∀ c p p' q (h : p + 1 = p'), (@d C c p p' q).norm_noninc) :\n  C.admissible :=\n{ d_norm_noninc' := λ c p p' q h', hd c p p' q h',\n  d'_norm_noninc' := λ c p q q' h', (h p).d_norm_noninc' _ _ _ h',\n  res_norm_noninc := λ c₁ c₂ p q h', by { resetI, apply (h p).res_norm_noninc } }\n\nend admissible\n\nend system_of_double_complexes\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/system_of_complexes/double.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837527911057, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.4945834041107463}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebraic_geometry.Spec\nimport Mathlib.PostPort\n\nuniverses u_1 l \n\nnamespace Mathlib\n\n/-!\n# The category of schemes\n\nA scheme is a locally ringed space such that every point is contained in some open set\nwhere there is an isomorphism of presheaves between the restriction to that open set,\nand the structure sheaf of `Spec R`, for some commutative ring `R`.\n\nA morphism is schemes is just a morphism of the underlying locally ringed spaces.\n\n-/\n\nnamespace algebraic_geometry\n\n\n/--\nWe define `Scheme` as a `X : LocallyRingedSpace`,\nalong with a proof that every point has an open neighbourhood `U`\nso that that the restriction of `X` to `U` is isomorphic, as a space with a presheaf of commutative\nrings, to `Spec.PresheafedSpace R` for some `R : CommRing`.\n\n(Note we're not asking in the definition that this is an isomorphism as locally ringed spaces,\nalthough that is a consequence.)\n-/\nstructure Scheme where\n  local_affine :\n    ∀\n      (x :\n        ↥(PresheafedSpace.carrier\n            (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace _X)))),\n      ∃ (U :\n        topological_space.opens\n          ↥(PresheafedSpace.carrier\n              (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace _X)))),\n        ∃ (m : x ∈ U),\n          ∃ (R : CommRing),\n            ∃ (i :\n              PresheafedSpace.restrict\n                  (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace _X))\n                  (topological_space.opens.inclusion U)\n                  (topological_space.opens.inclusion_open_embedding U) ≅\n                Spec.PresheafedSpace R),\n              True\n\n-- PROJECT\n\n-- In fact, we can make the isomorphism `i` above an isomorphism in `LocallyRingedSpace`.\n\n-- However this is a consequence of the above definition, and not necessary for defining schemes.\n\n-- We haven't done this yet because we haven't shown that you can restrict a `LocallyRingedSpace`\n\n-- along an open embedding.\n\n-- We can do this already for `SheafedSpace` (as above), but we need to know that\n\n-- the stalks of the restriction are still local rings, which we follow if we knew that\n\n-- the stalks didn't change.\n\n-- This will follow if we define cofinal functors, and show precomposing with a cofinal functor\n\n-- doesn't change colimits, because open neighbourhoods of `x` within `U` are cofinal in\n\n-- all open neighbourhoods of `x`.\n\nnamespace Scheme\n\n\n/--\nEvery `Scheme` is a `LocallyRingedSpace`.\n-/\n-- (This parent projection is apparently not automatically generated because\n\n-- we used the `extends X : LocallyRingedSpace` syntax.)\n\ndef to_LocallyRingedSpace (S : Scheme) : LocallyRingedSpace :=\n  LocallyRingedSpace.mk (LocallyRingedSpace.to_SheafedSpace (X S)) sorry\n\n/--\n`Spec R` as a `Scheme`.\n-/\ndef Spec (R : CommRing) : Scheme :=\n  mk (LocallyRingedSpace.mk (LocallyRingedSpace.to_SheafedSpace (Spec.LocallyRingedSpace R)) sorry)\n    sorry\n\n/--\nThe empty scheme, as `Spec 0`.\n-/\ndef empty : Scheme := Spec (CommRing.of PUnit)\n\nprotected instance has_emptyc : has_emptyc Scheme := has_emptyc.mk empty\n\nprotected instance inhabited : Inhabited Scheme := { default := ∅ }\n\n/--\nSchemes are a full subcategory of locally ringed spaces.\n-/\nprotected instance category_theory.category : category_theory.category Scheme :=\n  category_theory.induced_category.category to_LocallyRingedSpace\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : Schemeᵒᵖ ⥤ CommRing :=\n  category_theory.functor.op (category_theory.induced_functor to_LocallyRingedSpace) ⋙\n    LocallyRingedSpace.Γ\n\ntheorem Γ_def :\n    Γ =\n        category_theory.functor.op (category_theory.induced_functor to_LocallyRingedSpace) ⋙\n          LocallyRingedSpace.Γ :=\n  rfl\n\n@[simp] theorem Γ_obj (X : Schemeᵒᵖ) :\n    category_theory.functor.obj Γ X =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf\n            (SheafedSpace.to_PresheafedSpace\n              (LocallyRingedSpace.to_SheafedSpace (X (opposite.unop X)))))\n          (opposite.op ⊤) :=\n  rfl\n\ntheorem Γ_obj_op (X : Scheme) :\n    category_theory.functor.obj Γ (opposite.op X) =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf\n            (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace (X X))))\n          (opposite.op ⊤) :=\n  rfl\n\n@[simp] theorem Γ_map {X : Schemeᵒᵖ} {Y : Schemeᵒᵖ} (f : X ⟶ Y) :\n    category_theory.functor.map Γ f =\n        category_theory.nat_trans.app\n            (PresheafedSpace.hom.c (subtype.val (category_theory.has_hom.hom.unop f)))\n            (opposite.op ⊤) ≫\n          category_theory.functor.map\n            (PresheafedSpace.presheaf\n              (SheafedSpace.to_PresheafedSpace\n                (LocallyRingedSpace.to_SheafedSpace (X (opposite.unop Y)))))\n            (category_theory.has_hom.hom.op\n              (topological_space.opens.le_map_top\n                (PresheafedSpace.hom.base (subtype.val (category_theory.has_hom.hom.unop f))) ⊤)) :=\n  rfl\n\ntheorem Γ_map_op {X : Scheme} {Y : Scheme} (f : X ⟶ Y) :\n    category_theory.functor.map Γ (category_theory.has_hom.hom.op f) =\n        category_theory.nat_trans.app (PresheafedSpace.hom.c (subtype.val f)) (opposite.op ⊤) ≫\n          category_theory.functor.map\n            (PresheafedSpace.presheaf\n              (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace (X X))))\n            (category_theory.has_hom.hom.op\n              (topological_space.opens.le_map_top (PresheafedSpace.hom.base (subtype.val f)) ⊤)) :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebraic_geometry/Scheme_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.49456740954868883}}
{"text": "import .algebra\nnoncomputable theory\n\nset_option eqn_compiler.zeta true\n\nuniverses u v w u₁ v₁ w₁\n\ninfix ` ⊗ `:100 := tensor_product\n\nvariables {R : Type u} {A : Type v} {B : Type w} {C : Type u₁} {D : Type v₁}\nvariables [comm_ring R] [comm_ring A] [comm_ring B] [comm_ring C] [comm_ring D]\nvariables (iA : algebra R A) (iB : algebra R B) (iC : algebra R C) (iD : algebra R D)\n\nnamespace tensor_product\nopen linear_map\n\nset_option class.instance_max_depth 200\ndef lmul : iA.mod ⊗ iB.mod →ₗ iA.mod ⊗ iB.mod →ₗ iA.mod ⊗ iB.mod :=\nlift $ linear_map.compr₂\n  ((linear_map.lflip _ _ _ _).comp $\n    linear_map.compr₂\n      (curry $ curry $ map (lift iA.lmul) $\n        lift iB.lmul)\n      (lcurry _ _ _))\n  (uncurry _ _ _)\n\ntheorem lmul_tmul (p : iA.mod) (q : iB.mod) (r : iA.mod) (s : iB.mod) :\n  lmul iA iB (p ⊗ₜ q) (r ⊗ₜ s) = (p * r) ⊗ₜ (q * s) :=\nby rw [lmul, lift.tmul, compr₂_apply, uncurry_apply, comp_apply, lflip_apply, compr₂_apply, lcurry_apply,\n    curry_apply, curry_apply, map_tmul, lift.tmul, lift.tmul]; refl\n\ninstance : comm_ring (iA.mod ⊗ iB.mod) :=\n{ mul := λ x y, lmul iA iB x y,\n  mul_assoc := begin\n    intros x y z,\n    show lmul iA iB (lmul iA iB x y) z =\n      lmul iA iB x (lmul iA iB y z),\n    refine tensor_product.induction_on _ _ z _ (λ z₁ z₂, _) (λ z₁ z₂ ih₁ ih₂, _),\n    { simp only [map_zero] },\n    { refine tensor_product.induction_on _ _ y _ (λ y₁ y₂, _) (λ y₁ y₂ ih₁ ih₂, _),\n      { rw [map_zero₂, map_zero, map_zero₂] },\n      { refine tensor_product.induction_on _ _ x _ (λ x₁ x₂, _) (λ x₁ x₂ ih₁ ih₂, _),\n        { rw [map_zero₂, map_zero₂, map_zero₂] },\n        { iterate 4 { rw [lmul_tmul] },\n          iterate 2 { rw mul_assoc } },\n        { rw [map_add₂, map_add₂, map_add₂], congr' 1, exacts [ih₁, ih₂] } },\n      { rw [map_add₂, map_add, map_add₂, map_add], congr' 1, exacts [ih₁, ih₂] } },\n    { rw [map_add, map_add, map_add], congr' 1, exacts [ih₁, ih₂] }\n  end,\n  one := 1 ⊗ₜ 1,\n  one_mul := λ x, show lmul iA iB (1 ⊗ₜ 1) x = x, from\n    tensor_product.induction_on _ _ x (map_zero _)\n    (λ x y, (lmul_tmul _ _ _ _ _ _).trans $ by rw [one_mul, one_mul])\n    (λ x y ihx ihy, (map_add _ _ _).trans $ by rw [ihx, ihy]),\n  mul_one := λ x, show lmul iA iB x (1 ⊗ₜ 1) = x, from\n    tensor_product.induction_on _ _ x (map_zero₂ _ _)\n    (λ x y, (lmul_tmul _ _ _ _ _ _).trans $ by rw [mul_one, mul_one])\n    (λ x y ihx ihy, (map_add₂ _ _ _ _).trans $ by rw [ihx, ihy]),\n  left_distrib := λ _, map_add _,\n  right_distrib := map_add₂ _,\n  mul_comm := λ x y, show lmul iA iB x y = lmul iA iB y x, from\n    tensor_product.induction_on _ _ x (by rw [map_zero₂, map_zero])\n      (λ x₁ x₂, tensor_product.induction_on _ _ y (by rw [map_zero₂, map_zero])\n        (λ y₁ y₂, by rw [lmul_tmul, lmul_tmul, mul_comm x₁ y₁, mul_comm x₂ y₂])\n        (λ y₁ y₂ ih₁ ih₂, by rw [map_add₂, map_add, ih₁, ih₂]))\n      (λ x₁ x₂ ih₁ ih₂, by rw [map_add₂, map_add, ih₁, ih₂]),\n  .. tensor_product.add_comm_group _ _ }\n\nset_option class.instance_max_depth 32\n\ntheorem mul_def (p : iA.mod) (q : iB.mod) (r : iA.mod) (s : iB.mod) :\n  (p ⊗ₜ q) * (r ⊗ₜ s) = (p * r) ⊗ₜ (q * s) :=\nlmul_tmul _ _ _ _ _ _\n\ntheorem one_def : (1 : iA.mod ⊗ iB.mod) = 1 ⊗ₜ 1 := rfl\n\nend tensor_product\n\nnamespace algebra\nopen tensor_product linear_map\n\ndef tensor_product : algebra R (iA.mod ⊗ iB.mod) :=\n{ to_fun := λ r, iA r ⊗ₜ 1,\n  hom := ⟨by rw iA.map_one; refl,\n    λ x y, by rw [iA.map_mul, mul_def, mul_one],\n    λ x y, by rw [iA.map_add, add_tmul]⟩,\n  smul_def' := λ r x, tensor_product.induction_on _ _ x\n    (by rw [smul_zero, mul_zero])\n    (λ x y, by rw [← tmul_smul, ← smul_tmul, mul_def, iA.smul_def, one_mul])\n    (λ x y ihx ihy, by rw [smul_add, mul_add, ihx, ihy]) }\n\ndef inl : iA →ₐ iA.tensor_product iB :=\n{ to_fun := λ x, x ⊗ₜ 1,\n  hom := ⟨rfl, λ x y, by rw [mul_def, mul_one], λ x y, add_tmul _ _ _⟩,\n  commutes' := λ r, rfl }\n\ntheorem inl_def (p : iA.mod) : iA.inl iB p = p ⊗ₜ 1 := rfl\n\ndef inr : iB →ₐ iA.tensor_product iB :=\n{ to_fun := λ x, 1 ⊗ₜ x,\n  hom := ⟨rfl, λ x y, by rw [mul_def, mul_one], λ x y, tmul_add _ _ _⟩,\n  commutes' := λ r, by rw [← mul_one (iB r), ← iB.smul_def, ← smul_tmul, iA.smul_def, mul_one]; refl }\n\ntheorem inr_def (q : iB.mod) : iA.inr iB q = 1 ⊗ₜ q := rfl\n\nnamespace tensor_product\n\nvariables {iA iB iC}\nset_option class.instance_max_depth 100\n@[elab_with_expected_type]\ndef arec (f : iA →ₐ iC) (g : iB →ₐ iC) : iA.tensor_product iB →ₐ iC :=\n{ to_fun := (tensor_product.lift iC.lmul).comp $ map f.to_linear_map g.to_linear_map,\n  hom := ⟨by rw [one_def, comp_apply, map_tmul, lift.tmul]; show f 1 * g 1 = 1;\n      rw [f.map_one, g.map_one, mul_one],\n    λ x y, tensor_product.induction_on _ _ x\n      (by rw [zero_mul, linear_map.map_zero]; exact (zero_mul _).symm)\n      (λ x₁ x₂, tensor_product.induction_on _ _ y\n        (by rw [mul_zero, linear_map.map_zero]; exact (mul_zero _).symm)\n        (λ y₁ y₂, by simp only [mul_def, comp_apply, map_tmul, lift.tmul];\n          change f _ * g _ = (f _ * g _) * (f _ * g _);\n          rw [f.map_mul, g.map_mul, mul_assoc, mul_assoc, mul_left_comm (f y₁)])\n        (λ y₁ y₂ ih₁ ih₂, by simp only [mul_add, linear_map.map_add, ih₁, ih₂]))\n      (λ x₁ x₂ ih₁ ih₂, by simp only [add_mul, linear_map.map_add, ih₁, ih₂]),\n    linear_map.map_add _⟩,\n  commutes' := λ r, show lift iC.lmul (map f.to_linear_map g.to_linear_map (iA r ⊗ₜ 1)) = _,\n    by rw [map_tmul, lift.tmul]; change f _ * g 1 = _; rw [f.commutes, g.map_one, mul_one] }\nset_option class.instance_max_depth 32\n\ntheorem arec_tmul (f : iA →ₐ iC) (g : iB →ₐ iC) (p : iA.mod) (q : iB.mod) :\n  arec f g (p ⊗ₜ q) = f p * g q :=\nlift.tmul _ _\n\nvariables (iA iB iC)\ndef UMP : ((iA →ₐ iC) × (iB →ₐ iC)) ≃ (iA.tensor_product iB →ₐ iC) :=\n{ to_fun := λ φ, arec φ.1 φ.2,\n  inv_fun := λ φ, (φ.comp (iA.inl iB), φ.comp (iA.inr iB)),\n  left_inv := λ ⟨φ₁, φ₂⟩, prod.ext\n    (by ext p; change (arec φ₁ φ₂) (p ⊗ₜ 1) = φ₁ p;\n      rw [arec_tmul, φ₂.map_one', mul_one])\n    (by ext q; change (arec φ₁ φ₂) (1 ⊗ₜ q) = φ₂ q;\n      rw [arec_tmul, φ₁.map_one', one_mul]),\n  right_inv := λ φ, alg_hom.to_linear_map_inj $ tensor_product.ext $ λ p q,\n    by dsimp only [alg_hom.to_linear_map_apply]; rw [arec_tmul,\n      alg_hom.comp_apply, alg_hom.comp_apply, inl_def, inr_def, ← φ.map_mul, mul_def, mul_one, one_mul] }\n\nvariables {iA iB iC iD}\ndef amap (f : iA →ₐ iC) (g : iB →ₐ iD) : (iA.tensor_product iB) →ₐ (iC.tensor_product iD) :=\narec ((iC.inl iD).comp f) ((iC.inr iD).comp g)\nvariables (iA iB iC iD)\n\n@[simp] lemma amap_tmul (f : iA →ₐ iC) (g : iB →ₐ iD) (x : A) (y : B) :\n  amap f g (x ⊗ₜ y) = f x ⊗ₜ g y :=\nby rw amap; simp only [arec_tmul,\n  alg_hom.comp_apply, inl_def, inr_def, mul_def, mul_one, one_mul]\n\ndef aassoc : (iA.tensor_product iB).tensor_product iC →ₐ\n  iA.tensor_product (iB.tensor_product iC) :=\narec (arec\n  (iA.inl $ iB.tensor_product iC)\n  ((iA.inr $ iB.tensor_product iC).comp $ iB.inl iC))\n  ((iA.inr $ iB.tensor_product iC).comp $ iB.inr iC)\n\n@[simp] lemma aassoc_tmul (x y z) :\n  aassoc iA iB iC (x ⊗ₜ y ⊗ₜ z) = x ⊗ₜ (y ⊗ₜ z) :=\nby rw aassoc; simp only [arec_tmul, inl_def, inr_def, alg_hom.comp_apply, mul_def, mul_one, one_mul]\n\ndef id_tensor : (algebra.id R).tensor_product iA →ₐ iA :=\narec iA.of_id (alg_hom.id iA)\n\n@[simp] lemma id_tensor_tmul (r x) : id_tensor iA (r ⊗ₜ x) = ((r : R) • x : iA.mod) :=\nby rw id_tensor; simp only [arec_tmul, alg_hom.id_apply, of_id_apply, iA.smul_def]\n\ndef tensor_id : iA.tensor_product (algebra.id R) →ₐ iA :=\narec (alg_hom.id iA) iA.of_id\n\n@[simp] lemma tensor_id_tmul (r x) : tensor_id iA (x ⊗ₜ r) = ((r : R) • x : iA.mod) :=\nby rw tensor_id; simp only [arec_tmul, alg_hom.id_apply, of_id_apply, iA.smul_def, mul_comm]\n\ndef base_change_left : algebra iA.mod (iA.mod ⊗ iB.mod) :=\nalgebra.of_core { to_fun := iA.inl iB }\n\ntheorem base_change_left_apply (r : iA.mod) : base_change_left iA iB r = r ⊗ₜ 1 := rfl\n\nset_option class.instance_max_depth 100\ndef base_change_left_rec {D : Type v₁} [comm_ring D] (iD : algebra iA.mod D)\n  (φ : iB →ₐ iA.comap iD) : base_change_left iA iB →ₐ iD :=\n{ to_fun := (tensor_product.lift (iA.comap iD).lmul).comp\n    (map (iA.to_comap iD).to_linear_map φ.to_linear_map),\n  hom := ⟨by simp only [comp_apply, one_def, map_tmul, alg_hom.to_linear_map_apply, lmul_apply,\n      lift.tmul, φ.map_one', (to_comap iA iD).map_one']; apply mul_one,\n    λ x y, tensor_product.induction_on _ _ x\n      (by rw [zero_mul, linear_map.map_zero]; exact (zero_mul _).symm)\n      (λ x₁ x₂, tensor_product.induction_on _ _ y\n        (by rw [mul_zero, linear_map.map_zero]; exact (mul_zero _).symm)\n        (λ y₁ y₂, by simp only [mul_def, comp_apply, map_tmul, alg_hom.to_linear_map_apply, lmul_apply,\n          lift.tmul, (iA.to_comap iD).map_mul, φ.map_mul, mul_assoc]; rw mul_left_comm ((iA.to_comap iD) y₁))\n        (λ y₁ y₂ ih₁ ih₂, by rw [mul_add, linear_map.map_add, ih₁, ih₂, linear_map.map_add, mul_add]))\n      (λ x₁ x₂ ih₁ ih₂, by rw [add_mul, linear_map.map_add, ih₁, ih₂, linear_map.map_add, add_mul]),\n    linear_map.map_add _⟩,\n  commutes' := λ x, by rw [comp_apply, base_change_left_apply, map_tmul, alg_hom.to_linear_map_apply,\n    alg_hom.to_linear_map_apply, to_comap_apply, lift.tmul, lmul_apply, φ.map_one']; exact mul_one _ }\nset_option class.instance_max_depth 32\n\ndef base_change_right : algebra B (iA.mod ⊗ iB.mod) :=\nalgebra.of_core { to_fun := iA.inr iB }\n\nend tensor_product\nend algebra", "meta": {"author": "kckennylau", "repo": "local-langlands-abelian", "sha": "ee22666898357dab800a0432214a22c519ed26a9", "save_path": "github-repos/lean/kckennylau-local-langlands-abelian", "path": "github-repos/lean/kckennylau-local-langlands-abelian/local-langlands-abelian-ee22666898357dab800a0432214a22c519ed26a9/src/algebra_tensor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.494567407804815}}
{"text": "import order_mv_polynomial noetherian ideal\n\nopen mv_polynomial\nopen finsupp\n\nnamespace buch\nvariables {σ : Type*} {α : Type*} [decidable_eq σ] [decidable_eq α] [discrete_field α] [fintype σ]\nvariables [decidable_linear_order (σ →₀ ℕ)] [is_well_founded (σ →₀ ℕ) (<)] [is_monomial_order (σ →₀ ℕ) (≤)] \n\nsection reduction\n\ndef reduction (a b : mv_polynomial σ α) := \n    a - b * (monomial (a.LM - b.LM) (a.LC / b.LC))\n\ndef red_list_aux : mv_polynomial σ α → list (mv_polynomial σ α) → mv_polynomial σ α\n| a [] := a\n| a (hd :: tl) := if h : hd.LM ∣ a.LM  then red_list_aux (reduction a hd) tl else red_list_aux a tl\n\nlemma reduction_of_LM_eqz {p q : mv_polynomial σ α} (hp : p.LM = 0) (hq : q.LM = 0) (hq' : q ≠ 0) : reduction p q = 0 :=\nbegin\n    rw [reduction, eqC_of_LM_eqz.1 hp, eqC_of_LM_eqz.1 hq],\n    simp [C, monomial_mul_monomial, mul_div_cancel' _ (LC_nez_iff.1 hq')],\nend\n\nlemma zero_red_list_aux : ∀ (l : list (mv_polynomial σ α)), red_list_aux 0 l = 0\n| [] := by simp [red_list_aux]\n| (q :: l') := begin\n    by_cases q.LM ∣ (0 : mv_polynomial (σ) α).LM;\n    simp [red_list_aux, h, reduction];\n    exact zero_red_list_aux l',\nend\n\ntheorem reduction_LM_lt {a b : mv_polynomial σ α} (hba : b.LM ∣ a.LM) (ha : a.LM ≠ 0) (hb : b ≠ 0) : (reduction a b).LM < a.LM := begin\n    simp [reduction],\n    apply sub_LM_lt _ ha,\n    rw [LT_of_mul_m, LT_mul_monomial, add_sub_cancel' hba, mul_div_cancel' _ (LC_nez_iff.1 hb), LT],\nend\n\nlemma red_list_aux_red_LM_lt : ∀ (l : list (mv_polynomial σ α)) {p q : mv_polynomial σ α} (hqp : q.LM ∣ p.LM) (hp : p.LM ≠ 0) (hq : q ≠ 0),\n(red_list_aux (reduction p q) l).LM < p.LM \n| [] := by simp [red_list_aux]; apply reduction_LM_lt\n| (r :: l') := \nλ p q hqp hp hq, begin \n    by_cases h_dvd : r.LM ∣ (reduction p q).LM;\n    simp [red_list_aux, h_dvd],\n    {\n        by_cases hr : r = 0,\n        {simp [reduction, hr], apply red_list_aux_red_LM_lt, assumption'},\n        by_cases h_r : (reduction p q).LM = 0,\n        simp [h_r] at h_dvd,\n        {\n            rw [reduction_of_LM_eqz h_r h_dvd hr, zero_red_list_aux],\n            simpa [finsupp.zero_lt_iff_ne_zero] using hp,\n        },\n        {apply lt_trans (red_list_aux_red_LM_lt l' h_dvd h_r hr) (reduction_LM_lt hqp hp hq)},\n    },\n    {apply red_list_aux_red_LM_lt; assumption},\nend\n\ntheorem red_list_aux_LM_lt : ∀ (l : list (mv_polynomial σ α)) (p : mv_polynomial σ α) (hp : p.LM ≠ 0) \n(h_red : red_list_aux p l ≠ p), (red_list_aux p l).LM < p.LM \n| [] := by simp [red_list_aux] \n| (r :: l') := λ p hp h_red, begin\n    by_cases hr : r = 0,\n    {simp [red_list_aux, reduction, hr] at h_red ⊢, apply red_list_aux_LM_lt, assumption'},\n    by_cases hrp : r.LM ∣ p.LM;\n    simp [red_list_aux, hrp] at h_red ⊢, \n    apply red_list_aux_red_LM_lt l' hrp hp hr,\n    apply red_list_aux_LM_lt, assumption',\nend\n\ndef red_list : mv_polynomial σ α → list (mv_polynomial σ α) → mv_polynomial σ α\n| a l := \n    let r := red_list_aux a l in\n    if h₁ : r = a\n    then r\n    else if h₂ : a.LM = 0\n        then 0\n        else have r.LM < a.LM := red_list_aux_LM_lt _ _ h₂ h₁,\n            red_list r l\nusing_well_founded \n{ rel_tac := λ _ _, `[exact ⟨_, inv_image.wf (λ a, a.1.LM) _inst_6.wf⟩] \n, dec_tac := tactic.assumption }\n\nlemma zero_red_list : ∀ (l : list (mv_polynomial σ α)), red_list 0 l = 0\n| [] := by unfold red_list; simp [red_list_aux]\n| (hd :: tl) := begin\n    unfold red_list, simp [zero_red_list_aux],\nend\n\nlemma eqz_of_red_list_aux_eq : ∀ (l : list (mv_polynomial σ α)) (p : mv_polynomial σ α), \n(red_list_aux p l = p) → (∃ (q : mv_polynomial σ α) (hq₁ : q ∈ l) (hq₂ : q ≠ 0), q.LM = 0) → p = 0 \n| [] := by simp\n| (r :: l') := λ p, begin\n    simp_intros hp₁ hl [red_list_aux, -finset.insert_empty_eq_singleton],\n    rcases hl with ⟨q, ⟨hq | hq, hq'₁, hq'₂⟩⟩,\n    {\n        rw hq at hq'₁ hq'₂,\n        simp [hq'₂] at hp₁,\n        by_cases hp₂ : p.LM = 0,\n        {rwa [reduction_of_LM_eqz hp₂ hq'₂ hq'₁, zero_red_list_aux, eq_comm] at hp₁},\n        {\n            have h := red_list_aux_red_LM_lt l' (by simp [hq'₂]) hp₂ hq'₁,\n            rw hp₁ at h,\n            apply absurd h (lt_irrefl _),\n        },\n    },\n    by_cases hrp : r.LM ∣ p.LM;\n    simp [hrp] at hp₁,\n    {\n        by_cases hr : r = 0, \n        {exact eqz_of_red_list_aux_eq l' _ (by simpa [hr, reduction] using hp₁) ⟨q, hq, hq'₁, hq'₂⟩},\n        {\n            \n            by_cases hp₂ : p.LM = 0,\n            {\n                simp [hp₂] at hrp,\n                rwa [reduction_of_LM_eqz hp₂ hrp hr, zero_red_list_aux, eq_comm] at hp₁,\n            },\n            {\n                have h := red_list_aux_red_LM_lt l' hrp hp₂ hr,\n                rw hp₁ at h,\n                apply absurd h (lt_irrefl _),\n            },\n        },\n    },\n    {apply eqz_of_red_list_aux_eq l' _ hp₁, refine ⟨q, hq, hq'₁, hq'₂⟩},\nend\n\nlemma red_list_eqz_of_const : ∀ (p : mv_polynomial σ α) (l : list (mv_polynomial σ α)), \n(∃ (q : mv_polynomial σ α) (hq₁ : q ∈ l) (hq₂ : q ≠ 0), q.LM = 0) → red_list p l = 0 \n| p l := λ h, begin \n    unfold red_list, \n    by_cases hp₁ : red_list_aux p l = p;\n    by_cases hp₂ : p.LM = 0;\n    simp [hp₁, hp₂], \n    repeat {apply eqz_of_red_list_aux_eq l _ hp₁ h},\n    {\n        let : (red_list_aux p l).LM < p.LM, from red_list_aux_LM_lt l p hp₂ hp₁,\n        apply red_list_eqz_of_const, assumption,\n    }\nend\nusing_well_founded \n{ rel_tac := λ _ _, `[exact ⟨_, inv_image.wf (λ a, a.1.LM) _inst_6.wf⟩] \n, dec_tac := tactic.assumption }\n\n\nlemma red_list_nez_no_const : ∀ (l : list (mv_polynomial σ α)) (p : mv_polynomial σ α) (h : red_list p l ≠ 0) \n(q : mv_polynomial σ α) (hq₁ : q ∈ l) (hq₂ : q ≠ 0), q.LM ≠ 0 :=\nλ l p h q hq₁ hq₂ hq₃, h (red_list_eqz_of_const _ _ ⟨q, hq₁, hq₂, hq₃⟩)\n\n\nlemma red_list_aux_not_div : ∀ (l : list (mv_polynomial σ α)) (p : mv_polynomial σ α) (h : red_list_aux p l = p)\n    (q : mv_polynomial σ α) (hq₁ : q ∈ l) (hq₂ : q.LM ≠ 0), q.LM ∤ p.LM\n| [] := by simp\n| (r :: l') := begin \n    simp_intros p hp₁ q hq₁ hq₂ [red_list_aux, -finset.insert_empty_eq_singleton], cases hq₁;\n    by_cases hrp : r.LM ∣ p.LM; simp [hrp] at hp₁,\n    {\n        by_cases hp : p.LM = 0,\n        {\n            rw hq₁ at hq₂,\n            simp [hp] at hrp,\n            apply absurd hrp hq₂,\n        },\n        {\n            rw hq₁ at hq₂,\n            have h_r := red_list_aux_red_LM_lt l' hrp hp (nez_of_LM_nez hq₂),\n            rw [hp₁] at h_r, apply absurd h_r (lt_irrefl _),\n        },\n    },\n    {rwa hq₁,},\n    {\n        by_cases hr : r = 0,\n        {simp [reduction, hr] at hp₁, apply red_list_aux_not_div l', assumption',},\n        {\n            by_cases hp : p.LM = 0,\n            {\n                simp [hp]at hrp,\n                simp [reduction_of_LM_eqz hp hrp hr, zero_red_list_aux] at hp₁,\n                simpa [hp₁.symm] using hq₂,\n            },\n            {\n                have h_r := red_list_aux_red_LM_lt l' hrp hp hr,\n                rw [hp₁] at h_r, apply absurd h_r (lt_irrefl _),\n            },\n        },\n    },\n    {apply red_list_aux_not_div l', assumption'},\nend\n\n\ntheorem red_list_not_div : ∀ (p : mv_polynomial σ α) (l : list (mv_polynomial σ α)) (h : red_list p l ≠ 0)\n    (q : mv_polynomial σ α) (hq₁ : q ∈ l) (hq₂ : q ≠ 0), q.LM ∤ (red_list p l).LM\n| p l := λ h q hq₁ hq₂, begin\n    have hq₃ := red_list_nez_no_const l p h _ hq₁ hq₂,\n    unfold red_list at ⊢ h, \n    by_cases hp₁ : red_list_aux p l = p; \n    by_cases hp₂ : p.LM = 0; \n    simp [hp₁, hp₂], assumption',\n    {apply red_list_aux_not_div _ _ hp₁ _ hq₁ hq₃},\n    {\n        let : (red_list_aux p l).LM < p.LM, from red_list_aux_LM_lt l p hp₂ hp₁,\n        apply red_list_not_div, simp [hp₁, hp₂] at h,\n        assumption',\n    }\nend\nusing_well_founded \n{ rel_tac := λ _ _, `[exact ⟨_, inv_image.wf (λ a, a.1.LM) _inst_6.wf⟩] \n, dec_tac := tactic.assumption }\n\nend reduction\n\ndef s_poly (p q : mv_polynomial σ α) : mv_polynomial σ α := \n    let X := m_lcm (LM p) (LM q) in\n    --let Xc := lcm (LC p) (LC q) in\n    monomial (X - p.LM) (1 / (LC p)) * p - monomial (X - q.LM) (1 / (LC q)) * q\n\ndef s_polyL : mv_polynomial σ α → list (mv_polynomial σ α) → list (mv_polynomial σ α)\n| p [] := []\n| p (q :: l₁) := s_poly p q :: s_polyL p l₁\n\ndef s_polys : list (mv_polynomial σ α) → list (mv_polynomial σ α)\n| [] := []\n| (a :: l) := s_polyL a l ++ (s_polys l)\n\nlemma mem_s_polyL {p q : mv_polynomial σ α} : ∀ {l : list (mv_polynomial σ α)},\nq ∈ l → s_poly p q ∈ s_polyL p l\n| [] := by simp\n| (hd :: tl) := begin\n    simp_intros hq [s_polyL],\n    cases hq,\n    {simp [hq]},\n    {simp [mem_s_polyL hq]}\nend\n\nlemma s_poly_comm {p q : mv_polynomial σ α} : s_poly p q = -(s_poly q p) :=\nby simp [s_poly, m_lcm_comm]\n\nset_option class.instance_max_depth 50\ntheorem ideal_increase (l : list (mv_polynomial σ α)) (p : mv_polynomial σ α) (h : red_list p l ≠ 0) :\n    monomial_ideal l < monomial_ideal (list.cons (red_list p l) l) := \nbegin\n    simp [lt_iff_le_and_ne], \n    refine ⟨by apply ideal.span_mono; simp, _⟩,\n    apply ideal.ne_of_not_mem_mem (red_list p l).LT,\n    {\n        intro h_mem, \n        rcases monomial_mem_ideal (by rwa ←LC_nez_iff) l h_mem with ⟨q, ⟨hq₁, hq₂⟩, hq₃⟩, \n        apply red_list_not_div p l h, assumption',\n    },\n    {\n        simp [monomial_ideal, ideal.mem_span_insert], \n        refine ⟨1, 0, by simp, by simp⟩, \n    }\nend\n\ndef buchberger : (list (mv_polynomial σ α) × list (mv_polynomial σ α)) → list (mv_polynomial σ α)\n| ⟨l₁, []⟩ := l₁\n| ⟨l₁, (p :: l₂)⟩ :=\n    let lex := prod.lex ((>) : ideal (mv_polynomial σ α) → ideal (mv_polynomial σ α) → Prop) nat.lt in\n    let a := red_list p l₁ in\n    if h : a = 0 \n    then \n        have lex ⟨monomial_ideal l₁, l₂.length⟩ ⟨monomial_ideal l₁, (list.cons p l₂).length⟩ := \n            by right; rw [list.length_cons]; apply nat.lt_succ_self,\n        buchberger ⟨l₁, l₂⟩\n    else \n        have lex ⟨monomial_ideal (list.cons a l₁), (s_polyL a l₁ ++ l₂).length⟩ ⟨monomial_ideal l₁, (list.cons p l₂).length⟩ := \n            by left; exact ideal_increase l₁ p h,\n        buchberger ⟨a :: l₁, s_polyL a l₁ ++ l₂⟩\nusing_well_founded \n{ rel_tac := λ _ _, \n`[exact ⟨_, inv_image.wf (λ ⟨l₁, l₂⟩, prod.mk (monomial_ideal l₁) l₂.length) (prod.lex_wf ideal_wf nat.lt_wf)⟩ ] \n, dec_tac := tactic.assumption }\n\nend buch\n", "meta": {"author": "FCL-lean", "repo": "verification", "sha": "be02c698c0ca78b18762e3fe7749cdc72a55d197", "save_path": "github-repos/lean/FCL-lean-verification", "path": "github-repos/lean/FCL-lean-verification/verification-be02c698c0ca78b18762e3fe7749cdc72a55d197/src/buchberger.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085909370423, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4945673986349941}}
{"text": "/- The tactic search_mem_list defined at back.lean does\n   not update the tactic_state. More importantly, it does not change\n   the set of goals that need to be solved.\n   It is also possible to write a very compact search_mem_list on top of the\n   apply tactic. This version will create subgoals while searching for\n   a proof of (a ∈ e). -/\nopen list expr tactic\n\nuniverse variable u\n\n/- We change the implicit arguments of in_tail and in_head.\n   The goal is to allow us to create in_tail and in_head application using\n   quotation without having information about the expected type. -/\nlemma in_tail  {α : Type u} {a : α} (b : α) {l : list α}      : a ∈ l → a ∈ b::l :=\nmem_cons_of_mem _\n\nlemma in_head  {α : Type u} (a : α) (l : list α)              : a ∈ a::l :=\nmem_cons_self _ _\n\nlemma in_left  {α : Type u} {a : α}   {l : list α} (r : list α) : a ∈ l → a ∈ l ++ r :=\nmem_append_left _\n\nlemma in_right {α : Type u} {a : α}   (l : list α) {r : list α} : a ∈ r → a ∈ l ++ r :=\nmem_append_right _\n\n/- The command `declare_trace` add a new trace.search_mem_list to Lean -/\ndeclare_trace search_mem_list\n\n/- In Lean, we can only reference a function 'f' while defining 'f' when we use\n   recursive equation compiler. This is true also for meta definitions.\n   Thus, we cannot write a tactic such as\n       meta def f : tactic unit :=\n       ... f ...\n   that invokes itself but it is not defined using the equational compiler.\n   We workaround this issue by defining it as\n       meta def f : unit → tactic unit\n       | () := ... f () ...\n-/\n\nmeta def mk_mem_list_rec : unit → tactic unit\n| () :=\nwhen_tracing `search_mem_list (do t ← target, f ← pp t, trace (to_fmt \"search \" ++ f))\n>> (assumption\n    <|>\n    /- The notation `[t] allows us to use the Lean \"tactic interactive mode\" inside regular tactic.\n       In the following example `[apply in_left] is syntax sugar for\n           tactic.interactive.apply `(in_left)\n    -/\n    (`[apply in_left] >> mk_mem_list_rec ())\n    <|>\n    (`[apply in_right] >> mk_mem_list_rec ())\n    <|>\n    (`[apply in_head])\n    <|>\n    (`[apply in_tail] >> mk_mem_list_rec ()))\n/- The tactic `now` fails if we still have goals to be solved -/\n>> done\n\nmeta def mk_mem_list : tactic unit :=\nsolve1 (mk_mem_list_rec ())\n\nset_option trace.search_mem_list true\n\nexample (a b c : nat) : a ∈ [b, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a ∈ [b, c] ++ [b, a+0, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a ∈ [b, c] ++ [b, c, c] ++ [b, a+0, b] :=\nby mk_mem_list\n\n--- my example\nexample (a b c : nat) : a ∈ [b, c] ++ [b, c+0, c] ++ [b, a+1, b] :=\nby mk_mem_list\n\nexample (a b c : nat) (l : list nat) : a ∈ l → a ∈ [b, c] ++ b::l :=\nbegin intros, mk_mem_list end\n\nexample (a b c : nat) (l₁ l₂ : list nat) : a ∈ l₁ → a ∈ b::b::c::l₂ ++ b::c::l₁ ++ [c, c, b] :=\nbegin intros, mk_mem_list end", "meta": {"author": "mathprocessing", "repo": "lean_mathlib_examples", "sha": "743c6456c0a3219dd1722efdd31ee6f3a113818a", "save_path": "github-repos/lean/mathprocessing-lean_mathlib_examples", "path": "github-repos/lean/mathprocessing-lean_mathlib_examples/lean_mathlib_examples-743c6456c0a3219dd1722efdd31ee6f3a113818a/src/tactics/back2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4945673977630576}}
{"text": "/-\nCopyright (c) 2014 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Yury Kudryashov, Neil Strickland\n\n! This file was ported from Lean 3 source module algebra.ring.basic\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Ring.Defs\nimport Mathbin.Algebra.Hom.Group\nimport Mathbin.Algebra.Opposites\n\n/-!\n# Semirings and rings\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file gives lemmas about semirings, rings and domains.\nThis is analogous to `algebra.group.basic`,\nthe difference being that the former is about `+` and `*` separately, while\nthe present file is about their interaction.\n\nFor the definitions of semirings and rings see `algebra.ring.defs`.\n\n-/\n\n\nuniverse u v w x\n\nvariable {α : Type u} {β : Type v} {γ : Type w} {R : Type x}\n\nopen Function\n\nnamespace AddHom\n\n/- warning: add_hom.mul_left -> AddHom.mulLeft is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Distrib.{u1} R], R -> (AddHom.{u1, u1} R R (Distrib.toHasAdd.{u1} R _inst_1) (Distrib.toHasAdd.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Distrib.{u1} R], R -> (AddHom.{u1, u1} R R (Distrib.toAdd.{u1} R _inst_1) (Distrib.toAdd.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align add_hom.mul_left AddHom.mulLeftₓ'. -/\n/-- Left multiplication by an element of a type with distributive multiplication is an `add_hom`. -/\n@[simps (config := { fullyApplied := false })]\ndef mulLeft {R : Type _} [Distrib R] (r : R) : AddHom R R :=\n  ⟨(· * ·) r, mul_add r⟩\n#align add_hom.mul_left AddHom.mulLeft\n\n/- warning: add_hom.mul_right -> AddHom.mulRight is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Distrib.{u1} R], R -> (AddHom.{u1, u1} R R (Distrib.toHasAdd.{u1} R _inst_1) (Distrib.toHasAdd.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Distrib.{u1} R], R -> (AddHom.{u1, u1} R R (Distrib.toAdd.{u1} R _inst_1) (Distrib.toAdd.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align add_hom.mul_right AddHom.mulRightₓ'. -/\n/-- Left multiplication by an element of a type with distributive multiplication is an `add_hom`. -/\n@[simps (config := { fullyApplied := false })]\ndef mulRight {R : Type _} [Distrib R] (r : R) : AddHom R R :=\n  ⟨fun a => a * r, fun _ _ => add_mul _ _ r⟩\n#align add_hom.mul_right AddHom.mulRight\n\nend AddHom\n\nsection AddHomClass\n\nvariable {F : Type _} [NonAssocSemiring α] [NonAssocSemiring β] [AddHomClass F α β]\n\n/- warning: map_bit0 -> map_bit0 is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {F : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : NonAssocSemiring.{u2} β] [_inst_3 : AddHomClass.{u3, u1, u2} F α β (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_2)))] (f : F) (a : α), Eq.{succ u2} β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_2))) _inst_3)) f (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) a)) (bit0.{u2} β (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_2))) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_2))) _inst_3)) f a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {F : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : NonAssocSemiring.{u3} β] [_inst_3 : AddHomClass.{u1, u2, u3} F α β (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u3} β (NonUnitalNonAssocSemiring.toDistrib.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_2)))] (f : F) (a : α), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) (bit0.{u2} α (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) a)) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u3} β (NonUnitalNonAssocSemiring.toDistrib.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_2))) _inst_3) f (bit0.{u2} α (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) a)) (bit0.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) a) (Distrib.toAdd.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) a) (NonUnitalNonAssocSemiring.toDistrib.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) a) _inst_2))) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u3} β (NonUnitalNonAssocSemiring.toDistrib.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_2))) _inst_3) f a))\nCase conversion may be inaccurate. Consider using '#align map_bit0 map_bit0ₓ'. -/\n/-- Additive homomorphisms preserve `bit0`. -/\n@[simp]\ntheorem map_bit0 (f : F) (a : α) : (f (bit0 a) : β) = bit0 (f a) :=\n  map_add _ _ _\n#align map_bit0 map_bit0\n\nend AddHomClass\n\nnamespace AddMonoidHom\n\n#print AddMonoidHom.mulLeft /-\n/-- Left multiplication by an element of a (semi)ring is an `add_monoid_hom` -/\ndef mulLeft {R : Type _} [NonUnitalNonAssocSemiring R] (r : R) : R →+ R\n    where\n  toFun := (· * ·) r\n  map_zero' := MulZeroClass.mul_zero r\n  map_add' := mul_add r\n#align add_monoid_hom.mul_left AddMonoidHom.mulLeft\n-/\n\n/- warning: add_monoid_hom.coe_mul_left -> AddMonoidHom.coe_mul_left is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] (r : R), Eq.{succ u1} (R -> R) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (fun (_x : AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) => R -> R) (AddMonoidHom.hasCoeToFun.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddMonoidHom.mulLeft.{u1} R _inst_1 r)) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_1))) r)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] (r : R), Eq.{succ u1} (forall (ᾰ : R), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R R (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoidHom.addMonoidHomClass.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))))) (AddMonoidHom.mulLeft.{u1} R _inst_1 r)) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_1)) r)\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.coe_mul_left AddMonoidHom.coe_mul_leftₓ'. -/\n@[simp]\ntheorem coe_mul_left {R : Type _} [NonUnitalNonAssocSemiring R] (r : R) :\n    ⇑(mulLeft r) = (· * ·) r :=\n  rfl\n#align add_monoid_hom.coe_mul_left AddMonoidHom.coe_mul_left\n\n#print AddMonoidHom.mulRight /-\n/-- Right multiplication by an element of a (semi)ring is an `add_monoid_hom` -/\ndef mulRight {R : Type _} [NonUnitalNonAssocSemiring R] (r : R) : R →+ R\n    where\n  toFun a := a * r\n  map_zero' := MulZeroClass.zero_mul r\n  map_add' _ _ := add_mul _ _ r\n#align add_monoid_hom.mul_right AddMonoidHom.mulRight\n-/\n\n/- warning: add_monoid_hom.coe_mul_right -> AddMonoidHom.coe_mul_right is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] (r : R), Eq.{succ u1} (R -> R) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (fun (_x : AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) => R -> R) (AddMonoidHom.hasCoeToFun.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddMonoidHom.mulRight.{u1} R _inst_1 r)) (fun (_x : R) => HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_1))) _x r)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] (r : R), Eq.{succ u1} (forall (ᾰ : R), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R R (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoidHom.addMonoidHomClass.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))))) (AddMonoidHom.mulRight.{u1} R _inst_1 r)) (fun (_x : R) => HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_1)) _x r)\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.coe_mul_right AddMonoidHom.coe_mul_rightₓ'. -/\n@[simp]\ntheorem coe_mul_right {R : Type _} [NonUnitalNonAssocSemiring R] (r : R) :\n    ⇑(mulRight r) = (· * r) :=\n  rfl\n#align add_monoid_hom.coe_mul_right AddMonoidHom.coe_mul_right\n\n/- warning: add_monoid_hom.mul_right_apply -> AddMonoidHom.mul_right_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] (a : R) (r : R), Eq.{succ u1} R (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (fun (_x : AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) => R -> R) (AddMonoidHom.hasCoeToFun.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddMonoidHom.mulRight.{u1} R _inst_1 r) a) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_1))) a r)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] (a : R) (r : R), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) a) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R R (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoidHom.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))) R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoidHom.addMonoidHomClass.{u1, u1} R R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1))) (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_1)))))) (AddMonoidHom.mulRight.{u1} R _inst_1 r) a) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_1)) a r)\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.mul_right_apply AddMonoidHom.mul_right_applyₓ'. -/\ntheorem mul_right_apply {R : Type _} [NonUnitalNonAssocSemiring R] (a r : R) :\n    mulRight r a = a * r :=\n  rfl\n#align add_monoid_hom.mul_right_apply AddMonoidHom.mul_right_apply\n\nend AddMonoidHom\n\nsection HasDistribNeg\n\nsection Mul\n\nvariable [Mul α] [HasDistribNeg α]\n\nopen MulOpposite\n\ninstance : HasDistribNeg αᵐᵒᵖ :=\n  {\n    MulOpposite.hasInvolutiveNeg\n      _ with\n    neg_mul := fun _ _ => unop_injective <| mul_neg _ _\n    mul_neg := fun _ _ => unop_injective <| neg_mul _ _ }\n\nend Mul\n\nsection Group\n\nvariable [Group α] [HasDistribNeg α]\n\n/- warning: inv_neg' -> inv_neg' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Group.{u1} α] [_inst_2 : HasDistribNeg.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1))))] (a : α), Eq.{succ u1} α (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1)) (Neg.neg.{u1} α (InvolutiveNeg.toHasNeg.{u1} α (HasDistribNeg.toHasInvolutiveNeg.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1)))) _inst_2)) a)) (Neg.neg.{u1} α (InvolutiveNeg.toHasNeg.{u1} α (HasDistribNeg.toHasInvolutiveNeg.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1)))) _inst_2)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1)) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Group.{u1} α] [_inst_2 : HasDistribNeg.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1))))] (a : α), Eq.{succ u1} α (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_1)))) (Neg.neg.{u1} α (InvolutiveNeg.toNeg.{u1} α (HasDistribNeg.toInvolutiveNeg.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1)))) _inst_2)) a)) (Neg.neg.{u1} α (InvolutiveNeg.toNeg.{u1} α (HasDistribNeg.toInvolutiveNeg.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_1)))) _inst_2)) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_1)))) a))\nCase conversion may be inaccurate. Consider using '#align inv_neg' inv_neg'ₓ'. -/\n@[simp]\ntheorem inv_neg' (a : α) : (-a)⁻¹ = -a⁻¹ := by\n  rw [eq_comm, eq_inv_iff_mul_eq_one, neg_mul, mul_neg, neg_neg, mul_left_inv]\n#align inv_neg' inv_neg'\n\nend Group\n\nend HasDistribNeg\n\nsection NonUnitalCommRing\n\nvariable [NonUnitalCommRing α] {a b c : α}\n\nattribute [local simp] add_assoc add_comm add_left_comm mul_comm\n\n/- warning: Vieta_formula_quadratic -> vieta_formula_quadratic is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonUnitalCommRing.{u1} α] {b : α} {c : α} {x : α}, (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (NonUnitalNonAssocRing.toAddCommGroup.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) x x) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) b x)) c) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))))) -> (Exists.{succ u1} α (fun (y : α) => And (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (NonUnitalNonAssocRing.toAddCommGroup.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) y y) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) b y)) c) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))))) (And (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) x y) b) (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) x y) c))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonUnitalCommRing.{u1} α] {b : α} {c : α} {x : α}, (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (NonUnitalNonAssocRing.toAddCommGroup.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))) x x) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))) b x)) c) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (SemigroupWithZero.toZero.{u1} α (NonUnitalSemiring.toSemigroupWithZero.{u1} α (NonUnitalRing.toNonUnitalSemiring.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))) -> (Exists.{succ u1} α (fun (y : α) => And (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (NonUnitalNonAssocRing.toAddCommGroup.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))) y y) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))) b y)) c) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (SemigroupWithZero.toZero.{u1} α (NonUnitalSemiring.toSemigroupWithZero.{u1} α (NonUnitalRing.toNonUnitalSemiring.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1))))))) (And (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))))) x y) b) (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonUnitalRing.toNonUnitalNonAssocRing.{u1} α (NonUnitalCommRing.toNonUnitalRing.{u1} α _inst_1)))) x y) c))))\nCase conversion may be inaccurate. Consider using '#align Vieta_formula_quadratic vieta_formula_quadraticₓ'. -/\n/-- Vieta's formula for a quadratic equation, relating the coefficients of the polynomial with\n  its roots. This particular version states that if we have a root `x` of a monic quadratic\n  polynomial, then there is another root `y` such that `x + y` is negative the `a_1` coefficient\n  and `x * y` is the `a_0` coefficient. -/\ntheorem vieta_formula_quadratic {b c x : α} (h : x * x - b * x + c = 0) :\n    ∃ y : α, y * y - b * y + c = 0 ∧ x + y = b ∧ x * y = c :=\n  by\n  have : c = x * (b - x) := (eq_neg_of_add_eq_zero_right h).trans (by simp [mul_sub, mul_comm])\n  refine' ⟨b - x, _, by simp, by rw [this]⟩\n  rw [this, sub_add, ← sub_mul, sub_self]\n#align Vieta_formula_quadratic vieta_formula_quadratic\n\nend NonUnitalCommRing\n\n/- warning: succ_ne_self -> succ_ne_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocRing.{u1} α] [_inst_2 : Nontrivial.{u1} α] (a : α), Ne.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (NonAssocRing.toAddCommGroupWithOne.{u1} α _inst_1)))))))) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocRing.{u1} α] [_inst_2 : Nontrivial.{u1} α] (a : α), Ne.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α _inst_1)))) a\nCase conversion may be inaccurate. Consider using '#align succ_ne_self succ_ne_selfₓ'. -/\ntheorem succ_ne_self [NonAssocRing α] [Nontrivial α] (a : α) : a + 1 ≠ a := fun h =>\n  one_ne_zero ((add_right_inj a).mp (by simp [h]))\n#align succ_ne_self succ_ne_self\n\n/- warning: pred_ne_self -> pred_ne_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocRing.{u1} α] [_inst_2 : Nontrivial.{u1} α] (a : α), Ne.{succ u1} α (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (NonAssocRing.toAddCommGroupWithOne.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (NonAssocRing.toAddCommGroupWithOne.{u1} α _inst_1)))))))) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocRing.{u1} α] [_inst_2 : Nontrivial.{u1} α] (a : α), Ne.{succ u1} α (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (AddGroupWithOne.toSub.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (NonAssocRing.toAddCommGroupWithOne.{u1} α _inst_1)))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α _inst_1)))) a\nCase conversion may be inaccurate. Consider using '#align pred_ne_self pred_ne_selfₓ'. -/\ntheorem pred_ne_self [NonAssocRing α] [Nontrivial α] (a : α) : a - 1 ≠ a := fun h =>\n  one_ne_zero (neg_injective ((add_right_inj a).mp (by simpa [sub_eq_add_neg] using h)))\n#align pred_ne_self pred_ne_self\n\nsection NoZeroDivisors\n\nvariable (α)\n\n/- warning: is_left_cancel_mul_zero.to_no_zero_divisors -> IsLeftCancelMulZero.to_noZeroDivisors is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : IsLeftCancelMulZero.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))], NoZeroDivisors.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : IsLeftCancelMulZero.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))], NoZeroDivisors.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align is_left_cancel_mul_zero.to_no_zero_divisors IsLeftCancelMulZero.to_noZeroDivisorsₓ'. -/\ntheorem IsLeftCancelMulZero.to_noZeroDivisors [Ring α] [IsLeftCancelMulZero α] : NoZeroDivisors α :=\n  by\n  refine' ⟨fun x y h => _⟩\n  by_cases hx : x = 0\n  · left\n    exact hx\n  · right\n    rw [← sub_zero (x * y), ← MulZeroClass.mul_zero x, ← mul_sub] at h\n    convert IsLeftCancelMulZero.mul_left_cancel_of_ne_zero hx h\n    rw [sub_zero]\n#align is_left_cancel_mul_zero.to_no_zero_divisors IsLeftCancelMulZero.to_noZeroDivisors\n\n/- warning: is_right_cancel_mul_zero.to_no_zero_divisors -> IsRightCancelMulZero.to_noZeroDivisors is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : IsRightCancelMulZero.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))], NoZeroDivisors.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : IsRightCancelMulZero.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))], NoZeroDivisors.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align is_right_cancel_mul_zero.to_no_zero_divisors IsRightCancelMulZero.to_noZeroDivisorsₓ'. -/\ntheorem IsRightCancelMulZero.to_noZeroDivisors [Ring α] [IsRightCancelMulZero α] :\n    NoZeroDivisors α := by\n  refine' ⟨fun x y h => _⟩\n  by_cases hy : y = 0\n  · right\n    exact hy\n  · left\n    rw [← sub_zero (x * y), ← MulZeroClass.zero_mul y, ← sub_mul] at h\n    convert IsRightCancelMulZero.mul_right_cancel_of_ne_zero hy h\n    rw [sub_zero]\n#align is_right_cancel_mul_zero.to_no_zero_divisors IsRightCancelMulZero.to_noZeroDivisors\n\n/- warning: no_zero_divisors.to_is_cancel_mul_zero -> NoZeroDivisors.to_isCancelMulZero is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : NoZeroDivisors.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))], IsCancelMulZero.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : NoZeroDivisors.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))], IsCancelMulZero.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align no_zero_divisors.to_is_cancel_mul_zero NoZeroDivisors.to_isCancelMulZeroₓ'. -/\ninstance (priority := 100) NoZeroDivisors.to_isCancelMulZero [Ring α] [NoZeroDivisors α] :\n    IsCancelMulZero α\n    where\n  mul_left_cancel_of_ne_zero a b c ha h :=\n    by\n    rw [← sub_eq_zero, ← mul_sub] at h\n    exact sub_eq_zero.1 ((eq_zero_or_eq_zero_of_mul_eq_zero h).resolve_left ha)\n  mul_right_cancel_of_ne_zero a b c hb h :=\n    by\n    rw [← sub_eq_zero, ← sub_mul] at h\n    exact sub_eq_zero.1 ((eq_zero_or_eq_zero_of_mul_eq_zero h).resolve_right hb)\n#align no_zero_divisors.to_is_cancel_mul_zero NoZeroDivisors.to_isCancelMulZero\n\n/- warning: no_zero_divisors.to_is_domain -> NoZeroDivisors.to_isDomain is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [h : Nontrivial.{u1} α] [_inst_2 : NoZeroDivisors.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))], IsDomain.{u1} α (Ring.toSemiring.{u1} α _inst_1)\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [h : Nontrivial.{u1} α] [_inst_2 : NoZeroDivisors.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))], IsDomain.{u1} α (Ring.toSemiring.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align no_zero_divisors.to_is_domain NoZeroDivisors.to_isDomainₓ'. -/\ntheorem NoZeroDivisors.to_isDomain [Ring α] [h : Nontrivial α] [NoZeroDivisors α] : IsDomain α :=\n  { NoZeroDivisors.to_isCancelMulZero α, h with }\n#align no_zero_divisors.to_is_domain NoZeroDivisors.to_isDomain\n\n/- warning: is_domain.to_no_zero_divisors -> IsDomain.to_noZeroDivisors is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α _inst_1)], NoZeroDivisors.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α _inst_1)) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1)))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Ring.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α _inst_1)], NoZeroDivisors.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (Ring.toSemiring.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align is_domain.to_no_zero_divisors IsDomain.to_noZeroDivisorsₓ'. -/\ninstance (priority := 100) IsDomain.to_noZeroDivisors [Ring α] [IsDomain α] : NoZeroDivisors α :=\n  IsRightCancelMulZero.to_noZeroDivisors α\n#align is_domain.to_no_zero_divisors IsDomain.to_noZeroDivisors\n\nend NoZeroDivisors\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Ring/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4945118398535881}}
{"text": "/-\nCopyright (c) 2021 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport geometry.manifold.algebra.structures\nimport geometry.manifold.bump_function\nimport topology.paracompact\nimport topology.partition_of_unity\nimport topology.shrinking_lemma\n\n/-!\n# Smooth partition of unity\n\nIn this file we define two structures, `smooth_bump_covering` and `smooth_partition_of_unity`. Both\nstructures describe coverings of a set by a locally finite family of supports of smooth functions\nwith some additional properties. The former structure is mostly useful as an intermediate step in\nthe construction of a smooth partition of unity but some proofs that traditionally deal with a\npartition of unity can use a `smooth_bump_covering` as well.\n\nGiven a real manifold `M` and its subset `s`, a `smooth_bump_covering ι I M s` is a collection of\n`smooth_bump_function`s `f i` indexed by `i : ι` such that\n\n* the center of each `f i` belongs to `s`;\n* the family of sets `support (f i)` is locally finite;\n* for each `x ∈ s`, there exists `i : ι` such that `f i =ᶠ[𝓝 x] 1`.\nIn the same settings, a `smooth_partition_of_unity ι I M s` is a collection of smooth nonnegative\nfunctions `f i : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯`, `i : ι`, such that\n\n* the family of sets `support (f i)` is locally finite;\n* for each `x ∈ s`, the sum `∑ᶠ i, f i x` equals one;\n* for each `x`, the sum `∑ᶠ i, f i x` is less than or equal to one.\n\nWe say that `f : smooth_bump_covering ι I M s` is *subordinate* to a map `U : M → set M` if for each\nindex `i`, we have `tsupport (f i) ⊆ U (f i).c`. This notion is a bit more general than\nbeing subordinate to an open covering of `M`, because we make no assumption about the way `U x`\ndepends on `x`.\n\nWe prove that on a smooth finitely dimensional real manifold with `σ`-compact Hausdorff topology,\nfor any `U : M → set M` such that `∀ x ∈ s, U x ∈ 𝓝 x` there exists a `smooth_bump_covering ι I M s`\nsubordinate to `U`. Then we use this fact to prove a similar statement about smooth partitions of\nunity.\n\n## Implementation notes\n\n\n\n## TODO\n\n* Build a framework for to transfer local definitions to global using partition of unity and use it\n  to define, e.g., the integral of a differential form over a manifold.\n\n## Tags\n\nsmooth bump function, partition of unity\n-/\n\nuniverses uι uE uH uM\n\nopen function filter finite_dimensional set\nopen_locale topological_space manifold classical filter big_operators\n\nnoncomputable theory\n\nvariables {ι : Type uι}\n{E : Type uE} [normed_group E] [normed_space ℝ E] [finite_dimensional ℝ E]\n{H : Type uH} [topological_space H] (I : model_with_corners ℝ E H)\n{M : Type uM} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M]\n\n/-!\n### Covering by supports of smooth bump functions\n\nIn this section we define `smooth_bump_covering ι I M s` to be a collection of\n`smooth_bump_function`s such that their supports is a locally finite family of sets and for each `x\n∈ s` some function `f i` from the collection is equal to `1` in a neighborhood of `x`. A covering of\nthis type is useful to construct a smooth partition of unity and can be used instead of a partition\nof unity in some proofs.\n\nWe prove that on a smooth finite dimensional real manifold with `σ`-compact Hausdorff topology, for\nany `U : M → set M` such that `∀ x ∈ s, U x ∈ 𝓝 x` there exists a `smooth_bump_covering ι I M s`\nsubordinate to `U`. Then we use this fact to prove a version of the Whitney embedding theorem: any\ncompact real manifold can be embedded into `ℝ^n` for large enough `n`.  -/\n\nvariables (ι M)\n\n/-- We say that a collection of `smooth_bump_function`s is a `smooth_bump_covering` of a set `s` if\n\n* `(f i).c ∈ s` for all `i`;\n* the family `λ i, support (f i)` is locally finite;\n* for each point `x ∈ s` there exists `i` such that `f i =ᶠ[𝓝 x] 1`;\n  in other words, `x` belongs to the interior of `{y | f i y = 1}`;\n\nIf `M` is a finite dimensional real manifold which is a sigma-compact Hausdorff topological space,\nthen for every covering `U : M → set M`, `∀ x, U x ∈ 𝓝 x`, there exists a `smooth_bump_covering`\nsubordinate to `U`, see `smooth_bump_covering.exists_is_subordinate`.\n\nThis covering can be used, e.g., to construct a partition of unity and to prove the weak\nWhitney embedding theorem. -/\n@[nolint has_inhabited_instance]\nstructure smooth_bump_covering (s : set M := univ) :=\n(c : ι → M)\n(to_fun : Π i, smooth_bump_function I (c i))\n(c_mem' : ∀ i, c i ∈ s)\n(locally_finite' : locally_finite (λ i, support (to_fun i)))\n(eventually_eq_one' : ∀ x ∈ s, ∃ i, to_fun i =ᶠ[𝓝 x] 1)\n\n/-- We say that that a collection of functions form a smooth partition of unity on a set `s` if\n\n* all functions are infinitely smooth and nonnegative;\n* the family `λ i, support (f i)` is locally finite;\n* for all `x ∈ s` the sum `∑ᶠ i, f i x` equals one;\n* for all `x`, the sum `∑ᶠ i, f i x` is less than or equal to one. -/\nstructure smooth_partition_of_unity (s : set M := univ) :=\n(to_fun : ι → C^∞⟮I, M; 𝓘(ℝ), ℝ⟯)\n(locally_finite' : locally_finite (λ i, support (to_fun i)))\n(nonneg' : ∀ i x, 0 ≤ to_fun i x)\n(sum_eq_one' : ∀ x ∈ s, ∑ᶠ i, to_fun i x = 1)\n(sum_le_one' : ∀ x, ∑ᶠ i, to_fun i x ≤ 1)\n\nvariables {ι I M}\n\nnamespace smooth_partition_of_unity\n\nvariables {s : set M} (f : smooth_partition_of_unity ι I M s)\n\ninstance {s : set M} : has_coe_to_fun (smooth_partition_of_unity ι I M s)\n  (λ _, ι → C^∞⟮I, M; 𝓘(ℝ), ℝ⟯) :=\n⟨smooth_partition_of_unity.to_fun⟩\n\nprotected lemma locally_finite : locally_finite (λ i, support (f i)) :=\nf.locally_finite'\n\nlemma nonneg (i : ι) (x : M) : 0 ≤ f i x := f.nonneg' i x\n\nlemma sum_eq_one {x} (hx : x ∈ s) : ∑ᶠ i, f i x = 1 := f.sum_eq_one' x hx\n\nlemma sum_le_one (x : M) : ∑ᶠ i, f i x ≤ 1 := f.sum_le_one' x\n\n/-- Reinterpret a smooth partition of unity as a continuous partition of unity. -/\ndef to_partition_of_unity : partition_of_unity ι M s :=\n{ to_fun := λ i, f i, .. f }\n\nlemma smooth_sum : smooth I 𝓘(ℝ) (λ x, ∑ᶠ i, f i x) :=\nsmooth_finsum (λ i, (f i).smooth) f.locally_finite\n\nlemma le_one (i : ι) (x : M) : f i x ≤ 1 := f.to_partition_of_unity.le_one i x\n\nlemma sum_nonneg (x : M) : 0 ≤ ∑ᶠ i, f i x := f.to_partition_of_unity.sum_nonneg x\n\n/-- A smooth partition of unity `f i` is subordinate to a family of sets `U i` indexed by the same\ntype if for each `i` the closure of the support of `f i` is a subset of `U i`. -/\ndef is_subordinate (f : smooth_partition_of_unity ι I M s) (U : ι → set M) :=\n∀ i, tsupport (f i) ⊆ U i\n\n@[simp] lemma is_subordinate_to_partition_of_unity {f : smooth_partition_of_unity ι I M s}\n  {U : ι → set M} :\n  f.to_partition_of_unity.is_subordinate U ↔ f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_partition_of_unity ↔\n  _ smooth_partition_of_unity.is_subordinate.to_partition_of_unity\n\nend smooth_partition_of_unity\n\nnamespace bump_covering\n\n-- Repeat variables to drop [finite_dimensional ℝ E] and [smooth_manifold_with_corners I M]\nlemma smooth_to_partition_of_unity {E : Type uE} [normed_group E] [normed_space ℝ E]\n  {H : Type uH} [topological_space H] {I : model_with_corners ℝ E H}\n  {M : Type uM} [topological_space M] [charted_space H M] {s : set M}\n  (f : bump_covering ι M s) (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) (i : ι) :\n  smooth I 𝓘(ℝ) (f.to_partition_of_unity i) :=\n(hf i).mul $ smooth_finprod_cond (λ j _, smooth_const.sub (hf j)) $\n  by { simp only [mul_support_one_sub], exact f.locally_finite }\n\nvariables {s : set M}\n\n/-- A `bump_covering` such that all functions in this covering are smooth generates a smooth\npartition of unity.\n\nIn our formalization, not every `f : bump_covering ι M s` with smooth functions `f i` is a\n`smooth_bump_covering`; instead, a `smooth_bump_covering` is a covering by supports of\n`smooth_bump_function`s. So, we define `bump_covering.to_smooth_partition_of_unity`, then reuse it\nin `smooth_bump_covering.to_smooth_partition_of_unity`. -/\ndef to_smooth_partition_of_unity (f : bump_covering ι M s) (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) :\n  smooth_partition_of_unity ι I M s :=\n{ to_fun := λ i, ⟨f.to_partition_of_unity i, f.smooth_to_partition_of_unity hf i⟩,\n  .. f.to_partition_of_unity }\n\n@[simp] lemma to_smooth_partition_of_unity_to_partition_of_unity (f : bump_covering ι M s)\n  (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) :\n  (f.to_smooth_partition_of_unity hf).to_partition_of_unity = f.to_partition_of_unity :=\nrfl\n\n@[simp] lemma coe_to_smooth_partition_of_unity (f : bump_covering ι M s)\n  (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) (i : ι) :\n  ⇑(f.to_smooth_partition_of_unity hf i) = f.to_partition_of_unity i :=\nrfl\n\nlemma is_subordinate.to_smooth_partition_of_unity {f : bump_covering ι M s}\n  {U : ι → set M} (h : f.is_subordinate U) (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) :\n  (f.to_smooth_partition_of_unity hf).is_subordinate U :=\nh.to_partition_of_unity\n\nend bump_covering\n\nnamespace smooth_bump_covering\n\nvariables {s : set M} {U : M → set M} (fs : smooth_bump_covering ι I M s) {I}\n\ninstance : has_coe_to_fun (smooth_bump_covering ι I M s)\n  (λ x, Π (i : ι), smooth_bump_function I (x.c i)) :=\n⟨to_fun⟩\n\n@[simp] lemma coe_mk (c : ι → M) (to_fun : Π i, smooth_bump_function I (c i))\n  (h₁ h₂ h₃) : ⇑(mk c to_fun h₁ h₂ h₃ : smooth_bump_covering ι I M s) = to_fun :=\nrfl\n\n/--\nWe say that `f : smooth_bump_covering ι I M s` is *subordinate* to a map `U : M → set M` if for each\nindex `i`, we have `tsupport (f i) ⊆ U (f i).c`. This notion is a bit more general than\nbeing subordinate to an open covering of `M`, because we make no assumption about the way `U x`\ndepends on `x`.\n-/\ndef is_subordinate {s : set M} (f : smooth_bump_covering ι I M s) (U : M → set M) :=\n∀ i, tsupport (f i) ⊆ U (f.c i)\n\nlemma is_subordinate.support_subset {fs : smooth_bump_covering ι I M s} {U : M → set M}\n  (h : fs.is_subordinate U) (i : ι) :\n  support (fs i) ⊆ U (fs.c i) :=\nsubset.trans subset_closure (h i)\n\nvariable (I)\n\n/-- Let `M` be a smooth manifold with corners modelled on a finite dimensional real vector space.\nSuppose also that `M` is a Hausdorff `σ`-compact topological space. Let `s` be a closed set\nin `M` and `U : M → set M` be a collection of sets such that `U x ∈ 𝓝 x` for every `x ∈ s`.\nThen there exists a smooth bump covering of `s` that is subordinate to `U`. -/\nlemma exists_is_subordinate [t2_space M] [sigma_compact_space M] (hs : is_closed s)\n  (hU : ∀ x ∈ s, U x ∈ 𝓝 x) :\n  ∃ (ι : Type uM) (f : smooth_bump_covering ι I M s), f.is_subordinate U :=\nbegin\n  -- First we deduce some missing instances\n  haveI : locally_compact_space H := I.locally_compact,\n  haveI : locally_compact_space M := charted_space.locally_compact H,\n  haveI : normal_space M := normal_of_paracompact_t2,\n  -- Next we choose a covering by supports of smooth bump functions\n  have hB := λ x hx, smooth_bump_function.nhds_basis_support I (hU x hx),\n  rcases refinement_of_locally_compact_sigma_compact_of_nhds_basis_set hs hB\n    with ⟨ι, c, f, hf, hsub', hfin⟩, choose hcs hfU using hf,\n  /- Then we use the shrinking lemma to get a covering by smaller open -/\n  rcases exists_subset_Union_closed_subset hs (λ i, (f i).open_support)\n    (λ x hx, hfin.point_finite x) hsub' with ⟨V, hsV, hVc, hVf⟩,\n  choose r hrR hr using λ i, (f i).exists_r_pos_lt_subset_ball (hVc i) (hVf i),\n  refine ⟨ι, ⟨c, λ i, (f i).update_r (r i) (hrR i), hcs, _, λ x hx, _⟩, λ i, _⟩,\n  { simpa only [smooth_bump_function.support_update_r] },\n  { refine (mem_Union.1 $ hsV hx).imp (λ i hi, _),\n    exact ((f i).update_r _ _).eventually_eq_one_of_dist_lt\n      ((f i).support_subset_source $ hVf _ hi) (hr i hi).2 },\n  { simpa only [coe_mk, smooth_bump_function.support_update_r, tsupport] using hfU i }\nend\n\nvariables {I M}\n\nprotected lemma locally_finite : locally_finite (λ i, support (fs i)) := fs.locally_finite'\n\nprotected lemma point_finite (x : M) : {i | fs i x ≠ 0}.finite :=\nfs.locally_finite.point_finite x\n\nlemma mem_chart_at_source_of_eq_one {i : ι} {x : M} (h : fs i x = 1) :\n  x ∈ (chart_at H (fs.c i)).source :=\n(fs i).support_subset_source $ by simp [h]\n\nlemma mem_ext_chart_at_source_of_eq_one {i : ι} {x : M} (h : fs i x = 1) :\n  x ∈ (ext_chart_at I (fs.c i)).source :=\nby { rw ext_chart_at_source, exact fs.mem_chart_at_source_of_eq_one h }\n\n/-- Index of a bump function such that `fs i =ᶠ[𝓝 x] 1`. -/\ndef ind (x : M) (hx : x ∈ s) : ι := (fs.eventually_eq_one' x hx).some\n\nlemma eventually_eq_one (x : M) (hx : x ∈ s) : fs (fs.ind x hx) =ᶠ[𝓝 x] 1 :=\n(fs.eventually_eq_one' x hx).some_spec\n\nlemma apply_ind (x : M) (hx : x ∈ s) : fs (fs.ind x hx) x = 1 :=\n(fs.eventually_eq_one x hx).eq_of_nhds\n\nlemma mem_support_ind (x : M) (hx : x ∈ s) : x ∈ support (fs $ fs.ind x hx) :=\nby simp [fs.apply_ind x hx]\n\nlemma mem_chart_at_ind_source (x : M) (hx : x ∈ s) :\n  x ∈ (chart_at H (fs.c (fs.ind x hx))).source :=\nfs.mem_chart_at_source_of_eq_one (fs.apply_ind x hx)\n\nlemma mem_ext_chart_at_ind_source (x : M) (hx : x ∈ s) :\n  x ∈ (ext_chart_at I (fs.c (fs.ind x hx))).source :=\nfs.mem_ext_chart_at_source_of_eq_one (fs.apply_ind x hx)\n\n/-- The index type of a `smooth_bump_covering` of a compact manifold is finite. -/\nprotected def fintype [compact_space M] : fintype ι :=\nfs.locally_finite.fintype_of_compact $ λ i, (fs i).nonempty_support\n\nvariable [t2_space M]\n\n/-- Reinterpret a `smooth_bump_covering` as a continuous `bump_covering`. Note that not every\n`f : bump_covering ι M s` with smooth functions `f i` is a `smooth_bump_covering`. -/\ndef to_bump_covering : bump_covering ι M s :=\n{ to_fun := λ i, ⟨fs i, (fs i).continuous⟩,\n  locally_finite' := fs.locally_finite,\n  nonneg' := λ i x, (fs i).nonneg,\n  le_one' := λ i x, (fs i).le_one,\n  eventually_eq_one' := fs.eventually_eq_one' }\n\n@[simp] lemma is_subordinate_to_bump_covering {f : smooth_bump_covering ι I M s} {U : M → set M} :\n  f.to_bump_covering.is_subordinate (λ i, U (f.c i)) ↔ f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_bump_covering ↔\n  _ smooth_bump_covering.is_subordinate.to_bump_covering\n\n/-- Every `smooth_bump_covering` defines a smooth partition of unity. -/\ndef to_smooth_partition_of_unity : smooth_partition_of_unity ι I M s :=\nfs.to_bump_covering.to_smooth_partition_of_unity (λ i, (fs i).smooth)\n\nlemma to_smooth_partition_of_unity_apply (i : ι) (x : M) :\n  fs.to_smooth_partition_of_unity i x = fs i x * ∏ᶠ j (hj : well_ordering_rel j i), (1 - fs j x) :=\nrfl\n\nlemma to_smooth_partition_of_unity_eq_mul_prod (i : ι) (x : M) (t : finset ι)\n  (ht : ∀ j, well_ordering_rel j i → fs j x ≠ 0 → j ∈ t) :\n  fs.to_smooth_partition_of_unity i x =\n    fs i x * ∏ j in t.filter (λ j, well_ordering_rel j i), (1 - fs j x) :=\nfs.to_bump_covering.to_partition_of_unity_eq_mul_prod i x t ht\n\nlemma exists_finset_to_smooth_partition_of_unity_eventually_eq (i : ι) (x : M) :\n  ∃ t : finset ι, fs.to_smooth_partition_of_unity i =ᶠ[𝓝 x]\n    fs i * ∏ j in t.filter (λ j, well_ordering_rel j i), (1 - fs j) :=\nfs.to_bump_covering.exists_finset_to_partition_of_unity_eventually_eq i x\n\nlemma to_smooth_partition_of_unity_zero_of_zero {i : ι} {x : M} (h : fs i x = 0) :\n  fs.to_smooth_partition_of_unity i x = 0 :=\nfs.to_bump_covering.to_partition_of_unity_zero_of_zero h\n\nlemma support_to_smooth_partition_of_unity_subset (i : ι) :\n  support (fs.to_smooth_partition_of_unity i) ⊆ support (fs i) :=\nfs.to_bump_covering.support_to_partition_of_unity_subset i\n\nlemma is_subordinate.to_smooth_partition_of_unity {f : smooth_bump_covering ι I M s} {U : M → set M}\n  (h : f.is_subordinate U) :\n  f.to_smooth_partition_of_unity.is_subordinate (λ i, U (f.c i)) :=\nh.to_bump_covering.to_partition_of_unity\n\nlemma sum_to_smooth_partition_of_unity_eq (x : M) :\n  ∑ᶠ i, fs.to_smooth_partition_of_unity i x = 1 - ∏ᶠ i, (1 - fs i x) :=\nfs.to_bump_covering.sum_to_partition_of_unity_eq x\n\nend smooth_bump_covering\n\nvariable (I)\n\n/-- Given two disjoint closed sets in a Hausdorff σ-compact finite dimensional manifold, there\nexists an infinitely smooth function that is equal to `0` on one of them and is equal to one on the\nother. -/\nlemma exists_smooth_zero_one_of_closed [t2_space M] [sigma_compact_space M] {s t : set M}\n  (hs : is_closed s) (ht : is_closed t) (hd : disjoint s t) :\n  ∃ f : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯, eq_on f 0 s ∧ eq_on f 1 t ∧ ∀ x, f x ∈ Icc (0 : ℝ) 1 :=\nbegin\n  have : ∀ x ∈ t, sᶜ ∈ 𝓝 x, from λ x hx, hs.is_open_compl.mem_nhds (disjoint_right.1 hd hx),\n  rcases smooth_bump_covering.exists_is_subordinate I ht this with ⟨ι, f, hf⟩,\n  set g := f.to_smooth_partition_of_unity,\n  refine ⟨⟨_, g.smooth_sum⟩, λ x hx, _, λ x, g.sum_eq_one, λ x, ⟨g.sum_nonneg x, g.sum_le_one x⟩⟩,\n  suffices : ∀ i, g i x = 0,\n    by simp only [this, cont_mdiff_map.coe_fn_mk, finsum_zero, pi.zero_apply],\n  refine λ i, f.to_smooth_partition_of_unity_zero_of_zero _,\n  exact nmem_support.1 (subset_compl_comm.1 (hf.support_subset i) hx)\nend\n\nvariable {I}\n\nnamespace smooth_partition_of_unity\n\n/-- A `smooth_partition_of_unity` that consists of a single function, uniformly equal to one,\ndefined as an example for `inhabited` instance. -/\ndef single (i : ι) (s : set M) : smooth_partition_of_unity ι I M s :=\n(bump_covering.single i s).to_smooth_partition_of_unity $ λ j,\n  begin\n    rcases eq_or_ne j i with rfl|h,\n    { simp only [smooth_one, continuous_map.coe_one, bump_covering.coe_single, pi.single_eq_same] },\n    { simp only [smooth_zero, bump_covering.coe_single, pi.single_eq_of_ne h,\n        continuous_map.coe_zero] }\n  end\n\ninstance [inhabited ι] (s : set M) : inhabited (smooth_partition_of_unity ι I M s) :=\n⟨single default s⟩\n\nvariables [t2_space M] [sigma_compact_space M]\n\n/-- If `X` is a paracompact normal topological space and `U` is an open covering of a closed set\n`s`, then there exists a `bump_covering ι X s` that is subordinate to `U`. -/\nlemma exists_is_subordinate {s : set M} (hs : is_closed s) (U : ι → set M) (ho : ∀ i, is_open (U i))\n  (hU : s ⊆ ⋃ i, U i) :\n  ∃ f : smooth_partition_of_unity ι I M s, f.is_subordinate U :=\nbegin\n  haveI : locally_compact_space H := I.locally_compact,\n  haveI : locally_compact_space M := charted_space.locally_compact H,\n  haveI : normal_space M := normal_of_paracompact_t2,\n  rcases bump_covering.exists_is_subordinate_of_prop (smooth I 𝓘(ℝ)) _ hs U ho hU\n    with ⟨f, hf, hfU⟩,\n  { exact ⟨f.to_smooth_partition_of_unity hf, hfU.to_smooth_partition_of_unity hf⟩ },\n  { intros s t hs ht hd,\n    rcases exists_smooth_zero_one_of_closed I hs ht hd with ⟨f, hf⟩,\n    exact ⟨f, f.smooth, hf⟩ }\nend\n\nend smooth_partition_of_unity\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/geometry/manifold/partition_of_unity.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339716830605, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.49451020866065676}}
{"text": "import .sets\n\nnamespace zfc\nopen tactic\n/-\n__Axiom Tactics__\nThis file contains a few tactics relating to the axioms of ZFC in sets.lean. While not particularly\nuseful, these tactics might be helpful in very specific scenarios. Here is an elevator pitch for each\none:\n\n`by_axiom` This tactic allows you to easily solve a goal by applying the axioms of ZFC. Wow!\n\n`list_axioms` Did you forget which axiomatic system you're working in again? Don't worry! This\n  tactic shows you all of the axioms.\n\n`explain_axioms` Why go into the sets.lean file when the sets.lean file can come to you? Use this\n  tactic to see the gist of each axiom.\n\n-/\n\n\n/-__by_axiom__\n  This tactic attempts to solve the current goal by applying an axiom. -/\nmeta def by_axiom : tactic unit :=\n    ((do applyc `zfc.extensionality, trace \"Applied Axiom of Extensionality\", skip)  <|>\n    (do applyc `zfc.pairing, trace \"Applied Axiom of Pairing\", skip) <|>\n    (do applyc `zfc.separation, trace \"Applied Axiom of Separation\", skip) <|>\n    (do applyc `zfc.empty_set, trace \"Applied Axiom of Empty Set\", skip) <|>\n    (do applyc `zfc.union, trace \"Applied Axiom of Union\", skip) <|>\n    (do applyc `zfc.power_set, trace \"Applied Axiom of Power Set\", skip) <|>\n    (do applyc `zfc.infinity, trace \"Applied Axiom of Infinity\", skip) <|>\n    (do applyc `zfc.replacement, trace \"Applied Axiom of Replacement\", skip) <|>\n    (do applyc `zfc.regularity, trace \"Applied Axiom of Regularity\", skip) <|>\n    (do applyc `zfc.choice, trace \"Applied Axiom of Choice\", skip)) <|>\n    fail \"Could not apply ZFC axioms to current state. Instead, enjoy this poem I wrote\n    Roses are red,\n    Violets are blue,\n    ZFC is cool, I guess,\n    But no one's as cool as you <3 B)\"\n\n/-__list_axioms__\n  This tactic lists the axioms of ZFC that are implemented. -/\nmeta def list_axioms : tactic unit :=\n  trace \"-List of ZFC Axioms-\n  Extensionality - `zfc.extensionality`\n  Pairing        - `zfc.pairing`\n  Separation     - `zfc.separation`\n  Empty Set      - `zfc.empty_set`\n  Union          - `zfc.union`\n  Power Set      - `zfc.power_set`\n  Infinity       - `zfc.infinity`\n  Replacemnt     - `zfc.replacement`\n  Regularity     - `zfc.regularity`\n  Choice         - `zfc.choice`\"\n\n/-__list_axioms__\n  This tactic attempts to explain each axiom.-/\nmeta def explain_axioms : tactic unit :=\n  trace \n  \"<><>Extensionality<><>\n  If two sets have the same elements, they are equal.\n\n  <><>Pairing<><>\n  Given two sets, there exists a set with only those two sets as elements.\n\n  <><>Separation<><>\n  Given some proposition P, we can separate some set into a subset whose elements all satisfy P.\n\n  <><>Empty Set<><>\n  There exists a set that has no elements.\n\n  <><>Union<><>\n  For any set X, there exists a set whose elements are all elements of elements of X. \n\n  <><>Power Set<><>\n  For any set X, there exists a set P(X) that is the collection of all subsets of X. \n\n  <><>Infinity<><>\n  There exists a set that can be built inductively, starting with the empty set and adding the union of elements of the set to the set.\n\n  <><>Replacement<><>\n  If F is a function on the set X, then the image F(X) is also a set.\n\n  <><>Regularity<><>\n  Every set has a minimal element with respect to ∈ (a set X can't contain itself, nor contain elements that contain X, etc.).\n\n  <><>Choice<><>\n  For any nonempty set, there exists a function that returns an element of that set. \n  \"\n\n/-__Examples__-/\n-- lemma example1 : (∀(s : Set), ∃(t : Set), ∀(sel sel_el tel: Set), \n--   sel ∈ s → sel_el ∈ sel → tel ∈ t ↔ sel_el = tel) ∧ (∀(s: Set) (φ : Set → Set),\n--    (∀(x y a : Set), x ∈ s ∧ φ(x) = y → φ(x) = a ↔ a = y) → ∃(t : Set), ∀(z x: Set),\n--     x ∈ s → z ∈ t ↔ φ(x) = z) :=\n--   begin\n--     split,\n--     repeat {by_axiom},\n--   end\n\n-- lemma example2 : true :=\n--   begin\n--     explain_axioms,\n--     list_axioms,\n--     by_axiom, --fails\n--   end\nend zfc", "meta": {"author": "Beanway144", "repo": "fpv-final-project", "sha": "2d72b50e8c5627f2fc61c597a9c6e4e83f5022ca", "save_path": "github-repos/lean/Beanway144-fpv-final-project", "path": "github-repos/lean/Beanway144-fpv-final-project/fpv-final-project-2d72b50e8c5627f2fc61c597a9c6e4e83f5022ca/src/axiom_tactics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.640635841117624, "lm_q1q2_score": 0.49447061517370283}}
{"text": "/-\nCopyright (c) 2021 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport tactic.hint\n\n/-!\n\n# Intuitionistic tautology (`itauto`) decision procedure\n\nThe `itauto` tactic will prove any intuitionistic tautology. It implements the well known\n`G4ip` algorithm:\n[Dyckhoff, *Contraction-free sequent calculi for intuitionistic logic*][dyckhoff_1992].\n\nAll built in propositional connectives are supported: `true`, `false`, `and`, `or`, `implies`,\n`not`, `iff`, `xor`, as well as `eq` and `ne` on propositions. Anything else, including definitions\nand predicate logical connectives (`forall` and `exists`), are not supported, and will have to be\nsimplified or instantiated before calling this tactic.\n\nThe resulting proofs will never use any axioms except possibly `propext`, and `propext` is only\nused if the input formula contains an equality of propositions `p = q`.\n\n## Implementation notes\n\nThe core logic of the prover is in three functions:\n\n* `prove : context → prop → state_t ℕ option proof`: The main entry point.\n  Gets a context and a goal, and returns a `proof` object or fails, using `state_t ℕ` for the name\n  generator.\n* `search : context → prop → state_t ℕ option proof`: Same meaning as `proof`, called during the\n  search phase (see below).\n* `context.add : prop → proof → context → except (prop → proof) context`: Adds a proposition with\n  its proof into the context, but it also does some simplifications on the spot while doing so.\n  It will either return the new context, or if it happens to notice a proof of false, it will\n  return a function to compute a proof of any proposition in the original context.\n\nThe intuitionistic logic rules are separated into three groups:\n\n* level 1: No splitting, validity preserving: apply whenever you can.\n  Left rules in `context.add`, right rules in `prove`.\n  * `context.add`:\n    * simplify `Γ, ⊤ ⊢ B` to `Γ ⊢ B`\n    * `Γ, ⊥ ⊢ B` is true\n    * simplify `Γ, A ∧ B ⊢ C` to `Γ, A, B ⊢ C`\n    * simplify `Γ, ⊥ → A ⊢ B` to `Γ ⊢ B`\n    * simplify `Γ, ⊤ → A ⊢ B` to `Γ, A ⊢ B`\n    * simplify `Γ, A ∧ B → C ⊢ D` to `Γ, A → B → C ⊢ D`\n    * simplify `Γ, A ∨ B → C ⊢ D` to `Γ, A → C, B → C ⊢ D`\n  * `prove`:\n    * `Γ ⊢ ⊤` is true\n    * simplify `Γ ⊢ A → B` to `Γ, A ⊢ B`\n  * `search`:\n    * `Γ, P ⊢ P` is true\n    * simplify `Γ, P, P → A ⊢ B` to `Γ, P, A ⊢ B`\n* level 2: Splitting rules, validity preserving: apply after level 1 rules. Done in `prove`\n  * simplify `Γ ⊢ A ∧ B` to `Γ ⊢ A` and `Γ ⊢ B`\n  * simplify `Γ, A ∨ B ⊢ C` to `Γ, A ⊢ C` and `Γ, B ⊢ C`\n* level 3: Splitting rules, not validity preserving: apply only if nothing else applies.\n  Done in `search`\n  * `Γ ⊢ A ∨ B` follows from `Γ ⊢ A`\n  * `Γ ⊢ A ∨ B` follows from `Γ ⊢ B`\n  * `Γ, (A₁ → A₂) → C ⊢ B` follows from `Γ, A₂ → C, A₁ ⊢ A₂` and `Γ, C ⊢ B`\n\nThis covers the core algorithm, which only handles `true`, `false`, `and`, `or`, and `implies`.\nFor `iff` and `eq`, we treat them essentially the same as `(p → q) ∧ (q → p)`, although we use\na different `prop` representation because we have to remember to apply different theorems during\nreplay. For definitions like `not` and `xor`, we just eagerly unfold them. (This could potentially\ncause a blowup issue for `xor`, but it isn't used very often anyway. We could add it to the `prop`\ngrammar if it matters.)\n\n## Tags\n\npropositional logic, intuitionistic logic, decision procedure\n-/\n\nnamespace tactic\nnamespace itauto\n\n/-- Different propositional constructors that are variants of \"and\" for the purposes of the\ntheorem prover. -/\n@[derive [has_reflect, decidable_eq]]\ninductive and_kind | and | iff | eq\n\ninstance : inhabited and_kind := ⟨and_kind.and⟩\n\n/-- A reified inductive type for propositional logic. -/\n@[derive [has_reflect, decidable_eq]]\ninductive prop : Type\n| var : ℕ → prop            -- propositional atoms P_i\n| true : prop               -- ⊤\n| false : prop              -- ⊥\n| and' : and_kind → prop → prop → prop  -- p ∧ q, p ↔ q, p = q\n| or : prop → prop → prop   -- p ∨ q\n| imp : prop → prop → prop  -- p → q\n\n/-- Constructor for `p ∧ q`. -/\n@[pattern] def prop.and : prop → prop → prop := prop.and' and_kind.and\n/-- Constructor for `p ↔ q`. -/\n@[pattern] def prop.iff : prop → prop → prop := prop.and' and_kind.iff\n/-- Constructor for `p = q`. -/\n@[pattern] def prop.eq : prop → prop → prop := prop.and' and_kind.eq\n/-- Constructor for `¬ p`. -/\n@[pattern] def prop.not (a : prop) : prop := a.imp prop.false\n/-- Constructor for `xor p q`. -/\n@[pattern] def prop.xor (a b : prop) : prop := (a.and b.not).or (b.and a.not)\n\ninstance : inhabited prop := ⟨prop.true⟩\n\n/-- Given the contents of an `and` variant, return the two conjuncts. -/\ndef and_kind.sides : and_kind → prop → prop → prop × prop\n| and_kind.and A B := (A, B)\n| _ A B := (A.imp B, B.imp A)\n\n/-- Debugging printer for propositions. -/\nmeta def prop.to_format : prop → format\n| (prop.var i) := format!\"v{i}\"\n| prop.true := format!\"⊤\"\n| prop.false := format!\"⊥\"\n| (prop.and p q) := format!\"({p.to_format} ∧ {q.to_format})\"\n| (prop.iff p q) := format!\"({p.to_format} ↔ {q.to_format})\"\n| (prop.eq p q) := format!\"({p.to_format} = {q.to_format})\"\n| (prop.or p q) := format!\"({p.to_format} ∨ {q.to_format})\"\n| (prop.imp p q) := format!\"({p.to_format} → {q.to_format})\"\n\nmeta instance : has_to_format prop := ⟨prop.to_format⟩\n\nsection\nopen ordering\n\n/-- A comparator for `and_kind`. (There should really be a derive handler for this.) -/\ndef and_kind.cmp (p q : and_kind) : ordering :=\nby { cases p; cases q, exacts [eq, lt, lt, gt, eq, lt, gt, gt, eq] }\n\n/-- A comparator for propositions. (There should really be a derive handler for this.) -/\ndef prop.cmp (p q : prop) : ordering :=\nbegin\n  induction p with _ ap _ _ p₁ p₂ _ _ p₁ p₂ _ _ p₁ p₂ _ _ p₁ p₂ generalizing q; cases q,\n  case var var { exact cmp p q },\n  case true true { exact eq },\n  case false false { exact eq },\n  case and' and' : aq q₁ q₂ { exact (ap.cmp aq).or_else ((p₁ q₁).or_else (p₂ q₂)) },\n  case or or : q₁ q₂ { exact (p₁ q₁).or_else (p₂ q₂) },\n  case imp imp : q₁ q₂ { exact (p₁ q₁).or_else (p₂ q₂) },\n  exacts [lt, lt, lt, lt, lt,\n          gt, lt, lt, lt, lt,\n          gt, gt, lt, lt, lt,\n          gt, gt, gt, lt, lt,\n          gt, gt, gt, gt, lt,\n          gt, gt, gt, gt, gt]\nend\n\ninstance : has_lt prop := ⟨λ p q, p.cmp q = lt⟩\n\ninstance : decidable_rel (@has_lt.lt prop _) := λ _ _, ordering.decidable_eq _ _\n\nend\n\n/-- A reified inductive proof type for intuitionistic propositional logic. -/\n@[derive has_reflect]\ninductive proof\n-- ⊢ A, causes failure during reconstruction\n| «sorry» : proof\n-- (n: A) ⊢ A\n| hyp (n : name) : proof\n-- ⊢ ⊤\n| triv : proof\n-- (p: ⊥) ⊢ A\n| exfalso' (p : proof) : proof\n-- (p: (x: A) ⊢ B) ⊢ A → B\n| intro (x : name) (p : proof) : proof\n-- ak = and:  (p: A ∧ B) ⊢ A\n-- ak = iff:  (p: A ↔ B) ⊢ A → B\n-- ak = eq:  (p: A = B) ⊢ A → B\n| and_left (ak : and_kind) (p : proof) : proof\n-- ak = and:  (p: A ∧ B) ⊢ B\n-- ak = iff:  (p: A ↔ B) ⊢ B → A\n-- ak = eq:  (p: A = B) ⊢ B → A\n| and_right (ak : and_kind) (p : proof) : proof\n-- ak = and:  (p₁: A) (p₂: B) ⊢ A ∧ B\n-- ak = iff:  (p₁: A → B) (p₁: B → A) ⊢ A ↔ B\n-- ak = eq:  (p₁: A → B) (p₁: B → A) ⊢ A = B\n| and_intro (ak : and_kind) (p₁ p₂ : proof) : proof\n-- ak = and:  (p: A ∧ B → C) ⊢ A → B → C\n-- ak = iff:  (p: (A ↔ B) → C) ⊢ (A → B) → (B → A) → C\n-- ak = eq:  (p: (A = B) → C) ⊢ (A → B) → (B → A) → C\n| curry (ak : and_kind) (p : proof) : proof\n-- This is a partial application of curry.\n-- ak = and:  (p: A ∧ B → C) (q : A) ⊢ B → C\n-- ak = iff:  (p: (A ↔ B) → C) (q: A → B) ⊢ (B → A) → C\n-- ak = eq:  (p: (A ↔ B) → C) (q: A → B) ⊢ (B → A) → C\n| curry₂ (ak : and_kind) (p q : proof) : proof\n-- (p: A → B) (q: A) ⊢ B\n| app' : proof → proof → proof\n-- (p: A ∨ B → C) ⊢ A → C\n| or_imp_left (p : proof) : proof\n-- (p: A ∨ B → C) ⊢ B → C\n| or_imp_right (p : proof) : proof\n-- (p: A) ⊢ A ∨ B\n| or_inl (p : proof) : proof\n-- (p: B) ⊢ A ∨ B\n| or_inr (p : proof) : proof\n-- (p: B) ⊢ A ∨ B\n-- (p₁: A ∨ B) (p₂: (x: A) ⊢ C) (p₃: (x: B) ⊢ C) ⊢ C\n| or_elim' (p₁ : proof) (x : name) (p₂ p₃ : proof) : proof\n-- (p₁: decidable A) (p₂: (x: A) ⊢ C) (p₃: (x: ¬ A) ⊢ C) ⊢ C\n| decidable_elim (classical : bool) (p₁ x : name) (p₂ p₃ : proof) : proof\n-- classical = ff: (p: decidable A) ⊢ A ∨ ¬A\n-- classical = tt: (p: Prop) ⊢ p ∨ ¬p\n| em (classical : bool) (p : name) : proof\n-- The variable x here names the variable that will be used in the elaborated proof\n-- (p: ((x:A) → B) → C) ⊢ B → C\n| imp_imp_simp (x : name) (p : proof) : proof\n\ninstance : inhabited proof := ⟨proof.triv⟩\n\n/-- Debugging printer for proof objects. -/\nmeta def proof.to_format : proof → format\n| proof.sorry := \"sorry\"\n| (proof.hyp i) := to_fmt i\n| proof.triv := \"triv\"\n| (proof.exfalso' p) := format!\"(exfalso {p.to_format})\"\n| (proof.intro x p) := format!\"(λ {x}, {p.to_format})\"\n| (proof.and_left _ p) := format!\"{p.to_format} .1\"\n| (proof.and_right _ p) := format!\"{p.to_format} .2\"\n| (proof.and_intro _ p q) := format!\"⟨{p.to_format}, {q.to_format}⟩\"\n| (proof.curry _ p) := format!\"(curry {p.to_format})\"\n| (proof.curry₂ _ p q) := format!\"(curry {p.to_format} {q.to_format})\"\n| (proof.app' p q) := format!\"({p.to_format} {q.to_format})\"\n| (proof.or_imp_left p) := format!\"(or_imp_left {p.to_format})\"\n| (proof.or_imp_right p) := format!\"(or_imp_right {p.to_format})\"\n| (proof.or_inl p) := format!\"(or.inl {p.to_format})\"\n| (proof.or_inr p) := format!\"(or.inr {p.to_format})\"\n| (proof.or_elim' p x q r) :=\n  format!\"({p.to_format}.elim (λ {x}, {q.to_format}) (λ {x}, {r.to_format})\"\n| (proof.em ff p) := format!\"(decidable.em {p})\"\n| (proof.em tt p) := format!\"(classical.em {p})\"\n| (proof.decidable_elim _ p x q r) :=\n  format!\"({p}.elim (λ {x}, {q.to_format}) (λ {x}, {r.to_format})\"\n| (proof.imp_imp_simp _ p) := format!\"(imp_imp_simp {p.to_format})\"\n\nmeta instance : has_to_format proof := ⟨proof.to_format⟩\n\n/-- A variant on `proof.exfalso'` that performs opportunistic simplification. -/\nmeta def proof.exfalso : prop → proof → proof\n| prop.false p := p\n| A p := proof.exfalso' p\n\n/-- A variant on `proof.or_elim` that performs opportunistic simplification. -/\nmeta def proof.or_elim : proof → name → proof → proof → proof\n| (proof.em cl p) x q r := proof.decidable_elim cl p x q r\n| p x q r := proof.or_elim' p x q r\n\n/-- A variant on `proof.app'` that performs opportunistic simplification.\n(This doesn't do full normalization because we don't want the proof size to blow up.) -/\nmeta def proof.app : proof → proof → proof\n| (proof.curry ak p) q := proof.curry₂ ak p q\n| (proof.curry₂ ak p q) r := p.app (q.and_intro ak r)\n| (proof.or_imp_left p) q := p.app q.or_inl\n| (proof.or_imp_right p) q := p.app q.or_inr\n| (proof.imp_imp_simp x p) q := p.app (proof.intro x q)\n| p q := p.app' q\n\n-- Note(Mario): the typechecker is disabled because it requires proofs to carry around additional\n-- props. These can be retrieved from the git history if you want to re-enable this.\n/-\n/-- A typechecker for the `proof` type. This is not used by the tactic but can be used for\ndebugging. -/\nmeta def proof.check : name_map prop → proof → option prop\n| Γ (proof.hyp i) := Γ.find i\n| Γ proof.triv := some prop.true\n| Γ (proof.exfalso' A p) := guard (p.check Γ = some prop.false) $> A\n| Γ (proof.intro x A p) := do B ← p.check (Γ.insert x A), pure (prop.imp A B)\n| Γ (proof.and_left ak p) := do\n  prop.and' ak' A B ← p.check Γ | none,\n  guard (ak = ak') $> (ak.sides A B).1\n| Γ (proof.and_right ak p) := do\n  prop.and' ak' A B ← p.check Γ | none,\n  guard (ak = ak') $> (ak.sides A B).2\n| Γ (proof.and_intro and_kind.and p q) := do\n  A ← p.check Γ, B ← q.check Γ,\n  pure (A.and B)\n| Γ (proof.and_intro ak p q) := do\n  prop.imp A B ← p.check Γ | none,\n  C ← q.check Γ, guard (C = prop.imp B A) $> (A.and' ak B)\n| Γ (proof.curry ak p) := do\n  prop.imp (prop.and' ak' A B) C ← p.check Γ | none,\n  let (A', B') := ak.sides A B,\n  guard (ak = ak') $> (A'.imp $ B'.imp C)\n| Γ (proof.curry₂ ak p q) := do\n  prop.imp (prop.and' ak' A B) C ← p.check Γ | none,\n  A₂ ← q.check Γ,\n  let (A', B') := ak.sides A B,\n  guard (ak = ak' ∧ A₂ = A') $> (B'.imp C)\n| Γ (proof.app' p q) := do prop.imp A B ← p.check Γ | none, A' ← q.check Γ, guard (A = A') $> B\n| Γ (proof.or_imp_left B p) := do\n  prop.imp (prop.or A B') C ← p.check Γ | none,\n  guard (B = B') $> (A.imp C)\n| Γ (proof.or_imp_right A p) := do\n  prop.imp (prop.or A' B) C ← p.check Γ | none,\n  guard (A = A') $> (B.imp C)\n| Γ (proof.or_inl B p) := do A ← p.check Γ | none, pure (A.or B)\n| Γ (proof.or_inr A p) := do B ← p.check Γ | none, pure (A.or B)\n| Γ (proof.or_elim p x q r) := do\n  prop.or A B ← p.check Γ | none,\n  C ← q.check (Γ.insert x A),\n  C' ← r.check (Γ.insert x B),\n  guard (C = C') $> C\n| Γ (proof.imp_imp_simp x A p) := do\n  prop.imp (prop.imp A' B) C ← p.check Γ | none,\n  guard (A = A') $> (B.imp C)\n-/\n\n/-- Get a new name in the pattern `h0, h1, h2, ...` -/\n@[inline] meta def fresh_name : ℕ → name × ℕ :=\nλ n, (mk_simple_name (\"h\" ++ to_string n), n+1)\n\n/-- The context during proof search is a map from propositions to proof values. -/\nmeta def context := native.rb_map prop proof\n\n/-- Debug printer for the context. -/\nmeta def context.to_format (Γ : context) : format :=\nΓ.fold \"\" $ λ P p f, P.to_format /- ++ \" := \" ++ p.to_format -/ ++ \",\\n\" ++ f\n\nmeta instance : has_to_format context := ⟨context.to_format⟩\n\n/-- Insert a proposition and its proof into the context, as in `have : A := p`. This will eagerly\napply all level 1 rules on the spot, which are rules that don't split the goal and are validity\npreserving: specifically, we drop `⊤` and `A → ⊤` hypotheses, close the goal if we find a `⊥`\nhypothesis, split all conjunctions, and also simplify `⊥ → A` (drop), `⊤ → A` (simplify to `A`),\n`A ∧ B → C` (curry to `A → B → C`) and `A ∨ B → C` (rewrite to `(A → C) ∧ (B → C)` and split). -/\nmeta def context.add : prop → proof → context → except (prop → proof) context\n| prop.true p Γ := pure Γ\n| prop.false p Γ := except.error (λ A, proof.exfalso A p)\n| (prop.and' ak A B) p Γ := do\n  let (A, B) := ak.sides A B,\n  Γ ← Γ.add A (p.and_left ak),\n  Γ.add B (p.and_right ak)\n| (prop.imp prop.false A) p Γ := pure Γ\n| (prop.imp prop.true A) p Γ := Γ.add A (p.app proof.triv)\n| (prop.imp (prop.and' ak A B) C) p Γ :=\n  let (A, B) := ak.sides A B in\n  Γ.add (prop.imp A (B.imp C)) (p.curry ak)\n| (prop.imp (prop.or A B) C) p Γ := do\n  Γ ← Γ.add (A.imp C) p.or_imp_left,\n  Γ.add (B.imp C) p.or_imp_right\n| (prop.imp A prop.true) p Γ := pure Γ\n| A p Γ := pure (Γ.insert A p)\n\n/-- Add `A` to the context `Γ` with proof `p`. This version of `context.add` takes a continuation\nand a target proposition `B`, so that in the case that `⊥` is found we can skip the continuation\nand just prove `B` outright. -/\n@[inline] meta def context.with_add (Γ : context) (A : prop) (p : proof)\n  (B : prop) (f : context → prop → ℕ → bool × proof × ℕ) (n : ℕ) : bool × proof × ℕ :=\nmatch Γ.add A p with\n| except.ok Γ_A := f Γ_A B n\n| except.error p := (tt, p B, n)\nend\n\n/-- Map a function over the proof (regardless of whether the proof is successful or not). -/\ndef map_proof (f : proof → proof) : bool × proof × ℕ → bool × proof × ℕ\n| (b, p, n) := (b, f p, n)\n\n/-- Convert a value-with-success to an optional value. -/\ndef is_ok {α} : bool × α → option α\n| (ff, p) := none\n| (tt, p) := some p\n\n/-- Skip the continuation and return a failed proof if the boolean is false. -/\ndef when_ok : bool → (ℕ → bool × proof × ℕ) → ℕ → bool × proof × ℕ\n| ff f n := (ff, proof.sorry, n)\n| tt f n := f n\n\n/-- The search phase, which deals with the level 3 rules, which are rules that are not validity\npreserving and so require proof search. One obvious one is the or-introduction rule: we prove\n`A ∨ B` by proving `A` or `B`, and we might have to try one and backtrack.\n\nThere are two rules dealing with implication in this category: `p, p → C ⊢ B` where `p` is an\natom (which is safe if we can find it but often requires the right search to expose the `p`\nassumption), and `(A₁ → A₂) → C ⊢ B`. We decompose the double implication into two subgoals: one to\nprove `A₁ → A₂`, which can be written `A₂ → C, A₁ ⊢ A₂` (where we used `A₁` to simplify\n`(A₁ → A₂) → C`), and one to use the consequent, `C ⊢ B`. The search here is that there are\npotentially many implications to split like this, and we have to try all of them if we want to be\ncomplete. -/\nmeta def search (prove : context → prop → ℕ → bool × proof × ℕ) :\n  context → prop → ℕ → bool × proof × ℕ\n| Γ B n := match Γ.find B with\n  | some p := (tt, p, n)\n  | none :=\n    let search₁ := Γ.fold none $ λ A p r, match r with\n    | some r := some r\n    | none := match A with\n      | prop.imp A' C := match Γ.find A' with\n        | some q := is_ok $ context.with_add (Γ.erase A) C (p.app q) B prove n\n        | none := match A' with\n          | prop.imp A₁ A₂ := do\n            let Γ : context := Γ.erase A,\n            let (a, n) := fresh_name n,\n            (p₁, n) ← is_ok $ Γ.with_add A₁ (proof.hyp a) A₂ (λ Γ_A₁ A₂,\n              Γ_A₁.with_add (prop.imp A₂ C) (proof.imp_imp_simp a p) A₂ prove) n,\n            is_ok $ Γ.with_add C (p.app (proof.intro a p₁)) B prove n\n          | _ := none\n          end\n        end\n      | _ := none\n      end\n    end in\n    match search₁ with\n    | some r := (tt, r)\n    | none := match B with\n      | prop.or B₁ B₂ := match map_proof proof.or_inl (prove Γ B₁ n) with\n        | (ff, _) := map_proof proof.or_inr (prove Γ B₂ n)\n        | r := r\n        end\n      | _ := (ff, proof.sorry, n)\n      end\n    end\n  end\n\n/-- The main prover. This receives a context of proven or assumed lemmas and a target proposition,\nand returns a proof or `none` (with state for the fresh variable generator).\nThe intuitionistic logic rules are separated into three groups:\n\n* level 1: No splitting, validity preserving: apply whenever you can.\n  Left rules in `context.add`, right rules in `prove`\n* level 2: Splitting rules, validity preserving: apply after level 1 rules. Done in `prove`\n* level 3: Splitting rules, not validity preserving: apply only if nothing else applies.\n  Done in `search`\n\nThe level 1 rules on the right of the turnstile are `Γ ⊢ ⊤` and `Γ ⊢ A → B`, these are easy to\nhandle. The rule `Γ ⊢ A ∧ B` is a level 2 rule, also handled here. If none of these apply, we try\nthe level 2 rule `A ∨ B ⊢ C` by searching the context and splitting all ors we find. Finally, if\nwe don't make any more progress, we go to the search phase.\n-/\nmeta def prove : context → prop → ℕ → bool × proof × ℕ\n| Γ prop.true n := (tt, proof.triv, n)\n| Γ (prop.imp A B) n :=\n  let (a, n) := fresh_name n in\n  map_proof (proof.intro a) $ Γ.with_add A (proof.hyp a) B prove n\n| Γ (prop.and' ak A B) n :=\n  let (A, B) := ak.sides A B in\n  let (b, p, n) := prove Γ A n in\n  map_proof (p.and_intro ak) $ when_ok b (prove Γ B) n\n| Γ B n := Γ.fold (λ b Γ, cond b prove (search prove) Γ B) (λ A p IH b Γ n,\n    match A with\n    | prop.or A₁ A₂ :=\n      let Γ : context := Γ.erase A in\n      let (a, n) := fresh_name n in\n      let (b, p₁, n) := Γ.with_add A₁ (proof.hyp a) B (λ Γ _, IH tt Γ) n in\n      map_proof (proof.or_elim p a p₁) $\n        when_ok b (Γ.with_add A₂ (proof.hyp a) B (λ Γ _, IH tt Γ)) n\n    | _ := IH b Γ n\n    end) ff Γ n\n\n/-- Reifies an atomic or otherwise unrecognized proposition. If it is defeq to a proposition we\nhave already allocated, we reuse it, otherwise we name it with a new index. -/\nmeta def reify_atom (atoms : ref (buffer expr)) (e : expr) : tactic prop := do\n  vec ← read_ref atoms,\n  o ← try_core $ vec.iterate failure (λ i e' r,\n    r <|> (is_def_eq e e' >> pure i.1)),\n  match o with\n  | none := write_ref atoms (vec.push_back e) $> prop.var vec.size\n  | some i := pure $ prop.var i\n  end\n\n/-- Reify an `expr` into a `prop`, allocating anything non-propositional as an atom in the\n`atoms` list. -/\nmeta def reify (atoms : ref (buffer expr)) : expr → tactic prop\n| `(true) := pure prop.true\n| `(false) := pure prop.false\n| `(¬ %%a) := prop.not <$> reify a\n| `(%%a ∧ %%b) := prop.and <$> reify a <*> reify b\n| `(%%a ∨ %%b) := prop.or <$> reify a <*> reify b\n| `(%%a ↔ %%b) := prop.iff <$> reify a <*> reify b\n| `(xor %%a %%b) := prop.xor <$> reify a <*> reify b\n| `(@eq Prop %%a %%b) := prop.eq <$> reify a <*> reify b\n| `(@ne Prop %%a %%b) := prop.not <$> (prop.eq <$> reify a <*> reify b)\n| `(implies %%a %%b) := prop.imp <$> reify a <*> reify b\n| e@`(%%a → %%b) :=\n  if b.has_var then reify_atom atoms e else prop.imp <$> reify a <*> reify b\n| e := reify_atom atoms e\n\n/-- Once we have a proof object, we have to apply it to the goal. (Some of these cases are a bit\nannoying because `applyc` gets the arguments wrong sometimes so we have to use `to_expr` instead.)\n-/\nmeta def apply_proof : name_map expr → proof → tactic unit\n| Γ proof.sorry := fail \"itauto failed\"\n| Γ (proof.hyp n) := do e ← Γ.find n, exact e\n| Γ proof.triv := triv\n| Γ (proof.exfalso' p) := do\n  t ← mk_mvar, to_expr ``(false.elim %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.intro x p) := do e ← intro_core x, apply_proof (Γ.insert x e) p\n| Γ (proof.and_left and_kind.and p) := do\n  t ← mk_mvar, to_expr ``(and.left %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.and_left and_kind.iff p) := do\n  t ← mk_mvar, to_expr ``(iff.mp %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.and_left and_kind.eq p) := do\n  t ← mk_mvar, to_expr ``(cast %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.and_right and_kind.and p) := do\n  t ← mk_mvar, to_expr ``(and.right %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.and_right and_kind.iff p) := do\n  t ← mk_mvar, to_expr ``(iff.mpr %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.and_right and_kind.eq p) := do\n  t ← mk_mvar, to_expr ``(cast (eq.symm %%t)) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.and_intro and_kind.and p q) := do\n  t₁ ← mk_mvar, t₂ ← mk_mvar, to_expr ``(and.intro %%t₁ %%t₂) tt ff >>= exact,\n  gs ← get_goals, set_goals (t₁::t₂::gs), apply_proof Γ p >> apply_proof Γ q\n| Γ (proof.and_intro and_kind.iff p q) := do\n  t₁ ← mk_mvar, t₂ ← mk_mvar, to_expr ``(iff.intro %%t₁ %%t₂) tt ff >>= exact,\n  gs ← get_goals, set_goals (t₁::t₂::gs), apply_proof Γ p >> apply_proof Γ q\n| Γ (proof.and_intro and_kind.eq p q) := do\n  t₁ ← mk_mvar, t₂ ← mk_mvar, to_expr ``(propext (iff.intro %%t₁ %%t₂)) tt ff >>= exact,\n  gs ← get_goals, set_goals (t₁::t₂::gs), apply_proof Γ p >> apply_proof Γ q\n| Γ (proof.curry ak p) := do\n  e ← intro_core `_, let n := e.local_uniq_name,\n  apply_proof (Γ.insert n e) (proof.curry₂ ak p (proof.hyp n))\n| Γ (proof.curry₂ ak p q) := do\n  e ← intro_core `_, let n := e.local_uniq_name,\n  apply_proof (Γ.insert n e) (p.app (q.and_intro ak (proof.hyp n)))\n| Γ (proof.app' p q) := do\n  A ← mk_meta_var (expr.sort level.zero),\n  B ← mk_meta_var (expr.sort level.zero),\n  g₁ ← mk_meta_var `((%%A : Prop) → (%%B : Prop)),\n  g₂ ← mk_meta_var A,\n  g :: gs ← get_goals,\n  unify (g₁ g₂) g,\n  set_goals (g₁::g₂::gs) >> apply_proof Γ p >> apply_proof Γ q\n| Γ (proof.or_imp_left p) := do\n  e ← intro_core `_, let n := e.local_uniq_name,\n  apply_proof (Γ.insert n e) (p.app (proof.hyp n).or_inl)\n| Γ (proof.or_imp_right p) := do\n  e ← intro_core `_, let n := e.local_uniq_name,\n  apply_proof (Γ.insert n e) (p.app (proof.hyp n).or_inr)\n| Γ (proof.or_inl p) := do\n  t ← mk_mvar, to_expr ``(or.inl %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.or_inr p) := do\n  t ← mk_mvar, to_expr ``(or.inr %%t) tt ff >>= exact,\n  gs ← get_goals, set_goals (t::gs), apply_proof Γ p\n| Γ (proof.or_elim' p x p₁ p₂) := do\n  t₁ ← mk_mvar, t₂ ← mk_mvar, t₃ ← mk_mvar, to_expr ``(or.elim %%t₁ %%t₂ %%t₃) tt ff >>= exact,\n  gs ← get_goals, set_goals (t₁::t₂::t₃::gs), apply_proof Γ p,\n  e ← intro_core x, apply_proof (Γ.insert x e) p₁,\n  e ← intro_core x, apply_proof (Γ.insert x e) p₂\n| Γ (proof.em ff n) := do\n  e ← Γ.find n,\n  to_expr ``(@decidable.em _ %%e) >>= exact\n| Γ (proof.em tt n) := do\n  e ← Γ.find n,\n  to_expr ``(@classical.em %%e) >>= exact\n| Γ (proof.decidable_elim ff n x p₁ p₂) := do\n  e ← Γ.find n,\n  t₁ ← mk_mvar, t₂ ← mk_mvar, to_expr ``(@dite _ _ %%e %%t₁ %%t₂) tt ff >>= exact,\n  gs ← get_goals, set_goals (t₁::t₂::gs),\n  e ← intro_core x, apply_proof (Γ.insert x e) p₁,\n  e ← intro_core x, apply_proof (Γ.insert x e) p₂\n| Γ (proof.decidable_elim tt n x p₁ p₂) := do\n  e ← Γ.find n,\n  e ← to_expr ``(@classical.dec %%e),\n  t₁ ← mk_mvar, t₂ ← mk_mvar, to_expr ``(@dite _ _ %%e %%t₁ %%t₂) tt ff >>= exact,\n  gs ← get_goals, set_goals (t₁::t₂::gs),\n  e ← intro_core x, apply_proof (Γ.insert x e) p₁,\n  e ← intro_core x, apply_proof (Γ.insert x e) p₂\n| Γ (proof.imp_imp_simp x p) := do\n  e ← intro_core `_, let n := e.local_uniq_name,\n  apply_proof (Γ.insert n e) (p.app (proof.intro x (proof.hyp n)))\n\nend itauto\n\nopen itauto\n\n/-- A decision procedure for intuitionistic propositional logic.\n\n* `use_dec` will add `a ∨ ¬ a` to the context for every decidable atomic proposition `a`.\n* `use_classical` will allow `a ∨ ¬ a` to be added even if the proposition is not decidable,\n  using classical logic.\n* `extra_dec` will add `a ∨ ¬ a` to the context for specified (not necessarily atomic)\n  propositions `a`.\n-/\nmeta def itauto (use_dec use_classical : bool) (extra_dec : list expr) : tactic unit :=\nusing_new_ref mk_buffer $ λ atoms,\nusing_new_ref mk_name_map $ λ hs, do\n  t ← target,\n  t ← mcond (is_prop t) (reify atoms t) (tactic.exfalso $> prop.false),\n  hyps ← local_context,\n  (Γ, decs) ← hyps.mfoldl\n    (λ (Γ : except (prop → proof) context × native.rb_map prop (bool × expr)) h, do\n      e ← infer_type h,\n      mcond (is_prop e)\n        (do A ← reify atoms e,\n          let n := h.local_uniq_name,\n          read_ref hs >>= λ Γ, write_ref hs (Γ.insert n h),\n          pure (Γ.1 >>= λ Γ', Γ'.add A (proof.hyp n), Γ.2))\n        (match e with\n        | `(decidable %%p) :=\n          if use_dec then do\n            A ← reify atoms p,\n            let n := h.local_uniq_name,\n            pure (Γ.1, Γ.2.insert A (ff, h))\n          else pure Γ\n        | _ := pure Γ\n        end))\n    (except.ok native.mk_rb_map, native.mk_rb_map),\n  let add_dec (force : bool) (decs : native.rb_map prop (bool × expr)) (e : expr) := (do\n    A ← reify atoms e,\n    dec_e ← mk_app ``decidable [e],\n    res ← try_core (mk_instance dec_e),\n    if res.is_none ∧ ¬ use_classical then\n      if force then do\n        m ← mk_meta_var dec_e,\n        set_goals [m] >> apply_instance >> failure\n      else pure decs\n    else\n      pure (native.rb_map.insert decs A (res.elim (tt, e) (prod.mk ff)))),\n  decs ← extra_dec.mfoldl (add_dec tt) decs,\n  decs ← if use_dec then do\n    let decided := match Γ with\n    | except.ok Γ := Γ.fold native.mk_rb_set $ λ p _ m, match p with\n      | prop.var i := m.insert i\n      | prop.not (prop.var i) := m.insert i\n      | _ := m\n      end\n    | except.error _ := native.mk_rb_set\n    end,\n    read_ref atoms >>= λ ats, ats.2.iterate (pure decs) $ λ i e r,\n      if decided.contains i.1 then r else r >>= λ decs, add_dec ff decs e\n  else pure decs,\n  Γ ← decs.fold (pure Γ) (λ A ⟨cl, pf⟩ r, r >>= λ Γ, do\n    n ← mk_fresh_name,\n    read_ref hs >>= λ Γ, write_ref hs (Γ.insert n pf),\n    pure (Γ >>= λ Γ', Γ'.add (A.or A.not) (proof.em cl n))),\n  let p := match Γ with\n  | except.ok Γ := (prove Γ t 0).2.1\n  | except.error p := p t\n  end,\n  hs ← read_ref hs, apply_proof hs p\n\nnamespace interactive\nsetup_tactic_parser\n\n/-- A decision procedure for intuitionistic propositional logic. Unlike `finish` and `tauto!` this\ntactic never uses the law of excluded middle (without the `!` option), and the proof search is\ntailored for this use case. (`itauto!` will work as a classical SAT solver, but the algorithm is\nnot very good in this situation.)\n\n```lean\nexample (p : Prop) : ¬ (p ↔ ¬ p) := by itauto\n```\n\n`itauto [a, b]` will additionally attempt case analysis on `a` and `b` assuming that it can derive\n`decidable a` and `decidable b`. `itauto *` will case on all decidable propositions that it can\nfind among the atomic propositions, and `itauto! *` will case on all propositional atoms.\n*Warning:* This can blow up the proof search, so it should be used sparingly.\n-/\nmeta def itauto (classical : parse (tk \"!\")?)\n  : parse (some <$> pexpr_list <|> tk \"*\" *> pure none)? → tactic unit\n| none := tactic.itauto false classical.is_some []\n| (some none) := tactic.itauto true classical.is_some []\n| (some (some ls)) := ls.mmap i_to_expr >>= tactic.itauto false classical.is_some\n\nadd_hint_tactic \"itauto\"\n\nadd_tactic_doc\n{ name       := \"itauto\",\n  category   := doc_category.tactic,\n  decl_names := [`tactic.interactive.itauto],\n  tags       := [\"logic\", \"propositional logic\", \"intuitionistic logic\", \"decision procedure\"] }\n\nend interactive\nend tactic\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/tactic/itauto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434873426302, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4944706123163539}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport analysis.calculus.deriv\nimport analysis.analytic.basic\nimport analysis.calculus.cont_diff\n\n/-!\n# Frechet derivatives of analytic functions.\n\nA function expressible as a power series at a point has a Frechet derivative there.\nAlso the special case in terms of `deriv` when the domain is 1-dimensional.\n-/\n\nopen filter asymptotics\nopen_locale ennreal\n\nvariables {𝕜 : Type*} [nontrivially_normed_field 𝕜]\nvariables {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]\nvariables {F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F]\n\nsection fderiv\n\nvariables {p : formal_multilinear_series 𝕜 E F} {r : ℝ≥0∞}\nvariables {f : E → F} {x : E} {s : set E}\n\nlemma has_fpower_series_at.has_strict_fderiv_at (h : has_fpower_series_at f p x) :\n  has_strict_fderiv_at f (continuous_multilinear_curry_fin1 𝕜 E F (p 1)) x :=\nbegin\n  refine h.is_O_image_sub_norm_mul_norm_sub.trans_is_o (is_o.of_norm_right _),\n  refine is_o_iff_exists_eq_mul.2 ⟨λ y, ‖y - (x, x)‖, _, eventually_eq.rfl⟩,\n  refine (continuous_id.sub continuous_const).norm.tendsto' _ _ _,\n  rw [_root_.id, sub_self, norm_zero]\nend\n\nlemma has_fpower_series_at.has_fderiv_at (h : has_fpower_series_at f p x) :\n  has_fderiv_at f (continuous_multilinear_curry_fin1 𝕜 E F (p 1)) x :=\nh.has_strict_fderiv_at.has_fderiv_at\n\nlemma has_fpower_series_at.differentiable_at (h : has_fpower_series_at f p x) :\n  differentiable_at 𝕜 f x :=\nh.has_fderiv_at.differentiable_at\n\nlemma analytic_at.differentiable_at : analytic_at 𝕜 f x → differentiable_at 𝕜 f x\n| ⟨p, hp⟩ := hp.differentiable_at\n\nlemma analytic_at.differentiable_within_at (h : analytic_at 𝕜 f x) :\n  differentiable_within_at 𝕜 f s x :=\nh.differentiable_at.differentiable_within_at\n\nlemma has_fpower_series_at.fderiv_eq (h : has_fpower_series_at f p x) :\n  fderiv 𝕜 f x = continuous_multilinear_curry_fin1 𝕜 E F (p 1) :=\nh.has_fderiv_at.fderiv\n\nlemma has_fpower_series_on_ball.differentiable_on [complete_space F]\n  (h : has_fpower_series_on_ball f p x r) :\n  differentiable_on 𝕜 f (emetric.ball x r) :=\nλ y hy, (h.analytic_at_of_mem hy).differentiable_within_at\n\nlemma analytic_on.differentiable_on (h : analytic_on 𝕜 f s) :\n  differentiable_on 𝕜 f s :=\nλ y hy, (h y hy).differentiable_within_at\n\nlemma has_fpower_series_on_ball.has_fderiv_at [complete_space F]\n  (h : has_fpower_series_on_ball f p x r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :\n  has_fderiv_at f (continuous_multilinear_curry_fin1 𝕜 E F (p.change_origin y 1)) (x + y) :=\n(h.change_origin hy).has_fpower_series_at.has_fderiv_at\n\nlemma has_fpower_series_on_ball.fderiv_eq [complete_space F]\n  (h : has_fpower_series_on_ball f p x r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :\n  fderiv 𝕜 f (x + y) = continuous_multilinear_curry_fin1 𝕜 E F (p.change_origin y 1) :=\n(h.has_fderiv_at hy).fderiv\n\n/-- If a function has a power series on a ball, then so does its derivative. -/\nlemma has_fpower_series_on_ball.fderiv [complete_space F]\n  (h : has_fpower_series_on_ball f p x r) :\n  has_fpower_series_on_ball (fderiv 𝕜 f)\n    ((continuous_multilinear_curry_fin1 𝕜 E F : (E [×1]→L[𝕜] F) →L[𝕜] (E →L[𝕜] F))\n      .comp_formal_multilinear_series (p.change_origin_series 1)) x r :=\nbegin\n  suffices A : has_fpower_series_on_ball\n    (λ z, continuous_multilinear_curry_fin1 𝕜 E F (p.change_origin (z - x) 1))\n      ((continuous_multilinear_curry_fin1 𝕜 E F : (E [×1]→L[𝕜] F) →L[𝕜] (E →L[𝕜] F))\n        .comp_formal_multilinear_series (p.change_origin_series 1)) x r,\n  { apply A.congr,\n    assume z hz,\n    dsimp,\n    rw [← h.fderiv_eq, add_sub_cancel'_right],\n    simpa only [edist_eq_coe_nnnorm_sub, emetric.mem_ball] using hz},\n  suffices B : has_fpower_series_on_ball (λ z, p.change_origin (z - x) 1)\n    (p.change_origin_series 1) x r,\n      from (continuous_multilinear_curry_fin1 𝕜 E F).to_continuous_linear_equiv\n        .to_continuous_linear_map.comp_has_fpower_series_on_ball B,\n  simpa using ((p.has_fpower_series_on_ball_change_origin 1 (h.r_pos.trans_le h.r_le)).mono\n    h.r_pos h.r_le).comp_sub x,\nend\n\n/-- If a function is analytic on a set `s`, so is its Fréchet derivative. -/\nlemma analytic_on.fderiv [complete_space F] (h : analytic_on 𝕜 f s) :\n  analytic_on 𝕜 (fderiv 𝕜 f) s :=\nbegin\n  assume y hy,\n  rcases h y hy with ⟨p, r, hp⟩,\n  exact hp.fderiv.analytic_at,\nend\n\n/-- If a function is analytic on a set `s`, so are its successive Fréchet derivative. -/\nlemma analytic_on.iterated_fderiv [complete_space F] (h : analytic_on 𝕜 f s) (n : ℕ) :\n  analytic_on 𝕜 (iterated_fderiv 𝕜 n f) s :=\nbegin\n  induction n with n IH,\n  { rw iterated_fderiv_zero_eq_comp,\n    exact ((continuous_multilinear_curry_fin0 𝕜 E F).symm : F →L[𝕜] (E [×0]→L[𝕜] F))\n      .comp_analytic_on h },\n  { rw iterated_fderiv_succ_eq_comp_left,\n    apply (continuous_multilinear_curry_left_equiv 𝕜 (λ (i : fin (n + 1)), E) F)\n      .to_continuous_linear_equiv.to_continuous_linear_map.comp_analytic_on,\n    exact IH.fderiv }\nend\n\n/-- An analytic function is infinitely differentiable. -/\nlemma analytic_on.cont_diff_on [complete_space F] (h : analytic_on 𝕜 f s) {n : ℕ∞} :\n  cont_diff_on 𝕜 n f s :=\nbegin\n  let t := {x | analytic_at 𝕜 f x},\n  suffices : cont_diff_on 𝕜 n f t, from this.mono h,\n  have H : analytic_on 𝕜 f t := λ x hx, hx,\n  have t_open : is_open t := is_open_analytic_at 𝕜 f,\n  apply cont_diff_on_of_continuous_on_differentiable_on,\n  { assume m hm,\n    apply (H.iterated_fderiv m).continuous_on.congr,\n    assume x hx,\n    exact iterated_fderiv_within_of_is_open _ t_open hx },\n  { assume m hm,\n    apply (H.iterated_fderiv m).differentiable_on.congr,\n    assume x hx,\n    exact iterated_fderiv_within_of_is_open _ t_open hx }\nend\n\nend fderiv\n\nsection deriv\n\nvariables {p : formal_multilinear_series 𝕜 𝕜 F} {r : ℝ≥0∞}\nvariables {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}\n\nprotected lemma has_fpower_series_at.has_strict_deriv_at (h : has_fpower_series_at f p x) :\n  has_strict_deriv_at f (p 1 (λ _, 1)) x :=\nh.has_strict_fderiv_at.has_strict_deriv_at\n\nprotected lemma has_fpower_series_at.has_deriv_at (h : has_fpower_series_at f p x) :\n  has_deriv_at f (p 1 (λ _, 1)) x :=\nh.has_strict_deriv_at.has_deriv_at\n\nprotected lemma has_fpower_series_at.deriv (h : has_fpower_series_at f p x) :\n  deriv f x = p 1 (λ _, 1) :=\nh.has_deriv_at.deriv\n\n/-- If a function is analytic on a set `s`, so is its derivative. -/\nlemma analytic_on.deriv [complete_space F] (h : analytic_on 𝕜 f s) :\n  analytic_on 𝕜 (deriv f) s :=\n(continuous_linear_map.apply 𝕜 F (1 : 𝕜)).comp_analytic_on h.fderiv\n\n/-- If a function is analytic on a set `s`, so are its successive derivatives. -/\nlemma analytic_on.iterated_deriv [complete_space F] (h : analytic_on 𝕜 f s) (n : ℕ) :\n  analytic_on 𝕜 (deriv^[n] f) s :=\nbegin\n  induction n with n IH,\n  { exact h },\n  { simpa only [function.iterate_succ', function.comp_app] using IH.deriv }\nend\n\nend deriv\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/analysis/calculus/fderiv_analytic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4944706084493044}}
{"text": "/-\nCopyright (c) 2020 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.rat.meta_defs\nimport Mathlib.tactic.norm_num\nimport Mathlib.data.tree\nimport Mathlib.meta.expr\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n# A tactic for canceling numeric denominators\n\nThis file defines tactics that cancel numeric denominators from field expressions.\n\nAs an example, we want to transform a comparison `5*(a/3 + b/4) < c/3` into the equivalent\n`5*(4*a + 3*b) < 4*c`.\n\n## Implementation notes\n\nThe tooling here was originally written for `linarith`, not intended as an interactive tactic.\nThe interactive version has been split off because it is sometimes convenient to use on its own.\nThere are likely some rough edges to it.\n\nImproving this tactic would be a good project for someone interested in learning tactic programming.\n-/\n\nnamespace cancel_factors\n\n\n/-! ### Lemmas used in the procedure -/\n\ntheorem mul_subst {α : Type u_1} [comm_ring α] {n1 : α} {n2 : α} {k : α} {e1 : α} {e2 : α} {t1 : α} {t2 : α} (h1 : n1 * e1 = t1) (h2 : n2 * e2 = t2) (h3 : n1 * n2 = k) : k * (e1 * e2) = t1 * t2 := sorry\n\ntheorem div_subst {α : Type u_1} [field α] {n1 : α} {n2 : α} {k : α} {e1 : α} {e2 : α} {t1 : α} (h1 : n1 * e1 = t1) (h2 : n2 / e2 = 1) (h3 : n1 * n2 = k) : k * (e1 / e2) = t1 := sorry\n\ntheorem cancel_factors_eq_div {α : Type u_1} [field α] {n : α} {e : α} {e' : α} (h : n * e = e') (h2 : n ≠ 0) : e = e' / n :=\n  eq_div_of_mul_eq h2 (eq.mp (Eq._oldrec (Eq.refl (n * e = e')) (mul_comm n e)) h)\n\ntheorem add_subst {α : Type u_1} [ring α] {n : α} {e1 : α} {e2 : α} {t1 : α} {t2 : α} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 + e2) = t1 + t2 := sorry\n\ntheorem sub_subst {α : Type u_1} [ring α] {n : α} {e1 : α} {e2 : α} {t1 : α} {t2 : α} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 - e2) = t1 - t2 := sorry\n\ntheorem neg_subst {α : Type u_1} [ring α] {n : α} {e : α} {t : α} (h1 : n * e = t) : n * -e = -t := sorry\n\ntheorem cancel_factors_lt {α : Type u_1} [linear_ordered_field α] {a : α} {b : α} {ad : α} {bd : α} {a' : α} {b' : α} {gcd : α} (ha : ad * a = a') (hb : bd * b = b') (had : 0 < ad) (hbd : 0 < bd) (hgcd : 0 < gcd) : a < b = (1 / gcd * (bd * a') < 1 / gcd * (ad * b')) := sorry\n\ntheorem cancel_factors_le {α : Type u_1} [linear_ordered_field α] {a : α} {b : α} {ad : α} {bd : α} {a' : α} {b' : α} {gcd : α} (ha : ad * a = a') (hb : bd * b = b') (had : 0 < ad) (hbd : 0 < bd) (hgcd : 0 < gcd) : a ≤ b = (1 / gcd * (bd * a') ≤ 1 / gcd * (ad * b')) := sorry\n\ntheorem cancel_factors_eq {α : Type u_1} [linear_ordered_field α] {a : α} {b : α} {ad : α} {bd : α} {a' : α} {b' : α} {gcd : α} (ha : ad * a = a') (hb : bd * b = b') (had : 0 < ad) (hbd : 0 < bd) (hgcd : 0 < gcd) : a = b = (1 / gcd * (bd * a') = 1 / gcd * (ad * b')) := sorry\n\n/-! ### Computing cancelation factors -/\n\n/--\n`find_cancel_factor e` produces a natural number `n`, such that multiplying `e` by `n` will\nbe able to cancel all the numeric denominators in `e`. The returned `tree` describes how to\ndistribute the value `n` over products inside `e`.\n-/\n/--\n`mk_prod_prf n tr e` produces a proof of `n*e = e'`, where numeric denominators have been\ncanceled in `e'`, distributing `n` proportionally according to `tr`.\n-/\n/--\nGiven `e`, a term with rational division, produces a natural number `n` and a proof of `n*e = e'`,\nwhere `e'` has no division. Assumes \"well-behaved\" division.\n-/\n/--\nGiven `e`, a term with rational divison, produces a natural number `n` and a proof of `e = e' / n`,\nwhere `e'` has no divison. Assumes \"well-behaved\" division.\n-/\n/--\n`find_comp_lemma e` arranges `e` in the form `lhs R rhs`, where `R ∈ {<, ≤, =}`, and returns\n`lhs`, `rhs`, and the `cancel_factors` lemma corresponding to `R`.\n-/\n/--\n`cancel_denominators_in_type h` assumes that `h` is of the form `lhs R rhs`,\nwhere `R ∈ {<, ≤, =, ≥, >}`.\nIt produces an expression `h'` of the form `lhs' R rhs'` and a proof that `h = h'`.\nNumeric denominators have been canceled in `lhs'` and `rhs'`.\n-/\nend cancel_factors\n\n\n/-! ### Interactive version -/\n\n/--\n`cancel_denoms` attempts to remove numerals from the denominators of fractions.\nIt works on propositions that are field-valued inequalities.\n\n```lean\nvariables {α : Type} [linear_ordered_field α] (a b c : α)\n\nexample (h : a / 5 + b / 4 < c) : 4*a + 5*b < 20*c :=\nbegin\n  cancel_denoms at h,\n  exact h\nend\n\nexample (h : a > 0) : a / 5 > 0 :=\nbegin\n  cancel_denoms,\n  exact h\nend\n```\n-/\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/cancel_denoms.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426302, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4944706017249059}}
{"text": "/-\nCopyright (c) 2020 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\nimport linear_algebra.affine_space.affine_map\nimport topology.algebra.group\nimport topology.algebra.mul_action\n\n/-!\n# Topological properties of affine spaces and maps\n\nFor now, this contains only a few facts regarding the continuity of affine maps in the special\ncase when the point space and vector space are the same.\n\nTODO: Deal with the case where the point spaces are different from the vector spaces. Note that\nwe do have some results in this direction under the assumption that the topologies are induced by\n(semi)norms.\n-/\n\nnamespace affine_map\n\nvariables {R E F : Type*}\nvariables [add_comm_group E] [topological_space E]\nvariables [add_comm_group F] [topological_space F] [topological_add_group F]\n\nsection ring\n\nvariables [ring R] [module R E] [module R F]\n\n/-- An affine map is continuous iff its underlying linear map is continuous. See also\n`affine_map.continuous_linear_iff`. -/\nlemma continuous_iff {f : E →ᵃ[R] F} :\n  continuous f ↔ continuous f.linear :=\nbegin\n  split,\n  { intro hc,\n    rw decomp' f,\n    have := hc.sub continuous_const,\n    exact this, },\n  { intro hc,\n    rw decomp f,\n    have := hc.add continuous_const,\n    exact this }\nend\n\n/-- The line map is continuous. -/\n@[continuity]\nlemma line_map_continuous [topological_space R] [has_continuous_smul R F] {p v : F} :\n  continuous ⇑(line_map p v : R →ᵃ[R] F) :=\ncontinuous_iff.mpr $ (continuous_id.smul continuous_const).add $\n  @continuous_const _ _ _ _ (0 : F)\n\nend ring\n\nsection comm_ring\n\nvariables [comm_ring R] [module R F] [topological_space R] [has_continuous_smul R F]\n\n@[continuity]\nlemma homothety_continuous (x : F) (t : R) : continuous $ homothety x t :=\nbegin\n  suffices : ⇑(homothety x t) = λ y, t • (y - x) + x, { rw this, continuity, },\n  ext y,\n  simp [homothety_apply],\nend\n\nend comm_ring\n\nsection field\n\nvariables [field R] [module R F] [topological_space R] [has_continuous_smul R F]\n\nlemma homothety_is_open_map (x : F) (t : R) (ht : t ≠ 0) : is_open_map $ homothety x t :=\nbegin\n  apply is_open_map.of_inverse (homothety_continuous x t⁻¹);\n  intros e;\n  simp [← affine_map.comp_apply, ← homothety_mul, ht],\nend\n\nend field\n\nend affine_map\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/topology/algebra/affine.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.4944254278742047}}
{"text": "example (P Q R : Type) : (P → (Q → R)) → ((P → Q) → (P → R)) :=\nbegin\nintros f g p,\nhave h : Q -> R := f p,\napply h,\nexact g p,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/3-function-world/l6.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4944254264361619}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n\n! This file was ported from Lean 3 source module order.category.PartOrd\n! leanprover-community/mathlib commit e8ac6315bcfcbaf2d19a046719c3b553206dac75\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Antisymmetrization\nimport Mathbin.Order.Category.Preord\n\n/-!\n# Category of partial orders\n\nThis defines `PartOrd`, the category of partial orders with monotone maps.\n-/\n\n\nopen CategoryTheory\n\nuniverse u\n\n/-- The category of partially ordered types. -/\ndef PartOrd :=\n  Bundled PartialOrder\n#align PartOrd PartOrd\n\nnamespace PartOrd\n\ninstance : BundledHom.ParentProjection @PartialOrder.toPreorder :=\n  ⟨⟩\n\nderiving instance LargeCategory, ConcreteCategory for PartOrd\n\ninstance : CoeSort PartOrd (Type _) :=\n  Bundled.hasCoeToSort\n\n/-- Construct a bundled PartOrd from the underlying type and typeclass. -/\ndef of (α : Type _) [PartialOrder α] : PartOrd :=\n  Bundled.of α\n#align PartOrd.of PartOrd.of\n\n@[simp]\ntheorem coe_of (α : Type _) [PartialOrder α] : ↥(of α) = α :=\n  rfl\n#align PartOrd.coe_of PartOrd.coe_of\n\ninstance : Inhabited PartOrd :=\n  ⟨of PUnit⟩\n\ninstance (α : PartOrd) : PartialOrder α :=\n  α.str\n\ninstance hasForgetToPreord : HasForget₂ PartOrd Preord :=\n  BundledHom.forget₂ _ _\n#align PartOrd.has_forget_to_Preord PartOrd.hasForgetToPreord\n\n/-- Constructs an equivalence between partial orders from an order isomorphism between them. -/\n@[simps]\ndef Iso.mk {α β : PartOrd.{u}} (e : α ≃o β) : α ≅ β\n    where\n  Hom := e\n  inv := e.symm\n  hom_inv_id' := by\n    ext\n    exact e.symm_apply_apply x\n  inv_hom_id' := by\n    ext\n    exact e.apply_symm_apply x\n#align PartOrd.iso.mk PartOrd.Iso.mk\n\n/-- `order_dual` as a functor. -/\n@[simps]\ndef dual : PartOrd ⥤ PartOrd where\n  obj X := of Xᵒᵈ\n  map X Y := OrderHom.dual\n#align PartOrd.dual PartOrd.dual\n\n/-- The equivalence between `PartOrd` and itself induced by `order_dual` both ways. -/\n@[simps Functor inverse]\ndef dualEquiv : PartOrd ≌ PartOrd :=\n  Equivalence.mk dual dual\n    (NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun X Y f => rfl)\n    (NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun X Y f => rfl)\n#align PartOrd.dual_equiv PartOrd.dualEquiv\n\nend PartOrd\n\ntheorem partOrd_dual_comp_forget_to_preord :\n    PartOrd.dual ⋙ forget₂ PartOrd Preord = forget₂ PartOrd Preord ⋙ Preord.dual :=\n  rfl\n#align PartOrd_dual_comp_forget_to_Preord partOrd_dual_comp_forget_to_preord\n\n/-- `antisymmetrization` as a functor. It is the free functor. -/\ndef preordToPartOrd : Preord.{u} ⥤ PartOrd\n    where\n  obj X := PartOrd.of (Antisymmetrization X (· ≤ ·))\n  map X Y f := f.Antisymmetrization\n  map_id' X := by\n    ext\n    exact Quotient.inductionOn' x fun x => Quotient.map'_mk'' _ (fun a b => id) _\n  map_comp' X Y Z f g := by\n    ext\n    exact Quotient.inductionOn' x fun x => OrderHom.antisymmetrization_apply_mk _ _\n#align Preord_to_PartOrd preordToPartOrd\n\n/-- `Preord_to_PartOrd` is left adjoint to the forgetful functor, meaning it is the free\nfunctor from `Preord` to `PartOrd`. -/\ndef preordToPartOrdForgetAdjunction : preordToPartOrd.{u} ⊣ forget₂ PartOrd Preord :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f =>\n            ⟨f ∘ toAntisymmetrization (· ≤ ·), f.mono.comp toAntisymmetrization_mono⟩\n          invFun := fun f =>\n            ⟨fun a => Quotient.liftOn' a f fun a b h => (AntisymmRel.image h f.mono).Eq, fun a b =>\n              Quotient.inductionOn₂' a b fun a b h => f.mono h⟩\n          left_inv := fun f =>\n            OrderHom.ext _ _ <| funext fun x => Quotient.inductionOn' x fun x => rfl\n          right_inv := fun f => OrderHom.ext _ _ <| funext fun x => rfl }\n      homEquiv_naturality_left_symm := fun X Y Z f g =>\n        OrderHom.ext _ _ <| funext fun x => Quotient.inductionOn' x fun x => rfl\n      homEquiv_naturality_right := fun X Y Z f g => OrderHom.ext _ _ <| funext fun x => rfl }\n#align Preord_to_PartOrd_forget_adjunction preordToPartOrdForgetAdjunction\n\n/-- `Preord_to_PartOrd` and `order_dual` commute. -/\n@[simps]\ndef preordToPartOrdCompToDualIsoToDualCompPreordToPartOrd :\n    preordToPartOrd.{u} ⋙ PartOrd.dual ≅ Preord.dual ⋙ preordToPartOrd :=\n  NatIso.ofComponents (fun X => PartOrd.Iso.mk <| OrderIso.dualAntisymmetrization _) fun X Y f =>\n    OrderHom.ext _ _ <| funext fun x => Quotient.inductionOn' x fun x => rfl\n#align Preord_to_PartOrd_comp_to_dual_iso_to_dual_comp_Preord_to_PartOrd preordToPartOrdCompToDualIsoToDualCompPreordToPartOrd\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Category/PartOrd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.49442542242787324}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module control.bitraversable.basic\n! leanprover-community/mathlib commit 6f1d45dcccf674593073ee4e54da10ba35aedbc0\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Control.Bifunctor\nimport Mathlib.Control.Traversable.Basic\n\n/-!\n# Bitraversable type class\n\nType class for traversing bifunctors.\n\nSimple examples of `Bitraversable` are `Prod` and `Sum`. A more elaborate example is\nto define an a-list as:\n\n```\ndef AList (key val : Type) := List (key × val)\n```\n\nThen we can use `f : key → IO key'` and `g : val → IO val'` to manipulate the `AList`'s key\nand value respectively with `Bitraverse f g : AList key val → IO (AList key' val')`.\n\n## Main definitions\n\n* `Bitraversable`: Bare typeclass to hold the `Bitraverse` function.\n* `IsLawfulBitraversable`: Typeclass for the laws of the `Bitraverse` function. Similar to\n  `IsLawfulTraversable`.\n\n## References\n\nThe concepts and laws are taken from\n<https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bitraversable.html>\n\n## Tags\n\ntraversable bitraversable iterator functor bifunctor applicative\n-/\n\n\nuniverse u\n\n/-- Lawless bitraversable bifunctor. This only holds data for the bimap and bitraverse. -/\nclass Bitraversable (t : Type u → Type u → Type u) extends Bifunctor t where\n  bitraverse :\n    ∀ {m : Type u → Type u} [Applicative m] {α α' β β'},\n      (α → m α') → (β → m β') → t α β → m (t α' β')\n#align bitraversable Bitraversable\n\nexport Bitraversable (bitraverse)\n\n/-- A bitraversable functor commutes with all applicative functors. -/\ndef bisequence {t m} [Bitraversable t] [Applicative m] {α β} : t (m α) (m β) → m (t α β) :=\n  bitraverse id id\n#align bisequence bisequence\n\nopen Functor\n\n/-- Bifunctor. This typeclass asserts that a lawless bitraversable bifunctor is lawful. -/\nclass IsLawfulBitraversable (t : Type u → Type u → Type u) [Bitraversable t] extends\n  LawfulBifunctor t where\n  -- Porting note: need to specify `m := Id` because `id` no longer has a `Monad` instance\n  id_bitraverse : ∀ {α β} (x : t α β), bitraverse (m := Id) pure pure x = pure x\n  comp_bitraverse :\n    ∀ {F G} [Applicative F] [Applicative G] [LawfulApplicative F] [LawfulApplicative G]\n      {α α' β β' γ γ'} (f : β → F γ) (f' : β' → F γ') (g : α → G β) (g' : α' → G β') (x : t α α'),\n      bitraverse (Comp.mk ∘ map f ∘ g) (Comp.mk ∘ map f' ∘ g') x =\n        Comp.mk (bitraverse f f' <$> bitraverse g g' x)\n  bitraverse_eq_bimap_id :\n    ∀ {α α' β β'} (f : α → β) (f' : α' → β') (x : t α α'),\n      bitraverse (m := Id) (pure ∘ f) (pure ∘ f') x = pure (bimap f f' x)\n  binaturality :\n    ∀ {F G} [Applicative F] [Applicative G] [LawfulApplicative F] [LawfulApplicative G]\n      (η : ApplicativeTransformation F G) {α α' β β'} (f : α → F β) (f' : α' → F β') (x : t α α'),\n      η (bitraverse f f' x) = bitraverse (@η _ ∘ f) (@η _ ∘ f') x\n#align is_lawful_bitraversable IsLawfulBitraversable\n\nexport IsLawfulBitraversable (id_bitraverse comp_bitraverse bitraverse_eq_bimap_id)\n\nopen IsLawfulBitraversable\n\nattribute [higher_order bitraverse_id_id] id_bitraverse\n\nattribute [higher_order bitraverse_comp] comp_bitraverse\n\nattribute [higher_order] binaturality bitraverse_eq_bimap_id\n\nexport IsLawfulBitraversable (bitraverse_id_id bitraverse_comp)\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Control/Bitraversable/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4944254184195845}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.separation\nimport Mathlib.topology.bases\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Dense embeddings\n\nThis file defines three properties of functions:\n\n* `dense_range f`      means `f` has dense image;\n* `dense_inducing i`   means `i` is also `inducing`;\n* `dense_embedding e`  means `e` is also an `embedding`.\n\nThe main theorem `continuous_extend` gives a criterion for a function\n`f : X → Z` to a regular (T₃) space Z to extend along a dense embedding\n`i : X → Y` to a continuous function `g : Y → Z`. Actually `i` only\nhas to be `dense_inducing` (not necessarily injective).\n\n-/\n\n/-- `i : α → β` is \"dense inducing\" if it has dense range and the topology on `α`\n  is the one induced by `i` from the topology on `β`. -/\nstructure dense_inducing {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (i : α → β) \nextends inducing i\nwhere\n  dense : dense_range i\n\nnamespace dense_inducing\n\n\ntheorem nhds_eq_comap {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) (a : α) : nhds a = filter.comap i (nhds (i a)) :=\n  inducing.nhds_eq_comap (to_inducing di)\n\nprotected theorem continuous {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) : continuous i :=\n  inducing.continuous (to_inducing di)\n\ntheorem closure_range {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) : closure (set.range i) = set.univ :=\n  dense_range.closure_range (dense di)\n\ntheorem self_sub_closure_image_preimage_of_open {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} {s : set β} (di : dense_inducing i) : is_open s → s ⊆ closure (i '' (i ⁻¹' s)) := sorry\n\ntheorem closure_image_nhds_of_nhds {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} {s : set α} {a : α} (di : dense_inducing i) : s ∈ nhds a → closure (i '' s) ∈ nhds (i a) := sorry\n\n/-- The product of two dense inducings is a dense inducing -/\nprotected theorem prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] {e₁ : α → β} {e₂ : γ → δ} (de₁ : dense_inducing e₁) (de₂ : dense_inducing e₂) : dense_inducing fun (p : α × γ) => (e₁ (prod.fst p), e₂ (prod.snd p)) :=\n  mk (inducing.mk (inducing.induced (inducing.prod_mk (to_inducing de₁) (to_inducing de₂))))\n    (dense_range.prod_map (dense de₁) (dense de₂))\n\n/-- If the domain of a `dense_inducing` map is a separable space, then so is the codomain. -/\nprotected theorem separable_space {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) [topological_space.separable_space α] : topological_space.separable_space β :=\n  dense_range.separable_space (dense di) (dense_inducing.continuous di)\n\n/--\n γ -f→ α\ng↓     ↓e\n δ -h→ β\n-/\ntheorem tendsto_comap_nhds_nhds {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] {i : α → β} [topological_space δ] {f : γ → α} {g : γ → δ} {h : δ → β} {d : δ} {a : α} (di : dense_inducing i) (H : filter.tendsto h (nhds d) (nhds (i a))) (comm : h ∘ g = i ∘ f) : filter.tendsto f (filter.comap g (nhds d)) (nhds a) := sorry\n\nprotected theorem nhds_within_ne_bot {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) (b : β) : filter.ne_bot (nhds_within b (set.range i)) :=\n  dense_range.nhds_within_ne_bot (dense di) b\n\ntheorem comap_nhds_ne_bot {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) (b : β) : filter.ne_bot (filter.comap i (nhds b)) := sorry\n\n/-- If `i : α → β` is a dense inducing, then any function `f : α → γ` \"extends\"\n  to a function `g = extend di f : β → γ`. If `γ` is Hausdorff and `f` has a\n  continuous extension, then `g` is the unique such extension. In general,\n  `g` might not be continuous or even extend `f`. -/\ndef extend {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} [topological_space γ] (di : dense_inducing i) (f : α → γ) (b : β) : γ :=\n  lim (filter.comap i (nhds b)) f\n\ntheorem extend_eq_of_tendsto {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) [topological_space γ] [t2_space γ] {b : β} {c : γ} {f : α → γ} (hf : filter.tendsto f (filter.comap i (nhds b)) (nhds c)) : extend di f b = c :=\n  filter.tendsto.lim_eq hf\n\ntheorem extend_eq_at {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) [topological_space γ] [t2_space γ] {f : α → γ} (a : α) (hf : continuous_at f a) : extend di f (i a) = f a :=\n  extend_eq_of_tendsto di (nhds_eq_comap di a ▸ hf)\n\ntheorem extend_eq {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} (di : dense_inducing i) [topological_space γ] [t2_space γ] {f : α → γ} (hf : continuous f) (a : α) : extend di f (i a) = f a :=\n  extend_eq_at di a (continuous.continuous_at hf)\n\ntheorem extend_unique_at {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} [topological_space γ] [t2_space γ] {b : β} {f : α → γ} {g : β → γ} (di : dense_inducing i) (hf : filter.eventually (fun (x : α) => g (i x) = f x) (filter.comap i (nhds b))) (hg : continuous_at g b) : extend di f b = g b := sorry\n\ntheorem extend_unique {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} [topological_space γ] [t2_space γ] {f : α → γ} {g : β → γ} (di : dense_inducing i) (hf : ∀ (x : α), g (i x) = f x) (hg : continuous g) : extend di f = g :=\n  funext fun (b : β) => extend_unique_at di (filter.eventually_of_forall hf) (continuous.continuous_at hg)\n\ntheorem continuous_at_extend {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} [topological_space γ] [regular_space γ] {b : β} {f : α → γ} (di : dense_inducing i) (hf : filter.eventually (fun (x : β) => ∃ (c : γ), filter.tendsto f (filter.comap i (nhds x)) (nhds c)) (nhds b)) : continuous_at (extend di f) b := sorry\n\ntheorem continuous_extend {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] {i : α → β} [topological_space γ] [regular_space γ] {f : α → γ} (di : dense_inducing i) (hf : ∀ (b : β), ∃ (c : γ), filter.tendsto f (filter.comap i (nhds b)) (nhds c)) : continuous (extend di f) :=\n  iff.mpr continuous_iff_continuous_at fun (b : β) => continuous_at_extend di (filter.univ_mem_sets' hf)\n\ntheorem mk' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (i : α → β) (c : continuous i) (dense : ∀ (x : β), x ∈ closure (set.range i)) (H : ∀ (a : α) (s : set α) (H : s ∈ nhds a), ∃ (t : set β), ∃ (H : t ∈ nhds (i a)), ∀ (b : α), i b ∈ t → b ∈ s) : dense_inducing i := sorry\n\nend dense_inducing\n\n\n/-- A dense embedding is an embedding with dense image. -/\nstructure dense_embedding {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α → β) \nextends dense_inducing e\nwhere\n  inj : function.injective e\n\ntheorem dense_embedding.mk' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α → β) (c : continuous e) (dense : dense_range e) (inj : function.injective e) (H : ∀ (a : α) (s : set α) (H : s ∈ nhds a), ∃ (t : set β), ∃ (H : t ∈ nhds (e a)), ∀ (b : α), e b ∈ t → b ∈ s) : dense_embedding e := sorry\n\nnamespace dense_embedding\n\n\ntheorem inj_iff {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : α → β} (de : dense_embedding e) {x : α} {y : α} : e x = e y ↔ x = y :=\n  function.injective.eq_iff (inj de)\n\ntheorem to_embedding {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : α → β} (de : dense_embedding e) : embedding e :=\n  embedding.mk (inducing.mk (inducing.induced (dense_inducing.to_inducing (to_dense_inducing de)))) (inj de)\n\n/-- If the domain of a `dense_embedding` is a separable space, then so is its codomain. -/\nprotected theorem separable_space {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : α → β} (de : dense_embedding e) [topological_space.separable_space α] : topological_space.separable_space β :=\n  dense_inducing.separable_space (to_dense_inducing de)\n\n/-- The product of two dense embeddings is a dense embedding. -/\nprotected theorem prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] {e₁ : α → β} {e₂ : γ → δ} (de₁ : dense_embedding e₁) (de₂ : dense_embedding e₂) : dense_embedding fun (p : α × γ) => (e₁ (prod.fst p), e₂ (prod.snd p)) := sorry\n\n/-- The dense embedding of a subtype inside its closure. -/\ndef subtype_emb {β : Type u_2} [topological_space β] {α : Type u_1} (p : α → Prop) (e : α → β) (x : Subtype fun (x : α) => p x) : Subtype fun (x : β) => x ∈ closure (e '' set_of fun (x : α) => p x) :=\n  { val := e ↑x, property := sorry }\n\nprotected theorem subtype {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : α → β} (de : dense_embedding e) (p : α → Prop) : dense_embedding (subtype_emb p e) := sorry\n\nend dense_embedding\n\n\ntheorem is_closed_property {α : Type u_1} {β : Type u_2} [topological_space β] {e : α → β} {p : β → Prop} (he : dense_range e) (hp : is_closed (set_of fun (x : β) => p x)) (h : ∀ (a : α), p (e a)) (b : β) : p b := sorry\n\ntheorem is_closed_property2 {α : Type u_1} {β : Type u_2} [topological_space β] {e : α → β} {p : β → β → Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : β × β) => p (prod.fst q) (prod.snd q))) (h : ∀ (a₁ a₂ : α), p (e a₁) (e a₂)) (b₁ : β) (b₂ : β) : p b₁ b₂ :=\n  (fun (this : ∀ (q : β × β), p (prod.fst q) (prod.snd q)) (b₁ b₂ : β) => this (b₁, b₂))\n    (is_closed_property (dense_range.prod_map he he) hp fun (_x : α × α) => h (prod.fst _x) (prod.snd _x))\n\ntheorem is_closed_property3 {α : Type u_1} {β : Type u_2} [topological_space β] {e : α → β} {p : β → β → β → Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : β × β × β) => p (prod.fst q) (prod.fst (prod.snd q)) (prod.snd (prod.snd q)))) (h : ∀ (a₁ a₂ a₃ : α), p (e a₁) (e a₂) (e a₃)) (b₁ : β) (b₂ : β) (b₃ : β) : p b₁ b₂ b₃ := sorry\n\ntheorem dense_range.induction_on {α : Type u_1} {β : Type u_2} [topological_space β] {e : α → β} (he : dense_range e) {p : β → Prop} (b₀ : β) (hp : is_closed (set_of fun (b : β) => p b)) (ih : ∀ (a : α), p (e a)) : p b₀ :=\n  is_closed_property he hp ih b₀\n\ntheorem dense_range.induction_on₂ {α : Type u_1} {β : Type u_2} [topological_space β] {e : α → β} {p : β → β → Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : β × β) => p (prod.fst q) (prod.snd q))) (h : ∀ (a₁ a₂ : α), p (e a₁) (e a₂)) (b₁ : β) (b₂ : β) : p b₁ b₂ :=\n  is_closed_property2 he hp h b₁ b₂\n\ntheorem dense_range.induction_on₃ {α : Type u_1} {β : Type u_2} [topological_space β] {e : α → β} {p : β → β → β → Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : β × β × β) => p (prod.fst q) (prod.fst (prod.snd q)) (prod.snd (prod.snd q)))) (h : ∀ (a₁ a₂ a₃ : α), p (e a₁) (e a₂) (e a₃)) (b₁ : β) (b₂ : β) (b₃ : β) : p b₁ b₂ b₃ :=\n  is_closed_property3 he hp h b₁ b₂ b₃\n\n/-- Two continuous functions to a t2-space that agree on the dense range of a function are equal. -/\ntheorem dense_range.equalizer {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space β] [topological_space γ] [t2_space γ] {f : α → β} (hfd : dense_range f) {g : β → γ} {h : β → γ} (hg : continuous g) (hh : continuous h) (H : g ∘ f = h ∘ f) : g = h :=\n  funext fun (y : β) => dense_range.induction_on hfd y (is_closed_eq hg hh) (congr_fun H)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/dense_embedding.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4944254136922744}}
{"text": "/-\nCopyright (c) 2022 Yuma Mizuno. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuma Mizuno\n\n! This file was ported from Lean 3 source module category_theory.bicategory.natural_transformation\n! leanprover-community/mathlib commit 4ff75f5b8502275a4c2eb2d2f02bdf84d7fb8993\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Bicategory.Functor\n\n/-!\n# Oplax natural transformations\n\nJust as there are natural transformations between functors, there are oplax natural transformations\nbetween oplax functors. The equality in the naturality of natural transformations is replaced by a\nspecified 2-morphism `F.map f ≫ app b ⟶ app a ≫ G.map f` in the case of oplax natural\ntransformations.\n\n## Main definitions\n\n* `oplax_nat_trans F G` : oplax natural transformations between oplax functors `F` and `G`\n* `oplax_nat_trans.vcomp η θ` : the vertical composition of oplax natural transformations `η`\n  and `θ`\n* `oplax_nat_trans.category F G` : the category structure on the oplax natural transformations\n  between `F` and `G`\n-/\n\n\nnamespace CategoryTheory\n\nopen Category Bicategory\n\nopen Bicategory\n\nuniverse w₁ w₂ v₁ v₂ u₁ u₂\n\nvariable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]\n\n/-- If `η` is an oplax natural transformation between `F` and `G`, we have a 1-morphism\n`η.app a : F.obj a ⟶ G.obj a` for each object `a : B`. We also have a 2-morphism\n`η.naturality f : F.map f ≫ app b ⟶ app a ≫ G.map f` for each 1-morphism `f : a ⟶ b`.\nThese 2-morphisms satisfies the naturality condition, and preserve the identities and\nthe compositions modulo some adjustments of domains and codomains of 2-morphisms.\n-/\nstructure OplaxNatTrans (F G : OplaxFunctor B C) where\n  app (a : B) : F.obj a ⟶ G.obj a\n  naturality {a b : B} (f : a ⟶ b) : F.map f ≫ app b ⟶ app a ≫ G.map f\n  naturality_naturality' :\n    ∀ {a b : B} {f g : a ⟶ b} (η : f ⟶ g),\n      F.zipWith η ▷ app b ≫ naturality g = naturality f ≫ app a ◁ G.zipWith η := by\n    obviously\n  naturality_id' :\n    ∀ a : B,\n      naturality (𝟙 a) ≫ app a ◁ G.map_id a =\n        F.map_id a ▷ app a ≫ (λ_ (app a)).Hom ≫ (ρ_ (app a)).inv := by\n    obviously\n  naturality_comp' :\n    ∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c),\n      naturality (f ≫ g) ≫ app a ◁ G.map_comp f g =\n        F.map_comp f g ▷ app c ≫\n          (α_ _ _ _).Hom ≫\n            F.map f ◁ naturality g ≫ (α_ _ _ _).inv ≫ naturality f ▷ G.map g ≫ (α_ _ _ _).Hom := by\n    obviously\n#align category_theory.oplax_nat_trans CategoryTheory.OplaxNatTrans\n\nrestate_axiom oplax_nat_trans.naturality_naturality'\n\nrestate_axiom oplax_nat_trans.naturality_id'\n\nrestate_axiom oplax_nat_trans.naturality_comp'\n\nattribute [simp, reassoc.1]\n  oplax_nat_trans.naturality_naturality oplax_nat_trans.naturality_id oplax_nat_trans.naturality_comp\n\nnamespace OplaxNatTrans\n\nsection\n\nvariable (F : OplaxFunctor B C)\n\n/-- The identity oplax natural transformation. -/\n@[simps]\ndef id : OplaxNatTrans F F where\n  app a := 𝟙 (F.obj a)\n  naturality a b f := (ρ_ (F.map f)).Hom ≫ (λ_ (F.map f)).inv\n#align category_theory.oplax_nat_trans.id CategoryTheory.OplaxNatTrans.id\n\ninstance : Inhabited (OplaxNatTrans F F) :=\n  ⟨id F⟩\n\nvariable {F} {G H : OplaxFunctor B C} (η : OplaxNatTrans F G) (θ : OplaxNatTrans G H)\n\nsection\n\nvariable {a b c : B} {a' : C}\n\n@[simp, reassoc.1]\ntheorem whiskerLeft_naturality_naturality (f : a' ⟶ G.obj a) {g h : a ⟶ b} (β : g ⟶ h) :\n    f ◁ G.zipWith β ▷ θ.app b ≫ f ◁ θ.naturality h =\n      f ◁ θ.naturality g ≫ f ◁ θ.app a ◁ H.zipWith β :=\n  by simp_rw [← bicategory.whisker_left_comp, naturality_naturality]\n#align category_theory.oplax_nat_trans.whisker_left_naturality_naturality CategoryTheory.OplaxNatTrans.whiskerLeft_naturality_naturality\n\n@[simp, reassoc.1]\ntheorem whiskerRight_naturality_naturality {f g : a ⟶ b} (β : f ⟶ g) (h : G.obj b ⟶ a') :\n    F.zipWith β ▷ η.app b ▷ h ≫ η.naturality g ▷ h =\n      η.naturality f ▷ h ≫ (α_ _ _ _).Hom ≫ η.app a ◁ G.zipWith β ▷ h ≫ (α_ _ _ _).inv :=\n  by rw [← comp_whisker_right, naturality_naturality, comp_whisker_right, whisker_assoc]\n#align category_theory.oplax_nat_trans.whisker_right_naturality_naturality CategoryTheory.OplaxNatTrans.whiskerRight_naturality_naturality\n\n@[simp, reassoc.1]\ntheorem whiskerLeft_naturality_comp (f : a' ⟶ G.obj a) (g : a ⟶ b) (h : b ⟶ c) :\n    f ◁ θ.naturality (g ≫ h) ≫ f ◁ θ.app a ◁ H.map_comp g h =\n      f ◁ G.map_comp g h ▷ θ.app c ≫\n        f ◁ (α_ _ _ _).Hom ≫\n          f ◁ G.map g ◁ θ.naturality h ≫\n            f ◁ (α_ _ _ _).inv ≫ f ◁ θ.naturality g ▷ H.map h ≫ f ◁ (α_ _ _ _).Hom :=\n  by simp_rw [← bicategory.whisker_left_comp, naturality_comp]\n#align category_theory.oplax_nat_trans.whisker_left_naturality_comp CategoryTheory.OplaxNatTrans.whiskerLeft_naturality_comp\n\n@[simp, reassoc.1]\ntheorem whiskerRight_naturality_comp (f : a ⟶ b) (g : b ⟶ c) (h : G.obj c ⟶ a') :\n    η.naturality (f ≫ g) ▷ h ≫ (α_ _ _ _).Hom ≫ η.app a ◁ G.map_comp f g ▷ h =\n      F.map_comp f g ▷ η.app c ▷ h ≫\n        (α_ _ _ _).Hom ▷ h ≫\n          (α_ _ _ _).Hom ≫\n            F.map f ◁ η.naturality g ▷ h ≫\n              (α_ _ _ _).inv ≫\n                (α_ _ _ _).inv ▷ h ≫\n                  η.naturality f ▷ G.map g ▷ h ≫ (α_ _ _ _).Hom ▷ h ≫ (α_ _ _ _).Hom :=\n  by\n  rw [← associator_naturality_middle, ← comp_whisker_right_assoc, naturality_comp]\n  simp\n#align category_theory.oplax_nat_trans.whisker_right_naturality_comp CategoryTheory.OplaxNatTrans.whiskerRight_naturality_comp\n\n@[simp, reassoc.1]\ntheorem whiskerLeft_naturality_id (f : a' ⟶ G.obj a) :\n    f ◁ θ.naturality (𝟙 a) ≫ f ◁ θ.app a ◁ H.map_id a =\n      f ◁ G.map_id a ▷ θ.app a ≫ f ◁ (λ_ (θ.app a)).Hom ≫ f ◁ (ρ_ (θ.app a)).inv :=\n  by simp_rw [← bicategory.whisker_left_comp, naturality_id]\n#align category_theory.oplax_nat_trans.whisker_left_naturality_id CategoryTheory.OplaxNatTrans.whiskerLeft_naturality_id\n\n@[simp, reassoc.1]\ntheorem whiskerRight_naturality_id (f : G.obj a ⟶ a') :\n    η.naturality (𝟙 a) ▷ f ≫ (α_ _ _ _).Hom ≫ η.app a ◁ G.map_id a ▷ f =\n      F.map_id a ▷ η.app a ▷ f ≫ (λ_ (η.app a)).Hom ▷ f ≫ (ρ_ (η.app a)).inv ▷ f ≫ (α_ _ _ _).Hom :=\n  by\n  rw [← associator_naturality_middle, ← comp_whisker_right_assoc, naturality_id]\n  simp\n#align category_theory.oplax_nat_trans.whisker_right_naturality_id CategoryTheory.OplaxNatTrans.whiskerRight_naturality_id\n\nend\n\n/-- Vertical composition of oplax natural transformations. -/\n@[simps]\ndef vcomp (η : OplaxNatTrans F G) (θ : OplaxNatTrans G H) : OplaxNatTrans F H\n    where\n  app a := η.app a ≫ θ.app a\n  naturality a b f :=\n    (α_ _ _ _).inv ≫\n      η.naturality f ▷ θ.app b ≫ (α_ _ _ _).Hom ≫ η.app a ◁ θ.naturality f ≫ (α_ _ _ _).inv\n  naturality_comp' a b c f g :=\n    by\n    calc\n      _ =\n          _ ≫\n            F.map_comp f g ▷ η.app c ▷ θ.app c ≫\n              _ ≫\n                F.map f ◁ η.naturality g ▷ θ.app c ≫\n                  _ ≫\n                    (F.map f ≫ η.app b) ◁ θ.naturality g ≫\n                      η.naturality f ▷ (θ.app b ≫ H.map g) ≫\n                        _ ≫ η.app a ◁ θ.naturality f ▷ H.map g ≫ _ :=\n        _\n      _ = _ := _\n      \n    exact (α_ _ _ _).inv\n    exact (α_ _ _ _).Hom ▷ _ ≫ (α_ _ _ _).Hom\n    exact _ ◁ (α_ _ _ _).Hom ≫ (α_ _ _ _).inv\n    exact (α_ _ _ _).Hom ≫ _ ◁ (α_ _ _ _).inv\n    exact _ ◁ (α_ _ _ _).Hom ≫ (α_ _ _ _).inv\n    · rw [whisker_exchange_assoc]\n      simp\n    · simp\n#align category_theory.oplax_nat_trans.vcomp CategoryTheory.OplaxNatTrans.vcomp\n\nvariable (B C)\n\n@[simps]\ninstance : CategoryStruct (OplaxFunctor B C)\n    where\n  Hom := OplaxNatTrans\n  id := OplaxNatTrans.id\n  comp F G H := OplaxNatTrans.vcomp\n\nend\n\nsection\n\nvariable {F G : OplaxFunctor B C}\n\n/-- A modification `Γ` between oplax natural transformations `η` and `θ` consists of a family of\n2-morphisms `Γ.app a : η.app a ⟶ θ.app a`, which satisfies the equation\n`(F.map f ◁ app b) ≫ θ.naturality f = η.naturality f ≫ (app a ▷ G.map f)`\nfor each 1-morphism `f : a ⟶ b`.\n-/\n@[ext]\nstructure Modification (η θ : F ⟶ G) where\n  app (a : B) : η.app a ⟶ θ.app a\n  naturality' :\n    ∀ {a b : B} (f : a ⟶ b),\n      F.map f ◁ app b ≫ θ.naturality f = η.naturality f ≫ app a ▷ G.map f := by\n    obviously\n#align category_theory.oplax_nat_trans.modification CategoryTheory.OplaxNatTrans.Modification\n\nrestate_axiom modification.naturality'\n\nattribute [simp, reassoc.1] modification.naturality\n\nvariable {η θ ι : F ⟶ G}\n\nnamespace Modification\n\nvariable (η)\n\n/-- The identity modification. -/\n@[simps]\ndef id : Modification η η where app a := 𝟙 (η.app a)\n#align category_theory.oplax_nat_trans.modification.id CategoryTheory.OplaxNatTrans.Modification.id\n\ninstance : Inhabited (Modification η η) :=\n  ⟨Modification.id η⟩\n\nvariable {η}\n\nsection\n\nvariable (Γ : Modification η θ) {a b c : B} {a' : C}\n\n@[simp, reassoc.1]\ntheorem whiskerLeft_naturality (f : a' ⟶ F.obj b) (g : b ⟶ c) :\n    f ◁ F.map g ◁ Γ.app c ≫ f ◁ θ.naturality g = f ◁ η.naturality g ≫ f ◁ Γ.app b ▷ G.map g := by\n  simp_rw [← bicategory.whisker_left_comp, naturality]\n#align category_theory.oplax_nat_trans.modification.whisker_left_naturality CategoryTheory.OplaxNatTrans.Modification.whiskerLeft_naturality\n\n@[simp, reassoc.1]\ntheorem whiskerRight_naturality (f : a ⟶ b) (g : G.obj b ⟶ a') :\n    F.map f ◁ Γ.app b ▷ g ≫ (α_ _ _ _).inv ≫ θ.naturality f ▷ g =\n      (α_ _ _ _).inv ≫ η.naturality f ▷ g ≫ Γ.app a ▷ G.map f ▷ g :=\n  by simp_rw [associator_inv_naturality_middle_assoc, ← comp_whisker_right, naturality]\n#align category_theory.oplax_nat_trans.modification.whisker_right_naturality CategoryTheory.OplaxNatTrans.Modification.whiskerRight_naturality\n\nend\n\n/-- Vertical composition of modifications. -/\n@[simps]\ndef vcomp (Γ : Modification η θ) (Δ : Modification θ ι) : Modification η ι\n    where app a := Γ.app a ≫ Δ.app a\n#align category_theory.oplax_nat_trans.modification.vcomp CategoryTheory.OplaxNatTrans.Modification.vcomp\n\nend Modification\n\n/-- Category structure on the oplax natural transformations between oplax_functors. -/\n@[simps]\ninstance category (F G : OplaxFunctor B C) : Category (F ⟶ G)\n    where\n  Hom := Modification\n  id := Modification.id\n  comp η θ ι := Modification.vcomp\n#align category_theory.oplax_nat_trans.category CategoryTheory.OplaxNatTrans.category\n\n/-- Construct a modification isomorphism between oplax natural transformations\nby giving object level isomorphisms, and checking naturality only in the forward direction.\n-/\n@[simps]\ndef ModificationIso.ofComponents (app : ∀ a, η.app a ≅ θ.app a)\n    (naturality :\n      ∀ {a b} (f : a ⟶ b),\n        F.map f ◁ (app b).Hom ≫ θ.naturality f = η.naturality f ≫ (app a).Hom ▷ G.map f) :\n    η ≅ θ where\n  Hom := { app := fun a => (app a).Hom }\n  inv :=\n    { app := fun a => (app a).inv\n      naturality' := fun a b f => by\n        simpa using congr_arg (fun f => _ ◁ (app b).inv ≫ f ≫ (app a).inv ▷ _) (naturality f).symm }\n#align category_theory.oplax_nat_trans.modification_iso.of_components CategoryTheory.OplaxNatTrans.ModificationIso.ofComponents\n\nend\n\nend OplaxNatTrans\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Bicategory/NaturalTransformation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4944254136922744}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module data.option.n_ary\n! leanprover-community/mathlib commit 995b47e555f1b6297c7cf16855f1023e355219fb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Option.Basic\n\n/-!\n# Binary map of options\n\nThis file defines the binary map of `Option`. This is mostly useful to define pointwise operations\non intervals.\n\n## Main declarations\n\n* `Option.map₂`: Binary map of options.\n\n## Notes\n\nThis file is very similar to the n-ary section of `Mathlib.Data.Set.Basic`, to\n`Mathlib.Data.Finset.NAry` and to `Mathlib.Order.Filter.NAry`. Please keep them in sync.\n(porting note - only some of these may exist right now!)\n\nWe do not define `Option.map₃` as its only purpose so far would be to prove properties of\n`Option.map₂` and casing already fulfills this task.\n-/\n\n\nopen Function\n\nnamespace Option\n\nvariable {f : α → β → γ} {a : Option α} {b : Option β} {c : Option γ}\n\n/-- The image of a binary function `f : α → β → γ` as a function `Option α → Option β → Option γ`.\nMathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/\ndef map₂ (f : α → β → γ) (a : Option α) (b : Option β) : Option γ :=\n  a.bind fun a => b.map <| f a\n#align option.map₂ Option.map₂\n\n/-- `Option.map₂` in terms of monadic operations. Note that this can't be taken as the definition\nbecause of the lack of universe polymorphism. -/\ntheorem map₂_def {α β γ : Type _} (f : α → β → γ) (a : Option α) (b : Option β) :\n    map₂ f a b = f <$> a <*> b :=\n  by cases a <;> rfl\n#align option.map₂_def Option.map₂_def\n\n-- porting note: In Lean3, was `@[simp]` but now `simp` can prove it\ntheorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = f a b := rfl\n#align option.map₂_some_some Option.map₂_some_some\n\ntheorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b := rfl\n#align option.map₂_coe_coe Option.map₂_coe_coe\n\n@[simp]\ntheorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none := rfl\n#align option.map₂_none_left Option.map₂_none_left\n\n@[simp]\ntheorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl\n#align option.map₂_none_right Option.map₂_none_right\n\n@[simp]\ntheorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b :=\n  rfl\n#align option.map₂_coe_left Option.map₂_coe_left\n\n-- porting note: This proof was `rfl` in Lean3, but now is not.\n@[simp]\ntheorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) : map₂ f a b = a.map fun a => f a b :=\n  by cases a <;> rfl\n#align option.map₂_coe_right Option.map₂_coe_right\n\n-- porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal.\ntheorem mem_map₂_iff {c : γ} : c ∈ map₂ f a b ↔ ∃ a' b', a' ∈ a ∧ b' ∈ b ∧ f a' b' = c :=\n  by simp [map₂]\n#align option.mem_map₂_iff Option.mem_map₂_iff\n\n@[simp]\ntheorem map₂_eq_none_iff : map₂ f a b = none ↔ a = none ∨ b = none :=\n  by cases a <;> cases b <;> simp\n#align option.map₂_eq_none_iff Option.map₂_eq_none_iff\n\ntheorem map₂_swap (f : α → β → γ) (a : Option α) (b : Option β) :\n    map₂ f a b = map₂ (fun a b => f b a) b a := by cases a <;> cases b <;> rfl\n#align option.map₂_swap Option.map₂_swap\n\ntheorem map_map₂ (f : α → β → γ) (g : γ → δ) :\n    (map₂ f a b).map g = map₂ (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl\n#align option.map_map₂ Option.map_map₂\n\ntheorem map₂_map_left (f : γ → β → δ) (g : α → γ) :\n    map₂ f (a.map g) b = map₂ (fun a b => f (g a) b) a b := by cases a <;> rfl\n#align option.map₂_map_left Option.map₂_map_left\n\n\n\n@[simp]\ntheorem map₂_curry (f : α × β → γ) (a : Option α) (b : Option β) :\n    map₂ (curry f) a b = Option.map f (map₂ Prod.mk a b) := (map_map₂ _ _).symm\n#align option.map₂_curry Option.map₂_curry\n\n@[simp]\ntheorem map_uncurry (f : α → β → γ) (x : Option (α × β)) :\n    x.map (uncurry f) = map₂ f (x.map Prod.fst) (x.map Prod.snd) := by cases x <;> rfl\n#align option.map_uncurry Option.map_uncurry\n\n/-!\n### Algebraic replacement rules\n\nA collection of lemmas to transfer associativity, commutativity, distributivity, ... of operations\nto the associativity, commutativity, distributivity, ... of `Option.map₂` of those operations.\nThe proof pattern is `map₂_lemma operation_lemma`. For example, `map₂_comm mul_comm` proves that\n`map₂ (*) a b = map₂ (*) g f` in a `CommSemigroup`.\n-/\n\ntheorem map₂_assoc {f : δ → γ → ε} {g : α → β → δ} {f' : α → ε' → ε} {g' : β → γ → ε'}\n    (h_assoc : ∀ a b c, f (g a b) c = f' a (g' b c)) :\n    map₂ f (map₂ g a b) c = map₂ f' a (map₂ g' b c) :=\n  by cases a <;> cases b <;> cases c <;> simp [h_assoc]\n#align option.map₂_assoc Option.map₂_assoc\n\ntheorem map₂_comm {g : β → α → γ} (h_comm : ∀ a b, f a b = g b a) : map₂ f a b = map₂ g b a :=\n  by cases a <;> cases b <;> simp [h_comm]\n#align option.map₂_comm Option.map₂_comm\n\ntheorem map₂_left_comm {f : α → δ → ε} {g : β → γ → δ} {f' : α → γ → δ'} {g' : β → δ' → ε}\n    (h_left_comm : ∀ a b c, f a (g b c) = g' b (f' a c)) :\n    map₂ f a (map₂ g b c) = map₂ g' b (map₂ f' a c) :=\n  by cases a <;> cases b <;> cases c <;> simp [h_left_comm]\n#align option.map₂_left_comm Option.map₂_left_comm\n\ntheorem map₂_right_comm {f : δ → γ → ε} {g : α → β → δ} {f' : α → γ → δ'} {g' : δ' → β → ε}\n    (h_right_comm : ∀ a b c, f (g a b) c = g' (f' a c) b) :\n    map₂ f (map₂ g a b) c = map₂ g' (map₂ f' a c) b :=\n  by cases a <;> cases b <;> cases c <;> simp [h_right_comm]\n#align option.map₂_right_comm Option.map₂_right_comm\n\ntheorem map_map₂_distrib {g : γ → δ} {f' : α' → β' → δ} {g₁ : α → α'} {g₂ : β → β'}\n    (h_distrib : ∀ a b, g (f a b) = f' (g₁ a) (g₂ b)) :\n    (map₂ f a b).map g = map₂ f' (a.map g₁) (b.map g₂) :=\n  by cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map₂_distrib Option.map_map₂_distrib\n\n/-!\nThe following symmetric restatement are needed because unification has a hard time figuring all the\nfunctions if you symmetrize on the spot. This is also how the other n-ary APIs do it.\n-/\n\n/-- Symmetric statement to `Option.map₂_map_left_comm`. -/\ntheorem map_map₂_distrib_left {g : γ → δ} {f' : α' → β → δ} {g' : α → α'}\n    (h_distrib : ∀ a b, g (f a b) = f' (g' a) b) :\n    (map₂ f a b).map g = map₂ f' (a.map g') b := by cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map₂_distrib_left Option.map_map₂_distrib_left\n\n/-- Symmetric statement to `Option.map_map₂_right_comm`. -/\ntheorem map_map₂_distrib_right {g : γ → δ} {f' : α → β' → δ} {g' : β → β'}\n    (h_distrib : ∀ a b, g (f a b) = f' a (g' b)) : (map₂ f a b).map g = map₂ f' a (b.map g') :=\n  by cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map₂_distrib_right Option.map_map₂_distrib_right\n\n/-- Symmetric statement to `Option.map_map₂_distrib_left`. -/\ntheorem map₂_map_left_comm {f : α' → β → γ} {g : α → α'} {f' : α → β → δ} {g' : δ → γ}\n    (h_left_comm : ∀ a b, f (g a) b = g' (f' a b)) : map₂ f (a.map g) b = (map₂ f' a b).map g' :=\n  by cases a <;> cases b <;> simp [h_left_comm]\n#align option.map₂_map_left_comm Option.map₂_map_left_comm\n\n/-- Symmetric statement to `Option.map_map₂_distrib_right`. -/\ntheorem map_map₂_right_comm {f : α → β' → γ} {g : β → β'} {f' : α → β → δ} {g' : δ → γ}\n    (h_right_comm : ∀ a b, f a (g b) = g' (f' a b)) : map₂ f a (b.map g) = (map₂ f' a b).map g' :=\n  by cases a <;> cases b <;> simp [h_right_comm]\n#align option.map_map₂_right_comm Option.map_map₂_right_comm\n\ntheorem map_map₂_antidistrib {g : γ → δ} {f' : β' → α' → δ} {g₁ : β → β'} {g₂ : α → α'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' (g₁ b) (g₂ a)) :\n    (map₂ f a b).map g = map₂ f' (b.map g₁) (a.map g₂) :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map₂_antidistrib Option.map_map₂_antidistrib\n\n/-- Symmetric statement to `Option.map₂_map_left_anticomm`. -/\ntheorem map_map₂_antidistrib_left {g : γ → δ} {f' : β' → α → δ} {g' : β → β'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' (g' b) a) :\n    (map₂ f a b).map g = map₂ f' (b.map g') a :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map₂_antidistrib_left Option.map_map₂_antidistrib_left\n\n/-- Symmetric statement to `Option.map_map₂_right_anticomm`. -/\ntheorem map_map₂_antidistrib_right {g : γ → δ} {f' : β → α' → δ} {g' : α → α'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' b (g' a)) : (map₂ f a b).map g = map₂ f' b (a.map g') :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map₂_antidistrib_right Option.map_map₂_antidistrib_right\n\n/-- Symmetric statement to `Option.map_map₂_antidistrib_left`. -/\ntheorem map₂_map_left_anticomm {f : α' → β → γ} {g : α → α'} {f' : β → α → δ} {g' : δ → γ}\n    (h_left_anticomm : ∀ a b, f (g a) b = g' (f' b a)) :\n    map₂ f (a.map g) b = (map₂ f' b a).map g' := by cases a <;> cases b <;> simp [h_left_anticomm]\n#align option.map₂_map_left_anticomm Option.map₂_map_left_anticomm\n\n/-- Symmetric statement to `Option.map_map₂_antidistrib_right`. -/\ntheorem map_map₂_right_anticomm {f : α → β' → γ} {g : β → β'} {f' : β → α → δ} {g' : δ → γ}\n    (h_right_anticomm : ∀ a b, f a (g b) = g' (f' b a)) :\n    map₂ f a (b.map g) = (map₂ f' b a).map g' := by cases a <;> cases b <;> simp [h_right_anticomm]\n#align option.map_map₂_right_anticomm Option.map_map₂_right_anticomm\n\n/-- If `a` is a left identity for a binary operation `f`, then `some a` is a left identity for\n`Option.map₂ f`. -/\nlemma map₂_left_identity {f : α → β → β} {a : α} (h : ∀ b, f a b = b) (o : Option β) :\n    map₂ f (some a) o = o := by\n  cases o; exacts [rfl, congr_arg some (h _)]\n#align option.map₂_left_identity Option.map₂_left_identity\n\n/-- If `b` is a right identity for a binary operation `f`, then `some b` is a right identity for\n`Option.map₂ f`. -/\nlemma map₂_right_identity {f : α → β → α} {b : β} (h : ∀ a, f a b = a) (o : Option α) :\n    map₂ f o (some b) = o := by\n  simp [h, map₂]\n#align option.map₂_right_identity Option.map₂_right_identity\n\nend Option\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Option/NAry.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7549149868676283, "lm_q1q2_score": 0.494389855944055}}
{"text": "/-\nCopyright (c) 2022 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n\n! This file was ported from Lean 3 source module data.fun_like.fintype\n! leanprover-community/mathlib commit 13a5329a8625701af92e9a96ffc90fa787fff24d\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finite.Basic\nimport Mathbin.Data.Fintype.Basic\nimport Mathbin.Data.FunLike.Basic\n\n/-!\n# Finiteness of `fun_like` types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe show a type `F` with a `fun_like F α β` is finite if both `α` and `β` are finite.\nThis corresponds to the following two pairs of declarations:\n\n * `fun_like.fintype` is a definition stating all `fun_like`s are finite if their domain and\n   codomain are.\n * `fun_like.finite` is a lemma stating all `fun_like`s are finite if their domain and\n   codomain are.\n * `fun_like.fintype'` is a non-dependent version of `fun_like.fintype` and\n * `fun_like.finite` is a non-dependent version of `fun_like.finite`, because dependent instances\n   are harder to infer.\n\nYou can use these to produce instances for specific `fun_like` types.\n(Although there might be options for `fintype` instances with better definitional behaviour.)\nThey can't be instances themselves since they can cause loops.\n-/\n\n\nsection Type\n\nvariable (F G : Type _) {α γ : Type _} {β : α → Type _} [FunLike F α β] [FunLike G α fun _ => γ]\n\n#print FunLike.fintype /-\n/-- All `fun_like`s are finite if their domain and codomain are.\n\nThis is not an instance because specific `fun_like` types might have a better-suited definition.\n\nSee also `fun_like.finite`.\n-/\nnoncomputable def FunLike.fintype [DecidableEq α] [Fintype α] [∀ i, Fintype (β i)] : Fintype F :=\n  Fintype.ofInjective _ FunLike.coe_injective\n#align fun_like.fintype FunLike.fintype\n-/\n\n#print FunLike.fintype' /-\n/-- All `fun_like`s are finite if their domain and codomain are.\n\nNon-dependent version of `fun_like.fintype` that might be easier to infer.\nThis is not an instance because specific `fun_like` types might have a better-suited definition.\n-/\nnoncomputable def FunLike.fintype' [DecidableEq α] [Fintype α] [Fintype γ] : Fintype G :=\n  FunLike.fintype G\n#align fun_like.fintype' FunLike.fintype'\n-/\n\nend Type\n\nsection Sort\n\nvariable (F G : Sort _) {α γ : Sort _} {β : α → Sort _} [FunLike F α β] [FunLike G α fun _ => γ]\n\n/- warning: fun_like.finite -> FunLike.finite is a dubious translation:\nlean 3 declaration is\n  forall (F : Sort.{u1}) {α : Sort.{u2}} {β : α -> Sort.{u3}} [_inst_1 : FunLike.{u1, u2, u3} F α β] [_inst_3 : Finite.{u2} α] [_inst_4 : forall (i : α), Finite.{u3} (β i)], Finite.{u1} F\nbut is expected to have type\n  forall (F : Sort.{u1}) {α : Sort.{u3}} {β : α -> Sort.{u2}} [_inst_1 : FunLike.{u1, u3, u2} F α β] [_inst_3 : Finite.{u3} α] [_inst_4 : forall (i : α), Finite.{u2} (β i)], Finite.{u1} F\nCase conversion may be inaccurate. Consider using '#align fun_like.finite FunLike.finiteₓ'. -/\n/-- All `fun_like`s are finite if their domain and codomain are.\n\nCan't be an instance because it can cause infinite loops.\n-/\ntheorem FunLike.finite [Finite α] [∀ i, Finite (β i)] : Finite F :=\n  Finite.of_injective _ FunLike.coe_injective\n#align fun_like.finite FunLike.finite\n\n/- warning: fun_like.finite' -> FunLike.finite' is a dubious translation:\nlean 3 declaration is\n  forall (G : Sort.{u1}) {α : Sort.{u2}} {γ : Sort.{u3}} [_inst_2 : FunLike.{u1, u2, u3} G α (fun (_x : α) => γ)] [_inst_3 : Finite.{u2} α] [_inst_4 : Finite.{u3} γ], Finite.{u1} G\nbut is expected to have type\n  forall (G : Sort.{u1}) {α : Sort.{u3}} {γ : Sort.{u2}} [_inst_2 : FunLike.{u1, u3, u2} G α (fun (_x : α) => γ)] [_inst_3 : Finite.{u3} α] [_inst_4 : Finite.{u2} γ], Finite.{u1} G\nCase conversion may be inaccurate. Consider using '#align fun_like.finite' FunLike.finite'ₓ'. -/\n/-- All `fun_like`s are finite if their domain and codomain are.\n\nNon-dependent version of `fun_like.finite` that might be easier to infer.\nCan't be an instance because it can cause infinite loops.\n-/\ntheorem FunLike.finite' [Finite α] [Finite γ] : Finite G :=\n  FunLike.finite G\n#align fun_like.finite' FunLike.finite'\n\nend Sort\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/FunLike/Fintype.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.494389852996665}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Filippo A. E. Nuccio\n-/\nimport ring_theory.localization\nimport ring_theory.noetherian\nimport ring_theory.principal_ideal_domain\nimport tactic.field_simp\n\n/-!\n# Fractional ideals\n\nThis file defines fractional ideals of an integral domain and proves basic facts about them.\n\n## Main definitions\nLet `S` be a submonoid of an integral domain `R`, `P` the localization of `R` at `S`, and `f` the\nnatural ring hom from `R` to `P`.\n * `is_fractional` defines which `R`-submodules of `P` are fractional ideals\n * `fractional_ideal f` is the type of fractional ideals in `P`\n * `has_coe (ideal R) (fractional_ideal f)` instance\n * `comm_semiring (fractional_ideal f)` instance:\n   the typical ideal operations generalized to fractional ideals\n * `lattice (fractional_ideal f)` instance\n * `map` is the pushforward of a fractional ideal along an algebra morphism\n\nLet `K` be the localization of `R` at `R \\ {0}` and `g` the natural ring hom from `R` to `K`.\n * `has_div (fractional_ideal g)` instance:\n   the ideal quotient `I / J` (typically written $I : J$, but a `:` operator cannot be defined)\n\n## Main statements\n\n  * `mul_left_mono` and `mul_right_mono` state that ideal multiplication is monotone\n  * `prod_one_self_div_eq` states that `1 / I` is the inverse of `I` if one exists\n  * `is_noetherian` states that very fractional ideal of a noetherian integral domain is noetherian\n\n## Implementation notes\n\nFractional ideals are considered equal when they contain the same elements,\nindependent of the denominator `a : R` such that `a I ⊆ R`.\nThus, we define `fractional_ideal` to be the subtype of the predicate `is_fractional`,\ninstead of having `fractional_ideal` be a structure of which `a` is a field.\n\nMost definitions in this file specialize operations from submodules to fractional ideals,\nproving that the result of this operation is fractional if the input is fractional.\nExceptions to this rule are defining `(+) := (⊔)` and `⊥ := 0`,\nin order to re-use their respective proof terms.\nWe can still use `simp` to show `I.1 + J.1 = (I + J).1` and `⊥.1 = 0.1`.\n\nIn `ring_theory.localization`, we define a copy of the localization map `f`'s codomain `P`\n(`f.codomain`) so that the `R`-algebra instance on `P` can 'know' the map needed to induce\nthe `R`-algebra structure.\n\nWe don't assume that the localization is a field until we need it to define ideal quotients.\nWhen this assumption is needed, we replace `S` with `non_zero_divisors R`, making the localization\na field.\n\n## References\n\n  * https://en.wikipedia.org/wiki/Fractional_ideal\n\n## Tags\n\nfractional ideal, fractional ideals, invertible ideal\n-/\n\nopen localization_map\n\nnamespace ring\n\nsection defs\n\nvariables {R : Type*} [comm_ring R] {S : submonoid R} {P : Type*} [comm_ring P]\n  (f : localization_map S P)\n\n/-- A submodule `I` is a fractional ideal if `a I ⊆ R` for some `a ≠ 0`. -/\ndef is_fractional (I : submodule R f.codomain) :=\n∃ a ∈ S, ∀ b ∈ I, f.is_integer (f.to_map a * b)\n\n/-- The fractional ideals of a domain `R` are ideals of `R` divided by some `a ∈ R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I ⊆ P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I ⊆ R`.\n-/\ndef fractional_ideal :=\n{I : submodule R f.codomain // is_fractional f I}\n\nend defs\n\nnamespace fractional_ideal\n\nopen set\nopen submodule\n\nvariables {R : Type*} [comm_ring R] {S : submonoid R} {P : Type*} [comm_ring P]\n  {f : localization_map S P}\n\ninstance : has_coe (fractional_ideal f) (submodule R f.codomain) := ⟨λ I, I.val⟩\n\n@[simp] lemma val_eq_coe (I : fractional_ideal f) : I.val = I := rfl\n\n@[simp, norm_cast] lemma coe_mk (I : submodule R f.codomain) (hI : is_fractional f I) :\n  (subtype.mk I hI : submodule R f.codomain) = I := rfl\n\ninstance : has_mem P (fractional_ideal f) := ⟨λ x I, x ∈ (I : submodule R f.codomain)⟩\n\nlemma mem_coe {x : f.codomain} {I : fractional_ideal f} :\n  x ∈ (I : submodule R f.codomain) ↔ x ∈ I :=\niff.rfl\n\n/-- Fractional ideals are equal if their submodules are equal.\n\n  Combined with `submodule.ext` this gives that fractional ideals are equal if\n  they have the same elements.\n-/\n@[ext]\nlemma ext {I J : fractional_ideal f} : (I : submodule R f.codomain) = J → I = J :=\nsubtype.ext_iff_val.mpr\n\nlemma ext_iff {I J : fractional_ideal f} : (∀ x, (x ∈ I ↔ x ∈ J)) ↔ I = J :=\n⟨ λ h, ext (submodule.ext h), λ h x, h ▸ iff.rfl ⟩\n\nlemma fractional_of_subset_one (I : submodule R f.codomain)\n  (h : I ≤ (submodule.span R {1})) :\n  is_fractional f I :=\nbegin\n  use [1, S.one_mem],\n  intros b hb,\n  rw [f.to_map.map_one, one_mul],\n  rw ←submodule.one_eq_span at h,\n  obtain ⟨b', b'_mem, b'_eq_b⟩ := h hb,\n  rw (show b = f.to_map b', from b'_eq_b.symm),\n  exact set.mem_range_self b',\nend\n\nlemma is_fractional_of_le {I : submodule R f.codomain} {J : fractional_ideal f}\n  (hIJ : I ≤ J) : is_fractional f I :=\nbegin\n  obtain ⟨a, a_mem, ha⟩ := J.2,\n  use [a, a_mem],\n  intros b b_mem,\n  exact ha b (hIJ b_mem)\nend\n\ninstance coe_to_fractional_ideal : has_coe (ideal R) (fractional_ideal f) :=\n⟨ λ I, ⟨f.coe_submodule I, fractional_of_subset_one _ $ λ x ⟨y, hy, h⟩,\n  submodule.mem_span_singleton.2 ⟨y, by rw ←h; exact mul_one _⟩⟩ ⟩\n\n@[simp, norm_cast] lemma coe_coe_ideal (I : ideal R) :\n  ((I : fractional_ideal f) : submodule R f.codomain) = f.coe_submodule I := rfl\n\n@[simp] lemma mem_coe_ideal {x : f.codomain} {I : ideal R} :\n  x ∈ (I : fractional_ideal f) ↔ ∃ (x' ∈ I), f.to_map x' = x :=\n⟨ λ ⟨x', hx', hx⟩, ⟨x', hx', hx⟩,\n  λ ⟨x', hx', hx⟩, ⟨x', hx', hx⟩ ⟩\n\ninstance : has_zero (fractional_ideal f) := ⟨(0 : ideal R)⟩\n\n@[simp] lemma mem_zero_iff {x : P} : x ∈ (0 : fractional_ideal f) ↔ x = 0 :=\n⟨ (λ ⟨x', x'_mem_zero, x'_eq_x⟩,\n    have x'_eq_zero : x' = 0 := x'_mem_zero,\n    by simp [x'_eq_x.symm, x'_eq_zero]),\n  (λ hx, ⟨0, rfl, by simp [hx]⟩) ⟩\n\n@[simp, norm_cast] lemma coe_zero : ↑(0 : fractional_ideal f) = (⊥ : submodule R f.codomain) :=\nsubmodule.ext $ λ _, mem_zero_iff\n\n@[simp, norm_cast] lemma coe_to_fractional_ideal_bot : ((⊥ : ideal R) : fractional_ideal f) = 0 :=\nrfl\n\n@[simp] lemma exists_mem_to_map_eq {x : R} {I : ideal R} (h : S ≤ non_zero_divisors R) :\n  (∃ x', x' ∈ I ∧ f.to_map x' = f.to_map x) ↔ x ∈ I :=\n⟨λ ⟨x', hx', eq⟩, f.injective h eq ▸ hx', λ h, ⟨x, h, rfl⟩⟩\n\nlemma coe_to_fractional_ideal_injective (h : S ≤ non_zero_divisors R) :\n  function.injective (coe : ideal R → fractional_ideal f) :=\nλ I J heq, have\n  ∀ (x : R), f.to_map x ∈ (I : fractional_ideal f) ↔ f.to_map x ∈ (J : fractional_ideal f) :=\nλ x, heq ▸ iff.rfl,\nideal.ext (by { simpa only [mem_coe_ideal, exists_prop, exists_mem_to_map_eq h] using this })\n\nlemma coe_to_fractional_ideal_eq_zero {I : ideal R} (hS : S ≤ non_zero_divisors R) :\n  (I : fractional_ideal f) = 0 ↔ I = (⊥ : ideal R) :=\n⟨λ h, coe_to_fractional_ideal_injective hS h,\n λ h, by rw [h, coe_to_fractional_ideal_bot]⟩\n\nlemma coe_to_fractional_ideal_ne_zero {I : ideal R} (hS : S ≤ non_zero_divisors R) :\n  (I : fractional_ideal f) ≠ 0 ↔ I ≠ (⊥ : ideal R) :=\nnot_iff_not.mpr (coe_to_fractional_ideal_eq_zero hS)\n\nlemma coe_to_submodule_eq_bot {I : fractional_ideal f} :\n  (I : submodule R f.codomain) = ⊥ ↔ I = 0 :=\n⟨λ h, ext (by simp [h]),\n λ h, by simp [h] ⟩\n\nlemma coe_to_submodule_ne_bot {I : fractional_ideal f} :\n  ↑I ≠ (⊥ : submodule R f.codomain) ↔ I ≠ 0 :=\nnot_iff_not.mpr coe_to_submodule_eq_bot\n\ninstance : inhabited (fractional_ideal f) := ⟨0⟩\n\ninstance : has_one (fractional_ideal f) :=\n⟨(1 : ideal R)⟩\n\nlemma mem_one_iff {x : P} : x ∈ (1 : fractional_ideal f) ↔ ∃ x' : R, f.to_map x' = x :=\niff.intro (λ ⟨x', _, h⟩, ⟨x', h⟩) (λ ⟨x', h⟩, ⟨x', ⟨x', set.mem_univ _, rfl⟩, h⟩)\n\nlemma coe_mem_one (x : R) : f.to_map x ∈ (1 : fractional_ideal f) :=\nmem_one_iff.mpr ⟨x, rfl⟩\n\nlemma one_mem_one : (1 : P) ∈ (1 : fractional_ideal f) :=\nmem_one_iff.mpr ⟨1, f.to_map.map_one⟩\n\n/-- `(1 : fractional_ideal f)` is defined as the R-submodule `f(R) ≤ K`.\n\nHowever, this is not definitionally equal to `1 : submodule R K`,\nwhich is proved in the actual `simp` lemma `coe_one`. -/\nlemma coe_one_eq_coe_submodule_one :\n  ↑(1 : fractional_ideal f) = f.coe_submodule (1 : ideal R) :=\nrfl\n\n@[simp, norm_cast] lemma coe_one :\n  (↑(1 : fractional_ideal f) : submodule R f.codomain) = 1 :=\nbegin\n  simp only [coe_one_eq_coe_submodule_one, ideal.one_eq_top],\n  convert (submodule.one_eq_map_top).symm,\nend\n\nsection lattice\n\n/-!\n### `lattice` section\n\nDefines the order on fractional ideals as inclusion of their underlying sets,\nand ports the lattice structure on submodules to fractional ideals.\n-/\n\ninstance : partial_order (fractional_ideal f) :=\n{ le := λ I J, I.1 ≤ J.1,\n  le_refl := λ I, le_refl I.1,\n  le_antisymm := λ ⟨I, hI⟩ ⟨J, hJ⟩ hIJ hJI, by { congr, exact le_antisymm hIJ hJI },\n  le_trans := λ _ _ _ hIJ hJK, le_trans hIJ hJK }\n\nlemma le_iff_mem {I J : fractional_ideal f} : I ≤ J ↔ (∀ x ∈ I, x ∈ J) :=\niff.rfl\n\n@[simp] lemma coe_le_coe {I J : fractional_ideal f} :\n  (I : submodule R f.codomain) ≤ (J : submodule R f.codomain) ↔ I ≤ J :=\niff.rfl\n\nlemma zero_le (I : fractional_ideal f) : 0 ≤ I :=\nbegin\n  intros x hx,\n  convert submodule.zero_mem _,\n  simpa using hx\nend\n\ninstance order_bot : order_bot (fractional_ideal f) :=\n{ bot := 0,\n  bot_le := zero_le,\n  ..fractional_ideal.partial_order }\n\n@[simp] lemma bot_eq_zero : (⊥ : fractional_ideal f) = 0 :=\nrfl\n\n@[simp] lemma le_zero_iff {I : fractional_ideal f} : I ≤ 0 ↔ I = 0 :=\nle_bot_iff\n\nlemma eq_zero_iff {I : fractional_ideal f} : I = 0 ↔ (∀ x ∈ I, x = (0 : P)) :=\n⟨ (λ h x hx, by simpa [h, mem_zero_iff] using hx),\n  (λ h, le_bot_iff.mp (λ x hx, mem_zero_iff.mpr (h x hx))) ⟩\n\nlemma fractional_sup (I J : fractional_ideal f) : is_fractional f (I.1 ⊔ J.1) :=\nbegin\n  rcases I.2 with ⟨aI, haI, hI⟩,\n  rcases J.2 with ⟨aJ, haJ, hJ⟩,\n  use aI * aJ,\n  use S.mul_mem haI haJ,\n  intros b hb,\n  rcases mem_sup.mp hb with\n    ⟨bI, hbI, bJ, hbJ, hbIJ⟩,\n  rw [←hbIJ, mul_add],\n  apply is_integer_add,\n  { rw [mul_comm aI, f.to_map.map_mul, mul_assoc],\n    apply is_integer_smul (hI bI hbI), },\n  { rw [f.to_map.map_mul, mul_assoc],\n    apply is_integer_smul (hJ bJ hbJ) }\nend\n\nlemma fractional_inf (I J : fractional_ideal f) : is_fractional f (I.1 ⊓ J.1) :=\nbegin\n  rcases I.2 with ⟨aI, haI, hI⟩,\n  use aI,\n  use haI,\n  intros b hb,\n  rcases mem_inf.mp hb with ⟨hbI, hbJ⟩,\n  exact (hI b hbI)\nend\n\ninstance lattice : lattice (fractional_ideal f) :=\n{ inf := λ I J, ⟨I.1 ⊓ J.1, fractional_inf I J⟩,\n  sup := λ I J, ⟨I.1 ⊔ J.1, fractional_sup I J⟩,\n  inf_le_left := λ I J, show I.1 ⊓ J.1 ≤ I.1, from inf_le_left,\n  inf_le_right := λ I J, show I.1 ⊓ J.1 ≤ J.1, from inf_le_right,\n  le_inf := λ I J K hIJ hIK, show I.1 ≤ (J.1 ⊓ K.1), from le_inf hIJ hIK,\n  le_sup_left := λ I J, show I.1 ≤ I.1 ⊔ J.1, from le_sup_left,\n  le_sup_right := λ I J, show J.1 ≤ I.1 ⊔ J.1, from le_sup_right,\n  sup_le := λ I J K hIK hJK, show (I.1 ⊔ J.1) ≤ K.1, from sup_le hIK hJK,\n  ..fractional_ideal.partial_order }\n\ninstance : semilattice_sup_bot (fractional_ideal f) :=\n{ ..fractional_ideal.order_bot, ..fractional_ideal.lattice }\n\n@[simp]\nlemma coe_ideal_le {I : ideal R} {J : fractional_ideal f} :\n  ↑I ≤ J ↔ ∀ x ∈ I, f.to_map x ∈ J :=\n⟨λ h x hx, h ⟨x, hx, rfl⟩,\n λ h x hx, let ⟨x', hx', eq_x⟩ := fractional_ideal.mem_coe_ideal.mp hx in eq_x ▸ h x' hx'⟩\n\nend lattice\n\nsection semiring\n\ninstance : has_add (fractional_ideal f) := ⟨(⊔)⟩\n\n@[simp]\nlemma sup_eq_add (I J : fractional_ideal f) : I ⊔ J = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_add (I J : fractional_ideal f) : (↑(I + J) : submodule R f.codomain) = I + J := rfl\n\nlemma fractional_mul (I J : fractional_ideal f) : is_fractional f (I.1 * J.1) :=\nbegin\n  rcases I with ⟨I, aI, haI, hI⟩,\n  rcases J with ⟨I, aJ, haJ, hJ⟩,\n  use aI * aJ,\n  use S.mul_mem haI haJ,\n  intros b hb,\n  apply submodule.mul_induction_on hb,\n  { intros m hm n hn,\n    obtain ⟨n', hn'⟩ := hJ n hn,\n    rw [f.to_map.map_mul, mul_comm m, ←mul_assoc, mul_assoc _ _ n],\n    erw ←hn', rw mul_assoc,\n    apply hI,\n    exact submodule.smul_mem _ _ hm },\n  { rw [mul_zero],\n    exact ⟨0, f.to_map.map_zero⟩ },\n  { intros x y hx hy,\n    rw [mul_add],\n    apply is_integer_add hx hy },\n  { intros r x hx,\n    show f.is_integer (_ * (f.to_map r * x)),\n    rw [←mul_assoc, ←f.to_map.map_mul, mul_comm _ r, f.to_map.map_mul, mul_assoc],\n    apply is_integer_smul hx },\nend\n\n/-- `fractional_ideal.mul` is the product of two fractional ideals,\nused to define the `has_mul` instance.\n\nThis is only an auxiliary definition: the preferred way of writing `I.mul J` is `I * J`.\n\nElaborated terms involving `fractional_ideal` tend to grow quite large,\nso by making definitions irreducible, we hope to avoid deep unfolds.\n-/\n@[irreducible]\ndef mul (I J : fractional_ideal f) : fractional_ideal f :=\n⟨I.1 * J.1, fractional_mul I J⟩\n\nlocal attribute [semireducible] mul\n\ninstance : has_mul (fractional_ideal f) := ⟨λ I J, mul I J⟩\n\n@[simp] lemma mul_eq_mul (I J : fractional_ideal f) : mul I J = I * J := rfl\n\n@[simp, norm_cast]\nlemma coe_mul (I J : fractional_ideal f) : (↑(I * J) : submodule R f.codomain) = I * J := rfl\n\nlemma mul_left_mono (I : fractional_ideal f) : monotone ((*) I) :=\nλ J J' h, mul_le.mpr (λ x hx y hy, mul_mem_mul hx (h hy))\n\nlemma mul_right_mono (I : fractional_ideal f) : monotone (λ J, J * I) :=\nλ J J' h, mul_le.mpr (λ x hx y hy, mul_mem_mul (h hx) hy)\n\nlemma mul_mem_mul {I J : fractional_ideal f} {i j : f.codomain} (hi : i ∈ I) (hj : j ∈ J) :\n  i * j ∈ I * J := submodule.mul_mem_mul hi hj\n\nlemma mul_le {I J K : fractional_ideal f} :\n  I * J ≤ K ↔ (∀ (i ∈ I) (j ∈ J), i * j ∈ K) :=\nsubmodule.mul_le\n\n@[elab_as_eliminator] protected theorem mul_induction_on\n  {I J : fractional_ideal f}\n  {C : f.codomain → Prop} {r : f.codomain} (hr : r ∈ I * J)\n  (hm : ∀ (i ∈ I) (j ∈ J), C (i * j))\n  (h0 : C 0) (ha : ∀ x y, C x → C y → C (x + y))\n  (hs : ∀ (r : R) x, C x → C (r • x)) : C r :=\nsubmodule.mul_induction_on hr hm h0 ha hs\n\n@[simp, norm_cast]\nlemma coe_ideal_mul (I J : ideal R) :\n  (↑(I * J) : fractional_ideal f) = I * J :=\nbegin\n  apply le_antisymm,\n  { rw fractional_ideal.coe_ideal_le,\n    intros x hx,\n    refine submodule.mul_induction_on hx (λ x hx y hy, _) _ (λ x y hx hy, _) (λ r x hx, _),\n    { rw f.to_map.map_mul,\n      apply fractional_ideal.mul_mem_mul; rw fractional_ideal.mem_coe_ideal,\n      { exact ⟨x, hx, rfl⟩ },\n      { exact ⟨y, hy, rfl⟩ } },\n    { rw f.to_map.map_zero,\n      exact submodule.zero_mem _ },\n    { rw f.to_map.map_add,\n      exact submodule.add_mem _ hx hy },\n    { rw [smul_eq_mul, f.to_map.map_mul],\n      exact submodule.smul_mem _ _ hx } },\n  { rw fractional_ideal.mul_le,\n    intros x hx y hy,\n    obtain ⟨x', hx', rfl⟩ := fractional_ideal.mem_coe_ideal.mp hx,\n    obtain ⟨y', hy', rfl⟩ := fractional_ideal.mem_coe_ideal.mp hy,\n    rw fractional_ideal.mem_coe_ideal,\n    exact ⟨x' * y', ideal.mul_mem_mul hx' hy', f.to_map.map_mul _ _⟩ },\nend\n\ninstance comm_semiring : comm_semiring (fractional_ideal f) :=\n{ add_assoc := λ I J K, sup_assoc,\n  add_comm := λ I J, sup_comm,\n  add_zero := λ I, sup_bot_eq,\n  zero_add := λ I, bot_sup_eq,\n  mul_assoc := λ I J K, ext (submodule.mul_assoc _ _ _),\n  mul_comm := λ I J, ext (submodule.mul_comm _ _),\n  mul_one := λ I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x hx y ⟨y', y'_mem_R, y'_eq_y⟩,\n      rw [←y'_eq_y, mul_comm],\n      exact submodule.smul_mem _ _ hx },\n    { have : x * 1 ∈ (I * 1) := mul_mem_mul h one_mem_one,\n      rwa [mul_one] at this }\n  end,\n  one_mul := λ I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x ⟨x', x'_mem_R, x'_eq_x⟩ y hy,\n      rw ←x'_eq_x,\n      exact submodule.smul_mem _ _ hy },\n    { have : 1 * x ∈ (1 * I) := mul_mem_mul one_mem_one h,\n      rwa [one_mul] at this }\n  end,\n  mul_zero := λ I, eq_zero_iff.mpr (λ x hx, submodule.mul_induction_on hx\n    (λ x hx y hy, by simp [mem_zero_iff.mp hy])\n    rfl\n    (λ x y hx hy, by simp [hx, hy])\n    (λ r x hx, by simp [hx])),\n  zero_mul := λ I, eq_zero_iff.mpr (λ x hx, submodule.mul_induction_on hx\n    (λ x hx y hy, by simp [mem_zero_iff.mp hx])\n    rfl\n    (λ x y hx hy, by simp [hx, hy])\n    (λ r x hx, by simp [hx])),\n  left_distrib := λ I J K, ext (mul_add _ _ _),\n  right_distrib := λ I J K, ext (add_mul _ _ _),\n  ..fractional_ideal.has_zero,\n  ..fractional_ideal.has_add,\n  ..fractional_ideal.has_one,\n  ..fractional_ideal.has_mul }\n\nsection order\n\nlemma add_le_add_left {I J : fractional_ideal f} (hIJ : I ≤ J) (J' : fractional_ideal f) :\n  J' + I ≤ J' + J :=\nsup_le_sup_left hIJ J'\n\nlemma mul_le_mul_left {I J : fractional_ideal f} (hIJ : I ≤ J) (J' : fractional_ideal f) :\n  J' * I ≤ J' * J :=\nmul_le.mpr (λ k hk j hj, mul_mem_mul hk (hIJ hj))\n\nlemma le_self_mul_self {I : fractional_ideal f} (hI: 1 ≤ I) : I ≤ I * I :=\nbegin\n  convert mul_left_mono I hI,\n  exact (mul_one I).symm\nend\n\nlemma mul_self_le_self {I : fractional_ideal f} (hI: I ≤ 1) : I * I ≤ I :=\nbegin\n  convert mul_left_mono I hI,\n  exact (mul_one I).symm\nend\n\nlemma coe_ideal_le_one {I : ideal R} : (I : fractional_ideal f) ≤ 1 :=\nλ x hx, let ⟨y, _, hy⟩ := fractional_ideal.mem_coe_ideal.mp hx\n  in fractional_ideal.mem_one_iff.mpr ⟨y, hy⟩\n\nlemma le_one_iff_exists_coe_ideal {J : fractional_ideal f} :\n  J ≤ (1 : fractional_ideal f) ↔ ∃ (I : ideal R), ↑I = J :=\nbegin\n  split,\n  { intro hJ,\n    refine ⟨⟨{x : R | f.to_map x ∈ J}, _, _, _⟩, _⟩,\n    { rw [mem_set_of_eq, ring_hom.map_zero],\n      exact J.val.zero_mem },\n    { intros a b ha hb,\n      rw [mem_set_of_eq, ring_hom.map_add],\n      exact J.val.add_mem ha hb },\n    { intros c x hx,\n      rw [smul_eq_mul, mem_set_of_eq, ring_hom.map_mul],\n      exact J.val.smul_mem c hx },\n    { ext x,\n      split,\n      { rintros ⟨y, hy, eq_y⟩,\n        rwa ← eq_y },\n      { intro hx,\n        obtain ⟨y, eq_x⟩ := fractional_ideal.mem_one_iff.mp (hJ hx),\n        rw ← eq_x at *,\n        exact ⟨y, hx, rfl⟩ } } },\n  { rintro ⟨I, hI⟩,\n    rw ← hI,\n    apply coe_ideal_le_one },\nend\n\nend order\n\nvariables {P' : Type*} [comm_ring P'] {f' : localization_map S P'}\nvariables {P'' : Type*} [comm_ring P''] {f'' : localization_map S P''}\n\nlemma fractional_map (g : f.codomain →ₐ[R] f'.codomain) (I : fractional_ideal f) :\n  is_fractional f' (submodule.map g.to_linear_map I.1) :=\nbegin\n  rcases I with ⟨I, a, a_nonzero, hI⟩,\n  use [a, a_nonzero],\n  intros b hb,\n  obtain ⟨b', b'_mem, hb'⟩ := submodule.mem_map.mp hb,\n  obtain ⟨x, hx⟩ := hI b' b'_mem,\n  use x,\n  erw [←g.commutes, hx, g.map_smul, hb'],\n  refl\nend\n\n/-- `I.map g` is the pushforward of the fractional ideal `I` along the algebra morphism `g` -/\ndef map (g : f.codomain →ₐ[R] f'.codomain) :\n  fractional_ideal f → fractional_ideal f' :=\nλ I, ⟨submodule.map g.to_linear_map I.1, fractional_map g I⟩\n\n@[simp, norm_cast] lemma coe_map (g : f.codomain →ₐ[R] f'.codomain) (I : fractional_ideal f) :\n  ↑(map g I) = submodule.map g.to_linear_map I := rfl\n\n@[simp] lemma mem_map {I : fractional_ideal f} {g : f.codomain →ₐ[R] f'.codomain}\n  {y : f'.codomain} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y :=\nsubmodule.mem_map\n\nvariables (I J : fractional_ideal f) (g : f.codomain →ₐ[R] f'.codomain)\n\n@[simp] lemma map_id : I.map (alg_hom.id _ _) = I :=\next (submodule.map_id I.1)\n\n@[simp] lemma map_comp (g' : f'.codomain →ₐ[R] f''.codomain) :\n  I.map (g'.comp g) = (I.map g).map g' :=\next (submodule.map_comp g.to_linear_map g'.to_linear_map I.1)\n\n@[simp, norm_cast] lemma map_coe_ideal (I : ideal R) :\n  (I : fractional_ideal f).map g = I :=\nbegin\n  ext x,\n  simp only [coe_coe_ideal, mem_coe_submodule],\n  split,\n  { rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩,\n    exact ⟨y, hy, (g.commutes y).symm⟩ },\n  { rintro ⟨y, hy, rfl⟩,\n    exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ },\nend\n\n@[simp] lemma map_one :\n  (1 : fractional_ideal f).map g = 1 :=\nmap_coe_ideal g 1\n\n@[simp] lemma map_zero :\n  (0 : fractional_ideal f).map g = 0 :=\nmap_coe_ideal g 0\n\n@[simp] lemma map_add : (I + J).map g = I.map g + J.map g :=\next (submodule.map_sup _ _ _)\n\n@[simp] lemma map_mul : (I * J).map g = I.map g * J.map g :=\next (submodule.map_mul _ _ _)\n\n@[simp] lemma map_map_symm (g : f.codomain ≃ₐ[R] f'.codomain) :\n  (I.map (g : f.codomain →ₐ[R] f'.codomain)).map (g.symm : f'.codomain →ₐ[R] f.codomain) = I :=\nby rw [←map_comp, g.symm_comp, map_id]\n\n@[simp] lemma map_symm_map (I : fractional_ideal f') (g : f.codomain ≃ₐ[R] f'.codomain) :\n  (I.map (g.symm : f'.codomain →ₐ[R] f.codomain)).map (g : f.codomain →ₐ[R] f'.codomain) = I :=\nby rw [←map_comp, g.comp_symm, map_id]\n\n/-- If `g` is an equivalence, `map g` is an isomorphism -/\ndef map_equiv (g : f.codomain ≃ₐ[R] f'.codomain) :\n  fractional_ideal f ≃+* fractional_ideal f' :=\n{ to_fun := map g,\n  inv_fun := map g.symm,\n  map_add' := λ I J, map_add I J _,\n  map_mul' := λ I J, map_mul I J _,\n  left_inv := λ I, by { rw [←map_comp, alg_equiv.symm_comp, map_id] },\n  right_inv := λ I, by { rw [←map_comp, alg_equiv.comp_symm, map_id] } }\n\n@[simp] lemma coe_fun_map_equiv (g : f.codomain ≃ₐ[R] f'.codomain) :\n  ⇑(map_equiv g) = map g :=\nrfl\n\n@[simp] lemma map_equiv_apply (g : f.codomain ≃ₐ[R] f'.codomain) (I : fractional_ideal f) :\n  map_equiv g I = map ↑g I := rfl\n\n@[simp] lemma map_equiv_symm (g : f.codomain ≃ₐ[R] f'.codomain) :\n  (map_equiv g).symm = map_equiv g.symm := rfl\n\n@[simp] lemma map_equiv_refl :\n  map_equiv alg_equiv.refl = ring_equiv.refl (fractional_ideal f) :=\nring_equiv.ext (λ x, by simp)\n\nlemma is_fractional_span_iff {s : set f.codomain} :\nis_fractional f (span R s) ↔ ∃ a ∈ S, ∀ (b : P), b ∈ s → f.is_integer (f.to_map a * b) :=\n⟨ λ ⟨a, a_mem, h⟩, ⟨a, a_mem, λ b hb, h b (subset_span hb)⟩,\n  λ ⟨a, a_mem, h⟩, ⟨a, a_mem, λ b hb, span_induction hb\n    h\n    (by { rw mul_zero, exact f.is_integer_zero })\n    (λ x y hx hy, by { rw mul_add, exact is_integer_add hx hy })\n    (λ s x hx, by { rw algebra.mul_smul_comm, exact is_integer_smul hx }) ⟩ ⟩\n\nlemma is_fractional_of_fg {I : submodule R f.codomain} (hI : I.fg) :\n  is_fractional f I :=\nbegin\n  rcases hI with ⟨I, rfl⟩,\n  rcases localization_map.exist_integer_multiples_of_finset f I with ⟨⟨s, hs1⟩, hs⟩,\n  rw is_fractional_span_iff,\n  exact ⟨s, hs1, hs⟩,\nend\n\n/-- `canonical_equiv f f'` is the canonical equivalence between the fractional\nideals in `f.codomain` and in `f'.codomain` -/\n@[irreducible]\nnoncomputable def canonical_equiv (f : localization_map S P) (f' : localization_map S P') :\n  fractional_ideal f ≃+* fractional_ideal f' :=\nmap_equiv\n  { commutes' := λ r, ring_equiv_of_ring_equiv_eq _ _ _,\n    ..ring_equiv_of_ring_equiv f f' (ring_equiv.refl R)\n      (by rw [ring_equiv.to_monoid_hom_refl, submonoid.map_id]) }\n\n@[simp] lemma mem_canonical_equiv_apply {I : fractional_ideal f} {x : f'.codomain} :\n  x ∈ canonical_equiv f f' I ↔\n    ∃ y ∈ I, @localization_map.map _ _ _ _ _ _ _ f (ring_hom.id _) _ (λ ⟨y, hy⟩, hy) _ _ f' y = x :=\nbegin\n  rw [canonical_equiv, map_equiv_apply, mem_map],\n  exact ⟨λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩, λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩⟩\nend\n\n@[simp] lemma canonical_equiv_symm (f : localization_map S P) (f' : localization_map S P') :\n  (canonical_equiv f f').symm = canonical_equiv f' f :=\nring_equiv.ext $ λ I, fractional_ideal.ext_iff.mp $ λ x,\nby { erw [mem_canonical_equiv_apply, canonical_equiv, map_equiv_symm, map_equiv, mem_map],\n    exact ⟨λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩, λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩⟩ }\n\n@[simp] lemma canonical_equiv_flip (f : localization_map S P) (f' : localization_map S P') (I) :\n  canonical_equiv f f' (canonical_equiv f' f I) = I :=\nby rw [←canonical_equiv_symm, ring_equiv.symm_apply_apply]\n\nend semiring\n\nsection fraction_map\n\n/-!\n### `fraction_map` section\n\nThis section concerns fractional ideals in the field of fractions,\ni.e. the type `fractional_ideal g` when `g` is a `fraction_map R K`.\n-/\n\nvariables {K K' : Type*} [field K] [field K'] {g : fraction_map R K} {g' : fraction_map R K'}\nvariables {I J : fractional_ideal g} (h : g.codomain →ₐ[R] g'.codomain)\n\n/-- Nonzero fractional ideals contain a nonzero integer. -/\nlemma exists_ne_zero_mem_is_integer [nontrivial R] (hI : I ≠ 0) :\n  ∃ x ≠ (0 : R), g.to_map x ∈ I :=\nbegin\n  obtain ⟨y, y_mem, y_not_mem⟩ := submodule.exists_of_lt (bot_lt_iff_ne_bot.mpr hI),\n  have y_ne_zero : y ≠ 0 := by simpa using y_not_mem,\n  obtain ⟨z, ⟨x, hx⟩⟩ := g.exists_integer_multiple y,\n  refine ⟨x, _, _⟩,\n  { rw [ne.def, ← g.to_map_eq_zero_iff, hx],\n    exact mul_ne_zero (g.to_map_ne_zero_of_mem_non_zero_divisors _) y_ne_zero },\n  { rw hx,\n    exact smul_mem _ _ y_mem }\nend\n\nlemma map_ne_zero [nontrivial R] (hI : I ≠ 0) : I.map h ≠ 0 :=\nbegin\n  obtain ⟨x, x_ne_zero, hx⟩ := exists_ne_zero_mem_is_integer hI,\n  contrapose! x_ne_zero with map_eq_zero,\n  refine g'.to_map_eq_zero_iff.mp (eq_zero_iff.mp map_eq_zero _ (mem_map.mpr _)),\n  exact ⟨g.to_map x, hx, h.commutes x⟩,\nend\n\n@[simp] lemma map_eq_zero_iff [nontrivial R] : I.map h = 0 ↔ I = 0 :=\n⟨imp_of_not_imp_not _ _ (map_ne_zero _),\n λ hI, hI.symm ▸ map_zero h⟩\n\n@[simp, norm_cast]\nlemma coe_ideal_le_coe_ideal {I J : ideal R} :\n(I : fractional_ideal g) ≤ (J : fractional_ideal g) ↔ I ≤ J :=\nbegin\n  split,\n  { intros h x hI,\n    rw le_iff_mem at h,\n    specialize h (g.to_map x),\n    simp only [mem_coe_ideal, exists_prop, exists_mem_to_map_eq] at h,\n    exact h hI },\n  { rintros h x hx,\n    simp only [val_eq_coe, coe_coe_ideal, localization_map.mem_coe_submodule] at hx ⊢,\n    obtain ⟨y, hy, y_eq⟩ := hx,\n    exact ⟨y, h hy, y_eq⟩ },\nend\n\nend fraction_map\n\nsection quotient\n\n/-!\n### `quotient` section\n\nThis section defines the ideal quotient of fractional ideals.\n\nIn this section we need that each non-zero `y : R` has an inverse in\nthe localization, i.e. that the localization is a field. We satisfy this\nassumption by taking `S = non_zero_divisors R`, `R`'s localization at which\nis a field because `R` is a domain.\n-/\n\nopen_locale classical\n\nvariables {R₁ : Type*} [integral_domain R₁] {K : Type*} [field K] {g : fraction_map R₁ K}\n\ninstance : nontrivial (fractional_ideal g) :=\n⟨⟨0, 1, λ h,\n  have this : (1 : K) ∈ (0 : fractional_ideal g) :=\n    by rw ←g.to_map.map_one; convert coe_mem_one _,\n  one_ne_zero (mem_zero_iff.mp this) ⟩⟩\n\nlemma fractional_div_of_nonzero {I J : fractional_ideal g} (h : J ≠ 0) :\n  is_fractional g (I.1 / J.1) :=\nbegin\n  rcases I with ⟨I, aI, haI, hI⟩,\n  rcases J with ⟨J, aJ, haJ, hJ⟩,\n  obtain ⟨y, mem_J, not_mem_zero⟩ := exists_of_lt (bot_lt_iff_ne_bot.mpr h),\n  obtain ⟨y', hy'⟩ := hJ y mem_J,\n  use (aI * y'),\n  split,\n  { apply (non_zero_divisors R₁).mul_mem haI (mem_non_zero_divisors_iff_ne_zero.mpr _),\n    intro y'_eq_zero,\n    have : g.to_map aJ * y = 0 := by rw [←hy', y'_eq_zero, g.to_map.map_zero],\n    obtain aJ_zero | y_zero := mul_eq_zero.mp this,\n    { have : aJ = 0 := g.to_map.injective_iff.1 g.injective _ aJ_zero,\n      have : aJ ≠ 0 := mem_non_zero_divisors_iff_ne_zero.mp haJ,\n      contradiction },\n    { exact not_mem_zero (mem_zero_iff.mpr y_zero) } },\n  intros b hb,\n  rw [g.to_map.map_mul, mul_assoc, mul_comm _ b, hy'],\n  exact hI _ (hb _ (submodule.smul_mem _ aJ mem_J)),\nend\n\nnoncomputable instance fractional_ideal_has_div :\n  has_div (fractional_ideal g) :=\n⟨ λ I J, if h : J = 0 then 0 else ⟨I.1 / J.1, fractional_div_of_nonzero h⟩ ⟩\n\nvariables {I J : fractional_ideal g} [ J ≠ 0 ]\n\n@[simp] lemma div_zero {I : fractional_ideal g} :\n  I / 0 = 0 :=\ndif_pos rfl\n\nlemma div_nonzero {I J : fractional_ideal g} (h : J ≠ 0) :\n  (I / J) = ⟨I.1 / J.1, fractional_div_of_nonzero h⟩ :=\ndif_neg h\n\n@[simp] lemma coe_div {I J : fractional_ideal g} (hJ : J ≠ 0) :\n  (↑(I / J) : submodule R₁ g.codomain) = ↑I / (↑J : submodule R₁ g.codomain) :=\nbegin\n  unfold has_div.div,\n  simp only [dif_neg hJ, coe_mk, val_eq_coe],\nend\n\nlemma mem_div_iff_of_nonzero {I J : fractional_ideal g} (h : J ≠ 0) {x} :\n  x ∈ I / J ↔ ∀ y ∈ J, x * y ∈ I :=\nby { rw div_nonzero h, exact submodule.mem_div_iff_forall_mul_mem }\n\nlemma mul_one_div_le_one {I : fractional_ideal g} : I * (1 / I) ≤ 1 :=\nbegin\n  by_cases hI : I = 0,\n  { rw [hI, div_zero, mul_zero],\n    exact zero_le 1 },\n  { rw [← coe_le_coe, coe_mul, coe_div hI, coe_one],\n    apply submodule.mul_one_div_le_one },\nend\n\nlemma le_self_mul_one_div {I : fractional_ideal g} (hI : I ≤ (1 : fractional_ideal g)) :\n  I ≤ I * (1 / I) :=\nbegin\n  by_cases hI_nz : I = 0,\n  { rw [hI_nz, div_zero, mul_zero], exact zero_le 0 },\n  { rw [← coe_le_coe, coe_mul, coe_div hI_nz, coe_one],\n    rw [← coe_le_coe, coe_one] at hI,\n    exact submodule.le_self_mul_one_div hI },\nend\n\nlemma le_div_iff_of_nonzero {I J J' : fractional_ideal g} (hJ' : J' ≠ 0) :\n  I ≤ J / J' ↔ ∀ (x ∈ I) (y ∈ J'), x * y ∈ J :=\n⟨ λ h x hx, (mem_div_iff_of_nonzero hJ').mp (h hx),\n  λ h x hx, (mem_div_iff_of_nonzero hJ').mpr (h x hx) ⟩\n\nlemma le_div_iff_mul_le {I J J' : fractional_ideal g} (hJ' : J' ≠ 0) : I ≤ J / J' ↔ I * J' ≤ J :=\nbegin\n  rw div_nonzero hJ',\n  convert submodule.le_div_iff_mul_le using 1,\n  rw [val_eq_coe, val_eq_coe, ←coe_mul],\n  refl,\nend\n\nlemma mul_one_div_le_div {I J : fractional_ideal g} : I * (1 / J) ≤ I / J :=\nif hJ : J = 0 then by simp [hJ] else (le_div_iff_mul_le hJ).mpr $\ncalc I * (1 / J) * J\n    = I * (J * (1 / J)) : by rw [mul_assoc, mul_comm (1 / J)]\n... ≤ I * 1 : mul_left_mono _ mul_one_div_le_one\n... = I : mul_one _\n\n@[simp] lemma div_one {I : fractional_ideal g} : I / 1 = I :=\nbegin\n  rw [div_nonzero (@one_ne_zero (fractional_ideal g) _ _)],\n  ext,\n  split; intro h,\n  { convert mem_div_iff_forall_mul_mem.mp h 1\n      (g.to_map.map_one ▸ coe_mem_one 1), simp },\n  { apply mem_div_iff_forall_mul_mem.mpr,\n    rintros y ⟨y', _, y_eq_y'⟩,\n    rw mul_comm,\n    convert submodule.smul_mem _ y' h,\n    rw ←y_eq_y',\n    refl }\nend\n\nlemma ne_zero_of_mul_eq_one (I J : fractional_ideal g) (h : I * J = 1) : I ≠ 0 :=\nλ hI, @zero_ne_one (fractional_ideal g) _ _ (by { convert h, simp [hI], })\n\n\ntheorem eq_one_div_of_mul_eq_one (I J : fractional_ideal g) (h : I * J = 1) :\n  J = 1 / I :=\nbegin\n  have hI : I ≠ 0 := ne_zero_of_mul_eq_one I J h,\n  suffices h' : I * (1 / I) = 1,\n  { exact (congr_arg units.inv $\n      @units.ext _ _ (units.mk_of_mul_eq_one _ _ h) (units.mk_of_mul_eq_one _ _ h') rfl) },\n  apply le_antisymm,\n  { apply mul_le.mpr _,\n    intros x hx y hy,\n    rw mul_comm,\n    exact (mem_div_iff_of_nonzero hI).mp hy x hx },\n  rw ← h,\n  apply mul_left_mono I,\n  apply (le_div_iff_of_nonzero hI).mpr _,\n  intros y hy x hx,\n  rw mul_comm,\n  exact mul_mem_mul hx hy,\nend\n\ntheorem mul_div_self_cancel_iff {I : fractional_ideal g} :\n  I * (1 / I) = 1 ↔ ∃ J, I * J = 1 :=\n⟨λ h, ⟨(1 / I), h⟩, λ ⟨J, hJ⟩, by rwa [← eq_one_div_of_mul_eq_one I J hJ]⟩\n\nvariables {K' : Type*} [field K'] {g' : fraction_map R₁ K'}\n\n@[simp] lemma map_div (I J : fractional_ideal g) (h : g.codomain ≃ₐ[R₁] g'.codomain) :\n  (I / J).map (h : g.codomain →ₐ[R₁] g'.codomain) = I.map h / J.map h :=\nbegin\n  by_cases H : J = 0,\n  { rw [H, div_zero, map_zero, div_zero] },\n  { ext x,\n    simp [div_nonzero H, div_nonzero (map_ne_zero _ H), submodule.map_div] }\nend\n\n@[simp] lemma map_one_div (I : fractional_ideal g) (h : g.codomain ≃ₐ[R₁] g'.codomain) :\n  (1 / I).map (h : g.codomain →ₐ[R₁] g'.codomain) = 1 / I.map h :=\nby rw [map_div, map_one]\n\nend quotient\n\nsection principal_ideal_ring\n\nvariables {R₁ : Type*} [integral_domain R₁] {K : Type*} [field K] {g : fraction_map R₁ K}\n\nopen_locale classical\n\nopen submodule submodule.is_principal\n\nlemma is_fractional_span_singleton (x : f.codomain) : is_fractional f (span R {x}) :=\nlet ⟨a, ha⟩ := f.exists_integer_multiple x in\nis_fractional_span_iff.mpr ⟨ a.1, a.2, λ x hx, (mem_singleton_iff.mp hx).symm ▸ ha⟩\n\n/-- `span_singleton x` is the fractional ideal generated by `x` if `0 ∉ S` -/\n@[irreducible]\ndef span_singleton (x : f.codomain) : fractional_ideal f :=\n⟨span R {x}, is_fractional_span_singleton x⟩\n\nlocal attribute [semireducible] span_singleton\n\n@[simp] lemma coe_span_singleton (x : f.codomain) :\n  (span_singleton x : submodule R f.codomain) = span R {x} := rfl\n\n@[simp] lemma mem_span_singleton {x y : f.codomain} :\n  x ∈ span_singleton y ↔ ∃ (z : R), z • y = x :=\nsubmodule.mem_span_singleton\n\nlemma mem_span_singleton_self (x : f.codomain) :\n  x ∈ span_singleton x :=\nmem_span_singleton.mpr ⟨1, one_smul _ _⟩\n\nlemma eq_span_singleton_of_principal (I : fractional_ideal f)\n  [is_principal (I : submodule R f.codomain)] :\n  I = span_singleton (generator (I : submodule R f.codomain)) :=\next (span_singleton_generator I.1).symm\n\nlemma is_principal_iff (I : fractional_ideal f) :\n  is_principal (I : submodule R f.codomain) ↔ ∃ x, I = span_singleton x :=\n⟨λ h, ⟨@generator _ _ _ _ _ I.1 h, @eq_span_singleton_of_principal _ _ _ _ _ _ I h⟩,\n λ ⟨x, hx⟩, { principal := ⟨x, trans (congr_arg _ hx) (coe_span_singleton x)⟩ } ⟩\n\n@[simp] lemma span_singleton_zero : span_singleton (0 : f.codomain) = 0 :=\nby { ext, simp [submodule.mem_span_singleton, eq_comm] }\n\nlemma span_singleton_eq_zero_iff {y : f.codomain} : span_singleton y = 0 ↔ y = 0 :=\n⟨λ h, span_eq_bot.mp (by simpa using congr_arg subtype.val h : span R {y} = ⊥) y (mem_singleton y),\n λ h, by simp [h] ⟩\n\nlemma span_singleton_ne_zero_iff {y : f.codomain} : span_singleton y ≠ 0 ↔ y ≠ 0 :=\nnot_congr span_singleton_eq_zero_iff\n\n@[simp] lemma span_singleton_one : span_singleton (1 : f.codomain) = 1 :=\nbegin\n  ext,\n  refine mem_span_singleton.trans ((exists_congr _).trans mem_one_iff.symm),\n  intro x',\n  refine eq.congr (mul_one _) rfl,\nend\n\n@[simp]\nlemma span_singleton_mul_span_singleton (x y : f.codomain) :\n  span_singleton x * span_singleton y = span_singleton (x * y) :=\nbegin\n  ext,\n  simp_rw [coe_mul, coe_span_singleton, span_mul_span, singleton.is_mul_hom.map_mul]\nend\n\n@[simp]\nlemma coe_ideal_span_singleton (x : R) :\n  (↑(span R {x} : ideal R) : fractional_ideal f) = span_singleton (f.to_map x) :=\nbegin\n  ext y,\n  refine mem_coe_ideal.trans (iff.trans _ mem_span_singleton.symm),\n  split,\n  { rintros ⟨y', hy', rfl⟩,\n    obtain ⟨x', rfl⟩ := submodule.mem_span_singleton.mp hy',\n    use x',\n    rw [smul_eq_mul, f.to_map.map_mul],\n    refl },\n  { rintros ⟨y', rfl⟩,\n    exact ⟨y' * x, submodule.mem_span_singleton.mpr ⟨y', rfl⟩, f.to_map.map_mul _ _⟩ }\nend\n\n@[simp]\nlemma canonical_equiv_span_singleton (f : localization_map S P) {P'} [comm_ring P']\n  (f' : localization_map S P') (x : f.codomain) :\n  canonical_equiv f f' (span_singleton x) =\n    span_singleton (f.map (show ∀ (y : S), ring_hom.id _ y.1 ∈ S, from λ y, y.2) f' x) :=\nbegin\n  apply ext_iff.mp,\n  intro y,\n  split; intro h,\n  { apply mem_span_singleton.mpr,\n    obtain ⟨x', hx', rfl⟩ := mem_canonical_equiv_apply.mp h,\n    obtain ⟨z, rfl⟩ := mem_span_singleton.mp hx',\n    use z,\n    rw localization_map.map_smul,\n    refl },\n  { apply mem_canonical_equiv_apply.mpr,\n    obtain ⟨z, rfl⟩ := mem_span_singleton.mp h,\n    use f.to_map z * x,\n    use mem_span_singleton.mpr ⟨z, rfl⟩,\n    rw [ring_hom.map_mul, localization_map.map_eq],\n    refl }\nend\n\nlemma mem_singleton_mul {x y : f.codomain} {I : fractional_ideal f} :\n  y ∈ span_singleton x * I ↔ ∃ y' ∈ I, y = x * y' :=\nbegin\n  split,\n  { intro h,\n    apply fractional_ideal.mul_induction_on h,\n    { intros x' hx' y' hy',\n      obtain ⟨a, ha⟩ := mem_span_singleton.mp hx',\n      use [a • y', I.1.smul_mem a hy'],\n      rw [←ha, algebra.mul_smul_comm, algebra.smul_mul_assoc] },\n    { exact ⟨0, I.1.zero_mem, (mul_zero x).symm⟩ },\n    { rintros _ _ ⟨y, hy, rfl⟩ ⟨y', hy', rfl⟩,\n      exact ⟨y + y', I.1.add_mem hy hy', (mul_add _ _ _).symm⟩ },\n    { rintros r _ ⟨y', hy', rfl⟩,\n      exact ⟨r • y', I.1.smul_mem r hy', (algebra.mul_smul_comm _ _ _).symm ⟩ } },\n  { rintros ⟨y', hy', rfl⟩,\n    exact mul_mem_mul (mem_span_singleton.mpr ⟨1, one_smul _ _⟩) hy' }\nend\n\nlemma one_div_span_singleton (x : g.codomain) :\n  1 / span_singleton x = span_singleton (x⁻¹) :=\nif h : x = 0 then by simp [h] else (eq_one_div_of_mul_eq_one _ _ (by simp [h])).symm\n\n@[simp] lemma div_span_singleton (J : fractional_ideal g) (d : g.codomain) :\n  J / span_singleton d = span_singleton (d⁻¹) * J :=\nbegin\n  rw ← one_div_span_singleton,\n  by_cases hd : d = 0,\n  { simp only [hd, span_singleton_zero, div_zero, zero_mul] },\n  have h_spand : span_singleton d ≠ 0 := mt span_singleton_eq_zero_iff.mp hd,\n  apply le_antisymm,\n  { intros x hx,\n    rw [val_eq_coe, coe_div h_spand, submodule.mem_div_iff_forall_mul_mem] at hx,\n    specialize hx d (mem_span_singleton_self d),\n    have h_xd : x = d⁻¹ * (x * d), { field_simp },\n    rw [val_eq_coe, coe_mul, one_div_span_singleton, h_xd],\n    exact submodule.mul_mem_mul (mem_span_singleton_self _) hx },\n  { rw [le_div_iff_mul_le h_spand, mul_assoc, mul_left_comm, one_div_span_singleton,\n    span_singleton_mul_span_singleton, inv_mul_cancel hd, span_singleton_one, mul_one],\n    exact le_refl J },\nend\n\nlemma exists_eq_span_singleton_mul (I : fractional_ideal g) :\n  ∃ (a : R₁) (aI : ideal R₁), a ≠ 0 ∧ I = span_singleton (g.to_map a)⁻¹ * aI :=\nbegin\n  obtain ⟨a_inv, nonzero, ha⟩ := I.2,\n  have nonzero := mem_non_zero_divisors_iff_ne_zero.mp nonzero,\n  have map_a_nonzero := mt g.to_map_eq_zero_iff.mp nonzero,\n  use a_inv,\n  use (span_singleton (g.to_map a_inv) * I).1.comap g.lin_coe,\n  split, exact nonzero,\n  ext,\n  refine iff.trans _ mem_singleton_mul.symm,\n  split,\n  { intro hx,\n    obtain ⟨x', hx'⟩ := ha x hx,\n    refine ⟨g.to_map x', mem_coe_ideal.mpr ⟨x', (mem_singleton_mul.mpr ⟨x, hx, hx'⟩), rfl⟩, _⟩,\n    erw [hx', ←mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] },\n  { rintros ⟨y, hy, rfl⟩,\n    obtain ⟨x', hx', rfl⟩ := mem_coe_ideal.mp hy,\n    obtain ⟨y', hy', hx'⟩ := mem_singleton_mul.mp hx',\n    rw lin_coe_apply at hx',\n    erw [hx', ←mul_assoc, inv_mul_cancel map_a_nonzero, one_mul],\n    exact hy' }\nend\n\ninstance is_principal {R} [integral_domain R] [is_principal_ideal_ring R] {f : fraction_map R K}\n  (I : fractional_ideal f) : (I : submodule R f.codomain).is_principal :=\nbegin\n  obtain ⟨a, aI, -, ha⟩ := exists_eq_span_singleton_mul I,\n  use (f.to_map a)⁻¹ * f.to_map (generator aI),\n  suffices : I = span_singleton ((f.to_map a)⁻¹ * f.to_map (generator aI)),\n  { exact congr_arg subtype.val this },\n  conv_lhs { rw [ha, ←span_singleton_generator aI] },\n  rw [coe_ideal_span_singleton (generator aI), span_singleton_mul_span_singleton]\nend\n\nend principal_ideal_ring\n\nvariables {R₁ : Type*} [integral_domain R₁]\nvariables {K : Type*} [field K] {g : fraction_map R₁ K}\n\nlocal attribute [instance] classical.prop_decidable\n\nlemma is_noetherian_zero : is_noetherian R₁ (0 : fractional_ideal g) :=\nis_noetherian_submodule.mpr (λ I (hI : I ≤ (0 : fractional_ideal g)),\n  by { rw coe_zero at hI, rw le_bot_iff.mp hI, exact fg_bot })\n\nlemma is_noetherian_iff {I : fractional_ideal g} :\n  is_noetherian R₁ I ↔ ∀ J ≤ I, (J : submodule R₁ g.codomain).fg :=\nis_noetherian_submodule.trans ⟨λ h J hJ, h _ hJ, λ h J hJ, h ⟨J, is_fractional_of_le hJ⟩ hJ⟩\n\nlemma is_noetherian_coe_to_fractional_ideal [is_noetherian_ring R₁] (I : ideal R₁) :\n  is_noetherian R₁ (I : fractional_ideal g) :=\nbegin\n  rw is_noetherian_iff,\n  intros J hJ,\n  obtain ⟨J, rfl⟩ := le_one_iff_exists_coe_ideal.mp (le_trans hJ coe_ideal_le_one),\n  exact fg_map (is_noetherian.noetherian J),\nend\n\nlemma is_noetherian_span_singleton_inv_to_map_mul (x : R₁) {I : fractional_ideal g}\n  (hI : is_noetherian R₁ I) :\n  is_noetherian R₁ (span_singleton (g.to_map x)⁻¹ * I : fractional_ideal g) :=\nbegin\n  by_cases hx : x = 0,\n  { rw [hx, g.to_map.map_zero, _root_.inv_zero, span_singleton_zero, zero_mul],\n    exact is_noetherian_zero },\n  have h_gx : g.to_map x ≠ 0,\n    from mt (g.to_map.injective_iff.mp (fraction_map.injective g) x) hx,\n  have h_spanx : span_singleton (g.to_map x) ≠ (0 : fractional_ideal g),\n    from span_singleton_ne_zero_iff.mpr h_gx,\n  rw is_noetherian_iff at ⊢ hI,\n  intros J hJ,\n  rw [← div_span_singleton, le_div_iff_mul_le h_spanx] at hJ,\n  obtain ⟨s, hs⟩ := hI _ hJ,\n  use s * {(g.to_map x)⁻¹},\n  rw [finset.coe_mul, finset.coe_singleton, ← span_mul_span, hs, ← coe_span_singleton, ← coe_mul,\n      mul_assoc, span_singleton_mul_span_singleton, mul_inv_cancel h_gx,\n      span_singleton_one, mul_one],\nend\n\n/-- Every fractional ideal of a noetherian integral domain is noetherian. -/\ntheorem is_noetherian [is_noetherian_ring R₁] (I : fractional_ideal g) : is_noetherian R₁ I :=\nbegin\n  obtain ⟨d, J, h_nzd, rfl⟩ := exists_eq_span_singleton_mul I,\n  apply is_noetherian_span_singleton_inv_to_map_mul,\n  apply is_noetherian_coe_to_fractional_ideal,\nend\n\nsection field\n\nlemma eq_zero_or_one {K L : Type*} [field K] [field L] {f : fraction_map K L}\n  (I : fractional_ideal f) : I = 0 ∨ I = 1 :=\nbegin\n  rw or_iff_not_imp_left,\n  intro hI,\n  simp only [← fractional_ideal.ext_iff, fractional_ideal.mem_one_iff],\n  intro x,\n  split,\n  { intro x_mem,\n    obtain ⟨n, d, rfl⟩ := f.mk'_surjective x,\n    refine ⟨n / d, _⟩,\n    rw [ring_hom.map_div, f.mk'_eq_div] },\n  { rintro ⟨x, rfl⟩,\n    obtain ⟨y, y_ne, y_mem⟩ := fractional_ideal.exists_ne_zero_mem_is_integer hI,\n    rw [← div_mul_cancel x y_ne, ring_hom.map_mul],\n    exact submodule.smul_mem I _ y_mem }\nend\n\nlemma eq_zero_or_one_of_is_field (hF : is_field R₁)\n  (I : fractional_ideal g) : I = 0 ∨ I = 1 :=\nby { letI : field R₁ := hF.to_field R₁, exact eq_zero_or_one I }\n\nend field\n\nend fractional_ideal\n\nend ring\n", "meta": {"author": "lean-forward", "repo": "class-number", "sha": "812ff19e6fbde86f8d71689851adaa2bbae9695e", "save_path": "github-repos/lean/lean-forward-class-number", "path": "github-repos/lean/lean-forward-class-number/class-number-812ff19e6fbde86f8d71689851adaa2bbae9695e/src/fractional_ideal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.49438984791189555}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport data.bundle\nimport topology.algebra.order.field\nimport topology.local_homeomorph\n\n/-!\n# Trivializations\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n## Main definitions\n\n### Basic definitions\n\n* `trivialization F p` : structure extending local homeomorphisms, defining a local\n                  trivialization of a topological space `Z` with projection `p` and fiber `F`.\n\n* `pretrivialization F proj` : trivialization as a local equivalence, mainly used when the\n                                      topology on the total space has not yet been defined.\n\n### Operations on bundles\n\nWe provide the following operations on `trivialization`s.\n\n* `trivialization.comp_homeomorph`: given a local trivialization `e` of a fiber bundle\n  `p : Z → B` and a homeomorphism `h : Z' ≃ₜ Z`, returns a local trivialization of the fiber bundle\n  `p ∘ h`.\n\n## Implementation notes\n\nPreviously, in mathlib, there was a structure `topological_vector_bundle.trivialization` which\nextended another structure `topological_fiber_bundle.trivialization` by a linearity hypothesis. As\nof PR #17359, we have changed this to a single structure `trivialization` (no namespace), together\nwith a mixin class `trivialization.is_linear`.\n\nThis permits all the *data* of a vector bundle to be held at the level of fiber bundles, so that the\nsame trivializations can underlie an object's structure as (say) a vector bundle over `ℂ` and as a\nvector bundle over `ℝ`, as well as its structure simply as a fiber bundle.\n\nThis might be a little surprising, given the general trend of the library to ever-increased\nbundling.  But in this case the typical motivation for more bundling does not apply: there is no\nalgebraic or order structure on the whole type of linear (say) trivializations of a bundle.\nIndeed, since trivializations only have meaning on their base sets (taking junk values outside), the\ntype of linear trivializations is not even particularly well-behaved.\n\n-/\n\nopen topological_space filter set bundle\nopen_locale topology classical bundle\n\nvariables {ι : Type*} {B : Type*} {F : Type*} {E : B → Type*}\nvariables (F) {Z : Type*} [topological_space B] [topological_space F] {proj : Z → B}\n\n/-- This structure contains the information left for a local trivialization (which is implemented\nbelow as `trivialization F proj`) if the total space has not been given a topology, but we\nhave a topology on both the fiber and the base space. Through the construction\n`topological_fiber_prebundle F proj` it will be possible to promote a\n`pretrivialization F proj` to a `trivialization F proj`. -/\n@[ext, nolint has_nonempty_instance]\nstructure pretrivialization (proj : Z → B) extends local_equiv Z (B × F) :=\n(open_target   : is_open target)\n(base_set      : set B)\n(open_base_set : is_open base_set)\n(source_eq     : source = proj ⁻¹' base_set)\n(target_eq     : target = base_set ×ˢ univ)\n(proj_to_fun   : ∀ p ∈ source, (to_fun p).1 = proj p)\n\nnamespace pretrivialization\n\ninstance : has_coe_to_fun (pretrivialization F proj) (λ _, Z → (B × F)) := ⟨λ e, e.to_fun⟩\n\nvariables {F} (e : pretrivialization F proj) {x : Z}\n\n@[simp, mfld_simps] lemma coe_coe : ⇑e.to_local_equiv = e := rfl\n@[simp, mfld_simps] lemma coe_fst (ex : x ∈ e.source) : (e x).1 = proj x := e.proj_to_fun x ex\nlemma mem_source : x ∈ e.source ↔ proj x ∈ e.base_set := by rw [e.source_eq, mem_preimage]\nlemma coe_fst' (ex : proj x ∈ e.base_set) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex)\nprotected lemma eq_on : eq_on (prod.fst ∘ e) proj e.source := λ x hx, e.coe_fst hx\nlemma mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x := prod.ext (e.coe_fst ex).symm rfl\nlemma mk_proj_snd' (ex : proj x ∈ e.base_set) : (proj x, (e x).2) = e x :=\nprod.ext (e.coe_fst' ex).symm rfl\n\n/-- Composition of inverse and coercion from the subtype of the target. -/\ndef set_symm : e.target → Z := e.target.restrict e.to_local_equiv.symm\n\nlemma mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.base_set :=\nby rw [e.target_eq, prod_univ, mem_preimage]\n\nlemma proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.to_local_equiv.symm x) = x.1 :=\nbegin\n  have := (e.coe_fst (e.to_local_equiv.map_target hx)).symm,\n  rwa [← e.coe_coe, e.to_local_equiv.right_inv hx] at this\nend\n\nlemma proj_symm_apply' {b : B} {x : F} (hx : b ∈ e.base_set) :\n  proj (e.to_local_equiv.symm (b, x)) = b :=\ne.proj_symm_apply (e.mem_target.2 hx)\n\nlemma proj_surj_on_base_set [nonempty F] : set.surj_on proj e.source e.base_set :=\nλ b hb, let ⟨y⟩ := ‹nonempty F› in ⟨e.to_local_equiv.symm (b, y),\n  e.to_local_equiv.map_target $ e.mem_target.2 hb, e.proj_symm_apply' hb⟩\n\nlemma apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.to_local_equiv.symm x) = x :=\ne.to_local_equiv.right_inv hx\n\nlemma apply_symm_apply' {b : B} {x : F} (hx : b ∈ e.base_set) :\n  e (e.to_local_equiv.symm (b, x)) = (b, x) :=\ne.apply_symm_apply (e.mem_target.2 hx)\n\nlemma symm_apply_apply {x : Z} (hx : x ∈ e.source) : e.to_local_equiv.symm (e x) = x :=\ne.to_local_equiv.left_inv hx\n\n@[simp, mfld_simps] lemma symm_apply_mk_proj {x : Z} (ex : x ∈ e.source) :\n  e.to_local_equiv.symm (proj x, (e x).2) = x :=\nby rw [← e.coe_fst ex, prod.mk.eta, ← e.coe_coe, e.to_local_equiv.left_inv ex]\n\n@[simp, mfld_simps] lemma preimage_symm_proj_base_set :\n  (e.to_local_equiv.symm ⁻¹' (proj ⁻¹' e.base_set)) ∩ e.target  = e.target :=\nbegin\n  refine inter_eq_right_iff_subset.mpr (λ x hx, _),\n  simp only [mem_preimage, local_equiv.inv_fun_as_coe, e.proj_symm_apply hx],\n  exact e.mem_target.mp hx,\nend\n\n@[simp, mfld_simps] lemma preimage_symm_proj_inter (s : set B) :\n  (e.to_local_equiv.symm ⁻¹' (proj ⁻¹' s)) ∩ e.base_set ×ˢ univ = (s ∩ e.base_set) ×ˢ univ :=\nbegin\n  ext ⟨x, y⟩,\n  suffices : x ∈ e.base_set → (proj (e.to_local_equiv.symm (x, y)) ∈ s ↔ x ∈ s),\n    by simpa only [prod_mk_mem_set_prod_eq, mem_inter_iff, and_true, mem_univ, and.congr_left_iff],\n  intro h,\n  rw [e.proj_symm_apply' h]\nend\n\nlemma target_inter_preimage_symm_source_eq (e f : pretrivialization F proj) :\n  f.target ∩ (f.to_local_equiv.symm) ⁻¹' e.source = (e.base_set ∩ f.base_set) ×ˢ univ :=\nby rw [inter_comm, f.target_eq, e.source_eq, f.preimage_symm_proj_inter]\n\nlemma trans_source (e f : pretrivialization F proj) :\n  (f.to_local_equiv.symm.trans e.to_local_equiv).source = (e.base_set ∩ f.base_set) ×ˢ univ :=\nby rw [local_equiv.trans_source, local_equiv.symm_source, e.target_inter_preimage_symm_source_eq]\n\nlemma symm_trans_symm (e e' : pretrivialization F proj) :\n  (e.to_local_equiv.symm.trans e'.to_local_equiv).symm =\n  e'.to_local_equiv.symm.trans e.to_local_equiv :=\nby rw [local_equiv.trans_symm_eq_symm_trans_symm, local_equiv.symm_symm]\n\nlemma symm_trans_source_eq (e e' : pretrivialization F proj) :\n  (e.to_local_equiv.symm.trans e'.to_local_equiv).source = (e.base_set ∩ e'.base_set) ×ˢ univ :=\nby rw [local_equiv.trans_source, e'.source_eq, local_equiv.symm_source, e.target_eq, inter_comm,\n  e.preimage_symm_proj_inter, inter_comm]\n\nlemma symm_trans_target_eq (e e' : pretrivialization F proj) :\n  (e.to_local_equiv.symm.trans e'.to_local_equiv).target = (e.base_set ∩ e'.base_set) ×ˢ univ :=\nby rw [← local_equiv.symm_source, symm_trans_symm, symm_trans_source_eq, inter_comm]\n\nvariables {B F} (e' : pretrivialization F (π E)) {x' : total_space E} {b : B} {y : E b}\n\nlemma coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.base_set := e'.mem_source\n\n@[simp, mfld_simps] \n\nlemma mk_mem_target {x : B} {y : F} : (x, y) ∈ e'.target ↔ x ∈ e'.base_set :=\ne'.mem_target\n\nlemma symm_coe_proj {x : B} {y : F} (e' : pretrivialization F (π E)) (h : x ∈ e'.base_set) :\n  (e'.to_local_equiv.symm (x, y)).1 = x :=\ne'.proj_symm_apply' h\n\nsection has_zero\nvariables [∀ x, has_zero (E x)]\n\n/-- A fiberwise inverse to `e`. This is the function `F → E b` that induces a local inverse\n`B × F → total_space E` of `e` on `e.base_set`. It is defined to be `0` outside `e.base_set`. -/\nprotected noncomputable def symm (e : pretrivialization F (π E)) (b : B) (y : F) : E b :=\nif hb : b ∈ e.base_set\nthen cast (congr_arg E (e.proj_symm_apply' hb)) (e.to_local_equiv.symm (b, y)).2\nelse 0\n\nlemma symm_apply (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :\n  e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.to_local_equiv.symm (b, y)).2 :=\ndif_pos hb\n\nlemma symm_apply_of_not_mem (e : pretrivialization F (π E)) {b : B} (hb : b ∉ e.base_set) (y : F) :\n  e.symm b y = 0 :=\ndif_neg hb\n\nlemma coe_symm_of_not_mem (e : pretrivialization F (π E)) {b : B} (hb : b ∉ e.base_set) :\n  (e.symm b : F → E b) = 0 :=\nfunext $ λ y, dif_neg hb\n\nlemma mk_symm (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :\n  total_space_mk b (e.symm b y) = e.to_local_equiv.symm (b, y) :=\nby rw [e.symm_apply hb, total_space.mk_cast, total_space.eta]\n\nlemma symm_proj_apply (e : pretrivialization F (π E)) (z : total_space E)\n  (hz : z.proj ∈ e.base_set) : e.symm z.proj (e z).2 = z.2 :=\nby rw [e.symm_apply hz, cast_eq_iff_heq, e.mk_proj_snd' hz,\n  e.symm_apply_apply (e.mem_source.mpr hz)]\n\nlemma symm_apply_apply_mk (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : E b) :\n  e.symm b (e (total_space_mk b y)).2 = y :=\ne.symm_proj_apply (total_space_mk b y) hb\n\nlemma apply_mk_symm (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :\n  e (total_space_mk b (e.symm b y)) = (b, y) :=\nby rw [e.mk_symm hb, e.apply_symm_apply (e.mk_mem_target.mpr hb)]\n\nend has_zero\n\nend pretrivialization\n\nvariables [topological_space Z] [topological_space (total_space E)]\n\n/--\nA structure extending local homeomorphisms, defining a local trivialization of a projection\n`proj : Z → B` with fiber `F`, as a local homeomorphism between `Z` and `B × F` defined between two\nsets of the form `proj ⁻¹' base_set` and `base_set × F`, acting trivially on the first coordinate.\n-/\n@[ext, nolint has_nonempty_instance]\nstructure trivialization (proj : Z → B)\n  extends local_homeomorph Z (B × F) :=\n(base_set      : set B)\n(open_base_set : is_open base_set)\n(source_eq     : source = proj ⁻¹' base_set)\n(target_eq     : target = base_set ×ˢ univ)\n(proj_to_fun   : ∀ p ∈ source, (to_local_homeomorph p).1 = proj p)\n\nnamespace trivialization\n\nvariables {F} (e : trivialization F proj) {x : Z}\n\n/-- Natural identification as a `pretrivialization`. -/\ndef to_pretrivialization : pretrivialization F proj := { ..e }\n\ninstance : has_coe_to_fun (trivialization F proj) (λ _, Z → B × F) := ⟨λ e, e.to_fun⟩\ninstance : has_coe (trivialization F proj) (pretrivialization F proj) :=\n⟨to_pretrivialization⟩\n\nlemma to_pretrivialization_injective :\n  function.injective (λ e : trivialization F proj, e.to_pretrivialization) :=\nby { intros e e', rw [pretrivialization.ext_iff, trivialization.ext_iff,\n  ← local_homeomorph.to_local_equiv_injective.eq_iff], exact id }\n\n@[simp, mfld_simps] lemma coe_coe : ⇑e.to_local_homeomorph = e := rfl\n@[simp, mfld_simps] lemma coe_fst (ex : x ∈ e.source) : (e x).1 = proj x := e.proj_to_fun x ex\nprotected lemma eq_on : eq_on (prod.fst ∘ e) proj e.source := λ x hx, e.coe_fst hx\nlemma mem_source : x ∈ e.source ↔ proj x ∈ e.base_set := by rw [e.source_eq, mem_preimage]\nlemma coe_fst' (ex : proj x ∈ e.base_set) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex)\nlemma mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x := prod.ext (e.coe_fst ex).symm rfl\nlemma mk_proj_snd' (ex : proj x ∈ e.base_set) : (proj x, (e x).2) = e x :=\nprod.ext (e.coe_fst' ex).symm rfl\n\nlemma source_inter_preimage_target_inter (s : set (B × F)) :\n  e.source ∩ (e ⁻¹' (e.target ∩ s)) = e.source ∩ (e ⁻¹' s) :=\ne.to_local_homeomorph.source_inter_preimage_target_inter s\n\n@[simp, mfld_simps] lemma coe_mk (e : local_homeomorph Z (B × F)) (i j k l m) (x : Z) :\n  (trivialization.mk e i j k l m : trivialization F proj) x = e x := rfl\n\nlemma mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.base_set :=\ne.to_pretrivialization.mem_target\n\nlemma map_target {x : B × F} (hx : x ∈ e.target) : e.to_local_homeomorph.symm x ∈ e.source :=\ne.to_local_homeomorph.map_target hx\n\nlemma proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.to_local_homeomorph.symm x) = x.1 :=\ne.to_pretrivialization.proj_symm_apply hx\n\nlemma proj_symm_apply' {b : B} {x : F}\n  (hx : b ∈ e.base_set) : proj (e.to_local_homeomorph.symm (b, x)) = b :=\ne.to_pretrivialization.proj_symm_apply' hx\n\nlemma proj_surj_on_base_set [nonempty F] : set.surj_on proj e.source e.base_set :=\ne.to_pretrivialization.proj_surj_on_base_set\n\nlemma apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.to_local_homeomorph.symm x) = x :=\ne.to_local_homeomorph.right_inv hx\n\nlemma apply_symm_apply'\n  {b : B} {x : F} (hx : b ∈ e.base_set) : e (e.to_local_homeomorph.symm (b, x)) = (b, x) :=\ne.to_pretrivialization.apply_symm_apply' hx\n\n@[simp, mfld_simps] lemma symm_apply_mk_proj (ex : x ∈ e.source) :\n  e.to_local_homeomorph.symm (proj x, (e x).2) = x :=\ne.to_pretrivialization.symm_apply_mk_proj ex\n\nlemma symm_trans_source_eq (e e' : trivialization F proj) :\n  (e.to_local_equiv.symm.trans e'.to_local_equiv).source = (e.base_set ∩ e'.base_set) ×ˢ univ :=\npretrivialization.symm_trans_source_eq e.to_pretrivialization e'\n\nlemma symm_trans_target_eq (e e' : trivialization F proj) :\n  (e.to_local_equiv.symm.trans e'.to_local_equiv).target = (e.base_set ∩ e'.base_set) ×ˢ univ :=\npretrivialization.symm_trans_target_eq e.to_pretrivialization e'\n\nlemma coe_fst_eventually_eq_proj (ex : x ∈ e.source) : prod.fst ∘ e =ᶠ[𝓝 x] proj  :=\nmem_nhds_iff.2 ⟨e.source, λ y hy, e.coe_fst hy, e.open_source, ex⟩\n\nlemma coe_fst_eventually_eq_proj' (ex : proj x ∈ e.base_set) : prod.fst ∘ e =ᶠ[𝓝 x] proj :=\ne.coe_fst_eventually_eq_proj (e.mem_source.2 ex)\n\nlemma map_proj_nhds (ex : x ∈ e.source) : map proj (𝓝 x) = 𝓝 (proj x) :=\nby rw [← e.coe_fst ex, ← map_congr (e.coe_fst_eventually_eq_proj ex), ← map_map, ← e.coe_coe,\n  e.to_local_homeomorph.map_nhds_eq ex, map_fst_nhds]\n\nlemma preimage_subset_source {s : set B} (hb : s ⊆ e.base_set) : proj ⁻¹' s ⊆ e.source :=\nλ p hp, e.mem_source.mpr (hb hp)\n\nlemma image_preimage_eq_prod_univ {s : set B} (hb : s ⊆ e.base_set) :\n  e '' (proj ⁻¹' s) = s ×ˢ univ :=\nsubset.antisymm (image_subset_iff.mpr (λ p hp,\n  ⟨(e.proj_to_fun p (e.preimage_subset_source hb hp)).symm ▸ hp, trivial⟩)) (λ p hp,\n  let hp' : p ∈ e.target := e.mem_target.mpr (hb hp.1) in\n  ⟨e.inv_fun p, mem_preimage.mpr ((e.proj_symm_apply hp').symm ▸ hp.1), e.apply_symm_apply hp'⟩)\n\n/-- The preimage of a subset of the base set is homeomorphic to the product with the fiber. -/\ndef preimage_homeomorph {s : set B} (hb : s ⊆ e.base_set) : proj ⁻¹' s ≃ₜ s × F :=\n(e.to_local_homeomorph.homeomorph_of_image_subset_source (e.preimage_subset_source hb)\n  (e.image_preimage_eq_prod_univ hb)).trans\n  ((homeomorph.set.prod s univ).trans ((homeomorph.refl s).prod_congr (homeomorph.set.univ F)))\n\n@[simp] lemma preimage_homeomorph_apply {s : set B} (hb : s ⊆ e.base_set) (p : proj ⁻¹' s) :\n  e.preimage_homeomorph hb p = (⟨proj p, p.2⟩, (e p).2) :=\nprod.ext (subtype.ext (e.proj_to_fun p (e.mem_source.mpr (hb p.2)))) rfl\n\n@[simp] lemma preimage_homeomorph_symm_apply {s : set B} (hb : s ⊆ e.base_set) (p : s × F) :\n  (e.preimage_homeomorph hb).symm p = ⟨e.symm (p.1, p.2), ((e.preimage_homeomorph hb).symm p).2⟩ :=\nrfl\n\n/-- The source is homeomorphic to the product of the base set with the fiber. -/\ndef source_homeomorph_base_set_prod : e.source ≃ₜ e.base_set × F :=\n(homeomorph.set_congr e.source_eq).trans (e.preimage_homeomorph subset_rfl)\n\n@[simp] lemma source_homeomorph_base_set_prod_apply (p : e.source) :\n  e.source_homeomorph_base_set_prod p = (⟨proj p, e.mem_source.mp p.2⟩, (e p).2) :=\ne.preimage_homeomorph_apply subset_rfl ⟨p, e.mem_source.mp p.2⟩\n\n@[simp] lemma source_homeomorph_base_set_prod_symm_apply (p : e.base_set × F) :\n  e.source_homeomorph_base_set_prod.symm p =\n    ⟨e.symm (p.1, p.2), (e.source_homeomorph_base_set_prod.symm p).2⟩ :=\nrfl\n\n/-- Each fiber of a trivialization is homeomorphic to the specified fiber. -/\ndef preimage_singleton_homeomorph {b : B} (hb : b ∈ e.base_set) : proj ⁻¹' {b} ≃ₜ F :=\n(e.preimage_homeomorph (set.singleton_subset_iff.mpr hb)).trans (((homeomorph.homeomorph_of_unique\n  ({b} : set B) punit).prod_congr (homeomorph.refl F)).trans (homeomorph.punit_prod F))\n\n@[simp] lemma preimage_singleton_homeomorph_apply {b : B} (hb : b ∈ e.base_set)\n  (p : proj ⁻¹' {b}) : e.preimage_singleton_homeomorph hb p = (e p).2 :=\nrfl\n\n@[simp] lemma preimage_singleton_homeomorph_symm_apply {b : B} (hb : b ∈ e.base_set) (p : F) :\n  (e.preimage_singleton_homeomorph hb).symm p =\n    ⟨e.symm (b, p), by rw [mem_preimage, e.proj_symm_apply' hb, mem_singleton_iff]⟩ :=\nrfl\n\n/-- In the domain of a bundle trivialization, the projection is continuous-/\nlemma continuous_at_proj (ex : x ∈ e.source) : continuous_at proj x :=\n(e.map_proj_nhds ex).le\n\n/-- Composition of a `trivialization` and a `homeomorph`. -/\nprotected def comp_homeomorph {Z' : Type*} [topological_space Z'] (h : Z' ≃ₜ Z) :\n  trivialization F (proj ∘ h) :=\n{ to_local_homeomorph := h.to_local_homeomorph.trans e.to_local_homeomorph,\n  base_set := e.base_set,\n  open_base_set := e.open_base_set,\n  source_eq := by simp [e.source_eq, preimage_preimage],\n  target_eq := by simp [e.target_eq],\n  proj_to_fun := λ p hp,\n    have hp : h p ∈ e.source, by simpa using hp,\n    by simp [hp] }\n\n/-- Read off the continuity of a function `f : Z → X` at `z : Z` by transferring via a\ntrivialization of `Z` containing `z`. -/\nlemma continuous_at_of_comp_right {X : Type*} [topological_space X] {f : Z → X} {z : Z}\n  (e : trivialization F proj) (he : proj z ∈ e.base_set)\n  (hf : continuous_at (f ∘ e.to_local_equiv.symm) (e z)) :\n  continuous_at f z :=\nbegin\n  have hez : z ∈ e.to_local_equiv.symm.target,\n  { rw [local_equiv.symm_target, e.mem_source],\n    exact he },\n  rwa [e.to_local_homeomorph.symm.continuous_at_iff_continuous_at_comp_right hez,\n   local_homeomorph.symm_symm]\nend\n\n/-- Read off the continuity of a function `f : X → Z` at `x : X` by transferring via a\ntrivialization of `Z` containing `f x`. -/\nlemma continuous_at_of_comp_left {X : Type*} [topological_space X] {f : X → Z} {x : X}\n  (e : trivialization F proj) (hf_proj : continuous_at (proj ∘ f) x) (he : proj (f x) ∈ e.base_set)\n  (hf : continuous_at (e ∘ f) x) :\n  continuous_at f x :=\nbegin\n  rw e.to_local_homeomorph.continuous_at_iff_continuous_at_comp_left,\n  { exact hf },\n  rw [e.source_eq, ← preimage_comp],\n  exact hf_proj.preimage_mem_nhds (e.open_base_set.mem_nhds he),\nend\n\nvariables {E} (e' : trivialization F (π E)) {x' : total_space E} {b : B} {y : E b}\n\nprotected lemma continuous_on : continuous_on e' e'.source := e'.continuous_to_fun\n\nlemma coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.base_set := e'.mem_source\n\nlemma open_target : is_open e'.target :=\nby { rw e'.target_eq, exact e'.open_base_set.prod is_open_univ }\n\n@[simp, mfld_simps] lemma coe_coe_fst (hb : b ∈ e'.base_set) : (e' y).1 = b :=\ne'.coe_fst (e'.mem_source.2 hb)\n\nlemma mk_mem_target {y : F} : (b, y) ∈ e'.target ↔ b ∈ e'.base_set :=\ne'.to_pretrivialization.mem_target\n\nlemma symm_apply_apply {x : total_space E} (hx : x ∈ e'.source) :\n  e'.to_local_homeomorph.symm (e' x) = x :=\ne'.to_local_equiv.left_inv hx\n\n@[simp, mfld_simps] lemma symm_coe_proj {x : B} {y : F}\n  (e : trivialization F (π E)) (h : x ∈ e.base_set) :\n  (e.to_local_homeomorph.symm (x, y)).1 = x := e.proj_symm_apply' h\n\nsection has_zero\nvariables [∀ x, has_zero (E x)]\n\n/-- A fiberwise inverse to `e'`. The function `F → E x` that induces a local inverse\n`B × F → total_space E` of `e'` on `e'.base_set`. It is defined to be `0` outside `e'.base_set`. -/\nprotected noncomputable def symm (e : trivialization F (π E)) (b : B) (y : F) : E b :=\ne.to_pretrivialization.symm b y\n\nlemma symm_apply (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :\n  e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.to_local_homeomorph.symm (b, y)).2 :=\ndif_pos hb\n\nlemma symm_apply_of_not_mem (e : trivialization F (π E)) {b : B} (hb : b ∉ e.base_set) (y : F) :\n  e.symm b y = 0 :=\ndif_neg hb\n\nlemma mk_symm (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :\n  total_space_mk b (e.symm b y) = e.to_local_homeomorph.symm (b, y) :=\ne.to_pretrivialization.mk_symm hb y\n\nlemma symm_proj_apply (e : trivialization F (π E)) (z : total_space E)\n  (hz : z.proj ∈ e.base_set) : e.symm z.proj (e z).2 = z.2 :=\ne.to_pretrivialization.symm_proj_apply z hz\n\nlemma symm_apply_apply_mk (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : E b) :\n  e.symm b (e (total_space_mk b y)).2 = y :=\ne.symm_proj_apply (total_space_mk b y) hb\n\nlemma apply_mk_symm (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :\n  e (total_space_mk b (e.symm b y)) = (b, y) :=\ne.to_pretrivialization.apply_mk_symm hb y\n\nlemma continuous_on_symm (e : trivialization F (π E)) :\n  continuous_on (λ z : B × F, total_space_mk z.1 (e.symm z.1 z.2)) (e.base_set ×ˢ univ) :=\nbegin\n  have : ∀ (z : B × F) (hz : z ∈ e.base_set ×ˢ (univ : set F)),\n    total_space_mk z.1 (e.symm z.1 z.2) = e.to_local_homeomorph.symm z,\n  { rintro x ⟨hx : x.1 ∈ e.base_set, _⟩, simp_rw [e.mk_symm hx, prod.mk.eta] },\n  refine continuous_on.congr _ this,\n  rw [← e.target_eq],\n  exact e.to_local_homeomorph.continuous_on_symm\nend\n\nend has_zero\n\n/-- If `e` is a `trivialization` of `proj : Z → B` with fiber `F` and `h` is a homeomorphism\n`F ≃ₜ F'`, then `e.trans_fiber_homeomorph h` is the trivialization of `proj` with the fiber `F'`\nthat sends `p : Z` to `((e p).1, h (e p).2)`. -/\ndef trans_fiber_homeomorph {F' : Type*} [topological_space F']\n  (e : trivialization F proj) (h : F ≃ₜ F') : trivialization F' proj :=\n{ to_local_homeomorph := e.to_local_homeomorph.trans_homeomorph $ (homeomorph.refl _).prod_congr h,\n  base_set := e.base_set,\n  open_base_set := e.open_base_set,\n  source_eq := e.source_eq,\n  target_eq := by simp [e.target_eq, prod_univ, preimage_preimage],\n  proj_to_fun := e.proj_to_fun }\n\n@[simp] lemma trans_fiber_homeomorph_apply {F' : Type*} [topological_space F']\n  (e : trivialization F proj) (h : F ≃ₜ F') (x : Z) :\n  e.trans_fiber_homeomorph h x = ((e x).1, h (e x).2) :=\nrfl\n\n/-- Coordinate transformation in the fiber induced by a pair of bundle trivializations. See also\n`trivialization.coord_change_homeomorph` for a version bundled as `F ≃ₜ F`. -/\ndef coord_change (e₁ e₂ : trivialization F proj) (b : B) (x : F) : F :=\n(e₂ $ e₁.to_local_homeomorph.symm (b, x)).2\n\nlemma mk_coord_change\n  (e₁ e₂ : trivialization F proj) {b : B}\n  (h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) (x : F) :\n  (b, e₁.coord_change e₂ b x) = e₂ (e₁.to_local_homeomorph.symm (b, x)) :=\nbegin\n  refine prod.ext _ rfl,\n  rw [e₂.coe_fst', ← e₁.coe_fst', e₁.apply_symm_apply' h₁],\n  { rwa [e₁.proj_symm_apply' h₁] },\n  { rwa [e₁.proj_symm_apply' h₁] }\nend\n\nlemma coord_change_apply_snd\n  (e₁ e₂ : trivialization F proj) {p : Z}\n  (h : proj p ∈ e₁.base_set) :\n  e₁.coord_change e₂ (proj p) (e₁ p).snd = (e₂ p).snd :=\nby rw [coord_change, e₁.symm_apply_mk_proj (e₁.mem_source.2 h)]\n\nlemma coord_change_same_apply\n  (e : trivialization F proj) {b : B} (h : b ∈ e.base_set) (x : F) :\n  e.coord_change e b x = x :=\nby rw [coord_change, e.apply_symm_apply' h]\n\nlemma coord_change_same\n  (e : trivialization F proj) {b : B} (h : b ∈ e.base_set) :\n  e.coord_change e b = id :=\nfunext $ e.coord_change_same_apply h\n\nlemma coord_change_coord_change\n  (e₁ e₂ e₃ : trivialization F proj) {b : B}\n  (h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) (x : F) :\n  e₂.coord_change e₃ b (e₁.coord_change e₂ b x) = e₁.coord_change e₃ b x :=\nbegin\n  rw [coord_change, e₁.mk_coord_change _ h₁ h₂, ← e₂.coe_coe,\n    e₂.to_local_homeomorph.left_inv, coord_change],\n  rwa [e₂.mem_source, e₁.proj_symm_apply' h₁]\nend\n\nlemma continuous_coord_change (e₁ e₂ : trivialization F proj) {b : B}\n  (h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) :\n  continuous (e₁.coord_change e₂ b) :=\nbegin\n  refine continuous_snd.comp (e₂.to_local_homeomorph.continuous_on.comp_continuous\n    (e₁.to_local_homeomorph.continuous_on_symm.comp_continuous _ _) _),\n  { exact continuous_const.prod_mk continuous_id },\n  { exact λ x, e₁.mem_target.2 h₁ },\n  { intro x,\n    rwa [e₂.mem_source, e₁.proj_symm_apply' h₁] }\nend\n\n/-- Coordinate transformation in the fiber induced by a pair of bundle trivializations,\nas a homeomorphism. -/\nprotected def coord_change_homeomorph\n  (e₁ e₂ : trivialization F proj) {b : B} (h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) :\n  F ≃ₜ F :=\n{ to_fun := e₁.coord_change e₂ b,\n  inv_fun := e₂.coord_change e₁ b,\n  left_inv := λ x, by simp only [*, coord_change_coord_change, coord_change_same_apply],\n  right_inv := λ x, by simp only [*, coord_change_coord_change, coord_change_same_apply],\n  continuous_to_fun := e₁.continuous_coord_change e₂ h₁ h₂,\n  continuous_inv_fun := e₂.continuous_coord_change e₁ h₂ h₁ }\n\n@[simp] lemma coord_change_homeomorph_coe\n  (e₁ e₂ : trivialization F proj) {b : B} (h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) :\n  ⇑(e₁.coord_change_homeomorph e₂ h₁ h₂) = e₁.coord_change e₂ b :=\nrfl\n\nvariables {F} {B' : Type*} [topological_space B']\n\nlemma is_image_preimage_prod (e : trivialization F proj) (s : set B) :\n  e.to_local_homeomorph.is_image (proj ⁻¹' s) (s ×ˢ univ) :=\nλ x hx, by simp [e.coe_fst', hx]\n\n/-- Restrict a `trivialization` to an open set in the base. `-/\nprotected def restr_open (e : trivialization F proj) (s : set B)\n  (hs : is_open s) : trivialization F proj :=\n{ to_local_homeomorph := ((e.is_image_preimage_prod s).symm.restr\n    (is_open.inter e.open_target (hs.prod is_open_univ))).symm,\n  base_set := e.base_set ∩ s,\n  open_base_set := is_open.inter e.open_base_set hs,\n  source_eq := by simp [e.source_eq],\n  target_eq := by simp [e.target_eq, prod_univ],\n  proj_to_fun := λ p hp, e.proj_to_fun p hp.1 }\n\nsection piecewise\n\nlemma frontier_preimage (e : trivialization F proj) (s : set B) :\n  e.source ∩ frontier (proj ⁻¹' s) = proj ⁻¹' (e.base_set ∩ frontier s) :=\nby rw [← (e.is_image_preimage_prod s).frontier.preimage_eq, frontier_prod_univ_eq,\n  (e.is_image_preimage_prod _).preimage_eq, e.source_eq, preimage_inter]\n\n/-- Given two bundle trivializations `e`, `e'` of `proj : Z → B` and a set `s : set B` such that\nthe base sets of `e` and `e'` intersect `frontier s` on the same set and `e p = e' p` whenever\n`proj p ∈ e.base_set ∩ frontier s`, `e.piecewise e' s Hs Heq` is the bundle trivialization over\n`set.ite s e.base_set e'.base_set` that is equal to `e` on `proj ⁻¹ s` and is equal to `e'`\notherwise. -/\nnoncomputable def piecewise (e e' : trivialization F proj) (s : set B)\n  (Hs : e.base_set ∩ frontier s = e'.base_set ∩ frontier s)\n  (Heq : eq_on e e' $ proj ⁻¹' (e.base_set ∩ frontier s)) :\n  trivialization F proj :=\n{ to_local_homeomorph := e.to_local_homeomorph.piecewise e'.to_local_homeomorph\n    (proj ⁻¹' s) (s ×ˢ univ) (e.is_image_preimage_prod s) (e'.is_image_preimage_prod s)\n    (by rw [e.frontier_preimage, e'.frontier_preimage, Hs])\n    (by rwa e.frontier_preimage),\n  base_set := s.ite e.base_set e'.base_set,\n  open_base_set := e.open_base_set.ite e'.open_base_set Hs,\n  source_eq := by simp [e.source_eq, e'.source_eq],\n  target_eq := by simp [e.target_eq, e'.target_eq, prod_univ],\n  proj_to_fun := by rintro p (⟨he, hs⟩|⟨he, hs⟩); simp * }\n\n/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B`\nover a linearly ordered base `B` and a point `a ∈ e.base_set ∩ e'.base_set` such that\n`e` equals `e'` on `proj ⁻¹' {a}`, `e.piecewise_le_of_eq e' a He He' Heq` is the bundle\ntrivialization over `set.ite (Iic a) e.base_set e'.base_set` that is equal to `e` on points `p`\nsuch that `proj p ≤ a` and is equal to `e'` otherwise. -/\nnoncomputable def piecewise_le_of_eq [linear_order B] [order_topology B]\n  (e e' : trivialization F proj) (a : B) (He : a ∈ e.base_set) (He' : a ∈ e'.base_set)\n  (Heq : ∀ p, proj p = a → e p = e' p) :\n  trivialization F proj :=\ne.piecewise e' (Iic a)\n  (set.ext $ λ x, and.congr_left_iff.2 $ λ hx,\n    by simp [He, He', mem_singleton_iff.1 (frontier_Iic_subset _ hx)])\n  (λ p hp, Heq p $ frontier_Iic_subset _ hp.2)\n\n/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B` over a\nlinearly ordered base `B` and a point `a ∈ e.base_set ∩ e'.base_set`, `e.piecewise_le e' a He He'`\nis the bundle trivialization over `set.ite (Iic a) e.base_set e'.base_set` that is equal to `e` on\npoints `p` such that `proj p ≤ a` and is equal to `((e' p).1, h (e' p).2)` otherwise, where\n`h = `e'.coord_change_homeomorph e _ _` is the homeomorphism of the fiber such that\n`h (e' p).2 = (e p).2` whenever `e p = a`. -/\nnoncomputable def piecewise_le [linear_order B] [order_topology B]\n  (e e' : trivialization F proj) (a : B) (He : a ∈ e.base_set) (He' : a ∈ e'.base_set) :\n  trivialization F proj :=\ne.piecewise_le_of_eq (e'.trans_fiber_homeomorph (e'.coord_change_homeomorph e He' He))\n  a He He' $ by { unfreezingI {rintro p rfl },\n    ext1,\n    { simp [e.coe_fst', e'.coe_fst', *] },\n    { simp [e'.coord_change_apply_snd, *] } }\n\n/-- Given two bundle trivializations `e`, `e'` over disjoint sets, `e.disjoint_union e' H` is the\nbundle trivialization over the union of the base sets that agrees with `e` and `e'` over their\nbase sets. -/\nnoncomputable def disjoint_union (e e' : trivialization F proj)\n  (H : disjoint e.base_set e'.base_set) :\n  trivialization F proj :=\n{ to_local_homeomorph := e.to_local_homeomorph.disjoint_union e'.to_local_homeomorph\n    (by { rw [e.source_eq, e'.source_eq], exact H.preimage _, })\n    (by { rw [e.target_eq, e'.target_eq, disjoint_iff_inf_le],\n          intros x hx, exact H.le_bot ⟨hx.1.1, hx.2.1⟩ }),\n  base_set := e.base_set ∪ e'.base_set,\n  open_base_set := is_open.union e.open_base_set e'.open_base_set,\n  source_eq := congr_arg2 (∪) e.source_eq e'.source_eq,\n  target_eq := (congr_arg2 (∪) e.target_eq e'.target_eq).trans union_prod.symm,\n  proj_to_fun :=\n    begin\n      rintro p (hp|hp'),\n      { show (e.source.piecewise e e' p).1 = proj p,\n        rw [piecewise_eq_of_mem, e.coe_fst]; exact hp },\n      { show (e.source.piecewise e e' p).1 = proj p,\n        rw [piecewise_eq_of_not_mem, e'.coe_fst hp'],\n        simp only [e.source_eq, e'.source_eq] at hp' ⊢,\n        exact λ h, H.le_bot ⟨h, hp'⟩ }\n    end }\n\nend piecewise\n\nend trivialization\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/fiber_bundle/trivialization.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.4943898406897475}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Simon Hudon\n\n! This file was ported from Lean 3 source module data.qpf.multivariate.constructions.cofix\n! leanprover-community/mathlib commit f694c7dead66f5d4c80f446c796a5aad14707f0e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Control.Functor.Multivariate\nimport Mathbin.Data.Pfunctor.Multivariate.Basic\nimport Mathbin.Data.Pfunctor.Multivariate.M\nimport Mathbin.Data.Qpf.Multivariate.Basic\n\n/-!\n# The final co-algebra of a multivariate qpf is again a qpf.\n\nFor a `(n+1)`-ary QPF `F (α₀,..,αₙ)`, we take the least fixed point of `F` with\nregards to its last argument `αₙ`. The result is a `n`-ary functor: `fix F (α₀,..,αₙ₋₁)`.\nMaking `fix F` into a functor allows us to take the fixed point, compose with other functors\nand take a fixed point again.\n\n## Main definitions\n\n * `cofix.mk`     - constructor\n * `cofix.dest`   - destructor\n * `cofix.corec`  - corecursor: useful for formulating infinite, productive computations\n * `cofix.bisim`  - bisimulation: proof technique to show the equality of possibly infinite values\n                    of `cofix F α`\n\n## Implementation notes\n\nFor `F` a QPF, we define `cofix F α` in terms of the M-type of the polynomial functor `P` of `F`.\nWe define the relation `Mcongr` and take its quotient as the definition of `cofix F α`.\n\n`Mcongr` is taken as the weakest bisimulation on M-type. See\n[avigad-carneiro-hudon2019] for more details.\n\n## Reference\n\n * Jeremy Avigad, Mario M. Carneiro and Simon Hudon.\n   [*Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019]\n-/\n\n\nuniverse u\n\nopen MvFunctor\n\nnamespace MvQPF\n\nopen TypeVec MvPFunctor\n\nopen MvFunctor (Liftp Liftr)\n\nvariable {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [MvFunctor F] [q : MvQPF F]\n\ninclude q\n\n/-- `corecF` is used as a basis for defining the corecursor of `cofix F α`. `corecF`\nuses corecursion to construct the M-type generated by `q.P` and uses function on `F`\nas a corecursive step -/\ndef corecF {α : TypeVec n} {β : Type _} (g : β → F (α.append1 β)) : β → q.p.M α :=\n  M.corec _ fun x => repr (g x)\n#align mvqpf.corecF MvQPF.corecF\n\ntheorem corecF_eq {α : TypeVec n} {β : Type _} (g : β → F (α.append1 β)) (x : β) :\n    M.dest q.p (corecF g x) = appendFun id (corecF g) <$$> repr (g x) := by\n  rw [corecF, M.dest_corec]\n#align mvqpf.corecF_eq MvQPF.corecF_eq\n\n/-- Characterization of desirable equivalence relations on M-types -/\ndef IsPrecongr {α : TypeVec n} (r : q.p.M α → q.p.M α → Prop) : Prop :=\n  ∀ ⦃x y⦄,\n    r x y →\n      abs (appendFun id (Quot.mk r) <$$> M.dest q.p x) =\n        abs (appendFun id (Quot.mk r) <$$> M.dest q.p y)\n#align mvqpf.is_precongr MvQPF.IsPrecongr\n\n/-- Equivalence relation on M-types representing a value of type `cofix F` -/\ndef Mcongr {α : TypeVec n} (x y : q.p.M α) : Prop :=\n  ∃ r, IsPrecongr r ∧ r x y\n#align mvqpf.Mcongr MvQPF.Mcongr\n\n/-- Greatest fixed point of functor F. The result is a functor with one fewer parameters\nthan the input. For `F a b c` a ternary functor, fix F is a binary functor such that\n\n```lean\ncofix F a b = F a b (cofix F a b)\n```\n-/\ndef Cofix (F : TypeVec (n + 1) → Type u) [MvFunctor F] [q : MvQPF F] (α : TypeVec n) :=\n  Quot (@Mcongr _ F _ q α)\n#align mvqpf.cofix MvQPF.Cofix\n\ninstance {α : TypeVec n} [Inhabited q.p.A] [∀ i : Fin2 n, Inhabited (α i)] :\n    Inhabited (Cofix F α) :=\n  ⟨Quot.mk _ default⟩\n\n/-- maps every element of the W type to a canonical representative -/\ndef mrepr {α : TypeVec n} : q.p.M α → q.p.M α :=\n  corecF (abs ∘ M.dest q.p)\n#align mvqpf.Mrepr MvQPF.mrepr\n\n/-- the map function for the functor `cofix F` -/\ndef Cofix.map {α β : TypeVec n} (g : α ⟹ β) : Cofix F α → Cofix F β :=\n  Quot.lift (fun x : q.p.M α => Quot.mk Mcongr (g <$$> x))\n    (by\n      rintro aa₁ aa₂ ⟨r, pr, ra₁a₂⟩; apply Quot.sound\n      let r' b₁ b₂ := ∃ a₁ a₂ : q.P.M α, r a₁ a₂ ∧ b₁ = g <$$> a₁ ∧ b₂ = g <$$> a₂\n      use r'; constructor\n      · show is_precongr r'\n        rintro b₁ b₂ ⟨a₁, a₂, ra₁a₂, b₁eq, b₂eq⟩\n        let u : Quot r → Quot r' :=\n          Quot.lift (fun x : q.P.M α => Quot.mk r' (g <$$> x))\n            (by\n              intro a₁ a₂ ra₁a₂\n              apply Quot.sound\n              exact ⟨a₁, a₂, ra₁a₂, rfl, rfl⟩)\n        have hu : (Quot.mk r' ∘ fun x : q.P.M α => g <$$> x) = u ∘ Quot.mk r :=\n          by\n          ext x\n          rfl\n        rw [b₁eq, b₂eq, M.dest_map, M.dest_map, ← q.P.comp_map, ← q.P.comp_map]\n        rw [← append_fun_comp, id_comp, hu, hu, ← comp_id g, append_fun_comp]\n        rw [q.P.comp_map, q.P.comp_map, abs_map, pr ra₁a₂, ← abs_map]\n      show r' (g <$$> aa₁) (g <$$> aa₂); exact ⟨aa₁, aa₂, ra₁a₂, rfl, rfl⟩)\n#align mvqpf.cofix.map MvQPF.Cofix.map\n\ninstance Cofix.mvfunctor : MvFunctor (Cofix F) where map := @Cofix.map _ _ _ _\n#align mvqpf.cofix.mvfunctor MvQPF.Cofix.mvfunctor\n\n/-- Corecursor for `cofix F` -/\ndef Cofix.corec {α : TypeVec n} {β : Type u} (g : β → F (α.append1 β)) : β → Cofix F α := fun x =>\n  Quot.mk _ (corecF g x)\n#align mvqpf.cofix.corec MvQPF.Cofix.corec\n\n/-- Destructor for `cofix F` -/\ndef Cofix.dest {α : TypeVec n} : Cofix F α → F (α.append1 (Cofix F α)) :=\n  Quot.lift (fun x => appendFun id (Quot.mk Mcongr) <$$> abs (M.dest q.p x))\n    (by\n      rintro x y ⟨r, pr, rxy⟩\n      dsimp\n      have : ∀ x y, r x y → Mcongr x y := by\n        intro x y h\n        exact ⟨r, pr, h⟩\n      rw [← Quot.factor_mk_eq _ _ this]\n      dsimp\n      conv =>\n        lhs\n        rw [append_fun_comp_id, comp_map, ← abs_map, pr rxy, abs_map, ← comp_map, ←\n          append_fun_comp_id])\n#align mvqpf.cofix.dest MvQPF.Cofix.dest\n\n/-- Abstraction function for `cofix F α` -/\ndef Cofix.abs {α} : q.p.M α → Cofix F α :=\n  Quot.mk _\n#align mvqpf.cofix.abs MvQPF.Cofix.abs\n\n/-- Representation function for `cofix F α` -/\ndef Cofix.repr {α} : Cofix F α → q.p.M α :=\n  M.corec _ <| repr ∘ Cofix.dest\n#align mvqpf.cofix.repr MvQPF.Cofix.repr\n\n/-- Corecursor for `cofix F` -/\ndef Cofix.corec'₁ {α : TypeVec n} {β : Type u} (g : ∀ {X}, (β → X) → F (α.append1 X)) (x : β) :\n    Cofix F α :=\n  Cofix.corec (fun x => g id) x\n#align mvqpf.cofix.corec'₁ MvQPF.Cofix.corec'₁\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- More flexible corecursor for `cofix F`. Allows the return of a fully formed\nvalue instead of making a recursive call -/\ndef Cofix.corec' {α : TypeVec n} {β : Type u} (g : β → F (α.append1 (Sum (Cofix F α) β))) (x : β) :\n    Cofix F α :=\n  let f : (α ::: Cofix F α) ⟹ (α ::: Sum (Cofix F α) β) := id ::: Sum.inl\n  Cofix.corec (Sum.elim (MvFunctor.map f ∘ Cofix.dest) g) (Sum.inr x : Sum (Cofix F α) β)\n#align mvqpf.cofix.corec' MvQPF.Cofix.corec'\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Corecursor for `cofix F`. The shape allows recursive calls to\nlook like recursive calls. -/\ndef Cofix.corec₁ {α : TypeVec n} {β : Type u}\n    (g : ∀ {X}, (Cofix F α → X) → (β → X) → β → F (α ::: X)) (x : β) : Cofix F α :=\n  Cofix.corec' (fun x => g Sum.inl Sum.inr x) x\n#align mvqpf.cofix.corec₁ MvQPF.Cofix.corec₁\n\ntheorem Cofix.dest_corec {α : TypeVec n} {β : Type u} (g : β → F (α.append1 β)) (x : β) :\n    Cofix.dest (Cofix.corec g x) = appendFun id (Cofix.corec g) <$$> g x :=\n  by\n  conv =>\n    lhs\n    rw [cofix.dest, cofix.corec];\n  dsimp\n  rw [corecF_eq, abs_map, abs_repr, ← comp_map, ← append_fun_comp]; rfl\n#align mvqpf.cofix.dest_corec MvQPF.Cofix.dest_corec\n\n/-- constructor for `cofix F` -/\ndef Cofix.mk {α : TypeVec n} : F (α.append1 <| Cofix F α) → Cofix F α :=\n  Cofix.corec fun x => (appendFun id fun i : Cofix F α => Cofix.dest.{u} i) <$$> x\n#align mvqpf.cofix.mk MvQPF.Cofix.mk\n\n/-!\n## Bisimulation principles for `cofix F`\n\nThe following theorems are bisimulation principles. The general idea\nis to use a bisimulation relation to prove the equality between\nspecific values of type `cofix F α`.\n\nA bisimulation relation `R` for values `x y : cofix F α`:\n\n * holds for `x y`: `R x y`\n * for any values `x y` that satisfy `R`, their root has the same shape\n   and their children can be paired in such a way that they satisfy `R`.\n\n-/\n\n\nprivate theorem cofix.bisim_aux {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop) (h' : ∀ x, r x x)\n    (h :\n      ∀ x y,\n        r x y →\n          appendFun id (Quot.mk r) <$$> Cofix.dest x = appendFun id (Quot.mk r) <$$> Cofix.dest y) :\n    ∀ x y, r x y → x = y := by\n  intro x\n  apply Quot.inductionOn x\n  clear x\n  intro x y\n  apply Quot.inductionOn y\n  clear y\n  intro y rxy\n  apply Quot.sound\n  let r' x y := r (Quot.mk _ x) (Quot.mk _ y)\n  have : is_precongr r' := by\n    intro a b r'ab\n    have h₀ :\n      append_fun id (Quot.mk r ∘ Quot.mk Mcongr) <$$> abs (M.dest q.P a) =\n        append_fun id (Quot.mk r ∘ Quot.mk Mcongr) <$$> abs (M.dest q.P b) :=\n      by rw [append_fun_comp_id, comp_map, comp_map] <;> exact h _ _ r'ab\n    have h₁ : ∀ u v : q.P.M α, Mcongr u v → Quot.mk r' u = Quot.mk r' v :=\n      by\n      intro u v cuv\n      apply Quot.sound\n      dsimp [r']\n      rw [Quot.sound cuv]\n      apply h'\n    let f : Quot r → Quot r' :=\n      Quot.lift (Quot.lift (Quot.mk r') h₁)\n        (by\n          intro c; apply Quot.inductionOn c; clear c\n          intro c d; apply Quot.inductionOn d; clear d\n          intro d rcd; apply Quot.sound; apply rcd)\n    have : f ∘ Quot.mk r ∘ Quot.mk Mcongr = Quot.mk r' := rfl\n    rw [← this, append_fun_comp_id, q.P.comp_map, q.P.comp_map, abs_map, abs_map, abs_map, abs_map,\n      h₀]\n  refine' ⟨r', this, rxy⟩\n#align mvqpf.cofix.bisim_aux mvqpf.cofix.bisim_aux\n\n/-- Bisimulation principle using `map` and `quot.mk` to match and relate children of two trees. -/\ntheorem Cofix.bisim_rel {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)\n    (h :\n      ∀ x y,\n        r x y →\n          appendFun id (Quot.mk r) <$$> Cofix.dest x = appendFun id (Quot.mk r) <$$> Cofix.dest y) :\n    ∀ x y, r x y → x = y := by\n  let r' (x y) := x = y ∨ r x y\n  intro x y rxy\n  apply cofix.bisim_aux r'\n  · intro x\n    left\n    rfl\n  · intro x y r'xy\n    cases r'xy\n    · rw [r'xy]\n    have : ∀ x y, r x y → r' x y := fun x y h => Or.inr h\n    rw [← Quot.factor_mk_eq _ _ this]\n    dsimp\n    rw [append_fun_comp_id, append_fun_comp_id]\n    rw [@comp_map _ _ _ q _ _ _ (append_fun id (Quot.mk r)),\n      @comp_map _ _ _ q _ _ _ (append_fun id (Quot.mk r))]\n    rw [h _ _ r'xy]\n  right; exact rxy\n#align mvqpf.cofix.bisim_rel MvQPF.Cofix.bisim_rel\n\n/-- Bisimulation principle using `liftr` to match and relate children of two trees. -/\ntheorem Cofix.bisim {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)\n    (h : ∀ x y, r x y → LiftR (RelLast α r) (Cofix.dest x) (Cofix.dest y)) : ∀ x y, r x y → x = y :=\n  by\n  apply cofix.bisim_rel\n  intro x y rxy\n  rcases(liftr_iff (rel_last α r) _ _).mp (h x y rxy) with ⟨a, f₀, f₁, dxeq, dyeq, h'⟩\n  rw [dxeq, dyeq, ← abs_map, ← abs_map, MvPFunctor.map_eq, MvPFunctor.map_eq]\n  rw [← split_drop_fun_last_fun f₀, ← split_drop_fun_last_fun f₁]\n  rw [append_fun_comp_split_fun, append_fun_comp_split_fun]\n  rw [id_comp, id_comp]\n  congr 2 with (i j); cases' i with _ i <;> dsimp\n  · apply Quot.sound\n    apply h' _ j\n  · change f₀ _ j = f₁ _ j\n    apply h' _ j\n#align mvqpf.cofix.bisim MvQPF.Cofix.bisim\n\nopen MvFunctor\n\n/-- Bisimulation principle using `liftr'` to match and relate children of two trees. -/\ntheorem Cofix.bisim₂ {α : TypeVec n} (r : Cofix F α → Cofix F α → Prop)\n    (h : ∀ x y, r x y → LiftR' (RelLast' α r) (Cofix.dest x) (Cofix.dest y)) :\n    ∀ x y, r x y → x = y :=\n  Cofix.bisim _ <| by intros <;> rw [← liftr_last_rel_iff] <;> apply h <;> assumption\n#align mvqpf.cofix.bisim₂ MvQPF.Cofix.bisim₂\n\n/-- Bisimulation principle the values `⟨a,f⟩` of the polynomial functor representing\n`cofix F α` as well as an invariant `Q : β → Prop` and a state `β` generating the\nleft-hand side and right-hand side of the equality through functions `u v : β → cofix F α` -/\ntheorem Cofix.bisim' {α : TypeVec n} {β : Type _} (Q : β → Prop) (u v : β → Cofix F α)\n    (h :\n      ∀ x,\n        Q x →\n          ∃ a f' f₀ f₁,\n            Cofix.dest (u x) = abs ⟨a, q.p.appendContents f' f₀⟩ ∧\n              Cofix.dest (v x) = abs ⟨a, q.p.appendContents f' f₁⟩ ∧\n                ∀ i, ∃ x', Q x' ∧ f₀ i = u x' ∧ f₁ i = v x') :\n    ∀ x, Q x → u x = v x := fun x Qx =>\n  let R := fun w z : Cofix F α => ∃ x', Q x' ∧ w = u x' ∧ z = v x'\n  Cofix.bisim R\n    (fun x y ⟨x', Qx', xeq, yeq⟩ =>\n      by\n      rcases h x' Qx' with ⟨a, f', f₀, f₁, ux'eq, vx'eq, h'⟩\n      rw [liftr_iff]\n      refine'\n        ⟨a, q.P.append_contents f' f₀, q.P.append_contents f' f₁, xeq.symm ▸ ux'eq,\n          yeq.symm ▸ vx'eq, _⟩\n      intro i; cases i\n      · apply h'\n      · intro j\n        apply Eq.refl)\n    _ _ ⟨x, Qx, rfl, rfl⟩\n#align mvqpf.cofix.bisim' MvQPF.Cofix.bisim'\n\ntheorem Cofix.mk_dest {α : TypeVec n} (x : Cofix F α) : Cofix.mk (Cofix.dest x) = x :=\n  by\n  apply cofix.bisim_rel (fun x y : cofix F α => x = cofix.mk (cofix.dest y)) _ _ _ rfl; dsimp\n  intro x y h; rw [h]\n  conv =>\n    lhs\n    congr\n    skip\n    rw [cofix.mk]\n    rw [cofix.dest_corec]\n  rw [← comp_map, ← append_fun_comp, id_comp]\n  rw [← comp_map, ← append_fun_comp, id_comp, ← cofix.mk]\n  congr 2 with u; apply Quot.sound; rfl\n#align mvqpf.cofix.mk_dest MvQPF.Cofix.mk_dest\n\ntheorem Cofix.dest_mk {α : TypeVec n} (x : F (α.append1 <| Cofix F α)) :\n    Cofix.dest (Cofix.mk x) = x :=\n  by\n  have : cofix.mk ∘ cofix.dest = @_root_.id (cofix F α) := funext cofix.mk_dest\n  rw [cofix.mk, cofix.dest_corec, ← comp_map, ← cofix.mk, ← append_fun_comp, this, id_comp,\n    append_fun_id_id, MvFunctor.id_map]\n#align mvqpf.cofix.dest_mk MvQPF.Cofix.dest_mk\n\ntheorem Cofix.ext {α : TypeVec n} (x y : Cofix F α) (h : x.dest = y.dest) : x = y := by\n  rw [← cofix.mk_dest x, h, cofix.mk_dest]\n#align mvqpf.cofix.ext MvQPF.Cofix.ext\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Cofix.ext_mk {α : TypeVec n} (x y : F (α ::: Cofix F α)) (h : Cofix.mk x = Cofix.mk y) :\n    x = y := by rw [← cofix.dest_mk x, h, cofix.dest_mk]\n#align mvqpf.cofix.ext_mk MvQPF.Cofix.ext_mk\n\n/-!\n`liftr_map`, `liftr_map_last` and `liftr_map_last'` are useful for reasoning about\nthe induction step in bisimulation proofs.\n-/\n\n\nsection LiftrMap\n\nomit q\n\ntheorem liftr_map {α β : TypeVec n} {F' : TypeVec n → Type u} [MvFunctor F'] [LawfulMvFunctor F']\n    (R : β ⊗ β ⟹ repeat n Prop) (x : F' α) (f g : α ⟹ β) (h : α ⟹ Subtype_ R)\n    (hh : subtypeVal _ ⊚ h = (f ⊗' g) ⊚ prod.diag) : LiftR' R (f <$$> x) (g <$$> x) :=\n  by\n  rw [liftr_def]\n  exists h <$$> x\n  rw [MvFunctor.map_map, comp_assoc, hh, ← comp_assoc, fst_prod_mk, comp_assoc, fst_diag]\n  rw [MvFunctor.map_map, comp_assoc, hh, ← comp_assoc, snd_prod_mk, comp_assoc, snd_diag]\n  dsimp [liftr']; constructor <;> rfl\n#align mvqpf.liftr_map MvQPF.liftr_map\n\nopen Function\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem liftr_map_last [LawfulMvFunctor F] {α : TypeVec n} {ι ι'} (R : ι' → ι' → Prop)\n    (x : F (α ::: ι)) (f g : ι → ι') (hh : ∀ x : ι, R (f x) (g x)) :\n    LiftR' (RelLast' _ R) ((id ::: f) <$$> x) ((id ::: g) <$$> x) :=\n  let h : ι → { x : ι' × ι' // uncurry R x } := fun x => ⟨(f x, g x), hh x⟩\n  let b : (α ::: ι) ⟹ _ := @diagSub n α ::: h\n  let c :\n    (Subtype_ α.repeatEq ::: { x // uncurry R x }) ⟹\n      ((fun i : Fin2 n => { x // ofRepeat (α.RelLast' R i.fs x) }) ::: Subtype (uncurry R)) :=\n    ofSubtype _ ::: id\n  have hh :\n    subtypeVal _ ⊚ toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b =\n      ((id ::: f) ⊗' (id ::: g)) ⊚ prod.diag :=\n    by\n    dsimp [c, b]\n    apply eq_of_drop_last_eq\n    · dsimp\n      simp only [prod_map_id, drop_fun_prod, drop_fun_append_fun, drop_fun_diag, id_comp,\n        drop_fun_to_subtype]\n      erw [to_subtype_of_subtype_assoc, id_comp]\n      clear * -\n      ext (i x) : 2\n      induction i\n      rfl\n      apply i_ih\n    simp only [h, last_fun_from_append1_drop_last, last_fun_to_subtype, last_fun_append_fun,\n      last_fun_subtype_val, comp.left_id, last_fun_comp, last_fun_prod]\n    dsimp\n    ext1\n    rfl\n  liftr_map _ _ _ _ (toSubtype _ ⊚ fromAppend1DropLast ⊚ c ⊚ b) hh\n#align mvqpf.liftr_map_last MvQPF.liftr_map_last\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem liftr_map_last' [LawfulMvFunctor F] {α : TypeVec n} {ι} (R : ι → ι → Prop) (x : F (α ::: ι))\n    (f : ι → ι) (hh : ∀ x : ι, R (f x) x) : LiftR' (RelLast' _ R) ((id ::: f) <$$> x) x :=\n  by\n  have := liftr_map_last R x f id hh\n  rwa [append_fun_id_id, MvFunctor.id_map] at this\n#align mvqpf.liftr_map_last' MvQPF.liftr_map_last'\n\nend LiftrMap\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Cofix.abs_repr {α} (x : Cofix F α) : Quot.mk _ (Cofix.repr x) = x :=\n  by\n  let R := fun x y : cofix F α => cofix.abs (cofix.repr y) = x\n  refine' cofix.bisim₂ R _ _ _ rfl\n  clear x; rintro x y h; dsimp [R] at h; subst h\n  dsimp [cofix.dest, cofix.abs]\n  induction y using Quot.ind\n  simp only [cofix.repr, M.dest_corec, abs_map, abs_repr]\n  conv =>\n    congr\n    skip\n    rw [cofix.dest]\n  dsimp; rw [MvFunctor.map_map, MvFunctor.map_map, ← append_fun_comp_id, ← append_fun_comp_id]\n  let f : (α ::: (P F).M α) ⟹ subtype_ (α.rel_last' R) :=\n    split_fun diag_sub fun x => ⟨(cofix.abs (cofix.abs x).repr, cofix.abs x), _⟩\n  refine' liftr_map _ _ _ _ f _\n  · simp only [← append_prod_append_fun, prod_map_id]\n    apply eq_of_drop_last_eq\n    · dsimp\n      simp only [drop_fun_diag]\n      erw [subtype_val_diag_sub]\n    ext1\n    simp only [cofix.abs, Prod.mk.inj_iff, Prod_map, Function.comp_apply, last_fun_append_fun,\n      last_fun_subtype_val, last_fun_comp, last_fun_split_fun]\n    dsimp [drop_fun_rel_last, last_fun, prod.diag]\n    constructor <;> rfl\n  dsimp [rel_last', split_fun, Function.uncurry, R]\n  rfl\n#align mvqpf.cofix.abs_repr MvQPF.Cofix.abs_repr\n\nsection Tactic\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\nopen Tactic\n\nomit q\n\n/-- tactic for proof by bisimulation -/\nunsafe def mv_bisim (e : parse texpr) (ids : parse with_ident_list) : tactic Unit := do\n  let e ← to_expr e\n  let expr.pi n bi d b ←\n    retrieve do\n        generalize e\n        target\n  let q(@Eq $(t) $(l) $(r)) ← pure b\n  let x ← mk_local_def `n d\n  let v₀ ← mk_local_def `a t\n  let v₁ ← mk_local_def `b t\n  let x₀ ← mk_app `` Eq [v₀, l.instantiate_var x]\n  let x₁ ← mk_app `` Eq [v₁, r.instantiate_var x]\n  let xx ← mk_app `` And [x₀, x₁]\n  let ex ← lambdas [x] xx\n  let ex ← mk_app `` Exists [ex] >>= lambdas [v₀, v₁]\n  let R ← pose `R none ex\n  refine ``(Cofix.bisim₂ $(R) _ _ _ ⟨_, rfl, rfl⟩)\n  let f (a b : Name) : Name := if a = `_ then b else a\n  let ids := (ids ++ List.replicate 5 `_).zipWith f [`a, `b, `x, `Ha, `Hb]\n  let (ids₀, w :: ids₁) ← pure <| List.splitAt 2 ids\n  intro_lst ids₀\n  let h ← intro1\n  let [(_, [w, h], _)] ← cases_core h [w]\n  cases h ids₁\n  pure ()\n#align mvqpf.mv_bisim mvqpf.mv_bisim\n\nrun_cmd\n  add_interactive [`` mv_bisim]\n\nend Tactic\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem corec_roll {α : TypeVec n} {X Y} {x₀ : X} (f : X → Y) (g : Y → F (α ::: X)) :\n    Cofix.corec (g ∘ f) x₀ = Cofix.corec (MvFunctor.map (id ::: f) ∘ g) (f x₀) :=\n  by\n  mv_bisim x₀\n  rw [Ha, Hb, cofix.dest_corec, cofix.dest_corec]\n  rw [MvFunctor.map_map, ← append_fun_comp_id]\n  refine' liftr_map_last _ _ _ _ _\n  intro a; refine' ⟨a, rfl, rfl⟩\n#align mvqpf.corec_roll MvQPF.corec_roll\n\ntheorem Cofix.dest_corec' {α : TypeVec n} {β : Type u} (g : β → F (α.append1 (Sum (Cofix F α) β)))\n    (x : β) :\n    Cofix.dest (Cofix.corec' g x) = appendFun id (Sum.elim id (Cofix.corec' g)) <$$> g x :=\n  by\n  rw [cofix.corec', cofix.dest_corec]; dsimp\n  congr with (i | i) <;> rw [corec_roll] <;> dsimp [cofix.corec']\n  · mv_bisim i\n    rw [Ha, Hb, cofix.dest_corec]\n    dsimp [(· ∘ ·)]\n    repeat' rw [MvFunctor.map_map, ← append_fun_comp_id]\n    apply liftr_map_last'\n    dsimp [(· ∘ ·), R]\n    intros\n    exact ⟨_, rfl, rfl⟩\n  · congr with y\n    erw [append_fun_id_id]\n    simp [MvFunctor.id_map]\n#align mvqpf.cofix.dest_corec' MvQPF.Cofix.dest_corec'\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Cofix.dest_corec₁ {α : TypeVec n} {β : Type u}\n    (g : ∀ {X}, (Cofix F α → X) → (β → X) → β → F (α.append1 X)) (x : β)\n    (h :\n      ∀ (X Y) (f : Cofix F α → X) (f' : β → X) (k : X → Y),\n        g (k ∘ f) (k ∘ f') x = (id ::: k) <$$> g f f' x) :\n    Cofix.dest (Cofix.corec₁ (@g) x) = g id (Cofix.corec₁ @g) x := by\n  rw [cofix.corec₁, cofix.dest_corec', ← h] <;> rfl\n#align mvqpf.cofix.dest_corec₁ MvQPF.Cofix.dest_corec₁\n\ninstance mvqpfCofix : MvQPF (Cofix F) where\n  p := q.p.mp\n  abs α := Quot.mk Mcongr\n  repr α := Cofix.repr\n  abs_repr α := Cofix.abs_repr\n  abs_map α β g x := rfl\n#align mvqpf.mvqpf_cofix MvQPF.mvqpfCofix\n\nend MvQPF\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Qpf/Multivariate/Constructions/Cofix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.4943898385523684}}
{"text": "/- This file includes the proofs of the axioms for the encapsulation operator.-/\nimport .iff_lemmas\n\nopen mcrl2\n\nvariable {α : Type}\nvariable [comm_semigroup_with_zero α]\n\nlemma transition.encap_deadlock (A z) (a : α):\ntransition (encap A (δ : mcrl2 α)) a z ↔ transition (δ : mcrl2 α) a z :=\nbegin\n  simp [transition.encap_iff, transition.deadlock_iff],\nend\n\nlemma transition.encap_success (a₁ : α) (A) (h : a₁ ∉ A) (z a₂) :\ntransition (encap A (atom a₁)) a₂ z ↔ transition (atom a₁) a₂ z :=\nbegin\n  simp [transition.encap_iff, transition.atom_iff, h, ←and_assoc, h],\n  intros _ _ h,\n  rw h,\n  assumption\nend\n\nlemma transition.encap_fail (a₁ : α) (A) (h : a₁ ∈ A) (z a₂) :\ntransition (encap A (atom a₁)) a₂ z ↔ transition δ a₂ z :=\nbegin\n  simp [transition.deadlock_iff, transition.encap_iff, transition.atom_iff, h],\n  intros _ _ _ _ h,\n  rw h,\n  assumption\nend\n\nlemma transition.encap_alt (x : mcrl2 α) (y A z) (a : α) :\ntransition (encap A (x + y)) a z ↔ transition ((encap A x) + (encap A y)) a z:=\nbegin\n  simp [transition.encap_iff, transition.alt_iff, ←exists_and_distrib_right, and_or_distrib_left, or_and_distrib_right, exists_or_distrib]\nend\n\n/- encap_seq (∂_H(x ⬝ y) = ∂_H(x) ⬝ ∂_H(y)) needs to be proved via bisimulation. -/", "meta": {"author": "Wolfb34", "repo": "mucrl2lean_public", "sha": "0d687d0ad00a6f276f1c1e9acbfc3dd4c0b2ce39", "save_path": "github-repos/lean/Wolfb34-mucrl2lean_public", "path": "github-repos/lean/Wolfb34-mucrl2lean_public/mucrl2lean_public-0d687d0ad00a6f276f1c1e9acbfc3dd4c0b2ce39/Lean/transition/encap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6548947155710234, "lm_q1q2_score": 0.4943898283828301}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport category_theory.concrete_category.bundled\nimport category_theory.discrete_category\nimport category_theory.types\nimport category_theory.bicategory.strict\n\n/-!\n# Category of categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains the definition of the category `Cat` of all categories.\nIn this category objects are categories and\nmorphisms are functors between these categories.\n\n## Implementation notes\n\nThough `Cat` is not a concrete category, we use `bundled` to define\nits carrier type.\n-/\n\nuniverses v u\n\nnamespace category_theory\n\n/-- Category of categories. -/\n@[nolint check_univs] -- intended to be used with explicit universe parameters\ndef Cat := bundled category.{v u}\n\nnamespace Cat\n\ninstance : inhabited Cat := ⟨⟨Type u, category_theory.types⟩⟩\n\ninstance : has_coe_to_sort Cat (Type u) := ⟨bundled.α⟩\n\ninstance str (C : Cat.{v u}) : category.{v u} C := C.str\n\n/-- Construct a bundled `Cat` from the underlying type and the typeclass. -/\ndef of (C : Type u) [category.{v} C] : Cat.{v u} := bundled.of C\n\n/-- Bicategory structure on `Cat` -/\ninstance bicategory : bicategory.{(max v u) (max v u)} Cat.{v u} :=\n{ hom := λ C D, C ⥤ D,\n  id := λ C, 𝟭 C,\n  comp := λ C D E F G, F ⋙ G,\n  hom_category := λ C D, functor.category C D,\n  whisker_left := λ C D E F G H η, whisker_left F η,\n  whisker_right := λ C D E F G η H, whisker_right η H,\n  associator := λ A B C D, functor.associator,\n  left_unitor :=  λ A B, functor.left_unitor,\n  right_unitor := λ A B, functor.right_unitor,\n  pentagon' := λ A B C D E, functor.pentagon,\n  triangle' := λ A B C, functor.triangle }\n\n/-- `Cat` is a strict bicategory. -/\ninstance bicategory.strict : bicategory.strict Cat.{v u} :=\n{ id_comp' := λ C D F, by cases F; refl,\n  comp_id' := λ C D F, by cases F; refl,\n  assoc' := by intros; refl }\n\n/-- Category structure on `Cat` -/\ninstance category : large_category.{max v u} Cat.{v u} := strict_bicategory.category Cat.{v u}\n\n@[simp]\nlemma id_map {C : Cat} {X Y : C} (f : X ⟶ Y) : (𝟙 C : C ⥤ C).map f = f :=\nfunctor.id_map f\n\n@[simp]\nlemma comp_obj {C D E : Cat} (F : C ⟶ D) (G : D ⟶ E) (X : C) :\n  (F ≫ G).obj X = G.obj (F.obj X) :=\nfunctor.comp_obj F G X\n\n@[simp]\nlemma comp_map {C D E : Cat} (F : C ⟶ D) (G : D ⟶ E) {X Y : C} (f : X ⟶ Y) :\n  (F ≫ G).map f = G.map (F.map f) :=\nfunctor.comp_map F G f\n\n/-- Functor that gets the set of objects of a category. It is not\ncalled `forget`, because it is not a faithful functor. -/\ndef objects : Cat.{v u} ⥤ Type u :=\n{ obj := λ C, C,\n  map := λ C D F, F.obj }\n\nsection\nlocal attribute [simp] eq_to_hom_map\n\n/-- Any isomorphism in `Cat` induces an equivalence of the underlying categories. -/\ndef equiv_of_iso {C D : Cat} (γ : C ≅ D) : C ≌ D :=\n{ functor := γ.hom,\n  inverse := γ.inv,\n  unit_iso := eq_to_iso $ eq.symm γ.hom_inv_id,\n  counit_iso := eq_to_iso γ.inv_hom_id }\n\nend\n\nend Cat\n\n/--\nEmbedding `Type` into `Cat` as discrete categories.\n\nThis ought to be modelled as a 2-functor!\n-/\n@[simps]\ndef Type_to_Cat : Type u ⥤ Cat :=\n{ obj := λ X, Cat.of (discrete X),\n  map := λ X Y f, discrete.functor (discrete.mk ∘ f),\n  map_id' := λ X, begin apply functor.ext, tidy, end,\n  map_comp' := λ X Y Z f g, begin apply functor.ext, tidy, end }\n\ninstance : faithful Type_to_Cat.{u} :=\n{ map_injective' := λ X Y f g h, funext (λ x, congr_arg discrete.as (functor.congr_obj h ⟨x⟩)), }\n\ninstance : full Type_to_Cat.{u} :=\n{ preimage := λ X Y F, discrete.as ∘ F.obj ∘ discrete.mk,\n  witness' :=\n  begin\n    intros X Y F,\n    apply functor.ext,\n    { intros x y f, dsimp, ext, },\n    { rintros ⟨x⟩, ext, refl, }\n  end }\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/category/Cat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929104825006, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4940555258909024}}
{"text": "import tactic.ring\nimport tactic.ring_exp\nimport data.finset\nimport data.finsupp\nimport data.nat.choose\nimport algebra.category.CommRing.basic\nimport data.fin\nimport data.finset\nopen CommRing\nopen finset\n\n---          Goal : understand the notion of structure with a little exemple !\nnamespace co_maxi         \nstructure comax {R : Type*}[comm_ring R] (a b : R)  :=   --- ici c'est est ce que a et b sont comaximaux \n(u : R)(v : R)\n(certificat : a * u + b * v = (1 : R))\n#print comax\nlocal infix     ⊥  :=  comax   --- notation \nstructure comax_hom (A : Type*) (B : Type*)[comm_ring A] [comm_ring B] (a1 a2: A)(b1 b2 : B) :=\n    (hom : ring_hom A  B)\n    (hom_comp_point : hom a1 = b1 ∧ (hom a2 = b2))\n\n\nopen is_ring_hom  --- to have acces map_mul map_one \ndef comp (A B: Type)(φ : A → B)[comm_ring A][comm_ring B][is_ring_hom φ] (a b : A) : (comax a b) → comax (φ a) (φ b) := λ ⟨u_ab,v_ab,certificat_ab⟩, --- {} or ⟨ ⟩ λ OBJET and then OBJET.u etc \n    begin\n        have certificat : (φ a) * (φ u_ab) + (φ b) * (φ v_ab) = 1,          -- It's trivial ring identity, but i have to control ! \n            rw [ ←  map_mul φ, ← map_mul φ , ← map_add φ,certificat_ab],\n            apply map_one,\n        exact {u := φ u_ab,v := φ v_ab,certificat := certificat},            --- the constructor of structure  : i thinck better than  ⟨  ⟩ \n    end\n\nend co_maxi\nnamespace Exemple\n--- This is a closed universe   \n#print Ring\n--- but we have access to the primitive structure\n#print co_maxi.comax -- we have to co_maxi. first to acces comax ! \nend Exemple \nopen co_maxi\nnamespace comax\nsection \nparameters  {R : Type}[comm_ring R]\nparameters (a b c : R)\nlocal infix     ⊥  :=  comax   --- notation \n\n\ndef symm  :  (a) ⊥  (b)  →   (b) ⊥ (a)   :=   --- a u + b v = 1 → b v + a u = 1 \n    λ ⟨u,v,certificat⟩,    \n        begin   \n            have  t :  b * v + a * u = 1, \n                rw add_comm,  assumption,\n            use ⟨v,u,t⟩,\n        end \nlemma one_perp  :  1 ⊥ a :=   --- with 1 * 1 + a * 0 = 1 \nbegin \n    have h: 1 * 1 + a * 0 = 1,\n        rw [one_mul,mul_zero,add_zero],\n    use ⟨1,0,h⟩\nend\nlemma abab_trick : (a ⊥ c) → (b ⊥ c) → (a * b) ⊥ c :=    ---  Trick to simplify proof !  if a ⊥ c and b ⊥ c then ab ⊥ c  from calculus !  \n    λ ⟨ua,va,ka⟩  ⟨ub,vb,kb⟩, \n        begin \n            have J : (a * b) * ( ua * ub) + c * ( a * ua * vb + va * b * ub + va * c * vb) = 1,\n                 by calc \n                    (a * b) * ( ua * ub) + c * ( a * ua * vb + va * b * ub + va * c * vb)  =  (a * ua + c * va) * (b * ub + c * vb) : by ring_exp\n                    ...                                                                    =   1                                    : by rw [ka,kb, one_mul],\n        use ⟨ ua * ub,  a * ua * vb + va * b * ub + va * c * vb , J⟩,\n        end\nopen nat\nlemma star (a  b : R) (n : nat):   (a ⊥ b) → ((a^n) ⊥ b)  := \n    λ u,\n        nat.rec_on n\n                (show  (a^0) ⊥ b, {rw pow_zero a, apply one_perp, })\n                (assume n, assume re : ((a^n) ⊥ b), show (a^(n+1)) ⊥ b,\n                       {rw pow_succ a n,apply abab_trick, assumption,assumption})\n\ntheorem My_favorite_localisation_lemma (n m : nat) : (a ⊥ b) → (a^n) ⊥ (b^m) :=                 --- the goals \n    λ u, begin  \n        apply star,\n        apply symm,    -- is there a repeat method ? How to programme such method ? \n        apply star,\n        apply symm,\n        assumption,\n    end\n---- \n---     We want to proof 𝔸 is a local functor : a scheaf for global Zariski for Affᵒᵖ. \n----   ( Note 𝔸 is structural for Ring so if you do the job for 𝔸 you do the job for all ring i.e Spec R := Hom(R,•) is a scheme (in sense of functorial geometry)\n---    (ref Jantzen : 'algebraic group and representation' the first chapter) for all ring R : i can explain) ! \n---                 for the moment only with 2-covering famillies \n---     There is two axioms : \n---             1/ Separation : (for two elements ONLY)\n---                      let R : comm_ring\n---                      Let f,g ∈ R :  f ⊥ g. \n---                      Let a ∈ R : \n---                             ∃ m n : ℕ,  f^m a = 0 ∧  g^n a = 0   --- i.e a = 0 in localisation  {f^k k ∈ N⋆} and   {g^k k ∈ N⋆}\n---                      Since f ⊥ g , we have f^m ⊥ b^n \n---                      Have (u,v) s.t   f^m u + g^n v = 1\n---                      multipliying by a give f^m au  + g^n a v = a  so 0 = a ! \n---    Note : i don't use Localisation library for the moment (i have to study) !  \nparameters (f g : R)\n\nstructure localy_zero (a : R) extends  comax(f)(g) := \n(m : ℕ)(n : ℕ)\n(proof_localy_zero : f^m * a = 0 ∧ g^n * a = 0)\n\ntheorem Separation_axiom (a : R) : f ⊥ g → localy_zero (a)   →   a = 0  :=  λ coma ⟨t,m,n,proof_localy_zero ⟩,\nbegin \n     have H : (f^m) ⊥ (g^n),\n        apply My_favorite_localisation_lemma,\n        assumption,\n    rcases H with ⟨ua,va,ka⟩,\n        apply eq.symm,\n        have H :  0  = (f ^ m * a* ua  +  g ^ n *a * va),\n            rw [proof_localy_zero.1,proof_localy_zero.2],\n            apply eq.symm,\n            rw [zero_mul,zero_mul,add_zero],\n        have G : (f ^ m * a* ua  +  g ^ n *a * va) = (f ^ m * ua  +  g ^ n  * va) * a,\n        ring,\n        rewrite [H,G,ka,one_mul a], \nend \n---   Gluing_axiome : \n---\nstructure descent_data (s_f s_g : R)(n : ℕ) extends f ⊥ g  :=    --- comment est structuré la notion de desc\n(m : ℕ)                                                                      ---   F : N →₀ R  + certiticat F^⊥ : N →₀ R  co-max \n(proof_m : f^m * g^(n+m) * s_f = g^m * f^(n+m) * s_g )                       ---   là j'ai accées a des fonctions touts faites \n                                                                             ---    --->  F,  :::  s_F : ℕ  → R  et  n_F : N → ℕ   \n                                                                             ---    ' ζ_f :=  s_f / f^n_f ' (data)\nparameters s_f s_g : R                                                       ---    descent data + ∃ m_f t q  (f,g) ---> certificat f g\nparameters n : ℕ                                                             ---   \n\nstructure effective_descente_data  extends descent_data s_f  s_g n:=\n( s : R)\n(N_f : ℕ) (N_g : ℕ)\n(proof_n_plus_m_f_g : f^(N_f+n) * s = f^N_f * s_f ∧  g^(N_g+n) * s = g^N_g * s_g)\n\n\nset_option class.instance_max_depth 20\ntheorem gluing_data  :   f ⊥ g →      descent_data s_f s_g n    →   effective_descente_data  := \n         λ comma,λ y, \n            begin\n                rcases comma with ⟨u,v,proof_of_comax⟩,\n                rcases y with ⟨t,m,proof_m⟩,  \n                have H: (f^(n+m)) ⊥ (g^(n+m)),\n                    apply My_favorite_localisation_lemma,\n                assumption,\n            rcases H with ⟨vf,vg,proof_n_plus_m_f_g⟩,\n\n            have H1 : f ^ (m + n) * (vf * s_f * f ^ m + vg * s_g * g ^ m) =   ( f ^ (n + m)* vf * s_f * f ^ m +  g ^ m *f ^ (n + m) *s_g * vg), \n                        ring_exp,\n                        \n            have B1 : f ^ (n + m) * vf * s_f * f ^ m + f ^ m * g ^ (n + m) * s_f * vg = f^m *s_f *(f ^ (n + m) * vf + g ^ (n + m) * vg), \n                           ring, \n            \n            have H2 : g ^ (m + n) * (vf * s_f * f ^ m + vg * s_g * g ^ m) =      f ^ m *g ^ (n+m) *s_f *vf + g ^ m* g ^ (n + m) * vg * s_g,\n                  ring_exp,\n\n            have B2 : g ^ m * f ^ (n + m) * s_g * vf + g ^ m * g ^ (n + m) * vg * s_g = g^m * s_g *(f ^ (n + m) * vf + g ^ (n + m) * vg ), \n                      ring,\n            have Y : f^(m+n) * (vf *s_f * f^m+ vg*s_g*g^m) = f^m * s_f ∧  g^(m+n) * (vf *s_f * f^m+ vg*s_g*g^m) = g^m * s_g,\n                split,\n                rw [H1,eq.symm proof_m,B1,proof_n_plus_m_f_g,mul_one],\n                rw [H2,proof_m,B2, proof_n_plus_m_f_g,mul_one],\n            exact {to_descent_data := ⟨t,m,proof_m⟩, s := vf *s_f * f^m+ vg*s_g*g^m, N_f := m, N_g := m, proof_n_plus_m_f_g := Y},\nend\n\n#check gluing_data\n\nend co_maxi\n\n\n", "meta": {"author": "Or7ando", "repo": "lean", "sha": "d41169cf4e416a0d42092fb6bdc14131cee9dd15", "save_path": "github-repos/lean/Or7ando-lean", "path": "github-repos/lean/Or7ando-lean/lean-d41169cf4e416a0d42092fb6bdc14131cee9dd15/.github/workflows/project_1_a_decrire/foncteur/structure_comax.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.49405551941213277}}
{"text": "import .love08_operational_semantics_demo\n\n\n/- # LoVe Demo 9: Hoare Logic\n\nWe review a second way to specify the semantics of a programming language: Hoare\nlogic. If operational semantics corresponds to an idealized interpreter,\n__Hoare logic__ (also called __axiomatic semantics__) corresponds to a verifier.\nHoare logic is particularly convenient to reason about concrete programs. -/\n\n\nset_option pp.beta true\nset_option pp.generalized_field_notation false\n\nnamespace LoVe\n\n\n/- ## First Things First: Formalization Projects\n\nInstead of two of the homework sheets, you can do a verification project, worth\n20 points. If you choose to do so, please send your lecturer a message by email\nby the end of the week. For a fully successful project, we expect about 200 (or\nmore) lines of Lean, including definitions and proofs.\n\nSome ideas for projects follow.\n\nComputer science:\n\n* extended WHILE language with static arrays or other features;\n* functional data structures (e.g., balanced trees);\n* functional algorithms (e.g., bubble sort, merge sort, Tarjan's algorithm);\n* compiler from expressions or imperative programs to, e.g., stack machine;\n* type systems (e.g., Benjamin Pierce's __Types and Programming Languages__);\n* security properties (e.g., Volpano–Smith-style noninterference analysis);\n* theory of first-order terms, including matching, term rewriting;\n* automata theory;\n* normalization of context-free grammars or regular expressions;\n* process algebras and bisimilarity;\n* soundness and possibly completeness of proof systems (e.g., Genzen's sequent\n  calculus, natural deduction, tableaux);\n* separation logic;\n* verified program using Hoare logic.\n\nMathematics:\n\n* graphs;\n* combinatorics;\n* number theory.\n\nEvaluation from 2018–2019:\n\nQ: How did you find the project?\n\nA: Enjoyable.\n\nA: Fun and hard.\n\nA: Good, I think the format was excellent in a way that it gave people the\n   chance to do challenging exercises and hand them in incomplete.\n\nA: I really really liked it. I think it's a great way of learning—find\n   something you like, dig in it a little, get stuck, ask for help. I wish I\n   could do more of that!\n\nA: It was great to have some time to try to work out some stuff you find\n   interesting yourself.\n\nA: lots of fun actually!!!\n\nA: Very helpful. It gave the opportunity to spend some more time on a\n   particular aspect of the course.\n\n\n## Hoare Triples\n\nThe basic judgments of Hoare logic are often called __Hoare triples__. They have\nthe form\n\n    `{P} S {Q}`\n\nwhere `S` is a statement, and `P` and `Q` (called __precondition__ and\n__postcondition__) are logical formulas over the state variables.\n\nIntended meaning:\n\n    If `P` holds before `S` is executed and the execution terminates normally,\n    `Q` holds at termination.\n\nThis is a __partial correctness__ statement: The program is correct if it\nterminates normally (i.e., no run-time error, no infinite loop or divergence).\n\nAll of these Hoare triples are valid (with respect to the intended meaning):\n\n    `{true} b := 4 {b = 4}`\n    `{a = 2} b := 2 * a {a = 2 ∧ b = 4}`\n    `{b ≥ 5} b := b + 1 {b ≥ 6}`\n    `{false} skip {b = 100}`\n    `{true} while i ≠ 100 do i := i + 1 {i = 100}`\n\n\n## Hoare Rules\n\nThe following is a complete set of rules for reasoning about WHILE programs:\n\n    ———————————— Skip\n    {P} skip {P}\n\n    ——————————————————— Asn\n    {Q[a/x]} x := a {Q}\n\n    {P} S {R}   {R} S' {Q}\n    —————————————————————— Seq\n    {P} S; S' {Q}\n\n    {P ∧ b} S {Q}   {P ∧ ¬b} S' {Q}\n    ——————————————————————————————— If\n    {P} if b then S else S' {Q}\n\n    {I ∧ b} S {I}\n    ————————————————————————— While\n    {I} while b do S {I ∧ ¬b}\n\n    P' → P   {P} S {Q}   Q → Q'\n    ——————————————————————————— Conseq\n    {P'} S {Q'}\n\n`Q[a/x]` denotes `Q` with `x` replaced by `a`.\n\nIn the `While` rule, `I` is called an __invariant__.\n\nExcept for `Conseq`, the rules are syntax-driven: by looking at a program, we\nsee immediately which rule to apply.\n\nExample derivations:\n\n    —————————————————————— Asn   —————————————————————— Asn\n    {a = 2} b := a {b = 2}       {b = 2} c := b {c = 2}\n    ——————————————————————————————————————————————————— Seq\n    {a = 2} b := a; c := b {c = 2}\n\n\n                     —————————————————————— Asn\n    x > 10 → x > 5   {x > 5} y := x {y > 5}   y > 5 → y > 0\n    ——————————————————————————————————————————————————————— Conseq\n    {x > 10} y := x {y > 0}\n\nVarious __derived rules__ can be proved to be correct in terms of the standard\nrules. For example, we can derive bidirectional rules for `skip`, `:=`, and\n`while`:\n\n    P → Q\n    ———————————— Skip'\n    {P} skip {Q}\n\n    P → Q[a/x]\n    —————————————— Asn'\n    {P} x := a {Q}\n\n    {P ∧ b} S {P}   P ∧ ¬b → Q\n    —————————————————————————— While'\n    {P} while b do S {Q}\n\n\n## A Semantic Approach to Hoare Logic\n\nWe can, and will, define Hoare triples **semantically** in Lean.\n\nWe will use predicates on states (`state → Prop`) to represent pre- and\npostconditions, following the shallow embedding style. -/\n\ndef partial_hoare (P : state → Prop) (S : stmt)\n  (Q : state → Prop) : Prop :=\n∀s t, P s → (S, s) ⟹ t → Q t\n\nnotation `{* ` P : 1 ` *} ` S : 1 ` {* ` Q : 1 ` *}` :=\npartial_hoare P S Q\n\nnamespace partial_hoare\n\nlemma skip_intro {P} :\n  {* P *} stmt.skip {* P *} :=\nbegin\n  intros s t hs hst,\n  cases' hst,\n  assumption\nend\n\nlemma assign_intro (P : state → Prop) {x} {a : state → ℕ} :\n  {* λs, P (s{x ↦ a s}) *} stmt.assign x a {* P *} :=\nbegin\n  intros s t P hst,\n  cases' hst,\n  assumption\nend\n\nlemma seq_intro {P Q R S T} (hS : {* P *} S {* Q *})\n    (hT : {* Q *} T {* R *}) :\n  {* P *} S ;; T {* R *} :=\nbegin\n  intros s t hs hst,\n  cases' hst,\n  apply hT,\n  { apply hS,\n    { exact hs },\n    { assumption } },\n  { assumption }\nend\n\nlemma ite_intro {b P Q : state → Prop} {S T}\n    (hS : {* λs, P s ∧ b s *} S {* Q *})\n    (hT : {* λs, P s ∧ ¬ b s *} T {* Q *}) :\n  {* P *} stmt.ite b S T {* Q *} :=\nbegin\n  intros s t hs hst,\n  cases' hst,\n  { apply hS,\n    exact and.intro hs hcond,\n    assumption },\n  { apply hT,\n    exact and.intro hs hcond,\n    assumption }\nend\n\nlemma while_intro (P : state → Prop) {b : state → Prop} {S}\n    (h : {* λs, P s ∧ b s *} S {* P *}) :\n  {* P *} stmt.while b S {* λs, P s ∧ ¬ b s *} :=\nbegin\n  intros s t hs hst,\n  induction' hst,\n  case while_true {\n    apply ih_hst_1 P h,\n    exact h _ _ (and.intro hs hcond) hst },\n  case while_false {\n    exact and.intro hs hcond }\nend\n\nlemma consequence {P P' Q Q' : state → Prop} {S}\n    (h : {* P *} S {* Q *}) (hp : ∀s, P' s → P s)\n    (hq : ∀s, Q s → Q' s) :\n  {* P' *} S {* Q' *} :=\nfix s t,\nassume hs : P' s,\nassume hst : (S, s) ⟹ t,\nshow Q' t, from\n  hq _ (h s t (hp s hs) hst)\n\nlemma consequence_left (P' : state → Prop) {P Q S}\n    (h : {* P *} S {* Q *}) (hp : ∀s, P' s → P s) :\n  {* P' *} S {* Q *} :=\nconsequence h hp (by cc)\n\nlemma consequence_right (Q) {Q' : state → Prop} {P S}\n    (h : {* P *} S {* Q *}) (hq : ∀s, Q s → Q' s) :\n  {* P *} S {* Q' *} :=\nconsequence h (by cc) hq\n\nlemma skip_intro' {P Q : state → Prop} (h : ∀s, P s → Q s) :\n  {* P *} stmt.skip {* Q *} :=\nconsequence skip_intro h (by cc)\n\nlemma assign_intro' {P Q : state → Prop} {x} {a : state → ℕ}\n    (h : ∀s, P s → Q (s{x ↦ a s})):\n  {* P *} stmt.assign x a {* Q *} :=\nconsequence (assign_intro Q) h (by cc)\n\nlemma seq_intro' {P Q R S T} (hT : {* Q *} T {* R *})\n    (hS : {* P *} S {* Q *}) :\n  {* P *} S ;; T {* R *} :=\nseq_intro hS hT\n\nlemma while_intro' {b P Q : state → Prop} {S}\n    (I : state → Prop)\n    (hS : {* λs, I s ∧ b s *} S {* I *})\n    (hP : ∀s, P s → I s)\n    (hQ : ∀s, ¬ b s → I s → Q s) :\n  {* P *} stmt.while b S {* Q *} :=\nconsequence (while_intro I hS) hP (by finish)\n\n/- `finish` applies a combination of techniques, including normalization of\nlogical connectives and quantifiers, simplification, congruence closure, and\nquantifier instantiation. It either fully succeeds or fails. -/\n\nlemma assign_intro_forward (P) {x a} :\n  {* P *}\n  stmt.assign x a\n  {* λs, ∃n₀, P (s{x ↦ n₀}) ∧ s x = a (s{x ↦ n₀}) *} :=\nbegin\n  apply assign_intro',\n  intros s hP,\n  apply exists.intro (s x),\n  simp [*]\nend\n\nlemma assign_intro_backward (Q : state → Prop) {x}\n    {a : state → ℕ} :\n  {* λs, ∃n', Q (s{x ↦ n'}) ∧ n' = a s *}\n  stmt.assign x a\n  {* Q *} :=\nbegin\n  apply assign_intro',\n  intros s hP,\n  cases' hP,\n  cc\nend\n\nend partial_hoare\n\n\n/- ## First Program: Exchanging Two Variables -/\n\ndef SWAP : stmt :=\nstmt.assign \"t\" (λs, s \"a\") ;;\nstmt.assign \"a\" (λs, s \"b\") ;;\nstmt.assign \"b\" (λs, s \"t\")\n\nlemma SWAP_correct (a₀ b₀ : ℕ) :\n  {* λs, s \"a\" = a₀ ∧ s \"b\" = b₀ *}\n  SWAP\n  {* λs, s \"a\" = b₀ ∧ s \"b\" = a₀ *} :=\nbegin\n  apply partial_hoare.seq_intro',\n  apply partial_hoare.seq_intro',\n  apply partial_hoare.assign_intro,\n  apply partial_hoare.assign_intro,\n  apply partial_hoare.assign_intro',\n  simp { contextual := tt }\nend\n\nlemma SWAP_correct₂ (a₀ b₀ : ℕ) :\n  {* λs, s \"a\" = a₀ ∧ s \"b\" = b₀ *}\n  SWAP\n  {* λs, s \"a\" = b₀ ∧ s \"b\" = a₀ *} :=\nbegin\n  intros s t hP hstep,\n  cases' hstep,\n  cases' hstep,\n  cases' hstep_1,\n  cases' hstep_1_1,\n  cases' hstep_1,\n  finish\nend\n\n\n/- ## Second Program: Adding Two Numbers -/\n\ndef ADD : stmt :=\nstmt.while (λs, s \"n\" ≠ 0)\n  (stmt.assign \"n\" (λs, s \"n\" - 1) ;;\n   stmt.assign \"m\" (λs, s \"m\" + 1))\n\nlemma ADD_correct (n₀ m₀ : ℕ) :\n  {* λs, s \"n\" = n₀ ∧ s \"m\" = m₀ *}\n  ADD\n  {* λs, s \"n\" = 0 ∧ s \"m\" = n₀ + m₀ *} :=\npartial_hoare.while_intro' (λs, s \"n\" + s \"m\" = n₀ + m₀)\n  begin\n    apply partial_hoare.seq_intro',\n    { apply partial_hoare.assign_intro },\n    { apply partial_hoare.assign_intro',\n      simp,\n      intros s hnm hnz,\n      rw ←hnm,\n      cases' s \"n\",\n      { finish },\n      { simp [nat.succ_eq_add_one],\n        linarith } }\n  end\n  (by simp { contextual := true })\n  (by simp { contextual := true })\n\n\n/- ## A Verification Condition Generator\n\n__Verification condition generators__ (VCGs) are programs that apply Hoare rules\nautomatically, producing __verification conditions__ that must be proved by the\nuser. The user must usually also provide strong enough loop invariants, as an\nannotation in their programs.\n\nWe can use Lean's metaprogramming framework to define a simple VCG.\n\nHundreds if not thousands of program verification tools are based on these\nprinciples. Often these are based on an extension called separation logic.\n\nVCGs typically work backwards from the postcondition, using backward rules\n(rules stated to have an arbitrary `Q` as their postcondition). This works well\nbecause `Asn` is backward. -/\n\ndef stmt.while_inv (I b : state → Prop) (S : stmt) : stmt :=\nstmt.while b S\n\nnamespace partial_hoare\n\nlemma while_inv_intro {b I Q : state → Prop} {S}\n    (hS : {* λs, I s ∧ b s *} S {* I *})\n    (hQ : ∀s, ¬ b s → I s → Q s) :\n  {* I *} stmt.while_inv I b S {* Q *} :=\nwhile_intro' I hS (by cc) hQ\n\nlemma while_inv_intro' {b I P Q : state → Prop} {S}\n    (hS : {* λs, I s ∧ b s *} S {* I *})\n    (hP : ∀s, P s → I s) (hQ : ∀s, ¬ b s → I s → Q s) :\n  {* P *} stmt.while_inv I b S {* Q *} :=\nwhile_intro' I hS hP hQ\n\nend partial_hoare\n\nmeta def vcg : tactic unit :=\ndo\n  t ← tactic.target,\n  match t with\n  | `({* %%P *} %%S {* _ *}) :=\n    match S with\n    | `(stmt.skip)            :=\n      tactic.applyc\n        (if expr.is_mvar P then ``partial_hoare.skip_intro\n         else ``partial_hoare.skip_intro')\n    | `(stmt.assign _ _)      :=\n      tactic.applyc\n        (if expr.is_mvar P then ``partial_hoare.assign_intro\n         else ``partial_hoare.assign_intro')\n    | `(stmt.seq _ _)         :=\n      tactic.applyc ``partial_hoare.seq_intro'; vcg\n    | `(stmt.ite _ _ _)       :=\n      tactic.applyc ``partial_hoare.ite_intro; vcg\n    | `(stmt.while_inv _ _ _) :=\n      tactic.applyc\n        (if expr.is_mvar P then ``partial_hoare.while_inv_intro\n         else ``partial_hoare.while_inv_intro');\n        vcg\n    | _                       :=\n      tactic.fail (to_fmt \"cannot analyze \" ++ to_fmt S)\n    end\n  | _                        := pure ()\n  end\n\nend LoVe\n\n/- Register `vcg` as a proper tactic: -/\n\nmeta def tactic.interactive.vcg : tactic unit :=\nLoVe.vcg\n\nnamespace LoVe\n\n\n/- ## Second Program Revisited: Adding Two Numbers -/\n\nlemma ADD_correct₂ (n₀ m₀ : ℕ) :\n  {* λs, s \"n\" = n₀ ∧ s \"m\" = m₀ *}\n  ADD\n  {* λs, s \"n\" = 0 ∧ s \"m\" = n₀ + m₀ *} :=\nshow {* λs, s \"n\" = n₀ ∧ s \"m\" = m₀ *}\n     stmt.while_inv (λs, s \"n\" + s \"m\" = n₀ + m₀)\n       (λs, s \"n\" ≠ 0)\n       (stmt.assign \"n\" (λs, s \"n\" - 1) ;;\n        stmt.assign \"m\" (λs, s \"m\" + 1))\n     {* λs, s \"n\" = 0 ∧ s \"m\" = n₀ + m₀ *}, from\n  begin\n    vcg; simp { contextual := tt },\n    intros s hnm hnz,\n    rw ←hnm,\n    cases' s \"n\",\n    { finish },\n    { simp [nat.succ_eq_add_one],\n      linarith }\n  end\n\n\n/- ## Hoare Triples for Total Correctness\n\n__Total correctness__ asserts that the program not only is partially correct but\nalso that it always terminates normally. Hoare triples for total correctness\nhave the form\n\n    [P] S [Q]\n\nIntended meaning:\n\n    If `P` holds before `S` is executed, the execution terminates normally and\n    `Q` holds in the final state.\n\nFor deterministic programs, an equivalent formulation is as follows:\n\n    If `P` holds before `S` is executed, there exists a state in which execution\n    terminates normally and `Q` holds in that state.\n\nExample:\n\n    `[i ≤ 100] while i ≠ 100 do i := i + 1 [i = 100]`\n\nIn our WHILE language, this only affects while loops, which must now be\nannotated by a __variant__ `V` (a natural number that decreases with each\niteration):\n\n    [I ∧ b ∧ V = v₀] S [I ∧ V < v₀]\n    ——————————————————————————————— While-Var\n    [I] while b do S [I ∧ ¬b]\n\nWhat is a suitable variant for the example above? -/\n\nend LoVe\n", "meta": {"author": "blanchette", "repo": "logical_verification_2020", "sha": "7a9f4bd73498189d9beb5d4591e0f2b3ca316111", "save_path": "github-repos/lean/blanchette-logical_verification_2020", "path": "github-repos/lean/blanchette-logical_verification_2020/logical_verification_2020-7a9f4bd73498189d9beb5d4591e0f2b3ca316111/lean/love09_hoare_logic_demo.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102775181399, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.4940555161727477}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.sites.closed\n! leanprover-community/mathlib commit 4cfc30e317caad46858393f1a7a33f609296cc30\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Sites.SheafOfTypes\nimport Mathbin.Order.Closure\n\n/-!\n# Closed sieves\n\nA natural closure operator on sieves is a closure operator on `sieve X` for each `X` which commutes\nwith pullback.\nWe show that a Grothendieck topology `J` induces a natural closure operator, and define what the\nclosed sieves are. The collection of `J`-closed sieves forms a presheaf which is a sheaf for `J`,\nand further this presheaf can be used to determine the Grothendieck topology from the sheaf\npredicate.\nFinally we show that a natural closure operator on sieves induces a Grothendieck topology, and hence\nthat natural closure operators are in bijection with Grothendieck topologies.\n\n## Main definitions\n\n* `category_theory.grothendieck_topology.close`: Sends a sieve `S` on `X` to the set of arrows\n  which it covers. This has all the usual properties of a closure operator, as well as commuting\n  with pullback.\n* `category_theory.grothendieck_topology.closure_operator`: The bundled `closure_operator` given\n  by `category_theory.grothendieck_topology.close`.\n* `category_theory.grothendieck_topology.closed`: A sieve `S` on `X` is closed for the topology `J`\n   if it contains every arrow it covers.\n* `category_theory.functor.closed_sieves`: The presheaf sending `X` to the collection of `J`-closed\n  sieves on `X`. This is additionally shown to be a sheaf for `J`, and if this is a sheaf for a\n  different topology `J'`, then `J' ≤ J`.\n* `category_theory.grothendieck_topology.topology_of_closure_operator`: A closure operator on the\n  set of sieves on every object which commutes with pullback additionally induces a Grothendieck\n  topology, giving a bijection with `category_theory.grothendieck_topology.closure_operator`.\n\n\n## Tags\n\nclosed sieve, closure, Grothendieck topology\n\n## References\n\n* [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM92]\n-/\n\n\nuniverse v u\n\nnamespace CategoryTheory\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable (J₁ J₂ : GrothendieckTopology C)\n\nnamespace GrothendieckTopology\n\n/-- The `J`-closure of a sieve is the collection of arrows which it covers. -/\n@[simps]\ndef close {X : C} (S : Sieve X) : Sieve X\n    where\n  arrows Y f := J₁.Covers S f\n  downward_closed' Y Z f hS := J₁.arrow_stable _ _ hS\n#align category_theory.grothendieck_topology.close CategoryTheory.GrothendieckTopology.close\n\n/-- Any sieve is smaller than its closure. -/\ntheorem le_close {X : C} (S : Sieve X) : S ≤ J₁.close S := fun Y g hg =>\n  J₁.covering_of_eq_top (S.pullback_eq_top_of_mem hg)\n#align category_theory.grothendieck_topology.le_close CategoryTheory.GrothendieckTopology.le_close\n\n/-- A sieve is closed for the Grothendieck topology if it contains every arrow it covers.\nIn the case of the usual topology on a topological space, this means that the open cover contains\nevery open set which it covers.\n\nNote this has no relation to a closed subset of a topological space.\n-/\ndef IsClosed {X : C} (S : Sieve X) : Prop :=\n  ∀ ⦃Y : C⦄ (f : Y ⟶ X), J₁.Covers S f → S f\n#align category_theory.grothendieck_topology.is_closed CategoryTheory.GrothendieckTopology.IsClosed\n\n/-- If `S` is `J₁`-closed, then `S` covers exactly the arrows it contains. -/\ntheorem covers_iff_mem_of_closed {X : C} {S : Sieve X} (h : J₁.IsClosed S) {Y : C} (f : Y ⟶ X) :\n    J₁.Covers S f ↔ S f :=\n  ⟨h _, J₁.arrow_max _ _⟩\n#align category_theory.grothendieck_topology.covers_iff_mem_of_closed CategoryTheory.GrothendieckTopology.covers_iff_mem_of_closed\n\n/-- Being `J`-closed is stable under pullback. -/\ntheorem isClosed_pullback {X Y : C} (f : Y ⟶ X) (S : Sieve X) :\n    J₁.IsClosed S → J₁.IsClosed (S.pullback f) := fun hS Z g hg =>\n  hS (g ≫ f) (by rwa [J₁.covers_iff, sieve.pullback_comp])\n#align category_theory.grothendieck_topology.is_closed_pullback CategoryTheory.GrothendieckTopology.isClosed_pullback\n\n/-- The closure of a sieve `S` is the largest closed sieve which contains `S` (justifying the name\n\"closure\").\n-/\ntheorem le_close_of_isClosed {X : C} {S T : Sieve X} (h : S ≤ T) (hT : J₁.IsClosed T) :\n    J₁.close S ≤ T := fun Y f hf => hT _ (J₁.superset_covering (Sieve.pullback_monotone f h) hf)\n#align category_theory.grothendieck_topology.le_close_of_is_closed CategoryTheory.GrothendieckTopology.le_close_of_isClosed\n\n/-- The closure of a sieve is closed. -/\ntheorem close_isClosed {X : C} (S : Sieve X) : J₁.IsClosed (J₁.close S) := fun Y g hg =>\n  J₁.arrow_trans g _ S hg fun Z h hS => hS\n#align category_theory.grothendieck_topology.close_is_closed CategoryTheory.GrothendieckTopology.close_isClosed\n\n/-- The sieve `S` is closed iff its closure is equal to itself. -/\ntheorem isClosed_iff_close_eq_self {X : C} (S : Sieve X) : J₁.IsClosed S ↔ J₁.close S = S :=\n  by\n  constructor\n  · intro h\n    apply le_antisymm\n    · intro Y f hf\n      rw [← J₁.covers_iff_mem_of_closed h]\n      apply hf\n    · apply J₁.le_close\n  · intro e\n    rw [← e]\n    apply J₁.close_is_closed\n#align category_theory.grothendieck_topology.is_closed_iff_close_eq_self CategoryTheory.GrothendieckTopology.isClosed_iff_close_eq_self\n\ntheorem close_eq_self_of_isClosed {X : C} {S : Sieve X} (hS : J₁.IsClosed S) : J₁.close S = S :=\n  (J₁.isClosed_iff_close_eq_self S).1 hS\n#align category_theory.grothendieck_topology.close_eq_self_of_is_closed CategoryTheory.GrothendieckTopology.close_eq_self_of_isClosed\n\n/-- Closing under `J` is stable under pullback. -/\ntheorem pullback_close {X Y : C} (f : Y ⟶ X) (S : Sieve X) :\n    J₁.close (S.pullback f) = (J₁.close S).pullback f :=\n  by\n  apply le_antisymm\n  · refine' J₁.le_close_of_is_closed (sieve.pullback_monotone _ (J₁.le_close S)) _\n    apply J₁.is_closed_pullback _ _ (J₁.close_is_closed _)\n  · intro Z g hg\n    change _ ∈ J₁ _\n    rw [← sieve.pullback_comp]\n    apply hg\n#align category_theory.grothendieck_topology.pullback_close CategoryTheory.GrothendieckTopology.pullback_close\n\n@[mono]\ntheorem monotone_close {X : C} : Monotone (J₁.close : Sieve X → Sieve X) := fun S₁ S₂ h =>\n  J₁.le_close_of_isClosed (h.trans (J₁.le_close _)) (J₁.close_isClosed S₂)\n#align category_theory.grothendieck_topology.monotone_close CategoryTheory.GrothendieckTopology.monotone_close\n\n@[simp]\ntheorem close_close {X : C} (S : Sieve X) : J₁.close (J₁.close S) = J₁.close S :=\n  le_antisymm (J₁.le_close_of_isClosed le_rfl (J₁.close_isClosed S))\n    (J₁.monotone_close (J₁.le_close _))\n#align category_theory.grothendieck_topology.close_close CategoryTheory.GrothendieckTopology.close_close\n\n/--\nThe sieve `S` is in the topology iff its closure is the maximal sieve. This shows that the closure\noperator determines the topology.\n-/\ntheorem close_eq_top_iff_mem {X : C} (S : Sieve X) : J₁.close S = ⊤ ↔ S ∈ J₁ X :=\n  by\n  constructor\n  · intro h\n    apply J₁.transitive (J₁.top_mem X)\n    intro Y f hf\n    change J₁.close S f\n    rwa [h]\n  · intro hS\n    rw [eq_top_iff]\n    intro Y f hf\n    apply J₁.pullback_stable _ hS\n#align category_theory.grothendieck_topology.close_eq_top_iff_mem CategoryTheory.GrothendieckTopology.close_eq_top_iff_mem\n\n/-- A Grothendieck topology induces a natural family of closure operators on sieves. -/\n@[simps (config := { rhsMd := semireducible })]\ndef closureOperator (X : C) : ClosureOperator (Sieve X) :=\n  ClosureOperator.mk' J₁.close\n    (fun S₁ S₂ h => J₁.le_close_of_isClosed (h.trans (J₁.le_close _)) (J₁.close_isClosed S₂))\n    J₁.le_close fun S => J₁.le_close_of_isClosed le_rfl (J₁.close_isClosed S)\n#align category_theory.grothendieck_topology.closure_operator CategoryTheory.GrothendieckTopology.closureOperator\n\n@[simp]\ntheorem closed_iff_closed {X : C} (S : Sieve X) :\n    S ∈ (J₁.ClosureOperator X).closed ↔ J₁.IsClosed S :=\n  (J₁.isClosed_iff_close_eq_self S).symm\n#align category_theory.grothendieck_topology.closed_iff_closed CategoryTheory.GrothendieckTopology.closed_iff_closed\n\nend GrothendieckTopology\n\n/--\nThe presheaf sending each object to the set of `J`-closed sieves on it. This presheaf is a `J`-sheaf\n(and will turn out to be a subobject classifier for the category of `J`-sheaves).\n-/\n@[simps]\ndef Functor.closedSieves : Cᵒᵖ ⥤ Type max v u\n    where\n  obj X := { S : Sieve X.unop // J₁.IsClosed S }\n  map X Y f S := ⟨S.1.pullback f.unop, J₁.isClosed_pullback f.unop _ S.2⟩\n#align category_theory.functor.closed_sieves CategoryTheory.Functor.closedSieves\n\n/-- The presheaf of `J`-closed sieves is a `J`-sheaf.\nThe proof of this is adapted from [MM92], Chatper III, Section 7, Lemma 1.\n-/\ntheorem classifier_isSheaf : Presieve.IsSheaf J₁ (Functor.closedSieves J₁) :=\n  by\n  intro X S hS\n  rw [← presieve.is_separated_for_and_exists_is_amalgamation_iff_sheaf_for]\n  refine' ⟨_, _⟩\n  · rintro x ⟨M, hM⟩ ⟨N, hN⟩ hM₂ hN₂\n    ext\n    dsimp only [Subtype.coe_mk]\n    rw [← J₁.covers_iff_mem_of_closed hM, ← J₁.covers_iff_mem_of_closed hN]\n    have q : ∀ ⦃Z : C⦄ (g : Z ⟶ X) (hg : S g), M.pullback g = N.pullback g :=\n      by\n      intro Z g hg\n      apply congr_arg Subtype.val ((hM₂ g hg).trans (hN₂ g hg).symm)\n    have MSNS : M ⊓ S = N ⊓ S := by\n      ext (Z g)\n      rw [sieve.inter_apply, sieve.inter_apply, and_comm' (N g), and_comm']\n      apply and_congr_right\n      intro hg\n      rw [sieve.pullback_eq_top_iff_mem, sieve.pullback_eq_top_iff_mem, q g hg]\n    constructor\n    · intro hf\n      rw [J₁.covers_iff]\n      apply J₁.superset_covering (sieve.pullback_monotone f inf_le_left)\n      rw [← MSNS]\n      apply J₁.arrow_intersect f M S hf (J₁.pullback_stable _ hS)\n    · intro hf\n      rw [J₁.covers_iff]\n      apply J₁.superset_covering (sieve.pullback_monotone f inf_le_left)\n      rw [MSNS]\n      apply J₁.arrow_intersect f N S hf (J₁.pullback_stable _ hS)\n  · intro x hx\n    rw [presieve.compatible_iff_sieve_compatible] at hx\n    let M := sieve.bind S fun Y f hf => (x f hf).1\n    have : ∀ ⦃Y⦄ (f : Y ⟶ X) (hf : S f), M.pullback f = (x f hf).1 :=\n      by\n      intro Y f hf\n      apply le_antisymm\n      · rintro Z u ⟨W, g, f', hf', hg : (x f' hf').1 _, c⟩\n        rw [sieve.pullback_eq_top_iff_mem, ←\n          show (x (u ≫ f) _).1 = (x f hf).1.pullback u from congr_arg Subtype.val (hx f u hf)]\n        simp_rw [← c]\n        rw [show (x (g ≫ f') _).1 = _ from congr_arg Subtype.val (hx f' g hf')]\n        apply sieve.pullback_eq_top_of_mem _ hg\n      · apply sieve.le_pullback_bind S fun Y f hf => (x f hf).1\n    refine' ⟨⟨_, J₁.close_is_closed M⟩, _⟩\n    · intro Y f hf\n      ext1\n      dsimp\n      rw [← J₁.pullback_close, this _ hf]\n      apply le_antisymm (J₁.le_close_of_is_closed le_rfl (x f hf).2) (J₁.le_close _)\n#align category_theory.classifier_is_sheaf CategoryTheory.classifier_isSheaf\n\n/-- If presheaf of `J₁`-closed sieves is a `J₂`-sheaf then `J₁ ≤ J₂`. Note the converse is true by\n`classifier_is_sheaf` and `is_sheaf_of_le`.\n-/\ntheorem le_topology_of_closedSieves_isSheaf {J₁ J₂ : GrothendieckTopology C}\n    (h : Presieve.IsSheaf J₁ (Functor.closedSieves J₂)) : J₁ ≤ J₂ := fun X S hS =>\n  by\n  rw [← J₂.close_eq_top_iff_mem]\n  have : J₂.is_closed (⊤ : sieve X) := by\n    intro Y f hf\n    trivial\n  suffices (⟨J₂.close S, J₂.close_is_closed S⟩ : Subtype _) = ⟨⊤, this⟩\n    by\n    rw [Subtype.ext_iff] at this\n    exact this\n  apply (h S hS).IsSeparatedFor.ext\n  · intro Y f hf\n    ext1\n    dsimp\n    rw [sieve.pullback_top, ← J₂.pullback_close, S.pullback_eq_top_of_mem hf,\n      J₂.close_eq_top_iff_mem]\n    apply J₂.top_mem\n#align category_theory.le_topology_of_closed_sieves_is_sheaf CategoryTheory.le_topology_of_closedSieves_isSheaf\n\n/-- If being a sheaf for `J₁` is equivalent to being a sheaf for `J₂`, then `J₁ = J₂`. -/\ntheorem topology_eq_iff_same_sheaves {J₁ J₂ : GrothendieckTopology C} :\n    J₁ = J₂ ↔ ∀ P : Cᵒᵖ ⥤ Type max v u, Presieve.IsSheaf J₁ P ↔ Presieve.IsSheaf J₂ P :=\n  by\n  constructor\n  · rintro rfl\n    intro P\n    rfl\n  · intro h\n    apply le_antisymm\n    · apply le_topology_of_closed_sieves_is_sheaf\n      rw [h]\n      apply classifier_is_sheaf\n    · apply le_topology_of_closed_sieves_is_sheaf\n      rw [← h]\n      apply classifier_is_sheaf\n#align category_theory.topology_eq_iff_same_sheaves CategoryTheory.topology_eq_iff_same_sheaves\n\n/--\nA closure (increasing, inflationary and idempotent) operation on sieves that commutes with pullback\ninduces a Grothendieck topology.\nIn fact, such operations are in bijection with Grothendieck topologies.\n-/\n@[simps]\ndef topologyOfClosureOperator (c : ∀ X : C, ClosureOperator (Sieve X))\n    (hc : ∀ ⦃X Y : C⦄ (f : Y ⟶ X) (S : Sieve X), c _ (S.pullback f) = (c _ S).pullback f) :\n    GrothendieckTopology C where\n  sieves X := { S | c X S = ⊤ }\n  top_mem' X := top_unique ((c X).le_closure _)\n  pullback_stable' X Y S f hS := by\n    rw [Set.mem_setOf_eq] at hS\n    rw [Set.mem_setOf_eq, hc, hS, sieve.pullback_top]\n  transitive' X S hS R hR := by\n    rw [Set.mem_setOf_eq] at hS\n    rw [Set.mem_setOf_eq, ← (c X).idempotent, eq_top_iff, ← hS]\n    apply (c X).Monotone fun Y f hf => _\n    rw [sieve.pullback_eq_top_iff_mem, ← hc]\n    apply hR hf\n#align category_theory.topology_of_closure_operator CategoryTheory.topologyOfClosureOperator\n\n/--\nThe topology given by the closure operator `J.close` on a Grothendieck topology is the same as `J`.\n-/\ntheorem topologyOfClosureOperator_self :\n    (topologyOfClosureOperator J₁.ClosureOperator fun X Y => J₁.pullback_close) = J₁ :=\n  by\n  ext (X S)\n  apply grothendieck_topology.close_eq_top_iff_mem\n#align category_theory.topology_of_closure_operator_self CategoryTheory.topologyOfClosureOperator_self\n\ntheorem topologyOfClosureOperator_close (c : ∀ X : C, ClosureOperator (Sieve X))\n    (pb : ∀ ⦃X Y : C⦄ (f : Y ⟶ X) (S : Sieve X), c Y (S.pullback f) = (c X S).pullback f) (X : C)\n    (S : Sieve X) : (topologyOfClosureOperator c pb).close S = c X S :=\n  by\n  ext\n  change c _ (sieve.pullback f S) = ⊤ ↔ c _ S f\n  rw [pb, sieve.pullback_eq_top_iff_mem]\n#align category_theory.topology_of_closure_operator_close CategoryTheory.topologyOfClosureOperator_close\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Sites/Closed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541067, "lm_q2_score": 0.63341027059799, "lm_q1q2_score": 0.4940555140144648}}
{"text": "import data.vect\nimport .basic .prod\n\n/-!\n * Theories that have trivial initial models.\n-/\n\nnamespace model\n\n--- `is_initial th α` guarantees that `α` is an initial model of the theory `th`.\nstructure is_initial (th : theory) (α : Type _) [model th α] :=\n  (elim : Π {β : Type _} [mb : model th β], @morphism th α β _ mb.to_premodel)\n  (hunique : Π {β : Type _} [mb : model th β], ∀ (g : @morphism th α β _ mb.to_premodel) (a : α), g.val a = elim.val a)\n\n--- `has_trivial_init th` can be defined if `unit` is an initial model of the theory `th`. Examples include groups and abelian groups. Non-examples include unital rings.\nclass has_trivial_init (th : theory) :=\n  (init_unit : is_initial th unit)\n\n--- If a theory `th` has `unit` as an initial model, then every model of `th` admits an element that is closed under operations in the theory.\ndefinition fixed_element (th : theory) [ht : has_trivial_init th] (α : Type _) [model th α] : α := ((@is_initial.elim th unit _ ht.init_unit) α _).val ()\n\n--- Proof that `fixed th α` is closed under operations in the theory `th`.\ntheorem fixed_op (th : theory) [ht : has_trivial_init th] (α : Type _) [model th α] : ∀ {n} μ, fixed_element th α = @premodel.act th α _ n μ (vect.repeat (fixed_element th α) n) :=\n  begin\n    intros n μ,\n    dsimp [fixed_element],\n    cases hht: ht.init_unit with f hf,\n    dsimp [is_initial.elim],\n    rw [←vect.map_repeat],\n    let hact := (@f α _).property,\n    dunfold is_morphism at hact,\n    rw [←hact],\n    dsimp [premodel.act],\n    refl\n  end\n\n#print axioms fixed_op\n\ntheorem fixed_const (th : theory) [ht : has_trivial_init th] (α : Type _) [model th α] : ∀ (μ : th.op 0), fixed_element th α = @premodel.act th α _ _ μ vect.nil :=\n  fixed_op th α\n\n--- The morphism that factors through the terminal model.\ndefinition null_morphism (th : theory) [ht : has_trivial_init th] (α β : Type _) [model th α] [model th β] : morphism th α β :=\n  ⟨(λ _, fixed_element th β), by intros n μ as; dsimp *; rw [vect.map_const,←fixed_op th β μ]⟩\n\n--- If `unit` is an initial model, then there is a canonical morphism that injects a model `α` into the first component of a product `α×β`.\ndefinition prod_inl (th : theory) [has_trivial_init th] {α β : Type _} [model th α] [model th β] : morphism th α (α×β) :=\n{\n  val := λ a, (a, fixed_element th β),\n  property :=\n    begin\n      intros n μ as,\n      dsimp [premodel.act, prod.map],\n      rw [vect.unzip_fst_is_map_fst, vect.unzip_snd_is_map_snd],\n      csimp [←vect.map_comp],\n      dsimp [function.comp],\n      have : @id α = (λ x,x) , from rfl,\n      rw [←this,vect.map_id]; clear this,\n      rw [vect.map_const],\n      rw [←fixed_op th β μ],\n    end\n}\n\n--- If `unit` is an initial model, then there is a canonical morphism that injects a model `β` into the second component of a product `α×β`.\ndefinition prod_inr (th : theory) [has_trivial_init th] {α β : Type _} [model th α] [model th β] : morphism th β (α×β) :=\n{\n  val := λ b, (fixed_element th α,b),\n  property :=\n    begin\n      intros n μ as,\n      dsimp [premodel.act, prod.map],\n      rw [vect.unzip_fst_is_map_fst, vect.unzip_snd_is_map_snd],\n      csimp [←vect.map_comp],\n      dsimp [function.comp],\n      have : @id β = (λ x,x) , from rfl,\n      rw [←this,vect.map_id]; clear this,\n      rw [vect.map_const],\n      rw [←fixed_op th α μ],\n    end\n}\n\n#print axioms prod_inl\n#print axioms prod_inr\n\nend model\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/algebra/theory/initial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257127, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.49405549134269167}}
{"text": "import model_theory.substructures\nimport model_theory.bundled\n\n\n--OUTPUT 1\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n  -- For each $n$, let $\\mathbf A_n$ be the formula:\n  let A : ℕ → L.formula,\n  -- $\\exists x_1 \\exists x_2 \\ldots \\exists x_n: \\{x_1 \\ne x_2 \\land x_1 \\ne x_3 \\land \\ldots \\land x_{n - 1} \\ne x_n\\}$\n  have h1 : ∀ n : ℕ, A n = ∃' (x : fin n), ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n    assume n : ℕ,\n    have h2 : ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n      assume (i j : fin n) (hne : i ≠ j),\n      have h3 : i < n ∧ j < n, from by {split, apply fin.lt_iff_ne_zero.mp hne.left, apply fin.lt_iff_ne_zero.mp hne.right},\n      have h4 : i ≠ j, from by {apply ne_of_lt, exact h3.left},\n      have h5 : i ≠ j, from by {apply ne_of_lt, exact h3.right},\n      show x i ≠ x j, from by {apply ne_of_ne_of_ne, exact h4, exact h5},\n    },\n    show A n = ∃' (x : fin n), ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n      apply funext,\n      assume x : fin n,\n      show (∃' (x : fin n), ∀ (i j : fin n), i ≠ j → x i ≠ x j) x ↔ ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n        split,\n        assume h3 : (∃' (x : fin n), ∀ (i j : fin n), i ≠ j → x i ≠ x j) x,\n        show ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n          assume (i j : fin n) (hne : i ≠ j),\n          have h4 : ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n            assume (i j : fin n) (hne : i ≠ j),\n            have h5 : i < n ∧ j < n, from by {split, apply fin.lt_iff_ne_zero.mp hne.left, apply fin.lt_iff_ne_zero.mp hne.right},\n            have h6 : i ≠ j, from by {apply ne_of_lt, exact h5.left},\n            have h7 : i ≠ j, from by {apply ne_of_lt, exact h5.right},\n            show x i ≠ x j, from by {apply ne_of_ne_of_ne, exact h6, exact h7},\n          },\n          show x i ≠ x j, from by {apply h4, exact hne},\n        },\n        assume h3 : ∀ (i j : fin n), i ≠ j → x i ≠ x j,\n        show (∃' (x : fin n), ∀ (i j : fin n), i ≠ j → x i ≠ x j) x, from by {\n          apply exists.intro x,\n          show ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n            assume (i j : fin n) (hne : i ≠ j),\n            have h4 : ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n              assume (i j : fin n) (hne : i ≠ j),\n              have h5 : i < n ∧ j < n, from by {split, apply fin.lt_iff_ne_zero.mp hne.left, apply fin.lt_iff_ne_zero.mp hne.right},\n              have h6 : i ≠ j, from by {apply ne_of_lt, exact h5.left},\n              have h7 : i ≠ j, from by {apply ne_of_lt, exact h5.right},\n              show x i ≠ x j, from by {apply ne_of_ne_of_ne, exact h6, exact h7},\n            },\n            show x i ≠ x j, from by {apply h4, exact hne},\n          },\n        },\n      },\n    },\n  },\n  -- Then $\\mathbf A_i$ is true in a structure $\\AA$ iff $\\AA$ has at least $n$ elements.\n  have h2 : ∀ (n : ℕ) (M : F.Model), M ⊨ A n ↔ fintype.card M ≥ n, from by {\n    assume (n : ℕ) (M : F.Model),\n    have h3 : ∀ (n : ℕ) (M : F.Model), M ⊨ A n → fintype.card M ≥ n, from by {\n      assume (n : ℕ) (M : F.Model) (h4 : M ⊨ A n),\n      have h5 : ∃ (x : fin n → M), ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n        have h6 : ∃ (x : fin n → M), ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n          apply exists.elim h4,\n          assume (x : fin n → M),\n          assume h7 : ∀ (i j : fin n), i ≠ j → x i ≠ x j,\n          show ∃ (x : fin n → M), ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n            apply exists.intro x,\n            show ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n              assume (i j : fin n) (hne : i ≠ j),\n              have h8 : ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n                assume (i j : fin n) (hne : i ≠ j),\n                have h9 : i < n ∧ j < n, from by {split, apply fin.lt_iff_ne_zero.mp hne.left, apply fin.lt_iff_ne_zero.mp hne.right},\n                have h10 : i ≠ j, from by {apply ne_of_lt, exact h9.left},\n                have h11 : i ≠ j, from by {apply ne_of_lt, exact h9.right},\n                show x i ≠ x j, from by {apply ne_of_ne_of_ne, exact h10, exact h11},\n              },\n              show x i ≠ x j, from by {apply h8, exact hne},\n            },\n          },\n        },\n        show ∃ (x : fin n → M), ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n          apply exists.elim h6,\n          assume (x : fin n → M),\n          assume h7 : ∀ (i j : fin n), i ≠ j → x i ≠ x j,\n          show ∃ (x : fin n → M), ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n            apply exists.intro x,\n            show ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n              assume (i j : fin n) (hne : i ≠ j),\n              have h8 : ∀ (i j : fin n), i ≠ j → x i ≠ x j, from by {\n                assume (i j : fin n) (hne : i ≠ j),\n                have h9 : i < n ∧ j < n, from by {split, apply fin.lt_iff_ne_zero.mp hne.left, apply fin.lt_iff_ne_zero.mp hne\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by rw add_mul\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n    assume a b : G, use a⁻¹ * b, obviously, },\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n    assume a b : G, use b * a⁻¹, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n    exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n    (mul_one a),\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n    exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n        exists_unique.unique (h3 a) (hident a).right\n        (classical.some_spec (exists_unique.exists (h3 a))), \n      have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n        exists_unique.unique (h4 a) (hident a).left\n        (classical.some_spec (exists_unique.exists (h4 a))),\n      show e = (1 : G), from eq.trans (h9 e) (h6 _),     \n    },\n    exact ⟨by obviously, h7⟩,\n  }\nend\n\n/--`theorem`\nOverflow theorem\nLet $F$ be a set of first-order formulas which has finite models of arbitrarily large size. Then $F$ has an infinite model.\n`proof`\nFor each $n$, let $\\mathbf A_n$ be the formula:\n\n$\\exists x_1 \\exists x_2 \\ldots \\exists x_n: \\{x_1 \\ne x_2 \\land x_1 \\ne x_3 \\land \\ldots \\land x_{n - 1} \\ne x_n\\}$\n\nThen $\\mathbf A_i$ is true in a structure $\\AA$ iff $\\AA$ has at least $n$ elements.\n\nTake:\n$$ \\Gamma := F \\cup \\bigcup_{i \\mathop = 1}^\\infty A_i $$\n\nSince $F$ has models of arbitrarily large size, every finite subset of $\\Gamma$ is satisfiable.\n\nFrom the Compactness Theorem, $\\Gamma$ is satisfiable in some model $\\mathbf{M}$.\n\nBut since $\\mathbf{M} \\models A_i$ for each $i$, $\\mathbf{M}$ must be infinite.\n\nSo $F$ has an infinite model.\n\nQED\n-/\ntheorem  overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_with_comments-Natural-Language-Proof-Translation/Correct_statement-lean_proof_with_comments-3_few_shot_temperature_0_max_tokens_2000_n_1/clean_files/Overflow theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4940377275761945}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.homology.homological_complex\nimport category_theory.differential_object\n\n/-!\n# Homological complexes are differential graded objects.\n\nWe verify that a `homological_complex` indexed by an `add_comm_group` is\nessentially the same thing as a differential graded object.\n\nThis equivalence is probably not particularly useful in practice;\nit's here to check that definitions match up as expected.\n-/\n\nopen category_theory\nopen category_theory.limits\n\nopen_locale classical\nnoncomputable theory\n\nnamespace homological_complex\n\nvariables {β : Type*} [add_comm_group β] {b : β}\nvariables {V : Type*} [category V] [has_zero_morphisms V]\n\n/-- Since `eq_to_hom` only preserves the fact that `X.X i = X.X j` but not `i = j`, this definition\nis used to aid the simplifier. -/\nabbreviation _root_.category_theory.differential_object.X_eq_to_hom\n  (X : differential_object (graded_object_with_shift b V))\n  {i j : β} (h : i = j) : X.X i ⟶ X.X j := eq_to_hom (congr_arg X.X h)\n\n@[simp] lemma _root_.category_theory.differential_object.X_eq_to_hom_refl\n  (X : differential_object (graded_object_with_shift b V)) (i : β) :\n  X.X_eq_to_hom (refl i) = 𝟙 _ := rfl\n\n@[simp, reassoc] lemma eq_to_hom_d (X : differential_object (graded_object_with_shift b V))\n  {x y : β} (h : x = y) :\n  X.X_eq_to_hom h ≫ X.d y = X.d x ≫ X.X_eq_to_hom (by { cases h, refl }) :=\nby { cases h, dsimp, simp }\n\n@[simp, reassoc] lemma d_eq_to_hom (X : homological_complex V (complex_shape.up' b))\n  {x y z : β} (h : y = z) :\n  X.d x y ≫ eq_to_hom (congr_arg X.X h) = X.d x z :=\nby { cases h, simp }\n\n@[simp, reassoc] lemma eq_to_hom_f {X Y : differential_object (graded_object_with_shift b V)}\n  (f : X ⟶ Y) {x y : β} (h : x = y) :\n  X.X_eq_to_hom h ≫ f.f y = f.f x ≫ Y.X_eq_to_hom h :=\nby { cases h, simp }\n\nvariables (b V)\n\nlocal attribute [reducible] graded_object.has_shift\n\n/--\nThe functor from differential graded objects to homological complexes.\n-/\n@[simps]\ndef dgo_to_homological_complex :\n  differential_object (graded_object_with_shift b V) ⥤\n    homological_complex V (complex_shape.up' b) :=\n{ obj := λ X,\n  { X := λ i, X.X i,\n    d := λ i j, if h : i + b = j then\n      X.d i ≫ X.X_eq_to_hom (show i + (1 : ℤ) • b = j, by simp [h]) else 0,\n    shape' := λ i j w, by { dsimp at w, convert dif_neg w },\n    d_comp_d' := λ i j k hij hjk, begin\n      dsimp at hij hjk, substs hij hjk,\n      have : X.d i ≫ X.d _ = _ := (congr_fun X.d_squared i : _),\n      reassoc! this,\n      simp [this],\n    end },\n  map := λ X Y f,\n  { f := f.f,\n    comm' := λ i j h, begin\n      dsimp at h ⊢,\n      subst h,\n      have : f.f i ≫ Y.d i = X.d i ≫ f.f (i + 1 • b) := (congr_fun f.comm i).symm,\n      reassoc! this,\n      simp only [category.comp_id, eq_to_hom_refl, dif_pos rfl, this, category.assoc, eq_to_hom_f]\n    end, } }\n\n/--\nThe functor from homological complexes to differential graded objects.\n-/\n@[simps]\ndef homological_complex_to_dgo :\n  homological_complex V (complex_shape.up' b) ⥤\n    differential_object (graded_object_with_shift b V) :=\n{ obj := λ X,\n  { X := λ i, X.X i,\n    d := λ i, X.d i (i + 1 • b),\n    d_squared' := by { ext i, dsimp, simp, } },\n  map := λ X Y f,\n  { f := f.f,\n    comm' := by { ext i, dsimp, simp, }, } }\n\n/--\nThe unit isomorphism for `dgo_equiv_homological_complex`.\n-/\n@[simps]\ndef dgo_equiv_homological_complex_unit_iso :\n  𝟭 (differential_object (graded_object_with_shift b V)) ≅\n    dgo_to_homological_complex b V ⋙ homological_complex_to_dgo b V :=\nnat_iso.of_components (λ X,\n  { hom := { f := λ i, 𝟙 (X.X i), },\n    inv := { f := λ i, 𝟙 (X.X i), }, }) (by tidy)\n\n/--\nThe counit isomorphism for `dgo_equiv_homological_complex`.\n-/\n@[simps]\ndef dgo_equiv_homological_complex_counit_iso :\n  homological_complex_to_dgo b V ⋙ dgo_to_homological_complex b V ≅\n    𝟭 (homological_complex V (complex_shape.up' b)) :=\nnat_iso.of_components (λ X,\n  { hom :=\n    { f := λ i, 𝟙 (X.X i),\n      comm' := λ i j h, begin\n        dsimp at h ⊢, subst h,\n        delta homological_complex_to_dgo,\n        simp,\n      end },\n    inv :=\n    { f := λ i, 𝟙 (X.X i),\n      comm' := λ i j h, begin\n        dsimp at h ⊢, subst h,\n        delta homological_complex_to_dgo,\n        simp,\n      end }, }) (by tidy)\n\n/--\nThe category of differential graded objects in `V` is equivalent\nto the category of homological complexes in `V`.\n-/\n@[simps]\ndef dgo_equiv_homological_complex :\n  differential_object (graded_object_with_shift b V) ≌\n    homological_complex V (complex_shape.up' b) :=\n{ functor := dgo_to_homological_complex b V,\n  inverse := homological_complex_to_dgo b V,\n  unit_iso := dgo_equiv_homological_complex_unit_iso b V,\n  counit_iso := dgo_equiv_homological_complex_counit_iso b V, }\n\nend homological_complex\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebra/homology/differential_object.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4940377219243606}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Std.Data.Option.Init.Lemmas\nimport Std.Data.Option.Basic\nimport Std.Tactic.Ext.Attr\nimport Std.Logic\n\nnamespace Option\n\ntheorem mem_iff {a : α} {b : Option α} : a ∈ b ↔ b = a := .rfl\n\ntheorem some_ne_none (x : α) : some x ≠ none := fun.\n\nprotected theorem «forall» {p : Option α → Prop} : (∀ x, p x) ↔ p none ∧ ∀ x, p (some x) :=\n  ⟨fun h => ⟨h _, fun _ => h _⟩, fun h x => Option.casesOn x h.1 h.2⟩\n\nprotected theorem «exists» {p : Option α → Prop} : (∃ x, p x) ↔ p none ∨ ∃ x, p (some x) :=\n  ⟨fun | ⟨none, hx⟩ => .inl hx | ⟨some x, hx⟩ => .inr ⟨x, hx⟩,\n   fun | .inl h => ⟨_, h⟩ | .inr ⟨_, hx⟩ => ⟨_, hx⟩⟩\n\ntheorem get_mem : ∀ {o : Option α} (h : isSome o), o.get h ∈ o\n| some _, _ => rfl\n\ntheorem get_of_mem : ∀ {o : Option α} (h : isSome o), a ∈ o → o.get h = a\n| _, _, rfl => rfl\n\ntheorem not_mem_none (a : α) : a ∉ (none : Option α) := fun.\n\n@[simp] theorem some_get : ∀ {x : Option α} (h : isSome x), some (x.get h) = x\n| some _, _ => rfl\n\n@[simp] theorem get_some (x : α) (h : isSome (some x)) : (some x).get h = x := rfl\n\ntheorem getD_of_ne_none {x : Option α} (hx : x ≠ none) (y : α) : some (x.getD y) = x := by\n  cases x; {contradiction}; rw [getD_some]\n\ntheorem mem_unique {o : Option α} {a b : α} (ha : a ∈ o) (hb : b ∈ o) : a = b :=\n  some.inj <| ha ▸ hb\n\n@[ext] theorem ext : ∀ {o₁ o₂ : Option α}, (∀ a, a ∈ o₁ ↔ a ∈ o₂) → o₁ = o₂\n  | none, none, _ => rfl\n  | some _, _, H => ((H _).1 rfl).symm\n  | _, some _, H => (H _).2 rfl\n\ntheorem eq_none_iff_forall_not_mem : o = none ↔ ∀ a, a ∉ o :=\n  ⟨fun e a h => by rw [e] at h; (cases h), fun h => ext <| by simp; exact h⟩\n\n@[simp] theorem isSome_none : @isSome α none = false := rfl\n\n@[simp] theorem isSome_some : isSome (some a) = true := rfl\n\ntheorem isSome_iff_exists : isSome x ↔ ∃ a, x = some a := by cases x <;> simp [isSome]\n\n@[simp] theorem isNone_none : @isNone α none = true := rfl\n\n@[simp] theorem isNone_some : isNone (some a) = false := rfl\n\n@[simp] theorem not_isSome : isSome a = false ↔ a.isNone = true := by\n  cases a <;> simp\n\ntheorem eq_some_iff_get_eq : o = some a ↔ ∃ h : o.isSome, o.get h = a := by\n  cases o <;> simp; intro.\n\ntheorem eq_some_of_isSome : ∀ {o : Option α} (h : o.isSome), o = some (o.get h)\n  | some _, _ => rfl\n\ntheorem not_isSome_iff_eq_none : ¬o.isSome ↔ o = none := by\n  cases o <;> simp\n\ntheorem ne_none_iff_isSome : o ≠ none ↔ o.isSome := by cases o <;> simp\n\ntheorem ne_none_iff_exists : o ≠ none ↔ ∃ x, some x = o := by cases o <;> simp\n\ntheorem ne_none_iff_exists' : o ≠ none ↔ ∃ x, o = some x :=\n  ne_none_iff_exists.trans <| exists_congr fun _ => eq_comm\n\n\n\ntheorem ball_ne_none {p : Option α → Prop} : (∀ x (_ : x ≠ none), p x) ↔ ∀ x, p (some x) :=\n  ⟨fun h x => h (some x) (some_ne_none x),\n    fun h x hx => by\n      have := h <| x.get <| ne_none_iff_isSome.1 hx\n      simp [some_get] at this ⊢\n      exact this⟩\n\n@[simp] theorem bind_some (x : Option α) : x.bind some = x := by cases x <;> rfl\n\n@[simp] theorem bind_eq_some : x.bind f = some b ↔ ∃ a, x = some a ∧ f a = some b := by\n  cases x <;> simp\n\n@[simp] theorem bind_eq_none {o : Option α} {f : α → Option β} :\n    o.bind f = none ↔ ∀ b a, a ∈ o → b ∉ f a := by\n  simp only [eq_none_iff_forall_not_mem, not_exists, not_and, mem_def, bind_eq_some]\n\ntheorem bind_comm {f : α → β → Option γ} (a : Option α) (b : Option β) :\n    (a.bind fun x => b.bind (f x)) = b.bind fun y => a.bind fun x => f x y := by\n  cases a <;> cases b <;> rfl\n\ntheorem bind_assoc (x : Option α) (f : α → Option β) (g : β → Option γ) :\n    (x.bind f).bind g = x.bind fun y => (f y).bind g := by cases x <;> rfl\n\ntheorem join_eq_some : x.join = some a ↔ x = some (some a) := by\n  simp\n\ntheorem join_ne_none : x.join ≠ none ↔ ∃ z, x = some (some z) := by\n  simp only [ne_none_iff_exists', join_eq_some, iff_self]\n\ntheorem join_ne_none' : ¬x.join = none ↔ ∃ z, x = some (some z) :=\n  join_ne_none\n\ntheorem join_eq_none : o.join = none ↔ o = none ∨ o = some none :=\n  match o with | none | some none | some (some _) => by simp\n\ntheorem bind_id_eq_join {x : Option (Option α)} : x.bind id = x.join := rfl\n\n@[simp] theorem map_eq_map : Functor.map f = Option.map f := rfl\n\ntheorem map_none : f <$> none = none := rfl\n\ntheorem map_some : f <$> some a = some (f a) := rfl\n\n@[simp] theorem map_eq_some' : x.map f = some b ↔ ∃ a, x = some a ∧ f a = b := by cases x <;> simp\n\ntheorem map_eq_some : f <$> x = some b ↔ ∃ a, x = some a ∧ f a = b := map_eq_some'\n\n@[simp] theorem map_eq_none' : x.map f = none ↔ x = none := by\n  cases x <;> simp only [map_none', map_some', eq_self_iff_true]\n\ntheorem map_eq_none : f <$> x = none ↔ x = none := map_eq_none'\n\ntheorem map_eq_bind {x : Option α} : x.map f = x.bind (some ∘ f) := by\n  cases x <;> simp [Option.bind]\n\ntheorem map_congr {x : Option α} (h : ∀ a ∈ x, f a = g a) : x.map f = x.map g := by\n  cases x <;> simp only [map_none', map_some', h, mem_def]\n\n@[simp] theorem map_id' : Option.map (@id α) = id := map_id\n\n@[simp] theorem map_map (h : β → γ) (g : α → β) (x : Option α) :\n    (x.map g).map h = x.map (h ∘ g) := by\n  cases x <;> simp only [map_none', map_some', ·∘·]\n\ntheorem comp_map (h : β → γ) (g : α → β) (x : Option α) : x.map (h ∘ g) = (x.map g).map h :=\n  (map_map ..).symm\n\n@[simp] theorem map_comp_map (f : α → β) (g : β → γ) :\n    Option.map g ∘ Option.map f = Option.map (g ∘ f) := by funext x; simp\n\ntheorem mem_map_of_mem (g : α → β) (h : a ∈ x) : g a ∈ Option.map g x := h.symm ▸ map_some' ..\n\ntheorem bind_map_comm {α β} {x : Option (Option α)} {f : α → β} :\n    x.bind (Option.map f) = (x.map (Option.map f)).bind id := by cases x <;> simp\n\ntheorem join_map_eq_map_join {f : α → β} {x : Option (Option α)} :\n    (x.map (Option.map f)).join = x.join.map f := by cases x <;> simp\n\ntheorem join_join {x : Option (Option (Option α))} : x.join.join = (x.map join).join := by\n  cases x <;> simp\n\ntheorem mem_of_mem_join {a : α} {x : Option (Option α)} (h : a ∈ x.join) : some a ∈ x :=\n  h.symm ▸ join_eq_some.1 h\n\n@[simp] theorem some_orElse (a : α) (x : Option α) : (some a <|> x) = some a := rfl\n\n@[simp] theorem none_orElse (x : Option α) : (none <|> x) = x := rfl\n\n@[simp] theorem orElse_none (x : Option α) : (x <|> none) = x := by cases x <;> rfl\n\n@[simp] theorem guard_eq_some [DecidablePred p] : guard p a = some b ↔ a = b ∧ p a := by\n  by_cases h : p a <;> simp [Option.guard, h]\n\ntheorem liftOrGet_eq_or_eq {f : α → α → α} (h : ∀ a b, f a b = a ∨ f a b = b) :\n    ∀ o₁ o₂, liftOrGet f o₁ o₂ = o₁ ∨ liftOrGet f o₁ o₂ = o₂\n  | none, none => .inl rfl\n  | some a, none => .inl rfl\n  | none, some b => .inr rfl\n  | some a, some b => by have := h a b; simp [liftOrGet] at this ⊢; exact this\n\n@[simp] theorem liftOrGet_none_left {f} {b : Option α} : liftOrGet f none b = b := by\n  cases b <;> rfl\n\n@[simp] theorem liftOrGet_none_right {f} {a : Option α} : liftOrGet f a none = a := by\n  cases a <;> rfl\n\n@[simp] theorem liftOrGet_some_some {f} {a b : α} :\n  liftOrGet f (some a) (some b) = f a b := rfl\n\ntheorem elim_none (x : β) (f : α → β) : none.elim x f = x := rfl\n\ntheorem elim_some (x : β) (f : α → β) (a : α) : (some a).elim x f = f a := rfl\n\n@[simp] theorem getD_map (f : α → β) (x : α) (o : Option α) :\n  (o.map f).getD (f x) = f (getD o x) := by cases o <;> rfl\n\nsection\n\nattribute [local instance] Classical.propDecidable\n\n/-- An arbitrary `some a` with `a : α` if `α` is nonempty, and otherwise `none`. -/\nnoncomputable def choice (α : Type _) : Option α :=\n  if h : Nonempty α then some (Classical.choice h) else none\n\ntheorem choice_eq {α : Type _} [Subsingleton α] (a : α) : choice α = some a := by\n  simp [choice]\n  rw [dif_pos (⟨a⟩ : Nonempty α)]\n  simp; apply Subsingleton.elim\n\ntheorem choice_isSome_iff_nonempty {α : Type _} : (choice α).isSome ↔ Nonempty α :=\n  ⟨fun h => ⟨(choice α).get h⟩, fun h => by simp only [choice, dif_pos h, isSome_some]⟩\n\nend\n\n@[simp] theorem to_list_some (a : α) : (a : Option α).toList = [a] := rfl\n\n@[simp] theorem to_list_none (α : Type _) : (none : Option α).toList = [] := rfl\n", "meta": {"author": "leanprover", "repo": "std4", "sha": "5507f9d8409f93b984ce04eccf4914d534e6fca2", "save_path": "github-repos/lean/leanprover-std4", "path": "github-repos/lean/leanprover-std4/std4-5507f9d8409f93b984ce04eccf4914d534e6fca2/Std/Data/Option/Lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788308, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.49402351429728636}}
{"text": "/-\nCopyright (c) 2020 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis\n-/\nimport linear_algebra.affine_space.affine_map\nimport topology.algebra.group\nimport topology.algebra.mul_action\n\n/-!\n# Topological properties of affine spaces and maps\n\nFor now, this contains only a few facts regarding the continuity of affine maps in the special\ncase when the point space and vector space are the same.\n\nTODO: Deal with the case where the point spaces are different from the vector spaces. Note that\nwe do have some results in this direction under the assumption that the topologies are induced by\n(semi)norms.\n-/\n\nnamespace affine_map\n\nvariables {R E F : Type*}\nvariables [add_comm_group E] [topological_space E]\nvariables [add_comm_group F] [topological_space F] [topological_add_group F]\n\nsection ring\n\nvariables [ring R] [module R E] [module R F]\n\n/-- An affine map is continuous iff its underlying linear map is continuous. See also\n`affine_map.continuous_linear_iff`. -/\nlemma continuous_iff {f : E →ᵃ[R] F} :\n  continuous f ↔ continuous f.linear :=\nbegin\n  split,\n  { intro hc,\n    rw decomp' f,\n    have := hc.sub continuous_const,\n    exact this, },\n  { intro hc,\n    rw decomp f,\n    have := hc.add continuous_const,\n    exact this }\nend\n\n/-- The line map is continuous. -/\n@[continuity]\nlemma line_map_continuous [topological_space R] [has_continuous_smul R F] {p v : F} :\n  continuous ⇑(line_map p v : R →ᵃ[R] F) :=\ncontinuous_iff.mpr $ (continuous_id.smul continuous_const).add $\n  @continuous_const _ _ _ _ (0 : F)\n\nend ring\n\nsection comm_ring\n\nvariables [comm_ring R] [module R F] [has_continuous_const_smul R F]\n\n@[continuity]\nlemma homothety_continuous (x : F) (t : R) : continuous $ homothety x t :=\nbegin\n  suffices : ⇑(homothety x t) = λ y, t • (y - x) + x, { rw this, continuity, },\n  ext y,\n  simp [homothety_apply],\nend\n\nend comm_ring\n\nsection field\n\nvariables [field R] [module R F] [has_continuous_const_smul R F]\n\nlemma homothety_is_open_map (x : F) (t : R) (ht : t ≠ 0) : is_open_map $ homothety x t :=\nbegin\n  apply is_open_map.of_inverse (homothety_continuous x t⁻¹);\n  intros e;\n  simp [← affine_map.comp_apply, ← homothety_mul, ht],\nend\n\nend field\n\nend affine_map\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/algebra/affine.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.49402351348319057}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n\n! This file was ported from Lean 3 source module measure_theory.group.arithmetic\n! leanprover-community/mathlib commit a75898643b2d774cced9ae7c0b28c21663b99666\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.MeasureTheory.Measure.AeMeasurable\n\n/-!\n# Typeclasses for measurability of operations\n\nIn this file we define classes `has_measurable_mul` etc and prove dot-style lemmas\n(`measurable.mul`, `ae_measurable.mul` etc). For binary operations we define two typeclasses:\n\n- `has_measurable_mul` says that both left and right multiplication are measurable;\n- `has_measurable_mul₂` says that `λ p : α × α, p.1 * p.2` is measurable,\n\nand similarly for other binary operations. The reason for introducing these classes is that in case\nof topological space `α` equipped with the Borel `σ`-algebra, instances for `has_measurable_mul₂`\netc require `α` to have a second countable topology.\n\nWe define separate classes for `has_measurable_div`/`has_measurable_sub`\nbecause on some types (e.g., `ℕ`, `ℝ≥0∞`) division and/or subtraction are not defined as `a * b⁻¹` /\n`a + (-b)`.\n\nFor instances relating, e.g., `has_continuous_mul` to `has_measurable_mul` see file\n`measure_theory.borel_space`.\n\n## Implementation notes\n\nFor the heuristics of `@[to_additive]` it is important that the type with a multiplication\n(or another multiplicative operations) is the first (implicit) argument of all declarations.\n\n## Tags\n\nmeasurable function, arithmetic operator\n\n## Todo\n\n* Uniformize the treatment of `pow` and `smul`.\n* Use `@[to_additive]` to send `has_measurable_pow` to `has_measurable_smul₂`.\n* This might require changing the definition (swapping the arguments in the function that is\n  in the conclusion of `measurable_smul`.)\n-/\n\n\nuniverse u v\n\nopen BigOperators Pointwise MeasureTheory\n\nopen MeasureTheory\n\n/-!\n### Binary operations: `(+)`, `(*)`, `(-)`, `(/)`\n-/\n\n\n/-- We say that a type `has_measurable_add` if `((+) c)` and `(+ c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (+)` see `has_measurable_add₂`. -/\nclass HasMeasurableAdd (M : Type _) [MeasurableSpace M] [Add M] : Prop where\n  measurable_const_add : ∀ c : M, Measurable ((· + ·) c)\n  measurable_add_const : ∀ c : M, Measurable (· + c)\n#align has_measurable_add HasMeasurableAdd\n\nexport HasMeasurableAdd (measurable_const_add measurable_add_const)\n\n/-- We say that a type `has_measurable_add` if `uncurry (+)` is a measurable functions.\nFor a typeclass assuming measurability of `((+) c)` and `(+ c)` see `has_measurable_add`. -/\nclass HasMeasurableAdd₂ (M : Type _) [MeasurableSpace M] [Add M] : Prop where\n  measurable_add : Measurable fun p : M × M => p.1 + p.2\n#align has_measurable_add₂ HasMeasurableAdd₂\n\nexport HasMeasurableAdd₂ (measurable_add)\n\nexport HasMeasurableAdd (measurable_const_add measurable_add_const)\n\n/-- We say that a type `has_measurable_mul` if `((*) c)` and `(* c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (*)` see `has_measurable_mul₂`. -/\n@[to_additive]\nclass HasMeasurableMul (M : Type _) [MeasurableSpace M] [Mul M] : Prop where\n  measurable_const_mul : ∀ c : M, Measurable ((· * ·) c)\n  measurable_mul_const : ∀ c : M, Measurable (· * c)\n#align has_measurable_mul HasMeasurableMul\n#align has_measurable_add HasMeasurableAdd\n\nexport HasMeasurableMul (measurable_const_mul measurable_mul_const)\n\n/-- We say that a type `has_measurable_mul` if `uncurry (*)` is a measurable functions.\nFor a typeclass assuming measurability of `((*) c)` and `(* c)` see `has_measurable_mul`. -/\n@[to_additive HasMeasurableAdd₂]\nclass HasMeasurableMul₂ (M : Type _) [MeasurableSpace M] [Mul M] : Prop where\n  measurable_mul : Measurable fun p : M × M => p.1 * p.2\n#align has_measurable_mul₂ HasMeasurableMul₂\n#align has_measurable_add₂ HasMeasurableAdd₂\n\nexport HasMeasurableMul₂ (measurable_mul)\n\nsection Mul\n\nvariable {M α : Type _} [MeasurableSpace M] [Mul M] {m : MeasurableSpace α} {f g : α → M}\n  {μ : Measure α}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Measurable.const_mul [HasMeasurableMul M] (hf : Measurable f) (c : M) :\n    Measurable fun x => c * f x :=\n  (measurable_const_mul c).comp hf\n#align measurable.const_mul Measurable.const_mul\n#align measurable.const_add Measurable.const_add\n\n@[measurability, to_additive]\ntheorem AeMeasurable.constMul [HasMeasurableMul M] (hf : AeMeasurable f μ) (c : M) :\n    AeMeasurable (fun x => c * f x) μ :=\n  (HasMeasurableMul.measurable_const_mul c).compAeMeasurable hf\n#align ae_measurable.const_mul AeMeasurable.constMul\n#align ae_measurable.const_add AeMeasurable.const_add\n\n@[measurability, to_additive]\ntheorem Measurable.mul_const [HasMeasurableMul M] (hf : Measurable f) (c : M) :\n    Measurable fun x => f x * c :=\n  (measurable_mul_const c).comp hf\n#align measurable.mul_const Measurable.mul_const\n#align measurable.add_const Measurable.add_const\n\n@[measurability, to_additive]\ntheorem AeMeasurable.mulConst [HasMeasurableMul M] (hf : AeMeasurable f μ) (c : M) :\n    AeMeasurable (fun x => f x * c) μ :=\n  (measurable_mul_const c).compAeMeasurable hf\n#align ae_measurable.mul_const AeMeasurable.mulConst\n#align ae_measurable.add_const AeMeasurable.add_const\n\n@[measurability, to_additive]\ntheorem Measurable.mul' [HasMeasurableMul₂ M] (hf : Measurable f) (hg : Measurable g) :\n    Measurable (f * g) :=\n  measurable_mul.comp (hf.prod_mk hg)\n#align measurable.mul' Measurable.mul'\n#align measurable.add' Measurable.add'\n\n@[measurability, to_additive]\ntheorem Measurable.mul [HasMeasurableMul₂ M] (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun a => f a * g a :=\n  measurable_mul.comp (hf.prod_mk hg)\n#align measurable.mul Measurable.mul\n#align measurable.add Measurable.add\n\n@[measurability, to_additive]\ntheorem AeMeasurable.mul' [HasMeasurableMul₂ M] (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) :\n    AeMeasurable (f * g) μ :=\n  measurable_mul.compAeMeasurable (hf.prod_mk hg)\n#align ae_measurable.mul' AeMeasurable.mul'\n#align ae_measurable.add' AeMeasurable.add'\n\n@[measurability, to_additive]\ntheorem AeMeasurable.mul [HasMeasurableMul₂ M] (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) :\n    AeMeasurable (fun a => f a * g a) μ :=\n  measurable_mul.compAeMeasurable (hf.prod_mk hg)\n#align ae_measurable.mul AeMeasurable.mul\n#align ae_measurable.add AeMeasurable.add\n\nomit m\n\n@[to_additive]\ninstance (priority := 100) HasMeasurableMul₂.to_hasMeasurableMul [HasMeasurableMul₂ M] :\n    HasMeasurableMul M :=\n  ⟨fun c => measurable_const.mul measurable_id, fun c => measurable_id.mul measurable_const⟩\n#align has_measurable_mul₂.to_has_measurable_mul HasMeasurableMul₂.to_hasMeasurableMul\n#align has_measurable_add₂.to_has_measurable_add HasMeasurableAdd₂.to_has_measurable_add\n\n@[to_additive]\ninstance Pi.hasMeasurableMul {ι : Type _} {α : ι → Type _} [∀ i, Mul (α i)]\n    [∀ i, MeasurableSpace (α i)] [∀ i, HasMeasurableMul (α i)] : HasMeasurableMul (∀ i, α i) :=\n  ⟨fun g => measurable_pi_iff.mpr fun i => (measurable_pi_apply i).const_mul _, fun g =>\n    measurable_pi_iff.mpr fun i => (measurable_pi_apply i).mul_const _⟩\n#align pi.has_measurable_mul Pi.hasMeasurableMul\n#align pi.has_measurable_add Pi.has_measurable_add\n\n@[to_additive Pi.has_measurable_add₂]\ninstance Pi.hasMeasurableMul₂ {ι : Type _} {α : ι → Type _} [∀ i, Mul (α i)]\n    [∀ i, MeasurableSpace (α i)] [∀ i, HasMeasurableMul₂ (α i)] : HasMeasurableMul₂ (∀ i, α i) :=\n  ⟨measurable_pi_iff.mpr fun i => measurable_fst.eval.mul measurable_snd.eval⟩\n#align pi.has_measurable_mul₂ Pi.hasMeasurableMul₂\n#align pi.has_measurable_add₂ Pi.has_measurable_add₂\n\nattribute [measurability]\n  Measurable.add' Measurable.add AeMeasurable.add AeMeasurable.add' Measurable.const_add AeMeasurable.const_add Measurable.add_const AeMeasurable.add_const\n\nend Mul\n\n/-- A version of `measurable_div_const` that assumes `has_measurable_mul` instead of\n  `has_measurable_div`. This can be nice to avoid unnecessary type-class assumptions. -/\n@[to_additive\n      \" A version of `measurable_sub_const` that assumes `has_measurable_add` instead of\\n  `has_measurable_sub`. This can be nice to avoid unnecessary type-class assumptions. \"]\ntheorem measurable_div_const' {G : Type _} [DivInvMonoid G] [MeasurableSpace G] [HasMeasurableMul G]\n    (g : G) : Measurable fun h => h / g := by simp_rw [div_eq_mul_inv, measurable_mul_const]\n#align measurable_div_const' measurable_div_const'\n#align measurable_sub_const' measurable_sub_const'\n\n/-- This class assumes that the map `β × γ → β` given by `(x, y) ↦ x ^ y` is measurable. -/\nclass HasMeasurablePow (β γ : Type _) [MeasurableSpace β] [MeasurableSpace γ] [Pow β γ] where\n  measurable_pow : Measurable fun p : β × γ => p.1 ^ p.2\n#align has_measurable_pow HasMeasurablePow\n\nexport HasMeasurablePow (measurable_pow)\n\n/-- `monoid.has_pow` is measurable. -/\ninstance Monoid.hasMeasurablePow (M : Type _) [Monoid M] [MeasurableSpace M] [HasMeasurableMul₂ M] :\n    HasMeasurablePow M ℕ :=\n  ⟨measurable_from_prod_countable fun n =>\n      by\n      induction' n with n ih\n      · simp only [pow_zero, ← Pi.one_def, measurable_one]\n      · simp only [pow_succ]\n        exact measurable_id.mul ih⟩\n#align monoid.has_measurable_pow Monoid.hasMeasurablePow\n\nsection Pow\n\nvariable {β γ α : Type _} [MeasurableSpace β] [MeasurableSpace γ] [Pow β γ] [HasMeasurablePow β γ]\n  {m : MeasurableSpace α} {μ : Measure α} {f : α → β} {g : α → γ}\n\ninclude m\n\n@[measurability]\ntheorem Measurable.pow (hf : Measurable f) (hg : Measurable g) : Measurable fun x => f x ^ g x :=\n  measurable_pow.comp (hf.prod_mk hg)\n#align measurable.pow Measurable.pow\n\n@[measurability]\ntheorem AeMeasurable.pow (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) :\n    AeMeasurable (fun x => f x ^ g x) μ :=\n  measurable_pow.compAeMeasurable (hf.prod_mk hg)\n#align ae_measurable.pow AeMeasurable.pow\n\n@[measurability]\ntheorem Measurable.pow_const (hf : Measurable f) (c : γ) : Measurable fun x => f x ^ c :=\n  hf.pow measurable_const\n#align measurable.pow_const Measurable.pow_const\n\n@[measurability]\ntheorem AeMeasurable.powConst (hf : AeMeasurable f μ) (c : γ) : AeMeasurable (fun x => f x ^ c) μ :=\n  hf.pow aeMeasurableConst\n#align ae_measurable.pow_const AeMeasurable.powConst\n\n@[measurability]\ntheorem Measurable.const_pow (hg : Measurable g) (c : β) : Measurable fun x => c ^ g x :=\n  measurable_const.pow hg\n#align measurable.const_pow Measurable.const_pow\n\n@[measurability]\ntheorem AeMeasurable.constPow (hg : AeMeasurable g μ) (c : β) : AeMeasurable (fun x => c ^ g x) μ :=\n  aeMeasurableConst.pow hg\n#align ae_measurable.const_pow AeMeasurable.constPow\n\nomit m\n\nend Pow\n\n/-- We say that a type `has_measurable_sub` if `(λ x, c - x)` and `(λ x, x - c)` are measurable\nfunctions. For a typeclass assuming measurability of `uncurry (-)` see `has_measurable_sub₂`. -/\nclass HasMeasurableSub (G : Type _) [MeasurableSpace G] [Sub G] : Prop where\n  measurable_const_sub : ∀ c : G, Measurable fun x => c - x\n  measurable_sub_const : ∀ c : G, Measurable fun x => x - c\n#align has_measurable_sub HasMeasurableSub\n\nexport HasMeasurableSub (measurable_const_sub measurable_sub_const)\n\n/-- We say that a type `has_measurable_sub` if `uncurry (-)` is a measurable functions.\nFor a typeclass assuming measurability of `((-) c)` and `(- c)` see `has_measurable_sub`. -/\nclass HasMeasurableSub₂ (G : Type _) [MeasurableSpace G] [Sub G] : Prop where\n  measurable_sub : Measurable fun p : G × G => p.1 - p.2\n#align has_measurable_sub₂ HasMeasurableSub₂\n\nexport HasMeasurableSub₂ (measurable_sub)\n\n/-- We say that a type `has_measurable_div` if `((/) c)` and `(/ c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (/)` see `has_measurable_div₂`. -/\n@[to_additive]\nclass HasMeasurableDiv (G₀ : Type _) [MeasurableSpace G₀] [Div G₀] : Prop where\n  measurable_const_div : ∀ c : G₀, Measurable ((· / ·) c)\n  measurable_div_const : ∀ c : G₀, Measurable (· / c)\n#align has_measurable_div HasMeasurableDiv\n#align has_measurable_sub HasMeasurableSub\n\nexport HasMeasurableDiv (measurable_const_div measurable_div_const)\n\n/-- We say that a type `has_measurable_div` if `uncurry (/)` is a measurable functions.\nFor a typeclass assuming measurability of `((/) c)` and `(/ c)` see `has_measurable_div`. -/\n@[to_additive HasMeasurableSub₂]\nclass HasMeasurableDiv₂ (G₀ : Type _) [MeasurableSpace G₀] [Div G₀] : Prop where\n  measurable_div : Measurable fun p : G₀ × G₀ => p.1 / p.2\n#align has_measurable_div₂ HasMeasurableDiv₂\n#align has_measurable_sub₂ HasMeasurableSub₂\n\nexport HasMeasurableDiv₂ (measurable_div)\n\nsection Div\n\nvariable {G α : Type _} [MeasurableSpace G] [Div G] {m : MeasurableSpace α} {f g : α → G}\n  {μ : Measure α}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Measurable.const_div [HasMeasurableDiv G] (hf : Measurable f) (c : G) :\n    Measurable fun x => c / f x :=\n  (HasMeasurableDiv.measurable_const_div c).comp hf\n#align measurable.const_div Measurable.const_div\n#align measurable.const_sub Measurable.const_sub\n\n@[measurability, to_additive]\ntheorem AeMeasurable.constDiv [HasMeasurableDiv G] (hf : AeMeasurable f μ) (c : G) :\n    AeMeasurable (fun x => c / f x) μ :=\n  (HasMeasurableDiv.measurable_const_div c).compAeMeasurable hf\n#align ae_measurable.const_div AeMeasurable.constDiv\n#align ae_measurable.const_sub AeMeasurable.const_sub\n\n@[measurability, to_additive]\ntheorem Measurable.div_const [HasMeasurableDiv G] (hf : Measurable f) (c : G) :\n    Measurable fun x => f x / c :=\n  (HasMeasurableDiv.measurable_div_const c).comp hf\n#align measurable.div_const Measurable.div_const\n#align measurable.sub_const Measurable.sub_const\n\n@[measurability, to_additive]\ntheorem AeMeasurable.divConst [HasMeasurableDiv G] (hf : AeMeasurable f μ) (c : G) :\n    AeMeasurable (fun x => f x / c) μ :=\n  (HasMeasurableDiv.measurable_div_const c).compAeMeasurable hf\n#align ae_measurable.div_const AeMeasurable.divConst\n#align ae_measurable.sub_const AeMeasurable.sub_const\n\n@[measurability, to_additive]\ntheorem Measurable.div' [HasMeasurableDiv₂ G] (hf : Measurable f) (hg : Measurable g) :\n    Measurable (f / g) :=\n  measurable_div.comp (hf.prod_mk hg)\n#align measurable.div' Measurable.div'\n#align measurable.sub' Measurable.sub'\n\n@[measurability, to_additive]\ntheorem Measurable.div [HasMeasurableDiv₂ G] (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun a => f a / g a :=\n  measurable_div.comp (hf.prod_mk hg)\n#align measurable.div Measurable.div\n#align measurable.sub Measurable.sub\n\n@[measurability, to_additive]\ntheorem AeMeasurable.div' [HasMeasurableDiv₂ G] (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) :\n    AeMeasurable (f / g) μ :=\n  measurable_div.compAeMeasurable (hf.prod_mk hg)\n#align ae_measurable.div' AeMeasurable.div'\n#align ae_measurable.sub' AeMeasurable.sub'\n\n@[measurability, to_additive]\ntheorem AeMeasurable.div [HasMeasurableDiv₂ G] (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) :\n    AeMeasurable (fun a => f a / g a) μ :=\n  measurable_div.compAeMeasurable (hf.prod_mk hg)\n#align ae_measurable.div AeMeasurable.div\n#align ae_measurable.sub AeMeasurable.sub\n\nattribute [measurability]\n  Measurable.sub Measurable.sub' AeMeasurable.sub AeMeasurable.sub' Measurable.const_sub AeMeasurable.const_sub Measurable.sub_const AeMeasurable.sub_const\n\nomit m\n\n@[to_additive]\ninstance (priority := 100) HasMeasurableDiv₂.to_hasMeasurableDiv [HasMeasurableDiv₂ G] :\n    HasMeasurableDiv G :=\n  ⟨fun c => measurable_const.div measurable_id, fun c => measurable_id.div measurable_const⟩\n#align has_measurable_div₂.to_has_measurable_div HasMeasurableDiv₂.to_hasMeasurableDiv\n#align has_measurable_sub₂.to_has_measurable_sub HasMeasurableSub₂.to_has_measurable_sub\n\n@[to_additive]\ninstance Pi.hasMeasurableDiv {ι : Type _} {α : ι → Type _} [∀ i, Div (α i)]\n    [∀ i, MeasurableSpace (α i)] [∀ i, HasMeasurableDiv (α i)] : HasMeasurableDiv (∀ i, α i) :=\n  ⟨fun g => measurable_pi_iff.mpr fun i => (measurable_pi_apply i).const_div _, fun g =>\n    measurable_pi_iff.mpr fun i => (measurable_pi_apply i).div_const _⟩\n#align pi.has_measurable_div Pi.hasMeasurableDiv\n#align pi.has_measurable_sub Pi.has_measurable_sub\n\n@[to_additive Pi.has_measurable_sub₂]\ninstance Pi.hasMeasurableDiv₂ {ι : Type _} {α : ι → Type _} [∀ i, Div (α i)]\n    [∀ i, MeasurableSpace (α i)] [∀ i, HasMeasurableDiv₂ (α i)] : HasMeasurableDiv₂ (∀ i, α i) :=\n  ⟨measurable_pi_iff.mpr fun i => measurable_fst.eval.div measurable_snd.eval⟩\n#align pi.has_measurable_div₂ Pi.hasMeasurableDiv₂\n#align pi.has_measurable_sub₂ Pi.has_measurable_sub₂\n\n@[measurability]\ntheorem measurableSet_eq_fun {m : MeasurableSpace α} {E} [MeasurableSpace E] [AddGroup E]\n    [MeasurableSingletonClass E] [HasMeasurableSub₂ E] {f g : α → E} (hf : Measurable f)\n    (hg : Measurable g) : MeasurableSet { x | f x = g x } :=\n  by\n  suffices h_set_eq : { x : α | f x = g x } = { x | (f - g) x = (0 : E) }\n  · rw [h_set_eq]\n    exact (hf.sub hg) measurableSet_eq\n  ext\n  simp_rw [Set.mem_setOf_eq, Pi.sub_apply, sub_eq_zero]\n#align measurable_set_eq_fun measurableSet_eq_fun\n\ntheorem nullMeasurableSetEqFun {E} [MeasurableSpace E] [AddGroup E] [MeasurableSingletonClass E]\n    [HasMeasurableSub₂ E] {f g : α → E} (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) :\n    NullMeasurableSet { x | f x = g x } μ :=\n  by\n  apply (measurableSet_eq_fun hf.measurable_mk hg.measurable_mk).NullMeasurableSet.congr\n  filter_upwards [hf.ae_eq_mk, hg.ae_eq_mk]with x hfx hgx\n  change (hf.mk f x = hg.mk g x) = (f x = g x)\n  simp only [hfx, hgx]\n#align null_measurable_set_eq_fun nullMeasurableSetEqFun\n\ntheorem measurableSet_eq_fun_of_countable {m : MeasurableSpace α} {E} [MeasurableSpace E]\n    [MeasurableSingletonClass E] [Countable E] {f g : α → E} (hf : Measurable f)\n    (hg : Measurable g) : MeasurableSet { x | f x = g x } :=\n  by\n  have : { x | f x = g x } = ⋃ j, { x | f x = j } ∩ { x | g x = j } :=\n    by\n    ext1 x\n    simp only [Set.mem_setOf_eq, Set.mem_unionᵢ, Set.mem_inter_iff, exists_eq_right']\n  rw [this]\n  refine' MeasurableSet.unionᵢ fun j => MeasurableSet.inter _ _\n  · exact hf (measurable_set_singleton j)\n  · exact hg (measurable_set_singleton j)\n#align measurable_set_eq_fun_of_countable measurableSet_eq_fun_of_countable\n\ntheorem ae_eq_trim_of_measurable {α E} {m m0 : MeasurableSpace α} {μ : Measure α}\n    [MeasurableSpace E] [AddGroup E] [MeasurableSingletonClass E] [HasMeasurableSub₂ E]\n    (hm : m ≤ m0) {f g : α → E} (hf : measurable[m] f) (hg : measurable[m] g) (hfg : f =ᵐ[μ] g) :\n    f =ᶠ[@Measure.ae α m (μ.trim hm)] g :=\n  by\n  rwa [Filter.EventuallyEq, ae_iff, trim_measurable_set_eq hm _]\n  exact @MeasurableSet.compl α _ m (@measurableSet_eq_fun α m E _ _ _ _ _ _ hf hg)\n#align ae_eq_trim_of_measurable ae_eq_trim_of_measurable\n\nend Div\n\n/-- We say that a type `has_measurable_neg` if `x ↦ -x` is a measurable function. -/\nclass HasMeasurableNeg (G : Type _) [Neg G] [MeasurableSpace G] : Prop where\n  measurable_neg : Measurable (Neg.neg : G → G)\n#align has_measurable_neg HasMeasurableNeg\n\n/-- We say that a type `has_measurable_inv` if `x ↦ x⁻¹` is a measurable function. -/\n@[to_additive]\nclass HasMeasurableInv (G : Type _) [Inv G] [MeasurableSpace G] : Prop where\n  measurable_inv : Measurable (Inv.inv : G → G)\n#align has_measurable_inv HasMeasurableInv\n#align has_measurable_neg HasMeasurableNeg\n\nexport HasMeasurableInv (measurable_inv)\n\nexport HasMeasurableNeg (measurable_neg)\n\n@[to_additive]\ninstance (priority := 100) hasMeasurableDiv_of_mul_inv (G : Type _) [MeasurableSpace G]\n    [DivInvMonoid G] [HasMeasurableMul G] [HasMeasurableInv G] : HasMeasurableDiv G\n    where\n  measurable_const_div c := by\n    convert measurable_inv.const_mul c\n    ext1\n    apply div_eq_mul_inv\n  measurable_div_const c := by\n    convert measurable_id.mul_const c⁻¹\n    ext1\n    apply div_eq_mul_inv\n#align has_measurable_div_of_mul_inv hasMeasurableDiv_of_mul_inv\n#align has_measurable_sub_of_add_neg has_measurable_sub_of_add_neg\n\nsection Inv\n\nvariable {G α : Type _} [Inv G] [MeasurableSpace G] [HasMeasurableInv G] {m : MeasurableSpace α}\n  {f : α → G} {μ : Measure α}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Measurable.inv (hf : Measurable f) : Measurable fun x => (f x)⁻¹ :=\n  measurable_inv.comp hf\n#align measurable.inv Measurable.inv\n#align measurable.neg Measurable.neg\n\n@[measurability, to_additive]\ntheorem AeMeasurable.inv (hf : AeMeasurable f μ) : AeMeasurable (fun x => (f x)⁻¹) μ :=\n  measurable_inv.compAeMeasurable hf\n#align ae_measurable.inv AeMeasurable.inv\n#align ae_measurable.neg AeMeasurable.neg\n\nattribute [measurability] Measurable.neg AeMeasurable.neg\n\n@[simp, to_additive]\ntheorem measurable_inv_iff {G : Type _} [Group G] [MeasurableSpace G] [HasMeasurableInv G]\n    {f : α → G} : (Measurable fun x => (f x)⁻¹) ↔ Measurable f :=\n  ⟨fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv⟩\n#align measurable_inv_iff measurable_inv_iff\n#align measurable_neg_iff measurable_neg_iff\n\n@[simp, to_additive]\ntheorem aeMeasurable_inv_iff {G : Type _} [Group G] [MeasurableSpace G] [HasMeasurableInv G]\n    {f : α → G} : AeMeasurable (fun x => (f x)⁻¹) μ ↔ AeMeasurable f μ :=\n  ⟨fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv⟩\n#align ae_measurable_inv_iff aeMeasurable_inv_iff\n#align ae_measurable_neg_iff ae_measurable_neg_iff\n\n@[simp]\ntheorem measurable_inv_iff₀ {G₀ : Type _} [GroupWithZero G₀] [MeasurableSpace G₀]\n    [HasMeasurableInv G₀] {f : α → G₀} : (Measurable fun x => (f x)⁻¹) ↔ Measurable f :=\n  ⟨fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv⟩\n#align measurable_inv_iff₀ measurable_inv_iff₀\n\n@[simp]\ntheorem aeMeasurable_inv_iff₀ {G₀ : Type _} [GroupWithZero G₀] [MeasurableSpace G₀]\n    [HasMeasurableInv G₀] {f : α → G₀} : AeMeasurable (fun x => (f x)⁻¹) μ ↔ AeMeasurable f μ :=\n  ⟨fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv⟩\n#align ae_measurable_inv_iff₀ aeMeasurable_inv_iff₀\n\nomit m\n\n@[to_additive]\ninstance Pi.hasMeasurableInv {ι : Type _} {α : ι → Type _} [∀ i, Inv (α i)]\n    [∀ i, MeasurableSpace (α i)] [∀ i, HasMeasurableInv (α i)] : HasMeasurableInv (∀ i, α i) :=\n  ⟨measurable_pi_iff.mpr fun i => (measurable_pi_apply i).inv⟩\n#align pi.has_measurable_inv Pi.hasMeasurableInv\n#align pi.has_measurable_neg Pi.has_measurable_neg\n\n@[to_additive]\ntheorem MeasurableSet.inv {s : Set G} (hs : MeasurableSet s) : MeasurableSet s⁻¹ :=\n  measurable_inv hs\n#align measurable_set.inv MeasurableSet.inv\n#align measurable_set.neg MeasurableSet.neg\n\nend Inv\n\n/-- `div_inv_monoid.has_pow` is measurable. -/\ninstance DivInvMonoid.hasMeasurableZpow (G : Type u) [DivInvMonoid G] [MeasurableSpace G]\n    [HasMeasurableMul₂ G] [HasMeasurableInv G] : HasMeasurablePow G ℤ :=\n  ⟨measurable_from_prod_countable fun n => by\n      cases' n with n n\n      · simp_rw [zpow_ofNat]\n        exact measurable_id.pow_const _\n      · simp_rw [zpow_negSucc]\n        exact (measurable_id.pow_const (n + 1)).inv⟩\n#align div_inv_monoid.has_measurable_zpow DivInvMonoid.hasMeasurableZpow\n\n@[to_additive]\ninstance (priority := 100) hasMeasurableDiv₂_of_mul_inv (G : Type _) [MeasurableSpace G]\n    [DivInvMonoid G] [HasMeasurableMul₂ G] [HasMeasurableInv G] : HasMeasurableDiv₂ G :=\n  ⟨by\n    simp only [div_eq_mul_inv]\n    exact measurable_fst.mul measurable_snd.inv⟩\n#align has_measurable_div₂_of_mul_inv hasMeasurableDiv₂_of_mul_inv\n#align has_measurable_div₂_of_add_neg hasMeasurableDiv₂_of_add_neg\n\n/-- We say that the action of `M` on `α` `has_measurable_vadd` if for each `c` the map `x ↦ c +ᵥ x`\nis a measurable function and for each `x` the map `c ↦ c +ᵥ x` is a measurable function. -/\nclass HasMeasurableVadd (M α : Type _) [VAdd M α] [MeasurableSpace M] [MeasurableSpace α] :\n  Prop where\n  measurable_const_vadd : ∀ c : M, Measurable ((· +ᵥ ·) c : α → α)\n  measurable_vadd_const : ∀ x : α, Measurable fun c : M => c +ᵥ x\n#align has_measurable_vadd HasMeasurableVadd\n\n/-- We say that the action of `M` on `α` `has_measurable_smul` if for each `c` the map `x ↦ c • x`\nis a measurable function and for each `x` the map `c ↦ c • x` is a measurable function. -/\n@[to_additive]\nclass HasMeasurableSmul (M α : Type _) [SMul M α] [MeasurableSpace M] [MeasurableSpace α] :\n  Prop where\n  measurable_const_smul : ∀ c : M, Measurable ((· • ·) c : α → α)\n  measurable_smul_const : ∀ x : α, Measurable fun c : M => c • x\n#align has_measurable_smul HasMeasurableSmul\n#align has_measurable_vadd HasMeasurableVadd\n\n/-- We say that the action of `M` on `α` `has_measurable_vadd₂` if the map\n`(c, x) ↦ c +ᵥ x` is a measurable function. -/\nclass HasMeasurableVadd₂ (M α : Type _) [VAdd M α] [MeasurableSpace M] [MeasurableSpace α] :\n  Prop where\n  measurable_vadd : Measurable (Function.uncurry (· +ᵥ ·) : M × α → α)\n#align has_measurable_vadd₂ HasMeasurableVadd₂\n\n/-- We say that the action of `M` on `α` `has_measurable_smul₂` if the map\n`(c, x) ↦ c • x` is a measurable function. -/\n@[to_additive HasMeasurableVadd₂]\nclass HasMeasurableSmul₂ (M α : Type _) [SMul M α] [MeasurableSpace M] [MeasurableSpace α] :\n  Prop where\n  measurable_smul : Measurable (Function.uncurry (· • ·) : M × α → α)\n#align has_measurable_smul₂ HasMeasurableSmul₂\n#align has_measurable_vadd₂ HasMeasurableVadd₂\n\nexport HasMeasurableSmul (measurable_const_smul measurable_smul_const)\n\nexport HasMeasurableSmul₂ (measurable_smul)\n\nexport HasMeasurableVadd (measurable_const_vadd measurable_vadd_const)\n\nexport HasMeasurableVadd₂ (measurable_vadd)\n\n@[to_additive]\ninstance hasMeasurableSmul_of_mul (M : Type _) [Mul M] [MeasurableSpace M] [HasMeasurableMul M] :\n    HasMeasurableSmul M M :=\n  ⟨measurable_id.const_mul, measurable_id.mul_const⟩\n#align has_measurable_smul_of_mul hasMeasurableSmul_of_mul\n#align has_measurable_vadd_of_add has_measurable_vadd_of_add\n\n@[to_additive]\ninstance hasMeasurableSmul₂_of_mul (M : Type _) [Mul M] [MeasurableSpace M] [HasMeasurableMul₂ M] :\n    HasMeasurableSmul₂ M M :=\n  ⟨measurable_mul⟩\n#align has_measurable_smul₂_of_mul hasMeasurableSmul₂_of_mul\n#align has_measurable_smul₂_of_add hasMeasurableSmul₂_of_add\n\n@[to_additive]\ninstance Submonoid.hasMeasurableSmul {M α} [MeasurableSpace M] [MeasurableSpace α] [Monoid M]\n    [MulAction M α] [HasMeasurableSmul M α] (s : Submonoid M) : HasMeasurableSmul s α :=\n  ⟨fun c => by simpa only using measurable_const_smul (c : M), fun x =>\n    (measurable_smul_const x : Measurable fun c : M => c • x).comp measurable_subtype_coe⟩\n#align submonoid.has_measurable_smul Submonoid.hasMeasurableSmul\n#align add_submonoid.has_measurable_vadd AddSubmonoid.has_measurable_vadd\n\n@[to_additive]\ninstance Subgroup.hasMeasurableSmul {G α} [MeasurableSpace G] [MeasurableSpace α] [Group G]\n    [MulAction G α] [HasMeasurableSmul G α] (s : Subgroup G) : HasMeasurableSmul s α :=\n  s.toSubmonoid.HasMeasurableSmul\n#align subgroup.has_measurable_smul Subgroup.hasMeasurableSmul\n#align add_subgroup.has_measurable_vadd AddSubgroup.has_measurable_vadd\n\nsection Smul\n\nvariable {M β α : Type _} [MeasurableSpace M] [MeasurableSpace β] [SMul M β] {m : MeasurableSpace α}\n  {f : α → M} {g : α → β}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Measurable.smul [HasMeasurableSmul₂ M β] (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun x => f x • g x :=\n  measurable_smul.comp (hf.prod_mk hg)\n#align measurable.smul Measurable.smul\n#align measurable.vadd Measurable.vadd\n\n@[measurability, to_additive]\ntheorem AeMeasurable.smul [HasMeasurableSmul₂ M β] {μ : Measure α} (hf : AeMeasurable f μ)\n    (hg : AeMeasurable g μ) : AeMeasurable (fun x => f x • g x) μ :=\n  HasMeasurableSmul₂.measurable_smul.compAeMeasurable (hf.prod_mk hg)\n#align ae_measurable.smul AeMeasurable.smul\n#align ae_measurable.vadd AeMeasurable.vadd\n\nomit m\n\n@[to_additive]\ninstance (priority := 100) HasMeasurableSmul₂.to_hasMeasurableSmul [HasMeasurableSmul₂ M β] :\n    HasMeasurableSmul M β :=\n  ⟨fun c => measurable_const.smul measurable_id, fun y => measurable_id.smul measurable_const⟩\n#align has_measurable_smul₂.to_has_measurable_smul HasMeasurableSmul₂.to_hasMeasurableSmul\n#align has_measurable_vadd₂.to_has_measurable_vadd HasMeasurableVadd₂.to_has_measurable_vadd\n\ninclude m\n\nvariable [HasMeasurableSmul M β] {μ : Measure α}\n\n@[measurability, to_additive]\ntheorem Measurable.smul_const (hf : Measurable f) (y : β) : Measurable fun x => f x • y :=\n  (HasMeasurableSmul.measurable_smul_const y).comp hf\n#align measurable.smul_const Measurable.smul_const\n#align measurable.vadd_const Measurable.vadd_const\n\n@[measurability, to_additive]\ntheorem AeMeasurable.smulConst (hf : AeMeasurable f μ) (y : β) :\n    AeMeasurable (fun x => f x • y) μ :=\n  (HasMeasurableSmul.measurable_smul_const y).compAeMeasurable hf\n#align ae_measurable.smul_const AeMeasurable.smulConst\n#align ae_measurable.vadd_const AeMeasurable.vadd_const\n\n@[measurability, to_additive]\ntheorem Measurable.const_smul' (hg : Measurable g) (c : M) : Measurable fun x => c • g x :=\n  (HasMeasurableSmul.measurable_const_smul c).comp hg\n#align measurable.const_smul' Measurable.const_smul'\n#align measurable.const_vadd' Measurable.const_vadd'\n\n@[measurability, to_additive]\ntheorem Measurable.const_smul (hg : Measurable g) (c : M) : Measurable (c • g) :=\n  hg.const_smul' c\n#align measurable.const_smul Measurable.const_smul\n#align measurable.const_vadd Measurable.const_vadd\n\n@[measurability, to_additive]\ntheorem AeMeasurable.constSmul' (hg : AeMeasurable g μ) (c : M) :\n    AeMeasurable (fun x => c • g x) μ :=\n  (HasMeasurableSmul.measurable_const_smul c).compAeMeasurable hg\n#align ae_measurable.const_smul' AeMeasurable.constSmul'\n#align ae_measurable.const_vadd' AeMeasurable.const_vadd'\n\n@[measurability, to_additive]\ntheorem AeMeasurable.constSmul (hf : AeMeasurable g μ) (c : M) : AeMeasurable (c • g) μ :=\n  hf.const_smul' c\n#align ae_measurable.const_smul AeMeasurable.constSmul\n#align ae_measurable.const_vadd AeMeasurable.const_vadd\n\nomit m\n\n@[to_additive]\ninstance Pi.hasMeasurableSmul {ι : Type _} {α : ι → Type _} [∀ i, SMul M (α i)]\n    [∀ i, MeasurableSpace (α i)] [∀ i, HasMeasurableSmul M (α i)] :\n    HasMeasurableSmul M (∀ i, α i) :=\n  ⟨fun g => measurable_pi_iff.mpr fun i => (measurable_pi_apply i).const_smul _, fun g =>\n    measurable_pi_iff.mpr fun i => measurable_smul_const _⟩\n#align pi.has_measurable_smul Pi.hasMeasurableSmul\n#align pi.has_measurable_vadd Pi.has_measurable_vadd\n\n/-- `add_monoid.has_smul_nat` is measurable. -/\ninstance AddMonoid.has_measurable_smul_nat₂ (M : Type _) [AddMonoid M] [MeasurableSpace M]\n    [HasMeasurableAdd₂ M] : HasMeasurableSmul₂ ℕ M :=\n  ⟨by\n    suffices Measurable fun p : M × ℕ => p.2 • p.1 by apply this.comp measurable_swap\n    refine' measurable_from_prod_countable fun n => _\n    induction' n with n ih\n    · simp only [zero_smul, ← Pi.zero_def, measurable_zero]\n    · simp only [succ_nsmul]\n      exact measurable_id.add ih⟩\n#align add_monoid.has_measurable_smul_nat₂ AddMonoid.has_measurable_smul_nat₂\n\n/-- `sub_neg_monoid.has_smul_int` is measurable. -/\ninstance SubNegMonoid.has_measurable_smul_int₂ (M : Type _) [SubNegMonoid M] [MeasurableSpace M]\n    [HasMeasurableAdd₂ M] [HasMeasurableNeg M] : HasMeasurableSmul₂ ℤ M :=\n  ⟨by\n    suffices Measurable fun p : M × ℤ => p.2 • p.1 by apply this.comp measurable_swap\n    refine' measurable_from_prod_countable fun n => _\n    induction' n with n n ih\n    · simp only [ofNat_zsmul]\n      exact measurable_const_smul _\n    · simp only [negSucc_zsmul]\n      exact (measurable_const_smul _).neg⟩\n#align sub_neg_monoid.has_measurable_smul_int₂ SubNegMonoid.has_measurable_smul_int₂\n\nend Smul\n\nsection MulAction\n\nvariable {M β α : Type _} [MeasurableSpace M] [MeasurableSpace β] [Monoid M] [MulAction M β]\n  [HasMeasurableSmul M β] [MeasurableSpace α] {f : α → β} {μ : Measure α}\n\nvariable {G : Type _} [Group G] [MeasurableSpace G] [MulAction G β] [HasMeasurableSmul G β]\n\n@[to_additive]\ntheorem measurable_const_smul_iff (c : G) : (Measurable fun x => c • f x) ↔ Measurable f :=\n  ⟨fun h => by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, fun h => h.const_smul c⟩\n#align measurable_const_smul_iff measurable_const_smul_iff\n#align measurable_const_vadd_iff measurable_const_vadd_iff\n\n@[to_additive]\ntheorem aeMeasurable_const_smul_iff (c : G) :\n    AeMeasurable (fun x => c • f x) μ ↔ AeMeasurable f μ :=\n  ⟨fun h => by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, fun h => h.const_smul c⟩\n#align ae_measurable_const_smul_iff aeMeasurable_const_smul_iff\n#align ae_measurable_const_vadd_iff ae_measurable_const_vadd_iff\n\n@[to_additive]\ninstance : MeasurableSpace Mˣ :=\n  MeasurableSpace.comap (coe : Mˣ → M) ‹_›\n\n@[to_additive]\ninstance Units.hasMeasurableSmul : HasMeasurableSmul Mˣ β\n    where\n  measurable_const_smul c := (measurable_const_smul (c : M) : _)\n  measurable_smul_const x :=\n    (measurable_smul_const x : Measurable fun c : M => c • x).comp MeasurableSpace.le_map_comap\n#align units.has_measurable_smul Units.hasMeasurableSmul\n#align add_units.has_measurable_vadd AddUnits.has_measurable_vadd\n\n@[to_additive]\ntheorem IsUnit.measurable_const_smul_iff {c : M} (hc : IsUnit c) :\n    (Measurable fun x => c • f x) ↔ Measurable f :=\n  let ⟨u, hu⟩ := hc\n  hu ▸ measurable_const_smul_iff u\n#align is_unit.measurable_const_smul_iff IsUnit.measurable_const_smul_iff\n#align is_add_unit.measurable_const_vadd_iff IsAddUnit.measurable_const_vadd_iff\n\n@[to_additive]\ntheorem IsUnit.aeMeasurable_const_smul_iff {c : M} (hc : IsUnit c) :\n    AeMeasurable (fun x => c • f x) μ ↔ AeMeasurable f μ :=\n  let ⟨u, hu⟩ := hc\n  hu ▸ aeMeasurable_const_smul_iff u\n#align is_unit.ae_measurable_const_smul_iff IsUnit.aeMeasurable_const_smul_iff\n#align is_add_unit.ae_measurable_const_vadd_iff IsAddUnit.ae_measurable_const_vadd_iff\n\nvariable {G₀ : Type _} [GroupWithZero G₀] [MeasurableSpace G₀] [MulAction G₀ β]\n  [HasMeasurableSmul G₀ β]\n\ntheorem measurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) :\n    (Measurable fun x => c • f x) ↔ Measurable f :=\n  (IsUnit.mk0 c hc).measurable_const_smul_iff\n#align measurable_const_smul_iff₀ measurable_const_smul_iff₀\n\ntheorem aeMeasurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) :\n    AeMeasurable (fun x => c • f x) μ ↔ AeMeasurable f μ :=\n  (IsUnit.mk0 c hc).aeMeasurable_const_smul_iff\n#align ae_measurable_const_smul_iff₀ aeMeasurable_const_smul_iff₀\n\nend MulAction\n\n/-!\n### Opposite monoid\n-/\n\n\nsection Opposite\n\nopen MulOpposite\n\n@[to_additive]\ninstance {α : Type _} [h : MeasurableSpace α] : MeasurableSpace αᵐᵒᵖ :=\n  MeasurableSpace.map op h\n\n@[to_additive]\ntheorem measurable_mul_op {α : Type _} [MeasurableSpace α] : Measurable (op : α → αᵐᵒᵖ) := fun s =>\n  id\n#align measurable_mul_op measurable_mul_op\n#align measurable_add_op measurable_add_op\n\n@[to_additive]\ntheorem measurable_mul_unop {α : Type _} [MeasurableSpace α] : Measurable (unop : αᵐᵒᵖ → α) :=\n  fun s => id\n#align measurable_mul_unop measurable_mul_unop\n#align measurable_add_unop measurable_add_unop\n\n@[to_additive]\ninstance {M : Type _} [Mul M] [MeasurableSpace M] [HasMeasurableMul M] : HasMeasurableMul Mᵐᵒᵖ :=\n  ⟨fun c => measurable_mul_op.comp (measurable_mul_unop.mul_const _), fun c =>\n    measurable_mul_op.comp (measurable_mul_unop.const_mul _)⟩\n\n@[to_additive]\ninstance {M : Type _} [Mul M] [MeasurableSpace M] [HasMeasurableMul₂ M] : HasMeasurableMul₂ Mᵐᵒᵖ :=\n  ⟨measurable_mul_op.comp\n      ((measurable_mul_unop.comp measurable_snd).mul (measurable_mul_unop.comp measurable_fst))⟩\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance HasMeasurableSmul.op {M α} [MeasurableSpace M] [MeasurableSpace α] [SMul M α] [SMul Mᵐᵒᵖ α]\n    [IsCentralScalar M α] [HasMeasurableSmul M α] : HasMeasurableSmul Mᵐᵒᵖ α :=\n  ⟨MulOpposite.rec' fun c =>\n      show Measurable fun x => op c • x by\n        simpa only [op_smul_eq_smul] using measurable_const_smul c,\n    fun x =>\n    show Measurable fun c => op (unop c) • x by\n      simpa only [op_smul_eq_smul] using (measurable_smul_const x).comp measurable_mul_unop⟩\n#align has_measurable_smul.op HasMeasurableSmul.op\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance HasMeasurableSmul₂.op {M α} [MeasurableSpace M] [MeasurableSpace α] [SMul M α]\n    [SMul Mᵐᵒᵖ α] [IsCentralScalar M α] [HasMeasurableSmul₂ M α] : HasMeasurableSmul₂ Mᵐᵒᵖ α :=\n  ⟨show Measurable fun x : Mᵐᵒᵖ × α => op (unop x.1) • x.2\n      by\n      simp_rw [op_smul_eq_smul]\n      refine' (measurable_mul_unop.comp measurable_fst).smul measurable_snd⟩\n#align has_measurable_smul₂.op HasMeasurableSmul₂.op\n\n@[to_additive]\ninstance hasMeasurableSmul_opposite_of_mul {M : Type _} [Mul M] [MeasurableSpace M]\n    [HasMeasurableMul M] : HasMeasurableSmul Mᵐᵒᵖ M :=\n  ⟨fun c => measurable_mul_const (unop c), fun x => measurable_mul_unop.const_mul x⟩\n#align has_measurable_smul_opposite_of_mul hasMeasurableSmul_opposite_of_mul\n#align has_measurable_vadd_opposite_of_add has_measurable_vadd_opposite_of_add\n\n@[to_additive]\ninstance hasMeasurableSmul₂_opposite_of_mul {M : Type _} [Mul M] [MeasurableSpace M]\n    [HasMeasurableMul₂ M] : HasMeasurableSmul₂ Mᵐᵒᵖ M :=\n  ⟨measurable_snd.mul (measurable_mul_unop.comp measurable_fst)⟩\n#align has_measurable_smul₂_opposite_of_mul hasMeasurableSmul₂_opposite_of_mul\n#align has_measurable_smul₂_opposite_of_add hasMeasurableSmul₂_opposite_of_add\n\nend Opposite\n\n/-!\n### Big operators: `∏` and `∑`\n-/\n\n\nsection Monoid\n\nvariable {M α : Type _} [Monoid M] [MeasurableSpace M] [HasMeasurableMul₂ M] {m : MeasurableSpace α}\n  {μ : Measure α}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem List.measurable_prod' (l : List (α → M)) (hl : ∀ f ∈ l, Measurable f) : Measurable l.Prod :=\n  by\n  induction' l with f l ihl; · exact measurable_one\n  rw [List.forall_mem_cons] at hl\n  rw [List.prod_cons]\n  exact hl.1.mul (ihl hl.2)\n#align list.measurable_prod' List.measurable_prod'\n#align list.measurable_sum' List.measurable_sum'\n\n@[measurability, to_additive]\ntheorem List.aeMeasurableProd' (l : List (α → M)) (hl : ∀ f ∈ l, AeMeasurable f μ) :\n    AeMeasurable l.Prod μ := by\n  induction' l with f l ihl; · exact aeMeasurableOne\n  rw [List.forall_mem_cons] at hl\n  rw [List.prod_cons]\n  exact hl.1.mul (ihl hl.2)\n#align list.ae_measurable_prod' List.aeMeasurableProd'\n#align list.ae_measurable_sum' List.ae_measurable_sum'\n\n@[measurability, to_additive]\ntheorem List.measurable_prod (l : List (α → M)) (hl : ∀ f ∈ l, Measurable f) :\n    Measurable fun x => (l.map fun f : α → M => f x).Prod := by\n  simpa only [← Pi.list_prod_apply] using l.measurable_prod' hl\n#align list.measurable_prod List.measurable_prod\n#align list.measurable_sum List.measurable_sum\n\n@[measurability, to_additive]\ntheorem List.aeMeasurableProd (l : List (α → M)) (hl : ∀ f ∈ l, AeMeasurable f μ) :\n    AeMeasurable (fun x => (l.map fun f : α → M => f x).Prod) μ := by\n  simpa only [← Pi.list_prod_apply] using l.ae_measurable_prod' hl\n#align list.ae_measurable_prod List.aeMeasurableProd\n#align list.ae_measurable_sum List.ae_measurable_sum\n\nomit m\n\nend Monoid\n\nsection CommMonoid\n\nvariable {M ι α : Type _} [CommMonoid M] [MeasurableSpace M] [HasMeasurableMul₂ M]\n  {m : MeasurableSpace α} {μ : Measure α} {f : ι → α → M}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Multiset.measurable_prod' (l : Multiset (α → M)) (hl : ∀ f ∈ l, Measurable f) :\n    Measurable l.Prod := by\n  rcases l with ⟨l⟩\n  simpa using l.measurable_prod' (by simpa using hl)\n#align multiset.measurable_prod' Multiset.measurable_prod'\n#align multiset.measurable_sum' Multiset.measurable_sum'\n\n@[measurability, to_additive]\ntheorem Multiset.aeMeasurableProd' (l : Multiset (α → M)) (hl : ∀ f ∈ l, AeMeasurable f μ) :\n    AeMeasurable l.Prod μ := by\n  rcases l with ⟨l⟩\n  simpa using l.ae_measurable_prod' (by simpa using hl)\n#align multiset.ae_measurable_prod' Multiset.aeMeasurableProd'\n#align multiset.ae_measurable_sum' Multiset.ae_measurable_sum'\n\n@[measurability, to_additive]\ntheorem Multiset.measurable_prod (s : Multiset (α → M)) (hs : ∀ f ∈ s, Measurable f) :\n    Measurable fun x => (s.map fun f : α → M => f x).Prod := by\n  simpa only [← Pi.multiset_prod_apply] using s.measurable_prod' hs\n#align multiset.measurable_prod Multiset.measurable_prod\n#align multiset.measurable_sum Multiset.measurable_sum\n\n@[measurability, to_additive]\ntheorem Multiset.aeMeasurableProd (s : Multiset (α → M)) (hs : ∀ f ∈ s, AeMeasurable f μ) :\n    AeMeasurable (fun x => (s.map fun f : α → M => f x).Prod) μ := by\n  simpa only [← Pi.multiset_prod_apply] using s.ae_measurable_prod' hs\n#align multiset.ae_measurable_prod Multiset.aeMeasurableProd\n#align multiset.ae_measurable_sum Multiset.ae_measurable_sum\n\n@[measurability, to_additive]\ntheorem Finset.measurable_prod' (s : Finset ι) (hf : ∀ i ∈ s, Measurable (f i)) :\n    Measurable (∏ i in s, f i) :=\n  Finset.prod_induction _ _ (fun _ _ => Measurable.mul) (@measurable_one M _ _ _ _) hf\n#align finset.measurable_prod' Finset.measurable_prod'\n#align finset.measurable_sum' Finset.measurable_sum'\n\n@[measurability, to_additive]\ntheorem Finset.measurable_prod (s : Finset ι) (hf : ∀ i ∈ s, Measurable (f i)) :\n    Measurable fun a => ∏ i in s, f i a := by\n  simpa only [← Finset.prod_apply] using s.measurable_prod' hf\n#align finset.measurable_prod Finset.measurable_prod\n#align finset.measurable_sum Finset.measurable_sum\n\n@[measurability, to_additive]\ntheorem Finset.aeMeasurableProd' (s : Finset ι) (hf : ∀ i ∈ s, AeMeasurable (f i) μ) :\n    AeMeasurable (∏ i in s, f i) μ :=\n  Multiset.aeMeasurableProd' _ fun g hg =>\n    let ⟨i, hi, hg⟩ := Multiset.mem_map.1 hg\n    hg ▸ hf _ hi\n#align finset.ae_measurable_prod' Finset.aeMeasurableProd'\n#align finset.ae_measurable_sum' Finset.ae_measurable_sum'\n\n@[measurability, to_additive]\ntheorem Finset.aeMeasurableProd (s : Finset ι) (hf : ∀ i ∈ s, AeMeasurable (f i) μ) :\n    AeMeasurable (fun a => ∏ i in s, f i a) μ := by\n  simpa only [← Finset.prod_apply] using s.ae_measurable_prod' hf\n#align finset.ae_measurable_prod Finset.aeMeasurableProd\n#align finset.ae_measurable_sum Finset.ae_measurable_sum\n\nomit m\n\nend CommMonoid\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/MeasureTheory/Group/Arithmetic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.4940235103376487}}
{"text": "/-\nCopyright (c) 2014-2016 Jakob von Raumer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jakob von Raumer, Floris van Doorn\n\nEarly library ported from Coq HoTT, but greatly extended since.\nThe basic definitions are in init.pointed\n\nSee also .pointed2\n-/\nimport ..arity ..prop_trunc .bool\n\nuniverses u u₁ u₂ u₃ u₄\n\nnamespace hott\nhott_theory\nopen is_trunc nat hott.bool hott.is_equiv hott.equiv hott.sigma\nnamespace pointed\n  variables {A : Type _} {B : Type _}\n\n  @[hott, instance, hsimp] def pointed_loop (a : A) : pointed (a = a) :=\n  pointed.mk idp\n\n  @[hott, hsimp] def pointed_fun_closed (f : A → B) [H : pointed A] : pointed B :=\n  pointed.mk (f pt)\n\n  @[hott, reducible] def loop (A : Type*) : Type* :=\n  pointed.mk' (point A = point A)\n\n  @[hott, reducible] def loopn : ℕ → Type* → Type*\n  | 0     X := X\n  | (n+1) X := loop (loopn n X)\n\n  notation `Ω` := loop\n  notation `Ω[`:95 n:0 `]`:0 := loopn n\n\n  @[hott] def is_trunc_pointed_MK (n : ℕ₋₂) {A : Type _} (a : A)\n    [H : is_trunc n A] : is_trunc n (pointed.MK A a) :=\n  H\n\n  @[hott, instance, priority 1100] def is_trunc_loop (A : Type*)\n    (n : ℕ₋₂) [H : is_trunc (n.+1) A] : is_trunc n (Ω A) :=\n  is_trunc_eq _ _ _\n\n  @[hott] def loopn_zero_eq (A : Type*)\n    : Ω[0] A = A := rfl\n\n  @[hott] def loopn_succ_eq (k : ℕ) (A : Type*)\n    : Ω[succ k] A = Ω (Ω[k] A) := rfl\n\n  @[hott,reducible] def rfln  {n : ℕ} {A : Type*} : Ω[n] A := pt\n  @[hott,reducible] def refln (n : ℕ) (A : Type*) : Ω[n] A := Point _\n  @[hott] def refln_eq_refl (A : Type*) (n : ℕ) : rfln = rfl :> Ω[succ n] A := rfl\n\n  @[hott] def loopn_space (A : Type _) [H : pointed A] (n : ℕ) : Type _ :=\n  Ω[n] (pointed.mk' A)\n\n  @[hott] def loop_mul {k : ℕ} {A : Type*} (mul : A → A → A) : Ω[k] A → Ω[k] A → Ω[k] A :=\n  begin cases k with k, exact mul, exact concat end\n\n  @[hott] def pType_eq {A B : Type*} (f : A ≃ B) (p : f pt = pt) : A = B :=\n  begin\n    cases A with A a, cases B with B b, dsimp at f p,\n    fapply apdt011 @pType.mk,\n    { apply ua f },\n    { rwr [←cast_def, cast_ua], exact p },\n  end\n\n  @[hott] def pType_eq_elim {A B : Type*} (p : A = B :> Type*)\n    : Σ(p : carrier A = carrier B :> Type _), Point A =[p; λX, X] Point B :=\n  by induction p; exact ⟨idp, idpo⟩\n\n  @[hott] protected def pType.sigma_char : pType.{u} ≃ Σ(X : Type u), X :=\n  begin\n    fapply equiv.MK,\n    { intro x, induction x with X x, exact ⟨X, x⟩},\n    { intro x, induction x with X x, exact pointed.MK X x},\n    { intro x, induction x with X x, reflexivity},\n    { intro x, induction x with X x, reflexivity},\n  end\n\n  @[hott] def pType.eta_expand (A : Type*) : Type* :=\n  pointed.MK A pt\n\n  @[hott] def add_point (A : Type _) : Type* :=\n  pointed.Mk (none : option A)\n  postfix `₊`:(max+1) := add_point\n  -- the inclusion A → A₊ is called \"some\", the extra point \"pt\" or \"none\" (\"@none A\")\nend pointed\n\nnamespace pointed\n  /- truncated pointed types -/\n  @[hott] def ptrunctype_eq {n : ℕ₋₂} {A B : n-Type*}\n    (p : ↥A = ↥B) (q : Point (↑A) =[p; λX, X] Point (↑B)) : A = B :=\n  begin\n    induction A with A HA, induction B with B HB, \n    induction A with A a₀, induction B with B b₀, dsimp at p q, \n    induction q,\n    exact ap (ptrunctype.mk _) (is_prop.elim _ _)\n  end\n\n  @[hott] def ptrunctype_eq_of_pType_eq {n : ℕ₋₂} {A B : n-Type*} (p : A.to_pType = B.to_pType)\n    : A = B :=\n  begin\n    cases pType_eq_elim p with q r,\n    exact ptrunctype_eq q r\n  end\n\n  @[hott, instance] def is_trunc_ptrunctype {n : ℕ₋₂} (A : n-Type*) : is_trunc n A :=\n  trunctype.struct A\n\nend pointed open pointed\n\nnamespace pointed\n  variables {A : pType.{u₁}} {B : pType.{u₂}} {C : pType.{u₃}} {D : pType.{u₄}}\n            {f g h : A →* B} {P : A → Type _} {p₀ : P pt} {k k' l m : ppi P p₀}\n\n  /- categorical properties of pointed maps -/\n\n  @[hott, refl] def pid (A : Type*) : A →* A :=\n  pmap.mk id idp\n\n  @[hott, trans] def pcompose {A B C : Type*} (g : B →* C) (f : A →* B) : A →* C :=\n  pmap.mk (λa, g (f a)) (ap g (respect_pt f) ⬝ respect_pt g)\n\n  infixr ` ∘* `:60 := pcompose\n\n  @[hott] def pmap_of_map {A B : Type _} (f : A → B) (a : A) :\n    pointed.MK A a →* pointed.MK B (f a) :=\n  pmap.mk f idp\n\n  @[hott, hsimp] def respect_pt_pcompose {A B C : Type*} (g : B →* C) (f : A →* B)\n    : respect_pt (g ∘* f) = ap g (respect_pt f) ⬝ respect_pt g :=\n  idp\n\n  @[hott] def passoc (h : C →* D) (g : B →* C) (f : A →* B) : (h ∘* g) ∘* f ~* h ∘* (g ∘* f) :=\n  phomotopy.mk (λa, idp)\n    begin abstract {\n      refine (idp_con _ ⬝ whisker_right _ (ap_con _ _ _ ⬝ whisker_right _ _) ⬝ (con.assoc _ _ _)),\n      exact ap_compose' h g (respect_pt f)\n    } end\n\n  @[hott] def pid_pcompose (f : A →* B) : pid B ∘* f ~* f :=\n  begin\n    fapply phomotopy.mk,\n    { intro a, reflexivity},\n    { reflexivity}\n  end\n\n  @[hott] def pcompose_pid (f : A →* B) : f ∘* pid A ~* f :=\n  begin\n    fapply phomotopy.mk,\n    { intro a, reflexivity},\n    { reflexivity}\n  end\n\n  /- equivalences and equalities -/\n\n  @[hott] protected def ppi.sigma_char {A : Type*} (B : A → Type _) (b₀ : B pt) :\n    ppi B b₀ ≃ Σ(k : Πa, B a), k pt = b₀ :=\n  begin\n    fapply equiv.MK; all_goals {intro x},\n    { constructor, exact respect_pt x },\n    { induction x with f p, constructor, exact p },\n    { induction x, reflexivity },\n    { induction x, reflexivity }\n  end\n\n  @[hott] def pmap.sigma_char {A B : Type*} : (A →* B) ≃ Σ(f : A → B), f pt = pt :=\n  ppi.sigma_char _ _\n\n  @[hott] def pmap.eta_expand {A B : Type*} (f : A →* B) : A →* B :=\n  pmap.mk f (respect_pt f)\n\n  @[hott] def pmap_equiv_right (A : Type*) (B : Type _)\n    : (Σ(b : B), A →* (pointed.Mk b)) ≃ (A → B) :=\n  begin\n    fapply equiv.MK,\n    { intros u a, exact u.2 a},\n    { intro f, refine ⟨f pt, _⟩, fapply pmap.mk,\n        intro a, exact f a,\n        reflexivity},\n    { intro f, reflexivity},\n    { intro u, cases u with b f, cases f with f p, dsimp at f p, induction p,\n      reflexivity}\n  end\n\n  /- some specific pointed maps -/\n\n  -- The constant pointed map between any two types\n  @[hott] def pconst (A B : Type*) : A →* B :=\n  ppi_const _\n\n  -- the pointed type of pointed maps -- TODO: remove\n  @[hott] def ppmap (A B : Type*) : Type* :=\n  @pppi A (λa, B)\n\n  @[hott] def pcast {A B : Type*} (p : A = B) : A →* B :=\n  pmap.mk (cast (ap pType.carrier p)) (by induction p; reflexivity)\n\n  @[hott] def pinverse (X : Type*) : Ω X →* Ω X :=\n  pmap.mk eq.inverse idp\n\n  /-\n    we generalize the @[hott] def of ap1 to arbitrary paths, so that we can prove properties about it\n    using path induction (see for example ap1_gen_con and ap1_gen_con_natural)\n  -/\n  @[hott, reducible] def ap1_gen {A B : Type _} (f : A → B) {a a' : A}\n    {b b' : B} (q : f a = b) (q' : f a' = b') (p : a = a') : b = b' :=\n  q⁻¹ ⬝ ap f p ⬝ q'\n\n  @[hott] def ap1_gen_idp {A B : Type _} (f : A → B) {a : A} {b : B} (q : f a = b) :\n    ap1_gen f q q idp = idp :=\n  con.left_inv q\n\n  @[hott, hsimp] def ap1_gen_idp_left {A B : Type _} (f : A → B) {a a' : A} (p : a = a') :\n    ap1_gen f idp idp p = ap f p :=\n  idp_con (ap f p)\n\n  @[hott] def ap1_gen_idp_left_con {A B : Type _} (f : A → B) {a : A} (p : a = a) (q : ap f p = idp) :\n    ap1_gen_idp_left f p ⬝ q = ap (concat idp) q :=\n  idp_con_idp q\n\n  @[hott] def ap1 (f : A →* B) : Ω A →* Ω B :=\n  pmap.mk (λp, ap1_gen f (respect_pt f) (respect_pt f) p) (ap1_gen_idp f (respect_pt f))\n\n  @[hott] def apn (n : ℕ) (f : A →* B) : Ω[n] A →* Ω[n] B :=\n  begin\n  induction n with n IH,\n  { exact f },\n  { exact ap1 IH }\n  end\n\n  notation `Ω→`:(max+5) := ap1\n  notation `Ω→[`:95 n:0 `]`:0 := apn n\n\n  @[hott] def ptransport {A : Type _} (B : A → Type*) {a a' : A} (p : a = a')\n    : B a →* B a' :=\n  pmap.mk (transport _ p) (apdt (λa, Point (B a)) p)\n\n  @[hott] def pmap_of_eq_pt {A : Type _} {a a' : A} (p : a = a') :\n    pointed.MK A a →* pointed.MK A a' :=\n  pmap.mk id p\n\n  @[hott] def pbool_pmap {A : Type*} (a : A) : pbool →* A :=\n  pmap.mk (λb, bool.rec pt a b) idp\n\n  /- properties of pointed maps -/\n\n  @[hott] def apn_zero (f : A →* B) : Ω→[0] f = f := idp\n  @[hott] def apn_succ (n : ℕ) (f : A →* B) : Ω→[n + 1] f = Ω→ (Ω→[n] f) := idp\n\n  @[hott] def ap1_gen_con {A B : Type _} (f : A → B) {a₁ a₂ a₃ : A} {b₁ b₂ b₃ : B}\n    (q₁ : f a₁ = b₁) (q₂ : f a₂ = b₂) (q₃ : f a₃ = b₃) (p₁ : a₁ = a₂) (p₂ : a₂ = a₃) :\n    ap1_gen f q₁ q₃ (p₁ ⬝ p₂) = ap1_gen f q₁ q₂ p₁ ⬝ ap1_gen f q₂ q₃ p₂ :=\n  begin induction p₂, induction q₃, induction q₂, reflexivity end\n\n  @[hott] def ap1_gen_inv {A B : Type _} (f : A → B) {a₁ a₂ : A}\n    {b₁ b₂ : B} (q₁ : f a₁ = b₁) (q₂ : f a₂ = b₂) (p₁ : a₁ = a₂) :\n    ap1_gen f q₂ q₁ p₁⁻¹ = (ap1_gen f q₁ q₂ p₁)⁻¹ :=\n  begin induction p₁, induction q₁, induction q₂, reflexivity end\n\n  @[hott] def ap1_con {A B : Type*} (f : A →* B) (p q : Ω A) : ap1 f (p ⬝ q) = ap1 f p ⬝ ap1 f q :=\n  ap1_gen_con f (respect_pt f) (respect_pt f) (respect_pt f) p q\n\n  @[hott] def ap1_inv (f : A →* B) (p : Ω A) : ap1 f p⁻¹ = (ap1 f p)⁻¹ :=\n  ap1_gen_inv f (respect_pt f) (respect_pt f) p\n\n  -- the following two facts are used for the suspension axiom to define spectrum cohomology\n  @[hott] def ap1_gen_con_natural {A B : Type _} (f : A → B) {a₁ a₂ a₃ : A} {p₁ p₁' : a₁ = a₂}\n    {p₂ p₂' : a₂ = a₃}\n    {b₁ b₂ b₃ : B} (q₁ : f a₁ = b₁) (q₂ : f a₂ = b₂) (q₃ : f a₃ = b₃)\n    (r₁ : p₁ = p₁') (r₂ : p₂ = p₂') :\n      square (ap1_gen_con f q₁ q₂ q₃ p₁ p₂)\n             (ap1_gen_con f q₁ q₂ q₃ p₁' p₂')\n             (ap (ap1_gen f q₁ q₃) (r₁ ◾ r₂))\n             (ap (ap1_gen f q₁ q₂) r₁ ◾ ap (ap1_gen f q₂ q₃) r₂) :=\n  begin induction r₁, induction r₂, exact vrfl end\n\n  @[hott] def ap1_gen_con_idp {A B : Type _} (f : A → B) {a : A} {b : B} (q : f a = b) :\n    ap1_gen_con f q q q idp idp ⬝ con.left_inv q ◾ con.left_inv q = con.left_inv q :=\n  by induction q; reflexivity\n\n  @[hott] def apn_con (n : ℕ) (f : A →* B) (p q : Ω[succ n] A)\n    : (Ω→[succ n] f) (p ⬝ q) = (Ω→[succ n] f) p ⬝ (Ω→[succ n] f) q :=\n  ap1_con (Ω→[n] f) p q\n\n  @[hott] def apn_inv (n : ℕ) (f : A →* B) (p : Ω[succ n] A) :\n    Ω→[succ n] f p⁻¹ᵖ = (Ω→[succ n] f p)⁻¹ᵖ :=\n  ap1_inv (Ω→[n] f) p\n\n  @[hott] def is_equiv_ap1 (f : A →* B) [H : is_equiv f] : is_equiv (ap1 f) :=\n  begin\n    unfreezeI, induction B with B b, induction f with f pf, dsimp at f pf H, induction pf,\n    apply is_equiv.homotopy_closed (ap f),\n    introI p, exact (idp_con _)⁻¹, apply_instance\n  end\n\n  @[hott] def is_equiv_apn (n : ℕ) (f : A →* B) [H : is_equiv f]\n    : is_equiv (Ω→[n] f) :=\n  begin\n    induction n with n IH,\n    { exact H },\n    { exact @is_equiv_ap1 _ _ (Ω→[n] f) IH }\n  end\n\n  @[hott] def pinverse_con {X : Type*} (p q : Ω X)\n    : pinverse X (p ⬝ q) = pinverse X q ⬝ pinverse X p :=\n  con_inv p q\n\n  @[hott] def pinverse_inv {X : Type*} (p : Ω X)\n    : pinverse X p⁻¹ = (pinverse X p)⁻¹ :=\n  idp\n\n  @[hott] def ap1_pcompose_pinverse {X Y : Type*} (f : X →* Y) :\n    Ω→ f ∘* pinverse X ~* pinverse Y ∘* Ω→ f :=\n  phomotopy.mk (ap1_gen_inv f (respect_pt f) (respect_pt f))\n    begin\n      induction Y with Y y₀, induction f with f f₀, dsimp at f f₀, induction f₀,\n      refl\n    end\n\n  @[hott, instance] def is_equiv_pcast {A B : Type*} (p : A = B) : is_equiv (pcast p) :=\n  is_equiv_cast _\n\n  /- categorical properties of pointed homotopies -/\n\n  variable (k)\n  @[hott] protected def phomotopy.refl : k ~* k :=\n  phomotopy.mk homotopy.rfl (idp_con _)\n  variable {k}\n  @[hott, reducible, refl] protected def phomotopy.rfl : k ~* k :=\n  phomotopy.refl k\n\n  @[hott, symm] protected def phomotopy.symm (p : k ~* l) : l ~* k :=\n  phomotopy.mk p⁻¹ʰᵗʸ (inv_con_eq_of_eq_con (to_homotopy_pt p)⁻¹)\n\n  @[hott, trans] protected def phomotopy.trans (p : k ~* l) (q : l ~* m) :\n    k ~* m :=\n  phomotopy.mk (λa, p a ⬝ q a) (con.assoc _ _ _ ⬝ whisker_left (p pt) (to_homotopy_pt q) ⬝ to_homotopy_pt p)\n\n  infix ` ⬝* `:75 := phomotopy.trans\n  postfix `⁻¹*`:(max+1) := phomotopy.symm\n\n  /- equalities and equivalences relating pointed homotopies -/\n\n  @[hott, reducible, elab_as_eliminator] def phomotopy.rec' (B : k ~* l → Type _)\n    (H : Π(h : k ~ l) (p : h pt ⬝ respect_pt l = respect_pt k), B (phomotopy.mk h p))\n    (h : k ~* l) : B h :=\n  begin\n    induction h with h p,\n    refine transport (λp, B (ppi.mk h p)) _ (H h (con_eq_of_eq_con_inv p)),\n    apply (eq_con_inv_equiv_con_eq _ _ _).to_left_inv p\n  end\n\n  @[hott] def phomotopy.eta_expand (p : k ~* l) : k ~* l :=\n  phomotopy.mk p (to_homotopy_pt p)\n\n  @[hott, instance] def is_trunc_ppi (n : ℕ₋₂) {A : Type*} (B : A → Type _) (b₀ : B pt) [Πa, is_trunc n (B a)] :\n    is_trunc n (ppi B b₀) :=\n  is_trunc_equiv_closed_rev _ (ppi.sigma_char _ _) (by infer)\n\n  @[hott, instance] def is_trunc_pmap (n : ℕ₋₂) (A B : Type*) [is_trunc n B] :\n    is_trunc n (A →* B) :=\n  is_trunc_ppi _ _ _\n\n  @[hott, instance] def is_trunc_ppmap (n : ℕ₋₂) {A B : Type*} [is_trunc n B] :\n    is_trunc n (ppmap A B) :=\n  is_trunc_pmap _ _ _\n\n  @[hott] def phomotopy_of_eq (p : k = l) : k ~* l :=\n  phomotopy.mk (ap010 ppi.to_fun p) begin induction p, exact idp_con _ end\n\n  @[hott, hsimp] def phomotopy_of_eq_idp (k : ppi P p₀) : phomotopy_of_eq idp = phomotopy.refl k :=\n  idp\n\n  @[hott] def pconcat_eq (p : k ~* l) (q : l = m) : k ~* m :=\n  p ⬝* phomotopy_of_eq q\n\n  @[hott] def eq_pconcat (p : k = l) (q : l ~* m) : k ~* m :=\n  phomotopy_of_eq p ⬝* q\n\n  infix ` ⬝*p `:75 := pconcat_eq\n  infix ` ⬝p* `:75 := eq_pconcat\n\n  @[hott] def fst_phomotopy_eq {p q : k ~* l} (r : p = q) (a : A) : p a = q a :=\n  ap010 to_homotopy r a\n\n  @[hott] def pwhisker_left (h : B →* C) (p : f ~* g) : h ∘* f ~* h ∘* g :=\n  phomotopy.mk (λa, ap h (p a))\n    begin abstract {exact con.assoc' _ _ _ ⬝ whisker_right _ ((ap_con _ _ _)⁻¹ ⬝ ap02 _ (to_homotopy_pt p))} end\n\n  @[hott] def pwhisker_right (h : C →* A) (p : f ~* g) : f ∘* h ~* g ∘* h :=\n  phomotopy.mk (λc, p (h c))\n    (by abstract {exact con.assoc' _ _ _ ⬝ whisker_right _ (ap_con_eq_con_ap _ _)⁻¹ ⬝\n       con.assoc _ _ _ ⬝ whisker_left _ (to_homotopy_pt p)})\n\n  @[hott] def pconcat2 {A B C : Type*} {h i : B →* C} {f g : A →* B}\n    (q : h ~* i) (p : f ~* g) : h ∘* f ~* i ∘* g :=\n  pwhisker_left _ p ⬝* pwhisker_right _ q\n\n  variables (k l)\n\n  @[hott] def phomotopy.sigma_char\n    : (k ~* l) ≃ Σ(p : k ~ l), p pt ⬝ respect_pt l = respect_pt k :=\n  begin\n    fapply equiv.MK, all_goals {intros h},\n    { exact ⟨h , to_homotopy_pt h⟩ },\n    { cases h with h p, exact phomotopy.mk h p },\n    { cases h with h p, exact ap (dpair h) ((eq_con_inv_equiv_con_eq _ _ _).to_right_inv p) },\n    { refine phomotopy.rec' _ _ h, clear h, intros h p,\n      exact (ap (phomotopy.mk h) $ (eq_con_inv_equiv_con_eq _ _ _).to_right_inv p) }\n  end\n\n  @[hott] def ppi_eq_equiv_internal : (k = l) ≃ (k ~* l) :=\n    calc (k = l) ≃ ppi.sigma_char P p₀ k = ppi.sigma_char P p₀ l\n                   : eq_equiv_fn_eq (ppi.sigma_char P p₀) k l\n            ...  ≃ Σ(p : k = l :> Πa, P a),\n                     respect_pt k =[p; λ(h : Πa, P a), h pt = p₀] respect_pt l\n                   : sigma_eq_equiv _ _\n            ...  ≃ Σ(p : k = l :> Πa, P a),\n                     respect_pt k = ap (λ(h : Πa, P a), h pt) p ⬝ respect_pt l\n                   : sigma_equiv_sigma_right\n                       (λp, eq_pathover_equiv_Fl p (respect_pt k) (respect_pt l))\n            ...  ≃ Σ(p : k = l :> Πa, P a),\n                     respect_pt k = apd10 p pt ⬝ respect_pt l\n                   : sigma_equiv_sigma_right\n                       (λp, equiv_eq_closed_right _ (whisker_right _ (ap_eq_apd10 p _)))\n            ...  ≃ Σ(p : k ~ l), respect_pt k = p pt ⬝ respect_pt l\n                   : sigma_equiv_sigma_left' (λ(p : k ~ l), respect_pt k = p pt ⬝ respect_pt l) (eq_equiv_homotopy k l)\n            ...  ≃ Σ(p : k ~ l), p pt ⬝ respect_pt l = respect_pt k\n                   : sigma_equiv_sigma_right (λp, eq_equiv_eq_symm _ _)\n            ...  ≃ (k ~* l) : (phomotopy.sigma_char k l)⁻¹ᵉ\n\n  @[hott] def ppi_eq_equiv_internal_idp :\n    ppi_eq_equiv_internal k k idp = phomotopy.refl k :=\n  begin\n    --apply ap (phomotopy.mk (homotopy.refl _)), /- do we need this? -/\n    induction k with k k₀,\n    induction k₀, reflexivity\n  end\n\n  @[hott] def ppi_eq_equiv : (k = l) ≃ (k ~* l) :=\n  begin\n    refine equiv_change_fun (ppi_eq_equiv_internal k l) _,\n    { apply phomotopy_of_eq },\n    { intro p, induction p, exact ppi_eq_equiv_internal_idp k }\n  end\n  variables {k l}\n\n  @[hott] def pmap_eq_equiv (f g : A →* B) : (f = g) ≃ (f ~* g) :=\n  ppi_eq_equiv f g\n\n  @[hott] def eq_of_phomotopy (p : k ~* l) : k = l :=\n  to_inv (ppi_eq_equiv k l) p\n\n  @[hott] def eq_of_phomotopy_refl (k : ppi P p₀) : eq_of_phomotopy (phomotopy.refl k) = idpath k :=\n  begin\n    apply to_inv_eq_of_eq (ppi_eq_equiv k k), refl\n  end\n\n  @[hott] def phomotopy_of_homotopy (h : k ~ l) [Πa, is_set (P a)] : k ~* l :=\n  begin\n    fapply phomotopy.mk,\n    { exact h },\n    { apply is_set.elim }\n  end\n\n  @[hott] def ppi_eq_of_homotopy [Πa, is_set (P a)] (p : k ~ l) : k = l :=\n  eq_of_phomotopy (phomotopy_of_homotopy p)\n\n  @[hott] def pmap_eq_of_homotopy [is_set B] (p : f ~ g) : f = g :=\n  ppi_eq_of_homotopy p\n\n  @[hott] def phomotopy_of_eq_of_phomotopy (p : k ~* l) : phomotopy_of_eq (eq_of_phomotopy p) = p :=\n  to_right_inv (ppi_eq_equiv k l) p\n\n  @[hott, induction, reducible] def phomotopy_rec_eq {Q : (k ~* k') → Type _} (p : k ~* k')\n    (H : Π(q : k = k'), Q (phomotopy_of_eq q)) : Q p :=\n  phomotopy_of_eq_of_phomotopy p ▸ H (eq_of_phomotopy p)\n\n  @[hott, induction, reducible] def phomotopy_rec_idp {Q : Π {k' : ppi P p₀}, (k ~* k') → Type _}\n    {k' : ppi P p₀} (H : k ~* k') (q : Q (phomotopy.refl k)) : Q H :=\n  begin\n    hinduction H using phomotopy_rec_eq with t,\n    induction t, exact phomotopy_of_eq_idp k ▸ q,\n  end\n\n  @[hott] def phomotopy_rec_idp' (Q : Π ⦃k' : ppi P p₀⦄, (k ~* k') → (k = k') → Type _)\n    (q : Q phomotopy.rfl idp) ⦃k' : ppi P p₀⦄ (H : k ~* k') : Q H (eq_of_phomotopy H) :=\n  begin\n    hinduction H using phomotopy_rec_idp,\n    exact transport (Q phomotopy.rfl) (eq_of_phomotopy_refl _)⁻¹ q\n  end\n\n  @[hott] theorem phomotopy_rec_eq_phomotopy_of_eq {Q : (k ~* l) → Type _} (p : k = l)\n    (H : Π(q : k = l), Q (phomotopy_of_eq q)) : phomotopy_rec_eq (phomotopy_of_eq p) H = H p :=\n  begin\n    refine transport2 _ (adj (ppi_eq_equiv _ _).to_fun _) _ ⬝ _,\n    refine tr_ap _ _ _ _ ⬝ _,\n    apply apdt\n  end\n\n  @[hott] def phomotopy_rec_idp_refl {Q : Π{l}, (k ~* l) → Type _} (H : Q (phomotopy.refl k)) :\n    phomotopy_rec_idp phomotopy.rfl H = H :=\n  begin\n    apply phomotopy_rec_eq_phomotopy_of_eq idp\n  end\n\n  @[hott] def phomotopy_rec_idp'_refl (Q : Π ⦃k' : ppi P p₀⦄, (k ~* k') → (k = k') → Type _)\n    (q : Q phomotopy.rfl idp) :\n    phomotopy_rec_idp' Q q phomotopy.rfl = transport (Q phomotopy.rfl) (eq_of_phomotopy_refl _)⁻¹ q :=\n  begin dsimp [phomotopy_rec_idp'], exact phomotopy_rec_idp_refl _ end\n\n  /- maps out of or into contractible types -/\n  @[hott] def phomotopy_of_is_contr_cod (k l : ppi P p₀) [Πa, is_contr (P a)] :\n    k ~* l :=\n  phomotopy.mk (λa, eq_of_is_contr _ _) (eq_of_is_contr _ _)\n\n  @[hott] def phomotopy_of_is_contr_cod_pmap (f g : A →* B) [is_contr B] : f ~* g :=\n  phomotopy_of_is_contr_cod f g\n\n  @[hott] def phomotopy_of_is_contr_dom (k l : ppi P p₀) [is_contr A] : k ~* l :=\n  begin\n    fapply phomotopy.mk,\n    { hintro a, exact eq_of_pathover_idp (change_path (is_prop.elim _ _)\n      (apd k (is_prop.elim _ _) ⬝op respect_pt k ⬝ (respect_pt l)⁻¹ ⬝o apd l (is_prop.elim _ _))) },\n    dsimp, rwr [is_prop_elim_self], hsimp\n    -- dsimp, rwr [is_prop_elim_self],\n    -- dsimp [apd], rwr [idpo_concato_eq, inv_con_cancel_right],\n  end\n\n  /- adjunction between (-)₊ : Type _ → Type* and pType.carrier : Type* → Type _  -/\n  @[hott] def pmap_equiv_left (A : Type _) (B : Type*) : A₊ →* B ≃ (A → B) :=\n  begin\n    fapply equiv.MK,\n    { intros f a, cases f with f p, exact f (some a) },\n    { intro f, fconstructor,\n        intro a, cases a, exact pt, exact f a,\n        reflexivity },\n    { intro f, reflexivity },\n    { intro f, cases f with f p, fapply eq_of_phomotopy, fapply phomotopy.mk,\n      { intro a, cases a, exact p⁻¹, refl },\n      { apply con.left_inv }},\n  end\n\n  -- pmap_pbool_pequiv is the pointed equivalence\n  @[hott] def pmap_pbool_equiv (B : Type*) : (pbool →* B) ≃ B :=\n  begin\n    fapply equiv.MK,\n    { intro f, cases f with f p, exact f tt },\n    { intro b, fconstructor,\n        intro u, cases u, exact pt, exact b,\n        reflexivity },\n    { intro b, reflexivity },\n    { intro f, cases f with f p, fapply eq_of_phomotopy, fapply phomotopy.mk,\n      { intro a, cases a, exact p⁻¹, refl },\n      { apply con.left_inv }},\n  end\n\n  /-\n    Pointed maps respecting pointed homotopies.\n    In general we need function extensionality for pap,\n    but for particular F we can do it without function extensionality.\n    This might be preferred, because such pointed homotopies compute. On the other hand,\n    when using function extensionality, it's easier to prove that if p is reflexivity, then the\n    resulting pointed homotopy is reflexivity\n  -/\n  @[hott] def pap (F : (A →* B) → (C →* D)) {f g : A →* B} (p : f ~* g) : F f ~* F g :=\n  begin\n    hinduction p using phomotopy_rec_idp, refl\n  end\n\n  @[hott] def pap_refl (F : (A →* B) → (C →* D)) (f : A →* B) :\n    pap F (phomotopy.refl f) = phomotopy.refl (F f) :=\n  begin dsimp [pap], exact phomotopy_rec_idp_refl _ end\n\n  @[hott] def ap1_phomotopy {f g : A →* B} (p : f ~* g) : Ω→ f ~* Ω→ g :=\n  pap Ω→ p\n\n  @[hott] def ap1_phomotopy_refl {X Y : Type*} (f : X →* Y) :\n    ap1_phomotopy (phomotopy.refl f) = phomotopy.refl (Ω→ f) :=\n  pap_refl _ _\n\n  --a proof not using function extensionality:\n  @[hott] def ap1_phomotopy_explicit {f g : A →* B} (p : f ~* g) : Ω→ f ~* Ω→ g :=\n  begin\n    induction p with p q, induction f with f pf, induction g with g pg, induction B with B b,\n    dsimp at *, induction pg, dsimp [respect_pt] at *, induction q,\n    fapply phomotopy.mk,\n    { hintro l, refine _ ⬝ (idp_con _)⁻¹, \n      dsimp [ap1, ap1_gen], symmetry,\n      apply eq_bot_of_square, exact natural_square_tr p l },\n    { induction A with A a, hsimp [ap1], refl }\n  end\n\n  @[hott] def apn_phomotopy {f g : A →* B} (n : ℕ) (p : f ~* g) : apn n f ~* apn n g :=\n  begin\n    induction n with n IH,\n    { exact p},\n    { exact ap1_phomotopy IH}\n  end\n\n  -- the following two definitiongs are mostly the same, maybe we should remove one\n  @[hott] def ap_eq_of_phomotopy {A B : Type*} {f g : A →* B} (p : f ~* g) (a : A) :\n    ap (λf : A →* B, f a) (eq_of_phomotopy p) = p a :=\n  ap010 to_homotopy (phomotopy_of_eq_of_phomotopy p) a\n\n  @[hott] def to_fun_eq_of_phomotopy {A B : Type*} {f g : A →* B} (p : f ~* g) (a : A) :\n    ap010 pmap.to_fun (eq_of_phomotopy p) a = p a :=\n  begin\n    hinduction p using phomotopy_rec_idp,\n    exact ap (λx, ap010 pmap.to_fun x a) (eq_of_phomotopy_refl _)\n  end\n\n  @[hott] def ap1_eq_of_phomotopy {A B : Type*} {f g : A →* B} (p : f ~* g) :\n    ap Ω→ (eq_of_phomotopy p) = eq_of_phomotopy (ap1_phomotopy p) :=\n  begin\n    hinduction p using phomotopy_rec_idp,\n    refine ap02 _ (eq_of_phomotopy_refl _) ⬝ (eq_of_phomotopy_refl _)⁻¹ ⬝ ap eq_of_phomotopy _,\n    exact (ap1_phomotopy_refl _)⁻¹\n  end\n\n  /- pointed homotopies between the given pointed maps -/\n\n  @[hott] def ap1_pid {A : Type*} : ap1 (pid A) ~* pid (Ω A) :=\n  begin\n    fapply phomotopy.mk,\n    { intro p, refine idp_con _ ⬝ ap_id _ },\n    { refl }\n  end\n\n  @[hott] def ap1_pinverse {A : Type*} : ap1 (@pinverse A) ~* @pinverse (Ω A) :=\n  begin\n    fapply phomotopy.mk,\n    { intro p, refine idp_con _ ⬝ _, exact (inv_eq_inv2 _)⁻¹ },\n    { refl }\n  end\n\n  @[hott] def ap1_gen_compose {A B C : Type _} (g : B → C) (f : A → B) {a₁ a₂ : A} {b₁ b₂ : B}\n    {c₁ c₂ : C} (q₁ : f a₁ = b₁) (q₂ : f a₂ = b₂) (r₁ : g b₁ = c₁) (r₂ : g b₂ = c₂) (p : a₁ = a₂) :\n    ap1_gen (g ∘ f) (ap g q₁ ⬝ r₁) (ap g q₂ ⬝ r₂) p = ap1_gen g r₁ r₂ (ap1_gen f q₁ q₂ p) :=\n  begin induction p, induction q₁, induction q₂, induction r₁, induction r₂, reflexivity end\n\n  @[hott] def ap1_gen_compose_idp {A B C : Type _} (g : B → C) (f : A → B) {a : A}\n    {b : B} {c : C} (q : f a = b) (r : g b = c) :\n    ap1_gen_compose g f q q r r idp ⬝ (ap (ap1_gen g r r) (ap1_gen_idp f q) ⬝ ap1_gen_idp g r) =\n    ap1_gen_idp (g ∘ f) (ap g q ⬝ r) :=\n  begin induction q, induction r, reflexivity end\n\n  @[hott] def ap1_pcompose {A B C : Type*} (g : B →* C) (f : A →* B) :\n    ap1 (g ∘* f) ~* ap1 g ∘* ap1 f :=\n  phomotopy.mk (ap1_gen_compose g f (respect_pt f) (respect_pt f) (respect_pt g) (respect_pt g))\n               (ap1_gen_compose_idp g f (respect_pt f) (respect_pt g))\n\n  @[hott] def ap1_pconst (A B : Type*) : Ω→(pconst A B) ~* pconst (Ω A) (Ω B) :=\n  phomotopy.mk (λp, ap1_gen_idp_left (const A pt) p ⬝ ap_constant p pt) rfl\n\n  @[hott] def ap1_gen_con_left {A B : Type _} {a a' : A} {b₀ b₁ b₂ : B}\n    {f : A → b₀ = b₁} {f' : A → b₁ = b₂} {q₀ q₁ : b₀ = b₁} {q₀' q₁' : b₁ = b₂}\n    (r₀ : f a = q₀) (r₁ : f a' = q₁) (r₀' : f' a = q₀') (r₁' : f' a' = q₁') (p : a = a') :\n      ap1_gen (λa, f a ⬝ f' a) (r₀ ◾ r₀') (r₁ ◾ r₁') p =\n      whisker_right q₀' (ap1_gen f r₀ r₁ p) ⬝ whisker_left q₁ (ap1_gen f' r₀' r₁' p) :=\n  begin induction r₀, induction r₁, induction r₀', induction r₁', induction p, reflexivity end\n\n  @[hott] def ap1_gen_con_left_idp {A B : Type _} {a : A} {b₀ b₁ b₂ : B}\n    {f : A → b₀ = b₁} {f' : A → b₁ = b₂} {q₀ : b₀ = b₁} {q₁ : b₁ = b₂}\n    (r₀ : f a = q₀) (r₁ : f' a = q₁) :\n      ap1_gen_con_left r₀ r₀ r₁ r₁ idp =\n      con.left_inv _ ⬝ (ap (whisker_right q₁) (con.left_inv _) ◾ ap (whisker_left _) (con.left_inv _))⁻¹ :=\n  begin induction r₀, induction r₁, reflexivity end\n\n  @[hott] def ptransport_change_eq {A : Type _} (B : A → Type*) {a a' : A} {p q : a = a'}\n    (r : p = q) : ptransport B p ~* ptransport B q :=\n  phomotopy.mk (λb, ap (λp, transport (λa, B a) p b) r) begin induction r, apply idp_con end\n\n  @[hott] def pnatural_square {A B : Type _} (X : B → Type*) {f g : A → B}\n    (h : Πa, X (f a) →* X (g a)) {a a' : A} (p : a = a') :\n    h a' ∘* ptransport X (ap f p) ~* ptransport X (ap g p) ∘* h a :=\n  by induction p; exact pcompose_pid _ ⬝* (pid_pcompose _)⁻¹*\n\n  @[hott] def apn_pid {A : Type*} (n : ℕ) : apn n (pid A) ~* pid (Ω[n] A) :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { exact ap1_phomotopy IH ⬝* ap1_pid}\n  end\n\n  @[hott] def apn_pconst (A B : Type*) (n : ℕ) :\n    apn n (pconst A B) ~* pconst (Ω[n] A) (Ω[n] B) :=\n  begin\n    induction n with n IH,\n    { reflexivity },\n    { exact ap1_phomotopy IH ⬝* ap1_pconst _ _ }\n  end\n\n  @[hott] def apn_pcompose (n : ℕ) (g : B →* C) (f : A →* B) :\n    apn n (g ∘* f) ~* apn n g ∘* apn n f :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { refine ap1_phomotopy IH ⬝* _, apply ap1_pcompose}\n  end\n\n  @[hott] def pcast_idp {A : Type*} : pcast (idpath A) ~* pid A :=\n  by reflexivity\n\n  @[hott] def pinverse_pinverse (A : Type*) : pinverse A ∘* pinverse A ~* pid (Ω A) :=\n  begin\n    fapply phomotopy.mk,\n    { apply hott.eq.inv_inv },\n    { reflexivity}\n  end\n\n  @[hott] def pcast_ap_loop {A B : Type*} (p : A = B) :\n    pcast (ap Ω p) ~* ap1 (pcast p) :=\n  begin\n    fapply phomotopy.mk,\n    { intro a, induction p, symmetry, exact idp_con _ ⬝ ap_id _ },\n    { induction p, refl }\n  end\n\n  @[hott] def ap1_pmap_of_map {A B : Type _} (f : A → B) (a : A) :\n    ap1 (pmap_of_map f a) ~* pmap_of_map (ap f) (idpath a) :=\n  begin\n    fapply phomotopy.mk,\n    { intro a, apply idp_con },\n    { reflexivity }\n  end\n\n  @[hott] def pcast_commute {A : Type _} {B C : A → Type*} (f : Πa, B a →* C a)\n    {a₁ a₂ : A} (p : a₁ = a₂) : pcast (ap C p) ∘* f a₁ ~* f a₂ ∘* pcast (ap B p) :=\n  phomotopy.mk\n    begin induction p, reflexivity end\n    begin induction p, refine idp_con _ ⬝ idp_con _ ⬝ _, symmetry, apply ap_id end\n\n  /- pointed equivalences -/\n\n  structure pequiv (A B : Type*) :=\n  mk' :: (to_pmap : A →* B)\n         (to_pinv1 : B →* A)\n         (to_pinv2 : B →* A)\n         (pright_inv : to_pmap ∘* to_pinv1 ~* pid B)\n         (pleft_inv : to_pinv2 ∘* to_pmap ~* pid A)\n\n  infix ` ≃* `:25 := pequiv\n\n  @[hott, reducible] def pmap_of_pequiv {A B : Type*} (f : A ≃* B) :\n    @ppi A (λa, B) pt :=\n  f.to_pmap\n\n  @[hott, reducible] def pequiv.to_fun {A B : Type*} (f : A ≃* B) : A → B := f.to_pmap\n\n  @[hott] instance {A B : Type*} (f : A ≃* B) : has_coe (A ≃* B) (A →* B) :=\n  ⟨pmap_of_pequiv⟩\n\n  @[hott] def to_pinv (f : A ≃* B) : B →* A :=\n  pequiv.to_pinv1 f\n\n  @[hott] def pleft_inv' (f : A ≃* B) : to_pinv f ∘* f.to_pmap ~* pid A :=\n  let g := to_pinv f in\n  let h := pequiv.to_pinv2 f in\n  calc g ∘* f.to_pmap ~* pid A ∘* (g ∘* f.to_pmap)    : by exact (pid_pcompose _)⁻¹*\n          ... ~* (h ∘* f.to_pmap) ∘* (g ∘* f.to_pmap) : by exact pwhisker_right _ (pequiv.pleft_inv f)⁻¹*\n          ... ~* h ∘* (f.to_pmap ∘* g) ∘* f.to_pmap   : by exact passoc _ _ _ ⬝* pwhisker_left _ (passoc _ _ _)⁻¹*\n          ... ~* h ∘* pid B ∘* f.to_pmap              : by exact pwhisker_left _ (pwhisker_right _ (pequiv.pright_inv _))\n          ... ~* h ∘* f.to_pmap                       : by exact pwhisker_left _ (pid_pcompose _)\n          ... ~* pid A                                : by exact pequiv.pleft_inv f\n\n  @[hott] def equiv_of_pequiv (f : A ≃* B) : A ≃ B :=\n  equiv.mk f.to_pmap $ adjointify f.to_pmap (to_pinv f) (pequiv.pright_inv f) (pleft_inv' f)\n\n  @[hott] def pequiv.to_equiv (f : A ≃* B) : A ≃ B := equiv_of_pequiv f\n\n  @[hott] instance pequiv_to_equiv {A B : Type*} (f : A ≃* B) : has_coe (A ≃* B) (A ≃ B) :=\n  ⟨equiv_of_pequiv⟩\n\n  @[hott, instance] def pequiv.to_is_equiv (f : A ≃* B) : is_equiv (f.to_pmap) :=\n  to_is_equiv (equiv_of_pequiv f)\n\n  @[hott] protected def pequiv.MK (f : A →* B) (g : B →* A)\n    (gf : g ∘* f ~* pid A) (fg : f ∘* g ~* pid B) : A ≃* B :=\n  pequiv.mk' f g g fg gf\n\n  @[hott] def pinv (f : A →* B) (H : is_equiv f) : B →* A :=\n  pmap.mk f⁻¹ᶠ (ap f⁻¹ᶠ (respect_pt f)⁻¹ ⬝ (left_inv f pt))\n\n  @[hott] def pequiv_of_pmap (f : A →* B) (H : is_equiv f) : A ≃* B :=\n  pequiv.mk' f (pinv f H) (pinv f H)\n  begin abstract\n    {fapply phomotopy.mk, exact right_inv f,\n    unfreezeI, induction f with f f₀, induction B with B b₀, dsimp at *, induction f₀,\n    exactI adj f pt ⬝ ap02 f (idp_con _)⁻¹ᵖ }\n  end\n  begin abstract\n    {fapply phomotopy.mk, exact left_inv f,\n    unfreezeI, induction f with f f₀, induction B with B b₀, dsimp at *, induction f₀,\n    exact (idp_con _)⁻¹ ⬝ (idp_con _)⁻¹}\n  end\n\n  @[hott] def pequiv.mk (f : A → B) (H : is_equiv f) (p : f pt = pt) : A ≃* B :=\n  pequiv_of_pmap (pmap.mk f p) H\n\n  @[hott] def pequiv_of_equiv (f : A ≃ B) (H : f pt = pt) : A ≃* B :=\n  pequiv.mk f f.to_is_equiv H\n\n  @[hott, hsimp] def respect_pt_pequiv_of_equiv (f : A ≃ B) (H : f pt = pt) : \n    respect_pt (pequiv_of_equiv f H).to_pmap = H :=\n  by refl\n\n  @[hott, hsimp] def to_fun_pequiv_of_equiv (f : A ≃ B) (H : f pt = pt) : \n    (pequiv_of_equiv f H).to_pmap.to_fun = f.to_fun :=\n  by refl\n\n  @[hott] protected def pequiv.MK' (f : A →* B) (g : B → A)\n    (gf : Πa, g (f a) = a) (fg : Πb, f (g b) = b) : A ≃* B :=\n  pequiv.mk f (adjointify f g fg gf) (respect_pt f)\n\n  /- reflexivity and symmetry (transitivity is below) -/\n\n  @[hott] protected def pequiv.refl (A : Type*) : A ≃* A :=\n  pequiv.mk' (pid A) (pid A) (pid A) (pid_pcompose _) (pcompose_pid _)\n\n  @[hott, refl, reducible] protected def pequiv.rfl : A ≃* A :=\n  pequiv.refl A\n\n  @[hott, symm] protected def pequiv.symm (f : A ≃* B) : B ≃* A :=\n  pequiv.MK (to_pinv f) f.to_pmap (pequiv.pright_inv f) (pleft_inv' f)\n\n  postfix `⁻¹ᵉ*`:(max + 1) := pequiv.symm\n\n  @[hott] def pleft_inv (f : A ≃* B) : f⁻¹ᵉ*.to_pmap ∘* f.to_pmap ~* pid A :=\n  pleft_inv' f\n\n  @[hott] def pright_inv (f : A ≃* B) : f.to_pmap ∘* f⁻¹ᵉ*.to_pmap ~* pid B :=\n  pequiv.pright_inv f\n\n  @[hott] def to_pmap_pequiv_of_pmap {A B : Type*} (f : A →* B) (H : is_equiv f)\n    : pequiv.to_pmap (pequiv_of_pmap f H) = f :=\n  by reflexivity\n\n  @[hott] def to_pmap_pequiv_MK (f : A →* B) (g : B →* A)\n    (gf : g ∘* f ~* pid A) (fg : f ∘* g ~* pid B) : (pequiv.MK f g gf fg).to_pmap ~* f :=\n  by reflexivity\n\n  @[hott] def to_pinv_pequiv_MK (f : A →* B) (g : B →* A)\n    (gf : g ∘* f ~* pid A) (fg : f ∘* g ~* pid B) : to_pinv (pequiv.MK f g gf fg) ~* g :=\n  by reflexivity\n\n  /- more on pointed equivalences -/\n\n  @[hott] def pequiv_ap {A : Type _} (B : A → Type*) {a a' : A} (p : a = a')\n    : B a ≃* B a' :=\n  pequiv_of_pmap (ptransport B p) (is_equiv_tr (λa, B a) p)\n\n  @[hott] def pequiv_change_fun (f : A ≃* B) (f' : A →* B) (Heq : f.to_pmap ~ f') : A ≃* B :=\n  pequiv_of_pmap f' (is_equiv.homotopy_closed f.to_pmap Heq)\n\n  @[hott] def pequiv_change_inv (f : A ≃* B) (f' : B →* A) (Heq : to_pinv f ~ f')\n    : A ≃* B :=\n  pequiv.MK' f.to_pmap f' (to_left_inv (equiv_change_inv (equiv_of_pequiv f) Heq)) (to_right_inv (equiv_change_inv (equiv_of_pequiv f) Heq))\n\n  @[hott] def pequiv_rect' (f : A ≃* B) (P : A → B → Type _)\n    (g : Πb, P ((equiv_of_pequiv f)⁻¹ᵉ b) b) (a : A) : P a (f.to_pmap a) :=\n  transport (λx, P x (f.to_pmap a)) (left_inv f.to_pmap a) (g (f.to_pmap a))\n\n  @[hott] def pua {A B : Type*} (f : A ≃* B) : A = B :=\n  pType_eq (equiv_of_pequiv f) (respect_pt _)\n\n  @[hott] def pequiv_of_eq {A B : Type*} (p : A = B) : A ≃* B :=\n  pequiv_of_pmap (pcast p) (is_equiv_tr (λa, a) _)\n\n  @[hott] def eq_of_pequiv {A B : Type*} (p : A ≃* B) : A = B :=\n  pType_eq (equiv_of_pequiv p) (respect_pt _)\n\n  @[hott] def peap {A B : Type*} (F : Type* → Type*) (p : A ≃* B) : F A ≃* F B :=\n  pequiv_of_pmap (pcast (ap F (eq_of_pequiv p))) begin induction eq_of_pequiv p, apply is_equiv_id end\n\n  -- rename pequiv_of_eq_natural\n  @[hott] def pequiv_of_eq_commute {A : Type _} {B C : A → Type*} (f : Πa, B a →* C a)\n    {a₁ a₂ : A} (p : a₁ = a₂) : (pequiv_of_eq (ap C p)).to_pmap ∘* f a₁ ~* f a₂ ∘* (pequiv_of_eq (ap B p)).to_pmap :=\n  pcast_commute f p\n\n  -- @[hott] def pequiv.eta_expand {A B : Type*} (f : A ≃* B) : A ≃* B :=\n  -- pequiv.mk' f (to_pinv f) (pequiv.to_pinv2 f) (pright_inv f) _\n\n  /-\n    the @[hott] theorem pequiv_eq, which gives a condition for two pointed equivalences are equal\n    is in types.equiv to avoid circular imports\n  -/\n\n  /- computation rules of pointed homotopies, possibly combined with pointed equivalences -/\n  @[hott] def pcancel_left (f : B ≃* C) {g h : A →* B} (p : f.to_pmap ∘* g ~* f.to_pmap ∘* h) : g ~* h :=\n  begin\n    refine _⁻¹* ⬝* pwhisker_left f⁻¹ᵉ*.to_pmap p ⬝* _,\n    all_goals {refine (passoc _ _ _)⁻¹* ⬝* _,\n    refine pwhisker_right _ (pleft_inv f) ⬝* _,\n    apply pid_pcompose }\n  end\n\n  @[hott] def pcancel_right (f : A ≃* B) {g h : B →* C} (p : g ∘* f.to_pmap ~* h ∘* f.to_pmap) : g ~* h :=\n  begin\n    refine _⁻¹* ⬝* pwhisker_right f⁻¹ᵉ*.to_pmap p ⬝* _,\n    all_goals {refine passoc _ _ _ ⬝* _,\n    refine pwhisker_left _ (pright_inv f) ⬝* _,\n    apply pcompose_pid }\n  end\n\n  @[hott] def phomotopy_pinv_right_of_phomotopy {f : A ≃* B} {g : B →* C} {h : A →* C}\n    (p : g ∘* f.to_pmap ~* h) : g ~* h ∘* f⁻¹ᵉ*.to_pmap :=\n  begin\n    refine _ ⬝* pwhisker_right _ p, symmetry,\n    refine passoc _ _ _ ⬝* _,\n    refine pwhisker_left _ (pright_inv f) ⬝* _,\n    apply pcompose_pid\n  end\n\n  @[hott] def phomotopy_of_pinv_right_phomotopy {f : B ≃* A} {g : B →* C} {h : A →* C}\n    (p : g ∘* f⁻¹ᵉ*.to_pmap ~* h) : g ~* h ∘* f.to_pmap :=\n  begin\n    refine _ ⬝* pwhisker_right _ p, symmetry,\n    refine passoc _ _ _ ⬝* _,\n    refine pwhisker_left _ (pleft_inv f) ⬝* _,\n    apply pcompose_pid\n  end\n\n  @[hott] def pinv_right_phomotopy_of_phomotopy {f : A ≃* B} {g : B →* C} {h : A →* C}\n    (p : h ~* g ∘* f.to_pmap) : h ∘* f⁻¹ᵉ*.to_pmap ~* g :=\n  (phomotopy_pinv_right_of_phomotopy p⁻¹*)⁻¹*\n\n  @[hott] def phomotopy_of_phomotopy_pinv_right {f : B ≃* A} {g : B →* C} {h : A →* C}\n    (p : h ~* g ∘* f⁻¹ᵉ*.to_pmap) : h ∘* f.to_pmap ~* g :=\n  (phomotopy_of_pinv_right_phomotopy p⁻¹*)⁻¹*\n\n  @[hott] def phomotopy_pinv_left_of_phomotopy {f : B ≃* C} {g : A →* B} {h : A →* C}\n    (p : f.to_pmap ∘* g ~* h) : g ~* f⁻¹ᵉ*.to_pmap ∘* h :=\n  begin\n    refine _ ⬝* pwhisker_left _ p, symmetry,\n    refine (passoc _ _ _)⁻¹* ⬝* _,\n    refine pwhisker_right _ (pleft_inv f) ⬝* _,\n    apply pid_pcompose\n  end\n\n  @[hott] def phomotopy_of_pinv_left_phomotopy {f : C ≃* B} {g : A →* B} {h : A →* C}\n    (p : f⁻¹ᵉ*.to_pmap ∘* g ~* h) : g ~* f.to_pmap ∘* h :=\n  begin\n    refine _ ⬝* pwhisker_left _ p, symmetry,\n    refine (passoc _ _ _)⁻¹* ⬝* _,\n    refine pwhisker_right _ (pright_inv f) ⬝* _,\n    apply pid_pcompose\n  end\n\n  @[hott] def pinv_left_phomotopy_of_phomotopy {f : B ≃* C} {g : A →* B} {h : A →* C}\n    (p : h ~* f.to_pmap ∘* g) : f⁻¹ᵉ*.to_pmap ∘* h ~* g :=\n  (phomotopy_pinv_left_of_phomotopy p⁻¹*)⁻¹*\n\n  @[hott] def phomotopy_of_phomotopy_pinv_left {f : C ≃* B} {g : A →* B} {h : A →* C}\n    (p : h ~* f⁻¹ᵉ*.to_pmap ∘* g) : f.to_pmap ∘* h ~* g :=\n  (phomotopy_of_pinv_left_phomotopy p⁻¹*)⁻¹*\n\n  @[hott] def pcompose2 {A B C : Type*} {g g' : B →* C} {f f' : A →* B} (q : g ~* g') (p : f ~* f') :\n    g ∘* f ~* g' ∘* f' :=\n  pwhisker_right f q ⬝* pwhisker_left g' p\n\n  infixr ` ◾* `:80 := pcompose2\n\n  @[hott] def phomotopy_pinv_of_phomotopy_pid {A B : Type*} {f : A →* B} {g : B ≃* A}\n    (p : g.to_pmap ∘* f ~* pid A) : f ~* g⁻¹ᵉ*.to_pmap :=\n  phomotopy_pinv_left_of_phomotopy p ⬝* pcompose_pid _\n\n  @[hott] def phomotopy_pinv_of_phomotopy_pid' {A B : Type*} {f : A →* B} {g : B ≃* A}\n    (p : f ∘* g.to_pmap ~* pid B) : f ~* g⁻¹ᵉ*.to_pmap :=\n  phomotopy_pinv_right_of_phomotopy p ⬝* pid_pcompose _\n\n  @[hott] def pinv_phomotopy_of_pid_phomotopy {A B : Type*} {f : A →* B} {g : B ≃* A}\n    (p : pid A ~* g.to_pmap ∘* f) : g⁻¹ᵉ*.to_pmap ~* f :=\n  (phomotopy_pinv_of_phomotopy_pid p⁻¹*)⁻¹*\n\n  @[hott] def pinv_phomotopy_of_pid_phomotopy' {A B : Type*} {f : A →* B} {g : B ≃* A}\n    (p : pid B ~* f ∘* g.to_pmap) : g⁻¹ᵉ*.to_pmap ~* f :=\n  (phomotopy_pinv_of_phomotopy_pid' p⁻¹*)⁻¹*\n\n  @[hott] def pinv_pcompose_cancel_left {A B C : Type*} (g : B ≃* C) (f : A →* B) :\n    g⁻¹ᵉ*.to_pmap ∘* (g.to_pmap ∘* f) ~* f :=\n  (passoc _ _ _)⁻¹* ⬝* pwhisker_right f (pleft_inv _) ⬝* pid_pcompose _\n\n  @[hott] def pcompose_pinv_cancel_left {A B C : Type*} (g : C ≃* B) (f : A →* B) :\n    g.to_pmap ∘* (g⁻¹ᵉ*.to_pmap ∘* f) ~* f :=\n  (passoc _ _ _)⁻¹* ⬝* pwhisker_right f (pright_inv _) ⬝* pid_pcompose _\n\n  @[hott] def pinv_pcompose_cancel_right {A B C : Type*} (g : B →* C) (f : B ≃* A) :\n    (g ∘* f⁻¹ᵉ*.to_pmap) ∘* f.to_pmap ~* g :=\n  passoc _ _ _ ⬝* pwhisker_left g (pleft_inv _) ⬝* pcompose_pid _\n\n  @[hott] def pcompose_pinv_cancel_right {A B C : Type*} (g : B →* C) (f : A ≃* B) :\n    (g ∘* f.to_pmap) ∘* f⁻¹ᵉ*.to_pmap ~* g :=\n  passoc _ _ _ ⬝* pwhisker_left g (pright_inv _) ⬝* pcompose_pid _\n\n  @[hott] def pinv_pinv {A B : Type*} (f : A ≃* B) : (f⁻¹ᵉ*)⁻¹ᵉ*.to_pmap ~* f.to_pmap :=\n  (phomotopy_pinv_of_phomotopy_pid (pleft_inv f))⁻¹*\n\n  @[hott] def pinv2 {A B : Type*} {f f' : A ≃* B} (p : f.to_pmap ~* f'.to_pmap) : f⁻¹ᵉ*.to_pmap ~* f'⁻¹ᵉ*.to_pmap :=\n  phomotopy_pinv_of_phomotopy_pid (pinv_right_phomotopy_of_phomotopy (pid_pcompose _ ⬝* p)⁻¹*)\n\n  postfix [parsing_only] `⁻²*`:(max+10) := pinv2\n\n  @[hott, trans] protected def pequiv.trans (f : A ≃* B) (g : B ≃* C) : A ≃* C :=\n  pequiv.MK (g.to_pmap ∘* f.to_pmap) (f⁻¹ᵉ*.to_pmap ∘* g⁻¹ᵉ*.to_pmap)\n    begin abstract {exact passoc _ _ _ ⬝* pwhisker_left _ (pinv_pcompose_cancel_left g f.to_pmap) ⬝* pleft_inv f} end\n    begin abstract {exact passoc _ _ _ ⬝* pwhisker_left _ (pcompose_pinv_cancel_left f g⁻¹ᵉ*.to_pmap) ⬝* pright_inv g} end\n\n  @[hott] def pequiv_compose {A B C : Type*} (g : B ≃* C) (f : A ≃* B) : A ≃* C :=\n  pequiv.trans f g\n\n  infix ` ⬝e* `:75 := pequiv.trans\n  infixr ` ∘*ᵉ `:60 := pequiv_compose\n\n  @[hott] def to_pmap_pequiv_trans {A B C : Type*} (f : A ≃* B) (g : B ≃* C)\n    : (f ⬝e* g).to_pmap = g.to_pmap ∘* f.to_pmap :=\n  by reflexivity\n\n  @[hott] def to_fun_pequiv_trans {X Y Z : Type*} (f : X ≃* Y) (g :Y ≃* Z) : (f ⬝e* g).to_pmap ~ g.to_pmap ∘ f.to_pmap :=\n  λx, idp\n\n  @[hott] def peconcat_eq {A B C : Type*} (p : A ≃* B) (q : B = C) : A ≃* C :=\n  p ⬝e* pequiv_of_eq q\n\n  @[hott] def eq_peconcat {A B C : Type*} (p : A = B) (q : B ≃* C) : A ≃* C :=\n  pequiv_of_eq p ⬝e* q\n\n\n  infix ` ⬝e*p `:75 := peconcat_eq\n  infix ` ⬝pe* `:75 := eq_peconcat\n\n\n  @[hott] def trans_pinv {A B C : Type*} (f : A ≃* B) (g : B ≃* C) :\n    (f ⬝e* g)⁻¹ᵉ*.to_pmap ~* f⁻¹ᵉ*.to_pmap ∘* g⁻¹ᵉ*.to_pmap :=\n  by reflexivity\n\n  @[hott] def pinv_trans_pinv_left {A B C : Type*} (f : B ≃* A) (g : B ≃* C) :\n    (f⁻¹ᵉ* ⬝e* g)⁻¹ᵉ*.to_pmap ~* f.to_pmap ∘* g⁻¹ᵉ*.to_pmap :=\n  by reflexivity\n\n  @[hott] def pinv_trans_pinv_right {A B C : Type*} (f : A ≃* B) (g : C ≃* B) :\n    (f ⬝e* g⁻¹ᵉ*)⁻¹ᵉ*.to_pmap ~* f⁻¹ᵉ*.to_pmap ∘* g.to_pmap :=\n  by reflexivity\n\n  @[hott] def pinv_trans_pinv_pinv {A B C : Type*} (f : B ≃* A) (g : C ≃* B) :\n    (f⁻¹ᵉ* ⬝e* g⁻¹ᵉ*)⁻¹ᵉ*.to_pmap ~* f.to_pmap ∘* g.to_pmap :=\n  by reflexivity\n\n  /- pointed equivalences between particular pointed types -/\n\n  -- TODO: remove is_equiv_apn, which is proven again here\n  @[hott] def loopn_pequiv_loopn (n : ℕ) (f : A ≃* B) : Ω[n] A ≃* Ω[n] B :=\n  pequiv.MK (apn n f.to_pmap) (apn n f⁻¹ᵉ*.to_pmap)\n  begin abstract\n    {induction n with n IH,\n    { apply pleft_inv},\n    { rwr [show nat.succ n = n + 1, from idp, apn_succ],\n      refine (ap1_pcompose _ _)⁻¹* ⬝* _,\n      refine ap1_phomotopy IH ⬝* _,\n      apply ap1_pid}}\n  end\n  begin abstract\n    {induction n with n IH,\n    { apply pright_inv},\n    { rwr [show nat.succ n = n + 1, from idp, apn_succ],\n      refine (ap1_pcompose _ _)⁻¹* ⬝* _,\n      refine ap1_phomotopy IH ⬝* _,\n      apply ap1_pid}}\n  end\n\n  @[hott] def loop_pequiv_loop (f : A ≃* B) : Ω A ≃* Ω B :=\n  loopn_pequiv_loopn 1 f\n\n  @[hott] def loop_pequiv_eq_closed {A : Type _} {a a' : A} (p : a = a')\n    : pointed.MK (a = a) idp ≃* pointed.MK (a' = a') idp :=\n  pequiv_of_equiv (loop_equiv_eq_closed p) (con.left_inv p)\n\n  @[hott] def to_pmap_loopn_pequiv_loopn (n : ℕ) (f : A ≃* B)\n    : (loopn_pequiv_loopn n f).to_pmap ~* apn n f.to_pmap :=\n  by refl\n\n  @[hott] def to_pinv_loopn_pequiv_loopn (n : ℕ) (f : A ≃* B)\n    : (loopn_pequiv_loopn n f)⁻¹ᵉ*.to_pmap ~* apn n f⁻¹ᵉ*.to_pmap :=\n  by refl\n\n  @[hott] def loopn_pequiv_loopn_con (n : ℕ) (f : A ≃* B) (p q : Ω[n+1] A)\n    : (loopn_pequiv_loopn (n+1) f).to_pmap.to_fun (p ⬝ q) =\n    (loopn_pequiv_loopn (n+1) f).to_pmap.to_fun p ⬝ (loopn_pequiv_loopn (n+1) f).to_pmap.to_fun q :=\n  ap1_con (loopn_pequiv_loopn n f).to_pmap p q\n\n  @[hott] def loop_pequiv_loop_con {A B : Type*} (f : A ≃* B) (p q : Ω A)\n    : (loop_pequiv_loop f).to_pmap (p ⬝ q) = (loop_pequiv_loop f).to_pmap p ⬝ (loop_pequiv_loop f).to_pmap q :=\n  loopn_pequiv_loopn_con 0 f p q\n\n  @[hott] def loopn_pequiv_loopn_rfl (n : ℕ) (A : Type*) :\n    (loopn_pequiv_loopn n (pequiv.refl A)).to_pmap ~* (pequiv.refl (Ω[n] A)).to_pmap :=\n  begin\n    exact to_pmap_loopn_pequiv_loopn _ _ ⬝* apn_pid n,\n  end\n\n  @[hott] def loop_pequiv_loop_rfl (A : Type*) :\n    (loop_pequiv_loop (pequiv.refl A)).to_pmap ~* (pequiv.refl (Ω A)).to_pmap :=\n  loopn_pequiv_loopn_rfl 1 A\n\n-- duplicate of to_pinv_loopn_pequiv_loopn\n  @[hott] def apn_pinv (n : ℕ) {A B : Type*} (f : A ≃* B) :\n    Ω→[n] f⁻¹ᵉ*.to_pmap ~* (loopn_pequiv_loopn n f)⁻¹ᵉ*.to_pmap :=\n  by reflexivity\n\n  @[hott] def pmap_functor {A A' B B' : Type*} (f : A' →* A) (g : B →* B') :\n    ppmap A B →* ppmap A' B' :=\n  pmap.mk (λh, g ∘* h ∘* f)\n    begin abstract {fapply eq_of_phomotopy, fapply phomotopy.mk,\n      { hintro a, exact respect_pt g},\n      { symmetry, refine _ ◾ idp ⬝ idp_con _,\n        exact ap02 g (ap_constant _ _) }}\n    end\n\n  @[hott] def pequiv_pinverse (A : Type*) : Ω A ≃* Ω A :=\n  pequiv_of_pmap (pinverse A) (is_equiv_eq_inverse _ _)\n\n  @[hott] def pequiv_of_eq_pt {A : Type _} {a a' : A} (p : a = a') :\n    pointed.MK A a ≃* pointed.MK A a' :=\n  pequiv_of_pmap (pmap_of_eq_pt p) (is_equiv_id _)\n\n  @[hott] def pointed_eta_pequiv (A : Type*) : A ≃* pointed.MK A pt :=\n  pequiv.mk id (is_equiv_id _) idp\n\n  /- every pointed map is homotopic to one of the form `pmap_of_map _ _`, up to some\n     pointed equivalences -/\n  @[hott] def phomotopy_pmap_of_map {A B : Type*} (f : A →* B) :\n    (pointed_eta_pequiv B ⬝e* (pequiv_of_eq_pt (respect_pt f))⁻¹ᵉ*).to_pmap ∘* f ∘*\n      (pointed_eta_pequiv A)⁻¹ᵉ*.to_pmap ~* pmap_of_map f pt :=\n  begin\n    fapply phomotopy.mk,\n    { reflexivity},\n    { symmetry, exact (ap_id _ ⬝ idp_con _) ◾ (idp_con _ ⬝ ap_id _) ⬝ con.right_inv _ }\n  end\n\n  /- properties of iterated loop space -/\n  variable (A)\n  @[hott] def loopn_succ_in (n : ℕ) : Ω[succ n] A ≃* Ω[n] (Ω A) :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { exact loop_pequiv_loop IH}\n  end\n\n  @[hott] def loopn_add (n m : ℕ) : Ω[n] (Ω[m] A) ≃* Ω[m+n] (A) :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { exact loop_pequiv_loop IH}\n  end\n\n  @[hott] def loopn_succ_out (n : ℕ) : Ω[succ n] A ≃* Ω(Ω[n] A)  :=\n  by reflexivity\n\n  variable {A}\n\n  @[hott] def loopn_succ_in_con {n : ℕ} (p q : Ω[succ (succ n)] A) :\n    (loopn_succ_in A (succ n)).to_pmap (p ⬝ q) =\n    (loopn_succ_in A (succ n)).to_pmap p ⬝ (loopn_succ_in A (succ n)).to_pmap q :=\n  loop_pequiv_loop_con _ _ _\n\n  @[hott] def loopn_loop_irrel (p : point A = point A) : Ω(pointed.Mk p) = Ω[2] A :=\n  begin\n    intros, fapply pType_eq,\n    { transitivity _,\n      apply eq_equiv_fn_eq_of_equiv (equiv_eq_closed_right _ p⁻¹),\n      apply eq_equiv_eq_closed, apply con.right_inv, apply con.right_inv},\n    { apply con.left_inv}\n  end\n\n  @[hott] def loopn_space_loop_irrel (n : ℕ) (p : point A = point A)\n    : Ω[succ n](pointed.Mk p) = Ω[succ (succ n)] A :> pType :=\n  calc\n    Ω[succ n](pointed.Mk p) = Ω[n](Ω (pointed.Mk p)) : eq_of_pequiv $ loopn_succ_in _ _\n      ... = Ω[n] (Ω[2] A)                            : ap Ω[n] $ loopn_loop_irrel p\n      ... = Ω[n+1] (Ω A)                             : eq_of_pequiv $ (loopn_succ_in _ _)⁻¹ᵉ*\n      ... = Ω[n+2] A                                 : eq_of_pequiv $ (loopn_succ_in _ _)⁻¹ᵉ*\n\n  @[hott] def apn_succ_phomotopy_in (n : ℕ) (f : A →* B) :\n    (loopn_succ_in B n).to_pmap ∘* Ω→[n + 1] f ~* Ω→[n] (Ω→ f) ∘* (loopn_succ_in A n).to_pmap :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { exact (ap1_pcompose _ _)⁻¹* ⬝* ap1_phomotopy IH ⬝* (ap1_pcompose _ _)}\n  end\n\n  @[hott] def loopn_succ_in_natural {A B : Type*} (n : ℕ) (f : A →* B) :\n    (loopn_succ_in B n).to_pmap ∘* Ω→[n+1] f ~* Ω→[n] (Ω→ f) ∘* (loopn_succ_in A n).to_pmap :=\n  apn_succ_phomotopy_in _ _\n\n  @[hott] def loopn_succ_in_inv_natural {A B : Type*} (n : ℕ) (f : A →* B) :\n    Ω→[n + 1] f ∘* (loopn_succ_in A n)⁻¹ᵉ*.to_pmap ~* (loopn_succ_in B n)⁻¹ᵉ*.to_pmap ∘* Ω→[n] (Ω→ f):=\n  begin\n    apply pinv_right_phomotopy_of_phomotopy,\n    refine _ ⬝* (passoc _ _ _)⁻¹*,\n    apply phomotopy_pinv_left_of_phomotopy,\n    apply apn_succ_phomotopy_in\n  end\n\n  section psquare\n  /-\n    Squares of pointed maps\n\n    We treat expressions of the form\n      psquare f g h k :≡ k ∘* f ~* g ∘* h\n    as squares, where f is the top, g is the bottom, h is the left face and k is the right face.\n    Then we define various operations on squares\n  -/\n\n  variables {A' : Type*} {A₀₀ : Type*} {A₂₀ : Type*} {A₄₀ : Type*} \n            {A₀₂ : Type*} {A₂₂ : Type*} {A₄₂ : Type*} \n            {A₀₄ : Type*} {A₂₄ : Type*} {A₄₄ : Type*}\n            {f₁₀ f₁₀' : A₀₀ →* A₂₀} {f₃₀ : A₂₀ →* A₄₀}\n            {f₀₁ f₀₁' : A₀₀ →* A₀₂} {f₂₁ f₂₁' : A₂₀ →* A₂₂} {f₄₁ : A₄₀ →* A₄₂}\n            {f₁₂ f₁₂' : A₀₂ →* A₂₂} {f₃₂ : A₂₂ →* A₄₂}\n            {f₀₃ : A₀₂ →* A₀₄} {f₂₃ : A₂₂ →* A₂₄} {f₄₃ : A₄₂ →* A₄₄}\n            {f₁₄ : A₀₄ →* A₂₄} {f₃₄ : A₂₄ →* A₄₄}\n\n  @[hott, reducible] def psquare (f₁₀ : A₀₀ →* A₂₀) (f₁₂ : A₀₂ →* A₂₂)\n                                 (f₀₁ : A₀₀ →* A₀₂) (f₂₁ : A₂₀ →* A₂₂) : Type _ :=\n  f₂₁ ∘* f₁₀ ~* f₁₂ ∘* f₀₁\n\n  @[hott] def psquare_of_phomotopy (p : f₂₁ ∘* f₁₀ ~* f₁₂ ∘* f₀₁) : psquare f₁₀ f₁₂ f₀₁ f₂₁ :=\n  p\n\n  @[hott] def phomotopy_of_psquare (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) : f₂₁ ∘* f₁₀ ~* f₁₂ ∘* f₀₁ :=\n  p\n\n  @[hott] def phdeg_square {f f' : A →* A'} (p : f ~* f') : psquare (pid A) (pid A') f f' :=\n  pcompose_pid _ ⬝* p⁻¹* ⬝* (pid_pcompose _)⁻¹*\n  @[hott] def pvdeg_square {f f' : A →* A'} (p : f ~* f') : psquare f f' (pid A) (pid A') :=\n  pid_pcompose _ ⬝* p ⬝* (pcompose_pid _)⁻¹*\n\n  variables (f₀₁ f₁₀)\n  @[hott] def phrefl : psquare (pid A₀₀) (pid A₀₂) f₀₁ f₀₁ := phdeg_square phomotopy.rfl\n  @[hott] def pvrefl : psquare f₁₀ f₁₀ (pid A₀₀) (pid A₂₀) := pvdeg_square phomotopy.rfl\n  variables {f₀₁ f₁₀}\n  @[hott] def phrfl : psquare (pid A₀₀) (pid A₀₂) f₀₁ f₀₁ := phrefl f₀₁\n  @[hott] def pvrfl : psquare f₁₀ f₁₀ (pid A₀₀) (pid A₂₀) := pvrefl f₁₀\n\n  @[hott] def phconcat (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) (q : psquare f₃₀ f₃₂ f₂₁ f₄₁) :\n    psquare (f₃₀ ∘* f₁₀) (f₃₂ ∘* f₁₂) f₀₁ f₄₁ :=\n  (passoc _ _ _)⁻¹* ⬝* pwhisker_right f₁₀ q ⬝* passoc _ _ _ ⬝* pwhisker_left f₃₂ p ⬝* (passoc _ _ _)⁻¹*\n\n  @[hott] def pvconcat (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) (q : psquare f₁₂ f₁₄ f₀₃ f₂₃) :\n    psquare f₁₀ f₁₄ (f₀₃ ∘* f₀₁) (f₂₃ ∘* f₂₁) :=\n  passoc _ _ _ ⬝* pwhisker_left _ p ⬝* (passoc _ _ _)⁻¹* ⬝* pwhisker_right _ q ⬝* passoc _ _ _\n\n  @[hott] def phinverse {f₁₀ : A₀₀ ≃* A₂₀} {f₁₂ : A₀₂ ≃* A₂₂} \n    (p : psquare f₁₀.to_pmap f₁₂.to_pmap f₀₁ f₂₁) : \n    psquare f₁₀⁻¹ᵉ*.to_pmap f₁₂⁻¹ᵉ*.to_pmap f₂₁ f₀₁ :=\n  (pid_pcompose _)⁻¹* ⬝* pwhisker_right _ (pleft_inv f₁₂)⁻¹* ⬝* passoc _ _ _ ⬝*\n  pwhisker_left _\n    ((passoc _ _ _)⁻¹* ⬝* pwhisker_right _ p⁻¹* ⬝* passoc _ _ _ ⬝* pwhisker_left _ (pright_inv _) ⬝* (pcompose_pid _))\n\n  @[hott] def pvinverse {f₀₁ : A₀₀ ≃* A₀₂} {f₂₁ : A₂₀ ≃* A₂₂} \n    (p : psquare f₁₀ f₁₂ f₀₁.to_pmap f₂₁.to_pmap) : \n    psquare f₁₂ f₁₀ f₀₁⁻¹ᵉ*.to_pmap f₂₁⁻¹ᵉ*.to_pmap :=\n  (phinverse p⁻¹*)⁻¹*\n\n  @[hott] def phomotopy_hconcat (q : f₀₁' ~* f₀₁) (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) :\n    psquare f₁₀ f₁₂ f₀₁' f₂₁ :=\n  p ⬝* pwhisker_left f₁₂ q⁻¹*\n\n  @[hott] def hconcat_phomotopy (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) (q : f₂₁' ~* f₂₁) :\n    psquare f₁₀ f₁₂ f₀₁ f₂₁' :=\n  pwhisker_right f₁₀ q ⬝* p\n\n  @[hott] def phomotopy_vconcat (q : f₁₀' ~* f₁₀) (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) :\n    psquare f₁₀' f₁₂ f₀₁ f₂₁ :=\n  pwhisker_left f₂₁ q ⬝* p\n\n  @[hott] def vconcat_phomotopy (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) (q : f₁₂' ~* f₁₂) :\n    psquare f₁₀ f₁₂' f₀₁ f₂₁ :=\n  p ⬝* pwhisker_right f₀₁ q⁻¹*\n\n  infix ` ⬝h* `:73 := phconcat\n  infix ` ⬝v* `:73 := pvconcat\n  infixl ` ⬝hp* `:72 := hconcat_phomotopy\n  infixr ` ⬝ph* `:72 := phomotopy_hconcat\n  infixl ` ⬝vp* `:72 := vconcat_phomotopy\n  infixr ` ⬝pv* `:72 := phomotopy_vconcat\n  postfix `⁻¹ʰ*`:(max+1) := phinverse\n  postfix `⁻¹ᵛ*`:(max+1) := pvinverse\n\n  @[hott, hsimp] def ptranspose (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) : psquare f₀₁ f₂₁ f₁₀ f₁₂ :=\n  p⁻¹*\n\n  @[hott] def pwhisker_tl (f : A →* A₀₀) (q : psquare f₁₀ f₁₂ f₀₁ f₂₁) :\n    psquare (f₁₀ ∘* f) f₁₂ (f₀₁ ∘* f) f₂₁ :=\n  (passoc _ _ _)⁻¹* ⬝* pwhisker_right f q ⬝* passoc _ _ _\n\n  @[hott] def ap1_psquare (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) :\n    psquare (Ω→ f₁₀) (Ω→ f₁₂) (Ω→ f₀₁) (Ω→ f₂₁) :=\n  (ap1_pcompose _ _)⁻¹* ⬝* ap1_phomotopy p ⬝* ap1_pcompose _ _\n\n  @[hott] def apn_psquare (n : ℕ) (p : psquare f₁₀ f₁₂ f₀₁ f₂₁) :\n    psquare (Ω→[n] f₁₀) (Ω→[n] f₁₂) (Ω→[n] f₀₁) (Ω→[n] f₂₁) :=\n  (apn_pcompose _ _ _)⁻¹* ⬝* apn_phomotopy n p ⬝* apn_pcompose _ _ _\n\n  end psquare\n\nend pointed\nend hott\n", "meta": {"author": "gebner", "repo": "hott3", "sha": "7ead7a8a2503049eacd45cbff6587802bae2add2", "save_path": "github-repos/lean/gebner-hott3", "path": "github-repos/lean/gebner-hott3/hott3-7ead7a8a2503049eacd45cbff6587802bae2add2/src/hott/types/pointed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110202, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.49402351033764863}}
{"text": "import polyhedral_lattice.basic\nimport normed_group.pseudo_normed_group\nimport pseudo_normed_group.profinitely_filtered\n\nnoncomputable theory\nopen_locale nnreal big_operators\n\nnamespace polyhedral_lattice\n\nopen pseudo_normed_group normed_add_comm_group\n\nvariables (Λ : Type*) [polyhedral_lattice Λ]\n\nlemma filtration_finite (ε : ℝ≥0) : (filtration Λ ε).finite :=\nbegin\n  classical,\n  obtain ⟨ι, _ι_inst, l, hl, hl'⟩ := polyhedral_lattice.polyhedral Λ, resetI,\n  let n : ι → ℕ := λ i, ⌈(ε / ∥l i∥₊ : ℝ)⌉.nat_abs + 1,\n  let S := finset.univ.pi (λ i, finset.range (n i)),\n  let S' : finset Λ := S.image (λ x, ∑ i, x i (finset.mem_univ _) • l i),\n  apply S'.finite_to_set.subset,\n  intros l₀ H,\n  obtain ⟨c, h1, h2⟩ := hl.generates_nnnorm l₀,\n  simp only [S', set.mem_image, finset.mem_univ, finset.mem_pi, forall_true_left, finset.mem_range,\n    finset.mem_coe, finset.coe_image],\n  refine ⟨λ i _, c i, _, h1.symm⟩,\n  intro i,\n  apply nat.succ_le_succ,\n  contrapose! H,\n  simp only [not_le, seminormed_add_comm_group.mem_filtration_iff, h2],\n  have aux : 0 < ∥l i∥₊,\n  { rw [zero_lt_iff, ne.def, nnnorm_eq_zero], exact hl' i },\n  calc ε\n      ≤ (⌈(ε / ∥l i∥₊ : ℝ)⌉.nat_abs : ℝ≥0) * ∥l i∥₊ : _\n  ... < ↑(c i) * ∥l i∥₊ : _\n  ... ≤ ∑ (i : ι), ↑(c i) * ∥l i∥₊ : _,\n  { rw [← nnreal.div_le_iff aux.ne', ← nnreal.coe_le_coe],\n    simp only [coe_nnnorm, nnreal.coe_nat_abs, nnreal.coe_div],\n    refine (int.le_ceil _).trans (le_abs_self _), },\n  { rw mul_lt_mul_right aux,\n    { exact_mod_cast H }, },\n  { refine @finset.single_le_sum _ _ _ _ _ _ i (finset.mem_univ _),\n    exact λ _ _, zero_le', }\nend\n\nopen metric seminormed_add_comm_group\n\ninstance : discrete_topology Λ :=\ndiscrete_topology_of_open_singleton_zero $\nbegin\n  classical,\n  have aux := filtration_finite Λ 1,\n  let s := aux.to_finset,\n  let s₀ := s.erase 0,\n  by_cases hs₀ : s₀.nonempty,\n  { let ε : ℝ≥0 := finset.min' (s₀.image $ nnnorm) (hs₀.image _),\n    obtain ⟨a, has₀, ha⟩ : ∃ a ∈ s₀, ∥a∥₊ = ε,\n    { rw ← finset.mem_image, apply finset.min'_mem },\n    have H : 0 < ∥a∥ := by simpa only [norm_pos_iff] using finset.ne_of_mem_erase has₀,\n    have h0ε : 0 < ε, { simpa only [← ha] },\n    have hε1 : ε ≤ 1,\n    { replace has₀ := finset.mem_of_mem_erase has₀,\n      simp only [set.finite.mem_to_finset, mem_filtration_iff] at has₀,\n      rwa [← ha] },\n    suffices : ({0} : set Λ) = ball (0:Λ) ε,\n    { rw this, apply is_open_ball },\n    ext,\n    simp only [metric.mem_ball, set.mem_singleton_iff, dist_zero_right],\n    split,\n    { rintro rfl, rw norm_zero, exact_mod_cast h0ε },\n    intro h,\n    have hx : x ∈ s,\n    { simp only [set.finite.mem_to_finset, mem_filtration_iff],\n      exact le_of_lt (lt_of_lt_of_le h hε1) },\n    by_contra hx0,\n    replace hx := finset.mem_erase_of_ne_of_mem hx0 hx,\n    have := finset.min'_le (s₀.image $ nnnorm),\n    refine not_lt.2 (this ∥x∥₊ _) h,\n    simp only [exists_prop, set.finite.mem_to_finset, finset.mem_image],\n    use ⟨x, ⟨hx, rfl⟩⟩ },\n  { suffices : ({0} : set Λ) = ball (0:Λ) 1,\n    { rw this, apply is_open_ball },\n    ext,\n    simp only [metric.mem_ball, set.mem_singleton_iff, dist_zero_right],\n    split,\n    { rintro rfl, rw norm_zero, exact zero_lt_one },\n    intro h,\n    contrapose! hs₀,\n    refine ⟨x, _⟩,\n    simp only [set.finite.mem_to_finset, finset.mem_erase, mem_filtration_iff, nnreal.coe_one],\n    exact ⟨hs₀, h.le⟩ }\nend\n\ninstance filtration_fintype (c : ℝ≥0) : fintype (filtration Λ c) :=\n(filtration_finite Λ c).fintype\n\n-- we don't need this\ninstance : profinitely_filtered_pseudo_normed_group Λ :=\n{ compact := λ c, by apply_instance, -- compact of finite\n  continuous_add' := λ _ _, continuous_of_discrete_topology,\n  continuous_neg' := λ _, continuous_of_discrete_topology,\n  continuous_cast_le := λ _ _ _, continuous_of_discrete_topology,\n  .. (show pseudo_normed_group Λ, by apply_instance) }\n\nend polyhedral_lattice\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/polyhedral_lattice/topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.494023503935724}}
{"text": "import Mathlib.Logic.Basic\n\nnamespace Bool\n\nsection\n\ntheorem and_of_true {p q} (hp : p = true) (hq : q = true) : (p && q) = true\n:= hp.symm ▸ hq.symm ▸ rfl\n\ntheorem and_left : {p q : Bool} → (p && q) = true → p = true\n| true, _, _ => rfl\n| false, _, h => false_and _ ▸ h\n\ntheorem and_right : {p q : Bool} → (p && q) = true → q = true\n| _, true, _ => rfl\n| _, false, h => and_false _ ▸ h\n\nend\n\nend Bool\n\n\n-- section\n-- instance (p : Fin k → Prop) [Decidable (∀ k, ¬p k)] : Decidable (∃ k, p k) :=\n--   if h : ∀ k, ¬p k then isFalse $ not_exists.mpr h\n--   else isTrue $ let ⟨x, hx⟩ := not_forall.mp h; ⟨x, of_not_not hx⟩\n-- end", "meta": {"author": "michelsol", "repo": "lean-playground", "sha": "0bfffb7bd41729fb9f95974e93f6ecbc0b6e59ca", "save_path": "github-repos/lean/michelsol-lean-playground", "path": "github-repos/lean/michelsol-lean-playground/lean-playground-0bfffb7bd41729fb9f95974e93f6ecbc0b6e59ca/Playground/Data/Bool/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128673359709795, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.49394954202974345}}
{"text": "import graphs.definitions\n\ndef compose {G H K : graph} (β : H ↦ K) (α : G ↦ H) : G ↦ K :=\n  morphism.mk (β.vertex_map ∘ α.vertex_map) (β.edge_map ∘ α.edge_map) (by exact compatability α β)\n\ninfix `⊚`:80 := compose\n\nlemma mor_assoc {G H K L : graph} (α : G ↦ H) (β : H ↦ K) (γ : K ↦ L) : γ ⊚ (β ⊚ α) = (γ ⊚ β) ⊚ α :=\nbegin\n  refl,\nend", "meta": {"author": "barriecooper", "repo": "lean-graphs", "sha": "3f7be961f99fe084f950f52fe17c53e8093b5337", "save_path": "github-repos/lean/barriecooper-lean-graphs", "path": "github-repos/lean/barriecooper-lean-graphs/lean-graphs-3f7be961f99fe084f950f52fe17c53e8093b5337/src/graphs/composition.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.49390236053832887}}
{"text": "variables P Q R : Prop\n\nexample (HP : P) (HQ : Q) : P :=\nbegin\n  sorry,\nend\n\nexample (HP : P) (HPQ : P → Q) : Q :=\nbegin\n  sorry\nend\n\nexample (HQ : Q) : P → Q :=\nbegin\n  sorry,\nend\n\nexample : P → P :=\nbegin\n  sorry,\nend\n\nexample (HR : R) : P → (Q → R) :=\nbegin\n  sorry,\nend\n\nexample : true :=\nbegin\n  sorry\nend\n\nexample : false → false :=\nbegin\n  sorry\nend\n\nexample : P → ¬ (¬ P) :=\nbegin\n  sorry,\nend\n\nexample : ¬ ¬ P → P :=\nbegin\n  sorry\nend\n", "meta": {"author": "kbuzzard", "repo": "mathematics-in-lean", "sha": "3fad7bb7e888dabef94921101af8671b78a4304a", "save_path": "github-repos/lean/kbuzzard-mathematics-in-lean", "path": "github-repos/lean/kbuzzard-mathematics-in-lean/mathematics-in-lean-3fad7bb7e888dabef94921101af8671b78a4304a/src/Exercises/01_Propositions/ch01all.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.4938864730268784}}
{"text": "/-\nCopyright (c) 2022 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport probability.variance\nimport measure_theory.function.uniform_integrable\n\n/-!\n# Identically distributed random variables\n\nTwo random variables defined on two (possibly different) probability spaces but taking value in\nthe same space are *identically distributed* if their distributions (i.e., the image probability\nmeasures on the target space) coincide. We define this concept and establish its basic properties\nin this file.\n\n## Main definitions and results\n\n* `ident_distrib f g μ ν` registers that the image of `μ` under `f` coincides with the image of `ν`\n  under `g` (and that `f` and `g` are almost everywhere measurable, as otherwise the image measures\n  don't make sense). The measures can be kept implicit as in `ident_distrib f g` if the spaces\n  are registered as measure spaces.\n* `ident_distrib.comp`: being identically distributed is stable under composition with measurable\n  maps.\n\nThere are two main kind of lemmas, under the assumption that `f` and `g` are identically\ndistributed: lemmas saying that two quantities computed for `f` and `g` are the same, and lemmas\nsaying that if `f` has some property then `g` also has it. The first kind is registered as\n`ident_distrib.foo_eq`, the second one as `ident_distrib.foo_snd` (in the latter case, to deduce\na property of `f` from one of `g`, use `h.symm.foo_snd` where `h : ident_distrib f g μ ν`). For\ninstance:\n\n* `ident_distrib.measure_mem_eq`: if `f` and `g` are identically distributed, then the probabilities\n  that they belong to a given measurable set are the same.\n* `ident_distrib.integral_eq`: if `f` and `g` are identically distributed, then their integrals\n  are the same.\n* `ident_distrib.variance_eq`: if `f` and `g` are identically distributed, then their variances\n  are the same.\n\n* `ident_distrib.ae_strongly_measurable_snd`: if `f` and `g` are identically distributed and `f`\n  is almost everywhere strongly measurable, then so is `g`.\n* `ident_distrib.mem_ℒp_snd`: if `f` and `g` are identically distributed and `f`\n  belongs to `ℒp`, then so does `g`.\n\nWe also register several dot notation shortcuts for convenience.\nFor instance, if `h : ident_distrib f g μ ν`, then `h.sq` states that `f^2` and `g^2` are\nidentically distributed, and `h.norm` states that `‖f‖` and `‖g‖` are identically distributed, and\nso on.\n-/\n\nopen measure_theory filter finset\n\nnoncomputable theory\n\nopen_locale topology big_operators measure_theory ennreal nnreal\n\nvariables {α β γ δ : Type*} [measurable_space α] [measurable_space β]\n  [measurable_space γ] [measurable_space δ]\n\nnamespace probability_theory\n\n/-- Two functions defined on two (possibly different) measure spaces are identically distributed if\ntheir image measures coincide. This only makes sense when the functions are ae measurable\n(as otherwise the image measures are not defined), so we require this as well in the definition. -/\nstructure ident_distrib\n  (f : α → γ) (g : β → γ) (μ : measure α . volume_tac) (ν : measure β . volume_tac) : Prop :=\n(ae_measurable_fst : ae_measurable f μ)\n(ae_measurable_snd : ae_measurable g ν)\n(map_eq : measure.map f μ = measure.map g ν)\n\nnamespace ident_distrib\n\nopen topological_space\n\nvariables {μ : measure α} {ν : measure β} {f : α → γ} {g : β → γ}\n\nprotected lemma refl (hf : ae_measurable f μ) :\n  ident_distrib f f μ μ :=\n{ ae_measurable_fst := hf,\n  ae_measurable_snd := hf,\n  map_eq := rfl }\n\nprotected lemma symm (h : ident_distrib f g μ ν) : ident_distrib g f ν μ :=\n{ ae_measurable_fst := h.ae_measurable_snd,\n  ae_measurable_snd := h.ae_measurable_fst,\n  map_eq := h.map_eq.symm }\n\nprotected lemma trans {ρ : measure δ} {h : δ → γ}\n  (h₁ : ident_distrib f g μ ν) (h₂ : ident_distrib g h ν ρ) : ident_distrib f h μ ρ :=\n{ ae_measurable_fst := h₁.ae_measurable_fst,\n  ae_measurable_snd := h₂.ae_measurable_snd,\n  map_eq := h₁.map_eq.trans h₂.map_eq }\n\nprotected lemma comp_of_ae_measurable {u : γ → δ} (h : ident_distrib f g μ ν)\n  (hu : ae_measurable u (measure.map f μ)) :\n  ident_distrib (u ∘ f) (u ∘ g) μ ν :=\n{ ae_measurable_fst := hu.comp_ae_measurable h.ae_measurable_fst,\n  ae_measurable_snd :=\n    by { rw h.map_eq at hu, exact hu.comp_ae_measurable h.ae_measurable_snd },\n  map_eq :=\n  begin\n    rw [← ae_measurable.map_map_of_ae_measurable hu h.ae_measurable_fst,\n      ← ae_measurable.map_map_of_ae_measurable _ h.ae_measurable_snd, h.map_eq],\n    rwa ← h.map_eq,\n  end }\n\nprotected lemma comp {u : γ → δ} (h : ident_distrib f g μ ν) (hu : measurable u) :\n  ident_distrib (u ∘ f) (u ∘ g) μ ν :=\nh.comp_of_ae_measurable hu.ae_measurable\n\nprotected lemma of_ae_eq {g : α → γ} (hf : ae_measurable f μ) (heq : f =ᵐ[μ] g) :\n  ident_distrib f g μ μ :=\n{ ae_measurable_fst := hf,\n  ae_measurable_snd := hf.congr heq,\n  map_eq := measure.map_congr heq }\n\nlemma measure_mem_eq (h : ident_distrib f g μ ν) {s : set γ} (hs : measurable_set s) :\n  μ (f ⁻¹' s) = ν (g ⁻¹' s) :=\nby rw [← measure.map_apply_of_ae_measurable h.ae_measurable_fst hs,\n  ← measure.map_apply_of_ae_measurable h.ae_measurable_snd hs, h.map_eq]\n\nalias measure_mem_eq ← measure_preimage_eq\n\nlemma ae_snd (h : ident_distrib f g μ ν) {p : γ → Prop}\n  (pmeas : measurable_set {x | p x}) (hp : ∀ᵐ x ∂μ, p (f x)) :\n   ∀ᵐ x ∂ν, p (g x) :=\nbegin\n  apply (ae_map_iff h.ae_measurable_snd pmeas).1,\n  rw ← h.map_eq,\n  exact (ae_map_iff h.ae_measurable_fst pmeas).2 hp,\nend\n\nlemma ae_mem_snd (h : ident_distrib f g μ ν) {t : set γ}\n  (tmeas : measurable_set t) (ht : ∀ᵐ x ∂μ, f x ∈ t) :\n   ∀ᵐ x ∂ν, g x ∈ t :=\nh.ae_snd tmeas ht\n\n/-- In a second countable topology, the first function in an identically distributed pair is a.e.\nstrongly measurable. So is the second function, but use `h.symm.ae_strongly_measurable_fst` as\n`h.ae_strongly_measurable_snd` has a different meaning.-/\n\n\n/-- If `f` and `g` are identically distributed and `f` is a.e. strongly measurable, so is `g`. -/\nlemma ae_strongly_measurable_snd [topological_space γ] [metrizable_space γ] [borel_space γ]\n  (h : ident_distrib f g μ ν) (hf : ae_strongly_measurable f μ) :\n  ae_strongly_measurable g ν :=\nbegin\n  refine ae_strongly_measurable_iff_ae_measurable_separable.2 ⟨h.ae_measurable_snd, _⟩,\n  rcases (ae_strongly_measurable_iff_ae_measurable_separable.1 hf).2 with ⟨t, t_sep, ht⟩,\n  refine ⟨closure t, t_sep.closure, _⟩,\n  apply h.ae_mem_snd is_closed_closure.measurable_set,\n  filter_upwards [ht] with x hx using subset_closure hx,\nend\n\nlemma ae_strongly_measurable_iff [topological_space γ] [metrizable_space γ] [borel_space γ]\n  (h : ident_distrib f g μ ν) :\n  ae_strongly_measurable f μ ↔ ae_strongly_measurable g ν :=\n⟨λ hf, h.ae_strongly_measurable_snd hf, λ hg, h.symm.ae_strongly_measurable_snd hg⟩\n\nlemma ess_sup_eq [conditionally_complete_linear_order γ] [topological_space γ]\n  [opens_measurable_space γ] [order_closed_topology γ] (h : ident_distrib f g μ ν) :\n  ess_sup f μ = ess_sup g ν :=\nbegin\n  have I : ∀ a, μ {x : α | a < f x} = ν {x : β | a < g x} :=\n    λ a, h.measure_mem_eq measurable_set_Ioi,\n  simp_rw [ess_sup_eq_Inf, I],\nend\n\nlemma lintegral_eq {f : α → ℝ≥0∞} {g : β → ℝ≥0∞} (h : ident_distrib f g μ ν) :\n  ∫⁻ x, f x ∂μ = ∫⁻ x, g x ∂ν :=\nbegin\n  change ∫⁻ x, id (f x) ∂μ = ∫⁻ x, id (g x) ∂ν,\n  rw [← lintegral_map' ae_measurable_id h.ae_measurable_fst,\n      ← lintegral_map' ae_measurable_id h.ae_measurable_snd, h.map_eq],\nend\n\nlemma integral_eq [normed_add_comm_group γ] [normed_space ℝ γ] [complete_space γ] [borel_space γ]\n  (h : ident_distrib f g μ ν) : ∫ x, f x ∂μ = ∫ x, g x ∂ν :=\nbegin\n  by_cases hf : ae_strongly_measurable f μ,\n  { have A : ae_strongly_measurable id (measure.map f μ),\n    { rw ae_strongly_measurable_iff_ae_measurable_separable,\n      rcases (ae_strongly_measurable_iff_ae_measurable_separable.1 hf).2 with ⟨t, t_sep, ht⟩,\n      refine ⟨ae_measurable_id, ⟨closure t, t_sep.closure, _⟩⟩,\n      rw ae_map_iff h.ae_measurable_fst,\n      { filter_upwards [ht] with x hx using subset_closure hx },\n      { exact is_closed_closure.measurable_set } },\n    change ∫ x, id (f x) ∂μ = ∫ x, id (g x) ∂ν,\n    rw [← integral_map h.ae_measurable_fst A],\n    rw h.map_eq at A,\n    rw [← integral_map h.ae_measurable_snd A, h.map_eq] },\n  { rw integral_non_ae_strongly_measurable hf,\n    rw h.ae_strongly_measurable_iff at hf,\n    rw integral_non_ae_strongly_measurable hf }\nend\n\nlemma snorm_eq [normed_add_comm_group γ] [opens_measurable_space γ] (h : ident_distrib f g μ ν)\n  (p : ℝ≥0∞) :\n  snorm f p μ = snorm g p ν :=\nbegin\n  by_cases h0 : p = 0,\n  { simp [h0], },\n  by_cases h_top : p = ∞,\n  { simp only [h_top, snorm, snorm_ess_sup, ennreal.top_ne_zero, eq_self_iff_true, if_true,\n      if_false],\n    apply ess_sup_eq,\n    exact h.comp (measurable_coe_nnreal_ennreal.comp measurable_nnnorm) },\n  simp only [snorm_eq_snorm' h0 h_top, snorm', one_div],\n  congr' 1,\n  apply lintegral_eq,\n  exact h.comp\n    (measurable.pow_const (measurable_coe_nnreal_ennreal.comp measurable_nnnorm) p.to_real),\nend\n\nlemma mem_ℒp_snd [normed_add_comm_group γ] [borel_space γ]\n  {p : ℝ≥0∞} (h : ident_distrib f g μ ν) (hf : mem_ℒp f p μ) :\n  mem_ℒp g p ν :=\nbegin\n  refine ⟨h.ae_strongly_measurable_snd hf.ae_strongly_measurable, _⟩,\n  rw ← h.snorm_eq,\n  exact hf.2\nend\n\nlemma mem_ℒp_iff [normed_add_comm_group γ] [borel_space γ] {p : ℝ≥0∞} (h : ident_distrib f g μ ν) :\n  mem_ℒp f p μ ↔ mem_ℒp g p ν :=\n⟨λ hf, h.mem_ℒp_snd hf, λ hg, h.symm.mem_ℒp_snd hg⟩\n\nlemma integrable_snd [normed_add_comm_group γ] [borel_space γ] (h : ident_distrib f g μ ν)\n  (hf : integrable f μ) : integrable g ν :=\nbegin\n  rw ← mem_ℒp_one_iff_integrable at hf ⊢,\n  exact h.mem_ℒp_snd hf\nend\n\nlemma integrable_iff [normed_add_comm_group γ] [borel_space γ] (h : ident_distrib f g μ ν) :\n  integrable f μ ↔ integrable g ν :=\n⟨λ hf, h.integrable_snd hf, λ hg, h.symm.integrable_snd hg⟩\n\nprotected lemma norm [normed_add_comm_group γ] [borel_space γ] (h : ident_distrib f g μ ν) :\n  ident_distrib (λ x, ‖f x‖) (λ x, ‖g x‖) μ ν :=\nh.comp measurable_norm\n\nprotected lemma nnnorm [normed_add_comm_group γ] [borel_space γ] (h : ident_distrib f g μ ν) :\n  ident_distrib (λ x, ‖f x‖₊) (λ x, ‖g x‖₊) μ ν :=\nh.comp measurable_nnnorm\n\nprotected lemma pow [has_pow γ ℕ] [has_measurable_pow γ ℕ] (h : ident_distrib f g μ ν) {n : ℕ} :\n  ident_distrib (λ x, (f x) ^ n) (λ x, (g x) ^ n) μ ν :=\nh.comp (measurable_id.pow_const n)\n\nprotected lemma sq [has_pow γ ℕ] [has_measurable_pow γ ℕ] (h : ident_distrib f g μ ν) :\n  ident_distrib (λ x, (f x) ^ 2) (λ x, (g x) ^ 2) μ ν :=\nh.comp (measurable_id.pow_const 2)\n\nprotected lemma coe_nnreal_ennreal {f : α → ℝ≥0} {g : β → ℝ≥0} (h : ident_distrib f g μ ν) :\n  ident_distrib (λ x, (f x : ℝ≥0∞)) (λ x, (g x : ℝ≥0∞)) μ ν :=\nh.comp measurable_coe_nnreal_ennreal\n\n@[to_additive]\nlemma mul_const [has_mul γ] [has_measurable_mul γ] (h : ident_distrib f g μ ν) (c : γ) :\n  ident_distrib (λ x, f x * c) (λ x, g x * c) μ ν :=\nh.comp (measurable_mul_const c)\n\n@[to_additive]\nlemma const_mul [has_mul γ] [has_measurable_mul γ] (h : ident_distrib f g μ ν) (c : γ) :\n  ident_distrib (λ x, c * f x) (λ x, c * g x) μ ν :=\nh.comp (measurable_const_mul c)\n\n@[to_additive]\nlemma div_const [has_div γ] [has_measurable_div γ] (h : ident_distrib f g μ ν) (c : γ) :\n  ident_distrib (λ x, f x / c) (λ x, g x / c) μ ν :=\nh.comp (has_measurable_div.measurable_div_const c)\n\n@[to_additive]\nlemma const_div [has_div γ] [has_measurable_div γ] (h : ident_distrib f g μ ν) (c : γ) :\n  ident_distrib (λ x, c / f x) (λ x, c / g x) μ ν :=\nh.comp (has_measurable_div.measurable_const_div c)\n\nlemma evariance_eq {f : α → ℝ} {g : β → ℝ} (h : ident_distrib f g μ ν) :\n  evariance f μ = evariance g ν :=\nbegin\n  convert (h.sub_const (∫ x, f x ∂μ)).nnnorm.coe_nnreal_ennreal.sq.lintegral_eq,\n  rw h.integral_eq,\n  refl\nend\n\nlemma variance_eq {f : α → ℝ} {g : β → ℝ} (h : ident_distrib f g μ ν) :\n  variance f μ = variance g ν :=\nby { rw [variance, h.evariance_eq], refl, }\n\nend ident_distrib\n\nsection uniform_integrable\n\nopen topological_space\n\nvariables {E : Type*} [measurable_space E] [normed_add_comm_group E] [borel_space E]\n  [second_countable_topology E] {μ : measure α} [is_finite_measure μ]\n\n/-- This lemma is superceded by `mem_ℒp.uniform_integrable_of_ident_distrib` which only require\n`ae_strongly_measurable`. -/\nlemma mem_ℒp.uniform_integrable_of_ident_distrib_aux {ι : Type*} {f : ι → α → E}\n  {j : ι} {p : ℝ≥0∞} (hp : 1 ≤ p) (hp' : p ≠ ∞)\n  (hℒp : mem_ℒp (f j) p μ) (hfmeas : ∀ i, strongly_measurable (f i))\n  (hf : ∀ i, ident_distrib (f i) (f j) μ μ) :\n  uniform_integrable f p μ :=\nbegin\n  refine uniform_integrable_of' hp hp' hfmeas (λ ε hε, _),\n  by_cases hι : nonempty ι,\n  swap, { exact ⟨0, λ i, false.elim (hι $ nonempty.intro i)⟩ },\n  obtain ⟨C, hC₁, hC₂⟩ := hℒp.snorm_indicator_norm_ge_pos_le μ (hfmeas _) hε,\n  have hmeas : ∀ i, measurable_set {x | (⟨C, hC₁.le⟩ : ℝ≥0) ≤ ‖f i x‖₊} :=\n    λ i, measurable_set_le measurable_const (hfmeas _).measurable.nnnorm,\n  refine ⟨⟨C, hC₁.le⟩, λ i, le_trans (le_of_eq _) hC₂⟩,\n  have : {x : α | (⟨C, hC₁.le⟩ : ℝ≥0) ≤ ‖f i x‖₊}.indicator (f i) =\n    (λ x : E, if (⟨C, hC₁.le⟩ : ℝ≥0) ≤ ‖x‖₊ then x else 0) ∘ (f i),\n  { ext x,\n    simp only [set.indicator, set.mem_set_of_eq] },\n  simp_rw [coe_nnnorm, this],\n  rw [← snorm_map_measure _ (hf i).ae_measurable_fst, (hf i).map_eq,\n    snorm_map_measure _ (hf j).ae_measurable_fst],\n  { refl },\n  all_goals { exact ae_strongly_measurable_id.indicator\n      (measurable_set_le measurable_const measurable_nnnorm) },\nend\n\n/-- A sequence of identically distributed Lᵖ functions is p-uniformly integrable. -/\nlemma mem_ℒp.uniform_integrable_of_ident_distrib {ι : Type*} {f : ι → α → E}\n  {j : ι} {p : ℝ≥0∞} (hp : 1 ≤ p) (hp' : p ≠ ∞)\n  (hℒp : mem_ℒp (f j) p μ) (hf : ∀ i, ident_distrib (f i) (f j) μ μ) :\n  uniform_integrable f p μ :=\nbegin\n  have hfmeas : ∀ i, ae_strongly_measurable (f i) μ :=\n    λ i, (hf i).ae_strongly_measurable_iff.2 hℒp.1,\n  set g : ι → α → E := λ i, (hfmeas i).some,\n  have hgmeas : ∀ i, strongly_measurable (g i) := λ i, (Exists.some_spec $ hfmeas i).1,\n  have hgeq : ∀ i, g i =ᵐ[μ] f i := λ i, (Exists.some_spec $ hfmeas i).2.symm,\n  have hgℒp : mem_ℒp (g j) p μ := hℒp.ae_eq (hgeq j).symm,\n  exact uniform_integrable.ae_eq (mem_ℒp.uniform_integrable_of_ident_distrib_aux hp hp'\n    hgℒp hgmeas $\n    λ i, (ident_distrib.of_ae_eq (hgmeas i).ae_measurable (hgeq i)).trans ((hf i).trans\n      $ ident_distrib.of_ae_eq (hfmeas j).ae_measurable (hgeq j).symm)) hgeq,\nend\n\nend uniform_integrable\n\nend probability_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/probability/ident_distrib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.4938864605775915}}
{"text": "import tactic\n\ndef square {A B : Type*} (R : A → B → Prop) : Prop :=\n∀ x₁ x₂ y₁ y₂, R x₁ y₁ → R x₂ y₁ → R x₂ y₂ → R x₁ y₂\n\nstructure edge (X Y : Type) : Type :=\n( R : X → Y → Prop )\n( square : square R )\n\nnamespace edge\n\nvariables {X Y : Type}\n\ndef le : edge X Y → edge X Y → Prop :=\nλ e₁ e₂, ∃ (f : X → X) (g : Y → Y), ∀ x y, e₁.R (f x) y ↔ e₂.R x (g y)\n\ninstance : preorder (edge X Y) :=\n{ le := le,\n  le_refl := λ _, ⟨id, id, λ _ _, iff.rfl⟩,\n  le_trans := λ a b c ⟨f₁, g₁, h₁⟩ ⟨f₂, g₂, h₂⟩, \n    ⟨f₁ ∘ f₂, g₂ ∘ g₁, λ x y, (h₁ _ _).trans $ h₂ _ _⟩ }\n\ndef of_fun (f : X → Y) : edge X Y := \n{ R := λ x y, f x = y,\n  square := λ _ _ _ _, by cc }\n\nlemma maximal_of_fun (f : X → Y) (E : edge X Y) (h : of_fun f ≤ E) : \n  E ≤ of_fun f :=\nbegin\n  rcases h with ⟨a, b, h⟩,\n  \n  refine ⟨a, b, _⟩,\n  dsimp [of_fun] at *,\n\nend \n\n\nend edge", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/parametricity/pullback_partial_order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6224593382055109, "lm_q1q2_score": 0.4936762055009145}}
{"text": "import tactic\nopen classical\nlocal attribute [instance] prop_decidable\n\nstructure gamestate (α : Type) :=\n-- α represents the type of squares on the chessboard\n(left : α → α → Prop)\n(white_turn : Prop)\n(K : α → Prop)  -- Is the White king on this square?\n(k : α → Prop)  -- ...    Black ...\n(left_nonrefl : ∀ x y, left x y → x ≠ y)\n(left_trans : ∀ x y z, left x y ∧ left y z → left x z)\n(square_one_piece_K : ∀ x, K x → ¬ k x)\n(square_one_piece_k : ∀ x, k x → ¬ K x)\n\nvariables {α : Type} (G : gamestate α)\n\ndef adjleft (x y : α) := G.left x y ∧ (∀ z, ¬ G.left x z ∧ ¬ G.left z y)\n\n-- `can'_<color> x y` iff a piece on `x` can\n-- 1. reach `y`\n-- *or*\n-- 2. capture a different-colored piece on `y`\n-- *or*\n-- 3. protect a same-colored piece on `y`\ndef can'_white (x y : α) := G.K x ∧ (adjleft G x y ∨ adjleft G y x)\ndef can'_black (x y : α) := G.k x ∧ (adjleft G x y ∨ adjleft G y x)\ndef can' (x y : α) := (G.white_turn → can'_white G x y) ∧ (¬ G.white_turn → can'_black G x y)\n\n-- `can_<color> x y` iff only 1 and 2 from above hold\ndef can_white (x y : α) := G.K x ∧ ¬ G.K y ∧ (adjleft G x y ∨ adjleft G y x)\ndef can_black (x y : α) := G.k x ∧ ¬ G.k y ∧ (adjleft G x y ∨ adjleft G y x)\ndef can (x y : α) := (G.white_turn → can_white G x y) ∧ (¬ G.white_turn → can_black G x y)\n\ndef checked_white := ∃ (x y : α), G.K y ∧ can_black G x y\ndef checked_black := ∃ (x y : α), G.k y ∧ can_white G x y\ndef checked := (G.white_turn → checked_white G) ∧ (¬ G.white_turn → checked_black G)\ndef checking := (G.white_turn → checked_black G) ∧ (¬ G.white_turn → checked_white G)\n\ndef move (x y : α) (h : can G x y) : gamestate α :=\n{ left := G.left,\n  white_turn := ¬ G.white_turn,\n  -- Piece on source square always disappears on next move\n  -- Piece on target square only present if it was moved from\n  -- source square\n  K := λ z, ite (z = x) false\n    (ite (z = y) (G.K x) (G.K z)),\n  k := λ z, ite (z = x) false\n    (ite (z = y) (G.k x) (G.k z)),\n  left_nonrefl := G.left_nonrefl,\n  left_trans := G.left_trans,\n  -- Mindless case bashing lol\n  square_one_piece_K := begin\n    intros z h1,\n    by_contra h2,\n    by_cases h3 : z = x,\n      exfalso, rwa (if_pos h3) at h1,\n    by_cases h4 : z = y;\n    rw (if_neg h3) at h1,\n    { rw (if_pos h4) at h1,\n      rw [if_neg h3, if_pos h4] at h2,\n      exact (G.square_one_piece_K x h1) h2 },\n    rw (if_neg h4) at h1,\n    rw [if_neg h3, if_neg h4] at h2,\n    exact (G.square_one_piece_K z h1) h2\n  end,\n  square_one_piece_k := begin\n    intros z h1,\n    by_contra h2,\n    by_cases h3 : z = x,\n      exfalso, rwa (if_pos h3) at h1,\n    by_cases h4 : z = y;\n    rw (if_neg h3) at h1,\n    { rw (if_pos h4) at h1,\n      rw [if_neg h3, if_pos h4] at h2,\n      exact (G.square_one_piece_k x h1) h2 },\n    rw (if_neg h4) at h1,\n    rw [if_neg h3, if_neg h4] at h2,\n    exact (G.square_one_piece_k z h1) h2\n  end }\n\n-- legal moves don't leave the player in check\ndef legal (x y : α) (h : can G x y) := ¬ checking (move G x y h)\ndef got_can := ∃ (x y : α), can G x y\ndef got_legal := ∃ (x y : α) {h : can G x y}, legal G x y h\ndef stalemated := ¬ checked G ∧ (¬ got_can G ∨ ¬ got_legal G)\ndef checkmated := checked G ∧ (¬ got_can G ∨ ¬ got_legal G)\n\ndef winning : ℕ → gamestate α → Prop\n| 0 := λ G, ¬ G.white_turn ∧ checkmated G\n| (k+1) := λ G, ¬ stalemated G ∧ got_can G ∧\n  (¬ G.white_turn → ∀ (x y : α) {h : can G x y}, legal G x y h ∧ winning k (move G x y h)) ∧\n  (G.white_turn → ∃ (x y : α) (h : can G x y), legal G x y h ∧ winning k (move G x y h))\n\ndef losing : ℕ → gamestate α → Prop\n| 0 := λ G, G.white_turn ∧ checkmated G\n| (k+1) := λ G, ¬ stalemated G ∧ got_can G ∧\n  (G.white_turn → ∀ (x y : α) {h : can G x y}, legal G x y h ∧ losing k (move G x y h)) ∧\n  (¬ G.white_turn → ∃ (x y : α) (h : can G x y), legal G x y h ∧ losing k (move G x y h))\n\ndef draw := ∀ (k : ℕ), ¬ winning k G ∧ ¬ losing k G\n\n-- Some basic results\n-- When there is only one White/Black king on the board\nlemma left_of_adjleft {x y : α} (h : adjleft G x y) : G.left x y := h.left\nlemma check_of_checkmate (h : checkmated G) : checked G := h.left\n\ndef one_white_piece (x : α) := G.K x ∧ (∀ (z : α), G.K z → z = x)\ndef one_black_piece (x : α) := G.k x ∧ (∀ (z : α), G.k z → z = x)\n\nlemma adj_of_can {x y : α} (hcan : can G x y) : adjleft G x y ∨ adjleft G y x := begin\n  unfold can at hcan,\n  by_cases hwhite : G.white_turn,\n  { have h1 := hcan.left hwhite,\n    unfold can_white at h1,\n    exact h1.right.right },\n  have h1 := hcan.right hwhite,\n  unfold can_black at h1,\n  exact h1.right.right,\nend\n\nlemma neq_of_adj {x y : α} (h : adjleft G x y ∨ adjleft G y x) : x ≠ y := begin\n  cases h,\n    exact G.left_nonrefl _ _ h.left,\n  exact ne_comm.mp (G.left_nonrefl _ _ h.left),\nend\n\nlemma neq_of_can {x y : α} (hcan : can G x y) : x ≠ y := neq_of_adj G (adj_of_can G hcan)\n\nlemma K_of_move {x y : α} (hK : G.K x) (hcan : can G x y) :\n  (move G x y hcan).K y := begin\n  unfold move, dsimp,\n  rwa [if_neg _, if_pos _],\n    refl,\n  exact ne_comm.mp (neq_of_can G hcan),\nend\n\nlemma k_of_move {x y : α} (hk : G.k x) (hcan : can G x y) :\n  (move G x y hcan).k y := begin\n  unfold move, dsimp,\n  rwa [if_neg _, if_pos _],\n    refl,\n  exact ne_comm.mp (neq_of_can G hcan),\nend\n\nlemma K_of_move_2 {x y z : α} (hK : G.K x) (hk : G.k z) (hcan : can G x y)\n  (hxz : x ≠ z) (hyz : y ≠ z) : (move G x y hcan).k z := begin\n  unfold move, dsimp,\n  rwa [if_neg (ne_comm.mp hyz), if_neg (ne_comm.mp hxz)],\nend\n\nlemma k_of_move_2 {x y z : α} (hk : G.k x) (hK : G.K z) (hcan : can G x y)\n  (hxz : x ≠ z) (hyz : y ≠ z) : (move G x y hcan).K z := begin\n  unfold move, dsimp,\n  rwa [if_neg (ne_comm.mp hyz), if_neg (ne_comm.mp hxz)],\nend\n\n-- Making a move preserves the number of pieces of your color\nlemma one_white_piece_preserved_1 {x y : α} (hone : one_white_piece G x) (hcan : can G x y) :\n  one_white_piece (move G x y hcan) y := begin\n  unfold one_white_piece,\n  split,\n    exact K_of_move G hone.left hcan,\n  intros z hz,\n  unfold move at hz, dsimp at hz,\n  have hzx : z ≠ x := λ h, by rwa (if_pos h) at hz,\n  by_contra h,\n  rw [if_neg hzx, if_neg h] at hz,\n  exact hzx (hone.right z hz),\nend\n\nlemma one_black_piece_preserved_1 {x y : α} (hone : one_black_piece G x) (hcan : can G x y) :\n  one_black_piece (move G x y hcan) y := begin\n  unfold one_black_piece,\n  split,\n    exact k_of_move G hone.left hcan,\n  intros z hz,\n  unfold move at hz, dsimp at hz,\n  have hzx : z ≠ x := λ h, by rwa (if_pos h) at hz,\n  by_contra h,\n  rw [if_neg hzx, if_neg h] at hz,\n  exact hzx (hone.right z hz),\nend\n\n-- Non-capturing moves by the opponent preserve the number of pieces of your color\nlemma one_white_piece_preserved_2 {x y z : α} (hblack : ¬ G.white_turn) (hone : one_white_piece G z)\n  (hcan : can G x y) (hyz : y ≠ z) :\n  one_white_piece (move G x y hcan) z := begin\n  unfold one_white_piece,\n  split,\n  { unfold move, dsimp,\n    by_cases hxz : x = z,\n    { subst hxz,\n      rw (if_pos rfl),\n      have hkx := (hcan.right hblack).left,\n      exact G.square_one_piece_K x hone.left hkx },\n    rw [if_neg (ne_comm.mp hxz), if_neg (ne_comm.mp hyz)],\n    exact hone.left },\n  intros w hw,\n  unfold move at hw, dsimp at hw,\n  rw [if_neg _, if_neg _] at hw,\n  exact hone.right w hw,\n  { by_contra h1,\n    rw (if_pos h1) at hw,\n    have h2 := (hcan.right hblack).left,\n    exact G.square_one_piece_K x hw h2 },\n  by_contra h1,\n  rwa (if_pos h1) at hw,\nend\n\nlemma one_black_piece_preserved_2 {x y z : α} (hwhite : G.white_turn) (hone : one_black_piece G z)\n  (hcan : can G x y) (hyz : y ≠ z) :\n  one_black_piece (move G x y hcan) z := begin\n  unfold one_black_piece,\n  split,\n  { unfold move, dsimp,\n    by_cases hxz : x = z,\n    { subst hxz,\n      rw (if_pos rfl),\n      have hkx := (hcan.left hwhite).left,\n      exact G.square_one_piece_k x hone.left hkx },\n    rw [if_neg (ne_comm.mp hxz), if_neg (ne_comm.mp hyz)],\n    exact hone.left },\n  intros w hw,\n  unfold move at hw, dsimp at hw,\n  rw [if_neg _, if_neg _] at hw,\n  exact hone.right w hw,\n  { by_contra h1,\n    rw (if_pos h1) at hw,\n    have h2 := (hcan.left hwhite).left,\n    exact G.square_one_piece_k x hw h2 },\n  by_contra h1,\n  rwa (if_pos h1) at hw,\nend\n\nlemma adj_of_move {x y : α} (hcan : can G x y) : adjleft G x y ∨ adjleft G y x := begin\n  by_cases hwhite : G.white_turn,\n    exact (hcan.left hwhite).right.right,\n  exact (hcan.right hwhite).right.right,\nend\n\n-- Define a `KvK position` to be a position with only one non-adjacent White and Black king\n-- I show that KvK positions are draws\ndef KvK := ∃ (x y : α), one_white_piece G x ∧ one_black_piece G y ∧ ¬ adjleft G x y ∧ ¬ adjleft G y x\n\n-- 1. A KvK position is a check for neither player\nlemma KvK_no_check (h : KvK G) : ¬ checked G :=\nbegin\n  unfold checked,\n  simp only [not_and_distrib, not_not, not_imp],\n  by_cases hturn : G.white_turn,\n  { left, split,\n      assumption,\n    unfold checked_white,\n    simp only [not_exists, not_and_distrib],\n    intros y x,\n\n    by_cases hK : G.K x, swap,\n      left, assumption,\n    right,\n    unfold can_black,\n    simp only [not_and_distrib, not_not, not_or_distrib],\n    \n    by_cases hk : G.k y, swap,\n      left, assumption,\n    right, right,\n    rcases h with ⟨x', y', hx', hy', hnotadj⟩,\n    rw and_comm at hnotadj,\n    convert hnotadj,\n    repeat { exact hy'.right y hk <|> exact hx'.right x hK } },\n\n  -- The same thing\n  right, split,\n    assumption,\n  unfold checked_black,\n  simp only [not_exists, not_and_distrib],\n  intros x y,\n\n  by_cases hk : G.k y, swap,\n    left, assumption,\n  right,\n  unfold can_white,\n  simp only [not_and_distrib, not_not, not_or_distrib],\n  \n  by_cases hK : G.K x, swap,\n    left, assumption,\n  right, right,\n  rcases h with ⟨x', y', hx', hy', hnotadj⟩,\n  convert hnotadj,\n  repeat { exact hy'.right y hk <|> exact hx'.right x hK },\nend\n\n-- 2. Legal moves preserve KvK positions\nlemma KvK_preserved {x y : α} (hG : KvK G) (hcan : can G x y) (hlegal : legal G x y hcan) :\n  KvK (move G x y hcan) :=\nbegin\n  rcases hG with ⟨x1, x2, hx1, hx2, hnotadj⟩,\n  unfold KvK,\n  by_cases hwhite : G.white_turn,\n  { have : x = x1 := hx1.right x (hcan.left hwhite).left,\n    subst this,\n\n    have hy_x2 : y ≠ x2 := begin\n      by_contra h, subst h,\n      apply not_or_distrib.mpr hnotadj,\n      exact adj_of_move G hcan,\n    end,\n\n    use [y, x2],\n    split,\n    { apply one_white_piece_preserved_1,\n      convert hx1 },\n    split,\n    { apply one_black_piece_preserved_2,\n      repeat { assumption } },\n\n    let G' := move G x y hcan,\n    -- Expanding the monstrous expression out\n    rename hlegal h1,\n    unfold legal checking checked_white checked_black can_white can_black at h1,\n    simp only [not_and_distrib, not_imp, not_not] at h1,\n    cases h1,\n      exact false.elim (not_not.mpr hwhite h1.left),\n    replace h1 := h1.right,\n    simp only [not_exists, not_and_distrib, not_not, not_or_distrib] at h1,\n    replace h1 := h1 x2 y,\n    cases h1,\n      exact false.elim (h1 (K_of_move G hx1.left hcan)),\n    cases h1,\n    { refine false.elim (h1 (K_of_move_2 G hx1.left hx2.left hcan _ hy_x2)),\n      by_contra h2,\n      subst h2,\n      exact (G.square_one_piece_K x hx1.left) hx2.left },\n    cases h1,\n    { refine false.elim ((G'.square_one_piece_K y _) h1),\n      apply K_of_move G hx1.left },\n    rwa and_comm },\n\n  -- EXACT SAME THING\n  have : x = x2 := hx2.right x (hcan.right hwhite).left,\n  subst this,\n\n  have hy_x2 : y ≠ x1 := begin\n    by_contra h, subst h,\n    apply not_or_distrib.mpr hnotadj,\n    rw or_comm,\n    exact adj_of_move G hcan,\n  end,\n\n  use [x1, y],\n  split,\n  { apply one_white_piece_preserved_2,\n    repeat { assumption } },\n  split,\n  { apply one_black_piece_preserved_1,\n    assumption },\n\n  let G' := move G x y hcan,\n  have : G'.white_turn := hwhite,\n  -- Expanding the monstrous expression out\n  rename hlegal h1,\n  unfold legal checking checked_white checked_black can_white can_black at h1,\n  simp only [not_and_distrib, not_imp, not_not] at h1,\n  cases h1, swap,\n    exact false.elim (h1.left this),\n  replace h1 := h1.right,\n  simp only [not_exists, not_and_distrib, not_not, not_or_distrib] at h1,\n  replace h1 := h1 x1 y,\n  cases h1,\n    exact false.elim (h1 (k_of_move G hx2.left hcan)),\n  cases h1,\n  { refine false.elim (h1 (k_of_move_2 G hx2.left hx1.left hcan _ hy_x2)),\n    by_contra h2,\n    subst h2,\n    exact (G.square_one_piece_K x hx1.left) hx2.left },\n  cases h1,\n  { refine false.elim ((G'.square_one_piece_k y _) h1),\n    apply k_of_move G hx2.left },\n  assumption,\nend\n\n-- The main result\ntheorem KvK_draw (h : KvK G) : draw G := begin\n  unfold draw, intro k, revert G,\n  induction k with k hk; intros G hG,\n  { split,\n    { unfold winning,\n      rw [not_and_distrib, not_not],\n      right,\n      exact (λ h, (KvK_no_check G hG) (check_of_checkmate G h)) },\n    unfold losing,\n    rw not_and_distrib,\n    right,\n    exact (λ h, (KvK_no_check G hG) (check_of_checkmate G h)) },\n\n  split,\n  { unfold winning,\n    simp only [not_and_distrib, not_not, not_imp, not_forall, not_exists],\n    by_cases h1 : stalemated G,\n      left, assumption,\n    right,\n\n    by_cases h2 : G.white_turn,\n    { right, right,\n      use h2,\n      intros x y hcan,\n      by_cases h3 : legal G x y _, swap,\n        left, assumption,\n      right,\n      let G' := move G x y _,\n      exact (hk G' (KvK_preserved G hG hcan h3)).left },\n\n    by_cases h3 : got_can G, swap,\n      left, assumption, \n    right, left,\n    rcases h3 with ⟨x, y, hxy⟩,\n    use [h2, x, y, hxy],\n\n    by_cases h4 : legal G x y _, swap,\n      left, assumption,\n    right,\n    let G' := move G x y _,\n    exact (hk G' (KvK_preserved G hG hxy h4)).left, },\n\n  -- The exact same thing but replace `winning` with `losing`\n  unfold losing,\n  simp only [not_and_distrib, not_not, not_imp, not_forall, not_exists],\n  by_cases h1 : stalemated G,\n    left, assumption,\n  right,\n\n  by_cases h2 : G.white_turn, swap,\n  { right, right,\n    use h2,\n    intros x y hcan,\n    by_cases h3 : legal G x y _, swap,\n      left, assumption,\n    right,\n    let G' := move G x y _,\n    exact (hk G' (KvK_preserved G hG hcan h3)).right },\n\n  by_cases h3 : got_can G, swap,\n    left, assumption, \n  right, left,\n  rcases h3 with ⟨x, y, hxy⟩,\n  use [h2, x, y, hxy],\n\n  by_cases h4 : legal G x y _, swap,\n    left, assumption,\n  right,\n  let G' := move G x y _,\n  exact (hk G' (KvK_preserved G hG hxy h4)).right\nend", "meta": {"author": "greysome", "repo": "lean-practice", "sha": "00729df4b18a2538cd3f63f68ab9c59308e3a6c2", "save_path": "github-repos/lean/greysome-lean-practice", "path": "github-repos/lean/greysome-lean-practice/lean-practice-00729df4b18a2538cd3f63f68ab9c59308e3a6c2/src/old/chess.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4936761999462731}}
{"text": "constants p q : Prop\n\ntheorem t1 : p → q → p := λ hp : p, λ hq : q, hp\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0201.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.49367619385833394}}
{"text": "import SciLean.Quot.Basic\n\nnamespace SciLean.Quot'\n\n  class QForm {α} (S : Rel α) where\n    RedForm  : α → Prop \n    NormForm : α → Prop\n    norm_red : ∀ x, NormForm x → RedForm x\n    norm_eq  : ∀ x y, S x y → NormForm x → NormForm y → x = y\n\n  open QForm\n\n  class IsQHomR (S : Rel α) (R : Rel β) [QForm S] [QForm R] (f : α → β) extends IsQHom S R f where\n    preserve_red : ∀ x : α, RedForm S x → RedForm R (f x)\n\n  class IsQHomN (S : Rel α) (R : Rel β) [QForm S] [QForm R] (f : α → β) extends IsQHomR S R f where\n    preserve_norm : ∀ x : α, NormForm S x → NormForm R (f x)\n\n  ---\n  \n  class QReduce {α} (S : Rel α) [QForm S] where\n    reduce : α → α\n    is_reduce : ∀ x, RedForm S (reduce x)\n    eq_reduce : ∀ x, ⟦x, S⟧ = ⟦reduce x⟧\n    preserve_norm : ∀ x, NormForm S x → NormForm S (reduce x)\n\n  class Reduce (α) where\n    reduce : α → α\n    id_reduce : ∀ x : α, reduce x = x\n\n  ---\n  \n  class QNormalize {α} (S : Rel α) [QForm S] where\n    normalize : α → α\n    is_normalize : ∀ x, NormForm S (normalize x)\n    eq_normalize : ∀ x, ⟦x, S⟧ = ⟦normalize x⟧\n\n  class Normalize (α) where\n    normalize : α → α\n    id_normalize : ∀ x : α, normalize x = x\n\n  ---\n\n  -- This just tags `Repr` in which form they are\n  inductive QRepr {α} (S : Rel α) [QForm S] where\n    | raw  (x : α) : QRepr S\n    | red  (x : α) (h : RedForm S x)  : QRepr S\n    | norm (x : α) (h : NormForm S x) : QRepr S\n\n  namespace QRepr \n\n    variable {α} {S : Rel α} [QForm S]\n\n    def repr (x : QRepr S) : α :=\n      match x with\n      | raw  x   => x\n      | red  x _ => x\n      | norm x _ => x\n\n    @[simp]\n    theorem raw_repr (x : α) : (raw x : QRepr S).repr = x := by simp[repr] done\n\n    @[simp]\n    theorem red_repr (x : α) (h : RedForm S x) : (red x h : QRepr S).repr = x := by simp[repr] done\n\n    @[simp]\n    theorem norm_repr (x : α) (h : NormForm S x) : (norm x h : QRepr S).repr = x := by simp[repr] done\n\n    def isReduced (x : QRepr S) : Bool :=\n      match x with\n      | raw x => false\n      | _ => true\n\n    def isNormalized (x : QRepr S) : Bool :=\n      match x with\n      | norm x _ => true\n      | _ => false\n\n    -- variable {Repr' } {R'  : Repr'  → Repr'  → Prop} [Symbolic R']\n    -- variable {Repr''} {R'' : Repr'' → Repr'' → Prop} [Symbolic R'']\n\n    -- def lift (f : Repr → Repr') (x : QRepr R) : QRepr R' := raw (f x.repr)\n\n    -- def lift₂ (f : Repr → Repr' → Repr'') (x : QRepr R) (x' : QRepr R') : QRepr R'' :=\n    --   raw (f x.repr x'.repr)\n\n    -- def liftHom (f : Repr → Repr') (h : SHom R R' f) (x : QRepr R) : QRepr R' := \n    --   match x with\n    --   | raw x => raw (f x)\n    --   | red  x h' => red  (f x) (h.preserve_red x h')\n    --   | norm x h' => norm (f x) (h.preserve_norm x h')\n\n    -- @[simp] \n    -- theorem lift_hom_repr (f : Repr → Repr') (h : SHom R R' f) (x : QRepr R)\n    --   : (liftHom f h x).repr = f x.repr\n    --   := \n    --   by induction x \n    --      repeat simp[liftHom]\n    --      done\n\n    -- def liftHom₂ (f : Repr → Repr' → Repr'') (h : SHom₂ R R' R'' f) \n    --   (x : QRepr R) (y : QRepr R') : QRepr R'' :=\n    --   match x, y with\n    --   | red x hx,  red y hy  => red  (f x y) (h.preserve_red  x y hx hy)\n    --   | norm x hx, norm y hy => norm (f x y) (h.preserve_norm x y hx hy)\n    --   | x, y => raw (f x.repr y.repr)\n\n    def reduce (x : QRepr S) [QReduce S] : QRepr S :=\n      match x with\n      | raw x => red (QReduce.reduce S x) (QReduce.is_reduce x)\n      | x => x\n\n    def normalize (x : QRepr S) [QNormalize S] : QRepr S :=\n      match x with\n      | raw x   => norm (QNormalize.normalize S x) (QNormalize.is_normalize x)\n      | red x _ => norm (QNormalize.normalize S x) (QNormalize.is_normalize x)\n      | x => x\n\n  end QRepr\n\nend Quot'\n\nopen Quot' in\ndef Quot' {α} (S : Rel α) [QForm S]\n  := Quot (λ x y : QRepr S => S x.repr y.repr)\n\nnamespace Quot'\n\n  variable {α} {S : Rel α} [QForm S]\n\n  -- Normalized representant is unique, follows from `QForm.norm_eq`\n  def nrepr [QNormalize S] : Quot' S → α := Quot.lift (λ x => x.normalize.repr) sorry\n\n  noncomputable\n  def srepr (x : Quot' S) : QRepr S := x.repr\n\n  noncomputable\n  def repr (x : Quot' S) : α := x.srepr.repr\n\n  variable (x : Quot' S)\n\n  #check x.repr\n  #check x.srepr\n\nend Quot'\n\n  \n\n\n  -- TODO:\n  ---  QNormalize -> Normalize\n  ---  QNormalize -> DecidableEq\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Quot/SQuot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4936656038168806}}
{"text": "/-\nCopyright (c) 2021 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module tactic.by_contra\n! leanprover-community/mathlib commit 770703645cbd2f8d0e96743527f9ca57e7b9b63d\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.Core\nimport Mathbin.Tactic.PushNeg\n\n/-!\n# by_contra'\n\n`by_contra'` is a tactic for proving propositions by contradiction.\nIt is similar to `by_contra` except that it also uses `push_neg` to normalize negations.\n-/\n\n\nnamespace Tactic\n\nnamespace Interactive\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `parser.optional -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `parser.optional -/\n/-- If the target of the main goal is a proposition `p`,\n`by_contra'` reduces the goal to proving `false` using the additional hypothesis `h : ¬ p`.\n`by_contra' h` can be used to name the hypothesis `h : ¬ p`.\nThe hypothesis `¬ p` will be negation normalized using `push_neg`.\nFor instance, `¬ a < b` will be changed to `b ≤ a`.\n`by_contra' h : q` will normalize negations in `¬ p`, normalize negations in `q`,\nand then check that the two normalized forms are equal.\nThe resulting hypothesis is the pre-normalized form, `q`.\n\nIf the name `h` is not explicitly provided, then `this` will be used as name.\n\nThis tactic uses classical reasoning.\nIt is a variant on the tactic `by_contra` (`tactic.interactive.by_contra`).\n\nExamples:\n\n```lean\nexample : 1 < 2 :=\nbegin\n  by_contra' h,\n  -- h : 2 ≤ 1 ⊢ false\nend\n\nexample : 1 < 2 :=\nbegin\n  by_contra' h : ¬ 1 < 2,\n  -- h : ¬ 1 < 2 ⊢ false\nend\n```\n-/\nunsafe def by_contra' (h : parse (parser.optional ident))\n    (t : parse (parser.optional (tk \":\" *> texpr))) : tactic Unit := do\n  let h := h.getD `this\n  let tgt ← target\n  mk_mapp `classical.by_contradiction [some tgt] >>= tactic.eapply\n  let h₁ ← tactic.intro h\n  let t' ← infer_type h₁\n  let-- negation-normalize `t'` to the expression `e'` and get a proof `pr'` of `t' = e'`\n    (e', pr')\n    ← push_neg.normalize_negations t' <|> refl_conv t'\n  match t with\n    | none => () <$ replace_hyp h₁ e' pr'\n    | some t => do\n      let t ← to_expr ``(($(t) : Prop))\n      let-- negation-normalize `t` to the expression `e` and get a proof `pr` of `t = e`\n        (e, pr)\n        ← push_neg.normalize_negations t <|> refl_conv t\n      unify e e'\n      () <$ (mk_eq_symm pr >>= mk_eq_trans pr' >>= replace_hyp h₁ t)\n#align tactic.interactive.by_contra' tactic.interactive.by_contra'\n\nadd_tactic_doc\n  { Name := \"by_contra'\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.by_contra']\n    tags := [\"logic\"] }\n\nend Interactive\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/ByContra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6442251064863698, "lm_q1q2_score": 0.4936656038168806}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module data.dfinsupp.interval\n! leanprover-community/mathlib commit b6da1a0b3e7cd83b1f744c49ce48ef8c6307d2f6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.LocallyFinite\nimport Mathbin.Data.Finset.Pointwise\nimport Mathbin.Data.Fintype.BigOperators\nimport Mathbin.Data.Dfinsupp.Order\n\n/-!\n# Finite intervals of finitely supported functions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides the `locally_finite_order` instance for `Π₀ i, α i` when `α` itself is locally\nfinite and calculates the cardinality of its finite intervals.\n-/\n\n\nopen Dfinsupp Finset\n\nopen BigOperators Pointwise\n\nvariable {ι : Type _} {α : ι → Type _}\n\nnamespace Finset\n\nvariable [DecidableEq ι] [∀ i, Zero (α i)] {s : Finset ι} {f : Π₀ i, α i} {t : ∀ i, Finset (α i)}\n\n#print Finset.dfinsupp /-\n/-- Finitely supported product of finsets. -/\ndef dfinsupp (s : Finset ι) (t : ∀ i, Finset (α i)) : Finset (Π₀ i, α i) :=\n  (s.pi t).map\n    ⟨fun f => Dfinsupp.mk s fun i => f i i.2,\n      by\n      refine' (mk_injective _).comp fun f g h => _\n      ext (i hi)\n      convert congr_fun h ⟨i, hi⟩⟩\n#align finset.dfinsupp Finset.dfinsupp\n-/\n\n/- warning: finset.card_dfinsupp -> Finset.card_dfinsupp is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), Zero.{u2} (α i)] (s : Finset.{u1} ι) (t : forall (i : ι), Finset.{u2} (α i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (Finset.dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) s t)) (Finset.prod.{0, u1} Nat ι Nat.commMonoid s (fun (i : ι) => Finset.card.{u2} (α i) (t i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), Zero.{u1} (α i)] (s : Finset.{u2} ι) (t : forall (i : ι), Finset.{u1} (α i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (Finset.dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) s t)) (Finset.prod.{0, u2} Nat ι Nat.commMonoid s (fun (i : ι) => Finset.card.{u1} (α i) (t i)))\nCase conversion may be inaccurate. Consider using '#align finset.card_dfinsupp Finset.card_dfinsuppₓ'. -/\n@[simp]\ntheorem card_dfinsupp (s : Finset ι) (t : ∀ i, Finset (α i)) :\n    (s.Dfinsupp t).card = ∏ i in s, (t i).card :=\n  (card_map _).trans <| card_pi _ _\n#align finset.card_dfinsupp Finset.card_dfinsupp\n\nvariable [∀ i, DecidableEq (α i)]\n\n/- warning: finset.mem_dfinsupp_iff -> Finset.mem_dfinsupp_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), Zero.{u2} (α i)] {s : Finset.{u1} ι} {f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)} {t : forall (i : ι), Finset.{u2} (α i)} [_inst_3 : forall (i : ι), DecidableEq.{succ u2} (α i)], Iff (Membership.Mem.{max u1 u2, max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) (Finset.hasMem.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) f (Finset.dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) s t)) (And (HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_3 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_2 i))))) f) s) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Membership.Mem.{u2, u2} (α i) (Finset.{u2} (α i)) (Finset.hasMem.{u2} (α i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) f i) (t i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), Zero.{u1} (α i)] {s : Finset.{u2} ι} {f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)} {t : forall (i : ι), Finset.{u1} (α i)} [_inst_3 : forall (i : ι), DecidableEq.{succ u1} (α i)], Iff (Membership.mem.{max u2 u1, max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) (Finset.instMembershipFinset.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) f (Finset.dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) s t)) (And (HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_2 i)))) (_inst_3 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_2 i))))) f) s) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Membership.mem.{u1, u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (Finset.{u1} (α i)) (Finset.instMembershipFinset.{u1} (α i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_2 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_2 i) i)) f i) (t i))))\nCase conversion may be inaccurate. Consider using '#align finset.mem_dfinsupp_iff Finset.mem_dfinsupp_iffₓ'. -/\ntheorem mem_dfinsupp_iff : f ∈ s.Dfinsupp t ↔ f.support ⊆ s ∧ ∀ i ∈ s, f i ∈ t i :=\n  by\n  refine' mem_map.trans ⟨_, _⟩\n  · rintro ⟨f, hf, rfl⟩\n    refine' ⟨support_mk_subset, fun i hi => _⟩\n    convert mem_pi.1 hf i hi\n    exact mk_of_mem hi\n  · refine' fun h => ⟨fun i _ => f i, mem_pi.2 h.2, _⟩\n    ext i\n    dsimp\n    exact ite_eq_left_iff.2 fun hi => (not_mem_support_iff.1 fun H => hi <| h.1 H).symm\n#align finset.mem_dfinsupp_iff Finset.mem_dfinsupp_iff\n\n/- warning: finset.mem_dfinsupp_iff_of_support_subset -> Finset.mem_dfinsupp_iff_of_support_subset is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), Zero.{u2} (α i)] {s : Finset.{u1} ι} {f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)} [_inst_3 : forall (i : ι), DecidableEq.{succ u2} (α i)] {t : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i))}, (HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i)) (fun (i : ι) (x : Finset.{u2} (α i)) => Ne.decidable.{succ u2} (Finset.{u2} (α i)) (fun (a : Finset.{u2} (α i)) (b : Finset.{u2} (α i)) => Finset.decidableEq.{u2} (α i) (fun (a : α i) (b : α i) => _inst_3 i a b) a b) x (OfNat.ofNat.{u2} (Finset.{u2} (α i)) 0 (OfNat.mk.{u2} (Finset.{u2} (α i)) 0 (Zero.zero.{u2} (Finset.{u2} (α i)) (Finset.zero.{u2} (α i) (_inst_2 i)))))) t) s) -> (Iff (Membership.Mem.{max u1 u2, max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) (Finset.hasMem.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) f (Finset.dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) s (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i))) => forall (i : ι), Finset.{u2} (α i)) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i))) t))) (forall (i : ι), Membership.Mem.{u2, u2} (α i) (Finset.{u2} (α i)) (Finset.hasMem.{u2} (α i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i))) => forall (i : ι), Finset.{u2} (α i)) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_2 i))) t i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), Zero.{u1} (α i)] {s : Finset.{u2} ι} {f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)} [_inst_3 : forall (i : ι), DecidableEq.{succ u1} (α i)] {t : Dfinsupp.{u2, u1} ι (fun (i : ι) => Finset.{u1} (α i)) (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_2 i))}, (HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => Finset.{u1} (α i)) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_2 i)) (fun (i : ι) (x : Finset.{u1} (α i)) => instDecidableNot (Eq.{succ u1} (Finset.{u1} (α i)) x (OfNat.ofNat.{u1} (Finset.{u1} (α i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (α i)) (Finset.zero.{u1} (α i) (_inst_2 i))))) (Finset.decidableEq.{u1} (α i) ((fun (i : ι) (a : α i) (b : α i) => _inst_3 i a b) i) x (OfNat.ofNat.{u1} (Finset.{u1} (α i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (α i)) (Finset.zero.{u1} (α i) (_inst_2 i)))))) t) s) -> (Iff (Membership.mem.{max u2 u1, max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) (Finset.instMembershipFinset.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_2 i))) f (Finset.dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_2 i) s (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_2 i)) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_2 i)) i)) t))) (forall (i : ι), Membership.mem.{u1, u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) ((fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) i) (Finset.instMembershipFinset.{u1} (α i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_2 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_2 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_2 i)) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_2 i)) i)) t i)))\nCase conversion may be inaccurate. Consider using '#align finset.mem_dfinsupp_iff_of_support_subset Finset.mem_dfinsupp_iff_of_support_subsetₓ'. -/\n/-- When `t` is supported on `s`, `f ∈ s.dfinsupp t` precisely means that `f` is pointwise in `t`.\n-/\n@[simp]\ntheorem mem_dfinsupp_iff_of_support_subset {t : Π₀ i, Finset (α i)} (ht : t.support ⊆ s) :\n    f ∈ s.Dfinsupp t ↔ ∀ i, f i ∈ t i :=\n  by\n  refine'\n    mem_dfinsupp_iff.trans\n      (forall_and_distrib.symm.trans <|\n        forall_congr' fun i =>\n          ⟨fun h => _, fun h =>\n            ⟨fun hi => ht <| mem_support_iff.2 fun H => mem_support_iff.1 hi _, fun _ => h⟩⟩)\n  · by_cases hi : i ∈ s\n    · exact h.2 hi\n    · rw [not_mem_support_iff.1 (mt h.1 hi), not_mem_support_iff.1 (not_mem_mono ht hi)]\n      exact zero_mem_zero\n  · rwa [H, mem_zero] at h\n#align finset.mem_dfinsupp_iff_of_support_subset Finset.mem_dfinsupp_iff_of_support_subset\n\nend Finset\n\nopen Finset\n\nnamespace Dfinsupp\n\nsection BundledSingleton\n\nvariable [∀ i, Zero (α i)] {f : Π₀ i, α i} {i : ι} {a : α i}\n\n#print Dfinsupp.singleton /-\n/-- Pointwise `finset.singleton` bundled as a `dfinsupp`. -/\ndef singleton (f : Π₀ i, α i) : Π₀ i, Finset (α i)\n    where\n  toFun i := {f i}\n  support' := f.support'.map fun s => ⟨s, fun i => (s.Prop i).imp id (congr_arg _)⟩\n#align dfinsupp.singleton Dfinsupp.singleton\n-/\n\n#print Dfinsupp.mem_singleton_apply_iff /-\ntheorem mem_singleton_apply_iff : a ∈ f.singleton i ↔ a = f i :=\n  mem_singleton\n#align dfinsupp.mem_singleton_apply_iff Dfinsupp.mem_singleton_apply_iff\n-/\n\nend BundledSingleton\n\nsection BundledIcc\n\nvariable [∀ i, Zero (α i)] [∀ i, PartialOrder (α i)] [∀ i, LocallyFiniteOrder (α i)]\n  {f g : Π₀ i, α i} {i : ι} {a : α i}\n\n#print Dfinsupp.rangeIcc /-\n/-- Pointwise `finset.Icc` bundled as a `dfinsupp`. -/\ndef rangeIcc (f g : Π₀ i, α i) : Π₀ i, Finset (α i)\n    where\n  toFun i := Icc (f i) (g i)\n  support' :=\n    f.support'.bind fun fs =>\n      g.support'.map fun gs =>\n        ⟨fs + gs, fun i =>\n          or_iff_not_imp_left.2 fun h =>\n            by\n            have hf : f i = 0 :=\n              (fs.prop i).resolve_left\n                (Multiset.not_mem_mono (Multiset.Le.subset <| Multiset.le_add_right _ _) h)\n            have hg : g i = 0 :=\n              (gs.prop i).resolve_left\n                (Multiset.not_mem_mono (Multiset.Le.subset <| Multiset.le_add_left _ _) h)\n            rw [hf, hg]\n            exact Icc_self _⟩\n#align dfinsupp.range_Icc Dfinsupp.rangeIcc\n-/\n\n/- warning: dfinsupp.range_Icc_apply -> Dfinsupp.rangeIcc_apply is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : forall (i : ι), Zero.{u2} (α i)] [_inst_2 : forall (i : ι), PartialOrder.{u2} (α i)] [_inst_3 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_2 i))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (i : ι), Eq.{succ u2} (Finset.{u2} ((fun (i : ι) => α i) i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} ((fun (i : ι) => α i) i)) (fun (i : ι) => Finset.zero.{u2} ((fun (i : ι) => α i) i) ((fun (i : ι) => _inst_1 i) i))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} ((fun (i : ι) => α i) i)) (fun (i : ι) => Finset.zero.{u2} ((fun (i : ι) => α i) i) ((fun (i : ι) => _inst_1 i) i))) => forall (i : ι), Finset.{u2} ((fun (i : ι) => α i) i)) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => Finset.{u2} ((fun (i : ι) => α i) i)) (fun (i : ι) => Finset.zero.{u2} ((fun (i : ι) => α i) i) ((fun (i : ι) => _inst_1 i) i))) (Dfinsupp.rangeIcc.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (i : ι) => _inst_2 i) (fun (i : ι) => _inst_3 i) f g) i) (Finset.Icc.{u2} ((fun (i : ι) => α i) i) (PartialOrder.toPreorder.{u2} ((fun (i : ι) => α i) i) (_inst_2 i)) (_inst_3 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) g i))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : forall (i : ι), Zero.{u1} (α i)] [_inst_2 : forall (i : ι), PartialOrder.{u1} (α i)] [_inst_3 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (_inst_2 i))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (i : ι), Eq.{succ u1} ((fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) i)) (Dfinsupp.rangeIcc.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (i : ι) => _inst_2 i) (fun (i : ι) => _inst_3 i) f g) i) (Finset.Icc.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_2 i)) (_inst_3 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_1 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_1 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_1 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_1 i) i)) g i))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.range_Icc_apply Dfinsupp.rangeIcc_applyₓ'. -/\n@[simp]\ntheorem rangeIcc_apply (f g : Π₀ i, α i) (i : ι) : f.rangeIcc g i = Icc (f i) (g i) :=\n  rfl\n#align dfinsupp.range_Icc_apply Dfinsupp.rangeIcc_apply\n\n#print Dfinsupp.mem_rangeIcc_apply_iff /-\ntheorem mem_rangeIcc_apply_iff : a ∈ f.rangeIcc g i ↔ f i ≤ a ∧ a ≤ g i :=\n  mem_Icc\n#align dfinsupp.mem_range_Icc_apply_iff Dfinsupp.mem_rangeIcc_apply_iff\n-/\n\n/- warning: dfinsupp.support_range_Icc_subset -> Dfinsupp.support_rangeIcc_subset is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : forall (i : ι), Zero.{u2} (α i)] [_inst_2 : forall (i : ι), PartialOrder.{u2} (α i)] [_inst_3 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_2 i))] {f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)} {g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)} [_inst_4 : DecidableEq.{succ u1} ι] [_inst_5 : forall (i : ι), DecidableEq.{succ u2} (α i)], HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (a : ι) (b : ι) => _inst_4 a b) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i)) (fun (i : ι) (x : Finset.{u2} (α i)) => Ne.decidable.{succ u2} (Finset.{u2} (α i)) (fun (a : Finset.{u2} (α i)) (b : Finset.{u2} (α i)) => Finset.decidableEq.{u2} (α i) (fun (a : α i) (b : α i) => _inst_5 i a b) a b) x (OfNat.ofNat.{u2} (Finset.{u2} (α i)) 0 (OfNat.mk.{u2} (Finset.{u2} (α i)) 0 (Zero.zero.{u2} (Finset.{u2} (α i)) (Finset.zero.{u2} (α i) (_inst_1 i)))))) (Dfinsupp.rangeIcc.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (i : ι) => _inst_2 i) (fun (i : ι) => _inst_3 i) f g)) (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_4 a b)) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_4 a b) (fun (i : ι) => _inst_1 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_5 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_1 i))))) f) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_4 a b) (fun (i : ι) => _inst_1 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_5 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_1 i))))) g))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : forall (i : ι), Zero.{u1} (α i)] [_inst_2 : forall (i : ι), PartialOrder.{u1} (α i)] [_inst_3 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (_inst_2 i))] {f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)} {g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)} [_inst_4 : DecidableEq.{succ u2} ι] [_inst_5 : forall (i : ι), DecidableEq.{succ u1} (α i)], HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => Finset.{u1} (α i)) (fun (a : ι) (b : ι) => _inst_4 a b) (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) (fun (i : ι) (x : Finset.{u1} (α i)) => instDecidableNot (Eq.{succ u1} (Finset.{u1} (α i)) x (OfNat.ofNat.{u1} (Finset.{u1} (α i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (α i)) (Finset.zero.{u1} (α i) (_inst_1 i))))) (Finset.decidableEq.{u1} (α i) ((fun (i : ι) (a : α i) (b : α i) => _inst_5 i a b) i) x (OfNat.ofNat.{u1} (Finset.{u1} (α i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (α i)) (Finset.zero.{u1} (α i) (_inst_1 i)))))) (Dfinsupp.rangeIcc.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (i : ι) => _inst_2 i) (fun (i : ι) => _inst_3 i) f g)) (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_4 a b)) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_4 a b) (fun (i : ι) => _inst_1 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_1 i)))) (_inst_5 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_1 i))))) f) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_4 a b) (fun (i : ι) => _inst_1 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_1 i)))) (_inst_5 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_1 i))))) g))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.support_range_Icc_subset Dfinsupp.support_rangeIcc_subsetₓ'. -/\ntheorem support_rangeIcc_subset [DecidableEq ι] [∀ i, DecidableEq (α i)] :\n    (f.rangeIcc g).support ⊆ f.support ∪ g.support :=\n  by\n  refine' fun x hx => _\n  by_contra\n  refine' not_mem_support_iff.2 _ hx\n  rw [range_Icc_apply, not_mem_support_iff.1 (not_mem_mono (subset_union_left _ _) h),\n    not_mem_support_iff.1 (not_mem_mono (subset_union_right _ _) h)]\n  exact Icc_self _\n#align dfinsupp.support_range_Icc_subset Dfinsupp.support_rangeIcc_subset\n\nend BundledIcc\n\nsection Pi\n\nvariable [∀ i, Zero (α i)] [DecidableEq ι] [∀ i, DecidableEq (α i)]\n\n#print Dfinsupp.pi /-\n/-- Given a finitely supported function `f : Π₀ i, finset (α i)`, one can define the finset\n`f.pi` of all finitely supported functions whose value at `i` is in `f i` for all `i`. -/\ndef pi (f : Π₀ i, Finset (α i)) : Finset (Π₀ i, α i) :=\n  f.support.Dfinsupp f\n#align dfinsupp.pi Dfinsupp.pi\n-/\n\n/- warning: dfinsupp.mem_pi -> Dfinsupp.mem_pi is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : forall (i : ι), Zero.{u2} (α i)] [_inst_2 : DecidableEq.{succ u1} ι] [_inst_3 : forall (i : ι), DecidableEq.{succ u2} (α i)] {f : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))} {g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)}, Iff (Membership.Mem.{max u1 u2, max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (Finset.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i))) (Finset.hasMem.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i))) g (Dfinsupp.pi.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (a : ι) (b : ι) => _inst_2 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_3 i a b) f)) (forall (i : ι), Membership.Mem.{u2, u2} (α i) (Finset.{u2} (α i)) (Finset.hasMem.{u2} (α i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) g i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))) => forall (i : ι), Finset.{u2} (α i)) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))) f i))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : forall (i : ι), Zero.{u1} (α i)] [_inst_2 : DecidableEq.{succ u2} ι] [_inst_3 : forall (i : ι), DecidableEq.{succ u1} (α i)] {f : Dfinsupp.{u2, u1} ι (fun (i : ι) => Finset.{u1} (α i)) (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i))} {g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)}, Iff (Membership.mem.{max u2 u1, max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (Finset.{max u1 u2} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i))) (Finset.instMembershipFinset.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i))) g (Dfinsupp.pi.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (a : ι) (b : ι) => _inst_2 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_3 i a b) f)) (forall (i : ι), Membership.mem.{u1, u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) ((fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) i) (Finset.instMembershipFinset.{u1} (α i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_1 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_1 i) i)) g i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) i)) f i))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.mem_pi Dfinsupp.mem_piₓ'. -/\n@[simp]\ntheorem mem_pi {f : Π₀ i, Finset (α i)} {g : Π₀ i, α i} : g ∈ f.pi ↔ ∀ i, g i ∈ f i :=\n  mem_dfinsupp_iff_of_support_subset <| Subset.refl _\n#align dfinsupp.mem_pi Dfinsupp.mem_pi\n\n/- warning: dfinsupp.card_pi -> Dfinsupp.card_pi is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : forall (i : ι), Zero.{u2} (α i)] [_inst_2 : DecidableEq.{succ u1} ι] [_inst_3 : forall (i : ι), DecidableEq.{succ u2} (α i)] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (Dfinsupp.pi.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (a : ι) (b : ι) => _inst_2 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_3 i a b) f)) (Dfinsupp.prod.{u1, u2, 0} ι Nat (fun (i : ι) => Finset.{u2} (α i)) (fun (a : ι) (b : ι) => _inst_2 a b) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i)) (fun (i : ι) (x : Finset.{u2} (α i)) => Ne.decidable.{succ u2} (Finset.{u2} (α i)) (fun (a : Finset.{u2} (α i)) (b : Finset.{u2} (α i)) => Finset.decidableEq.{u2} (α i) (fun (a : α i) (b : α i) => _inst_3 i a b) a b) x (OfNat.ofNat.{u2} (Finset.{u2} (α i)) 0 (OfNat.mk.{u2} (Finset.{u2} (α i)) 0 (Zero.zero.{u2} (Finset.{u2} (α i)) (Finset.zero.{u2} (α i) (_inst_1 i)))))) Nat.commMonoid f (fun (i : ι) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat ((Finset.{u2} (α i)) -> Nat) (HasLiftT.mk.{1, succ u2} Nat ((Finset.{u2} (α i)) -> Nat) (CoeTCₓ.coe.{1, succ u2} Nat ((Finset.{u2} (α i)) -> Nat) (Nat.castCoe.{u2} ((Finset.{u2} (α i)) -> Nat) (Pi.hasNatCast.{u2, 0} (Finset.{u2} (α i)) (fun (ᾰ : Finset.{u2} (α i)) => Nat) (fun (a : Finset.{u2} (α i)) => AddMonoidWithOne.toNatCast.{0} Nat (AddCommMonoidWithOne.toAddMonoidWithOne.{0} Nat (NonAssocSemiring.toAddCommMonoidWithOne.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)))))))) (Finset.card.{u2} (α i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))) => forall (i : ι), Finset.{u2} (α i)) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => Finset.{u2} (α i)) (fun (i : ι) => Finset.zero.{u2} (α i) (_inst_1 i))) f i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : forall (i : ι), Zero.{u1} (α i)] [_inst_2 : DecidableEq.{succ u2} ι] [_inst_3 : forall (i : ι), DecidableEq.{succ u1} (α i)] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => Finset.{u1} (α i)) (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i))), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) (Dfinsupp.pi.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (a : ι) (b : ι) => _inst_2 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_3 i a b) f)) (Dfinsupp.prod.{u2, u1, 0} ι Nat (fun (i : ι) => Finset.{u1} (α i)) (fun (a : ι) (b : ι) => _inst_2 a b) (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) (fun (i : ι) (x : Finset.{u1} (α i)) => instDecidableNot (Eq.{succ u1} (Finset.{u1} (α i)) x (OfNat.ofNat.{u1} (Finset.{u1} (α i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (α i)) (Finset.zero.{u1} (α i) (_inst_1 i))))) (Finset.decidableEq.{u1} (α i) ((fun (i : ι) (a : α i) (b : α i) => _inst_3 i a b) i) x (OfNat.ofNat.{u1} (Finset.{u1} (α i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (α i)) (Finset.zero.{u1} (α i) (_inst_1 i)))))) Nat.commMonoid f (fun (i : ι) => Nat.cast.{u1} ((Finset.{u1} (α i)) -> Nat) (Pi.natCast.{u1, 0} (Finset.{u1} (α i)) (fun (a._@.Mathlib.Data.Dfinsupp.Basic._hyg.25484 : Finset.{u1} (α i)) => Nat) (fun (a : Finset.{u1} (α i)) => instNatCastNat)) (Finset.card.{u1} (α i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_1 i)) i)) f i))))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_pi Dfinsupp.card_piₓ'. -/\n@[simp]\ntheorem card_pi (f : Π₀ i, Finset (α i)) : f.pi.card = f.Prod fun i => (f i).card :=\n  by\n  rw [pi, card_dfinsupp]\n  exact Finset.prod_congr rfl fun i _ => by simp only [Pi.nat_apply, Nat.cast_id]\n#align dfinsupp.card_pi Dfinsupp.card_pi\n\nend Pi\n\nsection LocallyFinite\n\nvariable [DecidableEq ι] [∀ i, DecidableEq (α i)]\n\nvariable [∀ i, PartialOrder (α i)] [∀ i, Zero (α i)] [∀ i, LocallyFiniteOrder (α i)]\n\ninstance : LocallyFiniteOrder (Π₀ i, α i) :=\n  LocallyFiniteOrder.ofIcc (Π₀ i, α i) (fun f g => (f.support ∪ g.support).Dfinsupp <| f.rangeIcc g)\n    fun f g x =>\n    by\n    refine' (mem_dfinsupp_iff_of_support_subset <| support_range_Icc_subset).trans _\n    simp_rw [mem_range_Icc_apply_iff, forall_and]\n    rfl\n\nvariable (f g : Π₀ i, α i)\n\n/- warning: dfinsupp.Icc_eq -> Dfinsupp.Icc_eq is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u2} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u2} (α i)] [_inst_4 : forall (i : ι), Zero.{u2} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i))) (Finset.Icc.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g) (Finset.dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) g)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} ((fun (i : ι) => α i) i)) (fun (i : ι) => Finset.zero.{u2} ((fun (i : ι) => α i) i) ((fun (i : ι) => _inst_4 i) i))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => Finset.{u2} ((fun (i : ι) => α i) i)) (fun (i : ι) => Finset.zero.{u2} ((fun (i : ι) => α i) i) ((fun (i : ι) => _inst_4 i) i))) => forall (i : ι), Finset.{u2} ((fun (i : ι) => α i) i)) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => Finset.{u2} ((fun (i : ι) => α i) i)) (fun (i : ι) => Finset.zero.{u2} ((fun (i : ι) => α i) i) ((fun (i : ι) => _inst_4 i) i))) (Dfinsupp.rangeIcc.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_5 i) f g)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u1} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u1} (α i)] [_inst_4 : forall (i : ι), Zero.{u1} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i))) (Finset.Icc.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g) (Finset.dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) g)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_4 i)) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => Finset.{u1} (α i)) i) (fun (i : ι) => (fun (i : ι) => Finset.zero.{u1} (α i) (_inst_4 i)) i)) (Dfinsupp.rangeIcc.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_5 i) f g)))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.Icc_eq Dfinsupp.Icc_eqₓ'. -/\ntheorem Icc_eq : Icc f g = (f.support ∪ g.support).Dfinsupp (f.rangeIcc g) :=\n  rfl\n#align dfinsupp.Icc_eq Dfinsupp.Icc_eq\n\n/- warning: dfinsupp.card_Icc -> Dfinsupp.card_Icc is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u2} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u2} (α i)] [_inst_4 : forall (i : ι), Zero.{u2} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Icc.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (Finset.prod.{0, u1} Nat ι Nat.commMonoid (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u2} (α i) (Finset.Icc.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) g i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u1} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u1} (α i)] [_inst_4 : forall (i : ι), Zero.{u1} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Icc.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (Finset.prod.{0, u2} Nat ι Nat.commMonoid (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (Finset.Icc.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) g i))))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Icc Dfinsupp.card_Iccₓ'. -/\ntheorem card_Icc : (Icc f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card :=\n  card_dfinsupp _ _\n#align dfinsupp.card_Icc Dfinsupp.card_Icc\n\n/- warning: dfinsupp.card_Ico -> Dfinsupp.card_Ico is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u2} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u2} (α i)] [_inst_4 : forall (i : ι), Zero.{u2} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Ico.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat ι Nat.commMonoid (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u2} (α i) (Finset.Icc.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) g i)))) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u1} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u1} (α i)] [_inst_4 : forall (i : ι), Zero.{u1} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Ico.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat ι Nat.commMonoid (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (Finset.Icc.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) g i)))) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Ico Dfinsupp.card_Icoₓ'. -/\ntheorem card_Ico : (Ico f g).card = (∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card) - 1 := by\n  rw [card_Ico_eq_card_Icc_sub_one, card_Icc]\n#align dfinsupp.card_Ico Dfinsupp.card_Ico\n\n/- warning: dfinsupp.card_Ioc -> Dfinsupp.card_Ioc is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u2} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u2} (α i)] [_inst_4 : forall (i : ι), Zero.{u2} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Ioc.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat ι Nat.commMonoid (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u2} (α i) (Finset.Icc.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) g i)))) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u1} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u1} (α i)] [_inst_4 : forall (i : ι), Zero.{u1} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Ioc.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat ι Nat.commMonoid (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (Finset.Icc.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) g i)))) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Ioc Dfinsupp.card_Iocₓ'. -/\ntheorem card_Ioc : (Ioc f g).card = (∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card) - 1 := by\n  rw [card_Ioc_eq_card_Icc_sub_one, card_Icc]\n#align dfinsupp.card_Ioc Dfinsupp.card_Ioc\n\n/- warning: dfinsupp.card_Ioo -> Dfinsupp.card_Ioo is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u2} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u2} (α i)] [_inst_4 : forall (i : ι), Zero.{u2} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Ioo.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat ι Nat.commMonoid (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u2} (α i) (Finset.Icc.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) g i)))) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u1} (α i)] [_inst_3 : forall (i : ι), PartialOrder.{u1} (α i)] [_inst_4 : forall (i : ι), Zero.{u1} (α i)] [_inst_5 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (g : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Finset.Ioo.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => _inst_3 i) (fun (i : ι) => _inst_4 i) (fun (i : ι) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat ι Nat.commMonoid (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => _inst_4 i) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (_inst_4 i))))) g)) (fun (i : ι) => Finset.card.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (Finset.Icc.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => _inst_4 i) i)) g i)))) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Ioo Dfinsupp.card_Iooₓ'. -/\ntheorem card_Ioo : (Ioo f g).card = (∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card) - 2 := by\n  rw [card_Ioo_eq_card_Icc_sub_two, card_Icc]\n#align dfinsupp.card_Ioo Dfinsupp.card_Ioo\n\nend LocallyFinite\n\nsection CanonicallyOrdered\n\nvariable [DecidableEq ι] [∀ i, DecidableEq (α i)]\n\nvariable [∀ i, CanonicallyOrderedAddMonoid (α i)] [∀ i, LocallyFiniteOrder (α i)]\n\nvariable (f : Π₀ i, α i)\n\n/- warning: dfinsupp.card_Iic -> Dfinsupp.card_Iic is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u2} (α i)] [_inst_3 : forall (i : ι), CanonicallyOrderedAddMonoid.{u2} (α i)] [_inst_4 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (Finset.Iic.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))) (Dfinsupp.orderBot.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_3 i)) (Dfinsupp.locallyFiniteOrder.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) => _inst_4 i))) f)) (Finset.prod.{0, u1} Nat ι Nat.commMonoid (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))))))) f) (fun (i : ι) => Finset.card.{u2} (α i) (Finset.Iic.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u2} (α i) (_inst_3 i)) (_inst_4 i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) f i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u1} (α i)] [_inst_3 : forall (i : ι), CanonicallyOrderedAddMonoid.{u1} (α i)] [_inst_4 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))) (Finset.Iic.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))))) (Dfinsupp.instOrderBotDfinsuppToZeroToAddMonoidToAddCommMonoidToOrderedAddCommMonoidInstLEDfinsuppToLEToPreorderToPartialOrder.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_3 i)) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) => _inst_4 i))) f)) (Finset.prod.{0, u2} Nat ι Nat.commMonoid (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))))))) f) (fun (i : ι) => Finset.card.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (Finset.Iic.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)) (_inst_4 i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) i)) f i))))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Iic Dfinsupp.card_Iicₓ'. -/\ntheorem card_Iic : (Iic f).card = ∏ i in f.support, (Iic (f i)).card := by\n  simp_rw [Iic_eq_Icc, card_Icc, Dfinsupp.bot_eq_zero, support_zero, empty_union, zero_apply,\n    bot_eq_zero]\n#align dfinsupp.card_Iic Dfinsupp.card_Iic\n\n/- warning: dfinsupp.card_Iio -> Dfinsupp.card_Iio is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u2} (α i)] [_inst_3 : forall (i : ι), CanonicallyOrderedAddMonoid.{u2} (α i)] [_inst_4 : forall (i : ι), LocallyFiniteOrder.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))] (f : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (Finset.Iio.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u1 u2} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) => PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))) (Dfinsupp.orderBot.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_3 i)) (Dfinsupp.locallyFiniteOrder.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) => _inst_4 i))) f)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat ι Nat.commMonoid (Dfinsupp.support.{u1, u2} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))) (fun (i : ι) (x : α i) => Ne.decidable.{succ u2} (α i) (fun (a : α i) (b : α i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (α i) 0 (OfNat.mk.{u2} (α i) 0 (Zero.zero.{u2} (α i) (AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))))))))) f) (fun (i : ι) => Finset.card.{u2} (α i) (Finset.Iic.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u2} (α i) (PartialOrder.toPreorder.{u2} (α i) (OrderedAddCommMonoid.toPartialOrder.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u2} (α i) (_inst_3 i)) (_inst_4 i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) (fun (_x : Dfinsupp.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) => forall (i : ι), α i) (Dfinsupp.hasCoeToFun.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => AddZeroClass.toHasZero.{u2} (α i) (AddMonoid.toAddZeroClass.{u2} (α i) (AddCommMonoid.toAddMonoid.{u2} (α i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (α i) (_inst_3 i))))))) f i)))) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : forall (i : ι), DecidableEq.{succ u1} (α i)] [_inst_3 : forall (i : ι), CanonicallyOrderedAddMonoid.{u1} (α i)] [_inst_4 : forall (i : ι), LocallyFiniteOrder.{u1} (α i) (PartialOrder.toPreorder.{u1} (α i) (OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))))] (f : Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))) (Finset.Iio.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u2 u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) => PartialOrder.toPreorder.{u1} (α i) (OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))))) (Dfinsupp.instOrderBotDfinsuppToZeroToAddMonoidToAddCommMonoidToOrderedAddCommMonoidInstLEDfinsuppToLEToPreorderToPartialOrder.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_3 i)) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) (a : α i) (b : α i) => _inst_2 i a b) (fun (i : ι) => OrderedAddCommMonoid.toPartialOrder.{u1} (α i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (α i) (_inst_3 i))) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) => _inst_4 i))) f)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat ι Nat.commMonoid (Dfinsupp.support.{u2, u1} ι (fun (i : ι) => α i) (fun (a : ι) (b : ι) => _inst_1 a b) (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) (fun (i : ι) (x : α i) => instDecidableNot (Eq.{succ u1} (α i) x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i)))))))) (_inst_2 i x (OfNat.ofNat.{u1} (α i) 0 (Zero.toOfNat0.{u1} (α i) (AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))))))) f) (fun (i : ι) => Finset.card.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (Finset.Iic.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u1} ((fun (i : ι) => (fun (i : ι) => α i) i) i) (_inst_3 i)) (_inst_4 i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) i)) ι (fun (_x : ι) => (fun (i : ι) => (fun (i : ι) => α i) i) _x) (Dfinsupp.funLike.{u2, u1} ι (fun (i : ι) => (fun (i : ι) => α i) i) (fun (i : ι) => (fun (i : ι) => AddMonoid.toZero.{u1} ((fun (i : ι) => α i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : ι) => α i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : ι) => α i) i) (_inst_3 i))))) i)) f i)))) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Iio Dfinsupp.card_Iioₓ'. -/\ntheorem card_Iio : (Iio f).card = (∏ i in f.support, (Iic (f i)).card) - 1 := by\n  rw [card_Iio_eq_card_Iic_sub_one, card_Iic]\n#align dfinsupp.card_Iio Dfinsupp.card_Iio\n\nend CanonicallyOrdered\n\nend Dfinsupp\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Dfinsupp/Interval.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6442250996557035, "lm_q1q2_score": 0.4936655985825845}}
{"text": "inductive Cat :=\n| var (n : Nat) : Cat\n\nmutual\n\ninductive Obj : Cat → Type where\n| var (C : Cat) (n : Nat) : Obj C\n| varApp {C D : Cat} (v : Nat) (X : Obj C) : Obj D\n| rAdjApp {C D : Cat} (F : Func C D) (X : Obj D) : Obj C\n\ninductive Func : Cat → Cat → Type where\n| id (C : Cat) : Func C C\n| compVar {C D E : Cat} (F : Func C D) (v : Nat) : Func C E\n| compRAdj {C D E : Cat} (F : Func C D) (G : Func E D) : Func C E\n\nend\n\nmutual\n\ndef ObjContainsRAdj {C' D' : Cat} (L : Func C' D') : {C : Cat} → (X : Obj C) → Prop\n| _, Obj.var _ _     => False\n| _, Obj.varApp _ X  => ObjContainsRAdj L X\n| _, Obj.rAdjApp F X => FuncContainsRAdj L F ∨ ObjContainsRAdj L X ∨ HEq L F\n\ndef FuncContainsRAdj {C' D' : Cat} (L : Func C' D') : {C D : Cat} → (F : Func C D) → Prop\n| _, _, Func.id _         => False\n| _, _, Func.compVar G v  => FuncContainsRAdj L G\n| _, _, Func.compRAdj G H => FuncContainsRAdj L G ∨ FuncContainsRAdj L H ∨ HEq L H\n\nend\n\nnoncomputable def Func.compAux {D E : Cat} (G : Func D E) : (C : Cat) → (F : Func C D) → Func C E :=\n@Func.recOn (λ _ _ => Unit) (λ D E G => (C : Cat) → (F : Func C D) → Func C E)\n  D E G\n  (λ _ _ => ())\n  (λ _ _ _ => ())\n  (λ _ _ _ _ => ())\n  (λ _ _ F => F)\n  (λ D v ih C F => compVar (ih _ F) v)\n  (λ F G ih _ C H => compRAdj (ih _ H) G)\n\nnoncomputable def Func.comp {C D E : Cat} (F : Func C D) (G : Func D E) : Func C E :=\nFunc.compAux G _ F\n\nnoncomputable def Func.app {C D : Cat} (F : Func C D) : (X : Obj C) → Obj D :=\n@Func.recOn (λ _ _ => Unit) (λ C D _ => Obj C → Obj D)\n  C D F\n  (λ _ _ => ())\n  (λ _ _ _ => ())\n  (λ _ _ _ _ => ())\n  (λ _ X => X)\n  (λ F v ih X => Obj.varApp v (ih X))\n  (λ F G ih _ X => Obj.rAdjApp G (ih X))\n\ntheorem Func.idApp {C : Cat} (X : Obj C) : (Func.id C).app X = X := rfl\n\ntheorem Func.compVarApp {C D E : Cat} (F : Func C D) (v : Nat) (X : Obj C) :\n  (@Func.compVar C D E F v).app X = Obj.varApp v (F.app X) := rfl\n\ntheorem Func.compRAdjApp {C D E : Cat} (F : Func C D) (G : Func E D) (X : Obj C) :\n  (Func.compRAdj F G).app X = Obj.rAdjApp G (F.app X) := rfl\n\ndef Func.var (C D : Cat) (v : Nat) : Func C D :=\nFunc.compVar (Func.id _) v\n\ndef Func.rAdj {C D : Cat} (F : Func D C) : Func C D :=\nFunc.compRAdj (Func.id _) F\n\nnoncomputable def Obj.cases : {C : Cat} → (X Y : Obj C) → Σ D : Cat, Obj D × Obj D\n| C, X, rAdjApp F Y => cases (F.app X) Y\n| C, X,           Y => ⟨C, X, Y⟩\n\ntheorem FuncAppContainsRAdj {C' D' : Cat} (G : Func C' D') :\n  {C D : Cat} → (F : Func C D) → (X : Obj C) →\n  ObjContainsRAdj G (F.app X) ↔ FuncContainsRAdj G F ∨ ObjContainsRAdj G X\n| _, _, (Func.id _), X => by\nrw [Func.idApp, FuncContainsRAdj, false_or, iff_self]\ntrivial\n| _, _, (Func.compVar F v), X => by\nrw [Func.compVarApp, ObjContainsRAdj, FuncContainsRAdj, FuncAppContainsRAdj G F, iff_self]\ntrivial\n| _, _, (Func.compRAdj I H), X => by\nrw [Func.compRAdjApp, ObjContainsRAdj, FuncContainsRAdj, FuncAppContainsRAdj G I]\nsorry\n\n\ntheorem ObjContainsRAdjCases1 : {C D E : Cat} → {X Y : Obj E} → {F : Func C D} →\n  ObjContainsRAdj F (X.cases Y).2.1 → ObjContainsRAdj F X ∨ ObjContainsRAdj F Y\n| C, D, E, X, Obj.rAdjApp G Y, F, h => by\n  rw [Obj.cases] at h\n  have h' := ObjContainsRAdjCases1 h\n  rw [FuncAppContainsRAdj] at h'\n  rw [ObjContainsRAdj]\n  sorry\n| C, D, E, X, Obj.var _ _, F, h => by\n  rw [Obj.cases] at h\n  simp [Obj.cases] at h\n  exact Or.inl h\n  intros _ _ _ h\n  injection h\n| C, D, E, X, Obj.varApp v Y, F, h => by\n  rw [Obj.cases] at h\n  simp at h\n  exact Or.inl h\n  intros _ _ _ h\n  injection h\n\ntheorem ObjContainsRAdjCases2 : {C D E : Cat} → {X Y : Obj E} → {F : Func C D} →\n  ObjContainsRAdj F (X.cases Y).2.2 → ObjContainsRAdj F X ∨ ObjContainsRAdj F Y\n| C, D, E, X, Obj.rAdjApp G Y, F, h => by\n  rw [Obj.cases] at h\n  have h' := ObjContainsRAdjCases2 h\n  rw [FuncAppContainsRAdj] at h'\n  rw [ObjContainsRAdj]\n  sorry\n| C, D, E, X, Obj.var _ _, F, h => by\n  rw [Obj.cases] at h\n  simp [Obj.cases] at h\n  exact Or.inr h\n  intros _ _ _ h\n  injection h\n| C, D, E, X, Obj.varApp v Y, F, h => by\n  rw [Obj.cases] at h\n  simp at h\n  exact Or.inr h\n  intros _ _ _ h\n  injection h\n\nmutual\n\ninductive HomAux : {C : Cat} → (X Y : Obj C) → Type where\n| mapVar {C D : Cat} {X Y : Obj C} (v : Nat) (f : HomAux X Y) :\n  HomAux ((Func.var C D v).app X) ((Func.var C D v).app Y)\n| mapRAdj {C D : Cat} {X Y : Obj C} (F : Func D C) (f : HomAux X Y) :\n  HomAux (F.rAdj.app X) (F.rAdj.app Y)\n| var {C : Cat} {X Y : Obj C} (v : Nat) : HomAux (X.cases Y).2.1 (X.cases Y).2.2\n| restrict {C D : Cat} (F : Func C D) {X : Obj C} {Y : Obj D} :\n  Hom (F.app X) Y → HomAux X (Obj.rAdjApp F Y)\n| counit {C D : Cat} (F : Func C D) (X : Obj D) :\n  HomAux (F.app (F.rAdj.app X)) X\n\ninductive Hom : {C : Cat} → (X Y : Obj C) → Type where\n| id {C : Cat} (X : Obj C) : Hom X X\n| comp' {C : Cat} {X Y Z : Obj C} (f : HomAux X Y) (g : Hom Y Z) : Hom X Z\n\nend\n\nmutual\n\nnoncomputable def HomAuxContainsVar {C' : Cat} (A B : Obj C') (v : Nat) :\n  {C : Cat} → {X Y : Obj C} → HomAux X Y → Prop\n| _, _, _, HomAux.mapVar _ f      => HomAuxContainsVar A B v f\n| _, _, _, HomAux.mapRAdj F f     => HomAuxContainsVar A B v f\n| _, _, _, HomAux.var w        => _\n| _, _, _, HomAux.restrict F f => HomContainsVar A B v f\n| _, _, _, HomAux.counit F X   => False\n\nnoncomputable def HomContainsVar {C' : Cat} (A B : Obj C') (v : Nat) :\n  {C : Cat} → {X Y : Obj C} → Hom X Y → Prop\n| _, _, _, Hom.id _ => False\n| _, _, _, Hom.comp' f g => HomAuxContainsVar A B v f ∨ HomContainsVar A B v g\n\nend\n\nmutual\n\nnoncomputable def HomAuxContainsRAdj {C' D' : Cat} (F : Func C' D') :\n  {C : Cat} → {X Y : Obj C} → HomAux X Y → Prop\n| _, _, _, HomAux.mapVar _ f   => HomAuxContainsRAdj F f\n| _, _, _, HomAux.mapRAdj G f  => HomAuxContainsRAdj F f ∨ HEq F G\n  ∨ FuncContainsRAdj F G\n| _, _, _, @HomAux.var _ X Y w => ObjContainsRAdj F X ∨ ObjContainsRAdj F Y\n| _, _, _, HomAux.restrict G f => HomContainsRAdj F f ∨ HEq F G ∨ FuncContainsRAdj F G\n| _, _, _, HomAux.counit G X   => ObjContainsRAdj F X ∨ HEq F G ∨ FuncContainsRAdj F G\n\nnoncomputable def HomContainsRAdj {C' D' : Cat} (F : Func C' D') :\n  {C : Cat} → {X Y : Obj C} → Hom X Y → Prop\n| _, X, _, Hom.id _ => ObjContainsRAdj F X\n| _, _, _, Hom.comp' f g => HomAuxContainsRAdj F f ∨ HomContainsRAdj F g\n\nend\n\nvariable {Γ}\n\nnamespace Hom\n\nvariable {C D : Cat}\n\nsection defs\n\ndef ofHomAux {X Y : Obj C} (f : HomAux X Y) : Hom X Y :=\nHom.comp' f (Hom.id _)\n\nnoncomputable def var (X Y : Obj C) (v : Nat) : Hom (X.cases Y).2.1 (X.cases Y).2.2 :=\nofHomAux (HomAux.var v)\n\nnoncomputable def comp : {C : Cat} → {X Y Z : Obj C} →\n  Hom X Y → Hom Y Z → Hom X Z\n| _, _, _, _, Hom.id _, g => g\n| _, _, _, _, Hom.comp' f g, h => Hom.comp' f (comp g h)\n\nnoncomputable def mapAux : {C D : Cat} → (F : Func C D) → {X Y : Obj C} →\n  (f : HomAux X Y) → HomAux (F.app X) (F.app Y)\n| _, _, Func.id _,           _, _, f => f\n| _, _, (Func.compVar F v),  _, _, f => HomAux.mapVar v (mapAux F f)\n| _, _, (Func.compRAdj F G), _, _, f => HomAux.mapRAdj G (mapAux F f)\n\nnoncomputable def map {C D : Cat} (F : Func C D) : {X Y : Obj C} →\n  (f : Hom X Y) → Hom (F.app X) (F.app Y)\n| _, _, Hom.id _ => Hom.id _\n| _, _, Hom.comp' f g => Hom.comp' (mapAux F f) (map F g)\n\nnoncomputable def restrict {C D : Cat} (F : Func C D)\n  {X : Obj C} {Y : Obj D}\n  (f : Hom (F.app X) Y) : Hom X (Obj.rAdjApp F Y) :=\nofHomAux (HomAux.restrict F f)\n\nnoncomputable def counit {C D : Cat} (F : Func C D) (X : Obj D) :\n  Hom (F.app (F.rAdj.app X)) X :=\nofHomAux (HomAux.counit F X)\n\nend defs\n\nsection lemmas\n\ntheorem compId : {X Y : Obj C} → (f : Hom X Y) → f.comp (Hom.id _) = f\n| _, _, (Hom.id _) => by rw [comp]\n| _, _, (Hom.comp' f g) => by rw [Hom.comp, compId g]\n\ntheorem idComp {X Y : Obj C} (f : Hom X Y) : (Hom.id _).comp f = f :=\nby rw [Hom.comp]\n\ntheorem compAssoc : {W X Y Z : Obj C} →\n  (f : Hom W X) → (g : Hom X Y) → (h : Hom Y Z) →\n  (f.comp g).comp h = f.comp (g.comp h)\n| _, _, _, _, Hom.id _,      h, i => by rw [idComp, idComp]\n| _, _, _, _, Hom.comp' f g, h, i =>\nby rw [Hom.comp, Hom.comp, Hom.comp, compAssoc g]\n\ntheorem mapId {X : Obj C} (F : Func C D) : map F (@Hom.id C X) = Hom.id (F.app X) :=\nby rw [Hom.map]\n\ntheorem mapComp (F : Func C D) : {X Y Z : Obj C} → (f : Hom X Y) → (g : Hom Y Z) →\n  map F (f.comp g) = (map F f).comp (map F g)\n| _, _, _, Hom.id _,      g => by rw [idComp, mapId, idComp]\n| _, _, _, Hom.comp' f g, h => by rw [comp, map, map, mapComp F g, comp]\n\nend lemmas\n\n/- Now the other normalisation stuff.\n  -- Suppose we have f : X → Y where X and Y are Objects of C and the context is cased.\n  -- If Y is rAdj, then f must be restrict to be almostNormal\n  -- If Y is not rAdj then f is almostNormal if every rAdj functor contained in\n    f is contained in the domain of a variable in f or cases of the codomain.\n  -- A term is normal if every subterm (define properly) is almostNormal\n -/\n\nend Hom\n\nstructure Context : Type :=\n( HomVar {C : Cat} (X Y : Obj C) : Nat → Prop )\n( hasRAdj {C D : Cat} (F : Func C D) : Prop )\n-- ( h : ∀ {C : Cat} (X Y : Obj C) (v : Nat),\n--     HomVar X Y v → ∀ {C' D' : Cat} (F : Func C' D'),\n--     ObjContainsRAdj F X ∨ ObjContainsRAdj F Y →\n--     hasRAdj F )\n\ndef SmallestContext {C : Cat} {X Y : Obj C} (f : Hom X Y) : Context :=\n{ HomVar  := λ X Y n => HomContainsVar X Y n f,\n  hasRAdj := λ F     => HomContainsRAdj F f }\n\ndef lessRAdj (Γ₁ Γ₂ : Context) : Prop :=\n@Context.HomVar Γ₁ = @Context.HomVar Γ₂ ∧\n  ∀ {C D : Cat} (F : Func C D), Γ₁.hasRAdj F → Γ₂.hasRAdj F\n\nvariable (Γ : Context)\n\ndef ObjC (C : Cat) : Type :=\nΣ' X : Obj C, ∀ (C' D' : Cat) (F : Func C' D'), ObjContainsRAdj F X → Γ.hasRAdj F\n\ndef FuncC (C D : Cat) : Type :=\nΣ' F : Func C D, ∀ (C' D' : Cat) (G : Func C' D'), FuncContainsRAdj G F → Γ.hasRAdj G\n\ndef HomC {C : Cat} (X Y : ObjC Γ C) : Type :=\nΣ' f : Hom X.1 Y.1,\n  (∀ (C' D' : Cat) (F : Func C' D'), HomContainsRAdj F f → Γ.hasRAdj F) ∧\n  ∀ (C' : Cat) (X' Y' : ObjC Γ C') (v : Nat), HomContainsVar X'.1 Y'.1 v f →\n    Γ.HomVar X'.1 Y'.1 v\n\nvariable {Γ}\n\nnoncomputable def ObjC.cases {C : Cat} (X Y : ObjC Γ C) : Σ D : Cat, ObjC Γ D × ObjC Γ D :=\nlet B := Obj.cases X.1 Y.1\n⟨B.1, ⟨B.2.1,\n  by\n  intros C' D' F h\n  have := ObjContainsRAdjCases1 h\n  cases this\n  apply X.2\n  assumption\n  apply Y.2\n  assumption⟩,\n  ⟨B.2.2,\n  by\n  intros C' D' F h\n  have := ObjContainsRAdjCases2 h\n  cases this\n  apply X.2\n  assumption\n  apply Y.2\n  assumption⟩⟩\n\nnoncomputable def FuncC.app {C D : Cat} (F : FuncC Γ C D) (X : ObjC Γ C) : ObjC Γ D :=\n⟨F.1.app X.1, sorry⟩\n\nnamespace HomC\n\nnoncomputable def var (X Y : ObjC Γ C) (v : Nat) (h : Γ.HomVar X.1 Y.1 v) :\n  HomC Γ (X.cases Y).2.1 (X.cases Y).2.2 :=\n⟨Hom.var X.1 Y.1 v, by\n  apply And.intro\n  intros C' D' F h2\n  rw [Hom.var, Hom.ofHomAux, HomContainsRAdj, HomContainsRAdj] at h2\n  sorry\n  intros C' X' Y' w h2\n  rw [Hom.var, Hom.ofHomAux, HomContainsVar] at h2\n  sorry ⟩\n\nnoncomputable def id {C : Cat} (X : ObjC Γ C) : HomC Γ X X :=\n⟨Hom.id X.1, sorry⟩\n\nnoncomputable def comp {C : Cat} {X Y Z : ObjC Γ C} :\n  HomC Γ X Y → HomC Γ Y Z → HomC Γ X Z :=\nλ f g => ⟨Hom.comp f.1 g.1, sorry⟩\n\nnoncomputable def map {C D : Cat} (F : FuncC Γ C D) {X Y : ObjC Γ C}\n  (f : HomC Γ X Y) : HomC Γ (F.app X) (F.app Y) :=\n⟨Hom.map F.1 f.1, sorry⟩\n\nnoncomputable def restrict {C D : Cat} (F : FuncC Γ C D)\n  {X : ObjC Γ C} {Y : ObjC Γ D}\n  (f : Hom (F.app X) Y) : Hom X (Obj.rAdjApp F Y) :=\nofHomAux (HomAux.restrict F f)\n\nnoncomputable def counit {C D : Cat} (F : Func C D) (X : Obj D) :\n  Hom (F.app (F.rAdj.app X)) X :=\nofHomAux (HomAux.counit F X)\n\nend HomC", "meta": {"author": "ChrisHughes24", "repo": "lean4stuff", "sha": "2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346", "save_path": "github-repos/lean/ChrisHughes24-lean4stuff", "path": "github-repos/lean/ChrisHughes24-lean4stuff/lean4stuff-2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346/Stuff/repfunctoradjoint2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115012, "lm_q2_score": 0.6442251064863695, "lm_q1q2_score": 0.49366559694012624}}
{"text": "/-\nCopyright © 2020 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicolò Cavalleri\n-/\n\nimport geometry.manifold.cont_mdiff\nimport topology.continuous_function.basic\n\n/-!\n# Smooth bundled map\n\nIn this file we define the type `cont_mdiff_map` of `n` times continuously differentiable\nbundled maps.\n-/\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{E : Type*} [normed_group E] [normed_space 𝕜 E]\n{E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n{H : Type*} [topological_space H]\n{H' : Type*} [topological_space H']\n(I : model_with_corners 𝕜 E H) (I' : model_with_corners 𝕜 E' H')\n(M : Type*) [topological_space M] [charted_space H M]\n(M' : Type*) [topological_space M'] [charted_space H' M']\n{E'' : Type*} [normed_group E''] [normed_space 𝕜 E'']\n{H'' : Type*} [topological_space H'']\n{I'' : model_with_corners 𝕜 E'' H''}\n{M'' : Type*} [topological_space M''] [charted_space H'' M'']\n(n : with_top ℕ)\n\n/-- Bundled `n` times continuously differentiable maps. -/\n@[protect_proj]\nstructure cont_mdiff_map :=\n(to_fun                  : M → M')\n(cont_mdiff_to_fun : cont_mdiff I I' n to_fun)\n\n/-- Bundled smooth maps. -/\n@[reducible] def smooth_map := cont_mdiff_map I I' M M' ⊤\n\nlocalized \"notation `C^` n `⟮` I `, ` M `; ` I' `, ` M' `⟯` :=\n  cont_mdiff_map I I' M M' n\" in manifold\nlocalized \"notation `C^` n `⟮` I `, ` M `; ` k `⟯` :=\n  cont_mdiff_map I (model_with_corners_self k k) M k n\" in manifold\n\nopen_locale manifold\n\nnamespace cont_mdiff_map\n\nvariables {I} {I'} {M} {M'} {n}\n\ninstance : has_coe_to_fun C^n⟮I, M; I', M'⟯ (λ _, M → M') := ⟨cont_mdiff_map.to_fun⟩\ninstance : has_coe C^n⟮I, M; I', M'⟯ C(M, M') :=\n⟨λ f, ⟨f, f.cont_mdiff_to_fun.continuous⟩⟩\n\nattribute [to_additive_ignore_args 21] cont_mdiff_map\n  cont_mdiff_map.has_coe_to_fun cont_mdiff_map.continuous_map.has_coe\nvariables {f g : C^n⟮I, M; I', M'⟯}\n\n@[simp] lemma coe_fn_mk (f : M → M') (hf : cont_mdiff I I' n f) :\n  (mk f hf : M → M') = f :=\nrfl\n\nprotected lemma cont_mdiff (f : C^n⟮I, M; I', M'⟯) :\n  cont_mdiff I I' n f := f.cont_mdiff_to_fun\n\nprotected lemma smooth (f : C^∞⟮I, M; I', M'⟯) :\n  smooth I I' f := f.cont_mdiff_to_fun\n\nprotected lemma mdifferentiable' (f : C^n⟮I, M; I', M'⟯) (hn : 1 ≤ n) :\n  mdifferentiable I I' f :=\nf.cont_mdiff.mdifferentiable hn\n\nprotected \n\nprotected lemma mdifferentiable_at (f : C^∞⟮I, M; I', M'⟯) {x} :\n  mdifferentiable_at I I' f x :=\nf.mdifferentiable x\n\nlemma coe_inj ⦃f g : C^n⟮I, M; I', M'⟯⦄ (h : (f : M → M') = g) : f = g :=\nby cases f; cases g; cases h; refl\n\n@[ext] theorem ext (h : ∀ x, f x = g x) : f = g :=\nby cases f; cases g; congr'; exact funext h\n\n/-- The identity as a smooth map. -/\ndef id : C^n⟮I, M; I, M⟯ := ⟨id, cont_mdiff_id⟩\n\n/-- The composition of smooth maps, as a smooth map. -/\ndef comp (f : C^n⟮I', M'; I'', M''⟯) (g : C^n⟮I, M; I', M'⟯) : C^n⟮I, M; I'', M''⟯ :=\n{ to_fun := λ a, f (g a),\n  cont_mdiff_to_fun := f.cont_mdiff_to_fun.comp g.cont_mdiff_to_fun, }\n\n@[simp] lemma comp_apply (f : C^n⟮I', M'; I'', M''⟯) (g : C^n⟮I, M; I', M'⟯) (x : M) :\n  f.comp g x = f (g x) := rfl\n\ninstance [inhabited M'] : inhabited C^n⟮I, M; I', M'⟯ :=\n⟨⟨λ _, default, cont_mdiff_const⟩⟩\n\n/-- Constant map as a smooth map -/\ndef const (y : M') : C^n⟮I, M; I', M'⟯ := ⟨λ x, y, cont_mdiff_const⟩\n\nend cont_mdiff_map\n\ninstance continuous_linear_map.has_coe_to_cont_mdiff_map :\n  has_coe (E →L[𝕜] E') C^n⟮𝓘(𝕜, E), E; 𝓘(𝕜, E'), E'⟯ :=\n⟨λ f, ⟨f.to_fun, f.cont_mdiff⟩⟩\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/geometry/manifold/cont_mdiff_map.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.49359306752937965}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.limits.shapes.finite_limits\n! leanprover-community/mathlib commit f47581155c818e6361af4e4fda60d27d020c226b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.FinCategory\nimport Mathbin.CategoryTheory.Limits.Shapes.BinaryProducts\nimport Mathbin.CategoryTheory.Limits.Shapes.Equalizers\nimport Mathbin.CategoryTheory.Limits.Shapes.WidePullbacks\nimport Mathbin.CategoryTheory.Limits.Shapes.Pullbacks\nimport Mathbin.Data.Fintype.Option\n\n/-!\n# Categories with finite limits.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA typeclass for categories with all finite (co)limits.\n-/\n\n\nuniverse w' w v' u' v u\n\nnoncomputable section\n\nopen CategoryTheory\n\nnamespace CategoryTheory.Limits\n\nvariable (C : Type u) [Category.{v} C]\n\n#print CategoryTheory.Limits.HasFiniteLimits /-\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\n/-- A category has all finite limits if every functor `J ⥤ C` with a `fin_category J`\ninstance and `J : Type` has a limit.\n\nThis is often called 'finitely complete'.\n-/\nclass HasFiniteLimits : Prop where\n  out (J : Type) [𝒥 : SmallCategory J] [@FinCategory J 𝒥] : @HasLimitsOfShape J 𝒥 C _\n#align category_theory.limits.has_finite_limits CategoryTheory.Limits.HasFiniteLimits\n-/\n\n#print CategoryTheory.Limits.hasLimitsOfShape_of_hasFiniteLimits /-\ninstance (priority := 100) hasLimitsOfShape_of_hasFiniteLimits (J : Type w) [SmallCategory J]\n    [FinCategory J] [HasFiniteLimits C] : HasLimitsOfShape J C :=\n  by\n  apply has_limits_of_shape_of_equivalence (fin_category.equiv_as_type J)\n  apply has_finite_limits.out\n#align category_theory.limits.has_limits_of_shape_of_has_finite_limits CategoryTheory.Limits.hasLimitsOfShape_of_hasFiniteLimits\n-/\n\n#print CategoryTheory.Limits.hasFiniteLimits_of_hasLimitsOfSize /-\ninstance (priority := 100) hasFiniteLimits_of_hasLimitsOfSize [HasLimitsOfSize.{v', u'} C] :\n    HasFiniteLimits C :=\n  ⟨fun J hJ hJ' =>\n    haveI := hasLimitsOfSizeShrink.{0, 0} C\n    has_limits_of_shape_of_equivalence (fin_category.equiv_as_type J)⟩\n#align category_theory.limits.has_finite_limits_of_has_limits_of_size CategoryTheory.Limits.hasFiniteLimits_of_hasLimitsOfSize\n-/\n\n#print CategoryTheory.Limits.hasFiniteLimits_of_hasLimits /-\n/-- If `C` has all limits, it has finite limits. -/\ninstance (priority := 100) hasFiniteLimits_of_hasLimits [HasLimits C] : HasFiniteLimits C :=\n  inferInstance\n#align category_theory.limits.has_finite_limits_of_has_limits CategoryTheory.Limits.hasFiniteLimits_of_hasLimits\n-/\n\n#print CategoryTheory.Limits.hasFiniteLimits_of_hasFiniteLimits_of_size /-\n/-- We can always derive `has_finite_limits C` by providing limits at an\narbitrary universe. -/\ntheorem hasFiniteLimits_of_hasFiniteLimits_of_size\n    (h :\n      ∀ (J : Type w) {𝒥 : SmallCategory J} (hJ : @FinCategory J 𝒥),\n        by\n        skip\n        exact has_limits_of_shape J C) :\n    HasFiniteLimits C :=\n  ⟨fun J hJ hhJ => by\n    skip\n    let this : Category.{w, w} (ULiftHom.{w} (ULift.{w, 0} J)) :=\n      by\n      apply ULiftHom.category.{0}\n      exact CategoryTheory.uliftCategory J\n    haveI := h (ULiftHom.{w} (ULift.{w} J)) CategoryTheory.finCategoryUlift\n    exact has_limits_of_shape_of_equivalence (ULiftHomULiftCategory.equiv.{w, w} J).symm⟩\n#align category_theory.limits.has_finite_limits_of_has_finite_limits_of_size CategoryTheory.Limits.hasFiniteLimits_of_hasFiniteLimits_of_size\n-/\n\n#print CategoryTheory.Limits.HasFiniteColimits /-\n/-- A category has all finite colimits if every functor `J ⥤ C` with a `fin_category J`\ninstance and `J : Type` has a colimit.\n\nThis is often called 'finitely cocomplete'.\n-/\nclass HasFiniteColimits : Prop where\n  out (J : Type) [𝒥 : SmallCategory J] [@FinCategory J 𝒥] : @HasColimitsOfShape J 𝒥 C _\n#align category_theory.limits.has_finite_colimits CategoryTheory.Limits.HasFiniteColimits\n-/\n\n#print CategoryTheory.Limits.hasColimitsOfShape_of_hasFiniteColimits /-\ninstance (priority := 100) hasColimitsOfShape_of_hasFiniteColimits (J : Type w) [SmallCategory J]\n    [FinCategory J] [HasFiniteColimits C] : HasColimitsOfShape J C :=\n  by\n  apply has_colimits_of_shape_of_equivalence (fin_category.equiv_as_type J)\n  apply has_finite_colimits.out\n#align category_theory.limits.has_colimits_of_shape_of_has_finite_colimits CategoryTheory.Limits.hasColimitsOfShape_of_hasFiniteColimits\n-/\n\n#print CategoryTheory.Limits.hasFiniteColimits_of_hasColimitsOfSize /-\ninstance (priority := 100) hasFiniteColimits_of_hasColimitsOfSize [HasColimitsOfSize.{v', u'} C] :\n    HasFiniteColimits C :=\n  ⟨fun J hJ hJ' =>\n    haveI := hasColimitsOfSize_shrink.{0, 0} C\n    has_colimits_of_shape_of_equivalence (fin_category.equiv_as_type J)⟩\n#align category_theory.limits.has_finite_colimits_of_has_colimits_of_size CategoryTheory.Limits.hasFiniteColimits_of_hasColimitsOfSize\n-/\n\n#print CategoryTheory.Limits.hasFiniteColimits_of_hasFiniteColimits_of_size /-\n/-- We can always derive `has_finite_colimits C` by providing colimits at an\narbitrary universe. -/\ntheorem hasFiniteColimits_of_hasFiniteColimits_of_size\n    (h :\n      ∀ (J : Type w) {𝒥 : SmallCategory J} (hJ : @FinCategory J 𝒥),\n        by\n        skip\n        exact has_colimits_of_shape J C) :\n    HasFiniteColimits C :=\n  ⟨fun J hJ hhJ => by\n    skip\n    let this : Category.{w, w} (ULiftHom.{w} (ULift.{w, 0} J)) :=\n      by\n      apply ULiftHom.category.{0}\n      exact CategoryTheory.uliftCategory J\n    haveI := h (ULiftHom.{w} (ULift.{w} J)) CategoryTheory.finCategoryUlift\n    exact has_colimits_of_shape_of_equivalence (ULiftHomULiftCategory.equiv.{w, w} J).symm⟩\n#align category_theory.limits.has_finite_colimits_of_has_finite_colimits_of_size CategoryTheory.Limits.hasFiniteColimits_of_hasFiniteColimits_of_size\n-/\n\nsection\n\nopen WalkingParallelPair WalkingParallelPairHom\n\n#print CategoryTheory.Limits.fintypeWalkingParallelPair /-\ninstance fintypeWalkingParallelPair : Fintype WalkingParallelPair\n    where\n  elems := [WalkingParallelPair.zero, WalkingParallelPair.one].toFinset\n  complete x := by cases x <;> simp\n#align category_theory.limits.fintype_walking_parallel_pair CategoryTheory.Limits.fintypeWalkingParallelPair\n-/\n\nattribute [local tidy] tactic.case_bash\n\ninstance (j j' : WalkingParallelPair) : Fintype (WalkingParallelPairHom j j')\n    where\n  elems :=\n    WalkingParallelPair.recOn j\n      (WalkingParallelPair.recOn j' [WalkingParallelPairHom.id zero].toFinset\n        [left, right].toFinset)\n      (WalkingParallelPair.recOn j' ∅ [WalkingParallelPairHom.id one].toFinset)\n  complete := by tidy\n\nend\n\ninstance : FinCategory WalkingParallelPair where\n\n/-- Equalizers are finite limits, so if `C` has all finite limits, it also has all equalizers -/\nexample [HasFiniteLimits C] : HasEqualizers C := by infer_instance\n\n/-- Coequalizers are finite colimits, of if `C` has all finite colimits, it also has all\n    coequalizers -/\nexample [HasFiniteColimits C] : HasCoequalizers C := by infer_instance\n\nvariable {J : Type v}\n\nattribute [local tidy] tactic.case_bash\n\nnamespace WidePullbackShape\n\n#print CategoryTheory.Limits.WidePullbackShape.fintypeObj /-\ninstance fintypeObj [Fintype J] : Fintype (WidePullbackShape J) :=\n  by\n  rw [wide_pullback_shape]\n  infer_instance\n#align category_theory.limits.wide_pullback_shape.fintype_obj CategoryTheory.Limits.WidePullbackShape.fintypeObj\n-/\n\n#print CategoryTheory.Limits.WidePullbackShape.fintypeHom /-\ninstance fintypeHom (j j' : WidePullbackShape J) : Fintype (j ⟶ j')\n    where\n  elems := by\n    cases j'\n    · cases j\n      · exact {hom.id none}\n      · exact {hom.term j}\n    · by_cases some j' = j\n      · rw [h]\n        exact {hom.id j}\n      · exact ∅\n  complete := by tidy\n#align category_theory.limits.wide_pullback_shape.fintype_hom CategoryTheory.Limits.WidePullbackShape.fintypeHom\n-/\n\nend WidePullbackShape\n\nnamespace WidePushoutShape\n\n#print CategoryTheory.Limits.WidePushoutShape.fintypeObj /-\ninstance fintypeObj [Fintype J] : Fintype (WidePushoutShape J) :=\n  by\n  rw [wide_pushout_shape]\n  infer_instance\n#align category_theory.limits.wide_pushout_shape.fintype_obj CategoryTheory.Limits.WidePushoutShape.fintypeObj\n-/\n\n#print CategoryTheory.Limits.WidePushoutShape.fintypeHom /-\ninstance fintypeHom (j j' : WidePushoutShape J) : Fintype (j ⟶ j')\n    where\n  elems := by\n    cases j\n    · cases j'\n      · exact {hom.id none}\n      · exact {hom.init j'}\n    · by_cases some j = j'\n      · rw [h]\n        exact {hom.id j'}\n      · exact ∅\n  complete := by tidy\n#align category_theory.limits.wide_pushout_shape.fintype_hom CategoryTheory.Limits.WidePushoutShape.fintypeHom\n-/\n\nend WidePushoutShape\n\n#print CategoryTheory.Limits.finCategoryWidePullback /-\ninstance finCategoryWidePullback [Fintype J] : FinCategory (WidePullbackShape J)\n    where fintypeHom := WidePullbackShape.fintypeHom\n#align category_theory.limits.fin_category_wide_pullback CategoryTheory.Limits.finCategoryWidePullback\n-/\n\n#print CategoryTheory.Limits.finCategoryWidePushout /-\ninstance finCategoryWidePushout [Fintype J] : FinCategory (WidePushoutShape J)\n    where fintypeHom := WidePushoutShape.fintypeHom\n#align category_theory.limits.fin_category_wide_pushout CategoryTheory.Limits.finCategoryWidePushout\n-/\n\n#print CategoryTheory.Limits.HasFiniteWidePullbacks /-\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\n/-- `has_finite_wide_pullbacks` represents a choice of wide pullback\nfor every finite collection of morphisms\n-/\nclass HasFiniteWidePullbacks : Prop where\n  out (J : Type) [Fintype J] : HasLimitsOfShape (WidePullbackShape J) C\n#align category_theory.limits.has_finite_wide_pullbacks CategoryTheory.Limits.HasFiniteWidePullbacks\n-/\n\n#print CategoryTheory.Limits.hasLimitsOfShape_widePullbackShape /-\ninstance hasLimitsOfShape_widePullbackShape (J : Type) [Finite J] [HasFiniteWidePullbacks C] :\n    HasLimitsOfShape (WidePullbackShape J) C :=\n  by\n  cases nonempty_fintype J\n  haveI := @has_finite_wide_pullbacks.out C _ _ J\n  infer_instance\n#align category_theory.limits.has_limits_of_shape_wide_pullback_shape CategoryTheory.Limits.hasLimitsOfShape_widePullbackShape\n-/\n\n#print CategoryTheory.Limits.HasFiniteWidePushouts /-\n/-- `has_finite_wide_pushouts` represents a choice of wide pushout\nfor every finite collection of morphisms\n-/\nclass HasFiniteWidePushouts : Prop where\n  out (J : Type) [Fintype J] : HasColimitsOfShape (WidePushoutShape J) C\n#align category_theory.limits.has_finite_wide_pushouts CategoryTheory.Limits.HasFiniteWidePushouts\n-/\n\n#print CategoryTheory.Limits.hasColimitsOfShape_widePushoutShape /-\ninstance hasColimitsOfShape_widePushoutShape (J : Type) [Finite J] [HasFiniteWidePushouts C] :\n    HasColimitsOfShape (WidePushoutShape J) C :=\n  by\n  cases nonempty_fintype J\n  haveI := @has_finite_wide_pushouts.out C _ _ J\n  infer_instance\n#align category_theory.limits.has_colimits_of_shape_wide_pushout_shape CategoryTheory.Limits.hasColimitsOfShape_widePushoutShape\n-/\n\n#print CategoryTheory.Limits.hasFiniteWidePullbacks_of_hasFiniteLimits /-\n/-- Finite wide pullbacks are finite limits, so if `C` has all finite limits,\nit also has finite wide pullbacks\n-/\ntheorem hasFiniteWidePullbacks_of_hasFiniteLimits [HasFiniteLimits C] : HasFiniteWidePullbacks C :=\n  ⟨fun J _ => has_finite_limits.out _⟩\n#align category_theory.limits.has_finite_wide_pullbacks_of_has_finite_limits CategoryTheory.Limits.hasFiniteWidePullbacks_of_hasFiniteLimits\n-/\n\n#print CategoryTheory.Limits.hasFiniteWidePushouts_of_has_finite_limits /-\n/-- Finite wide pushouts are finite colimits, so if `C` has all finite colimits,\nit also has finite wide pushouts\n-/\ntheorem hasFiniteWidePushouts_of_has_finite_limits [HasFiniteColimits C] :\n    HasFiniteWidePushouts C :=\n  ⟨fun J _ => has_finite_colimits.out _⟩\n#align category_theory.limits.has_finite_wide_pushouts_of_has_finite_limits CategoryTheory.Limits.hasFiniteWidePushouts_of_has_finite_limits\n-/\n\n#print CategoryTheory.Limits.fintypeWalkingPair /-\ninstance fintypeWalkingPair : Fintype WalkingPair\n    where\n  elems := {WalkingPair.left, WalkingPair.right}\n  complete x := by cases x <;> simp\n#align category_theory.limits.fintype_walking_pair CategoryTheory.Limits.fintypeWalkingPair\n-/\n\n/-- Pullbacks are finite limits, so if `C` has all finite limits, it also has all pullbacks -/\nexample [HasFiniteWidePullbacks C] : HasPullbacks C := by infer_instance\n\n/-- Pushouts are finite colimits, so if `C` has all finite colimits, it also has all pushouts -/\nexample [HasFiniteWidePushouts C] : HasPushouts C := by infer_instance\n\nend CategoryTheory.Limits\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Shapes/FiniteLimits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4935930604035838}}
{"text": "/-\nCopyright (c) 2018 Ellen Arlt. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.big_operators.pi\nimport Mathlib.algebra.module.pi\nimport Mathlib.algebra.module.linear_map\nimport Mathlib.algebra.big_operators.ring\nimport Mathlib.algebra.star.basic\nimport Mathlib.data.equiv.ring\nimport Mathlib.data.fintype.card\nimport Mathlib.PostPort\n\nuniverses u u' v u_2 u_3 w u_1 u_4 u_5 u_6 \n\nnamespace Mathlib\n\n/-!\n# Matrices\n-/\n\n/-- `matrix m n` is the type of matrices whose rows are indexed by the fintype `m`\n    and whose columns are indexed by the fintype `n`. -/\ndef matrix (m : Type u) (n : Type u') [fintype m] [fintype n] (α : Type v) :=\n  m → n → α\n\nnamespace matrix\n\n\ntheorem ext_iff {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix m n α} {N : matrix m n α} : (∀ (i : m) (j : n), M i j = N i j) ↔ M = N := sorry\n\ntheorem ext {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix m n α} {N : matrix m n α} : (∀ (i : m) (j : n), M i j = N i j) → M = N :=\n  iff.mp ext_iff\n\n/-- `M.map f` is the matrix obtained by applying `f` to each entry of the matrix `M`. -/\ndef map {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} (M : matrix m n α) {β : Type w} (f : α → β) : matrix m n β :=\n  fun (i : m) (j : n) => f (M i j)\n\n@[simp] theorem map_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix m n α} {β : Type w} {f : α → β} {i : m} {j : n} : map M f i j = f (M i j) :=\n  rfl\n\n@[simp] theorem map_map {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix m n α} {β : Type u_1} {γ : Type u_4} {f : α → β} {g : β → γ} : map (map M f) g = map M (g ∘ f) := sorry\n\n/-- The transpose of a matrix. -/\ndef transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} (M : matrix m n α) : matrix n m α :=\n  sorry\n\n/-- `matrix.col u` is the column matrix whose entries are given by `u`. -/\ndef col {m : Type u_2} [fintype m] {α : Type v} (w : m → α) : matrix m Unit α :=\n  sorry\n\n/-- `matrix.row u` is the row matrix whose entries are given by `u`. -/\ndef row {n : Type u_3} [fintype n] {α : Type v} (v : n → α) : matrix Unit n α :=\n  sorry\n\nprotected instance inhabited {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Inhabited α] : Inhabited (matrix m n α) :=\n  pi.inhabited m\n\nprotected instance has_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Add α] : Add (matrix m n α) :=\n  pi.has_add\n\nprotected instance add_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_semigroup α] : add_semigroup (matrix m n α) :=\n  pi.add_semigroup\n\nprotected instance add_comm_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_comm_semigroup α] : add_comm_semigroup (matrix m n α) :=\n  pi.add_comm_semigroup\n\nprotected instance has_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [HasZero α] : HasZero (matrix m n α) :=\n  pi.has_zero\n\nprotected instance add_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_monoid α] : add_monoid (matrix m n α) :=\n  pi.add_monoid\n\nprotected instance add_comm_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_comm_monoid α] : add_comm_monoid (matrix m n α) :=\n  pi.add_comm_monoid\n\nprotected instance has_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Neg α] : Neg (matrix m n α) :=\n  pi.has_neg\n\nprotected instance has_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Sub α] : Sub (matrix m n α) :=\n  pi.has_sub\n\nprotected instance add_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_group α] : add_group (matrix m n α) :=\n  pi.add_group\n\nprotected instance add_comm_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_comm_group α] : add_comm_group (matrix m n α) :=\n  pi.add_comm_group\n\n@[simp] theorem zero_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [HasZero α] (i : m) (j : n) : HasZero.zero i j = 0 :=\n  rfl\n\n@[simp] theorem neg_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Neg α] (M : matrix m n α) (i : m) (j : n) : Neg.neg M i j = -M i j :=\n  rfl\n\n@[simp] theorem add_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Add α] (M : matrix m n α) (N : matrix m n α) (i : m) (j : n) : Add.add M N i j = M i j + N i j :=\n  rfl\n\n@[simp] theorem sub_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Sub α] (M : matrix m n α) (N : matrix m n α) (i : m) (j : n) : Sub.sub M N i j = M i j - N i j :=\n  rfl\n\n@[simp] theorem map_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [HasZero α] {β : Type w} [HasZero β] {f : α → β} (h : f 0 = 0) : map 0 f = 0 := sorry\n\ntheorem map_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_monoid α] {β : Type w} [add_monoid β] (f : α →+ β) (M : matrix m n α) (N : matrix m n α) : map (M + N) ⇑f = map M ⇑f + map N ⇑f := sorry\n\ntheorem map_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_group α] {β : Type w} [add_group β] (f : α →+ β) (M : matrix m n α) (N : matrix m n α) : map (M - N) ⇑f = map M ⇑f - map N ⇑f := sorry\n\ntheorem subsingleton_of_empty_left {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} (hm : ¬Nonempty m) : subsingleton (matrix m n α) := sorry\n\ntheorem subsingleton_of_empty_right {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} (hn : ¬Nonempty n) : subsingleton (matrix m n α) := sorry\n\nend matrix\n\n\n/-- The `add_monoid_hom` between spaces of matrices induced by an `add_monoid_hom` between their\ncoefficients. -/\ndef add_monoid_hom.map_matrix {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_monoid α] {β : Type w} [add_monoid β] (f : α →+ β) : matrix m n α →+ matrix m n β :=\n  add_monoid_hom.mk (fun (M : matrix m n α) => matrix.map M ⇑f) sorry (matrix.map_add f)\n\n@[simp] theorem add_monoid_hom.map_matrix_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_monoid α] {β : Type w} [add_monoid β] (f : α →+ β) (M : matrix m n α) : coe_fn (add_monoid_hom.map_matrix f) M = matrix.map M ⇑f :=\n  rfl\n\nnamespace matrix\n\n\n/-- `diagonal d` is the square matrix such that `(diagonal d) i i = d i` and `(diagonal d) i j = 0`\nif `i ≠ j`. -/\ndef diagonal {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] (d : n → α) : matrix n n α :=\n  fun (i j : n) => ite (i = j) (d i) 0\n\n@[simp] theorem diagonal_apply_eq {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] {d : n → α} (i : n) : diagonal d i i = d i := sorry\n\n@[simp] theorem diagonal_apply_ne {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] {d : n → α} {i : n} {j : n} (h : i ≠ j) : diagonal d i j = 0 := sorry\n\ntheorem diagonal_apply_ne' {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] {d : n → α} {i : n} {j : n} (h : j ≠ i) : diagonal d i j = 0 :=\n  diagonal_apply_ne (ne.symm h)\n\n@[simp] theorem diagonal_zero {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] : (diagonal fun (_x : n) => 0) = 0 := sorry\n\n@[simp] theorem diagonal_transpose {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] (v : n → α) : transpose (diagonal v) = diagonal v := sorry\n\n@[simp] theorem diagonal_add {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α] (d₁ : n → α) (d₂ : n → α) : diagonal d₁ + diagonal d₂ = diagonal fun (i : n) => d₁ i + d₂ i := sorry\n\n@[simp] theorem diagonal_map {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] {β : Type w} [HasZero α] [HasZero β] {f : α → β} (h : f 0 = 0) {d : n → α} : map (diagonal d) f = diagonal fun (m : n) => f (d m) := sorry\n\nprotected instance has_one {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] : HasOne (matrix n n α) :=\n  { one := diagonal fun (_x : n) => 1 }\n\n@[simp] theorem diagonal_one {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] : (diagonal fun (_x : n) => 1) = 1 :=\n  rfl\n\ntheorem one_apply {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] {i : n} {j : n} : HasOne.one i j = ite (i = j) 1 0 :=\n  rfl\n\n@[simp] theorem one_apply_eq {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] (i : n) : HasOne.one i i = 1 :=\n  diagonal_apply_eq i\n\n@[simp] theorem one_apply_ne {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] {i : n} {j : n} : i ≠ j → HasOne.one i j = 0 :=\n  diagonal_apply_ne\n\ntheorem one_apply_ne' {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] {i : n} {j : n} : j ≠ i → HasOne.one i j = 0 :=\n  diagonal_apply_ne'\n\n@[simp] theorem one_map {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] {β : Type w} [HasZero β] [HasOne β] {f : α → β} (h₀ : f 0 = 0) (h₁ : f 1 = 1) : map 1 f = 1 := sorry\n\n@[simp] theorem bit0_apply {m : Type u_2} [fintype m] {α : Type v} [Add α] (M : matrix m m α) (i : m) (j : m) : bit0 M i j = bit0 (M i j) :=\n  rfl\n\ntheorem bit1_apply {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α] [HasOne α] (M : matrix n n α) (i : n) (j : n) : bit1 M i j = ite (i = j) (bit1 (M i j)) (bit0 (M i j)) := sorry\n\n@[simp] theorem bit1_apply_eq {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α] [HasOne α] (M : matrix n n α) (i : n) : bit1 M i i = bit1 (M i i) := sorry\n\n@[simp] theorem bit1_apply_ne {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α] [HasOne α] (M : matrix n n α) {i : n} {j : n} (h : i ≠ j) : bit1 M i j = bit0 (M i j) := sorry\n\n/-- `dot_product v w` is the sum of the entrywise products `v i * w i` -/\ndef dot_product {m : Type u_2} [fintype m] {α : Type v} [Mul α] [add_comm_monoid α] (v : m → α) (w : m → α) : α :=\n  finset.sum finset.univ fun (i : m) => v i * w i\n\ntheorem dot_product_assoc {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (u : m → α) (v : m → n → α) (w : n → α) : dot_product (fun (j : n) => dot_product u fun (i : m) => v i j) w = dot_product u fun (i : m) => dot_product (v i) w := sorry\n\ntheorem dot_product_comm {m : Type u_2} [fintype m] {α : Type v} [comm_semiring α] (v : m → α) (w : m → α) : dot_product v w = dot_product w v := sorry\n\n@[simp] theorem dot_product_punit {α : Type v} [add_comm_monoid α] [Mul α] (v : PUnit → α) (w : PUnit → α) : dot_product v w = v PUnit.unit * w PUnit.unit := sorry\n\n@[simp] theorem dot_product_zero {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) : dot_product v 0 = 0 := sorry\n\n@[simp] theorem dot_product_zero' {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) : (dot_product v fun (_x : m) => 0) = 0 :=\n  dot_product_zero v\n\n@[simp] theorem zero_dot_product {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) : dot_product 0 v = 0 := sorry\n\n@[simp] theorem zero_dot_product' {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) : dot_product (fun (_x : m) => 0) v = 0 :=\n  zero_dot_product v\n\n@[simp] theorem add_dot_product {m : Type u_2} [fintype m] {α : Type v} [semiring α] (u : m → α) (v : m → α) (w : m → α) : dot_product (u + v) w = dot_product u w + dot_product v w := sorry\n\n@[simp] theorem dot_product_add {m : Type u_2} [fintype m] {α : Type v} [semiring α] (u : m → α) (v : m → α) (w : m → α) : dot_product u (v + w) = dot_product u v + dot_product u w := sorry\n\n@[simp] theorem diagonal_dot_product {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m] [semiring α] (v : m → α) (w : m → α) (i : m) : dot_product (diagonal v i) w = v i * w i := sorry\n\n@[simp] theorem dot_product_diagonal {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m] [semiring α] (v : m → α) (w : m → α) (i : m) : dot_product v (diagonal w i) = v i * w i := sorry\n\n@[simp] theorem dot_product_diagonal' {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m] [semiring α] (v : m → α) (w : m → α) (i : m) : (dot_product v fun (j : m) => diagonal w j i) = v i * w i := sorry\n\n@[simp] theorem neg_dot_product {m : Type u_2} [fintype m] {α : Type v} [ring α] (v : m → α) (w : m → α) : dot_product (-v) w = -dot_product v w := sorry\n\n@[simp] theorem dot_product_neg {m : Type u_2} [fintype m] {α : Type v} [ring α] (v : m → α) (w : m → α) : dot_product v (-w) = -dot_product v w := sorry\n\n@[simp] theorem smul_dot_product {m : Type u_2} [fintype m] {α : Type v} [semiring α] (x : α) (v : m → α) (w : m → α) : dot_product (x • v) w = x * dot_product v w := sorry\n\n@[simp] theorem dot_product_smul {m : Type u_2} [fintype m] {α : Type v} [comm_semiring α] (x : α) (v : m → α) (w : m → α) : dot_product v (x • w) = x * dot_product v w := sorry\n\n/-- `M ⬝ N` is the usual product of matrices `M` and `N`, i.e. we have that\n    `(M ⬝ N) i k` is the dot product of the `i`-th row of `M` by the `k`-th column of `Ǹ`. -/\nprotected def mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [Mul α] [add_comm_monoid α] (M : matrix l m α) (N : matrix m n α) : matrix l n α :=\n  fun (i : l) (k : n) => dot_product (fun (j : m) => M i j) fun (j : m) => N j k\n\ntheorem mul_apply {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [Mul α] [add_comm_monoid α] {M : matrix l m α} {N : matrix m n α} {i : l} {k : n} : matrix.mul M N i k = finset.sum finset.univ fun (j : m) => M i j * N j k :=\n  rfl\n\nprotected instance has_mul {n : Type u_3} [fintype n] {α : Type v} [Mul α] [add_comm_monoid α] : Mul (matrix n n α) :=\n  { mul := matrix.mul }\n\n@[simp] theorem mul_eq_mul {n : Type u_3} [fintype n] {α : Type v} [Mul α] [add_comm_monoid α] (M : matrix n n α) (N : matrix n n α) : M * N = matrix.mul M N :=\n  rfl\n\ntheorem mul_apply' {n : Type u_3} [fintype n] {α : Type v} [Mul α] [add_comm_monoid α] {M : matrix n n α} {N : matrix n n α} {i : n} {k : n} : matrix.mul M N i k = dot_product (fun (j : n) => M i j) fun (j : n) => N j k :=\n  rfl\n\nprotected theorem mul_assoc {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (L : matrix l m α) (M : matrix m n α) (N : matrix n o α) : matrix.mul (matrix.mul L M) N = matrix.mul L (matrix.mul M N) :=\n  ext\n    fun (i : l) (j : o) =>\n      dot_product_assoc (fun (j : m) => L i j) (fun (i : m) (j : n) => M i j) fun (j_1 : n) => N j_1 j\n\nprotected instance semigroup {n : Type u_3} [fintype n] {α : Type v} [semiring α] : semigroup (matrix n n α) :=\n  semigroup.mk Mul.mul matrix.mul_assoc\n\n@[simp] theorem diagonal_neg {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_group α] (d : n → α) : -diagonal d = diagonal fun (i : n) => -d i := sorry\n\n@[simp] protected theorem mul_zero {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (M : matrix m n α) : matrix.mul M 0 = 0 :=\n  ext fun (i : m) (j : o) => dot_product_zero fun (j : n) => M i j\n\n@[simp] protected theorem zero_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) : matrix.mul 0 M = 0 :=\n  ext fun (i : l) (j : n) => zero_dot_product fun (j_1 : m) => M j_1 j\n\nprotected theorem mul_add {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (L : matrix m n α) (M : matrix n o α) (N : matrix n o α) : matrix.mul L (M + N) = matrix.mul L M + matrix.mul L N :=\n  ext fun (i : m) (j : o) => dot_product_add (fun (j : n) => L i j) (fun (i : n) => M i j) fun (i : n) => N i j\n\nprotected theorem add_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [semiring α] (L : matrix l m α) (M : matrix l m α) (N : matrix m n α) : matrix.mul (L + M) N = matrix.mul L N + matrix.mul M N :=\n  ext\n    fun (i : l) (j : n) => add_dot_product (fun (i_1 : m) => L i i_1) (fun (i_1 : m) => M i i_1) fun (j_1 : m) => N j_1 j\n\n@[simp] theorem diagonal_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] (d : m → α) (M : matrix m n α) (i : m) (j : n) : matrix.mul (diagonal d) M i j = d i * M i j :=\n  diagonal_dot_product (fun (i : m) => d i) (fun (j_1 : m) => M j_1 j) i\n\n@[simp] theorem mul_diagonal {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq n] (d : n → α) (M : matrix m n α) (i : m) (j : n) : matrix.mul M (diagonal d) i j = M i j * d j :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (matrix.mul M (diagonal d) i j = M i j * d j)) (Eq.symm (diagonal_transpose d))))\n    (dot_product_diagonal (fun (j : n) => M i j) (fun (j : n) => d j) j)\n\n@[simp] protected theorem one_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] (M : matrix m n α) : matrix.mul 1 M = M := sorry\n\n@[simp] protected theorem mul_one {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq n] (M : matrix m n α) : matrix.mul M 1 = M := sorry\n\nprotected instance monoid {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] : monoid (matrix n n α) :=\n  monoid.mk semigroup.mul sorry 1 sorry sorry\n\nprotected instance semiring {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] : semiring (matrix n n α) :=\n  semiring.mk add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry sorry monoid.mul sorry monoid.one sorry sorry\n    matrix.zero_mul matrix.mul_zero matrix.mul_add matrix.add_mul\n\n@[simp] theorem diagonal_mul_diagonal {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] (d₁ : n → α) (d₂ : n → α) : matrix.mul (diagonal d₁) (diagonal d₂) = diagonal fun (i : n) => d₁ i * d₂ i := sorry\n\ntheorem diagonal_mul_diagonal' {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] (d₁ : n → α) (d₂ : n → α) : diagonal d₁ * diagonal d₂ = diagonal fun (i : n) => d₁ i * d₂ i :=\n  diagonal_mul_diagonal d₁ d₂\n\n@[simp] theorem map_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] {L : matrix m n α} {M : matrix n o α} {β : Type w} [semiring β] {f : α →+* β} : map (matrix.mul L M) ⇑f = matrix.mul (map L ⇑f) (map M ⇑f) := sorry\n\n-- TODO: there should be a way to avoid restating these for each `foo_hom`. \n\n/-- A version of `one_map` where `f` is a ring hom. -/\n@[simp] theorem ring_hom_map_one {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] {β : Type w} [semiring β] (f : α →+* β) : map 1 ⇑f = 1 :=\n  one_map (ring_hom.map_zero f) (ring_hom.map_one f)\n\n/-- A version of `one_map` where `f` is a `ring_equiv`. -/\n@[simp] theorem ring_equiv_map_one {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] {β : Type w} [semiring β] (f : α ≃+* β) : map 1 ⇑f = 1 :=\n  one_map (ring_equiv.map_zero f) (ring_equiv.map_one f)\n\n/-- A version of `map_zero` where `f` is a `zero_hom`. -/\n@[simp] theorem zero_hom_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w} [HasZero β] (f : zero_hom α β) : map 0 ⇑f = 0 :=\n  map_zero (zero_hom.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `add_monoid_hom`. -/\n@[simp] theorem add_monoid_hom_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w} [add_monoid β] (f : α →+ β) : map 0 ⇑f = 0 :=\n  map_zero (add_monoid_hom.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `add_equiv`. -/\n@[simp] theorem add_equiv_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w} [add_monoid β] (f : α ≃+ β) : map 0 ⇑f = 0 :=\n  map_zero (add_equiv.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `linear_map`. -/\n@[simp] theorem linear_map_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {R : Type u_1} [semiring R] {β : Type w} [add_comm_monoid β] [semimodule R α] [semimodule R β] (f : linear_map R α β) : map 0 ⇑f = 0 :=\n  map_zero (linear_map.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `linear_equiv`. -/\n@[simp] theorem linear_equiv_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {R : Type u_1} [semiring R] {β : Type w} [add_comm_monoid β] [semimodule R α] [semimodule R β] (f : linear_equiv R α β) : map 0 ⇑f = 0 :=\n  map_zero (linear_equiv.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `ring_hom`. -/\n@[simp] theorem ring_hom_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w} [semiring β] (f : α →+* β) : map 0 ⇑f = 0 :=\n  map_zero (ring_hom.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `ring_equiv`. -/\n@[simp] theorem ring_equiv_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w} [semiring β] (f : α ≃+* β) : map 0 ⇑f = 0 :=\n  map_zero (ring_equiv.map_zero f)\n\ntheorem is_add_monoid_hom_mul_left {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix l m α) : is_add_monoid_hom fun (x : matrix m n α) => matrix.mul M x :=\n  is_add_monoid_hom.mk (matrix.mul_zero M)\n\ntheorem is_add_monoid_hom_mul_right {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) : is_add_monoid_hom fun (x : matrix l m α) => matrix.mul x M :=\n  is_add_monoid_hom.mk (matrix.zero_mul M)\n\nprotected theorem sum_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [semiring α] {β : Type u_4} (s : finset β) (f : β → matrix l m α) (M : matrix m n α) : matrix.mul (finset.sum s fun (a : β) => f a) M = finset.sum s fun (a : β) => matrix.mul (f a) M :=\n  Eq.symm (finset.sum_hom s fun (x : matrix l m α) => matrix.mul x M)\n\n/- This line does not type-check without `id` and `: _`. Lean did not recognize that two different\n  `add_monoid` instances were def-eq -/\n\nprotected theorem mul_sum {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [semiring α] {β : Type u_4} (s : finset β) (f : β → matrix m n α) (M : matrix l m α) : matrix.mul M (finset.sum s fun (a : β) => f a) = finset.sum s fun (a : β) => matrix.mul M (f a) :=\n  Eq.symm (finset.sum_hom s fun (x : matrix m n α) => matrix.mul M x)\n\n/- This line does not type-check without `id` and `: _`. Lean did not recognize that two different\n  `add_monoid` instances were def-eq -/\n\n@[simp] theorem row_mul_col_apply {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) (w : m → α) (i : Unit) (j : Unit) : matrix.mul (row v) (col w) i j = dot_product v w :=\n  rfl\n\nend matrix\n\n\n/-- The `ring_hom` between spaces of square matrices induced by a `ring_hom` between their\ncoefficients. -/\ndef ring_hom.map_matrix {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m] [semiring α] {β : Type w} [semiring β] (f : α →+* β) : matrix m m α →+* matrix m m β :=\n  ring_hom.mk (fun (M : matrix m m α) => matrix.map M ⇑f) sorry sorry sorry sorry\n\n@[simp] theorem ring_hom.map_matrix_apply {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m] [semiring α] {β : Type w} [semiring β] (f : α →+* β) (M : matrix m m α) : coe_fn (ring_hom.map_matrix f) M = matrix.map M ⇑f :=\n  rfl\n\nnamespace matrix\n\n\n@[simp] theorem neg_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [ring α] (M : matrix m n α) (N : matrix n o α) : matrix.mul (-M) N = -matrix.mul M N :=\n  ext fun (i : m) (j : o) => neg_dot_product (fun (i_1 : n) => M i i_1) fun (j_1 : n) => N j_1 j\n\n@[simp] theorem mul_neg {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [ring α] (M : matrix m n α) (N : matrix n o α) : matrix.mul M (-N) = -matrix.mul M N :=\n  ext fun (i : m) (j : o) => dot_product_neg (fun (j : n) => M i j) fun (i : n) => N i j\n\nprotected theorem sub_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [ring α] (M : matrix m n α) (M' : matrix m n α) (N : matrix n o α) : matrix.mul (M - M') N = matrix.mul M N - matrix.mul M' N := sorry\n\nprotected theorem mul_sub {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [ring α] (M : matrix m n α) (N : matrix n o α) (N' : matrix n o α) : matrix.mul M (N - N') = matrix.mul M N - matrix.mul M N' := sorry\n\nprotected instance ring {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [ring α] : ring (matrix n n α) :=\n  ring.mk semiring.add sorry semiring.zero sorry sorry add_comm_group.neg add_comm_group.sub sorry sorry semiring.mul\n    sorry semiring.one sorry sorry sorry sorry\n\nprotected instance has_scalar {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] : has_scalar α (matrix m n α) :=\n  pi.has_scalar\n\nprotected instance semimodule {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {β : Type w} [semiring α] [add_comm_monoid β] [semimodule α β] : semimodule α (matrix m n β) :=\n  pi.semimodule m (fun (ᾰ : m) => n → β) α\n\n@[simp] theorem smul_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (a : α) (A : matrix m n α) (i : m) (j : n) : has_scalar.smul a A i j = a * A i j :=\n  rfl\n\ntheorem smul_eq_diagonal_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] (M : matrix m n α) (a : α) : a • M = matrix.mul (diagonal fun (_x : m) => a) M := sorry\n\n@[simp] theorem smul_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) (a : α) (N : matrix n l α) : matrix.mul (a • M) N = a • matrix.mul M N :=\n  ext fun (i : m) (j : l) => smul_dot_product a (fun (i_1 : n) => M i i_1) fun (j_1 : n) => N j_1 j\n\n@[simp] theorem mul_mul_left {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (M : matrix m n α) (N : matrix n o α) (a : α) : matrix.mul (fun (i : m) (j : n) => a * M i j) N = a • matrix.mul M N := sorry\n\n/--\nThe ring homomorphism `α →+* matrix n n α`\nsending `a` to the diagonal matrix with `a` on the diagonal.\n-/\ndef scalar {α : Type v} [semiring α] (n : Type u) [DecidableEq n] [fintype n] : α →+* matrix n n α :=\n  ring_hom.mk (fun (a : α) => a • 1) sorry sorry sorry sorry\n\n@[simp] theorem coe_scalar {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] : ⇑(scalar n) = fun (a : α) => a • 1 :=\n  rfl\n\ntheorem scalar_apply_eq {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] (a : α) (i : n) : coe_fn (scalar n) a i i = a := sorry\n\ntheorem scalar_apply_ne {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] (a : α) (i : n) (j : n) (h : i ≠ j) : coe_fn (scalar n) a i j = 0 := sorry\n\ntheorem scalar_inj {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] [Nonempty n] {r : α} {s : α} : coe_fn (scalar n) r = coe_fn (scalar n) s ↔ r = s := sorry\n\ntheorem smul_eq_mul_diagonal {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [comm_semiring α] [DecidableEq n] (M : matrix m n α) (a : α) : a • M = matrix.mul M (diagonal fun (_x : n) => a) := sorry\n\n@[simp] theorem mul_smul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [comm_semiring α] (M : matrix m n α) (a : α) (N : matrix n l α) : matrix.mul M (a • N) = a • matrix.mul M N :=\n  ext fun (i : m) (j : l) => dot_product_smul a (fun (j : n) => M i j) fun (i : n) => N i j\n\n@[simp] theorem mul_mul_right {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [comm_semiring α] (M : matrix m n α) (N : matrix n o α) (a : α) : (matrix.mul M fun (i : n) (j : o) => a * N i j) = a • matrix.mul M N := sorry\n\ntheorem scalar.commute {n : Type u_3} [fintype n] {α : Type v} [comm_semiring α] [DecidableEq n] (r : α) (M : matrix n n α) : commute (coe_fn (scalar n) r) M := sorry\n\n/-- For two vectors `w` and `v`, `vec_mul_vec w v i j` is defined to be `w i * v j`.\n    Put another way, `vec_mul_vec w v` is exactly `col w ⬝ row v`. -/\ndef vec_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (w : m → α) (v : n → α) : matrix m n α :=\n  sorry\n\n/-- `mul_vec M v` is the matrix-vector product of `M` and `v`, where `v` is seen as a column matrix.\n    Put another way, `mul_vec M v` is the vector whose entries\n    are those of `M ⬝ col v` (see `col_mul_vec`). -/\ndef mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) (v : n → α) : m → α :=\n  sorry\n\n/-- `vec_mul v M` is the vector-matrix product of `v` and `M`, where `v` is seen as a row matrix.\n    Put another way, `vec_mul v M` is the vector whose entries\n    are those of `row v ⬝ M` (see `row_vec_mul`). -/\ndef vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (v : m → α) (M : matrix m n α) : n → α :=\n  sorry\n\nprotected instance mul_vec.is_add_monoid_hom_left {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (v : n → α) : is_add_monoid_hom fun (M : matrix m n α) => mul_vec M v :=\n  is_add_monoid_hom.mk\n    (funext\n      fun (x : m) =>\n        eq.mpr\n          (id\n            (Eq.trans\n              ((fun (a a_1 : α) (e_1 : a = a_1) (ᾰ ᾰ_1 : α) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n                (mul_vec 0 v x) 0\n                (Eq.trans\n                  (Eq.trans (mul_vec.equations._eqn_1 0 v x)\n                    ((fun [_inst_2 : fintype n] {α : Type v} (v v_1 : n → α) (e_5 : v = v_1) (w w_1 : n → α)\n                        (e_6 : w = w_1) => eq.drec (eq.drec (Eq.refl (dot_product v w)) e_6) e_5)\n                      (fun (j : n) => HasZero.zero x j) (fun (j : n) => 0) (funext fun (j : n) => zero_apply x j) v v\n                      (Eq.refl v)))\n                  (zero_dot_product' v))\n                (HasZero.zero x) 0 (pi.zero_apply x))\n              (propext (eq_self_iff_true 0))))\n          trivial)\n\ntheorem mul_vec_diagonal {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m] (v : m → α) (w : m → α) (x : m) : mul_vec (diagonal v) w x = v x * w x :=\n  diagonal_dot_product v w x\n\ntheorem vec_mul_diagonal {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m] (v : m → α) (w : m → α) (x : m) : vec_mul v (diagonal w) x = v x * w x :=\n  dot_product_diagonal' v w x\n\n@[simp] theorem mul_vec_one {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m] (v : m → α) : mul_vec 1 v = v := sorry\n\n@[simp] theorem vec_mul_one {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m] (v : m → α) : vec_mul v 1 = v := sorry\n\n@[simp] theorem mul_vec_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (A : matrix m n α) : mul_vec A 0 = 0 := sorry\n\n@[simp] theorem vec_mul_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (A : matrix m n α) : vec_mul 0 A = 0 := sorry\n\n@[simp] theorem vec_mul_vec_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (v : m → α) (M : matrix m n α) (N : matrix n o α) : vec_mul (vec_mul v M) N = vec_mul v (matrix.mul M N) :=\n  funext fun (x : o) => dot_product_assoc v (fun (i : m) (j : n) => M i j) fun (i : n) => N i x\n\n@[simp] theorem mul_vec_mul_vec {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (v : o → α) (M : matrix m n α) (N : matrix n o α) : mul_vec M (mul_vec N v) = mul_vec (matrix.mul M N) v :=\n  funext fun (x : m) => Eq.symm (dot_product_assoc (fun (j : n) => M x j) (fun (i : n) (j : o) => N i j) v)\n\ntheorem vec_mul_vec_eq {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (w : m → α) (v : n → α) : vec_mul_vec w v = matrix.mul (col w) (row v) := sorry\n\n/--\n`std_basis_matrix i j a` is the matrix with `a` in the `i`-th row, `j`-th column,\nand zeroes elsewhere.\n-/\ndef std_basis_matrix {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : α) : matrix m n α :=\n  fun (i' : m) (j' : n) => ite (i' = i ∧ j' = j) a 0\n\n@[simp] theorem smul_std_basis_matrix {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : α) (b : α) : b • std_basis_matrix i j a = std_basis_matrix i j (b • a) := sorry\n\n@[simp] theorem std_basis_matrix_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] [DecidableEq n] (i : m) (j : n) : std_basis_matrix i j 0 = 0 := sorry\n\ntheorem std_basis_matrix_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : α) (b : α) : std_basis_matrix i j (a + b) = std_basis_matrix i j a + std_basis_matrix i j b := sorry\n\ntheorem matrix_eq_sum_std_basis {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] [DecidableEq m] [DecidableEq n] (x : matrix n m α) : x = finset.sum finset.univ fun (i : n) => finset.sum finset.univ fun (j : m) => std_basis_matrix i j (x i j) := sorry\n\n-- TODO: tie this up with the `basis` machinery of linear algebra\n\n-- this is not completely trivial because we are indexing by two types, instead of one\n\n-- TODO: add `std_basis_vec`\n\ntheorem std_basis_eq_basis_mul_basis {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] [DecidableEq m] [DecidableEq n] (i : m) (j : n) : std_basis_matrix i j 1 = vec_mul_vec (fun (i' : m) => ite (i = i') 1 0) fun (j' : n) => ite (j = j') 1 0 := sorry\n\nprotected theorem induction_on' {n : Type u_3} [fintype n] [DecidableEq n] {X : Type u_1} [semiring X] {M : matrix n n X → Prop} (m : matrix n n X) (h_zero : M 0) (h_add : ∀ (p q : matrix n n X), M p → M q → M (p + q)) (h_std_basis : ∀ (i j : n) (x : X), M (std_basis_matrix i j x)) : M m := sorry\n\nprotected theorem induction_on {n : Type u_3} [fintype n] [DecidableEq n] [Nonempty n] {X : Type u_1} [semiring X] {M : matrix n n X → Prop} (m : matrix n n X) (h_add : ∀ (p q : matrix n n X), M p → M q → M (p + q)) (h_std_basis : ∀ (i j : n) (x : X), M (std_basis_matrix i j x)) : M m := sorry\n\ntheorem neg_vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α] (v : m → α) (A : matrix m n α) : vec_mul (-v) A = -vec_mul v A :=\n  funext fun (x : n) => neg_dot_product v fun (i : m) => A i x\n\ntheorem vec_mul_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α] (v : m → α) (A : matrix m n α) : vec_mul v (-A) = -vec_mul v A :=\n  funext fun (x : n) => dot_product_neg v fun (i : m) => A i x\n\ntheorem neg_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α] (v : n → α) (A : matrix m n α) : mul_vec (-A) v = -mul_vec A v :=\n  funext fun (x : m) => neg_dot_product (fun (i : n) => A x i) v\n\ntheorem mul_vec_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α] (v : n → α) (A : matrix m n α) : mul_vec A (-v) = -mul_vec A v :=\n  funext fun (x : m) => dot_product_neg (fun (j : n) => A x j) v\n\ntheorem smul_mul_vec_assoc {n : Type u_3} [fintype n] {α : Type v} [ring α] (A : matrix n n α) (b : n → α) (a : α) : mul_vec (a • A) b = a • mul_vec A b := sorry\n\n/--\n  Tell `simp` what the entries are in a transposed matrix.\n\n  Compare with `mul_apply`, `diagonal_apply_eq`, etc.\n-/\n@[simp] theorem transpose_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} (M : matrix m n α) (i : m) (j : n) : transpose M j i = M i j :=\n  rfl\n\n@[simp] theorem transpose_transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} (M : matrix m n α) : transpose (transpose M) = M :=\n  ext fun (i : m) (j : n) => Eq.refl (transpose (transpose M) i j)\n\n@[simp] theorem transpose_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [HasZero α] : transpose 0 = 0 :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose 0 i j)\n\n@[simp] theorem transpose_one {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α] : transpose 1 = 1 := sorry\n\n@[simp] theorem transpose_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Add α] (M : matrix m n α) (N : matrix m n α) : transpose (M + N) = transpose M + transpose N := sorry\n\n@[simp] theorem transpose_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_group α] (M : matrix m n α) (N : matrix m n α) : transpose (M - N) = transpose M - transpose N := sorry\n\n@[simp] theorem transpose_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {α : Type v} [comm_semiring α] (M : matrix m n α) (N : matrix n l α) : transpose (matrix.mul M N) = matrix.mul (transpose N) (transpose M) :=\n  ext\n    fun (i : l) (j : m) =>\n      dot_product_comm (fun (i : n) => (fun (j_1 : n) => M j j_1) i) fun (i_1 : n) => (fun (j : n) => N j i) i_1\n\n@[simp] theorem transpose_smul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (c : α) (M : matrix m n α) : transpose (c • M) = c • transpose M :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose (c • M) i j)\n\n@[simp] theorem transpose_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Neg α] (M : matrix m n α) : transpose (-M) = -transpose M :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose (-M) i j)\n\ntheorem transpose_map {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {β : Type w} {f : α → β} {M : matrix m n α} : map (transpose M) f = transpose (map M f) :=\n  ext fun (i : n) (j : m) => Eq.refl (map (transpose M) f i j)\n\n/--\nWhen `R` is a *-(semi)ring, `matrix n n R` becomes a *-(semi)ring with\nthe star operation given by taking the conjugate, and the star of each entry.\n-/\nprotected instance star_ring {n : Type u_3} [fintype n] [DecidableEq n] {R : Type u_5} [semiring R] [star_ring R] : star_ring (matrix n n R) :=\n  star_ring.mk sorry\n\n@[simp] theorem star_apply {n : Type u_3} [fintype n] [DecidableEq n] {R : Type u_5} [semiring R] [star_ring R] (M : matrix n n R) (i : n) (j : n) : star M i j = star (M j i) :=\n  rfl\n\n/-- `M.minor row col` is the matrix obtained by reindexing the rows and the lines of\n    `M`, such that `M.minor row col i j = M (row i) (col j)`. Note that the total number\n    of row/colums doesn't have to be preserved. -/\ndef minor {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix m n α) (row : l → m) (col : o → n) : matrix l o α :=\n  fun (i : l) (j : o) => A (row i) (col j)\n\n/-- The left `n × l` part of a `n × (l+r)` matrix. -/\ndef sub_left {α : Type v} {m : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin m) (fin (l + r)) α) : matrix (fin m) (fin l) α :=\n  minor A id ⇑(fin.cast_add r)\n\n/-- The right `n × r` part of a `n × (l+r)` matrix. -/\ndef sub_right {α : Type v} {m : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin m) (fin (l + r)) α) : matrix (fin m) (fin r) α :=\n  minor A id ⇑(fin.nat_add l)\n\n/-- The top `u × n` part of a `(u+d) × n` matrix. -/\ndef sub_up {α : Type v} {d : ℕ} {u : ℕ} {n : ℕ} (A : matrix (fin (u + d)) (fin n) α) : matrix (fin u) (fin n) α :=\n  minor A (⇑(fin.cast_add d)) id\n\n/-- The bottom `d × n` part of a `(u+d) × n` matrix. -/\ndef sub_down {α : Type v} {d : ℕ} {u : ℕ} {n : ℕ} (A : matrix (fin (u + d)) (fin n) α) : matrix (fin d) (fin n) α :=\n  minor A (⇑(fin.nat_add u)) id\n\n/-- The top-right `u × r` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_up_right {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin u) (fin r) α :=\n  sub_up (sub_right A)\n\n/-- The bottom-right `d × r` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_down_right {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin d) (fin r) α :=\n  sub_down (sub_right A)\n\n/-- The top-left `u × l` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_up_left {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin u) (fin l) α :=\n  sub_up (sub_left A)\n\n/-- The bottom-left `d × l` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_down_left {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin d) (fin l) α :=\n  sub_down (sub_left A)\n\n/-!\n### `row_col` section\n\nSimplification lemmas for `matrix.row` and `matrix.col`.\n-/\n\n@[simp] theorem col_add {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) (w : m → α) : col (v + w) = col v + col w :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (v + w) i j)\n\n@[simp] theorem col_smul {m : Type u_2} [fintype m] {α : Type v} [semiring α] (x : α) (v : m → α) : col (x • v) = x • col v :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (x • v) i j)\n\n@[simp] theorem row_add {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) (w : m → α) : row (v + w) = row v + row w :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (v + w) i j)\n\n@[simp] theorem row_smul {m : Type u_2} [fintype m] {α : Type v} [semiring α] (x : α) (v : m → α) : row (x • v) = x • row v :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (x • v) i j)\n\n@[simp] theorem col_apply {m : Type u_2} [fintype m] {α : Type v} (v : m → α) (i : m) (j : Unit) : col v i j = v i :=\n  rfl\n\n@[simp] theorem row_apply {m : Type u_2} [fintype m] {α : Type v} (v : m → α) (i : Unit) (j : m) : row v i j = v j :=\n  rfl\n\n@[simp] theorem transpose_col {m : Type u_2} [fintype m] {α : Type v} (v : m → α) : transpose (col v) = row v :=\n  ext fun (i : Unit) (j : m) => Eq.refl (transpose (col v) i j)\n\n@[simp] theorem transpose_row {m : Type u_2} [fintype m] {α : Type v} (v : m → α) : transpose (row v) = col v :=\n  ext fun (i : m) (j : Unit) => Eq.refl (transpose (row v) i j)\n\ntheorem row_vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) (v : m → α) : row (vec_mul v M) = matrix.mul (row v) M :=\n  ext fun (i : Unit) (j : n) => Eq.refl (row (vec_mul v M) i j)\n\ntheorem col_vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) (v : m → α) : col (vec_mul v M) = transpose (matrix.mul (row v) M) :=\n  ext fun (i : n) (j : Unit) => Eq.refl (col (vec_mul v M) i j)\n\ntheorem col_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) (v : n → α) : col (mul_vec M v) = matrix.mul M (col v) :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (mul_vec M v) i j)\n\ntheorem row_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) (v : n → α) : row (mul_vec M v) = transpose (matrix.mul M (col v)) :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (mul_vec M v) i j)\n\n/-- Update, i.e. replace the `i`th row of matrix `A` with the values in `b`. -/\ndef update_row {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [DecidableEq n] (M : matrix n m α) (i : n) (b : m → α) : matrix n m α :=\n  function.update M i b\n\n/-- Update, i.e. replace the `j`th column of matrix `A` with the values in `b`. -/\ndef update_column {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [DecidableEq m] (M : matrix n m α) (j : m) (b : n → α) : matrix n m α :=\n  fun (i : n) => function.update (M i) j (b i)\n\n@[simp] theorem update_row_self {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {i : n} {b : m → α} [DecidableEq n] : update_row M i b i = b :=\n  function.update_same i b M\n\n@[simp] theorem update_column_self {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {i : n} {j : m} {c : n → α} [DecidableEq m] : update_column M j c i j = c i :=\n  function.update_same j (c i) (M i)\n\n@[simp] theorem update_row_ne {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {i : n} {b : m → α} [DecidableEq n] {i' : n} (i_ne : i' ≠ i) : update_row M i b i' = M i' :=\n  function.update_noteq i_ne b M\n\n@[simp] theorem update_column_ne {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {i : n} {j : m} {c : n → α} [DecidableEq m] {j' : m} (j_ne : j' ≠ j) : update_column M j c i j' = M i j' :=\n  function.update_noteq j_ne (c i) (M i)\n\ntheorem update_row_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {i : n} {j : m} {b : m → α} [DecidableEq n] {i' : n} : update_row M i b i' j = ite (i' = i) (b j) (M i' j) := sorry\n\ntheorem update_column_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {i : n} {j : m} {c : n → α} [DecidableEq m] {j' : m} : update_column M j c i j' = ite (j' = j) (c i) (M i j') := sorry\n\ntheorem update_row_transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {j : m} {c : n → α} [DecidableEq m] : update_row (transpose M) j c = transpose (update_column M j c) := sorry\n\ntheorem update_column_transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix n m α} {i : n} {b : m → α} [DecidableEq n] : update_column (transpose M) i b = transpose (update_row M i b) := sorry\n\n/-- We can form a single large matrix by flattening smaller 'block' matrices of compatible\ndimensions. -/\ndef from_blocks {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) : matrix (n ⊕ o) (l ⊕ m) α :=\n  sum.elim (fun (i : n) => sum.elim (A i) (B i)) fun (i : o) => sum.elim (C i) (D i)\n\n@[simp] theorem from_blocks_apply₁₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : n) (j : l) : from_blocks A B C D (sum.inl i) (sum.inl j) = A i j :=\n  rfl\n\n@[simp] theorem from_blocks_apply₁₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : n) (j : m) : from_blocks A B C D (sum.inl i) (sum.inr j) = B i j :=\n  rfl\n\n@[simp] theorem from_blocks_apply₂₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : o) (j : l) : from_blocks A B C D (sum.inr i) (sum.inl j) = C i j :=\n  rfl\n\n@[simp] theorem from_blocks_apply₂₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : o) (j : m) : from_blocks A B C D (sum.inr i) (sum.inr j) = D i j :=\n  rfl\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"top left\" submatrix. -/\ndef to_blocks₁₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix n l α :=\n  fun (i : n) (j : l) => M (sum.inl i) (sum.inl j)\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"top right\" submatrix. -/\ndef to_blocks₁₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix n m α :=\n  fun (i : n) (j : m) => M (sum.inl i) (sum.inr j)\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"bottom left\" submatrix. -/\ndef to_blocks₂₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix o l α :=\n  fun (i : o) (j : l) => M (sum.inr i) (sum.inl j)\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"bottom right\" submatrix. -/\ndef to_blocks₂₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix o m α :=\n  fun (i : o) (j : m) => M (sum.inr i) (sum.inr j)\n\ntheorem from_blocks_to_blocks {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : from_blocks (to_blocks₁₁ M) (to_blocks₁₂ M) (to_blocks₂₁ M) (to_blocks₂₂ M) = M := sorry\n\n@[simp] theorem to_blocks_from_blocks₁₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) : to_blocks₁₁ (from_blocks A B C D) = A :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks₁₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) : to_blocks₁₂ (from_blocks A B C D) = B :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks₂₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) : to_blocks₂₁ (from_blocks A B C D) = C :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks₂₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) : to_blocks₂₂ (from_blocks A B C D) = D :=\n  rfl\n\ntheorem from_blocks_transpose {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) : transpose (from_blocks A B C D) = from_blocks (transpose A) (transpose C) (transpose B) (transpose D) := sorry\n\ntheorem from_blocks_smul {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (x : α) (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) : x • from_blocks A B C D = from_blocks (x • A) (x • B) (x • C) (x • D) := sorry\n\ntheorem from_blocks_add {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (A' : matrix n l α) (B' : matrix n m α) (C' : matrix o l α) (D' : matrix o m α) : from_blocks A B C D + from_blocks A' B' C' D' = from_blocks (A + A') (B + B') (C + C') (D + D') := sorry\n\ntheorem from_blocks_multiply {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] {p : Type u_5} {q : Type u_6} [fintype p] [fintype q] (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (A' : matrix l p α) (B' : matrix l q α) (C' : matrix m p α) (D' : matrix m q α) : matrix.mul (from_blocks A B C D) (from_blocks A' B' C' D') =\n  from_blocks (matrix.mul A A' + matrix.mul B C') (matrix.mul A B' + matrix.mul B D')\n    (matrix.mul C A' + matrix.mul D C') (matrix.mul C B' + matrix.mul D D') := sorry\n\n@[simp] theorem from_blocks_diagonal {l : Type u_1} {m : Type u_2} [fintype l] [fintype m] {α : Type v} [semiring α] [DecidableEq l] [DecidableEq m] (d₁ : l → α) (d₂ : m → α) : from_blocks (diagonal d₁) 0 0 (diagonal d₂) = diagonal (sum.elim d₁ d₂) := sorry\n\n@[simp] theorem from_blocks_one {l : Type u_1} {m : Type u_2} [fintype l] [fintype m] {α : Type v} [semiring α] [DecidableEq l] [DecidableEq m] : from_blocks 1 0 0 1 = 1 := sorry\n\n/-- `matrix.block_diagonal M` turns `M : o → matrix m n α'` into a\n`m × o`-by`n × o` block matrix which has the entries of `M` along the diagonal\nand zero elsewhere. -/\ndef block_diagonal {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] : matrix (m × o) (n × o) α :=\n  sorry\n\ntheorem block_diagonal_apply {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] (ik : m × o) (jk : n × o) : block_diagonal M ik jk = ite (prod.snd ik = prod.snd jk) (M (prod.snd ik) (prod.fst ik) (prod.fst jk)) 0 :=\n  prod.cases_on ik\n    fun (ik_fst : m) (ik_snd : o) =>\n      prod.cases_on jk fun (jk_fst : n) (jk_snd : o) => Eq.refl (block_diagonal M (ik_fst, ik_snd) (jk_fst, jk_snd))\n\n@[simp] theorem block_diagonal_apply_eq {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] (i : m) (j : n) (k : o) : block_diagonal M (i, k) (j, k) = M k i j :=\n  if_pos rfl\n\ntheorem block_diagonal_apply_ne {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] (i : m) (j : n) {k : o} {k' : o} (h : k ≠ k') : block_diagonal M (i, k) (j, k') = 0 :=\n  if_neg h\n\n@[simp] theorem block_diagonal_transpose {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] : transpose (block_diagonal M) = block_diagonal fun (k : o) => transpose (M k) := sorry\n\n@[simp] theorem block_diagonal_zero {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} [DecidableEq o] [HasZero α] : block_diagonal 0 = 0 := sorry\n\n@[simp] theorem block_diagonal_diagonal {m : Type u_2} {o : Type u_4} [fintype m] [fintype o] {α : Type v} [DecidableEq o] [HasZero α] [DecidableEq m] (d : o → m → α) : (block_diagonal fun (k : o) => diagonal (d k)) = diagonal fun (ik : m × o) => d (prod.snd ik) (prod.fst ik) := sorry\n\n@[simp] theorem block_diagonal_one {m : Type u_2} {o : Type u_4} [fintype m] [fintype o] {α : Type v} [DecidableEq o] [HasZero α] [DecidableEq m] [HasOne α] : block_diagonal 1 = 1 := sorry\n\n@[simp] theorem block_diagonal_add {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) (N : o → matrix m n α) [DecidableEq o] [add_monoid α] : block_diagonal (M + N) = block_diagonal M + block_diagonal N := sorry\n\n@[simp] theorem block_diagonal_neg {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [add_group α] : block_diagonal (-M) = -block_diagonal M := sorry\n\n@[simp] theorem block_diagonal_sub {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) (N : o → matrix m n α) [DecidableEq o] [add_group α] : block_diagonal (M - N) = block_diagonal M - block_diagonal N := sorry\n\n@[simp] theorem block_diagonal_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] {p : Type u_1} [fintype p] [semiring α] (N : o → matrix n p α) : (block_diagonal fun (k : o) => matrix.mul (M k) (N k)) = matrix.mul (block_diagonal M) (block_diagonal N) := sorry\n\n@[simp] theorem block_diagonal_smul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] {R : Type u_1} [semiring R] [add_comm_monoid α] [semimodule R α] (x : R) : block_diagonal (x • M) = x • block_diagonal M := sorry\n\nend matrix\n\n\nnamespace ring_hom\n\n\ntheorem map_matrix_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {α : Type v} {β : Type u_5} [semiring α] [semiring β] (M : matrix m n α) (N : matrix n o α) (i : m) (j : o) (f : α →+* β) : coe_fn f (matrix.mul M N i j) =\n  matrix.mul (fun (i : m) (j : n) => coe_fn f (M i j)) (fun (i : n) (j : o) => coe_fn f (N i j)) i j := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/matrix/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4935930572720868}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\n\nimport algebra.char_p.basic\nimport data.mv_polynomial.comm_ring\nimport data.mv_polynomial.equiv\nimport ring_theory.polynomial.content\nimport ring_theory.unique_factorization_domain\n\n/-!\n# Ring-theoretic supplement of data.polynomial.\n\n## Main results\n* `mv_polynomial.is_domain`:\n  If a ring is an integral domain, then so is its polynomial ring over finitely many variables.\n* `polynomial.is_noetherian_ring`:\n  Hilbert basis theorem, that if a ring is noetherian then so is its polynomial ring.\n* `polynomial.wf_dvd_monoid`:\n  If an integral domain is a `wf_dvd_monoid`, then so is its polynomial ring.\n* `polynomial.unique_factorization_monoid`:\n  If an integral domain is a `unique_factorization_monoid`, then so is its polynomial ring.\n-/\n\nnoncomputable theory\nopen_locale classical big_operators\n\nuniverses u v w\n\nnamespace polynomial\n\ninstance {R : Type u} [semiring R] (p : ℕ) [h : char_p R p] : char_p (polynomial R) p :=\nlet ⟨h⟩ := h in ⟨λ n, by rw [← C.map_nat_cast, ← C_0, C_inj, h]⟩\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R (polynomial R) :=\n⨅ k : ℕ, ⨅ h : ↑k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : ℕ) : submodule R (polynomial R) :=\n⨅ k : ℕ, ⨅ h : k ≥ n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot ℕ} {f : polynomial R} :\n  f ∈ degree_le R n ↔ degree f ≤ n :=\nby simp only [degree_le, submodule.mem_infi, degree_le_iff_coeff_zero, linear_map.mem_ker]; refl\n\n@[mono] theorem degree_le_mono {m n : with_bot ℕ} (H : m ≤ n) :\n  degree_le R m ≤ degree_le R n :=\nλ f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : ℕ} :\n  degree_le R n = submodule.span R ↑((finset.range (n+1)).image (λ n, (X : polynomial R)^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [← polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_le_coe.1 (finset.sup_le_iff.1 hp k hk),\n    rw [monomial_eq_C_mul_X, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_le.2,\n  exact (degree_X_pow_le _).trans\n    (with_bot.coe_le_coe.2 $ nat.le_of_lt_succ $ finset.mem_range.1 hk)\nend\n\ntheorem mem_degree_lt {n : ℕ} {f : polynomial R} :\n  f ∈ degree_lt R n ↔ degree f < n :=\nby { simp_rw [degree_lt, submodule.mem_infi, linear_map.mem_ker, degree,\n    finset.sup_lt_iff (with_bot.bot_lt_coe n), mem_support_iff, with_bot.some_eq_coe,\n    with_bot.coe_lt_coe, lt_iff_not_ge', ne, not_imp_not], refl }\n\n@[mono] theorem degree_lt_mono {m n : ℕ} (H : m ≤ n) :\n  degree_lt R m ≤ degree_lt R n :=\nλ f hf, mem_degree_lt.2 (lt_of_lt_of_le (mem_degree_lt.1 hf) $ with_bot.coe_le_coe.2 H)\n\ntheorem degree_lt_eq_span_X_pow {n : ℕ} :\n  degree_lt R n = submodule.span R ↑((finset.range n).image (λ n, X^n) : finset (polynomial R)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [← polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_lt_coe.1 ((finset.sup_lt_iff $ with_bot.bot_lt_coe n).1 hp k hk),\n    rw [monomial_eq_C_mul_X, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 this, rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_lt.2,\n  exact lt_of_le_of_lt (degree_X_pow_le _) (with_bot.coe_lt_coe.2 $ finset.mem_range.1 hk)\nend\n\n/-- The first `n` coefficients on `degree_lt n` form a linear equivalence with `fin n → F`. -/\ndef degree_lt_equiv (F : Type*) [field F] (n : ℕ) : degree_lt F n ≃ₗ[F] (fin n → F) :=\n{ to_fun := λ p n, (↑p : polynomial F).coeff n,\n  inv_fun := λ f, ⟨∑ i : fin n, monomial i (f i),\n    (degree_lt F n).sum_mem (λ i _, mem_degree_lt.mpr (lt_of_le_of_lt\n      (degree_monomial_le i (f i)) (with_bot.coe_lt_coe.mpr i.is_lt)))⟩,\n  map_add' := λ p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := λ x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro ⟨p, hp⟩, ext1,\n    simp only [submodule.coe_mk],\n    by_cases hp0 : p = 0,\n    { subst hp0, simp only [coeff_zero, linear_map.map_zero, finset.sum_const_zero] },\n    rw [mem_degree_lt, degree_eq_nat_degree hp0, with_bot.coe_lt_coe] at hp,\n    conv_rhs { rw [p.as_sum_range' n hp, ← fin.sum_univ_eq_sum_range] },\n  end,\n  right_inv :=\n  begin\n    intro f, ext i,\n    simp only [finset_sum_coeff, submodule.coe_mk],\n    rw [finset.sum_eq_single i, coeff_monomial, if_pos rfl],\n    { rintro j - hji, rw [coeff_monomial, if_neg], rwa [← subtype.ext_iff] },\n    { intro h, exact (h (finset.mem_univ _)).elim }\n  end }\n\n/-- The finset of nonzero coefficients of a polynomial. -/\ndef frange (p : polynomial R) : finset R :=\nfinset.image (λ n, p.coeff n) p.support\n\nlemma frange_zero : frange (0 : polynomial R) = ∅ :=\nrfl\n\nlemma mem_frange_iff {p : polynomial R} {c : R} :\n  c ∈ p.frange ↔ ∃ n ∈ p.support, c = p.coeff n :=\nby simp [frange, eq_comm]\n\nlemma frange_one : frange (1 : polynomial R) ⊆ {1} :=\nbegin\n  simp [frange, finset.image_subset_iff],\n  simp only [← C_1, coeff_C],\n  assume n hn,\n  simp only [exists_prop, ite_eq_right_iff, not_forall] at hn,\n  simp [hn],\nend\n\nlemma coeff_mem_frange (p : polynomial R) (n : ℕ) (h : p.coeff n ≠ 0) :\n  p.coeff n ∈ p.frange :=\nbegin\n  simp only [frange, exists_prop, mem_support_iff, finset.mem_image, ne.def],\n  exact ⟨n, h, rfl⟩,\nend\n\n/-- Given a polynomial, return the polynomial whose coefficients are in\nthe ring closure of the original coefficients. -/\ndef restriction (p : polynomial R) : polynomial (subring.closure (↑p.frange : set R)) :=\n∑ i in p.support, monomial i (⟨p.coeff i,\n  if H : p.coeff i = 0 then H.symm ▸ (subring.closure _).zero_mem\n  else subring.subset_closure (p.coeff_mem_frange _ H)⟩ : (subring.closure (↑p.frange : set R)))\n\n@[simp] theorem coeff_restriction {p : polynomial R} {n : ℕ} :\n  ↑(coeff (restriction p) n) = coeff p n :=\nbegin\n  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ne.def, ite_not],\n  split_ifs,\n  { rw h, refl },\n  { refl }\nend\n\n@[simp] theorem coeff_restriction' {p : polynomial R} {n : ℕ} :\n  (coeff (restriction p) n).1 = coeff p n :=\ncoeff_restriction\n\n@[simp] lemma support_restriction (p : polynomial R) :\n  support (restriction p) = support p :=\nbegin\n  ext i,\n  simp only [mem_support_iff, not_iff_not, ne.def],\n  conv_rhs { rw [← coeff_restriction] },\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem map_restriction (p : polynomial R) : p.restriction.map (algebra_map _ _) = p :=\next $ λ n, by rw [coeff_map, algebra.algebra_map_of_subring_apply, coeff_restriction]\n\n@[simp] theorem degree_restriction {p : polynomial R} : (restriction p).degree = p.degree :=\nby simp [degree]\n\n@[simp] theorem nat_degree_restriction {p : polynomial R} :\n  (restriction p).nat_degree = p.nat_degree :=\nby simp [nat_degree]\n\n@[simp] theorem monic_restriction {p : polynomial R} : monic (restriction p) ↔ monic p :=\nbegin\n  simp only [monic, leading_coeff, nat_degree_restriction],\n  rw [←@coeff_restriction _ _ p],\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem restriction_zero : restriction (0 : polynomial R) = 0 :=\nby simp only [restriction, finset.sum_empty, support_zero]\n\n@[simp] theorem restriction_one : restriction (1 : polynomial R) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables {S : Type v} [ring S] {f : R →+* S} {x : S}\n\ntheorem eval₂_restriction {p : polynomial R} :\n  eval₂ f x p = eval₂ (f.comp (subring.subtype _)) x p.restriction :=\nbegin\n  simp only [eval₂_eq_sum, sum, support_restriction, ←@coeff_restriction _ _ p],\n  refl,\nend\n\nsection to_subring\n\nvariables (p : polynomial R) (T : subring R)\n\n/-- Given a polynomial `p` and a subring `T` that contains the coefficients of `p`,\nreturn the corresponding polynomial whose coefficients are in `T. -/\ndef to_subring (hp : (↑p.frange : set R) ⊆ T) : polynomial T :=\n∑ i in p.support, monomial i (⟨p.coeff i,\n  if H : p.coeff i = 0 then H.symm ▸ T.zero_mem\n  else hp (p.coeff_mem_frange _ H)⟩ : T)\n\nvariables (hp : (↑p.frange : set R) ⊆ T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : ℕ} : ↑(coeff (to_subring p T hp) n) = coeff p n :=\nbegin\n  simp only [to_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ne.def, ite_not],\n  split_ifs,\n  { rw h, refl },\n  { refl }\nend\n\n@[simp] theorem coeff_to_subring' {n : ℕ} : (coeff (to_subring p T hp) n).1 = coeff p n :=\ncoeff_to_subring _ _ hp\n\n@[simp] lemma support_to_subring :\n  support (to_subring p T hp) = support p :=\nbegin\n  ext i,\n  simp only [mem_support_iff, not_iff_not, ne.def],\n  conv_rhs { rw [← coeff_to_subring p T hp] },\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem degree_to_subring : (to_subring p T hp).degree = p.degree :=\nby simp [degree]\n\n@[simp] theorem nat_degree_to_subring : (to_subring p T hp).nat_degree = p.nat_degree :=\nby simp [nat_degree]\n\n@[simp] theorem monic_to_subring : monic (to_subring p T hp) ↔ monic p :=\nbegin\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, ← coeff_to_subring p T hp],\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\nomit hp\n\n@[simp] theorem to_subring_zero : to_subring (0 : polynomial R) T (by simp [frange_zero]) = 0 :=\nby { ext i, simp }\n\n@[simp] theorem to_subring_one : to_subring (1 : polynomial R) T\n  (set.subset.trans frange_one $finset.singleton_subset_set_iff.2 T.one_mem) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_to_subring', coeff_one, coeff_one]; split_ifs; refl\n\n@[simp] theorem map_to_subring : (p.to_subring T hp).map (subring.subtype T) = p :=\nby { ext n, simp [coeff_map] }\n\nend to_subring\n\nvariables (T : subring R)\n\n/-- Given a polynomial whose coefficients are in some subring, return\nthe corresponding polynomial whose coefficients are in the ambient ring. -/\ndef of_subring (p : polynomial T) : polynomial R :=\n∑ i in p.support, monomial i (p.coeff i : R)\n\nlemma coeff_of_subring (p : polynomial T) (n : ℕ) :\n  coeff (of_subring T p) n = (coeff p n : T) :=\nbegin\n  simp only [of_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ite_eq_right_iff, ne.def, ite_not, not_not, ite_eq_left_iff],\n  assume h,\n  rw h,\n  refl\nend\n\n@[simp] theorem frange_of_subring {p : polynomial T} :\n  (↑(p.of_subring T).frange : set R) ⊆ T :=\nbegin\n  assume i hi,\n  simp only [frange, set.mem_image, mem_support_iff, ne.def, finset.mem_coe, finset.coe_image]\n    at hi,\n  rcases hi with ⟨n, hn, h'n⟩,\n  rw [← h'n, coeff_of_subring],\n  exact subtype.mem (coeff p n : T)\nend\n\nsection mod_by_monic\n\nvariables {q : polynomial R}\n\nlemma mem_ker_mod_by_monic [nontrivial R] (hq : q.monic) {p : polynomial R} :\n  p ∈ (mod_by_monic_hom hq).ker ↔ q ∣ p :=\nlinear_map.mem_ker.trans (dvd_iff_mod_by_monic_eq_zero hq)\n\n@[simp] lemma ker_mod_by_monic_hom [nontrivial R] (hq : q.monic) :\n  (polynomial.mod_by_monic_hom hq).ker = (ideal.span {q}).restrict_scalars R :=\nsubmodule.ext (λ f, (mem_ker_mod_by_monic hq).trans ideal.mem_span_singleton.symm)\n\nend mod_by_monic\n\nend polynomial\n\nvariables {R : Type u} {S : Type*} {σ : Type v} {M : Type w}\nvariables [comm_ring R] [comm_ring S] [add_comm_group M] [module R M]\n\nnamespace ideal\nopen polynomial\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself -/\nlemma polynomial_mem_ideal_of_coeff_mem_ideal (I : ideal (polynomial R)) (p : polynomial R)\n  (hp : ∀ (n : ℕ), (p.coeff n) ∈ I.comap C) : p ∈ I :=\nsum_C_mul_X_eq p ▸ submodule.sum_mem I (λ n hn, I.mul_mem_right _ (hp n))\n\n/-- The push-forward of an ideal `I` of `R` to `polynomial R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : polynomial R} :\n  f ∈ (ideal.map C I : ideal (polynomial R)) ↔ ∀ n : ℕ, f.coeff n ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw ← sum_monomial_eq f,\n    refine (I.map C : ideal (polynomial R)).sum_mem (λ n hn, _),\n    simp [monomial_eq_C_mul_X],\n    rw mul_comm,\n    exact (I.map C : ideal (polynomial R)).mul_mem_left _ (mem_map_of_mem _ (hf n)) }\nend\n\nlemma _root_.polynomial.ker_map_ring_hom (f : R →+* S) :\n  (polynomial.map_ring_hom f).ker = f.ker.map C :=\nbegin\n  ext,\n  rw [mem_map_C_iff, ring_hom.mem_ker, polynomial.ext_iff],\n  simp_rw [coe_map_ring_hom, coeff_map, coeff_zero, ring_hom.mem_ker],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} :\n  ∀ a ∈ I, ((quotient.mk (map C I : ideal (polynomial R))).comp C) a = 0 :=\nbegin\n  intros a ha,\n  rw [ring_hom.comp_apply, quotient.eq_zero_iff_mem],\n  exact mem_map_of_mem _ ha,\nend\n\nlemma eval₂_C_mk_eq_zero {I : ideal R} :\n  ∀ f ∈ (map C I : ideal (polynomial R)), eval₂_ring_hom (C.comp (quotient.mk I)) X f = 0 :=\nbegin\n  intros a ha,\n  rw ← sum_monomial_eq a,\n  dsimp,\n  rw eval₂_sum,\n  refine finset.sum_eq_zero (λ n hn, _),\n  dsimp,\n  rw eval₂_monomial (C.comp (quotient.mk I)) X,\n  refine mul_eq_zero_of_left (polynomial.ext (λ m, _)) (X ^ n),\n  erw coeff_C,\n  by_cases h : m = 0,\n  { simpa [h] using quotient.eq_zero_iff_mem.2 ((mem_map_C_iff.1 ha) n) },\n  { simp [h] }\nend\n\n/-- If `I` is an ideal of `R`, then the ring polynomials over the quotient ring `I.quotient` is\nisomorphic to the quotient of `polynomial R` by the ideal `map C I`,\nwhere `map C I` contains exactly the polynomials whose coefficients all lie in `I` -/\ndef polynomial_quotient_equiv_quotient_polynomial (I : ideal R) :\n  polynomial (R ⧸ I) ≃+* polynomial R ⧸ (map C I : ideal (polynomial R)) :=\n{ to_fun := eval₂_ring_hom\n    (quotient.lift I ((quotient.mk (map C I : ideal (polynomial R))).comp C) quotient_map_C_eq_zero)\n    ((quotient.mk (map C I : ideal (polynomial R)) X)),\n  inv_fun := quotient.lift (map C I : ideal (polynomial R))\n    (eval₂_ring_hom (C.comp (quotient.mk I)) X) eval₂_C_mk_eq_zero,\n  map_mul' := λ f g, by simp only [coe_eval₂_ring_hom, eval₂_mul],\n  map_add' := λ f g, by simp only [eval₂_add, coe_eval₂_ring_hom],\n  left_inv := begin\n    intro f,\n    apply polynomial.induction_on' f,\n    { intros p q hp hq,\n      simp only [coe_eval₂_ring_hom] at hp,\n      simp only [coe_eval₂_ring_hom] at hq,\n      simp only [coe_eval₂_ring_hom, hp, hq, ring_hom.map_add] },\n    { rintros n ⟨x⟩,\n      simp only [monomial_eq_smul_X, C_mul', quotient.lift_mk, submodule.quotient.quot_mk_eq_mk,\n        quotient.mk_eq_mk, eval₂_X_pow, eval₂_smul, coe_eval₂_ring_hom, ring_hom.map_pow,\n        eval₂_C, ring_hom.coe_comp, ring_hom.map_mul, eval₂_X] }\n  end,\n  right_inv := begin\n    rintro ⟨f⟩,\n    apply polynomial.induction_on' f,\n    { simp_intros p q hp hq,\n      rw [hp, hq] },\n    { intros n a,\n      simp only [monomial_eq_smul_X, ← C_mul' a (X ^ n), quotient.lift_mk,\n        submodule.quotient.quot_mk_eq_mk, quotient.mk_eq_mk, eval₂_X_pow,\n        eval₂_smul, coe_eval₂_ring_hom, ring_hom.map_pow, eval₂_C, ring_hom.coe_comp,\n        ring_hom.map_mul, eval₂_X] },\n  end, }\n\n@[simp]\nlemma polynomial_quotient_equiv_quotient_polynomial_symm_mk (I : ideal R) (f : polynomial R) :\n  I.polynomial_quotient_equiv_quotient_polynomial.symm (quotient.mk _ f) = f.map (quotient.mk I) :=\nby rw [polynomial_quotient_equiv_quotient_polynomial, ring_equiv.symm_mk, ring_equiv.coe_mk,\n  ideal.quotient.lift_mk, coe_eval₂_ring_hom, eval₂_eq_eval_map, ←polynomial.map_map,\n  ←eval₂_eq_eval_map, polynomial.eval₂_C_X]\n\n@[simp]\nlemma polynomial_quotient_equiv_quotient_polynomial_map_mk (I : ideal R) (f : polynomial R) :\n  I.polynomial_quotient_equiv_quotient_polynomial (f.map I^.quotient.mk) = quotient.mk _ f :=\nbegin\n  apply (polynomial_quotient_equiv_quotient_polynomial I).symm.injective,\n  rw [ring_equiv.symm_apply_apply, polynomial_quotient_equiv_quotient_polynomial_symm_mk],\nend\n\n/-- If `P` is a prime ideal of `R`, then `R[x]/(P)` is an integral domain. -/\nlemma is_domain_map_C_quotient {P : ideal R} (H : is_prime P) :\n  is_domain (polynomial R ⧸ (map C P : ideal (polynomial R))) :=\nring_equiv.is_domain (polynomial (R ⧸ P))\n  (polynomial_quotient_equiv_quotient_polynomial P).symm\n\n/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/\nlemma is_prime_map_C_of_is_prime {P : ideal R} (H : is_prime P) :\n  is_prime (map C P : ideal (polynomial R)) :=\n(quotient.is_domain_iff_prime (map C P : ideal (polynomial R))).mp\n  (is_domain_map_C_quotient H)\n\n/-- Given any ring `R` and an ideal `I` of `polynomial R`, we get a map `R → R[x] → R[x]/I`.\n  If we let `R` be the image of `R` in `R[x]/I` then we also have a map `R[x] → R'[x]`.\n  In particular we can map `I` across this map, to get `I'` and a new map `R' → R'[x] → R'[x]/I`.\n  This theorem shows `I'` will not contain any non-zero constant polynomials\n  -/\nlemma eq_zero_of_polynomial_mem_map_range (I : ideal (polynomial R))\n  (x : ((quotient.mk I).comp C).range)\n  (hx : C x ∈ (I.map (polynomial.map_ring_hom ((quotient.mk I).comp C).range_restrict))) :\n  x = 0 :=\nbegin\n  let i := ((quotient.mk I).comp C).range_restrict,\n  have hi' : (polynomial.map_ring_hom i).ker ≤ I,\n  { refine λ f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (λ n, _),\n    rw [mem_comap, ← quotient.eq_zero_iff_mem, ← ring_hom.comp_apply],\n    rw [ring_hom.mem_ker, coe_map_ring_hom] at hf,\n    replace hf := congr_arg (λ (f : polynomial _), f.coeff n) hf,\n    simp only [coeff_map, coeff_zero] at hf,\n    rwa [subtype.ext_iff, ring_hom.coe_range_restrict] at hf },\n  obtain ⟨x, hx'⟩ := x,\n  obtain ⟨y, rfl⟩ := (ring_hom.mem_range).1 hx',\n  refine subtype.eq _,\n  simp only [ring_hom.comp_apply, quotient.eq_zero_iff_mem, subring.coe_zero, subtype.val_eq_coe],\n  suffices : C (i y) ∈ (I.map (polynomial.map_ring_hom i)),\n  { obtain ⟨f, hf⟩ := mem_image_of_mem_map_of_surjective (polynomial.map_ring_hom i)\n      (polynomial.map_surjective _ (((quotient.mk I).comp C).range_restrict_surjective)) this,\n    refine sub_add_cancel (C y) f ▸ I.add_mem (hi' _ : (C y - f) ∈ I) hf.1,\n    rw [ring_hom.mem_ker, ring_hom.map_sub, hf.2, sub_eq_zero, coe_map_ring_hom, map_C] },\n  exact hx,\nend\n\n/-- `polynomial R` is never a field for any ring `R`. -/\nlemma polynomial_not_is_field : ¬ is_field (polynomial R) :=\nbegin\n  by_contradiction hR,\n  by_cases hR' : ∃ (x y : R), x ≠ y,\n  { haveI : nontrivial R := let ⟨x, y, hxy⟩ := hR' in nontrivial_of_ne x y hxy,\n    obtain ⟨p, hp⟩ := hR.mul_inv_cancel X_ne_zero,\n    by_cases hp0 : p = 0,\n    { replace hp := congr_arg degree hp,\n      rw [hp0, mul_zero, degree_zero, degree_one] at hp,\n      contradiction },\n    { have : p.degree < (X * p).degree := (mul_comm p X) ▸ degree_lt_degree_mul_X hp0,\n      rw [congr_arg degree hp, degree_one, nat.with_bot.lt_zero_iff, degree_eq_bot] at this,\n      exact hp0 this } },\n  { push_neg at hR',\n    exact let ⟨x, y, hxy⟩ := hR.exists_pair_ne in hxy (polynomial.ext (λ n, hR' _ _)) }\nend\n\n/-- The only constant in a maximal ideal over a field is `0`. -/\nlemma eq_zero_of_constant_mem_of_maximal (hR : is_field R)\n  (I : ideal (polynomial R)) [hI : I.is_maximal] (x : R) (hx : C x ∈ I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (λ hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain ⟨y, hy⟩ := hR.mul_inv_cancel hx0,\n  convert I.smul_mem (C y) hx,\n  rw [smul_eq_mul, ← C.map_mul, mul_comm y x, hy, ring_hom.map_one],\nend\n\n/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/\ndef of_polynomial (I : ideal (polynomial R)) : submodule R (polynomial R) :=\n{ carrier := I.carrier,\n  zero_mem' := I.zero_mem,\n  add_mem' := λ _ _, I.add_mem,\n  smul_mem' := λ c x H, by { rw [← C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal (polynomial R)}\ntheorem mem_of_polynomial (x) : x ∈ I.of_polynomial ↔ x ∈ I := iff.rfl\nvariables (I)\n\n/-- Given an ideal `I` of `R[X]`, make the `R`-submodule of `I`\nconsisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R (polynomial R) :=\ndegree_le R n ⊓ I.of_polynomial\n\n/-- Given an ideal `I` of `R[X]`, make the ideal in `R` of\nleading coefficients of polynomials in `I` with degree ≤ `n`. -/\ndef leading_coeff_nth (n : ℕ) : ideal R :=\n(I.degree_le n).map $ lcoeff R n\n\ntheorem mem_leading_coeff_nth (n : ℕ) (x) :\n  x ∈ I.leading_coeff_nth n ↔ ∃ p ∈ I, degree p ≤ n ∧ leading_coeff p = x :=\nbegin\n  simp only [leading_coeff_nth, degree_le, submodule.mem_map, lcoeff_apply, submodule.mem_inf,\n    mem_degree_le],\n  split,\n  { rintro ⟨p, ⟨hpdeg, hpI⟩, rfl⟩,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine ⟨0, I.zero_mem, bot_le, _⟩,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine ⟨p, hpI, le_of_eq hpdeg, _⟩,\n      rw [leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro ⟨p, hpI, hpdeg, rfl⟩,\n    have : nat_degree p + (n - nat_degree p) = n,\n    { exact add_tsub_cancel_of_le (nat_degree_le_of_degree_le hpdeg) },\n    refine ⟨p * X ^ (n - nat_degree p), ⟨_, I.mul_mem_right _ hpI⟩, _⟩,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [← with_bot.coe_add, this],\n      exact le_refl _ },\n    { rw [leading_coeff, ← coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x ∈ I.leading_coeff_nth 0 ↔ C x ∈ I :=\n(mem_leading_coeff_nth _ _ _).trans\n⟨λ ⟨p, hpI, hpdeg, hpx⟩, by rwa [← hpx, leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  ← eq_C_of_degree_le_zero hpdeg],\nλ hx, ⟨C x, hx, degree_C_le, leading_coeff_C x⟩⟩\n\ntheorem leading_coeff_nth_mono {m n : ℕ} (H : m ≤ n) :\n  I.leading_coeff_nth m ≤ I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr ⊢,\n  rcases hr with ⟨p, hpI, hpdeg, rfl⟩,\n  refine ⟨p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow⟩,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [← with_bot.coe_add, add_tsub_cancel_of_le H],\n  exact le_refl _\nend\n\n/-- Given an ideal `I` in `R[X]`, make the ideal in `R` of the\nleading coefficients in `I`. -/\ndef leading_coeff : ideal R :=\n⨆ n : ℕ, I.leading_coeff_nth n\n\ntheorem mem_leading_coeff (x) :\n  x ∈ I.leading_coeff ↔ ∃ p ∈ I, polynomial.leading_coeff p = x :=\nbegin\n  rw [leading_coeff, submodule.mem_supr_of_directed],\n  simp only [mem_leading_coeff_nth],\n  { split, { rintro ⟨i, p, hpI, hpdeg, rfl⟩, exact ⟨p, hpI, rfl⟩ },\n    rintro ⟨p, hpI, rfl⟩, exact ⟨nat_degree p, p, hpI, degree_le_nat_degree, rfl⟩ },\n  intros i j, exact ⟨i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)⟩\nend\n\ntheorem is_fg_degree_le [is_noetherian_ring R] (n : ℕ) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  ⟨_, degree_le_eq_span_X_pow.symm⟩) _\n\nend ideal\n\nnamespace polynomial\n@[priority 100]\ninstance {R : Type*} [comm_ring R] [is_domain R] [wf_dvd_monoid R] :\n  wf_dvd_monoid (polynomial R) :=\n{ well_founded_dvd_not_unit := begin\n    classical,\n    refine rel_hom.well_founded\n      ⟨λ p, (if p = 0 then ⊤ else ↑p.degree, p.leading_coeff), _⟩\n      (prod.lex_wf (with_top.well_founded_lt $ with_bot.well_founded_lt nat.lt_wf)\n        ‹wf_dvd_monoid R›.well_founded_dvd_not_unit),\n    rintros a b ⟨ane0, ⟨c, ⟨not_unit_c, rfl⟩⟩⟩,\n    rw [polynomial.degree_mul, if_neg ane0],\n    split_ifs with hac,\n    { rw [hac, polynomial.leading_coeff_zero],\n      apply prod.lex.left,\n      exact lt_of_le_of_ne le_top with_top.coe_ne_top },\n    have cne0 : c ≠ 0 := right_ne_zero_of_mul hac,\n    simp only [cne0, ane0, polynomial.leading_coeff_mul],\n    by_cases hdeg : c.degree = 0,\n    { simp only [hdeg, add_zero],\n      refine prod.lex.right _ ⟨_, ⟨c.leading_coeff, (λ unit_c, not_unit_c _), rfl⟩⟩,\n      { rwa [ne, polynomial.leading_coeff_eq_zero] },\n      rw [polynomial.is_unit_iff, polynomial.eq_C_of_degree_eq_zero hdeg],\n      use [c.leading_coeff, unit_c],\n      rw [polynomial.leading_coeff, polynomial.nat_degree_eq_of_degree_eq_some hdeg] },\n    { apply prod.lex.left,\n      rw polynomial.degree_eq_nat_degree cne0 at *,\n      rw [with_top.coe_lt_coe, polynomial.degree_eq_nat_degree ane0,\n          ← with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (λ h, hdeg (h.symm ▸ with_bot.coe_zero))) },\n  end }\n\nend polynomial\n\n/-- Hilbert basis theorem: a polynomial ring over a noetherian ring is a noetherian ring. -/\nprotected theorem polynomial.is_noetherian_ring [is_noetherian_ring R] :\n  is_noetherian_ring (polynomial R) :=\nis_noetherian_ring_iff.2 ⟨assume I : ideal (polynomial R),\nlet M := well_founded.min (is_noetherian_iff_well_founded.1 (by apply_instance))\n  (set.range I.leading_coeff_nth) ⟨_, ⟨0, rfl⟩⟩ in\nhave hm : M ∈ set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet ⟨N, HN⟩ := hm, ⟨s, hs⟩ := I.is_fg_degree_le N in\nhave hm2 : ∀ k, I.leading_coeff_nth k ≤ M := λ k, or.cases_on (le_or_lt k N)\n  (λ h, HN ▸ I.leading_coeff_nth_mono h)\n  (λ h x hx, classical.by_contradiction $ λ hxm,\n    have ¬M < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact ⟨k, rfl⟩,\n    this ⟨HN ▸ I.leading_coeff_nth_mono (le_of_lt h), λ H, hxm (H hx)⟩),\nhave hs2 : ∀ {x}, x ∈ I.degree_le N → x ∈ ideal.span (↑s : set (polynomial R)),\nfrom hs ▸ λ x hx, submodule.span_induction hx (λ _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (λ _ _, ideal.add_mem _) (λ c f hf, f.C_mul' c ▸ ideal.mul_mem_left _ _ hf),\n⟨s, le_antisymm\n  (ideal.span_le.2 $ λ x hx, have x ∈ I.degree_le N, from hs ▸ submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span (polynomial R) ↑s = ideal.span ↑s, by refl,\n  rw this,\n  intros p hp, generalize hn : p.nat_degree = k,\n  induction k using nat.strong_induction_on with k ih generalizing p,\n  cases le_or_lt k N,\n  { subst k, refine hs2 ⟨polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp⟩ },\n  { have hp0 : p ≠ 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) ≠ 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [← h, mul_zero], refl },\n    haveI : nontrivial R := ⟨⟨0, 1, this⟩⟩,\n    have : p.leading_coeff ∈ I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        ⟨_, hp, hn ▸ polynomial.degree_le_nat_degree, rfl⟩) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with ⟨q, hq, hdq, hlqp⟩,\n    have hq0 : q ≠ 0,\n    { intro H, rw [← polynomial.leading_coeff_eq_zero] at H,\n      rw [hlqp, polynomial.leading_coeff_eq_zero] at H, exact hp0 H },\n    have h1 : p.degree = (q * polynomial.X ^ (k - q.nat_degree)).degree,\n    { rw [polynomial.degree_mul', polynomial.degree_X_pow],\n      rw [polynomial.degree_eq_nat_degree hp0, polynomial.degree_eq_nat_degree hq0],\n      rw [← with_bot.coe_add, add_tsub_cancel_of_le, hn],\n      { refine le_trans (polynomial.nat_degree_le_of_degree_le hdq) (le_of_lt h) },\n      rw [polynomial.leading_coeff_X_pow, mul_one],\n      exact mt polynomial.leading_coeff_eq_zero.1 hq0 },\n    have h2 : p.leading_coeff = (q * polynomial.X ^ (k - q.nat_degree)).leading_coeff,\n    { rw [← hlqp, polynomial.leading_coeff_mul_X_pow] },\n    have := polynomial.degree_sub_lt h1 hp0 h2,\n    rw [polynomial.degree_eq_nat_degree hp0] at this,\n    rw ← sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span ↑s).add_mem _ ((ideal.span ↑s).mul_mem_right _ _),\n    { by_cases hpq : p - q * polynomial.X ^ (k - q.nat_degree) = 0,\n      { rw hpq, exact ideal.zero_mem _ },\n      refine ih _ _ (I.sub_mem hp (I.mul_mem_right _ hq)) rfl,\n      rwa [polynomial.degree_eq_nat_degree hpq, with_bot.coe_lt_coe, hn] at this },\n    exact hs2 ⟨polynomial.mem_degree_le.2 hdq, hq⟩ }\nend⟩⟩\n\nattribute [instance] polynomial.is_noetherian_ring\n\nnamespace polynomial\n\ntheorem exists_irreducible_of_degree_pos\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : polynomial R} (hf : 0 < f.degree) : ∃ g, irreducible g ∧ g ∣ f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (λ huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (λ hf0, not_lt_of_lt hf $ hf0.symm ▸ (@degree_zero R _).symm ▸ with_bot.bot_lt_coe _)\n\ntheorem exists_irreducible_of_nat_degree_pos\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : polynomial R} (hf : 0 < f.nat_degree) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_degree_pos $ by { contrapose! hf, exact nat_degree_le_of_degree_le hf }\n\ntheorem exists_irreducible_of_nat_degree_ne_zero\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : polynomial R} (hf : f.nat_degree ≠ 0) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_aeval\n  (f : M →ₗ[R] M) (v : M) :\n  linear_independent R (λ n : ℕ, (f ^ n) v)\n    ↔ ∀ (p : polynomial R), aeval f p v = 0 → p = 0 :=\nbegin\n  rw linear_independent_iff,\n  simp only [finsupp.total_apply, aeval_endomorphism, forall_iff_forall_finsupp, sum, support,\n    coeff, ← zero_to_finsupp],\n  exact iff.rfl,\nend\n\nlemma disjoint_ker_aeval_of_coprime\n  (f : M →ₗ[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  disjoint (aeval f p).ker (aeval f q).ker :=\nbegin\n  intros v hv,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  simpa [linear_map.mem_ker.1 (submodule.mem_inf.1 hv).1,\n         linear_map.mem_ker.1 (submodule.mem_inf.1 hv).2]\n    using congr_arg (λ p : polynomial R, aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M →ₗ[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).range ⊔ (aeval f q).range = ⊤ :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 ⟨aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 ⟨aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (λ p : polynomial R, aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M →ₗ[R] M} {p q : polynomial R} :\n  (aeval f p).ker ⊔ (aeval f q).ker ≤ (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with ⟨x, hx, y, hy, hxy⟩,\n  have h_eval_x : aeval f (p * q) x = 0,\n  { rw [mul_comm, aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hx, linear_map.map_zero] },\n  have h_eval_y : aeval f (p * q) y = 0,\n  { rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hy, linear_map.map_zero] },\n  rw [linear_map.mem_ker, ←hxy, linear_map.map_add, h_eval_x, h_eval_y, add_zero],\nend\n\nlemma sup_ker_aeval_eq_ker_aeval_mul_of_coprime\n  (f : M →ₗ[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).ker ⊔ (aeval f q).ker = (aeval f (p * q)).ker :=\nbegin\n  apply le_antisymm sup_ker_aeval_le_ker_aeval_mul,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  have h_eval₂_qpp' := calc\n    aeval f (q * (p * p')) v = aeval f (p' * (p * q)) v :\n      by rw [mul_comm, mul_assoc, mul_comm, mul_assoc, mul_comm q p]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  have h_eval₂_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [←mul_assoc, mul_comm]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  rw aeval_mul at h_eval₂_qpp' h_eval₂_pqq',\n  refine ⟨aeval f (q * q') v, linear_map.mem_ker.1 h_eval₂_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval₂_qpp', _⟩,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa using congr_arg (λ p : polynomial R, aeval f p v) hpq'\nend\n\nend polynomial\n\nnamespace mv_polynomial\n\nlemma is_noetherian_ring_fin_0 [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial (fin 0) R) :=\nis_noetherian_ring_of_ring_equiv R\n  ((mv_polynomial.is_empty_ring_equiv R pempty).symm.trans\n   (rename_equiv R fin_zero_equiv'.symm).to_ring_equiv)\n\ntheorem is_noetherian_ring_fin [is_noetherian_ring R] :\n  ∀ {n : ℕ}, is_noetherian_ring (mv_polynomial (fin n) R)\n| 0 := is_noetherian_ring_fin_0\n| (n+1) :=\n  @is_noetherian_ring_of_ring_equiv (polynomial (mv_polynomial (fin n) R)) _ _ _\n    (mv_polynomial.fin_succ_equiv _ n).to_ring_equiv.symm\n    (@polynomial.is_noetherian_ring (mv_polynomial (fin n) R) _ (is_noetherian_ring_fin))\n\n/-- The multivariate polynomial ring in finitely many variables over a noetherian ring\nis itself a noetherian ring. -/\ninstance is_noetherian_ring [fintype σ] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial σ R) :=\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card σ)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin σ).symm).to_ring_equiv is_noetherian_ring_fin\n\nlemma is_domain_fin_zero (R : Type u) [comm_ring R] [is_domain R] :\n  is_domain (mv_polynomial (fin 0) R) :=\nring_equiv.is_domain R\n  ((rename_equiv R fin_zero_equiv').to_ring_equiv.trans\n    (mv_polynomial.is_empty_ring_equiv R pempty))\n\n/-- Auxiliary lemma:\nMultivariate polynomials over an integral domain\nwith variables indexed by `fin n` form an integral domain.\nThis fact is proven inductively,\nand then used to prove the general case without any finiteness hypotheses.\nSee `mv_polynomial.is_domain` for the general case. -/\nlemma is_domain_fin (R : Type u) [comm_ring R] [is_domain R] :\n  ∀ (n : ℕ), is_domain (mv_polynomial (fin n) R)\n| 0 := is_domain_fin_zero R\n| (n+1) :=\n  begin\n    haveI := is_domain_fin n,\n    exact ring_equiv.is_domain\n      (polynomial (mv_polynomial (fin n) R))\n      (mv_polynomial.fin_succ_equiv _ n).to_ring_equiv\n  end\n\n/-- Auxiliary definition:\nMultivariate polynomials in finitely many variables over an integral domain form an integral domain.\nThis fact is proven by transport of structure from the `mv_polynomial.is_domain_fin`,\nand then used to prove the general case without finiteness hypotheses.\nSee `mv_polynomial.is_domain` for the general case. -/\nlemma is_domain_fintype (R : Type u) (σ : Type v) [comm_ring R] [fintype σ]\n  [is_domain R] : is_domain (mv_polynomial σ R) :=\n@ring_equiv.is_domain _ (mv_polynomial (fin $ fintype.card σ) R) _ _\n  (mv_polynomial.is_domain_fin _ _)\n  (rename_equiv R (fintype.equiv_fin σ)).to_ring_equiv\n\nprotected theorem eq_zero_or_eq_zero_of_mul_eq_zero\n  {R : Type u} [comm_ring R] [is_domain R] {σ : Type v}\n  (p q : mv_polynomial σ R) (h : p * q = 0) : p = 0 ∨ q = 0 :=\nbegin\n  obtain ⟨s, p, rfl⟩ := exists_finset_rename p,\n  obtain ⟨t, q, rfl⟩ := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x ∈ s} → {x // x ∈ s ∪ t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x ∈ t} → {x // x ∈ s ∪ t}) q = 0,\n  { apply rename_injective _ subtype.val_injective, simpa using h },\n  letI := mv_polynomial.is_domain_fintype R {x // x ∈ (s ∪ t)},\n  rw mul_eq_zero at this,\n  cases this; [left, right],\n  all_goals { simpa using congr_arg (rename subtype.val) this }\nend\n\n/-- The multivariate polynomial ring over an integral domain is an integral domain. -/\ninstance {R : Type u} {σ : Type v} [comm_ring R] [is_domain R] :\n  is_domain (mv_polynomial σ R) :=\n{ eq_zero_or_eq_zero_of_mul_eq_zero := mv_polynomial.eq_zero_or_eq_zero_of_mul_eq_zero,\n  exists_pair_ne := ⟨0, 1, λ H,\n  begin\n    have : eval₂ (ring_hom.id _) (λ s, (0:R)) (0 : mv_polynomial σ R) =\n      eval₂ (ring_hom.id _) (λ s, (0:R)) (1 : mv_polynomial σ R),\n    { congr, exact H },\n    simpa,\n  end⟩,\n  .. (by apply_instance : comm_ring (mv_polynomial σ R)) }\n\nlemma map_mv_polynomial_eq_eval₂ {S : Type*} [comm_ring S] [fintype σ]\n  (ϕ : mv_polynomial σ R →+* S) (p : mv_polynomial σ R) :\n  ϕ p = mv_polynomial.eval₂ (ϕ.comp mv_polynomial.C) (λ s, ϕ (mv_polynomial.X s)) p :=\nbegin\n  refine trans (congr_arg ϕ (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval₂_eq', ϕ.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, ϕ.map_pow, ϕ.map_prod, ϕ.comp_apply, ϕ.map_mul, finsupp.prod_pow],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} {i : R} (hi : i ∈ I) :\n  (ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial σ R))).comp C i = 0 :=\nbegin\n  simp only [function.comp_app, ring_hom.coe_comp, ideal.quotient.eq_zero_iff_mem],\n  exact ideal.mem_map_of_mem _ hi\nend\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself,\nmultivariate version. -/\nlemma mem_ideal_of_coeff_mem_ideal (I : ideal (mv_polynomial σ R)) (p : mv_polynomial σ R)\n  (hcoe : ∀ (m : σ →₀ ℕ), p.coeff m ∈ I.comap C) : p ∈ I :=\nbegin\n  rw as_sum p,\n  suffices : ∀ m ∈ p.support, monomial m (mv_polynomial.coeff m p) ∈ I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [← mul_one (coeff m p), ← C_mul_monomial],\n  suffices : C (coeff m p) ∈ I,\n  { exact I.mul_mem_right (monomial m 1) this },\n  simpa [ideal.mem_comap] using hcoe m\nend\n\n/-- The push-forward of an ideal `I` of `R` to `mv_polynomial σ R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : mv_polynomial σ R} :\n  f ∈ (ideal.map C I : ideal (mv_polynomial σ R)) ↔ ∀ (m : σ →₀ ℕ), f.coeff m ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n    { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : ∀ m ∈ f.support, monomial m (coeff m f) ∈\n      (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [← mul_one (coeff m f), ← C_mul_monomial],\n    suffices : C (coeff m f) ∈ (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact ideal.mul_mem_right _ _ this },\n    apply ideal.mem_map_of_mem _,\n    exact hf m }\nend\n\nlemma ker_map (f : R →+* S) : (map f : mv_polynomial σ R →+* mv_polynomial σ S).ker = f.ker.map C :=\nbegin\n  ext,\n  rw [mv_polynomial.mem_map_C_iff, ring_hom.mem_ker, mv_polynomial.ext_iff],\n  simp_rw [coeff_map, coeff_zero, ring_hom.mem_ker],\nend\n\nlemma eval₂_C_mk_eq_zero {I : ideal R} {a : mv_polynomial σ R}\n  (ha : a ∈ (ideal.map C I : ideal (mv_polynomial σ R))) :\n  eval₂_hom (C.comp (ideal.quotient.mk I)) X a = 0 :=\nbegin\n  rw as_sum a,\n  rw [coe_eval₂_hom, eval₂_sum],\n  refine finset.sum_eq_zero (λ n hn, _),\n  simp only [eval₂_monomial, function.comp_app, ring_hom.coe_comp],\n  refine mul_eq_zero_of_left _ _,\n  suffices : coeff n a ∈ I,\n  { rw [← @ideal.mk_ker R _ I, ring_hom.mem_ker] at this,\n    simp only [this, C_0] },\n  exact mem_map_C_iff.1 ha n\nend\n\n/-- If `I` is an ideal of `R`, then the ring `mv_polynomial σ I.quotient` is isomorphic as an\n`R`-algebra to the quotient of `mv_polynomial σ R` by the ideal generated by `I`. -/\ndef quotient_equiv_quotient_mv_polynomial (I : ideal R) :\n  mv_polynomial σ (R ⧸ I) ≃ₐ[R]\n    mv_polynomial σ R ⧸ (ideal.map C I : ideal (mv_polynomial σ R)) :=\n{ to_fun := eval₂_hom (ideal.quotient.lift I ((ideal.quotient.mk (ideal.map C I : ideal\n    (mv_polynomial σ R))).comp C) (λ i hi, quotient_map_C_eq_zero hi))\n    (λ i, ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial σ R)) (X i)),\n  inv_fun := ideal.quotient.lift (ideal.map C I : ideal (mv_polynomial σ R))\n    (eval₂_hom (C.comp (ideal.quotient.mk I)) X) (λ a ha, eval₂_C_mk_eq_zero ha),\n  map_mul' := ring_hom.map_mul _,\n  map_add' := ring_hom.map_add _,\n  left_inv := begin\n    intro f,\n    apply induction_on f,\n    { rintro ⟨r⟩,\n      rw [coe_eval₂_hom, eval₂_C],\n      simp only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk,\n        ideal.quotient.mk_eq_mk, bind₂_C_right, ring_hom.coe_comp] },\n    { simp_intros p q hp hq only [ring_hom.map_add, mv_polynomial.coe_eval₂_hom, coe_eval₂_hom,\n        mv_polynomial.eval₂_add, mv_polynomial.eval₂_hom_eq_bind₂, eval₂_hom_eq_bind₂],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval₂_hom_eq_bind₂, coe_eval₂_hom],\n      simp only [hp, eval₂_hom_eq_bind₂, coe_eval₂_hom, ideal.quotient.lift_mk, bind₂_X_right,\n        eval₂_mul, ring_hom.map_mul, eval₂_X] }\n  end,\n  right_inv := begin\n    rintro ⟨f⟩,\n    apply induction_on f,\n    { intros r,\n      simp only [submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk,\n        ring_hom.coe_comp, eval₂_hom_C] },\n    { simp_intros p q hp hq only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, eval₂_add,\n        ring_hom.map_add, coe_eval₂_hom, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, coe_eval₂_hom,\n        ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk, bind₂_X_right, eval₂_mul, ring_hom.map_mul,\n        eval₂_X],\n      simp only [hp] }\n  end,\n  commutes' := λ r, eval₂_hom_C _ _ (ideal.quotient.mk I r) }\n\nend mv_polynomial\n\nnamespace polynomial\nopen unique_factorization_monoid\n\nvariables {D : Type u} [comm_ring D] [is_domain D] [unique_factorization_monoid D]\n\n@[priority 100]\ninstance unique_factorization_monoid : unique_factorization_monoid (polynomial D) :=\nbegin\n  haveI := arbitrary (normalization_monoid D),\n  haveI := to_normalized_gcd_monoid D,\n  exact ufm_of_gcd_of_wf_dvd_monoid\nend\n\nend polynomial\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/ring_theory/polynomial/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.49357182109950976}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.list.basic\n\n/-!\n# Boolean quantifiers\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis proves a few properties about `list.all` and `list.any`, which are the `bool` universal and\nexistential quantifiers. Their definitions are in core Lean.\n-/\n\nvariables {α : Type*} {p : α → Prop} [decidable_pred p] {l : list α} {a : α}\n\nnamespace list\n\n@[simp] theorem all_nil (p : α → bool) : all [] p = tt := rfl\n\n@[simp] theorem all_cons (p : α → bool) (a : α) (l : list α) : all (a::l) p = (p a && all l p) :=\nrfl\n\n\n\ntheorem all_iff_forall_prop : all l (λ a, p a) ↔ ∀ a ∈ l, p a :=\nby simp only [all_iff_forall, bool.of_to_bool_iff]\n\n@[simp] theorem any_nil (p : α → bool) : any [] p = ff := rfl\n\n@[simp] theorem any_cons (p : α → bool) (a : α) (l : list α) : any (a :: l) p = (p a || any l p) :=\nrfl\n\ntheorem any_iff_exists {p : α → bool} : any l p ↔ ∃ a ∈ l, p a :=\nbegin\n  induction l with a l ih,\n  { exact iff_of_false bool.not_ff (not_exists_mem_nil _) },\n  simp only [any_cons, bor_coe_iff, ih, exists_mem_cons_iff]\nend\n\ntheorem any_iff_exists_prop : any l (λ a, p a) ↔ ∃ a ∈ l, p a := by simp [any_iff_exists]\n\ntheorem any_of_mem {p : α → bool} (h₁ : a ∈ l) (h₂ : p a) : any l p := any_iff_exists.2 ⟨_, h₁, h₂⟩\n\nend list\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/bool/all_any.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.49354849029461634}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module data.quot\n! leanprover-community/mathlib commit 6ed6abbde29b8f630001a1b481603f657a3384f1\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Init.Data.Quot\nimport Mathlib.Logic.Relator\n\n/-!\n# Quotient types\nThis module extends the core library's treatment of quotient types (`Init.Core`).\n## Tags\nquotient\n-/\n\n\nvariable {α : Sort _} {β : Sort _}\n\nnamespace Setoid\n\n#align setoid.r Setoid.r\n\ntheorem ext {α : Sort _} : ∀ {s t : Setoid α},\n    (∀ a b, @Setoid.r α s a b ↔ @Setoid.r α t a b) → s = t\n  | ⟨r, _⟩, ⟨p, _⟩, Eq =>\n  by have : r = p := funext fun a ↦ funext fun b ↦ propext <| Eq a b\n     subst this\n     rfl\n#align setoid.ext Setoid.ext\n\nend Setoid\n\nnamespace Quot\n\nvariable {ra : α → α → Prop} {rb : β → β → Prop} {φ : Quot ra → Quot rb → Sort _}\n\n-- mathport name: mk\n@[inherit_doc]\nlocal notation:arg \"⟦\" a \"⟧\" => Quot.mk _ a\n\n@[elab_as_elim]\nprotected theorem induction_on {α : Sort u} {r : α → α → Prop} {β : Quot r → Prop} (q : Quot r)\n    (h : ∀ a, β (Quot.mk r a)) : β q :=\n  ind h q\n\ninstance (r : α → α → Prop) [Inhabited α] : Inhabited (Quot r) :=\n  ⟨⟦default⟧⟩\n\nprotected instance Subsingleton [Subsingleton α] : Subsingleton (Quot ra) :=\n  ⟨fun x ↦ Quot.induction_on x fun _ ↦ Quot.ind fun _ ↦ congr_arg _ (Subsingleton.elim _ _)⟩\n#align quot.subsingleton Quot.Subsingleton\n\n/-- Recursion on two `Quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrecOn₂ (qa : Quot ra) (qb : Quot rb) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧)\n    (ca : ∀ {b a₁ a₂}, ra a₁ a₂ → HEq (f a₁ b) (f a₂ b))\n    (cb : ∀ {a b₁ b₂}, rb b₁ b₂ → HEq (f a b₁) (f a b₂)) :\n    φ qa qb :=\n  Quot.hrecOn (motive := fun qa ↦ φ qa qb) qa\n    (fun a ↦ Quot.hrecOn qb (f a) (fun b₁ b₂ pb ↦ cb pb))\n    fun a₁ a₂ pa ↦\n      Quot.induction_on qb fun b ↦\n        have h₁ : HEq (@Quot.hrecOn _ _ (φ _) ⟦b⟧ (f a₁) (@cb _)) (f a₁ b) :=\n          by simp [heq_self_iff_true]\n        have h₂ : HEq (f a₂ b) (@Quot.hrecOn _ _ (φ _) ⟦b⟧ (f a₂) (@cb _)) :=\n          by simp [heq_self_iff_true]\n        (h₁.trans (ca pa)).trans h₂\n#align quot.hrec_on₂ Quot.hrecOn₂\n\n/-- Map a function `f : α → β` such that `ra x y` implies `rb (f x) (f y)`\nto a map `Quot ra → Quot rb`. -/\nprotected def map (f : α → β) (h : (ra ⇒ rb) f f) : Quot ra → Quot rb :=\n  (Quot.lift fun x ↦ ⟦f x⟧) fun x y (h₁ : ra x y) ↦ Quot.sound <| h h₁\n#align quot.map Quot.map\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `Quot ra → Quot ra'`. -/\nprotected def mapRight {ra' : α → α → Prop} (h : ∀ a₁ a₂, ra a₁ a₂ → ra' a₁ a₂) :\n    Quot ra → Quot ra' :=\n  Quot.map id h\n#align quot.map_right Quot.mapRight\n\n/-- Weaken the relation of a quotient. This is the same as `Quot.map id`. -/\ndef factor {α : Type _} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) : Quot r → Quot s :=\n  Quot.lift (Quot.mk s) fun x y rxy ↦ Quot.sound (h x y rxy)\n#align quot.factor Quot.factor\n\ntheorem factor_mk_eq {α : Type _} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n    factor r s h ∘ Quot.mk _ = Quot.mk _ :=\n  rfl\n#align quot.factor_mk_eq Quot.factor_mk_eq\n\nvariable {γ : Sort _} {r : α → α → Prop} {s : β → β → Prop}\n\n-- Porting note: used to be an Alias of `quot.lift_beta`.\ntheorem lift_mk (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) (a : α) :\n    Quot.lift f h (Quot.mk r a) = f a :=\n  rfl\n#align quot.lift_beta Quot.lift_mk\n#align quot.lift_mk Quot.lift_mk\n\ntheorem liftOn_mk (a : α) (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :\n  Quot.liftOn (Quot.mk r a) f h = f a :=\n  rfl\n#align quot.lift_on_mk Quot.liftOn_mk\n\n@[simp] theorem surjective_lift {f : α → γ} (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :\n    Function.Surjective (lift f h) ↔ Function.Surjective f :=\n  ⟨fun hf => hf.comp Quot.exists_rep, fun hf y => let ⟨x, hx⟩ := hf y; ⟨Quot.mk _ x, hx⟩⟩\n#align quot.surjective_lift Quot.surjective_lift\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β`. -/\n-- porting note: removed `@[elab_as_elim]`, gave \"unexpected resulting type γ\"\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\nprotected def lift₂ (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) (q₁ : Quot r) (q₂ : Quot s) : γ :=\n  Quot.lift (fun a ↦ Quot.lift (f a) (hr a))\n    (fun a₁ a₂ ha ↦ funext fun q ↦ Quot.induction_on q fun b ↦ hs a₁ a₂ b ha) q₁ q₂\n#align quot.lift₂ Quot.lift₂\n\n@[simp]\ntheorem lift₂_mk (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n    (a : α) (b : β) : Quot.lift₂ f hr hs (Quot.mk r a) (Quot.mk s b) = f a b :=\n  rfl\n#align quot.lift₂_mk Quot.lift₂_mk\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` and applies it. -/\n-- porting note: removed `@[elab_as_elim]`, gave \"unexpected resulting type γ\"\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\nprotected def liftOn₂ (p : Quot r) (q : Quot s) (f : α → β → γ)\n    (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂) (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) : γ :=\n  Quot.lift₂ f hr hs p q\n#align quot.lift_on₂ Quot.liftOn₂\n\n@[simp]\ntheorem liftOn₂_mk (a : α) (b : β) (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) :\n    Quot.liftOn₂ (Quot.mk r a) (Quot.mk s b) f hr hs = f a b :=\n  rfl\n#align quot.lift_on₂_mk Quot.liftOn₂_mk\n\nvariable {t : γ → γ → Prop}\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` wih values in a quotient of\n`γ`. -/\nprotected def map₂ (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b)) (q₁ : Quot r) (q₂ : Quot s) : Quot t :=\n  Quot.lift₂ (fun a b ↦ Quot.mk t <| f a b) (fun a b₁ b₂ hb ↦ Quot.sound (hr a b₁ b₂ hb))\n    (fun a₁ a₂ b ha ↦ Quot.sound (hs a₁ a₂ b ha)) q₁ q₂\n#align quot.map₂ Quot.map₂\n\n@[simp]\ntheorem map₂_mk (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b)) (a : α) (b : β) :\n    Quot.map₂ f hr hs (Quot.mk r a) (Quot.mk s b) = Quot.mk t (f a b) :=\n  rfl\n#align quot.map₂_mk Quot.map₂_mk\n\n/-- A binary version of `Quot.recOnSubsingleton`. -/\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\n@[elab_as_elim]\nprotected def recOnSubsingleton₂ {φ : Quot r → Quot s → Sort _}\n    [h : ∀ a b, Subsingleton (φ ⟦a⟧ ⟦b⟧)] (q₁ : Quot r)\n    (q₂ : Quot s) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧) : φ q₁ q₂ :=\n  @Quot.recOnSubsingleton _ r (fun q ↦ φ q q₂)\n    (fun a ↦ Quot.ind (β := λ b => Subsingleton (φ (mk r a) b)) (h a) q₂) q₁\n    fun a ↦ Quot.recOnSubsingleton q₂ fun b ↦ f a b\n#align quot.rec_on_subsingleton₂ Quot.recOnSubsingleton₂\n\n@[elab_as_elim]\nprotected theorem induction_on₂ {δ : Quot r → Quot s → Prop} (q₁ : Quot r) (q₂ : Quot s)\n    (h : ∀ a b, δ (Quot.mk r a) (Quot.mk s b)) : δ q₁ q₂ :=\n  Quot.ind (β := λ a => δ a q₂) (fun a₁ ↦ Quot.ind (fun a₂ ↦ h a₁ a₂) q₂) q₁\n#align quot.induction_on₂ Quot.induction_on₂\n\n@[elab_as_elim]\nprotected theorem induction_on₃ {δ : Quot r → Quot s → Quot t → Prop} (q₁ : Quot r)\n    (q₂ : Quot s) (q₃ : Quot t) (h : ∀ a b c, δ (Quot.mk r a) (Quot.mk s b) (Quot.mk t c)) :\n    δ q₁ q₂ q₃ :=\n  Quot.ind (β := λ a => δ a q₂ q₃) (fun a₁ ↦ Quot.ind (β := λ b => δ _ b q₃)\n    (fun a₂ ↦ Quot.ind (fun a₃ ↦ h a₁ a₂ a₃) q₃) q₂) q₁\n#align quot.induction_on₃ Quot.induction_on₃\n\ninstance lift.decidablePred (r : α → α → Prop) (f : α → Prop) (h : ∀ a b, r a b → f a = f b)\n    [hf : DecidablePred f] :\n    DecidablePred (Quot.lift f h) :=\n  fun q ↦ Quot.recOnSubsingleton (motive := λ _ => Decidable _) q hf\n\n/-- Note that this provides `DecidableRel (Quot.Lift₂ f ha hb)` when `α = β`. -/\ninstance lift₂.decidablePred (r : α → α → Prop) (s : β → β → Prop) (f : α → β → Prop)\n    (ha : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂) (hb : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n    [hf : ∀ a, DecidablePred (f a)] (q₁ : Quot r) :\n    DecidablePred (Quot.lift₂ f ha hb q₁) :=\n  fun q₂ ↦ Quot.recOnSubsingleton₂ q₁ q₂ hf\n\ninstance (r : α → α → Prop) (q : Quot r) (f : α → Prop) (h : ∀ a b, r a b → f a = f b)\n    [DecidablePred f] :\n    Decidable (Quot.liftOn q f h) :=\n  Quot.lift.decidablePred _ _ _ _\n\ninstance (r : α → α → Prop) (s : β → β → Prop) (q₁ : Quot r) (q₂ : Quot s) (f : α → β → Prop)\n    (ha : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂) (hb : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n    [∀ a, DecidablePred (f a)] :\n    Decidable (Quot.liftOn₂ q₁ q₂ f ha hb) :=\n  Quot.lift₂.decidablePred _ _ _ _ _ _ _\n\nend Quot\n\nnamespace Quotient\n\nvariable [sa : Setoid α] [sb : Setoid β]\n\nvariable {φ : Quotient sa → Quotient sb → Sort _}\n\n@[inherit_doc]\nnotation:arg \"⟦\" a \"⟧\" => Quotient.mk _ a\n\ninstance (s : Setoid α) [Inhabited α] : Inhabited (Quotient s) :=\n  ⟨⟦default⟧⟩\n\ninstance (s : Setoid α) [Subsingleton α] : Subsingleton (Quotient s) :=\n  Quot.Subsingleton\n\ninstance {α : Type _} [Setoid α] : IsEquiv α (· ≈ ·) where\n  refl := Setoid.refl\n  symm _ _ := Setoid.symm\n  trans _ _ _ := Setoid.trans\n\n/-- Induction on two `Quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrecOn₂ (qa : Quotient sa) (qb : Quotient sb) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧)\n    (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → HEq (f a₁ b₁) (f a₂ b₂)) : φ qa qb :=\n  Quot.hrecOn₂ qa qb f (fun p ↦ c _ _ _ _ p (Setoid.refl _)) fun p ↦ c _ _ _ _ (Setoid.refl _) p\n#align quotient.hrec_on₂ Quotient.hrecOn₂\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `Quotient sa → Quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : α → β) (h : ((· ≈ ·) ⇒ (· ≈ ·)) f f) : Quotient sa → Quotient sb :=\n  Quot.map f h\n#align quotient.map Quotient.map\n\n@[simp]\ntheorem map_mk (f : α → β) (h : ((· ≈ ·) ⇒ (· ≈ ·)) f f) (x : α) :\n    Quotient.map f h (⟦x⟧ : Quotient sa) = (⟦f x⟧ : Quotient sb) :=\n  rfl\n#align quotient.map_mk Quotient.map_mk\n\nvariable {γ : Sort _} [sc : Setoid γ]\n\n/-- Map a function `f : α → β → γ` that sends equivalent elements to equivalent elements\nto a function `f : Quotient sa → Quotient sb → Quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map₂ (f : α → β → γ) (h : ((· ≈ ·) ⇒ (· ≈ ·) ⇒ (· ≈ ·)) f f) :\n    Quotient sa → Quotient sb → Quotient sc :=\n  Quotient.lift₂ (fun x y ↦ ⟦f x y⟧) fun _ _ _ _ h₁ h₂ ↦ Quot.sound <| h h₁ h₂\n#align quotient.map₂ Quotient.map₂\n\n@[simp]\ntheorem map₂_mk (f : α → β → γ) (h : ((· ≈ ·) ⇒ (· ≈ ·) ⇒ (· ≈ ·)) f f) (x : α) (y : β) :\n    Quotient.map₂ f h (⟦x⟧ : Quotient sa) (⟦y⟧ : Quotient sb) = (⟦f x y⟧ : Quotient sc) :=\n  rfl\n#align quotient.map₂_mk Quotient.map₂_mk\n\ninstance lift.decidablePred (f : α → Prop) (h : ∀ a b, a ≈ b → f a = f b) [DecidablePred f] :\n    DecidablePred (Quotient.lift f h) :=\n  Quot.lift.decidablePred _ _ _\n\n/-- Note that this provides `DecidableRel (Quotient.lift₂ f h)` when `α = β`. -/\ninstance lift₂.decidablePred (f : α → β → Prop)\n    (h : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ = f a₂ b₂)\n    [hf : ∀ a, DecidablePred (f a)]\n    (q₁ : Quotient sa) : DecidablePred (Quotient.lift₂ f h q₁) :=\n  fun q₂ ↦ Quotient.recOnSubsingleton₂ q₁ q₂ hf\n\ninstance (q : Quotient sa) (f : α → Prop) (h : ∀ a b, a ≈ b → f a = f b) [DecidablePred f] :\n    Decidable (Quotient.liftOn q f h) :=\n  Quotient.lift.decidablePred _ _ _\n\ninstance (q₁ : Quotient sa) (q₂ : Quotient sb) (f : α → β → Prop)\n    (h : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ = f a₂ b₂) [∀ a, DecidablePred (f a)] :\n    Decidable (Quotient.liftOn₂ q₁ q₂ f h) :=\n  Quotient.lift₂.decidablePred _ _ _ _\n\nend Quotient\n\ntheorem Quot.eq {α : Type _} {r : α → α → Prop} {x y : α} :\n    Quot.mk r x = Quot.mk r y ↔ EqvGen r x y :=\n  ⟨Quot.exact r, Quot.EqvGen_sound⟩\n#align quot.eq Quot.eq\n\n@[simp]\ntheorem Quotient.eq [r : Setoid α] {x y : α} : Quotient.mk r x = ⟦y⟧ ↔ x ≈ y :=\n  ⟨Quotient.exact, Quotient.sound⟩\n\ntheorem forall_quotient_iff {α : Type _} [r : Setoid α] {p : Quotient r → Prop} :\n    (∀ a : Quotient r, p a) ↔ ∀ a : α, p ⟦a⟧ :=\n  ⟨fun h _ ↦ h _, fun h a ↦ a.induction_on h⟩\n#align forall_quotient_iff forall_quotient_iff\n\n@[simp]\ntheorem Quotient.lift_mk [s : Setoid α] (f : α → β) (h : ∀ a b : α, a ≈ b → f a = f b) (x : α) :\n    Quotient.lift f h (Quotient.mk s x) = f x :=\nrfl\n#align quotient.lift_mk Quotient.lift_mk\n\n@[simp]\ntheorem Quotient.lift_comp_mk [Setoid α] (f : α → β) (h : ∀ a b : α, a ≈ b → f a = f b) :\n    Quotient.lift f h ∘ Quotient.mk _ = f :=\n  rfl\n#align quotient.lift_comp_mk Quotient.lift_comp_mk\n\n@[simp]\ntheorem Quotient.lift₂_mk {α : Sort _} {β : Sort _} {γ : Sort _} [Setoid α] [Setoid β]\n    (f : α → β → γ)\n    (h : ∀ (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂)\n    (a : α) (b : β) :\n    Quotient.lift₂ f h (Quotient.mk _ a) (Quotient.mk _ b) = f a b :=\n  rfl\n#align quotient.lift₂_mk Quotient.lift₂_mk\n\ntheorem Quotient.liftOn_mk [s : Setoid α] (f : α → β) (h : ∀ a b : α, a ≈ b → f a = f b) (x : α) :\n    Quotient.liftOn (Quotient.mk s x) f h = f x :=\n  rfl\n#align quotient.lift_on_mk Quotient.liftOn_mk\n\n@[simp]\ntheorem Quotient.liftOn₂_mk {α : Sort _} {β : Sort _} [Setoid α] (f : α → α → β)\n    (h : ∀ a₁ a₂ b₁ b₂ : α, a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂) (x y : α) :\n    Quotient.liftOn₂ (Quotient.mk _ x) (Quotient.mk _ y) f h = f x y :=\n  rfl\n#align quotient.lift_on₂_mk Quotient.liftOn₂_mk\n\n/-- `Quot.mk r` is a surjective function. -/\ntheorem surjective_quot_mk (r : α → α → Prop) : Function.Surjective (Quot.mk r) :=\n  Quot.exists_rep\n#align surjective_quot_mk surjective_quot_mk\n\n/-- `Quotient.mk` is a surjective function. -/\ntheorem surjective_quotient_mk (α : Sort _) [s : Setoid α] :\n    Function.Surjective (Quotient.mk _ : α → Quotient s) :=\n  Quot.exists_rep\n#align surjective_quotient_mk surjective_quotient_mk\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def Quot.out {r : α → α → Prop} (q : Quot r) : α :=\n  Classical.choose (Quot.exists_rep q)\n#align quot.out Quot.out\n\n/-- Unwrap the VM representation of a quotient to obtain an element of the equivalence class.\n  Computable but unsound. -/\nunsafe def Quot.unquot {r : α → α → Prop} : Quot r → α :=\n  cast lcProof -- porting notes: was `unchecked_cast` before, which unfolds to `cast undefined`\n\n@[simp]\ntheorem Quot.out_eq {r : α → α → Prop} (q : Quot r) : Quot.mk r q.out = q :=\n  Classical.choose_spec (Quot.exists_rep q)\n#align quot.out_eq Quot.out_eq\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def Quotient.out [s : Setoid α] : Quotient s → α :=\n  Quot.out\n#align quotient.out Quotient.out\n\n@[simp]\ntheorem Quotient.out_eq [s : Setoid α] (q : Quotient s) : ⟦q.out⟧ = q :=\n  Quot.out_eq q\n#align quotient.out_eq Quotient.out_eq\n\ntheorem Quotient.mk_out [Setoid α] (a : α) : ⟦a⟧.out ≈ a :=\n  Quotient.exact (Quotient.out_eq _)\n#align quotient.mk_out Quotient.mk_out\n\ntheorem Quotient.mk_eq_iff_out [s : Setoid α] {x : α} {y : Quotient s} :\n    ⟦x⟧ = y ↔ x ≈ Quotient.out y := by\n  refine' Iff.trans _ Quotient.eq\n  rw [Quotient.out_eq y]\n#align quotient.mk_eq_iff_out Quotient.mk_eq_iff_out\n\ntheorem Quotient.eq_mk_iff_out [s : Setoid α] {x : Quotient s} {y : α} :\n    x = ⟦y⟧ ↔ Quotient.out x ≈ y := by\n  refine' Iff.trans _ Quotient.eq\n  rw [Quotient.out_eq x]\n#align quotient.eq_mk_iff_out Quotient.eq_mk_iff_out\n\n@[simp]\ntheorem Quotient.out_equiv_out {s : Setoid α} {x y : Quotient s} : x.out ≈ y.out ↔ x = y := by\n  rw [← Quotient.eq_mk_iff_out, Quotient.out_eq]\n#align quotient.out_equiv_out Quotient.out_equiv_out\n\ntheorem Quotient.out_injective {s : Setoid α} : Function.Injective (@Quotient.out α s) :=\n  fun _ _ h ↦ Quotient.out_equiv_out.1 <| h ▸ Setoid.refl _\n#align quotient.out_injective Quotient.out_injective\n\n@[simp]\ntheorem Quotient.out_inj {s : Setoid α} {x y : Quotient s} : x.out = y.out ↔ x = y :=\n  ⟨fun h ↦ Quotient.out_injective h, fun h ↦ h ▸ rfl⟩\n#align quotient.out_inj Quotient.out_inj\n\nsection Pi\n\ninstance piSetoid {ι : Sort _} {α : ι → Sort _} [∀ i, Setoid (α i)] : Setoid (∀ i, α i) where\n  r a b := ∀ i, a i ≈ b i\n  iseqv := ⟨fun _ _ ↦ Setoid.refl _,\n            fun h _ ↦ Setoid.symm (h _),\n            fun h₁ h₂ _ ↦ Setoid.trans (h₁ _) (h₂ _)⟩\n\n/-- Given a function `f : Π i, Quotient (S i)`, returns the class of functions `Π i, α i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def Quotient.choice {ι : Type _} {α : ι → Type _} [S : ∀ i, Setoid (α i)]\n    (f : ∀ i, Quotient (S i)) :\n    @Quotient (∀ i, α i) (by infer_instance) :=\n  ⟦fun i ↦ (f i).out⟧\n#align quotient.choice Quotient.choice\n\n@[simp]\ntheorem Quotient.choice_eq {ι : Type _} {α : ι → Type _} [∀ i, Setoid (α i)] (f : ∀ i, α i) :\n    (Quotient.choice fun i ↦ ⟦f i⟧) = ⟦f⟧ :=\n  Quotient.sound fun _ ↦ Quotient.mk_out _\n#align quotient.choice_eq Quotient.choice_eq\n\n@[elab_as_elim]\ntheorem Quotient.induction_on_pi {ι : Type _} {α : ι → Sort _} [s : ∀ i, Setoid (α i)]\n    {p : (∀ i, Quotient (s i)) → Prop} (f : ∀ i, Quotient (s i))\n    (h : ∀ a : ∀ i, α i, p fun i ↦ ⟦a i⟧) : p f := by\n  rw [← (funext fun i ↦ Quotient.out_eq (f i) : (fun i ↦ ⟦(f i).out⟧) = f)]\n  apply h\n#align quotient.induction_on_pi Quotient.induction_on_pi\n\nend Pi\n\ntheorem nonempty_quotient_iff (s : Setoid α) : Nonempty (Quotient s) ↔ Nonempty α :=\n  ⟨fun ⟨a⟩ ↦ Quotient.inductionOn a Nonempty.intro, fun ⟨a⟩ ↦ ⟨⟦a⟧⟩⟩\n#align nonempty_quotient_iff nonempty_quotient_iff\n\n/-! ### Truncation -/\n\n\ntheorem true_equivalence : @Equivalence α fun _ _ ↦ True :=\n  ⟨fun _ ↦ trivial, fun _ ↦ trivial, fun _ _ ↦ trivial⟩\n#align true_equivalence true_equivalence\n\n/-- Always-true relation as a `Setoid`.\n\nNote that in later files the preferred spelling is `⊤ : Setoid α`. -/\ndef trueSetoid : Setoid α :=\n  ⟨_, true_equivalence⟩\n#align true_setoid trueSetoid\n\n/-- `Trunc α` is the quotient of `α` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `Nonempty α`, but unlike `Nonempty α`, `Trunc α` is data,\n  so the VM representation is the same as `α`, and so this can be used to\n  maintain computability. -/\ndef Trunc.{u} (α : Sort u) : Sort u :=\n  @Quotient α trueSetoid\n#align trunc Trunc\n\nnamespace Trunc\n\n/-- Constructor for `Trunc α` -/\ndef mk (a : α) : Trunc α :=\n  Quot.mk _ a\n#align trunc.mk Trunc.mk\n\ninstance [Inhabited α] : Inhabited (Trunc α) :=\n  ⟨mk default⟩\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : α → β) (c : ∀ a b : α, f a = f b) : Trunc α → β :=\n  Quot.lift f fun a b _ ↦ c a b\n#align trunc.lift Trunc.lift\n\ntheorem ind {β : Trunc α → Prop} : (∀ a : α, β (mk a)) → ∀ q : Trunc α, β q :=\n  Quot.ind\n#align trunc.ind Trunc.ind\n\nprotected theorem lift_mk (f : α → β) (c) (a : α) : lift f c (mk a) = f a :=\n  rfl\n#align trunc.lift_mk Trunc.lift_mk\n\n/-- Lift a constant function on `q : Trunc α`. -/\n-- porting note: removed `@[elab_as_elim]` because it gave \"unexpected eliminator resulting type\"\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\nprotected def liftOn (q : Trunc α) (f : α → β) (c : ∀ a b : α, f a = f b) : β :=\n  lift f c q\n#align trunc.lift_on Trunc.liftOn\n\n@[elab_as_elim]\nprotected theorem induction_on {β : Trunc α → Prop} (q : Trunc α) (h : ∀ a, β (mk a)) : β q :=\n  ind h q\n#align trunc.induction_on Trunc.induction_on\n\ntheorem exists_rep (q : Trunc α) : ∃ a : α, mk a = q :=\n  Quot.exists_rep q\n#align trunc.exists_rep Trunc.exists_rep\n\n@[elab_as_elim]\nprotected theorem induction_on₂ {C : Trunc α → Trunc β → Prop} (q₁ : Trunc α) (q₂ : Trunc β)\n    (h : ∀ a b, C (mk a) (mk b)) : C q₁ q₂ :=\n  Trunc.induction_on q₁ fun a₁ ↦ Trunc.induction_on q₂ (h a₁)\n#align trunc.induction_on₂ Trunc.induction_on₂\n\nprotected theorem eq (a b : Trunc α) : a = b :=\n  Trunc.induction_on₂ a b fun _ _ ↦ Quot.sound trivial\n#align trunc.eq Trunc.eq\n\ninstance : Subsingleton (Trunc α) :=\n  ⟨Trunc.eq⟩\n\n/-- The `bind` operator for the `Trunc` monad. -/\ndef bind (q : Trunc α) (f : α → Trunc β) : Trunc β :=\n  Trunc.liftOn q f fun _ _ ↦ Trunc.eq _ _\n#align trunc.bind Trunc.bind\n\n/-- A function `f : α → β` defines a function `map f : Trunc α → Trunc β`. -/\ndef map (f : α → β) (q : Trunc α) : Trunc β :=\n  bind q (Trunc.mk ∘ f)\n#align trunc.map Trunc.map\n\ninstance : Monad Trunc where\n  pure := @Trunc.mk\n  bind := @Trunc.bind\n\ninstance : LawfulMonad Trunc where\n  id_map _ := Trunc.eq _ _\n  pure_bind _ _ := rfl\n  bind_assoc _ _ _ := Trunc.eq _ _\n  -- porting note: the fields below are new in Lean 4\n  map_const := rfl\n  seqLeft_eq _ _ := Trunc.eq _ _\n  seqRight_eq _ _ := Trunc.eq _ _\n  pure_seq _ _ := rfl\n  bind_pure_comp _ _ := rfl\n  bind_map _ _ := rfl\n\nvariable {C : Trunc α → Sort _}\n\n/-- Recursion/induction principle for `Trunc`. -/\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\n@[elab_as_elim]\nprotected def rec (f : ∀ a, C (mk a))\n    (h : ∀ a b : α, (Eq.ndrec (f a) (Trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n    (q : Trunc α) : C q :=\n  Quot.rec f (fun a b _ ↦ h a b) q\n#align trunc.rec Trunc.rec\n\n/-- A version of `Trunc.rec` taking `q : Trunc α` as the first argument. -/\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\n@[elab_as_elim]\nprotected def recOn (q : Trunc α) (f : ∀ a, C (mk a))\n    (h : ∀ a b : α, (Eq.ndrec (f a) (Trunc.eq (mk a) (mk b)) : C (mk b)) = f b) : C q :=\n  Trunc.rec f h q\n#align trunc.rec_on Trunc.recOn\n\n/-- A version of `Trunc.recOn` assuming the codomain is a `Subsingleton`. -/\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\n@[elab_as_elim]\nprotected def recOnSubsingleton [∀ a, Subsingleton (C (mk a))] (q : Trunc α) (f : ∀ a, C (mk a)) :\n    C q :=\n  Trunc.rec f (fun _ b ↦ Subsingleton.elim _ (f b)) q\n#align trunc.rec_on_subsingleton Trunc.recOnSubsingleton\n\n/-- Noncomputably extract a representative of `Trunc α` (using the axiom of choice). -/\nnoncomputable def out : Trunc α → α :=\n  Quot.out\n#align trunc.out Trunc.out\n\n@[simp]\ntheorem out_eq (q : Trunc α) : mk q.out = q :=\n  Trunc.eq _ _\n#align trunc.out_eq Trunc.out_eq\n\nprotected theorem nonempty (q : Trunc α) : Nonempty α :=\n  nonempty_of_exists q.exists_rep\n#align trunc.nonempty Trunc.nonempty\n\nend Trunc\n\n/-! ### `Quotient` with implicit `Setoid` -/\n\n\nnamespace Quotient\n\nvariable {γ : Sort _} {φ : Sort _} {s₁ : Setoid α} {s₂ : Setoid β} {s₃ : Setoid γ}\n\n/-! Versions of quotient definitions and lemmas ending in `'` use unification instead\nof typeclass inference for inferring the `Setoid` argument. This is useful when there are\nseveral different quotient relations on a type, for example quotient groups, rings and modules. -/\n\n-- TODO: this whole section can probably be replaced `Quotient.mk`, with explicit parameter\n\n-- porting note: Quotient.mk' is the equivalent of Lean 3's `Quotient.mk`\n/-- A version of `Quotient.mk` taking `{s : Setoid α}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk'' (a : α) : Quotient s₁ :=\n  Quot.mk s₁.1 a\n#align quotient.mk Quotient.mk'\n#align quotient.mk' Quotient.mk''\n\n/-- `Quotient.mk''` is a surjective function. -/\ntheorem surjective_Quotient_mk'' : Function.Surjective (Quotient.mk'' : α → Quotient s₁) :=\n  Quot.exists_rep\n#align quotient.surjective_quotient_mk' Quotient.surjective_Quotient_mk''\n\n/-- A version of `Quotient.liftOn` taking `{s : Setoid α}` as an implicit argument instead of an\ninstance argument. -/\n-- porting note: removed `@[elab_as_elim]` because it gave \"unexpected eliminator resulting type\"\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\nprotected def liftOn' (q : Quotient s₁) (f : α → φ) (h : ∀ a b, @Setoid.r α s₁ a b → f a = f b) :\n    φ :=\n  Quotient.liftOn q f h\n#align quotient.lift_on' Quotient.liftOn'\n\n@[simp]\nprotected theorem liftOn'_mk'' (f : α → φ) (h) (x : α) :\n    Quotient.liftOn' (@Quotient.mk'' _ s₁ x) f h = f x :=\n  rfl\n\n@[simp] lemma surjective_liftOn' {f : α → φ} (h) :\n    Function.Surjective (λ x : Quotient s₁ => x.liftOn' f h) ↔ Function.Surjective f :=\n  Quot.surjective_lift _\n#align quotient.surjective_lift_on' Quotient.surjective_liftOn'\n\n/-- A version of `Quotient.liftOn₂` taking `{s₁ : Setoid α} {s₂ : Setoid β}` as implicit arguments\ninstead of instance arguments. -/\n-- porting note: removed `@[elab_as_elim]` because it gave \"unexpected eliminator resulting type\"\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\nprotected def liftOn₂' (q₁ : Quotient s₁) (q₂ : Quotient s₂) (f : α → β → γ)\n    (h : ∀ a₁ a₂ b₁ b₂, @Setoid.r α s₁ a₁ b₁ → @Setoid.r β s₂ a₂ b₂ → f a₁ a₂ = f b₁ b₂) : γ :=\n  Quotient.liftOn₂ q₁ q₂ f h\n#align quotient.lift_on₂' Quotient.liftOn₂'\n\n@[simp]\nprotected theorem liftOn₂'_mk'' (f : α → β → γ) (h) (a : α) (b : β) :\n    Quotient.liftOn₂' (@Quotient.mk'' _ s₁ a) (@Quotient.mk'' _ s₂ b) f h = f a b :=\n  rfl\n\n/-- A version of `Quotient.ind` taking `{s : Setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_elim]\nprotected theorem ind' {p : Quotient s₁ → Prop} (h : ∀ a, p (Quotient.mk'' a)) (q : Quotient s₁) :\n    p q :=\n  Quotient.ind h q\n#align quotient.ind' Quotient.ind'\n\n/-- A version of `Quotient.ind₂` taking `{s₁ : Setoid α} {s₂ : Setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem ind₂' {p : Quotient s₁ → Quotient s₂ → Prop}\n    (h : ∀ a₁ a₂, p (Quotient.mk'' a₁) (Quotient.mk'' a₂))\n    (q₁ : Quotient s₁) (q₂ : Quotient s₂) : p q₁ q₂ :=\n  Quotient.ind₂ h q₁ q₂\n#align quotient.ind₂' Quotient.ind₂'\n\n/-- A version of `Quotient.inductionOn` taking `{s : Setoid α}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_elim]\nprotected theorem inductionOn' {p : Quotient s₁ → Prop} (q : Quotient s₁)\n    (h : ∀ a, p (Quotient.mk'' a)) : p q :=\n  Quotient.inductionOn q h\n#align quotient.induction_on' Quotient.inductionOn'\n\n/-- A version of `Quotient.inductionOn₂` taking `{s₁ : Setoid α} {s₂ : Setoid β}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn₂' {p : Quotient s₁ → Quotient s₂ → Prop} (q₁ : Quotient s₁)\n    (q₂ : Quotient s₂)\n    (h : ∀ a₁ a₂, p (Quotient.mk'' a₁) (Quotient.mk'' a₂)) : p q₁ q₂ :=\n  Quotient.inductionOn₂ q₁ q₂ h\n#align quotient.induction_on₂' Quotient.inductionOn₂'\n\n/-- A version of `Quotient.inductionOn₃` taking `{s₁ : Setoid α} {s₂ : Setoid β} {s₃ : Setoid γ}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn₃' {p : Quotient s₁ → Quotient s₂ → Quotient s₃ → Prop}\n    (q₁ : Quotient s₁) (q₂ : Quotient s₂) (q₃ : Quotient s₃)\n    (h : ∀ a₁ a₂ a₃, p (Quotient.mk'' a₁) (Quotient.mk'' a₂) (Quotient.mk'' a₃)) :\n    p q₁ q₂ q₃ :=\n  Quotient.inductionOn₃ q₁ q₂ q₃ h\n#align quotient.induction_on₃' Quotient.inductionOn₃'\n\n/-- A version of `Quotient.recOnSubsingleton` taking `{s₁ : Setoid α}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_elim]\nprotected def recOnSubsingleton' {φ : Quotient s₁ → Sort _} [∀ a, Subsingleton (φ ⟦a⟧)]\n    (q : Quotient s₁)\n    (f : ∀ a, φ (Quotient.mk'' a)) : φ q :=\n  Quotient.recOnSubsingleton q f\n#align quotient.rec_on_subsingleton' Quotient.recOnSubsingleton'\n\n/-- A version of `Quotient.recOnSubsingleton₂` taking `{s₁ : Setoid α} {s₂ : Setoid α}`\nas implicit arguments instead of instance arguments. -/\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\n@[elab_as_elim]\nprotected def recOnSubsingleton₂' {φ : Quotient s₁ → Quotient s₂ → Sort _}\n    [∀ a b, Subsingleton (φ ⟦a⟧ ⟦b⟧)]\n    (q₁ : Quotient s₁) (q₂ : Quotient s₂) (f : ∀ a₁ a₂, φ (Quotient.mk'' a₁) (Quotient.mk'' a₂)) :\n    φ q₁ q₂ :=\n  Quotient.recOnSubsingleton₂ q₁ q₂ f\n#align quotient.rec_on_subsingleton₂' Quotient.recOnSubsingleton₂'\n\n/-- Recursion on a `Quotient` argument `a`, result type depends on `⟦a⟧`. -/\nprotected def hrecOn' {φ : Quotient s₁ → Sort _} (qa : Quotient s₁) (f : ∀ a, φ (Quotient.mk'' a))\n    (c : ∀ a₁ a₂, a₁ ≈ a₂ → HEq (f a₁) (f a₂)) : φ qa :=\n  Quot.hrecOn qa f c\n#align quotient.hrec_on' Quotient.hrecOn'\n\n@[simp]\ntheorem hrecOn'_mk'' {φ : Quotient s₁ → Sort _} (f : ∀ a, φ (Quotient.mk'' a))\n    (c : ∀ a₁ a₂, a₁ ≈ a₂ → HEq (f a₁) (f a₂))\n    (x : α) : (Quotient.mk'' x).hrecOn' f c = f x :=\n  rfl\n#align quotient.hrec_on'_mk' Quotient.hrecOn'_mk''\n\n/-- Recursion on two `Quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrecOn₂' {φ : Quotient s₁ → Quotient s₂ → Sort _} (qa : Quotient s₁)\n    (qb : Quotient s₂) (f : ∀ a b, φ (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → HEq (f a₁ b₁) (f a₂ b₂)) :\n    φ qa qb :=\n  Quotient.hrecOn₂ qa qb f c\n#align quotient.hrec_on₂' Quotient.hrecOn₂'\n\n@[simp]\ntheorem hrecOn₂'_mk'' {φ : Quotient s₁ → Quotient s₂ → Sort _}\n    (f : ∀ a b, φ (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → HEq (f a₁ b₁) (f a₂ b₂)) (x : α) (qb : Quotient s₂) :\n    (Quotient.mk'' x).hrecOn₂' qb f c = qb.hrecOn' (f x) fun _ _ ↦ c _ _ _ _ (Setoid.refl _) :=\n  rfl\n#align quotient.hrec_on₂'_mk' Quotient.hrecOn₂'_mk''\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `Quotient sa → Quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : α → β) (h : (s₁.r ⇒ s₂.r) f f) : Quotient s₁ → Quotient s₂ :=\n  Quot.map f h\n#align quotient.map' Quotient.map'\n\n@[simp]\ntheorem map'_mk'' (f : α → β) (h) (x : α) :\n    (Quotient.mk'' x : Quotient s₁).map' f h = (Quotient.mk'' (f x) : Quotient s₂) :=\n  rfl\n\n/-- A version of `Quotient.map₂` using curly braces and unification. -/\nprotected def map₂' (f : α → β → γ) (h : (s₁.r ⇒ s₂.r ⇒ s₃.r) f f) :\n    Quotient s₁ → Quotient s₂ → Quotient s₃ :=\n  Quotient.map₂ f h\n#align quotient.map₂' Quotient.map₂'\n\n@[simp]\ntheorem map₂'_mk'' (f : α → β → γ) (h) (x : α) :\n    (Quotient.mk'' x : Quotient s₁).map₂' f h =\n      (Quotient.map' (f x) (h (Setoid.refl x)) : Quotient s₂ → Quotient s₃) :=\n  rfl\n\ntheorem exact' {a b : α} :\n    (Quotient.mk'' a : Quotient s₁) = Quotient.mk'' b → @Setoid.r _ s₁ a b :=\n  Quotient.exact\n#align quotient.exact' Quotient.exact'\n\ntheorem sound' {a b : α} : @Setoid.r _ s₁ a b → @Quotient.mk'' α s₁ a = Quotient.mk'' b :=\n  Quotient.sound\n#align quotient.sound' Quotient.sound'\n\n@[simp]\nprotected theorem eq' [s₁ : Setoid α] {a b : α} :\n    @Quotient.mk' α s₁ a = @Quotient.mk' α s₁ b ↔ @Setoid.r _ s₁ a b :=\n  Quotient.eq\n#align quotient.eq Quotient.eq'\n\n@[simp]\nprotected theorem eq'' {a b : α} : @Quotient.mk'' α s₁ a = Quotient.mk'' b ↔ @Setoid.r _ s₁ a b :=\n  Quotient.eq\n#align quotient.eq' Quotient.eq''\n\n/-- A version of `Quotient.out` taking `{s₁ : Setoid α}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : Quotient s₁) : α :=\n  Quotient.out a\n#align quotient.out' Quotient.out'\n\n@[simp]\ntheorem out_eq' (q : Quotient s₁) : Quotient.mk'' q.out' = q :=\n  q.out_eq\n#align quotient.out_eq' Quotient.out_eq'\n\ntheorem mk_out' (a : α) : @Setoid.r α s₁ (Quotient.mk'' a : Quotient s₁).out' a :=\n  Quotient.exact (Quotient.out_eq _)\n#align quotient.mk_out' Quotient.mk_out'\n\nsection\n\nvariable [s : Setoid α]\n\nprotected theorem mk''_eq_mk (x : α) : Quotient.mk'' x = Quotient.mk s x :=\n  rfl\n\n@[simp]\nprotected theorem liftOn'_mk (x : α) (f : α → β) (h) : (Quotient.mk s x).liftOn' f h = f x :=\n  rfl\n#align quotient.lift_on'_mk Quotient.liftOn'_mk\n\n@[simp]\nprotected theorem liftOn₂'_mk [t : Setoid β] (f : α → β → γ) (h) (a : α) (b : β) :\n    Quotient.liftOn₂' (Quotient.mk s a) (Quotient.mk t b) f h = f a b :=\n  Quotient.liftOn₂'_mk'' _ _ _ _\n#align quotient.lift_on₂'_mk Quotient.liftOn₂'_mk\n\n@[simp]\n\n\nend\n\ninstance (q : Quotient s₁) (f : α → Prop) (h : ∀ a b, @Setoid.r α s₁ a b → f a = f b)\n    [DecidablePred f] :\n    Decidable (Quotient.liftOn' q f h) :=\n  Quotient.lift.decidablePred _ _ q\n\ninstance (q₁ : Quotient s₁) (q₂ : Quotient s₂) (f : α → β → Prop)\n    (h : ∀ a₁ b₁ a₂ b₂, @Setoid.r α s₁ a₁ a₂ → @Setoid.r β s₂ b₁ b₂ → f a₁ b₁ = f a₂ b₂)\n    [∀ a, DecidablePred (f a)] :\n    Decidable (Quotient.liftOn₂' q₁ q₂ f h) :=\n  Quotient.lift₂.decidablePred _ _ _ _\n\nend Quotient\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Quot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.7025300698514778, "lm_q1q2_score": 0.4935484902946163}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module algebra.category.Group.zero\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Category.GroupCat.Basic\nimport Mathlib.CategoryTheory.Limits.Shapes.ZeroObjects\n\n/-!\n# The category of (commutative) (additive) groups has a zero object.\n\n`AddCommGroup` also has zero morphisms. For definitional reasons, we infer this from preadditivity\nrather than from the existence of a zero object.\n-/\n\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse u\n\nnamespace GroupCat\n\n@[to_additive]\ntheorem isZero_of_subsingleton (G : GroupCat) [Subsingleton G] : IsZero G := by\n  refine' ⟨fun X => ⟨⟨⟨1⟩, fun f => _⟩⟩, fun X => ⟨⟨⟨1⟩, fun f => _⟩⟩⟩\n  · ext x\n    have : x = 1 := Subsingleton.elim _ _\n    rw [this, Hom.map_one, Hom.map_one]\n  · ext\n    apply Subsingleton.elim\nset_option linter.uppercaseLean3 false in\n#align Group.is_zero_of_subsingleton GroupCat.isZero_of_subsingleton\nset_option linter.uppercaseLean3 false in\n#align AddGroup.is_zero_of_subsingleton AddGroupCat.isZero_of_subsingleton\n\n@[to_additive AddGroupCat.hasZeroObject]\ninstance : HasZeroObject GroupCat :=\n  ⟨⟨of PUnit, isZero_of_subsingleton _⟩⟩\n\nend GroupCat\n\nnamespace CommGroupCat\n\n@[to_additive]\ntheorem isZero_of_subsingleton (G : CommGroupCat) [Subsingleton G] : IsZero G := by\n  refine' ⟨fun X => ⟨⟨⟨1⟩, fun f => _⟩⟩, fun X => ⟨⟨⟨1⟩, fun f => _⟩⟩⟩\n  · ext x\n    have : x = 1 := Subsingleton.elim _ _\n    rw [this, Hom.map_one, Hom.map_one]\n  · ext\n    apply Subsingleton.elim\nset_option linter.uppercaseLean3 false in\n#align CommGroup.is_zero_of_subsingleton CommGroupCat.isZero_of_subsingleton\nset_option linter.uppercaseLean3 false in\n#align AddCommGroup.is_zero_of_subsingleton AddCommGroupCat.isZero_of_subsingleton\n\n@[to_additive AddCommGroupCat.hasZeroObject]\ninstance : HasZeroObject CommGroupCat :=\n  ⟨⟨of PUnit, isZero_of_subsingleton _⟩⟩\n\nend CommGroupCat\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/Category/GroupCat/Zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.49352331411022743}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.group_theory.perm.basic\nimport Mathlib.data.fintype.basic\nimport Mathlib.group_theory.subgroup\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Lemmas about subgroups within the permutations (self-equivalences) of a type `α`\n\nThis file provides extra lemmas about some `subgroup`s that exist within `equiv.perm α`.\n`group_theory.subgroup` depends on `group_theory.perm.basic`, so these need to be in a separate\nfile.\n-/\n\nnamespace equiv\n\n\nnamespace perm\n\n\n@[simp] theorem sum_congr_hom.card_range {α : Type u_1} {β : Type u_2} [fintype ↥(monoid_hom.range (sum_congr_hom α β))] [fintype (perm α × perm β)] : fintype.card ↥(monoid_hom.range (sum_congr_hom α β)) = fintype.card (perm α × perm β) :=\n  iff.mpr fintype.card_eq (Nonempty.intro (equiv.symm (set.range (⇑(sum_congr_hom α β)) sum_congr_hom_injective)))\n\n@[simp] theorem sigma_congr_right_hom.card_range {α : Type u_1} {β : α → Type u_2} [fintype ↥(monoid_hom.range (sigma_congr_right_hom β))] [fintype ((a : α) → perm (β a))] : fintype.card ↥(monoid_hom.range (sigma_congr_right_hom β)) = fintype.card ((a : α) → perm (β a)) :=\n  iff.mpr fintype.card_eq\n    (Nonempty.intro (equiv.symm (set.range (⇑(sigma_congr_right_hom β)) sigma_congr_right_hom_injective)))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/group_theory/perm/subgroup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.49352330987892534}}
{"text": "example (P Q : Prop) (p : P) (q : Q) : P ∧ Q :=\nbegin\nsplit,\nexact p,\nexact q,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world07/level01.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.49352330968681923}}
{"text": "import GMLInit.Meta.Stable\nimport GMLInit.Data.Nat.Basic\nimport GMLInit.Data.Nat.IsPos\nimport GMLInit.Data.Nat.Order\n\nnamespace Nat\n\nattribute [local eliminator] Nat.recDiagAux\n\nprotected theorem pred_zero' : 0 - 1 = 0 := rfl\n\nprotected theorem pred_succ' (x : Nat) : (x + 1) - 1 = x := rfl\n\nprotected theorem succ_pred' (x : Nat) (h : x > 0 := by nat_is_pos) : (x - 1) + 1 = x := by\n  cases x with\n  | zero => contradiction\n  | succ x => rw [Nat.pred_succ']\n\nprotected theorem zero_lt_succ' (x : Nat) : 0 < x + 1 := Nat.zero_lt_succ x\n\nprotected theorem not_succ_le_zero' (x : Nat) : ¬ x + 1 ≤ 0 := Nat.not_succ_le_zero x\n\nprotected theorem lt_succ_self' (x : Nat) : x < x + 1 := Nat.lt_succ_self x\n\nprotected theorem not_succ_le_self' (x : Nat) : ¬ x + 1 ≤ x := Nat.not_succ_le_self x\n\nprotected theorem succ_le_succ' {x y : Nat} : x ≤ y → x + 1 ≤ y + 1 := Nat.succ_le_succ\n\nprotected theorem le_of_succ_le_succ' {x y : Nat} : x + 1 ≤ y + 1 → x ≤ y := Nat.le_of_succ_le_succ\n\nprotected theorem succ_lt_succ' {x y : Nat} : x < y → x + 1 < y + 1 := Nat.succ_lt_succ\n\nprotected theorem lt_of_succ_lt_succ' {x y : Nat} : x + 1 < y + 1 → x < y := Nat.lt_of_succ_lt_succ\n\nprotected theorem succ_le_of_lt' {x y : Nat} : x + 1 ≤ y → x < y := Nat.succ_le_of_lt\n\nprotected theorem lt_of_succ_le' {x y : Nat} : x + 1 ≤ y → x < y := Nat.lt_of_succ_le\n\nprotected theorem lt_succ_of_le' {x y : Nat} : x ≤ y → x < y + 1 := Nat.lt_succ_of_le\n\nprotected theorem le_of_lt_succ' {x y : Nat} : x < y + 1 → x ≤ y := Nat.le_of_lt_succ\n\nprotected theorem succ_le_iff_lt (x y : Nat) : x + 1 ≤ y ↔ x < y :=\n  ⟨Nat.lt_of_succ_le, Nat.succ_le_of_lt⟩\n\nprotected theorem lt_succ_iff_le (x y : Nat) : x < y + 1 ↔ x ≤ y :=\n  ⟨Nat.le_of_lt_succ, Nat.lt_succ_of_le⟩\n\nprotected theorem succ_le_succ_iff_le (x y : Nat) : x + 1 ≤ y + 1 ↔ x ≤ y :=\n  ⟨Nat.le_of_succ_le_succ, Nat.succ_le_succ⟩\n\nprotected theorem succ_lt_succ_iff_lt (x y : Nat) : x + 1 < y + 1 ↔ x < y :=\n  ⟨Nat.lt_of_succ_lt_succ, Nat.succ_lt_succ⟩\n\nprotected theorem pred_le_iff_le_succ (x y : Nat) : x - 1 ≤ y ↔ x ≤ y + 1 := by\n  cases x, y with\n  | left x =>\n    cases x with\n    | zero =>\n      constr\n      · intro\n        apply Nat.zero_le\n      · intro\n        apply Nat.zero_le\n    | succ x =>\n      constr\n      · exact Nat.succ_le_succ\n      · exact Nat.le_of_succ_le_succ\n  | right y =>\n    constr\n    · intro\n      apply Nat.zero_le\n    · intro\n      apply Nat.zero_le\n  | diag x y =>\n    constr\n    · exact Nat.succ_le_succ\n    · exact Nat.le_of_succ_le_succ\n\nprotected theorem succ_lt_iff_lt_pred (x y : Nat) : x + 1 < y ↔ x < y - 1 := by\n  rw [Nat.lt_iff_not_ge, Nat.lt_iff_not_ge]\n  apply Iff.mt\n  exact Nat.pred_le_iff_le_succ y x\n\nprotected theorem succ_le_or_eq_zero_iff_le_pred (x y : Nat) : x + 1 ≤ y ∨ x = 0 ↔ x ≤ y - 1 := by\n  cases x, y with\n  | left x =>\n    constr\n    · intro\n      | Or.inl h => absurd h; apply Nat.not_succ_le_zero\n      | Or.inr h => rw [h]; apply Nat.le_refl\n    · intro h\n      right\n      antisymmetry using LE.le\n      exact h\n      exact Nat.zero_le x\n  | right y =>\n    constr\n    · intro; apply Nat.zero_le\n    · intro; right; reflexivity\n  | diag x y =>\n    constr\n    · intro\n      | Or.inl h => exact Nat.le_of_succ_le_succ h\n      | Or.inr h => absurd h; apply Nat.succ_ne_zero\n    · intro h\n      left\n      exact Nat.succ_le_succ h\n\nprotected theorem pred_lt_or_eq_zero_iff_lt_succ (x y : Nat) : x - 1 < y ∨ x = 0 ↔ x < y + 1 := by\n  cases x, y using Nat.casesDiagAuxOn with\n  | left x =>\n    constr\n    · intro\n      | Or.inl h => absurd h; apply Nat.not_lt_zero\n      | Or.inr h => rw [h]; apply Nat.zero_lt_one\n    · intro h\n      right\n      antisymmetry using LE.le\n      exact Nat.le_of_lt_succ h\n      exact Nat.zero_le x\n  | right y =>\n    constr\n    · intro\n      apply Nat.zero_lt_succ\n    · intro\n      right\n      reflexivity\n  | diag x y =>\n    constr\n    · intro\n      | Or.inl h => exact Nat.succ_lt_succ h\n      | Or.inr h => absurd h; apply Nat.succ_ne_zero\n    · intro h\n      left\n      exact Nat.lt_of_succ_lt_succ h\n\nend Nat\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/Nat/Succ.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.49352330555157015}}
{"text": "import number_theory.bernoulli\n\n\n--OUTPUT 1\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  sorry,\nend\n\n--OUTPUT 2\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  sorry\nend\n\n--OUTPUT 3\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  induction n with d hd,\n  {\n    show (polynomial.bernoulli 0).eval (1 + x) = (polynomial.bernoulli 0).eval x + 0 * x^(0 - 1),\n    simp,\n  },\n  {\n    have h1 : (polynomial.bernoulli d).eval (1 + x) = (polynomial.bernoulli d).eval x + d * x^(d - 1), from sorry,\n    show (polynomial.bernoulli (d + 1)).eval (1 + x) = (polynomial.bernoulli (d + 1)).eval x + (d + 1) * x^((d + 1) - 1), from sorry,\n  }\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n  have h2 : (A ∩ B) ⊆ A, from sorry,\n  have h3 : (A ∩ B) ⊆ S, from sorry,\n  show (A ∩ B) ∈  𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by sorry\n  ... = x*(x+y) + y*(x+y) : by sorry\n  ... = x*x + x*y + y*x + y*y : by sorry\n  ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n  have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n      have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n      show e = (1 : G), from sorry,     \n    },\n    sorry,\n  }\nend\n\n/--`theorem`\nBernoulli polynomial evaluation\nGiven a natural number $n$ and a rational $x$, let $B_n (x)$ denote the $n$-th Bernoulli polynomial evaluated at $x$. Then, $$B_n (1 + x) = B_n (x) + n x^{n - 1}$$\n`proof`\nWe apply strong induction on $n$. So, for all $m < d$, we have $B_{m} (1 + x) = B_{m} (x) + m x^{m - 1}$ and we want to show that $$B_{d} (1 + x) = B_{d} (x) + d x^{d - 1}$$\nMultiplying both sides by $d + 1$, and using the fact that, for all $l \\in \\mathbb{N}$, $\\sum_{k = 0}^{l} {l + 1 \\choose k} B_k = (l + 1) X^l$ (where $B_k$ is the $k$-th Bernoulli number), we get that \n$$ (d + 1) (1 + x)^d - (d + 1) x^d = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\nThe conclusion then follows easily.\n\nQED\n\n-/\ntheorem  bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0.2_max_tokens_2000_n_3/clean_files/Bernoulli polynomial evaluation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.49352330535946415}}
{"text": "example : True := by\n  apply True.intro\n      --^ textDocument/hover\n\nexample : True := by\n  simp [True.intro]\n      --^ textDocument/hover\n\nexample (n : Nat) : True := by\n  match n with\n  | Nat.zero => _\n  --^ textDocument/hover\n  | n + 1 => _\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/interactive/hover.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.49352329660870076}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport order.filter.basic\nimport topology.bases\nimport data.real.nnreal\nimport topology.instances.real\nimport topology.instances.nnreal\nimport topology.instances.ennreal\n\nimport topology.algebra.infinite_sum\nimport formal_ml.set\nimport formal_ml.finset\nimport formal_ml.nat\nimport formal_ml.ennreal\nimport formal_ml.nnreal\nimport data.finset\nimport order.complete_lattice\nimport formal_ml.real\n\nopen finset\n\nlemma filter_le_intro (α:Type*) (A B:filter α):\n  (∀ a, a∈ B → a∈ A)→ (A≤ B)  :=\nbegin\n  intros,\n  apply (@filter.le_def α A B).mpr,\n  assumption,\nend\n\n\nlemma filter_le_intro2 (α:Type*) (A B:filter α):\n  (B.sets ⊆ A.sets)→ (A≤ B)  :=\nbegin\n  intros,\n  apply (@filter.le_def α A B).mpr,\n  have A1:((B.sets ⊆ A.sets) ↔ (∀ a∈ B.sets, a∈ A.sets)),\n  {\n     refl,\n  },\n  assumption,\nend\n\n\nlemma filter_le_elim {α:Type*} {A B:filter α} {a:set α}:\n   (A≤ B) → (a∈ B)→ (a∈ A) :=\nbegin\n  intros,\n  apply (@filter.le_def α A B).mp;assumption,\nend\n\n\n/-\n  filter.map f A is the pre-image of the pre-image of the sets in A.\n  --set.preimage f has type (set β)→ (set α)\n  --set.preimage f B = {x:f x ∈ B}\n  --set.preimage (set.preimage f) has type (set (set α)) → (set (set β))\n  --set.preimage (set.preimage f) AF = {y:(set.preimage f) y ∈ AF}\n  --set.preimage (set.preimage f) AF = {y:{x:f x∈ y} ∈ AF}\n\n-/\nlemma filter_map_def (α β:Type*) (A:filter α) (f:α → β):\n  (filter.map f A).sets = set.preimage (set.preimage f) A.sets :=\nbegin\n  refl,\nend\n\nlemma filter_mem_def (α:Type*) (A:filter α) (a:set α):\n  (a∈ A) = (a ∈ A.sets) :=\nbegin\n  refl,\nend\n\n\nlemma filter_map_intro (α β : Type*) (A : filter α) (f : α → β) (X : set α) (Y : set β)\n (a: X∈ A) (a_1 : X=set.preimage f Y) : (Y∈ filter.map f A)  :=\nbegin\n  rw filter_mem_def,\n  rw filter_map_def,\n  unfold set.preimage,\n  simp,\n  rw filter_mem_def at a,\n  unfold set.preimage at a_1,\n  rw ← a_1,\n  assumption,\nend\n\nlemma filter_map_elim (α β:Type*) (A:filter α) (f:α → β) (Y:set β)\n  (a : Y ∈ filter.map f A) : (∃ (X∈ A), (X=set.preimage f Y))   :=\nbegin\n  rw filter_mem_def at a,\n  rw filter_map_def at a,\n  --unfold set.preimage,\n  simp,\n  unfold set.preimage at a,\n  simp at a,\n  apply a,\nend\n\nlemma filter_tendsto_intro (α β:Type*)   (f:α → β) (A:filter α) (B:filter β):\n  (∀ b∈ B, set.preimage f b ∈ A) → (@filter.tendsto α β  f A B)  :=\nbegin\n  intros a,\n  unfold filter.tendsto,\n  apply filter_le_intro,\n  intros a_1 a_2,\n  apply filter_map_intro,\n  have A1:a_1 ∈ B → f ⁻¹' a_1 ∈ A,\n  {\n    apply a,\n  },\n\n  have A2:f ⁻¹' a_1 ∈ A,\n  {\n     apply A1,\n     apply a_2,\n  },\n  apply A2,\n  refl,\nend\n\nlemma filter_tendsto_elim {α β:Type*} {f:α → β} {A:filter α} {B:filter β} {s:set β}:\n   (@filter.tendsto α β  f A B) →(s∈ B)→  (set.preimage f s ∈ A) :=\nbegin\n  intros a a_1,\n  unfold filter.tendsto at a,\n  have A1:s∈ filter.map f A,\n  {\n    apply filter_le_elim,\n    apply a,\n    apply a_1,\n  },\n\n  have A2:(∃ (X∈ A), (X=set.preimage f s)),\n  {\n    apply (filter_map_elim),\n    apply A1,\n  },\n  cases A2,\n  cases A2_h,\n  subst A2_w,\n  exact A2_h_w,\nend\n\n\nlemma filter_principal_intro {α:Type*} (a:finset α) (b:set (finset α)):\n  ({c : finset α | a ⊆ c} ⊆ b) → b ∈ (filter.principal  {c:finset α | a⊆ c}):=\nbegin\n  --apply b∈ (filter.principal  {c:finset ℕ | a⊆ c}),\n  intros a_1,\n  unfold filter.principal,\n  have A1:b ∈ {t : set (finset α) | {c : finset α | a ⊆ c} ⊆ t},\n  {\n    simp,\n    apply a_1,\n  },\n  apply A1,\nend\n\n\nlemma filter_principal_elim {α:Type*} (a:finset α) (b:set (finset α)):\n  b ∈ (filter.principal  {c:finset α | a⊆ c}) → ({c : finset α | a ⊆ c} ⊆ b) :=\nbegin\n  intros a_1,\n  apply (@filter.mem_principal_sets (finset α) b {c:finset α | a⊆ c}).mp,\n  apply a_1,\nend\n\n\n\nlemma filter_principal_intro2 {α:Type*} (a:finset α) (b:set (finset α)):\n  (∀ c:finset α, a⊆ c → c∈ b) → b ∈ (filter.principal  {c:finset α | a⊆ c}):=\nbegin\n  intros a_1,\n  apply filter_principal_intro,\n  rw set.subset_def,\n  intros a_3 a_2,\n  simp at a_2,\n  apply a_1,\n  apply a_2,\nend\n\n\nlemma filter_principal_intro3 {α:Type*} (a b:set α):\n  (a⊆ b) → b ∈ filter.principal  a:=\nbegin\n  simp [filter.principal],\nend\n\n\nlemma filter_principal_elim2 {α:Type*} (a:finset α) (b:set (finset α)) (c:finset α):\n  b ∈ (filter.principal  {c:finset α | a⊆ c}) → (a ⊆ c) → (c∈ b) :=\nbegin\n  intros a_1 a_2,\n  apply (@filter_principal_elim α a b),\n  {\n    apply a_1,\n  },\n  apply a_2,\nend\n\nlemma filter_principal_elim3 {α:Type*} (a b:set α):\n  b ∈ filter.principal  a → (a⊆ b):=\nbegin\n  unfold filter.principal,\n  simp,\nend\n\n\n\n\n/-\n  Let's walk through a simple example.\n  b={1,2}\n  c={2,3}\n  filter.principal {{1,2},{1,2,3},{1,2,3,4}, {1,2,4}} ⊓\n  filter.principal {{1,3},{1,2,3},{1,2,3,4}, {1,3,4}} =\n  filter.principal {{1,2,3}, {1,2,3,4}}\n -/\n\n\nlemma principal_inf\n    (α:Type*) (A B:set α):\n    (filter.principal A ⊓ filter.principal B = filter.principal (A∩B)) :=\nbegin\n  simp,\nend\n\n\nlemma principal_inf_sets2 {α:Type*} [semilattice_sup_bot α] (b c:α):\n   filter.principal {d:α |b ≤ d} ⊓ filter.principal {d: α |c ≤ d}\n   = filter.principal {d:α |(b ⊔ c) ≤ d} :=\nbegin\n  have A1:{d:α |b ≤ d} ∩ {d:α |c ≤ d} = {d: α |(b ⊔ c) ≤ d},\n  {\n    ext,\n    split;intros a,\n    {\n      cases a,\n      simp at a_left,\n      simp at a_right,\n      simp,\n      split;assumption,\n    },\n    {\n      simp at a,\n      cases a with A2 A3,\n      split;simp;assumption,\n    }\n  },\n  rw ← A1,\n  apply principal_inf,\nend\n\n-- Use apply principal_inf_sets2,\nlemma principal_inf_sets {α:Type*} [decidable_eq α] (b c:finset α):\n   filter.principal {d:finset α |b ≤ d} ⊓ filter.principal {d:finset α |c ≤ d}\n   = filter.principal {d:finset α |(b ∪ c) ≤ d} :=\nbegin\n  apply principal_inf_sets2,\nend\n\n\n\n-- src/data/set/lattice.lean\nlemma set_Inf_def (α:Type*) (S:set (set α)):\n(Inf S) = {a | ∀ t ∈ S, a ∈ t } :=\nbegin\n  refl,\nend\n\n\nlemma set_Inf_intro (α:Type*) (S:set (set α)) (x:α):\n   (∀ X∈ S, x∈ X) → x∈ Inf S :=\nbegin\n  intros a,\n  rw set_Inf_def,\n  simp,\n  exact a,\nend\n\n\nlemma set_Inf_range_intro (α β:Type*) (f:α → set (β)) (x:β):\n   (∀ y:α, x∈ f y) →  x∈ Inf (set.range  (λ (a : α), f a)) :=\nbegin\n  intros a,\n  apply set_Inf_intro,\n  intros,\n  unfold set.range at H,\n  simp at H,\n  cases H,\n  rw ← H_h,\n  apply a,\nend\n\nlemma glb_intro {α β:Type*} (f:α → set (β)) (x:β):\n(∀ a:α, x∈ f a) → x ∈  ⨅ a, f a :=\nbegin\n  intros a,\n  unfold infi,\n  unfold Inf,\n  apply set_Inf_range_intro,\n  assumption,\nend\n\n\nlemma le_Inf_simp (α:Type*) (s : set (filter α)) (a : filter α) :\n    (∀ (b : filter α ), b ∈ s → a ≤ b) → a ≤ complete_lattice.Inf s :=\nbegin\n  intros a_1,\n  apply (complete_lattice.le_Inf s),\n  apply a_1,\nend\n\n\nlemma Inf_le_simp (α : Type*)  (s : set (filter α)) (a : filter α) :\n  a ∈ s → complete_lattice.Inf s ≤ a :=\nbegin\n  intros a_1,\n  apply (complete_lattice.Inf_le s),\n  assumption,\nend\n\nlemma mem_Inf_intro {α : Type*}  {s : set (filter α)} {a : filter α} {t:set α}:\n  t ∈ a → a ∈ s → t∈  complete_lattice.Inf s :=\nbegin\n  intros,\n  apply (complete_lattice.Inf_le s),\n  assumption,\n  assumption\nend\n\n-- This is equivalent to filter.mem_infi (or a mem_Inf variant of mem_infi)\n\ndef inf_filter_sets_def (α:Type*) (S : set (filter α)):set (set α) :=\n  {s:set α | ∃ f∈ S, s∈ f}\n\nlemma inf_filter_sets_of_superset2 (α:Type*) (S : set (filter α)) (s t:set α):\n  s∈ (inf_filter_sets_def α S) → s⊆ t → t∈ (inf_filter_sets_def α S) :=\nbegin\n  intro a,\n  unfold inf_filter_sets_def,\n  simp,\n  unfold inf_filter_sets_def at a,\n  simp at a,\n  cases a,\n  cases a_h,\n  intros a_1,\n  apply exists.intro a_w,\n  split,\n  {\n    assumption,\n  },\n  {\n    apply filter.sets_of_superset,\n    apply a_h_right,\n    assumption,\n  }\nend\n\n--This suggests the definition is overly simplistic.\ndef inf_filter_sets_inter_sets2 (α:Type*) (S : set (filter α))\n  (H:∀ a b:filter α, a∈ S→ b∈ S→ a⊓b∈ S)  (s t:set α):\n  s∈ (inf_filter_sets_def α S) →\n  t∈ (inf_filter_sets_def α S) →\n  s ∩ t ∈ (inf_filter_sets_def α S) :=\nbegin\n  unfold inf_filter_sets_def,\n  simp only [and_imp, exists_prop, set.mem_set_of_eq, exists_imp_distrib],\n  intros x a a_1 x_1 a_2 a_3,\n  apply (exists.intro (x⊓x_1)),\n  split,\n  {\n    apply H;assumption,\n  },\n  {\n     simp only [filter.mem_inf_sets, ← filter_mem_def],\n     have B1:(s ∩ t) ∈ x ⊓ x_1 ↔ ∃t₁∈x, ∃t₂∈x_1, t₁ ∩ t₂ ⊆ (s ∩ t),\n     apply filter.mem_inf_sets,\n     apply B1.mpr,\n     apply exists.intro s,\n     apply exists.intro a_1,\n     apply exists.intro t,\n     apply exists.intro a_3,\n     refl,\n  }\nend\n\nlemma inf_filter_univ_sets2 (α:Type*) (S : set (filter α)) (b:filter α):\n  (b∈ S) → set.univ ∈ (inf_filter_sets_def α S) :=\nbegin\n  unfold inf_filter_sets_def,\n  simp,\n  intros h1,\n  apply exists.intro b,\n  repeat {assumption},\nend\n\ndef inf_filter_def2 (α:Type*) (S : set (filter α)) (b:filter α) (H:b∈ S)\n  (H2:∀ a b:filter α, a∈ S→ b∈ S→ a⊓b∈ S):filter α := {\n  sets := inf_filter_sets_def α S,\n  sets_of_superset := inf_filter_sets_of_superset2 α S,\n  univ_sets := (inf_filter_univ_sets2 α S b H),\n  inter_sets := inf_filter_sets_inter_sets2 α S H2,\n}\n\n/-\n  This definition is a little weak, as it assumes S is\n  nonempty and closed under (binary) infimum.\n\n  However, given these two constraints, the result is more\n  elegant, and it corresponds to the generic result about\n  filters, filter.eq_Inf_of_mem_sets_iff_exists_mem.\n-/\nlemma Inf_filter_def (α:Type*) (S : set (filter α))\n(b:filter α) (H:b∈ S)\n  (H2:∀ a b:filter α, a∈ S→ b∈ S→ a⊓b∈ S) (s:set α):\n(s ∈ Inf S)↔ (∃ t∈ S, s∈ t) :=\nbegin\n  have A1:(inf_filter_def2 α  S b H H2) = Inf S,\n  {\n     apply filter.eq_Inf_of_mem_sets_iff_exists_mem,\n     intros,\n     unfold inf_filter_def2,\n     simp,\n     unfold inf_filter_sets_def,\n     simp,\n  },\n  rw ← A1,\n  unfold inf_filter_def2,\n  simp,\n  unfold inf_filter_sets_def,\n  simp,\nend\n\n\nlemma eq_Inf_of_mem_sets_iff_exists_mem {α:Type} {S : set (filter α)} {l : filter α}\n  (h : ∀ {s}, s ∈ l ↔ ∃ f ∈ S, s ∈ f) : l = Inf S :=\nle_antisymm (le_Inf $ λ f hf s hs, h.2 ⟨f, hf, hs⟩)\n  (λ s hs, let ⟨f, hf, hs⟩ := h.1 hs in (Inf_le hf : Inf S ≤ f) hs)\n\n\n--def filter_from_element (α:Type) (a:α):filter α  := filter.principal (λ a', a=a')\n\n--filter.principal s contains all the supersets of s.\n--if s is in F, then F also contains\nlemma le_principal (F:filter (finset ℕ)) (s:set (finset ℕ)):\n  (s∈ F)→ (F ≤ filter.principal s) :=\nbegin\n  intros a,\n  apply (filter_le_intro2 (finset ℕ) F (filter.principal s)),\n  rw set.subset_def,\n  intros x a_1,\n\n  unfold filter.principal at a_1,\n  simp at a_1,\n  apply filter.sets_of_superset,\n  {\n    apply a,\n  },\n  {\n    assumption,\n  }\nend\n\n\n\n/-\n\nWhat is a neighborhood of x? First, for every open set containing x,\nconsider the principal filter (set of all supersets). Now, let's consider the\ninfimum of all those settings, keeping in mind that for a set, the\ninf (filter.principal S) (filter.principal T)=(filter.principal S∪T) (at this point,\nwe should be able to write a proof for this). Since the\nunion of two open sets containing X itself is an open set containing X, and every\nelement has at least one neighborhood that contains it, we are OK.\n\nThus, a neighborhood of x is a superset of an open set containing x.\n\n--a more standard definition of neighborhood.\nlemma mem_nhds_def (x:nnreal) (b:set nnreal):\n  (b∈ nhds x)↔ (∃ u:set nnreal, (u⊆ b) ∧ is_open u ∧ x∈ u) :=\n\n-/\nlemma mem_nhds_elim_real_rat (b:set real) (x:real): b∈ nhds x →\n(∃ p q:ℚ, (p < q) ∧ ((set.Ioo p q:set ℝ) ⊆ b) ∧ ((p:ℝ) < x) ∧ (x < (q:ℝ)))\n  :=\nbegin\n  let rat_basis := (⋃ (a b : ℚ) (h : a < b), {set.Ioo ↑a ↑b}),\n  begin\n  intros a,\n  have A1:topological_space.is_topological_basis rat_basis,\n  {\n    apply real.is_topological_basis_Ioo_rat,\n  },\n  have A2: (b ∈ nhds x ↔ ∃ (t : set real) (H : t ∈ rat_basis), x ∈ t ∧ t ⊆ b),\n  {\n    apply @topological_space.mem_nhds_of_is_topological_basis,\n    apply A1,\n  },\n  have A3: (∃ (t : set real) (H : t ∈ rat_basis), x ∈ t ∧ t ⊆ b),\n  {\n    apply A2.mp,\n    apply a,\n  },\n  /-\n    Now that we have proven A3, we are basically done. We just rewrite A3\n    into the statement of the theorem.\n  -/\n  cases A3,\n  cases A3_h,\n  simp at A3_h_w,\n  cases A3_h_w,\n  cases A3_h_w_h,\n  cases A3_h_w_h_h,\n  subst A3_w,\n  cases A3_h_h,\n  apply exists.intro A3_h_w_w,\n  apply exists.intro A3_h_w_h_w,\n  unfold set.Ioo at A3_h_h_left,\n  simp at A3_h_h_left,\n  cases A3_h_h_left,\n  split,\n  {\n    assumption,\n  },\n  split,\n  {\n    assumption,\n  },\n  split,\n  {\n    assumption,\n  },\n  {\n    assumption,\n  },\n  end\nend\n\n------ Move theorems here to where they belong -----------------------------------\n\nlemma induced_topological_basis {α β:Type*} [Tα:topological_space α] \n  [Tβ:topological_space β]\n  {f:α → β} {S:set (set β)}:(inducing f) → \n  (topological_space.is_topological_basis S) →\n  (topological_space.is_topological_basis (set.image (set.preimage f) S)) :=\nbegin\n  intros A1 A2,\n  rw A1.induced,\n  unfold topological_space.is_topological_basis,\n  split,\n  {\n    intros t₁ A3 t₂ A4 x A5,\n    cases A3 with u₁ A3,\n    cases A4 with u₂ A4,\n    cases A5 with A6 A7,\n    cases A3 with A8 A9,\n    cases A4 with A10 A11,\n    subst t₁,\n    subst t₂,\n    simp at A6,\n    simp at A7,\n    have A12:f x ∈ u₁ ∩ u₂,\n    {\n      simp,\n      apply and.intro A6 A7,\n    },\n    unfold topological_space.is_topological_basis at A2,\n    have A13 := A2.left u₁ A8 u₂ A10 (f x) A12,\n    cases A13 with u₃ A13,\n    cases A13 with A14 A15,\n    cases A15 with A16 A17,\n    apply exists.intro (f ⁻¹' u₃),\n    have A18:f ⁻¹' u₃ ∈ set.preimage f '' S,\n    {\n      simp,\n      apply exists.intro u₃,\n      split,\n      apply A14,\n      refl,\n    },\n    apply exists.intro A18,\n    split,\n    apply A16,\n    {\n      rw set.subset_inter_iff at A17,\n      apply set.subset_inter;apply set.preimage_mono,\n      apply A17.left,\n      apply A17.right,\n    },\n  },\n  split,\n  {\n    ext a,split;intro A3;simp,\n    unfold topological_space.is_topological_basis at A2,\n    have A4:f a ∈ ⋃₀ S, \n    {\n      rw A2.right.left,\n      simp,\n    },\n    cases A4 with X A5,    \n    cases A5 with A6 A7,\n    apply exists.intro X,\n    apply and.intro A6 A7,  \n  },\n  {\n    unfold topological_space.is_topological_basis at A2,\n    have A3 := A2.right.right,\n    rw A3,\n    apply induced_generate_from_eq,\n  }\nend\n\nlemma nnreal_topological_space_def:\n   nnreal.topological_space = @topological_space.induced nnreal real \n   (@coe nnreal real _) (@uniform_space.to_topological_space real _) := rfl\n\n\nlemma inducing_nnreal_topological_space:\n   inducing (@coe nnreal real _) := {\n  induced := nnreal_topological_space_def,\n}\n\n\nlemma nnreal_nhds {x:nnreal}:\n   nhds x = filter.comap (@coe nnreal real _) (nhds x.val) :=\nbegin\n  apply inducing.nhds_eq_comap,\n  apply inducing_nnreal_topological_space,\nend\n\nlemma nnreal_nhds2 {x:nnreal} {B:set nnreal}:\n   B ∈ nhds x ↔ \n   (∃ C∈ nhds (x.val),set.preimage (@coe nnreal real _) C⊆ B)  :=\nbegin\n  rw nnreal_nhds,\n  apply filter.mem_comap_sets,\nend\n\nlemma coe_nnreal_real_val:(@coe nnreal real _) = subtype.val := rfl\n\nlemma mem_nhds_elim_real {b:set real} {x:real}: b∈ nhds x →\n(∃ p q:ℝ, (p < q) ∧ ((set.Ioo p q) ⊆ b) ∧ (p < x) ∧ (x < q))\n  :=\nbegin\n  intros a,\n  have A1:(∃ prat qrat:ℚ, (prat < qrat) ∧ ((set.Ioo prat qrat:set ℝ) ⊆ b) ∧ ((prat:ℝ) < x) ∧ (x < (qrat:ℝ))),\n  {\n    apply mem_nhds_elim_real_rat,\n    apply a,\n  },\n  cases A1,\n  cases A1_h,\n  cases A1_h_h,\n  cases A1_h_h_right,\n  cases A1_h_h_right_right,\n\n  apply exists.intro (A1_w:ℝ),\n  apply exists.intro (A1_h_w:ℝ),\n  split,\n  {\n    apply (@rat.cast_lt real _ A1_w A1_h_w).mpr,\n    apply A1_h_h_left,\n  },\n  {\n    split,\n    {\n      assumption,\n    },\n    split,\n    {\n      apply A1_h_h_right_right_left,\n    },\n    {\n      apply A1_h_h_right_right_right,\n    }\n  },\nend\n\n\nlemma mem_nhds_elim_nnreal {b:set nnreal} {x:nnreal}: b∈ nhds x →\n(∃ p q:ℝ, (p < q) ∧ \n          (set.preimage  (@coe nnreal real _) (set.Ioo p q) ⊆ b) ∧ \n          (p < ↑x) ∧ (↑x < q))\n  :=\nbegin\n  intro A1,\n  rw nnreal_nhds2 at A1,\n  cases A1 with C A1,\n  cases A1 with A2 A3,\n  have A4 := mem_nhds_elim_real A2,\n  cases A4 with p A4,\n  cases A4 with q A4,\n  cases A4 with A5 A6,\n  cases A6 with A7 A8,\n  --cases A8 with A9 A10,\n  apply exists.intro p,\n  apply exists.intro q,\n  split,\n  apply A5,\n  split,\n  apply set.subset.trans,\n  {\n    apply set.preimage_mono,\n    apply A7,\n  },\n  {\n    apply A3,\n  },\n  apply A8,\nend\n\nlemma preimage_coe_Ioo {p q:ℝ}:(p < 0) → (0 ≤ q) →\n    set.preimage (@coe nnreal real _) (set.Ioo p q) = set.Iio (nnreal.of_real q) :=\nbegin\n  intro A1,\n  intro A2,\n  unfold set.Ioo set.Iio,\n  ext,split;intro A3;simp at A3;simp,\n  {\n    cases A3 with A4 A5,\n    rw ← nnreal.coe_lt_coe,\n    rw nnreal.coe_of_real,\n    apply A5,\n    apply A2,\n  },\n  {\n    split,\n    {\n      apply lt_of_lt_of_le,\n      apply A1,\n      apply x.property,\n    },\n    {\n      rw ← nnreal.coe_of_real q,\n      rw nnreal.coe_lt_coe,\n      apply A3,\n      apply A2,\n    },\n  },\nend\n\nlemma preimage_coe_Ioo2 {p q:ℝ}:(0 ≤ p) → (p < q) →\n    set.preimage (@coe nnreal real _) (set.Ioo p q) = set.Ioo (nnreal.of_real p) (nnreal.of_real q) :=\nbegin\n  intro A1,\n  intro A2,\n  have B1:0 ≤ q,\n  {\n    apply le_trans,\n    apply A1,\n    apply le_of_lt,\n    apply A2,\n  },\n  unfold set.Ioo,\n  ext,split;intro A3;simp at A3;simp,\n  {\n    cases A3 with A4 A5,\n    split;rw ← nnreal.coe_lt_coe;rw nnreal.coe_of_real,\n    apply A4,\n    apply A1,\n    apply A5,\n    apply B1,\n  },\n  {\n    cases A3 with A4 A5,\n    split,\n    {\n      rw ← nnreal.coe_of_real p,\n      rw nnreal.coe_lt_coe,\n      apply A4,\n      apply A1,\n    },\n    {\n      rw ← nnreal.coe_of_real q,\n      rw nnreal.coe_lt_coe,\n      apply A5,\n      apply B1,\n    },\n  },\nend\n\n\n\n\nlemma mem_nhds_elim_nnreal2 {b:set nnreal} {x:nnreal}:x ≠ 0 →  b∈ nhds x →\n(∃ p q:nnreal, (p < q) ∧ \n          ((set.Ioo p q) ⊆ b) ∧ \n          (p < x) ∧ (x < q))\n  :=\nbegin\n  intros A1 A2,\n  have A3 := mem_nhds_elim_nnreal A2,\n  cases A3 with p A3,\n  cases A3 with q A3,\n  cases A3 with A4 A5,\n  cases A5 with A6 A7,\n  cases A7 with A8 A9,\n  have A10:p < 0 ∨ 0 ≤ p := lt_or_le p 0,\n  have A11:0 < x := bot_lt_iff_ne_bot.mpr A1,\n  have A12:(@coe nnreal real _ 0) = (0:real) := rfl,\n  have A13:x.val = (@coe nnreal real _ x) := rfl,\n  have A14:0 < x.val,\n  {\n    rw A13,\n    rw ← A12,\n    rw nnreal.coe_lt_coe,\n    apply A11,\n  },\n  have A15:0 ≤ q,\n  {\n    apply le_trans,\n    apply x.property,\n    apply le_of_lt,\n    apply A9,\n  },\n  have A16:x < nnreal.of_real q,\n  {\n    rw ← nnreal.coe_lt_coe,\n    rw nnreal.coe_of_real,\n    apply A9,\n    apply A15,\n  },\n  cases A10,\n  {\n    apply exists.intro (0:nnreal),\n    apply exists.intro (nnreal.of_real q),\n    split,\n    {\n      rw ← nnreal.coe_lt_coe,\n      rw A12,\n      apply lt_trans,\n      apply A14,\n      rw A13,\n      apply lt_of_lt_of_le,\n      apply A9,\n      rw nnreal.coe_of_real,\n      apply A15,\n    },\n    split,\n    {\n      have B2:set.Ioo 0 (nnreal.of_real q) ⊆ \n              (set.preimage (@coe nnreal real _) (set.Ioo p q)),\n      {\n        rw preimage_coe_Ioo,\n        rw set.subset_def,\n        intros y B2A,\n        unfold set.Iio,\n        unfold set.Ioo at B2A,\n        simp at B2A,\n        simp,\n        apply B2A.right,\n        apply A10,\n        apply A15,\n      },\n      apply set.subset.trans B2 A6,\n    },\n    split,\n    {\n      apply A11,\n    },\n    {\n      apply A16,\n    },\n  },\n  {\n    apply exists.intro (nnreal.of_real p),\n    apply exists.intro (nnreal.of_real q),\n    have B1:nnreal.of_real p < x,\n    {\n      rw ← nnreal.coe_lt_coe,\n      rw nnreal.coe_of_real,\n      apply A8,\n      apply A10,\n    },\n    split,\n    {\n      apply lt_trans B1 A16,\n    },\n    split,\n    {\n      rw ← preimage_coe_Ioo2,\n      apply A6,\n      apply A10,\n      apply A4,\n    },\n    split,\n    {\n      apply B1,\n    },\n    {\n      apply A16,\n    },\n  },\nend\n\nlemma mem_nhds_elim_real_bound (b:set real) (x:real): b∈ nhds x →\n(∃ r>0, (set.Ioo (x-r) (x+r)) ⊆ b)\n  :=\nbegin\n  intros a,\n  have A1:(∃ p q:ℝ, (p < q) ∧ ((set.Ioo p q) ⊆ b) ∧ (p < x) ∧ (x < q)),\n  {\n    apply mem_nhds_elim_real,\n    apply a,\n  },\n  cases A1,\n  cases A1_h,\n  cases A1_h_h,\n  cases A1_h_h_right,\n  cases A1_h_h_right_right,\n\n  let r := min (x - A1_w) (A1_h_w -x),\n  begin\n  apply exists.intro r,\n  have A2:r>0,\n  {\n    apply lt_min,\n    {\n       apply (@lt_sub real _ 0 x A1_w).mpr,\n       simp,\n       assumption,\n    },\n    {\n       apply (@lt_sub real _ 0 A1_h_w x).mpr,\n       simp,\n       assumption,\n    }\n  },\n  apply exists.intro A2,\n  have A3:set.Ioo (x-r) (x+r) ⊆ set.Ioo A1_w A1_h_w,\n  {\n    unfold set.Ioo,\n    simp,\n    intros a_1 a_2 a_3,\n    split,\n    {\n      apply lt_of_le_of_lt,\n      show x - r < a_1,\n      {\n        assumption,\n      },\n      {\n        have A4:r <= x - A1_w,\n        apply min_le_left,\n        apply (@le_sub real _ r x A1_w).mp,\n        assumption,\n      }\n    },\n    {\n      apply lt_of_lt_of_le,\n      {\n        apply a_3,\n      },\n      { -- prove x + r ≤ A1_h_w\n        have A6:r <= A1_h_w - x,\n        apply min_le_right,\n        --rw A7,\n        apply (@le_neg_add_iff_add_le real _ x r A1_h_w).mp,\n        have A7:((-x)+A1_h_w=A1_h_w-x),\n        {\n          apply real.linear_ordered_comm_ring.add_comm,\n        },\n        rw A7,\n        assumption,\n      }\n    },\n  },\n  apply set.subset.trans,\n  apply A3,\n  assumption,\n  end\nend\n\nlemma nnreal_sub_le_sub_of_le2 {a b c:nnreal}:a ≤ b → a - c ≤ b - c :=\nbegin\n  intro A1,\n  have A2:(c ≤ a) ∨ (a ≤ c) := le_total c a,\n  cases A2,\n  {\n    rw ← add_le_add_iff_right c,\n    rw nnreal.sub_add_cancel_of_le A2,\n    rw nnreal.sub_add_cancel_of_le (le_trans A2 A1),\n    apply A1,\n  },\n  {\n    rw nnreal.sub_eq_zero A2,\n    apply bot_le,\n  },\nend\n\nlemma nnreal_le_sub_of_le_sub_of_le {p x r:nnreal}:p ≤ x → r ≤ x - p → p ≤ x - r :=\nbegin\n  intros A1 A2,\n  rw ← add_le_add_iff_right p at A2,\n  rw nnreal.sub_add_cancel_of_le A1 at A2,\n  have A3:(r + p) - r ≤ x - r := nnreal_sub_le_sub_of_le2 A2,\n  rw add_comm r p at A3,\n  rw nnreal.add_sub_cancel at A3,\n  apply A3,\nend\n\n--TODO: remove dependence on x≠0\nlemma mem_nhds_elim_nnreal_bound (b:set nnreal) (x:nnreal):x ≠ 0 →  b∈ nhds x →\n(∃ r>0, (set.Ioo (x-r) (x+r)) ⊆ b)\n  :=\nbegin\n  intros AX a,\n  have A1:(∃ p q:nnreal, (p < q) ∧ ((set.Ioo p q) ⊆ b) ∧ (p < x) ∧ (x < q)),\n  {\n    apply mem_nhds_elim_nnreal2,\n    apply AX,\n    apply a,\n  },\n  cases A1 with p A1,\n  cases A1 with q A1,\n  cases A1 with B1 B2,\n  cases B2 with B2 B3,\n  cases B3 with B3 B4,\n\n  let r := min (x - p) (q -x),\n  begin\n  apply exists.intro r,\n  have A2:r>0,\n  {\n    apply lt_min;rw nnreal.sub_pos,\n    {\n       apply B3,\n    },\n    {\n       apply B4,\n    }\n  },\n  apply exists.intro A2,\n  have A3:set.Ioo (x-r) (x+r) ⊆ set.Ioo p q,\n  {\n    apply set.Ioo_subset_Ioo,\n    {\n      have A4:r <= x - p := min_le_left (x-p) (q - x),\n      apply nnreal_le_sub_of_le_sub_of_le (le_of_lt B3) A4,\n    },\n    {\n      have A4:r <= q - x := min_le_right (x-p) (q - x),\n      rw ← add_le_add_iff_left x at A4,\n      apply le_trans A4,\n      rw add_comm x,\n      rw nnreal.sub_add_cancel_of_le (le_of_lt B4),\n    },\n  },\n  apply set.subset.trans,\n  apply A3,\n  assumption,\n  end\nend\n\n\n--This is filter.at_top_def\nlemma filter_at_top_def3 {α:Type*} [preorder α]:\nfilter.at_top = ⨅ a:α, filter.principal {b | a ≤ b} := rfl\n\nlemma filter_at_top_def (α:Type*):\n  (@filter.at_top (finset α) _)=  ⨅ (a:(finset α)),\n   filter.principal  {b:finset α | a⊆  b} := rfl\n\n--This is (roughly) filter.at_top_mem_sets\nlemma mem_filter_at_top_def2 {α:Type*}  [SL:semilattice_sup_bot α] {S:set α}:\n  (S∈ @filter.at_top α _)↔\n  (∃ a:α, {b:α|a ≤ b}⊆ S) :=\nbegin\n  have B1:order_bot α := semilattice_sup_bot.to_order_bot α,\n  have B2:has_bot α := order_bot.to_has_bot α,\n  rw filter_at_top_def3,\n  unfold infi,\n  have A1:(∀ X Y:filter α,\n  X ∈ (set.range (λ (a :α), filter.principal {b : α | a ≤ b})) →\n  Y ∈ (set.range (λ (a : α), filter.principal {b : α | a ≤ b})) →\n  X ⊓ Y ∈ (set.range (λ (a : α), filter.principal {b : α | a ≤ b}))),\n  {\n    intros X Y a a_1,\n    simp at a,\n    cases a,\n    subst X,\n    simp at a_1,\n    cases a_1,\n    subst Y,\n    --simp,\n    apply exists.intro (a_w ⊔ a_1_w),\n    symmetry,\n    apply principal_inf_sets2,\n  },\n  have A2:filter.principal {b : α | ⊥ ≤  b} ∈\n   (set.range (λ (a : α), filter.principal {b : α | a ≤ b})),\n  {\n    rw set.mem_range,\n    apply exists.intro ⊥,\n    refl,\n  },\n  have A3:(S ∈ Inf (set.range (λ (a : α), filter.principal {b :  α | a ≤ b})))↔\n          (∃ t∈ (set.range (λ (a : α), filter.principal {b : α | a ≤ b})), S∈ t),\n  {\n    apply (@Inf_filter_def (α)\n          (set.range (λ (a : α), filter.principal {b : α | a ≤ b}))\n          (filter.principal {b : α | ⊥ ≤ b})\n          A2\n          A1\n          ),\n  },\n  apply iff.trans,\n  apply A3,\n  split;intros a,\n  {\n    cases a,\n    cases a_h,\n    simp at a_h_w,\n    cases a_h_w,\n    apply exists.intro a_h_w_w,\n    simp,\n    subst a_w,\n    simp at a_h_h,\n    exact a_h_h,\n  },\n  {\n    cases a,\n    apply exists.intro (filter.principal  {b : α | a_w ≤ b}),\n    have A4:filter.principal {b : α | a_w ≤ b} ∈\n        set.range (λ (a : α), filter.principal {b : α | a ≤ b}),\n    {\n      simp,\n    },\n    apply exists.intro A4,\n    apply a_h,\n  }\nend\n\n\nlemma filter_at_top_def2 (α:Type*) [decidable_eq α] (S:set (finset α)):\n  (S∈ @filter.at_top (finset α) _)↔\n  (∃ a:finset α, {b:finset α|a ≤ b}⊆ S) :=\nbegin\n  apply mem_filter_at_top_def2,\nend\n\n\n--See alternatives below.\nlemma filter_at_top_intro {α:Type*} (b:set (finset α)) (c:finset α):\n  (b∈ (filter.principal {d:finset α |c ≤ d} )) →\n  (b ∈ (@filter.at_top (finset α) _)) :=\nbegin\n  intros,\n  rw filter_at_top_def,\n  unfold infi,\n  apply Inf_le_simp,\n  {\n    have A1:(filter.principal {d:finset α |c ≤ d} ) ∈\n    set.range (λ (a : finset α), filter.principal {b : finset α | a ⊆ b}),\n    {\n      unfold set.range,\n      simp,\n    },\n    apply A1,\n  },\n  {\n    assumption,\n  }\nend\n\nlemma filter_at_top_elim {α:Type*} [decidable_eq α] {S:set (finset α)} :\n  (S ∈ (@filter.at_top (finset α) _))→\n  (∃ a:(finset α), {b:finset α|a ≤ b}⊆ S) :=\nbegin\n  apply (filter_at_top_def2 α S).mp,\nend\n\nlemma filter_at_top_intro2 {α:Type*} (b:set (finset α)) (c:finset α):\n  ({d:finset α |c ≤ d} ⊆ b) →\n  (b ∈ (@filter.at_top (finset α) _)) :=\nbegin\n  intros a,\n  have A1:b∈ filter.principal {d:finset α |c ≤ d},\n  {\n    unfold filter.principal,\n    simp,\n    apply a,\n  },\n  apply filter_at_top_intro,\n  apply A1,\nend\n\n\nlemma filter_contains_preimage_superset (α β:Type) (B:filter β) (S T:set α) (f:β  → α):\n  (S⊆ T)→ ({x:β |f x ∈ S}∈ B) → ({x:β |f x ∈ T}∈ B) :=\nbegin\n  intros a a_1,\n  have A1:{x:β |f x ∈ S} ⊆ {x:β |f x ∈ T},\n  {\n    apply set.preimage_mono,\n    assumption,\n  },\n  apply B.sets_of_superset,\n  apply a_1,\n  assumption,\nend\n\nlemma filter_at_top_intro3  {α β:Type*} (c:finset α) (S:set β) (f:finset α → β):\n  (∀ d ≥ c, f d ∈ S) →\n  ({x:finset α|f x∈ S} ∈ (@filter.at_top (finset α) _)) :=\nbegin\n  intros a,\n  have A1:({d:finset α |c ≤ d} ⊆ {x:finset α|f x∈ S}),\n  {\n    rw set.subset_def,\n    intros x a_1,\n    simp,\n    simp at a_1,\n    apply a,\n    apply a_1,\n  },\n  apply filter_at_top_intro2,\n  apply A1,\nend\n\n\n\n\nlemma mem_filter_at_top_intro {α:Type*} [P:semilattice_sup_bot α] {S:set α} {x:α}:\n  {y|x≤ y}⊆ S →\n  S∈ (@filter.at_top α _) :=\nbegin\n  intro A1,\n  rw mem_filter_at_top_def2,\n  apply exists.intro x,\n  apply A1,\nend\n\n\n\nlemma mem_filter_at_top_elim {α:Type*} [P:semilattice_sup_bot α] {S:set α} :\n  (S ∈ (@filter.at_top α _))→\n  (∃ a:α, {b:α|a ≤ b}⊆ S) :=\nbegin\n  apply (mem_filter_at_top_def2).mp,\nend\n\nlemma in_own_Ioo {x ε:ℝ}:(0 < ε)→ x ∈ set.Ioo (x -ε) (x + ε) :=\nbegin\n  apply x_in_Ioo,\nend\n\n\n/-\n  Unused.\n-/\nlemma mem_nhds_elim_helper (b:set nnreal) (x:nnreal) (s:set nnreal)\n  (H2 : s ∈ {s : set nnreal | x ∈ s ∧ is_open s}):\n (set.range (λ (H : s ∈ {s : set nnreal | x ∈ s ∧ is_open s}), filter.principal s))\n = {x:filter nnreal| x=filter.principal s}\n  :=\nbegin\n  unfold set.range,\n  simp,\n  ext,\n  split,\n  {\n    simp,\n    intros a a_1 a_2,\n    symmetry,\n    exact a_2,\n  },\n  {\n    simp,\n    intros a,\n    split,\n    {\n      apply H2,\n    },\n    {\n      symmetry,\n      assumption,\n    }\n  }\nend\n\n\n\n\n\nlemma lim_Inf_filter_empty (α:Type*):\n  (@Inf (filter α) _ ∅) = ⊤ :=\nbegin\n  simp,\nend\n\nlemma set_in_lattice_infih (α:Type*) (s:set α) (S:set (set α))\n  (H2 : s ∉ S):\n (set.range (λ (H : s ∈ S), filter.principal s)) = ∅\n  :=\nbegin\n  unfold set.range,\n  simp,\n  rw set.eq_empty_iff_forall_not_mem,\n  intros F,\n  simp,\n  intros B1 B2,\n  apply H2,\n  apply B1\nend\n\nlemma set_in_lattice_infih2 (α:Type*) (s:set α) (S:set (set α))\n  (H2 : s ∈ S):\n (set.range (λ (H : s ∈ S), filter.principal s))\n = {filter.principal s}\n  :=\nbegin\n  unfold set.range,\n  simp,\n  ext,\n  split,\n  {\n    simp,\n    intros a a_1,\n    symmetry,\n    exact a_1,\n  },\n  {\n    simp,\n    intros a,\n    split,\n    {\n      apply H2,\n    },\n    {\n      symmetry,\n      exact a,\n    }\n  }\nend\n\n\n\nlemma lower_bounds_top (α:Type*) (S:set (filter α)):lower_bounds S = lower_bounds (S ∪ {⊤}) :=\nbegin\n  ext,\n  unfold lower_bounds,\n  split;intros a;\n   simp only [true_and, set.mem_insert_iff, forall_eq_or_imp, le_top, set.mem_set_of_eq, set.union_singleton];\n  simp only [true_and, set.mem_insert_iff, forall_eq_or_imp, le_top, set.mem_set_of_eq, \n             set.union_singleton] at a;intros;\n  {\n    apply a,\n    assumption,\n  },\nend\n\nlemma Inf_union_top (α:Type*) (S:set (filter α)):\nInf (S∪ {⊤}) = Inf S :=\nbegin\n  have A2:is_glb S (Inf S),\n  {\n    apply is_glb_Inf,\n  },\n  have A3:is_glb (S∪ {⊤}) (Inf S),\n  {\n    cases A2,\n    split,\n    {\n      rw ← lower_bounds_top,\n      exact A2_left,\n    },\n    {\n      rw ← lower_bounds_top,\n      exact A2_right,\n    }\n  },\n  apply is_glb.Inf_eq A3,\nend\n\n/-\n  If we unfold infi in nhds, we get a doubly-nested Infimum that is hard to\n  work with. This rewrites it more simply.\n -/\nlemma set_in_lattice_infi (α:Type*) (S:set (set α)):\n(⨅ (s∈ S), (filter.principal s)) = Inf  (set.image (filter.principal) S) :=\nbegin\n  unfold infi,\n  rw ← (@set.image_union_image_compl_eq_range (set α) _ S),\n  have A1:(λ (s : set α), Inf (set.range (λ (H : s ∈ S), filter.principal s))) '' (S)ᶜ =\n    (λ (s : set α), ⊤) '' Sᶜ,\n  {\n    rw set.image_congr,\n    intros,\n    have A1AA:set.range (λ (H : a ∈ S), filter.principal a) = ∅,\n    {\n      apply set_in_lattice_infih,\n      apply H,\n    },\n    rw A1AA,\n    rw lim_Inf_filter_empty,\n  },\n  rw A1,\n  have A2:(λ (s : set α), Inf (set.range (λ (H : s ∈ S), filter.principal s))) '' (S) =\n    (λ (s : set α), filter.principal s) '' S,\n  {\n    rw set.image_congr,\n    intros,\n    have A2A:set.range (λ (H : a ∈ S), filter.principal a) = {filter.principal a},\n    {\n      apply set_in_lattice_infih2,\n      apply H,\n    },\n    rw A2A,\n    simp,\n  },\n  rw A2,\n\n  have A4:(Sᶜ = ∅)∨ set.nonempty Sᶜ,\n  {\n    apply set.eq_empty_or_nonempty,\n  },\n  cases A4,\n  {\n    rw A4,\n    simp,\n  },\n  {\n    rw set.nonempty_def at A4,\n    cases A4,\n    have A4A:∀ k:filter α,(λ (s : set α), k) '' Sᶜ = {k},\n    {\n      intros,\n      ext,\n      split;intros a,\n      {\n        cases a,\n        cases a_h,\n        simp at a_h_right,\n        rw a_h_right,\n        apply (set.mem_singleton),\n      },\n      {\n        split,\n        {\n          split,\n          apply A4_h,\n          simp,\n          simp at a,\n          rw a,\n        }\n      }\n    },\n    have A4B:(λ (s : set α), ⊤) '' Sᶜ = {⊤},\n    {\n      apply (A4A ⊤),\n    },\n    rw A4B,\n    apply Inf_union_top,\n  }\nend\n\n\nlemma open_nhds_inter\n    (α:Type*) [topological_space α] (x:α) (A B:set α):\n    (A∈ {s:set α|x∈ s∧ is_open s}) →\n    (B∈ {s:set α|x∈ s∧ is_open s}) →\n    ((A∩ B) ∈ {s:set α|x∈ s∧ is_open s}) :=\nbegin\n  intros a a_1,\n  cases a,\n  cases a_1,\n  split,\n  {\n    split;assumption,\n  },\n  {\n    apply is_open_inter;assumption,\n  },\nend\n\nlemma nhds_def1 (α:Type*) [topological_space α] (x:α):\nnhds x = Inf  (set.image (filter.principal) {S:set α|x∈ S ∧ is_open S}) :=\nbegin\n  unfold nhds,\n  unfold infi,\n  apply set_in_lattice_infi,\nend\n\n\n/-\n   This holds for an arbitrary topology.\n   See @mem_nhds_sets_iff\n -/\nlemma mem_nhds_intro_real2 {b U:set real} {x:real}:\nx∈ U →\nis_open U →\nU ⊆ b →\nb∈ nhds x :=\nbegin\n  intros A1 A2 A3,\n  rw nhds_def1,\n  have A4:b∈ filter.principal U,\n  {\n    apply filter_principal_intro3,\n    apply A3,\n  },\n  apply mem_Inf_intro A4,\n  {\n    simp,\n    split;assumption,\n  },\nend\n\n\n/- This holds for a (closed) order topology (I think) -/\nlemma mem_nhds_intro_real (b:set real) (x y z:real):\nx∈ set.Ioo y z →\nset.Ioo y z ⊆ b →\nb∈ nhds x :=\nbegin\n  intros A1 A2,\n  apply mem_nhds_intro_real2 A1 _ A2,\n  apply @is_open_Ioo ℝ _ _ _ y z,\nend\n\n\nlemma mem_nhds_filter_principal_intro (α:Type*) [topological_space α] (x:α) (V:set α):\n  V∈ {S:set α|x∈ S ∧ is_open S}→ filter.principal V ∈ (set.image (filter.principal) {S:set α|x∈ S ∧ is_open S}) :=\nbegin\n  intros a,\n  simp only [filter.principal_eq_iff_eq, set.mem_image, exists_eq_right, set.mem_set_of_eq],\n  assumption,\nend\n\n\nlemma mem_nhds_filter_principal_elim (α:Type*) [topological_space α] (x:α) (V:set α):\n  filter.principal V ∈ (set.image (filter.principal) {S:set α|x∈ S ∧ is_open S}) →\n  V∈ {S:set α|x∈ S ∧ is_open S} :=\nbegin\n  intros a,\n  simp at a,\n  apply a,\nend\n\n\nlemma mem_nhds_filter_principal_elim2 (α:Type*) [topological_space α] (x:α) (Z:filter α):\n  Z ∈ (set.image (filter.principal) {S:set α|x∈ S ∧ is_open S}) →\n  (∃ V:set α, V∈ {S:set α|x∈ S ∧ is_open S} ∧ filter.principal V = Z) :=\nbegin\n  intros a,\n  simp at a,\n  apply a,\nend\n\n\nlemma has_open_neighborhood (α:Type*) [topological_space α] (x:α):∃ U:set α, x∈ U ∧ is_open U :=\nbegin\n  apply exists.intro set.univ,\n  split,\n  {\n    simp,\n  },\n  {\n    apply topological_space.is_open_univ,\n  }\nend\n\n\nlemma nhds_def2 (α:Type*) [topological_space α] (x:α) (S:set α):\nS ∈ nhds x ↔\n(∃ u:set α, (u⊆ S) ∧ is_open u ∧ (x∈ u)) :=\nbegin\n  rw nhds_def1,\n  have H:∃ U:set α, x∈ U ∧ is_open U,\n  apply has_open_neighborhood,\n  cases H,\n  cases H_h,\n\n  apply iff.trans,\n  {\n    apply Inf_filter_def,\n    {\n      apply mem_nhds_filter_principal_intro,\n      simp,\n      split,\n      {\n        apply H_h_left,\n      },\n      {\n        apply H_h_right,\n      }\n    },\n    {\n      intros a b a_1 a_2,\n      have A1:(∃ V:set α, V∈ {S:set α|x∈ S ∧ is_open S} ∧ filter.principal V = a),\n      {\n        apply mem_nhds_filter_principal_elim2,\n        apply a_1,\n      },\n      cases A1,\n      cases A1_h,\n      subst a,\n      have A2:(∃ V:set α, V∈ {S:set α|x∈ S ∧ is_open S} ∧ filter.principal V = b),\n      {\n        apply mem_nhds_filter_principal_elim2,\n        apply a_2,\n      },\n      cases A2,\n      cases A2_h,\n      subst b,\n      have A3:((A1_w ∩ A2_w) ∈ {s:set α|x∈ s∧ is_open s}),\n      {\n        apply open_nhds_inter;assumption,\n      },\n      rw principal_inf,\n      split,\n      {\n        split,\n        {\n          apply A3,\n        },\n        {\n          refl,\n        }\n      }\n    }\n  },\n  {\n    split;intros a,\n    {\n      cases a,\n      cases a_h,\n      have A4:(∃ V:set α, V∈ {S:set α|x∈ S ∧ is_open S} ∧ filter.principal V = a_w),\n      {\n        apply mem_nhds_filter_principal_elim2,\n        apply a_h_w,\n      },\n      cases A4,\n      cases A4_h,\n      subst a_w,\n      apply exists.intro A4_w,\n      cases A4_h_left,\n      split,\n      {\n        assumption,\n      },\n      split;assumption,\n    },\n    {\n      cases a,\n      cases a_h,\n      cases a_h_right,\n      apply exists.intro (filter.principal a_w),\n      {\n        have A5:filter.principal a_w ∈ filter.principal '' {S : set α | x ∈ S ∧ is_open S},\n        {\n          apply mem_nhds_filter_principal_intro,\n          split;assumption,\n        },\n        apply exists.intro A5,\n        apply filter_principal_intro3,\n        assumption,\n      }\n    }\n  }\nend\n\n\nlemma nhds_contain_point (α:Type*) [topological_space α] (x:α) (S:set α):\nS ∈ nhds x → x∈ S :=\nbegin\n  intros a,\n   have A1:(∃ u:set α, (u⊆ S) ∧ is_open u ∧ (x∈ u)),\n   {\n     apply (nhds_def2 α x S).mp a,\n   },\n   cases A1,\n   cases A1_h,\n   rw set.subset_def at A1_h_left,\n   apply A1_h_left,\n   apply A1_h_right.right,\nend\n\n\nlemma Ioo_nbhd {x ε:ℝ}:(0 < ε)→ set.Ioo (x -ε) (x + ε) ∈ nhds x :=\nbegin\n  intro A1,\n  apply mem_nhds_intro_real,\n  apply in_own_Ioo A1,\n  apply set.subset.refl,\nend\n\n\n--Remove dependency on not equal to zero.\nlemma set_Ioo_in_nhds_of_ne_zero {x:nnreal} {ε:nnreal}:x ≠ 0 → ε >0 → set.Ioo (x - ε) (x + ε) ∈ nhds x :=\nbegin\n  intros A1 A2,\n  rw @mem_nhds_sets_iff,\n--  have A3:(ε≤x) ∨ (x < ε) := le_or_lt ε x,\n  apply exists.intro (set.Ioo (x - ε) (x + ε)),\n  split,\n  apply @complete_lattice.le_refl (set nnreal) (@set.lattice_set nnreal),\n  split,\n  apply is_open_Ioo,\n  simp,\n  split,\n  {\n    apply nnreal.sub_lt_self,\n    {  \n      apply bot_lt_iff_ne_bot.mpr,\n      apply A1,\n    },\n    {\n      apply A2,\n    },\n  },\n  {\n    apply A2,\n  },\nend\n\n--TODO: remove dependence on x ≠ 0\nlemma set_Iio_in_nhds_of_lt {x y:nnreal}:x ≠ 0 → x < y → set.Iio y ∈ nhds x :=\nbegin\n  intros AX A1,\n  rw @mem_nhds_sets_iff,\n  apply exists.intro (set.Ioo 0 y),\n  split,\n  {\n    apply set.Ioo_subset_Iio_self,  \n  },\n  split,\n  {\n    apply is_open_Ioo,\n  },\n  simp,\n  split,\n  {\n    apply bot_lt_iff_ne_bot.mpr,\n    apply AX,\n  },\n  {\n    apply A1,\n  },\nend\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/filter_util.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.4935232879539904}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Sébastien Gouëzel, Zhouhang Zhou, Reid Barton\n-/\nimport topology.dense_embedding\nimport data.equiv.fin\n\n/-!\n# Homeomorphisms\n\nThis file defines homeomorphisms between two topological spaces. They are bijections with both\ndirections continuous. We denote homeomorphisms with the notation `≃ₜ`.\n\n# Main definitions\n\n* `homeomorph α β`: The type of homeomorphisms from `α` to `β`.\n  This type can be denoted using the following notation: `α ≃ₜ β`.\n\n# Main results\n\n* Pretty much every topological property is preserved under homeomorphisms.\n* `homeomorph.homeomorph_of_continuous_open`: A continuous bijection that is\n  an open map is a homeomorphism.\n\n-/\n\nopen set filter\nopen_locale topological_space\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\n\n/-- Homeomorphism between `α` and `β`, also called topological isomorphism -/\n@[nolint has_inhabited_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (α : Type*) (β : Type*) [topological_space α] [topological_space β]\n  extends α ≃ β :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` ≃ₜ `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n\ninstance : has_coe_to_fun (α ≃ₜ β) (λ _, α → β) := ⟨λe, e.to_equiv⟩\n\n@[simp] lemma homeomorph_mk_coe (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c) : α → β) = a :=\nrfl\n\n@[simp] lemma coe_to_equiv (h : α ≃ₜ β) : ⇑h.to_equiv = h := rfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : α ≃ₜ β) : β ≃ₜ α :=\n{ continuous_to_fun  := h.continuous_inv_fun,\n  continuous_inv_fun := h.continuous_to_fun,\n  to_equiv := h.to_equiv.symm }\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : α ≃ₜ β) : α → β := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : α ≃ₜ β) : β → α := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply, -to_equiv)\n\nlemma to_equiv_injective : function.injective (to_equiv : α ≃ₜ β → α ≃ β)\n| ⟨e, h₁, h₂⟩ ⟨e', h₁', h₂'⟩ rfl := rfl\n\n@[ext] lemma ext {h h' : α ≃ₜ β} (H : ∀ x, h x = h' x) : h = h' :=\nto_equiv_injective $ equiv.ext H\n\n/-- Identity map as a homeomorphism. -/\n@[simps apply {fully_applied := ff}]\nprotected def refl (α : Type*) [topological_space α] : α ≃ₜ α :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl α }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) : α ≃ₜ γ :=\n{ continuous_to_fun  := h₂.continuous_to_fun.comp h₁.continuous_to_fun,\n  continuous_inv_fun := h₁.continuous_inv_fun.comp h₂.continuous_inv_fun,\n  to_equiv := equiv.trans h₁.to_equiv h₂.to_equiv }\n\n@[simp] lemma trans_apply (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) (a : α) : h₁.trans h₂ a = h₂ (h₁ a) := rfl\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c).symm : β → α) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl α).symm = homeomorph.refl α := rfl\n\n@[continuity]\nprotected lemma continuous (h : α ≃ₜ β) : continuous h := h.continuous_to_fun\n\n@[continuity] -- otherwise `by continuity` can't prove continuity of `h.to_equiv.symm`\nprotected lemma continuous_symm (h : α ≃ₜ β) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : α ≃ₜ β) (x : β) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : α ≃ₜ β) (x : α) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : α ≃ₜ β) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : α ≃ₜ β) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : α ≃ₜ β) : function.surjective h := h.to_equiv.surjective\n\n/-- Change the homeomorphism `f` to make the inverse function definitionally equal to `g`. -/\ndef change_inv (f : α ≃ₜ β) (g : β → α) (hg : function.right_inverse g f) : α ≃ₜ β :=\nhave g = f.symm, from funext (λ x, calc g x = f.symm (f (g x)) : (f.left_inv (g x)).symm\n                                        ... = f.symm x : by rw hg x),\n{ to_fun := f,\n  inv_fun := g,\n  left_inv := by convert f.left_inv,\n  right_inv := by convert f.right_inv,\n  continuous_to_fun := f.continuous,\n  continuous_inv_fun := by convert f.symm.continuous }\n\n@[simp] lemma symm_comp_self (h : α ≃ₜ β) : ⇑h.symm ∘ ⇑h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : α ≃ₜ β) : ⇑h ∘ ⇑h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : α ≃ₜ β) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : α ≃ₜ β) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : α ≃ₜ β) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : α ≃ₜ β) (s : set β) : h '' (h ⁻¹' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : α ≃ₜ β) (s : set α) : h ⁻¹' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : α ≃ₜ β) : inducing h :=\ninducing_of_inducing_compose h.continuous h.symm.continuous $\n  by simp only [symm_comp_self, inducing_id]\n\nlemma induced_eq (h : α ≃ₜ β) : topological_space.induced h ‹_› = ‹_› := h.inducing.1.symm\n\nprotected lemma quotient_map (h : α ≃ₜ β) : quotient_map h :=\nquotient_map.of_quotient_map_compose h.symm.continuous h.continuous $\n  by simp only [self_comp_symm, quotient_map.id]\n\nlemma coinduced_eq (h : α ≃ₜ β) : topological_space.coinduced h ‹_› = ‹_› :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : α ≃ₜ β) : embedding h :=\n⟨h.inducing, h.injective⟩\n\n/-- Homeomorphism given an embedding. -/\nnoncomputable def of_embedding (f : α → β) (hf : embedding f) : α ≃ₜ (set.range f) :=\n{ continuous_to_fun := continuous_subtype_mk _ hf.continuous,\n  continuous_inv_fun := by simp [hf.continuous_iff, continuous_subtype_coe],\n  .. equiv.of_injective f hf.inj }\n\nprotected lemma second_countable_topology [topological_space.second_countable_topology β]\n  (h : α ≃ₜ β) :\n  topological_space.second_countable_topology α :=\nh.inducing.second_countable_topology\n\nlemma compact_image {s : set α} (h : α ≃ₜ β) : is_compact (h '' s) ↔ is_compact s :=\nh.embedding.is_compact_iff_is_compact_image.symm\n\nlemma compact_preimage {s : set β} (h : α ≃ₜ β) : is_compact (h ⁻¹' s) ↔ is_compact s :=\nby rw ← image_symm; exact h.symm.compact_image\n\nlemma compact_space [compact_space α] (h : α ≃ₜ β) : compact_space β :=\n{ compact_univ := by { rw [← image_univ_of_surjective h.surjective, h.compact_image],\n    apply compact_space.compact_univ } }\n\nlemma t2_space [t2_space α] (h : α ≃ₜ β) : t2_space β :=\n{ t2 :=\n  begin\n    intros x y hxy,\n    obtain ⟨u, v, hu, hv, hxu, hyv, huv⟩ := t2_separation (h.symm.injective.ne hxy),\n    refine ⟨h.symm ⁻¹' u, h.symm ⁻¹' v,\n      h.symm.continuous.is_open_preimage _ hu,\n      h.symm.continuous.is_open_preimage _ hv,\n      hxu, hyv, _⟩,\n    rw [← preimage_inter, huv, preimage_empty],\n  end }\n\nprotected lemma dense_embedding (h : α ≃ₜ β) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : α ≃ₜ β) {s : set β} : is_open (h ⁻¹' s) ↔ is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : α ≃ₜ β) {s : set α} : is_open (h '' s) ↔ is_open s :=\nby rw [← preimage_symm, is_open_preimage]\n\n@[simp] lemma is_closed_preimage (h : α ≃ₜ β) {s : set β} : is_closed (h ⁻¹' s) ↔ is_closed s :=\nby simp only [← is_open_compl_iff, ← preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : α ≃ₜ β) {s : set α} : is_closed (h '' s) ↔ is_closed s :=\nby rw [← preimage_symm, is_closed_preimage]\n\nlemma preimage_closure (h : α ≃ₜ β) (s : set β) : h ⁻¹' (closure s) = closure (h ⁻¹' s) :=\nby rw [h.embedding.closure_eq_preimage_closure_image, h.image_preimage]\n\nlemma image_closure (h : α ≃ₜ β) (s : set α) : h '' (closure s) = closure (h '' s) :=\nby rw [← preimage_symm, preimage_closure]\n\nprotected lemma is_open_map (h : α ≃ₜ β) : is_open_map h := λ s, h.is_open_image.2\n\nprotected lemma is_closed_map (h : α ≃ₜ β) : is_closed_map h := λ s, h.is_closed_image.2\n\nprotected lemma open_embedding (h : α ≃ₜ β) : open_embedding h :=\nopen_embedding_of_embedding_open h.embedding h.is_open_map\n\nprotected lemma closed_embedding (h : α ≃ₜ β) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\n@[simp] lemma map_nhds_eq (h : α ≃ₜ β) (x : α) : map h (𝓝 x) = 𝓝 (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : α ≃ₜ β) (x : α) : map h.symm (𝓝 (h x)) = 𝓝 x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : α ≃ₜ β) (x : α) : 𝓝 x = comap h (𝓝 (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : α ≃ₜ β) (y : β) : comap h (𝓝 y) = 𝓝 (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : α ≃ β` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : α ≃ β) (h₁ : continuous e) (h₂ : is_open_map e) :\n  α ≃ₜ β :=\n{ continuous_to_fun := h₁,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert ← h₂ s hs using 1,\n    apply e.image_eq_preimage\n  end,\n  to_equiv := e }\n\n@[simp] lemma comp_continuous_on_iff (h : α ≃ₜ β) (f : γ → α) (s : set γ) :\n  continuous_on (h ∘ f) s ↔ continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : α ≃ₜ β) {f : γ → α} :\n  continuous (h ∘ f) ↔ continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : α ≃ₜ β) {f : β → γ} :\n  continuous (f ∘ h) ↔ continuous f :=\nh.quotient_map.continuous_iff.symm\n\nlemma comp_continuous_at_iff (h : α ≃ₜ β) (f : γ → α) (x : γ) :\n  continuous_at (h ∘ f) x ↔ continuous_at f x :=\nh.inducing.continuous_at_iff.symm\n\nlemma comp_continuous_at_iff' (h : α ≃ₜ β) (f : β → γ) (x : α) :\n  continuous_at (f ∘ h) x ↔ continuous_at f (h x) :=\nh.inducing.continuous_at_iff' (by simp)\n\nlemma comp_continuous_within_at_iff (h : α ≃ₜ β) (f : γ → α) (s : set γ) (x : γ) :\n  continuous_within_at f s x ↔ continuous_within_at (h ∘ f) s x :=\nh.inducing.continuous_within_at_iff\n\n@[simp] lemma comp_is_open_map_iff (h : α ≃ₜ β) {f : γ → α} :\n  is_open_map (h ∘ f) ↔ is_open_map f :=\nbegin\n  refine ⟨_, λ hf, h.is_open_map.comp hf⟩,\n  intros hf,\n  rw [← function.comp.left_id f, ← h.symm_comp_self, function.comp.assoc],\n  exact h.symm.is_open_map.comp hf,\nend\n\n@[simp] lemma comp_is_open_map_iff' (h : α ≃ₜ β) {f : β → γ} :\n  is_open_map (f ∘ h) ↔ is_open_map f :=\nbegin\n  refine ⟨_, λ hf, hf.comp h.is_open_map⟩,\n  intros hf,\n  rw [← function.comp.right_id f, ← h.self_comp_symm, ← function.comp.assoc],\n  exact hf.comp h.symm.is_open_map,\nend\n\n/-- If two sets are equal, then they are homeomorphic. -/\ndef set_congr {s t : set α} (h : s = t) : s ≃ₜ t :=\n{ continuous_to_fun := continuous_subtype_mk _ continuous_subtype_val,\n  continuous_inv_fun := continuous_subtype_mk _ continuous_subtype_val,\n  to_equiv := equiv.set_congr h }\n\n/-- Sum of two homeomorphisms. -/\ndef sum_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α ⊕ γ ≃ₜ β ⊕ δ :=\n{ continuous_to_fun  :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h₁.continuous)\n      (continuous_inr.comp h₂.continuous),\n    ext x, cases x; refl,\n  end,\n  continuous_inv_fun :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h₁.symm.continuous)\n      (continuous_inr.comp h₂.symm.continuous),\n    ext x, cases x; refl\n  end,\n  to_equiv := h₁.to_equiv.sum_congr h₂.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α × γ ≃ₜ β × δ :=\n{ continuous_to_fun  := (h₁.continuous.comp continuous_fst).prod_mk\n    (h₂.continuous.comp continuous_snd),\n  continuous_inv_fun := (h₁.symm.continuous.comp continuous_fst).prod_mk\n    (h₂.symm.continuous.comp continuous_snd),\n  to_equiv := h₁.to_equiv.prod_congr h₂.to_equiv }\n\n@[simp] lemma prod_congr_symm (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  (h₁.prod_congr h₂).symm = h₁.symm.prod_congr h₂.symm := rfl\n\n@[simp] lemma coe_prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  ⇑(h₁.prod_congr h₂) = prod.map h₁ h₂ := rfl\n\nsection\nvariables (α β γ)\n\n/-- `α × β` is homeomorphic to `β × α`. -/\ndef prod_comm : α × β ≃ₜ β × α :=\n{ continuous_to_fun  := continuous_snd.prod_mk continuous_fst,\n  continuous_inv_fun := continuous_snd.prod_mk continuous_fst,\n  to_equiv := equiv.prod_comm α β }\n\n@[simp] lemma prod_comm_symm : (prod_comm α β).symm = prod_comm β α := rfl\n@[simp] lemma coe_prod_comm : ⇑(prod_comm α β) = prod.swap := rfl\n\n/-- `(α × β) × γ` is homeomorphic to `α × (β × γ)`. -/\ndef prod_assoc : (α × β) × γ ≃ₜ α × (β × γ) :=\n{ continuous_to_fun  := (continuous_fst.comp continuous_fst).prod_mk\n    ((continuous_snd.comp continuous_fst).prod_mk continuous_snd),\n  continuous_inv_fun := (continuous_fst.prod_mk (continuous_fst.comp continuous_snd)).prod_mk\n    (continuous_snd.comp continuous_snd),\n  to_equiv := equiv.prod_assoc α β γ }\n\n/-- `α × {*}` is homeomorphic to `α`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : α × punit ≃ₜ α :=\n{ to_equiv := equiv.prod_punit α,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} × α` is homeomorphic to `α`. -/\ndef punit_prod : punit × α ≃ₜ α :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : ⇑(punit_prod α) = prod.snd := rfl\n\nend\n\n/-- `ulift α` is homeomorphic to `α`. -/\ndef {u v} ulift {α : Type u} [topological_space α] : ulift.{v u} α ≃ₜ α :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(α ⊕ β) × γ` is homeomorphic to `α × γ ⊕ β × γ`. -/\ndef sum_prod_distrib : (α ⊕ β) × γ ≃ₜ α × γ ⊕ β × γ :=\nbegin\n  refine (homeomorph.homeomorph_of_continuous_open (equiv.sum_prod_distrib α β γ).symm _ _).symm,\n  { convert continuous_sum_rec\n      ((continuous_inl.comp continuous_fst).prod_mk continuous_snd)\n      ((continuous_inr.comp continuous_fst).prod_mk continuous_snd),\n    ext1 x, cases x; refl, },\n  { exact (is_open_map_sum\n    (open_embedding_inl.prod open_embedding_id).is_open_map\n    (open_embedding_inr.prod open_embedding_id).is_open_map) }\nend\n\n/-- `α × (β ⊕ γ)` is homeomorphic to `α × β ⊕ α × γ`. -/\ndef prod_sum_distrib : α × (β ⊕ γ) ≃ₜ α × β ⊕ α × γ :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {ι : Type*} {σ : ι → Type*} [Π i, topological_space (σ i)]\n\n/-- `(Σ i, σ i) × β` is homeomorphic to `Σ i, (σ i × β)`. -/\ndef sigma_prod_distrib : ((Σ i, σ i) × β) ≃ₜ (Σ i, (σ i × β)) :=\nhomeomorph.symm $\nhomeomorph_of_continuous_open (equiv.sigma_prod_distrib σ β).symm\n  (continuous_sigma $ λ i,\n    (continuous_sigma_mk.comp continuous_fst).prod_mk continuous_snd)\n  (is_open_map_sigma $ λ i,\n    (open_embedding_sigma_mk.prod open_embedding_id).is_open_map)\n\nend distrib\n\n/-- If `ι` has a unique element, then `ι → α` is homeomorphic to `α`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (ι α : Type*) [unique ι] [topological_space α] : (ι → α) ≃ₜ α :=\n{ to_equiv := equiv.fun_unique ι α,\n  continuous_to_fun := continuous_apply _,\n  continuous_inv_fun := continuous_pi (λ _, continuous_id) }\n\n/-- Homeomorphism between dependent functions `Π i : fin 2, α i` and `α 0 × α 1`. -/\n@[simps { fully_applied := ff }]\ndef {u} pi_fin_two (α : fin 2 → Type u) [Π i, topological_space (α i)] : (Π i, α i) ≃ₜ α 0 × α 1 :=\n{ to_equiv := pi_fin_two_equiv α,\n  continuous_to_fun := (continuous_apply 0).prod_mk (continuous_apply 1),\n  continuous_inv_fun := continuous_pi $ fin.forall_fin_two.2 ⟨continuous_fst, continuous_snd⟩ }\n\n/-- Homeomorphism between `α² = fin 2 → α` and `α × α`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 → α) ≃ₜ α × α :=\n{ to_equiv := fin_two_arrow_equiv α, ..  pi_fin_two (λ _, α) }\n\n/--\nA subset of a topological space is homeomorphic to its image under a homeomorphism.\n-/\ndef image (e : α ≃ₜ β) (s : set α) : s ≃ₜ e '' s :=\n{ continuous_to_fun := by continuity!,\n  continuous_inv_fun := by continuity!,\n  ..e.to_equiv.image s, }\n\nend homeomorph\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/topology/homeomorph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240402, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.4935232878579374}}
{"text": "import ring_theory.is_tensor_product\nimport category_theory.limits.shapes.comm_sq\nimport ring_theory.polynomial.basic\nimport algebra.category.Ring.constructions\n\nsection \nvariables (R S : Type*) [comm_ring R] [comm_ring S] [algebra R S] \n\nopen_locale polynomial\n\n\n@[reducible] noncomputable\ndef polynomial.polynomial_algebra_of_algebra :\n  algebra R[X] S[X] := (polynomial.map_ring_hom $ algebra_map R S).to_algebra\n\nlocal attribute [instance] polynomial.polynomial_algebra_of_algebra\n\n@[simp]\nlemma polynomial.polynomial_algebra_of_algebra_algebra_map_apply (p : R[X]) :\n  algebra_map R[X] S[X] p = p.map (algebra_map R S) := rfl\n\ninstance polynomial.is_scalar_tower_of_algebra : is_scalar_tower R R[X] S[X] :=\nis_scalar_tower.of_algebra_map_eq (λ x, (@polynomial.map_C _ _ x _ _ $ algebra_map R S).symm)\n\nlemma algebra.is_pushout_iff_bijective {R S R' S' : Type*} [comm_ring R] [comm_ring S] \n  [comm_ring R'] [comm_ring S']\n  [algebra R S] [algebra R R'] [algebra S S'] [algebra R' S'] [algebra R S']\n  [is_scalar_tower R R' S'] [is_scalar_tower R S S'] :\n  algebra.is_pushout R R' S S' ↔ function.bijective (algebra.tensor_product.product_map\n    (is_scalar_tower.to_alg_hom R R' S')\n      (is_scalar_tower.to_alg_hom R S S')) :=\nbegin\n  rw algebra.is_pushout_iff,\n  change _ ↔ function.bijective (algebra.tensor_product.product_map _ _).to_linear_map,\n  delta is_base_change is_tensor_product,\n  congr',\n  apply tensor_product.ext',\n  intros x y,\n  simp only [algebra.of_id_apply,\n tensor_product.lift.tmul,\n alg_hom.to_linear_map_apply,\n linear_map.smul_apply,\n module.algebra_map_End_apply,\n is_scalar_tower.coe_to_alg_hom',\n algebra.smul_def,\n algebra.tensor_product.product_map_apply_tmul,\n linear_map.coe_restrict_scalars_eq_coe,\n linear_map.flip_apply],\nend \n\nlemma algebra.tensor_product.ring_hom_ext {R A B S : Type*} [comm_ring R] [comm_ring A] \n  [comm_ring B] [comm_ring S] [algebra R A] [algebra R B] (f g : tensor_product R A B →+* S) \n    (h : f.comp algebra.tensor_product.include_left.to_ring_hom =\n      g.comp algebra.tensor_product.include_left.to_ring_hom)\n    (h' : f.comp algebra.tensor_product.include_right.to_ring_hom =\n      g.comp algebra.tensor_product.include_right.to_ring_hom) : f = g :=\nbegin\n  ext x,\n  induction x using tensor_product.induction_on with x y x y hx hy,\n  { rw [map_zero, map_zero] },\n  { rw [← mul_one x, ← one_mul y, ← algebra.tensor_product.tmul_mul_tmul,\n      map_mul, map_mul],\n    congr' 1,\n    exacts [(ring_hom.congr_fun h x : _), (ring_hom.congr_fun h' y : _)] },\n  { rw [map_add, map_add, hx, hy] }\nend \n\nnoncomputable\ndef tensor_product_polynomial_equiv  :\n  tensor_product R S R[X] ≃ₐ[S] S[X] :=\n{ inv_fun := (polynomial.eval₂_ring_hom (algebra.tensor_product.include_left.to_ring_hom :\n    S →+* tensor_product R S R[X]) (1 ⊗ₜ polynomial.X) : _) ,\n  left_inv := begin\n    intro x,\n    rw [alg_hom.to_fun_eq_coe, ← alg_hom.coe_to_ring_hom, ← ring_hom.comp_apply],\n    conv_rhs { rw ← ring_hom.id_apply x },\n    congr' 1,\n    convert algebra.tensor_product.ring_hom_ext _ (ring_hom.id (tensor_product R S R[X])) _ _,\n    { ext x, simp only [algebra.of_id_apply,\n polynomial.eval₂_C,\n mul_one,\n ring_hom_comp_triple.comp_eq,\n algebra.tensor_product.product_left_alg_hom_apply,\n  polynomial.polynomial_algebra_of_algebra_algebra_map_apply,\n algebra.id.map_eq_id,\n ring_hom.to_fun_eq_coe,\n ring_hom.id_apply,\n alg_hom.coe_to_ring_hom,\n eq_self_iff_true,\n function.comp_app,\n polynomial.map_one,\n polynomial.coe_eval₂_ring_hom,\n ring_hom.coe_comp,\n is_scalar_tower.coe_to_alg_hom',\n algebra.tensor_product.include_left_apply,\n algebra.tensor_product.product_map_apply_tmul,\n alg_hom.coe_restrict_scalars',\n alg_hom.to_ring_hom_eq_coe,\n polynomial.algebra_map_apply]},\n    ext y,\n    { suffices : algebra_map R S y ⊗ₜ[R] 1 = 1 ⊗ₜ[R] polynomial.C y, { simpa only [polynomial.map_C,\n polynomial.eval₂_C,\n ring_hom_comp_triple.comp_eq,\n one_mul,\n algebra.tensor_product.product_left_alg_hom_apply,\n polynomial.polynomial_algebra_of_algebra_algebra_map_apply,\n ring_hom.to_fun_eq_coe,\n alg_hom.coe_to_ring_hom,\n function.comp_app,\n map_one,\n algebra.tensor_product.include_right_apply,\n polynomial.coe_eval₂_ring_hom,\n ring_hom.coe_comp,\n is_scalar_tower.coe_to_alg_hom',\n algebra.tensor_product.include_left_apply,\n algebra.tensor_product.product_map_apply_tmul,\n alg_hom.coe_restrict_scalars',\n alg_hom.to_ring_hom_eq_coe] using this },\n      rw [algebra.algebra_map_eq_smul_one, tensor_product.smul_tmul,\n        ← algebra.algebra_map_eq_smul_one, polynomial.algebra_map_apply], refl },\n    { simp only [ring_hom_comp_triple.comp_eq,\n polynomial.map_X,\n one_mul,\n algebra.tensor_product.product_left_alg_hom_apply,\n polynomial.polynomial_algebra_of_algebra_algebra_map_apply,\n polynomial.eval₂_X,\n ring_hom.to_fun_eq_coe,\n alg_hom.coe_to_ring_hom,\n eq_self_iff_true,\n function.comp_app,\n map_one,\n algebra.tensor_product.include_right_apply,\n polynomial.coe_eval₂_ring_hom,\n ring_hom.coe_comp,\n is_scalar_tower.coe_to_alg_hom',\n algebra.tensor_product.product_map_apply_tmul,\n alg_hom.coe_restrict_scalars',\n alg_hom.to_ring_hom_eq_coe] }\n  end,\n  right_inv := begin\n    intro x,\n    rw [alg_hom.to_fun_eq_coe, ← alg_hom.coe_to_ring_hom, ← ring_hom.comp_apply],\n    conv_rhs { rw ← ring_hom.id_apply x },\n    congr' 1,\n    ext y; simp only [ alg_hom.coe_restrict_scalars',\n alg_hom.coe_to_ring_hom,\n alg_hom.to_ring_hom_eq_coe,\n algebra.id.map_eq_id,\n algebra.of_id_apply,\n algebra.tensor_product.include_left_apply,\n algebra.tensor_product.product_left_alg_hom_apply,\n algebra.tensor_product.product_map_apply_tmul,\n polynomial.polynomial_algebra_of_algebra_algebra_map_apply,\n function.comp_app,\n is_scalar_tower.coe_to_alg_hom',\n map_one,\n mul_one,\n one_mul,\n polynomial.algebra_map_apply, polynomial.map_X,\n polynomial.coe_eval₂_ring_hom,\n polynomial.eval₂_C,\n polynomial.eval₂_X,\n polynomial.map_one,\n ring_hom.coe_comp,\n ring_hom.id_apply,\n ring_hom.to_fun_eq_coe,\n ring_hom_comp_triple.comp_eq]\n  end,\n  ..(algebra.tensor_product.product_left_alg_hom (algebra.of_id S S[X])\n      (is_scalar_tower.to_alg_hom R R[X] S[X]) : _) }\n.\n@[instance]\nlemma is_pushout_CommRing_polynomial (R S : Type*) [comm_ring R] [comm_ring S] [algebra R S] :\n  algebra.is_pushout R S R[X] S[X] :=\nbegin\n  rw algebra.is_pushout_iff_bijective,\n  exact (tensor_product_polynomial_equiv R S).bijective,\nend \n\nopen category_theory category_theory.limits\n\nlemma algebra.is_pushout.to_is_pushout (R S R' S' : Type*) [comm_ring R] [comm_ring S] \n  [comm_ring R'] [comm_ring S']\n  [algebra R S] [algebra R R'] [algebra S S'] [algebra R' S'] [algebra R S']\n  [is_scalar_tower R R' S'] [is_scalar_tower R S S'] [H : algebra.is_pushout R S R' S'] :\n  is_pushout (CommRing.of_hom $ algebra_map R S) (CommRing.of_hom $ algebra_map R R')\n   (CommRing.of_hom $ algebra_map S S') (CommRing.of_hom $ algebra_map R' S') :=\nbegin\n  refine ⟨⟨_⟩, ⟨pushout_cocone.is_colimit_aux' _ _⟩⟩,\n  { ext x, refine (is_scalar_tower.algebra_map_apply R S S' x)\n      .symm.trans (is_scalar_tower.algebra_map_apply R R' S' x : _) },\n  { intro s, \n    let T := s.X,\n    letI : algebra R T := (s.ι.app $ walking_span.zero).to_algebra,\n    let f : S →ₐ[R] T :=\n      { commutes' := ring_hom.congr_fun (s.ι.naturality walking_span.hom.fst), ..s.inl },\n    let g : R' →ₐ[R] T :=\n      { commutes' := ring_hom.congr_fun (s.ι.naturality walking_span.hom.snd), ..s.inr },\n    refine ⟨(algebra.pushout_desc S' f g $ λ _ _, mul_comm _ _).to_ring_hom, _, _, _⟩,\n    { ext, exact algebra.pushout_desc_left S' f g (λ _ _, mul_comm _ _) x },\n    { ext, exact algebra.pushout_desc_right S' f g (λ _ _, mul_comm _ _) x },\n    { intros m hm₁ hm₂,\n      ext x,\n      apply H.1.induction_on x,\n  { simp only [map_zero] },\n  { intro y, exact (ring_hom.congr_fun hm₂ y).trans\n      (algebra.pushout_desc_right S' f g (λ _ _, mul_comm _ _) y).symm },\n  { intros y y' e, rw [algebra.smul_def, map_mul, map_mul, e],\n    congr' 1, exact (ring_hom.congr_fun hm₁ y).trans\n      (algebra.pushout_desc_left  S' f g (λ _ _, mul_comm _ _) y).symm },\n  { intros s₁ s₂ e₁ e₂, rw [map_add, map_add, e₁, e₂] } } }\nend\n\nend ", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/for_mathlib/algebra_is_pushout.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4934683452495439}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta, E. W. Ayers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, E. W. Ayers\n-/\n\nimport category_theory.sites.sieves\nimport category_theory.limits.shapes.pullbacks\nimport order.copy\n\n/-!\n# Grothendieck topologies\n\nDefinition and lemmas about Grothendieck topologies.\nA Grothendieck topology for a category `C` is a set of sieves on each object `X` satisfying\ncertain closure conditions.\n\nAlternate versions of the axioms (in arrow form) are also described.\nTwo explicit examples of Grothendieck topologies are given:\n* The dense topology\n* The atomic topology\nas well as the complete lattice structure on Grothendieck topologies (which gives two additional\nexplicit topologies: the discrete and trivial topologies.)\n\nA pretopology, or a basis for a topology is defined in `pretopology.lean`. The topology associated\nto a topological space is defined in `spaces.lean`.\n\n## Tags\n\nGrothendieck topology, coverage, pretopology, site\n\n## References\n\n* [https://ncatlab.org/nlab/show/Grothendieck+topology][nlab]\n* [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM91]\n\n## Implementation notes\n\nWe use the definition of [nlab] and [MM91](Chapter III, Section 2), where Grothendieck topologies\nare saturated collections of morphisms, rather than the notions of the Stacks project (00VG) and\nthe Elephant, in which topologies are allowed to be unsaturated, and are then completed.\nTODO (BM): Add the definition from Stacks, as a pretopology, and complete to a topology.\n\nThis is so that we can produce a bijective correspondence between Grothendieck topologies on a\nsmall category and Lawvere-Tierney topologies on its presheaf topos, as well as the equivalence\nbetween Grothendieck topoi and left exact reflective subcategories of presheaf toposes.\n-/\n\nuniverses v u\nnamespace category_theory\n\nopen category_theory category\n\nvariables (C : Type u) [category.{v} C]\n\n/--\nThe definition of a Grothendieck topology: a set of sieves `J X` on each object `X` satisfying\nthree axioms:\n1. For every object `X`, the maximal sieve is in `J X`.\n2. If `S ∈ J X` then its pullback along any `h : Y ⟶ X` is in `J Y`.\n3. If `S ∈ J X` and `R` is a sieve on `X`, then provided that the pullback of `R` along any arrow\n   `f : Y ⟶ X` in `S` is in `J Y`, we have that `R` itself is in `J X`.\n\nA sieve `S` on `X` is referred to as `J`-covering, (or just covering), if `S ∈ J X`.\n\nSee https://stacks.math.columbia.edu/tag/00Z4, or [nlab], or [MM92] Chapter III, Section 2,\nDefinition 1.\n-/\nstructure grothendieck_topology :=\n(sieves : Π (X : C), set (sieve X))\n(top_mem' : ∀ X, ⊤ ∈ sieves X)\n(pullback_stable' : ∀ ⦃X Y : C⦄ ⦃S : sieve X⦄ (f : Y ⟶ X), S ∈ sieves X → S.pullback f ∈ sieves Y)\n(transitive' : ∀ ⦃X⦄ ⦃S : sieve X⦄ (hS : S ∈ sieves X) (R : sieve X),\n              (∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → R.pullback f ∈ sieves Y) → R ∈ sieves X)\n\nnamespace grothendieck_topology\n\ninstance : has_coe_to_fun (grothendieck_topology C) :=\n⟨_, λ J, J.sieves⟩\n\nvariables {C} {X Y : C} {S R : sieve X}\nvariables (J : grothendieck_topology C)\n\n/--\nAn extensionality lemma in terms of the coercion to a pi-type.\nWe prove this explicitly rather than deriving it so that it is in terms of the coercion rather than\nthe projection `.sieves`.\n-/\n@[ext]\nlemma ext {J₁ J₂ : grothendieck_topology C} (h : (J₁ : Π (X : C), set (sieve X)) = J₂) : J₁ = J₂ :=\nby { cases J₁, cases J₂, congr, apply h }\n\n@[simp] lemma mem_sieves_iff_coe : S ∈ J.sieves X ↔ S ∈ J X := iff.rfl\n\n-- Also known as the maximality axiom.\n@[simp] lemma top_mem (X : C) : ⊤ ∈ J X := J.top_mem' X\n-- Also known as the stability axiom.\n@[simp] lemma pullback_stable (f : Y ⟶ X) (hS : S ∈ J X) : S.pullback f ∈ J Y :=\nJ.pullback_stable' f hS\nlemma transitive (hS : S ∈ J X) (R : sieve X)\n  (h : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → R.pullback f ∈ J Y) :\n  R ∈ J X :=\nJ.transitive' hS R h\n\nlemma covering_of_eq_top : S = ⊤ → S ∈ J X := λ h, h.symm ▸ J.top_mem X\n\n/--\nIf `S` is a subset of `R`, and `S` is covering, then `R` is covering as well.\n\nSee https://stacks.math.columbia.edu/tag/00Z5 (2), or discussion after [MM92] Chapter III,\nSection 2, Definition 1.\n-/\nlemma superset_covering (Hss : S ≤ R) (sjx : S ∈ J X) : R ∈ J X :=\nbegin\n  apply J.transitive sjx R (λ Y f hf, _),\n  apply covering_of_eq_top,\n  rw [← top_le_iff, ← S.pullback_eq_top_of_mem hf],\n  apply sieve.pullback_monotone _ Hss,\nend\n\n/--\nThe intersection of two covering sieves is covering.\n\nSee https://stacks.math.columbia.edu/tag/00Z5 (1), or [MM92] Chapter III,\nSection 2, Definition 1 (iv).\n-/\nlemma intersection_covering (rj : R ∈ J X) (sj : S ∈ J X) : R ⊓ S ∈ J X :=\nbegin\n  apply J.transitive rj _ (λ Y f Hf, _),\n  rw [sieve.pullback_inter, R.pullback_eq_top_of_mem Hf],\n  simp [sj],\nend\n\n@[simp]\nlemma intersection_covering_iff : R ⊓ S ∈ J X ↔ R ∈ J X ∧ S ∈ J X :=\n⟨λ h, ⟨J.superset_covering inf_le_left h, J.superset_covering inf_le_right h⟩,\n λ t, intersection_covering _ t.1 t.2⟩\n\n\n\n/--\nThe sieve `S` on `X` `J`-covers an arrow `f` to `X` if `S.pullback f ∈ J Y`.\nThis definition is an alternate way of presenting a Grothendieck topology.\n-/\ndef covers (S : sieve X) (f : Y ⟶ X) : Prop := S.pullback f ∈ J Y\n\nlemma covers_iff (S : sieve X) (f : Y ⟶ X) : J.covers S f ↔ S.pullback f ∈ J Y :=\niff.rfl\n\nlemma covering_iff_covers_id (S : sieve X) : S ∈ J X ↔ J.covers S (𝟙 X) :=\nby simp [covers_iff]\n\n/-- The maximality axiom in 'arrow' form: Any arrow `f` in `S` is covered by `S`. -/\nlemma arrow_max (f : Y ⟶ X) (S : sieve X) (hf : S f) : J.covers S f :=\nbegin\n  rw [covers, (sieve.pullback_eq_top_iff_mem f).1 hf],\n  apply J.top_mem,\nend\n\n/-- The stability axiom in 'arrow' form: If `S` covers `f` then `S` covers `g ≫ f` for any `g`. -/\nlemma arrow_stable (f : Y ⟶ X) (S : sieve X) (h : J.covers S f) {Z : C} (g : Z ⟶ Y) :\n  J.covers S (g ≫ f) :=\nbegin\n  rw covers_iff at h ⊢,\n  simp [h, sieve.pullback_comp],\nend\n\n/--\nThe transitivity axiom in 'arrow' form: If `S` covers `f` and every arrow in `S` is covered by\n`R`, then `R` covers `f`.\n-/\nlemma arrow_trans (f : Y ⟶ X) (S R : sieve X) (h : J.covers S f) :\n  (∀ {Z : C} (g : Z ⟶ X), S g → J.covers R g) → J.covers R f :=\nbegin\n  intro k,\n  apply J.transitive h,\n  intros Z g hg,\n  rw ← sieve.pullback_comp,\n  apply k (g ≫ f) hg,\nend\n\nlemma arrow_intersect (f : Y ⟶ X) (S R : sieve X) (hS : J.covers S f) (hR : J.covers R f) :\n  J.covers (S ⊓ R) f :=\nby simpa [covers_iff] using and.intro hS hR\n\nvariable (C)\n/--\nThe trivial Grothendieck topology, in which only the maximal sieve is covering. This topology is\nalso known as the indiscrete, coarse, or chaotic topology.\n\nSee [MM92] Chapter III, Section 2, example (a), or\nhttps://en.wikipedia.org/wiki/Grothendieck_topology#The_discrete_and_indiscrete_topologies\n-/\ndef trivial : grothendieck_topology C :=\n{ sieves := λ X, {⊤},\n  top_mem' := λ X, rfl,\n  pullback_stable' := λ X Y S f hf,\n  begin\n    rw set.mem_singleton_iff at ⊢ hf,\n    simp [hf],\n  end,\n  transitive' := λ X S hS R hR,\n  begin\n    rw [set.mem_singleton_iff, ← sieve.id_mem_iff_eq_top] at hS,\n    simpa using hR hS,\n  end }\n\n/--\nThe discrete Grothendieck topology, in which every sieve is covering.\n\nSee https://en.wikipedia.org/wiki/Grothendieck_topology#The_discrete_and_indiscrete_topologies.\n-/\ndef discrete : grothendieck_topology C :=\n{ sieves := λ X, set.univ,\n  top_mem' := by simp,\n  pullback_stable' := λ X Y f, by simp,\n  transitive' := by simp }\nvariable {C}\n\nlemma trivial_covering : S ∈ trivial C X ↔ S = ⊤ := set.mem_singleton_iff\n\n/-- See https://stacks.math.columbia.edu/tag/00Z6 -/\ninstance : partial_order (grothendieck_topology C) :=\n{ le := λ J₁ J₂, (J₁ : Π (X : C), set (sieve X)) ≤ (J₂ : Π (X : C), set (sieve X)),\n  le_refl := λ J₁, le_refl _,\n  le_trans := λ J₁ J₂ J₃ h₁₂ h₂₃, le_trans h₁₂ h₂₃,\n  le_antisymm := λ J₁ J₂ h₁₂ h₂₁, grothendieck_topology.ext (le_antisymm h₁₂ h₂₁) }\n\n/-- See https://stacks.math.columbia.edu/tag/00Z7 -/\ninstance : has_Inf (grothendieck_topology C) :=\n{ Inf := λ T,\n  { sieves := Inf (sieves '' T),\n    top_mem' :=\n    begin\n      rintro X S ⟨⟨_, J, hJ, rfl⟩, rfl⟩,\n      simp,\n    end,\n    pullback_stable' :=\n    begin\n      rintro X Y S hS f _ ⟨⟨_, J, hJ, rfl⟩, rfl⟩,\n      apply J.pullback_stable _ (f _ ⟨⟨_, _, hJ, rfl⟩, rfl⟩),\n    end,\n    transitive' :=\n    begin\n      rintro X S hS R h _ ⟨⟨_, J, hJ, rfl⟩, rfl⟩,\n      apply J.transitive (hS _ ⟨⟨_, _, hJ, rfl⟩, rfl⟩) _ (λ Y f hf, h hf _ ⟨⟨_, _, hJ, rfl⟩, rfl⟩),\n    end } }\n\n/-- See https://stacks.math.columbia.edu/tag/00Z7 -/\nlemma is_glb_Inf (s : set (grothendieck_topology C)) : is_glb s (Inf s) :=\nbegin\n  refine @is_glb.of_image _ _ _ _ sieves _ _ _ _,\n  { intros, refl },\n  { exact is_glb_Inf _ },\nend\n\n/--\nConstruct a complete lattice from the `Inf`, but make the trivial and discrete topologies\ndefinitionally equal to the bottom and top respectively.\n-/\ninstance : complete_lattice (grothendieck_topology C) :=\ncomplete_lattice.copy\n(complete_lattice_of_Inf _ is_glb_Inf)\n_ rfl\n(discrete C)\n(begin\n  apply le_antisymm,\n  { exact @complete_lattice.le_top _ (complete_lattice_of_Inf _ is_glb_Inf) (discrete C) },\n  { intros X S hS,\n    apply set.mem_univ },\nend)\n(trivial C)\n(begin\n  apply le_antisymm,\n  { intros X S hS,\n    rw trivial_covering at hS,\n    apply covering_of_eq_top _ hS },\n  { refine @complete_lattice.bot_le _ (complete_lattice_of_Inf _ is_glb_Inf) (trivial C) },\nend)\n_ rfl\n_ rfl\n_ rfl\nInf rfl\n\ninstance : inhabited (grothendieck_topology C) := ⟨⊤⟩\n\n@[simp] lemma trivial_eq_bot : trivial C = ⊥ := rfl\n@[simp] lemma discrete_eq_top : discrete C = ⊤ := rfl\n\n@[simp] lemma bot_covering : S ∈ (⊥ : grothendieck_topology C) X ↔ S = ⊤ := trivial_covering\n@[simp] lemma top_covering : S ∈ (⊤ : grothendieck_topology C) X := ⟨⟩\n\nlemma bot_covers (S : sieve X) (f : Y ⟶ X) :\n  (⊥ : grothendieck_topology C).covers S f ↔ S f :=\nby rw [covers_iff, bot_covering, ← sieve.pullback_eq_top_iff_mem]\n\n@[simp] lemma top_covers (S : sieve X) (f : Y ⟶ X) : (⊤ : grothendieck_topology C).covers S f :=\nby simp [covers_iff]\n\n/--\nThe dense Grothendieck topology.\n\nSee https://ncatlab.org/nlab/show/dense+topology, or [MM92] Chapter III, Section 2, example (e).\n-/\ndef dense : grothendieck_topology C :=\n{ sieves := λ X S, ∀ {Y : C} (f : Y ⟶ X), ∃ Z (g : Z ⟶ Y), S (g ≫ f),\n  top_mem' := λ X Y f, ⟨Y, 𝟙 Y, ⟨⟩⟩,\n  pullback_stable' :=\n  begin\n    intros X Y S h H Z f,\n    rcases H (f ≫ h) with ⟨W, g, H'⟩,\n    exact ⟨W, g, by simpa⟩,\n  end,\n  transitive' :=\n  begin\n    intros X S H₁ R H₂ Y f,\n    rcases H₁ f with ⟨Z, g, H₃⟩,\n    rcases H₂ H₃ (𝟙 Z) with ⟨W, h, H₄⟩,\n    exact ⟨W, (h ≫ g), by simpa using H₄⟩,\n  end }\n\nlemma dense_covering : S ∈ dense X ↔ ∀ {Y} (f : Y ⟶ X), ∃ Z (g : Z ⟶ Y), S (g ≫ f) :=\niff.rfl\n\n/--\nA category satisfies the right Ore condition if any span can be completed to a commutative square.\nNB. Any category with pullbacks obviously satisfies the right Ore condition, see\n`right_ore_of_pullbacks`.\n-/\ndef right_ore_condition (C : Type u) [category.{v} C] : Prop :=\n∀ {X Y Z : C} (yx : Y ⟶ X) (zx : Z ⟶ X), ∃ W (wy : W ⟶ Y) (wz : W ⟶ Z), wy ≫ yx = wz ≫ zx\n\nlemma right_ore_of_pullbacks [limits.has_pullbacks C] : right_ore_condition C :=\nλ X Y Z yx zx, ⟨_, _, _, limits.pullback.condition⟩\n\n/--\nThe atomic Grothendieck topology: a sieve is covering iff it is nonempty.\nFor the pullback stability condition, we need the right Ore condition to hold.\n\nSee https://ncatlab.org/nlab/show/atomic+site, or [MM92] Chapter III, Section 2, example (f).\n-/\ndef atomic (hro : right_ore_condition C) : grothendieck_topology C :=\n{ sieves := λ X S, ∃ Y (f : Y ⟶ X), S f,\n  top_mem' := λ X, ⟨_, 𝟙 _, ⟨⟩⟩,\n  pullback_stable' :=\n  begin\n    rintros X Y S h ⟨Z, f, hf⟩,\n    rcases hro h f with ⟨W, g, k, comm⟩,\n    refine ⟨_, g, _⟩,\n    simp [comm, hf],\n  end,\n  transitive' :=\n  begin\n    rintros X S ⟨Y, f, hf⟩ R h,\n    rcases h hf with ⟨Z, g, hg⟩,\n    exact ⟨_, _, hg⟩,\n  end }\n\nend grothendieck_topology\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/sites/grothendieck.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.709019146082187, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.493447781795211}}
{"text": "/-\nCopyright (c) 2022 Arthur Paulino. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Arthur Paulino\n-/\nimport Mathlib.Tactic.Replace\n\nset_option linter.unusedVariables false\n\n-- tests with a explicitly named hypothesis\n\nexample (h : Int) : Nat := by\n  replace h : Nat := 0\n  exact h\n\nexample (h : Nat) : Nat := by\n  have h : Int := 0\n  assumption -- original `h` is not absent but...\n\nexample (h : Nat) : Nat := by\n  replace h : Int := 0\n  fail_if_success assumption -- original `h` is absent now\n  replace h : Nat := 0\n  exact h\n\n-- tests with `this`\n\nexample : Nat := by\n  have : Int := 0\n  replace : Nat := 0\n  assumption\n\nexample : Nat := by\n  have : Nat := 0\n  have : Int := 0\n  assumption -- original `this` is not absent but...\n\nexample : Nat := by\n  have : Nat := 0\n  replace : Int := 0\n  fail_if_success assumption -- original `this` is absent now\n  replace : Nat := 0\n  assumption\n\n-- trying to replace the type of a variable when the goal depends on it\n\nexample {a : Nat} : a = a := by\n  replace a : Int := 0\n  have : Nat := by assumption -- old `a` is not gone\n  have : Int := by exact a    -- new `a` is of type `Int`\n  simp\n\n-- tests without `:=`, creating a new subgoal\n\nexample (z : Int) : Nat := by\n  replace z : Nat\n  exact 0\n  assumption\n\nexample : True := by\n  have : 1 + 1 = 2 := by simp_arith\n  replace : 2 + 2 = 4\n  simp_arith\n  trivial\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/test/Replace.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.49344777732400774}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module control.traversable.equiv\n! leanprover-community/mathlib commit 706d88f2b8fdfeb0b22796433d7a6c1a010af9f2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Control.Traversable.Lemmas\nimport Mathlib.Logic.Equiv.Defs\n\n/-!\n# Transferring `Traversable` instances along isomorphisms\n\nThis file allows to transfer `Traversable` instances along isomorphisms.\n\n## Main declarations\n\n* `Equiv.map`: Turns functorially a function `α → β` into a function `t' α → t' β` using the functor\n  `t` and the equivalence `Π α, t α ≃ t' α`.\n* `Equiv.functor`: `Equiv.map` as a functor.\n* `Equiv.traverse`: Turns traversably a function `α → m β` into a function `t' α → m (t' β)` using\n  the traversable functor `t` and the equivalence `Π α, t α ≃ t' α`.\n* `Equiv.traversable`: `Equiv.traverse` as a traversable functor.\n* `Equiv.isLawfulTraversable`: `Equiv.traverse` as a lawful traversable functor.\n-/\n\n\nuniverse u\n\nnamespace Equiv\n\nsection Functor\n\n-- Porting note: `parameter` doesn't seem to work yet.\nvariable {t t' : Type u → Type u} (eqv : ∀ α, t α ≃ t' α)\n\nvariable [Functor t]\n\nopen Functor\n\n/-- Given a functor `t`, a function `t' : Type u → Type u`, and\nequivalences `t α ≃ t' α` for all `α`, then every function `α → β` can\nbe mapped to a function `t' α → t' β` functorially (see\n`Equiv.functor`). -/\nprotected def map {α β : Type u} (f : α → β) (x : t' α) : t' β :=\n  eqv β <| map f ((eqv α).symm x)\n#align equiv.map Equiv.map\n\n/-- The function `Equiv.map` transfers the functoriality of `t` to\n`t'` using the equivalences `eqv`.  -/\nprotected def functor : Functor t' where map := Equiv.map eqv\n#align equiv.functor Equiv.functor\n\n-- Porting note: `LawfulFunctor` is missing an `#align`.\nvariable [LawfulFunctor t]\n\nprotected theorem id_map {α : Type u} (x : t' α) : Equiv.map eqv id x = x := by\n  simp [Equiv.map, id_map]\n#align equiv.id_map Equiv.id_map\n\nprotected theorem comp_map {α β γ : Type u} (g : α → β) (h : β → γ) (x : t' α) :\n    Equiv.map eqv (h ∘ g) x = Equiv.map eqv h (Equiv.map eqv g x) := by\n  simp [Equiv.map]; apply comp_map\n#align equiv.comp_map Equiv.comp_map\n\nprotected theorem lawfulFunctor : @LawfulFunctor _ (Equiv.functor eqv) :=\n  -- Porting note: why is `_inst` required here?\n  let _inst := Equiv.functor eqv; {\n    map_const := fun {_ _} => rfl\n    id_map := Equiv.id_map eqv\n    comp_map := Equiv.comp_map eqv }\n#align equiv.is_lawful_functor Equiv.lawfulFunctor\n\nprotected theorem lawfulFunctor' [F : Functor t']\n    (h₀ : ∀ {α β} (f : α → β), Functor.map f = Equiv.map eqv f)\n    (h₁ : ∀ {α β} (f : β), Functor.mapConst f = (Equiv.map eqv ∘ Function.const α) f) :\n    LawfulFunctor t' := by\n  have : F = Equiv.functor eqv := by\n    cases F\n    dsimp [Equiv.functor]\n    congr <;> ext <;> dsimp only <;> [rw [← h₀], rw [← h₁]] <;> rfl\n  subst this\n  exact Equiv.lawfulFunctor eqv\n#align equiv.is_lawful_functor' Equiv.lawfulFunctor'\n\nend Functor\n\nsection Traversable\n\nvariable {t t' : Type u → Type u} (eqv : ∀ α, t α ≃ t' α)\n\nvariable [Traversable t]\n\nvariable {m : Type u → Type u} [Applicative m]\n\nvariable {α β : Type u}\n\n/-- Like `Equiv.map`, a function `t' : Type u → Type u` can be given\nthe structure of a traversable functor using a traversable functor\n`t'` and equivalences `t α ≃ t' α` for all α. See `Equiv.traversable`. -/\nprotected def traverse (f : α → m β) (x : t' α) : m (t' β) :=\n  eqv β <$> traverse f ((eqv α).symm x)\n#align equiv.traverse Equiv.traverse\n\n/-- The function `Equiv.traverse` transfers a traversable functor\ninstance across the equivalences `eqv`. -/\nprotected def traversable : Traversable t' where\n  toFunctor := Equiv.functor eqv\n  traverse := Equiv.traverse eqv\n#align equiv.traversable Equiv.traversable\n\nend Traversable\n\nsection Equiv\n\nvariable {t t' : Type u → Type u} (eqv : ∀ α, t α ≃ t' α)\n\n-- Porting note: The naming `IsLawfulTraversable` seems weird, why not `LawfulTraversable`?\n-- Is this to do with the fact it lives in `Type (u+1)` not `Prop`?\nvariable [Traversable t] [IsLawfulTraversable t]\n\nvariable {F G : Type u → Type u} [Applicative F] [Applicative G]\n\nvariable [LawfulApplicative F] [LawfulApplicative G]\n\nvariable (η : ApplicativeTransformation F G)\n\nvariable {α β γ : Type u}\n\nopen IsLawfulTraversable Functor\n\n-- Porting note: Id.bind_eq is missing an `#align`.\n\nprotected theorem id_traverse (x : t' α) : Equiv.traverse eqv (pure : α → Id α) x = x := by\n  -- Porting note: Changing this `simp` to an `rw` somehow breaks the proof of `comp_traverse`.\n  simp [Equiv.traverse]\n#align equiv.id_traverse Equiv.id_traverse\n\nprotected theorem traverse_eq_map_id (f : α → β) (x : t' α) :\n    Equiv.traverse eqv ((pure : β → Id β) ∘ f) x = pure (Equiv.map eqv f x) := by\n  simp [Equiv.traverse, traverse_eq_map_id, functor_norm]; rfl\n#align equiv.traverse_eq_map_id Equiv.traverse_eq_map_id\n\nprotected theorem comp_traverse (f : β → F γ) (g : α → G β) (x : t' α) :\n    Equiv.traverse eqv (Comp.mk ∘ Functor.map f ∘ g) x =\n      Comp.mk (Equiv.traverse eqv f <$> Equiv.traverse eqv g x) := by\n  simp [Equiv.traverse, comp_traverse, functor_norm]; congr; ext; simp\n#align equiv.comp_traverse Equiv.comp_traverse\n\nprotected theorem naturality (f : α → F β) (x : t' α) :\n    η (Equiv.traverse eqv f x) = Equiv.traverse eqv (@η _ ∘ f) x := by\n  simp only [Equiv.traverse, functor_norm]\n#align equiv.naturality Equiv.naturality\n\n/-- The fact that `t` is a lawful traversable functor carries over the\nequivalences to `t'`, with the traversable functor structure given by\n`Equiv.traversable`. -/\nprotected def isLawfulTraversable : @IsLawfulTraversable t' (Equiv.traversable eqv) :=\n  -- Porting note: Same `_inst` local variable problem.\n  let _inst := Equiv.traversable eqv; {\n    toLawfulFunctor := Equiv.lawfulFunctor eqv\n    id_traverse := Equiv.id_traverse eqv\n    comp_traverse := Equiv.comp_traverse eqv\n    traverse_eq_map_id := Equiv.traverse_eq_map_id eqv\n    naturality := Equiv.naturality eqv }\n#align equiv.is_lawful_traversable Equiv.isLawfulTraversable\n\n/-- If the `Traversable t'` instance has the properties that `map`,\n`map_const`, and `traverse` are equal to the ones that come from\ncarrying the traversable functor structure from `t` over the\nequivalences, then the fact that `t` is a lawful traversable functor\ncarries over as well. -/\nprotected def isLawfulTraversable' [Traversable t']\n    (h₀ : ∀ {α β} (f : α → β), map f = Equiv.map eqv f)\n    (h₁ : ∀ {α β} (f : β), mapConst f = (Equiv.map eqv ∘ Function.const α) f)\n    (h₂ :\n      ∀ {F : Type u → Type u} [Applicative F],\n        ∀ [LawfulApplicative F] {α β} (f : α → F β), traverse f = Equiv.traverse eqv f) :\n    IsLawfulTraversable t' := by\n  -- we can't use the same approach as for `lawful_functor'` because\n  -- h₂ needs a `LawfulApplicative` assumption\n  refine' { toLawfulFunctor := Equiv.lawfulFunctor' eqv @h₀ @h₁.. } <;> intros\n  · rw [h₂, Equiv.id_traverse]\n  · rw [h₂, Equiv.comp_traverse, h₂]\n    congr\n    rw [h₂]\n  · rw [h₂, Equiv.traverse_eq_map_id, h₀]; rfl\n  · rw [h₂, Equiv.naturality, h₂]\n#align equiv.is_lawful_traversable' Equiv.isLawfulTraversable'\n\nend Equiv\n\nend Equiv\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Control/Traversable/Equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334525, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.49344776876574287}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Joseph Myers.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.finset.sort\nimport Mathlib.data.matrix.notation\nimport Mathlib.linear_algebra.affine_space.combination\nimport Mathlib.linear_algebra.basis\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 l \n\nnamespace Mathlib\n\n/-!\n# Affine independence\n\nThis file defines affinely independent families of points.\n\n## Main definitions\n\n* `affine_independent` defines affinely independent families of points\n  as those where no nontrivial weighted subtraction is 0.  This is\n  proved equivalent to two other formulations: linear independence of\n  the results of subtracting a base point in the family from the other\n  points in the family, or any equal affine combinations having the\n  same weights.  A bundled type `simplex` is provided for finite\n  affinely independent families of points, with an abbreviation\n  `triangle` for the case of three points.\n\n## References\n\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\n/-- An indexed family is said to be affinely independent if no\nnontrivial weighted subtractions (where the sum of weights is 0) are\n0. -/\ndef affine_independent (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V]\n    [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) :=\n  ∀ (s : finset ι) (w : ι → k),\n    (finset.sum s fun (i : ι) => w i) = 0 →\n      coe_fn (finset.weighted_vsub s p) w = 0 → ∀ (i : ι), i ∈ s → w i = 0\n\n/-- The definition of `affine_independent`. -/\ntheorem affine_independent_def (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) :\n    affine_independent k p ↔\n        ∀ (s : finset ι) (w : ι → k),\n          (finset.sum s fun (i : ι) => w i) = 0 →\n            coe_fn (finset.weighted_vsub s p) w = 0 → ∀ (i : ι), i ∈ s → w i = 0 :=\n  iff.rfl\n\n/-- A family with at most one point is affinely independent. -/\ntheorem affine_independent_of_subsingleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [subsingleton ι] (p : ι → P) :\n    affine_independent k p :=\n  fun (s : finset ι) (w : ι → k) (h : (finset.sum s fun (i : ι) => w i) = 0)\n    (hs : coe_fn (finset.weighted_vsub s p) w = 0) (i : ι) (hi : i ∈ s) =>\n    fintype.eq_of_subsingleton_of_sum_eq h i hi\n\n/-- A family indexed by a `fintype` is affinely independent if and\nonly if no nontrivial weighted subtractions over `finset.univ` (where\nthe sum of the weights is 0) are 0. -/\ntheorem affine_independent_iff_of_fintype (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [fintype ι] (p : ι → P) :\n    affine_independent k p ↔\n        ∀ (w : ι → k),\n          (finset.sum finset.univ fun (i : ι) => w i) = 0 →\n            coe_fn (finset.weighted_vsub finset.univ p) w = 0 → ∀ (i : ι), w i = 0 :=\n  sorry\n\n/-- A family is affinely independent if and only if the differences\nfrom a base point in that family are linearly independent. -/\ntheorem affine_independent_iff_linear_independent_vsub (k : Type u_1) {V : Type u_2} {P : Type u_3}\n    [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) (i1 : ι) :\n    affine_independent k p ↔\n        linear_independent k fun (i : Subtype fun (x : ι) => x ≠ i1) => p ↑i -ᵥ p i1 :=\n  sorry\n\n/-- A set is affinely independent if and only if the differences from\na base point in that set are linearly independent. -/\ntheorem affine_independent_set_iff_linear_independent_vsub (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P} {p₁ : P}\n    (hp₁ : p₁ ∈ s) :\n    (affine_independent k fun (p : ↥s) => ↑p) ↔\n        linear_independent k fun (v : ↥((fun (p : P) => p -ᵥ p₁) '' (s \\ singleton p₁))) => ↑v :=\n  sorry\n\n/-- A set of nonzero vectors is linearly independent if and only if,\ngiven a point `p₁`, the vectors added to `p₁` and `p₁` itself are\naffinely independent. -/\ntheorem linear_independent_set_iff_affine_independent_vadd_union_singleton (k : Type u_1)\n    {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P]\n    {s : set V} (hs : ∀ (v : V), v ∈ s → v ≠ 0) (p₁ : P) :\n    (linear_independent k fun (v : ↥s) => ↑v) ↔\n        affine_independent k fun (p : ↥(singleton p₁ ∪ (fun (v : V) => v +ᵥ p₁) '' s)) => ↑p :=\n  sorry\n\n/-- A family is affinely independent if and only if any affine\ncombinations (with sum of weights 1) that evaluate to the same point\nhave equal `set.indicator`. -/\ntheorem affine_independent_iff_indicator_eq_of_affine_combination_eq (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    (p : ι → P) :\n    affine_independent k p ↔\n        ∀ (s1 s2 : finset ι) (w1 w2 : ι → k),\n          (finset.sum s1 fun (i : ι) => w1 i) = 1 →\n            (finset.sum s2 fun (i : ι) => w2 i) = 1 →\n              coe_fn (finset.affine_combination s1 p) w1 =\n                  coe_fn (finset.affine_combination s2 p) w2 →\n                set.indicator (↑s1) w1 = set.indicator (↑s2) w2 :=\n  sorry\n\n/-- An affinely independent family is injective, if the underlying\nring is nontrivial. -/\ntheorem injective_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {p : ι → P}\n    (ha : affine_independent k p) : function.injective p :=\n  sorry\n\n/-- If a family is affinely independent, so is any subfamily given by\ncomposition of an embedding into index type with the original\nfamily. -/\ntheorem affine_independent_embedding_of_affine_independent {k : Type u_1} {V : Type u_2}\n    {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    {ι2 : Type u_5} (f : ι2 ↪ ι) {p : ι → P} (ha : affine_independent k p) :\n    affine_independent k (p ∘ ⇑f) :=\n  sorry\n\n/-- If a family is affinely independent, so is any subfamily indexed\nby a subtype of the index type. -/\ntheorem affine_independent_subtype_of_affine_independent {k : Type u_1} {V : Type u_2}\n    {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    {p : ι → P} (ha : affine_independent k p) (s : set ι) :\n    affine_independent k fun (i : ↥s) => p ↑i :=\n  affine_independent_embedding_of_affine_independent\n    (function.embedding.subtype fun (x : ι) => x ∈ s) ha\n\n/-- If an indexed family of points is affinely independent, so is the\ncorresponding set of points. -/\ntheorem affine_independent_set_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3}\n    [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {p : ι → P}\n    (ha : affine_independent k p) : affine_independent k fun (x : ↥(set.range p)) => ↑x :=\n  sorry\n\n/-- If a set of points is affinely independent, so is any subset. -/\ntheorem affine_independent_of_subset_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3}\n    [ring k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P} {t : set P}\n    (ha : affine_independent k fun (x : ↥t) => ↑x) (hs : s ⊆ t) :\n    affine_independent k fun (x : ↥s) => ↑x :=\n  affine_independent_embedding_of_affine_independent (set.embedding_of_subset s t hs) ha\n\n/-- If the range of an injective indexed family of points is affinely\nindependent, so is that family. -/\ntheorem affine_independent_of_affine_independent_set_of_injective {k : Type u_1} {V : Type u_2}\n    {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    {p : ι → P} (ha : affine_independent k fun (x : ↥(set.range p)) => ↑x)\n    (hi : function.injective p) : affine_independent k p :=\n  sorry\n\n/-- If a family is affinely independent, and the spans of points\nindexed by two subsets of the index type have a point in common, those\nsubsets of the index type have an element in common, if the underlying\nring is nontrivial. -/\ntheorem exists_mem_inter_of_exists_mem_inter_affine_span_of_affine_independent {k : Type u_1}\n    {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P]\n    {ι : Type u_4} [nontrivial k] {p : ι → P} (ha : affine_independent k p) {s1 : set ι}\n    {s2 : set ι} {p0 : P} (hp0s1 : p0 ∈ affine_span k (p '' s1))\n    (hp0s2 : p0 ∈ affine_span k (p '' s2)) : ∃ (i : ι), i ∈ s1 ∩ s2 :=\n  sorry\n\n/-- If a family is affinely independent, the spans of points indexed\nby disjoint subsets of the index type are disjoint, if the underlying\nring is nontrivial. -/\ntheorem affine_span_disjoint_of_disjoint_of_affine_independent {k : Type u_1} {V : Type u_2}\n    {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    [nontrivial k] {p : ι → P} (ha : affine_independent k p) {s1 : set ι} {s2 : set ι}\n    (hd : s1 ∩ s2 = ∅) : ↑(affine_span k (p '' s1)) ∩ ↑(affine_span k (p '' s2)) = ∅ :=\n  sorry\n\n/-- If a family is affinely independent, a point in the family is in\nthe span of some of the points given by a subset of the index type if\nand only if that point's index is in the subset, if the underlying\nring is nontrivial. -/\n@[simp] theorem mem_affine_span_iff_mem_of_affine_independent {k : Type u_1} {V : Type u_2}\n    {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    [nontrivial k] {p : ι → P} (ha : affine_independent k p) (i : ι) (s : set ι) :\n    p i ∈ affine_span k (p '' s) ↔ i ∈ s :=\n  sorry\n\n/-- If a family is affinely independent, a point in the family is not\nin the affine span of the other points, if the underlying ring is\nnontrivial. -/\ntheorem not_mem_affine_span_diff_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3}\n    [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k]\n    {p : ι → P} (ha : affine_independent k p) (i : ι) (s : set ι) :\n    ¬p i ∈ affine_span k (p '' (s \\ singleton i)) :=\n  sorry\n\n/-- An affinely independent set of points can be extended to such a\nset that spans the whole space. -/\ntheorem exists_subset_affine_independent_affine_span_eq_top {k : Type u_1} {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P}\n    (h : affine_independent k fun (p : ↥s) => ↑p) :\n    ∃ (t : set P), s ⊆ t ∧ (affine_independent k fun (p : ↥t) => ↑p) ∧ affine_span k t = ⊤ :=\n  sorry\n\n/-- Two different points are affinely independent. -/\ntheorem affine_independent_of_ne (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] {p₁ : P} {p₂ : P} (h : p₁ ≠ p₂) :\n    affine_independent k (matrix.vec_cons p₁ (matrix.vec_cons p₂ matrix.vec_empty)) :=\n  sorry\n\nnamespace affine\n\n\n/-- A `simplex k P n` is a collection of `n + 1` affinely\nindependent points. -/\nstructure simplex (k : Type u_1) {V : Type u_2} (P : Type u_3) [ring k] [add_comm_group V]\n    [module k V] [add_torsor V P] (n : ℕ)\n    where\n  points : fin (n + 1) → P\n  independent : affine_independent k points\n\n/-- A `triangle k P` is a collection of three affinely independent points. -/\ndef triangle (k : Type u_1) {V : Type u_2} (P : Type u_3) [ring k] [add_comm_group V] [module k V]\n    [add_torsor V P] :=\n  simplex k P (bit0 1)\n\nnamespace simplex\n\n\n/-- Construct a 0-simplex from a point. -/\ndef mk_of_point (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V]\n    [module k V] [add_torsor V P] (p : P) : simplex k P 0 :=\n  mk (fun (_x : fin (0 + 1)) => p) sorry\n\n/-- The point in a simplex constructed with `mk_of_point`. -/\n@[simp] theorem mk_of_point_points (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] (p : P) (i : fin 1) :\n    points (mk_of_point k p) i = p :=\n  rfl\n\nprotected instance inhabited (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] [Inhabited P] : Inhabited (simplex k P 0) :=\n  { default := mk_of_point k Inhabited.default }\n\nprotected instance nonempty (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V]\n    [module k V] [add_torsor V P] : Nonempty (simplex k P 0) :=\n  Nonempty.intro (mk_of_point k (nonempty.some add_torsor.nonempty))\n\n/-- Two simplices are equal if they have the same points. -/\ntheorem ext {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V]\n    [add_torsor V P] {n : ℕ} {s1 : simplex k P n} {s2 : simplex k P n}\n    (h : ∀ (i : fin (n + 1)), points s1 i = points s2 i) : s1 = s2 :=\n  sorry\n\n/-- Two simplices are equal if and only if they have the same points. -/\ntheorem ext_iff {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V]\n    [module k V] [add_torsor V P] {n : ℕ} (s1 : simplex k P n) (s2 : simplex k P n) :\n    s1 = s2 ↔ ∀ (i : fin (n + 1)), points s1 i = points s2 i :=\n  { mp := fun (h : s1 = s2) (_x : fin (n + 1)) => h ▸ rfl, mpr := ext }\n\n/-- A face of a simplex is a simplex with the given subset of\npoints. -/\ndef face {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V]\n    [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ}\n    (h : finset.card fs = m + 1) : simplex k P m :=\n  mk (points s ∘ ⇑(finset.order_emb_of_fin fs h)) sorry\n\n/-- The points of a face of a simplex are given by `mono_of_fin`. -/\ntheorem face_points {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V]\n    [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ}\n    (h : finset.card fs = m + 1) (i : fin (m + 1)) :\n    points (face s h) i = points s (coe_fn (finset.order_emb_of_fin fs h) i) :=\n  rfl\n\n/-- The points of a face of a simplex are given by `mono_of_fin`. -/\ntheorem face_points' {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V]\n    [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ}\n    (h : finset.card fs = m + 1) : points (face s h) = points s ∘ ⇑(finset.order_emb_of_fin fs h) :=\n  rfl\n\n/-- A single-point face equals the 0-simplex constructed with\n`mk_of_point`. -/\n@[simp] theorem face_eq_mk_of_point {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) (i : fin (n + 1)) :\n    face s (finset.card_singleton i) = mk_of_point k (points s i) :=\n  sorry\n\n/-- The set of points of a face. -/\n@[simp] theorem range_face_points {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n)\n    {fs : finset (fin (n + 1))} {m : ℕ} (h : finset.card fs = m + 1) :\n    set.range (points (face s h)) = points s '' ↑fs :=\n  sorry\n\nend simplex\n\n\nend affine\n\n\nnamespace affine\n\n\nnamespace simplex\n\n\n/-- The centroid of a face of a simplex as the centroid of a subset of\nthe points. -/\n@[simp] theorem face_centroid_eq_centroid {k : Type u_1} {V : Type u_2} {P : Type u_3}\n    [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n)\n    {fs : finset (fin (n + 1))} {m : ℕ} (h : finset.card fs = m + 1) :\n    finset.centroid k finset.univ (points (face s h)) = finset.centroid k fs (points s) :=\n  sorry\n\n/-- Over a characteristic-zero division ring, the centroids given by\ntwo subsets of the points of a simplex are equal if and only if those\nfaces are given by the same subset of points. -/\n@[simp] theorem centroid_eq_iff {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] [char_zero k] {n : ℕ} (s : simplex k P n)\n    {fs₁ : finset (fin (n + 1))} {fs₂ : finset (fin (n + 1))} {m₁ : ℕ} {m₂ : ℕ}\n    (h₁ : finset.card fs₁ = m₁ + 1) (h₂ : finset.card fs₂ = m₂ + 1) :\n    finset.centroid k fs₁ (points s) = finset.centroid k fs₂ (points s) ↔ fs₁ = fs₂ :=\n  sorry\n\n/-- Over a characteristic-zero division ring, the centroids of two\nfaces of a simplex are equal if and only if those faces are given by\nthe same subset of points. -/\ntheorem face_centroid_eq_iff {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] [char_zero k] {n : ℕ} (s : simplex k P n)\n    {fs₁ : finset (fin (n + 1))} {fs₂ : finset (fin (n + 1))} {m₁ : ℕ} {m₂ : ℕ}\n    (h₁ : finset.card fs₁ = m₁ + 1) (h₂ : finset.card fs₂ = m₂ + 1) :\n    finset.centroid k finset.univ (points (face s h₁)) =\n          finset.centroid k finset.univ (points (face s h₂)) ↔\n        fs₁ = fs₂ :=\n  sorry\n\n/-- Two simplices with the same points have the same centroid. -/\ntheorem centroid_eq_of_range_eq {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k]\n    [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} {s₁ : simplex k P n}\n    {s₂ : simplex k P n} (h : set.range (points s₁) = set.range (points s₂)) :\n    finset.centroid k finset.univ (points s₁) = finset.centroid k finset.univ (points s₂) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/affine_space/independent_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4934477644866104}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport algebra.big_operators.order\nimport algebra.big_operators.ring\nimport algebra.char_zero.lemmas\nimport data.rat.cast\n\n/-!\n# The Oxford Invariants Puzzle Challenges - Summer 2021, Week 3, Problem 1\n\n## Original statement\n\nLet `n ≥ 3`, `a₁, ..., aₙ` be strictly positive integers such that `aᵢ ∣ aᵢ₋₁ + aᵢ₊₁` for\n`i = 2, ..., n - 1`. Show that $\\sum_{i=1}^{n-1}\\dfrac{a_0a_n}{a_ia_{i+1}} ∈ \\mathbb N$.\n\n## Comments\n\nMathlib is based on type theory, so saying that a rational is a natural doesn't make sense. Instead,\nwe ask that there exists `b : ℕ` whose cast to `α` is the sum we want.\n\nIn mathlib, `ℕ` starts at `0`. To make the indexing cleaner, we use `a₀, ..., aₙ₋₁` instead of\n`a₁, ..., aₙ`. Similarly, it's nicer to not use subtraction of naturals, so we replace\n`aᵢ ∣ aᵢ₋₁ + aᵢ₊₁` by `aᵢ₊₁ ∣ aᵢ + aᵢ₊₂`.\n\nWe don't actually have to work in `ℚ` or `ℝ`. We can be even more general by stating the result for\nany linearly ordered field.\n\nInstead of having `n` naturals, we use a function `a : ℕ → ℕ`.\n\nIn the proof itself, we replace `n : ℕ, 1 ≤ n` by `n + 1`.\n\nThe statement is actually true for `n = 0, 1` (`n = 1, 2` before the reindexing) as the sum is\nsimply `0` and `1` respectively. So the version we prove is slightly more general.\n\nOverall, the indexing is a bit of a mess to understand. But, trust Lean, it works.\n\n## Formalised statement\n\nLet `n : ℕ`, `a : ℕ → ℕ`, `∀ i ≤ n, 0 < a i`, `∀ i, i + 2 ≤ n → aᵢ₊₁ ∣ aᵢ + aᵢ₊₂` (read `→` as\n\"implies\"). Then there exists `b : ℕ` such that `b` as an element of any linearly ordered field\nequals $\\sum_{i=0}^{n-1} (a_0 a_n) / (a_i a_{i+1})$.\n\n## Proof outline\n\nThe case `n = 0` is trivial.\n\nFor `n + 1`, we prove the result by induction but by adding `aₙ₊₁ ∣ aₙ * b - a₀` to the induction\nhypothesis, where `b` is the previous sum, $\\sum_{i=0}^{n-1} (a_0 a_n) / (a_i a_{i+1})$, as a\nnatural.\n* Base case:\n  * $\\sum_{i=0}^0 (a_0 a_{0+1}) / (a_0 a_{0+1})$ is a natural:\n    $\\sum_{i=0}^0 (a_0 a_{0+1}) / (a_0 a_{0+1}) = (a_0 a_1) / (a_0 a_1) = 1$.\n  * Divisibility condition:\n    `a₀ * 1 - a₀ = 0` is clearly divisible by `a₁`.\n* Induction step:\n  * $\\sum_{i=0}^n (a_0 a_{n+1}) / (a_i a_{i+1})$ is a natural:\n    $$\\sum_{i=0}^{n+1} (a_0 a_{n+2}) / (a_i a_{i+1})\n      = \\sum_{i=0}^n\\ (a_0 a_{n+2}) / (a_i a_{i+1}) + (a_0 a_{n+2}) / (a_{n+1} a_{n+2})\n      = a_{n+2} / a_{n+1} × \\sum_{i=0}^n (a_0 a_{n+1}) / (a_i a_{i+1}) + a_0 / a_{n+1}\n      = a_{n+2} / a_{n+1} × b + a_0 / a_{n+1}\n      = (a_n + a_{n+2}) / a_{n+1} × b - (a_n b - a_0)(a_{n+1})$$\n    which is a natural because `(aₙ + aₙ₊₂)/aₙ₊₁`, `b` and `(aₙ * b - a₀)/aₙ₊₁` are (plus an\n    annoying inequality, or the fact that the original sum is positive because its terms are).\n  * Divisibility condition:\n    `aₙ₊₁ * ((aₙ + aₙ₊₂)/aₙ₊₁ * b - (aₙ * b - a₀)/aₙ₊₁) - a₀ = aₙ₊₁aₙ₊₂b` is divisible by `aₙ₊₂`.\n-/\n\nopen_locale big_operators\n\nvariables {α : Type*} [linear_ordered_field α]\n\ntheorem week3_p1 (n : ℕ) (a : ℕ → ℕ) (a_pos : ∀ i ≤ n, 0 < a i)\n  (ha : ∀ i, i + 2 ≤ n → a (i + 1) ∣ a i + a (i + 2)) :\n  ∃ b : ℕ, (b : α) = ∑ i in finset.range n, (a 0 * a n)/(a i * a (i + 1)) :=\nbegin\n  -- Treat separately `n = 0` and `n ≥ 1`\n  cases n,\n  /- Case `n = 0`\n  The sum is trivially equal to `0` -/\n  { exact ⟨0, by rw [nat.cast_zero, finset.sum_range_zero]⟩ }, -- `⟨Claim it, Prove it⟩`\n  /- Case `n ≥ 1`. We replace `n` by `n + 1` everywhere to make this inequality explicit\n  Set up the stronger induction hypothesis -/\n  rsuffices ⟨b, hb, -⟩ :\n    ∃ b : ℕ, (b : α) = ∑ i in finset.range (n + 1), (a 0 * a (n + 1)) / (a i * a (i + 1))\n    ∧ a (n + 1) ∣ a n * b - a 0,\n  { exact ⟨b, hb⟩ },\n  simp_rw ←@nat.cast_pos α at a_pos,\n  /- Declare the induction\n  `ih` will be the induction hypothesis -/\n  induction n with n ih,\n  /- Base case\n  Claim that the sum equals `1`-/\n  { refine ⟨1, _, _⟩,\n    -- Check that this indeed equals the sum\n    { rw [nat.cast_one, finset.sum_range_one, div_self],\n      exact (mul_pos (a_pos 0 (nat.zero_le _)) (a_pos 1 (nat.zero_lt_succ _))).ne' },\n    -- Check the divisibility condition\n    { rw [mul_one, tsub_self],\n      exact dvd_zero _ } },\n  /- Induction step\n  `b` is the value of the previous sum as a natural, `hb` is the proof that it is indeed the value,\n  and `han` is the divisibility condition -/\n  obtain ⟨b, hb, han⟩ := ih (λ i hi, ha i $ nat.le_succ_of_le hi)\n    (λ i hi, a_pos i $ nat.le_succ_of_le hi),\n  specialize ha n le_rfl,\n  have ha₀ : a 0 ≤ a n * b, -- Needing this is an artifact of `ℕ`-subtraction.\n  { rw [←@nat.cast_le α, nat.cast_mul, hb, ←div_le_iff' (a_pos _ $ n.le_succ.trans $ nat.le_succ _),\n      ←mul_div_mul_right _ _ (a_pos _ $ nat.le_succ _).ne'],\n    suffices h : ∀ i, i ∈ finset.range (n + 1) → 0 ≤ (a 0 : α) * a (n + 1) / (a i * a (i + 1)),\n    { exact finset.single_le_sum h (finset.self_mem_range_succ n) },\n    refine (λ i _, div_nonneg _ _); refine mul_nonneg _ _; exact nat.cast_nonneg _ },\n  -- Claim that the sum equals `(aₙ + aₙ₊₂)/aₙ₊₁ * b - (aₙ * b - a₀)/aₙ₊₁`\n  refine ⟨(a n + a (n + 2))/ a (n + 1) * b - (a n * b - a 0) / a (n + 1), _, _⟩,\n  -- Check that this indeed equals the sum\n  { calc\n      (((a n + a (n + 2)) / a (n + 1) * b - (a n * b - a 0) / a (n + 1) : ℕ) : α)\n        = (a n + a (n + 2)) / a (n + 1) * b - (a n * b - a 0) / a (n + 1) : begin\n          norm_cast,\n          rw nat.cast_sub (nat.div_le_of_le_mul _),\n          rw [←mul_assoc, nat.mul_div_cancel' ha, add_mul],\n          exact tsub_le_self.trans (nat.le_add_right _ _),\n        end\n    ... = a (n + 2) / a (n + 1) * b + (a 0 * a (n + 2)) / (a (n + 1) * a (n + 2))\n        : by rw [add_div, add_mul, sub_div, mul_div_right_comm, add_sub_sub_cancel,\n            mul_div_mul_right _ _ (a_pos _ le_rfl).ne']\n    ... = ∑ (i : ℕ) in finset.range (n + 2), a 0 * a (n + 2) / (a i * a (i + 1))\n        : begin\n          rw [finset.sum_range_succ, hb, finset.mul_sum],\n          congr, ext i,\n          rw [←mul_div_assoc, ←mul_div_right_comm, mul_div_assoc, mul_div_cancel _\n            (a_pos _ $ nat.le_succ _).ne', mul_comm],\n        end },\n  -- Check the divisibility condition\n  { rw [mul_tsub, ← mul_assoc, nat.mul_div_cancel' ha, add_mul,\n      nat.mul_div_cancel' han, add_tsub_tsub_cancel ha₀, add_tsub_cancel_right],\n    exact dvd_mul_right _ _ }\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/archive/oxford_invariants/2021summer/week3_p1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.4934477642945396}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport algebra.hom.equiv.basic\nimport data.part\nimport data.enat.lattice\nimport tactic.norm_num\n\n/-!\n# Natural numbers with infinity\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe natural numbers and an extra `top` element `⊤`. This implementation uses `part ℕ` as an\nimplementation. Use `ℕ∞` instead unless you care about computability.\n\n## Main definitions\n\nThe following instances are defined:\n\n* `ordered_add_comm_monoid part_enat`\n* `canonically_ordered_add_monoid part_enat`\n* `complete_linear_order part_enat`\n\nThere is no additive analogue of `monoid_with_zero`; if there were then `part_enat` could\nbe an `add_monoid_with_top`.\n\n* `to_with_top` : the map from `part_enat` to `ℕ∞`, with theorems that it plays well\nwith `+` and `≤`.\n\n* `with_top_add_equiv : part_enat ≃+ ℕ∞`\n* `with_top_order_iso : part_enat ≃o ℕ∞`\n\n## Implementation details\n\n`part_enat` is defined to be `part ℕ`.\n\n`+` and `≤` are defined on `part_enat`, but there is an issue with `*` because it's not\nclear what `0 * ⊤` should be. `mul` is hence left undefined. Similarly `⊤ - ⊤` is ambiguous\nso there is no `-` defined on `part_enat`.\n\nBefore the `open_locale classical` line, various proofs are made with decidability assumptions.\nThis can cause issues -- see for example the non-simp lemma `to_with_top_zero` proved by `rfl`,\nfollowed by `@[simp] lemma to_with_top_zero'` whose proof uses `convert`.\n\n\n## Tags\n\npart_enat, ℕ∞\n-/\nopen part (hiding some)\n\n/-- Type of natural numbers with infinity (`⊤`) -/\ndef part_enat : Type := part ℕ\n\nnamespace part_enat\n\n/-- The computable embedding `ℕ → part_enat`.\n\nThis coincides with the coercion `coe : ℕ → part_enat`, see `part_enat.some_eq_coe`.\nHowever, `coe` is noncomputable so `some` is preferable when computability is a concern. -/\ndef some : ℕ → part_enat := part.some\n\ninstance : has_zero part_enat := ⟨some 0⟩\ninstance : inhabited part_enat := ⟨0⟩\ninstance : has_one part_enat := ⟨some 1⟩\ninstance : has_add part_enat := ⟨λ x y, ⟨x.dom ∧ y.dom, λ h, get x h.1 + get y h.2⟩⟩\n\ninstance (n : ℕ) : decidable (some n).dom := is_true trivial\n\n@[simp] lemma dom_some (x : ℕ) : (some x).dom := trivial\n\ninstance : add_comm_monoid part_enat :=\n{ add       := (+),\n  zero      := (0),\n  add_comm  := λ x y, part.ext' and.comm (λ _ _, add_comm _ _),\n  zero_add  := λ x, part.ext' (true_and _) (λ _ _, zero_add _),\n  add_zero  := λ x, part.ext' (and_true _) (λ _ _, add_zero _),\n  add_assoc := λ x y z, part.ext' and.assoc (λ _ _, add_assoc _ _ _) }\n\ninstance : add_comm_monoid_with_one part_enat :=\n{ one := 1,\n  nat_cast := some,\n  nat_cast_zero := rfl,\n  nat_cast_succ := λ _, part.ext' (true_and _).symm (λ _ _, rfl),\n  .. part_enat.add_comm_monoid }\n\nlemma some_eq_coe (n : ℕ) : some n = n := rfl\n\n@[simp, norm_cast] lemma coe_inj {x y : ℕ} : (x : part_enat) = y ↔ x = y := part.some_inj\n\n@[simp] \n\ninstance : can_lift part_enat ℕ coe dom := ⟨λ n hn, ⟨n.get hn, part.some_get _⟩⟩\n\ninstance : has_le part_enat := ⟨λ x y, ∃ h : y.dom → x.dom, ∀ hy : y.dom, x.get (h hy) ≤ y.get hy⟩\ninstance : has_top part_enat := ⟨none⟩\ninstance : has_bot part_enat := ⟨0⟩\ninstance : has_sup part_enat := ⟨λ x y, ⟨x.dom ∧ y.dom, λ h, x.get h.1 ⊔ y.get h.2⟩⟩\n\nlemma le_def (x y : part_enat) :\n  x ≤ y ↔ ∃ h : y.dom → x.dom, ∀ hy : y.dom, x.get (h hy) ≤ y.get hy :=\niff.rfl\n\n@[elab_as_eliminator] protected lemma cases_on' {P : part_enat → Prop} :\n  ∀ a : part_enat, P ⊤ → (∀ n : ℕ, P (some n)) → P a :=\npart.induction_on\n\n@[elab_as_eliminator] protected lemma cases_on {P : part_enat → Prop} :\n  ∀ a : part_enat, P ⊤ → (∀ n : ℕ, P n) → P a :=\nby { simp only [← some_eq_coe], exact part_enat.cases_on' }\n\n@[simp] lemma top_add (x : part_enat) : ⊤ + x = ⊤ :=\npart.ext' (false_and _) (λ h, h.left.elim)\n\n@[simp] lemma add_top (x : part_enat) : x + ⊤ = ⊤ :=\nby rw [add_comm, top_add]\n\n@[simp] lemma coe_get {x : part_enat} (h : x.dom) : (x.get h : part_enat) = x :=\nby { rw [← some_eq_coe], exact part.ext' (iff_of_true trivial h) (λ _ _, rfl) }\n\n@[simp, norm_cast] lemma get_coe' (x : ℕ) (h : (x : part_enat).dom) : get (x : part_enat) h = x :=\nby rw [← coe_inj, coe_get]\n\nlemma get_coe {x : ℕ} : get (x : part_enat) (dom_coe x) = x := get_coe' _ _\n\nlemma coe_add_get {x : ℕ} {y : part_enat} (h : ((x : part_enat) + y).dom) :\n  get ((x : part_enat) + y) h = x + get y h.2 :=\nby { simp only [← some_eq_coe] at h ⊢, refl }\n\n@[simp] lemma get_add {x y : part_enat} (h : (x + y).dom) :\n  get (x + y) h = x.get h.1 + y.get h.2 := rfl\n\n@[simp] lemma get_zero (h : (0 : part_enat).dom) : (0 : part_enat).get h = 0 := rfl\n\n@[simp] lemma get_one (h : (1 : part_enat).dom) : (1 : part_enat).get h = 1 := rfl\n\nlemma get_eq_iff_eq_some {a : part_enat} {ha : a.dom} {b : ℕ} :\n  a.get ha = b ↔ a = some b := get_eq_iff_eq_some\n\nlemma get_eq_iff_eq_coe {a : part_enat} {ha : a.dom} {b : ℕ} :\n  a.get ha = b ↔ a = b := by rw [get_eq_iff_eq_some, some_eq_coe]\n\nlemma dom_of_le_of_dom {x y : part_enat} : x ≤ y → y.dom → x.dom := λ ⟨h, _⟩, h\n\nlemma dom_of_le_some {x : part_enat} {y : ℕ} (h : x ≤ some y) : x.dom := dom_of_le_of_dom h trivial\n\nlemma dom_of_le_coe {x : part_enat} {y : ℕ} (h : x ≤ y) : x.dom :=\nby { rw [← some_eq_coe] at h, exact dom_of_le_some h }\n\ninstance decidable_le (x y : part_enat) [decidable x.dom] [decidable y.dom] : decidable (x ≤ y) :=\nif hx : x.dom\nthen decidable_of_decidable_of_iff\n  (show decidable (∀ (hy : (y : part_enat).dom), x.get hx ≤ (y : part_enat).get hy),\n    from forall_prop_decidable _) $\n  by { dsimp [(≤)], simp only [hx, exists_prop_of_true, forall_true_iff] }\nelse if hy : y.dom\nthen is_false $ λ h, hx $ dom_of_le_of_dom h hy\nelse is_true ⟨λ h, (hy h).elim, λ h, (hy h).elim⟩\n\n/-- The coercion `ℕ → part_enat` preserves `0` and addition. -/\ndef coe_hom : ℕ →+ part_enat := ⟨coe, nat.cast_zero, nat.cast_add⟩\n\n@[simp] lemma coe_coe_hom : ⇑coe_hom = coe := rfl\n\ninstance : partial_order part_enat :=\n{ le          := (≤),\n  le_refl     := λ x, ⟨id, λ _, le_rfl⟩,\n  le_trans    := λ x y z ⟨hxy₁, hxy₂⟩ ⟨hyz₁, hyz₂⟩,\n    ⟨hxy₁ ∘ hyz₁, λ _, le_trans (hxy₂ _) (hyz₂ _)⟩,\n  le_antisymm := λ x y ⟨hxy₁, hxy₂⟩ ⟨hyx₁, hyx₂⟩, part.ext' ⟨hyx₁, hxy₁⟩\n    (λ _ _, le_antisymm (hxy₂ _) (hyx₂ _)) }\n\nlemma lt_def (x y : part_enat) : x < y ↔ ∃ (hx : x.dom), ∀ (hy : y.dom), x.get hx < y.get hy :=\nbegin\n  rw [lt_iff_le_not_le, le_def, le_def, not_exists],\n  split,\n  { rintro ⟨⟨hyx, H⟩, h⟩,\n    by_cases hx : x.dom,\n    { use hx, intro hy,\n      specialize H hy, specialize h (λ _, hy),\n      rw not_forall at h, cases h with hx' h,\n      rw not_le at h, exact h },\n    { specialize h (λ hx', (hx hx').elim),\n      rw not_forall at h, cases h with hx' h,\n      exact (hx hx').elim } },\n  { rintro ⟨hx, H⟩, exact ⟨⟨λ _, hx, λ hy, (H hy).le⟩, λ hxy h, not_lt_of_le (h _) (H _)⟩ }\nend\n\n@[simp, norm_cast] lemma coe_le_coe {x y : ℕ} : (x : part_enat) ≤ y ↔ x ≤ y :=\nby { rw [← some_eq_coe, ← some_eq_coe], exact ⟨λ ⟨_, h⟩, h trivial, λ h, ⟨λ _, trivial, λ _, h⟩⟩ }\n\n@[simp, norm_cast] lemma coe_lt_coe {x y : ℕ} : (x : part_enat) < y ↔ x < y :=\nby rw [lt_iff_le_not_le, lt_iff_le_not_le, coe_le_coe, coe_le_coe]\n\n@[simp] lemma get_le_get {x y : part_enat} {hx : x.dom} {hy : y.dom} :\n  x.get hx ≤ y.get hy ↔ x ≤ y :=\nby conv { to_lhs, rw [← coe_le_coe, coe_get, coe_get]}\n\nlemma le_coe_iff (x : part_enat) (n : ℕ) : x ≤ n ↔ ∃ h : x.dom, x.get h ≤ n :=\nbegin\n  rw [← some_eq_coe],\n  show (∃ (h : true → x.dom), _) ↔ ∃ h : x.dom, x.get h ≤ n,\n  simp only [forall_prop_of_true, some_eq_coe, dom_coe, get_coe']\nend\n\nlemma lt_coe_iff (x : part_enat) (n : ℕ) : x < n ↔ ∃ h : x.dom, x.get h < n :=\nby simp only [lt_def, forall_prop_of_true, get_coe', dom_coe]\n\nlemma coe_le_iff (n : ℕ) (x : part_enat) : (n : part_enat) ≤ x ↔ ∀ h : x.dom, n ≤ x.get h :=\nbegin\n  rw [← some_eq_coe],\n  simp only [le_def, exists_prop_of_true, dom_some, forall_true_iff],\n  refl,\nend\n\nlemma coe_lt_iff (n : ℕ) (x : part_enat) : (n : part_enat) < x ↔ ∀ h : x.dom, n < x.get h :=\nbegin\n  rw [← some_eq_coe],\n  simp only [lt_def, exists_prop_of_true, dom_some, forall_true_iff],\n  refl,\nend\n\ninstance ne_zero.one : ne_zero (1 : part_enat) := ⟨coe_inj.not.mpr dec_trivial⟩\n\ninstance semilattice_sup : semilattice_sup part_enat :=\n{ sup := (⊔),\n  le_sup_left := λ _ _, ⟨and.left, λ _, le_sup_left⟩,\n  le_sup_right := λ _ _, ⟨and.right, λ _, le_sup_right⟩,\n  sup_le := λ x y z ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩, ⟨λ hz, ⟨hx₁ hz, hy₁ hz⟩,\n    λ _, sup_le (hx₂ _) (hy₂ _)⟩,\n  ..part_enat.partial_order }\n\ninstance order_bot : order_bot part_enat :=\n{ bot := (⊥),\n  bot_le := λ _, ⟨λ _, trivial, λ _, nat.zero_le _⟩ }\n\ninstance order_top : order_top part_enat :=\n{ top := (⊤),\n  le_top := λ x, ⟨λ h, false.elim h, λ hy, false.elim hy⟩ }\n\nlemma eq_zero_iff {x : part_enat} : x = 0 ↔ x ≤ 0 := eq_bot_iff\nlemma ne_zero_iff {x : part_enat} : x ≠ 0 ↔ ⊥ < x := bot_lt_iff_ne_bot.symm\n\nlemma dom_of_lt {x y : part_enat} : x < y → x.dom :=\npart_enat.cases_on x not_top_lt $ λ _ _, dom_coe _\n\nlemma top_eq_none : (⊤ : part_enat) = none := rfl\n\n@[simp] lemma coe_lt_top (x : ℕ) : (x : part_enat) < ⊤ :=\nne.lt_top (λ h, absurd (congr_arg dom h) $ by simpa only [dom_coe] using true_ne_false)\n\n@[simp] lemma coe_ne_top (x : ℕ) : (x : part_enat) ≠ ⊤ := ne_of_lt (coe_lt_top x)\n\nlemma not_is_max_coe (x : ℕ) : ¬ is_max (x : part_enat) :=\nnot_is_max_of_lt (coe_lt_top x)\n\nlemma ne_top_iff {x : part_enat} : x ≠ ⊤ ↔ ∃ (n : ℕ), x = n :=\nby simpa only [← some_eq_coe] using part.ne_none_iff\n\nlemma ne_top_iff_dom {x : part_enat} : x ≠ ⊤ ↔ x.dom :=\nby classical; exact not_iff_comm.1 part.eq_none_iff'.symm\n\nlemma not_dom_iff_eq_top {x : part_enat} : ¬ x.dom ↔ x = ⊤ :=\niff.not_left ne_top_iff_dom.symm\n\nlemma ne_top_of_lt {x y : part_enat} (h : x < y) : x ≠ ⊤ :=\nne_of_lt $ lt_of_lt_of_le h le_top\n\nlemma eq_top_iff_forall_lt (x : part_enat) : x = ⊤ ↔ ∀ n : ℕ, (n : part_enat) < x :=\nbegin\n  split,\n  { rintro rfl n, exact coe_lt_top _ },\n  { contrapose!, rw ne_top_iff, rintro ⟨n, rfl⟩, exact ⟨n, irrefl _⟩ }\nend\n\nlemma eq_top_iff_forall_le (x : part_enat) : x = ⊤ ↔ ∀ n : ℕ, (n : part_enat) ≤ x :=\n(eq_top_iff_forall_lt x).trans\n⟨λ h n, (h n).le, λ h n, lt_of_lt_of_le (coe_lt_coe.mpr n.lt_succ_self) (h (n + 1))⟩\n\nlemma pos_iff_one_le {x : part_enat} : 0 < x ↔ 1 ≤ x :=\npart_enat.cases_on x (by simp only [iff_true, le_top, coe_lt_top, ← @nat.cast_zero part_enat]) $\n  λ n, by { rw [← nat.cast_zero, ← nat.cast_one, part_enat.coe_lt_coe, part_enat.coe_le_coe], refl }\n\ninstance : is_total part_enat (≤) :=\n{ total := λ x y, part_enat.cases_on x\n    (or.inr le_top) (part_enat.cases_on y (λ _, or.inl le_top)\n      (λ x y, (le_total x y).elim (or.inr ∘ coe_le_coe.2)\n        (or.inl ∘ coe_le_coe.2))) }\n\nnoncomputable instance : linear_order part_enat :=\n{ le_total := is_total.total,\n  decidable_le := classical.dec_rel _,\n  max := (⊔),\n  max_def := @sup_eq_max_default _ _ (id _) _,\n  ..part_enat.partial_order }\n\ninstance : bounded_order part_enat :=\n{ ..part_enat.order_top,\n  ..part_enat.order_bot }\n\nnoncomputable instance : lattice part_enat :=\n{ inf := min,\n  inf_le_left := min_le_left,\n  inf_le_right := min_le_right,\n  le_inf := λ _ _ _, le_min,\n  ..part_enat.semilattice_sup }\n\ninstance : ordered_add_comm_monoid part_enat :=\n{ add_le_add_left := λ a b ⟨h₁, h₂⟩ c,\n    part_enat.cases_on c (by simp)\n      (λ c, ⟨λ h, and.intro (dom_coe _) (h₁ h.2),\n        λ h, by simpa only [coe_add_get] using add_le_add_left (h₂ _) c⟩),\n  ..part_enat.linear_order,\n  ..part_enat.add_comm_monoid }\n\ninstance : canonically_ordered_add_monoid part_enat :=\n{ le_self_add := λ a b, part_enat.cases_on b (le_top.trans_eq (add_top _).symm) $\n    λ b, part_enat.cases_on a (top_add _).ge $\n      λ a, (coe_le_coe.2 le_self_add).trans_eq (nat.cast_add _ _),\n  exists_add_of_le := λ a b, part_enat.cases_on b (λ _, ⟨⊤, (add_top _).symm⟩) $\n    λ b, part_enat.cases_on a (λ h, ((coe_lt_top _).not_le h).elim) $ λ a h, ⟨(b - a : ℕ),\n        by rw [←nat.cast_add, coe_inj, add_comm, tsub_add_cancel_of_le (coe_le_coe.1 h)]⟩,\n  ..part_enat.semilattice_sup,\n  ..part_enat.order_bot,\n  ..part_enat.ordered_add_comm_monoid }\n\nlemma eq_coe_sub_of_add_eq_coe {x y : part_enat} {n : ℕ} (h : x + y = n) :\n  x = ↑(n - y.get (dom_of_le_coe ((le_add_left le_rfl).trans_eq h))) :=\nbegin\n  lift x to ℕ using dom_of_le_coe ((le_add_right le_rfl).trans_eq h),\n  lift y to ℕ using dom_of_le_coe ((le_add_left le_rfl).trans_eq h),\n  rw [← nat.cast_add, coe_inj] at h,\n  rw [get_coe, coe_inj, eq_tsub_of_add_eq h]\nend\n\nprotected lemma add_lt_add_right {x y z : part_enat} (h : x < y) (hz : z ≠ ⊤) : x + z < y + z :=\nbegin\n  rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩,\n  rcases ne_top_iff.mp hz with ⟨k, rfl⟩,\n  induction y using part_enat.cases_on with n,\n  { rw [top_add], apply_mod_cast coe_lt_top },\n  norm_cast at h, apply_mod_cast add_lt_add_right h\nend\n\nprotected lemma add_lt_add_iff_right {x y z : part_enat} (hz : z ≠ ⊤) : x + z < y + z ↔ x < y :=\n⟨lt_of_add_lt_add_right, λ h, part_enat.add_lt_add_right h hz⟩\n\nprotected lemma add_lt_add_iff_left {x y z : part_enat} (hz : z ≠ ⊤) : z + x < z + y ↔ x < y :=\nby rw [add_comm z, add_comm z, part_enat.add_lt_add_iff_right hz]\n\nprotected lemma lt_add_iff_pos_right {x y : part_enat} (hx : x ≠ ⊤) : x < x + y ↔ 0 < y :=\nby { conv_rhs { rw [← part_enat.add_lt_add_iff_left hx] }, rw [add_zero] }\n\nlemma lt_add_one {x : part_enat} (hx : x ≠ ⊤) : x < x + 1 :=\nby { rw [part_enat.lt_add_iff_pos_right hx], norm_cast, norm_num }\n\nlemma le_of_lt_add_one {x y : part_enat} (h : x < y + 1) : x ≤ y :=\nbegin\n  induction y using part_enat.cases_on with n, apply le_top,\n  rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩,\n  apply_mod_cast nat.le_of_lt_succ, apply_mod_cast h\nend\n\nlemma add_one_le_of_lt {x y : part_enat} (h : x < y) : x + 1 ≤ y :=\nbegin\n  induction y using part_enat.cases_on with n, apply le_top,\n  rcases ne_top_iff.mp (ne_top_of_lt h) with ⟨m, rfl⟩,\n  apply_mod_cast nat.succ_le_of_lt, apply_mod_cast h\nend\n\nlemma add_one_le_iff_lt {x y : part_enat} (hx : x ≠ ⊤) : x + 1 ≤ y ↔ x < y :=\nbegin\n  split, swap, exact add_one_le_of_lt,\n  intro h, rcases ne_top_iff.mp hx with ⟨m, rfl⟩,\n  induction y using part_enat.cases_on with n, apply coe_lt_top,\n  apply_mod_cast nat.lt_of_succ_le, apply_mod_cast h\nend\n\nlemma lt_add_one_iff_lt {x y : part_enat} (hx : x ≠ ⊤) : x < y + 1 ↔ x ≤ y :=\nbegin\n  split, exact le_of_lt_add_one,\n  intro h, rcases ne_top_iff.mp hx with ⟨m, rfl⟩,\n  induction y using part_enat.cases_on with n, { rw [top_add], apply coe_lt_top },\n  apply_mod_cast nat.lt_succ_of_le, apply_mod_cast h\nend\n\nlemma add_eq_top_iff {a b : part_enat} : a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤ :=\nby apply part_enat.cases_on a; apply part_enat.cases_on b;\n  simp; simp only [(nat.cast_add _ _).symm, part_enat.coe_ne_top]; simp\n\nprotected lemma add_right_cancel_iff {a b c : part_enat} (hc : c ≠ ⊤) : a + c = b + c ↔ a = b :=\nbegin\n  rcases ne_top_iff.1 hc with ⟨c, rfl⟩,\n  apply part_enat.cases_on a; apply part_enat.cases_on b;\n  simp [add_eq_top_iff, coe_ne_top, @eq_comm _ (⊤ : part_enat)];\n  simp only [(nat.cast_add _ _).symm, add_left_cancel_iff, part_enat.coe_inj, add_comm];\n  tauto\nend\n\nprotected lemma add_left_cancel_iff {a b c : part_enat} (ha : a ≠ ⊤) : a + b = a + c ↔ b = c :=\nby rw [add_comm a, add_comm a, part_enat.add_right_cancel_iff ha]\n\nsection with_top\n\n/-- Computably converts an `part_enat` to a `ℕ∞`. -/\ndef to_with_top (x : part_enat) [decidable x.dom] : ℕ∞ := x.to_option\n\nlemma to_with_top_top : to_with_top ⊤ = ⊤ := rfl\n\n@[simp] lemma to_with_top_top' {h : decidable (⊤ : part_enat).dom} : to_with_top ⊤ = ⊤ :=\nby convert to_with_top_top\n\nlemma to_with_top_zero : to_with_top 0 = 0 := rfl\n\n@[simp] lemma to_with_top_zero' {h : decidable (0 : part_enat).dom} : to_with_top 0 = 0 :=\nby convert to_with_top_zero\n\nlemma to_with_top_some (n : ℕ) : to_with_top (some n) = n := rfl\n\nlemma to_with_top_coe (n : ℕ) {_ : decidable (n : part_enat).dom} : to_with_top n = n :=\nby simp only [← some_eq_coe, ← to_with_top_some]\n\n@[simp] lemma to_with_top_coe' (n : ℕ) {h : decidable (n : part_enat).dom} :\n  to_with_top (n : part_enat) = n :=\nby convert to_with_top_coe n\n\n@[simp] lemma to_with_top_le {x y : part_enat} : Π [decidable x.dom]\n  [decidable y.dom], by exactI to_with_top x ≤ to_with_top y ↔ x ≤ y :=\npart_enat.cases_on y (by simp) (part_enat.cases_on x (by simp) (by intros; simp))\n\n@[simp] lemma to_with_top_lt {x y : part_enat} [decidable x.dom] [decidable y.dom] :\n  to_with_top x < to_with_top y ↔ x < y :=\nlt_iff_lt_of_le_iff_le to_with_top_le\n\nend with_top\n\nsection with_top_equiv\n\nopen_locale classical\n\n@[simp] lemma to_with_top_add {x y : part_enat} :\n  to_with_top (x + y) = to_with_top x + to_with_top y :=\nby apply part_enat.cases_on y; apply part_enat.cases_on x; simp [← nat.cast_add, ← enat.coe_add]\n\n/-- `equiv` between `part_enat` and `ℕ∞` (for the order isomorphism see\n`with_top_order_iso`). -/\nnoncomputable def with_top_equiv : part_enat ≃ ℕ∞ :=\n{ to_fun := λ x, to_with_top x,\n  inv_fun := λ x, match x with (option.some n) := coe n | none := ⊤ end,\n  left_inv := λ x, by apply part_enat.cases_on x; intros; simp; refl,\n  right_inv := λ x, by cases x; simp [with_top_equiv._match_1]; refl }\n\n@[simp] lemma with_top_equiv_top : with_top_equiv ⊤ = ⊤ :=\nto_with_top_top'\n\n@[simp] lemma with_top_equiv_coe (n : nat) : with_top_equiv n = n :=\nto_with_top_coe' _\n\n@[simp] lemma with_top_equiv_zero : with_top_equiv 0 = 0 :=\nby simpa only [nat.cast_zero] using with_top_equiv_coe 0\n\n@[simp] lemma with_top_equiv_le {x y : part_enat} : with_top_equiv x ≤ with_top_equiv y ↔ x ≤ y :=\nto_with_top_le\n\n@[simp] lemma with_top_equiv_lt {x y : part_enat} : with_top_equiv x < with_top_equiv y ↔ x < y :=\nto_with_top_lt\n\n/-- `to_with_top` induces an order isomorphism between `part_enat` and `ℕ∞`. -/\nnoncomputable def with_top_order_iso : part_enat ≃o ℕ∞ :=\n{ map_rel_iff' := λ _ _, with_top_equiv_le,\n  .. with_top_equiv}\n\n@[simp] lemma with_top_equiv_symm_top : with_top_equiv.symm ⊤ = ⊤ :=\nrfl\n\n@[simp] lemma with_top_equiv_symm_coe (n : nat) : with_top_equiv.symm n = n :=\nrfl\n\n@[simp] lemma with_top_equiv_symm_zero : with_top_equiv.symm 0 = 0 :=\nrfl\n\n@[simp] lemma with_top_equiv_symm_le {x y : ℕ∞} :\n  with_top_equiv.symm x ≤ with_top_equiv.symm y ↔ x ≤ y :=\nby rw ← with_top_equiv_le; simp\n\n@[simp] lemma with_top_equiv_symm_lt {x y : ℕ∞} :\n  with_top_equiv.symm x < with_top_equiv.symm y ↔ x < y :=\nby rw ← with_top_equiv_lt; simp\n\n/-- `to_with_top` induces an additive monoid isomorphism between `part_enat` and `ℕ∞`. -/\nnoncomputable def with_top_add_equiv : part_enat ≃+ ℕ∞ :=\n{ map_add' := λ x y, by simp only [with_top_equiv]; convert to_with_top_add,\n  ..with_top_equiv}\n\nend with_top_equiv\n\nlemma lt_wf : @well_founded part_enat (<) :=\nbegin\n  classical,\n  change well_founded (λ a b : part_enat, a < b),\n  simp_rw ←to_with_top_lt,\n  exact inv_image.wf _ (with_top.well_founded_lt nat.lt_wf)\nend\n\ninstance : well_founded_lt part_enat := ⟨lt_wf⟩\ninstance : is_well_order part_enat (<) := { }\ninstance : has_well_founded part_enat := ⟨(<), lt_wf⟩\n\nsection find\n\nvariables (P : ℕ → Prop) [decidable_pred P]\n\n/-- The smallest `part_enat` satisfying a (decidable) predicate `P : ℕ → Prop` -/\ndef find : part_enat := ⟨∃ n, P n, nat.find⟩\n\n@[simp] lemma find_get (h : (find P).dom) : (find P).get h = nat.find h := rfl\n\nlemma find_dom (h : ∃ n, P n) : (find P).dom := h\n\nlemma lt_find (n : ℕ) (h : ∀ m ≤ n, ¬P m) : (n : part_enat) < find P :=\nbegin\n  rw coe_lt_iff, intro h', rw find_get,\n  have := @nat.find_spec P _ h',\n  contrapose! this,\n  exact h _ this\nend\n\nlemma lt_find_iff (n : ℕ) : (n : part_enat) < find P ↔ (∀ m ≤ n, ¬P m) :=\nbegin\n  refine ⟨_, lt_find P n⟩,\n  intros h m hm,\n  by_cases H : (find P).dom,\n  { apply nat.find_min H, rw coe_lt_iff at h, specialize h H, exact lt_of_le_of_lt hm h },\n  { exact not_exists.mp H m }\nend\n\nlemma find_le (n : ℕ) (h : P n) : find P ≤ n :=\nby { rw le_coe_iff, refine ⟨⟨_, h⟩, @nat.find_min' P _ _ _ h⟩ }\n\nlemma find_eq_top_iff : find P = ⊤ ↔ ∀ n, ¬P n :=\n(eq_top_iff_forall_lt _).trans\n⟨λ h n, (lt_find_iff P n).mp (h n) _ le_rfl, λ h n, lt_find P n $ λ _ _, h _⟩\n\nend find\n\nnoncomputable instance : linear_ordered_add_comm_monoid_with_top part_enat :=\n{ top_add' := top_add,\n  .. part_enat.linear_order,\n  .. part_enat.ordered_add_comm_monoid,\n  .. part_enat.order_top }\n\nnoncomputable instance : complete_linear_order part_enat :=\n{ inf := (⊓),\n  sup := (⊔),\n  top := ⊤,\n  bot := ⊥,\n  le := (≤),\n  lt := (<),\n  .. part_enat.lattice,\n  .. with_top_order_iso.symm.to_galois_insertion.lift_complete_lattice,\n  .. part_enat.linear_order, }\n\nend part_enat\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/nat/part_enat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.49344775554420384}}
{"text": "import regular_sequence\nimport reals\n\nnamespace regular_sequence\n\ndef add : regular_sequence → regular_sequence → regular_sequence :=\nλ a b,\n  { val := λ n, a (2*n) + b (2*n),\n    property := \n    begin\n      intros m n m_pos n_pos,\n      have two_m_pos: 0 < 2 * m,\n        { exact nat.succ_mul_pos 1 m_pos },\n      have two_n_pos: 0 < 2 * n,\n        { exact nat.succ_mul_pos 1 n_pos },\n      cases a,\n      cases b,\n      specialize a_property two_m_pos two_n_pos,\n      specialize b_property two_m_pos two_n_pos,\n\n      calc |a_val (2 * m) + b_val (2 * m) - (a_val (2 * n) + b_val (2 * n))| = \n      |(a_val (2 * m) - a_val (2 * n)) + ((b_val (2 * m) - b_val (2 * n)))| : by ring_nf\n        ... ≤ |a_val (2 * m) - a_val (2 * n)| + |b_val (2 * m) - b_val (2 * n)| : abs_add _ _\n        ... ≤ ((↑(2 * m))⁻¹ + (↑(2 * n))⁻¹) + ((↑(2 * m))⁻¹ + (↑(2 * n))⁻¹) : add_le_add a_property b_property\n        ... = (↑m)⁻¹ + (↑n)⁻¹ : by { push_cast, rw mul_inv₀, simp, norm_num, ring_nf, simp, rw mul_inv₀, ring,},\n    end\n  }\n\ndef neg (a: regular_sequence): regular_sequence :=\n  { val := (λ x, -(a x)),\n    property := λ _ _ m_pos n_pos, let h := a.property m_pos n_pos \n        in by rwa [←abs_neg, neg_sub_neg, neg_sub] }\n\ninstance : has_neg regular_sequence :=\n  ⟨neg⟩\n\nlemma neg_apply (a: regular_sequence) (n: ℕ): -a n = -(a n) := rfl\n\ninstance : has_sub regular_sequence :=\n  ⟨λ a b, add a (neg b)⟩\n\n@[simp] lemma sub_apply (a b: regular_sequence) (n: ℕ): (a - b) n = a (2*n) - b (2*n) := rfl\n\nlemma subs' {a b : regular_sequence} {n : ℕ}: (a-b) n  =  a (2*n) - b (2*n)  := rfl \n\ninstance : has_add regular_sequence :=\n  ⟨add⟩\n\n@[simp] lemma add_apply' (a b: regular_sequence) (n: ℕ): (a + b).val n = a (2*n) + b (2*n) := rfl\n\n@[simp] lemma add_apply (a b: regular_sequence) (n: ℕ): (a + b) n = a (2*n) + b (2*n) := rfl\n\n\nlemma zero_add {a : regular_sequence} {n : ℕ}: (0 + a) n = a (2*n) :=\n  begin\n    simp,\n    refl,\n  end\n\nlemma add_zero {a : regular_sequence} {n : ℕ}: (a + 0) n = a (2*n) :=\n  begin\n    simp,\n    refl,\n  end\n\ntheorem add_lim_zero {f g : regular_sequence}\n  (hf : lim_zero f) (hg : lim_zero g) : lim_zero (f + g) :=\n  begin\n    intros j hj,\n    obtain ⟨N₁, hN₁⟩ := hf (2*j) (mul_pos zero_lt_two hj),\n    obtain ⟨N₂, hN₂⟩ := hg (2*j) (mul_pos zero_lt_two hj),\n    use max N₁ N₂,\n    intros n hn,\n    have h3 : | f (2*n) | + | g (2*n) | ≤ (2*j: ℚ)⁻¹+ (2*j: ℚ)⁻¹,\n    {\n      have hfg : | f (2*n) | ≤ (2*j: ℚ)⁻¹ ∧ | g (2*n) | ≤ (2*j: ℚ)⁻¹,\n      {\n        have : 2*n ≥ N₁ ∧ 2*n ≥ N₂,\n        {\n          have : n ≤ 2 * n,\n          {\n            obtain h := mul_le_mul one_le_two rfl.ge (zero_le n) (zero_le 2),\n            rwa one_mul at h,\n          },\n          exact ⟨le_trans (le_of_max_le_left hn) this, le_trans (le_of_max_le_right hn) this⟩\n        },\n        obtain tt := hN₁ (2*n) this.1,\n        obtain ttt := hN₂ (2*n) this.2,\n        simp only [nat.cast_bit0, nat.cast_one, nat.cast_mul] at *,\n        exact ⟨tt,ttt⟩,\n      },\n      exact add_le_add hfg.1 hfg.2,\n    },\n    rw [← one_mul (j : ℚ)⁻¹ ,← mul_inv_cancel (@two_ne_zero ℚ _ _), mul_assoc, ← @mul_inv₀ ℚ _ 2 (j : ℚ), two_mul],\n    exact le_trans (abs_add (f (2 * n)) (g (2 * n))) h3,\n  end\n\nend regular_sequence\n\nnamespace real\nopen regular_sequence\n\ndef add: real → real → real :=\n  quotient.lift₂ (λ x y, ⟦regular_sequence.add x y⟧)\n  begin\n    simp only [quotient.eq],\n    intros a₁ b₁ a₂ b₂ a₁_eq_a₂ b₁_eq_b₂,\n    rw equivalent_iff at *,\n    unfold add,\n    intros j j_pos,\n    have two_j_pos : 0 < 2*j,\n    {\n      simpa,\n    },\n    specialize a₁_eq_a₂ (2*j) two_j_pos,\n    specialize b₁_eq_b₂ (2*j) two_j_pos,\n    obtain ⟨N, hN⟩ := a₁_eq_a₂,\n    obtain ⟨M, hM⟩ := b₁_eq_b₂,\n    use max N M,\n    intros n n_ge_max,\n    specialize hN (2*n),\n    specialize hM (2*n),\n    simp only [fn_apply, subtype.val_eq_coe],\n    sorry,\n  end\n\nend real", "meta": {"author": "Eloitor", "repo": "Constructive-Analysis-in-Lean", "sha": "5aab8143b2d6b3d7e190de91a55fed3faf596bf7", "save_path": "github-repos/lean/Eloitor-Constructive-Analysis-in-Lean", "path": "github-repos/lean/Eloitor-Constructive-Analysis-in-Lean/Constructive-Analysis-in-Lean-5aab8143b2d6b3d7e190de91a55fed3faf596bf7/src/add.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6261241842048092, "lm_q1q2_score": 0.4933427770814274}}
{"text": "import data.rat tactic.norm_num .misc .string\n\nuniverses u v \n\nvariables {α : Type} \n\ndef N (α : Type) : Type := nat → α \n\ndef NN (α : Type) : Type := nat → nat → α \n\ndef N.eq (n : nat) (a b : N α) : Prop :=\n∀ j < n, a j = b j\n\ndef NN.eq (m n : nat) (A B : NN α) : Prop :=\n∀ i < m, ∀ j < n, A i j = B i j\n\ndef NN.mul_aux [ring α] (A B : NN α) (i j : nat) : nat → α \n| 0       := 0\n| (m + 1) := NN.mul_aux m + (A i m * B m j)\n\ndef NN.mul [ring α] (k m n : nat) (A B : NN α) : NN α | i j := \nNN.mul_aux A B i j m \n\nlemma N.eq_zero (a b : N α) : \n  N.eq 0 a b := forall_lt_zero _\n\nlemma N.eq_succ {n : nat} {a b : N α} : \n  a n = b n → N.eq n a b → N.eq n.succ a b := \nforall_lt_succ _ n\n\nlemma NN.eq_zero {n : nat} {A B : NN α} : \n  NN.eq 0 n A B := forall_lt_zero _\n\nlemma NN.eq_succ {m n : nat} {A B : NN α} : \n  N.eq n (A m) (B m) → NN.eq m n A B → \n  NN.eq m.succ n A B := forall_lt_succ _ m\n\nlemma NN.eq_symm {m n : nat} {A B : NN α} : \nNN.eq m n A B → NN.eq m n B A := \nbegin\n  intros h1 i hi j hj,  \n  exact (h1 i hi j hj).symm\nend\n\nlemma NN.eq_trans {m n : nat} {A B C : NN α} : \nNN.eq m n A B → NN.eq m n B C → NN.eq m n A C :=\nbegin\n  intros h1 h2 i hi j hj, \n  apply eq.trans (h1 i hi j hj) (h2 i hi j hj)\nend\n\ndef N.of_list [inhabited α] : list α → nat →  α \n| []      _     := inhabited.default α\n| (a::as) 0     := a\n| (a::as) (j+1) := N.of_list as j\n\ndef NN.of_lists (α : Type) [inhabited α] : list (list α) → NN α \n| []      _     _ := inhabited.default α\n| (l::ll) 0     j := N.of_list l j \n| (l::ll) (i+1) j := NN.of_lists ll i j \n\ninstance N.eq.decidable [decidable_eq α] (n : nat) :\n  decidable_rel (@N.eq α n) := \nby {intros A B, apply forall_lt.decidable} \n\ninstance NN.eq.decidable [decidable_eq α] (m n : nat) :\n  decidable_rel (@NN.eq α m n) := \nby {intros A B, apply forall_lt.decidable} \n\n\n/- repr -/\n\ndef N.cell_size [has_repr α] (b : N α) : nat → nat \n| 0     := 0 \n| (n+1) := max (N.cell_size n) (repr $ b n).length\n\ndef NN.cell_size [has_repr α] (A : NN α) : nat → nat → nat  \n| 0     n := 0\n| (m+1) n := max (NN.cell_size m n) (N.cell_size (A m) n)\n\ndef N.repr [has_repr α] (k : nat) (b : N α) : nat → string \n| 0     := \"|\" \n| (n+1) := N.repr n ++ \" \" ++ (repr $ b n).resize k ++ \" |\"\n\ndef NN.repr_aux [has_repr α] (k : nat) (A : NN α) : nat → nat → string \n| 0     n := \"\" \n| (m+1) n := NN.repr_aux m n ++ \"\\n\" ++ N.repr k (A m) n\n\ndef NN.repr (m n : nat) [has_repr α] (A : NN α) : string := \nNN.repr_aux (NN.cell_size A m n) A m n  \n\ndef N.le [has_le α] (k : nat) (v w : N α) : Prop :=\n∀ x < k, v x ≤ w x \n\ninstance N.le.decidable [has_le α] [decidable_rel ((≤) : α → α → Prop)] \n  (k : nat) (v w : N α) : decidable (N.le k v w) :=\nforall_lt.decidable _ _ \n   \ndef N.zero (α : Type) [has_zero α] : N α := λ _, 0\n\ndef N.sum [has_zero α] [has_add α] : ∀ k : nat, ∀ v : N α, α  \n| 0       _ := 0\n| (k + 1) v := v k + v.sum k \n\ndef dot_prod [has_zero α] [has_add α] [has_mul α] (k : nat) (v w : N α) : α := \nN.sum k (λ m, v m * w m)\n\ndef mul_vec [has_zero α] [has_add α] [has_mul α] (k : nat) (A : NN α) (x : N α) : N α := \nλ m, dot_prod k (A m) x\n\n\n/- norm -/\n\nopen tactic expr\n\n/- (N.mk_meta n) returns ⌜g : nat → α⌝, where ⌜f j⌝ is \n   a unique metavariable for any j < n, and ⌜g j⌝ = x \n   otherwise. -/\nmeta def N.mk_meta (τx tx : expr) : nat → tactic expr \n| 0     := to_expr ``(λ x : nat, (%%tx : %%τx))\n| (n+1) := \n  do gx ← N.mk_meta n,\n     sx ← mk_meta_var τx, \n     to_expr ``(update %%τx %%`(n) %%sx %%gx)\n\n/- (mk_meta m n) returns ⌜f : NN α⌝, where each \n   ⌜f i j⌝ is a unique metavariable for any \n   i < m and j < n, and ⌜f i j⌝ = x otherwise. -/\nmeta def NN.mk_meta (αx ax : expr) : nat → nat → tactic expr \n| 0     _ := to_expr ``(λ i j : nat, (%%ax : %%αx))\n| (m+1) n := \n  do fx ← NN.mk_meta m n,\n     gx ← N.mk_meta αx ax n,\n     to_expr ``(update (N %%αx) %%`(m) %%gx %%fx)\n  \nmeta def mul_simp_lemmas : list name := \n[`NN.mul, `NN.mul_aux, `N.of_list, `NN.of_lists] \n\nmeta def get_simp_lemmas : list name → tactic simp_lemmas \n| []      := return simp_lemmas.mk\n| (n::ns) := \n  do s ← get_simp_lemmas ns,\n     s.add_simp n\n\nmeta def simp_mul (x : expr) : tactic (expr × expr) := \ndo s ← get_simp_lemmas mul_simp_lemmas,\n   simplify s [] x\n\n/- Return ⌜h : t = s⌝ -/\nmeta def prove_eq (αx tx ux : expr) : tactic expr := \ndo (sx,px) ← simp_mul tx,\n   (rx,qx) ← norm_num.derive' sx,\n   unify rx ux,\n   to_expr ``(@eq.trans %%αx %%tx %%sx %%rx %%px %%qx)\n\n/- Return ⌜h : N.eq n a b⌝ -/\nmeta def N.prove_eq (αx ax bx : expr) : nat → tactic expr\n| 0     := return `(@N.eq_zero %%αx %%ax %%bx)\n| (n+1) := \n  do px ← prove_eq αx (app ax `(n)) (app bx `(n)),\n     qx ← N.prove_eq n,\n     return `(@N.eq_succ %%αx %%`(n) %%ax %%bx %%px %%qx)\n\n/- Return ⌜h : NN.eq m n A B⌝ -/\nmeta def NN.prove_eq (αx Ax Bx : expr) : nat → nat → tactic expr\n| 0     n := return `(@NN.eq_zero %%αx %%`(n) %%Ax %%Bx)\n| (m+1) n :=\n  do px ← N.prove_eq αx (app Ax `(m)) (app Bx `(m)) n,\n     qx ← NN.prove_eq m n,\n     return `(@NN.eq_succ %%αx %%`(m) %%`(n) %%Ax %%Bx %%px %%qx)\n\n/- Return ⌜B : NN α⌝ and ⌜h : NN.eq m n A B⌝ -/\nmeta def NN.norm (αx ax Ax : expr) (m n : nat) : tactic (expr × expr) := \ndo Bx ← NN.mk_meta αx ax m n, \n   px ← NN.prove_eq αx Ax Bx m n,\n   return (Bx,px)\n\nmeta def NN.equate : tactic unit :=\ndo `(@NN.eq %%αx %%mx %%nx %%Ax %%Bx) ← target,\n   ax ← get_default αx, \n   m ← eval_expr nat mx, \n   n ← eval_expr nat nx, \n   (A'x, px) ← NN.norm αx ax Ax m n, \n   (B'x, qx) ← NN.norm αx ax Bx m n, \n   ( do is_def_eq A'x B'x, \n        pq ← to_expr ``(@NN.eq_trans %%αx %%mx %%nx %%Ax %%A'x %%Bx\n               %%px (@NN.eq_symm %%αx %%mx %%nx %%Bx %%B'x %%qx)),\n        apply pq, skip ) <|>\n   fail \"Not definitionally equal\"\n\n\n/- Tests -/\n\nset_option profiler true\n\nlemma ex1 :\nNN.eq 2 2\n  ( NN.mul 2 2 2\n    ( NN.of_lists int \n      [ [ 9  , -7 ], \n        [ 18 , 4  ] ] )\n    ( NN.of_lists int \n      [ [ -14 , 1 ], \n        [ 5   , 22 ] ] ) ) \n  ( NN.of_lists int\n    [ [ -161 , -145 ],    \n      [ -232 , 106  ] ] ) :=\nby NN.equate\n\nlemma ex2 :\nNN.eq 3 2\n  ( NN.mul 3 4 2\n    ( NN.of_lists rat \n      [ [ 4.5  , -3.5 , 12.5 , 0.5 ], \n        [ -1/2 , -3/2 , -2   , 0   ], \n        [ 20   , 2    , 3    , 1   ] ] )\n    ( NN.of_lists rat \n      [ [ 8    , 1/2   ], \n        [ 5/2  , -13.5 ], \n        [ 1/2  , 4     ],\n        [ 21.5 , 11    ] ] ) ) \n  ( NN.of_lists rat\n    [ [ 177/4 , 105 ],\n      [ -35/4 , 12  ],\n      [ 188   , 6   ] ] ) :=\nby NN.equate\n\nlemma ex3 :\nNN.eq 3 3\n  ( NN.mul 3 3 3\n    ( NN.of_lists rat \n      [ [ 1/3 , -3.2   , 0.9 ], \n        [ -1/2 , 3 - 5 , -2  ], \n        [ 20   , 2     , 3.4 ] ] )\n    ( NN.of_lists rat \n      [ [ 8   , 1/4 , 4/3   ], \n        [ 5/3 , 3   , 4 * 7 ], \n        [ 1/2 , 4   , 0     ] ] ) ) \n  ( NN.of_lists rat \n    [ [ -133/60 , -71/12 , -4012/45 ],\n      [ -25/3   , -113/8 , -170/3   ],\n      [ 4951/30 , 123/5  , 248/3    ] ] ) := \nby NN.equate\n\nlemma ex4 :\nNN.eq 4 4 \n  ( NN.mul 4 4 4\n    ( NN.of_lists int \n      [ [ 9   , -71 , 25  , 1  ], \n        [ -1  , -3  , -4  , 92 ], \n        [ 133 , -39 , -23 , 0  ], \n        [ 40  , 26  , 366 , 28 ] ] )\n    ( NN.of_lists int \n      [ [ 16  , 1   , 55  , -11 ], \n        [ 512 , -27 , 219 , 129 ], \n        [ 1   , 8   , -89 , 5   ],\n        [ 43  , 22  , 4   , 42  ] ] ) ) \n  ( NN.of_lists int \n    [ [ -36140 , 2148 , -17275 , -9091 ],\n      [ 2400   , 2072 , 12     , 3468  ],\n      [ -17863 , 1002 , 821    , -6609 ],\n      [ 15522  , 2882 , -24568 , 5920  ] ] ) := \nby NN.equate\n\nlemma ex5 :\nNN.eq 5 5 \n  ( NN.mul 5 5 5\n    ( NN.of_lists int \n      [ [ 9   , -71 , 25  , 1   , 910 ], \n        [ -1  , -3  , -4  , 92  , 52  ], \n        [ 133 , -39 , -23 , 0   , -20 ], \n        [ -12 , 492 , 9   , 10 , 1929 ], \n        [ 40  , 26  , 366 , 28 , 2    ] ] )\n    ( NN.of_lists int \n      [ [ 16  , 1    , 55  , -11  , 13  ], \n        [ 512 , -27  , 219 , 1921 , 212 ], \n        [ 828   , 8  , -2  , 35   , 0   ],\n        [ 1   , 4283 , -89 , 5    , 431 ],\n        [ 43  , 22   , 4   , 42   , 880 ] ] ) ) \n  ( NN.of_lists int\n    [ [ 23623  , 26429  , -11553 , -97390  , 786296  ],\n      [ -2536  , 395228 , -8684  , -3248   , 84763   ],\n      [ -37744 , 562    , -1260  , -78027  , -24139  ],\n      [ 342121 , 72044  , 113896 , 1026647 , 1805978 ],\n      [ 317114 , 122234 , 4678   , 62540   , 19860   ] ] ) :=\nby NN.equate", "meta": {"author": "skbaek", "repo": "cvx", "sha": "c50c790c9116f9fac8dfe742903a62bdd7292c15", "save_path": "github-repos/lean/skbaek-cvx", "path": "github-repos/lean/skbaek-cvx/cvx-c50c790c9116f9fac8dfe742903a62bdd7292c15/src/NN.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4933427715844208}}
{"text": "import Lean\n\nimport Meta.Pull\n\nopen Lean Elab.Tactic Meta\n\ntheorem resolution_thm : ∀ {A B C : Prop}, (A ∨ B) → (¬ A ∨ C) → B ∨ C := by\n  intros A B C h₁ h₂\n  cases h₁ with\n  | inl ap => cases h₂ with\n              | inl nap => exact (False.elim (nap ap))\n              | inr cp  => exact (Or.inr cp)\n  | inr bp => exact (Or.inl bp)\n\ntheorem resolution_thm₂ : ∀ {A C: Prop}, A → (¬ A ∨ C) → C := λ a ornac =>\n  match ornac with\n  | Or.inl na => False.elim (na a)\n  | Or.inr c  => c\n\ntheorem resolution_thm₃ : ∀ {A B: Prop}, (A ∨ B) → ¬ A → B := λ orab na =>\n  match orab with\n  | Or.inl a => False.elim (na a)\n  | Or.inr b => b\n\ntheorem resolution_thm₄ : ∀ {A : Prop}, A → ¬ A → False := λ a na => na a\n\ndef resolutionCore (firstHyp secondHyp : Ident) (pivotTerm : Term) : TacticM Unit := do\n  let fident1 ← mkIdent <$> mkFreshId\n  let fident2 ← mkIdent <$> mkFreshId\n  let notPivot : Term := Syntax.mkApp (mkIdent `Not) #[pivotTerm]\n  let pivotExpr     ← elabTerm pivotTerm none\n  let notPivotExpr  ← elabTerm notPivot none\n  let firstHypType  ← inferType (← elabTerm firstHyp none)\n  let secondHypType ← inferType (← elabTerm secondHyp none)\n\n  let lenGoal ← getLength <$> getMainTarget\n  pullCore pivotExpr    firstHypType  firstHyp  fident1\n  pullCore notPivotExpr secondHypType secondHyp fident2\n\n  let mut len₁ := getLength firstHypType\n  if Option.isNone (getIndex pivotExpr firstHypType) then\n    len₁ := len₁ - (getLength pivotExpr) + 1\n\n  let len₂ := getLength secondHypType\n\n  if lenGoal > 2 then\n    for s in getCongAssoc (len₁ - 2) `orAssocConv do\n      evalTactic (← `(tactic| apply $s))\n      logInfo m!\"....apply {s}\"\n      printGoal\n\n  if len₁ > 1 then\n    if len₂ > 1 then\n      evalTactic (← `(tactic| exact resolution_thm $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm\"\n    else\n      evalTactic (← `(tactic| exact resolution_thm₃ $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm₃\"\n  else\n    if len₂ > 1 then\n      evalTactic (← `(tactic| exact resolution_thm₂ $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm₂\"\n    else\n      evalTactic (← `(tactic| exact resolution_thm₄ $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm₄\"\n\nsyntax (name := resolution_1) \"R1\" ident \",\" ident \",\" term : tactic\n@[tactic resolution_1] def evalResolution_1 : Tactic :=\n  fun stx => withMainContext do\n    let firstHyp : Ident := ⟨stx[1]⟩\n    let secondHyp : Ident := ⟨stx[3]⟩\n    let pivotTerm : Term := ⟨stx[5]⟩\n    resolutionCore firstHyp secondHyp pivotTerm\n\nsyntax (name := resolution_2) \"R2\" ident \",\" ident \",\" term : tactic\n@[tactic resolution_2] def evalResolution_2 : Tactic :=\n  fun stx => withMainContext do\n    let firstHyp : Ident := ⟨stx[1]⟩\n    let secondHyp : Ident := ⟨stx[3]⟩\n    let pivotTerm : Term := ⟨stx[5]⟩\n    resolutionCore secondHyp firstHyp pivotTerm\n\nexample : A ∨ B ∨ D ∨ (W ∨ Z) → E ∨ F ∨ G ∨ ¬ (W ∨ Z) → A ∨ B ∨ D ∨ E ∨ F ∨ G := by\n  intros h₁ h₂\n  R1 h₁, h₂, (W ∨ Z)\n\n", "meta": {"author": "tomaz1502", "repo": "Reconstruction", "sha": "3cd76aacfa5e4acb47de7d45b831e24bf607fb4c", "save_path": "github-repos/lean/tomaz1502-Reconstruction", "path": "github-repos/lean/tomaz1502-Reconstruction/Reconstruction-3cd76aacfa5e4acb47de7d45b831e24bf607fb4c/Meta/Resolution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.49334277158442075}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.hom_functor\nimport Mathlib.PostPort\n\nuniverses u₁ v₁ l \n\nnamespace Mathlib\n\n/-!\n# The Yoneda embedding\n\nThe Yoneda embedding as a functor `yoneda : C ⥤ (Cᵒᵖ ⥤ Type v₁)`,\nalong with an instance that it is `fully_faithful`.\n\nAlso the Yoneda lemma, `yoneda_lemma : (yoneda_pairing C) ≅ (yoneda_evaluation C)`.\n\n## References\n* [Stacks: Opposite Categories and the Yoneda Lemma](https://stacks.math.columbia.edu/tag/001L)\n-/\n\nnamespace category_theory\n\n\n/--\nThe Yoneda embedding, as a functor from `C` into presheaves on `C`.\n\nSee https://stacks.math.columbia.edu/tag/001O.\n-/\ndef yoneda {C : Type u₁} [category C] : C ⥤ Cᵒᵖ ⥤ Type v₁ :=\n  functor.mk\n    (fun (X : C) =>\n      functor.mk (fun (Y : Cᵒᵖ) => opposite.unop Y ⟶ X)\n        fun (Y Y' : Cᵒᵖ) (f : Y ⟶ Y') (g : opposite.unop Y ⟶ X) => has_hom.hom.unop f ≫ g)\n    fun (X X' : C) (f : X ⟶ X') =>\n      nat_trans.mk\n        fun (Y : Cᵒᵖ)\n          (g :\n          functor.obj\n            (functor.mk (fun (Y : Cᵒᵖ) => opposite.unop Y ⟶ X)\n              fun (Y Y' : Cᵒᵖ) (f : Y ⟶ Y') (g : opposite.unop Y ⟶ X) => has_hom.hom.unop f ≫ g)\n            Y) =>\n          g ≫ f\n\n/--\nThe co-Yoneda embedding, as a functor from `Cᵒᵖ` into co-presheaves on `C`.\n-/\n@[simp] theorem coyoneda_obj_map {C : Type u₁} [category C] (X : Cᵒᵖ) (Y : C) (Y' : C) (f : Y ⟶ Y') (g : opposite.unop X ⟶ Y) : functor.map (functor.obj coyoneda X) f g = g ≫ f :=\n  Eq.refl (functor.map (functor.obj coyoneda X) f g)\n\nnamespace yoneda\n\n\ntheorem obj_map_id {C : Type u₁} [category C] {X : C} {Y : C} (f : opposite.op X ⟶ opposite.op Y) : functor.map (functor.obj yoneda X) f 𝟙 = nat_trans.app (functor.map yoneda (has_hom.hom.unop f)) (opposite.op Y) 𝟙 := sorry\n\n@[simp] theorem naturality {C : Type u₁} [category C] {X : C} {Y : C} (α : functor.obj yoneda X ⟶ functor.obj yoneda Y) {Z : C} {Z' : C} (f : Z ⟶ Z') (h : Z' ⟶ X) : f ≫ nat_trans.app α (opposite.op Z') h = nat_trans.app α (opposite.op Z) (f ≫ h) :=\n  Eq.symm (functor_to_types.naturality (functor.obj yoneda X) (functor.obj yoneda Y) α (has_hom.hom.op f) h)\n\n/--\nThe Yoneda embedding is full.\n\nSee https://stacks.math.columbia.edu/tag/001P.\n-/\nprotected instance yoneda_full {C : Type u₁} [category C] : full yoneda :=\n  full.mk fun (X Y : C) (f : functor.obj yoneda X ⟶ functor.obj yoneda Y) => nat_trans.app f (opposite.op X) 𝟙\n\n/--\nThe Yoneda embedding is faithful.\n\nSee https://stacks.math.columbia.edu/tag/001P.\n-/\nprotected instance yoneda_faithful {C : Type u₁} [category C] : faithful yoneda :=\n  faithful.mk\n\n/-- Extensionality via Yoneda. The typical usage would be\n```\n-- Goal is `X ≅ Y`\n\n-- Goal is `X ≅ Y`\napply yoneda.ext,\n-- Goals are now functions `(Z ⟶ X) → (Z ⟶ Y)`, `(Z ⟶ Y) → (Z ⟶ X)`, and the fact that these\n\n-- Goals are now functions `(Z ⟶ X) → (Z ⟶ Y)`, `(Z ⟶ Y) → (Z ⟶ X)`, and the fact that these\nfunctions are inverses and natural in `Z`.\n```\n-/\ndef ext {C : Type u₁} [category C] (X : C) (Y : C) (p : {Z : C} → (Z ⟶ X) → (Z ⟶ Y)) (q : {Z : C} → (Z ⟶ Y) → (Z ⟶ X)) (h₁ : ∀ {Z : C} (f : Z ⟶ X), q (p f) = f) (h₂ : ∀ {Z : C} (f : Z ⟶ Y), p (q f) = f) (n : ∀ {Z Z' : C} (f : Z' ⟶ Z) (g : Z ⟶ X), p (f ≫ g) = f ≫ p g) : X ≅ Y :=\n  preimage_iso (nat_iso.of_components (fun (Z : Cᵒᵖ) => iso.mk p q) sorry)\n\n/--\nIf `yoneda.map f` is an isomorphism, so was `f`.\n-/\ndef is_iso {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y) [is_iso (functor.map yoneda f)] : is_iso f :=\n  is_iso_of_fully_faithful yoneda f\n\nend yoneda\n\n\nnamespace coyoneda\n\n\n@[simp] theorem naturality {C : Type u₁} [category C] {X : Cᵒᵖ} {Y : Cᵒᵖ} (α : functor.obj coyoneda X ⟶ functor.obj coyoneda Y) {Z : C} {Z' : C} (f : Z' ⟶ Z) (h : opposite.unop X ⟶ Z') : nat_trans.app α Z' h ≫ f = nat_trans.app α Z (h ≫ f) := sorry\n\nprotected instance coyoneda_full {C : Type u₁} [category C] : full coyoneda :=\n  full.mk\n    fun (X Y : Cᵒᵖ) (f : functor.obj coyoneda X ⟶ functor.obj coyoneda Y) =>\n      has_hom.hom.op (nat_trans.app f (opposite.unop X) 𝟙)\n\nprotected instance coyoneda_faithful {C : Type u₁} [category C] : faithful coyoneda :=\n  faithful.mk\n\n/--\nIf `coyoneda.map f` is an isomorphism, so was `f`.\n-/\ndef is_iso {C : Type u₁} [category C] {X : Cᵒᵖ} {Y : Cᵒᵖ} (f : X ⟶ Y) [is_iso (functor.map coyoneda f)] : is_iso f :=\n  is_iso_of_fully_faithful coyoneda f\n\n-- No need to use Cᵒᵖ here, works with any category\n\n/-- A Type-valued presheaf `P` is isomorphic to the composition of `P` with the\n  coyoneda functor coming from `punit`. -/\n@[simp] theorem iso_comp_punit_inv_app {C : Type u₁} [category C] (P : C ⥤ Type v₁) (X : C) (a : functor.obj P X) (_x : opposite.unop (opposite.op PUnit)) : nat_trans.app (iso.inv (iso_comp_punit P)) X a _x = a :=\n  Eq.refl (nat_trans.app (iso.inv (iso_comp_punit P)) X a _x)\n\nend coyoneda\n\n\n/--\nA presheaf `F` is representable if there is object `X` so `F ≅ yoneda.obj X`.\n\nSee https://stacks.math.columbia.edu/tag/001Q.\n-/\n-- TODO should we make this a Prop, merely asserting existence of such an object?\n\nclass representable {C : Type u₁} [category C] (F : Cᵒᵖ ⥤ Type v₁) \nwhere\n  X : C\n  w : functor.obj yoneda X ≅ F\n\nend category_theory\n\n\nnamespace category_theory\n\n\n-- For the rest of the file, we are using product categories,\n\n-- so need to restrict to the case morphisms are in 'Type', not 'Sort'.\n\n-- We need to help typeclass inference with some awkward universe levels here.\n\nprotected instance prod_category_instance_1 (C : Type u₁) [category C] : category ((Cᵒᵖ ⥤ Type v₁) × (Cᵒᵖ)) :=\n  category_theory.prod (Cᵒᵖ ⥤ Type v₁) (Cᵒᵖ)\n\nprotected instance prod_category_instance_2 (C : Type u₁) [category C] : category (Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁)) :=\n  category_theory.prod (Cᵒᵖ) (Cᵒᵖ ⥤ Type v₁)\n\n/--\nThe \"Yoneda evaluation\" functor, which sends `X : Cᵒᵖ` and `F : Cᵒᵖ ⥤ Type`\nto `F.obj X`, functorially in both `X` and `F`.\n-/\ndef yoneda_evaluation (C : Type u₁) [category C] : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁) ⥤ Type (max u₁ v₁) :=\n  evaluation_uncurried (Cᵒᵖ) (Type v₁) ⋙ ulift_functor\n\n@[simp] theorem yoneda_evaluation_map_down (C : Type u₁) [category C] (P : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁)) (Q : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁)) (α : P ⟶ Q) (x : functor.obj (yoneda_evaluation C) P) : ulift.down (functor.map (yoneda_evaluation C) α x) =\n  nat_trans.app (prod.snd α) (prod.fst Q) (functor.map (prod.snd P) (prod.fst α) (ulift.down x)) :=\n  rfl\n\n/--\nThe \"Yoneda pairing\" functor, which sends `X : Cᵒᵖ` and `F : Cᵒᵖ ⥤ Type`\nto `yoneda.op.obj X ⟶ F`, functorially in both `X` and `F`.\n-/\ndef yoneda_pairing (C : Type u₁) [category C] : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁) ⥤ Type (max u₁ v₁) :=\n  functor.prod (functor.op yoneda) 𝟭 ⋙ functor.hom (Cᵒᵖ ⥤ Type v₁)\n\n@[simp] theorem yoneda_pairing_map (C : Type u₁) [category C] (P : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁)) (Q : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁)) (α : P ⟶ Q) (β : functor.obj (yoneda_pairing C) P) : functor.map (yoneda_pairing C) α β = functor.map yoneda (has_hom.hom.unop (prod.fst α)) ≫ β ≫ prod.snd α :=\n  rfl\n\n/--\nThe Yoneda lemma asserts that that the Yoneda pairing\n`(X : Cᵒᵖ, F : Cᵒᵖ ⥤ Type) ↦ (yoneda.obj (unop X) ⟶ F)`\nis naturally isomorphic to the evaluation `(X, F) ↦ F.obj X`.\n\nSee https://stacks.math.columbia.edu/tag/001P.\n-/\ndef yoneda_lemma (C : Type u₁) [category C] : yoneda_pairing C ≅ yoneda_evaluation C :=\n  iso.mk\n    (nat_trans.mk\n      fun (F : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁)) (x : functor.obj (yoneda_pairing C) F) => ulift.up (nat_trans.app x (prod.fst F) 𝟙))\n    (nat_trans.mk\n      fun (F : Cᵒᵖ × (Cᵒᵖ ⥤ Type v₁)) (x : functor.obj (yoneda_evaluation C) F) =>\n        nat_trans.mk\n          fun (X : Cᵒᵖ)\n            (a : functor.obj (opposite.unop (prod.fst (functor.obj (functor.prod (functor.op yoneda) 𝟭) F))) X) =>\n            functor.map (prod.snd F) (has_hom.hom.op a) (ulift.down x))\n\n/--\nThe isomorphism between `yoneda.obj X ⟶ F` and `F.obj (op X)`\n(we need to insert a `ulift` to get the universes right!)\ngiven by the Yoneda lemma.\n-/\n@[simp] def yoneda_sections {C : Type u₁} [category C] (X : C) (F : Cᵒᵖ ⥤ Type v₁) : (functor.obj yoneda X ⟶ F) ≅ ulift (functor.obj F (opposite.op X)) :=\n  iso.app (yoneda_lemma C) (opposite.op X, F)\n\n/--\nWe have a type-level equivalence between natural transformations from the yoneda embedding\nand elements of `F.obj X`, without any universe switching.\n-/\ndef yoneda_equiv {C : Type u₁} [category C] {X : C} {F : Cᵒᵖ ⥤ Type v₁} : (functor.obj yoneda X ⟶ F) ≃ functor.obj F (opposite.op X) :=\n  equiv.trans (iso.to_equiv (yoneda_sections X F)) equiv.ulift\n\ntheorem yoneda_equiv_naturality {C : Type u₁} [category C] {X : C} {Y : C} {F : Cᵒᵖ ⥤ Type v₁} (f : functor.obj yoneda X ⟶ F) (g : Y ⟶ X) : functor.map F (has_hom.hom.op g) (coe_fn yoneda_equiv f) = coe_fn yoneda_equiv (functor.map yoneda g ≫ f) := sorry\n\n@[simp] theorem yoneda_equiv_apply {C : Type u₁} [category C] {X : C} {F : Cᵒᵖ ⥤ Type v₁} (f : functor.obj yoneda X ⟶ F) : coe_fn yoneda_equiv f = nat_trans.app f (opposite.op X) 𝟙 :=\n  rfl\n\n@[simp] theorem yoneda_equiv_symm_app_apply {C : Type u₁} [category C] {X : C} {F : Cᵒᵖ ⥤ Type v₁} (x : functor.obj F (opposite.op X)) (Y : Cᵒᵖ) (f : opposite.unop Y ⟶ X) : nat_trans.app (coe_fn (equiv.symm yoneda_equiv) x) Y f = functor.map F (has_hom.hom.op f) x :=\n  rfl\n\n/--\nWhen `C` is a small category, we can restate the isomorphism from `yoneda_sections`\nwithout having to change universes.\n-/\ndef yoneda_sections_small {C : Type u₁} [small_category C] (X : C) (F : Cᵒᵖ ⥤ Type u₁) : (functor.obj yoneda X ⟶ F) ≅ functor.obj F (opposite.op X) :=\n  yoneda_sections X F ≪≫ ulift_trivial (functor.obj F (opposite.op X))\n\n@[simp] theorem yoneda_sections_small_hom {C : Type u₁} [small_category C] (X : C) (F : Cᵒᵖ ⥤ Type u₁) (f : functor.obj yoneda X ⟶ F) : iso.hom (yoneda_sections_small X F) f = nat_trans.app f (opposite.op X) 𝟙 :=\n  rfl\n\n@[simp] theorem yoneda_sections_small_inv_app_apply {C : Type u₁} [small_category C] (X : C) (F : Cᵒᵖ ⥤ Type u₁) (t : functor.obj F (opposite.op X)) (Y : Cᵒᵖ) (f : opposite.unop Y ⟶ X) : nat_trans.app (iso.inv (yoneda_sections_small X F) t) Y f = functor.map F (has_hom.hom.op f) t :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/yoneda.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.787931185683219, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.493342765348427}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.subobject.lattice\n! leanprover-community/mathlib commit 024a4231815538ac739f52d08dd20a55da0d6b23\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Subobject.FactorThru\nimport Mathbin.CategoryTheory.Subobject.WellPowered\n\n/-!\n# The lattice of subobjects\n\nWe provide the `semilattice_inf` with `order_top (subobject X)` instance when `[has_pullback C]`,\nand the `semilattice_sup (subobject X)` instance when `[has_images C] [has_binary_coproducts C]`.\n-/\n\n\nuniverse v₁ v₂ u₁ u₂\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits\n\nvariable {C : Type u₁} [Category.{v₁} C] {X Y Z : C}\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\nnamespace CategoryTheory\n\nnamespace MonoOver\n\nsection Top\n\ninstance {X : C} : Top (MonoOver X) where top := mk' (𝟙 _)\n\ninstance {X : C} : Inhabited (MonoOver X) :=\n  ⟨⊤⟩\n\n/-- The morphism to the top object in `mono_over X`. -/\ndef leTop (f : MonoOver X) : f ⟶ ⊤ :=\n  homMk f.arrow (comp_id _)\n#align category_theory.mono_over.le_top CategoryTheory.MonoOver.leTop\n\n@[simp]\ntheorem top_left (X : C) : ((⊤ : MonoOver X) : C) = X :=\n  rfl\n#align category_theory.mono_over.top_left CategoryTheory.MonoOver.top_left\n\n@[simp]\ntheorem top_arrow (X : C) : (⊤ : MonoOver X).arrow = 𝟙 X :=\n  rfl\n#align category_theory.mono_over.top_arrow CategoryTheory.MonoOver.top_arrow\n\n/-- `map f` sends `⊤ : mono_over X` to `⟨X, f⟩ : mono_over Y`. -/\ndef mapTop (f : X ⟶ Y) [Mono f] : (map f).obj ⊤ ≅ mk' f :=\n  iso_of_both_ways (homMk (𝟙 _) rfl) (homMk (𝟙 _) (by simp [id_comp f]))\n#align category_theory.mono_over.map_top CategoryTheory.MonoOver.mapTop\n\nsection\n\nvariable [HasPullbacks C]\n\n/-- The pullback of the top object in `mono_over Y`\nis (isomorphic to) the top object in `mono_over X`. -/\ndef pullbackTop (f : X ⟶ Y) : (pullback f).obj ⊤ ≅ ⊤ :=\n  iso_of_both_ways (leTop _) (homMk (pullback.lift f (𝟙 _) (by tidy)) (pullback.lift_snd _ _ _))\n#align category_theory.mono_over.pullback_top CategoryTheory.MonoOver.pullbackTop\n\n/-- There is a morphism from `⊤ : mono_over A` to the pullback of a monomorphism along itself;\nas the category is thin this is an isomorphism. -/\ndef topLePullbackSelf {A B : C} (f : A ⟶ B) [Mono f] :\n    (⊤ : MonoOver A) ⟶ (pullback f).obj (mk' f) :=\n  homMk _ (pullback.lift_snd _ _ rfl)\n#align category_theory.mono_over.top_le_pullback_self CategoryTheory.MonoOver.topLePullbackSelf\n\n/-- The pullback of a monomorphism along itself is isomorphic to the top object. -/\ndef pullbackSelf {A B : C} (f : A ⟶ B) [Mono f] : (pullback f).obj (mk' f) ≅ ⊤ :=\n  iso_of_both_ways (leTop _) (topLePullbackSelf _)\n#align category_theory.mono_over.pullback_self CategoryTheory.MonoOver.pullbackSelf\n\nend\n\nend Top\n\nsection Bot\n\nvariable [HasInitial C] [InitialMonoClass C]\n\ninstance {X : C} : Bot (MonoOver X) where bot := mk' (initial.to X)\n\n@[simp]\ntheorem bot_left (X : C) : ((⊥ : MonoOver X) : C) = ⊥_ C :=\n  rfl\n#align category_theory.mono_over.bot_left CategoryTheory.MonoOver.bot_left\n\n@[simp]\ntheorem bot_arrow {X : C} : (⊥ : MonoOver X).arrow = initial.to X :=\n  rfl\n#align category_theory.mono_over.bot_arrow CategoryTheory.MonoOver.bot_arrow\n\n/-- The (unique) morphism from `⊥ : mono_over X` to any other `f : mono_over X`. -/\ndef botLe {X : C} (f : MonoOver X) : ⊥ ⟶ f :=\n  homMk (initial.to _) (by simp)\n#align category_theory.mono_over.bot_le CategoryTheory.MonoOver.botLe\n\n/-- `map f` sends `⊥ : mono_over X` to `⊥ : mono_over Y`. -/\ndef mapBot (f : X ⟶ Y) [Mono f] : (map f).obj ⊥ ≅ ⊥ :=\n  iso_of_both_ways (homMk (initial.to _) (by simp)) (homMk (𝟙 _) (by simp))\n#align category_theory.mono_over.map_bot CategoryTheory.MonoOver.mapBot\n\nend Bot\n\nsection ZeroOrderBot\n\nvariable [HasZeroObject C]\n\nopen ZeroObject\n\n/-- The object underlying `⊥ : subobject B` is (up to isomorphism) the zero object. -/\ndef botCoeIsoZero {B : C} : ((⊥ : MonoOver B) : C) ≅ 0 :=\n  initialIsInitial.uniqueUpToIso HasZeroObject.zeroIsInitial\n#align category_theory.mono_over.bot_coe_iso_zero CategoryTheory.MonoOver.botCoeIsoZero\n\n@[simp]\ntheorem bot_arrow_eq_zero [HasZeroMorphisms C] {B : C} : (⊥ : MonoOver B).arrow = 0 :=\n  zero_of_source_iso_zero _ botCoeIsoZero\n#align category_theory.mono_over.bot_arrow_eq_zero CategoryTheory.MonoOver.bot_arrow_eq_zero\n\nend ZeroOrderBot\n\nsection Inf\n\nvariable [HasPullbacks C]\n\n/-- When `[has_pullbacks C]`, `mono_over A` has \"intersections\", functorial in both arguments.\n\nAs `mono_over A` is only a preorder, this doesn't satisfy the axioms of `semilattice_inf`,\nbut we reuse all the names from `semilattice_inf` because they will be used to construct\n`semilattice_inf (subobject A)` shortly.\n-/\n@[simps]\ndef inf {A : C} : MonoOver A ⥤ MonoOver A ⥤ MonoOver A\n    where\n  obj f := pullback f.arrow ⋙ map f.arrow\n  map f₁ f₂ k :=\n    {\n      app := fun g => by\n        apply hom_mk _ _\n        apply pullback.lift pullback.fst (pullback.snd ≫ k.left) _\n        rw [pullback.condition, assoc, w k]\n        dsimp\n        rw [pullback.lift_snd_assoc, assoc, w k] }\n#align category_theory.mono_over.inf CategoryTheory.MonoOver.inf\n\n/-- A morphism from the \"infimum\" of two objects in `mono_over A` to the first object. -/\ndef infLeLeft {A : C} (f g : MonoOver A) : (inf.obj f).obj g ⟶ f :=\n  homMk _ rfl\n#align category_theory.mono_over.inf_le_left CategoryTheory.MonoOver.infLeLeft\n\n/-- A morphism from the \"infimum\" of two objects in `mono_over A` to the second object. -/\ndef infLeRight {A : C} (f g : MonoOver A) : (inf.obj f).obj g ⟶ g :=\n  homMk _ pullback.condition\n#align category_theory.mono_over.inf_le_right CategoryTheory.MonoOver.infLeRight\n\n/-- A morphism version of the `le_inf` axiom. -/\ndef leInf {A : C} (f g h : MonoOver A) : (h ⟶ f) → (h ⟶ g) → (h ⟶ (inf.obj f).obj g) :=\n  by\n  intro k₁ k₂\n  refine' hom_mk (pullback.lift k₂.left k₁.left _) _\n  rw [w k₁, w k₂]\n  erw [pullback.lift_snd_assoc, w k₁]\n#align category_theory.mono_over.le_inf CategoryTheory.MonoOver.leInf\n\nend Inf\n\nsection Sup\n\nvariable [HasImages C] [HasBinaryCoproducts C]\n\n/-- When `[has_images C] [has_binary_coproducts C]`, `mono_over A` has a `sup` construction,\nwhich is functorial in both arguments,\nand which on `subobject A` will induce a `semilattice_sup`. -/\ndef sup {A : C} : MonoOver A ⥤ MonoOver A ⥤ MonoOver A :=\n  curryObj ((forget A).Prod (forget A) ⋙ uncurry.obj Over.coprod ⋙ image)\n#align category_theory.mono_over.sup CategoryTheory.MonoOver.sup\n\n/-- A morphism version of `le_sup_left`. -/\ndef leSupLeft {A : C} (f g : MonoOver A) : f ⟶ (sup.obj f).obj g :=\n  by\n  refine' hom_mk (coprod.inl ≫ factor_thru_image _) _\n  erw [category.assoc, image.fac, coprod.inl_desc]\n  rfl\n#align category_theory.mono_over.le_sup_left CategoryTheory.MonoOver.leSupLeft\n\n/-- A morphism version of `le_sup_right`. -/\ndef leSupRight {A : C} (f g : MonoOver A) : g ⟶ (sup.obj f).obj g :=\n  by\n  refine' hom_mk (coprod.inr ≫ factor_thru_image _) _\n  erw [category.assoc, image.fac, coprod.inr_desc]\n  rfl\n#align category_theory.mono_over.le_sup_right CategoryTheory.MonoOver.leSupRight\n\n/-- A morphism version of `sup_le`. -/\ndef supLe {A : C} (f g h : MonoOver A) : (f ⟶ h) → (g ⟶ h) → ((sup.obj f).obj g ⟶ h) :=\n  by\n  intro k₁ k₂\n  refine' hom_mk _ _\n  apply image.lift ⟨_, h.arrow, coprod.desc k₁.left k₂.left, _⟩\n  · dsimp\n    ext1\n    · simp [w k₁]\n    · simp [w k₂]\n  · apply image.lift_fac\n#align category_theory.mono_over.sup_le CategoryTheory.MonoOver.supLe\n\nend Sup\n\nend MonoOver\n\nnamespace Subobject\n\nsection OrderTop\n\ninstance orderTop {X : C} : OrderTop (Subobject X)\n    where\n  top := Quotient.mk'' ⊤\n  le_top := by\n    refine' Quotient.ind' fun f => _\n    exact ⟨mono_over.le_top f⟩\n#align category_theory.subobject.order_top CategoryTheory.Subobject.orderTop\n\ninstance {X : C} : Inhabited (Subobject X) :=\n  ⟨⊤⟩\n\ntheorem top_eq_id (B : C) : (⊤ : Subobject B) = Subobject.mk (𝟙 B) :=\n  rfl\n#align category_theory.subobject.top_eq_id CategoryTheory.Subobject.top_eq_id\n\ntheorem underlyingIso_top_hom {B : C} : (underlyingIso (𝟙 B)).Hom = (⊤ : Subobject B).arrow :=\n  by\n  convert underlying_iso_hom_comp_eq_mk (𝟙 B)\n  simp only [comp_id]\n#align category_theory.subobject.underlying_iso_top_hom CategoryTheory.Subobject.underlyingIso_top_hom\n\ninstance top_arrow_isIso {B : C} : IsIso (⊤ : Subobject B).arrow :=\n  by\n  rw [← underlying_iso_top_hom]\n  infer_instance\n#align category_theory.subobject.top_arrow_is_iso CategoryTheory.Subobject.top_arrow_isIso\n\n@[simp, reassoc.1]\ntheorem underlyingIso_inv_top_arrow {B : C} :\n    (underlyingIso _).inv ≫ (⊤ : Subobject B).arrow = 𝟙 B :=\n  underlyingIso_arrow _\n#align category_theory.subobject.underlying_iso_inv_top_arrow CategoryTheory.Subobject.underlyingIso_inv_top_arrow\n\n@[simp]\ntheorem map_top (f : X ⟶ Y) [Mono f] : (map f).obj ⊤ = Subobject.mk f :=\n  Quotient.sound' ⟨MonoOver.mapTop f⟩\n#align category_theory.subobject.map_top CategoryTheory.Subobject.map_top\n\ntheorem top_factors {A B : C} (f : A ⟶ B) : (⊤ : Subobject B).Factors f :=\n  ⟨f, comp_id _⟩\n#align category_theory.subobject.top_factors CategoryTheory.Subobject.top_factors\n\ntheorem isIso_iff_mk_eq_top {X Y : C} (f : X ⟶ Y) [Mono f] : IsIso f ↔ mk f = ⊤ :=\n  ⟨fun _ => mk_eq_mk_of_comm _ _ (as_iso f) (category.comp_id _), fun h =>\n    by\n    rw [← of_mk_le_mk_comp h.le, category.comp_id]\n    exact is_iso.of_iso (iso_of_mk_eq_mk _ _ h)⟩\n#align category_theory.subobject.is_iso_iff_mk_eq_top CategoryTheory.Subobject.isIso_iff_mk_eq_top\n\ntheorem isIso_arrow_iff_eq_top {Y : C} (P : Subobject Y) : IsIso P.arrow ↔ P = ⊤ := by\n  rw [is_iso_iff_mk_eq_top, mk_arrow]\n#align category_theory.subobject.is_iso_arrow_iff_eq_top CategoryTheory.Subobject.isIso_arrow_iff_eq_top\n\ninstance isIso_top_arrow {Y : C} : IsIso (⊤ : Subobject Y).arrow := by rw [is_iso_arrow_iff_eq_top]\n#align category_theory.subobject.is_iso_top_arrow CategoryTheory.Subobject.isIso_top_arrow\n\ntheorem mk_eq_top_of_isIso {X Y : C} (f : X ⟶ Y) [IsIso f] : mk f = ⊤ :=\n  (isIso_iff_mk_eq_top f).mp inferInstance\n#align category_theory.subobject.mk_eq_top_of_is_iso CategoryTheory.Subobject.mk_eq_top_of_isIso\n\ntheorem eq_top_of_isIso_arrow {Y : C} (P : Subobject Y) [IsIso P.arrow] : P = ⊤ :=\n  (isIso_arrow_iff_eq_top P).mp inferInstance\n#align category_theory.subobject.eq_top_of_is_iso_arrow CategoryTheory.Subobject.eq_top_of_isIso_arrow\n\nsection\n\nvariable [HasPullbacks C]\n\ntheorem pullback_top (f : X ⟶ Y) : (pullback f).obj ⊤ = ⊤ :=\n  Quotient.sound' ⟨MonoOver.pullbackTop f⟩\n#align category_theory.subobject.pullback_top CategoryTheory.Subobject.pullback_top\n\ntheorem pullback_self {A B : C} (f : A ⟶ B) [Mono f] : (pullback f).obj (mk f) = ⊤ :=\n  Quotient.sound' ⟨MonoOver.pullbackSelf f⟩\n#align category_theory.subobject.pullback_self CategoryTheory.Subobject.pullback_self\n\nend\n\nend OrderTop\n\nsection OrderBot\n\nvariable [HasInitial C] [InitialMonoClass C]\n\ninstance orderBot {X : C} : OrderBot (Subobject X)\n    where\n  bot := Quotient.mk'' ⊥\n  bot_le := by\n    refine' Quotient.ind' fun f => _\n    exact ⟨mono_over.bot_le f⟩\n#align category_theory.subobject.order_bot CategoryTheory.Subobject.orderBot\n\ntheorem bot_eq_initial_to {B : C} : (⊥ : Subobject B) = Subobject.mk (initial.to B) :=\n  rfl\n#align category_theory.subobject.bot_eq_initial_to CategoryTheory.Subobject.bot_eq_initial_to\n\n/-- The object underlying `⊥ : subobject B` is (up to isomorphism) the initial object. -/\ndef botCoeIsoInitial {B : C} : ((⊥ : Subobject B) : C) ≅ ⊥_ C :=\n  underlyingIso _\n#align category_theory.subobject.bot_coe_iso_initial CategoryTheory.Subobject.botCoeIsoInitial\n\ntheorem map_bot (f : X ⟶ Y) [Mono f] : (map f).obj ⊥ = ⊥ :=\n  Quotient.sound' ⟨MonoOver.mapBot f⟩\n#align category_theory.subobject.map_bot CategoryTheory.Subobject.map_bot\n\nend OrderBot\n\nsection ZeroOrderBot\n\nvariable [HasZeroObject C]\n\nopen ZeroObject\n\n/-- The object underlying `⊥ : subobject B` is (up to isomorphism) the zero object. -/\ndef botCoeIsoZero {B : C} : ((⊥ : Subobject B) : C) ≅ 0 :=\n  botCoeIsoInitial ≪≫ initialIsInitial.uniqueUpToIso HasZeroObject.zeroIsInitial\n#align category_theory.subobject.bot_coe_iso_zero CategoryTheory.Subobject.botCoeIsoZero\n\nvariable [HasZeroMorphisms C]\n\ntheorem bot_eq_zero {B : C} : (⊥ : Subobject B) = Subobject.mk (0 : 0 ⟶ B) :=\n  mk_eq_mk_of_comm _ _ (initialIsInitial.uniqueUpToIso HasZeroObject.zeroIsInitial) (by simp)\n#align category_theory.subobject.bot_eq_zero CategoryTheory.Subobject.bot_eq_zero\n\n@[simp]\ntheorem bot_arrow {B : C} : (⊥ : Subobject B).arrow = 0 :=\n  zero_of_source_iso_zero _ botCoeIsoZero\n#align category_theory.subobject.bot_arrow CategoryTheory.Subobject.bot_arrow\n\ntheorem bot_factors_iff_zero {A B : C} (f : A ⟶ B) : (⊥ : Subobject B).Factors f ↔ f = 0 :=\n  ⟨by\n    rintro ⟨h, rfl⟩\n    simp, by\n    rintro rfl\n    exact ⟨0, by simp⟩⟩\n#align category_theory.subobject.bot_factors_iff_zero CategoryTheory.Subobject.bot_factors_iff_zero\n\ntheorem mk_eq_bot_iff_zero {f : X ⟶ Y} [Mono f] : Subobject.mk f = ⊥ ↔ f = 0 :=\n  ⟨fun h => by simpa [h, bot_factors_iff_zero] using mk_factors_self f, fun h =>\n    mk_eq_mk_of_comm _ _ ((isoZeroOfMonoEqZero h).trans HasZeroObject.zeroIsoInitial) (by simp [h])⟩\n#align category_theory.subobject.mk_eq_bot_iff_zero CategoryTheory.Subobject.mk_eq_bot_iff_zero\n\nend ZeroOrderBot\n\nsection Functor\n\nvariable (C)\n\n/-- Sending `X : C` to `subobject X` is a contravariant functor `Cᵒᵖ ⥤ Type`. -/\n@[simps]\ndef functor [HasPullbacks C] : Cᵒᵖ ⥤ Type max u₁ v₁\n    where\n  obj X := Subobject X.unop\n  map X Y f := (pullback f.unop).obj\n  map_id' X := funext pullback_id\n  map_comp' X Y Z f g := funext (pullback_comp _ _)\n#align category_theory.subobject.functor CategoryTheory.Subobject.functor\n\nend Functor\n\nsection SemilatticeInfTop\n\nvariable [HasPullbacks C]\n\n/-- The functorial infimum on `mono_over A` descends to an infimum on `subobject A`. -/\ndef inf {A : C} : Subobject A ⥤ Subobject A ⥤ Subobject A :=\n  ThinSkeleton.map₂ MonoOver.inf\n#align category_theory.subobject.inf CategoryTheory.Subobject.inf\n\ntheorem inf_le_left {A : C} (f g : Subobject A) : (inf.obj f).obj g ≤ f :=\n  Quotient.inductionOn₂' f g fun a b => ⟨MonoOver.infLeLeft _ _⟩\n#align category_theory.subobject.inf_le_left CategoryTheory.Subobject.inf_le_left\n\ntheorem inf_le_right {A : C} (f g : Subobject A) : (inf.obj f).obj g ≤ g :=\n  Quotient.inductionOn₂' f g fun a b => ⟨MonoOver.infLeRight _ _⟩\n#align category_theory.subobject.inf_le_right CategoryTheory.Subobject.inf_le_right\n\ntheorem le_inf {A : C} (h f g : Subobject A) : h ≤ f → h ≤ g → h ≤ (inf.obj f).obj g :=\n  Quotient.inductionOn₃' h f g\n    (by\n      rintro f g h ⟨k⟩ ⟨l⟩\n      exact ⟨mono_over.le_inf _ _ _ k l⟩)\n#align category_theory.subobject.le_inf CategoryTheory.Subobject.le_inf\n\ninstance {B : C} : SemilatticeInf (Subobject B) :=\n  { Subobject.partialOrder _ with\n    inf := fun m n => (inf.obj m).obj n\n    inf_le_left := inf_le_left\n    inf_le_right := inf_le_right\n    le_inf := le_inf }\n\ntheorem factors_left_of_inf_factors {A B : C} {X Y : Subobject B} {f : A ⟶ B}\n    (h : (X ⊓ Y).Factors f) : X.Factors f :=\n  factors_of_le _ (inf_le_left _ _) h\n#align category_theory.subobject.factors_left_of_inf_factors CategoryTheory.Subobject.factors_left_of_inf_factors\n\ntheorem factors_right_of_inf_factors {A B : C} {X Y : Subobject B} {f : A ⟶ B}\n    (h : (X ⊓ Y).Factors f) : Y.Factors f :=\n  factors_of_le _ (inf_le_right _ _) h\n#align category_theory.subobject.factors_right_of_inf_factors CategoryTheory.Subobject.factors_right_of_inf_factors\n\n@[simp]\ntheorem inf_factors {A B : C} {X Y : Subobject B} (f : A ⟶ B) :\n    (X ⊓ Y).Factors f ↔ X.Factors f ∧ Y.Factors f :=\n  ⟨fun h => ⟨factors_left_of_inf_factors h, factors_right_of_inf_factors h⟩,\n    by\n    revert X Y\n    refine' Quotient.ind₂' _\n    rintro X Y ⟨⟨g₁, rfl⟩, ⟨g₂, hg₂⟩⟩\n    exact ⟨_, pullback.lift_snd_assoc _ _ hg₂ _⟩⟩\n#align category_theory.subobject.inf_factors CategoryTheory.Subobject.inf_factors\n\ntheorem inf_arrow_factors_left {B : C} (X Y : Subobject B) : X.Factors (X ⊓ Y).arrow :=\n  (factors_iff _ _).mpr ⟨ofLe (X ⊓ Y) X (inf_le_left X Y), by simp⟩\n#align category_theory.subobject.inf_arrow_factors_left CategoryTheory.Subobject.inf_arrow_factors_left\n\ntheorem inf_arrow_factors_right {B : C} (X Y : Subobject B) : Y.Factors (X ⊓ Y).arrow :=\n  (factors_iff _ _).mpr ⟨ofLe (X ⊓ Y) Y (inf_le_right X Y), by simp⟩\n#align category_theory.subobject.inf_arrow_factors_right CategoryTheory.Subobject.inf_arrow_factors_right\n\n@[simp]\ntheorem finset_inf_factors {I : Type _} {A B : C} {s : Finset I} {P : I → Subobject B} (f : A ⟶ B) :\n    (s.inf P).Factors f ↔ ∀ i ∈ s, (P i).Factors f := by\n  classical\n    apply Finset.induction_on s\n    · simp [top_factors]\n    · intro i s nm ih\n      simp [ih]\n#align category_theory.subobject.finset_inf_factors CategoryTheory.Subobject.finset_inf_factors\n\n-- `i` is explicit here because often we'd like to defer a proof of `m`\ntheorem finset_inf_arrow_factors {I : Type _} {B : C} (s : Finset I) (P : I → Subobject B) (i : I)\n    (m : i ∈ s) : (P i).Factors (s.inf P).arrow :=\n  by\n  revert i m\n  classical\n    apply Finset.induction_on s\n    · rintro _ ⟨⟩\n    · intro i s nm ih j m\n      rw [Finset.inf_insert]\n      simp only [Finset.mem_insert] at m\n      rcases m with (rfl | m)\n      · rw [← factor_thru_arrow _ _ (inf_arrow_factors_left _ _)]\n        exact factors_comp_arrow _\n      · rw [← factor_thru_arrow _ _ (inf_arrow_factors_right _ _)]\n        apply factors_of_factors_right\n        exact ih _ m\n#align category_theory.subobject.finset_inf_arrow_factors CategoryTheory.Subobject.finset_inf_arrow_factors\n\ntheorem inf_eq_map_pullback' {A : C} (f₁ : MonoOver A) (f₂ : Subobject A) :\n    (Subobject.inf.obj (Quotient.mk'' f₁)).obj f₂ =\n      (Subobject.map f₁.arrow).obj ((Subobject.pullback f₁.arrow).obj f₂) :=\n  by\n  apply Quotient.inductionOn' f₂\n  intro f₂\n  rfl\n#align category_theory.subobject.inf_eq_map_pullback' CategoryTheory.Subobject.inf_eq_map_pullback'\n\ntheorem inf_eq_map_pullback {A : C} (f₁ : MonoOver A) (f₂ : Subobject A) :\n    (Quotient.mk'' f₁ ⊓ f₂ : Subobject A) = (map f₁.arrow).obj ((pullback f₁.arrow).obj f₂) :=\n  inf_eq_map_pullback' f₁ f₂\n#align category_theory.subobject.inf_eq_map_pullback CategoryTheory.Subobject.inf_eq_map_pullback\n\ntheorem prod_eq_inf {A : C} {f₁ f₂ : Subobject A} [HasBinaryProduct f₁ f₂] : (f₁ ⨯ f₂) = f₁ ⊓ f₂ :=\n  le_antisymm (le_inf Limits.prod.fst.le Limits.prod.snd.le)\n    (prod.lift inf_le_left.Hom inf_le_right.Hom).le\n#align category_theory.subobject.prod_eq_inf CategoryTheory.Subobject.prod_eq_inf\n\ntheorem inf_def {B : C} (m m' : Subobject B) : m ⊓ m' = (inf.obj m).obj m' :=\n  rfl\n#align category_theory.subobject.inf_def CategoryTheory.Subobject.inf_def\n\n/-- `⊓` commutes with pullback. -/\ntheorem inf_pullback {X Y : C} (g : X ⟶ Y) (f₁ f₂) :\n    (pullback g).obj (f₁ ⊓ f₂) = (pullback g).obj f₁ ⊓ (pullback g).obj f₂ :=\n  by\n  revert f₁\n  apply Quotient.ind'\n  intro f₁\n  erw [inf_def, inf_def, inf_eq_map_pullback', inf_eq_map_pullback', ← pullback_comp, ←\n    map_pullback pullback.condition (pullback_is_pullback f₁.arrow g), ← pullback_comp,\n    pullback.condition]\n  rfl\n#align category_theory.subobject.inf_pullback CategoryTheory.Subobject.inf_pullback\n\n/-- `⊓` commutes with map. -/\ntheorem inf_map {X Y : C} (g : Y ⟶ X) [Mono g] (f₁ f₂) :\n    (map g).obj (f₁ ⊓ f₂) = (map g).obj f₁ ⊓ (map g).obj f₂ :=\n  by\n  revert f₁\n  apply Quotient.ind'\n  intro f₁\n  erw [inf_def, inf_def, inf_eq_map_pullback', inf_eq_map_pullback', ← map_comp]\n  dsimp\n  rw [pullback_comp, pullback_map_self]\n#align category_theory.subobject.inf_map CategoryTheory.Subobject.inf_map\n\nend SemilatticeInfTop\n\nsection SemilatticeSup\n\nvariable [HasImages C] [HasBinaryCoproducts C]\n\n/-- The functorial supremum on `mono_over A` descends to an supremum on `subobject A`. -/\ndef sup {A : C} : Subobject A ⥤ Subobject A ⥤ Subobject A :=\n  ThinSkeleton.map₂ MonoOver.sup\n#align category_theory.subobject.sup CategoryTheory.Subobject.sup\n\ninstance {B : C} : SemilatticeSup (Subobject B) :=\n  { Subobject.partialOrder B with\n    sup := fun m n => (sup.obj m).obj n\n    le_sup_left := fun m n => Quotient.inductionOn₂' m n fun a b => ⟨MonoOver.leSupLeft _ _⟩\n    le_sup_right := fun m n => Quotient.inductionOn₂' m n fun a b => ⟨MonoOver.leSupRight _ _⟩\n    sup_le := fun m n k =>\n      Quotient.inductionOn₃' m n k fun a b c ⟨i⟩ ⟨j⟩ => ⟨MonoOver.supLe _ _ _ i j⟩ }\n\ntheorem sup_factors_of_factors_left {A B : C} {X Y : Subobject B} {f : A ⟶ B} (P : X.Factors f) :\n    (X ⊔ Y).Factors f :=\n  factors_of_le f le_sup_left P\n#align category_theory.subobject.sup_factors_of_factors_left CategoryTheory.Subobject.sup_factors_of_factors_left\n\ntheorem sup_factors_of_factors_right {A B : C} {X Y : Subobject B} {f : A ⟶ B} (P : Y.Factors f) :\n    (X ⊔ Y).Factors f :=\n  factors_of_le f le_sup_right P\n#align category_theory.subobject.sup_factors_of_factors_right CategoryTheory.Subobject.sup_factors_of_factors_right\n\nvariable [HasInitial C] [InitialMonoClass C]\n\ntheorem finset_sup_factors {I : Type _} {A B : C} {s : Finset I} {P : I → Subobject B} {f : A ⟶ B}\n    (h : ∃ i ∈ s, (P i).Factors f) : (s.sup P).Factors f := by\n  classical\n    revert h\n    apply Finset.induction_on s\n    · rintro ⟨_, ⟨⟨⟩, _⟩⟩\n    · rintro i s nm ih ⟨j, ⟨m, h⟩⟩\n      simp only [Finset.sup_insert]\n      simp at m\n      rcases m with (rfl | m)\n      · exact sup_factors_of_factors_left h\n      · exact sup_factors_of_factors_right (ih ⟨j, ⟨m, h⟩⟩)\n#align category_theory.subobject.finset_sup_factors CategoryTheory.Subobject.finset_sup_factors\n\nend SemilatticeSup\n\nsection Lattice\n\ninstance [HasInitial C] [InitialMonoClass C] {B : C} : BoundedOrder (Subobject B) :=\n  { Subobject.orderTop, Subobject.orderBot with }\n\nvariable [HasPullbacks C] [HasImages C] [HasBinaryCoproducts C]\n\ninstance {B : C} : Lattice (Subobject B) :=\n  { Subobject.semilatticeInf, Subobject.semilatticeSup with }\n\nend Lattice\n\nsection Inf\n\nvariable [WellPowered C]\n\n/-- The \"wide cospan\" diagram, with a small indexing type, constructed from a set of subobjects.\n(This is just the diagram of all the subobjects pasted together, but using `well_powered C`\nto make the diagram small.)\n-/\ndef wideCospan {A : C} (s : Set (Subobject A)) : WidePullbackShape (equivShrink _ '' s) ⥤ C :=\n  WidePullbackShape.wideCospan A\n    (fun j : equivShrink _ '' s => ((equivShrink (Subobject A)).symm j : C)) fun j =>\n    ((equivShrink (Subobject A)).symm j).arrow\n#align category_theory.subobject.wide_cospan CategoryTheory.Subobject.wideCospan\n\n@[simp]\ntheorem wideCospan_map_term {A : C} (s : Set (Subobject A)) (j) :\n    (wideCospan s).map (WidePullbackShape.Hom.term j) =\n      ((equivShrink (Subobject A)).symm j).arrow :=\n  rfl\n#align category_theory.subobject.wide_cospan_map_term CategoryTheory.Subobject.wideCospan_map_term\n\n/-- Auxiliary construction of a cone for `le_Inf`. -/\ndef leInfCone {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈ s, f ≤ g) :\n    Cone (wideCospan s) :=\n  WidePullbackShape.mkCone f.arrow\n    (fun j =>\n      underlying.map\n        (homOfLE\n          (k _\n            (by\n              rcases j with ⟨-, ⟨g, ⟨m, rfl⟩⟩⟩\n              simpa using m))))\n    (by tidy)\n#align category_theory.subobject.le_Inf_cone CategoryTheory.Subobject.leInfCone\n\n@[simp]\ntheorem leInfCone_π_app_none {A : C} (s : Set (Subobject A)) (f : Subobject A)\n    (k : ∀ g ∈ s, f ≤ g) : (leInfCone s f k).π.app none = f.arrow :=\n  rfl\n#align category_theory.subobject.le_Inf_cone_π_app_none CategoryTheory.Subobject.leInfCone_π_app_none\n\nvariable [HasWidePullbacks.{v₁} C]\n\n/-- The limit of `wide_cospan s`. (This will be the supremum of the set of subobjects.)\n-/\ndef widePullback {A : C} (s : Set (Subobject A)) : C :=\n  Limits.limit (wideCospan s)\n#align category_theory.subobject.wide_pullback CategoryTheory.Subobject.widePullback\n\n/-- The inclusion map from `wide_pullback s` to `A`\n-/\ndef widePullbackι {A : C} (s : Set (Subobject A)) : widePullback s ⟶ A :=\n  Limits.limit.π (wideCospan s) none\n#align category_theory.subobject.wide_pullback_ι CategoryTheory.Subobject.widePullbackι\n\ninstance widePullbackι_mono {A : C} (s : Set (Subobject A)) : Mono (widePullbackι s) :=\n  ⟨fun W u v h =>\n    limit.hom_ext fun j => by\n      cases j\n      · exact h\n      · apply (cancel_mono ((equivShrink (subobject A)).symm j).arrow).1\n        rw [assoc, assoc]\n        erw [limit.w (wide_cospan s) (wide_pullback_shape.hom.term j)]\n        exact h⟩\n#align category_theory.subobject.wide_pullback_ι_mono CategoryTheory.Subobject.widePullbackι_mono\n\n/- warning: category_theory.subobject.Inf clashes with category_theory.subobject.inf -> CategoryTheory.Subobject.inf\nwarning: category_theory.subobject.Inf -> CategoryTheory.Subobject.inf is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.WellPowered.{u1, u2} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasWidePullbacks.{u1, u1, u2} C _inst_1] {A : C}, (Set.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A)) -> (CategoryTheory.Subobject.{u1, u2} C _inst_1 A)\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.Limits.HasPullbacks.{u1, u2} C _inst_1] {_inst_4 : C}, CategoryTheory.Functor.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.Functor.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)))) (CategoryTheory.Functor.category.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))))\nCase conversion may be inaccurate. Consider using '#align category_theory.subobject.Inf CategoryTheory.Subobject.infₓ'. -/\n/-- When `[well_powered C]` and `[has_wide_pullbacks C]`, `subobject A` has arbitrary infimums.\n-/\ndef inf {A : C} (s : Set (Subobject A)) : Subobject A :=\n  Subobject.mk (widePullbackι s)\n#align category_theory.subobject.Inf CategoryTheory.Subobject.inf\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (f «expr ∈ » s) -/\ntheorem inf_le {A : C} (s : Set (Subobject A)) (f) (_ : f ∈ s) : inf s ≤ f :=\n  by\n  fapply le_of_comm\n  · refine'\n      (underlying_iso _).Hom ≫\n        limits.limit.π (wide_cospan s)\n            (some ⟨equivShrink _ f, Set.mem_image_of_mem (equivShrink (subobject A)) H⟩) ≫\n          _\n    apply eq_to_hom\n    apply congr_arg fun X : subobject A => (X : C)\n    exact Equiv.symm_apply_apply _ _\n  · dsimp [Inf]\n    simp only [category.comp_id, category.assoc, ← underlying_iso_hom_comp_eq_mk,\n      subobject.arrow_congr, congr_arg_mpr_hom_left, iso.cancel_iso_hom_left]\n    convert limit.w (wide_cospan s) (wide_pullback_shape.hom.term _)\n#align category_theory.subobject.Inf_le CategoryTheory.Subobject.inf_le\n\n/- warning: category_theory.subobject.le_Inf clashes with category_theory.subobject.le_inf -> CategoryTheory.Subobject.le_inf\nwarning: category_theory.subobject.le_Inf -> CategoryTheory.Subobject.le_inf is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.WellPowered.{u1, u2} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasWidePullbacks.{u1, u1, u2} C _inst_1] {A : C} (s : Set.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A)) (f : CategoryTheory.Subobject.{u1, u2} C _inst_1 A), (forall (g : CategoryTheory.Subobject.{u1, u2} C _inst_1 A), (Membership.Mem.{max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A) (Set.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A)) (Set.hasMem.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A)) g s) -> (LE.le.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A) (Preorder.toLE.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A) (PartialOrder.toPreorder.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A) (CategoryTheory.Subobject.partialOrder.{u2, u1} C _inst_1 A))) f g)) -> (LE.le.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A) (Preorder.toLE.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A) (PartialOrder.toPreorder.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A) (CategoryTheory.Subobject.partialOrder.{u2, u1} C _inst_1 A))) f (CategoryTheory.Subobject.inf.{u1, u2} C _inst_1 _inst_3 (fun (J : Type.{u1}) => _inst_4 J) A s))\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.Limits.HasPullbacks.{u1, u2} C _inst_1] {_inst_4 : C} (A : CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (s : CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (f : CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4), (LE.le.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.toLE.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (PartialOrder.toPreorder.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.Subobject.partialOrder.{u2, u1} C _inst_1 _inst_4))) A s) -> (LE.le.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.toLE.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (PartialOrder.toPreorder.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.Subobject.partialOrder.{u2, u1} C _inst_1 _inst_4))) A f) -> (LE.le.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.toLE.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (PartialOrder.toPreorder.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.Subobject.partialOrder.{u2, u1} C _inst_1 _inst_4))) A (CategoryTheory.Functor.obj.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.Functor.obj.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.Functor.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_4) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)))) (CategoryTheory.Functor.category.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4))) (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_4) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_4)))) (CategoryTheory.Subobject.inf.{u1, u2} C _inst_1 _inst_3 _inst_4) s) f))\nCase conversion may be inaccurate. Consider using '#align category_theory.subobject.le_Inf CategoryTheory.Subobject.le_infₓ'. -/\ntheorem le_inf {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈ s, f ≤ g) : f ≤ inf s :=\n  by\n  fapply le_of_comm\n  · exact limits.limit.lift _ (le_Inf_cone s f k) ≫ (underlying_iso _).inv\n  · dsimp [Inf, wide_pullback_ι]\n    simp\n#align category_theory.subobject.le_Inf CategoryTheory.Subobject.le_inf\n\ninstance {B : C} : CompleteSemilatticeInf (Subobject B) :=\n  { Subobject.partialOrder B with\n    infₛ := inf\n    inf_le := inf_le\n    le_inf := le_inf }\n\nend Inf\n\nsection Sup\n\nvariable [WellPowered C] [HasCoproducts.{v₁} C]\n\n/-- The univesal morphism out of the coproduct of a set of subobjects,\nafter using `[well_powered C]` to reindex by a small type.\n-/\ndef smallCoproductDesc {A : C} (s : Set (Subobject A)) : _ ⟶ A :=\n  Limits.Sigma.desc fun j : equivShrink _ '' s => ((equivShrink (Subobject A)).symm j).arrow\n#align category_theory.subobject.small_coproduct_desc CategoryTheory.Subobject.smallCoproductDesc\n\nvariable [HasImages C]\n\n/- warning: category_theory.subobject.Sup clashes with category_theory.subobject.sup -> CategoryTheory.Subobject.sup\nwarning: category_theory.subobject.Sup -> CategoryTheory.Subobject.sup is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.WellPowered.{u1, u2} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasCoproducts.{u1, u1, u2} C _inst_1] [_inst_5 : CategoryTheory.Limits.HasImages.{u1, u2} C _inst_1] {A : C}, (Set.{max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 A)) -> (CategoryTheory.Subobject.{u1, u2} C _inst_1 A)\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.Limits.HasImages.{u1, u2} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasBinaryCoproducts.{u1, u2} C _inst_1] {_inst_5 : C}, CategoryTheory.Functor.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_5) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5))) (CategoryTheory.Functor.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_5) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5))) (CategoryTheory.Subobject.{u1, u2} C _inst_1 _inst_5) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)))) (CategoryTheory.Functor.category.{max u2 u1, max u2 u1, max u2 u1, max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5))) (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)) (Preorder.smallCategory.{max u2 u1} (CategoryTheory.ThinSkeleton.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5)) (CategoryTheory.ThinSkeleton.preorder.{u1, max u2 u1} (CategoryTheory.MonoOver.{u1, u2} C _inst_1 _inst_5) (CategoryTheory.MonoOver.category.{u2, u1} C _inst_1 _inst_5))))\nCase conversion may be inaccurate. Consider using '#align category_theory.subobject.Sup CategoryTheory.Subobject.supₓ'. -/\n/-- When `[well_powered C] [has_images C] [has_coproducts C]`,\n`subobject A` has arbitrary supremums. -/\ndef sup {A : C} (s : Set (Subobject A)) : Subobject A :=\n  Subobject.mk (image.ι (smallCoproductDesc s))\n#align category_theory.subobject.Sup CategoryTheory.Subobject.sup\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (f «expr ∈ » s) -/\ntheorem le_sup {A : C} (s : Set (Subobject A)) (f) (_ : f ∈ s) : f ≤ sup s :=\n  by\n  fapply le_of_comm\n  · dsimp [Sup]\n    refine' _ ≫ factor_thru_image _ ≫ (underlying_iso _).inv\n    refine' _ ≫ sigma.ι _ ⟨equivShrink _ f, by simpa [Set.mem_image] using H⟩\n    exact eq_to_hom (congr_arg (fun X : subobject A => (X : C)) (Equiv.symm_apply_apply _ _).symm)\n  · dsimp [Sup, small_coproduct_desc]\n    simp\n    dsimp\n    simp\n#align category_theory.subobject.le_Sup CategoryTheory.Subobject.le_sup\n\ntheorem symm_apply_mem_iff_mem_image {α β : Type _} (e : α ≃ β) (s : Set α) (x : β) :\n    e.symm x ∈ s ↔ x ∈ e '' s :=\n  ⟨fun h => ⟨e.symm x, h, by simp⟩, by\n    rintro ⟨a, m, rfl⟩\n    simpa using m⟩\n#align category_theory.subobject.symm_apply_mem_iff_mem_image CategoryTheory.Subobject.symm_apply_mem_iff_mem_image\n\ntheorem sup_le {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈ s, g ≤ f) : sup s ≤ f :=\n  by\n  fapply le_of_comm\n  · dsimp [Sup]\n    refine' (underlying_iso _).Hom ≫ image.lift ⟨_, f.arrow, _, _⟩\n    · refine' sigma.desc _\n      rintro ⟨g, m⟩\n      refine' underlying.map (hom_of_le (k _ _))\n      simpa [symm_apply_mem_iff_mem_image] using m\n    · ext j\n      rcases j with ⟨j, m⟩\n      dsimp [small_coproduct_desc]\n      simp\n      dsimp\n      simp\n  · dsimp [Sup]\n    simp\n#align category_theory.subobject.Sup_le CategoryTheory.Subobject.sup_le\n\ninstance {B : C} : CompleteSemilatticeSup (Subobject B) :=\n  { Subobject.partialOrder B with\n    supₛ := sup\n    le_sup := le_sup\n    sup_le := sup_le }\n\nend Sup\n\nsection CompleteLattice\n\nvariable [WellPowered C] [HasWidePullbacks.{v₁} C] [HasImages C] [HasCoproducts.{v₁} C]\n  [InitialMonoClass C]\n\nattribute [local instance] has_smallest_coproducts_of_has_coproducts\n\ninstance {B : C} : CompleteLattice (Subobject B) :=\n  { Subobject.semilatticeInf, Subobject.semilatticeSup, Subobject.boundedOrder,\n    Subobject.completeSemilatticeInf, Subobject.completeSemilatticeSup with }\n\nend CompleteLattice\n\nsection ZeroObject\n\nvariable [HasZeroMorphisms C] [HasZeroObject C]\n\nopen ZeroObject\n\n/-- A nonzero object has nontrivial subobject lattice. -/\ntheorem nontrivial_of_not_isZero {X : C} (h : ¬IsZero X) : Nontrivial (Subobject X) :=\n  ⟨⟨mk (0 : 0 ⟶ X), mk (𝟙 X), fun w => h (IsZero.of_iso (isZero_zero C) (isoOfMkEqMk _ _ w).symm)⟩⟩\n#align category_theory.subobject.nontrivial_of_not_is_zero CategoryTheory.Subobject.nontrivial_of_not_isZero\n\nend ZeroObject\n\nsection SubobjectSubobject\n\n/-- The subobject lattice of a subobject `Y` is order isomorphic to the interval `set.Iic Y`. -/\ndef subobjectOrderIso {X : C} (Y : Subobject X) : Subobject (Y : C) ≃o Set.Iic Y\n    where\n  toFun Z :=\n    ⟨Subobject.mk (Z.arrow ≫ Y.arrow),\n      Set.mem_Iic.mpr (le_of_comm ((underlyingIso _).Hom ≫ Z.arrow) (by simp))⟩\n  invFun Z := Subobject.mk (ofLe _ _ Z.2)\n  left_inv Z :=\n    mk_eq_of_comm _ (underlyingIso _)\n      (by\n        ext\n        simp)\n  right_inv Z :=\n    Subtype.ext\n      (mk_eq_of_comm _ (underlyingIso _)\n        (by\n          dsimp\n          simp [← iso.eq_inv_comp]))\n  map_rel_iff' W Z :=\n    ⟨fun h =>\n      le_of_comm ((underlyingIso _).inv ≫ ofLe _ _ (Subtype.mk_le_mk.mp h) ≫ (underlyingIso _).Hom)\n        (by\n          ext\n          simp),\n      fun h =>\n      Subtype.mk_le_mk.mpr\n        (le_of_comm ((underlyingIso _).Hom ≫ ofLe _ _ h ≫ (underlyingIso _).inv) (by simp))⟩\n#align category_theory.subobject.subobject_order_iso CategoryTheory.Subobject.subobjectOrderIso\n\nend SubobjectSubobject\n\nend Subobject\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Subobject/Lattice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.49332192158128924}}
{"text": "/-\nCopyright (c) 2017 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module data.pfunctor.univariate.M\n! leanprover-community/mathlib commit 8631e2d5ea77f6c13054d9151d82b83069680cb1\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.PFunctor.Univariate.Basic\n\n/-!\n# M-types\n\nM types are potentially infinite tree-like structures. They are defined\nas the greatest fixpoint of a polynomial functor.\n-/\n\n\nuniverse u v w\n\nopen Nat Function\n\nopen List\n\nvariable (F : PFunctor.{u})\n\n-- porting note: the ♯ tactic is never used\n-- local prefix:0 \"♯\" => cast (by first |simp [*]|cc|solve_by_elim)\n\nnamespace PFunctor\n\nnamespace Approx\n\n/-- `CofixA F n` is an `n` level approximation of an M-type -/\ninductive CofixA : ℕ → Type u\n  | continue : CofixA 0\n  | intro {n} : ∀ a, (F.B a → CofixA n) → CofixA (succ n)\n#align pfunctor.approx.cofix_a PFunctor.Approx.CofixA\n\n/-- default inhabitant of `CofixA` -/\nprotected def CofixA.default [Inhabited F.A] : ∀ n, CofixA F n\n  | 0 => CofixA.continue\n  | succ n => CofixA.intro default fun _ => CofixA.default n\n#align pfunctor.approx.cofix_a.default PFunctor.Approx.CofixA.default\n\ninstance [Inhabited F.A] {n} : Inhabited (CofixA F n) :=\n  ⟨CofixA.default F n⟩\n\ntheorem cofixA_eq_zero : ∀ x y : CofixA F 0, x = y\n  | CofixA.continue, CofixA.continue => rfl\n#align pfunctor.approx.cofix_a_eq_zero PFunctor.Approx.cofixA_eq_zero\n\nvariable {F}\n\n/-- The label of the root of the tree for a non-trivial\napproximation of the cofix of a pfunctor.\n-/\ndef head' : ∀ {n}, CofixA F (succ n) → F.A\n  | _, CofixA.intro i _ => i\n#align pfunctor.approx.head' PFunctor.Approx.head'\n\n/-- for a non-trivial approximation, return all the subtrees of the root -/\ndef children' : ∀ {n} (x : CofixA F (succ n)), F.B (head' x) → CofixA F n\n  | _, CofixA.intro _ f => f\n#align pfunctor.approx.children' PFunctor.Approx.children'\n\ntheorem approx_eta {n : ℕ} (x : CofixA F (n + 1)) : x = CofixA.intro (head' x) (children' x) := by\n  cases x; rfl\n#align pfunctor.approx.approx_eta PFunctor.Approx.approx_eta\n\n/-- Relation between two approximations of the cofix of a pfunctor\nthat state they both contain the same data until one of them is truncated -/\ninductive Agree : ∀ {n : ℕ}, CofixA F n → CofixA F (n + 1) → Prop\n  | continu (x : CofixA F 0) (y : CofixA F 1) : Agree x y\n  | intro {n} {a} (x : F.B a → CofixA F n) (x' : F.B a → CofixA F (n + 1)) :\n    (∀ i : F.B a, Agree (x i) (x' i)) → Agree (CofixA.intro a x) (CofixA.intro a x')\n#align pfunctor.approx.agree PFunctor.Approx.Agree\n\n/-- Given an infinite series of approximations `approx`,\n`AllAgree approx` states that they are all consistent with each other.\n-/\ndef AllAgree (x : ∀ n, CofixA F n) :=\n  ∀ n, Agree (x n) (x (succ n))\n#align pfunctor.approx.all_agree PFunctor.Approx.AllAgree\n\n@[simp]\ntheorem agree_trival {x : CofixA F 0} {y : CofixA F 1} : Agree x y := by constructor\n#align pfunctor.approx.agree_trival PFunctor.Approx.agree_trival\n\ntheorem agree_children {n : ℕ} (x : CofixA F (succ n)) (y : CofixA F (succ n + 1)) {i j}\n    (h₀ : HEq i j) (h₁ : Agree x y) : Agree (children' x i) (children' y j) := by\n  cases' h₁ with _ _ _ _ _ _ hagree; cases h₀\n  apply hagree\n#align pfunctor.approx.agree_children PFunctor.Approx.agree_children\n\n/-- `truncate a` turns `a` into a more limited approximation -/\ndef truncate : ∀ {n : ℕ}, CofixA F (n + 1) → CofixA F n\n  | 0, CofixA.intro _ _ => CofixA.continue\n  | succ _, CofixA.intro i f => CofixA.intro i <| truncate ∘ f\n#align pfunctor.approx.truncate PFunctor.Approx.truncate\n\ntheorem truncate_eq_of_agree {n : ℕ} (x : CofixA F n) (y : CofixA F (succ n)) (h : Agree x y) :\n    truncate y = x := by\n  induction n <;> cases x <;> cases y\n  · rfl\n  · -- cases' h with _ _ _ _ _ h₀ h₁\n    cases h\n    simp only [truncate, Function.comp, true_and_iff, eq_self_iff_true, heq_iff_eq]\n    -- porting note: used to be `ext y`\n    rename_i n_ih a f y h₁\n    suffices (fun x => truncate (y x)) = f\n      by simp [this]; try (exact HEq.rfl;)\n    funext y\n\n    apply n_ih\n    apply h₁\n#align pfunctor.approx.truncate_eq_of_agree PFunctor.Approx.truncate_eq_of_agree\n\nvariable {X : Type w}\n\nvariable (f : X → F.Obj X)\n\n/-- `sCorec f i n` creates an approximation of height `n`\nof the final coalgebra of `f` -/\ndef sCorec : X → ∀ n, CofixA F n\n  | _, 0 => CofixA.continue\n  | j, succ _ => CofixA.intro (f j).1 fun i => sCorec ((f j).2 i) _\n#align pfunctor.approx.s_corec PFunctor.Approx.sCorec\n\ntheorem P_corec (i : X) (n : ℕ) : Agree (sCorec f i n) (sCorec f i (succ n)) := by\n  induction' n with n n_ih generalizing i\n  constructor\n  cases' h : f i with y g\n  constructor\n  introv\n  apply n_ih\nset_option linter.uppercaseLean3 false in\n#align pfunctor.approx.P_corec PFunctor.Approx.P_corec\n\n/-- `Path F` provides indices to access internal nodes in `Corec F` -/\ndef Path (F : PFunctor.{u}) :=\n  List F.IdxCat\n#align pfunctor.approx.path PFunctor.Approx.Path\n\ninstance Path.inhabited : Inhabited (Path F) :=\n  ⟨[]⟩\n#align pfunctor.approx.path.inhabited PFunctor.Approx.Path.inhabited\n\nopen List Nat\n\ninstance CofixA.instSubsingleton : Subsingleton (CofixA F 0) :=\n  ⟨by rintro ⟨⟩ ⟨⟩; rfl⟩\n\ntheorem head_succ' (n m : ℕ) (x : ∀ n, CofixA F n) (Hconsistent : AllAgree x) :\n    head' (x (succ n)) = head' (x (succ m)) := by\n  suffices ∀ n, head' (x (succ n)) = head' (x 1) by simp [this]\n  clear m n\n  intro n\n  cases' h₀ : x (succ n) with _ i₀ f₀\n  cases' h₁ : x 1 with _ i₁ f₁\n  dsimp only [head']\n  induction' n with n n_ih\n  · rw [h₁] at h₀\n    cases h₀\n    trivial\n  · have H := Hconsistent (succ n)\n    cases' h₂ : x (succ n) with _ i₂ f₂\n    rw [h₀, h₂] at H\n    apply n_ih (truncate ∘ f₀)\n    rw [h₂]\n    cases' H with _ _ _ _ _ _ hagree\n    congr\n    funext j\n    dsimp only [comp_apply]\n    rw [truncate_eq_of_agree]\n    apply hagree\n#align pfunctor.approx.head_succ' PFunctor.Approx.head_succ'\n\nend Approx\n\nopen Approx\n\n/-- Internal definition for `M`. It is needed to avoid name clashes\nbetween `M.mk` and `M.cases_on` and the declarations generated for\nthe structure -/\nstructure MIntl where\n  /-- An `n`-th level approximation, for each depth `n` -/\n  approx : ∀ n, CofixA F n\n  /-- Each approximation agrees with the next -/\n  consistent : AllAgree approx\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M_intl PFunctor.MIntl\n\n/-- For polynomial functor `F`, `M F` is its final coalgebra -/\ndef M :=\n  MIntl F\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M PFunctor.M\n\ntheorem M.default_consistent [Inhabited F.A] : ∀ n, Agree (default : CofixA F n) default\n  | 0 => Agree.continu _ _\n  | succ n => Agree.intro _ _ fun _ => M.default_consistent n\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.default_consistent PFunctor.M.default_consistent\n\ninstance M.inhabited [Inhabited F.A] : Inhabited (M F) :=\n  ⟨{  approx := default\n      consistent := M.default_consistent _ }⟩\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.inhabited PFunctor.M.inhabited\n\ninstance MIntl.inhabited [Inhabited F.A] : Inhabited (MIntl F) :=\n  show Inhabited (M F) by infer_instance\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M_intl.inhabited PFunctor.MIntl.inhabited\n\nnamespace M\n\ntheorem ext' (x y : M F) (H : ∀ i : ℕ, x.approx i = y.approx i) : x = y := by\n  cases x\n  cases y\n  congr with n\n  apply H\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.ext' PFunctor.M.ext'\n\nvariable {X : Type _}\n\nvariable (f : X → F.Obj X)\n\nvariable {F}\n\n/-- Corecursor for the M-type defined by `F`. -/\nprotected def corec (i : X) : M F where\n  approx := sCorec f i\n  consistent := P_corec _ _\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec PFunctor.M.corec\n\n/-- given a tree generated by `F`, `head` gives us the first piece of data\nit contains -/\ndef head (x : M F) :=\n  head' (x.1 1)\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.head PFunctor.M.head\n\n/-- return all the subtrees of the root of a tree `x : M F` -/\ndef children (x : M F) (i : F.B (head x)) : M F :=\n  let H := fun n : ℕ => @head_succ' _ n 0 x.1 x.2\n  { approx := fun n => children' (x.1 _) (cast (congr_arg _ <| by simp only [head, H]) i)\n    consistent := by\n      intro n\n      have P' := x.2 (succ n)\n      apply agree_children _ _ _ P'\n      trans i\n      apply cast_heq\n      symm\n      apply cast_heq }\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.children PFunctor.M.children\n\n/-- select a subtree using a `i : F.Idx` or return an arbitrary tree if\n`i` designates no subtree of `x` -/\ndef ichildren [Inhabited (M F)] [DecidableEq F.A] (i : F.IdxCat) (x : M F) : M F :=\n  if H' : i.1 = head x then children x (cast (congr_arg _ <| by simp only [head, H']) i.2)\n  else default\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.ichildren PFunctor.M.ichildren\n\ntheorem head_succ (n m : ℕ) (x : M F) : head' (x.approx (succ n)) = head' (x.approx (succ m)) :=\n  head_succ' n m _ x.consistent\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.head_succ PFunctor.M.head_succ\n\ntheorem head_eq_head' : ∀ (x : M F) (n : ℕ), head x = head' (x.approx <| n + 1)\n  | ⟨_, h⟩, _ => head_succ' _ _ _ h\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.head_eq_head' PFunctor.M.head_eq_head'\n\ntheorem head'_eq_head : ∀ (x : M F) (n : ℕ), head' (x.approx <| n + 1) = head x\n  | ⟨_, h⟩, _ => head_succ' _ _ _ h\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.head'_eq_head PFunctor.M.head'_eq_head\n\ntheorem truncate_approx (x : M F) (n : ℕ) : truncate (x.approx <| n + 1) = x.approx n :=\n  truncate_eq_of_agree _ _ (x.consistent _)\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.truncate_approx PFunctor.M.truncate_approx\n\n/-- unfold an M-type -/\ndef dest : M F → F.Obj (M F)\n  | x => ⟨head x, fun i => children x i⟩\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.dest PFunctor.M.dest\n\nnamespace Approx\n\n/-- generates the approximations needed for `M.mk` -/\nprotected def sMk (x : F.Obj <| M F) : ∀ n, CofixA F n\n  | 0 => CofixA.continue\n  | succ n => CofixA.intro x.1 fun i => (x.2 i).approx n\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.approx.s_mk PFunctor.M.Approx.sMk\n\nprotected theorem P_mk (x : F.Obj <| M F) : AllAgree (Approx.sMk x)\n  | 0 => by constructor\n  | succ n => by\n    constructor\n    introv\n    apply (x.2 i).consistent\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.approx.P_mk PFunctor.M.Approx.P_mk\n\nend Approx\n\n/-- constructor for M-types -/\nprotected def mk (x : F.Obj <| M F) : M F\n    where\n  approx := Approx.sMk x\n  consistent := Approx.P_mk x\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.mk PFunctor.M.mk\n\n/-- `Agree' n` relates two trees of type `M F` that\nare the same up to dept `n` -/\ninductive Agree' : ℕ → M F → M F → Prop\n  | trivial (x y : M F) : Agree' 0 x y\n  | step {n : ℕ} {a} (x y : F.B a → M F) {x' y'} :\n      x' = M.mk ⟨a, x⟩ → y' = M.mk ⟨a, y⟩ → (∀ i, Agree' n (x i) (y i)) → Agree' (succ n) x' y'\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.agree' PFunctor.M.Agree'\n\n@[simp]\ntheorem dest_mk (x : F.Obj <| M F) : dest (M.mk x) = x := by rfl\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.dest_mk PFunctor.M.dest_mk\n\n@[simp]\n\n\ntheorem mk_inj {x y : F.Obj <| M F} (h : M.mk x = M.mk y) : x = y := by rw [← dest_mk x, h, dest_mk]\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.mk_inj PFunctor.M.mk_inj\n\n/-- destructor for M-types -/\nprotected def cases {r : M F → Sort w} (f : ∀ x : F.Obj <| M F, r (M.mk x)) (x : M F) : r x :=\n  suffices r (M.mk (dest x)) by\n    rw [← mk_dest x]\n    exact this\n  f _\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.cases PFunctor.M.cases\n\n/-- destructor for M-types -/\nprotected def casesOn {r : M F → Sort w} (x : M F) (f : ∀ x : F.Obj <| M F, r (M.mk x)) : r x :=\n  M.cases f x\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.cases_on PFunctor.M.casesOn\n\n/-- destructor for M-types, similar to `casesOn` but also\ngives access directly to the root and subtrees on an M-type -/\nprotected def casesOn' {r : M F → Sort w} (x : M F) (f : ∀ a f, r (M.mk ⟨a, f⟩)) : r x :=\n  M.casesOn x (fun ⟨a, g⟩ => f a g)\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.cases_on' PFunctor.M.casesOn'\n\ntheorem approx_mk (a : F.A) (f : F.B a → M F) (i : ℕ) :\n    (M.mk ⟨a, f⟩).approx (succ i) = CofixA.intro a fun j => (f j).approx i :=\n  rfl\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.approx_mk PFunctor.M.approx_mk\n\n@[simp]\ntheorem agree'_refl {n : ℕ} (x : M F) : Agree' n x x := by\n  induction' n with _ n_ih generalizing x <;>\n  induction x using PFunctor.M.casesOn' <;> constructor <;> try rfl\n  intros\n  apply n_ih\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.agree'_refl PFunctor.M.agree'_refl\n\ntheorem agree_iff_agree' {n : ℕ} (x y : M F) :\n    Agree (x.approx n) (y.approx <| n + 1) ↔ Agree' n x y := by\n  constructor <;> intro h\n  · induction' n with _ n_ih generalizing x y\n    constructor\n    · induction x using PFunctor.M.casesOn'\n      induction y using PFunctor.M.casesOn'\n      simp only [approx_mk] at h\n      cases' h with _ _ _ _ _ _ hagree\n      constructor <;> try rfl\n      intro i\n      apply n_ih\n      apply hagree\n  · induction' n with _ n_ih generalizing x y\n    constructor\n    · cases' h with _ _ _ a x' y'\n      induction' x using PFunctor.M.casesOn' with x_a x_f\n      induction' y using PFunctor.M.casesOn' with y_a y_f\n      simp only [approx_mk]\n      have h_a_1 := mk_inj ‹M.mk ⟨x_a, x_f⟩ = M.mk ⟨a, x'⟩›\n      cases h_a_1\n      replace h_a_2 := mk_inj ‹M.mk ⟨y_a, y_f⟩ = M.mk ⟨a, y'⟩›\n      cases h_a_2\n      constructor\n      intro i\n      apply n_ih\n      simp [*]\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.agree_iff_agree' PFunctor.M.agree_iff_agree'\n\n@[simp]\ntheorem cases_mk {r : M F → Sort _} (x : F.Obj <| M F) (f : ∀ x : F.Obj <| M F, r (M.mk x)) :\n    PFunctor.M.cases f (M.mk x) = f x := by\n  dsimp only [M.mk, PFunctor.M.cases, dest, head, Approx.sMk, head']\n  cases x; dsimp only [Approx.sMk]\n  simp only [Eq.mpr]\n  apply congrFun\n  rfl\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.cases_mk PFunctor.M.cases_mk\n\n@[simp]\ntheorem casesOn_mk {r : M F → Sort _} (x : F.Obj <| M F) (f : ∀ x : F.Obj <| M F, r (M.mk x)) :\n    PFunctor.M.casesOn (M.mk x) f = f x :=\n  cases_mk x f\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.cases_on_mk PFunctor.M.casesOn_mk\n\n@[simp]\ntheorem casesOn_mk' {r : M F → Sort _} {a} (x : F.B a → M F)\n                    (f : ∀ (a) (f : F.B a → M F), r (M.mk ⟨a, f⟩)) :\n    PFunctor.M.casesOn' (M.mk ⟨a, x⟩) f = f a x :=\n  @cases_mk F r ⟨a, x⟩ (fun ⟨a, g⟩ => f a g)\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.cases_on_mk' PFunctor.M.casesOn_mk'\n\n/-- `IsPath p x` tells us if `p` is a valid path through `x` -/\ninductive IsPath : Path F → M F → Prop\n  | nil (x : M F) : IsPath [] x\n  |\n  cons (xs : Path F) {a} (x : M F) (f : F.B a → M F) (i : F.B a) :\n    x = M.mk ⟨a, f⟩ → IsPath xs (f i) → IsPath (⟨a, i⟩ :: xs) x\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.is_path PFunctor.M.IsPath\n\ntheorem isPath_cons {xs : Path F} {a a'} {f : F.B a → M F} {i : F.B a'} :\n    IsPath (⟨a', i⟩ :: xs) (M.mk ⟨a, f⟩) → a = a' := by\n  generalize h : M.mk ⟨a, f⟩ = x\n  rintro (_ | ⟨_, _, _, _, rfl, _⟩)\n  cases mk_inj h\n  rfl\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.is_path_cons PFunctor.M.isPath_cons\n\ntheorem isPath_cons' {xs : Path F} {a} {f : F.B a → M F} {i : F.B a} :\n    IsPath (⟨a, i⟩ :: xs) (M.mk ⟨a, f⟩) → IsPath xs (f i) := by\n  generalize h : M.mk ⟨a, f⟩ = x\n  rintro (_ | ⟨_, _, _, _, rfl, hp⟩)\n  cases mk_inj h\n  exact hp\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.is_path_cons' PFunctor.M.isPath_cons'\n\n/-- follow a path through a value of `M F` and return the subtree\nfound at the end of the path if it is a valid path for that value and\nreturn a default tree -/\ndef isubtree [DecidableEq F.A] [Inhabited (M F)] : Path F → M F → M F\n  | [], x => x\n  | ⟨a, i⟩ :: ps, x =>\n    PFunctor.M.casesOn' (r := fun _ => M F) x (fun a' f =>\n      if h : a = a' then\n        isubtree ps (f <| cast (by rw [h]) i)\n      else\n        default (α := M F)\n    )\n\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.isubtree PFunctor.M.isubtree\n\n/-- similar to `isubtree` but returns the data at the end of the path instead\nof the whole subtree -/\ndef iselect [DecidableEq F.A] [Inhabited (M F)] (ps : Path F) : M F → F.A := fun x : M F =>\n  head <| isubtree ps x\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.iselect PFunctor.M.iselect\n\ntheorem iselect_eq_default [DecidableEq F.A] [Inhabited (M F)] (ps : Path F) (x : M F)\n    (h : ¬IsPath ps x) : iselect ps x = head default := by\n  induction' ps with ps_hd ps_tail ps_ih generalizing x\n  · exfalso\n    apply h\n    constructor\n  · cases' ps_hd with a i\n    induction' x using PFunctor.M.casesOn' with x_a x_f\n    simp only [iselect, isubtree] at ps_ih⊢\n    by_cases h'' : a = x_a\n    subst x_a\n    · simp only [dif_pos, eq_self_iff_true, casesOn_mk']\n      rw [ps_ih]\n      intro h'\n      apply h\n      constructor <;> try rfl\n      apply h'\n    · simp [*]\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.iselect_eq_default PFunctor.M.iselect_eq_default\n\n@[simp]\ntheorem head_mk (x : F.Obj (M F)) : head (M.mk x) = x.1 :=\n  Eq.symm <|\n    calc\n      x.1 = (dest (M.mk x)).1 := by rw [dest_mk]\n      _ = head (M.mk x) := by rfl\n\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.head_mk PFunctor.M.head_mk\n\ntheorem children_mk {a} (x : F.B a → M F) (i : F.B (head (M.mk ⟨a, x⟩))) :\n    children (M.mk ⟨a, x⟩) i = x (cast (by rw [head_mk]) i) := by apply ext'; intro n; rfl\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.children_mk PFunctor.M.children_mk\n\n@[simp]\ntheorem ichildren_mk [DecidableEq F.A] [Inhabited (M F)] (x : F.Obj (M F)) (i : F.IdxCat) :\n    ichildren i (M.mk x) = x.iget i := by\n  dsimp only [ichildren, PFunctor.Obj.iget]\n  congr with h\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.ichildren_mk PFunctor.M.ichildren_mk\n\n@[simp]\ntheorem isubtree_cons [DecidableEq F.A] [Inhabited (M F)] (ps : Path F) {a} (f : F.B a → M F)\n    {i : F.B a} : isubtree (⟨_, i⟩ :: ps) (M.mk ⟨a, f⟩) = isubtree ps (f i) := by\n  simp only [isubtree, ichildren_mk, PFunctor.Obj.iget, dif_pos, isubtree, M.casesOn_mk']; rfl\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.isubtree_cons PFunctor.M.isubtree_cons\n\n@[simp]\ntheorem iselect_nil [DecidableEq F.A] [Inhabited (M F)] {a} (f : F.B a → M F) :\n    iselect nil (M.mk ⟨a, f⟩) = a := by rfl\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.iselect_nil PFunctor.M.iselect_nil\n\n@[simp]\ntheorem iselect_cons [DecidableEq F.A] [Inhabited (M F)] (ps : Path F) {a} (f : F.B a → M F) {i} :\n    iselect (⟨a, i⟩ :: ps) (M.mk ⟨a, f⟩) = iselect ps (f i) := by simp only [iselect, isubtree_cons]\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.iselect_cons PFunctor.M.iselect_cons\n\ntheorem corec_def {X} (f : X → F.Obj X) (x₀ : X) : M.corec f x₀ = M.mk (M.corec f <$> f x₀) := by\n  dsimp only [M.corec, M.mk]\n  congr with n\n  cases' n with n\n  · dsimp only [sCorec, Approx.sMk]\n  · dsimp only [sCorec, Approx.sMk]\n    cases h : f x₀\n    dsimp only [(· <$> ·), PFunctor.map]\n    congr\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec_def PFunctor.M.corec_def\n\ntheorem ext_aux [Inhabited (M F)] [DecidableEq F.A] {n : ℕ} (x y z : M F) (hx : Agree' n z x)\n    (hy : Agree' n z y) (hrec : ∀ ps : Path F, n = ps.length → iselect ps x = iselect ps y) :\n    x.approx (n + 1) = y.approx (n + 1) := by\n  induction' n with n n_ih generalizing x y z\n  · specialize hrec [] rfl\n    induction x using PFunctor.M.casesOn'\n    induction y using PFunctor.M.casesOn'\n    simp only [iselect_nil] at hrec\n    subst hrec\n    simp only [approx_mk, true_and_iff, eq_self_iff_true, heq_iff_eq, zero_eq, CofixA.intro.injEq,\n                heq_eq_eq, eq_iff_true_of_subsingleton, and_self]\n  · cases hx\n    cases hy\n    induction x using PFunctor.M.casesOn'\n    induction y using PFunctor.M.casesOn'\n    subst z\n    iterate 3 (have := mk_inj ‹_›; cases this)\n    rename_i n_ih a f₃ f₂ hAgree₂ _ _ h₂ _ _ f₁ h₁ hAgree₁ clr\n    simp only [approx_mk, true_and_iff, eq_self_iff_true, heq_iff_eq]\n\n    have := mk_inj h₁\n    cases this; clear h₁\n    have := mk_inj h₂\n    cases this; clear h₂\n\n    congr\n    ext i\n    apply n_ih\n    · solve_by_elim\n    · solve_by_elim\n    introv h\n    specialize hrec (⟨_, i⟩ :: ps) (congr_arg _ h)\n    simp only [iselect_cons] at hrec\n    exact hrec\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.ext_aux PFunctor.M.ext_aux\n\nopen PFunctor.Approx\n\nattribute [local instance] Classical.propDecidable\n\ntheorem ext [Inhabited (M F)] (x y : M F) (H : ∀ ps : Path F, iselect ps x = iselect ps y) :\n    x = y := by\n  apply ext'; intro i\n  induction' i with i i_ih\n  · cases x.approx 0\n    cases y.approx 0\n    constructor\n  · apply ext_aux x y x\n    · rw [← agree_iff_agree']\n      apply x.consistent\n    · rw [← agree_iff_agree', i_ih]\n      apply y.consistent\n    introv H'\n    dsimp only [iselect] at H\n    cases H'\n    apply H ps\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.ext PFunctor.M.ext\n\nsection Bisim\n\nvariable (R : M F → M F → Prop)\n\nlocal infixl:50 \" ~ \" => R\n\n/-- Bisimulation is the standard proof technique for equality between\ninfinite tree-like structures -/\nstructure IsBisimulation : Prop where\n  /-- The head of the trees are equal -/\n  head : ∀ {a a'} {f f'}, M.mk ⟨a, f⟩ ~ M.mk ⟨a', f'⟩ → a = a'\n  /-- The tails are equal -/\n  tail : ∀ {a} {f f' : F.B a → M F}, M.mk ⟨a, f⟩ ~ M.mk ⟨a, f'⟩ → ∀ i : F.B a, f i ~ f' i\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.is_bisimulation PFunctor.M.IsBisimulation\n\ntheorem nth_of_bisim [Inhabited (M F)] (bisim : IsBisimulation R) (s₁ s₂) (ps : Path F) :\n    (R s₁ s₂) →\n      IsPath ps s₁ ∨ IsPath ps s₂ →\n        iselect ps s₁ = iselect ps s₂ ∧\n          ∃ (a : _)(f f' : F.B a → M F),\n            isubtree ps s₁ = M.mk ⟨a, f⟩ ∧\n              isubtree ps s₂ = M.mk ⟨a, f'⟩ ∧ ∀ i : F.B a, f i ~ f' i := by\n  intro h₀ hh\n  induction' s₁ using PFunctor.M.casesOn' with a f\n  rename_i h₁ hh₁\n  induction' s₂ using PFunctor.M.casesOn' with a' f'\n  rename_i h₁' hh₁' h₂ hh₂\n  clear h₁ hh₁ h₂ hh₂ hh₁'\n  obtain rfl : a = a' := bisim.head h₀\n  induction' ps with i ps ps_ih generalizing a f f'\n  · exists rfl, a, f, f', rfl, rfl\n    apply bisim.tail h₀\n  cases' i with a' i\n  obtain rfl : a = a' := by rcases hh with hh|hh <;> cases isPath_cons hh <;> rfl\n  dsimp only [iselect] at ps_ih⊢\n  have h₁ := bisim.tail h₀ i\n  induction' h : f i using PFunctor.M.casesOn' with a₀ f₀\n  induction' h' : f' i using PFunctor.M.casesOn' with a₁ f₁\n  simp only [h, h', isubtree_cons] at ps_ih⊢\n  rw [h, h'] at h₁\n  obtain rfl : a₀ = a₁ := bisim.head h₁\n  apply ps_ih _ _ _ h₁\n  rw [← h, ← h']\n  apply Or.imp isPath_cons' isPath_cons' hh\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.nth_of_bisim PFunctor.M.nth_of_bisim\n\ntheorem eq_of_bisim [Nonempty (M F)] (bisim : IsBisimulation R) : ∀ s₁ s₂, R s₁ s₂ → s₁ = s₂ := by\n  inhabit M F\n  introv Hr; apply ext\n  introv\n  by_cases h : IsPath ps s₁ ∨ IsPath ps s₂\n  · have H := nth_of_bisim R bisim _ _ ps Hr h\n    exact H.left\n  · rw [not_or] at h\n    cases' h with h₀ h₁\n    simp only [iselect_eq_default, *, not_false_iff]\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.eq_of_bisim PFunctor.M.eq_of_bisim\n\nend Bisim\n\nuniverse u' v'\n\n/-- corecursor for `M F` with swapped arguments -/\ndef corecOn {X : Type _} (x₀ : X) (f : X → F.Obj X) : M F :=\n  M.corec f x₀\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec_on PFunctor.M.corecOn\n\nvariable {P : PFunctor.{u}} {α : Type u}\n\ntheorem dest_corec (g : α → P.Obj α) (x : α) : M.dest (M.corec g x) = M.corec g <$> g x := by\n  rw [corec_def, dest_mk]\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.dest_corec PFunctor.M.dest_corec\n\ntheorem bisim (R : M P → M P → Prop)\n    (h : ∀ x y, R x y → ∃ a f f', M.dest x = ⟨a, f⟩ ∧ M.dest y = ⟨a, f'⟩ ∧ ∀ i, R (f i) (f' i)) :\n    ∀ x y, R x y → x = y := by\n  introv h'\n  haveI := Inhabited.mk x.head\n  apply eq_of_bisim R _ _ _ h'; clear h' x y\n  constructor <;> introv ih <;> rcases h _ _ ih with ⟨a'', g, g', h₀, h₁, h₂⟩ <;> clear h\n  · replace h₀ := congr_arg Sigma.fst h₀\n    replace h₁ := congr_arg Sigma.fst h₁\n    simp only [dest_mk] at h₀ h₁\n    rw [h₀, h₁]\n  · simp only [dest_mk] at h₀ h₁\n    cases h₀\n    cases h₁\n    apply h₂\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.bisim PFunctor.M.bisim\n\ntheorem bisim' {α : Type _} (Q : α → Prop) (u v : α → M P)\n    (h : ∀ x, Q x → ∃ a f f',\n          M.dest (u x) = ⟨a, f⟩\n          ∧ M.dest (v x) = ⟨a, f'⟩\n          ∧ ∀ i, ∃ x', Q x' ∧ f i = u x' ∧ f' i = v x'\n      ) :\n    ∀ x, Q x → u x = v x := fun x Qx =>\n  let R := fun w z : M P => ∃ x', Q x' ∧ w = u x' ∧ z = v x'\n  @M.bisim P R\n    (fun _ _ ⟨x', Qx', xeq, yeq⟩ =>\n      let ⟨a, f, f', ux'eq, vx'eq, h'⟩ := h x' Qx'\n      ⟨a, f, f', xeq.symm ▸ ux'eq, yeq.symm ▸ vx'eq, h'⟩)\n    _ _ ⟨x, Qx, rfl, rfl⟩\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.bisim' PFunctor.M.bisim'\n\n-- for the record, show M_bisim follows from _bisim'\ntheorem bisim_equiv (R : M P → M P → Prop)\n    (h : ∀ x y, R x y → ∃ a f f', M.dest x = ⟨a, f⟩ ∧ M.dest y = ⟨a, f'⟩ ∧ ∀ i, R (f i) (f' i)) :\n    ∀ x y, R x y → x = y := fun x y Rxy =>\n  let Q : M P × M P → Prop := fun p => R p.fst p.snd\n  bisim' Q Prod.fst Prod.snd\n    (fun p Qp =>\n      let ⟨a, f, f', hx, hy, h'⟩ := h p.fst p.snd Qp\n      ⟨a, f, f', hx, hy, fun i => ⟨⟨f i, f' i⟩, h' i, rfl, rfl⟩⟩)\n    ⟨x, y⟩ Rxy\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.bisim_equiv PFunctor.M.bisim_equiv\n\ntheorem corec_unique (g : α → P.Obj α) (f : α → M P) (hyp : ∀ x, M.dest (f x) = f <$> g x) :\n    f = M.corec g := by\n  ext x\n  apply bisim' (fun _ => True) _ _ _ _ trivial\n  clear x\n  intro x _\n  cases' gxeq : g x with a f'\n  have h₀ : M.dest (f x) = ⟨a, f ∘ f'⟩ := by rw [hyp, gxeq, PFunctor.map_eq]\n  have h₁ : M.dest (M.corec g x) = ⟨a, M.corec g ∘ f'⟩ := by rw [dest_corec, gxeq, PFunctor.map_eq]\n  refine' ⟨_, _, _, h₀, h₁, _⟩\n  intro i\n  exact ⟨f' i, trivial, rfl, rfl⟩\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec_unique PFunctor.M.corec_unique\n\n/-- corecursor where the state of the computation can be sent downstream\nin the form of a recursive call -/\ndef corec₁ {α : Type u} (F : ∀ X, (α → X) → α → P.Obj X) : α → M P :=\n  M.corec (F _ id)\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec₁ PFunctor.M.corec₁\n\n/-- corecursor where it is possible to return a fully formed value at any point\nof the computation -/\ndef corec' {α : Type u} (F : ∀ {X : Type u}, (α → X) → α → Sum (M P) (P.Obj X)) (x : α) : M P :=\n  corec₁\n    (fun _ rec (a : Sum (M P) α) =>\n      let y := a >>= F (rec ∘ Sum.inr)\n      match y with\n      | Sum.inr y => y\n      | Sum.inl y => (rec ∘ Sum.inl) <$> M.dest y)\n    (@Sum.inr (M P) _ x)\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec' PFunctor.M.corec'\n\nend M\n\nend PFunctor\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/PFunctor/Univariate/M.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.49332190831284656}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport category_theory.equivalence\n\n/-! Tools for compatibilities between Dold-Kan equivalences\n\nThe purpose of this file is to introduce tools which will enable the\nconstruction of the Dold-Kan equivalence `simplicial_object C ≌ chain_complex C ℕ`\nfor a pseudoabelian category `C` from the equivalence\n`karoubi (simplicial_object C) ≌ karoubi (chain_complex C ℕ)` and the two\nequivalences `simplicial_object C ≅ karoubi (simplicial_object C)` and\n`chain_complex C ℕ ≅ karoubi (chain_complex C ℕ)`.\n\nIt is certainly possible to get an equivalence `simplicial_object C ≌ chain_complex C ℕ`\nusing a compositions of the three equivalences above, but then neither the functor\nnor the inverse would have good definitional properties. For example, it would be better\nif the inverse functor of the equivalence was exactly the functor\n`Γ₀ : simplicial_object C ⥤ chain_complex C ℕ` which was constructed in `functor_gamma.lean`.\n\nIn this file, given four categories `A`, `A'`, `B`, `B'`, equivalences `eA : A ≅ A'`,\n`eB : B ≅ B'`, `e' : A' ≅ B'`, functors `F : A ⥤ B'`, `G : B ⥤ A` equipped with certain\ncompatibilities, we construct successive equivalences:\n- `equivalence₀` from `A` to `B'`, which is the composition of `eA` and `e'`.\n- `equivalence₁` from `A` to `B'`, with the same inverse functor as `equivalence₀`,\nbut whose functor is `F`.\n- `equivalence₂` from `A` to `B`, which is the composition of `equivalence₁` and the\ninverse of `eB`:\n- `equivalence` from `A` to `B`, which has the same functor `F ⋙ eB.inverse` as `equivalence₂`,\nbut whose inverse functor is `G`.\n\nWhen extra assumptions are given, we shall also provide simplification lemmas for the\nunit and counit isomorphisms of `equivalence`. (TODO)\n\n-/\n\nopen category_theory category_theory.category\n\nnamespace algebraic_topology\n\nnamespace dold_kan\n\nnamespace compatibility\n\nvariables {A A' B B' : Type*} [category A] [category A'] [category B] [category B']\n  (eA : A ≌ A') (eB : B ≌ B') (e' : A' ≌ B')\n  {F : A ⥤ B'} (hF : eA.functor ⋙ e'.functor ≅ F)\n  {G : B ⥤ A} (hG : eB.functor ⋙ e'.inverse ≅ G ⋙ eA.functor)\n\n/-- A basic equivalence `A ≅ B'` obtained by composing `eA : A ≅ A'` and `e' : A' ≅ B'`. -/\n@[simps functor inverse unit_iso_hom_app]\ndef equivalence₀ : A ≌ B' := eA.trans e'\n\ninclude hF\nvariables {eA} {e'}\n\n/-- An intermediate equivalence `A ≅ B'` whose functor is `F` and whose inverse is\n`e'.inverse ⋙ eA.inverse`. -/\n@[simps functor]\ndef equivalence₁ : A ≌ B' :=\nbegin\n  letI : is_equivalence F :=\n    is_equivalence.of_iso hF (is_equivalence.of_equivalence (equivalence₀ eA e')),\n  exact F.as_equivalence,\nend\n\nlemma equivalence₁_inverse : (equivalence₁ hF).inverse = e'.inverse ⋙ eA.inverse := rfl\n\n/-- The counit isomorphism of the equivalence `equivalence₁` between `A` and `B'`. -/\n@[simps]\ndef equivalence₁_counit_iso :\n  (e'.inverse ⋙ eA.inverse) ⋙ F ≅ 𝟭 B' :=\ncalc (e'.inverse ⋙ eA.inverse) ⋙ F\n  ≅ (e'.inverse ⋙ eA.inverse) ⋙ (eA.functor ⋙ e'.functor) : iso_whisker_left _ hF.symm\n... ≅ e'.inverse ⋙ (eA.inverse ⋙ eA.functor) ⋙ e'.functor : iso.refl _\n... ≅ e'.inverse ⋙ 𝟭 _ ⋙ e'.functor : iso_whisker_left _ (iso_whisker_right eA.counit_iso _)\n... ≅ e'.inverse ⋙ e'.functor : iso.refl _\n... ≅ 𝟭 B' : e'.counit_iso\n\nlemma equivalence₁_counit_iso_eq : (equivalence₁ hF).counit_iso = equivalence₁_counit_iso hF :=\nbegin\n  ext Y,\n  dsimp [equivalence₀, equivalence₁, is_equivalence.inverse, is_equivalence.of_equivalence],\n  simp only [equivalence₁_counit_iso_hom_app, category_theory.functor.map_id, comp_id],\nend\n\n/-- The unit isomorphism of the equivalence `equivalence₁` between `A` and `B'`. -/\n@[simps]\ndef equivalence₁_unit_iso :\n  𝟭 A ≅ F ⋙ (e'.inverse ⋙ eA.inverse) :=\ncalc 𝟭 A ≅ eA.functor ⋙ eA.inverse : eA.unit_iso\n... ≅ eA.functor ⋙ 𝟭 A' ⋙ eA.inverse : iso.refl _\n... ≅ eA.functor ⋙ (e'.functor ⋙ e'.inverse) ⋙ eA.inverse :\n  iso_whisker_left _ (iso_whisker_right e'.unit_iso _)\n... ≅ (eA.functor ⋙ e'.functor) ⋙ (e'.inverse ⋙ eA.inverse) : iso.refl _\n... ≅ F ⋙ (e'.inverse ⋙ eA.inverse) : iso_whisker_right hF _\n\nlemma equivalence₁_unit_iso_eq : (equivalence₁ hF).unit_iso = equivalence₁_unit_iso hF :=\nbegin\n  ext X,\n  dsimp [equivalence₀, equivalence₁, nat_iso.hcomp,\n    is_equivalence.of_equivalence],\n  simp only [id_comp, assoc, equivalence₁_unit_iso_hom_app],\nend\n\ninclude eB\n\n/-- An intermediate equivalence `A ≅ B` obtained as the composition of `equivalence₁` and\nthe inverse of `eB : B ≌ B'`. -/\n@[simps functor]\ndef equivalence₂ : A ≌ B := (equivalence₁ hF).trans eB.symm\n\nlemma equivalence₂_inverse : (equivalence₂ eB hF).inverse =\n  eB.functor ⋙ e'.inverse ⋙ eA.inverse := rfl\n\n/-- The counit isomorphism of the equivalence `equivalence₂` between `A` and `B`. -/\n@[simps]\ndef equivalence₂_counit_iso :\n  (eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ (F ⋙ eB.inverse) ≅ 𝟭 B :=\ncalc (eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ (F ⋙ eB.inverse)\n  ≅ eB.functor ⋙ (e'.inverse ⋙ eA.inverse ⋙ F) ⋙ eB.inverse : iso.refl _\n... ≅ eB.functor ⋙ 𝟭 _ ⋙ eB.inverse :\n  iso_whisker_left _ (iso_whisker_right (equivalence₁_counit_iso hF) _)\n... ≅ eB.functor ⋙ eB.inverse : iso.refl _\n... ≅ 𝟭 B : eB.unit_iso.symm\n\n\n\n/-- The unit isomorphism of the equivalence `equivalence₂` between `A` and `B`. -/\n@[simps]\ndef equivalence₂_unit_iso :\n  𝟭 A ≅ (F ⋙ eB.inverse) ⋙ (eB.functor ⋙ e'.inverse ⋙ eA.inverse) :=\ncalc 𝟭 A ≅ F ⋙ e'.inverse ⋙ eA.inverse : equivalence₁_unit_iso hF\n... ≅ F ⋙ 𝟭 B' ⋙ (e'.inverse ⋙ eA.inverse) : iso.refl _\n... ≅ F ⋙ (eB.inverse ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :\n  iso_whisker_left _ (iso_whisker_right eB.counit_iso.symm _)\n... ≅ (F ⋙ eB.inverse) ⋙ (eB.functor ⋙ e'.inverse ⋙ eA.inverse) : iso.refl _\n\nlemma equivalence₂_unit_iso_eq :\n  (equivalence₂ eB hF).unit_iso = equivalence₂_unit_iso eB hF :=\nbegin\n  ext X,\n  dsimp [equivalence₂],\n  simpa only [equivalence₂_unit_iso_hom_app, equivalence₁_unit_iso_eq,\n    equivalence₁_unit_iso_hom_app, assoc, nat_iso.cancel_nat_iso_hom_left],\nend\n\nvariable {eB}\ninclude hG\n\n/-- The equivalence `A ≅ B` whose functor is `F ⋙ eB.inverse` and\nwhose inverse is `G : B ≅ A`. -/\n@[simps inverse]\ndef equivalence : A ≌ B :=\nbegin\n  letI : is_equivalence G := begin\n    refine is_equivalence.of_iso _ (is_equivalence.of_equivalence (equivalence₂ eB hF).symm),\n    calc eB.functor ⋙ e'.inverse ⋙ eA.inverse\n      ≅ (eB.functor ⋙ e'.inverse) ⋙ eA.inverse : iso.refl _\n    ... ≅ (G ⋙ eA.functor) ⋙ eA.inverse : iso_whisker_right hG _\n    ... ≅ G ⋙ 𝟭 A : iso_whisker_left _ eA.unit_iso.symm\n    ... ≅ G : functor.right_unitor G,\n  end,\n  exact G.as_equivalence.symm,\nend\n\nlemma equivalence_functor : (equivalence hF hG).functor = F ⋙ eB.inverse := rfl\n\nend compatibility\n\nend dold_kan\n\nend algebraic_topology\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_topology/dold_kan/compatibility.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.49332190350600846}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.comma\n\n/-!\n# The category of arrows\n\nThe category of arrows, with morphisms commutative squares.\nWe set this up as a specialization of the comma category `comma L R`,\nwhere `L` and `R` are both the identity functor.\n\nWe also define the typeclass `has_lift`, representing a choice of a lift\nof a commutative square (that is, a diagonal morphism making the two triangles commute).\n\n## Tags\n\ncomma, arrow\n-/\n\nnamespace category_theory\n\nuniverses v u -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u} [category.{v} T]\n\nsection\nvariables (T)\n\n/-- The arrow category of `T` has as objects all morphisms in `T` and as morphisms commutative\n     squares in `T`. -/\n@[derive category]\ndef arrow := comma.{v v v} (𝟭 T) (𝟭 T)\n\n-- Satisfying the inhabited linter\ninstance arrow.inhabited [inhabited T] : inhabited (arrow T) :=\n{ default := show comma (𝟭 T) (𝟭 T), from default (comma (𝟭 T) (𝟭 T)) }\n\nend\n\nnamespace arrow\n\n@[simp] lemma id_left (f : arrow T) : comma_morphism.left (𝟙 f) = 𝟙 (f.left) := rfl\n@[simp] lemma id_right (f : arrow T) : comma_morphism.right (𝟙 f) = 𝟙 (f.right) := rfl\n\n/-- An object in the arrow category is simply a morphism in `T`. -/\n@[simps]\ndef mk {X Y : T} (f : X ⟶ Y) : arrow T :=\n{ left := X,\n  right := Y,\n  hom := f }\n\ntheorem mk_injective (A B : T) :\n  function.injective (arrow.mk : (A ⟶ B) → arrow T) :=\nλ f g h, by { cases h, refl }\n\ntheorem mk_inj (A B : T) {f g : A ⟶ B} : arrow.mk f = arrow.mk g ↔ f = g :=\n(mk_injective A B).eq_iff\ninstance {X Y : T} : has_coe (X ⟶ Y) (arrow T) := ⟨mk⟩\n\n/-- A morphism in the arrow category is a commutative square connecting two objects of the arrow\n    category. -/\n@[simps]\ndef hom_mk {f g : arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}\n  (w : u ≫ g.hom = f.hom ≫ v) : f ⟶ g :=\n{ left := u,\n  right := v,\n  w' := w }\n\n/-- We can also build a morphism in the arrow category out of any commutative square in `T`. -/\n@[simps]\ndef hom_mk' {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}\n  (w : u ≫ g = f ≫ v) : arrow.mk f ⟶ arrow.mk g :=\n{ left := u,\n  right := v,\n  w' := w }\n\n@[simp, reassoc] lemma w {f g : arrow T} (sq : f ⟶ g) : sq.left ≫ g.hom = f.hom ≫ sq.right := sq.w\n\n-- `w_mk_left` is not needed, as it is a consequence of `w` and `mk_hom`.\n@[simp, reassoc] lemma w_mk_right {f : arrow T} {X Y : T} {g : X ⟶ Y} (sq : f ⟶ mk g) :\n  sq.left ≫ g = f.hom ≫ sq.right :=\nsq.w\n\nlemma is_iso_of_iso_left_of_is_iso_right\n  {f g : arrow T} (ff : f ⟶ g) [is_iso ff.left] [is_iso ff.right] : is_iso ff :=\n{ out := ⟨⟨inv ff.left, inv ff.right⟩,\n          by { ext; dsimp; simp only [is_iso.hom_inv_id] },\n          by { ext; dsimp; simp only [is_iso.inv_hom_id] }⟩ }\n\n/-- Create an isomorphism between arrows,\nby providing isomorphisms between the domains and codomains,\nand a proof that the square commutes. -/\n@[simps] def iso_mk {f g : arrow T}\n  (l : f.left ≅ g.left) (r : f.right ≅ g.right) (h : l.hom ≫ g.hom = f.hom ≫ r.hom) :\n  f ≅ g :=\ncomma.iso_mk l r h\n\nsection\n\nvariables {f g : arrow T} (sq : f ⟶ g)\n\ninstance is_iso_left [is_iso sq] : is_iso sq.left :=\n{ out := ⟨(inv sq).left, by simp only [← comma.comp_left, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_left, eq_self_iff_true, and_self]⟩ }\n\ninstance is_iso_right [is_iso sq] : is_iso sq.right :=\n{ out := ⟨(inv sq).right, by simp only [← comma.comp_right, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_right, eq_self_iff_true, and_self]⟩ }\n\n@[simp] lemma inv_left [is_iso sq] : (inv sq).left = inv sq.left :=\nis_iso.eq_inv_of_hom_inv_id $ by rw [← comma.comp_left, is_iso.hom_inv_id, id_left]\n\n@[simp] lemma inv_right [is_iso sq] : (inv sq).right = inv sq.right :=\nis_iso.eq_inv_of_hom_inv_id $ by rw [← comma.comp_right, is_iso.hom_inv_id, id_right]\n\n@[simp] lemma left_hom_inv_right [is_iso sq] : sq.left ≫ g.hom ≫ inv sq.right = f.hom :=\nby simp only [← category.assoc, is_iso.comp_inv_eq, w]\n\n-- simp proves this\nlemma inv_left_hom_right [is_iso sq] : inv sq.left ≫ f.hom ≫ sq.right = g.hom :=\nby simp only [w, is_iso.inv_comp_eq]\n\ninstance mono_left [mono sq] : mono sq.left :=\n{ right_cancellation := λ Z φ ψ h, begin\n    let aux : (Z ⟶ f.left) → (arrow.mk (𝟙 Z) ⟶ f) := λ φ, { left := φ, right := φ ≫ f.hom },\n    show (aux φ).left = (aux ψ).left,\n    congr' 1,\n    rw ← cancel_mono sq,\n    ext,\n    { exact h },\n    { simp only [comma.comp_right, category.assoc, ← arrow.w],\n      simp only [← category.assoc, h], },\n  end }\n\ninstance epi_right [epi sq] : epi sq.right :=\n{ left_cancellation := λ Z φ ψ h, begin\n    let aux : (g.right ⟶ Z) → (g ⟶ arrow.mk (𝟙 Z)) := λ φ, { right := φ, left := g.hom ≫ φ },\n    show (aux φ).right = (aux ψ).right,\n    congr' 1,\n    rw ← cancel_epi sq,\n    ext,\n    { simp only [comma.comp_left, category.assoc, arrow.w_assoc, h], },\n    { exact h },\n  end }\n\nend\n\n/-- Given a square from an arrow `i` to an isomorphism `p`, express the source part of `sq`\nin terms of the inverse of `p`. -/\n@[simp] lemma square_to_iso_invert (i : arrow T) {X Y : T} (p : X ≅ Y) (sq : i ⟶ arrow.mk p.hom) :\n  i.hom ≫ sq.right ≫ p.inv = sq.left :=\nby simpa only [category.assoc] using (iso.comp_inv_eq p).mpr ((arrow.w_mk_right sq).symm)\n\n/-- Given a square from an isomorphism `i` to an arrow `p`, express the target part of `sq`\nin terms of the inverse of `i`. -/\nlemma square_from_iso_invert {X Y : T} (i : X ≅ Y) (p : arrow T) (sq : arrow.mk i.hom ⟶ p) :\n  i.inv ≫ sq.left ≫ p.hom = sq.right :=\nby simp only [iso.inv_hom_id_assoc, arrow.w, arrow.mk_hom]\n\n/-- A lift of a commutative square is a diagonal morphism making the two triangles commute. -/\n@[ext] structure lift_struct {f g : arrow T} (sq : f ⟶ g) :=\n(lift : f.right ⟶ g.left)\n(fac_left' : f.hom ≫ lift = sq.left . obviously)\n(fac_right' : lift ≫ g.hom = sq.right . obviously)\n\nrestate_axiom lift_struct.fac_left'\nrestate_axiom lift_struct.fac_right'\n\ninstance lift_struct_inhabited {X : T} : inhabited (lift_struct (𝟙 (arrow.mk (𝟙 X)))) :=\n⟨⟨𝟙 _, category.id_comp _, category.comp_id _⟩⟩\n\n/-- `has_lift sq` says that there is some `lift_struct sq`, i.e., that it is possible to find a\n    diagonal morphism making the two triangles commute. -/\nclass has_lift {f g : arrow T} (sq : f ⟶ g) : Prop :=\nmk' :: (exists_lift : nonempty (lift_struct sq))\n\nlemma has_lift.mk {f g : arrow T} {sq : f ⟶ g} (s : lift_struct sq) : has_lift sq :=\n⟨nonempty.intro s⟩\n\nattribute [simp, reassoc] lift_struct.fac_left lift_struct.fac_right\n\n/-- Given `has_lift sq`, obtain a lift. -/\nnoncomputable def has_lift.struct {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : lift_struct sq :=\nclassical.choice has_lift.exists_lift\n\n/-- If there is a lift of a commutative square `sq`, we can access it by saying `lift sq`. -/\nnoncomputable abbreviation lift {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : f.right ⟶ g.left :=\n(has_lift.struct sq).lift\n\nlemma lift.fac_left {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : f.hom ≫ lift sq = sq.left :=\nby simp\n\nlemma lift.fac_right {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : lift sq ≫ g.hom = sq.right :=\nby simp\n\n@[simp, reassoc]\nlemma lift.fac_right_of_to_mk {X Y : T} {f : arrow T} {g : X ⟶ Y} (sq : f ⟶ mk g) [has_lift sq] :\n  lift sq ≫ g = sq.right :=\nby simp only [←mk_hom g, lift.fac_right]\n\n@[simp, reassoc]\nlemma lift.fac_left_of_from_mk {X Y : T} {f : X ⟶ Y} {g : arrow T} (sq : mk f ⟶ g) [has_lift sq] :\n  f ≫ lift sq = sq.left :=\nby simp only [←mk_hom f, lift.fac_left]\n\n@[simp, reassoc]\nlemma lift_mk'_left {X Y P Q : T} {f : X ⟶ Y} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}\n  (h : u ≫ g = f ≫ v) [has_lift $ arrow.hom_mk' h] : f ≫ lift (arrow.hom_mk' h) = u :=\nby simp only [←arrow.mk_hom f, lift.fac_left, arrow.hom_mk'_left]\n\n@[simp, reassoc]\nlemma lift_mk'_right {X Y P Q : T} {f : X ⟶ Y} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}\n  (h : u ≫ g = f ≫ v) [has_lift $ arrow.hom_mk' h] : lift (arrow.hom_mk' h) ≫ g = v :=\nby simp only [←arrow.mk_hom g, lift.fac_right, arrow.hom_mk'_right]\n\nsection\n\ninstance subsingleton_lift_struct_of_epi {f g : arrow T} (sq : f ⟶ g) [epi f.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ λ a b, lift_struct.ext a b $ (cancel_epi f.hom).1 $ by simp\n\ninstance subsingleton_lift_struct_of_mono {f g : arrow T} (sq : f ⟶ g) [mono g.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ λ a b, lift_struct.ext a b $ (cancel_mono g.hom).1 $ by simp\n\nend\n\nvariables {C : Type u} [category.{v} C]\n/-- A helper construction: given a square between `i` and `f ≫ g`, produce a square between\n`i` and `g`, whose top leg uses `f`:\nA  → X\n     ↓f\n↓i   Y             --> A → Y\n     ↓g                ↓i  ↓g\nB  → Z                 B → Z\n -/\n@[simps] def square_to_snd {X Y Z: C} {i : arrow C} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (sq : i ⟶ arrow.mk (f ≫ g)) :\n  i ⟶ arrow.mk g :=\n{ left := sq.left ≫ f,\n  right := sq.right }\n\n/-- The functor sending an arrow to its source. -/\n@[simps] def left_func : arrow C ⥤ C := comma.fst _ _\n\n/-- The functor sending an arrow to its target. -/\n@[simps] def right_func : arrow C ⥤ C := comma.snd _ _\n\n/-- The natural transformation from `left_func` to `right_func`, given by the arrow itself. -/\n@[simps]\ndef left_to_right : (left_func : arrow C ⥤ C) ⟶ right_func :=\n{ app := λ f, f.hom }\n\nend arrow\n\nnamespace functor\n\nuniverses v₁ v₂ u₁ u₂\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/\n@[simps]\ndef map_arrow (F : C ⥤ D) : arrow C ⥤ arrow D :=\n{ obj := λ a,\n  { left := F.obj a.left,\n    right := F.obj a.right,\n    hom := F.map a.hom, },\n  map := λ a b f,\n  { left := F.map f.left,\n    right := F.map f.right,\n    w' := by { have w := f.w, simp only [id_map] at w, dsimp, simp only [←F.map_comp, w], } } }\n\nend functor\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/arrow.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.49332190350600846}}
{"text": "/- -----------------------------------------------------------------------\nBasic properties of LeanCat.\n----------------------------------------------------------------------- -/\n\nimport ..c1_basic\nimport ..c2_limits\nimport ..c3_wtypes\nimport ..c4_topoi\n\nnamespace qp\n\nopen stdaux\n\nuniverse variables ℓ' ℓ ℓobj ℓhom\n\n\n\n/- -----------------------------------------------------------------------\nConstant homs.\n----------------------------------------------------------------------- -/\n\n/-! #brief A constant hom in LeanCat.\n-/\ndefinition LeanCat.const_hom\n    {X Y : LeanCat.{ℓ}^.obj}\n    (y : Y)\n    : LeanCat^.hom X Y\n| x := y\n\n\n\n/- -----------------------------------------------------------------------\nLimits and colimits.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has all limits.\n-/\ninstance LeanCat.HasAllLimits : HasAllLimits.{ℓobj ℓhom} LeanCat.{max ℓ ℓobj}\n:= { has_limit\n      := λ X L\n         , HasLimit.show\n            { g : ∀ (x : X^.obj), L^.obj x\n               // ∀ {x₁ x₂ : X^.obj} (f : X^.hom x₁ x₂)\n                  , g x₂ = L^.hom f (g x₁)\n            }\n            (λ x g, g^.val x)\n            (λ x₁ x₂ f, funext (λ g, g^.property f))\n            (λ C hom ωhom c\n             , { val := λ x, hom x c\n               , property := λ x₁ x₂ f, begin rw ωhom f, trivial end\n               })\n            (λ C hom ωhom x, rfl)\n            (λ C hom ωhom f ωf\n             , funext (λ c, subtype.eq (funext (λ x, eq.symm (by apply congr_fun (ωf x) c)))))\n   }\n\n/-! #brief The equivalence relation underlying colimits in LeanCat.\n-/\ndefinition LeanCat.HasAllCoLimits.prop {X : Cat.{ℓobj ℓhom}}\n    (L : Fun X LeanCat.{max ℓ ℓobj})\n    (a b : (Σ (x : X^.obj), L^.obj x))\n    : Prop\n:= ∃ (f : X^.hom a^.fst b^.fst), b^.snd = L^.hom f a^.snd\n\n/-! #brief LeanCat has all co-limits.\n-/\ninstance LeanCat.HasAllCoLimits : HasAllCoLimits.{ℓobj ℓhom} LeanCat.{max ℓ ℓobj}\n:= { has_colimit\n      := λ X L\n         , HasCoLimit.show\n            (quot (LeanCat.HasAllCoLimits.prop L))\n            (λ x Lx, quot.mk _ {fst := x, snd := Lx})\n            (λ x₁ x₂ f, funext (λ Lx, quot.sound (exists.intro f rfl)))\n            (λ C hom ωhom\n             , let f : (Σ (x : X^.obj), L^.obj x) → C\n                      := λ Lx, hom Lx^.fst Lx^.snd in\n               let ωf : ∀ (a b : Σ (x : ⟦X⟧), L^.obj x)\n                        , LeanCat.HasAllCoLimits.prop L a b\n                        → f a = f b\n                     := λ a b ωab\n                        , begin\n                            dsimp,\n                            cases ωab with g ωg,\n                            rw [ωg, ωhom g],\n                            trivial\n                          end\n               in quot.lift f ωf)\n            (λ C hom ωhom x, rfl)\n            (λ C hom ωhom f ωf\n             , funext (quot.ind (begin\n                                   intro Lx,\n                                   cases Lx with x Lx,\n                                   apply eq.symm (congr_fun (ωf x) Lx)\n                                 end)))\n   }\n\n\n\n/- -----------------------------------------------------------------------\nLimits and colimits in over/under categories.\n----------------------------------------------------------------------- -/\n\n\n/-! #brief Structure hom for colimits in OverCat LeanCat.\n-/\ndefinition LeanCat.Over.HasCoLimit.colim_hom\n    (B : LeanCat.{max ℓ ℓobj}^.obj)\n    {X : Cat.{ℓobj ℓhom}}\n    (L : Fun X (OverCat LeanCat B))\n    : LeanCat^.hom (colimit (OverFun.out LeanCat B □□ L)) B\n:= let f : (Σ (x : X^.obj), (L^.obj x)^.obj) → B\n        := λ x, (L^.obj x^.fst)^.hom x^.snd\nin quot.lift f\n    begin\n      intros a b,\n      cases a with xa a,\n      cases b with xb b,\n      intro ω, cases ω with h ωb,\n      dsimp at h,\n      dsimp at ωb, subst ωb,\n      apply congr_fun (L^.hom h)^.triangle a\n    end\n\n/-! #brief OverCat LeanCat has all co-limits.\n-/\ninstance LeanCat.Over.HasCoLimit\n    (B : LeanCat.{max ℓ ℓobj}^.obj)\n    {X : Cat.{ℓobj ℓhom}} (L : Fun X (OverCat LeanCat B))\n    : HasCoLimit L\n:= HasCoLimit.show\n    { obj := colimit (OverFun.out LeanCat B □□ L)\n    , hom := LeanCat.Over.HasCoLimit.colim_hom B L\n    }\n    (λ x, { hom := λ Lx, quot.mk _ { fst := x, snd := Lx }\n          , triangle := sorry\n          })\n    (λ x₁ x₂ f, begin\n                  apply OverHom.eq,\n                  apply funext, intro Lx,\n                  apply quot.sound,\n                  apply exists.intro f,\n                  trivial\n                end)\n    sorry\n    sorry\n    sorry\n\ninstance LeanCat.Over.HasAllCoLimits\n    (B : LeanCat.{max ℓ ℓobj}^.obj)\n    : HasAllCoLimits.{ℓobj ℓhom}\n        (OverCat LeanCat.{max ℓ ℓobj} B)\n:= { has_colimit := @LeanCat.Over.HasCoLimit B\n   }      \n\n/-! #brief Handy simplifier.\n-/\ntheorem LeanCat.Over.HasCoLimit.obj\n    (B : LeanCat.{max ℓ ℓobj}^.obj)\n    {X : Cat.{ℓobj ℓhom}} (L : Fun X (OverCat LeanCat B))\n    : (colimit L)^.obj = colimit (OverFun.out LeanCat B □□ L)\n:= rfl\n\n\n\n/- -----------------------------------------------------------------------\nProducts.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has all products.\n-/\ninstance LeanCat.HasProduct\n    {A : Type ℓ'} (factor : A → LeanCat.{max ℓ ℓ'}^.obj)\n    : HasProduct LeanCat.{max ℓ ℓ'} factor\n:= HasProduct.show LeanCat factor\n    (∀ (a : A), factor a)\n    (λ a fa, fa a)\n    (λ T f t a, f a t)\n    (λ T f a, rfl)\n    (λ T f h ωh\n      , begin\n          apply funext, intro t,\n          apply funext, intro a,\n          rw ωh,\n          trivial\n        end)\n\n/-! #brief LeanCat has all products.\n-/\ninstance LeanCat.HasAllProducts\n    : HasAllProducts.{ℓ'} LeanCat.{max ℓ ℓ'}\n:= { has_product := @LeanCat.HasProduct\n   }\n\n/-! #brief Finite product type in LeanCat.\n-/\ndefinition ListProd\n    : ∀ (TT : list LeanCat.{ℓ}^.obj)\n      , LeanCat.{ℓ}^.obj\n| [] := punit\n| [T] := T\n| (T :: TT) := T × ListProd TT\n\n/-! #brief A fancy way of mapping through a ListProd.\n-/\ndefinition {ℓb ℓx ℓy} ListProd.map\n    {Ba : Type ℓb} {Tx : Ba → Type ℓx} {Ty : Ba → Type ℓy}\n    (f : ∀ (b : Ba), Tx b → Ty b)\n    : ∀ (BB : list Ba)\n      , ListProd (list.map Tx BB)\n      → ListProd (list.map Ty BB)\n| [] _ := punit.star\n| [Ba] x := f Ba x\n| (Ba :: Ba₀ :: BB) (prod.mk x xx) := (f Ba x, @ListProd.map (Ba₀ :: BB) xx)\n\n/-! #brief Projection from finite product type in LeanCat.\n-/\ndefinition ListProd.π\n    : ∀ (TT : list LeanCat.{ℓ}^.obj)\n        (n : fin (list.length TT))\n        (x : ListProd TT)\n      , list.get TT n\n| [] n x := fin.zero_elim n\n| [T] (fin.mk 0 ω0) X := X\n| [T] (fin.mk (nat.succ n) ωn) X := false.rec _ begin cases ωn, cases a end\n| (T :: T₁ :: TT) (fin.mk 0 ω0) X := X^.fst\n| (T :: T₁ :: TT) (fin.mk (nat.succ n) ωn) X := ListProd.π (T₁ :: TT) { val := n, is_lt := nat.lt_of_succ_lt_succ ωn } X^.snd\n\n/-! #brief Enumerating a map into a finite product.\n-/\ndefinition ListProd.univ\n    : ∀ (TT : list LeanCat.{ℓ}^.obj)\n        (S : LeanCat.{ℓ}^.obj)\n        (f : ∀ (n : ℕ)\n               (ωn : n < list.length TT)\n             , S → list.get TT { val := n, is_lt := ωn })\n      , S → ListProd TT\n| [] S f s := punit.star\n| [T] S f s := f 0 (fin_of 0)^.is_lt s\n| (T :: T₁ :: TT) S f s\n:= ( f 0 (fin_of 0)^.is_lt s\n   , ListProd.univ (T₁ :: TT) S (λ n ωn s', f (nat.succ n) (nat.succ_lt_succ ωn) s') s\n   )\n\n/-! #brief Factoring property of the universal map.\n-/\ndefinition ListProd.univ.factor\n    : ∀ {TT : list LeanCat.{ℓ}^.obj}\n        {S : LeanCat.{ℓ}^.obj}\n        {f : ∀ (n : ℕ)\n               (ωn : n < list.length TT)\n             , S → list.get TT { val := n, is_lt := ωn }}\n        {n : ℕ} {ωn : n < list.length TT}\n        {s : S}\n      , f n ωn s = ListProd.π TT\n                    { val := n, is_lt := ωn }\n                    (ListProd.univ TT S f s)\n| [] S f n ωn s := by cases ωn\n| [T] S f 0 ω0 s := rfl\n| [T] S f (nat.succ n) ωn s := false.rec _ begin cases ωn, cases a end\n| (T :: T₁ :: TT) S f 0 ω0 s := rfl\n| (T :: T₁ :: TT) S f (nat.succ n) ωn s\n:= begin\n     refine eq.trans _ (@ListProd.univ.factor (T₁ :: TT) S _ n _ s),\n     trivial\n   end\n\n/-! #brief LeanCat has all finite products.\n-/\ninstance LeanCat.HasFinProduct (factor : list LeanCat.{ℓ}^.obj)\n    : HasFinProduct LeanCat factor\n:= HasProduct.show LeanCat (list.get factor)\n    (ListProd factor)\n    (ListProd.π factor)\n    (λ T f, ListProd.univ factor T (λ n ωn, f { val := n, is_lt := ωn }))\n    (λ T f n\n      , begin\n          apply funext, intro t,\n          cases n with n ωn,\n          refine eq.trans _ (ListProd.univ.factor),\n          trivial\n        end)\n    (λ T f h ωh\n      , begin\n          assert ωf : f = λ n t, ListProd.π factor n (h t),\n          { apply funext @ωh },\n          subst ωf,\n          apply funext, intro t,\n          induction factor with T factor rec,\n          { apply punit.uniq },\n          cases factor with T₁ factor,\n          { trivial },\n          { apply prod.eq,\n            { trivial },\n            { refine eq.trans _ (rec (λ t, (h t)^.snd) _),\n              { trivial },\n              { intro n, trivial }\n            }\n          }\n        end)\n\n/-! #brief LeanCat has all finite products.\n-/\ninstance LeanCat.HasAllFinProducts\n    : HasAllFinProducts LeanCat.{ℓ}\n:= { has_product := LeanCat.HasFinProduct\n   }\n\n\n\n/- -----------------------------------------------------------------------\nCo-products.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has all co-products.\n-/\ninstance LeanCat.HasCoProduct\n    {A : Type ℓ'} (factor : A → LeanCat.{max ℓ ℓ'}^.obj)\n    : HasCoProduct LeanCat.{max ℓ ℓ'} factor\n:= HasCoProduct.show LeanCat factor\n    (Σ (a : A), factor a)\n    (sigma.mk)\n    (λ T f af, f af^.fst af^.snd)\n    (λ T f a, rfl)\n    (λ T f h ωh\n      , begin\n          apply funext, intro af,\n          cases af with a f,\n          rw ωh,\n          trivial\n        end)\n\n/-! #brief LeanCat has all co-products.\n-/\ninstance LeanCat.HasAllCoProducts\n    : HasAllCoProducts.{ℓ'} LeanCat.{max ℓ ℓ'}\n:= { has_coproduct := @LeanCat.HasCoProduct\n   }\n\n/-! #brief Finite sum type in LeanCat.\n-/\ndefinition ListSum\n    : ∀ (TT : list LeanCat.{ℓ}^.obj)\n      , LeanCat.{ℓ}^.obj\n| [] := pempty\n| [T] := T\n| (T :: TT) := sum T (ListSum TT)\n\n/-! #brief A fancy way of mapping through a ListSum.\n-/\ndefinition {ℓb ℓx ℓy} ListSum.map\n    {Ba : Type ℓb} {Tx : Ba → Type ℓx} {Ty : Ba → Type ℓy}\n    : ∀ (BB : list Ba)\n        (f : ∀ (n : ℕ) (ωn : n < list.length BB)\n             , Tx (list.get BB {val := n, is_lt := ωn}) → Ty (list.get BB {val := n, is_lt := ωn}))\n      , ListSum (list.map Tx BB)\n      → ListSum (list.map Ty BB)\n| [] f e := by cases e\n| [Ba] f x := f 0 fin.zero^.is_lt x\n| (Ba :: Ba₀ :: BB) f (sum.inl x) := sum.inl (f 0 fin.zero^.is_lt x)\n| (Ba :: Ba₀ :: BB) f (sum.inr xx)\n:= sum.inr (ListSum.map (Ba₀ :: BB)\n             (λ n ωn, f (nat.succ n) (nat.succ_le_succ ωn))\n            xx)\n\n/-! #brief Inclusion into finite sum type in LeanCat.\n-/\ndefinition ListSum.ι\n    : ∀ (TT : list LeanCat.{ℓ}^.obj)\n        (n : fin (list.length TT))\n        (x : list.get TT n)\n      , ListSum TT\n| [] n x := fin.zero_elim n\n| [T] (fin.mk 0 ω0) x := x\n| [T] (fin.mk (nat.succ n) ωn) x := false.rec _ begin cases ωn, cases a end\n| (T :: T₁ :: TT) (fin.mk 0 ω0) x := sum.inl x\n| (T :: T₁ :: TT) (fin.mk (nat.succ n) ωn) x\n:= sum.inr (ListSum.ι (T₁ :: TT) { val := n, is_lt := nat.lt_of_succ_lt_succ ωn } x)\n\n/-! #brief Enumerating a map out of a finite sum.\n-/\ndefinition ListSum.univ\n    : ∀ (TT : list LeanCat.{ℓ}^.obj)\n        (S : LeanCat.{ℓ}^.obj)\n        (f : ∀ (n : ℕ)\n               (ωn : n < list.length TT)\n             , list.get TT { val := n, is_lt := ωn } → S)\n      , ListSum TT → S\n| [] S f e := by cases e\n| [T] S f s := f 0 (fin_of 0)^.is_lt s\n| (T :: T₁ :: TT) S f (sum.inl s)\n:= f 0 (fin_of 0)^.is_lt s\n| (T :: T₁ :: TT) S f (sum.inr s)\n:= ListSum.univ (T₁ :: TT) S (λ n ωn s', f (nat.succ n) (nat.succ_lt_succ ωn) s') s\n\n/-! #brief Factoring property of the universal map.\n-/\ndefinition ListSum.univ.factor\n    : ∀ {TT : list LeanCat.{ℓ}^.obj}\n        {S : LeanCat.{ℓ}^.obj}\n        {f : ∀ (n : ℕ)\n               (ωn : n < list.length TT)\n             , list.get TT { val := n, is_lt := ωn } → S}\n        {n : ℕ} {ωn : n < list.length TT}\n        {s : list.get TT { val := n, is_lt := ωn }}\n      , f n ωn s = ListSum.univ TT S f\n                     (ListSum.ι TT { val := n, is_lt := ωn } s)\n| [] S f n ωn s := by cases ωn\n| [T] S f 0 ω0 s := rfl\n| [T] S f (nat.succ n) ωn s := false.rec _ begin cases ωn, cases a end\n| (T :: T₁ :: TT) S f 0 ω0 s := rfl\n| (T :: T₁ :: TT) S f (nat.succ n) ωn s\n:= begin\n     refine eq.trans _ (@ListSum.univ.factor (T₁ :: TT) S _ n _ s),\n     trivial\n   end\n\n/-! #brief LeanCat has all finite products.\n-/\ninstance LeanCat.HasFinCoProduct (factor : list LeanCat.{ℓ}^.obj)\n    : HasFinCoProduct LeanCat factor\n:= HasCoProduct.show LeanCat (list.get factor)\n    (ListSum factor)\n    (ListSum.ι factor)\n    (λ T f, ListSum.univ factor T (λ n ωn, f { val := n, is_lt := ωn }))\n    (λ T f n\n      , begin\n          apply funext, intro t,\n          cases n with n ωn,\n          refine eq.trans _ (ListSum.univ.factor),\n          trivial\n        end)\n    (λ T f h ωh\n      , begin\n          assert ωf : f = λ n t, h (ListSum.ι factor n t),\n          { apply funext @ωh },\n          subst ωf,\n          apply funext, intro t,\n          induction factor with T factor rec,\n          { cases t },\n          cases factor with T₁ factor,\n          { trivial },\n          { cases t,\n            { trivial },\n            { refine eq.trans _ (rec (λ a, (h (sum.inr a))) _ _),\n              { trivial },\n              { intro n, trivial }\n            }\n          }\n        end)\n\n/-! #brief LeanCat has all finite products.\n-/\ninstance LeanCat.HasAllFinCoProducts\n    : HasAllFinCoProducts LeanCat.{ℓ}\n:= { has_coproduct := LeanCat.HasFinCoProduct\n   }\n\n\n\n/- -----------------------------------------------------------------------\nPullbacks.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has all pullbacks.\n-/\ninstance LeanCat.HasPullback\n    {base : LeanCat.{ℓ}^.obj} {factor : list LeanCat.{ℓ}^.obj}\n    {T : LeanCat.{ℓ}^.obj}\n    (maps : @HomsIn LeanCat (base :: factor) T)\n    : HasPullback LeanCat maps\n:= HasPullback.show LeanCat.{ℓ} maps\n    { p : finproduct LeanCat (base :: factor)\n      // ∀ (n : fin (list.length (base :: factor)))\n         , HomsIn.get maps (fin_of 0) (finproduct.π LeanCat (base :: factor) (fin_of 0) p)\n            = HomsIn.get maps n (finproduct.π LeanCat (base :: factor) n p)\n    }\n    (λ p, HomsIn.get maps (fin_of 0) (finproduct.π LeanCat (base :: factor) (fin_of 0) p^.val))\n    (HomsOut.comp (finproduct.cone LeanCat (base :: factor))^.Proj (λ p, p^.val))\n    begin\n      cases maps with _ m_base _ maps,\n      -- apply HomsList.eq,\n      -- { trivial },\n      -- induction maps with _ m₁ _ maps rec,\n      -- { trivial },\n      exact sorry\n    end\n    sorry\n    sorry\n    sorry\n\n\ninstance LeanCat.HasAllPullbacks\n    : HasAllPullbacks LeanCat.{ℓ}\n:= { has_pullback\n      := λ base factor T maps\n         , LeanCat.HasPullback maps\n   }\n\n/-! #brief A handy wrapper.\n-/\ndefinition LeanCat.BaseChangeFun\n    {X Y : LeanCat.{ℓ}^.obj}\n    (f : LeanCat.{ℓ}^.hom X Y)\n    : Fun (OverCat LeanCat Y) (OverCat LeanCat X)\n:= @BaseChangeFun LeanCat X Y f\n     (HasAllPullbacks.HasPullbacksAlong LeanCat f)\n\n\n\n/- -----------------------------------------------------------------------\nProducts in OverCat LeanCat.\n----------------------------------------------------------------------- -/\n\n/-! #brief OverCat LeanCat has finite products.\n-/\ninstance LeanCat.Over.HasFinProduct\n    (T₀ : LeanCat.{ℓ}^.obj)\n    (factor : list (OverCat LeanCat T₀)^.obj)\n    : HasFinProduct (OverCat LeanCat T₀) factor\n:= OverCat.HasFinProduct LeanCat.{ℓ} T₀ factor\n\n\n\n/- -----------------------------------------------------------------------\nExponentials.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has exponential objects.\n-/\ninstance LeanCat.HasExp (X Y : LeanCat.{ℓ}^.obj)\n    : @HasExp LeanCat X Y\n:= { exp := Y → X\n   , ev\n      := λ exp_Y_HasFinProduct p\n         , let f := @finproduct.π _ _ exp_Y_HasFinProduct (@fin_of 1 0)\n        in let y := @finproduct.π _ _ exp_Y_HasFinProduct (@fin_of 0 1)\n        in f p (y p)\n   , univ\n      := λ Z Z_Y_HasFinProduct e z y\n         , e (finproduct.iso (LeanCat.HasFinProduct [Z, Y]) Z_Y_HasFinProduct (z, y))\n   , factor := λ exp_Y_HasFinProduct Z Z_Y_HasFinProduct e\n               , begin\n                   apply funext, intro zy,\n                   rw LeanCat.simp_circ,\n                   dsimp,\n                   exact sorry\n                 end\n   , uniq := λ exp_Y_HasFinProduct Z Z_Y_HasFinProduct e u ωu\n             , begin\n                 apply funext, intro z,\n                 apply funext, intro y,\n                 rw ωu,\n                 exact sorry\n               end\n   }\n\n\n\n/- -----------------------------------------------------------------------\nExponentials in OverCat LeanCat.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has exponential objects.\n-/\ndefinition LeanCat.Over.exp\n      (T₀ : LeanCat.{ℓ}^.obj)\n      (T S : (OverCat LeanCat T₀)^.obj)\n      : OverObj LeanCat.{ℓ} T₀\n:= { obj := Σ (t₀ : T₀)\n            , {s : S^.dom // S^.hom s = t₀}\n              → {t : T^.obj // T^.hom t = t₀}\n   , hom := sigma.fst\n   }\n\n/-! #brief LeanCat has exponential objects.\n-/\ninstance LeanCat.Over.HasExp\n      (T₀ : LeanCat.{ℓ}^.obj)\n      (X Y : (OverCat LeanCat T₀)^.obj)\n    : @HasExp (OverCat LeanCat T₀) X Y\n:= { exp := LeanCat.Over.exp T₀ X Y\n   , ev\n      := λ p_HasProd\n         , { hom := λ p, let f := (@finproduct.π (OverCat LeanCat T₀) [LeanCat.Over.exp T₀ X Y, Y] p_HasProd (@fin_of 1 0))^.hom p\n                      in let y := (@finproduct.π (OverCat LeanCat T₀) [LeanCat.Over.exp T₀ X Y, Y] p_HasProd (@fin_of 0 1))^.hom p\n                      in (f^.snd { val := y, property := sorry })^.val\n           , triangle := sorry\n           }\n   , univ\n      := λ A A_HasProd f\n         , let a_y : ∀ (a : A^.obj)\n                       (y : {s // Y^.hom s = A^.hom a})\n                     , OverObj.dom (finproduct (OverCat LeanCat T₀) [A, Y])\n                   := λ a y\n                      , { val := (a, y^.val)\n                        , property\n                           := begin\n                                intro nωn, cases nωn with n ωn,\n                                cases n with n, { trivial },\n                                cases n with n, { apply eq.symm y^.property },\n                                apply nat.not_lt_add_right n 2 ωn\n                              end\n                        }\n        in let a_y' := λ a y, ((finproduct.iso (LeanCat.Over.HasFinProduct T₀ [A, Y]) A_HasProd)^.hom (a_y a y))\n        in { hom\n              := λ a\n                 , ⟨ A^.hom a\n                   , λ y, { val := f^.hom (a_y' a y)\n                          , property := begin\n                                          refine eq.trans (congr_fun (eq.symm f^.triangle) (a_y' a y)) _,\n                                          exact sorry\n                                        end\n                          }\n                   ⟩\n         , triangle := sorry\n         }\n   , factor := λ A p_HasProd A_HasProd e\n               , sorry\n   , uniq := λ exp_Y_HasFinProduct Z Z_Y_HasFinProduct e u ωu\n             , sorry\n   }\n\n/-! #brief OverCat LeanCat has all exponentials.\n-/\ninstance LeanCat.Over.HasAllExp\n    (T₀ : LeanCat.{ℓ}^.obj)\n    : @HasAllExp (OverCat LeanCat T₀)\n:= { has_exp := LeanCat.Over.HasExp T₀\n   }\n\n/-! #brief LeanCat has exponentials in all slices.\n-/\ninstance LeanCat.HasAllLocalExp\n    : HasAllLocalExp LeanCat.{ℓ}\n:= { has_exp := LeanCat.Over.HasExp\n   }\n\n\n/- -----------------------------------------------------------------------\nSubobject classifiers.\n----------------------------------------------------------------------- -/\n\n/-! #brief Axiom of choice gives LeanCat a subobject classifier.\n-/\nnoncomputable instance LeanCat.HasSubobjClass\n    : HasSubobjClass LeanCat.{ℓ}\n:= HasSubobjClass.show\n    (λ LeanCat_HasFinal, Lean.LevelMax Prop)\n    (λ LeanCat_HasFinal, λ u, Lean.LevelMax.lift true)\n    (λ LeanCat_HasFinal U X m m_Monic, λ x, Lean.LevelMax.lift (∃ (u : U), m u = x))\n    (λ LeanCat_HasFinal U X V m m_Monic h ωh x\n     , let u₀ : ∃ (u : U), m u = h x\n             := begin\n                  apply of_iff_true,\n                  apply eq.to_iff,\n                  apply Lean.LevelMax.lift.inj,\n                  apply congr_fun ωh\n                end in\n       let u : ∃! (u : U), h x = m u\n            := exists.elim u₀\n                (λ u ωu\n                 , exists_unique.intro u (eq.symm ωu)\n                    (λ u' ωu', LeanCat.Monic.inj m_Monic\n                                (eq.symm (eq.trans ωu ωu'))))\n       in unique_choice u)\n    (λ LeanCat_HasFinal U X m m_Monic\n     , begin\n         apply funext, intro u,\n         apply congr_arg Lean.LevelMax.lift,\n         apply iff.to_eq,\n         apply iff_true_intro,\n         apply exists.intro u,\n         trivial\n       end)\n    (λ LeanCat_HasFinal U V X m m_Monic h ωh\n     , begin\n         apply funext, intro v,\n         dsimp, unfold LeanCat SortCat, dsimp,\n         generalize (of_iff_true (eq.to_iff (Lean.LevelMax.lift.inj (congr_fun ωh v)))) ω,\n         intro ω, cases ω with u ωu,\n         refine eq.trans (eq.symm _) (eq.symm (congr_arg m unique_choice.simp)),\n         exact ωu\n       end)\n    (λ LeanCat_HasFinal U V X m m_Monic h ωh\n     , begin\n         apply funext, intro v,\n         generalize (of_iff_true (eq.to_iff (Lean.LevelMax.lift.inj (congr_fun ωh v)))) ω,\n         intro ω, cases ω with u ωu,\n         refine eq.trans _ (eq.symm unique_choice.simp),\n         apply LeanCat.Monic.inj m_Monic,\n         exact eq.symm ωu\n       end)\n    (λ LeanCat_HasFinal U X m m_Monic char' char'_IsPullback\n     , sorry)\n\n\n--    , char_uniq\n--       := λ LeanCat_HasFinal U X m m_Monic char' ωchar'\n--          , let char'' : X → Prop\n--                      := λ x, Lean.LevelMax.cases_on (char' x) (λ P, P)\n--         in begin\n--              apply funext, intro x,\n--              assert ωchar'' : char' x = Lean.LevelMax.lift (Lean.LevelMax.cases_on (char' x) (λ P, P)),\n--              { generalize (char' x) char'_x,\n--                intro char'_x, cases char'_x,\n--                trivial,\n--              },\n--              refine eq.trans ωchar'' (congr_arg Lean.LevelMax.lift _),\n--              apply iff.to_eq,\n--              apply iff.intro,\n--              { intro ωP_x, exact sorry\n--              },\n--              { intro ωu, cases ωu with u ωu,\n--                subst ωu,\n--                -- true because ωchar' implies char' (m u) = Lean.LevelMax.lift true.\n--                exact sorry\n--              }\n--            end\n--    }\n\n\n\n/- -----------------------------------------------------------------------\nNatural numbers object.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has an NNO.\n-/\ninstance LeanCat.HasNNO\n    : @HasNNO LeanCat.{ℓ} LeanCat.HasFinal\n:= { nn := Lean.LevelMax ℕ\n   , zero := λ u, Lean.LevelMax.lift 0\n   , succ := Lean.LevelMax.map nat.succ\n   , univ := λ A z s n, nat.rec_on (Lean.LevelMax.unlift n)\n                         (z punit.star)\n                         (λ n' a, s a)\n   , comm_zero\n      := λ A z s\n         , begin\n             apply funext, intro u, cases u,\n             trivial\n           end\n   , comm_succ\n      := λ A z s\n         , begin\n             apply funext, intro n, cases n with n,\n             induction n with n rec,\n             { trivial },\n             { apply congr_arg s,\n               apply rec\n             }\n           end\n   , uniq\n      := λ A z s u' ωzero ωsucc\n         , begin\n             apply funext, intro n, cases n with n,\n             induction n with n rec,\n             { rw ωzero, trivial },\n             { refine eq.trans (eq.symm (congr_fun ωsucc (Lean.LevelMax.lift n))) _,\n               apply congr_arg s rec\n             }\n           end\n   }\n\nend qp\n", "meta": {"author": "intoverflow", "repo": "qvr", "sha": "0cfcd33fe4bf8d93851a00cec5bfd21e77105d74", "save_path": "github-repos/lean/intoverflow-qvr", "path": "github-repos/lean/intoverflow-qvr/qvr-0cfcd33fe4bf8d93851a00cec5bfd21e77105d74/qp/p1_categories/c5_leancat/s1_basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.49326529689524345}}
{"text": "import tactic.transport\nimport order.bounded_order\nimport algebra.lie.basic\n\n-- We verify that `transport` can move a `semiring` across an equivalence.\n-- Note that we've never even mentioned the idea of addition or multiplication to `transport`.\ndef semiring.map {α : Type} [semiring α] {β : Type} (e : α ≃ β) : semiring β :=\nby transport using e\n\n-- Indeed, it can equally well move a `semilattice_sup`.\ndef sup.map {α : Type} [semilattice_sup α] {β : Type} (e : α ≃ β) : semilattice_sup β :=\nby transport using e\n\n-- Verify definitional equality of the new structure data.\nexample {α : Type} [semilattice_sup α] {β : Type} (e : α ≃ β) (x y : β) :\nbegin\n  haveI := sup.map e,\n  exact (x ≤ y) = (e.symm x ≤ e.symm y),\nend :=\nrfl\n\n-- Below we verify in more detail that the transported structure for `semiring`\n-- is definitionally what you would hope for.\n\ninductive mynat : Type\n| zero : mynat\n| succ : mynat → mynat\n\ndef mynat_equiv : ℕ ≃ mynat :=\n{ to_fun := λ n, nat.rec_on n mynat.zero (λ n, mynat.succ),\n  inv_fun := λ n, mynat.rec_on n nat.zero (λ n, nat.succ),\n  left_inv := λ n, begin induction n, refl, exact congr_arg nat.succ n_ih, end,\n  right_inv := λ n, begin induction n, refl, exact congr_arg mynat.succ n_ih, end }\n\n@[simp] lemma mynat_equiv_apply_zero : mynat_equiv 0 = mynat.zero := rfl\n@[simp] lemma mynat_equiv_apply_succ (n : ℕ) :\n  mynat_equiv (n + 1) = mynat.succ (mynat_equiv n) := rfl\n@[simp] lemma mynat_equiv_symm_apply_zero : mynat_equiv.symm mynat.zero = 0:= rfl\n@[simp] lemma mynat_equiv_symm_apply_succ (n : mynat) :\n  mynat_equiv.symm (mynat.succ n) = (mynat_equiv.symm n) + 1 := rfl\n\ninstance semiring_mynat : semiring mynat :=\nsemiring.map mynat_equiv\n\nlemma mynat_add_def (a b : mynat) : a + b = mynat_equiv (mynat_equiv.symm a + mynat_equiv.symm b) :=\nrfl\n\n-- Verify that we can do computations with the transported structure.\nexample :\n  (mynat.succ (mynat.succ mynat.zero)) + (mynat.succ mynat.zero) =\n    (mynat.succ (mynat.succ (mynat.succ mynat.zero))) :=\nrfl\n\nlemma mynat_zero_def : (0 : mynat) = mynat_equiv 0 :=\nrfl\n\nlemma mynat_one_def : (1 : mynat) = mynat_equiv 1 :=\nrfl\n\nlemma mynat_mul_def (a b : mynat) : a * b = mynat_equiv (mynat_equiv.symm a * mynat_equiv.symm b) :=\nrfl\n\nexample : (3 : mynat) + (7 : mynat) = (10 : mynat) :=\nrfl\n\nexample : (2 : mynat) * (2 : mynat) = (4 : mynat) :=\nrfl\n\nexample : (3 : mynat) + (7 : mynat) * (2 : mynat) = (17 : mynat) :=\nrfl\n\nexample : (2 : ℕ) • (3 : mynat) = (6 : mynat) :=\nrfl\n\nexample : (3 : mynat) ^ 2 = (9 : mynat) :=\nrfl\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/test/transport/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177518, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4932121429588586}}
{"text": "example (P Q R S T U: Type)\n(p : P)\n(h : P → Q)\n(i : Q → R)\n(j : Q → T)\n(k : S → T)\n(l : T → U)\n: U :=\nbegin\napply l,\napply j,\napply h,\nexact p,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world05/level04.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4932121282063238}}
{"text": "variable {α : Type*}\n\ndef is_prefix (l₁ : list α) (l₂ : list α) : Prop :=\n  ∃ t, l₁ ++ t = l₂\n\ndef list_has_le : has_le (list α) := ⟨is_prefix⟩\n\nsection\n  local attribute [instance] list_has_le\n\n  theorem list.is_prefix_refl (l : list α) : l ≤ l :=\n    ⟨[], by simp⟩\nend\n\n-- error:\n-- theorem bar (l : list α) : l ≤ l :=\n--   ⟨[], by simp⟩\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch6/ex0406.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.49321212554084}}
{"text": "/-\nCopyright (c) 2020 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Rémy Degenne.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.measure_theory.ess_sup\nimport Mathlib.measure_theory.l1_space\nimport Mathlib.analysis.mean_inequalities\nimport Mathlib.PostPort\n\nuniverses u_1 u_3 u_2 u_4 \n\nnamespace Mathlib\n\n/-!\n# ℒp space and Lp space\n\nThis file describes properties of almost everywhere measurable functions with finite seminorm,\ndenoted by `snorm f p μ` and defined for `p:ennreal` as `0` if `p=0`, `(∫ ∥f a∥^p ∂μ) ^ (1/p)` for\n`0 < p < ∞` and `ess_sup ∥f∥ μ` for `p=∞`.\n\nThe Prop-valued `mem_ℒp f p μ` states that a function `f : α → E` has finite seminorm.\nThe space `Lp α E p μ` is the subtype of elements of `α →ₘ[μ] E` (see ae_eq_fun) such that\n`snorm f p μ` is finite. For `1 ≤ p`, `snorm` defines a norm and Lp is a metric space.\n\nTODO: prove that Lp is complete.\n\n## Main definitions\n\n* `snorm' f p μ` : `(∫ ∥f a∥^p ∂μ) ^ (1/p)` for `f : α → F` and `p : ℝ`, where `α` is a  measurable\n  space and `F` is a normed group.\n* `snorm_ess_sup f μ` : seminorm in `ℒ∞`, equal to the essential supremum `ess_sup ∥f∥ μ`.\n* `snorm f p μ` : for `p : ennreal`, seminorm in `ℒp`, equal to `0` for `p=0`, to `snorm' f p μ`\n  for `0 < p < ∞` and to `snorm_ess_sup f μ` for `p = ∞`.\n\n* `mem_ℒp f p μ` : property that the function `f` is almost everywhere measurable and has finite\n  p-seminorm for measure `μ` (`snorm f p μ < ∞`)\n* `Lp E p μ` : elements of `α →ₘ[μ] E` (see ae_eq_fun) such that `snorm f p μ` is finite. Defined\n  as an `add_subgroup` of `α →ₘ[μ] E`.\n\n-/\n\nnamespace measure_theory\n\n\n/-- `(∫ ∥f a∥^p ∂μ) ^ (1/p)`, which is a seminorm on the space of measurable functions for which\nthis quantity is finite -/\ndef snorm' {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] (f : α → F) (p : ℝ) (μ : measure α) : ennreal :=\n  (lintegral μ fun (a : α) => ↑(nnnorm (f a)) ^ p) ^ (1 / p)\n\n/-- seminorm for `ℒ∞`, equal to the essential supremum of `∥f∥`. -/\ndef snorm_ess_sup {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] (f : α → F) (μ : measure α) : ennreal :=\n  ess_sup (fun (x : α) => ↑(nnnorm (f x))) μ\n\n/-- `ℒp` seminorm, equal to `0` for `p=0`, to `(∫ ∥f a∥^p ∂μ) ^ (1/p)` for `0 < p < ∞` and to\n`ess_sup ∥f∥ μ` for `p = ∞`. -/\ndef snorm {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] (f : α → F) (q : ennreal) (μ : measure α) : ennreal :=\n  ite (q = 0) 0 (ite (q = ⊤) (snorm_ess_sup f μ) (snorm' f (ennreal.to_real q) μ))\n\ntheorem snorm_eq_snorm' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {q : ennreal} (hq_ne_zero : q ≠ 0) (hq_ne_top : q ≠ ⊤) {f : α → F} : snorm f q μ = snorm' f (ennreal.to_real q) μ := sorry\n\n@[simp] theorem snorm_exponent_top {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {f : α → F} : snorm f ⊤ μ = snorm_ess_sup f μ := sorry\n\n/-- The property that `f:α→E` is ae_measurable and `(∫ ∥f a∥^p ∂μ)^(1/p)` is finite -/\ndef mem_ℒp {α : Type u_1} {E : Type u_2} [measurable_space α] [measurable_space E] [normed_group E] (f : α → E) (p : ennreal) (μ : measure α) :=\n  ae_measurable f ∧ snorm f p μ < ⊤\n\ntheorem lintegral_rpow_nnnorm_eq_rpow_snorm' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} {f : α → F} (hp0_lt : 0 < p) : (lintegral μ fun (a : α) => ↑(nnnorm (f a)) ^ p) = snorm' f p μ ^ p := sorry\n\ntheorem mem_ℒp_one_iff_integrable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {f : α → E} : mem_ℒp f 1 μ ↔ integrable f := sorry\n\ntheorem mem_ℒp.snorm_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} (hfp : mem_ℒp f q μ) : snorm f q μ < ⊤ :=\n  and.right hfp\n\ntheorem mem_ℒp.snorm_ne_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} (hfp : mem_ℒp f q μ) : snorm f q μ ≠ ⊤ :=\n  ne_of_lt (and.right hfp)\n\ntheorem lintegral_rpow_nnnorm_lt_top_of_snorm'_lt_top {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} {f : α → F} (hp0_lt : 0 < p) (hfp : snorm' f p μ < ⊤) : (lintegral μ fun (a : α) => ↑(nnnorm (f a)) ^ p) < ⊤ := sorry\n\n@[simp] theorem snorm'_exponent_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {f : α → F} : snorm' f 0 μ = 1 := sorry\n\n@[simp] theorem snorm_exponent_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {f : α → F} : snorm f 0 μ = 0 := sorry\n\ntheorem mem_ℒp_zero_iff_ae_measurable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {f : α → E} : mem_ℒp f 0 μ ↔ ae_measurable f := sorry\n\n@[simp] theorem snorm'_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (hp0_lt : 0 < p) : snorm' 0 p μ = 0 := sorry\n\n@[simp] theorem snorm'_zero' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (hp0_ne : p ≠ 0) (hμ : μ ≠ 0) : snorm' 0 p μ = 0 := sorry\n\n@[simp] theorem snorm_ess_sup_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] : snorm_ess_sup 0 μ = 0 := sorry\n\n@[simp] theorem snorm_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {q : ennreal} : snorm 0 q μ = 0 := sorry\n\ntheorem zero_mem_ℒp {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} : mem_ℒp 0 q μ :=\n  { left := measurable.ae_measurable measurable_zero,\n    right := eq.mpr (id (Eq._oldrec (Eq.refl (snorm 0 q μ < ⊤)) snorm_zero)) ennreal.coe_lt_top }\n\ntheorem snorm'_measure_zero_of_pos {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] {p : ℝ} {f : α → F} (hp_pos : 0 < p) : snorm' f p 0 = 0 := sorry\n\ntheorem snorm'_measure_zero_of_exponent_zero {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] {f : α → F} : snorm' f 0 0 = 1 := sorry\n\ntheorem snorm'_measure_zero_of_neg {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] {p : ℝ} {f : α → F} (hp_neg : p < 0) : snorm' f p 0 = ⊤ := sorry\n\n@[simp] theorem snorm_ess_sup_measure_zero {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] {f : α → F} : snorm_ess_sup f 0 = 0 := sorry\n\n@[simp] theorem snorm_measure_zero {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] {q : ennreal} {f : α → F} : snorm f q 0 = 0 := sorry\n\ntheorem snorm'_const {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (c : F) (hp_pos : 0 < p) : snorm' (fun (x : α) => c) p μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / p) := sorry\n\ntheorem snorm'_const' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} [finite_measure μ] (c : F) (hc_ne_zero : c ≠ 0) (hp_ne_zero : p ≠ 0) : snorm' (fun (x : α) => c) p μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / p) := sorry\n\ntheorem snorm_ess_sup_const {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] (c : F) (hμ : μ ≠ 0) : snorm_ess_sup (fun (x : α) => c) μ = ↑(nnnorm c) := sorry\n\ntheorem snorm'_const_of_probability_measure {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (c : F) (hp_pos : 0 < p) [probability_measure μ] : snorm' (fun (x : α) => c) p μ = ↑(nnnorm c) := sorry\n\ntheorem snorm_const {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {q : ennreal} (c : F) (h0 : q ≠ 0) (hμ : μ ≠ 0) : snorm (fun (x : α) => c) q μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / ennreal.to_real q) := sorry\n\ntheorem snorm_const' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {q : ennreal} (c : F) (h0 : q ≠ 0) (h_top : q ≠ ⊤) : snorm (fun (x : α) => c) q μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / ennreal.to_real q) := sorry\n\ntheorem mem_ℒp_const {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} (c : E) [finite_measure μ] : mem_ℒp (fun (a : α) => c) q μ := sorry\n\ntheorem snorm'_congr_ae {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} {f : α → F} {g : α → F} (hfg : filter.eventually_eq (measure.ae μ) f g) : snorm' f p μ = snorm' g p μ := sorry\n\ntheorem snorm_ess_sup_congr_ae {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {f : α → F} {g : α → F} (hfg : filter.eventually_eq (measure.ae μ) f g) : snorm_ess_sup f μ = snorm_ess_sup g μ := sorry\n\ntheorem snorm_congr_ae {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {q : ennreal} {f : α → F} {g : α → F} (hfg : filter.eventually_eq (measure.ae μ) f g) : snorm f q μ = snorm g q μ := sorry\n\ntheorem mem_ℒp.ae_eq {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} {g : α → E} (hfg : filter.eventually_eq (measure.ae μ) f g) (hf_Lp : mem_ℒp f q μ) : mem_ℒp g q μ := sorry\n\ntheorem mem_ℒp_congr_ae {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} {g : α → E} (hfg : filter.eventually_eq (measure.ae μ) f g) : mem_ℒp f q μ ↔ mem_ℒp g q μ :=\n  { mp := fun (h : mem_ℒp f q μ) => mem_ℒp.ae_eq hfg h,\n    mpr := fun (h : mem_ℒp g q μ) => mem_ℒp.ae_eq (filter.eventually_eq.symm hfg) h }\n\ntheorem snorm'_eq_zero_of_ae_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} {f : α → F} (hp0_lt : 0 < p) (hf_zero : filter.eventually_eq (measure.ae μ) f 0) : snorm' f p μ = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p μ = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p μ = 0)) (snorm'_zero hp0_lt))) (Eq.refl 0))\n\ntheorem snorm'_eq_zero_of_ae_zero' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (hp0_ne : p ≠ 0) (hμ : μ ≠ 0) {f : α → F} (hf_zero : filter.eventually_eq (measure.ae μ) f 0) : snorm' f p μ = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p μ = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p μ = 0)) (snorm'_zero' hp0_ne hμ))) (Eq.refl 0))\n\ntheorem ae_eq_zero_of_snorm'_eq_zero {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {p : ℝ} [opens_measurable_space E] {f : α → E} (hp0 : 0 ≤ p) (hf : ae_measurable f) (h : snorm' f p μ = 0) : filter.eventually_eq (measure.ae μ) f 0 := sorry\n\ntheorem snorm'_eq_zero_iff {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {p : ℝ} [opens_measurable_space E] (hp0_lt : 0 < p) {f : α → E} (hf : ae_measurable f) : snorm' f p μ = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 :=\n  { mp := ae_eq_zero_of_snorm'_eq_zero (le_of_lt hp0_lt) hf, mpr := snorm'_eq_zero_of_ae_zero hp0_lt }\n\ntheorem coe_nnnorm_ae_le_snorm_ess_sup {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] (f : α → F) (μ : measure α) : filter.eventually (fun (x : α) => ↑(nnnorm (f x)) ≤ snorm_ess_sup f μ) (measure.ae μ) :=\n  ennreal.ae_le_ess_sup fun (x : α) => ↑(nnnorm (f x))\n\ntheorem snorm_ess_sup_eq_zero_iff {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {f : α → F} : snorm_ess_sup f μ = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 := sorry\n\ntheorem snorm_eq_zero_iff {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [opens_measurable_space E] {f : α → E} (hf : ae_measurable f) (h0 : q ≠ 0) : snorm f q μ = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 := sorry\n\n@[simp] theorem snorm'_neg {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} {f : α → F} : snorm' (-f) p μ = snorm' f p μ := sorry\n\n@[simp] theorem snorm_neg {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {q : ennreal} {f : α → F} : snorm (-f) q μ = snorm f q μ := sorry\n\ntheorem mem_ℒp.neg {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E} (hf : mem_ℒp f q μ) : mem_ℒp (-f) q μ := sorry\n\ntheorem snorm'_le_snorm'_mul_rpow_measure_univ {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] {p : ℝ} {q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) {f : α → E} (hf : ae_measurable f) : snorm' f p μ ≤ snorm' f q μ * coe_fn μ set.univ ^ (1 / p - 1 / q) := sorry\n\ntheorem snorm'_le_snorm_ess_sup_mul_rpow_measure_univ {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (hp_pos : 0 < p) {f : α → F} : snorm' f p μ ≤ snorm_ess_sup f μ * coe_fn μ set.univ ^ (1 / p) := sorry\n\ntheorem snorm'_le_snorm'_of_exponent_le {α : Type u_1} {E : Type u_2} [measurable_space α] [measurable_space E] [normed_group E] [borel_space E] {p : ℝ} {q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) (μ : measure α) [probability_measure μ] {f : α → E} (hf : ae_measurable f) : snorm' f p μ ≤ snorm' f q μ := sorry\n\ntheorem snorm'_le_snorm_ess_sup {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (hp_pos : 0 < p) {f : α → F} [probability_measure μ] : snorm' f p μ ≤ snorm_ess_sup f μ := sorry\n\ntheorem snorm_le_snorm_of_exponent_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal} {q : ennreal} (hpq : p ≤ q) [probability_measure μ] {f : α → E} (hf : ae_measurable f) : snorm f p μ ≤ snorm f q μ := sorry\n\ntheorem snorm'_lt_top_of_snorm'_lt_top_of_exponent_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] {p : ℝ} {q : ℝ} [finite_measure μ] {f : α → E} (hf : ae_measurable f) (hfq_lt_top : snorm' f q μ < ⊤) (hp_nonneg : 0 ≤ p) (hpq : p ≤ q) : snorm' f p μ < ⊤ := sorry\n\ntheorem mem_ℒp.mem_ℒp_of_exponent_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal} {q : ennreal} [finite_measure μ] {f : α → E} (hfq : mem_ℒp f q μ) (hpq : p ≤ q) : mem_ℒp f p μ := sorry\n\ntheorem mem_ℒp.integrable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] (hq1 : 1 ≤ q) {f : α → E} [finite_measure μ] (hfq : mem_ℒp f q μ) : integrable f :=\n  iff.mp mem_ℒp_one_iff_integrable (mem_ℒp.mem_ℒp_of_exponent_le hfq hq1)\n\ntheorem snorm'_add_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {p : ℝ} [borel_space E] {f : α → E} {g : α → E} (hf : ae_measurable f) (hg : ae_measurable g) (hp1 : 1 ≤ p) : snorm' (f + g) p μ ≤ snorm' f p μ + snorm' g p μ := sorry\n\ntheorem snorm_ess_sup_add_le {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {f : α → F} {g : α → F} : snorm_ess_sup (f + g) μ ≤ snorm_ess_sup f μ + snorm_ess_sup g μ := sorry\n\ntheorem snorm_add_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E} {g : α → E} (hf : ae_measurable f) (hg : ae_measurable g) (hq1 : 1 ≤ q) : snorm (f + g) q μ ≤ snorm f q μ + snorm g q μ := sorry\n\ntheorem snorm_add_lt_top_of_one_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E} {g : α → E} (hf : mem_ℒp f q μ) (hg : mem_ℒp g q μ) (hq1 : 1 ≤ q) : snorm (f + g) q μ < ⊤ :=\n  lt_of_le_of_lt (snorm_add_le (and.left hf) (and.left hg) hq1)\n    (iff.mpr ennreal.add_lt_top { left := and.right hf, right := and.right hg })\n\ntheorem snorm'_add_lt_top_of_le_one {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {p : ℝ} [borel_space E] {f : α → E} {g : α → E} (hf : ae_measurable f) (hg : ae_measurable g) (hf_snorm : snorm' f p μ < ⊤) (hg_snorm : snorm' g p μ < ⊤) (hp_pos : 0 < p) (hp1 : p ≤ 1) : snorm' (f + g) p μ < ⊤ := sorry\n\ntheorem snorm_add_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E} {g : α → E} (hf : mem_ℒp f q μ) (hg : mem_ℒp g q μ) : snorm (f + g) q μ < ⊤ := sorry\n\ntheorem mem_ℒp.add {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] [topological_space.second_countable_topology E] {f : α → E} {g : α → E} (hf : mem_ℒp f q μ) (hg : mem_ℒp g q μ) : mem_ℒp (f + g) q μ :=\n  { left := ae_measurable.add (and.left hf) (and.left hg), right := snorm_add_lt_top hf hg }\n\ntheorem mem_ℒp.sub {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] [topological_space.second_countable_topology E] {f : α → E} {g : α → E} (hf : mem_ℒp f q μ) (hg : mem_ℒp g q μ) : mem_ℒp (f - g) q μ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (mem_ℒp (f - g) q μ)) (sub_eq_add_neg f g))) (mem_ℒp.add hf (mem_ℒp.neg hg))\n\ntheorem snorm'_const_smul {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 F] {f : α → F} (c : 𝕜) (hp0_lt : 0 < p) : snorm' (c • f) p μ = ↑(nnnorm c) * snorm' f p μ := sorry\n\ntheorem snorm_ess_sup_const_smul {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 F] {f : α → F} (c : 𝕜) : snorm_ess_sup (c • f) μ = ↑(nnnorm c) * snorm_ess_sup f μ := sorry\n\ntheorem snorm_const_smul {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α} [normed_group F] {q : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 F] {f : α → F} (c : 𝕜) : snorm (c • f) q μ = ↑(nnnorm c) * snorm f q μ := sorry\n\ntheorem mem_ℒp.const_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] [borel_space E] {f : α → E} (hf : mem_ℒp f q μ) (c : 𝕜) : mem_ℒp (c • f) q μ :=\n  { left := ae_measurable.const_smul (and.left hf) c,\n    right := lt_of_le_of_lt (le_of_eq (snorm_const_smul c)) (ennreal.mul_lt_top ennreal.coe_lt_top (and.right hf)) }\n\ntheorem snorm'_smul_le_mul_snorm' {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {p : ℝ} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] [opens_measurable_space E] [measurable_space 𝕜] [opens_measurable_space 𝕜] {q : ℝ} {r : ℝ} {f : α → E} (hf : ae_measurable f) {φ : α → 𝕜} (hφ : ae_measurable φ) (hp0_lt : 0 < p) (hpq : p < q) (hpqr : 1 / p = 1 / q + 1 / r) : snorm' (φ • f) p μ ≤ snorm' φ q μ * snorm' f r μ := sorry\n\n/-! ### Lp space\n\nThe space of equivalence classes of measurable functions for which `snorm f p μ < ⊤`.\n-/\n\n@[simp] theorem snorm_ae_eq_fun {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {p : ennreal} {f : α → E} (hf : ae_measurable f) : snorm (⇑(ae_eq_fun.mk f hf)) p μ = snorm f p μ :=\n  snorm_congr_ae (ae_eq_fun.coe_fn_mk f hf)\n\ntheorem mem_ℒp.snorm_mk_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] {p : ennreal} {f : α → E} (hfp : mem_ℒp f p μ) : snorm (⇑(ae_eq_fun.mk f (and.left hfp))) p μ < ⊤ := sorry\n\n/-- Lp space -/\ndef Lp {α : Type u_1} (E : Type u_2) [measurable_space α] [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] (p : ennreal) (μ : measure α) : add_subgroup (ae_eq_fun α E μ) :=\n  add_subgroup.mk (set_of fun (f : ae_eq_fun α E μ) => snorm (⇑f) p μ < ⊤) sorry sorry sorry\n\n/-- make an element of Lp from a function verifying `mem_ℒp` -/\ndef mem_ℒp.to_Lp {α : Type u_1} {E : Type u_2} [measurable_space α] [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] (f : α → E) {p : ennreal} {μ : measure α} (h_mem_ℒp : mem_ℒp f p μ) : ↥(Lp E p μ) :=\n  { val := ae_eq_fun.mk f sorry, property := mem_ℒp.snorm_mk_lt_top h_mem_ℒp }\n\ntheorem mem_ℒp.coe_fn_to_Lp {α : Type u_1} {E : Type u_2} [measurable_space α] [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {μ : measure α} {p : ennreal} {f : α → E} (hf : mem_ℒp f p μ) : filter.eventually_eq (measure.ae μ) (⇑(mem_ℒp.to_Lp f hf)) f :=\n  ae_eq_fun.coe_fn_mk f (mem_ℒp.to_Lp._proof_1 f hf)\n\nnamespace Lp\n\n\ntheorem mem_Lp_iff_snorm_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun α E μ} : f ∈ Lp E p μ ↔ snorm (⇑f) p μ < ⊤ :=\n  iff.refl (f ∈ Lp E p μ)\n\ntheorem antimono {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] [finite_measure μ] {p : ennreal} {q : ennreal} (hpq : p ≤ q) : Lp E q μ ≤ Lp E p μ :=\n  fun (f : ae_eq_fun α E μ) (hf : f ∈ Lp E q μ) =>\n    and.right (mem_ℒp.mem_ℒp_of_exponent_le { left := ae_eq_fun.ae_measurable f, right := hf } hpq)\n\ntheorem coe_fn_mk {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun α E μ} (hf : snorm (⇑f) p μ < ⊤) : filter.eventually_eq (measure.ae μ) ⇑{ val := f, property := hf } ⇑f := sorry\n\ntheorem snorm_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) : snorm (⇑f) p μ < ⊤ :=\n  subtype.prop f\n\ntheorem snorm_ne_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) : snorm (⇑f) p μ ≠ ⊤ :=\n  has_lt.lt.ne (snorm_lt_top f)\n\ntheorem measurable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) : measurable ⇑f :=\n  ae_eq_fun.measurable (subtype.val f)\n\ntheorem ae_measurable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) : ae_measurable ⇑f :=\n  ae_eq_fun.ae_measurable (subtype.val f)\n\ntheorem mem_ℒp {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) : mem_ℒp (⇑f) p μ :=\n  { left := ae_measurable f, right := subtype.prop f }\n\ntheorem coe_fn_zero {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} : filter.eventually_eq (measure.ae μ) (⇑0) 0 :=\n  ae_eq_fun.coe_fn_zero\n\ntheorem coe_fn_neg {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} : filter.eventually_eq (measure.ae μ) (⇑(-f)) (-⇑f) :=\n  ae_eq_fun.coe_fn_neg ↑f\n\ntheorem coe_fn_add {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} {g : ↥(Lp E p μ)} : filter.eventually_eq (measure.ae μ) (⇑(f + g)) (⇑f + ⇑g) :=\n  ae_eq_fun.coe_fn_add (subtype.val f) (subtype.val g)\n\ntheorem coe_fn_sub {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} {g : ↥(Lp E p μ)} : filter.eventually_eq (measure.ae μ) (⇑(f - g)) (⇑f - ⇑g) :=\n  ae_eq_fun.coe_fn_sub ↑f ↑g\n\ntheorem mem_Lp_const {E : Type u_2} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (α : Type u_1) [measurable_space α] (μ : measure α) (c : E) [finite_measure μ] : ae_eq_fun.const α c ∈ Lp E p μ :=\n  mem_ℒp.snorm_mk_lt_top (mem_ℒp_const c)\n\nprotected instance has_norm {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} : has_norm ↥(Lp E p μ) :=\n  has_norm.mk fun (f : ↥(Lp E p μ)) => ennreal.to_real (snorm (⇑f) p μ)\n\ntheorem norm_def {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) : norm f = ennreal.to_real (snorm (⇑f) p μ) :=\n  rfl\n\n@[simp] theorem norm_zero {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} : norm 0 = 0 := sorry\n\ntheorem norm_eq_zero_iff {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} (hp : 0 < p) : norm f = 0 ↔ f = 0 := sorry\n\n@[simp] theorem norm_neg {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} : norm (-f) = norm f := sorry\n\nprotected instance normed_group {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} [hp : fact (1 ≤ p)] : normed_group ↥(Lp E p μ) :=\n  normed_group.of_core ↥(Lp E p μ) sorry\n\ntheorem mem_Lp_const_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] (c : 𝕜) (f : ↥(Lp E p μ)) : c • ↑f ∈ Lp E p μ := sorry\n\nprotected instance has_scalar {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] : has_scalar 𝕜 ↥(Lp E p μ) :=\n  has_scalar.mk fun (c : 𝕜) (f : ↥(Lp E p μ)) => { val := c • ↑f, property := mem_Lp_const_smul c f }\n\ntheorem coe_fn_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] {f : ↥(Lp E p μ)} {c : 𝕜} : filter.eventually_eq (measure.ae μ) (⇑(c • f)) (c • ⇑f) :=\n  ae_eq_fun.coe_fn_smul c ↑f\n\nprotected instance semimodule {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] : semimodule 𝕜 ↥(Lp E p μ) :=\n  semimodule.mk sorry sorry\n\ntheorem norm_const_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] (c : 𝕜) (f : ↥(Lp E p μ)) : norm (c • f) = norm c * norm f := sorry\n\nprotected instance normed_space {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] [fact (1 ≤ p)] : normed_space 𝕜 ↥(Lp E p μ) :=\n  normed_space.mk sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/measure_theory/lp_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.49321212318544827}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport data.rat.order\nimport data.int.char_zero\nimport algebra.field.opposite\n\n/-!\n# Casts for Rational Numbers\n\n## Summary\n\nWe define the canonical injection from ℚ into an arbitrary division ring and prove various\ncasting lemmas showing the well-behavedness of this injection.\n\n## Notations\n\n- `/.` is infix notation for `rat.mk`.\n\n## Tags\n\nrat, rationals, field, ℚ, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nnamespace rat\nvariable {α : Type*}\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring α]\n\n/-- Construct the canonical injection from `ℚ` into an arbitrary\n  division ring. If the field has positive characteristic `p`,\n  we define `1 / p = 1 / 0 = 0` for consistency with our\n  division by zero convention. -/\n-- see Note [coercion into rings]\n@[priority 900] instance cast_coe : has_coe_t ℚ α := ⟨λ r, r.1 / r.2⟩\n\ntheorem cast_def (r : ℚ) : (r : α) = r.num / r.denom := rfl\n\n@[simp] theorem cast_of_int (n : ℤ) : (of_int n : α) = n :=\nshow (n / (1:ℕ) : α) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : ℤ) : ((n : ℚ) : α) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : ℕ) : ((n : ℚ) : α) = n := cast_coe_int n\n\n@[simp, norm_cast] theorem cast_zero : ((0 : ℚ) : α) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : ℚ) : α) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : ℚ) (a : α) : commute ↑r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : ℚ) (a : α) : (r : α) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : α) (r : ℚ) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : ℤ)\n  (b0 : (b:α) ≠ 0) : (a /. b : α) = a / b :=\nbegin\n  have b0' : b ≠ 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:α) ≠ 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:ℤ) ∣ b, by rwa e at dd) with k ke,\n    have : (b:α) = (d:α) * (k:α), {rw [ke, int.cast_mul], refl},\n    rw [d0, zero_mul] at this, contradiction },\n  rw [num_denom'] at e,\n  have := congr_arg (coe : ℤ → α) ((mk_eq b0' $ ne_of_gt $ int.coe_nat_pos.2 h).1 e),\n  rw [int.cast_mul, int.cast_mul, int.cast_coe_nat] at this,\n  symmetry, change (a / b : α) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      ← mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m + n : ℚ) : α) = m + n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', add_def d₁0' d₂0'],\n  suffices : (n₁ * (d₂ * (d₂⁻¹ * d₁⁻¹)) +\n    n₂ * (d₁ * d₂⁻¹) * d₁⁻¹ : α) = n₁ * d₁⁻¹ + n₂ * d₂⁻¹,\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, left_distrib, right_distrib, mul_inv_rev₀, d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [← mul_assoc (d₂:α), mul_inv_cancel d₂0, one_mul,\n      (nat.cast_commute _ _).eq], simp [d₁0, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : ∀ n, ((-n : ℚ) : α) = -n\n| ⟨n, d, h, c⟩ := show (↑-n / d : α) = -(n / d),\n  by rw [div_eq_mul_inv, div_eq_mul_inv, int.cast_neg, neg_mul_eq_neg_mul]\n\n@[norm_cast] theorem cast_sub_of_ne_zero {m n : ℚ}\n  (m0 : (m.denom : α) ≠ 0) (n0 : (n.denom : α) ≠ 0) : ((m - n : ℚ) : α) = m - n :=\nhave ((-n).denom : α) ≠ 0, by cases n; exact n0,\nby simp [sub_eq_add_neg, (cast_add_of_ne_zero m0 this)]\n\n@[norm_cast] theorem cast_mul_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m * n : ℚ) : α) = m * n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', mul_def d₁0' d₂0'],\n  suffices : (n₁ * ((n₂ * d₂⁻¹) * d₁⁻¹) : α) = n₁ * (d₁⁻¹ * (n₂ * d₂⁻¹)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_rev₀, d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [(d₁.commute_cast (_:α)).inv_right₀.eq]\nend\n\n@[simp] theorem cast_inv_nat (n : ℕ) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nbegin\n  cases n, { simp },\n  simp_rw [coe_nat_eq_mk, inv_def, mk, mk_nat, dif_neg n.succ_ne_zero, mk_pnat],\n  simp [cast_def]\nend\n\n@[simp] theorem cast_inv_int (n : ℤ) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nbegin\n  cases n,\n  { exact cast_inv_nat _ },\n  { simp only [int.cast_neg_succ_of_nat, ← nat.cast_succ, cast_neg, inv_neg, cast_inv_nat] }\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : ∀ {n : ℚ},\n  (n.num : α) ≠ 0 → (n.denom : α) ≠ 0 → ((n⁻¹ : ℚ) : α) = n⁻¹\n| ⟨n, d, h, c⟩ := λ (n0 : (n:α) ≠ 0) (d0 : (d:α) ≠ 0), begin\n  have n0' : (n:ℤ) ≠ 0 := λ e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d0; exact d0 rfl),\n  rw [num_denom', inv_def],\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, inv_div];\n  simp [n0, d0]\nend\n\n@[norm_cast] theorem cast_div_of_ne_zero {m n : ℚ} (md : (m.denom : α) ≠ 0)\n  (nn : (n.num : α) ≠ 0) (nd : (n.denom : α) ≠ 0) : ((m / n : ℚ) : α) = m / n :=\nhave (n⁻¹.denom : ℤ) ∣ n.num,\nby conv in n⁻¹.denom { rw [←(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n⁻¹.denom : α) = 0 → (n.num : α) = 0, from\nλ h, let ⟨k, e⟩ := this in\n  by have := congr_arg (coe : ℤ → α) e;\n     rwa [int.cast_mul, int.cast_coe_nat, h, zero_mul] at this,\nby rw [division_def, cast_mul_of_ne_zero md (mt this nn), cast_inv_of_ne_zero nn nd, division_def]\n\n@[simp, norm_cast] theorem cast_inj [char_zero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := begin\n  refine ⟨λ h, _, congr_arg _⟩,\n  have d₁0 : d₁ ≠ 0 := ne_of_gt h₁,\n  have d₂0 : d₂ ≠ 0 := ne_of_gt h₂,\n  have d₁a : (d₁:α) ≠ 0 := nat.cast_ne_zero.2 d₁0,\n  have d₂a : (d₂:α) ≠ 0 := nat.cast_ne_zero.2 d₂0,\n  rw [num_denom', num_denom'] at h ⊢,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d₁0, d₂0] at h ⊢,\n  rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂:α)).inv_left₀.eq,\n    ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm,\n    ← int.cast_coe_nat, ← int.cast_mul, ← int.cast_coe_nat, ← int.cast_mul,\n    int.cast_inj, ← mk_eq (int.coe_nat_ne_zero.2 d₁0) (int.coe_nat_ne_zero.2 d₂0)] at h\nend\n\ntheorem cast_injective [char_zero α] : function.injective (coe : ℚ → α)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 :=\nby rw [← cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero α] {n : ℚ} : (n : α) ≠ 0 ↔ n ≠ 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero α] (m n) :\n  ((m + n : ℚ) : α) = m + n :=\ncast_add_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_sub [char_zero α] (m n) :\n  ((m - n : ℚ) : α) = m - n :=\ncast_sub_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_mul [char_zero α] (m n) :\n  ((m * n : ℚ) : α) = m * n :=\ncast_mul_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_bit0 [char_zero α] (n : ℚ) :\n  ((bit0 n : ℚ) : α) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero α] (n : ℚ) :\n  ((bit1 n : ℚ) : α) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariable (α)\n\n/-- Coercion `ℚ → α` as a `ring_hom`. -/\ndef cast_hom [char_zero α] : ℚ →+* α := ⟨coe, cast_one, cast_mul, cast_zero, cast_add⟩\n\nvariable {α}\n\n@[simp] lemma coe_cast_hom [char_zero α] : ⇑(cast_hom α) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv [char_zero α] (n) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\n(cast_hom α).map_inv _\n\n@[simp, norm_cast] theorem cast_div [char_zero α] (m n) :\n  ((m / n : ℚ) : α) = m / n :=\n(cast_hom α).map_div _ _\n\n@[norm_cast] theorem cast_mk [char_zero α] (a b : ℤ) : ((a /. b) : α) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow [char_zero α] (q) (k : ℕ) :\n  ((q ^ k : ℚ) : α) = q ^ k :=\n(cast_hom α).map_pow q k\n\nend with_div_ring\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field α] : ∀ {n : ℚ}, 0 ≤ (n : α) ↔ 0 ≤ n\n| ⟨n, d, h, c⟩ :=\n  by { rw [num_denom', cast_mk, mk_eq_div, div_nonneg_iff, div_nonneg_iff], norm_cast }\n\n@[simp, norm_cast] theorem cast_le [linear_ordered_field α] {m n : ℚ} : (m : α) ≤ n ↔ m ≤ n :=\nby rw [← sub_nonneg, ← cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field α] {m n : ℚ} : (m : α) < n ↔ m < n :=\nby simpa [-cast_le] using not_congr (@cast_le α _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field α] {n : ℚ} : (n : α) ≤ 0 ↔ n ≤ 0 :=\nby rw [← cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field α] {n : ℚ} : (0 : α) < n ↔ 0 < n :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field α] {n : ℚ} : (n : α) < 0 ↔ n < 0 :=\nby rw [← cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : ∀ n : ℚ, ↑n = n\n| ⟨n, d, h, c⟩ := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp] lemma cast_hom_rat : cast_hom ℚ = ring_hom.id ℚ :=\nring_hom.ext cast_id\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field α] {a b : ℚ} :\n  (↑(min a b) : α) = min a b :=\nby by_cases a ≤ b; simp [h, min_def]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field α] {a b : ℚ} :\n  (↑(max a b) : α) = max a b :=\nby by_cases b ≤ a; simp [h, max_def]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field α] {q : ℚ} :\n  ((|q| : ℚ) : α) = |q| :=\nby simp [abs_eq_max_neg]\n\nend rat\n\nopen rat ring_hom\n\nlemma ring_hom.eq_rat_cast {k} [division_ring k] (f : ℚ →+* k) (r : ℚ) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [← int.cast_coe_nat, ← mk_eq_div, num_denom]\n     ... = f r.1 / f r.2 : f.map_div _ _\n     ... = r.1 / r.2     : by rw [map_nat_cast, map_int_cast]\n\n-- This seems to be true for a `[char_p k]` too because `k'` must have the same characteristic\n-- but the proof would be much longer\nlemma ring_hom.map_rat_cast {k k'} [division_ring k] [char_zero k] [division_ring k']\n  (f : k →+* k') (r : ℚ) :\n  f r = r :=\n(f.comp (cast_hom k)).eq_rat_cast r\n\nlemma ring_hom.ext_rat {R : Type*} [semiring R] (f g : ℚ →+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let φ : ℤ →+* R := f.comp (int.cast_ring_hom ℚ),\n  let ψ : ℤ →+* R := g.comp (int.cast_ring_hom ℚ),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:ℚ) ≠ 0 := nat.cast_ne_zero.2 b0,\n  have : ∀ n : ℤ, f n = g n := λ n, show φ n = ψ n, by rw [φ.ext_int ψ],\n  calc f (a * b⁻¹)\n      = f a * f b⁻¹ * (g (b:ℤ) * g b⁻¹) :\n        by rw [int.cast_coe_nat, ← g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b⁻¹ * (f (b:ℤ) * g b⁻¹) : by rw [this a, ← this b]\n  ... = g (a * b⁻¹) :\n        by rw [int.cast_coe_nat, mul_assoc, ← mul_assoc (f b⁻¹),\n              ← f.map_mul, inv_mul_cancel b0', f.map_one, one_mul, g.map_mul]\nend\n\ninstance rat.subsingleton_ring_hom {R : Type*} [semiring R] : subsingleton (ℚ →+* R) :=\n⟨ring_hom.ext_rat⟩\n\nnamespace monoid_with_zero_hom\n\nvariables {M : Type*} [group_with_zero M]\n\n/-- If `f` and `g` agree on the integers then they are equal `φ`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : ℚ →*₀ M}\n  (same_on_int : f.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : ∀ k : ℤ, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [← @rat.num_denom x, rat.mk_eq_div, f.map_div, g.map_div,\n    same_on_int' x.num, same_on_int' x.denom],\nend\n\n/-- Positive integer values of a morphism `φ` and its value on `-1` completely determine `φ`. -/\ntheorem ext_rat_on_pnat {f g : ℚ →*₀ M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : ∀ n : ℕ, 0 < n → f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) ‹_›\n\nend monoid_with_zero_hom\n\nnamespace mul_opposite\n\nvariables {α : Type*} [division_ring α]\n\n@[simp, norm_cast] lemma op_rat_cast (r : ℚ) : op (r : α) = (↑r : αᵐᵒᵖ) :=\nby rw [cast_def, div_eq_mul_inv, op_mul, op_inv, op_nat_cast, op_int_cast,\n    (commute.cast_int_right _ r.num).eq, cast_def, div_eq_mul_inv]\n\n@[simp, norm_cast] lemma unop_rat_cast (r : ℚ) : unop (r : αᵐᵒᵖ) = r :=\nby rw [cast_def, div_eq_mul_inv, unop_mul, unop_inv, unop_nat_cast, unop_int_cast,\n    (commute.cast_int_right _ r.num).eq, cast_def, div_eq_mul_inv]\n\nend mul_opposite\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/data/rat/cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484144, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.4931457611793892}}
{"text": "import ..lovelib\n\n\n/-!\n\n# LoVe Demo 1: Definitions and Statements\n\nWe introduce the basics of Lean and proof assistants, without trying to carry\nout actual proofs yet. We focus on specifying objects and statements of their\nintended properties. -/\n\n\nset_option pp.beta true\nset_option pp.generalized_field_notation false\n\nnamespace LoVe\n\n\n/-! ## A View of Lean\n\nLean is a proof assistant developed principally by Leonardo de Moura \nat Microsoft Research. Note: we are using Lean _3_ in this class. You might \nfind information online about Lean _4_, which is in a pre-release stage. \n\nIn a first approximation:\n\n    Lean = functional programming + logic\n\nIn today's lecture, we cover inductive types, recursive functions, and lemma\nstatements.\n\nIf you are not familiar with typed functional programming (e.g., Haskell, ML,\nOCaml, Scala), we recommend that you study a tutorial, such as the first\nchapters of the online tutorial __Learn You a Haskell for Great Good!__:\n\n    http://learnyouahaskell.com/chapters\n\nMake sure to at least reach the section titled \"Lambdas\".\n\nSome keywords we'll talk about over the next few days/weeks:\n\n* Dependent types\n* Martin-Lof type theory\n* Calculus of constructions\n\nThese all refer to the type theory of Lean, or equivalently, it's logic. \n(Why are these the same? Stay tuned!)\nThis is what Lean adds over many other strongly typed functional languages.\n\n## Types and Terms\n\nSimilar to simply typed λ-calculus or typed functional programming languages\n(ML, OCaml, Haskell).\n\nTypes `σ`, `τ`, `υ`:\n\n* type variables `α`;\n* basic types `T`;\n* complex types `T σ1 … σN`.\n\n-/\n\n#check ℕ\n#check ℤ\n\n#check empty\n#check unit\n#check bool\n\n/-!\nSome type constructors `T` are written infix, e.g., `→` (function type).\n\nThe function arrow is right-associative:\n`σ₁ → σ₂ → σ₃ → τ` = `σ₁ → (σ₂ → (σ₃ → τ))`.\n\n-/ \n\n#check ℕ → ℤ\n#check ℤ → ℕ\n#check bool → ℕ → ℤ\n#check (bool → ℕ) → ℤ\n#check ℕ → (bool → ℕ) → ℤ\n\n#check prod ℕ bool \n#check prod\n\n/-!\n\nPolymorphic types are also possible. In Lean, the type variables must be bound\nusing `∀`, e.g., `∀α, α → α`.\n\nYou'll also see the capital Pi `Π` used in place of `∀`. \n\n-/\n\n#check ∀ (α : Type), α → α\n\n/-!\nTerms `t`, `u`:\n\n* constants `c`;\n* variables `x`;\n* applications `t u`;\n* λ-expressions `λx, t`.\n\n__Currying__: functions can be\n\n* fully applied (e.g., `f x y z` if `f` is ternary);\n* partially applied (e.g., `f x y`, `f x`);\n* left unapplied (e.g., `f`).\n\nApplication is left-associative: `f x y z` = `((f x) y) z`. -/\n\n\n#check λx : ℕ, x\n#check λf : ℕ → ℕ, λg : ℕ → ℕ, λh : ℕ → ℕ, λx : ℕ, h (g (f x))\n#check λ(f g h : ℕ → ℕ) (x : ℕ), h (g (f x))\n\nconstants a b : ℤ\nconstant f : ℤ → ℤ\nconstant g : ℤ → ℤ → ℤ\n\n#check λx : ℤ, g (f (g a x)) (g x b)\n#check λx, g (f (g a x)) (g x b)\n\n#check λx, x\n\nconstant trool : Type\nconstants trool.true trool.false trool.maybe : trool\n\n\n/-! ### Type Checking and Type Inference\n\nType checking and type inference are decidable problems, but this property is\nquickly lost if features such as overloading or subtyping are added.\n\nType judgment: `C ⊢ t : σ`, meaning `t` has type `σ` in local context `C`.\n\nTyping rules:\n\n    —————————— Cst   if c is declared with type σ\n    C ⊢ c : σ\n\n    —————————— Var   if x : σ occurs in C\n    C ⊢ x : σ\n\n    C ⊢ t : σ → τ    C ⊢ u : σ\n    ——————————————————————————— App\n    C ⊢ t u : τ\n\n    C, x : σ ⊢ t : τ\n    ———————————————————————— Lam\n    C ⊢ (λx : σ, t) : σ → τ\n\n\n### Type Inhabitation\n\nGiven a type `σ`, the __type inhabitation__ problem consists of finding a term\nof that type.\n\nRecursive procedure:\n\n1. If `σ` is of the form `τ → υ`, a candidate inhabitant is an anonymous\n   function of the form `λx, _`.\n\n2. Alternatively, you can use any constant or variable `x : τ₁ → ⋯ → τN → σ` to\n   build the term `x _ … _`. -/\n\nconstants α β γ : Type\n\ndef some_fun_of_type : (α → β → γ) → ((β → α) → β) → α → γ :=\nλf g a, f a (g (λb, a))\n\n\n/-! ## Type Definitions\n\nAn __inductive type__ (also called __inductive datatype__,\n__algebraic datatype__, or just __datatype__) is a type that consists of all the\nvalues that can be built using a finite number of applications of its\n__constructors__, and only those.\n\n\n### Natural Numbers -/\n\nnamespace my_nat\n\n/-! Definition of type `nat` (= `ℕ`) of natural numbers, using Peano-style unary\nnotation: -/\n\ninductive nat : Type\n| zero : nat\n| succ : nat → nat\n\n#check nat\n#check nat.zero\n#check nat.succ\n\nend my_nat\n\n#print nat\n#print ℕ\n\n\n/-! ### Arithmetic Expressions -/\n\ninductive aexp : Type\n| num : ℤ → aexp\n| var : string → aexp\n| add : aexp → aexp → aexp\n| sub : aexp → aexp → aexp\n| mul : aexp → aexp → aexp\n| div : aexp → aexp → aexp\n\n\n/-! ### Lists -/\n\nnamespace my_list\n\ninductive list (α : Type) : Type\n| nil  : list\n| cons : α → list → list\n\n#check list.nil\n#check list.cons\n\nend my_list\n\n#print list\n\n\n/-! ## Function Definitions\n\nThe syntax for defining a function operating on an inductive type is very\ncompact: We define a single function and use __pattern matching__ to extract the\narguments to the constructors. -/\n\ndef add : ℕ → ℕ → ℕ\n| m nat.zero     := m\n| m (nat.succ n) := nat.succ (add m n)\n\n#eval add 2 7\n#reduce add 2 7\n\ndef mul : ℕ → ℕ → ℕ\n| _ nat.zero     := nat.zero\n| m (nat.succ n) := add m (mul m n)\n\n#eval mul 2 7\n\n#print mul\n#print mul._main\n\ndef power : ℕ → ℕ → ℕ\n| _ nat.zero     := 1\n| m (nat.succ n) := m * power m n\n\n#eval power 2 5\n\ndef power₂ (m : ℕ) : ℕ → ℕ\n| nat.zero     := 1\n| (nat.succ n) := m * power₂ n\n\n#eval power₂ 2 5\n\ndef iter (α : Type) (z : α) (f : α → α) : ℕ → α\n| nat.zero     := z\n| (nat.succ n) := f (iter n)\n\n#check iter\n\ndef power₃ (m n : ℕ) : ℕ :=\niter ℕ 1 (λl, m * l) n\n\n#eval power₃ 2 5\n\ndef append (α : Type) : list α → list α → list α\n| list.nil         ys := ys\n| (list.cons x xs) ys := list.cons x (append xs ys)\n\n#check append\n#eval append _ [3, 1] [4, 1, 5]\n\n/-! Aliases:\n\n    `[]`          := `nil`\n    `x :: xs`     := `cons x xs`\n    `[x₁, …, xN]` := `x₁ :: … :: xN :: []` -/\n\ndef append₂ {α : Type} : list α → list α → list α\n| list.nil         ys := ys\n| (list.cons x xs) ys := list.cons x (append₂ xs ys)\n\n#check append₂\n#eval append₂ [3, 1] [4, 1, 5]\n\n#check @append₂\n#eval @append₂ _ [3, 1] [4, 1, 5]\n\ndef append₃ {α : Type} : list α → list α → list α\n| []        ys := ys\n| (x :: xs) ys := x :: append₃ xs ys\n\ndef reverse {α : Type} : list α → list α\n| []        := []\n| (x :: xs) := reverse xs ++ [x]\n\ndef eval (env : string → ℤ) : aexp → ℤ\n| (aexp.num i)     := i\n| (aexp.var x)     := env x\n| (aexp.add e₁ e₂) := eval e₁ + eval e₂\n| (aexp.sub e₁ e₂) := eval e₁ - eval e₂\n| (aexp.mul e₁ e₂) := eval e₁ * eval e₂\n| (aexp.div e₁ e₂) := eval e₁ / eval e₂\n\n#eval eval (λs, 7) (aexp.div (aexp.var \"x\") (aexp.num 0))\n\n/-! Lean only accepts the function definitions for which it can prove\ntermination. In particular, it accepts __structurally recursive__ functions,\nwhich peel off exactly one constructor at a time.\n\n\n## Lemma Statements\n\nNotice the similarity with `def` commands. -/\n\nnamespace sorry_lemmas\n\nlemma add_comm (m n : ℕ) :\n  add m n = add n m :=\nsorry\n\nlemma add_assoc (l m n : ℕ) :\n  add (add l m) n = add l (add m n) :=\nsorry\n\nlemma mul_comm (m n : ℕ) :\n  mul m n = mul n m :=\nsorry\n\nlemma mul_assoc (l m n : ℕ) :\n  mul (mul l m) n = mul l (mul m n) :=\nsorry\n\nlemma mul_add (l m n : ℕ) :\n  mul l (add m n) = add (mul l m) (mul l n) :=\nsorry\n\nlemma reverse_reverse {α : Type} (xs : list α) :\n  reverse (reverse xs) = xs :=\nsorry\n\n/-! Axioms are like lemmas but without proofs (`:= …`). Constant declarations\nare like definitions but without bodies (`:= …`). -/\n\nconstants a b : ℤ\n\naxiom a_less_b :\n  a < b\n\nend sorry_lemmas\n\nend LoVe\n", "meta": {"author": "BrownCS1951x", "repo": "fpv2022", "sha": "aeaf291183721460387f8ae4c3c008836b8460e7", "save_path": "github-repos/lean/BrownCS1951x-fpv2022", "path": "github-repos/lean/BrownCS1951x-fpv2022/fpv2022-aeaf291183721460387f8ae4c3c008836b8460e7/src/lectures/love01_definitions_and_statements_demo.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722129, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.49307055734743166}}
{"text": "/- Copyright 2019 (c) Hans-Dieter Hiep. All rights reserved. Released under MIT license as described in the file LICENSE. -/\n\nimport data.finmap data.bool data.vector data.list data.multiset\nimport data.finsupp\n\nopen nat option finset list\n\nuniverses u v\nvariables {α : Type u} {β : Type v}\n\n/- Indices of a list -/\n@[derive decidable_eq]\ninductive pointer: list α → Type u\n| here (x : α) (xs : list α): pointer (x :: xs)\n| tail {xs : list α} (y : α): pointer xs → pointer (y :: xs)\n\n/- List membership with concrete witness (position) -/\n@[derive decidable_eq]\ninductive list_at: α → list α → Type u\n| here (x : α) (xs : list α): list_at x (x :: xs)\n| tail {x : α} {l : list α} (y : α): list_at x l → list_at x (y :: l)\n\nlemma list_at_mem {x : α} {l : list α} : list_at x l → x ∈ l :=\nbegin\n    intro H,\n    induction l,\n    cases H,\n    cases H,\n    constructor, refl,\n    have: x ∈ l_tl,\n        apply l_ih, assumption,\n    right, assumption\nend\n\n/- A FIFO queue is a list of elements. Adding an element appends it to the back. Removing an element takes it from the front. -/\n@[derive decidable_eq]\nstructure queue (α : Type u) := (l : list α)\n\n@[reducible]\ndef queue.add (q : queue α) (x : α) : queue α := ⟨q.l ++ [x]⟩\n@[reducible]\ndef queue.empty : queue α → bool\n| ⟨[]⟩ := tt\n| ⟨(x :: l)⟩ := ff\ndef queue.full : queue α → Prop := λq, q ≠ ⟨[]⟩\n@[reducible]\ndef queue.remove : Π q : queue α, queue.full q → α × queue α\n| ⟨[]⟩ H := begin exfalso, apply H, simp end\n| ⟨(x :: l)⟩ _ := ⟨x, ⟨l⟩⟩\n@[reducible]\ndef queue.first (q : queue α) (H : queue.full q) : α :=\n  (queue.remove q H).fst\n@[reducible]\ndef queue.unshift (q : queue α) (H : queue.full q) : queue α :=\n  (queue.remove q H).snd\n@[reducible]\ndef queue.poll : queue α → option (α × queue α)\n| ⟨[]⟩ := none\n| ⟨(x :: l)⟩ := some ⟨x, ⟨l⟩⟩\ninstance queue.has_zero : has_zero (queue α) := ⟨⟨[]⟩⟩\n\n/- A function with finite support can be updated. This either adds a new value, or overwrites the value previoulsy mapped. -/\nnamespace finsupp\nvariables [decidable_eq α] [decidable_eq β] [has_zero β]\n\ndef update (f : α →₀ β) (a : α) (b : β) : α →₀ β :=\n  ⟨if b = 0 then f.support.erase a else f.support ∪ {a},\n   (λa', if a = a' then b else f a'), λa',\n    begin\n      by_cases H : (a = a'); by_cases G : (b = 0); simp [G,H],\n      { split, {intro, cases a_1, assumption}, {intro,\n          have : ¬a' = a, intro, apply H,\n            apply eq.symm, assumption, \n          exact ⟨this, a_1⟩ } },\n      { split, {intro, cases a_1, exfalso,\n          apply H, apply eq.symm, assumption, assumption},\n        { intro, right, assumption } }\n    end⟩\n\n@[simp]\ntheorem update.to_fun (f : α →₀ β) (a : α) (b : β) :\n  (update f a b).to_fun = (λa', if a = a' then b else f a') := rfl\n\n@[simp]\ntheorem update.app_new_eq (f : α →₀ β) (a : α) (b : β) :\n  (update f a b) a = b :=\nbegin\n  simp [coe_fn], unfold has_coe_to_fun.coe, simp\nend\n\ntheorem update.app_old_eq (f : α →₀ β) (a : α) (b : β)\n    (c : α) (H : a ≠ c) :\n  (update f a b) c = f c :=\nbegin\n  simp [coe_fn], unfold has_coe_to_fun.coe, simp [H, coe_fn],\n  unfold has_coe_to_fun.coe\nend\n\nend finsupp\n\n/- Elimination and matching with equality (thanks to Rob Lewis) -/\ndef option.elim {β : Sort v} (t : option α)\n    (f : t = none → β) (g : Π(a : α), t = some a → β) : β :=\n  match t, rfl : (∀ b, t = b → β) with\n  | none, h := f h\n  | (some a), h := g a h\n  end\n\n/- Lift list of options -/\nlemma head_lift_nil {a : α} :\n  head (lift (@nil α)) ≠ some a :=\nbegin\n  intro,\n  simp [lift, has_lift.lift, default, inhabited.default] at a_1,\n  assumption\nend\nlemma tail_lift_some {hd a : α} {tl : list α} :\n  head (lift (list.cons hd tl)) = some a → hd = a :=\nbegin\n  intro,\n  simp [lift, has_lift.lift, coe] at a_1,\n  simp [lift_t, has_lift_t.lift, coe_t, has_coe_t.coe] at a_1,\n  assumption\nend\n\n/- Decomposition of finite set: a singleton and remainder set, such they are disjoint. A decomposition can be coerced to their union set. -/\ninductive decomp_finset [decidable_eq α]\n  (rem: finset α) (elem: α) : Type\n| mk: elem ∉ rem → decomp_finset\ninstance decomp_finset.coe_finset [decidable_eq α]\n  (rem: finset α) (elem: α) : has_coe (decomp_finset rem elem) (finset α) := ⟨λ_, rem ∪ {elem}⟩\n\nnotation Γ `;;` x := decomp_finset Γ x\n\n/- Existence of a proof of a proposition implies that proposition. -/\nlemma exists_proof_prop (P Q : Prop) : (∃x : P, Q) → P :=\nbegin\n  intro, cases a, assumption\nend\n", "meta": {"author": "praalhans", "repo": "lean-abs", "sha": "5d23eec7234c880f5ebc0d7b831caf55119edef8", "save_path": "github-repos/lean/praalhans-lean-abs", "path": "github-repos/lean/praalhans-lean-abs/lean-abs-5d23eec7234c880f5ebc0d7b831caf55119edef8/src/util.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.4929194411828172}}
{"text": "import tactic.lift\nimport data.set.basic\nimport data.int.basic\n\n/-! Some tests of the `lift` tactic. -/\n\nexample (n m k x z u : ℤ) (hn : 0 < n) (hk : 0 ≤ k + n) (hu : 0 ≤ u)\n  (h : k + n = 2 + x) (f : false) :\n  k + n = m + x :=\nbegin\n  lift n to ℕ using le_of_lt hn,\n    guard_target (k + ↑n = m + x), guard_hyp hn : (0 : ℤ) < ↑n,\n  lift m to ℕ,\n    guard_target (k + ↑n = ↑m + x), tactic.swap, guard_target (0 ≤ m), tactic.swap,\n    tactic.num_goals >>= λ n, guard (n = 2),\n  lift (k + n) to ℕ using hk with l hl,\n    guard_hyp l : ℕ, guard_hyp hl : ↑l = k + ↑n, guard_target (↑l = ↑m + x),\n    tactic.success_if_fail (tactic.get_local `hk),\n  lift x to ℕ with y hy,\n    guard_hyp y : ℕ, guard_hyp hy : ↑y = x, guard_target (↑l = ↑m + x),\n  lift z to ℕ with w,\n    guard_hyp w : ℕ, tactic.success_if_fail (tactic.get_local `z),\n  lift u to ℕ using hu with u rfl hu,\n    guard_hyp hu : (0 : ℤ) ≤ ↑u,\n\n  all_goals { exfalso, assumption },\nend\n\n-- test lift of functions\nexample (α : Type*) (f : α → ℤ) (hf : ∀ a, 0 ≤ f a) (hf' : ∀ a, f a < 1) (a : α) : 0 ≤ 2 * f a :=\nbegin\n  lift f to α → ℕ using hf,\n    guard_target ((0:ℤ) ≤ 2 * (λ i : α, (f i : ℤ)) a),\n    guard_hyp hf' : ∀ a, ((λ i : α, (f i:ℤ)) a) < 1,\n  exact int.coe_nat_nonneg _\nend\n\n-- fail gracefully when the lifted variable is a local definition\nexample : let n : ℤ := 3 in n = n :=\nbegin\n  intro n,\n  success_if_fail_with_msg { lift n to ℕ }\n    (\"Cannot substitute variable n, it is a local definition. \" ++\n    \"If you really want to do this, use `clear_value` first.\"),\n  refl\nend\n\ninstance can_lift_unit : can_lift unit unit :=\n⟨id, λ x, true, λ x _, ⟨x, rfl⟩⟩\n\n/- test whether new instances of `can_lift` are added as simp lemmas -/\nrun_cmd do l ← can_lift_attr.get_cache, guard (`can_lift_unit ∈ l)\n\n/- test error messages -/\nexample (n : ℤ) (hn : 0 < n) : true :=\nbegin\n  success_if_fail_with_msg {lift n to ℕ using hn} \"lift tactic failed.\ninvalid type ascription, term has type\\n  0 < n\\nbut is expected to have type\\n  0 ≤ n\",\n  success_if_fail_with_msg {lift (n : option ℤ) to ℕ}\n    \"Failed to find a lift from option ℤ to ℕ. Provide an instance of\\n  can_lift (option ℤ) ℕ\",\n  trivial\nend\n\nexample (n : ℤ) : ℕ :=\nbegin\n  success_if_fail_with_msg {lift n to ℕ}\n    \"lift tactic failed. Tactic is only applicable when the target is a proposition.\",\n  exact 0\nend\n\ninstance can_lift_subtype (R : Type*) (P : R → Prop) : can_lift R {x // P x} :=\n{ coe := coe,\n  cond := λ x, P x,\n  prf := λ x hx, ⟨⟨x, hx⟩, rfl⟩ }\n\ninstance can_lift_set (R : Type*) (s : set R) : can_lift R s :=\n{ coe := coe,\n  cond := λ x, x ∈ s,\n  prf := λ x hx, ⟨⟨x, hx⟩, rfl⟩ }\n\nexample {R : Type*} {P : R → Prop} (x : R) (hx : P x) : true :=\nby { lift x to {x // P x} using hx with y, trivial }\n\n/-! Test that `lift` elaborates `s` as a type, not as a set. -/\nexample {R : Type*} {s : set R} (x : R) (hx : x ∈ s) : true :=\nby { lift x to s using hx with y, trivial }\n\nexample (n : ℤ) (hn : 0 ≤ n) : true :=\nby { lift n to ℕ, trivial, exact hn }\n\nexample (n : ℤ) (hn : 0 ≤ n) : true :=\nby { lift n to ℕ using hn, trivial }\n\nexample (n : ℤ) (hn : n ≥ 0) : true :=\nby { lift n to ℕ using ge.le _, trivial, guard_target (n ≥ 0), exact hn }\n\nexample (n : ℤ) (hn : 0 ≤ 1 * n) : true :=\nbegin\n  lift n to ℕ using by { simpa [int.one_mul] using hn } with k,\n  -- the above braces are optional, but it would be bad style to remove them (see next example)\n  guard_hyp hn : 0 ≤ 1 * ((k : ℕ) : ℤ),\n  trivial\nend\n\nexample (n : ℤ) (hn : 0 ≤ n ↔ true) : true :=\nbegin\n  lift n to ℕ using by { simp [hn] } with k, -- the braces are not optional here\n  trivial\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/test/lift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.4929194411828171}}
{"text": "/-\nCopyright (c) 2021 Alena Gusakov, Bhavik Mehta, Kyle Miller. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alena Gusakov, Bhavik Mehta, Kyle Miller\n-/\nimport data.fintype.basic\nimport data.set.finite\n\n/-!\n# Hall's Marriage Theorem for finite index types\n\nThis module proves the basic form of Hall's theorem.\nIn constrast to the theorem described in `combinatorics.hall.basic`, this\nversion requires that the indexed family `t : ι → finset α` have `ι` be a `fintype`.\nThe `combinatorics.hall.basic` module applies a compactness argument to this version\nto remove the `fintype` constraint on `ι`.\n\nThe modules are split like this since the generalized statement\ndepends on the topology and category theory libraries, but the finite\ncase in this module has few dependencies.\n\nA description of this formalization is in [Gusakov2021].\n\n## Main statements\n\n* `finset.all_card_le_bUnion_card_iff_exists_injective'` is Hall's theorem with\n  a finite index set.  This is elsewhere generalized to\n  `finset.all_card_le_bUnion_card_iff_exists_injective`.\n\n## Tags\n\nHall's Marriage Theorem, indexed families\n-/\n\nopen finset\n\nuniverses u v\n\nnamespace hall_marriage_theorem\n\nvariables {ι : Type u} {α : Type v} [fintype ι] {t : ι → finset α} [decidable_eq α]\n\nlemma hall_cond_of_erase {x : ι} (a : α)\n  (ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card)\n  (s' : finset {x' : ι | x' ≠ x}) :\n  s'.card ≤ (s'.bUnion (λ x', (t x').erase a)).card :=\nbegin\n  haveI := classical.dec_eq ι,\n  specialize ha (s'.image coe),\n  rw [nonempty.image_iff, finset.card_image_of_injective s' subtype.coe_injective] at ha,\n  by_cases he : s'.nonempty,\n  { have ha' : s'.card < (s'.bUnion (λ x, t x)).card,\n    { convert ha he (λ h, by simpa [←h] using mem_univ x) using 2,\n      ext x,\n      simp only [mem_image, mem_bUnion, exists_prop, set_coe.exists,\n                 exists_and_distrib_right, exists_eq_right, subtype.coe_mk], },\n    rw ←erase_bUnion,\n    by_cases hb : a ∈ s'.bUnion (λ x, t x),\n    { rw card_erase_of_mem hb,\n      exact nat.le_pred_of_lt ha' },\n    { rw erase_eq_of_not_mem hb,\n      exact nat.le_of_lt ha' }, },\n  { rw [nonempty_iff_ne_empty, not_not] at he,\n    subst s',\n    simp },\nend\n\n/--\nFirst case of the inductive step: assuming that\n`∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_A {n : ℕ} (hn : fintype.card ι = n + 1)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),\n        by exactI fintype.card ι' ≤ n →\n                  (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                  ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)\n  (ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  haveI : nonempty ι := fintype.card_pos_iff.mp (hn.symm ▸ nat.succ_pos _),\n  haveI := classical.dec_eq ι,\n  /- Choose an arbitrary element `x : ι` and `y : t x`. -/\n  let x := classical.arbitrary ι,\n  have tx_ne : (t x).nonempty,\n  { rw ←finset.card_pos,\n    calc 0 < 1 : nat.one_pos\n       ... ≤ (finset.bUnion {x} t).card : ht {x}\n       ... = (t x).card : by rw finset.singleton_bUnion, },\n  choose y hy using tx_ne,\n  /- Restrict to everything except `x` and `y`. -/\n  let ι' := {x' : ι | x' ≠ x},\n  let t' : ι' → finset α := λ x', (t x').erase y,\n  have card_ι' : fintype.card ι' = n :=\n    calc fintype.card ι' = fintype.card ι - 1 : set.card_ne_eq _\n                     ... = n : by { rw [hn, nat.add_succ_sub_one, add_zero], },\n  rcases ih t' card_ι'.le (hall_cond_of_erase y ha) with ⟨f', hfinj, hfr⟩,\n  /- Extend the resulting function. -/\n  refine ⟨λ z, if h : z = x then y else f' ⟨z, h⟩, _, _⟩,\n  { rintro z₁ z₂,\n    have key : ∀ {x}, y ≠ f' x,\n    { intros x h,\n      simpa [←h] using hfr x, },\n    by_cases h₁ : z₁ = x; by_cases h₂ : z₂ = x; simp [h₁, h₂, hfinj.eq_iff, key, key.symm], },\n  { intro z,\n    split_ifs with hz,\n    { rwa hz },\n    { specialize hfr ⟨z, hz⟩,\n      rw mem_erase at hfr,\n      exact hfr.2, }, },\nend\n\nlemma hall_cond_of_restrict {ι : Type u} {t : ι → finset α} {s : finset ι}\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (s' : finset (s : set ι)) :\n  s'.card ≤ (s'.bUnion (λ a', t a')).card :=\nbegin\n  classical,\n  rw ← card_image_of_injective s' subtype.coe_injective,\n  convert ht (s'.image coe) using 1,\n  apply congr_arg,\n  ext y,\n  simp,\nend\n\nlemma hall_cond_of_compl {ι : Type u} {t : ι → finset α} {s : finset ι}\n  (hus : s.card = (s.bUnion t).card)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (s' : finset (sᶜ : set ι)) :\n  s'.card ≤ (s'.bUnion (λ x', t x' \\ s.bUnion t)).card :=\nbegin\n  haveI := classical.dec_eq ι,\n  have disj : disjoint s (s'.image coe),\n  { simp only [disjoint_left, not_exists, mem_image, exists_prop, set_coe.exists,\n               exists_and_distrib_right, exists_eq_right, subtype.coe_mk],\n    intros x hx hc h,\n    exact absurd hx hc, },\n  have : s'.card = (s ∪ s'.image coe).card - s.card,\n  { simp [disj, card_image_of_injective _ subtype.coe_injective], },\n  rw [this, hus],\n  refine (tsub_le_tsub_right (ht _) _).trans _,\n  rw ← card_sdiff,\n  { refine (card_le_of_subset _).trans le_rfl,\n    intros t,\n    simp only [mem_bUnion, mem_sdiff, not_exists, mem_image, and_imp, mem_union,\n               exists_and_distrib_right, exists_imp_distrib],\n    rintro x (hx | ⟨x', hx', rfl⟩) rat hs,\n    { exact (hs x hx rat).elim },\n    { exact ⟨⟨x', hx', rat⟩, hs⟩, } },\n  { apply bUnion_subset_bUnion_of_subset_left,\n    apply subset_union_left }\nend\n\n/--\nSecond case of the inductive step: assuming that\n`∃ (s : finset ι), s ≠ univ → s.card = (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_B {n : ℕ} (hn : fintype.card ι = n + 1)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),\n        by exactI fintype.card ι' ≤ n →\n                  (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                  ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)\n  (s : finset ι)\n  (hs : s.nonempty)\n  (hns : s ≠ univ)\n  (hus : s.card = (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  haveI := classical.dec_eq ι,\n  /- Restrict to `s` -/\n  let t' : s → finset α := λ x', t x',\n  rw nat.add_one at hn,\n  have card_ι'_le : fintype.card s ≤ n,\n  { apply nat.le_of_lt_succ,\n    calc fintype.card s = s.card : fintype.card_coe _\n                    ... < fintype.card ι : (card_lt_iff_ne_univ _).mpr hns\n                    ... = n.succ : hn },\n  rcases ih t' card_ι'_le (hall_cond_of_restrict ht) with ⟨f', hf', hsf'⟩,\n  /- Restrict to `sᶜ` in the domain and `(s.bUnion t)ᶜ` in the codomain. -/\n  set ι'' := (s : set ι)ᶜ with ι''_def,\n  let t'' : ι'' → finset α := λ a'', t a'' \\ s.bUnion t,\n  have card_ι''_le : fintype.card ι'' ≤ n,\n  { simp_rw [← nat.lt_succ_iff, ← hn, ι'', ← finset.coe_compl, coe_sort_coe],\n    rwa [fintype.card_coe, card_compl_lt_iff_nonempty] },\n  rcases ih t'' card_ι''_le (hall_cond_of_compl hus ht) with ⟨f'', hf'', hsf''⟩,\n  /- Put them together -/\n  have f'_mem_bUnion : ∀ {x'} (hx' : x' ∈ s), f' ⟨x', hx'⟩ ∈ s.bUnion t,\n  { intros x' hx',\n    rw mem_bUnion,\n    exact ⟨x', hx', hsf' _⟩, },\n  have f''_not_mem_bUnion : ∀ {x''} (hx'' : ¬ x'' ∈ s), ¬ f'' ⟨x'', hx''⟩ ∈ s.bUnion t,\n  { intros x'' hx'',\n    have h := hsf'' ⟨x'', hx''⟩,\n    rw mem_sdiff at h,\n    exact h.2, },\n  have im_disj : ∀ (x' x'' : ι) (hx' : x' ∈ s) (hx'' : ¬x'' ∈ s), f' ⟨x', hx'⟩ ≠ f'' ⟨x'', hx''⟩,\n  { intros _ _ hx' hx'' h,\n    apply f''_not_mem_bUnion hx'',\n    rw ←h,\n    apply f'_mem_bUnion, },\n  refine ⟨λ x, if h : x ∈ s then f' ⟨x, h⟩ else f'' ⟨x, h⟩, _, _⟩,\n  { exact hf'.dite _ hf'' im_disj },\n  { intro x,\n    split_ifs with h,\n    { exact hsf' ⟨x, h⟩ },\n    { exact sdiff_subset _ _ (hsf'' ⟨x, h⟩) } }\nend\n\n/--\nHere we combine the two inductive steps into a full strong induction proof,\ncompleting the proof the harder direction of **Hall's Marriage Theorem**.\n-/\ntheorem hall_hard_inductive\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  unfreezingI\n  { induction hn : fintype.card ι using nat.strong_induction_on with n ih generalizing ι },\n  rcases n with _|_,\n  { rw fintype.card_eq_zero_iff at hn,\n    exactI ⟨is_empty_elim, is_empty_elim, is_empty_elim⟩, },\n  { have ih' : ∀ (ι' : Type u) [fintype ι'] (t' : ι' → finset α),\n                 by exactI fintype.card ι' ≤ n →\n                    (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                    ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x,\n    { introsI ι' _ _ hι' ht',\n      exact ih _ (nat.lt_succ_of_le hι') ht' rfl, },\n    by_cases h : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card,\n    { exact hall_hard_inductive_step_A hn ht ih' h, },\n    { push_neg at h,\n      rcases h with ⟨s, sne, snu, sle⟩,\n      exact hall_hard_inductive_step_B hn ht ih' s sne snu (nat.le_antisymm (ht _) sle), } },\nend\n\nend hall_marriage_theorem\n\n/--\nThis is the version of **Hall's Marriage Theorem** in terms of indexed\nfamilies of finite sets `t : ι → finset α` with `ι` a `fintype`.\nIt states that there is a set of distinct representatives if and only\nif every union of `k` of the sets has at least `k` elements.\n\nSee `finset.all_card_le_bUnion_card_iff_exists_injective` for a version\nwhere the `fintype ι` constraint is removed.\n-/\ntheorem finset.all_card_le_bUnion_card_iff_exists_injective'\n  {ι α : Type*} [fintype ι] [decidable_eq α] (t : ι → finset α) :\n  (∀ (s : finset ι), s.card ≤ (s.bUnion t).card) ↔\n    (∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x) :=\nbegin\n  split,\n  { exact hall_marriage_theorem.hall_hard_inductive },\n  { rintro ⟨f, hf₁, hf₂⟩ s,\n    rw ←card_image_of_injective s hf₁,\n    apply card_le_of_subset,\n    intro _,\n    rw [mem_image, mem_bUnion],\n    rintros ⟨x, hx, rfl⟩,\n    exact ⟨x, hx, hf₂ x⟩, },\nend\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/combinatorics/hall/finite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.4929194411828171}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport logic.basic\n\n/-!\n# Extra facts about `pprod`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\nopen function\nvariables {α β γ δ : Sort*}\n\nnamespace pprod\n\n@[simp] lemma mk.eta {p : pprod α β} : pprod.mk p.1 p.2 = p :=\npprod.cases_on p (λ a b, rfl)\n\n@[simp] theorem «forall» {p : pprod α β → Prop} : (∀ x, p x) ↔ (∀ a b, p ⟨a, b⟩) :=\n⟨assume h a b, h ⟨a, b⟩, assume h ⟨a, b⟩, h a b⟩\n\n@[simp] theorem «exists» {p : pprod α β → Prop} : (∃ x, p x) ↔ (∃ a b, p ⟨a, b⟩) :=\n⟨assume ⟨⟨a, b⟩, h⟩, ⟨a, b, h⟩, assume ⟨a, b, h⟩, ⟨⟨a, b⟩, h⟩⟩\n\ntheorem forall' {p : α → β → Prop} : (∀ x : pprod α β, p x.1 x.2) ↔ ∀ a b, p a b :=\npprod.forall\n\ntheorem exists' {p : α → β → Prop} : (∃ x : pprod α β, p x.1 x.2) ↔ ∃ a b, p a b :=\npprod.exists\n\nend pprod\n\nlemma function.injective.pprod_map {f : α → β} {g : γ → δ} (hf : injective f) (hg : injective g) :\n  injective (λ x, ⟨f x.1, g x.2⟩ : pprod α γ → pprod β δ) :=\nλ ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ h,\nhave A : _ := congr_arg pprod.fst h,\nhave B : _ := congr_arg pprod.snd h,\ncongr_arg2 pprod.mk (hf A) (hg B)\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/prod/pprod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.4929194329150393}}
{"text": "import lib.lib09\n\nopen m154\n\n/-\nLe bouquet final\n\nCette feuille utilise tout le cours de MDD 154 pour démontrer de nombreux\nthéorèmes parmi les plus subtils de Math 101 : la caractérisation\nséquentielle des bornes supérieures, l'équivalence entre continuité\nséquentielle et continuité, le fait que toute fonction continue sur un segment\nest majorée et atteint son maximum, et enfin le théorème des valeurs\nintermédiaires.\n\nIl est inutile d'aborder cette feuille sans être à l'aise avec les feuilles\nprécédentes. Réviser les feuilles précédentes et poser des questions est toujours \nune bonne idée.\n\nOn commence par un échauffement, une variante du\n\n  lim_le (hu : limite_suite u x) (ineg : ∀ n, u n ≤ y) : x ≤ y\n\nde la feuille 11, avec l'autre inégalité et seulement à partir d'un certain rang.\n\nOn pourra utiliser les lemmes habituels :\n\n  `abs_inferieur_ssi (x y : ℝ) : |x| ≤ y ↔ -y ≤ x ∧ x ≤ y`\n\n  `superieur_max_ssi (p q r) : r ≥ max p q  ↔ r ≥ p ∧ r ≥ q`\n\n  `inferieur_max_gauche p q : p ≤ max p q`\n\n  `inferieur_max_droite p q : q ≤ max p q`\n\nainsi que le lemme\n\n  `inferieur_si_inferieur_plus_eps : (∀ ε > 0, y ≤ x + ε) →  y ≤ x`\n\ndémontré dans la feuille 11\n-/\n\n-- Si u tend vers x et y ≤ u_n pour n assez grand n alors y ≤ x.\nlemma le_lim {x y : ℝ} {u : ℕ → ℝ} (hu : limite_suite u x)\n  (ineg : ∃ N, ∀ n ≥ N, y ≤ u n) : y ≤ x :=\nbegin\n  sorry\nend\n\n/-\nLe premier objectif sérieux de cette feuille est de démontrer la caractérisation\nséquentielle des bornes supérieures. Pour cela, et pour les objectifs suivants,\nnous aurons besoin de pas mal de choses des feuilles précédentes, et de\nquelques extras.\n\nNous avons démontré dans la feuille 8 qu'une suite constante converge vers\nsa valeur :\n\n  `lim_constante (x : ℝ) : limite_suite (fct n ↦ x) x`\n\net le théorème des gendarmes :\n\n  `gendarmes (lim_u : limite_suite u l) (lim_w : limite_suite w l)`\n    `(hu : ∀ n, u n ≤ v n) (hw : ∀ n, v n ≤ w n)  : limite_suite v l`\n\nDans la feuille 11, nous avons introduit les deux définitions :\n\n  Le réel x est un majorant de l'ensemble de réels A :\n  `def majorant (A : set ℝ) (x : ℝ) := ∀ a ∈ A, a ≤ x`\n\n  Le réel x est une  borne supérieure de l'ensemble de réels A :\n  `def borne_sup (A : set ℝ) (x : ℝ) := majorant A x ∧ ∀ y, majorant A y → x ≤ y`\n\net montré que si un réel x est borne supérieure d'un ensemble de réels A alors,\npour tout y, si y < x alors il existe a dans A strictement plus grand que y.\n\n  `lt_sup (hx : borne_sup A x) : ∀ y, y < x → ∃ a ∈ A, y < a`\n\nDans les exercices suivants, on pourra aussi utiliser les lemmes\n\n  `inv_succ_pos : ∀ n : ℕ, 1/(n + 1 : ℝ) > 0`\n\n  `limite_inv_succ :  ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, 1/(n + 1 : ℝ) ≤ ε`\n\net les conséquences faciles suivantes de limite_inv_succ :\n\n  `limite_si_inferieur_un_sur (h : ∀ n, |u n - x| ≤ 1/(n+1)) : limite_suite u x`\n\n  `lim_plus_un_sur (x : ℝ) : limite_suite (fct n ↦ x + 1/(n+1)) x`\n\n  `lim_moins_un_sur (x : ℝ) : limite_suite (fct n ↦ x - 1/(n+1)) x`\n\nLa structure de la démonstration est offerte. Les accolades servent à\ndélimiter les objectifs intermédiaires, tout en faisant provisoirement\ndisparaître l'affichage des objectifs en attente. Il ne faut surtout pas\nles supprimer, sous peine de se perdre irrémédiablement.\n\nEnfin on notera l'apparition dans la structure de démonstration ci-dessous\nde la commande `Par ... on choisit ... tel que`. Cette commande est décrite \ndans la dernière section du chapitre 3 du cours, intitulée \n« Utilisation d'un ∀x, ∃y et axiome du choix »\n(qu'il convient donc de relire ou de lire), mais n'était pas encore apparue\ndans les exercices.\n-/\n\n-- Un réel x est borne supérieure d'un ensemble de réels A ssi il est\n-- majorant de A et il existe une suite d'éléments de A qui tend vers x.\nlemma borne_sup_ssi (A : set ℝ) (x : ℝ) :\n(borne_sup A x) ↔ (majorant A x ∧ ∃ u : ℕ → ℝ, limite_suite u x ∧ ∀ n, u n ∈ A) :=\nbegin\n  Montrons que (borne_sup A x) → (majorant A x ∧ ∃ u : ℕ → ℝ, limite_suite u x ∧ ∀ n, u n ∈ A),\n  { Supposons h : borne_sup A x,\n    Montrons que majorant A x,\n    { \n  sorry\n    },\n    Montrons que ∃ (u : ℕ → ℝ), limite_suite u x ∧ ∀ n, u n ∈ A,\n    { Fait F1 : ∀ n : ℕ, ∃ a ∈ A, x - 1/(n+1) < a,\n      { \n  sorry\n        },\n      Par F1 on choisit u tel que (hu : ∀ n, u n ∈ A) (hu' : ∀ (n : ℕ), x - 1 / (n + 1 : ℝ) < u n),\n  sorry\n           } },\n  { \n  sorry\n      },\nend\n\n\n/-\nLes autres exercices de cette feuille utiliseront la définition de la\ncontinuité d'une fonction de ℝ dans ℝ en un point de ℝ.\n-/\n\n/-- La fonction `f` est continue en `x₀`. -/\ndef continue_en (f : ℝ → ℝ) (x₀ : ℝ) : Prop :=\n∀ ε > 0, ∃ δ > 0, ∀ x, |x - x₀| ≤ δ → |f x - f x₀| ≤ ε\n\n-- Dans la suite, f désignera une fonction de ℝ dans ℝ, x₀ un réel et u\n-- une suite de réels\nvariables {f : ℝ → ℝ} {x₀ : ℝ} {u : ℕ → ℝ}\n\n/-\nOn commence par un échauffement concernant définition de la continuité.\n-/\n\n/-- Une fonction continue en x₀ est séquentiellement continue en x₀ -/\nlemma seq_continue_si_continue (hf : continue_en f x₀)\n  (hu : limite_suite u x₀) : limite_suite (f ∘ u) (f x₀) :=\nbegin\n  sorry\nend\n\n/-\nLa réciproque de du lemme précédent est vraie aussi :\nLa continuité séquentielle en x₀ implique la continuité en x₀.\nMais la démonstration est moins courte. On pourra s'inspirer de\nla démonstration de borne_sup_ssi (et du poly de math 101 !).\n-/\nexample :\n  (∀ u : ℕ → ℝ, limite_suite u x₀ → limite_suite (f ∘ u) (f x₀)) →\n  continue_en f x₀ :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, étant donnés deux réels,\non utilise la notation habituelle [a, b] pour désigner le segment [a, b].\nAttention, si par malheur b < a alors ce segment est vide. C'est un peu\nune question de convention, mais notre définition d'un segment assure le\nlemme suivant (dont l'utilisation est rarement nécessaire vu qu'il ne fait que\ndéplier une définition).\n-/\n\nlemma dans_segment {a b x : ℝ}  : x ∈ [a, b] ↔ a ≤ x ∧ x ≤ b :=\niff.rfl -- cette ligne signifie : « C'est équivalent par définition. »\n\n/-\nNous avons vu dans la feuille 9 les définitions et le lemme :\n\nUne extraction est une fonction strictement croissante de ℕ dans ℕ :\n\n  `def extraction (φ : ℕ → ℕ) := ∀ n m, n < m → φ n < φ m`\n\nUn réel a est valeur d'adhérence d'une suite u s'il\nexiste une suite extraite de u qui tend vers a.\n\n  `def valeur_adherence (u : ℕ → ℝ) (a : ℝ) := ∃ φ, extraction φ ∧ limite_suite (u ∘ φ) a`\n\nToute extraction est supérieure à l'identité :\n\n  `extraction_superieur_id : extraction φ → ∀ n, n ≤ φ n`\n\nEt dans la feuille 11 la définition et le lemme :\n\nLa suite u tend vers +∞.\n\n  `def limite_infinie_suite (u : ℕ → ℝ) := ∀ A, ∃ N, ∀ n ≥ N, u n ≥ A`\n\nSi u tend vers +∞ alors u ne tend vers aucune limite finie\n\n  `limite_infinie_pas_finie : limite_infinie_suite u → ∀ l, ¬ limite_suite u l`\n-/\n\n-- Dans la suite, φ sera une fonction de ℕ dans ℕ\nvariables {φ : ℕ → ℕ}\n\n\n/-- Si `u` tend vers `+∞` alors toutes ses suites extraites tendent vers `+∞`. -/\nlemma limite_infinie_extraction_si_limite\n  (h : limite_infinie_suite u) (hφ : extraction φ) :\nlimite_infinie_suite (u ∘ φ) :=\nbegin\n  sorry\nend\n\nlemma limite_infinie_gendarme {u v : ℕ → ℝ} (hu : limite_infinie_suite u)\n(huv : ∀ n, u n ≤ v n) : limite_infinie_suite v :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, on pourra aussi utiliser le théorème de Bolzano-Weirstrass :\n\nToute suite à valeur dans un segment [a, b] admet une valeur d'adhérence\ndans [a, b].\n\n  `bolzano_weierstrass (h : ∀ n, u n ∈ [a, b]) : ∃ c ∈ [a, b], valeur_adherence u c`\n\nCe théorème se démontre à partir du théorème de la borne supérieure, mais il\nfaut construire une suite par récurrence, ce que nous n'avons pas appris à\nfaire dans Lean.\n\nOn pourra utiliser aussi le lemme suivant, qui lui est évident\n\n  `limite_suite_id : limite_infinie_suite (fct n ↦ n)`\n-/\n\n-- Toute fonction continue sur un segment y est majorée.\nlemma majoree_segment {f : ℝ → ℝ} {a b : ℝ} (hf : ∀ x ∈ [a, b], continue_en f x) :\n∃ M, ∀ x ∈ [a, b], f x ≤ M :=\nbegin\n  sorry\nend\n\n/-\nPour l'exercice suivant, on pourra utiliser le lemme\n\n  `abs_neg x : |-x| = |x|`\n-/\n\n-- Si f est continue en x₀ alors -f est aussi continue en x₀\nlemma continue_opposee {f : ℝ → ℝ} {x₀ : ℝ} (h : continue_en f x₀) :\n  continue_en (fct x ↦ -f x) x₀ :=\nbegin\n  sorry\nend\n\n-- Toute fonction continue sur un segment y est minorée.\nlemma minoree_segment {f : ℝ → ℝ} {a b : ℝ} (hf : ∀ x ∈ [a, b], continue_en f x) :\n∃ m, ∀ x ∈ [a, b], m ≤ f x :=\nbegin\n  Fait clef : ∃ M, ∀ x ∈ [a, b], -f x ≤ M,\n  {\n  sorry\n  },\n  sorry\nend\n\n/-\nNous avons démontré dans la feuille 8 qu'une suite a au plus une limite :\n\n `unicite_limite : limite_suite u l → limite_suite u l' → l = l'`\n\net démontré dans la feuille 9 que,si u tend vers l alors toutes ses suites\nextraites tendent vers l :\n\n  `limite_extraction_si_limite (h : limite_suite u l) (hφ : extraction φ) :` \n    `limite_suite (u ∘ φ) l`\n\nOn admet une version du théorème de la borne supérieure (qu'on ne peut pas\ndémontrer sans construire les nombres réels ou admettre un autre théorème\naussi fort) :\n\n`sup_segment {a b : ℝ} {A : set ℝ} (hnonvide : ∃ x, x ∈ A) (h : A ⊆ [a, b]) :`\n  `∃ x ∈ [a, b], borne_sup A x`\n\nDans l'exercice suivant, il peut être utile de démontrer une inclusion\nentre ensembles A et B de nombres réels.\nPar définition, `A ⊆ B` signifie : `∀ x, x ∈ A → x ∈ B`.\nOn peut donc commencer la démonstration de A ⊆ B par « Soit (x ∈ A) »\nqui fait apparaître « x : ℝ » et « x_mem : x ∈ A  » dans le contexte,\npuis démontrer x ∈ B.\n\nOn remarquera aussi l'utilisation de la notation\n  {x | P x}\nqui désigne l'ensemble des x vérifiant le prédicat P.\nPar exemple, la définition du segment [a, b] est :\n`[a, b] = { x | a ≤ x ∧ x ≤ b }`\n\nAinsi l'énoncé `y ∈ { x | P x}` signifie `P y`, par définition.\n\n-/\n\n/-- Toute fonction continue sur un segment non vide y admet un maximum. -/\nexample {a b : ℝ} (hab : a ≤ b) (hf : ∀ x ∈ [a, b], continue_en f x) :\n∃ x₀ ∈ [a, b], ∀ x ∈ [a, b], f x ≤ f x₀ :=\nbegin\n  Par minoree_segment appliqué à hf on obtient m \n     tel que hm : ∀ (x : ℝ), x ∈ [a, b] → m ≤ f x,\n  Par majoree_segment appliqué à hf on obtient M \n     tel que hM : ∀ (x : ℝ), x ∈ [a, b] → f x ≤ M,\n  Posons A := {y | ∃ x ∈ [a, b], y = f x}, -- A est l'image de [a, b] par f\n  Fait etape1 : ∃ y₀ ∈ [m, M], borne_sup A y₀,\n  {\n  sorry\n  }, \n  Par etape1 on obtient y₀ tel que (y_dans : y₀ ∈ [m, M]) (y_sup : borne_sup A y₀),\n  On réécrit via borne_sup_ssi dans y_sup,\n  Par y_sup on obtient (y_maj : majorant A y₀) \n                       (u : ℕ → ℝ) (lim_u : limite_suite u y₀) (u_dans : ∀ n, u n ∈ A),\n  Par u_dans on choisit (v : ℕ → ℝ) tel que \n    (v_dans : ∀ n, v n ∈ [a, b]) (hufv : ∀ n, u n = f (v n)),\n  Fait hu_eq_comp : u = f ∘ v,\n    On conclut par funext appliqué à hufv,\n  sorry\nend\n\n-- Malheureusement `On combine` ne fait pas tout seul le lemme suivant\nlemma stupide {a b x : ℝ} (h : x ∈ [a, b]) (h' : x ≠ b) : x < b :=\nbegin\n  On conclut par lt_of_le_of_ne appliqué à [h.right, h'],\nend\n/-\nEt maintenant le boss final...\n\nOn pourra utiliser le lemme `not_and {P Q : Prop} : (¬(P ∧ Q)) ↔ (P → ¬Q)`\nplutôt que d'utiliser directement la commande `On pousse la négation` qui utilise\nune autre reformulation de `¬(P ∧ Q)`.\n-/\n\n/-- Le théorème des valeurs intermédiaires -/\nexample (f : ℝ → ℝ) (hf : ∀ x, continue_en f x) (h₀ : f 0 < 0) (h₁ : f 1 > 0) :\n∃ x₀ ∈ [0, 1], f x₀ = 0 :=\nbegin\n  Posons A := { x | x ∈ [0, 1] ∧ f x < 0},\n  Fait ex_x₀ : ∃ x₀ ∈ [0, 1], borne_sup A x₀,\n  {\n  sorry\n  },\n  Par ex_x₀ on obtient x₀ tel que x₀_dans x₀_sup,\n  Montrons que x₀ convient,\n    On conclut par x₀_dans,\n  Fait fx₀_neg : f x₀ ≤ 0,\n  {\n  sorry\n  },\n  Fait x₀_1: x₀ < 1,\n  {\n  sorry\n  },\n  Fait fx₀_pos : f x₀ ≥ 0,\n  { Fait dans' : ∃ N : ℕ, ∀ n ≥ N, x₀ + 1/(n+1) ∈ [0, 1],\n    { Fait dans'' : ∃ N : ℕ, ∀ n≥ N, 1/(n+1 : ℝ) ≤ 1-x₀,\n      {\n  sorry\n      },\n  sorry\n    },\n    Fait pas_dans : ∀ n : ℕ, x₀ + 1/(n+1) ∉ A,\n    -- Par définition, x ∉ A signifie « non (x ∈ A) ».\n    {\n  sorry\n    },\n    On reformule pas_dans en ∀ n : ℕ, ¬(x₀ + 1 / (n + 1 : ℝ) ∈ [0, 1] ∧ f (x₀ + 1 / (n + 1 : ℝ)) < 0),\n  sorry\n  },\n  On combine [fx₀_pos, fx₀_neg],\nend\n\n", "meta": {"author": "PatrickMassot", "repo": "MDD154", "sha": "00defe82a4b6b7992ed522a92f62abd685e8c943", "save_path": "github-repos/lean/PatrickMassot-MDD154", "path": "github-repos/lean/PatrickMassot-MDD154/MDD154-00defe82a4b6b7992ed522a92f62abd685e8c943/src/12_final.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.49291942272902656}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.finset.image\n\n/-!\n# Finite types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines a typeclass to state that a type is finite.\n\n## Main declarations\n\n* `fintype α`:  Typeclass saying that a type is finite. It takes as fields a `finset` and a proof\n  that all terms of type `α` are in it.\n* `finset.univ`: The finset of all elements of a fintype.\n\nSee `data.fintype.card` for the cardinality of a fintype,\nthe equivalence with `fin (fintype.card α)`, and pigeonhole principles.\n\n## Instances\n\nInstances for `fintype` for\n* `{x // p x}` are in this file as `fintype.subtype`\n* `option α` are in `data.fintype.option`\n* `α × β` are in `data.fintype.prod`\n* `α ⊕ β` are in `data.fintype.sum`\n* `Σ (a : α), β a` are in `data.fintype.sigma`\n\nThese files also contain appropriate `infinite` instances for these types.\n\n`infinite` instances for `ℕ`, `ℤ`, `multiset α`, and `list α` are in `data.fintype.lattice`.\n\nTypes which have a surjection from/an injection to a `fintype` are themselves fintypes.\nSee `fintype.of_injective` and `fintype.of_surjective`.\n-/\n\nopen function\nopen_locale nat\n\nuniverses u v\n\nvariables {α β γ : Type*}\n\n/-- `fintype α` means that `α` is finite, i.e. there are only\n  finitely many distinct elements of type `α`. The evidence of this\n  is a finset `elems` (a list up to permutation without duplicates),\n  together with a proof that everything of type `α` is in the list. -/\nclass fintype (α : Type*) :=\n(elems [] : finset α)\n(complete : ∀ x : α, x ∈ elems)\n\nnamespace finset\nvariables [fintype α] {s t : finset α}\n\n/-- `univ` is the universal finite set of type `finset α` implied from\n  the assumption `fintype α`. -/\ndef univ : finset α := fintype.elems α\n\n@[simp] theorem mem_univ (x : α) : x ∈ (univ : finset α) :=\nfintype.complete x\n\n@[simp] theorem mem_univ_val : ∀ x, x ∈ (univ : finset α).1 := mem_univ\n\nlemma eq_univ_iff_forall : s = univ ↔ ∀ x, x ∈ s := by simp [ext_iff]\nlemma eq_univ_of_forall  : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2\n\n@[simp, norm_cast] lemma coe_univ : ↑(univ : finset α) = (set.univ : set α) := by ext; simp\n@[simp, norm_cast] lemma coe_eq_univ : (s : set α) = set.univ ↔ s = univ :=\nby rw [←coe_univ, coe_inj]\n\nlemma nonempty.eq_univ [subsingleton α] : s.nonempty → s = univ :=\nby { rintro ⟨x, hx⟩, refine eq_univ_of_forall (λ y, by rwa subsingleton.elim y x) }\n\nlemma univ_nonempty_iff : (univ : finset α).nonempty ↔ nonempty α :=\nby rw [← coe_nonempty, coe_univ, set.nonempty_iff_univ_nonempty]\n\nlemma univ_nonempty [nonempty α] : (univ : finset α).nonempty :=\nuniv_nonempty_iff.2 ‹_›\n\nlemma univ_eq_empty_iff : (univ : finset α) = ∅ ↔ is_empty α :=\nby rw [← not_nonempty_iff, ← univ_nonempty_iff, not_nonempty_iff_eq_empty]\n\n@[simp] lemma univ_eq_empty [is_empty α] : (univ : finset α) = ∅ := univ_eq_empty_iff.2 ‹_›\n\n@[simp] lemma univ_unique [unique α] : (univ : finset α) = {default} :=\nfinset.ext $ λ x, iff_of_true (mem_univ _) $ mem_singleton.2 $ subsingleton.elim x default\n\n@[simp] theorem subset_univ (s : finset α) : s ⊆ univ := λ a _, mem_univ a\n\ninstance : bounded_order (finset α) :=\n{ top := univ,\n  le_top := subset_univ,\n  .. finset.order_bot }\n\n@[simp] lemma top_eq_univ : (⊤ : finset α) = univ := rfl\n\nlemma ssubset_univ_iff {s : finset α} : s ⊂ univ ↔ s ≠ univ := @lt_top_iff_ne_top _ _ _ s\n\nlemma codisjoint_left : codisjoint s t ↔ ∀ ⦃a⦄, a ∉ s → a ∈ t :=\nby { classical, simp [codisjoint_iff, eq_univ_iff_forall, or_iff_not_imp_left] }\n\nlemma codisjoint_right : codisjoint s t ↔ ∀ ⦃a⦄, a ∉ t → a ∈ s :=\ncodisjoint.comm.trans codisjoint_left\n\nsection boolean_algebra\nvariables [decidable_eq α] {a : α}\n\ninstance : boolean_algebra (finset α) := generalized_boolean_algebra.to_boolean_algebra\n\nlemma sdiff_eq_inter_compl (s t : finset α) : s \\ t = s ∩ tᶜ := sdiff_eq\n\nlemma compl_eq_univ_sdiff (s : finset α) : sᶜ = univ \\ s := rfl\n\n@[simp] lemma mem_compl : a ∈ sᶜ ↔ a ∉ s := by simp [compl_eq_univ_sdiff]\n\nlemma not_mem_compl : a ∉ sᶜ ↔ a ∈ s := by rw [mem_compl, not_not]\n\n@[simp, norm_cast] lemma coe_compl (s : finset α) : ↑(sᶜ) = (↑s : set α)ᶜ :=\nset.ext $ λ x, mem_compl\n\n@[simp] lemma compl_empty : (∅ : finset α)ᶜ = univ := compl_bot\n\n@[simp] lemma compl_univ : (univ : finset α)ᶜ = ∅ := compl_top\n\n@[simp] lemma compl_eq_empty_iff (s : finset α) : sᶜ = ∅ ↔ s = univ := compl_eq_bot\n\n@[simp] lemma compl_eq_univ_iff (s : finset α) : sᶜ = univ ↔ s = ∅ := compl_eq_top\n\n@[simp] lemma union_compl (s : finset α) : s ∪ sᶜ = univ := sup_compl_eq_top\n\n@[simp] lemma inter_compl (s : finset α) : s ∩ sᶜ = ∅ := inf_compl_eq_bot\n\n@[simp] lemma compl_union (s t : finset α) : (s ∪ t)ᶜ = sᶜ ∩ tᶜ := compl_sup\n\n@[simp] lemma compl_inter (s t : finset α) : (s ∩ t)ᶜ = sᶜ ∪ tᶜ := compl_inf\n\n@[simp] lemma compl_erase : (s.erase a)ᶜ = insert a sᶜ :=\nby { ext, simp only [or_iff_not_imp_left, mem_insert, not_and, mem_compl, mem_erase] }\n\n@[simp] lemma compl_insert : (insert a s)ᶜ = sᶜ.erase a :=\nby { ext, simp only [not_or_distrib, mem_insert, iff_self, mem_compl, mem_erase] }\n\n@[simp] lemma insert_compl_self (x : α) : insert x ({x}ᶜ : finset α) = univ :=\nby rw [←compl_erase, erase_singleton, compl_empty]\n\n@[simp] lemma compl_filter (p : α → Prop) [decidable_pred p] [Π x, decidable (¬p x)] :\n  (univ.filter p)ᶜ = univ.filter (λ x, ¬p x) :=\n(filter_not _ _).symm\n\nlemma compl_ne_univ_iff_nonempty (s : finset α) : sᶜ ≠ univ ↔ s.nonempty :=\nby simp [eq_univ_iff_forall, finset.nonempty]\n\nlemma compl_singleton (a : α) : ({a} : finset α)ᶜ = univ.erase a :=\nby rw [compl_eq_univ_sdiff, sdiff_singleton_eq_erase]\n\nlemma insert_inj_on' (s : finset α) : set.inj_on (λ a, insert a s) (sᶜ : finset α) :=\nby { rw coe_compl, exact s.insert_inj_on }\n\nlemma image_univ_of_surjective [fintype β] {f : β → α} (hf : surjective f) : univ.image f = univ :=\neq_univ_of_forall $ hf.forall.2 $ λ _, mem_image_of_mem _ $ mem_univ _\n\nend boolean_algebra\n\nlemma map_univ_of_surjective [fintype β] {f : β ↪ α} (hf : surjective f) : univ.map f = univ :=\neq_univ_of_forall $ hf.forall.2 $ λ _, mem_map_of_mem _ $ mem_univ _\n\n@[simp] lemma map_univ_equiv [fintype β] (f : β ≃ α) : univ.map f.to_embedding = univ :=\nmap_univ_of_surjective f.surjective\n\n@[simp] lemma univ_inter [decidable_eq α] (s : finset α) :\n  univ ∩ s = s := ext $ λ a, by simp\n\n@[simp] lemma inter_univ [decidable_eq α] (s : finset α) :\n  s ∩ univ = s :=\nby rw [inter_comm, univ_inter]\n\n@[simp] lemma piecewise_univ [Π i : α, decidable (i ∈ (univ : finset α))]\n  {δ : α → Sort*} (f g : Π i, δ i) : univ.piecewise f g = f :=\nby { ext i, simp [piecewise] }\n\nlemma piecewise_compl [decidable_eq α] (s : finset α) [Π i : α, decidable (i ∈ s)]\n  [Π i : α, decidable (i ∈ sᶜ)] {δ : α → Sort*} (f g : Π i, δ i) :\n  sᶜ.piecewise f g = s.piecewise g f :=\nby { ext i, simp [piecewise] }\n\n@[simp] lemma piecewise_erase_univ {δ : α → Sort*} [decidable_eq α] (a : α) (f g : Π a, δ a) :\n  (finset.univ.erase a).piecewise f g = function.update f a (g a) :=\nby rw [←compl_singleton, piecewise_compl, piecewise_singleton]\n\nlemma univ_map_equiv_to_embedding {α β : Type*} [fintype α] [fintype β] (e : α ≃ β) :\n  univ.map e.to_embedding = univ :=\neq_univ_iff_forall.mpr (λ b, mem_map.mpr ⟨e.symm b, mem_univ _, by simp⟩)\n\n@[simp] lemma univ_filter_exists (f : α → β) [fintype β]\n  [decidable_pred (λ y, ∃ x, f x = y)] [decidable_eq β] :\n  finset.univ.filter (λ y, ∃ x, f x = y) = finset.univ.image f :=\nby { ext, simp }\n\n/-- Note this is a special case of `(finset.image_preimage f univ _).symm`. -/\nlemma univ_filter_mem_range (f : α → β) [fintype β]\n  [decidable_pred (λ y, y ∈ set.range f)] [decidable_eq β] :\n  finset.univ.filter (λ y, y ∈ set.range f) = finset.univ.image f :=\nuniv_filter_exists f\n\nlemma coe_filter_univ (p : α → Prop) [decidable_pred p] : (univ.filter p : set α) = {x | p x} :=\nby rw [coe_filter, coe_univ, set.sep_univ]\n\nend finset\n\nopen finset function\n\nnamespace fintype\n\ninstance decidable_pi_fintype {α} {β : α → Type*} [∀ a, decidable_eq (β a)] [fintype α] :\n  decidable_eq (Π a, β a) :=\nλ f g, decidable_of_iff (∀ a ∈ fintype.elems α, f a = g a)\n  (by simp [function.funext_iff, fintype.complete])\n\ninstance decidable_forall_fintype {p : α → Prop} [decidable_pred p] [fintype α] :\n  decidable (∀ a, p a) :=\ndecidable_of_iff (∀ a ∈ @univ α _, p a) (by simp)\n\ninstance decidable_exists_fintype {p : α → Prop} [decidable_pred p] [fintype α] :\n  decidable (∃ a, p a) :=\ndecidable_of_iff (∃ a ∈ @univ α _, p a) (by simp)\n\ninstance decidable_mem_range_fintype [fintype α] [decidable_eq β] (f : α → β) :\n  decidable_pred (∈ set.range f) :=\nλ x, fintype.decidable_exists_fintype\n\nsection bundled_homs\n\ninstance decidable_eq_equiv_fintype [decidable_eq β] [fintype α] :\n  decidable_eq (α ≃ β) :=\nλ a b, decidable_of_iff (a.1 = b.1) equiv.coe_fn_injective.eq_iff\n\ninstance decidable_eq_embedding_fintype [decidable_eq β] [fintype α] :\n  decidable_eq (α ↪ β) :=\nλ a b, decidable_of_iff ((a : α → β) = b) function.embedding.coe_injective.eq_iff\n\n@[to_additive]\ninstance decidable_eq_one_hom_fintype [decidable_eq β] [fintype α] [has_one α] [has_one β]:\n  decidable_eq (one_hom α β) :=\nλ a b, decidable_of_iff ((a : α → β) = b) (injective.eq_iff one_hom.coe_inj)\n\n@[to_additive]\ninstance decidable_eq_mul_hom_fintype [decidable_eq β] [fintype α] [has_mul α] [has_mul β]:\n  decidable_eq (α →ₙ* β) :=\nλ a b, decidable_of_iff ((a : α → β) = b) (injective.eq_iff mul_hom.coe_inj)\n\n@[to_additive]\ninstance decidable_eq_monoid_hom_fintype [decidable_eq β] [fintype α]\n  [mul_one_class α] [mul_one_class β]:\n  decidable_eq (α →* β) :=\nλ a b, decidable_of_iff ((a : α → β) = b) (injective.eq_iff monoid_hom.coe_inj)\n\ninstance decidable_eq_monoid_with_zero_hom_fintype [decidable_eq β] [fintype α]\n  [mul_zero_one_class α] [mul_zero_one_class β] :\n  decidable_eq (α →*₀ β) :=\nλ a b, decidable_of_iff ((a : α → β) = b) (injective.eq_iff monoid_with_zero_hom.coe_inj)\n\ninstance decidable_eq_ring_hom_fintype [decidable_eq β] [fintype α]\n  [semiring α] [semiring β]:\n  decidable_eq (α →+* β) :=\nλ a b, decidable_of_iff ((a : α → β) = b) (injective.eq_iff ring_hom.coe_inj)\n\nend bundled_homs\n\ninstance decidable_injective_fintype [decidable_eq α] [decidable_eq β] [fintype α] :\n  decidable_pred (injective : (α → β) → Prop) := λ x, by unfold injective; apply_instance\n\ninstance decidable_surjective_fintype [decidable_eq β] [fintype α] [fintype β] :\n  decidable_pred (surjective : (α → β) → Prop) := λ x, by unfold surjective; apply_instance\n\ninstance decidable_bijective_fintype [decidable_eq α] [decidable_eq β] [fintype α] [fintype β] :\n  decidable_pred (bijective : (α → β) → Prop) := λ x, by unfold bijective; apply_instance\n\ninstance decidable_right_inverse_fintype [decidable_eq α] [fintype α] (f : α → β) (g : β → α) :\n  decidable (function.right_inverse f g) :=\nshow decidable (∀ x, g (f x) = x), by apply_instance\n\ninstance decidable_left_inverse_fintype [decidable_eq β] [fintype β] (f : α → β) (g : β → α) :\n  decidable (function.left_inverse f g) :=\nshow decidable (∀ x, f (g x) = x), by apply_instance\n\n/-- Construct a proof of `fintype α` from a universal multiset -/\ndef of_multiset [decidable_eq α] (s : multiset α) (H : ∀ x : α, x ∈ s) :\n  fintype α :=\n⟨s.to_finset, by simpa using H⟩\n\n/-- Construct a proof of `fintype α` from a universal list -/\ndef of_list [decidable_eq α] (l : list α) (H : ∀ x : α, x ∈ l) :\n  fintype α :=\n⟨l.to_finset, by simpa using H⟩\n\ninstance (α : Type*) : subsingleton (fintype α) :=\n⟨λ ⟨s₁, h₁⟩ ⟨s₂, h₂⟩, by congr; simp [finset.ext_iff, h₁, h₂]⟩\n\n/-- Given a predicate that can be represented by a finset, the subtype\nassociated to the predicate is a fintype. -/\nprotected def subtype {p : α → Prop} (s : finset α) (H : ∀ x : α, x ∈ s ↔ p x) :\n  fintype {x // p x} :=\n⟨⟨s.1.pmap subtype.mk (λ x, (H x).1),\n  s.nodup.pmap $ λ a _ b _, congr_arg subtype.val⟩,\nλ ⟨x, px⟩, multiset.mem_pmap.2 ⟨x, (H x).2 px, rfl⟩⟩\n\n/-- Construct a fintype from a finset with the same elements. -/\ndef of_finset {p : set α} (s : finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) : fintype p :=\nfintype.subtype s H\n\n/-- If `f : α → β` is a bijection and `α` is a fintype, then `β` is also a fintype. -/\ndef of_bijective [fintype α] (f : α → β) (H : function.bijective f) : fintype β :=\n⟨univ.map ⟨f, H.1⟩,\nλ b, let ⟨a, e⟩ := H.2 b in e ▸ mem_map_of_mem _ (mem_univ _)⟩\n\n/-- If `f : α → β` is a surjection and `α` is a fintype, then `β` is also a fintype. -/\ndef of_surjective [decidable_eq β] [fintype α] (f : α → β) (H : function.surjective f) :\n  fintype β :=\n⟨univ.image f, λ b, let ⟨a, e⟩ := H b in e ▸ mem_image_of_mem _ (mem_univ _)⟩\n\nend fintype\n\nnamespace finset\nvariables [fintype α] [decidable_eq α] {s t : finset α}\n\ninstance decidable_codisjoint : decidable (codisjoint s t) :=\ndecidable_of_iff _ codisjoint_left.symm\n\ninstance decidable_is_compl : decidable (is_compl s t) := decidable_of_iff' _ is_compl_iff\n\nend finset\n\nsection inv\n\nnamespace function\n\nvariables [fintype α] [decidable_eq β]\n\nnamespace injective\n\nvariables {f : α → β} (hf : function.injective f)\n\n/--\nThe inverse of an `hf : injective` function `f : α → β`, of the type `↥(set.range f) → α`.\nThis is the computable version of `function.inv_fun` that requires `fintype α` and `decidable_eq β`,\nor the function version of applying `(equiv.of_injective f hf).symm`.\nThis function should not usually be used for actual computation because for most cases,\nan explicit inverse can be stated that has better computational properties.\nThis function computes by checking all terms `a : α` to find the `f a = b`, so it is O(N) where\n`N = fintype.card α`.\n-/\ndef inv_of_mem_range : set.range f → α :=\nλ b, finset.choose (λ a, f a = b) finset.univ ((exists_unique_congr (by simp)).mp\n  (hf.exists_unique_of_mem_range b.property))\n\nlemma left_inv_of_inv_of_mem_range (b : set.range f) :\n  f (hf.inv_of_mem_range b) = b :=\n(finset.choose_spec (λ a, f a = b) _ _).right\n\n@[simp] lemma right_inv_of_inv_of_mem_range (a : α) :\n  hf.inv_of_mem_range (⟨f a, set.mem_range_self a⟩) = a :=\nhf (finset.choose_spec (λ a', f a' = f a) _ _).right\n\nlemma inv_fun_restrict [nonempty α] :\n  (set.range f).restrict (inv_fun f) = hf.inv_of_mem_range :=\nbegin\n  ext ⟨b, h⟩,\n  apply hf,\n  simp [hf.left_inv_of_inv_of_mem_range, @inv_fun_eq _ _ _ f b (set.mem_range.mp h)]\nend\n\nlemma inv_of_mem_range_surjective : function.surjective hf.inv_of_mem_range :=\nλ a, ⟨⟨f a, set.mem_range_self a⟩, by simp⟩\n\nend injective\n\nnamespace embedding\nvariables (f : α ↪ β) (b : set.range f)\n\n/--\nThe inverse of an embedding `f : α ↪ β`, of the type `↥(set.range f) → α`.\nThis is the computable version of `function.inv_fun` that requires `fintype α` and `decidable_eq β`,\nor the function version of applying `(equiv.of_injective f f.injective).symm`.\nThis function should not usually be used for actual computation because for most cases,\nan explicit inverse can be stated that has better computational properties.\nThis function computes by checking all terms `a : α` to find the `f a = b`, so it is O(N) where\n`N = fintype.card α`.\n-/\ndef inv_of_mem_range : α :=\nf.injective.inv_of_mem_range b\n\n@[simp] lemma left_inv_of_inv_of_mem_range :\n  f (f.inv_of_mem_range b) = b :=\nf.injective.left_inv_of_inv_of_mem_range b\n\n@[simp] lemma right_inv_of_inv_of_mem_range (a : α) :\n  f.inv_of_mem_range ⟨f a, set.mem_range_self a⟩ = a :=\nf.injective.right_inv_of_inv_of_mem_range a\n\nlemma inv_fun_restrict [nonempty α] :\n  (set.range f).restrict (inv_fun f) = f.inv_of_mem_range :=\nbegin\n  ext ⟨b, h⟩,\n  apply f.injective,\n  simp [f.left_inv_of_inv_of_mem_range, @inv_fun_eq _ _ _ f b (set.mem_range.mp h)]\nend\n\nlemma inv_of_mem_range_surjective : function.surjective f.inv_of_mem_range :=\nλ a, ⟨⟨f a, set.mem_range_self a⟩, by simp⟩\n\nend embedding\n\nend function\n\nend inv\n\nnamespace fintype\n\n/-- Given an injective function to a fintype, the domain is also a\nfintype. This is noncomputable because injectivity alone cannot be\nused to construct preimages. -/\nnoncomputable def of_injective [fintype β] (f : α → β) (H : function.injective f) : fintype α :=\nby letI := classical.dec; exact\nif hα : nonempty α then by letI := classical.inhabited_of_nonempty hα;\n  exact of_surjective (inv_fun f) (inv_fun_surjective H)\nelse ⟨∅, λ x, (hα ⟨x⟩).elim⟩\n\n/-- If `f : α ≃ β` and `α` is a fintype, then `β` is also a fintype. -/\ndef of_equiv (α : Type*) [fintype α] (f : α ≃ β) : fintype β := of_bijective _ f.bijective\n\n/-- Any subsingleton type with a witness is a fintype (with one term). -/\ndef of_subsingleton (a : α) [subsingleton α] : fintype α :=\n⟨{a}, λ b, finset.mem_singleton.2 (subsingleton.elim _ _)⟩\n\n@[simp] theorem univ_of_subsingleton (a : α) [subsingleton α] :\n  @univ _ (of_subsingleton a) = {a} := rfl\n\n@[priority 100] -- see Note [lower instance priority]\ninstance of_is_empty [is_empty α] : fintype α := ⟨∅, is_empty_elim⟩\n\n/-- Note: this lemma is specifically about `fintype.of_is_empty`. For a statement about\narbitrary `fintype` instances, use `finset.univ_eq_empty`. -/\n-- no-lint since while `finset.univ_eq_empty` can prove this, it isn't applicable for `dsimp`.\n@[simp, nolint simp_nf] theorem univ_of_is_empty [is_empty α] : @univ α _ = ∅ := rfl\n\nend fintype\n\nnamespace set\nvariables {s t : set α}\n\n/-- Construct a finset enumerating a set `s`, given a `fintype` instance.  -/\ndef to_finset (s : set α) [fintype s] : finset α :=\n(@finset.univ s _).map $ function.embedding.subtype _\n\n@[congr]\nlemma to_finset_congr {s t : set α} [fintype s] [fintype t] (h : s = t) :\n  to_finset s = to_finset t :=\nby cc\n\n@[simp] theorem mem_to_finset {s : set α} [fintype s] {a : α} : a ∈ s.to_finset ↔ a ∈ s :=\nby simp [to_finset]\n\n/-- Many `fintype` instances for sets are defined using an extensionally equal `finset`.\nRewriting `s.to_finset` with `set.to_finset_of_finset` replaces the term with such a `finset`. -/\ntheorem to_finset_of_finset {p : set α} (s : finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) :\n  @set.to_finset _ p (fintype.of_finset s H) = s :=\nfinset.ext (λ x, by rw [mem_to_finset, H])\n\n/-- Membership of a set with a `fintype` instance is decidable.\n\nUsing this as an instance leads to potential loops with `subtype.fintype` under certain decidability\nassumptions, so it should only be declared a local instance. -/\ndef decidable_mem_of_fintype [decidable_eq α] (s : set α) [fintype s] (a) : decidable (a ∈ s) :=\ndecidable_of_iff _ mem_to_finset\n\n@[simp] theorem coe_to_finset (s : set α) [fintype s] : (↑s.to_finset : set α) = s :=\nset.ext $ λ _, mem_to_finset\n\n@[simp] lemma to_finset_nonempty {s : set α} [fintype s] : s.to_finset.nonempty ↔ s.nonempty :=\nby rw [←finset.coe_nonempty, coe_to_finset]\n\n@[simp] theorem to_finset_inj {s t : set α} [fintype s] [fintype t] :\n  s.to_finset = t.to_finset ↔ s = t :=\n⟨λ h, by rw [←s.coe_to_finset, h, t.coe_to_finset], λ h, by simp [h]; congr⟩\n\n@[mono]\nlemma to_finset_subset_to_finset [fintype s] [fintype t] : s.to_finset ⊆ t.to_finset ↔ s ⊆ t :=\nby simp [finset.subset_iff, set.subset_def]\n\n@[simp] lemma to_finset_ssubset [fintype s] {t : finset α} : s.to_finset ⊂ t ↔ s ⊂ t :=\nby rw [←finset.coe_ssubset, coe_to_finset]\n\n@[simp] lemma subset_to_finset {s : finset α} [fintype t] : s ⊆ t.to_finset ↔ ↑s ⊆ t :=\nby rw [←finset.coe_subset, coe_to_finset]\n\n@[simp] lemma ssubset_to_finset {s : finset α} [fintype t] : s ⊂ t.to_finset ↔ ↑s ⊂ t :=\nby rw [←finset.coe_ssubset, coe_to_finset]\n\n@[mono]\nlemma to_finset_ssubset_to_finset [fintype s] [fintype t] : s.to_finset ⊂ t.to_finset ↔ s ⊂ t :=\nby simp only [finset.ssubset_def, to_finset_subset_to_finset, ssubset_def]\n\n@[simp] lemma to_finset_subset [fintype s] {t : finset α} : s.to_finset ⊆ t ↔ s ⊆ t :=\nby rw [←finset.coe_subset, coe_to_finset]\n\nalias to_finset_subset_to_finset ↔ _ to_finset_mono\nalias to_finset_ssubset_to_finset ↔ _ to_finset_strict_mono\n\n@[simp] lemma disjoint_to_finset [fintype s] [fintype t] :\n  disjoint s.to_finset t.to_finset ↔ disjoint s t :=\nby simp only [←disjoint_coe, coe_to_finset]\n\nsection decidable_eq\nvariables [decidable_eq α] (s t) [fintype s] [fintype t]\n\n@[simp] lemma to_finset_inter [fintype ↥(s ∩ t)] : (s ∩ t).to_finset = s.to_finset ∩ t.to_finset :=\nby { ext, simp }\n\n@[simp] lemma to_finset_union [fintype ↥(s ∪ t)] : (s ∪ t).to_finset = s.to_finset ∪ t.to_finset :=\nby { ext, simp }\n\n@[simp] lemma to_finset_diff [fintype ↥(s \\ t)] : (s \\ t).to_finset = s.to_finset \\ t.to_finset :=\nby { ext, simp }\n\n@[simp] lemma to_finset_symm_diff [fintype ↥(s ∆ t)] :\n  (s ∆ t).to_finset = s.to_finset ∆ t.to_finset :=\nby { ext, simp [mem_symm_diff, finset.mem_symm_diff] }\n\n@[simp] lemma to_finset_compl [fintype α] [fintype ↥sᶜ] : sᶜ.to_finset = s.to_finsetᶜ :=\nby { ext, simp }\n\nend decidable_eq\n\n/- TODO The `↥` circumvents an elaboration bug. See comment on `set.to_finset_univ`. -/\n@[simp] lemma to_finset_empty [fintype ↥(∅ : set α)] : (∅ : set α).to_finset = ∅ := by { ext, simp }\n\n/- TODO Without the coercion arrow (`↥`) there is an elaboration bug in the following two;\nit essentially infers `fintype.{v} (set.univ.{u} : set α)` with `v` and `u` distinct.\nReported in leanprover-community/lean#672 -/\n@[simp] lemma to_finset_univ [fintype α] [fintype ↥(set.univ : set α)] :\n  (set.univ : set α).to_finset = finset.univ :=\nby { ext, simp }\n\n@[simp] lemma to_finset_eq_empty [fintype s] : s.to_finset = ∅ ↔ s = ∅ :=\nby rw [←to_finset_empty, to_finset_inj]\n\n@[simp] lemma to_finset_eq_univ [fintype α] [fintype s] : s.to_finset = finset.univ ↔ s = univ :=\nby rw [← coe_inj, coe_to_finset, coe_univ]\n\n@[simp] lemma to_finset_set_of [fintype α] (p : α → Prop) [decidable_pred p] [fintype {x | p x}] :\n  {x | p x}.to_finset = finset.univ.filter p :=\nby { ext, simp }\n\n@[simp] lemma to_finset_ssubset_univ [fintype α] {s : set α} [fintype s] :\n  s.to_finset ⊂ finset.univ ↔ s ⊂ univ :=\nby rw [← coe_ssubset, coe_to_finset, coe_univ]\n\n@[simp]\nlemma to_finset_image [decidable_eq β] (f : α → β) (s : set α) [fintype s] [fintype (f '' s)] :\n  (f '' s).to_finset = s.to_finset.image f :=\nfinset.coe_injective $ by simp\n\n@[simp] lemma to_finset_range [decidable_eq α] [fintype β] (f : β → α) [fintype (set.range f)] :\n  (set.range f).to_finset = finset.univ.image f :=\nby { ext, simp }\n\n/- TODO The `↥` circumvents an elaboration bug. See comment on `set.to_finset_univ`. -/\nlemma to_finset_singleton (a : α) [fintype ↥({a} : set α)] : ({a} : set α).to_finset = {a} :=\nby { ext, simp }\n\n/- TODO The `↥` circumvents an elaboration bug. See comment on `set.to_finset_univ`. -/\n@[simp] lemma to_finset_insert [decidable_eq α] {a : α} {s : set α}\n  [fintype ↥(insert a s : set α)] [fintype s] :\n  (insert a s).to_finset = insert a s.to_finset :=\nby { ext, simp }\n\nlemma filter_mem_univ_eq_to_finset [fintype α] (s : set α) [fintype s] [decidable_pred (∈ s)] :\n  finset.univ.filter (∈ s) = s.to_finset :=\nby { ext, simp only [mem_filter, finset.mem_univ, true_and, mem_to_finset] }\n\nend set\n\n@[simp] lemma finset.to_finset_coe (s : finset α) [fintype ↥(s : set α)] :\n  (s : set α).to_finset = s :=\next $ λ _, set.mem_to_finset\n\ninstance (n : ℕ) : fintype (fin n) :=\n⟨⟨list.fin_range n, list.nodup_fin_range n⟩, list.mem_fin_range⟩\n\nlemma fin.univ_def (n : ℕ) : (univ : finset (fin n)) = ⟨list.fin_range n, list.nodup_fin_range n⟩ :=\nrfl\n\n@[simp] lemma fin.image_succ_above_univ {n : ℕ} (i : fin (n + 1)) :\n  univ.image i.succ_above = {i}ᶜ :=\nby { ext m, simp }\n\n@[simp] lemma fin.image_succ_univ (n : ℕ) : (univ : finset (fin n)).image fin.succ = {0}ᶜ :=\nby rw [← fin.succ_above_zero, fin.image_succ_above_univ]\n\n@[simp] lemma fin.image_cast_succ (n : ℕ) :\n  (univ : finset (fin n)).image fin.cast_succ = {fin.last n}ᶜ :=\nby rw [← fin.succ_above_last, fin.image_succ_above_univ]\n\n/- The following three lemmas use `finset.cons` instead of `insert` and `finset.map` instead of\n`finset.image` to reduce proof obligations downstream. -/\n\n/-- Embed `fin n` into `fin (n + 1)` by prepending zero to the `univ` -/\nlemma fin.univ_succ (n : ℕ) :\n  (univ : finset (fin (n + 1))) =\n    cons 0 (univ.map ⟨fin.succ, fin.succ_injective _⟩) (by simp [map_eq_image]) :=\nby simp [map_eq_image]\n\n/-- Embed `fin n` into `fin (n + 1)` by appending a new `fin.last n` to the `univ` -/\nlemma fin.univ_cast_succ (n : ℕ) :\n  (univ : finset (fin (n + 1))) =\n    cons (fin.last n) (univ.map fin.cast_succ.to_embedding) (by simp [map_eq_image]) :=\nby simp [map_eq_image]\n\n/-- Embed `fin n` into `fin (n + 1)` by inserting\naround a specified pivot `p : fin (n + 1)` into the `univ` -/\nlemma fin.univ_succ_above (n : ℕ) (p : fin (n + 1)) :\n  (univ : finset (fin (n + 1))) = cons p (univ.map $ (fin.succ_above p).to_embedding) (by simp) :=\nby simp [map_eq_image]\n\n@[instance, priority 10] def unique.fintype {α : Type*} [unique α] : fintype α :=\nfintype.of_subsingleton default\n\n/-- Short-circuit instance to decrease search for `unique.fintype`,\nsince that relies on a subsingleton elimination for `unique`. -/\ninstance fintype.subtype_eq (y : α) : fintype {x // x = y} :=\nfintype.subtype {y} (by simp)\n\n/-- Short-circuit instance to decrease search for `unique.fintype`,\nsince that relies on a subsingleton elimination for `unique`. -/\ninstance fintype.subtype_eq' (y : α) : fintype {x // y = x} :=\nfintype.subtype {y} (by simp [eq_comm])\n\n@[simp] theorem fintype.univ_empty : @univ empty _ = ∅ := rfl\n\n@[simp] theorem fintype.univ_pempty : @univ pempty _ = ∅ := rfl\n\ninstance : fintype unit := fintype.of_subsingleton ()\n\ntheorem fintype.univ_unit : @univ unit _ = {()} := rfl\n\ninstance : fintype punit := fintype.of_subsingleton punit.star\n\n@[simp] theorem fintype.univ_punit : @univ punit _ = {punit.star} := rfl\n\ninstance : fintype bool := ⟨⟨{tt, ff}, by simp⟩, λ x, by cases x; simp⟩\n\n@[simp] theorem fintype.univ_bool : @univ bool _ = {tt, ff} := rfl\n\ninstance additive.fintype : Π [fintype α], fintype (additive α) := id\n\ninstance multiplicative.fintype : Π [fintype α], fintype (multiplicative α) := id\n\n/-- Given that `α × β` is a fintype, `α` is also a fintype. -/\ndef fintype.prod_left {α β} [decidable_eq α] [fintype (α × β)] [nonempty β] : fintype α :=\n⟨(fintype.elems (α × β)).image prod.fst,\n  λ a, let ⟨b⟩ := ‹nonempty β› in by simp; exact ⟨b, fintype.complete _⟩⟩\n\n/-- Given that `α × β` is a fintype, `β` is also a fintype. -/\ndef fintype.prod_right {α β} [decidable_eq β] [fintype (α × β)] [nonempty α] : fintype β :=\n⟨(fintype.elems (α × β)).image prod.snd,\n  λ b, let ⟨a⟩ := ‹nonempty α› in by simp; exact ⟨a, fintype.complete _⟩⟩\n\ninstance (α : Type*) [fintype α] : fintype (ulift α) :=\nfintype.of_equiv _ equiv.ulift.symm\n\ninstance (α : Type*) [fintype α] : fintype (plift α) :=\nfintype.of_equiv _ equiv.plift.symm\n\ninstance (α : Type*) [fintype α] : fintype αᵒᵈ := ‹fintype α›\ninstance (α : Type*) [finite α] : finite αᵒᵈ := ‹finite α›\n\ninstance (α : Type*) [fintype α] : fintype (lex α) := ‹fintype α›\n\nsection finset\n\n/-! ### `fintype (s : finset α)` -/\n\ninstance finset.fintype_coe_sort {α : Type u} (s : finset α) : fintype s :=\n⟨s.attach, s.mem_attach⟩\n\n@[simp] lemma finset.univ_eq_attach {α : Type u} (s : finset α) :\n  (univ : finset s) = s.attach :=\nrfl\n\nend finset\n\nlemma fintype.coe_image_univ [fintype α] [decidable_eq β] {f : α → β} :\n  ↑(finset.image f finset.univ) = set.range f :=\nby { ext x, simp }\n\ninstance list.subtype.fintype [decidable_eq α] (l : list α) : fintype {x // x ∈ l} :=\nfintype.of_list l.attach l.mem_attach\n\ninstance multiset.subtype.fintype [decidable_eq α] (s : multiset α) : fintype {x // x ∈ s} :=\nfintype.of_multiset s.attach s.mem_attach\n\ninstance finset.subtype.fintype (s : finset α) : fintype {x // x ∈ s} :=\n⟨s.attach, s.mem_attach⟩\n\ninstance finset_coe.fintype (s : finset α) : fintype (↑s : set α) :=\nfinset.subtype.fintype s\n\nlemma finset.attach_eq_univ {s : finset α} : s.attach = finset.univ := rfl\n\ninstance plift.fintype_Prop (p : Prop) [decidable p] : fintype (plift p) :=\n⟨if h : p then {⟨h⟩} else ∅, λ ⟨h⟩, by simp [h]⟩\n\ninstance Prop.fintype : fintype Prop :=\n⟨⟨{true, false}, by simp [true_ne_false]⟩, classical.cases (by simp) (by simp)⟩\n\n@[simp] lemma fintype.univ_Prop : (finset.univ : finset Prop) = {true, false} :=\nfinset.eq_of_veq $ by simp; refl\n\ninstance subtype.fintype (p : α → Prop) [decidable_pred p] [fintype α] : fintype {x // p x} :=\nfintype.subtype (univ.filter p) (by simp)\n\n/-- A set on a fintype, when coerced to a type, is a fintype. -/\ndef set_fintype [fintype α] (s : set α) [decidable_pred (∈ s)] : fintype s :=\nsubtype.fintype (λ x, x ∈ s)\n\nsection\nvariables (α)\n\n/-- The `αˣ` type is equivalent to a subtype of `α × α`. -/\n@[simps]\ndef _root_.units_equiv_prod_subtype [monoid α] :\n  αˣ ≃ {p : α × α // p.1 * p.2 = 1 ∧ p.2 * p.1 = 1} :=\n{ to_fun := λ u, ⟨(u, ↑u⁻¹), u.val_inv, u.inv_val⟩,\n  inv_fun := λ p, units.mk (p : α × α).1 (p : α × α).2 p.prop.1 p.prop.2,\n  left_inv := λ u, units.ext rfl,\n  right_inv := λ p, subtype.ext $ prod.ext rfl rfl}\n\n/-- In a `group_with_zero` `α`, the unit group `αˣ` is equivalent to the subtype of nonzero\nelements. -/\n@[simps]\ndef _root_.units_equiv_ne_zero [group_with_zero α] : αˣ ≃ {a : α // a ≠ 0} :=\n⟨λ a, ⟨a, a.ne_zero⟩, λ a, units.mk0 _ a.prop, λ _, units.ext rfl, λ _, subtype.ext rfl⟩\n\nend\n\nnamespace fintype\n\n/-- Given `fintype α`, `finset_equiv_set` is the equiv between `finset α` and `set α`. (All\nsets on a finite type are finite.) -/\nnoncomputable def finset_equiv_set [fintype α] : finset α ≃ set α :=\n{ to_fun := coe,\n  inv_fun := by { classical, exact λ s, s.to_finset },\n  left_inv := λ s, by convert finset.to_finset_coe s,\n  right_inv := λ s, by { classical, exact s.coe_to_finset } }\n\n@[simp] lemma finset_equiv_set_apply [fintype α] (s : finset α) : finset_equiv_set s = s := rfl\n\n@[simp] \n\nend fintype\n\ninstance quotient.fintype [fintype α] (s : setoid α)\n  [decidable_rel ((≈) : α → α → Prop)] : fintype (quotient s) :=\nfintype.of_surjective quotient.mk (λ x, quotient.induction_on x (λ x, ⟨x, rfl⟩))\n\ninstance psigma.fintype_prop_left {α : Prop} {β : α → Type*} [decidable α] [∀ a, fintype (β a)] :\n  fintype (Σ' a, β a) :=\nif h : α then fintype.of_equiv (β h) ⟨λ x, ⟨h, x⟩, psigma.snd, λ _, rfl, λ ⟨_, _⟩, rfl⟩\nelse ⟨∅, λ x, h x.1⟩\n\ninstance psigma.fintype_prop_right {α : Type*} {β : α → Prop} [∀ a, decidable (β a)] [fintype α] :\n  fintype (Σ' a, β a) :=\nfintype.of_equiv {a // β a} ⟨λ ⟨x, y⟩, ⟨x, y⟩, λ ⟨x, y⟩, ⟨x, y⟩, λ ⟨x, y⟩, rfl, λ ⟨x, y⟩, rfl⟩\n\ninstance psigma.fintype_prop_prop {α : Prop} {β : α → Prop} [decidable α] [∀ a, decidable (β a)] :\n  fintype (Σ' a, β a) :=\nif h : ∃ a, β a then ⟨{⟨h.fst, h.snd⟩}, λ ⟨_, _⟩, by simp⟩ else ⟨∅, λ ⟨x, y⟩, h ⟨x, y⟩⟩\n\ninstance pfun_fintype (p : Prop) [decidable p] (α : p → Type*)\n  [Π hp, fintype (α hp)] : fintype (Π hp : p, α hp) :=\nif hp : p then fintype.of_equiv (α hp) ⟨λ a _, a, λ f, f hp, λ _, rfl, λ _, rfl⟩\n          else ⟨singleton (λ h, (hp h).elim), by simp [hp, function.funext_iff]⟩\n\nlemma mem_image_univ_iff_mem_range\n  {α β : Type*} [fintype α] [decidable_eq β] {f : α → β} {b : β} :\n  b ∈ univ.image f ↔ b ∈ set.range f :=\nby simp\n\nnamespace fintype\n\nsection choose\nopen fintype equiv\n\nvariables [fintype α] (p : α → Prop) [decidable_pred p]\n\n/-- Given a fintype `α` and a predicate `p`, associate to a proof that there is a unique element of\n`α` satisfying `p` this unique element, as an element of the corresponding subtype. -/\ndef choose_x (hp : ∃! a : α, p a) : {a // p a} :=\n⟨finset.choose p univ (by simp; exact hp), finset.choose_property _ _ _⟩\n\n/-- Given a fintype `α` and a predicate `p`, associate to a proof that there is a unique element of\n`α` satisfying `p` this unique element, as an element of `α`. -/\ndef choose (hp : ∃! a, p a) : α := choose_x p hp\n\nlemma choose_spec (hp : ∃! a, p a) : p (choose p hp) :=\n(choose_x p hp).property\n\n@[simp] lemma choose_subtype_eq {α : Type*} (p : α → Prop) [fintype {a : α // p a}]\n  [decidable_eq α] (x : {a : α // p a})\n  (h : ∃! (a : {a // p a}), (a : α) = x := ⟨x, rfl, λ y hy, by simpa [subtype.ext_iff] using hy⟩) :\n  fintype.choose (λ (y : {a : α // p a}), (y : α) = x) h = x :=\nby rw [subtype.ext_iff, fintype.choose_spec (λ (y : {a : α // p a}), (y : α) = x) _]\n\nend choose\n\nsection bijection_inverse\nopen function\n\nvariables [fintype α] [decidable_eq β] {f : α → β}\n\n/--\n`bij_inv f` is the unique inverse to a bijection `f`. This acts\n  as a computable alternative to `function.inv_fun`. -/\ndef bij_inv (f_bij : bijective f) (b : β) : α :=\nfintype.choose (λ a, f a = b)\nbegin\n  rcases f_bij.right b with ⟨a', fa_eq_b⟩,\n  rw ← fa_eq_b,\n  exact ⟨a', ⟨rfl, (λ a h, f_bij.left h)⟩⟩\nend\n\nlemma left_inverse_bij_inv (f_bij : bijective f) : left_inverse (bij_inv f_bij) f :=\nλ a, f_bij.left (choose_spec (λ a', f a' = f a) _)\n\nlemma right_inverse_bij_inv (f_bij : bijective f) : right_inverse (bij_inv f_bij) f :=\nλ b, choose_spec (λ a', f a' = b) _\n\nlemma bijective_bij_inv (f_bij : bijective f) : bijective (bij_inv f_bij) :=\n⟨(right_inverse_bij_inv _).injective, (left_inverse_bij_inv _).surjective⟩\n\nend bijection_inverse\nend fintype\n\nsection trunc\n\n/--\nFor `s : multiset α`, we can lift the existential statement that `∃ x, x ∈ s` to a `trunc α`.\n-/\ndef trunc_of_multiset_exists_mem {α} (s : multiset α) : (∃ x, x ∈ s) → trunc α :=\nquotient.rec_on_subsingleton s $ λ l h,\n  match l, h with\n    | [],       _ := false.elim (by tauto)\n    | (a :: _), _ := trunc.mk a\n  end\n\n/--\nA `nonempty` `fintype` constructively contains an element.\n-/\ndef trunc_of_nonempty_fintype (α) [nonempty α] [fintype α] : trunc α :=\ntrunc_of_multiset_exists_mem finset.univ.val (by simp)\n\n/--\nBy iterating over the elements of a fintype, we can lift an existential statement `∃ a, P a`\nto `trunc (Σ' a, P a)`, containing data.\n-/\ndef trunc_sigma_of_exists {α} [fintype α] {P : α → Prop} [decidable_pred P] (h : ∃ a, P a) :\n  trunc (Σ' a, P a) :=\n@trunc_of_nonempty_fintype (Σ' a, P a) (exists.elim h $ λ a ha, ⟨⟨a, ha⟩⟩) _\n\nend trunc\n\nnamespace multiset\n\nvariables [fintype α] [decidable_eq α]\n\n@[simp] lemma count_univ (a : α) :\n  count a finset.univ.val = 1 :=\ncount_eq_one_of_mem finset.univ.nodup (finset.mem_univ _)\n\nend multiset\n\n/-- Auxiliary definition to show `exists_seq_of_forall_finset_exists`. -/\nnoncomputable def seq_of_forall_finset_exists_aux\n  {α : Type*} [decidable_eq α] (P : α → Prop) (r : α → α → Prop)\n  (h : ∀ (s : finset α), ∃ y, (∀ x ∈ s, P x) → (P y ∧ (∀ x ∈ s, r x y))) : ℕ → α\n| n := classical.some (h (finset.image (λ (i : fin n), seq_of_forall_finset_exists_aux i)\n        (finset.univ : finset (fin n))))\nusing_well_founded {dec_tac := `[exact i.2]}\n\n/-- Induction principle to build a sequence, by adding one point at a time satisfying a given\nrelation with respect to all the previously chosen points.\n\nMore precisely, Assume that, for any finite set `s`, one can find another point satisfying\nsome relation `r` with respect to all the points in `s`. Then one may construct a\nfunction `f : ℕ → α` such that `r (f m) (f n)` holds whenever `m < n`.\nWe also ensure that all constructed points satisfy a given predicate `P`. -/\nlemma exists_seq_of_forall_finset_exists {α : Type*} (P : α → Prop) (r : α → α → Prop)\n  (h : ∀ (s : finset α), (∀ x ∈ s, P x) → ∃ y, P y ∧ (∀ x ∈ s, r x y)) :\n  ∃ (f : ℕ → α), (∀ n, P (f n)) ∧ (∀ m n, m < n → r (f m) (f n)) :=\nbegin\n  classical,\n  haveI : nonempty α,\n  { rcases h ∅ (by simp) with ⟨y, hy⟩,\n    exact ⟨y⟩ },\n  choose! F hF using h,\n  have h' : ∀ (s : finset α), ∃ y, (∀ x ∈ s, P x) → (P y ∧ (∀ x ∈ s, r x y)) := λ s, ⟨F s, hF s⟩,\n  set f := seq_of_forall_finset_exists_aux P r h' with hf,\n  have A : ∀ (n : ℕ), P (f n),\n  { assume n,\n    induction n using nat.strong_induction_on with n IH,\n    have IH' : ∀ (x : fin n), P (f x) := λ n, IH n.1 n.2,\n    rw [hf, seq_of_forall_finset_exists_aux],\n    exact (classical.some_spec (h' (finset.image (λ (i : fin n), f i)\n      (finset.univ : finset (fin n)))) (by simp [IH'])).1 },\n  refine ⟨f, A, λ m n hmn, _⟩,\n  nth_rewrite 1 hf,\n  rw seq_of_forall_finset_exists_aux,\n  apply (classical.some_spec (h' (finset.image (λ (i : fin n), f i)\n    (finset.univ : finset (fin n)))) (by simp [A])).2,\n  exact finset.mem_image.2 ⟨⟨m, hmn⟩, finset.mem_univ _, rfl⟩,\nend\n\n/-- Induction principle to build a sequence, by adding one point at a time satisfying a given\nsymmetric relation with respect to all the previously chosen points.\n\nMore precisely, Assume that, for any finite set `s`, one can find another point satisfying\nsome relation `r` with respect to all the points in `s`. Then one may construct a\nfunction `f : ℕ → α` such that `r (f m) (f n)` holds whenever `m ≠ n`.\nWe also ensure that all constructed points satisfy a given predicate `P`. -/\nlemma exists_seq_of_forall_finset_exists' {α : Type*} (P : α → Prop) (r : α → α → Prop)\n  [is_symm α r]\n  (h : ∀ (s : finset α), (∀ x ∈ s, P x) → ∃ y, P y ∧ (∀ x ∈ s, r x y)) :\n  ∃ (f : ℕ → α), (∀ n, P (f n)) ∧ (∀ m n, m ≠ n → r (f m) (f n)) :=\nbegin\n  rcases exists_seq_of_forall_finset_exists P r h with ⟨f, hf, hf'⟩,\n  refine ⟨f, hf, λ m n hmn, _⟩,\n  rcases lt_trichotomy m n with h|rfl|h,\n  { exact hf' m n h },\n  { exact (hmn rfl).elim },\n  { apply symm,\n    exact hf' n m h }\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/fintype/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.4929194185951377}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport algebra.homology.image_to_kernel\n\n/-!\n# Exact sequences\n\nIn a category with zero morphisms, images, and equalizers we say that `f : A ⟶ B` and `g : B ⟶ C`\nare exact if `f ≫ g = 0` and the natural map `image f ⟶ kernel g` is an epimorphism.\n\nIn any preadditive category this is equivalent to the homology at `B` vanishing.\n\nHowever in general it is weaker than other reasonable definitions of exactness,\nparticularly that\n1. the inclusion map `image.ι f` is a kernel of `g` or\n2. `image f ⟶ kernel g` is an isomorphism or\n3. `image_subobject f = kernel_subobject f`.\nHowever when the category is abelian, these all become equivalent;\nthese results are found in `category_theory/abelian/exact.lean`.\n\n# Main results\n* Suppose that cokernels exist and that `f` and `g` are exact.\n  If `s` is any kernel fork over `g` and `t` is any cokernel cofork over `f`,\n  then `fork.ι s ≫ cofork.π t = 0`.\n* Precomposing the first morphism with an epimorphism retains exactness.\n  Postcomposing the second morphism with a monomorphism retains exactness.\n* If `f` and `g` are exact and `i` is an isomorphism,\n  then `f ≫ i.hom` and `i.inv ≫ g` are also exact.\n\n# Future work\n* Short exact sequences, split exact sequences, the splitting lemma (maybe only for abelian\n  categories?)\n* Two adjacent maps in a chain complex are exact iff the homology vanishes\n\n-/\n\nuniverses v v₂ u u₂\n\nopen category_theory\nopen category_theory.limits\n\nvariables {V : Type u} [category.{v} V]\nvariables [has_images V]\n\nnamespace category_theory\n\n/--\nTwo morphisms `f : A ⟶ B`, `g : B ⟶ C` are called exact if `w : f ≫ g = 0` and the natural map\n`image_to_kernel f g w : image_subobject f ⟶ kernel_subobject g` is an epimorphism.\n\nIn any preadditive category, this is equivalent to `w : f ≫ g = 0` and `homology f g w ≅ 0`.\n\nIn an abelian category, this is equivalent to `image_to_kernel f g w` being an isomorphism,\nand hence equivalent to the usual definition,\n`image_subobject f = kernel_subobject g`.\n-/\n-- One nice feature of this definition is that we have\n-- `epi f → exact g h → exact (f ≫ g) h` and `exact f g → mono h → exact f (g ≫ h)`,\n-- which do not necessarily hold in a non-abelian category with the usual definition of `exact`.\nstructure exact [has_zero_morphisms V] [has_kernels V] {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Prop :=\n(w : f ≫ g = 0)\n(epi : epi (image_to_kernel f g w))\n\n-- This works as an instance even though `exact` itself is not a class, as long as the goal is\n-- literally of the form `epi (image_to_kernel f g h.w)` (where `h : exact f g`). If the proof of\n-- `f ≫ g = 0` looks different, we are out of luck and have to add the instance by hand.\nattribute [instance] exact.epi\nattribute [reassoc] exact.w\n\nsection\nvariables [has_zero_object V] [preadditive V] [has_kernels V] [has_cokernels V]\nopen_locale zero_object\n\n/--\nIn any preadditive category,\ncomposable morphisms `f g` are exact iff they compose to zero and the homology vanishes.\n-/\nlemma preadditive.exact_iff_homology_zero {A B C : V} (f : A ⟶ B) (g : B ⟶ C) :\n  exact f g ↔ ∃ w : f ≫ g = 0, nonempty (homology f g w ≅ 0) :=\n⟨λ h, ⟨h.w, ⟨cokernel.of_epi _⟩⟩,\n  λ h, begin\n    obtain ⟨w, ⟨i⟩⟩ := h,\n    exact ⟨w, preadditive.epi_of_cokernel_zero ((cancel_mono i.hom).mp (by ext))⟩,\n  end⟩\n\nlemma preadditive.exact_of_iso_of_exact {A₁ B₁ C₁ A₂ B₂ C₂ : V}\n  (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂)\n  (α : arrow.mk f₁ ≅ arrow.mk f₂) (β : arrow.mk g₁ ≅ arrow.mk g₂) (p : α.hom.right = β.hom.left)\n  (h : exact f₁ g₁) :\n  exact f₂ g₂ :=\nbegin\n  rw preadditive.exact_iff_homology_zero at h ⊢,\n  rcases h with ⟨w₁, ⟨i⟩⟩,\n  suffices w₂ : f₂ ≫ g₂ = 0, from ⟨w₂, ⟨(homology.map_iso w₁ w₂ α β p).symm.trans i⟩⟩,\n  rw [← cancel_epi α.hom.left, ← cancel_mono β.inv.right, comp_zero, zero_comp, ← w₁],\n  simp only [← arrow.mk_hom f₁, ← arrow.left_hom_inv_right α.hom,\n      ← arrow.mk_hom g₁, ← arrow.left_hom_inv_right β.hom, p],\n  simp only [arrow.mk_hom, is_iso.inv_hom_id_assoc, category.assoc, ← arrow.inv_right,\n    is_iso.iso.inv_hom]\nend\n\n/-- A reformulation of `preadditive.exact_of_iso_of_exact` that does not involve the arrow\ncategory. -/\nlemma preadditive.exact_of_iso_of_exact' {A₁ B₁ C₁ A₂ B₂ C₂ : V}\n  (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂)\n  (α : A₁ ≅ A₂) (β : B₁ ≅ B₂) (γ : C₁ ≅ C₂) (hsq₁ : α.hom ≫ f₂ = f₁ ≫ β.hom)\n  (hsq₂ : β.hom ≫ g₂ = g₁ ≫ γ.hom)\n  (h : exact f₁ g₁) :\n  exact f₂ g₂ :=\npreadditive.exact_of_iso_of_exact f₁ g₁ f₂ g₂ (arrow.iso_mk α β hsq₁) (arrow.iso_mk β γ hsq₂) rfl h\n\nlemma preadditive.exact_iff_exact_of_iso {A₁ B₁ C₁ A₂ B₂ C₂ : V}\n  (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂)\n  (α : arrow.mk f₁ ≅ arrow.mk f₂) (β : arrow.mk g₁ ≅ arrow.mk g₂) (p : α.hom.right = β.hom.left) :\n  exact f₁ g₁ ↔ exact f₂ g₂ :=\n⟨preadditive.exact_of_iso_of_exact _ _ _ _ _ _ p,\npreadditive.exact_of_iso_of_exact _ _ _ _ α.symm β.symm\n  begin\n    rw ← cancel_mono α.hom.right,\n    simp only [iso.symm_hom, ← comma.comp_right, α.inv_hom_id],\n    simp only [p, ←comma.comp_left, arrow.id_right, arrow.id_left, iso.inv_hom_id],\n    refl\n  end⟩\n\nend\n\nsection\nvariables [has_zero_morphisms V] [has_kernels V]\n\nlemma comp_eq_zero_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C)\n  (p : image_subobject f = kernel_subobject g) : f ≫ g = 0 :=\nbegin\n  rw [←image_subobject_arrow_comp f, category.assoc],\n  convert comp_zero,\n  rw p,\n  simp,\nend\n\nlemma image_to_kernel_is_iso_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C)\n  (p : image_subobject f = kernel_subobject g) :\n  is_iso (image_to_kernel f g (comp_eq_zero_of_image_eq_kernel f g p)) :=\nbegin\n  refine ⟨⟨subobject.of_le _ _ p.ge, _⟩⟩,\n  dsimp [image_to_kernel],\n  simp only [subobject.of_le_comp_of_le, subobject.of_le_refl],\n  simp,\nend\n\n-- We'll prove the converse later, when `V` is abelian.\nlemma exact_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C)\n  (p : image_subobject f = kernel_subobject g) : exact f g :=\n{ w := comp_eq_zero_of_image_eq_kernel f g p,\n  epi := begin\n    haveI := image_to_kernel_is_iso_of_image_eq_kernel f g p,\n    apply_instance,\n  end }\n\nend\n\nvariables {A B C D : V} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\nlocal attribute [instance] epi_comp\n\nsection\nvariables [has_zero_morphisms V] [has_equalizers V]\n\nlemma exact_comp_hom_inv_comp (i : B ≅ D) (h : exact f g) : exact (f ≫ i.hom) (i.inv ≫ g) :=\nbegin\n  refine ⟨by simp [h.w], _⟩,\n  rw image_to_kernel_comp_hom_inv_comp,\n  haveI := h.epi,\n  apply_instance,\nend\n\nlemma exact_comp_inv_hom_comp (i : D ≅ B) (h : exact f g) : exact (f ≫ i.inv) (i.hom ≫ g) :=\nexact_comp_hom_inv_comp i.symm h\n\nlemma exact_comp_hom_inv_comp_iff (i : B ≅ D) : exact (f ≫ i.hom) (i.inv ≫ g) ↔ exact f g :=\n⟨λ h, by simpa using exact_comp_inv_hom_comp i h, exact_comp_hom_inv_comp i⟩\n\nlemma exact_epi_comp (hgh : exact g h) [epi f] : exact (f ≫ g) h :=\nbegin\n  refine ⟨by simp [hgh.w], _⟩,\n  rw image_to_kernel_comp_left,\n  apply_instance,\nend\n\n@[simp]\nlemma exact_iso_comp [is_iso f] : exact (f ≫ g) h ↔ exact g h :=\n⟨λ w, by { rw ←is_iso.inv_hom_id_assoc f g, exact exact_epi_comp w }, λ w, exact_epi_comp w⟩\n\nlemma exact_comp_mono (hfg : exact f g) [mono h] : exact f (g ≫ h) :=\nbegin\n  refine ⟨by simp [hfg.w_assoc], _⟩,\n  rw image_to_kernel_comp_right f g h hfg.w,\n  apply_instance,\nend\n\n/-- The dual of this lemma is only true when `V` is abelian, see `abelian.exact_epi_comp_iff`. -/\nlemma exact_comp_mono_iff [mono h] : exact f (g ≫ h) ↔ exact f g :=\nbegin\n  refine ⟨λ hfg, ⟨zero_of_comp_mono h (by rw [category.assoc, hfg.1]), _⟩, λ h, exact_comp_mono h⟩,\n  rw ← (iso.eq_comp_inv _).1 (image_to_kernel_comp_mono _ _ h hfg.1),\n  haveI := hfg.2, apply_instance\nend\n\n@[simp]\n\n\nlemma exact_kernel_subobject_arrow : exact (kernel_subobject f).arrow f :=\nbegin\n  refine ⟨by simp, _⟩,\n  apply @is_iso.epi_of_iso _ _ _ _ _ _,\n  exact ⟨⟨factor_thru_image_subobject _, by { ext, simp, }, by { ext, simp, }⟩⟩,\nend\n\nlemma exact_kernel_ι : exact (kernel.ι f) f :=\nby { rw [←kernel_subobject_arrow', exact_iso_comp], exact exact_kernel_subobject_arrow }\n\ninstance (h : exact f g) : epi (factor_thru_kernel_subobject g f h.w) :=\nbegin\n  rw ←factor_thru_image_subobject_comp_image_to_kernel,\n  apply epi_comp,\nend\n\ninstance (h : exact f g) : epi (kernel.lift g f h.w) :=\nbegin\n  rw ←factor_thru_kernel_subobject_comp_kernel_subobject_iso,\n  apply epi_comp\nend\n\nvariables (A)\n\nlemma kernel_subobject_arrow_eq_zero_of_exact_zero_left (h : exact (0 : A ⟶ B) g) :\n  (kernel_subobject g).arrow = 0 :=\nbegin\n  rw [←cancel_epi (image_to_kernel (0 : A ⟶ B) g h.w),\n    ←cancel_epi (factor_thru_image_subobject (0 : A ⟶ B))],\n  simp\nend\n\nlemma kernel_ι_eq_zero_of_exact_zero_left (h : exact (0 : A ⟶ B) g) :\n  kernel.ι g = 0 :=\nby { rw ←kernel_subobject_arrow', simp [kernel_subobject_arrow_eq_zero_of_exact_zero_left A h], }\n\nlemma exact_zero_left_of_mono [has_zero_object V] [mono g] : exact (0 : A ⟶ B) g :=\n⟨by simp, image_to_kernel_epi_of_zero_of_mono _⟩\n\nend\n\nsection has_cokernels\nvariables [has_zero_morphisms V] [has_equalizers V] [has_cokernels V] (f g)\n\n@[simp, reassoc] lemma kernel_comp_cokernel (h : exact f g) : kernel.ι g ≫ cokernel.π f = 0 :=\nbegin\n  rw [←kernel_subobject_arrow', category.assoc],\n  convert comp_zero,\n  apply zero_of_epi_comp (image_to_kernel f g h.w) _,\n  rw [image_to_kernel_arrow_assoc, ←image_subobject_arrow, category.assoc, ←iso.eq_inv_comp],\n  ext,\n  simp,\nend\n\nlemma comp_eq_zero_of_exact (h : exact f g) {X Y : V} {ι : X ⟶ B} (hι : ι ≫ g = 0) {π : B ⟶ Y}\n  (hπ : f ≫ π = 0) : ι ≫ π = 0 :=\nby rw [←kernel.lift_ι _ _ hι, ←cokernel.π_desc _ _ hπ, category.assoc,\n  kernel_comp_cokernel_assoc _ _ h, zero_comp, comp_zero]\n\n@[simp, reassoc] lemma fork_ι_comp_cofork_π (h : exact f g) (s : kernel_fork g)\n  (t : cokernel_cofork f) : fork.ι s ≫ cofork.π t = 0 :=\ncomp_eq_zero_of_exact f g h (kernel_fork.condition s) (cokernel_cofork.condition t)\n\nend has_cokernels\n\nsection\nvariables [has_zero_object V]\n\nopen_locale zero_object\n\nsection\nvariables [has_zero_morphisms V] [has_kernels V]\n\nlemma exact_of_zero {A C : V} (f : A ⟶ 0) (g : 0 ⟶ C) : exact f g :=\nbegin\n  obtain rfl : f = 0 := by ext,\n  obtain rfl : g = 0 := by ext,\n  fsplit,\n  { simp, },\n  { exact image_to_kernel_epi_of_zero_of_mono 0, },\nend\n\nlemma exact_zero_mono {B C : V} (f : B ⟶ C) [mono f] : exact (0 : (0 ⟶ B)) f :=\n⟨by simp, infer_instance⟩\n\nlemma exact_epi_zero {A B : V} (f : A ⟶ B) [epi f] : exact f (0 : (B ⟶ 0)) :=\n⟨by simp, infer_instance⟩\n\nend\n\nsection\nvariables [preadditive V]\n\nlemma mono_iff_exact_zero_left [has_kernels V] {B C : V} (f : B ⟶ C) :\n  mono f ↔ exact (0 : (0 ⟶ B)) f :=\n⟨λ h, by exactI exact_zero_mono _,\n  λ h, preadditive.mono_of_kernel_iso_zero\n      ((kernel_subobject_iso f).symm ≪≫ iso_zero_of_epi_zero (by simpa using h.epi))⟩\n\nlemma epi_iff_exact_zero_right [has_equalizers V] {A B : V} (f : A ⟶ B) :\n  epi f ↔ exact f (0 : (B ⟶ 0)) :=\n⟨λ h, by exactI exact_epi_zero _,\n  λ h, begin\n    have e₁ := h.epi,\n    rw image_to_kernel_zero_right at e₁,\n    have e₂ : epi (((image_subobject f).arrow ≫ inv (kernel_subobject 0).arrow) ≫\n      (kernel_subobject 0).arrow) := @epi_comp _ _ _ _ _ _ e₁ _ _,\n    rw [category.assoc, is_iso.inv_hom_id, category.comp_id] at e₂,\n    rw [←image_subobject_arrow] at e₂,\n    resetI,\n    haveI : epi (image.ι f) := epi_of_epi (image_subobject_iso f).hom (image.ι f),\n    apply epi_of_epi_image,\n  end⟩\n\nend\n\nend\n\nnamespace functor\nvariables [has_zero_morphisms V] [has_kernels V] {W : Type u₂} [category.{v₂} W]\nvariables [has_images W] [has_zero_morphisms W] [has_kernels W]\n\n/-- A functor reflects exact sequences if any composable pair of morphisms that is mapped to an\n    exact pair is itself exact. -/\nclass reflects_exact_sequences (F : V ⥤ W) :=\n(reflects : ∀ {A B C : V} (f : A ⟶ B) (g : B ⟶ C), exact (F.map f) (F.map g) → exact f g)\n\nlemma exact_of_exact_map (F : V ⥤ W) [reflects_exact_sequences F] {A B C : V} {f : A ⟶ B}\n  {g : B ⟶ C} (hfg : exact (F.map f) (F.map g)) : exact f g :=\nreflects_exact_sequences.reflects f g hfg\n\nend functor\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/homology/exact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.49290094453583033}}
{"text": "/-\nCopyright (c) 2022 Yuma Mizuno. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuma Mizuno\n-/\nimport category_theory.bicategory.functor\n\n/-!\n# Free bicategories\n\nWe define the free bicategory over a quiver. In this bicategory, the 1-morphisms are freely\ngenerated by the arrows in the quiver, and the 2-morphisms are freely generated by the formal\nidentities, the formal unitors, and the formal associators modulo the relation derived from the\naxioms of a bicategory.\n\n## Main definitions\n\n* `free_bicategory B`: the free bicategory over a quiver `B`.\n* `free_bicategory.lift F`: the pseudofunctor from `free_bicategory B` to `C` associated with a\n  prefunctor `F` from `B` to `C`.\n-/\n\nuniverses w w₁ w₂ v v₁ v₂ u u₁ u₂\n\nnamespace category_theory\nopen category bicategory\nopen_locale bicategory\n\n/-- Free bicategory over a quiver. Its objects are the same as those in the underlying quiver. -/\ndef free_bicategory (B : Type u) := B\n\ninstance (B : Type u) : Π [inhabited B], inhabited (free_bicategory B) := id\n\nnamespace free_bicategory\n\nsection\nvariables {B : Type u} [quiver.{v+1} B]\n\n/-- 1-morphisms in the free bicategory. -/\ninductive hom : B → B → Type (max u v)\n| of {a b : B} (f : a ⟶ b) : hom a b\n| id (a : B) : hom a a\n| comp {a b c : B} (f : hom a b) (g : hom b c) : hom a c\n\ninstance (a b : B) [inhabited (a ⟶ b)] : inhabited (hom a b) := ⟨hom.of default⟩\n\n/-- Representatives of 2-morphisms in the free bicategory. -/\n@[nolint has_nonempty_instance]\ninductive hom₂ : Π {a b : B}, hom a b → hom a b → Type (max u v)\n| id {a b} (f : hom a b) : hom₂ f f\n| vcomp {a b} {f g h : hom a b} (η : hom₂ f g) (θ : hom₂ g h) : hom₂ f h\n| whisker_left {a b c} (f : hom a b) {g h : hom b c} (η : hom₂ g h) : hom₂ (f.comp g) (f.comp h)\n-- `η` cannot be earlier than `h` since it is a recursive argument.\n| whisker_right {a b c} {f g : hom a b} (h : hom b c) (η : hom₂ f g) : hom₂ (f.comp h) (g.comp h)\n| associator {a b c d} (f : hom a b) (g : hom b c) (h : hom c d) :\n    hom₂ ((f.comp g).comp h) (f.comp (g.comp h))\n| associator_inv {a b c d} (f : hom a b) (g : hom b c) (h : hom c d) :\n    hom₂ (f.comp (g.comp h)) ((f.comp g).comp h)\n| right_unitor     {a b} (f : hom a b) : hom₂ (f.comp (hom.id b)) f\n| right_unitor_inv {a b} (f : hom a b) : hom₂ f (f.comp (hom.id b))\n| left_unitor      {a b} (f : hom a b) : hom₂ ((hom.id a).comp f) f\n| left_unitor_inv  {a b} (f : hom a b) : hom₂ f ((hom.id a).comp f)\n\nsection\nvariables {B}\n\n-- The following notations are only used in the definition of `rel` to simplify the notation.\nlocal infixr (name := vcomp) ` ≫ ` := hom₂.vcomp\nlocal notation (name := id) `𝟙` := hom₂.id\nlocal notation (name := whisker_left) f ` ◁ ` η := hom₂.whisker_left f η\nlocal notation (name := whisker_right) η ` ▷ ` h := hom₂.whisker_right h η\nlocal notation (name := associator) `α_` := hom₂.associator\nlocal notation (name := left_unitor) `λ_` := hom₂.left_unitor\nlocal notation (name := right_unitor) `ρ_` := hom₂.right_unitor\nlocal notation (name := associator_inv) `α⁻¹_` := hom₂.associator_inv\nlocal notation (name := left_unitor_inv) `λ⁻¹_` := hom₂.left_unitor_inv\nlocal notation (name := right_unitor_inv) `ρ⁻¹_` := hom₂.right_unitor_inv\n\n/-- Relations between 2-morphisms in the free bicategory. -/\ninductive rel : Π {a b : B} {f g : hom a b}, hom₂ f g → hom₂ f g → Prop\n| vcomp_right {a b} {f g h : hom a b} (η : hom₂ f g) (θ₁ θ₂ : hom₂ g h) :\n    rel θ₁ θ₂ → rel (η ≫ θ₁) (η ≫ θ₂)\n| vcomp_left {a b} {f g h : hom a b} (η₁ η₂ : hom₂ f g) (θ : hom₂ g h) :\n    rel η₁ η₂ → rel (η₁ ≫ θ) (η₂ ≫ θ)\n| id_comp {a b} {f g : hom a b} (η : hom₂ f g) :\n    rel (𝟙 f ≫ η) η\n| comp_id {a b} {f g : hom a b} (η : hom₂ f g) :\n    rel (η ≫ 𝟙 g) η\n| assoc {a b} {f g h i : hom a b} (η : hom₂ f g) (θ : hom₂ g h) (ι : hom₂ h i) :\n    rel ((η ≫ θ) ≫ ι) (η ≫ (θ ≫ ι))\n| whisker_left {a b c} (f : hom a b) (g h : hom b c) (η η' : hom₂ g h) :\n    rel η η' → rel (f ◁ η) (f ◁ η')\n| whisker_left_id {a b c} (f : hom a b) (g : hom b c) :\n    rel (f ◁ 𝟙 g) (𝟙 (f.comp g))\n| whisker_left_comp {a b c} (f : hom a b) {g h i : hom b c} (η : hom₂ g h) (θ : hom₂ h i) :\n    rel (f ◁ (η ≫ θ)) (f ◁ η ≫ f ◁ θ)\n| id_whisker_left {a b} {f g : hom a b} (η : hom₂ f g) :\n    rel (hom.id a ◁ η) (λ_ f ≫ η ≫ λ⁻¹_ g)\n| comp_whisker_left\n    {a b c d} (f : hom a b) (g : hom b c) {h h' : hom c d} (η : hom₂ h h') :\n    rel ((f.comp g) ◁ η) (α_ f g h ≫ f ◁ g ◁ η ≫ α⁻¹_ f g h')\n| whisker_right {a b c} (f g : hom a b) (h : hom b c) (η η' : hom₂ f g) :\n    rel η η' → rel (η ▷ h) (η' ▷ h)\n| id_whisker_right {a b c} (f : hom a b) (g : hom b c) :\n    rel (𝟙 f ▷ g) (𝟙 (f.comp g))\n| comp_whisker_right {a b c} {f g h : hom a b} (i : hom b c) (η : hom₂ f g) (θ : hom₂ g h) :\n    rel ((η ≫ θ) ▷ i) (η ▷ i ≫ θ ▷ i)\n| whisker_right_id {a b} {f g : hom a b} (η : hom₂ f g) :\n    rel (η ▷ hom.id b) (ρ_ f ≫ η ≫ ρ⁻¹_ g)\n| whisker_right_comp\n    {a b c d} {f f' : hom a b} (g : hom b c) (h : hom c d) (η : hom₂ f f') :\n    rel (η ▷ (g.comp h)) (α⁻¹_ f g h ≫ η ▷ g ▷ h ≫ α_ f' g h)\n| whisker_assoc\n    {a b c d} (f : hom a b) {g g' : hom b c} (η : hom₂ g g') (h : hom c d) :\n    rel ((f ◁ η) ▷ h) (α_ f g h ≫ f ◁ (η ▷ h)≫ α⁻¹_ f g' h)\n| whisker_exchange {a b c} {f g : hom a b} {h i : hom b c} (η : hom₂ f g) (θ : hom₂ h i) :\n    rel (f ◁ θ ≫ η ▷ i) (η ▷ h ≫ g ◁ θ)\n| associator_hom_inv {a b c d} (f : hom a b) (g : hom b c) (h : hom c d) :\n    rel (α_ f g h ≫ α⁻¹_ f g h) (𝟙 ((f.comp g).comp h))\n| associator_inv_hom {a b c d} (f : hom a b) (g : hom b c) (h : hom c d) :\n    rel (α⁻¹_ f g h ≫ α_ f g h) (𝟙 (f.comp (g.comp h)))\n| left_unitor_hom_inv {a b} (f : hom a b) :\n    rel (λ_ f ≫ λ⁻¹_ f) (𝟙 ((hom.id a).comp f))\n| left_unitor_inv_hom {a b} (f : hom a b) :\n    rel (λ⁻¹_ f ≫ λ_ f) (𝟙 f)\n| right_unitor_hom_inv {a b} (f : hom a b) :\n    rel (ρ_ f ≫ ρ⁻¹_ f) (𝟙 (f.comp (hom.id b)))\n| right_unitor_inv_hom {a b} (f : hom a b) :\n    rel (ρ⁻¹_ f ≫ ρ_ f) (𝟙 f)\n| pentagon {a b c d e} (f : hom a b) (g : hom b c) (h : hom c d) (i : hom d e) :\n    rel (α_ f g h ▷ i ≫ α_ f (g.comp h) i ≫ f ◁ α_ g h i)\n        (α_ (f.comp g) h i ≫ α_ f g (h.comp i))\n| triangle {a b c} (f : hom a b) (g : hom b c) :\n    rel (α_ f (hom.id b) g ≫ f ◁ λ_ g) (ρ_ f ▷ g)\n\nend\n\nvariables {B}\n\ninstance hom_category (a b : B) : category (hom a b) :=\n{ hom       := λ f g, quot (@rel _ _ _ _ f g),\n  id        := λ f, quot.mk rel (hom₂.id f),\n  comp      := λ f g h, quot.map₂ hom₂.vcomp rel.vcomp_right rel.vcomp_left,\n  id_comp'  := by { rintros f g ⟨η⟩, exact quot.sound (rel.id_comp η) },\n  comp_id'  := by { rintros f g ⟨η⟩, exact quot.sound (rel.comp_id η) },\n  assoc'    := by { rintros f g h i ⟨η⟩ ⟨θ⟩ ⟨ι⟩, exact quot.sound (rel.assoc η θ ι) } }\n\n/-- Bicategory structure on the free bicategory. -/\ninstance bicategory : bicategory (free_bicategory B) :=\n{ hom   := λ a b : B, hom a b,\n  id    := hom.id,\n  comp  := λ a b c, hom.comp,\n  hom_category := free_bicategory.hom_category,\n  whisker_left := λ a b c f g h η,\n    quot.map (hom₂.whisker_left f) (rel.whisker_left f g h) η,\n  whisker_left_id' := λ a b c f g, quot.sound (rel.whisker_left_id f g),\n  whisker_left_comp' := by\n  { rintros a b c f g h i ⟨η⟩ ⟨θ⟩, exact quot.sound (rel.whisker_left_comp f η θ) },\n  id_whisker_left' := by\n  { rintros a b f g ⟨η⟩, exact quot.sound (rel.id_whisker_left η) },\n  comp_whisker_left' := by\n  { rintros a b c d f g h h' ⟨η⟩, exact quot.sound (rel.comp_whisker_left f g η) },\n  whisker_right := λ a b c f g η h,\n    quot.map (hom₂.whisker_right h) (rel.whisker_right f g h) η,\n  id_whisker_right' := λ a b c f g, quot.sound (rel.id_whisker_right f g),\n  comp_whisker_right' := by\n  { rintros a b c f g h ⟨η⟩ ⟨θ⟩ i, exact quot.sound (rel.comp_whisker_right i η θ) },\n  whisker_right_id' := by\n  { rintros a b f g ⟨η⟩, exact quot.sound (rel.whisker_right_id η) },\n  whisker_right_comp' := by\n  { rintros a b c d f f' ⟨η⟩ g h, exact quot.sound (rel.whisker_right_comp g h η) },\n  whisker_assoc' := by\n  { rintros a b c d f g g' ⟨η⟩ h, exact quot.sound (rel.whisker_assoc f η h) },\n  whisker_exchange' := by\n  { rintros a b c f g h i ⟨η⟩ ⟨θ⟩, exact quot.sound (rel.whisker_exchange η θ) },\n  associator := λ a b c d f g h,\n  { hom := quot.mk rel (hom₂.associator f g h),\n    inv := quot.mk rel (hom₂.associator_inv f g h),\n    hom_inv_id' := quot.sound (rel.associator_hom_inv f g h),\n    inv_hom_id' := quot.sound (rel.associator_inv_hom f g h) },\n  left_unitor := λ a b f,\n  { hom := quot.mk rel (hom₂.left_unitor f),\n    inv := quot.mk rel (hom₂.left_unitor_inv f),\n    hom_inv_id' := quot.sound (rel.left_unitor_hom_inv f),\n    inv_hom_id' := quot.sound (rel.left_unitor_inv_hom f) },\n  right_unitor := λ a b f,\n  { hom := quot.mk rel (hom₂.right_unitor f),\n    inv := quot.mk rel (hom₂.right_unitor_inv f),\n    hom_inv_id' := quot.sound (rel.right_unitor_hom_inv f),\n    inv_hom_id' := quot.sound (rel.right_unitor_inv_hom f) },\n  pentagon' := λ a b c d e f g h i, quot.sound (rel.pentagon f g h i),\n  triangle' := λ a b c f g, quot.sound (rel.triangle f g) }\n\nvariables {a b c d : free_bicategory B}\n\n@[simp] lemma mk_vcomp {f g h : a ⟶ b} (η : hom₂ f g) (θ : hom₂ g h) :\n  quot.mk rel (η.vcomp θ) = (quot.mk rel η ≫ quot.mk rel θ : f ⟶ h) := rfl\n@[simp] lemma mk_whisker_left (f : a ⟶ b) {g h : b ⟶ c} (η : hom₂ g h) :\n  quot.mk rel (hom₂.whisker_left f η) = (f ◁ quot.mk rel η : f ≫ g ⟶ f ≫ h) := rfl\n@[simp] lemma mk_whisker_right {f g : a ⟶ b} (η : hom₂ f g) (h : b ⟶ c) :\n  quot.mk rel (hom₂.whisker_right h η) = (quot.mk rel η ▷ h : f ≫ h ⟶ g ≫ h) := rfl\n\nvariables (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d)\n\nlemma id_def : hom.id a = 𝟙 a := rfl\nlemma comp_def : hom.comp f g = f ≫ g := rfl\n@[simp] lemma mk_id : quot.mk _ (hom₂.id f) = 𝟙 f := rfl\n@[simp] lemma mk_associator_hom : quot.mk _ (hom₂.associator f g h) = (α_ f g h).hom := rfl\n@[simp] \n\n/-- Canonical prefunctor from `B` to `free_bicategory B`. -/\n@[simps]\ndef of : prefunctor B (free_bicategory B) :=\n{ obj := id,\n  map := λ a b, hom.of }\n\nend\n\nsection\nvariables {B : Type u₁} [quiver.{v₁+1} B] {C : Type u₂} [category_struct.{v₂} C]\nvariables (F : prefunctor B C)\n\n/-- Auxiliary definition for `lift`. -/\n@[simp]\ndef lift_hom : ∀ {a b : B}, hom a b → (F.obj a ⟶ F.obj b)\n| _ _ (hom.of f)      := F.map f\n| _ _ (hom.id a)      := 𝟙 (F.obj a)\n| _ _ (hom.comp f g)  := lift_hom f ≫ lift_hom g\n\n@[simp] lemma lift_hom_id (a : free_bicategory B) : lift_hom F (𝟙 a) = 𝟙 (F.obj a) := rfl\n@[simp] lemma lift_hom_comp {a b c : free_bicategory B} (f : a ⟶ b) (g : b ⟶ c) :\n  lift_hom F (f ≫ g) = lift_hom F f ≫ lift_hom F g := rfl\n\nend\n\nsection\nvariables {B : Type u₁} [quiver.{v₁+1} B] {C : Type u₂} [bicategory.{w₂ v₂} C]\nvariables (F : prefunctor B C)\n\n/-- Auxiliary definition for `lift`. -/\n@[simp]\ndef lift_hom₂ : ∀ {a b : B} {f g : hom a b}, hom₂ f g → (lift_hom F f ⟶ lift_hom F g)\n| _ _ _ _ (hom₂.id _)                   := 𝟙 _\n| _ _ _ _ (hom₂.associator _ _ _)       := (α_ _ _ _).hom\n| _ _ _ _ (hom₂.associator_inv _ _ _)   := (α_ _ _ _).inv\n| _ _ _ _ (hom₂.left_unitor _)          := (λ_ _).hom\n| _ _ _ _ (hom₂.left_unitor_inv _)      := (λ_ _).inv\n| _ _ _ _ (hom₂.right_unitor _)         := (ρ_ _).hom\n| _ _ _ _ (hom₂.right_unitor_inv _)     := (ρ_ _).inv\n| _ _ _ _ (hom₂.vcomp η θ)              := lift_hom₂ η ≫ lift_hom₂ θ\n| _ _ _ _ (hom₂.whisker_left f η)       := lift_hom F f ◁ lift_hom₂ η\n| _ _ _ _ (hom₂.whisker_right h η)      := lift_hom₂ η ▷ lift_hom F h\n\nlocal attribute [simp] whisker_exchange\n\nlemma lift_hom₂_congr {a b : B} {f g : hom a b} {η θ : hom₂ f g} (H : rel η θ) :\n  lift_hom₂ F η = lift_hom₂ F θ :=\nby induction H; tidy\n\n/--\nA prefunctor from a quiver `B` to a bicategory `C` can be lifted to a pseudofunctor from\n`free_bicategory B` to `C`.\n-/\n@[simps]\ndef lift : pseudofunctor (free_bicategory B) C :=\n{ obj       := F.obj,\n  map       := λ a b, lift_hom F,\n  map₂      := λ a b f g, quot.lift (lift_hom₂ F) (λ η θ H, lift_hom₂_congr F H),\n  map_id    := λ a, iso.refl _,\n  map_comp  := λ a b c f g, iso.refl _ }\n\nend\n\nend free_bicategory\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/bicategory/free.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.4927481476326506}}
{"text": "/-\nCopyright (c) 2022 Paul Reichert. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Paul Reichert\n\n! This file was ported from Lean 3 source module linear_algebra.affine_space.restrict\n! leanprover-community/mathlib commit cb3ceec8485239a61ed51d944cb9a95b68c6bafc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.AffineSpace.AffineSubspace\n\n/-!\n# Affine map restrictions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines restrictions of affine maps.\n\n## Main definitions\n\n* The domain and codomain of an affine map can be restricted using\n  `affine_map.restrict`.\n\n## Main theorems\n\n* The associated linear map of the restriction is the restriction of the\n  linear map associated to the original affine map.\n* The restriction is injective if the original map is injective.\n* The restriction in surjective if the codomain is the image of the domain.\n-/\n\n\nvariable {k V₁ P₁ V₂ P₂ : Type _} [Ring k] [AddCommGroup V₁] [AddCommGroup V₂] [Module k V₁]\n  [Module k V₂] [AddTorsor V₁ P₁] [AddTorsor V₂ P₂]\n\ninclude V₁ V₂\n\n/- warning: affine_subspace.nonempty_map -> AffineSubspace.nonempty_map is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} [Ene : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E)] {φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, Nonempty.{succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))\nbut is expected to have type\n  forall {k : Type.{u5}} {V₁ : Type.{u4}} {P₁ : Type.{u3}} {V₂ : Type.{u2}} {P₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : AddCommGroup.{u2} V₂] [_inst_4 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_5 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_3)] {E : AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} [Ene : Nonempty.{succ u3} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))] {φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, Nonempty.{succ u1} (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)))\nCase conversion may be inaccurate. Consider using '#align affine_subspace.nonempty_map AffineSubspace.nonempty_mapₓ'. -/\n-- not an instance because it loops with `nonempty`\ntheorem AffineSubspace.nonempty_map {E : AffineSubspace k P₁} [Ene : Nonempty E] {φ : P₁ →ᵃ[k] P₂} :\n    Nonempty (E.map φ) := by\n  obtain ⟨x, hx⟩ := id Ene\n  refine' ⟨⟨φ x, affine_subspace.mem_map.mpr ⟨x, hx, rfl⟩⟩⟩\n#align affine_subspace.nonempty_map AffineSubspace.nonempty_map\n\nattribute [local instance, local nolint fails_quickly] AffineSubspace.nonempty_map\n\nattribute [local instance, local nolint fails_quickly] AffineSubspace.toAddTorsor\n\n/- warning: affine_map.restrict -> AffineMap.restrict is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] (φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E)] [_inst_9 : Nonempty.{succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)], (LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F) -> (AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9))\nbut is expected to have type\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] (φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u5} (Subtype.{succ u5} P₂ (fun (x : P₂) => Membership.mem.{u5, u5} P₂ (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F))], (LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F) -> (AffineMap.{u1, u2, u3, u4, u5} k (Subtype.{succ u2} V₁ (fun (x : V₁) => Membership.mem.{u2, u2} V₁ (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u4} V₂ (fun (x : V₂) => Membership.mem.{u4, u4} V₂ (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u5} P₂ (fun (x : P₂) => Membership.mem.{u5, u5} P₂ (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict AffineMap.restrictₓ'. -/\n/-- Restrict domain and codomain of an affine map to the given subspaces. -/\ndef AffineMap.restrict (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁} {F : AffineSubspace k P₂}\n    [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) : E →ᵃ[k] F :=\n  by\n  refine' ⟨_, _, _⟩\n  · exact fun x => ⟨φ x, hEF <| affine_subspace.mem_map.mpr ⟨x, x.property, rfl⟩⟩\n  · refine' φ.linear.restrict (_ : E.direction ≤ F.direction.comap φ.linear)\n    rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n    exact AffineSubspace.direction_le hEF\n  · intro p v\n    simp only [Subtype.ext_iff, Subtype.coe_mk, AffineSubspace.coe_vadd]\n    apply AffineMap.map_vadd\n#align affine_map.restrict AffineMap.restrict\n\n/- warning: affine_map.restrict.coe_apply -> AffineMap.restrict.coe_apply is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] (φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E)] [_inst_9 : Nonempty.{succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)] (hEF : LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F) (x : coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E), Eq.{succ u5} P₂ ((fun (a : Type.{u5}) (b : Type.{u5}) [self : HasLiftT.{succ u5, succ u5} a b] => self.0) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) P₂ (HasLiftT.mk.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) P₂ (CoeTCₓ.coe.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) P₂ (coeBase.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) P₂ (coeSubtype.{succ u5} P₂ (fun (x : P₂) => Membership.Mem.{u5, u5} P₂ (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.hasMem.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F))))) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 hEF) x)) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) => P₁ -> P₂) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) φ ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) P₁ (HasLiftT.mk.{succ u3, succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) P₁ (CoeTCₓ.coe.{succ u3, succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) P₁ (coeBase.{succ u3, succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) P₁ (coeSubtype.{succ u3} P₁ (fun (x : P₁) => Membership.Mem.{u3, u3} P₁ (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.hasMem.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))))) x))\nbut is expected to have type\n  forall {k : Type.{u5}} {V₁ : Type.{u4}} {P₁ : Type.{u3}} {V₂ : Type.{u2}} {P₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : AddCommGroup.{u2} V₂] [_inst_4 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_5 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_3)] (φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (hEF : LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F) (x : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)), Eq.{succ u1} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) (Subtype.val.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (Set.{u3} P₁) (Set.instMembershipSet.{u3} P₁) x (SetLike.coe.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) E)) x)) (Subtype.val.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (Set.{u1} P₂) (Set.instMembershipSet.{u1} P₂) x (SetLike.coe.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) F)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 hEF) x)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) φ (Subtype.val.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (Set.{u3} P₁) (Set.instMembershipSet.{u3} P₁) x (SetLike.coe.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) E)) x))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.coe_apply AffineMap.restrict.coe_applyₓ'. -/\ntheorem AffineMap.restrict.coe_apply (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) (x : E) :\n    ↑(φ.restrict hEF x) = φ x :=\n  rfl\n#align affine_map.restrict.coe_apply AffineMap.restrict.coe_apply\n\n/- warning: affine_map.restrict.linear_aux -> AffineMap.restrict.linear_aux is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] {φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7} {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7}, (LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F) -> (LE.le.{u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) (Preorder.toLE.{u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) (SetLike.partialOrder.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)))) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E) (Submodule.comap.{u1, u1, u2, u4, max u2 u4} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_4 _inst_5 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (LinearMap.{u1, u1, u2, u4} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_4 _inst_5) (LinearMap.semilinearMapClass.{u1, u1, u2, u4} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_4 _inst_5 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1)))) (AffineMap.linear.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)))\nbut is expected to have type\n  forall {k : Type.{u5}} {V₁ : Type.{u4}} {P₁ : Type.{u3}} {V₂ : Type.{u2}} {P₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : AddCommGroup.{u2} V₂] [_inst_4 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_5 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_3)] {φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7} {E : AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7}, (LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F) -> (LE.le.{u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (Preorder.toLE.{u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (PartialOrder.toPreorder.{u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (OmegaCompletePartialOrder.toPartialOrder.{u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (CompleteLattice.instOmegaCompletePartialOrder.{u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (Submodule.completeLattice.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4))))) (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E) (Submodule.comap.{u5, u5, u4, u2, max u4 u2} k k V₁ V₂ (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_4 _inst_5 (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (LinearMap.{u5, u5, u4, u2} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_4 _inst_5) (LinearMap.instSemilinearMapClassLinearMap.{u5, u5, u4, u2} k k V₁ V₂ (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_4 _inst_5 (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1)))) (AffineMap.linear.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ) (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.linear_aux AffineMap.restrict.linear_auxₓ'. -/\ntheorem AffineMap.restrict.linear_aux {φ : P₁ →ᵃ[k] P₂} {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} (hEF : E.map φ ≤ F) : E.direction ≤ F.direction.comap φ.linear :=\n  by\n  rw [← Submodule.map_le_iff_le_comap, ← AffineSubspace.map_direction]\n  exact AffineSubspace.direction_le hEF\n#align affine_map.restrict.linear_aux AffineMap.restrict.linear_aux\n\n/- warning: affine_map.restrict.linear -> AffineMap.restrict.linear is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] (φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E)] [_inst_9 : Nonempty.{succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)] (hEF : LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F), Eq.{max (succ u2) (succ u4)} (LinearMap.{u1, u1, u2, u4} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (AddCommGroup.toAddCommMonoid.{u4} (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (AffineMap.linear.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 hEF)) (LinearMap.restrict.{u1, u2, u4} k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_4 _inst_5 (AffineMap.linear.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F) (AffineMap.restrict.linear_aux.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F hEF))\nbut is expected to have type\n  forall {k : Type.{u5}} {V₁ : Type.{u4}} {P₁ : Type.{u3}} {V₂ : Type.{u2}} {P₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : AddCommGroup.{u2} V₂] [_inst_4 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_5 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_3)] (φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (hEF : LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F), Eq.{max (succ u4) (succ u2)} (LinearMap.{u5, u5, u4, u2} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (AddCommGroup.toAddCommMonoid.{u4} (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (AddCommGroup.toAddCommMonoid.{u2} (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (AffineMap.linear.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 hEF)) (LinearMap.restrict.{u5, u4, u2} k V₁ V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_4 _inst_5 (AffineMap.linear.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ) (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E) (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F) (AffineMap.restrict.linear_aux.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F hEF))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.linear AffineMap.restrict.linearₓ'. -/\ntheorem AffineMap.restrict.linear (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (hEF : E.map φ ≤ F) :\n    (φ.restrict hEF).linear = φ.linear.restrict (AffineMap.restrict.linear_aux hEF) :=\n  rfl\n#align affine_map.restrict.linear AffineMap.restrict.linear\n\n/- warning: affine_map.restrict.injective -> AffineMap.restrict.injective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] {φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u5} P₁ P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) => P₁ -> P₂) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) φ)) -> (forall {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E)] [_inst_9 : Nonempty.{succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)] (hEF : LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F), Function.Injective.{succ u3, succ u5} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 hEF)))\nbut is expected to have type\n  forall {k : Type.{u5}} {V₁ : Type.{u4}} {P₁ : Type.{u3}} {V₂ : Type.{u2}} {P₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : AddCommGroup.{u2} V₂] [_inst_4 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_5 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_3)] {φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u1} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) φ)) -> (forall {E : AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (hEF : LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F), Function.Injective.{succ u3, succ u1} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 hEF)))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.injective AffineMap.restrict.injectiveₓ'. -/\ntheorem AffineMap.restrict.injective {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Injective φ)\n    {E : AffineSubspace k P₁} {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F]\n    (hEF : E.map φ ≤ F) : Function.Injective (AffineMap.restrict φ hEF) :=\n  by\n  intro x y h\n  simp only [Subtype.ext_iff, Subtype.coe_mk, AffineMap.restrict.coe_apply] at h⊢\n  exact hφ h\n#align affine_map.restrict.injective AffineMap.restrict.injective\n\n/- warning: affine_map.restrict.surjective -> AffineMap.restrict.surjective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] (φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E)] [_inst_9 : Nonempty.{succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)] (h : Eq.{succ u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F), Function.Surjective.{succ u3, succ u5} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F)) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 (le_of_eq.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F h)))\nbut is expected to have type\n  forall {k : Type.{u5}} {V₁ : Type.{u4}} {P₁ : Type.{u3}} {V₂ : Type.{u2}} {P₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : AddCommGroup.{u2} V₂] [_inst_4 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_5 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_3)] (φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (h : Eq.{succ u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F), Function.Surjective.{succ u3, succ u1} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E F _inst_8 _inst_9 (le_of_eq.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) F h)))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.surjective AffineMap.restrict.surjectiveₓ'. -/\ntheorem AffineMap.restrict.surjective (φ : P₁ →ᵃ[k] P₂) {E : AffineSubspace k P₁}\n    {F : AffineSubspace k P₂} [Nonempty E] [Nonempty F] (h : E.map φ = F) :\n    Function.Surjective (AffineMap.restrict φ (le_of_eq h)) :=\n  by\n  rintro ⟨x, hx : x ∈ F⟩\n  rw [← h, AffineSubspace.mem_map] at hx\n  obtain ⟨y, hy, rfl⟩ := hx\n  exact ⟨⟨y, hy⟩, rfl⟩\n#align affine_map.restrict.surjective AffineMap.restrict.surjective\n\n/- warning: affine_map.restrict.bijective -> AffineMap.restrict.bijective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {P₁ : Type.{u3}} {V₂ : Type.{u4}} {P₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : AddCommGroup.{u4} V₂] [_inst_4 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : Module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u4} V₂ _inst_3)] {E : AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} [_inst_8 : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E)] {φ : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u5} P₁ P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) => P₁ -> P₂) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) φ)) -> (Function.Bijective.{succ u3, succ u5} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 φ))) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 φ))) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.setLike.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (Submodule.module.{u1, u4} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 φ))) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) _inst_8 (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 φ) (le_refl.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.setLike.{u1, u4, u5} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)))))\nbut is expected to have type\n  forall {k : Type.{u5}} {V₁ : Type.{u4}} {P₁ : Type.{u3}} {V₂ : Type.{u2}} {P₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : AddCommGroup.{u2} V₂] [_inst_4 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_5 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_3)] {E : AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E))] {φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u1} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) φ)) -> (Function.Bijective.{succ u3, succ u1} (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 φ))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V₁ (fun (x : V₁) => Membership.mem.{u4, u4} V₁ (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4) V₁ (Submodule.setLike.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P₁ (fun (x : P₁) => Membership.mem.{u3, u3} P₁ (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6) P₁ (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V₂ (fun (x : V₂) => Membership.mem.{u2, u2} V₂ (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5) V₂ (Submodule.setLike.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)))) (Subtype.{succ u1} P₂ (fun (x : P₂) => Membership.mem.{u1, u1} P₂ (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) P₂ (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) _inst_1 (Submodule.addCommGroup.{u5, u4} k V₁ _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V₁ P₁ _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V₂ _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (Submodule.module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E))) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 φ))) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ E (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E) _inst_8 (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 φ) (le_refl.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V₂ P₂ _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 φ E)))))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.bijective AffineMap.restrict.bijectiveₓ'. -/\ntheorem AffineMap.restrict.bijective {E : AffineSubspace k P₁} [Nonempty E] {φ : P₁ →ᵃ[k] P₂}\n    (hφ : Function.Injective φ) : Function.Bijective (φ.restrict (le_refl (E.map φ))) :=\n  ⟨AffineMap.restrict.injective hφ _, AffineMap.restrict.surjective _ rfl⟩\n#align affine_map.restrict.bijective AffineMap.restrict.bijective\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/AffineSpace/Restrict.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4927481424605538}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\nimport data.prod.pprod\nimport data.set.countable\nimport order.filter.prod\n\n/-!\n# Filter bases\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA filter basis `B : filter_basis α` on a type `α` is a nonempty collection of sets of `α`\nsuch that the intersection of two elements of this collection contains some element of\nthe collection. Compared to filters, filter bases do not require that any set containing\nan element of `B` belongs to `B`.\nA filter basis `B` can be used to construct `B.filter : filter α` such that a set belongs\nto `B.filter` if and only if it contains an element of `B`.\n\nGiven an indexing type `ι`, a predicate `p : ι → Prop`, and a map `s : ι → set α`,\nthe proposition `h : filter.is_basis p s` makes sure the range of `s` bounded by `p`\n(ie. `s '' set_of p`) defines a filter basis `h.filter_basis`.\n\nIf one already has a filter `l` on `α`, `filter.has_basis l p s` (where `p : ι → Prop`\nand `s : ι → set α` as above) means that a set belongs to `l` if and\nonly if it contains some `s i` with `p i`. It implies `h : filter.is_basis p s`, and\n`l = h.filter_basis.filter`. The point of this definition is that checking statements\ninvolving elements of `l` often reduces to checking them on the basis elements.\n\nWe define a function `has_basis.index (h : filter.has_basis l p s) (t) (ht : t ∈ l)` that returns\nsome index `i` such that `p i` and `s i ⊆ t`. This function can be useful to avoid manual\ndestruction of `h.mem_iff.mpr ht` using `cases` or `let`.\n\nThis file also introduces more restricted classes of bases, involving monotonicity or\ncountability. In particular, for `l : filter α`, `l.is_countably_generated` means\nthere is a countable set of sets which generates `s`. This is reformulated in term of bases,\nand consequences are derived.\n\n## Main statements\n\n* `has_basis.mem_iff`, `has_basis.mem_of_superset`, `has_basis.mem_of_mem` : restate `t ∈ f`\n  in terms of a basis;\n* `basis_sets` : all sets of a filter form a basis;\n* `has_basis.inf`, `has_basis.inf_principal`, `has_basis.prod`, `has_basis.prod_self`,\n  `has_basis.map`, `has_basis.comap` : combinators to construct filters of `l ⊓ l'`,\n  `l ⊓ 𝓟 t`, `l ×ᶠ l'`, `l ×ᶠ l`, `l.map f`, `l.comap f` respectively;\n* `has_basis.le_iff`, `has_basis.ge_iff`, has_basis.le_basis_iff` : restate `l ≤ l'` in terms\n  of bases.\n* `has_basis.tendsto_right_iff`, `has_basis.tendsto_left_iff`, `has_basis.tendsto_iff` : restate\n  `tendsto f l l'` in terms of bases.\n* `is_countably_generated_iff_exists_antitone_basis` : proves a filter is\n  countably generated if and only if it admits a basis parametrized by a\n  decreasing sequence of sets indexed by `ℕ`.\n* `tendsto_iff_seq_tendsto ` : an abstract version of \"sequentially continuous implies continuous\".\n\n## Implementation notes\n\nAs with `Union`/`bUnion`/`sUnion`, there are three different approaches to filter bases:\n\n* `has_basis l s`, `s : set (set α)`;\n* `has_basis l s`, `s : ι → set α`;\n* `has_basis l p s`, `p : ι → Prop`, `s : ι → set α`.\n\nWe use the latter one because, e.g., `𝓝 x` in an `emetric_space` or in a `metric_space` has a basis\nof this form. The other two can be emulated using `s = id` or `p = λ _, true`.\n\nWith this approach sometimes one needs to `simp` the statement provided by the `has_basis`\nmachinery, e.g., `simp only [exists_prop, true_and]` or `simp only [forall_const]` can help\nwith the case `p = λ _, true`.\n-/\n\nopen set filter\nopen_locale filter classical\n\nsection sort\n\nvariables {α β γ : Type*} {ι ι' : Sort*}\n\n/-- A filter basis `B` on a type `α` is a nonempty collection of sets of `α`\nsuch that the intersection of two elements of this collection contains some element\nof the collection. -/\nstructure filter_basis (α : Type*) :=\n(sets                   : set (set α))\n(nonempty               : sets.nonempty)\n(inter_sets {x y}       : x ∈ sets → y ∈ sets → ∃ z ∈ sets, z ⊆ x ∩ y)\n\ninstance filter_basis.nonempty_sets (B : filter_basis α) : nonempty B.sets := B.nonempty.to_subtype\n\n/-- If `B` is a filter basis on `α`, and `U` a subset of `α` then we can write `U ∈ B` as\non paper. -/\n@[reducible]\ninstance {α : Type*}: has_mem (set α) (filter_basis α) := ⟨λ U B, U ∈ B.sets⟩\n\n-- For illustration purposes, the filter basis defining (at_top : filter ℕ)\ninstance : inhabited (filter_basis ℕ) :=\n⟨{ sets := range Ici,\n  nonempty := ⟨Ici 0, mem_range_self 0⟩,\n  inter_sets := begin\n    rintros _ _ ⟨n, rfl⟩ ⟨m, rfl⟩,\n    refine ⟨Ici (max n m), mem_range_self _, _⟩,\n    rintros p p_in,\n    split ; rw mem_Ici at *,\n    exact le_of_max_le_left p_in,\n    exact le_of_max_le_right p_in,\n  end }⟩\n\n/-- View a filter as a filter basis. -/\ndef filter.as_basis (f : filter α) : filter_basis α :=\n⟨f.sets, ⟨univ, univ_mem⟩, λ x y hx hy, ⟨x ∩ y, inter_mem hx hy, subset_rfl⟩⟩\n\n/-- `is_basis p s` means the image of `s` bounded by `p` is a filter basis. -/\nprotected structure filter.is_basis (p : ι → Prop) (s : ι → set α) : Prop :=\n(nonempty : ∃ i, p i)\n(inter : ∀ {i j}, p i → p j → ∃ k, p k ∧ s k ⊆ s i ∩ s j)\n\nnamespace filter\nnamespace is_basis\n\n/-- Constructs a filter basis from an indexed family of sets satisfying `is_basis`. -/\nprotected def filter_basis {p : ι → Prop} {s : ι → set α} (h : is_basis p s) : filter_basis α :=\n{ sets := {t | ∃ i, p i ∧ s i = t},\n  nonempty := let ⟨i, hi⟩ := h.nonempty in ⟨s i, ⟨i, hi, rfl⟩⟩,\n  inter_sets := by { rintros _ _ ⟨i, hi, rfl⟩ ⟨j, hj, rfl⟩,\n                     rcases h.inter hi hj with ⟨k, hk, hk'⟩,\n                     exact ⟨_, ⟨k, hk, rfl⟩, hk'⟩ } }\n\nvariables {p : ι → Prop} {s : ι → set α} (h : is_basis p s)\n\nlemma mem_filter_basis_iff {U : set α} : U ∈ h.filter_basis ↔ ∃ i, p i ∧ s i = U :=\niff.rfl\nend is_basis\nend filter\n\nnamespace filter_basis\n\n/-- The filter associated to a filter basis. -/\nprotected def filter (B : filter_basis α) : filter α :=\n{ sets := {s | ∃ t ∈ B, t ⊆ s},\n  univ_sets := let ⟨s, s_in⟩ := B.nonempty in ⟨s, s_in, s.subset_univ⟩,\n  sets_of_superset := λ x y ⟨s, s_in, h⟩ hxy, ⟨s, s_in, set.subset.trans h hxy⟩,\n  inter_sets := λ x y ⟨s, s_in, hs⟩ ⟨t, t_in, ht⟩,\n                let ⟨u, u_in, u_sub⟩ := B.inter_sets s_in t_in in\n                ⟨u, u_in, set.subset.trans u_sub $ set.inter_subset_inter hs ht⟩ }\n\nlemma mem_filter_iff (B : filter_basis α) {U : set α} : U ∈ B.filter ↔ ∃ s ∈ B, s ⊆ U :=\niff.rfl\n\nlemma mem_filter_of_mem (B : filter_basis α) {U : set α} : U ∈ B → U ∈ B.filter:=\nλ U_in, ⟨U, U_in, subset.refl _⟩\n\nlemma eq_infi_principal (B : filter_basis α) : B.filter = ⨅ s : B.sets, 𝓟 s :=\nbegin\n  have : directed (≥) (λ (s : B.sets), 𝓟 (s : set α)),\n  { rintros ⟨U, U_in⟩ ⟨V, V_in⟩,\n    rcases B.inter_sets U_in V_in with ⟨W, W_in, W_sub⟩,\n    use [W, W_in],\n    simp only [ge_iff_le, le_principal_iff, mem_principal, subtype.coe_mk],\n    exact subset_inter_iff.mp W_sub },\n  ext U,\n  simp [mem_filter_iff, mem_infi_of_directed this]\nend\n\nprotected lemma generate (B : filter_basis α) : generate B.sets = B.filter :=\nbegin\n  apply le_antisymm,\n  { intros U U_in,\n    rcases B.mem_filter_iff.mp U_in with ⟨V, V_in, h⟩,\n    exact generate_sets.superset (generate_sets.basic V_in) h },\n  { rw sets_iff_generate,\n    apply mem_filter_of_mem }\nend\nend filter_basis\n\nnamespace filter\nnamespace is_basis\nvariables {p : ι → Prop} {s : ι → set α}\n\n/-- Constructs a filter from an indexed family of sets satisfying `is_basis`. -/\nprotected def filter (h : is_basis p s) : filter α := h.filter_basis.filter\n\nprotected lemma mem_filter_iff (h : is_basis p s) {U : set α} :\n  U ∈ h.filter ↔ ∃ i, p i ∧ s i ⊆ U :=\nbegin\n  erw [h.filter_basis.mem_filter_iff],\n  simp only [mem_filter_basis_iff h, exists_prop],\n  split,\n  { rintros ⟨_, ⟨i, pi, rfl⟩, h⟩,\n    tauto },\n  { tauto }\nend\n\nlemma filter_eq_generate (h : is_basis p s) : h.filter = generate {U | ∃ i, p i ∧ s i = U} :=\nby erw h.filter_basis.generate ; refl\nend is_basis\n\n/-- We say that a filter `l` has a basis `s : ι → set α` bounded by `p : ι → Prop`,\nif `t ∈ l` if and only if `t` includes `s i` for some `i` such that `p i`. -/\nprotected structure has_basis (l : filter α) (p : ι → Prop) (s : ι → set α) : Prop :=\n(mem_iff' : ∀ (t : set α), t ∈ l ↔ ∃ i (hi : p i), s i ⊆ t)\n\nsection same_type\n\nvariables {l l' : filter α} {p : ι → Prop} {s : ι → set α} {t : set α} {i : ι}\n  {p' : ι' → Prop} {s' : ι' → set α} {i' : ι'}\n\nlemma has_basis_generate (s : set (set α)) :\n  (generate s).has_basis (λ t, set.finite t ∧ t ⊆ s) (λ t, ⋂₀ t) :=\n⟨λ U, by simp only [mem_generate_iff, exists_prop, and.assoc, and.left_comm]⟩\n\n/-- The smallest filter basis containing a given collection of sets. -/\ndef filter_basis.of_sets (s : set (set α)) : filter_basis α :=\n{ sets := sInter '' { t | set.finite t ∧ t ⊆ s},\n  nonempty := ⟨univ, ∅, ⟨⟨finite_empty, empty_subset s⟩, sInter_empty⟩⟩,\n  inter_sets := begin\n    rintros _ _ ⟨a, ⟨fina, suba⟩, rfl⟩ ⟨b, ⟨finb, subb⟩, rfl⟩,\n    exact ⟨⋂₀ (a ∪ b), mem_image_of_mem _ ⟨fina.union finb, union_subset suba subb⟩,\n           by rw sInter_union⟩,\n  end }\n\n/-- Definition of `has_basis` unfolded with implicit set argument. -/\nlemma has_basis.mem_iff (hl : l.has_basis p s) : t ∈ l ↔ ∃ i (hi : p i), s i ⊆ t :=\nhl.mem_iff' t\n\nlemma has_basis.eq_of_same_basis (hl : l.has_basis p s) (hl' : l'.has_basis p s) : l = l' :=\nbegin\n  ext t,\n  rw [hl.mem_iff, hl'.mem_iff]\nend\n\nlemma has_basis_iff : l.has_basis p s ↔ ∀ t, t ∈ l ↔ ∃ i (hi : p i), s i ⊆ t :=\n⟨λ ⟨h⟩, h, λ h, ⟨h⟩⟩\n\nlemma has_basis.ex_mem (h : l.has_basis p s) : ∃ i, p i :=\nlet ⟨i, pi, h⟩ := h.mem_iff.mp univ_mem in ⟨i, pi⟩\n\nprotected lemma has_basis.nonempty (h : l.has_basis p s) : nonempty ι :=\nnonempty_of_exists h.ex_mem\n\nprotected lemma is_basis.has_basis (h : is_basis p s) : has_basis h.filter p s :=\n⟨λ t, by simp only [h.mem_filter_iff, exists_prop]⟩\n\nlemma has_basis.mem_of_superset (hl : l.has_basis p s) (hi : p i) (ht : s i ⊆ t) : t ∈ l :=\n(hl.mem_iff).2 ⟨i, hi, ht⟩\n\nlemma has_basis.mem_of_mem (hl : l.has_basis p s) (hi : p i) : s i ∈ l :=\nhl.mem_of_superset hi $ subset.refl _\n\n/-- Index of a basis set such that `s i ⊆ t` as an element of `subtype p`. -/\nnoncomputable def has_basis.index (h : l.has_basis p s) (t : set α) (ht : t ∈ l) :\n  {i : ι // p i} :=\n⟨(h.mem_iff.1 ht).some, (h.mem_iff.1 ht).some_spec.fst⟩\n\nlemma has_basis.property_index (h : l.has_basis p s) (ht : t ∈ l) : p (h.index t ht) :=\n(h.index t ht).2\n\nlemma has_basis.set_index_mem (h : l.has_basis p s) (ht : t ∈ l) : s (h.index t ht) ∈ l :=\nh.mem_of_mem $ h.property_index _\n\nlemma has_basis.set_index_subset (h : l.has_basis p s) (ht : t ∈ l) : s (h.index t ht) ⊆ t :=\n(h.mem_iff.1 ht).some_spec.snd\n\nlemma has_basis.is_basis (h : l.has_basis p s) : is_basis p s :=\n{ nonempty := let ⟨i, hi, H⟩ := h.mem_iff.mp univ_mem in ⟨i, hi⟩,\n  inter := λ i j hi hj, by simpa [h.mem_iff]\n    using l.inter_sets (h.mem_of_mem hi) (h.mem_of_mem hj) }\n\nlemma has_basis.filter_eq (h : l.has_basis p s) : h.is_basis.filter = l :=\nby { ext U, simp [h.mem_iff, is_basis.mem_filter_iff] }\n\nlemma has_basis.eq_generate (h : l.has_basis p s) : l = generate { U | ∃ i, p i ∧ s i = U } :=\nby rw [← h.is_basis.filter_eq_generate, h.filter_eq]\n\nlemma generate_eq_generate_inter (s : set (set α)) :\n  generate s = generate (sInter '' { t | set.finite t ∧ t ⊆ s}) :=\nby erw [(filter_basis.of_sets s).generate, ← (has_basis_generate s).filter_eq] ; refl\n\nlemma of_sets_filter_eq_generate (s : set (set α)) : (filter_basis.of_sets s).filter = generate s :=\nby rw [← (filter_basis.of_sets s).generate, generate_eq_generate_inter s] ; refl\n\nprotected lemma _root_.filter_basis.has_basis {α : Type*} (B : filter_basis α) :\n  has_basis (B.filter) (λ s : set α, s ∈ B) id :=\n⟨λ t, B.mem_filter_iff⟩\n\nlemma has_basis.to_has_basis' (hl : l.has_basis p s) (h : ∀ i, p i → ∃ i', p' i' ∧ s' i' ⊆ s i)\n  (h' : ∀ i', p' i' → s' i' ∈ l) : l.has_basis p' s' :=\nbegin\n  refine ⟨λ t, ⟨λ ht, _, λ ⟨i', hi', ht⟩, mem_of_superset (h' i' hi') ht⟩⟩,\n  rcases hl.mem_iff.1 ht with ⟨i, hi, ht⟩,\n  rcases h i hi with ⟨i', hi', hs's⟩,\n  exact ⟨i', hi', subset.trans hs's ht⟩\nend\n\nlemma has_basis.to_has_basis (hl : l.has_basis p s) (h : ∀ i, p i → ∃ i', p' i' ∧ s' i' ⊆ s i)\n  (h' : ∀ i', p' i' → ∃ i, p i ∧ s i ⊆ s' i') : l.has_basis p' s' :=\nhl.to_has_basis' h $ λ i' hi', let ⟨i, hi, hss'⟩ := h' i' hi' in hl.mem_iff.2 ⟨i, hi, hss'⟩\n\nlemma has_basis.to_subset (hl : l.has_basis p s) {t : ι → set α} (h : ∀ i, p i → t i ⊆ s i)\n  (ht : ∀ i, p i → t i ∈ l) : l.has_basis p t :=\nhl.to_has_basis' (λ i hi, ⟨i, hi, h i hi⟩) ht\n\nlemma has_basis.eventually_iff (hl : l.has_basis p s) {q : α → Prop} :\n  (∀ᶠ x in l, q x) ↔ ∃ i, p i ∧ ∀ ⦃x⦄, x ∈ s i → q x :=\nby simpa using hl.mem_iff\n\nlemma has_basis.frequently_iff (hl : l.has_basis p s) {q : α → Prop} :\n  (∃ᶠ x in l, q x) ↔ ∀ i, p i → ∃ x ∈ s i, q x :=\nby simp [filter.frequently, hl.eventually_iff]\n\nlemma has_basis.exists_iff (hl : l.has_basis p s) {P : set α → Prop}\n  (mono : ∀ ⦃s t⦄, s ⊆ t → P t → P s) :\n  (∃ s ∈ l, P s) ↔ ∃ (i) (hi : p i), P (s i) :=\n⟨λ ⟨s, hs, hP⟩, let ⟨i, hi, his⟩ := hl.mem_iff.1 hs in ⟨i, hi, mono his hP⟩,\n  λ ⟨i, hi, hP⟩, ⟨s i, hl.mem_of_mem hi, hP⟩⟩\n\nlemma has_basis.forall_iff (hl : l.has_basis p s) {P : set α → Prop}\n  (mono : ∀ ⦃s t⦄, s ⊆ t → P s → P t) :\n  (∀ s ∈ l, P s) ↔ ∀ i, p i → P (s i) :=\n⟨λ H i hi, H (s i) $ hl.mem_of_mem hi,\n  λ H s hs, let ⟨i, hi, his⟩ := hl.mem_iff.1 hs in mono his (H i hi)⟩\n\nlemma has_basis.ne_bot_iff (hl : l.has_basis p s) :\n  ne_bot l ↔ (∀ {i}, p i → (s i).nonempty) :=\nforall_mem_nonempty_iff_ne_bot.symm.trans $ hl.forall_iff $ λ _ _, nonempty.mono\n\nlemma has_basis.eq_bot_iff (hl : l.has_basis p s) :\n  l = ⊥ ↔ ∃ i, p i ∧ s i = ∅ :=\nnot_iff_not.1 $ ne_bot_iff.symm.trans $ hl.ne_bot_iff.trans $\nby simp only [not_exists, not_and, nonempty_iff_ne_empty]\n\nlemma generate_ne_bot_iff {s : set (set α)} :\n  ne_bot (generate s) ↔ ∀ t ⊆ s, t.finite → (⋂₀ t).nonempty :=\n(has_basis_generate s).ne_bot_iff.trans $ by simp only [← and_imp, and_comm]\n\nlemma basis_sets (l : filter α) : l.has_basis (λ s : set α, s ∈ l) id :=\n⟨λ t, exists_mem_subset_iff.symm⟩\n\nlemma as_basis_filter (f : filter α) : f.as_basis.filter = f :=\nby ext t; exact exists_mem_subset_iff\n\nlemma has_basis_self {l : filter α} {P : set α → Prop} :\n  has_basis l (λ s, s ∈ l ∧ P s) id ↔ ∀ t ∈ l, ∃ r ∈ l, P r ∧ r ⊆ t :=\nbegin\n  simp only [has_basis_iff, exists_prop, id, and_assoc],\n  exact forall_congr (λ s, ⟨λ h, h.1, λ h, ⟨h, λ ⟨t, hl, hP, hts⟩, mem_of_superset hl hts⟩⟩)\nend\n\nlemma has_basis.comp_surjective (h : l.has_basis p s) {g : ι' → ι} (hg : function.surjective g) :\n  l.has_basis (p ∘ g) (s ∘ g) :=\n⟨λ t, h.mem_iff.trans hg.exists⟩\n\nlemma has_basis.comp_equiv (h : l.has_basis p s) (e : ι' ≃ ι) : l.has_basis (p ∘ e) (s ∘ e) :=\nh.comp_surjective e.surjective\n\n/-- If `{s i | p i}` is a basis of a filter `l` and each `s i` includes `s j` such that\n`p j ∧ q j`, then `{s j | p j ∧ q j}` is a basis of `l`. -/\nlemma has_basis.restrict (h : l.has_basis p s) {q : ι → Prop}\n  (hq : ∀ i, p i → ∃ j, p j ∧ q j ∧ s j ⊆ s i) :\n  l.has_basis (λ i, p i ∧ q i) s :=\nbegin\n  refine ⟨λ t, ⟨λ ht, _, λ ⟨i, hpi, hti⟩, h.mem_iff.2 ⟨i, hpi.1, hti⟩⟩⟩,\n  rcases h.mem_iff.1 ht with ⟨i, hpi, hti⟩,\n  rcases hq i hpi with ⟨j, hpj, hqj, hji⟩,\n  exact ⟨j, ⟨hpj, hqj⟩, subset.trans hji hti⟩\nend\n\n/-- If `{s i | p i}` is a basis of a filter `l` and `V ∈ l`, then `{s i | p i ∧ s i ⊆ V}`\nis a basis of `l`. -/\nlemma has_basis.restrict_subset (h : l.has_basis p s) {V : set α} (hV : V ∈ l) :\n  l.has_basis (λ i, p i ∧ s i ⊆ V) s :=\nh.restrict $ λ i hi, (h.mem_iff.1 (inter_mem hV (h.mem_of_mem hi))).imp $\n  λ j hj, ⟨hj.fst, subset_inter_iff.1 hj.snd⟩\n\nlemma has_basis.has_basis_self_subset {p : set α → Prop} (h : l.has_basis (λ s, s ∈ l ∧ p s) id)\n  {V : set α} (hV : V ∈ l) : l.has_basis (λ s, s ∈ l ∧ p s ∧ s ⊆ V) id :=\nby simpa only [and_assoc] using h.restrict_subset hV\n\ntheorem has_basis.ge_iff (hl' : l'.has_basis p' s')  : l ≤ l' ↔ ∀ i', p' i' → s' i' ∈ l :=\n⟨λ h i' hi', h $ hl'.mem_of_mem hi',\n  λ h s hs, let ⟨i', hi', hs⟩ := hl'.mem_iff.1 hs in mem_of_superset (h _ hi') hs⟩\n\ntheorem has_basis.le_iff (hl : l.has_basis p s) : l ≤ l' ↔ ∀ t ∈ l', ∃ i (hi : p i), s i ⊆ t :=\nby simp only [le_def, hl.mem_iff]\n\ntheorem has_basis.le_basis_iff (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  l ≤ l' ↔ ∀ i', p' i' → ∃ i (hi : p i), s i ⊆ s' i' :=\nby simp only [hl'.ge_iff, hl.mem_iff]\n\nlemma has_basis.ext (hl : l.has_basis p s) (hl' : l'.has_basis p' s')\n  (h : ∀ i, p i → ∃ i', p' i' ∧ s' i' ⊆ s i)\n  (h' : ∀ i', p' i' → ∃ i, p i ∧ s i ⊆ s' i') : l = l' :=\nbegin\n  apply le_antisymm,\n  { rw hl.le_basis_iff hl',\n    simpa using h' },\n  { rw hl'.le_basis_iff hl,\n    simpa using h },\nend\n\nlemma has_basis.inf' (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  (l ⊓ l').has_basis (λ i : pprod ι ι', p i.1 ∧ p' i.2) (λ i, s i.1 ∩ s' i.2) :=\n⟨begin\n  intro t,\n  split,\n  { simp only [mem_inf_iff, exists_prop, hl.mem_iff, hl'.mem_iff],\n    rintros ⟨t, ⟨i, hi, ht⟩, t', ⟨i', hi', ht'⟩, rfl⟩,\n    use [⟨i, i'⟩, ⟨hi, hi'⟩, inter_subset_inter ht ht'] },\n  { rintros ⟨⟨i, i'⟩, ⟨hi, hi'⟩, H⟩,\n    exact mem_inf_of_inter (hl.mem_of_mem hi) (hl'.mem_of_mem hi') H }\nend⟩\n\nlemma has_basis.inf {ι ι' : Type*} {p : ι → Prop} {s : ι → set α} {p' : ι' → Prop}\n  {s' : ι' → set α} (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  (l ⊓ l').has_basis (λ i : ι × ι', p i.1 ∧ p' i.2) (λ i, s i.1 ∩ s' i.2) :=\n(hl.inf' hl').to_has_basis (λ i hi, ⟨⟨i.1, i.2⟩, hi, subset.rfl⟩)\n  (λ i hi, ⟨⟨i.1, i.2⟩, hi, subset.rfl⟩)\n\nlemma has_basis_infi' {ι : Type*} {ι' : ι → Type*} {l : ι → filter α}\n  {p : Π i, ι' i → Prop} {s : Π i, ι' i → set α} (hl : ∀ i, (l i).has_basis (p i) (s i)) :\n  (⨅ i, l i).has_basis (λ If : set ι × Π i, ι' i, If.1.finite ∧ ∀ i ∈ If.1, p i (If.2 i))\n    (λ If : set ι × Π i, ι' i, ⋂ i ∈ If.1, s i (If.2 i)) :=\n⟨begin\n  intro t,\n  split,\n  { simp only [mem_infi', (hl _).mem_iff],\n    rintros ⟨I, hI, V, hV, -, rfl, -⟩,\n    choose u hu using hV,\n    exact ⟨⟨I, u⟩, ⟨hI, λ i _, (hu i).1⟩, Inter_mono (λ i, Inter_mono $ λ hi, (hu i).2)⟩ },\n  { rintros ⟨⟨I, f⟩, ⟨hI₁, hI₂⟩, hsub⟩,\n    refine mem_of_superset _ hsub,\n    exact (bInter_mem hI₁).mpr (λ i hi, mem_infi_of_mem i $ (hl i).mem_of_mem $ hI₂ _ hi) }\nend⟩\n\nlemma has_basis_infi {ι : Type*} {ι' : ι → Type*} {l : ι → filter α}\n  {p : Π i, ι' i → Prop} {s : Π i, ι' i → set α} (hl : ∀ i, (l i).has_basis (p i) (s i)) :\n  (⨅ i, l i).has_basis (λ If : Σ I : set ι, Π i : I, ι' i, If.1.finite ∧ ∀ i : If.1, p i (If.2 i))\n    (λ If, ⋂ i : If.1, s i (If.2 i)) :=\nbegin\n  refine ⟨λ t, ⟨λ ht, _, _⟩⟩,\n  { rcases (has_basis_infi' hl).mem_iff.mp ht with ⟨⟨I, f⟩, ⟨hI, hf⟩, hsub⟩,\n    exact ⟨⟨I, λ i, f i⟩, ⟨hI, subtype.forall.mpr hf⟩,\n      trans_rel_right _ (Inter_subtype _ _) hsub⟩ },\n  { rintro ⟨⟨I, f⟩, ⟨hI, hf⟩, hsub⟩,\n    refine mem_of_superset _ hsub,\n    casesI hI.nonempty_fintype,\n    exact Inter_mem.2 (λ i, mem_infi_of_mem i $ (hl i).mem_of_mem $ hf _) }\nend\n\nlemma has_basis_infi_of_directed' {ι : Type*} {ι' : ι → Sort*}\n  [nonempty ι]\n  {l : ι → filter α} (s : Π i, (ι' i) → set α) (p : Π i, (ι' i) → Prop)\n  (hl : ∀ i, (l i).has_basis (p i) (s i)) (h : directed (≥) l) :\n  (⨅ i, l i).has_basis (λ (ii' : Σ i, ι' i), p ii'.1 ii'.2) (λ ii', s ii'.1 ii'.2) :=\nbegin\n  refine ⟨λ t, _⟩,\n  rw [mem_infi_of_directed h, sigma.exists],\n  exact exists_congr (λ i, (hl i).mem_iff)\nend\n\nlemma has_basis_infi_of_directed {ι : Type*} {ι' : Sort*}\n  [nonempty ι]\n  {l : ι → filter α} (s : ι → ι' → set α) (p : ι → ι' → Prop)\n  (hl : ∀ i, (l i).has_basis (p i) (s i)) (h : directed (≥) l) :\n  (⨅ i, l i).has_basis (λ (ii' : ι × ι'), p ii'.1 ii'.2) (λ ii', s ii'.1 ii'.2) :=\nbegin\n  refine ⟨λ t, _⟩,\n  rw [mem_infi_of_directed h, prod.exists],\n  exact exists_congr (λ i, (hl i).mem_iff)\nend\n\nlemma has_basis_binfi_of_directed' {ι : Type*} {ι' : ι → Sort*}\n  {dom : set ι} (hdom : dom.nonempty)\n  {l : ι → filter α} (s : Π i, (ι' i) → set α) (p : Π i, (ι' i) → Prop)\n  (hl : ∀ i ∈ dom, (l i).has_basis (p i) (s i)) (h : directed_on (l ⁻¹'o ge) dom) :\n  (⨅ i ∈ dom, l i).has_basis (λ (ii' : Σ i, ι' i), ii'.1 ∈ dom ∧ p ii'.1 ii'.2)\n    (λ ii', s ii'.1 ii'.2) :=\nbegin\n  refine ⟨λ t, _⟩,\n  rw [mem_binfi_of_directed h hdom, sigma.exists],\n  refine exists_congr (λ i, ⟨_, _⟩),\n  { rintros ⟨hi, hti⟩,\n    rcases (hl i hi).mem_iff.mp hti with ⟨b, hb, hbt⟩,\n    exact ⟨b, ⟨hi, hb⟩, hbt⟩ },\n  { rintros ⟨b, ⟨hi, hb⟩, hibt⟩,\n    exact ⟨hi, (hl i hi).mem_iff.mpr ⟨b, hb, hibt⟩⟩ }\nend\n\nlemma has_basis_binfi_of_directed {ι : Type*} {ι' : Sort*}\n  {dom : set ι} (hdom : dom.nonempty)\n  {l : ι → filter α} (s : ι → ι' → set α) (p : ι → ι' → Prop)\n  (hl : ∀ i ∈ dom, (l i).has_basis (p i) (s i)) (h : directed_on (l ⁻¹'o ge) dom) :\n  (⨅ i ∈ dom, l i).has_basis (λ (ii' : ι × ι'), ii'.1 ∈ dom ∧ p ii'.1 ii'.2)\n    (λ ii', s ii'.1 ii'.2) :=\nbegin\n  refine ⟨λ t, _⟩,\n  rw [mem_binfi_of_directed h hdom, prod.exists],\n  refine exists_congr (λ i, ⟨_, _⟩),\n  { rintros ⟨hi, hti⟩,\n    rcases (hl i hi).mem_iff.mp hti with ⟨b, hb, hbt⟩,\n    exact ⟨b, ⟨hi, hb⟩, hbt⟩ },\n  { rintros ⟨b, ⟨hi, hb⟩, hibt⟩,\n    exact ⟨hi, (hl i hi).mem_iff.mpr ⟨b, hb, hibt⟩⟩ }\nend\n\nlemma has_basis_principal (t : set α) : (𝓟 t).has_basis (λ i : unit, true) (λ i, t) :=\n⟨λ U, by simp⟩\n\nlemma has_basis_pure (x : α) : (pure x : filter α).has_basis (λ i : unit, true) (λ i, {x}) :=\nby simp only [← principal_singleton, has_basis_principal]\n\nlemma has_basis.sup' (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  (l ⊔ l').has_basis (λ i : pprod ι ι', p i.1 ∧ p' i.2) (λ i, s i.1 ∪ s' i.2) :=\n⟨begin\n  intros t,\n  simp only [mem_sup, hl.mem_iff, hl'.mem_iff, pprod.exists, union_subset_iff, exists_prop,\n    and_assoc, exists_and_distrib_left],\n  simp only [← and_assoc, exists_and_distrib_right, and_comm]\nend⟩\n\nlemma has_basis.sup {ι ι' : Type*} {p : ι → Prop} {s : ι → set α} {p' : ι' → Prop}\n  {s' : ι' → set α} (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  (l ⊔ l').has_basis (λ i : ι × ι', p i.1 ∧ p' i.2) (λ i, s i.1 ∪ s' i.2) :=\n(hl.sup' hl').to_has_basis (λ i hi, ⟨⟨i.1, i.2⟩, hi, subset.rfl⟩)\n  (λ i hi, ⟨⟨i.1, i.2⟩, hi, subset.rfl⟩)\n\nlemma has_basis_supr {ι : Sort*} {ι' : ι → Type*} {l : ι → filter α}\n  {p : Π i, ι' i → Prop} {s : Π i, ι' i → set α} (hl : ∀ i, (l i).has_basis (p i) (s i)) :\n  (⨆ i, l i).has_basis (λ f : Π i, ι' i, ∀ i, p i (f i)) (λ f : Π i, ι' i, ⋃ i, s i (f i)) :=\nhas_basis_iff.mpr $ λ t, by simp only [has_basis_iff, (hl _).mem_iff, classical.skolem,\n  forall_and_distrib, Union_subset_iff, mem_supr]\n\nlemma has_basis.sup_principal (hl : l.has_basis p s) (t : set α) :\n  (l ⊔ 𝓟 t).has_basis p (λ i, s i ∪ t) :=\n⟨λ u, by simp only [(hl.sup' (has_basis_principal t)).mem_iff, pprod.exists, exists_prop, and_true,\n  unique.exists_iff]⟩\n\nlemma has_basis.sup_pure (hl : l.has_basis p s) (x : α) :\n  (l ⊔ pure x).has_basis p (λ i, s i ∪ {x}) :=\nby simp only [← principal_singleton, hl.sup_principal]\n\nlemma has_basis.inf_principal (hl : l.has_basis p s) (s' : set α) :\n  (l ⊓ 𝓟 s').has_basis p (λ i, s i ∩ s') :=\n⟨λ t, by simp only [mem_inf_principal, hl.mem_iff, subset_def, mem_set_of_eq,\n  mem_inter_iff, and_imp]⟩\n\nlemma has_basis.principal_inf (hl : l.has_basis p s) (s' : set α) :\n  (𝓟 s' ⊓ l).has_basis p (λ i, s' ∩ s i) :=\nby simpa only [inf_comm, inter_comm] using hl.inf_principal s'\n\nlemma has_basis.inf_basis_ne_bot_iff (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  ne_bot (l ⊓ l') ↔ ∀ ⦃i⦄ (hi : p i) ⦃i'⦄ (hi' : p' i'), (s i ∩ s' i').nonempty :=\n(hl.inf' hl').ne_bot_iff.trans $ by simp [@forall_swap _ ι']\n\nlemma has_basis.inf_ne_bot_iff (hl : l.has_basis p s) :\n  ne_bot (l ⊓ l') ↔ ∀ ⦃i⦄ (hi : p i) ⦃s'⦄ (hs' : s' ∈ l'), (s i ∩ s').nonempty :=\nhl.inf_basis_ne_bot_iff l'.basis_sets\n\nlemma has_basis.inf_principal_ne_bot_iff (hl : l.has_basis p s) {t : set α} :\n  ne_bot (l ⊓ 𝓟 t) ↔ ∀ ⦃i⦄ (hi : p i), (s i ∩ t).nonempty :=\n(hl.inf_principal t).ne_bot_iff\n\nlemma has_basis.disjoint_iff (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  disjoint l l' ↔ ∃ i (hi : p i) i' (hi' : p' i'), disjoint (s i) (s' i') :=\nnot_iff_not.mp $ by simp only [disjoint_iff, ← ne.def, ← ne_bot_iff, hl.inf_basis_ne_bot_iff hl',\n  not_exists, bot_eq_empty, ←nonempty_iff_ne_empty, inf_eq_inter]\n\nlemma _root_.disjoint.exists_mem_filter_basis (h : disjoint l l') (hl : l.has_basis p s)\n  (hl' : l'.has_basis p' s') :\n  ∃ i (hi : p i) i' (hi' : p' i'), disjoint (s i) (s' i') :=\n(hl.disjoint_iff hl').1 h\n\nlemma _root_.pairwise.exists_mem_filter_basis_of_disjoint {I : Type*} [finite I]\n  {l : I → filter α} {ι : I → Sort*} {p : Π i, ι i → Prop} {s : Π i, ι i → set α}\n  (hd : pairwise (disjoint on l)) (h : ∀ i, (l i).has_basis (p i) (s i)) :\n  ∃ ind : Π i, ι i, (∀ i, p i (ind i)) ∧ pairwise (disjoint on λ i, s i (ind i)) :=\nbegin\n  rcases hd.exists_mem_filter_of_disjoint with ⟨t, htl, hd⟩,\n  choose ind hp ht using λ i, (h i).mem_iff.1 (htl i),\n  exact ⟨ind, hp, hd.mono $ λ i j hij, hij.mono (ht _) (ht _)⟩\nend\n\nlemma _root_.set.pairwise_disjoint.exists_mem_filter_basis {I : Type*} {l : I → filter α}\n  {ι : I → Sort*} {p : Π i, ι i → Prop} {s : Π i, ι i → set α} {S : set I}\n  (hd : S.pairwise_disjoint l) (hS : S.finite) (h : ∀ i, (l i).has_basis (p i) (s i)) :\n  ∃ ind : Π i, ι i, (∀ i, p i (ind i)) ∧ S.pairwise_disjoint (λ i, s i (ind i)) :=\nbegin\n  rcases hd.exists_mem_filter hS with ⟨t, htl, hd⟩,\n  choose ind hp ht using λ i, (h i).mem_iff.1 (htl i),\n  exact ⟨ind, hp, hd.mono ht⟩\nend\n\nlemma inf_ne_bot_iff :\n  ne_bot (l ⊓ l') ↔ ∀ ⦃s : set α⦄ (hs : s ∈ l) ⦃s'⦄ (hs' : s' ∈ l'), (s ∩ s').nonempty :=\nl.basis_sets.inf_ne_bot_iff\n\nlemma inf_principal_ne_bot_iff {s : set α} :\n  ne_bot (l ⊓ 𝓟 s) ↔ ∀ U ∈ l, (U ∩ s).nonempty :=\nl.basis_sets.inf_principal_ne_bot_iff\n\nlemma mem_iff_inf_principal_compl {f : filter α} {s : set α} :\n  s ∈ f ↔ f ⊓ 𝓟 sᶜ = ⊥ :=\nbegin\n  refine not_iff_not.1 ((inf_principal_ne_bot_iff.trans _).symm.trans ne_bot_iff),\n  exact ⟨λ h hs, by simpa [not_nonempty_empty] using h s hs,\n    λ hs t ht, inter_compl_nonempty_iff.2 $ λ hts, hs $ mem_of_superset ht hts⟩,\nend\n\nlemma not_mem_iff_inf_principal_compl {f : filter α} {s : set α} :\n  s ∉ f ↔ ne_bot (f ⊓ 𝓟 sᶜ) :=\n(not_congr mem_iff_inf_principal_compl).trans ne_bot_iff.symm\n\n@[simp] lemma disjoint_principal_right {f : filter α} {s : set α} :\n  disjoint f (𝓟 s) ↔ sᶜ ∈ f :=\nby rw [mem_iff_inf_principal_compl, compl_compl, disjoint_iff]\n\n@[simp] lemma disjoint_principal_left {f : filter α} {s : set α} :\n  disjoint (𝓟 s) f ↔ sᶜ ∈ f :=\nby rw [disjoint.comm, disjoint_principal_right]\n\n@[simp] lemma disjoint_principal_principal {s t : set α} :\n  disjoint (𝓟 s) (𝓟 t) ↔ disjoint s t :=\nby simp [←subset_compl_iff_disjoint_left]\n\nalias disjoint_principal_principal ↔ _ _root_.disjoint.filter_principal\n\n@[simp] lemma disjoint_pure_pure {x y : α} :\n  disjoint (pure x : filter α) (pure y) ↔ x ≠ y :=\nby simp only [← principal_singleton, disjoint_principal_principal, disjoint_singleton]\n\n@[simp] lemma compl_diagonal_mem_prod {l₁ l₂ : filter α} :\n  (diagonal α)ᶜ ∈ l₁ ×ᶠ l₂ ↔ disjoint l₁ l₂ :=\nby simp only [mem_prod_iff, filter.disjoint_iff, prod_subset_compl_diagonal_iff_disjoint]\n\nlemma has_basis.disjoint_iff_left (h : l.has_basis p s) :\n  disjoint l l' ↔ ∃ i (hi : p i), (s i)ᶜ ∈ l' :=\nby simp only [h.disjoint_iff l'.basis_sets, exists_prop, id, ← disjoint_principal_left,\n  (has_basis_principal _).disjoint_iff l'.basis_sets, unique.exists_iff]\n\nlemma has_basis.disjoint_iff_right (h : l.has_basis p s) :\n  disjoint l' l ↔ ∃ i (hi : p i), (s i)ᶜ ∈ l' :=\ndisjoint.comm.trans h.disjoint_iff_left\n\nlemma le_iff_forall_inf_principal_compl {f g : filter α} :\n  f ≤ g ↔ ∀ V ∈ g, f ⊓ 𝓟 Vᶜ = ⊥ :=\nforall₂_congr $ λ _ _, mem_iff_inf_principal_compl\n\nlemma inf_ne_bot_iff_frequently_left {f g : filter α} :\n  ne_bot (f ⊓ g) ↔ ∀ {p : α → Prop}, (∀ᶠ x in f, p x) → ∃ᶠ x in g, p x :=\nby simpa only [inf_ne_bot_iff, frequently_iff, exists_prop, and_comm]\n\nlemma inf_ne_bot_iff_frequently_right {f g : filter α} :\n  ne_bot (f ⊓ g) ↔ ∀ {p : α → Prop}, (∀ᶠ x in g, p x) → ∃ᶠ x in f, p x :=\nby { rw inf_comm, exact inf_ne_bot_iff_frequently_left }\n\nlemma has_basis.eq_binfi (h : l.has_basis p s) :\n  l = ⨅ i (_ : p i), 𝓟 (s i) :=\neq_binfi_of_mem_iff_exists_mem $ λ t, by simp only [h.mem_iff, mem_principal]\n\nlemma has_basis.eq_infi (h : l.has_basis (λ _, true) s) :\n  l = ⨅ i, 𝓟 (s i) :=\nby simpa only [infi_true] using h.eq_binfi\n\nlemma has_basis_infi_principal {s : ι → set α} (h : directed (≥) s) [nonempty ι] :\n  (⨅ i, 𝓟 (s i)).has_basis (λ _, true) s :=\n⟨begin\n  refine λ t, (mem_infi_of_directed (h.mono_comp _ _) t).trans $\n    by simp only [exists_prop, true_and, mem_principal],\n  exact λ _ _, principal_mono.2\nend⟩\n\n/-- If `s : ι → set α` is an indexed family of sets, then finite intersections of `s i` form a basis\nof `⨅ i, 𝓟 (s i)`.  -/\nlemma has_basis_infi_principal_finite {ι : Type*} (s : ι → set α) :\n  (⨅ i, 𝓟 (s i)).has_basis (λ t : set ι, t.finite) (λ t, ⋂ i ∈ t, s i) :=\nbegin\n  refine ⟨λ U, (mem_infi_finite _).trans _⟩,\n  simp only [infi_principal_finset, mem_Union, mem_principal, exists_prop,\n    exists_finite_iff_finset, finset.set_bInter_coe]\nend\n\nlemma has_basis_binfi_principal {s : β → set α} {S : set β} (h : directed_on (s ⁻¹'o (≥)) S)\n  (ne : S.nonempty) :\n  (⨅ i ∈ S, 𝓟 (s i)).has_basis (λ i, i ∈ S) s :=\n⟨begin\n  refine λ t, (mem_binfi_of_directed _ ne).trans $ by simp only [mem_principal],\n  rw [directed_on_iff_directed, ← directed_comp, (∘)] at h ⊢,\n  apply h.mono_comp _ _,\n  exact λ _ _, principal_mono.2\nend⟩\n\nlemma has_basis_binfi_principal' {ι : Type*} {p : ι → Prop} {s : ι → set α}\n  (h : ∀ i, p i → ∀ j, p j → ∃ k (h : p k), s k ⊆ s i ∧ s k ⊆ s j) (ne : ∃ i, p i) :\n  (⨅ i (h : p i), 𝓟 (s i)).has_basis p s :=\nfilter.has_basis_binfi_principal h ne\n\nlemma has_basis.map (f : α → β) (hl : l.has_basis p s) :\n  (l.map f).has_basis p (λ i, f '' (s i)) :=\n⟨λ t, by simp only [mem_map, image_subset_iff, hl.mem_iff, preimage]⟩\n\nlemma has_basis.comap (f : β → α) (hl : l.has_basis p s) :\n  (l.comap f).has_basis p (λ i, f ⁻¹' (s i)) :=\n⟨begin\n  intro t,\n  simp only [mem_comap, exists_prop, hl.mem_iff],\n  split,\n  { rintros ⟨t', ⟨i, hi, ht'⟩, H⟩,\n    exact ⟨i, hi, subset.trans (preimage_mono ht') H⟩ },\n  { rintros ⟨i, hi, H⟩,\n    exact ⟨s i, ⟨i, hi, subset.refl _⟩, H⟩ }\nend⟩\n\nlemma comap_has_basis (f : α → β) (l : filter β) :\n  has_basis (comap f l) (λ s : set β, s ∈ l) (λ s, f ⁻¹' s) :=\n⟨λ t, mem_comap⟩\n\n\n\nprotected lemma has_basis.binfi_mem [complete_lattice β] {f : set α → β} (h : has_basis l p s)\n  (hf : monotone f) :\n  (⨅ t ∈ l, f t) = ⨅ i (hi : p i), f (s i) :=\nle_antisymm (le_infi₂ $ λ i hi, infi₂_le (s i) (h.mem_of_mem hi)) $\n  le_infi₂ $ λ t ht, let ⟨i, hpi, hi⟩ := h.mem_iff.1 ht in infi₂_le_of_le i hpi (hf hi)\n\nprotected lemma has_basis.bInter_mem {f : set α → set β} (h : has_basis l p s) (hf : monotone f) :\n  (⋂ t ∈ l, f t) = ⋂ i (hi : p i), f (s i) :=\nh.binfi_mem hf\n\nlemma has_basis.sInter_sets (h : has_basis l p s) : ⋂₀ l.sets = ⋂ i (hi : p i), s i :=\nby { rw [sInter_eq_bInter], exact h.bInter_mem monotone_id }\n\nvariables {ι'' : Type*} [preorder ι''] (l) (s'' : ι'' → set α)\n\n/-- `is_antitone_basis s` means the image of `s` is a filter basis such that `s` is decreasing. -/\n@[protect_proj] structure is_antitone_basis extends is_basis (λ _, true) s'' : Prop :=\n(antitone : antitone s'')\n\n/-- We say that a filter `l` has an antitone basis `s : ι → set α`, if `t ∈ l` if and only if `t`\nincludes `s i` for some `i`, and `s` is decreasing. -/\n@[protect_proj] structure has_antitone_basis (l : filter α) (s : ι'' → set α)\n  extends has_basis l (λ _, true) s : Prop :=\n(antitone : antitone s)\n\nlemma has_antitone_basis.map {l : filter α} {s : ι'' → set α} {m : α → β}\n  (hf : has_antitone_basis l s) :\n  has_antitone_basis (map m l) (λ n, m '' s n) :=\n⟨has_basis.map _ hf.to_has_basis, λ i j hij, image_subset _ $ hf.2 hij⟩\n\nend same_type\n\nsection two_types\n\nvariables {la : filter α} {pa : ι → Prop} {sa : ι → set α}\n  {lb : filter β} {pb : ι' → Prop} {sb : ι' → set β} {f : α → β}\n\nlemma has_basis.tendsto_left_iff (hla : la.has_basis pa sa) :\n  tendsto f la lb ↔ ∀ t ∈ lb, ∃ i (hi : pa i), maps_to f (sa i) t :=\nby { simp only [tendsto, (hla.map f).le_iff, image_subset_iff], refl }\n\nlemma has_basis.tendsto_right_iff (hlb : lb.has_basis pb sb) :\n  tendsto f la lb ↔ ∀ i (hi : pb i), ∀ᶠ x in la, f x ∈ sb i :=\nby simpa only [tendsto, hlb.ge_iff, mem_map, filter.eventually]\n\nlemma has_basis.tendsto_iff (hla : la.has_basis pa sa) (hlb : lb.has_basis pb sb) :\n  tendsto f la lb ↔ ∀ ib (hib : pb ib), ∃ ia (hia : pa ia), ∀ x ∈ sa ia, f x ∈ sb ib :=\nby simp [hlb.tendsto_right_iff, hla.eventually_iff]\n\nlemma tendsto.basis_left (H : tendsto f la lb) (hla : la.has_basis pa sa) :\n  ∀ t ∈ lb, ∃ i (hi : pa i), maps_to f (sa i) t :=\nhla.tendsto_left_iff.1 H\n\nlemma tendsto.basis_right (H : tendsto f la lb) (hlb : lb.has_basis pb sb) :\n  ∀ i (hi : pb i), ∀ᶠ x in la, f x ∈ sb i :=\nhlb.tendsto_right_iff.1 H\n\nlemma tendsto.basis_both (H : tendsto f la lb) (hla : la.has_basis pa sa)\n  (hlb : lb.has_basis pb sb) :\n  ∀ ib (hib : pb ib), ∃ ia (hia : pa ia), ∀ x ∈ sa ia, f x ∈ sb ib :=\n(hla.tendsto_iff hlb).1 H\n\nlemma has_basis.prod_pprod (hla : la.has_basis pa sa) (hlb : lb.has_basis pb sb) :\n  (la ×ᶠ lb).has_basis (λ i : pprod ι ι', pa i.1 ∧ pb i.2) (λ i, sa i.1 ×ˢ sb i.2) :=\n(hla.comap prod.fst).inf' (hlb.comap prod.snd)\n\nlemma has_basis.prod {ι ι' : Type*} {pa : ι → Prop} {sa : ι → set α} {pb : ι' → Prop}\n  {sb : ι' → set β} (hla : la.has_basis pa sa) (hlb : lb.has_basis pb sb) :\n  (la ×ᶠ lb).has_basis (λ i : ι × ι', pa i.1 ∧ pb i.2) (λ i, sa i.1 ×ˢ sb i.2) :=\n(hla.comap prod.fst).inf (hlb.comap prod.snd)\n\nlemma has_basis.prod_same_index {p : ι → Prop} {sb : ι → set β}\n  (hla : la.has_basis p sa) (hlb : lb.has_basis p sb)\n  (h_dir : ∀ {i j}, p i → p j → ∃ k, p k ∧ sa k ⊆ sa i ∧ sb k ⊆ sb j) :\n  (la ×ᶠ lb).has_basis p (λ i, sa i ×ˢ sb i) :=\nbegin\n  simp only [has_basis_iff, (hla.prod_pprod hlb).mem_iff],\n  refine λ t, ⟨_, _⟩,\n  { rintros ⟨⟨i, j⟩, ⟨hi, hj⟩, hsub : sa i ×ˢ sb j ⊆ t⟩,\n    rcases h_dir hi hj with ⟨k, hk, ki, kj⟩,\n    exact ⟨k, hk, (set.prod_mono ki kj).trans hsub⟩ },\n  { rintro ⟨i, hi, h⟩,\n    exact ⟨⟨i, i⟩, ⟨hi, hi⟩, h⟩ },\nend\n\nlemma has_basis.prod_same_index_mono {ι : Type*} [linear_order ι]\n  {p : ι → Prop} {sa : ι → set α} {sb : ι → set β}\n  (hla : la.has_basis p sa) (hlb : lb.has_basis p sb)\n  (hsa : monotone_on sa {i | p i}) (hsb : monotone_on sb {i | p i}) :\n  (la ×ᶠ lb).has_basis p (λ i, sa i ×ˢ sb i) :=\nhla.prod_same_index hlb $ λ i j hi hj,\n  have p (min i j), from min_rec' _ hi hj,\n  ⟨min i j, this, hsa this hi $ min_le_left _ _, hsb this hj $ min_le_right _ _⟩\n\nlemma has_basis.prod_same_index_anti {ι : Type*} [linear_order ι]\n  {p : ι → Prop} {sa : ι → set α} {sb : ι → set β}\n  (hla : la.has_basis p sa) (hlb : lb.has_basis p sb)\n  (hsa : antitone_on sa {i | p i}) (hsb : antitone_on sb {i | p i}) :\n  (la ×ᶠ lb).has_basis p (λ i, sa i ×ˢ sb i) :=\n@has_basis.prod_same_index_mono _ _ _ _ ιᵒᵈ _ _ _ _  hla hlb hsa.dual_left hsb.dual_left\n\nlemma has_basis.prod_self (hl : la.has_basis pa sa) :\n  (la ×ᶠ la).has_basis pa (λ i, sa i ×ˢ sa i) :=\nhl.prod_same_index hl $ λ i j hi hj, by simpa only [exists_prop, subset_inter_iff]\n  using hl.mem_iff.1 (inter_mem (hl.mem_of_mem hi) (hl.mem_of_mem hj))\n\nlemma mem_prod_self_iff {s} : s ∈ la ×ᶠ la ↔ ∃ t ∈ la, t ×ˢ t ⊆ s :=\nla.basis_sets.prod_self.mem_iff\n\nlemma has_antitone_basis.prod {ι : Type*} [linear_order ι] {f : filter α} {g : filter β}\n  {s : ι → set α} {t : ι → set β} (hf : has_antitone_basis f s) (hg : has_antitone_basis g t) :\n  has_antitone_basis (f ×ᶠ g) (λ n, s n ×ˢ t n) :=\n⟨hf.1.prod_same_index_anti hg.1 (hf.2.antitone_on _) (hg.2.antitone_on _), hf.2.set_prod hg.2⟩\n\nlemma has_basis.coprod {ι ι' : Type*} {pa : ι → Prop} {sa : ι → set α} {pb : ι' → Prop}\n  {sb : ι' → set β} (hla : la.has_basis pa sa) (hlb : lb.has_basis pb sb) :\n  (la.coprod lb).has_basis (λ i : ι × ι', pa i.1 ∧ pb i.2)\n    (λ i, prod.fst ⁻¹' sa i.1 ∪ prod.snd ⁻¹' sb i.2) :=\n(hla.comap prod.fst).sup (hlb.comap prod.snd)\n\nend two_types\n\nlemma map_sigma_mk_comap {π : α → Type*} {π' : β → Type*} {f : α → β}\n  (hf : function.injective f) (g : Π a, π a → π' (f a)) (a : α) (l : filter (π' (f a))) :\n  map (sigma.mk a) (comap (g a) l) = comap (sigma.map f g) (map (sigma.mk (f a)) l) :=\nbegin\n  refine (((basis_sets _).comap _).map _).eq_of_same_basis _,\n  convert ((basis_sets _).map _).comap _,\n  ext1 s,\n  apply image_sigma_mk_preimage_sigma_map hf\nend\n\nend filter\n\nend sort\n\nnamespace filter\n\nvariables {α β γ ι : Type*} {ι' : Sort*}\n\n/-- `is_countably_generated f` means `f = generate s` for some countable `s`. -/\nclass is_countably_generated (f : filter α) : Prop :=\n(out [] : ∃ s : set (set α), s.countable ∧ f = generate s)\n\n/-- `is_countable_basis p s` means the image of `s` bounded by `p` is a countable filter basis. -/\nstructure is_countable_basis (p : ι → Prop) (s : ι → set α) extends is_basis p s : Prop :=\n(countable : (set_of p).countable)\n\n/-- We say that a filter `l` has a countable basis `s : ι → set α` bounded by `p : ι → Prop`,\nif `t ∈ l` if and only if `t` includes `s i` for some `i` such that `p i`, and the set\ndefined by `p` is countable. -/\nstructure has_countable_basis (l : filter α) (p : ι → Prop) (s : ι → set α)\n  extends has_basis l p s : Prop :=\n(countable : (set_of p).countable)\n\n/-- A countable filter basis `B` on a type `α` is a nonempty countable collection of sets of `α`\nsuch that the intersection of two elements of this collection contains some element\nof the collection. -/\nstructure countable_filter_basis (α : Type*) extends filter_basis α :=\n(countable : sets.countable)\n\n-- For illustration purposes, the countable filter basis defining (at_top : filter ℕ)\ninstance nat.inhabited_countable_filter_basis : inhabited (countable_filter_basis ℕ) :=\n⟨{ countable := countable_range (λ n, Ici n),\n   ..(default : filter_basis ℕ) }⟩\n\nlemma has_countable_basis.is_countably_generated {f : filter α} {p : ι → Prop} {s : ι → set α}\n  (h : f.has_countable_basis p s) :\n  f.is_countably_generated :=\n⟨⟨{t | ∃ i, p i ∧ s i = t}, h.countable.image s, h.to_has_basis.eq_generate⟩⟩\n\nlemma antitone_seq_of_seq (s : ℕ → set α) :\n  ∃ t : ℕ → set α, antitone t ∧ (⨅ i, 𝓟 $ s i) = ⨅ i, 𝓟 (t i) :=\nbegin\n  use λ n, ⋂ m ≤ n, s m, split,\n  { exact λ i j hij, bInter_mono (Iic_subset_Iic.2 hij) (λ n hn, subset.refl _) },\n  apply le_antisymm; rw le_infi_iff; intro i,\n  { rw le_principal_iff, refine (bInter_mem (finite_le_nat _)).2 (λ j hji, _),\n    rw ← le_principal_iff, apply infi_le_of_le j _, exact le_rfl },\n  { apply infi_le_of_le i _, rw principal_mono, intro a, simp, intro h, apply h, refl },\nend\n\nlemma countable_binfi_eq_infi_seq [complete_lattice α] {B : set ι} (Bcbl : B.countable)\n  (Bne : B.nonempty) (f : ι → α) :\n  ∃ (x : ℕ → ι), (⨅ t ∈ B, f t) = ⨅ i, f (x i) :=\nlet ⟨g, hg⟩ := Bcbl.exists_eq_range Bne in ⟨g, hg.symm ▸ infi_range⟩\n\nlemma countable_binfi_eq_infi_seq' [complete_lattice α] {B : set ι} (Bcbl : B.countable) (f : ι → α)\n  {i₀ : ι} (h : f i₀ = ⊤) :\n  ∃ (x : ℕ → ι), (⨅ t ∈ B, f t) = ⨅ i, f (x i) :=\nbegin\n  cases B.eq_empty_or_nonempty with hB Bnonempty,\n  { rw [hB, infi_emptyset],\n    use λ n, i₀,\n    simp [h] },\n  { exact countable_binfi_eq_infi_seq Bcbl Bnonempty f }\nend\n\nlemma countable_binfi_principal_eq_seq_infi {B : set (set α)} (Bcbl : B.countable) :\n  ∃ (x : ℕ → set α), (⨅ t ∈ B, 𝓟 t) = ⨅ i, 𝓟 (x i) :=\ncountable_binfi_eq_infi_seq' Bcbl 𝓟 principal_univ\n\nsection is_countably_generated\n\nprotected lemma has_antitone_basis.mem_iff [preorder ι] {l : filter α} {s : ι → set α}\n  (hs : l.has_antitone_basis s) {t : set α} : t ∈ l ↔ ∃ i, s i ⊆ t :=\nhs.to_has_basis.mem_iff.trans $ by simp only [exists_prop, true_and]\n\nprotected lemma has_antitone_basis.mem [preorder ι] {l : filter α} {s : ι → set α}\n  (hs : l.has_antitone_basis s) (i : ι) : s i ∈ l :=\nhs.to_has_basis.mem_of_mem trivial\n\nlemma has_antitone_basis.has_basis_ge [preorder ι] [is_directed ι (≤)] {l : filter α}\n  {s : ι → set α} (hs : l.has_antitone_basis s) (i : ι) :\n  l.has_basis (λ j, i ≤ j) s :=\nhs.1.to_has_basis (λ j _, (exists_ge_ge i j).imp $ λ k hk, ⟨hk.1, hs.2 hk.2⟩)\n  (λ j hj, ⟨j, trivial, subset.rfl⟩)\n\n/-- If `f` is countably generated and `f.has_basis p s`, then `f` admits a decreasing basis\nenumerated by natural numbers such that all sets have the form `s i`. More precisely, there is a\nsequence `i n` such that `p (i n)` for all `n` and `s (i n)` is a decreasing sequence of sets which\nforms a basis of `f`-/\nlemma has_basis.exists_antitone_subbasis {f : filter α} [h : f.is_countably_generated]\n  {p : ι' → Prop} {s : ι' → set α} (hs : f.has_basis p s) :\n  ∃ x : ℕ → ι', (∀ i, p (x i)) ∧ f.has_antitone_basis (λ i, s (x i)) :=\nbegin\n  obtain ⟨x', hx'⟩ : ∃ x : ℕ → set α, f = ⨅ i, 𝓟 (x i),\n  { unfreezingI { rcases h with ⟨s, hsc, rfl⟩ },\n    rw generate_eq_binfi,\n    exact countable_binfi_principal_eq_seq_infi hsc },\n  have : ∀ i, x' i ∈ f := λ i, hx'.symm ▸ (infi_le (λ i, 𝓟 (x' i)) i) (mem_principal_self _),\n  let x : ℕ → {i : ι' // p i} := λ n, nat.rec_on n (hs.index _ $ this 0)\n    (λ n xn, (hs.index _ $ inter_mem (this $ n + 1) (hs.mem_of_mem xn.2))),\n  have x_mono : antitone (λ i, s (x i)),\n  { refine antitone_nat_of_succ_le (λ i, _),\n    exact (hs.set_index_subset _).trans (inter_subset_right _ _) },\n  have x_subset : ∀ i, s (x i) ⊆ x' i,\n  { rintro (_|i),\n    exacts [hs.set_index_subset _, subset.trans (hs.set_index_subset _) (inter_subset_left _ _)] },\n  refine ⟨λ i, x i, λ i, (x i).2, _⟩,\n  have : (⨅ i, 𝓟 (s (x i))).has_antitone_basis (λ i, s (x i)) :=\n    ⟨has_basis_infi_principal (directed_of_sup x_mono), x_mono⟩,\n  convert this,\n  exact le_antisymm (le_infi $ λ i, le_principal_iff.2 $ by cases i; apply hs.set_index_mem)\n    (hx'.symm ▸ le_infi (λ i, le_principal_iff.2 $\n      this.to_has_basis.mem_iff.2 ⟨i, trivial, x_subset i⟩))\nend\n\n/-- A countably generated filter admits a basis formed by an antitone sequence of sets. -/\nlemma exists_antitone_basis (f : filter α) [f.is_countably_generated] :\n  ∃ x : ℕ → set α, f.has_antitone_basis x :=\nlet ⟨x, hxf, hx⟩ := f.basis_sets.exists_antitone_subbasis in ⟨x, hx⟩\n\nlemma exists_antitone_seq (f : filter α) [f.is_countably_generated] :\n  ∃ x : ℕ → set α, antitone x ∧ ∀ {s}, (s ∈ f ↔ ∃ i, x i ⊆ s) :=\nlet ⟨x, hx⟩ := f.exists_antitone_basis in\n⟨x, hx.antitone, λ s, by simp [hx.to_has_basis.mem_iff]⟩\n\ninstance inf.is_countably_generated (f g : filter α) [is_countably_generated f]\n  [is_countably_generated g] :\n  is_countably_generated (f ⊓ g) :=\nbegin\n  rcases f.exists_antitone_basis with ⟨s, hs⟩,\n  rcases g.exists_antitone_basis with ⟨t, ht⟩,\n  exact has_countable_basis.is_countably_generated\n    ⟨hs.to_has_basis.inf ht.to_has_basis, set.to_countable _⟩\nend\n\ninstance map.is_countably_generated (l : filter α) [l.is_countably_generated] (f : α → β) :\n  (map f l).is_countably_generated :=\nlet ⟨x, hxl⟩ := l.exists_antitone_basis in\nhas_countable_basis.is_countably_generated ⟨hxl.map.to_has_basis, to_countable _⟩\n\ninstance comap.is_countably_generated (l : filter β) [l.is_countably_generated] (f : α → β) :\n  (comap f l).is_countably_generated :=\nlet ⟨x, hxl⟩ := l.exists_antitone_basis in\nhas_countable_basis.is_countably_generated ⟨hxl.to_has_basis.comap _, to_countable _⟩\n\ninstance sup.is_countably_generated (f g : filter α) [is_countably_generated f]\n  [is_countably_generated g] :\n  is_countably_generated (f ⊔ g) :=\nbegin\n  rcases f.exists_antitone_basis with ⟨s, hs⟩,\n  rcases g.exists_antitone_basis with ⟨t, ht⟩,\n  exact has_countable_basis.is_countably_generated\n    ⟨hs.to_has_basis.sup ht.to_has_basis, set.to_countable _⟩\nend\n\ninstance prod.is_countably_generated (la : filter α) (lb : filter β) [is_countably_generated la]\n  [is_countably_generated lb] : is_countably_generated (la ×ᶠ lb) :=\nfilter.inf.is_countably_generated _ _\n\ninstance coprod.is_countably_generated (la : filter α) (lb : filter β) [is_countably_generated la]\n  [is_countably_generated lb] : is_countably_generated (la.coprod lb) :=\nfilter.sup.is_countably_generated _ _\n\nend is_countably_generated\n\nlemma is_countably_generated_seq [countable β] (x : β → set α) :\n  is_countably_generated (⨅ i, 𝓟 $ x i) :=\nbegin\n  use [range x, countable_range x],\n  rw [generate_eq_binfi, infi_range]\nend\n\nlemma is_countably_generated_of_seq {f : filter α} (h : ∃ x : ℕ → set α, f = ⨅ i, 𝓟 $ x i) :\n  f.is_countably_generated  :=\nlet ⟨x, h⟩ := h in by rw h ; apply is_countably_generated_seq\n\nlemma is_countably_generated_binfi_principal {B : set $ set α} (h : B.countable) :\n  is_countably_generated (⨅ (s ∈ B), 𝓟 s) :=\nis_countably_generated_of_seq (countable_binfi_principal_eq_seq_infi h)\n\nlemma is_countably_generated_iff_exists_antitone_basis {f : filter α} :\n  is_countably_generated f ↔ ∃ x : ℕ → set α, f.has_antitone_basis x :=\nbegin\n  split,\n  { introI h, exact f.exists_antitone_basis },\n  { rintros ⟨x, h⟩,\n    rw h.to_has_basis.eq_infi,\n    exact is_countably_generated_seq x },\nend\n\n@[instance] lemma is_countably_generated_principal (s : set α) : is_countably_generated (𝓟 s) :=\nis_countably_generated_of_seq ⟨λ _, s, infi_const.symm⟩\n\n@[instance] lemma is_countably_generated_pure (a : α) : is_countably_generated (pure a) :=\nby { rw ← principal_singleton, exact is_countably_generated_principal _, }\n\n@[instance] lemma is_countably_generated_bot : is_countably_generated (⊥ : filter α) :=\n@principal_empty α ▸ is_countably_generated_principal _\n\n@[instance] lemma is_countably_generated_top : is_countably_generated (⊤ : filter α) :=\n@principal_univ α ▸ is_countably_generated_principal _\n\ninstance infi.is_countably_generated {ι : Sort*} [countable ι] (f : ι → filter α)\n  [∀ i, is_countably_generated (f i)] : is_countably_generated (⨅ i, f i) :=\nbegin\n  choose s hs using λ i, exists_antitone_basis (f i),\n  rw [← plift.down_surjective.infi_comp],\n  refine has_countable_basis.is_countably_generated\n    ⟨has_basis_infi (λ n, (hs _).to_has_basis), _⟩,\n  refine (countable_range $ sigma.map (coe : finset (plift ι) → set (plift ι)) (λ _, id)).mono _,\n  rintro ⟨I, f⟩ ⟨hI, -⟩,\n  lift I to finset (plift ι) using hI,\n  exact ⟨⟨I, f⟩, rfl⟩\nend\n\nend filter\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/order/filter/bases.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.492748133973972}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta, Edward Ayers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Edward Ayers\n-/\n\nimport category_theory.limits.shapes.binary_products\nimport category_theory.adjunction\nimport adjunction\nimport tactic\nimport to_mathlib\nimport binary_products\n\n/-!\n# Cartesian closed categories\n\nDefine exponentiable objects and cartesian closed categories.\nShow that exponential forms a difunctor.\n-/\nuniverses v u\n\nnamespace category_theory\n\nopen limits category\nsection\nvariables {C : Type u} [𝒞 : category.{v} C] [has_binary_products.{v} C] {A U V W X Y Z : C}\ninclude 𝒞\n\nlocal attribute [tidy] tactic.case_bash\n\ndef prodinl (X : C) : C ⥤ C := prod_functor.obj X\n\n@[simp] lemma prodinl_map_def {f : Y ⟶ Z} : (prodinl X).map f = limits.prod.map (𝟙 X) f := rfl\n@[simp] lemma map_fst {f : U ⟶ V} {g : W ⟶ X} : limits.prod.map f g ≫ limits.prod.fst = limits.prod.fst ≫ f := by simp\n@[simp] lemma map_snd {f : U ⟶ V} {g : W ⟶ X} : limits.prod.map f g ≫ limits.prod.snd = limits.prod.snd ≫ g := by simp\n@[simp] lemma prod.map_id : limits.prod.map (𝟙 X) (𝟙 Y) = 𝟙 (X⨯Y) := begin apply prod.hom_ext, simp, simp end\n@[simp] lemma lift_fst {f : W ⟶ X} {g : W ⟶ Y} : limits.prod.lift f g ≫ limits.prod.fst = f := by simp\n@[simp] lemma lift_snd {f : W ⟶ X} {g : W ⟶ Y} : limits.prod.lift f g ≫ limits.prod.snd = g := by simp\nopen category\n\ndef prodinl_comp (X Y : C) : prodinl (X ⨯ Y) ≅ prodinl Y ⋙ prodinl X :=\nnat_iso.of_components (limits.prod.associator _ _) (by tidy)\n\nend\n\nclass exponentiable {C : Type u} [𝒞 : category.{v} C] [bp : @has_binary_products C 𝒞] (X : C) :=\n(exponentiable : is_left_adjoint (prodinl X))\n\ndef binary_product_exponentiable {C : Type u} [𝒞 : category.{v} C] [bp : @has_binary_products C 𝒞] {X Y : C}\n  (hX : exponentiable X) (hY : exponentiable Y) : exponentiable (X ⨯ Y) :=\n{ exponentiable :=\n  { right := hX.exponentiable.right ⋙ hY.exponentiable.right,\n    adj := adjunction_of_nat_iso_left (adjunction.comp _ _ hY.exponentiable.adj hX.exponentiable.adj) (prodinl_comp _ _).symm } }\n\nclass is_cartesian_closed (C : Type u) [𝒞 : category.{v} C] [has_binary_products.{v} C] extends has_terminal.{v} C :=\n(cart_closed : Π (X : C), exponentiable X)\n\ninstance exponentiable_of_cc {C : Type u} [𝒞 : category.{v} C] [@has_binary_products C 𝒞] [is_cartesian_closed C] {A : C} :\n  exponentiable A := is_cartesian_closed.cart_closed A\n\nvariables {C : Type u} [𝒞 : category.{v} C] [has_binary_products.{v} C] {X X' Y Y' Z A B : C} [exponentiable A]\ninclude 𝒞\n\n/-- This is (-)^A -/\ndef exp.functor (A : C) [exponentiable A] : C ⥤ C :=\n(exponentiable.exponentiable A).right\n\ndef exp.adjunction : prodinl A ⊣ exp.functor A :=\n(exponentiable.exponentiable A).adj\n\ndef ev.nat_trans (A : C) [exponentiable A] : exp.functor A ⋙ prodinl A ⟶ 𝟭 C :=\nexp.adjunction.counit\n\ndef coev.nat_trans (A : C) [exponentiable A] : 𝟭 C ⟶ prodinl A ⋙ exp.functor A :=\nexp.adjunction.unit\n\n/-- `B ^ A` or `A ⟹ B` -/\ndef exp (A : C) (B : C) [exponentiable A] : C := (exp.functor A).obj B\n\ninfixl `⟹`:20 := exp\n\n-- [todo] rename as 'post compose' or similar?\ndef post (A : C) [exponentiable A] {X Y : C} (f : X ⟶ Y) : A⟹X ⟶ A⟹Y :=\n(exp.functor A).map f\n\nlemma post.map_comp {f : X ⟶ Y} {g : Y ⟶ Z} : post A (f ≫ g) = post A f ≫ post A g :=\nbegin\n  show functor.map _ _ = _ ≫ _,\n  rw (exp.functor A).map_comp',\n  refl,\nend\n\ndef ev : A ⨯ (A⟹B) ⟶ B :=\n(ev.nat_trans A).app B\n\ndef coev : B ⟶ A⟹(A⨯B) :=\n(coev.nat_trans A).app B\n\n@[simp] lemma ev_coev : limits.prod.map (𝟙 A) coev ≫ ev = 𝟙 (A⨯B) :=\n(@adjunction.left_triangle_components C _ C _ (prodinl A) (exp.functor A) exp.adjunction B)\n\n@[simp] lemma coev_ev : coev ≫ post _ ev = 𝟙 (A⟹B) :=\n(@adjunction.right_triangle_components C _ C _ (prodinl A) (exp.functor A) exp.adjunction B)\n\nlemma coev_nat (f : X ⟶ Y) : f ≫ coev = coev ≫ post _ (limits.prod.map (𝟙 A) f) :=\n(coev.nat_trans A).naturality f\n\nlemma ev_nat {f : X ⟶ Y} : limits.prod.map (𝟙 A) (post _ f) ≫ ev = ev ≫ f :=\n(ev.nat_trans A).naturality f\n\ndef exp_transpose : (A ⨯ Y ⟶ X) ≃ (Y ⟶ A⟹X) :=\nexp.adjunction.hom_equiv _ _\n\nlemma exp_transpose_natural_left  (f : X ⟶ X') (g : A ⨯ X' ⟶ Y) :\n  exp_transpose.to_fun (limits.prod.map (𝟙 _) f ≫ g) = f ≫ exp_transpose.to_fun g :=\nadjunction.hom_equiv_naturality_left _ _ _\n\nlemma exp_transpose_natural_right (f : A ⨯ X ⟶ Y) (g : Y ⟶ Y') :\n  exp_transpose.to_fun (f ≫ g) = exp_transpose.to_fun f ≫ post _ g :=\nadjunction.hom_equiv_naturality_right _ _ _\n\nlemma exp_transpose_natural_right_symm  (f : X ⟶ A⟹Y) (g : Y ⟶ Y') :\n  exp_transpose.inv_fun (f ≫ post A g) = exp_transpose.inv_fun f ≫ g :=\nadjunction.hom_equiv_naturality_right_symm _ _ _\n\nlemma exp_transpose_natural_left_symm  (f : X ⟶ X') (g : X' ⟶ A⟹Y) :\n  exp_transpose.inv_fun (f ≫ g) = limits.prod.map (𝟙 _) f ≫ exp_transpose.inv_fun g :=\nadjunction.hom_equiv_naturality_left_symm _ _ _\n\nsection terminal\nvariable [has_terminal.{v} C]\n\nlemma prod_left_unitor_naturality (f : X ⟶ Y):\n  (prod.left_unitor X).inv ≫ limits.prod.map (𝟙 _) f = f ≫ (prod.left_unitor Y).inv :=\nbegin\n  apply prod.hom_ext,\n  { apply subsingleton.elim },\n  { simp [id_comp C f] }\nend\n\ndef terminal_exponentiable : exponentiable ⊤_C :=\n{ exponentiable := {\n  right := 𝟭 C,\n  adj := adjunction.mk_of_hom_equiv\n  { hom_equiv := λ X _, have unitor : _, from prod.left_unitor X,\n      ⟨λ a, unitor.inv ≫ a, λ a, unitor.hom ≫ a, by tidy, by tidy⟩ } } }\n\nattribute [instance] terminal_exponentiable\n\ndef exp_terminal_iso : (⊤_C ⟹ X) ≅ X :=\nbegin\n  apply yoneda.ext (⊤_ C ⟹ X) X _ _ _ _ _,\n  intros Y f, exact (prod.left_unitor Y).inv ≫ exp_transpose.inv_fun f,\n  intros Y f, exact exp_transpose.to_fun ((prod.left_unitor Y).hom ≫ f),\n  { intros Z g, dsimp,\n    rw ← assoc, erw iso.hom_inv_id (prod.left_unitor Z),\n    simp [exp_transpose.right_inv g] },\n  { intros Z g, dsimp,\n    rw exp_transpose.left_inv,\n    rw ← assoc,\n    erw iso.inv_hom_id (prod.left_unitor Z),\n    simp },\n  { intros Z W f g, dsimp,\n    rw exp_transpose_natural_left_symm,\n    rw ← assoc, rw ← assoc,\n    erw prod_left_unitor_naturality _, refl },\nend\n\n@[reducible]\ndef point_at_hom (f : A ⟶ Y) : ⊤_C ⟶ (A ⟹ Y) :=\nexp_transpose.to_fun (limits.prod.fst ≫ f)\nend terminal\n\nsection pre\n\nvariables [exponentiable B]\n\n-- this notation (and the hats) are just here so i could figure out how to\n-- do pre_map - I think the ⟨f,g⟩ might be nice but the rest can go (TODO)\nlocal notation `⟨`f`, `g`⟩` := limits.prod.map f g\n\n@[reducible]\ndef hat : (A ⨯ Y ⟶ X) → (Y ⟶ A ⟹ X) := exp_transpose.to_fun\n@[reducible]\ndef unhat : (Y ⟶ A ⟹ X) → (A ⨯ Y ⟶ X) := exp_transpose.inv_fun\n\ndef pre (X : C) (f : B ⟶ A) :  (A⟹X) ⟶ B⟹X :=\nhat (⟨f, 𝟙 (A ⟹ X)⟩ ≫ unhat (𝟙 (A ⟹ X)))\n\nlemma pre_id : pre X (𝟙 A) = 𝟙 (A⟹X) :=\nbegin\n  dunfold pre hat, erw exp_transpose_natural_left, rw exp_transpose.right_inv, simp\nend\n\nlemma pre_map {D : C} [exponentiable D] {f : A ⟶ B} {g : B ⟶ D} : pre X (f ≫ g) = pre X g ≫ pre X f :=\nbegin\n  dunfold pre, apply function.injective_of_left_inverse exp_transpose.right_inv,\n  rw exp_transpose.left_inv, rw ← exp_transpose_natural_left, rw exp_transpose.left_inv,\n  show ⟨f ≫ g, 𝟙 (D ⟹ X)⟩ ≫ unhat (𝟙 (D ⟹ X)) =\n    ⟨𝟙 A, (hat (⟨g, 𝟙 (D ⟹ X)⟩ ≫ unhat (𝟙 (D ⟹ X))))⟩ ≫\n      ⟨f, 𝟙 (B ⟹ X)⟩ ≫ unhat (𝟙 (B ⟹ X)),\n  suffices: ⟨f ≫ g, 𝟙 (D ⟹ X)⟩ ≫ unhat (𝟙 (D ⟹ X)) =\n    (⟨f, 𝟙 (D ⟹ X)⟩ ≫ ⟨𝟙 B, (hat (⟨g, 𝟙 (D ⟹ X)⟩ ≫ unhat (𝟙 (D ⟹ X))))⟩) ≫ unhat (𝟙 (B ⟹ X)),\n  rw this, rw ← assoc, congr' 1, apply prod.hom_ext, simp, dsimp, simp, simp, dsimp, simp,\n  have: ⟨f ≫ g, 𝟙 (D ⟹ X)⟩ = ⟨f, 𝟙 _⟩ ≫ ⟨g, 𝟙 _⟩, apply prod.hom_ext, simp, simp,\n  rw this, rw assoc, rw assoc, congr' 1, erw ← exp_transpose_natural_left_symm,\n  apply function.injective_of_left_inverse exp_transpose.left_inv, rw exp_transpose_natural_right,\n  rw exp_transpose.right_inv, simp, exact (exp_transpose_natural_right _ _).symm\nend\n\ndef pre.functor [is_cartesian_closed C] (X : C) : Cᵒᵖ ⥤ C :=\n{ obj := λ A, (A.unop) ⟹ X,\n  map := λ A B f, pre X f.unop,\n  map_id' := begin intros, apply pre_id, end,\n  map_comp' := begin intros, apply pre_map, end,\n}\nend pre\n\nlemma exp_natural [is_cartesian_closed C] (A B : C) (X Y : Cᵒᵖ) (f : A ⟶ B) (g : X ⟶ Y) :\n  (pre.functor A).map g ≫ post (opposite.unop Y) f = post (opposite.unop X) f ≫ (pre.functor B).map g :=\nbegin\n  dunfold pre.functor,\n  dsimp, dunfold pre,\n  show _ = _,\n  rw ← exp_transpose_natural_right,\n  rw ← exp_transpose_natural_left,\n  congr' 1,\n  rw assoc,\n  rw ← exp_transpose_natural_right_symm,\n  rw ← assoc,\n  show _ = (limits.prod.map _ _ ≫ _) ≫ _,\n  rw prod_map_comm,\n  rw assoc,\n  erw ← exp_transpose_natural_left_symm,\n  rw id_comp,\n  rw comp_id\nend\n\ndef exp.difunctor [is_cartesian_closed C] : C ⥤ Cᵒᵖ ⥤ C :=\n{ obj := pre.functor,\n  map := λ A B f, { app := λ X, post X.unop f, naturality' := λ X Y g, begin apply exp_natural end },\n  map_id' := λ X, begin ext, apply functor.map_id end,\n  map_comp' := λ X Y Z f g, begin ext, apply functor.map_comp end\n}\n\nsection functor\n\nuniverses v₂ u₂\n\nvariables {D : Type u} [category.{v} D] [has_binary_products.{v} D]\nvariables (F : C ⥤ D) [preserves_limits_of_shape (discrete walking_pair) F]\n\n-- (implementation)\ndef alternative_cone (A B : C) : cone (pair A B ⋙ F) :=\n{ X := F.obj A ⨯ F.obj B,\n  π := nat_trans.of_homs (λ j, walking_pair.cases_on j limits.prod.fst limits.prod.snd)}\n\n-- (implementation)\ndef alt_is_limit (A B : C) : is_limit (functor.map_cone F (limit.cone (pair A B))) :=\npreserves_limit.preserves F (limit.is_limit (pair A B))\n\n-- the multiplicative comparison isomorphism\ndef mult_comparison (A B : C) : F.obj (A ⨯ B) ≅ F.obj A ⨯ F.obj B :=\n{ hom := prod.lift (F.map limits.prod.fst) (F.map limits.prod.snd),\n  inv := (alt_is_limit F A B).lift (alternative_cone F A B),\n  hom_inv_id' :=\n  begin\n    apply is_limit.hom_ext (alt_is_limit F A B),\n    rintro ⟨j⟩,\n      rw assoc, rw (alt_is_limit F A B).fac,\n      erw limit.lift_π, simp,\n    rw assoc, rw (alt_is_limit F A B).fac,\n    erw limit.lift_π, simp\n  end,\n  inv_hom_id' :=\n  begin\n    ext ⟨j⟩, simp, erw (alt_is_limit F A B).fac, refl,\n    simp, erw (alt_is_limit F A B).fac, refl,\n  end\n}\n\nvariables [is_cartesian_closed C] [is_cartesian_closed D]\n\n-- the exponential comparison map\ndef exp_comparison (A B : C) :\n  F.obj (A ⟹ B) ⟶ F.obj A ⟹ F.obj B :=\nhat ((mult_comparison F A _).inv ≫ F.map ev)\n\nend functor\n\nend category_theory", "meta": {"author": "Or7ando", "repo": "lean", "sha": "d41169cf4e416a0d42092fb6bdc14131cee9dd15", "save_path": "github-repos/lean/Or7ando-lean", "path": "github-repos/lean/Or7ando-lean/lean-d41169cf4e416a0d42092fb6bdc14131cee9dd15/.github/workflows/geo/src/cartesian_closed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.49274812694426323}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.polynomial.big_operators\nimport Mathlib.field_theory.minpoly\nimport Mathlib.field_theory.splitting_field\nimport Mathlib.field_theory.tower\nimport Mathlib.algebra.squarefree\nimport Mathlib.PostPort\n\nuniverses u u_1 v u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n\n# Separable polynomials\n\nWe define a polynomial to be separable if it is coprime with its derivative. We prove basic\nproperties about separable polynomials here.\n\n## Main definitions\n\n* `polynomial.separable f`: a polynomial `f` is separable iff it is coprime with its derivative.\n* `polynomial.expand R p f`: expand the polynomial `f` with coefficients in a\n  commutative semiring `R` by a factor of p, so `expand R p (∑ aₙ xⁿ)` is `∑ aₙ xⁿᵖ`.\n* `polynomial.contract p f`: the opposite of `expand`, so it sends `∑ aₙ xⁿᵖ` to `∑ aₙ xⁿ`.\n\n-/\n\nnamespace polynomial\n\n\n/-- A polynomial is separable iff it is coprime with its derivative. -/\ndef separable {R : Type u} [comm_semiring R] (f : polynomial R) :=\n  is_coprime f (coe_fn derivative f)\n\ntheorem separable_def {R : Type u} [comm_semiring R] (f : polynomial R) : separable f ↔ is_coprime f (coe_fn derivative f) :=\n  iff.rfl\n\ntheorem separable_def' {R : Type u} [comm_semiring R] (f : polynomial R) : separable f ↔ ∃ (a : polynomial R), ∃ (b : polynomial R), a * f + b * coe_fn derivative f = 1 :=\n  iff.rfl\n\ntheorem separable_one {R : Type u} [comm_semiring R] : separable 1 :=\n  is_coprime_one_left\n\ntheorem separable_X_add_C {R : Type u} [comm_semiring R] (a : R) : separable (X + coe_fn C a) := sorry\n\ntheorem separable_X {R : Type u} [comm_semiring R] : separable X :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (separable X)) (propext (separable_def X))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime X (coe_fn derivative X))) derivative_X)) is_coprime_one_right)\n\ntheorem separable_C {R : Type u} [comm_semiring R] (r : R) : separable (coe_fn C r) ↔ is_unit r := sorry\n\ntheorem separable.of_mul_left {R : Type u} [comm_semiring R] {f : polynomial R} {g : polynomial R} (h : separable (f * g)) : separable f := sorry\n\ntheorem separable.of_mul_right {R : Type u} [comm_semiring R] {f : polynomial R} {g : polynomial R} (h : separable (f * g)) : separable g :=\n  separable.of_mul_left (eq.mp (Eq._oldrec (Eq.refl (separable (f * g))) (mul_comm f g)) h)\n\ntheorem separable.of_dvd {R : Type u} [comm_semiring R] {f : polynomial R} {g : polynomial R} (hf : separable f) (hfg : g ∣ f) : separable g :=\n  Exists.dcases_on hfg\n    fun (f' : polynomial R) (hfg_h : f = g * f') =>\n      Eq._oldrec (fun (hf : separable (g * f')) => separable.of_mul_left hf) (Eq.symm hfg_h) hf\n\ntheorem separable_gcd_left {F : Type u_1} [field F] {f : polynomial F} (hf : separable f) (g : polynomial F) : separable (euclidean_domain.gcd f g) :=\n  separable.of_dvd hf (euclidean_domain.gcd_dvd_left f g)\n\ntheorem separable_gcd_right {F : Type u_1} [field F] {g : polynomial F} (f : polynomial F) (hg : separable g) : separable (euclidean_domain.gcd f g) :=\n  separable.of_dvd hg (euclidean_domain.gcd_dvd_right f g)\n\ntheorem separable.is_coprime {R : Type u} [comm_semiring R] {f : polynomial R} {g : polynomial R} (h : separable (f * g)) : is_coprime f g := sorry\n\ntheorem separable.of_pow' {R : Type u} [comm_semiring R] {f : polynomial R} {n : ℕ} (h : separable (f ^ n)) : is_unit f ∨ separable f ∧ n = 1 ∨ n = 0 := sorry\n\ntheorem separable.of_pow {R : Type u} [comm_semiring R] {f : polynomial R} (hf : ¬is_unit f) {n : ℕ} (hn : n ≠ 0) (hfs : separable (f ^ n)) : separable f ∧ n = 1 :=\n  or.resolve_right (or.resolve_left (separable.of_pow' hfs) hf) hn\n\ntheorem separable.map {R : Type u} [comm_semiring R] {S : Type v} [comm_semiring S] {p : polynomial R} (h : separable p) {f : R →+* S} : separable (map f p) := sorry\n\n/-- Expand the polynomial by a factor of p, so `∑ aₙ xⁿ` becomes `∑ aₙ xⁿᵖ`. -/\ndef expand (R : Type u) [comm_semiring R] (p : ℕ) : alg_hom R (polynomial R) (polynomial R) :=\n  alg_hom.mk (ring_hom.to_fun (eval₂_ring_hom C (X ^ p))) sorry sorry sorry sorry sorry\n\ntheorem coe_expand (R : Type u) [comm_semiring R] (p : ℕ) : ⇑(expand R p) = eval₂ C (X ^ p) :=\n  rfl\n\ntheorem expand_eq_sum {R : Type u} [comm_semiring R] (p : ℕ) {f : polynomial R} : coe_fn (expand R p) f = finsupp.sum f fun (e : ℕ) (a : R) => coe_fn C a * (X ^ p) ^ e :=\n  id (Eq.refl (finsupp.sum f fun (e : ℕ) (a : R) => coe_fn C a * (X ^ p) ^ e))\n\n@[simp] theorem expand_C {R : Type u} [comm_semiring R] (p : ℕ) (r : R) : coe_fn (expand R p) (coe_fn C r) = coe_fn C r :=\n  eval₂_C C (X ^ p)\n\n@[simp] theorem expand_X {R : Type u} [comm_semiring R] (p : ℕ) : coe_fn (expand R p) X = X ^ p :=\n  eval₂_X C (X ^ p)\n\n@[simp] theorem expand_monomial {R : Type u} [comm_semiring R] (p : ℕ) (q : ℕ) (r : R) : coe_fn (expand R p) (coe_fn (monomial q) r) = coe_fn (monomial (q * p)) r := sorry\n\ntheorem expand_expand {R : Type u} [comm_semiring R] (p : ℕ) (q : ℕ) (f : polynomial R) : coe_fn (expand R p) (coe_fn (expand R q) f) = coe_fn (expand R (p * q)) f := sorry\n\ntheorem expand_mul {R : Type u} [comm_semiring R] (p : ℕ) (q : ℕ) (f : polynomial R) : coe_fn (expand R (p * q)) f = coe_fn (expand R p) (coe_fn (expand R q) f) :=\n  Eq.symm (expand_expand p q f)\n\n@[simp] theorem expand_one {R : Type u} [comm_semiring R] (f : polynomial R) : coe_fn (expand R 1) f = f := sorry\n\ntheorem expand_pow {R : Type u} [comm_semiring R] (p : ℕ) (q : ℕ) (f : polynomial R) : coe_fn (expand R (p ^ q)) f = nat.iterate (⇑(expand R p)) q f := sorry\n\ntheorem derivative_expand {R : Type u} [comm_semiring R] (p : ℕ) (f : polynomial R) : coe_fn derivative (coe_fn (expand R p) f) = coe_fn (expand R p) (coe_fn derivative f) * (↑p * X ^ (p - 1)) := sorry\n\ntheorem coeff_expand {R : Type u} [comm_semiring R] {p : ℕ} (hp : 0 < p) (f : polynomial R) (n : ℕ) : coeff (coe_fn (expand R p) f) n = ite (p ∣ n) (coeff f (n / p)) 0 := sorry\n\n@[simp] theorem coeff_expand_mul {R : Type u} [comm_semiring R] {p : ℕ} (hp : 0 < p) (f : polynomial R) (n : ℕ) : coeff (coe_fn (expand R p) f) (n * p) = coeff f n := sorry\n\n@[simp] theorem coeff_expand_mul' {R : Type u} [comm_semiring R] {p : ℕ} (hp : 0 < p) (f : polynomial R) (n : ℕ) : coeff (coe_fn (expand R p) f) (p * n) = coeff f n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coeff (coe_fn (expand R p) f) (p * n) = coeff f n)) (mul_comm p n)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coeff (coe_fn (expand R p) f) (n * p) = coeff f n)) (coeff_expand_mul hp f n)))\n      (Eq.refl (coeff f n)))\n\ntheorem expand_eq_map_domain {R : Type u} [comm_semiring R] (p : ℕ) (f : polynomial R) : coe_fn (expand R p) f = finsupp.map_domain (fun (_x : ℕ) => _x * p) f := sorry\n\ntheorem expand_inj {R : Type u} [comm_semiring R] {p : ℕ} (hp : 0 < p) {f : polynomial R} {g : polynomial R} : coe_fn (expand R p) f = coe_fn (expand R p) g ↔ f = g := sorry\n\ntheorem expand_eq_zero {R : Type u} [comm_semiring R] {p : ℕ} (hp : 0 < p) {f : polynomial R} : coe_fn (expand R p) f = 0 ↔ f = 0 := sorry\n\ntheorem expand_eq_C {R : Type u} [comm_semiring R] {p : ℕ} (hp : 0 < p) {f : polynomial R} {r : R} : coe_fn (expand R p) f = coe_fn C r ↔ f = coe_fn C r := sorry\n\ntheorem nat_degree_expand {R : Type u} [comm_semiring R] (p : ℕ) (f : polynomial R) : nat_degree (coe_fn (expand R p) f) = nat_degree f * p := sorry\n\ntheorem map_expand {R : Type u} [comm_semiring R] {S : Type v} [comm_semiring S] {p : ℕ} (hp : 0 < p) {f : R →+* S} {q : polynomial R} : map f (coe_fn (expand R p) q) = coe_fn (expand S p) (map f q) := sorry\n\ntheorem separable_X_sub_C {R : Type u} [comm_ring R] {x : R} : separable (X - coe_fn C x) := sorry\n\ntheorem separable.mul {R : Type u} [comm_ring R] {f : polynomial R} {g : polynomial R} (hf : separable f) (hg : separable g) (h : is_coprime f g) : separable (f * g) := sorry\n\ntheorem separable_prod' {R : Type u} [comm_ring R] {ι : Type u_1} {f : ι → polynomial R} {s : finset ι} : (∀ (x : ι), x ∈ s → ∀ (y : ι), y ∈ s → x ≠ y → is_coprime (f x) (f y)) →\n  (∀ (x : ι), x ∈ s → separable (f x)) → separable (finset.prod s fun (x : ι) => f x) := sorry\n\ntheorem separable_prod {R : Type u} [comm_ring R] {ι : Type u_1} [fintype ι] {f : ι → polynomial R} (h1 : pairwise (is_coprime on f)) (h2 : ∀ (x : ι), separable (f x)) : separable (finset.prod finset.univ fun (x : ι) => f x) :=\n  separable_prod' (fun (x : ι) (hx : x ∈ finset.univ) (y : ι) (hy : y ∈ finset.univ) (hxy : x ≠ y) => h1 x y hxy)\n    fun (x : ι) (hx : x ∈ finset.univ) => h2 x\n\ntheorem separable.inj_of_prod_X_sub_C {R : Type u} [comm_ring R] [nontrivial R] {ι : Type u_1} {f : ι → R} {s : finset ι} (hfs : separable (finset.prod s fun (i : ι) => X - coe_fn C (f i))) {x : ι} {y : ι} (hx : x ∈ s) (hy : y ∈ s) (hfxy : f x = f y) : x = y := sorry\n\ntheorem separable.injective_of_prod_X_sub_C {R : Type u} [comm_ring R] [nontrivial R] {ι : Type u_1} [fintype ι] {f : ι → R} (hfs : separable (finset.prod finset.univ fun (i : ι) => X - coe_fn C (f i))) : function.injective f :=\n  fun (x y : ι) (hfxy : f x = f y) => separable.inj_of_prod_X_sub_C hfs (finset.mem_univ x) (finset.mem_univ y) hfxy\n\ntheorem is_unit_of_self_mul_dvd_separable {R : Type u} [comm_ring R] {p : polynomial R} {q : polynomial R} (hp : separable p) (hq : q * q ∣ p) : is_unit q := sorry\n\ntheorem is_local_ring_hom_expand (R : Type u) [integral_domain R] {p : ℕ} (hp : 0 < p) : is_local_ring_hom ↑(expand R p) := sorry\n\ntheorem separable_iff_derivative_ne_zero {F : Type u} [field F] {f : polynomial F} (hf : irreducible f) : separable f ↔ coe_fn derivative f ≠ 0 := sorry\n\ntheorem separable_map {F : Type u} [field F] {K : Type v} [field K] (f : F →+* K) {p : polynomial F} : separable (map f p) ↔ separable p := sorry\n\n/-- The opposite of `expand`: sends `∑ aₙ xⁿᵖ` to `∑ aₙ xⁿ`. -/\ndef contract {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] (f : polynomial F) : polynomial F :=\n  finsupp.mk (finset.preimage (finsupp.support f) (fun (_x : ℕ) => _x * p) sorry) (fun (n : ℕ) => coeff f (n * p)) sorry\n\ntheorem coeff_contract {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] (f : polynomial F) (n : ℕ) : coeff (contract p f) n = coeff f (n * p) :=\n  rfl\n\ntheorem of_irreducible_expand {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] {f : polynomial F} (hf : irreducible (coe_fn (expand F p) f)) : irreducible f :=\n  of_irreducible_map (↑(expand F p)) hf\n\ntheorem of_irreducible_expand_pow {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] {f : polynomial F} {n : ℕ} : irreducible (coe_fn (expand F (p ^ n)) f) → irreducible f := sorry\n\ntheorem expand_char {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] [HF : char_p F p] (f : polynomial F) : map (frobenius F p) (coe_fn (expand F p) f) = f ^ p := sorry\n\ntheorem map_expand_pow_char {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] [HF : char_p F p] (f : polynomial F) (n : ℕ) : map (frobenius F p ^ n) (coe_fn (expand F (p ^ n)) f) = f ^ p ^ n := sorry\n\ntheorem expand_contract {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (hf : coe_fn derivative f = 0) : coe_fn (expand F p) (contract p f) = f := sorry\n\ntheorem separable_or {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (hf : irreducible f) : separable f ∨ ¬separable f ∧ ∃ (g : polynomial F), irreducible g ∧ coe_fn (expand F p) g = f := sorry\n\ntheorem exists_separable_of_irreducible {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (hf : irreducible f) (hf0 : f ≠ 0) : ∃ (n : ℕ), ∃ (g : polynomial F), separable g ∧ coe_fn (expand F (p ^ n)) g = f := sorry\n\ntheorem is_unit_or_eq_zero_of_separable_expand {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (n : ℕ) (hf : separable (coe_fn (expand F (p ^ n)) f)) : is_unit f ∨ n = 0 := sorry\n\ntheorem unique_separable_of_irreducible {F : Type u} [field F] (p : ℕ) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (hf : irreducible f) (hf0 : f ≠ 0) (n₁ : ℕ) (g₁ : polynomial F) (hg₁ : separable g₁) (hgf₁ : coe_fn (expand F (p ^ n₁)) g₁ = f) (n₂ : ℕ) (g₂ : polynomial F) (hg₂ : separable g₂) (hgf₂ : coe_fn (expand F (p ^ n₂)) g₂ = f) : n₁ = n₂ ∧ g₁ = g₂ := sorry\n\ntheorem separable_prod_X_sub_C_iff' {F : Type u} [field F] {ι : Type u_1} {f : ι → F} {s : finset ι} : separable (finset.prod s fun (i : ι) => X - coe_fn C (f i)) ↔ ∀ (x : ι), x ∈ s → ∀ (y : ι), y ∈ s → f x = f y → x = y := sorry\n\ntheorem separable_prod_X_sub_C_iff {F : Type u} [field F] {ι : Type u_1} [fintype ι] {f : ι → F} : separable (finset.prod finset.univ fun (i : ι) => X - coe_fn C (f i)) ↔ function.injective f := sorry\n\ntheorem not_unit_X_sub_C {F : Type u} [field F] (a : F) : ¬is_unit (X - coe_fn C a) := sorry\n\ntheorem nodup_of_separable_prod {F : Type u} [field F] {s : multiset F} (hs : separable (multiset.prod (multiset.map (fun (a : F) => X - coe_fn C a) s))) : multiset.nodup s := sorry\n\ntheorem multiplicity_le_one_of_separable {F : Type u} [field F] {p : polynomial F} {q : polynomial F} (hq : ¬is_unit q) (hsep : separable p) : multiplicity q p ≤ 1 := sorry\n\ntheorem separable.squarefree {F : Type u} [field F] {p : polynomial F} (hsep : separable p) : squarefree p := sorry\n\n/--If `n ≠ 0` in `F`, then ` X ^ n - a` is separable for any `a ≠ 0`. -/\ntheorem separable_X_pow_sub_C {F : Type u} [field F] {n : ℕ} (a : F) (hn : ↑n ≠ 0) (ha : a ≠ 0) : separable (X ^ n - coe_fn C a) := sorry\n\n/--If `n ≠ 0` in `F`, then ` X ^ n - a` is squarefree for any `a ≠ 0`. -/\ntheorem squarefree_X_pow_sub_C {F : Type u} [field F] {n : ℕ} (a : F) (hn : ↑n ≠ 0) (ha : a ≠ 0) : squarefree (X ^ n - coe_fn C a) :=\n  separable.squarefree (separable_X_pow_sub_C a hn ha)\n\ntheorem root_multiplicity_le_one_of_separable {F : Type u} [field F] {p : polynomial F} (hp : p ≠ 0) (hsep : separable p) (x : F) : root_multiplicity x p ≤ 1 := sorry\n\ntheorem count_roots_le_one {F : Type u} [field F] {p : polynomial F} (hsep : separable p) (x : F) : multiset.count x (roots p) ≤ 1 := sorry\n\ntheorem nodup_roots {F : Type u} [field F] {p : polynomial F} (hsep : separable p) : multiset.nodup (roots p) :=\n  iff.mpr multiset.nodup_iff_count_le_one (count_roots_le_one hsep)\n\ntheorem eq_X_sub_C_of_separable_of_root_eq {F : Type u} [field F] {K : Type v} [field K] {i : F →+* K} {x : F} {h : polynomial F} (h_ne_zero : h ≠ 0) (h_sep : separable h) (h_root : eval x h = 0) (h_splits : splits i h) (h_roots : ∀ (y : K), y ∈ roots (map i h) → y = coe_fn i x) : h = coe_fn C (leading_coeff h) * (X - coe_fn C x) := sorry\n\nend polynomial\n\n\ntheorem irreducible.separable {F : Type u} [field F] [char_zero F] {f : polynomial F} (hf : irreducible f) : polynomial.separable f := sorry\n\n-- TODO: refactor to allow transcendental extensions?\n\n-- See: https://en.wikipedia.org/wiki/Separable_extension#Separability_of_transcendental_extensions\n\n/-- Typeclass for separable field extension: `K` is a separable field extension of `F` iff\nthe minimal polynomial of every `x : K` is separable. -/\ndef is_separable (F : Type u_1) (K : Type u_2) [field F] [field K] [algebra F K] :=\n  ∀ (x : K), is_integral F x ∧ polynomial.separable (minpoly F x)\n\nprotected instance is_separable_self (F : Type u_1) [field F] : is_separable F F :=\n  fun (x : F) =>\n    { left := is_integral_algebra_map,\n      right :=\n        eq.mpr (id (Eq._oldrec (Eq.refl (polynomial.separable (minpoly F x))) (minpoly.eq_X_sub_C' x)))\n          polynomial.separable_X_sub_C }\n\ntheorem is_separable_tower_top_of_is_separable (F : Type u_1) (K : Type u_2) (E : Type u_3) [field F] [field K] [field E] [algebra F K] [algebra F E] [algebra K E] [is_scalar_tower F K E] [h : is_separable F E] : is_separable K E := sorry\n\ntheorem is_separable_tower_bot_of_is_separable (F : Type u_1) (K : Type u_2) (E : Type u_3) [field F] [field K] [field E] [algebra F K] [algebra F E] [algebra K E] [is_scalar_tower F K E] [h : is_separable F E] : is_separable F K := sorry\n\ntheorem is_separable.of_alg_hom (F : Type u_1) {E : Type u_3} [field F] [field E] [algebra F E] (E' : Type u_2) [field E'] [algebra F E'] (f : alg_hom F E E') [is_separable F E'] : is_separable F E :=\n  let _inst : algebra E E' := ring_hom.to_algebra (alg_hom.to_ring_hom f);\n  is_separable_tower_bot_of_is_separable F E E'\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/field_theory/separable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.4927481199145544}}
{"text": "namespace Ex1\n\nmutual\ndef h (c : Nat) (x : Nat) := match g c x c c with\n  | 0 => 1\n  | r => r + 2\ndef g (c : Nat) (t : Nat) (a b : Nat) : Nat := match t with\n  | (n+1) => match g c n a b with\n    | 0 => 0\n    | m => match g c (n - m) a b with\n      | 0 => 0\n      | m + 1 => g c m a b\n  | 0 => f c 0\ndef f (c : Nat) (x : Nat) := match h c x with\n  | 0 => 1\n  | r => f c r\nend\ntermination_by\n  g x a b => 0\n  f c x => 0\n  h c x => 0\ndecreasing_by sorry\n\nattribute [simp] g\nattribute [simp] h\nattribute [simp] f\n\n#check g._eq_1\n#check g._eq_2\n\n#check h._eq_1\n\n#check f._eq_1\n\nend Ex1\n\nnamespace Ex2\n\ndef g (t : Nat) : Nat := match t with\n  | (n+1) => match g n with\n    | 0 => 0\n    | m + 1 => match g (n - m) with\n      | 0 => 0\n      | m + 1 => g n\n  | 0 => 0\ntermination_by' sorry\ndecreasing_by sorry\n\ntheorem ex1 : g 0 = 0 := by\n  rw [g]\n\n#check g._eq_1\n#check g._eq_2\n\ntheorem ex2 : g 0 = 0 := by\n  unfold g\n  simp\n\n#check g._unfold\n\n\nend Ex2\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/nestedWF.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.640635861701035, "lm_q1q2_score": 0.49270038039304226}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.functor.epi_mono\n! leanprover-community/mathlib commit ef7acf407d265ad4081c8998687e994fa80ba70c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.EpiMono\nimport Mathbin.CategoryTheory.Limits.Shapes.StrongEpi\nimport Mathbin.CategoryTheory.LiftingProperties.Adjunction\n\n/-!\n# Preservation and reflection of monomorphisms and epimorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe provide typeclasses that state that a functor preserves or reflects monomorphisms or\nepimorphisms.\n-/\n\n\nopen CategoryTheory\n\nuniverse v₁ v₂ v₃ u₁ u₂ u₃\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] {E : Type u₃}\n  [Category.{v₃} E]\n\n#print CategoryTheory.Functor.PreservesMonomorphisms /-\n/-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/\nclass PreservesMonomorphisms (F : C ⥤ D) : Prop where\n  preserves : ∀ {X Y : C} (f : X ⟶ Y) [Mono f], Mono (F.map f)\n#align category_theory.functor.preserves_monomorphisms CategoryTheory.Functor.PreservesMonomorphisms\n-/\n\n/- warning: category_theory.functor.map_mono -> CategoryTheory.Functor.map_mono is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.PreservesMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_5 : CategoryTheory.Mono.{u1, u3} C _inst_1 X Y f], CategoryTheory.Mono.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.PreservesMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_5 : CategoryTheory.Mono.{u1, u3} C _inst_1 X Y f], CategoryTheory.Mono.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_mono CategoryTheory.Functor.map_monoₓ'. -/\ninstance map_mono (F : C ⥤ D) [PreservesMonomorphisms F] {X Y : C} (f : X ⟶ Y) [Mono f] :\n    Mono (F.map f) :=\n  PreservesMonomorphisms.preserves f\n#align category_theory.functor.map_mono CategoryTheory.Functor.map_mono\n\n#print CategoryTheory.Functor.PreservesEpimorphisms /-\n/-- A functor preserves epimorphisms if it maps epimorphisms to epimorphisms. -/\nclass PreservesEpimorphisms (F : C ⥤ D) : Prop where\n  preserves : ∀ {X Y : C} (f : X ⟶ Y) [Epi f], Epi (F.map f)\n#align category_theory.functor.preserves_epimorphisms CategoryTheory.Functor.PreservesEpimorphisms\n-/\n\n/- warning: category_theory.functor.map_epi -> CategoryTheory.Functor.map_epi is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.PreservesEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_5 : CategoryTheory.Epi.{u1, u3} C _inst_1 X Y f], CategoryTheory.Epi.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.PreservesEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_5 : CategoryTheory.Epi.{u1, u3} C _inst_1 X Y f], CategoryTheory.Epi.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_epi CategoryTheory.Functor.map_epiₓ'. -/\ninstance map_epi (F : C ⥤ D) [PreservesEpimorphisms F] {X Y : C} (f : X ⟶ Y) [Epi f] :\n    Epi (F.map f) :=\n  PreservesEpimorphisms.preserves f\n#align category_theory.functor.map_epi CategoryTheory.Functor.map_epi\n\n#print CategoryTheory.Functor.ReflectsMonomorphisms /-\n/-- A functor reflects monomorphisms if morphisms that are mapped to monomorphisms are themselves\n    monomorphisms. -/\nclass ReflectsMonomorphisms (F : C ⥤ D) : Prop where\n  reflects : ∀ {X Y : C} (f : X ⟶ Y), Mono (F.map f) → Mono f\n#align category_theory.functor.reflects_monomorphisms CategoryTheory.Functor.ReflectsMonomorphisms\n-/\n\n/- warning: category_theory.functor.mono_of_mono_map -> CategoryTheory.Functor.mono_of_mono_map is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.ReflectsMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y}, (CategoryTheory.Mono.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)) -> (CategoryTheory.Mono.{u1, u3} C _inst_1 X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.ReflectsMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y}, (CategoryTheory.Mono.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)) -> (CategoryTheory.Mono.{u1, u3} C _inst_1 X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.mono_of_mono_map CategoryTheory.Functor.mono_of_mono_mapₓ'. -/\ntheorem mono_of_mono_map (F : C ⥤ D) [ReflectsMonomorphisms F] {X Y : C} {f : X ⟶ Y}\n    (h : Mono (F.map f)) : Mono f :=\n  ReflectsMonomorphisms.reflects f h\n#align category_theory.functor.mono_of_mono_map CategoryTheory.Functor.mono_of_mono_map\n\n#print CategoryTheory.Functor.ReflectsEpimorphisms /-\n/-- A functor reflects epimorphisms if morphisms that are mapped to epimorphisms are themselves\n    epimorphisms. -/\nclass ReflectsEpimorphisms (F : C ⥤ D) : Prop where\n  reflects : ∀ {X Y : C} (f : X ⟶ Y), Epi (F.map f) → Epi f\n#align category_theory.functor.reflects_epimorphisms CategoryTheory.Functor.ReflectsEpimorphisms\n-/\n\n/- warning: category_theory.functor.epi_of_epi_map -> CategoryTheory.Functor.epi_of_epi_map is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.ReflectsEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y}, (CategoryTheory.Epi.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)) -> (CategoryTheory.Epi.{u1, u3} C _inst_1 X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_4 : CategoryTheory.Functor.ReflectsEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y}, (CategoryTheory.Epi.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)) -> (CategoryTheory.Epi.{u1, u3} C _inst_1 X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.epi_of_epi_map CategoryTheory.Functor.epi_of_epi_mapₓ'. -/\ntheorem epi_of_epi_map (F : C ⥤ D) [ReflectsEpimorphisms F] {X Y : C} {f : X ⟶ Y}\n    (h : Epi (F.map f)) : Epi f :=\n  ReflectsEpimorphisms.reflects f h\n#align category_theory.functor.epi_of_epi_map CategoryTheory.Functor.epi_of_epi_map\n\n#print CategoryTheory.Functor.preservesMonomorphisms_comp /-\ninstance preservesMonomorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [PreservesMonomorphisms F]\n    [PreservesMonomorphisms G] : PreservesMonomorphisms (F ⋙ G)\n    where preserves X Y f h := by\n    rw [comp_map]\n    exact inferInstance\n#align category_theory.functor.preserves_monomorphisms_comp CategoryTheory.Functor.preservesMonomorphisms_comp\n-/\n\n#print CategoryTheory.Functor.preservesEpimorphisms_comp /-\ninstance preservesEpimorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [PreservesEpimorphisms F]\n    [PreservesEpimorphisms G] : PreservesEpimorphisms (F ⋙ G)\n    where preserves X Y f h := by\n    rw [comp_map]\n    exact inferInstance\n#align category_theory.functor.preserves_epimorphisms_comp CategoryTheory.Functor.preservesEpimorphisms_comp\n-/\n\n#print CategoryTheory.Functor.reflectsMonomorphisms_comp /-\ninstance reflectsMonomorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [ReflectsMonomorphisms F]\n    [ReflectsMonomorphisms G] : ReflectsMonomorphisms (F ⋙ G)\n    where reflects X Y f h := F.mono_of_mono_map (G.mono_of_mono_map h)\n#align category_theory.functor.reflects_monomorphisms_comp CategoryTheory.Functor.reflectsMonomorphisms_comp\n-/\n\n#print CategoryTheory.Functor.reflectsEpimorphisms_comp /-\ninstance reflectsEpimorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [ReflectsEpimorphisms F]\n    [ReflectsEpimorphisms G] : ReflectsEpimorphisms (F ⋙ G)\n    where reflects X Y f h := F.epi_of_epi_map (G.epi_of_epi_map h)\n#align category_theory.functor.reflects_epimorphisms_comp CategoryTheory.Functor.reflectsEpimorphisms_comp\n-/\n\n#print CategoryTheory.Functor.preservesEpimorphisms_of_preserves_of_reflects /-\ntheorem preservesEpimorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)\n    [PreservesEpimorphisms (F ⋙ G)] [ReflectsEpimorphisms G] : PreservesEpimorphisms F :=\n  ⟨fun X Y f hf => G.epi_of_epi_map <| show Epi ((F ⋙ G).map f) from inferInstance⟩\n#align category_theory.functor.preserves_epimorphisms_of_preserves_of_reflects CategoryTheory.Functor.preservesEpimorphisms_of_preserves_of_reflects\n-/\n\n#print CategoryTheory.Functor.preservesMonomorphisms_of_preserves_of_reflects /-\ntheorem preservesMonomorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)\n    [PreservesMonomorphisms (F ⋙ G)] [ReflectsMonomorphisms G] : PreservesMonomorphisms F :=\n  ⟨fun X Y f hf => G.mono_of_mono_map <| show Mono ((F ⋙ G).map f) from inferInstance⟩\n#align category_theory.functor.preserves_monomorphisms_of_preserves_of_reflects CategoryTheory.Functor.preservesMonomorphisms_of_preserves_of_reflects\n-/\n\n#print CategoryTheory.Functor.reflectsEpimorphisms_of_preserves_of_reflects /-\ntheorem reflectsEpimorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)\n    [PreservesEpimorphisms G] [ReflectsEpimorphisms (F ⋙ G)] : ReflectsEpimorphisms F :=\n  ⟨fun X Y f hf => (F ⋙ G).epi_of_epi_map <| show Epi (G.map (F.map f)) from inferInstance⟩\n#align category_theory.functor.reflects_epimorphisms_of_preserves_of_reflects CategoryTheory.Functor.reflectsEpimorphisms_of_preserves_of_reflects\n-/\n\n#print CategoryTheory.Functor.reflectsMonomorphisms_of_preserves_of_reflects /-\ntheorem reflectsMonomorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)\n    [PreservesMonomorphisms G] [ReflectsMonomorphisms (F ⋙ G)] : ReflectsMonomorphisms F :=\n  ⟨fun X Y f hf => (F ⋙ G).mono_of_mono_map <| show Mono (G.map (F.map f)) from inferInstance⟩\n#align category_theory.functor.reflects_monomorphisms_of_preserves_of_reflects CategoryTheory.Functor.reflectsMonomorphisms_of_preserves_of_reflects\n-/\n\n#print CategoryTheory.Functor.preservesMonomorphisms.of_iso /-\ntheorem preservesMonomorphisms.of_iso {F G : C ⥤ D} [PreservesMonomorphisms F] (α : F ≅ G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun X Y f h =>\n      by\n      haveI : mono (F.map f ≫ (α.app Y).Hom) := mono_comp _ _\n      convert(mono_comp _ _ : mono ((α.app X).inv ≫ F.map f ≫ (α.app Y).Hom))\n      rw [iso.eq_inv_comp, iso.app_hom, iso.app_hom, nat_trans.naturality] }\n#align category_theory.functor.preserves_monomorphisms.of_iso CategoryTheory.Functor.preservesMonomorphisms.of_iso\n-/\n\n#print CategoryTheory.Functor.preservesMonomorphisms.iso_iff /-\ntheorem preservesMonomorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    PreservesMonomorphisms F ↔ PreservesMonomorphisms G :=\n  ⟨fun h => preserves_monomorphisms.of_iso α, fun h => preserves_monomorphisms.of_iso α.symm⟩\n#align category_theory.functor.preserves_monomorphisms.iso_iff CategoryTheory.Functor.preservesMonomorphisms.iso_iff\n-/\n\n#print CategoryTheory.Functor.preservesEpimorphisms.of_iso /-\ntheorem preservesEpimorphisms.of_iso {F G : C ⥤ D} [PreservesEpimorphisms F] (α : F ≅ G) :\n    PreservesEpimorphisms G :=\n  {\n    preserves := fun X Y f h =>\n      by\n      haveI : epi (F.map f ≫ (α.app Y).Hom) := epi_comp _ _\n      convert(epi_comp _ _ : epi ((α.app X).inv ≫ F.map f ≫ (α.app Y).Hom))\n      rw [iso.eq_inv_comp, iso.app_hom, iso.app_hom, nat_trans.naturality] }\n#align category_theory.functor.preserves_epimorphisms.of_iso CategoryTheory.Functor.preservesEpimorphisms.of_iso\n-/\n\n#print CategoryTheory.Functor.preservesEpimorphisms.iso_iff /-\ntheorem preservesEpimorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    PreservesEpimorphisms F ↔ PreservesEpimorphisms G :=\n  ⟨fun h => preserves_epimorphisms.of_iso α, fun h => preserves_epimorphisms.of_iso α.symm⟩\n#align category_theory.functor.preserves_epimorphisms.iso_iff CategoryTheory.Functor.preservesEpimorphisms.iso_iff\n-/\n\n#print CategoryTheory.Functor.reflectsMonomorphisms.of_iso /-\ntheorem reflectsMonomorphisms.of_iso {F G : C ⥤ D} [ReflectsMonomorphisms F] (α : F ≅ G) :\n    ReflectsMonomorphisms G :=\n  {\n    reflects := fun X Y f h => by\n      apply F.mono_of_mono_map\n      haveI : mono (G.map f ≫ (α.app Y).inv) := mono_comp _ _\n      convert(mono_comp _ _ : mono ((α.app X).Hom ≫ G.map f ≫ (α.app Y).inv))\n      rw [← category.assoc, iso.eq_comp_inv, iso.app_hom, iso.app_hom, nat_trans.naturality] }\n#align category_theory.functor.reflects_monomorphisms.of_iso CategoryTheory.Functor.reflectsMonomorphisms.of_iso\n-/\n\n#print CategoryTheory.Functor.reflectsMonomorphisms.iso_iff /-\ntheorem reflectsMonomorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    ReflectsMonomorphisms F ↔ ReflectsMonomorphisms G :=\n  ⟨fun h => reflects_monomorphisms.of_iso α, fun h => reflects_monomorphisms.of_iso α.symm⟩\n#align category_theory.functor.reflects_monomorphisms.iso_iff CategoryTheory.Functor.reflectsMonomorphisms.iso_iff\n-/\n\n#print CategoryTheory.Functor.reflectsEpimorphisms.of_iso /-\ntheorem reflectsEpimorphisms.of_iso {F G : C ⥤ D} [ReflectsEpimorphisms F] (α : F ≅ G) :\n    ReflectsEpimorphisms G :=\n  {\n    reflects := fun X Y f h => by\n      apply F.epi_of_epi_map\n      haveI : epi (G.map f ≫ (α.app Y).inv) := epi_comp _ _\n      convert(epi_comp _ _ : epi ((α.app X).Hom ≫ G.map f ≫ (α.app Y).inv))\n      rw [← category.assoc, iso.eq_comp_inv, iso.app_hom, iso.app_hom, nat_trans.naturality] }\n#align category_theory.functor.reflects_epimorphisms.of_iso CategoryTheory.Functor.reflectsEpimorphisms.of_iso\n-/\n\n#print CategoryTheory.Functor.reflectsEpimorphisms.iso_iff /-\ntheorem reflectsEpimorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    ReflectsEpimorphisms F ↔ ReflectsEpimorphisms G :=\n  ⟨fun h => reflects_epimorphisms.of_iso α, fun h => reflects_epimorphisms.of_iso α.symm⟩\n#align category_theory.functor.reflects_epimorphisms.iso_iff CategoryTheory.Functor.reflectsEpimorphisms.iso_iff\n-/\n\n#print CategoryTheory.Functor.preservesEpimorphsisms_of_adjunction /-\ntheorem preservesEpimorphsisms_of_adjunction {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :\n    PreservesEpimorphisms F :=\n  {\n    preserves := fun X Y f hf =>\n      ⟨by\n        intro Z g h H\n        replace H := congr_arg (adj.hom_equiv X Z) H\n        rwa [adj.hom_equiv_naturality_left, adj.hom_equiv_naturality_left, cancel_epi,\n          Equiv.apply_eq_iff_eq] at H⟩ }\n#align category_theory.functor.preserves_epimorphsisms_of_adjunction CategoryTheory.Functor.preservesEpimorphsisms_of_adjunction\n-/\n\n#print CategoryTheory.Functor.preservesEpimorphisms_of_isLeftAdjoint /-\ninstance (priority := 100) preservesEpimorphisms_of_isLeftAdjoint (F : C ⥤ D) [IsLeftAdjoint F] :\n    PreservesEpimorphisms F :=\n  preservesEpimorphsisms_of_adjunction (Adjunction.ofLeftAdjoint F)\n#align category_theory.functor.preserves_epimorphisms_of_is_left_adjoint CategoryTheory.Functor.preservesEpimorphisms_of_isLeftAdjoint\n-/\n\n#print CategoryTheory.Functor.preservesMonomorphisms_of_adjunction /-\ntheorem preservesMonomorphisms_of_adjunction {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun X Y f hf =>\n      ⟨by\n        intro Z g h H\n        replace H := congr_arg (adj.hom_equiv Z Y).symm H\n        rwa [adj.hom_equiv_naturality_right_symm, adj.hom_equiv_naturality_right_symm, cancel_mono,\n          Equiv.apply_eq_iff_eq] at H⟩ }\n#align category_theory.functor.preserves_monomorphisms_of_adjunction CategoryTheory.Functor.preservesMonomorphisms_of_adjunction\n-/\n\n#print CategoryTheory.Functor.preservesMonomorphisms_of_isRightAdjoint /-\ninstance (priority := 100) preservesMonomorphisms_of_isRightAdjoint (F : C ⥤ D) [IsRightAdjoint F] :\n    PreservesMonomorphisms F :=\n  preservesMonomorphisms_of_adjunction (Adjunction.ofRightAdjoint F)\n#align category_theory.functor.preserves_monomorphisms_of_is_right_adjoint CategoryTheory.Functor.preservesMonomorphisms_of_isRightAdjoint\n-/\n\n#print CategoryTheory.Functor.reflectsMonomorphisms_of_faithful /-\ninstance (priority := 100) reflectsMonomorphisms_of_faithful (F : C ⥤ D) [Faithful F] :\n    ReflectsMonomorphisms F\n    where reflects X Y f hf :=\n    ⟨fun Z g h hgh =>\n      F.map_injective ((cancel_mono (F.map f)).1 (by rw [← F.map_comp, hgh, F.map_comp]))⟩\n#align category_theory.functor.reflects_monomorphisms_of_faithful CategoryTheory.Functor.reflectsMonomorphisms_of_faithful\n-/\n\n#print CategoryTheory.Functor.reflectsEpimorphisms_of_faithful /-\ninstance (priority := 100) reflectsEpimorphisms_of_faithful (F : C ⥤ D) [Faithful F] :\n    ReflectsEpimorphisms F\n    where reflects X Y f hf :=\n    ⟨fun Z g h hgh =>\n      F.map_injective ((cancel_epi (F.map f)).1 (by rw [← F.map_comp, hgh, F.map_comp]))⟩\n#align category_theory.functor.reflects_epimorphisms_of_faithful CategoryTheory.Functor.reflectsEpimorphisms_of_faithful\n-/\n\nsection\n\nvariable (F : C ⥤ D) {X Y : C} (f : X ⟶ Y)\n\n/- warning: category_theory.functor.split_epi_equiv -> CategoryTheory.Functor.splitEpiEquiv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Equiv.{succ u1, succ u2} (CategoryTheory.SplitEpi.{u1, u3} C _inst_1 X Y f) (CategoryTheory.SplitEpi.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Equiv.{succ u1, succ u2} (CategoryTheory.SplitEpi.{u1, u3} C _inst_1 X Y f) (CategoryTheory.SplitEpi.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.split_epi_equiv CategoryTheory.Functor.splitEpiEquivₓ'. -/\n/-- If `F` is a fully faithful functor, split epimorphisms are preserved and reflected by `F`. -/\ndef splitEpiEquiv [Full F] [Faithful F] : SplitEpi f ≃ SplitEpi (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' ⟨F.preimage s.section_, _⟩\n    apply F.map_injective\n    simp only [map_comp, image_preimage, map_id]\n    apply split_epi.id\n  left_inv := by tidy\n  right_inv := by tidy\n#align category_theory.functor.split_epi_equiv CategoryTheory.Functor.splitEpiEquiv\n\n/- warning: category_theory.functor.is_split_epi_iff -> CategoryTheory.Functor.isSplitEpi_iff is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.IsSplitEpi.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)) (CategoryTheory.IsSplitEpi.{u1, u3} C _inst_1 X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.IsSplitEpi.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)) (CategoryTheory.IsSplitEpi.{u1, u3} C _inst_1 X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.is_split_epi_iff CategoryTheory.Functor.isSplitEpi_iffₓ'. -/\n@[simp]\ntheorem isSplitEpi_iff [Full F] [Faithful F] : IsSplitEpi (F.map f) ↔ IsSplitEpi f :=\n  by\n  constructor\n  · intro h\n    exact is_split_epi.mk' ((split_epi_equiv F f).invFun h.exists_split_epi.some)\n  · intro h\n    exact is_split_epi.mk' ((split_epi_equiv F f).toFun h.exists_split_epi.some)\n#align category_theory.functor.is_split_epi_iff CategoryTheory.Functor.isSplitEpi_iff\n\n/- warning: category_theory.functor.split_mono_equiv -> CategoryTheory.Functor.splitMonoEquiv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Equiv.{succ u1, succ u2} (CategoryTheory.SplitMono.{u1, u3} C _inst_1 X Y f) (CategoryTheory.SplitMono.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Equiv.{succ u1, succ u2} (CategoryTheory.SplitMono.{u1, u3} C _inst_1 X Y f) (CategoryTheory.SplitMono.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.split_mono_equiv CategoryTheory.Functor.splitMonoEquivₓ'. -/\n/-- If `F` is a fully faithful functor, split monomorphisms are preserved and reflected by `F`. -/\ndef splitMonoEquiv [Full F] [Faithful F] : SplitMono f ≃ SplitMono (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' ⟨F.preimage s.retraction, _⟩\n    apply F.map_injective\n    simp only [map_comp, image_preimage, map_id]\n    apply split_mono.id\n  left_inv := by tidy\n  right_inv := by tidy\n#align category_theory.functor.split_mono_equiv CategoryTheory.Functor.splitMonoEquiv\n\n/- warning: category_theory.functor.is_split_mono_iff -> CategoryTheory.Functor.isSplitMono_iff is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.IsSplitMono.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)) (CategoryTheory.IsSplitMono.{u1, u3} C _inst_1 X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [_inst_4 : CategoryTheory.Full.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [_inst_5 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.IsSplitMono.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)) (CategoryTheory.IsSplitMono.{u1, u3} C _inst_1 X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.is_split_mono_iff CategoryTheory.Functor.isSplitMono_iffₓ'. -/\n@[simp]\ntheorem isSplitMono_iff [Full F] [Faithful F] : IsSplitMono (F.map f) ↔ IsSplitMono f :=\n  by\n  constructor\n  · intro h\n    exact is_split_mono.mk' ((split_mono_equiv F f).invFun h.exists_split_mono.some)\n  · intro h\n    exact is_split_mono.mk' ((split_mono_equiv F f).toFun h.exists_split_mono.some)\n#align category_theory.functor.is_split_mono_iff CategoryTheory.Functor.isSplitMono_iff\n\n/- warning: category_theory.functor.epi_map_iff_epi -> CategoryTheory.Functor.epi_map_iff_epi is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [hF₁ : CategoryTheory.Functor.PreservesEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF₂ : CategoryTheory.Functor.ReflectsEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.Epi.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)) (CategoryTheory.Epi.{u1, u3} C _inst_1 X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [hF₁ : CategoryTheory.Functor.PreservesEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF₂ : CategoryTheory.Functor.ReflectsEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.Epi.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)) (CategoryTheory.Epi.{u1, u3} C _inst_1 X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.epi_map_iff_epi CategoryTheory.Functor.epi_map_iff_epiₓ'. -/\n@[simp]\ntheorem epi_map_iff_epi [hF₁ : PreservesEpimorphisms F] [hF₂ : ReflectsEpimorphisms F] :\n    Epi (F.map f) ↔ Epi f := by\n  constructor\n  · exact F.epi_of_epi_map\n  · intro h\n    exact F.map_epi f\n#align category_theory.functor.epi_map_iff_epi CategoryTheory.Functor.epi_map_iff_epi\n\n/- warning: category_theory.functor.mono_map_iff_mono -> CategoryTheory.Functor.mono_map_iff_mono is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [hF₁ : CategoryTheory.Functor.PreservesMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF₂ : CategoryTheory.Functor.ReflectsMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.Mono.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f)) (CategoryTheory.Mono.{u1, u3} C _inst_1 X Y f)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) [hF₁ : CategoryTheory.Functor.PreservesMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF₂ : CategoryTheory.Functor.ReflectsMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F], Iff (CategoryTheory.Mono.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f)) (CategoryTheory.Mono.{u1, u3} C _inst_1 X Y f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.mono_map_iff_mono CategoryTheory.Functor.mono_map_iff_monoₓ'. -/\n@[simp]\ntheorem mono_map_iff_mono [hF₁ : PreservesMonomorphisms F] [hF₂ : ReflectsMonomorphisms F] :\n    Mono (F.map f) ↔ Mono f := by\n  constructor\n  · exact F.mono_of_mono_map\n  · intro h\n    exact F.map_mono f\n#align category_theory.functor.mono_map_iff_mono CategoryTheory.Functor.mono_map_iff_mono\n\n#print CategoryTheory.Functor.splitEpiCategoryImpOfIsEquivalence /-\n/-- If `F : C ⥤ D` is an equivalence of categories and `C` is a `split_epi_category`,\nthen `D` also is. -/\ndef splitEpiCategoryImpOfIsEquivalence [IsEquivalence F] [SplitEpiCategory C] :\n    SplitEpiCategory D :=\n  ⟨fun X Y f => by\n    intro\n    rw [← F.inv.is_split_epi_iff f]\n    apply is_split_epi_of_epi⟩\n#align category_theory.functor.split_epi_category_imp_of_is_equivalence CategoryTheory.Functor.splitEpiCategoryImpOfIsEquivalence\n-/\n\nend\n\nend CategoryTheory.Functor\n\nnamespace CategoryTheory.Adjunction\n\nvariable {C D : Type _} [Category C] [Category D] {F : C ⥤ D} {F' : D ⥤ C} {A B : C}\n\n/- warning: category_theory.adjunction.strong_epi_map_of_strong_epi -> CategoryTheory.Adjunction.strongEpi_map_of_strongEpi is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u1}} {D : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u3, u1} C] [_inst_2 : CategoryTheory.Category.{u4, u2} D] {F : CategoryTheory.Functor.{u3, u4, u1, u2} C _inst_1 D _inst_2} {F' : CategoryTheory.Functor.{u4, u3, u2, u1} D _inst_2 C _inst_1} {A : C} {B : C}, (CategoryTheory.Adjunction.{u3, u4, u1, u2} C _inst_1 D _inst_2 F F') -> (forall (f : Quiver.Hom.{succ u3, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} C (CategoryTheory.Category.toCategoryStruct.{u3, u1} C _inst_1)) A B) [h₁ : CategoryTheory.Functor.PreservesMonomorphisms.{u4, u3, u2, u1} D _inst_2 C _inst_1 F'] [h₂ : CategoryTheory.Functor.PreservesEpimorphisms.{u3, u4, u1, u2} C _inst_1 D _inst_2 F] [_inst_3 : CategoryTheory.StrongEpi.{u3, u1} C _inst_1 A B f], CategoryTheory.StrongEpi.{u4, u2} D _inst_2 (CategoryTheory.Functor.obj.{u3, u4, u1, u2} C _inst_1 D _inst_2 F A) (CategoryTheory.Functor.obj.{u3, u4, u1, u2} C _inst_1 D _inst_2 F B) (CategoryTheory.Functor.map.{u3, u4, u1, u2} C _inst_1 D _inst_2 F A B f))\nbut is expected to have type\n  forall {C : Type.{u2}} {D : Type.{u1}} [_inst_1 : CategoryTheory.Category.{u4, u2} C] [_inst_2 : CategoryTheory.Category.{u3, u1} D] {F : CategoryTheory.Functor.{u4, u3, u2, u1} C _inst_1 D _inst_2} {F' : CategoryTheory.Functor.{u3, u4, u1, u2} D _inst_2 C _inst_1} {A : C} {B : C}, (CategoryTheory.Adjunction.{u4, u3, u2, u1} C _inst_1 D _inst_2 F F') -> (forall (f : Quiver.Hom.{succ u4, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) A B) [h₁ : CategoryTheory.Functor.PreservesMonomorphisms.{u3, u4, u1, u2} D _inst_2 C _inst_1 F'] [h₂ : CategoryTheory.Functor.PreservesEpimorphisms.{u4, u3, u2, u1} C _inst_1 D _inst_2 F] [_inst_3 : CategoryTheory.StrongEpi.{u4, u2} C _inst_1 A B f], CategoryTheory.StrongEpi.{u3, u1} D _inst_2 (Prefunctor.obj.{succ u4, succ u3, u2, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} D (CategoryTheory.Category.toCategoryStruct.{u3, u1} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u4, u3, u2, u1} C _inst_1 D _inst_2 F) A) (Prefunctor.obj.{succ u4, succ u3, u2, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} D (CategoryTheory.Category.toCategoryStruct.{u3, u1} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u4, u3, u2, u1} C _inst_1 D _inst_2 F) B) (Prefunctor.map.{succ u4, succ u3, u2, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} D (CategoryTheory.Category.toCategoryStruct.{u3, u1} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u4, u3, u2, u1} C _inst_1 D _inst_2 F) A B f))\nCase conversion may be inaccurate. Consider using '#align category_theory.adjunction.strong_epi_map_of_strong_epi CategoryTheory.Adjunction.strongEpi_map_of_strongEpiₓ'. -/\ntheorem strongEpi_map_of_strongEpi (adj : F ⊣ F') (f : A ⟶ B) [h₁ : F'.PreservesMonomorphisms]\n    [h₂ : F.PreservesEpimorphisms] [StrongEpi f] : StrongEpi (F.map f) :=\n  ⟨inferInstance, fun X Y Z => by\n    intro\n    rw [adj.has_lifting_property_iff]\n    infer_instance⟩\n#align category_theory.adjunction.strong_epi_map_of_strong_epi CategoryTheory.Adjunction.strongEpi_map_of_strongEpi\n\n/- warning: category_theory.adjunction.strong_epi_map_of_is_equivalence -> CategoryTheory.Adjunction.strongEpi_map_of_isEquivalence is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u1}} {D : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u3, u1} C] [_inst_2 : CategoryTheory.Category.{u4, u2} D] {F : CategoryTheory.Functor.{u3, u4, u1, u2} C _inst_1 D _inst_2} {A : C} {B : C} [_inst_3 : CategoryTheory.IsEquivalence.{u3, u4, u1, u2} C _inst_1 D _inst_2 F] (f : Quiver.Hom.{succ u3, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} C (CategoryTheory.Category.toCategoryStruct.{u3, u1} C _inst_1)) A B) [h : CategoryTheory.StrongEpi.{u3, u1} C _inst_1 A B f], CategoryTheory.StrongEpi.{u4, u2} D _inst_2 (CategoryTheory.Functor.obj.{u3, u4, u1, u2} C _inst_1 D _inst_2 F A) (CategoryTheory.Functor.obj.{u3, u4, u1, u2} C _inst_1 D _inst_2 F B) (CategoryTheory.Functor.map.{u3, u4, u1, u2} C _inst_1 D _inst_2 F A B f)\nbut is expected to have type\n  forall {C : Type.{u1}} {D : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u3, u1} C] [_inst_2 : CategoryTheory.Category.{u4, u2} D] {F : CategoryTheory.Functor.{u3, u4, u1, u2} C _inst_1 D _inst_2} {A : C} {B : C} [_inst_3 : CategoryTheory.IsEquivalence.{u3, u4, u1, u2} C _inst_1 D _inst_2 F] (f : Quiver.Hom.{succ u3, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} C (CategoryTheory.Category.toCategoryStruct.{u3, u1} C _inst_1)) A B) [h : CategoryTheory.StrongEpi.{u3, u1} C _inst_1 A B f], CategoryTheory.StrongEpi.{u4, u2} D _inst_2 (Prefunctor.obj.{succ u3, succ u4, u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} C (CategoryTheory.Category.toCategoryStruct.{u3, u1} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} D (CategoryTheory.Category.toCategoryStruct.{u4, u2} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u3, u4, u1, u2} C _inst_1 D _inst_2 F) A) (Prefunctor.obj.{succ u3, succ u4, u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} C (CategoryTheory.Category.toCategoryStruct.{u3, u1} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} D (CategoryTheory.Category.toCategoryStruct.{u4, u2} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u3, u4, u1, u2} C _inst_1 D _inst_2 F) B) (Prefunctor.map.{succ u3, succ u4, u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} C (CategoryTheory.Category.toCategoryStruct.{u3, u1} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} D (CategoryTheory.Category.toCategoryStruct.{u4, u2} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u3, u4, u1, u2} C _inst_1 D _inst_2 F) A B f)\nCase conversion may be inaccurate. Consider using '#align category_theory.adjunction.strong_epi_map_of_is_equivalence CategoryTheory.Adjunction.strongEpi_map_of_isEquivalenceₓ'. -/\ninstance strongEpi_map_of_isEquivalence [IsEquivalence F] (f : A ⟶ B) [h : StrongEpi f] :\n    StrongEpi (F.map f) :=\n  F.asEquivalence.toAdjunction.strongEpi_map_of_strongEpi f\n#align category_theory.adjunction.strong_epi_map_of_is_equivalence CategoryTheory.Adjunction.strongEpi_map_of_isEquivalence\n\nend CategoryTheory.Adjunction\n\nnamespace CategoryTheory.Functor\n\nvariable {C D : Type _} [Category C] [Category D] {F : C ⥤ D} {A B : C} (f : A ⟶ B)\n\n/- warning: category_theory.functor.strong_epi_map_iff_strong_epi_of_is_equivalence -> CategoryTheory.Functor.strongEpi_map_iff_strongEpi_of_isEquivalence is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u1}} {D : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u3, u1} C] [_inst_2 : CategoryTheory.Category.{u4, u2} D] {F : CategoryTheory.Functor.{u3, u4, u1, u2} C _inst_1 D _inst_2} {A : C} {B : C} (f : Quiver.Hom.{succ u3, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} C (CategoryTheory.Category.toCategoryStruct.{u3, u1} C _inst_1)) A B) [_inst_3 : CategoryTheory.IsEquivalence.{u3, u4, u1, u2} C _inst_1 D _inst_2 F], Iff (CategoryTheory.StrongEpi.{u4, u2} D _inst_2 (CategoryTheory.Functor.obj.{u3, u4, u1, u2} C _inst_1 D _inst_2 F A) (CategoryTheory.Functor.obj.{u3, u4, u1, u2} C _inst_1 D _inst_2 F B) (CategoryTheory.Functor.map.{u3, u4, u1, u2} C _inst_1 D _inst_2 F A B f)) (CategoryTheory.StrongEpi.{u3, u1} C _inst_1 A B f)\nbut is expected to have type\n  forall {C : Type.{u2}} {D : Type.{u1}} [_inst_1 : CategoryTheory.Category.{u4, u2} C] [_inst_2 : CategoryTheory.Category.{u3, u1} D] {F : CategoryTheory.Functor.{u4, u3, u2, u1} C _inst_1 D _inst_2} {A : C} {B : C} (f : Quiver.Hom.{succ u4, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) A B) [_inst_3 : CategoryTheory.IsEquivalence.{u4, u3, u2, u1} C _inst_1 D _inst_2 F], Iff (CategoryTheory.StrongEpi.{u3, u1} D _inst_2 (Prefunctor.obj.{succ u4, succ u3, u2, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} D (CategoryTheory.Category.toCategoryStruct.{u3, u1} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u4, u3, u2, u1} C _inst_1 D _inst_2 F) A) (Prefunctor.obj.{succ u4, succ u3, u2, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} D (CategoryTheory.Category.toCategoryStruct.{u3, u1} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u4, u3, u2, u1} C _inst_1 D _inst_2 F) B) (Prefunctor.map.{succ u4, succ u3, u2, u1} C (CategoryTheory.CategoryStruct.toQuiver.{u4, u2} C (CategoryTheory.Category.toCategoryStruct.{u4, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u1} D (CategoryTheory.Category.toCategoryStruct.{u3, u1} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u4, u3, u2, u1} C _inst_1 D _inst_2 F) A B f)) (CategoryTheory.StrongEpi.{u4, u2} C _inst_1 A B f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.strong_epi_map_iff_strong_epi_of_is_equivalence CategoryTheory.Functor.strongEpi_map_iff_strongEpi_of_isEquivalenceₓ'. -/\n@[simp]\ntheorem strongEpi_map_iff_strongEpi_of_isEquivalence [IsEquivalence F] :\n    StrongEpi (F.map f) ↔ StrongEpi f := by\n  constructor\n  · intro\n    have e : arrow.mk f ≅ arrow.mk (F.inv.map (F.map f)) :=\n      arrow.iso_of_nat_iso F.as_equivalence.unit_iso (arrow.mk f)\n    rw [strong_epi.iff_of_arrow_iso e]\n    infer_instance\n  · intro\n    infer_instance\n#align category_theory.functor.strong_epi_map_iff_strong_epi_of_is_equivalence CategoryTheory.Functor.strongEpi_map_iff_strongEpi_of_isEquivalence\n\nend CategoryTheory.Functor\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Functor/EpiMono.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.49270037511627746}}
{"text": "import ring_theory.noetherian\nimport ring_theory.polynomial.basic\nimport ring_theory.adjoin_root\nimport ring_theory.norm\nimport data.zmod.basic\nimport ring_theory.dedekind_domain.ideal\nimport linear_algebra.free_module.finite.basic\nimport ring_theory.class_group\nimport ring_theory.principal_ideal_domain\nimport tactic.slim_check\n.\n\n/-! This is essentially one big for_mathlib file\n-/\n\n/-! # Parity stuff-/\nsection parity\n\n-- @[parity_simps]\nlemma nat.coprime_two_iff_odd (n : ℕ) : n.coprime 2 ↔ ¬ even n :=\nby rw [nat.coprime_comm, nat.prime.coprime_iff_not_dvd nat.prime_two,\n    nat.two_dvd_ne_zero, nat.not_even_iff]\n  -- simp only [nat.two_dvd_ne_zero, nat.not_even_iff] with parity_simps,\n  -- TODO squeeze simp with doesn't remove the with?\n-- @[parity_simps]\nlemma nat.two_coprime_iff_odd (n : ℕ) : (2 : ℕ).coprime n ↔ ¬ even n :=\nby rw [nat.coprime_comm, nat.coprime_two_iff_odd]\n\n@[parity_simps]\nlemma nat.coprime_bit0 (n m : ℕ) : n.coprime (bit0 m) ↔ ¬ even n ∧ n.coprime m :=\nby rw [bit0_eq_two_mul, nat.coprime_mul_iff_right, nat.coprime_two_iff_odd]\n\n@[parity_simps]\nlemma nat.bit0_coprime (n m : ℕ) : (bit0 n).coprime m ↔ ¬ even m ∧ n.coprime m :=\nby rw [nat.coprime_comm, nat.coprime_bit0, nat.coprime_comm]\n\nexample : ¬ (8 : ℕ).coprime 6 := by simp with parity_simps\nexample : (8 : ℕ).coprime 9 := by simp with parity_simps\n\nend parity\n\n\n/-! # zeroness of zmod powers-/\nsection pow_zmod_nat\nvariables {n m : ℕ} (e : ℕ)\n\n-- TODO think if any generalized version of this with exponents in hyp would be useful\n\nlemma pow_zmod_nat (h : (m : zmod n) = 0) : (m ^ e : zmod (n ^ e)) = 0 :=\nbegin\n  norm_cast,\n  rw zmod.nat_coe_zmod_eq_zero_iff_dvd at *,\n  exact pow_dvd_pow_of_dvd h e,\nend\nend pow_zmod_nat\nsection pow_zmod_int\nvariables {n : ℕ} {m : ℤ} (e : ℕ)\n\nlemma pow_zmod_int (h : (m : zmod n) = 0) : (m ^ e : zmod (n ^ e)) = 0 :=\nbegin\n  norm_cast,\n  rw zmod.int_coe_zmod_eq_zero_iff_dvd at *,\n  push_cast,\n  exact pow_dvd_pow_of_dvd h e,\nend\n\nend pow_zmod_int\n\nsection norm_zero\nnamespace algebra\nlemma norm_zero_of_basis {R S ι : Type*} [comm_ring R] [comm_ring S] [algebra R S] [nontrivial S]\n  [fintype ι] (b : basis ι R S) : algebra.norm R (0 : S) = 0 :=\nbegin\n  have hι : nonempty ι := b.index_nonempty,\n  letI := classical.dec_eq ι,\n  rw algebra.norm_eq_matrix_det b,\n  rw [alg_hom.map_zero, matrix.det_zero hι],\nend\n\n@[simp]\nlemma norm_zero {R S : Type*} [comm_ring R] [comm_ring S] [algebra R S] [nontrivial R]\n  [nontrivial S] [_root_.module.finite R S] [_root_.module.free R S] : algebra.norm R (0 : S) = 0 :=\nnorm_zero_of_basis (module.free.choose_basis R S)\n\nend algebra\nend norm_zero\n\n\nsection int_squarefree\nlemma int.squarefree_iff_squarefree_nat_abs {z : ℤ} : squarefree z ↔ squarefree (int.nat_abs z) :=\nbegin\n  rw [squarefree, squarefree],\n  split; intros h x hx,\n  { specialize h x _, norm_cast, rw ← int.coe_nat_dvd_left at hx, exact hx,\n    norm_cast at h, exact h },\n  { specialize h x.nat_abs _, rw ← int.nat_abs_mul, simpa, simp [nat.is_unit_iff] at h,\n    exact int.is_unit_iff_nat_abs_eq.mpr h, }\nend\n-- namespace norm_num\n-- open norm_num\n-- open tactic\n-- TODO try to get this working\n-- @[norm_num] meta def eval_squarefree_int : expr → tactic (expr × expr)\n-- | `(squarefree (%%e : ℤ)) := do\n--   trace \"hi mom\",\n--   return (`(squarefree (int.nat_abs (%%e : int))), `((@int.squarefree_iff_squarefree_nat_abs %%e).symm))\n-- | _ := failed\n-- end norm_num\n\nend int_squarefree\n\nsection irred\n\nlemma irreducible_of_map_irreducible {α β : Type*} [monoid α] [monoid β] [unique βˣ] {p : α}\n  {F : Type*} [monoid_hom_class F α β] (f : F) (hf : ∀ x, f x = 1 → x = 1)\n  (h : irreducible $ f p) : irreducible p :=\n{ not_unit := λ hn, h.not_unit (hn.map f),\n  is_unit_or_is_unit' := λ a b hab, begin\n    have := map_mul f a b,\n    rw ← hab at this,\n    apply or.imp _ _ (h.is_unit_or_is_unit this);\n    rintro ⟨ua, ha⟩;\n    [rw hf a, rw hf b];\n    { exact is_unit_one } <|>\n    { simp [← ha], },\n  end }\n\nend irred\n\nsection zero_generator\n\nopen ideal\nsection noncomm\nvariables {R : Type*} [ring R]\n\n-- TODO maybe submodule version\n\n@[simp] lemma span_zero' : span ({0} : set R) = ⊥ := by simp\n@[simp] lemma span_one : span ({1} : set R) = ⊤ := by simp\ninstance : submodule.is_principal (⊥ : ideal R) :=\n{ principal := ⟨0, by {rw ← submodule.span_zero, refl}⟩ }\ninstance {a : R} : submodule.is_principal (span ({a} : set R)) := { principal := ⟨a, rfl⟩ }\n\n@[simp]\nlemma generator_bot : submodule.is_principal.generator (⊥ : ideal R) = 0 :=\nbegin\n  apply mem_bot.mp,\n  exact submodule.is_principal.generator_mem _,\nend\n\nlemma generator_zero : submodule.is_principal.generator (span ({0} : set R)) = 0 :=\nby simp\n\nopen submodule.is_principal\n\nlemma span_generator' (a : R) :\n  ideal.span ({(generator (span ({a} : set R)))} : set R) = ideal.span {a} :=\nideal.span_singleton_generator _\nend noncomm\n\nsection comm\nvariables {R : Type*} [comm_ring R]\nopen submodule.is_principal\n\nlocal infix ` ~ᵤ ` : 50 := associated\n\n-- TODO is the domain assumption needed?\nlemma associated_generator_span_singleton [is_domain R] (a : R) :\n  generator (span ({a} : set R)) ~ᵤ a := -- TODO notation for associated?\nbegin\n  apply associated_of_dvd_dvd; rw ← mem_span_singleton,\n  rw ideal.span_singleton_generator,\n  exact submodule.mem_span_singleton_self _, -- maybe also an ideal version needed\n  exact generator_mem _, -- TODO need ideal version for library search\nend\n\n-- TODO generalize these two\nlemma norm_unit (u : Rˣ) : is_unit $ algebra.norm ℤ (u : R) :=\nbegin\n  apply is_unit_of_mul_eq_one _ (algebra.norm ℤ (↑u⁻¹ : R)),\n  simp [← _root_.map_mul],\nend\n\n-- TODO generalize these two\nlemma norm_associated_of_associated {a b : R} (h : associated a b) :\n  associated (algebra.norm ℤ a) (algebra.norm ℤ b) :=\nbegin\n  obtain ⟨u, hu⟩ := h,\n  apply_fun (algebra.norm ℤ) at hu,\n  rw _root_.map_mul at hu,\n  obtain ⟨Nu, hNu⟩ := norm_unit u,\n  use Nu,\n  rwa hNu,\nend\n\nend comm\n\nend zero_generator\n\nsection top_generator\n\nvariables (R : Type*) [comm_ring R]\nopen submodule.is_principal\n\nlemma is_unit_generator_top : is_unit (generator (⊤ : ideal R)) :=\nis_unit_of_dvd_one (generator ⊤) $ (mem_iff_generator_dvd ⊤).mp submodule.mem_top\n\nend top_generator\nsection class_group_span_singleton\n\n@[simp]\nlemma class_group.mk0_span_singleton {R K : Type*} [comm_ring R] [field K] [algebra R K]\n  [is_fraction_ring R K] [is_domain R] [is_dedekind_domain R] (x : R) (h) :\n  class_group.mk0 ⟨ideal.span ({x} : set R), h⟩ = 1 :=\nbegin\n  rw class_group.mk0_eq_one_iff,\n  exact ideal.span.submodule.is_principal,\nend\nend class_group_span_singleton\n\nsection mk0_pow\nlemma units.mk0_pow {G₀ : Type*} [group_with_zero G₀] (x : G₀) {n : ℕ} (hn : 0 < n) (hxy) :\n  units.mk0 (x ^ n) hxy = (units.mk0 x (λ h, hxy (by simp only [h, zero_pow_eq_zero, hn]))) ^ n :=\nby { ext, simp, }\nend mk0_pow\n\nsection poly_lemma\nopen_locale polynomial\nopen polynomial\n\n-- TODO cleanup, maybe a general version for other powers less than multiplicity?\n-- TODO probably delete as dup of mul_div_by_monic_eq_iff_is_root\nlemma polynomial.div_by_monic_mul_eq {R : Type*} [comm_ring R] [is_domain R]\n  (p : R[X]) (a : R) (ha : a ∈ p.roots) :\n  p /ₘ (X - C a) * (X - C a) = p :=\nhave monic (X - C a), from (monic_X_sub_C _),\nby conv_rhs { rw [← mod_by_monic_add_div p this,\n    (dvd_iff_mod_by_monic_eq_zero this).2\n    ((dvd_pow_self _ begin have := is_root_of_mem_roots ha,\n        rw ← root_multiplicity_pos at this, exact this.ne.symm,\n        intro hp, simpa [hp] using ha, end).trans (pow_root_multiplicity_dvd _ _))] };\n  simp [mul_comm]\n\nlemma polynomial.not_is_unit_of_nat_degree_pos {R : Type*} [comm_ring R] [is_domain R]\n  (p : R[X]) (hpl : 0 < p.nat_degree) : ¬ is_unit p :=\nbegin\n  intro h,\n  have : p.nat_degree = 0,\n  { simp [polynomial.nat_degree_eq_zero_iff_degree_le_zero,\n      polynomial.degree_eq_zero_of_is_unit h], },\n  simpa [this] using hpl,\nend\n\nlemma polynomial.irreducible_iff_roots_empty_of_degree_le_three {R : Type*} [field R]\n  {p : R[X]} (hp : p.nat_degree ≤ 3) (hpl : 2 ≤ p.nat_degree) : irreducible p ↔ p.roots = 0 :=\nbegin\n  have hpz : p ≠ 0 := polynomial.ne_zero_of_nat_degree_gt hpl,\n  have hpu : ¬ is_unit p := p.not_is_unit_of_nat_degree_pos (pos_of_gt hpl),\n  rw irreducible_iff,\n  simp only [hpu, not_false_iff, true_and],\n  split,\n  { intro h,\n    contrapose! h,\n    obtain ⟨r, hr⟩ := multiset.exists_mem_of_ne_zero h,\n    -- rw ← polynomial.div_by_monic_mul_pow_root_multiplicity_eq p r,\n    refine ⟨p /ₘ (X - C r), X - C r, _, _, _⟩,\n    { conv_lhs\n      { rw [← mul_div_by_monic_eq_iff_is_root.mpr (is_root_of_mem_roots hr), mul_comm] }, },\n    { apply polynomial.not_is_unit_of_nat_degree_pos,\n      rw nat_degree_div_by_monic _ (monic_X_sub_C r), -- TODO why is there no degree version? is it false?\n      simpa using hpl, },\n    { apply polynomial.not_is_unit_of_nat_degree_pos,\n      simp, }, },\n  { rintro h a b rfl,\n    simp only [not_or_distrib, ne.def, mul_eq_zero] at hpz,\n    rw polynomial.nat_degree_mul hpz.1 hpz.2 at hp,\n    -- sad wlog\n    have key : ∀ (A B : R[X]) (Hpl : 2 ≤ (A * B).nat_degree) (Hpu : ¬is_unit (A * B))\n      (H : (A * B).roots = 0) (Hpz : ¬A = 0 ∧ ¬B = 0) (Hp : A.nat_degree + B.nat_degree ≤ 3)\n      (this : 1 ≤ A.nat_degree),\n      is_unit A ∨ is_unit B,\n    { clear_except,\n      intros A B Hpl Hpu H Hpz Hp this,\n      have : A.nat_degree ≤ 3 := le_of_add_le_left Hp,\n      interval_cases A.nat_degree with H_eq,\n      { exfalso,\n        have : A.roots ≠ 0,\n        { convert roots_ne_zero_of_splits (ring_hom.id _) (splits_of_nat_degree_eq_one _ H_eq)\n            (by simp [H_eq]), -- TODO this probably should be simpler\n          simp, },\n        rw [roots_mul (mul_ne_zero Hpz.1 Hpz.2), add_eq_zero_iff] at H,\n        exact this H.1, },\n      { -- TODO deduplicate these somehow\n        simp only [H_eq, is_unit.mul_iff, not_and, le_refl, nat.bit0_le_bit1_iff, eq_self_iff_true,\n          nat.one_le_bit0_iff, nat.lt_one_iff] at *,\n        rw ← le_tsub_iff_left (by norm_num : 2 ≤ 3) at Hp,\n        norm_num at Hp,\n        rw or_iff_not_imp_right,\n        intro HB,\n        exfalso,\n        have : B.nat_degree = 1,\n        { rw [is_unit_iff_degree_eq_zero, degree_eq_nat_degree Hpz.2, with_top.coe_eq_zero] at HB,\n          interval_cases B.nat_degree with Hi,\n          { simpa [Hi] using HB, },\n          { simp [Hi], }, },\n        have : B.roots ≠ 0,\n        { convert roots_ne_zero_of_splits (ring_hom.id _) (splits_of_nat_degree_le_one _ Hp)\n            (by simp [this]), -- TODO this probably should be simpler\n          simp, },\n        rw [roots_mul (mul_ne_zero Hpz.1 Hpz.2), add_eq_zero_iff] at H,\n        exact this H.2, },\n      { simp only [H_eq, ne.def, mul_eq_zero, is_unit.mul_iff, not_and, le_refl,\n          nat.bit0_le_bit1_iff, eq_self_iff_true, add_le_iff_nonpos_right, le_zero_iff,\n          polynomial.is_unit_iff_degree_eq_zero, not_or_distrib] at ⊢ Hp,\n        right,\n        rw [polynomial.degree_eq_nat_degree Hpz.2, Hp, enat.coe_zero], }, },\n    have : 1 ≤ a.nat_degree ∨ 1 ≤ b.nat_degree, -- TODO this should be a lemma, with ceil (d / 2)\n    { rw [nat_degree_mul hpz.1 hpz.2] at hpl,\n      contrapose! hpl,\n      linarith, },\n    cases this,\n    exact key a b hpl hpu h hpz hp this,\n    exact (key b a (by simpa [mul_comm] using hpl) (by simpa [mul_comm] using hpu)\n      (by simpa [mul_comm] using h) hpz.symm (by simpa [add_comm] using hp) this).symm, },\nend\n\nend poly_lemma\n\n\nsection unique_unit\n@[simp] lemma is_unit_iff_eq_one {M : Type*} [monoid M] [hu : unique Mˣ] (m : M) :\n  is_unit m ↔ m = 1 :=\nbegin\n  split; intro h,\n  { lift m to Mˣ using h,\n    simp, },\n  { simp [h], },\nend\nend unique_unit\n\n\nsection ring_equiv\n\n@[simp] -- TODO which way is simp, also in the library?\nlemma ring_equiv.to_equiv_symm {R S : Type*} [semiring R] [semiring S] (f : R ≃+* S) :\n  (f : R ≃ S).symm = (f.symm : S ≃ R) := rfl\n\nend ring_equiv\n\n\nsection dvd_sub_self\n\nvariables {α : Type*} [ring α]\n\ntheorem dvd_sub_iff_left {a b c : α} (h : a ∣ c) : a ∣ b ↔ a ∣ b - c :=\n⟨λh₂, dvd_sub h₂ h, λH, by have t := dvd_add H h; rwa sub_add_cancel at t⟩\n\ntheorem dvd_sub_iff_right {a b c : α} (h : a ∣ b) : a ∣ c ↔ a ∣ b - c :=\n⟨λh₂, dvd_sub h h₂, λH, by have t := dvd_sub h H; rwa [← sub_add, sub_self, zero_add] at t⟩\n\n/-- If an element a divides another element c in a commutative ring, a divides the sum of another\n  element b with c iff a divides b. -/\ntheorem dvd_sub_left {a b c : α} (h : a ∣ c) : a ∣ b - c ↔ a ∣ b :=\n(dvd_sub_iff_left h).symm\n\n/-- If an element a divides another element b in a commutative ring, a divides the sum of b and\n  another element c iff a divides c. -/\ntheorem dvd_sub_right {a b c : α} (h : a ∣ b) : a ∣ b - c ↔ a ∣ c :=\n(dvd_sub_iff_right h).symm\n\n/-- An element a divides the difference a - b if and only if a divides b.-/\n@[simp] lemma dvd_sub_self_left {a b : α} : a ∣ a - b ↔ a ∣ b :=\ndvd_sub_right (dvd_refl a)\n\n/-- An element a divides the difference b - a if and only if a divides b.-/\n@[simp] lemma dvd_sub_self_right {a b : α} : a ∣ b - a ↔ a ∣ b :=\ndvd_sub_left (dvd_refl a)\n\nend dvd_sub_self\n\nsection zmod_reduced\n\ninstance {n : ℕ} [fact $ squarefree n] : is_reduced (zmod n) :=\n⟨begin\n  casesI n,\n  { exfalso,\n    apply not_squarefree_zero _inst_1.out, },\n  rintro ⟨x, hx⟩ ⟨_ | m, h⟩,\n  { rw [pow_zero, fin.one_eq_zero_iff] at h,\n    rw [h, nat.lt_one_iff] at hx,\n    simp only [hx, fin.mk_zero], },\n  { have : ((⟨x, hx⟩ : zmod n.succ) = (x : zmod n.succ)),\n    { ext,\n      simp only [fin.coe_mk, fin.coe_of_nat_eq_mod],\n      exact (nat.mod_eq_of_lt hx).symm, },\n    rw this at h ⊢,\n    norm_cast at h,\n    rw zmod.nat_coe_zmod_eq_zero_iff_dvd at h ⊢,\n    rwa unique_factorization_monoid.dvd_pow_iff_dvd_of_squarefree at h,\n    exact fact.out _,\n    exact ne_zero.ne _, }\nend⟩\n\nend zmod_reduced\n\nsection squarefree_gcd_of_squarefree\n\nvariables {α : Type*} [cancel_comm_monoid_with_zero α] [gcd_monoid α]\n\nlemma squarefree_gcd_of_squarefree_right {a b : α} (hb : squarefree b) :\n  squarefree (gcd a b) :=\nλ x hx, hb x $ hx.trans $ gcd_dvd_right _ _\n\nlemma squarefree_gcd_of_squarefree_left {a b : α} (ha : squarefree a) :\n  squarefree (gcd a b) :=\nλ x hx, ha x $ hx.trans $ gcd_dvd_left _ _\n\nend squarefree_gcd_of_squarefree\n\n@[simp]\nlemma int.is_unit_coe_nat {n : ℕ} : is_unit (n : ℤ) ↔ n = 1 :=\nby rw [int.is_unit_iff_nat_abs_eq, int.nat_abs_of_nat]\n\ninstance : Π (n : ℕ), slim_check.sampleable (zmod n)\n| 0 := show slim_check.sampleable ℤ, by apply_instance\n| (n+1) := show slim_check.sampleable (fin (n + 1)), by apply_instance\n\n\nlemma is_square.nonneg {α : Type*} [linear_ordered_field α] {a : α} (h : is_square a) : 0 ≤ a :=\nbegin\n  rcases h with ⟨h_w, rfl⟩,\n  exact mul_self_nonneg h_w,\nend\n", "meta": {"author": "lean-forward", "repo": "class-group-and-mordell-equation", "sha": "baba2049f3bfe4d2cc184f8205997333e7c58638", "save_path": "github-repos/lean/lean-forward-class-group-and-mordell-equation", "path": "github-repos/lean/lean-forward-class-group-and-mordell-equation/class-group-and-mordell-equation-baba2049f3bfe4d2cc184f8205997333e7c58638/src/number_theory/assorted_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.49270037511627746}}
{"text": "inductive Mem (a : α) : List α → Prop where\n  | head {as} : Mem a (a::as)\n  | tail {as} : Mem a as → Mem a (a'::as)\n\ninfix:50 (priority := high) \" ∈ \" => Mem\n\nexample (a b : Nat) (h : a ∈ [b]) : b = a :=\n  match h with\n  | Mem.head => rfl\n\nexample {as : List α} (h : a ∈ b :: as) : b = a ∨ a ∈ as :=\n  match h with\n  | Mem.head    => Or.inl rfl\n  | Mem.tail h' => Or.inr h'\n\nexample (a b : Nat) (h : a.succ.succ = b.succ.succ.succ) : a = b.succ :=\n  match h with\n  | rfl => rfl\n\ninductive Vec (α : Type u) : Nat → Type u where\n  | nil  : Vec α 0\n  | cons : α → Vec α n → Vec α (n + 1)\n\ndef hv (xs : Vec Nat (n+1)) : Nat :=\n  match xs with\n  | Vec.cons a .. => a\n\ndef addHead (p : Vec Nat n × Vec Nat n) : Nat :=\n  match p with\n  | (Vec.cons a _, Vec.cons b _) => a + b\n  | (Vec.nil, Vec.nil) => 0\n\ninductive HVec : {n : Nat} → Vec (Type u) n → Type (u+1)\n  | nil  : HVec Vec.nil\n  | cons : {αs : Vec (Type u) n} → α → HVec αs → HVec (Vec.cons α αs)\n\nabbrev HVec.TypeHead {αs : Vec (Type u) n} (xs : HVec αs) : Type u :=\n  match xs with\n  | HVec.nil => PUnit\n  | HVec.cons (α := α) .. => α\n\ndef HVec.head {αs : Vec (Type u) n} (xs : HVec αs) : TypeHead xs :=\n  match xs with\n  | HVec.cons a _ => a\n  | HVec.nil      => PUnit.unit\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/discrRefinement3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.49270037511627734}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl\n\nContinuous linear functions -- functions between normed vector spaces which are bounded and linear.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.normed_space.multilinear\nimport Mathlib.PostPort\n\nuniverses u_5 u_6 u_7 l u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-- A function `f` satisfies `is_bounded_linear_map 𝕜 f` if it is linear and satisfies the\ninequality `∥ f x ∥ ≤ M * ∥ x ∥` for some positive constant `M`. -/\nstructure is_bounded_linear_map (𝕜 : Type u_5) [normed_field 𝕜] {E : Type u_6} [normed_group E] [normed_space 𝕜 E] {F : Type u_7} [normed_group F] [normed_space 𝕜 F] (f : E → F) \nextends is_linear_map 𝕜 f\nwhere\n  bound : ∃ (M : ℝ), 0 < M ∧ ∀ (x : E), norm (f x) ≤ M * norm x\n\ntheorem is_linear_map.with_bound {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (hf : is_linear_map 𝕜 f) (M : ℝ) (h : ∀ (x : E), norm (f x) ≤ M * norm x) : is_bounded_linear_map 𝕜 f := sorry\n\n/-- A continuous linear map satisfies `is_bounded_linear_map` -/\ntheorem continuous_linear_map.is_bounded_linear_map {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] (f : continuous_linear_map 𝕜 E F) : is_bounded_linear_map 𝕜 ⇑f := sorry\n\nnamespace is_bounded_linear_map\n\n\n/-- Construct a linear map from a function `f` satisfying `is_bounded_linear_map 𝕜 f`. -/\ndef to_linear_map {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] (f : E → F) (h : is_bounded_linear_map 𝕜 f) : linear_map 𝕜 E F :=\n  is_linear_map.mk' f sorry\n\n/-- Construct a continuous linear map from is_bounded_linear_map -/\ndef to_continuous_linear_map {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (hf : is_bounded_linear_map 𝕜 f) : continuous_linear_map 𝕜 E F :=\n  continuous_linear_map.mk (linear_map.mk (linear_map.to_fun (to_linear_map f hf)) sorry sorry)\n\ntheorem zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] : is_bounded_linear_map 𝕜 fun (x : E) => 0 := sorry\n\ntheorem id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] : is_bounded_linear_map 𝕜 fun (x : E) => x := sorry\n\ntheorem fst {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] : is_bounded_linear_map 𝕜 fun (x : E × F) => prod.fst x := sorry\n\ntheorem snd {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] : is_bounded_linear_map 𝕜 fun (x : E × F) => prod.snd x := sorry\n\ntheorem smul {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (c : 𝕜) (hf : is_bounded_linear_map 𝕜 f) : is_bounded_linear_map 𝕜 fun (e : E) => c • f e := sorry\n\ntheorem neg {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (hf : is_bounded_linear_map 𝕜 f) : is_bounded_linear_map 𝕜 fun (e : E) => -f e := sorry\n\ntheorem add {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} {g : E → F} (hf : is_bounded_linear_map 𝕜 f) (hg : is_bounded_linear_map 𝕜 g) : is_bounded_linear_map 𝕜 fun (e : E) => f e + g e := sorry\n\ntheorem sub {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} {g : E → F} (hf : is_bounded_linear_map 𝕜 f) (hg : is_bounded_linear_map 𝕜 g) : is_bounded_linear_map 𝕜 fun (e : E) => f e - g e := sorry\n\ntheorem comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E → F} {g : F → G} (hg : is_bounded_linear_map 𝕜 g) (hf : is_bounded_linear_map 𝕜 f) : is_bounded_linear_map 𝕜 (g ∘ f) :=\n  continuous_linear_map.is_bounded_linear_map\n    (continuous_linear_map.comp (to_continuous_linear_map hg) (to_continuous_linear_map hf))\n\nprotected theorem tendsto {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (x : E) (hf : is_bounded_linear_map 𝕜 f) : filter.tendsto f (nhds x) (nhds (f x)) := sorry\n\ntheorem continuous {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (hf : is_bounded_linear_map 𝕜 f) : continuous f :=\n  iff.mpr continuous_iff_continuous_at fun (_x : E) => is_bounded_linear_map.tendsto _x hf\n\ntheorem lim_zero_bounded_linear_map {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (hf : is_bounded_linear_map 𝕜 f) : filter.tendsto f (nhds 0) (nhds 0) :=\n  linear_map.map_zero (is_linear_map.mk' f (to_is_linear_map hf)) ▸ iff.mp continuous_iff_continuous_at (continuous hf) 0\n\ntheorem is_O_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (h : is_bounded_linear_map 𝕜 f) (l : filter E) : asymptotics.is_O f (fun (x : E) => x) l := sorry\n\ntheorem is_O_comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {E : Type u_2} {g : F → G} (hg : is_bounded_linear_map 𝕜 g) {f : E → F} (l : filter E) : asymptotics.is_O (fun (x' : E) => g (f x')) f l :=\n  asymptotics.is_O.comp_tendsto (is_O_id hg ⊤) le_top\n\ntheorem is_O_sub {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {f : E → F} (h : is_bounded_linear_map 𝕜 f) (l : filter E) (x : E) : asymptotics.is_O (fun (x' : E) => f (x' - x)) (fun (x' : E) => x' - x) l :=\n  is_O_comp h l\n\nend is_bounded_linear_map\n\n\n/-- Taking the cartesian product of two continuous linear maps is a bounded linear operation. -/\ntheorem is_bounded_linear_map_prod_iso {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] : is_bounded_linear_map 𝕜\n  fun (p : continuous_linear_map 𝕜 E F × continuous_linear_map 𝕜 E G) =>\n    continuous_linear_map.prod (prod.fst p) (prod.snd p) := sorry\n\n/-- Taking the cartesian product of two continuous multilinear maps is a bounded linear operation. -/\ntheorem is_bounded_linear_map_prod_multilinear {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {ι : Type u_5} [DecidableEq ι] [fintype ι] {E : ι → Type u_2} [(i : ι) → normed_group (E i)] [(i : ι) → normed_space 𝕜 (E i)] : is_bounded_linear_map 𝕜\n  fun (p : continuous_multilinear_map 𝕜 E F × continuous_multilinear_map 𝕜 E G) =>\n    continuous_multilinear_map.prod (prod.fst p) (prod.snd p) := sorry\n\n/-- Given a fixed continuous linear map `g`, associating to a continuous multilinear map `f` the\ncontinuous multilinear map `f (g m₁, ..., g mₙ)` is a bounded linear operation. -/\ntheorem is_bounded_linear_map_continuous_multilinear_map_comp_linear {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {ι : Type u_5} [DecidableEq ι] [fintype ι] (g : continuous_linear_map 𝕜 G E) : is_bounded_linear_map 𝕜\n  fun (f : continuous_multilinear_map 𝕜 (fun (i : ι) => E) F) =>\n    continuous_multilinear_map.comp_continuous_linear_map f fun (_x : ι) => g := sorry\n\n/-- A map `f : E × F → G` satisfies `is_bounded_bilinear_map 𝕜 f` if it is bilinear and\ncontinuous. -/\nstructure is_bounded_bilinear_map (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] (f : E × F → G) \nwhere\n  add_left : ∀ (x₁ x₂ : E) (y : F), f (x₁ + x₂, y) = f (x₁, y) + f (x₂, y)\n  smul_left : ∀ (c : 𝕜) (x : E) (y : F), f (c • x, y) = c • f (x, y)\n  add_right : ∀ (x : E) (y₁ y₂ : F), f (x, y₁ + y₂) = f (x, y₁) + f (x, y₂)\n  smul_right : ∀ (c : 𝕜) (x : E) (y : F), f (x, c • y) = c • f (x, y)\n  bound : ∃ (C : ℝ), ∃ (H : C > 0), ∀ (x : E) (y : F), norm (f (x, y)) ≤ C * norm x * norm y\n\nprotected theorem is_bounded_bilinear_map.is_O {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) : asymptotics.is_O f (fun (p : E × F) => norm (prod.fst p) * norm (prod.snd p)) ⊤ := sorry\n\ntheorem is_bounded_bilinear_map.is_O_comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} {α : Type u_5} (H : is_bounded_bilinear_map 𝕜 f) {g : α → E} {h : α → F} {l : filter α} : asymptotics.is_O (fun (x : α) => f (g x, h x)) (fun (x : α) => norm (g x) * norm (h x)) l :=\n  asymptotics.is_O.comp_tendsto (is_bounded_bilinear_map.is_O H) le_top\n\nprotected theorem is_bounded_bilinear_map.is_O' {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) : asymptotics.is_O f (fun (p : E × F) => norm p * norm p) ⊤ :=\n  asymptotics.is_O.trans (is_bounded_bilinear_map.is_O h)\n    (asymptotics.is_O.mul (asymptotics.is_O.norm_norm asymptotics.is_O_fst_prod')\n      (asymptotics.is_O.norm_norm asymptotics.is_O_snd_prod'))\n\ntheorem is_bounded_bilinear_map.map_sub_left {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) {x : E} {y : E} {z : F} : f (x - y, z) = f (x, z) - f (y, z) := sorry\n\ntheorem is_bounded_bilinear_map.map_sub_right {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) {x : E} {y : F} {z : F} : f (x, y - z) = f (x, y) - f (x, z) := sorry\n\ntheorem is_bounded_bilinear_map.is_bounded_linear_map_left {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) (y : F) : is_bounded_linear_map 𝕜 fun (x : E) => f (x, y) := sorry\n\ntheorem is_bounded_bilinear_map.is_bounded_linear_map_right {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) (x : E) : is_bounded_linear_map 𝕜 fun (y : F) => f (x, y) := sorry\n\ntheorem is_bounded_bilinear_map_smul {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] : is_bounded_bilinear_map 𝕜 fun (p : 𝕜 × E) => prod.fst p • prod.snd p := sorry\n\ntheorem is_bounded_bilinear_map_smul_algebra {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {𝕜' : Type u_2} [normed_field 𝕜'] [normed_algebra 𝕜 𝕜'] {E : Type u_3} [normed_group E] [normed_space 𝕜 E] [normed_space 𝕜' E] [is_scalar_tower 𝕜 𝕜' E] : is_bounded_bilinear_map 𝕜 fun (p : 𝕜' × E) => prod.fst p • prod.snd p := sorry\n\ntheorem is_bounded_bilinear_map_mul {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] : is_bounded_bilinear_map 𝕜 fun (p : 𝕜 × 𝕜) => prod.fst p * prod.snd p :=\n  is_bounded_bilinear_map_smul\n\ntheorem is_bounded_bilinear_map_comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] : is_bounded_bilinear_map 𝕜\n  fun (p : continuous_linear_map 𝕜 E F × continuous_linear_map 𝕜 F G) =>\n    continuous_linear_map.comp (prod.snd p) (prod.fst p) := sorry\n\ntheorem continuous_linear_map.is_bounded_linear_map_comp_left {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] (g : continuous_linear_map 𝕜 F G) : is_bounded_linear_map 𝕜 fun (f : continuous_linear_map 𝕜 E F) => continuous_linear_map.comp g f :=\n  is_bounded_bilinear_map.is_bounded_linear_map_left is_bounded_bilinear_map_comp g\n\ntheorem continuous_linear_map.is_bounded_linear_map_comp_right {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] (f : continuous_linear_map 𝕜 E F) : is_bounded_linear_map 𝕜 fun (g : continuous_linear_map 𝕜 F G) => continuous_linear_map.comp g f :=\n  is_bounded_bilinear_map.is_bounded_linear_map_right is_bounded_bilinear_map_comp f\n\ntheorem is_bounded_bilinear_map_apply {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] : is_bounded_bilinear_map 𝕜 fun (p : continuous_linear_map 𝕜 E F × E) => coe_fn (prod.fst p) (prod.snd p) := sorry\n\n/-- The function `continuous_linear_map.smul_right`, associating to a continuous linear map\n`f : E → 𝕜` and a scalar `c : F` the tensor product `f ⊗ c` as a continuous linear map from `E` to\n`F`, is a bounded bilinear map. -/\ntheorem is_bounded_bilinear_map_smul_right {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] : is_bounded_bilinear_map 𝕜\n  fun (p : continuous_linear_map 𝕜 E 𝕜 × F) => continuous_linear_map.smul_right (prod.fst p) (prod.snd p) := sorry\n\n/-- The composition of a continuous linear map with a continuous multilinear map is a bounded\nbilinear operation. -/\ntheorem is_bounded_bilinear_map_comp_multilinear {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {ι : Type u_2} {E : ι → Type u_5} [DecidableEq ι] [fintype ι] [(i : ι) → normed_group (E i)] [(i : ι) → normed_space 𝕜 (E i)] : is_bounded_bilinear_map 𝕜\n  fun (p : continuous_linear_map 𝕜 F G × continuous_multilinear_map 𝕜 E F) =>\n    continuous_linear_map.comp_continuous_multilinear_map (prod.fst p) (prod.snd p) := sorry\n\n/-- Definition of the derivative of a bilinear map `f`, given at a point `p` by\n`q ↦ f(p.1, q.2) + f(q.1, p.2)` as in the standard formula for the derivative of a product.\nWe define this function here a bounded linear map from `E × F` to `G`. The fact that this\nis indeed the derivative of `f` is proved in `is_bounded_bilinear_map.has_fderiv_at` in\n`fderiv.lean`-/\ndef is_bounded_bilinear_map.linear_deriv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) (p : E × F) : linear_map 𝕜 (E × F) G :=\n  linear_map.mk (fun (q : E × F) => f (prod.fst p, prod.snd q) + f (prod.fst q, prod.snd p)) sorry sorry\n\n/-- The derivative of a bounded bilinear map at a point `p : E × F`, as a continuous linear map\nfrom `E × F` to `G`. -/\ndef is_bounded_bilinear_map.deriv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) (p : E × F) : continuous_linear_map 𝕜 (E × F) G :=\n  linear_map.mk_continuous_of_exists_bound (is_bounded_bilinear_map.linear_deriv h p) sorry\n\n@[simp] theorem is_bounded_bilinear_map_deriv_coe {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) (p : E × F) (q : E × F) : coe_fn (is_bounded_bilinear_map.deriv h p) q = f (prod.fst p, prod.snd q) + f (prod.fst q, prod.snd p) :=\n  rfl\n\n/-- The function `lmul_left_right : 𝕜' × 𝕜' → (𝕜' →L[𝕜] 𝕜')` is a bounded bilinear map. -/\ntheorem continuous_linear_map.lmul_left_right_is_bounded_bilinear (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (𝕜' : Type u_2) [normed_ring 𝕜'] [normed_algebra 𝕜 𝕜'] : is_bounded_bilinear_map 𝕜 (continuous_linear_map.lmul_left_right 𝕜 𝕜') := sorry\n\n/-- Given a bounded bilinear map `f`, the map associating to a point `p` the derivative of `f` at\n`p` is itself a bounded linear map. -/\ntheorem is_bounded_bilinear_map.is_bounded_linear_map_deriv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] {f : E × F → G} (h : is_bounded_bilinear_map 𝕜 f) : is_bounded_linear_map 𝕜 fun (p : E × F) => is_bounded_bilinear_map.deriv h p := sorry\n\n/-- A linear isometry preserves the norm. -/\ntheorem linear_map.norm_apply_of_isometry {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] (f : linear_map 𝕜 E F) {x : E} (hf : isometry ⇑f) : norm (coe_fn f x) = norm x := sorry\n\n/-- Construct a continuous linear equiv from a linear map that is also an isometry with full range. -/\ndef continuous_linear_equiv.of_isometry {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] (f : linear_map 𝕜 E F) (hf : isometry ⇑f) (hfr : linear_map.range f = ⊤) : continuous_linear_equiv 𝕜 E F :=\n  continuous_linear_equiv.of_homothety 𝕜 (linear_equiv.of_bijective f sorry hfr) 1 zero_lt_one sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/bounded_linear_maps.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.640635847978761, "lm_q1q2_score": 0.4927003698395125}}
{"text": "import category_theory.limits.shapes.pullbacks\n\n/-!\nThanks to Markus Himmel for suggesting this question.\n-/\n\nopen category_theory\nopen category_theory.limits\n\n/-!\nLet C be a category, X and Y be objects and f : X ⟶ Y be a morphism. Show that f is an epimorphism\nif and only if the diagram\n\nX --f--→ Y\n|        |\nf        𝟙\n|        |\n↓        ↓\nY --𝟙--→ Y\n\nis a pushout.\n-/\n\nuniverses v u\n\nvariables {C : Type u} [category.{v} C]\n\ndef pushout_of_epi {X Y : C} (f : X ⟶ Y) [epi f] :\n  is_colimit (pushout_cocone.mk (𝟙 Y) (𝟙 Y) rfl : pushout_cocone f f) :=\nbegin\n  fapply pushout_cocone.is_colimit.mk,\n  all_goals { sorry, },\nend\n\ntheorem epi_of_pushout {X Y : C} (f : X ⟶ Y)\n  (is_colim : is_colimit (pushout_cocone.mk (𝟙 Y) (𝟙 Y) rfl : pushout_cocone f f)) : epi f :=\n{ left_cancellation := λ Z g h hf,\n  begin\n    let a := pushout_cocone.mk _ _ hf,\n    sorry,\n  end }\n", "meta": {"author": "leanprover-community", "repo": "lftcm2020", "sha": "cc683e2b074b61909310746d6acc1fb3d42d6ee2", "save_path": "github-repos/lean/leanprover-community-lftcm2020", "path": "github-repos/lean/leanprover-community-lftcm2020/lftcm2020-cc683e2b074b61909310746d6acc1fb3d42d6ee2/src/hints/category_theory/exercise6/hint1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.49264295675944036}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport analysis.normed_space.basic\nimport linear_algebra.affine_space.midpoint\nimport topology.instances.real_vector_space\n\n/-!\n# Torsors of additive normed group actions.\n\nThis file defines torsors of additive normed group actions, with a\nmetric space structure.  The motivating case is Euclidean affine\nspaces.\n\n-/\n\nnoncomputable theory\nopen_locale nnreal topological_space\nopen filter\n\n/-- A `semi_normed_add_torsor V P` is a torsor of an additive seminormed group\naction by a `semi_normed_group V` on points `P`. We bundle the pseudometric space\nstructure and require the distance to be the same as results from the\nnorm (which in fact implies the distance yields a pseudometric space, but\nbundling just the distance and using an instance for the pseudometric space\nresults in type class problems). -/\nclass semi_normed_add_torsor (V : out_param $ Type*) (P : Type*)\n  [out_param $ semi_normed_group V] [pseudo_metric_space P]\n  extends add_torsor V P :=\n(dist_eq_norm' : ∀ (x y : P), dist x y = ∥(x -ᵥ y : V)∥)\n\n/-- A `normed_add_torsor V P` is a torsor of an additive normed group\naction by a `normed_group V` on points `P`. We bundle the metric space\nstructure and require the distance to be the same as results from the\nnorm (which in fact implies the distance yields a metric space, but\nbundling just the distance and using an instance for the metric space\nresults in type class problems). -/\nclass normed_add_torsor (V : out_param $ Type*) (P : Type*)\n  [out_param $ normed_group V] [metric_space P]\n  extends add_torsor V P :=\n(dist_eq_norm' : ∀ (x y : P), dist x y = ∥(x -ᵥ y : V)∥)\n\n/-- A `normed_add_torsor` is a `semi_normed_add_torsor`. -/\n@[priority 100]\ninstance normed_add_torsor.to_semi_normed_add_torsor {V P : Type*} [normed_group V] [metric_space P]\n  [β : normed_add_torsor V P] : semi_normed_add_torsor V P := { ..β }\n\nvariables {α V P : Type*} [semi_normed_group V] [pseudo_metric_space P] [semi_normed_add_torsor V P]\nvariables {W Q : Type*} [normed_group W] [metric_space Q] [normed_add_torsor W Q]\n\n/-- A `semi_normed_group` is a `semi_normed_add_torsor` over itself. -/\n@[priority 100]\ninstance semi_normed_group.normed_add_torsor : semi_normed_add_torsor V V :=\n{ dist_eq_norm' := dist_eq_norm }\n\n/-- A `normed_group` is a `normed_add_torsor` over itself. -/\n@[priority 100]\ninstance normed_group.normed_add_torsor : normed_add_torsor W W :=\n{ dist_eq_norm' := dist_eq_norm }\n\ninclude V\n\nsection\n\nvariables (V W)\n\n/-- The distance equals the norm of subtracting two points. In this\nlemma, it is necessary to have `V` as an explicit argument; otherwise\n`rw dist_eq_norm_vsub` sometimes doesn't work. -/\nlemma dist_eq_norm_vsub (x y : P) :\n  dist x y = ∥(x -ᵥ y)∥ :=\nsemi_normed_add_torsor.dist_eq_norm' x y\n\nend\n\n@[simp] lemma dist_vadd_cancel_left (v : V) (x y : P) :\n  dist (v +ᵥ x) (v +ᵥ y) = dist x y :=\nby rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, vadd_vsub_vadd_cancel_left]\n\n@[simp] lemma dist_vadd_cancel_right (v₁ v₂ : V) (x : P) :\n  dist (v₁ +ᵥ x) (v₂ +ᵥ x) = dist v₁ v₂ :=\nby rw [dist_eq_norm_vsub V, dist_eq_norm, vadd_vsub_vadd_cancel_right]\n\n@[simp] lemma dist_vadd_left (v : V) (x : P) : dist (v +ᵥ x) x = ∥v∥ :=\nby simp [dist_eq_norm_vsub V _ x]\n\n@[simp] lemma dist_vadd_right (v : V) (x : P) : dist x (v +ᵥ x) = ∥v∥ :=\nby rw [dist_comm, dist_vadd_left]\n\n@[simp] lemma dist_vsub_cancel_left (x y z : P) : dist (x -ᵥ y) (x -ᵥ z) = dist y z :=\nby rw [dist_eq_norm, vsub_sub_vsub_cancel_left, dist_comm, dist_eq_norm_vsub V]\n\n@[simp] lemma dist_vsub_cancel_right (x y z : P) : dist (x -ᵥ z) (y -ᵥ z) = dist x y :=\nby rw [dist_eq_norm, vsub_sub_vsub_cancel_right, dist_eq_norm_vsub V]\n\nlemma dist_vadd_vadd_le (v v' : V) (p p' : P) :\n  dist (v +ᵥ p) (v' +ᵥ p') ≤ dist v v' + dist p p' :=\nby simpa using dist_triangle (v +ᵥ p) (v' +ᵥ p) (v' +ᵥ p')\n\nlemma dist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :\n  dist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ dist p₁ p₃ + dist p₂ p₄ :=\nby { rw [dist_eq_norm, vsub_sub_vsub_comm, dist_eq_norm_vsub V, dist_eq_norm_vsub V],\n exact norm_sub_le _ _ }\n\nlemma nndist_vadd_vadd_le (v v' : V) (p p' : P) :\n  nndist (v +ᵥ p) (v' +ᵥ p') ≤ nndist v v' + nndist p p' :=\nby simp only [← nnreal.coe_le_coe, nnreal.coe_add, ← dist_nndist, dist_vadd_vadd_le]\n\nlemma nndist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :\n  nndist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ nndist p₁ p₃ + nndist p₂ p₄ :=\nby simp only [← nnreal.coe_le_coe, nnreal.coe_add, ← dist_nndist, dist_vsub_vsub_le]\n\nlemma edist_vadd_vadd_le (v v' : V) (p p' : P) :\n  edist (v +ᵥ p) (v' +ᵥ p') ≤ edist v v' + edist p p' :=\nby { simp only [edist_nndist], apply_mod_cast nndist_vadd_vadd_le }\n\nlemma edist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :\n  edist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ edist p₁ p₃ + edist p₂ p₄ :=\nby { simp only [edist_nndist], apply_mod_cast nndist_vsub_vsub_le }\n\nomit V\n\n/-- The pseudodistance defines a pseudometric space structure on the torsor. This\nis not an instance because it depends on `V` to define a `metric_space\nP`. -/\ndef pseudo_metric_space_of_normed_group_of_add_torsor (V P : Type*) [semi_normed_group V]\n  [add_torsor V P] : pseudo_metric_space P :=\n{ dist := λ x y, ∥(x -ᵥ y : V)∥,\n  dist_self := λ x, by simp,\n  dist_comm := λ x y, by simp only [←neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change ∥x -ᵥ z∥ ≤ ∥x -ᵥ y∥ + ∥y -ᵥ z∥,\n    rw ←vsub_add_vsub_cancel,\n    apply norm_add_le\n  end }\n\n/-- The distance defines a metric space structure on the torsor. This\nis not an instance because it depends on `V` to define a `metric_space\nP`. -/\ndef metric_space_of_normed_group_of_add_torsor (V P : Type*) [normed_group V] [add_torsor V P] :\n  metric_space P :=\n{ dist := λ x y, ∥(x -ᵥ y : V)∥,\n  dist_self := λ x, by simp,\n  eq_of_dist_eq_zero := λ x y h, by simpa using h,\n  dist_comm := λ x y, by simp only [←neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change ∥x -ᵥ z∥ ≤ ∥x -ᵥ y∥ + ∥y -ᵥ z∥,\n    rw ←vsub_add_vsub_cancel,\n    apply norm_add_le\n  end }\n\ninclude V\n\nlemma lipschitz_with.vadd [pseudo_emetric_space α] {f : α → V} {g : α → P} {Kf Kg : ℝ≥0}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f +ᵥ g) :=\nλ x y,\ncalc edist (f x +ᵥ g x) (f y +ᵥ g y) ≤ edist (f x) (f y) + edist (g x) (g y) :\n  edist_vadd_vadd_le _ _ _ _\n... ≤ Kf * edist x y + Kg * edist x y :\n  add_le_add (hf x y) (hg x y)\n... = (Kf + Kg) * edist x y :\n  (add_mul _ _ _).symm\n\nlemma lipschitz_with.vsub [pseudo_emetric_space α] {f g : α → P} {Kf Kg : ℝ≥0}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f -ᵥ g) :=\nλ x y,\ncalc edist (f x -ᵥ g x) (f y -ᵥ g y) ≤ edist (f x) (f y) + edist (g x) (g y) :\n  edist_vsub_vsub_le _ _ _ _\n... ≤ Kf * edist x y + Kg * edist x y :\n  add_le_add (hf x y) (hg x y)\n... = (Kf + Kg) * edist x y :\n  (add_mul _ _ _).symm\n\nlemma uniform_continuous_vadd : uniform_continuous (λ x : V × P, x.1 +ᵥ x.2) :=\n(lipschitz_with.prod_fst.vadd lipschitz_with.prod_snd).uniform_continuous\n\nlemma uniform_continuous_vsub : uniform_continuous (λ x : P × P, x.1 -ᵥ x.2) :=\n(lipschitz_with.prod_fst.vsub lipschitz_with.prod_snd).uniform_continuous\n\n@[priority 100] instance semi_normed_add_torsor.has_continuous_vadd :\n  has_continuous_vadd V P :=\n{ continuous_vadd := uniform_continuous_vadd.continuous }\n\nlemma continuous_vsub : continuous (λ x : P × P, x.1 -ᵥ x.2) :=\nuniform_continuous_vsub.continuous\n\nlemma filter.tendsto.vsub {l : filter α} {f g : α → P} {x y : P}\n  (hf : tendsto f l (𝓝 x)) (hg : tendsto g l (𝓝 y)) :\n  tendsto (f -ᵥ g) l (𝓝 (x -ᵥ y)) :=\n(continuous_vsub.tendsto (x, y)).comp (hf.prod_mk_nhds hg)\n\nsection\n\nvariables [topological_space α]\n\nlemma continuous.vsub {f g : α → P} (hf : continuous f) (hg : continuous g) :\n  continuous (f -ᵥ g) :=\ncontinuous_vsub.comp (hf.prod_mk hg : _)\n\nlemma continuous_at.vsub {f g : α → P}  {x : α} (hf : continuous_at f x) (hg : continuous_at g x) :\n  continuous_at (f -ᵥ g) x :=\nhf.vsub hg\n\nlemma continuous_within_at.vsub {f g : α → P} {x : α} {s : set α}\n  (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n  continuous_within_at (f -ᵥ g) s x :=\nhf.vsub hg\n\nend\n\nsection\n\nvariables {R : Type*} [ring R] [topological_space R] [module R V] [has_continuous_smul R V]\n\nlemma filter.tendsto.line_map {l : filter α} {f₁ f₂ : α → P} {g : α → R} {p₁ p₂ : P} {c : R}\n  (h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) (hg : tendsto g l (𝓝 c)) :\n  tendsto (λ x, affine_map.line_map (f₁ x) (f₂ x) (g x)) l (𝓝 $ affine_map.line_map p₁ p₂ c) :=\n(hg.smul (h₂.vsub h₁)).vadd h₁\n\nlemma filter.tendsto.midpoint [invertible (2:R)] {l : filter α} {f₁ f₂ : α → P} {p₁ p₂ : P}\n  (h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) :\n  tendsto (λ x, midpoint R (f₁ x) (f₂ x)) l (𝓝 $ midpoint R p₁ p₂) :=\nh₁.line_map h₂ tendsto_const_nhds\n\nend\n\nsection normed_space\n\nvariables {𝕜 : Type*} [normed_field 𝕜] [semi_normed_space 𝕜 V]\n\nopen affine_map\n\n@[simp] lemma dist_center_homothety (p₁ p₂ : P) (c : 𝕜) :\n  dist p₁ (homothety p₁ c p₂) = ∥c∥ * dist p₁ p₂ :=\nby simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm]\n\n@[simp] lemma dist_homothety_center (p₁ p₂ : P) (c : 𝕜) :\n  dist (homothety p₁ c p₂) p₁ = ∥c∥ * dist p₁ p₂ :=\nby rw [dist_comm, dist_center_homothety]\n\n@[simp] lemma dist_homothety_self (p₁ p₂ : P) (c : 𝕜) :\n  dist (homothety p₁ c p₂) p₂ = ∥1 - c∥ * dist p₁ p₂ :=\nby rw [homothety_eq_line_map, ← line_map_apply_one_sub, ← homothety_eq_line_map,\n  dist_homothety_center, dist_comm]\n\n@[simp] lemma dist_self_homothety (p₁ p₂ : P) (c : 𝕜) :\n  dist p₂ (homothety p₁ c p₂) = ∥1 - c∥ * dist p₁ p₂ :=\nby rw [dist_comm, dist_homothety_self]\n\nvariables [invertible (2:𝕜)]\n\n@[simp] lemma dist_left_midpoint (p₁ p₂ : P) :\n  dist p₁ (midpoint 𝕜 p₁ p₂) = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [midpoint, ← homothety_eq_line_map, dist_center_homothety, inv_of_eq_inv,\n  ← normed_field.norm_inv]\n\n@[simp] lemma dist_midpoint_left (p₁ p₂ : P) :\n  dist (midpoint 𝕜 p₁ p₂) p₁ = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [dist_comm, dist_left_midpoint]\n\n@[simp] lemma dist_midpoint_right (p₁ p₂ : P) :\n  dist (midpoint 𝕜 p₁ p₂) p₂ = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [midpoint_comm, dist_midpoint_left, dist_comm]\n\n@[simp] lemma dist_right_midpoint (p₁ p₂ : P) :\n  dist p₂ (midpoint 𝕜 p₁ p₂) = ∥(2:𝕜)∥⁻¹ * dist p₁ p₂ :=\nby rw [dist_comm, dist_midpoint_right]\n\nlemma dist_midpoint_midpoint_le' (p₁ p₂ p₃ p₄ : P) :\n  dist (midpoint 𝕜 p₁ p₂) (midpoint 𝕜 p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / ∥(2 : 𝕜)∥ :=\nbegin\n  rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, midpoint_vsub_midpoint];\n    try { apply_instance },\n  rw [midpoint_eq_smul_add, norm_smul, inv_of_eq_inv, normed_field.norm_inv, ← div_eq_inv_mul],\n  exact div_le_div_of_le_of_nonneg (norm_add_le _ _) (norm_nonneg _),\nend\n\nend normed_space\n\nvariables [semi_normed_space ℝ V] [normed_space ℝ W]\n\nlemma dist_midpoint_midpoint_le (p₁ p₂ p₃ p₄ : V) :\n  dist (midpoint ℝ p₁ p₂) (midpoint ℝ p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / 2 :=\nby simpa using dist_midpoint_midpoint_le' p₁ p₂ p₃ p₄\n\ninclude W\n\n/-- A continuous map between two normed affine spaces is an affine map provided that\nit sends midpoints to midpoints. -/\ndef affine_map.of_map_midpoint (f : P → Q)\n  (h : ∀ x y, f (midpoint ℝ x y) = midpoint ℝ (f x) (f y))\n  (hfc : continuous f) :\n  P →ᵃ[ℝ] Q :=\naffine_map.mk' f\n  ↑((add_monoid_hom.of_map_midpoint ℝ ℝ\n    ((affine_equiv.vadd_const ℝ (f $ classical.arbitrary P)).symm ∘ f ∘\n      (affine_equiv.vadd_const ℝ (classical.arbitrary P))) (by simp)\n      (λ x y, by simp [h])).to_real_linear_map $ by apply_rules [continuous.vadd, continuous.vsub,\n        continuous_const, hfc.comp, continuous_id])\n  (classical.arbitrary P)\n  (λ p, by simp)\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/normed_space/add_torsor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.4926429556092759}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport formal_ml.set\nimport formal_ml.finset\nimport formal_ml.classical\n\nlemma set_Prop_le_def {α:Type*}\n  (M M2:set α → Prop):\n  M ≤ M2 ↔\n  (∀ X:set α, M X → M2 X)\n   :=\nbegin\n  refl,\nend\n\nlemma finset_union_measurable {α:Type*} {T:finset α} {β:Type*} [measurable_space β] {U:α → set β}:\n  (∀ t∈ T, measurable_set (U t)) →\n  measurable_set (⋃ x ∈ T, U x) :=\nbegin\n  intros a,\n  have A1:(set.sUnion (set.image U ({a|a∈ T}:set α))) = (⋃ x ∈ T, U x),\n  {\n    simp,\n  },\n  rw ← A1,\n  apply measurable_set.sUnion,\n  {\n    apply set.countable.image,\n    apply set.finite.countable,\n    apply finite_finset,\n  },\n  {\n    intros,\n    simp at H,\n    cases H with x H,\n    cases H with A2 A3,\n    subst t,\n    apply a,\n    exact A2,\n  }\nend\n\nlemma finset_inter_measurable {α:Type*} {T:finset α} {β:Type*} [measurable_space β] {U:α → set β}:\n  (∀ t∈ T, measurable_set (U t)) →\n  measurable_set (⋂ x ∈ T, U x) :=\nbegin\n  intros a,\n  have A1:(set.sInter (set.image U ({a|a∈ T}:set α))) = (⋂ x ∈ T, U x),\n  {\n    simp,\n  },\n  rw ← A1,\n  apply measurable_set.sInter,\n  {\n    apply set.countable.image,\n    apply set.finite.countable,\n    apply finite_finset,\n  },\n  {\n    intros,\n    simp at H,\n    cases H with x H,\n    cases H with A2 A3,\n    subst t,\n    apply a,\n    exact A2,\n  }\nend\n\nlemma measurable_space_le_def {α:Type*}\n  (M:measurable_space α) (M2:measurable_space α):\n  M.measurable_set' ≤  M2.measurable_set'\n  ↔  M ≤ M2 :=\nbegin\n  refl,\nend\n\nlemma measurable_space_le_def2 {α:Type*}\n  (M:measurable_space α) (M2:measurable_space α):\n  (∀ X:set α, M.measurable_set' X → M2.measurable_set' X) ↔\n   M ≤ M2 :=\nbegin\n  intros,\n  apply iff.trans,\n  {\n    apply set_Prop_le_def,\n  },\n  {\n    apply measurable_space_le_def,\n  }\nend\n\n-- Delete?\nlemma measurable_space_le_intro {α:Type*}\n  (M:measurable_space α) (M2:measurable_space α):\n  (∀ X:set α, M.measurable_set' X → M2.measurable_set' X) →\n   M ≤ M2 :=\nbegin\n  intros a,\n  have A1:M.measurable_set' ≤  M2.measurable_set'\n  ↔  M ≤ M2,\n  {\n    apply measurable_space_le_def,\n  },\n  apply A1.mp,\n  have A2:M.measurable_set' ≤ M2.measurable_set' ↔\n  (∀ X:set α, M.measurable_set' X → M2.measurable_set' X),\n  {\n    apply set_Prop_le_def,\n  },\n  apply A2.mpr,\n  apply a,\nend\n\n\n\nlemma measurable_def {α β:Type*}\n  [M1:measurable_space α] [M2:measurable_space β] (f:α → β):\n  (∀ B:(set β), (measurable_set B) → measurable_set (f ⁻¹' B))\n  ↔ (measurable f) :=\nbegin\n  unfold measurable,\nend\n\nlemma measurable_intro {α β:Type*}\n  [measurable_space α] [measurable_space β] (f:α → β):\n  (∀ B:(set β), measurable_set B → measurable_set (f ⁻¹' B))\n  → (measurable f) :=\nbegin\n  apply (measurable_def _).mp,\nend\n\nlemma measurable_elim {α β:Type*}\n  [measurable_space α] [measurable_space β] (f:α → β) (B:set β):\n  (measurable f)→ (measurable_set B) → (measurable_set (f ⁻¹' B)) :=\nbegin\n  intros a a_1,\n  apply (measurable_def _).mpr,\n  apply a,\n  apply a_1,\nend\n\n\nlemma measurable_fun_product_measurableh {α β:Type*}\n  [M1:measurable_space α] [M2:measurable_space β]:\n  (@prod.measurable_space α β M1 M2) = M1.comap prod.fst ⊔ M2.comap prod.snd :=\nbegin\n  refl\nend\n\n\nlemma comap_elim {α β:Type*} [M2:measurable_space β] (f:α → β) (B:set β):\n  (measurable_set B) →\n  (M2.comap f).measurable_set'  (set.preimage f B) :=\nbegin\n  intros a,\n  unfold measurable_space.comap,\n  simp,\n  apply exists.intro B,\n  split,\n  apply a,\n  refl\nend\n\n\nlemma measurable_comap {α β:Type*} [M1:measurable_space α] [M2:measurable_space β] (f:α → β):\n  (M2.comap f) ≤ M1 → measurable f :=\nbegin\n  intros a,\n  apply measurable_intro,\n  intros B a_1,\n  have A1:(M2.comap f).measurable_set'  (set.preimage f B),\n  {\n    apply comap_elim,\n    apply a_1,\n  },\n  rw ← measurable_space_le_def2 at a,\n  apply a,\n  apply A1,\nend\n\nlemma fst_measurable {α β:Type*}\n  [M1:measurable_space α] [M2:measurable_space β]:measurable (λ x:(α × β), x.fst) :=\nbegin\n  apply measurable_comap,\n  have A1:M1.comap prod.fst ≤ (@prod.measurable_space α β M1 M2),\n  {\n    rw measurable_fun_product_measurableh,\n    apply complete_lattice.le_sup_left (M1.comap prod.fst) (M2.comap prod.snd),\n  },\n  apply A1,\nend\n\nlemma snd_measurable {α β:Type*}\n  [M1:measurable_space α] [M2:measurable_space β]:measurable (λ x:(α × β), x.snd) :=\nbegin\n  apply measurable_comap,\n  have A1:M2.comap prod.snd ≤ (@prod.measurable_space α β M1 M2),\n  {\n    rw measurable_fun_product_measurableh,\n    apply complete_lattice.le_sup_right (M1.comap prod.fst) (M2.comap prod.snd),\n  },\n  apply A1,\nend\n\n\nlemma comap_def {α β:Type*} {B:set (set β)}\n  (f:α → β):\n  @measurable_space.comap α β f (measurable_space.generate_from B)\n  = (measurable_space.generate_from (set.image (set.preimage f) B)) :=\nbegin\n  apply measurable_space.comap_generate_from,\nend\n\nlemma comap_fst_def {α β:Type*} {Bα:set (set α)}:\n  (measurable_space.generate_from Bα).comap (@prod.fst α β) =\n  measurable_space.generate_from {U:set (α × β)|∃ A∈ Bα, U = set.prod A set.univ} :=\nbegin\n  rw measurable_space.comap_generate_from,\n  rw set.preimage_fst_def,\nend\n\nlemma comap_snd_def {α β:Type*} {Bβ:set (set β)}:\n  (measurable_space.generate_from Bβ).comap (@prod.snd α β) =\n  measurable_space.generate_from {U:set (α × β)|∃ B∈ Bβ, U = set.prod set.univ B} :=\nbegin\n  rw measurable_space.comap_generate_from,\n  rw set.preimage_snd_def,\nend\n\n\n\nlemma measurable_space_sup_def {α:Type*} {B C:set (set α)}:\n  (measurable_space.generate_from B) ⊔ (measurable_space.generate_from C) =\n  (measurable_space.generate_from (B ∪ C)) :=\nbegin\n  apply measurable_space.generate_from_sup_generate_from,\nend\n\nlemma prod_measurable_space_def {α β:Type*} {Bα:set (set α)}\n  {Bβ:set (set β)}:\n  (@prod.measurable_space α β (measurable_space.generate_from Bα)\n  (measurable_space.generate_from Bβ)) =\n  @measurable_space.generate_from (α × β) (\n    {U:set (α × β)|∃ A∈ Bα, U = set.prod A set.univ} ∪\n    {U:set (α × β)|∃ B∈ Bβ, U = set.prod set.univ B})\n   :=\nbegin\n  rw measurable_fun_product_measurableh,\n  rw comap_fst_def,\n  rw comap_snd_def,\n  rw measurable_space_sup_def,\nend\n\n\nlemma set.sUnion_eq_univ_elim {α:Type*} {S:set (set α)} (a:α):\n  (set.sUnion S = set.univ) → (∃ T∈S, a∈ T) :=\nbegin\n  intro A1,\n  have A2:a∈ set.univ := set.mem_univ a,\n  rw ← A1 at A2,\n  simp at A2,\n  cases A2 with T A2,\n  apply exists.intro T,\n  apply exists.intro A2.left,\n  apply A2.right,\nend\n\nlemma prod_measurable_space_le {α β:Type*} {Bα:set (set α)}\n  {Bβ:set (set β)}:\n  @measurable_space.generate_from (α × β) \n    {U:set (α × β)|∃ A∈ Bα, ∃ B∈Bβ,  U = set.prod A B} ≤\n  (@prod.measurable_space α β (measurable_space.generate_from Bα)\n  (measurable_space.generate_from Bβ))\n   :=\nbegin\n  rw prod_measurable_space_def,\n  apply measurable_space.generate_from_le, intros X A5,\n  simp at A5,\n  cases A5 with A A5,\n  cases A5 with A5 A6,\n  cases A6 with B A6,\n  cases A6 with A6 A7,\n  have A8:(set.prod A (@set.univ β)) ∩ \n          (set.prod (@set.univ α) B) = set.prod A B,\n  {\n    ext p,split;intros A3A;{\n      simp at A3A,\n      simp,\n       --cases p,\n      apply A3A,\n    },\n  },\n  rw ← A8 at A7,\n  rw A7,\n  apply measurable_set.inter,\n  {\n    apply measurable_space.measurable_set_generate_from,\n    apply set.mem_union_left,\n    simp,\n    apply exists.intro A,\n    split,\n    apply A5,\n    refl,\n  },\n  { \n    apply measurable_space.measurable_set_generate_from,\n    apply set.mem_union_right,\n    simp,\n    apply exists.intro B,\n    split,\n    apply A6,\n    refl,\n  },\nend\n\nlemma prod_measurable_space_def2 {α β:Type*} {Bα:set (set α)}\n  {Bβ:set (set β)} {Cα:set (set α)} {Cβ:set (set β)}:\n  (set.countable Cα) →\n  (set.countable Cβ) →\n  (Cα ⊆ Bα) →\n  (Cβ ⊆ Bβ) →\n  (set.sUnion Cα = set.univ) →\n  (set.sUnion Cβ = set.univ) →\n  (@prod.measurable_space α β (measurable_space.generate_from Bα)\n  (measurable_space.generate_from Bβ)) =\n  @measurable_space.generate_from (α × β) \n    {U:set (α × β)|∃ A∈ Bα, ∃ B∈Bβ,  U = set.prod A B}\n   :=\nbegin\n  intros A1 A2 A3 A4 AX1 AX2,\n  --rw prod_measurable_space_def,\n  apply le_antisymm,\n  {\n    rw prod_measurable_space_def,\n    apply measurable_space.generate_from_le,\n    intros X A5,\n    simp at A5,\n    cases A5,\n    {\n       cases A5 with A A5,\n       cases A5 with A5 A6,\n       have A7:X = set.sUnion (set.image (set.prod A) Cβ), \n       {\n         rw A6,\n         ext a,split;intro A7A;simp;simp at A7A,\n         {\n           have A7B := set.sUnion_eq_univ_elim a.snd AX2,\n           cases A7B with i A7B,\n           cases A7B with A7B A7C,\n           apply exists.intro i,\n           apply and.intro A7B (and.intro A7A A7C),\n         },\n         {\n           cases A7A with i A7A,\n           apply A7A.right.left,\n         },\n       },\n       rw A7,\n       --apply measurable_space.measurable_set_generate_from,\n       apply measurable_set.sUnion,\n       apply set.countable.image,\n       apply A2,\n       intro U,\n       intro A8,\n       simp at A8,\n       cases A8 with B A8,\n       cases A8 with A8 A9,\n       subst U,\n       apply measurable_space.measurable_set_generate_from,\n       simp,\n       apply exists.intro A,\n       split,\n       apply A5,\n       apply exists.intro B,\n       split,\n       rw set.subset_def at A4,\n       apply A4,\n       apply A8,\n       refl,\n    },\n    {\n       cases A5 with B A5,\n       cases A5 with A5 A6,\n       have A7:X = set.sUnion (set.image (λ x, set.prod x B)  Cα), \n       {\n         rw A6,\n         ext a,split;intro A7A;simp;simp at A7A,\n         {\n           have A7B := set.sUnion_eq_univ_elim a.fst AX1,\n           cases A7B with i A7B,\n           cases A7B with A7B A7C,\n           apply exists.intro i,\n           apply and.intro A7B (and.intro A7C A7A),\n         },\n         {\n           cases A7A with i A7A,\n           apply A7A.right.right,\n         },\n       },\n       rw A7,\n       --apply measurable_space.measurable_set_generate_from,\n       apply measurable_set.sUnion,\n       apply set.countable.image,\n       apply A1,\n       intro U,\n       intro A8,\n       simp at A8,\n       cases A8 with A A8,\n       cases A8 with A8 A9,\n       subst U,\n       apply measurable_space.measurable_set_generate_from,\n       simp,\n       apply exists.intro A,\n       split,\n       rw set.subset_def at A3,\n       apply A3,\n       apply A8,\n       apply exists.intro B,\n       split,\n       apply A5,\n       refl,\n    },\n  },\n  {\n    apply prod_measurable_space_le,\n  }\nend\n\n\nlemma preimage_compl {α β:Type*} (f:α → β) (S:set β):\n  (f ⁻¹' Sᶜ) = ((f ⁻¹' S)ᶜ) :=\nbegin\n  ext,\n  split;intros a,\n  {\n    intro a_1,\n    unfold set.preimage at a,\n    simp at a,\n    apply a,\n    apply a_1,\n  },\n  {\n    unfold set.preimage,\n    simp,\n    intro a_1,\n    apply a,\n    apply a_1,\n  }\nend\n\n\nlemma preimage_Union {α β:Type*} (f:α → β) (g:ℕ → set β):\n   (f ⁻¹' ⋃ (i : ℕ), g i)=(⋃ (i : ℕ), f ⁻¹' (g i)) :=\nbegin\n  ext,\n  split;intros a,\n  {\n    cases a with B a,\n    cases a with H a,\n    cases H with y H,\n    split,\n    simp,\n    split,\n    apply exists.intro y,\n    {\n      simp at H,\n    },\n    {\n      simp at H,\n      subst B,\n      apply a,\n    }\n  },\n  {\n    cases a with A a,\n    cases a with A1 A2,\n    cases A1 with i A3,\n    simp at A3,\n    subst A,\n    split,\n    simp,\n    split,\n    {\n      apply exists.intro i,\n      refl,\n    },\n    {\n      apply A2,\n    },\n  }\nend\n\n\n\nlemma generate_from_measurable {α β:Type*} [M:measurable_space α] [M2:measurable_space β]\n   (X:set (set β)) (f:α → β):\n   (measurable_space.generate_from X = M2)→\n   (∀ B∈ X, measurable_set (set.preimage f B))→\n   (measurable f) :=\nbegin\n  intros a a_1,\n  apply measurable_intro,\n  intros B a_2,\n  have A1:@measurable_set β (measurable_space.generate_from X) B,\n  {\n    rw a,\n    apply a_2,\n  },\n  clear a_2, -- Important for induction later.\n  have A2:measurable_space.generate_measurable X B,\n  {\n    apply A1,\n  },\n  induction A2,\n  {\n    apply a_1,\n    apply A2_H,\n  },\n  {\n    simp,\n  },\n  { -- ⊢ measurable_set (f ⁻¹' -A2_s)\n    rw preimage_compl,\n    apply measurable_space.measurable_set_compl,\n    apply A2_ih,\n    {\n      apply (measurable_set.compl_iff).mp,\n      apply A1,\n    },\n  },\n  {\n    rw preimage_Union,\n    apply measurable_space.measurable_set_Union,\n    intros i,\n    apply A2_ih,\n    {\n      apply A2_ᾰ,\n    }\n  }\nend\n\n\nlemma generate_from_self {α:Type*}\n  (M:measurable_space α):\n  M = measurable_space.generate_from {s : set α|measurable_space.measurable_set' M s} :=\nbegin\n  ext,\n  split;intros a,\n  {\n    apply measurable_space.generate_measurable.basic,\n    apply a,\n  },\n  {\n    induction a,\n    {\n      apply a_H,\n    },\n    {\n      apply measurable_space.measurable_set_empty,\n    },\n    {\n      apply measurable_space.measurable_set_compl,\n      apply a_ih,\n    },\n    {\n      apply measurable_space.measurable_set_Union,\n      apply a_ih,\n    },\n  }\nend\n\n\nlemma measurable_fun_comap_def {α β:Type*}\n  [M2:measurable_space β]  (f:α → β):\n  measurable_space.comap f M2 = measurable_space.generate_from\n  {s : set α|∃ (s' : set β), measurable_space.measurable_set' M2 s' ∧ f ⁻¹' s' = s} :=\nbegin\n  unfold measurable_space.comap,\n  apply generate_from_self,\nend\n\n\n\n\nlemma measurable_fun_product_measurable {α β γ:Type*}\n  [M1:measurable_space α] [M2:measurable_space β] [M3:measurable_space γ]\n  (X: α →  β) (Y: α → γ):\n  measurable X →\n  measurable Y →\n  measurable (λ a:α, prod.mk (X a) (Y a)) :=\nbegin\n  intros B1 B2,\n  have A1:@measurable _ _ _ (@prod.measurable_space β γ M2 M3) (λ a:α, prod.mk (X a) (Y a)),\n  {\n    have A1A:(@prod.measurable_space β  γ  M2 M3)=measurable_space.generate_from (\n      {s : set (β × γ) | ∃ (s' : set β), measurable_space.measurable_set' M2 s' ∧ prod.fst ⁻¹' s' = s} ∪\n      {s : set (β  × γ) | ∃ (s' : set γ), measurable_space.measurable_set' M3 s' ∧ prod.snd ⁻¹' s' = s}),\n    {\n      rw measurable_fun_product_measurableh,\n      rw measurable_fun_comap_def,\n      rw measurable_fun_comap_def,\n      rw measurable_space.generate_from_sup_generate_from,\n    },\n    rw A1A,\n    apply generate_from_measurable,\n    {\n      refl,\n    },\n    {\n      intro BC,\n      intros H,\n      cases H,\n      {\n        cases H with B H,\n        cases H,\n        subst BC,\n        have A1B:(λ (a : α), (X a, Y a)) ⁻¹' (prod.fst ⁻¹' B) = (X ⁻¹' B),\n        {\n          ext,split;intros a,\n          {\n            simp at a,\n            apply a,\n          },\n          {\n            simp,\n            apply a,\n          }\n        },\n        rw A1B,\n        apply B1,\n        apply H_left,\n      },\n      {\n        cases H with C H,\n        cases H,\n        subst BC,\n        have A1C:(λ (a : α), (X a, Y a)) ⁻¹' (prod.snd ⁻¹' C) = (Y ⁻¹' C),\n        {\n          ext,split;intros a,\n          {\n            simp at a,\n            apply a,\n          },\n          {\n            simp,\n            apply a,\n          }\n        },\n        rw A1C,\n        apply B2,\n        apply H_left,\n      }\n    }\n  },\n  apply A1,\nend\n\nlemma compose_measurable_fun_measurable {α β γ:Type*}\n  [measurable_space α] [measurable_space β] [measurable_space γ]\n  (X:β → γ) (Y: α→  β):\n  measurable X →\n  measurable Y →\n  measurable (X ∘ Y) :=\nbegin\n  intros B1 B2,\n  apply measurable_intro,\n  intros B a,\n  have A1:(X ∘ Y ⁻¹' B)=(Y ⁻¹' (X ⁻¹' B)),\n  {\n    refl,\n  },\n  rw A1,\n  apply measurable_elim Y _ B2,\n  apply measurable_elim X _ B1,\n  apply a\nend\n\n-- Constant functions are measurable.\n-- Different than measurable_set.const\nlemma const_measurable {Ω:Type*} [measurable_space Ω] {β:Type*} [measurable_space β] (c:β):\n  (measurable (λ ω:Ω, c)) :=\nbegin\n  apply measurable_const,\nend\n\nlemma measurable_set_of_le_of_measurable_set\n{α : Type*} {M1 : measurable_space α} {M2 : measurable_space α} \n  {X:set α}:\n  M1 ≤ M2 →\nmeasurable_space.measurable_set' M1 X →\n   measurable_space.measurable_set' M2 X :=\nbegin\n  intros A2 A1,\n  rw ← measurable_space_le_def2 at A2,\n  apply A2,\n  apply A1,\nend\n\n-- cf. measurable_set_prod\nlemma measurable_set_prod' {β : Type*} {γ : Type*}\n  {Mβ : measurable_space β} {Mγ : measurable_space γ} \n  {X:set β} {Y:set γ}:measurable_set X →\n   measurable_set Y →\n   measurable_set (set.prod X Y) :=\nbegin\n  --apply measurable_set_of_le_of_measurable_set,\n  intros A1 A2,\n  rw generate_from_self Mβ,\n  rw generate_from_self Mγ,\n  apply measurable_set_of_le_of_measurable_set,\n  apply prod_measurable_space_le,\n  apply measurable_space.measurable_set_generate_from,\n  simp,\n  apply exists.intro X,\n  split,\n  apply A1,\n  apply exists.intro Y,\n  split,\n  apply A2,\n  refl,\nend\n\nlemma measurable.preimage {α β:Type*} [measurable_space α] [measurable_space β] {f:α → β}\n   {S:set β}:measurable f → measurable_set S → measurable_set (set.preimage f S) :=\nbegin\n  intros A1 A2,\n  apply A1,\n  apply A2,\nend\n\nlemma measurable.if {α β:Type*}\n  {Mα:measurable_space α} {Mβ:measurable_space β}\n  {E:set α} {D:decidable_pred E}\n  {X Y:α → β}:measurable_set E →\n  measurable X →\n  measurable Y →\n  measurable (λ a:α, if (E a) then (X a) else (Y a)) :=\nbegin\n  intros A1 A2 A3,\n  intros S B1,\n  rw preimage_if,\n  apply measurable_set.union,\n  {\n    apply measurable_set.inter,\n    apply A1,\n    apply A2,\n    apply B1,\n  }, \n  {\n    apply measurable_set.inter,\n    apply measurable_set.compl,\n    apply A1,\n    apply A3,\n    apply B1,\n  },\nend \n\n\nlemma measurable_set.pi' {α:Type*} [F:fintype α] {β:α → Type*} [M:∀ a, measurable_space (β a)]\n  {P:Π a, set (β a)} (T:set α):(∀ a, measurable_set (P a)) →\n  measurable_set (set.pi T P) := begin\n  classical,\n  intros A0,\n  have A1:(set.pi T P) = ⋂ (a ∈ T), ((λ (p:Π a, β a), p a) ⁻¹' (P a)),\n  { ext x, simp,  },\n  rw A1,\n  have A3:trunc (encodable α) := encodable.trunc_encodable_of_fintype α,\n  trunc_cases A3,\n  haveI:encodable α := A3,\n  apply measurable_set.Inter,\n  intros a',\n  cases classical.em (a' ∈ T) with A4 A4,\n  { have A5:(⋂ (H : a' ∈ T), (λ (p : Π (a : α), β a), p a') ⁻¹' P a') =\n            (λ (p : Π (a : α), β a), p a') ⁻¹' P a',\n    { ext, simp; split; intros A5_1,\n      apply A5_1 A4,\n      intros A5_2, apply A5_1 },\n      rw A5,\n    have A2:measurable_space.comap (λ (p:Π a, β a), p a') (M a') ≤ measurable_space.pi,\n    { simp [measurable_space.pi], apply @le_supr (measurable_space (Π a, β a)) _ _ _ (a') },\n    apply A2,\n    simp [measurable_space.comap],\n    apply exists.intro (P a'),\n    simp,\n    apply A0 a' },\n  { have A6:(⋂ (H : a' ∈ T), (λ (p : Π (a : α), β a), p a') ⁻¹' P a') = set.univ,\n    { ext, simp; intros A6_1,\n      apply absurd A4,\n      simp,apply A6_1 },\n    rw A6,\n    simp, },\nend\n\n\n--Unused.\nlemma measurable_space.generate_measurable_monotone {α:Type*} {s t:set (set α)}:\n  (s ⊆ t) → \n  (∀ u, (measurable_space.generate_measurable s u → \n          measurable_space.generate_measurable t u)) :=\nbegin\n  intros h1 u h2,\n  induction h2 with u' h_u' u' h_u' h_ind f h_f h_ind,\n  { apply measurable_space.generate_measurable.basic,\n    apply h1,\n    apply h_u' },\n  { apply measurable_space.generate_measurable.empty },\n  { apply measurable_space.generate_measurable.compl,\n    apply h_ind },\n  { apply measurable_space.generate_measurable.union,\n    apply h_ind },\nend\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/measurable_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4926429556092759}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov, Patrick Massot\n\n! This file was ported from Lean 3 source module data.set.intervals.proj_Icc\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Function\nimport Mathbin.Data.Set.Intervals.Basic\n\n/-!\n# Projection of a line onto a closed interval\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nGiven a linearly ordered type `α`, in this file we define\n\n* `set.proj_Icc (a b : α) (h : a ≤ b)` to be the map `α → [a, b]` sending `(-∞, a]` to `a`, `[b, ∞)`\n  to `b`, and each point `x ∈ [a, b]` to itself;\n* `set.Icc_extend {a b : α} (h : a ≤ b) (f : Icc a b → β)` to be the extension of `f` to `α` defined\n  as `f ∘ proj_Icc a b h`.\n\nWe also prove some trivial properties of these maps.\n-/\n\n\nvariable {α β : Type _} [LinearOrder α]\n\nopen Function\n\nnamespace Set\n\n#print Set.projIcc /-\n/-- Projection of `α` to the closed interval `[a, b]`. -/\ndef projIcc (a b : α) (h : a ≤ b) (x : α) : Icc a b :=\n  ⟨max a (min b x), le_max_left _ _, max_le h (min_le_left _ _)⟩\n#align set.proj_Icc Set.projIcc\n-/\n\nvariable {a b : α} (h : a ≤ b) {x : α}\n\n#print Set.projIcc_of_le_left /-\ntheorem projIcc_of_le_left (hx : x ≤ a) : projIcc a b h x = ⟨a, left_mem_Icc.2 h⟩ := by\n  simp [proj_Icc, hx, hx.trans h]\n#align set.proj_Icc_of_le_left Set.projIcc_of_le_left\n-/\n\n#print Set.projIcc_left /-\n@[simp]\ntheorem projIcc_left : projIcc a b h a = ⟨a, left_mem_Icc.2 h⟩ :=\n  projIcc_of_le_left h le_rfl\n#align set.proj_Icc_left Set.projIcc_left\n-/\n\n#print Set.projIcc_of_right_le /-\ntheorem projIcc_of_right_le (hx : b ≤ x) : projIcc a b h x = ⟨b, right_mem_Icc.2 h⟩ := by\n  simp [proj_Icc, hx, h]\n#align set.proj_Icc_of_right_le Set.projIcc_of_right_le\n-/\n\n#print Set.projIcc_right /-\n@[simp]\ntheorem projIcc_right : projIcc a b h b = ⟨b, right_mem_Icc.2 h⟩ :=\n  projIcc_of_right_le h le_rfl\n#align set.proj_Icc_right Set.projIcc_right\n-/\n\n#print Set.projIcc_eq_left /-\ntheorem projIcc_eq_left (h : a < b) : projIcc a b h.le x = ⟨a, left_mem_Icc.mpr h.le⟩ ↔ x ≤ a :=\n  by\n  refine' ⟨fun h' => _, proj_Icc_of_le_left _⟩\n  simp_rw [Subtype.ext_iff_val, proj_Icc, max_eq_left_iff, min_le_iff, h.not_le, false_or_iff] at h'\n  exact h'\n#align set.proj_Icc_eq_left Set.projIcc_eq_left\n-/\n\n#print Set.projIcc_eq_right /-\ntheorem projIcc_eq_right (h : a < b) : projIcc a b h.le x = ⟨b, right_mem_Icc.mpr h.le⟩ ↔ b ≤ x :=\n  by\n  refine' ⟨fun h' => _, proj_Icc_of_right_le _⟩\n  simp_rw [Subtype.ext_iff_val, proj_Icc] at h'\n  have := ((max_choice _ _).resolve_left (by simp [h.ne', h'])).symm.trans h'\n  exact min_eq_left_iff.mp this\n#align set.proj_Icc_eq_right Set.projIcc_eq_right\n-/\n\n#print Set.projIcc_of_mem /-\ntheorem projIcc_of_mem (hx : x ∈ Icc a b) : projIcc a b h x = ⟨x, hx⟩ := by\n  simp [proj_Icc, hx.1, hx.2]\n#align set.proj_Icc_of_mem Set.projIcc_of_mem\n-/\n\n#print Set.projIcc_val /-\n@[simp]\ntheorem projIcc_val (x : Icc a b) : projIcc a b h x = x :=\n  by\n  cases x\n  apply proj_Icc_of_mem\n#align set.proj_Icc_coe Set.projIcc_val\n-/\n\n#print Set.projIcc_surjOn /-\ntheorem projIcc_surjOn : SurjOn (projIcc a b h) (Icc a b) univ := fun x _ =>\n  ⟨x, x.2, projIcc_val h x⟩\n#align set.proj_Icc_surj_on Set.projIcc_surjOn\n-/\n\n#print Set.projIcc_surjective /-\ntheorem projIcc_surjective : Surjective (projIcc a b h) := fun x => ⟨x, projIcc_val h x⟩\n#align set.proj_Icc_surjective Set.projIcc_surjective\n-/\n\n#print Set.range_projIcc /-\n@[simp]\ntheorem range_projIcc : range (projIcc a b h) = univ :=\n  (projIcc_surjective h).range_eq\n#align set.range_proj_Icc Set.range_projIcc\n-/\n\n#print Set.monotone_projIcc /-\ntheorem monotone_projIcc : Monotone (projIcc a b h) := fun x y hxy =>\n  max_le_max le_rfl <| min_le_min le_rfl hxy\n#align set.monotone_proj_Icc Set.monotone_projIcc\n-/\n\n#print Set.strictMonoOn_projIcc /-\ntheorem strictMonoOn_projIcc : StrictMonoOn (projIcc a b h) (Icc a b) := fun x hx y hy hxy => by\n  simpa only [proj_Icc_of_mem, hx, hy]\n#align set.strict_mono_on_proj_Icc Set.strictMonoOn_projIcc\n-/\n\n#print Set.IccExtend /-\n/-- Extend a function `[a, b] → β` to a map `α → β`. -/\ndef IccExtend {a b : α} (h : a ≤ b) (f : Icc a b → β) : α → β :=\n  f ∘ projIcc a b h\n#align set.Icc_extend Set.IccExtend\n-/\n\n/- warning: set.Icc_extend_range -> Set.IccExtend_range is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β), Eq.{succ u2} (Set.{u2} β) (Set.range.{u2, succ u1} β α (Set.IccExtend.{u1, u2} α β _inst_1 a b h f)) (Set.range.{u2, succ u1} β (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β), Eq.{succ u1} (Set.{u1} β) (Set.range.{u1, succ u2} β α (Set.IccExtend.{u2, u1} α β _inst_1 a b h f)) (Set.range.{u1, succ u2} β (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) f)\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_range Set.IccExtend_rangeₓ'. -/\n@[simp]\ntheorem IccExtend_range (f : Icc a b → β) : range (IccExtend h f) = range f := by\n  simp only [Icc_extend, range_comp f, range_proj_Icc, range_id']\n#align set.Icc_extend_range Set.IccExtend_range\n\n/- warning: set.Icc_extend_of_le_left -> Set.IccExtend_of_le_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) {x : α} (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β), (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) x a) -> (Eq.{succ u2} β (Set.IccExtend.{u1, u2} α β _inst_1 a b h f x) (f (Subtype.mk.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) a (Iff.mpr (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (Set.left_mem_Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b) h))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) {x : α} (f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β), (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) x a) -> (Eq.{succ u1} β (Set.IccExtend.{u2, u1} α β _inst_1 a b h f x) (f (Subtype.mk.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) a (Iff.mpr (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (Set.left_mem_Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b) h))))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_of_le_left Set.IccExtend_of_le_leftₓ'. -/\ntheorem IccExtend_of_le_left (f : Icc a b → β) (hx : x ≤ a) :\n    IccExtend h f x = f ⟨a, left_mem_Icc.2 h⟩ :=\n  congr_arg f <| projIcc_of_le_left h hx\n#align set.Icc_extend_of_le_left Set.IccExtend_of_le_left\n\n/- warning: set.Icc_extend_left -> Set.IccExtend_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β), Eq.{succ u2} β (Set.IccExtend.{u1, u2} α β _inst_1 a b h f a) (f (Subtype.mk.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) a (Iff.mpr (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (Set.left_mem_Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b) h)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β), Eq.{succ u1} β (Set.IccExtend.{u2, u1} α β _inst_1 a b h f a) (f (Subtype.mk.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) a (Iff.mpr (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (Set.left_mem_Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b) h)))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_left Set.IccExtend_leftₓ'. -/\n@[simp]\ntheorem IccExtend_left (f : Icc a b → β) : IccExtend h f a = f ⟨a, left_mem_Icc.2 h⟩ :=\n  IccExtend_of_le_left h f le_rfl\n#align set.Icc_extend_left Set.IccExtend_left\n\n/- warning: set.Icc_extend_of_right_le -> Set.IccExtend_of_right_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) {x : α} (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β), (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) b x) -> (Eq.{succ u2} β (Set.IccExtend.{u1, u2} α β _inst_1 a b h f x) (f (Subtype.mk.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) b (Iff.mpr (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (Set.right_mem_Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b) h))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) {x : α} (f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β), (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) b x) -> (Eq.{succ u1} β (Set.IccExtend.{u2, u1} α β _inst_1 a b h f x) (f (Subtype.mk.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) b (Iff.mpr (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) b (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (Set.right_mem_Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b) h))))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_of_right_le Set.IccExtend_of_right_leₓ'. -/\ntheorem IccExtend_of_right_le (f : Icc a b → β) (hx : b ≤ x) :\n    IccExtend h f x = f ⟨b, right_mem_Icc.2 h⟩ :=\n  congr_arg f <| projIcc_of_right_le h hx\n#align set.Icc_extend_of_right_le Set.IccExtend_of_right_le\n\n/- warning: set.Icc_extend_right -> Set.IccExtend_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β), Eq.{succ u2} β (Set.IccExtend.{u1, u2} α β _inst_1 a b h f b) (f (Subtype.mk.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) b (Iff.mpr (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (Set.right_mem_Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b) h)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β), Eq.{succ u1} β (Set.IccExtend.{u2, u1} α β _inst_1 a b h f b) (f (Subtype.mk.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) b (Iff.mpr (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) b (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (Set.right_mem_Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b) h)))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_right Set.IccExtend_rightₓ'. -/\n@[simp]\ntheorem IccExtend_right (f : Icc a b → β) : IccExtend h f b = f ⟨b, right_mem_Icc.2 h⟩ :=\n  IccExtend_of_right_le h f le_rfl\n#align set.Icc_extend_right Set.IccExtend_right\n\n/- warning: set.Icc_extend_of_mem -> Set.IccExtend_of_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) {x : α} (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (hx : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)), Eq.{succ u2} β (Set.IccExtend.{u1, u2} α β _inst_1 a b h f x) (f (Subtype.mk.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) x hx))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) {x : α} (f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β) (hx : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)), Eq.{succ u1} β (Set.IccExtend.{u2, u1} α β _inst_1 a b h f x) (f (Subtype.mk.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) x hx))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_of_mem Set.IccExtend_of_memₓ'. -/\ntheorem IccExtend_of_mem (f : Icc a b → β) (hx : x ∈ Icc a b) : IccExtend h f x = f ⟨x, hx⟩ :=\n  congr_arg f <| projIcc_of_mem h hx\n#align set.Icc_extend_of_mem Set.IccExtend_of_mem\n\n/- warning: set.Icc_extend_coe -> Set.Icc_extend_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (x : coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)), Eq.{succ u2} β (Set.IccExtend.{u1, u2} α β _inst_1 a b h f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)))))) x)) (f x)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) (f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β) (x : Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)), Eq.{succ u1} β (Set.IccExtend.{u2, u1} α β _inst_1 a b h f (Subtype.val.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) x)) (f x)\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_coe Set.Icc_extend_coeₓ'. -/\n@[simp]\ntheorem Icc_extend_coe (f : Icc a b → β) (x : Icc a b) : IccExtend h f x = f x :=\n  congr_arg f <| projIcc_val h x\n#align set.Icc_extend_coe Set.Icc_extend_coe\n\nend Set\n\nopen Set\n\nvariable [Preorder β] {a b : α} (h : a ≤ b) {f : Icc a b → β}\n\n/- warning: monotone.Icc_extend -> Monotone.IccExtend is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : Preorder.{u2} β] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β}, (Monotone.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) _inst_2 f) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 (Set.IccExtend.{u1, u2} α β _inst_1 a b h f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : Preorder.{u1} β] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) {f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β}, (Monotone.{u2, u1} (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) β (Subtype.preorder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b))) _inst_2 f) -> (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 (Set.IccExtend.{u2, u1} α β _inst_1 a b h f))\nCase conversion may be inaccurate. Consider using '#align monotone.Icc_extend Monotone.IccExtendₓ'. -/\ntheorem Monotone.IccExtend (hf : Monotone f) : Monotone (IccExtend h f) :=\n  hf.comp <| monotone_projIcc h\n#align monotone.Icc_extend Monotone.IccExtend\n\n/- warning: strict_mono.strict_mono_on_Icc_extend -> StrictMono.strictMonoOn_IccExtend is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : Preorder.{u2} β] {a : α} {b : α} (h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b) {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β}, (StrictMono.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) _inst_2 f) -> (StrictMonoOn.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 (Set.IccExtend.{u1, u2} α β _inst_1 a b h f) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : Preorder.{u1} β] {a : α} {b : α} (h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b) {f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β}, (StrictMono.{u2, u1} (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) β (Subtype.preorder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b))) _inst_2 f) -> (StrictMonoOn.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 (Set.IccExtend.{u2, u1} α β _inst_1 a b h f) (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b))\nCase conversion may be inaccurate. Consider using '#align strict_mono.strict_mono_on_Icc_extend StrictMono.strictMonoOn_IccExtendₓ'. -/\ntheorem StrictMono.strictMonoOn_IccExtend (hf : StrictMono f) :\n    StrictMonoOn (IccExtend h f) (Icc a b) :=\n  hf.comp_strictMonoOn (strictMonoOn_projIcc h)\n#align strict_mono.strict_mono_on_Icc_extend StrictMono.strictMonoOn_IccExtend\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Set/Intervals/ProjIcc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.4926429544591106}}
{"text": "/-\nAuthor: <Redacted for anonymized submission>\n-/\n\nimport .vars\nimport ...attributes\nimport ...integral_domain_tactic\n\n/-!\n# Knowledge Soundness\n\nThis file proves the knowledge-soundness property of a very trivial SNARK\n-/\n\nopen_locale big_operators classical\n\nsection\n\nopen mv_polynomial vars\n\nnoncomputable theory\n\nuniverses u\n\n\n/-- The finite field parameter of our SNARK -/\nparameter {F : Type u}\nparameter [field F]\n\n-- TODO\n\n/-- Checks whether a statement witness pair satisfies the SSP -/\ndef satisfying (a b c d e : F) := a * d = e ∨ b * c = e\n\n\n\n/-- The coefficients of the CRS elements in the algebraic adversary's representation -/\nparameters {A B C D E  : F}\n\n\n\n\n/-- Polynomial forms of the adversary's proof representation -/\ndef proof1 : mv_polynomial vars F := \n  mv_polynomial.C A * X vars.α\n  +\n  mv_polynomial.C B * X vars.β\n\ndef proof2 : mv_polynomial vars F := \n  mv_polynomial.C C * X vars.α\n  +\n  mv_polynomial.C D * X vars.β\n\ndef proof3 : mv_polynomial vars F := \n  mv_polynomial.C E * X vars.α * X vars.β\n\n\n\ndef verified  : Prop := proof1 * proof2 = proof3\n\nopen finsupp\n\n/-- The main theorem for the soundness of the Groth '16 SNARK. \nShow that if the adversary polynomials obey the equations, \nthen the coefficients give a satisfying witness. -/\ntheorem soundness : \n  verified\n  -> (satisfying A B C D E)\n:=\nbegin\n  \n  intros eqn,\n  rw satisfying,\n  \n  rw verified at eqn,\n  rw [proof1, proof2, proof3] at eqn,\n\n  simp only [] with polynomial_nf_3 at eqn,\n\n  have h20 := congr_arg (coeff (single α 2 + single β 0)) eqn,\n  have h11 := congr_arg (coeff (single α 1 + single β 1)) eqn,\n  have h02 := congr_arg (coeff (single α 0 + single β 2)) eqn,\n\n  clear eqn,\n\n  simp only [finsupp_vars_eq_ext] with coeff_simp finsupp_eq at *,\n  simp only [] with finsupp_simp at *,\n\n  tactic.integral_domain_tactic_v3,\n  repeat { apply or.inr, assumption, },\n  repeat { apply or.inl, assumption, },\n\nend \n\nend \n\n\n\n", "meta": {"author": "BoltonBailey", "repo": "formal-snarks-project", "sha": "154414784f90a1e257162fcbdd7e805ecb2a49c2", "save_path": "github-repos/lean/BoltonBailey-formal-snarks-project", "path": "github-repos/lean/BoltonBailey-formal-snarks-project/formal-snarks-project-154414784f90a1e257162fcbdd7e805ecb2a49c2/src/snarks/toysnark/knowledge_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.831143060406073, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4925907316862873}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.pnat.basic\nimport Mathlib.data.finset.intervals\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\nnamespace pnat\n\n\n/-- `Ico l u` is the set of positive natural numbers `l ≤ k < u`. -/\ndef Ico (l : ℕ+) (u : ℕ+) : finset ℕ+ :=\n  finset.map\n    (function.embedding.mk\n      (fun (n : Subtype fun (x : ℕ) => x ∈ finset.Ico ↑l ↑u) => { val := ↑n, property := sorry })\n      sorry)\n    (finset.attach (finset.Ico ↑l ↑u))\n\n@[simp] theorem Ico.mem {n : ℕ+} {m : ℕ+} {l : ℕ+} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := sorry\n\n@[simp] theorem Ico.card (l : ℕ+) (u : ℕ+) : finset.card (Ico l u) = ↑u - ↑l := sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/pnat/intervals_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4925907292074087}}
{"text": "import topology.algebra.ordered\nimport o_minimal.order\n\nnamespace omin\n\nopen o_minimal\n\nuniverse u\n\nvariables (R : Type u) [decidable_linear_order R] (S : struc R)\n\nvariables {X : Type*} [has_coordinates R X]\nvariables {Y : Type*} [has_coordinates R Y]\nvariables {Z : Type*} [has_coordinates R Z]\nvariables {W : Type*} [has_coordinates R W]\n\nsection\n\nlocal attribute [instance] preorder.topology\n\nvariables (X)\ndef coordinate_topology : topological_space X :=\ntopological_space.induced (@coords R X _) (show topological_space (fin _ → R), by apply_instance)\n\nend\n\nvariables {X}\ndef is_open (s : set X) : Prop :=\n@_root_.is_open X (coordinate_topology R X) s\n\ndef interior (s : set X) : set X :=\n@_root_.interior X (coordinate_topology R X) s\n\ndef continuous (f : X → Y) : Prop :=\n@_root_.continuous X Y (coordinate_topology R X) (coordinate_topology R Y) f\n\nsection\n\n-- This seems like it shouldn't work, because we need to guess `R`,\n-- but it does work here (but not above for some reason).\nlocal attribute [instance] coordinate_topology\n\nlemma is_open_univ : is_open R (set.univ : set X) :=\n_root_.is_open_univ\n\n-- etc.\n\nlemma is_open_iff_subset_interior {s : set X} : is_open R s ↔ s ⊆ interior R s :=\nsubset_interior_iff_open.symm\n\nlemma mem_interior_iff {s : set X} {x : X} :\n  x ∈ interior R s ↔\n  ∃ (l u : fin _ → R), (∀ i, l i < coords R x i ∧ coords R x i < u i)\n    ∧ ∀ y, (∀ i, l i < coords R y i ∧ coords R y i < u i) → y ∈ s :=\nsorry\n\nend\n\n-- Definability.\n\nvariables [is_definable_le S R]\nvariables [is_definable S X] [is_definable S Y] [is_definable S Z] [is_definable S W]\n\nlemma def_interior {s : set X} (hs : def_set S s) : def_set S (interior R s) :=\nbegin\n  -- TODO: would it make more sense to use `fin _ → R` for the types of `l`, `u`?\n  -- bring back instance for `fin n → R` (or `fin n → X`)?\n  suffices : def_set S\n    {x | ∃ (l u : finvec _ R), (∀ i, l i < coords R x i ∧ coords R x i < u i)\n         ∧ ∀ y, (∀ i, l i < coords R y i ∧ coords R y i < u i) → y ∈ s},\n  { convert this,\n    ext x,\n    rw mem_interior_iff, refl },\n  apply def_set.exists,\n  apply def_set.exists,\n  apply def_set.and,\n  { apply def_set.forall_fintype, intro i,\n    apply def_set.and,\n    { apply definable_lt,\n      exact (def_fun.coord_rn i).comp (def_fun.snd.comp def_fun.fst),\n      exact (def_fun.coord i).comp (def_fun.fst.comp def_fun.fst) },\n    { apply definable_lt,\n      exact (def_fun.coord i).comp (def_fun.fst.comp def_fun.fst),\n      exact (def_fun.coord_rn i).comp def_fun.snd } },\n  { apply def_set.forall,\n    apply def_set.imp,\n    { apply def_set.forall_fintype, intro i,\n      apply def_set.and,\n      { apply definable_lt,\n        exact (def_fun.coord_rn i).comp (def_fun.snd.comp (def_fun.fst.comp def_fun.fst)),\n        exact (def_fun.coord i).comp def_fun.snd },\n      { apply definable_lt,\n        exact (def_fun.coord i).comp def_fun.snd,\n        exact (def_fun.coord_rn i).comp (def_fun.snd.comp def_fun.fst) } },\n    exact def_fun.preimage def_fun.snd hs }\nend\n\nend omin\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/omin/topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583168, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.49259072424965133}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.monoidal.opposite\n! leanprover-community/mathlib commit 14b69e9f3c16630440a2cbd46f1ddad0d561dee7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Monoidal.Coherence\n\n/-!\n# Monoidal opposites\n\nWe write `Cᵐᵒᵖ` for the monoidal opposite of a monoidal category `C`.\n-/\n\n\nuniverse v₁ v₂ u₁ u₂\n\nvariable {C : Type u₁}\n\nnamespace CategoryTheory\n\nopen CategoryTheory.MonoidalCategory\n\n/-- A type synonym for the monoidal opposite. Use the notation `Cᴹᵒᵖ`. -/\n@[nolint has_nonempty_instance]\ndef MonoidalOpposite (C : Type u₁) :=\n  C\n#align category_theory.monoidal_opposite CategoryTheory.MonoidalOpposite\n\nnamespace MonoidalOpposite\n\n-- mathport name: «expr ᴹᵒᵖ»\nnotation:max C \"ᴹᵒᵖ\" => MonoidalOpposite C\n\n/-- Think of an object of `C` as an object of `Cᴹᵒᵖ`. -/\n@[pp_nodot]\ndef mop (X : C) : Cᴹᵒᵖ :=\n  X\n#align category_theory.monoidal_opposite.mop CategoryTheory.MonoidalOpposite.mop\n\n/-- Think of an object of `Cᴹᵒᵖ` as an object of `C`. -/\n@[pp_nodot]\ndef unmop (X : Cᴹᵒᵖ) : C :=\n  X\n#align category_theory.monoidal_opposite.unmop CategoryTheory.MonoidalOpposite.unmop\n\ntheorem op_injective : Function.Injective (mop : C → Cᴹᵒᵖ) := fun _ _ => id\n#align category_theory.monoidal_opposite.op_injective CategoryTheory.MonoidalOpposite.op_injective\n\ntheorem unop_injective : Function.Injective (unmop : Cᴹᵒᵖ → C) := fun _ _ => id\n#align category_theory.monoidal_opposite.unop_injective CategoryTheory.MonoidalOpposite.unop_injective\n\n@[simp]\ntheorem op_inj_iff (x y : C) : mop x = mop y ↔ x = y :=\n  Iff.rfl\n#align category_theory.monoidal_opposite.op_inj_iff CategoryTheory.MonoidalOpposite.op_inj_iff\n\n@[simp]\ntheorem unop_inj_iff (x y : Cᴹᵒᵖ) : unmop x = unmop y ↔ x = y :=\n  Iff.rfl\n#align category_theory.monoidal_opposite.unop_inj_iff CategoryTheory.MonoidalOpposite.unop_inj_iff\n\n@[simp]\ntheorem mop_unmop (X : Cᴹᵒᵖ) : mop (unmop X) = X :=\n  rfl\n#align category_theory.monoidal_opposite.mop_unmop CategoryTheory.MonoidalOpposite.mop_unmop\n\n@[simp]\ntheorem unmop_mop (X : C) : unmop (mop X) = X :=\n  rfl\n#align category_theory.monoidal_opposite.unmop_mop CategoryTheory.MonoidalOpposite.unmop_mop\n\ninstance monoidalOppositeCategory [I : Category.{v₁} C] : Category Cᴹᵒᵖ\n    where\n  Hom X Y := unmop X ⟶ unmop Y\n  id X := 𝟙 (unmop X)\n  comp X Y Z f g := f ≫ g\n#align category_theory.monoidal_opposite.monoidal_opposite_category CategoryTheory.MonoidalOpposite.monoidalOppositeCategory\n\nend MonoidalOpposite\n\nend CategoryTheory\n\nopen CategoryTheory\n\nopen CategoryTheory.MonoidalOpposite\n\nvariable [Category.{v₁} C]\n\n/-- The monoidal opposite of a morphism `f : X ⟶ Y` is just `f`, thought of as `mop X ⟶ mop Y`. -/\ndef Quiver.Hom.mop {X Y : C} (f : X ⟶ Y) : @Quiver.Hom Cᴹᵒᵖ _ (mop X) (mop Y) :=\n  f\n#align quiver.hom.mop Quiver.Hom.mop\n\n/-- We can think of a morphism `f : mop X ⟶ mop Y` as a morphism `X ⟶ Y`. -/\ndef Quiver.Hom.unmop {X Y : Cᴹᵒᵖ} (f : X ⟶ Y) : unmop X ⟶ unmop Y :=\n  f\n#align quiver.hom.unmop Quiver.Hom.unmop\n\nnamespace CategoryTheory\n\ntheorem mop_inj {X Y : C} : Function.Injective (Quiver.Hom.mop : (X ⟶ Y) → (mop X ⟶ mop Y)) :=\n  fun _ _ H => congr_arg Quiver.Hom.unmop H\n#align category_theory.mop_inj CategoryTheory.mop_inj\n\ntheorem unmop_inj {X Y : Cᴹᵒᵖ} :\n    Function.Injective (Quiver.Hom.unmop : (X ⟶ Y) → (unmop X ⟶ unmop Y)) := fun _ _ H =>\n  congr_arg Quiver.Hom.mop H\n#align category_theory.unmop_inj CategoryTheory.unmop_inj\n\n@[simp]\ntheorem unmop_mop {X Y : C} {f : X ⟶ Y} : f.mop.unmop = f :=\n  rfl\n#align category_theory.unmop_mop CategoryTheory.unmop_mop\n\n@[simp]\ntheorem mop_unmop {X Y : Cᴹᵒᵖ} {f : X ⟶ Y} : f.unmop.mop = f :=\n  rfl\n#align category_theory.mop_unmop CategoryTheory.mop_unmop\n\n@[simp]\ntheorem mop_comp {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} : (f ≫ g).mop = f.mop ≫ g.mop :=\n  rfl\n#align category_theory.mop_comp CategoryTheory.mop_comp\n\n@[simp]\ntheorem mop_id {X : C} : (𝟙 X).mop = 𝟙 (mop X) :=\n  rfl\n#align category_theory.mop_id CategoryTheory.mop_id\n\n@[simp]\ntheorem unmop_comp {X Y Z : Cᴹᵒᵖ} {f : X ⟶ Y} {g : Y ⟶ Z} : (f ≫ g).unmop = f.unmop ≫ g.unmop :=\n  rfl\n#align category_theory.unmop_comp CategoryTheory.unmop_comp\n\n@[simp]\ntheorem unmop_id {X : Cᴹᵒᵖ} : (𝟙 X).unmop = 𝟙 (unmop X) :=\n  rfl\n#align category_theory.unmop_id CategoryTheory.unmop_id\n\n@[simp]\ntheorem unmop_id_mop {X : C} : (𝟙 (mop X)).unmop = 𝟙 X :=\n  rfl\n#align category_theory.unmop_id_mop CategoryTheory.unmop_id_mop\n\n@[simp]\ntheorem mop_id_unmop {X : Cᴹᵒᵖ} : (𝟙 (unmop X)).mop = 𝟙 X :=\n  rfl\n#align category_theory.mop_id_unmop CategoryTheory.mop_id_unmop\n\nnamespace Iso\n\nvariable {X Y : C}\n\n/-- An isomorphism in `C` gives an isomorphism in `Cᴹᵒᵖ`. -/\n@[simps]\ndef mop (f : X ≅ Y) : mop X ≅ mop Y where\n  Hom := f.Hom.mop\n  inv := f.inv.mop\n  hom_inv_id' := unmop_inj f.hom_inv_id\n  inv_hom_id' := unmop_inj f.inv_hom_id\n#align category_theory.iso.mop CategoryTheory.Iso.mop\n\nend Iso\n\nvariable [MonoidalCategory.{v₁} C]\n\nopen Opposite MonoidalCategory\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ninstance monoidalCategoryOp : MonoidalCategory Cᵒᵖ\n    where\n  tensorObj X Y := op (unop X ⊗ unop Y)\n  tensorHom X₁ Y₁ X₂ Y₂ f g := (f.unop ⊗ g.unop).op\n  tensorUnit := op (𝟙_ C)\n  associator X Y Z := (α_ (unop X) (unop Y) (unop Z)).symm.op\n  leftUnitor X := (λ_ (unop X)).symm.op\n  rightUnitor X := (ρ_ (unop X)).symm.op\n  associator_naturality' := by\n    intros\n    apply Quiver.Hom.unop_inj\n    simp\n  leftUnitor_naturality' := by\n    intros\n    apply Quiver.Hom.unop_inj\n    simp\n  rightUnitor_naturality' := by\n    intros\n    apply Quiver.Hom.unop_inj\n    simp\n  triangle' := by\n    intros\n    apply Quiver.Hom.unop_inj\n    coherence\n  pentagon' := by\n    intros\n    apply Quiver.Hom.unop_inj\n    coherence\n#align category_theory.monoidal_category_op CategoryTheory.monoidalCategoryOp\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem op_tensorObj (X Y : Cᵒᵖ) : X ⊗ Y = op (unop X ⊗ unop Y) :=\n  rfl\n#align category_theory.op_tensor_obj CategoryTheory.op_tensorObj\n\ntheorem op_tensorUnit : 𝟙_ Cᵒᵖ = op (𝟙_ C) :=\n  rfl\n#align category_theory.op_tensor_unit CategoryTheory.op_tensorUnit\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ninstance monoidalCategoryMop : MonoidalCategory Cᴹᵒᵖ\n    where\n  tensorObj X Y := mop (unmop Y ⊗ unmop X)\n  tensorHom X₁ Y₁ X₂ Y₂ f g := (g.unmop ⊗ f.unmop).mop\n  tensorUnit := mop (𝟙_ C)\n  associator X Y Z := (α_ (unmop Z) (unmop Y) (unmop X)).symm.mop\n  leftUnitor X := (ρ_ (unmop X)).mop\n  rightUnitor X := (λ_ (unmop X)).mop\n  associator_naturality' := by\n    intros\n    apply unmop_inj\n    simp\n  leftUnitor_naturality' := by\n    intros\n    apply unmop_inj\n    simp\n  rightUnitor_naturality' := by\n    intros\n    apply unmop_inj\n    simp\n  triangle' := by\n    intros\n    apply unmop_inj\n    coherence\n  pentagon' := by\n    intros\n    apply unmop_inj\n    coherence\n#align category_theory.monoidal_category_mop CategoryTheory.monoidalCategoryMop\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem mop_tensorObj (X Y : Cᴹᵒᵖ) : X ⊗ Y = mop (unmop Y ⊗ unmop X) :=\n  rfl\n#align category_theory.mop_tensor_obj CategoryTheory.mop_tensorObj\n\ntheorem mop_tensorUnit : 𝟙_ Cᴹᵒᵖ = mop (𝟙_ C) :=\n  rfl\n#align category_theory.mop_tensor_unit CategoryTheory.mop_tensorUnit\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Monoidal/Opposite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105587468141, "lm_q2_score": 0.7401743677704878, "lm_q1q2_score": 0.4925198396282302}}
{"text": "\nuniverses u\n\nnamespace Ex1\n\nstructure A (α : Type u) :=\n(x : α) (f : α → α := λ x => x)\n\nstructure B (α : Type u) extends A α :=\n(y : α := f (f x)) (g : α → α → α := λ x y => f x)\n\nstructure C (α : Type u) extends B α :=\n(z : α := g x y) (x := f z)\n\nend Ex1\n\nopen Ex1\n\ndef c1 : C Nat := { x := 1 }\n\n#check { c1 with z := 2 }\n\n#check { c1 with z := 2 }\n\ntheorem ex1 : { c1 with z := 2 }.z = 2 :=\nrfl\n\n#check ex1\n\ntheorem ex2 : { c1 with z := 2 }.x = c1.x :=\nrfl\n\n#check ex2\n\ndef c2 : C (Nat × Nat) := { z := (1, 1) }\n\n#check { c2 with x.fst := 2 }\n\n#check { c2 with x.1 := 3 }\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/run/structInst3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.665410572017153, "lm_q1q2_score": 0.49251983800924937}}
{"text": "/-\nCopyright © 2020 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicolò Cavalleri\n-/\n\nimport geometry.manifold.algebra.monoid\n\n/-!\n# Lie groups\n\nA Lie group is a group that is also a smooth manifold, in which the group operations of\nmultiplication and inversion are smooth maps. Smoothness of the group multiplication means that\nmultiplication is a smooth mapping of the product manifold `G` × `G` into `G`.\n\nNote that, since a manifold here is not second-countable and Hausdorff a Lie group here is not\nguaranteed to be second-countable (even though it can be proved it is Hausdorff). Note also that Lie\ngroups here are not necessarily finite dimensional.\n\n## Main definitions and statements\n\n* `lie_add_group I G` : a Lie additive group where `G` is a manifold on the model with corners `I`.\n* `lie_group I G`     : a Lie multiplicative group where `G` is a manifold on the model with\n                        corners `I`.\n* `normed_space_lie_add_group` : a normed vector space over a nontrivially normed field\n                                 is an additive Lie group.\n\n## Implementation notes\n\nA priori, a Lie group here is a manifold with corners.\n\nThe definition of Lie group cannot require `I : model_with_corners 𝕜 E E` with the same space as the\nmodel space and as the model vector space, as one might hope, beause in the product situation,\nthe model space is `model_prod E E'` and the model vector space is `E × E'`, which are not the same,\nso the definition does not apply. Hence the definition should be more general, allowing\n`I : model_with_corners 𝕜 E H`.\n-/\n\nnoncomputable theory\n\nopen_locale manifold\n\n/-- A Lie (additive) group is a group and a smooth manifold at the same time in which\nthe addition and negation operations are smooth. -/\n-- See note [Design choices about smooth algebraic structures]\n@[ancestor has_smooth_add]\nclass lie_add_group {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E] (I : model_with_corners 𝕜 E H)\n  (G : Type*) [add_group G] [topological_space G] [charted_space H G]\n  extends has_smooth_add I G : Prop :=\n(smooth_neg : smooth I I (λ a:G, -a))\n\n/-- A Lie group is a group and a smooth manifold at the same time in which\nthe multiplication and inverse operations are smooth. -/\n-- See note [Design choices about smooth algebraic structures]\n@[ancestor has_smooth_mul, to_additive]\nclass lie_group {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E] (I : model_with_corners 𝕜 E H)\n  (G : Type*) [group G] [topological_space G] [charted_space H G]\n  extends has_smooth_mul I G : Prop :=\n(smooth_inv : smooth I I (λ a:G, a⁻¹))\n\nsection lie_group\n\nvariables {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n{H : Type*} [topological_space H]\n{E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E] {I : model_with_corners 𝕜 E H}\n{F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F] {J : model_with_corners 𝕜 F F}\n{G : Type*} [topological_space G] [charted_space H G] [group G] [lie_group I G]\n{E' : Type*} [normed_add_comm_group E'] [normed_space 𝕜 E']\n{H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}\n{M : Type*} [topological_space M] [charted_space H' M]\n{E'' : Type*} [normed_add_comm_group E''] [normed_space 𝕜 E'']\n{H'' : Type*} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''}\n{M' : Type*} [topological_space M'] [charted_space H'' M']\n\nsection\n\nvariable (I)\n\n@[to_additive]\nlemma smooth_inv : smooth I I (λ x : G, x⁻¹) :=\nlie_group.smooth_inv\n\n/-- A Lie group is a topological group. This is not an instance for technical reasons,\nsee note [Design choices about smooth algebraic structures]. -/\n@[to_additive\n\"An additive Lie group is an additive topological group. This is not an instance for technical\nreasons, see note [Design choices about smooth algebraic structures].\"]\nlemma topological_group_of_lie_group : topological_group G :=\n{ continuous_inv := (smooth_inv I).continuous,\n  .. has_continuous_mul_of_smooth I }\n\nend\n\n@[to_additive]\nlemma smooth.inv {f : M → G}\n  (hf : smooth I' I f) : smooth I' I (λx, (f x)⁻¹) :=\n(smooth_inv I).comp hf\n\n@[to_additive]\nlemma smooth_on.inv {f : M → G} {s : set M}\n  (hf : smooth_on I' I f s) : smooth_on I' I (λx, (f x)⁻¹) s :=\n(smooth_inv I).comp_smooth_on hf\n\n@[to_additive]\nlemma smooth.div {f g : M → G}\n  (hf : smooth I' I f) (hg : smooth I' I g) : smooth I' I (f / g) :=\nby { rw div_eq_mul_inv, exact ((smooth_mul I).comp (hf.prod_mk hg.inv) : _), }\n\n@[to_additive]\nlemma smooth_on.div {f g : M → G} {s : set M}\n  (hf : smooth_on I' I f s) (hg : smooth_on I' I g s) : smooth_on I' I (f / g) s :=\nby { rw div_eq_mul_inv, exact ((smooth_mul I).comp_smooth_on (hf.prod_mk hg.inv) : _), }\n\nend lie_group\n\nsection prod_lie_group\n\n/- Instance of product group -/\n@[to_additive]\ninstance {𝕜 : Type*} [nontrivially_normed_field 𝕜] {H : Type*} [topological_space H]\n  {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]  {I : model_with_corners 𝕜 E H}\n  {G : Type*} [topological_space G] [charted_space H G] [group G] [lie_group I G]\n  {E' : Type*} [normed_add_comm_group E'] [normed_space 𝕜 E']\n  {H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}\n  {G' : Type*} [topological_space G'] [charted_space H' G']\n  [group G'] [lie_group I' G'] :\n  lie_group (I.prod I') (G×G') :=\n{ smooth_inv := smooth_fst.inv.prod_mk smooth_snd.inv,\n  ..has_smooth_mul.prod _ _ _ _ }\n\nend prod_lie_group\n\n/-! ### Normed spaces are Lie groups -/\n\ninstance normed_space_lie_add_group {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n  {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E] :\n  lie_add_group (𝓘(𝕜, E)) E :=\n{ smooth_add := smooth_iff.2 ⟨continuous_add, λ x y, cont_diff_add.cont_diff_on⟩,\n  smooth_neg := smooth_iff.2 ⟨continuous_neg, λ x y, cont_diff_neg.cont_diff_on⟩,\n  .. model_space_smooth }\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/geometry/manifold/algebra/lie_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.49251982599208355}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport analysis.box_integral.basic\nimport measure_theory.measure.regular\n\n/-!\n# McShane integrability vs Bochner integrability\n\nIn this file we prove that any Bochner integrable function is McShane integrable (hence, it is\nHenstock and `⊥` integrable) with the same integral. The proof is based on\n[Russel A. Gordon, *The integrals of Lebesgue, Denjoy, Perron, and Henstock*][Gordon55].\n\n## Tags\n\nintegral, McShane integral, Bochner integral\n-/\n\nopen_locale classical nnreal ennreal topology big_operators\n\nuniverses u v\n\nvariables {ι : Type u} {E : Type v} [fintype ι] [normed_add_comm_group E] [normed_space ℝ E]\n\nopen measure_theory metric set finset filter box_integral\n\nnamespace box_integral\n\n/-- The indicator function of a measurable set is McShane integrable with respect to any\nlocally-finite measure. -/\nlemma has_integral_indicator_const (l : integration_params) (hl : l.bRiemann = ff)\n  {s : set (ι → ℝ)} (hs : measurable_set s) (I : box ι) (y : E)\n  (μ : measure (ι → ℝ)) [is_locally_finite_measure μ] :\n  has_integral.{u v v} I l (s.indicator (λ _, y)) μ.to_box_additive.to_smul\n    ((μ (s ∩ I)).to_real • y) :=\nbegin\n  refine has_integral_of_mul (‖y‖) (λ ε ε0, _),\n  lift ε to ℝ≥0 using ε0.le, rw nnreal.coe_pos at ε0,\n  /- First we choose a closed set `F ⊆ s ∩ I.Icc` and an open set `U ⊇ s` such that\n  both `(s ∩ I.Icc) \\ F` and `U \\ s` have measuer less than `ε`. -/\n  have A : μ (s ∩ I.Icc) ≠ ∞,\n    from ((measure_mono $ set.inter_subset_right _ _).trans_lt (I.measure_Icc_lt_top μ)).ne,\n  have B : μ (s ∩ I) ≠ ∞,\n    from ((measure_mono $ set.inter_subset_right _ _).trans_lt (I.measure_coe_lt_top μ)).ne,\n  obtain ⟨F, hFs, hFc, hμF⟩ : ∃ F ⊆ s ∩ I.Icc, is_closed F ∧ μ ((s ∩ I.Icc) \\ F) < ε,\n    from (hs.inter I.measurable_set_Icc).exists_is_closed_diff_lt A (ennreal.coe_pos.2 ε0).ne',\n  obtain ⟨U, hsU, hUo, hUt, hμU⟩ : ∃ U ⊇ s ∩ I.Icc, is_open U ∧ μ U < ∞ ∧ μ (U \\ (s ∩ I.Icc)) < ε,\n    from (hs.inter I.measurable_set_Icc).exists_is_open_diff_lt A (ennreal.coe_pos.2 ε0).ne',\n  /- Then we choose `r` so that `closed_ball x (r x) ⊆ U` whenever `x ∈ s ∩ I.Icc` and\n  `closed_ball x (r x)` is disjoint with `F` otherwise. -/\n  have : ∀ x ∈ s ∩ I.Icc, ∃ r : Ioi (0 : ℝ), closed_ball x r ⊆ U,\n    from λ x hx, subtype.exists'.1 (nhds_basis_closed_ball.mem_iff.1 (hUo.mem_nhds $ hsU hx)),\n  choose! rs hrsU,\n  have : ∀ x ∈ I.Icc \\ s, ∃ r : Ioi (0 : ℝ), closed_ball x r ⊆ Fᶜ,\n    from λ x hx, subtype.exists'.1 (nhds_basis_closed_ball.mem_iff.1 (hFc.is_open_compl.mem_nhds $\n      λ hx', hx.2 (hFs hx').1)),\n  choose! rs' hrs'F,\n  set r : (ι → ℝ) → Ioi (0 : ℝ) := s.piecewise rs rs',\n  refine ⟨λ c, r, λ c, l.r_cond_of_bRiemann_eq_ff hl, λ c π hπ hπp, _⟩, rw mul_comm,\n  /- Then the union of boxes `J ∈ π` such that `π.tag ∈ s` includes `F` and is included by `U`,\n  hence its measure is `ε`-close to the measure of `s`. -/\n  dsimp [integral_sum],\n  simp only [mem_closed_ball, dist_eq_norm, ← indicator_const_smul_apply,\n    sum_indicator_eq_sum_filter, ← sum_smul, ← sub_smul, norm_smul, real.norm_eq_abs,\n    ← prepartition.filter_boxes, ← prepartition.measure_Union_to_real],\n  refine mul_le_mul_of_nonneg_right _ (norm_nonneg y),\n  set t := (π.to_prepartition.filter (λ J, π.tag J ∈ s)).Union,\n  change abs ((μ t).to_real - (μ (s ∩ I)).to_real) ≤ ε,\n  have htU : t ⊆ U ∩ I,\n  { simp only [t, prepartition.Union_def, Union_subset_iff, prepartition.mem_filter, and_imp],\n    refine λ J hJ hJs x hx, ⟨hrsU _ ⟨hJs, π.tag_mem_Icc J⟩  _, π.le_of_mem' J hJ hx⟩,\n    simpa only [r, s.piecewise_eq_of_mem _ _ hJs] using hπ.1 J hJ (box.coe_subset_Icc hx) },\n  refine abs_sub_le_iff.2 ⟨_, _⟩,\n  { refine (ennreal.le_to_real_sub B).trans (ennreal.to_real_le_coe_of_le_coe _),\n    refine (tsub_le_tsub (measure_mono htU) le_rfl).trans (le_measure_diff.trans _),\n    refine (measure_mono $ λ x hx, _).trans hμU.le,\n    exact ⟨hx.1.1, λ hx', hx.2 ⟨hx'.1, hx.1.2⟩⟩ },\n  { have hμt : μ t ≠ ∞ :=\n      ((measure_mono (htU.trans (inter_subset_left _ _))).trans_lt hUt).ne,\n    refine (ennreal.le_to_real_sub hμt).trans (ennreal.to_real_le_coe_of_le_coe _),\n    refine le_measure_diff.trans ((measure_mono _).trans hμF.le),\n    rintro x ⟨⟨hxs, hxI⟩, hxt⟩,\n    refine ⟨⟨hxs, box.coe_subset_Icc hxI⟩, λ hxF, hxt _⟩,\n    simp only [t, prepartition.Union_def, prepartition.mem_filter, set.mem_Union, exists_prop],\n    rcases hπp x hxI with ⟨J, hJπ, hxJ⟩,\n    refine ⟨J, ⟨hJπ, _⟩, hxJ⟩,\n    contrapose hxF,\n    refine hrs'F _ ⟨π.tag_mem_Icc J, hxF⟩ _,\n    simpa only [r, s.piecewise_eq_of_not_mem _ _ hxF] using hπ.1 J hJπ (box.coe_subset_Icc hxJ) }\nend\n\n/-- If `f` is a.e. equal to zero on a rectangular box, then it has McShane integral zero on this\nbox. -/\nlemma has_integral_zero_of_ae_eq_zero {l : integration_params} {I : box ι} {f : (ι → ℝ) → E}\n  {μ : measure (ι → ℝ)} [is_locally_finite_measure μ] (hf : f =ᵐ[μ.restrict I] 0)\n  (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l f μ.to_box_additive.to_smul 0 :=\nbegin\n  /- Each set `{x | n < ‖f x‖ ≤ n + 1}`, `n : ℕ`, has measure zero. We cover it by an open set of\n  measure less than `ε / 2 ^ n / (n + 1)`. Then the norm of the integral sum is less than `ε`. -/\n  refine has_integral_iff.2 (λ ε ε0, _),\n  lift ε to ℝ≥0 using ε0.lt.le, rw [gt_iff_lt, nnreal.coe_pos] at ε0,\n  rcases nnreal.exists_pos_sum_of_countable ε0.ne' ℕ with ⟨δ, δ0, c, hδc, hcε⟩,\n  haveI := fact.mk (I.measure_coe_lt_top μ),\n  change μ.restrict I {x | f x ≠ 0} = 0 at hf,\n  set N : (ι → ℝ) → ℕ := λ x, ⌈‖f x‖⌉₊,\n  have N0 : ∀ {x}, N x = 0 ↔ f x = 0, by { intro x, simp [N] },\n  have : ∀ n, ∃ U ⊇ N ⁻¹' {n}, is_open U ∧ μ.restrict I U < δ n / n,\n  { refine λ n, (N ⁻¹' {n}).exists_is_open_lt_of_lt _ _,\n    cases n,\n    { simpa [ennreal.div_zero (ennreal.coe_pos.2 (δ0 _)).ne']\n        using measure_lt_top (μ.restrict I) _ },\n    { refine (measure_mono_null _ hf).le.trans_lt _,\n      { exact λ x hxN hxf, n.succ_ne_zero ((eq.symm hxN).trans $ N0.2 hxf) },\n      { simp [(δ0 _).ne'] } } },\n  choose U hNU hUo hμU,\n  have : ∀ x, ∃ r : Ioi (0 : ℝ), closed_ball x r ⊆ U (N x),\n    from λ x, subtype.exists'.1 (nhds_basis_closed_ball.mem_iff.1 ((hUo _).mem_nhds (hNU _ rfl))),\n  choose r hrU,\n  refine ⟨λ _, r, λ c, l.r_cond_of_bRiemann_eq_ff hl, λ c π hπ hπp, _⟩,\n  rw [dist_eq_norm, sub_zero, ← integral_sum_fiberwise (λ J, N (π.tag J))],\n  refine le_trans _ (nnreal.coe_lt_coe.2 hcε).le,\n  refine (norm_sum_le_of_le _ _).trans\n    (sum_le_has_sum _ (λ n _, (δ n).2) (nnreal.has_sum_coe.2 hδc)),\n  rintro n -,\n  dsimp [integral_sum],\n  have : ∀ J ∈ π.filter (λ J, N (π.tag J) = n),\n    ‖(μ ↑J).to_real • f (π.tag J)‖ ≤ (μ J).to_real * n,\n  { intros J hJ, rw tagged_prepartition.mem_filter at hJ,\n    rw [norm_smul, real.norm_eq_abs, abs_of_nonneg ennreal.to_real_nonneg],\n    exact mul_le_mul_of_nonneg_left (hJ.2 ▸ nat.le_ceil _) ennreal.to_real_nonneg },\n  refine (norm_sum_le_of_le _ this).trans _, clear this,\n  rw [← sum_mul, ← prepartition.measure_Union_to_real],\n  generalize hm : μ (π.filter (λ J, N (π.tag J) = n)).Union = m,\n  have : m < δ n / n,\n  { simp only [measure.restrict_apply (hUo _).measurable_set] at hμU,\n    refine hm ▸ (measure_mono _).trans_lt (hμU _),\n    simp only [set.subset_def, tagged_prepartition.mem_Union, exists_prop,\n      tagged_prepartition.mem_filter],\n    rintro x ⟨J, ⟨hJ, rfl⟩, hx⟩,\n    exact ⟨hrU _ (hπ.1 _ hJ (box.coe_subset_Icc hx)), π.le_of_mem' J hJ hx⟩ },\n  lift m to ℝ≥0 using ne_top_of_lt this,\n  rw [ennreal.coe_to_real, ← nnreal.coe_nat_cast, ← nnreal.coe_mul, nnreal.coe_le_coe,\n    ← ennreal.coe_le_coe, ennreal.coe_mul, ennreal.coe_nat, mul_comm],\n  exact (mul_le_mul_left' this.le _).trans ennreal.mul_div_le\nend\n\n/-- If `f` has integral `y` on a box `I` with respect to a locally finite measure `μ` and `g` is\na.e. equal to `f` on `I`, then `g` has the same integral on `I`.  -/\nlemma has_integral.congr_ae {l : integration_params} {I : box ι} {y : E} {f g : (ι → ℝ) → E}\n  {μ : measure (ι → ℝ)} [is_locally_finite_measure μ]\n  (hf : has_integral.{u v v} I l f μ.to_box_additive.to_smul y)\n  (hfg : f =ᵐ[μ.restrict I] g) (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l g μ.to_box_additive.to_smul y :=\nbegin\n  have : (g - f) =ᵐ[μ.restrict I] 0, from hfg.mono (λ x hx, sub_eq_zero.2 hx.symm),\n  simpa using hf.add (has_integral_zero_of_ae_eq_zero this hl)\nend\n\nend box_integral\n\nnamespace measure_theory\n\nnamespace simple_func\n\n/-- A simple function is McShane integrable w.r.t. any locally finite measure. -/\nlemma has_box_integral (f : simple_func (ι → ℝ) E) (μ : measure (ι → ℝ))\n  [is_locally_finite_measure μ] (I : box ι) (l : integration_params) (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l f μ.to_box_additive.to_smul (f.integral (μ.restrict I)) :=\nbegin\n  induction f using measure_theory.simple_func.induction with y s hs f g hd hfi hgi,\n  { simpa only [measure.restrict_apply hs, const_zero, integral_piecewise_zero, integral_const,\n      measure.restrict_apply, measurable_set.univ, set.univ_inter]\n      using box_integral.has_integral_indicator_const l hl hs I y μ },\n  { borelize E, haveI := fact.mk (I.measure_coe_lt_top μ),\n    rw integral_add,\n    exacts [hfi.add hgi, integrable_iff.2 $ λ _ _, measure_lt_top _ _,\n      integrable_iff.2 $ λ _ _, measure_lt_top _ _] }\nend\n\n/-- For a simple function, its McShane (or Henstock, or `⊥`) box integral is equal to its\nintegral in the sense of `measure_theory.simple_func.integral`. -/\nlemma box_integral_eq_integral (f : simple_func (ι → ℝ) E) (μ : measure (ι → ℝ))\n  [is_locally_finite_measure μ] (I : box ι) (l : integration_params) (hl : l.bRiemann = ff) :\n  box_integral.integral.{u v v} I l f μ.to_box_additive.to_smul = f.integral (μ.restrict I) :=\n(f.has_box_integral μ I l hl).integral_eq\n\nend simple_func\n\nopen topological_space\n\n/-- If `f : ℝⁿ → E` is Bochner integrable w.r.t. a locally finite measure `μ` on a rectangular box\n`I`, then it is McShane integrable on `I` with the same integral.  -/\nlemma integrable_on.has_box_integral [complete_space E] {f : (ι → ℝ) → E} {μ : measure (ι → ℝ)}\n  [is_locally_finite_measure μ] {I : box ι} (hf : integrable_on f I μ) (l : integration_params)\n  (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l f μ.to_box_additive.to_smul (∫ x in I, f x ∂ μ) :=\nbegin\n  borelize E,\n  /- First we replace an `ae_strongly_measurable` function by a measurable one. -/\n  rcases hf.ae_strongly_measurable with ⟨g, hg, hfg⟩,\n  haveI : separable_space (range g ∪ {0} : set E) := hg.separable_space_range_union_singleton,\n  rw integral_congr_ae hfg, have hgi : integrable_on g I μ := (integrable_congr hfg).1 hf,\n  refine box_integral.has_integral.congr_ae _ hfg.symm hl,\n  clear_dependent f,\n  /- Now consider the sequence of simple functions\n  `simple_func.approx_on g hg.measurable (range g ∪ {0}) 0 (by simp)`\n  approximating `g`. Recall some properties of this sequence. -/\n  set f : ℕ → simple_func (ι → ℝ) E :=\n    simple_func.approx_on g hg.measurable (range g ∪ {0}) 0 (by simp),\n  have hfi : ∀ n, integrable_on (f n) I μ,\n    from simple_func.integrable_approx_on_range hg.measurable hgi,\n  have hfi' := λ n, ((f n).has_box_integral μ I l hl).integrable,\n  have hfgi : tendsto (λ n, (f n).integral (μ.restrict I)) at_top (𝓝 $ ∫ x in I, g x ∂μ),\n    from tendsto_integral_approx_on_of_measurable_of_range_subset hg.measurable hgi _ subset.rfl,\n  have hfg_mono : ∀ x {m n}, m ≤ n → ‖f n x - g x‖ ≤ ‖f m x - g x‖,\n  { intros x m n hmn,\n    rw [← dist_eq_norm, ← dist_eq_norm, dist_nndist, dist_nndist, nnreal.coe_le_coe,\n      ← ennreal.coe_le_coe, ← edist_nndist, ← edist_nndist],\n    exact simple_func.edist_approx_on_mono hg.measurable _ x hmn },\n  /- Now consider `ε > 0`. We need to find `r` such that for any tagged partition subordinate\n  to `r`, the integral sum is `(μ I + 1 + 1) * ε`-close to the Bochner integral. -/\n  refine has_integral_of_mul ((μ I).to_real + 1 + 1) (λ ε ε0, _),\n  lift ε to ℝ≥0 using ε0.le, rw nnreal.coe_pos at ε0, have ε0' := ennreal.coe_pos.2 ε0,\n  /- Choose `N` such that the integral of `‖f N x - g x‖` is less than or equal to `ε`. -/\n  obtain ⟨N₀, hN₀⟩ : ∃ N : ℕ, ∫ x in I, ‖f N x - g x‖ ∂μ ≤ ε,\n  { have : tendsto (λ n, ∫⁻ x in I, ‖f n x - g x‖₊ ∂μ) at_top (𝓝 0),\n      from simple_func.tendsto_approx_on_range_L1_nnnorm hg.measurable hgi,\n    refine (this.eventually (ge_mem_nhds ε0')).exists.imp (λ N hN, _),\n    exact integral_coe_le_of_lintegral_coe_le hN },\n  /- For each `x`, we choose `Nx x ≥ N₀` such that `dist (f Nx x) (g x) ≤ ε`. -/\n  have : ∀ x, ∃ N₁, N₀ ≤ N₁ ∧ dist (f N₁ x) (g x) ≤ ε,\n  { intro x,\n    have : tendsto (λ n, f n x) at_top (𝓝 $ g x),\n      from simple_func.tendsto_approx_on hg.measurable _ (subset_closure (by simp)),\n    exact ((eventually_ge_at_top N₀).and $ this $ closed_ball_mem_nhds _ ε0).exists },\n  choose Nx hNx hNxε,\n  /- We also choose a convergent series with `∑' i : ℕ, δ i < ε`. -/\n  rcases nnreal.exists_pos_sum_of_countable ε0.ne' ℕ with ⟨δ, δ0, c, hδc, hcε⟩,\n  /- Since each simple function `fᵢ` is integrable, there exists `rᵢ : ℝⁿ → (0, ∞)` such that\n  the integral sum of `f` over any tagged prepartition is `δᵢ`-close to the sum of integrals\n  of `fᵢ` over the boxes of this prepartition. For each `x`, we choose `r (Nx x)` as the radius\n  at `x`. -/\n  set r : ℝ≥0 → (ι → ℝ) → Ioi (0 : ℝ) := λ c x, (hfi' $ Nx x).convergence_r (δ $ Nx x) c x,\n  refine ⟨r, λ c, l.r_cond_of_bRiemann_eq_ff hl, λ c π hπ hπp, _⟩,\n  /- Now we prove the estimate in 3 \"jumps\": first we replace `g x` in the formula for the\n  integral sum by `f (Nx x)`; then we replace each `μ J • f (Nx (π.tag J)) (π.tag J)`\n  by the Bochner integral of `f (Nx (π.tag J)) x` over `J`, then we jump to the Bochner\n  integral of `g`. -/\n  refine (dist_triangle4 _ (∑ J in π.boxes, (μ J).to_real • f (Nx $ π.tag J) (π.tag J))\n    (∑ J in π.boxes, ∫ x in J, f (Nx $ π.tag J) x ∂μ) _).trans _,\n  rw [add_mul, add_mul, one_mul],\n  refine add_le_add_three _ _ _,\n  { /- Since each `f (Nx $ π.tag J)` is `ε`-close to `g (π.tag J)`, replacing the latter with\n    the former in the formula for the integral sum changes the sum at most by `μ I * ε`. -/\n    rw [← hπp.Union_eq, π.to_prepartition.measure_Union_to_real, sum_mul, integral_sum],\n    refine dist_sum_sum_le_of_le _ (λ J hJ, _), dsimp,\n    rw [dist_eq_norm, ← smul_sub, norm_smul, real.norm_eq_abs,\n      abs_of_nonneg ennreal.to_real_nonneg],\n    refine mul_le_mul_of_nonneg_left _ ennreal.to_real_nonneg,\n    rw [← dist_eq_norm'], exact hNxε _ },\n  { /- We group the terms of both sums by the values of `Nx (π.tag J)`.\n    For each `N`, the sum of Bochner integrals over the boxes is equal\n    to the sum of box integrals, and the sum of box integrals is `δᵢ`-close\n    to the corresponding integral sum due to the Henstock-Sacks inequality. -/\n    rw [← π.to_prepartition.sum_fiberwise (λ J, Nx (π.tag J)),\n      ← π.to_prepartition.sum_fiberwise (λ J, Nx (π.tag J))],\n    refine le_trans _ (nnreal.coe_lt_coe.2 hcε).le,\n    refine (dist_sum_sum_le_of_le _ (λ n hn, _)).trans\n      (sum_le_has_sum _ (λ n _, (δ n).2) (nnreal.has_sum_coe.2 hδc)),\n    have hNxn : ∀ J ∈ π.filter (λ J, Nx (π.tag J) = n), Nx (π.tag J) = n,\n      from λ J hJ, (π.mem_filter.1 hJ).2,\n    have hrn : ∀ J ∈ π.filter (λ J, Nx (π.tag J) = n),\n      r c (π.tag J) = (hfi' n).convergence_r (δ n) c (π.tag J),\n    { intros J hJ,\n      obtain rfl := hNxn J hJ,\n      refl },\n    have : l.mem_base_set I c ((hfi' n).convergence_r (δ n) c) (π.filter (λ J, Nx (π.tag J) = n)),\n      from (hπ.filter _).mono' _ le_rfl le_rfl (λ J hJ, (hrn J hJ).le),\n    convert (hfi' n).dist_integral_sum_sum_integral_le_of_mem_base_set (δ0 _) this using 2,\n    { refine sum_congr rfl (λ J hJ, _),\n      simp [hNxn J hJ] },\n    { refine sum_congr rfl (λ J hJ, _),\n      rw [← simple_func.integral_eq_integral, simple_func.box_integral_eq_integral _ _ _ _ hl,\n        hNxn J hJ],\n      exact (hfi _).mono_set (prepartition.le_of_mem _ hJ) } },\n  { /-  For the last jump, we use the fact that the distance between `f (Nx x) x` and `g x` is less\n    than or equal to the distance between `f N₀ x` and `g x` and the integral of `‖f N₀ x - g x‖`\n    is less than or equal to `ε`. -/\n    refine le_trans _ hN₀,\n    have hfi : ∀ n (J ∈ π), integrable_on (f n) ↑J  μ,\n      from λ n J hJ, (hfi n).mono_set (π.le_of_mem' J hJ),\n    have hgi : ∀ J ∈ π, integrable_on g ↑J μ, from λ J hJ, hgi.mono_set (π.le_of_mem' J hJ),\n    have hfgi : ∀ n (J ∈ π), integrable_on (λ x, ‖f n x - g x‖) J μ,\n      from λ n J hJ, ((hfi n J hJ).sub (hgi J hJ)).norm,\n    rw [← hπp.Union_eq, prepartition.Union_def',\n      integral_finset_bUnion π.boxes (λ J hJ, J.measurable_set_coe) π.pairwise_disjoint hgi,\n      integral_finset_bUnion π.boxes (λ J hJ, J.measurable_set_coe) π.pairwise_disjoint (hfgi _)],\n    refine dist_sum_sum_le_of_le _ (λ J hJ, _),\n    rw [dist_eq_norm, ← integral_sub (hfi _ J hJ) (hgi J hJ)],\n    refine norm_integral_le_of_norm_le (hfgi _ J hJ) (eventually_of_forall $ λ x, _),\n    exact hfg_mono x (hNx (π.tag J)) }\nend\n\nend measure_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/analysis/box_integral/integrability.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.49251982599208355}}
{"text": "import .lang\nimport .ualg\n\nnamespace lang\n\nuniverses v u\nvariables (L : lang.{v}) (S : Type u)\n\ninductive free : Type (max v u)\n| of : S → free\n| op {n} : L n → (fin n → free) → free\n\nnamespace free\ninstance : has_app L (L.free S) :=  \n{ app := λ _, op }\n\ndef univ : S → L.free S := of\n\nvariable {S} \ndef lift {B : Type*} [has_app L B] (f : S → B) : L.free S →$[L] B := \n{ to_fn := λ t, free.rec_on t f (λ n t as bs, applyo t bs),\n  applyo_map' := by tauto }\n\ntheorem univ_comp_lift {B : Type*} [has_app L B] (f : S → B) : (lift L f) ∘ (univ L S) = f := rfl\n\ntheorem lift_unique {B : Type*} [has_app L B] (f : S → B) (g : L.free S →$[L] B) (hyp : g ∘ (univ L S) = f) : g = lift L f := \nbegin\n  apply ralg_hom.ext,\n  ext,\n  induction x with _ _ t as ind, \n  { change (g ∘ (univ _ _)) x = _,\n    rw hyp, refl },\n  { change g (applyo t as) = (lift L f) (applyo t as),\n    simp_rw ←ralg_hom.applyo_map,\n    apply congr_arg,\n    ext,\n    apply ind }\nend\n\nend free\n\nend lang", "meta": {"author": "adamtopaz", "repo": "UnivAlg", "sha": "2458d47a6e4fd0525e3a25b07cb7dd518ac173ef", "save_path": "github-repos/lean/adamtopaz-UnivAlg", "path": "github-repos/lean/adamtopaz-UnivAlg/UnivAlg-2458d47a6e4fd0525e3a25b07cb7dd518ac173ef/src/free_ralg.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4924959323487615}}
{"text": "lemma mul_add (t a b : mynat) : t * (a + b) = t * a + t * b :=\nbegin\ninduction b with k Pk,\nrw mul_zero,\nrepeat { rw add_zero },\nrw mul_succ,\nrw ← add_assoc,\nrw ← Pk,\nrw ← mul_succ,\nrw add_succ,\nrefl,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/3-multiplication-world/l4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920116079208, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.49249593234876143}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.filter.lift\nimport Mathlib.topology.separation\nimport Mathlib.PostPort\n\nuniverses u_1 u u_2 l u_3 u_4 u_6 \n\nnamespace Mathlib\n\n/-!\n# Uniform spaces\n\nUniform spaces are a generalization of metric spaces and topological groups. Many concepts directly\ngeneralize to uniform spaces, e.g.\n\n* uniform continuity (in this file)\n* completeness (in `cauchy.lean`)\n* extension of uniform continuous functions to complete spaces (in `uniform_embedding.lean`)\n* totally bounded sets (in `cauchy.lean`)\n* totally bounded complete sets are compact (in `cauchy.lean`)\n\nA uniform structure on a type `X` is a filter `𝓤 X` on `X × X` satisfying some conditions\nwhich makes it reasonable to say that `∀ᶠ (p : X × X) in 𝓤 X, ...` means\n\"for all p.1 and p.2 in X close enough, ...\". Elements of this filter are called entourages\nof `X`. The two main examples are:\n\n* If `X` is a metric space, `V ∈ 𝓤 X ↔ ∃ ε > 0, { p | dist p.1 p.2 < ε } ⊆ V`\n* If `G` is an additive topological group, `V ∈ 𝓤 G ↔ ∃ U ∈ 𝓝 (0 : G), {p | p.2 - p.1 ∈ U} ⊆ V`\n\nThose examples are generalizations in two different directions of the elementary example where\n`X = ℝ` and `V ∈ 𝓤 ℝ ↔ ∃ ε > 0, { p | |p.2 - p.1| < ε } ⊆ V` which features both the topological\ngroup structure on `ℝ` and its metric space structure.\n\nEach uniform structure on `X` induces a topology on `X` characterized by\n\n> `nhds_eq_comap_uniformity : ∀ {x : X}, 𝓝 x = comap (prod.mk x) (𝓤 X)`\n\nwhere `prod.mk x : X → X × X := (λ y, (x, y))` is the partial evaluation of the product\nconstructor.\n\nThe dictionary with metric spaces includes:\n* an upper bound for `dist x y` translates into `(x, y) ∈ V` for some `V ∈ 𝓤 X`\n* a ball `ball x r` roughly corresponds to `uniform_space.ball x V := {y | (x, y) ∈ V}`\n  for some `V ∈ 𝓤 X`, but the later is more general (it includes in\n  particular both open and closed balls for suitable `V`).\n  In particular we have:\n  `is_open_iff_ball_subset {s : set X} : is_open s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 X, ball x V ⊆ s`\n\nThe triangle inequality is abstracted to a statement involving the composition of relations in `X`.\nFirst note that the triangle inequality in a metric space is equivalent to\n`∀ (x y z : X) (r r' : ℝ), dist x y ≤ r → dist y z ≤ r' → dist x z ≤ r + r'`.\nThen, for any `V` and `W` with type `set (X × X)`, the composition `V ○ W : set (X × X)` is\ndefined as `{ p : X × X | ∃ z, (p.1, z) ∈ V ∧ (z, p.2) ∈ W }`.\nIn the metric space case, if `V = { p | dist p.1 p.2 ≤ r }` and `W = { p | dist p.1 p.2 ≤ r' }`\nthen the triangle inequality, as reformulated above, says `V ○ W` is contained in\n`{p | dist p.1 p.2 ≤ r + r'}` which is the entourage associated to the radius `r + r'`.\nIn general we have `mem_ball_comp (h : y ∈ ball x V) (h' : z ∈ ball y W) : z ∈ ball x (V ○ W)`.\nNote that this discussion does not depend on any axiom imposed on the uniformity filter,\nit is simply captured by the definition of composition.\n\nThe uniform space axioms ask the filter `𝓤 X` to satisfy the following:\n* every `V ∈ 𝓤 X` contains the diagonal `id_rel = { p | p.1 = p.2 }`. This abstracts the fact\n  that `dist x x ≤ r` for every non-negative radius `r` in the metric space case and also that\n  `x - x` belongs to every neighborhood of zero in the topological group case.\n* `V ∈ 𝓤 X → prod.swap '' V ∈ 𝓤 X`. This is tightly related the fact that `dist x y = dist y x`\n  in a metric space, and to continuity of negation in the topological group case.\n* `∀ V ∈ 𝓤 X, ∃ W ∈ 𝓤 X, W ○ W ⊆ V`. In the metric space case, it corresponds\n  to cutting the radius of a ball in half and applying the triangle inequality.\n  In the topological group case, it comes from continuity of addition at `(0, 0)`.\n\nThese three axioms are stated more abstractly in the definition below, in terms of\noperations on filters, without directly manipulating entourages.\n\n## Main definitions\n\n* `uniform_space X` is a uniform space structure on a type `X`\n* `uniform_continuous f` is a predicate saying a function `f : α → β` between uniform spaces\n  is uniformly continuous : `∀ r ∈ 𝓤 β, ∀ᶠ (x : α × α) in 𝓤 α, (f x.1, f x.2) ∈ r`\n\nIn this file we also define a complete lattice structure on the type `uniform_space X`\nof uniform structures on `X`, as well as the pullback (`uniform_space.comap`) of uniform structures\ncoming from the pullback of filters.\nLike distance functions, uniform structures cannot be pushed forward in general.\n\n## Notations\n\nLocalized in `uniformity`, we have the notation `𝓤 X` for the uniformity on a uniform space `X`,\nand `○` for composition of relations, seen as terms with type `set (X × X)`.\n\n## Implementation notes\n\nThere is already a theory of relations in `data/rel.lean` where the main definition is\n`def rel (α β : Type*) := α → β → Prop`.\nThe relations used in the current file involve only one type, but this is not the reason why\nwe don't reuse `data/rel.lean`. We use `set (α × α)`\ninstead of `rel α α` because we really need sets to use the filter library, and elements\nof filters on `α × α` have type `set (α × α)`.\n\nThe structure `uniform_space X` bundles a uniform structure on `X`, a topology on `X` and\nan assumption saying those are compatible. This may not seem mathematically reasonable at first,\nbut is in fact an instance of the forgetful inheritance pattern. See Note [forgetful inheritance]\nbelow.\n\n## References\n\nThe formalization uses the books:\n\n* [N. Bourbaki, *General Topology*][bourbaki1966]\n* [I. M. James, *Topologies and Uniformities*][james1999]\n\nBut it makes a more systematic use of the filter library.\n-/\n\n/-!\n### Relations, seen as `set (α × α)`\n-/\n\n/-- The identity relation, or the graph of the identity function -/\ndef id_rel {α : Type u_1} : set (α × α) := set_of fun (p : α × α) => prod.fst p = prod.snd p\n\n@[simp] theorem mem_id_rel {α : Type u_1} {a : α} {b : α} : (a, b) ∈ id_rel ↔ a = b := iff.rfl\n\n@[simp] theorem id_rel_subset {α : Type u_1} {s : set (α × α)} :\n    id_rel ⊆ s ↔ ∀ (a : α), (a, a) ∈ s :=\n  sorry\n\n/-- The composition of relations -/\ndef comp_rel {α : Type u} (r₁ : set (α × α)) (r₂ : set (α × α)) : set (α × α) :=\n  set_of fun (p : α × α) => ∃ (z : α), (prod.fst p, z) ∈ r₁ ∧ (z, prod.snd p) ∈ r₂\n\n@[simp] theorem mem_comp_rel {α : Type u_1} {r₁ : set (α × α)} {r₂ : set (α × α)} {x : α} {y : α} :\n    (x, y) ∈ comp_rel r₁ r₂ ↔ ∃ (z : α), (x, z) ∈ r₁ ∧ (z, y) ∈ r₂ :=\n  iff.rfl\n\n@[simp] theorem swap_id_rel {α : Type u_1} : prod.swap '' id_rel = id_rel := sorry\n\ntheorem monotone_comp_rel {α : Type u_1} {β : Type u_2} [preorder β] {f : β → set (α × α)}\n    {g : β → set (α × α)} (hf : monotone f) (hg : monotone g) :\n    monotone fun (x : β) => comp_rel (f x) (g x) :=\n  sorry\n\ntheorem comp_rel_mono {α : Type u_1} {f : set (α × α)} {g : set (α × α)} {h : set (α × α)}\n    {k : set (α × α)} (h₁ : f ⊆ h) (h₂ : g ⊆ k) : comp_rel f g ⊆ comp_rel h k :=\n  sorry\n\ntheorem prod_mk_mem_comp_rel {α : Type u_1} {a : α} {b : α} {c : α} {s : set (α × α)}\n    {t : set (α × α)} (h₁ : (a, c) ∈ s) (h₂ : (c, b) ∈ t) : (a, b) ∈ comp_rel s t :=\n  Exists.intro c { left := h₁, right := h₂ }\n\n@[simp] theorem id_comp_rel {α : Type u_1} {r : set (α × α)} : comp_rel id_rel r = r := sorry\n\ntheorem comp_rel_assoc {α : Type u_1} {r : set (α × α)} {s : set (α × α)} {t : set (α × α)} :\n    comp_rel (comp_rel r s) t = comp_rel r (comp_rel s t) :=\n  sorry\n\ntheorem subset_comp_self {α : Type u_1} {s : set (α × α)} (h : id_rel ⊆ s) : s ⊆ comp_rel s s :=\n  sorry\n\n/-- The relation is invariant under swapping factors. -/\ndef symmetric_rel {α : Type u_1} (V : set (α × α)) := prod.swap ⁻¹' V = V\n\n/-- The maximal symmetric relation contained in a given relation. -/\ndef symmetrize_rel {α : Type u_1} (V : set (α × α)) : set (α × α) := V ∩ prod.swap ⁻¹' V\n\ntheorem symmetric_symmetrize_rel {α : Type u_1} (V : set (α × α)) :\n    symmetric_rel (symmetrize_rel V) :=\n  sorry\n\ntheorem symmetrize_rel_subset_self {α : Type u_1} (V : set (α × α)) : symmetrize_rel V ⊆ V :=\n  set.sep_subset V fun (a : α × α) => a ∈ prod.swap ⁻¹' V\n\ntheorem symmetrize_mono {α : Type u_1} {V : set (α × α)} {W : set (α × α)} (h : V ⊆ W) :\n    symmetrize_rel V ⊆ symmetrize_rel W :=\n  set.inter_subset_inter h (set.preimage_mono h)\n\ntheorem symmetric_rel_inter {α : Type u_1} {U : set (α × α)} {V : set (α × α)}\n    (hU : symmetric_rel U) (hV : symmetric_rel V) : symmetric_rel (U ∩ V) :=\n  sorry\n\n/-- This core description of a uniform space is outside of the type class hierarchy. It is useful\n  for constructions of uniform spaces, when the topology is derived from the uniform space. -/\nstructure uniform_space.core (α : Type u) where\n  uniformity : filter (α × α)\n  refl : filter.principal id_rel ≤ uniformity\n  symm : filter.tendsto prod.swap uniformity uniformity\n  comp : (filter.lift' uniformity fun (s : set (α × α)) => comp_rel s s) ≤ uniformity\n\n/-- An alternative constructor for `uniform_space.core`. This version unfolds various\n`filter`-related definitions. -/\ndef uniform_space.core.mk' {α : Type u} (U : filter (α × α))\n    (refl : ∀ (r : set (α × α)), r ∈ U → ∀ (x : α), (x, x) ∈ r)\n    (symm : ∀ (r : set (α × α)), r ∈ U → prod.swap ⁻¹' r ∈ U)\n    (comp : ∀ (r : set (α × α)) (H : r ∈ U), ∃ (t : set (α × α)), ∃ (H : t ∈ U), comp_rel t t ⊆ r) :\n    uniform_space.core α :=\n  uniform_space.core.mk U sorry symm sorry\n\n/-- A uniform space generates a topological space -/\ndef uniform_space.core.to_topological_space {α : Type u} (u : uniform_space.core α) :\n    topological_space α :=\n  topological_space.mk\n    (fun (s : set α) =>\n      ∀ (x : α),\n        x ∈ s →\n          (set_of fun (p : α × α) => prod.fst p = x → prod.snd p ∈ s) ∈\n            uniform_space.core.uniformity u)\n    sorry sorry sorry\n\ntheorem uniform_space.core_eq {α : Type u_1} {u₁ : uniform_space.core α}\n    {u₂ : uniform_space.core α} :\n    uniform_space.core.uniformity u₁ = uniform_space.core.uniformity u₂ → u₁ = u₂ :=\n  sorry\n\n/-- Suppose that one can put two mathematical structures on a type, a rich one `R` and a poor one\n`P`, and that one can deduce the poor structure from the rich structure through a map `F` (called a\nforgetful functor) (think `R = metric_space` and `P = topological_space`). A possible\nimplementation would be to have a type class `rich` containing a field `R`, a type class `poor`\ncontaining a field `P`, and an instance from `rich` to `poor`. However, this creates diamond\nproblems, and a better approach is to let `rich` extend `poor` and have a field saying that\n`F R = P`.\n\nTo illustrate this, consider the pair `metric_space` / `topological_space`. Consider the topology\non a product of two metric spaces. With the first approach, it could be obtained by going first from\neach metric space to its topology, and then taking the product topology. But it could also be\nobtained by considering the product metric space (with its sup distance) and then the topology\ncoming from this distance. These would be the same topology, but not definitionally, which means\nthat from the point of view of Lean's kernel, there would be two different `topological_space`\ninstances on the product. This is not compatible with the way instances are designed and used:\nthere should be at most one instance of a kind on each type. This approach has created an instance\ndiamond that does not commute definitionally.\n\nThe second approach solves this issue. Now, a metric space contains both a distance, a topology, and\na proof that the topology coincides with the one coming from the distance. When one defines the\nproduct of two metric spaces, one uses the sup distance and the product topology, and one has to\ngive the proof that the sup distance induces the product topology. Following both sides of the\ninstance diamond then gives rise (definitionally) to the product topology on the product space.\n\nAnother approach would be to have the rich type class take the poor type class as an instance\nparameter. It would solve the diamond problem, but it would lead to a blow up of the number\nof type classes one would need to declare to work with complicated classes, say a real inner\nproduct space, and would create exponential complexity when working with products of\nsuch complicated spaces, that are avoided by bundling things carefully as above.\n\nNote that this description of this specific case of the product of metric spaces is oversimplified\ncompared to mathlib, as there is an intermediate typeclass between `metric_space` and\n`topological_space` called `uniform_space`. The above scheme is used at both levels, embedding a\ntopology in the uniform space structure, and a uniform structure in the metric space structure.\n\nNote also that, when `P` is a proposition, there is no such issue as any two proofs of `P` are\ndefinitionally equivalent in Lean.\n\nTo avoid boilerplate, there are some designs that can automatically fill the poor fields when\ncreating a rich structure if one doesn't want to do something special about them. For instance,\nin the definition of metric spaces, default tactics fill the uniform space fields if they are\nnot given explicitly. One can also have a helper function creating the rich structure from a\nstructure with less fields, where the helper function fills the remaining fields. See for instance\n`uniform_space.of_core` or `real_inner_product.of_core`.\n\nFor more details on this question, called the forgetful inheritance pattern, see [Competing\ninheritance paths in dependent type theory: a case study in functional\nanalysis](https://hal.inria.fr/hal-02463336).\n-/\n/-- A uniform space is a generalization of the \"uniform\" topological aspects of a\n  metric space. It consists of a filter on `α × α` called the \"uniformity\", which\n  satisfies properties analogous to the reflexivity, symmetry, and triangle properties\n  of a metric.\n\n  A metric space has a natural uniformity, and a uniform space has a natural topology.\n  A topological group also has a natural uniformity, even when it is not metrizable. -/\nclass uniform_space (α : Type u) extends uniform_space.core α, topological_space α where\n  is_open_uniformity :\n    ∀ (s : set α),\n      topological_space.is_open _to_topological_space s ↔\n        ∀ (x : α),\n          x ∈ s →\n            (set_of fun (p : α × α) => prod.fst p = x → prod.snd p ∈ s) ∈\n              uniform_space.core.uniformity _to_core\n\n/-- Alternative constructor for `uniform_space α` when a topology is already given. -/\ndef uniform_space.mk' {α : Type u_1} (t : topological_space α) (c : uniform_space.core α)\n    (is_open_uniformity :\n      ∀ (s : set α),\n        topological_space.is_open t s ↔\n          ∀ (x : α),\n            x ∈ s →\n              (set_of fun (p : α × α) => prod.fst p = x → prod.snd p ∈ s) ∈\n                uniform_space.core.uniformity c) :\n    uniform_space α :=\n  uniform_space.mk c is_open_uniformity\n\n/-- Construct a `uniform_space` from a `uniform_space.core`. -/\ndef uniform_space.of_core {α : Type u} (u : uniform_space.core α) : uniform_space α :=\n  uniform_space.mk u sorry\n\n/-- Construct a `uniform_space` from a `u : uniform_space.core` and a `topological_space` structure\nthat is equal to `u.to_topological_space`. -/\ndef uniform_space.of_core_eq {α : Type u} (u : uniform_space.core α) (t : topological_space α)\n    (h : t = uniform_space.core.to_topological_space u) : uniform_space α :=\n  uniform_space.mk u sorry\n\ntheorem uniform_space.to_core_to_topological_space {α : Type u_1} (u : uniform_space α) :\n    uniform_space.core.to_topological_space uniform_space.to_core =\n        uniform_space.to_topological_space :=\n  sorry\n\ntheorem uniform_space_eq {α : Type u_1} {u₁ : uniform_space α} {u₂ : uniform_space α} :\n    uniform_space.core.uniformity uniform_space.to_core =\n          uniform_space.core.uniformity uniform_space.to_core →\n        u₁ = u₂ :=\n  sorry\n\ntheorem uniform_space.of_core_eq_to_core {α : Type u_1} (u : uniform_space α)\n    (t : topological_space α)\n    (h : t = uniform_space.core.to_topological_space uniform_space.to_core) :\n    uniform_space.of_core_eq uniform_space.to_core t h = u :=\n  uniform_space_eq rfl\n\n/-- The uniformity is a filter on α × α (inferred from an ambient uniform space\n  structure on α). -/\ndef uniformity (α : Type u) [uniform_space α] : filter (α × α) :=\n  uniform_space.core.uniformity uniform_space.to_core\n\ntheorem is_open_uniformity {α : Type u_1} [uniform_space α] {s : set α} :\n    is_open s ↔\n        ∀ (x : α),\n          x ∈ s → (set_of fun (p : α × α) => prod.fst p = x → prod.snd p ∈ s) ∈ uniformity α :=\n  uniform_space.is_open_uniformity s\n\ntheorem refl_le_uniformity {α : Type u_1} [uniform_space α] :\n    filter.principal id_rel ≤ uniformity α :=\n  uniform_space.core.refl uniform_space.to_core\n\ntheorem refl_mem_uniformity {α : Type u_1} [uniform_space α] {x : α} {s : set (α × α)}\n    (h : s ∈ uniformity α) : (x, x) ∈ s :=\n  refl_le_uniformity h rfl\n\ntheorem symm_le_uniformity {α : Type u_1} [uniform_space α] :\n    filter.map prod.swap (uniformity α) ≤ uniformity α :=\n  uniform_space.core.symm uniform_space.to_core\n\ntheorem comp_le_uniformity {α : Type u_1} [uniform_space α] :\n    (filter.lift' (uniformity α) fun (s : set (α × α)) => comp_rel s s) ≤ uniformity α :=\n  uniform_space.core.comp uniform_space.to_core\n\ntheorem tendsto_swap_uniformity {α : Type u_1} [uniform_space α] :\n    filter.tendsto prod.swap (uniformity α) (uniformity α) :=\n  symm_le_uniformity\n\ntheorem comp_mem_uniformity_sets {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (hs : s ∈ uniformity α) : ∃ (t : set (α × α)), ∃ (H : t ∈ uniformity α), comp_rel t t ⊆ s :=\n  (fun (this : s ∈ filter.lift' (uniformity α) fun (t : set (α × α)) => comp_rel t t) =>\n      iff.mp (filter.mem_lift'_sets (monotone_comp_rel monotone_id monotone_id)) this)\n    (comp_le_uniformity hs)\n\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is transitive. -/\ntheorem filter.tendsto.uniformity_trans {α : Type u_1} {β : Type u_2} [uniform_space α]\n    {l : filter β} {f₁ : β → α} {f₂ : β → α} {f₃ : β → α}\n    (h₁₂ : filter.tendsto (fun (x : β) => (f₁ x, f₂ x)) l (uniformity α))\n    (h₂₃ : filter.tendsto (fun (x : β) => (f₂ x, f₃ x)) l (uniformity α)) :\n    filter.tendsto (fun (x : β) => (f₁ x, f₃ x)) l (uniformity α) :=\n  sorry\n\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is symmetric -/\ntheorem filter.tendsto.uniformity_symm {α : Type u_1} {β : Type u_2} [uniform_space α]\n    {l : filter β} {f : β → α × α} (h : filter.tendsto f l (uniformity α)) :\n    filter.tendsto (fun (x : β) => (prod.snd (f x), prod.fst (f x))) l (uniformity α) :=\n  filter.tendsto.comp tendsto_swap_uniformity h\n\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is reflexive. -/\ntheorem tendsto_diag_uniformity {α : Type u_1} {β : Type u_2} [uniform_space α] (f : β → α)\n    (l : filter β) : filter.tendsto (fun (x : β) => (f x, f x)) l (uniformity α) :=\n  fun (s : set (α × α)) (hs : s ∈ uniformity α) =>\n    iff.mpr filter.mem_map (filter.univ_mem_sets' fun (x : β) => refl_mem_uniformity hs)\n\ntheorem tendsto_const_uniformity {α : Type u_1} {β : Type u_2} [uniform_space α] {a : α}\n    {f : filter β} : filter.tendsto (fun (_x : β) => (a, a)) f (uniformity α) :=\n  tendsto_diag_uniformity (fun (_x : β) => a) f\n\ntheorem symm_of_uniformity {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (hs : s ∈ uniformity α) :\n    ∃ (t : set (α × α)), ∃ (H : t ∈ uniformity α), (∀ (a b : α), (a, b) ∈ t → (b, a) ∈ t) ∧ t ⊆ s :=\n  sorry\n\ntheorem comp_symm_of_uniformity {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (hs : s ∈ uniformity α) :\n    ∃ (t : set (α × α)),\n        ∃ (H : t ∈ uniformity α), (∀ {a b : α}, (a, b) ∈ t → (b, a) ∈ t) ∧ comp_rel t t ⊆ s :=\n  sorry\n\ntheorem uniformity_le_symm {α : Type u_1} [uniform_space α] :\n    uniformity α ≤ prod.swap <$> uniformity α :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (uniformity α ≤ prod.swap <$> uniformity α))\n        filter.map_swap_eq_comap_swap))\n    (iff.mp filter.map_le_iff_le_comap tendsto_swap_uniformity)\n\ntheorem uniformity_eq_symm {α : Type u_1} [uniform_space α] :\n    uniformity α = prod.swap <$> uniformity α :=\n  le_antisymm uniformity_le_symm symm_le_uniformity\n\ntheorem symmetrize_mem_uniformity {α : Type u_1} [uniform_space α] {V : set (α × α)}\n    (h : V ∈ uniformity α) : symmetrize_rel V ∈ uniformity α :=\n  sorry\n\ntheorem uniformity_lift_le_swap {α : Type u_1} {β : Type u_2} [uniform_space α]\n    {g : set (α × α) → filter β} {f : filter β} (hg : monotone g)\n    (h : (filter.lift (uniformity α) fun (s : set (α × α)) => g (prod.swap ⁻¹' s)) ≤ f) :\n    filter.lift (uniformity α) g ≤ f :=\n  sorry\n\ntheorem uniformity_lift_le_comp {α : Type u_1} {β : Type u_2} [uniform_space α]\n    {f : set (α × α) → filter β} (h : monotone f) :\n    (filter.lift (uniformity α) fun (s : set (α × α)) => f (comp_rel s s)) ≤\n        filter.lift (uniformity α) f :=\n  sorry\n\ntheorem comp_le_uniformity3 {α : Type u_1} [uniform_space α] :\n    (filter.lift' (uniformity α) fun (s : set (α × α)) => comp_rel s (comp_rel s s)) ≤\n        uniformity α :=\n  sorry\n\ntheorem comp_symm_mem_uniformity_sets {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (hs : s ∈ uniformity α) :\n    ∃ (t : set (α × α)), ∃ (H : t ∈ uniformity α), symmetric_rel t ∧ comp_rel t t ⊆ s :=\n  sorry\n\ntheorem subset_comp_self_of_mem_uniformity {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (h : s ∈ uniformity α) : s ⊆ comp_rel s s :=\n  subset_comp_self (refl_le_uniformity h)\n\ntheorem comp_comp_symm_mem_uniformity_sets {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (hs : s ∈ uniformity α) :\n    ∃ (t : set (α × α)),\n        ∃ (H : t ∈ uniformity α), symmetric_rel t ∧ comp_rel (comp_rel t t) t ⊆ s :=\n  sorry\n\n/-!\n### Balls in uniform spaces\n-/\n\n/-- The ball around `(x : β)` with respect to `(V : set (β × β))`. Intended to be\nused for `V ∈ 𝓤 β`, but this is not needed for the definition. Recovers the\nnotions of metric space ball when `V = {p | dist p.1 p.2 < r }`.  -/\ndef uniform_space.ball {β : Type u_2} (x : β) (V : set (β × β)) : set β := Prod.mk x ⁻¹' V\n\ntheorem uniform_space.mem_ball_self {α : Type u_1} [uniform_space α] (x : α) {V : set (α × α)}\n    (hV : V ∈ uniformity α) : x ∈ uniform_space.ball x V :=\n  refl_mem_uniformity hV\n\n/-- The triangle inequality for `uniform_space.ball` -/\ntheorem mem_ball_comp {β : Type u_2} {V : set (β × β)} {W : set (β × β)} {x : β} {y : β} {z : β}\n    (h : y ∈ uniform_space.ball x V) (h' : z ∈ uniform_space.ball y W) :\n    z ∈ uniform_space.ball x (comp_rel V W) :=\n  prod_mk_mem_comp_rel h h'\n\ntheorem ball_subset_of_comp_subset {β : Type u_2} {V : set (β × β)} {W : set (β × β)} {x : β}\n    {y : β} (h : x ∈ uniform_space.ball y W) (h' : comp_rel W W ⊆ V) :\n    uniform_space.ball x W ⊆ uniform_space.ball y V :=\n  fun (z : β) (z_in : z ∈ uniform_space.ball x W) => h' (mem_ball_comp h z_in)\n\ntheorem ball_mono {β : Type u_2} {V : set (β × β)} {W : set (β × β)} (h : V ⊆ W) (x : β) :\n    uniform_space.ball x V ⊆ uniform_space.ball x W :=\n  id fun (a : β) (ᾰ : a ∈ uniform_space.ball x V) => h ᾰ\n\ntheorem mem_ball_symmetry {β : Type u_2} {V : set (β × β)} (hV : symmetric_rel V) {x : β} {y : β} :\n    x ∈ uniform_space.ball y V ↔ y ∈ uniform_space.ball x V :=\n  sorry\n\ntheorem ball_eq_of_symmetry {β : Type u_2} {V : set (β × β)} (hV : symmetric_rel V) {x : β} :\n    uniform_space.ball x V = set_of fun (y : β) => (y, x) ∈ V :=\n  sorry\n\ntheorem mem_comp_of_mem_ball {β : Type u_2} {V : set (β × β)} {W : set (β × β)} {x : β} {y : β}\n    {z : β} (hV : symmetric_rel V) (hx : x ∈ uniform_space.ball z V)\n    (hy : y ∈ uniform_space.ball z W) : (x, y) ∈ comp_rel V W :=\n  Exists.intro z\n    { left :=\n        eq.mp (Eq._oldrec (Eq.refl (x ∈ uniform_space.ball z V)) (propext (mem_ball_symmetry hV)))\n          hx,\n      right := hy }\n\ntheorem uniform_space.is_open_ball {α : Type u_1} [uniform_space α] (x : α) {V : set (α × α)}\n    (hV : is_open V) : is_open (uniform_space.ball x V) :=\n  is_open.preimage (continuous.prod_mk continuous_const continuous_id) hV\n\ntheorem mem_comp_comp {β : Type u_2} {V : set (β × β)} {W : set (β × β)} {M : set (β × β)}\n    (hW' : symmetric_rel W) {p : β × β} :\n    p ∈ comp_rel (comp_rel V M) W ↔\n        set.nonempty\n          (set.prod (uniform_space.ball (prod.fst p) V) (uniform_space.ball (prod.snd p) W) ∩ M) :=\n  sorry\n\n/-!\n### Neighborhoods in uniform spaces\n-/\n\ntheorem mem_nhds_uniformity_iff_right {α : Type u_1} [uniform_space α] {x : α} {s : set α} :\n    s ∈ nhds x ↔ (set_of fun (p : α × α) => prod.fst p = x → prod.snd p ∈ s) ∈ uniformity α :=\n  sorry\n\ntheorem mem_nhds_uniformity_iff_left {α : Type u_1} [uniform_space α] {x : α} {s : set α} :\n    s ∈ nhds x ↔ (set_of fun (p : α × α) => prod.snd p = x → prod.fst p ∈ s) ∈ uniformity α :=\n  sorry\n\ntheorem nhds_eq_comap_uniformity_aux {α : Type u} {x : α} {s : set α} {F : filter (α × α)} :\n    (set_of fun (p : α × α) => prod.fst p = x → prod.snd p ∈ s) ∈ F ↔\n        s ∈ filter.comap (Prod.mk x) F :=\n  sorry\n\ntheorem nhds_eq_comap_uniformity {α : Type u_1} [uniform_space α] {x : α} :\n    nhds x = filter.comap (Prod.mk x) (uniformity α) :=\n  sorry\n\ntheorem is_open_iff_ball_subset {α : Type u_1} [uniform_space α] {s : set α} :\n    is_open s ↔\n        ∀ (x : α) (H : x ∈ s),\n          ∃ (V : set (α × α)), ∃ (H : V ∈ uniformity α), uniform_space.ball x V ⊆ s :=\n  sorry\n\ntheorem nhds_basis_uniformity' {α : Type u_1} {β : Type u_2} [uniform_space α] {p : β → Prop}\n    {s : β → set (α × α)} (h : filter.has_basis (uniformity α) p s) {x : α} :\n    filter.has_basis (nhds x) p fun (i : β) => uniform_space.ball x (s i) :=\n  sorry\n\ntheorem nhds_basis_uniformity {α : Type u_1} {β : Type u_2} [uniform_space α] {p : β → Prop}\n    {s : β → set (α × α)} (h : filter.has_basis (uniformity α) p s) {x : α} :\n    filter.has_basis (nhds x) p fun (i : β) => set_of fun (y : α) => (y, x) ∈ s i :=\n  sorry\n\ntheorem uniform_space.mem_nhds_iff {α : Type u_1} [uniform_space α] {x : α} {s : set α} :\n    s ∈ nhds x ↔ ∃ (V : set (α × α)), ∃ (H : V ∈ uniformity α), uniform_space.ball x V ⊆ s :=\n  sorry\n\ntheorem uniform_space.ball_mem_nhds {α : Type u_1} [uniform_space α] (x : α) {V : set (α × α)}\n    (V_in : V ∈ uniformity α) : uniform_space.ball x V ∈ nhds x :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (uniform_space.ball x V ∈ nhds x)) (propext uniform_space.mem_nhds_iff)))\n    (Exists.intro V (Exists.intro V_in (set.subset.refl (uniform_space.ball x V))))\n\ntheorem uniform_space.mem_nhds_iff_symm {α : Type u_1} [uniform_space α] {x : α} {s : set α} :\n    s ∈ nhds x ↔\n        ∃ (V : set (α × α)),\n          ∃ (H : V ∈ uniformity α), symmetric_rel V ∧ uniform_space.ball x V ⊆ s :=\n  sorry\n\ntheorem uniform_space.has_basis_nhds {α : Type u_1} [uniform_space α] (x : α) :\n    filter.has_basis (nhds x) (fun (s : set (α × α)) => s ∈ uniformity α ∧ symmetric_rel s)\n        fun (s : set (α × α)) => uniform_space.ball x s :=\n  sorry\n\ntheorem uniform_space.has_basis_nhds_prod {α : Type u_1} [uniform_space α] (x : α) (y : α) :\n    filter.has_basis (nhds (x, y)) (fun (s : set (α × α)) => s ∈ uniformity α ∧ symmetric_rel s)\n        fun (s : set (α × α)) => set.prod (uniform_space.ball x s) (uniform_space.ball y s) :=\n  sorry\n\ntheorem nhds_eq_uniformity {α : Type u_1} [uniform_space α] {x : α} :\n    nhds x = filter.lift' (uniformity α) (uniform_space.ball x) :=\n  filter.has_basis.eq_binfi (nhds_basis_uniformity' (filter.basis_sets (uniformity α)))\n\ntheorem mem_nhds_left {α : Type u_1} [uniform_space α] (x : α) {s : set (α × α)}\n    (h : s ∈ uniformity α) : (set_of fun (y : α) => (x, y) ∈ s) ∈ nhds x :=\n  uniform_space.ball_mem_nhds x h\n\ntheorem mem_nhds_right {α : Type u_1} [uniform_space α] (y : α) {s : set (α × α)}\n    (h : s ∈ uniformity α) : (set_of fun (x : α) => (x, y) ∈ s) ∈ nhds y :=\n  mem_nhds_left y (symm_le_uniformity h)\n\ntheorem tendsto_right_nhds_uniformity {α : Type u_1} [uniform_space α] {a : α} :\n    filter.tendsto (fun (a' : α) => (a', a)) (nhds a) (uniformity α) :=\n  fun (s : set (α × α)) => mem_nhds_right a\n\ntheorem tendsto_left_nhds_uniformity {α : Type u_1} [uniform_space α] {a : α} :\n    filter.tendsto (fun (a' : α) => (a, a')) (nhds a) (uniformity α) :=\n  fun (s : set (α × α)) => mem_nhds_left a\n\ntheorem lift_nhds_left {α : Type u_1} {β : Type u_2} [uniform_space α] {x : α}\n    {g : set α → filter β} (hg : monotone g) :\n    filter.lift (nhds x) g =\n        filter.lift (uniformity α) fun (s : set (α × α)) => g (set_of fun (y : α) => (x, y) ∈ s) :=\n  sorry\n\ntheorem lift_nhds_right {α : Type u_1} {β : Type u_2} [uniform_space α] {x : α}\n    {g : set α → filter β} (hg : monotone g) :\n    filter.lift (nhds x) g =\n        filter.lift (uniformity α) fun (s : set (α × α)) => g (set_of fun (y : α) => (y, x) ∈ s) :=\n  sorry\n\ntheorem nhds_nhds_eq_uniformity_uniformity_prod {α : Type u_1} [uniform_space α] {a : α} {b : α} :\n    filter.prod (nhds a) (nhds b) =\n        filter.lift (uniformity α)\n          fun (s : set (α × α)) =>\n            filter.lift' (uniformity α)\n              fun (t : set (α × α)) =>\n                set.prod (set_of fun (y : α) => (y, a) ∈ s) (set_of fun (y : α) => (b, y) ∈ t) :=\n  sorry\n\ntheorem nhds_eq_uniformity_prod {α : Type u_1} [uniform_space α] {a : α} {b : α} :\n    nhds (a, b) =\n        filter.lift' (uniformity α)\n          fun (s : set (α × α)) =>\n            set.prod (set_of fun (y : α) => (y, a) ∈ s) (set_of fun (y : α) => (b, y) ∈ s) :=\n  sorry\n\ntheorem nhdset_of_mem_uniformity {α : Type u_1} [uniform_space α] {d : set (α × α)}\n    (s : set (α × α)) (hd : d ∈ uniformity α) :\n    ∃ (t : set (α × α)),\n        is_open t ∧\n          s ⊆ t ∧\n            t ⊆\n              set_of\n                fun (p : α × α) =>\n                  ∃ (x : α), ∃ (y : α), (prod.fst p, x) ∈ d ∧ (x, y) ∈ s ∧ (y, prod.snd p) ∈ d :=\n  sorry\n\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem nhds_le_uniformity {α : Type u_1} [uniform_space α] (x : α) : nhds (x, x) ≤ uniformity α :=\n  sorry\n\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem supr_nhds_le_uniformity {α : Type u_1} [uniform_space α] :\n    (supr fun (x : α) => nhds (x, x)) ≤ uniformity α :=\n  supr_le nhds_le_uniformity\n\n/-!\n### Closure and interior in uniform spaces\n-/\n\ntheorem closure_eq_uniformity {α : Type u_1} [uniform_space α] (s : set (α × α)) :\n    closure s =\n        set.Inter\n          fun (V : set (α × α)) =>\n            set.Inter\n              fun (H : V ∈ set_of fun (V : set (α × α)) => V ∈ uniformity α ∧ symmetric_rel V) =>\n                comp_rel (comp_rel V s) V :=\n  sorry\n\ntheorem uniformity_has_basis_closed {α : Type u_1} [uniform_space α] :\n    filter.has_basis (uniformity α) (fun (V : set (α × α)) => V ∈ uniformity α ∧ is_closed V) id :=\n  sorry\n\n/-- Closed entourages form a basis of the uniformity filter. -/\ntheorem uniformity_has_basis_closure {α : Type u_1} [uniform_space α] :\n    filter.has_basis (uniformity α) (fun (V : set (α × α)) => V ∈ uniformity α) closure :=\n  sorry\n\ntheorem closure_eq_inter_uniformity {α : Type u_1} [uniform_space α] {t : set (α × α)} :\n    closure t =\n        set.Inter\n          fun (d : set (α × α)) =>\n            set.Inter fun (H : d ∈ uniformity α) => comp_rel d (comp_rel t d) :=\n  sorry\n\ntheorem uniformity_eq_uniformity_closure {α : Type u_1} [uniform_space α] :\n    uniformity α = filter.lift' (uniformity α) closure :=\n  sorry\n\ntheorem uniformity_eq_uniformity_interior {α : Type u_1} [uniform_space α] :\n    uniformity α = filter.lift' (uniformity α) interior :=\n  sorry\n\ntheorem interior_mem_uniformity {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (hs : s ∈ uniformity α) : interior s ∈ uniformity α :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (interior s ∈ uniformity α)) uniformity_eq_uniformity_interior))\n    (filter.mem_lift' hs)\n\ntheorem mem_uniformity_is_closed {α : Type u_1} [uniform_space α] {s : set (α × α)}\n    (h : s ∈ uniformity α) : ∃ (t : set (α × α)), ∃ (H : t ∈ uniformity α), is_closed t ∧ t ⊆ s :=\n  sorry\n\n/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/\ntheorem dense.bUnion_uniformity_ball {α : Type u_1} [uniform_space α] {s : set α} {U : set (α × α)}\n    (hs : dense s) (hU : U ∈ uniformity α) :\n    (set.Union fun (x : α) => set.Union fun (H : x ∈ s) => uniform_space.ball x U) = set.univ :=\n  sorry\n\n/-!\n### Uniformity bases\n-/\n\n/-- Open elements of `𝓤 α` form a basis of `𝓤 α`. -/\ntheorem uniformity_has_basis_open {α : Type u_1} [uniform_space α] :\n    filter.has_basis (uniformity α) (fun (V : set (α × α)) => V ∈ uniformity α ∧ is_open V) id :=\n  sorry\n\ntheorem filter.has_basis.mem_uniformity_iff {α : Type u_1} {β : Type u_2} [uniform_space α]\n    {p : β → Prop} {s : β → set (α × α)} (h : filter.has_basis (uniformity α) p s)\n    {t : set (α × α)} :\n    t ∈ uniformity α ↔ ∃ (i : β), ∃ (hi : p i), ∀ (a b : α), (a, b) ∈ s i → (a, b) ∈ t :=\n  sorry\n\n/-- Symmetric entourages form a basis of `𝓤 α` -/\ntheorem uniform_space.has_basis_symmetric {α : Type u_1} [uniform_space α] :\n    filter.has_basis (uniformity α) (fun (s : set (α × α)) => s ∈ uniformity α ∧ symmetric_rel s)\n        id :=\n  sorry\n\n/-- Open elements `s : set (α × α)` of `𝓤 α` such that `(x, y) ∈ s ↔ (y, x) ∈ s` form a basis\nof `𝓤 α`. -/\ntheorem uniformity_has_basis_open_symmetric {α : Type u_1} [uniform_space α] :\n    filter.has_basis (uniformity α)\n        (fun (V : set (α × α)) => V ∈ uniformity α ∧ is_open V ∧ symmetric_rel V) id :=\n  sorry\n\ntheorem uniform_space.has_seq_basis {α : Type u_1} [uniform_space α]\n    (h : filter.is_countably_generated (uniformity α)) :\n    ∃ (V : ℕ → set (α × α)),\n        filter.has_antimono_basis (uniformity α) (fun (_x : ℕ) => True) V ∧\n          ∀ (n : ℕ), symmetric_rel (V n) :=\n  sorry\n\n/-! ### Uniform continuity -/\n\n/-- A function `f : α → β` is *uniformly continuous* if `(f x, f y)` tends to the diagonal\nas `(x, y)` tends to the diagonal. In other words, if `x` is sufficiently close to `y`, then\n`f x` is close to `f y` no matter where `x` and `y` are located in `α`. -/\ndef uniform_continuous {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    (f : α → β) :=\n  filter.tendsto (fun (x : α × α) => (f (prod.fst x), f (prod.snd x))) (uniformity α) (uniformity β)\n\n/-- A function `f : α → β` is *uniformly continuous* on `s : set α` if `(f x, f y)` tends to\nthe diagonal as `(x, y)` tends to the diagonal while remaining in `s.prod s`.\nIn other words, if `x` is sufficiently close to `y`, then `f x` is close to\n`f y` no matter where `x` and `y` are located in `s`.-/\ndef uniform_continuous_on {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    (f : α → β) (s : set α) :=\n  filter.tendsto (fun (x : α × α) => (f (prod.fst x), f (prod.snd x)))\n    (uniformity α ⊓ filter.principal (set.prod s s)) (uniformity β)\n\ntheorem uniform_continuous_def {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    {f : α → β} :\n    uniform_continuous f ↔\n        ∀ (r : set (β × β)),\n          r ∈ uniformity β →\n            (set_of fun (x : α × α) => (f (prod.fst x), f (prod.snd x)) ∈ r) ∈ uniformity α :=\n  iff.rfl\n\ntheorem uniform_continuous_iff_eventually {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] {f : α → β} :\n    uniform_continuous f ↔\n        ∀ (r : set (β × β)),\n          r ∈ uniformity β →\n            filter.eventually (fun (x : α × α) => (f (prod.fst x), f (prod.snd x)) ∈ r)\n              (uniformity α) :=\n  iff.rfl\n\ntheorem uniform_continuous_of_const {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] {c : α → β} (h : ∀ (a b : α), c a = c b) : uniform_continuous c :=\n  sorry\n\ntheorem uniform_continuous_id {α : Type u_1} [uniform_space α] : uniform_continuous id := sorry\n\ntheorem uniform_continuous_const {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    {b : β} : uniform_continuous fun (a : α) => b :=\n  uniform_continuous_of_const fun (_x _x : α) => rfl\n\ntheorem uniform_continuous.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n    [uniform_space β] [uniform_space γ] {g : β → γ} {f : α → β} (hg : uniform_continuous g)\n    (hf : uniform_continuous f) : uniform_continuous (g ∘ f) :=\n  filter.tendsto.comp hg hf\n\ntheorem filter.has_basis.uniform_continuous_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n    {δ : Type u_4} [uniform_space α] [uniform_space β] {p : γ → Prop} {s : γ → set (α × α)}\n    (ha : filter.has_basis (uniformity α) p s) {q : δ → Prop} {t : δ → set (β × β)}\n    (hb : filter.has_basis (uniformity β) q t) {f : α → β} :\n    uniform_continuous f ↔\n        ∀ (i : δ), q i → ∃ (j : γ), ∃ (hj : p j), ∀ (x y : α), (x, y) ∈ s j → (f x, f y) ∈ t i :=\n  sorry\n\ntheorem filter.has_basis.uniform_continuous_on_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n    {δ : Type u_4} [uniform_space α] [uniform_space β] {p : γ → Prop} {s : γ → set (α × α)}\n    (ha : filter.has_basis (uniformity α) p s) {q : δ → Prop} {t : δ → set (β × β)}\n    (hb : filter.has_basis (uniformity β) q t) {f : α → β} {S : set α} :\n    uniform_continuous_on f S ↔\n        ∀ (i : δ),\n          q i →\n            ∃ (j : γ), ∃ (hj : p j), ∀ (x y : α), x ∈ S → y ∈ S → (x, y) ∈ s j → (f x, f y) ∈ t i :=\n  sorry\n\nprotected instance uniform_space.partial_order {α : Type u_1} : partial_order (uniform_space α) :=\n  partial_order.mk\n    (fun (t s : uniform_space α) =>\n      uniform_space.core.uniformity uniform_space.to_core ≤\n        uniform_space.core.uniformity uniform_space.to_core)\n    (preorder.lt._default\n      fun (t s : uniform_space α) =>\n        uniform_space.core.uniformity uniform_space.to_core ≤\n          uniform_space.core.uniformity uniform_space.to_core)\n    sorry sorry sorry\n\nprotected instance uniform_space.has_Inf {α : Type u_1} : has_Inf (uniform_space α) :=\n  has_Inf.mk\n    fun (s : set (uniform_space α)) =>\n      uniform_space.of_core\n        (uniform_space.core.mk\n          (infi fun (u : uniform_space α) => infi fun (H : u ∈ s) => uniformity α) sorry sorry\n          sorry)\n\nprotected instance uniform_space.has_top {α : Type u_1} : has_top (uniform_space α) :=\n  has_top.mk (uniform_space.of_core (uniform_space.core.mk ⊤ sorry sorry sorry))\n\nprotected instance uniform_space.has_bot {α : Type u_1} : has_bot (uniform_space α) :=\n  has_bot.mk\n    (uniform_space.mk (uniform_space.core.mk (filter.principal id_rel) sorry sorry sorry) sorry)\n\nprotected instance uniform_space.complete_lattice {α : Type u_1} :\n    complete_lattice (uniform_space α) :=\n  complete_lattice.mk\n    (fun (a b : uniform_space α) => Inf (set_of fun (x : uniform_space α) => a ≤ x ∧ b ≤ x))\n    partial_order.le partial_order.lt sorry sorry sorry sorry sorry sorry\n    (fun (a b : uniform_space α) => Inf (insert a (singleton b))) sorry sorry sorry ⊤ sorry ⊥ sorry\n    (fun (tt : set (uniform_space α)) =>\n      Inf (set_of fun (t : uniform_space α) => ∀ (t' : uniform_space α), t' ∈ tt → t' ≤ t))\n    Inf sorry sorry sorry sorry\n\ntheorem infi_uniformity {α : Type u_1} {ι : Sort u_2} {u : ι → uniform_space α} :\n    uniform_space.core.uniformity uniform_space.to_core =\n        infi fun (i : ι) => uniform_space.core.uniformity uniform_space.to_core :=\n  sorry\n\ntheorem inf_uniformity {α : Type u_1} {u : uniform_space α} {v : uniform_space α} :\n    uniform_space.core.uniformity uniform_space.to_core =\n        uniform_space.core.uniformity uniform_space.to_core ⊓\n          uniform_space.core.uniformity uniform_space.to_core :=\n  sorry\n\nprotected instance inhabited_uniform_space {α : Type u_1} : Inhabited (uniform_space α) :=\n  { default := ⊥ }\n\nprotected instance inhabited_uniform_space_core {α : Type u_1} : Inhabited (uniform_space.core α) :=\n  { default := uniform_space.to_core }\n\n/-- Given `f : α → β` and a uniformity `u` on `β`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `α × α → β × β`. -/\ndef uniform_space.comap {α : Type u_1} {β : Type u_2} (f : α → β) (u : uniform_space β) :\n    uniform_space α :=\n  uniform_space.mk\n    (uniform_space.core.mk\n      (filter.comap (fun (p : α × α) => (f (prod.fst p), f (prod.snd p)))\n        (uniform_space.core.uniformity uniform_space.to_core))\n      sorry sorry sorry)\n    sorry\n\ntheorem uniformity_comap {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    {f : α → β} (h : _inst_1 = uniform_space.comap f _inst_2) :\n    uniformity α = filter.comap (prod.map f f) (uniformity β) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (uniformity α = filter.comap (prod.map f f) (uniformity β))) h))\n    (Eq.refl (uniformity α))\n\ntheorem uniform_space_comap_id {α : Type u_1} : uniform_space.comap id = id := sorry\n\ntheorem uniform_space.comap_comap {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n    [uγ : uniform_space γ] {f : α → β} {g : β → γ} :\n    uniform_space.comap (g ∘ f) uγ = uniform_space.comap f (uniform_space.comap g uγ) :=\n  sorry\n\ntheorem uniform_continuous_iff {α : Type u_1} {β : Type u_2} [uα : uniform_space α]\n    [uβ : uniform_space β] {f : α → β} : uniform_continuous f ↔ uα ≤ uniform_space.comap f uβ :=\n  filter.map_le_iff_le_comap\n\ntheorem uniform_continuous_comap {α : Type u_1} {β : Type u_2} {f : α → β} [u : uniform_space β] :\n    uniform_continuous f :=\n  filter.tendsto_comap\n\ntheorem to_topological_space_comap {α : Type u_1} {β : Type u_2} {f : α → β} {u : uniform_space β} :\n    uniform_space.to_topological_space =\n        topological_space.induced f uniform_space.to_topological_space :=\n  rfl\n\ntheorem uniform_continuous_comap' {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : γ → β}\n    {g : α → γ} [v : uniform_space β] [u : uniform_space α] (h : uniform_continuous (f ∘ g)) :\n    uniform_continuous g :=\n  iff.mpr filter.tendsto_comap_iff h\n\ntheorem to_topological_space_mono {α : Type u_1} {u₁ : uniform_space α} {u₂ : uniform_space α}\n    (h : u₁ ≤ u₂) : uniform_space.to_topological_space ≤ uniform_space.to_topological_space :=\n  sorry\n\ntheorem uniform_continuous.continuous {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] {f : α → β} (hf : uniform_continuous f) : continuous f :=\n  iff.mpr continuous_iff_le_induced (to_topological_space_mono (iff.mp uniform_continuous_iff hf))\n\ntheorem to_topological_space_bot {α : Type u_1} : uniform_space.to_topological_space = ⊥ := rfl\n\ntheorem to_topological_space_top {α : Type u_1} : uniform_space.to_topological_space = ⊤ := sorry\n\ntheorem to_topological_space_infi {α : Type u_1} {ι : Sort u_2} {u : ι → uniform_space α} :\n    uniform_space.to_topological_space = infi fun (i : ι) => uniform_space.to_topological_space :=\n  sorry\n\ntheorem to_topological_space_Inf {α : Type u_1} {s : set (uniform_space α)} :\n    uniform_space.to_topological_space =\n        infi\n          fun (i : uniform_space α) => infi fun (H : i ∈ s) => uniform_space.to_topological_space :=\n  sorry\n\ntheorem to_topological_space_inf {α : Type u_1} {u : uniform_space α} {v : uniform_space α} :\n    uniform_space.to_topological_space =\n        uniform_space.to_topological_space ⊓ uniform_space.to_topological_space :=\n  sorry\n\nprotected instance empty.uniform_space : uniform_space empty := ⊥\n\nprotected instance unit.uniform_space : uniform_space Unit := ⊥\n\nprotected instance bool.uniform_space : uniform_space Bool := ⊥\n\nprotected instance nat.uniform_space : uniform_space ℕ := ⊥\n\nprotected instance int.uniform_space : uniform_space ℤ := ⊥\n\nprotected instance subtype.uniform_space {α : Type u_1} {p : α → Prop} [t : uniform_space α] :\n    uniform_space (Subtype p) :=\n  uniform_space.comap subtype.val t\n\ntheorem uniformity_subtype {α : Type u_1} {p : α → Prop} [t : uniform_space α] :\n    uniformity (Subtype p) =\n        filter.comap\n          (fun (q : Subtype p × Subtype p) => (subtype.val (prod.fst q), subtype.val (prod.snd q)))\n          (uniformity α) :=\n  rfl\n\ntheorem uniform_continuous_subtype_val {α : Type u_1} {p : α → Prop} [uniform_space α] :\n    uniform_continuous subtype.val :=\n  uniform_continuous_comap\n\ntheorem uniform_continuous_subtype_mk {α : Type u_1} {β : Type u_2} {p : α → Prop} [uniform_space α]\n    [uniform_space β] {f : β → α} (hf : uniform_continuous f) (h : ∀ (x : β), p (f x)) :\n    uniform_continuous fun (x : β) => { val := f x, property := h x } :=\n  uniform_continuous_comap' hf\n\ntheorem uniform_continuous_on_iff_restrict {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] {f : α → β} {s : set α} :\n    uniform_continuous_on f s ↔ uniform_continuous (set.restrict f s) :=\n  sorry\n\ntheorem tendsto_of_uniform_continuous_subtype {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] {f : α → β} {s : set α} {a : α}\n    (hf : uniform_continuous fun (x : ↥s) => f (subtype.val x)) (ha : s ∈ nhds a) :\n    filter.tendsto f (nhds a) (nhds (f a)) :=\n  sorry\n\ntheorem uniform_continuous_on.continuous_on {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] {f : α → β} {s : set α} (h : uniform_continuous_on f s) : continuous_on f s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (continuous_on f s)) (propext continuous_on_iff_continuous_restrict)))\n    (uniform_continuous.continuous\n      (eq.mp\n        (Eq._oldrec (Eq.refl (uniform_continuous_on f s))\n          (propext uniform_continuous_on_iff_restrict))\n        h))\n\n/- a similar product space is possible on the function space (uniformity of pointwise convergence),\n  but we want to have the uniformity of uniform convergence on function spaces -/\n\nprotected instance prod.uniform_space {α : Type u_1} {β : Type u_2} [u₁ : uniform_space α]\n    [u₂ : uniform_space β] : uniform_space (α × β) :=\n  uniform_space.of_core_eq uniform_space.to_core prod.topological_space sorry\n\ntheorem uniformity_prod {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β] :\n    uniformity (α × β) =\n        filter.comap (fun (p : (α × β) × α × β) => (prod.fst (prod.fst p), prod.fst (prod.snd p)))\n            (uniformity α) ⊓\n          filter.comap (fun (p : (α × β) × α × β) => (prod.snd (prod.fst p), prod.snd (prod.snd p)))\n            (uniformity β) :=\n  inf_uniformity\n\ntheorem uniformity_prod_eq_prod {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β] :\n    uniformity (α × β) =\n        filter.map\n          (fun (p : (α × α) × β × β) =>\n            ((prod.fst (prod.fst p), prod.fst (prod.snd p)), prod.snd (prod.fst p),\n            prod.snd (prod.snd p)))\n          (filter.prod (uniformity α) (uniformity β)) :=\n  sorry\n\ntheorem mem_map_sets_iff' {α : Type u_1} {β : Type u_2} {f : filter α} {m : α → β} {t : set β} :\n    t ∈ filter.sets (filter.map m f) ↔ ∃ (s : set α), ∃ (H : s ∈ f), m '' s ⊆ t :=\n  filter.mem_map_sets_iff\n\ntheorem mem_uniformity_of_uniform_continuous_invariant {α : Type u_1} [uniform_space α]\n    {s : set (α × α)} {f : α → α → α}\n    (hf : uniform_continuous fun (p : α × α) => f (prod.fst p) (prod.snd p))\n    (hs : s ∈ uniformity α) :\n    ∃ (u : set (α × α)), ∃ (H : u ∈ uniformity α), ∀ (a b c : α), (a, b) ∈ u → (f a c, f b c) ∈ s :=\n  sorry\n\ntheorem mem_uniform_prod {α : Type u_1} {β : Type u_2} [t₁ : uniform_space α] [t₂ : uniform_space β]\n    {a : set (α × α)} {b : set (β × β)} (ha : a ∈ uniformity α) (hb : b ∈ uniformity β) :\n    (set_of\n          fun (p : (α × β) × α × β) =>\n            (prod.fst (prod.fst p), prod.fst (prod.snd p)) ∈ a ∧\n              (prod.snd (prod.fst p), prod.snd (prod.snd p)) ∈ b) ∈\n        uniformity (α × β) :=\n  sorry\n\ntheorem tendsto_prod_uniformity_fst {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] :\n    filter.tendsto (fun (p : (α × β) × α × β) => (prod.fst (prod.fst p), prod.fst (prod.snd p)))\n        (uniformity (α × β)) (uniformity α) :=\n  le_trans (filter.map_mono inf_le_left) filter.map_comap_le\n\ntheorem tendsto_prod_uniformity_snd {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] :\n    filter.tendsto (fun (p : (α × β) × α × β) => (prod.snd (prod.fst p), prod.snd (prod.snd p)))\n        (uniformity (α × β)) (uniformity β) :=\n  le_trans (filter.map_mono inf_le_right) filter.map_comap_le\n\ntheorem uniform_continuous_fst {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β] :\n    uniform_continuous fun (p : α × β) => prod.fst p :=\n  tendsto_prod_uniformity_fst\n\ntheorem uniform_continuous_snd {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β] :\n    uniform_continuous fun (p : α × β) => prod.snd p :=\n  tendsto_prod_uniformity_snd\n\ntheorem uniform_continuous.prod_mk {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n    [uniform_space β] [uniform_space γ] {f₁ : α → β} {f₂ : α → γ} (h₁ : uniform_continuous f₁)\n    (h₂ : uniform_continuous f₂) : uniform_continuous fun (a : α) => (f₁ a, f₂ a) :=\n  sorry\n\ntheorem uniform_continuous.prod_mk_left {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n    [uniform_space α] [uniform_space β] [uniform_space γ] {f : α × β → γ} (h : uniform_continuous f)\n    (b : β) : uniform_continuous fun (a : α) => f (a, b) :=\n  uniform_continuous.comp h\n    (uniform_continuous.prod_mk uniform_continuous_id uniform_continuous_const)\n\ntheorem uniform_continuous.prod_mk_right {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n    [uniform_space α] [uniform_space β] [uniform_space γ] {f : α × β → γ} (h : uniform_continuous f)\n    (a : α) : uniform_continuous fun (b : β) => f (a, b) :=\n  uniform_continuous.comp h\n    (uniform_continuous.prod_mk uniform_continuous_const uniform_continuous_id)\n\ntheorem uniform_continuous.prod_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4}\n    [uniform_space α] [uniform_space β] [uniform_space γ] [uniform_space δ] {f : α → γ} {g : β → δ}\n    (hf : uniform_continuous f) (hg : uniform_continuous g) : uniform_continuous (prod.map f g) :=\n  uniform_continuous.prod_mk (uniform_continuous.comp hf uniform_continuous_fst)\n    (uniform_continuous.comp hg uniform_continuous_snd)\n\ntheorem to_topological_space_prod {α : Type u_1} {β : Type u_2} [u : uniform_space α]\n    [v : uniform_space β] : uniform_space.to_topological_space = prod.topological_space :=\n  rfl\n\n/-- Uniform continuity for functions of two variables. -/\ndef uniform_continuous₂ {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n    [uniform_space β] [uniform_space γ] (f : α → β → γ) :=\n  uniform_continuous (function.uncurry f)\n\ntheorem uniform_continuous₂_def {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n    [uniform_space β] [uniform_space γ] (f : α → β → γ) :\n    uniform_continuous₂ f ↔ uniform_continuous (function.uncurry f) :=\n  iff.rfl\n\ntheorem uniform_continuous₂.uniform_continuous {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n    [uniform_space α] [uniform_space β] [uniform_space γ] {f : α → β → γ}\n    (h : uniform_continuous₂ f) : uniform_continuous (function.uncurry f) :=\n  h\n\ntheorem uniform_continuous₂_curry {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n    [uniform_space β] [uniform_space γ] (f : α × β → γ) :\n    uniform_continuous₂ (function.curry f) ↔ uniform_continuous f :=\n  sorry\n\ntheorem uniform_continuous₂.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4}\n    [uniform_space α] [uniform_space β] [uniform_space γ] [uniform_space δ] {f : α → β → γ}\n    {g : γ → δ} (hg : uniform_continuous g) (hf : uniform_continuous₂ f) :\n    uniform_continuous₂ (function.bicompr g f) :=\n  uniform_continuous.comp hg hf\n\ntheorem uniform_continuous₂.bicompl {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4}\n    {δ' : Type u_6} [uniform_space α] [uniform_space β] [uniform_space γ] [uniform_space δ]\n    [uniform_space δ'] {f : α → β → γ} {ga : δ → α} {gb : δ' → β} (hf : uniform_continuous₂ f)\n    (hga : uniform_continuous ga) (hgb : uniform_continuous gb) :\n    uniform_continuous₂ (function.bicompl f ga gb) :=\n  uniform_continuous.comp (uniform_continuous₂.uniform_continuous hf)\n    (uniform_continuous.prod_map hga hgb)\n\ntheorem to_topological_space_subtype {α : Type u_1} [u : uniform_space α] {p : α → Prop} :\n    uniform_space.to_topological_space = subtype.topological_space :=\n  rfl\n\n/-- Uniformity on a disjoint union. Entourages of the diagonal in the union are obtained\nby taking independently an entourage of the diagonal in the first part, and an entourage of\nthe diagonal in the second part. -/\ndef uniform_space.core.sum {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β] :\n    uniform_space.core (α ⊕ β) :=\n  uniform_space.core.mk'\n    (filter.map (fun (p : α × α) => (sum.inl (prod.fst p), sum.inl (prod.snd p))) (uniformity α) ⊔\n      filter.map (fun (p : β × β) => (sum.inr (prod.fst p), sum.inr (prod.snd p))) (uniformity β))\n    sorry sorry sorry\n\n/-- The union of an entourage of the diagonal in each set of a disjoint union is again an entourage\nof the diagonal. -/\ntheorem union_mem_uniformity_sum {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    {a : set (α × α)} (ha : a ∈ uniformity α) {b : set (β × β)} (hb : b ∈ uniformity β) :\n    (fun (p : α × α) => (sum.inl (prod.fst p), sum.inl (prod.snd p))) '' a ∪\n          (fun (p : β × β) => (sum.inr (prod.fst p), sum.inr (prod.snd p))) '' b ∈\n        uniform_space.core.uniformity uniform_space.core.sum :=\n  sorry\n\n/- To prove that the topology defined by the uniform structure on the disjoint union coincides with\nthe disjoint union topology, we need two lemmas saying that open sets can be characterized by\nthe uniform structure -/\n\ntheorem uniformity_sum_of_open_aux {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    {s : set (α ⊕ β)} (hs : is_open s) {x : α ⊕ β} (xs : x ∈ s) :\n    (set_of fun (p : (α ⊕ β) × (α ⊕ β)) => prod.fst p = x → prod.snd p ∈ s) ∈\n        uniform_space.core.uniformity uniform_space.core.sum :=\n  sorry\n\ntheorem open_of_uniformity_sum_aux {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n    {s : set (α ⊕ β)}\n    (hs :\n      ∀ (x : α ⊕ β),\n        x ∈ s →\n          (set_of fun (p : (α ⊕ β) × (α ⊕ β)) => prod.fst p = x → prod.snd p ∈ s) ∈\n            uniform_space.core.uniformity uniform_space.core.sum) :\n    is_open s :=\n  sorry\n\n/- We can now define the uniform structure on the disjoint union -/\n\nprotected instance sum.uniform_space {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [uniform_space β] : uniform_space (α ⊕ β) :=\n  uniform_space.mk uniform_space.core.sum sorry\n\ntheorem sum.uniformity {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β] :\n    uniformity (α ⊕ β) =\n        filter.map (fun (p : α × α) => (sum.inl (prod.fst p), sum.inl (prod.snd p)))\n            (uniformity α) ⊔\n          filter.map (fun (p : β × β) => (sum.inr (prod.fst p), sum.inr (prod.snd p)))\n            (uniformity β) :=\n  rfl\n\n-- For a version of the Lebesgue number lemma assuming only a sequentially compact space,\n\n-- see topology/sequences.lean\n\n/-- Let `c : ι → set α` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/\ntheorem lebesgue_number_lemma {α : Type u} [uniform_space α] {s : set α} {ι : Sort u_1}\n    {c : ι → set α} (hs : is_compact s) (hc₁ : ∀ (i : ι), is_open (c i))\n    (hc₂ : s ⊆ set.Union fun (i : ι) => c i) :\n    ∃ (n : set (α × α)),\n        ∃ (H : n ∈ uniformity α),\n          ∀ (x : α), x ∈ s → ∃ (i : ι), (set_of fun (y : α) => (x, y) ∈ n) ⊆ c i :=\n  sorry\n\n/-- Let `c : set (set α)` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `t ∈ c`. -/\ntheorem lebesgue_number_lemma_sUnion {α : Type u} [uniform_space α] {s : set α} {c : set (set α)}\n    (hs : is_compact s) (hc₁ : ∀ (t : set α), t ∈ c → is_open t) (hc₂ : s ⊆ ⋃₀c) :\n    ∃ (n : set (α × α)),\n        ∃ (H : n ∈ uniformity α),\n          ∀ (x : α) (H : x ∈ s), ∃ (t : set α), ∃ (H : t ∈ c), ∀ (y : α), (x, y) ∈ n → y ∈ t :=\n  sorry\n\n/-!\n### Expressing continuity properties in uniform spaces\n\nWe reformulate the various continuity properties of functions taking values in a uniform space\nin terms of the uniformity in the target. Since the same lemmas (essentially with the same names)\nalso exist for metric spaces and emetric spaces (reformulating things in terms of the distance or\nthe edistance in the target), we put them in a namespace `uniform` here.\n\nIn the metric and emetric space setting, there are also similar lemmas where one assumes that\nboth the source and the target are metric spaces, reformulating things in terms of the distance\non both sides. These lemmas are generally written without primes, and the versions where only\nthe target is a metric space is primed. We follow the same convention here, thus giving lemmas\nwith primes.\n-/\n\nnamespace uniform\n\n\ntheorem tendsto_nhds_right {α : Type u_1} {β : Type u_2} [uniform_space α] {f : filter β}\n    {u : β → α} {a : α} :\n    filter.tendsto u f (nhds a) ↔ filter.tendsto (fun (x : β) => (a, u x)) f (uniformity α) :=\n  sorry\n\ntheorem tendsto_nhds_left {α : Type u_1} {β : Type u_2} [uniform_space α] {f : filter β} {u : β → α}\n    {a : α} :\n    filter.tendsto u f (nhds a) ↔ filter.tendsto (fun (x : β) => (u x, a)) f (uniformity α) :=\n  sorry\n\ntheorem continuous_at_iff'_right {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [topological_space β] {f : β → α} {b : β} :\n    continuous_at f b ↔ filter.tendsto (fun (x : β) => (f b, f x)) (nhds b) (uniformity α) :=\n  sorry\n\ntheorem continuous_at_iff'_left {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [topological_space β] {f : β → α} {b : β} :\n    continuous_at f b ↔ filter.tendsto (fun (x : β) => (f x, f b)) (nhds b) (uniformity α) :=\n  sorry\n\ntheorem continuous_at_iff_prod {α : Type u_1} {β : Type u_2} [uniform_space α] [topological_space β]\n    {f : β → α} {b : β} :\n    continuous_at f b ↔\n        filter.tendsto (fun (x : β × β) => (f (prod.fst x), f (prod.snd x))) (nhds (b, b))\n          (uniformity α) :=\n  sorry\n\ntheorem continuous_within_at_iff'_right {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [topological_space β] {f : β → α} {b : β} {s : set β} :\n    continuous_within_at f s b ↔\n        filter.tendsto (fun (x : β) => (f b, f x)) (nhds_within b s) (uniformity α) :=\n  sorry\n\ntheorem continuous_within_at_iff'_left {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [topological_space β] {f : β → α} {b : β} {s : set β} :\n    continuous_within_at f s b ↔\n        filter.tendsto (fun (x : β) => (f x, f b)) (nhds_within b s) (uniformity α) :=\n  sorry\n\ntheorem continuous_on_iff'_right {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [topological_space β] {f : β → α} {s : set β} :\n    continuous_on f s ↔\n        ∀ (b : β),\n          b ∈ s → filter.tendsto (fun (x : β) => (f b, f x)) (nhds_within b s) (uniformity α) :=\n  sorry\n\ntheorem continuous_on_iff'_left {α : Type u_1} {β : Type u_2} [uniform_space α]\n    [topological_space β] {f : β → α} {s : set β} :\n    continuous_on f s ↔\n        ∀ (b : β),\n          b ∈ s → filter.tendsto (fun (x : β) => (f x, f b)) (nhds_within b s) (uniformity α) :=\n  sorry\n\ntheorem continuous_iff'_right {α : Type u_1} {β : Type u_2} [uniform_space α] [topological_space β]\n    {f : β → α} :\n    continuous f ↔ ∀ (b : β), filter.tendsto (fun (x : β) => (f b, f x)) (nhds b) (uniformity α) :=\n  iff.trans continuous_iff_continuous_at (forall_congr fun (b : β) => tendsto_nhds_right)\n\ntheorem continuous_iff'_left {α : Type u_1} {β : Type u_2} [uniform_space α] [topological_space β]\n    {f : β → α} :\n    continuous f ↔ ∀ (b : β), filter.tendsto (fun (x : β) => (f x, f b)) (nhds b) (uniformity α) :=\n  iff.trans continuous_iff_continuous_at (forall_congr fun (b : β) => tendsto_nhds_left)\n\nend uniform\n\n\ntheorem filter.tendsto.congr_uniformity {α : Type u_1} {β : Type u_2} [uniform_space β] {f : α → β}\n    {g : α → β} {l : filter α} {b : β} (hf : filter.tendsto f l (nhds b))\n    (hg : filter.tendsto (fun (x : α) => (f x, g x)) l (uniformity β)) :\n    filter.tendsto g l (nhds b) :=\n  iff.mpr uniform.tendsto_nhds_right\n    (filter.tendsto.uniformity_trans (iff.mp uniform.tendsto_nhds_right hf) hg)\n\ntheorem uniform.tendsto_congr {α : Type u_1} {β : Type u_2} [uniform_space β] {f : α → β}\n    {g : α → β} {l : filter α} {b : β}\n    (hfg : filter.tendsto (fun (x : α) => (f x, g x)) l (uniformity β)) :\n    filter.tendsto f l (nhds b) ↔ filter.tendsto g l (nhds b) :=\n  { mp := fun (h : filter.tendsto f l (nhds b)) => filter.tendsto.congr_uniformity h hfg,\n    mpr :=\n      fun (h : filter.tendsto g l (nhds b)) =>\n        filter.tendsto.congr_uniformity h (filter.tendsto.uniformity_symm hfg) }\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/uniform_space/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006919925839875, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4924959206473711}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Joseph Myers.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.affine_space.independent\nimport Mathlib.linear_algebra.finite_dimensional\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Finite-dimensional subspaces of affine spaces.\n\nThis file provides a few results relating to finite-dimensional\nsubspaces of affine spaces.\n\n## Main definitions\n\n* `collinear` defines collinear sets of points as those that span a\n  subspace of dimension at most 1.\n\n-/\n\n/-- The `vector_span` of a finite set is finite-dimensional. -/\ntheorem finite_dimensional_vector_span_of_finite (k : Type u_1) {V : Type u_2} {P : Type u_3}\n    [field k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P} (h : set.finite s) :\n    finite_dimensional k ↥(vector_span k s) :=\n  finite_dimensional.span_of_finite k (set.finite.vsub h h)\n\n/-- The `vector_span` of a family indexed by a `fintype` is\nfinite-dimensional. -/\nprotected instance finite_dimensional_vector_span_of_fintype (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    [fintype ι] (p : ι → P) : finite_dimensional k ↥(vector_span k (set.range p)) :=\n  finite_dimensional_vector_span_of_finite k (set.finite_range p)\n\n/-- The `vector_span` of a subset of a family indexed by a `fintype`\nis finite-dimensional. -/\nprotected instance finite_dimensional_vector_span_image_of_fintype (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    [fintype ι] (p : ι → P) (s : set ι) : finite_dimensional k ↥(vector_span k (p '' s)) :=\n  finite_dimensional_vector_span_of_finite k (set.finite.image p (set.finite.of_fintype s))\n\n/-- The direction of the affine span of a finite set is\nfinite-dimensional. -/\ntheorem finite_dimensional_direction_affine_span_of_finite (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P}\n    (h : set.finite s) : finite_dimensional k ↥(affine_subspace.direction (affine_span k s)) :=\n  Eq.symm (direction_affine_span k s) ▸ finite_dimensional_vector_span_of_finite k h\n\n/-- The direction of the affine span of a family indexed by a\n`fintype` is finite-dimensional. -/\nprotected instance finite_dimensional_direction_affine_span_of_fintype (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    [fintype ι] (p : ι → P) :\n    finite_dimensional k ↥(affine_subspace.direction (affine_span k (set.range p))) :=\n  finite_dimensional_direction_affine_span_of_finite k (set.finite_range p)\n\n/-- The direction of the affine span of a subset of a family indexed\nby a `fintype` is finite-dimensional. -/\nprotected instance finite_dimensional_direction_affine_span_image_of_fintype (k : Type u_1)\n    {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P]\n    {ι : Type u_4} [fintype ι] (p : ι → P) (s : set ι) :\n    finite_dimensional k ↥(affine_subspace.direction (affine_span k (p '' s))) :=\n  finite_dimensional_direction_affine_span_of_finite k\n    (set.finite.image p (set.finite.of_fintype s))\n\n/-- The `vector_span` of a finite subset of an affinely independent\nfamily has dimension one less than its cardinality. -/\ntheorem findim_vector_span_image_finset_of_affine_independent {k : Type u_1} {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    {p : ι → P} (hi : affine_independent k p) {s : finset ι} {n : ℕ} (hc : finset.card s = n + 1) :\n    finite_dimensional.findim k ↥(vector_span k (p '' ↑s)) = n :=\n  sorry\n\n/-- The `vector_span` of a finite affinely independent family has\ndimension one less than its cardinality. -/\ntheorem findim_vector_span_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3}\n    [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [fintype ι]\n    {p : ι → P} (hi : affine_independent k p) {n : ℕ} (hc : fintype.card ι = n + 1) :\n    finite_dimensional.findim k ↥(vector_span k (set.range p)) = n :=\n  sorry\n\n/-- If the `vector_span` of a finite subset of an affinely independent\nfamily lies in a submodule with dimension one less than its\ncardinality, it equals that submodule. -/\ntheorem vector_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_findim_add_one\n    {k : Type u_1} {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V]\n    [add_torsor V P] {ι : Type u_4} {p : ι → P} (hi : affine_independent k p) {s : finset ι}\n    {sm : submodule k V} [finite_dimensional k ↥sm] (hle : vector_span k (p '' ↑s) ≤ sm)\n    (hc : finset.card s = finite_dimensional.findim k ↥sm + 1) : vector_span k (p '' ↑s) = sm :=\n  finite_dimensional.eq_of_le_of_findim_eq hle\n    (findim_vector_span_image_finset_of_affine_independent hi hc)\n\n/-- If the `vector_span` of a finite affinely independent\nfamily lies in a submodule with dimension one less than its\ncardinality, it equals that submodule. -/\ntheorem vector_span_eq_of_le_of_affine_independent_of_card_eq_findim_add_one {k : Type u_1}\n    {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P]\n    {ι : Type u_4} [fintype ι] {p : ι → P} (hi : affine_independent k p) {sm : submodule k V}\n    [finite_dimensional k ↥sm] (hle : vector_span k (set.range p) ≤ sm)\n    (hc : fintype.card ι = finite_dimensional.findim k ↥sm + 1) :\n    vector_span k (set.range p) = sm :=\n  finite_dimensional.eq_of_le_of_findim_eq hle (findim_vector_span_of_affine_independent hi hc)\n\n/-- If the `affine_span` of a finite subset of an affinely independent\nfamily lies in an affine subspace whose direction has dimension one\nless than its cardinality, it equals that subspace. -/\ntheorem affine_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_findim_add_one\n    {k : Type u_1} {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V]\n    [add_torsor V P] {ι : Type u_4} {p : ι → P} (hi : affine_independent k p) {s : finset ι}\n    {sp : affine_subspace k P} [finite_dimensional k ↥(affine_subspace.direction sp)]\n    (hle : affine_span k (p '' ↑s) ≤ sp)\n    (hc : finset.card s = finite_dimensional.findim k ↥(affine_subspace.direction sp) + 1) :\n    affine_span k (p '' ↑s) = sp :=\n  sorry\n\n/-- If the `affine_span` of a finite affinely independent family lies\nin an affine subspace whose direction has dimension one less than its\ncardinality, it equals that subspace. -/\ntheorem affine_span_eq_of_le_of_affine_independent_of_card_eq_findim_add_one {k : Type u_1}\n    {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P]\n    {ι : Type u_4} [fintype ι] {p : ι → P} (hi : affine_independent k p) {sp : affine_subspace k P}\n    [finite_dimensional k ↥(affine_subspace.direction sp)] (hle : affine_span k (set.range p) ≤ sp)\n    (hc : fintype.card ι = finite_dimensional.findim k ↥(affine_subspace.direction sp) + 1) :\n    affine_span k (set.range p) = sp :=\n  sorry\n\n/-- The `vector_span` of a finite affinely independent family whose\ncardinality is one more than that of the finite-dimensional space is\n`⊤`. -/\ntheorem vector_span_eq_top_of_affine_independent_of_card_eq_findim_add_one {k : Type u_1}\n    {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P]\n    {ι : Type u_4} [finite_dimensional k V] [fintype ι] {p : ι → P} (hi : affine_independent k p)\n    (hc : fintype.card ι = finite_dimensional.findim k V + 1) : vector_span k (set.range p) = ⊤ :=\n  finite_dimensional.eq_top_of_findim_eq (findim_vector_span_of_affine_independent hi hc)\n\n/-- The `affine_span` of a finite affinely independent family whose\ncardinality is one more than that of the finite-dimensional space is\n`⊤`. -/\ntheorem affine_span_eq_top_of_affine_independent_of_card_eq_findim_add_one {k : Type u_1}\n    {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P]\n    {ι : Type u_4} [finite_dimensional k V] [fintype ι] {p : ι → P} (hi : affine_independent k p)\n    (hc : fintype.card ι = finite_dimensional.findim k V + 1) : affine_span k (set.range p) = ⊤ :=\n  sorry\n\n/-- The `vector_span` of `n + 1` points in an indexed family has\ndimension at most `n`. -/\ntheorem findim_vector_span_image_finset_le (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) (s : finset ι)\n    {n : ℕ} (hc : finset.card s = n + 1) :\n    finite_dimensional.findim k ↥(vector_span k (p '' ↑s)) ≤ n :=\n  sorry\n\n/-- The `vector_span` of an indexed family of `n + 1` points has\ndimension at most `n`. -/\ntheorem findim_vector_span_range_le (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [fintype ι] (p : ι → P) {n : ℕ}\n    (hc : fintype.card ι = n + 1) :\n    finite_dimensional.findim k ↥(vector_span k (set.range p)) ≤ n :=\n  sorry\n\n/-- `n + 1` points are affinely independent if and only if their\n`vector_span` has dimension `n`. -/\ntheorem affine_independent_iff_findim_vector_span_eq (k : Type u_1) {V : Type u_2} {P : Type u_3}\n    [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [fintype ι]\n    (p : ι → P) {n : ℕ} (hc : fintype.card ι = n + 1) :\n    affine_independent k p ↔ finite_dimensional.findim k ↥(vector_span k (set.range p)) = n :=\n  sorry\n\n/-- `n + 1` points are affinely independent if and only if their\n`vector_span` has dimension at least `n`. -/\ntheorem affine_independent_iff_le_findim_vector_span (k : Type u_1) {V : Type u_2} {P : Type u_3}\n    [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [fintype ι]\n    (p : ι → P) {n : ℕ} (hc : fintype.card ι = n + 1) :\n    affine_independent k p ↔ n ≤ finite_dimensional.findim k ↥(vector_span k (set.range p)) :=\n  sorry\n\n/-- `n + 2` points are affinely independent if and only if their\n`vector_span` does not have dimension at most `n`. -/\ntheorem affine_independent_iff_not_findim_vector_span_le (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    [fintype ι] (p : ι → P) {n : ℕ} (hc : fintype.card ι = n + bit0 1) :\n    affine_independent k p ↔ ¬finite_dimensional.findim k ↥(vector_span k (set.range p)) ≤ n :=\n  sorry\n\n/-- `n + 2` points have a `vector_span` with dimension at most `n` if\nand only if they are not affinely independent. -/\ntheorem findim_vector_span_le_iff_not_affine_independent (k : Type u_1) {V : Type u_2}\n    {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4}\n    [fintype ι] (p : ι → P) {n : ℕ} (hc : fintype.card ι = n + bit0 1) :\n    finite_dimensional.findim k ↥(vector_span k (set.range p)) ≤ n ↔ ¬affine_independent k p :=\n  iff.symm\n    (iff.mp not_iff_comm (iff.symm (affine_independent_iff_not_findim_vector_span_le k p hc)))\n\n/-- A set of points is collinear if their `vector_span` has dimension\nat most `1`. -/\ndef collinear (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V]\n    [add_torsor V P] (s : set P) :=\n  vector_space.dim k ↥(vector_span k s) ≤ 1\n\n/-- The definition of `collinear`. -/\ntheorem collinear_iff_dim_le_one (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] (s : set P) :\n    collinear k s ↔ vector_space.dim k ↥(vector_span k s) ≤ 1 :=\n  iff.rfl\n\n/-- A set of points, whose `vector_span` is finite-dimensional, is\ncollinear if and only if their `vector_span` has dimension at most\n`1`. -/\ntheorem collinear_iff_findim_le_one (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] (s : set P)\n    [finite_dimensional k ↥(vector_span k s)] :\n    collinear k s ↔ finite_dimensional.findim k ↥(vector_span k s) ≤ 1 :=\n  sorry\n\n/-- The empty set is collinear. -/\ntheorem collinear_empty (k : Type u_1) {V : Type u_2} (P : Type u_3) [field k] [add_comm_group V]\n    [module k V] [add_torsor V P] : collinear k ∅ :=\n  sorry\n\n/-- A single point is collinear. -/\ntheorem collinear_singleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] (p : P) : collinear k (singleton p) :=\n  sorry\n\n/-- Given a point `p₀` in a set of points, that set is collinear if and\nonly if the points can all be expressed as multiples of the same\nvector, added to `p₀`. -/\ntheorem collinear_iff_of_mem (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] {s : set P} {p₀ : P} (h : p₀ ∈ s) :\n    collinear k s ↔ ∃ (v : V), ∀ (p : P), p ∈ s → ∃ (r : k), p = r • v +ᵥ p₀ :=\n  sorry\n\n/-- A set of points is collinear if and only if they can all be\nexpressed as multiples of the same vector, added to the same base\npoint. -/\ntheorem collinear_iff_exists_forall_eq_smul_vadd (k : Type u_1) {V : Type u_2} {P : Type u_3}\n    [field k] [add_comm_group V] [module k V] [add_torsor V P] (s : set P) :\n    collinear k s ↔ ∃ (p₀ : P), ∃ (v : V), ∀ (p : P), p ∈ s → ∃ (r : k), p = r • v +ᵥ p₀ :=\n  sorry\n\n/-- Two points are collinear. -/\ntheorem collinear_insert_singleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] (p₁ : P) (p₂ : P) :\n    collinear k (insert p₁ (singleton p₂)) :=\n  sorry\n\n/-- Three points are affinely independent if and only if they are not\ncollinear. -/\ntheorem affine_independent_iff_not_collinear (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] (p : fin (bit1 1) → P) :\n    affine_independent k p ↔ ¬collinear k (set.range p) :=\n  sorry\n\n/-- Three points are collinear if and only if they are not affinely\nindependent. -/\ntheorem collinear_iff_not_affine_independent (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k]\n    [add_comm_group V] [module k V] [add_torsor V P] (p : fin (bit1 1) → P) :\n    collinear k (set.range p) ↔ ¬affine_independent k p :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/affine_space/finite_dimensional_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.6548947357776796, "lm_q1q2_score": 0.49248908307349587}}
{"text": "import data.matrix data.rat.basic linear_algebra.basis data.fintype tactic.omega\nimport algebra.associated\nimport linear_algebra.determinant .misc\n\nnoncomputable theory\nuniverses u v w\n\nopen matrix fintype finset function\nvariables {m n k : Type u} [fintype m] [fintype n] [fintype k]\nvariables [decidable_eq m] [decidable_eq n] [decidable_eq k]\nvariables {one : Type u} [unique one]\nvariables (A M : matrix m n ℚ)\n\nvariables (b : matrix m one ℚ) (c x : matrix n one ℚ)\n\nlocal notation M `⬝` N := M.mul N\nlocal postfix `ᵀ` : 1500 := transpose\n\ndef is_feasible : Prop := 0 ≤ x ∧ A ⬝ x = b\n\ninstance decidable_le : decidable_rel ((≤) : matrix m n ℚ → matrix m n ℚ → Prop) :=\nλ M N, show decidable (∀ i j, M i j ≤ N i j), by apply_instance\n\ninstance : decidable (is_feasible A b x) :=\nby dunfold is_feasible; apply_instance\n\ndef is_optimal : Prop :=\nis_feasible A b x ∧ ∀ y, is_feasible A b y → cᵀ ⬝ y ≤ cᵀ ⬝ x\n\ndef basis (B : m → n) : matrix m m ℚ := minor A id B\n\ndef non_basis (B : m → n) : matrix m {b // b ∉ univ.image B}  ℚ :=\nminor A id subtype.val\n\ndef c_basis (B : m → n) : matrix m one ℚ := minor c B id\n\ndef c_non_basis (B : m → n) : matrix {b // b ∉ univ.image B} one ℚ :=\nminor c subtype.val id\n\n--#print non_basis\ndef reduced_cost (B : m → n) : Prop :=\nis_invertible (basis A B) ∧\n(c_non_basis c B)ᵀ ⬝ non_basis _ B = 0\n\n\n\nlemma is_optimal_of_check_reduced_cost (x : cvec n) (B : finset (fin n)) :\n  check_reduced_cost A c x B ∧ is_feasible A b x → is_optimal A b c x := sorry\n\nset_option profiler true\n\ndef ex.A : matrix (fin 2) (fin 4) ℚ :=\nλ i j, (list.nth_le [[1,0,1,0], [1,2,0,1]] i sorry).nth_le j sorry\n\ndef ex.B : finset (fin 4) := {2,3}\n\ndef ex.c : cvec 4 := λ i _, (list.nth_le [1,1,0,0] i sorry)\n\ndef ex.b : cvec 2 := λ i _, (list.nth_le [2,4] i sorry)\n\ndef ex.x : cvec 4 := λ i _, (list.nth_le [0,0,2,4] i sorry)\n\n\n--#reduce (is_feasible ex.A ex.b ex.x : bool)\n\n--set_option trace.class_instances true\n--#reduce (check_reduced_cost ex.A ex.c ex.x ex.B : bool)\n\ndef ex2.A : matrix (fin 2) (fin 4) ℚ :=\n  λ i j, (list.nth_le [[1,0,1,0], [1,2,0,1]] i sorry).nth_le j sorry\n\ndef ex2.B : finset (fin 4) := {0,1}\n\ndef ex2.c : cvec 4 := λ i _, (list.nth_le [1,1,0,0] i sorry)\n\ndef ex2.b : cvec 2 := λ i _, (list.nth_le [2,4] i sorry)\n\ndef ex2.x : cvec 4 := λ i _, (list.nth_le [2,1,0,0] i sorry)\n\n\n#eval (is_feasible ex2.A ex2.b ex2.x : bool)\n\n#eval (check_reduced_cost ex2.A ex2.c ex2.x ex2.B : bool)\n", "meta": {"author": "ChrisHughes24", "repo": "LP", "sha": "e3ed64c2d1f642696104584e74ae7226d8e916de", "save_path": "github-repos/lean/ChrisHughes24-LP", "path": "github-repos/lean/ChrisHughes24-LP/LP-e3ed64c2d1f642696104584e74ae7226d8e916de/scratch/simplex2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.49248905838389484}}
{"text": "/-\nCopyright (c) 2021 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.monoidal.free.basic\nimport category_theory.groupoid\nimport category_theory.discrete_category\n\n/-!\n# The monoidal coherence theorem\n\nIn this file, we prove the monoidal coherence theorem, stated in the following form: the free\nmonoidal category over any type `C` is thin.\n\nWe follow a proof described by Ilya Beylin and Peter Dybjer, which has been previously formalized\nin the proof assistant ALF. The idea is to declare a normal form (with regard to association and\nadding units) on objects of the free monoidal category and consider the discrete subcategory of\nobjects that are in normal form. A normalization procedure is then just a functor\n`full_normalize : free_monoidal_category C ⥤ discrete (normal_monoidal_object C)`, where\nfunctoriality says that two objects which are related by associators and unitors have the\nsame normal form. Another desirable property of a normalization procedure is that an object is\nisomorphic (i.e., related via associators and unitors) to its normal form. In the case of the\nspecific normalization procedure we use we not only get these isomorphismns, but also that they\nassemble into a natural isomorphism `𝟭 (free_monoidal_category C) ≅ full_normalize ⋙ inclusion`.\nBut this means that any two parallel morphisms in the free monoidal category factor through a\ndiscrete category in the same way, so they must be equal, and hence the free monoidal category\nis thin.\n\n## References\n\n* [Ilya Beylin and Peter Dybjer, Extracting a proof of coherence for monoidal categories from a\n   proof of normalization for monoids][beylin1996]\n\n-/\n\nuniverse u\n\nnamespace category_theory\nopen monoidal_category\n\nnamespace free_monoidal_category\n\n\nvariables {C : Type u}\n\nsection\nvariables (C)\n\n/-- We say an object in the free monoidal category is in normal form if it is of the form\n    `(((𝟙_ C) ⊗ X₁) ⊗ X₂) ⊗ ⋯`. -/\n@[nolint has_nonempty_instance]\ninductive normal_monoidal_object : Type u\n| unit : normal_monoidal_object\n| tensor : normal_monoidal_object → C → normal_monoidal_object\n\nend\n\nlocal notation `F` := free_monoidal_category\nlocal notation `N` := discrete ∘ normal_monoidal_object\nlocal infixr ` ⟶ᵐ `:10 := hom\n\n/-- Auxiliary definition for `inclusion`. -/\n@[simp] def inclusion_obj : normal_monoidal_object C → F C\n| normal_monoidal_object.unit := unit\n| (normal_monoidal_object.tensor n a) := tensor (inclusion_obj n) (of a)\n\n/-- The discrete subcategory of objects in normal form includes into the free monoidal category. -/\n@[simp] def inclusion : N C ⥤ F C :=\ndiscrete.functor inclusion_obj\n\n/-- Auxiliary definition for `normalize`. -/\n@[simp] def normalize_obj : F C → normal_monoidal_object C → N C\n| unit n := ⟨n⟩\n| (of X) n := ⟨normal_monoidal_object.tensor n X⟩\n| (tensor X Y) n := normalize_obj Y (normalize_obj X n).as\n\n@[simp] lemma normalize_obj_unitor (n : normal_monoidal_object C) :\n  normalize_obj (𝟙_ (F C)) n = ⟨n⟩ :=\nrfl\n\n@[simp] lemma normalize_obj_tensor (X Y : F C) (n : normal_monoidal_object C) :\n  normalize_obj (X ⊗ Y) n = normalize_obj Y (normalize_obj X n).as :=\nrfl\n\nsection\nopen hom\n\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- Auxiliary definition for `normalize`. Here we prove that objects that are related by\n    associators and unitors map to the same normal form. -/\n@[simp] def normalize_map_aux : Π {X Y : F C},\n  (X ⟶ᵐ Y) →\n    ((discrete.functor (normalize_obj X) : _ ⥤ N C) ⟶ discrete.functor (normalize_obj Y))\n| _ _ (id _) := 𝟙 _\n| _ _ (α_hom _ _ _) := ⟨λ X, 𝟙 _, by { rintros ⟨X⟩ ⟨Y⟩ f, simp }⟩\n| _ _ (α_inv _ _ _) := ⟨λ X, 𝟙 _, by { rintros ⟨X⟩ ⟨Y⟩ f, simp }⟩\n| _ _ (l_hom _) := ⟨λ X, 𝟙 _, by { rintros ⟨X⟩ ⟨Y⟩ f, simp }⟩\n| _ _ (l_inv _) := ⟨λ X, 𝟙 _, by { rintros ⟨X⟩ ⟨Y⟩ f, simp }⟩\n| _ _ (ρ_hom _) := ⟨λ ⟨X⟩, ⟨⟨by simp⟩⟩, by { rintros ⟨X⟩ ⟨Y⟩ f, simp }⟩\n| _ _ (ρ_inv _) := ⟨λ ⟨X⟩, ⟨⟨by simp⟩⟩, by { rintros ⟨X⟩ ⟨Y⟩ f, simp }⟩\n| X Y (@comp _ U V W f g) := normalize_map_aux f ≫ normalize_map_aux g\n| X Y (@hom.tensor _ T U V W f g) :=\n    ⟨λ X, (normalize_map_aux g).app (normalize_obj T X.as) ≫\n      (discrete.functor (normalize_obj W) : _ ⥤ N C).map ((normalize_map_aux f).app X), by tidy⟩\n\nend\n\nsection\nvariables (C)\n\n/-- Our normalization procedure works by first defining a functor `F C ⥤ (N C ⥤ N C)` (which turns\n    out to be very easy), and then obtain a functor `F C ⥤ N C` by plugging in the normal object\n    `𝟙_ C`. -/\n@[simp] def normalize : F C ⥤ N C ⥤ N C :=\n{ obj := λ X, discrete.functor (normalize_obj X),\n  map := λ X Y, quotient.lift normalize_map_aux (by tidy) }\n\n/-- A variant of the normalization functor where we consider the result as an object in the free\n    monoidal category (rather than an object of the discrete subcategory of objects in normal\n    form). -/\n@[simp] def normalize' : F C ⥤ N C ⥤ F C :=\nnormalize C ⋙ (whiskering_right _ _ _).obj inclusion\n\n/-- The normalization functor for the free monoidal category over `C`. -/\ndef full_normalize : F C ⥤ N C :=\n{ obj := λ X, ((normalize C).obj X).obj ⟨normal_monoidal_object.unit⟩,\n  map := λ X Y f, ((normalize C).map f).app ⟨normal_monoidal_object.unit⟩ }\n\n/-- Given an object `X` of the free monoidal category and an object `n` in normal form, taking\n    the tensor product `n ⊗ X` in the free monoidal category is functorial in both `X` and `n`. -/\n@[simp] def tensor_func : F C ⥤ N C ⥤ F C :=\n{ obj := λ X, discrete.functor (λ n, (inclusion.obj ⟨n⟩) ⊗ X),\n  map := λ X Y f, ⟨λ n, 𝟙 _ ⊗ f, by { rintro ⟨X⟩ ⟨Y⟩, tidy }⟩ }\n\nlemma tensor_func_map_app {X Y : F C} (f : X ⟶ Y) (n) : ((tensor_func C).map f).app n =\n  𝟙 _ ⊗ f :=\nrfl\n\nlemma tensor_func_obj_map (Z : F C) {n n' : N C} (f : n ⟶ n') :\n  ((tensor_func C).obj Z).map f = inclusion.map f ⊗ 𝟙 Z :=\nby { cases n, cases n', tidy }\n\n/-- Auxiliary definition for `normalize_iso`. Here we construct the isomorphism between\n    `n ⊗ X` and `normalize X n`. -/\n@[simp] def normalize_iso_app :\n  Π (X : F C) (n : N C), ((tensor_func C).obj X).obj n ≅ ((normalize' C).obj X).obj n\n| (of X) n := iso.refl _\n| unit n := ρ_ _\n| (tensor X Y) n :=\n    (α_ _ _ _).symm ≪≫ tensor_iso (normalize_iso_app X n) (iso.refl _) ≪≫ normalize_iso_app _ _\n\n@[simp] lemma normalize_iso_app_tensor (X Y : F C) (n : N C) :\n  normalize_iso_app C (X ⊗ Y) n =\n  (α_ _ _ _).symm ≪≫ tensor_iso (normalize_iso_app C X n) (iso.refl _) ≪≫\n    normalize_iso_app _ _ _ :=\nrfl\n\n@[simp] lemma normalize_iso_app_unitor (n : N C) : normalize_iso_app C (𝟙_ (F C)) n = ρ_ _ :=\nrfl\n\n/-- Auxiliary definition for `normalize_iso`. -/\n@[simp] def normalize_iso_aux (X : F C) : (tensor_func C).obj X ≅ (normalize' C).obj X :=\nnat_iso.of_components (normalize_iso_app C X) (by { rintros ⟨X⟩ ⟨Y⟩, tidy })\n\nsection\nvariables {D : Type u} [category.{u} D] {I : Type u} (f : I → D) (X : discrete I)\n\n-- TODO: move to discrete_category.lean, decide whether this should be a global simp lemma\n@[simp] lemma discrete_functor_obj_eq_as : (discrete.functor f).obj X = f X.as :=\nrfl\n\n-- TODO: move to discrete_category.lean, decide whether this should be a global simp lemma\n@[simp] lemma discrete_functor_map_eq_id (g : X ⟶ X) : (discrete.functor f).map g = 𝟙 _ :=\nby tidy\n\nend\n\n/-- The isomorphism between `n ⊗ X` and `normalize X n` is natural (in both `X` and `n`, but\n    naturality in `n` is trivial and was \"proved\" in `normalize_iso_aux`). This is the real heart\n    of our proof of the coherence theorem. -/\ndef normalize_iso : tensor_func C ≅ normalize' C :=\nnat_iso.of_components (normalize_iso_aux C)\nbegin\n  rintros X Y f,\n  apply quotient.induction_on f,\n  intro f,\n  ext n,\n  induction f generalizing n,\n  { simp only [mk_id, functor.map_id, category.id_comp, category.comp_id] },\n  { dsimp,\n    simp only [id_tensor_associator_inv_naturality_assoc, ←pentagon_inv_assoc,\n      tensor_hom_inv_id_assoc, tensor_id, category.id_comp, discrete.functor_map_id, comp_tensor_id,\n      iso.cancel_iso_inv_left, category.assoc],\n    dsimp, simp only [category.comp_id], },\n  { dsimp,\n    simp only [discrete.functor_map_id, comp_tensor_id, category.assoc, pentagon_inv_assoc,\n      ←associator_inv_naturality_assoc, tensor_id, iso.cancel_iso_inv_left],\n    dsimp, simp only [category.comp_id],},\n  { dsimp,\n    rw triangle_assoc_comp_right_assoc,\n    simp only [discrete.functor_map_id, category.assoc],\n    cases n,\n    dsimp, simp only [category.comp_id] },\n  { dsimp,\n    simp only [triangle_assoc_comp_left_inv_assoc, inv_hom_id_tensor_assoc, tensor_id,\n      category.id_comp, discrete.functor_map_id],\n    dsimp, simp only [category.comp_id],\n    cases n, simp },\n  { dsimp,\n    rw [←(iso.inv_comp_eq _).2 (right_unitor_tensor _ _), category.assoc, ←right_unitor_naturality],\n    simp only [iso.cancel_iso_inv_left, category.assoc],\n    congr' 1,\n    convert (category.comp_id _).symm,\n    convert discrete_functor_map_eq_id inclusion_obj _ _,\n    ext,\n    refl },\n  { dsimp,\n    simp only [←(iso.eq_comp_inv _).1 (right_unitor_tensor_inv _ _), right_unitor_conjugation,\n      category.assoc, iso.hom_inv_id, iso.hom_inv_id_assoc, iso.inv_hom_id, iso.inv_hom_id_assoc],\n    congr,\n    convert (discrete_functor_map_eq_id inclusion_obj _ _).symm,\n    ext, refl, },\n  { dsimp at *,\n    rw [id_tensor_comp, category.assoc, f_ih_g ⟦f_g⟧, ←category.assoc, f_ih_f ⟦f_f⟧, category.assoc,\n      ←functor.map_comp],\n    congr' 2 },\n  { dsimp at *,\n    rw associator_inv_naturality_assoc,\n    slice_lhs 2 3 { rw [←tensor_comp, f_ih_f ⟦f_f⟧] },\n    conv_lhs { rw [←@category.id_comp (F C) _ _ _ ⟦f_g⟧] },\n    simp only [category.comp_id, tensor_comp, category.assoc],\n    congr' 2,\n    rw [←mk_tensor, quotient.lift_mk],\n    dsimp,\n    rw [functor.map_comp, ←category.assoc, ←f_ih_g ⟦f_g⟧, ←@category.comp_id (F C) _ _ _ ⟦f_g⟧,\n      ←category.id_comp ((discrete.functor inclusion_obj).map _), tensor_comp],\n    dsimp,\n    simp only [category.assoc, category.comp_id],\n    congr' 1,\n    convert (normalize_iso_aux C f_Z).hom.naturality ((normalize_map_aux f_f).app n),\n    exact (tensor_func_obj_map _ _ _).symm }\nend\n\n/-- The isomorphism between an object and its normal form is natural. -/\ndef full_normalize_iso : 𝟭 (F C) ≅ full_normalize C ⋙ inclusion :=\nnat_iso.of_components\n  (λ X, (λ_ X).symm ≪≫ ((normalize_iso C).app X).app ⟨normal_monoidal_object.unit⟩)\n  begin\n    intros X Y f,\n    dsimp,\n    rw [left_unitor_inv_naturality_assoc, category.assoc, iso.cancel_iso_inv_left],\n    exact congr_arg (λ f, nat_trans.app f (discrete.mk normal_monoidal_object.unit))\n      ((normalize_iso.{u} C).hom.naturality f)\n  end\n\nend\n\n/-- The monoidal coherence theorem. -/\ninstance subsingleton_hom : quiver.is_thin (F C) :=\nλ _ _,\n  ⟨λ f g, have (full_normalize C).map f = (full_normalize C).map g, from subsingleton.elim _ _,\n  begin\n    rw [←functor.id_map f, ←functor.id_map g],\n    simp [←nat_iso.naturality_2 (full_normalize_iso.{u} C), this]\n  end⟩\n\nsection groupoid\n\nsection\nopen hom\n\n/-- Auxiliary construction for showing that the free monoidal category is a groupoid. Do not use\n    this, use `is_iso.inv` instead. -/\ndef inverse_aux : Π {X Y : F C}, (X ⟶ᵐ Y) → (Y ⟶ᵐ X)\n| _ _ (id X) := id X\n| _ _ (α_hom _ _ _) := α_inv _ _ _\n| _ _ (α_inv _ _ _) := α_hom _ _ _\n| _ _ (ρ_hom _) := ρ_inv _\n| _ _ (ρ_inv _) := ρ_hom _\n| _ _ (l_hom _) := l_inv _\n| _ _ (l_inv _) := l_hom _\n| _ _ (comp f g) := (inverse_aux g).comp (inverse_aux f)\n| _ _ (hom.tensor f g) := (inverse_aux f).tensor (inverse_aux g)\n\nend\n\ninstance : groupoid.{u} (F C) :=\n{ inv := λ X Y, quotient.lift (λ f, ⟦inverse_aux f⟧) (by tidy),\n  ..(infer_instance : category (F C)) }\n\nend groupoid\n\nend free_monoidal_category\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/monoidal/free/coherence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.4923497154024413}}
{"text": "import field_theory.is_alg_closed.algebraic_closure\nimport data.zmod.basic\nimport data.equiv.transfer_instance\nimport Rings.ToMathlib.char_p\n\n\nnamespace is_alg_closed\n\nopen polynomial\n\nlemma of_exists_root_nat_degree {k : Type*} [field k] (H : ∀ p : polynomial k, p.monic → irreducible p → nat_degree p ≠ 0 → ∃ x, p.eval x = 0) :\n  is_alg_closed k :=\nbegin\n  apply of_exists_root,\n  intros p hmonic hirr,\n  by_cases hdeg : nat_degree p = 0,\n  {\n    rw monic.nat_degree_eq_zero_iff_eq_one hmonic at hdeg,\n    rw hdeg at hirr,\n    exfalso,\n    apply hirr.1,\n    exact ⟨ 1 , rfl ⟩,\n  },\n  apply H p hmonic hirr hdeg,\nend\n\nlemma of_nat_degree_ne_zero_exists_root {k : Type*} [field k]\n  (H : ∀ p : polynomial k, nat_degree p ≠ 0 → ∃ x, p.eval x = 0) :\n  is_alg_closed k :=\nof_exists_root_nat_degree $ λ _ _ hdeg, H _\n\nend is_alg_closed\n\n\nsection zmod\n\nvariables (p : ℕ) [hp : fact (nat.prime p)]\n\ninclude hp\n\n/-- lift zmod up to any universe -/\ndef ulift_zmod := ulift (zmod p)\n\ninstance ulift_zmod.field : field (ulift_zmod p) := equiv.ulift.field\n\nlemma down_nat_coe_ulift_of_zmod :\n  Π {n : ℕ}, (n : ulift_zmod p).down = (n : zmod p)\n| nat.zero := rfl\n| (nat.succ n) :=\nbegin\n  simp only [nat.cast_succ],\n  rw ← down_nat_coe_ulift_of_zmod,\n  refl,\nend\n\nlemma ulift_zmod.char_p : char_p (ulift_zmod p) p :=\nbegin\n  split,\n  intro n,\n  rw ← (zmod.char_p p).cast_eq_zero_iff,\n  split,\n  {\n    intro hn,\n    have hn' := congr_arg ulift.down hn,\n    convert hn',\n    rw down_nat_coe_ulift_of_zmod,\n  },\n  {\n    intro hn,\n    rw ← ulift.up_down ↑n,\n    rw ← ulift.up_down 0,\n    apply congr_arg ulift.up,\n    convert hn,\n    rw down_nat_coe_ulift_of_zmod,\n  },\nend\n\nend zmod\n\n\nnamespace algebraic_closure\n\nsection instances\n\nvariables (p : ℕ) [hp : fact (nat.prime p)]\n\ninclude hp\n\n/-- algebraic closure of finite fields with char p lifted to any universe -/\n@[reducible] def of_ulift_zmod := algebraic_closure (ulift_zmod p)\n\n-- noncomputable instance fields : field (of_zmod p) := by apply_instance\n\nuniverse u\n\n-- noncomputable instance :\n--  algebra (ulift_zmod.{u} p) (of_ulift_zmod.{u} p) := by apply_instance\n\n/-- algebraic closure of zmod is still characteristic p -/\nlemma of_ulift_zmod.char_p : char_p (of_ulift_zmod.{u} p) p :=\n(ring_hom.char_p_iff_char_p (algebra_map (ulift_zmod.{u} p) (of_ulift_zmod.{u} p)) p).1 $ ulift_zmod.char_p p\n\n\n-- @[reducible] def ulift_of_zmod : Type* := ulift (of_zmod p)\n\n-- noncomputable instance of_zmod.field : field (ulift (of_zmod p)) := equiv.ulift.field\n\n-- #check equiv.iff\n\n-- lemma difjsij {α β : Type*} (hequiv : α ≃ β) (p : Type* → Prop) :\n--   p α ↔ p β :=\n-- by library_search\n\ninstance of_zmod.is_alg_closed : is_alg_closed (of_ulift_zmod p) :=\nby apply_instance\n\n-- lemma down_nat_coe_ulift_of_zmod :\n--   Π {n : ℕ}, (n : ulift_of_zmod p).down = (n : of_zmod p)\n-- | nat.zero := rfl\n-- | (nat.succ n) :=\n-- begin\n--   simp only [nat.cast_succ],\n--   rw ← down_nat_coe_ulift_of_zmod,\n--   refl,\n-- end\n\n-- lemma ulift_of_zmod.char_p :\n--   char_p (ulift_of_zmod p) p :=\n-- begin\n--   split,\n--   intro n,\n--   rw ← (of_zmod.char_p p).cast_eq_zero_iff,\n--   split,\n--   {\n--     intro hn,\n--     have hn' := congr_arg ulift.down hn,\n--     convert hn',\n--     rw down_nat_coe_ulift_of_zmod,\n--   },\n--   {\n--     intro hn,\n--     rw ← ulift.up_down ↑n,\n--     rw ← ulift.up_down 0,\n--     apply congr_arg ulift.up,\n--     convert hn,\n--     rw down_nat_coe_ulift_of_zmod,\n--   },\n-- end\n\n\n\nend instances\n\nend algebraic_closure\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/algebraic_closure2March.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.49234970464437805}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Johannes Hölzl, Yury Kudryashov\n-/\nimport algebra.category.Group.basic\nimport category_theory.concrete_category.reflects_isomorphisms\nimport data.equiv.ring\n\n/-!\n# Category instances for semiring, ring, comm_semiring, and comm_ring.\n\nWe introduce the bundled categories:\n* `SemiRing`\n* `Ring`\n* `CommSemiRing`\n* `CommRing`\nalong with the relevant forgetful functors between them.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of semirings. -/\ndef SemiRing : Type (u+1) := bundled semiring\n\nnamespace SemiRing\n\n/-- `ring_hom` doesn't actually assume associativity. This alias is needed to make the category\ntheory machinery work. We use the same trick in `category_theory.Mon.assoc_monoid_hom`. -/\nabbreviation assoc_ring_hom (M N : Type*) [semiring M] [semiring N] := ring_hom M N\n\ninstance bundled_hom : bundled_hom assoc_ring_hom :=\n⟨λ M N [semiring M] [semiring N], by exactI @ring_hom.to_fun M N _ _,\n λ M [semiring M], by exactI @ring_hom.id M _,\n λ M N P [semiring M] [semiring N] [semiring P], by exactI @ring_hom.comp M N P _ _ _,\n λ M N [semiring M] [semiring N], by exactI @ring_hom.coe_inj M N _ _⟩\n\nattribute [derive [large_category, concrete_category]] SemiRing\n\ninstance : has_coe_to_sort SemiRing Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled SemiRing from the underlying type and typeclass. -/\ndef of (R : Type u) [semiring R] : SemiRing := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `SemiRing`. -/\ndef of_hom {R S : Type u} [semiring R] [semiring S] (f : R →+* S) : of R ⟶ of S := f\n\ninstance : inhabited SemiRing := ⟨of punit⟩\n\ninstance (R : SemiRing) : semiring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [semiring R] : (SemiRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_Mon : has_forget₂ SemiRing Mon :=\nbundled_hom.mk_has_forget₂\n  (λ R hR, @monoid_with_zero.to_monoid R (@semiring.to_monoid_with_zero R hR))\n  (λ R₁ R₂, ring_hom.to_monoid_hom) (λ _ _ _, rfl)\n\ninstance has_forget_to_AddCommMon : has_forget₂ SemiRing AddCommMon :=\n-- can't use bundled_hom.mk_has_forget₂, since AddCommMon is an induced category\n{ forget₂ :=\n  { obj := λ R, AddCommMon.of R,\n    map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }\n\nend SemiRing\n\n/-- The category of rings. -/\ndef Ring : Type (u+1) := bundled ring\n\nnamespace Ring\n\ninstance : bundled_hom.parent_projection @ring.to_semiring := ⟨⟩\n\nattribute [derive [(λ Ring, has_coe_to_sort Ring Type*), large_category, concrete_category]] Ring\n\n/-- Construct a bundled Ring from the underlying type and typeclass. -/\ndef of (R : Type u) [ring R] : Ring := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `Ring`. -/\ndef of_hom {R S : Type u} [ring R] [ring S] (f : R →+* S) : of R ⟶ of S := f\n\ninstance : inhabited Ring := ⟨of punit⟩\n\ninstance (R : Ring) : ring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [ring R] : (Ring.of R : Type u) = R := rfl\n\ninstance has_forget_to_SemiRing : has_forget₂ Ring SemiRing := bundled_hom.forget₂ _ _\ninstance has_forget_to_AddCommGroup : has_forget₂ Ring AddCommGroup :=\n-- can't use bundled_hom.mk_has_forget₂, since AddCommGroup is an induced category\n{ forget₂ :=\n  { obj := λ R, AddCommGroup.of R,\n    map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }\n\nend Ring\n\n/-- The category of commutative semirings. -/\ndef CommSemiRing : Type (u+1) := bundled comm_semiring\n\nnamespace CommSemiRing\n\ninstance : bundled_hom.parent_projection @comm_semiring.to_semiring := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommSemiRing\n\ninstance : has_coe_to_sort CommSemiRing Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled CommSemiRing from the underlying type and typeclass. -/\ndef of (R : Type u) [comm_semiring R] : CommSemiRing := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `CommSemiRing`. -/\ndef of_hom {R S : Type u} [comm_semiring R] [comm_semiring S] (f : R →+* S) : of R ⟶ of S := f\n\ninstance : inhabited CommSemiRing := ⟨of punit⟩\n\ninstance (R : CommSemiRing) : comm_semiring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [comm_semiring R] : (CommSemiRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_SemiRing : has_forget₂ CommSemiRing SemiRing := bundled_hom.forget₂ _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommMon : has_forget₂ CommSemiRing CommMon :=\nhas_forget₂.mk'\n  (λ R : CommSemiRing, CommMon.of R) (λ R, rfl)\n  (λ R₁ R₂ f, f.to_monoid_hom) (by tidy)\n\nend CommSemiRing\n\n/-- The category of commutative rings. -/\ndef CommRing : Type (u+1) := bundled comm_ring\n\nnamespace CommRing\n\ninstance : bundled_hom.parent_projection @comm_ring.to_ring := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommRing\n\ninstance : has_coe_to_sort CommRing Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled CommRing from the underlying type and typeclass. -/\ndef of (R : Type u) [comm_ring R] : CommRing := bundled.of R\n\n/-- Typecheck a `ring_hom` as a morphism in `CommRing`. -/\ndef of_hom {R S : Type u} [comm_ring R] [comm_ring S] (f : R →+* S) : of R ⟶ of S := f\n\ninstance : inhabited CommRing := ⟨of punit⟩\n\ninstance (R : CommRing) : comm_ring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [comm_ring R] : (CommRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_Ring : has_forget₂ CommRing Ring := bundled_hom.forget₂ _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommSemiRing : has_forget₂ CommRing CommSemiRing :=\nhas_forget₂.mk' (λ R : CommRing, CommSemiRing.of R) (λ R, rfl) (λ R₁ R₂ f, f) (by tidy)\n\ninstance : full (forget₂ CommRing CommSemiRing) :=\n{ preimage := λ X Y f, f, }\n\nend CommRing\n\n-- This example verifies an improvement possible in Lean 3.8.\n-- Before that, to have `add_ring_hom.map_zero` usable by `simp` here,\n-- we had to mark all the concrete category `has_coe_to_sort` instances reducible.\n-- Now, it just works.\nexample {R S : CommRing} (i : R ⟶ S) (r : R) (h : r = 0) : i r = 0 :=\nby simp [h]\n\nnamespace ring_equiv\n\nvariables {X Y : Type u}\n\n/-- Build an isomorphism in the category `Ring` from a `ring_equiv` between `ring`s. -/\n@[simps] def to_Ring_iso [ring X] [ring Y] (e : X ≃+* Y) : Ring.of X ≅ Ring.of Y :=\n{ hom := e.to_ring_hom,\n  inv := e.symm.to_ring_hom }\n\n/-- Build an isomorphism in the category `CommRing` from a `ring_equiv` between `comm_ring`s. -/\n@[simps] def to_CommRing_iso [comm_ring X] [comm_ring Y] (e : X ≃+* Y) :\n  CommRing.of X ≅ CommRing.of Y :=\n{ hom := e.to_ring_hom,\n  inv := e.symm.to_ring_hom }\n\nend ring_equiv\n\nnamespace category_theory.iso\n\n/-- Build a `ring_equiv` from an isomorphism in the category `Ring`. -/\ndef Ring_iso_to_ring_equiv {X Y : Ring} (i : X ≅ Y) : X ≃+* Y :=\n{ to_fun    := i.hom,\n  inv_fun   := i.inv,\n  left_inv  := by tidy,\n  right_inv := by tidy,\n  map_add'  := by tidy,\n  map_mul'  := by tidy }.\n\n/-- Build a `ring_equiv` from an isomorphism in the category `CommRing`. -/\ndef CommRing_iso_to_ring_equiv {X Y : CommRing} (i : X ≅ Y) : X ≃+* Y :=\n{ to_fun    := i.hom,\n  inv_fun   := i.inv,\n  left_inv  := by tidy,\n  right_inv := by tidy,\n  map_add'  := by tidy,\n  map_mul'  := by tidy }.\n\nend category_theory.iso\n\n/-- Ring equivalences between `ring`s are the same as (isomorphic to) isomorphisms in `Ring`. -/\ndef ring_equiv_iso_Ring_iso {X Y : Type u} [ring X] [ring Y] :\n  (X ≃+* Y) ≅ (Ring.of X ≅ Ring.of Y) :=\n{ hom := λ e, e.to_Ring_iso,\n  inv := λ i, i.Ring_iso_to_ring_equiv, }\n\n/-- Ring equivalences between `comm_ring`s are the same as (isomorphic to) isomorphisms\nin `CommRing`. -/\ndef ring_equiv_iso_CommRing_iso {X Y : Type u} [comm_ring X] [comm_ring Y] :\n  (X ≃+* Y) ≅ (CommRing.of X ≅ CommRing.of Y) :=\n{ hom := λ e, e.to_CommRing_iso,\n  inv := λ i, i.CommRing_iso_to_ring_equiv, }\n\ninstance Ring.forget_reflects_isos : reflects_isomorphisms (forget Ring.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Ring).map f),\n    let e : X ≃+* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Ring_iso).1⟩,\n  end }\n\ninstance CommRing.forget_reflects_isos : reflects_isomorphisms (forget CommRing.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommRing).map f),\n    let e : X ≃+* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommRing_iso).1⟩,\n  end }\n\n-- It would be nice if we could have the following,\n-- but it requires making `reflects_isomorphisms_forget₂` an instance,\n-- which can cause typeclass loops:\n\nlocal attribute [priority 50,instance] reflects_isomorphisms_forget₂\nexample : reflects_isomorphisms (forget₂ Ring AddCommGroup) := by apply_instance\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/category/CommRing/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629465, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.49231645662222406}}
{"text": "/-\nCopyright (c) 2019 Jan-David Salchow. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo\n-/\nimport algebra.algebra.tower\nimport analysis.asymptotics.asymptotics\nimport analysis.normed_space.linear_isometry\nimport analysis.normed_space.riesz_lemma\n\n/-!\n# Operator norm on the space of continuous linear maps\n\nDefine the operator norm on the space of continuous (semi)linear maps between normed spaces, and\nprove its basic properties. In particular, show that this space is itself a normed space.\n\nSince a lot of elementary properties don't require `∥x∥ = 0 → x = 0` we start setting up the\ntheory for `semi_normed_group` and we specialize to `normed_group` at the end.\n\nNote that most of statements that apply to semilinear maps only hold when the ring homomorphism\nis isometric, as expressed by the typeclass `[ring_hom_isometric σ]`.\n\n-/\n\nnoncomputable theory\nopen_locale classical nnreal topological_space\n\n-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables {𝕜 : Type*} {𝕜₂ : Type*} {𝕜₃ : Type*} {E : Type*} {F : Type*} {Fₗ : Type*} {G : Type*}\n  {Gₗ : Type*}\n\nsection semi_normed\n\nvariables [semi_normed_group E] [semi_normed_group F] [semi_normed_group Fₗ] [semi_normed_group G]\n  [semi_normed_group Gₗ]\n\nopen metric continuous_linear_map\n\nsection normed_field\n/-! Most statements in this file require the field to be non-discrete,\nas this is necessary to deduce an inequality `∥f x∥ ≤ C ∥x∥` from the continuity of f.\nHowever, the other direction always holds.\nIn this section, we just assume that `𝕜` is a normed field.\nIn the remainder of the file, it will be non-discrete. -/\n\nvariables [normed_field 𝕜] [normed_field 𝕜₂] [normed_space 𝕜 E] [normed_space 𝕜₂ F]\nvariables [normed_space 𝕜 G] {σ : 𝕜 →+* 𝕜₂} (f : E →ₛₗ[σ] F)\n\nlemma linear_map.lipschitz_of_bound (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  lipschitz_with (real.to_nnreal C) f :=\nf.to_add_monoid_hom.lipschitz_of_bound C h\n\nlemma linear_map.lipschitz_of_bound_nnnorm (C : ℝ≥0) (h : ∀ x, ∥f x∥₊ ≤ C * ∥x∥₊) :\n  lipschitz_with C f :=\nf.to_add_monoid_hom.lipschitz_of_bound_nnnorm C h\n\ntheorem linear_map.antilipschitz_of_bound {K : ℝ≥0} (h : ∀ x, ∥x∥ ≤ K * ∥f x∥) :\n  antilipschitz_with K f :=\nantilipschitz_with.of_le_mul_dist $\nλ x y, by simpa only [dist_eq_norm, f.map_sub] using h (x - y)\n\nlemma linear_map.bound_of_antilipschitz {K : ℝ≥0} (h : antilipschitz_with K f) (x) :\n  ∥x∥ ≤ K * ∥f x∥ :=\nby simpa only [dist_zero_right, f.map_zero] using h.le_mul_dist x 0\n\nlemma linear_map.uniform_continuous_of_bound (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  uniform_continuous f :=\n(f.lipschitz_of_bound C h).uniform_continuous\n\nlemma linear_map.continuous_of_bound (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  continuous f :=\n(f.lipschitz_of_bound C h).continuous\n\n/-- Construct a continuous linear map from a linear map and a bound on this linear map.\nThe fact that the norm of the continuous linear map is then controlled is given in\n`linear_map.mk_continuous_norm_le`. -/\ndef linear_map.mk_continuous (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) : E →SL[σ] F :=\n⟨f, linear_map.continuous_of_bound f C h⟩\n\n/-- Reinterpret a linear map `𝕜 →ₗ[𝕜] E` as a continuous linear map. This construction\nis generalized to the case of any finite dimensional domain\nin `linear_map.to_continuous_linear_map`. -/\ndef linear_map.to_continuous_linear_map₁ (f : 𝕜 →ₗ[𝕜] E) : 𝕜 →L[𝕜] E :=\nf.mk_continuous (∥f 1∥) $ λ x, le_of_eq $\nby { conv_lhs { rw ← mul_one x }, rw [← smul_eq_mul, f.map_smul, norm_smul, mul_comm] }\n\n/-- Construct a continuous linear map from a linear map and the existence of a bound on this linear\nmap. If you have an explicit bound, use `linear_map.mk_continuous` instead, as a norm estimate will\nfollow automatically in `linear_map.mk_continuous_norm_le`. -/\ndef linear_map.mk_continuous_of_exists_bound (h : ∃C, ∀x, ∥f x∥ ≤ C * ∥x∥) : E →SL[σ] F :=\n⟨f, let ⟨C, hC⟩ := h in linear_map.continuous_of_bound f C hC⟩\n\nlemma continuous_of_linear_of_boundₛₗ {f : E → F} (h_add : ∀ x y, f (x + y) = f x + f y)\n  (h_smul : ∀ (c : 𝕜) x, f (c • x) = (σ c) • f x) {C : ℝ} (h_bound : ∀ x, ∥f x∥ ≤ C*∥x∥) :\n  continuous f :=\nlet φ : E →ₛₗ[σ] F := { to_fun := f, map_add' := h_add, map_smul' := h_smul } in\nφ.continuous_of_bound C h_bound\n\nlemma continuous_of_linear_of_bound {f : E → G} (h_add : ∀ x y, f (x + y) = f x + f y)\n  (h_smul : ∀ (c : 𝕜) x, f (c • x) = c • f x) {C : ℝ} (h_bound : ∀ x, ∥f x∥ ≤ C*∥x∥) :\n  continuous f :=\nlet φ : E →ₗ[𝕜] G := { to_fun := f, map_add' := h_add, map_smul' := h_smul } in\nφ.continuous_of_bound C h_bound\n\n@[simp, norm_cast] lemma linear_map.mk_continuous_coe (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  ((f.mk_continuous C h) : E →ₛₗ[σ] F) = f := rfl\n\n@[simp] lemma linear_map.mk_continuous_apply (C : ℝ) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) (x : E) :\n  f.mk_continuous C h x = f x := rfl\n\n@[simp, norm_cast] lemma linear_map.mk_continuous_of_exists_bound_coe\n  (h : ∃C, ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  ((f.mk_continuous_of_exists_bound h) : E →ₛₗ[σ] F) = f := rfl\n\n@[simp] lemma linear_map.mk_continuous_of_exists_bound_apply (h : ∃C, ∀x, ∥f x∥ ≤ C * ∥x∥) (x : E) :\n  f.mk_continuous_of_exists_bound h x = f x := rfl\n\n@[simp] lemma linear_map.to_continuous_linear_map₁_coe (f : 𝕜 →ₗ[𝕜] E) :\n  (f.to_continuous_linear_map₁ : 𝕜 →ₗ[𝕜] E) = f :=\nrfl\n\n@[simp] lemma linear_map.to_continuous_linear_map₁_apply (f : 𝕜 →ₗ[𝕜] E) (x) :\n  f.to_continuous_linear_map₁ x = f x :=\nrfl\n\nend normed_field\n\nvariables [nondiscrete_normed_field 𝕜] [nondiscrete_normed_field 𝕜₂] [nondiscrete_normed_field 𝕜₃]\n  [normed_space 𝕜 E] [normed_space 𝕜₂ F] [normed_space 𝕜 Fₗ]\n  [normed_space 𝕜₃ G] [normed_space 𝕜 Gₗ]\n  {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃}\n  [ring_hom_comp_triple σ₁₂ σ₂₃ σ₁₃]\n\n/-- If `∥x∥ = 0` and `f` is continuous then `∥f x∥ = 0`. -/\nlemma norm_image_of_norm_zero {f : E →ₛₗ[σ₁₂] F} (hf : continuous f) {x : E} (hx : ∥x∥ = 0) :\n  ∥f x∥ = 0 :=\nbegin\n  refine le_antisymm (le_of_forall_pos_le_add (λ ε hε, _)) (norm_nonneg (f x)),\n  rcases normed_group.tendsto_nhds_nhds.1 (hf.tendsto 0) ε hε with ⟨δ, δ_pos, hδ⟩,\n  replace hδ := hδ x,\n  rw [sub_zero, hx] at hδ,\n  replace hδ := le_of_lt (hδ δ_pos),\n  rw [linear_map.map_zero, sub_zero] at hδ,\n  rwa [zero_add]\nend\n\nsection\n\nvariables [ring_hom_isometric σ₁₂] [ring_hom_isometric σ₂₃]\n\nlemma linear_map.bound_of_shell_semi_normed (f : E →ₛₗ[σ₁₂] F) {ε C : ℝ} (ε_pos : 0 < ε) {c : 𝕜}\n  (hc : 1 < ∥c∥) (hf : ∀ x, ε / ∥c∥ ≤ ∥x∥ → ∥x∥ < ε → ∥f x∥ ≤ C * ∥x∥) {x : E} (hx : ∥x∥ ≠ 0) :\n  ∥f x∥ ≤ C * ∥x∥ :=\nbegin\n  rcases rescale_to_shell_semi_normed hc ε_pos hx with ⟨δ, hδ, δxle, leδx, δinv⟩,\n  have := hf (δ • x) leδx δxle,\n  simpa only [f.map_smulₛₗ, norm_smul, mul_left_comm C, mul_le_mul_left (norm_pos_iff.2 hδ),\n              ring_hom_isometric.is_iso] using hf (δ • x) leδx δxle\nend\n\n/-- A continuous linear map between seminormed spaces is bounded when the field is nondiscrete. The\ncontinuity ensures boundedness on a ball of some radius `ε`. The nondiscreteness is then used to\nrescale any element into an element of norm in `[ε/C, ε]`, whose image has a controlled norm. The\nnorm control for the original element follows by rescaling. -/\nlemma linear_map.bound_of_continuous (f : E →ₛₗ[σ₁₂] F) (hf : continuous f) :\n  ∃ C, 0 < C ∧ (∀ x : E, ∥f x∥ ≤ C * ∥x∥) :=\nbegin\n  rcases normed_group.tendsto_nhds_nhds.1 (hf.tendsto 0) 1 zero_lt_one with ⟨ε, ε_pos, hε⟩,\n  simp only [sub_zero, f.map_zero] at hε,\n  rcases normed_field.exists_one_lt_norm 𝕜 with ⟨c, hc⟩,\n  have : 0 < ∥c∥ / ε, from div_pos (zero_lt_one.trans hc) ε_pos,\n  refine ⟨∥c∥ / ε, this, λ x, _⟩,\n  by_cases hx : ∥x∥ = 0,\n  { rw [hx, mul_zero],\n    exact le_of_eq (norm_image_of_norm_zero hf hx) },\n  refine f.bound_of_shell_semi_normed ε_pos hc (λ x hle hlt, _) hx,\n  refine (hε _ hlt).le.trans _,\n  rwa [← div_le_iff' this, one_div_div]\nend\n\nend\n\nnamespace continuous_linear_map\n\ntheorem bound [ring_hom_isometric σ₁₂] (f : E →SL[σ₁₂] F) :\n  ∃ C, 0 < C ∧ (∀ x : E, ∥f x∥ ≤ C * ∥x∥) :=\nf.to_linear_map.bound_of_continuous f.2\n\nsection\nopen filter\n\n/-- A linear map which is a homothety is a continuous linear map.\n    Since the field `𝕜` need not have `ℝ` as a subfield, this theorem is not directly deducible from\n    the corresponding theorem about isometries plus a theorem about scalar multiplication.  Likewise\n    for the other theorems about homotheties in this file.\n -/\ndef of_homothety (f : E →ₛₗ[σ₁₂] F) (a : ℝ) (hf : ∀x, ∥f x∥ = a * ∥x∥) : E →SL[σ₁₂] F :=\nf.mk_continuous a (λ x, le_of_eq (hf x))\n\nvariable (𝕜)\n\nlemma to_span_singleton_homothety (x : E) (c : 𝕜) :\n  ∥linear_map.to_span_singleton 𝕜 E x c∥ = ∥x∥ * ∥c∥ :=\nby {rw mul_comm, exact norm_smul _ _}\n\n/-- Given an element `x` of a normed space `E` over a field `𝕜`, the natural continuous\n    linear map from `𝕜` to `E` by taking multiples of `x`.-/\ndef to_span_singleton (x : E) : 𝕜 →L[𝕜] E :=\nof_homothety (linear_map.to_span_singleton 𝕜 E x) ∥x∥ (to_span_singleton_homothety 𝕜 x)\n\nlemma to_span_singleton_apply (x : E) (r : 𝕜) : to_span_singleton 𝕜 x r = r • x :=\nby simp [to_span_singleton, of_homothety, linear_map.to_span_singleton]\n\nlemma to_span_singleton_add (x y : E) :\n  to_span_singleton 𝕜 (x + y) = to_span_singleton 𝕜 x + to_span_singleton 𝕜 y :=\nby { ext1, simp [to_span_singleton_apply], }\n\nlemma to_span_singleton_smul' (𝕜') [nondiscrete_normed_field 𝕜'] [normed_space 𝕜' E]\n  [smul_comm_class 𝕜 𝕜' E] (c : 𝕜') (x : E) :\n  to_span_singleton 𝕜 (c • x) = c • to_span_singleton 𝕜 x :=\nby { ext1, rw [to_span_singleton_apply, smul_apply, to_span_singleton_apply, smul_comm], }\n\nlemma to_span_singleton_smul (c : 𝕜) (x : E) :\n  to_span_singleton 𝕜 (c • x) = c • to_span_singleton 𝕜 x :=\nto_span_singleton_smul' 𝕜 𝕜 c x\n\nvariables (𝕜 E)\n/-- Given a unit-length element `x` of a normed space `E` over a field `𝕜`, the natural linear\n    isometry map from `𝕜` to `E` by taking multiples of `x`.-/\ndef _root_.linear_isometry.to_span_singleton {v : E} (hv : ∥v∥ = 1) : 𝕜 →ₗᵢ[𝕜] E :=\n{ norm_map' := λ x, by simp [norm_smul, hv],\n  .. linear_map.to_span_singleton 𝕜 E v }\nvariables {𝕜 E}\n\n@[simp] lemma _root_.linear_isometry.to_span_singleton_apply {v : E} (hv : ∥v∥ = 1) (a : 𝕜) :\n  linear_isometry.to_span_singleton 𝕜 E hv a = a • v :=\nrfl\n\n@[simp] lemma _root_.linear_isometry.coe_to_span_singleton {v : E} (hv : ∥v∥ = 1) :\n  (linear_isometry.to_span_singleton 𝕜 E hv).to_linear_map = linear_map.to_span_singleton 𝕜 E v :=\nrfl\n\nend\n\nsection op_norm\nopen set real\n\n/-- The operator norm of a continuous linear map is the inf of all its bounds. -/\ndef op_norm (f : E →SL[σ₁₂] F) := Inf {c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥}\ninstance has_op_norm : has_norm (E →SL[σ₁₂] F) := ⟨op_norm⟩\n\nlemma norm_def (f : E →SL[σ₁₂] F) : ∥f∥ = Inf {c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥} := rfl\n\n-- So that invocations of `le_cInf` make sense: we show that the set of\n-- bounds is nonempty and bounded below.\nlemma bounds_nonempty [ring_hom_isometric σ₁₂] {f : E →SL[σ₁₂] F} :\n  ∃ c, c ∈ { c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥ } :=\nlet ⟨M, hMp, hMb⟩ := f.bound in ⟨M, le_of_lt hMp, hMb⟩\n\nlemma bounds_bdd_below {f : E →SL[σ₁₂] F} :\n  bdd_below { c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥ } :=\n⟨0, λ _ ⟨hn, _⟩, hn⟩\n\n/-- If one controls the norm of every `A x`, then one controls the norm of `A`. -/\nlemma op_norm_le_bound (f : E →SL[σ₁₂] F) {M : ℝ} (hMp: 0 ≤ M) (hM : ∀ x, ∥f x∥ ≤ M * ∥x∥) :\n  ∥f∥ ≤ M :=\ncInf_le bounds_bdd_below ⟨hMp, hM⟩\n\ntheorem op_norm_le_of_lipschitz {f : E →SL[σ₁₂] F} {K : ℝ≥0} (hf : lipschitz_with K f) :\n  ∥f∥ ≤ K :=\nf.op_norm_le_bound K.2 $ λ x, by simpa only [dist_zero_right, f.map_zero] using hf.dist_le_mul x 0\n\nlemma op_norm_eq_of_bounds {φ : E →SL[σ₁₂] F} {M : ℝ} (M_nonneg : 0 ≤ M)\n  (h_above : ∀ x, ∥φ x∥ ≤ M*∥x∥) (h_below : ∀ N ≥ 0, (∀ x, ∥φ x∥ ≤ N*∥x∥) → M ≤ N) :\n  ∥φ∥ = M :=\nle_antisymm (φ.op_norm_le_bound M_nonneg h_above)\n  ((le_cInf_iff continuous_linear_map.bounds_bdd_below ⟨M, M_nonneg, h_above⟩).mpr $\n   λ N ⟨N_nonneg, hN⟩, h_below N N_nonneg hN)\n\nlemma op_norm_neg (f : E →SL[σ₁₂] F) : ∥-f∥ = ∥f∥ := by simp only [norm_def, neg_apply, norm_neg]\n\ntheorem antilipschitz_of_bound (f : E →SL[σ₁₂] F) {K : ℝ≥0} (h : ∀ x, ∥x∥ ≤ K * ∥f x∥) :\n  antilipschitz_with K f :=\nlinear_map.antilipschitz_of_bound _ h\n\nlemma bound_of_antilipschitz (f : E →SL[σ₁₂] F) {K : ℝ≥0} (h : antilipschitz_with K f) (x) :\n  ∥x∥ ≤ K * ∥f x∥ :=\nlinear_map.bound_of_antilipschitz _ h x\n\nsection\n\nvariables [ring_hom_isometric σ₁₂] [ring_hom_isometric σ₂₃]\n  (f g : E →SL[σ₁₂] F) (h : F →SL[σ₂₃] G) (x : E)\n\nlemma op_norm_nonneg : 0 ≤ ∥f∥ :=\nle_cInf bounds_nonempty (λ _ ⟨hx, _⟩, hx)\n\n/-- The fundamental property of the operator norm: `∥f x∥ ≤ ∥f∥ * ∥x∥`. -/\ntheorem le_op_norm : ∥f x∥ ≤ ∥f∥ * ∥x∥ :=\nbegin\n  obtain ⟨C, Cpos, hC⟩ := f.bound,\n  replace hC := hC x,\n  by_cases h : ∥x∥ = 0,\n  { rwa [h, mul_zero] at ⊢ hC },\n  have hlt : 0 < ∥x∥ := lt_of_le_of_ne (norm_nonneg x) (ne.symm h),\n  exact  (div_le_iff hlt).mp (le_cInf bounds_nonempty (λ c ⟨_, hc⟩,\n    (div_le_iff hlt).mpr $ by { apply hc })),\nend\n\ntheorem le_op_norm_of_le {c : ℝ} {x} (h : ∥x∥ ≤ c) : ∥f x∥ ≤ ∥f∥ * c :=\nle_trans (f.le_op_norm x) (mul_le_mul_of_nonneg_left h f.op_norm_nonneg)\n\ntheorem le_of_op_norm_le {c : ℝ} (h : ∥f∥ ≤ c) (x : E) : ∥f x∥ ≤ c * ∥x∥ :=\n(f.le_op_norm x).trans (mul_le_mul_of_nonneg_right h (norm_nonneg x))\n\nlemma ratio_le_op_norm : ∥f x∥ / ∥x∥ ≤ ∥f∥ :=\ndiv_le_of_nonneg_of_le_mul (norm_nonneg _) f.op_norm_nonneg (le_op_norm _ _)\n\n/-- The image of the unit ball under a continuous linear map is bounded. -/\nlemma unit_le_op_norm : ∥x∥ ≤ 1 → ∥f x∥ ≤ ∥f∥ :=\nmul_one ∥f∥ ▸ f.le_op_norm_of_le\n\nlemma op_norm_le_of_shell {f : E →SL[σ₁₂] F} {ε C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C)\n  {c : 𝕜} (hc : 1 < ∥c∥) (hf : ∀ x, ε / ∥c∥ ≤ ∥x∥ → ∥x∥ < ε → ∥f x∥ ≤ C * ∥x∥) :\n  ∥f∥ ≤ C :=\nbegin\n  refine f.op_norm_le_bound hC (λ x, _),\n  by_cases hx : ∥x∥ = 0,\n  { rw [hx, mul_zero],\n    exact le_of_eq (norm_image_of_norm_zero f.2 hx) },\n  exact linear_map.bound_of_shell_semi_normed f ε_pos hc hf hx\nend\n\nlemma op_norm_le_of_ball {f : E →SL[σ₁₂] F} {ε : ℝ} {C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C)\n  (hf : ∀ x ∈ ball (0 : E) ε, ∥f x∥ ≤ C * ∥x∥) : ∥f∥ ≤ C :=\nbegin\n  rcases normed_field.exists_one_lt_norm 𝕜 with ⟨c, hc⟩,\n  refine op_norm_le_of_shell ε_pos hC hc (λ x _ hx, hf x _),\n  rwa ball_zero_eq\nend\n\nlemma op_norm_le_of_nhds_zero {f : E →SL[σ₁₂] F} {C : ℝ} (hC : 0 ≤ C)\n  (hf : ∀ᶠ x in 𝓝 (0 : E), ∥f x∥ ≤ C * ∥x∥) : ∥f∥ ≤ C :=\nlet ⟨ε, ε0, hε⟩ := metric.eventually_nhds_iff_ball.1 hf in op_norm_le_of_ball ε0 hC hε\n\nlemma op_norm_le_of_shell' {f : E →SL[σ₁₂] F} {ε C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C)\n  {c : 𝕜} (hc : ∥c∥ < 1) (hf : ∀ x, ε * ∥c∥ ≤ ∥x∥ → ∥x∥ < ε → ∥f x∥ ≤ C * ∥x∥) :\n  ∥f∥ ≤ C :=\nbegin\n  by_cases h0 : c = 0,\n  { refine op_norm_le_of_ball ε_pos hC (λ x hx, hf x _ _),\n    { simp [h0] },\n    { rwa ball_zero_eq at hx } },\n  { rw [← inv_inv c, norm_inv,\n      inv_lt_one_iff_of_pos (norm_pos_iff.2 $ inv_ne_zero h0)] at hc,\n    refine op_norm_le_of_shell ε_pos hC hc _,\n    rwa [norm_inv, div_eq_mul_inv, inv_inv] }\nend\n\n/-- The operator norm satisfies the triangle inequality. -/\ntheorem op_norm_add_le : ∥f + g∥ ≤ ∥f∥ + ∥g∥ :=\n(f + g).op_norm_le_bound (add_nonneg f.op_norm_nonneg g.op_norm_nonneg) $\n  λ x, (norm_add_le_of_le (f.le_op_norm x) (g.le_op_norm x)).trans_eq (add_mul _ _ _).symm\n\n/-- The norm of the `0` operator is `0`. -/\ntheorem op_norm_zero : ∥(0 : E →SL[σ₁₂] F)∥ = 0 :=\nle_antisymm (cInf_le bounds_bdd_below\n    ⟨ge_of_eq rfl, λ _, le_of_eq (by { rw [zero_mul], exact norm_zero })⟩)\n    (op_norm_nonneg _)\n\n/-- The norm of the identity is at most `1`. It is in fact `1`, except when the space is trivial\nwhere it is `0`. It means that one can not do better than an inequality in general. -/\nlemma norm_id_le : ∥id 𝕜 E∥ ≤ 1 :=\nop_norm_le_bound _ zero_le_one (λx, by simp)\n\n/-- If there is an element with norm different from `0`, then the norm of the identity equals `1`.\n(Since we are working with seminorms supposing that the space is non-trivial is not enough.) -/\nlemma norm_id_of_nontrivial_seminorm (h : ∃ (x : E), ∥x∥ ≠ 0) : ∥id 𝕜 E∥ = 1 :=\nle_antisymm norm_id_le $ let ⟨x, hx⟩ := h in\nhave _ := (id 𝕜 E).ratio_le_op_norm x,\nby rwa [id_apply, div_self hx] at this\n\nlemma op_norm_smul_le {𝕜' : Type*} [normed_field 𝕜'] [normed_space 𝕜' F]\n  [smul_comm_class 𝕜₂ 𝕜' F] (c : 𝕜') (f : E →SL[σ₁₂] F) : ∥c • f∥ ≤ ∥c∥ * ∥f∥ :=\n((c • f).op_norm_le_bound\n  (mul_nonneg (norm_nonneg _) (op_norm_nonneg _)) (λ _,\n  begin\n    erw [norm_smul, mul_assoc],\n    exact mul_le_mul_of_nonneg_left (le_op_norm _ _) (norm_nonneg _)\n  end))\n\n/-- Continuous linear maps themselves form a seminormed space with respect to\n    the operator norm. -/\ninstance to_semi_normed_group : semi_normed_group (E →SL[σ₁₂] F) :=\nsemi_normed_group.of_core _ ⟨op_norm_zero, λ x y, op_norm_add_le x y, op_norm_neg⟩\n\ninstance to_normed_space {𝕜' : Type*} [normed_field 𝕜'] [normed_space 𝕜' F]\n  [smul_comm_class 𝕜₂ 𝕜' F] : normed_space 𝕜' (E →SL[σ₁₂] F) :=\n⟨op_norm_smul_le⟩\n\ninclude σ₁₃\n/-- The operator norm is submultiplicative. -/\nlemma op_norm_comp_le (f : E →SL[σ₁₂] F) : ∥h.comp f∥ ≤ ∥h∥ * ∥f∥ :=\n(cInf_le bounds_bdd_below\n  ⟨mul_nonneg (op_norm_nonneg _) (op_norm_nonneg _), λ x,\n    by { rw mul_assoc, exact h.le_op_norm_of_le (f.le_op_norm x) } ⟩)\nomit σ₁₃\n\n/-- Continuous linear maps form a seminormed ring with respect to the operator norm. -/\ninstance to_semi_normed_ring : semi_normed_ring (E →L[𝕜] E) :=\n{ norm_mul := λ f g, op_norm_comp_le f g,\n  .. continuous_linear_map.to_semi_normed_group }\n\ntheorem le_op_nnnorm : ∥f x∥₊ ≤ ∥f∥₊ * ∥x∥₊ := f.le_op_norm x\n\n/-- continuous linear maps are Lipschitz continuous. -/\ntheorem lipschitz : lipschitz_with ∥f∥₊ f :=\n(f : E →ₛₗ[σ₁₂] F).lipschitz_of_bound_nnnorm _ f.le_op_nnnorm\n\n/-- Evaluation of a continuous linear map `f` at a point is Lipschitz continuous in `f`. -/\ntheorem lipschitz_apply (x : E) : lipschitz_with ∥x∥₊ (λ f : E →SL[σ₁₂] F, f x) :=\nlipschitz_with_iff_norm_sub_le.2 $ λ f g, ((f - g).le_op_norm x).trans_eq (mul_comm _ _)\n\nend\n\nsection\n\nlemma op_norm_ext [ring_hom_isometric σ₁₃] (f : E →SL[σ₁₂] F) (g : E →SL[σ₁₃] G)\n  (h : ∀ x, ∥f x∥ = ∥g x∥) : ∥f∥ = ∥g∥ :=\nop_norm_eq_of_bounds (norm_nonneg _) (λ x, by { rw h x, exact le_op_norm _ _ })\n  (λ c hc h₂, op_norm_le_bound _ hc (λ z, by { rw ←h z, exact h₂ z }))\n\nvariables [ring_hom_isometric σ₂₃]\n\ntheorem op_norm_le_bound₂ (f : E →SL[σ₁₃] F →SL[σ₂₃] G) {C : ℝ} (h0 : 0 ≤ C)\n  (hC : ∀ x y, ∥f x y∥ ≤ C * ∥x∥ * ∥y∥) :\n  ∥f∥ ≤ C :=\nf.op_norm_le_bound h0 $ λ x,\n  (f x).op_norm_le_bound (mul_nonneg h0 (norm_nonneg _)) $ hC x\n\ntheorem le_op_norm₂ [ring_hom_isometric σ₁₃] (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (x : E) (y : F) :\n  ∥f x y∥ ≤ ∥f∥ * ∥x∥ * ∥y∥ :=\n(f x).le_of_op_norm_le (f.le_op_norm x) y\n\nend\n\n@[simp] lemma op_norm_prod (f : E →L[𝕜] Fₗ) (g : E →L[𝕜] Gₗ) : ∥f.prod g∥ = ∥(f, g)∥ :=\nle_antisymm\n  (op_norm_le_bound _ (norm_nonneg _) $ λ x,\n    by simpa only [prod_apply, prod.norm_def, max_mul_of_nonneg, norm_nonneg]\n      using max_le_max (le_op_norm f x) (le_op_norm g x)) $\n  max_le\n    (op_norm_le_bound _ (norm_nonneg _) $ λ x, (le_max_left _ _).trans ((f.prod g).le_op_norm x))\n    (op_norm_le_bound _ (norm_nonneg _) $ λ x, (le_max_right _ _).trans ((f.prod g).le_op_norm x))\n\n/-- `continuous_linear_map.prod` as a `linear_isometry_equiv`. -/\ndef prodₗᵢ (R : Type*) [semiring R] [module R Fₗ] [module R Gₗ]\n  [has_continuous_const_smul R Fₗ] [has_continuous_const_smul R Gₗ]\n  [smul_comm_class 𝕜 R Fₗ] [smul_comm_class 𝕜 R Gₗ] :\n  (E →L[𝕜] Fₗ) × (E →L[𝕜] Gₗ) ≃ₗᵢ[R] (E →L[𝕜] Fₗ × Gₗ) :=\n⟨prodₗ R, λ ⟨f, g⟩, op_norm_prod f g⟩\n\n/-- A continuous linear map is an isometry if and only if it preserves the norm.\n(Note: Do you really want to use this lemma?  Try using the bundled structure `linear_isometry`\ninstead.) -/\nlemma isometry_iff_norm (f : E →SL[σ₁₂] F) : isometry f ↔ ∀x, ∥f x∥ = ∥x∥ :=\nf.to_linear_map.to_add_monoid_hom.isometry_iff_norm\n\nvariables [ring_hom_isometric σ₁₂] (f : E →SL[σ₁₂] F)\n\n/-- A continuous linear map is automatically uniformly continuous. -/\nprotected theorem uniform_continuous : uniform_continuous f :=\nf.lipschitz.uniform_continuous\n\n@[simp, nontriviality] lemma op_norm_subsingleton [subsingleton E] : ∥f∥ = 0 :=\nbegin\n  refine le_antisymm _ (norm_nonneg _),\n  apply op_norm_le_bound _ rfl.ge,\n  intros x,\n  simp [subsingleton.elim x 0]\nend\n\nend op_norm\n\nsection is_O\n\nvariables [ring_hom_isometric σ₁₂]\n  (c : 𝕜) (f g : E →SL[σ₁₂] F) (h : F →SL[σ₂₃] G) (x y z : E)\n\nopen asymptotics\n\ntheorem is_O_with_id (l : filter E) : is_O_with ∥f∥ f (λ x, x) l :=\nis_O_with_of_le' _ f.le_op_norm\n\ntheorem is_O_id (l : filter E) : is_O f (λ x, x) l :=\n(f.is_O_with_id l).is_O\n\ntheorem is_O_with_comp [ring_hom_isometric σ₂₃] {α : Type*} (g : F →SL[σ₂₃] G) (f : α → F)\n  (l : filter α) :\n  is_O_with ∥g∥ (λ x', g (f x')) f l :=\n(g.is_O_with_id ⊤).comp_tendsto le_top\n\ntheorem is_O_comp [ring_hom_isometric σ₂₃] {α : Type*} (g : F →SL[σ₂₃] G) (f : α → F)\n  (l : filter α) :\n  is_O (λ x', g (f x')) f l :=\n(g.is_O_with_comp f l).is_O\n\ntheorem is_O_with_sub (f : E →SL[σ₁₂] F) (l : filter E) (x : E) :\n  is_O_with ∥f∥ (λ x', f (x' - x)) (λ x', x' - x) l :=\nf.is_O_with_comp _ l\n\ntheorem is_O_sub (f : E →SL[σ₁₂] F) (l : filter E) (x : E) :\n  is_O (λ x', f (x' - x)) (λ x', x' - x) l :=\nf.is_O_comp _ l\n\nend is_O\n\nend continuous_linear_map\n\nnamespace linear_isometry\n\nlemma norm_to_continuous_linear_map_le (f : E →ₛₗᵢ[σ₁₂] F) :\n  ∥f.to_continuous_linear_map∥ ≤ 1 :=\nf.to_continuous_linear_map.op_norm_le_bound zero_le_one $ λ x, by simp\n\nend linear_isometry\n\nnamespace linear_map\n\n/-- If a continuous linear map is constructed from a linear map via the constructor `mk_continuous`,\nthen its norm is bounded by the bound given to the constructor if it is nonnegative. -/\nlemma mk_continuous_norm_le (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (hC : 0 ≤ C) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  ∥f.mk_continuous C h∥ ≤ C :=\ncontinuous_linear_map.op_norm_le_bound _ hC h\n\n/-- If a continuous linear map is constructed from a linear map via the constructor `mk_continuous`,\nthen its norm is bounded by the bound or zero if bound is negative. -/\nlemma mk_continuous_norm_le' (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  ∥f.mk_continuous C h∥ ≤ max C 0 :=\ncontinuous_linear_map.op_norm_le_bound _ (le_max_right _ _) $ λ x, (h x).trans $\n  mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg x)\n\nvariables [ring_hom_isometric σ₂₃]\n\n/-- Create a bilinear map (represented as a map `E →L[𝕜] F →L[𝕜] G`) from the corresponding linear\nmap and a bound on the norm of the image. The linear map can be constructed using\n`linear_map.mk₂`. -/\ndef mk_continuous₂ (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) (C : ℝ)\n  (hC : ∀ x y, ∥f x y∥ ≤ C * ∥x∥ * ∥y∥) :\n  E →SL[σ₁₃] F →SL[σ₂₃] G :=\nlinear_map.mk_continuous\n  { to_fun := λ x, (f x).mk_continuous (C * ∥x∥) (hC x),\n    map_add' := λ x y, by { ext z, simp },\n    map_smul' := λ c x, by { ext z, simp } }\n  (max C 0) $ λ x, (mk_continuous_norm_le' _ _).trans_eq $\n    by rw [max_mul_of_nonneg _ _ (norm_nonneg x), zero_mul]\n\n@[simp] lemma mk_continuous₂_apply (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) {C : ℝ}\n  (hC : ∀ x y, ∥f x y∥ ≤ C * ∥x∥ * ∥y∥) (x : E) (y : F) :\n  f.mk_continuous₂ C hC x y = f x y :=\nrfl\n\nlemma mk_continuous₂_norm_le' (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) {C : ℝ}\n  (hC : ∀ x y, ∥f x y∥ ≤ C * ∥x∥ * ∥y∥) :\n  ∥f.mk_continuous₂ C hC∥ ≤ max C 0 :=\nmk_continuous_norm_le _ (le_max_iff.2 $ or.inr le_rfl) _\n\nlemma mk_continuous₂_norm_le (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) {C : ℝ} (h0 : 0 ≤ C)\n  (hC : ∀ x y, ∥f x y∥ ≤ C * ∥x∥ * ∥y∥) :\n  ∥f.mk_continuous₂ C hC∥ ≤ C :=\n(f.mk_continuous₂_norm_le' hC).trans_eq $ max_eq_left h0\n\nend linear_map\n\nnamespace continuous_linear_map\n\nvariables [ring_hom_isometric σ₂₃] [ring_hom_isometric σ₁₃]\n\n/-- Flip the order of arguments of a continuous bilinear map.\nFor a version bundled as `linear_isometry_equiv`, see\n`continuous_linear_map.flipL`. -/\ndef flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) : F →SL[σ₂₃] E →SL[σ₁₃] G :=\nlinear_map.mk_continuous₂\n  (linear_map.mk₂'ₛₗ σ₂₃ σ₁₃ (λ y x, f x y)\n    (λ x y z, (f z).map_add x y)\n    (λ c y x, (f x).map_smulₛₗ c y)\n    (λ z x y, by rw [f.map_add, add_apply])\n    (λ c y x, by rw [map_smulₛₗ, smul_apply]))\n  ∥f∥\n  (λ y x, (f.le_op_norm₂ x y).trans_eq $ by rw mul_right_comm)\n\nprivate lemma le_norm_flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) : ∥f∥ ≤ ∥flip f∥ :=\nf.op_norm_le_bound₂ (norm_nonneg _) $ λ x y,\n  by { rw mul_right_comm, exact (flip f).le_op_norm₂ y x }\n\n@[simp] lemma flip_apply (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (x : E) (y : F) : f.flip y x = f x y := rfl\n\n@[simp] lemma flip_flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) :\n  f.flip.flip = f :=\nby { ext, refl }\n\n@[simp] lemma op_norm_flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) :\n  ∥f.flip∥ = ∥f∥ :=\nle_antisymm (by simpa only [flip_flip] using le_norm_flip f.flip) (le_norm_flip f)\n\n@[simp] lemma flip_add (f g : E →SL[σ₁₃] F →SL[σ₂₃] G) :\n  (f + g).flip = f.flip + g.flip :=\nrfl\n\n@[simp] lemma flip_smul (c : 𝕜₃) (f : E →SL[σ₁₃] F →SL[σ₂₃] G) :\n  (c • f).flip = c • f.flip :=\nrfl\n\nvariables (E F G σ₁₃ σ₂₃)\n\n/-- Flip the order of arguments of a continuous bilinear map.\nThis is a version bundled as a `linear_isometry_equiv`.\nFor an unbundled version see `continuous_linear_map.flip`. -/\ndef flipₗᵢ' : (E →SL[σ₁₃] F →SL[σ₂₃] G) ≃ₗᵢ[𝕜₃] (F →SL[σ₂₃] E →SL[σ₁₃] G) :=\n{ to_fun := flip,\n  inv_fun := flip,\n  map_add' := flip_add,\n  map_smul' := flip_smul,\n  left_inv := flip_flip,\n  right_inv := flip_flip,\n  norm_map' := op_norm_flip }\n\nvariables {E F G σ₁₃ σ₂₃}\n\n@[simp] lemma flipₗᵢ'_symm : (flipₗᵢ' E F G σ₂₃ σ₁₃).symm = flipₗᵢ' F E G σ₁₃ σ₂₃ := rfl\n\n@[simp] lemma coe_flipₗᵢ' : ⇑(flipₗᵢ' E F G σ₂₃ σ₁₃) = flip := rfl\n\nvariables (𝕜 E Fₗ Gₗ)\n\n/-- Flip the order of arguments of a continuous bilinear map.\nThis is a version bundled as a `linear_isometry_equiv`.\nFor an unbundled version see `continuous_linear_map.flip`. -/\ndef flipₗᵢ : (E →L[𝕜] Fₗ →L[𝕜] Gₗ) ≃ₗᵢ[𝕜] (Fₗ →L[𝕜] E →L[𝕜] Gₗ) :=\n{ to_fun := flip,\n  inv_fun := flip,\n  map_add' := flip_add,\n  map_smul' := flip_smul,\n  left_inv := flip_flip,\n  right_inv := flip_flip,\n  norm_map' := op_norm_flip }\n\nvariables {𝕜 E Fₗ Gₗ}\n\n@[simp] lemma flipₗᵢ_symm : (flipₗᵢ 𝕜 E Fₗ Gₗ).symm = flipₗᵢ 𝕜 Fₗ E Gₗ := rfl\n\n@[simp] lemma coe_flipₗᵢ : ⇑(flipₗᵢ 𝕜 E Fₗ Gₗ) = flip := rfl\n\nvariables (F σ₁₂) [ring_hom_isometric σ₁₂]\n\n/-- The continuous semilinear map obtained by applying a continuous semilinear map at a given\nvector.\n\nThis is the continuous version of `linear_map.applyₗ`. -/\ndef apply' : E →SL[σ₁₂] (E →SL[σ₁₂] F) →L[𝕜₂] F := flip (id 𝕜₂ (E →SL[σ₁₂] F))\n\nvariables {F σ₁₂}\n\n@[simp] lemma apply_apply' (v : E) (f : E →SL[σ₁₂] F) : apply' F σ₁₂ v f = f v := rfl\n\nvariables (𝕜 Fₗ)\n\n/-- The continuous semilinear map obtained by applying a continuous semilinear map at a given\nvector.\n\nThis is the continuous version of `linear_map.applyₗ`. -/\ndef apply : E →L[𝕜] (E →L[𝕜] Fₗ) →L[𝕜] Fₗ := flip (id 𝕜 (E →L[𝕜] Fₗ))\n\nvariables {𝕜 Fₗ}\n\n@[simp] lemma apply_apply (v : E) (f : E →L[𝕜] Fₗ) : apply 𝕜 Fₗ v f = f v := rfl\n\nvariables (σ₁₂ σ₂₃ E F G)\n\n/-- Composition of continuous semilinear maps as a continuous semibilinear map. -/\ndef compSL : (F →SL[σ₂₃] G) →L[𝕜₃] (E →SL[σ₁₂] F) →SL[σ₂₃] (E →SL[σ₁₃] G) :=\nlinear_map.mk_continuous₂\n  (linear_map.mk₂'ₛₗ (ring_hom.id 𝕜₃) σ₂₃ comp add_comp smul_comp comp_add\n    (λ c f g, by { ext, simp only [map_smulₛₗ, coe_smul', coe_comp',\n                                   function.comp_app, pi.smul_apply] }))\n  1 $ λ f g, by simpa only [one_mul] using op_norm_comp_le f g\n\nvariables {𝕜 E F G}\n\ninclude σ₁₃\n\n@[simp] lemma compSL_apply (f : F →SL[σ₂₃] G) (g : E →SL[σ₁₂] F) :\n  compSL E F G σ₁₂ σ₂₃ f g = f.comp g := rfl\n\nomit σ₁₃\nvariables (𝕜 E Fₗ Gₗ)\n\n/-- Composition of continuous linear maps as a continuous bilinear map. -/\ndef compL : (Fₗ →L[𝕜] Gₗ) →L[𝕜] (E →L[𝕜] Fₗ) →L[𝕜] (E →L[𝕜] Gₗ) :=\n  compSL E Fₗ Gₗ (ring_hom.id 𝕜) (ring_hom.id 𝕜)\n\n@[simp] lemma compL_apply (f : Fₗ →L[𝕜] Gₗ) (g : E →L[𝕜] Fₗ) : compL 𝕜 E Fₗ Gₗ f g = f.comp g := rfl\n\nuniverses u₁ u₂ u₃ u₄\nvariables (M₁ : Type u₁) [normed_group M₁] [normed_space 𝕜 M₁]\n          (M₂ : Type u₂) [normed_group M₂] [normed_space 𝕜 M₂]\n          (M₃ : Type u₃) [normed_group M₃] [normed_space 𝕜 M₃]\n          (M₄ : Type u₄) [normed_group M₄] [normed_space 𝕜 M₄]\n\n/-- `continuous_linear_map.prod_map` as a continuous linear map. -/\ndef prod_mapL : ((M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄)) →L[𝕜] ((M₁ × M₃) →L[𝕜] (M₂ × M₄)) :=\ncontinuous_linear_map.copy\n(have Φ₁ : (M₁ →L[𝕜] M₂) →L[𝕜] (M₁ →L[𝕜] M₂ × M₄), from\n  continuous_linear_map.compL 𝕜 M₁ M₂ (M₂ × M₄) (continuous_linear_map.inl 𝕜 M₂ M₄),\nhave Φ₂ : (M₃ →L[𝕜] M₄) →L[𝕜] (M₃ →L[𝕜] M₂ × M₄), from\n  continuous_linear_map.compL 𝕜 M₃ M₄ (M₂ × M₄) (continuous_linear_map.inr 𝕜 M₂ M₄),\nhave Φ₁' : _, from (continuous_linear_map.compL 𝕜 (M₁ × M₃) M₁ (M₂ × M₄)).flip\n  (continuous_linear_map.fst 𝕜 M₁ M₃),\nhave Φ₂' : _ , from (continuous_linear_map.compL 𝕜 (M₁ × M₃) M₃ (M₂ × M₄)).flip\n  (continuous_linear_map.snd 𝕜 M₁ M₃),\nhave Ψ₁ : ((M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄)) →L[𝕜] (M₁ →L[𝕜] M₂), from\n  continuous_linear_map.fst 𝕜 (M₁ →L[𝕜] M₂) (M₃ →L[𝕜] M₄),\nhave Ψ₂ : ((M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄)) →L[𝕜] (M₃ →L[𝕜] M₄), from\n    continuous_linear_map.snd 𝕜 (M₁ →L[𝕜] M₂) (M₃ →L[𝕜] M₄),\nΦ₁' ∘L Φ₁ ∘L Ψ₁ + Φ₂' ∘L Φ₂ ∘L Ψ₂)\n(λ p : (M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄), p.1.prod_map p.2)\n(begin\n  apply funext,\n  rintros ⟨φ, ψ⟩,\n  apply continuous_linear_map.ext (λ x, _),\n  simp only [add_apply, coe_comp', coe_fst', function.comp_app,\n             compL_apply, flip_apply, coe_snd', inl_apply, inr_apply, prod.mk_add_mk, add_zero,\n             zero_add, coe_prod_map', prod_map, prod.mk.inj_iff, eq_self_iff_true, and_self],\n  refl\nend)\n\nvariables {M₁ M₂ M₃ M₄}\n\n@[simp] lemma prod_mapL_apply (p : (M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄)) :\n  continuous_linear_map.prod_mapL 𝕜 M₁ M₂ M₃ M₄ p = p.1.prod_map p.2 :=\nrfl\n\nvariables {X : Type*} [topological_space X]\n\nlemma _root_.continuous.prod_mapL {f : X → M₁ →L[𝕜] M₂} {g : X → M₃ →L[𝕜] M₄}\n  (hf : continuous f) (hg : continuous g) : continuous (λ x, (f x).prod_map (g x)) :=\n(prod_mapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp (hf.prod_mk hg)\n\nlemma _root_.continuous.prod_map_equivL {f : X → M₁ ≃L[𝕜] M₂} {g : X → M₃ ≃L[𝕜] M₄}\n  (hf : continuous (λ x, (f x : M₁ →L[𝕜] M₂))) (hg : continuous (λ x, (g x : M₃ →L[𝕜] M₄))) :\n  continuous (λ x, ((f x).prod (g x) : M₁ × M₃ →L[𝕜] M₂ × M₄)) :=\n(prod_mapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp (hf.prod_mk hg)\n\nlemma _root_.continuous_on.prod_mapL {f : X → M₁ →L[𝕜] M₂} {g : X → M₃ →L[𝕜] M₄} {s : set X}\n  (hf : continuous_on f s) (hg : continuous_on g s) :\n  continuous_on (λ x, (f x).prod_map (g x)) s :=\n((prod_mapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp_continuous_on (hf.prod hg) : _)\n\nlemma _root_.continuous_on.prod_map_equivL {f : X → M₁ ≃L[𝕜] M₂} {g : X → M₃ ≃L[𝕜] M₄} {s : set X}\n  (hf : continuous_on (λ x, (f x : M₁ →L[𝕜] M₂)) s)\n  (hg : continuous_on (λ x, (g x : M₃ →L[𝕜] M₄)) s) :\n  continuous_on (λ x, ((f x).prod (g x) : M₁ × M₃ →L[𝕜] M₂ × M₄)) s :=\n(prod_mapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp_continuous_on (hf.prod hg)\n\nvariables {𝕜 E Fₗ Gₗ}\n\nsection multiplication_linear\nvariables (𝕜) (𝕜' : Type*) [normed_ring 𝕜'] [normed_algebra 𝕜 𝕜']\n\n/-- Left multiplication in a normed algebra as a linear isometry to the space of\ncontinuous linear maps. -/\ndef lmulₗᵢ : 𝕜' →ₗᵢ[𝕜] 𝕜' →L[𝕜] 𝕜' :=\n{ to_linear_map := (algebra.lmul 𝕜 𝕜').to_linear_map.mk_continuous₂ 1 $\n    λ x y, by simpa using norm_mul_le x y,\n  norm_map' := λ x, le_antisymm\n    (op_norm_le_bound _ (norm_nonneg x) (norm_mul_le x))\n    (by { convert ratio_le_op_norm _ (1 : 𝕜'), simp [normed_algebra.norm_one 𝕜 𝕜'],\n          apply_instance }) }\n\n/-- Left multiplication in a normed algebra as a continuous bilinear map. -/\ndef lmul : 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' :=\n(lmulₗᵢ 𝕜 𝕜').to_continuous_linear_map\n\n@[simp] lemma lmul_apply (x y : 𝕜') : lmul 𝕜 𝕜' x y = x * y := rfl\n\n@[simp] lemma coe_lmulₗᵢ : ⇑(lmulₗᵢ 𝕜 𝕜') = lmul 𝕜 𝕜' := rfl\n\n@[simp] lemma op_norm_lmul_apply (x : 𝕜') : ∥lmul 𝕜 𝕜' x∥ = ∥x∥ :=\n(lmulₗᵢ 𝕜 𝕜').norm_map x\n\n/-- Right-multiplication in a normed algebra, considered as a continuous linear map. -/\ndef lmul_right : 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' := (lmul 𝕜 𝕜').flip\n\n@[simp] lemma lmul_right_apply (x y : 𝕜') : lmul_right 𝕜 𝕜' x y = y * x := rfl\n\n@[simp] lemma op_norm_lmul_right_apply (x : 𝕜') : ∥lmul_right 𝕜 𝕜' x∥ = ∥x∥ :=\nle_antisymm\n  (op_norm_le_bound _ (norm_nonneg x) (λ y, (norm_mul_le y x).trans_eq (mul_comm _ _)))\n  (by { convert ratio_le_op_norm _ (1 : 𝕜'), simp [normed_algebra.norm_one 𝕜 𝕜'],\n        apply_instance })\n\n/-- Right-multiplication in a normed algebra, considered as a linear isometry to the space of\ncontinuous linear maps. -/\ndef lmul_rightₗᵢ : 𝕜' →ₗᵢ[𝕜] 𝕜' →L[𝕜] 𝕜' :=\n{ to_linear_map := lmul_right 𝕜 𝕜',\n  norm_map' := op_norm_lmul_right_apply 𝕜 𝕜' }\n\n@[simp] lemma coe_lmul_rightₗᵢ : ⇑(lmul_rightₗᵢ 𝕜 𝕜') = lmul_right 𝕜 𝕜' := rfl\n\n/-- Simultaneous left- and right-multiplication in a normed algebra, considered as a continuous\ntrilinear map. -/\ndef lmul_left_right : 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' :=\n((compL 𝕜 𝕜' 𝕜' 𝕜').comp (lmul_right 𝕜 𝕜')).flip.comp (lmul 𝕜 𝕜')\n\n@[simp] lemma lmul_left_right_apply (x y z : 𝕜') :\n  lmul_left_right 𝕜 𝕜' x y z = x * z * y := rfl\n\nlemma op_norm_lmul_left_right_apply_apply_le (x y : 𝕜') :\n  ∥lmul_left_right 𝕜 𝕜' x y∥ ≤ ∥x∥ * ∥y∥ :=\n(op_norm_comp_le _ _).trans_eq $ by simp [mul_comm]\n\nlemma op_norm_lmul_left_right_apply_le (x : 𝕜') :\n  ∥lmul_left_right 𝕜 𝕜' x∥ ≤ ∥x∥ :=\nop_norm_le_bound _ (norm_nonneg x) (op_norm_lmul_left_right_apply_apply_le 𝕜 𝕜' x)\n\nlemma op_norm_lmul_left_right_le :\n  ∥lmul_left_right 𝕜 𝕜'∥ ≤ 1 :=\nop_norm_le_bound _ zero_le_one (λ x, (one_mul ∥x∥).symm ▸ op_norm_lmul_left_right_apply_le 𝕜 𝕜' x)\n\nend multiplication_linear\n\nsection smul_linear\n\nvariables (𝕜) (𝕜' : Type*) [normed_field 𝕜'] [normed_algebra 𝕜 𝕜']\n  [normed_space 𝕜' E] [is_scalar_tower 𝕜 𝕜' E]\n\n/-- Scalar multiplication as a continuous bilinear map. -/\ndef lsmul : 𝕜' →L[𝕜] E →L[𝕜] E :=\n((algebra.lsmul 𝕜 E).to_linear_map : 𝕜' →ₗ[𝕜] E →ₗ[𝕜] E).mk_continuous₂ 1 $\n  λ c x, by simpa only [one_mul] using (norm_smul c x).le\n\n@[simp] lemma lsmul_apply (c : 𝕜') (x : E) : lsmul 𝕜 𝕜' c x = c • x := rfl\n\nvariables {𝕜'}\n\nlemma norm_to_span_singleton (x : E) : ∥to_span_singleton 𝕜 x∥ = ∥x∥ :=\nbegin\n  refine op_norm_eq_of_bounds (norm_nonneg _) (λ x, _) (λ N hN_nonneg h, _),\n  { rw [to_span_singleton_apply, norm_smul, mul_comm], },\n  { specialize h 1,\n    rw [to_span_singleton_apply, norm_smul, mul_comm] at h,\n    exact (mul_le_mul_right (by simp)).mp h, },\nend\n\nend smul_linear\n\nsection restrict_scalars\n\nvariables {𝕜' : Type*} [nondiscrete_normed_field 𝕜'] [normed_algebra 𝕜' 𝕜]\nvariables [normed_space 𝕜' E] [is_scalar_tower 𝕜' 𝕜 E]\nvariables [normed_space 𝕜' Fₗ] [is_scalar_tower 𝕜' 𝕜 Fₗ]\n\n@[simp] lemma norm_restrict_scalars (f : E →L[𝕜] Fₗ) : ∥f.restrict_scalars 𝕜'∥ = ∥f∥ :=\nle_antisymm (op_norm_le_bound _ (norm_nonneg _) $ λ x, f.le_op_norm x)\n  (op_norm_le_bound _ (norm_nonneg _) $ λ x, f.le_op_norm x)\n\nvariables (𝕜 E Fₗ 𝕜') (𝕜'' : Type*) [ring 𝕜''] [module 𝕜'' Fₗ]\n  [has_continuous_const_smul 𝕜'' Fₗ] [smul_comm_class 𝕜 𝕜'' Fₗ] [smul_comm_class 𝕜' 𝕜'' Fₗ]\n\n/-- `continuous_linear_map.restrict_scalars` as a `linear_isometry`. -/\ndef restrict_scalars_isometry : (E →L[𝕜] Fₗ) →ₗᵢ[𝕜''] (E →L[𝕜'] Fₗ) :=\n⟨restrict_scalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'', norm_restrict_scalars⟩\n\nvariables {𝕜 E Fₗ 𝕜' 𝕜''}\n\n@[simp] lemma coe_restrict_scalars_isometry :\n  ⇑(restrict_scalars_isometry 𝕜 E Fₗ 𝕜' 𝕜'') = restrict_scalars 𝕜' :=\nrfl\n\n@[simp] lemma restrict_scalars_isometry_to_linear_map :\n  (restrict_scalars_isometry 𝕜 E Fₗ 𝕜' 𝕜'').to_linear_map = restrict_scalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'' :=\nrfl\n\nvariables (𝕜 E Fₗ 𝕜' 𝕜'')\n\n/-- `continuous_linear_map.restrict_scalars` as a `continuous_linear_map`. -/\ndef restrict_scalarsL : (E →L[𝕜] Fₗ) →L[𝕜''] (E →L[𝕜'] Fₗ) :=\n(restrict_scalars_isometry 𝕜 E Fₗ 𝕜' 𝕜'').to_continuous_linear_map\n\nvariables {𝕜 E Fₗ 𝕜' 𝕜''}\n\n@[simp] lemma coe_restrict_scalarsL :\n  (restrict_scalarsL 𝕜 E Fₗ 𝕜' 𝕜'' : (E →L[𝕜] Fₗ) →ₗ[𝕜''] (E →L[𝕜'] Fₗ)) =\n    restrict_scalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'' :=\nrfl\n\n@[simp] \n\nend restrict_scalars\n\nend continuous_linear_map\n\nnamespace submodule\n\nlemma norm_subtypeL_le (K : submodule 𝕜 E) : ∥K.subtypeL∥ ≤ 1 :=\nK.subtypeₗᵢ.norm_to_continuous_linear_map_le\n\nend submodule\n\nsection has_sum\n\n-- Results in this section hold for continuous additive monoid homomorphisms or equivalences but we\n-- don't have bundled continuous additive homomorphisms.\n\nvariables {ι R R₂ M M₂ : Type*} [semiring R] [semiring R₂] [add_comm_monoid M] [module R M]\n  [add_comm_monoid M₂] [module R₂ M₂] [topological_space M] [topological_space M₂]\n  {σ : R →+* R₂} {σ' : R₂ →+* R} [ring_hom_inv_pair σ σ'] [ring_hom_inv_pair σ' σ]\n\n/-- Applying a continuous linear map commutes with taking an (infinite) sum. -/\nprotected lemma continuous_linear_map.has_sum {f : ι → M} (φ : M →SL[σ] M₂) {x : M}\n  (hf : has_sum f x) :\n  has_sum (λ (b:ι), φ (f b)) (φ x) :=\nby simpa only using hf.map φ.to_linear_map.to_add_monoid_hom φ.continuous\n\nalias continuous_linear_map.has_sum ← has_sum.mapL\n\nprotected lemma continuous_linear_map.summable {f : ι → M} (φ : M →SL[σ] M₂) (hf : summable f) :\n  summable (λ b:ι, φ (f b)) :=\n(hf.has_sum.mapL φ).summable\n\nalias continuous_linear_map.summable ← summable.mapL\n\nprotected lemma continuous_linear_map.map_tsum [t2_space M₂] {f : ι → M}\n  (φ : M →SL[σ] M₂) (hf : summable f) : φ (∑' z, f z) = ∑' z, φ (f z) :=\n(hf.has_sum.mapL φ).tsum_eq.symm\n\ninclude σ'\n/-- Applying a continuous linear map commutes with taking an (infinite) sum. -/\nprotected lemma continuous_linear_equiv.has_sum {f : ι → M} (e : M ≃SL[σ] M₂) {y : M₂} :\n  has_sum (λ (b:ι), e (f b)) y ↔ has_sum f (e.symm y) :=\n⟨λ h, by simpa only [e.symm.coe_coe, e.symm_apply_apply] using h.mapL (e.symm : M₂ →SL[σ'] M),\n  λ h, by simpa only [e.coe_coe, e.apply_symm_apply] using (e : M →SL[σ] M₂).has_sum h⟩\n\n\nprotected lemma continuous_linear_equiv.summable {f : ι → M} (e : M ≃SL[σ] M₂) :\n  summable (λ b:ι, e (f b)) ↔ summable f :=\n⟨λ hf, (e.has_sum.1 hf.has_sum).summable, (e : M →SL[σ] M₂).summable⟩\n\n\nlemma continuous_linear_equiv.tsum_eq_iff [t2_space M] [t2_space M₂] {f : ι → M}\n  (e : M ≃SL[σ] M₂) {y : M₂} : ∑' z, e (f z) = y ↔ ∑' z, f z = e.symm y :=\nbegin\n  by_cases hf : summable f,\n  { exact ⟨λ h, (e.has_sum.mp ((e.summable.mpr hf).has_sum_iff.mpr h)).tsum_eq,\n      λ h, (e.has_sum.mpr (hf.has_sum_iff.mpr h)).tsum_eq⟩ },\n  { have hf' : ¬summable (λ z, e (f z)) := λ h, hf (e.summable.mp h),\n    rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hf'],\n    exact ⟨by { rintro rfl, simp }, λ H, by simpa using (congr_arg (λ z, e z) H)⟩ }\nend\n\nprotected lemma continuous_linear_equiv.map_tsum [t2_space M] [t2_space M₂] {f : ι → M}\n  (e : M ≃SL[σ] M₂) : e (∑' z, f z) = ∑' z, e (f z) :=\nby { refine symm (e.tsum_eq_iff.mpr _), rw e.symm_apply_apply _ }\n\nend has_sum\n\nnamespace continuous_linear_equiv\n\nsection\n\nvariables {σ₂₁ : 𝕜₂ →+* 𝕜} [ring_hom_inv_pair σ₁₂ σ₂₁] [ring_hom_inv_pair σ₂₁ σ₁₂]\n  [ring_hom_isometric σ₁₂]\nvariables (e : E ≃SL[σ₁₂] F)\n\ninclude σ₂₁\nprotected lemma lipschitz : lipschitz_with (∥(e : E →SL[σ₁₂] F)∥₊) e :=\n(e : E →SL[σ₁₂] F).lipschitz\n\ntheorem is_O_comp {α : Type*} (f : α → E) (l : filter α) :\n  asymptotics.is_O (λ x', e (f x')) f l :=\n(e : E →SL[σ₁₂] F).is_O_comp f l\n\ntheorem is_O_sub (l : filter E) (x : E) :\n  asymptotics.is_O (λ x', e (x' - x)) (λ x', x' - x) l :=\n(e : E →SL[σ₁₂] F).is_O_sub l x\n\nend\n\nvariables {σ₂₁ : 𝕜₂ →+* 𝕜} [ring_hom_inv_pair σ₁₂ σ₂₁] [ring_hom_inv_pair σ₂₁ σ₁₂]\n\ninclude σ₂₁\nlemma homothety_inverse (a : ℝ) (ha : 0 < a) (f : E ≃ₛₗ[σ₁₂] F) :\n  (∀ (x : E), ∥f x∥ = a * ∥x∥) → (∀ (y : F), ∥f.symm y∥ = a⁻¹ * ∥y∥) :=\nbegin\n  intros hf y,\n  calc ∥(f.symm) y∥ = a⁻¹ * (a * ∥ (f.symm) y∥) : _\n  ... =  a⁻¹ * ∥f ((f.symm) y)∥ : by rw hf\n  ... = a⁻¹ * ∥y∥ : by simp,\n  rw [← mul_assoc, inv_mul_cancel (ne_of_lt ha).symm, one_mul],\nend\n\n/-- A linear equivalence which is a homothety is a continuous linear equivalence. -/\ndef of_homothety (f : E ≃ₛₗ[σ₁₂] F) (a : ℝ) (ha : 0 < a) (hf : ∀x, ∥f x∥ = a * ∥x∥) :\n  E ≃SL[σ₁₂] F :=\n{ to_linear_equiv := f,\n  continuous_to_fun := f.to_linear_map.continuous_of_bound a (λ x, le_of_eq (hf x)),\n  continuous_inv_fun := f.symm.to_linear_map.continuous_of_bound a⁻¹\n    (λ x, le_of_eq (homothety_inverse a ha f hf x)) }\n\nvariables [ring_hom_isometric σ₂₁] (e : E ≃SL[σ₁₂] F)\n\ntheorem is_O_comp_rev {α : Type*} (f : α → E) (l : filter α) :\n  asymptotics.is_O f (λ x', e (f x')) l :=\n(e.symm.is_O_comp _ l).congr_left $ λ _, e.symm_apply_apply _\n\ntheorem is_O_sub_rev (l : filter E) (x : E) :\n  asymptotics.is_O (λ x', x' - x) (λ x', e (x' - x)) l :=\ne.is_O_comp_rev _ _\n\nomit σ₂₁\n\nvariable (𝕜)\n\nlemma to_span_nonzero_singleton_homothety (x : E) (h : x ≠ 0) (c : 𝕜) :\n  ∥linear_equiv.to_span_nonzero_singleton 𝕜 E x h c∥ = ∥x∥ * ∥c∥ :=\ncontinuous_linear_map.to_span_singleton_homothety _ _ _\n\nend continuous_linear_equiv\n\nvariables {σ₂₁ : 𝕜₂ →+* 𝕜} [ring_hom_inv_pair σ₁₂ σ₂₁] [ring_hom_inv_pair σ₂₁ σ₁₂]\ninclude σ₂₁\n\n/-- Construct a continuous linear equivalence from a linear equivalence together with\nbounds in both directions. -/\ndef linear_equiv.to_continuous_linear_equiv_of_bounds (e : E ≃ₛₗ[σ₁₂] F) (C_to C_inv : ℝ)\n  (h_to : ∀ x, ∥e x∥ ≤ C_to * ∥x∥) (h_inv : ∀ x : F, ∥e.symm x∥ ≤ C_inv * ∥x∥) : E ≃SL[σ₁₂] F :=\n{ to_linear_equiv := e,\n  continuous_to_fun := e.to_linear_map.continuous_of_bound C_to h_to,\n  continuous_inv_fun := e.symm.to_linear_map.continuous_of_bound C_inv h_inv }\n\nomit σ₂₁\n\nnamespace continuous_linear_map\nvariables {E' F' : Type*} [semi_normed_group E'] [semi_normed_group F']\n\nvariables {𝕜₁' : Type*} {𝕜₂' : Type*} [nondiscrete_normed_field 𝕜₁'] [nondiscrete_normed_field 𝕜₂']\n  [normed_space 𝕜₁' E'] [normed_space 𝕜₂' F']\n  {σ₁' : 𝕜₁' →+* 𝕜} {σ₁₃' : 𝕜₁' →+* 𝕜₃} {σ₂' : 𝕜₂' →+* 𝕜₂} {σ₂₃' : 𝕜₂' →+* 𝕜₃}\n  [ring_hom_comp_triple σ₁' σ₁₃ σ₁₃'] [ring_hom_comp_triple σ₂' σ₂₃ σ₂₃']\n  [ring_hom_isometric σ₂₃] [ring_hom_isometric σ₁₃'] [ring_hom_isometric σ₂₃']\n\n/--\nCompose a bilinear map `E →SL[σ₁₃] F →SL[σ₂₃] G` with two linear maps\n`E' →SL[σ₁'] E` and `F' →SL[σ₂'] F`.  -/\ndef bilinear_comp (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (gE : E' →SL[σ₁'] E) (gF : F' →SL[σ₂'] F) :\n  E' →SL[σ₁₃'] F' →SL[σ₂₃'] G :=\n((f.comp gE).flip.comp gF).flip\n\ninclude σ₁₃' σ₂₃'\n@[simp] lemma bilinear_comp_apply (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (gE : E' →SL[σ₁'] E)\n  (gF : F' →SL[σ₂'] F) (x : E') (y : F') : f.bilinear_comp gE gF x y = f (gE x) (gF y) :=\nrfl\n\nomit σ₁₃' σ₂₃'\n\nvariables [ring_hom_isometric σ₁₃] [ring_hom_isometric σ₁'] [ring_hom_isometric σ₂']\n\n/-- Derivative of a continuous bilinear map `f : E →L[𝕜] F →L[𝕜] G` interpreted as a map `E × F → G`\nat point `p : E × F` evaluated at `q : E × F`, as a continuous bilinear map. -/\ndef deriv₂ (f : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : (E × Fₗ) →L[𝕜] (E × Fₗ) →L[𝕜] Gₗ :=\nf.bilinear_comp (fst _ _ _) (snd _ _ _) + f.flip.bilinear_comp (snd _ _ _) (fst _ _ _)\n\n@[simp] lemma coe_deriv₂ (f : E →L[𝕜] Fₗ →L[𝕜] Gₗ) (p : E × Fₗ) :\n  ⇑(f.deriv₂ p) = λ q : E × Fₗ, f p.1 q.2 + f q.1 p.2 := rfl\n\nlemma map_add₂ (f : E →L[𝕜] Fₗ →L[𝕜] Gₗ) (x x' : E) (y y' : Fₗ) :\n  f (x + x') (y + y') = f x y + f.deriv₂ (x, y) (x', y') + f x' y' :=\nby simp only [map_add, add_apply, coe_deriv₂, add_assoc]\n\nend continuous_linear_map\n\nend semi_normed\n\nsection normed\n\nvariables [normed_group E] [normed_group F] [normed_group G] [normed_group Fₗ]\n\nopen metric continuous_linear_map\n\nsection normed_field\n\nvariables [normed_field 𝕜] [normed_space 𝕜 E] [normed_space 𝕜 F] (f : E →ₗ[𝕜] F)\n\nlemma linear_map.continuous_iff_is_closed_ker {f : E →ₗ[𝕜] 𝕜} :\n  continuous f ↔ is_closed (f.ker : set E) :=\nbegin\n  -- the continuity of f obviously implies that its kernel is closed\n  refine ⟨λh, (t1_space.t1 (0 : 𝕜)).preimage h, λh, _⟩,\n  -- for the other direction, we assume that the kernel is closed\n  by_cases hf : ∀x, x ∈ f.ker,\n  { -- if `f = 0`, its continuity is obvious\n    have : (f : E → 𝕜) = (λx, 0), by { ext x, simpa using hf x },\n    rw this,\n    exact continuous_const },\n  { /- if `f` is not zero, we use an element `x₀ ∉ ker f` such that `∥x₀∥ ≤ 2 ∥x₀ - y∥` for all\n    `y ∈ ker f`, given by Riesz's lemma, and prove that `2 ∥f x₀∥ / ∥x₀∥` gives a bound on the\n    operator norm of `f`. For this, start from an arbitrary `x` and note that\n    `y = x₀ - (f x₀ / f x) x` belongs to the kernel of `f`. Applying the above inequality to `x₀`\n    and `y` readily gives the conclusion. -/\n    push_neg at hf,\n    let r : ℝ := (2 : ℝ)⁻¹,\n    have : 0 ≤ r, by norm_num [r],\n    have : r < 1, by norm_num [r],\n    obtain ⟨x₀, x₀ker, h₀⟩ : ∃ (x₀ : E), x₀ ∉ f.ker ∧ ∀ y ∈ linear_map.ker f,\n      r * ∥x₀∥ ≤ ∥x₀ - y∥, from riesz_lemma h hf this,\n    have : x₀ ≠ 0,\n    { assume h,\n      have : x₀ ∈ f.ker, by { rw h, exact (linear_map.ker f).zero_mem },\n      exact x₀ker this },\n    have rx₀_ne_zero : r * ∥x₀∥ ≠ 0, by { simp [norm_eq_zero, this], },\n    have : ∀x, ∥f x∥ ≤ (((r * ∥x₀∥)⁻¹) * ∥f x₀∥) * ∥x∥,\n    { assume x,\n      by_cases hx : f x = 0,\n      { rw [hx, norm_zero],\n        apply_rules [mul_nonneg, norm_nonneg, inv_nonneg.2] },\n      { let y := x₀ - (f x₀ * (f x)⁻¹ ) • x,\n        have fy_zero : f y = 0, by calc\n          f y = f x₀ - (f x₀ * (f x)⁻¹ ) * f x : by simp [y]\n          ... = 0 :\n            by { rw [mul_assoc, inv_mul_cancel hx, mul_one, sub_eq_zero_of_eq], refl },\n        have A : r * ∥x₀∥ ≤ ∥f x₀∥ * ∥f x∥⁻¹ * ∥x∥, from calc\n          r * ∥x₀∥ ≤ ∥x₀ - y∥ : h₀ _ (linear_map.mem_ker.2 fy_zero)\n          ... = ∥(f x₀ * (f x)⁻¹ ) • x∥ : by { dsimp [y], congr, abel }\n          ... = ∥f x₀∥ * ∥f x∥⁻¹ * ∥x∥ :\n            by rw [norm_smul, norm_mul, norm_inv],\n        calc\n          ∥f x∥ = (r * ∥x₀∥)⁻¹ * (r * ∥x₀∥) * ∥f x∥ : by rwa [inv_mul_cancel, one_mul]\n          ... ≤ (r * ∥x₀∥)⁻¹ * (∥f x₀∥ * ∥f x∥⁻¹ * ∥x∥) * ∥f x∥ : begin\n            apply mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left A _) (norm_nonneg _),\n            exact inv_nonneg.2 (mul_nonneg (by norm_num) (norm_nonneg _))\n          end\n          ... = (∥f x∥ ⁻¹ * ∥f x∥) * (((r * ∥x₀∥)⁻¹) * ∥f x₀∥) * ∥x∥ : by ring\n          ... = (((r * ∥x₀∥)⁻¹) * ∥f x₀∥) * ∥x∥ :\n            by { rw [inv_mul_cancel, one_mul], simp [norm_eq_zero, hx] } } },\n    exact linear_map.continuous_of_bound f _ this }\nend\n\nend normed_field\n\nsection\nvariables [nondiscrete_normed_field 𝕜] [nondiscrete_normed_field 𝕜₂] [nondiscrete_normed_field 𝕜₃]\n  [normed_space 𝕜 E] [normed_space 𝕜₂ F] [normed_space 𝕜₃ G] [normed_space 𝕜 Fₗ] (c : 𝕜)\n  {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃}\n  [ring_hom_isometric σ₁₂] (f g : E →SL[σ₁₂] F) (x y z : E)\n\nlemma linear_map.bound_of_shell (f : E →ₛₗ[σ₁₂] F) {ε C : ℝ} (ε_pos : 0 < ε) {c : 𝕜}\n  (hc : 1 < ∥c∥) (hf : ∀ x, ε / ∥c∥ ≤ ∥x∥ → ∥x∥ < ε → ∥f x∥ ≤ C * ∥x∥) (x : E) :\n  ∥f x∥ ≤ C * ∥x∥ :=\nbegin\n  by_cases hx : x = 0, { simp [hx] },\n  exact linear_map.bound_of_shell_semi_normed f ε_pos hc hf (ne_of_lt (norm_pos_iff.2 hx)).symm\nend\n\n/--\n`linear_map.bound_of_ball_bound'` is a version of this lemma over a field satisfying `is_R_or_C`\nthat produces a concrete bound.\n-/\nlemma linear_map.bound_of_ball_bound {r : ℝ} (r_pos : 0 < r) (c : ℝ) (f : E →ₗ[𝕜] Fₗ)\n  (h : ∀ z ∈ metric.ball (0 : E) r, ∥f z∥ ≤ c) :\n  ∃ C, ∀ (z : E), ∥f z∥ ≤ C * ∥z∥ :=\nbegin\n  cases @nondiscrete_normed_field.non_trivial 𝕜 _ with k hk,\n  use c * (∥k∥ / r),\n  intro z,\n  refine linear_map.bound_of_shell _ r_pos hk (λ x hko hxo, _) _,\n  calc ∥f x∥ ≤ c : h _ (mem_ball_zero_iff.mpr hxo)\n         ... ≤ c * ((∥x∥ * ∥k∥) / r) : le_mul_of_one_le_right _ _\n         ... = _ : by ring,\n  { exact le_trans (norm_nonneg _) (h 0 (by simp [r_pos])) },\n  { rw [div_le_iff (zero_lt_one.trans hk)] at hko,\n    exact (one_le_div r_pos).mpr hko }\nend\n\nnamespace continuous_linear_map\n\nsection op_norm\nopen set real\n\n/-- An operator is zero iff its norm vanishes. -/\ntheorem op_norm_zero_iff : ∥f∥ = 0 ↔ f = 0 :=\niff.intro\n  (λ hn, continuous_linear_map.ext (λ x, norm_le_zero_iff.1\n    (calc _ ≤ ∥f∥ * ∥x∥ : le_op_norm _ _\n     ...     = _ : by rw [hn, zero_mul])))\n  (λ hf, le_antisymm (cInf_le bounds_bdd_below\n    ⟨le_rfl, λ _, le_of_eq (by { rw [zero_mul, hf], exact norm_zero })⟩)\n    (op_norm_nonneg _))\n\n/-- If a normed space is non-trivial, then the norm of the identity equals `1`. -/\n@[simp] lemma norm_id [nontrivial E] : ∥id 𝕜 E∥ = 1 :=\nbegin\n  refine norm_id_of_nontrivial_seminorm _,\n  obtain ⟨x, hx⟩ := exists_ne (0 : E),\n  exact ⟨x, ne_of_gt (norm_pos_iff.2 hx)⟩,\nend\n\ninstance norm_one_class [nontrivial E] : norm_one_class (E →L[𝕜] E) := ⟨norm_id⟩\n\n/-- Continuous linear maps themselves form a normed space with respect to\n    the operator norm. -/\ninstance to_normed_group : normed_group (E →SL[σ₁₂] F) :=\nnormed_group.of_core _ ⟨op_norm_zero_iff, op_norm_add_le, op_norm_neg⟩\n\n/-- Continuous linear maps form a normed ring with respect to the operator norm. -/\ninstance to_normed_ring : normed_ring (E →L[𝕜] E) :=\n{ norm_mul := op_norm_comp_le,\n  .. continuous_linear_map.to_normed_group }\n\n/-- For a nonzero normed space `E`, continuous linear endomorphisms form a normed algebra with\nrespect to the operator norm. -/\ninstance to_normed_algebra [nontrivial E] : normed_algebra 𝕜 (E →L[𝕜] E) :=\n{ norm_algebra_map_eq := λ c, show ∥c • id 𝕜 E∥ = ∥c∥,\n    by {rw [norm_smul, norm_id], simp},\n  .. continuous_linear_map.algebra }\n\nvariable {f}\n\nlemma homothety_norm [nontrivial E] (f : E →SL[σ₁₂] F) {a : ℝ} (hf : ∀x, ∥f x∥ = a * ∥x∥) :\n  ∥f∥ = a :=\nbegin\n  obtain ⟨x, hx⟩ : ∃ (x : E), x ≠ 0 := exists_ne 0,\n  rw ← norm_pos_iff at hx,\n  have ha : 0 ≤ a, by simpa only [hf, hx, zero_le_mul_right] using norm_nonneg (f x),\n  apply le_antisymm (f.op_norm_le_bound ha (λ y, le_of_eq (hf y))),\n  simpa only [hf, hx, mul_le_mul_right] using f.le_op_norm x,\nend\n\nlemma to_span_singleton_norm (x : E) : ∥to_span_singleton 𝕜 x∥ = ∥x∥ :=\nhomothety_norm _ (to_span_singleton_homothety 𝕜 x)\n\nvariable (f)\n\ntheorem uniform_embedding_of_bound {K : ℝ≥0} (hf : ∀ x, ∥x∥ ≤ K * ∥f x∥) :\n  uniform_embedding f :=\n(f.to_linear_map.antilipschitz_of_bound hf).uniform_embedding f.uniform_continuous\n\n/-- If a continuous linear map is a uniform embedding, then it is expands the distances\nby a positive factor.-/\ntheorem antilipschitz_of_uniform_embedding (f : E →L[𝕜] Fₗ) (hf : uniform_embedding f) :\n  ∃ K, antilipschitz_with K f :=\nbegin\n  obtain ⟨ε, εpos, hε⟩ : ∃ (ε : ℝ) (H : ε > 0), ∀ {x y : E}, dist (f x) (f y) < ε → dist x y < 1,\n    from (uniform_embedding_iff.1 hf).2.2 1 zero_lt_one,\n  let δ := ε/2,\n  have δ_pos : δ > 0 := half_pos εpos,\n  have H : ∀{x}, ∥f x∥ ≤ δ → ∥x∥ ≤ 1,\n  { assume x hx,\n    have : dist x 0 ≤ 1,\n    { refine (hε _).le,\n      rw [f.map_zero, dist_zero_right],\n      exact hx.trans_lt (half_lt_self εpos) },\n    simpa using this },\n  rcases normed_field.exists_one_lt_norm 𝕜 with ⟨c, hc⟩,\n  refine ⟨⟨δ⁻¹, _⟩ * nnnorm c, f.to_linear_map.antilipschitz_of_bound $ λx, _⟩,\n  exact inv_nonneg.2 (le_of_lt δ_pos),\n  by_cases hx : f x = 0,\n  { have : f x = f 0, by { simp [hx] },\n    have : x = 0 := (uniform_embedding_iff.1 hf).1 this,\n    simp [this] },\n  { rcases rescale_to_shell hc δ_pos hx with ⟨d, hd, dxlt, ledx, dinv⟩,\n    rw [← f.map_smul d] at dxlt,\n    have : ∥d • x∥ ≤ 1 := H dxlt.le,\n    calc ∥x∥ = ∥d∥⁻¹ * ∥d • x∥ :\n      by rwa [← norm_inv, ← norm_smul, ← mul_smul, inv_mul_cancel, one_smul]\n    ... ≤ ∥d∥⁻¹ * 1 :\n      mul_le_mul_of_nonneg_left this (inv_nonneg.2 (norm_nonneg _))\n    ... ≤ δ⁻¹ * ∥c∥ * ∥f x∥ :\n      by rwa [mul_one] }\nend\n\nsection completeness\n\nopen_locale topological_space\nopen filter\n\nvariables {E' : Type*} [semi_normed_group E'] [normed_space 𝕜 E']\n\n/-- Construct a bundled continuous (semi)linear map from a map `f : E → F` and a proof of the fact\nthat it belongs to the closure of the image of a bounded set `s : set (E →SL[σ₁₂] F)` under coercion\nto function. Coercion to function of the result is definitionally equal to `f`. -/\n@[simps apply { fully_applied := ff }]\ndef of_mem_closure_image_coe_bounded (f : E' → F) {s : set (E' →SL[σ₁₂] F)} (hs : bounded s)\n  (hf : f ∈ closure ((λ g x, g x : (E' →SL[σ₁₂] F) → E' → F) '' s)) :\n  E' →SL[σ₁₂] F :=\nbegin\n  -- `f` is a linear map due to `linear_map_of_mem_closure_range_coe`\n  refine (linear_map_of_mem_closure_range_coe f _).mk_continuous_of_exists_bound _,\n  { refine closure_mono (image_subset_iff.2 $ λ g hg, _) hf, exact ⟨g, rfl⟩ },\n  { -- We need to show that `f` has bounded norm. Choose `C` such that `∥g∥ ≤ C` for all `g ∈ s`.\n    rcases bounded_iff_forall_norm_le.1 hs with ⟨C, hC⟩,\n    -- Then `∥g x∥ ≤ C * ∥x∥` for all `g ∈ s`, `x : E`, hence `∥f x∥ ≤ C * ∥x∥` for all `x`.\n    have : ∀ x, is_closed {g : E' → F | ∥g x∥ ≤ C * ∥x∥},\n      from λ x, is_closed_Iic.preimage (@continuous_apply E' (λ _, F) _ x).norm,\n    refine ⟨C, λ x, (this x).closure_subset_iff.2 (image_subset_iff.2 $ λ g hg, _) hf⟩,\n    exact g.le_of_op_norm_le (hC _ hg) _ }\nend\n\n/-- Let `f : E → F` be a map, let `g : α → E →SL[σ₁₂] F` be a family of continuous (semi)linear maps\nthat takes values in a bounded set and converges to `f` pointwise along a nontrivial filter. Then\n`f` is a continuous (semi)linear map. -/\n@[simps apply { fully_applied := ff }]\ndef of_tendsto_of_bounded_range {α : Type*} {l : filter α} [l.ne_bot] (f : E' → F)\n  (g : α → E' →SL[σ₁₂] F) (hf : tendsto (λ a x, g a x) l (𝓝 f)) (hg : bounded (set.range g)) :\n  E' →SL[σ₁₂] F :=\nof_mem_closure_image_coe_bounded f hg $ mem_closure_of_tendsto hf $\n  eventually_of_forall $ λ a, mem_image_of_mem _ $ set.mem_range_self _\n\n/-- If a Cauchy sequence of continuous linear map converges to a continuous linear map pointwise,\nthen it converges to the same map in norm. This lemma is used to prove that the space of continuous\nlinear maps is complete provided that the codomain is a complete space. -/\nlemma tendsto_of_tendsto_pointwise_of_cauchy_seq {f : ℕ → E' →SL[σ₁₂] F} {g : E' →SL[σ₁₂] F}\n  (hg : tendsto (λ n x, f n x) at_top (𝓝 g)) (hf : cauchy_seq f) :\n  tendsto f at_top (𝓝 g) :=\nbegin\n  /- Since `f` is a Cauchy sequence, there exists `b → 0` such that `∥f n - f m∥ ≤ b N` for any\n  `m, n ≥ N`. -/\n  rcases cauchy_seq_iff_le_tendsto_0.1 hf with ⟨b, hb₀, hfb, hb_lim⟩,\n  -- Since `b → 0`, it suffices to show that `∥f n x - g x∥ ≤ b n * ∥x∥` for all `n` and `x`.\n  suffices : ∀ n x, ∥f n x - g x∥ ≤ b n * ∥x∥,\n    from tendsto_iff_norm_tendsto_zero.2 (squeeze_zero (λ n, norm_nonneg _)\n      (λ n, op_norm_le_bound _ (hb₀ n) (this n)) hb_lim),\n  intros n x,\n  -- Note that `f m x → g x`, hence `∥f n x - f m x∥ → ∥f n x - g x∥` as `m → ∞`\n  have : tendsto (λ m, ∥f n x - f m x∥) at_top (𝓝 (∥f n x - g x∥)),\n    from (tendsto_const_nhds.sub $ tendsto_pi_nhds.1 hg _).norm,\n  -- Thus it suffices to verify `∥f n x - f m x∥ ≤ b n * ∥x∥` for `m ≥ n`.\n  refine le_of_tendsto this (eventually_at_top.2 ⟨n, λ m hm, _⟩),\n  -- This inequality follows from `∥f n - f m∥ ≤ b n`.\n  exact (f n - f m).le_of_op_norm_le (hfb _ _ _ le_rfl hm) _\nend\n\n/-- If the target space is complete, the space of continuous linear maps with its norm is also\ncomplete. This works also if the source space is seminormed. -/\ninstance [complete_space F] : complete_space (E' →SL[σ₁₂] F) :=\nbegin\n  -- We show that every Cauchy sequence converges.\n  refine metric.complete_of_cauchy_seq_tendsto (λ f hf, _),\n  -- The evaluation at any point `v : E` is Cauchy.\n  have cau : ∀ v, cauchy_seq (λ n, f n v),\n    from λ v, hf.map (lipschitz_apply v).uniform_continuous,\n  -- We assemble the limits points of those Cauchy sequences\n  -- (which exist as `F` is complete)\n  -- into a function which we call `G`.\n  choose G hG using λv, cauchy_seq_tendsto_of_complete (cau v),\n  -- Next, we show that this `G` is a continuous linear map.\n  -- This is done in `continuous_linear_map.of_tendsto_of_bounded_range`.\n  set Glin : E' →SL[σ₁₂] F :=\n    of_tendsto_of_bounded_range _ _ (tendsto_pi_nhds.mpr hG) hf.bounded_range,\n  -- Finally, `f n` converges to `Glin` in norm because of\n  -- `continuous_linear_map.tendsto_of_tendsto_pointwise_of_cauchy_seq`\n  exact ⟨Glin, tendsto_of_tendsto_pointwise_of_cauchy_seq (tendsto_pi_nhds.2 hG) hf⟩\nend\n\nend completeness\n\nsection uniformly_extend\n\nvariables [complete_space F] (e : E →L[𝕜] Fₗ) (h_dense : dense_range e)\n\nsection\nvariables (h_e : uniform_inducing e)\n\n/-- Extension of a continuous linear map `f : E →SL[σ₁₂] F`, with `E` a normed space and `F` a\ncomplete normed space, along a uniform and dense embedding `e : E →L[𝕜] Fₗ`.  -/\ndef extend : Fₗ →SL[σ₁₂] F :=\n/- extension of `f` is continuous -/\nhave cont : _ := (uniform_continuous_uniformly_extend h_e h_dense f.uniform_continuous).continuous,\n/- extension of `f` agrees with `f` on the domain of the embedding `e` -/\nhave eq : _ := uniformly_extend_of_ind h_e h_dense f.uniform_continuous,\n{ to_fun := (h_e.dense_inducing h_dense).extend f,\n  map_add' :=\n  begin\n    refine h_dense.induction_on₂ _ _,\n    { exact is_closed_eq (cont.comp continuous_add)\n        ((cont.comp continuous_fst).add (cont.comp continuous_snd)) },\n    { assume x y, simp only [eq, ← e.map_add], exact f.map_add _ _ },\n  end,\n  map_smul' := λk,\n  begin\n    refine (λ b, h_dense.induction_on b _ _),\n    { exact is_closed_eq (cont.comp (continuous_const_smul _))\n        ((continuous_const_smul _).comp cont) },\n    { assume x, rw ← map_smul, simp only [eq], exact map_smulₛₗ _ _ _ },\n  end,\n  cont := cont }\n\nlemma extend_unique (g : Fₗ →SL[σ₁₂] F) (H : g.comp e = f) : extend f e h_dense h_e = g :=\ncontinuous_linear_map.coe_fn_injective $\n  uniformly_extend_unique h_e h_dense (continuous_linear_map.ext_iff.1 H) g.continuous\n\n@[simp] lemma extend_zero : extend (0 : E →SL[σ₁₂] F) e h_dense h_e = 0 :=\nextend_unique _ _ _ _ _ (zero_comp _)\n\nend\n\nsection\nvariables {N : ℝ≥0} (h_e : ∀x, ∥x∥ ≤ N * ∥e x∥)\n\nlocal notation `ψ` := f.extend e h_dense (uniform_embedding_of_bound _ h_e).to_uniform_inducing\n\n/-- If a dense embedding `e : E →L[𝕜] G` expands the norm by a constant factor `N⁻¹`, then the\nnorm of the extension of `f` along `e` is bounded by `N * ∥f∥`. -/\nlemma op_norm_extend_le : ∥ψ∥ ≤ N * ∥f∥ :=\nbegin\n  have uni : uniform_inducing e := (uniform_embedding_of_bound _ h_e).to_uniform_inducing,\n  have eq : ∀x, ψ (e x) = f x := uniformly_extend_of_ind uni h_dense f.uniform_continuous,\n  by_cases N0 : 0 ≤ N,\n  { refine op_norm_le_bound ψ _ (is_closed_property h_dense (is_closed_le _ _) _),\n    { exact mul_nonneg N0 (norm_nonneg _) },\n    { exact continuous_norm.comp (cont ψ) },\n    { exact continuous_const.mul continuous_norm },\n    { assume x,\n      rw eq,\n      calc ∥f x∥ ≤ ∥f∥ * ∥x∥ : le_op_norm _ _\n        ... ≤ ∥f∥ * (N * ∥e x∥) : mul_le_mul_of_nonneg_left (h_e x) (norm_nonneg _)\n        ... ≤ N * ∥f∥ * ∥e x∥ : by rw [mul_comm ↑N ∥f∥, mul_assoc] } },\n  { have he : ∀ x : E, x = 0,\n    { assume x,\n      have N0 : N ≤ 0 := le_of_lt (lt_of_not_ge N0),\n      rw ← norm_le_zero_iff,\n      exact le_trans (h_e x) (mul_nonpos_of_nonpos_of_nonneg N0 (norm_nonneg _)) },\n    have hf : f = 0, { ext, simp only [he x, zero_apply, map_zero] },\n    have hψ : ψ = 0, { rw hf, apply extend_zero },\n    rw [hψ, hf, norm_zero, norm_zero, mul_zero] }\nend\n\nend\n\nend uniformly_extend\n\nend op_norm\n\nend continuous_linear_map\n\nnamespace linear_isometry\n\n@[simp] lemma norm_to_continuous_linear_map [nontrivial E] (f : E →ₛₗᵢ[σ₁₂] F) :\n  ∥f.to_continuous_linear_map∥ = 1 :=\nf.to_continuous_linear_map.homothety_norm $ by simp\n\nvariables {σ₁₃ : 𝕜 →+* 𝕜₃} [ring_hom_comp_triple σ₁₂ σ₂₃ σ₁₃]\n\ninclude σ₁₃\n/-- Postcomposition of a continuous linear map with a linear isometry preserves\nthe operator norm. -/\nlemma norm_to_continuous_linear_map_comp (f : F →ₛₗᵢ[σ₂₃] G) {g : E →SL[σ₁₂] F} :\n  ∥f.to_continuous_linear_map.comp g∥ = ∥g∥ :=\nop_norm_ext (f.to_continuous_linear_map.comp g) g\n  (λ x, by simp only [norm_map, coe_to_continuous_linear_map, coe_comp'])\nomit σ₁₃\n\nend linear_isometry\n\nend\n\nnamespace continuous_linear_map\n\nvariables [nondiscrete_normed_field 𝕜] [nondiscrete_normed_field 𝕜₂] [nondiscrete_normed_field 𝕜₃]\n  [normed_space 𝕜 E] [normed_space 𝕜₂ F] [normed_space 𝕜₃ G] [normed_space 𝕜 Fₗ] (c : 𝕜)\n  {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃}\n\nvariables {𝕜₂' : Type*} [nondiscrete_normed_field 𝕜₂'] {F' : Type*} [normed_group F']\n  [normed_space 𝕜₂' F'] {σ₂' : 𝕜₂' →+* 𝕜₂} {σ₂'' : 𝕜₂ →+* 𝕜₂'}\n  {σ₂₃' : 𝕜₂' →+* 𝕜₃}\n  [ring_hom_inv_pair σ₂' σ₂''] [ring_hom_inv_pair σ₂'' σ₂']\n  [ring_hom_comp_triple σ₂' σ₂₃ σ₂₃'] [ring_hom_comp_triple σ₂'' σ₂₃' σ₂₃]\n  [ring_hom_isometric σ₂₃]\n  [ring_hom_isometric σ₂'] [ring_hom_isometric σ₂''] [ring_hom_isometric σ₂₃']\n\ninclude σ₂'' σ₂₃'\n/-- Precomposition with a linear isometry preserves the operator norm. -/\nlemma op_norm_comp_linear_isometry_equiv (f : F →SL[σ₂₃] G) (g : F' ≃ₛₗᵢ[σ₂'] F) :\n  ∥f.comp g.to_linear_isometry.to_continuous_linear_map∥ = ∥f∥ :=\nbegin\n  casesI subsingleton_or_nontrivial F',\n  { haveI := g.symm.to_linear_equiv.to_equiv.subsingleton,\n    simp },\n  refine le_antisymm _ _,\n  { convert f.op_norm_comp_le g.to_linear_isometry.to_continuous_linear_map,\n    simp [g.to_linear_isometry.norm_to_continuous_linear_map] },\n  { convert (f.comp g.to_linear_isometry.to_continuous_linear_map).op_norm_comp_le\n      g.symm.to_linear_isometry.to_continuous_linear_map,\n    { ext,\n      simp },\n    haveI := g.symm.surjective.nontrivial,\n    simp [g.symm.to_linear_isometry.norm_to_continuous_linear_map] },\nend\nomit σ₂'' σ₂₃'\n\n/-- The norm of the tensor product of a scalar linear map and of an element of a normed space\nis the product of the norms. -/\n@[simp] lemma norm_smul_right_apply (c : E →L[𝕜] 𝕜) (f : Fₗ) :\n  ∥smul_right c f∥ = ∥c∥ * ∥f∥ :=\nbegin\n  refine le_antisymm _ _,\n  { apply op_norm_le_bound _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) (λx, _),\n    calc\n     ∥(c x) • f∥ = ∥c x∥ * ∥f∥ : norm_smul _ _\n     ... ≤ (∥c∥ * ∥x∥) * ∥f∥ :\n       mul_le_mul_of_nonneg_right (le_op_norm _ _) (norm_nonneg _)\n     ... = ∥c∥ * ∥f∥ * ∥x∥ : by ring },\n  { by_cases h : f = 0,\n    { simp [h] },\n    { have : 0 < ∥f∥ := norm_pos_iff.2 h,\n      rw ← le_div_iff this,\n      apply op_norm_le_bound _ (div_nonneg (norm_nonneg _) (norm_nonneg f)) (λx, _),\n      rw [div_mul_eq_mul_div, le_div_iff this],\n      calc ∥c x∥ * ∥f∥ = ∥c x • f∥ : (norm_smul _ _).symm\n      ... = ∥smul_right c f x∥ : rfl\n      ... ≤ ∥smul_right c f∥ * ∥x∥ : le_op_norm _ _ } },\nend\n\n/-- The non-negative norm of the tensor product of a scalar linear map and of an element of a normed\nspace is the product of the non-negative norms. -/\n@[simp] lemma nnnorm_smul_right_apply (c : E →L[𝕜] 𝕜) (f : Fₗ) :\n  ∥smul_right c f∥₊ = ∥c∥₊ * ∥f∥₊ :=\nnnreal.eq $ c.norm_smul_right_apply f\n\nvariables (𝕜 E Fₗ)\n\n/-- `continuous_linear_map.smul_right` as a continuous trilinear map:\n`smul_rightL (c : E →L[𝕜] 𝕜) (f : F) (x : E) = c x • f`. -/\ndef smul_rightL : (E →L[𝕜] 𝕜) →L[𝕜] Fₗ →L[𝕜] E →L[𝕜] Fₗ :=\nlinear_map.mk_continuous₂\n  { to_fun := smul_rightₗ,\n    map_add' := λ c₁ c₂, by { ext x, simp only [add_smul, coe_smul_rightₗ, add_apply,\n                                               smul_right_apply, linear_map.add_apply] },\n    map_smul' := λ m c, by { ext x, simp only [smul_smul, coe_smul_rightₗ, algebra.id.smul_eq_mul,\n                                               coe_smul', smul_right_apply, linear_map.smul_apply,\n                                               ring_hom.id_apply, pi.smul_apply] } }\n  1 $ λ c x, by simp only [coe_smul_rightₗ, one_mul, norm_smul_right_apply, linear_map.coe_mk]\n\nvariables {𝕜 E Fₗ}\n\n@[simp] lemma norm_smul_rightL_apply (c : E →L[𝕜] 𝕜) (f : Fₗ) :\n  ∥smul_rightL 𝕜 E Fₗ c f∥ = ∥c∥ * ∥f∥ :=\nnorm_smul_right_apply c f\n\n@[simp] lemma norm_smul_rightL (c : E →L[𝕜] 𝕜) [nontrivial Fₗ] :\n  ∥smul_rightL 𝕜 E Fₗ c∥ = ∥c∥ :=\ncontinuous_linear_map.homothety_norm _ c.norm_smul_right_apply\n\nvariables (𝕜) (𝕜' : Type*) [normed_ring 𝕜'] [normed_algebra 𝕜 𝕜']\n\n@[simp] lemma op_norm_lmul : ∥lmul 𝕜 𝕜'∥ = 1 :=\nby haveI := normed_algebra.nontrivial 𝕜 𝕜'; exact (lmulₗᵢ 𝕜 𝕜').norm_to_continuous_linear_map\n\n@[simp] lemma op_norm_lmul_right : ∥lmul_right 𝕜 𝕜'∥ = 1 :=\n(op_norm_flip (@lmul 𝕜 _ 𝕜' _ _)).trans (op_norm_lmul _ _)\n\nend continuous_linear_map\n\nnamespace submodule\nvariables [nondiscrete_normed_field 𝕜] [nondiscrete_normed_field 𝕜₂] [nondiscrete_normed_field 𝕜₃]\n  [normed_space 𝕜 E] [normed_space 𝕜₂ F] {σ₁₂ : 𝕜 →+* 𝕜₂}\n\nlemma norm_subtypeL (K : submodule 𝕜 E) [nontrivial K] : ∥K.subtypeL∥ = 1 :=\nK.subtypeₗᵢ.norm_to_continuous_linear_map\n\nend submodule\n\nnamespace continuous_linear_equiv\nvariables [nondiscrete_normed_field 𝕜] [nondiscrete_normed_field 𝕜₂] [nondiscrete_normed_field 𝕜₃]\n  [normed_space 𝕜 E] [normed_space 𝕜₂ F] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₁ : 𝕜₂ →+* 𝕜}\n  [ring_hom_inv_pair σ₁₂ σ₂₁] [ring_hom_inv_pair σ₂₁ σ₁₂]\n\nsection\nvariables [ring_hom_isometric σ₂₁]\n\nprotected lemma antilipschitz (e : E ≃SL[σ₁₂] F) :\n  antilipschitz_with (nnnorm (e.symm : F →SL[σ₂₁] E)) e :=\ne.symm.lipschitz.to_right_inverse e.left_inv\n\ninclude σ₂₁\n/-- A continuous linear equiv is a uniform embedding. -/\nlemma uniform_embedding [ring_hom_isometric σ₁₂] (e : E ≃SL[σ₁₂] F) : uniform_embedding e :=\ne.antilipschitz.uniform_embedding e.lipschitz.uniform_continuous\nomit σ₂₁\n\nlemma one_le_norm_mul_norm_symm [ring_hom_isometric σ₁₂] [nontrivial E] (e : E ≃SL[σ₁₂] F) :\n  1 ≤ ∥(e : E →SL[σ₁₂] F)∥ * ∥(e.symm : F →SL[σ₂₁] E)∥ :=\nbegin\n  rw [mul_comm],\n  convert (e.symm : F →SL[σ₂₁] E).op_norm_comp_le (e : E →SL[σ₁₂] F),\n  rw [e.coe_symm_comp_coe, continuous_linear_map.norm_id]\nend\n\ninclude σ₂₁\nlemma norm_pos [ring_hom_isometric σ₁₂] [nontrivial E] (e : E ≃SL[σ₁₂] F) :\n  0 < ∥(e : E →SL[σ₁₂] F)∥ :=\npos_of_mul_pos_right (lt_of_lt_of_le zero_lt_one e.one_le_norm_mul_norm_symm) (norm_nonneg _)\nomit σ₂₁\n\nlemma norm_symm_pos [ring_hom_isometric σ₁₂] [nontrivial E] (e : E ≃SL[σ₁₂] F) :\n  0 < ∥(e.symm : F →SL[σ₂₁] E)∥ :=\npos_of_mul_pos_left (lt_of_lt_of_le zero_lt_one e.one_le_norm_mul_norm_symm) (norm_nonneg _)\n\nlemma nnnorm_symm_pos [ring_hom_isometric σ₁₂] [nontrivial E] (e : E ≃SL[σ₁₂] F) :\n  0 < nnnorm (e.symm : F →SL[σ₂₁] E) :=\ne.norm_symm_pos\n\nlemma subsingleton_or_norm_symm_pos [ring_hom_isometric σ₁₂] (e : E ≃SL[σ₁₂] F) :\n  subsingleton E ∨ 0 < ∥(e.symm : F →SL[σ₂₁] E)∥ :=\nbegin\n  rcases subsingleton_or_nontrivial E with _i|_i; resetI,\n  { left, apply_instance },\n  { right, exact e.norm_symm_pos }\nend\n\nlemma subsingleton_or_nnnorm_symm_pos [ring_hom_isometric σ₁₂] (e : E ≃SL[σ₁₂] F) :\n  subsingleton E ∨ 0 < (nnnorm $ (e.symm : F →SL[σ₂₁] E)) :=\nsubsingleton_or_norm_symm_pos e\n\nvariable (𝕜)\n\n/-- Given a nonzero element `x` of a normed space `E₁` over a field `𝕜`, the natural\n    continuous linear equivalence from `E₁` to the span of `x`.-/\ndef to_span_nonzero_singleton (x : E) (h : x ≠ 0) : 𝕜 ≃L[𝕜] (𝕜 ∙ x) :=\nof_homothety\n  (linear_equiv.to_span_nonzero_singleton 𝕜 E x h)\n  ∥x∥\n  (norm_pos_iff.mpr h)\n  (to_span_nonzero_singleton_homothety 𝕜 x h)\n\n/-- Given a nonzero element `x` of a normed space `E₁` over a field `𝕜`, the natural continuous\n    linear map from the span of `x` to `𝕜`.-/\ndef coord (x : E) (h : x ≠ 0) : (𝕜 ∙ x) →L[𝕜] 𝕜 := (to_span_nonzero_singleton 𝕜 x h).symm\n\n@[simp] lemma coe_to_span_nonzero_singleton_symm {x : E} (h : x ≠ 0) :\n  ⇑(to_span_nonzero_singleton 𝕜 x h).symm = coord 𝕜 x h := rfl\n\n@[simp] lemma coord_to_span_nonzero_singleton {x : E} (h : x ≠ 0) (c : 𝕜) :\n  coord 𝕜 x h (to_span_nonzero_singleton 𝕜 x h c) = c :=\n(to_span_nonzero_singleton 𝕜 x h).symm_apply_apply c\n\n@[simp] lemma to_span_nonzero_singleton_coord {x : E} (h : x ≠ 0) (y : 𝕜 ∙ x) :\n  to_span_nonzero_singleton 𝕜 x h (coord 𝕜 x h y) = y :=\n(to_span_nonzero_singleton 𝕜 x h).apply_symm_apply y\n\n@[simp] lemma coord_norm (x : E) (h : x ≠ 0) : ∥coord 𝕜 x h∥ = ∥x∥⁻¹ :=\nbegin\n  have hx : 0 < ∥x∥ := (norm_pos_iff.mpr h),\n  haveI : nontrivial (𝕜 ∙ x) := submodule.nontrivial_span_singleton h,\n  exact continuous_linear_map.homothety_norm _\n        (λ y, homothety_inverse _ hx _ (to_span_nonzero_singleton_homothety 𝕜 x h) _)\nend\n\n@[simp] lemma coord_self (x : E) (h : x ≠ 0) :\n  (coord 𝕜 x h) (⟨x, submodule.mem_span_singleton_self x⟩ : 𝕜 ∙ x) = 1 :=\nlinear_equiv.coord_self 𝕜 E x h\n\nend\n\nend continuous_linear_equiv\n\nvariables [nondiscrete_normed_field 𝕜] [nondiscrete_normed_field 𝕜₂]\n  [normed_space 𝕜 E] [normed_space 𝕜₂ F] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₁ : 𝕜₂ →+* 𝕜}\n  [ring_hom_inv_pair σ₁₂ σ₂₁] [ring_hom_inv_pair σ₂₁ σ₁₂]\n  [ring_hom_isometric σ₁₂] [ring_hom_isometric σ₂₁]\n\ninclude σ₂₁\nlemma linear_equiv.uniform_embedding (e : E ≃ₛₗ[σ₁₂] F) (h₁ : continuous e)\n  (h₂ : continuous e.symm) : uniform_embedding e :=\ncontinuous_linear_equiv.uniform_embedding\n({ continuous_to_fun := h₁,\n  continuous_inv_fun := h₂,\n  .. e } : E ≃SL[σ₁₂] F)\n\nomit σ₂₁\n\nend normed\n\n/--\nA bounded bilinear form `B` in a real normed space is *coercive*\nif there is some positive constant C such that `C * ∥u∥ * ∥u∥ ≤ B u u`.\n-/\ndef is_coercive\n  [normed_group E] [normed_space ℝ E]\n  (B : E →L[ℝ] E →L[ℝ] ℝ) : Prop :=\n∃ C, (0 < C) ∧ ∀ u, C * ∥u∥ * ∥u∥ ≤ B u u\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/analysis/normed_space/operator_norm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.4923164559518295}}
{"text": "-- Formalization of matrices defined over 'grid's.\n\nimport grid utils data.vector2 tactic.elide\n\nopen utils\n\nnamespace matrix\n\nstructure matrix (m n : ℕ) (α : Type) :=\n  (g  : dep_vec_grid α m n)\n\nprivate lemma matrix_of_f_ {x : ℤ} {m} (h : x < ↑m) (h₁ : 0 ≤ x) : |x| < m :=\n  by rwa [← int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg h₁]\n\ndef matrix_of_f {m n} {α} (h : m * n > 0) (f : fin m → fin n → α) : matrix m n α :=\n  ⟨⟨h, ⟨℘(fgrid₀.mk m n h ⟨0, 0⟩\n    (λx y, f \n      ⟨|x.1|,\n         begin\n           rcases x with ⟨x, ⟨hx₁, hx₂⟩⟩, simp at hx₁ hx₂ ⊢, \n           exact matrix_of_f_ hx₂ hx₁\n         end\n       ⟩\n      ⟨|y.1|,\n         begin\n           rcases y with ⟨y, ⟨hy₁, hy₂⟩⟩, simp at hy₁ hy₂ ⊢, \n           exact matrix_of_f_ hy₂ hy₁\n         end\n      ⟩)), by simpa [length_generate_eq_size, size]⟩⟩⟩\n\nprivate lemma matrix_at_ {m n} {α} (m₁ : matrix m n α) (i : fin m) :\n  (grid.bl (vec_grid_of_dep_vec_grid (m₁.g))).y ≤ ↑(i.val) ∧\n  ↑(i.val) < (gtr (vec_grid_of_dep_vec_grid (m₁.g))).y :=\nbegin\n  rcases m₁ with ⟨⟨h, ⟨d, hd⟩⟩⟩,\n  simp [grid.bl, expand_gtr, relative_grid.rows, vec_grid_of_dep_vec_grid],\n  norm_cast,\n  exact ⟨zero_le _, i.2⟩\nend\n\nprivate lemma matrix_at_ {m n} {α} (m₁ : matrix m n α) (j : fin n) :\n  (grid.bl (vec_grid_of_dep_vec_grid (m₁.g))).x ≤ ↑(j.val) ∧\n  ↑(j.val) < (gtr (vec_grid_of_dep_vec_grid (m₁.g))).x :=\nbegin\n  rcases m₁ with ⟨⟨h, ⟨d, hd⟩⟩⟩,\n  simp [grid.bl, expand_gtr, relative_grid.rows, vec_grid_of_dep_vec_grid],\n  norm_cast,\n  exact ⟨zero_le _, j.2⟩\nend\n\ndef matrix_at {m n} {α} (m₁ : matrix m n α) (i : fin m) (j : fin n) : α :=\n  abs_data (vec_grid_of_dep_vec_grid m₁.1)\n    ⟨⟨i.1, matrix_at_ m₁ i⟩, ⟨j.1, matrix_at_ m₁ j⟩⟩\n\n@[simp]\nlemma matrix_get_mk {α} {m n} (h : m * n > 0)\n  (f : fin m → fin n → α) (i : fin m) (j : fin n) :\n  matrix_at (matrix_of_f h f) i j = f i j :=\nbegin\n  simp [matrix_of_f, matrix_at], unfold_projs,\n  delta vec_grid_of_dep_vec_grid, unfold_projs,\n  rw abs_data_eq_nth_v₀, unfold_projs,\n  simp [\n    vector.nth, nth_generate, grid.bl, relative_grid.cols,\n    grid_point_to_fin, rel_point_to_fin, relpoint_of_gpoint,\n    abs_data, relative_grid.contents\n  ],\n  cases i with i hi, cases j with i hj,\n  have intzero_add : ∀x, int.zero + x = x,\n    by intros; simp [int.zero]; rw int.of_nat_eq_coe; ring,\n  congr,\n    {\n      simp, norm_cast,\n      have : ↑i + -int.zero = ↑i, by ring, simp [this, intzero_add],\n      unfold_coes, simp [fin.val],\n      rw [← int.coe_nat_eq_coe_nat_iff, int.coe_nat_div, int.coe_nat_add], simp,\n      have h₁ : int.of_nat i + -int.zero = ↑i, by ring,\n      have : int.of_nat i + -int.zero ≥ (0 : ℤ), by norm_cast,\n      rw int.nat_abs_of_nonneg, swap 2, exact this,\n      have : ↑n ≠ (0 : ℤ), by simp; clear_except h; intros contra; subst contra; linarith,\n      rw int.add_mul_div_right _ _ this,\n      have : ↑i / ↑n = (0 : ℤ), by norm_cast; exact nat.div_eq_of_lt hj, simp [this],\n      ring\n    },\n    {\n      have : -int.zero = int.zero, by refl, simp [this, intzero_add],\n      unfold_coes, simp [fin.val], rw ← int.coe_nat_eq_coe_nat_iff,\n      have : int.of_nat i % int.of_nat n ≥ (0 : ℤ), by norm_cast,\n      rw int.nat_abs_of_nonneg this, repeat { rw int.of_nat_eq_coe },\n      rw [← int.coe_nat_mod, int.coe_nat_eq_coe_nat_iff],\n      exact nat.mod_eq_of_lt hj\n    }\nend\n\nsection ext\n\nvariables {m n : ℕ} {α : Type} {m₁ m₂ : matrix m n α}\n\ntheorem ext_iff : m₁.g = m₂.g ↔ m₁ = m₂ :=\n  by cases m₁; rcases m₂; simp\n\n@[extensionality] theorem ext : m₁.g = m₂.g → m₁ = m₂ := ext_iff.1\n\n@[extensionality]\nlemma m_ext {m₁ m₂ : matrix m n α}\n  (h : ∀i j, matrix_at m₁ i j = matrix_at m₂ i j) : m₁ = m₂ :=\nbegin\n  let m₁' := @matrix_of_f m n _ m₁.1.1\n    (λx y, abs_data (vec_grid_of_dep_vec_grid m₁.1) ⟨⟨x.1, ⟨_, _⟩⟩, ⟨y.1, ⟨_, _⟩⟩⟩),\n  let m₂' := @matrix_of_f m n _ m₂.1.1\n    (λx y, abs_data (vec_grid_of_dep_vec_grid m₂.1) ⟨⟨x.1, ⟨_, _⟩⟩, ⟨y.1, ⟨_, _⟩⟩⟩),\n  swap 2, { simp [vec_grid_of_dep_vec_grid] },\n  swap 2, {\n    simp [vec_grid_of_dep_vec_grid, expand_gtr, grid.bl, relative_grid.rows, x.2]\n  },\n  swap 2, { simp [vec_grid_of_dep_vec_grid] },\n  swap 2, {\n    simp [vec_grid_of_dep_vec_grid, expand_gtr, grid.bl, relative_grid.cols, y.2]\n  },\n  swap 2, { simp [vec_grid_of_dep_vec_grid] },\n  swap 2, {\n    simp [vec_grid_of_dep_vec_grid, expand_gtr, grid.bl, relative_grid.rows, x.2]\n  },\n  swap 2, { simp [vec_grid_of_dep_vec_grid] },\n  swap 2, {\n    simp [vec_grid_of_dep_vec_grid, expand_gtr, grid.bl, relative_grid.cols, y.2]\n  },\n  have heq₁ : m₁ = m₁',\n    {\n      rcases m₁ with ⟨⟨h, ⟨d, hd⟩⟩⟩,\n      simp [m₁', matrix_of_f],\n      apply list.ext_le _ _,\n        {\n          simp [\n            length_generate_eq_size, hd, size, relative_grid.rows,\n            relative_grid.cols\n          ]\n        },\n        {\n          intros k h₁ h₂, rw nth_generate,\n          simp [\n            abs_data, relative_grid.cols, relpoint_of_gpoint, relative_grid.contents,\n            grid.bl, vec_grid_of_dep_vec_grid\n          ],\n          delta vec_grid_of_dep_vec_grid, simp [vector.nth],\n          congr, norm_cast, unfold_coes, simp [fin.val],\n          rw [\n            ← int.coe_nat_eq_coe_nat_iff, int.coe_nat_add,\n            int.coe_nat_mul, int.coe_nat_div\n          ],\n          have : int.of_nat k % int.of_nat n ≥ (0 : ℤ), by norm_cast,\n          rw int.nat_abs_of_nonneg this, repeat { rw int.of_nat_eq_coe },\n          symmetry, rw [mul_comm, int.mod_add_div]\n        }\n    },\n  rw heq₁ at h,\n  have heq₂ : m₂ = m₂',\n    {\n      rcases m₂ with ⟨⟨h, ⟨d, hd⟩⟩⟩,\n      simp [m₂', matrix_of_f],\n      apply list.ext_le _ _,\n        {\n          simp [\n            length_generate_eq_size, hd, size, relative_grid.rows,\n            relative_grid.cols\n          ]\n        },\n        {\n          intros k h₁ h₂, rw nth_generate,\n          simp [\n            abs_data, relative_grid.cols, relpoint_of_gpoint, relative_grid.contents,\n            grid.bl, vec_grid_of_dep_vec_grid\n          ],\n          delta vec_grid_of_dep_vec_grid, simp [vector.nth],\n          congr, norm_cast, unfold_coes, simp [fin.val],\n          rw [\n            ← int.coe_nat_eq_coe_nat_iff, int.coe_nat_add,\n            int.coe_nat_mul, int.coe_nat_div\n          ],\n          have : int.of_nat k % int.of_nat n ≥ (0 : ℤ), by norm_cast,\n          rw int.nat_abs_of_nonneg this, repeat { rw int.of_nat_eq_coe },\n          symmetry, rw [mul_comm, int.mod_add_div]\n        }\n    },\n  rw heq₂ at h,\n  simp [m₁', m₂'] at h,\n  delta vec_grid_of_dep_vec_grid at h,\n  rcases m₁ with ⟨⟨h₁, ⟨d₁, hd₁⟩⟩⟩, rcases m₂ with ⟨⟨h₂, ⟨d₂, hd₂⟩⟩⟩, simp at *,\n  simp [\n    abs_data, relpoint_of_gpoint, relative_grid.contents, grid.bl, expand_gtr,\n    vector.nth\n  ] at h,\n  apply list.ext_le _ _,\n    {simp [hd₁, hd₂]},\n    {\n      intros k hk₁ hk₂,\n      have eq₁ : k % n < n, by\n        apply nat.mod_lt; exact (gt_and_gt_of_mul_gt h₁).2,\n      have eq₂ : k / n < m, {\n        rw hd₁ at hk₁, rw nat.div_lt_iff_lt_mul, exact hk₁,\n        exact (gt_and_gt_of_mul_gt h₁).2\n      },\n      specialize h ⟨k / n, eq₂⟩ ⟨k % n, eq₁⟩,\n      revert h, rw ← option.some_inj, intros h,\n      repeat { rw ← list.nth_le_nth at h }, simp at h,\n      rw ← option.some_inj, repeat { rw ← list.nth_le_nth },\n      have : k % n + k / n * n = k,\n        {\n          rw [\n            mul_comm,\n            ← int.coe_nat_eq_coe_nat_iff, int.coe_nat_add, int.coe_nat_mod,\n            int.coe_nat_mul, int.coe_nat_div\n          ],\n          exact int.mod_add_div _ _\n        },\n      simp [this] at h, exact h\n    }\nend\n\nend ext\n\nsection operations\n\nvariables {m n o p : ℕ} {α β γ δ : Type}\n\nopen relative_grid grid\n\nlemma matrix_nonempty {m₁ : matrix m n α} : m * n > 0 := m₁.1.1\n\ndef matrix_string [has_to_string α] (m : matrix m n α) :=\n  grid_str (vec_grid_of_dep_vec_grid m.g)\n\ninstance matrix_repr [has_to_string α] : has_repr (matrix m n α) :=\n  ⟨matrix_string⟩\n\ninstance matrix_to_string [has_to_string α] : has_to_string (matrix m n α) :=\n  ⟨matrix_string⟩\n\ninstance matrix_functor : functor (matrix m n) := {\n  map := λα β f m, ⟨f <$> m.g⟩\n}\n\ninstance matrix_functor_law : is_lawful_functor (matrix m n) := {\n  id_map := λα ⟨⟨r, c, h⟩⟩, by simp [(<$>), vector.map_id],\n  comp_map := λα β γ f h ⟨⟨r, c, h⟩⟩, by simp [(<$>)]\n}\n\ndef m₁ : matrix 5 2 ℕ :=\n  matrix.mk\n    (@dep_vec_grid.mk _ 5 2 dec_trivial\n                       ⟨[1, 3, 4, 5, 7, 8, 9, 10, 11, 12], dec_trivial⟩)\n\ndef m₂ : matrix 2 3 ℕ :=\n  matrix.mk\n    (@dep_vec_grid.mk _ 2 3 dec_trivial\n                      ⟨[2, 2, 2, 2, 2, 2], dec_trivial⟩)\n\ninstance [has_add α] : has_add (matrix m n α) := {\n  add := λm₁ m₂, ⟨\n    @dep_vec_grid.mk _ m n m₁.1.1 (vector.zip_with (+) m₁.1.2 m₂.1.2)\n  ⟩\n}\n\ndef transpose {α} {m n} (m₁ : matrix m n α) : matrix n m α :=\n  matrix_of_f (by rw mul_comm; exact m₁.1.1) $ λi j, matrix_at m₁ j i\n\ntheorem transpose_transpose_eq_self (A : matrix m n α) :\n  transpose (transpose A) = A := by ext; simp [transpose]\n\nend operations\n\nend matrix", "meta": {"author": "FerdoSil", "repo": "LatticesAndCellularAutomata", "sha": "2a69d2e74a231addf0e446dca86ef90d50d60218", "save_path": "github-repos/lean/FerdoSil-LatticesAndCellularAutomata", "path": "github-repos/lean/FerdoSil-LatticesAndCellularAutomata/LatticesAndCellularAutomata-2a69d2e74a231addf0e446dca86ef90d50d60218/src/matrix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.49231644183039197}}
{"text": "/-\nCopyright (c) 2020 Kenji Nakagawa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio\n\n! This file was ported from Lean 3 source module ring_theory.dedekind_domain.integral_closure\n! leanprover-community/mathlib commit 641b6a82006416ec431b2987b354af9311fed4f2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.FreeModule.Pid\nimport Mathbin.RingTheory.DedekindDomain.Basic\nimport Mathbin.RingTheory.Localization.Module\nimport Mathbin.RingTheory.Trace\n\n/-!\n# Integral closure of Dedekind domains\n\nThis file shows the integral closure of a Dedekind domain (in particular, the ring of integers\nof a number field) is a Dedekind domain.\n\n## Implementation notes\n\nThe definitions that involve a field of fractions choose a canonical field of fractions,\nbut are independent of that choice. The `..._iff` lemmas express this independence.\n\nOften, definitions assume that Dedekind domains are not fields. We found it more practical\nto add a `(h : ¬ is_field A)` assumption whenever this is explicitly needed.\n\n## References\n\n* [D. Marcus, *Number Fields*][marcus1977number]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]\n\n## Tags\n\ndedekind domain, dedekind ring\n-/\n\n\nvariable (R A K : Type _) [CommRing R] [CommRing A] [Field K]\n\nopen nonZeroDivisors Polynomial\n\nvariable [IsDomain A]\n\nsection IsIntegralClosure\n\n/-! ### `is_integral_closure` section\n\nWe show that an integral closure of a Dedekind domain in a finite separable\nfield extension is again a Dedekind domain. This implies the ring of integers\nof a number field is a Dedekind domain. -/\n\n\nopen Algebra\n\nopen BigOperators\n\nvariable (A K) [Algebra A K] [IsFractionRing A K]\n\nvariable (L : Type _) [Field L] (C : Type _) [CommRing C]\n\nvariable [Algebra K L] [Algebra A L] [IsScalarTower A K L]\n\nvariable [Algebra C L] [IsIntegralClosure C A L] [Algebra A C] [IsScalarTower A C L]\n\n/- If `L` is a separable extension of `K = Frac(A)` and `L` has no zero smul divisors by `A`,\nthen `L` is the localization of the integral closure `C` of `A` in `L` at `A⁰`. -/\ntheorem IsIntegralClosure.isLocalization [IsSeparable K L] [NoZeroSMulDivisors A L] :\n    IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L :=\n  by\n  haveI : IsDomain C :=\n    (IsIntegralClosure.equiv A C L (integralClosure A L)).toRingEquiv.IsDomain (integralClosure A L)\n  haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L\n  refine' ⟨_, fun z => _, fun x y => ⟨fun h => ⟨1, _⟩, _⟩⟩\n  · rintro ⟨_, x, hx, rfl⟩\n    rw [isUnit_iff_ne_zero, map_ne_zero_iff _ (IsIntegralClosure.algebraMap_injective C A L),\n      Subtype.coe_mk, map_ne_zero_iff _ (NoZeroSMulDivisors.algebraMap_injective A C)]\n    exact mem_non_zero_divisors_iff_ne_zero.mp hx\n  · obtain ⟨m, hm⟩ :=\n      IsIntegral.exists_multiple_integral_of_isLocalization A⁰ z (IsSeparable.isIntegral K z)\n    obtain ⟨x, hx⟩ : ∃ x, algebraMap C L x = m • z := is_integral_closure.is_integral_iff.mp hm\n    refine' ⟨⟨x, algebraMap A C m, m, SetLike.coe_mem m, rfl⟩, _⟩\n    rw [Subtype.coe_mk, ← IsScalarTower.algebraMap_apply, hx, mul_comm, Submonoid.smul_def,\n      smul_def]\n  · simp only [IsIntegralClosure.algebraMap_injective C A L h]\n  · rintro ⟨⟨_, m, hm, rfl⟩, h⟩\n    refine' congr_arg (algebraMap C L) ((mul_right_inj' _).mp h)\n    rw [Subtype.coe_mk, map_ne_zero_iff _ (NoZeroSMulDivisors.algebraMap_injective A C)]\n    exact mem_non_zero_divisors_iff_ne_zero.mp hm\n#align is_integral_closure.is_localization IsIntegralClosure.isLocalization\n\nvariable [FiniteDimensional K L]\n\nvariable {A K L}\n\ntheorem IsIntegralClosure.range_le_span_dualBasis [IsSeparable K L] {ι : Type _} [Fintype ι]\n    [DecidableEq ι] (b : Basis ι K L) (hb_int : ∀ i, IsIntegral A (b i)) [IsIntegrallyClosed A] :\n    ((Algebra.linearMap C L).restrictScalars A).range ≤\n      Submodule.span A (Set.range <| (traceForm K L).dualBasis (traceFormNondegenerate K L) b) :=\n  by\n  let db := (trace_form K L).dualBasis (traceFormNondegenerate K L) b\n  rintro _ ⟨x, rfl⟩\n  simp only [LinearMap.coe_restrictScalars, Algebra.linearMap_apply]\n  have hx : IsIntegral A (algebraMap C L x) := (IsIntegralClosure.isIntegral A L x).algebraMap\n  rsuffices ⟨c, x_eq⟩ : ∃ c : ι → A, algebraMap C L x = ∑ i, c i • db i\n  · rw [x_eq]\n    refine' Submodule.sum_mem _ fun i _ => Submodule.smul_mem _ _ (Submodule.subset_span _)\n    rw [Set.mem_range]\n    exact ⟨i, rfl⟩\n  suffices ∃ c : ι → K, (∀ i, IsIntegral A (c i)) ∧ algebraMap C L x = ∑ i, c i • db i\n    by\n    obtain ⟨c, hc, hx⟩ := this\n    have hc' : ∀ i, IsLocalization.IsInteger A (c i) := fun i =>\n      is_integrally_closed.is_integral_iff.mp (hc i)\n    use fun i => Classical.choose (hc' i)\n    refine' hx.trans (Finset.sum_congr rfl fun i _ => _)\n    conv_lhs => rw [← Classical.choose_spec (hc' i)]\n    rw [← IsScalarTower.algebraMap_smul K (Classical.choose (hc' i)) (db i)]\n  refine' ⟨fun i => db.repr (algebraMap C L x) i, fun i => _, (db.sum_repr _).symm⟩\n  rw [BilinForm.dualBasis_repr_apply]\n  exact is_integral_trace (isIntegral_mul hx (hb_int i))\n#align is_integral_closure.range_le_span_dual_basis IsIntegralClosure.range_le_span_dualBasis\n\ntheorem integralClosure_le_span_dualBasis [IsSeparable K L] {ι : Type _} [Fintype ι] [DecidableEq ι]\n    (b : Basis ι K L) (hb_int : ∀ i, IsIntegral A (b i)) [IsIntegrallyClosed A] :\n    (integralClosure A L).toSubmodule ≤\n      Submodule.span A (Set.range <| (traceForm K L).dualBasis (traceFormNondegenerate K L) b) :=\n  by\n  refine' le_trans _ (IsIntegralClosure.range_le_span_dualBasis (integralClosure A L) b hb_int)\n  intro x hx\n  exact ⟨⟨x, hx⟩, rfl⟩\n#align integral_closure_le_span_dual_basis integralClosure_le_span_dualBasis\n\nvariable (A) (K)\n\ninclude K\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y «expr ≠ » (0 : A)) -/\n/-- Send a set of `x`'es in a finite extension `L` of the fraction field of `R`\nto `(y : R) • x ∈ integral_closure R L`. -/\ntheorem exists_integral_multiples (s : Finset L) :\n    ∃ (y : _)(_ : y ≠ (0 : A)), ∀ x ∈ s, IsIntegral A (y • x) :=\n  by\n  haveI := Classical.decEq L\n  refine' s.induction _ _\n  · use 1, one_ne_zero\n    rintro x ⟨⟩\n  · rintro x s hx ⟨y, hy, hs⟩\n    obtain ⟨x', y', hy', hx'⟩ :=\n      exists_integral_multiple\n        ((IsFractionRing.isAlgebraic_iff A K L).mpr (is_algebraic_of_finite _ _ x))\n        ((injective_iff_map_eq_zero (algebraMap A L)).mp _)\n    refine' ⟨y * y', mul_ne_zero hy hy', fun x'' hx'' => _⟩\n    rcases finset.mem_insert.mp hx'' with (rfl | hx'')\n    · rw [mul_smul, Algebra.smul_def, Algebra.smul_def, mul_comm _ x'', hx']\n      exact isIntegral_mul isIntegral_algebraMap x'.2\n    · rw [mul_comm, mul_smul, Algebra.smul_def]\n      exact isIntegral_mul isIntegral_algebraMap (hs _ hx'')\n    · rw [IsScalarTower.algebraMap_eq A K L]\n      apply (algebraMap K L).Injective.comp\n      exact IsFractionRing.injective _ _\n#align exists_integral_multiples exists_integral_multiples\n\nvariable (L)\n\n/-- If `L` is a finite extension of `K = Frac(A)`,\nthen `L` has a basis over `A` consisting of integral elements. -/\ntheorem FiniteDimensional.exists_is_basis_integral :\n    ∃ (s : Finset L)(b : Basis s K L), ∀ x, IsIntegral A (b x) :=\n  by\n  letI := Classical.decEq L\n  letI : IsNoetherian K L := IsNoetherian.iff_fg.2 inferInstance\n  let s' := IsNoetherian.finsetBasisIndex K L\n  let bs' := IsNoetherian.finsetBasis K L\n  obtain ⟨y, hy, his'⟩ := exists_integral_multiples A K (finset.univ.image bs')\n  have hy' : algebraMap A L y ≠ 0 :=\n    by\n    refine' mt ((injective_iff_map_eq_zero (algebraMap A L)).mp _ _) hy\n    rw [IsScalarTower.algebraMap_eq A K L]\n    exact (algebraMap K L).Injective.comp (IsFractionRing.injective A K)\n  refine'\n    ⟨s',\n      bs'.map\n        {\n          LinearMap.Algebra.lmul _ _\n            (algebraMap A L y) with\n          toFun := fun x => algebraMap A L y * x\n          invFun := fun x => (algebraMap A L y)⁻¹ * x\n          left_inv := _\n          right_inv := _ },\n      _⟩\n  · intro x\n    simp only [inv_mul_cancel_left₀ hy']\n  · intro x\n    simp only [mul_inv_cancel_left₀ hy']\n  · rintro ⟨x', hx'⟩\n    simp only [Algebra.smul_def, Finset.mem_image, exists_prop, Finset.mem_univ, true_and_iff] at\n      his'\n    simp only [Basis.map_apply, LinearEquiv.coe_mk]\n    exact his' _ ⟨_, rfl⟩\n#align finite_dimensional.exists_is_basis_integral FiniteDimensional.exists_is_basis_integral\n\nvariable (A K L) [IsSeparable K L]\n\ninclude L\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is\nintegrally closed and Noetherian, the integral closure `C` of `A` in `L` is\nNoetherian over `A`. -/\ntheorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :\n    IsNoetherian A C := by\n  haveI := Classical.decEq L\n  obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L\n  let b' := (trace_form K L).dualBasis (traceFormNondegenerate K L) b\n  letI := isNoetherian_span_of_finite A (Set.finite_range b')\n  let f : C →ₗ[A] Submodule.span A (Set.range b') :=\n    (Submodule.ofLe (IsIntegralClosure.range_le_span_dualBasis C b hb_int)).comp\n      ((Algebra.linearMap C L).restrictScalars A).range_restrict\n  refine' isNoetherian_of_ker_bot f _\n  rw [LinearMap.ker_comp, Submodule.ker_ofLe, Submodule.comap_bot, LinearMap.ker_codRestrict]\n  exact LinearMap.ker_eq_bot_of_injective (IsIntegralClosure.algebraMap_injective C A L)\n#align is_integral_closure.is_noetherian IsIntegralClosure.isNoetherian\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is\nintegrally closed and Noetherian, the integral closure `C` of `A` in `L` is\nNoetherian. -/\ntheorem IsIntegralClosure.isNoetherianRing [IsIntegrallyClosed A] [IsNoetherianRing A] :\n    IsNoetherianRing C :=\n  isNoetherianRing_iff.mpr <| isNoetherian_of_tower A (IsIntegralClosure.isNoetherian A K L C)\n#align is_integral_closure.is_noetherian_ring IsIntegralClosure.isNoetherianRing\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a principal ring\nand `L` has no zero smul divisors by `A`, the integral closure `C` of `A` in `L` is\na free `A`-module. -/\ntheorem IsIntegralClosure.module_free [NoZeroSMulDivisors A L] [IsPrincipalIdealRing A] :\n    Module.Free A C :=\n  by\n  haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L\n  haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L _\n  exact Module.free_of_finite_type_torsion_free'\n#align is_integral_closure.module_free IsIntegralClosure.module_free\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a principal ring\nand `L` has no zero smul divisors by `A`, the `A`-rank of the integral closure `C` of `A` in `L`\nis equal to the `K`-rank of `L`. -/\ntheorem IsIntegralClosure.rank [IsPrincipalIdealRing A] [NoZeroSMulDivisors A L] :\n    FiniteDimensional.finrank A C = FiniteDimensional.finrank K L :=\n  by\n  haveI : Module.Free A C := IsIntegralClosure.module_free A K L C\n  haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L C\n  haveI : IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L :=\n    IsIntegralClosure.isLocalization A K L C\n  let b := Basis.localizationLocalization K A⁰ L (Module.Free.chooseBasis A C)\n  rw [Module.Free.finrank_eq_card_chooseBasisIndex, FiniteDimensional.finrank_eq_card_basis b]\n#align is_integral_closure.rank IsIntegralClosure.rank\n\nvariable {A K}\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is\nintegrally closed and Noetherian, the integral closure of `A` in `L` is\nNoetherian. -/\ntheorem integralClosure.isNoetherianRing [IsIntegrallyClosed A] [IsNoetherianRing A] :\n    IsNoetherianRing (integralClosure A L) :=\n  IsIntegralClosure.isNoetherianRing A K L (integralClosure A L)\n#align integral_closure.is_noetherian_ring integralClosure.isNoetherianRing\n\nvariable (A K) [IsDomain C]\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a Dedekind domain,\nthe integral closure `C` of `A` in `L` is a Dedekind domain.\n\nCan't be an instance since `A`, `K` or `L` can't be inferred. See also the instance\n`integral_closure.is_dedekind_domain_fraction_ring` where `K := fraction_ring A`\nand `C := integral_closure A L`.\n-/\ntheorem IsIntegralClosure.isDedekindDomain [h : IsDedekindDomain A] : IsDedekindDomain C :=\n  haveI : IsFractionRing C L := IsIntegralClosure.isFractionRing_of_finite_extension A K L C\n  ⟨IsIntegralClosure.isNoetherianRing A K L C, h.dimension_le_one.is_integral_closure _ L _,\n    (isIntegrallyClosed_iff L).mpr fun x hx =>\n      ⟨IsIntegralClosure.mk' C x (isIntegral_trans (IsIntegralClosure.isIntegral_algebra A L) _ hx),\n        IsIntegralClosure.algebraMap_mk' _ _ _⟩⟩\n#align is_integral_closure.is_dedekind_domain IsIntegralClosure.isDedekindDomain\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a Dedekind domain,\nthe integral closure of `A` in `L` is a Dedekind domain.\n\nCan't be an instance since `K` can't be inferred. See also the instance\n`integral_closure.is_dedekind_domain_fraction_ring` where `K := fraction_ring A`.\n-/\ntheorem integralClosure.isDedekindDomain [h : IsDedekindDomain A] :\n    IsDedekindDomain (integralClosure A L) :=\n  IsIntegralClosure.isDedekindDomain A K L (integralClosure A L)\n#align integral_closure.is_dedekind_domain integralClosure.isDedekindDomain\n\nomit K\n\nvariable [Algebra (FractionRing A) L] [IsScalarTower A (FractionRing A) L]\n\nvariable [FiniteDimensional (FractionRing A) L] [IsSeparable (FractionRing A) L]\n\n/- If `L` is a finite separable extension of `Frac(A)`, where `A` is a Dedekind domain,\nthe integral closure of `A` in `L` is a Dedekind domain.\n\nSee also the lemma `integral_closure.is_dedekind_domain` where you can choose\nthe field of fractions yourself.\n-/\ninstance integralClosure.isDedekindDomainFractionRing [IsDedekindDomain A] :\n    IsDedekindDomain (integralClosure A L) :=\n  integralClosure.isDedekindDomain A (FractionRing A) L\n#align integral_closure.is_dedekind_domain_fraction_ring integralClosure.isDedekindDomainFractionRing\n\nend IsIntegralClosure\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/DedekindDomain/IntegralClosure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.72487026428967, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.49231643846403567}}
{"text": "example (P Q : Prop) (p : P) (q : Q) : P ∧ Q :=\nbegin\nsplit,\nexact p,\nexact q,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/5-advanced-proposition-world/l1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4919400467578895}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n-/\nprelude\nimport Init.Data.UInt\n\n@[inline, reducible] def isValidChar (n : UInt32) : Prop :=\n  n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000)\n\nnamespace Char\n\nprotected def lt (a b : Char) : Prop := a.val < b.val\nprotected def le (a b : Char) : Prop := a.val ≤ b.val\n\ninstance : LT Char := ⟨Char.lt⟩\ninstance : LE Char := ⟨Char.le⟩\n\ninstance (a b : Char) :  Decidable (a < b) :=\n  UInt32.decLt _ _\n\ninstance (a b : Char) : Decidable (a ≤ b) :=\n  UInt32.decLe _ _\n\nabbrev isValidCharNat (n : Nat) : Prop :=\n  n < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000)\n\ntheorem isValidUInt32 (n : Nat) (h : isValidCharNat n) : n < UInt32.size := by\n  match h with\n  | Or.inl h        =>\n    apply Nat.ltTrans h\n    decide\n  | Or.inr ⟨h₁, h₂⟩ =>\n    apply Nat.ltTrans h₂\n    decide\n\ntheorem isValidCharOfValidNat (n : Nat) (h : isValidCharNat n) : isValidChar (UInt32.ofNat' n (isValidUInt32 n h)) :=\n  match h with\n  | Or.inl h        => Or.inl h\n  | Or.inr ⟨h₁, h₂⟩ => Or.inr ⟨h₁, h₂⟩\n\ntheorem isValidChar0 : isValidChar 0 :=\n  Or.inl (by decide)\n\n@[inline] def toNat (c : Char) : Nat :=\n  c.val.toNat\n\ninstance : Inhabited Char where\n  default := 'A'\n\ndef isWhitespace (c : Char) : Bool :=\n  c = ' ' || c = '\\t' || c = '\\r' || c = '\\n'\n\ndef isUpper (c : Char) : Bool :=\n  c.val ≥ 65 && c.val ≤ 90\n\ndef isLower (c : Char) : Bool :=\n  c.val ≥ 97 && c.val ≤ 122\n\ndef isAlpha (c : Char) : Bool :=\n  c.isUpper || c.isLower\n\ndef isDigit (c : Char) : Bool :=\n  c.val ≥ 48 && c.val ≤ 57\n\ndef isAlphanum (c : Char) : Bool :=\n  c.isAlpha || c.isDigit\n\ndef toLower (c : Char) : Char :=\n  let n := toNat c;\n  if n >= 65 ∧ n <= 90 then ofNat (n + 32) else c\n\ndef toUpper (c : Char) : Char :=\n  let n := toNat c;\n  if n >= 97 ∧ n <= 122 then ofNat (n - 32) else c\n\nend Char\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/stage0/src/Init/Data/Char/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.49194004353521076}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.finite_limits\nimport Mathlib.category_theory.limits.shapes.binary_products\nimport Mathlib.category_theory.limits.shapes.terminal\nimport Mathlib.PostPort\n\nuniverses v u \n\nnamespace Mathlib\n\nnamespace category_theory.limits\n\n\n/--\nA category has finite products if there is a chosen limit for every diagram\nwith shape `discrete J`, where we have `[decidable_eq J]` and `[fintype J]`.\n-/\n-- We can't simply make this an abbreviation, as we do with other `has_Xs` limits typeclasses,\n\n-- because of https://github.com/leanprover-community/lean/issues/429\n\ndef has_finite_products (C : Type u) [category C] :=\n  ∀ (J : Type v) [_inst_2 : DecidableEq J] [_inst_3 : fintype J], has_limits_of_shape (discrete J) C\n\nprotected instance has_limits_of_shape_discrete (C : Type u) [category C] (J : Type v) [fintype J]\n    [has_finite_products C] : has_limits_of_shape (discrete J) C :=\n  _inst_3 J\n\n/-- If `C` has finite limits then it has finite products. -/\ntheorem has_finite_products_of_has_finite_limits (C : Type u) [category C] [has_finite_limits C] :\n    has_finite_products C :=\n  fun (J : Type v) (𝒥₁ : DecidableEq J) (𝒥₂ : fintype J) =>\n    limits.has_limits_of_shape_of_has_finite_limits C (discrete J)\n\n/--\nIf a category has all products then in particular it has finite products.\n-/\ntheorem has_finite_products_of_has_products (C : Type u) [category C] [has_products C] :\n    has_finite_products C :=\n  id fun (J : Type v) => _inst_2 J\n\n/--\nA category has finite coproducts if there is a chosen colimit for every diagram\nwith shape `discrete J`, where we have `[decidable_eq J]` and `[fintype J]`.\n-/\ndef has_finite_coproducts (C : Type u) [category C] :=\n  ∀ (J : Type v) [_inst_2 : DecidableEq J] [_inst_3 : fintype J],\n    has_colimits_of_shape (discrete J) C\n\nprotected instance has_colimits_of_shape_discrete (C : Type u) [category C] (J : Type v) [fintype J]\n    [has_finite_coproducts C] : has_colimits_of_shape (discrete J) C :=\n  _inst_3 J\n\n/-- If `C` has finite colimits then it has finite coproducts. -/\ntheorem has_finite_coproducts_of_has_finite_colimits (C : Type u) [category C]\n    [has_finite_colimits C] : has_finite_coproducts C :=\n  fun (J : Type v) (𝒥₁ : DecidableEq J) (𝒥₂ : fintype J) =>\n    limits.has_colimits_of_shape_of_has_finite_colimits C (discrete J)\n\n/--\nIf a category has all coproducts then in particular it has finite coproducts.\n-/\ntheorem has_finite_coproducts_of_has_coproducts (C : Type u) [category C] [has_coproducts C] :\n    has_finite_coproducts C :=\n  id fun (J : Type v) => _inst_2 J\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/shapes/finite_products_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.49194004200428865}}
{"text": "import algebra\nimport data.real.basic\nimport data.vector\nimport tactic.explode\nimport tactic.find\nimport tactic.induction\nimport tactic.linarith\nimport tactic.rcases\nimport tactic.rewrite\nimport tactic.ring_exp\nimport tactic.tidy\nimport tactic.where\n\n\n/- # LoVe Library\n\nThis files contains a few extensions on top of Lean's core libraries and\n`mathlib`. -/\n\n\nnamespace LoVe\n\n\n/- ## Structured Proofs -/\n\nnotation `fix ` binders `, ` r:(scoped f, f) := r\n\n\n/- ## Logical Connectives -/\n\nattribute [pattern] or.intro_left or.intro_right\n\nmeta def tactic.dec_trivial := `[exact dec_trivial]\n\nlemma not_def (a : Prop) :\n  ¬ a ↔ a → false :=\nby refl\n\n@[simp] lemma not_not_iff (a : Prop) [decidable a] :\n  ¬¬ a ↔ a :=\nby by_cases a; simp [h]\n\n@[simp] lemma and_imp_distrib (a b c : Prop) :\n  (a ∧ b → c) ↔ (a → b → c) :=\niff.intro\n  (assume h ha hb, h ⟨ha, hb⟩)\n  (assume h ⟨ha, hb⟩, h ha hb)\n\n@[simp] lemma or_imp_distrib {a b c : Prop} :\n  a ∨ b → c ↔ (a → c) ∧ (b → c) :=\niff.intro\n  (assume h,\n   ⟨assume ha, h (or.intro_left _ ha), assume hb, h (or.intro_right _ hb)⟩)\n  (assume ⟨ha, hb⟩ h, match h with or.inl h := ha h | or.inr h := hb h end)\n\n@[simp] lemma exists_imp_distrib {α : Sort*} {p : α → Prop} {a : Prop} :\n  ((∃x, p x) → a) ↔ (∀x, p x → a) :=\niff.intro\n  (assume h hp ha, h ⟨hp, ha⟩)\n  (assume h ⟨hp, ha⟩, h hp ha)\n\nlemma and_exists {α : Sort*} {p : α → Prop} {a : Prop} :\n  (a ∧ (∃x, p x)) ↔ (∃x, a ∧ p x) :=\niff.intro\n  (assume ⟨ha, x, hp⟩, ⟨x, ha, hp⟩)\n  (assume ⟨x, ha, hp⟩, ⟨ha, x, hp⟩)\n\n@[simp] lemma exists_false {α : Sort*} :\n  (∃x : α, false) ↔ false :=\niff.intro (assume ⟨a, f⟩, f) (assume h, h.elim)\n\n\n/- ## Natural Numbers -/\n\nattribute [simp] nat.add\n\n\n/- ## Integers -/\n\n@[simp] lemma int.neg_comp_neg :\n  int.neg ∘ int.neg = id :=\nbegin\n  apply funext,\n  apply neg_neg\nend\n\n\n/- ## Reflexive Transitive Closure -/\n\nnamespace rtc\n\ninductive star {α : Sort*} (r : α → α → Prop) (a : α) : α → Prop\n| refl {}    : star a\n| tail {b c} : star b → r b c → star c\n\nattribute [refl] star.refl\n\nnamespace star\n\nvariables {α : Sort*} {r : α → α → Prop} {a b c d : α}\n\n@[trans] lemma trans (hab : star r a b) (hbc : star r b c) :\n  star r a c :=\nbegin\n  induction' hbc,\n  case refl {\n    assumption },\n  case tail : c d hbc hcd hac {\n    exact (tail (hac hab)) hcd }\nend\n\nlemma single (hab : r a b) :\n  star r a b :=\nrefl.tail hab\n\nlemma head (hab : r a b) (hbc : star r b c) :\n  star r a c :=\nbegin\n  induction' hbc,\n  case refl {\n    exact (tail refl) hab },\n  case tail : c d hbc hcd hac {\n    exact (tail (hac hab)) hcd }\nend\n\nlemma head_induction_on {α : Sort*} {r : α → α → Prop} {b : α}\n  {P : ∀a : α, star r a b → Prop} {a : α} (h : star r a b)\n  (refl : P b refl)\n  (head : ∀{a c} (h' : r a c) (h : star r c b), P c h → P a (h.head h')) :\n  P a h :=\nbegin\n  induction' h,\n  case refl {\n    exact refl },\n  case tail : b c hab hbc ih {\n    apply ih,\n    show P b _, from\n      head hbc _ refl,\n    show ∀a a', r a a' → star r a' b → P a' _ → P a _, from\n      assume a a' hab hbc, head hab _ }\nend\n\nlemma trans_induction_on {α : Sort*} {r : α → α → Prop}\n    {p : ∀{a b : α}, star r a b → Prop} {a b : α} (h : star r a b)\n    (ih₁ : ∀a, @p a a refl) (ih₂ : ∀{a b} (h : r a b), p (single h))\n    (ih₃ : ∀{a b c} (h₁ : star r a b) (h₂ : star r b c), p h₁ →\n       p h₂ → p (h₁.trans h₂)) :\n  p h :=\nbegin\n  induction' h,\n  case refl {\n    exact ih₁ a },\n  case tail : b c hab hbc ih {\n    exact ih₃ hab (single hbc) (ih ih₁ @ih₂ @ih₃) (ih₂ hbc) }\nend\n\nlemma lift {β : Sort*} {s : β → β → Prop} (f : α → β)\n  (h : ∀a b, r a b → s (f a) (f b)) (hab : star r a b) :\n  star s (f a) (f b) :=\nhab.trans_induction_on\n  (assume a, refl)\n  (assume a b, single ∘ h _ _)\n  (assume a b c _ _, trans)\n\nlemma mono {p : α → α → Prop} :\n  (∀a b, r a b → p a b) → star r a b → star p a b :=\nlift id\n\nlemma star_star_eq :\n  star (star r) = star r :=\nfunext\n  (assume a,\n   funext\n     (assume b,\n      propext (iff.intro\n        (assume h,\n         begin\n           induction' h,\n           { refl },\n           { transitivity;\n               assumption }\n         end)\n        (star.mono (assume a b,\n           single)))))\n\nend star\n\nend rtc\n\nexport rtc\n\n\n/- ## States -/\n\ndef state :=\nstring → ℕ\n\ndef state.update (name : string) (val : ℕ) (s : state) : state :=\nλname', if name' = name then val else s name'\n\nnotation s `{` name ` ↦ ` val `}` := state.update name val s\n\ninstance : has_emptyc state :=\n{ emptyc := λ_, 0 }\n\n@[simp] lemma update_apply (name : string) (val : ℕ) (s : state) :\n  s{name ↦ val} name = val :=\nif_pos rfl\n\n@[simp] lemma update_apply_ne (name name' : string) (val : ℕ) (s : state)\n    (h : name' ≠ name . tactic.dec_trivial) :\n  s{name ↦ val} name' = s name' :=\nif_neg h\n\n@[simp] lemma update_override (name : string) (val₁ val₂ : ℕ) (s : state) :\n  s{name ↦ val₂}{name ↦ val₁} = s{name ↦ val₁} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma update_swap (name₁ name₂ : string) (val₁ val₂ : ℕ) (s : state)\n    (h : name₁ ≠ name₂ . tactic.dec_trivial) :\n  s{name₂ ↦ val₂}{name₁ ↦ val₁} = s{name₁ ↦ val₁}{name₂ ↦ val₂} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name₁;\n    by_cases name' = name₂;\n    simp * at *\nend\n\n@[simp] lemma update_id (name : string) (s : state) :\n  s{name ↦ s name} = s :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp * at *\nend\n\nexample (s : state) :\n  s{\"a\" ↦ 0}{\"a\" ↦ 2} = s{\"a\" ↦ 2} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" ↦ 0}{\"b\" ↦ 2} = s{\"b\" ↦ 2}{\"a\" ↦ 0} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" ↦ s \"a\"}{\"b\" ↦ 0} = s{\"b\" ↦ 0} :=\nby simp\n\n\n/- ## Relations -/\n\ndef Id {α : Type} : set (α × α) :=\n{ab | prod.snd ab = prod.fst ab}\n\n@[simp] lemma mem_Id {α : Type} (a b : α) :\n  (a, b) ∈ @Id α ↔ b = a :=\nby refl\n\ndef comp {α : Type} (r₁ r₂ : set (α × α)) : set (α × α) :=\n{ac | ∃b, (prod.fst ac, b) ∈ r₁ ∧ (b, prod.snd ac) ∈ r₂}\n\ninfixl ` ◯ ` : 90 := comp\n\n@[simp] lemma mem_comp {α : Type} (r₁ r₂ : set (α × α))\n    (a b : α) :\n  (a, b) ∈ r₁ ◯ r₂ ↔ (∃c, (a, c) ∈ r₁ ∧ (c, b) ∈ r₂) :=\nby refl\n\ndef restrict {α : Type} (r : set (α × α)) (p : α → Prop) :\n  set (α × α) :=\n{ab | p (prod.fst ab) ∧ ab ∈ r}\n\ninfixl ` ⇃ ` : 90 := restrict\n\n@[simp] lemma mem_restrict {α : Type} (r : set (α × α))\n    (p : α → Prop) (a b : α) :\n  (a, b) ∈ r ⇃ p ↔ p a ∧ (a, b) ∈ r :=\nby refl\n\nend LoVe\n", "meta": {"author": "blanchette", "repo": "logical_verification_2020", "sha": "7a9f4bd73498189d9beb5d4591e0f2b3ca316111", "save_path": "github-repos/lean/blanchette-logical_verification_2020", "path": "github-repos/lean/blanchette-logical_verification_2020/logical_verification_2020-7a9f4bd73498189d9beb5d4591e0f2b3ca316111/lean/lovelib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.49194003878160986}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under MIT license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.algebra.basic\n\n/-! # Submonoids including the central ring -/\n\nnamespace algebra\n\nset_option old_structure_cmd true\n\n/-- A `center_submonoid` is a submonoid that includes the central ring of the algebra -/\nstructure center_submonoid (R : Type*) (A : Type*) [comm_semiring R] [semiring A] [algebra R A]\n  extends submonoid A, sub_mul_action R A.\n\nnamespace center_submonoid\n\nvariables {R : Type*} {A : Type*}\n\nsection semiring\n\nvariables [comm_semiring R] [semiring A] [algebra R A] (S : center_submonoid R A)\n\ninstance : set_like (center_submonoid R A) A :=\n{ coe := center_submonoid.carrier,\n  coe_injective' := λ x y h, by { cases x, cases y, congr' } }\n\ninstance : submonoid_class (center_submonoid R A) A :=\n{ one_mem := λ S, S.to_submonoid.one_mem,\n  mul_mem := λ S _ _, S.to_submonoid.mul_mem, }\n\ninstance : nonempty S.to_sub_mul_action := ⟨⟨1, S.to_submonoid.one_mem⟩⟩\n\ninstance : zero_mem_class (center_submonoid R A) A :=\n{ zero_mem := λ S,  S.to_sub_mul_action.zero_mem ⟨1, S.to_submonoid.one_mem⟩, }\n\nlemma smul_mem (r : R) {a : A} : a ∈ S → r • a ∈ S := S.to_sub_mul_action.smul_mem r\nprotected lemma mul_mem {a b : A} : a ∈ S → b ∈ S → a * b ∈ S := S.to_submonoid.mul_mem\nprotected lemma one_mem : (1 : A) ∈ S := S.to_submonoid.one_mem\nprotected lemma zero_mem : (0 : A) ∈ S := S.to_sub_mul_action.zero_mem ⟨1, S.one_mem⟩\n\n@[simp] lemma algebra_map_mem (r : R) : algebra_map R A r ∈ S :=\nby { rw algebra_map_eq_smul_one r, exact S.smul_mem r S.one_mem, }\n\nvariables (R)\ndef closure (s : set A) : center_submonoid R A :=\nlet c := submonoid.closure (set.range (algebra_map R A) ∪ s) in\n{ smul_mem' := λ r a h, begin\n    rw algebra.smul_def r a, \n    exact c.mul_mem (submonoid.subset_closure $ or.inl $ set.mem_range_self r) h\n  end, ..c}\n\n@[simp] lemma subset_closure {s : set A} : s ⊆ closure R s :=\nλ x hx, submonoid.subset_closure $ or.inr hx\n\n@[simp] lemma closure_to_submonoid {s : set A} :\n  (closure R s).to_submonoid = submonoid.closure (set.range (algebra_map R A) ∪ s) :=\nrfl\n\nvariables {R}\n\ninstance : mul_action R S := S.to_sub_mul_action.mul_action\n  \ninstance : monoid_with_zero S :=\n{ zero_mul := λ v, subtype.eq $ zero_mul ↑v,\n  mul_zero := λ v, subtype.eq $ mul_zero ↑v,\n  ..S.to_sub_mul_action.has_zero,\n  ..S.to_submonoid.to_monoid }\n\ninstance [nontrivial A] : nontrivial S :=\nnontrivial_of_ne 0 1 (subtype.ne_of_val_ne zero_ne_one)\n\n@[simp, norm_cast] lemma coe_zero : ((0 : S) : A) = 0 := rfl\n@[simp, norm_cast] lemma coe_smul (k : R) (v : S) : (↑(k • v) : A) = k • v := rfl\n\nend semiring\n\nsection ring\n\nvariables [comm_ring R] [ring A] [algebra R A] (S : center_submonoid R A)\n\n@[simp] lemma neg_mem (S : center_submonoid R A) (v : A) : v ∈ S → -v ∈ S := S.to_sub_mul_action.neg_mem\n\ninstance : has_neg (S) := S.to_sub_mul_action.has_neg\n\n@[simp, norm_cast] lemma coe_neg (v : S) : (↑-v : A) = -v := rfl\n\nend ring\n\nend center_submonoid\n\nend algebra\n", "meta": {"author": "pygae", "repo": "lean-ga", "sha": "5e8b22b2f25c7037723ad811faa312660eeb6775", "save_path": "github-repos/lean/pygae-lean-ga", "path": "github-repos/lean/pygae-lean-ga/lean-ga-5e8b22b2f25c7037723ad811faa312660eeb6775/src/for_mathlib/algebra/center_submonoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.49194003402800907}}
{"text": "/-\nCopyright (c) 2022 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Floris van Doorn\n-/\nimport measure_theory.integral.integrable_on\n\n/-!\n# Locally integrable functions\n\nA function is called *locally integrable* (`measure_theory.locally_integrable`) if it is integrable\non every compact subset of its domain.\n\nThis file contains properties of locally integrable functions and of integrability results\non compact sets.\n\n## Main statements\n\n* `continuous.locally_integrable`: A continuous function is locally integrable.\n\n-/\n\nopen measure_theory measure_theory.measure set function topological_space\nopen_locale topological_space interval\n\nvariables {X Y E : Type*} [measurable_space X] [topological_space X]\nvariables [measurable_space Y] [topological_space Y]\nvariables [normed_group E] {f : X → E} {μ : measure X}\n\nnamespace measure_theory\n\n/-- A function `f : X → E` is locally integrable if it is integrable on all compact sets.\n  See `measure_theory.locally_integrable_iff` for the justification of this name. -/\ndef locally_integrable (f : X → E) (μ : measure X . volume_tac) : Prop :=\n∀ ⦃K⦄, is_compact K → integrable_on f K μ\n\nlemma integrable.locally_integrable (hf : integrable f μ) : locally_integrable f μ :=\nλ K hK, hf.integrable_on\n\nlemma locally_integrable.ae_strongly_measurable [sigma_compact_space X]\n  (hf : locally_integrable f μ) :\n  ae_strongly_measurable f μ :=\nbegin\n  rw [← @restrict_univ _ _ μ, ← Union_compact_covering, ae_strongly_measurable_Union_iff],\n  exact λ i, (hf $ is_compact_compact_covering X i).ae_strongly_measurable\nend\n\n\n\nsection real\nvariables [opens_measurable_space X] {A K : set X} {g g' : X → ℝ}\n\nlemma integrable_on.mul_continuous_on_of_subset\n  (hg : integrable_on g A μ) (hg' : continuous_on g' K)\n  (hA : measurable_set A) (hK : is_compact K) (hAK : A ⊆ K) :\n  integrable_on (λ x, g x * g' x) A μ :=\nbegin\n  rcases is_compact.exists_bound_of_continuous_on hK hg' with ⟨C, hC⟩,\n  rw [integrable_on, ← mem_ℒp_one_iff_integrable] at hg ⊢,\n  have : ∀ᵐ x ∂(μ.restrict A), ∥g x * g' x∥ ≤ C * ∥g x∥,\n  { filter_upwards [ae_restrict_mem hA] with x hx,\n    rw [real.norm_eq_abs, abs_mul, mul_comm, real.norm_eq_abs],\n    apply mul_le_mul_of_nonneg_right (hC x (hAK hx)) (abs_nonneg _), },\n  exact mem_ℒp.of_le_mul hg (hg.ae_strongly_measurable.ae_measurable.mul\n    ((hg'.mono hAK).ae_measurable hA)).ae_strongly_measurable this,\nend\n\nlemma integrable_on.mul_continuous_on [t2_space X]\n  (hg : integrable_on g K μ) (hg' : continuous_on g' K) (hK : is_compact K) :\n  integrable_on (λ x, g x * g' x) K μ :=\nhg.mul_continuous_on_of_subset hg' hK.measurable_set hK (subset.refl _)\n\nlemma integrable_on.continuous_on_mul_of_subset\n  (hg : continuous_on g K) (hg' : integrable_on g' A μ)\n  (hK : is_compact K) (hA : measurable_set A) (hAK : A ⊆ K) :\n  integrable_on (λ x, g x * g' x) A μ :=\nby simpa [mul_comm] using hg'.mul_continuous_on_of_subset hg hA hK hAK\n\nlemma integrable_on.continuous_on_mul [t2_space X]\n  (hg : continuous_on g K) (hg' : integrable_on g' K μ) (hK : is_compact K) :\n  integrable_on (λ x, g x * g' x) K μ :=\nintegrable_on.continuous_on_mul_of_subset hg hg' hK hK.measurable_set subset.rfl\n\nend real\n\nend measure_theory\nopen measure_theory\n\n/-- If a function is integrable at `𝓝[s] x` for each point `x` of a compact set `s`, then it is\nintegrable on `s`. -/\nlemma is_compact.integrable_on_of_nhds_within {K : set X} (hK : is_compact K)\n  (hf : ∀ x ∈ K, integrable_at_filter f (𝓝[K] x) μ) : integrable_on f K μ :=\nis_compact.induction_on hK integrable_on_empty (λ s t hst ht, ht.mono_set hst)\n  (λ s t hs ht, hs.union ht) hf\n\nsection borel\n\nvariables [opens_measurable_space X] [metrizable_space X] [is_locally_finite_measure μ]\nvariables {K : set X} {a b : X}\n\n/-- A function `f` continuous on a compact set `K` is integrable on this set with respect to any\nlocally finite measure. -/\nlemma continuous_on.integrable_on_compact (hK : is_compact K) (hf : continuous_on f K) :\n  integrable_on f K μ :=\nbegin\n  letI := metrizable_space_metric X,\n  apply hK.integrable_on_of_nhds_within (λ x hx, _),\n  exact hf.integrable_at_nhds_within_of_is_separable hK.measurable_set hK.is_separable hx,\nend\n\n/-- A continuous function `f` is locally integrable with respect to any locally finite measure. -/\nlemma continuous.locally_integrable (hf : continuous f) : locally_integrable f μ :=\nλ s hs, hf.continuous_on.integrable_on_compact hs\n\nlemma continuous_on.integrable_on_Icc [preorder X] [compact_Icc_space X]\n  (hf : continuous_on f (Icc a b)) : integrable_on f (Icc a b) μ :=\nhf.integrable_on_compact is_compact_Icc\n\nlemma continuous.integrable_on_Icc [preorder X] [compact_Icc_space X] (hf : continuous f) :\n  integrable_on f (Icc a b) μ :=\nhf.locally_integrable is_compact_Icc\n\nlemma continuous.integrable_on_Ioc [preorder X] [compact_Icc_space X] (hf : continuous f) :\n  integrable_on f (Ioc a b) μ :=\nhf.integrable_on_Icc.mono_set Ioc_subset_Icc_self\n\nlemma continuous_on.integrable_on_interval [linear_order X] [compact_Icc_space X]\n  (hf : continuous_on f [a, b]) : integrable_on f [a, b] μ :=\nhf.integrable_on_Icc\n\nlemma continuous.integrable_on_interval [linear_order X] [compact_Icc_space X] (hf : continuous f) :\n  integrable_on f [a, b] μ :=\nhf.integrable_on_Icc\n\nlemma continuous.integrable_on_interval_oc [linear_order X] [compact_Icc_space X]\n  (hf : continuous f) : integrable_on f (Ι a b) μ :=\nhf.integrable_on_Ioc\n\n/-- A continuous function with compact support is integrable on the whole space. -/\nlemma continuous.integrable_of_has_compact_support\n  (hf : continuous f) (hcf : has_compact_support f) : integrable f μ :=\n(integrable_on_iff_integable_of_support_subset (subset_tsupport f) measurable_set_closure).mp $\n  hf.locally_integrable hcf\n\nend borel\n\nsection monotone\n\nvariables [borel_space X] [metrizable_space X]\n  [conditionally_complete_linear_order X] [conditionally_complete_linear_order E]\n  [order_topology X] [order_topology E] [second_countable_topology E]\n  [is_locally_finite_measure μ] {s : set X}\n\nlemma monotone_on.integrable_on_compact (hs : is_compact s) (hmono : monotone_on f s) :\n  integrable_on f s μ :=\nbegin\n  borelize E,\n  obtain rfl | h := s.eq_empty_or_nonempty,\n  { exact integrable_on_empty },\n  have hbelow : bdd_below (f '' s) :=\n    ⟨f (Inf s), λ x ⟨y, hy, hyx⟩, hyx ▸ hmono (hs.Inf_mem h) hy (cInf_le hs.bdd_below hy)⟩,\n  have habove : bdd_above (f '' s) :=\n    ⟨f (Sup s), λ x ⟨y, hy, hyx⟩, hyx ▸ hmono hy (hs.Sup_mem h) (le_cSup hs.bdd_above hy)⟩,\n  have : metric.bounded (f '' s) := metric.bounded_of_bdd_above_of_bdd_below habove hbelow,\n  rcases bounded_iff_forall_norm_le.mp this with ⟨C, hC⟩,\n  refine integrable.mono' (continuous_const.locally_integrable hs)\n    (ae_measurable_restrict_of_monotone_on hs.measurable_set hmono).ae_strongly_measurable\n    ((ae_restrict_iff' hs.measurable_set).mpr $ ae_of_all _ $\n      λ y hy, hC (f y) (mem_image_of_mem f hy)),\nend\n\nlemma antitone_on.integrable_on_compact (hs : is_compact s) (hanti : antitone_on f s) :\n  integrable_on f s μ :=\n@monotone_on.integrable_on_compact X (order_dual E) _ _ _ _ _ _ _ _ _ _ _ _ _ _ hs hanti\n\nlemma monotone.locally_integrable (hmono : monotone f) : locally_integrable f μ :=\nλ s hs, monotone_on.integrable_on_compact hs (λ x y _ _ hxy, hmono hxy)\n\nlemma antitone.locally_integrable (hanti : antitone f) : locally_integrable f μ :=\n@monotone.locally_integrable X (order_dual E) _ _ _ _ _ _ _ _ _ _ _ _ _ hanti\n\nend monotone\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/measure_theory/function/locally_integrable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.49191992294364517}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n\n! This file was ported from Lean 3 source module ring_theory.subsemiring.basic\n! leanprover-community/mathlib commit feb99064803fd3108e37c18b0f77d0a8344677a3\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Module.Basic\nimport Mathlib.Algebra.Ring.Equiv\nimport Mathlib.Algebra.Ring.Prod\nimport Mathlib.Algebra.Order.Ring.InjSurj\nimport Mathlib.Algebra.GroupRingAction.Subobjects\nimport Mathlib.Data.Set.Finite\nimport Mathlib.GroupTheory.Submonoid.Centralizer\nimport Mathlib.GroupTheory.Submonoid.Membership\n\n/-!\n# Bundled subsemirings\n\nWe define bundled subsemirings and some standard constructions: `CompleteLattice` structure,\n`Subtype` and `inclusion` ring homomorphisms, subsemiring `map`, `comap` and range (`rangeS`) of\na `RingHom` etc.\n-/\n\n\nopen BigOperators\n\nuniverse u v w\n\nsection AddSubmonoidWithOneClass\n\n/-- `AddSubmonoidWithOneClass S R` says `S` is a type of subsets `s ≤ R` that contain `0`, `1`,\nand are closed under `(+)` -/\nclass AddSubmonoidWithOneClass (S R : Type _) [AddMonoidWithOne R]\n  [SetLike S R] extends AddSubmonoidClass S R, OneMemClass S R : Prop\n#align add_submonoid_with_one_class AddSubmonoidWithOneClass\n\nvariable {S R : Type _} [AddMonoidWithOne R] [SetLike S R] (s : S)\n\ntheorem natCast_mem [AddSubmonoidWithOneClass S R] (n : ℕ) : (n : R) ∈ s := by\n  induction n <;> simp [zero_mem, add_mem, one_mem, *]\n#align nat_cast_mem natCast_mem\n\ninstance (priority := 74) AddSubmonoidWithOneClass.toAddMonoidWithOne\n    [AddSubmonoidWithOneClass S R] : AddMonoidWithOne s :=\n  { AddSubmonoidClass.toAddMonoid s with\n    one := ⟨_, one_mem s⟩\n    natCast := fun n => ⟨n, natCast_mem s n⟩\n    natCast_zero := Subtype.ext Nat.cast_zero\n    natCast_succ := fun _ => Subtype.ext (Nat.cast_succ _) }\n#align add_submonoid_with_one_class.to_add_monoid_with_one AddSubmonoidWithOneClass.toAddMonoidWithOne\n\nend AddSubmonoidWithOneClass\n\nvariable {R : Type u} {S : Type v} {T : Type w} [NonAssocSemiring R] (M : Submonoid R)\n\nsection SubsemiringClass\n\n/-- `SubsemiringClass S R` states that `S` is a type of subsets `s ⊆ R` that\nare both a multiplicative and an additive submonoid. -/\nclass SubsemiringClass (S : Type _) (R : Type u) [NonAssocSemiring R]\n  [SetLike S R] extends SubmonoidClass S R, AddSubmonoidClass S R : Prop\n#align subsemiring_class SubsemiringClass\n\n-- See note [lower instance priority]\ninstance (priority := 100) SubsemiringClass.addSubmonoidWithOneClass (S : Type _)\n    (R : Type u) [NonAssocSemiring R] [SetLike S R] [h : SubsemiringClass S R] :\n    AddSubmonoidWithOneClass S R :=\n  { h with }\n#align subsemiring_class.add_submonoid_with_one_class SubsemiringClass.addSubmonoidWithOneClass\n\nvariable [SetLike S R] [hSR : SubsemiringClass S R] (s : S)\n\ntheorem coe_nat_mem (n : ℕ) : (n : R) ∈ s := by\n  rw [← nsmul_one]\n  exact nsmul_mem (one_mem _) _\n#align coe_nat_mem coe_nat_mem\n\nnamespace SubsemiringClass\n\n-- Prefer subclasses of `NonAssocSemiring` over subclasses of `SubsemiringClass`.\n/-- A subsemiring of a `NonAssocSemiring` inherits a `NonAssocSemiring` structure -/\ninstance (priority := 75) toNonAssocSemiring : NonAssocSemiring s :=\n  Subtype.coe_injective.nonAssocSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_non_assoc_semiring SubsemiringClass.toNonAssocSemiring\n\ninstance nontrivial [Nontrivial R] : Nontrivial s :=\n  nontrivial_of_ne 0 1 fun H => zero_ne_one (congr_arg Subtype.val H)\n#align subsemiring_class.nontrivial SubsemiringClass.nontrivial\n\ninstance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s :=\n  Subtype.coe_injective.noZeroDivisors _ rfl fun _ _ => rfl\n#align subsemiring_class.no_zero_divisors SubsemiringClass.noZeroDivisors\n\n/-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/\ndef subtype : s →+* R :=\n  { SubmonoidClass.Subtype s, AddSubmonoidClass.Subtype s with toFun := (↑) }\n#align subsemiring_class.subtype SubsemiringClass.subtype\n\n@[simp]\ntheorem coe_subtype : (subtype s : s → R) = ((↑) : s → R) :=\n  rfl\n#align subsemiring_class.coe_subtype SubsemiringClass.coe_subtype\n\n-- Prefer subclasses of `Semiring` over subclasses of `SubsemiringClass`.\n/-- A subsemiring of a `Semiring` is a `Semiring`. -/\ninstance (priority := 75) toSemiring {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] :\n    Semiring s :=\n  Subtype.coe_injective.semiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_semiring SubsemiringClass.toSemiring\n\n@[simp, norm_cast]\ntheorem coe_pow {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] (x : s) (n : ℕ) :\n    ((x ^ n : s) : R) = (x : R) ^ n := by\n  induction' n with n ih\n  · simp\n  · simp [pow_succ, ih]\n#align subsemiring_class.coe_pow SubsemiringClass.coe_pow\n\n/-- A subsemiring of a `CommSemiring` is a `CommSemiring`. -/\ninstance toCommSemiring {R} [CommSemiring R] [SetLike S R] [SubsemiringClass S R] :\n    CommSemiring s :=\n  Subtype.coe_injective.commSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_comm_semiring SubsemiringClass.toCommSemiring\n\n/-- A subsemiring of an `OrderedSemiring` is an `OrderedSemiring`. -/\ninstance toOrderedSemiring {R} [OrderedSemiring R] [SetLike S R] [SubsemiringClass S R] :\n    OrderedSemiring s :=\n  Subtype.coe_injective.orderedSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_ordered_semiring SubsemiringClass.toOrderedSemiring\n\n/-- A subsemiring of an `StrictOrderedSemiring` is an `StrictOrderedSemiring`. -/\ninstance toStrictOrderedSemiring {R} [StrictOrderedSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : StrictOrderedSemiring s :=\n  Subtype.coe_injective.strictOrderedSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_strict_ordered_semiring SubsemiringClass.toStrictOrderedSemiring\n\n/-- A subsemiring of an `OrderedCommSemiring` is an `OrderedCommSemiring`. -/\ninstance toOrderedCommSemiring {R} [OrderedCommSemiring R] [SetLike S R] [SubsemiringClass S R] :\n    OrderedCommSemiring s :=\n  Subtype.coe_injective.orderedCommSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_ordered_comm_semiring SubsemiringClass.toOrderedCommSemiring\n\n/-- A subsemiring of an `StrictOrderedCommSemiring` is an `StrictOrderedCommSemiring`. -/\ninstance toStrictOrderedCommSemiring {R} [StrictOrderedCommSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : StrictOrderedCommSemiring s :=\n  Subtype.coe_injective.strictOrderedCommSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_strict_ordered_comm_semiring SubsemiringClass.toStrictOrderedCommSemiring\n\n/-- A subsemiring of a `LinearOrderedSemiring` is a `LinearOrderedSemiring`. -/\ninstance toLinearOrderedSemiring {R} [LinearOrderedSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : LinearOrderedSemiring s :=\n  Subtype.coe_injective.linearOrderedSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring_class.to_linear_ordered_semiring SubsemiringClass.toLinearOrderedSemiring\n\n/-- A subsemiring of a `LinearOrderedCommSemiring` is a `LinearOrderedCommSemiring`. -/\ninstance toLinearOrderedCommSemiring {R} [LinearOrderedCommSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : LinearOrderedCommSemiring s :=\n  Subtype.coe_injective.linearOrderedCommSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring_class.to_linear_ordered_comm_semiring SubsemiringClass.toLinearOrderedCommSemiring\n\nend SubsemiringClass\n\nend SubsemiringClass\n\nvariable [NonAssocSemiring S] [NonAssocSemiring T]\n\n/-- A subsemiring of a semiring `R` is a subset `s` that is both a multiplicative and an additive\nsubmonoid. -/\nstructure Subsemiring (R : Type u) [NonAssocSemiring R] extends Submonoid R, AddSubmonoid R\n#align subsemiring Subsemiring\n\n/-- Reinterpret a `Subsemiring` as a `Submonoid`. -/\nadd_decl_doc Subsemiring.toSubmonoid\n\n/-- Reinterpret a `Subsemiring` as an `AddSubmonoid`. -/\nadd_decl_doc Subsemiring.toAddSubmonoid\n\nnamespace Subsemiring\n\ninstance : SetLike (Subsemiring R) R\n    where\n  coe s := s.carrier\n  coe_injective' p q h := by cases p; cases q; congr; exact SetLike.coe_injective' h\n\ninstance : SubsemiringClass (Subsemiring R) R\n    where\n  zero_mem := zero_mem'\n  add_mem {s} := AddSubsemigroup.add_mem' s.toAddSubmonoid.toAddSubsemigroup\n  one_mem {s} := Submonoid.one_mem' s.toSubmonoid\n  mul_mem {s} := Subsemigroup.mul_mem' s.toSubmonoid.toSubsemigroup\n\n@[simp]\ntheorem mem_toSubmonoid {s : Subsemiring R} {x : R} : x ∈ s.toSubmonoid ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_to_submonoid Subsemiring.mem_toSubmonoid\n\n-- `@[simp]` -- Porting note: simp can prove this\ntheorem mem_carrier {s : Subsemiring R} {x : R} : x ∈ s.carrier ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_carrier Subsemiring.mem_carrier\n\n/-- Two subsemirings are equal if they have the same elements. -/\n@[ext]\ntheorem ext {S T : Subsemiring R} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=\n  SetLike.ext h\n#align subsemiring.ext Subsemiring.ext\n\n/-- Copy of a subsemiring with a new `carrier` equal to the old one. Useful to fix definitional\nequalities.-/\nprotected def copy (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : Subsemiring R :=\n  { S.toAddSubmonoid.copy s hs, S.toSubmonoid.copy s hs with carrier := s }\n#align subsemiring.copy Subsemiring.copy\n\n@[simp]\ntheorem coe_copy (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : (S.copy s hs : Set R) = s :=\n  rfl\n#align subsemiring.coe_copy Subsemiring.coe_copy\n\ntheorem copy_eq (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : S.copy s hs = S :=\n  SetLike.coe_injective hs\n#align subsemiring.copy_eq Subsemiring.copy_eq\n\ntheorem toSubmonoid_injective : Function.Injective (toSubmonoid : Subsemiring R → Submonoid R)\n  | _, _, h => ext (SetLike.ext_iff.mp h : _)\n#align subsemiring.to_submonoid_injective Subsemiring.toSubmonoid_injective\n\n@[mono]\ntheorem toSubmonoid_strictMono : StrictMono (toSubmonoid : Subsemiring R → Submonoid R) :=\n  fun _ _ => id\n#align subsemiring.to_submonoid_strict_mono Subsemiring.toSubmonoid_strictMono\n\n@[mono]\ntheorem toSubmonoid_mono : Monotone (toSubmonoid : Subsemiring R → Submonoid R) :=\n  toSubmonoid_strictMono.monotone\n#align subsemiring.to_submonoid_mono Subsemiring.toSubmonoid_mono\n\ntheorem toAddSubmonoid_injective :\n    Function.Injective (toAddSubmonoid : Subsemiring R → AddSubmonoid R)\n  | _, _, h => ext (SetLike.ext_iff.mp h : _)\n#align subsemiring.to_add_submonoid_injective Subsemiring.toAddSubmonoid_injective\n\n@[mono]\ntheorem toAddSubmonoid_strictMono : StrictMono (toAddSubmonoid : Subsemiring R → AddSubmonoid R) :=\n  fun _ _ => id\n#align subsemiring.to_add_submonoid_strict_mono Subsemiring.toAddSubmonoid_strictMono\n\n@[mono]\ntheorem toAddSubmonoid_mono : Monotone (toAddSubmonoid : Subsemiring R → AddSubmonoid R) :=\n  toAddSubmonoid_strictMono.monotone\n#align subsemiring.to_add_submonoid_mono Subsemiring.toAddSubmonoid_mono\n\n/-- Construct a `Subsemiring R` from a set `s`, a submonoid `sm`, and an additive\nsubmonoid `sa` such that `x ∈ s ↔ x ∈ sm ↔ x ∈ sa`. -/\nprotected def mk' (s : Set R) (sm : Submonoid R) (hm : ↑sm = s) (sa : AddSubmonoid R)\n    (ha : ↑sa = s) : Subsemiring R where\n  carrier := s\n  zero_mem' := by exact ha ▸ sa.zero_mem\n  one_mem' := by exact hm ▸ sm.one_mem\n  add_mem' {x y} := by simpa only [← ha] using sa.add_mem\n  mul_mem' {x y} := by simpa only [← hm] using sm.mul_mem\n#align subsemiring.mk' Subsemiring.mk'\n\n@[simp]\ntheorem coe_mk' {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R} (ha : ↑sa = s) :\n    (Subsemiring.mk' s sm hm sa ha : Set R) = s :=\n  rfl\n#align subsemiring.coe_mk' Subsemiring.coe_mk'\n\n@[simp]\ntheorem mem_mk' {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R} (ha : ↑sa = s)\n    {x : R} : x ∈ Subsemiring.mk' s sm hm sa ha ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_mk' Subsemiring.mem_mk'\n\n@[simp]\ntheorem mk'_toSubmonoid {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R}\n    (ha : ↑sa = s) : (Subsemiring.mk' s sm hm sa ha).toSubmonoid = sm :=\n  SetLike.coe_injective hm.symm\n#align subsemiring.mk'_to_submonoid Subsemiring.mk'_toSubmonoid\n\n@[simp]\ntheorem mk'_toAddSubmonoid {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R}\n    (ha : ↑sa = s) : (Subsemiring.mk' s sm hm sa ha).toAddSubmonoid = sa :=\n  SetLike.coe_injective ha.symm\n#align subsemiring.mk'_to_add_submonoid Subsemiring.mk'_toAddSubmonoid\n\nend Subsemiring\n\nnamespace Subsemiring\n\nvariable (s : Subsemiring R)\n\n/-- A subsemiring contains the semiring's 1. -/\nprotected theorem one_mem : (1 : R) ∈ s :=\n  one_mem s\n#align subsemiring.one_mem Subsemiring.one_mem\n\n/-- A subsemiring contains the semiring's 0. -/\nprotected theorem zero_mem : (0 : R) ∈ s :=\n  zero_mem s\n#align subsemiring.zero_mem Subsemiring.zero_mem\n\n/-- A subsemiring is closed under multiplication. -/\nprotected theorem mul_mem {x y : R} : x ∈ s → y ∈ s → x * y ∈ s :=\n  mul_mem\n#align subsemiring.mul_mem Subsemiring.mul_mem\n\n/-- A subsemiring is closed under addition. -/\nprotected theorem add_mem {x y : R} : x ∈ s → y ∈ s → x + y ∈ s :=\n  add_mem\n#align subsemiring.add_mem Subsemiring.add_mem\n\n/-- Product of a list of elements in a `Subsemiring` is in the `Subsemiring`. -/\nnonrec theorem list_prod_mem {R : Type _} [Semiring R] (s : Subsemiring R) {l : List R} :\n    (∀ x ∈ l, x ∈ s) → l.prod ∈ s :=\n  list_prod_mem\n#align subsemiring.list_prod_mem Subsemiring.list_prod_mem\n\n/-- Sum of a list of elements in a `Subsemiring` is in the `Subsemiring`. -/\nprotected theorem list_sum_mem {l : List R} : (∀ x ∈ l, x ∈ s) → l.sum ∈ s :=\n  list_sum_mem\n#align subsemiring.list_sum_mem Subsemiring.list_sum_mem\n\n/-- Product of a multiset of elements in a `Subsemiring` of a `CommSemiring`\n    is in the `Subsemiring`. -/\nprotected theorem multiset_prod_mem {R} [CommSemiring R] (s : Subsemiring R) (m : Multiset R) :\n    (∀ a ∈ m, a ∈ s) → m.prod ∈ s :=\n  multiset_prod_mem m\n#align subsemiring.multiset_prod_mem Subsemiring.multiset_prod_mem\n\n/-- Sum of a multiset of elements in a `Subsemiring` of a `Semiring` is\nin the `add_subsemiring`. -/\nprotected theorem multiset_sum_mem (m : Multiset R) : (∀ a ∈ m, a ∈ s) → m.sum ∈ s :=\n  multiset_sum_mem m\n#align subsemiring.multiset_sum_mem Subsemiring.multiset_sum_mem\n\n/-- Product of elements of a subsemiring of a `CommSemiring` indexed by a `Finset` is in the\n    subsemiring. -/\nprotected theorem prod_mem {R : Type _} [CommSemiring R] (s : Subsemiring R) {ι : Type _}\n    {t : Finset ι} {f : ι → R} (h : ∀ c ∈ t, f c ∈ s) : (∏ i in t, f i) ∈ s :=\n  prod_mem h\n#align subsemiring.prod_mem Subsemiring.prod_mem\n\n/-- Sum of elements in an `Subsemiring` of an `Semiring` indexed by a `Finset`\nis in the `add_subsemiring`. -/\nprotected theorem sum_mem (s : Subsemiring R) {ι : Type _} {t : Finset ι} {f : ι → R}\n    (h : ∀ c ∈ t, f c ∈ s) : (∑ i in t, f i) ∈ s :=\n  sum_mem h\n#align subsemiring.sum_mem Subsemiring.sum_mem\n\n/-- A subsemiring of a `NonAssocSemiring` inherits a `NonAssocSemiring` structure -/\ninstance toNonAssocSemiring : NonAssocSemiring s :=\n  -- Porting note: this used to be a specialized instance which needed to be expensively unified.\n  SubsemiringClass.toNonAssocSemiring _\n#align subsemiring.to_non_assoc_semiring Subsemiring.toNonAssocSemiring\n\n@[simp, norm_cast]\ntheorem coe_one : ((1 : s) : R) = (1 : R) :=\n  rfl\n#align subsemiring.coe_one Subsemiring.coe_one\n\n@[simp, norm_cast]\ntheorem coe_zero : ((0 : s) : R) = (0 : R) :=\n  rfl\n#align subsemiring.coe_zero Subsemiring.coe_zero\n\n@[simp, norm_cast]\ntheorem coe_add (x y : s) : ((x + y : s) : R) = (x + y : R) :=\n  rfl\n#align subsemiring.coe_add Subsemiring.coe_add\n\n@[simp, norm_cast]\ntheorem coe_mul (x y : s) : ((x * y : s) : R) = (x * y : R) :=\n  rfl\n#align subsemiring.coe_mul Subsemiring.coe_mul\n\ninstance nontrivial [Nontrivial R] : Nontrivial s :=\n  nontrivial_of_ne 0 1 fun H => zero_ne_one (congr_arg Subtype.val H)\n#align subsemiring.nontrivial Subsemiring.nontrivial\n\nprotected theorem pow_mem {R : Type _} [Semiring R] (s : Subsemiring R) {x : R} (hx : x ∈ s)\n    (n : ℕ) : x ^ n ∈ s :=\n  pow_mem hx n\n#align subsemiring.pow_mem Subsemiring.pow_mem\n\ninstance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s where\n  eq_zero_or_eq_zero_of_mul_eq_zero {_ _} h :=\n    (eq_zero_or_eq_zero_of_mul_eq_zero <| Subtype.ext_iff.mp h).imp Subtype.eq Subtype.eq\n#align subsemiring.no_zero_divisors Subsemiring.noZeroDivisors\n\n/-- A subsemiring of a `Semiring` is a `Semiring`. -/\ninstance toSemiring {R} [Semiring R] (s : Subsemiring R) : Semiring s :=\n  { s.toNonAssocSemiring, s.toSubmonoid.toMonoid with }\n#align subsemiring.to_semiring Subsemiring.toSemiring\n\n@[simp, norm_cast]\ntheorem coe_pow {R} [Semiring R] (s : Subsemiring R) (x : s) (n : ℕ) :\n    ((x ^ n : s) : R) = (x : R) ^ n := by\n  induction' n with n ih\n  · simp\n  · simp [pow_succ, ih]\n#align subsemiring.coe_pow Subsemiring.coe_pow\n\n/-- A subsemiring of a `CommSemiring` is a `CommSemiring`. -/\ninstance toCommSemiring {R} [CommSemiring R] (s : Subsemiring R) : CommSemiring s :=\n  { s.toSemiring with mul_comm := fun _ _ => Subtype.eq <| mul_comm _ _ }\n#align subsemiring.to_comm_semiring Subsemiring.toCommSemiring\n\n/-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/\ndef subtype : s →+* R :=\n  { s.toSubmonoid.subtype, s.toAddSubmonoid.subtype with toFun := (↑) }\n#align subsemiring.subtype Subsemiring.subtype\n\n@[simp]\ntheorem coe_subtype : ⇑s.subtype = ((↑) : s → R) :=\n  rfl\n#align subsemiring.coe_subtype Subsemiring.coe_subtype\n\n/-- A subsemiring of an `OrderedSemiring` is an `OrderedSemiring`. -/\ninstance toOrderedSemiring {R} [OrderedSemiring R] (s : Subsemiring R) : OrderedSemiring s :=\n  Subtype.coe_injective.orderedSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_ordered_semiring Subsemiring.toOrderedSemiring\n\n/-- A subsemiring of a `StrictOrderedSemiring` is a `StrictOrderedSemiring`. -/\ninstance toStrictOrderedSemiring {R} [StrictOrderedSemiring R] (s : Subsemiring R) :\n    StrictOrderedSemiring s :=\n  Subtype.coe_injective.strictOrderedSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_strict_ordered_semiring Subsemiring.toStrictOrderedSemiring\n\n/-- A subsemiring of an `OrderedCommSemiring` is an `OrderedCommSemiring`. -/\ninstance toOrderedCommSemiring {R} [OrderedCommSemiring R] (s : Subsemiring R) :\n    OrderedCommSemiring s :=\n  Subtype.coe_injective.orderedCommSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_ordered_comm_semiring Subsemiring.toOrderedCommSemiring\n\n/-- A subsemiring of a `StrictOrderedCommSemiring` is a `StrictOrderedCommSemiring`. -/\ninstance toStrictOrderedCommSemiring {R} [StrictOrderedCommSemiring R] (s : Subsemiring R) :\n    StrictOrderedCommSemiring s :=\n  Subtype.coe_injective.strictOrderedCommSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_strict_ordered_comm_semiring Subsemiring.toStrictOrderedCommSemiring\n\n/-- A subsemiring of a `LinearOrderedSemiring` is a `LinearOrderedSemiring`. -/\ninstance toLinearOrderedSemiring {R} [LinearOrderedSemiring R] (s : Subsemiring R) :\n    LinearOrderedSemiring s :=\n  Subtype.coe_injective.linearOrderedSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring.to_linear_ordered_semiring Subsemiring.toLinearOrderedSemiring\n\n/-- A subsemiring of a `LinearOrderedCommSemiring` is a `LinearOrderedCommSemiring`. -/\ninstance toLinearOrderedCommSemiring {R} [LinearOrderedCommSemiring R] (s : Subsemiring R) :\n    LinearOrderedCommSemiring s :=\n  Subtype.coe_injective.linearOrderedCommSemiring (↑) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring.to_linear_ordered_comm_semiring Subsemiring.toLinearOrderedCommSemiring\n\nprotected theorem nsmul_mem {x : R} (hx : x ∈ s) (n : ℕ) : n • x ∈ s :=\n  nsmul_mem hx n\n#align subsemiring.nsmul_mem Subsemiring.nsmul_mem\n\n@[simp]\ntheorem coe_toSubmonoid (s : Subsemiring R) : (s.toSubmonoid : Set R) = s :=\n  rfl\n#align subsemiring.coe_to_submonoid Subsemiring.coe_toSubmonoid\n\n-- Porting note: adding this as `simp`-normal form for `coe_toAddSubmonoid`\n@[simp]\ntheorem coe_carrier_toSubmonoid (s : Subsemiring R) : (s.toSubmonoid.carrier : Set R) = s :=\n  rfl\n\n-- Porting note: can be proven using `SetLike` so removing `@[simp]`\ntheorem mem_toAddSubmonoid {s : Subsemiring R} {x : R} : x ∈ s.toAddSubmonoid ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_to_add_submonoid Subsemiring.mem_toAddSubmonoid\n\n-- Porting note: new normal form is `coe_carrier_toSubmonoid` so removing `@[simp]`\ntheorem coe_toAddSubmonoid (s : Subsemiring R) : (s.toAddSubmonoid : Set R) = s :=\n  rfl\n#align subsemiring.coe_to_add_submonoid Subsemiring.coe_toAddSubmonoid\n\n/-- The subsemiring `R` of the semiring `R`. -/\ninstance : Top (Subsemiring R) :=\n  ⟨{ (⊤ : Submonoid R), (⊤ : AddSubmonoid R) with }⟩\n\n@[simp]\ntheorem mem_top (x : R) : x ∈ (⊤ : Subsemiring R) :=\n  Set.mem_univ x\n#align subsemiring.mem_top Subsemiring.mem_top\n\n@[simp]\ntheorem coe_top : ((⊤ : Subsemiring R) : Set R) = Set.univ :=\n  rfl\n#align subsemiring.coe_top Subsemiring.coe_top\n\n/-- The ring equiv between the top element of `Subsemiring R` and `R`. -/\n@[simps]\ndef topEquiv : (⊤ : Subsemiring R) ≃+* R where\n  toFun r := r\n  invFun r := ⟨r, Subsemiring.mem_top r⟩\n  left_inv _ := rfl\n  right_inv _ := rfl\n  map_mul' := (⊤ : Subsemiring R).coe_mul\n  map_add' := (⊤ : Subsemiring R).coe_add\n#align subsemiring.top_equiv Subsemiring.topEquiv\n\n/-- The preimage of a subsemiring along a ring homomorphism is a subsemiring. -/\ndef comap (f : R →+* S) (s : Subsemiring S) : Subsemiring R :=\n  { s.toSubmonoid.comap (f : R →* S), s.toAddSubmonoid.comap (f : R →+ S) with carrier := f ⁻¹' s }\n#align subsemiring.comap Subsemiring.comap\n\n@[simp]\ntheorem coe_comap (s : Subsemiring S) (f : R →+* S) : (s.comap f : Set R) = f ⁻¹' s :=\n  rfl\n#align subsemiring.coe_comap Subsemiring.coe_comap\n\n@[simp]\ntheorem mem_comap {s : Subsemiring S} {f : R →+* S} {x : R} : x ∈ s.comap f ↔ f x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_comap Subsemiring.mem_comap\n\ntheorem comap_comap (s : Subsemiring T) (g : S →+* T) (f : R →+* S) :\n    (s.comap g).comap f = s.comap (g.comp f) :=\n  rfl\n#align subsemiring.comap_comap Subsemiring.comap_comap\n\n/-- The image of a subsemiring along a ring homomorphism is a subsemiring. -/\ndef map (f : R →+* S) (s : Subsemiring R) : Subsemiring S :=\n  { s.toSubmonoid.map (f : R →* S), s.toAddSubmonoid.map (f : R →+ S) with carrier := f '' s }\n#align subsemiring.map Subsemiring.map\n\n@[simp]\ntheorem coe_map (f : R →+* S) (s : Subsemiring R) : (s.map f : Set S) = f '' s :=\n  rfl\n#align subsemiring.coe_map Subsemiring.coe_map\n\n@[simp]\ntheorem mem_map {f : R →+* S} {s : Subsemiring R} {y : S} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=\n  by\n    -- Porting note: was `exact Set.mem_image_iff_bex`\n    convert Set.mem_image_iff_bex (f := f) (s := s.carrier) (y := y) using 1\n    simp\n\n#align subsemiring.mem_map Subsemiring.mem_map\n\n@[simp]\ntheorem map_id : s.map (RingHom.id R) = s :=\n  SetLike.coe_injective <| Set.image_id _\n#align subsemiring.map_id Subsemiring.map_id\n\ntheorem map_map (g : S →+* T) (f : R →+* S) : (s.map f).map g = s.map (g.comp f) :=\n  SetLike.coe_injective <| Set.image_image _ _ _\n#align subsemiring.map_map Subsemiring.map_map\n\ntheorem map_le_iff_le_comap {f : R →+* S} {s : Subsemiring R} {t : Subsemiring S} :\n    s.map f ≤ t ↔ s ≤ t.comap f :=\n  Set.image_subset_iff\n#align subsemiring.map_le_iff_le_comap Subsemiring.map_le_iff_le_comap\n\ntheorem gc_map_comap (f : R →+* S) : GaloisConnection (map f) (comap f) := fun _ _ =>\n  map_le_iff_le_comap\n#align subsemiring.gc_map_comap Subsemiring.gc_map_comap\n\n/-- A subsemiring is isomorphic to its image under an injective function -/\nnoncomputable def equivMapOfInjective (f : R →+* S) (hf : Function.Injective f) : s ≃+* s.map f :=\n  { Equiv.Set.image f s hf with\n    map_mul' := fun _ _ => Subtype.ext (f.map_mul _ _)\n    map_add' := fun _ _ => Subtype.ext (f.map_add _ _) }\n#align subsemiring.equiv_map_of_injective Subsemiring.equivMapOfInjective\n\n@[simp]\ntheorem coe_equivMapOfInjective_apply (f : R →+* S) (hf : Function.Injective f) (x : s) :\n    (equivMapOfInjective s f hf x : S) = f x :=\n  rfl\n#align subsemiring.coe_equiv_map_of_injective_apply Subsemiring.coe_equivMapOfInjective_apply\n\nend Subsemiring\n\nnamespace RingHom\n\nvariable (g : S →+* T) (f : R →+* S)\n\n/-- The range of a ring homomorphism is a subsemiring. See Note [range copy pattern]. -/\ndef rangeS : Subsemiring S :=\n  ((⊤ : Subsemiring R).map f).copy (Set.range f) Set.image_univ.symm\n#align ring_hom.srange RingHom.rangeS\n\n@[simp]\ntheorem coe_rangeS : (f.rangeS : Set S) = Set.range f :=\n  rfl\n#align ring_hom.coe_srange RingHom.coe_rangeS\n\n@[simp]\ntheorem mem_rangeS {f : R →+* S} {y : S} : y ∈ f.rangeS ↔ ∃ x, f x = y :=\n  Iff.rfl\n#align ring_hom.mem_srange RingHom.mem_rangeS\n\ntheorem rangeS_eq_map (f : R →+* S) : f.rangeS = (⊤ : Subsemiring R).map f := by\n  ext\n  simp\n#align ring_hom.srange_eq_map RingHom.rangeS_eq_map\n\ntheorem mem_rangeS_self (f : R →+* S) (x : R) : f x ∈ f.rangeS :=\n  mem_rangeS.mpr ⟨x, rfl⟩\n#align ring_hom.mem_srange_self RingHom.mem_rangeS_self\n\ntheorem map_rangeS : f.rangeS.map g = (g.comp f).rangeS := by\n  simpa only [rangeS_eq_map] using (⊤ : Subsemiring R).map_map g f\n#align ring_hom.map_srange RingHom.map_rangeS\n\n/-- The range of a morphism of semirings is a fintype, if the domain is a fintype.\nNote: this instance can form a diamond with `Subtype.fintype` in the\n  presence of `Fintype S`.-/\ninstance fintypeRangeS [Fintype R] [DecidableEq S] (f : R →+* S) : Fintype (rangeS f) :=\n  Set.fintypeRange f\n#align ring_hom.fintype_srange RingHom.fintypeRangeS\n\nend RingHom\n\nnamespace Subsemiring\n\ninstance : Bot (Subsemiring R) :=\n  ⟨(Nat.castRingHom R).rangeS⟩\n\ninstance : Inhabited (Subsemiring R) :=\n  ⟨⊥⟩\n\ntheorem coe_bot : ((⊥ : Subsemiring R) : Set R) = Set.range ((↑) : ℕ → R) :=\n  (Nat.castRingHom R).coe_rangeS\n#align subsemiring.coe_bot Subsemiring.coe_bot\n\ntheorem mem_bot {x : R} : x ∈ (⊥ : Subsemiring R) ↔ ∃ n : ℕ, ↑n = x :=\n  RingHom.mem_rangeS\n#align subsemiring.mem_bot Subsemiring.mem_bot\n\n/-- The inf of two subsemirings is their intersection. -/\ninstance : Inf (Subsemiring R) :=\n  ⟨fun s t =>\n    { s.toSubmonoid ⊓ t.toSubmonoid, s.toAddSubmonoid ⊓ t.toAddSubmonoid with carrier := s ∩ t }⟩\n\n@[simp]\ntheorem coe_inf (p p' : Subsemiring R) : ((p ⊓ p' : Subsemiring R) : Set R) = (p : Set R) ∩ p' :=\n  rfl\n#align subsemiring.coe_inf Subsemiring.coe_inf\n\n@[simp]\ntheorem mem_inf {p p' : Subsemiring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=\n  Iff.rfl\n#align subsemiring.mem_inf Subsemiring.mem_inf\n\ninstance : InfSet (Subsemiring R) :=\n  ⟨fun s =>\n    Subsemiring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, Subsemiring.toSubmonoid t) (by simp)\n      (⨅ t ∈ s, Subsemiring.toAddSubmonoid t)\n      (by simp)⟩\n\n@[simp, norm_cast]\ntheorem coe_infₛ (S : Set (Subsemiring R)) : ((infₛ S : Subsemiring R) : Set R) = ⋂ s ∈ S, ↑s :=\n  rfl\n#align subsemiring.coe_Inf Subsemiring.coe_infₛ\n\ntheorem mem_infₛ {S : Set (Subsemiring R)} {x : R} : x ∈ infₛ S ↔ ∀ p ∈ S, x ∈ p :=\n  Set.mem_interᵢ₂\n#align subsemiring.mem_Inf Subsemiring.mem_infₛ\n\n@[simp]\ntheorem infₛ_toSubmonoid (s : Set (Subsemiring R)) :\n    (infₛ s).toSubmonoid = ⨅ t ∈ s, Subsemiring.toSubmonoid t :=\n  mk'_toSubmonoid _ _\n#align subsemiring.Inf_to_submonoid Subsemiring.infₛ_toSubmonoid\n\n@[simp]\ntheorem infₛ_toAddSubmonoid (s : Set (Subsemiring R)) :\n    (infₛ s).toAddSubmonoid = ⨅ t ∈ s, Subsemiring.toAddSubmonoid t :=\n  mk'_toAddSubmonoid _ _\n#align subsemiring.Inf_to_add_submonoid Subsemiring.infₛ_toAddSubmonoid\n\n/-- Subsemirings of a semiring form a complete lattice. -/\ninstance : CompleteLattice (Subsemiring R) :=\n  { completeLatticeOfInf (Subsemiring R) fun _ =>\n      IsGLB.of_image\n        (fun {s t : Subsemiring R} => show (s : Set R) ⊆ t ↔ s ≤ t from SetLike.coe_subset_coe)\n        isGLB_binfᵢ with\n    bot := ⊥\n    bot_le := fun s _ hx =>\n      let ⟨n, hn⟩ := mem_bot.1 hx\n      hn ▸ coe_nat_mem s n\n    top := ⊤\n    le_top := fun _ _ _ => trivial\n    inf := (· ⊓ ·)\n    inf_le_left := fun _ _ _ => And.left\n    inf_le_right := fun _ _ _ => And.right\n    le_inf := fun _ _ _ h₁ h₂ _ hx => ⟨h₁ hx, h₂ hx⟩ }\n\ntheorem eq_top_iff' (A : Subsemiring R) : A = ⊤ ↔ ∀ x : R, x ∈ A :=\n  eq_top_iff.trans ⟨fun h m => h <| mem_top m, fun h m _ => h m⟩\n#align subsemiring.eq_top_iff' Subsemiring.eq_top_iff'\n\nsection Center\n\n/-- The center of a semiring `R` is the set of elements that commute with everything in `R` -/\ndef center (R) [Semiring R] : Subsemiring R :=\n  { Submonoid.center R with\n    carrier := Set.center R\n    zero_mem' := Set.zero_mem_center R\n    add_mem' := Set.add_mem_center }\n#align subsemiring.center Subsemiring.center\n\ntheorem coe_center (R) [Semiring R] : ↑(center R) = Set.center R :=\n  rfl\n#align subsemiring.coe_center Subsemiring.coe_center\n\n@[simp]\ntheorem center_toSubmonoid (R) [Semiring R] : (center R).toSubmonoid = Submonoid.center R :=\n  rfl\n#align subsemiring.center_to_submonoid Subsemiring.center_toSubmonoid\n\ntheorem mem_center_iff {R} [Semiring R] {z : R} : z ∈ center R ↔ ∀ g, g * z = z * g :=\n  Iff.rfl\n#align subsemiring.mem_center_iff Subsemiring.mem_center_iff\n\ninstance decidableMemCenter {R} [Semiring R] [DecidableEq R] [Fintype R] :\n    DecidablePred (· ∈ center R) := fun _ => decidable_of_iff' _ mem_center_iff\n#align subsemiring.decidable_mem_center Subsemiring.decidableMemCenter\n\n@[simp]\ntheorem center_eq_top (R) [CommSemiring R] : center R = ⊤ :=\n  SetLike.coe_injective (Set.center_eq_univ R)\n#align subsemiring.center_eq_top Subsemiring.center_eq_top\n\n/-- The center is commutative. -/\ninstance commSemiring {R} [Semiring R] : CommSemiring (center R) :=\n  { Submonoid.center.commMonoid, (center R).toSemiring with }\n\nend Center\n\nsection Centralizer\n\n/-- The centralizer of a set as subsemiring. -/\ndef centralizer {R} [Semiring R] (s : Set R) : Subsemiring R :=\n  { Submonoid.centralizer s with\n    carrier := s.centralizer\n    zero_mem' := Set.zero_mem_centralizer _\n    add_mem' := Set.add_mem_centralizer }\n#align subsemiring.centralizer Subsemiring.centralizer\n\n@[simp, norm_cast]\ntheorem coe_centralizer {R} [Semiring R] (s : Set R) : (centralizer s : Set R) = s.centralizer :=\n  rfl\n#align subsemiring.coe_centralizer Subsemiring.coe_centralizer\n\ntheorem centralizer_toSubmonoid {R} [Semiring R] (s : Set R) :\n    (centralizer s).toSubmonoid = Submonoid.centralizer s :=\n  rfl\n#align subsemiring.centralizer_to_submonoid Subsemiring.centralizer_toSubmonoid\n\ntheorem mem_centralizer_iff {R} [Semiring R] {s : Set R} {z : R} :\n    z ∈ centralizer s ↔ ∀ g ∈ s, g * z = z * g :=\n  Iff.rfl\n#align subsemiring.mem_centralizer_iff Subsemiring.mem_centralizer_iff\n\ntheorem centralizer_le {R} [Semiring R] (s t : Set R) (h : s ⊆ t) : centralizer t ≤ centralizer s :=\n  Set.centralizer_subset h\n#align subsemiring.centralizer_le Subsemiring.centralizer_le\n\n@[simp]\ntheorem centralizer_univ {R} [Semiring R] : centralizer Set.univ = center R :=\n  SetLike.ext' (Set.centralizer_univ R)\n#align subsemiring.centralizer_univ Subsemiring.centralizer_univ\n\nend Centralizer\n\n/-- The `Subsemiring` generated by a set. -/\ndef closure (s : Set R) : Subsemiring R :=\n  infₛ { S | s ⊆ S }\n#align subsemiring.closure Subsemiring.closure\n\ntheorem mem_closure {x : R} {s : Set R} : x ∈ closure s ↔ ∀ S : Subsemiring R, s ⊆ S → x ∈ S :=\n  mem_infₛ\n#align subsemiring.mem_closure Subsemiring.mem_closure\n\n/-- The subsemiring generated by a set includes the set. -/\n@[simp]\ntheorem subset_closure {s : Set R} : s ⊆ closure s := fun _ hx => mem_closure.2 fun _ hS => hS hx\n#align subsemiring.subset_closure Subsemiring.subset_closure\n\ntheorem not_mem_of_not_mem_closure {s : Set R} {P : R} (hP : P ∉ closure s) : P ∉ s := fun h =>\n  hP (subset_closure h)\n#align subsemiring.not_mem_of_not_mem_closure Subsemiring.not_mem_of_not_mem_closure\n\n/-- A subsemiring `S` includes `closure s` if and only if it includes `s`. -/\n@[simp]\ntheorem closure_le {s : Set R} {t : Subsemiring R} : closure s ≤ t ↔ s ⊆ t :=\n  ⟨Set.Subset.trans subset_closure, fun h => infₛ_le h⟩\n#align subsemiring.closure_le Subsemiring.closure_le\n\n/-- Subsemiring closure of a set is monotone in its argument: if `s ⊆ t`,\nthen `closure s ≤ closure t`. -/\ntheorem closure_mono ⦃s t : Set R⦄ (h : s ⊆ t) : closure s ≤ closure t :=\n  closure_le.2 <| Set.Subset.trans h subset_closure\n#align subsemiring.closure_mono Subsemiring.closure_mono\n\ntheorem closure_eq_of_le {s : Set R} {t : Subsemiring R} (h₁ : s ⊆ t) (h₂ : t ≤ closure s) :\n    closure s = t :=\n  le_antisymm (closure_le.2 h₁) h₂\n#align subsemiring.closure_eq_of_le Subsemiring.closure_eq_of_le\n\ntheorem mem_map_equiv {f : R ≃+* S} {K : Subsemiring R} {x : S} :\n    x ∈ K.map (f : R →+* S) ↔ f.symm x ∈ K := by\n  convert @Set.mem_image_equiv _ _ (↑K) f.toEquiv x using 1\n#align subsemiring.mem_map_equiv Subsemiring.mem_map_equiv\n\ntheorem map_equiv_eq_comap_symm (f : R ≃+* S) (K : Subsemiring R) :\n    K.map (f : R →+* S) = K.comap f.symm :=\n  SetLike.coe_injective (f.toEquiv.image_eq_preimage K)\n#align subsemiring.map_equiv_eq_comap_symm Subsemiring.map_equiv_eq_comap_symm\n\ntheorem comap_equiv_eq_map_symm (f : R ≃+* S) (K : Subsemiring S) :\n    K.comap (f : R →+* S) = K.map f.symm :=\n  (map_equiv_eq_comap_symm f.symm K).symm\n#align subsemiring.comap_equiv_eq_map_symm Subsemiring.comap_equiv_eq_map_symm\n\nend Subsemiring\n\nnamespace Submonoid\n\n/-- The additive closure of a submonoid is a subsemiring. -/\ndef subsemiringClosure (M : Submonoid R) : Subsemiring R :=\n  { AddSubmonoid.closure (M : Set R) with\n    one_mem' := AddSubmonoid.mem_closure.mpr fun _ hy => hy M.one_mem\n    mul_mem' := MulMemClass.mul_mem_add_closure }\n#align submonoid.subsemiring_closure Submonoid.subsemiringClosure\n\ntheorem subsemiringClosure_coe :\n    (M.subsemiringClosure : Set R) = AddSubmonoid.closure (M : Set R) :=\n  rfl\n#align submonoid.subsemiring_closure_coe Submonoid.subsemiringClosure_coe\n\ntheorem subsemiringClosure_toAddSubmonoid :\n    M.subsemiringClosure.toAddSubmonoid = AddSubmonoid.closure (M : Set R) :=\n  rfl\n#align submonoid.subsemiring_closure_to_add_submonoid Submonoid.subsemiringClosure_toAddSubmonoid\n\n/-- The `Subsemiring` generated by a multiplicative submonoid coincides with the\n`Subsemiring.closure` of the submonoid itself . -/\ntheorem subsemiringClosure_eq_closure : M.subsemiringClosure = Subsemiring.closure (M : Set R) := by\n  ext\n  refine'\n    ⟨fun hx => _, fun hx =>\n      (Subsemiring.mem_closure.mp hx) M.subsemiringClosure fun s sM => _⟩\n  <;> rintro - ⟨H1, rfl⟩\n  <;> rintro - ⟨H2, rfl⟩\n  · exact AddSubmonoid.mem_closure.mp hx H1.toAddSubmonoid H2\n  · exact H2 sM\n#align submonoid.subsemiring_closure_eq_closure Submonoid.subsemiringClosure_eq_closure\n\nend Submonoid\n\nnamespace Subsemiring\n\n@[simp]\ntheorem closure_submonoid_closure (s : Set R) : closure ↑(Submonoid.closure s) = closure s :=\n  le_antisymm\n    (closure_le.mpr fun _ hy =>\n      (Submonoid.mem_closure.mp hy) (closure s).toSubmonoid subset_closure)\n    (closure_mono Submonoid.subset_closure)\n#align subsemiring.closure_submonoid_closure Subsemiring.closure_submonoid_closure\n\n/-- The elements of the subsemiring closure of `M` are exactly the elements of the additive closure\nof a multiplicative submonoid `M`. -/\ntheorem coe_closure_eq (s : Set R) :\n    (closure s : Set R) = AddSubmonoid.closure (Submonoid.closure s : Set R) := by\n  simp [← Submonoid.subsemiringClosure_toAddSubmonoid, Submonoid.subsemiringClosure_eq_closure]\n#align subsemiring.coe_closure_eq Subsemiring.coe_closure_eq\n\ntheorem mem_closure_iff {s : Set R} {x} :\n    x ∈ closure s ↔ x ∈ AddSubmonoid.closure (Submonoid.closure s : Set R) :=\n  Set.ext_iff.mp (coe_closure_eq s) x\n#align subsemiring.mem_closure_iff Subsemiring.mem_closure_iff\n\n@[simp]\ntheorem closure_addSubmonoid_closure {s : Set R} : closure ↑(AddSubmonoid.closure s) = closure s :=\n  by\n  ext x\n  refine' ⟨fun hx => _, fun hx => closure_mono AddSubmonoid.subset_closure hx⟩\n  rintro - ⟨H, rfl⟩\n  rintro - ⟨J, rfl⟩\n  refine' (AddSubmonoid.mem_closure.mp (mem_closure_iff.mp hx)) H.toAddSubmonoid fun y hy => _\n  refine' (Submonoid.mem_closure.mp hy) H.toSubmonoid fun z hz => _\n  exact (AddSubmonoid.mem_closure.mp hz) H.toAddSubmonoid fun w hw => J hw\n#align subsemiring.closure_add_submonoid_closure Subsemiring.closure_addSubmonoid_closure\n\n/-- An induction principle for closure membership. If `p` holds for `0`, `1`, and all elements\nof `s`, and is preserved under addition and multiplication, then `p` holds for all elements\nof the closure of `s`. -/\n@[elab_as_elim]\ntheorem closure_induction {s : Set R} {p : R → Prop} {x} (h : x ∈ closure s) (Hs : ∀ x ∈ s, p x)\n    (H0 : p 0) (H1 : p 1) (Hadd : ∀ x y, p x → p y → p (x + y))\n    (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=\n  (@closure_le _ _ _ ⟨⟨⟨p, @Hmul⟩, H1⟩, @Hadd, H0⟩).2 Hs h\n#align subsemiring.closure_induction Subsemiring.closure_induction\n\n/-- An induction principle for closure membership for predicates with two arguments. -/\n@[elab_as_elim]\ntheorem closure_induction₂ {s : Set R} {p : R → R → Prop} {x} {y : R} (hx : x ∈ closure s)\n    (hy : y ∈ closure s) (Hs : ∀ x ∈ s, ∀ y ∈ s, p x y) (H0_left : ∀ x, p 0 x)\n    (H0_right : ∀ x, p x 0) (H1_left : ∀ x, p 1 x) (H1_right : ∀ x, p x 1)\n    (Hadd_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y)\n    (Hadd_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂))\n    (Hmul_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ * x₂) y)\n    (Hmul_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ * y₂)) : p x y :=\n  closure_induction hx\n    (fun x₁ x₁s =>\n      closure_induction hy (Hs x₁ x₁s) (H0_right x₁) (H1_right x₁) (Hadd_right x₁) (Hmul_right x₁))\n    (H0_left y) (H1_left y) (fun z z' => Hadd_left z z' y) fun z z' => Hmul_left z z' y\n#align subsemiring.closure_induction₂ Subsemiring.closure_induction₂\n\ntheorem mem_closure_iff_exists_list {R} [Semiring R] {s : Set R} {x} :\n    x ∈ closure s ↔ ∃ L : List (List R), (∀ t ∈ L, ∀ y ∈ t, y ∈ s) ∧ (L.map List.prod).sum = x := by\n  constructor\n  · intro hx\n    -- Porting note: needed explicit `p`\n    let p : R → Prop := fun x =>\n      ∃ (L : List (List R)),\n        (∀ (t : List R), t ∈ L → ∀ (y : R), y ∈ t → y ∈ s) ∧ (List.map List.prod L).sum = x\n    exact AddSubmonoid.closure_induction (p := p) (mem_closure_iff.1 hx)\n      (fun x hx =>\n        suffices ∃ t : List R, (∀ y ∈ t, y ∈ s) ∧ t.prod = x from\n          let ⟨t, ht1, ht2⟩ := this\n          ⟨[t], List.forall_mem_singleton.2 ht1, by\n            rw [List.map_singleton, List.sum_singleton, ht2]⟩\n        Submonoid.closure_induction hx\n          (fun x hx => ⟨[x], List.forall_mem_singleton.2 hx, one_mul x⟩)\n          ⟨[], List.forall_mem_nil _, rfl⟩ fun x y ⟨t, ht1, ht2⟩ ⟨u, hu1, hu2⟩ =>\n          ⟨t ++ u, List.forall_mem_append.2 ⟨ht1, hu1⟩, by rw [List.prod_append, ht2, hu2]⟩)\n      ⟨[], List.forall_mem_nil _, rfl⟩ fun x y ⟨L, HL1, HL2⟩ ⟨M, HM1, HM2⟩ =>\n      ⟨L ++ M, List.forall_mem_append.2 ⟨HL1, HM1⟩, by\n        rw [List.map_append, List.sum_append, HL2, HM2]⟩\n  · rintro ⟨L, HL1, HL2⟩\n    exact HL2 ▸\n      list_sum_mem fun r hr =>\n        let ⟨t, ht1, ht2⟩ := List.mem_map.1 hr\n        ht2 ▸ list_prod_mem _ fun y hy => subset_closure <| HL1 t ht1 y hy\n#align subsemiring.mem_closure_iff_exists_list Subsemiring.mem_closure_iff_exists_list\n\nvariable (R)\n\n/-- `closure` forms a Galois insertion with the coercion to set. -/\nprotected def gi : GaloisInsertion (@closure R _) (↑)\n    where\n  choice s _ := closure s\n  gc _ _ := closure_le\n  le_l_u _ := subset_closure\n  choice_eq _ _ := rfl\n#align subsemiring.gi Subsemiring.gi\n\nvariable {R}\n\n/-- Closure of a subsemiring `S` equals `S`. -/\ntheorem closure_eq (s : Subsemiring R) : closure (s : Set R) = s :=\n  (Subsemiring.gi R).l_u_eq s\n#align subsemiring.closure_eq Subsemiring.closure_eq\n\n@[simp]\ntheorem closure_empty : closure (∅ : Set R) = ⊥ :=\n  (Subsemiring.gi R).gc.l_bot\n#align subsemiring.closure_empty Subsemiring.closure_empty\n\n@[simp]\ntheorem closure_univ : closure (Set.univ : Set R) = ⊤ :=\n  @coe_top R _ ▸ closure_eq ⊤\n#align subsemiring.closure_univ Subsemiring.closure_univ\n\ntheorem closure_union (s t : Set R) : closure (s ∪ t) = closure s ⊔ closure t :=\n  (Subsemiring.gi R).gc.l_sup\n#align subsemiring.closure_union Subsemiring.closure_union\n\ntheorem closure_unionᵢ {ι} (s : ι → Set R) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=\n  (Subsemiring.gi R).gc.l_supᵢ\n#align subsemiring.closure_Union Subsemiring.closure_unionᵢ\n\ntheorem closure_unionₛ (s : Set (Set R)) : closure (⋃₀ s) = ⨆ t ∈ s, closure t :=\n  (Subsemiring.gi R).gc.l_supₛ\n#align subsemiring.closure_sUnion Subsemiring.closure_unionₛ\n\ntheorem map_sup (s t : Subsemiring R) (f : R →+* S) : (s ⊔ t).map f = s.map f ⊔ t.map f :=\n  (gc_map_comap f).l_sup\n#align subsemiring.map_sup Subsemiring.map_sup\n\ntheorem map_supᵢ {ι : Sort _} (f : R →+* S) (s : ι → Subsemiring R) :\n    (supᵢ s).map f = ⨆ i, (s i).map f :=\n  (gc_map_comap f).l_supᵢ\n#align subsemiring.map_supr Subsemiring.map_supᵢ\n\ntheorem comap_inf (s t : Subsemiring S) (f : R →+* S) : (s ⊓ t).comap f = s.comap f ⊓ t.comap f :=\n  (gc_map_comap f).u_inf\n#align subsemiring.comap_inf Subsemiring.comap_inf\n\ntheorem comap_infᵢ {ι : Sort _} (f : R →+* S) (s : ι → Subsemiring S) :\n    (infᵢ s).comap f = ⨅ i, (s i).comap f :=\n  (gc_map_comap f).u_infᵢ\n#align subsemiring.comap_infi Subsemiring.comap_infᵢ\n\n@[simp]\ntheorem map_bot (f : R →+* S) : (⊥ : Subsemiring R).map f = ⊥ :=\n  (gc_map_comap f).l_bot\n#align subsemiring.map_bot Subsemiring.map_bot\n\n@[simp]\ntheorem comap_top (f : R →+* S) : (⊤ : Subsemiring S).comap f = ⊤ :=\n  (gc_map_comap f).u_top\n#align subsemiring.comap_top Subsemiring.comap_top\n\n/-- Given `Subsemiring`s `s`, `t` of semirings `R`, `S` respectively, `s.prod t` is `s × t`\nas a subsemiring of `R × S`. -/\ndef prod (s : Subsemiring R) (t : Subsemiring S) : Subsemiring (R × S) :=\n  { s.toSubmonoid.prod t.toSubmonoid, s.toAddSubmonoid.prod t.toAddSubmonoid with\n    carrier := s ×ˢ t }\n#align subsemiring.prod Subsemiring.prod\n\n@[norm_cast]\ntheorem coe_prod (s : Subsemiring R) (t : Subsemiring S) : (s.prod t : Set (R × S)) = s ×ˢ t :=\n  rfl\n#align subsemiring.coe_prod Subsemiring.coe_prod\n\ntheorem mem_prod {s : Subsemiring R} {t : Subsemiring S} {p : R × S} :\n    p ∈ s.prod t ↔ p.1 ∈ s ∧ p.2 ∈ t :=\n  Iff.rfl\n#align subsemiring.mem_prod Subsemiring.mem_prod\n\n@[mono]\ntheorem prod_mono ⦃s₁ s₂ : Subsemiring R⦄ (hs : s₁ ≤ s₂) ⦃t₁ t₂ : Subsemiring S⦄ (ht : t₁ ≤ t₂) :\n    s₁.prod t₁ ≤ s₂.prod t₂ :=\n  Set.prod_mono hs ht\n#align subsemiring.prod_mono Subsemiring.prod_mono\n\ntheorem prod_mono_right (s : Subsemiring R) : Monotone fun t : Subsemiring S => s.prod t :=\n  prod_mono (le_refl s)\n#align subsemiring.prod_mono_right Subsemiring.prod_mono_right\n\ntheorem prod_mono_left (t : Subsemiring S) : Monotone fun s : Subsemiring R => s.prod t :=\n  fun _ _ hs => prod_mono hs (le_refl t)\n#align subsemiring.prod_mono_left Subsemiring.prod_mono_left\n\ntheorem prod_top (s : Subsemiring R) : s.prod (⊤ : Subsemiring S) = s.comap (RingHom.fst R S) :=\n  ext fun x => by simp [mem_prod, MonoidHom.coe_fst]\n#align subsemiring.prod_top Subsemiring.prod_top\n\ntheorem top_prod (s : Subsemiring S) : (⊤ : Subsemiring R).prod s = s.comap (RingHom.snd R S) :=\n  ext fun x => by simp [mem_prod, MonoidHom.coe_snd]\n#align subsemiring.top_prod Subsemiring.top_prod\n\n@[simp]\ntheorem top_prod_top : (⊤ : Subsemiring R).prod (⊤ : Subsemiring S) = ⊤ :=\n  (top_prod _).trans <| comap_top _\n#align subsemiring.top_prod_top Subsemiring.top_prod_top\n\n/-- Product of subsemirings is isomorphic to their product as monoids. -/\ndef prodEquiv (s : Subsemiring R) (t : Subsemiring S) : s.prod t ≃+* s × t :=\n  { Equiv.Set.prod (s : Set R) (t : Set S) with\n    map_mul' := fun _ _ => rfl\n    map_add' := fun _ _ => rfl }\n#align subsemiring.prod_equiv Subsemiring.prodEquiv\n\ntheorem mem_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → Subsemiring R} (hS : Directed (· ≤ ·) S)\n    {x : R} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by\n  refine' ⟨_, fun ⟨i, hi⟩ => (SetLike.le_def.1 <| le_supᵢ S i) hi⟩\n  let U : Subsemiring R :=\n    Subsemiring.mk' (⋃ i, (S i : Set R)) (⨆ i, (S i).toSubmonoid)\n      (Submonoid.coe_supᵢ_of_directed <| hS.mono_comp _ fun _ _ => id) (⨆ i, (S i).toAddSubmonoid)\n      (AddSubmonoid.coe_supᵢ_of_directed <| hS.mono_comp _ fun _ _ => id)\n  -- Porting note: gave the hypothesis an explicit name because `@this` doesn't work\n  suffices h : (⨆ i, S i) ≤ U by simpa using @h x\n  exact supᵢ_le fun i x hx => Set.mem_unionᵢ.2 ⟨i, hx⟩\n#align subsemiring.mem_supr_of_directed Subsemiring.mem_supᵢ_of_directed\n\ntheorem coe_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → Subsemiring R}\n    (hS : Directed (· ≤ ·) S) : ((⨆ i, S i : Subsemiring R) : Set R) = ⋃ i, ↑(S i) :=\n  Set.ext fun x => by simp [mem_supᵢ_of_directed hS]\n#align subsemiring.coe_supr_of_directed Subsemiring.coe_supᵢ_of_directed\n\ntheorem mem_supₛ_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (· ≤ ·) S) {x : R} : x ∈ supₛ S ↔ ∃ s ∈ S, x ∈ s := by\n  haveI : Nonempty S := Sne.to_subtype\n  simp only [supₛ_eq_supᵢ', mem_supᵢ_of_directed hS.directed_val, SetCoe.exists, Subtype.coe_mk,\n    exists_prop]\n#align subsemiring.mem_Sup_of_directed_on Subsemiring.mem_supₛ_of_directedOn\n\ntheorem coe_supₛ_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (· ≤ ·) S) : (↑(supₛ S) : Set R) = ⋃ s ∈ S, ↑s :=\n  Set.ext fun x => by simp [mem_supₛ_of_directedOn Sne hS]\n#align subsemiring.coe_Sup_of_directed_on Subsemiring.coe_supₛ_of_directedOn\n\nend Subsemiring\n\nnamespace RingHom\n\nvariable [NonAssocSemiring T] {s : Subsemiring R}\n\nvariable {σR σS : Type _}\n\nvariable [SetLike σR R] [SetLike σS S] [SubsemiringClass σR R] [SubsemiringClass σS S]\n\nopen Subsemiring\n\n/-- Restriction of a ring homomorphism to a subsemiring of the domain. -/\ndef domRestrict (f : R →+* S) (s : σR) : s →+* S :=\n  f.comp <| SubsemiringClass.subtype s\n#align ring_hom.dom_restrict RingHom.domRestrict\n\n@[simp]\ntheorem restrict_apply (f : R →+* S) {s : σR} (x : s) : f.domRestrict s x = f x :=\n  rfl\n#align ring_hom.restrict_apply RingHom.restrict_apply\n\n/-- Restriction of a ring homomorphism to a subsemiring of the codomain. -/\ndef codRestrict (f : R →+* S) (s : σS) (h : ∀ x, f x ∈ s) : R →+* s :=\n  { (f : R →* S).codRestrict s h, (f : R →+ S).codRestrict s h with toFun := fun n => ⟨f n, h n⟩ }\n#align ring_hom.cod_restrict RingHom.codRestrict\n\n/-- The ring homomorphism from the preimage of `s` to `s`. -/\ndef restrict (f : R →+* S) (s' : σR) (s : σS) (h : ∀ x ∈ s', f x ∈ s) : s' →+* s :=\n  (f.domRestrict s').codRestrict s fun x => h x x.2\n#align ring_hom.restrict RingHom.restrict\n\n@[simp]\ntheorem coe_restrict_apply (f : R →+* S) (s' : σR) (s : σS) (h : ∀ x ∈ s', f x ∈ s) (x : s') :\n    (f.restrict s' s h x : S) = f x :=\n  rfl\n#align ring_hom.coe_restrict_apply RingHom.coe_restrict_apply\n\n@[simp]\ntheorem comp_restrict (f : R →+* S) (s' : σR) (s : σS) (h : ∀ x ∈ s', f x ∈ s) :\n    (SubsemiringClass.subtype s).comp (f.restrict s' s h) = f.comp (SubsemiringClass.subtype s') :=\n  rfl\n#align ring_hom.comp_restrict RingHom.comp_restrict\n\n/-- Restriction of a ring homomorphism to its range interpreted as a subsemiring.\n\nThis is the bundled version of `Set.rangeFactorization`. -/\ndef rangeSRestrict (f : R →+* S) : R →+* f.rangeS :=\n  f.codRestrict (R := R) (S := S) (σS := Subsemiring S) f.rangeS f.mem_rangeS_self\n#align ring_hom.srange_restrict RingHom.rangeSRestrict\n\n@[simp]\ntheorem coe_rangeSRestrict (f : R →+* S) (x : R) : (f.rangeSRestrict x : S) = f x :=\n  rfl\n#align ring_hom.coe_srange_restrict RingHom.coe_rangeSRestrict\n\ntheorem rangeSRestrict_surjective (f : R →+* S) : Function.Surjective f.rangeSRestrict :=\n  fun ⟨_, hy⟩ =>\n  let ⟨x, hx⟩ := mem_rangeS.mp hy\n  ⟨x, Subtype.ext hx⟩\n#align ring_hom.srange_restrict_surjective RingHom.rangeSRestrict_surjective\n\ntheorem rangeS_top_iff_surjective {f : R →+* S} :\n    f.rangeS = (⊤ : Subsemiring S) ↔ Function.Surjective f :=\n  SetLike.ext'_iff.trans <| Iff.trans (by rw [coe_rangeS, coe_top]) Set.range_iff_surjective\n#align ring_hom.srange_top_iff_surjective RingHom.rangeS_top_iff_surjective\n\n/-- The range of a surjective ring homomorphism is the whole of the codomain. -/\ntheorem rangeS_top_of_surjective (f : R →+* S) (hf : Function.Surjective f) :\n    f.rangeS = (⊤ : Subsemiring S) :=\n  rangeS_top_iff_surjective.2 hf\n#align ring_hom.srange_top_of_surjective RingHom.rangeS_top_of_surjective\n\n/-- The subsemiring of elements `x : R` such that `f x = g x` -/\ndef eqLocusS (f g : R →+* S) : Subsemiring R :=\n  { (f : R →* S).eqLocusM g, (f : R →+ S).eqLocusM g with carrier := { x | f x = g x } }\n#align ring_hom.eq_slocus RingHom.eqLocusS\n\n@[simp]\ntheorem eqLocusS_same (f : R →+* S) : f.eqLocusS f = ⊤ :=\n  SetLike.ext fun _ => eq_self_iff_true _\n#align ring_hom.eq_slocus_same RingHom.eqLocusS_same\n\n/-- If two ring homomorphisms are equal on a set, then they are equal on its subsemiring closure. -/\n\n\ntheorem eq_of_eqOn_stop {f g : R →+* S} (h : Set.EqOn f g (⊤ : Subsemiring R)) : f = g :=\n  ext fun _ => h trivial\n#align ring_hom.eq_of_eq_on_stop RingHom.eq_of_eqOn_stop\n\ntheorem eq_of_eqOn_sdense {s : Set R} (hs : closure s = ⊤) {f g : R →+* S} (h : s.EqOn f g) :\n    f = g :=\n  eq_of_eqOn_stop <| hs ▸ eqOn_sclosure h\n#align ring_hom.eq_of_eq_on_sdense RingHom.eq_of_eqOn_sdense\n\ntheorem sclosure_preimage_le (f : R →+* S) (s : Set S) : closure (f ⁻¹' s) ≤ (closure s).comap f :=\n  closure_le.2 fun _ hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx\n#align ring_hom.sclosure_preimage_le RingHom.sclosure_preimage_le\n\n/-- The image under a ring homomorphism of the subsemiring generated by a set equals\nthe subsemiring generated by the image of the set. -/\ntheorem map_closureS (f : R →+* S) (s : Set R) : (closure s).map f = closure (f '' s) :=\n  le_antisymm\n    (map_le_iff_le_comap.2 <|\n      le_trans (closure_mono <| Set.subset_preimage_image _ _) (sclosure_preimage_le _ _))\n    (closure_le.2 <| Set.image_subset _ subset_closure)\n#align ring_hom.map_sclosure RingHom.map_closureS\n\nend RingHom\n\nnamespace Subsemiring\n\nopen RingHom\n\n/-- The ring homomorphism associated to an inclusion of subsemirings. -/\ndef inclusion {S T : Subsemiring R} (h : S ≤ T) : S →+* T :=\n  S.subtype.codRestrict _ fun x => h x.2\n#align subsemiring.inclusion Subsemiring.inclusion\n\n@[simp]\ntheorem rangeS_subtype (s : Subsemiring R) : s.subtype.rangeS = s :=\n  SetLike.coe_injective <| (coe_rangeS _).trans Subtype.range_coe\n#align subsemiring.srange_subtype Subsemiring.rangeS_subtype\n\n@[simp]\ntheorem range_fst : (fst R S).rangeS = ⊤ :=\n  (fst R S).rangeS_top_of_surjective <| Prod.fst_surjective\n#align subsemiring.range_fst Subsemiring.range_fst\n\n@[simp]\ntheorem range_snd : (snd R S).rangeS = ⊤ :=\n  (snd R S).rangeS_top_of_surjective <| Prod.snd_surjective\n#align subsemiring.range_snd Subsemiring.range_snd\n\n@[simp]\ntheorem prod_bot_sup_bot_prod (s : Subsemiring R) (t : Subsemiring S) :\n    s.prod ⊥ ⊔ prod ⊥ t = s.prod t :=\n  le_antisymm (sup_le (prod_mono_right s bot_le) (prod_mono_left t bot_le)) fun p hp =>\n    Prod.fst_mul_snd p ▸\n      mul_mem\n        ((le_sup_left : s.prod ⊥ ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨hp.1, SetLike.mem_coe.2 <| one_mem ⊥⟩)\n        ((le_sup_right : prod ⊥ t ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨SetLike.mem_coe.2 <| one_mem ⊥, hp.2⟩)\n#align subsemiring.prod_bot_sup_bot_prod Subsemiring.prod_bot_sup_bot_prod\n\nend Subsemiring\n\nnamespace RingEquiv\n\nvariable {s t : Subsemiring R}\n\n/-- Makes the identity isomorphism from a proof two subsemirings of a multiplicative\n    monoid are equal. -/\ndef subsemiringCongr (h : s = t) : s ≃+* t :=\n  {\n    Equiv.setCongr <| congr_arg _ h with\n    map_mul' := fun _ _ => rfl\n    map_add' := fun _ _ => rfl }\n#align ring_equiv.subsemiring_congr RingEquiv.subsemiringCongr\n\n/-- Restrict a ring homomorphism with a left inverse to a ring isomorphism to its\n`RingHom.rangeS`. -/\ndef ofLeftInverseS {g : S → R} {f : R →+* S} (h : Function.LeftInverse g f) : R ≃+* f.rangeS :=\n  { f.rangeSRestrict with\n    toFun := fun x => f.rangeSRestrict x\n    invFun := fun x => (g ∘ f.rangeS.subtype) x\n    left_inv := h\n    right_inv := fun x =>\n      Subtype.ext <|\n        let ⟨x', hx'⟩ := RingHom.mem_rangeS.mp x.prop\n        show f (g x) = x by rw [← hx', h x'] }\n#align ring_equiv.sof_left_inverse RingEquiv.ofLeftInverseS\n\n@[simp]\ntheorem ofLeftInverseS_apply {g : S → R} {f : R →+* S} (h : Function.LeftInverse g f) (x : R) :\n    ↑(ofLeftInverseS h x) = f x :=\n  rfl\n#align ring_equiv.sof_left_inverse_apply RingEquiv.ofLeftInverseS_apply\n\n@[simp]\ntheorem ofLeftInverseS_symm_apply {g : S → R} {f : R →+* S} (h : Function.LeftInverse g f)\n    (x : f.rangeS) : (ofLeftInverseS h).symm x = g x :=\n  rfl\n#align ring_equiv.sof_left_inverse_symm_apply RingEquiv.ofLeftInverseS_symm_apply\n\n/-- Given an equivalence `e : R ≃+* S` of semirings and a subsemiring `s` of `R`,\n`subsemiring_map e s` is the induced equivalence between `s` and `s.map e` -/\n@[simps!]\ndef subsemiringMap (e : R ≃+* S) (s : Subsemiring R) : s ≃+* s.map e.toRingHom :=\n  { e.toAddEquiv.addSubmonoidMap s.toAddSubmonoid, e.toMulEquiv.submonoidMap s.toSubmonoid with }\n#align ring_equiv.subsemiring_map RingEquiv.subsemiringMap\n\nend RingEquiv\n\n/-! ### Actions by `Subsemiring`s\n\nThese are just copies of the definitions about `Submonoid` starting from `submonoid.mul_action`.\nThe only new result is `subsemiring.module`.\n\nWhen `R` is commutative, `algebra.of_subsemiring` provides a stronger result than those found in\nthis file, which uses the same scalar action.\n-/\n\n\nsection Actions\n\nnamespace Subsemiring\n\nvariable {R' α β : Type _}\n\nsection NonAssocSemiring\n\nvariable [NonAssocSemiring R']\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance smul [SMul R' α] (S : Subsemiring R') : SMul S α :=\n  S.toSubmonoid.smul\n\ntheorem smul_def [SMul R' α] {S : Subsemiring R'} (g : S) (m : α) : g • m = (g : R') • m :=\n  rfl\n#align subsemiring.smul_def Subsemiring.smul_def\n\ninstance smulCommClass_left [SMul R' β] [SMul α β] [SMulCommClass R' α β] (S : Subsemiring R') :\n    SMulCommClass S α β :=\n  S.toSubmonoid.smulCommClass_left\n#align subsemiring.smul_comm_class_left Subsemiring.smulCommClass_left\n\ninstance smulCommClass_right [SMul α β] [SMul R' β] [SMulCommClass α R' β] (S : Subsemiring R') :\n    SMulCommClass α S β :=\n  S.toSubmonoid.smulCommClass_right\n#align subsemiring.smul_comm_class_right Subsemiring.smulCommClass_right\n\n/-- Note that this provides `IsScalarTower S R R` which is needed by `smul_mul_assoc`. -/\ninstance isScalarTower [SMul α β] [SMul R' α] [SMul R' β] [IsScalarTower R' α β]\n    (S : Subsemiring R') :\n    IsScalarTower S α β :=\n  S.toSubmonoid.isScalarTower\n\ninstance faithfulSMul [SMul R' α] [FaithfulSMul R' α] (S : Subsemiring R') : FaithfulSMul S α :=\n  S.toSubmonoid.faithfulSMul\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Zero α] [SMulWithZero R' α] (S : Subsemiring R') : SMulWithZero S α :=\n  SMulWithZero.compHom _ S.subtype.toMonoidWithZeroHom.toZeroHom\n\nend NonAssocSemiring\n\nvariable [Semiring R']\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance mulAction [MulAction R' α] (S : Subsemiring R') : MulAction S α :=\n  S.toSubmonoid.mulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance distribMulAction [AddMonoid α] [DistribMulAction R' α] (S : Subsemiring R') :\n    DistribMulAction S α :=\n  S.toSubmonoid.distribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance mulDistribMulAction [Monoid α] [MulDistribMulAction R' α] (S : Subsemiring R') :\n    MulDistribMulAction S α :=\n  S.toSubmonoid.mulDistribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance mulActionWithZero [Zero α] [MulActionWithZero R' α] (S : Subsemiring R') :\n    MulActionWithZero S α :=\n  MulActionWithZero.compHom _ S.subtype.toMonoidWithZeroHom\n\n-- Porting note: instance named explicitly for use in `RingTheory/Subring/Basic`\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance module [AddCommMonoid α] [Module R' α] (S : Subsemiring R') : Module S α :=\n  -- Porting note: copying over the `smul` field causes a timeout\n  -- { Module.compHom _ S.subtype with smul := (· • ·) }\n  Module.compHom _ S.subtype\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Semiring α] [MulSemiringAction R' α] (S : Subsemiring R') : MulSemiringAction S α :=\n  S.toSubmonoid.mulSemiringAction\n\n/-- The center of a semiring acts commutatively on that semiring. -/\ninstance center.smulCommClass_left : SMulCommClass (center R') R' R' :=\n  Submonoid.center.smulCommClass_left\n#align subsemiring.center.smul_comm_class_left Subsemiring.center.smulCommClass_left\n\n/-- The center of a semiring acts commutatively on that semiring. -/\ninstance center.smulCommClass_right : SMulCommClass R' (center R') R' :=\n  Submonoid.center.smulCommClass_right\n#align subsemiring.center.smul_comm_class_right Subsemiring.center.smulCommClass_right\n\n/-- If all the elements of a set `s` commute, then `closure s` is a commutative monoid. -/\ndef closureCommSemiringOfComm {s : Set R'} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) :\n    CommSemiring (closure s) :=\n  { (closure s).toSemiring with\n    mul_comm := fun x y => by\n      ext\n      simp only [Subsemiring.coe_mul]\n      refine'\n        closure_induction₂ x.prop y.prop hcomm (fun x => by simp only [zero_mul, mul_zero])\n          (fun x => by simp only [zero_mul, mul_zero]) (fun x => by simp only [one_mul, mul_one])\n          (fun x => by simp only [one_mul, mul_one])\n          (fun x y z h₁ h₂ => by simp only [add_mul, mul_add, h₁, h₂])\n          (fun x y z h₁ h₂ => by simp only [add_mul, mul_add, h₁, h₂])\n          (fun x y z h₁ h₂ => by rw [mul_assoc, h₂, ← mul_assoc, h₁, mul_assoc]) fun x y z h₁ h₂ =>\n          by rw [← mul_assoc, h₁, mul_assoc, h₂, ← mul_assoc] }\n#align subsemiring.closure_comm_semiring_of_comm Subsemiring.closureCommSemiringOfComm\n\nend Subsemiring\n\nend Actions\n\n-- While this definition is not about `Subsemiring`s, this is the earliest we have\n-- both `StrictOrderedSemiring` and `Submonoid` available.\n/-- Submonoid of positive elements of an ordered semiring. -/\ndef posSubmonoid (R : Type _) [StrictOrderedSemiring R] : Submonoid R\n    where\n  carrier := { x | 0 < x }\n  one_mem' := show (0 : R) < 1 from zero_lt_one\n  mul_mem' {x y} (hx : 0 < x) (hy : 0 < y) := mul_pos hx hy\n#align pos_submonoid posSubmonoid\n\n@[simp]\ntheorem mem_posSubmonoid {R : Type _} [StrictOrderedSemiring R] (u : Rˣ) :\n    ↑u ∈ posSubmonoid R ↔ (0 : R) < u :=\n  Iff.rfl\n#align mem_pos_monoid mem_posSubmonoid\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/RingTheory/Subsemiring/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.49191991303098337}}
{"text": "/-\nCopyright (c) 2021 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Scott Morrison\n\n! This file was ported from Lean 3 source module topology.algebra.field\n! leanprover-community/mathlib commit c10e724be91096453ee3db13862b9fb9a992fef2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Topology.Algebra.Ring.Basic\nimport Mathlib.Topology.Algebra.GroupWithZero\nimport Mathlib.Topology.LocalExtr\nimport Mathlib.FieldTheory.Subfield\n\n/-!\n# Topological fields\n\nA topological division ring is a topological ring whose inversion function is continuous at every\nnon-zero element.\n\n-/\n\nvariable {K : Type _} [DivisionRing K] [TopologicalSpace K]\n\n/-- Left-multiplication by a nonzero element of a topological division ring is proper, i.e.,\ninverse images of compact sets are compact. -/\ntheorem Filter.tendsto_cocompact_mul_left₀ [ContinuousMul K] {a : K} (ha : a ≠ 0) :\n    Filter.Tendsto (fun x : K => a * x) (Filter.cocompact K) (Filter.cocompact K) :=\n  Filter.tendsto_cocompact_mul_left (inv_mul_cancel ha)\n#align filter.tendsto_cocompact_mul_left₀ Filter.tendsto_cocompact_mul_left₀\n\n/-- Right-multiplication by a nonzero element of a topological division ring is proper, i.e.,\ninverse images of compact sets are compact. -/\ntheorem Filter.tendsto_cocompact_mul_right₀ [ContinuousMul K] {a : K} (ha : a ≠ 0) :\n    Filter.Tendsto (fun x : K => x * a) (Filter.cocompact K) (Filter.cocompact K) :=\n  Filter.tendsto_cocompact_mul_right (mul_inv_cancel ha)\n#align filter.tendsto_cocompact_mul_right₀ Filter.tendsto_cocompact_mul_right₀\n\nvariable (K)\n\n/-- A topological division ring is a division ring with a topology where all operations are\n    continuous, including inversion. -/\nclass TopologicalDivisionRing extends TopologicalRing K, HasContinuousInv₀ K : Prop\n#align topological_division_ring TopologicalDivisionRing\n\nsection Subfield\n\nvariable {α : Type _} [Field α] [TopologicalSpace α] [TopologicalDivisionRing α]\n\n/-- The (topological-space) closure of a subfield of a topological field is\nitself a subfield. -/\ndef Subfield.topologicalClosure (K : Subfield α) : Subfield α :=\n  { K.toSubring.topologicalClosure with\n    carrier := _root_.closure (K : Set α)\n    inv_mem' := fun x hx => by\n      dsimp only at hx ⊢\n      rcases eq_or_ne x 0 with (rfl | h)\n      · rwa [inv_zero]\n      · -- porting note: todo: Lean fails to find InvMemClass instance\n        rw [← @inv_coe_set α (Subfield α) _ _ SubfieldClass.toInvMemClass K, ← Set.image_inv]\n        exact mem_closure_image (continuousAt_inv₀ h) hx }\n#align subfield.topological_closure Subfield.topologicalClosure\n\ntheorem Subfield.le_topologicalClosure (s : Subfield α) : s ≤ s.topologicalClosure :=\n  _root_.subset_closure\n#align subfield.le_topological_closure Subfield.le_topologicalClosure\n\ntheorem Subfield.isClosed_topologicalClosure (s : Subfield α) :\n    IsClosed (s.topologicalClosure : Set α) :=\n  isClosed_closure\n#align subfield.is_closed_topological_closure Subfield.isClosed_topologicalClosure\n\ntheorem Subfield.topologicalClosure_minimal (s : Subfield α) {t : Subfield α} (h : s ≤ t)\n    (ht : IsClosed (t : Set α)) : s.topologicalClosure ≤ t :=\n  closure_minimal h ht\n#align subfield.topological_closure_minimal Subfield.topologicalClosure_minimal\n\nend Subfield\n\nsection affineHomeomorph\n\n/-!\nThis section is about affine homeomorphisms from a topological field `𝕜` to itself.\nTechnically it does not require `𝕜` to be a topological field, a topological ring that\nhappens to be a field is enough.\n-/\n\n\nvariable {𝕜 : Type _} [Field 𝕜] [TopologicalSpace 𝕜] [TopologicalRing 𝕜]\n\n/--\nThe map `fun x => a * x + b`, as a homeomorphism from `𝕜` (a topological field) to itself,\nwhen `a ≠ 0`.\n-/\n@[simps]\ndef affineHomeomorph (a b : 𝕜) (h : a ≠ 0) : 𝕜 ≃ₜ 𝕜 where\n  toFun x := a * x + b\n  invFun y := (y - b) / a\n  left_inv x := by\n    simp only [add_sub_cancel]\n    exact mul_div_cancel_left x h\n  right_inv y := by simp [mul_div_cancel' _ h]\n#align affine_homeomorph affineHomeomorph\n\nend affineHomeomorph\n\nsection LocalExtr\n\nvariable {α β : Type _} [TopologicalSpace α] [LinearOrderedSemifield β] {a : α}\n\nopen Topology\n\ntheorem IsLocalMin.inv {f : α → β} {a : α} (h1 : IsLocalMin f a) (h2 : ∀ᶠ z in 𝓝 a, 0 < f z) :\n    IsLocalMax f⁻¹ a := by\n  filter_upwards [h1, h2]with z h3 h4 using(inv_le_inv h4 h2.self_of_nhds).mpr h3\n#align is_local_min.inv IsLocalMin.inv\n\nend LocalExtr\n\nsection Preconnected\n\n/-! Some results about functions on preconnected sets valued in a ring or field with a topology. -/\n\nopen Set\n\nvariable {α 𝕜 : Type _} {f g : α → 𝕜} {S : Set α} [TopologicalSpace α] [TopologicalSpace 𝕜]\n  [T1Space 𝕜]\n\n/-- If `f` is a function `α → 𝕜` which is continuous on a preconnected set `S`, and\n`f ^ 2 = 1` on `S`, then either `f = 1` on `S`, or `f = -1` on `S`. -/\ntheorem IsPreconnected.eq_one_or_eq_neg_one_of_sq_eq [Ring 𝕜] [NoZeroDivisors 𝕜]\n    (hS : IsPreconnected S) (hf : ContinuousOn f S) (hsq : EqOn (f ^ 2) 1 S) :\n    EqOn f 1 S ∨ EqOn f (-1) S := by\n  have : DiscreteTopology ({1, -1} : Set 𝕜) := discrete_of_t1_of_finite\n  have hmaps : MapsTo f S {1, -1}\n  · simpa only [EqOn, Pi.one_apply, Pi.pow_apply, sq_eq_one_iff] using hsq\n  simpa using hS.eqOn_const_of_mapsTo hf hmaps\n#align is_preconnected.eq_one_or_eq_neg_one_of_sq_eq IsPreconnected.eq_one_or_eq_neg_one_of_sq_eq\n\n/-- If `f, g` are functions `α → 𝕜`, both continuous on a preconnected set `S`, with\n`f ^ 2 = g ^ 2` on `S`, and `g z ≠ 0` all `z ∈ S`, then either `f = g` or `f = -g` on\n`S`. -/\ntheorem IsPreconnected.eq_or_eq_neg_of_sq_eq [Field 𝕜] [HasContinuousInv₀ 𝕜] [ContinuousMul 𝕜]\n    (hS : IsPreconnected S) (hf : ContinuousOn f S) (hg : ContinuousOn g S)\n    (hsq : EqOn (f ^ 2) (g ^ 2) S) (hg_ne : ∀ {x : α}, x ∈ S → g x ≠ 0) :\n    EqOn f g S ∨ EqOn f (-g) S := by\n  have hsq : EqOn ((f / g) ^ 2) 1 S := fun x hx => by\n    simpa [div_eq_one_iff_eq (pow_ne_zero _ (hg_ne hx))] using hsq hx\n  simpa (config := { contextual := true }) [EqOn, div_eq_iff (hg_ne _)]\n    using hS.eq_one_or_eq_neg_one_of_sq_eq (hf.div hg fun z => hg_ne) hsq\n#align is_preconnected.eq_or_eq_neg_of_sq_eq IsPreconnected.eq_or_eq_neg_of_sq_eq\n\n/-- If `f, g` are functions `α → 𝕜`, both continuous on a preconnected set `S`, with\n`f ^ 2 = g ^ 2` on `S`, and `g z ≠ 0` all `z ∈ S`, then as soon as `f = g` holds at\none point of `S` it holds for all points. -/\ntheorem IsPreconnected.eq_of_sq_eq [Field 𝕜] [HasContinuousInv₀ 𝕜] [ContinuousMul 𝕜]\n    (hS : IsPreconnected S) (hf : ContinuousOn f S) (hg : ContinuousOn g S)\n    (hsq : EqOn (f ^ 2) (g ^ 2) S) (hg_ne : ∀ {x : α}, x ∈ S → g x ≠ 0) {y : α} (hy : y ∈ S)\n    (hy' : f y = g y) : EqOn f g S := fun x hx => by\n  rcases hS.eq_or_eq_neg_of_sq_eq hf hg @hsq @hg_ne with (h | h)\n  · exact h hx\n  · rw [h _, Pi.neg_apply, neg_eq_iff_add_eq_zero, ← two_mul, mul_eq_zero,\n      iff_false_iff.2 (hg_ne _)] at hy' ⊢ <;> assumption\n#align is_preconnected.eq_of_sq_eq IsPreconnected.eq_of_sq_eq\n\nend Preconnected\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Topology/Algebra/Field.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.49191991303098337}}
{"text": "import system_of_complexes.basic\nimport rescale.normed_group\n/-!\n\n# rescaling norms on a system of complexes\n\nThis file defines the `rescale` functor which will take a system of complexes of seminormed groups\nand systematically rescale all the norms on all the seminormed groups by a constant factor.\n\n-/\nnoncomputable theory\n\nuniverse variables u\n\nopen category_theory\nopen_locale nat nnreal\n\nnamespace nnreal\n\ndef MulLeft (κ : ℝ≥0) : ℝ≥0 ⥤ ℝ≥0 :=\n{ obj := λ c, κ * c,\n  map := λ c₁ c₂ h, hom_of_le $ mul_le_mul' le_rfl (le_of_hom h) }\n\ndef MulRight (κ : ℝ≥0) : ℝ≥0 ⥤ ℝ≥0 :=\n{ obj := λ c, c * κ,\n  map := λ c₁ c₂ h, hom_of_le $ mul_le_mul' (le_of_hom h) le_rfl }\n\nend nnreal\n\nnamespace system_of_complexes\n\ndef rescale (r : ℝ≥0) [fact (0 < r)] : system_of_complexes.{u} ⥤ system_of_complexes.{u} :=\n(whiskering_right _ _ _).obj $ (SemiNormedGroup.rescale r).map_homological_complex _\n\nlemma rescale_obj (r c : ℝ≥0) [fact (0 < r)] (C : system_of_complexes) (i : ℕ) :\n  ↥(((rescale r).obj C) c i) = _root_.rescale r (C c i) := rfl\n\nlemma rescale_d (r c : ℝ≥0) [fact (0 < r)] (C : system_of_complexes) (i j : ℕ)\n  (v : (((rescale r).obj C) c i)) :\n  (((rescale r).obj C).d i j) v = @rescale.of r _ ((C.d i j) (((@rescale.of r _).symm) v)) :=\nrfl\n\ninstance rescale.additive (r : ℝ≥0) [fact (0 < r)] : (rescale r).additive :=\n{ map_add' := λ X Y f g, by { ext, refl } } -- a heavy refl\n.\n\n-- can we golf this? speed it up?\ndef to_rescale (r : ℝ≥0) [fact (0 < r)] : 𝟭 system_of_complexes ⟶ rescale r :=\n{ app := λ C,\n  { app := λ c,\n    { f := λ _, (SemiNormedGroup.to_rescale r).app _,\n      comm' := by { intros, exact ((SemiNormedGroup.to_rescale r).naturality _).symm } },\n    naturality' := by { intros c₁ c₂ h, ext i : 2, refl } },\n  naturality' := λ C₁ C₂ f, by { ext, refl } }\n.\n\ndef scale (i j : ℝ≥0) [fact (0 < i)] [fact (0 < j)] : rescale i ⟶ rescale j :=\n(whiskering_right _ _ _).map $ nat_trans.map_homological_complex (SemiNormedGroup.scale i j) _\n\nsection exact_and_admissible\n\nvariables {k K : ℝ≥0} [fact (1 ≤ k)] {m : ℕ} {c₀ : ℝ≥0}\n\nlemma rescale_is_weak_bounded_exact (r : ℝ≥0) [hr : fact (0 < r)] (C : system_of_complexes)\n  (hC : C.is_weak_bounded_exact k K m c₀) :\n  ((rescale r).obj C).is_weak_bounded_exact k K m c₀ :=\nbegin\n  intros c hc i hi x ε hε,\n  obtain ⟨_, _, rfl, rfl, y, hy⟩ := hC c hc i hi ((@rescale.of r _).symm x) (ε * r) _,\n  swap, { exact mul_pos hε hr.out },\n  refine ⟨_, _, rfl, rfl, (@rescale.of r _) y, _⟩,\n  erw [rescale.norm_def, rescale.norm_def],\n  rwa [div_le_iff, add_mul, mul_assoc, div_mul_cancel],\n  { apply ne_of_gt, exact hr.out },\n  { exact hr.out },\nend\n.\n/-- `rescale C` is admissible if `C` is. -/\nlemma rescale_admissible (r : ℝ≥0) [fact (0 < r)] (C : system_of_complexes) (hC : C.admissible) :\n  ((rescale r).obj C).admissible :=\n{ d_norm_noninc' := begin\n    rintro c i j h,\n    rintro (v : _root_.rescale r (C c i)), -- rw rescale_obj gives motive issues\n    rw [rescale_d, rescale.norm_def, rescale.norm_def, equiv.symm_apply_apply],\n    refine div_le_div_of_le_of_nonneg _ _,\n    { apply hC.d_norm_noninc' c i j h},\n    { exact nnreal.coe_nonneg r },\n  end,\n  res_norm_noninc := λ c' c i h v, div_le_div_of_le_of_nonneg\n    (hC.res_norm_noninc c' c i h _) (nnreal.coe_nonneg r) }\n\nend exact_and_admissible\n\ninstance (m : ℕ) : fact (0 < m!) :=\n⟨nat.factorial_pos _⟩\n\ndef rescale_functor : ℕ → (system_of_complexes ⥤ system_of_complexes)\n| 0     := 𝟭 _\n| 1     := 𝟭 _\n| (m+2) := rescale (m+2)!\n\ninstance rescale_functor.additive : Π m, (rescale_functor m).additive\n| 0     := functor.id.additive\n| 1     := functor.id.additive\n| (m+2) := show (rescale (m+2)!).additive, from rescale.additive _\n\ndef rescale_nat_trans : Π i j, rescale_functor i ⟶ rescale_functor j\n| 0     1     := 𝟙 _\n| 1     (j+2) := to_rescale (j+2)!\n| (i+2) (j+2) := scale (i+2)! (j+2)!\n| _     _     := 0\n\nsection scale_index\n\n@[simps]\ndef ScaleIndexLeft (κ : ℝ≥0) : system_of_complexes ⥤ system_of_complexes :=\n(whiskering_left _ _ _).obj (nnreal.MulLeft κ).op\n\n@[simp] lemma ScaleIndexLeft_apply (C : system_of_complexes) (κ c : ℝ≥0) (i : ℕ) :\n  (ScaleIndexLeft κ).obj C c i = C (κ * c) i := rfl\n\ndef scale_index_left (C : system_of_complexes) (κ : ℝ≥0) := (ScaleIndexLeft κ).obj C\n\nlemma admissible.scale_index_left {C : system_of_complexes} (hC : C.admissible) (κ : ℝ≥0) :\n  (C.scale_index_left κ).admissible :=\n{ d_norm_noninc' := λ c i j hij, (by { apply admissible.d_norm_noninc C hC (κ * c) i j, }),\n  res_norm_noninc := λ c₁ c₂ i hc, hC.res_norm_noninc _ _ i\n    (by { resetI, dsimp, apply_instance }) }\n\nlemma is_weak_bounded_exact.scale_index_left\n  {C : system_of_complexes} {k K :ℝ≥0} {m : ℕ} (c₀ c₁: ℝ≥0) [fact (1 ≤ k)]\n  (hC : C.is_weak_bounded_exact k K m c₀) (κ : ℝ≥0) [hκ : fact (c₀ ≤ κ * c₁)]\n  (C_adm : C.admissible) :\n  (C.scale_index_left κ).is_weak_bounded_exact k K m c₁ :=\nbegin\n  intros c hc i hi x ε hε,\n  dsimp [scale_index_left, ScaleIndexLeft_apply] at x,\n  haveI aux1 : fact (k * (κ * c) ≤ κ * (k * c)) := ⟨(mul_left_comm _ _ _).le⟩,\n  obtain ⟨i₀, j, hi₀, hj, y, hy⟩ := hC (κ * c) _ i hi (res x) ε hε,\n  swap, { exact ⟨hκ.1.trans $ fact.out _⟩, },\n  refine ⟨i₀, j, hi₀, hj, y, _⟩,\n  simp only [res_res, d_res] at hy,\n  refine hy.trans (add_le_add (mul_le_mul le_rfl _ (norm_nonneg _) K.coe_nonneg) le_rfl),\n  apply C_adm.res_norm_noninc,\nend\n\n@[simps]\ndef ScaleIndexRight (κ : ℝ≥0) : system_of_complexes ⥤ system_of_complexes :=\n(whiskering_left _ _ _).obj (nnreal.MulRight κ).op\n\n@[simp] lemma ScaleIndexRight_apply (C : system_of_complexes) (κ c : ℝ≥0) (i : ℕ) :\n  (ScaleIndexRight κ).obj C c i = C (c * κ) i := rfl\n\ndef scale_index_right (C : system_of_complexes) (κ : ℝ≥0) := (ScaleIndexRight κ).obj C\n\nlemma admissible.scale_index_right {C : system_of_complexes} (hC : C.admissible) (κ : ℝ≥0) :\n  (C.scale_index_right κ).admissible :=\n{ d_norm_noninc' := λ c i j hij, (by { apply admissible.d_norm_noninc C hC (c * κ) i j, }),\n  res_norm_noninc := λ c₁ c₂ i hc, hC.res_norm_noninc _ _ i\n    (by { resetI, dsimp, apply_instance }) }\n\nlemma is_weak_bounded_exact.scale_index_right\n  {C : system_of_complexes} {k K :ℝ≥0} {m : ℕ} (c₀ c₁ : ℝ≥0) [fact (1 ≤ k)]\n  (hC : C.is_weak_bounded_exact k K m c₀) (κ : ℝ≥0) [hκ : fact (c₀ ≤ κ * c₁)]\n  (C_adm : C.admissible) :\n  (C.scale_index_right κ).is_weak_bounded_exact k K m c₁ :=\nbegin\n  intros c hc i hi x ε hε,\n  dsimp [scale_index_right, ScaleIndexRight_apply] at x,\n  haveI aux1 : fact (k * (c * κ) ≤ k * c * κ) := ⟨(mul_assoc _ _ _).ge⟩,\n  obtain ⟨i₀, j, hi₀, hj, y, hy⟩ := hC (c * κ) _ i hi (res x) ε hε,\n  swap, { rw mul_comm, exact ⟨hκ.1.trans $ fact.out _⟩, },\n  refine ⟨i₀, j, hi₀, hj, y, _⟩,\n  simp only [res_res, d_res] at hy,\n  refine hy.trans (add_le_add (mul_le_mul le_rfl _ (norm_nonneg _) K.coe_nonneg) le_rfl),\n  apply C_adm.res_norm_noninc,\nend\n\nend scale_index\n\nend system_of_complexes\n\nnamespace thm95\n\ndef rescale_functor' : ℕ → ((ℝ≥0ᵒᵖ ⥤ SemiNormedGroup) ⥤ (ℝ≥0ᵒᵖ ⥤ SemiNormedGroup))\n| 0     := 𝟭 _\n| 1     := 𝟭 _\n| (m+2) := (whiskering_right _ _ _).obj (SemiNormedGroup.rescale (m+2)!)\n\ninstance rescale_functor'.additive : Π m, (rescale_functor' m).additive\n| 0     := functor.id.additive\n| 1     := functor.id.additive\n| (m+2) := {}\n\ndef to_rescale' (r : ℝ≥0) [fact (0 < r)] :\n  𝟭 (ℝ≥0ᵒᵖ ⥤ SemiNormedGroup) ⟶ ((whiskering_right _ _ _).obj (SemiNormedGroup.rescale r)) :=\n{ app := λ V,\n  { app := λ c, (SemiNormedGroup.to_rescale r).app _,\n    naturality' := by { intros c₁ c₂ h, dsimp, ext i : 2, refl } },\n  naturality' := λ C₁ C₂ f, by { ext, refl } }\n\n@[simps app]\ndef scale' (i j : ℝ≥0) [fact (0 < i)] [fact (0 < j)] :\n  ((whiskering_right ℝ≥0ᵒᵖ _ _).obj (SemiNormedGroup.rescale i)) ⟶\n  ((whiskering_right ℝ≥0ᵒᵖ _ _).obj (SemiNormedGroup.rescale j)) :=\n(whiskering_right ℝ≥0ᵒᵖ _ _).map $ SemiNormedGroup.scale i j\n\ndef rescale_nat_trans' : Π i j, rescale_functor' i ⟶ rescale_functor' j\n| 0     1     := 𝟙 _\n| 1     (j+2) := to_rescale' (j+2)!\n| (i+2) (j+2) := scale' (i+2)! (j+2)!\n| _     _     := 0\n\nend thm95\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/system_of_complexes/rescale.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4919199104568177}}
{"text": "/-\nDefines a normal ASP program and its three-valued semantics\n-/\n\nimport primitives\nimport misc\nimport .complete_lattice.I\nimport order.fixed_points\nopen tv\nopen order_hom\nopen atom\n\nstructure Rule :=\n  (head : atom)\n  (pbody : list atom)\n  (nbody : list atom)\ndef Program := list Rule\n\n\n-- set_option trace.simplify.rewrite true\n\n\nnamespace Rule\n  def eval_pbody (self : Rule) (i : I) : tv := tv.conj (i.eval self.pbody) \n  def eval_nbody (self : Rule) (i : I) : tv := tv.conj (tv.negl (i.eval self.nbody))\n  def eval_body (self : Rule) (i_pos i_neg : I) : tv := (self.eval_pbody i_pos) ⊓ (self.eval_nbody i_neg)\n  def eval_head (self : Rule) (i : I) : tv := i self.head\n\n  @[simp] def eval_pbody_monotone (r : Rule) : monotone r.eval_pbody := λ a b c, begin\n    unfold Rule.eval_pbody,\n    induction r.pbody, exact rfl.ge,\n    unfold tv.conj at |- ih, unfold tv.inf at |- ih,\n    rw [I.unfold_eval a, I.unfold_eval b],\n    have t : ⊤ = vtrue := by { refl },\n    have rd_a := tv.foldl_remove_default (a hd),\n    have rd_b := tv.foldl_remove_default (b hd),\n    rw t at rd_a rd_b, rw [rd_a, rd_b], rw [@tv.foldl_min_extract (a hd), @tv.foldl_min_extract (b hd)],\n    exact min_le_min (c.p hd) ih,\n  end\n\n  def eval_body_monotone (r : Rule) (i_neg : I) : monotone (λ i_pos, r.eval_body i_pos i_neg) :=\n      λ a b c, inf_le_inf (eval_pbody_monotone r c) (rfl.ge)\n\n  def reduct_satisfied (r : Rule) (i_pos i_neg : I) : Prop := r.eval_body i_pos i_neg <= r.eval_head i_pos\n  def satisfied (r : Rule) (i : I) := r.reduct_satisfied i i\n\nend Rule\n\ninstance : has_mem Rule Program := ⟨@list.mem Rule⟩ \nnamespace Program\n  structure reduct_model (self : Program) (i_pos i_neg : I) : Prop :=\n    (p : ∀r ∈ self, Rule.reduct_satisfied r i_pos i_neg)\n  def model (self : Program) (i : I) := self.reduct_model i i\n  structure stable_model (self : Program) (i : I) : Prop :=\n    (m : self.model i)\n    (p : ∀ii < i, ¬(self.reduct_model ii i))\n\n  def atoms (p : Program) : set atom := {\n    a : atom | ∃ (r : Rule) (m : r ∈ p), a = r.head ∨ a ∈ r.pbody ∨ a ∈ r.nbody\n  }\n\n  instance Program.has_subset : has_subset Program := list.has_subset\n\n  lemma subset_atoms_subset (p : Program) {p' : Program} (ss : p ⊆ p') : p.atoms ⊆ p'.atoms := λ a amem, begin\n    cases amem with r b, cases b with rmem,\n    exact Exists.intro r (Exists.intro (ss rmem) b_h),\n  end\n\n  def atoms_list : Program -> list atom\n  | [] := []\n  | (r::tl) := (r.head::(r.pbody ++ r.nbody)) ++ (atoms_list tl)\n\n  lemma atoms_atoms_list_mem_iff {p : Program} (a : atom) : a ∈ p.atoms ↔ a ∈ p.atoms_list := begin     split; assume h,     induction p,      cases h, cases h_h, change false at h_h_w,     contradiction,     cases h with r h2, cases h2 with r_mem acond,     cases r_mem,     unfold atoms_list,     cases acond,     rw [<-r_mem, acond],     exact list.mem_cons_self r.head ((r.pbody ++ r.nbody).append (atoms_list p_tl)),     cases acond; right; rw <-r_mem,     change a ∈ ((r.pbody ++ r.nbody) ++ (atoms_list p_tl)),     rw list.mem_append_eq, left, rw list.mem_append_eq, left,     exact acond,     change a ∈ ((r.pbody ++ r.nbody) ++ (atoms_list p_tl)),     rw list.mem_append_eq, left, rw list.mem_append_eq, right,     exact acond, right,     change a ∈ ((p_hd.pbody ++ p_hd.nbody) ++ (atoms_list p_tl)),     change r ∈ p_tl at r_mem,     rw list.mem_append_eq, right,     refine p_ih _,     exact Exists.intro r (Exists.intro r_mem acond),     induction p, change false at h, contradiction,     cases h,     refine Exists.intro p_hd (Exists.intro (list.mem_cons_self p_hd p_tl) _),     exact or.inl h,     change a ∈ ((p_hd.pbody ++ p_hd.nbody) ++ (atoms_list p_tl)) at h,     repeat {rw list.mem_append_eq at h},     repeat {cases h},     refine Exists.intro p_hd (Exists.intro (list.mem_cons_self p_hd p_tl) _),     right, left, exact h,     refine Exists.intro p_hd (Exists.intro (list.mem_cons_self p_hd p_tl) _),     right, right, exact h,     have h2 := p_ih h,     cases h2 with r h3, cases h3 with rmem acond,     have rmem2 : r ∈ p_hd :: p_tl := list.mem_of_mem_tail rmem,     exact Exists.intro r (Exists.intro rmem2 acond),   end \n\n  instance program_atom_mem_decidable {p : Program} {a : atom} : decidable (a ∈ p.atoms) := begin\n    rw (@atoms_atoms_list_mem_iff p a),\n    exact @list.decidable_mem atom atom.decidable_eq a p.atoms_list\n  end \n\n  instance program_forall_atom_mem_decidable (p : Program) {prop : atom -> Prop} [decidable_pred prop] : decidable (∀ a ∈ p.atoms, prop a) := begin\n    by_cases ∀ a ∈ p.atoms_list, prop a,\n    apply decidable.is_true, intros a amem, \n    exact h a ((atoms_atoms_list_mem_iff a).mp amem),\n    apply decidable.is_false, simp at |- h, cases h with x,\n    refine Exists.intro x (and.intro ((atoms_atoms_list_mem_iff x).mpr h_h.left) h_h.right),\n  end\n\n  instance program_exists_atom_mem_decidable (p : Program) {prop : atom -> Prop} [decidable_pred prop] : decidable (∃ a ∈ p.atoms, prop a) := begin\n    by_cases ∀ a ∈ p.atoms, ¬prop a,\n    apply decidable.is_false, simp, exact h,\n    apply decidable.is_true, simp at h, exact bex_def.mpr h,\n  end\nend Program\n\n\n\ndef localize (p : Program) (i : I) : I := λ a, if a ∈ p.atoms then i a else vfalse\nlemma localize.monotone {p : Program} : monotone $ localize p := λ _ _ c, I.less_than_or_equal.mk (λ a, by {unfold localize, split_ifs, exact c.p a, exact rfl.le})\ndef Program.localize (p : Program) : I →o I := ⟨localize p, localize.monotone⟩\n\n\ndef Program.I (p : Program) := { i : I // p.localize i = i }\n@[reducible] noncomputable instance Program.I.complete_lattice {p : Program} : complete_lattice p.I := fixed_points.function.fixed_points.complete_lattice p.localize\nlemma Program.localize_single_fixedpoint {p : Program} {i : I} : p.localize (p.localize i) = p.localize i := by {ext, unfold_coes, simp, unfold_coes, unfold Program.localize, simp, unfold localize, split_ifs, all_goals {refl}}\ndef Program.I.mk {p : Program} (i : I) : p.I := subtype.mk (p.localize i) Program.localize_single_fixedpoint\n-- p.localize pi.val carries more info and may be more convenient. \n-- Program.I.ext validates the correctness of this choice\ninstance {p : Program} : has_coe_to_fun p.I (λ _, I) := ⟨λ pi, p.localize pi.val⟩\n@[ext] lemma Program.I.ext {p : Program} {i ii : p.I} : (∀ a : atom, i a = ii a) ↔ i = ii := begin\n  have i_prop := i.prop, unfold_coes at i_prop, \n  have ii_prop := ii.prop, unfold_coes at ii_prop, \n  split; intro h, unfold_coes at h,\n  rw [i_prop, ii_prop] at h,\n  ext, unfold_coes, exact h x,\n  intro a, unfold_coes,\n  rw [function.funext_iff.mp i_prop a, function.funext_iff.mp ii_prop a],\n  exact congr_fun (congr_arg subtype.val h) a,\nend\nlemma Program.I.not_mem_atom_vfalse {p : Program} {pi : p.I} {a : atom} (anmem : a ∉ p.atoms) : pi a = vfalse := by { unfold_coes, unfold Program.localize, simp, unfold localize, split_ifs, refl }\n\ninstance Program.has_subset : has_subset Program := list.has_subset\n\ninstance {p : Program} : decidable_eq p.I := begin\n  intros i1 i2,\n  by_cases ∀ a ∈ p.atoms, i1 a = i2 a,\n  apply decidable.is_true,\n  apply Program.I.ext.mp, intro a,\n  by_cases h2 : a ∈ p.atoms, exact h a h2,\n  repeat {rw Program.I.not_mem_atom_vfalse h2},\n  apply decidable.is_false,\n  simp at h, rw <-Program.I.ext, simp, cases h with c,\n  exact Exists.intro c h_h.right,\nend\n\n\n\ndef construct_all_interps {p : Program} : list p.I := sorry\ndef all_interps_complete {p : Program} (i : p.I) : i ∈ (@construct_all_interps p) := sorry\n\ninstance {p : Program} : fintype p.I := fintype.mk ((@construct_all_interps p).to_finset) (λ x, list.mem_to_finset.mpr (all_interps_complete x))\n\n\n\ninstance Program.I.has_compl {p : Program} : has_compl p.I := begin\n  constructor, assume i, fconstructor,\n  exact p.localize (λ x : atom, -(i x)),\n  rw Program.localize_single_fixedpoint,\nend\n\n\ninstance Program.I.is_complemented {p : Program} : is_complemented p.I := begin\n  fconstructor, assume a,\n  refine Exists.intro _ _,\n  exact aᶜ,\n  fconstructor,\n  fconstructor, assume x,\nend\n\n-- def finset_interpretation {p.I} (fs : finset atom) : finset \n\n\n-- #check [].to_finset\n\n-- instance {p : Program} : fintype p.I := begin\n--   let atoms_pow := p.atoms_list.to_finset.powerset,\n--   have atoms_pow2 := p.atoms_list.to_finset.powerset,\n--   have g := atoms_pow2.map (λ x, x),\n--   let interps := finset.map (λ x : finset atom, x) atoms_pow,\n\n--   refine fintype.mk _ _,\n--   have h := p.atoms_list,\n--   refine finset.mk _ _,\n-- end\n\n\nnamespace Rule\n  lemma atom_program_mem_pbody {p : Program} (r : Rule) (rmem : r ∈ p) (a : atom) : a ∈ r.pbody -> a ∈ p.atoms := λ h, begin\n    refine Exists.intro r (Exists.intro rmem _),\n    right, left, exact h,\n  end\n  lemma atom_program_mem_nbody {p : Program} (r : Rule) (rmem : r ∈ p) (a : atom) : a ∈ r.nbody -> a ∈ p.atoms := λ h, begin\n    refine Exists.intro r (Exists.intro rmem _),\n    right, right, exact h,\n  end\nend Rule\n", "meta": {"author": "sjkillen", "repo": "Lean", "sha": "323e99f48fecfa4fc6ad9155eac4d939b2097930", "save_path": "github-repos/lean/sjkillen-Lean", "path": "github-repos/lean/sjkillen-Lean/Lean-323e99f48fecfa4fc6ad9155eac4d939b2097930/april-asp/src/program.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431679972357831, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4919199029263209}}
{"text": "/-\nhttps://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Redefine.20precedence.20of.20.60infix.60\n-/\nimport tactic.localized\nopen tactic\n\nuniverse u\n\nnamespace domain\n\nclass has_wedge (α : Type u) := (wedge : α → α → α)\n\nlocalized \"infix ∧:70 := has_wedge.wedge\" in domain\n\nend domain\n\nnamespace userland\n\nopen domain\nopen_locale domain\n\n-- I'm being lazy here to define a dummy wedge\ninstance nat.to_has_wedge : has_wedge ℕ := {\n  wedge := (*)\n}\n\nlemma dummy : 2 ∧ 3 = 6 := rfl\n\n/-\nfailed to synthesize type class instance for\n⊢ has_wedge Prop\n-/\n-- lemma dummy' : (2 ∧ 3 = 6) ∧ (2 ∧ 9 = 18) := sorry\n\nend userland\n\n-- \\curlywedge ⋏\n-- \\curlyvee ⋎\n", "meta": {"author": "utensil", "repo": "lean-playground", "sha": "77dc2dd18ea1498c766e09c3e488c2f9d3069ba6", "save_path": "github-repos/lean/utensil-lean-playground", "path": "github-repos/lean/utensil-lean-playground/lean-playground-77dc2dd18ea1498c766e09c3e488c2f9d3069ba6/lean3/src/zulip/local_wedge.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.4919199005441559}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport tactic.elementwise\nimport category_theory.concrete_category.bundled_hom\nimport algebra.punit_instances\nimport category_theory.functor.reflects_isomorphisms\n\n/-!\n# Category instances for monoid, add_monoid, comm_monoid, and add_comm_monoid.\n\nWe introduce the bundled categories:\n* `Mon`\n* `AddMon`\n* `CommMon`\n* `AddCommMon`\nalong with the relevant forgetful functors between them.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of monoids and monoid morphisms. -/\n@[to_additive AddMon]\ndef Mon : Type (u+1) := bundled monoid\n\n/-- The category of additive monoids and monoid morphisms. -/\nadd_decl_doc AddMon\n\nnamespace Mon\n\n/-- `monoid_hom` doesn't actually assume associativity. This alias is needed to make the category\ntheory machinery work. -/\n@[to_additive \"`add_monoid_hom` doesn't actually assume associativity. This alias is needed to make\nthe category theory machinery work.\"]\nabbreviation assoc_monoid_hom (M N : Type*) [monoid M] [monoid N] := monoid_hom M N\n\n@[to_additive]\ninstance bundled_hom : bundled_hom assoc_monoid_hom :=\n⟨λ M N [monoid M] [monoid N], by exactI @monoid_hom.to_fun M N _ _,\n λ M [monoid M], by exactI @monoid_hom.id M _,\n λ M N P [monoid M] [monoid N] [monoid P], by exactI @monoid_hom.comp M N P _ _ _,\n λ M N [monoid M] [monoid N], by exactI @monoid_hom.coe_inj M N _ _⟩\n\nattribute [derive [large_category, concrete_category]] Mon\nattribute [to_additive] Mon.large_category Mon.concrete_category\n\n@[to_additive] instance : has_coe_to_sort Mon Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `Mon` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [monoid M] : Mon := bundled.of M\n\n/-- Construct a bundled `Mon` from the underlying type and typeclass. -/\nadd_decl_doc AddMon.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `Mon`. -/\n@[to_additive] def of_hom {X Y : Type u} [monoid X] [monoid Y] (f : X →* Y) :\n  of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddMon`. -/\nadd_decl_doc AddMon.of_hom\n\n@[simp] lemma of_hom_apply {X Y : Type u} [monoid X] [monoid Y] (f : X →* Y)\n  (x : X) : of_hom f x = f x := rfl\n\n@[to_additive]\ninstance : inhabited Mon :=\n-- The default instance for `monoid punit` is derived via `punit.comm_ring`,\n-- which breaks to_additive.\n⟨@of punit $ @group.to_monoid _ $ @comm_group.to_group _ punit.comm_group⟩\n\n@[to_additive]\ninstance (M : Mon) : monoid M := M.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [monoid R] : (Mon.of R : Type u) = R := rfl\n\nend Mon\n\n/-- The category of commutative monoids and monoid morphisms. -/\n@[to_additive AddCommMon]\ndef CommMon : Type (u+1) := bundled comm_monoid\n\n/-- The category of additive commutative monoids and monoid morphisms. -/\nadd_decl_doc AddCommMon\n\nnamespace CommMon\n\n@[to_additive]\ninstance : bundled_hom.parent_projection comm_monoid.to_monoid := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommMon\nattribute [to_additive] CommMon.large_category CommMon.concrete_category\n\n@[to_additive] instance : has_coe_to_sort CommMon Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `CommMon` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [comm_monoid M] : CommMon := bundled.of M\n\n/-- Construct a bundled `AddCommMon` from the underlying type and typeclass. -/\nadd_decl_doc AddCommMon.of\n\n@[to_additive]\ninstance : inhabited CommMon :=\n-- The default instance for `comm_monoid punit` is derived via `punit.comm_ring`,\n-- which breaks to_additive.\n⟨@of punit $ @comm_group.to_comm_monoid _ punit.comm_group⟩\n\n@[to_additive]\ninstance (M : CommMon) : comm_monoid M := M.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [comm_monoid R] : (CommMon.of R : Type u) = R := rfl\n\n@[to_additive has_forget_to_AddMon]\ninstance has_forget_to_Mon : has_forget₂ CommMon Mon := bundled_hom.forget₂ _ _\n\nend CommMon\n\n-- We verify that the coercions of morphisms to functions work correctly:\nexample {R S : Mon}     (f : R ⟶ S) : (R : Type) → (S : Type) := f\nexample {R S : CommMon} (f : R ⟶ S) : (R : Type) → (S : Type) := f\n\n-- We verify that when constructing a morphism in `CommMon`,\n-- when we construct the `to_fun` field, the types are presented as `↥R`,\n-- rather than `R.α` or (as we used to have) `↥(bundled.map comm_monoid.to_monoid R)`.\nexample (R : CommMon.{u}) : R ⟶ R :=\n{ to_fun := λ x,\n  begin\n    match_target (R : Type u),\n    match_hyp x : (R : Type u),\n    exact x * x\n  end ,\n  map_one' := by simp,\n  map_mul' := λ x y,\n  begin rw [mul_assoc x y (x * y), ←mul_assoc y x y, mul_comm y x, mul_assoc, mul_assoc], end, }\n\nvariables {X Y : Type u}\n\nsection\nvariables [monoid X] [monoid Y]\n\n/-- Build an isomorphism in the category `Mon` from a `mul_equiv` between `monoid`s. -/\n@[to_additive add_equiv.to_AddMon_iso \"Build an isomorphism in the category `AddMon` from\nan `add_equiv` between `add_monoid`s.\", simps]\ndef mul_equiv.to_Mon_iso (e : X ≃* Y) : Mon.of X ≅ Mon.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\nend\n\nsection\nvariables [comm_monoid X] [comm_monoid Y]\n\n/-- Build an isomorphism in the category `CommMon` from a `mul_equiv` between `comm_monoid`s. -/\n@[to_additive add_equiv.to_AddCommMon_iso \"Build an isomorphism in the category `AddCommMon`\nfrom an `add_equiv` between `add_comm_monoid`s.\", simps]\ndef mul_equiv.to_CommMon_iso (e : X ≃* Y) : CommMon.of X ≅ CommMon.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\nend\n\nnamespace category_theory.iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Mon`. -/\n@[to_additive AddMon_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism in the category\n`AddMon`.\"]\ndef Mon_iso_to_mul_equiv {X Y : Mon} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\n/-- Build a `mul_equiv` from an isomorphism in the category `CommMon`. -/\n@[to_additive \"Build an `add_equiv` from an isomorphism in the category\n`AddCommMon`.\"]\ndef CommMon_iso_to_mul_equiv {X Y : CommMon} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\nend category_theory.iso\n\n/-- multiplicative equivalences between `monoid`s are the same as (isomorphic to) isomorphisms\nin `Mon` -/\n@[to_additive add_equiv_iso_AddMon_iso \"additive equivalences between `add_monoid`s are the same\nas (isomorphic to) isomorphisms in `AddMon`\"]\ndef mul_equiv_iso_Mon_iso {X Y : Type u} [monoid X] [monoid Y] :\n  (X ≃* Y) ≅ (Mon.of X ≅ Mon.of Y) :=\n{ hom := λ e, e.to_Mon_iso,\n  inv := λ i, i.Mon_iso_to_mul_equiv, }\n\n/-- multiplicative equivalences between `comm_monoid`s are the same as (isomorphic to) isomorphisms\nin `CommMon` -/\n@[to_additive add_equiv_iso_AddCommMon_iso \"additive equivalences between `add_comm_monoid`s are\nthe same as (isomorphic to) isomorphisms in `AddCommMon`\"]\ndef mul_equiv_iso_CommMon_iso {X Y : Type u} [comm_monoid X] [comm_monoid Y] :\n  (X ≃* Y) ≅ (CommMon.of X ≅ CommMon.of Y) :=\n{ hom := λ e, e.to_CommMon_iso,\n  inv := λ i, i.CommMon_iso_to_mul_equiv, }\n\n@[to_additive]\ninstance Mon.forget_reflects_isos : reflects_isomorphisms (forget Mon.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Mon).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Mon_iso).1⟩,\n  end }\n\n@[to_additive]\ninstance CommMon.forget_reflects_isos : reflects_isomorphisms (forget CommMon.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommMon).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommMon_iso).1⟩,\n  end }\n\n/-!\nOnce we've shown that the forgetful functors to type reflect isomorphisms,\nwe automatically obtain that the `forget₂` functors between our concrete categories\nreflect isomorphisms.\n-/\nexample : reflects_isomorphisms (forget₂ CommMon Mon) := by apply_instance\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/category/Mon/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.7431679972357831, "lm_q1q2_score": 0.4919198979699901}}
{"text": "import data.real.basic\n\n\n--OUTPUT 1\ntheorem nesbitt_inequality {a b c : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) :=\nbegin\n  have h1 : (a + b + c) / (b + c) + (a + b + c) / (a + c) + (a + b + c) / (a + b) ≥ 9 / 2, from sorry,\n  have h2 : (a + b + c) / (b + c) + (a + b + c) / (a + c) + (a + b + c) / (a + b) ≥ 3 / ((b + c) + (a + c) + (a + b)), from sorry,\n  have h3 : (1 / (b + c) + 1 / (a + c) + 1 / (a + b)) / 3 ≥ 3 / ((b + c) + (a + c) + (a + b)), from sorry,\n  show (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2), from sorry,\nend\n\n--OUTPUT 2\ntheorem nesbitt_inequality {a b c : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) :=\nbegin\n  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n                                                                                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem nesbitt_inequality {a b c : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) :=\nbegin\n  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) : by {\n    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) = (a + b + c) / (b + c) + (a + b + c) / (a + c) + (a + b + c) / (a + b) : by sorry\n    ... ≥ (9 * (a + b + c)) / ((b + c) + (a + c) + (a + b)) : by sorry\n    ... ≥ (3 / ((b + c) + (a + c) + (a + b))) : by sorry\n    ... ≥ (3 / 2) : by sorry,\n  },\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n  have h2 : (A ∩ B) ⊆ A, from sorry,\n  have h3 : (A ∩ B) ⊆ S, from sorry,\n  show (A ∩ B) ∈  𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by sorry\n  ... = x*(x+y) + y*(x+y) : by sorry\n  ... = x*x + x*y + y*x + y*y : by sorry\n  ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n  have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n      have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n      show e = (1 : G), from sorry,     \n    },\n    sorry,\n  }\nend\n\n/--`theorem`\nNesbitt's inequality\nLet $a$, $b$ and $c$ be positive real numbers.\n\nThen:\n:$\\dfrac a {b + c} + \\dfrac b {a + c} + \\dfrac c {a + b} \\ge \\dfrac 3 2$\n\n`proof`\n{{begin-eqn}}\n{{eqn | l = \\frac a {b + c} + \\frac b {a + c} + \\frac c {a + b}\n      | o = \\ge\n      | r = \\dfrac 3 2\n}}\n{{eqn | ll= \\leadstoandfrom\n      | l = \\frac {a + b + c} {b + c} + \\frac {a + b + c} {a + c} + \\frac {a + b + c} {a + b}\n      | o = \\ge\n      | r = \\frac 9 2\n      | c = by adding $3$\n}}\n{{eqn | ll= \\leadstoandfrom\n      | l = \\frac {a + b + c} {b + c} + \\frac {a + b + c} {a + c} + \\frac {a + b + c} {a + b}\n      | o = \\ge\n      | r = \\frac {9 \\paren {a + b + c} } {\\paren {b + c} + \\paren {a + c} + \\paren {a + b} }\n      | c = as $\\dfrac {a + b + c} {\\paren {b + c} + \\paren {a + c} + \\paren {a + b} } = \\dfrac 1 2$\n}}\n{{eqn | ll= \\leadstoandfrom\n      | l = \\frac {\\frac 1 {b + c} + \\frac 1 {a + c} + \\frac 1 {a + b} } 3\n      | o = \\ge\n      | r = \\frac 3 {\\paren {b + c} + \\paren {a + c} + \\paren {a + b} }\n      | c = dividing by $3 \\paren {a + b + c}$\n}}\n{{end-eqn}}\nThese are the arithmetic mean and the harmonic mean of $\\dfrac 1 {b + c}$, $\\dfrac 1 {a + c}$ and $\\dfrac 1 {a + b}$.\n\nFrom Arithmetic Mean is Never Less than Harmonic Mean the last inequality is true.\n\nThus Nesbitt's Inequality holds.\n{{qed}}\n\n-/\ntheorem  nesbitt_inequality {a b c : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) ≥ (3 / 2) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0.2_max_tokens_2000_n_3/clean_files/Nesbitt inequality.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.89330940889474, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4918627402393756}}
{"text": "import data.real.basic\nimport algebra.ring.basic\nimport algebra.group_power.order\nimport algebra.group_with_zero.basic\n\n\n\ntheorem IMO_2008_Pb_4 (f:ℝ  → ℝ)(hf0:∀(x:ℝ), (0<x) → (0 <f x))\n(hf: ∀(x y z w :ℝ), (0<x∧0<z∧0<y∧0<w) → ((f w^2)+(f x^2))/ (f (y^2)+(f (z^2))) = (w^2+x^2)/(y^2+z^2)):\n(∀ (x:ℝ), 0<x→ f x = x)∨(∀ (x:ℝ),0<x → f x = 1/x):=\nbegin\n  sorry\nend", "meta": {"author": "ahayat16", "repo": "lean_exos", "sha": "682f2552d5b04a8c8eb9e4ab15f875a91b03845c", "save_path": "github-repos/lean/ahayat16-lean_exos", "path": "github-repos/lean/ahayat16-lean_exos/lean_exos-682f2552d5b04a8c8eb9e4ab15f875a91b03845c/IMO_2008_Pb_4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267626522814, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.49177205153561526}}
{"text": "import to_mathlib_maybe.Hilbert_space\nimport entropy\nimport state\n\nimport Lemma3\n\nnotation `D(`ρ`,`σ`)` := 1/2 * ∥ρ - σ∥₁\nnotation ρ`^⊗`n := tpow ρ n\n\nvariables {ℋ : Type} [complex_hilbert_space ℋ]\n{ρ ρ' : module.End ℂ ℋ} [quantum_state ρ]\n[H(ρ) ≤ H(ρ')]\n\ndef dephasing_channel_in_eigenbasis (ρ : module.End ℂ ℋ) [quantum_state ρ] : quantum_channel := sorry\n\nnotation `𝒟 ` ρ := dephasing_channel_in_eigenbasis ρ\n\n/--\n\"The next Lemma will be essential to construct a candidate\ncatalyst by making use of Lemma 3. It is based on the Schur-Horn \ntheorem, which states that for any d×d Hermitian matrix its vector \nof eigenvalues λ majorizes the vector of diagonal elements in every \northonormal basis. Conversely, every vector that is majorized by λ \nmay be obtained as the diagonal elements in a suitable orthonormal \nbasis.\"\n-/\nlemma basic_lemma : \n∀ ε > 0, ∃ (n : ℕ), ∃ (U : module.End ℂ ℋ) [unitary U], ∀ k ≤ n,\nD(ρ', 𝒟(pTr_{1,..,n}\\{k} (U * ρ^⊗n * U†))) ≤ ε := \nbegin\n  sorry\nend", "meta": {"author": "BassemSafieldeen", "repo": "Entropy_and_reversible_catalysis", "sha": "5dd6ee062f61e26bbcf254477e3e24aa3fc489af", "save_path": "github-repos/lean/BassemSafieldeen-Entropy_and_reversible_catalysis", "path": "github-repos/lean/BassemSafieldeen-Entropy_and_reversible_catalysis/Entropy_and_reversible_catalysis-5dd6ee062f61e26bbcf254477e3e24aa3fc489af/src/Lemma4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8459424295406087, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.49174894879911507}}
{"text": "/-\nCopyright (c) 2019 Seul Baek. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Seul Baek\n\n! This file was ported from Lean 3 source module tactic.omega.int.main\n! leanprover-community/mathlib commit 58581d0fe523063f5651df0619be2bf65012a94a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.Omega.ProveUnsats\nimport Mathbin.Tactic.Omega.Int.Dnf\n\n/-\nMain procedure for linear integer arithmetic.\n-/\nopen Tactic\n\nnamespace Omega\n\nnamespace Int\n\nopen Omega.Int\n\nrun_cmd\n  mk_simp_attr `sugar\n\nattribute [sugar]\n  Ne not_le not_lt Int.lt_iff_add_one_le or_false_iff false_or_iff and_true_iff true_and_iff GE.ge GT.gt mul_add add_mul one_mul mul_one mul_comm sub_eq_add_neg imp_iff_not_or iff_iff_not_or_and_or_not\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\nunsafe def desugar :=\n  sorry\n#align omega.int.desugar omega.int.desugar\n\ntheorem univClose_of_unsat_clausify (m : Nat) (p : Preform) :\n    Clauses.Unsat (dnf (¬* p)) → UnivClose p (fun x => 0) m\n  | h1 => by\n    apply univ_close_of_valid\n    apply valid_of_unsat_not\n    apply unsat_of_clauses_unsat\n    exact h1\n#align omega.int.univ_close_of_unsat_clausify Omega.Int.univClose_of_unsat_clausify\n\n/-- Given a (p : preform), return the expr of a (t : univ_close m p) -/\nunsafe def prove_univ_close (m : Nat) (p : Preform) : tactic expr := do\n  let x ← prove_unsats (dnf (¬* p))\n  return q(univClose_of_unsat_clausify $(q(m)) $(q(p)) $(x))\n#align omega.int.prove_univ_close omega.int.prove_univ_close\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/-- Reification to imtermediate shadow syntax that retains exprs -/ unsafe\n  def\n    to_exprterm\n    : expr → tactic exprterm\n    |\n        q( - $ ( x ) )\n        =>\n        ( do let z ← eval_expr' Int x return ( exprterm.cst ( - z : Int ) ) )\n          <|>\n          ( return <| exprterm.exp ( - 1 : Int ) x )\n      | q( $ ( mx ) * $ ( zx ) ) => do let z ← eval_expr' Int zx return ( exprterm.exp z mx )\n      |\n        q( $ ( t1x ) + $ ( t2x ) )\n        =>\n        do let t1 ← to_exprterm t1x let t2 ← to_exprterm t2x return ( exprterm.add t1 t2 )\n      |\n        x\n        =>\n        ( do let z ← eval_expr' Int x return ( exprterm.cst z ) ) <|> ( return <| exprterm.exp 1 x )\n#align omega.int.to_exprterm omega.int.to_exprterm\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/-- Reification to imtermediate shadow syntax that retains exprs -/ unsafe\n  def\n    to_exprform\n    : expr → tactic exprform\n    |\n        q( $ ( tx1 ) = $ ( tx2 ) )\n        =>\n        do let t1 ← to_exprterm tx1 let t2 ← to_exprterm tx2 return ( exprform.eq t1 t2 )\n      |\n        q( $ ( tx1 ) ≤ $ ( tx2 ) )\n        =>\n        do let t1 ← to_exprterm tx1 let t2 ← to_exprterm tx2 return ( exprform.le t1 t2 )\n      | q( ¬ $ ( px ) ) => do let p ← to_exprform px return ( exprform.not p )\n      |\n        q( $ ( px ) ∨ $ ( qx ) )\n        =>\n        do let p ← to_exprform px let q ← to_exprform qx return ( exprform.or p q )\n      |\n        q( $ ( px ) ∧ $ ( qx ) )\n        =>\n        do let p ← to_exprform px let q ← to_exprform qx return ( exprform.and p q )\n      | q( _ → $ ( px ) ) => to_exprform px\n      | x => ( trace \"Cannot reify expr : \" >> trace x ) >> failed\n#align omega.int.to_exprform omega.int.to_exprform\n\n/-- List of all unreified exprs -/\nunsafe def exprterm.exprs : exprterm → List expr\n  | exprterm.cst _ => []\n  | exprterm.exp _ x => [x]\n  | exprterm.add t s => List.union t.exprs s.exprs\n#align omega.int.exprterm.exprs omega.int.exprterm.exprs\n\n/-- List of all unreified exprs -/\nunsafe def exprform.exprs : exprform → List expr\n  | exprform.eq t s => List.union t.exprs s.exprs\n  | exprform.le t s => List.union t.exprs s.exprs\n  | exprform.not p => p.exprs\n  | exprform.or p q => List.union p.exprs q.exprs\n  | exprform.and p q => List.union p.exprs q.exprs\n#align omega.int.exprform.exprs omega.int.exprform.exprs\n\n/-- Reification to an intermediate shadow syntax which eliminates exprs,\n    but still includes non-canonical terms -/\nunsafe def exprterm.to_preterm (xs : List expr) : exprterm → tactic Preterm\n  | exprterm.cst k => return (&k)\n  | exprterm.exp k x =>\n    let m := xs.indexOfₓ x\n    if m < xs.length then return (k ** m) else failed\n  | exprterm.add xa xb => do\n    let a ← xa.to_preterm\n    let b ← xb.to_preterm\n    return (a +* b)\n#align omega.int.exprterm.to_preterm omega.int.exprterm.to_preterm\n\n/-- Reification to an intermediate shadow syntax which eliminates exprs,\n    but still includes non-canonical terms -/\nunsafe def exprform.to_preform (xs : List expr) : exprform → tactic Preform\n  | exprform.eq xa xb => do\n    let a ← xa.to_preterm xs\n    let b ← xb.to_preterm xs\n    return (a =* b)\n  | exprform.le xa xb => do\n    let a ← xa.to_preterm xs\n    let b ← xb.to_preterm xs\n    return (a ≤* b)\n  | exprform.not xp => do\n    let p ← xp.to_preform\n    return (¬* p)\n  | exprform.or xp xq => do\n    let p ← xp.to_preform\n    let q ← xq.to_preform\n    return (p ∨* q)\n  | exprform.and xp xq => do\n    let p ← xp.to_preform\n    let q ← xq.to_preform\n    return (p ∧* q)\n#align omega.int.exprform.to_preform omega.int.exprform.to_preform\n\n/-- Reification to an intermediate shadow syntax which eliminates exprs,\n    but still includes non-canonical terms. -/\nunsafe def to_preform (x : expr) : tactic (Preform × Nat) := do\n  let xf ← to_exprform x\n  let xs := xf.exprs\n  let f ← xf.to_preform xs\n  return (f, xs)\n#align omega.int.to_preform omega.int.to_preform\n\n/-- Return expr of proof of current LIA goal -/\nunsafe def prove : tactic expr := do\n  let (p, m) ← target >>= to_preform\n  trace_if_enabled `omega p\n  prove_univ_close m p\n#align omega.int.prove omega.int.prove\n\n/-- Succeed iff argument is the expr of ℤ -/\nunsafe def eq_int (x : expr) : tactic Unit :=\n  if x = q(Int) then skip else failed\n#align omega.int.eq_int omega.int.eq_int\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/-- Check whether argument is expr of a well-formed formula of LIA-/ unsafe\n  def\n    wff\n    : expr → tactic Unit\n    | q( ¬ $ ( px ) ) => wff px\n      | q( $ ( px ) ∨ $ ( qx ) ) => wff px >> wff qx\n      | q( $ ( px ) ∧ $ ( qx ) ) => wff px >> wff qx\n      | q( $ ( px ) ↔ $ ( qx ) ) => wff px >> wff qx\n      |\n        q( $ ( expr.pi _ _ px qx ) )\n        =>\n        Monad.cond\n          ( if expr.has_var px then return true else is_prop px )\n            ( wff px >> wff qx )\n            ( eq_int px >> wff qx )\n      | q( @ LT.lt $ ( dx ) $ ( h ) _ _ ) => eq_int dx\n      | q( @ LE.le $ ( dx ) $ ( h ) _ _ ) => eq_int dx\n      | q( @ Eq $ ( dx ) _ _ ) => eq_int dx\n      | q( @ GE.ge $ ( dx ) $ ( h ) _ _ ) => eq_int dx\n      | q( @ GT.gt $ ( dx ) $ ( h ) _ _ ) => eq_int dx\n      | q( @ Ne $ ( dx ) _ _ ) => eq_int dx\n      | q( True ) => skip\n      | q( False ) => skip\n      | _ => failed\n#align omega.int.wff omega.int.wff\n\n/-- Succeed iff argument is expr of term whose type is wff -/\nunsafe def wfx (x : expr) : tactic Unit :=\n  infer_type x >>= wff\n#align omega.int.wfx omega.int.wfx\n\n/-- Intro all universal quantifiers over ℤ -/\nunsafe def intro_ints_core : tactic Unit := do\n  let x ← target\n  match x with\n    | expr.pi _ _ q(Int) _ => intro_fresh >> intro_ints_core\n    | _ => skip\n#align omega.int.intro_ints_core omega.int.intro_ints_core\n\nunsafe def intro_ints : tactic Unit := do\n  let expr.pi _ _ q(Int) _ ← target\n  intro_ints_core\n#align omega.int.intro_ints omega.int.intro_ints\n\n/-- If the goal has universal quantifiers over integers, introduce all of them.\nOtherwise, revert all hypotheses that are formulas of linear integer arithmetic. -/\nunsafe def preprocess : tactic Unit :=\n  intro_ints <|> revert_cond_all wfx >> desugar\n#align omega.int.preprocess omega.int.preprocess\n\nend Int\n\nend Omega\n\nopen Omega.Int\n\n/-- The core omega tactic for integers. -/\nunsafe def omega_int (is_manual : Bool) : tactic Unit :=\n  andthen (andthen desugar (if is_manual then skip else preprocess)) ((prove >>= apply) >> skip)\n#align omega_int omega_int\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/Omega/Int/Main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765707, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.491736420724172}}
{"text": "/-\nCopyright (c) 2022 Yakov Pechersky. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yakov Pechersky\n\n! This file was ported from Lean 3 source module data.finsupp.big_operators\n! leanprover-community/mathlib commit f16e7a22e11fc09c71f25446ac1db23a24e8a0bd\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finsupp.Defs\nimport Mathbin.Data.Finset.Pairwise\n\n/-!\n\n# Sums of collections of finsupp, and their support\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\nThis file provides results about the `finsupp.support` of sums of collections of `finsupp`,\nincluding sums of `list`, `multiset`, and `finset`.\n\nThe support of the sum is a subset of the union of the supports:\n* `list.support_sum_subset`\n* `multiset.support_sum_subset`\n* `finset.support_sum_subset`\n\nThe support of the sum of pairwise disjoint finsupps is equal to the union of the supports\n* `list.support_sum_eq`\n* `multiset.support_sum_eq`\n* `finset.support_sum_eq`\n\nMember in the support of the indexed union over a collection iff\nit is a member of the support of a member of the collection:\n* `list.mem_foldr_sup_support_iff`\n* `multiset.mem_sup_map_support_iff`\n* `finset.mem_sup_support_iff`\n\n-/\n\n\nvariable {ι M : Type _} [DecidableEq ι]\n\n/- warning: list.support_sum_subset -> List.support_sum_subset is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))), HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (List.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finsupp.add.{u1, u2} ι M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) l)) (List.foldr.{max u1 u2, u1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} ι) (Function.comp.{max (succ u1) (succ u2), succ u1, succ u1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} ι) ((Finset.{u1} ι) -> (Finset.{u1} ι)) (Sup.sup.{u1} (Finset.{u1} ι) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))))) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} ι) (Finset.hasEmptyc.{u1} ι)) l)\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2))), HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.instHasSubsetFinset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2) (List.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Finsupp.add.{u1, u2} ι M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) l)) (List.foldr.{max u2 u1, u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} ι) (Function.comp.{succ (max u2 u1), succ u1, succ u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} ι) ((Finset.{u1} ι) -> (Finset.{u1} ι)) (fun (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.45 : Finset.{u1} ι) (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.47 : Finset.{u1} ι) => Sup.sup.{u1} (Finset.{u1} ι) (SemilatticeSup.toSup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)))) x._@.Mathlib.Data.Finsupp.BigOperators._hyg.45 x._@.Mathlib.Data.Finsupp.BigOperators._hyg.47) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} ι) (Finset.instEmptyCollectionFinset.{u1} ι)) l)\nCase conversion may be inaccurate. Consider using '#align list.support_sum_subset List.support_sum_subsetₓ'. -/\ntheorem List.support_sum_subset [AddMonoid M] (l : List (ι →₀ M)) :\n    l.Sum.support ⊆ l.foldr ((· ⊔ ·) ∘ Finsupp.support) ∅ :=\n  by\n  induction' l with hd tl IH\n  · simp\n  · simp only [List.sum_cons, Finset.union_comm]\n    refine' finsupp.support_add.trans (Finset.union_subset_union _ IH)\n    rfl\n#align list.support_sum_subset List.support_sum_subset\n\n/- warning: multiset.support_sum_subset -> Multiset.support_sum_subset is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.orderBot.{u1} ι) (Multiset.map.{max u1 u2, u1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) s))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.instHasSubsetFinset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι) (Multiset.map.{max u2 u1, u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) s))\nCase conversion may be inaccurate. Consider using '#align multiset.support_sum_subset Multiset.support_sum_subsetₓ'. -/\ntheorem Multiset.support_sum_subset [AddCommMonoid M] (s : Multiset (ι →₀ M)) :\n    s.Sum.support ⊆ (s.map Finsupp.support).sup :=\n  by\n  induction s using Quot.inductionOn\n  simpa using List.support_sum_subset _\n#align multiset.support_sum_subset Multiset.support_sum_subset\n\n/- warning: finset.support_sum_subset -> Finset.support_sum_subset is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.sum.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.orderBot.{u1} ι) s (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.instHasSubsetFinset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Finset.sum.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι) s (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))\nCase conversion may be inaccurate. Consider using '#align finset.support_sum_subset Finset.support_sum_subsetₓ'. -/\ntheorem Finset.support_sum_subset [AddCommMonoid M] (s : Finset (ι →₀ M)) :\n    (s.Sum id).support ⊆ Finset.sup s Finsupp.support := by\n  classical convert Multiset.support_sum_subset s.1 <;> simp\n#align finset.support_sum_subset Finset.support_sum_subset\n\n/- warning: list.mem_foldr_sup_support_iff -> List.mem_foldr_sup_support_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : Zero.{u2} M] {l : List.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)} {x : ι}, Iff (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x (List.foldr.{max u1 u2, u1} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{u1} ι) (Function.comp.{max (succ u1) (succ u2), succ u1, succ u1} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{u1} ι) ((Finset.{u1} ι) -> (Finset.{u1} ι)) (Sup.sup.{u1} (Finset.{u1} ι) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))))) (Finsupp.support.{u1, u2} ι M _inst_2)) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} ι) (Finset.hasEmptyc.{u1} ι)) l)) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M _inst_2) (fun (f : Finsupp.{u1, u2} ι M _inst_2) => Exists.{0} (Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (List.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) (List.hasMem.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f l) (fun (hf : Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (List.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) (List.hasMem.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f l) => Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x (Finsupp.support.{u1, u2} ι M _inst_2 f))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : Zero.{u2} M] {l : List.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)} {x : ι}, Iff (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) x (List.foldr.{max u2 u1, u1} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{u1} ι) (Function.comp.{succ (max u2 u1), succ u1, succ u1} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{u1} ι) ((Finset.{u1} ι) -> (Finset.{u1} ι)) (fun (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.336 : Finset.{u1} ι) (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.338 : Finset.{u1} ι) => Sup.sup.{u1} (Finset.{u1} ι) (SemilatticeSup.toSup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)))) x._@.Mathlib.Data.Finsupp.BigOperators._hyg.336 x._@.Mathlib.Data.Finsupp.BigOperators._hyg.338) (Finsupp.support.{u1, u2} ι M _inst_2)) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} ι) (Finset.instEmptyCollectionFinset.{u1} ι)) l)) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M _inst_2) (fun (f : Finsupp.{u1, u2} ι M _inst_2) => Exists.{0} (Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (List.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)) (List.instMembershipList.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f l) (fun (hf : Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (List.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)) (List.instMembershipList.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f l) => Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) x (Finsupp.support.{u1, u2} ι M _inst_2 f))))\nCase conversion may be inaccurate. Consider using '#align list.mem_foldr_sup_support_iff List.mem_foldr_sup_support_iffₓ'. -/\ntheorem List.mem_foldr_sup_support_iff [Zero M] {l : List (ι →₀ M)} {x : ι} :\n    x ∈ l.foldr ((· ⊔ ·) ∘ Finsupp.support) ∅ ↔ ∃ (f : ι →₀ M)(hf : f ∈ l), x ∈ f.support :=\n  by\n  simp only [Finset.sup_eq_union, List.foldr_map, Finsupp.mem_support_iff, exists_prop]\n  induction' l with hd tl IH\n  · simp\n  · simp only [IH, List.foldr_cons, Finset.mem_union, Finsupp.mem_support_iff, List.mem_cons]\n    constructor\n    · rintro (h | h)\n      · exact ⟨hd, Or.inl rfl, h⟩\n      · exact h.imp fun f hf => hf.imp_left Or.inr\n    · rintro ⟨f, rfl | hf, h⟩\n      · exact Or.inl h\n      · exact Or.inr ⟨f, hf, h⟩\n#align list.mem_foldr_sup_support_iff List.mem_foldr_sup_support_iff\n\n/- warning: multiset.mem_sup_map_support_iff -> Multiset.mem_sup_map_support_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : Zero.{u2} M] {s : Multiset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)} {x : ι}, Iff (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x (Multiset.sup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.orderBot.{u1} ι) (Multiset.map.{max u1 u2, u1} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M _inst_2) s))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M _inst_2) (fun (f : Finsupp.{u1, u2} ι M _inst_2) => Exists.{0} (Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Multiset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) (Multiset.hasMem.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) (fun (hf : Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Multiset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) (Multiset.hasMem.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) => Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x (Finsupp.support.{u1, u2} ι M _inst_2 f))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : Zero.{u2} M] {s : Multiset.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)} {x : ι}, Iff (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) x (Multiset.sup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι) (Multiset.map.{max u2 u1, u1} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M _inst_2) s))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M _inst_2) (fun (f : Finsupp.{u1, u2} ι M _inst_2) => Exists.{0} (Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Multiset.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)) (Multiset.instMembershipMultiset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) (fun (hf : Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Multiset.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)) (Multiset.instMembershipMultiset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) => Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) x (Finsupp.support.{u1, u2} ι M _inst_2 f))))\nCase conversion may be inaccurate. Consider using '#align multiset.mem_sup_map_support_iff Multiset.mem_sup_map_support_iffₓ'. -/\ntheorem Multiset.mem_sup_map_support_iff [Zero M] {s : Multiset (ι →₀ M)} {x : ι} :\n    x ∈ (s.map Finsupp.support).sup ↔ ∃ (f : ι →₀ M)(hf : f ∈ s), x ∈ f.support :=\n  Quot.inductionOn s fun _ => by simpa using List.mem_foldr_sup_support_iff\n#align multiset.mem_sup_map_support_iff Multiset.mem_sup_map_support_iff\n\n/- warning: finset.mem_sup_support_iff -> Finset.mem_sup_support_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : Zero.{u2} M] {s : Finset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)} {x : ι}, Iff (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x (Finset.sup.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M _inst_2) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.orderBot.{u1} ι) s (Finsupp.support.{u1, u2} ι M _inst_2))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M _inst_2) (fun (f : Finsupp.{u1, u2} ι M _inst_2) => Exists.{0} (Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) (Finset.hasMem.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) (fun (hf : Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) (Finset.hasMem.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) => Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x (Finsupp.support.{u1, u2} ι M _inst_2 f))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : Zero.{u2} M] {s : Finset.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)} {x : ι}, Iff (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) x (Finset.sup.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M _inst_2) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι) s (Finsupp.support.{u1, u2} ι M _inst_2))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M _inst_2) (fun (f : Finsupp.{u1, u2} ι M _inst_2) => Exists.{0} (Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)) (Finset.instMembershipFinset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) (fun (hf : Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M _inst_2) (Finset.{max u2 u1} (Finsupp.{u1, u2} ι M _inst_2)) (Finset.instMembershipFinset.{max u1 u2} (Finsupp.{u1, u2} ι M _inst_2)) f s) => Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) x (Finsupp.support.{u1, u2} ι M _inst_2 f))))\nCase conversion may be inaccurate. Consider using '#align finset.mem_sup_support_iff Finset.mem_sup_support_iffₓ'. -/\ntheorem Finset.mem_sup_support_iff [Zero M] {s : Finset (ι →₀ M)} {x : ι} :\n    x ∈ s.sup Finsupp.support ↔ ∃ (f : ι →₀ M)(hf : f ∈ s), x ∈ f.support :=\n  Multiset.mem_sup_map_support_iff\n#align finset.mem_sup_support_iff Finset.mem_sup_support_iff\n\n/- warning: list.support_sum_eq -> List.support_sum_eq is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))), (List.Pairwise.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Function.onFun.{succ (max u1 u2), succ u1, 1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} ι) Prop (Disjoint.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι) (Finset.orderBot.{u1} ι)) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))) l) -> (Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (List.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finsupp.add.{u1, u2} ι M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) l)) (List.foldr.{max u1 u2, u1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} ι) (Function.comp.{max (succ u1) (succ u2), succ u1, succ u1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} ι) ((Finset.{u1} ι) -> (Finset.{u1} ι)) (Sup.sup.{u1} (Finset.{u1} ι) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))))) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} ι) (Finset.hasEmptyc.{u1} ι)) l))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2))), (List.Pairwise.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Function.onFun.{succ (max u2 u1), succ u1, 1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} ι) Prop (Disjoint.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι)) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2))) l) -> (Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2) (List.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Finsupp.add.{u1, u2} ι M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) l)) (List.foldr.{max u2 u1, u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} ι) (Function.comp.{succ (max u2 u1), succ u1, succ u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} ι) ((Finset.{u1} ι) -> (Finset.{u1} ι)) (fun (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.585 : Finset.{u1} ι) (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.587 : Finset.{u1} ι) => Sup.sup.{u1} (Finset.{u1} ι) (SemilatticeSup.toSup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b)))) x._@.Mathlib.Data.Finsupp.BigOperators._hyg.585 x._@.Mathlib.Data.Finsupp.BigOperators._hyg.587) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M _inst_2))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} ι) (Finset.instEmptyCollectionFinset.{u1} ι)) l))\nCase conversion may be inaccurate. Consider using '#align list.support_sum_eq List.support_sum_eqₓ'. -/\ntheorem List.support_sum_eq [AddMonoid M] (l : List (ι →₀ M))\n    (hl : l.Pairwise (Disjoint on Finsupp.support)) :\n    l.Sum.support = l.foldr ((· ⊔ ·) ∘ Finsupp.support) ∅ :=\n  by\n  induction' l with hd tl IH\n  · simp\n  · simp only [List.pairwise_cons] at hl\n    simp only [List.sum_cons, List.foldr_cons, Function.comp_apply]\n    rw [Finsupp.support_add_eq, IH hl.right, Finset.sup_eq_union]\n    suffices Disjoint hd.support (tl.foldr ((· ⊔ ·) ∘ Finsupp.support) ∅) by\n      exact Finset.disjoint_of_subset_right (List.support_sum_subset _) this\n    · rw [← List.foldr_map, ← Finset.bot_eq_empty, List.foldr_sup_eq_sup_toFinset]\n      rw [Finset.disjoint_sup_right]\n      intro f hf\n      simp only [List.mem_toFinset, List.mem_map] at hf\n      obtain ⟨f, hf, rfl⟩ := hf\n      exact hl.left _ hf\n#align list.support_sum_eq List.support_sum_eq\n\n/- warning: multiset.support_sum_eq -> Multiset.support_sum_eq is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), (Multiset.Pairwise.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Function.onFun.{succ (max u1 u2), succ u1, 1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.{u1} ι) Prop (Disjoint.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι) (Finset.orderBot.{u1} ι)) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) s) -> (Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.orderBot.{u1} ι) (Multiset.map.{max u1 u2, u1} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) s)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), (Multiset.Pairwise.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Function.onFun.{succ (max u2 u1), succ u1, 1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.{u1} ι) Prop (Disjoint.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι)) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) s) -> (Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} ι) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι) (Multiset.map.{max u2 u1, u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) s)))\nCase conversion may be inaccurate. Consider using '#align multiset.support_sum_eq Multiset.support_sum_eqₓ'. -/\ntheorem Multiset.support_sum_eq [AddCommMonoid M] (s : Multiset (ι →₀ M))\n    (hs : s.Pairwise (Disjoint on Finsupp.support)) : s.Sum.support = (s.map Finsupp.support).sup :=\n  by\n  induction s using Quot.inductionOn\n  obtain ⟨l, hl, hd⟩ := hs\n  convert List.support_sum_eq _ _\n  · simp\n  · simp\n  · simp only [Multiset.quot_mk_to_coe'', Multiset.coe_map, Multiset.coe_eq_coe] at hl\n    exact hl.symm.pairwise hd fun _ _ h => Disjoint.symm h\n#align multiset.support_sum_eq Multiset.support_sum_eq\n\n/- warning: finset.support_sum_eq -> Finset.support_sum_eq is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), (Set.PairwiseDisjoint.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.partialOrder.{u1} ι) (Finset.orderBot.{u1} ι) ((fun (a : Type.{max u1 u2}) (b : Type.{max u1 u2}) [self : HasLiftT.{succ (max u1 u2), succ (max u1 u2)} a b] => self.0) (Finset.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Set.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (HasLiftT.mk.{succ (max u1 u2), succ (max u1 u2)} (Finset.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Set.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (CoeTCₓ.coe.{succ (max u1 u2), succ (max u1 u2)} (Finset.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Set.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Finset.Set.hasCoeT.{max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))) s) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) -> (Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.sum.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.lattice.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.orderBot.{u1} ι) s (Finsupp.support.{u1, u2} ι M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u2 u1} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), (Set.PairwiseDisjoint.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.partialOrder.{u1} ι) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι) (Finset.toSet.{max u1 u2} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) s) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) -> (Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Finset.sum.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} ι M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} ι) (Finsupp.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} ι) (Finset.instLatticeFinset.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} ι) s (Finsupp.support.{u1, u2} ι M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align finset.support_sum_eq Finset.support_sum_eqₓ'. -/\ntheorem Finset.support_sum_eq [AddCommMonoid M] (s : Finset (ι →₀ M))\n    (hs : (s : Set (ι →₀ M)).PairwiseDisjoint Finsupp.support) :\n    (s.Sum id).support = Finset.sup s Finsupp.support := by\n  classical\n    convert Multiset.support_sum_eq s.1 _\n    · exact (Finset.sum_val _).symm\n    · obtain ⟨l, hl, hn⟩ : ∃ l : List (ι →₀ M), l.toFinset = s ∧ l.Nodup :=\n        by\n        refine' ⟨s.to_list, _, Finset.nodup_toList _⟩\n        simp\n      subst hl\n      rwa [List.toFinset_val, list.dedup_eq_self.mpr hn, Multiset.pairwise_coe_iff_pairwise, ←\n        List.pairwiseDisjoint_iff_coe_toFinset_pairwise_disjoint hn]\n      intro x y hxy\n      exact symmetric_disjoint hxy\n#align finset.support_sum_eq Finset.support_sum_eq\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finsupp/BigOperators.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676284, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.4917175542146993}}
{"text": "/-\nA labeled transition system built on top of temporal logic\n-/\n\nimport .fixpoint\n\nuniverses u v u' v'\n\nopen temporal\n\nsection LTS\nparameters {S : Type u} {L : S → Type v}\n\n-- TODO: Why can't this be a doc?\n-- Ben S.: I think they're not allowed inside sections.\n/-\nA labeled trace takes a relation from start state through a label to an end state\nand a trace made up of states paired with labels. In each pair the label represents\nthe step that will be taken from its paired state\n-/\ndef LTS_trace  (r : ∀ s : S, L s → S → Prop)\n  (t : trace (sigma L)) : Prop :=\n  ∀ n : ℕ, r (t n).fst (t n).snd (t n.succ).fst\n\n/--\nApply a function (usually a predicate) to the state of a state-label pair\n-/\ndef inState {B} (f : S → B) (x : sigma L) : B := f x.fst\n\n\nlemma inState_mono : subset.monotone (@inState Prop)\n:= begin\nintros P Q PQ x Hx, apply PQ, apply Hx\nend\n\ninstance inState_decidable {P : S → Prop} [decP : decidable_pred P] :\n  decidable_pred (@inState Prop P) :=\nbegin\nintros x, apply decP,\nend\n\nparameter (LTS : ∀ s : S, L s → S → Prop)\n\n/--\nA trace is valid if it is a labeled transition system\n-/\nstructure valid_trace (t : trace (sigma L)) : Prop :=\n  (next_step : LTS_trace LTS t)\n\nlemma prove_next {P : sigma L → Prop}\n  {Q : S → Prop}\n  (H : ∀ s l s', LTS s l s' → P ⟨ s, l ⟩ → Q s')\n  : ⊩ valid_trace\n    => now P => ◯ (now (inState Q))\n:= begin\nintros tr validtr,\nunfold next nextn now later,\nintros HP,\napply H,\napply validtr.next_step,\ncases (tr 0), dsimp, assumption\nend\n\nlemma valid_trace_delay : ⊩ valid_trace => ◯ valid_trace\n:= begin\nintros tr validtr, constructor,\nsimp [delayn], dsimp [LTS_trace],\nintros n, apply validtr.next_step\nend\n\nlemma valid_trace_always : ⊩ valid_trace => □ valid_trace\n:= begin\nintros tr validtr, apply temporal_induction, assumption,\nintros n, apply valid_trace_delay,\nend\n\nlemma global_always (P : tProp (sigma L))\n  (H : ⊩ valid_trace => P)\n  : ⊩ valid_trace => □ P\n:= begin\nintros tr validtr n,\napply H, apply valid_trace_always, assumption\nend\n\nlemma prove_always {P : sigma L → Prop}\n  {Q : S → Prop}\n  (H : ∀ s l s', LTS s l s' → P ⟨ s, l ⟩ → Q s')\n  : ⊩ valid_trace\n    => □ (now P => ◯ (now (inState Q)))\n:= begin\napply (global_always _ _),\napply prove_next, assumption\nend\n\n\nlemma invariant_always (P : S → Prop)\n  (H : ∀ s l s', P s → LTS s l s' → P s')\n  : ⊩ valid_trace => now (inState P) => □ (now (inState P))\n:= begin\nintros tr validtr H0 n, induction n,\n{ apply H0 },\n{ apply H, apply ih_1, apply validtr.next_step }\nend\n\nlemma sigma_eta (x : sigma L) : sigma.mk x.fst x.snd  = x\n:= begin induction x, reflexivity end\n\nlemma invariant_holds_while {P : S → Prop} {Q : sigma L → Prop}\n  [decidable_pred Q]\n  (H : ∀ s l s', LTS s l s' → ¬ Q ⟨s, l⟩ → P s → P s')\n  : ⊩ valid_trace => now (inState P)\n    => ◯ (now (inState P)) 𝓦 now Q\n:= begin\nintros tr validtr HP,\napply weak_until_induction,\nassumption,\nintros n HQn HPn,\nunfold next nextn, rw delayn_combine,\nrw add_comm,\nsimp [inState] with ltl at HQn HPn,\nsimp [inState] with ltl,\napply (H _ _), apply validtr.next_step,\nrw sigma_eta, assumption, assumption,\nend\n\nlemma LTS_now_next (P' : S → Prop) (P Q : sigma L → Prop)\n  (H : ∀ s l s', LTS s l s' → P ⟨ _, l⟩ → P' s' ∨ Q ⟨ _, l ⟩)\n  : ⊩ valid_trace\n    => now P\n    => ( ◯ (now (inState P')) ∪ now Q)\n:= begin\nintros tr valid HP,\nspecialize (H _ _ _ (valid.next_step 0)),\nrw sigma_eta at H,\nspecialize (H HP),\ninduction H, left, assumption,\nright, assumption\nend\n\nend LTS\n\nsection LTS_refinement\n\ndef WithSkip {S : Type u} (L : S → Type v) (s : S) : Type v := option (L s)\n\nparameters {S : Type u} {L : S → Type v}\nparameter (LTS : ∀ s : S, L s → S → Prop)\n\ndef SkipLTS (s : S) (l : WithSkip L s) (s' : S) : Prop :=\n  match l with\n  | none := s = s'\n  | some l' := LTS s l' s'\n  end\n\ndef inSkipLabel (P : sigma L → Prop) : sigma (WithSkip L) → Prop\n| (sigma.mk s l) := match l with\n  | none := false\n  | some l' := P (sigma.mk s l')\n  end\n\ninstance inSkipLabel_decidable (P) [decP : decidable_pred P]\n  : decidable_pred (inSkipLabel P)\n:= begin\nintros x, induction x with s l,\ninduction l; dsimp [inSkipLabel],\napply decidable.is_false, trivial,\napply decP,\nend\n\ndef fairness_SkipLTS : tProp (sigma (WithSkip L)) :=\n  fair (now (inSkipLabel (λ _, true)))\n\nlemma SkipLTS_next_state\n  (P Q : S → Prop)\n  (W : sigma L → Prop)\n  (HLTS : ∀ s l s', LTS s l s' → P s → W ⟨ _, l ⟩ → Q s')\n   : ⊩ valid_trace SkipLTS\n   => now (inState P)\n   => now (inSkipLabel W)\n   => ◯ (now (inState Q))\n:= begin\nsimp with ltl,\nintros tr valid nowP goes,\nhave H := valid.next_step 0,\ndestruct ((tr 0)), intros s l Hsl,\nrw Hsl at goes,\ninduction l; dsimp [inSkipLabel] at goes,\n{ contradiction },\n{ apply HLTS, rw Hsl at H, dsimp [SkipLTS] at H,\n  apply H, rw Hsl at nowP, assumption, assumption\n}\nend\n\nlemma SkipLTS_now_next (P' : S → Prop) (P Q : sigma (WithSkip L) → Prop)\n  (H : ∀ s l s', LTS s l s' → P ⟨ _, some l⟩ → P' s' ∨ Q ⟨ _, some l ⟩)\n  : ⊩ valid_trace SkipLTS\n    => now P => now (inSkipLabel (λ _, true))\n    => ( ◯ (now (inState P')) ∪ now Q)\n:= begin\nintros tr valid HP Hgoes,\nhave valid0 := valid.next_step 0,\nunfold now later at Hgoes,\nunfold now later at HP,\ndestruct ((tr 0)); intros,\nrw a at Hgoes,\ncases snd; dsimp [inSkipLabel] at Hgoes,\ncontradiction,\nrw a at valid0, rw a at HP,\ndsimp [SkipLTS] at valid0,\nspecialize (H _ _ _ valid0 HP),\ninduction H with H H,\nleft, assumption, right, unfold now later,\nrw a, assumption,\nend\n\nlemma SkipLTS_state_stays_constant\n  (P : S → Prop) :\n  ⊩  valid_trace SkipLTS\n  => □ (now (inState P)\n  => ((◯ (now (inState P)))\n       𝓦\n       now (inSkipLabel (λ _, true)))\n  )\n:= begin\nintros tr validtr n Pst,\napply (invariant_holds_while SkipLTS _ (delayn n tr)),\napply valid_trace_always, assumption, assumption,\napply_instance,\nintros,\ninduction l,\n{ dsimp [SkipLTS] at a, subst s', assumption },\n{ exfalso, apply a_1, constructor, }\nend\n\nparameters {S' : Type u'}{L' : S' → Type v'}\nparameter (LTS' : ∀ s : S', L' s → S' → Prop)\n\nstructure Refinement :=\n  (S_refine : S → S')\n  (L_refine : ∀ {s}, L s → L' (S_refine s))\n  (refines : ∀ s l s', LTS s l s' → LTS' (S_refine s) (L_refine l) (S_refine s'))\nend LTS_refinement\n\nnamespace Refinement\nsection\nparameters {S : Type u} {S' : Type u'} {L : S → Type v} {L' : S' → Type v'}\n  {LTS : ∀ s : S, L s → S → Prop}\n  {LTS' : ∀ s : S', L' s → S' → Prop}\n\ndef SL_refine' (r : Refinement LTS LTS')\n  : sigma L → sigma L'\n| (sigma.mk s l) := sigma.mk (r.S_refine s) (r.L_refine l)\ndef SL_refine (r : Refinement LTS LTS')\n  (x : sigma L) : sigma L'\n   := sigma.mk (r.S_refine x.fst) (r.L_refine x.snd)\n\ndef SL_refine_valid_trace (r : Refinement LTS LTS')\n  (tr : trace (sigma L))\n  (valid : valid_trace LTS tr)\n  : valid_trace LTS' (tr.map r.SL_refine)\n:= begin\nconstructor, unfold LTS_trace,\ndsimp [trace.map],\nintros n, dsimp [SL_refine], apply refines, apply valid.next_step,\nend\n\ndef SL_refine_transform\n  (r : Refinement LTS LTS')\n  (P : tProp (sigma L'))\n  (H : ⊩ valid_trace LTS' => P)\n  : ⊩ valid_trace LTS => (P ∘ trace.map r.SL_refine)\n:= begin\nintros tr validtr, dsimp [function.comp],\napply H, apply SL_refine_valid_trace, assumption\nend\n\nend\nend Refinement", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/temporal/LTS.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6513548714339144, "lm_q1q2_score": 0.49171755421469915}}
{"text": "import tactic.localized\nimport algebra.group_power\n\nopen tactic\nlocal infix ` ⊹ `:59 := nat.mul\nlocal infix ` ↓ `:59 := pow\nlocal infix ` ⊖ `:59 := pow\nexample : 2 ⊹ 3 = 6 := rfl\nexample : 2 ↓ 3 = 8 := rfl\nexample : 2 ⊖ 3 = 8 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { success_if_fail { simp [h] }, exact le_of_lt h }\nsection\nlocalized \"infix ` ⊹ `:59 := nat.add\" in nat\nlocalized \"infix ` ↓ `:59 := nat.mul\" in nat\nlocalized \"infix ` ⊖ `:59 := nat.mul\" in nat.mul\nlocalized \"attribute [simp] le_of_lt\" in le\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 6 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { simp [h] }\nend\n\nsection\nexample : 2 ⊹ 3 = 6 := rfl\nexample : 2 ↓ 3 = 8 := rfl\nexample : 2 ⊖ 3 = 8 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { success_if_fail { simp [h] }, exact le_of_lt h }\n\n-- test that `open_locale` will fail when given a nonexistent locale\nrun_cmd success_if_fail $ get_localized [`ceci_nest_pas_une_locale]\n\nopen_locale nat\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 8 := rfl\n\nopen_locale nat.mul\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 6 := rfl\nend\n\nsection\nopen_locale nat.mul nat nat.mul le\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 6 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { simp [h] }\nend\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/localized/localized.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.49171754910554016}}
{"text": "import algebra.camera.option\n\nuniverse u\n\ninductive sum_camera (α β : Type u)\n| cinl : α → sum_camera\n| cinr : β → sum_camera\n| invalid : sum_camera\n\nnamespace sum_camera\n\ninfixr ` ⊕ₖ `:30 := sum_camera\n\nlemma cinl_injective {α β : Type u} : function.injective (cinl : α → sum_camera α β) :=\nby intros x y h; cases h; refl\n\nlemma cinr_injective {α β : Type u} : function.injective (cinr : β → sum_camera α β) :=\nby intros x y h; cases h; refl\n\ninductive eq_at_prop {α β : Type u} [ofe α] [ofe β] (n : ℕ) : α ⊕ₖ β → α ⊕ₖ β → Prop\n| cinl : Π {a b : α}, a =[n] b → eq_at_prop (cinl a) (cinl b)\n| cinr : Π {a b : β}, a =[n] b → eq_at_prop (cinr a) (cinr b)\n| invalid : eq_at_prop invalid invalid\n\ninstance ofe {α β : Type u} [ofe α] [ofe β] : ofe (α ⊕ₖ β) := {\n  eq_at := eq_at_prop,\n  eq_at_reflexive := begin\n    intros n a,\n    cases a,\n    { refine eq_at_prop.cinl _, refl, },\n    { refine eq_at_prop.cinr _, refl, },\n    { exact eq_at_prop.invalid, },\n  end,\n  eq_at_symmetric := begin\n    intros n a b h,\n    cases h,\n    { refine eq_at_prop.cinl _, symmetry, assumption, },\n    { refine eq_at_prop.cinr _, symmetry, assumption, },\n    { exact eq_at_prop.invalid, },\n  end,\n  eq_at_transitive := begin\n    intros n a b c hab hbc,\n    cases hab with a₁ b₁ hab₁ a₂ b₂ hab₂,\n    { cases c; cases hbc with hbc,\n      refine eq_at_prop.cinl _, transitivity b₁; assumption, },\n    { cases c; cases hbc with hbc,\n      refine eq_at_prop.cinr _, transitivity b₂; assumption, },\n    { cases c; cases hbc with hbc,\n      exact eq_at_prop.invalid, },\n  end,\n  eq_at_mono' := begin\n    intros m n hmn a b h,\n    cases h,\n    { refine eq_at_prop.cinl _, refine eq_at_mono hmn _, assumption, },\n    { refine eq_at_prop.cinr _, refine eq_at_mono hmn _, assumption, },\n    { exact eq_at_prop.invalid, },\n  end,\n  eq_at_limit' := begin\n    intros a b h,\n    cases h 0,\n    { refine congr_arg _ _, rw eq_at_limit,\n      intro n, cases h n, assumption, },\n    { refine congr_arg _ _, rw eq_at_limit,\n      intro n, cases h n, assumption, },\n    { refl, },\n  end,\n}\n\nlemma cinl_is_nonexpansive {α β : Type u} [ofe α] [ofe β] :\n  is_nonexpansive (cinl : α → α ⊕ₖ β) :=\nλ m a b, eq_at_prop.cinl\n\nlemma cinr_is_nonexpansive {α β : Type u} [ofe α] [ofe β] :\n  is_nonexpansive (cinr : β → α ⊕ₖ β) :=\nλ m a b, eq_at_prop.cinr\n\n@[simp] lemma cinl_eq_at_cinl {α β : Type u} [ofe α] [ofe β] {n : ℕ} {a b : α} :\n  (cinl a : α ⊕ₖ β) =[n] cinl b ↔ a =[n] b :=\nbegin\n  split,\n  { rintro (h | h | h),\n    assumption, },\n  { exact eq_at_prop.cinl, },\nend\n\n@[simp] lemma cinr_eq_at_cinr {α β : Type u} [ofe α] [ofe β] {n : ℕ} {a b : β} :\n  (cinr a : α ⊕ₖ β) =[n] cinr b ↔ a =[n] b :=\nbegin\n  split,\n  { rintro (h | h | h),\n    assumption, },\n  { exact eq_at_prop.cinr, },\nend\n\nlemma cinl_eq_at {α β : Type u} [ofe α] [ofe β] {n : ℕ} {a : α} {b : α ⊕ₖ β} :\n  cinl a =[n] b → ∃ b', b = cinl b' :=\nbegin\n  rintro (h | h | h),\n  exact ⟨_, rfl⟩,\nend\n\nlemma cinr_eq_at {α β : Type u} [ofe α] [ofe β] {n : ℕ} {a : β} {b : α ⊕ₖ β} :\n  cinr a =[n] b → ∃ b', b = cinr b' :=\nbegin\n  rintro (h | h | h),\n  exact ⟨_, rfl⟩,\nend\n\nlemma invalid_eq_at {α β : Type u} [ofe α] [ofe β] {n : ℕ} {b : α ⊕ₖ β} :\n  invalid =[n] b → b = invalid :=\nbegin\n  rintro (h | h | h),\n  refl,\nend\n\ndef mul {α β : Type u} [comm_semigroup α] [comm_semigroup β] : α ⊕ₖ β → α ⊕ₖ β → α ⊕ₖ β\n| (cinl a) (cinl b) := cinl (a * b)\n| (cinr a) (cinr b) := cinr (a * b)\n| _ _ := invalid\n\ninstance comm_semigroup {α β : Type u} [comm_semigroup α] [comm_semigroup β] :\n  comm_semigroup (α ⊕ₖ β) := {\n  mul := mul,\n  mul_assoc := begin\n    intros a b c,\n    cases a; cases b; cases c;\n    try { refl, },\n    refine congr_arg cinl _, rw mul_assoc,\n    refine congr_arg cinr _, rw mul_assoc,\n  end,\n  mul_comm := begin\n    intros a b,\n    cases a; cases b;\n    try { refl, },\n    refine congr_arg cinl _, rw mul_comm,\n    refine congr_arg cinr _, rw mul_comm,\n  end,\n}\n\nlemma cinl_mul_cinl {α β : Type u} [comm_semigroup α] [comm_semigroup β] {a b : α} :\n  (cinl a : α ⊕ₖ β) * cinl b = cinl (a * b) := rfl\n\nlemma cinr_mul_cinr {α β : Type u} [comm_semigroup α] [comm_semigroup β] {a b : β} :\n  (cinr a : α ⊕ₖ β) * cinr b = cinr (a * b) := rfl\n\nlemma cinl_eq_mul {α β : Type u} [comm_semigroup α] [comm_semigroup β] {a : α} {b c : α ⊕ₖ β} :\n  cinl a = b * c → ∃ b' c', b = cinl b' ∧ c = cinl c' :=\nbegin\n  cases b; cases c,\n  repeat { intro h, cases h, },\n  exact ⟨b, c, rfl, rfl⟩,\nend\n\nlemma cinr_eq_mul {α β : Type u} [comm_semigroup α] [comm_semigroup β] {a : β} {b c : α ⊕ₖ β} :\n  cinr a = b * c → ∃ b' c', b = cinr b' ∧ c = cinr c' :=\nbegin\n  cases b; cases c,\n  repeat { intro h, cases h, },\n  exact ⟨b, c, rfl, rfl⟩,\nend\n\ndef validn {α β : Type u} [camera α] [camera β] : α ⊕ₖ β → sprop\n| (cinl a) := camera.validn a\n| (cinr a) := camera.validn a\n| invalid := ⊥\n\ndef core {α β : Type u} [camera α] [camera β] : α ⊕ₖ β → option (α ⊕ₖ β)\n| (cinl a) := (camera.core a).map cinl\n| (cinr a) := (camera.core a).map cinr\n| invalid := some invalid\n\ndef extend {α β : Type u} [camera α] [camera β] {n : ℕ} : Π {a b₁ b₂ : α ⊕ₖ β},\n  validn a n → a =[n] b₁ * b₂ → (α ⊕ₖ β) × (α ⊕ₖ β)\n| (cinl a) (cinl b₁) (cinl b₂) va hab :=\n  (cinl (camera.extend va (by cases hab; assumption)).1,\n   cinl (camera.extend va (by cases hab; assumption)).2)\n| (cinr a) (cinr b₁) (cinr b₂) va hab :=\n  (cinr (camera.extend va (by cases hab; assumption)).1,\n   cinr (camera.extend va (by cases hab; assumption)).2)\n| (cinl a) (cinl b₁) (cinr b₂) va hab := by exfalso; cases hab\n| (cinl a) (cinl b₁) invalid va hab := by exfalso; cases hab\n| (cinl a) (cinr b₁) b₂ va hab := by exfalso; cases b₂; cases hab\n| (cinl a) invalid b₂ va hab := by exfalso; cases hab\n| (cinr a) (cinr b₁) (cinl b₂) va hab := by exfalso; cases hab\n| (cinr a) (cinr b₁) invalid va hab := by exfalso; cases hab\n| (cinr a) (cinl b₁) b₂ va hab := by exfalso; cases b₂; cases hab\n| (cinr a) invalid b₂ va hab := by exfalso; cases hab\n| invalid _ b₂ va hab := by exfalso; cases va\n\nprivate lemma mul_is_nonexpansive {α β : Type u} [camera α] [camera β] :\n  is_nonexpansive (function.uncurry ((*) : α ⊕ₖ β → α ⊕ₖ β → α ⊕ₖ β)) :=\nbegin\n  rintros n ⟨a, b⟩ ⟨c, d⟩ ⟨h₁, h₂⟩,\n  cases h₁,\n  case invalid { refl, },\n  { cases h₂,\n    case cinr { refl, },\n    case invalid { refl, },\n    refine cinl_is_nonexpansive _,\n    refine camera.mul_eq_at _ _; assumption, },\n  { cases h₂,\n    case cinl { refl, },\n    case invalid { refl, },\n    refine cinr_is_nonexpansive _,\n    refine camera.mul_eq_at _ _; assumption, },\nend\n\nprivate lemma cinl_core_eq_some {α β : Type u} [camera α] [camera β] {a : α} {ca : α ⊕ₖ β} :\n  (cinl a : α ⊕ₖ β).core = some ca → ∃ ca', ca = cinl ca' ∧ camera.core a = some ca' :=\nbegin\n  intro h,\n  cases ca,\n  { refine ⟨ca, rfl, _⟩,\n    simpa only [core, option.map_eq_some', exists_eq_right] using h, },\n  { simpa only [core, option.map_eq_some', and_false, exists_false] using h, },\n  { simpa only [core, option.map_eq_some', and_false, exists_false] using h, },\nend\n\nprivate lemma cinr_core_eq_some {α β : Type u} [camera α] [camera β] {a : β} {ca : α ⊕ₖ β} :\n  (cinr a : α ⊕ₖ β).core = some ca → ∃ ca', ca = cinr ca' ∧ camera.core a = some ca' :=\nbegin\n  intro h,\n  cases ca,\n  { simpa only [core, option.map_eq_some', and_false, exists_false] using h, },\n  { refine ⟨ca, rfl, _⟩,\n    simpa only [core, option.map_eq_some', exists_eq_right] using h, },\n  { simpa only [core, option.map_eq_some', and_false, exists_false] using h, },\nend\n\nprivate lemma core_mul_self {α β : Type u} [camera α] [camera β]\n  (a : α ⊕ₖ β) {ca : α ⊕ₖ β} : core a = some ca → ca * a = a :=\nbegin\n  intro h,\n  cases a,\n  { obtain ⟨ca, rfl, hca⟩ := cinl_core_eq_some h,\n    exact congr_arg cinl (camera.core_mul_self _ hca), },\n  { obtain ⟨ca, rfl, hca⟩ := cinr_core_eq_some h,\n    exact congr_arg cinr (camera.core_mul_self _ hca), },\n  { rw mul_comm, refl, },\nend\n\nprivate lemma core_core {α β : Type u} [camera α] [camera β]\n  (a : α ⊕ₖ β) {ca : α ⊕ₖ β} : core a = some ca → core ca = some ca :=\nbegin\n  intro h,\n  cases a,\n  { obtain ⟨ca, rfl, hca⟩ := cinl_core_eq_some h,\n    simp only [core, option.map_eq_some', exists_eq_right],\n    exact camera.core_core _ hca, },\n  { obtain ⟨ca, rfl, hca⟩ := cinr_core_eq_some h,\n    simp only [core, option.map_eq_some', exists_eq_right],\n    exact camera.core_core _ hca, },\n  { cases h, exact h, },\nend\n\nprivate lemma core_mono_some {α β : Type u} [camera α] [camera β]\n  (a b : α ⊕ₖ β) {ca : α ⊕ₖ β} : core a = some ca → a ≼ b →\n    ∃ cb : α ⊕ₖ β, core b = some cb :=\nbegin\n  rintros h ⟨c, hc⟩,\n  cases a,\n  { obtain ⟨ca, rfl, hca⟩ := cinl_core_eq_some h,\n    cases c; cases hc,\n    { obtain ⟨d, hd⟩ := camera.core_mono_some a (a * c) hca ⟨c, rfl⟩,\n      refine ⟨cinl d, _⟩,\n      simp only [core, option.map_eq_some', exists_eq_right],\n      exact hd, },\n    { exact ⟨invalid, rfl⟩, },\n    { exact ⟨invalid, rfl⟩, }, },\n  { obtain ⟨ca, rfl, hca⟩ := cinr_core_eq_some h,\n    cases c; cases hc,\n    { exact ⟨invalid, rfl⟩, },\n    { obtain ⟨d, hd⟩ := camera.core_mono_some a (a * c) hca ⟨c, rfl⟩,\n      refine ⟨cinr d, _⟩,\n      simp only [core, option.map_eq_some', exists_eq_right],\n      exact hd, },\n    { exact ⟨invalid, rfl⟩, }, },\n  { cases hc,\n    exact ⟨invalid, rfl⟩, },\nend\n\nprivate lemma core_mono {α β : Type u} [camera α] [camera β]\n  (a b : α ⊕ₖ β) {ca : α ⊕ₖ β} : core a = some ca → a ≼ b → core a ≼ core b :=\nbegin\n  rintros h ⟨c, hc⟩,\n  cases a,\n  { obtain ⟨ca, rfl, hca⟩ := cinl_core_eq_some h,\n    cases c; cases hc,\n    { obtain ⟨d, hd⟩ := camera.core_mono a (a * c) hca ⟨c, rfl⟩,\n      refine ⟨d.map cinl, _⟩,\n      simp only [core, option.map_eq_some', exists_eq_right, ← hd],\n      cases camera.core a; cases d;\n      simp only [option.map_none', option.map_some', none_mul, mul_none, some_mul_some],\n      refl, },\n    { refine ⟨some invalid, _⟩,\n      cases (cinl a).core, refl, cases val; refl, },\n    { refine ⟨some invalid, _⟩,\n      cases (cinl a).core, refl, cases val; refl, }, },\n  { obtain ⟨ca, rfl, hca⟩ := cinr_core_eq_some h,\n    cases c; cases hc,\n    { refine ⟨some invalid, _⟩,\n      cases (cinr a).core, refl, cases val; refl, },\n    { obtain ⟨d, hd⟩ := camera.core_mono a (a * c) hca ⟨c, rfl⟩,\n      refine ⟨d.map cinr, _⟩,\n      simp only [core, option.map_eq_some', exists_eq_right, ← hd],\n      cases camera.core a; cases d;\n      simp only [option.map_none', option.map_some', none_mul, mul_none, some_mul_some],\n      refl, },\n    { refine ⟨some invalid, _⟩,\n      cases (cinr a).core, refl, cases val; refl, }, },\n  { cases hc, exact ⟨some invalid, rfl⟩, },\nend\n\nprivate lemma validn_mul {α β : Type u} [camera α] [camera β] (a b : α ⊕ₖ β) :\n  validn (a * b) ≤ validn a :=\nbegin\n  intros n h,\n  cases a,\n  { cases b,\n    exact camera.validn_mul a b n h,\n    cases h,\n    cases h, },\n  { cases b,\n    cases h,\n    exact camera.validn_mul a b n h,\n    cases h, },\n  { cases h, },\nend\n\nprivate lemma extend_mul_eq {α β : Type u} [camera α] [camera β] (n : ℕ)\n  (a b₁ b₂ : α ⊕ₖ β) (ha : validn a n) (hb : a =[n] b₁ * b₂) :\n  a = (extend ha hb).1 * (extend ha hb).2 :=\nbegin\n  cases a,\n  { obtain ⟨b, hb'⟩ := cinl_eq_at hb,\n    obtain ⟨b₁, b₂, rfl, rfl⟩ := cinl_eq_mul hb'.symm,\n    rw [cinl_mul_cinl, cinl_eq_at_cinl] at hb,\n    exact congr_arg cinl (camera.extend_mul_eq ha hb), },\n  { obtain ⟨b, hb'⟩ := cinr_eq_at hb,\n    obtain ⟨b₁, b₂, rfl, rfl⟩ := cinr_eq_mul hb'.symm,\n    rw [cinr_mul_cinr, cinr_eq_at_cinr] at hb,\n    exact congr_arg cinr (camera.extend_mul_eq ha hb), },\n  { cases ha, },\nend\n\nprivate lemma extend_eq_at_left {α β : Type u} [camera α] [camera β] (n : ℕ)\n  (a b₁ b₂ : α ⊕ₖ β) (ha : validn a n) (hb : a =[n] b₁ * b₂) :\n  (extend ha hb).1 =[n] b₁ :=\nbegin\n  cases a,\n  { obtain ⟨b, hb'⟩ := cinl_eq_at hb,\n    obtain ⟨b₁, b₂, rfl, rfl⟩ := cinl_eq_mul hb'.symm,\n    rw [cinl_mul_cinl, cinl_eq_at_cinl] at hb,\n    exact cinl_is_nonexpansive (camera.extend_eq_at_left ha hb), },\n  { obtain ⟨b, hb'⟩ := cinr_eq_at hb,\n    obtain ⟨b₁, b₂, rfl, rfl⟩ := cinr_eq_mul hb'.symm,\n    rw [cinr_mul_cinr, cinr_eq_at_cinr] at hb,\n    exact cinr_is_nonexpansive (camera.extend_eq_at_left ha hb), },\n  { cases ha, },\nend\n\nprivate lemma extend_eq_at_right {α β : Type u} [camera α] [camera β] (n : ℕ)\n  (a b₁ b₂ : α ⊕ₖ β) (ha : validn a n) (hb : a =[n] b₁ * b₂) :\n  (extend ha hb).2 =[n] b₂ :=\nbegin\n  cases a,\n  { obtain ⟨b, hb'⟩ := cinl_eq_at hb,\n    obtain ⟨b₁, b₂, rfl, rfl⟩ := cinl_eq_mul hb'.symm,\n    rw [cinl_mul_cinl, cinl_eq_at_cinl] at hb,\n    exact cinl_is_nonexpansive (camera.extend_eq_at_right ha hb), },\n  { obtain ⟨b, hb'⟩ := cinr_eq_at hb,\n    obtain ⟨b₁, b₂, rfl, rfl⟩ := cinr_eq_mul hb'.symm,\n    rw [cinr_mul_cinr, cinr_eq_at_cinr] at hb,\n    exact cinr_is_nonexpansive (camera.extend_eq_at_right ha hb), },\n  { cases ha, },\nend\n\ninstance camera {α β : Type u} [camera α] [camera β] : camera (α ⊕ₖ β) := {\n  validn := ⟨validn, begin\n    intros n a b h,\n    cases h,\n    refine nonexpansive camera.validn _, assumption,\n    refine nonexpansive camera.validn _, assumption,\n    intros m hmn, refl,\n  end⟩,\n  core := ⟨core, begin\n    intros n a b h,\n    cases h,\n    { refine option.map_nonexpansive _ cinl_is_nonexpansive _,\n      refine nonexpansive camera.core _, assumption, },\n    { refine option.map_nonexpansive _ cinr_is_nonexpansive _,\n      refine nonexpansive camera.core _, assumption, },\n    { refl, },\n  end⟩,\n  extend := @extend α β _ _,\n  mul_is_nonexpansive := mul_is_nonexpansive,\n  core_mul_self := core_mul_self,\n  core_core := core_core,\n  core_mono_some := core_mono_some,\n  core_mono := core_mono,\n  validn_mul := validn_mul,\n  extend_mul_eq := extend_mul_eq,\n  extend_eq_at_left := extend_eq_at_left,\n  extend_eq_at_right := extend_eq_at_right,\n  ..sum_camera.ofe,\n  ..sum_camera.comm_semigroup,\n}\n\nlemma mul_cinl_valid {α β : Type u} [camera α] [camera β] {a : α} {b : α ⊕ₖ β} {n : ℕ} :\n  ✓[n] b * cinl a → ∃ b', b = cinl b' :=\nbegin\n  intro h,\n  cases b,\n  exact ⟨b, rfl⟩,\n  cases h,\n  cases h,\nend\n\nlemma mul_cinr_valid {α β : Type u} [camera α] [camera β] {a : β} {b : α ⊕ₖ β} {n : ℕ} :\n  ✓[n] b * cinr a → ∃ b', b = cinr b' :=\nbegin\n  intro h,\n  cases b,\n  cases h,\n  exact ⟨b, rfl⟩,\n  cases h,\nend\n\nlemma can_update_cinl {α β : Type u} [camera α] [camera β] {a : α} {A : set α} :\n  a ↝ A → (cinl a : α ⊕ₖ β) ↝ cinl '' A :=\nbegin\n  rintros h n ⟨c, hc⟩,\n  obtain ⟨c, rfl⟩ := mul_cinl_valid hc,\n  obtain ⟨f, hf⟩ := h n ⟨c, hc⟩,\n  exact ⟨⟨cinl f.val, f.prop⟩, f.val, hf, rfl⟩,\nend\n\nlemma can_update_cinr {α β : Type u} [camera α] [camera β] {b : β} {B : set β} :\n  b ↝ B → (cinr b : α ⊕ₖ β) ↝ cinr '' B :=\nbegin\n  rintros h n ⟨c, hc⟩,\n  obtain ⟨c, rfl⟩ := mul_cinr_valid hc,\n  obtain ⟨f, hf⟩ := h n ⟨c, hc⟩,\n  exact ⟨⟨cinr f.val, f.prop⟩, f.val, hf, rfl⟩,\nend\n\n/-- If `cinl a` has no frame, we can update it to any valid `cinr b`.\nTODO: Why does the Iris appendix add the additional `✓ b` assumption? -/\nlemma can_update_swap {α β : Type u} [camera α] [camera β] (a : α) (b : β) :\n  (∀ n, is_empty (time_frame a n)) → ✓ b → (cinl a : α ⊕ₖ β) ↝ {cinr b} :=\nbegin\n  rintros ha hb n ⟨c, hc⟩,\n  obtain ⟨c, rfl⟩ := mul_cinl_valid hc,\n  cases (ha n).false ⟨c, hc⟩,\nend\n\nend sum_camera\n", "meta": {"author": "zeramorphic", "repo": "separation-logic", "sha": "51c131501cc541b3aae072957942e8ef744c4ebf", "save_path": "github-repos/lean/zeramorphic-separation-logic", "path": "github-repos/lean/zeramorphic-separation-logic/separation-logic-51c131501cc541b3aae072957942e8ef744c4ebf/src/algebra/camera/sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.49170068359996405}}
{"text": "import .homology_of_spheres\nimport algebra.quadratic_discriminant\n\nlemma connected_to_disconnected_surjection_nogo {α β : Type*}\n  [topological_space α] [topological_space β] (h1 : connected_space α) (h2 : ¬ connected_space β)\n  : ¬ ∃ (r : C(α, β)), function.surjective r :=\nbegin\n  rintros ⟨r, h⟩,\n  have : is_connected (set.range r) := is_connected_range r.continuous_to_fun,\n  rw h.range_eq at this,\n  refine h2 _,\n  exact @connected_space.mk _ _ ⟨this.right⟩ (set.nonempty_iff_univ_nonempty.mpr this.left)\nend\n\nlemma ball_to_sphere_retraction_nogo (n : ℕ)\n  : ¬ ∃ (r : C(metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1,\n               metric.sphere (0 : euclidean_space ℝ (fin n)) 1)),\n      ∀ x h, (r ⟨x, metric.sphere_subset_closed_ball h⟩ : euclidean_space ℝ (fin n)) = x :=\nbegin\n  rw not_exists,\n  intros r H,\n  let i : C(metric.sphere (0 : euclidean_space ℝ (fin n)) 1,\n            metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1)\n        := ⟨_, continuous_inclusion metric.sphere_subset_closed_ball⟩,\n  have : r.comp i = continuous_map.id _,\n  { ext : 2, cases a with a ha, exact H a ha },\n  by_cases n > 0,\n  { let i' : Top.of (metric.sphere (0 : euclidean_space ℝ (fin n)) 1)\n          ⟶ Top.of (metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1)\n        := i,\n    let r' : Top.of (metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1)\n          ⟶ Top.of (metric.sphere (0 : euclidean_space ℝ (fin n)) 1)\n        := r,\n    cases n, { exact lt_irrefl 0 h },\n    by_cases n > 0,\n    { change i' ≫ r' = 𝟙 (Top.of (metric.sphere (0 : euclidean_space ℝ (fin (n + 1))) 1)) at this,\n      replace this := congr_arg (@category_theory.functor.map _ _ _ _ (singular_homology ℤ n) _ _) this,\n      simp at this,\n      have H : category_theory.limits.is_zero ((singular_homology ℤ n).obj (Top.of (metric.closed_ball (0 : euclidean_space ℝ (fin (n + 1))) 1))),\n      { obtain ⟨P⟩ := homology_of_contractible_space ℤ (Top.of (metric.closed_ball (0 : euclidean_space ℝ (fin (n + 1))) 1)) _ n h,\n        exact category_theory.limits.is_zero_of_iso_of_zero (category_theory.limits.is_zero_zero _) P.symm,\n        exact convex.contractible_space (strict_convex_closed_ball ℝ _ _).convex \n                                        ⟨0, metric.mem_closed_ball_self zero_le_one⟩ },\n      refine absurd (category_theory.limits.is_zero_of_iso_of_zero H (category_theory.iso.mk _ _ _ this)) _,\n      { exact category_theory.limits.is_zero.eq_of_src H _ _ },\n      { obtain ⟨P⟩ := @nth_homology_of_n_sphere ℤ _ _ n h,\n        intro H', \n        have H'' := category_theory.limits.is_zero_of_iso_of_zero H' P,\n        rw category_theory.limits.is_zero_iff_id_eq_zero at H'', \n        have H''' : (𝟙 (Module.of ℤ ℤ) : ℤ → ℤ) 1 = 0, { rw H'', refl },\n        exact @one_ne_zero ℤ _ _ H''' } },\n    { simp at h, subst h,\n      refine connected_to_disconnected_surjection_nogo _ _ ⟨r, _⟩,\n      { rw ← is_connected_iff_connected_space,\n        refine convex.is_connected (strict_convex_closed_ball ℝ _ _).convex\n                                   ⟨0, metric.mem_closed_ball_self zero_le_one⟩ },\n      { let x0 : (metric.sphere (0 : euclidean_space ℝ (fin 1)) 1) := ⟨(λ _, (-1) : fin 1 → ℝ), _⟩,\n        swap, { simp [euclidean_space.norm_eq] },\n        let x1 : (metric.sphere (0 : euclidean_space ℝ (fin 1)) 1) := ⟨(λ _, 1 : fin 1 → ℝ), _⟩,\n        swap, { simp [euclidean_space.norm_eq] },\n        let F := two_point_t2_space_homeo_coprod_two_points x0 x1 _ _,\n        { intro h, haveI := h,\n          have h' : is_connected (set.range F.symm) := is_connected_range F.symm.continuous_to_fun,\n          rw [F.symm.range_coe, sum.is_connected_iff] at h',\n          cases h', \n          { obtain ⟨t, _, ht⟩ := h',\n            have := @set.mem_univ (punit.{1} ⊕ punit.{1}), rw ht at this,\n            specialize this (sum.inr ()), cases this with _ h'', simp at h'', exact h'' },\n          { obtain ⟨t, _, ht⟩ := h',\n            have := @set.mem_univ (punit.{1} ⊕ punit.{1}), rw ht at this,\n            specialize this (sum.inl ()), cases this with _ h'', simp at h'', exact h'' } },\n        { simp [x0, x1], refine ne.symm _, rw [ne.def, eq_neg_self_iff], exact one_ne_zero },\n        { rintro ⟨x, hx⟩, simp [euclidean_space.norm_eq] at hx, simp [x0, x1], \n          refine or.imp _ _ (or.symm hx); intro; ext i; fin_cases i; assumption } },\n      { refine @function.right_inverse.surjective _ _ r i _,\n        intro x, rw [← continuous_map.comp_apply, this], refl } } },\n  { simp at h, subst h, \n    suffices : is_empty ↥(metric.sphere (0 : euclidean_space ℝ (fin 0)) 1),\n    { obtain ⟨h⟩ := this, exact h (r ⟨0, metric.mem_closed_ball_self zero_le_one⟩) },\n    apply_with metric.sphere_is_empty_of_subsingleton {instances:=ff},\n    { dsimp [euclidean_space, pi_Lp], apply_instance },\n    { exact zero_ne_one.symm } }\nend.\n\nnotation `⟪`x`, `y`⟫` := @inner ℝ _ _ x y\n\nnoncomputable\ndef time_to_boundary (n : ℕ) (p q : euclidean_space ℝ (fin n)) : ℝ :=\n  (2 * ⟪q - p, q⟫ - real.sqrt (4 * ⟪q - p, q⟫^2 + 4 * ∥p - q∥^2 * (1 - ∥q∥^2))) / (2 * ∥p - q∥^2)\n\nnoncomputable\ndef time_to_boundary_aux (x : { tuple : ℝ × ℝ × ℝ // tuple.snd.fst > 0 ∧ tuple.snd.snd ≤ 1 }) : ℝ :=\n  (2 * x.val.fst - real.sqrt (4 * x.val.fst^2 + 4 * x.val.snd.fst^2 * (1 - x.val.snd.snd^2))) / (2 * x.val.snd.fst^2)\n\nnoncomputable\ndef time_to_boundary' (n : ℕ) (pair : { x : metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1\n                                           × metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1\n                                           // x.fst ≠ x.snd })\n  := time_to_boundary n pair.val.fst pair.val.snd\n\nnoncomputable\ndef time_to_boundary'_aux (n : ℕ) (pair : { x : metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1\n                                              × metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1\n                                              // x.fst ≠ x.snd })\n  : { tuple : ℝ × ℝ × ℝ // tuple.snd.fst > 0 ∧ tuple.snd.snd ≤ 1 } := {\n    val := ⟨⟪pair.val.snd.val - pair.val.fst.val, pair.val.snd⟫,\n            ∥pair.val.fst.val - pair.val.snd.val∥,\n            ∥pair.val.snd.val∥⟩,\n    property := by { split; simp, { rw [sub_eq_zero, ← subtype.ext_iff], exact pair.property },\n                     { have := pair.val.snd.property, simp at this, exact this } }\n  }.\n\nlemma time_to_boundary'_fact (n : ℕ)\n  : time_to_boundary' n  = time_to_boundary_aux ∘ time_to_boundary'_aux n :=\nbegin\n  ext x, rcases x with ⟨⟨⟨x1, h1⟩, ⟨x2, h2⟩⟩, h⟩, refl\nend.\n\nlemma time_to_boundary'_continuous (n : ℕ) : continuous (time_to_boundary' n) :=\nbegin\n  rw time_to_boundary'_fact,\n  refine continuous.comp _ _,\n  { refine continuous.div _ _ _, { continuity }, { continuity },\n    { rintro ⟨⟨a, b, c⟩, h1, h2⟩, rw mul_ne_zero_iff, simp, exact ne_of_gt h1 } },\n  { refine continuous_subtype_mk _ _, \n    refine continuous.prod_mk _ ((continuous_norm.comp _).prod_mk (continuous_norm.comp _)),\n    { refine continuous.inner _ _,\n      { exact continuous.sub (continuous_subtype_val.comp (continuous_snd.comp continuous_subtype_val))\n                             (continuous_subtype_val.comp (continuous_fst.comp continuous_subtype_val)) },\n      { exact continuous_subtype_coe.comp (continuous_snd.comp continuous_subtype_val) } },\n    { exact continuous.sub (continuous_subtype_val.comp (continuous_fst.comp continuous_subtype_val))\n                             (continuous_subtype_val.comp (continuous_snd.comp continuous_subtype_val)) },\n    { exact continuous_subtype_val.comp (continuous_snd.comp continuous_subtype_val) } }\nend.\n\nlemma real.quadratic_eq_zero_iff {a b c : ℝ} (ha : a ≠ 0) (h : discrim a b c ≥ 0) (x : ℝ) :\n  a * x * x + b * x + c = 0\n  ↔ x = (-b + real.sqrt (discrim a b c)) / (2 * a) ∨ x = (-b - real.sqrt (discrim a b c)) / (2 * a) :=\n  quadratic_eq_zero_iff ha (by { rw [← pow_two, real.sq_sqrt h] }) x\n\nlemma real.AM_GM2 (a b : ℝ) : 2 * a * b ≤ a^2 + b^2 :=\n  sub_nonneg.mp (eq.subst (sub_sq' a b) (sq_nonneg (a - b))) \n\nlemma time_to_boundary'_lands_in_sphere (n : ℕ) (pair)\n  : time_to_boundary' n pair • pair.val.fst.val + (1 - time_to_boundary' n pair) • pair.val.snd.val\n  ∈ metric.sphere (0 : euclidean_space ℝ (fin n)) 1 :=\nbegin\n  simp, generalize h : time_to_boundary' n pair = t,\n  rw [norm_eq_sqrt_real_inner, real_inner_add_add_self,\n      real_inner_smul_left, real_inner_smul_left, real_inner_smul_left,\n      real_inner_smul_right, real_inner_smul_right, real_inner_smul_right,\n      real.sqrt_eq_iff_sq_eq _ zero_le_one, one_pow],\n  { ring_nf SOP,\n    rw [mul_assoc, ← mul_neg, ← mul_add, ← mul_add, mul_assoc, mul_assoc, ← mul_sub],\n    symmetry,\n    rw [mul_comm t _, mul_comm, pow_two, ← mul_assoc, ← sub_eq_zero, add_sub_assoc],\n    rw real.quadratic_eq_zero_iff,\n    { right,\n      rw ← h, delta time_to_boundary' time_to_boundary discrim,\n      congr' 2,\n      { rw [neg_sub, mul_comm, inner_sub_left, sub_mul], refl },\n      { refine congr_arg _ _,\n        rw [← real_inner_self_eq_norm_sq, real_inner_sub_sub_self, inner_sub_left], \n        rw [← neg_sq, neg_sub, ← sub_mul, mul_pow, mul_comm],\n        congr, norm_cast,\n        rw [← mul_neg, neg_sub, ← real_inner_self_eq_norm_sq,\n            sub_eq_add_neg, add_assoc, mul_comm (2 : ℝ)], refl },\n      { rw [← real_inner_self_eq_norm_sq, real_inner_sub_sub_self,\n            sub_eq_add_neg, add_assoc, mul_comm (2 : ℝ)], refl } },\n    { refine ne_of_eq_of_ne _ (sq_eq_zero_iff.not.mpr (norm_ne_zero_iff.mpr (sub_ne_zero.mpr (subtype.ext_iff.not.mp pair.property)))),\n      rw [← real_inner_self_eq_norm_sq, real_inner_sub_sub_self], ring },\n    { delta discrim,\n      rw [ge_iff_le, sub_nonneg, sub_sq],\n      transitivity (0 : ℝ),\n      { rw [← neg_nonneg, ← mul_neg, neg_sub],\n        refine mul_nonneg (mul_nonneg zero_le_four _) _,\n        { rw [← sub_eq_neg_add, add_sub_left_comm, add_comm, mul_comm, ← real_inner_sub_sub_self,\n              real_inner_self_eq_norm_sq],\n         apply sq_nonneg },\n        { rw [sub_nonneg, real_inner_self_eq_norm_sq, sq_le_one_iff (norm_nonneg _),\n              ← mem_closed_ball_zero_iff],\n          exact subtype.mem _ } },\n      { rw [add_comm, ← add_sub_assoc, sub_nonneg, add_comm], apply real.AM_GM2 } } },\n  { ring_nf SOP,\n    rw [mul_assoc, ← mul_neg, ← mul_add, ← mul_add, mul_assoc, mul_assoc, ← mul_sub],\n    rw [← sub_eq_neg_add, add_sub_left_comm, add_comm _ (_ - _), mul_comm _ (2 : ℝ),\n        ← real_inner_sub_sub_self, real_inner_self_eq_norm_sq],\n    rw [mul_comm _ (2 : ℝ), ← mul_sub, ← inner_sub_left, add_right_comm,\n        ← sub_neg_eq_add, sub_nonneg],\n    refine le_trans (neg_le_abs_self _) _,\n    rw [← real_inner_smul_left, ← real_inner_smul_left, smul_smul, mul_comm, ← smul_smul],\n    refine le_trans (abs_real_inner_le_norm _ _) _,\n    rw [norm_smul, real.norm_eq_abs, abs_eq_self.mpr (zero_le_two : (0 : ℝ) ≤ (2 : ℝ))],\n    refine le_trans (real.AM_GM2 _ _) (le_of_eq _),\n    rw [norm_smul, real.norm_eq_abs, mul_pow, sq_abs, real_inner_self_eq_norm_sq] }\nend.\n\n-- rcases pair with ⟨⟨⟨p, hp⟩, ⟨q, hq⟩⟩, h⟩,\n-- rw [subtype.val_eq_coe],\n-- simp only [prod.fst, prod.snd, subtype.coe_mk],\n\nlemma time_to_boundary_eq_zero_if_in_boundary (n : ℕ) (p q : euclidean_space ℝ (fin n)) \n  (h1 : p ∈ metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1)\n  (h2 : q ∈ metric.sphere (0 : euclidean_space ℝ (fin n)) 1)\n  : time_to_boundary n p q = 0 :=\nbegin\n  simp at h1 h2,\n  simp only [div_eq_zero_iff, time_to_boundary],\n  left,\n  rw [h2, one_pow, sub_self, mul_zero, add_zero, real.sqrt_mul, sub_eq_zero], \n  symmetry, congr,\n  { rw real.sqrt_eq_iff_sq_eq; norm_cast; apply nat.zero_le },\n  { apply real.sqrt_sq,\n    rw [inner_sub_left, sub_nonneg, real_inner_self_eq_norm_mul_norm],\n    refine le_trans (real_inner_le_norm _ _) _,\n    rw h2, simp, exact h1 },\n  { norm_cast, exact nat.zero_le 4 }\nend\n\n/-\nProof sketch, due to Ivo Vekemans (see https://www.ivovekemans.net/mathematical-art):\n\nI slept.\nAnd slumbering dreamt.\nAnd dreaming, I ambled clockwise around a great circular lake in an infinite desert.\nAnd ambling, caught my sweater on a thorn, and began to unravel.\nAnd unravelling, I saw all the points of the lake.\nAnd observed, the lake began to stir.\nAnd stirring, the surface did not break, remaining contained.\nAnd contained, the visited a violent vortex, but STILL the surface did not break.\nAnd unbroken, the whirring pool... ...subsided, as the last sweater thread unwound.\nAnd unwound in the setting sun I spied again the thorn.\nAnd spying, noticed that no point on the lake was where it began.\nAnd beginning at each point emanated a single ray of light, through the point it was prior perturbation, each ray illuminating a spot on the shore.\nAnd sure that the points perturbed from the bank illuminated those points from whence they came, I tied the ends of my sweater together and HEAVED. And heaved and heaved.\nAnd, so heft, the thread, without breaking or crossing the lake, rewound unto me a complete sweater.\nAnd sweating from the exertion, I woke.\nAnd waking, recalled that one is not zero, snapping the thread.\n-/\n\nlemma brouwer_fixed_point_for_sphere (n : ℕ)\n  (f : C(metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1,\n         metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1))\n  : ∃ x : metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1, f x = x :=\nbegin\n  by_contra, rw not_exists at h,\n  apply ball_to_sphere_retraction_nogo n,\n  let mk_pair : metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1\n              → { x : metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1\n                    × metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1\n                    // x.fst ≠ x.snd } := λ p, ⟨⟨f p, p⟩, h p⟩,\n  have mk_pair_cont : continuous mk_pair :=\n    continuous_subtype_mk _ (continuous.prod_mk f.continuous_to_fun continuous_id),\n  let r :  C(metric.closed_ball (0 : euclidean_space ℝ (fin n)) 1,\n             metric.sphere (0 : euclidean_space ℝ (fin n)) 1) :=\n    continuous_map.comp ⟨(λ p, ⟨time_to_boundary' n p • p.val.fst.val\n                                + (1 - time_to_boundary' n p) • p.val.snd.val,\n                                time_to_boundary'_lands_in_sphere n p⟩), _⟩\n                        ⟨mk_pair, mk_pair_cont⟩,\n  swap,\n  { refine continuous_subtype_mk _ (continuous.add _ _);\n    refine continuous.smul _ _,\n    { exact time_to_boundary'_continuous n },\n    { exact continuous_subtype_val.comp (continuous_fst.comp continuous_subtype_val) },\n    { exact continuous.sub (continuous_const) (time_to_boundary'_continuous n) },\n    { exact continuous_subtype_val.comp (continuous_snd.comp continuous_subtype_val) } },\n  refine ⟨r, _⟩,\n  intros x h,\n  simp [r, mk_pair, time_to_boundary'],\n  rw time_to_boundary_eq_zero_if_in_boundary n _ _ (subtype.mem _) h,\n  simp\nend.\n\ntheorem brouwer_fixed_point {V : Type*}\n  [normed_add_comm_group V] [normed_space ℝ V] [finite_dimensional ℝ V]\n  : ∀ (s : set V), convex ℝ s → is_compact s → set.nonempty s → \n    ∀ (f : C(s, s)), ∃ x, f x = x :=\nbegin\n  intros s h1 h2 h3,\n  have : affine_dim ℝ s < cardinal.aleph_0, \n  { apply @lt_of_le_of_lt _ _ _ (module.rank ℝ V),\n    { dsimp [affine_dim],\n      rw [← finite_dimensional.finrank_eq_dim, ← finite_dimensional.finrank_eq_dim],\n      norm_cast,\n      apply submodule.finrank_le },\n    { rw ← finite_dimensional.finrank_eq_dim, exact cardinal.nat_lt_aleph_0 _ } },\n  rw cardinal.lt_aleph_0 at this, \n  obtain ⟨n, hn⟩ := this,\n  obtain ⟨F⟩ := convex_compact_homeo_to_ball s h1 h2 h3 n hn,\n  intro f, \n  let g := F.to_continuous_map.comp (f.comp F.symm.to_continuous_map),\n  obtain ⟨y, hy⟩ := brouwer_fixed_point_for_sphere n g,\n  refine ⟨F.symm y, _⟩,\n  rw [← homeomorph.coe_symm_to_equiv, equiv.eq_symm_apply],\n  exact hy\nend", "meta": {"author": "Shamrock-Frost", "repo": "BrouwerFixedPoint", "sha": "52f48d25068df0eadf3df5b2ede7bcb087d30527", "save_path": "github-repos/lean/Shamrock-Frost-BrouwerFixedPoint", "path": "github-repos/lean/Shamrock-Frost-BrouwerFixedPoint/BrouwerFixedPoint-52f48d25068df0eadf3df5b2ede7bcb087d30527/src/brouwer_fixed_point.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384735, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4917006718291542}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n-/\nprelude\nimport init.data.nat.basic\n\nopen nat\n@[reducible] def is_valid_char (n : nat) : Prop :=\nn < 0xd800 ∨ (0xdfff < n ∧ n < 0x110000)\n\nlemma is_valid_char_range_1 (n : nat) (h : n < 0xd800) : is_valid_char n :=\nor.inl h\n\nlemma is_valid_char_range_2 (n : nat) (h₁ : 0xdfff < n) (h₂ : n < 0x110000) : is_valid_char n :=\nor.inr ⟨h₁, h₂⟩\n\n/-- The `char` type represents an unicode scalar value.\n    See http://www.unicode.org/glossary/#unicode_scalar_value). -/\nstructure char :=\n(val : nat) (valid : is_valid_char val)\n\ninstance : has_sizeof char :=\n⟨λ c, c.val⟩\n\nnamespace char\nprotected def lt (a b : char) : Prop := a.val < b.val\nprotected def le (a b : char) : Prop := a.val ≤ b.val\n\ninstance : has_lt char := ⟨char.lt⟩\ninstance : has_le char := ⟨char.le⟩\n\ninstance decidable_lt (a b : char) :  decidable (a < b) :=\nnat.decidable_lt _ _\n\ninstance decidable_le (a b : char) : decidable (a ≤ b) :=\nnat.decidable_le _ _\n\n/-\nWe cannot use tactics dec_trivial or comp_val here because the tactic framework has not been defined yet.\nWe also do not use `zero_lt_succ _` as a proof term because this proof may not be trivial to check by\nexternal type checkers. See discussion at: https://github.com/leanprover/tc/issues/8\n-/\nlemma zero_lt_d800 : 0 < 0xd800 :=\nnat.zero_lt_bit0 $ nat.bit0_ne_zero $ nat.bit0_ne_zero $ nat.bit0_ne_zero $\nnat.bit0_ne_zero $ nat.bit0_ne_zero $ nat.bit0_ne_zero $ nat.bit0_ne_zero $\nnat.bit0_ne_zero $ nat.bit0_ne_zero $ nat.bit0_ne_zero $ nat.bit1_ne_zero 13\n\n@[pattern] def of_nat (n : nat) : char :=\nif h : is_valid_char n then {val := n, valid := h} else {val := 0, valid := or.inl zero_lt_d800}\n\ndef to_nat (c : char) : nat :=\nc.val\n\nlemma eq_of_veq : ∀ {c d : char}, c.val = d.val → c = d\n| ⟨v, h⟩ ⟨_, _⟩ rfl := rfl\n\nlemma veq_of_eq : ∀ {c d : char}, c = d → c.val = d.val\n| _ _ rfl := rfl\n\nlemma ne_of_vne {c d : char} (h : c.val ≠ d.val) : c ≠ d :=\nλ h', absurd (veq_of_eq h') h\n\nlemma vne_of_ne {c d : char} (h : c ≠ d) : c.val ≠ d.val :=\nλ h', absurd (eq_of_veq h') h\n\nend char\n\ninstance : decidable_eq char :=\nλ i j, decidable_of_decidable_of_iff\n  (nat.decidable_eq i.val j.val) ⟨char.eq_of_veq, char.veq_of_eq⟩\n\ninstance : inhabited char :=\n⟨'A'⟩\n", "meta": {"author": "subfish-zhou", "repo": "N2Lean", "sha": "8e858cc5b01f1ad921094dc355db3cb9473a42fd", "save_path": "github-repos/lean/subfish-zhou-N2Lean", "path": "github-repos/lean/subfish-zhou-N2Lean/N2Lean-8e858cc5b01f1ad921094dc355db3cb9473a42fd/library/init/data/char/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4916880833295017}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.limits.shapes.biproducts\nimport category_theory.limits.preserves.shapes.zero\n\n/-!\n# Preservation of biproducts\n\nWe define the image of a (binary) bicone under a functor that preserves zero morphisms and define\nclasses `preserves_biproduct` and `preserves_binary_biproduct`. We then\n\n* show that a functor that preserves biproducts of a two-element type preserves binary biproducts,\n* give the canonical isomorphism between the image of a biproduct and the biproduct of the images,\n* show that in a preadditive category, a functor preserves a biproduct if and only if it preserves\n  the corresponding product if and only if it preserves the corresponding coproduct.\n\n-/\n\nuniverses w₁ w₂ v₁ v₂ u₁ u₂\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\nsection has_zero_morphisms\nvariables [has_zero_morphisms C] [has_zero_morphisms D]\n\nnamespace functor\n\nsection map\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w₁}\n\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef map_bicone {f : J → C} (b : bicone f) : bicone (F.obj ∘ f) :=\n{ X := F.obj b.X,\n  π := λ j, F.map (b.π j),\n  ι := λ j, F.map (b.ι j),\n  ι_π := λ j j',\n  begin\n    rw ← F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_ι_π_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_ι_π_ne _ h, F.map_zero] }\n  end }\n\nlemma map_bicone_whisker {K : Type w₂} {g : K ≃ J} {f : J → C} (c : bicone f) :\n  F.map_bicone (c.whisker g) = (F.map_bicone c).whisker g := rfl\n\nend bicone\n\n/-- The image of a binary bicone under a functor. -/\n@[simps]\ndef map_binary_bicone {X Y : C} (b : binary_bicone X Y) : binary_bicone (F.obj X) (F.obj Y) :=\n{ X := F.obj b.X,\n  fst := F.map b.fst,\n  snd := F.map b.snd,\n  inl := F.map b.inl,\n  inr := F.map b.inr,\n  inl_fst' := by rw [← F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [← F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [← F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [← F.map_comp, b.inr_snd, F.map_id] }\n\nend map\n\nend functor\n\nopen category_theory.functor\n\nnamespace limits\n\nsection bicone\nvariables {J : Type w₁} {K : Type w₂}\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\nclass preserves_biproduct (f : J → C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : bicone f}, b.is_bilimit → (F.map_bicone b).is_bilimit)\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\ndef is_bilimit_of_preserves {f : J → C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_biproduct f F] {b : bicone f} (hb : b.is_bilimit) : (F.map_bicone b).is_bilimit :=\npreserves_biproduct.preserves hb\n\nvariables (J)\n\n/-- A functor `F` preserves biproducts of shape `J` if it preserves biproducts of `f` for every\n    `f : J → C`. -/\nclass preserves_biproducts_of_shape (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {f : J → C}, preserves_biproduct f F)\n\nattribute [instance, priority 100] preserves_biproducts_of_shape.preserves\n\nend bicone\n\n/-- A functor `F` preserves finite biproducts if it preserves biproducts of shape `J` whenever\n    `J` is a fintype. -/\nclass preserves_finite_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type} [fintype J], preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_finite_biproducts.preserves\n\n/-- A functor `F` preserves biproducts if it preserves biproducts of any shape `J` of size `w`.\n    The usual notion of preservation of biproducts is recovered by choosing `w` to be the universe\n    of the morphisms of `C`. -/\nclass preserves_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type w₁}, preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_biproducts.preserves\n\n/-- Preserving biproducts at a bigger universe level implies preserving biproducts at a\nsmaller universe level. -/\ndef preserves_biproducts_shrink (F : C ⥤ D) [preserves_zero_morphisms F]\n  [hp : preserves_biproducts.{max w₁ w₂} F] : preserves_biproducts.{w₁} F :=\n⟨λ J, ⟨λ f, ⟨λ b ib, ((F.map_bicone b).whisker_is_bilimit_iff _).to_fun\n  (is_bilimit_of_preserves F ((b.whisker_is_bilimit_iff equiv.ulift.{w₂}).inv_fun ib))⟩⟩⟩\n\n@[priority 100]\ninstance preserves_finite_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts.{w₁} F] : preserves_finite_biproducts F :=\n{ preserves := λ J _, by letI := preserves_biproducts_shrink.{0} F; apply_instance }\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\nclass preserves_binary_biproduct (X Y : C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : binary_bicone X Y}, b.is_bilimit → (F.map_binary_bicone b).is_bilimit)\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\ndef is_binary_bilimit_of_preserves {X Y : C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_binary_biproduct X Y F] {b : binary_bicone X Y} (hb : b.is_bilimit) :\n  (F.map_binary_bicone b).is_bilimit :=\npreserves_binary_biproduct.preserves hb\n\n/-- A functor `F` preserves binary biproducts if it preserves the binary biproduct of `X` and `Y`\n    for all `X` and `Y`. -/\nclass preserves_binary_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {X Y : C}, preserves_binary_biproduct X Y F . tactic.apply_instance)\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_biproduct (F : C ⥤ D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair_function X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb,\n  { is_limit := is_limit.of_iso_limit\n      ((is_limit.postcompose_hom_equiv (by exact diagram_iso_pair _) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_limit)) $\n      cones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy, }),\n    is_colimit := is_colimit.of_iso_colimit\n      ((is_colimit.precompose_inv_equiv (by exact diagram_iso_pair _ ) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_colimit)) $\n      cocones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy, }) } }\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape walking_pair F] :\n  preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_biproduct F X Y }\n\nattribute [instance, priority 100] preserves_binary_biproducts.preserves\n\nend limits\n\nopen category_theory.limits\n\nnamespace functor\n\nsection bicone\nvariables {J : Type w₁} (F : C ⥤ D) [preserves_zero_morphisms F] (f : J → C)\n  [has_biproduct f] [preserves_biproduct f F]\n\ninstance has_biproduct_of_preserves : has_biproduct (F.obj ∘ f) :=\nhas_biproduct.mk\n{ bicone := F.map_bicone (biproduct.bicone f),\n  is_bilimit := preserves_biproduct.preserves (biproduct.is_bilimit _) }\n\n/-- If `F` preserves a biproduct, we get a definitionally nice isomorphism\n    `F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f)`. -/\n@[simp]\ndef map_biproduct : F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (λ j, F.map (biproduct.π f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (λ j, F.map (biproduct.ι f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C ⥤ D) [preserves_zero_morphisms F] (X Y : C) [has_binary_biproduct X Y]\n  [preserves_binary_biproduct X Y F]\n\ninstance has_binary_biproduct_of_preserves : has_binary_biproduct (F.obj X) (F.obj Y) :=\nhas_binary_biproduct.mk\n{ bicone := F.map_binary_bicone (binary_biproduct.bicone X Y),\n  is_bilimit := preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _) }\n\n/-- If `F` preserves a binary biproduct, we get a definitionally nice isomorphism\n    `F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y :=\nbiprod.unique_up_to_iso _ _\n  (preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _))\n\nlemma map_biprod_hom : (map_biprod F X Y).hom = biprod.lift (F.map biprod.fst) (F.map biprod.snd) :=\nrfl\n\nlemma map_biprod_inv : (map_biprod F X Y).inv = biprod.desc (F.map biprod.inl) (F.map biprod.inr) :=\nrfl\n\nend functor\n\nnamespace limits\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w₁} (f : J → C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : Π j, W ⟶ f j) :\n  F.map (biproduct.lift g) ≫ (F.map_biproduct f).hom = biproduct.lift (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).inv ≫ F.map (biproduct.desc g) = biproduct.desc (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).hom ≫ biproduct.desc (λ j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [← biproduct.map_biproduct_inv_map_desc, iso.hom_inv_id_assoc]\n\nend bicone\n\nsection binary_bicone\nvariables (X Y : C) [has_binary_biproduct X Y] [preserves_binary_biproduct X Y F] {W : C}\n\nlemma biprod.map_lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  F.map (biprod.lift f g) ≫ (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  biprod.lift (F.map f) (F.map g) ≫ (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [← biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X ⟶ W) (g : Y ⟶ W) :\n  (F.map_biprod X Y).inv ≫ F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X ⟶ W) (g : Y ⟶ W) :\n (F.map_biprod X Y).hom ≫ biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [← biprod.map_biprod_inv_map_desc, iso.hom_inv_id_assoc]\n\nend binary_bicone\n\nend limits\n\nend has_zero_morphisms\n\nopen category_theory.functor\n\nsection preadditive\nvariables [preadditive C] [preadditive D] (F : C ⥤ D) [preserves_zero_morphisms F]\n\nnamespace limits\n\nsection fintype\nvariables {J : Type} [fintype J]\n\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite products. -/\ndef preserves_product_of_preserves_biproduct {f : J → C} [preserves_biproduct f F] :\n  preserves_limit (discrete.functor f) F :=\n{ preserves := λ c hc, is_limit.of_iso_limit\n  ((is_limit.postcompose_inv_equiv (discrete.comp_nat_iso_discrete _ _) _).symm\n    (is_bilimit_of_preserves F (bicone_is_bilimit_of_limit_cone_of_is_limit hc)).is_limit) $\n  cones.ext (iso.refl _) (by tidy) }\n\nsection\nlocal attribute [instance] preserves_product_of_preserves_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite products. -/\ndef preserves_products_of_shape_of_preserves_biproducts_of_shape\n  [preserves_biproducts_of_shape J F] : preserves_limits_of_shape (discrete J) F :=\n{ preserves_limit := λ f, preserves_limit_of_iso_diagram _ discrete.nat_iso_functor.symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite products\n    preserves finite biproducts. -/\ndef preserves_biproduct_of_preserves_product {f : J → C} [preserves_limit (discrete.functor f) F] :\n  preserves_biproduct f F :=\n{ preserves := λ b hb, is_bilimit_of_is_limit _ $\n    is_limit.of_iso_limit ((is_limit.postcompose_hom_equiv (discrete.comp_nat_iso_discrete _ _)\n      (F.map_cone b.to_cone)).symm (is_limit_of_preserves F hb.is_limit)) $\n      cones.ext (iso.refl _) (by tidy) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite products\n    preserves finite biproducts. -/\ndef preserves_biproducts_of_shape_of_preserves_products_of_shape\n  [preserves_limits_of_shape (discrete J) F] : preserves_biproducts_of_shape J F :=\n{ preserves := λ f, preserves_biproduct_of_preserves_product F }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite coproducts. -/\ndef preserves_coproduct_of_preserves_biproduct {f : J → C} [preserves_biproduct f F] :\n  preserves_colimit (discrete.functor f) F :=\n{ preserves := λ c hc, is_colimit.of_iso_colimit\n    ((is_colimit.precompose_hom_equiv (discrete.comp_nat_iso_discrete _ _) _).symm\n      (is_bilimit_of_preserves F\n        (bicone_is_bilimit_of_colimit_cocone_of_is_colimit hc)).is_colimit) $\n    cocones.ext (iso.refl _) (by tidy) }\n\nsection\nlocal attribute [instance] preserves_coproduct_of_preserves_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite coproducts. -/\ndef preserves_coproducts_of_shape_of_preserves_biproducts_of_shape\n  [preserves_biproducts_of_shape J F] : preserves_colimits_of_shape (discrete J) F :=\n{ preserves_colimit := λ f, preserves_colimit_of_iso_diagram _ discrete.nat_iso_functor.symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts\n    preserves finite biproducts. -/\ndef preserves_biproduct_of_preserves_coproduct {f : J → C}\n  [preserves_colimit (discrete.functor f) F] : preserves_biproduct f F :=\n{ preserves := λ b hb, is_bilimit_of_is_colimit _ $\n    is_colimit.of_iso_colimit ((is_colimit.precompose_inv_equiv (discrete.comp_nat_iso_discrete _ _)\n      (F.map_cocone b.to_cocone)).symm (is_colimit_of_preserves F hb.is_colimit)) $\n      cocones.ext (iso.refl _) (by tidy) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts\n    preserves finite biproducts. -/\ndef preserves_biproducts_of_shape_of_preserves_coproducts_of_shape\n  [preserves_colimits_of_shape (discrete J) F] : preserves_biproducts_of_shape J F :=\n{ preserves := λ f, preserves_biproduct_of_preserves_coproduct F }\n\nend fintype\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary products. -/\ndef preserves_binary_product_of_preserves_binary_biproduct {X Y : C}\n  [preserves_binary_biproduct X Y F] : preserves_limit (pair X Y) F :=\n{ preserves := λ c hc, is_limit.of_iso_limit\n    ((is_limit.postcompose_inv_equiv (by exact diagram_iso_pair _) _).symm\n      (is_binary_bilimit_of_preserves F\n        (binary_bicone_is_bilimit_of_limit_cone_of_is_limit hc)).is_limit) $\n    cones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\nsection\nlocal attribute [instance] preserves_binary_product_of_preserves_binary_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary products. -/\ndef preserves_binary_products_of_preserves_binary_biproducts\n  [preserves_binary_biproducts F] : preserves_limits_of_shape (discrete walking_pair) F :=\n{ preserves_limit := λ K, preserves_limit_of_iso_diagram _ (diagram_iso_pair _).symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary products\n    preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_binary_product {X Y : C}\n  [preserves_limit (pair X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb, is_binary_bilimit_of_is_limit _ $\n    is_limit.of_iso_limit ((is_limit.postcompose_hom_equiv (by exact diagram_iso_pair _)\n      (F.map_cone b.to_cone)).symm (is_limit_of_preserves F hb.is_limit)) $\n        cones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary products\n    preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_binary_products\n  [preserves_limits_of_shape (discrete walking_pair) F] : preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_binary_product F }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary coproducts. -/\ndef preserves_binary_coproduct_of_preserves_binary_biproduct {X Y : C}\n  [preserves_binary_biproduct X Y F] : preserves_colimit (pair X Y) F :=\n{ preserves := λ c hc, is_colimit.of_iso_colimit\n    ((is_colimit.precompose_hom_equiv (by exact diagram_iso_pair _) _).symm\n      (is_binary_bilimit_of_preserves F\n        (binary_bicone_is_bilimit_of_colimit_cocone_of_is_colimit hc)).is_colimit) $\n      cocones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\nsection\nlocal attribute [instance] preserves_binary_coproduct_of_preserves_binary_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary coproducts. -/\ndef preserves_binary_coproducts_of_preserves_binary_biproducts\n  [preserves_binary_biproducts F] : preserves_colimits_of_shape (discrete walking_pair) F :=\n{ preserves_colimit := λ K, preserves_colimit_of_iso_diagram _ (diagram_iso_pair _).symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts\n    preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_binary_coproduct {X Y : C}\n  [preserves_colimit (pair X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb, is_binary_bilimit_of_is_colimit _ $\n    is_colimit.of_iso_colimit ((is_colimit.precompose_inv_equiv (by exact diagram_iso_pair _)\n      (F.map_cocone b.to_cocone)).symm (is_colimit_of_preserves F hb.is_colimit)) $\n        cocones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy }) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts\n    preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_binary_coproducts\n  [preserves_colimits_of_shape (discrete walking_pair) F] : preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_binary_coproduct F }\n\nend limits\n\nend preadditive\n\nend category_theory\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/category_theory/limits/preserves/shapes/biproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4916880766429436}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# modular equivalence for submodule\n-/\n\n/-- A predicate saying two elements of a module are equivalent modulo a submodule. -/\ndef smodeq {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    (U : submodule R M) (x : M) (y : M) :=\n  submodule.quotient.mk x = submodule.quotient.mk y\n\nprotected theorem smodeq.def {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x : M} {y : M} :\n    smodeq U x y ↔ submodule.quotient.mk x = submodule.quotient.mk y :=\n  iff.rfl\n\nnamespace smodeq\n\n\n@[simp] theorem top {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {x : M}\n    {y : M} : smodeq ⊤ x y :=\n  iff.mpr (submodule.quotient.eq ⊤) submodule.mem_top\n\n@[simp] theorem bot {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {x : M}\n    {y : M} : smodeq ⊥ x y ↔ x = y :=\n  sorry\n\ntheorem mono {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U₁ : submodule R M} {U₂ : submodule R M} {x : M} {y : M} (HU : U₁ ≤ U₂) (hxy : smodeq U₁ x y) :\n    smodeq U₂ x y :=\n  iff.mpr (submodule.quotient.eq U₂) (HU (iff.mp (submodule.quotient.eq U₁) hxy))\n\ntheorem refl {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x : M} : smodeq U x x :=\n  Eq.refl (submodule.quotient.mk x)\n\ntheorem symm {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x : M} {y : M} (hxy : smodeq U x y) : smodeq U y x :=\n  Eq.symm hxy\n\ntheorem trans {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x : M} {y : M} {z : M} (hxy : smodeq U x y) (hyz : smodeq U y z) :\n    smodeq U x z :=\n  Eq.trans hxy hyz\n\ntheorem add {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x₁ : M} {x₂ : M} {y₁ : M} {y₂ : M} (hxy₁ : smodeq U x₁ y₁)\n    (hxy₂ : smodeq U x₂ y₂) : smodeq U (x₁ + x₂) (y₁ + y₂) :=\n  sorry\n\ntheorem smul {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x : M} {y : M} (hxy : smodeq U x y) (c : R) : smodeq U (c • x) (c • y) :=\n  sorry\n\ntheorem zero {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x : M} : smodeq U x 0 ↔ x ∈ U :=\n  sorry\n\ntheorem map {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M]\n    {U : submodule R M} {x : M} {y : M} {N : Type u_3} [add_comm_group N] [module R N]\n    (hxy : smodeq U x y) (f : linear_map R M N) :\n    smodeq (submodule.map f U) (coe_fn f x) (coe_fn f y) :=\n  iff.mpr (submodule.quotient.eq (submodule.map f U))\n    (Eq.subst (linear_map.map_sub f x y) submodule.mem_map_of_mem\n      (iff.mp (submodule.quotient.eq U) hxy))\n\ntheorem comap {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {x : M} {y : M}\n    {N : Type u_3} [add_comm_group N] [module R N] (V : submodule R N) {f : linear_map R M N}\n    (hxy : smodeq V (coe_fn f x) (coe_fn f y)) : smodeq (submodule.comap f V) x y :=\n  iff.mpr (submodule.quotient.eq (submodule.comap f V))\n    ((fun (this : coe_fn f (x - y) ∈ V) => this)\n      (Eq.symm (linear_map.map_sub f x y) ▸ iff.mp (submodule.quotient.eq V) hxy))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/smodeq_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489892, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.49151386904871824}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nEvaluate expressions in the language of (semi-)rings.\nBased on http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf .\n-/\nimport algebra.group_power tactic.norm_num\nimport tactic.converter.interactive\n\nnamespace tactic\nnamespace ring\n\ndef horner {α} [comm_semiring α] (a x : α) (n : ℕ) (b : α) := a * x ^ n + b\n\nmeta structure cache :=\n(α : expr)\n(univ : level)\n(comm_semiring_inst : expr)\n\nmeta def mk_cache (e : expr) : tactic cache :=\ndo α ← infer_type e,\n   c ← mk_app ``comm_semiring [α] >>= mk_instance,\n   u ← mk_meta_univ,\n   infer_type α >>= unify (expr.sort (level.succ u)),\n   u ← get_univ_assignment u,\n   return ⟨α, u, c⟩\n\nmeta def cache.cs_app (c : cache) (n : name) : list expr → expr :=\n(@expr.const tt n [c.univ] c.α c.comm_semiring_inst).mk_app\n\nmeta def cache.mk_app (c : cache) (n inst : name) (l : list expr) : tactic expr :=\ndo m ← mk_instance ((expr.const inst [c.univ] : expr) c.α),\n   return $ (@expr.const tt n [c.univ] c.α m).mk_app l\n\nmeta inductive horner_expr : Type\n| const (e : expr) : horner_expr\n| xadd (e : expr) (a : horner_expr) (x : expr) (n : expr × ℕ) (b : horner_expr) : horner_expr\n\nmeta def horner_expr.e : horner_expr → expr\n| (horner_expr.const e) := e\n| (horner_expr.xadd e _ _ _ _) := e\n\nmeta instance : has_coe horner_expr expr := ⟨horner_expr.e⟩\n\nmeta def horner_expr.xadd' (c : cache) (a : horner_expr) (x : expr) (n : expr × ℕ) (b : horner_expr): horner_expr :=\nhorner_expr.xadd (c.cs_app ``horner [a, x, n.1, b]) a x n b\n\nopen horner_expr\n\nmeta def horner_expr.to_string : horner_expr → string\n| (const e) := to_string e\n| (xadd e a x (_, n) b) :=\n    \"(\" ++ a.to_string ++ \") * (\" ++ to_string x ++ \")^\"\n        ++ to_string n ++ \" + \" ++ b.to_string\n\nmeta def horner_expr.pp : horner_expr → tactic format\n| (const e) := pp e\n| (xadd e a x (_, n) b) := do\n  pa ← a.pp, pb ← b.pp, px ← pp x,\n  return $ \"(\" ++ pa ++ \") * (\" ++ px ++ \")^\" ++ to_string n ++ \" + \" ++ pb\n\nmeta instance : has_to_tactic_format horner_expr := ⟨horner_expr.pp⟩\n\nmeta def horner_expr.refl_conv (e : horner_expr) : tactic (horner_expr × expr) :=\ndo p ← mk_eq_refl e, return (e, p)\n\ntheorem zero_horner {α} [comm_semiring α] (x n b) :\n  @horner α _ 0 x n b = b :=\nby simp [horner]\n\ntheorem horner_horner {α} [comm_semiring α] (a₁ x n₁ n₂ b n')\n  (h : n₁ + n₂ = n') :\n  @horner α _ (horner a₁ x n₁ 0) x n₂ b = horner a₁ x n' b :=\nby simp [h.symm, horner, pow_add, mul_assoc]\n\nmeta def eval_horner (c : cache) : horner_expr → expr → expr × ℕ → horner_expr → tactic (horner_expr × expr)\n| ha@(const a) x n b :=\n  if a.to_nat = some 0 then\n    return (b, c.cs_app ``zero_horner [x, n.1, b])\n  else (xadd' c ha x n b).refl_conv\n| ha@(xadd a a₁ x₁ n₁ b₁) x n b :=\n  if x₁ = x ∧ b₁.e.to_nat = some 0 then do\n    (n', h) ← mk_app ``has_add.add [n₁.1, n.1] >>= norm_num,\n    return (xadd' c a₁ x (n', n₁.2 + n.2) b,\n      c.cs_app ``horner_horner [a₁, x, n₁.1, n.1, b, n', h])\n  else (xadd' c ha x n b).refl_conv\n\ntheorem const_add_horner {α} [comm_semiring α] (k a x n b b') (h : k + b = b') :\n  k + @horner α _ a x n b = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_const {α} [comm_semiring α] (a x n b k b') (h : b + k = b') :\n  @horner α _ a x n b + k = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_horner_lt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b')\n  (h₁ : n₁ + k = n₂) (h₂ : (a₁ + horner a₂ x k 0 : α) = a') (h₃ : b₁ + b₂ = b') :\n  @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₁ b' :=\nby simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_gt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b')\n  (h₁ : n₂ + k = n₁) (h₂ : (horner a₁ x k 0 + a₂ : α) = a') (h₃ : b₁ + b₂ = b') :\n  @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₂ b' :=\nby simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_eq {α} [comm_semiring α] (a₁ x n b₁ a₂ b₂ a' b' t)\n  (h₁ : a₁ + a₂ = a') (h₂ : b₁ + b₂ = b') (h₃ : horner a' x n b' = t) :\n  @horner α _ a₁ x n b₁ + horner a₂ x n b₂ = t :=\nby simp [h₃.symm, h₂.symm, h₁.symm, horner, add_mul, mul_comm]\n\nmeta def eval_add (c : cache) : horner_expr → horner_expr → tactic (horner_expr × expr)\n| (const e₁) (const e₂) := do\n  (e, p) ← mk_app ``has_add.add [e₁, e₂] >>= norm_num,\n  return (const e, p)\n| he₁@(const e₁) he₂@(xadd e₂ a x n b) :=\n  if e₁.to_nat = some 0 then  do\n    p ← mk_app ``zero_add [e₂],\n    return (he₂, p)\n  else do\n    (b', h) ← eval_add he₁ b,\n    return (xadd' c a x n b',\n      c.cs_app ``const_add_horner [e₁, a, x, n.1, b, b', h])\n| he₁@(xadd e₁ a x n b) he₂@(const e₂) :=\n  if e₂.to_nat = some 0 then do\n    p ← mk_app ``add_zero [e₁],\n    return (he₁, p)\n  else do\n    (b', h) ← eval_add b he₂,\n    return (xadd' c a x n b',\n      c.cs_app ``horner_add_const [a, x, n.1, b, e₂, b', h])\n| he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) :=\n  if expr.lex_lt x₁ x₂ then do\n    (b', h) ← eval_add b₁ he₂,\n    return (xadd' c a₁ x₁ n₁ b',\n      c.cs_app ``horner_add_const [a₁, x₁, n₁.1, b₁, e₂, b', h])\n  else if x₁ ≠ x₂ then do\n    (b', h) ← eval_add he₁ b₂,\n    return (xadd' c a₂ x₂ n₂ b',\n      c.cs_app ``const_add_horner [e₁, a₂, x₂, n₂.1, b₂, b', h])\n  else if n₁.2 < n₂.2 then do\n    let k := n₂.2 - n₁.2,\n    ek ← expr.of_nat (expr.const `nat []) k,\n    (_, h₁) ← mk_app ``has_add.add [n₁.1, ek] >>= norm_num,\n    α0 ← expr.of_nat c.α 0,\n    (a', h₂) ← eval_add a₁ (xadd' c a₂ x₁ (ek, k) (const α0)),\n    (b', h₃) ← eval_add b₁ b₂,\n    return (xadd' c a' x₁ n₁ b',\n      c.cs_app ``horner_add_horner_lt [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃])\n  else if n₁ ≠ n₂ then do\n    let k := n₁.2 - n₂.2,\n    ek ← expr.of_nat (expr.const `nat []) k,\n    (_, h₁) ← mk_app ``has_add.add [n₂.1, ek] >>= norm_num,\n    α0 ← expr.of_nat c.α 0,\n    (a', h₂) ← eval_add (xadd' c a₁ x₁ (ek, k) (const α0)) a₂,\n    (b', h₃) ← eval_add b₁ b₂,\n    return (xadd' c a' x₁ n₂ b',\n      c.cs_app ``horner_add_horner_gt [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃])\n  else do\n    (a', h₁) ← eval_add a₁ a₂,\n    (b', h₂) ← eval_add b₁ b₂,\n    (t, h₃) ← eval_horner c a' x₁ n₁ b',\n    return (t, c.cs_app ``horner_add_horner_eq\n      [a₁, x₁, n₁.1, b₁, a₂, b₂, a', b', t, h₁, h₂, h₃])\n\ntheorem horner_neg {α} [comm_ring α] (a x n b a' b')\n  (h₁ : -a = a') (h₂ : -b = b') :\n  -@horner α _ a x n b = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner]\n\nmeta def eval_neg (c : cache) : horner_expr → tactic (horner_expr × expr)\n| (const e) := do\n  (e', p) ← mk_app ``has_neg.neg [e] >>= norm_num,\n  return (const e', p)\n| (xadd e a x n b) := do\n  (a', h₁) ← eval_neg a,\n  (b', h₂) ← eval_neg b,\n  p ← c.mk_app ``horner_neg ``comm_ring [a, x, n.1, b, a', b', h₁, h₂],\n  return (xadd' c a' x n b', p)\n\ntheorem horner_const_mul {α} [comm_semiring α] (c a x n b a' b')\n  (h₁ : c * a = a') (h₂ : c * b = b') :\n  c * @horner α _ a x n b = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner, mul_add, mul_assoc]\n\ntheorem horner_mul_const {α} [comm_semiring α] (a x n b c a' b')\n  (h₁ : a * c = a') (h₂ : b * c = b') :\n  @horner α _ a x n b * c = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner, add_mul, mul_right_comm]\n\nmeta def eval_const_mul (c : cache) (k : expr) :\n  horner_expr → tactic (horner_expr × expr)\n| (const e) := do\n  (e', p) ← mk_app ``has_mul.mul [k, e] >>= norm_num,\n  return (const e', p)\n| (xadd e a x n b) := do\n  (a', h₁) ← eval_const_mul a,\n  (b', h₂) ← eval_const_mul b,\n  return (xadd' c a' x n b',\n    c.cs_app ``horner_const_mul [k, a, x, n.1, b, a', b', h₁, h₂])\n\ntheorem horner_mul_horner_zero {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ aa t)\n  (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa)\n  (h₂ : horner aa x n₂ 0 = t) :\n  horner a₁ x n₁ b₁ * horner a₂ x n₂ 0 = t :=\nby rw [← h₂, ← h₁];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\ntheorem horner_mul_horner {α} [comm_semiring α]\n  (a₁ x n₁ b₁ a₂ n₂ b₂ aa haa ab bb t)\n  (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa)\n  (h₂ : horner aa x n₂ 0 = haa)\n  (h₃ : a₁ * b₂ = ab) (h₄ : b₁ * b₂ = bb)\n  (H : haa + horner ab x n₁ bb = t) :\n  horner a₁ x n₁ b₁ * horner a₂ x n₂ b₂ = t :=\nby rw [← H, ← h₂, ← h₁, ← h₃, ← h₄];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\nmeta def eval_mul (c : cache) : horner_expr → horner_expr → tactic (horner_expr × expr)\n| (const e₁) (const e₂) := do\n  (e', p) ← mk_app ``has_mul.mul [e₁, e₂] >>= norm_num,\n  return (const e', p)\n| (const e₁) e₂ :=\n  match e₁.to_nat with\n  | (some 0) := do\n    α0 ← expr.of_nat c.α 0,\n    p ← mk_app ``zero_mul [e₂],\n    return (const α0, p)\n  | (some 1) := do\n    p ← mk_app ``one_mul [e₂],\n    return (e₂, p)\n  | _ := eval_const_mul c e₁ e₂\n  end\n| e₁ he₂@(const e₂) := do\n  p₁ ← mk_app ``mul_comm [e₁, e₂],\n  (e', p₂) ← eval_mul he₂ e₁,\n  p ← mk_eq_trans p₁ p₂, return (e', p)\n| he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) :=\n  if expr.lex_lt x₁ x₂ then do\n    (a', h₁) ← eval_mul a₁ he₂,\n    (b', h₂) ← eval_mul b₁ he₂,\n    return (xadd' c a' x₁ n₁ b',\n      c.cs_app ``horner_mul_const [a₁, x₁, n₁.1, b₁, e₂, a', b', h₁, h₂])\n  else if x₁ ≠ x₂ then do\n    (a', h₁) ← eval_mul he₁ a₂,\n    (b', h₂) ← eval_mul he₁ b₂,\n    return (xadd' c a' x₂ n₂ b',\n      c.cs_app ``horner_const_mul [e₁, a₂, x₂, n₂.1, b₂, a', b', h₁, h₂])\n  else do\n    (aa, h₁) ← eval_mul he₁ a₂,\n    α0 ← expr.of_nat c.α 0,\n    (haa, h₂) ← eval_horner c aa x₁ n₂ (const α0),\n    if b₂.e.to_nat = some 0 then\n      return (haa, c.cs_app ``horner_mul_horner_zero\n        [a₁, x₁, n₁.1, b₁, a₂, n₂.1, aa, haa, h₁, h₂])\n    else do\n      (ab, h₃) ← eval_mul a₁ b₂,\n      (bb, h₄) ← eval_mul b₁ b₂,\n      (t, H) ← eval_add c haa (xadd' c ab x₁ n₁ bb),\n      return (t, c.cs_app ``horner_mul_horner\n        [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, aa, haa, ab, bb, t, h₁, h₂, h₃, h₄, H])\n\ntheorem horner_pow {α} [comm_semiring α] (a x n m n' a')\n  (h₁ : n * m = n') (h₂ : a ^ m = a') :\n  @horner α _ a x n 0 ^ m = horner a' x n' 0 :=\nby simp [h₁.symm, h₂.symm, horner, mul_pow, pow_mul]\n\nmeta def eval_pow (c : cache) : horner_expr → expr × ℕ → tactic (horner_expr × expr)\n| e (_, 0) := do\n  α1 ← expr.of_nat c.α 1,\n  p ← mk_app ``pow_zero [e],\n  return (const α1, p)\n| e (_, 1) := do\n  p ← mk_app ``pow_one [e],\n  return (e, p)\n| (const e) (e₂, m) := do\n  (e', p) ← mk_app ``monoid.pow [e, e₂] >>= norm_num.derive,\n  return (const e', p)\n| he@(xadd e a x n b) m :=\n  let N : expr := expr.const `nat [] in\n  match b.e.to_nat with\n  | some 0 := do\n    (n', h₁) ← mk_app ``has_mul.mul [n.1, m.1] >>= norm_num,\n    (a', h₂) ← eval_pow a m,\n    α0 ← expr.of_nat c.α 0,\n    return (xadd' c a' x (n', n.2 * m.2) (const α0),\n      c.cs_app ``horner_pow [a, x, n.1, m.1, n', a', h₁, h₂])\n  | _ := do\n    e₂ ← expr.of_nat N (m.2-1),\n    l ← mk_app ``monoid.pow [e, e₂],\n    (tl, hl) ← eval_pow he (e₂, m.2-1),\n    (t, p₂) ← eval_mul c tl he,\n    hr ← mk_eq_refl e,\n    p₂ ← c.mk_app ``norm_num.subst_into_prod ``has_mul [l, e, tl, e, t, hl, hr, p₂],\n    p₁ ← mk_app ``pow_succ' [e, e₂],\n    p ← mk_eq_trans p₁ p₂,\n    return (t, p)\n  end\n\ntheorem horner_atom {α} [comm_semiring α] (x : α) : x = horner 1 x 1 0 :=\nby simp [horner]\n\nmeta def eval_atom (c : cache) (e : expr) : tactic (horner_expr × expr) :=\ndo α0 ← expr.of_nat c.α 0,\n   α1 ← expr.of_nat c.α 1,\n   n1 ← expr.of_nat (expr.const `nat []) 1,\n   return (xadd' c (const α1) e (n1, 1) (const α0), c.cs_app ``horner_atom [e])\n\nlemma subst_into_pow {α} [monoid α] (l r tl tr t)\n  (prl : (l : α) = tl) (prr : (r : ℕ) = tr) (prt : tl ^ tr = t) : l ^ r = t :=\nby simp [prl, prr, prt]\n\nlemma unfold_sub {α} [add_group α] (a b c : α)\n  (h : a + -b = c) : a - b = c := h\n\nlemma unfold_div {α} [division_ring α] (a b c : α)\n  (h : a * b⁻¹ = c) : a / b = c := h\n\nmeta def eval (c : cache) : expr → tactic (horner_expr × expr)\n| `(%%e₁ + %%e₂) := do\n  (e₁', p₁) ← eval e₁,\n  (e₂', p₂) ← eval e₂,\n  (e', p') ← eval_add c e₁' e₂',\n  p ← c.mk_app ``norm_num.subst_into_sum ``has_add [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n  return (e', p)\n| `(%%e₁ - %%e₂) := do\n  e₂' ← mk_app ``has_neg.neg [e₂],\n  e ← mk_app ``has_add.add [e₁, e₂'],\n  (e', p) ← eval e,\n  p' ← c.mk_app ``unfold_sub ``add_group [e₁, e₂, e', p],\n  return (e', p')\n| `(- %%e) := do\n  (e₁, p₁) ← eval e,\n  (e₂, p₂) ← eval_neg c e₁,\n  p ← c.mk_app ``norm_num.subst_into_neg ``has_neg [e, e₁, e₂, p₁, p₂],\n  return (e₂, p)\n| `(%%e₁ * %%e₂) := do\n  (e₁', p₁) ← eval e₁,\n  (e₂', p₂) ← eval e₂,\n  (e', p') ← eval_mul c e₁' e₂',\n  p ← c.mk_app ``norm_num.subst_into_prod ``has_mul [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n  return (e', p)\n| e@`(has_inv.inv %%_) := (do\n    (e', p) ← norm_num.derive e,\n    e'.to_rat,\n    return (const e', p)) <|> eval_atom c e\n| `(%%e₁ / %%e₂) := do\n  e₂' ← mk_app ``has_inv.inv [e₂],\n  e ← mk_app ``has_mul.mul [e₁, e₂'],\n  (e', p) ← eval e,\n  p' ← c.mk_app ``unfold_div ``division_ring [e₁, e₂, e', p],\n  return (e', p')\n| e@`(@has_pow.pow _ _ %%P %%e₁ %%e₂) := do\n  (e₂', p₂) ← eval e₂,\n  match e₂'.e.to_nat, P with\n  | some k, `(monoid.has_pow) := do\n    (e₁', p₁) ← eval e₁,\n    (e', p') ← eval_pow c e₁' (e₂, k),\n    p ← c.mk_app ``subst_into_pow ``monoid [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n    return (e', p)\n  | some k, `(nat.has_pow) := do\n    (e₁', p₁) ← eval e₁,\n    (e', p') ← eval_pow c e₁' (e₂, k),\n    p₃ ← c.mk_app ``subst_into_pow ``monoid [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n    p₄ ← mk_app ``nat.pow_eq_pow [e₁, e₂] >>= mk_eq_symm,\n    p ← mk_eq_trans p₄ p₃,\n    return (e', p)\n  | _, _ := eval_atom c e\n  end\n| e := match e.to_nat with\n  | some n := (const e).refl_conv\n  | none := eval_atom c e\n  end\n\nmeta def eval' (c : cache) (e : expr) : tactic (expr × expr) :=\ndo (e', p) ← eval c e, return (e', p)\n\ntheorem horner_def' {α} [comm_semiring α] (a x n b) : @horner α _ a x n b = x ^ n * a + b :=\nby simp [horner, mul_comm]\n\ntheorem mul_assoc_rev {α} [semigroup α] (a b c : α) : a * (b * c) = a * b * c :=\nby simp [mul_assoc]\n\ntheorem pow_add_rev {α} [monoid α] (a b : α) (m n : ℕ) : a ^ m * a ^ n = a ^ (m + n) :=\nby simp [pow_add]\n\ntheorem pow_add_rev_right {α} [monoid α] (a b : α) (m n : ℕ) : b * a ^ m * a ^ n = b * a ^ (m + n) :=\nby simp [pow_add, mul_assoc]\n\ntheorem add_neg_eq_sub {α} [add_group α] (a b : α) : a + -b = a - b := rfl\n\n@[derive has_reflect]\ninductive normalize_mode | raw | SOP | horner\n\nmeta def normalize (mode := normalize_mode.horner) (e : expr) : tactic (expr × expr) := do\npow_lemma ← simp_lemmas.mk.add_simp ``pow_one,\nlet lemmas := match mode with\n| normalize_mode.SOP :=\n  [``horner_def', ``add_zero, ``mul_one, ``mul_add, ``mul_sub,\n   ``mul_assoc_rev, ``pow_add_rev, ``pow_add_rev_right,\n   ``mul_neg_eq_neg_mul_symm, ``add_neg_eq_sub]\n| normalize_mode.horner :=\n  [``horner.equations._eqn_1, ``add_zero, ``one_mul, ``pow_one,\n   ``neg_mul_eq_neg_mul_symm, ``add_neg_eq_sub]\n| _ := []\nend,\nlemmas ← lemmas.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n(_, e', pr) ← ext_simplify_core () {}\n  simp_lemmas.mk (λ _, failed) (λ _ _ _ _ e, do\n    c ← mk_cache e,\n    (new_e, pr) ← match mode with\n    | normalize_mode.raw := eval' c\n    | normalize_mode.horner := trans_conv (eval' c) (simplify lemmas [])\n    | normalize_mode.SOP :=\n      trans_conv (eval' c) $\n      trans_conv (simplify lemmas []) $\n      simp_bottom_up' (λ e, norm_num e <|> pow_lemma.rewrite e)\n    end e,\n    guard (¬ new_e =ₐ e),\n    return ((), new_e, some pr, ff))\n   (λ _ _ _ _ _, failed) `eq e,\nreturn (e', pr)\n\nend ring\n\nnamespace interactive\nopen interactive interactive.types lean.parser\nopen tactic.ring\n\nlocal postfix `?`:9001 := optional\n\n/-- Tactic for solving equations in the language of rings.\n  This version of `ring` fails if the target is not an equality\n  that is provable by the axioms of commutative (semi)rings. -/\nmeta def ring1 : tactic unit :=\ndo `(%%e₁ = %%e₂) ← target,\n  c ← mk_cache e₁,\n  (e₁', p₁) ← eval c e₁,\n  (e₂', p₂) ← eval c e₂,\n  is_def_eq e₁' e₂',\n  p ← mk_eq_symm p₂ >>= mk_eq_trans p₁,\n  tactic.exact p\n\nmeta def ring.mode : lean.parser ring.normalize_mode :=\nwith_desc \"(SOP|raw|horner)?\" $\ndo mode ← ident?, match mode with\n| none         := return ring.normalize_mode.horner\n| some `horner := return ring.normalize_mode.horner\n| some `SOP    := return ring.normalize_mode.SOP\n| some `raw    := return ring.normalize_mode.raw\n| _            := failed\nend\n\n/-- Tactic for solving equations in the language of rings.\n  Attempts to prove the goal outright if there is no `at`\n  specifier and the target is an equality, but if this\n  fails it falls back to rewriting all ring expressions\n  into a normal form. When writing a normal form,\n  `ring SOP` will use sum-of-products form instead of horner form. -/\nmeta def ring (SOP : parse ring.mode) (loc : parse location) : tactic unit :=\nmatch loc with\n| interactive.loc.ns [none] := ring1\n| _ := failed\nend <|>\ndo ns ← loc.get_locals,\n   tt ← tactic.replace_at (normalize SOP) ns loc.include_goal\n      | fail \"ring failed to simplify\",\n   when loc.include_goal $ try tactic.reflexivity\n\nend interactive\nend tactic\n\nnamespace conv.interactive\nopen conv interactive\nopen tactic tactic.interactive (ring.mode ring1)\nopen tactic.ring (normalize)\n\nmeta def ring (SOP : parse ring.mode) : conv unit :=\ndischarge_eq_lhs ring1\n<|> replace_lhs (normalize SOP)\n<|> fail \"ring failed to simplify\"\n\nend conv.interactive\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/tactic/ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4915138611696735}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Robert Y. Lewis\n\nGeneralizes the Cauchy completion of (ℚ, abs) to the completion of a\ncommutative ring with absolute value.\n-/\nimport data.real.cau_seq\n\nnamespace cau_seq.completion\nopen cau_seq\n\nsection\nparameters {α : Type*} [linear_ordered_field α]\nparameters {β : Type*} [comm_ring β] {abv : β → α} [is_absolute_value abv]\n\ndef Cauchy := @quotient (cau_seq _ abv) cau_seq.equiv\n\ndef mk : cau_seq _ abv → Cauchy := quotient.mk\n\n@[simp] theorem mk_eq_mk (f) : @eq Cauchy ⟦f⟧ (mk f) := rfl\n\ntheorem mk_eq {f g} : mk f = mk g ↔ f ≈ g := quotient.eq\n\ndef of_rat (x : β) : Cauchy := mk (const abv x)\n\ninstance : has_zero Cauchy := ⟨of_rat 0⟩\ninstance : has_one Cauchy := ⟨of_rat 1⟩\ninstance : inhabited Cauchy := ⟨0⟩\n\ntheorem of_rat_zero : of_rat 0 = 0 := rfl\ntheorem of_rat_one : of_rat 1 = 1 := rfl\n\n@[simp] theorem mk_eq_zero {f} : mk f = 0 ↔ lim_zero f :=\nby have : mk f = 0 ↔ lim_zero (f - 0) := quotient.eq;\n   rwa sub_zero at this\n\ninstance : has_add Cauchy :=\n⟨λ x y, quotient.lift_on₂ x y (λ f g, mk (f + g)) $\n  λ f₁ g₁ f₂ g₂ hf hg, quotient.sound $\n  by simpa [(≈), setoid.r, sub_eq_add_neg, add_comm, add_left_comm, add_assoc]\n    using add_lim_zero hf hg⟩\n\n@[simp] theorem mk_add (f g : cau_seq β abv) : mk f + mk g = mk (f + g) := rfl\n\ninstance : has_neg Cauchy :=\n⟨λ x, quotient.lift_on x (λ f, mk (-f)) $\n  λ f₁ f₂ hf, quotient.sound $\n  by simpa [(≈), setoid.r] using neg_lim_zero hf⟩\n\n@[simp] theorem mk_neg (f : cau_seq β abv) : -mk f = mk (-f) := rfl\n\ninstance : has_mul Cauchy :=\n⟨λ x y, quotient.lift_on₂ x y (λ f g, mk (f * g)) $\n  λ f₁ g₁ f₂ g₂ hf hg, quotient.sound $\n  by simpa [(≈), setoid.r, mul_add, mul_comm, add_assoc, sub_eq_add_neg] using\n    add_lim_zero (mul_lim_zero_right g₁ hf) (mul_lim_zero_right f₂ hg)⟩\n\n@[simp] theorem mk_mul (f g : cau_seq β abv) : mk f * mk g = mk (f * g) := rfl\n\ninstance : has_sub Cauchy :=\n⟨λ x y, quotient.lift_on₂ x y (λ f g, mk (f - g)) $\n  λ f₁ g₁ f₂ g₂ hf hg, quotient.sound $ show ((f₁ - g₁) - (f₂ - g₂)).lim_zero,\n    by simpa [sub_eq_add_neg, add_assoc, add_comm, add_left_comm] using sub_lim_zero hf hg⟩\n\n@[simp] theorem mk_sub (f g : cau_seq β abv) : mk f - mk g = mk (f - g) := rfl\n\ntheorem of_rat_add (x y : β) : of_rat (x + y) = of_rat x + of_rat y :=\ncongr_arg mk (const_add _ _)\n\ntheorem of_rat_neg (x : β) : of_rat (-x) = -of_rat x :=\ncongr_arg mk (const_neg _)\n\ntheorem of_rat_mul (x y : β) : of_rat (x * y) = of_rat x * of_rat y :=\ncongr_arg mk (const_mul _ _)\n\nprivate lemma zero_def : 0 = mk 0 := rfl\n\nprivate lemma one_def : 1 = mk 1 := rfl\n\ninstance : comm_ring Cauchy :=\nby refine { neg := has_neg.neg, sub := has_sub.sub, sub_eq_add_neg := _,\n    add := (+), zero := (0 : Cauchy), mul := (*), one := 1, nsmul := nsmul_rec, npow := npow_rec,\n    gsmul := gsmul_rec, .. }; try { intros; refl };\n{ repeat {refine λ a, quotient.induction_on a (λ _, _)},\n  simp [zero_def, one_def, mul_left_comm, mul_comm, mul_add, add_comm, add_left_comm,\n          sub_eq_add_neg] }\n\ntheorem of_rat_sub (x y : β) : of_rat (x - y) = of_rat x - of_rat y :=\ncongr_arg mk (const_sub _ _)\n\nend\n\nopen_locale classical\nsection\n\nparameters {α : Type*} [linear_ordered_field α]\nparameters {β : Type*} [field β] {abv : β → α} [is_absolute_value abv]\nlocal notation `Cauchy` := @Cauchy _ _ _ _ abv _\n\nnoncomputable instance : has_inv Cauchy :=\n⟨λ x, quotient.lift_on x\n  (λ f, mk $ if h : lim_zero f then 0 else inv f h) $\nλ f g fg, begin\n  have := lim_zero_congr fg,\n  by_cases hf : lim_zero f,\n  { simp [hf, this.1 hf, setoid.refl] },\n  { have hg := mt this.2 hf, simp [hf, hg],\n    have If : mk (inv f hf) * mk f = 1 := mk_eq.2 (inv_mul_cancel hf),\n    have Ig : mk (inv g hg) * mk g = 1 := mk_eq.2 (inv_mul_cancel hg),\n    rw [mk_eq.2 fg, ← Ig] at If,\n    rw mul_comm at Ig,\n    rw [← mul_one (mk (inv f hf)), ← Ig, ← mul_assoc, If,\n        mul_assoc, Ig, mul_one] }\nend⟩\n\n@[simp] theorem inv_zero : (0 : Cauchy)⁻¹ = 0 :=\ncongr_arg mk $ by rw dif_pos; [refl, exact zero_lim_zero]\n\n@[simp] theorem inv_mk {f} (hf) : (@mk α _ β _ abv _ f)⁻¹ = mk (inv f hf) :=\ncongr_arg mk $ by rw dif_neg\n\nlemma cau_seq_zero_ne_one : ¬ (0 : cau_seq _ abv) ≈ 1 := λ h,\nhave lim_zero (1 - 0), from setoid.symm h,\nhave lim_zero 1, by simpa,\none_ne_zero $ const_lim_zero.1 this\n\nlemma zero_ne_one : (0 : Cauchy) ≠ 1 :=\nλ h, cau_seq_zero_ne_one $ mk_eq.1 h\n\nprotected theorem inv_mul_cancel {x : Cauchy} : x ≠ 0 → x⁻¹ * x = 1 :=\nquotient.induction_on x $ λ f hf, begin\n  simp at hf, simp [hf],\n  exact quotient.sound (cau_seq.inv_mul_cancel hf)\nend\n\nnoncomputable def field : field Cauchy :=\n{ inv              := has_inv.inv,\n  mul_inv_cancel   := λ x x0, by rw [mul_comm, cau_seq.completion.inv_mul_cancel x0],\n  exists_pair_ne   := ⟨0, 1, zero_ne_one⟩,\n  inv_zero         := inv_zero,\n  .. Cauchy.comm_ring }\n\nlocal attribute [instance] field\n\ntheorem of_rat_inv (x : β) : of_rat (x⁻¹) = ((of_rat x)⁻¹ : Cauchy) :=\ncongr_arg mk $ by split_ifs with h; [simp [const_lim_zero.1 h], refl]\n\ntheorem of_rat_div (x y : β) : of_rat (x / y) = (of_rat x / of_rat y : Cauchy) :=\nby simp only [div_eq_inv_mul, of_rat_inv, of_rat_mul]\n\nend\nend cau_seq.completion\n\nvariables {α : Type*} [linear_ordered_field α]\nnamespace cau_seq\nsection\n\nvariables (β : Type*) [ring β] (abv : β → α) [is_absolute_value abv]\n\nclass is_complete :=\n(is_complete : ∀ s : cau_seq β abv, ∃ b : β, s ≈ const abv b)\nend\n\nsection\n\nvariables {β : Type*} [ring β] {abv : β → α} [is_absolute_value abv]\nvariable [is_complete β abv]\n\nlemma complete : ∀ s : cau_seq β abv, ∃ b : β, s ≈ const abv b :=\nis_complete.is_complete\n\nnoncomputable def lim (s : cau_seq β abv) := classical.some (complete s)\n\nlemma equiv_lim (s : cau_seq β abv) : s ≈ const abv (lim s) :=\nclassical.some_spec (complete s)\n\nlemma eq_lim_of_const_equiv {f : cau_seq β abv} {x : β} (h : cau_seq.const abv x ≈ f) : x = lim f :=\nconst_equiv.mp $ setoid.trans h $ equiv_lim f\n\nlemma lim_eq_of_equiv_const {f : cau_seq β abv} {x : β} (h : f ≈ cau_seq.const abv x) : lim f = x :=\n(eq_lim_of_const_equiv $ setoid.symm h).symm\n\nlemma lim_eq_lim_of_equiv {f g : cau_seq β abv} (h : f ≈ g) : lim f = lim g :=\nlim_eq_of_equiv_const $ setoid.trans h $ equiv_lim g\n\n@[simp] lemma lim_const (x : β) : lim (const abv x) = x :=\nlim_eq_of_equiv_const $ setoid.refl _\n\nlemma lim_add (f g : cau_seq β abv) : lim f + lim g = lim (f + g) :=\neq_lim_of_const_equiv $ show lim_zero (const abv (lim f + lim g) - (f + g)),\n  by rw [const_add, add_sub_comm];\n  exact add_lim_zero (setoid.symm (equiv_lim f)) (setoid.symm (equiv_lim g))\n\nlemma lim_mul_lim (f g : cau_seq β abv) : lim f * lim g = lim (f * g) :=\neq_lim_of_const_equiv $ show lim_zero (const abv (lim f * lim g) - f * g),\n  from have h : const abv (lim f * lim g) - f * g = (const abv (lim f) - f) * g\n      + const abv (lim f) * (const abv (lim g) - g) :=\n    by simp [const_mul (lim f), mul_add, add_mul, sub_eq_add_neg, add_comm, add_left_comm],\n  by rw h; exact add_lim_zero (mul_lim_zero_left _ (setoid.symm (equiv_lim _)))\n    (mul_lim_zero_right _ (setoid.symm (equiv_lim _)))\n\nlemma lim_mul (f : cau_seq β abv) (x : β) : lim f * x = lim (f * const abv x) :=\nby rw [← lim_mul_lim, lim_const]\n\nlemma lim_neg (f : cau_seq β abv) : lim (-f) = -lim f :=\nlim_eq_of_equiv_const (show lim_zero (-f - const abv (-lim f)),\n  by rw [const_neg, sub_neg_eq_add, add_comm, ← sub_eq_add_neg];\n  exact setoid.symm (equiv_lim f))\n\nlemma lim_eq_zero_iff (f : cau_seq β abv) : lim f = 0 ↔ lim_zero f :=\n⟨assume h,\n  by have hf := equiv_lim f;\n  rw h at hf;\n  exact (lim_zero_congr hf).mpr (const_lim_zero.mpr rfl),\nassume h,\n  have h₁ : f = (f - const abv 0) := ext (λ n, by simp [sub_apply, const_apply]),\n  by rw h₁ at h; exact lim_eq_of_equiv_const h ⟩\n\nend\n\nsection\nvariables {β : Type*} [field β] {abv : β → α} [is_absolute_value abv] [is_complete β abv]\n\nlemma lim_inv {f : cau_seq β abv} (hf : ¬ lim_zero f) : lim (inv f hf) = (lim f)⁻¹ :=\nhave hl : lim f ≠ 0 := by rwa ← lim_eq_zero_iff at hf,\nlim_eq_of_equiv_const $ show lim_zero (inv f hf - const abv (lim f)⁻¹),\n  from have h₁ : ∀ (g f : cau_seq β abv) (hf : ¬ lim_zero f), lim_zero (g - f * inv f hf * g) :=\n    λ g f hf, by rw [← one_mul g, ← mul_assoc, ← sub_mul, mul_one, mul_comm, mul_comm f];\n    exact mul_lim_zero_right _ (setoid.symm (cau_seq.inv_mul_cancel _)),\n  have h₂ : lim_zero ((inv f hf - const abv (lim f)⁻¹) - (const abv (lim f) - f) *\n      (inv f hf * const abv (lim f)⁻¹)) :=\n    by rw [sub_mul, ← sub_add, sub_sub, sub_add_eq_sub_sub, sub_right_comm, sub_add];\n    exact show lim_zero (inv f hf - const abv (lim f) * (inv f hf * const abv (lim f)⁻¹)\n      - (const abv (lim f)⁻¹ - f * (inv f hf * const abv (lim f)⁻¹))),\n    from sub_lim_zero\n      (by rw [← mul_assoc, mul_right_comm, const_inv hl]; exact h₁ _ _ _)\n      (by rw [← mul_assoc]; exact h₁ _ _ _),\n  (lim_zero_congr h₂).mpr $ mul_lim_zero_left _ (setoid.symm (equiv_lim f))\n\nend\n\nsection\nvariables [is_complete α abs]\n\nlemma lim_le {f : cau_seq α abs} {x : α}\n  (h : f ≤ cau_seq.const abs x) : lim f ≤ x :=\ncau_seq.const_le.1 $ cau_seq.le_of_eq_of_le (setoid.symm (equiv_lim f)) h\n\nlemma le_lim {f : cau_seq α abs} {x : α}\n  (h : cau_seq.const abs x ≤ f) : x ≤ lim f :=\ncau_seq.const_le.1 $ cau_seq.le_of_le_of_eq h (equiv_lim f)\n\nlemma lt_lim {f : cau_seq α abs} {x : α}\n  (h : cau_seq.const abs x < f) : x < lim f :=\ncau_seq.const_lt.1 $ cau_seq.lt_of_lt_of_eq h (equiv_lim f)\n\nlemma lim_lt {f : cau_seq α abs} {x : α}\n  (h : f < cau_seq.const abs x) : lim f < x :=\ncau_seq.const_lt.1 $ cau_seq.lt_of_eq_of_lt (setoid.symm (equiv_lim f)) h\n\nend\nend cau_seq\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/real/cau_seq_completion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4915138515701363}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.group.pi\nimport data.fintype.basic\n\n/-!\n# Matrices\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\nuniverses u u' v w z\n\n/-- `dmatrix m n` is the type of dependently typed matrices\nwhose rows are indexed by the fintype `m` and\nwhose columns are indexed by the fintype `n`. -/\n@[nolint unused_arguments]\ndef dmatrix (m : Type u) (n : Type u') [fintype m] [fintype n] (α : m → n → Type v) :\n  Type (max u u' v) :=\nΠ i j, α i j\n\nvariables {l m n o : Type*} [fintype l] [fintype m] [fintype n] [fintype o]\nvariables {α : m → n → Type v}\n\nnamespace dmatrix\n\nsection ext\nvariables {M N : dmatrix m n α}\n\ntheorem ext_iff : (∀ i j, M i j = N i j) ↔ M = N :=\n⟨λ h, funext $ λ i, funext $ h i, λ h, by simp [h]⟩\n\n@[ext] theorem ext : (∀ i j, M i j = N i j) → M = N :=\next_iff.mp\n\nend ext\n\n/-- `M.map f` is the dmatrix obtained by applying `f` to each entry of the matrix `M`. -/\ndef map (M : dmatrix m n α) {β : m → n → Type w} (f : Π ⦃i j⦄, α i j → β i j) :\n  dmatrix m n β := λ i j, f (M i j)\n\n@[simp]\nlemma map_apply {M : dmatrix m n α} {β : m → n → Type w} {f : Π ⦃i j⦄, α i j → β i j}\n  {i : m} {j : n} : M.map f i j = f (M i j) :=\nrfl\n\n@[simp]\nlemma map_map {M : dmatrix m n α} {β : m → n → Type w} {γ : m → n → Type z}\n  {f : Π ⦃i j⦄, α i j → β i j} {g : Π ⦃i j⦄, β i j → γ i j} :\n  (M.map f).map g = M.map (λ i j x, g (f x)) :=\nby { ext, simp, }\n\n/-- The transpose of a dmatrix. -/\ndef transpose (M : dmatrix m n α) : dmatrix n m (λ j i, α i j)\n| x y := M y x\n\nlocalized \"postfix (name := dmatrix.transpose) `ᵀ`:1500 := dmatrix.transpose\" in dmatrix\n\n/-- `dmatrix.col u` is the column matrix whose entries are given by `u`. -/\ndef col {α : m → Type v} (w : Π i, α i) : dmatrix m unit (λ i j, α i)\n| x y := w x\n\n/-- `dmatrix.row u` is the row matrix whose entries are given by `u`. -/\ndef row {α : n → Type v} (v : Π j, α j) : dmatrix unit n (λ i j, α j)\n| x y := v y\n\ninstance [∀ i j, inhabited (α i j)] : inhabited (dmatrix m n α) := pi.inhabited _\ninstance [∀ i j, has_add (α i j)] : has_add (dmatrix m n α) := pi.has_add\ninstance [∀ i j, add_semigroup (α i j)] : add_semigroup (dmatrix m n α) := pi.add_semigroup\ninstance [∀ i j, add_comm_semigroup (α i j)] : add_comm_semigroup (dmatrix m n α) :=\npi.add_comm_semigroup\ninstance [∀ i j, has_zero (α i j)] : has_zero (dmatrix m n α) := pi.has_zero\ninstance [∀ i j, add_monoid (α i j)] : add_monoid (dmatrix m n α) := pi.add_monoid\ninstance [∀ i j, add_comm_monoid (α i j)] : add_comm_monoid (dmatrix m n α) := pi.add_comm_monoid\ninstance [∀ i j, has_neg (α i j)] : has_neg (dmatrix m n α) := pi.has_neg\ninstance [∀ i j, has_sub (α i j)] : has_sub (dmatrix m n α) := pi.has_sub\ninstance [∀ i j, add_group (α i j)] : add_group (dmatrix m n α) := pi.add_group\ninstance [∀ i j, add_comm_group (α i j)] : add_comm_group (dmatrix m n α) := pi.add_comm_group\ninstance [∀ i j, unique (α i j)] : unique (dmatrix m n α) := pi.unique\ninstance [∀ i j, subsingleton (α i j)] : subsingleton (dmatrix m n α) := pi.subsingleton\n\n@[simp] theorem zero_apply [∀ i j, has_zero (α i j)] (i j) : (0 : dmatrix m n α) i j = 0 := rfl\n@[simp] theorem neg_apply [∀ i j, has_neg (α i j)] (M : dmatrix m n α) (i j) :\n  (- M) i j = - M i j :=\nrfl\n@[simp] theorem add_apply [∀ i j, has_add (α i j)] (M N : dmatrix m n α) (i j) :\n  (M + N) i j = M i j + N i j :=\nrfl\n@[simp] theorem sub_apply [∀ i j, has_sub (α i j)] (M N : dmatrix m n α) (i j) :\n  (M - N) i j = M i j - N i j :=\nrfl\n\n@[simp] lemma map_zero [∀ i j, has_zero (α i j)] {β : m → n → Type w} [∀ i j, has_zero (β i j)]\n  {f : Π ⦃i j⦄, α i j → β i j} (h : ∀ i j, f (0 : α i j) = 0) :\n  (0 : dmatrix m n α).map f = 0 :=\nby { ext, simp [h], }\n\nlemma map_add [∀ i j, add_monoid (α i j)] {β : m → n → Type w} [∀ i j, add_monoid (β i j)]\n  (f : Π ⦃i j⦄, α i j →+ β i j) (M N : dmatrix m n α) :\n  (M + N).map (λ i j, @f i j) = M.map (λ i j, @f i j) + N.map (λ i j, @f i j) :=\nby { ext, simp, }\n\nlemma map_sub [∀ i j, add_group (α i j)] {β : m → n → Type w} [∀ i j, add_group (β i j)]\n  (f : Π ⦃i j⦄, α i j →+ β i j) (M N : dmatrix m n α) :\n  (M - N).map (λ i j, @f i j) = M.map (λ i j, @f i j) - N.map (λ i j, @f i j) :=\nby { ext, simp }\n\ninstance subsingleton_of_empty_left [is_empty m] : subsingleton (dmatrix m n α) :=\n⟨λ M N, by { ext, exact is_empty_elim i }⟩\n\ninstance subsingleton_of_empty_right [is_empty n] : subsingleton (dmatrix m n α) :=\n⟨λ M N, by { ext, exact is_empty_elim j }⟩\n\nend dmatrix\n\n/-- The `add_monoid_hom` between spaces of dependently typed matrices\ninduced by an `add_monoid_hom` between their coefficients. -/\ndef add_monoid_hom.map_dmatrix\n  [∀ i j, add_monoid (α i j)] {β : m → n → Type w} [∀ i j, add_monoid (β i j)]\n  (f : Π ⦃i j⦄, α i j →+ β i j) :\n  dmatrix m n α →+ dmatrix m n β :=\n{ to_fun := λ M, M.map (λ i j, @f i j),\n  map_zero' := by simp,\n  map_add' := dmatrix.map_add f, }\n\n@[simp] lemma add_monoid_hom.map_dmatrix_apply\n  [∀ i j, add_monoid (α i j)] {β : m → n → Type w} [∀ i j, add_monoid (β i j)]\n  (f : Π ⦃i j⦄, α i j →+ β i j) (M : dmatrix m n α) :\n  add_monoid_hom.map_dmatrix f M = M.map (λ i j, @f i j) :=\nrfl\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/matrix/dmatrix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.4915138507098898}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.normed_space.banach\nimport Mathlib.analysis.normed_space.finite_dimension\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Complemented subspaces of normed vector spaces\n\nA submodule `p` of a topological module `E` over `R` is called *complemented* if there exists\na continuous linear projection `f : E →ₗ[R] p`, `∀ x : p, f x = x`. We prove that for\na closed subspace of a normed space this condition is equivalent to existence of a closed\nsubspace `q` such that `p ⊓ q = ⊥`, `p ⊔ q = ⊤`. We also prove that a subspace of finite codimension\nis always a complemented subspace.\n\n## Tags\n\ncomplemented subspace, normed vector space\n-/\n\nnamespace continuous_linear_map\n\n\ntheorem ker_closed_complemented_of_finite_dimensional_range {𝕜 : Type u_1}\n    [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3}\n    [normed_group F] [normed_space 𝕜 F] [complete_space 𝕜] (f : continuous_linear_map 𝕜 E F)\n    [finite_dimensional 𝕜 ↥(range f)] : submodule.closed_complemented (ker f) :=\n  sorry\n\n/-- If `f : E →L[R] F` and `g : E →L[R] G` are two surjective linear maps and\ntheir kernels are complement of each other, then `x ↦ (f x, g x)` defines\na linear equivalence `E ≃L[R] F × G`. -/\ndef equiv_prod_of_surjective_of_is_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    {G : Type u_4} [normed_group G] [normed_space 𝕜 G] [complete_space E] [complete_space (F × G)]\n    (f : continuous_linear_map 𝕜 E F) (g : continuous_linear_map 𝕜 E G) (hf : range f = ⊤)\n    (hg : range g = ⊤) (hfg : is_compl (ker f) (ker g)) : continuous_linear_equiv 𝕜 E (F × G) :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous\n    (linear_map.equiv_prod_of_surjective_of_is_compl (↑f) (↑g) hf hg hfg) sorry\n\n@[simp] theorem coe_equiv_prod_of_surjective_of_is_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F]\n    [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] [complete_space E]\n    [complete_space (F × G)] {f : continuous_linear_map 𝕜 E F} {g : continuous_linear_map 𝕜 E G}\n    (hf : range f = ⊤) (hg : range g = ⊤) (hfg : is_compl (ker f) (ker g)) :\n    ↑(equiv_prod_of_surjective_of_is_compl f g hf hg hfg) = ↑(continuous_linear_map.prod f g) :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_to_linear_equiv {𝕜 : Type u_1}\n    [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3}\n    [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G]\n    [complete_space E] [complete_space (F × G)] {f : continuous_linear_map 𝕜 E F}\n    {g : continuous_linear_map 𝕜 E G} (hf : range f = ⊤) (hg : range g = ⊤)\n    (hfg : is_compl (ker f) (ker g)) :\n    continuous_linear_equiv.to_linear_equiv (equiv_prod_of_surjective_of_is_compl f g hf hg hfg) =\n        linear_map.equiv_prod_of_surjective_of_is_compl (↑f) (↑g) hf hg hfg :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_apply {𝕜 : Type u_1}\n    [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3}\n    [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G]\n    [complete_space E] [complete_space (F × G)] {f : continuous_linear_map 𝕜 E F}\n    {g : continuous_linear_map 𝕜 E G} (hf : range f = ⊤) (hg : range g = ⊤)\n    (hfg : is_compl (ker f) (ker g)) (x : E) :\n    coe_fn (equiv_prod_of_surjective_of_is_compl f g hf hg hfg) x = (coe_fn f x, coe_fn g x) :=\n  rfl\n\nend continuous_linear_map\n\n\nnamespace subspace\n\n\n/-- If `q` is a closed complement of a closed subspace `p`, then `p × q` is continuously\nisomorphic to `E`. -/\ndef prod_equiv_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] [complete_space E] (p : subspace 𝕜 E) (q : subspace 𝕜 E)\n    (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) :\n    continuous_linear_equiv 𝕜 (↥p × ↥q) E :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous (submodule.prod_equiv_of_is_compl p q h)\n    sorry\n\n/-- Projection to a closed submodule along a closed complement. -/\ndef linear_proj_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] [complete_space E] (p : subspace 𝕜 E) (q : subspace 𝕜 E)\n    (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : continuous_linear_map 𝕜 E ↥p :=\n  continuous_linear_map.comp (continuous_linear_map.fst 𝕜 ↥p ↥q)\n    ↑(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq))\n\n@[simp] theorem coe_prod_equiv_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E}\n    {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) :\n    ⇑(prod_equiv_of_closed_compl p q h hp hq) = ⇑(submodule.prod_equiv_of_is_compl p q h) :=\n  rfl\n\n@[simp] theorem coe_prod_equiv_of_closed_compl_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E}\n    {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) :\n    ⇑(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq)) =\n        ⇑(linear_equiv.symm (submodule.prod_equiv_of_is_compl p q h)) :=\n  rfl\n\n@[simp] theorem coe_continuous_linear_proj_of_closed_compl {𝕜 : Type u_1}\n    [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E]\n    [complete_space E] {p : subspace 𝕜 E} {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p)\n    (hq : is_closed ↑q) :\n    ↑(linear_proj_of_closed_compl p q h hp hq) = submodule.linear_proj_of_is_compl p q h :=\n  rfl\n\n@[simp] theorem coe_continuous_linear_proj_of_closed_compl' {𝕜 : Type u_1}\n    [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E]\n    [complete_space E] {p : subspace 𝕜 E} {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p)\n    (hq : is_closed ↑q) :\n    ⇑(linear_proj_of_closed_compl p q h hp hq) = ⇑(submodule.linear_proj_of_is_compl p q h) :=\n  rfl\n\ntheorem closed_complemented_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E}\n    {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) :\n    submodule.closed_complemented p :=\n  Exists.intro (linear_proj_of_closed_compl p q h hp hq)\n    (submodule.linear_proj_of_is_compl_apply_left h)\n\ntheorem closed_complemented_iff_has_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} :\n    submodule.closed_complemented p ↔\n        is_closed ↑p ∧ ∃ (q : subspace 𝕜 E), ∃ (hq : is_closed ↑q), is_compl p q :=\n  sorry\n\ntheorem closed_complemented_of_quotient_finite_dimensional {𝕜 : Type u_1}\n    [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E]\n    [complete_space E] {p : subspace 𝕜 E} [complete_space 𝕜]\n    [finite_dimensional 𝕜 (submodule.quotient p)] (hp : is_closed ↑p) :\n    submodule.closed_complemented p :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/complemented_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.4915138467703676}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.equalizers\nimport Mathlib.category_theory.limits.shapes.pullbacks\nimport Mathlib.category_theory.limits.shapes.regular_mono\nimport Mathlib.PostPort\n\nuniverses v u l \n\nnamespace Mathlib\n\n/-!\n# Kernel pairs\n\nThis file defines what it means for a parallel pair of morphisms `a b : R ⟶ X` to be the kernel pair\nfor a morphism `f`.\nSome properties of kernel pairs are given, namely allowing one to transfer between\nthe kernel pair of `f₁ ≫ f₂` to the kernel pair of `f₁`.\nIt is also proved that if `f` is a coequalizer of some pair, and `a`,`b` is a kernel pair for `f` then\nit is a coequalizer of `a`,`b`.\n\n## Implementation\n\nThe definition is essentially just a wrapper for `is_limit (pullback_cone.mk _ _ _)`, but the\nconstructions given here are useful, yet awkward to present in that language, so a basic API\nis developed here.\n\n## TODO\n\n- Internal equivalence relations (or congruences) and the fact that every kernel pair induces one,\n  and the converse in an effective regular category (WIP by b-mehta).\n\n-/\n\nnamespace category_theory\n\n\n/--\n`is_kernel_pair f a b` expresses that `(a, b)` is a kernel pair for `f`, i.e. `a ≫ f = b ≫ f`\nand the square\n  R → X\n  ↓   ↓\n  X → Y\nis a pullback square.\nThis is essentially just a convenience wrapper over `is_limit (pullback_cone.mk _ _ _)`.\n-/\nstructure is_kernel_pair {C : Type u} [category C] {R : C} {X : C} {Y : C} (f : X ⟶ Y) (a : R ⟶ X)\n    (b : R ⟶ X)\n    where\n  comm : a ≫ f = b ≫ f\n  is_limit : limits.is_limit (limits.pullback_cone.mk a b comm)\n\ntheorem is_kernel_pair.comm_assoc {C : Type u} [category C] {R : C} {X : C} {Y : C} {f : X ⟶ Y}\n    {a : R ⟶ X} {b : R ⟶ X} (c : is_kernel_pair f a b) {X' : C} (f' : Y ⟶ X') :\n    a ≫ f ≫ f' = b ≫ f ≫ f' :=\n  sorry\n\nnamespace is_kernel_pair\n\n\n/-- The data expressing that `(a, b)` is a kernel pair is subsingleton. -/\nprotected instance subsingleton {C : Type u} [category C] {R : C} {X : C} {Y : C} (f : X ⟶ Y)\n    (a : R ⟶ X) (b : R ⟶ X) : subsingleton (is_kernel_pair f a b) :=\n  subsingleton.intro\n    fun (P Q : is_kernel_pair f a b) =>\n      cases_on P\n        fun (P_comm : a ≫ f = b ≫ f)\n          (P_is_limit : limits.is_limit (limits.pullback_cone.mk a b P_comm)) =>\n          cases_on Q\n            fun (Q_comm : a ≫ f = b ≫ f)\n              (Q_is_limit : limits.is_limit (limits.pullback_cone.mk a b Q_comm)) =>\n              (fun {f : X ⟶ Y} {a b : R ⟶ X} (comm comm_1 : a ≫ f = b ≫ f)\n                  (is_limit : limits.is_limit (limits.pullback_cone.mk a b comm))\n                  (is_limit_1 : limits.is_limit (limits.pullback_cone.mk a b comm_1)) =>\n                  Eq.trans\n                    ((fun {f : X ⟶ Y} {a b : R ⟶ X} (comm : a ≫ f = b ≫ f)\n                        (is_limit : limits.is_limit (limits.pullback_cone.mk a b comm)) =>\n                        Eq.refl (mk comm is_limit))\n                      comm is_limit)\n                    (congr (Eq.refl (mk comm)) (subsingleton.elim is_limit is_limit_1)))\n                P_comm Q_comm P_is_limit Q_is_limit\n\n/-- If `f` is a monomorphism, then `(𝟙 _, 𝟙 _)`  is a kernel pair for `f`. -/\ndef id_of_mono {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [mono f] :\n    is_kernel_pair f 𝟙 𝟙 :=\n  mk sorry\n    (limits.pullback_cone.is_limit_aux' (limits.pullback_cone.mk 𝟙 𝟙 sorry)\n      fun (s : limits.pullback_cone f f) =>\n        { val := limits.pullback_cone.snd s, property := sorry })\n\nprotected instance inhabited {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [mono f] :\n    Inhabited (is_kernel_pair f 𝟙 𝟙) :=\n  { default := id_of_mono f }\n\n/--\nGiven a pair of morphisms `p`, `q` to `X` which factor through `f`, they factor through any kernel\npair of `f`.\n-/\ndef lift' {C : Type u} [category C] {R : C} {X : C} {Y : C} {f : X ⟶ Y} {a : R ⟶ X} {b : R ⟶ X}\n    {S : C} (k : is_kernel_pair f a b) (p : S ⟶ X) (q : S ⟶ X) (w : p ≫ f = q ≫ f) :\n    Subtype fun (t : S ⟶ R) => t ≫ a = p ∧ t ≫ b = q :=\n  limits.pullback_cone.is_limit.lift' (is_limit k) p q w\n\n/--\nIf `(a,b)` is a kernel pair for `f₁ ≫ f₂` and `a ≫ f₁ = b ≫ f₁`, then `(a,b)` is a kernel pair for\njust `f₁`.\nThat is, to show that `(a,b)` is a kernel pair for `f₁` it suffices to only show the square\ncommutes, rather than to additionally show it's a pullback.\n-/\ndef cancel_right {C : Type u} [category C] {R : C} {X : C} {Y : C} {Z : C} {a : R ⟶ X} {b : R ⟶ X}\n    {f₁ : X ⟶ Y} {f₂ : Y ⟶ Z} (comm : a ≫ f₁ = b ≫ f₁) (big_k : is_kernel_pair (f₁ ≫ f₂) a b) :\n    is_kernel_pair f₁ a b :=\n  mk comm\n    (limits.pullback_cone.is_limit_aux' (limits.pullback_cone.mk a b comm)\n      fun (s : limits.pullback_cone f₁ f₁) =>\n        let s' : limits.pullback_cone (f₁ ≫ f₂) (f₁ ≫ f₂) :=\n          limits.pullback_cone.mk (limits.pullback_cone.fst s) (limits.pullback_cone.snd s)\n            (limits.pullback_cone.condition_assoc s f₂);\n        { val := limits.is_limit.lift (is_limit big_k) s', property := sorry })\n\n/--\nIf `(a,b)` is a kernel pair for `f₁ ≫ f₂` and `f₂` is mono, then `(a,b)` is a kernel pair for\njust `f₁`.\nThe converse of `comp_of_mono`.\n-/\ndef cancel_right_of_mono {C : Type u} [category C] {R : C} {X : C} {Y : C} {Z : C} {a : R ⟶ X}\n    {b : R ⟶ X} {f₁ : X ⟶ Y} {f₂ : Y ⟶ Z} [mono f₂] (big_k : is_kernel_pair (f₁ ≫ f₂) a b) :\n    is_kernel_pair f₁ a b :=\n  cancel_right sorry big_k\n\n/--\nIf `(a,b)` is a kernel pair for `f₁` and `f₂` is mono, then `(a,b)` is a kernel pair for `f₁ ≫ f₂`.\nThe converse of `cancel_right_of_mono`.\n-/\ndef comp_of_mono {C : Type u} [category C] {R : C} {X : C} {Y : C} {Z : C} {a : R ⟶ X} {b : R ⟶ X}\n    {f₁ : X ⟶ Y} {f₂ : Y ⟶ Z} [mono f₂] (small_k : is_kernel_pair f₁ a b) :\n    is_kernel_pair (f₁ ≫ f₂) a b :=\n  mk sorry\n    (limits.pullback_cone.is_limit_aux' (limits.pullback_cone.mk a b sorry)\n      fun (s : limits.pullback_cone (f₁ ≫ f₂) (f₁ ≫ f₂)) =>\n        { val :=\n            subtype.val\n              (limits.pullback_cone.is_limit.lift' (is_limit small_k) (limits.pullback_cone.fst s)\n                (limits.pullback_cone.snd s) sorry),\n          property := sorry })\n\n/--\nIf `(a,b)` is the kernel pair of `f`, and `f` is a coequalizer morphism for some parallel pair, then\n`f` is a coequalizer morphism of `a` and `b`.\n-/\ndef to_coequalizer {C : Type u} [category C] {R : C} {X : C} {Y : C} {f : X ⟶ Y} {a : R ⟶ X}\n    {b : R ⟶ X} (k : is_kernel_pair f a b) [r : regular_epi f] :\n    limits.is_colimit (limits.cofork.of_π f (comm k)) :=\n  limits.cofork.is_colimit.mk (limits.cofork.of_π f (comm k))\n    (fun (s : limits.cofork a b) =>\n      subtype.val (limits.cofork.is_colimit.desc' regular_epi.is_colimit (limits.cofork.π s) sorry))\n    sorry sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/shapes/kernel_pair_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110202, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.49151384369109147}}
{"text": "import data.qpf.univariate.basic\nimport control.bifunctor\n\nuniverses u\nvariables {F : Type u → Type u} [functor F]\n\nnamespace qpf\n\nsection box\nvariables (F)\n\n/-- apply a functor to a set of values. taken from\n [Basil Fürer, Andreas Lochbihler, Joshua Schneider, Dmitriy Traytel *Quotients of Bounded Natural Functors*][fuerer-lochbihler-schneider-traytel2020]\nhenceforth referred to as the QBNF paper\n -/\ndef box {α} (A : set α) : set (F α) :=\n{ x | ∀ β (f g : α → β), (∀ a ∈ A, f a = g a) → f <$> x = g <$> x }\n\nvariables {F}\n\n/--\nAlternate notion of support set based on `box`.\nTaken from the QBNF paper\n-/\ndef supp' {α} (x : F α) : set α :=\n⋂ A ∈ { A : set α | x ∈ box F A}, A\n\n/--\nAlternate notion of predicate lifting based on `box`.\nTaken from the QBNF paper\n-/\ndef liftp' {α} (x : F α) (p : α → Prop) : Prop :=\n∀ a ∈ supp' x, p a\n\nend box\n\nend qpf\n\n\nnamespace ex\n\n/-- polynomial functor isomorph to `α × _` for some `α` -/\ndef prod.pfunctor (α : Type) : pfunctor :=\n⟨ α, λ _, unit ⟩\n\ninstance {α} : qpf (prod α) :=\n{ P := prod.pfunctor α,\n  abs := λ β ⟨a,f⟩, (a, f ()),\n  repr := λ β ⟨x,y⟩, ⟨x, λ _, y⟩,\n  abs_repr := λ β ⟨x,y⟩, rfl,\n  abs_map := λ β γ f ⟨a,g⟩, rfl }\n\n/-- example relation for products -/\ndef foo.R (α : Type) (x y : bool × α) : Prop :=\nx.1 = y.1 ∧ (x.1 → x.2 = y.2)\n\nlemma equivalence_foo.R (α) : equivalence (foo.R α) :=\nbegin\n  refine ⟨_,_,_⟩,\n  { intro, exact ⟨rfl,λ _, rfl⟩ },\n  { intros x y h, refine ⟨h.1.symm, λ _, (h.2 _).symm⟩,\n    rwa h.1 },\n  { rintros x y z ⟨ha,ha'⟩ ⟨hb,hb'⟩,\n    refine ⟨ha.trans hb, λ hh, _⟩,\n    refine (ha' hh).trans (hb' _),\n    rwa ← ha }\nend\n\n/-- example of a qpf -/\ndef foo (α : Type) :=\nquot $ foo.R α\n\ninstance {α} [inhabited α] : inhabited (foo α) := ⟨ quot.mk _ (default _) ⟩\n\n/-- functor operation of `foo` -/\ndef foo.map {α β} (f : α → β) (x : foo α) : foo β :=\nquot.lift_on x (λ x : bool × α, quot.mk (foo.R β) $ f <$> x)\n  (λ ⟨a₀,a₁⟩ ⟨b₀,b₁⟩ h, quot.sound ⟨h.1,λ h', show f a₁ = f b₁, from congr_arg f (h.2 h')⟩)\n\ninstance : functor foo :=\n{ map := @foo.map }\n\n@[simp]\nlemma foo.map_mk {α β : Type} (f : α → β) (x : bool × α) :\n  (f <$> quot.mk _ x : foo β) = quot.mk _ (f <$> x) :=\nby simp [(<$>),foo.map]\n\nnoncomputable instance qpf.foo : qpf foo :=\n@qpf.quotient_qpf (prod bool) _ ex.prod.qpf foo _ (λ α, quot.mk _) (λ α, quot.out)\n  (by simp)\n  (by intros; simp)\n\n/-- constructor for `foo` -/\ndef foo.mk {α} (b : bool) (x : α) : foo α := quot.mk _ (b, x)\n\n@[simp]\nlemma foo.map_mk' {α β : Type} (f : α → β) (b : bool) (x : α) :\n  f <$> foo.mk b x = foo.mk b (f x) :=\nby simp only [foo.mk, foo.map_mk]; refl\n\n@[simp]\nlemma foo.map_tt {α : Type} (x y : α) :\n  foo.mk tt x = foo.mk tt y ↔ x = y :=\nby simp [foo.mk]; split; intro h; [replace h := quot.exact _ h, rw h];\n   rw relation.eqv_gen_iff_of_equivalence at h;\n   [exact h.2 rfl, apply equivalence_foo.R]\n\n/-- consequence of original definition of `supp`. If there exists more than\none value of type `α`, then the support of `foo.mk ff x` is empty -/\nlemma supp_mk_ff₀ {α} (x y : α) (h : ¬ x = y) : functor.supp (foo.mk ff x) = {} :=\nbegin\n  dsimp [functor.supp], ext z, simp, -- split; intro h,\n  classical, by_cases x = z,\n  { use (λ a, ¬ z = a), subst z,\n    dsimp [functor.liftp],\n    simp, refine ⟨foo.mk ff ⟨y,h⟩,_⟩,\n    simp, apply quot.sound, simp [foo.R] },\n  { use (λ a, x = a),\n    dsimp [functor.liftp],\n    simp [h], use foo.mk ff ⟨x,rfl⟩,\n    simp }\nend\n\n/-- consequence of original definition of `supp`. If there exists only\none value of type `α`, then the support of `foo.mk ff x` contains that value -/\nlemma supp_mk_ff₁ {α} (x : α) (h : ∀ z, x = z) : functor.supp (foo.mk ff x) = {x} :=\nbegin\n  dsimp [functor.supp], ext y, simp, split; intro h',\n  { apply @h' (= x), dsimp [functor.liftp],\n    use foo.mk ff ⟨x,rfl⟩, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with ⟨⟨z,z',hz⟩,hp⟩,\n    simp at hp, convert hz,\n    rw [h'], apply h },\nend\n\n/--\nSuch a QPF is not uniform\n-/\nlemma foo_not_uniform : ¬ @qpf.is_uniform foo _ qpf.foo :=\nbegin\n  simp only [qpf.is_uniform, foo, qpf.foo, set.image_univ, not_forall, not_imp],\n  existsi [bool,ff,ff,λ a : unit, tt,λ a : unit, ff], split,\n  { apply quot.sound, simp [foo.R, qpf.abs, prod.qpf._match_1] },\n  { simp! only [set.range, set.ext_iff],\n    simp only [not_exists, false_iff, bool.forall_bool, eq_self_iff_true, exists_false, not_true,\n      and_self, set.mem_set_of_eq, iff_false],\n    exact λ h, h () }\nend\n\n/-- intuitive consequence of original definition of `supp`. -/\nlemma supp_mk_tt {α} (x : α) : functor.supp (foo.mk tt x) = {x} :=\nbegin\n  dsimp [functor.supp], ext y, simp, split; intro h',\n  { apply @h' (= x), dsimp [functor.liftp],\n    use foo.mk tt ⟨x,rfl⟩, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with ⟨⟨z,z',hz⟩,hp⟩,\n    simp at hp, replace hp := quot.exact _ hp,\n    rw relation.eqv_gen_iff_of_equivalence (equivalence_foo.R _) at hp,\n    rcases hp with ⟨⟨⟩,hp⟩, subst y,\n    replace hp := hp rfl, cases hp,\n    exact hz }\nend\n\n/-- simple consequence of the definition of `supp` from the QBNF paper -/\nlemma supp_mk_ff' {α} (x : α) : qpf.supp' (foo.mk ff x) = {} :=\nbegin\n  dsimp [qpf.supp'], ext, simp, dsimp [qpf.box],\n  use ∅, simp [foo.mk], intros, apply quot.sound,\n  dsimp [foo.R], split, refl, rintro ⟨ ⟩\nend\n\n/-- simple consequence of the definition of `supp` from the QBNF paper -/\nlemma supp_mk_tt' {α} (x : α) : qpf.supp' (foo.mk tt x) = {x} :=\nbegin\n  dsimp [qpf.supp'], ext, simp, dsimp [qpf.box], split; intro h,\n  { specialize h {x} _,\n    { clear h, introv hfg, simp, rw hfg, simp },\n    { simp at h, assumption }, },\n  { introv hfg, subst x_1, classical,\n    let f : α → α ⊕ bool := λ x, if x ∈ i then sum.inl x else sum.inr tt,\n    let g : α → α ⊕ bool := λ x, if x ∈ i then sum.inl x else sum.inr ff,\n    specialize hfg _ f g _,\n    { intros, simp [*,f,g,if_pos] },\n    { simp [f,g] at hfg, split_ifs at hfg,\n      assumption, cases hfg } }\nend\nend ex\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/qpf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339676722393, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.491329313708686}}
{"text": "import tactic\nimport data.real.basic\n-- import data.set\n/-\n- nom des variables dans la def de limite !\n- variables muettes = variables globales : bof\n- calcul avec abs : abs (l'-l) /2 >0 ??\n(x ≠ 0 → |x| >0)\n- ne pas ajouter l'inégalité au contexte si elle y est déjà !\n- 'dsimp only at h' effectue les beta-réduction : (λ x, f x) 37 = f 37\n- max : def et propriétés\n- utiliser specialize ??\n\n-/\n\n\n-- dEAduction tactics\nimport structures2      -- hypo_analysis, targets_analysis\nimport utils            -- no_meta_vars\nimport user_notations   -- notations that can be used in deaduction UI for a new object\nimport compute\nimport push_neg_once    -- pushing negation just one step\n\n-- dEAduction definitions\nimport set_definitions\nimport real_definitions\n\n\n-- class real_number_subgroup (α : Type) := \n-- (subgroup : ((α = ℕ) ∨ (α = ℤ) ∨ (α = ℚ) ∨ (α = ℝ)) )\n\n-- lemma real_number_subgroup_nat : (nat = ℕ) ∨ (nat = ℤ) ∨ (nat = ℚ) ∨ (nat = ℝ) :=\n-- begin\n--   left, refl,\n-- end\n\n-- instance : real_number_subgroup nat := ⟨real_number_subgroup_nat⟩ \n\n\nlocal attribute [instance] classical.prop_decidable\n\n\n/-- `l` is the limit of the sequence `a` of reals -/\ndefinition limit (u : ℕ → ℝ) (l : ℝ) : Prop :=\n∀ ε > 0, ∃ N, ∀ n ≥ N, | u n - l | < ε\n\ndefinition converging_seq (u : ℕ → ℝ) : Prop :=\n∃ l, limit u l\n\ndefinition limit_plus_infinity (u : ℕ → ℝ) : Prop :=\n∀ M:ℝ, ∃ N:ℕ, ∀ n ≥ N, u n ≥ M\n\ndefinition increasing_seq (u : ℕ → ℝ) : Prop :=\n∀ p q , p ≤ q → u p ≤ u q\n\ndefinition bounded_above (u : ℕ → ℝ) : Prop :=\n∃ M:ℝ, ∀ n, u n ≤ M\n\ndefinition bounded_below (u : ℕ → ℝ) : Prop :=\n∃ m:ℝ, ∀ n, u n ≥ m\n\ndefinition bounded_sequence (u : ℕ → ℝ) : Prop :=\n∃ M>0, ∀ n, | u n | ≤ M\n\ndefinition even (n:ℕ) : Prop := ∃ n', n=2 * n'\n\ndefinition limit_function (f : ℝ → ℝ) (a : ℝ) (l : ℝ) : Prop :=\n∀ ε > 0, ∃ δ>0, ∀ x: ℝ, ( | x-a | < δ → | f x  - l | < ε )\n\ndefinition continuous_at (f : ℝ → ℝ) (a : ℝ) : Prop :=\nlimit_function (λ x, f x) a (f a)\n\ndefinition continuous (f: ℝ → ℝ) : Prop :=\n∀ a, continuous_at f a\n\ndefinition cauchy (u: ℕ → ℝ) : Prop :=\n∀ ε>0, ∃ N: ℕ, ∀ p≥N, ∀ q≥N, |u p - u q | < ε\n\ndefinition uniformly_continuous (f: ℝ → ℝ) : Prop :=\n∀ ε>0, ∃ δ>0, ∀ x y: ℝ,\n(|x - y| < δ → |f x - f y | < ε)\n\nsection course\nopen tactic.interactive\n-- notation `|` x `|` := abs x\n\n-----------------\n-- definitions --\n-----------------\nnamespace definitions\n/- dEAduction\nPrettyName\n  Définitions\n-/\n\n\nnamespace generalites\n/- dEAduction\nPrettyName\n  Généralités\n-/\n\n/-\nabs_pos : 0 < |a| ↔ a ≠ 0\nabs_mul x y : |x * y| = |x| * |y|\nabs_add x y : |x + y| ≤ |x| + |y|\n-/\n\n/-\nMax :\ndef\nmax ≥ n et n'\n1) We will be using `max` a lot in this workshop. `max A B` is\nthe max of `A` and `B`. `max` is a definition, not a theorem, so \nthat means that there will be an API associated with it, i.e. \na list of little theorems which make `max` possible to use.\nWe just saw the two important theorems which we'll be using:\n`le_max_left A B : A ≤ max A B` and\n`le_max-right A B : B ≤ max A B`.\nThere are other cool functions in the `max` API, for example\n`max_le : A ≤ C → B ≤ C → max A B ≤ C`. The easiest way to \nfind your way around the `max` API is to *guess* what the names\nof the theorems are! For example what do you think \n`max A B < C ↔ A < C ∧ B < C` is called?\n-/\n\n\n\n----------------------------------\nnamespace maximum\n-- The name RealSubGroup will be replaced by ℝ in d∃∀duction, \n-- but allows to treat the cases of integers or rationals.\nvariables {RealSubGroup : Type} [decidable_linear_order RealSubGroup] \n\nlemma theorem.ppe_max_gauche :\n∀ a b : RealSubGroup, a ≤ max a b :=\nbegin\n  -- targets_analysis,\n  intros a b,\n  -- hypo_analysis,\n  -- norm_num, tautology,\n  exact le_max_left a b,\n  -- todo\nend\n\nlemma theorem.ppe_max_droite :\n∀ a b : RealSubGroup,  b ≤ max a b :=\nbegin\n  have H := @theorem.ppe_max_gauche,\n  intros a b, norm_num, tautology,\n  -- exact le_max_right a b,\nend\n\nlemma theorem.max_ppe\n(a b c : RealSubGroup) (Ha: a ≤ c) (Hb: b ≤ c) :\nmax a b ≤ c :=\nbegin\n  norm_num, tautology,\n  -- exact max_le Ha Hb,\nend\n\nlemma theorem.max_pp\n(a b c : RealSubGroup) (Ha: a < c) (Hb: b < c) :\nmax a b < c :=\nbegin\n  norm_num, tautology,\n  -- exact max_lt Ha Hb,\nend\n\nend maximum\n\nnamespace valeur_absolue\nvariables {RealSubGroup : Type} [decidable_linear_ordered_comm_ring RealSubGroup] \n-- [has_zero RealSubGroup]\n\n-- A modifier : faire une classe \"nombres\" ?\nlemma theorem.valeur_absolue :\n∀ x : RealSubGroup,\n((0:RealSubGroup) ≤ x) → (abs x = x) and ((x ≤ 0) → (abs x = -x)) :=\nbegin\n  intro x, split, exact abs_of_nonneg, exact abs_of_nonpos,\nend\n\nlemma theorem.majoration_valeur_absolue :\n∀ x r : RealSubGroup, (abs x < r) ↔ ((-r < x) ∧ (x < r))\n:= \n/- dEAduction\nPrettyName\n  Majoration d'une valeur absolue\n-/\nbegin\n  intros x r,\n  exact abs_lt\nend\n\n\nlemma theorem.inegalite_triangulaire :\n∀ x y : RealSubGroup, |x + y| ≤ |x| + |y|\n:= \n/- dEAduction\nPrettyName\n  Inégalité triangulaire\n-/\nbegin\n  intros x y, exact abs_add x y \nend\n\nlemma theorem.valeur_absolue_produit :\n∀ x y : RealSubGroup,  |x * y| = |x| * |y|\n:= \n/- dEAduction\nPrettyName\n  Valeur absolue d'un produit\n-/\nbegin\n  intros x y, exact abs_mul x y \nend\n\nend valeur_absolue\n\nend generalites\nnamespace suites\n\n------------------------------\n-- Définitions de la limite --\n------------------------------\n\nlemma definition.limit \n{u : ℕ → ℝ} {l : ℝ} :\n(limit u l) ↔ \n∀ ε > 0, ∃ N, ∀ n ≥ N, | u n - l | < ε\n:= \n/- dEAduction\nPrettyName\n  Limite d'une suite\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.converging_seq\n{u : ℕ → ℝ} :\n(converging_seq u) ↔ \n∃ l, limit u l\n:= \n/- dEAduction\nPrettyName\n  Suite convergente\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.limit_plus_infinity\n{u : ℕ → ℝ} :\n(limit_plus_infinity u) ↔ ∀ M:ℝ, ∃ N:ℕ, ∀ n ≥ N, u n ≥ M := \n/- dEAduction\nPrettyName\n  Limite infinie d'une suite\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.increasing_seq\n{u : ℕ → ℝ} :\n(increasing_seq u) ↔ \n∀ p q, p ≤ q → u p ≤ u q\n:= \n/- dEAduction\nPrettyName\n  Suite croissante\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.bounded_above \n{u : ℕ → ℝ} :\n(bounded_above u) ↔ \n∃ M:ℝ, ∀ n,  u n ≤ M\n:= \n/- dEAduction\nPrettyName\n  Suite majorée\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\n-- lemma definition.bounded_below \n-- {u : ℕ → ℝ} :\n-- (bounded_below_sequence u) ↔ \n-- ∃ M:ℝ, ∀ n,  u n ≥ M\n-- := \n-- /- dEAduction\n-- PrettyName\n--   Suite minorée\n-- ImplicitUse\n--   True\n-- -/\n-- begin\n--   refl\n-- end\n\nlemma definition.bounded \n{u : ℕ → ℝ} :\n(bounded_sequence u) ↔ \n∃ M>0, ∀ n, | u n | ≤ M\n:= \n/- dEAduction\nPrettyName\n  Suite bornée\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nend suites\n\nnamespace fonctions\n\nlemma definition.composition {X Y Z: Type} {f: X → Y} {g:Y → Z} {x:X}:\nset.composition g f x = g (f x)\n:=\nbegin\n    todo,\nend\n\nlemma definition.limit_function (f : ℝ → ℝ) (a : ℝ) (l : ℝ) : \nlimit_function f a l ↔ \n( ∀ ε > 0, ∃ δ>0, ∀ x: ℝ, ( | x-a | < δ → | f x  - l | < ε ) ):=\n/- dEAduction\nPrettyName\n  Limite d'une fonction\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.continuous_at (f : ℝ → ℝ) (a : ℝ) :\n(continuous_at f a) ↔ (limit_function f a (f a)) :=\n/- dEAduction\nPrettyName\n  Continuité en un point\n-/\nbegin\n  refl\nend\n\nlemma definition.continuous (f: ℝ → ℝ) :\n(continuous f) ↔ ∀ a, continuous_at f a :=\n/- dEAduction\nPrettyName\n  Continuité\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\n\nend fonctions\n\nend definitions\n\n-----------------\n--  exercices  --\n-----------------\nnamespace exercices_suites_I\n/- dEAduction\nPrettyName\n  Exercices sur les suites I\n-/\n\n-- open definitions\n\n-- --------------------------------------------------\n-- namespace exemples\n\n\n-- end exemples\n\nlemma exercise.limit_constante \n(u : ℕ → ℝ) (c : ℝ) (H : ∀ n, u n = c) :\nconverging_seq u :=\n/- dEAduction\nPrettyName\n  La limite d'une suite constante !\nDescription\n  Dans ce premier exercice,\n  il s'agit de démontrer, dans un cas très simple,\n  l'existence d'une limite.\n-/\nbegin\n--   rw definition.limit,\n--   intros ε Hε,\n--   use 0,\n--   intros n H1,\n--   rw H,\n-- `[ solve1 {norm_num at * }, trace \"EFFECTIVE CODE n°4.0\"] <|> `[ `[ norm_num at *, trace \"EFFECTIVE CODE n°5.0\"] <|> `[ skip, trace \"EFFECTIVE CODE n°5.1\"], compute_n 10, trace \"EFFECTIVE CODE n°4.1\"],\n  todo,\nend\n\nlemma exercise.croissante_non_majoree\n(u: ℕ → ℝ) (H1: increasing_seq u) (H2: not (bounded_above u)) :\nlimit_plus_infinity u :=\n/- dEAduction\nPrettyName\n  Une suite croissante non majorée tend vers plus l'infini\nDescription\n  Dans ce deuxième exercice,\n  il s'agit à nouveau de démontrer une limite, mais infinie.\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.limite_positive\n(u : ℕ → ℝ) (l : ℝ) (H : limit u l)\n(H' : l >0) :\n∃ N, ∀ n ≥ N, u n > 0\n:=\n/- dEAduction\nPrettyName\n  Suite dont la limite est strictement positive\nDescription\n  Dans ce troisième exercice,\n  il s'agit d'utiliser une hypothèse de limite.\n-/\nbegin\n  -- have W := exercise.limit_constante,\n  -- hypo_analysis,\n  todo,\nend\n\n\nlemma exercise.limite_inegalites\n(u v: ℕ → ℝ) (l l' : ℝ) (H : limit u l)\n(H' : limit v l'):\n(∀n, u n ≤ v n ) → l ≤ l'\n:=\n/- dEAduction\nPrettyName\n  Passage à la limite dans une inégalité (*)\nDescription\n  Comment démarrer ??\n  Comment avoir un epsilon pertinent auquel appliquer nos\n  définitions de limites ?...\n-/\nbegin\n  todo,\n  -- contrapose H'' with H1,\n  -- push_neg,\n  -- push_neg at H1,\n  -- let e := (l-l')/2, have H2 : e = (l-l')/2, refl, no_meta_vars,\n  -- rw limit at H H',\n  -- have H3: (e:ℝ) > 0, rotate, have H4 := H e H3, rotate 1, rotate, rotate,\n  -- solve1 {norm_num at *, apply mul_pos, linarith only [H1], apply inv_pos.mpr, linarith},\n  -- have H5 := H' e H3,\n  -- cases H4 with n H6,\n  -- cases H5 with n' H7,\n  -- let n'' := max n n', have H8 : n'' = max n n', refl, no_meta_vars,\n  -- have H9: (n'':ℕ) ≥ n, rotate, have H10 := H6 n'' H9, rotate 1, solve1 {norm_num at *, tautology }, rotate,\n  -- have H11: (n'':ℕ) ≥ n', rotate, have H12 := H7 n'' H11, rotate 1, solve1 {norm_num at *, tautology }, rotate,\n  -- use n'',\n  -- rw generalites.valeur_absolue.theorem.majoration_valeur_absolue at H10,\n  -- cases H10 with H14 H15,\n  -- rw generalites.valeur_absolue.theorem.majoration_valeur_absolue at H12,\n  -- cases H12 with H17 H18,\n  -- linarith only [H18, H14, H2],\nend\n\nend exercices_suites_I\n\n\n\nnamespace exercices_suites_II\n/- dEAduction\nPrettyName\n  Exercices sur les suites II\n-/\n\nlemma exercise.couper_epsilon_en_deux\n(u : ℕ → ℝ) (l : ℝ) :\n(limit u l) ↔ \n∀ ε > 0, ∃ N, ∀ n ≥ N, | u n - l | < 2*ε\n:=\n/- dEAduction\nPrettyName\n  Couper les epsilons en deux\nDescription\n  Nous avons maintenant une limite dans les hypothèses,\n  et une limite dans la conclusion !\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.couper_epsilon_en_100\n(u : ℕ → ℝ) (l : ℝ) :\n(limit u l) ↔ \n∀ ε > 0, ∃ N, ∀ n ≥ N, | u n - l | < 100*ε\n:=\n/- dEAduction\nPrettyName\n  Couper les epsilons en cent !\nDescription\n  Simple variante du précédent,\n  pour voir si vous avez compris...\n-/\nbegin\n  todo,\nend\n\nlemma exercise.limite_somme\n(u v: ℕ → ℝ) (l l' : ℝ) (H : limit u l)\n(H' : limit v l') :\nlimit (λn, u n + v n) (l+l')\n:=\n/- dEAduction\nPrettyName\n  Limite d'une somme\nDescription\n  Aide : il peut être judicieux d'utiliser le résultat\n  d'un exercice précédent...\n-/\nbegin\n--   rw definitions.definition.limit,\n-- rw definitions.definition.limit at H H',\n-- intro ε, intro H1,\n-- have H2 := H _ H1,\n-- have H3 := H' _ H1,\n-- cases H2 with n H4,\n-- cases H3 with n' H5,\n-- let x2 := max n n', have H7 : x2 = max n n', refl,\n-- have H9 := @definitions.maximum.theorem.ppe_max_gauche,\n-- have H10 := H9 n n',\n-- -- norm_num at H10,\n-- rw H7 at H10,\n  todo,\n  -- rw limit,\n  -- intro ε, intro H1,\n  -- rw limit at H H',\n  -- have H2: ((ε/2):ℝ) > 0, rotate, have H3 := H (ε/2) H2, rotate 1, solve1 {linarith only [H1] }, rotate,\n  -- have H4: ((ε/2):ℝ) > 0, rotate, have H5 := H' (ε/2) H4, rotate 1, solve1 {assumption}, rotate,\n  -- cases H3 with n H6,\n  -- cases H5 with n' H7,\n  -- use max n n',\n  -- intro n'', intro H8,\n  -- have H9: (n'':ℕ) ≥ n, rotate, have H10 := H6 n'' H9, rotate 1, solve1 {norm_num at *, tautology }, rotate,\n  -- have H11: (n'':ℕ) ≥ n', rotate, have H12 := H7 n'' H11, rotate 1, solve1 {norm_num at *, tautology }, rotate,\n  \n  -- rw generalites.valeur_absolue.theorem.majoration_valeur_absolue at H10 H12,\n  -- rw generalites.valeur_absolue.theorem.majoration_valeur_absolue,\n  -- cases H12 with Ha Hb, cases H10 with Hc Hd,\n  -- split,\n  -- linarith only [Ha, Hc],\n  -- linarith only [Hb, Hc, Hd],\nend\n\nlemma exercise.limite_unique\n(u : ℕ → ℝ) (l : ℝ)(l' : ℝ) (H : limit u l) (H' : limit u l') :\nl = l' \n:=\n/- dEAduction\nPrettyName\n  (*) Unicité de la limite\n-/\nbegin\n  -- by_contradiction,\n  -- wlog Hll': l < l',\n  -- -- exact lt_or_gt_of_ne a,\n  -- rotate,\n  -- set ε := (l'-l)/2 with Heps,\n  -- have Hpos: ε >0, rotate, -- by compute1,\n  -- specialize H ε Hpos, rotate 2,\n  -- rotate,\n  \n  -- cases H with N1,\n  -- specialize H' ε Hpos, cases H' with N2,\n  -- set n := max N1 N2 with Hn,\n  -- have HnsuppN1: n ≥ N1, from le_max_left N1 N2,\n  -- have ineq1 := H_h n HnsuppN1,\n  -- have HnsuppN2: n ≥ N2, from le_max_right N1 N2,\n  -- have ineq1 := H'_h n HnsuppN2,\n\n  -- -- sorry,  \n  -- todo,\n  -- todo,\n  todo,\nend\n\n\nlemma exercise.gendarmes\n(u v w  : ℕ → ℝ) (l : ℝ) \n(H : limit u l) (H' : limit w l)\n(H'' : ∀n, (((u n) ≤ v n) and ((v n) ≤ w n))) :\nlimit v l\n:=\n/- dEAduction\nPrettyName\n  (**) Théorème des gendarmes\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.borne_fois_zero\n(u v: ℕ → ℝ) (H : limit u 0)\n(H' : bounded_sequence v) :\nlimit (λn, (u n) * (v n)) 0\n:=\n/- dEAduction\nPrettyName\n  (**) Limite d'un produit (cas particulier)\n-/\nbegin\n  todo,\nend\n\n\n/-\nA essayer : appliquer somme, CV implique borné, borné x 0\n-/\nlemma limite_produit\n(u u': ℕ → ℝ) (l l' : ℝ) (H : limit u l)\n(H' : limit u' l') :\nlimit (λn, (u n) * (u' n)) (l*l')\n:=\nbegin\n  todo,\nend\n\nend exercices_suites_II\n\nnamespace exercices_fonctions\n/- dEAduction\nPrettyName\n  Exercices sur les fonctions\n-/\n\nopen definitions\n\nopen set\n\nlemma exercise.limite_positive\n(f: ℝ → ℝ)\n(H0: continuous f) (H1: f(0) = 1):\n∃ δ>(0:ℝ), ∀ x, |x| < δ → f(x) >0 :=\n/- dEAduction\nPrettyName\n  Limite positive\nDescription\n  Deux limites en hypothèse, une en conclusion...\n-/\nbegin\n  todo,\n  -- have H2 := (H0 0) 1 _,\n  -- rcases H2 with ⟨δ, H3, H4⟩,\n  -- norm_num at H4,\n  -- rw H1 at H4,\n  -- use δ, split, rotate,\n  -- intros x x_del,\n  -- have H5 := H4 _ x_del,\n  -- rw generalites.valeur_absolue.theorem.majoration_valeur_absolue at *,\n  -- cases H5 with H5a H5b,\n  -- linarith only [H5a], linarith, assumption,\nend\n\nlemma exercise.composition_limite_fonction\n(f: ℝ → ℝ) (g: ℝ → ℝ) (a b c : ℝ)\n(H0: limit_function (λ x, f x) a b)\n(H1: limit_function (λ y, g y) b c):\nlimit_function (λ x, g ( f ( x)) ) a c :=\n/- dEAduction\nPrettyName\n  Limite et composition\nDescription\n  Deux limites en hypothèse, une en conclusion...\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.composition_continuite (f: ℝ → ℝ) (g: ℝ → ℝ)\n(H: continuous f) (H': continuous g):\ncontinuous (composition g f) :=\n/- dEAduction\nPrettyName\n  Continuité et composition\n-/\nbegin \n  todo,\nend\n\n\nlemma exercise.image_convergente (u: ℕ → ℝ) (l : ℝ) (f: ℝ → ℝ)\n(H: limit u l) (H': continuous f):\nlimit (λ n, f (u n)) (f l) :=\n/- dEAduction\nPrettyName\n  Image d'une suite convergente\nDescription\n  Deux limites en hypothèse, une en conclusion...\n-/\nbegin \n  todo,\nend\n\nend exercices_fonctions\n\n\n\nnamespace suites_de_Cauchy\n/- dEAduction\nPrettyName\n  Suites de Cauchy\n-/\n\n-- open definitions\n\nlemma definition.suite_de_cauchy\n(u: ℕ → ℝ) :\ncauchy u ↔ ∀ ε>0, ∃ N: ℕ, ∀ p≥N, ∀ q≥N, |u p - u q | < ε\n:=\n/- dEAduction\nPrettyName\n  Suites de Cauchy\nImplicitUse\n  True\n-/\nbegin\n  refl,\nend\n\n-- definition increasing (k: ℕ → ℕ) : Prop := \n-- ∀ n, (k n) > (k (n+1)) \n\n-- definition limit_value (u: ℕ → ℝ) (a: ℝ) : Prop :=\n-- ∃ k: ℕ → ℕ, increasing k ∧ limit (λ n, (u (k n))) a\n\n-- lemma definition.increasing (k: ℕ → ℕ): (increasing k) ↔\n-- ∀ n, (k n) > (k (n+1)) :=\n-- begin\n--   refl,\n-- end\n\n-- lemma theorem.increasing_limit (k: ℕ → ℕ) (H: increasing k):\n-- limit_plus_infinity (coe k) :=\n-- begin\n--   todo,\n-- end\n\n-- lemma definition.limit_value (u: ℕ → ℝ) (a: ℝ) :\n-- limit_value u a ↔\n-- ∃ k: ℕ → ℕ, increasing k ∧ limit (λ n, (u (k n))) a :=\n-- begin\n--   refl,\n-- end\n\n-- lemma exercise.limit_limit_value\n--  (u: ℕ → ℝ) (a b: ℝ) (H1: limit u a) (H2: limit_value u b) :\n--  b = a :=\n-- /- dEAduction\n-- PrettyName\n--   Une suite convergence a une unique valeur d'adhérence\n-- -/\n-- begin\n--   todo,\n-- end\n\nlemma exercise.convergente_implique_cauchy (u: ℕ → ℝ): \nconverging_seq u → cauchy u :=\n/- dEAduction\nPrettyName\n  Une suite convergente est de Cauchy\n-/\nbegin\n  todo,\n  -- intro H,\n  -- rw converging_seq at H, cases H with x H,\n  -- have H := limit (λ n, (u n)^2)  (x^2)\nend\n\n-- lemma theorem.cauchy_bounded (u: ℕ → ℝ): \n-- cauchy u → bounded_sequence u :=\n-- /- dEAduction\n-- PrettyName\n--   Une suite de Cauchy est bornée\n-- -/\n-- begin\n--   todo,\n-- end\n\n-- lemma theorem.bounded_limit_value (u: ℕ → ℝ): \n-- bounded_sequence u → ∃ a, limit_value u a :=\n-- /- dEAduction\n-- PrettyName\n--   Une suite bornée a une valeur d'adhérence\n-- -/\n-- begin\n--   todo,\n-- end\n\n-- lemma exercise.limit_value_cauchy_converge (u: ℕ → ℝ)\n-- (H1: cauchy u) (H2: ∃ a, limit_value u a) :\n-- converging_seq u  :=\n-- /- dEAduction\n-- PrettyName\n--   Une suite de Cauchy ayant une valeur d'adhérence converge\n-- -/\n-- begin\n--   todo,\n-- end\n\n-- lemma exercise.cauchy_converge (u: ℕ → ℝ)\n-- (H1: cauchy u):\n-- converging_seq u  :=\n-- /- dEAduction\n-- PrettyName\n--   Toute suite de Cauchy converge\n-- -/\n-- begin\n--   todo,\n-- end\n\nend suites_de_Cauchy\n\n\nnamespace continuite_uniforme\n/- dEAduction\nPrettyName\n  Continuité uniforme\n-/\n\nlemma definition.uniformly_continuous\n(f: ℝ → ℝ) : uniformly_continuous f ↔\n∀ ε>0, ∃ δ>0, ∀ x y: ℝ,\n(|x - y| < δ → |f x - f y | < ε)\n:=\n/- dEAduction\nPrettyName\n  Continuité uniforme\nImplicitUse\n  True\n-/\nbegin\n  refl,\nend\n\nlemma exercise.continue_de_uniformement_continue\n(f: ℝ → ℝ) (H0: uniformly_continuous f):\ncontinuous f :=\n/- dEAduction\nPrettyName\n  Uniformément continu implique continu\n-/\nbegin\n  todo,\nend\n\nlemma exercise.cauchy_uniformement_continue\n(u: ℕ → ℝ) (f: ℝ → ℝ)\n(H0: cauchy u) (H1: uniformly_continuous f):\ncauchy (λ n:ℕ, f (u n))\n:=\n/- dEAduction\nPrettyName\n  Image d'une suite de Cauchy\n-/\nbegin\n  todo,\nend\n\n-- TODO: cauchy => bornée, bornée => valeur d'adh,\n-- Cauchy + va => cv\n\nend continuite_uniforme\n\n-- namespace DL\n-- /- dEAduction\n-- PrettyName\n--   Développements limités\n-- -/\n\n-- definition DL_order_0 (f: ℝ → ℝ) : Prop :=\n-- ∃ (φ : ℝ → ℝ), (limit_function φ 0 0) and \n-- (∀ h, f h = f 0 + φ h)\n\n-- definition DL_order_1 (f: ℝ → ℝ) (a : ℝ) : Prop :=\n-- ∃ (φ : ℝ → ℝ), (limit_function φ 0 0) and \n-- (∀ h, f h = f 0 + a * h + (φ h) * h)\n\n-- lemma definition.DL_order_0\n-- (f: ℝ → ℝ) (a : ℝ):\n-- (DL_order_0 f) ↔ (∃ (φ : ℝ → ℝ), (limit_function φ 0 0) and \n-- (∀ h, f h = f 0 + φ h))\n-- :=\n-- begin\n--   todo\n-- end\n\n-- example \n-- (f: ℝ → ℝ):\n-- (DL_order_0 f) ↔ ∃ l, (limit_function f 0 l) :=\n-- begin\n--   todo\n-- end\n-- end DL\n\n\n/- \nOn peut multiplier les variantes : si une fonction a une\nlimite >0 en un point, elle est >0 au voisinage.\nSi lim f < lim g alors f < g au voisinage.\n\nSigne à partir d'un DL !\n\n-/\n\n\nend course", "meta": {"author": "dEAduction", "repo": "dEAduction-lean", "sha": "4fe1d642078fc94f9081ccbed08e047e86a741fd", "save_path": "github-repos/lean/dEAduction-dEAduction-lean", "path": "github-repos/lean/dEAduction-dEAduction-lean/dEAduction-lean-4fe1d642078fc94f9081ccbed08e047e86a741fd/src/exercises_deaduction_synchro/experimental/exercices_limite_continuite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.49127097586403295}}
{"text": "/-\nCopyright © 2018 François G. Dorais. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n-/\n\nimport .basic .cons .append\n\nnamespace tup\nvariable {α : Type*}\n\n@[reducible]\ndefinition bar (f : ℕ → α) (n : ℕ) : fin n → α\n| ⟨i,_⟩ := f i\n\n@[simp]\nlemma bar_val (f : ℕ → α) {n : ℕ} : \n∀ i, (bar f n)[i] = f i.val\n| ⟨_,_⟩ := rfl\n\nlemma take_bar (f : ℕ → α) {m n : ℕ} (h : m ≤ n) :\ntake h (bar f n) = bar f m :=\ntup.ext (λ _, by simp)\n\ndefinition extend {n : ℕ} (xs : α ^ n) (x : α) (i : ℕ) : α :=\nif h : i < n then xs[⟨i,h⟩] else x\n\nlemma extend_of_lt {n : ℕ} {xs : α ^ n} {x : α} {i : ℕ} (h : i < n) :\nextend xs x i = xs[⟨i,h⟩] := dif_pos h\n\nlemma extend_of_ge {n : ℕ} {xs : α ^ n} {x : α} {i : ℕ} (h : i ≥ n) :\nextend xs x i = x := dif_neg (not_lt_of_ge h)\n\nlemma bar_extend {n : ℕ} {xs : α ^ n} {x : α} :\nbar (extend xs x) n = xs :=\next (λ ⟨i,h⟩, extend_of_lt h)\n\nend tup", "meta": {"author": "fgdorais", "repo": "tup", "sha": "ac4a2f8ca2ccc8aea091498439a0a47d43ac4700", "save_path": "github-repos/lean/fgdorais-tup", "path": "github-repos/lean/fgdorais-tup/tup-ac4a2f8ca2ccc8aea091498439a0a47d43ac4700/src/tup/bar.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.491270963429352}}
{"text": "import Rings.Rings\nimport Rings.Fields\n\n-- import data.polynomial.eval\n-- import data.mv_polynomial\n\nnamespace AxGroth\n\nnoncomputable theory\n\nuniverse u\n\n@[simp] def poly_map_data (K : Type) [comm_semiring K] (n : ℕ) : Type :=\nfin n → mv_polynomial (fin n) K\n\ndef poly_map {K : Type} [comm_semiring K] {n : ℕ} :\n  poly_map_data K n → (fin n → K) → (fin n → K) :=\nλ ps as k, mv_polynomial.eval as (ps k)\n\nopen fol\nopen Rings\n\n/-\n-- takes x : A and for each xs : fin n → A appends x at the end,\n-- then take the image\ndef image_append {A : Type u} [decidable_eq A] {n} :\n  A → finset (fin n → A) → finset (fin n.succ → A) :=\nλ x, finset.image (λ xs k, dite (↑k < n) (λ h, xs ⟨ k , h ⟩) (λ _ , x))\n-/\n\ndef list_image_append {A : Type u} [decidable_eq A] {n} :\n  A → list (fin n → A) → list (fin n.succ → A) :=\nλ x, list.map (λ xs k, dite (↑k < n) (λ h, xs ⟨ k , h ⟩) (λ _ , x))\n\n/-\ndef homog_basis (n d : ℕ) : set (fin n → ℕ) :=\n{ f | finset.sum (finset.range n) (λ k, dite (k < n) (λ h, f ⟨ k , h ⟩) (λ h, 0)) = d }\n\n-- #check finset.sum_fin_eq_sum_range\ndef homog_basis' (n d : ℕ) : set (fin n → ℕ) :=\n{ f | finset.univ.sum (λ (k : fin n), f k) = d }\n-/\n\n/-\n-- takes number of variables n and degree d and returns finite set\n-- {f : fin n → ℕ | Σᵢ f i = d}\n-- for each i : fin n, we read (f i) as the degree of the variable xᵢ\n-- hence each f represents a monomial of degree d\ndef homog_basis'' : Π (n d : ℕ), finset (fin n → ℕ)\n| 0 d := {fin_zero_elim}\n| 1 d := {λ k, d}\n| (n + 2) 0 := {λ k, 0}\n| (n + 2) (d + 1) :=\n  finset.bUnion (finset.range (d + 2)) (λ i, image_append i (homog_basis'' (n + 1) (d + 1 - i)))\n-/\n\n-- takes number of variables n and degree d and returns list representing the set\n-- {f : fin n → ℕ | Σᵢ f i = d}\n-- for each i : fin n, we read (f i) as the degree of the variable xᵢ\n-- hence each f represents a monomial of degree d\n\n/-- lists all n-variable monomials of degree d -/\n@[simp] def homog_basis_list : Π (n d : ℕ), list (fin n → ℕ)\n| 0 d := [fin_zero_elim]\n| 1 d := [λ k, d]\n| (n + 2) 0 := [λ k, 0]\n| (n + 2) (d + 1) := list.join $ list.of_fn $\n  λ i : fin (d + 2), list_image_append i (homog_basis_list (n + 1) (d + 1 - i))\n\n/-- lists all n-variable monomials of degree < d -/\n@[simp] def n_var_monomials_of_deg (n d : ℕ) : list (fin n → ℕ) :=\nnat.natlist d (λ d', homog_basis_list n d')\n\n-- counts all n-variable monomials of degree < d\n@[simp] def n_var_monomials_of_deg_lt (n d : ℕ) : ℕ :=\nlist.length $ homog_basis_list n d\n-- def n_var_monomials_of_deg_lt (n d : ℕ) : ℕ :=\n-- finset.sum (finset.range d) (λ d', list.length $ homog_basis_list n d')\n\n/-\ndef homog_dim'' (n d : ℕ) : ℕ := finset.card (homog_basis'' n d)\n\n@[simp] def homog_dim : Π (n d : ℕ), ℕ\n| 0 d := 0\n| 1 d := 1\n| (n + 2) 0 := 1\n| (n + 2) (d + 1) :=\n  finset.sum (finset.range (d + 2)) (λ i, homog_dim (n + 1) (d + 1 - i))\n-/\n\n/-\nsection\n\nlocal attribute [instance] classical.prop_decidable\n\n-- set of monomials (in n variables) of degree d.\ndef homog_basis''' (n d : ℕ) : finset (mv_polynomial (fin n) ℤ) :=\n@finset.image (fin n → ℕ) (mv_polynomial (fin n) ℤ) _\n  (λ ms : fin n → ℕ, big_mul (λ k : fin n, mv_polynomial.X k))\n  (homog_basis'' n d)\n\n-- set of monomials (in n variables) of degree < d\ndef monomials_of_bounded_degree'\n  (n d : ℕ) : finset (mv_polynomial (fin n) ℤ) :=\nfinset.bUnion (finset.range d) (λ d', homog_basis''' n d')\n\n-- indexing the set of monomials (in n variables) of degree at most d.\ndef monomials_of_bounded_degree (n d : ℕ) : ℕ :=\nfinset.card (monomials_of_bounded_degree' n d)\n\nend\n-/\n\n-- TRIED LIST INSTEAD BECAUSE bounded_ring_term NOT COMMUTATIVE\n-- def homog_poly_indexed_by_monos {n d : ℕ} (i : ℕ) :\n--   bounded_ring_term (n * monomials_of_bounded_degree n d + 2 * n) :=\n-- finset.sum (homog_basis'' n d)\n--   (λ p, big_mul (λ j : fin n, x_ ⟨ j , _ ⟩))\n\n#eval list.index_of 5 ([1,2])\n\n#check list.mem_nil_iff\n\n\nsection\n\nlocal attribute [instance] classical.prop_decidable\n\nnamespace list\n\ndef fin_index_of {α : Type u} (a : α) : Π (l : list α), (a ∈ l) → fin (list.length l)\n| [] h :=\nbegin\n  exfalso,\n  rw ← list.mem_nil_iff a,\n  apply h,\nend\n| (hd :: l) h := ⟨ list.index_of a (hd :: l) , begin rw list.index_of_lt_length, apply h end ⟩\n\n-- λ a f, ⟨ list.index_of a f , (by rw list.index_of_lt_length; simp) ⟩\n\nend list\n\n-- #check nat.succ_le\n\n-- def lemma_idk {α : Type u} {n d : ℕ} (l : list α) (x : ℕ) :\n--  x\n--  ≤ (n.succ * x + 2 * n.succ) :=\n-- begin\n--   induction n,\n--   {\n--     induction x with x hx,\n--     {simp},\n--     have hx' := nat.succ_le_succ hx,\n--     apply nat.le_trans hx',\n--     simp,\n\n--   },\n--   sorry\n\n\n\n\n-- end\n\n\n\n-- ∑ {f ∈ n_var_monomials_of_deg n.succ d} x₍ⱼ₊ₛ₎ ∏ {0 ≤ i < n} x₍ᵢ₊ₚ₎ᶠ⁽ⁱ⁾ in \"context c\"\n-- where j is the index of f in n_var_monomials_of_deg n.succ d\ndef poly_indexed_by_monos (n d s p c : ℕ) (h : 0 < c) :\n  bounded_ring_term c :=\n-- sum indexed by the n-variable monomials of degree < d\nlist.sum\n(list.map\n  (λ f : (fin n.succ → ℕ),\n    (x_ ⟨ (list.index_of f (n_var_monomials_of_deg n.succ d) + s) % c , nat.mod_lt _ h ⟩)\n    *\n    (nat.prod n.succ $ λ i, (x_ ⟨ (i + p) % c , nat.mod_lt _ h ⟩) ^ (f i) )\n    )\n(n_var_monomials_of_deg n.succ d))\n\n-- NOTE s = 2 * n.succ\n-- NOTE c = n.succ * n_var_monomials_of_deg_lt n.succ d + 2 * n.succ\n\nend\n\n-- finset.sum (homog_basis'' n d)\n--  (λ p, big_mul (λ j : fin n, x_ ⟨ j , _ ⟩))\n\nlemma inj_formula_aux {n d : ℕ} :\n  0 < n.succ * n_var_monomials_of_deg_lt n.succ d + 2 * n.succ :=\nbegin\n  apply nat.lt_add_left 0 (2 * n.succ) _ ,\n  simp,\nend\n\nlemma inj_formula_aux' {n d : ℕ} :\n  0 < n.succ * n_var_monomials_of_deg_lt n.succ d + n.succ + n.succ :=\nbegin\n  apply nat.lt_add_left 0 (n.succ) _ ,\n  simp,\nend\n\n-- in the context of having n.succ polynomials pⱼ indexed by\n-- their monomial coefficients,\n-- if for all xᵢ and all yᵢ, every polynomial satisfies pⱼ xᵢ = pⱼ yᵢ\n-- then each xᵢ = yᵢ.\n-- This says the polynomial map formed by the pⱼs is injective\ndef inj_formula (n d : ℕ) :\n  bounded_ring_formula (n.succ * (n_var_monomials_of_deg_lt n.succ d)) :=\nlet c := n.succ * (n_var_monomials_of_deg_lt n.succ d) + 2 * n.succ,\n    monom := n_var_monomials_of_deg_lt n.succ d in\n-- for all pairs in the domain x₋ ∈ Kⁿ⁺¹ and y₋ ∈ Kⁿ⁺¹\nbd_alls' (2 * n.succ) _\n$\n-- if at each pⱼ\n(bd_big_and n.succ\n-- pⱼ xᵢ = pⱼ yᵢ\n  (λ j,\n    (poly_indexed_by_monos n.succ d (2 * n.succ + j * monom) 0 _ inj_formula_aux)\n    ≃\n    (poly_indexed_by_monos n.succ d (2 * n.succ + j * monom) (n.succ) _ inj_formula_aux)\n  )\n)\n-- then\n⟹\n-- at each 0 ≤ i < n.succ,\n(bd_big_and n.succ $\n-- xᵢ = yᵢ (where yᵢ is written as xᵢ₊ₙ₊₁)\n  λ i, x_ ⟨ i % c , nat.mod_lt _ inj_formula_aux ⟩\n  ≃\n  x_ ⟨ (i + n.succ) % c , nat.mod_lt _ inj_formula_aux ⟩\n)\n\ndef surj_formula (n d : ℕ) :\n  bounded_ring_formula (n.succ * n_var_monomials_of_deg_lt n.succ d) :=\nlet monom := n_var_monomials_of_deg_lt n.succ d in\n-- for all z₋ ∈ Kⁿ⁺¹ in the codomain\nbd_alls' n.succ _\n$\n-- there exists x₋ ∈ Kⁿ⁺¹ in the domain such that\nbd_exs' n.succ _\n$\n-- at each 0 ≤ j < n.succ\nbd_big_and n.succ\n$\n-- zⱼ = pⱼ x₋\nλ j, x_ j ≃ poly_indexed_by_monos n.succ d (n.succ + n.succ + j * monom) 0 _ inj_formula_aux'\n\ndef Ax_Groth_Formula {n d : ℕ} : sentence ring_signature :=\n-- quantify over (n.succ) many (n.succ-variable polynomials) called ps;\n-- i.e. the data of a polynomial map\n-- by quantifying over (n.succ * monomials_of_bounded_degree) monomial coefficients\nbd_alls (n.succ * (n_var_monomials_of_deg_lt n.succ d))\n-- if the polynomial function is injective then it is surjective\n$ inj_formula n d ⟹ surj_formula n d\n\n\n\n\ntheorem Ax_Grothendieck {K : Type} [field K] [is_alg_closed K]\n  (h0 : char_zero K) {n : ℕ}\n  (ps : poly_map_data K n) (hinj : function.injective (poly_map ps)) :\n  function.surjective (poly_map ps) := sorry\n\n\n\nend AxGroth\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/AxGroth21Oct.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.6584175005616829, "lm_q1q2_score": 0.4912709634293519}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nType of functions with finite support.\n\nFunctions with finite support provide the basis for the following concrete instances:\n\n * ℕ →₀ α: Polynomials (where α is a ring)\n * (σ →₀ ℕ) →₀ α: Multivariate Polynomials (again α is a ring, and σ are variable names)\n * α →₀ ℕ: Multisets\n * α →₀ ℤ: Abelian groups freely generated by α\n * β →₀ α: Linear combinations over β where α is the scalar ring\n\nMost of the theory assumes that the range is a commutative monoid. This gives us the big sum\noperator as a powerful way to construct `finsupp` elements.\n\nA general advice is to not use α →₀ β directly, as the type class setup might not be fitting.\nThe best is to define a copy and select the instances best suited.\n\n-/\nimport data.finset data.set.finite algebra.big_operators algebra.module\nopen finset\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} {ι : Type*}\n  {α₁ : Type*} {α₂ : Type*} {β₁ : Type*} {β₂ : Type*}\n\nreserve infix ` →₀ `:25\n\n/-- `finsupp α β`, denoted `α →₀ β`, is the type of functions `f : α → β` such that\n  `f x = 0` for all but finitely many `x`. -/\nstructure finsupp (α : Type*) (β : Type*) [has_zero β] :=\n(support            : finset α)\n(to_fun             : α → β)\n(mem_support_to_fun : ∀a, a ∈ support ↔ to_fun a ≠ 0)\n\ninfix →₀ := finsupp\n\nnamespace finsupp\n\nsection basic\nvariable [has_zero β]\n\ninstance : has_coe_to_fun (α →₀ β) := ⟨λ_, α → β, finsupp.to_fun⟩\n\ninstance : has_zero (α →₀ β) := ⟨⟨∅, (λ_, 0), by simp⟩⟩\n\n@[simp] lemma zero_apply {a : α} : (0 : α →₀ β) a = 0 := rfl\n\n@[simp] lemma support_zero : (0 : α →₀ β).support = ∅ := rfl\n\ninstance : inhabited (α →₀ β) := ⟨0⟩\n\n@[simp] lemma mem_support_iff (f : α →₀ β) : ∀a:α, a ∈ f.support ↔ f a ≠ 0 :=\nf.mem_support_to_fun\n\n@[extensionality]\nlemma ext : ∀{f g : α →₀ β}, (∀a, f a = g a) → f = g\n| ⟨s, f, hf⟩ ⟨t, g, hg⟩ h :=\n  begin\n    have : f = g, { funext a, exact h a },\n    subst this,\n    have : s = t, { simp [finset.ext, hf, hg] },\n    subst this\n  end\n\n@[simp] lemma support_eq_empty [decidable_eq β] {f : α →₀ β} : f.support = ∅ ↔ f = 0 :=\n⟨assume h, ext $ assume a, by simp [finset.ext] at h; exact h a, by simp {contextual:=tt}⟩\n\ninstance [decidable_eq α] [decidable_eq β] : decidable_eq (α →₀ β) :=\nassume f g, decidable_of_iff (f.support = g.support ∧ (∀a∈f.support, f a = g a))\n  ⟨assume ⟨h₁, h₂⟩, ext $ assume a,\n      if h : a ∈ f.support then h₂ a h else\n        have hf : f a = 0, by rwa [f.mem_support_iff, not_not] at h,\n        have hg : g a = 0, by rwa [h₁, g.mem_support_iff, not_not] at h,\n        by rw [hf, hg],\n    by intro h; subst h; simp⟩\n\nlemma finite_supp (f : α →₀ β) : set.finite {a | f a ≠ 0} :=\n⟨set.fintype_of_finset f.support f.mem_support_iff⟩\n\nlemma support_subset_iff {s : set α} {f : α →₀ β} [decidable_eq α] :\n  ↑f.support ⊆ s ↔ (∀a∉s, f a = 0) :=\nby simp [set.subset_def];\n   exact forall_congr (assume a, @not_imp_comm _ _ (classical.dec _) (classical.dec _))\n\nend basic\n\nsection single\nvariables [decidable_eq α] [decidable_eq β] [has_zero β] {a a' : α} {b : β}\n\n/-- `single a b` is the finitely supported function which has\n  value `b` at `a` and zero otherwise. -/\ndef single (a : α) (b : β) : α →₀ β :=\n⟨(if b = 0 then ∅ else {a}), (λa', if a = a' then b else 0),\n  begin intro a', by_cases hb : b = 0; by_cases a = a'; simp [h, hb], simp [ne.symm h, h] end⟩\n\nlemma single_apply : (single a b : α →₀ β) a' = (if a = a' then b else 0) :=\nrfl\n\n@[simp] lemma single_eq_same : (single a b : α →₀ β) a = b :=\nby simp [single_apply]\n\n@[simp] lemma single_eq_of_ne (h : a ≠ a') : (single a b : α →₀ β) a' = 0 :=\nby simp [single_apply, h]\n\n@[simp] lemma single_zero : (single a 0 : α →₀ β) = 0 :=\next $ assume a',\nbegin\n  by_cases h : a = a',\n  { rw [h, single_eq_same, zero_apply] },\n  { rw [single_eq_of_ne h, zero_apply] }\nend\n\nlemma support_single_ne_zero (hb : b ≠ 0) : (single a b).support = {a} :=\nif_neg hb\n\nlemma support_single_subset : (single a b).support ⊆ {a} :=\nby by_cases b = 0; simp [support_single_ne_zero, h]\n\nend single\n\nsection on_finset\nvariables [decidable_eq β] [has_zero β]\n\n/-- `on_finset s f hf` is the finsupp function representing `f` restricted to the set `s`.\nThe function needs to be 0 outside of `s`. Use this when the set needs filtered anyway, otherwise\noften better set representation is available. -/\ndef on_finset (s : finset α) (f : α → β) (hf : ∀a, f a ≠ 0 → a ∈ s) : α →₀ β :=\n⟨s.filter (λa, f a ≠ 0), f,\n  assume a, classical.by_cases\n    (assume h : f a = 0, by simp [h])\n    (assume h : f a ≠ 0, by simp [h, hf])⟩\n\n@[simp] lemma on_finset_apply {s : finset α} {f : α → β} {hf a} :\n  (on_finset s f hf : α →₀ β) a = f a :=\nrfl\n\n@[simp] lemma support_on_finset_subset {s : finset α} {f : α → β} {hf} :\n  (on_finset s f hf).support ⊆ s :=\nby simp [on_finset]\n\nend on_finset\n\nsection map_range\nvariables [has_zero β₁] [has_zero β₂] [decidable_eq β₂]\n\n/-- The composition of `f : β₁ → β₂` and `g : α →₀ β₁` is\n  `map_range f hf g : α →₀ β₂`, well defined when `f 0 = 0`. -/\ndef map_range (f : β₁ → β₂) (hf : f 0 = 0) (g : α →₀ β₁) : α →₀ β₂ :=\non_finset g.support (f ∘ g) $\n  assume a, by rw [mem_support_iff, not_imp_not]; simp [hf] {contextual := tt}\n\n@[simp] lemma map_range_apply {f : β₁ → β₂} {hf : f 0 = 0} {g : α →₀ β₁} {a : α} :\n  map_range f hf g a = f (g a) :=\nrfl\n\nlemma support_map_range {f : β₁ → β₂} {hf : f 0 = 0} {g : α →₀ β₁} :\n  (map_range f hf g).support ⊆ g.support :=\nsupport_on_finset_subset\n\nvariables [decidable_eq α] [decidable_eq β₁]\n@[simp] lemma map_range_single {f : β₁ → β₂} {hf : f 0 = 0} {a : α} {b : β₁} :\n  map_range f hf (single a b) = single a (f b) :=\nfinsupp.ext $ λ a', by by_cases a = a'; [{subst a', simp}, simp [h, hf]]\n\nend map_range\n\nsection zip_with\nvariables [has_zero β] [has_zero β₁] [has_zero β₂] [decidable_eq α] [decidable_eq β]\n\n/-- `zip_with f hf g₁ g₂` is the finitely supported function satisfying\n  `zip_with f hf g₁ g₂ a = f (g₁ a) (g₂ a)`, and well defined when `f 0 0 = 0`. -/\ndef zip_with (f : β₁ → β₂ → β) (hf : f 0 0 = 0) (g₁ : α →₀ β₁) (g₂ : α →₀ β₂) : (α →₀ β) :=\non_finset (g₁.support ∪ g₂.support) (λa, f (g₁ a) (g₂ a)) $\n  assume a, classical.by_cases\n    (assume h : g₁ a = 0, by simp [h]; rw [not_imp_not]; simp [hf] {contextual := tt})\n    (assume h : g₁ a ≠ 0, by simp [h])\n\n@[simp] lemma zip_with_apply\n  {f : β₁ → β₂ → β} {hf : f 0 0 = 0} {g₁ : α →₀ β₁} {g₂ : α →₀ β₂} {a : α} :\n  zip_with f hf g₁ g₂ a = f (g₁ a) (g₂ a) :=\nrfl\n\nlemma support_zip_with {f : β₁ → β₂ → β} {hf : f 0 0 = 0} {g₁ : α →₀ β₁} {g₂ : α →₀ β₂} :\n  (zip_with f hf g₁ g₂).support ⊆ g₁.support ∪ g₂.support :=\nsupport_on_finset_subset\n\nend zip_with\n\nsection erase\nvariables [decidable_eq α] [decidable_eq β]\n\ndef erase [has_zero β] (a : α) (f : α →₀ β) : α →₀ β :=\n⟨f.support.erase a, (λa', if a' = a then 0 else f a'),\n  assume a', by by_cases a' = a; simp [h]⟩\n\n@[simp] lemma support_erase [has_zero β] {a : α} {f : α →₀ β} :\n  (f.erase a).support = f.support.erase a :=\nrfl\n\n@[simp] lemma erase_same [has_zero β] {a : α} {f : α →₀ β} : (f.erase a) a = 0 :=\nif_pos rfl\n\n@[simp] lemma erase_ne [has_zero β] {a a' : α} {f : α →₀ β} (h : a' ≠ a) : (f.erase a) a' = f a' :=\nif_neg h\n\nend erase\n\n-- [to_additive finsupp.sum] for finsupp.prod doesn't work, the equation lemmas are not generated\n/-- `sum f g` is the sum of `g a (f a)` over the support of `f`. -/\ndef sum [has_zero β] [add_comm_monoid γ] (f : α →₀ β) (g : α → β → γ) : γ :=\nf.support.sum (λa, g a (f a))\n\n/-- `prod f g` is the product of `g a (f a)` over the support of `f`. -/\n@[to_additive finsupp.sum]\ndef prod [has_zero β] [comm_monoid γ] (f : α →₀ β) (g : α → β → γ) : γ :=\nf.support.prod (λa, g a (f a))\nattribute [to_additive finsupp.sum.equations._eqn_1] finsupp.prod.equations._eqn_1\n\n@[to_additive finsupp.sum_map_range_index]\nlemma prod_map_range_index [has_zero β₁] [has_zero β₂] [comm_monoid γ] [decidable_eq β₂]\n  {f : β₁ → β₂} {hf : f 0 = 0} {g : α →₀ β₁} {h : α → β₂ → γ} (h0 : ∀a, h a 0 = 1) :\n  (map_range f hf g).prod h = g.prod (λa b, h a (f b)) :=\nfinset.prod_subset support_map_range $ by simp [h0] {contextual := tt}\n\n@[to_additive finsupp.sum_zero_index]\nlemma prod_zero_index [add_comm_monoid β] [comm_monoid γ] {h : α → β → γ} :\n  (0 : α →₀ β).prod h = 1 :=\nby simp [finsupp.prod]\n\nsection decidable\nvariables [decidable_eq α] [decidable_eq β]\n\nsection add_monoid\nvariables [add_monoid β]\n\n@[to_additive finsupp.sum_single_index]\nlemma prod_single_index [comm_monoid γ] {a : α} {b : β} {h : α → β → γ} (h_zero : h a 0 = 1) :\n  (single a b).prod h = h a b :=\nbegin\n  by_cases h : b = 0,\n  { simp [h, prod_zero_index, h_zero], refl },\n  { simp [finsupp.prod, support_single_ne_zero h] }\nend\n\ninstance : has_add (α →₀ β) := ⟨zip_with (+) (add_zero 0)⟩\n\n@[simp] lemma add_apply {g₁ g₂ : α →₀ β} {a : α} : (g₁ + g₂) a = g₁ a + g₂ a :=\nrfl\n\nlemma support_add {g₁ g₂ : α →₀ β} : (g₁ + g₂).support ⊆ g₁.support ∪ g₂.support :=\nsupport_zip_with\n\nlemma support_add_eq {g₁ g₂ : α →₀ β} (h : disjoint g₁.support g₂.support):\n  (g₁ + g₂).support = g₁.support ∪ g₂.support :=\nle_antisymm support_zip_with $ assume a ha,\n(finset.mem_union.1 ha).elim\n  (assume ha, have a ∉ g₂.support, from disjoint_left.1 h ha, by simp * at *)\n  (assume ha, have a ∉ g₁.support, from disjoint_right.1 h ha, by simp * at *)\n\n@[simp] lemma single_add {a : α} {b₁ b₂ : β} : single a (b₁ + b₂) = single a b₁ + single a b₂ :=\next $ assume a',\nbegin\n  by_cases h : a = a',\n  { rw [h, add_apply, single_eq_same, single_eq_same, single_eq_same] },\n  { rw [add_apply, single_eq_of_ne h, single_eq_of_ne h, single_eq_of_ne h, zero_add] }\nend\n\ninstance : add_monoid (α →₀ β) :=\n{ add_monoid .\n  zero      := 0,\n  add       := (+),\n  add_assoc := assume ⟨s, f, hf⟩ ⟨t, g, hg⟩ ⟨u, h, hh⟩, ext $ assume a, add_assoc _ _ _,\n  zero_add  := assume ⟨s, f, hf⟩, ext $ assume a, zero_add _,\n  add_zero  := assume ⟨s, f, hf⟩, ext $ assume a, add_zero _ }\n\nlemma single_add_erase {a : α} {f : α →₀ β} : single a (f a) + f.erase a = f :=\next $ λ a',\nif h : a = a' then by subst h; simp\nelse by simp [ne.symm h, h]\n\nlemma erase_add_single {a : α} {f : α →₀ β} : f.erase a + single a (f a) = f :=\next $ λ a',\nif h : a = a' then by subst h; simp\nelse by simp [ne.symm h, h]\n\nprotected theorem induction {p : (α →₀ β) → Prop} (f : α →₀ β)\n  (h0 : p 0) (ha : ∀a b (f : α →₀ β), a ∉ f.support → b ≠ 0 → p f → p (single a b + f)) :\n  p f :=\nsuffices ∀s (f : α →₀ β), f.support = s → p f, from this _ _ rfl,\nassume s, finset.induction_on s (by simp [h0] {contextual := tt}) $\nassume a s has ih f hf,\nsuffices p (single a (f a) + f.erase a), by rwa [single_add_erase] at this,\nbegin\n  apply ha,\n  { simp },\n  { rw [← mem_support_iff _ a, hf], simp },\n  { apply ih _ _,\n    simp [hf, has, finset.erase_insert] }\nend\n\nlemma induction₂ {p : (α →₀ β) → Prop} (f : α →₀ β)\n  (h0 : p 0) (ha : ∀a b (f : α →₀ β), a ∉ f.support → b ≠ 0 → p f → p (f + single a b)) :\n  p f :=\nsuffices ∀s (f : α →₀ β), f.support = s → p f, from this _ _ rfl,\nassume s, finset.induction_on s (by simp [h0] {contextual := tt}) $\nassume a s has ih f hf,\nsuffices p (f.erase a + single a (f a)), by rwa [erase_add_single] at this,\nbegin\n  apply ha,\n  { simp },\n  { rw [← mem_support_iff _ a, hf], simp },\n  { apply ih _ _,\n    simp [hf, has, finset.erase_insert] }\nend\n\nend add_monoid\n\ninstance [add_comm_monoid β] : add_comm_monoid (α →₀ β) :=\n{ add_comm := assume ⟨s, f, _⟩ ⟨t, g, _⟩, ext $ assume a, add_comm _ _,\n  .. finsupp.add_monoid }\n\ninstance [add_group β] : add_group (α →₀ β) :=\n{ neg          := map_range (has_neg.neg) neg_zero,\n  add_left_neg := assume ⟨s, f, _⟩, ext $ assume x, add_left_neg _,\n  .. finsupp.add_monoid }\n\nlemma single_multiset_sum [add_comm_monoid β] [decidable_eq α] [decidable_eq β]\n  (s : multiset β) (a : α) : single a s.sum = (s.map (single a)).sum :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma single_finset_sum [add_comm_monoid β] [decidable_eq α] [decidable_eq β]\n  (s : finset γ) (f : γ → β) (a : α) : single a (s.sum f) = s.sum (λb, single a (f b)) :=\nbegin\n  transitivity,\n  apply single_multiset_sum,\n  rw [multiset.map_map],\n  refl\nend\n\nlemma single_sum [has_zero γ] [add_comm_monoid β] [decidable_eq α] [decidable_eq β]\n  (s : δ →₀ γ) (f : δ → γ → β) (a : α) : single a (s.sum f) = s.sum (λd c, single a (f d c)) :=\nsingle_finset_sum _ _ _\n\n\n@[to_additive finsupp.sum_neg_index]\nlemma prod_neg_index [add_group β] [comm_monoid γ]\n  {g : α →₀ β} {h : α → β → γ} (h0 : ∀a, h a 0 = 1) :\n  (-g).prod h = g.prod (λa b, h a (- b)) :=\nprod_map_range_index h0\n\n@[simp] lemma neg_apply [add_group β] {g : α →₀ β} {a : α} : (- g) a = - g a := rfl\n\n@[simp] lemma sub_apply [add_group β] {g₁ g₂ : α →₀ β} {a : α} : (g₁ - g₂) a = g₁ a - g₂ a := rfl\n\n@[simp] lemma support_neg [add_group β] {f : α →₀ β} : support (-f) = support f :=\nfinset.subset.antisymm\n  support_map_range\n  (calc support f = support (- (- f)) : by simp\n     ... ⊆ support (- f) : support_map_range)\n\ninstance [add_comm_group β] : add_comm_group (α →₀ β) :=\n{ add_comm := add_comm, ..finsupp.add_group }\n\n@[simp] lemma sum_apply [has_zero β₁] [add_comm_monoid β]\n  {f : α₁ →₀ β₁} {g : α₁ → β₁ → α →₀ β} {a₂ : α} :\n  (f.sum g) a₂ = f.sum (λa₁ b, g a₁ b a₂) :=\n(finset.sum_hom (λf : α →₀ β, f a₂) rfl (assume a b, rfl)).symm\n\nlemma support_sum [has_zero β₁] [add_comm_monoid β]\n  {f : α₁ →₀ β₁} {g : α₁ → β₁ → (α →₀ β)} :\n  (f.sum g).support ⊆ f.support.bind (λa, (g a (f a)).support) :=\nhave ∀a₁ : α, f.sum (λ (a : α₁) (b : β₁), (g a b) a₁) ≠ 0 →\n    (∃ (a : α₁), f a ≠ 0 ∧ ¬ (g a (f a)) a₁ = 0),\n  from assume a₁ h,\n  let ⟨a, ha, ne⟩ := finset.exists_ne_zero_of_sum_ne_zero h in\n  ⟨a, (f.mem_support_iff a).mp ha, ne⟩,\nby simpa [finset.subset_iff, mem_support_iff, finset.mem_bind, sum_apply] using this\n\n@[simp] lemma sum_zero [add_comm_monoid β] [add_comm_monoid γ] {f : α →₀ β} :\n  f.sum (λa b, (0 : γ)) = 0 :=\nfinset.sum_const_zero\n\n@[simp] lemma sum_add  [add_comm_monoid β] [add_comm_monoid γ] {f : α →₀ β}\n  {h₁ h₂ : α → β → γ} :\n  f.sum (λa b, h₁ a b + h₂ a b) = f.sum h₁ + f.sum h₂ :=\nfinset.sum_add_distrib\n\n@[simp] lemma sum_neg [add_comm_monoid β] [add_comm_group γ] {f : α →₀ β}\n  {h : α → β → γ} : f.sum (λa b, - h a b) = - f.sum h :=\nfinset.sum_hom (@has_neg.neg γ _) neg_zero (assume a b, neg_add _ _)\n\n@[simp] lemma sum_single [add_comm_monoid β] {f : α →₀ β} :\n  f.sum single = f :=\nhave ∀a:α, f.sum (λa' b, ite (a' = a) b 0) =\n    ({a} : finset α).sum (λa', ite (a' = a) (f a') 0),\nbegin\n  intro a,\n  by_cases h : a ∈ f.support,\n  { have : (finset.singleton a : finset α) ⊆ f.support,\n      { simp [finset.subset_iff, *] at * },\n    refine (finset.sum_subset this _).symm,\n    simp {contextual := tt} },\n  { transitivity (f.support.sum (λa, (0 : β))),\n    { refine (finset.sum_congr rfl _),\n      intros a' ha',\n      have h: a' ≠ a,\n        { assume eq, simp * at * },\n      simp * at * },\n    { simp * at * } }\nend,\next $ assume a, by simp [single_apply, this]\n\n@[to_additive finsupp.sum_add_index]\nlemma prod_add_index [add_comm_monoid β] [comm_monoid γ] {f g : α →₀ β}\n  {h : α → β → γ} (h_zero : ∀a, h a 0 = 1) (h_add : ∀a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) :\n  (f + g).prod h = f.prod h * g.prod h :=\nhave f_eq : (f.support ∪ g.support).prod (λa, h a (f a)) = f.prod h,\n  from (finset.prod_subset finset.subset_union_left $\n    by simp [mem_support_iff, h_zero] {contextual := tt}).symm,\nhave g_eq : (f.support ∪ g.support).prod (λa, h a (g a)) = g.prod h,\n  from (finset.prod_subset finset.subset_union_right $\n    by simp [mem_support_iff, h_zero] {contextual := tt}).symm,\ncalc (f + g).support.prod (λa, h a ((f + g) a)) =\n      (f.support ∪ g.support).prod (λa, h a ((f + g) a)) :\n    finset.prod_subset support_add $\n      by simp [mem_support_iff, h_zero] {contextual := tt}\n  ... = (f.support ∪ g.support).prod (λa, h a (f a)) *\n      (f.support ∪ g.support).prod (λa, h a (g a)) :\n    by simp [h_add, finset.prod_mul_distrib]\n  ... = _ : by rw [f_eq, g_eq]\n\nlemma sum_sub_index [add_comm_group β] [add_comm_group γ] {f g : α →₀ β}\n  {h : α → β → γ} (h_sub : ∀a b₁ b₂, h a (b₁ - b₂) = h a b₁ - h a b₂) :\n  (f - g).sum h = f.sum h - g.sum h :=\nhave h_zero : ∀a, h a 0 = 0,\n  from assume a,\n  have h a (0 - 0) = h a 0 - h a 0, from h_sub a 0 0,\n  by simpa using this,\nhave h_neg : ∀a b, h a (- b) = - h a b,\n  from assume a b,\n  have h a (0 - b) = h a 0 - h a b, from h_sub a 0 b,\n  by simpa [h_zero] using this,\nhave h_add : ∀a b₁ b₂, h a (b₁ + b₂) = h a b₁ + h a b₂,\n  from assume a b₁ b₂,\n  have h a (b₁ - (- b₂)) = h a b₁ - h a (- b₂), from h_sub a b₁ (-b₂),\n  by simpa [h_neg] using this,\ncalc (f - g).sum h = (f + - g).sum h : by simp\n  ... = f.sum h + - g.sum h : by simp [sum_add_index, sum_neg_index, h_add, h_zero, h_neg]\n  ... = _ : by simp\n\n@[to_additive finsupp.sum_finset_sum_index]\nlemma prod_finset_sum_index [add_comm_monoid β] [comm_monoid γ] [decidable_eq ι]\n  {s : finset ι} {g : ι → α →₀ β}\n  {h : α → β → γ} (h_zero : ∀a, h a 0 = 1) (h_add : ∀a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂):\n  s.prod (λi, (g i).prod h) = (s.sum g).prod h :=\nfinset.induction_on s\n  (by simp [prod_zero_index])\n  (by simp [prod_add_index, h_zero, h_add] {contextual := tt})\n\n@[to_additive finsupp.sum_sum_index]\nlemma prod_sum_index\n  [decidable_eq α₁] [add_comm_monoid β₁] [add_comm_monoid β] [comm_monoid γ]\n  {f : α₁ →₀ β₁} {g : α₁ → β₁ → α →₀ β}\n  {h : α → β → γ} (h_zero : ∀a, h a 0 = 1) (h_add : ∀a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂):\n  (f.sum g).prod h = f.prod (λa b, (g a b).prod h) :=\n(prod_finset_sum_index h_zero h_add).symm\n\nlemma multiset_sum_sum_index\n  [decidable_eq α] [decidable_eq β] [add_comm_monoid β] [add_comm_monoid γ]\n  (f : multiset (α →₀ β)) (h : α → β → γ)\n  (h₀ : ∀a, h a 0 = 0) (h₁ : ∀ (a : α) (b₁ b₂ : β), h a (b₁ + b₂) = h a b₁ + h a b₂) :\n  (f.sum.sum h) = (f.map $ λg:α →₀ β, g.sum h).sum :=\nmultiset.induction_on f (by simp [finsupp.sum_zero_index])\n  (assume a s ih, by simp [finsupp.sum_add_index h₀ h₁, ih] {contextual := tt})\n\nlemma multiset_map_sum [has_zero β] {f : α →₀ β} {m : γ → δ} {h : α → β → multiset γ} :\n  multiset.map m (f.sum h) = f.sum (λa b, (h a b).map m) :=\n(finset.sum_hom _ (multiset.map_zero m) (multiset.map_add m)).symm\n\nlemma multiset_sum_sum [has_zero β] [add_comm_monoid γ] {f : α →₀ β} {h : α → β → multiset γ} :\n  multiset.sum (f.sum h) = f.sum (λa b, multiset.sum (h a b)) :=\nbegin\n  refine (finset.sum_hom multiset.sum _ _).symm,\n  exact multiset.sum_zero,\n  exact multiset.sum_add\nend\n\nsection map_domain\nvariables [decidable_eq α₁] [decidable_eq α₂] [add_comm_monoid β] {v v₁ v₂ : α →₀ β}\n\n/-- Given `f : α₁ → α₂` and `v : α₁ →₀ β`, `map_domain f v : α₂ →₀ β`\n  is the finitely supported function whose value at `a : α₂` is the sum\n  of `v x` over all `x` such that `f x = a`. -/\ndef map_domain (f : α₁ → α₂) (v : α₁ →₀ β) : α₂ →₀ β :=\nv.sum $ λa, single (f a)\n\nlemma map_domain_id : map_domain id v = v :=\nsum_single\n\nlemma map_domain_comp {f : α → α₁} {g : α₁ → α₂} :\n  map_domain (g ∘ f) v = map_domain g (map_domain f v) :=\nby simp [map_domain, sum_sum_index, sum_single_index]\n\nlemma map_domain_single {f : α → α₁} {a : α} {b : β} : map_domain f (single a b) = single (f a) b :=\nsum_single_index (by simp)\n\nlemma map_domain_zero {f : α → α₂} : map_domain f 0 = (0 : α₂ →₀ β) :=\nsum_zero_index\n\nlemma map_domain_congr {f g : α → α₂} (h : ∀x∈v.support, f x = g x) :\n  v.map_domain f = v.map_domain g :=\nfinset.sum_congr rfl $ by simp [*] at * {contextual := tt}\n\nlemma map_domain_add {f : α → α₂} : map_domain f (v₁ + v₂) = map_domain f v₁ + map_domain f v₂ :=\nsum_add_index (by simp) (by simp)\n\nlemma map_domain_finset_sum [decidable_eq ι] {f : α → α₂} {s : finset ι} {v : ι → α →₀ β} :\n  map_domain f (s.sum v) = s.sum (λi, map_domain f (v i)) :=\nby refine (sum_finset_sum_index _ _).symm; simp\n\nlemma map_domain_sum [has_zero β₁] {f : α → α₂} {s : α →₀ β₁} {v : α → β₁ → α →₀ β} :\n  map_domain f (s.sum v) = s.sum (λa b, map_domain f (v a b)) :=\nby refine (sum_finset_sum_index _ _).symm; simp\n\nlemma map_domain_support {f : α → α₂} {s : α →₀ β} :\n  (s.map_domain f).support ⊆ s.support.image f :=\nfinset.subset.trans support_sum $\n  finset.subset.trans (finset.bind_mono $ assume a ha, support_single_subset) $\n  by rw [finset.bind_singleton]; exact subset.refl _\n\n@[to_additive finsupp.sum_map_domain_index]\nlemma prod_map_domain_index [comm_monoid γ] {f : α → α₂} {s : α →₀ β}\n  {h : α₂ → β → γ} (h_zero : ∀a, h a 0 = 1) (h_add : ∀a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) :\n  (s.map_domain f).prod h = s.prod (λa b, h (f a) b) :=\nby simp [map_domain, prod_sum_index, h_zero, h_add, prod_single_index]\n\nend map_domain\n\n/-- The product of `f g : α →₀ β` is the finitely supported function\n  whose value at `a` is the sum of `f x * g y` over all pairs `x, y`\n  such that `x + y = a`. (Think of the product of multivariate\n  polynomials where `α` is the monoid of monomial exponents.) -/\ninstance [has_add α] [semiring β] : has_mul (α →₀ β) :=\n⟨λf g, f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, single (a₁ + a₂) (b₁ * b₂)⟩\n\nlemma mul_def [has_add α] [semiring β] {f g : α →₀ β} :\n  f * g = (f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, single (a₁ + a₂) (b₁ * b₂)) := rfl\n\n/-- The unit of the multiplication is `single 0 1`, i.e. the function\n  that is 1 at 0 and zero elsewhere. -/\ninstance [has_zero α] [has_zero β] [has_one β] : has_one (α →₀ β) :=\n⟨single 0 1⟩\n\nlemma one_def [has_zero α] [has_zero β] [has_one β] : 1 = (single 0 1 : α →₀ β) := rfl\n\nsection filter -- TODO: remove filter? build upon subtype_domain?\nsection has_zero\nvariables [has_zero β] {p : α → Prop} [decidable_pred p] {f : α →₀ β}\n\n/-- `filter p f` is the function which is `f a` if `p a` is true and 0 otherwise. -/\ndef filter (p : α → Prop) [decidable_pred p] (f : α →₀ β) : α →₀ β :=\non_finset f.support (λa, if p a then f a else 0) (assume a, by by_cases (p a); simp [h])\n\n@[simp] lemma filter_apply_pos {a : α} (h : p a) : f.filter p a = f a :=\nif_pos h\n\n@[simp] lemma filter_apply_neg {a : α} (h : ¬ p a) : f.filter p a = 0 :=\nif_neg h\n\n@[simp] lemma support_filter : (f.filter p).support = f.support.filter p :=\nfinset.ext.mpr $ assume a, by by_cases p a; simp *\n\nend has_zero\n\nlemma filter_pos_add_filter_neg [add_monoid β] {f : α →₀ β} {p : α → Prop}\n  [decidable_pred p] [decidable_pred (λa, ¬ p a)] :\n  f.filter p + f.filter (λa, ¬ p a) = f :=\nfinsupp.ext $ assume a, by by_cases p a; simp *\n\nend filter\n\nsection subtype_domain\n\nvariables {α' : Type*} [has_zero δ] {p : α → Prop} [decidable_pred p]\n\nsection zero\nvariables [has_zero β] {v v' : α' →₀ β}\n\n/-- `subtype_domain p f` is the restriction of the finitely supported function\n  `f` to the subtype `p`. -/\ndef subtype_domain (p : α → Prop) [decidable_pred p] (f : α →₀ β) : (subtype p →₀ β) :=\n⟨f.support.subtype p, f ∘ subtype.val, by simp⟩\n\n@[simp] lemma support_subtype_domain {f : α →₀ β} :\n  (subtype_domain p f).support = f.support.subtype p :=\nrfl\n\n@[simp] lemma subtype_domain_apply {a : subtype p} {v : α →₀ β} :\n  (subtype_domain p v) a = v (a.val) :=\nrfl\n\n@[simp] lemma subtype_domain_zero : subtype_domain p (0 : α →₀ β) = 0 :=\nrfl\n\n@[to_additive finsupp.sum_subtype_domain_index]\nlemma prod_subtype_domain_index [comm_monoid γ] {v : α →₀ β}\n  {h : α → β → γ} (hp : ∀x∈v.support, p x) :\n  (v.subtype_domain p).prod (λa b, h a.1 b) = v.prod h :=\nprod_bij (λp _, p.val)\n  (by simp)\n  (by simp)\n  (assume ⟨a₀, ha₀⟩ ⟨a₁, ha₁⟩, by simp)\n  (begin simp; exact assume b hb, ⟨b, hp _ (by simp [hb]), by simp [hb]⟩ end)\n\nend zero\n\nsection monoid\nvariables [add_monoid β] {v v' : α' →₀ β}\n\n@[simp] lemma subtype_domain_add {v v' : α →₀ β} :\n  (v + v').subtype_domain p = v.subtype_domain p + v'.subtype_domain p :=\next $ by simp\n\nend monoid\n\nsection comm_monoid\nvariables [add_comm_monoid β]\n\nlemma subtype_domain_sum {s : finset γ} {h : γ → α →₀ β} :\n  (s.sum h).subtype_domain p = s.sum (λc, (h c).subtype_domain p) :=\neq.symm (finset.sum_hom _ subtype_domain_zero $ assume v v', subtype_domain_add)\n\nlemma subtype_domain_finsupp_sum {s : γ →₀ δ} {h : γ → δ → α →₀ β} :\n  (s.sum h).subtype_domain p = s.sum (λc d, (h c d).subtype_domain p) :=\nsubtype_domain_sum\n\nend comm_monoid\n\nsection group\nvariables [add_group β] {v v' : α' →₀ β}\n\n@[simp] lemma subtype_domain_neg {v : α →₀ β} :\n  (- v).subtype_domain p = - v.subtype_domain p :=\next $ by simp\n\n@[simp] lemma subtype_domain_sub {v v' : α →₀ β} :\n  (v - v').subtype_domain p = v.subtype_domain p - v'.subtype_domain p :=\next $ by simp\n\nend group\n\nend subtype_domain\n\nsection multiset\n\ndef to_multiset (f : α →₀ ℕ) : multiset α :=\nf.sum (λa n, add_monoid.smul n {a})\n\n@[simp] lemma count_to_multiset [decidable_eq α] (f : α →₀ ℕ) (a : α) :\n  f.to_multiset.count a = f a :=\ncalc f.to_multiset.count a = f.sum (λx n, (add_monoid.smul n {x} : multiset α).count a) :\n    (finset.sum_hom _ (multiset.count_zero a) (multiset.count_add a)).symm\n  ... = f.sum (λx n, n * ({x} : multiset α).count a) : by simp\n  ... = f.sum (λx n, n * (x :: 0 : multiset α).count a) : rfl\n  ... = f a * (a :: 0 : multiset α).count a :\n    begin\n      refine sum_eq_single _ _ _,\n      { simp [multiset.count_cons_of_ne, nat.mul_eq_zero, multiset.count_eq_zero, eq_comm]\n        {contextual := tt} },\n      { simp }\n    end\n  ... = f a : by simp [multiset.count_singleton]\n\ndef of_multiset [decidable_eq α] (m : multiset α) : α →₀ ℕ :=\non_finset m.to_finset (λa, m.count a) $ by simp [multiset.count_eq_zero]\n\n@[simp] lemma of_multiset_apply [decidable_eq α] (m : multiset α) (a : α) :\n  of_multiset m a = m.count a :=\nrfl\n\ndef equiv_multiset [decidable_eq α] : (α →₀ ℕ) ≃ (multiset α) :=\n⟨ to_multiset, of_multiset, assume f, finsupp.ext $ by simp, assume m, multiset.ext.2 $ by simp ⟩\n\nlemma mem_support_multiset_sum [decidable_eq α] [decidable_eq β] [add_comm_monoid β]\n  {s : multiset (α →₀ β)} (a : α) :\n  a ∈ s.sum.support → ∃f∈s, a ∈ (f : α →₀ β).support :=\nmultiset.induction_on s (by simp)\n  begin\n    assume f s ih ha,\n    by_cases a ∈ f.support,\n    { exact ⟨f, multiset.mem_cons_self _ _, h⟩ },\n    { simp at h,\n      simp [h] at ha,\n      simp [ha] at ih,\n      rcases ih with ⟨f', h₀, h₁⟩,\n      exact ⟨f', multiset.mem_cons_of_mem h₀, by simpa using h₁⟩ }\n  end\n\nlemma mem_support_finset_sum [decidable_eq α] [decidable_eq β] [add_comm_monoid β]\n  {s : finset γ} {h : γ → α →₀ β} (a : α) (ha : a ∈ (s.sum h).support) : ∃c∈s, a ∈ (h c).support :=\nlet ⟨f, hf, hfa⟩ := mem_support_multiset_sum a ha in\nlet ⟨c, hc, eq⟩ := multiset.mem_map.1 hf in\n⟨c, hc, eq.symm ▸ hfa⟩\n\nlemma mem_support_single [decidable_eq α] [decidable_eq β] [has_zero β] (a a' : α) (b : β) :\n  a ∈ (single a' b).support ↔ a = a' ∧ b ≠ 0 :=\nclassical.by_cases\n  (assume : b = 0, by simp [this])\n  (assume : b ≠ 0, by simp [this, -mem_support_iff, support_single_ne_zero])\n\nend multiset\n\nsection curry_uncurry\n\nprotected def curry [decidable_eq α] [decidable_eq β] [decidable_eq γ] [add_comm_monoid γ]\n  (f : (α × β) →₀ γ) : α →₀ (β →₀ γ) :=\nf.sum $ λp c, single p.1 (single p.2 c)\n\nlemma sum_curry_index\n  [decidable_eq α] [decidable_eq β] [decidable_eq γ] [add_comm_monoid γ] [add_comm_monoid δ]\n  (f : (α × β) →₀ γ) (g : α → β → γ → δ)\n  (hg₀ : ∀ a b, g a b 0 = 0) (hg₁ : ∀a b c₀ c₁, g a b (c₀ + c₁) = g a b c₀ + g a b c₁) :\n  f.curry.sum (λa f, f.sum (g a)) = f.sum (λp c, g p.1 p.2 c) :=\nbegin\n  rw [finsupp.curry],\n  transitivity,\n  { exact sum_sum_index (assume a, sum_zero_index)\n      (assume a b₀ b₁, sum_add_index (assume a, hg₀ _ _) (assume c d₀ d₁, hg₁ _ _ _ _)) },\n  congr, funext p c,\n  transitivity,\n  { exact sum_single_index sum_zero_index },\n  exact sum_single_index (hg₀ _ _)\nend\n\nprotected def uncurry [decidable_eq α] [decidable_eq β] [decidable_eq γ] [add_comm_monoid γ]\n  (f : α →₀ (β →₀ γ)) : (α × β) →₀ γ :=\nf.sum $ λa g, g.sum $ λb c, single (a, b) c\n\ndef finsupp_prod_equiv [add_comm_monoid γ] [decidable_eq α] [decidable_eq β] [decidable_eq γ] :\n  ((α × β) →₀ γ) ≃ (α →₀ (β →₀ γ)) :=\n⟨ finsupp.curry, finsupp.uncurry,\n  assume f, by simp [finsupp.curry, finsupp.uncurry, sum_sum_index, sum_zero_index, sum_add_index,\n    sum_single_index],\n  assume f, by simp [finsupp.curry, finsupp.uncurry, sum_sum_index, sum_zero_index, sum_add_index,\n    sum_single_index, (single_sum _ _ _).symm] ⟩\n\nend curry_uncurry\n\nsection\nvariables [add_monoid α] [semiring β]\n\n-- TODO: the simplifier unfolds 0 in the instance proof!\nprivate lemma zero_mul (f : α →₀ β) : 0 * f = 0 := by simp [mul_def, sum_zero_index]\nprivate lemma mul_zero (f : α →₀ β) : f * 0 = 0 := by simp [mul_def, sum_zero_index]\nprivate lemma left_distrib (a b c : α →₀ β) : a * (b + c) = a * b + a * c :=\nby simp [mul_def, sum_add_index, mul_add]\nprivate lemma right_distrib (a b c : α →₀ β) : (a + b) * c = a * c + b * c :=\nby simp [mul_def, sum_add_index, add_mul]\n\ndef to_semiring : semiring (α →₀ β) :=\n{ one       := 1,\n  mul       := (*),\n  one_mul   := assume f, by simp [mul_def, one_def, sum_single_index],\n  mul_one   := assume f, by simp [mul_def, one_def, sum_single_index],\n  zero_mul  := zero_mul,\n  mul_zero  := mul_zero,\n  mul_assoc := assume f g h,\n    by simp [mul_def, sum_sum_index, sum_zero_index, sum_add_index, sum_single_index,\n        add_mul, mul_add, mul_assoc],\n  left_distrib  := left_distrib,\n  right_distrib := right_distrib,\n  .. finsupp.add_comm_monoid }\n\nend\n\nlocal attribute [instance] to_semiring\n\ndef to_comm_semiring [add_comm_monoid α] [comm_semiring β] : comm_semiring (α →₀ β) :=\n{ mul_comm := assume f g,\n  begin\n    simp [mul_def, finsupp.sum, mul_comm],\n    rw [finset.sum_comm],\n    simp\n  end,\n  .. finsupp.to_semiring }\n\nlocal attribute [instance] to_comm_semiring\n\ndef to_ring [add_monoid α] [ring β] : ring (α →₀ β) :=\n{ neg := has_neg.neg,\n  add_left_neg := add_left_neg,\n  .. finsupp.to_semiring }\n\ndef to_comm_ring [add_comm_monoid α] [comm_ring β] : comm_ring (α →₀ β) :=\n{ mul_comm := mul_comm, .. finsupp.to_ring}\n\nlemma single_mul_single [has_add α] [semiring β] {a₁ a₂ : α} {b₁ b₂ : β}:\n  single a₁ b₁ * single a₂ b₂ = single (a₁ + a₂) (b₁ * b₂) :=\nby simp [mul_def, sum_single_index]\n\nlemma prod_single [decidable_eq ι] [add_comm_monoid α] [comm_semiring β]\n  {s : finset ι} {a : ι → α} {b : ι → β} :\n  s.prod (λi, single (a i) (b i)) = single (s.sum a) (s.prod b) :=\nfinset.induction_on s (by simp [one_def]) (by simp [single_mul_single] {contextual := tt})\n\nsection\nvariable (β)\n\ndef to_has_scalar' [ring γ] [module γ β] : has_scalar γ (α →₀ β) := ⟨λa v, v.map_range ((•) a) (smul_zero)⟩\nlocal attribute [instance] to_has_scalar'\n\n@[simp] lemma smul_apply' [ring γ] [module γ β] {a : α} {b : γ} {v : α →₀ β} :\n  (b • v) a = b • (v a) := rfl\n\ndef to_module [ring γ] [module γ β] : module γ (α →₀ β) :=\n{ smul     := (•),\n  smul_add := assume a x y, finsupp.ext $ by simp [smul_add],\n  add_smul := assume a x y, finsupp.ext $ by simp [add_smul],\n  one_smul := assume x, finsupp.ext $ by simp,\n  mul_smul := assume r s x, finsupp.ext $ by simp [smul_smul],\n  .. finsupp.add_comm_group }\n\nend\n\ndef to_has_scalar [ring β] : has_scalar β (α →₀ β) := to_has_scalar' β\nlocal attribute [instance] to_has_scalar\n\n@[simp] lemma smul_apply [ring β] {a : α} {b : β} {v : α →₀ β} :\n  (b • v) a = b • (v a) := rfl\n\nlemma sum_smul_index [ring β] [add_comm_monoid γ] {g : α →₀ β} {b : β} {h : α → β → γ}\n  (h0 : ∀i, h i 0 = 0) : (b • g).sum h = g.sum (λi a, h i (b * a)) :=\nfinsupp.sum_map_range_index h0\n\nend decidable\n\nsection\nvariables [semiring β] [semiring γ]\n\nlemma sum_mul (b : γ) (s : α →₀ β) {f : α → β → γ} :\n  (s.sum f) * b = s.sum (λ a c, (f a (s a)) * b) :=\nby simp [finsupp.sum, finset.sum_mul]\n\nlemma mul_sum [semiring β] [semiring γ] (b : γ) (s : α →₀ β) {f : α → β → γ} :\n  b * (s.sum f) = s.sum (λ a c, b * (f a (s a))) :=\nby simp [finsupp.sum, finset.mul_sum]\n\nend\n\nend finsupp\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/data/finsupp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.4912472442531649}}
{"text": "/-\nCopyright © 2020 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicolò Cavalleri\n-/\n\nimport data.set.Union_lift\nimport topology.homeomorph\n\n/-!\n# Continuous bundled maps\n\nIn this file we define the type `continuous_map` of continuous bundled maps.\n\nWe use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to\nbe satisfied by itself and all stricter types.\n-/\n\nopen function\n\n/-- The type of continuous maps from `α` to `β`.\n\nWhen possible, instead of parametrizing results over `(f : C(α, β))`,\nyou should parametrize over `{F : Type*} [continuous_map_class F α β] (f : F)`.\n\nWhen you extend this structure, make sure to extend `continuous_map_class`. -/\n@[protect_proj]\nstructure continuous_map (α β : Type*) [topological_space α] [topological_space β] :=\n(to_fun             : α → β)\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n\nnotation `C(` α `, ` β `)` := continuous_map α β\n\n/-- `continuous_map_class F α β` states that `F` is a type of continuous maps.\n\nYou should extend this class when you extend `continuous_map`. -/\nclass continuous_map_class (F : Type*) (α β : out_param $ Type*) [topological_space α]\n  [topological_space β]\n  extends fun_like F α (λ _, β) :=\n(map_continuous (f : F) : continuous f)\n\nexport continuous_map_class (map_continuous)\n\nattribute [continuity] map_continuous\n\nsection continuous_map_class\nvariables {F α β : Type*} [topological_space α] [topological_space β] [continuous_map_class F α β]\ninclude β\n\nlemma map_continuous_at (f : F) (a : α) : continuous_at f a := (map_continuous f).continuous_at\n\nlemma map_continuous_within_at (f : F) (s : set α) (a : α) : continuous_within_at f s a :=\n(map_continuous f).continuous_within_at\n\ninstance : has_coe_t F C(α, β) := ⟨λ f, { to_fun := f, continuous_to_fun := map_continuous f }⟩\n\nend continuous_map_class\n\n/-! ### Continuous maps-/\n\nnamespace continuous_map\nvariables {α β γ δ : Type*} [topological_space α] [topological_space β] [topological_space γ]\n  [topological_space δ]\n\ninstance : continuous_map_class C(α, β) α β :=\n{ coe := continuous_map.to_fun,\n  coe_injective' := λ f g h, by cases f; cases g; congr',\n  map_continuous := continuous_map.continuous_to_fun }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (C(α, β)) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : C(α, β)} : f.to_fun = (f : α → β) := rfl\n\n@[ext] \n\n/-- Copy of a `continuous_map` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : C(α, β)) (f' : α → β) (h : f' = f) : C(α, β) :=\n{ to_fun := f',\n  continuous_to_fun := h.symm ▸ f.continuous_to_fun }\n\nvariables {α β} {f g : C(α, β)}\n\n/-- Deprecated. Use `map_continuous` instead. -/\nprotected lemma continuous (f : C(α, β)) : continuous f := f.continuous_to_fun\n@[continuity] lemma continuous_set_coe (s : set C(α, β)) (f : s) : continuous f := f.1.continuous\n\n/-- Deprecated. Use `map_continuous_at` instead. -/\nprotected lemma continuous_at (f : C(α, β)) (x : α) : continuous_at f x :=\nf.continuous.continuous_at\n\n/-- Deprecated. Use `fun_like.congr_fun` instead. -/\nprotected lemma congr_fun {f g : C(α, β)} (H : f = g) (x : α) : f x = g x := H ▸ rfl\n/-- Deprecated. Use `fun_like.congr_arg` instead. -/\nprotected lemma congr_arg (f : C(α, β)) {x y : α} (h : x = y) : f x = f y := h ▸ rfl\n\ninstance [inhabited β] : inhabited C(α, β) :=\n⟨{ to_fun := λ _, default, }⟩\n\nlemma coe_injective : @function.injective (C(α, β)) (α → β) coe_fn :=\nλ f g h, by cases f; cases g; congr'\n\n@[simp] lemma coe_mk (f : α → β) (h : continuous f) :\n  ⇑(⟨f, h⟩ : C(α, β)) = f := rfl\n\nsection\nvariables (α β)\n\n/--\nThe continuous functions from `α` to `β` are the same as the plain functions when `α` is discrete.\n-/\n@[simps]\ndef equiv_fn_of_discrete [discrete_topology α] : C(α, β) ≃ (α → β) :=\n⟨(λ f, f), (λ f, ⟨f, continuous_of_discrete_topology⟩),\n  λ f, by { ext, refl, }, λ f, by { ext, refl, }⟩\n\nend\n\nvariables (α)\n\n/-- The identity as a continuous map. -/\nprotected def id : C(α, α) := ⟨id⟩\n\n@[simp] lemma coe_id : ⇑(continuous_map.id α) = id := rfl\n\n/-- The constant map as a continuous map. -/\ndef const (b : β) : C(α, β) := ⟨const α b⟩\n\n@[simp] lemma coe_const (b : β) : ⇑(const α b) = function.const α b := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : continuous_map.id α a = a := rfl\n@[simp] lemma const_apply (b : β) (a : α) : const α b a = b := rfl\n\n/-- The composition of continuous maps, as a continuous map. -/\ndef comp (f : C(β, γ)) (g : C(α, β)) : C(α, γ) := ⟨f ∘ g⟩\n\n@[simp] lemma coe_comp (f : C(β, γ)) (g : C(α, β)) : ⇑(comp f g) = f ∘ g := rfl\n@[simp] lemma comp_apply (f : C(β, γ)) (g : C(α, β)) (a : α) : comp f g a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : C(γ, δ)) (g : C(β, γ)) (h : C(α, β)) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma id_comp (f : C(α, β)) : (continuous_map.id _).comp f = f := ext $ λ _, rfl\n@[simp] lemma comp_id (f : C(α, β)) : f.comp (continuous_map.id _) = f := ext $ λ _, rfl\n@[simp] lemma const_comp (c : γ) (f : C(α, β)) : (const β c).comp f = const α c := ext $ λ _, rfl\n@[simp] lemma comp_const (f : C(β, γ)) (b : β) : f.comp (const α b) = const α (f b) :=\next $ λ _, rfl\n\nlemma cancel_right {f₁ f₂ : C(β, γ)} {g : C(α, β)} (hg : surjective g) :\n  f₁.comp g = f₂.comp g ↔ f₁ = f₂ :=\n⟨λ h, ext $ hg.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {f : C(β, γ)} {g₁ g₂ : C(α, β)} (hf : injective f) :\n  f.comp g₁ = f.comp g₂ ↔ g₁ = g₂ :=\n⟨λ h, ext $ λ a, hf $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩\n\ninstance [nonempty α] [nontrivial β] : nontrivial C(α, β) :=\n⟨let ⟨b₁, b₂, hb⟩ := exists_pair_ne β in\n    ⟨const _ b₁, const _ b₂, λ h, hb $ fun_like.congr_fun h $ classical.arbitrary α⟩⟩\n\nsection prod\n\nvariables {α₁ α₂ β₁ β₂ : Type*}\n          [topological_space α₁] [topological_space α₂]\n          [topological_space β₁] [topological_space β₂]\n\n/-- Given two continuous maps `f` and `g`, this is the continuous map `x ↦ (f x, g x)`. -/\ndef prod_mk (f : C(α, β₁)) (g : C(α, β₂)) :\n  C(α, β₁ × β₂) :=\n{ to_fun := (λ x, (f x, g x)),\n  continuous_to_fun := continuous.prod_mk f.continuous g.continuous }\n\n/-- Given two continuous maps `f` and `g`, this is the continuous map `(x, y) ↦ (f x, g y)`. -/\ndef prod_map (f : C(α₁, α₂)) (g : C(β₁, β₂)) :\n  C(α₁ × β₁, α₂ × β₂) :=\n{ to_fun := prod.map f g,\n  continuous_to_fun := continuous.prod_map f.continuous g.continuous }\n\n@[simp] lemma prod_eval (f : C(α, β₁)) (g : C(α, β₂)) (a : α) :\n  (prod_mk f g) a = (f a, g a) := rfl\n\nend prod\n\nsection pi\n\nvariables {I A : Type*} {X : I → Type*}\n          [topological_space A] [∀ i, topological_space (X i)]\n\n/-- Abbreviation for product of continuous maps, which is continuous -/\ndef pi (f : Π i, C(A, X i)) : C(A, Π i, X i) :=\n{ to_fun := λ (a : A) (i : I), f i a, }\n\n@[simp] lemma pi_eval (f : Π i, C(A, X i)) (a : A) :\n  (pi f) a = λ i : I, (f i) a := rfl\n\nend pi\n\nsection restrict\n\nvariables (s : set α)\n\n/-- The restriction of a continuous function `α → β` to a subset `s` of `α`. -/\ndef restrict (f : C(α, β)) : C(s, β) := ⟨f ∘ coe⟩\n\n@[simp] lemma coe_restrict (f : C(α, β)) : ⇑(f.restrict s) = f ∘ coe := rfl\n\nend restrict\n\nsection gluing\n\nvariables {ι : Type*}\n  (S : ι → set α)\n  (φ : Π i : ι, C(S i, β))\n  (hφ : ∀ i j (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), φ i ⟨x, hxi⟩ = φ j ⟨x, hxj⟩)\n  (hS : ∀ x : α, ∃ i, S i ∈ nhds x)\n\ninclude hφ hS\n\n/-- A family `φ i` of continuous maps `C(S i, β)`, where the domains `S i` contain a neighbourhood\nof each point in `α` and the functions `φ i` agree pairwise on intersections, can be glued to\nconstruct a continuous map in `C(α, β)`. -/\nnoncomputable def lift_cover : C(α, β) :=\nbegin\n  have H : (⋃ i, S i) = set.univ,\n  { rw set.eq_univ_iff_forall,\n    intros x,\n    rw set.mem_Union,\n    obtain ⟨i, hi⟩ := hS x,\n    exact ⟨i, mem_of_mem_nhds hi⟩ },\n  refine ⟨set.lift_cover S (λ i, φ i) hφ H, continuous_subtype_nhds_cover hS _⟩,\n  intros i,\n  convert (φ i).continuous,\n  ext x,\n  exact set.lift_cover_coe x,\nend\n\nvariables {S φ hφ hS}\n\n@[simp] lemma lift_cover_coe {i : ι} (x : S i) : lift_cover S φ hφ hS x = φ i x :=\nset.lift_cover_coe _\n\n@[simp] lemma lift_cover_restrict {i : ι} : (lift_cover S φ hφ hS).restrict (S i) = φ i :=\next $ lift_cover_coe\n\nomit hφ hS\n\nvariables (A : set (set α))\n  (F : Π (s : set α) (hi : s ∈ A), C(s, β))\n  (hF : ∀ s (hs : s ∈ A) t (ht : t ∈ A) (x : α) (hxi : x ∈ s) (hxj : x ∈ t),\n    F s hs ⟨x, hxi⟩ = F t ht ⟨x, hxj⟩)\n  (hA : ∀ x : α, ∃ i ∈ A, i ∈ nhds x)\n\ninclude hF hA\n\n/-- A family `F s` of continuous maps `C(s, β)`, where (1) the domains `s` are taken from a set `A`\nof sets in `α` which contain a neighbourhood of each point in `α` and (2) the functions `F s` agree\npairwise on intersections, can be glued to construct a continuous map in `C(α, β)`. -/\nnoncomputable def lift_cover' : C(α, β) :=\nbegin\n  let S : A → set α := coe,\n  let F : Π i : A, C(i, β) := λ i, F i i.prop,\n  refine lift_cover S F (λ i j, hF i i.prop j j.prop) _,\n  intros x,\n  obtain ⟨s, hs, hsx⟩ := hA x,\n  exact ⟨⟨s, hs⟩, hsx⟩\nend\n\nvariables {A F hF hA}\n\n@[simp] lemma lift_cover_coe' {s : set α} {hs : s ∈ A} (x : s) :\n  lift_cover' A F hF hA x = F s hs x :=\nlet x' : (coe : A → set α) ⟨s, hs⟩ := x in lift_cover_coe x'\n\n@[simp] lemma lift_cover_restrict' {s : set α} {hs : s ∈ A} :\n  (lift_cover' A F hF hA).restrict s = F s hs :=\next $ lift_cover_coe'\n\nend gluing\n\nend continuous_map\n\n/--\nThe forward direction of a homeomorphism, as a bundled continuous map.\n-/\n@[simps]\ndef homeomorph.to_continuous_map {α β : Type*} [topological_space α] [topological_space β]\n  (e : α ≃ₜ β) : C(α, β) := ⟨e⟩\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/continuous_function/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.49124723985015684}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n\nimport topology.continuous_on\n\n/-!\n# Bases of topologies. Countability axioms.\n\nA topological basis on a topological space `t` is a collection of sets,\nsuch that all open sets can be generated as unions of these sets, without the need to take\nfinite intersections of them. This file introduces a framework for dealing with these collections,\nand also what more we can say under certain countability conditions on bases,\nwhich are referred to as first- and second-countable.\nWe also briefly cover the theory of separable spaces, which are those with a countable, dense\nsubset. If a space is second-countable, and also has a countably generated uniformity filter\n(for example, if `t` is a metric space), it will automatically be separable (and indeed, these\nconditions are equivalent in this case).\n\n## Main definitions\n\n* `is_topological_basis s`: The topological space `t` has basis `s`.\n* `separable_space α`: The topological space `t` has a countable, dense subset.\n* `first_countable_topology α`: A topology in which `𝓝 x` is countably generated for every `x`.\n* `second_countable_topology α`: A topology which has a topological basis which is countable.\n\n## Main results\n\n* `first_countable_topology.tendsto_subseq`: In a first-countable space,\n  cluster points are limits of subsequences.\n* `second_countable_topology.is_open_Union_countable`: In a second-countable space, the union of\n  arbitrarily-many open sets is equal to a sub-union of only countably many of these sets.\n* `second_countable_topology.countable_cover_nhds`: Consider `f : α → set α` with the property that\n  `f x ∈ 𝓝 x` for all `x`. Then there is some countable set `s` whose image covers the space.\n\n## Implementation Notes\nFor our applications we are interested that there exists a countable basis, but we do not need the\nconcrete basis itself. This allows us to declare these type classes as `Prop` to use them as mixins.\n\n### TODO:\nMore fine grained instances for `first_countable_topology`, `separable_space`, `t2_space`, and more\n(see the comment below `subtype.second_countable_topology`.)\n-/\n\nopen set filter classical\nopen_locale topological_space filter\nnoncomputable theory\n\nnamespace topological_space\n\nuniverse u\nvariables {α : Type u} [t : topological_space α]\ninclude t\n\n/-- A topological basis is one that satisfies the necessary conditions so that\n  it suffices to take unions of the basis sets to get a topology (without taking\n  finite intersections as well). -/\nstructure is_topological_basis (s : set (set α)) : Prop :=\n(exists_subset_inter : ∀t₁∈s, ∀t₂∈s, ∀ x ∈ t₁ ∩ t₂, ∃ t₃∈s, x ∈ t₃ ∧ t₃ ⊆ t₁ ∩ t₂)\n(sUnion_eq : (⋃₀ s) = univ)\n(eq_generate_from : t = generate_from s)\n\n/-- If a family of sets `s` generates the topology, then nonempty intersections of finite\nsubcollections of `s` form a topological basis. -/\nlemma is_topological_basis_of_subbasis {s : set (set α)} (hs : t = generate_from s) :\n  is_topological_basis ((λ f, ⋂₀ f) '' {f : set (set α) | finite f ∧ f ⊆ s ∧ (⋂₀ f).nonempty}) :=\nbegin\n  refine ⟨_, _, _⟩,\n  { rintro _ ⟨t₁, ⟨hft₁, ht₁b, ht₁⟩, rfl⟩ _ ⟨t₂, ⟨hft₂, ht₂b, ht₂⟩, rfl⟩ x h,\n    have : ⋂₀ (t₁ ∪ t₂) = ⋂₀ t₁ ∩ ⋂₀ t₂ := sInter_union t₁ t₂,\n    exact ⟨_, ⟨t₁ ∪ t₂, ⟨hft₁.union hft₂, union_subset ht₁b ht₂b, this.symm ▸ ⟨x, h⟩⟩, this⟩, h,\n      subset.rfl⟩ },\n  { rw [sUnion_image, bUnion_eq_univ_iff],\n    intro x, have : x ∈ ⋂₀ ∅, { rw sInter_empty, exact mem_univ x },\n    exact ⟨∅, ⟨finite_empty, empty_subset _, x, this⟩, this⟩ },\n  { rw hs,\n    apply le_antisymm; apply le_generate_from,\n    { rintro _ ⟨t, ⟨hft, htb, ht⟩, rfl⟩,\n      exact @is_open_sInter _ (generate_from s) _ hft (λ s hs, generate_open.basic _ $ htb hs) },\n    { intros t ht,\n      rcases t.eq_empty_or_nonempty with rfl|hne, { apply @is_open_empty _ _ },\n      rw ← sInter_singleton t at hne ⊢,\n      exact generate_open.basic _ ⟨{t}, ⟨finite_singleton t, singleton_subset_iff.2 ht, hne⟩,\n        rfl⟩ } }\nend\n\n/-- If a family of open sets `s` is such that every open neighbourhood contains some\nmember of `s`, then `s` is a topological basis. -/\nlemma is_topological_basis_of_open_of_nhds {s : set (set α)}\n  (h_open : ∀ u ∈ s, is_open u)\n  (h_nhds : ∀(a:α) (u : set α), a ∈ u → is_open u → ∃v ∈ s, a ∈ v ∧ v ⊆ u) :\n  is_topological_basis s :=\nbegin\n  refine ⟨λ t₁ ht₁ t₂ ht₂ x hx, h_nhds _ _ hx (is_open_inter (h_open _ ht₁) (h_open _ ht₂)), _, _⟩,\n  { refine sUnion_eq_univ_iff.2 (λ a, _),\n    rcases h_nhds a univ trivial is_open_univ with ⟨u, h₁, h₂, -⟩,\n    exact ⟨u, h₁, h₂⟩ },\n  { refine (le_generate_from h_open).antisymm (λ u hu, _),\n    refine (@is_open_iff_nhds α (generate_from s) u).mpr (λ a ha, _),\n    rcases h_nhds a u ha hu with ⟨v, hvs, hav, hvu⟩,\n    rw nhds_generate_from,\n    exact binfi_le_of_le v ⟨hav, hvs⟩ (le_principal_iff.2 hvu) }\nend\n\n/-- A set `s` is in the neighbourhood of `a` iff there is some basis set `t`, which\ncontains `a` and is itself contained in `s`. -/\nlemma is_topological_basis.mem_nhds_iff {a : α} {s : set α} {b : set (set α)}\n  (hb : is_topological_basis b) : s ∈ 𝓝 a ↔ ∃t∈b, a ∈ t ∧ t ⊆ s :=\nbegin\n  change s ∈ (𝓝 a).sets ↔ ∃t∈b, a ∈ t ∧ t ⊆ s,\n  rw [hb.eq_generate_from, nhds_generate_from, binfi_sets_eq],\n  { simp only [mem_bUnion_iff, exists_prop, mem_set_of_eq, and_assoc, and.left_comm], refl },\n  { exact assume s ⟨hs₁, hs₂⟩ t ⟨ht₁, ht₂⟩,\n      have a ∈ s ∩ t, from ⟨hs₁, ht₁⟩,\n      let ⟨u, hu₁, hu₂, hu₃⟩ := hb.1 _ hs₂ _ ht₂ _ this in\n      ⟨u, ⟨hu₂, hu₁⟩, le_principal_iff.2 (subset.trans hu₃ (inter_subset_left _ _)),\n        le_principal_iff.2 (subset.trans hu₃ (inter_subset_right _ _))⟩ },\n  { rcases eq_univ_iff_forall.1 hb.sUnion_eq a with ⟨i, h1, h2⟩,\n    exact ⟨i, h2, h1⟩ }\nend\n\nlemma is_topological_basis.nhds_has_basis {b : set (set α)} (hb : is_topological_basis b) {a : α} :\n  (𝓝 a).has_basis (λ t : set α, t ∈ b ∧ a ∈ t) (λ t, t) :=\n⟨λ s, hb.mem_nhds_iff.trans $ by simp only [exists_prop, and_assoc]⟩\n\nprotected lemma is_topological_basis.is_open {s : set α} {b : set (set α)}\n  (hb : is_topological_basis b) (hs : s ∈ b) : is_open s :=\nby { rw hb.eq_generate_from, exact generate_open.basic s hs }\n\nlemma is_topological_basis.exists_subset_of_mem_open {b : set (set α)}\n  (hb : is_topological_basis b) {a:α} {u : set α} (au : a ∈ u)\n  (ou : is_open u) : ∃v ∈ b, a ∈ v ∧ v ⊆ u :=\nhb.mem_nhds_iff.1 $ mem_nhds_sets ou au\n\n /-- Any open set is the union of the basis sets contained in it. -/\nlemma is_topological_basis.open_eq_sUnion' {B : set (set α)}\n  (hB : is_topological_basis B) {u : set α} (ou : is_open u) :\n  u = ⋃₀ {s ∈ B | s ⊆ u} :=\next $ λ a,\n⟨λ ha, let ⟨b, hb, ab, bu⟩ := hB.exists_subset_of_mem_open ha ou in ⟨b, ⟨hb, bu⟩, ab⟩,\n  λ ⟨b, ⟨hb, bu⟩, ab⟩, bu ab⟩\n\nlemma is_topological_basis.open_eq_sUnion {B : set (set α)}\n  (hB : is_topological_basis B) {u : set α} (ou : is_open u) :\n  ∃ S ⊆ B, u = ⋃₀ S :=\n⟨{s ∈ B | s ⊆ u}, λ s h, h.1, hB.open_eq_sUnion' ou⟩\n\nlemma is_topological_basis.open_eq_Union {B : set (set α)}\n  (hB : is_topological_basis B) {u : set α} (ou : is_open u) :\n  ∃ (β : Type u) (f : β → set α), u = (⋃ i, f i) ∧ ∀ i, f i ∈ B :=\n⟨↥{s ∈ B | s ⊆ u}, coe, by { rw ← sUnion_eq_Union, apply hB.open_eq_sUnion' ou }, λ s, and.left s.2⟩\n\n /-- A point `a` is in the closure of `s` iff all basis sets containing `a` intersect `s`. -/\nlemma is_topological_basis.mem_closure_iff {b : set (set α)} (hb : is_topological_basis b)\n  {s : set α} {a : α} :\n  a ∈ closure s ↔ ∀ o ∈ b, a ∈ o → (o ∩ s).nonempty :=\n(mem_closure_iff_nhds_basis' hb.nhds_has_basis).trans $ by simp only [and_imp]\n\n /-- A set is dense iff it has non-trivial intersection with all basis sets. -/\nlemma is_topological_basis.dense_iff {b : set (set α)} (hb : is_topological_basis b) {s : set α} :\n  dense s ↔ ∀ o ∈ b, set.nonempty o → (o ∩ s).nonempty :=\nbegin\n  simp only [dense, hb.mem_closure_iff],\n  exact ⟨λ h o hb ⟨a, ha⟩, h a o hb ha, λ h a o hb ha, h o hb ⟨a, ha⟩⟩\nend\n\nprotected lemma is_topological_basis.prod {β} [topological_space β] {B₁ : set (set α)}\n  {B₂ : set (set β)} (h₁ : is_topological_basis B₁) (h₂ : is_topological_basis B₂) :\n  is_topological_basis (image2 set.prod B₁ B₂) :=\nbegin\n  refine is_topological_basis_of_open_of_nhds _ _,\n  { rintro _ ⟨u₁, u₂, hu₁, hu₂, rfl⟩,\n    exact (h₁.is_open hu₁).prod (h₂.is_open hu₂) },\n  { rintro ⟨a, b⟩ u hu uo,\n    rcases (h₁.nhds_has_basis.prod_nhds h₂.nhds_has_basis).mem_iff.1 (mem_nhds_sets uo hu)\n      with ⟨⟨s, t⟩, ⟨⟨hs, ha⟩, ht, hb⟩, hu⟩,\n    exact ⟨s.prod t, mem_image2_of_mem hs ht, ⟨ha, hb⟩, hu⟩ }\nend\n\nlemma is_topological_basis_of_cover {ι} {U  : ι → set α} (Uo : ∀ i, is_open (U i))\n  (Uc : (⋃ i, U i) = univ) {b : Π i, set (set (U i))} (hb : ∀ i, is_topological_basis (b i)) :\n  is_topological_basis (⋃ i : ι, image (coe : U i → α) '' (b i)) :=\nbegin\n  refine is_topological_basis_of_open_of_nhds (λ u hu, _) _,\n  { simp only [mem_Union, mem_image] at hu,\n    rcases hu with ⟨i, s, sb, rfl⟩,\n    exact (Uo i).is_open_map_subtype_coe _ ((hb i).is_open sb) },\n  { intros a u ha uo,\n    rcases Union_eq_univ_iff.1 Uc a with ⟨i, hi⟩,\n    lift a to ↥(U i) using hi,\n    rcases (hb i).exists_subset_of_mem_open (by exact ha) (uo.preimage continuous_subtype_coe)\n      with ⟨v, hvb, hav, hvu⟩,\n    exact ⟨coe '' v, mem_Union.2 ⟨i, mem_image_of_mem _ hvb⟩, mem_image_of_mem _ hav,\n      image_subset_iff.2 hvu⟩ }\nend\n\nvariables (α)\n\n/-- A separable space is one with a countable dense subset, available through\n`topological_space.exists_countable_dense`. If `α` is also known to be nonempty, then\n`topological_space.dense_seq` provides a sequence `ℕ → α` with dense range, see\n`topological_space.dense_range_dense_seq`.\n\nIf `α` is a uniform space with countably generated uniformity filter (e.g., an `emetric_space`),\nthen this condition is equivalent to `topological_space.second_countable_topology α`. In this case\nthe latter should be used as a typeclass argument in theorems because Lean can automatically deduce\n`separable_space` from `second_countable_topology` but it can't deduce `second_countable_topology`\nand `emetric_space`. -/\nclass separable_space : Prop :=\n(exists_countable_dense : ∃s:set α, countable s ∧ dense s)\n\nlemma exists_countable_dense [separable_space α] :\n  ∃ s : set α, countable s ∧ dense s :=\nseparable_space.exists_countable_dense\n\n/-- A nonempty separable space admits a sequence with dense range. Instead of running `cases` on the\nconclusion of this lemma, you might want to use `topological_space.dense_seq` and\n`topological_space.dense_range_dense_seq`.\n\nIf `α` might be empty, then `exists_countable_dense` is the main way to use separability of `α`. -/\nlemma exists_dense_seq [separable_space α] [nonempty α] : ∃ u : ℕ → α, dense_range u :=\nbegin\n  obtain ⟨s : set α, hs, s_dense⟩ := exists_countable_dense α,\n  cases countable_iff_exists_surjective.mp hs with u hu,\n  exact ⟨u, s_dense.mono hu⟩,\nend\n\n/-- A dense sequence in a non-empty separable topological space.\n\nIf `α` might be empty, then `exists_countable_dense` is the main way to use separability of `α`. -/\ndef dense_seq [separable_space α] [nonempty α] : ℕ → α := classical.some (exists_dense_seq α)\n\n/-- The sequence `dense_seq α` has dense range. -/\n@[simp] lemma dense_range_dense_seq [separable_space α] [nonempty α] :\n  dense_range (dense_seq α) := classical.some_spec (exists_dense_seq α)\n\nend topological_space\n\nopen topological_space\n\n/-- If `α` is a separable space and `f : α → β` is a continuous map with dense range, then `β` is\na separable space as well. E.g., the completion of a separable uniform space is separable. -/\nprotected lemma dense_range.separable_space {α β : Type*} [topological_space α] [separable_space α]\n  [topological_space β] {f : α → β} (h : dense_range f) (h' : continuous f) :\n  separable_space β :=\nlet ⟨s, s_cnt, s_dense⟩ := exists_countable_dense α in\n⟨⟨f '' s, countable.image s_cnt f, h.dense_image h' s_dense⟩⟩\n\nnamespace topological_space\nuniverse u\nvariables (α : Type u) [t : topological_space α]\ninclude t\n\n\n/-- A first-countable space is one in which every point has a\n  countable neighborhood basis. -/\nclass first_countable_topology : Prop :=\n(nhds_generated_countable : ∀a:α, (𝓝 a).is_countably_generated)\n\nnamespace first_countable_topology\nvariable {α}\n\n/-- In a first-countable space, a cluster point `x` of a sequence\nis the limit of some subsequence. -/\nlemma tendsto_subseq [first_countable_topology α] {u : ℕ → α} {x : α}\n  (hx : map_cluster_pt x at_top u) :\n  ∃ (ψ : ℕ → ℕ), (strict_mono ψ) ∧ (tendsto (u ∘ ψ) at_top (𝓝 x)) :=\n(nhds_generated_countable x).subseq_tendsto hx\n\nend first_countable_topology\n\nvariables {α}\n\nlemma is_countably_generated_nhds [first_countable_topology α] (x : α) :\n  is_countably_generated (𝓝 x) :=\nfirst_countable_topology.nhds_generated_countable x\n\nlemma is_countably_generated_nhds_within [first_countable_topology α] (x : α) (s : set α) :\n  is_countably_generated (𝓝[s] x) :=\n(is_countably_generated_nhds x).inf_principal s\n\nvariable (α)\n\n/-- A second-countable space is one with a countable basis. -/\nclass second_countable_topology : Prop :=\n(is_open_generated_countable [] :\n  ∃ b : set (set α), countable b ∧ t = topological_space.generate_from b)\n\nvariable {α}\n\nprotected lemma is_topological_basis.second_countable_topology\n  {b : set (set α)} (hb : is_topological_basis b) (hc : countable b) :\n  second_countable_topology α :=\n⟨⟨b, hc, hb.eq_generate_from⟩⟩\n\nvariable (α)\n\nlemma exists_countable_basis [second_countable_topology α] :\n  ∃b:set (set α), countable b ∧ ∅ ∉ b ∧ is_topological_basis b :=\nlet ⟨b, hb₁, hb₂⟩ := second_countable_topology.is_open_generated_countable α in\nlet b' := (λs, ⋂₀ s) '' {s:set (set α) | finite s ∧ s ⊆ b ∧ (⋂₀ s).nonempty} in\n⟨b',\n  ((countable_set_of_finite_subset hb₁).mono\n    (by { simp only [← and_assoc], apply inter_subset_left })).image _,\n  assume ⟨s, ⟨_, _, hn⟩, hp⟩, absurd hn (not_nonempty_iff_eq_empty.2 hp),\n  is_topological_basis_of_subbasis hb₂⟩\n\n/-- A countable topological basis of `α`. -/\ndef countable_basis [second_countable_topology α] : set (set α) :=\n(exists_countable_basis α).some\n\nlemma countable_countable_basis [second_countable_topology α] : countable (countable_basis α) :=\n(exists_countable_basis α).some_spec.1\n\ninstance encodable_countable_basis [second_countable_topology α] :\n  encodable (countable_basis α) :=\n(countable_countable_basis α).to_encodable\n\nlemma empty_nmem_countable_basis [second_countable_topology α] : ∅ ∉ countable_basis α :=\n(exists_countable_basis α).some_spec.2.1\n\nlemma is_basis_countable_basis [second_countable_topology α] :\n  is_topological_basis (countable_basis α) :=\n(exists_countable_basis α).some_spec.2.2\n\nlemma eq_generate_from_countable_basis [second_countable_topology α] :\n  ‹topological_space α› = generate_from (countable_basis α) :=\n(is_basis_countable_basis α).eq_generate_from\n\nvariable {α}\n\nlemma is_open_of_mem_countable_basis [second_countable_topology α] {s : set α}\n  (hs : s ∈ countable_basis α) : is_open s :=\n(is_basis_countable_basis α).is_open hs\n\nlemma nonempty_of_mem_countable_basis [second_countable_topology α] {s : set α}\n  (hs : s ∈ countable_basis α) : s.nonempty :=\nne_empty_iff_nonempty.1 $ ne_of_mem_of_not_mem hs $ empty_nmem_countable_basis α\n\nvariable (α)\n\n@[priority 100] -- see Note [lower instance priority]\ninstance second_countable_topology.to_first_countable_topology\n  [second_countable_topology α] : first_countable_topology α :=\n⟨λ x, has_countable_basis.is_countably_generated $\n  ⟨(is_basis_countable_basis α).nhds_has_basis, (countable_countable_basis α).mono $\n    inter_subset_left _ _⟩⟩\n\n/-- If `β` is a second-countable space, then its induced topology\nvia `f` on `α` is also second-countable. -/\nlemma second_countable_topology_induced (β)\n  [t : topological_space β] [second_countable_topology β] (f : α → β) :\n  @second_countable_topology α (t.induced f) :=\nbegin\n  rcases second_countable_topology.is_open_generated_countable β with ⟨b, hb, eq⟩,\n  refine { is_open_generated_countable := ⟨preimage f '' b, hb.image _, _⟩ },\n  rw [eq, induced_generate_from_eq]\nend\n\ninstance subtype.second_countable_topology (s : set α) [second_countable_topology α] :\n  second_countable_topology s :=\nsecond_countable_topology_induced s α coe\n\n/- TODO: more fine grained instances for first_countable_topology, separable_space, t2_space, ... -/\ninstance {β : Type*} [topological_space β]\n  [second_countable_topology α] [second_countable_topology β] : second_countable_topology (α × β) :=\n((is_basis_countable_basis α).prod (is_basis_countable_basis β)).second_countable_topology $\n  (countable_countable_basis α).image2 (countable_countable_basis β) _\n\ninstance second_countable_topology_fintype {ι : Type*} {π : ι → Type*}\n  [fintype ι] [t : ∀a, topological_space (π a)] [sc : ∀a, second_countable_topology (π a)] :\n  second_countable_topology (∀a, π a) :=\nbegin\n  have : t = (λa, generate_from (countable_basis (π a))),\n    from funext (assume a, (is_basis_countable_basis (π a)).eq_generate_from),\n  rw this,\n  constructor,\n  refine ⟨pi univ '' pi univ (λ a, countable_basis (π a)), countable.image _ _, _⟩,\n  { suffices : countable {f : Πa, set (π a) | ∀a, f a ∈ countable_basis (π a)}, { simpa [pi] },\n    exact countable_pi (assume i, (countable_countable_basis _)), },\n  rw [pi_generate_from_eq_fintype],\n  { congr' 1 with f, simp [pi, eq_comm] },\n  exact assume a, (is_basis_countable_basis (π a)).sUnion_eq\nend\n\n@[priority 100] -- see Note [lower instance priority]\ninstance second_countable_topology.to_separable_space\n  [second_countable_topology α] : separable_space α :=\nbegin\n  choose p hp using λ s : countable_basis α, nonempty_of_mem_countable_basis s.2,\n  exact ⟨⟨range p, countable_range _,\n    (is_basis_countable_basis α).dense_iff.2 $ λ o ho _, ⟨p ⟨o, ho⟩, hp _, mem_range_self _⟩⟩⟩\nend\n\nvariables {α}\n\n/-- A countable open cover induces a second-countable topology if all open covers\nare themselves second countable. -/\nlemma second_countable_topology_of_countable_cover {ι} [encodable ι] {U : ι → set α}\n  [∀ i, second_countable_topology (U i)] (Uo : ∀ i, is_open (U i))  (hc : (⋃ i, U i) = univ) :\n  second_countable_topology α :=\nbegin\n  have : is_topological_basis (⋃ i, image (coe : U i → α) '' (countable_basis (U i))),\n    from is_topological_basis_of_cover Uo hc (λ i, is_basis_countable_basis (U i)),\n  exact this.second_countable_topology\n    (countable_Union $ λ i, (countable_countable_basis _).image _)\nend\n\n/-- In a second-countable space, an open set, given as a union of open sets,\nis equal to the union of countably many of those sets. -/\nlemma is_open_Union_countable [second_countable_topology α]\n  {ι} (s : ι → set α) (H : ∀ i, is_open (s i)) :\n  ∃ T : set ι, countable T ∧ (⋃ i ∈ T, s i) = ⋃ i, s i :=\nbegin\n  let B := {b ∈ countable_basis α | ∃ i, b ⊆ s i},\n  choose f hf using λ b : B, b.2.2,\n  haveI : encodable B := ((countable_countable_basis α).mono (sep_subset _ _)).to_encodable,\n  refine ⟨_, countable_range f,\n    subset.antisymm (bUnion_subset_Union _ _) (sUnion_subset _)⟩,\n  rintro _ ⟨i, rfl⟩ x xs,\n  rcases (is_basis_countable_basis α).exists_subset_of_mem_open xs (H _) with ⟨b, hb, xb, bs⟩,\n  exact ⟨_, ⟨_, rfl⟩, _, ⟨⟨⟨_, hb, _, bs⟩, rfl⟩, rfl⟩, hf _ (by exact xb)⟩\nend\n\nlemma is_open_sUnion_countable [second_countable_topology α]\n  (S : set (set α)) (H : ∀ s ∈ S, is_open s) :\n  ∃ T : set (set α), countable T ∧ T ⊆ S ∧ ⋃₀ T = ⋃₀ S :=\nlet ⟨T, cT, hT⟩ := is_open_Union_countable (λ s:S, s.1) (λ s, H s.1 s.2) in\n⟨subtype.val '' T, cT.image _,\n  image_subset_iff.2 $ λ ⟨x, xs⟩ xt, xs,\n  by rwa [sUnion_image, sUnion_eq_Union]⟩\n\n/-- In a topological space with second countable topology, if `f` is a function that sends each\npoint `x` to a neighborhood of `x`, then for some countable set `s`, the neighborhoods `f x`,\n`x ∈ s`, cover the whole space. -/\nlemma countable_cover_nhds [second_countable_topology α] {f : α → set α}\n  (hf : ∀ x, f x ∈ 𝓝 x) : ∃ s : set α, countable s ∧ (⋃ x ∈ s, f x) = univ :=\nbegin\n  rcases is_open_Union_countable (λ x, interior (f x)) (λ x, is_open_interior) with ⟨s, hsc, hsU⟩,\n  suffices : (⋃ x ∈ s, interior (f x)) = univ,\n    from ⟨s, hsc, flip eq_univ_of_subset this (bUnion_mono $ λ _ _, interior_subset)⟩,\n  simp only [hsU, eq_univ_iff_forall, mem_Union],\n  exact λ x, ⟨x, mem_interior_iff_mem_nhds.2 (hf x)⟩\nend\n\nend topological_space\n\nopen topological_space\n\nvariables {α β : Type*} [topological_space α] [topological_space β] {f : α → β}\n\nprotected lemma inducing.second_countable_topology [second_countable_topology β]\n  (hf : inducing f) : second_countable_topology α :=\nby { rw hf.1, exact second_countable_topology_induced α β f }\n\nprotected lemma embedding.second_countable_topology [second_countable_topology β]\n  (hf : embedding f) : second_countable_topology α :=\nhf.1.second_countable_topology\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/bases.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6992544085240401, "lm_q1q2_score": 0.4912472397542442}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.punit\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Functor.Const\nimport Mathbin.CategoryTheory.DiscreteCategory\n\n/-!\n# The category `discrete punit`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define `star : C ⥤ discrete punit` sending everything to `punit.star`,\nshow that any two functors to `discrete punit` are naturally isomorphic,\nand construct the equivalence `(discrete punit ⥤ C) ≌ C`.\n-/\n\n\nuniverse v u\n\n-- morphism levels before object levels. See note [category_theory universes].\nnamespace CategoryTheory\n\nvariable (C : Type u) [Category.{v} C]\n\nnamespace Functor\n\n#print CategoryTheory.Functor.star /-\n/-- The constant functor sending everything to `punit.star`. -/\n@[simps]\ndef star : C ⥤ Discrete PUnit :=\n  (Functor.const _).obj ⟨⟨⟩⟩\n#align category_theory.functor.star CategoryTheory.Functor.star\n-/\n\nvariable {C}\n\n#print CategoryTheory.Functor.pUnitExt /-\n/-- Any two functors to `discrete punit` are isomorphic. -/\n@[simps]\ndef pUnitExt (F G : C ⥤ Discrete PUnit) : F ≅ G :=\n  NatIso.ofComponents (fun _ => eqToIso (by decide)) fun _ _ _ => by decide\n#align category_theory.functor.punit_ext CategoryTheory.Functor.pUnitExt\n-/\n\n/- warning: category_theory.functor.punit_ext' -> CategoryTheory.Functor.pUnit_ext' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] (F : CategoryTheory.Functor.{u1, u3, u2, u3} C _inst_1 (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3})) (G : CategoryTheory.Functor.{u1, u3, u2, u3} C _inst_1 (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3})), Eq.{succ (max u1 u2 u3)} (CategoryTheory.Functor.{u1, u3, u2, u3} C _inst_1 (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3})) F G\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u2, u3} C] (F : CategoryTheory.Functor.{u2, u1, u3, u1} C _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1})) (G : CategoryTheory.Functor.{u2, u1, u3, u1} C _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1})), Eq.{max (max (succ u3) (succ u2)) (succ u1)} (CategoryTheory.Functor.{u2, u1, u3, u1} C _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1})) F G\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.punit_ext' CategoryTheory.Functor.pUnit_ext'ₓ'. -/\n/-- Any two functors to `discrete punit` are *equal*.\nYou probably want to use `punit_ext` instead of this.\n-/\ntheorem pUnit_ext' (F G : C ⥤ Discrete PUnit) : F = G :=\n  Functor.ext (fun _ => by decide) fun _ _ _ => by decide\n#align category_theory.functor.punit_ext' CategoryTheory.Functor.pUnit_ext'\n\n#print CategoryTheory.Functor.fromPUnit /-\n/-- The functor from `discrete punit` sending everything to the given object. -/\nabbrev fromPUnit (X : C) : Discrete PUnit.{v + 1} ⥤ C :=\n  (Functor.const _).obj X\n#align category_theory.functor.from_punit CategoryTheory.Functor.fromPUnit\n-/\n\n/- warning: category_theory.functor.equiv -> CategoryTheory.Functor.equiv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{max u3 u1, u1, max u3 u1 u3 u2, u2} (CategoryTheory.Functor.{u3, u1, u3, u2} (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3}) C _inst_1) (CategoryTheory.Functor.category.{u3, u1, u3, u2} (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3}) C _inst_1) C _inst_1\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{max u1 u3, u1, max (max (max u2 u3) u1) u3, u2} (CategoryTheory.Functor.{u3, u1, u3, u2} (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3}) C _inst_1) C (CategoryTheory.Functor.category.{u3, u1, u3, u2} (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3}) C _inst_1) _inst_1\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.equiv CategoryTheory.Functor.equivₓ'. -/\n/-- Functors from `discrete punit` are equivalent to the category itself. -/\n@[simps]\ndef equiv : Discrete PUnit ⥤ C ≌ C\n    where\n  Functor :=\n    { obj := fun F => F.obj ⟨⟨⟩⟩\n      map := fun F G θ => θ.app ⟨⟨⟩⟩ }\n  inverse := Functor.const _\n  unitIso := by\n    apply nat_iso.of_components _ _\n    intro X\n    apply discrete.nat_iso\n    rintro ⟨⟨⟩⟩\n    apply iso.refl _\n    intros\n    ext ⟨⟨⟩⟩\n    simp\n  counitIso := by\n    refine' nat_iso.of_components iso.refl _\n    intro X Y f\n    dsimp; simp\n#align category_theory.functor.equiv CategoryTheory.Functor.equiv\n\n-- See note [dsimp, simp].\nend Functor\n\n/- warning: category_theory.equiv_punit_iff_unique -> CategoryTheory.equiv_pUnit_iff_unique is a dubious translation:\nlean 3 declaration is\n  forall (C : Type.{u2}) [_inst_1 : CategoryTheory.Category.{u1, u2} C], Iff (Nonempty.{max (succ u2) (succ u1) (succ u3)} (CategoryTheory.Equivalence.{u1, u3, u2, u3} C _inst_1 (CategoryTheory.Discrete.{u3} PUnit.{succ u3}) (CategoryTheory.discreteCategory.{u3} PUnit.{succ u3}))) (And (Nonempty.{succ u2} C) (forall (x : C) (y : C), Nonempty.{succ u1} (Unique.{succ u1} (Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) x y))))\nbut is expected to have type\n  forall (C : Type.{u3}) [_inst_1 : CategoryTheory.Category.{u2, u3} C], Iff (Nonempty.{max (max (succ u1) (succ u3)) (succ u2)} (CategoryTheory.Equivalence.{u2, u1, u3, u1} C (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) _inst_1 (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) (And (Nonempty.{succ u3} C) (forall (x : C) (y : C), Nonempty.{succ u2} (Unique.{succ u2} (Quiver.Hom.{succ u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) x y))))\nCase conversion may be inaccurate. Consider using '#align category_theory.equiv_punit_iff_unique CategoryTheory.equiv_pUnit_iff_uniqueₓ'. -/\n/-- A category being equivalent to `punit` is equivalent to it having a unique morphism between\n  any two objects. (In fact, such a category is also a groupoid; see `groupoid.of_hom_unique`) -/\ntheorem equiv_pUnit_iff_unique :\n    Nonempty (C ≌ Discrete PUnit) ↔ Nonempty C ∧ ∀ x y : C, Nonempty <| Unique (x ⟶ y) :=\n  by\n  constructor\n  · rintro ⟨h⟩\n    refine' ⟨⟨h.inverse.obj ⟨⟨⟩⟩⟩, fun x y => Nonempty.intro _⟩\n    apply uniqueOfSubsingleton _\n    swap\n    · have hx : x ⟶ h.inverse.obj ⟨⟨⟩⟩ := by convert h.unit.app x\n      have hy : h.inverse.obj ⟨⟨⟩⟩ ⟶ y := by convert h.unit_inv.app y\n      exact hx ≫ hy\n    have : ∀ z, z = h.unit.app x ≫ (h.functor ⋙ h.inverse).map z ≫ h.unit_inv.app y :=\n      by\n      intro z\n      simpa using congr_arg (· ≫ h.unit_inv.app y) (h.unit.naturality z)\n    apply Subsingleton.intro\n    intro a b\n    rw [this a, this b]\n    simp only [functor.comp_map]\n    congr\n  · rintro ⟨⟨p⟩, h⟩\n    haveI := fun x y => (h x y).some\n    refine'\n      Nonempty.intro\n        (CategoryTheory.Equivalence.mk ((Functor.Const _).obj ⟨⟨⟩⟩) ((Functor.Const _).obj p) _\n          (by apply functor.punit_ext))\n    exact\n      nat_iso.of_components\n        (fun _ =>\n          { Hom := default\n            inv := default })\n        fun _ _ _ => by tidy\n#align category_theory.equiv_punit_iff_unique CategoryTheory.equiv_pUnit_iff_unique\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Punit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.4912472354471487}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module algebra.homology.image_to_kernel\n! leanprover-community/mathlib commit 618ea3d5c99240cd7000d8376924906a148bf9ff\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Subobject.Limits\n\n/-!\n# Image-to-kernel comparison maps\n\nWhenever `f : A ⟶ B` and `g : B ⟶ C` satisfy `w : f ≫ g = 0`,\nwe have `image_le_kernel f g w : image_subobject f ≤ kernel_subobject g`\n(assuming the appropriate images and kernels exist).\n\n`image_to_kernel f g w` is the corresponding morphism between objects in `C`.\n\nWe define `homology f g w` of such a pair as the cokernel of `image_to_kernel f g w`.\n-/\n\n\nuniverse v u\n\nopen CategoryTheory CategoryTheory.Limits\n\nvariable {ι : Type _}\n\nvariable {V : Type u} [Category.{v} V] [HasZeroMorphisms V]\n\nopen Classical\n\nnoncomputable section\n\nsection\n\nvariable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g]\n\ntheorem image_le_kernel (w : f ≫ g = 0) : imageSubobject f ≤ kernelSubobject g :=\n  imageSubobject_le_mk _ _ (kernel.lift _ _ w) (by simp)\n#align image_le_kernel image_le_kernel\n\n/-- The canonical morphism `image_subobject f ⟶ kernel_subobject g` when `f ≫ g = 0`.\n-/\ndef imageToKernel (w : f ≫ g = 0) : (imageSubobject f : V) ⟶ (kernelSubobject g : V) :=\n  Subobject.ofLe _ _ (image_le_kernel _ _ w)deriving Mono\n#align image_to_kernel imageToKernel\n\n/-- Prefer `image_to_kernel`. -/\n@[simp]\ntheorem subobject_ofLe_as_imageToKernel (w : f ≫ g = 0) (h) :\n    Subobject.ofLe (imageSubobject f) (kernelSubobject g) h = imageToKernel f g w :=\n  rfl\n#align subobject_of_le_as_image_to_kernel subobject_ofLe_as_imageToKernel\n\n@[simp, reassoc.1, elementwise]\ntheorem imageToKernel_arrow (w : f ≫ g = 0) :\n    imageToKernel f g w ≫ (kernelSubobject g).arrow = (imageSubobject f).arrow := by\n  simp [imageToKernel]\n#align image_to_kernel_arrow imageToKernel_arrow\n\n-- This is less useful as a `simp` lemma than it initially appears,\n-- as it \"loses\" the information the morphism factors through the image.\ntheorem factorThruImageSubobject_comp_imageToKernel (w : f ≫ g = 0) :\n    factorThruImageSubobject f ≫ imageToKernel f g w = factorThruKernelSubobject g f w :=\n  by\n  ext\n  simp\n#align factor_thru_image_subobject_comp_image_to_kernel factorThruImageSubobject_comp_imageToKernel\n\nend\n\nsection\n\nvariable {A B C : V} (f : A ⟶ B) (g : B ⟶ C)\n\n@[simp]\ntheorem imageToKernel_zero_left [HasKernels V] [HasZeroObject V] {w} :\n    imageToKernel (0 : A ⟶ B) g w = 0 := by\n  ext\n  simp\n#align image_to_kernel_zero_left imageToKernel_zero_left\n\ntheorem imageToKernel_zero_right [HasImages V] {w} :\n    imageToKernel f (0 : B ⟶ C) w =\n      (imageSubobject f).arrow ≫ inv (kernelSubobject (0 : B ⟶ C)).arrow :=\n  by\n  ext\n  simp\n#align image_to_kernel_zero_right imageToKernel_zero_right\n\nsection\n\nvariable [HasKernels V] [HasImages V]\n\ntheorem imageToKernel_comp_right {D : V} (h : C ⟶ D) (w : f ≫ g = 0) :\n    imageToKernel f (g ≫ h) (by simp [reassoc_of w]) =\n      imageToKernel f g w ≫ Subobject.ofLe _ _ (kernelSubobject_comp_le g h) :=\n  by\n  ext\n  simp\n#align image_to_kernel_comp_right imageToKernel_comp_right\n\ntheorem imageToKernel_comp_left {Z : V} (h : Z ⟶ A) (w : f ≫ g = 0) :\n    imageToKernel (h ≫ f) g (by simp [w]) =\n      Subobject.ofLe _ _ (imageSubobject_comp_le h f) ≫ imageToKernel f g w :=\n  by\n  ext\n  simp\n#align image_to_kernel_comp_left imageToKernel_comp_left\n\n@[simp]\ntheorem imageToKernel_comp_mono {D : V} (h : C ⟶ D) [Mono h] (w) :\n    imageToKernel f (g ≫ h) w =\n      imageToKernel f g ((cancel_mono h).mp (by simpa using w : (f ≫ g) ≫ h = 0 ≫ h)) ≫\n        (Subobject.isoOfEq _ _ (kernelSubobject_comp_mono g h)).inv :=\n  by\n  ext\n  simp\n#align image_to_kernel_comp_mono imageToKernel_comp_mono\n\n@[simp]\ntheorem imageToKernel_epi_comp {Z : V} (h : Z ⟶ A) [Epi h] (w) :\n    imageToKernel (h ≫ f) g w =\n      Subobject.ofLe _ _ (imageSubobject_comp_le h f) ≫\n        imageToKernel f g ((cancel_epi h).mp (by simpa using w : h ≫ f ≫ g = h ≫ 0)) :=\n  by\n  ext\n  simp\n#align image_to_kernel_epi_comp imageToKernel_epi_comp\n\nend\n\n@[simp]\ntheorem imageToKernel_comp_hom_inv_comp [HasEqualizers V] [HasImages V] {Z : V} {i : B ≅ Z} (w) :\n    imageToKernel (f ≫ i.Hom) (i.inv ≫ g) w =\n      (imageSubobjectCompIso _ _).Hom ≫\n        imageToKernel f g (by simpa using w) ≫ (kernelSubobjectIsoComp i.inv g).inv :=\n  by\n  ext\n  simp\n#align image_to_kernel_comp_hom_inv_comp imageToKernel_comp_hom_inv_comp\n\nopen ZeroObject\n\n/-- `image_to_kernel` for `A --0--> B --g--> C`, where `g` is a mono is itself an epi\n(i.e. the sequence is exact at `B`).\n-/\ninstance imageToKernel_epi_of_zero_of_mono [HasKernels V] [HasZeroObject V] [Mono g] :\n    Epi (imageToKernel (0 : A ⟶ B) g (by simp)) :=\n  epi_of_target_iso_zero _ (kernelSubobjectIso g ≪≫ kernel.ofMono g)\n#align image_to_kernel_epi_of_zero_of_mono imageToKernel_epi_of_zero_of_mono\n\n/-- `image_to_kernel` for `A --f--> B --0--> C`, where `g` is an epi is itself an epi\n(i.e. the sequence is exact at `B`).\n-/\ninstance imageToKernel_epi_of_epi_of_zero [HasImages V] [Epi f] :\n    Epi (imageToKernel f (0 : B ⟶ C) (by simp)) :=\n  by\n  simp only [imageToKernel_zero_right]\n  haveI := epi_image_of_epi f\n  rw [← image_subobject_arrow]\n  refine' @epi_comp _ _ _ _ _ _ (epi_comp _ _) _ _\n#align image_to_kernel_epi_of_epi_of_zero imageToKernel_epi_of_epi_of_zero\n\nend\n\nsection\n\nvariable {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g]\n\n/-- The homology of a pair of morphisms `f : A ⟶ B` and `g : B ⟶ C` satisfying `f ≫ g = 0`\nis the cokernel of the `image_to_kernel` morphism for `f` and `g`.\n-/\ndef homology {A B C : V} (f : A ⟶ B) [HasImage f] (g : B ⟶ C) [HasKernel g] (w : f ≫ g = 0)\n    [HasCokernel (imageToKernel f g w)] : V :=\n  cokernel (imageToKernel f g w)\n#align homology homology\n\nsection\n\nvariable (w : f ≫ g = 0) [HasCokernel (imageToKernel f g w)]\n\n/-- The morphism from cycles to homology. -/\ndef homology.π : (kernelSubobject g : V) ⟶ homology f g w :=\n  cokernel.π _\n#align homology.π homology.π\n\n@[simp]\ntheorem homology.condition : imageToKernel f g w ≫ homology.π f g w = 0 :=\n  cokernel.condition _\n#align homology.condition homology.condition\n\n/-- To construct a map out of homology, it suffices to construct a map out of the cycles\nwhich vanishes on boundaries.\n-/\ndef homology.desc {D : V} (k : (kernelSubobject g : V) ⟶ D) (p : imageToKernel f g w ≫ k = 0) :\n    homology f g w ⟶ D :=\n  cokernel.desc _ k p\n#align homology.desc homology.desc\n\n@[simp, reassoc.1, elementwise]\ntheorem homology.π_desc {D : V} (k : (kernelSubobject g : V) ⟶ D)\n    (p : imageToKernel f g w ≫ k = 0) : homology.π f g w ≫ homology.desc f g w k p = k := by\n  simp [homology.π, homology.desc]\n#align homology.π_desc homology.π_desc\n\n/-- To check two morphisms out of `homology f g w` are equal, it suffices to check on cycles. -/\n@[ext]\ntheorem homology.ext {D : V} {k k' : homology f g w ⟶ D}\n    (p : homology.π f g w ≫ k = homology.π f g w ≫ k') : k = k' :=\n  by\n  ext\n  exact p\n#align homology.ext homology.ext\n\n/-- The cokernel of the map `Im f ⟶ Ker 0` is isomorphic to the cokernel of `f.` -/\ndef homologyOfZeroRight [HasCokernel (imageToKernel f (0 : B ⟶ C) comp_zero)] [HasCokernel f]\n    [HasCokernel (image.ι f)] [Epi (factorThruImage f)] :\n    homology f (0 : B ⟶ C) comp_zero ≅ cokernel f :=\n  (cokernel.mapIso _ _ (imageSubobjectIso _) ((kernelSubobjectIso 0).trans kernelZeroIsoSource)\n        (by simp)).trans\n    (cokernelImageι _)\n#align homology_of_zero_right homologyOfZeroRight\n\n/-- The kernel of the map `Im 0 ⟶ Ker f` is isomorphic to the kernel of `f.` -/\ndef homologyOfZeroLeft [HasZeroObject V] [HasKernels V] [HasImage (0 : A ⟶ B)]\n    [HasCokernel (imageToKernel (0 : A ⟶ B) g zero_comp)] :\n    homology (0 : A ⟶ B) g zero_comp ≅ kernel g :=\n  ((cokernelIsoOfEq <| imageToKernel_zero_left _).trans cokernelZeroIsoTarget).trans\n    (kernelSubobjectIso _)\n#align homology_of_zero_left homologyOfZeroLeft\n\n/-- `homology 0 0 _` is just the middle object. -/\n@[simps]\ndef homologyZeroZero [HasZeroObject V] [HasImage (0 : A ⟶ B)]\n    [HasCokernel (imageToKernel (0 : A ⟶ B) (0 : B ⟶ C) (by simp))] :\n    homology (0 : A ⟶ B) (0 : B ⟶ C) (by simp) ≅ B\n    where\n  Hom := homology.desc (0 : A ⟶ B) (0 : B ⟶ C) (by simp) (kernelSubobject 0).arrow (by simp)\n  inv := inv (kernelSubobject 0).arrow ≫ homology.π _ _ _\n#align homology_zero_zero homologyZeroZero\n\nend\n\nsection\n\nvariable {f g} (w : f ≫ g = 0) {A' B' C' : V} {f' : A' ⟶ B'} [HasImage f'] {g' : B' ⟶ C'}\n  [HasKernel g'] (w' : f' ≫ g' = 0) (α : Arrow.mk f ⟶ Arrow.mk f') [HasImageMap α]\n  (β : Arrow.mk g ⟶ Arrow.mk g') {A₁ B₁ C₁ : V} {f₁ : A₁ ⟶ B₁} [HasImage f₁] {g₁ : B₁ ⟶ C₁}\n  [HasKernel g₁] (w₁ : f₁ ≫ g₁ = 0) {A₂ B₂ C₂ : V} {f₂ : A₂ ⟶ B₂} [HasImage f₂] {g₂ : B₂ ⟶ C₂}\n  [HasKernel g₂] (w₂ : f₂ ≫ g₂ = 0) {A₃ B₃ C₃ : V} {f₃ : A₃ ⟶ B₃} [HasImage f₃] {g₃ : B₃ ⟶ C₃}\n  [HasKernel g₃] (w₃ : f₃ ≫ g₃ = 0) (α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂) [HasImageMap α₁]\n  (β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂) (α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃) [HasImageMap α₂]\n  (β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃)\n\n/-- Given compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f ≫ g = 0` and `f' ≫ g' = 0`,\nthe `image_to_kernel` morphisms intertwine the induced map on kernels and the induced map on images.\n-/\n@[reassoc.1]\ntheorem imageSubobjectMap_comp_imageToKernel (p : α.right = β.left) :\n    imageToKernel f g w ≫ kernelSubobjectMap β = imageSubobjectMap α ≫ imageToKernel f' g' w' :=\n  by\n  ext\n  simp [p]\n#align image_subobject_map_comp_image_to_kernel imageSubobjectMap_comp_imageToKernel\n\nvariable [HasCokernel (imageToKernel f g w)] [HasCokernel (imageToKernel f' g' w')]\n\nvariable [HasCokernel (imageToKernel f₁ g₁ w₁)]\n\nvariable [HasCokernel (imageToKernel f₂ g₂ w₂)]\n\nvariable [HasCokernel (imageToKernel f₃ g₃ w₃)]\n\n/-- Given compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f ≫ g = 0` and `f' ≫ g' = 0`,\nwe get a morphism on homology.\n-/\ndef homology.map (p : α.right = β.left) : homology f g w ⟶ homology f' g' w' :=\n  cokernel.desc _ (kernelSubobjectMap β ≫ cokernel.π _)\n    (by\n      rw [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p]\n      simp only [cokernel.condition, comp_zero])\n#align homology.map homology.map\n\n@[simp, reassoc.1, elementwise]\ntheorem homology.π_map (p : α.right = β.left) :\n    homology.π f g w ≫ homology.map w w' α β p = kernelSubobjectMap β ≫ homology.π f' g' w' := by\n  simp only [homology.π, homology.map, cokernel.π_desc]\n#align homology.π_map homology.π_map\n\n@[simp, reassoc.1, elementwise]\ntheorem homology.map_desc (p : α.right = β.left) {D : V} (k : (kernelSubobject g' : V) ⟶ D)\n    (z : imageToKernel f' g' w' ≫ k = 0) :\n    homology.map w w' α β p ≫ homology.desc f' g' w' k z =\n      homology.desc f g w (kernelSubobjectMap β ≫ k)\n        (by simp only [imageSubobjectMap_comp_imageToKernel_assoc w w' α β p, z, comp_zero]) :=\n  by ext <;> simp only [homology.π_desc, homology.π_map_assoc]\n#align homology.map_desc homology.map_desc\n\n@[simp]\ntheorem homology.map_id : homology.map w w (𝟙 _) (𝟙 _) rfl = 𝟙 _ := by\n  ext <;> simp only [homology.π_map, kernel_subobject_map_id, category.id_comp, category.comp_id]\n#align homology.map_id homology.map_id\n\n/-- Auxiliary lemma for homology computations. -/\ntheorem homology.comp_right_eq_comp_left {V : Type _} [Category V] {A₁ B₁ C₁ A₂ B₂ C₂ A₃ B₃ C₃ : V}\n    {f₁ : A₁ ⟶ B₁} {g₁ : B₁ ⟶ C₁} {f₂ : A₂ ⟶ B₂} {g₂ : B₂ ⟶ C₂} {f₃ : A₃ ⟶ B₃} {g₃ : B₃ ⟶ C₃}\n    {α₁ : Arrow.mk f₁ ⟶ Arrow.mk f₂} {β₁ : Arrow.mk g₁ ⟶ Arrow.mk g₂}\n    {α₂ : Arrow.mk f₂ ⟶ Arrow.mk f₃} {β₂ : Arrow.mk g₂ ⟶ Arrow.mk g₃} (p₁ : α₁.right = β₁.left)\n    (p₂ : α₂.right = β₂.left) : (α₁ ≫ α₂).right = (β₁ ≫ β₂).left := by\n  simp only [comma.comp_left, comma.comp_right, p₁, p₂]\n#align homology.comp_right_eq_comp_left homology.comp_right_eq_comp_left\n\n@[reassoc.1]\ntheorem homology.map_comp (p₁ : α₁.right = β₁.left) (p₂ : α₂.right = β₂.left) :\n    homology.map w₁ w₂ α₁ β₁ p₁ ≫ homology.map w₂ w₃ α₂ β₂ p₂ =\n      homology.map w₁ w₃ (α₁ ≫ α₂) (β₁ ≫ β₂) (homology.comp_right_eq_comp_left p₁ p₂) :=\n  by\n  ext <;>\n    simp only [kernel_subobject_map_comp, homology.π_map_assoc, homology.π_map, category.assoc]\n#align homology.map_comp homology.map_comp\n\n/-- An isomorphism between two three-term complexes induces an isomorphism on homology. -/\ndef homology.mapIso (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂)\n    (p : α.Hom.right = β.Hom.left) : homology f₁ g₁ w₁ ≅ homology f₂ g₂ w₂\n    where\n  Hom := homology.map w₁ w₂ α.Hom β.Hom p\n  inv :=\n    homology.map w₂ w₁ α.inv β.inv\n      (by\n        rw [← cancel_mono α.hom.right, ← comma.comp_right, α.inv_hom_id, comma.id_right, p, ←\n          comma.comp_left, β.inv_hom_id, comma.id_left]\n        rfl)\n  hom_inv_id' := by\n    rw [homology.map_comp]\n    convert homology.map_id _ <;> rw [iso.hom_inv_id]\n  inv_hom_id' := by\n    rw [homology.map_comp]\n    convert homology.map_id _ <;> rw [iso.inv_hom_id]\n#align homology.map_iso homology.mapIso\n\nend\n\nend\n\nsection\n\nvariable {A B C : V} {f : A ⟶ B} {g : B ⟶ C} (w : f ≫ g = 0) {f' : A ⟶ B} {g' : B ⟶ C}\n  (w' : f' ≫ g' = 0) [HasKernels V] [HasCokernels V] [HasImages V] [HasImageMaps V]\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/-- Custom tactic to golf and speedup boring proofs in `homology.congr`. -/\nprivate unsafe def aux_tac : tactic Unit :=\n  sorry\n#align aux_tac aux_tac\n\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic _private.601314589.aux_tac -/\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic _private.601314589.aux_tac -/\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic _private.601314589.aux_tac -/\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic _private.601314589.aux_tac -/\n/-- `homology f g w ≅ homology f' g' w'` if `f = f'` and `g = g'`.\n(Note the objects are not changing here.)\n-/\n@[simps]\ndef homology.congr (pf : f = f') (pg : g = g') : homology f g w ≅ homology f' g' w'\n    where\n  Hom :=\n    homology.map w w'\n      ⟨𝟙 _, 𝟙 _, by\n        run_tac\n          aux_tac⟩\n      ⟨𝟙 _, 𝟙 _, by\n        run_tac\n          aux_tac⟩\n      rfl\n  inv :=\n    homology.map w' w\n      ⟨𝟙 _, 𝟙 _, by\n        run_tac\n          aux_tac⟩\n      ⟨𝟙 _, 𝟙 _, by\n        run_tac\n          aux_tac⟩\n      rfl\n  hom_inv_id' := by\n    cases pf; cases pg; rw [homology.map_comp, ← homology.map_id]\n    congr 1 <;> exact category.comp_id _\n  inv_hom_id' := by\n    cases pf; cases pg; rw [homology.map_comp, ← homology.map_id]\n    congr 1 <;> exact category.comp_id _\n#align homology.congr homology.congr\n\nend\n\n/-!\nWe provide a variant `image_to_kernel' : image f ⟶ kernel g`,\nand use this to give alternative formulas for `homology f g w`.\n-/\n\n\nsection imageToKernel'\n\nvariable {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (w : f ≫ g = 0) [HasKernels V] [HasImages V]\n\n/-- While `image_to_kernel f g w` provides a morphism\n`image_subobject f ⟶ kernel_subobject g`\nin terms of the subobject API,\nthis variant provides a morphism\n`image f ⟶ kernel g`,\nwhich is sometimes more convenient.\n-/\ndef imageToKernel' (w : f ≫ g = 0) : image f ⟶ kernel g :=\n  kernel.lift g (image.ι f)\n    (by\n      ext\n      simpa using w)\n#align image_to_kernel' imageToKernel'\n\n@[simp]\ntheorem imageSubobjectIso_imageToKernel' (w : f ≫ g = 0) :\n    (imageSubobjectIso f).Hom ≫ imageToKernel' f g w =\n      imageToKernel f g w ≫ (kernelSubobjectIso g).Hom :=\n  by\n  ext\n  simp [imageToKernel']\n#align image_subobject_iso_image_to_kernel' imageSubobjectIso_imageToKernel'\n\n@[simp]\ntheorem imageToKernel'_kernelSubobjectIso (w : f ≫ g = 0) :\n    imageToKernel' f g w ≫ (kernelSubobjectIso g).inv =\n      (imageSubobjectIso f).inv ≫ imageToKernel f g w :=\n  by\n  ext\n  simp [imageToKernel']\n#align image_to_kernel'_kernel_subobject_iso imageToKernel'_kernelSubobjectIso\n\nvariable [HasCokernels V]\n\n/-- `homology f g w` can be computed as the cokernel of `image_to_kernel' f g w`.\n-/\ndef homologyIsoCokernelImageToKernel' (w : f ≫ g = 0) :\n    homology f g w ≅ cokernel (imageToKernel' f g w)\n    where\n  Hom :=\n    cokernel.map _ _ (imageSubobjectIso f).Hom (kernelSubobjectIso g).Hom\n      (by simp only [imageSubobjectIso_imageToKernel'])\n  inv :=\n    cokernel.map _ _ (imageSubobjectIso f).inv (kernelSubobjectIso g).inv\n      (by simp only [imageToKernel'_kernelSubobjectIso])\n  hom_inv_id' := by\n    apply coequalizer.hom_ext\n    simp only [iso.hom_inv_id_assoc, cokernel.π_desc, cokernel.π_desc_assoc, category.assoc,\n      coequalizer_as_cokernel]\n    exact (category.comp_id _).symm\n  inv_hom_id' := by\n    ext1\n    simp only [iso.inv_hom_id_assoc, cokernel.π_desc, category.comp_id, cokernel.π_desc_assoc,\n      category.assoc]\n#align homology_iso_cokernel_image_to_kernel' homologyIsoCokernelImageToKernel'\n\nvariable [HasEqualizers V]\n\n/-- `homology f g w` can be computed as the cokernel of `kernel.lift g f w`.\n-/\ndef homologyIsoCokernelLift (w : f ≫ g = 0) : homology f g w ≅ cokernel (kernel.lift g f w) :=\n  by\n  refine' homologyIsoCokernelImageToKernel' f g w ≪≫ _\n  have p : factor_thru_image f ≫ imageToKernel' f g w = kernel.lift g f w :=\n    by\n    ext\n    simp [imageToKernel']\n  exact (cokernel_epi_comp _ _).symm ≪≫ cokernel_iso_of_eq p\n#align homology_iso_cokernel_lift homologyIsoCokernelLift\n\nend imageToKernel'\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Homology/ImageToKernel.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.4912472310441406}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.lie.nilpotent\nimport algebra.lie.tensor_product\nimport algebra.lie.character\nimport algebra.lie.engel\nimport algebra.lie.cartan_subalgebra\nimport linear_algebra.eigenspace\nimport ring_theory.tensor_product\n\n/-!\n# Weights and roots of Lie modules and Lie algebras\n\nJust as a key tool when studying the behaviour of a linear operator is to decompose the space on\nwhich it acts into a sum of (generalised) eigenspaces, a key tool when studying a representation `M`\nof Lie algebra `L` is to decompose `M` into a sum of simultaneous eigenspaces of `x` as `x` ranges\nover `L`. These simultaneous generalised eigenspaces are known as the weight spaces of `M`.\n\nWhen `L` is nilpotent, it follows from the binomial theorem that weight spaces are Lie submodules.\nEven when `L` is not nilpotent, it may be useful to study its representations by restricting them\nto a nilpotent subalgebra (e.g., a Cartan subalgebra). In the particular case when we view `L` as a\nmodule over itself via the adjoint action, the weight spaces of `L` restricted to a nilpotent\nsubalgebra are known as root spaces.\n\nBasic definitions and properties of the above ideas are provided in this file.\n\n## Main definitions\n\n  * `lie_module.weight_space`\n  * `lie_module.is_weight`\n  * `lie_algebra.root_space`\n  * `lie_algebra.is_root`\n  * `lie_algebra.root_space_weight_space_product`\n  * `lie_algebra.root_space_product`\n  * `lie_algebra.zero_root_subalgebra_eq_iff_is_cartan`\n\n## References\n\n* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 7--9*](bourbaki1975b)\n\n## Tags\n\nlie character, eigenvalue, eigenspace, weight, weight vector, root, root vector\n-/\n\nuniverses u v w w₁ w₂ w₃\n\nvariables {R : Type u} {L : Type v} [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables (H : lie_subalgebra R L) [lie_algebra.is_nilpotent R H]\nvariables (M : Type w) [add_comm_group M] [module R M] [lie_ring_module L M] [lie_module R L M]\n\nnamespace lie_module\n\nopen lie_algebra\nopen tensor_product\nopen tensor_product.lie_module\n\nopen_locale big_operators\nopen_locale tensor_product\n\n/-- Given a Lie module `M` over a Lie algebra `L`, the pre-weight space of `M` with respect to a\nmap `χ : L → R` is the simultaneous generalized eigenspace of the action of all `x : L` on `M`,\nwith eigenvalues `χ x`.\n\nSee also `lie_module.weight_space`. -/\ndef pre_weight_space (χ : L → R) : submodule R M :=\n⨅ (x : L), (to_endomorphism R L M x).maximal_generalized_eigenspace (χ x)\n\nlemma mem_pre_weight_space (χ : L → R) (m : M) :\n  m ∈ pre_weight_space M χ ↔ ∀ x, ∃ (k : ℕ), ((to_endomorphism R L M x - (χ x) • 1)^k) m = 0 :=\nby simp [pre_weight_space, -linear_map.pow_apply]\n\nvariables (R)\n\nlemma exists_pre_weight_space_zero_le_ker_of_is_noetherian [is_noetherian R M] (x : L) :\n  ∃ (k : ℕ), pre_weight_space M (0 : L → R) ≤ ((to_endomorphism R L M x)^k).ker :=\nbegin\n  use (to_endomorphism R L M x).maximal_generalized_eigenspace_index 0,\n  simp only [← module.End.generalized_eigenspace_zero, pre_weight_space, pi.zero_apply, infi_le,\n    ← (to_endomorphism R L M x).maximal_generalized_eigenspace_eq],\nend\n\nvariables {R} (L)\n\n/-- See also `bourbaki1975b` Chapter VII §1.1, Proposition 2 (ii). -/\nprotected lemma weight_vector_multiplication (M₁ : Type w₁) (M₂ : Type w₂) (M₃ : Type w₃)\n  [add_comm_group M₁] [module R M₁] [lie_ring_module L M₁] [lie_module R L M₁]\n  [add_comm_group M₂] [module R M₂] [lie_ring_module L M₂] [lie_module R L M₂]\n  [add_comm_group M₃] [module R M₃] [lie_ring_module L M₃] [lie_module R L M₃]\n (g : M₁ ⊗[R] M₂ →ₗ⁅R,L⁆ M₃) (χ₁ χ₂ : L → R) :\n  ((g : M₁ ⊗[R] M₂ →ₗ[R] M₃).comp\n  (map_incl (pre_weight_space M₁ χ₁) (pre_weight_space M₂ χ₂))).range ≤\n    pre_weight_space M₃ (χ₁ + χ₂) :=\nbegin\n  /- Unpack the statement of the goal. -/\n  intros m₃,\n  simp only [lie_module_hom.coe_to_linear_map, pi.add_apply, function.comp_app,\n    mem_pre_weight_space, linear_map.coe_comp, tensor_product.map_incl, exists_imp_distrib,\n    linear_map.mem_range],\n  rintros t rfl x,\n\n  /- Set up some notation. -/\n  let F : module.End R M₃ := (to_endomorphism R L M₃ x) - (χ₁ x + χ₂ x) • 1,\n  change ∃ k, (F^k) (g _) = 0,\n\n  /- The goal is linear in `t` so use induction to reduce to the case that `t` is a pure tensor. -/\n  apply t.induction_on,\n  { use 0, simp only [linear_map.map_zero, lie_module_hom.map_zero], },\n  swap,\n  { rintros t₁ t₂ ⟨k₁, hk₁⟩ ⟨k₂, hk₂⟩, use max k₁ k₂,\n    simp only [lie_module_hom.map_add, linear_map.map_add,\n      linear_map.pow_map_zero_of_le (le_max_left k₁ k₂) hk₁,\n      linear_map.pow_map_zero_of_le (le_max_right k₁ k₂) hk₂, add_zero], },\n\n  /- Now the main argument: pure tensors. -/\n  rintros ⟨m₁, hm₁⟩ ⟨m₂, hm₂⟩,\n  change ∃ k, (F^k) ((g : M₁ ⊗[R] M₂ →ₗ[R] M₃) (m₁ ⊗ₜ m₂)) = 0,\n\n  /- Eliminate `g` from the picture. -/\n  let f₁ : module.End R (M₁ ⊗[R] M₂) := (to_endomorphism R L M₁ x - (χ₁ x) • 1).rtensor M₂,\n  let f₂ : module.End R (M₁ ⊗[R] M₂) := (to_endomorphism R L M₂ x - (χ₂ x) • 1).ltensor M₁,\n  have h_comm_square : F ∘ₗ ↑g = (g : M₁ ⊗[R] M₂ →ₗ[R] M₃).comp (f₁ + f₂),\n  { ext m₁ m₂, simp only [← g.map_lie x (m₁ ⊗ₜ m₂), add_smul, sub_tmul, tmul_sub, smul_tmul,\n      lie_tmul_right, tmul_smul, to_endomorphism_apply_apply, lie_module_hom.map_smul,\n      linear_map.one_apply, lie_module_hom.coe_to_linear_map, linear_map.smul_apply,\n      function.comp_app, linear_map.coe_comp, linear_map.rtensor_tmul, lie_module_hom.map_add,\n      linear_map.add_apply, lie_module_hom.map_sub, linear_map.sub_apply, linear_map.ltensor_tmul,\n      algebra_tensor_module.curry_apply, curry_apply, linear_map.to_fun_eq_coe,\n      linear_map.coe_restrict_scalars_eq_coe], abel, },\n  rsuffices ⟨k, hk⟩ : ∃ k, ((f₁ + f₂)^k) (m₁ ⊗ₜ m₂) = 0,\n  { use k,\n    rw [← linear_map.comp_apply, linear_map.commute_pow_left_of_commute h_comm_square,\n      linear_map.comp_apply, hk, linear_map.map_zero], },\n\n  /- Unpack the information we have about `m₁`, `m₂`. -/\n  simp only [mem_pre_weight_space] at hm₁ hm₂,\n  obtain ⟨k₁, hk₁⟩ := hm₁ x,\n  obtain ⟨k₂, hk₂⟩ := hm₂ x,\n  have hf₁ : (f₁^k₁) (m₁ ⊗ₜ m₂) = 0,\n  { simp only [hk₁, zero_tmul, linear_map.rtensor_tmul, linear_map.rtensor_pow], },\n  have hf₂ : (f₂^k₂) (m₁ ⊗ₜ m₂) = 0,\n  { simp only [hk₂, tmul_zero, linear_map.ltensor_tmul, linear_map.ltensor_pow], },\n\n  /- It's now just an application of the binomial theorem. -/\n  use k₁ + k₂ - 1,\n  have hf_comm : commute f₁ f₂,\n  { ext m₁ m₂, simp only [linear_map.mul_apply, linear_map.rtensor_tmul, linear_map.ltensor_tmul,\n      algebra_tensor_module.curry_apply, linear_map.to_fun_eq_coe, linear_map.ltensor_tmul,\n      curry_apply, linear_map.coe_restrict_scalars_eq_coe], },\n  rw hf_comm.add_pow',\n  simp only [tensor_product.map_incl, submodule.subtype_apply, finset.sum_apply,\n    submodule.coe_mk, linear_map.coe_fn_sum, tensor_product.map_tmul, linear_map.smul_apply],\n\n  /- The required sum is zero because each individual term is zero. -/\n  apply finset.sum_eq_zero,\n  rintros ⟨i, j⟩ hij,\n\n  /- Eliminate the binomial coefficients from the picture. -/\n  suffices : (f₁^i * f₂^j) (m₁ ⊗ₜ m₂) = 0, { rw this, apply smul_zero, },\n\n  /- Finish off with appropriate case analysis. -/\n  cases nat.le_or_le_of_add_eq_add_pred (finset.nat.mem_antidiagonal.mp hij) with hi hj,\n  { rw [(hf_comm.pow_pow i j).eq, linear_map.mul_apply, linear_map.pow_map_zero_of_le hi hf₁,\n    linear_map.map_zero], },\n  { rw [linear_map.mul_apply, linear_map.pow_map_zero_of_le hj hf₂, linear_map.map_zero], },\nend\n\nvariables {L M}\n\nlemma lie_mem_pre_weight_space_of_mem_pre_weight_space {χ₁ χ₂ : L → R} {x : L} {m : M}\n  (hx : x ∈ pre_weight_space L χ₁) (hm : m ∈ pre_weight_space M χ₂) :\n  ⁅x, m⁆ ∈ pre_weight_space M (χ₁ + χ₂) :=\nbegin\n  apply lie_module.weight_vector_multiplication L L M M (to_module_hom R L M) χ₁ χ₂,\n  simp only [lie_module_hom.coe_to_linear_map, function.comp_app, linear_map.coe_comp,\n    tensor_product.map_incl, linear_map.mem_range],\n  use [⟨x, hx⟩ ⊗ₜ ⟨m, hm⟩],\n  simp only [submodule.subtype_apply, to_module_hom_apply, tensor_product.map_tmul],\n  refl,\nend\n\nvariables (M)\n\n/-- If a Lie algebra is nilpotent, then pre-weight spaces are Lie submodules. -/\ndef weight_space [lie_algebra.is_nilpotent R L] (χ : L → R) : lie_submodule R L M :=\n{ lie_mem := λ x m hm,\n  begin\n    rw ← zero_add χ,\n    refine lie_mem_pre_weight_space_of_mem_pre_weight_space _ hm,\n    suffices : pre_weight_space L (0 : L → R) = ⊤, { simp only [this, submodule.mem_top], },\n    exact lie_algebra.infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L,\n  end,\n  .. pre_weight_space M χ }\n\nlemma mem_weight_space [lie_algebra.is_nilpotent R L] (χ : L → R) (m : M) :\n  m ∈ weight_space M χ ↔ m ∈ pre_weight_space M χ :=\niff.rfl\n\n/-- See also the more useful form `lie_module.zero_weight_space_eq_top_of_nilpotent`. -/\n@[simp] lemma zero_weight_space_eq_top_of_nilpotent'\n  [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] :\n  weight_space M (0 : L → R) = ⊤ :=\nbegin\n  rw [← lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule],\n  exact infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L M,\nend\n\nlemma coe_weight_space_of_top [lie_algebra.is_nilpotent R L] (χ : L → R) :\n  (weight_space M (χ ∘ (⊤ : lie_subalgebra R L).incl) : submodule R M) = weight_space M χ :=\nbegin\n  ext m,\n  simp only [weight_space, lie_submodule.coe_to_submodule_mk, lie_subalgebra.coe_bracket_of_module,\n    function.comp_app, mem_pre_weight_space],\n  split; intros h x,\n  { obtain ⟨k, hk⟩ := h ⟨x, set.mem_univ x⟩, use k, exact hk, },\n  { obtain ⟨k, hk⟩ := h x, use k, exact hk, },\nend\n\n@[simp] lemma zero_weight_space_eq_top_of_nilpotent\n  [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] :\n  weight_space M (0 : (⊤ : lie_subalgebra R L) → R) = ⊤ :=\nbegin\n  /- We use `coe_weight_space_of_top` as a trick to circumvent the fact that we don't (yet) know\n    `is_nilpotent R (⊤ : lie_subalgebra R L) M` is equivalent to `is_nilpotent R L M`. -/\n  have h₀ : (0 : L → R) ∘ (⊤ : lie_subalgebra R L).incl = 0, { ext, refl, },\n  rw [← lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule, ← h₀,\n    coe_weight_space_of_top, ← infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L M],\n  refl,\nend\n\n/-- Given a Lie module `M` of a Lie algebra `L`, a weight of `M` with respect to a nilpotent\nsubalgebra `H ⊆ L` is a Lie character whose corresponding weight space is non-empty. -/\ndef is_weight (χ : lie_character R H) : Prop := weight_space M χ ≠ ⊥\n\n/-- For a non-trivial nilpotent Lie module over a nilpotent Lie algebra, the zero character is a\nweight with respect to the `⊤` Lie subalgebra. -/\nlemma is_weight_zero_of_nilpotent\n   [nontrivial M] [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] :\n   is_weight (⊤ : lie_subalgebra R L) M 0 :=\nby { rw [is_weight, lie_hom.coe_zero, zero_weight_space_eq_top_of_nilpotent], exact top_ne_bot, }\n\n/-- A (nilpotent) Lie algebra acts nilpotently on the zero weight space of a Noetherian Lie\nmodule. -/\nlemma is_nilpotent_to_endomorphism_weight_space_zero\n  [lie_algebra.is_nilpotent R L] [is_noetherian R M] (x : L) :\n  _root_.is_nilpotent $ to_endomorphism R L (weight_space M (0 : L → R)) x :=\nbegin\n  obtain ⟨k, hk⟩ := exists_pre_weight_space_zero_le_ker_of_is_noetherian R M x,\n  use k,\n  ext ⟨m, hm⟩,\n  rw [linear_map.zero_apply, lie_submodule.coe_zero, submodule.coe_eq_zero,\n    ← lie_submodule.to_endomorphism_restrict_eq_to_endomorphism, linear_map.pow_restrict,\n    ← set_like.coe_eq_coe, linear_map.restrict_apply, submodule.coe_mk, submodule.coe_zero],\n  exact hk hm,\nend\n\n/-- By Engel's theorem, when the Lie algebra is Noetherian, the zero weight space of a Noetherian\nLie module is nilpotent. -/\ninstance [lie_algebra.is_nilpotent R L] [is_noetherian R L] [is_noetherian R M] :\n  is_nilpotent R L (weight_space M (0 : L → R)) :=\nis_nilpotent_iff_forall.mpr $ is_nilpotent_to_endomorphism_weight_space_zero M\n\nend lie_module\n\nnamespace lie_algebra\n\nopen_locale tensor_product\nopen tensor_product.lie_module\nopen lie_module\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L`, the root space of a map `χ : H → R` is the weight\nspace of `L` regarded as a module of `H` via the adjoint action. -/\nabbreviation root_space (χ : H → R) : lie_submodule R H L := weight_space L χ\n\n@[simp] \n\n/-- A root of a Lie algebra `L` with respect to a nilpotent subalgebra `H ⊆ L` is a weight of `L`,\nregarded as a module of `H` via the adjoint action. -/\nabbreviation is_root := is_weight H L\n\n@[simp] lemma root_space_comap_eq_weight_space (χ : H → R) :\n  (root_space H χ).comap H.incl' = weight_space H χ :=\nbegin\n  ext x,\n  let f : H → module.End R L := λ y, to_endomorphism R H L y - (χ y) • 1,\n  let g : H → module.End R H := λ y, to_endomorphism R H H y - (χ y) • 1,\n  suffices : (∀ (y : H), ∃ (k : ℕ), ((f y)^k).comp (H.incl : H →ₗ[R] L) x = 0) ↔\n              ∀ (y : H), ∃ (k : ℕ), (H.incl : H →ₗ[R] L).comp ((g y)^k) x = 0,\n  { simp only [lie_hom.coe_to_linear_map, lie_subalgebra.coe_incl, function.comp_app,\n      linear_map.coe_comp, submodule.coe_eq_zero] at this,\n    simp only [mem_weight_space, mem_pre_weight_space,\n      lie_subalgebra.coe_incl', lie_submodule.mem_comap, this], },\n  have hfg : ∀ (y : H), (f y).comp (H.incl : H →ₗ[R] L) = (H.incl : H →ₗ[R] L).comp (g y),\n  { rintros ⟨y, hy⟩, ext ⟨z, hz⟩,\n    simp only [submodule.coe_sub, to_endomorphism_apply_apply, lie_hom.coe_to_linear_map,\n      linear_map.one_apply, lie_subalgebra.coe_incl, lie_subalgebra.coe_bracket_of_module,\n      lie_subalgebra.coe_bracket, linear_map.smul_apply, function.comp_app,\n      submodule.coe_smul_of_tower, linear_map.coe_comp, linear_map.sub_apply], },\n  simp_rw [linear_map.commute_pow_left_of_commute (hfg _)],\nend\n\nvariables {H M}\n\nlemma lie_mem_weight_space_of_mem_weight_space {χ₁ χ₂ : H → R} {x : L} {m : M}\n  (hx : x ∈ root_space H χ₁) (hm : m ∈ weight_space M χ₂) : ⁅x, m⁆ ∈ weight_space M (χ₁ + χ₂) :=\nbegin\n  apply lie_module.weight_vector_multiplication\n    H L M M ((to_module_hom R L M).restrict_lie H) χ₁ χ₂,\n  simp only [lie_module_hom.coe_to_linear_map, function.comp_app, linear_map.coe_comp,\n    tensor_product.map_incl, linear_map.mem_range],\n  use [⟨x, hx⟩ ⊗ₜ ⟨m, hm⟩],\n  simp only [submodule.subtype_apply, to_module_hom_apply, submodule.coe_mk,\n    lie_module_hom.coe_restrict_lie, tensor_product.map_tmul],\nend\n\nvariables (R L H M)\n\n/--\nAuxiliary definition for `root_space_weight_space_product`,\nwhich is close to the deterministic timeout limit.\n-/\ndef root_space_weight_space_product_aux {χ₁ χ₂ χ₃ : H → R} (hχ : χ₁ + χ₂ = χ₃) :\n  (root_space H χ₁) →ₗ[R] (weight_space M χ₂) →ₗ[R] (weight_space M χ₃) :=\n{ to_fun    := λ x,\n  { to_fun    :=\n      λ m, ⟨⁅(x : L), (m : M)⁆,\n            hχ ▸ (lie_mem_weight_space_of_mem_weight_space x.property m.property) ⟩,\n    map_add'  := λ m n, by { simp only [lie_submodule.coe_add, lie_add], refl, },\n    map_smul' := λ t m, by { conv_lhs { congr, rw [lie_submodule.coe_smul, lie_smul], }, refl, }, },\n  map_add'  := λ x y, by ext m; rw [linear_map.add_apply, linear_map.coe_mk, linear_map.coe_mk,\n    linear_map.coe_mk, subtype.coe_mk, lie_submodule.coe_add, lie_submodule.coe_add, add_lie,\n    subtype.coe_mk, subtype.coe_mk],\n  map_smul' := λ t x,\n  begin\n    simp only [ring_hom.id_apply],\n    ext m,\n    rw [linear_map.smul_apply, linear_map.coe_mk, linear_map.coe_mk,\n      subtype.coe_mk, lie_submodule.coe_smul, smul_lie, lie_submodule.coe_smul, subtype.coe_mk],\n  end, }\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L` together with `χ₁ χ₂ : H → R`, there is a natural\n`R`-bilinear product of root vectors and weight vectors, compatible with the actions of `H`. -/\ndef root_space_weight_space_product (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) :\n  (root_space H χ₁) ⊗[R] (weight_space M χ₂) →ₗ⁅R,H⁆ weight_space M χ₃ :=\nlift_lie R H (root_space H χ₁) (weight_space M χ₂) (weight_space M χ₃)\n{ to_linear_map := root_space_weight_space_product_aux R L H M hχ,\n  map_lie' := λ x y, by ext m; rw [root_space_weight_space_product_aux,\n    lie_hom.lie_apply, lie_submodule.coe_sub, linear_map.coe_mk,\n    linear_map.coe_mk, subtype.coe_mk, subtype.coe_mk, lie_submodule.coe_bracket,\n    lie_submodule.coe_bracket, subtype.coe_mk, lie_subalgebra.coe_bracket_of_module,\n    lie_subalgebra.coe_bracket_of_module, lie_submodule.coe_bracket,\n    lie_subalgebra.coe_bracket_of_module, lie_lie], }\n\n@[simp] lemma coe_root_space_weight_space_product_tmul\n  (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) (x : root_space H χ₁) (m : weight_space M χ₂) :\n  (root_space_weight_space_product R L H M χ₁ χ₂ χ₃ hχ (x ⊗ₜ m) : M) = ⁅(x : L), (m : M)⁆ :=\nby simp only [root_space_weight_space_product, root_space_weight_space_product_aux,\n  lift_apply, lie_module_hom.coe_to_linear_map,\n  coe_lift_lie_eq_lift_coe, submodule.coe_mk, linear_map.coe_mk, lie_module_hom.coe_mk]\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L` together with `χ₁ χ₂ : H → R`, there is a natural\n`R`-bilinear product of root vectors, compatible with the actions of `H`. -/\ndef root_space_product (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) :\n  (root_space H χ₁) ⊗[R] (root_space H χ₂) →ₗ⁅R,H⁆ root_space H χ₃ :=\nroot_space_weight_space_product R L H L χ₁ χ₂ χ₃ hχ\n\n@[simp] lemma root_space_product_def :\n  root_space_product R L H = root_space_weight_space_product R L H L :=\nrfl\n\nlemma root_space_product_tmul\n  (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) (x : root_space H χ₁) (y : root_space H χ₂) :\n  (root_space_product R L H χ₁ χ₂ χ₃ hχ (x ⊗ₜ y) : L) = ⁅(x : L), (y : L)⁆ :=\nby simp only [root_space_product_def, coe_root_space_weight_space_product_tmul]\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L`, the root space of the zero map `0 : H → R` is a Lie\nsubalgebra of `L`. -/\ndef zero_root_subalgebra : lie_subalgebra R L :=\n{ lie_mem' := λ x y hx hy, by\n  { let xy : (root_space H 0) ⊗[R] (root_space H 0) := ⟨x, hx⟩ ⊗ₜ ⟨y, hy⟩,\n    suffices : (root_space_product R L H 0 0 0 (add_zero 0) xy : L) ∈ root_space H 0,\n    { rwa [root_space_product_tmul, subtype.coe_mk, subtype.coe_mk] at this, },\n    exact (root_space_product R L H 0 0 0 (add_zero 0) xy).property, },\n  .. (root_space H 0 : submodule R L) }\n\n@[simp] lemma coe_zero_root_subalgebra :\n  (zero_root_subalgebra R L H : submodule R L) = root_space H 0 :=\nrfl\n\nlemma mem_zero_root_subalgebra (x : L) :\n  x ∈ zero_root_subalgebra R L H ↔ ∀ (y : H), ∃ (k : ℕ), ((to_endomorphism R H L y)^k) x = 0 :=\nby simp only [zero_root_subalgebra, mem_weight_space, mem_pre_weight_space, pi.zero_apply, sub_zero,\n  set_like.mem_coe, zero_smul, lie_submodule.mem_coe_submodule, submodule.mem_carrier,\n  lie_subalgebra.mem_mk_iff]\n\nlemma to_lie_submodule_le_root_space_zero : H.to_lie_submodule ≤ root_space H 0 :=\nbegin\n  intros x hx,\n  simp only [lie_subalgebra.mem_to_lie_submodule] at hx,\n  simp only [mem_weight_space, mem_pre_weight_space, pi.zero_apply, sub_zero, zero_smul],\n  intros y,\n  unfreezingI { obtain ⟨k, hk⟩ := (infer_instance : is_nilpotent R H) },\n  use k,\n  let f : module.End R H := to_endomorphism R H H y,\n  let g : module.End R L := to_endomorphism R H L y,\n  have hfg : g.comp (H : submodule R L).subtype = (H : submodule R L).subtype.comp f,\n  { ext z, simp only [to_endomorphism_apply_apply, submodule.subtype_apply,\n      lie_subalgebra.coe_bracket_of_module, lie_subalgebra.coe_bracket, function.comp_app,\n      linear_map.coe_comp], },\n  change (g^k).comp (H : submodule R L).subtype ⟨x, hx⟩ = 0,\n  rw linear_map.commute_pow_left_of_commute hfg k,\n  have h := iterate_to_endomorphism_mem_lower_central_series R H H y ⟨x, hx⟩ k,\n  rw [hk, lie_submodule.mem_bot] at h,\n  simp only [submodule.subtype_apply, function.comp_app, linear_map.pow_apply, linear_map.coe_comp,\n    submodule.coe_eq_zero],\n  exact h,\nend\n\nlemma le_zero_root_subalgebra : H ≤ zero_root_subalgebra R L H :=\nbegin\n  rw [← lie_subalgebra.coe_submodule_le_coe_submodule, ← H.coe_to_lie_submodule,\n    coe_zero_root_subalgebra, lie_submodule.coe_submodule_le_coe_submodule],\n  exact to_lie_submodule_le_root_space_zero R L H,\nend\n\n@[simp] lemma zero_root_subalgebra_normalizer_eq_self :\n  (zero_root_subalgebra R L H).normalizer = zero_root_subalgebra R L H :=\nbegin\n  refine le_antisymm _ (lie_subalgebra.le_normalizer _),\n  intros x hx,\n  rw lie_subalgebra.mem_normalizer_iff at hx,\n  rw mem_zero_root_subalgebra,\n  rintros ⟨y, hy⟩,\n  specialize hx y (le_zero_root_subalgebra R L H hy),\n  rw mem_zero_root_subalgebra at hx,\n  obtain ⟨k, hk⟩ := hx ⟨y, hy⟩,\n  rw [← lie_skew, linear_map.map_neg, neg_eq_zero] at hk,\n  use k + 1,\n  rw [linear_map.iterate_succ, linear_map.coe_comp, function.comp_app, to_endomorphism_apply_apply,\n    lie_subalgebra.coe_bracket_of_module, submodule.coe_mk, hk],\nend\n\n/-- If the zero root subalgebra of a nilpotent Lie subalgebra `H` is just `H` then `H` is a Cartan\nsubalgebra.\n\nWhen `L` is Noetherian, it follows from Engel's theorem that the converse holds. See\n`lie_algebra.zero_root_subalgebra_eq_iff_is_cartan` -/\nlemma is_cartan_of_zero_root_subalgebra_eq (h : zero_root_subalgebra R L H = H) :\n  H.is_cartan_subalgebra :=\n{ nilpotent        := infer_instance,\n  self_normalizing := by { rw ← h, exact zero_root_subalgebra_normalizer_eq_self R L H, } }\n\n@[simp] lemma zero_root_subalgebra_eq_of_is_cartan (H : lie_subalgebra R L)\n  [H.is_cartan_subalgebra] [is_noetherian R L] :\n  zero_root_subalgebra R L H = H :=\nbegin\n  refine le_antisymm _ (le_zero_root_subalgebra R L H),\n  suffices : root_space H 0 ≤ H.to_lie_submodule, { exact λ x hx, this hx, },\n  obtain ⟨k, hk⟩ := (root_space H 0).is_nilpotent_iff_exists_self_le_ucs.mp (by apply_instance),\n  exact hk.trans (lie_submodule.ucs_le_of_normalizer_eq_self (by simp) k),\nend\n\nlemma zero_root_subalgebra_eq_iff_is_cartan [is_noetherian R L] :\n  zero_root_subalgebra R L H = H ↔ H.is_cartan_subalgebra :=\n⟨is_cartan_of_zero_root_subalgebra_eq R L H, by { introsI, simp, }⟩\n\nend lie_algebra\n\nnamespace lie_module\n\nopen lie_algebra\n\nvariables {R L H}\n\n/-- A priori, weight spaces are Lie submodules over the Lie subalgebra `H` used to define them.\nHowever they are naturally Lie submodules over the (in general larger) Lie subalgebra\n`zero_root_subalgebra R L H`. Even though it is often the case that\n`zero_root_subalgebra R L H = H`, it is likely to be useful to have the flexibility not to have\nto invoke this equality (as well as to work more generally). -/\ndef weight_space' (χ : H → R) : lie_submodule R (zero_root_subalgebra R L H) M :=\n{ lie_mem := λ x m hm, by\n  { have hx : (x : L) ∈ root_space H 0,\n    { rw [← lie_submodule.mem_coe_submodule, ← coe_zero_root_subalgebra], exact x.property, },\n    rw ← zero_add χ,\n    exact lie_mem_weight_space_of_mem_weight_space hx hm, },\n  .. (weight_space M χ : submodule R M) }\n\n@[simp] lemma coe_weight_space' (χ : H → R) :\n  (weight_space' M χ : submodule R M) = weight_space M χ :=\nrfl\n\nend lie_module\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/lie/weights.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458153, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.4911969704017945}}
{"text": "import category_theory.limits.shapes.pullbacks\n\n/-!\nThanks to Markus Himmel for suggesting this question.\n-/\n\nopen category_theory\nopen category_theory.limits\n\n/-!\nLet C be a category, X and Y be objects and f : X ⟶ Y be a morphism. Show that f is an epimorphism\nif and only if the diagram\n\nX --f--→ Y\n|        |\nf        𝟙\n|        |\n↓        ↓\nY --𝟙--→ Y\n\nis a pushout.\n-/\n\nvariables {C : Type*} [category C]\n\ndef pushout_of_epi {X Y : C} (f : X ⟶ Y) [epi f] :\n  is_colimit (pushout_cocone.mk (𝟙 Y) (𝟙 Y) rfl : pushout_cocone f f) :=\n-- Hint: you can start a proof with `fapply pushout_cocone.is_colimit.mk`\n-- to save a little bit of work over just building a `is_colimit` structure directly.\nsorry\n\ntheorem epi_of_pushout {X Y : C} (f : X ⟶ Y)\n  (is_colim : is_colimit (pushout_cocone.mk (𝟙 Y) (𝟙 Y) rfl : pushout_cocone f f)) : epi f :=\n-- Hint: You can use `pushout_cocone.mk` to conveniently construct a cocone over a cospan.\n-- Hint: use `is_colim.desc` to construct the map from a colimit cocone to any other cocone.\n-- Hint: use `is_colim.fac` to show that this map gives a factorisation of the cocone maps through the colimit cocone.\n-- Hint: if `simp` won't correctly simplify `𝟙 X ≫ f`, try `dsimp, simp`.\nsorry\n\n/-!\nThere are some further hints in\n`hints/category_theory/exercise6/`\n-/\n\n", "meta": {"author": "leanprover-community", "repo": "lftcm2020", "sha": "cc683e2b074b61909310746d6acc1fb3d42d6ee2", "save_path": "github-repos/lean/leanprover-community-lftcm2020", "path": "github-repos/lean/leanprover-community-lftcm2020/lftcm2020-cc683e2b074b61909310746d6acc1fb3d42d6ee2/src/exercises_sources/thursday/category_theory/exercise6.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.49119696580713496}}
{"text": "/-\nCopyright (c) 2020 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn\n-/\nimport category_theory.natural_isomorphism\n\n/-!\n# Quotient category\n\nConstructs the quotient of a category by an arbitrary family of relations on its hom-sets,\nby introducing a type synonym for the objects, and identifying homs as necessary.\n\nThis is analogous to 'the quotient of a group by the normal closure of a subset', rather\nthan 'the quotient of a group by a normal subgroup'.\n-/\n\nuniverses v v₁ u u₁\n\nnamespace category_theory\n\nvariables {C : Type u} [category.{v} C]\n          (r : Π ⦃a b : C⦄, (a ⟶ b) → (a ⟶ b) → Prop)\ninclude r\n\n/-- A type synonom for `C`, thought of as the objects of the quotient category. -/\nstructure quotient := (as : C)\n\ninstance [inhabited C] : inhabited (quotient r) := ⟨ { as := default C } ⟩\n\nnamespace quotient\n\n/-- Generates the closure of a family of relations w.r.t. composition from left and right. -/\ninductive comp_closure ⦃s t : C⦄ : (s ⟶ t) → (s ⟶ t) → Prop\n| intro {a b} (f : s ⟶ a) (m₁ m₂ : a ⟶ b) (g : b ⟶ t) (h : r m₁ m₂) :\n  comp_closure (f ≫ m₁ ≫ g) (f ≫ m₂ ≫ g)\n\nlemma comp_left {a b c : C} (f : a ⟶ b) : Π (g₁ g₂ : b ⟶ c) (h : comp_closure r g₁ g₂),\n  comp_closure r (f ≫ g₁) (f ≫ g₂)\n| _ _ ⟨x, m₁, m₂, y, h⟩ := by simpa using comp_closure.intro (f ≫ x) m₁ m₂ y h\n\nlemma comp_right {a b c : C} (g : b ⟶ c) : Π (f₁ f₂ : a ⟶ b) (h : comp_closure r f₁ f₂),\n  comp_closure r (f₁ ≫ g) (f₂ ≫ g)\n| _ _ ⟨x, m₁, m₂, y, h⟩ := by simpa using comp_closure.intro x m₁ m₂ (y ≫ g) h\n\n/-- Hom-sets of the quotient category. -/\ndef hom (s t : quotient r) := quot $ @comp_closure C _ r s.as t.as\n\ninstance (a : quotient r) : inhabited (hom r a a) := ⟨quot.mk _ (𝟙 a.as)⟩\n\n/-- Composition in the quotient category. -/\ndef comp ⦃a b c : quotient r⦄ : hom r a b → hom r b c → hom r a c :=\nλ hf hg, quot.lift_on hf ( λ f, quot.lift_on hg (λ g, quot.mk _ (f ≫ g))\n  (λ g₁ g₂ h, quot.sound $ comp_left r f g₁ g₂ h) )\n  (λ f₁ f₂ h, quot.induction_on hg $ λ g, quot.sound $ comp_right r g f₁ f₂ h)\n\n@[simp]\nlemma comp_mk {a b c : quotient r} (f : a.as ⟶ b.as) (g : b.as ⟶ c.as) :\n  comp r (quot.mk _ f) (quot.mk _ g) = quot.mk _ (f ≫ g) := rfl\n\ninstance category : category (quotient r) :=\n{ hom := hom r,\n  id := λ a, quot.mk _ (𝟙 a.as),\n  comp := comp r }\n\n/-- The functor from a category to its quotient. -/\n@[simps]\ndef functor : C ⥤ quotient r :=\n{ obj := λ a, { as := a },\n  map := λ _ _ f, quot.mk _ f }\n\nprotected lemma induction {P : Π {a b : quotient r}, (a ⟶ b) → Prop}\n  (h : ∀ {x y : C} (f : x ⟶ y), P ((functor r).map f)) :\n  ∀ {a b : quotient r} (f : a ⟶ b), P f :=\nby { rintros ⟨x⟩ ⟨y⟩ ⟨f⟩, exact h f, }\n\nprotected lemma sound {a b : C} {f₁ f₂ : a ⟶ b} (h : r f₁ f₂) :\n  (functor r).map f₁ = (functor r).map f₂ :=\nby simpa using quot.sound (comp_closure.intro (𝟙 a) f₁ f₂ (𝟙 b) h)\n\nvariables {D : Type*} [category D]\n  (F : C ⥤ D)\n  (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → F.map f₁ = F.map f₂)\ninclude H\n\n/-- The induced functor on the quotient category. -/\n@[simps]\ndef lift : quotient r ⥤ D :=\n{ obj := λ a, F.obj a.as,\n  map := λ a b hf, quot.lift_on hf (λ f, F.map f)\n    (by { rintros _ _ ⟨_, _, _, _, _, _, h⟩, simp [H _ _ _ _ h], }),\n  map_id' := λ a, F.map_id a.as,\n  map_comp' := by { rintros a b c ⟨f⟩ ⟨g⟩, exact F.map_comp f g, } }\n\n/-- The original functor factors through the induced functor. -/\ndef lift.is_lift : (functor r) ⋙ lift r F H ≅ F :=\nnat_iso.of_components (λ X, iso.refl _) (by tidy)\n\n@[simp]\nlemma lift.is_lift_hom (X : C) : (lift.is_lift r F H).hom.app X = 𝟙 (F.obj X) :=\nrfl\n@[simp]\nlemma lift.is_lift_inv (X : C) : (lift.is_lift r F H).inv.app X = 𝟙 (F.obj X) :=\nrfl\n\nend quotient\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/quotient.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.4911969613563267}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport analysis.normed_space.continuous_affine_map\nimport analysis.calculus.cont_diff\n\n/-!\n# Smooth affine maps\n\nThis file contains results about smoothness of affine maps.\n\n## Main definitions:\n\n * `continuous_affine_map.cont_diff`: a continuous affine map is smooth\n\n-/\n\nnamespace continuous_affine_map\n\nvariables {𝕜 V W : Type*} [nondiscrete_normed_field 𝕜]\nvariables [normed_group V] [normed_space 𝕜 V]\nvariables [normed_group W] [normed_space 𝕜 W]\n\n/-- A continuous affine map between normed vector spaces is smooth. -/\nlemma cont_diff {n : with_top ℕ} (f : V →A[𝕜] W) :\n  cont_diff 𝕜 n f :=\nbegin\n  rw f.decomp,\n  apply f.cont_linear.cont_diff.add,\n  simp only,\n  exact cont_diff_const,\nend\n\nend continuous_affine_map\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/analysis/calculus/affine_map.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.49119696135632657}}
{"text": "/-\nCopyright (c) 2021 Bryan Gin-ge Chen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bryan Gin-ge Chen, Yury Kudryashov\n-/\nimport algebra.group.hom\n\n/-!\n# Extensionality lemmas for monoid and group structures\n\nIn this file we prove extensionality lemmas for `monoid` and higher algebraic structures with one\nbinary operation. Extensionality lemmas for structures that are lower in the hierarchy can be found\nin `algebra.group.defs`.\n\n## Implementation details\n\nTo get equality of `npow` etc, we define a monoid homomorphism between two monoid structures on the\nsame type, then apply lemmas like `monoid_hom.map_div`, `monoid_hom.map_pow` etc.\n\n## Tags\nmonoid, group, extensionality\n-/\n\nuniverse u\n\n@[ext, to_additive]\nlemma monoid.ext {M : Type u} ⦃m₁ m₂ : monoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\nbegin\n  have h₁ : (@monoid.to_mul_one_class _ m₁).one = (@monoid.to_mul_one_class _ m₂).one,\n    from congr_arg (@mul_one_class.one M) (mul_one_class.ext h_mul),\n  set f : @monoid_hom M M (@monoid.to_mul_one_class _ m₁) (@monoid.to_mul_one_class _ m₂) :=\n    { to_fun := id, map_one' := h₁, map_mul' := λ x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : m₁.npow = m₂.npow, by { ext n x, exact @monoid_hom.map_pow M M m₁ m₂ f x n },\n  unfreezingI { cases m₁, cases m₂ },\n  congr; assumption\nend\n\n@[to_additive]\nlemma comm_monoid.to_monoid_injective {M : Type u} :\n  function.injective (@comm_monoid.to_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma comm_monoid.ext {M : Type*} ⦃m₁ m₂ : comm_monoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\ncomm_monoid.to_monoid_injective $ monoid.ext h_mul\n\n@[to_additive]\nlemma left_cancel_monoid.to_monoid_injective {M : Type u} :\n  function.injective (@left_cancel_monoid.to_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma left_cancel_monoid.ext {M : Type u} ⦃m₁ m₂ : left_cancel_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\nleft_cancel_monoid.to_monoid_injective $ monoid.ext h_mul\n\n@[to_additive]\nlemma right_cancel_monoid.to_monoid_injective {M : Type u} :\n  function.injective (@right_cancel_monoid.to_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma right_cancel_monoid.ext {M : Type u} ⦃m₁ m₂ : right_cancel_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\nright_cancel_monoid.to_monoid_injective $ monoid.ext h_mul\n\n@[to_additive]\nlemma cancel_monoid.to_left_cancel_monoid_injective {M : Type u} :\n  function.injective (@cancel_monoid.to_left_cancel_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_monoid.ext {M : Type*} ⦃m₁ m₂ : cancel_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\ncancel_monoid.to_left_cancel_monoid_injective $ left_cancel_monoid.ext h_mul\n\n@[to_additive]\nlemma cancel_comm_monoid.to_comm_monoid_injective {M : Type u} :\n  function.injective (@cancel_comm_monoid.to_comm_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_comm_monoid.ext {M : Type*} ⦃m₁ m₂ : cancel_comm_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\ncancel_comm_monoid.to_comm_monoid_injective $ comm_monoid.ext h_mul\n\n@[ext, to_additive]\nlemma div_inv_monoid.ext {M : Type*} ⦃m₁ m₂ : div_inv_monoid M⦄ (h_mul : m₁.mul = m₂.mul)\n  (h_inv : m₁.inv = m₂.inv) : m₁ = m₂ :=\nbegin\n  have h₁ : (@div_inv_monoid.to_monoid _ m₁).one = (@div_inv_monoid.to_monoid _ m₂).one,\n    from congr_arg (@monoid.one M) (monoid.ext h_mul),\n  set f : @monoid_hom M M (by letI := m₁; apply_instance) (by letI := m₂; apply_instance) :=\n    { to_fun := id, map_one' := h₁, map_mul' := λ x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : (@div_inv_monoid.to_monoid _ m₁).npow = (@div_inv_monoid.to_monoid _ m₂).npow :=\n    congr_arg (@monoid.npow M) (monoid.ext h_mul),\n  have hzpow : m₁.zpow = m₂.zpow,\n  { ext m x,\n    exact @monoid_hom.map_zpow' M M m₁ m₂ f (congr_fun h_inv) x m },\n  have hdiv : m₁.div = m₂.div,\n  { ext a b,\n    exact @monoid_hom.map_div' M M m₁ m₂ f (congr_fun h_inv) a b },\n  unfreezingI { cases m₁, cases m₂ },\n  congr, exacts [h_mul, h₁, hpow, h_inv, hdiv, hzpow]\nend\n\n@[ext, to_additive]\nlemma group.ext {G : Type*} ⦃g₁ g₂ : group G⦄ (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ :=\nbegin\n  set f := @monoid_hom.mk' G G (by letI := g₁; apply_instance) g₂ id\n    (λ a b, congr_fun (congr_fun h_mul a) b),\n  exact group.to_div_inv_monoid_injective (div_inv_monoid.ext h_mul\n    (funext $ @monoid_hom.map_inv G G g₁ g₂ f))\nend\n\n@[ext, to_additive]\nlemma comm_group.ext {G : Type*} ⦃g₁ g₂ : comm_group G⦄\n  (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ :=\ncomm_group.to_group_injective $ group.ext h_mul\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/group/ext.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4910964321609909}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Sébastien Gouëzel, Patrick Massot\n-/\nimport topology.uniform_space.cauchy\nimport topology.uniform_space.separation\nimport topology.dense_embedding\n\n/-!\n# Uniform embeddings of uniform spaces.\n\nExtension of uniform continuous functions.\n-/\n\nopen filter topological_space set classical\nopen_locale classical uniformity topological_space filter\n\nsection\nvariables {α : Type*} {β : Type*} {γ : Type*}\n          [uniform_space α] [uniform_space β] [uniform_space γ]\nuniverse u\n\n/-- A map `f : α → β` between uniform spaces is called *uniform inducing* if the uniformity filter\non `α` is the pullback of the uniformity filter on `β` under `prod.map f f`. If `α` is a separated\nspace, then this implies that `f` is injective, hence it is a `uniform_embedding`. -/\nstructure uniform_inducing (f : α → β) : Prop :=\n(comap_uniformity : comap (λx:α×α, (f x.1, f x.2)) (𝓤 β) = 𝓤 α)\n\nlemma uniform_inducing.mk' {f : α → β} (h : ∀ s, s ∈ 𝓤 α ↔\n    ∃ t ∈ 𝓤 β, ∀ x y : α, (f x, f y) ∈ t → (x, y) ∈ s) : uniform_inducing f :=\n⟨by simp [eq_comm, filter.ext_iff, subset_def, h]⟩\n\nlemma uniform_inducing.comp {g : β → γ} (hg : uniform_inducing g)\n  {f : α → β} (hf : uniform_inducing f) : uniform_inducing (g ∘ f) :=\n⟨ by rw [show (λ (x : α × α), ((g ∘ f) x.1, (g ∘ f) x.2)) =\n         (λ y : β × β, (g y.1, g y.2)) ∘ (λ x : α × α, (f x.1, f x.2)), by ext ; simp,\n        ← filter.comap_comap, hg.1, hf.1]⟩\n\nlemma uniform_inducing.basis_uniformity {f : α → β} (hf : uniform_inducing f)\n  {ι : Sort*} {p : ι → Prop} {s : ι → set (β × β)} (H : (𝓤 β).has_basis p s) :\n  (𝓤 α).has_basis p (λ i, prod.map f f ⁻¹' s i) :=\nhf.1 ▸ H.comap _\n\n/-- A map `f : α → β` between uniform spaces is a *uniform embedding* if it is uniform inducing and\ninjective. If `α` is a separated space, then the latter assumption follows from the former. -/\nstructure uniform_embedding (f : α → β) extends uniform_inducing f : Prop :=\n(inj : function.injective f)\n\nlemma uniform_embedding_subtype_val {p : α → Prop} :\n  uniform_embedding (subtype.val : subtype p → α) :=\n{ comap_uniformity := rfl,\n  inj := subtype.val_injective }\n\nlemma uniform_embedding_subtype_coe {p : α → Prop} :\n  uniform_embedding (coe : subtype p → α) :=\nuniform_embedding_subtype_val\n\nlemma uniform_embedding_set_inclusion {s t : set α} (hst : s ⊆ t) :\n  uniform_embedding (inclusion hst) :=\n{ comap_uniformity :=\n    by { erw [uniformity_subtype, uniformity_subtype, comap_comap], congr },\n  inj := inclusion_injective hst }\n\nlemma uniform_embedding.comp {g : β → γ} (hg : uniform_embedding g)\n  {f : α → β} (hf : uniform_embedding f) : uniform_embedding (g ∘ f) :=\n{ inj := hg.inj.comp hf.inj,\n  ..hg.to_uniform_inducing.comp hf.to_uniform_inducing }\n\ntheorem uniform_embedding_def {f : α → β} :\n  uniform_embedding f ↔ function.injective f ∧ ∀ s, s ∈ 𝓤 α ↔\n    ∃ t ∈ 𝓤 β, ∀ x y : α, (f x, f y) ∈ t → (x, y) ∈ s :=\nbegin\n  split,\n  { rintro ⟨⟨h⟩, h'⟩,\n    rw [eq_comm, filter.ext_iff] at h,\n    simp [*, subset_def] },\n  { rintro ⟨h, h'⟩,\n    refine uniform_embedding.mk ⟨_⟩ h,\n    rw [eq_comm, filter.ext_iff],\n    simp [*, subset_def] }\nend\n\ntheorem uniform_embedding_def' {f : α → β} :\n  uniform_embedding f ↔ function.injective f ∧ uniform_continuous f ∧\n    ∀ s, s ∈ 𝓤 α →\n      ∃ t ∈ 𝓤 β, ∀ x y : α, (f x, f y) ∈ t → (x, y) ∈ s :=\nby simp only [uniform_embedding_def, uniform_continuous_def]; exact\n⟨λ ⟨I, H⟩, ⟨I, λ s su, (H _).2 ⟨s, su, λ x y, id⟩, λ s, (H s).1⟩,\n λ ⟨I, H₁, H₂⟩, ⟨I, λ s, ⟨H₂ s,\n   λ ⟨t, tu, h⟩, mem_of_superset (H₁ t tu) (λ ⟨a, b⟩, h a b)⟩⟩⟩\n\n/-- If the domain of a `uniform_inducing` map `f` is a `separated_space`, then `f` is injective,\nhence it is a `uniform_embedding`. -/\nprotected theorem uniform_inducing.uniform_embedding [separated_space α] {f : α → β}\n  (hf : uniform_inducing f) :\n  uniform_embedding f :=\n⟨hf, λ x y h, eq_of_uniformity_basis (hf.basis_uniformity (𝓤 β).basis_sets) $\n  λ s hs, mem_preimage.2 $ mem_uniformity_of_eq hs h⟩\n\n/-- If a map `f : α → β` sends any two distinct points to point that are **not** related by a fixed\n`s ∈ 𝓤 β`, then `f` is uniform inducing with respect to the discrete uniformity on `α`:\nthe preimage of `𝓤 β` under `prod.map f f` is the principal filter generated by the diagonal in\n`α × α`. -/\nlemma comap_uniformity_of_spaced_out {α} {f : α → β} {s : set (β × β)} (hs : s ∈ 𝓤 β)\n  (hf : pairwise (λ x y, (f x, f y) ∉ s)) :\n  comap (prod.map f f) (𝓤 β) = 𝓟 id_rel :=\nbegin\n  refine le_antisymm _ (@refl_le_uniformity α (uniform_space.comap f ‹_›)),\n  calc comap (prod.map f f) (𝓤 β) ≤ comap (prod.map f f) (𝓟 s) : comap_mono (le_principal_iff.2 hs)\n  ... = 𝓟 (prod.map f f ⁻¹' s) : comap_principal\n  ... ≤ 𝓟 id_rel : principal_mono.2 _,\n  rintro ⟨x, y⟩, simpa [not_imp_not] using hf x y\nend\n\n/-- If a map `f : α → β` sends any two distinct points to point that are **not** related by a fixed\n`s ∈ 𝓤 β`, then `f` is a uniform embedding with respect to the discrete uniformity on `α`. -/\nlemma uniform_embedding_of_spaced_out {α} {f : α → β} {s : set (β × β)} (hs : s ∈ 𝓤 β)\n  (hf : pairwise (λ x y, (f x, f y) ∉ s)) :\n  @uniform_embedding α β ⊥ ‹_› f :=\nbegin\n  letI : uniform_space α := ⊥, haveI : separated_space α := separated_iff_t2.2 infer_instance,\n  exact uniform_inducing.uniform_embedding ⟨comap_uniformity_of_spaced_out hs hf⟩\nend\n\nlemma uniform_inducing.uniform_continuous {f : α → β}\n  (hf : uniform_inducing f) : uniform_continuous f :=\nby simp [uniform_continuous, hf.comap_uniformity.symm, tendsto_comap]\n\nlemma uniform_inducing.uniform_continuous_iff {f : α → β} {g : β → γ} (hg : uniform_inducing g) :\n  uniform_continuous f ↔ uniform_continuous (g ∘ f) :=\nby { dsimp only [uniform_continuous, tendsto],\n  rw [← hg.comap_uniformity, ← map_le_iff_le_comap, filter.map_map] }\n\nlemma uniform_inducing.inducing {f : α → β} (h : uniform_inducing f) : inducing f :=\nbegin\n  refine ⟨eq_of_nhds_eq_nhds $ assume a, _ ⟩,\n  rw [nhds_induced, nhds_eq_uniformity, nhds_eq_uniformity, ← h.comap_uniformity,\n    comap_lift'_eq, comap_lift'_eq2];\n    { refl <|> exact monotone_preimage }\nend\n\nlemma uniform_inducing.prod {α' : Type*} {β' : Type*} [uniform_space α'] [uniform_space β']\n  {e₁ : α → α'} {e₂ : β → β'} (h₁ : uniform_inducing e₁) (h₂ : uniform_inducing e₂) :\n  uniform_inducing (λp:α×β, (e₁ p.1, e₂ p.2)) :=\n⟨by simp [(∘), uniformity_prod, h₁.comap_uniformity.symm, h₂.comap_uniformity.symm,\n           comap_inf, comap_comap]⟩\n\nlemma uniform_inducing.dense_inducing {f : α → β} (h : uniform_inducing f) (hd : dense_range f) :\n  dense_inducing f :=\n{ dense   := hd,\n  induced := h.inducing.induced }\n\nlemma uniform_embedding.embedding {f : α → β} (h : uniform_embedding f) : embedding f :=\n{ induced := h.to_uniform_inducing.inducing.induced,\n  inj := h.inj }\n\nlemma uniform_embedding.dense_embedding {f : α → β} (h : uniform_embedding f) (hd : dense_range f) :\n  dense_embedding f :=\n{ dense   := hd,\n  inj     := h.inj,\n  induced := h.embedding.induced }\n\nlemma closed_embedding_of_spaced_out {α} [topological_space α] [discrete_topology α]\n  [separated_space β] {f : α → β} {s : set (β × β)} (hs : s ∈ 𝓤 β)\n  (hf : pairwise (λ x y, (f x, f y) ∉ s)) :\n  closed_embedding f :=\nbegin\n  unfreezingI { rcases (discrete_topology.eq_bot α) with rfl }, letI : uniform_space α := ⊥,\n  exact { closed_range := is_closed_range_of_spaced_out hs hf,\n          .. (uniform_embedding_of_spaced_out hs hf).embedding }\nend\n\nlemma closure_image_mem_nhds_of_uniform_inducing\n  {s : set (α×α)} {e : α → β} (b : β)\n  (he₁ : uniform_inducing e) (he₂ : dense_inducing e) (hs : s ∈ 𝓤 α) :\n  ∃a, closure (e '' {a' | (a, a') ∈ s}) ∈ 𝓝 b :=\nhave s ∈ comap (λp:α×α, (e p.1, e p.2)) (𝓤 β),\n  from he₁.comap_uniformity.symm ▸ hs,\nlet ⟨t₁, ht₁u, ht₁⟩ := this in\nhave ht₁ : ∀p:α×α, (e p.1, e p.2) ∈ t₁ → p ∈ s, from ht₁,\nlet ⟨t₂, ht₂u, ht₂s, ht₂c⟩ := comp_symm_of_uniformity ht₁u in\nlet ⟨t, htu, hts, htc⟩ := comp_symm_of_uniformity ht₂u in\nhave preimage e {b' | (b, b') ∈ t₂} ∈ comap e (𝓝 b),\n  from preimage_mem_comap $ mem_nhds_left b ht₂u,\nlet ⟨a, (ha : (b, e a) ∈ t₂)⟩ := (he₂.comap_nhds_ne_bot _).nonempty_of_mem this in\nhave ∀b' (s' : set (β × β)), (b, b') ∈ t → s' ∈ 𝓤 β →\n  ({y : β | (b', y) ∈ s'} ∩ e '' {a' : α | (a, a') ∈ s}).nonempty,\n  from assume b' s' hb' hs',\n  have preimage e {b'' | (b', b'') ∈ s' ∩ t} ∈ comap e (𝓝 b'),\n    from preimage_mem_comap $ mem_nhds_left b' $ inter_mem hs' htu,\n  let ⟨a₂, ha₂s', ha₂t⟩ := (he₂.comap_nhds_ne_bot _).nonempty_of_mem this in\n  have (e a, e a₂) ∈ t₁,\n    from ht₂c $ prod_mk_mem_comp_rel (ht₂s ha) $ htc $ prod_mk_mem_comp_rel hb' ha₂t,\n  have e a₂ ∈ {b'':β | (b', b'') ∈ s'} ∩ e '' {a' | (a, a') ∈ s},\n    from ⟨ha₂s', mem_image_of_mem _ $ ht₁ (a, a₂) this⟩,\n  ⟨_, this⟩,\nhave ∀b', (b, b') ∈ t → ne_bot (𝓝 b' ⊓ 𝓟 (e '' {a' | (a, a') ∈ s})),\nbegin\n  intros b' hb',\n  rw [nhds_eq_uniformity, lift'_inf_principal_eq, lift'_ne_bot_iff],\n  exact assume s, this b' s hb',\n  exact monotone_inter monotone_preimage monotone_const\nend,\nhave ∀b', (b, b') ∈ t → b' ∈ closure (e '' {a' | (a, a') ∈ s}),\n  from assume b' hb', by rw [closure_eq_cluster_pts]; exact this b' hb',\n⟨a, (𝓝 b).sets_of_superset (mem_nhds_left b htu) this⟩\n\nlemma uniform_embedding_subtype_emb (p : α → Prop) {e : α → β} (ue : uniform_embedding e)\n  (de : dense_embedding e) : uniform_embedding (dense_embedding.subtype_emb p e) :=\n{ comap_uniformity := by simp [comap_comap, (∘), dense_embedding.subtype_emb,\n           uniformity_subtype, ue.comap_uniformity.symm],\n  inj := (de.subtype p).inj }\n\nlemma uniform_embedding.prod {α' : Type*} {β' : Type*} [uniform_space α'] [uniform_space β']\n  {e₁ : α → α'} {e₂ : β → β'} (h₁ : uniform_embedding e₁) (h₂ : uniform_embedding e₂) :\n  uniform_embedding (λp:α×β, (e₁ p.1, e₂ p.2)) :=\n{ inj := h₁.inj.prod_map h₂.inj,\n  ..h₁.to_uniform_inducing.prod h₂.to_uniform_inducing }\n\nlemma is_complete_of_complete_image {m : α → β} {s : set α} (hm : uniform_inducing m)\n  (hs : is_complete (m '' s)) : is_complete s :=\nbegin\n  intros f hf hfs,\n  rw le_principal_iff at hfs,\n  obtain ⟨_, ⟨x, hx, rfl⟩, hyf⟩ : ∃ y ∈ m '' s, map m f ≤ 𝓝 y,\n    from hs (f.map m) (hf.map hm.uniform_continuous)\n      (le_principal_iff.2 (image_mem_map hfs)),\n  rw [map_le_iff_le_comap, ← nhds_induced, ← hm.inducing.induced] at hyf,\n  exact ⟨x, hx, hyf⟩\nend\n\nlemma is_complete.complete_space_coe {s : set α} (hs : is_complete s) :\n  complete_space s :=\ncomplete_space_iff_is_complete_univ.2 $\n  is_complete_of_complete_image uniform_embedding_subtype_coe.to_uniform_inducing $ by simp [hs]\n\n/-- A set is complete iff its image under a uniform inducing map is complete. -/\nlemma is_complete_image_iff {m : α → β} {s : set α} (hm : uniform_inducing m) :\n  is_complete (m '' s) ↔ is_complete s :=\nbegin\n  refine ⟨is_complete_of_complete_image hm, λ c, _⟩,\n  haveI : complete_space s := c.complete_space_coe,\n  set m' : s → β := m ∘ coe,\n  suffices : is_complete (range m'), by rwa [range_comp, subtype.range_coe] at this,\n  have hm' : uniform_inducing m' := hm.comp uniform_embedding_subtype_coe.to_uniform_inducing,\n  intros f hf hfm,\n  rw filter.le_principal_iff at hfm,\n  have cf' : cauchy (comap m' f) :=\n    hf.comap' hm'.comap_uniformity.le (ne_bot.comap_of_range_mem hf.1 hfm),\n  rcases complete_space.complete cf' with ⟨x, hx⟩,\n  rw [hm'.inducing.nhds_eq_comap, comap_le_comap_iff hfm] at hx,\n  use [m' x, mem_range_self _, hx]\nend\n\nlemma complete_space_iff_is_complete_range {f : α → β} (hf : uniform_inducing f) :\n  complete_space α ↔ is_complete (range f) :=\nby rw [complete_space_iff_is_complete_univ, ← is_complete_image_iff hf, image_univ]\n\nlemma uniform_inducing.is_complete_range [complete_space α] {f : α → β}\n  (hf : uniform_inducing f) :\n  is_complete (range f) :=\n(complete_space_iff_is_complete_range hf).1 ‹_›\n\nlemma complete_space_congr {e : α ≃ β} (he : uniform_embedding e) :\n  complete_space α ↔ complete_space β :=\nby rw [complete_space_iff_is_complete_range he.to_uniform_inducing, e.range_eq_univ,\n  complete_space_iff_is_complete_univ]\n\nlemma complete_space_coe_iff_is_complete {s : set α} :\n  complete_space s ↔ is_complete s :=\n(complete_space_iff_is_complete_range uniform_embedding_subtype_coe.to_uniform_inducing).trans $\n  by rw [subtype.range_coe]\n\nlemma is_closed.complete_space_coe [complete_space α] {s : set α} (hs : is_closed s) :\n  complete_space s :=\nhs.is_complete.complete_space_coe\n\nlemma complete_space_extension {m : β → α} (hm : uniform_inducing m) (dense : dense_range m)\n  (h : ∀f:filter β, cauchy f → ∃x:α, map m f ≤ 𝓝 x) : complete_space α :=\n⟨assume (f : filter α), assume hf : cauchy f,\nlet\n  p : set (α × α) → set α → set α := λs t, {y : α| ∃x:α, x ∈ t ∧ (x, y) ∈ s},\n  g := (𝓤 α).lift (λs, f.lift' (p s))\nin\nhave mp₀ : monotone p,\n  from assume a b h t s ⟨x, xs, xa⟩, ⟨x, xs, h xa⟩,\nhave mp₁ : ∀{s}, monotone (p s),\n  from assume s a b h x ⟨y, ya, yxs⟩, ⟨y, h ya, yxs⟩,\n\nhave f ≤ g, from\n  le_infi $ assume s, le_infi $ assume hs, le_infi $ assume t, le_infi $ assume ht,\n  le_principal_iff.mpr $\n  mem_of_superset ht $ assume x hx, ⟨x, hx, refl_mem_uniformity hs⟩,\n\nhave ne_bot g, from hf.left.mono this,\n\nhave ne_bot (comap m g), from comap_ne_bot $ assume t ht,\n  let ⟨t', ht', ht_mem⟩ := (mem_lift_sets $ monotone_lift' monotone_const mp₀).mp ht in\n  let ⟨t'', ht'', ht'_sub⟩ := (mem_lift'_sets mp₁).mp ht_mem in\n  let ⟨x, (hx : x ∈ t'')⟩ := hf.left.nonempty_of_mem ht'' in\n  have h₀ : ne_bot (𝓝[range m] x),\n    from dense.nhds_within_ne_bot x,\n  have h₁ : {y | (x, y) ∈ t'} ∈ 𝓝[range m] x,\n    from @mem_inf_of_left α (𝓝 x) (𝓟 (range m)) _ $ mem_nhds_left x ht',\n  have h₂ : range m ∈ 𝓝[range m] x,\n    from @mem_inf_of_right α (𝓝 x) (𝓟 (range m)) _ $ subset.refl _,\n  have {y | (x, y) ∈ t'} ∩ range m ∈ 𝓝[range m] x,\n    from @inter_mem α (𝓝[range m] x) _ _ h₁ h₂,\n  let ⟨y, xyt', b, b_eq⟩ := h₀.nonempty_of_mem this in\n  ⟨b, b_eq.symm ▸ ht'_sub ⟨x, hx, xyt'⟩⟩,\n\nhave cauchy g, from\n  ⟨‹ne_bot g›, assume s hs,\n  let\n    ⟨s₁, hs₁, (comp_s₁ : comp_rel s₁ s₁ ⊆ s)⟩ := comp_mem_uniformity_sets hs,\n    ⟨s₂, hs₂, (comp_s₂ : comp_rel s₂ s₂ ⊆ s₁)⟩ := comp_mem_uniformity_sets hs₁,\n    ⟨t, ht, (prod_t : set.prod t t ⊆ s₂)⟩ := mem_prod_same_iff.mp (hf.right hs₂)\n  in\n  have hg₁ : p (preimage prod.swap s₁) t ∈ g,\n    from mem_lift (symm_le_uniformity hs₁) $ @mem_lift' α α f _ t ht,\n  have hg₂ : p s₂ t ∈ g,\n    from mem_lift hs₂ $ @mem_lift' α α f _ t ht,\n  have hg : set.prod (p (preimage prod.swap s₁) t) (p s₂ t) ∈ g ×ᶠ g,\n    from @prod_mem_prod α α _ _ g g hg₁ hg₂,\n  (g ×ᶠ g).sets_of_superset hg\n    (assume ⟨a, b⟩ ⟨⟨c₁, c₁t, hc₁⟩, ⟨c₂, c₂t, hc₂⟩⟩,\n      have (c₁, c₂) ∈ set.prod t t, from ⟨c₁t, c₂t⟩,\n      comp_s₁ $ prod_mk_mem_comp_rel hc₁ $\n      comp_s₂ $ prod_mk_mem_comp_rel (prod_t this) hc₂)⟩,\n\nhave cauchy (filter.comap m g),\n  from ‹cauchy g›.comap' (le_of_eq hm.comap_uniformity) ‹_›,\n\nlet ⟨x, (hx : map m (filter.comap m g) ≤ 𝓝 x)⟩ := h _ this in\nhave cluster_pt x (map m (filter.comap m g)),\n  from (le_nhds_iff_adhp_of_cauchy (this.map hm.uniform_continuous)).mp hx,\nhave cluster_pt x g,\n  from  this.mono map_comap_le,\n\n⟨x, calc f ≤ g : by assumption\n  ... ≤ 𝓝 x : le_nhds_of_cauchy_adhp ‹cauchy g› this⟩⟩\n\nlemma totally_bounded_preimage {f : α → β} {s : set β} (hf : uniform_embedding f)\n  (hs : totally_bounded s) : totally_bounded (f ⁻¹' s) :=\nλ t ht, begin\n  rw ← hf.comap_uniformity at ht,\n  rcases mem_comap.2 ht with ⟨t', ht', ts⟩,\n  rcases totally_bounded_iff_subset.1\n    (totally_bounded_subset (image_preimage_subset f s) hs) _ ht' with ⟨c, cs, hfc, hct⟩,\n  refine ⟨f ⁻¹' c, hfc.preimage (hf.inj.inj_on _), λ x h, _⟩,\n  have := hct (mem_image_of_mem f h), simp at this ⊢,\n  rcases this with ⟨z, zc, zt⟩,\n  rcases cs zc with ⟨y, yc, rfl⟩,\n  exact ⟨y, zc, ts (by exact zt)⟩\nend\n\nend\n\nlemma uniform_embedding_comap {α : Type*} {β : Type*} {f : α → β} [u : uniform_space β]\n  (hf : function.injective f) : @uniform_embedding α β (uniform_space.comap f u) u f :=\n@uniform_embedding.mk _ _ (uniform_space.comap f u) _ _\n  (@uniform_inducing.mk _ _ (uniform_space.comap f u) _ _ rfl) hf\n\nsection uniform_extension\n\nvariables {α : Type*} {β : Type*} {γ : Type*}\n          [uniform_space α] [uniform_space β] [uniform_space γ]\n          {e : β → α}\n          (h_e : uniform_inducing e)\n          (h_dense : dense_range e)\n          {f : β → γ}\n          (h_f : uniform_continuous f)\n\nlocal notation `ψ` := (h_e.dense_inducing h_dense).extend f\n\nlemma uniformly_extend_exists [complete_space γ] (a : α) :\n  ∃c, tendsto f (comap e (𝓝 a)) (𝓝 c) :=\nlet de := (h_e.dense_inducing h_dense) in\nhave cauchy (𝓝 a), from cauchy_nhds,\nhave cauchy (comap e (𝓝 a)), from\n  this.comap' (le_of_eq h_e.comap_uniformity) (de.comap_nhds_ne_bot _),\nhave cauchy (map f (comap e (𝓝 a))), from this.map h_f,\ncomplete_space.complete this\n\nlemma uniform_extend_subtype [complete_space γ]\n  {p : α → Prop} {e : α → β} {f : α → γ} {b : β} {s : set α}\n  (hf : uniform_continuous (λx:subtype p, f x.val))\n  (he : uniform_embedding e) (hd : ∀x:β, x ∈ closure (range e))\n  (hb : closure (e '' s) ∈ 𝓝 b) (hs : is_closed s) (hp : ∀x∈s, p x) :\n  ∃c, tendsto f (comap e (𝓝 b)) (𝓝 c) :=\nhave de : dense_embedding e,\n  from he.dense_embedding hd,\nhave de' : dense_embedding (dense_embedding.subtype_emb p e),\n  by exact de.subtype p,\nhave ue' : uniform_embedding (dense_embedding.subtype_emb p e),\n  from uniform_embedding_subtype_emb _ he de,\nhave b ∈ closure (e '' {x | p x}),\n  from (closure_mono $ monotone_image $ hp) (mem_of_mem_nhds hb),\nlet ⟨c, (hc : tendsto (f ∘ subtype.val)\n     (comap (dense_embedding.subtype_emb p e) (𝓝 ⟨b, this⟩)) (𝓝 c))⟩ :=\n  uniformly_extend_exists ue'.to_uniform_inducing de'.dense hf _ in\nbegin\n  rw [nhds_subtype_eq_comap] at hc,\n  simp [comap_comap] at hc,\n  change (tendsto (f ∘ @subtype.val α p) (comap (e ∘ @subtype.val α p) (𝓝 b)) (𝓝 c)) at hc,\n  rw [←comap_comap, tendsto_comap'_iff] at hc,\n  exact ⟨c, hc⟩,\n  exact ⟨_, hb, assume x,\n    begin\n      change e x ∈ (closure (e '' s)) → x ∈ range subtype.val,\n      rw [← closure_induced, mem_closure_iff_cluster_pt, cluster_pt, ne_bot_iff,\n          nhds_induced, ← de.to_dense_inducing.nhds_eq_comap,\n          ← mem_closure_iff_nhds_ne_bot, hs.closure_eq],\n      exact assume hxs, ⟨⟨x, hp x hxs⟩, rfl⟩,\n    end⟩\nend\n\ninclude h_f\n\nlemma uniformly_extend_spec [complete_space γ] (a : α) :\n  tendsto f (comap e (𝓝 a)) (𝓝 (ψ a)) :=\nby simpa only [dense_inducing.extend] using tendsto_nhds_lim (uniformly_extend_exists h_e ‹_› h_f _)\n\nlemma uniform_continuous_uniformly_extend [cγ : complete_space γ] : uniform_continuous ψ :=\nassume d hd,\nlet ⟨s, hs, hs_comp⟩ := (mem_lift'_sets $\n  monotone_comp_rel monotone_id $ monotone_comp_rel monotone_id monotone_id).mp\n    (comp_le_uniformity3 hd) in\nhave h_pnt : ∀{a m}, m ∈ 𝓝 a → ∃c, c ∈ f '' preimage e m ∧ (c, ψ a) ∈ s ∧ (ψ a, c) ∈ s,\n  from assume a m hm,\n  have nb : ne_bot (map f (comap e (𝓝 a))),\n    from ((h_e.dense_inducing h_dense).comap_nhds_ne_bot _).map _,\n  have (f '' preimage e m) ∩ ({c | (c, ψ a) ∈ s } ∩ {c | (ψ a, c) ∈ s }) ∈ map f (comap e (𝓝 a)),\n    from inter_mem (image_mem_map $ preimage_mem_comap $ hm)\n      (uniformly_extend_spec h_e h_dense h_f _\n        (inter_mem (mem_nhds_right _ hs) (mem_nhds_left _ hs))),\n  nb.nonempty_of_mem this,\nhave preimage (λp:β×β, (f p.1, f p.2)) s ∈ 𝓤 β,\n  from h_f hs,\nhave preimage (λp:β×β, (f p.1, f p.2)) s ∈ comap (λx:β×β, (e x.1, e x.2)) (𝓤 α),\n  by rwa [h_e.comap_uniformity.symm] at this,\nlet ⟨t, ht, ts⟩ := this in\nshow preimage (λp:(α×α), (ψ p.1, ψ p.2)) d ∈ 𝓤 α,\n  from (𝓤 α).sets_of_superset (interior_mem_uniformity ht) $\n  assume ⟨x₁, x₂⟩ hx_t,\n  have 𝓝 (x₁, x₂) ≤ 𝓟 (interior t),\n    from is_open_iff_nhds.mp is_open_interior (x₁, x₂) hx_t,\n  have interior t ∈ 𝓝 x₁ ×ᶠ 𝓝 x₂,\n    by rwa [nhds_prod_eq, le_principal_iff] at this,\n  let ⟨m₁, hm₁, m₂, hm₂, (hm : set.prod m₁ m₂ ⊆ interior t)⟩ := mem_prod_iff.mp this in\n  let ⟨a, ha₁, _, ha₂⟩ := h_pnt hm₁ in\n  let ⟨b, hb₁, hb₂, _⟩ := h_pnt hm₂ in\n  have set.prod (preimage e m₁) (preimage e m₂) ⊆ preimage (λp:(β×β), (f p.1, f p.2)) s,\n    from calc _ ⊆ preimage (λp:(β×β), (e p.1, e p.2)) (interior t) : preimage_mono hm\n    ... ⊆ preimage (λp:(β×β), (e p.1, e p.2)) t : preimage_mono interior_subset\n    ... ⊆ preimage (λp:(β×β), (f p.1, f p.2)) s : ts,\n  have set.prod (f '' preimage e m₁) (f '' preimage e m₂) ⊆ s,\n    from calc set.prod (f '' preimage e m₁) (f '' preimage e m₂) =\n      (λp:(β×β), (f p.1, f p.2)) '' (set.prod (preimage e m₁) (preimage e m₂)) : prod_image_image_eq\n    ... ⊆ (λp:(β×β), (f p.1, f p.2)) '' preimage (λp:(β×β), (f p.1, f p.2)) s : monotone_image this\n    ... ⊆ s : image_subset_iff.mpr $ subset.refl _,\n  have (a, b) ∈ s, from @this (a, b) ⟨ha₁, hb₁⟩,\n  hs_comp $ show (ψ x₁, ψ x₂) ∈ comp_rel s (comp_rel s s),\n    from ⟨a, ha₂, ⟨b, this, hb₂⟩⟩\n\nomit h_f\n\nvariables [separated_space γ]\n\nlemma uniformly_extend_of_ind (b : β) : ψ (e b) = f b :=\ndense_inducing.extend_eq_at _ h_f.continuous.continuous_at\n\nlemma uniformly_extend_unique {g : α → γ} (hg : ∀ b, g (e b) = f b)\n  (hc : continuous g) :\n  ψ = g :=\ndense_inducing.extend_unique _ hg hc\n\nend uniform_extension\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/topology/uniform_space/uniform_embedding.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.49109642742286325}}
{"text": "import category_theory.basic\nimport category_theory.instances\nimport category_theory.universal_properties.colimit\nimport misc.graph\nimport misc.matrix\n\nuniverses v u vᵢ uᵢ\n\nopen classical\n\nnamespace category\n\ndef is_product {C : Type u} [category.{v} C] {I : Type uᵢ} (f : I → C) : \n  (Σ p : C, Π i : I, Mor p (f i)) → Prop \n| ⟨p,j⟩ := ∀ pair : (Σ p : C, Π i : I, Mor p (f i)), ∃! φ : Mor pair.1 p, ∀ i : I, pair.2 i = (j i) ∘ₘ φ\n\n-- the following makes is_product a little easier to work with.\n\ntheorem is_product_fn {C : Type u} [category.{v} C] {I : Type uᵢ} {f : I → C} \n  {prod :Σ p : C, Π i : I, Mor p (f i)} : is_product f prod → \n  ∀ pair : (Σ p : C, Π i : I, Mor p (f i)), ∃! φ : Mor pair.1 prod.1, \n  ∀ i : I, pair.2 i = (prod.2 i) ∘ₘ φ :=\nbegin\n  intro hprod,\n  have hrw : prod = ⟨prod.1,prod.2⟩,\n    apply sigma.eq,\n    refl,\n    refl,\n  rw hrw at hprod,\n  exact hprod, \nend\n\ntheorem pi_type_product {I : Type u} {β : I → Type u} \n  : is_product β ⟨Π i, β i, λ i f, f i⟩ :=\nbegin\n  intro pair,\n  cases pair with p' j',\n  dsimp,\n  existsi  λ x : p', λ i : I, j' i x,\n  dsimp,\n  split,\n  intro i,\n  refl,\n  intros ψ hψ,\n  apply funext,\n  intro a,\n  apply funext,\n  intro i,\n  rw hψ,\n  rw set_comp_app,\nend\n\ntheorem product_essentially_unquie {C : Type u} [category.{v} C] {I : Type uᵢ} {f : I → C} \n  {p₁ p₂ :(Σ p : C, Π i : I, Mor p (f i))} : is_product f p₁ → is_product f p₂ \n  → ∃! φ : Mor p₁.1 p₂.1, isomorphism φ ∧ (∀ i : I, p₁.2 i = (p₂.2 i) ∘ₘ φ ):=\nbegin\n  intros hp₁ hp₂,\n  cases p₁ with p₁ j₁,\n  cases p₂ with p₂ j₂,\n  cases hp₂ ⟨p₁,j₁⟩ with φ₁ hφ₁,\n  cases hp₁ ⟨p₂,j₂⟩ with φ₂ hφ₂,\n  cases hp₁ ⟨p₁, λ i, (j₂ i) ∘ₘ φ₁⟩ with id₁ hid₁,\n  cases hp₂ ⟨p₂, λ i, (j₁ i) ∘ₘ φ₂⟩ with id₂ hid₂,\n  dsimp at hφ₁,\n  dsimp at hφ₂,\n  dsimp at hid₁,\n  dsimp at hid₂,\n  cases hφ₁ with hφ₁ uφ₁,\n  cases hφ₂ with hφ₂ uφ₂,\n  cases hid₁ with hid₁ uid₁,\n  cases hid₂ with hid₂ uid₂,\n  have hrw₁ : idₘ p₁ = id₁,\n    apply uid₁,\n    simp [id_comp_right,← hφ₁],\n  have hrw₂ : idₘ p₂ = id₂,\n    apply uid₂,\n    simp [id_comp_right,← hφ₂],\n  existsi φ₁,\n  dsimp,\n  split,\n  split,\n  existsi φ₂,\n  rw [hrw₁,hrw₂],\n  split,\n  apply uid₂,\n  simp [comp_assoc,hφ₁],\n  apply uid₁,\n  simp [comp_assoc,hφ₂],\n  exact hφ₁,\n  intros φ hφ,\n  apply uφ₁,\n  exact hφ.2,\nend\n\nnoncomputable def prod_can_iso {C : Type u} [category.{v} C] {I : Type uᵢ} {f : I → C} \n  {p₁ p₂ :(Σ p : C, Π i : I, Mor p (f i))} : is_product f p₁ → is_product f p₂ \n  → Mor p₁.1 p₂.1 := λ hp₁ hp₂, some (product_essentially_unquie hp₁ hp₂)\n\ntheorem prod_can_iso_property {C : Type u} [category.{v} C] {I : Type uᵢ} {f : I → C} \n  {p₁ p₂ : (Σ p : C, Π i : I, Mor p (f i))} : Π (hp₁ : is_product f p₁) (hp₂ : is_product f p₂),\n  (isomorphism (prod_can_iso hp₁ hp₂) ∧ ( Π i : I, p₁.2 i = p₂.2 i ∘ₘ (prod_can_iso hp₁ hp₂))) \n  ∧ (∀ φ : Mor p₁.1 p₂.1, ((isomorphism φ ∧ ( Π i : I, p₁.2 i = p₂.2 i ∘ₘ φ)) \n  → φ = prod_can_iso hp₁ hp₂)) := λ hp₁ hp₂, some_spec (product_essentially_unquie hp₁ hp₂)\n\nclass has_products (C : Type u) [category.{v} C] :=\n(all_products_exist : ∀ {I : Type uᵢ} (f : I → C) , ∃ p : (Σ p : C, Π i : I, Mor p (f i)), \n  is_product f p)\n\nnoncomputable def product {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I : Type uᵢ} \n  (f : I → C) : (Σ p : C, Π i : I, Mor p (f i)) := some (has_products.all_products_exist f) \n\nprefix `Π₀`:110 := product\n\ntheorem has_product_prod_is_prod {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I : Type uᵢ} \n  (f : I → C) : is_product f (Π₀ f) := some_spec (has_products.all_products_exist f) \n\nnoncomputable def into_product {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I : Type uᵢ} \n  {f : I → C} {A : C} (g : Π i : I, Mor A (f i)) \n  : Mor A (Π₀ f).1 := some (is_product_fn (has_product_prod_is_prod f) ⟨A,g⟩)\n\ntheorem into_product_property {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I : Type uᵢ} \n  {f : I → C} {A : C} (g : Π i : I, Mor A (f i)) : (∀ i : I, g i = ((Π₀f).2 i) ∘ₘ (into_product g)) ∧ \n  ∀ φ : Mor A (Π₀f).1, (∀ i, g i = ((Π₀f).2 i) ∘ₘ φ) → φ = into_product g \n  := some_spec (is_product_fn (has_product_prod_is_prod f) ⟨A,g⟩)\n\ntheorem into_product_property_comp {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I : Type uᵢ} \n  {f : I → C} {A : C} (g : Π i : I, Mor A (f i)) : ∀ i : I, g i = ((Π₀f).2 i) ∘ₘ (into_product g)\n  := (into_product_property g).1\n\ntheorem into_product_property_up {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] \n  {I : Type uᵢ} {f : I → C} {A : C} (g : Π i : I, Mor A (f i)) \n  : ∀ φ : Mor A (Π₀f).1, (∀ i, g i = ((Π₀f).2 i) ∘ₘ φ) → φ = into_product g \n  := (into_product_property g).2\n\ntheorem double_prod_prod_left {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I J : Type uᵢ} \n  (f : I → J → C) : is_product (function.uncurry f) ⟨(Π₀ (λ i : I,(Π₀ (λ j : J,f i j)).1)).1, \n  λ ij : I × J, (Π₀ (λ k : J, f ij.1 k)).2 ij.2 ∘ₘ (Π₀ (λ i : I,(Π₀ (λ j : J,f i j)).1)).2 ij.1⟩ := \nbegin\n  simp[is_product],\n  intro,\n  cases pair with p g,\n  let φ : Mor p (Π₀ (λ i : I,(Π₀ (λ j : J,f i j)).1)).1,\n    apply into_product,\n    intro i,\n    apply into_product,\n    intro j,\n    exact g (i,j),\n  existsi φ,\n  simp[φ],\n  split,\n  intro ij,\n  cases ij with i j,\n  rw ← comp_assoc,\n  simp[← into_product_property_comp],\n  intros ψ hψ,\n  apply into_product_property_up,\n  intro i,\n  symmetry,\n  apply into_product_property_up,\n  intro j,\n  rw hψ (i,j),\n  rw comp_assoc,\nend\n\ntheorem double_prod_prod_right {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I J : Type uᵢ} \n  (f : I → J → C) : is_product (function.uncurry f) ⟨(Π₀ (λ j : J ,(Π₀ (λ i : I,f i j)).1)).1, \n  λ ij : I × J, (Π₀ (λ k : I, f k ij.2)).2 ij.1 ∘ₘ (Π₀ (λ j : J ,(Π₀ (λ i : I,f i j)).1)).2 ij.2⟩ := \nbegin\n  simp[is_product],\n  intro,\n  cases pair with p g,\n  let φ : Mor p (Π₀ (λ j : J,(Π₀ (λ i : I,f i j)).1)).1,\n    apply into_product,\n    intro j,\n    apply into_product,\n    intro i,\n    exact g (i,j),\n  existsi φ,\n  simp[φ],\n  split,\n  intro ij,\n  cases ij with i j,\n  rw ← comp_assoc,\n  simp[← into_product_property_comp],\n  intros ψ hψ,\n  apply into_product_property_up,\n  intro j,\n  symmetry,\n  apply into_product_property_up,\n  intro i,\n  rw hψ (i,j),\n  rw comp_assoc,\nend\n\ntheorem product_of_morphisms_exist {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] {I : Type uᵢ} \n  {f₁ f₂ : I → C} (φ : Π i : I, Mor (f₁ i) (f₂ i)) : ∃! ψ : Mor (Π₀ f₁).1 (Π₀ f₂).1, ∀ i : I,\n  (Π₀ f₂).2 i ∘ₘ ψ = φ i ∘ₘ (Π₀ f₁).2 i :=\nbegin\n  let ψ : Mor (Π₀ f₁).1 (Π₀ f₂).1,\n    apply into_product,\n    intro i,\n    exact φ i ∘ₘ (Π₀ f₁).2 i,\n  existsi ψ,\n  simp[ψ], \n  split,\n  simp[← into_product_property_comp],\n  intros ϕ hϕ,\n  apply into_product_property_up,\n  simp [hϕ],\nend\n\nnoncomputable def product_of_morphisms {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] \n  {I : Type uᵢ} {f₁ f₂ : I → C} (φ : Π i : I, Mor (f₁ i) (f₂ i)) : Mor (Π₀f₁).1 (Π₀f₂).1 := \n  some (product_of_morphisms_exist φ)\n\nprefix `Πₘ`:110 := product_of_morphisms\n\ntheorem product_of_morphisms_property {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] \n  {I : Type uᵢ} {f₁ f₂ : I → C} (φ : Π i : I, Mor (f₁ i) (f₂ i))\n  : (∀ i : I, (Π₀ f₂).2 i ∘ₘ Πₘ φ = φ i ∘ₘ (Π₀ f₁).2 i) ∧ (∀ ψ : Mor (Π₀f₁).1 (Π₀f₂).1,\n  (∀ i : I, (Π₀ f₂).2 i ∘ₘ ψ  = φ i ∘ₘ (Π₀ f₁).2 i) → ψ = Πₘ φ) \n  := some_spec (product_of_morphisms_exist φ)\n\ntheorem product_of_morphisms_property_comp {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] \n  {I : Type uᵢ} {f₁ f₂ : I → C} (φ : Π i : I, Mor (f₁ i) (f₂ i))\n  : ∀ i : I, (Π₀ f₂).2 i ∘ₘ Πₘ φ = φ i ∘ₘ (Π₀ f₁).2 i := (product_of_morphisms_property φ).1\n\ntheorem product_of_morphisms_property_up {C : Type u} [category.{v} C] [has_products.{v u uᵢ} C] \n  {I : Type uᵢ} {f₁ f₂ : I → C} (φ : Π i : I, Mor (f₁ i) (f₂ i))\n  : ∀ ψ : Mor (Π₀f₁).1 (Π₀f₂).1, (∀ i : I, (Π₀ f₂).2 i ∘ₘ ψ  = φ i ∘ₘ (Π₀ f₁).2 i) \n  → ψ = Πₘ φ := (product_of_morphisms_property φ).2\n\ndef is_equaliser {C : Type u} [category.{v} C] {A B : C} (f₁ f₂ : Mor A B) : (Σ E, Mor E A) → Prop \n| ⟨E,f⟩ := f₁ ∘ₘ f = f₂ ∘ₘ f ∧ ∀ p : (Σ E, Mor E A), f₁ ∘ₘ p.2 = f₂ ∘ₘ p.2 \n  → ∃! φ : Mor p.1 E, p.2 = f ∘ₘ φ\n\nend category", "meta": {"author": "CameronTorrance", "repo": "Schemes", "sha": "f407ce80b8407101231170680b03b55984c42496", "save_path": "github-repos/lean/CameronTorrance-Schemes", "path": "github-repos/lean/CameronTorrance-Schemes/Schemes-f407ce80b8407101231170680b03b55984c42496/src/category_theory/universal_properties/product.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4910964229244284}}
{"text": "import NBG.SetTheory.Defs\nimport NBG.SetTheory.Axioms.Domain\n\nopen Classical\n\n-- 8. AxiomMembership\naxiom AxiomMembership :\n  ∃E: Class, ∀z: Class,\n    (z ∈ E ↔ ∃x y: Class, ∃_: Set x, ∃_: Set y,\n      ∃_:x ∈ y,\n        z ＝ ＜x, y＞)\n\n-- class E\nnoncomputable def E: Class := choose AxiomMembership\nnoncomputable def E_def:\n  ∀z: Class,\n    (z ∈ E ↔ ∃x y: Class, ∃_: Set x, ∃_: Set y,\n      ∃_:x ∈ y,\n        z ＝ ＜x, y＞) :=\n  choose_spec AxiomMembership\n\ntheorem EIsRelation:\n  isRelation E := by {\n  intro z h;\n  have ⟨x,y,hx,hy,_,heq⟩ := (E_def z).1 h;\n  exact ⟨x,y,hx,hy,heq⟩;\n}\n\ntheorem DomEEqUniv : (Dom E) ＝ U := by {\n  rw [AxiomExtensionality];\n  intro z;\n  rw [Dom_def];\n  apply Iff.intro;\n  {\n    intro h;\n    let h1 := choose_spec h;\n    let h2 := choose_spec h1;\n    let h3 := choose_spec h2;\n    let h4 := choose_spec h3;\n    let x := choose h;\n    have set_x: Set x := choose h2;\n    have heq: z ＝ x := choose_spec h4;\n    exact ClassEqMenberImpMenber heq set_x.2;\n  }\n  {\n    intro h;\n    have set_z := Set.mk₂ h;\n    let y := Singleton_mk z;\n    have hy :=Singleton_def z;\n    have set_y := Set.mk₂ hy.1;\n    have z_in_y : z ∈ y := (hy.2 z).2 (ClassEq.refl _);\n    have hin := (E_def ＜z,y＞).2 ⟨z,y,set_z,set_y,z_in_y,ClassEq.refl _⟩\n    exists z,y,set_z,set_y,hin;\n    exact ClassEq.refl _;\n  }\n}\n\n-- Image type\ntheorem ImageClassExists (R X: Class.{u}) [hR: Relation R]:\n  ∃Im: Class.{u}, ∀z: Class,\n    ((z ∈ Im)\n      ↔ (∃x y: Class, ∃_: Set y, ∃(hx:x ∈ X), ∃(_:(@OrdPair_mk x y (Set.mk₁ hx) _)∈ R),\n        z ＝ y)) := by {\n  have : Relation (R ∩ (X ✕ U)) :=\n    ⟨fun z h => (hR.1 z) ((IntersectionClass_def R (X ✕ U) z).1 h).1⟩;\n  let im := Rng (R ∩ (X ✕ U));\n  let im_def := Rng_def (R ∩ (X ✕ U));\n  have inter_def := IntersectionClass_def R (X ✕ U);\n  have rel_def := hR.1;\n  have prod_def := ProductClass_def X U;\n  exists im;\n  intro z;\n  apply Iff.intro;\n  {\n    intro h;\n    have ⟨x,y,set_x,set_y,hin,heq⟩ := (im_def z).1 h;\n    have h1 := (inter_def ＜x, y＞).1 hin;\n    have ⟨x2,y2,set_x2,set_y2,heq2⟩ := (rel_def ＜x, y＞) h1.1;\n    have ⟨x3,y3,hx3,hy3,heq3⟩ := (prod_def ＜x, y＞).1 h1.2;\n    have set_x3 := Set.mk₁ hx3;\n    have set_y3 := Set.mk₁ hy3;\n    rw [OrdPairEq] at heq2;\n    rw [OrdPairEq] at heq3;\n    exists x,y,set_y,ClassEqMenberImpMenber heq3.1 hx3;\n    exists ClassEqMenberImpMenber (OrdPairEq.2 ⟨ClassEq.refl _,ClassEq.refl _⟩) h1.1;\n  }\n  {\n    intro ⟨x,y,set_y,x_in_X,xy_in_R,heq⟩;\n    have set_x := Set.mk₁ x_in_X;\n    apply (im_def z).2;\n    clear im_def;\n    exists x,y,set_x,set_y;\n    have h2 := (prod_def ＜x,y＞).2 ⟨x,y,x_in_X,set_y.2,(OrdPairEq.2 ⟨ClassEq.refl _,ClassEq.refl _⟩)⟩;\n    have h3 := (inter_def ＜x,y＞).2 ⟨xy_in_R,h2⟩;\n    exists h3;\n  }\n}\nnoncomputable def Im (R X: Class) [Relation R]: Class :=\n  choose (ImageClassExists R X)\nnoncomputable def ImageClass_def (R X: Class.{u}) [Relation R]:\n  ∀z: Class,\n      ((z ∈ (Im R X))\n        ↔ (∃x y: Class, ∃_: Set y, ∃(hx:x ∈ X), ∃(_:(@OrdPair_mk x y (Set.mk₁ hx) _)∈ R),\n          z ＝ y)) :=\n  choose_spec (ImageClassExists R X)\n\ntheorem PreImageClassExists (R X: Class) [Relation R]:\n  ∃PreIm: Class, ∀z: Class,\n    ((z ∈ PreIm)\n      ↔ (∃x y: Class, ∃_: Set y, ∃(hx:x ∈ X), ∃(_:(@OrdPair_mk x y (Set.mk₁ hx) _) ∈ (RelInv R)),\n        z ＝ y)) :=\n  @ImageClassExists (RelInv R) X ⟨RelInvRelationIsRelation⟩\n\n\nnoncomputable def Apply (F x: Class) {h: x ∈ (Dom F)} : Class :=\n  choose (choose_spec ((Dom_def F x).1 h))\nnoncomputable def Apply_def (F x: Class) {h: x ∈ (Dom F)} :=\n  choose_spec ((Dom_def F x).1 h)\nnoncomputable def TargetIsSet (F x: Class) {h: x ∈ (Dom F)} : Set (@Apply F x h) :=\n  choose (choose_spec (choose_spec (choose_spec ((Dom_def F x).1 h))))\nnoncomputable def SourceTargetPairIsIn (F x: Class) {h: x ∈ (Dom F)} :\n  (@OrdPair_mk x (@Apply F x h) (Set.mk₁ h) (TargetIsSet F x)) ∈ F := by {\n  have h1 := choose_spec ((Dom_def F x).1 h);\n  have h2 := choose_spec h1;\n  have h3 := choose_spec h2;\n  have h4 := choose_spec h3;\n  let u := choose ((Dom_def F x).1 h);\n  let v := choose h1;\n  have set_u : Set u := choose h2;\n  have set_v : Set v := choose h3;\n  have hin : ＜u,v＞ ∈ F := choose h4;\n  have heq_x : x ＝ u := choose_spec h4;\n  let y := @Apply F x h;\n  have heq_y: y ＝ v := ClassEq.refl _;\n  have set_x := Set.mk₁ h;\n  have set_y := @TargetIsSet F x h;\n  apply ClassEqMenberImpMenber _ hin;\n  exact (@OrdPairEq x y u v set_x set_y set_u set_v).2 ⟨heq_x,heq_y⟩;\n}\ntheorem ApplyFunctionUniqueTarget (F x x': Class) [set_x:Set x] [set_x':Set x']\n    {hx: x ∈ (Dom F)} {hx': x' ∈ (Dom F)} [hF: Function F]:\n      x ＝ x' →  @Apply F x hx ＝ @Apply F x' hx' := by {\n  let y := @Apply F x hx;\n  let y' := @Apply F x' hx';\n  have set_y: Set y := @TargetIsSet F x hx;\n  have set_y': Set y' := @TargetIsSet F x' hx';\n  have F_def: ＜x, y＞ ∈ F → ＜x', y'＞ ∈ F\n    → x ＝ x' → y ＝ y' :=\n    hF.2 x x' y y' set_x set_x' set_y set_y';\n  have hxy: ＜x, y＞ ∈ F := @SourceTargetPairIsIn F x hx;\n  have hxy': ＜x', y'＞ ∈ F := @SourceTargetPairIsIn F x' hx';\n  exact fun h => F_def hxy hxy' h;\n}\n\n-- define useful notation\nnoncomputable def as_map (F x: Class) [Relation F] {h: x ∈ Dom F}: Class := by\nexact (@Apply F x h)\nnotation F\"【\"x\"】\" => as_map F x\n\n/-- The brige theorem of image and function, namely f[ X ] = {f(x)}. -/\ntheorem SingleSetFunctionImageIsSingleton (F x: Class) [hx: Set x] {h: x ∈ (Dom F)} [hF: Function F]:\n  Im F x ＝ @Singleton_mk (@as_map F x hF.1 h) (TargetIsSet F x) := by {\n  sorry;\n}\n\n-- injective, surjective, bijective\n\n-- Todo\n\n\n-- restriction\nnoncomputable def Restriction (F X: Class) := F ∩ (X ✕ U)\ninfix:50 \" ↾ \"  => Restriction\n\n-- UnionAll\nnoncomputable def UnionAll_mk' (X : Class) :=\n  Dom (E ∩ (U ✕ X))\nnoncomputable instance : HasUnionAll Class where\n  UnionAll := UnionAll_mk'\n\n-- InterAll\nnoncomputable def InterAll_mk' (X : Class) :=\n  Diff U (Dom ((Diff U₂ E) ∩ (U ✕ X)))\nnoncomputable instance : HasInterAll Class where\n  InterAll := InterAll_mk'\n\n-- PowerClass\nnoncomputable def PowerClass_mk' (X : Class) : Class :=\n  Diff U (Dom ((RelInv E) ∩ (U ✕ (Diff U X))))\n\ntheorem PowerClassExists (X : Class):\n  ∃PX: Class,\n    ∀z: Class, ∀_: Set z,\n      z ∈ PX ↔ (z ⊂ X) := by {\n  let px := Diff U (Dom ((RelInv E) ∩ (U ✕ (Diff U X))));\n  have px_def := Diff_def U (Dom ((RelInv E) ∩ (U ✕ (Diff U X))));\n  have dom_def := Dom_def ((RelInv E) ∩ (U ✕ (Diff U X)));\n  have inter_def := IntersectionClass_def (RelInv E) (U ✕ (Diff U X));\n  have rel_inv_def := RelInv_def E;\n  have prod_def := ProductClass_def U (Diff U X);\n  have diff_def := Diff_def U X;\n  have E_def := E_def;\n  exists px;\n  intro z set_z;\n  apply Iff.intro;\n  {\n    intro h u hu;\n    have set_u :=  (Set.mk₁ hu);\n    have h1 := ((px_def z).1 h);\n    have h2 := (\n      ImpIffNotImpNot.1 (\n        NotExistsImpForall (\n          NotExistsImpForall (\n            NotExistsImpForall (\n              NotExistsImpForall (\n                NotExistsImpForall (\n                  (IffIffNotIffNot.1 (dom_def z)).2 h1.2) z) u) set_z) set_u)) (IffNotNot.1 ((ClassEq.refl _))));\n    have h3 := NotAndIffNotOrNot.1 ((IffIffNotIffNot.1 (inter_def ＜z,u＞)).2 h2);\n    cases h3;\n    case mp.inl h3 => {\n      have h4 := ImpIffNotImpNot.1 (\n        ExistsIffNotForall.1 (\n          ExistsIffNotForall.1 (\n            ExistsIffNotForall.1 (\n              ExistsIffNotForall.1 (\n                ExistsIffNotForall.1 (\n                  (IffIffNotIffNot.1 (rel_inv_def ＜z,u＞)).2 h3) u) z) set_u) set_z)) (IffNotNot.symm.2 (ClassEq.refl _));\n      have := (E_def ＜u,z＞).2;\n      have h5 := (\n        ExistsIffNotForall.1 (\n          ExistsIffNotForall.1 (\n            ExistsIffNotForall.1 (\n              ExistsIffNotForall.1 (\n                ExistsIffNotForall.1 (\n                  (IffIffNotIffNot.1 (E_def ＜u,z＞)).2 h4) u) z) set_u) set_z) hu);\n      exact False.elim (h5 (ClassEq.refl _));\n    }\n    case mp.inr h3 => {\n      have h4 := (@ImpIffNotImpNot (u ∈ Diff U X) (¬＜z,u＞ ＝ ＜z,u＞)).1 (\n        ExistsIffNotForall.1 (\n          ExistsIffNotForall.1 (\n            ExistsIffNotForall.1 (\n              ExistsIffNotForall.1 (\n                (IffIffNotIffNot.1 (prod_def ＜z,u＞)).2 h3) z) u) set_z.2)) (IffNotNot.symm.2 (ClassEq.refl _));\n      have h5 := NotAndIffNotOrNot.1 ((IffIffNotIffNot.1 (diff_def u)).2 h4);\n      cases h5;\n      case inl h5 => {exact False.elim (h5 set_u.2);}\n      case inr h5 => {exact IffNotNot.2 h5;}\n    }\n  }\n  {\n    intro h;\n    apply (px_def z).2;\n    apply And.intro;\n    {exact set_z.2;}\n    {\n      intro hn;\n      \n      -- have := (dom_def z).1 hn;\n      have ⟨z1,u,set_z1,set_u,hin1,heq1⟩ := (dom_def z).1 hn;\n      have h1 := (inter_def ＜z1,u＞).1 hin1;\n      have ⟨u2,z2,set_u2,set_z2,hin2,heq2⟩ := (rel_inv_def ＜z1,u＞).1 h1.1;\n      have ⟨u3,z3,hu3,hz3,hin3,heq3⟩ := (E_def ＜u2,z2＞).1 hin2;\n\n      have ⟨z4,u4,hz4,hu4,heq4⟩ := (prod_def ＜z1,u＞).1 h1.2;\n      have h3 := (diff_def u4).1 hu4;\n      rw [OrdPairEq] at heq2;\n      rw [OrdPairEq] at heq3;\n      have set_z4 := Set.mk₂ hz4;\n      have set_u4 := Set.mk₁ hu4;\n      rw [OrdPairEq] at heq4;\n      -- have heq5 := (AxiomExtensionality z z4).1 (ClassEq.trans (OrdPairEq.1 heq2).1 (OrdPairEq.1 heq'').2);\n      -- have heq''''' := ClassEq.trans (ClassEq.trans (ClassEq.symm (OrdPairEq.1 heq''').2) (OrdPairEq.1 heq').2) (OrdPairEq.1 heq'').1;\n      -- have := (AxiomExtensionality z z2) ;\n      have u_in_z : u ∈ X := by {\n        apply (h u);\n        apply ((AxiomExtensionality z z3).1 (ClassEq.trans (ClassEq.trans heq1 heq2.1) heq3.2) u).2;\n        apply ClassEqMenberImpMenber (ClassEq.trans heq2.2 heq3.1) hin3;\n      }\n      have u_not_in_z : ¬ u ∈ X := @RewiteClass (fun u => ¬ u ∈ X) u u4 ⟨heq4.2,h3.2⟩;\n      contradiction;\n    }\n  }\n}\n\nnoncomputable def PowerClass_mk (X : Class) : Class :=\n  choose (PowerClassExists X)\nnoncomputable instance : HasPow Class where\n  Pow := PowerClass_mk\nnoncomputable def PowerClass_def (X : Class):\n  ∀z: Class, ∀_: Set z,\n    z ∈ 𝒫 X ↔ (z ⊂ X) :=\n  choose_spec (PowerClassExists X)\ndef isPowerClass (PX : Class) :=\n  ∃(X: Class), ∀(Y: Class), ∀(_: Set Y), Y ∈ PX ↔ Y ⊂ X\nclass PowerClass (PX : Class) where\n  isPowerClass: isPowerClass PX\n\ntheorem PowerClass_def'_is_PowerClass {X: Class}:\n  isPowerClass (𝒫 X) := ⟨X, PowerClass_def X⟩\n\ntheorem UnivIsClosedPowerSet:\n  U ＝ 𝒫 U := by {\n  rw [AxiomExtensionality];\n  intro z;\n  apply Iff.intro;\n  {\n    intro h;\n    rw [PowerClass_def U z (Set.mk₁ h)];\n    exact AllSetSubsetU z;\n  }\n  {exact fun h => (Set.mk₁ h).2;}\n\n}\n\n", "meta": {"author": "furea2", "repo": "NBG", "sha": "51b45e0b08c1d0090430b0d898de4fc1b7bc09d7", "save_path": "github-repos/lean/furea2-NBG", "path": "github-repos/lean/furea2-NBG/NBG-51b45e0b08c1d0090430b0d898de4fc1b7bc09d7/NBG/SetTheory/Axioms/Membership.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6926419831347362, "lm_q1q2_score": 0.49109641890537986}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Joseph Myers.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.finset.sort\nimport Mathlib.data.matrix.notation\nimport Mathlib.linear_algebra.affine_space.combination\nimport Mathlib.linear_algebra.basis\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 l \n\nnamespace Mathlib\n\n/-!\n# Affine independence\n\nThis file defines affinely independent families of points.\n\n## Main definitions\n\n* `affine_independent` defines affinely independent families of points\n  as those where no nontrivial weighted subtraction is 0.  This is\n  proved equivalent to two other formulations: linear independence of\n  the results of subtracting a base point in the family from the other\n  points in the family, or any equal affine combinations having the\n  same weights.  A bundled type `simplex` is provided for finite\n  affinely independent families of points, with an abbreviation\n  `triangle` for the case of three points.\n\n## References\n\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\n/-- An indexed family is said to be affinely independent if no\nnontrivial weighted subtractions (where the sum of weights is 0) are\n0. -/\ndef affine_independent (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) :=\n  ∀ (s : finset ι) (w : ι → k),\n    (finset.sum s fun (i : ι) => w i) = 0 → coe_fn (finset.weighted_vsub s p) w = 0 → ∀ (i : ι), i ∈ s → w i = 0\n\n/-- The definition of `affine_independent`. -/\ntheorem affine_independent_def (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) : affine_independent k p ↔\n  ∀ (s : finset ι) (w : ι → k),\n    (finset.sum s fun (i : ι) => w i) = 0 → coe_fn (finset.weighted_vsub s p) w = 0 → ∀ (i : ι), i ∈ s → w i = 0 :=\n  iff.rfl\n\n/-- A family with at most one point is affinely independent. -/\ntheorem affine_independent_of_subsingleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [subsingleton ι] (p : ι → P) : affine_independent k p :=\n  fun (s : finset ι) (w : ι → k) (h : (finset.sum s fun (i : ι) => w i) = 0)\n    (hs : coe_fn (finset.weighted_vsub s p) w = 0) (i : ι) (hi : i ∈ s) => fintype.eq_of_subsingleton_of_sum_eq h i hi\n\n/-- A family indexed by a `fintype` is affinely independent if and\nonly if no nontrivial weighted subtractions over `finset.univ` (where\nthe sum of the weights is 0) are 0. -/\ntheorem affine_independent_iff_of_fintype (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [fintype ι] (p : ι → P) : affine_independent k p ↔\n  ∀ (w : ι → k),\n    (finset.sum finset.univ fun (i : ι) => w i) = 0 →\n      coe_fn (finset.weighted_vsub finset.univ p) w = 0 → ∀ (i : ι), w i = 0 := sorry\n\n/-- A family is affinely independent if and only if the differences\nfrom a base point in that family are linearly independent. -/\ntheorem affine_independent_iff_linear_independent_vsub (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) (i1 : ι) : affine_independent k p ↔ linear_independent k fun (i : Subtype fun (x : ι) => x ≠ i1) => p ↑i -ᵥ p i1 := sorry\n\n/-- A set is affinely independent if and only if the differences from\na base point in that set are linearly independent. -/\ntheorem affine_independent_set_iff_linear_independent_vsub (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P} {p₁ : P} (hp₁ : p₁ ∈ s) : (affine_independent k fun (p : ↥s) => ↑p) ↔\n  linear_independent k fun (v : ↥((fun (p : P) => p -ᵥ p₁) '' (s \\ singleton p₁))) => ↑v := sorry\n\n/-- A set of nonzero vectors is linearly independent if and only if,\ngiven a point `p₁`, the vectors added to `p₁` and `p₁` itself are\naffinely independent. -/\ntheorem linear_independent_set_iff_affine_independent_vadd_union_singleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {s : set V} (hs : ∀ (v : V), v ∈ s → v ≠ 0) (p₁ : P) : (linear_independent k fun (v : ↥s) => ↑v) ↔\n  affine_independent k fun (p : ↥(singleton p₁ ∪ (fun (v : V) => v +ᵥ p₁) '' s)) => ↑p := sorry\n\n/-- A family is affinely independent if and only if any affine\ncombinations (with sum of weights 1) that evaluate to the same point\nhave equal `set.indicator`. -/\ntheorem affine_independent_iff_indicator_eq_of_affine_combination_eq (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) : affine_independent k p ↔\n  ∀ (s1 s2 : finset ι) (w1 w2 : ι → k),\n    (finset.sum s1 fun (i : ι) => w1 i) = 1 →\n      (finset.sum s2 fun (i : ι) => w2 i) = 1 →\n        coe_fn (finset.affine_combination s1 p) w1 = coe_fn (finset.affine_combination s2 p) w2 →\n          set.indicator (↑s1) w1 = set.indicator (↑s2) w2 := sorry\n\n/-- An affinely independent family is injective, if the underlying\nring is nontrivial. -/\ntheorem injective_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {p : ι → P} (ha : affine_independent k p) : function.injective p := sorry\n\n/-- If a family is affinely independent, so is any subfamily given by\ncomposition of an embedding into index type with the original\nfamily. -/\ntheorem affine_independent_embedding_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {ι2 : Type u_5} (f : ι2 ↪ ι) {p : ι → P} (ha : affine_independent k p) : affine_independent k (p ∘ ⇑f) := sorry\n\n/-- If a family is affinely independent, so is any subfamily indexed\nby a subtype of the index type. -/\ntheorem affine_independent_subtype_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {p : ι → P} (ha : affine_independent k p) (s : set ι) : affine_independent k fun (i : ↥s) => p ↑i :=\n  affine_independent_embedding_of_affine_independent (function.embedding.subtype fun (x : ι) => x ∈ s) ha\n\n/-- If an indexed family of points is affinely independent, so is the\ncorresponding set of points. -/\ntheorem affine_independent_set_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {p : ι → P} (ha : affine_independent k p) : affine_independent k fun (x : ↥(set.range p)) => ↑x := sorry\n\n/-- If a set of points is affinely independent, so is any subset. -/\ntheorem affine_independent_of_subset_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P} {t : set P} (ha : affine_independent k fun (x : ↥t) => ↑x) (hs : s ⊆ t) : affine_independent k fun (x : ↥s) => ↑x :=\n  affine_independent_embedding_of_affine_independent (set.embedding_of_subset s t hs) ha\n\n/-- If the range of an injective indexed family of points is affinely\nindependent, so is that family. -/\ntheorem affine_independent_of_affine_independent_set_of_injective {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {p : ι → P} (ha : affine_independent k fun (x : ↥(set.range p)) => ↑x) (hi : function.injective p) : affine_independent k p := sorry\n\n/-- If a family is affinely independent, and the spans of points\nindexed by two subsets of the index type have a point in common, those\nsubsets of the index type have an element in common, if the underlying\nring is nontrivial. -/\ntheorem exists_mem_inter_of_exists_mem_inter_affine_span_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {p : ι → P} (ha : affine_independent k p) {s1 : set ι} {s2 : set ι} {p0 : P} (hp0s1 : p0 ∈ affine_span k (p '' s1)) (hp0s2 : p0 ∈ affine_span k (p '' s2)) : ∃ (i : ι), i ∈ s1 ∩ s2 := sorry\n\n/-- If a family is affinely independent, the spans of points indexed\nby disjoint subsets of the index type are disjoint, if the underlying\nring is nontrivial. -/\ntheorem affine_span_disjoint_of_disjoint_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {p : ι → P} (ha : affine_independent k p) {s1 : set ι} {s2 : set ι} (hd : s1 ∩ s2 = ∅) : ↑(affine_span k (p '' s1)) ∩ ↑(affine_span k (p '' s2)) = ∅ := sorry\n\n/-- If a family is affinely independent, a point in the family is in\nthe span of some of the points given by a subset of the index type if\nand only if that point's index is in the subset, if the underlying\nring is nontrivial. -/\n@[simp] theorem mem_affine_span_iff_mem_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {p : ι → P} (ha : affine_independent k p) (i : ι) (s : set ι) : p i ∈ affine_span k (p '' s) ↔ i ∈ s := sorry\n\n/-- If a family is affinely independent, a point in the family is not\nin the affine span of the other points, if the underlying ring is\nnontrivial. -/\ntheorem not_mem_affine_span_diff_of_affine_independent {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {p : ι → P} (ha : affine_independent k p) (i : ι) (s : set ι) : ¬p i ∈ affine_span k (p '' (s \\ singleton i)) := sorry\n\n/-- An affinely independent set of points can be extended to such a\nset that spans the whole space. -/\ntheorem exists_subset_affine_independent_affine_span_eq_top {k : Type u_1} {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {s : set P} (h : affine_independent k fun (p : ↥s) => ↑p) : ∃ (t : set P), s ⊆ t ∧ (affine_independent k fun (p : ↥t) => ↑p) ∧ affine_span k t = ⊤ := sorry\n\n/-- Two different points are affinely independent. -/\ntheorem affine_independent_of_ne (k : Type u_1) {V : Type u_2} {P : Type u_3} [field k] [add_comm_group V] [module k V] [add_torsor V P] {p₁ : P} {p₂ : P} (h : p₁ ≠ p₂) : affine_independent k (matrix.vec_cons p₁ (matrix.vec_cons p₂ matrix.vec_empty)) := sorry\n\nnamespace affine\n\n\n/-- A `simplex k P n` is a collection of `n + 1` affinely\nindependent points. -/\nstructure simplex (k : Type u_1) {V : Type u_2} (P : Type u_3) [ring k] [add_comm_group V] [module k V] [add_torsor V P] (n : ℕ) \nwhere\n  points : fin (n + 1) → P\n  independent : affine_independent k points\n\n/-- A `triangle k P` is a collection of three affinely independent points. -/\ndef triangle (k : Type u_1) {V : Type u_2} (P : Type u_3) [ring k] [add_comm_group V] [module k V] [add_torsor V P] :=\n  simplex k P (bit0 1)\n\nnamespace simplex\n\n\n/-- Construct a 0-simplex from a point. -/\ndef mk_of_point (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] (p : P) : simplex k P 0 :=\n  mk (fun (_x : fin (0 + 1)) => p) sorry\n\n/-- The point in a simplex constructed with `mk_of_point`. -/\n@[simp] theorem mk_of_point_points (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] (p : P) (i : fin 1) : points (mk_of_point k p) i = p :=\n  rfl\n\nprotected instance inhabited (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] [Inhabited P] : Inhabited (simplex k P 0) :=\n  { default := mk_of_point k Inhabited.default }\n\nprotected instance nonempty (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] : Nonempty (simplex k P 0) :=\n  Nonempty.intro (mk_of_point k (nonempty.some add_torsor.nonempty))\n\n/-- Two simplices are equal if they have the same points. -/\ntheorem ext {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} {s1 : simplex k P n} {s2 : simplex k P n} (h : ∀ (i : fin (n + 1)), points s1 i = points s2 i) : s1 = s2 := sorry\n\n/-- Two simplices are equal if and only if they have the same points. -/\ntheorem ext_iff {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s1 : simplex k P n) (s2 : simplex k P n) : s1 = s2 ↔ ∀ (i : fin (n + 1)), points s1 i = points s2 i :=\n  { mp := fun (h : s1 = s2) (_x : fin (n + 1)) => h ▸ rfl, mpr := ext }\n\n/-- A face of a simplex is a simplex with the given subset of\npoints. -/\ndef face {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ} (h : finset.card fs = m + 1) : simplex k P m :=\n  mk (points s ∘ ⇑(finset.order_emb_of_fin fs h)) sorry\n\n/-- The points of a face of a simplex are given by `mono_of_fin`. -/\ntheorem face_points {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ} (h : finset.card fs = m + 1) (i : fin (m + 1)) : points (face s h) i = points s (coe_fn (finset.order_emb_of_fin fs h) i) :=\n  rfl\n\n/-- The points of a face of a simplex are given by `mono_of_fin`. -/\ntheorem face_points' {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ} (h : finset.card fs = m + 1) : points (face s h) = points s ∘ ⇑(finset.order_emb_of_fin fs h) :=\n  rfl\n\n/-- A single-point face equals the 0-simplex constructed with\n`mk_of_point`. -/\n@[simp] theorem face_eq_mk_of_point {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) (i : fin (n + 1)) : face s (finset.card_singleton i) = mk_of_point k (points s i) := sorry\n\n/-- The set of points of a face. -/\n@[simp] theorem range_face_points {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ} (h : finset.card fs = m + 1) : set.range (points (face s h)) = points s '' ↑fs := sorry\n\nend simplex\n\n\nend affine\n\n\nnamespace affine\n\n\nnamespace simplex\n\n\n/-- The centroid of a face of a simplex as the centroid of a subset of\nthe points. -/\n@[simp] theorem face_centroid_eq_centroid {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : ℕ} (h : finset.card fs = m + 1) : finset.centroid k finset.univ (points (face s h)) = finset.centroid k fs (points s) := sorry\n\n/-- Over a characteristic-zero division ring, the centroids given by\ntwo subsets of the points of a simplex are equal if and only if those\nfaces are given by the same subset of points. -/\n@[simp] theorem centroid_eq_iff {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] [char_zero k] {n : ℕ} (s : simplex k P n) {fs₁ : finset (fin (n + 1))} {fs₂ : finset (fin (n + 1))} {m₁ : ℕ} {m₂ : ℕ} (h₁ : finset.card fs₁ = m₁ + 1) (h₂ : finset.card fs₂ = m₂ + 1) : finset.centroid k fs₁ (points s) = finset.centroid k fs₂ (points s) ↔ fs₁ = fs₂ := sorry\n\n/-- Over a characteristic-zero division ring, the centroids of two\nfaces of a simplex are equal if and only if those faces are given by\nthe same subset of points. -/\ntheorem face_centroid_eq_iff {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] [char_zero k] {n : ℕ} (s : simplex k P n) {fs₁ : finset (fin (n + 1))} {fs₂ : finset (fin (n + 1))} {m₁ : ℕ} {m₂ : ℕ} (h₁ : finset.card fs₁ = m₁ + 1) (h₂ : finset.card fs₂ = m₂ + 1) : finset.centroid k finset.univ (points (face s h₁)) = finset.centroid k finset.univ (points (face s h₂)) ↔ fs₁ = fs₂ := sorry\n\n/-- Two simplices with the same points have the same centroid. -/\ntheorem centroid_eq_of_range_eq {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {n : ℕ} {s₁ : simplex k P n} {s₂ : simplex k P n} (h : set.range (points s₁) = set.range (points s₂)) : finset.centroid k finset.univ (points s₁) = finset.centroid k finset.univ (points s₂) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/affine_space/independent.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.491096414646638}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Mario Carneiro\n-/\nimport logic.equiv.defs\nimport data.option.basic\nimport data.prod.basic\nimport data.sigma.basic\nimport data.subtype\nimport data.sum.basic\nimport logic.function.conjugate\n\n/-!\n# Equivalence between types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we continue the work on equivalences begun in `logic/equiv/defs.lean`, defining\n\n* canonical isomorphisms between various types: e.g.,\n\n  - `equiv.sum_equiv_sigma_bool` is the canonical equivalence between the sum of two types `α ⊕ β`\n    and the sigma-type `Σ b : bool, cond b α β`;\n\n  - `equiv.prod_sum_distrib : α × (β ⊕ γ) ≃ (α × β) ⊕ (α × γ)` shows that type product and type sum\n    satisfy the distributive law up to a canonical equivalence;\n\n* operations on equivalences: e.g.,\n\n  - `equiv.prod_congr ea eb : α₁ × β₁ ≃ α₂ × β₂`: combine two equivalences `ea : α₁ ≃ α₂` and\n    `eb : β₁ ≃ β₂` using `prod.map`.\n\n  More definitions of this kind can be found in other files. E.g., `data/equiv/transfer_instance`\n  does it for many algebraic type classes like `group`, `module`, etc.\n\n## Tags\n\nequivalence, congruence, bijective map\n-/\n\nopen function\n\nuniverses u v w z\nvariables {α : Sort u} {β : Sort v} {γ : Sort w}\n\nnamespace equiv\n\n/-- `pprod α β` is equivalent to `α × β` -/\n@[simps apply symm_apply]\ndef pprod_equiv_prod {α β : Type*} : pprod α β ≃ α × β :=\n{ to_fun := λ x, (x.1, x.2),\n  inv_fun := λ x, ⟨x.1, x.2⟩,\n  left_inv := λ ⟨x, y⟩, rfl,\n  right_inv := λ ⟨x, y⟩, rfl }\n\n/-- Product of two equivalences, in terms of `pprod`. If `α ≃ β` and `γ ≃ δ`, then\n`pprod α γ ≃ pprod β δ`. -/\n@[congr, simps apply]\ndef pprod_congr {δ : Sort z} (e₁ : α ≃ β) (e₂ : γ ≃ δ) : pprod α γ ≃ pprod β δ :=\n{ to_fun := λ x, ⟨e₁ x.1, e₂ x.2⟩,\n  inv_fun := λ x, ⟨e₁.symm x.1, e₂.symm x.2⟩,\n  left_inv := λ ⟨x, y⟩, by simp,\n  right_inv := λ ⟨x, y⟩, by simp }\n\n/-- Combine two equivalences using `pprod` in the domain and `prod` in the codomain. -/\n@[simps apply symm_apply]\ndef pprod_prod {α₁ β₁ : Sort*} {α₂ β₂ : Type*} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) :\n  pprod α₁ β₁ ≃ α₂ × β₂ :=\n(ea.pprod_congr eb).trans pprod_equiv_prod\n\n/-- Combine two equivalences using `pprod` in the codomain and `prod` in the domain. -/\n@[simps apply symm_apply]\ndef prod_pprod {α₁ β₁ : Type*} {α₂ β₂ : Sort*} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) :\n  α₁ × β₁ ≃ pprod α₂ β₂ :=\n(ea.symm.pprod_prod eb.symm).symm\n\n/-- `pprod α β` is equivalent to `plift α × plift β` -/\n@[simps apply symm_apply]\ndef pprod_equiv_prod_plift {α β : Sort*} : pprod α β ≃ plift α × plift β :=\nequiv.plift.symm.pprod_prod equiv.plift.symm\n\n/-- Product of two equivalences. If `α₁ ≃ α₂` and `β₁ ≃ β₂`, then `α₁ × β₁ ≃ α₂ × β₂`. This is\n`prod.map` as an equivalence. -/\n@[congr, simps apply { fully_applied := ff }]\ndef prod_congr {α₁ β₁ α₂ β₂ : Type*} (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) : α₁ × β₁ ≃ α₂ × β₂ :=\n⟨prod.map e₁ e₂, prod.map e₁.symm e₂.symm, λ ⟨a, b⟩, by simp, λ ⟨a, b⟩, by simp⟩\n\n@[simp] theorem prod_congr_symm {α₁ β₁ α₂ β₂ : Type*} (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) :\n  (prod_congr e₁ e₂).symm = prod_congr e₁.symm e₂.symm :=\nrfl\n\n/-- Type product is commutative up to an equivalence: `α × β ≃ β × α`. This is `prod.swap` as an\nequivalence.-/\ndef prod_comm (α β : Type*) : α × β ≃ β × α :=\n⟨prod.swap, prod.swap, prod.swap_swap, prod.swap_swap⟩\n\n@[simp] lemma coe_prod_comm (α β : Type*) : ⇑(prod_comm α β) = prod.swap := rfl\n@[simp] lemma prod_comm_apply {α β : Type*} (x : α × β) : prod_comm α β x = x.swap := rfl\n\n@[simp] lemma prod_comm_symm (α β) : (prod_comm α β).symm = prod_comm β α := rfl\n\n/-- Type product is associative up to an equivalence. -/\n@[simps] def prod_assoc (α β γ : Sort*) : (α × β) × γ ≃ α × (β × γ) :=\n⟨λ p, (p.1.1, p.1.2, p.2), λ p, ((p.1, p.2.1), p.2.2), λ ⟨⟨a, b⟩, c⟩, rfl, λ ⟨a, ⟨b, c⟩⟩, rfl⟩\n\n/-- Functions on `α × β` are equivalent to functions `α → β → γ`. -/\n@[simps {fully_applied := ff}] def curry (α β γ : Type*) :\n  (α × β → γ) ≃ (α → β → γ) :=\n{ to_fun := curry,\n  inv_fun := uncurry,\n  left_inv := uncurry_curry,\n  right_inv := curry_uncurry }\n\nsection\n/-- `punit` is a right identity for type product up to an equivalence. -/\n@[simps] def prod_punit (α : Type*) : α × punit.{u+1} ≃ α :=\n⟨λ p, p.1, λ a, (a, punit.star), λ ⟨_, punit.star⟩, rfl, λ a, rfl⟩\n\n/-- `punit` is a left identity for type product up to an equivalence. -/\n@[simps] def punit_prod (α : Type*) : punit.{u+1} × α ≃ α :=\ncalc punit × α ≃ α × punit : prod_comm _ _\n           ... ≃ α         : prod_punit _\n\n/-- Any `unique` type is a right identity for type product up to equivalence. -/\ndef prod_unique (α β : Type*) [unique β] : α × β ≃ α :=\n((equiv.refl α).prod_congr $ equiv_punit β).trans $ prod_punit α\n\n@[simp] lemma coe_prod_unique {α β : Type*} [unique β] :\n  ⇑(prod_unique α β) = prod.fst := rfl\n\nlemma prod_unique_apply {α β : Type*} [unique β] (x : α × β) :\n  prod_unique α β x = x.1 := rfl\n\n@[simp] lemma prod_unique_symm_apply {α β : Type*} [unique β] (x : α) :\n  (prod_unique α β).symm x = (x, default) := rfl\n\n/-- Any `unique` type is a left identity for type product up to equivalence. -/\ndef unique_prod (α β : Type*) [unique β] : β × α ≃ α :=\n((equiv_punit β).prod_congr $ equiv.refl α).trans $ punit_prod α\n\n@[simp] lemma coe_unique_prod {α β : Type*} [unique β] :\n  ⇑(unique_prod α β) = prod.snd := rfl\n\nlemma unique_prod_apply {α β : Type*} [unique β] (x : β × α) :\n  unique_prod α β x = x.2 := rfl\n\n@[simp] lemma unique_prod_symm_apply {α β : Type*} [unique β] (x : α) :\n  (unique_prod α β).symm x = (default, x) := rfl\n\n/-- `empty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_empty (α : Type*) : α × empty ≃ empty :=\nequiv_empty _\n\n/-- `empty` type is a left absorbing element for type product up to an equivalence. -/\ndef empty_prod (α : Type*) : empty × α ≃ empty :=\nequiv_empty _\n\n/-- `pempty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_pempty (α : Type*) : α × pempty ≃ pempty :=\nequiv_pempty _\n\n/-- `pempty` type is a left absorbing element for type product up to an equivalence. -/\ndef pempty_prod (α : Type*) : pempty × α ≃ pempty :=\nequiv_pempty _\nend\n\nsection\nopen sum\n\n/-- `psum` is equivalent to `sum`. -/\ndef psum_equiv_sum (α β : Type*) : psum α β ≃ α ⊕ β :=\n{ to_fun := λ s, psum.cases_on s inl inr,\n  inv_fun := sum.elim psum.inl psum.inr,\n  left_inv := λ s, by cases s; refl,\n  right_inv := λ s, by cases s; refl }\n\n/-- If `α ≃ α'` and `β ≃ β'`, then `α ⊕ β ≃ α' ⊕ β'`. This is `sum.map` as an equivalence. -/\n@[simps apply]\ndef sum_congr {α₁ β₁ α₂ β₂ : Type*} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) : α₁ ⊕ β₁ ≃ α₂ ⊕ β₂ :=\n⟨sum.map ea eb, sum.map ea.symm eb.symm, λ x, by simp, λ x, by simp⟩\n\n/-- If `α ≃ α'` and `β ≃ β'`, then `psum α β ≃ psum α' β'`. -/\ndef psum_congr {δ : Sort z} (e₁ : α ≃ β) (e₂ : γ ≃ δ) : psum α γ ≃ psum β δ :=\n{ to_fun := λ x, psum.cases_on x (psum.inl ∘ e₁) (psum.inr ∘ e₂),\n  inv_fun := λ x, psum.cases_on x (psum.inl ∘ e₁.symm) (psum.inr ∘ e₂.symm),\n  left_inv := by rintro (x|x); simp,\n  right_inv := by rintro (x|x); simp }\n\n/-- Combine two `equiv`s using `psum` in the domain and `sum` in the codomain. -/\ndef psum_sum {α₁ β₁ : Sort*} {α₂ β₂ : Type*} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) : psum α₁ β₁ ≃ α₂ ⊕ β₂ :=\n(ea.psum_congr eb).trans (psum_equiv_sum _ _)\n\n/-- Combine two `equiv`s using `sum` in the domain and `psum` in the codomain. -/\ndef sum_psum {α₁ β₁ : Type*} {α₂ β₂ : Sort*} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) : α₁ ⊕ β₁ ≃ psum α₂ β₂ :=\n(ea.symm.psum_sum eb.symm).symm\n\n@[simp] lemma sum_congr_trans {α₁ α₂ β₁ β₂ γ₁ γ₂ : Sort*}\n  (e : α₁ ≃ β₁) (f : α₂ ≃ β₂) (g : β₁ ≃ γ₁) (h : β₂ ≃ γ₂) :\n  (equiv.sum_congr e f).trans (equiv.sum_congr g h) = (equiv.sum_congr (e.trans g) (f.trans h)) :=\nby { ext i, cases i; refl }\n\n@[simp] lemma sum_congr_symm {α β γ δ : Sort*} (e : α ≃ β) (f : γ ≃ δ) :\n  (equiv.sum_congr e f).symm = (equiv.sum_congr (e.symm) (f.symm)) :=\nrfl\n\n@[simp] lemma sum_congr_refl {α β : Sort*} :\n  equiv.sum_congr (equiv.refl α) (equiv.refl β) = equiv.refl (α ⊕ β) :=\nby { ext i, cases i; refl }\n\nnamespace perm\n\n/-- Combine a permutation of `α` and of `β` into a permutation of `α ⊕ β`. -/\n@[reducible]\ndef sum_congr {α β : Type*} (ea : equiv.perm α) (eb : equiv.perm β) : equiv.perm (α ⊕ β) :=\nequiv.sum_congr ea eb\n\n@[simp] lemma sum_congr_apply {α β : Type*} (ea : equiv.perm α) (eb : equiv.perm β) (x : α ⊕ β) :\n  sum_congr ea eb x = sum.map ⇑ea ⇑eb x := equiv.sum_congr_apply ea eb x\n\n@[simp] lemma sum_congr_trans {α β : Sort*}\n  (e : equiv.perm α) (f : equiv.perm β) (g : equiv.perm α) (h : equiv.perm β) :\n  (sum_congr e f).trans (sum_congr g h) = sum_congr (e.trans g) (f.trans h) :=\nequiv.sum_congr_trans e f g h\n\n@[simp] lemma sum_congr_symm {α β : Sort*} (e : equiv.perm α) (f : equiv.perm β) :\n  (sum_congr e f).symm = sum_congr (e.symm) (f.symm) :=\nequiv.sum_congr_symm e f\n\n@[simp] lemma sum_congr_refl {α β : Sort*} :\n  sum_congr (equiv.refl α) (equiv.refl β) = equiv.refl (α ⊕ β) :=\nequiv.sum_congr_refl\n\nend perm\n\n/-- `bool` is equivalent the sum of two `punit`s. -/\ndef bool_equiv_punit_sum_punit : bool ≃ punit.{u+1} ⊕ punit.{v+1} :=\n⟨λ b, cond b (inr punit.star) (inl punit.star),\n sum.elim (λ _, ff) (λ _, tt),\n λ b, by cases b; refl,\n λ s, by rcases s with ⟨⟨⟩⟩ | ⟨⟨⟩⟩; refl⟩\n\n/-- Sum of types is commutative up to an equivalence. This is `sum.swap` as an equivalence. -/\n@[simps apply {fully_applied := ff}]\ndef sum_comm (α β : Type*) : α ⊕ β ≃ β ⊕ α :=\n⟨sum.swap, sum.swap, sum.swap_swap, sum.swap_swap⟩\n\n@[simp] lemma sum_comm_symm (α β) : (sum_comm α β).symm = sum_comm β α := rfl\n\n/-- Sum of types is associative up to an equivalence. -/\ndef sum_assoc (α β γ : Type*) : (α ⊕ β) ⊕ γ ≃ α ⊕ (β ⊕ γ) :=\n⟨sum.elim (sum.elim sum.inl (sum.inr ∘ sum.inl)) (sum.inr ∘ sum.inr),\n  sum.elim (sum.inl ∘ sum.inl) $ sum.elim (sum.inl ∘ sum.inr) sum.inr,\n  by rintros (⟨_ | _⟩ | _); refl,\n  by rintros (_ | ⟨_ | _⟩); refl⟩\n\n@[simp] lemma sum_assoc_apply_inl_inl {α β γ} (a) : sum_assoc α β γ (inl (inl a)) = inl a := rfl\n\n@[simp] lemma sum_assoc_apply_inl_inr {α β γ} (b) : sum_assoc α β γ (inl (inr b)) = inr (inl b) :=\nrfl\n\n@[simp] lemma sum_assoc_apply_inr {α β γ} (c) : sum_assoc α β γ (inr c) = inr (inr c) := rfl\n\n@[simp] lemma sum_assoc_symm_apply_inl {α β γ} (a) : (sum_assoc α β γ).symm (inl a) = inl (inl a) :=\nrfl\n\n@[simp] lemma sum_assoc_symm_apply_inr_inl {α β γ} (b) :\n  (sum_assoc α β γ).symm (inr (inl b)) = inl (inr b) := rfl\n\n@[simp] lemma sum_assoc_symm_apply_inr_inr {α β γ} (c) :\n  (sum_assoc α β γ).symm (inr (inr c)) = inr c := rfl\n\n\n/-- Sum with `empty` is equivalent to the original type. -/\n@[simps symm_apply] def sum_empty (α β : Type*) [is_empty β] : α ⊕ β ≃ α :=\n⟨sum.elim id is_empty_elim,\n inl,\n λ s, by { rcases s with _ | x, refl, exact is_empty_elim x },\n λ a, rfl⟩\n\n@[simp] lemma sum_empty_apply_inl {α β : Type*} [is_empty β] (a : α) :\n  sum_empty α β (sum.inl a) = a := rfl\n\n/-- The sum of `empty` with any `Sort*` is equivalent to the right summand. -/\n@[simps symm_apply] def empty_sum (α β : Type*) [is_empty α] : α ⊕ β ≃ β :=\n(sum_comm _ _).trans $ sum_empty _ _\n\n@[simp] lemma empty_sum_apply_inr {α β : Type*} [is_empty α] (b : β) :\n  empty_sum α β (sum.inr b) = b := rfl\n\n/-- `option α` is equivalent to `α ⊕ punit` -/\ndef option_equiv_sum_punit (α : Type*) : option α ≃ α ⊕ punit.{u+1} :=\n⟨λ o, o.elim (inr punit.star) inl,\n λ s, s.elim some (λ _, none),\n λ o, by cases o; refl,\n λ s, by rcases s with _ | ⟨⟨⟩⟩; refl⟩\n\n@[simp] lemma option_equiv_sum_punit_none {α} :\n  option_equiv_sum_punit α none = sum.inr punit.star := rfl\n@[simp] lemma option_equiv_sum_punit_some {α} (a) :\n  option_equiv_sum_punit α (some a) = sum.inl a := rfl\n\n@[simp] lemma option_equiv_sum_punit_coe {α} (a : α) :\n  option_equiv_sum_punit α a = sum.inl a := rfl\n\n@[simp] lemma option_equiv_sum_punit_symm_inl {α} (a) :\n  (option_equiv_sum_punit α).symm (sum.inl a) = a :=\nrfl\n\n@[simp] lemma option_equiv_sum_punit_symm_inr {α} (a) :\n  (option_equiv_sum_punit α).symm (sum.inr a) = none :=\nrfl\n\n/-- The set of `x : option α` such that `is_some x` is equivalent to `α`. -/\n@[simps] def option_is_some_equiv (α : Type*) : {x : option α // x.is_some} ≃ α :=\n{ to_fun := λ o, option.get o.2,\n  inv_fun := λ x, ⟨some x, dec_trivial⟩,\n  left_inv := λ o, subtype.eq $ option.some_get _,\n  right_inv := λ x, option.get_some _ _ }\n\n/-- The product over `option α` of `β a` is the binary product of the\nproduct over `α` of `β (some α)` and `β none` -/\n@[simps] def pi_option_equiv_prod {α : Type*} {β : option α → Type*} :\n  (Π a : option α, β a) ≃ (β none × Π a : α, β (some a)) :=\n{ to_fun := λ f, (f none, λ a, f (some a)),\n  inv_fun := λ x a, option.cases_on a x.fst x.snd,\n  left_inv := λ f, funext $ λ a, by cases a; refl,\n  right_inv := λ x, by simp }\n\n/-- `α ⊕ β` is equivalent to a `sigma`-type over `bool`. Note that this definition assumes `α` and\n`β` to be types from the same universe, so it cannot by used directly to transfer theorems about\nsigma types to theorems about sum types. In many cases one can use `ulift` to work around this\ndifficulty. -/\ndef sum_equiv_sigma_bool (α β : Type u) : α ⊕ β ≃ (Σ b: bool, cond b α β) :=\n⟨λ s, s.elim (λ x, ⟨tt, x⟩) (λ x, ⟨ff, x⟩),\n λ s, match s with ⟨tt, a⟩ := inl a | ⟨ff, b⟩ := inr b end,\n λ s, by cases s; refl,\n λ s, by rcases s with ⟨_|_, _⟩; refl⟩\n\n/-- `sigma_fiber_equiv f` for `f : α → β` is the natural equivalence between\nthe type of all fibres of `f` and the total space `α`. -/\n-- See also `equiv.sigma_preimage_equiv`.\n@[simps]\ndef sigma_fiber_equiv {α β : Type*} (f : α → β) :\n  (Σ y : β, {x // f x = y}) ≃ α :=\n⟨λ x, ↑x.2, λ x, ⟨f x, x, rfl⟩, λ ⟨y, x, rfl⟩, rfl, λ x, rfl⟩\n\nend\n\nsection sum_compl\n\n/-- For any predicate `p` on `α`,\nthe sum of the two subtypes `{a // p a}` and its complement `{a // ¬ p a}`\nis naturally equivalent to `α`.\n\nSee `subtype_or_equiv` for sum types over subtypes `{x // p x}` and `{x // q x}`\nthat are not necessarily `is_compl p q`.  -/\ndef sum_compl {α : Type*} (p : α → Prop) [decidable_pred p] :\n  {a // p a} ⊕ {a // ¬ p a} ≃ α :=\n{ to_fun := sum.elim coe coe,\n  inv_fun := λ a, if h : p a then sum.inl ⟨a, h⟩ else sum.inr ⟨a, h⟩,\n  left_inv := by { rintros (⟨x,hx⟩|⟨x,hx⟩); dsimp; [rw dif_pos, rw dif_neg], },\n  right_inv := λ a, by { dsimp, split_ifs; refl } }\n\n@[simp] lemma sum_compl_apply_inl {α : Type*} (p : α → Prop) [decidable_pred p]\n  (x : {a // p a}) :\n  sum_compl p (sum.inl x) = x := rfl\n\n@[simp] lemma sum_compl_apply_inr {α : Type*} (p : α → Prop) [decidable_pred p]\n  (x : {a // ¬ p a}) :\n  sum_compl p (sum.inr x) = x := rfl\n\n@[simp] lemma sum_compl_apply_symm_of_pos {α : Type*} (p : α → Prop) [decidable_pred p]\n  (a : α) (h : p a) :\n  (sum_compl p).symm a = sum.inl ⟨a, h⟩ := dif_pos h\n\n@[simp] lemma sum_compl_apply_symm_of_neg {α : Type*} (p : α → Prop) [decidable_pred p]\n  (a : α) (h : ¬ p a) :\n  (sum_compl p).symm a = sum.inr ⟨a, h⟩ := dif_neg h\n\n/-- Combines an `equiv` between two subtypes with an `equiv` between their complements to form a\n  permutation. -/\ndef subtype_congr {α : Type*} {p q : α → Prop} [decidable_pred p] [decidable_pred q]\n  (e : {x // p x} ≃ {x // q x}) (f : {x // ¬p x} ≃ {x // ¬q x}) : perm α :=\n(sum_compl p).symm.trans ((sum_congr e f).trans\n  (sum_compl q))\n\nopen equiv\n\nvariables {ε : Type*} {p : ε → Prop} [decidable_pred p]\nvariables (ep ep' : perm {a // p a}) (en en' : perm {a // ¬ p a})\n\n/-- Combining permutations on `ε` that permute only inside or outside the subtype\nsplit induced by `p : ε → Prop` constructs a permutation on `ε`. -/\ndef perm.subtype_congr : equiv.perm ε :=\nperm_congr (sum_compl p) (sum_congr ep en)\n\nlemma perm.subtype_congr.apply (a : ε) :\n  ep.subtype_congr en a = if h : p a then ep ⟨a, h⟩ else en ⟨a, h⟩ :=\nby { by_cases h : p a; simp [perm.subtype_congr, h] }\n\n@[simp] lemma perm.subtype_congr.left_apply {a : ε} (h : p a) :\n  ep.subtype_congr en a = ep ⟨a, h⟩ :=\nby simp [perm.subtype_congr.apply, h]\n\n@[simp] lemma perm.subtype_congr.left_apply_subtype (a : {a // p a}) :\n  ep.subtype_congr en a = ep a :=\nby { convert perm.subtype_congr.left_apply _ _ a.property, simp }\n\n@[simp] lemma perm.subtype_congr.right_apply {a : ε} (h : ¬ p a) :\n  ep.subtype_congr en a = en ⟨a, h⟩ :=\nby simp [perm.subtype_congr.apply, h]\n\n@[simp] lemma perm.subtype_congr.right_apply_subtype (a : {a // ¬ p a}) :\n  ep.subtype_congr en a = en a :=\nby { convert perm.subtype_congr.right_apply _ _ a.property, simp }\n\n@[simp] \n\n@[simp] lemma perm.subtype_congr.symm :\n  (ep.subtype_congr en).symm = perm.subtype_congr ep.symm en.symm :=\nbegin\n  ext x,\n  by_cases h : p x,\n  { have : p (ep.symm ⟨x, h⟩) := subtype.property _,\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this] },\n  { have : ¬ p (en.symm ⟨x, h⟩) := subtype.property (en.symm _),\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this] }\nend\n\n@[simp] lemma perm.subtype_congr.trans :\n  (ep.subtype_congr en).trans (ep'.subtype_congr en') =\n    perm.subtype_congr (ep.trans ep') (en.trans en') :=\nbegin\n  ext x,\n  by_cases h : p x,\n  { have : p (ep ⟨x, h⟩) := subtype.property _,\n    simp [perm.subtype_congr.apply, h, this] },\n  { have : ¬ p (en ⟨x, h⟩) := subtype.property (en _),\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this] }\nend\n\nend sum_compl\n\nsection subtype_preimage\n\nvariables (p : α → Prop) [decidable_pred p] (x₀ : {a // p a} → β)\n\n/-- For a fixed function `x₀ : {a // p a} → β` defined on a subtype of `α`,\nthe subtype of functions `x : α → β` that agree with `x₀` on the subtype `{a // p a}`\nis naturally equivalent to the type of functions `{a // ¬ p a} → β`. -/\n@[simps]\ndef subtype_preimage :\n  {x : α → β // x ∘ coe = x₀} ≃ ({a // ¬ p a} → β) :=\n{ to_fun := λ (x : {x : α → β // x ∘ coe = x₀}) a, (x : α → β) a,\n  inv_fun := λ x, ⟨λ a, if h : p a then x₀ ⟨a, h⟩ else x ⟨a, h⟩,\n    funext $ λ ⟨a, h⟩, dif_pos h⟩,\n  left_inv := λ ⟨x, hx⟩, subtype.val_injective $ funext $ λ a,\n    (by { dsimp, split_ifs; [ rw ← hx, skip ]; refl }),\n  right_inv := λ x, funext $ λ ⟨a, h⟩,\n    show dite (p a) _ _ = _, by { dsimp, rw [dif_neg h] } }\n\nlemma subtype_preimage_symm_apply_coe_pos (x : {a // ¬ p a} → β) (a : α) (h : p a) :\n  ((subtype_preimage p x₀).symm x : α → β) a = x₀ ⟨a, h⟩ :=\ndif_pos h\n\nlemma subtype_preimage_symm_apply_coe_neg (x : {a // ¬ p a} → β) (a : α) (h : ¬ p a) :\n  ((subtype_preimage p x₀).symm x : α → β) a = x ⟨a, h⟩ :=\ndif_neg h\n\nend subtype_preimage\n\nsection\n\n/-- A family of equivalences `Π a, β₁ a ≃ β₂ a` generates an equivalence between `Π a, β₁ a` and\n`Π a, β₂ a`. -/\ndef Pi_congr_right {α} {β₁ β₂ : α → Sort*} (F : Π a, β₁ a ≃ β₂ a) : (Π a, β₁ a) ≃ (Π a, β₂ a) :=\n⟨λ H a, F a (H a), λ H a, (F a).symm (H a),\n λ H, funext $ by simp, λ H, funext $ by simp⟩\n\n/-- Given `φ : α → β → Sort*`, we have an equivalence between `Π a b, φ a b` and `Π b a, φ a b`.\nThis is `function.swap` as an `equiv`. -/\n@[simps apply]\ndef Pi_comm {α β} (φ : α → β → Sort*) : (Π a b, φ a b) ≃ (Π b a, φ a b) :=\n⟨swap, swap, λ x, rfl, λ y, rfl⟩\n\n@[simp] lemma Pi_comm_symm {α β} {φ : α → β → Sort*} :\n  (Pi_comm φ).symm = (Pi_comm $ swap φ) :=\nrfl\n\n/-- Dependent `curry` equivalence: the type of dependent functions on `Σ i, β i` is equivalent\nto the type of dependent functions of two arguments (i.e., functions to the space of functions).\n\nThis is `sigma.curry` and `sigma.uncurry` together as an equiv. -/\ndef Pi_curry {α} {β : α → Sort*} (γ : Π a, β a → Sort*) :\n  (Π x : Σ i, β i, γ x.1 x.2) ≃ (Π a b, γ a b) :=\n{ to_fun := sigma.curry,\n  inv_fun := sigma.uncurry,\n  left_inv := sigma.uncurry_curry,\n  right_inv := sigma.curry_uncurry }\n\nend\n\nsection prod_congr\n\nvariables {α₁ β₁ β₂ : Type*} (e : α₁ → β₁ ≃ β₂)\n\n/-- A family of equivalences `Π (a : α₁), β₁ ≃ β₂` generates an equivalence\nbetween `β₁ × α₁` and `β₂ × α₁`. -/\ndef prod_congr_left : β₁ × α₁ ≃ β₂ × α₁ :=\n{ to_fun := λ ab, ⟨e ab.2 ab.1, ab.2⟩,\n  inv_fun := λ ab, ⟨(e ab.2).symm ab.1, ab.2⟩,\n  left_inv := by { rintros ⟨a, b⟩, simp },\n  right_inv := by { rintros ⟨a, b⟩, simp } }\n\n@[simp] lemma prod_congr_left_apply (b : β₁) (a : α₁) :\nprod_congr_left e (b, a) = (e a b, a) := rfl\n\nlemma prod_congr_refl_right (e : β₁ ≃ β₂) :\n  prod_congr e (equiv.refl α₁) = prod_congr_left (λ _, e) :=\nby { ext ⟨a, b⟩ : 1, simp }\n\n/-- A family of equivalences `Π (a : α₁), β₁ ≃ β₂` generates an equivalence\nbetween `α₁ × β₁` and `α₁ × β₂`. -/\ndef prod_congr_right : α₁ × β₁ ≃ α₁ × β₂ :=\n{ to_fun := λ ab, ⟨ab.1, e ab.1 ab.2⟩,\n  inv_fun := λ ab, ⟨ab.1, (e ab.1).symm ab.2⟩,\n  left_inv := by { rintros ⟨a, b⟩, simp },\n  right_inv := by { rintros ⟨a, b⟩, simp } }\n\n@[simp] lemma prod_congr_right_apply (a : α₁) (b : β₁) :\n  prod_congr_right e (a, b) = (a, e a b) := rfl\n\nlemma prod_congr_refl_left (e : β₁ ≃ β₂) :\n  prod_congr (equiv.refl α₁) e = prod_congr_right (λ _, e) :=\nby { ext ⟨a, b⟩ : 1, simp }\n\n@[simp] lemma prod_congr_left_trans_prod_comm :\n  (prod_congr_left e).trans (prod_comm _ _) = (prod_comm _ _).trans (prod_congr_right e) :=\nby { ext ⟨a, b⟩ : 1, simp }\n\n@[simp] lemma prod_congr_right_trans_prod_comm :\n  (prod_congr_right e).trans (prod_comm _ _) = (prod_comm _ _).trans (prod_congr_left e) :=\nby { ext ⟨a, b⟩ : 1, simp }\n\nlemma sigma_congr_right_sigma_equiv_prod :\n  (sigma_congr_right e).trans (sigma_equiv_prod α₁ β₂) =\n    (sigma_equiv_prod α₁ β₁).trans (prod_congr_right e) :=\nby { ext ⟨a, b⟩ : 1, simp }\n\nlemma sigma_equiv_prod_sigma_congr_right :\n  (sigma_equiv_prod α₁ β₁).symm.trans (sigma_congr_right e) =\n    (prod_congr_right e).trans (sigma_equiv_prod α₁ β₂).symm :=\nby { ext ⟨a, b⟩ : 1, simp }\n\n/-- A family of equivalences between fibers gives an equivalence between domains. -/\n-- See also `equiv.of_preimage_equiv`.\n@[simps]\ndef of_fiber_equiv {α β γ : Type*} {f : α → γ} {g : β → γ}\n  (e : Π c, {a // f a = c} ≃ {b // g b = c}) :\n  α ≃ β :=\n(sigma_fiber_equiv f).symm.trans $ (equiv.sigma_congr_right e).trans (sigma_fiber_equiv g)\n\nlemma of_fiber_equiv_map {α β γ} {f : α → γ} {g : β → γ}\n  (e : Π c, {a // f a = c} ≃ {b // g b = c}) (a : α) : g (of_fiber_equiv e a) = f a :=\n(_ : {b // g b = _}).prop\n\n/-- A variation on `equiv.prod_congr` where the equivalence in the second component can depend\n  on the first component. A typical example is a shear mapping, explaining the name of this\n  declaration. -/\n@[simps {fully_applied := ff}]\ndef prod_shear {α₁ β₁ α₂ β₂ : Type*} (e₁ : α₁ ≃ α₂) (e₂ : α₁ → β₁ ≃ β₂) : α₁ × β₁ ≃ α₂ × β₂ :=\n{ to_fun := λ x : α₁ × β₁, (e₁ x.1, e₂ x.1 x.2),\n  inv_fun := λ y : α₂ × β₂, (e₁.symm y.1, (e₂ $ e₁.symm y.1).symm y.2),\n  left_inv := by { rintro ⟨x₁, y₁⟩, simp only [symm_apply_apply] },\n  right_inv := by { rintro ⟨x₁, y₁⟩, simp only [apply_symm_apply] } }\n\nend prod_congr\n\nnamespace perm\n\nvariables {α₁ β₁ β₂ : Type*} [decidable_eq α₁] (a : α₁) (e : perm β₁)\n\n/-- `prod_extend_right a e` extends `e : perm β` to `perm (α × β)` by sending `(a, b)` to\n`(a, e b)` and keeping the other `(a', b)` fixed. -/\ndef prod_extend_right : perm (α₁ × β₁) :=\n{ to_fun := λ ab, if ab.fst = a then (a, e ab.snd) else ab,\n  inv_fun := λ ab, if ab.fst = a then (a, e.symm ab.snd) else ab,\n  left_inv := by { rintros ⟨k', x⟩, dsimp only, split_ifs with h; simp [h] },\n  right_inv := by { rintros ⟨k', x⟩, dsimp only, split_ifs with h; simp [h] } }\n\n@[simp] lemma prod_extend_right_apply_eq (b : β₁) :\n  prod_extend_right a e (a, b) = (a, e b) := if_pos rfl\n\nlemma prod_extend_right_apply_ne {a a' : α₁} (h : a' ≠ a) (b : β₁) :\n  prod_extend_right a e (a', b) = (a', b) := if_neg h\n\nlemma eq_of_prod_extend_right_ne {e : perm β₁} {a a' : α₁} {b : β₁}\n  (h : prod_extend_right a e (a', b) ≠ (a', b)) : a' = a :=\nby { contrapose! h, exact prod_extend_right_apply_ne _ h _ }\n\n@[simp] lemma fst_prod_extend_right (ab : α₁ × β₁) :\n  (prod_extend_right a e ab).fst = ab.fst :=\nbegin\n  rw [prod_extend_right, coe_fn_mk],\n  split_ifs with h,\n  { rw h },\n  { refl }\nend\n\nend perm\n\nsection\n/-- The type of functions to a product `α × β` is equivalent to the type of pairs of functions\n`γ → α` and `γ → β`. -/\ndef arrow_prod_equiv_prod_arrow (α β γ : Type*) : (γ → α × β) ≃ (γ → α) × (γ → β) :=\n⟨λ f, (λ c, (f c).1, λ c, (f c).2),\n λ p c, (p.1 c, p.2 c),\n λ f, funext $ λ c, prod.mk.eta,\n λ p, by { cases p, refl }⟩\n\nopen sum\n/-- The type of functions on a sum type `α ⊕ β` is equivalent to the type of pairs of functions\non `α` and on `β`. -/\ndef sum_arrow_equiv_prod_arrow (α β γ : Type*) : ((α ⊕ β) → γ) ≃ (α → γ) × (β → γ) :=\n⟨λ f, (f ∘ inl, f ∘ inr),\n λ p, sum.elim p.1 p.2,\n λ f, by { ext ⟨⟩; refl },\n λ p, by { cases p, refl }⟩\n\n@[simp] lemma sum_arrow_equiv_prod_arrow_apply_fst {α β γ} (f : (α ⊕ β) → γ) (a : α) :\n  (sum_arrow_equiv_prod_arrow α β γ f).1 a = f (inl a) := rfl\n@[simp] lemma sum_arrow_equiv_prod_arrow_apply_snd {α β γ} (f : (α ⊕ β) → γ) (b : β) :\n  (sum_arrow_equiv_prod_arrow α β γ f).2 b = f (inr b) := rfl\n@[simp] lemma sum_arrow_equiv_prod_arrow_symm_apply_inl {α β γ} (f : α → γ) (g : β → γ) (a : α) :\n  ((sum_arrow_equiv_prod_arrow α β γ).symm (f, g)) (inl a) = f a := rfl\n@[simp] lemma sum_arrow_equiv_prod_arrow_symm_apply_inr {α β γ} (f : α → γ) (g : β → γ) (b : β) :\n  ((sum_arrow_equiv_prod_arrow α β γ).symm (f, g)) (inr b) = g b := rfl\n\n/-- Type product is right distributive with respect to type sum up to an equivalence. -/\ndef sum_prod_distrib (α β γ : Sort*) : (α ⊕ β) × γ ≃ (α × γ) ⊕ (β × γ) :=\n⟨λ p, p.1.map (λ x, (x, p.2)) (λ x, (x, p.2)),\n λ s, s.elim (prod.map inl id) (prod.map inr id),\n by rintro ⟨_ | _, _⟩; refl,\n by rintro (⟨_, _⟩ | ⟨_, _⟩); refl⟩\n\n@[simp] theorem sum_prod_distrib_apply_left {α β γ} (a : α) (c : γ) :\n   sum_prod_distrib α β γ (sum.inl a, c) = sum.inl (a, c) := rfl\n@[simp] theorem sum_prod_distrib_apply_right {α β γ} (b : β) (c : γ) :\n   sum_prod_distrib α β γ (sum.inr b, c) = sum.inr (b, c) := rfl\n@[simp] theorem sum_prod_distrib_symm_apply_left {α β γ} (a : α × γ) :\n  (sum_prod_distrib α β γ).symm (inl a) = (inl a.1, a.2) := rfl\n@[simp] theorem sum_prod_distrib_symm_apply_right {α β γ} (b : β × γ) :\n  (sum_prod_distrib α β γ).symm (inr b) = (inr b.1, b.2) := rfl\n\n/-- Type product is left distributive with respect to type sum up to an equivalence. -/\ndef prod_sum_distrib (α β γ : Sort*) : α × (β ⊕ γ) ≃ (α × β) ⊕ (α × γ) :=\ncalc α × (β ⊕ γ) ≃ (β ⊕ γ) × α       : prod_comm _ _\n            ...   ≃ (β × α) ⊕ (γ × α) : sum_prod_distrib _ _ _\n            ...   ≃ (α × β) ⊕ (α × γ) : sum_congr (prod_comm _ _) (prod_comm _ _)\n\n@[simp] theorem prod_sum_distrib_apply_left {α β γ} (a : α) (b : β) :\n   prod_sum_distrib α β γ (a, sum.inl b) = sum.inl (a, b) := rfl\n@[simp] theorem prod_sum_distrib_apply_right {α β γ} (a : α) (c : γ) :\n   prod_sum_distrib α β γ (a, sum.inr c) = sum.inr (a, c) := rfl\n@[simp] theorem prod_sum_distrib_symm_apply_left {α β γ} (a : α × β) :\n  (prod_sum_distrib α β γ).symm (inl a) = (a.1, inl a.2) := rfl\n@[simp] theorem prod_sum_distrib_symm_apply_right {α β γ} (a : α × γ) :\n  (prod_sum_distrib α β γ).symm (inr a) = (a.1, inr a.2) := rfl\n\n/-- An indexed sum of disjoint sums of types is equivalent to the sum of the indexed sums. -/\n@[simps] def sigma_sum_distrib {ι : Type*} (α β : ι → Type*) :\n  (Σ i, α i ⊕ β i) ≃ (Σ i, α i) ⊕ Σ i, β i :=\n⟨λ p, p.2.map (sigma.mk p.1) (sigma.mk p.1),\n  sum.elim (sigma.map id (λ _, sum.inl)) (sigma.map id (λ _, sum.inr)),\n  λ p, by { rcases p with ⟨i, (a | b)⟩; refl },\n  λ p, by { rcases p with (⟨i, a⟩ | ⟨i, b⟩); refl }⟩\n\n/-- The product of an indexed sum of types (formally, a `sigma`-type `Σ i, α i`) by a type `β` is\nequivalent to the sum of products `Σ i, (α i × β)`. -/\ndef sigma_prod_distrib {ι : Type*} (α : ι → Type*) (β : Type*) :\n  ((Σ i, α i) × β) ≃ (Σ i, (α i × β)) :=\n⟨λ p, ⟨p.1.1, (p.1.2, p.2)⟩,\n λ p, (⟨p.1, p.2.1⟩, p.2.2),\n λ p, by { rcases p with ⟨⟨_, _⟩, _⟩, refl },\n λ p, by { rcases p with ⟨_, ⟨_, _⟩⟩, refl }⟩\n\n/-- An equivalence that separates out the 0th fiber of `(Σ (n : ℕ), f n)`. -/\ndef sigma_nat_succ (f : ℕ → Type u) :\n  (Σ n, f n) ≃ f 0 ⊕ Σ n, f (n + 1) :=\n⟨λ x, @sigma.cases_on ℕ f (λ _, f 0 ⊕ Σ n, f (n + 1)) x (λ n, @nat.cases_on (λ i, f i → (f 0 ⊕\n  Σ (n : ℕ), f (n + 1))) n (λ (x : f 0), sum.inl x) (λ (n : ℕ) (x : f n.succ), sum.inr ⟨n, x⟩)),\n  sum.elim (sigma.mk 0) (sigma.map nat.succ (λ _, id)),\n  by { rintro ⟨(n | n), x⟩; refl }, by { rintro (x | ⟨n, x⟩); refl }⟩\n\n/-- The product `bool × α` is equivalent to `α ⊕ α`. -/\n@[simps] def bool_prod_equiv_sum (α : Type u) : bool × α ≃ α ⊕ α :=\n{ to_fun := λ p, cond p.1 (inr p.2) (inl p.2),\n  inv_fun := sum.elim (prod.mk ff) (prod.mk tt),\n  left_inv := by rintro ⟨(_|_), _⟩; refl,\n  right_inv := by rintro (_|_); refl }\n\n/-- The function type `bool → α` is equivalent to `α × α`. -/\n@[simps] def bool_arrow_equiv_prod (α : Type u) : (bool → α) ≃ α × α :=\n{ to_fun := λ f, (f tt, f ff),\n  inv_fun := λ p b, cond b p.1 p.2,\n  left_inv := λ f, funext $ bool.forall_bool.2 ⟨rfl, rfl⟩,\n  right_inv := λ ⟨x, y⟩, rfl }\n\nend\n\nsection\nopen sum nat\n/-- The set of natural numbers is equivalent to `ℕ ⊕ punit`. -/\ndef nat_equiv_nat_sum_punit : ℕ ≃ ℕ ⊕ punit.{u+1} :=\n{ to_fun := λ n, nat.cases_on n (inr punit.star) inl,\n  inv_fun := sum.elim nat.succ (λ _, 0),\n  left_inv := λ n, by cases n; refl,\n  right_inv := by rintro (_|_|_); refl }\n\n/-- `ℕ ⊕ punit` is equivalent to `ℕ`. -/\ndef nat_sum_punit_equiv_nat : ℕ ⊕ punit.{u+1} ≃ ℕ :=\nnat_equiv_nat_sum_punit.symm\n\n/-- The type of integer numbers is equivalent to `ℕ ⊕ ℕ`. -/\ndef int_equiv_nat_sum_nat : ℤ ≃ ℕ ⊕ ℕ :=\n{ to_fun := λ z, int.cases_on z inl inr,\n  inv_fun := sum.elim coe int.neg_succ_of_nat,\n  left_inv := by rintro (m|n); refl,\n  right_inv := by rintro (m|n); refl }\n\nend\n\n/-- An equivalence between `α` and `β` generates an equivalence between `list α` and `list β`. -/\ndef list_equiv_of_equiv {α β : Type*} (e : α ≃ β) : list α ≃ list β :=\n{ to_fun := list.map e,\n  inv_fun := list.map e.symm,\n  left_inv := λ l, by rw [list.map_map, e.symm_comp_self, list.map_id],\n  right_inv := λ l, by rw [list.map_map, e.self_comp_symm, list.map_id] }\n\n/-- If `α` is equivalent to `β`, then `unique α` is equivalent to `unique β`. -/\ndef unique_congr (e : α ≃ β) : unique α ≃ unique β :=\n{ to_fun := λ h, @equiv.unique _ _ h e.symm,\n  inv_fun := λ h, @equiv.unique _ _ h e,\n  left_inv := λ _, subsingleton.elim _ _,\n  right_inv := λ _, subsingleton.elim _ _ }\n\n/-- If `α` is equivalent to `β`, then `is_empty α` is equivalent to `is_empty β`. -/\nlemma is_empty_congr (e : α ≃ β) : is_empty α ↔ is_empty β :=\n⟨λ h, @function.is_empty _ _ h e.symm, λ h, @function.is_empty _ _ h e⟩\n\nprotected lemma is_empty (e : α ≃ β) [is_empty β] : is_empty α :=\ne.is_empty_congr.mpr ‹_›\n\nsection\nopen subtype\n\n/-- If `α` is equivalent to `β` and the predicates `p : α → Prop` and `q : β → Prop` are equivalent\nat corresponding points, then `{a // p a}` is equivalent to `{b // q b}`.\nFor the statement where `α = β`, that is, `e : perm α`, see `perm.subtype_perm`. -/\ndef subtype_equiv {p : α → Prop} {q : β → Prop}\n  (e : α ≃ β) (h : ∀ a, p a ↔ q (e a)) : {a : α // p a} ≃ {b : β // q b} :=\n{ to_fun    := λ a, ⟨e a, (h _).mp a.prop⟩,\n  inv_fun   := λ b, ⟨e.symm b, (h _).mpr ((e.apply_symm_apply b).symm ▸ b.prop)⟩,\n  left_inv  := λ a, subtype.ext $ by simp,\n  right_inv := λ b, subtype.ext $ by simp }\n\n@[simp] lemma subtype_equiv_refl {p : α → Prop}\n  (h : ∀ a, p a ↔ p (equiv.refl _ a) := λ a, iff.rfl) :\n  (equiv.refl α).subtype_equiv h = equiv.refl {a : α // p a} :=\nby { ext, refl }\n\n@[simp] lemma subtype_equiv_symm {p : α → Prop} {q : β → Prop} (e : α ≃ β)\n  (h : ∀ (a : α), p a ↔ q (e a)) :\n  (e.subtype_equiv h).symm = e.symm.subtype_equiv (λ a, by\n  { convert (h $ e.symm a).symm,\n    exact (e.apply_symm_apply a).symm }) :=\nrfl\n\n@[simp] lemma subtype_equiv_trans {p : α → Prop} {q : β → Prop} {r : γ → Prop}\n  (e : α ≃ β) (f : β ≃ γ)\n  (h : ∀ (a : α), p a ↔ q (e a)) (h' : ∀ (b : β), q b ↔ r (f b)):\n  (e.subtype_equiv h).trans (f.subtype_equiv h') =\n    (e.trans f).subtype_equiv (λ a, (h a).trans (h' $ e a)) :=\nrfl\n\n@[simp] lemma subtype_equiv_apply {p : α → Prop} {q : β → Prop} (e : α ≃ β)\n  (h : ∀ (a : α), p a ↔ q (e a)) (x : {x // p x}) :\n  e.subtype_equiv h x = ⟨e x, (h _).1 x.2⟩ :=\nrfl\n\n/-- If two predicates `p` and `q` are pointwise equivalent, then `{x // p x}` is equivalent to\n`{x // q x}`. -/\n@[simps]\ndef subtype_equiv_right {p q : α → Prop} (e : ∀x, p x ↔ q x) : {x // p x} ≃ {x // q x} :=\nsubtype_equiv (equiv.refl _) e\n\n/-- If `α ≃ β`, then for any predicate `p : β → Prop` the subtype `{a // p (e a)}` is equivalent\nto the subtype `{b // p b}`. -/\ndef subtype_equiv_of_subtype {p : β → Prop} (e : α ≃ β) :\n  {a : α // p (e a)} ≃ {b : β // p b} :=\nsubtype_equiv e $ by simp\n\n/-- If `α ≃ β`, then for any predicate `p : α → Prop` the subtype `{a // p a}` is equivalent\nto the subtype `{b // p (e.symm b)}`. This version is used by `equiv_rw`. -/\ndef subtype_equiv_of_subtype' {p : α → Prop} (e : α ≃ β) :\n  {a : α // p a} ≃ {b : β // p (e.symm b)} :=\ne.symm.subtype_equiv_of_subtype.symm\n\n/-- If two predicates are equal, then the corresponding subtypes are equivalent. -/\ndef subtype_equiv_prop {α : Sort*} {p q : α → Prop} (h : p = q) : subtype p ≃ subtype q :=\nsubtype_equiv (equiv.refl α) (assume a, h ▸ iff.rfl)\n\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. This\nversion allows the “inner” predicate to depend on `h : p a`. -/\n@[simps]\ndef subtype_subtype_equiv_subtype_exists {α : Sort u} (p : α → Prop) (q : subtype p → Prop) :\n  subtype q ≃ {a : α // ∃h:p a, q ⟨a, h⟩ } :=\n⟨λ a, ⟨a, a.1.2, by { rcases a with ⟨⟨a, hap⟩, haq⟩, exact haq }⟩,\n  λ a, ⟨⟨a, a.2.fst⟩, a.2.snd⟩,\n  assume ⟨⟨a, ha⟩, h⟩, rfl, assume ⟨a, h₁, h₂⟩, rfl⟩\n\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. -/\n@[simps] def subtype_subtype_equiv_subtype_inter {α : Sort u} (p q : α → Prop) :\n  {x : subtype p // q x.1} ≃ subtype (λ x, p x ∧ q x) :=\n(subtype_subtype_equiv_subtype_exists p _).trans $\nsubtype_equiv_right $ λ x, exists_prop\n\n/-- If the outer subtype has more restrictive predicate than the inner one,\nthen we can drop the latter. -/\n@[simps] def subtype_subtype_equiv_subtype {α : Type u} {p q : α → Prop} (h : ∀ {x}, q x → p x) :\n  {x : subtype p // q x.1} ≃ subtype q :=\n(subtype_subtype_equiv_subtype_inter p _).trans $\nsubtype_equiv_right $ λ x, and_iff_right_of_imp h\n\n/-- If a proposition holds for all elements, then the subtype is\nequivalent to the original type. -/\n@[simps apply symm_apply]\ndef subtype_univ_equiv {α : Type u} {p : α → Prop} (h : ∀ x, p x) :\n  subtype p ≃ α :=\n⟨λ x, x, λ x, ⟨x, h x⟩, λ x, subtype.eq rfl, λ x, rfl⟩\n\n/-- A subtype of a sigma-type is a sigma-type over a subtype. -/\ndef subtype_sigma_equiv {α : Type u} (p : α → Type v) (q : α → Prop) :\n  { y : sigma p // q y.1 } ≃ Σ(x : subtype q), p x.1 :=\n⟨λ x, ⟨⟨x.1.1, x.2⟩, x.1.2⟩,\n λ x, ⟨⟨x.1.1, x.2⟩, x.1.2⟩,\n λ ⟨⟨x, h⟩, y⟩, rfl,\n λ ⟨⟨x, y⟩, h⟩, rfl⟩\n\n/-- A sigma type over a subtype is equivalent to the sigma set over the original type,\nif the fiber is empty outside of the subset -/\ndef sigma_subtype_equiv_of_subset {α : Type u} (p : α → Type v) (q : α → Prop)\n  (h : ∀ x, p x → q x) :\n  (Σ x : subtype q, p x) ≃ Σ x : α, p x :=\n(subtype_sigma_equiv p q).symm.trans $ subtype_univ_equiv $ λ x, h x.1 x.2\n\n/-- If a predicate `p : β → Prop` is true on the range of a map `f : α → β`, then\n`Σ y : {y // p y}, {x // f x = y}` is equivalent to `α`. -/\ndef sigma_subtype_fiber_equiv {α : Type u} {β : Type v} (f : α → β) (p : β → Prop)\n  (h : ∀ x, p (f x)) :\n  (Σ y : subtype p, {x : α // f x = y}) ≃ α :=\ncalc _ ≃ Σ y : β, {x : α // f x = y} : sigma_subtype_equiv_of_subset _ p (λ y ⟨x, h'⟩, h' ▸ h x)\n   ... ≃ α                           : sigma_fiber_equiv f\n\n/-- If for each `x` we have `p x ↔ q (f x)`, then `Σ y : {y // q y}, f ⁻¹' {y}` is equivalent\nto `{x // p x}`. -/\ndef sigma_subtype_fiber_equiv_subtype {α : Type u} {β : Type v} (f : α → β)\n  {p : α → Prop} {q : β → Prop} (h : ∀ x, p x ↔ q (f x)) :\n  (Σ y : subtype q, {x : α // f x = y}) ≃ subtype p :=\ncalc (Σ y : subtype q, {x : α // f x = y}) ≃\n  Σ y : subtype q, {x : subtype p // subtype.mk (f x) ((h x).1 x.2) = y} :\n  begin\n    apply sigma_congr_right,\n    assume y,\n    symmetry,\n    refine (subtype_subtype_equiv_subtype_exists _ _).trans (subtype_equiv_right _),\n    assume x,\n    exact ⟨λ ⟨hp, h'⟩, congr_arg subtype.val h', λ h', ⟨(h x).2 (h'.symm ▸ y.2), subtype.eq h'⟩⟩\n  end\n   ... ≃ subtype p : sigma_fiber_equiv (λ x : subtype p, (⟨f x, (h x).1 x.property⟩ : subtype q))\n\n/-- A sigma type over an `option` is equivalent to the sigma set over the original type,\nif the fiber is empty at none. -/\ndef sigma_option_equiv_of_some {α : Type u} (p : option α → Type v) (h : p none → false) :\n  (Σ x : option α, p x) ≃ (Σ x : α, p (some x)) :=\nbegin\n  have h' : ∀ x, p x → x.is_some,\n  { intro x,\n    cases x,\n    { intro n, exfalso, exact h n },\n    { intro s, exact rfl } },\n  exact (sigma_subtype_equiv_of_subset _ _ h').symm.trans\n    (sigma_congr_left' (option_is_some_equiv α)),\nend\n\n/-- The `pi`-type `Π i, π i` is equivalent to the type of sections `f : ι → Σ i, π i` of the\n`sigma` type such that for all `i` we have `(f i).fst = i`. -/\ndef pi_equiv_subtype_sigma (ι : Type*) (π : ι → Type*) :\n  (Π i, π i) ≃ {f : ι → Σ i, π i // ∀ i, (f i).1 = i } :=\n⟨ λf, ⟨λi, ⟨i, f i⟩, assume i, rfl⟩, λf i, begin rw ← f.2 i, exact (f.1 i).2 end,\n  assume f, funext $ assume i, rfl,\n  assume ⟨f, hf⟩, subtype.eq $ funext $ assume i, sigma.eq (hf i).symm $\n    eq_of_heq $ rec_heq_of_heq _ $ rec_heq_of_heq _ $ heq.refl _⟩\n\n/-- The set of functions `f : Π a, β a` such that for all `a` we have `p a (f a)` is equivalent\nto the set of functions `Π a, {b : β a // p a b}`. -/\ndef subtype_pi_equiv_pi {α : Sort u} {β : α → Sort v} {p : Πa, β a → Prop} :\n  {f : Πa, β a // ∀a, p a (f a) } ≃ Πa, { b : β a // p a b } :=\n⟨λf a, ⟨f.1 a, f.2 a⟩, λf, ⟨λa, (f a).1, λa, (f a).2⟩,\n  by { rintro ⟨f, h⟩, refl },\n  by { rintro f, funext a, exact subtype.ext_val rfl }⟩\n\n/-- A subtype of a product defined by componentwise conditions\nis equivalent to a product of subtypes. -/\ndef subtype_prod_equiv_prod {α : Type u} {β : Type v} {p : α → Prop} {q : β → Prop} :\n  {c : α × β // p c.1 ∧ q c.2} ≃ ({a // p a} × {b // q b}) :=\n⟨λ x, ⟨⟨x.1.1, x.2.1⟩, ⟨x.1.2, x.2.2⟩⟩,\n λ x, ⟨⟨x.1.1, x.2.1⟩, ⟨x.1.2, x.2.2⟩⟩,\n λ ⟨⟨_, _⟩, ⟨_, _⟩⟩, rfl,\n λ ⟨⟨_, _⟩, ⟨_, _⟩⟩, rfl⟩\n\n/-- A subtype of a `prod` is equivalent to a sigma type whose fibers are subtypes. -/\ndef subtype_prod_equiv_sigma_subtype {α β : Type*} (p : α → β → Prop) :\n  {x : α × β // p x.1 x.2} ≃ Σ a, {b : β // p a b} :=\n{ to_fun := λ x, ⟨x.1.1, x.1.2, x.prop⟩,\n  inv_fun := λ x, ⟨⟨x.1, x.2⟩, x.2.prop⟩,\n  left_inv := λ x, by ext; refl,\n  right_inv := λ ⟨a, b, pab⟩, rfl }\n\n/-- The type `Π (i : α), β i` can be split as a product by separating the indices in `α`\ndepending on whether they satisfy a predicate `p` or not. -/\n@[simps] def pi_equiv_pi_subtype_prod\n  {α : Type*} (p : α → Prop) (β : α → Type*) [decidable_pred p] :\n  (Π (i : α), β i) ≃ (Π (i : {x // p x}), β i) × (Π (i : {x // ¬ p x}), β i) :=\n{ to_fun := λ f, (λ x, f x, λ x, f x),\n  inv_fun := λ f x, if h : p x then f.1 ⟨x, h⟩ else f.2 ⟨x, h⟩,\n  right_inv := begin\n    rintros ⟨f, g⟩,\n    ext1;\n    { ext y,\n      rcases y,\n      simp only [y_property, dif_pos, dif_neg, not_false_iff, subtype.coe_mk],\n      refl },\n  end,\n  left_inv := λ f, begin\n    ext x,\n    by_cases h : p x;\n    { simp only [h, dif_neg, dif_pos, not_false_iff],\n      refl },\n  end }\n\n/-- A product of types can be split as the binary product of one of the types and the product\n  of all the remaining types. -/\n@[simps] def pi_split_at {α : Type*} [decidable_eq α] (i : α) (β : α → Type*) :\n  (Π j, β j) ≃ β i × Π j : {j // j ≠ i}, β j :=\n{ to_fun := λ f, ⟨f i, λ j, f j⟩,\n  inv_fun := λ f j, if h : j = i then h.symm.rec f.1 else f.2 ⟨j, h⟩,\n  right_inv := λ f, by { ext, exacts [dif_pos rfl, (dif_neg x.2).trans (by cases x; refl)] },\n  left_inv := λ f, by { ext, dsimp only, split_ifs, { subst h }, { refl } } }\n\n/-- A product of copies of a type can be split as the binary product of one copy and the product\n  of all the remaining copies. -/\n@[simps] def fun_split_at {α : Type*} [decidable_eq α] (i : α) (β : Type*) :\n  (α → β) ≃ β × ({j // j ≠ i} → β) := pi_split_at i _\n\nend\n\nsection subtype_equiv_codomain\nvariables {X : Type*} {Y : Type*} [decidable_eq X] {x : X}\n\n/-- The type of all functions `X → Y` with prescribed values for all `x' ≠ x`\nis equivalent to the codomain `Y`. -/\ndef subtype_equiv_codomain (f : {x' // x' ≠ x} → Y) : {g : X → Y // g ∘ coe = f} ≃ Y :=\n(subtype_preimage _ f).trans $\n@fun_unique {x' // ¬ x' ≠ x} _ $\nshow unique {x' // ¬ x' ≠ x}, from @equiv.unique _ _\n  (show unique {x' // x' = x}, from\n    { default := ⟨x, rfl⟩, uniq := λ ⟨x', h⟩, subtype.val_injective h })\n  (subtype_equiv_right $ λ a, not_not)\n\n@[simp] lemma coe_subtype_equiv_codomain (f : {x' // x' ≠ x} → Y) :\n  (subtype_equiv_codomain f : {g : X → Y // g ∘ coe = f} → Y) = λ g, (g : X → Y) x := rfl\n\n@[simp] lemma subtype_equiv_codomain_apply (f : {x' // x' ≠ x} → Y)\n  (g : {g : X → Y // g ∘ coe = f}) :\n  subtype_equiv_codomain f g = (g : X → Y) x := rfl\n\nlemma coe_subtype_equiv_codomain_symm (f : {x' // x' ≠ x} → Y) :\n  ((subtype_equiv_codomain f).symm : Y → {g : X → Y // g ∘ coe = f}) =\n  λ y, ⟨λ x', if h : x' ≠ x then f ⟨x', h⟩ else y,\n    by { funext x', dsimp, erw [dif_pos x'.2, subtype.coe_eta] }⟩ := rfl\n\n@[simp] lemma subtype_equiv_codomain_symm_apply (f : {x' // x' ≠ x} → Y) (y : Y) (x' : X) :\n  ((subtype_equiv_codomain f).symm y : X → Y) x' = if h : x' ≠ x then f ⟨x', h⟩ else y :=\nrfl\n\n@[simp] lemma subtype_equiv_codomain_symm_apply_eq (f : {x' // x' ≠ x} → Y) (y : Y) :\n  ((subtype_equiv_codomain f).symm y : X → Y) x = y :=\ndif_neg (not_not.mpr rfl)\n\nlemma subtype_equiv_codomain_symm_apply_ne (f : {x' // x' ≠ x} → Y) (y : Y) (x' : X) (h : x' ≠ x) :\n  ((subtype_equiv_codomain f).symm y : X → Y) x' = f ⟨x', h⟩ :=\ndif_pos h\n\nend subtype_equiv_codomain\n\n/-- If `f` is a bijective function, then its domain is equivalent to its codomain. -/\n@[simps apply]\nnoncomputable def of_bijective (f : α → β) (hf : bijective f) : α ≃ β :=\n{ to_fun := f,\n  inv_fun := function.surj_inv hf.surjective,\n  left_inv := function.left_inverse_surj_inv hf,\n  right_inv := function.right_inverse_surj_inv _}\n\nlemma of_bijective_apply_symm_apply (f : α → β) (hf : bijective f) (x : β) :\n  f ((of_bijective f hf).symm x) = x :=\n(of_bijective f hf).apply_symm_apply x\n\n@[simp] lemma of_bijective_symm_apply_apply (f : α → β) (hf : bijective f) (x : α) :\n  (of_bijective f hf).symm (f x) = x :=\n(of_bijective f hf).symm_apply_apply x\n\ninstance : can_lift (α → β) (α ≃ β) coe_fn bijective :=\n{ prf := λ f hf, ⟨of_bijective f hf, rfl⟩ }\n\nsection\n\nvariables {α' β' : Type*} (e : perm α') {p : β' → Prop} [decidable_pred p]\n  (f : α' ≃ subtype p)\n\n/--\nExtend the domain of `e : equiv.perm α` to one that is over `β` via `f : α → subtype p`,\nwhere `p : β → Prop`, permuting only the `b : β` that satisfy `p b`.\nThis can be used to extend the domain across a function `f : α → β`,\nkeeping everything outside of `set.range f` fixed. For this use-case `equiv` given by `f` can\nbe constructed by `equiv.of_left_inverse'` or `equiv.of_left_inverse` when there is a known\ninverse, or `equiv.of_injective` in the general case.`.\n-/\ndef perm.extend_domain : perm β' :=\n(perm_congr f e).subtype_congr (equiv.refl _)\n\n@[simp] lemma perm.extend_domain_apply_image (a : α') :\n  e.extend_domain f (f a) = f (e a) :=\nby simp [perm.extend_domain]\n\nlemma perm.extend_domain_apply_subtype {b : β'} (h : p b) :\n  e.extend_domain f b = f (e (f.symm ⟨b, h⟩)) :=\nby simp [perm.extend_domain, h]\n\nlemma perm.extend_domain_apply_not_subtype {b : β'} (h : ¬ p b) :\n  e.extend_domain f b = b :=\nby simp [perm.extend_domain, h]\n\n@[simp] lemma perm.extend_domain_refl : perm.extend_domain (equiv.refl _) f = equiv.refl _ :=\nby simp [perm.extend_domain]\n\n@[simp] lemma perm.extend_domain_symm :\n  (e.extend_domain f).symm = perm.extend_domain e.symm f := rfl\n\nlemma perm.extend_domain_trans (e e' : perm α') :\n  (e.extend_domain f).trans (e'.extend_domain f) = perm.extend_domain (e.trans e') f :=\nby simp [perm.extend_domain, perm_congr_trans]\n\nend\n\n/-- Subtype of the quotient is equivalent to the quotient of the subtype. Let `α` be a setoid with\nequivalence relation `~`. Let `p₂` be a predicate on the quotient type `α/~`, and `p₁` be the lift\nof this predicate to `α`: `p₁ a ↔ p₂ ⟦a⟧`. Let `~₂` be the restriction of `~` to `{x // p₁ x}`.\nThen `{x // p₂ x}` is equivalent to the quotient of `{x // p₁ x}` by `~₂`. -/\ndef subtype_quotient_equiv_quotient_subtype (p₁ : α → Prop) [s₁ : setoid α]\n  [s₂ : setoid (subtype p₁)] (p₂ : quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧)\n  (h : ∀ x y : subtype p₁, @setoid.r _ s₂ x y ↔ (x : α) ≈ y) :\n  {x // p₂ x} ≃ quotient s₂ :=\n{ to_fun := λ a, quotient.hrec_on a.1 (λ a h, ⟦⟨a, (hp₂ _).2 h⟩⟧)\n    (λ a b hab, hfunext (by rw quotient.sound hab)\n    (λ h₁ h₂ _, heq_of_eq (quotient.sound ((h _ _).2 hab)))) a.2,\n  inv_fun := λ a, quotient.lift_on a (λ a, (⟨⟦a.1⟧, (hp₂ _).1 a.2⟩ : {x // p₂ x}))\n    (λ a b hab, subtype.ext_val (quotient.sound ((h _ _).1 hab))),\n  left_inv := λ ⟨a, ha⟩, quotient.induction_on a (λ a ha, rfl) ha,\n  right_inv := λ a, quotient.induction_on a (λ ⟨a, ha⟩, rfl) }\n\n@[simp] lemma subtype_quotient_equiv_quotient_subtype_mk (p₁ : α → Prop) [s₁ : setoid α]\n  [s₂ : setoid (subtype p₁)] (p₂ : quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧)\n  (h : ∀ x y : subtype p₁, @setoid.r _ s₂ x y ↔ (x : α) ≈ y) (x hx) :\n  subtype_quotient_equiv_quotient_subtype p₁ p₂ hp₂ h ⟨⟦x⟧, hx⟩ = ⟦⟨x, (hp₂ _).2 hx⟩⟧ := rfl\n\n@[simp] lemma subtype_quotient_equiv_quotient_subtype_symm_mk (p₁ : α → Prop) [s₁ : setoid α]\n  [s₂ : setoid (subtype p₁)] (p₂ : quotient s₁ → Prop) (hp₂ : ∀ a, p₁ a ↔ p₂ ⟦a⟧)\n  (h : ∀ x y : subtype p₁, @setoid.r _ s₂ x y ↔ (x : α) ≈ y) (x) :\n  (subtype_quotient_equiv_quotient_subtype p₁ p₂ hp₂ h).symm ⟦x⟧ = ⟨⟦x⟧, (hp₂ _).1 x.prop⟩ := rfl\n\nsection swap\nvariable [decidable_eq α]\n\n/-- A helper function for `equiv.swap`. -/\ndef swap_core (a b r : α) : α :=\nif r = a then b\nelse if r = b then a\nelse r\n\ntheorem swap_core_self (r a : α) : swap_core a a r = r :=\nby { unfold swap_core, split_ifs; cc }\n\ntheorem swap_core_swap_core (r a b : α) : swap_core a b (swap_core a b r) = r :=\nby { unfold swap_core, split_ifs; cc }\n\ntheorem swap_core_comm (r a b : α) : swap_core a b r = swap_core b a r :=\nby { unfold swap_core, split_ifs; cc }\n\n/-- `swap a b` is the permutation that swaps `a` and `b` and\n  leaves other values as is. -/\ndef swap (a b : α) : perm α :=\n⟨swap_core a b, swap_core a b, λr, swap_core_swap_core r a b, λr, swap_core_swap_core r a b⟩\n\n@[simp] theorem swap_self (a : α) : swap a a = equiv.refl _ :=\next $ λ r, swap_core_self r a\n\ntheorem swap_comm (a b : α) : swap a b = swap b a :=\next $ λ r, swap_core_comm r _ _\n\ntheorem swap_apply_def (a b x : α) : swap a b x = if x = a then b else if x = b then a else x :=\nrfl\n\n@[simp] theorem swap_apply_left (a b : α) : swap a b a = b :=\nif_pos rfl\n\n@[simp] theorem swap_apply_right (a b : α) : swap a b b = a :=\nby { by_cases h : b = a; simp [swap_apply_def, h], }\n\ntheorem swap_apply_of_ne_of_ne {a b x : α} : x ≠ a → x ≠ b → swap a b x = x :=\nby simp [swap_apply_def] {contextual := tt}\n\n@[simp] theorem swap_swap (a b : α) : (swap a b).trans (swap a b) = equiv.refl _ :=\next $ λ x, swap_core_swap_core _ _ _\n\n@[simp] lemma symm_swap (a b : α) : (swap a b).symm = swap a b := rfl\n\n@[simp] lemma swap_eq_refl_iff {x y : α} : swap x y = equiv.refl _ ↔ x = y :=\nbegin\n  refine ⟨λ h, (equiv.refl _).injective _, λ h, h ▸ (swap_self _)⟩,\n  rw [←h, swap_apply_left, h, refl_apply]\nend\n\ntheorem swap_comp_apply {a b x : α} (π : perm α) :\n  π.trans (swap a b) x = if π x = a then b else if π x = b then a else π x :=\nby { cases π, refl }\n\nlemma swap_eq_update (i j : α) :\n  (equiv.swap i j : α → α) = update (update id j i) i j :=\nfunext $ λ x, by rw [update_apply _ i j, update_apply _ j i, equiv.swap_apply_def, id.def]\n\nlemma comp_swap_eq_update (i j : α) (f : α → β) :\n  f ∘ equiv.swap i j = update (update f j (f i)) i (f j) :=\nby rw [swap_eq_update, comp_update, comp_update, comp.right_id]\n\n@[simp] lemma symm_trans_swap_trans [decidable_eq β] (a b : α) (e : α ≃ β) :\n  (e.symm.trans (swap a b)).trans e = swap (e a) (e b) :=\nequiv.ext (λ x, begin\n  have : ∀ a, e.symm x = a ↔ x = e a :=\n    λ a, by { rw @eq_comm _ (e.symm x), split; intros; simp * at * },\n  simp [swap_apply_def, this],\n  split_ifs; simp\nend)\n\n@[simp] lemma trans_swap_trans_symm [decidable_eq β] (a b : β)\n  (e : α ≃ β) : (e.trans (swap a b)).trans e.symm = swap (e.symm a) (e.symm b) :=\nsymm_trans_swap_trans a b e.symm\n\n@[simp] lemma swap_apply_self (i j a : α) :\n  swap i j (swap i j a) = a :=\nby rw [← equiv.trans_apply, equiv.swap_swap, equiv.refl_apply]\n\n/-- A function is invariant to a swap if it is equal at both elements -/\nlemma apply_swap_eq_self {v : α → β} {i j : α} (hv : v i = v j) (k : α) : v (swap i j k) = v k :=\nbegin\n  by_cases hi : k = i, { rw [hi, swap_apply_left, hv] },\n  by_cases hj : k = j, { rw [hj, swap_apply_right, hv] },\n  rw swap_apply_of_ne_of_ne hi hj,\nend\n\nlemma swap_apply_eq_iff {x y z w : α} :\n  swap x y z = w ↔ z = swap x y w :=\nby rw [apply_eq_iff_eq_symm_apply, symm_swap]\n\nlemma swap_apply_ne_self_iff {a b x : α} : swap a b x ≠ x ↔ a ≠ b ∧ (x = a ∨ x = b) :=\nbegin\n  by_cases hab : a = b,\n  { simp [hab] },\n  by_cases hax : x = a,\n  { simp [hax, eq_comm] },\n  by_cases hbx : x = b,\n  { simp [hbx] },\n  simp [hab, hax, hbx, swap_apply_of_ne_of_ne]\nend\n\nnamespace perm\n\n@[simp] lemma sum_congr_swap_refl {α β : Sort*} [decidable_eq α] [decidable_eq β] (i j : α) :\n  equiv.perm.sum_congr (equiv.swap i j) (equiv.refl β) = equiv.swap (sum.inl i) (sum.inl j) :=\nbegin\n  ext x,\n  cases x,\n  { simp [sum.map, swap_apply_def],\n    split_ifs; refl},\n  { simp [sum.map, swap_apply_of_ne_of_ne] },\nend\n\n@[simp] lemma sum_congr_refl_swap {α β : Sort*} [decidable_eq α] [decidable_eq β] (i j : β) :\n  equiv.perm.sum_congr (equiv.refl α) (equiv.swap i j) = equiv.swap (sum.inr i) (sum.inr j) :=\nbegin\n  ext x,\n  cases x,\n  { simp [sum.map, swap_apply_of_ne_of_ne] },\n  { simp [sum.map, swap_apply_def],\n    split_ifs; refl},\nend\n\nend perm\n\n/-- Augment an equivalence with a prescribed mapping `f a = b` -/\ndef set_value (f : α ≃ β) (a : α) (b : β) : α ≃ β :=\n(swap a (f.symm b)).trans f\n\n@[simp] theorem set_value_eq (f : α ≃ β) (a : α) (b : β) : set_value f a b a = b :=\nby { dsimp [set_value], simp [swap_apply_left] }\n\nend swap\n\nend equiv\n\nnamespace function.involutive\n\n/-- Convert an involutive function `f` to a permutation with `to_fun = inv_fun = f`. -/\ndef to_perm (f : α → α) (h : involutive f) : equiv.perm α :=\n⟨f, f, h.left_inverse, h.right_inverse⟩\n\n@[simp] lemma coe_to_perm {f : α → α} (h : involutive f) : (h.to_perm f : α → α) = f := rfl\n\n@[simp] lemma to_perm_symm {f : α → α} (h : involutive f) : (h.to_perm f).symm = h.to_perm f := rfl\n\nlemma to_perm_involutive {f : α → α} (h : involutive f) : involutive (h.to_perm f) := h\n\nend function.involutive\n\nlemma plift.eq_up_iff_down_eq {x : plift α} {y : α} : x = plift.up y ↔ x.down = y :=\nequiv.plift.eq_symm_apply\n\nlemma function.injective.map_swap {α β : Sort*} [decidable_eq α] [decidable_eq β]\n  {f : α → β} (hf : function.injective f) (x y z : α) :\n  f (equiv.swap x y z) = equiv.swap (f x) (f y) (f z) :=\nbegin\n  conv_rhs { rw equiv.swap_apply_def },\n  split_ifs with h₁ h₂,\n  { rw [hf h₁, equiv.swap_apply_left] },\n  { rw [hf h₂, equiv.swap_apply_right] },\n  { rw [equiv.swap_apply_of_ne_of_ne (mt (congr_arg f) h₁) (mt (congr_arg f) h₂)] }\nend\n\nnamespace equiv\n\nsection\nvariables (P : α → Sort w) (e : α ≃ β)\n\n/--\nTransport dependent functions through an equivalence of the base space.\n-/\n@[simps] def Pi_congr_left' : (Π a, P a) ≃ (Π b, P (e.symm b)) :=\n{ to_fun := λ f x, f (e.symm x),\n  inv_fun := λ f x, begin rw [← e.symm_apply_apply x], exact f (e x)  end,\n  left_inv := λ f, funext $ λ x, eq_of_heq ((eq_rec_heq _ _).trans\n    (by { dsimp, rw e.symm_apply_apply })),\n  right_inv := λ f, funext $ λ x, eq_of_heq ((eq_rec_heq _ _).trans\n    (by { rw e.apply_symm_apply })) }\n\nend\n\nsection\nvariables (P : β → Sort w) (e : α ≃ β)\n\n/--\nTransporting dependent functions through an equivalence of the base,\nexpressed as a \"simplification\".\n-/\ndef Pi_congr_left : (Π a, P (e a)) ≃ (Π b, P b) :=\n(Pi_congr_left' P e.symm).symm\nend\n\nsection\nvariables\n  {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β) (h₂ : Π a : α, (W a ≃ Z (h₁ a)))\n\n/--\nTransport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibers.\n-/\ndef Pi_congr : (Π a, W a) ≃ (Π b, Z b) :=\n(equiv.Pi_congr_right h₂).trans (equiv.Pi_congr_left _ h₁)\n\n@[simp] lemma coe_Pi_congr_symm :\n  ((h₁.Pi_congr h₂).symm : (Π b, Z b) → (Π a, W a)) = λ f a, (h₂ a).symm (f (h₁ a)) :=\nrfl\n\nlemma Pi_congr_symm_apply (f : Π b, Z b) :\n  (h₁.Pi_congr h₂).symm f = λ a, (h₂ a).symm (f (h₁ a)) :=\nrfl\n\n@[simp] lemma Pi_congr_apply_apply (f : Π a, W a) (a : α) :\n  h₁.Pi_congr h₂ f (h₁ a) = h₂ a (f a) :=\nbegin\n  change cast _ ((h₂ (h₁.symm (h₁ a))) (f (h₁.symm (h₁ a)))) = (h₂ a) (f a),\n  generalize_proofs hZa,\n  revert hZa,\n  rw h₁.symm_apply_apply a,\n  simp,\nend\n\nend\n\nsection\nvariables\n  {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β) (h₂ : Π b : β, (W (h₁.symm b) ≃ Z b))\n\n/--\nTransport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibres.\n-/\ndef Pi_congr' : (Π a, W a) ≃ (Π b, Z b) :=\n(Pi_congr h₁.symm (λ b, (h₂ b).symm)).symm\n\n@[simp] lemma coe_Pi_congr' :\n  (h₁.Pi_congr' h₂ : (Π a, W a) → (Π b, Z b)) = λ f b, h₂ b $ f $ h₁.symm b :=\nrfl\n\nlemma Pi_congr'_apply (f : Π a, W a) :\n  h₁.Pi_congr' h₂ f = λ b, h₂ b $ f $ h₁.symm b :=\nrfl\n\n@[simp] lemma Pi_congr'_symm_apply_symm_apply (f : Π b, Z b) (b : β) :\n  (h₁.Pi_congr' h₂).symm f (h₁.symm b) = (h₂ b).symm (f b) :=\nbegin\n  change cast _ ((h₂ (h₁ (h₁.symm b))).symm (f (h₁ (h₁.symm b)))) = (h₂ b).symm (f b),\n  generalize_proofs hWb,\n  revert hWb,\n  generalize hb : h₁ (h₁.symm b) = b',\n  rw h₁.apply_symm_apply b at hb,\n  subst hb,\n  simp,\nend\n\nend\n\nsection binary_op\n\nvariables {α₁ β₁ : Type*} (e : α₁ ≃ β₁) (f : α₁ → α₁ → α₁)\n\nlemma semiconj_conj (f : α₁ → α₁) : semiconj e f (e.conj f) := λ x, by simp\n\nlemma semiconj₂_conj : semiconj₂ e f (e.arrow_congr e.conj f) := λ x y, by simp\n\ninstance [is_associative α₁ f] :\n  is_associative β₁ (e.arrow_congr (e.arrow_congr e) f) :=\n(e.semiconj₂_conj f).is_associative_right e.surjective\n\ninstance [is_idempotent α₁ f] :\n  is_idempotent β₁ (e.arrow_congr (e.arrow_congr e) f) :=\n(e.semiconj₂_conj f).is_idempotent_right e.surjective\n\ninstance [is_left_cancel α₁ f] :\n  is_left_cancel β₁ (e.arrow_congr (e.arrow_congr e) f) :=\n⟨e.surjective.forall₃.2 $ λ x y z, by simpa using @is_left_cancel.left_cancel _ f _ x y z⟩\n\ninstance [is_right_cancel α₁ f] :\n  is_right_cancel β₁ (e.arrow_congr (e.arrow_congr e) f) :=\n⟨e.surjective.forall₃.2 $ λ x y z, by simpa using @is_right_cancel.right_cancel _ f _ x y z⟩\n\nend binary_op\n\nend equiv\n\nlemma function.injective.swap_apply [decidable_eq α] [decidable_eq β] {f : α → β}\n  (hf : function.injective f) (x y z : α) :\n  equiv.swap (f x) (f y) (f z) = f (equiv.swap x y z) :=\nbegin\n  by_cases hx : z = x, by simp [hx],\n  by_cases hy : z = y, by simp [hy],\n  rw [equiv.swap_apply_of_ne_of_ne hx hy, equiv.swap_apply_of_ne_of_ne (hf.ne hx) (hf.ne hy)]\nend\n\nlemma function.injective.swap_comp [decidable_eq α] [decidable_eq β] {f : α → β}\n  (hf : function.injective f) (x y : α) :\n  equiv.swap (f x) (f y) ∘ f = f ∘ equiv.swap x y :=\nfunext $ λ z, hf.swap_apply _ _ _\n\n/-- If `α` is a subsingleton, then it is equivalent to `α × α`. -/\ndef subsingleton_prod_self_equiv {α : Type*} [subsingleton α] : α × α ≃ α :=\n{ to_fun := λ p, p.1,\n  inv_fun := λ a, (a, a),\n  left_inv := λ p, subsingleton.elim _ _,\n  right_inv := λ p, subsingleton.elim _ _, }\n\n/-- To give an equivalence between two subsingleton types, it is sufficient to give any two\n    functions between them. -/\ndef equiv_of_subsingleton_of_subsingleton [subsingleton α] [subsingleton β]\n  (f : α → β) (g : β → α) : α ≃ β :=\n{ to_fun := f,\n  inv_fun := g,\n  left_inv := λ _, subsingleton.elim _ _,\n  right_inv := λ _, subsingleton.elim _ _ }\n\n/-- A nonempty subsingleton type is (noncomputably) equivalent to `punit`. -/\nnoncomputable\ndef equiv.punit_of_nonempty_of_subsingleton {α : Sort*} [h : nonempty α] [subsingleton α] :\n  α ≃ punit.{v} :=\nequiv_of_subsingleton_of_subsingleton\n (λ _, punit.star) (λ _, h.some)\n\n/-- `unique (unique α)` is equivalent to `unique α`. -/\ndef unique_unique_equiv : unique (unique α) ≃ unique α :=\nequiv_of_subsingleton_of_subsingleton (λ h, h.default)\n  (λ h, { default := h, uniq := λ _, subsingleton.elim _ _ })\n\nnamespace function\n\nlemma update_comp_equiv {α β α' : Sort*} [decidable_eq α'] [decidable_eq α] (f : α → β) (g : α' ≃ α)\n  (a : α) (v : β) :\n  update f a v ∘ g = update (f ∘ g) (g.symm a) v :=\nby rw [← update_comp_eq_of_injective _ g.injective, g.apply_symm_apply]\n\nlemma update_apply_equiv_apply {α β α' : Sort*} [decidable_eq α'] [decidable_eq α]\n  (f : α → β) (g : α' ≃ α) (a : α) (v : β) (a' : α') :\n  update f a v (g a') = update (f ∘ g) (g.symm a) v a' :=\ncongr_fun (update_comp_equiv f g a v) a'\n\nlemma Pi_congr_left'_update [decidable_eq α] [decidable_eq β]\n  (P : α → Sort*) (e : α ≃ β) (f : Π a, P a) (b : β) (x : P (e.symm b)) :\n  e.Pi_congr_left' P (update f (e.symm b) x) = update (e.Pi_congr_left' P f) b x :=\nbegin\n  ext b',\n  rcases eq_or_ne b' b with rfl | h,\n  { simp, },\n  { simp [h], },\nend\n\nlemma Pi_congr_left'_symm_update [decidable_eq α] [decidable_eq β]\n  (P : α → Sort*) (e : α ≃ β) (f : Π b, P (e.symm b)) (b : β) (x : P (e.symm b)) :\n  (e.Pi_congr_left' P).symm (update f b x) = update ((e.Pi_congr_left' P).symm f) (e.symm b) x :=\nby simp [(e.Pi_congr_left' P).symm_apply_eq, Pi_congr_left'_update]\n\nend function\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/logic/equiv/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.49109640990851033}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.pempty\nimport category_theory.limits.has_limits\nimport category_theory.epi_mono\nimport category_theory.category.preorder\n\n/-!\n# Initial and terminal objects in a category.\n\n## References\n* [Stacks: Initial and final objects](https://stacks.math.columbia.edu/tag/002B)\n-/\n\nnoncomputable theory\n\nuniverses v u u₂\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables {C : Type u} [category.{v} C]\n\n/-- Construct a cone for the empty diagram given an object. -/\n@[simps] def as_empty_cone (X : C) : cone (functor.empty C) := { X := X, π := by tidy }\n/-- Construct a cocone for the empty diagram given an object. -/\n@[simps] def as_empty_cocone (X : C) : cocone (functor.empty C) := { X := X, ι := by tidy }\n\n/-- `X` is terminal if the cone it induces on the empty diagram is limiting. -/\nabbreviation is_terminal (X : C) := is_limit (as_empty_cone X)\n/-- `X` is initial if the cocone it induces on the empty diagram is colimiting. -/\nabbreviation is_initial (X : C) := is_colimit (as_empty_cocone X)\n\n/-- An object `Y` is terminal if for every `X` there is a unique morphism `X ⟶ Y`. -/\ndef is_terminal.of_unique (Y : C) [h : Π X : C, unique (X ⟶ Y)] : is_terminal Y :=\n{ lift := λ s, (h s.X).default }\n\n/-- If `α` is a preorder with top, then `⊤` is a terminal object. -/\ndef is_terminal_top {α : Type*} [preorder α] [order_top α] : is_terminal (⊤ : α) :=\nis_terminal.of_unique _\n\n/-- Transport a term of type `is_terminal` across an isomorphism. -/\ndef is_terminal.of_iso {Y Z : C} (hY : is_terminal Y) (i : Y ≅ Z) : is_terminal Z :=\nis_limit.of_iso_limit hY\n{ hom := { hom := i.hom },\n  inv := { hom := i.symm.hom } }\n\n/-- An object `X` is initial if for every `Y` there is a unique morphism `X ⟶ Y`. -/\ndef is_initial.of_unique (X : C) [h : Π Y : C, unique (X ⟶ Y)] : is_initial X :=\n{ desc := λ s, (h s.X).default }\n\n/-- If `α` is a preorder with bot, then `⊥` is an initial object. -/\ndef is_initial_bot {α : Type*} [preorder α] [order_bot α] : is_initial (⊥ : α) :=\nis_initial.of_unique _\n\n/-- Transport a term of type `is_initial` across an isomorphism. -/\ndef is_initial.of_iso {X Y : C} (hX : is_initial X) (i : X ≅ Y) : is_initial Y :=\nis_colimit.of_iso_colimit hX\n{ hom := { hom := i.hom },\n  inv := { hom := i.symm.hom } }\n\n/-- Give the morphism to a terminal object from any other. -/\ndef is_terminal.from {X : C} (t : is_terminal X) (Y : C) : Y ⟶ X :=\nt.lift (as_empty_cone Y)\n\n/-- Any two morphisms to a terminal object are equal. -/\nlemma is_terminal.hom_ext {X Y : C} (t : is_terminal X) (f g : Y ⟶ X) : f = g :=\nt.hom_ext (by tidy)\n\n@[simp] lemma is_terminal.comp_from {Z : C} (t : is_terminal Z) {X Y : C} (f : X ⟶ Y) :\n  f ≫ t.from Y = t.from X :=\nt.hom_ext _ _\n\n@[simp] lemma is_terminal.from_self {X : C} (t : is_terminal X) : t.from X = 𝟙 X :=\nt.hom_ext _ _\n\n/-- Give the morphism from an initial object to any other. -/\ndef is_initial.to {X : C} (t : is_initial X) (Y : C) : X ⟶ Y :=\nt.desc (as_empty_cocone Y)\n\n/-- Any two morphisms from an initial object are equal. -/\nlemma is_initial.hom_ext {X Y : C} (t : is_initial X) (f g : X ⟶ Y) : f = g :=\nt.hom_ext (by tidy)\n\n@[simp] lemma is_initial.to_comp {X : C} (t : is_initial X) {Y Z : C} (f : Y ⟶ Z) :\n  t.to Y ≫ f = t.to Z :=\nt.hom_ext _ _\n\n@[simp] lemma is_initial.to_self {X : C} (t : is_initial X) : t.to X = 𝟙 X :=\nt.hom_ext _ _\n\n/-- Any morphism from a terminal object is split mono. -/\ndef is_terminal.split_mono_from {X Y : C} (t : is_terminal X) (f : X ⟶ Y) : split_mono f :=\n⟨t.from _, t.hom_ext _ _⟩\n\n/-- Any morphism to an initial object is split epi. -/\ndef is_initial.split_epi_to {X Y : C} (t : is_initial X) (f : Y ⟶ X) : split_epi f :=\n⟨t.to _, t.hom_ext _ _⟩\n\n/-- Any morphism from a terminal object is mono. -/\nlemma is_terminal.mono_from {X Y : C} (t : is_terminal X) (f : X ⟶ Y) : mono f :=\nby haveI := t.split_mono_from f; apply_instance\n\n/-- Any morphism to an initial object is epi. -/\nlemma is_initial.epi_to {X Y : C} (t : is_initial X) (f : Y ⟶ X) : epi f :=\nby haveI := t.split_epi_to f; apply_instance\n\n/-- If `T` and `T'` are terminal, they are isomorphic. -/\n@[simps]\ndef is_terminal.unique_up_to_iso {T T' : C} (hT : is_terminal T) (hT' : is_terminal T') : T ≅ T' :=\n{ hom := hT'.from _,\n  inv := hT.from _ }\n\n/-- If `I` and `I'` are initial, they are isomorphic. -/\n@[simps]\ndef is_initial.unique_up_to_iso {I I' : C} (hI : is_initial I) (hI' : is_initial I') : I ≅ I' :=\n{ hom := hI.to _,\n  inv := hI'.to _ }\n\nvariable (C)\n\n/--\nA category has a terminal object if it has a limit over the empty diagram.\nUse `has_terminal_of_unique` to construct instances.\n-/\nabbreviation has_terminal := has_limits_of_shape (discrete pempty : Type v) C\n/--\nA category has an initial object if it has a colimit over the empty diagram.\nUse `has_initial_of_unique` to construct instances.\n-/\nabbreviation has_initial := has_colimits_of_shape (discrete pempty : Type v) C\n\n/--\nAn arbitrary choice of terminal object, if one exists.\nYou can use the notation `⊤_ C`.\nThis object is characterized by having a unique morphism from any object.\n-/\nabbreviation terminal [has_terminal C] : C := limit (functor.empty C)\n/--\nAn arbitrary choice of initial object, if one exists.\nYou can use the notation `⊥_ C`.\nThis object is characterized by having a unique morphism to any object.\n-/\nabbreviation initial [has_initial C] : C := colimit (functor.empty C)\n\nnotation `⊤_ ` C:20 := terminal C\nnotation `⊥_ ` C:20 := initial C\n\nsection\nvariables {C}\n\n/-- We can more explicitly show that a category has a terminal object by specifying the object,\nand showing there is a unique morphism to it from any other object. -/\nlemma has_terminal_of_unique (X : C) [h : Π Y : C, unique (Y ⟶ X)] : has_terminal C :=\n{ has_limit := λ F, has_limit.mk\n  { cone     := { X := X, π := { app := pempty.rec _ } },\n    is_limit := { lift := λ s, (h s.X).default } } }\n\n/-- We can more explicitly show that a category has an initial object by specifying the object,\nand showing there is a unique morphism from it to any other object. -/\nlemma has_initial_of_unique (X : C) [h : Π Y : C, unique (X ⟶ Y)] : has_initial C :=\n{ has_colimit := λ F, has_colimit.mk\n  { cocone     := { X := X, ι := { app := pempty.rec _ } },\n    is_colimit := { desc := λ s, (h s.X).default } } }\n\n/-- The map from an object to the terminal object. -/\nabbreviation terminal.from [has_terminal C] (P : C) : P ⟶ ⊤_ C :=\nlimit.lift (functor.empty C) (as_empty_cone P)\n/-- The map to an object from the initial object. -/\nabbreviation initial.to [has_initial C] (P : C) : ⊥_ C ⟶ P :=\ncolimit.desc (functor.empty C) (as_empty_cocone P)\n\ninstance unique_to_terminal [has_terminal C] (P : C) : unique (P ⟶ ⊤_ C) :=\n{ default := terminal.from P,\n  uniq := λ m, by { apply limit.hom_ext, rintro ⟨⟩ } }\n\ninstance unique_from_initial [has_initial C] (P : C) : unique (⊥_ C ⟶ P) :=\n{ default := initial.to P,\n  uniq := λ m, by { apply colimit.hom_ext, rintro ⟨⟩ } }\n\n@[simp] lemma terminal.comp_from [has_terminal C] {P Q : C} (f : P ⟶ Q) :\n  f ≫ terminal.from Q = terminal.from P :=\nby tidy\n@[simp] lemma initial.to_comp [has_initial C] {P Q : C} (f : P ⟶ Q) :\n  initial.to P ≫ f = initial.to Q :=\nby tidy\n\n/-- A terminal object is terminal. -/\ndef terminal_is_terminal [has_terminal C] : is_terminal (⊤_ C) :=\n{ lift := λ s, terminal.from _ }\n\n/-- An initial object is initial. -/\ndef initial_is_initial [has_initial C] : is_initial (⊥_ C) :=\n{ desc := λ s, initial.to _ }\n\n/-- Any morphism from a terminal object is split mono. -/\ninstance terminal.split_mono_from {Y : C} [has_terminal C] (f : ⊤_ C ⟶ Y) : split_mono f :=\nis_terminal.split_mono_from terminal_is_terminal _\n\n/-- Any morphism to an initial object is split epi. -/\ninstance initial.split_epi_to {Y : C} [has_initial C] (f : Y ⟶ ⊥_ C) : split_epi f :=\nis_initial.split_epi_to initial_is_initial _\n\n/-- An initial object is terminal in the opposite category. -/\ndef terminal_op_of_initial {X : C} (t : is_initial X) : is_terminal (opposite.op X) :=\n{ lift := λ s, (t.to s.X.unop).op,\n  uniq' := λ s m w, quiver.hom.unop_inj (t.hom_ext _ _) }\n\n/-- An initial object in the opposite category is terminal in the original category. -/\ndef terminal_unop_of_initial {X : Cᵒᵖ} (t : is_initial X) : is_terminal X.unop :=\n{ lift := λ s, (t.to (opposite.op s.X)).unop,\n  uniq' := λ s m w, quiver.hom.op_inj (t.hom_ext _ _) }\n\n/-- A terminal object is initial in the opposite category. -/\ndef initial_op_of_terminal {X : C} (t : is_terminal X) : is_initial (opposite.op X) :=\n{ desc := λ s, (t.from s.X.unop).op,\n  uniq' := λ s m w, quiver.hom.unop_inj (t.hom_ext _ _) }\n\n/-- A terminal object in the opposite category is initial in the original category. -/\ndef initial_unop_of_terminal {X : Cᵒᵖ} (t : is_terminal X) : is_initial X.unop :=\n{ desc := λ s, (t.from (opposite.op s.X)).unop,\n  uniq' := λ s m w, quiver.hom.op_inj (t.hom_ext _ _) }\n\n/-- A category is a `initial_mono_class` if the canonical morphism of an initial object is a\nmonomorphism.  In practice, this is most useful when given an arbitrary morphism out of the chosen\ninitial object, see `initial.mono_from`.\nGiven a terminal object, this is equivalent to the assumption that the unique morphism from initial\nto terminal is a monomorphism, which is the second of Freyd's axioms for an AT category.\n\nTODO: This is a condition satisfied by categories with zero objects and morphisms.\n-/\nclass initial_mono_class (C : Type u) [category.{v} C] : Prop :=\n(is_initial_mono_from : ∀ {I} (X : C) (hI : is_initial I), mono (hI.to X))\n\nlemma is_initial.mono_from [initial_mono_class C] {I} {X : C} (hI : is_initial I) (f : I ⟶ X) :\n  mono f :=\nbegin\n  rw hI.hom_ext f (hI.to X),\n  apply initial_mono_class.is_initial_mono_from,\nend\n\n@[priority 100]\ninstance initial.mono_from [has_initial C] [initial_mono_class C] (X : C) (f : ⊥_ C ⟶ X) :\n  mono f :=\ninitial_is_initial.mono_from f\n\n/-- To show a category is a `initial_mono_class` it suffices to give an initial object such that\nevery morphism out of it is a monomorphism. -/\nlemma initial_mono_class.of_is_initial {I : C} (hI : is_initial I) (h : ∀ X, mono (hI.to X)) :\n  initial_mono_class C :=\n{ is_initial_mono_from := λ I' X hI',\n  begin\n    rw hI'.hom_ext (hI'.to X) ((hI'.unique_up_to_iso hI).hom ≫ hI.to X),\n    apply mono_comp,\n  end }\n\n/-- To show a category is a `initial_mono_class` it suffices to show every morphism out of the\ninitial object is a monomorphism. -/\nlemma initial_mono_class.of_initial [has_initial C] (h : ∀ X : C, mono (initial.to X)) :\n  initial_mono_class C :=\ninitial_mono_class.of_is_initial initial_is_initial h\n\n/-- To show a category is a `initial_mono_class` it suffices to show the unique morphism from an\ninitial object to a terminal object is a monomorphism. -/\nlemma initial_mono_class.of_is_terminal {I T : C} (hI : is_initial I) (hT : is_terminal T)\n  (f : mono (hI.to T)) :\n  initial_mono_class C :=\ninitial_mono_class.of_is_initial hI (λ X, mono_of_mono_fac (hI.hom_ext (_ ≫ hT.from X) (hI.to T)))\n\n/-- To show a category is a `initial_mono_class` it suffices to show the unique morphism from the\ninitial object to a terminal object is a monomorphism. -/\nlemma initial_mono_class.of_terminal [has_initial C] [has_terminal C]\n  (h : mono (initial.to (⊤_ C))) :\n  initial_mono_class C :=\ninitial_mono_class.of_is_terminal initial_is_initial terminal_is_terminal h\n\nsection comparison\nvariables {D : Type u₂} [category.{v} D] (G : C ⥤ D)\n\n/--\nThe comparison morphism from the image of a terminal object to the terminal object in the target\ncategory.\nThis is an isomorphism iff `G` preserves terminal objects, see\n`category_theory.limits.preserves_terminal.of_iso_comparison`.\n-/\ndef terminal_comparison [has_terminal C] [has_terminal D] :\n  G.obj (⊤_ C) ⟶ ⊤_ D :=\nterminal.from _\n\n/--\nThe comparison morphism from the initial object in the target category to the image of the initial\nobject.\n-/\n-- TODO: Show this is an isomorphism if and only if `G` preserves initial objects.\ndef initial_comparison [has_initial C] [has_initial D] :\n  ⊥_ D ⟶ G.obj (⊥_ C) :=\ninitial.to _\n\nend comparison\n\nvariables {J : Type v} [small_category J]\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J`, construct a cone for `J`.\nIn `limit_of_diagram_initial` we show it is a limit cone. -/\n@[simps]\ndef cone_of_diagram_initial\n  {X : J} (tX : is_initial X) (F : J ⥤ C) : cone F :=\n{ X := F.obj X,\n  π :=\n  { app := λ j, F.map (tX.to j),\n    naturality' := λ j j' k,\n    begin\n      dsimp,\n      rw [← F.map_comp, category.id_comp, tX.hom_ext (tX.to j ≫ k) (tX.to j')],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J`, show the cone\n`cone_of_diagram_initial` is a limit. -/\ndef limit_of_diagram_initial\n  {X : J} (tX : is_initial X) (F : J ⥤ C) :\nis_limit (cone_of_diagram_initial tX F) :=\n{ lift := λ s, s.π.app X,\n  uniq' := λ s m w,\n    begin\n      rw [← w X, cone_of_diagram_initial_π_app, tX.hom_ext (tX.to X) (𝟙 _)],\n      dsimp, simp -- See note [dsimp, simp]\n    end}\n\n-- This is reducible to allow usage of lemmas about `cone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has an initial object then the image of it is isomorphic\nto the limit of `F`. -/\n@[reducible]\ndef limit_of_initial (F : J ⥤ C)\n  [has_initial J] [has_limit F] :\nlimit F ≅ F.obj (⊥_ J) :=\nis_limit.cone_point_unique_up_to_iso\n  (limit.is_limit _)\n  (limit_of_diagram_initial initial_is_initial F)\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J`, construct a cone for `J`,\nprovided that the morphisms in the diagram are isomorphisms.\nIn `limit_of_diagram_terminal` we show it is a limit cone. -/\n@[simps]\ndef cone_of_diagram_terminal {X : J} (hX : is_terminal X)\n  (F : J ⥤ C) [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : cone F :=\n{ X := F.obj X,\n  π :=\n  { app := λ i, inv (F.map (hX.from _)),\n    naturality' := begin\n      intros i j f,\n      dsimp,\n      simp only [is_iso.eq_inv_comp, is_iso.comp_inv_eq, category.id_comp,\n        ← F.map_comp, hX.hom_ext (hX.from i) (f ≫ hX.from j)],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J` and that the morphisms in the\ndiagram are isomorphisms, show the cone `cone_of_diagram_terminal` is a limit. -/\ndef limit_of_diagram_terminal {X : J} (hX : is_terminal X)\n  (F : J ⥤ C) [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] :\n  is_limit (cone_of_diagram_terminal hX F) :=\n{ lift := λ S, S.π.app _ }\n\n-- This is reducible to allow usage of lemmas about `cone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has a terminal object and all the morphisms in the diagram\nare isomorphisms, then the image of the terminal object is isomorphic to the limit of `F`. -/\n@[reducible]\ndef limit_of_terminal (F : J ⥤ C)\n  [has_terminal J] [has_limit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] :\nlimit F ≅ F.obj (⊤_ J) :=\nis_limit.cone_point_unique_up_to_iso\n  (limit.is_limit _)\n  (limit_of_diagram_terminal terminal_is_terminal F)\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J`, construct a cocone for `J`.\nIn `colimit_of_diagram_terminal` we show it is a colimit cocone. -/\n@[simps]\ndef cocone_of_diagram_terminal\n  {X : J} (tX : is_terminal X) (F : J ⥤ C) : cocone F :=\n{ X := F.obj X,\n  ι :=\n  { app := λ j, F.map (tX.from j),\n    naturality' := λ j j' k,\n    begin\n      dsimp,\n      rw [← F.map_comp, category.comp_id, tX.hom_ext (k ≫ tX.from j') (tX.from j)],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J`, show the cocone\n`cocone_of_diagram_terminal` is a colimit. -/\ndef colimit_of_diagram_terminal\n  {X : J} (tX : is_terminal X) (F : J ⥤ C) :\nis_colimit (cocone_of_diagram_terminal tX F) :=\n{ desc := λ s, s.ι.app X,\n  uniq' := λ s m w,\n    by { rw [← w X, cocone_of_diagram_terminal_ι_app, tX.hom_ext (tX.from X) (𝟙 _)], simp } }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has a terminal object then the image of it is isomorphic\nto the colimit of `F`. -/\n@[reducible]\ndef colimit_of_terminal (F : J ⥤ C)\n  [has_terminal J] [has_colimit F] :\ncolimit F ≅ F.obj (⊤_ J) :=\nis_colimit.cocone_point_unique_up_to_iso\n  (colimit.is_colimit _)\n  (colimit_of_diagram_terminal terminal_is_terminal F)\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J`, construct a cocone for `J`,\nprovided that the morphisms in the diagram are isomorphisms.\nIn `colimit_of_diagram_initial` we show it is a colimit cocone. -/\n@[simps]\ndef cocone_of_diagram_initial {X : J} (hX : is_initial X) (F : J ⥤ C)\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : cocone F :=\n{ X := F.obj X,\n  ι :=\n  { app := λ i, inv (F.map (hX.to _)),\n    naturality' := begin\n      intros i j f,\n      dsimp,\n      simp only [is_iso.eq_inv_comp, is_iso.comp_inv_eq, category.comp_id,\n        ← F.map_comp, hX.hom_ext (hX.to i ≫ f) (hX.to j)],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J` and that the morphisms in the\ndiagram are isomorphisms, show the cone `cocone_of_diagram_initial` is a colimit. -/\ndef colimit_of_diagram_initial {X : J} (hX : is_initial X) (F : J ⥤ C)\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_colimit (cocone_of_diagram_initial hX F) :=\n{ desc := λ S, S.ι.app _ }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has an initial object and all the morphisms in the diagram\nare isomorphisms, then the image of the initial object is isomorphic to the colimit of `F`. -/\n@[reducible]\ndef colimit_of_initial (F : J ⥤ C)\n  [has_initial J] [has_colimit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] :\ncolimit F ≅ F.obj (⊥_ J) :=\nis_colimit.cocone_point_unique_up_to_iso\n  (colimit.is_colimit _)\n  (colimit_of_diagram_initial initial_is_initial _)\n\n/--\nIf `j` is initial in the index category, then the map `limit.π F j` is an isomorphism.\n-/\nlemma is_iso_π_of_is_initial {j : J} (I : is_initial j) (F : J ⥤ C) [has_limit F] :\n  is_iso (limit.π F j) :=\n⟨⟨limit.lift _ (cone_of_diagram_initial I F), ⟨by { ext, simp }, by simp⟩⟩⟩\n\ninstance is_iso_π_initial [has_initial J] (F : J ⥤ C) [has_limit F] :\n  is_iso (limit.π F (⊥_ J)) :=\nis_iso_π_of_is_initial (initial_is_initial) F\n\nlemma is_iso_π_of_is_terminal {j : J} (I : is_terminal j) (F : J ⥤ C)\n  [has_limit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (limit.π F j) :=\n⟨⟨limit.lift _ (cone_of_diagram_terminal I F), by { ext, simp }, by simp ⟩⟩\n\ninstance is_iso_π_terminal [has_terminal J] (F : J ⥤ C) [has_limit F]\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (limit.π F (⊤_ J)) :=\nis_iso_π_of_is_terminal terminal_is_terminal F\n\n/--\nIf `j` is terminal in the index category, then the map `colimit.ι F j` is an isomorphism.\n-/\nlemma is_iso_ι_of_is_terminal {j : J} (I : is_terminal j) (F : J ⥤ C) [has_colimit F] :\n  is_iso (colimit.ι F j) :=\n⟨⟨colimit.desc _ (cocone_of_diagram_terminal I F), ⟨by simp, by { ext, simp }⟩⟩⟩\n\ninstance is_iso_ι_terminal [has_terminal J] (F : J ⥤ C) [has_colimit F] :\n  is_iso (colimit.ι F (⊤_ J)) :=\nis_iso_ι_of_is_terminal (terminal_is_terminal) F\n\nlemma is_iso_ι_of_is_initial {j : J} (I : is_initial j) (F : J ⥤ C)\n  [has_colimit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (colimit.ι F j) :=\n⟨⟨colimit.desc _ (cocone_of_diagram_initial I F), ⟨by tidy, by { ext, simp }⟩⟩⟩\n\ninstance is_iso_ι_initial [has_initial J] (F : J ⥤ C) [has_colimit F]\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (colimit.ι F (⊥_ J)) :=\nis_iso_ι_of_is_initial initial_is_initial F\n\nend\n\nend category_theory.limits\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/limits/shapes/terminal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4910964058894614}}
{"text": "import laurent_measures.basic\nimport laurent_measures.aux_lemmas\nimport analysis.special_functions.pow\nimport laurent_measures.thm69\n\nopen nnreal laurent_measures aux_thm69\nopen_locale nnreal\n\nnoncomputable theory\n\nsection slm\n\n--  This is the same as before, from here to...\n-- parameter {p : ℝ≥0}\n\n/--  This is the same `r` as before. -/\n-- def r : ℝ≥0 := 2⁻¹ ^ (p:ℝ)\n\n-- lemma r_pos : 0 < r :=\n-- suffices 0 < (2 : ℝ≥0)⁻¹ ^ (p : ℝ), by simpa [r],\n-- rpow_pos (nnreal.inv_pos.mpr zero_lt_two)\n\n-- lemma r_lt_one [fact(0 < p)] : r < 1 :=\n-- begin\n--   refine rpow_lt_one zero_le' (half_lt_self one_ne_zero) _,\n--   rw nnreal.coe_pos,\n--   exact fact.out _\n-- end\n\nvariables {r : ℝ≥0} [fact (0 < r)] [fact (r < 1)]\n\nlocal notation `ℒ` := laurent_measures r\n\nvariables {S : Fintype}\n\n-- /--  Let `F : ℒ S` be a Laurent measure.  `laurent_measures.d` chooses a bound `d ∈ ℤ` for `F`,\n-- such that, for all `s : S`, the sequence `F s` is zero from `d-1` and below. -/\n-- def laurent_measures.d (F : ℒ S) : ℤ :=\n-- (exists_bdd_filtration (fact.out _ : 0 < r) (fact.out _ : r < 1) F).some\n\n-- lemma lt_d_eq_zero (F : ℒ S) (s : S) (n : ℤ) :\n--   n < F.d → F s n = 0 :=\n-- (exists_bdd_filtration (fact.out _ : 0 < r) (fact.out _ : r < 1) F).some_spec s n\n--  ... here!\n\n\nsection new_stuff\n/--  Simpler Laurent measures? -/\nstructure slm (r : ℝ≥0) (S : Fintype) :=\n(to_fun    : S → ℤ → ℤ)\n(d         : ℤ)\n(summable' : ∀ s, summable (λ n : ℕ, ∥to_fun s n∥₊ * r ^ n))\n(zero_lt_d : ∀ s n, n < d → to_fun s n = 0)\n\n/--  A \"usual\" Laurent Measure `F : ℒ S` gives rise to a Simple Laurent Measure of type `slm S`. -/\ndef _root_.laurent_measures.to_slm (F : ℒ S) : slm r S :=\n{ to_fun    := F.to_fun,\n  d         := F.d,\n  zero_lt_d := λ n s, lt_d_eq_zero F _ _,\n  summable' := begin\n    refine λ s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (λ (n : ℤ), ∥F.to_fun s n∥ * r ^ n)).mp _).1,\n    exact summable_coe.mpr (F.summable' s)\n  end }\n\n/--  A Simple Laurent Measure `F : slm S` \"usual\" Laurent Measure of type `ℒ S`. -/\n--  The \"main\" input is `int_summable_iff`, proving that a series over `ℤ` is summable if and only\n--  if both its restrictions to `ℕ` and to \"`-ℕ`\" are summable.\ndef slm.to_laurent_measures {r : ℝ≥0} (F : slm r S) : laurent_measures r S :=\n{ to_fun := F.to_fun,\n  summable' := begin\n    refine λ s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (λ (n : ℤ), ∥F.to_fun s n∥ * r ^ n)).mpr _),\n    refine ⟨_, summable_of_eventually_zero (λ (n : ℤ), ∥F.to_fun s n∥ * ↑r ^ n) F.d (λ n nd, _)⟩,\n    { convert summable_coe.mpr (F.summable' s), },\n    { simp [F.zero_lt_d s n nd] }\n  end }\n\nlemma slm_lm_to_fun_eq {r : ℝ≥0} (F : slm r S) : F.to_fun = F.to_laurent_measures.to_fun := rfl\n\nlemma lm_slm_to_fun_eq (F : ℒ S) : F.to_fun = F.to_slm.to_fun := rfl\n\nend new_stuff\n\nend slm\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/laurent_measures/simpler_laurent_measures.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4910459805148371}}
{"text": "theorem subtype_inj (A: Type) (p: A → Prop) (a b: A) (pa: p a) (pb: p b) : (⟨a, pa⟩: {a//p a}) = (⟨b, pb⟩: {b//p b}) → a = b := by\n  intro eq\n  injection eq\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/subtype_inj.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342623, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4910459747540053}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport data.set.basic\nimport tactic.monotonicity.basic\n\n/-!\n# Typeclass for types with a set-like extensionality property\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe `has_mem` typeclass is used to let terms of a type have elements.\nMany instances of `has_mem` have a set-like extensionality property:\nthings are equal iff they have the same elements.  The `set_like`\ntypeclass provides a unified interface to define a `has_mem` that is\nextensional in this way.\n\nThe main use of `set_like` is for algebraic subobjects (such as\n`submonoid` and `submodule`), whose non-proof data consists only of a\ncarrier set.  In such a situation, the projection to the carrier set\nis injective.\n\nIn general, a type `A` is `set_like` with elements of type `B` if it\nhas an injective map to `set B`.  This module provides standard\nboilerplate for every `set_like`: a `coe_sort`, a `coe` to set, a\n`partial_order`, and various extensionality and simp lemmas.\n\nA typical subobject should be declared as:\n```\nstructure my_subobject (X : Type*) [object_typeclass X] :=\n(carrier : set X)\n(op_mem' : ∀ {x : X}, x ∈ carrier → sorry ∈ carrier)\n\nnamespace my_subobject\n\nvariables {X : Type*} [object_typeclass X] {x : X}\n\ninstance : set_like (my_subobject X) X :=\n⟨my_subobject.carrier, λ p q h, by cases p; cases q; congr'⟩\n\n@[simp] lemma mem_carrier {p : my_subobject X} : x ∈ p.carrier ↔ x ∈ (p : set X) := iff.rfl\n\n@[ext] theorem ext {p q : my_subobject X} (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := set_like.ext h\n\n/-- Copy of a `my_subobject` with a new `carrier` equal to the old one. Useful to fix definitional\nequalities. See Note [range copy pattern]. -/\nprotected def copy (p : my_subobject X) (s : set X) (hs : s = ↑p) : my_subobject X :=\n{ carrier := s,\n  op_mem' := hs.symm ▸ p.op_mem' }\n\n@[simp] lemma coe_copy (p : my_subobject X) (s : set X) (hs : s = ↑p) :\n  (p.copy s hs : set X) = s := rfl\n\nlemma copy_eq (p : my_subobject X) (s : set X) (hs : s = ↑p) : p.copy s hs = p :=\nset_like.coe_injective hs\n\nend my_subobject\n```\n\nAn alternative to `set_like` could have been an extensional `has_mem` typeclass:\n```\nclass has_ext_mem (α : out_param $ Type u) (β : Type v) extends has_mem α β :=\n(ext_iff : ∀ {s t : β}, s = t ↔ ∀ (x : α), x ∈ s ↔ x ∈ t)\n```\nWhile this is equivalent, `set_like` conveniently uses a carrier set projection directly.\n\n## Tags\n\nsubobjects\n-/\n\n/-- A class to indicate that there is a canonical injection between `A` and `set B`.\n\nThis has the effect of giving terms of `A` elements of type `B` (through a `has_mem`\ninstance) and a compatible coercion to `Type*` as a subtype.\n\nNote: if `set_like.coe` is a projection, implementers should create a simp lemma such as\n```\n@[simp] lemma mem_carrier {p : my_subobject X} : x ∈ p.carrier ↔ x ∈ (p : set X) := iff.rfl\n```\nto normalize terms.\n\nIf you declare an unbundled subclass of `set_like`, for example:\n```\nclass mul_mem_class (S : Type*) (M : Type*) [has_mul M] [set_like S M] where\n  ...\n```\nThen you should *not* repeat the `out_param` declaration, `set_like` will supply the value instead.\nThis ensures in Lean 4 your subclass will not have issues with synthesis of the `[has_mul M]`\nparameter starting before the value of `M` is known.\n-/\n@[protect_proj]\nclass set_like (A : Type*) (B : out_param $ Type*) :=\n(coe : A → set B)\n(coe_injective' : function.injective coe)\n\nnamespace set_like\n\nvariables {A : Type*} {B : Type*} [i : set_like A B]\n\ninclude i\n\ninstance : has_coe_t A (set B) := ⟨set_like.coe⟩\n\n@[priority 100]\ninstance : has_mem B A := ⟨λ x p, x ∈ (p : set B)⟩\n\n-- `dangerous_instance` does not know that `B` is used only as an `out_param`\n@[nolint dangerous_instance, priority 100]\ninstance : has_coe_to_sort A Type* := ⟨λ p, {x : B // x ∈ p}⟩\n\nvariables (p q : A)\n\n@[simp, norm_cast] theorem coe_sort_coe : ((p : set B) : Type*) = p := rfl\n\nvariables {p q}\n\nprotected theorem «exists» {q : p → Prop} :\n  (∃ x, q x) ↔ (∃ x ∈ p, q ⟨x, ‹_›⟩) := set_coe.exists\n\nprotected theorem «forall» {q : p → Prop} :\n  (∀ x, q x) ↔ (∀ x ∈ p, q ⟨x, ‹_›⟩) := set_coe.forall\n\ntheorem coe_injective : function.injective (coe : A → set B) :=\nλ x y h, set_like.coe_injective' h\n\n@[simp, norm_cast] \n\ntheorem ext' (h : (p : set B) = q) : p = q := coe_injective h\n\ntheorem ext'_iff : p = q ↔ (p : set B) = q := coe_set_eq.symm\n\n/-- Note: implementers of `set_like` must copy this lemma in order to tag it with `@[ext]`. -/\ntheorem ext (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := coe_injective $ set.ext h\n\ntheorem ext_iff : p = q ↔ (∀ x, x ∈ p ↔ x ∈ q) := coe_injective.eq_iff.symm.trans set.ext_iff\n\n@[simp] theorem mem_coe {x : B} : x ∈ (p : set B) ↔ x ∈ p := iff.rfl\n\n@[simp, norm_cast] lemma coe_eq_coe {x y : p} : (x : B) = y ↔ x = y := subtype.ext_iff_val.symm\n\n@[simp, norm_cast] lemma coe_mk (x : B) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : B) = x := rfl\n@[simp] lemma coe_mem (x : p) : (x : B) ∈ p := x.2\n\n@[simp] protected lemma eta (x : p) (hx : (x : B) ∈ p) : (⟨x, hx⟩ : p) = x := subtype.eta x hx\n\n-- `dangerous_instance` does not know that `B` is used only as an `out_param`\n@[nolint dangerous_instance, priority 100]\ninstance : partial_order A :=\n{ le := λ H K, ∀ ⦃x⦄, x ∈ H → x ∈ K,\n  .. partial_order.lift (coe : A → set B) coe_injective }\n\nlemma le_def {S T : A} : S ≤ T ↔ ∀ ⦃x : B⦄, x ∈ S → x ∈ T := iff.rfl\n\n@[simp, norm_cast]\nlemma coe_subset_coe {S T : A} : (S : set B) ⊆ T ↔ S ≤ T := iff.rfl\n\n@[mono] lemma coe_mono : monotone (coe : A → set B) := λ a b, coe_subset_coe.mpr\n\n@[simp, norm_cast]\nlemma coe_ssubset_coe {S T : A} : (S : set B) ⊂ T ↔ S < T := iff.rfl\n\n@[mono] lemma coe_strict_mono : strict_mono (coe : A → set B) := λ a b, coe_ssubset_coe.mpr\n\nlemma not_le_iff_exists : ¬(p ≤ q) ↔ ∃ x ∈ p, x ∉ q := set.not_subset\n\nlemma exists_of_lt : p < q → ∃ x ∈ q, x ∉ p := set.exists_of_ssubset\n\nlemma lt_iff_le_and_exists : p < q ↔ p ≤ q ∧ ∃ x ∈ q, x ∉ p :=\nby rw [lt_iff_le_not_le, not_le_iff_exists]\n\nend set_like\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/set_like/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.49103806998769794}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport tactic.lint\nimport tactic.ext\n\n/-!\n# Sigma types\n\nThis file proves basic results about sigma types.\n\nA sigma type is a dependent pair type. Like `α × β` but where the type of the second component\ndepends on the first component. This can be seen as a generalization of the sum type `α ⊕ β`:\n* `α ⊕ β` is made of stuff which is either of type `α` or `β`.\n* Given `α : ι → Type*`, `sigma α` is made of stuff which is of type `α i` for some `i : ι`. One\n  effectively recovers a type isomorphic to `α ⊕ β` by taking a `ι` with exactly two elements. See\n  `equiv.sum_equiv_sigma_bool`.\n\n`Σ x, A x` is notation for `sigma A` (note the difference with the big operator `∑`).\n`Σ x y z ..., A x y z ...` is notation for `Σ x, Σ y, Σ z, ..., A x y z ...`. Here we have\n`α : Type*`, `β : α → Type*`, `γ : Π a : α, β a → Type*`, ...,\n`A : Π (a : α) (b : β a) (c : γ a b) ..., Type*`  with `x : α` `y : β x`, `z : γ x y`, ...\n\n## Notes\n\nThe definition of `sigma` takes values in `Type*`. This effectively forbids `Prop`- valued sigma\ntypes. To that effect, we have `psigma`, which takes value in `Sort*` and carries a more complicated\nuniverse signature in consequence.\n-/\n\nsection sigma\nvariables {α α₁ α₂ : Type*} {β : α → Type*} {β₁ : α₁ → Type*} {β₂ : α₂ → Type*}\n\nnamespace sigma\n\ninstance [inhabited α] [inhabited (β default)] : inhabited (sigma β) :=\n⟨⟨default, default⟩⟩\n\ninstance [h₁ : decidable_eq α] [h₂ : ∀a, decidable_eq (β a)] : decidable_eq (sigma β)\n| ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ := match a₁, b₁, a₂, b₂, h₁ a₁ a₂ with\n  | _, b₁, _, b₂, is_true (eq.refl a) :=\n    match b₁, b₂, h₂ a b₁ b₂ with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b₁, b₂, is_false n := is_false (assume h, sigma.no_confusion h (λe₁ e₂, n $ eq_of_heq e₂))\n    end\n  | a₁, _, a₂, _, is_false n := is_false (assume h, sigma.no_confusion h (λe₁ e₂, n e₁))\n  end\n\n@[simp, nolint simp_nf] -- sometimes the built-in injectivity support does not work\ntheorem mk.inj_iff {a₁ a₂ : α} {b₁ : β a₁} {b₂ : β a₂} :\n  sigma.mk a₁ b₁ = ⟨a₂, b₂⟩ ↔ (a₁ = a₂ ∧ b₁ == b₂) :=\nby simp\n\n@[simp] theorem eta : ∀ x : Σ a, β a, sigma.mk x.1 x.2 = x\n| ⟨i, x⟩ := rfl\n\n@[ext]\nlemma ext {x₀ x₁ : sigma β} (h₀ : x₀.1 = x₁.1) (h₁ : x₀.2 == x₁.2) : x₀ = x₁ :=\nby { cases x₀, cases x₁, cases h₀, cases h₁, refl }\n\nlemma ext_iff {x₀ x₁ : sigma β} : x₀ = x₁ ↔ x₀.1 = x₁.1 ∧ x₀.2 == x₁.2 :=\nby { cases x₀, cases x₁, exact sigma.mk.inj_iff }\n\n/-- A specialized ext lemma for equality of sigma types over an indexed subtype. -/\n@[ext]\nlemma subtype_ext {β : Type*} {p : α → β → Prop} :\n  ∀ {x₀ x₁ : Σ a, subtype (p a)}, x₀.fst = x₁.fst → (x₀.snd : β) = x₁.snd → x₀ = x₁\n| ⟨a₀, b₀, hb₀⟩ ⟨a₁, b₁, hb₁⟩ rfl rfl := rfl\n\nlemma subtype_ext_iff {β : Type*} {p : α → β → Prop} {x₀ x₁ : Σ a, subtype (p a)} :\n  x₀ = x₁ ↔ x₀.fst = x₁.fst ∧ (x₀.snd : β) = x₁.snd :=\n⟨λ h, h ▸ ⟨rfl, rfl⟩, λ ⟨h₁, h₂⟩, subtype_ext h₁ h₂⟩\n\n@[simp] theorem «forall» {p : (Σ a, β a) → Prop} :\n  (∀ x, p x) ↔ (∀ a b, p ⟨a, b⟩) :=\n⟨assume h a b, h ⟨a, b⟩, assume h ⟨a, b⟩, h a b⟩\n\n@[simp] theorem «exists» {p : (Σ a, β a) → Prop} :\n  (∃ x, p x) ↔ (∃ a b, p ⟨a, b⟩) :=\n⟨assume ⟨⟨a, b⟩, h⟩, ⟨a, b, h⟩, assume ⟨a, b, h⟩, ⟨⟨a, b⟩, h⟩⟩\n\n/-- Map the left and right components of a sigma -/\ndef map (f₁ : α₁ → α₂) (f₂ : Πa, β₁ a → β₂ (f₁ a)) (x : sigma β₁) : sigma β₂ :=\n⟨f₁ x.1, f₂ x.1 x.2⟩\n\nend sigma\n\nlemma sigma_mk_injective {i : α} : function.injective (@sigma.mk α β i)\n| _ _ rfl := rfl\n\nlemma function.injective.sigma_map {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a → β₂ (f₁ a)}\n  (h₁ : function.injective f₁) (h₂ : ∀ a, function.injective (f₂ a)) :\n  function.injective (sigma.map f₁ f₂)\n| ⟨i, x⟩ ⟨j, y⟩ h :=\nbegin\n  have : i = j, from h₁ (sigma.mk.inj_iff.mp h).1,\n  subst j,\n  have : x = y, from h₂ i (eq_of_heq (sigma.mk.inj_iff.mp h).2),\n  subst y\nend\n\nlemma function.surjective.sigma_map {f₁ : α₁ → α₂} {f₂ : Πa, β₁ a → β₂ (f₁ a)}\n  (h₁ : function.surjective f₁) (h₂ : ∀ a, function.surjective (f₂ a)) :\n  function.surjective (sigma.map f₁ f₂) :=\nbegin\n  intros y,\n  cases y with j y,\n  cases h₁ j with i hi,\n  subst j,\n  cases h₂ i y with x hx,\n  subst y,\n  exact ⟨⟨i, x⟩, rfl⟩\nend\n\n/-- Interpret a function on `Σ x : α, β x` as a dependent function with two arguments.\n\nThis also exists as an `equiv` as `equiv.Pi_curry γ`. -/\ndef sigma.curry {γ : Π a, β a → Type*} (f : Π x : sigma β, γ x.1 x.2) (x : α) (y : β x) : γ x y :=\nf ⟨x,y⟩\n\n/-- Interpret a dependent function with two arguments as a function on `Σ x : α, β x`.\n\nThis also exists as an `equiv` as `(equiv.Pi_curry γ).symm`. -/\ndef sigma.uncurry {γ : Π a, β a → Type*} (f : Π x (y : β x), γ x y) (x : sigma β) : γ x.1 x.2 :=\nf x.1 x.2\n\n@[simp]\nlemma sigma.uncurry_curry {γ : Π a, β a → Type*} (f : Π x : sigma β, γ x.1 x.2) :\n  sigma.uncurry (sigma.curry f) = f :=\nfunext $ λ ⟨i, j⟩, rfl\n\n@[simp]\nlemma sigma.curry_uncurry {γ : Π a, β a → Type*} (f : Π x (y : β x), γ x y) :\n  sigma.curry (sigma.uncurry f) = f :=\nrfl\n\n/-- Convert a product type to a Σ-type. -/\n@[simp]\ndef prod.to_sigma {α β} : α × β → Σ _ : α, β\n| ⟨x,y⟩ := ⟨x,y⟩\n\n@[simp]\nlemma prod.fst_to_sigma {α β} (x : α × β) : (prod.to_sigma x).fst = x.fst :=\nby cases x; refl\n\n@[simp]\nlemma prod.snd_to_sigma {α β} (x : α × β) : (prod.to_sigma x).snd = x.snd :=\nby cases x; refl\n\nend sigma\n\nsection psigma\nvariables {α : Sort*} {β : α → Sort*}\n\nnamespace psigma\n\n/-- Nondependent eliminator for `psigma`. -/\ndef elim {γ} (f : ∀ a, β a → γ) (a : psigma β) : γ :=\npsigma.cases_on a f\n\n@[simp] theorem elim_val {γ} (f : ∀ a, β a → γ) (a b) : psigma.elim f ⟨a, b⟩ = f a b := rfl\n\ninstance [inhabited α] [inhabited (β default)] : inhabited (psigma β) :=\n⟨⟨default, default⟩⟩\n\ninstance [h₁ : decidable_eq α] [h₂ : ∀a, decidable_eq (β a)] : decidable_eq (psigma β)\n| ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ := match a₁, b₁, a₂, b₂, h₁ a₁ a₂ with\n  | _, b₁, _, b₂, is_true (eq.refl a) :=\n    match b₁, b₂, h₂ a b₁ b₂ with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b₁, b₂, is_false n := is_false (assume h, psigma.no_confusion h (λe₁ e₂, n $ eq_of_heq e₂))\n    end\n  | a₁, _, a₂, _, is_false n := is_false (assume h, psigma.no_confusion h (λe₁ e₂, n e₁))\n  end\n\ntheorem mk.inj_iff {a₁ a₂ : α} {b₁ : β a₁} {b₂ : β a₂} :\n  @psigma.mk α β a₁ b₁ = @psigma.mk α β a₂ b₂ ↔ (a₁ = a₂ ∧ b₁ == b₂) :=\niff.intro psigma.mk.inj $\n  assume ⟨h₁, h₂⟩, match a₁, a₂, b₁, b₂, h₁, h₂ with _, _, _, _, eq.refl a, heq.refl b := rfl end\n\n@[ext]\nlemma ext {x₀ x₁ : psigma β} (h₀ : x₀.1 = x₁.1) (h₁ : x₀.2 == x₁.2) : x₀ = x₁ :=\nby { cases x₀, cases x₁, cases h₀, cases h₁, refl }\n\nlemma ext_iff {x₀ x₁ : psigma β} : x₀ = x₁ ↔ x₀.1 = x₁.1 ∧ x₀.2 == x₁.2 :=\nby { cases x₀, cases x₁, exact psigma.mk.inj_iff }\n\n/-- A specialized ext lemma for equality of psigma types over an indexed subtype. -/\n@[ext]\nlemma subtype_ext {β : Sort*} {p : α → β → Prop} :\n  ∀ {x₀ x₁ : Σ' a, subtype (p a)}, x₀.fst = x₁.fst → (x₀.snd : β) = x₁.snd → x₀ = x₁\n| ⟨a₀, b₀, hb₀⟩ ⟨a₁, b₁, hb₁⟩ rfl rfl := rfl\n\nlemma subtype_ext_iff {β : Sort*} {p : α → β → Prop} {x₀ x₁ : Σ' a, subtype (p a)} :\n  x₀ = x₁ ↔ x₀.fst = x₁.fst ∧ (x₀.snd : β) = x₁.snd :=\n⟨λ h, h ▸ ⟨rfl, rfl⟩, λ ⟨h₁, h₂⟩, subtype_ext h₁ h₂⟩\n\nvariables {α₁ : Sort*} {α₂ : Sort*} {β₁ : α₁ → Sort*} {β₂ : α₂ → Sort*}\n\n/-- Map the left and right components of a sigma -/\ndef map (f₁ : α₁ → α₂) (f₂ : Πa, β₁ a → β₂ (f₁ a)) : psigma β₁ → psigma β₂\n| ⟨a, b⟩ := ⟨f₁ a, f₂ a b⟩\n\nend psigma\n\nend psigma\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/data/sigma/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.4910380525146066}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport logic.small.basic\nimport category_theory.category.ulift\nimport category_theory.skeletal\n\n/-!\n# Essentially small categories.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA category given by `(C : Type u) [category.{v} C]` is `w`-essentially small\nif there exists a `small_model C : Type w` equipped with `[small_category (small_model C)]`.\n\nA category is `w`-locally small if every hom type is `w`-small.\n\nThe main theorem here is that a category is `w`-essentially small iff\nthe type `skeleton C` is `w`-small, and `C` is `w`-locally small.\n-/\n\nuniverses w v v' u u'\n\nopen category_theory\n\nvariables (C : Type u) [category.{v} C]\n\nnamespace category_theory\n\n/-- A category is `essentially_small.{w}` if there exists\nan equivalence to some `S : Type w` with `[small_category S]`. -/\nclass essentially_small (C : Type u) [category.{v} C] : Prop :=\n(equiv_small_category : ∃ (S : Type w) (_ : small_category S), by exactI nonempty (C ≌ S))\n\n/-- Constructor for `essentially_small C` from an explicit small category witness. -/\n\n\n/--\nAn arbitrarily chosen small model for an essentially small category.\n-/\n@[nolint has_nonempty_instance]\ndef small_model (C : Type u) [category.{v} C] [essentially_small.{w} C] : Type w :=\nclassical.some (@essentially_small.equiv_small_category C _ _)\n\nnoncomputable\ninstance small_category_small_model\n  (C : Type u) [category.{v} C] [essentially_small.{w} C] : small_category (small_model C) :=\nclassical.some (classical.some_spec (@essentially_small.equiv_small_category C _ _))\n\n/--\nThe (noncomputable) categorical equivalence between\nan essentially small category and its small model.\n-/\nnoncomputable\ndef equiv_small_model (C : Type u) [category.{v} C] [essentially_small.{w} C] : C ≌ small_model C :=\nnonempty.some (classical.some_spec (classical.some_spec\n  (@essentially_small.equiv_small_category C _ _)))\n\nlemma essentially_small_congr {C : Type u} [category.{v} C] {D : Type u'} [category.{v'} D]\n  (e : C ≌ D) : essentially_small.{w} C ↔ essentially_small.{w} D :=\nbegin\n  fsplit,\n  { rintro ⟨S, 𝒮, ⟨f⟩⟩,\n    resetI,\n    exact essentially_small.mk' (e.symm.trans f), },\n  { rintro ⟨S, 𝒮, ⟨f⟩⟩,\n    resetI,\n    exact essentially_small.mk' (e.trans f), },\nend\n\nlemma discrete.essentially_small_of_small {α : Type u} [small.{w} α] :\n  essentially_small.{w} (discrete α) :=\n⟨⟨discrete (shrink α), ⟨infer_instance, ⟨discrete.equivalence (equiv_shrink _)⟩⟩⟩⟩\n\nlemma essentially_small_self : essentially_small.{max w v u} C :=\nessentially_small.mk' (as_small.equiv : C ≌ as_small.{w} C)\n\n/--\nA category is `w`-locally small if every hom set is `w`-small.\n\nSee `shrink_homs C` for a category instance where every hom set has been replaced by a small model.\n-/\nclass locally_small (C : Type u) [category.{v} C] : Prop :=\n(hom_small : ∀ X Y : C, small.{w} (X ⟶ Y) . tactic.apply_instance)\n\ninstance (C : Type u) [category.{v} C] [locally_small.{w} C] (X Y : C) :\n  small (X ⟶ Y) :=\nlocally_small.hom_small X Y\n\nlemma locally_small_congr {C : Type u} [category.{v} C] {D : Type u'} [category.{v'} D]\n  (e : C ≌ D) : locally_small.{w} C ↔ locally_small.{w} D :=\nbegin\n  fsplit,\n  { rintro ⟨L⟩,\n    fsplit,\n    intros X Y,\n    specialize L (e.inverse.obj X) (e.inverse.obj Y),\n    refine (small_congr _).mpr L,\n    exact equiv_of_fully_faithful e.inverse, },\n  { rintro ⟨L⟩,\n    fsplit,\n    intros X Y,\n    specialize L (e.functor.obj X) (e.functor.obj Y),\n    refine (small_congr _).mpr L,\n    exact equiv_of_fully_faithful e.functor, },\nend\n\n@[priority 100]\ninstance locally_small_self (C : Type u) [category.{v} C] : locally_small.{v} C := {}\n\n@[priority 100]\ninstance locally_small_of_essentially_small\n  (C : Type u) [category.{v} C] [essentially_small.{w} C] : locally_small.{w} C :=\n(locally_small_congr (equiv_small_model C)).mpr (category_theory.locally_small_self _)\n\n/--\nWe define a type alias `shrink_homs C` for `C`. When we have `locally_small.{w} C`,\nwe'll put a `category.{w}` instance on `shrink_homs C`.\n-/\n@[nolint has_nonempty_instance]\ndef shrink_homs (C : Type u) := C\n\nnamespace shrink_homs\n\nsection\nvariables {C' : Type*} -- a fresh variable with no category instance attached\n\n/-- Help the typechecker by explicitly translating from `C` to `shrink_homs C`. -/\ndef to_shrink_homs {C' : Type*} (X : C') : shrink_homs C' := X\n/-- Help the typechecker by explicitly translating from `shrink_homs C` to `C`. -/\ndef from_shrink_homs {C' : Type*} (X : shrink_homs C') : C' := X\n\n@[simp] lemma to_from (X : C') : from_shrink_homs (to_shrink_homs X) = X := rfl\n@[simp] lemma from_to (X : shrink_homs C') : to_shrink_homs (from_shrink_homs X) = X := rfl\n\nend\n\nvariables (C) [locally_small.{w} C]\n\n@[simps]\nnoncomputable\ninstance : category.{w} (shrink_homs C) :=\n{ hom := λ X Y, shrink (from_shrink_homs X ⟶ from_shrink_homs Y),\n  id := λ X, equiv_shrink _ (𝟙 (from_shrink_homs X)),\n  comp := λ X Y Z f g,\n    equiv_shrink _ (((equiv_shrink _).symm f) ≫ ((equiv_shrink _).symm g)), }.\n\n/-- Implementation of `shrink_homs.equivalence`. -/\n@[simps]\nnoncomputable\ndef functor : C ⥤ shrink_homs C :=\n{ obj := λ X, to_shrink_homs X,\n  map := λ X Y f, equiv_shrink (X ⟶ Y) f, }\n\n/-- Implementation of `shrink_homs.equivalence`. -/\n@[simps]\nnoncomputable\ndef inverse : shrink_homs C ⥤ C :=\n{ obj := λ X, from_shrink_homs X,\n  map := λ X Y f, (equiv_shrink (from_shrink_homs X ⟶ from_shrink_homs Y)).symm f, }\n\n/--\nThe categorical equivalence between `C` and `shrink_homs C`, when `C` is locally small.\n-/\n@[simps]\nnoncomputable\ndef equivalence : C ≌ shrink_homs C :=\nequivalence.mk (functor C) (inverse C)\n  (nat_iso.of_components (λ X, iso.refl X) (by tidy))\n  (nat_iso.of_components (λ X, iso.refl X) (by tidy))\n\nend shrink_homs\n\n/--\nA category is essentially small if and only if\nthe underlying type of its skeleton (i.e. the \"set\" of isomorphism classes) is small,\nand it is locally small.\n-/\ntheorem essentially_small_iff (C : Type u) [category.{v} C] :\n  essentially_small.{w} C ↔ small.{w} (skeleton C) ∧ locally_small.{w} C :=\nbegin\n  -- This theorem is the only bit of real work in this file.\n  fsplit,\n  { intro h,\n    fsplit,\n    { rcases h with ⟨S, 𝒮, ⟨e⟩⟩,\n      resetI,\n      refine ⟨⟨skeleton S, ⟨_⟩⟩⟩,\n      exact e.skeleton_equiv, },\n    { resetI, apply_instance, }, },\n  { rintro ⟨⟨S, ⟨e⟩⟩, L⟩,\n    resetI,\n    let e' := (shrink_homs.equivalence C).skeleton_equiv.symm,\n    refine ⟨⟨S, _, ⟨_⟩⟩⟩,\n    apply induced_category.category (e'.trans e).symm,\n    refine (shrink_homs.equivalence C).trans\n      ((skeleton_equivalence _).symm.trans\n      ((induced_functor (e'.trans e).symm).as_equivalence.symm)), },\nend\n\n/--\nAny thin category is locally small.\n-/\n@[priority 100]\ninstance locally_small_of_thin {C : Type u} [category.{v} C] [quiver.is_thin C] :\n  locally_small.{w} C := {}\n\n/--\nA thin category is essentially small if and only if the underlying type of its skeleton is small.\n-/\ntheorem essentially_small_iff_of_thin\n  {C : Type u} [category.{v} C] [quiver.is_thin C] :\n  essentially_small.{w} C ↔ small.{w} (skeleton C) :=\nby simp [essentially_small_iff, category_theory.locally_small_of_thin]\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/essentially_small.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6688802471698041, "lm_q1q2_score": 0.4910380506051741}}
{"text": "import analysis.inner_product_space.pi_L2\n  \nvariables {ι : Type*} [fintype ι]\nvariables {𝕜 : Type*} [is_R_or_C 𝕜] {E : Type*} [inner_product_space 𝕜 E]\nvariables {E' : Type*} [inner_product_space 𝕜 E']\n\nvariables {m n : ℕ}\n\nlocal notation `⟪`x`, `y`⟫` := @inner 𝕜 (euclidean_space 𝕜 (fin m)) _ x y\n\nopen_locale matrix\n\nlemma inner_matrix_row_row (A : matrix (fin n) (fin m) 𝕜) (i j : (fin n)) :\n  ⟪A i, A j⟫ = (A ⬝ Aᴴ) j i := by {simp only [inner, matrix.mul_apply, star_ring_end_apply,\n    matrix.conj_transpose_apply,mul_comm]}", "meta": {"author": "hparshall", "repo": "lean-matrix-analysis", "sha": "cc1b9949065257b6c19f047a5a996bfac29f178e", "save_path": "github-repos/lean/hparshall-lean-matrix-analysis", "path": "github-repos/lean/hparshall-lean-matrix-analysis/lean-matrix-analysis-cc1b9949065257b6c19f047a5a996bfac29f178e/src/matrix_inner_rows.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8080672135527631, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.49103268442550424}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro, Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Kevin Buzzard\n\n! This file was ported from Lean 3 source module ring_theory.ideal.idempotent_fg\n! leanprover-community/mathlib commit 290a7ba01fbcab1b64757bdaa270d28f4dcede35\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Ring.Idempotents\nimport Mathbin.RingTheory.Finiteness\n\n/-!\n## Lemmas on idempotent finitely generated ideals\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nnamespace Ideal\n\n/- warning: ideal.is_idempotent_elem_iff_of_fg -> Ideal.isIdempotentElem_iff_of_fg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (I : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), (Ideal.Fg.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) I) -> (Iff (IsIdempotentElem.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.hasMul.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) I) (Exists.{succ u1} R (fun (e : R) => And (IsIdempotentElem.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) e) (Eq.{succ u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) I (Submodule.span.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Singleton.singleton.{u1, u1} R (Set.{u1} R) (Set.hasSingleton.{u1} R) e))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (I : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), (Ideal.Fg.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) I) -> (Iff (IsIdempotentElem.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.instMulIdealToSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) I) (Exists.{succ u1} R (fun (e : R) => And (IsIdempotentElem.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) e) (Eq.{succ u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) I (Submodule.span.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (_private.Mathlib.RingTheory.Ideal.Operations.0.Ideal.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRingToNonUnitalCommRing.{u1, u1} R R (CommRing.toCommSemiring.{u1} R _inst_1) _inst_1 (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Singleton.singleton.{u1, u1} R (Set.{u1} R) (Set.instSingletonSet.{u1} R) e))))))\nCase conversion may be inaccurate. Consider using '#align ideal.is_idempotent_elem_iff_of_fg Ideal.isIdempotentElem_iff_of_fgₓ'. -/\n/-- A finitely generated idempotent ideal is generated by an idempotent element -/\ntheorem isIdempotentElem_iff_of_fg {R : Type _} [CommRing R] (I : Ideal R) (h : I.Fg) :\n    IsIdempotentElem I ↔ ∃ e : R, IsIdempotentElem e ∧ I = R ∙ e :=\n  by\n  constructor\n  · intro e\n    obtain ⟨r, hr, hr'⟩ :=\n      Submodule.exists_mem_and_smul_eq_self_of_fg_of_le_smul I I h\n        (by\n          rw [smul_eq_mul]\n          exact e.ge)\n    simp_rw [smul_eq_mul] at hr'\n    refine' ⟨r, hr' r hr, antisymm _ ((Submodule.span_singleton_le_iff_mem _ _).mpr hr)⟩\n    intro x hx\n    rw [← hr' x hx]\n    exact ideal.mem_span_singleton'.mpr ⟨_, mul_comm _ _⟩\n  · rintro ⟨e, he, rfl⟩\n    simp [IsIdempotentElem, Ideal.span_singleton_mul_span_singleton, he.eq]\n#align ideal.is_idempotent_elem_iff_of_fg Ideal.isIdempotentElem_iff_of_fg\n\n/- warning: ideal.is_idempotent_elem_iff_eq_bot_or_top -> Ideal.isIdempotentElem_iff_eq_bot_or_top is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] (I : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), (Ideal.Fg.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) I) -> (Iff (IsIdempotentElem.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.hasMul.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) I) (Or (Eq.{succ u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) I (Bot.bot.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.hasBot.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Eq.{succ u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) I (Top.top.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.hasTop.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : IsDomain.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))] (I : Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))), (Ideal.Fg.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) I) -> (Iff (IsIdempotentElem.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Ideal.instMulIdealToSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) I) (Or (Eq.{succ u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) I (Bot.bot.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.instBotSubmodule.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (Eq.{succ u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) I (Top.top.{u1} (Ideal.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Submodule.instTopSubmodule.{u1, u1} R R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align ideal.is_idempotent_elem_iff_eq_bot_or_top Ideal.isIdempotentElem_iff_eq_bot_or_topₓ'. -/\ntheorem isIdempotentElem_iff_eq_bot_or_top {R : Type _} [CommRing R] [IsDomain R] (I : Ideal R)\n    (h : I.Fg) : IsIdempotentElem I ↔ I = ⊥ ∨ I = ⊤ :=\n  by\n  constructor\n  · intro H\n    obtain ⟨e, he, rfl⟩ := (I.is_idempotent_elem_iff_of_fg h).mp H\n    simp only [Ideal.submodule_span_eq, Ideal.span_singleton_eq_bot]\n    apply or_of_or_of_imp_of_imp (is_idempotent_elem.iff_eq_zero_or_one.mp he) id\n    rintro rfl\n    simp\n  · rintro (rfl | rfl) <;> simp [IsIdempotentElem]\n#align ideal.is_idempotent_elem_iff_eq_bot_or_top Ideal.isIdempotentElem_iff_eq_bot_or_top\n\nend Ideal\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/Ideal/IdempotentFg.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4909549934211428}}
{"text": "import category_theory.limits.shapes.pullbacks\nimport category_theory.limits.limits\nimport category_theory.types\nimport category_theory.limits.types\nimport category_theory.monad.algebra\nimport category_theory.category.Cat\nimport tactic.equiv_rw\nimport category.pullbacks\nimport data.sigma\n\nnamespace category_theory\n\nopen category_theory category_theory.category category_theory.limits\n\nuniverses v u\nnoncomputable theory\nsection\nvariables (A : Type u) [category.{v} A]\n\nstructure internal_category_struct :=\n(C₀ C₁ C₂ : A) -- object of objects, object of morphisms, object of composable pairs (i.e (f,g) where f ∘ g makes sense)\n(trg src : C₁ ⟶ C₀) -- get codomain and domain of morphisms\n(ident : C₀ ⟶ C₁) -- get identity morphism on object\n(first_hom comp second_hom : C₂ ⟶ C₁) -- decompose composite\n(comp_comm : first_hom ≫ src = second_hom ≫ trg)\n(comp_pb : is_limit (pullback_cone.mk _ _ comp_comm))\n(ident_trg : ident ≫ trg = 𝟙 C₀)\n(ident_src : ident ≫ src = 𝟙 C₀)\n(comp_trg : comp ≫ trg = first_hom ≫ trg)\n(comp_src : comp ≫ src = second_hom ≫ src)\nend\n\nopen internal_category_struct\n\nattribute [simp, reassoc] internal_category_struct.ident_src internal_category_struct.ident_trg\nattribute [simp, reassoc] internal_category_struct.comp_comm internal_category_struct.comp_trg internal_category_struct.comp_src\n\nsection\nvariables {C : Type u} [category.{v} C] {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n@[simp] lemma mk_fst {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n  (pullback_cone.mk fst snd eq).fst = fst := rfl\n@[simp] lemma mk_snd {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n  (pullback_cone.mk fst snd eq).snd = snd := rfl\nend\n\nsection\nvariables {A : Type u} [category.{v} A] (c : internal_category_struct A)\n-- given f,g with the source of f = target of g (ie f ∘ g or g ≫ f makes sense), form the composable pair (f,g)\n\ndef make_pair {Q : A} (f g : Q ⟶ c.C₁)\n  (composable : f ≫ c.src = g ≫ c.trg) :\nQ ⟶ c.C₂ :=\n(pullback_cone.is_limit.lift' c.comp_pb _ _ composable).1\n\n@[simp, reassoc]\nlemma compose_l {Q : A} (f g : Q ⟶ c.C₁)\n  (cmp : f ≫ c.src = g ≫ c.trg) :\nmake_pair c f g cmp ≫ c.first_hom = f :=\n(pullback_cone.is_limit.lift' c.comp_pb _ _ cmp).2.1\n\n@[simp, reassoc]\nlemma compose_r {Q : A} (f g : Q ⟶ c.C₁)\n  (cmp : f ≫ c.src = g ≫ c.trg) :\nmake_pair c f g cmp ≫ c.second_hom = g :=\n(pullback_cone.is_limit.lift' c.comp_pb _ _ cmp).2.2\n\n@[reassoc] lemma compose_natural {Q R : A} (f g : R ⟶ c.C₁) (h : Q ⟶ R) (composable : f ≫ c.src = g ≫ c.trg) :\n  h ≫ make_pair c f g composable = make_pair c (h ≫ f) (h ≫ g) (by simp [*]) :=\nbegin\n  apply pullback_cone.is_limit.hom_ext c.comp_pb;\n  simp,\nend\nend\n\nsection\nvariables {A : Type u} [category.{v} A] [has_finite_limits A] (c : internal_category_struct A)\n/--\nobject of composable triples (f,g,h) where f ∘ (g ∘ h) makes sense\n(as should (f ∘ g) ∘ h)\nconstructed as the pullback of (f,g₁) and (g₂,h) where g₁ = g₂\n-/\ndef internal_category_struct.C₃ : A :=\npullback c.second_hom c.first_hom\n\nopen limits.pullback\n\n/-- The first pair `(f, g₁)` of the triple `(f, g₁ = g₂, h)` -/\nabbreviation internal_category_struct.left_pair : c.C₃ ⟶ c.C₂ := fst\n/-- The second pair `(g₂, h)` of the triple `(f, g₁ = g₂, h)` -/\nabbreviation internal_category_struct.right_pair : c.C₃ ⟶ c.C₂ := snd\n\n/-- The first homomorphism `f` of the triple `(f, g, h)` -/\nabbreviation internal_category_struct.trip_first_hom : c.C₃ ⟶ c.C₁ := c.left_pair ≫ c.first_hom\n/-- The first homomorphism `h` of the triple `(f, g, h)` -/\nabbreviation internal_category_struct.trip_third_hom : c.C₃ ⟶ c.C₁ := c.right_pair ≫ c.second_hom\n\n/-- Prove `g₁ = g₂` in the triple `(f, g₁ = g₂, h)` -/\n@[reassoc] lemma trip_snd_eq : c.left_pair ≫ c.second_hom = c.right_pair ≫ c.first_hom := condition\n\n/-- Map `(f, g, h)` to `(f ∘ g, h)` -/\nabbreviation internal_category_struct.comp_left_pair : c.C₃ ⟶ c.C₂ :=\nmake_pair c (c.left_pair ≫ c.comp) c.trip_third_hom $\nby rw [assoc, c.comp_src, trip_snd_eq_assoc, assoc, c.comp_comm]\n\n/-- Map `(f, g, h)` to `(f, g ∘ h)` -/\nabbreviation internal_category_struct.comp_right_pair : c.C₃ ⟶ c.C₂ :=\nmake_pair c c.trip_first_hom (c.right_pair ≫ c.comp) $\nby rw [assoc, assoc, c.comp_trg, c.comp_comm, trip_snd_eq_assoc]\n\nend\n-- def element {X : Type u} : (⊤_ (Type u) ⟶ X) ≃ X :=\n-- { to_fun := λ f, f _,\n\n-- }\n-- -- { to_fun := λ f, f ⟨λ t, t.elim, λ t, t.elim⟩,\n-- --   inv_fun := λ x _, x,\n-- --   left_inv := λ f,\n-- --   begin\n-- --     ext1 ⟨_, _⟩,\n-- --     dsimp,\n-- --     congr,\n-- --     ext ⟨⟩,\n-- --   end,\n-- --   right_inv := λ x, rfl }\n\n-- @[simp] lemma element_natural {X Y : Type u} (f : ⊤_ _ ⟶ X) (g : X ⟶ Y) : element (f ≫ g) = g (element f) :=\n-- rfl\n\n-- @[simp] lemma element_unelement {X : Type u} (x : X) : element (element.symm x) = x :=\n-- rfl\n\n-- def category_struct_of_internal_category_struct_type (c : internal_category_struct.{u} (Type u)) :\n--   category_struct c.C₀ :=\n-- { hom := λ X Y, {h : c.C₁ // c.src h = Y ∧ c.trg h = X},\n--   id := λ X, ⟨c.ident X, congr_fun c.ident_src X, congr_fun c.ident_trg X⟩,\n--   comp := λ X Y Z f g,\n--   begin\n--     refine ⟨_, _, _⟩,\n--     { refine element (make_pair c (element.symm ↑f) (element.symm ↑g) _ ≫ c.comp),\n--       rw ← element.apply_eq_iff_eq,\n--       dsimp, rw [f.prop.1, g.prop.2] },\n--     { change (make_pair _ _ _ _ ≫ c.comp ≫ c.src) _ = Z,\n--       rw [c.comp_src, compose_r_assoc],\n--       exact g.prop.1 },\n--     { change (make_pair _ _ _ _ ≫ c.comp ≫ c.trg) _ = X,\n--       rw [c.comp_trg, compose_l_assoc],\n--       exact f.prop.2 },\n--   end }\n\n-- structure internal_category (A : Type u) [category.{v} A] [has_finite_limits.{v} A] extends internal_category_struct.{v} A :=\n-- (assoc : internal_category_struct.comp_left_pair _ ≫ comp = internal_category_struct.comp_right_pair _ ≫ comp)\n-- (id_comp : make_pair _ (𝟙 _) (src ≫ ident) (by simp) ≫ comp = 𝟙 C₁)\n-- (comp_id : make_pair _ (trg ≫ ident) (𝟙 _) (by simp) ≫ comp = 𝟙 C₁)\n\n-- @[simps]\n-- def internal_category_struct_type_of_category_struct (C : Type u) [category_struct.{u} C] : internal_category_struct.{u} (Type u) :=\n-- { C₀ := C,\n--   C₁ := Σ (X Y : C), X ⟶ Y,\n--   C₂ := Σ (X Y Z : C), (X ⟶ Y) × (Y ⟶ Z),\n--   src := λ f, f.1,\n--   trg := λ f, f.2.1,\n--   ident := λ x, ⟨x, x, 𝟙 _⟩,\n--   first_hom := λ x, ⟨x.2.1, x.2.2.1, x.2.2.2.2⟩,\n--   comp := λ x, ⟨x.1, x.2.2.1, x.2.2.2.1 ≫ x.2.2.2.2⟩,\n--   second_hom := λ x, ⟨x.1, x.2.1, x.2.2.2.1⟩,\n--   comp_comm := rfl,\n--   comp_pb :=\n--   begin\n--     refine construct_type_pb _ _,\n--     rintros ⟨Y, X, f⟩ ⟨Z, Y, g⟩ _,\n--     dsimp at a, subst a,\n--     refine ⟨⟨Z, Y, X, g, f⟩, rfl, rfl, _⟩,\n--     rintro ⟨Z', Y', X', g', f'⟩ h₁ h₂,\n--     dsimp at h₁ h₂,\n--     cases h₁,\n--     cases h₂,\n--     refl,\n--   end,\n--   ident_trg := rfl,\n--   ident_src := rfl,\n--   comp_trg := rfl,\n--   comp_src := rfl }\n\n-- section\n\n-- def tag (α : Type*) (n : ℕ) (t : α) := t\n\n-- def alt_pb (C : Type u) [category_struct.{u} C] := Σ (W X Y Z : C), (W ⟶ X) × (X ⟶ Y) × (Y ⟶ Z)\n-- def alt_π₁ (C : Type u) [category_struct.{u} C] :\n--   alt_pb C ⟶ (internal_category_struct_type_of_category_struct C).C₂ :=\n-- begin\n--   intro x,\n--   refine ⟨x.2.1, x.2.2.1, x.2.2.2.1, x.2.2.2.2.2.1, x.2.2.2.2.2.2⟩,\n-- end\n-- def alt_π₂ (C : Type u) [category_struct.{u} C] :\n--   alt_pb C ⟶ (internal_category_struct_type_of_category_struct C).C₂ :=\n-- begin\n--   intro x,\n--   refine ⟨x.1, x.2.1, x.2.2.1, x.2.2.2.2.1, x.2.2.2.2.2.1⟩,\n-- end\n\n-- lemma alt_comm (C : Type u) [category_struct.{u} C] :\n--   alt_π₁ C ≫ (internal_category_struct_type_of_category_struct C).second_hom = alt_π₂ C ≫ (internal_category_struct_type_of_category_struct C).first_hom :=\n-- rfl\n\n-- def is_pb (C : Type u) [category_struct.{u} C] :\n--   is_limit (pullback_cone.mk _ _ (alt_comm C)) :=\n-- begin\n--   apply construct_type_pb _,\n--   rintros ⟨X, Y, Z, f, g⟩ ⟨W, X, Y, h, f⟩ _,\n--   dsimp [internal_category_struct_type_of_category_struct] at a,\n--   injection a with a₁ a₂,\n--   subst a₁,\n--   rw heq_iff_eq at a₂,\n--   injection a₂ with a₃ a₄,\n--   subst a₃,\n--   rw heq_iff_eq at a₄,\n--   subst a₄,\n--   refine ⟨⟨_, _, _, _, h, f, g⟩, _, _, _⟩,\n--   refl,\n--   refl,\n--   rintro ⟨_, _, _, _, _, _, _⟩ k l,\n--   cases k,\n--   cases l,\n--   refl,\n-- end\n\n-- end\n\n-- local attribute [instance] has_finite_limits_of_has_limits\n\n-- def to_C₃ (C : Type u) [category_struct.{u} C] : alt_pb C ≅ (internal_category_struct_type_of_category_struct C).C₃ :=\n-- limits.is_limit.cone_point_unique_up_to_iso (is_pb C) (limit.is_limit _)\n\n-- @[simps]\n-- def internal_category_type_of_category (C : Type u) [category.{u} C] : internal_category.{u} (Type u) :=\n-- { id_comp :=\n--   begin\n--     ext1 ⟨X, Y, f⟩,\n--     change (⟨_, _, _⟩ : Σ (X Y : C), X ⟶ Y) = _,\n--     congr' 2,\n--     apply id_comp,\n--   end,\n--   comp_id :=\n--   begin\n--     ext1 ⟨X, Y, f⟩,\n--     change (⟨X, Y, f ≫ 𝟙 _⟩ : Σ (X Y : C), X ⟶ Y) = (⟨X, Y, f⟩ : Σ (X Y : C), X ⟶ Y),\n--     congr' 2,\n--     apply comp_id,\n--   end,\n--   assoc :=\n--   begin\n--     haveI := is_iso.of_iso (to_C₃ C),\n--     rw [← cancel_epi (to_C₃ C).hom, compose_natural_assoc, compose_natural_assoc],\n--     change make_pair _ (pullback.lift _ _ _ ≫ pullback.fst ≫ _) (pullback.lift _ _ _ ≫ pullback.snd ≫ _) _ ≫ _ =\n--            make_pair _ (pullback.lift _ _ _ ≫ pullback.fst ≫ _) (pullback.lift _ _ _ ≫ pullback.snd ≫ _) _ ≫ _,\n--     simp_rw [pullback.lift_fst_assoc, pullback.lift_snd_assoc],\n--     ext1 ⟨W, X, Y, Z, f, g, h⟩,\n--     change (⟨W, Z, f ≫ g ≫ h⟩ : Σ (X Y : C), X ⟶ Y) = (⟨W, Z, (f ≫ g) ≫ h⟩ : Σ (X Y : C), X ⟶ Y),\n--     simp,\n--   end,\n--   ..internal_category_struct_type_of_category_struct C }\n\n-- instance category_of_internal_category_type (c : internal_category.{u} (Type u)) :\n--   small_category c.C₀ :=\n-- { comp_id' :=\n--   begin\n--     rintros X Y ⟨f, rfl, rfl⟩,\n--     ext1,\n--     change element (make_pair _ (element.symm f) _ _ ≫ c.comp) = f,\n--     equiv_rw (@element c.C₁).symm at f,\n--     rw equiv.apply_eq_iff_eq,\n--     change make_pair c.to_internal_category_struct f (element.symm (element ((f ≫ c.src) ≫ c.ident))) _ ≫ c.comp = _,\n--     simp_rw [equiv.symm_apply_apply, assoc],\n--     have := f ≫= c.id_comp,\n--     simp_rw [compose_natural_assoc, comp_id] at this,\n--     exact this,\n--   end,\n--   id_comp' :=\n--   begin\n--     rintros X Y ⟨f, rfl, rfl⟩,\n--     ext1,\n--     change element (make_pair _ _ (element.symm f) _ ≫ c.comp) = f,\n--     equiv_rw (@element c.C₁).symm at f,\n--     rw equiv.apply_eq_iff_eq,\n--     change make_pair c.to_internal_category_struct (element.symm (element ((f ≫ c.trg) ≫ c.ident))) f _ ≫ c.comp = _,\n--     simp_rw [equiv.symm_apply_apply, assoc],\n--     have := f ≫= c.comp_id,\n--     simp_rw [compose_natural_assoc, comp_id] at this,\n--     exact this,\n--   end,\n--   assoc' :=\n--   begin\n--     rintros W X Y Z ⟨f, rfl, rfl⟩ ⟨g, rfl, fg⟩ ⟨h, rfl, gh⟩,\n--     ext1,\n--     equiv_rw (@element c.C₁).symm at f,\n--     equiv_rw (@element c.C₁).symm at g,\n--     equiv_rw (@element c.C₁).symm at h,\n--     change element (make_pair _ _ _ _ ≫ c.comp) = element (make_pair _ _ _ _ ≫ c.comp),\n--     rw equiv.apply_eq_iff_eq,\n--     change make_pair _ (element.symm (element (make_pair _ (element.symm (element f)) (element.symm (element g)) _ ≫ c.comp))) (element.symm (element h)) _ ≫ c.comp =\n--            make_pair _ (element.symm (element f)) (element.symm (element (make_pair _ (element.symm (element g)) (element.symm (element h)) _ ≫ c.comp))) _ ≫ c.comp,\n--     simp_rw [equiv.symm_apply_apply],\n--     change make_pair _ (make_pair _ f g _ ≫ c.comp) h _ ≫ c.comp = make_pair _ f (make_pair _ g h _ ≫ c.comp) _ ≫ c.comp,\n--     have := pullback.lift (make_pair _ f g _) (make_pair _ g h _) _ ≫= c.assoc,\n--       rotate,\n--       { rw [equiv.symm_symm, ← element_natural _ c.trg, ← element_natural _ c.src, equiv.apply_eq_iff_eq] at fg,\n--         rw fg },\n--       { rw [equiv.symm_symm, ← element_natural _ c.trg, ← element_natural _ c.src, equiv.apply_eq_iff_eq] at gh,\n--         rw gh },\n--       { rw [compose_l, compose_r] },\n--     rw [← assoc, ← assoc] at this,\n--     convert this;\n--     apply pullback_cone.is_limit.hom_ext c.comp_pb;\n--     simp,\n--   end,\n--   ..category_struct_of_internal_category_struct_type c.to_internal_category_struct}\n\n-- structure internal_functor {A : Type u} [category.{v} A] [has_finite_limits A] (c d : internal_category A) :=\n-- (obj : c.C₀ ⟶ d.C₀)\n-- (map : c.C₁ ⟶ d.C₁)\n-- (map_src : map ≫ d.src = c.src ≫ obj)\n-- (map_trg : map ≫ d.trg = c.trg ≫ obj)\n-- (ident_map : c.ident ≫ map = obj ≫ d.ident)\n-- (comp_map : make_pair _ (first_hom _ ≫ map) (second_hom _ ≫ map) (by simp [map_src, map_trg]) ≫ d.comp = c.comp ≫ map)\n\n-- attribute [simp, reassoc] internal_functor.map_src internal_functor.map_trg internal_functor.ident_map internal_functor.comp_map\n-- variables {A : Type u} [category.{v} A] [has_finite_limits A]\n\n-- def internal_id (c : internal_category A) : internal_functor c c :=\n-- { obj := 𝟙 _,\n--   map := 𝟙 _,\n--   map_src := by simp,\n--   map_trg := by simp,\n--   ident_map := by simp,\n--   comp_map :=\n--   begin\n--     simp only [comp_id],\n--     convert id_comp _,\n--     apply pullback_cone.is_limit.hom_ext c.comp_pb;\n--     simp,\n--   end }\n\n-- def internal_comp {c d e : internal_category A} (F : internal_functor c d) (G : internal_functor d e) :\n--   internal_functor c e :=\n-- { obj := F.obj ≫ G.obj,\n--   map := F.map ≫ G.map,\n--   map_src := by simp,\n--   map_trg := by simp,\n--   ident_map := by simp,\n--   comp_map :=\n--   begin\n--     rw [← F.comp_map_assoc, ← G.comp_map, compose_natural_assoc],\n--     simp,\n--   end }\n\n-- @[ext] def internal_functor_ext {c d : internal_category A} (F G : internal_functor c d) (h₁ : F.obj = G.obj) (h₂ : F.map = G.map) : F = G :=\n-- begin\n--   cases F, cases G,\n--   congr; assumption\n-- end\n-- @[simps]\n-- def make_functor (c d : internal_category.{u} (Type u)) (F : internal_functor c d) :\n--   c.C₀ ⥤ d.C₀ :=\n-- { obj := F.obj,\n--   map := λ X Y f,\n--   begin\n--     refine ⟨F.map f.1, _, _⟩,\n--     { change (F.map ≫ d.src) _ = _,\n--       rw F.map_src,\n--       dsimp,\n--       rw f.prop.1 },\n--     { change (F.map ≫ d.trg) _ = _,\n--       rw F.map_trg,\n--       dsimp,\n--       rw f.prop.2 },\n--   end,\n--   map_id' := λ X,\n--   begin\n--     ext1,\n--     change (c.ident ≫ F.map) X = (F.obj ≫ d.ident) X,\n--     rw F.ident_map,\n--   end,\n--   map_comp' :=\n--   begin\n--     rintros _ _ Z ⟨f, rfl, rfl⟩ ⟨g, rfl, fg⟩,\n--     ext1,\n--     change F.map (element (make_pair _ (element.symm f) (element.symm g) _ ≫ c.comp)) = element (make_pair _ (element.symm (F.map f)) (element.symm (F.map g)) _ ≫ d.comp),\n--     equiv_rw (@element c.C₁).symm at f,\n--     equiv_rw (@element c.C₁).symm at g,\n--     have : g ≫ c.trg = f ≫ c.src,\n--       rw ← element.apply_eq_iff_eq,\n--       simpa using fg,\n--     simp_rw [← element_natural _ F.map, equiv.symm_apply_apply],\n--     rw [element.apply_eq_iff_eq, assoc, ← F.comp_map, compose_natural_assoc],\n--     simp,\n--   end }\n\n-- def internalise_functor (C D : Type u) [small_category C] [small_category D] (F : C ⥤ D) :\n--   internal_functor (internal_category_type_of_category C) (internal_category_type_of_category D) :=\n-- { obj := F.obj,\n--   map := λ XYf, ⟨F.obj XYf.1, F.obj XYf.2.1, F.map XYf.2.2⟩,\n--   map_src := rfl,\n--   map_trg := rfl,\n--   ident_map :=\n--   begin\n--     ext1 X,\n--     dsimp,\n--     simp only [functor.map_id],\n--     refl,\n--   end,\n--   comp_map :=\n--   begin\n--     ext1 ⟨X, Y, Z, f, g⟩,\n--     dsimp [internal_category_struct_type_of_category_struct],\n--     change (⟨F.obj X, ⟨F.obj Z, F.map f ≫ F.map g⟩⟩ : Σ (X Y : D), X ⟶ Y) = (⟨F.obj X, ⟨F.obj Z, F.map (f ≫ g)⟩⟩ : Σ (X Y : D), X ⟶ Y),\n--     simp,\n--   end }\n\n-- instance cat_of_int_cat : category (internal_category.{v} A) :=\n-- { hom := internal_functor,\n--   id := internal_id,\n--   comp := λ X Y Z, internal_comp,\n--   id_comp' := λ X Y f,\n--   begin\n--     apply internal_functor_ext;\n--     apply id_comp,\n--   end,\n--   comp_id' := λ X Y f,\n--   begin\n--     apply internal_functor_ext;\n--     apply comp_id,\n--   end,\n--   assoc' := λ c₁ c₂ c₃ c₄ f g h,\n--   begin\n--     apply internal_functor_ext;\n--     apply assoc,\n--   end }\n\n-- @[simps]\n-- def internal_equiv : internal_category (Type u) ⥤ Cat :=\n-- { obj := λ c, Cat.of c.C₀,\n--   map := make_functor,\n--   map_id' := λ c,\n--   begin\n--     refine functor.ext (λ X, rfl) _,\n--     intros,\n--     apply subtype.ext,\n--     dsimp [make_functor],\n--     simpa only [id_comp, comp_id],\n--   end,\n--   map_comp' := λ c d e f g,\n--   begin\n--     refine functor.ext (λ X, rfl) _,\n--     intros,\n--     apply subtype.ext,\n--     dsimp,\n--     simpa,\n--   end }\n\n-- @[simps]\n-- def internal_inv : Cat.{u} ⥤ internal_category (Type u) :=\n-- { obj := λ c, internal_category_type_of_category c.α,\n--   map := λ c d f, internalise_functor _ _ f }\n\n-- -- -- set_option pp.all true\n-- -- def internal_equivalence : internal_category.{u} (Type u) ≌ Cat.{u u} :=\n-- -- { functor :=\n-- --   { obj := λ c, Cat.of c.C₀,\n-- --     map := make_functor,\n-- --     map_id' := λ c,\n-- --     begin\n-- --       refine functor.ext (λ X, rfl) _,\n-- --       intros,\n-- --       apply subtype.ext,\n-- --       dsimp [make_functor],\n-- --       simpa only [id_comp, comp_id],\n-- --     end,\n-- --     map_comp' := λ c d e f g,\n-- --     begin\n-- --       refine functor.ext (λ X, rfl) _,\n-- --       intros,\n-- --       apply subtype.ext,\n-- --       dsimp,\n-- --       simpa,\n-- --     end },\n-- --   inverse :=\n-- --   { obj := λ c, internal_category_type_of_category c.α,\n-- --     map := λ c d f, internalise_functor _ _ f },\n-- --   unit_iso :=\n-- --   begin\n-- --     -- apply nat_iso.of_components _ _,\n-- --     -- intro X,\n-- --     -- dsimp,\n-- --     -- change X ≅ _,\n-- --     -- dsimp [Cat.of, bundled.of, Cat.str, category_theory.category_of_internal_category_type, internal_category_type_of_category],\n-- --     -- refine ⟨_, _, _, _⟩,\n-- --     -- refine ⟨𝟙 _, λ x, ⟨X.src x, X.trg x, sorry⟩, rfl, rfl, _, _⟩,\n-- --     -- ext1,\n-- --     -- dsimp [internal_category_struct_type_of_category_struct],\n-- --     -- change (⟨(X.ident ≫ X.src) x, (X.ident ≫ X.trg) x, _⟩ : Σ (X₁ Y₁ : X.to_internal_category_struct.C₀), X₁ ⟶ Y₁) = _,\n-- --     sorry,\n-- --   end,\n-- --   counit_iso :=\n-- --   begin\n-- --     apply nat_iso.of_components _ _,\n-- --     intro X,\n-- --     apply eq_to_iso,\n-- --     cases X,\n-- --     dsimp [Cat.of, bundled.of],\n-- --     congr,\n\n-- --   end\n-- -- }\n\nend category_theory", "meta": {"author": "b-mehta", "repo": "topos", "sha": "c9032b11789e36038bc841a1e2b486972421b983", "save_path": "github-repos/lean/b-mehta-topos", "path": "github-repos/lean/b-mehta-topos/topos-c9032b11789e36038bc841a1e2b486972421b983/src/internal_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867729389246, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4909549904682926}}
{"text": "import .form ..list\n\nnamespace nat\n\ndef update (m n) (v : nat → nat) : nat → nat \n| x := if x = m then n else v x\n\nlemma update_eq (m n v) : update m n v m = n :=\nbegin simp only [update, if_pos rfl] end\n\nlemma update_eq_of_ne {m n v k} : \n  m ≠ k → update m n v k = v k :=\nbegin\n  intro h1, simp only [update],\n  rw if_neg h1.symm\nend\n\nnamespace preterm\n\ndef sub_terms : preterm → option (preterm × preterm)\n| (& i)      := none\n| (i ** n)   := none\n| (t +* s) := t.sub_terms <|> s.sub_terms\n| (t -* s) := t.sub_terms <|> s.sub_terms <|> some (t,s)\n\ndef sub_subst (t s : preterm) (k : nat) : preterm → preterm \n| t@(& m)    := t\n| t@(m ** n) := t\n| (x +* y) := x.sub_subst +* y.sub_subst\n| (x -* y) := \n  if x = t ∧ y = s then (1 ** k)\n  else x.sub_subst -* y.sub_subst\n\nlemma val_sub_subst {k x y v} :\n  ∀ {t : preterm}, t.fresh_idx ≤ k → \n  (sub_subst x y k t).val \n  (update k (x.val v - y.val v) v) = t.val v \n| (& m)    h1 := rfl\n| (m ** n) h1 := \n  begin \n    simp_omega [sub_subst], apply congr_arg,\n    apply update_eq_of_ne (ne_of_gt _),\n    apply lt_iff_add_one_le.elim_right h1,\n end\n| (t +* s) h1 := \n  begin\n    simp_omega [sub_subst], apply fun_mono_2;\n    apply val_sub_subst (le_trans _ h1), \n    apply le_max_left, apply le_max_right\n  end\n| (t -* s) h1 := \n  begin\n    simp_omega [sub_subst], \n    by_cases h2 : t = x ∧ s = y,\n    { rw if_pos h2, simp_omega,\n      rw [update_eq, h2.left, h2.right, one_mul] },\n    { rw if_neg h2, simp_omega [sub_subst],\n      apply fun_mono_2;\n      apply val_sub_subst (le_trans _ h1), \n      apply le_max_left, apply le_max_right, }\n  end\n\nend preterm\n\nnamespace form\n\ndef sub_terms : form → option (preterm × preterm)\n| (t =* s) := t.sub_terms <|> s.sub_terms\n| (t ≤* s) := t.sub_terms <|> s.sub_terms\n| (¬* p)   := p.sub_terms\n| (p ∨* q) := p.sub_terms <|> q.sub_terms\n| (p ∧* q) := p.sub_terms <|> q.sub_terms\n\n@[omega] def sub_subst (x y : preterm) (k : nat) : form → form \n| (t =* s) := preterm.sub_subst x y k t =* preterm.sub_subst x y k s\n| (t ≤* s) := preterm.sub_subst x y k t ≤* preterm.sub_subst x y k s\n| (¬* p)   := ¬* p.sub_subst\n| (p ∨* q) := p.sub_subst ∨* q.sub_subst\n| (p ∧* q) := p.sub_subst ∧* q.sub_subst\n\nend form\n\ndef is_diff (t s k) : form := \n((t =* (s +* (1 ** k))) ∨* (t ≤* s ∧* ((1 ** k) =* &0))) \n\nlemma holds_is_diff {t s : preterm} {k} {v : nat → nat} :\n  v k = t.val v - s.val v → (is_diff t s k).holds v := \nbegin\n  intro h1, simp_omega [is_diff, if_pos (eq.refl 1)],\n  by_cases h2 : t.val v ≤ s.val v, \n  { right, refine ⟨h2,_⟩, \n    rw [h1, one_mul, nat.sub_eq_zero_iff_le], exact h2 },\n  { left, rw [h1, one_mul, add_comm, nat.sub_add_cancel _], \n    rw not_le at h2, apply le_of_lt h2 }\nend\n\ndef sub_elim_core (t s k) (p : form) : form := \n(form.sub_subst t s k p) ∧* (is_diff t s k)\n\ndef sub_fresh_idx (t s : preterm) (p : form) : nat :=\nmax p.fresh_idx (max t.fresh_idx s.fresh_idx) \n\ndef sub_elim (t s) (p : form) : form := \n-- sub_elim_core t s p.fresh_idx p\nsub_elim_core t s (sub_fresh_idx t s p) p\n\nlemma sub_subst_equiv {k} {x y : preterm} {v} :\n  ∀ p : form, p.fresh_idx ≤ k → ((form.sub_subst x y k p).holds \n    (update k (x.val v - y.val v) v) ↔ (p.holds v)) \n| (t =* s) h1 := \n  begin\n    simp_omega, apply pred_mono_2;\n    apply preterm.val_sub_subst (le_trans _ h1),\n    apply le_max_left, apply le_max_right\n  end\n| (t ≤* s) h1 := \n  begin\n    simp_omega, apply pred_mono_2;\n    apply preterm.val_sub_subst (le_trans _ h1),\n    apply le_max_left, apply le_max_right\n  end\n| (¬* p) h1 :=  \n  by { apply not_iff_not_of_iff, apply sub_subst_equiv p h1 } \n| (p ∨* q) h1 := \n  begin\n    simp_omega, apply pred_mono_2; apply propext;\n    apply sub_subst_equiv _ (le_trans _ h1),\n    apply le_max_left, apply le_max_right\n  end\n| (p ∧* q) h1 := \n  begin\n    simp_omega, apply pred_mono_2; apply propext;\n    apply sub_subst_equiv _ (le_trans _ h1),\n    apply le_max_left, apply le_max_right\n  end\n\nlemma sat_sub_elim {t s} {p : form} :\n  p.sat → (sub_elim t s p).sat := \nbegin\n  intro h1, simp only [sub_elim, sub_elim_core], \n  cases h1 with v h1, \n  refine ⟨update (sub_fresh_idx t s p) (t.val v - s.val v) v, _⟩, \n  constructor,\n  { apply (sub_subst_equiv p _).elim_right h1,\n    apply le_max_left },\n  { apply holds_is_diff, rw update_eq, \n    apply sub_eq_sub_of_eq_of_eq;\n    apply preterm.val_constant; intros x h2;\n    rw update_eq_of_ne; apply ne_of_gt;\n    apply lt_of_lt_of_le h2;\n    apply le_trans _ (le_max_right _ _),\n    apply le_max_left, apply le_max_right }\nend\n\nlemma unsat_of_unsat_sub_elim (t s p) :\n  (sub_elim t s p).unsat → p.unsat := \nnot_of_imp_of_not sat_sub_elim\n\nend nat", "meta": {"author": "skbaek", "repo": "omega", "sha": "715e384ed14e8eb177a326700066e7c98269e078", "save_path": "github-repos/lean/skbaek-omega", "path": "github-repos/lean/skbaek-omega/omega-715e384ed14e8eb177a326700066e7c98269e078/nat/sub_elim.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186768138228, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4909549875154424}}
{"text": "/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Paul Lezeau\n\n! This file was ported from Lean 3 source module number_theory.kummer_dedekind\n! leanprover-community/mathlib commit f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.RingTheory.AlgebraTower\nimport Mathbin.RingTheory.DedekindDomain.Ideal\nimport Mathbin.RingTheory.IsAdjoinRoot\n\n/-!\n# Kummer-Dedekind theorem\n\nThis file proves the monogenic version of the Kummer-Dedekind theorem on the splitting of prime\nideals in an extension of the ring of integers. This states that if `I` is a prime ideal of\nDedekind domain `R` and `S = R[α]` for some `α` that is integral over `R` with minimal polynomial\n`f`, then the prime factorisations of `I * S` and `f mod I` have the same shape, i.e. they have the\nsame number of prime factors, and each prime factors of `I * S` can be paired with a prime factor\nof `f mod I` in a way that ensures multiplicities match (in fact, this pairing can be made explicit\nwith a formula).\n\n## Main definitions\n\n * `normalized_factors_map_equiv_normalized_factors_min_poly_mk` : The bijection in the\n    Kummer-Dedekind theorem. This is the pairing between the prime factors of `I * S` and the prime\n    factors of `f mod I`.\n\n## Main results\n\n * `normalized_factors_ideal_map_eq_normalized_factors_min_poly_mk_map` : The Kummer-Dedekind\n    theorem.\n * `ideal.irreducible_map_of_irreducible_minpoly` : `I.map (algebra_map R S)` is irreducible if\n    `(map I^.quotient.mk (minpoly R pb.gen))` is irreducible, where `pb` is a power basis of `S`\n    over `R`.\n\n## TODO\n\n * Prove the Kummer-Dedekind theorem in full generality.\n\n * Prove the converse of `ideal.irreducible_map_of_irreducible_minpoly`.\n\n * Prove that `normalized_factors_map_equiv_normalized_factors_min_poly_mk` can be expressed as\n    `normalized_factors_map_equiv_normalized_factors_min_poly_mk g = ⟨I, G(α)⟩` for `g` a prime\n    factor of `f mod I` and `G` a lift of `g` to `R[X]`.\n\n## References\n\n * [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]\n\n## Tags\n\nkummer, dedekind, kummer dedekind, dedekind-kummer, dedekind kummer\n-/\n\n\nvariable (R : Type _) {S : Type _} [CommRing R] [CommRing S] [Algebra R S]\n\nopen Ideal Polynomial DoubleQuot UniqueFactorizationMonoid Algebra RingHom\n\n-- mathport name: «expr < >»\nlocal notation:max R \"<\" x \">\" => adjoin R ({x} : Set S)\n\n/-- Let `S / R` be a ring extension and `x : S`, then the conductor of `R<x>` is the\n    biggest ideal of `S` contained in `R<x>`. -/\ndef conductor (x : S) : Ideal S\n    where\n  carrier := { a | ∀ b : S, a * b ∈ R<x> }\n  zero_mem' b := by simpa only [MulZeroClass.zero_mul] using Subalgebra.zero_mem _\n  add_mem' a b ha hb c := by simpa only [add_mul] using Subalgebra.add_mem _ (ha c) (hb c)\n  smul_mem' c a ha b := by simpa only [smul_eq_mul, mul_left_comm, mul_assoc] using ha (c * b)\n#align conductor conductor\n\nvariable {R} {x : S}\n\ntheorem conductor_eq_of_eq {y : S} (h : (R<x> : Set S) = R<y>) : conductor R x = conductor R y :=\n  Ideal.ext fun a => forall_congr' fun b => Set.ext_iff.mp h _\n#align conductor_eq_of_eq conductor_eq_of_eq\n\ntheorem conductor_subset_adjoin : (conductor R x : Set S) ⊆ R<x> := fun y hy => by\n  simpa only [mul_one] using hy 1\n#align conductor_subset_adjoin conductor_subset_adjoin\n\ntheorem mem_conductor_iff {y : S} : y ∈ conductor R x ↔ ∀ b : S, y * b ∈ R<x> :=\n  ⟨fun h => h, fun h => h⟩\n#align mem_conductor_iff mem_conductor_iff\n\ntheorem conductor_eq_top_of_adjoin_eq_top (h : R<x> = ⊤) : conductor R x = ⊤ := by\n  simp only [Ideal.eq_top_iff_one, mem_conductor_iff, h, mem_top, forall_const]\n#align conductor_eq_top_of_adjoin_eq_top conductor_eq_top_of_adjoin_eq_top\n\ntheorem conductor_eq_top_of_powerBasis (pb : PowerBasis R S) : conductor R pb.gen = ⊤ :=\n  conductor_eq_top_of_adjoin_eq_top pb.adjoin_gen_eq_top\n#align conductor_eq_top_of_power_basis conductor_eq_top_of_powerBasis\n\nvariable {I : Ideal R}\n\n/-- This technical lemma tell us that if `C` is the conductor of `R<x>` and `I` is an ideal of `R`\n  then `p * (I * S) ⊆ I * R<x>` for any `p` in `C ∩ R` -/\ntheorem prod_mem_ideal_map_of_mem_conductor {p : R} {z : S}\n    (hp : p ∈ Ideal.comap (algebraMap R S) (conductor R x)) (hz' : z ∈ I.map (algebraMap R S)) :\n    algebraMap R S p * z ∈ algebraMap R<x> S '' ↑(I.map (algebraMap R R<x>)) :=\n  by\n  rw [Ideal.map, Ideal.span, Finsupp.mem_span_image_iff_total] at hz'\n  obtain ⟨l, H, H'⟩ := hz'\n  rw [Finsupp.total_apply] at H'\n  rw [← H', mul_comm, Finsupp.sum_mul]\n  have lem :\n    ∀ {a : R},\n      a ∈ I →\n        l a • algebraMap R S a * algebraMap R S p ∈\n          algebraMap R<x> S '' I.map (algebraMap R R<x>) :=\n    by\n    intro a ha\n    rw [Algebra.id.smul_eq_mul, mul_assoc, mul_comm, mul_assoc, Set.mem_image]\n    refine'\n      Exists.intro\n        (algebraMap R R<x> a * ⟨l a * algebraMap R S p, show l a * algebraMap R S p ∈ R<x> from _⟩)\n        _\n    · rw [mul_comm]\n      exact mem_conductor_iff.mp (ideal.mem_comap.mp hp) _\n    refine' ⟨_, by simpa only [RingHom.map_mul, mul_comm (algebraMap R S p) (l a)] ⟩\n    rw [mul_comm]\n    apply Ideal.mul_mem_left (I.map (algebraMap R R<x>)) _ (Ideal.mem_map_of_mem _ ha)\n  refine'\n    Finset.sum_induction _ (fun u => u ∈ algebraMap R<x> S '' I.map (algebraMap R R<x>))\n      (fun a b => _) _ _\n  rintro ⟨z, hz, rfl⟩ ⟨y, hy, rfl⟩\n  rw [← RingHom.map_add]\n  exact ⟨z + y, Ideal.add_mem _ (set_like.mem_coe.mp hz) hy, rfl⟩\n  · refine' ⟨0, set_like.mem_coe.mpr <| Ideal.zero_mem _, RingHom.map_zero _⟩\n  · intro y hy\n    exact lem ((Finsupp.mem_supported _ l).mp H hy)\n#align prod_mem_ideal_map_of_mem_conductor prod_mem_ideal_map_of_mem_conductor\n\n/-- A technical result telling us that `(I * S) ∩ R<x> = I * R<x>` for any ideal `I` of `R`. -/\ntheorem comap_map_eq_map_adjoin_of_coprime_conductor\n    (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)\n    (h_alg : Function.Injective (algebraMap R<x> S)) :\n    (I.map (algebraMap R S)).comap (algebraMap R<x> S) = I.map (algebraMap R R<x>) :=\n  by\n  apply le_antisymm\n  · -- This is adapted from [Neukirch1992]. Let `C = (conductor R x)`. The idea of the proof\n    -- is that since `I` and `C ∩ R` are coprime, we have\n    -- `(I * S) ∩ R<x> ⊆ (I + C) * ((I * S) ∩ R<x>) ⊆ I * R<x> + I * C * S ⊆ I * R<x>`.\n    intro y hy\n    obtain ⟨z, hz⟩ := y\n    obtain ⟨p, hp, q, hq, hpq⟩ := submodule.mem_sup.mp ((Ideal.eq_top_iff_one _).mp hx)\n    have temp : algebraMap R S p * z + algebraMap R S q * z = z := by\n      simp only [← add_mul, ← RingHom.map_add (algebraMap R S), hpq, map_one, one_mul]\n    suffices\n      z ∈ algebraMap R<x> S '' I.map (algebraMap R R<x>) ↔\n        (⟨z, hz⟩ : R<x>) ∈ I.map (algebraMap R R<x>)\n      by\n      rw [← this, ← temp]\n      obtain ⟨a, ha⟩ :=\n        (Set.mem_image _ _ _).mp\n          (prod_mem_ideal_map_of_mem_conductor hp\n            (show z ∈ I.map (algebraMap R S) by rwa [Ideal.mem_comap] at hy))\n      use a + algebraMap R R<x> q * ⟨z, hz⟩\n      refine'\n        ⟨Ideal.add_mem (I.map (algebraMap R R<x>)) ha.left _, by\n          simpa only [ha.right, map_add, AlgHom.map_mul, add_right_inj] ⟩\n      rw [mul_comm]\n      exact Ideal.mul_mem_left (I.map (algebraMap R R<x>)) _ (Ideal.mem_map_of_mem _ hq)\n    refine'\n      ⟨fun h => _, fun h => (Set.mem_image _ _ _).mpr (Exists.intro ⟨z, hz⟩ ⟨by simp [h], rfl⟩)⟩\n    · obtain ⟨x₁, hx₁, hx₂⟩ := (Set.mem_image _ _ _).mp h\n      have : x₁ = ⟨z, hz⟩ := by\n        apply h_alg\n        simpa [hx₂]\n      rwa [← this]\n  · -- The converse inclusion is trivial\n    have : algebraMap R S = (algebraMap _ S).comp (algebraMap R R<x>) :=\n      by\n      ext\n      rfl\n    rw [this, ← Ideal.map_map]\n    apply Ideal.le_comap_map\n#align comap_map_eq_map_adjoin_of_coprime_conductor comap_map_eq_map_adjoin_of_coprime_conductor\n\n/-- The canonical morphism of rings from `R<x> ⧸ (I*R<x>)` to `S ⧸ (I*S)` is an isomorphism\n    when `I` and `(conductor R x) ∩ R` are coprime. -/\nnoncomputable def quotAdjoinEquivQuotMap (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)\n    (h_alg : Function.Injective (algebraMap R<x> S)) :\n    R<x> ⧸ I.map (algebraMap R R<x>) ≃+* S ⧸ I.map (algebraMap R S) :=\n  RingEquiv.ofBijective\n    (Ideal.Quotient.lift (I.map (algebraMap R R<x>))\n      ((I.map (algebraMap R S)).Quotient.mk.comp (algebraMap R<x> S)) fun r hr =>\n      by\n      have : algebraMap R S = (algebraMap R<x> S).comp (algebraMap R R<x>) :=\n        by\n        ext\n        rfl\n      rw [RingHom.comp_apply, Ideal.Quotient.eq_zero_iff_mem, this, ← Ideal.map_map]\n      exact Ideal.mem_map_of_mem _ hr)\n    (by\n      constructor\n      · --the kernel of the map is clearly `(I * S) ∩ R<x>`. To get injectivity, we need to show that\n        --this is contained in `I * R<x>`, which is the content of the previous lemma.\n        refine' RingHom.lift_injective_of_ker_le_ideal _ _ fun u hu => _\n        rwa [RingHom.mem_ker, RingHom.comp_apply, Ideal.Quotient.eq_zero_iff_mem, ← Ideal.mem_comap,\n          comap_map_eq_map_adjoin_of_coprime_conductor hx h_alg] at hu\n      · -- Surjectivity follows from the surjectivity of the canonical map `R<x> → S ⧸ (I * S)`,\n        -- which in turn follows from the fact that `I * S + (conductor R x) = S`.\n        refine' Ideal.Quotient.lift_surjective_of_surjective _ _ fun y => _\n        obtain ⟨z, hz⟩ := Ideal.Quotient.mk_surjective y\n        have : z ∈ conductor R x ⊔ I.map (algebraMap R S) :=\n          by\n          suffices conductor R x ⊔ I.map (algebraMap R S) = ⊤ by simp only [this]\n          rw [Ideal.eq_top_iff_one] at hx⊢\n          replace hx := Ideal.mem_map_of_mem (algebraMap R S) hx\n          rw [Ideal.map_sup, RingHom.map_one] at hx\n          exact\n            (sup_le_sup\n                (show ((conductor R x).comap (algebraMap R S)).map (algebraMap R S) ≤ conductor R x\n                  from Ideal.map_comap_le)\n                (le_refl (I.map (algebraMap R S))))\n              hx\n        rw [← Ideal.mem_quotient_iff_mem_sup, hz, Ideal.mem_map_iff_of_surjective] at this\n        obtain ⟨u, hu, hu'⟩ := this\n        use ⟨u, conductor_subset_adjoin hu⟩\n        simpa only [← hu']\n        · exact Ideal.Quotient.mk_surjective)\n#align quot_adjoin_equiv_quot_map quotAdjoinEquivQuotMap\n\n@[simp]\ntheorem quotAdjoinEquivQuotMap_apply_mk (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)\n    (h_alg : Function.Injective (algebraMap R<x> S)) (a : R<x>) :\n    quotAdjoinEquivQuotMap hx h_alg ((I.map (algebraMap R R<x>)).Quotient.mk a) =\n      (I.map (algebraMap R S)).Quotient.mk ↑a :=\n  rfl\n#align quot_adjoin_equiv_quot_map_apply_mk quotAdjoinEquivQuotMap_apply_mk\n\nnamespace KummerDedekind\n\nopen BigOperators Polynomial Classical\n\nvariable [IsDomain R] [IsIntegrallyClosed R]\n\nvariable [IsDomain S] [IsDedekindDomain S]\n\nvariable [NoZeroSMulDivisors R S]\n\nattribute [local instance] Ideal.Quotient.field\n\n/-- The first half of the **Kummer-Dedekind Theorem** in the monogenic case, stating that the prime\n    factors of `I*S` are in bijection with those of the minimal polynomial of the generator of `S`\n    over `R`, taken `mod I`.-/\nnoncomputable def normalizedFactorsMapEquivNormalizedFactorsMinPolyMk (hI : IsMaximal I)\n    (hI' : I ≠ ⊥) (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) :\n    { J : Ideal S | J ∈ normalizedFactors (I.map (algebraMap R S)) } ≃\n      { d : (R ⧸ I)[X] | d ∈ normalizedFactors (map I.Quotient.mk (minpoly R x)) } :=\n  (normalizedFactorsEquivOfQuotEquiv\n        ((quotAdjoinEquivQuotMap hx\n                (by\n                  apply NoZeroSMulDivisors.algebraMap_injective (Algebra.adjoin R {x}) S\n                  exact Subalgebra.noZeroSMulDivisors_top (Algebra.adjoin R {x}))).symm.trans\n          (((Algebra.adjoin.powerBasis' hx').quotientEquivQuotientMinpolyMap I).toRingEquiv.trans\n            (quotEquivOfEq\n              (show\n                Ideal.span {(minpoly R (Algebra.adjoin.powerBasis' hx').gen).map I.Quotient.mk} =\n                  Ideal.span {(minpoly R x).map I.Quotient.mk}\n                by rw [Algebra.adjoin.powerBasis'_minpoly_gen hx']))))\n        (--show that `I * S` ≠ ⊥\n        show I.map (algebraMap R S) ≠ ⊥ by\n          rwa [Ne.def, map_eq_bot_iff_of_injective (NoZeroSMulDivisors.algebraMap_injective R S), ←\n            Ne.def])\n        (--show that the ideal spanned by `(minpoly R pb.gen) mod I` is non-zero\n        by\n          by_contra\n          exact\n            (show map I.Quotient.mk (minpoly R x) ≠ 0 from\n                Polynomial.map_monic_ne_zero (minpoly.monic hx'))\n              (span_singleton_eq_bot.mp h))).trans\n    (normalizedFactorsEquivSpanNormalizedFactors\n        (show map I.Quotient.mk (minpoly R x) ≠ 0 from\n          Polynomial.map_monic_ne_zero (minpoly.monic hx'))).symm\n#align kummer_dedekind.normalized_factors_map_equiv_normalized_factors_min_poly_mk KummerDedekind.normalizedFactorsMapEquivNormalizedFactorsMinPolyMk\n\n/-- The second half of the **Kummer-Dedekind Theorem** in the monogenic case, stating that the\n    bijection `factors_equiv'` defined in the first half preserves multiplicities. -/\ntheorem multiplicity_factors_map_eq_multiplicity (hI : IsMaximal I) (hI' : I ≠ ⊥)\n    (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) {J : Ideal S}\n    (hJ : J ∈ normalizedFactors (I.map (algebraMap R S))) :\n    multiplicity J (I.map (algebraMap R S)) =\n      multiplicity (↑(normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx' ⟨J, hJ⟩))\n        (map I.Quotient.mk (minpoly R x)) :=\n  by\n  rw [normalized_factors_map_equiv_normalized_factors_min_poly_mk, Equiv.coe_trans,\n    Function.comp_apply,\n    multiplicity_normalizedFactorsEquivSpanNormalizedFactors_symm_eq_multiplicity,\n    normalizedFactorsEquivOfQuotEquiv_multiplicity_eq_multiplicity]\n#align kummer_dedekind.multiplicity_factors_map_eq_multiplicity KummerDedekind.multiplicity_factors_map_eq_multiplicity\n\n/-- The **Kummer-Dedekind Theorem**. -/\ntheorem normalizedFactors_ideal_map_eq_normalizedFactors_min_poly_mk_map (hI : IsMaximal I)\n    (hI' : I ≠ ⊥) (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) :\n    normalizedFactors (I.map (algebraMap R S)) =\n      Multiset.map\n        (fun f =>\n          ((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx').symm f : Ideal S))\n        (normalizedFactors (Polynomial.map I.Quotient.mk (minpoly R x))).attach :=\n  by\n  ext J\n  -- WLOG, assume J is a normalized factor\n  by_cases hJ : J ∈ normalized_factors (I.map (algebraMap R S))\n  swap\n  · rw [multiset.count_eq_zero.mpr hJ, eq_comm, Multiset.count_eq_zero, Multiset.mem_map]\n    simp only [Multiset.mem_attach, true_and_iff, not_exists]\n    rintro J' rfl\n    exact\n      hJ ((normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx').symm J').Prop\n  -- Then we just have to compare the multiplicities, which we already proved are equal.\n  have := multiplicity_factors_map_eq_multiplicity hI hI' hx hx' hJ\n  rw [multiplicity_eq_count_normalized_factors, multiplicity_eq_count_normalized_factors,\n    UniqueFactorizationMonoid.normalize_normalized_factor _ hJ,\n    UniqueFactorizationMonoid.normalize_normalized_factor, PartENat.natCast_inj] at this\n  refine' this.trans _\n  -- Get rid of the `map` by applying the equiv to both sides.\n  generalize hJ' :\n    (normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx') ⟨J, hJ⟩ = J'\n  have :\n    ((normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx').symm J' :\n        Ideal S) =\n      J :=\n    by rw [← hJ', Equiv.symm_apply_apply _ _, Subtype.coe_mk]\n  subst this\n  -- Get rid of the `attach` by applying the subtype `coe` to both sides.\n  rw [Multiset.count_map_eq_count' fun f =>\n      ((normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx').symm f :\n        Ideal S),\n    Multiset.attach_count_eq_count_coe]\n  · exact subtype.coe_injective.comp (Equiv.injective _)\n  · exact (normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx' _).Prop\n  ·\n    exact\n      irreducible_of_normalized_factor _\n        (normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx' _).Prop\n  · exact Polynomial.map_monic_ne_zero (minpoly.monic hx')\n  · exact irreducible_of_normalized_factor _ hJ\n  ·\n    rwa [← bot_eq_zero, Ne.def,\n      map_eq_bot_iff_of_injective (NoZeroSMulDivisors.algebraMap_injective R S)]\n#align kummer_dedekind.normalized_factors_ideal_map_eq_normalized_factors_min_poly_mk_map KummerDedekind.normalizedFactors_ideal_map_eq_normalizedFactors_min_poly_mk_map\n\ntheorem Ideal.irreducible_map_of_irreducible_minpoly (hI : IsMaximal I) (hI' : I ≠ ⊥)\n    (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x)\n    (hf : Irreducible (map I.Quotient.mk (minpoly R x))) : Irreducible (I.map (algebraMap R S)) :=\n  by\n  have mem_norm_factors :\n    normalize (map I.Quotient.mk (minpoly R x)) ∈\n      normalized_factors (map I.Quotient.mk (minpoly R x)) :=\n    by simp [normalized_factors_irreducible hf]\n  suffices ∃ y, normalized_factors (I.map (algebraMap R S)) = {y}\n    by\n    obtain ⟨y, hy⟩ := this\n    have h :=\n      normalized_factors_prod\n        (show I.map (algebraMap R S) ≠ 0 by\n          rwa [← bot_eq_zero, Ne.def,\n            map_eq_bot_iff_of_injective (NoZeroSMulDivisors.algebraMap_injective R S)])\n    rw [associated_iff_eq, hy, Multiset.prod_singleton] at h\n    rw [← h]\n    exact\n      irreducible_of_normalized_factor y\n        (show y ∈ normalized_factors (I.map (algebraMap R S)) by simp [hy])\n  rw [normalized_factors_ideal_map_eq_normalized_factors_min_poly_mk_map hI hI' hx hx']\n  use\n    ((normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx').symm\n        ⟨normalize (map I.Quotient.mk (minpoly R x)), mem_norm_factors⟩ :\n      Ideal S)\n  rw [Multiset.map_eq_singleton]\n  use ⟨normalize (map I.Quotient.mk (minpoly R x)), mem_norm_factors⟩\n  refine' ⟨_, rfl⟩\n  apply Multiset.map_injective Subtype.coe_injective\n  rw [Multiset.attach_map_val, Multiset.map_singleton, Subtype.coe_mk]\n  exact normalized_factors_irreducible hf\n#align kummer_dedekind.ideal.irreducible_map_of_irreducible_minpoly KummerDedekind.Ideal.irreducible_map_of_irreducible_minpoly\n\nend KummerDedekind\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/NumberTheory/KummerDedekind.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.4909456580179879}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module order.zorn\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Chain\n\n/-!\n# Zorn's lemmas\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves several formulations of Zorn's Lemma.\n\n## Variants\n\nThe primary statement of Zorn's lemma is `exists_maximal_of_chains_bounded`. Then it is specialized\nto particular relations:\n* `(≤)` with `zorn_partial_order`\n* `(⊆)` with `zorn_subset`\n* `(⊇)` with `zorn_superset`\n\nLemma names carry modifiers:\n* `₀`: Quantifies over a set, as opposed to over a type.\n* `_nonempty`: Doesn't ask to prove that the empty chain is bounded and lets you give an element\n  that will be smaller than the maximal element found (the maximal element is no smaller than any\n  other element, but it can also be incomparable to some).\n\n## How-to\n\nThis file comes across as confusing to those who haven't yet used it, so here is a detailed\nwalkthrough:\n1. Know what relation on which type/set you're looking for. See Variants above. You can discharge\n  some conditions to Zorn's lemma directly using a `_nonempty` variant.\n2. Write down the definition of your type/set, put a `suffices : ∃ m, ∀ a, m ≺ a → a ≺ m, { ... },`\n  (or whatever you actually need) followed by a `apply some_version_of_zorn`.\n3. Fill in the details. This is where you start talking about chains.\n\nA typical proof using Zorn could look like this\n```lean\nlemma zorny_lemma : zorny_statement :=\nbegin\n  let s : set α := {x | whatever x},\n  suffices : ∃ x ∈ s, ∀ y ∈ s, y ⊆ x → y = x, -- or with another operator\n  { exact proof_post_zorn },\n  apply zorn_subset, -- or another variant\n  rintro c hcs hc,\n  obtain rfl | hcnemp := c.eq_empty_or_nonempty, -- you might need to disjunct on c empty or not\n  { exact ⟨edge_case_construction,\n      proof_that_edge_case_construction_respects_whatever,\n      proof_that_edge_case_construction_contains_all_stuff_in_c⟩ },\n  exact ⟨construction,\n    proof_that_construction_respects_whatever,\n    proof_that_construction_contains_all_stuff_in_c⟩,\nend\n```\n\n## Notes\n\nOriginally ported from Isabelle/HOL. The\n[original file](https://isabelle.in.tum.de/dist/library/HOL/HOL/Zorn.html) was written by Jacques D.\nFleuriot, Tobias Nipkow, Christian Sternagel.\n-/\n\n\nopen Classical Set\n\nvariable {α β : Type _} {r : α → α → Prop} {c : Set α}\n\n-- mathport name: «expr ≺ »\nlocal infixl:50 \" ≺ \" => r\n\n#print exists_maximal_of_chains_bounded /-\n/-- **Zorn's lemma**\n\nIf every chain has an upper bound, then there exists a maximal element. -/\ntheorem exists_maximal_of_chains_bounded (h : ∀ c, IsChain r c → ∃ ub, ∀ a ∈ c, a ≺ ub)\n    (trans : ∀ {a b c}, a ≺ b → b ≺ c → a ≺ c) : ∃ m, ∀ a, m ≺ a → a ≺ m :=\n  have : ∃ ub, ∀ a ∈ maxChain r, a ≺ ub := h _ <| maxChain_spec.left\n  let ⟨ub, (hub : ∀ a ∈ maxChain r, a ≺ ub)⟩ := this\n  ⟨ub, fun a ha =>\n    have : IsChain r (insert a <| maxChain r) :=\n      maxChain_spec.1.insert fun b hb _ => Or.inr <| trans (hub b hb) ha\n    hub a <| by\n      rw [max_chain_spec.right this (subset_insert _ _)]\n      exact mem_insert _ _⟩\n#align exists_maximal_of_chains_bounded exists_maximal_of_chains_bounded\n-/\n\n#print exists_maximal_of_nonempty_chains_bounded /-\n/-- A variant of Zorn's lemma. If every nonempty chain of a nonempty type has an upper bound, then\nthere is a maximal element.\n-/\ntheorem exists_maximal_of_nonempty_chains_bounded [Nonempty α]\n    (h : ∀ c, IsChain r c → c.Nonempty → ∃ ub, ∀ a ∈ c, a ≺ ub)\n    (trans : ∀ {a b c}, a ≺ b → b ≺ c → a ≺ c) : ∃ m, ∀ a, m ≺ a → a ≺ m :=\n  exists_maximal_of_chains_bounded\n    (fun c hc =>\n      (eq_empty_or_nonempty c).elim\n        (fun h => ⟨Classical.arbitrary α, fun x hx => (h ▸ hx : x ∈ (∅ : Set α)).elim⟩) (h c hc))\n    fun a b c => trans\n#align exists_maximal_of_nonempty_chains_bounded exists_maximal_of_nonempty_chains_bounded\n-/\n\nsection Preorder\n\nvariable [Preorder α]\n\n#print zorn_preorder /-\ntheorem zorn_preorder (h : ∀ c : Set α, IsChain (· ≤ ·) c → BddAbove c) :\n    ∃ m : α, ∀ a, m ≤ a → a ≤ m :=\n  exists_maximal_of_chains_bounded h fun a b c => le_trans\n#align zorn_preorder zorn_preorder\n-/\n\n#print zorn_nonempty_preorder /-\ntheorem zorn_nonempty_preorder [Nonempty α]\n    (h : ∀ c : Set α, IsChain (· ≤ ·) c → c.Nonempty → BddAbove c) : ∃ m : α, ∀ a, m ≤ a → a ≤ m :=\n  exists_maximal_of_nonempty_chains_bounded h fun a b c => le_trans\n#align zorn_nonempty_preorder zorn_nonempty_preorder\n-/\n\n/- warning: zorn_preorder₀ -> zorn_preorder₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) c s) -> (IsChain.{u1} α (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1)) c) -> (Exists.{succ u1} α (fun (ub : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) => forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z ub))))) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) => forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) m z) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z m))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) c s) -> (IsChain.{u1} α (fun (x._@.Mathlib.Order.Zorn._hyg.862 : α) (x._@.Mathlib.Order.Zorn._hyg.864 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) x._@.Mathlib.Order.Zorn._hyg.862 x._@.Mathlib.Order.Zorn._hyg.864) c) -> (Exists.{succ u1} α (fun (ub : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) ub s) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z ub))))) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) m s) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) m z) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z m))))\nCase conversion may be inaccurate. Consider using '#align zorn_preorder₀ zorn_preorder₀ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » s) -/\ntheorem zorn_preorder₀ (s : Set α)\n    (ih : ∀ (c) (_ : c ⊆ s), IsChain (· ≤ ·) c → ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) :\n    ∃ m ∈ s, ∀ z ∈ s, m ≤ z → z ≤ m :=\n  let ⟨⟨m, hms⟩, h⟩ :=\n    @zorn_preorder s _ fun c hc =>\n      let ⟨ub, hubs, hub⟩ :=\n        ih (Subtype.val '' c) (fun _ ⟨⟨x, hx⟩, _, h⟩ => h ▸ hx)\n          (by\n            rintro _ ⟨p, hpc, rfl⟩ _ ⟨q, hqc, rfl⟩ hpq <;>\n              refine' hc hpc hqc fun t => hpq (Subtype.ext_iff.1 t))\n      ⟨⟨ub, hubs⟩, fun ⟨y, hy⟩ hc => hub _ ⟨_, hc, rfl⟩⟩\n  ⟨m, hms, fun z hzs hmz => h ⟨z, hzs⟩ hmz⟩\n#align zorn_preorder₀ zorn_preorder₀\n\n/- warning: zorn_nonempty_preorder₀ -> zorn_nonempty_preorder₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) c s) -> (IsChain.{u1} α (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1)) c) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y c) -> (Exists.{succ u1} α (fun (ub : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) => forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z ub)))))) -> (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) => And (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) x m) (forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) m z) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z m))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) c s) -> (IsChain.{u1} α (fun (x._@.Mathlib.Order.Zorn._hyg.1178 : α) (x._@.Mathlib.Order.Zorn._hyg.1180 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) x._@.Mathlib.Order.Zorn._hyg.1178 x._@.Mathlib.Order.Zorn._hyg.1180) c) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y c) -> (Exists.{succ u1} α (fun (ub : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) ub s) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z ub)))))) -> (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) m s) (And (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) x m) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) m z) -> (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) z m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_nonempty_preorder₀ zorn_nonempty_preorder₀ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » s) -/\ntheorem zorn_nonempty_preorder₀ (s : Set α)\n    (ih : ∀ (c) (_ : c ⊆ s), IsChain (· ≤ ·) c → ∀ y ∈ c, ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) (x : α)\n    (hxs : x ∈ s) : ∃ m ∈ s, x ≤ m ∧ ∀ z ∈ s, m ≤ z → z ≤ m :=\n  by\n  rcases zorn_preorder₀ ({ y ∈ s | x ≤ y }) fun c hcs hc => _ with ⟨m, ⟨hms, hxm⟩, hm⟩\n  · exact ⟨m, hms, hxm, fun z hzs hmz => hm _ ⟨hzs, hxm.trans hmz⟩ hmz⟩\n  · rcases c.eq_empty_or_nonempty with (rfl | ⟨y, hy⟩)\n    · exact ⟨x, ⟨hxs, le_rfl⟩, fun z => False.elim⟩\n    · rcases ih c (fun z hz => (hcs hz).1) hc y hy with ⟨z, hzs, hz⟩\n      exact ⟨z, ⟨hzs, (hcs hy).2.trans <| hz _ hy⟩, hz⟩\n#align zorn_nonempty_preorder₀ zorn_nonempty_preorder₀\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » Ici[set.Ici] a) -/\n#print zorn_nonempty_Ici₀ /-\ntheorem zorn_nonempty_Ici₀ (a : α)\n    (ih : ∀ (c) (_ : c ⊆ Ici a), IsChain (· ≤ ·) c → ∀ y ∈ c, ∃ ub, a ≤ ub ∧ ∀ z ∈ c, z ≤ ub)\n    (x : α) (hax : a ≤ x) : ∃ m, x ≤ m ∧ ∀ z, m ≤ z → z ≤ m :=\n  let ⟨m, hma, hxm, hm⟩ := zorn_nonempty_preorder₀ (Ici a) (by simpa using ih) x hax\n  ⟨m, hxm, fun z hmz => hm _ (hax.trans <| hxm.trans hmz) hmz⟩\n#align zorn_nonempty_Ici₀ zorn_nonempty_Ici₀\n-/\n\nend Preorder\n\nsection PartialOrder\n\nvariable [PartialOrder α]\n\n#print zorn_partialOrder /-\ntheorem zorn_partialOrder (h : ∀ c : Set α, IsChain (· ≤ ·) c → BddAbove c) :\n    ∃ m : α, ∀ a, m ≤ a → a = m :=\n  let ⟨m, hm⟩ := zorn_preorder h\n  ⟨m, fun a ha => le_antisymm (hm a ha) ha⟩\n#align zorn_partial_order zorn_partialOrder\n-/\n\n#print zorn_nonempty_partialOrder /-\ntheorem zorn_nonempty_partialOrder [Nonempty α]\n    (h : ∀ c : Set α, IsChain (· ≤ ·) c → c.Nonempty → BddAbove c) : ∃ m : α, ∀ a, m ≤ a → a = m :=\n  let ⟨m, hm⟩ := zorn_nonempty_preorder h\n  ⟨m, fun a ha => le_antisymm (hm a ha) ha⟩\n#align zorn_nonempty_partial_order zorn_nonempty_partialOrder\n-/\n\n/- warning: zorn_partial_order₀ -> zorn_partialOrder₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) c s) -> (IsChain.{u1} α (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1))) c) -> (Exists.{succ u1} α (fun (ub : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) => forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) z ub))))) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) => forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) m z) -> (Eq.{succ u1} α z m))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) c s) -> (IsChain.{u1} α (fun (x._@.Mathlib.Order.Zorn._hyg.1874 : α) (x._@.Mathlib.Order.Zorn._hyg.1876 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) x._@.Mathlib.Order.Zorn._hyg.1874 x._@.Mathlib.Order.Zorn._hyg.1876) c) -> (Exists.{succ u1} α (fun (ub : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) ub s) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) z ub))))) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) m s) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) m z) -> (Eq.{succ u1} α z m))))\nCase conversion may be inaccurate. Consider using '#align zorn_partial_order₀ zorn_partialOrder₀ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » s) -/\ntheorem zorn_partialOrder₀ (s : Set α)\n    (ih : ∀ (c) (_ : c ⊆ s), IsChain (· ≤ ·) c → ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) :\n    ∃ m ∈ s, ∀ z ∈ s, m ≤ z → z = m :=\n  let ⟨m, hms, hm⟩ := zorn_preorder₀ s ih\n  ⟨m, hms, fun z hzs hmz => (hm z hzs hmz).antisymm hmz⟩\n#align zorn_partial_order₀ zorn_partialOrder₀\n\n/- warning: zorn_nonempty_partial_order₀ -> zorn_nonempty_partialOrder₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) c s) -> (IsChain.{u1} α (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1))) c) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y c) -> (Exists.{succ u1} α (fun (ub : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) ub s) => forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) z ub)))))) -> (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) m s) => And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) x m) (forall (z : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) m z) -> (Eq.{succ u1} α z m))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] (s : Set.{u1} α), (forall (c : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) c s) -> (IsChain.{u1} α (fun (x._@.Mathlib.Order.Zorn._hyg.2042 : α) (x._@.Mathlib.Order.Zorn._hyg.2044 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) x._@.Mathlib.Order.Zorn._hyg.2042 x._@.Mathlib.Order.Zorn._hyg.2044) c) -> (forall (y : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y c) -> (Exists.{succ u1} α (fun (ub : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) ub s) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) z ub)))))) -> (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) m s) (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) x m) (forall (z : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)) m z) -> (Eq.{succ u1} α z m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_nonempty_partial_order₀ zorn_nonempty_partialOrder₀ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » s) -/\ntheorem zorn_nonempty_partialOrder₀ (s : Set α)\n    (ih : ∀ (c) (_ : c ⊆ s), IsChain (· ≤ ·) c → ∀ y ∈ c, ∃ ub ∈ s, ∀ z ∈ c, z ≤ ub) (x : α)\n    (hxs : x ∈ s) : ∃ m ∈ s, x ≤ m ∧ ∀ z ∈ s, m ≤ z → z = m :=\n  let ⟨m, hms, hxm, hm⟩ := zorn_nonempty_preorder₀ s ih x hxs\n  ⟨m, hms, hxm, fun z hzs hmz => (hm z hzs hmz).antisymm hmz⟩\n#align zorn_nonempty_partial_order₀ zorn_nonempty_partialOrder₀\n\nend PartialOrder\n\n/- warning: zorn_subset -> zorn_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.hasSubset.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α)) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (ub : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) ub S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) ub S) => forall (s : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s ub))))) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) => forall (a : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) m a) -> (Eq.{succ u1} (Set.{u1} α) a m))))\nbut is expected to have type\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.instHasSubsetSet.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (fun (x._@.Mathlib.Order.Zorn._hyg.2249 : Set.{u1} α) (x._@.Mathlib.Order.Zorn._hyg.2251 : Set.{u1} α) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) x._@.Mathlib.Order.Zorn._hyg.2249 x._@.Mathlib.Order.Zorn._hyg.2251) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (ub : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) ub S) (forall (s : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s ub))))) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) m S) (forall (a : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) m a) -> (Eq.{succ u1} (Set.{u1} α) a m))))\nCase conversion may be inaccurate. Consider using '#align zorn_subset zorn_subsetₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » S) -/\ntheorem zorn_subset (S : Set (Set α))\n    (h : ∀ (c) (_ : c ⊆ S), IsChain (· ⊆ ·) c → ∃ ub ∈ S, ∀ s ∈ c, s ⊆ ub) :\n    ∃ m ∈ S, ∀ a ∈ S, m ⊆ a → a = m :=\n  zorn_partialOrder₀ S h\n#align zorn_subset zorn_subset\n\n/- warning: zorn_subset_nonempty -> zorn_subset_nonempty is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.hasSubset.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α)) c) -> (Set.Nonempty.{u1} (Set.{u1} α) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (ub : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) ub S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) ub S) => forall (s : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s ub))))) -> (forall (x : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) x S) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) => And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) x m) (forall (a : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) m a) -> (Eq.{succ u1} (Set.{u1} α) a m))))))\nbut is expected to have type\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.instHasSubsetSet.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (fun (x._@.Mathlib.Order.Zorn._hyg.2373 : Set.{u1} α) (x._@.Mathlib.Order.Zorn._hyg.2375 : Set.{u1} α) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) x._@.Mathlib.Order.Zorn._hyg.2373 x._@.Mathlib.Order.Zorn._hyg.2375) c) -> (Set.Nonempty.{u1} (Set.{u1} α) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (ub : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) ub S) (forall (s : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s ub))))) -> (forall (x : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) x S) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) m S) (And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) x m) (forall (a : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) m a) -> (Eq.{succ u1} (Set.{u1} α) a m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_subset_nonempty zorn_subset_nonemptyₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » S) -/\ntheorem zorn_subset_nonempty (S : Set (Set α))\n    (H : ∀ (c) (_ : c ⊆ S), IsChain (· ⊆ ·) c → c.Nonempty → ∃ ub ∈ S, ∀ s ∈ c, s ⊆ ub) (x)\n    (hx : x ∈ S) : ∃ m ∈ S, x ⊆ m ∧ ∀ a ∈ S, m ⊆ a → a = m :=\n  zorn_nonempty_partialOrder₀ _ (fun c cS hc y yc => H _ cS hc ⟨y, yc⟩) _ hx\n#align zorn_subset_nonempty zorn_subset_nonempty\n\n/- warning: zorn_superset -> zorn_superset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.hasSubset.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α)) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (lb : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) lb S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) lb S) => forall (s : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) lb s))))) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) => forall (a : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) a m) -> (Eq.{succ u1} (Set.{u1} α) a m))))\nbut is expected to have type\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.instHasSubsetSet.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (fun (x._@.Mathlib.Order.Zorn._hyg.2532 : Set.{u1} α) (x._@.Mathlib.Order.Zorn._hyg.2534 : Set.{u1} α) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) x._@.Mathlib.Order.Zorn._hyg.2532 x._@.Mathlib.Order.Zorn._hyg.2534) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (lb : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) lb S) (forall (s : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) lb s))))) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) m S) (forall (a : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) a m) -> (Eq.{succ u1} (Set.{u1} α) a m))))\nCase conversion may be inaccurate. Consider using '#align zorn_superset zorn_supersetₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » S) -/\ntheorem zorn_superset (S : Set (Set α))\n    (h : ∀ (c) (_ : c ⊆ S), IsChain (· ⊆ ·) c → ∃ lb ∈ S, ∀ s ∈ c, lb ⊆ s) :\n    ∃ m ∈ S, ∀ a ∈ S, a ⊆ m → a = m :=\n  @zorn_partialOrder₀ (Set α)ᵒᵈ _ S fun c cS hc => h c cS hc.symm\n#align zorn_superset zorn_superset\n\n/- warning: zorn_superset_nonempty -> zorn_superset_nonempty is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.hasSubset.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α)) c) -> (Set.Nonempty.{u1} (Set.{u1} α) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (lb : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) lb S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) lb S) => forall (s : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) lb s))))) -> (forall (x : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) x S) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) m S) => And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) m x) (forall (a : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) a m) -> (Eq.{succ u1} (Set.{u1} α) a m))))))\nbut is expected to have type\n  forall {α : Type.{u1}} (S : Set.{u1} (Set.{u1} α)), (forall (c : Set.{u1} (Set.{u1} α)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} α)) (Set.instHasSubsetSet.{u1} (Set.{u1} α)) c S) -> (IsChain.{u1} (Set.{u1} α) (fun (x._@.Mathlib.Order.Zorn._hyg.2674 : Set.{u1} α) (x._@.Mathlib.Order.Zorn._hyg.2676 : Set.{u1} α) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) x._@.Mathlib.Order.Zorn._hyg.2674 x._@.Mathlib.Order.Zorn._hyg.2676) c) -> (Set.Nonempty.{u1} (Set.{u1} α) c) -> (Exists.{succ u1} (Set.{u1} α) (fun (lb : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) lb S) (forall (s : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) lb s))))) -> (forall (x : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) x S) -> (Exists.{succ u1} (Set.{u1} α) (fun (m : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) m S) (And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) m x) (forall (a : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) a m) -> (Eq.{succ u1} (Set.{u1} α) a m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_superset_nonempty zorn_superset_nonemptyₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c «expr ⊆ » S) -/\ntheorem zorn_superset_nonempty (S : Set (Set α))\n    (H : ∀ (c) (_ : c ⊆ S), IsChain (· ⊆ ·) c → c.Nonempty → ∃ lb ∈ S, ∀ s ∈ c, lb ⊆ s) (x)\n    (hx : x ∈ S) : ∃ m ∈ S, m ⊆ x ∧ ∀ a ∈ S, a ⊆ m → a = m :=\n  @zorn_nonempty_partialOrder₀ (Set α)ᵒᵈ _ S (fun c cS hc y yc => H _ cS hc.symm ⟨y, yc⟩) _ hx\n#align zorn_superset_nonempty zorn_superset_nonempty\n\n#print IsChain.exists_maxChain /-\n/-- Every chain is contained in a maximal chain. This generalizes Hausdorff's maximality principle.\n-/\ntheorem IsChain.exists_maxChain (hc : IsChain r c) : ∃ M, @IsMaxChain _ r M ∧ c ⊆ M :=\n  by\n  obtain ⟨M, ⟨_, hM₀⟩, hM₁, hM₂⟩ :=\n    zorn_subset_nonempty { s | c ⊆ s ∧ IsChain r s } _ c ⟨subset.rfl, hc⟩\n  · exact ⟨M, ⟨hM₀, fun d hd hMd => (hM₂ _ ⟨hM₁.trans hMd, hd⟩ hMd).symm⟩, hM₁⟩\n  rintro cs hcs₀ hcs₁ ⟨s, hs⟩\n  refine'\n    ⟨⋃₀ cs, ⟨fun _ ha => Set.mem_unionₛ_of_mem ((hcs₀ hs).left ha) hs, _⟩, fun _ =>\n      Set.subset_unionₛ_of_mem⟩\n  rintro y ⟨sy, hsy, hysy⟩ z ⟨sz, hsz, hzsz⟩ hyz\n  obtain rfl | hsseq := eq_or_ne sy sz\n  · exact (hcs₀ hsy).right hysy hzsz hyz\n  cases' hcs₁ hsy hsz hsseq with h h\n  · exact (hcs₀ hsz).right (h hysy) hzsz hyz\n  · exact (hcs₀ hsy).right hysy (h hzsz) hyz\n#align is_chain.exists_max_chain IsChain.exists_maxChain\n-/\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Zorn.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4909456405054036}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Riccardo Brasca, Johan Commelin, Scott Morrison\n-/\nimport analysis.normed.group.SemiNormedGroup\nimport analysis.normed.group.quotient\nimport category_theory.limits.shapes.kernels\n\n/-!\n# Kernels and cokernels in SemiNormedGroup₁ and SemiNormedGroup\n\nWe show that `SemiNormedGroup₁` has cokernels\n(for which of course the `cokernel.π f` maps are norm non-increasing),\nas well as the easier result that `SemiNormedGroup` has cokernels. We also show that\n`SemiNormedGroup` has kernels.\n\nSo far, I don't see a way to state nicely what we really want:\n`SemiNormedGroup` has cokernels, and `cokernel.π f` is norm non-increasing.\nThe problem is that the limits API doesn't promise you any particular model of the cokernel,\nand in `SemiNormedGroup` one can always take a cokernel and rescale its norm\n(and hence making `cokernel.π f` arbitrarily large in norm), obtaining another categorical cokernel.\n\n-/\n\nopen category_theory category_theory.limits\n\nuniverse u\n\nnamespace SemiNormedGroup₁\n\nnoncomputable theory\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup₁`. -/\ndef cokernel_cocone {X Y : SemiNormedGroup₁.{u}} (f : X ⟶ Y) : cofork f 0 :=\ncofork.of_π\n  (@SemiNormedGroup₁.mk_hom\n    _ (SemiNormedGroup.of (Y ⧸ (normed_group_hom.range f.1)))\n    f.1.range.normed_mk\n    (normed_group_hom.is_quotient_quotient _).norm_le)\n  begin\n    ext,\n    simp only [comp_apply, limits.zero_comp, normed_group_hom.zero_apply,\n      SemiNormedGroup₁.mk_hom_apply, SemiNormedGroup₁.zero_apply, ←normed_group_hom.mem_ker,\n      f.1.range.ker_normed_mk, f.1.mem_range],\n    use x,\n    refl,\n  end\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup₁`. -/\ndef cokernel_lift {X Y : SemiNormedGroup₁.{u}} (f : X ⟶ Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X ⟶ s.X :=\nbegin\n  fsplit,\n  -- The lift itself:\n  { apply normed_group_hom.lift _ s.π.1,\n    rintro _ ⟨b, rfl⟩,\n    change (f ≫ s.π) b = 0,\n    simp, },\n  -- The lift has norm at most one:\n  exact normed_group_hom.lift_norm_noninc _ _ _ s.π.2,\nend\n\ninstance : has_cokernels SemiNormedGroup₁.{u} :=\n{ has_colimit := λ X Y f, has_colimit.mk\n  { cocone := cokernel_cocone f,\n    is_colimit := is_colimit_aux _\n      (cokernel_lift f)\n      (λ s, begin\n        ext,\n        apply normed_group_hom.lift_mk f.1.range,\n        rintro _ ⟨b, rfl⟩,\n        change (f ≫ s.π) b = 0,\n        simp,\n      end)\n      (λ s m w, subtype.eq\n        (normed_group_hom.lift_unique f.1.range _ _ _ (congr_arg subtype.val w : _))), } }\n\n-- Sanity check\nexample : has_cokernels SemiNormedGroup₁ := by apply_instance\n\nend SemiNormedGroup₁\n\nnamespace SemiNormedGroup\n\nsection equalizers_and_kernels\n\n/-- The equalizer cone for a parallel pair of morphisms of seminormed groups. -/\ndef parallel_pair_cone {V W : SemiNormedGroup.{u}} (f g : V ⟶ W) :\n  cone (parallel_pair f g) :=\n@fork.of_ι _ _ _ _ _ _ (of (f - g).ker) (normed_group_hom.incl (f - g).ker) $\nbegin\n  ext v,\n  have : v.1 ∈ (f - g).ker := v.2,\n  simpa only [normed_group_hom.incl_apply, pi.zero_apply, coe_comp, normed_group_hom.coe_zero,\n    subtype.val_eq_coe, normed_group_hom.mem_ker,\n    normed_group_hom.coe_sub, pi.sub_apply, sub_eq_zero] using this\nend\n\ninstance has_limit_parallel_pair {V W : SemiNormedGroup.{u}} (f g : V ⟶ W) :\n  has_limit (parallel_pair f g) :=\n{ exists_limit := nonempty.intro\n  { cone := parallel_pair_cone f g,\n    is_limit := fork.is_limit.mk _\n      (λ c, normed_group_hom.ker.lift (fork.ι c) _ $\n      show normed_group_hom.comp_hom (f - g) c.ι = 0,\n      by { rw [add_monoid_hom.map_sub, add_monoid_hom.sub_apply, sub_eq_zero], exact c.condition })\n      (λ c, normed_group_hom.ker.incl_comp_lift _ _ _)\n      (λ c g h, by { ext x, dsimp, rw ← h, refl }) } }\n\ninstance : limits.has_equalizers.{u (u+1)} SemiNormedGroup :=\n@has_equalizers_of_has_limit_parallel_pair SemiNormedGroup _ $ λ V W f g,\n  SemiNormedGroup.has_limit_parallel_pair f g\n\nend equalizers_and_kernels\n\nsection cokernel\n\n-- PROJECT: can we reuse the work to construct cokernels in `SemiNormedGroup₁` here?\n-- I don't see a way to do this that is less work than just repeating the relevant parts.\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : cofork f 0 :=\n@cofork.of_π _ _ _ _ _ _\n  (SemiNormedGroup.of (Y ⧸ (normed_group_hom.range f)))\n  f.range.normed_mk\n  begin\n    ext,\n    simp only [comp_apply, limits.zero_comp, normed_group_hom.zero_apply,\n      ←normed_group_hom.mem_ker, f.range.ker_normed_mk, f.mem_range, exists_apply_eq_apply],\n  end\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef cokernel_lift {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X ⟶ s.X := normed_group_hom.lift _ s.π\nbegin\n  rintro _ ⟨b, rfl⟩,\n  change (f ≫ s.π) b = 0,\n  simp,\nend\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef is_colimit_cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  is_colimit (cokernel_cocone f) :=\nis_colimit_aux _ (cokernel_lift f)\n(λ s, begin\n  ext,\n  apply normed_group_hom.lift_mk f.range,\n  rintro _ ⟨b, rfl⟩,\n  change (f ≫ s.π) b = 0,\n  simp,\nend)\n(λ s m w, normed_group_hom.lift_unique f.range _ _ _ w)\n\ninstance : has_cokernels SemiNormedGroup.{u} :=\n{ has_colimit := λ X Y f, has_colimit.mk\n  { cocone := cokernel_cocone f,\n    is_colimit := is_colimit_cokernel_cocone f } }\n\n-- Sanity check\nexample : has_cokernels SemiNormedGroup := by apply_instance\n\nsection explicit_cokernel\n\n/-- An explicit choice of cokernel, which has good properties with respect to the norm. -/\ndef explicit_cokernel {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : SemiNormedGroup.{u} :=\n(cokernel_cocone f).X\n\n/-- Descend to the explicit cokernel. -/\ndef explicit_cokernel_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) : explicit_cokernel f ⟶ Z :=\n(is_colimit_cokernel_cocone f).desc (cofork.of_π g (by simp [w]))\n\n/-- The projection from `Y` to the explicit cokernel of `X ⟶ Y`. -/\ndef explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : Y ⟶ explicit_cokernel f :=\n(cokernel_cocone f).ι.app walking_parallel_pair.one\n\nlemma explicit_cokernel_π_surjective {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} :\n  function.surjective (explicit_cokernel_π f) :=\nsurjective_quot_mk _\n\n@[simp, reassoc]\nlemma comp_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  f ≫ explicit_cokernel_π f = 0 :=\nbegin\n  convert (cokernel_cocone f).w walking_parallel_pair_hom.left,\n  simp,\nend\n\n@[simp]\nlemma explicit_cokernel_π_apply_dom_eq_zero {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} (x : X) :\n  (explicit_cokernel_π f) (f x) = 0 :=\nshow (f ≫ (explicit_cokernel_π f)) x = 0, by { rw [comp_explicit_cokernel_π], refl }\n\n@[simp, reassoc]\nlemma explicit_cokernel_π_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) : explicit_cokernel_π f ≫ explicit_cokernel_desc w = g :=\n(is_colimit_cokernel_cocone f).fac _ _\n\n@[simp]\nlemma explicit_cokernel_π_desc_apply {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  {cond : f ≫ g = 0} (x : Y) : explicit_cokernel_desc cond (explicit_cokernel_π f x) = g x :=\nshow (explicit_cokernel_π f ≫ explicit_cokernel_desc cond) x = g x, by rw explicit_cokernel_π_desc\n\nlemma explicit_cokernel_desc_unique {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) (e : explicit_cokernel f ⟶ Z) (he : explicit_cokernel_π f ≫ e = g) :\n  e = explicit_cokernel_desc w :=\nbegin\n  apply (is_colimit_cokernel_cocone f).uniq (cofork.of_π g (by simp [w])),\n  rintro (_|_),\n  { convert w.symm,\n    simp },\n  { exact he }\nend\n\nlemma explicit_cokernel_desc_comp_eq_desc {X Y Z W : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  {h : Z ⟶ W} {cond : f ≫ g = 0} :\n  explicit_cokernel_desc cond ≫ h = explicit_cokernel_desc (show f ≫ (g ≫ h) = 0,\n  by rw [← category_theory.category.assoc, cond, limits.zero_comp]) :=\nbegin\n  refine explicit_cokernel_desc_unique _ _ _,\n  rw [← category_theory.category.assoc, explicit_cokernel_π_desc]\nend\n\n@[simp]\nlemma explicit_cokernel_desc_zero {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} :\n  explicit_cokernel_desc (show f ≫ (0 : Y ⟶ Z) = 0, from category_theory.limits.comp_zero) = 0 :=\neq.symm $ explicit_cokernel_desc_unique _ _ category_theory.limits.comp_zero\n\n@[ext]\nlemma explicit_cokernel_hom_ext {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y}\n  (e₁ e₂ : explicit_cokernel f ⟶ Z)\n  (h : explicit_cokernel_π f ≫ e₁ = explicit_cokernel_π f ≫ e₂) : e₁ = e₂ :=\nbegin\n  let g : Y ⟶ Z := explicit_cokernel_π f ≫ e₂,\n  have w : f ≫ g = 0, by simp,\n  have : e₂ = explicit_cokernel_desc w,\n  { apply explicit_cokernel_desc_unique, refl },\n  rw this,\n  apply explicit_cokernel_desc_unique,\n  exact h,\nend\n\ninstance explicit_cokernel_π.epi {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} :\n  epi (explicit_cokernel_π f) :=\nbegin\n  constructor,\n  intros Z g h H,\n  ext x,\n  obtain ⟨x, hx⟩ := explicit_cokernel_π_surjective (explicit_cokernel_π f x),\n  change (explicit_cokernel_π f ≫ g) _ = _,\n  rw [H]\nend\n\nlemma is_quotient_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\nnormed_group_hom.is_quotient (explicit_cokernel_π f) :=\nnormed_group_hom.is_quotient_quotient _\n\nlemma norm_noninc_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  (explicit_cokernel_π f).norm_noninc :=\n(is_quotient_explicit_cokernel_π f).norm_le\n\nopen_locale nnreal\n\nlemma explicit_cokernel_desc_norm_le_of_norm_le {X Y Z : SemiNormedGroup.{u}}\n  {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) (c : ℝ≥0) (h : ∥ g ∥ ≤ c) :\n  ∥ explicit_cokernel_desc w ∥ ≤ c :=\nnormed_group_hom.lift_norm_le _ _ _ h\n\n\n\nlemma explicit_cokernel_desc_comp_eq_zero {X Y Z W : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  {h : Z ⟶ W} (cond : f ≫ g = 0) (cond2 : g ≫ h = 0) :\n  explicit_cokernel_desc cond ≫ h = 0 :=\nbegin\n  rw [← cancel_epi (explicit_cokernel_π f), ← category.assoc, explicit_cokernel_π_desc],\n  simp [cond2]\nend\n\nlemma explicit_cokernel_desc_norm_le {X Y Z : SemiNormedGroup.{u}}\n  {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) : ∥ explicit_cokernel_desc w ∥ ≤ ∥ g ∥ :=\nexplicit_cokernel_desc_norm_le_of_norm_le w ∥ g ∥₊ (le_refl _)\n\n/-- The explicit cokernel is isomorphic to the usual cokernel. -/\ndef explicit_cokernel_iso {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  explicit_cokernel f ≅ cokernel f :=\n(is_colimit_cokernel_cocone f).cocone_point_unique_up_to_iso (colimit.is_colimit _)\n\n@[simp]\nlemma explicit_cokernel_iso_hom_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  explicit_cokernel_π f ≫ (explicit_cokernel_iso f).hom = cokernel.π _ :=\nby simp [explicit_cokernel_π, explicit_cokernel_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_inv_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  cokernel.π f ≫ (explicit_cokernel_iso f).inv = explicit_cokernel_π f :=\nby simp [explicit_cokernel_π, explicit_cokernel_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_hom_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) :\n  (explicit_cokernel_iso f).hom ≫ cokernel.desc f g w = explicit_cokernel_desc w :=\nbegin\n  ext1,\n  simp [explicit_cokernel_desc, explicit_cokernel_π, explicit_cokernel_iso],\nend\n\n/-- A special case of `category_theory.limits.cokernel.map` adapted to `explicit_cokernel`. -/\nnoncomputable def explicit_cokernel.map {A B C D : SemiNormedGroup.{u}} {fab : A ⟶ B}\n  {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D} (h : fab ≫ fbd = fac ≫ fcd) :\n  explicit_cokernel fab ⟶ explicit_cokernel fcd :=\n@explicit_cokernel_desc _ _ _ fab (fbd ≫ explicit_cokernel_π _) $ by simp [reassoc_of h]\n\n/-- A special case of `category_theory.limits.cokernel.map_desc` adapted to `explicit_cokernel`. -/\nlemma explicit_coker.map_desc {A B C D B' D' : SemiNormedGroup.{u}}\n  {fab : A ⟶ B} {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D}\n  {h : fab ≫ fbd = fac ≫ fcd} {fbb' : B ⟶ B'} {fdd' : D ⟶ D'}\n  {condb : fab ≫ fbb' = 0} {condd : fcd ≫ fdd' = 0} {g : B' ⟶ D'}\n  (h' : fbb' ≫ g = fbd ≫ fdd'):\n  explicit_cokernel_desc condb ≫ g = explicit_cokernel.map h ≫ explicit_cokernel_desc condd :=\nbegin\n  delta explicit_cokernel.map,\n  simp [← cancel_epi (explicit_cokernel_π fab), category.assoc, explicit_cokernel_π_desc, h']\nend\n\nend explicit_cokernel\n\nend cokernel\n\nend SemiNormedGroup\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/normed/group/SemiNormedGroup/kernels.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4909456405054036}}
{"text": "import Err\n\n/-! # `Res String α` example -/\n\n\n\nnamespace Err.Examples.String\n\n\n\nabbrev Res :=\n  Err.Res (Err.Err String String)\nabbrev ErrStateT :=\n  Err.ErrStateT String String\nabbrev ErrStateM :=\n  Err.ErrStateM String String\n\nabbrev resOf (source : String) (trace : optParam (List String) []) : Res α :=\n  ⟨source, trace⟩\n  |> err\n\n\n\nabbrev div? (a b : Nat) : Res Nat :=\n  do\n    if b = 0 then\n      bail s!\"cannot divide `{a}` by `{b}`\"\n    return a / b\n\nexample :\n  div? 7 0 = resOf \"cannot divide `7` by `0`\"\n:= rfl\n\n\n\nabbrev divAddDiv? (a b c d : Nat) : Res Nat :=\n  do\n    let d₁ ←\n      div? a b\n      |>.withContext lazy_s!\"cannot compute `{a}/{b} + {c}/{d}`\"\n    let d₂ ←\n      div? c d\n      |>.withContext lazy_s!\"cannot compute `{a}/{b} + {c}/{d}\"\n    return d₁ + d₂\n\nexample :\n  divAddDiv? 7 0 3 2\n  =\n  resOf \"cannot divide `7` by `0`\" [\"cannot compute `7/0 + 3/2`\"]\n:= rfl\n\n\n\n-- Don't know how to prove this :/\n\n-- example :\n--   divAddDiv? 7 2 3 0\n--   =\n--   resOf \"cannot divide `3` by `0`\" [\"cannot compute `7/2 + 3/0`\"]\n-- := by\n--   simp [\n--     divAddDiv?, div?,\n--     Res.withContext, Res.pure,\n--     pure, bail, Err.context,\n--     resOf, Err.mk\n--   ]\n--   rfl\n\n\n\nabbrev ErrState.divAddDiv? (a b c d : Nat) : ErrStateM (Option Nat) :=\n  do\n    let d₁ ←\n      div? a b\n      |>.withContext\n        lazy_s!\"that's unexpected :/\"\n      |>.withContext\n        lazy_s!\"cannot compute `d₁` as `{a}/{b}`\"\n      |> ErrStateT.unwrap?\n\n    let d₂ ←\n      div? c d\n      |>.withContext\n        lazy_s!\"that's unexpected :/\"\n      |>.withContext\n        lazy_s!\"cannot compute `d₂` as `{c}/{d}`\"\n      |> ErrStateT.unwrap?\n\n    ErrStateT.withContext\n      lazy_s!\"while computing `d₁` and `d₂`\"\n\n    if let (some d₁, some d₂) := (d₁, d₂)\n    then\n      d₁ + d₂ |> some |> pure\n    else\n      ErrStateT.errgister\n        \"failed to compute d₁ and/or d₂, see below\"\n      ErrStateT.withContext\n        lazy_s!\"failed to compute `{a}/{b} + {c}/{d}`\"\n      ErrStateT.withContext\n          lazy_s!\"something went wrong `/(T_T)\\\\`\"\n      ErrStateT.finalizeWith\n          lazy_s!\"error during `divAddDiv?`\"\n      return none\n\n#eval\n  ErrState.divAddDiv? 3 0 7 0\n  |>.run default\n  |>.2\n\n#eval\n  ErrState.divAddDiv? 3 0 7 0\n  |>.run default\n  |>.2\n  |> fun ⟨_, _, trees⟩ =>\n    trees.head!.linearPrefixFoldl\n    0\n    (fun sum _ => sum + 1)\n    (fun sum _ => sum)\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/error/Err/Examples/String.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.4909456275386883}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module algebra.monoid_algebra.division\n! leanprover-community/mathlib commit 72c366d0475675f1309d3027d3d7d47ee4423951\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.MonoidAlgebra.Basic\nimport Mathbin.Data.Finsupp.Order\n\n/-!\n# Division of `add_monoid_algebra` by monomials\n\nThis file is most important for when `G = ℕ` (polynomials) or `G = σ →₀ ℕ` (multivariate\npolynomials).\n\nIn order to apply in maximal generality (such as for `laurent_polynomial`s), this uses\n`∃ d, g' = g + d` in many places instead of `g ≤ g'`.\n\n## Main definitions\n\n* `add_monoid_algebra.div_of x g`: divides `x` by the monomial `add_monoid_algebra.of k G g`\n* `add_monoid_algebra.mod_of x g`: the remainder upon dividing `x` by the monomial\n  `add_monoid_algebra.of k G g`.\n\n## Main results\n\n* `add_monoid_algebra.div_of_add_mod_of`, `add_monoid_algebra.mod_of_add_div_of`: `div_of` and\n  `mod_of` are well-behaved as quotient and remainder operators.\n\n## Implementation notes\n\n`∃ d, g' = g + d` is used as opposed to some other permutation up to commutativity in order to match\nthe definition of `semigroup_has_dvd`. The results in this file could be duplicated for\n`monoid_algebra` by using `g ∣ g'`, but this can't be done automatically, and in any case is not\nlikely to be very useful.\n\n-/\n\n\nvariable {k G : Type _} [Semiring k]\n\nnamespace AddMonoidAlgebra\n\nsection\n\nvariable [AddCancelCommMonoid G]\n\n#print AddMonoidAlgebra.divOf /-\n/-- Divide by `of' k G g`, discarding terms not divisible by this. -/\nnoncomputable def divOf (x : AddMonoidAlgebra k G) (g : G) : AddMonoidAlgebra k G :=\n  -- note: comapping by `+ g` has the effect of subtracting `g` from every element in the support, and\n    -- discarding the elements of the support from which `g` can't be subtracted. If `G` is an additive\n    -- group, such as `ℤ` when used for `laurent_polynomial`, then no discarding occurs.\n    @Finsupp.comapDomain.addMonoidHom\n    _ _ _ _ ((· + ·) g) (add_right_injective g) x\n#align add_monoid_algebra.div_of AddMonoidAlgebra.divOf\n-/\n\n-- mathport name: «expr /ᵒᶠ »\nlocal infixl:70 \" /ᵒᶠ \" => divOf\n\n/- warning: add_monoid_algebra.div_of_apply -> AddMonoidAlgebra.divOf_apply is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g' : G), Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g) g') (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) x (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g g'))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g' : G), Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) x (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g g'))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_apply AddMonoidAlgebra.divOf_applyₓ'. -/\n@[simp]\ntheorem divOf_apply (g : G) (x : AddMonoidAlgebra k G) (g' : G) : (x /ᵒᶠ g) g' = x (g + g') :=\n  rfl\n#align add_monoid_algebra.div_of_apply AddMonoidAlgebra.divOf_apply\n\n/- warning: add_monoid_algebra.support_div_of -> AddMonoidAlgebra.support_divOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), Eq.{succ u2} (Finset.{u2} G) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g)) (Finset.preimage.{u2, u2} G G (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x) (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g) (Function.Injective.injOn.{u2, u2} G G (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g) (add_right_injective.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))) (AddLeftCancelSemigroup.toIsLeftCancelAdd.{u2} G (AddLeftCancelMonoid.toAddLeftCancelSemigroup.{u2} G (AddCancelCommMonoid.toAddLeftCancelMonoid.{u2} G _inst_2))) g) (Set.preimage.{u2, u2} G G (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} G) (Set.{u2} G) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} G) (Set.{u2} G) (Finset.Set.hasCoeT.{u2} G))) (Finsupp.support.{u2, u1} G k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))) x)))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{succ u1} (Finset.{u1} G) (Finsupp.support.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1)) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g)) (Finset.preimage.{u1, u1} G G (Finsupp.support.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1)) x) ((fun (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 : G) (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823 : G) => HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823) g) (Function.Injective.injOn.{u1, u1} G G ((fun (x._@.Mathlib.Algebra.Group.Defs._hyg.2622 : G) (x._@.Mathlib.Algebra.Group.Defs._hyg.2624 : G) => HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x._@.Mathlib.Algebra.Group.Defs._hyg.2622 x._@.Mathlib.Algebra.Group.Defs._hyg.2624) g) (add_right_injective.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))) (IsCancelAdd.toIsLeftCancelAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))) (AddCancelMonoid.toIsCancelAdd.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))) g) (Set.preimage.{u1, u1} G G ((fun (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 : G) (x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823 : G) => HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.821 x._@.Mathlib.Algebra.MonoidAlgebra.Division._hyg.823) g) (Finset.toSet.{u1} G (Finsupp.support.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1)) x)))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.support_div_of AddMonoidAlgebra.support_divOfₓ'. -/\n@[simp]\ntheorem support_divOf (g : G) (x : AddMonoidAlgebra k G) :\n    (x /ᵒᶠ g).support =\n      x.support.Preimage ((· + ·) g) (Function.Injective.injOn (add_right_injective g) _) :=\n  rfl\n#align add_monoid_algebra.support_div_of AddMonoidAlgebra.support_divOf\n\n/- warning: add_monoid_algebra.zero_div_of -> AddMonoidAlgebra.zero_divOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))))) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))))) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.zero_div_of AddMonoidAlgebra.zero_divOfₓ'. -/\n@[simp]\ntheorem zero_divOf (g : G) : (0 : AddMonoidAlgebra k G) /ᵒᶠ g = 0 :=\n  map_zero _\n#align add_monoid_algebra.zero_div_of AddMonoidAlgebra.zero_divOf\n\n/- warning: add_monoid_algebra.div_of_zero -> AddMonoidAlgebra.divOf_zero is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x (OfNat.ofNat.{u2} G 0 (OfNat.mk.{u2} G 0 (Zero.zero.{u2} G (AddZeroClass.toHasZero.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) x\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x (OfNat.ofNat.{u1} G 0 (Zero.toOfNat0.{u1} G (AddRightCancelMonoid.toZero.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) x\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_zero AddMonoidAlgebra.divOf_zeroₓ'. -/\n@[simp]\ntheorem divOf_zero (x : AddMonoidAlgebra k G) : x /ᵒᶠ 0 = x :=\n  by\n  ext\n  simp only [AddMonoidAlgebra.divOf_apply, zero_add]\n#align add_monoid_algebra.div_of_zero AddMonoidAlgebra.divOf_zero\n\n/- warning: add_monoid_algebra.add_div_of -> AddMonoidAlgebra.add_divOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (y : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) x y) g) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 y g))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (y : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) x y) g) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 y g))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.add_div_of AddMonoidAlgebra.add_divOfₓ'. -/\ntheorem add_divOf (x y : AddMonoidAlgebra k G) (g : G) : (x + y) /ᵒᶠ g = x /ᵒᶠ g + y /ᵒᶠ g :=\n  map_add _ _ _\n#align add_monoid_algebra.add_div_of AddMonoidAlgebra.add_divOf\n\n/- warning: add_monoid_algebra.div_of_add -> AddMonoidAlgebra.divOf_add is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (a : G) (b : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) a b)) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x a) b)\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (a : G) (b : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) a b)) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x a) b)\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_add AddMonoidAlgebra.divOf_addₓ'. -/\ntheorem divOf_add (x : AddMonoidAlgebra k G) (a b : G) : x /ᵒᶠ (a + b) = x /ᵒᶠ a /ᵒᶠ b :=\n  by\n  ext\n  simp only [AddMonoidAlgebra.divOf_apply, add_assoc]\n#align add_monoid_algebra.div_of_add AddMonoidAlgebra.divOf_add\n\n/- warning: add_monoid_algebra.div_of_hom -> AddMonoidAlgebra.divOfHom is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G], MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Multiplicative.mulOneClass.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))) (MulZeroOneClass.toMulOneClass.{max u2 u1} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (NonAssocSemiring.toMulZeroOneClass.{max u2 u1} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Semiring.toNonAssocSemiring.{max u2 u1} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (AddMonoid.End.semiring.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.addCommMonoid.{u2, u1} k G _inst_1)))))\nbut is expected to have type\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G], MonoidHom.{u2, max u2 u1} (Multiplicative.{u2} G) (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Multiplicative.mulOneClass.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))) (MulZeroOneClass.toMulOneClass.{max u1 u2} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (Semiring.toNonAssocSemiring.{max u1 u2} (AddMonoid.End.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoid.toAddZeroClass.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonAssocSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))) (AddMonoid.End.semiring.{max u1 u2} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.addCommMonoid.{u1, u2} k G _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_hom AddMonoidAlgebra.divOfHomₓ'. -/\n/-- A bundled version of `add_monoid_algebra.div_of`. -/\n@[simps]\nnoncomputable def divOfHom : Multiplicative G →* AddMonoid.End (AddMonoidAlgebra k G)\n    where\n  toFun g :=\n    { toFun := fun x => divOf x g.toAdd\n      map_zero' := zero_divOf _\n      map_add' := fun x y => add_divOf x y g.toAdd }\n  map_one' := AddMonoidHom.ext divOf_zero\n  map_mul' g₁ g₂ :=\n    AddMonoidHom.ext fun x => (congr_arg _ (add_comm g₁.toAdd g₂.toAdd)).trans (divOf_add _ _ _)\n#align add_monoid_algebra.div_of_hom AddMonoidAlgebra.divOfHom\n\n/- warning: add_monoid_algebra.of'_mul_div_of -> AddMonoidAlgebra.of'_mul_divOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (a : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 a) x) a) x\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (a : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 a) x) a) x\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_mul_div_of AddMonoidAlgebra.of'_mul_divOfₓ'. -/\ntheorem of'_mul_divOf (a : G) (x : AddMonoidAlgebra k G) : of' k G a * x /ᵒᶠ a = x :=\n  by\n  ext b\n  rw [AddMonoidAlgebra.divOf_apply, of'_apply, single_mul_apply_aux, one_mul]\n  intro c\n  exact add_right_inj _\n#align add_monoid_algebra.of'_mul_div_of AddMonoidAlgebra.of'_mul_divOf\n\n/- warning: add_monoid_algebra.mul_of'_div_of -> AddMonoidAlgebra.mul_of'_divOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 a)) a) x\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 a)) a) x\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.mul_of'_div_of AddMonoidAlgebra.mul_of'_divOfₓ'. -/\ntheorem mul_of'_divOf (x : AddMonoidAlgebra k G) (a : G) : x * of' k G a /ᵒᶠ a = x :=\n  by\n  ext b\n  rw [AddMonoidAlgebra.divOf_apply, of'_apply, mul_single_apply_aux, mul_one]\n  intro c\n  rw [add_comm]\n  exact add_right_inj _\n#align add_monoid_algebra.mul_of'_div_of AddMonoidAlgebra.mul_of'_divOf\n\n/- warning: add_monoid_algebra.of'_div_of -> AddMonoidAlgebra.of'_divOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 a) a) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 1 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 1 (One.one.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.one.{u1, u2} k G _inst_1 (AddZeroClass.toHasZero.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (a : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 a) a) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 1 (One.toOfNat1.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.one.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toZero.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_div_of AddMonoidAlgebra.of'_divOfₓ'. -/\ntheorem of'_divOf (a : G) : of' k G a /ᵒᶠ a = 1 := by\n  simpa only [one_mul] using mul_of'_div_of (1 : AddMonoidAlgebra k G) a\n#align add_monoid_algebra.of'_div_of AddMonoidAlgebra.of'_divOf\n\n#print AddMonoidAlgebra.modOf /-\n/-- The remainder upon division by `of' k G g`. -/\nnoncomputable def modOf (x : AddMonoidAlgebra k G) (g : G) : AddMonoidAlgebra k G :=\n  x.filterₓ fun g₁ => ¬∃ g₂, g₁ = g + g₂\n#align add_monoid_algebra.mod_of AddMonoidAlgebra.modOf\n-/\n\n-- mathport name: «expr %ᵒᶠ »\nlocal infixl:70 \" %ᵒᶠ \" => modOf\n\n/- warning: add_monoid_algebra.mod_of_apply_of_not_exists_add -> AddMonoidAlgebra.modOf_apply_of_not_exists_add is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (g' : G), (Not (Exists.{succ u2} G (fun (d : G) => Eq.{succ u2} G g' (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g d)))) -> (Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) g') (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) x g'))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (g' : G), (Not (Exists.{succ u1} G (fun (d : G) => Eq.{succ u1} G g' (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)))) -> (Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) x g'))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_of_not_exists_add AddMonoidAlgebra.modOf_apply_of_not_exists_addₓ'. -/\n@[simp]\ntheorem modOf_apply_of_not_exists_add (x : AddMonoidAlgebra k G) (g : G) (g' : G)\n    (h : ¬∃ d, g' = g + d) : (x %ᵒᶠ g) g' = x g' :=\n  Finsupp.filter_apply_pos _ _ h\n#align add_monoid_algebra.mod_of_apply_of_not_exists_add AddMonoidAlgebra.modOf_apply_of_not_exists_add\n\n/- warning: add_monoid_algebra.mod_of_apply_of_exists_add -> AddMonoidAlgebra.modOf_apply_of_exists_add is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (g' : G), (Exists.{succ u2} G (fun (d : G) => Eq.{succ u2} G g' (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g d))) -> (Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) g') (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (g' : G), (Exists.{succ u1} G (fun (d : G) => Eq.{succ u1} G g' (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d))) -> (Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) g') (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (MonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) g') _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_of_exists_add AddMonoidAlgebra.modOf_apply_of_exists_addₓ'. -/\n@[simp]\ntheorem modOf_apply_of_exists_add (x : AddMonoidAlgebra k G) (g : G) (g' : G)\n    (h : ∃ d, g' = g + d) : (x %ᵒᶠ g) g' = 0 :=\n  Finsupp.filter_apply_neg _ _ <| by rwa [Classical.not_not]\n#align add_monoid_algebra.mod_of_apply_of_exists_add AddMonoidAlgebra.modOf_apply_of_exists_add\n\n/- warning: add_monoid_algebra.mod_of_apply_add_self -> AddMonoidAlgebra.modOf_apply_add_self is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (d : G), Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) d g)) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (d : G), Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (MonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) d g)) _inst_1))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_add_self AddMonoidAlgebra.modOf_apply_add_selfₓ'. -/\n@[simp]\ntheorem modOf_apply_add_self (x : AddMonoidAlgebra k G) (g : G) (d : G) : (x %ᵒᶠ g) (d + g) = 0 :=\n  modOf_apply_of_exists_add _ _ _ ⟨_, add_comm _ _⟩\n#align add_monoid_algebra.mod_of_apply_add_self AddMonoidAlgebra.modOf_apply_add_self\n\n/- warning: add_monoid_algebra.mod_of_apply_self_add -> AddMonoidAlgebra.modOf_apply_self_add is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G) (d : G), Eq.{succ u1} k (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (fun (_x : AddMonoidAlgebra.{u1, u2} k G _inst_1) => G -> k) (AddMonoidAlgebra.coeFun.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u2, u2, u2} G G G (instHAdd.{u2} G (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))) g d)) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k _inst_1)))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G) (d : G), Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) G (fun (_x : G) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) _x) (Finsupp.funLike.{u1, u2} G k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k _inst_1))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (MonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : G) => k) (HAdd.hAdd.{u1, u1, u1} G G G (instHAdd.{u1} G (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))) g d)) _inst_1))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_apply_self_add AddMonoidAlgebra.modOf_apply_self_addₓ'. -/\n@[simp]\ntheorem modOf_apply_self_add (x : AddMonoidAlgebra k G) (g : G) (d : G) : (x %ᵒᶠ g) (g + d) = 0 :=\n  modOf_apply_of_exists_add _ _ _ ⟨_, rfl⟩\n#align add_monoid_algebra.mod_of_apply_self_add AddMonoidAlgebra.modOf_apply_self_add\n\n/- warning: add_monoid_algebra.of'_mul_mod_of -> AddMonoidAlgebra.of'_mul_modOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G) (x : AddMonoidAlgebra.{u1, u2} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) x) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G) (x : AddMonoidAlgebra.{u2, u1} k G _inst_1), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) x) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_mul_mod_of AddMonoidAlgebra.of'_mul_modOfₓ'. -/\ntheorem of'_mul_modOf (g : G) (x : AddMonoidAlgebra k G) : of' k G g * x %ᵒᶠ g = 0 :=\n  by\n  ext g'\n  rw [Finsupp.zero_apply]\n  obtain ⟨d, rfl⟩ | h := em (∃ d, g' = g + d)\n  · rw [mod_of_apply_self_add]\n  · rw [mod_of_apply_of_not_exists_add _ _ _ h, of'_apply, single_mul_apply_of_not_exists_add _ _ h]\n#align add_monoid_algebra.of'_mul_mod_of AddMonoidAlgebra.of'_mul_modOf\n\n/- warning: add_monoid_algebra.mul_of'_mod_of -> AddMonoidAlgebra.mul_of'_modOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g)) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) x (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g)) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.mul_of'_mod_of AddMonoidAlgebra.mul_of'_modOfₓ'. -/\ntheorem mul_of'_modOf (x : AddMonoidAlgebra k G) (g : G) : x * of' k G g %ᵒᶠ g = 0 :=\n  by\n  ext g'\n  rw [Finsupp.zero_apply]\n  obtain ⟨d, rfl⟩ | h := em (∃ d, g' = g + d)\n  · rw [mod_of_apply_self_add]\n  · rw [mod_of_apply_of_not_exists_add _ _ _ h, of'_apply, mul_single_apply_of_not_exists_add]\n    simpa only [add_comm] using h\n#align add_monoid_algebra.mul_of'_mod_of AddMonoidAlgebra.mul_of'_modOf\n\n/- warning: add_monoid_algebra.of'_mod_of -> AddMonoidAlgebra.of'_modOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_mod_of AddMonoidAlgebra.of'_modOfₓ'. -/\ntheorem of'_modOf (g : G) : of' k G g %ᵒᶠ g = 0 := by\n  simpa only [one_mul] using mul_of'_mod_of (1 : AddMonoidAlgebra k G) g\n#align add_monoid_algebra.of'_mod_of AddMonoidAlgebra.of'_modOf\n\n/- warning: add_monoid_algebra.div_of_add_mod_of -> AddMonoidAlgebra.divOf_add_modOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{succ (max u2 u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g)) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g)) x\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g)) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g)) x\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.div_of_add_mod_of AddMonoidAlgebra.divOf_add_modOfₓ'. -/\ntheorem divOf_add_modOf (x : AddMonoidAlgebra k G) (g : G) : of' k G g * (x /ᵒᶠ g) + x %ᵒᶠ g = x :=\n  by\n  ext g'\n  simp_rw [Finsupp.add_apply]\n  obtain ⟨d, rfl⟩ | h := em (∃ d, g' = g + d)\n  swap\n  ·\n    rw [mod_of_apply_of_not_exists_add _ _ _ h, of'_apply, single_mul_apply_of_not_exists_add _ _ h,\n      zero_add]\n  · rw [mod_of_apply_self_add, add_zero]\n    rw [of'_apply, single_mul_apply_aux _ _ _, one_mul, div_of_apply]\n    intro a\n    exact add_right_inj _\n#align add_monoid_algebra.div_of_add_mod_of AddMonoidAlgebra.divOf_add_modOf\n\n/- warning: add_monoid_algebra.mod_of_add_div_of -> AddMonoidAlgebra.modOf_add_divOf is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] (x : AddMonoidAlgebra.{u1, u2} k G _inst_1) (g : G), Eq.{succ (max u2 u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (Distrib.toHasAdd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.{u1, u2} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.hasMul.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u1, u2} k G _inst_1 _inst_2 x g))) x\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] (x : AddMonoidAlgebra.{u2, u1} k G _inst_1) (g : G), Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Distrib.toAdd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))))) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.{u2, u1} k G _inst_1) (instHMul.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.hasMul.{u2, u1} k G _inst_1 (AddZeroClass.toAdd.{u1} G (AddMonoid.toAddZeroClass.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) (AddMonoidAlgebra.divOf.{u2, u1} k G _inst_1 _inst_2 x g))) x\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.mod_of_add_div_of AddMonoidAlgebra.modOf_add_divOfₓ'. -/\ntheorem modOf_add_divOf (x : AddMonoidAlgebra k G) (g : G) : x %ᵒᶠ g + of' k G g * (x /ᵒᶠ g) = x :=\n  by rw [add_comm, div_of_add_mod_of]\n#align add_monoid_algebra.mod_of_add_div_of AddMonoidAlgebra.modOf_add_divOf\n\n/- warning: add_monoid_algebra.of'_dvd_iff_mod_of_eq_zero -> AddMonoidAlgebra.of'_dvd_iff_modOf_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {G : Type.{u2}} [_inst_1 : Semiring.{u1} k] [_inst_2 : AddCancelCommMonoid.{u2} G] {x : AddMonoidAlgebra.{u1, u2} k G _inst_1} {g : G}, Iff (Dvd.Dvd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (semigroupDvd.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (SemigroupWithZero.toSemigroup.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalSemiring.toSemigroupWithZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalSemiring.{u1, u2} k G _inst_1 (AddMonoid.toAddSemigroup.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2)))))))) (AddMonoidAlgebra.of'.{u1, u2} k G _inst_1 g) x) (Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.modOf.{u1, u2} k G _inst_1 _inst_2 x g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (OfNat.mk.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) 0 (Zero.zero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (MulZeroClass.toHasZero.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (AddMonoidAlgebra.{u1, u2} k G _inst_1) (AddMonoidAlgebra.nonUnitalNonAssocSemiring.{u1, u2} k G _inst_1 (AddZeroClass.toHasAdd.{u2} G (AddMonoid.toAddZeroClass.{u2} G (AddRightCancelMonoid.toAddMonoid.{u2} G (AddCancelMonoid.toAddRightCancelMonoid.{u2} G (AddCancelCommMonoid.toAddCancelMonoid.{u2} G _inst_2))))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {G : Type.{u1}} [_inst_1 : Semiring.{u2} k] [_inst_2 : AddCancelCommMonoid.{u1} G] {x : AddMonoidAlgebra.{u2, u1} k G _inst_1} {g : G}, Iff (Dvd.dvd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (semigroupDvd.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (SemigroupWithZero.toSemigroup.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (NonUnitalSemiring.toSemigroupWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.nonUnitalSemiring.{u2, u1} k G _inst_1 (AddMonoid.toAddSemigroup.{u1} G (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))))) (AddMonoidAlgebra.of'.{u2, u1} k G _inst_1 g) x) (Eq.{max (succ u2) (succ u1)} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.modOf.{u2, u1} k G _inst_1 _inst_2 x g) (OfNat.ofNat.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (MonoidWithZero.toZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (Semiring.toMonoidWithZero.{max u2 u1} (AddMonoidAlgebra.{u2, u1} k G _inst_1) (AddMonoidAlgebra.semiring.{u2, u1} k G _inst_1 (AddRightCancelMonoid.toAddMonoid.{u1} G (AddCancelMonoid.toAddRightCancelMonoid.{u1} G (AddCancelCommMonoid.toAddCancelMonoid.{u1} G _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_algebra.of'_dvd_iff_mod_of_eq_zero AddMonoidAlgebra.of'_dvd_iff_modOf_eq_zeroₓ'. -/\ntheorem of'_dvd_iff_modOf_eq_zero {x : AddMonoidAlgebra k G} {g : G} :\n    of' k G g ∣ x ↔ x %ᵒᶠ g = 0 := by\n  constructor\n  · rintro ⟨x, rfl⟩\n    rw [of'_mul_mod_of]\n  · intro h\n    rw [← div_of_add_mod_of x g, h, add_zero]\n    exact dvd_mul_right _ _\n#align add_monoid_algebra.of'_dvd_iff_mod_of_eq_zero AddMonoidAlgebra.of'_dvd_iff_modOf_eq_zero\n\nend\n\nend AddMonoidAlgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/MonoidAlgebra/Division.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.49091518677360374}}
{"text": "import order.complete_lattice\nimport set_theory.ordinal\nimport data.nat.prime\n\nuniverses u v\n\nvariables (A : Type u) (B : Type v) [partial_order A] [partial_order B]\n\n/-- Aiming to construct a pscompletion of `B` that preserves all sups in `A`.\n  So if we have a partial order `C` a monotone function `B -> C` and a `sup_hom`\n  from `A -> C` that commute with `f` there is a unique cocontinuous map from\n  the pscompletion to `C` such that everything commutes. -/\n\ndef presheaf : Type* :=\n{ s : B → Prop // ∀ a b, a ≤ b → s b → s a }\n\nvariables {A B}\n\nnamespace presheaf\n\ninstance : has_coe_to_fun (presheaf B) (λ _, B → Prop) :=\n⟨subtype.val⟩\n\n@[simp] lemma coe_mk (s : B → Prop) (hs : ∀ a b, a ≤ b → s b → s a) :\n  @coe_fn (presheaf B) _ _ (⟨s, hs⟩ : presheaf B) = s := rfl\n\ninstance : partial_order (presheaf B) :=\n{ le := λ a b, ∀ x, a x → b x,\n  le_trans := λ a b c hab hbc x hax, hbc _ (hab _ hax),\n  le_refl := λ _ _, id,\n  le_antisymm := λ a b hab hba, subtype.val_injective (funext $ λ x, propext ⟨hab _, hba _⟩) }\n\nlemma le_def {a b : presheaf B} : a ≤ b = ∀ x, a x → b x := rfl\n\ninstance : has_Inf (presheaf B) :=\n{ Inf := λ s, ⟨λ p, ∀ B : presheaf B, B ∈ s → B p, \n     λ a b hab h B hBs, B.2 _ _ hab (h _ hBs)⟩ }\n\ninstance : complete_lattice (presheaf B) :=\ncomplete_lattice_of_Inf _\n  (λ s, begin\n    split,\n    { dsimp [Inf, lower_bounds],\n      intros B hBs p h,\n      apply h,\n      exact hBs },\n    { dsimp [Inf, upper_bounds, lower_bounds],\n      intros B h p hBp B hBs,\n      apply h,\n      exact hBs,\n      exact hBp }\n  end)\n\nlemma infi_def {ι : Sort*} (a : ι → presheaf B) : \n  infi a = ⟨λ p, ∀ i, a i p, λ x y hxy h i, (a i).2 _ y hxy (h i)⟩ :=\nle_antisymm \n  (infi_le_iff.2 (λ B h p hBp i, h i _ hBp)) \n  (le_infi (λ i p h, h _))\n\nlemma supr_def {ι : Sort*} (a : ι → presheaf B) : \n  supr a = ⟨λ p, ∃ i, a i p, λ x y hxy ⟨i, hi⟩, ⟨i, (a i).2 x y hxy hi⟩⟩ :=\nle_antisymm \n  (supr_le_iff.2 (λ i p h, ⟨i, h⟩)) \n  (le_supr_iff.2 (λ B h p ⟨i, hi⟩, h i _ hi))\n\ndef yoneda (a : B) : presheaf B :=\n⟨λ b, b ≤ a, λ b c, le_trans⟩\n\ndef yoneda_le_iff (a : presheaf B) (p : B) : yoneda p ≤ a ↔ a p :=\nbegin\n  simp [yoneda, presheaf.le_def],\n  split,\n  { intro h, apply h, exact le_rfl },\n  { intros h x hxp,\n    apply a.2,\n    apply hxp,\n    exact h }\nend\n\nlemma yoneda_mono {a b : B} : yoneda a ≤ yoneda b ↔ a ≤ b :=\nbegin\n  rw yoneda_le_iff, refl,\nend\n\nlemma eq_supr (a : presheaf B) : a = ⨆ (p : B) (h : a p), yoneda p :=\nbegin\n  apply le_antisymm; simp only [le_supr_iff, supr_le_iff, yoneda_le_iff],\n  { intros B hB p,\n    exact hB p },\n  { exact λ _, id }\nend\n\ndef extend {B : Type*} [complete_lattice B] (f : A → B) : presheaf A → B :=\nλ a, ⨆ (p : A) (h : a p), f p\n\nlemma extend_yoneda {B : Type*} [complete_lattice B] (f : A → B) (a : A)\n  (hf : monotone f) : extend f (yoneda a) = f a :=\nbegin\n  dsimp [extend, yoneda],\n  apply le_antisymm,\n  { refine supr_le (λ b, supr_le (λ h, hf h)) },\n  { refine le_supr_iff.2 (λ b hb, _),\n    refine le_trans _ (hb a),\n    refine le_supr_iff.2 (λ b hb, hb le_rfl) }\nend\n\nlemma extend_supr {B : Type*} {ι : Sort*} [complete_lattice B] (f : A → B) (a : ι → presheaf A) :\n  extend f (supr a) = ⨆ i, extend f (a i) :=\nbegin\n  dsimp [extend],\n  apply le_antisymm; \n  simp only [le_supr_iff, supr_le_iff, presheaf.supr_def]; \n  dsimp;\n  simp only [exists_imp_distrib],\n  { intros b i hbi c h,\n    exact h _ _ hbi },\n  { intros i b hbi c h,\n    exact h _ _ hbi }\nend\n\ndef total : presheaf (presheaf A) →o presheaf A :=\n{ to_fun := λ F, ⟨λ X, F (yoneda X), begin\n    intros B C hBC x,\n    exact F.2 _ _ (yoneda_mono.2 hBC) x\n  end⟩,\n  monotone' := λ F G hFG a hF, hFG _ hF }\n\ndef map (f : A → B) : presheaf A → presheaf B :=\nextend (λ a, yoneda (f a))\n\ndef map_total (f : A → B) (F : presheaf (presheaf A)) : map f (total F) = total (map (map f) F) :=\nbegin\n  dsimp [map, extend, total],\n  apply le_antisymm,\n  { simp only [supr_le_iff, presheaf.supr_def, presheaf.le_def],\n    simp,\n    intros b a ha hb,\n    use yoneda a,\n    use ha,\n    dsimp [yoneda, presheaf.le_def] at *,\n    intros x hxb,\n    use a,\n    use le_rfl,\n    use le_trans hxb hb },\n  { simp only [le_supr_iff, presheaf.supr_def, presheaf.le_def],\n    simp [yoneda],\n    intros a b ha h,\n    cases h le_rfl with x hx,\n    use x,split,\n    refine F.2 _ _ _ ha,\n    simp [presheaf.le_def],\n    intros y hy,\n    exact b.2 _ _ hy hx.1,\n    exact hx.2\n     }\n\nend \n\ndef comp (f : A →o B) : presheaf B → presheaf A :=\nλ b, ⟨λ a, b (f a), λ x y hxy, b.2 _ _ $ f.monotone hxy⟩\n\nexample (f : A →o B) : galois_connection (map f) (comp f):=\nbegin\n  intros x y,\n  simp [map, comp, extend, supr_le_iff, presheaf.le_def, presheaf.supr_def, yoneda],\n  split,\n  { intros h a hxa, exact h _ _ hxa le_rfl },\n  { intros h b a hxa hba,\n    exact y.2 _ _ hba (h _ hxa) }\nend\n\nvariables {A' : Type*} [complete_lattice A'] [B' : Type*] [complete_lattice B']\n  (i : A → A') (j : B → B') (hi : monotone i) (hj : monotone j)\ninclude hi hj\n\nexample (f : A → B) (hf : monotone f) (g : presheaf B → presheaf A)\n  (h : galois_connection (map f) g)\n  (f' : A' → B') (g' : B' → A') (gc : galois_connection f' g')\n  (hfij : ∀ x, f' (i x) = j (f x)) :\n  g' ∘ extend j = extend i ∘ g :=\n-- have hg : g = (λ b, ⨆ (c : presheaf A) (h : map f c ≤ b), c), \n--   begin\n--     funext b,\n--     apply le_antisymm,\n--     { simp only [le_supr_iff, supr_le_iff],\n--       intros c hc,\n--       refine hc _ _,\n--       exact h.l_u_le _ },\n--     { refine supr_le (λ c, supr_le (λ hc, h.le_iff_le.1 hc)) },\n--   end,\nhave hg : g = comp ⟨f, hf⟩ := \n  begin\n    apply le_antisymm,\n    intro x,\n    swap,\n    intro x,\n    rw [← h.le_iff_le],\n    simp [comp, map],\n    intro a,\n    simp [extend, yoneda, presheaf.supr_def],\n    intros,\n    apply x.2 _ (f x_1),\n    assumption, assumption,\n    simp [comp],\n    intro a,\n    intro h1,\n    rw [← yoneda_le_iff, ← h.le_iff_le] at h1,\n    simp [yoneda, map, extend] at *,\n    apply h1,\n    apply le_rfl,\n    simp,\n    \n  end,\nhave hg' : g' = (λ b, ⨆ (c : A') (h : f' c ≤ b), c), \n  begin\n    funext b,\n    apply le_antisymm,\n    { simp only [le_supr_iff, supr_le_iff],\n      intros c hc,\n      refine hc _ _,\n      exact gc.l_u_le _ },\n    { refine supr_le (λ c, supr_le (λ hc, gc.le_iff_le.1 hc)) },\n  end,\nbegin\n  funext a,\n  dsimp,\n  substs g g',\n  rw [eq_supr a],\n  simp only [extend_supr, extend_yoneda _ _ hj],\n  simp [extend, comp, presheaf.supr_def, yoneda],\n  apply le_antisymm,\n  { simp only [le_supr_iff, supr_le_iff],\n    intros x hx y hy,\n    refine le_trans (gc.le_iff_le.1 (hx ⊤ _)) _,\n    { intros b hai,\n      exact le_top,\n       },\n    simp only [supr_le_iff], admit,\n     },\n  { simp only [le_supr_iff, supr_le_iff],\n    intros b c hbc x hx,\n    apply hx,\n    intros d hd,\n    rw [hfij],\n    apply hd,\n    refine a.2 _ _ hbc.2 hbc.1 }\nend\n\n\nexample (f : A → B) (hf : monotone f) (g : presheaf B → presheaf A)\n  (h : galois_connection (map f) g)\n  (f' : A' → B') (g' : B' → A') (gc : galois_connection f' g')\n  (hfij : ∀ x, f' (i x) ≤ j (f x)) :\n  extend i ∘ g ≤ g' ∘ extend j :=\nhave hg : g = comp ⟨f, hf⟩ := sorry,\nhave hg' : g' = (λ b, ⨆ (c : A') (h : f' c ≤ b), c), \n  begin\n    funext b,\n    apply le_antisymm,\n    { simp only [le_supr_iff, supr_le_iff],\n      intros c hc,\n      refine hc _ _,\n      exact gc.l_u_le _ },\n    { refine supr_le (λ c, supr_le (λ hc, gc.le_iff_le.1 hc)) },\n  end,\nbegin\n  intros a,\n  dsimp,\n  substs g g',\n  simp only [extend_supr, extend_yoneda _ _ hj],\n  simp [extend, comp, presheaf.supr_def, yoneda],\n  { simp only [le_supr_iff, supr_le_iff],\n    intros b hb x hx,\n    apply hx,\n    intros d hd,\n    refine le_trans (hfij _) _,\n    apply hd,\n    exact hb }\nend\n\nexample : false :=\nbegin\n  have := @thing ℕ ℕ _ _,\n\nend\n\nexample (f : A → B) (hf : monotone f) (g : presheaf B → presheaf A) \n  (h : galois_connection g (map f))\n  (f' : A' → B') (g' : B' → A') (gc : galois_connection g' f') \n  (hfij : f' ∘ i = j ∘ f) : \n  g' ∘ extend j = extend i ∘ g :=\n-- have hg : g = (λ b, ⨆ (c : presheaf A) (h : map f c ≤ b), c), \n--   begin\n--     funext b,\n--     apply le_antisymm,\n--     { simp only [le_supr_iff, supr_le_iff],\n--       intros c hc,\n--       refine hc _ _,\n--       exact h.l_u_le _ },\n--     { refine supr_le (λ c, supr_le (λ hc, h.le_iff_le.1 hc)) },\n--   end,\nhave hfij' : f' ∘ extend i = extend j ∘ map f :=\nbegin\n  funext x,\n  dsimp [extend, gc.l_supr],\nend,\nhave hg : g = comp ⟨f, hf⟩ := sorry,\nhave hg' : g' = (λ b, ⨆ (c : A') (h : f' c ≤ b), c), \n  begin\n    funext b,\n    apply le_antisymm,\n    { simp only [le_supr_iff, supr_le_iff],\n      intros c hc,\n      refine hc _ _,\n      exact gc'.l_u_le _ },\n    { refine supr_le (λ c, supr_le (λ hc, gc.le_iff_le.1 hc)) },\n  end,\nbegin\n  funext a,\n  dsimp,\n  substs g g',\n  rw [eq_supr a],\n  simp only [extend_supr, extend_yoneda _ _ hj],\n  simp [extend, comp, presheaf.supr_def, yoneda],\n  apply le_antisymm,\n  { simp only [le_supr_iff, supr_le_iff],\n    intros x hx y hy, }\n  \n \n\nend\n\nend presheaf\n\nvariable (B)\n\ndef copresheaf : Type* :=\n{ s : B → Prop // ∀ a b, a ≤ b → s a → s b }\n\nvariable {B}\n\nnamespace copresheaf\n\ninstance : has_coe_to_fun (copresheaf B) (λ _, B → Prop) :=\n⟨subtype.val⟩\n\n@[simp] lemma coe_mk (s : B → Prop) (hs : ∀ a b, a ≤ b → s a → s b) :\n  @coe_fn (copresheaf B) _ _ (⟨s, hs⟩ : copresheaf B) = s := rfl\n\ninstance : partial_order (copresheaf B) :=\n{ le := λ a b, ∀ x, b x → a x,\n  le_trans := λ a b c hab hbc x hcx, hab _ (hbc _ hcx),\n  le_refl := λ _ _, id,\n  le_antisymm := λ a b hab hba, subtype.val_injective (funext $ λ x, propext ⟨hba _, hab _⟩) }\n\nlemma le_def {a b : copresheaf B} : a ≤ b = ∀ x, b x → a x := rfl\n\ninstance : has_Sup (copresheaf B) :=\n{ Sup := λ s, ⟨λ p, ∀ B : copresheaf B, B ∈ s → B p, \n     λ a b hab h B hBs, B.2 _ _ hab (h _ hBs)⟩ }\n\ninstance : complete_lattice (copresheaf B) :=\ncomplete_lattice_of_Sup _\n  (λ s, begin\n    split,\n    { dsimp [Sup, upper_bounds],\n      intros B hBs p h,\n      apply h,\n      exact hBs },\n    { dsimp [Inf, upper_bounds, lower_bounds],\n      intros B h p hBp B hBs,\n      apply h,\n      exact hBs,\n      exact hBp }\n  end)\n\nlemma infi_def {ι : Sort*} (a : ι → copresheaf B) : \n  infi a = ⟨λ p, ∃ i, a i p, λ x y hxy ⟨i, hi⟩, ⟨i, (a i).2 x y hxy hi⟩⟩ :=\nle_antisymm \n  (infi_le_iff.2 (λ B h p ⟨i, hi⟩, h i _ hi)) \n  (le_infi_iff.2 (λ i p h, ⟨i, h⟩))\n\nlemma supr_def {ι : Sort*} (a : ι → copresheaf B) : \n  supr a = ⟨λ p, ∀ i, a i p, λ x y hxy h i, (a i).2 _ y hxy (h i)⟩ :=\nle_antisymm \n  (supr_le_iff.2 (λ i p h, h _)) \n  (le_supr_iff.2 (λ B h p hBp i, h i _ hBp))\n\ndef coyoneda (a : B) : copresheaf B :=\n⟨λ b, a ≤ b, λ b c, function.swap le_trans⟩\n\ndef le_coyoneda_iff (a : copresheaf B) (p : B) : a ≤ coyoneda p ↔ a p :=\nbegin\n  simp [copresheaf.coyoneda, copresheaf.le_def],\n  split,\n  { intro h, apply h, exact le_rfl },\n  { intros h x hxp,\n    apply a.2,\n    apply hxp,\n    exact h }\nend\n\nlemma coyoneda_mono {a b : B} : coyoneda a ≤ coyoneda b ↔ a ≤ b :=\nbegin\n  rw le_coyoneda_iff, refl\nend\n\nlemma eq_infi (a : copresheaf B) : a = ⨅ (p : B) (h : a p), coyoneda p :=\nbegin\n  apply le_antisymm; simp only [le_infi_iff, infi_le_iff, le_coyoneda_iff],\n  { exact λ _, id },\n  { intros B hB p,\n    exact hB p }\nend\n\ndef extend {B : Type*} [complete_lattice B] (f : A → B) : copresheaf A → B :=\nλ a, ⨅ (p : A) (h : a p), f p\n\ndef blah1 (M : copresheaf (A × order_dual B)) : A →o presheaf B :=\n{ to_fun := λ a, ⟨λ b, M (a, order_dual.to_dual b), \n    λ x y hxy hM, M.2 (a, order_dual.to_dual y) _ ⟨le_rfl, hxy⟩ hM⟩,\n  monotone' := λ x y hxy a ha, begin\n    dsimp at *,\n    refine M.2 (x, order_dual.to_dual a) _ _ _,\n    split, exact hxy, refl, assumption \n  end, }\n\ndef blah2 (M : copresheaf (A × order_dual B)) : B →o copresheaf A :=\n{ to_fun := λ b, ⟨λ a, M (a, order_dual.to_dual b), \n    λ x y hxy hM, M.2 (x, order_dual.to_dual b) _ ⟨hxy, le_rfl⟩ hM⟩,\n  monotone' := λ x y hxy a ha, begin\n    dsimp at *,\n    refine M.2 (a, order_dual.to_dual y) _ _ _,\n    split, refl, assumption, assumption\n  end, }\n\nexample  \n  {A' B' : Type} [complete_lattice A'] [complete_lattice B'] \n  (M : copresheaf (A × order_dual B))\n  (f : A' → B') (g : B' → A') \n  (gc : galois_connection g f)\n  (i : A → A') (j : B → B') (hi : monotone i) (hj : monotone j)\n  (hf : ∀ x, f (i x) = presheaf.extend j (blah1 M x)) : \n  ∀ x, g (j x) = copresheaf.extend i (blah2 M x) :=\nbegin\n  intros x,\n  dsimp [presheaf.extend, copresheaf.extend, blah1, blah2] at *,\n  apply le_antisymm,\n  { simp only [le_infi_iff],\n    intros a ha,\n    rw [gc.le_iff_le],\n    rw hf,\n    simp only [le_supr_iff, supr_le_iff],\n    intros b hb,\n    apply hb,\n    exact ha },\n  { simp only [infi_le_iff, le_infi_iff],\n    intros a ha,\n     }\n\nend\n\nexample  \n  {A' B' : Type} [complete_lattice A'] [complete_lattice B'] \n  (M : copresheaf (A × order_dual B))\n  (f : A' → B') (g : B' → A') \n  (gc : galois_connection f g)\n  (i : A → A') (j : B → B') (hi : monotone i) (hj : monotone j)\n  (hf : ∀ x, f (i x) = presheaf.extend j (blah1 M x)) : \n  ∀ x, g (j x) = copresheaf.extend i (blah2 M x) :=\nbegin\n  intros x,\n  dsimp [presheaf.extend, copresheaf.extend, blah1, blah2] at *,\n  apply le_antisymm,\n  { admit },\n  { simp only [infi_le_iff, le_infi_iff],\n    intros a ha,\n    rw [← gc.le_iff_le],\n     }\n\nend\n  \n\nexample {A' B' : Type} [complete_lattice A'] [complete_lattice B'] \n  (f : A → B) (hf : monotone f) \n  (f' : A' → B') (g' : B' → A') (gc : galois_connection f' g') \n  (h1 : ) :\n\nend copresheaf\n\nopen presheaf copresheaf\n\nvariables (f : A ↪o B) (hf : ∀ b, { s : set A // is_glb (f '' s) b})\n\nnamespace presheaf\n\ndef u (a : presheaf B) : copresheaf B :=\n⟨λ p, coyoneda a (yoneda p), λ a b hab h x hxA, le_trans (h _ hxA) hab⟩\n\nlemma u_mono : monotone (@u B _):=\nλ A B h p hp q hAq, hp _ (h _ hAq)\n\ninclude hf\n\ndef d (a : copresheaf B) : presheaf B :=\n⟨λ q, ∀ (x : A), a (f x) → q ≤ f x, λ a b hab h x hxA, le_trans hab (h _ hxA)⟩\n\nlemma d_mono : monotone (d f hf) :=\nλ A B h p hp q hAq, hp _ (h _ hAq)\n\ndef gc : galois_connection u (d f hf) :=\nbegin\n  intros a b,\n  dsimp [presheaf.u, presheaf.d],\n  split,\n  { intros h x hxA y hyB,\n    dsimp [copresheaf.le_def] at h,\n    apply h,\n    assumption,\n    assumption },\n  { intros h x hxA y hyB,\n    dsimp [presheaf.le_def] at *,\n    dsimp [yoneda],\n    cases hf x with s hs,\n    rw [le_is_glb_iff hs, mem_lower_bounds],\n    intros z hz,\n    rcases hz with ⟨z, hz, rfl⟩,\n    apply h,\n    assumption,\n    rw [← le_coyoneda_iff] at *,\n    refine le_trans hxA _,\n    refine coyoneda_mono.2 _,\n    exact hs.1 (set.mem_image_of_mem _ hz) }\nend\n\nomit hf\n\nopen copresheaf\n\n@[simp] lemma le_d_u (a : presheaf B) : a ≤ d f hf (u a) := (gc f hf).le_u_l a\n\n@[simp] lemma u_d_u (a : presheaf B) : u (d f hf (u a)) = u a :=\n(gc f hf).l_u_l_eq_l a\n\n@[simp] lemma u_yoneda (p : B) : u (yoneda p) = coyoneda p :=\nbegin\n  rw [u],\n  conv_lhs { dsimp [coyoneda] },\n  simp only [yoneda_le_iff],\n  refl\nend\n\nend presheaf\n\nnamespace copresheaf\n\nopen presheaf\n\nlemma u_d_le (a : copresheaf B) : u (d f hf a) ≤ a := (gc f hf).l_u_le a\n\n@[simp] lemma d_u_d (a : copresheaf B) : d f hf (u (d f hf a)) = d f hf a :=\n(gc f hf).u_l_u_eq_u _\n\ninclude hf\n\n@[simp] lemma d_coyoneda (p : B) : d f hf (coyoneda p) = yoneda p :=\nbegin\n  rw [d],\n  ext,\n  dsimp,\n  split,\n  { intros h,\n    dsimp [yoneda],\n    cases hf p with s hs,\n    rw [le_is_glb_iff hs, mem_lower_bounds],\n    simp only [set.mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂],\n    intros a ha,\n    apply h,\n    apply hs.1,\n    exact set.mem_image_of_mem _ ha  },\n  { intros h y py,\n    exact le_trans h py }\nend \n\nend copresheaf\n\nopen presheaf copresheaf\n\nvariable {B}\n\ninclude hf\n\n/- Aiming to construct a pscompletion of `B` that preserves all sups in `A`.\n  So if we have a partial order `C` a monotone function `B -> C` and a `sup_hom`\n  from `A -> C` that commute with `f` there is a unique cocontinuous map from\n  the pscompletion to `C` such that everything commutes. -/\n\nstructure pscompletion : Type v :=\n( to_presheaf : presheaf B )\n( fixed : d f hf (u to_presheaf) = to_presheaf )\n\nnamespace pscompletion\n\nvariables {B}\n\ndef _root_.presheaf.to_pscompletion (a : presheaf B) : pscompletion f hf :=\n⟨d f hf (u a), by simp *⟩\n\ninstance : partial_order (pscompletion f hf) :=\npartial_order.lift pscompletion.to_presheaf \n  begin\n    rintros ⟨_, _⟩ ⟨_, _⟩,\n    simp\n  end\n\nlemma le_def {a b : pscompletion f hf} : a ≤ b ↔ a.to_presheaf ≤ b.to_presheaf := iff.rfl\n\ndef gi : galois_insertion (_root_.presheaf.to_pscompletion f hf) pscompletion.to_presheaf :=\ngalois_connection.to_galois_insertion \n  begin\n    intros x y,\n    simp only [_root_.presheaf.to_pscompletion, le_def],\n    rw [← y.fixed, ← (gc f hf).le_iff_le, u_d_u f hf, (gc f hf).le_iff_le],\n  end\n  (by simp [_root_.presheaf.to_pscompletion, le_def, le_d_u f hf])\n\ninstance : complete_lattice (pscompletion f hf) :=\ngalois_insertion.lift_complete_lattice (gi f hf)\n\nlemma supr_to_presheaf {ι : Sort*} (a : ι → pscompletion f hf) : \n  (supr a).to_presheaf = d f hf (⨆ i, (a i).to_presheaf).u :=\nbegin \n  rw ← (gi f hf).l_supr_u, refl,\nend\n\n@[simps] def of_partial_order (a : B) : pscompletion f hf :=\n⟨yoneda a, by rw [u_yoneda, d_coyoneda f hf]⟩\n\n@[simp] lemma of_partial_order_mono {a b : B} : of_partial_order f hf a ≤ of_partial_order f hf b ↔ a ≤ b :=\nyoneda_mono\n\nlemma of_partial_order_le_iff (a : B) (x : pscompletion f hf) : \n  of_partial_order f hf a ≤ x ↔ x.to_presheaf a :=\nby simp only [of_partial_order, le_def, yoneda_le_iff]\n\nlemma of_partial_order_lub (s : set A) (a : A) (h : is_lub s a) : \n  is_lub (of_partial_order f hf '' (f '' s)) (of_partial_order f hf (f a)) :=\nbegin\n  split,\n  { simp only [upper_bounds, set.mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, set.mem_set_of_eq,\n      of_partial_order_mono],\n    intros b hbs,\n    exact f.monotone (h.1 hbs) },\n  { simp only [upper_bounds, lower_bounds, set.mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂,\n      set.mem_set_of_eq],\n    intros x hx,\n    cases x with x x_fixed,\n    refine (yoneda_le_iff _ _).2 _,\n    dsimp,\n    simp only [le_def, of_partial_order_to_presheaf, yoneda_le_iff] at hx,\n    rw [← x_fixed],\n    dsimp [d, u],\n    intros b hb,\n    simp [coyoneda, presheaf.le_def, yoneda] at hb,\n    refine f.monotone _,\n    apply h.2,\n    intros c hc,\n    apply f.le_iff_le.1,\n    apply hb,\n    apply hx,\n    exact hc }\nend\n\nvariables {C : Type*} [complete_lattice C] (i : B →o C)\n\ndef ump : pscompletion f hf → C :=\nλ x, ⨆ (b : B) (h : x.to_presheaf b), i b\n\nlemma ump_supr {ι : Sort*} (a : ι → pscompletion f hf) : ump f hf i (supr a) = ⨆ j, ump f hf i (a j) :=\nbegin\n  dsimp [ump],\n  simp only [supr_to_presheaf],\n  simp only [of_partial_order_le_iff, le_antisymm_iff, supr_le_iff, le_supr_iff],\n  split,\n  { intros c h₁ b h₂,\n    simp [d, u, coyoneda, yoneda, le_def, presheaf.le_def, presheaf.supr_def] at h₂,\n    apply h₁,\n    apply h₂,\n    intros i, admit,  admit},\n  { intros c h₁ j b h₂,\n    apply h₁,\n    intros x h,\n    refine h j _ _,\n    exact h₂ }\nend\n\nend pscompletion", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/bicompletion/partial_order2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.640635847978761, "lm_q1q2_score": 0.4909151778391079}}
{"text": "import LeanExt\n\nnamespace Day8\n\nstructure Tree where\n  size : Nat\n  pos : Nat × Nat\nderiving Repr, Inhabited\n\ndef Tree.visibleOutside : List Tree → List Tree\n  | [] => []\n  | t :: ts =>\n    t :: loop t ts\n  where\n  loop (tMax:Tree) : List Tree → List Tree\n    | [] => []\n    | t :: ts =>\n      if t.size > tMax.size\n      then t :: loop t ts\n      else loop tMax ts\n\ntheorem Tree.visibleOutside.loop_idempotent {t:Tree} {ts:List Tree}\n  : visibleOutside.loop t ts = visibleOutside.loop t (visibleOutside.loop t ts)\n  := by\n  cases ts <;> simp [loop]\n  split <;> simp [loop, *] <;> apply loop_idempotent\n\ntheorem Tree.visibleOutside_idempotent {ts:List Tree}\n  : Tree.visibleOutside ts = Tree.visibleOutside (Tree.visibleOutside ts)\n  := by\n  cases ts <;> simp [visibleOutside]\n  apply Tree.visibleOutside.loop_idempotent\n  -- 🎉 finally, just took a rewrite of Tree.visibleOutside\n\ndef Tree.treeHouseVisible (acc:List (Tree × List Tree)) : List Tree → List (Tree × List Tree)\n  | [] => acc.reverse\n  | t₁ :: ts₁ =>\n    let rec visible (acc:List Tree) : List Tree → List Tree\n      | [] => acc.reverse\n      | t₂ :: ts₂ =>\n        let acc := t₂ :: acc\n        if t₂.size < t₁.size then\n          visible acc ts₂\n        else\n          acc |>.reverse\n    Tree.treeHouseVisible ((t₁, visible [] ts₁) :: acc) ts₁\n\ndef Tree.allSides (tss:List (List Tree)) : List (List Tree) :=\n  let left := tss\n  let right := left |>.map List.reverse\n  let top := tss.transpose!\n  let bottom := top |>.map List.reverse\n  [left, right, top, bottom].join\n\nnamespace Parse\n  def tree! (ls:List String) : List (List Tree) :=\n    ls\n    |>.enum\n    |>.map (fun (x, l) =>\n      l.toList\n      |>.map (fun c => c.toNat - '0'.toNat)\n      |>.enum\n      |>.map (fun (y, size) => {size := size, pos := (x, y) :Tree})\n    )\nend Parse\n\ndef part1 (ls:List String) :=\n  ls\n  |> Parse.tree!\n  |> Tree.allSides\n  |>.map Tree.visibleOutside\n  |>.join\n  |>.map Tree.pos\n  |>.eraseDups\n  |>.length\n\ndef part2 (ls:List String) :=\n  ls\n  |> Parse.tree!\n  |> Tree.allSides\n  |>.bind (Tree.treeHouseVisible [])\n  |>.groupByEx (fun (t, ts) => (t.pos, ts.length))\n  |>.map (List.foldl (·*·) 1 ∘ Prod.snd)\n  |>.maximum?\n  |>.get!\n\ndef testInput :=\n  [ \"30373\"\n  , \"25512\"\n  , \"65332\"\n  , \"33549\"\n  , \"35390\"\n  ]\n#eval 21 <== part1 testInput\n#eval 8 <== part2 testInput\n\nend Day8", "meta": {"author": "JanWosnitza", "repo": "advent-of-code-2022", "sha": "05caceb26df7b17c5d52772d36cfe58e82d92ef6", "save_path": "github-repos/lean/JanWosnitza-advent-of-code-2022", "path": "github-repos/lean/JanWosnitza-advent-of-code-2022/advent-of-code-2022-05caceb26df7b17c5d52772d36cfe58e82d92ef6/src/Days/Day8.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.49091517258146206}}
{"text": "import data.real.basic\nimport data.set\nimport tactic\nopen push_neg\n\n\n\nnamespace tactic.interactive\nopen lean.parser tactic interactive \nopen interactive (loc.ns)\nopen interactive.types\nopen tactic expr\nlocal postfix *:9001 := many -- sinon ne comprends pas ident*\n\n/- décompose en premier caractère, reste  INUTILISE-/\ndef un_car : string → string × string\n| ⟨(x :: xs)⟩  := ( ⟨ [x] ⟩ , ⟨ xs ⟩ )\n| _ := (\"\",\"\")\n\ndef deux_car : string → string\n| ⟨(x ::  y :: xs)⟩  := ⟨ [x,y] ⟩ \n| _ := \"\"\n\ndef trois_car : string → string\n| ⟨(x ::  y :: z ::xs)⟩  := ⟨ [x,y,z] ⟩ \n| _ := \"\"\n\n/- décompose une chaine de caractères selon la première parenthèse ouvrante\nLe premier terme ne sert qu'à la récursivité  INUTILISE-/\nmeta def debut_chaine : string × string → string × string\n| (s , t ) := do\n    let d := un_car t,\n    match d  with\n        | (\"(\",reste) :=  (s,t)\n        | ( ⟨(x)⟩, reste) :=  (debut_chaine (s ++ d.1, reste )) \n        -- | _ := (\"ERREUR\", \"\")\n        end\n\n-- set_option trace.eqn_compiler.elim_match true\n-- ne fonctionne pas : le \"Prop\" est ignoré, ou bien tout est Prop ??\n-- meta def is_prop : expr →  bool\n--     | `(%%e : Prop) := tt\n   --  | _             := ff\n    \n\n-- détermine si l'expression est une propriété\n-- basé sur le fait (peut-être optimiste) que si on échoue à trouver le type, \n-- c'est qu'il y a des variables libres,\n-- et donc que c'est une propriété\nmeta def is_prop : expr →  tactic bool\n| e := do {\n    expr_t ←  infer_type e,\n    -- expr_tt ← infer_type expr_t,\n    if expr_t = `(Prop) then return tt else return ff\n        } <|> return tt\n\n\n/- Décompose la racine d'une expression (un seul pas) \n LOGICS : ET, OU, SSI, QUELQUESOIT, IMPLIQUE, FONCTION, NON, EXISTE,\nSETS: INTER, UNION, INCLUS, APPARTIENT, COMPLEMENTAIRE1,s IMAGE_ENSEMBLE, IMAGE_RECIPROQUE, \nEGALITE, ENSEMBLE1, APPLICATION\nNUMBERS: -/\nprivate meta def analyse_expr_step  (e : expr) : tactic (string × (list expr)) := \ndo  S ←  (tactic.pp e), let e_joli := to_string S, \nmatch e with\n| (lam name binder type body)          := return (\"lambda[\" ++ to_string name ++ \"]\", [type,body]) -- name → binder_info → expr → expr → expr\n------------------------- LOGIQUE -------------------------\n| `(%%p ∧ %%q) := return (\"PROP_AND\", [p,q])\n| `(%%p ∨ %%q) := return (\"PROP_OR\", [p,q])\n| `(%%p ↔ %%q) := return (\"PROP_IFF\", [p,q])\n| `(¬ %%p) := return (\"PROP_NOT\", [p])\n| `(%%p → false)  := return (\"PROP_NOT\", [p])\n| `(%%p → %%q) :=   if deux_car(to_string e) = \"Pi\" then do match e with -- solution merdique\n                        | (pi name binder type body) :=  return (\"QUANT_∀[\" ++ to_string name ++ \"]\", [p,q]) \n                        |  _ := return (\"ERROR\", [])  \n                        end                  \n                    else --if has_var p then  return (\"IMPLIQUE\", [p,q])  \n                         --else do t ← infer_type p,\n                         --if t = `(Prop) then return (\"IMPLIQUE\", [p,q])\n                         do bool ← is_prop e, \n                         if bool then return (\"PROP_IMPLIES\", [p,q])\n                         else return (\"FUNCTION\", [p,q]) \n| `(Exists %%p) := do match p with          --  améliorer : cas d'une prop, mais attention aux variables !!\n    | (lam name binder type body) := \n    -- la suite teste s'il s'agit de l'existence d'un objet ou d'une propriété\n        -- d'abord, si `body` contient des variables libres, c'est une propriété\n        -- if type.has_var then return (\"EXISTE[PROP:\" ++ to_string name ++ \"]\", [type,body])\n        -- si ce n'est pas le cas, on peut chercher son type, et voir si c'est Prop\n        -- else do type_type ← infer_type type,\n            -- if type_type = `(Prop) \n            do bool ← is_prop p, if bool\n                then return (\"PROP_∃[\" ++ to_string name ++ \"]\", [type,body])\n                else return (\"QUANT_∃[\" ++ to_string name ++ \"]\", [type,body])\n    |  _ := return (\"ERROR\", [])\n    end \n------------------------- THEORIE DES ENSEMBLES -------------------------\n| `(%%A ∩ %%B) := return (\"SET_INTER\", [A,B])\n| `(%%A ∪ %%B) := return (\"SET_UNION\", [A,B])\n| `(set.compl %%A) := return (\"SET_COMPLEMENT\", [A])\n| `(%%A \\ %%B) := return (\"SET_SYM_DIFF\", [A,B])\n| `(%%A ⊆ %%B) := return (\"PROP_INCLUDED\", [A,B])\n| `(%%a ∈ %%A) := return (\"PROP_BELONGS\", [a,A])\n| `(@set.univ %%X) := return (\"SET_UNIVERSE\", [X])\n| `(-%%A) := return (\"MINUS\", [A])   \n| `(set.Union %%A) := return (\"SET_UNION+\", [A])\n| `(set.Inter %%A) := return (\"SET_INTER+\", [A])\n| `(%%f '' %%A) := return (\"SET_IMAGE\", [f,A])\n| `(%%f  ⁻¹' %%A) := return (\"SET_INVERSE\", [f,A])\n| `(∅) := return (\"SET_EMPTY\", [])\n| `(_root_.set %%X) := return (\"SET\", [X])\n-- polymorphe\n| `(%%a = %%b) := return (\"PROP_EQUAL\", [a,b]) -- faudrait connaitre le type ?\n| `(%%a ≠ %%b) := return (\"PROP_EQUAL_NOT\", [a,b]) -- faudrait connaitre le type ?\n----------- TOPOLOGY --------------\n-- | `(B(%%x, %%r))\n\n\n---------------------------- NOMBRES particuliers (cf aussi plus bas) \n| `(0:ℝ) := return (\"NUMBER[0]\",[])               -- OK, mais peut-être faut-il garder l'info 0 : réel\n| `(0:ℕ) := return (\"NUMBER[0]\",[])               -- non testé\n| `(0:ℤ) := return (\"NUMBER[0]\",[])               -- non testé\n| `(1:ℝ) := return (\"NUMBER[1]\",[])               \n| `(1:ℕ) := return (\"NUMBER[1]\",[])               -- non testé\n| `(1:ℤ) := return (\"NUMBER[1]\",[])               -- non testé\n-- | `(0 < %%b) := return (\"POSITIF\", [b]) \n| `(%%a < %%b) := return (\"PROP_<\", [a,b]) \n| `(%%a ≤ %%b) := return (\"PROP_≤\", [a,b])\n-- | `(%%a > 0) := return (\"POSITIF\", [a])\n| `(%%a > %%b) := return (\"PROP_>\", [a,b]) \n| `(%%a ≥ %%b) := return (\"PROP_≥\", [a,b]) \n------------------------------ Meta_applications\n\n| (app fonction argument)   := -- do let Sfonction := to_string(fonction),\n    -- pour les nombres, utiliser la pretty printer de Lean\n    -- récupérer le type ?\n    if is_numeral e\n        then return (\"NUMBER[\"++e_joli ++\"]\",[]) \n    -- détecter les sous-ensembles\n--    else if to_string(fonction) = \"set.{0}\"  \n--        then return(\"SET\", [argument])\n--        else return(\"META_APPLICATION[[pp:\" ++ e_joli ++\"]]\",[fonction,argument])\n        else return(\"APPLICATION\",[fonction,argument])\n| `(ℝ) := return (\"TYPE_NUMBER[ℝ]\",[])\n| `(ℕ) := return (\"TYPE_NUMBER[ℕ]\",[])\n| (const name list_level)   := return (\"CONSTANT[name:\"++ e_joli ++ \"/\" ++ to_string name ++\"]\", []) -- name → list level → expr\n| (var nat)       := return (\"VAR[\"++ to_string nat ++ \"]\", []) --  nat → expr\n| (sort level)      := return (\"TYPE\", [])  -- level → expr\n| (mvar name pretty_name type)        := return (\"METAVAR[\" ++ to_string pretty_name ++ \"]\", []) -- name → name → expr → expr\n| (local_const name pretty_name bi type) := return (\"LOCAL_CONSTANT[name:\"++ to_string pretty_name++\"/identifier:\"++ to_string name ++ \"]\", []) -- name → name → binder_info → expr → expr\n| (elet name_var type_var expr body)        := return (\"LET[\"++ to_string name_var ++\"]\", [type_var,expr,body]) --name → expr → expr → expr → expr\n| (macro liste pas_compris)       := return (\"MACRO\", []) -- macro_def → list expr → expr\nend\n\n-- A node will be a leaf of the analysis tree iff it belongs to the following list:\n-- leaves = [\"NOMBRE\", \"CONSTANT\", \"VAR\", \"TYPE\", \"METAVAR\", \"LOCAL_CONSTANT\", \n--          \"LET\", \"MACRO\", \"ERREUR\"]    \n-- A leaf is followed by a separateur_virgule or a \")\"\n-- A node which is not a leaf is followed by a \"(\"\n\n\ndef separateur_virgule := \"¿, \"\ndef separateur_egale := \" ¿= \"\ndef open_paren := \"¿(\"\ndef closed_paren := \"¿)\"\n/- Analyse récursivement une expression à l'aide de analyse_expr_step, \nrenvoie le résultat sous forme de chaine bien parenthésée-/\nprivate meta def analyse_rec : expr →  tactic string \n| e := \ndo ⟨string, liste_expr⟩ ←  analyse_expr_step(e), \n--    bool ← is_prop e,\n--    let string := to_string bool ++ \".\" ++ string,\n    match liste_expr with\n    -- ATTENTION, cas de plus de trois arguiments non traité\n    -- à remplacer par un list.map\n    |[e1] :=  do \n       string1 ← analyse_rec e1,\n       return(string ++ open_paren ++ string1 ++ closed_paren)\n    |[e1,e2] :=  do \n        string1 ← analyse_rec e1,\n        string2 ← analyse_rec e2,\n--        if  string = \"APPLICATION\"\n--            then return (string1 ++ open_paren ++ string2 ++ closed_paren) else\n        return (string ++ open_paren ++ string1 ++ separateur_virgule ++ string2 ++ closed_paren)\n    |[e1,e2,e3] :=  do  -- non utilisé\n        string1 ← analyse_rec e1,\n        string2 ← analyse_rec e2,\n        string3 ← analyse_rec e3,\n        return (string ++ open_paren ++ string1 ++ separateur_virgule ++ string2 ++ separateur_virgule ++ string3 ++ closed_paren)\n    | _ :=    return(string)\n    end\nprivate meta def analyse_expr : expr →  tactic string\n| e := do\n    expr_t ←  infer_type e,\n    bool ← is_prop expr_t,\n    -- expr_tt ← infer_type expr_t,\n    if bool then do\n            -- S ←  (tactic.pp expr_t), \n            -- let S1 := to_string S,\n            S ←  (tactic.pp expr_t), let et_joli := to_string S, \n            S1b ← analyse_rec e,\n            S2 ← analyse_rec expr_t,\n            let S3 := \"PROPERTY[\" ++ S1b ++ \"/pp_type: \" ++ et_joli ++ \"]\" ++ separateur_egale ++ S2,\n            return(S3)\n        else  do\n            -- let S1 :=  to_string e, \n            S1b ← analyse_rec e,\n            S2 ← analyse_rec expr_t,\n            let S3 := \"OBJECT[\" ++ S1b ++ separateur_egale ++ S2,\n            return(S3)\n\n\n/- Affiche la liste des objets du contexte, séparés par des retour chariots \nformat :  \"OBJET\" ou \"PROPRIETE\" : affichage Lean : structure -/\nmeta def analyse_contexte : tactic unit :=\ndo liste_expr ← local_context,\n    trace \"context:\",\n    liste_expr.mmap (λ h, analyse_expr h >>= trace),\n    return ()\n\n\n/- Affiche la liste des buts, même format que analyse_contexte\n(excepté qu'il n'y a que des PROPRIETES) -/ \nmeta def analyse_buts : tactic unit :=\ndo liste_expr ← get_goals,\n    trace \"goals:\", \n    liste_expr.mmap (λ h, analyse_expr h >>= trace),\n    return ()\n\n\n\n---------------------------------------------------------\n--------- NON UTILISES (debuggage) ----------------------------------\n---------------------------------------------------------\n\n\n/- Appelle l'analyse récursive sur le but ou sur une hypothèse. Non utilisé par la suite. -/\nmeta def analyse (names : parse ident*) : tactic unit := \nmatch names with\n    | [] := do goal ← tactic.target,\n                trace (analyse_rec goal)\n    | [nom] := do expr ← get_local nom,\n                expr_t ←  infer_type expr,\n                expr_tt ← infer_type expr_t,\n                -- la suite différencie selon la sémantique, \n                -- ie les objets (éléments, ensembles, fonctions)\n                -- vs les propriétés\n                if expr_tt = `(Prop) then  \n                    trace (analyse_rec expr_t)\n                else  do S1 ← (analyse_rec expr), \n                        S2 ← (analyse_rec expr_t),\n                        --let S2 := to_string expr_t,\n                        let S3 := S1 ++ \" : \"++ S2,\n                        trace(S3)\n    | _ := skip\n    end\n\n/- Appelle l'analyse en 1 coup sur le but ou sur une hypothèse. Non utilisé par la suite. -/\nmeta def analyse1 (names : parse ident*) : tactic unit := \nmatch names with\n    | [] := do goal ← tactic.target,\n                trace (analyse_expr_step goal)\n    | [nom] := do expr ← get_local nom,\n                expr_t ←  infer_type expr,\n                trace (analyse_expr_step expr_t)\n    | _ := skip\n    end\n\n\n-- non utilisé\nprivate meta def analyse_expr2 : expr →  tactic string\n| e := do\n    expr_t ←  infer_type e,\n    expr_tt ← infer_type expr_t,\n    if expr_tt = `(Prop) then do\n            S ←  (tactic.pp expr_t), \n            let S1 := to_string S,\n            S2 ← analyse_rec expr_t,\n            let S3 := \"PROPRIETE : \" ++ S1 ++ \" : \" ++ S2,\n            return(S3)\n        else  do let S0 := \"OBJET : \",\n            let S1 :=  to_string e, \n            S2 ← analyse_rec expr_t,\n            let S3 := S0 ++ S1 ++ \" : \"++ S2,\n            return(S3)\n\n\n\n\n\n\n\n---------------------------------------------------------\n----------------- Essai de rendu LateX, non abouti ------\n---------------------------------------------------------\n\n\n/- transforme une expression lean en expression latex\nAMELIORER : \ntenir compte de la profondeur de l'arbre pour décider si on met des prenthèses-/\n/- ET, OU, SSI, QUELQUESOIT, IMPLIQUE, FONCTION, NON1, EXISTE,\nINTER, UNION, INCLUS, APPARTIENT, COMPLEMENTAIRE1, IMAGE_ENSEMBLE, IMAGE_RECIPROQUE, \nEGALITE, ENSEMBLE1, APPLICATION-/\nmeta def latex_expr : expr →  tactic string \n| e := do\n    ⟨string, liste_expr⟩ ←  analyse_expr_step e, \n    if list.length liste_expr =2 then do\n        let e1 := list.head liste_expr,\n        let e2 := list.head (list.tail liste_expr),\n        S1 ← latex_expr e1,\n        S2 ← latex_expr e2,\n        match string with\n            | \"ET\" := return (S1 ++ \" et \" ++ S2)\n            | \"OU\" := return (S1 ++ \" ou \" ++ S2)\n            | \"SSI\" := return (\"(\" ++ S1 ++ \"\" ++\") \\\\Leftrightarrow (\" ++ S2 ++ \")\")\n\n            | \"INCLUS\" := return (S1 ++ \"\" ++\" \\\\subset \" ++ S2)\n            | _ := return \"ERREUR\"\n            end\n\n    else if list.length liste_expr =1 then do\n        let e1 := list.head liste_expr,\n        S1 ← latex_expr e1,\n        match string with\n            | \"NON\" := return (\"NON (\" ++ S1 ++ \")\")\n            | \"COMPLEMENTAIRE\" := return (S1  ++ \"^c\")\n            | _ := return \"ERREUR\"\n            end\n    else return (string)\n\n\n\n\nmeta def latex_buts : tactic unit :=\ndo liste_expr ← get_goals,\n    trace \"Buts :\", \n    -- liste_buts ← tactic.get_goals,\n    -- types ← list.mmap tactic.infer_type liste_buts, \n    -- trace types,\n    liste_expr.mmap (λ h, latex_expr h >>= trace),\n    return ()\n\nmeta def latex_but : tactic unit :=\ndo expr ← target,\n    trace \"But :\", \n    -- liste_buts ← tactic.get_goals,\n    -- types ← list.mmap tactic.infer_type liste_buts, \n    -- trace types,\n    trace (latex_expr expr),\n    return ()\n\n\n\n----------------------------------------------\n------------- DEBUGGAGE -------------------\n-------------------------------------------\n\n/- debug -/\nprivate meta def analyse_expr_step_brut  (e : expr) : tactic (string × (list expr)) := \nmatch e with\n-- autres\n| (pi name binder type body ) := return (\"pi (nom : \" ++ to_string name ++ \")\",[type,body]) \n| (app fonction argument)   := return (\"application\", [fonction,argument])\n| (const name list_level)   := return (\"constante :\" ++ to_string name, []) -- name → list level → expr\n| (var nat)       := return (\"var_\"++ to_string nat, []) --  nat → expr\n| (sort level)      := return (\"sort\", [])  -- level → expr\n| (mvar name pretty_name type)        := return (\"metavar\", []) -- name → name → expr → expr\n| (local_const name pretty_name bi type) := return (\"constante_locale :\" ++ to_string pretty_name, []) -- name → name → binder_info → expr → expr\n| (lam name binder type body)          := return (\"lambda (nom : \" ++ to_string name ++ \")\", [type,body]) -- name → binder_info → expr → expr → expr\n| (elet name_var type_var expr body)        := return (\"let\", []) --name → expr → expr → expr → expr\n| (macro liste pas_compris)       := return (\"macro\", []) -- macro_def → list expr → expr\nend\n\n/-  Debug -/\nprivate meta def analyse_rec_brut : expr →  tactic string \n| e := \ndo ⟨string, liste_expr⟩ ←  analyse_expr_step_brut e, \n    match liste_expr with\n    -- ATTENTION, cas de plus de trois arguiments non traité\n    -- à remplacer par un list.map\n    |[e1] :=  do \n       string1 ← analyse_rec_brut e1,\n       return(string ++ \"(\" ++ string1 ++ \")\")\n    |[e1,e2] :=  do \n        string1 ← analyse_rec_brut e1,\n        string2 ← analyse_rec_brut e2,\n        if  string = \"APPLICATION\" then do \n            { type2 ← infer_type e2,\n            let string_type2 := to_string type2, -- trace string_type2, \n            if (string_type2 = \"Type\" ) ∨ (trois_car (to_string(e2)) = \"_in\" ) -- Type  ou instance\n                then return (string1)\n                else return (string1 ++ \"(\" ++ string2 ++\")\")\n            }   <|> return (string1 ++ \"(\" ++ string2 ++\")\")\n            else return (string ++ \"(\" ++ string1 ++ \",\" ++ string2 ++ \")\")\n    |[e1,e2,e3] :=  do  -- non utilisé\n        string1 ← analyse_rec_brut e1,\n        string2 ← analyse_rec_brut e2,\n        string3 ← analyse_rec_brut e3,\n        return (string ++ \"(\" ++ string1 ++ \",\" ++ string2 ++ \",\" ++ string3 ++ \")\")\n    | _ :=    return(string)\n    end\n\n/- Debug -/\nmeta def analyse_brut (names : parse ident*) : tactic unit := \nmatch names with\n    | [] := do goal ← tactic.target,\n                trace (analyse_rec_brut goal)\n    | [nom] := do expr ← get_local nom,\n                expr_t ←  infer_type expr,\n                expr_tt ← infer_type expr_t,\n                -- la suite différencie selon la sémantique, \n                -- ie les objets (éléments, ensembles, fonctions)\n                -- vs les propriétés\n                if expr_tt = `(Prop) then  \n                    trace (analyse_rec_brut expr_t)\n                else  do S1 ← (analyse_rec_brut expr), \n                        S2 ← (analyse_rec_brut expr_t),\n                        --let S2 := to_string expr_t,\n                        let S3 := S1 ++ \" : \"++ S2,\n                        trace(S3)\n    | _ := skip\n    end\n\n-- débug    \nprivate meta def analyse_expr_brut : expr →  tactic string\n| e := do\n    expr_t ←  infer_type e,\n    expr_tt ← infer_type expr_t,\n    if expr_tt = `(Prop) then do\n            S ←  (tactic.pp expr_t), \n            let S1 := to_string S,\n            S2 ← analyse_rec_brut expr_t,\n            let S3 := \"PROPRIETE : \" ++ S1 ++ \" : \" ++ S2,\n            return(S3)\n        else  do let S0 := \"OBJET : \",\n            let S1 :=  to_string e, \n            S2 ← analyse_rec_brut expr_t,\n            let S3 := S0 ++ S1 ++ \" : \"++ S2,\n            return(S3)\n\n\n\n\n\n/- Affiche la liste des objets du contexte, séparés par des retour chariots \nformat :  \"OBJET\" ou \"PROPRIETE\" : affichage Lean : structure -/\nmeta def analyse_contexte_brut : tactic unit :=\ndo liste_expr ← local_context,\n    trace \"Contexte :\",\n    liste_expr.mmap (λ h, analyse_expr_brut h >>= trace),\n    return ()\n\n\n/- Analyse brute de Lean (dans expr) -/\nmeta def analyse_raw (names : parse ident*) : tactic unit := \nmatch names with\n    | [] := do goal ← tactic.target,\n                trace $ to_raw_fmt goal\n    | [nom] := do expr ← get_local nom,\n                expr_t ←  infer_type expr,\n                trace $ to_raw_fmt expr_t\n    | _ := skip\n    end\n\nend tactic.interactive\n\n#print set\n\nexample (x:ℝ) :  x^2 ≥ 0 := \nbegin\n    analyse_contexte,\nend", "meta": {"author": "FredericLeRoux", "repo": "dEAduction-lean2", "sha": "bf7d7d88c2511ecfda5a98ed96e4ca3bc7ae1151", "save_path": "github-repos/lean/FredericLeRoux-dEAduction-lean2", "path": "github-repos/lean/FredericLeRoux-dEAduction-lean2/dEAduction-lean2-bf7d7d88c2511ecfda5a98ed96e4ca3bc7ae1151/src/snippets/tactics/structures.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.49089784843852735}}
{"text": "-- Hausdorff abelianization, i.e.\n-- quotient by the closure of the commutator\n\nimport group_theory.abelianization\nimport .topological_group\n\nuniverses u v\n\ntheorem list.prod_map {G : Type u} {H : Type v} [group G] [group H]\n  (f : G → H) [is_group_hom f] {L : list G} :\n  (L.map f).prod = f L.prod :=\nlist.rec_on L (eq.symm $ is_group_hom.one f) $ λ hd tl ih,\nby simp [ih, is_group_hom.mul f]\n\ndef commutator_subgroup (G : Type u) [group G] (S : set G) : set G :=\n{ z | ∃ L : list G, (∀ x ∈ L, ∃ p ∈ S, ∃ q ∈ S, x = p * q * p⁻¹ * q⁻¹) ∧ L.prod = z }\n\ninstance commutator_subgroup.subgroup\n  (G : Type u) [group G] (S : set G) :\n  is_subgroup (commutator_subgroup G S) :=\n{ mul_mem := λ x y ⟨L1, h1, h2⟩ ⟨L2, h3, h4⟩, ⟨L1 ++ L2,\n    list.forall_mem_append.2 ⟨h1, h3⟩,\n    by simp [h2, h4]⟩,\n  one_mem := ⟨[], by simp⟩,\n  inv_mem := λ x ⟨L, h1, h2⟩, ⟨L.reverse.map has_inv.inv,\n    λ x hx, let ⟨y, h3, h4⟩ := list.exists_of_mem_map hx in\n      let ⟨p, hp, q, hq, h5⟩ := h1 y (list.mem_reverse.1 h3) in\n      ⟨q, hq, p, hp, by rw [← h4, h5]; simp [mul_assoc]⟩,\n    by rw ← h2; from list.rec_on L (by simp) (λ hd tl ih,\n      by rw [list.reverse_cons, list.map_append, list.prod_append, ih]; simp)⟩ }\n\ninstance commutator_subgroup.normal_subgroup\n  (G : Type u) [group G] (N : set G) [normal_subgroup N] :\n  normal_subgroup (commutator_subgroup G N) :=\n{ normal := λ x ⟨L, h1, h2⟩ g, ⟨L.map $ λ z, g * z * g⁻¹,\n    λ x hx, let ⟨y, h3, h4⟩ := list.exists_of_mem_map hx in\n      let ⟨p, hp, q, hq, h5⟩ := h1 y h3 in\n      ⟨g * p * g⁻¹, normal_subgroup.normal _ hp _,\n      g * q * g⁻¹, normal_subgroup.normal _ hq _,\n      by rw [← h4, h5]; simp [mul_assoc]⟩,\n    by rw ← h2; from list.rec_on L (by simp) (λ hd tl ih,\n      by rw [list.map_cons, list.prod_cons, ih]; simp [mul_assoc])⟩ }\n\nvariables (G : Type u) (H : Type v)\nvariables [topological_space G] [group G] [topological_group G]\nvariables [topological_space H] [group H] [topological_group H]\n\ndef Hausdorff_abelianization : Type u :=\nquotient_group.quotient (closure (commutator_subgroup G set.univ))\n\nattribute [elab_as_eliminator] quotient_group.induction_on\ninstance Hausdorff_abelianization.comm_group : comm_group (Hausdorff_abelianization G) :=\n{ mul_comm := λ x y, quotient_group.induction_on x $ λ m,\n    quotient_group.induction_on y $ λ n, quotient_group.eq.2 $\n    subset_closure ⟨[n⁻¹*m⁻¹*n*m], list.forall_mem_singleton.2\n      ⟨n⁻¹, trivial, m⁻¹, trivial, by rw [inv_inv, inv_inv]⟩,\n    by rw [list.prod_cons, list.prod_nil, mul_one, mul_inv_rev, ← mul_assoc]⟩,\n  .. quotient_group.group _ }\n\ninstance Hausdorff_abelianization.topological_space : topological_space (Hausdorff_abelianization G) :=\nquotient_group.topological_space _ _\n\ninstance Hausdorff_abelianization.topological_group : topological_group (Hausdorff_abelianization G) :=\nquotient_group.topological_group _ _\n\nvariables {G H}\ndef Hausdorff_abelianization.map (f : G → H) [hf : is_topological_group_hom f] :\n  Hausdorff_abelianization G → Hausdorff_abelianization H :=\nquotient_group.map _ _ f $ (closure_subset_iff_subset_of_is_closed $\n  continuous_iff_is_closed.1 (is_topological_group_hom.cts f) _ is_closed_closure).2 $\nλ x ⟨L, hL, hLx⟩, subset_closure ⟨L.map f,\n  λ c hcfL, let ⟨b, hbL, hfbc⟩ := list.exists_of_mem_map hcfL in\n    let ⟨p, _, q, _, hb⟩ := hL b hbL in\n    ⟨f p, trivial, f q, trivial, by rw [← hfbc, hb];\n      simp only [is_group_hom.mul f, is_group_hom.inv f]⟩,\n  by rw [list.prod_map f, hLx]⟩\n\nset_option class.instance_max_depth 100\ntheorem Hausdorff_abelianization.induced.is_topological_group_hom\n  (f : G → H) [hf : is_topological_group_hom f] :\n  is_topological_group_hom (Hausdorff_abelianization.map f) :=\n{ cts := continuous_coinduced_dom $\n    show continuous (quotient_group.mk ∘ f),\n    from hf.cts.comp continuous_coinduced_rng,\n  .. quotient_group.is_group_hom_quotient_lift _ _ _ }", "meta": {"author": "kckennylau", "repo": "local-langlands-abelian", "sha": "ee22666898357dab800a0432214a22c519ed26a9", "save_path": "github-repos/lean/kckennylau-local-langlands-abelian", "path": "github-repos/lean/kckennylau-local-langlands-abelian/local-langlands-abelian-ee22666898357dab800a0432214a22c519ed26a9/src/abelianization.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6477982179521105, "lm_q1q2_score": 0.4908978432858521}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebraic_geometry.presheafed_space\nimport topology.category.Top.limits\nimport topology.sheaves.limits\nimport category_theory.limits.concrete_category\n\n/-!\n# `PresheafedSpace C` has colimits.\n\nIf `C` has limits, then the category `PresheafedSpace C` has colimits,\nand the forgetful functor to `Top` preserves these colimits.\n\nWhen restricted to a diagram where the underlying continuous maps are open embeddings,\nthis says that we can glue presheaved spaces.\n\nGiven a diagram `F : J ⥤ PresheafedSpace C`,\nwe first build the colimit of the underlying topological spaces,\nas `colimit (F ⋙ PresheafedSpace.forget C)`. Call that colimit space `X`.\n\nOur strategy is to push each of the presheaves `F.obj j`\nforward along the continuous map `colimit.ι (F ⋙ PresheafedSpace.forget C) j` to `X`.\nSince pushforward is functorial, we obtain a diagram `J ⥤ (presheaf C X)ᵒᵖ`\nof presheaves on a single space `X`.\n(Note that the arrows now point the other direction,\nbecause this is the way `PresheafedSpace C` is set up.)\n\nThe limit of this diagram then constitutes the colimit presheaf.\n-/\n\nnoncomputable theory\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen Top.presheaf\nopen topological_space\nopen opposite\nopen category_theory.category\nopen category_theory.limits\nopen category_theory.functor\n\nvariables {J : Type v} [small_category J]\nvariables {C : Type u} [category.{v} C]\n\n\nnamespace algebraic_geometry\n\nnamespace PresheafedSpace\n\nlocal attribute [simp] eq_to_hom_map\n\n@[simp]\nlemma map_id_c_app (F : J ⥤ PresheafedSpace C) (j) (U) :\n  (F.map (𝟙 j)).c.app (op U) =\n    (pushforward.id (F.obj j).presheaf).inv.app (op U) ≫\n      (pushforward_eq (by { simp, refl }) (F.obj j).presheaf).hom.app (op U) :=\nbegin\n  cases U,\n  dsimp,\n  simp [PresheafedSpace.congr_app (F.map_id j)],\n  refl,\nend\n\n@[simp]\n\n\n/--\nGiven a diagram of presheafed spaces,\nwe can push all the presheaves forward to the colimit `X` of the underlying topological spaces,\nobtaining a diagram in `(presheaf C X)ᵒᵖ`.\n-/\n@[simps]\ndef pushforward_diagram_to_colimit (F : J ⥤ PresheafedSpace C) :\n  J ⥤ (presheaf C (colimit (F ⋙ PresheafedSpace.forget C)))ᵒᵖ :=\n{ obj := λ j, op ((colimit.ι (F ⋙ PresheafedSpace.forget C) j) _* (F.obj j).presheaf),\n  map := λ j j' f,\n  (pushforward_map (colimit.ι (F ⋙ PresheafedSpace.forget C) j') (F.map f).c ≫\n    (pushforward.comp (F.obj j).presheaf ((F ⋙ PresheafedSpace.forget C).map f)\n      (colimit.ι (F ⋙ PresheafedSpace.forget C) j')).inv ≫\n    (pushforward_eq (colimit.w (F ⋙ PresheafedSpace.forget C) f) (F.obj j).presheaf).hom).op,\n  map_id' := λ j,\n  begin\n    apply (op_equiv _ _).injective,\n    ext U,\n    induction U using opposite.rec,\n    cases U,\n    dsimp, simp, dsimp, simp,\n  end,\n  map_comp' := λ j₁ j₂ j₃ f g,\n  begin\n    apply (op_equiv _ _).injective,\n    ext U,\n    dsimp,\n    simp only [map_comp_c_app, id.def, eq_to_hom_op, pushforward_map_app, eq_to_hom_map, assoc,\n      id_comp, pushforward.comp_inv_app, pushforward_eq_hom_app],\n    dsimp,\n    simp only [eq_to_hom_trans, id_comp],\n    congr' 1,\n    -- The key fact is `(F.map f).c.congr`,\n    -- which allows us in rewrite in the argument of `(F.map f).c.app`.\n    rw (F.map f).c.congr,\n    -- Now we pick up the pieces. First, we say what we want to replace that open set by:\n    swap 3,\n    refine op ((opens.map (colimit.ι (F ⋙ PresheafedSpace.forget C) j₂)).obj (unop U)),\n    -- Now we show the open sets are equal.\n    swap 2,\n    { apply unop_injective,\n      rw ←opens.map_comp_obj,\n      congr,\n      exact colimit.w (F ⋙ PresheafedSpace.forget C) g, },\n    -- Finally, the original goal is now easy:\n    swap 2,\n    { simp, refl, },\n  end, }\n\nvariables [has_limits C]\n\n/--\nAuxiliary definition for `PresheafedSpace.has_colimits`.\n-/\ndef colimit (F : J ⥤ PresheafedSpace C) : PresheafedSpace C :=\n{ carrier := colimit (F ⋙ PresheafedSpace.forget C),\n  presheaf := limit (pushforward_diagram_to_colimit F).left_op, }\n\n@[simp] lemma colimit_carrier (F : J ⥤ PresheafedSpace C) :\n  (colimit F).carrier = limits.colimit (F ⋙ PresheafedSpace.forget C) := rfl\n\n@[simp] lemma colimit_presheaf (F : J ⥤ PresheafedSpace C) :\n  (colimit F).presheaf = limit (pushforward_diagram_to_colimit F).left_op := rfl\n\n/--\nAuxiliary definition for `PresheafedSpace.has_colimits`.\n-/\n@[simps]\ndef colimit_cocone (F : J ⥤ PresheafedSpace C) : cocone F :=\n{ X := colimit F,\n  ι :=\n  { app := λ j,\n    { base := colimit.ι (F ⋙ PresheafedSpace.forget C) j,\n      c := limit.π _ (op j), },\n    naturality' := λ j j' f,\n    begin\n      fapply PresheafedSpace.ext,\n      { ext x,\n        exact colimit.w_apply (F ⋙ PresheafedSpace.forget C) f x, },\n      { ext U,\n        induction U using opposite.rec,\n        cases U,\n        dsimp,\n        simp only [PresheafedSpace.id_c_app, eq_to_hom_op, eq_to_hom_map, assoc,\n          pushforward.comp_inv_app],\n        rw ← congr_arg nat_trans.app (limit.w (pushforward_diagram_to_colimit F).left_op f.op),\n        dsimp,\n        simp only [eq_to_hom_op, eq_to_hom_map, assoc, id_comp, pushforward.comp_inv_app],\n        congr,\n        dsimp,\n        simp only [id_comp],\n        simpa, }\n    end, }, }\n\nnamespace colimit_cocone_is_colimit\n\n/--\nAuxiliary definition for `PresheafedSpace.colimit_cocone_is_colimit`.\n-/\ndef desc_c_app (F : J ⥤ PresheafedSpace C) (s : cocone F) (U : (opens ↥(s.X.carrier))ᵒᵖ) :\n  s.X.presheaf.obj U ⟶\n    (colimit.desc (F ⋙ PresheafedSpace.forget C)\n         ((PresheafedSpace.forget C).map_cocone s) _*\n       limit (pushforward_diagram_to_colimit F).left_op).obj\n      U :=\nbegin\n  refine\n    limit.lift _ { X := s.X.presheaf.obj U, π := { app := λ j, _, naturality' := λ j j' f, _, }} ≫\n      (limit_obj_iso_limit_comp_evaluation _ _).inv,\n  -- We still need to construct the `app` and `naturality'` fields omitted above.\n  { refine (s.ι.app (unop j)).c.app U ≫ (F.obj (unop j)).presheaf.map (eq_to_hom _),\n    dsimp,\n    rw ←opens.map_comp_obj,\n    simp, },\n  { rw (PresheafedSpace.congr_app (s.w f.unop).symm U),\n    dsimp,\n    have w := functor.congr_obj (congr_arg opens.map\n      (colimit.ι_desc ((PresheafedSpace.forget C).map_cocone s) (unop j))) (unop U),\n    simp only [opens.map_comp_obj_unop] at w,\n    replace w := congr_arg op w,\n    have w' := nat_trans.congr (F.map f.unop).c w,\n    rw w',\n    dsimp, simp, dsimp, simp, },\nend\n\nlemma desc_c_naturality (F : J ⥤ PresheafedSpace C) (s : cocone F)\n  {U V : (opens ↥(s.X.carrier))ᵒᵖ} (i : U ⟶ V) :\n  s.X.presheaf.map i ≫ desc_c_app F s V =\n  desc_c_app F s U ≫ (colimit.desc (F ⋙ forget C)\n    ((forget C).map_cocone s) _* (colimit_cocone F).X.presheaf).map i :=\nbegin\n  dsimp [desc_c_app],\n  ext,\n  simp only [limit.lift_π, nat_trans.naturality, limit.lift_π_assoc, eq_to_hom_map, assoc,\n    pushforward_obj_map, nat_trans.naturality_assoc, op_map,\n    limit_obj_iso_limit_comp_evaluation_inv_π_app_assoc,\n    limit_obj_iso_limit_comp_evaluation_inv_π_app],\n  dsimp,\n  have w := functor.congr_hom (congr_arg opens.map\n    (colimit.ι_desc ((PresheafedSpace.forget C).map_cocone s) (unop j))) (i.unop),\n  simp only [opens.map_comp_map] at w,\n  replace w := congr_arg quiver.hom.op w,\n  rw w,\n  dsimp, simp,\nend\n\n/--\nAuxiliary definition for `PresheafedSpace.colimit_cocone_is_colimit`.\n-/\ndef desc (F : J ⥤ PresheafedSpace C) (s : cocone F) : colimit F ⟶ s.X :=\n{ base := colimit.desc (F ⋙ PresheafedSpace.forget C) ((PresheafedSpace.forget C).map_cocone s),\n  c :=\n  { app := λ U, desc_c_app F s U,\n    naturality' := λ U V i, desc_c_naturality F s i } }\n\nlemma desc_fac  (F : J ⥤ PresheafedSpace C) (s : cocone F) (j : J) :\n  (colimit_cocone F).ι.app j ≫ desc F s = s.ι.app j :=\nbegin\n  fapply PresheafedSpace.ext,\n  { simp [desc] },\n  { ext,\n    dsimp [desc, desc_c_app],\n    simpa }\nend\n\nend colimit_cocone_is_colimit\n\nopen colimit_cocone_is_colimit\n\n/--\nAuxiliary definition for `PresheafedSpace.has_colimits`.\n-/\ndef colimit_cocone_is_colimit (F : J ⥤ PresheafedSpace C) : is_colimit (colimit_cocone F) :=\n{ desc := λ s, desc F s,\n  fac' := λ s, desc_fac F s,\n  uniq' := λ s m w,\n  begin\n    -- We need to use the identity on the continuous maps twice, so we prepare that first:\n    have t : m.base = colimit.desc (F ⋙ PresheafedSpace.forget C)\n                        ((PresheafedSpace.forget C).map_cocone s),\n    { apply category_theory.limits.colimit.hom_ext, intros j,\n      apply continuous_map.ext, intros x,\n      dsimp,\n      simp only [colimit.ι_desc_apply, map_cocone_ι_app],\n      rw ← w j,\n      simp, },\n    fapply PresheafedSpace.ext, -- could `ext` please not reorder goals?\n    { exact t, },\n    { ext U j, dsimp [desc, desc_c_app],\n      simp only [limit.lift_π, eq_to_hom_op, eq_to_hom_map, assoc,\n        limit_obj_iso_limit_comp_evaluation_inv_π_app],\n      rw PresheafedSpace.congr_app (w (unop j)).symm U,\n      dsimp,\n      have w := congr_arg op (functor.congr_obj (congr_arg opens.map t) (unop U)),\n      rw nat_trans.congr (limit.π (pushforward_diagram_to_colimit F).left_op j) w,\n      simp }\n  end, }\n\n/--\nWhen `C` has limits, the category of presheaved spaces with values in `C` itself has colimits.\n-/\ninstance : has_colimits (PresheafedSpace C) :=\n{ has_colimits_of_shape := λ J 𝒥, by exactI\n  { has_colimit := λ F, has_colimit.mk\n    { cocone     := colimit_cocone F,\n      is_colimit := colimit_cocone_is_colimit F } } }\n\n/--\nThe underlying topological space of a colimit of presheaved spaces is\nthe colimit of the underlying topological spaces.\n-/\ninstance forget_preserves_colimits : preserves_colimits (PresheafedSpace.forget C) :=\n{ preserves_colimits_of_shape := λ J 𝒥, by exactI\n  { preserves_colimit := λ F, preserves_colimit_of_preserves_colimit_cocone\n    (colimit_cocone_is_colimit F)\n    begin\n      apply is_colimit.of_iso_colimit (colimit.is_colimit _),\n      fapply cocones.ext,\n      { refl, },\n      { intro j, dsimp, simp, }\n    end } }\n\n/--\nGiven a diagram of `PresheafedSpace C`s, its colimit is computed by pushing the sheaves onto\nthe colimit of the underlying spaces, and taking componentwise limit.\nThis is the componentwise diagram for an open set `U` of the colimit of the underlying spaces.\n-/\n@[simps]\ndef componentwise_diagram (F : J ⥤ PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) : Jᵒᵖ ⥤ C :=\n{ obj := λ j, (F.obj (unop j)).presheaf.obj (op ((opens.map (colimit.ι F (unop j)).base).obj U)),\n  map := λ j k f, (F.map f.unop).c.app _ ≫ (F.obj (unop k)).presheaf.map\n    (eq_to_hom (by { rw [← colimit.w F f.unop, comp_base], refl })),\n  map_comp' := λ i j k f g,\n  begin\n    cases U,\n    dsimp,\n    simp_rw [map_comp_c_app, category.assoc],\n    congr' 1,\n    rw [Top.presheaf.pushforward.comp_inv_app, Top.presheaf.pushforward_eq_hom_app,\n      category_theory.nat_trans.naturality_assoc, Top.presheaf.pushforward_map_app],\n    congr' 1,\n    rw [category.id_comp, ← (F.obj (unop k)).presheaf.map_comp],\n    erw ← (F.obj (unop k)).presheaf.map_comp,\n    congr\n  end }\n\n/--\nThe components of the colimit of a diagram of `PresheafedSpace C` is obtained\nvia taking componentwise limits.\n-/\ndef colimit_presheaf_obj_iso_componentwise_limit (F : J ⥤ PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) :\n  (limits.colimit F).presheaf.obj (op U) ≅ limit (componentwise_diagram F U) :=\nbegin\n  refine ((sheaf_iso_of_iso (colimit.iso_colimit_cocone\n    ⟨_, colimit_cocone_is_colimit F⟩).symm).app (op U)).trans _,\n  refine (limit_obj_iso_limit_comp_evaluation _ _).trans (limits.lim.map_iso _),\n  fapply nat_iso.of_components,\n  { intro X,\n    refine ((F.obj (unop X)).presheaf.map_iso (eq_to_iso _)),\n    dsimp only [functor.op, unop_op, opens.map],\n    congr' 2,\n    rw set.preimage_preimage,\n    simp_rw ← comp_app,\n    congr' 2,\n    exact ι_preserves_colimits_iso_inv (forget C) F (unop X) },\n  { intros X Y f,\n    change ((F.map f.unop).c.app _ ≫ _ ≫ _) ≫ (F.obj (unop Y)).presheaf.map _ = _ ≫ _,\n    rw Top.presheaf.pushforward.comp_inv_app,\n    erw category.id_comp,\n    rw category.assoc,\n    erw [← (F.obj (unop Y)).presheaf.map_comp, (F.map f.unop).c.naturality_assoc,\n      ← (F.obj (unop Y)).presheaf.map_comp],\n    congr }\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_inv_ι_app (F : J ⥤ PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n  (colimit_presheaf_obj_iso_componentwise_limit F U).inv ≫ (colimit.ι F j).c.app (op U) =\n    limit.π _ (op j) :=\nbegin\n  delta colimit_presheaf_obj_iso_componentwise_limit,\n  rw [iso.trans_inv, iso.trans_inv, iso.app_inv, sheaf_iso_of_iso_inv, pushforward_to_of_iso_app,\n    congr_app (iso.symm_inv _)],\n  simp_rw category.assoc,\n  rw [← functor.map_comp_assoc, nat_trans.naturality],\n  erw ← comp_c_app_assoc,\n  rw congr_app (colimit.iso_colimit_cocone_ι_hom _ _),\n  simp_rw category.assoc,\n  erw [limit_obj_iso_limit_comp_evaluation_inv_π_app_assoc, lim_map_π_assoc],\n  convert category.comp_id _,\n  erw ← (F.obj j).presheaf.map_id,\n  iterate 2 { erw ← (F.obj j).presheaf.map_comp },\n  congr\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_hom_π (F : J ⥤ PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n    (colimit_presheaf_obj_iso_componentwise_limit F U).hom ≫ limit.π _ (op j) =\n      (colimit.ι F j).c.app (op U) :=\nby rw [← iso.eq_inv_comp, colimit_presheaf_obj_iso_componentwise_limit_inv_ι_app]\n\nend PresheafedSpace\n\nend algebraic_geometry\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebraic_geometry/presheafed_space/has_colimits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.490897843285852}}
{"text": "import SciLean.Basic\nimport SciLean.Tactic\nimport SciLean.Operators.Calculus.RevCore\n\nnamespace SciLean\n\nvariable {α β γ : Type}\nvariable {X Y Z : Type} [Hilbert X] [Hilbert Y] [Hilbert Z]\nvariable {ι κ : Type} [Enumtype ι] [Enumtype κ]\n\nvariable {n : Nat} [NonZero n]\n\n-- set_option trace.Meta.Tactic.simp true in\nexample\n  : 𝓑 (λ x : Fin n → Fin 3 → ℝ => ∑ i j, ∥x i - x j∥²)\n    = \n    0 := \nby\n  simp\n  simp\n  admit\n\n\ninstance (x y : X) : HasAdjoint λ dx => ∂ (λ x y : X => x - y) x dx y := \nby \n  simp infer_instance done\n\ninstance (x y : X) : HasAdjoint λ dy => ∂ (λ y : X => x - y) y dy := \nby \n  simp\n  infer_instance done\n\n\nvariable (f : (α → (β×(β→α))))\n\n@[simp]\ntheorem reverse_comp_id {α β : Type} (f : (α → (β×(β→α)))) \n  : f • (λ x => (x, λ dx => dx)) = f := \nby     \n  funext x; simp[reverse_comp]\n  conv => lhs; enter [2,x]; simp\n  done\n\n@[simp]\ntheorem reverse_id_comp {α β : Type} (f : (α → (β×(β→α)))) \n  : (λ x => (x, λ dx => dx)) • f = f :=\nby     \n  funext x; simp[reverse_comp]\n  conv => lhs; enter [2,x]; simp\n  done\n\n\n\nexample (i j : Fin n) \n  : (𝓑 fun (x : Fin n → X) => x i - x j)\n    =\n    (fun x : X×X => (x.1 - x.2, fun dx : X => (dx, -dx))) •\n      ReverseDiff.reverse_lmap \n        (fun fx : Fin n → X => (fx i, fun (dv : X) k => kron i k * dv)) \n        (fun fx : Fin n → X => (fx j, fun (dv : X) k => kron j k * dv))\n   :=\nby\n  simp\n  simp[reverse_diff, Function.uncurry, adjoint_differential]\n  done\n\n\n-- These collect what needs to be defined for atomic functions\n\n\nsection NN\n  variable {X₀ X₁ X₂ X₃ : Type} [Hilbert X₀] [Hilbert X₁] [Hilbert X₂] [Hilbert X₃]\n  variable {W₁ W₂ : Type} [Hilbert W₁] [Hilbert W₂] [Hilbert W₃]\n  variable (f₁ : W₁ → X₀ → X₁) [IsSmooth f₁] [∀ w, IsSmooth (f₁ w)]\n     [∀ w x, HasAdjoint λ dw => ∂ f₁ w dw x]\n     [∀ w x, HasAdjoint λ dx => ∂ (f₁ w) x dx]\n  variable (f₂ : W₂ → X₁ → X₂) [IsSmooth f₂] [∀ w, IsSmooth (f₂ w)]\n     [∀ w x, HasAdjoint λ dw => ∂ f₂ w dw x]\n     [∀ w x, HasAdjoint λ dx => ∂ (f₂ w) x dx]\n  variable (f₃ : W₃ → X₂ → X₃) [IsSmooth f₃] [∀ w, IsSmooth (f₃ w)]\n     [∀ w x, HasAdjoint λ dw => ∂ f₃ w dw x]\n     [∀ w x, HasAdjoint λ dx => ∂ (f₃ w) x dx]\n\n     -- [∀ x₀ (x : W₁ × W₂), SciLean.HasAdjoint (SciLean.differential (fun x => f₁ x.1 x₀) x)]\n     -- [∀ (x₀ : X₀) (x : W₁ × W₂), SciLean.HasAdjoint (SciLean.differential (fun x => x₀) x)]\n\n  instance (x : W₁ × W₂) : SciLean.HasAdjoint (∂ (fun x => x.1) x) := sorry\n  instance (x : W₁ × W₂) : SciLean.HasAdjoint (∂ (fun x => x.2) x) := sorry\n\n\n  instance (f : X → W₁×W₂) [IsSmooth f] [HasAdjoint (∂ f x)] : SciLean.HasAdjoint (∂ (fun x => (f x).1) x) := by simp admit\n  instance (f : X → W₁×W₂) [IsSmooth f] [HasAdjoint (∂ f x)] : SciLean.HasAdjoint (∂ (fun x => (f x).2) x) := by simp admit\n\n\n  -- instance : ∀ (x : W₁ × W₂ × W₃), SciLean.HasAdjoint (SciLean.differential (fun x => x.2.2) x) := by infer_instance done\n\n  -- set_option trace.Meta.synthInstance true in\n  -- instance : IsSmooth (λ ((w₁,w₂,w₃) : W₁ × W₂ × W₃) => w₃) := by  infer_instance \n\n  @[simp]\n  theorem reverse_diff_of_id\n    : 𝓑 (λ x : X => x) = λ x => (x, λ dx => dx) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_const (y : Y)\n    : 𝓑 (λ x : X => y) = λ x => (y, λ dy : Y => (0:X)) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_fst\n    : 𝓑 (λ xy : X×Y => xy.1) = λ xy => (xy.1, λ dx => (dx, (0:Y))) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_snd\n    : 𝓑 (λ xy : X×Y => xy.2) = λ xy => (xy.2, λ dy => ((0:X), dy)) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_fst_comp (f : X → Y×Z) [IsSmooth f] [∀ x, HasAdjoint (∂ f x)]\n    : 𝓑 (λ x : X => (f x).1) = (λ yz => (yz.1, λ dy => (dy, (0:Z)))) • 𝓑 f := \n  by \n    funext x; simp[reverse_diff,reverse_comp]\n    funext dy; simp\n    admit\n\n  @[simp]\n  theorem reverse_diff_of_snd_comp (f : X → Y×Z) [IsSmooth f] [∀ x, HasAdjoint (∂ f x)]\n    : 𝓑 (λ x : X => (f x).2) = (λ yz => (yz.2, λ dz => ((0:Y), dz))) • 𝓑 f :=\n  by \n    funext x; simp[reverse_diff,reverse_comp]\n    funext dy; simp\n    admit\n\n  -- instance : SciLean.IsSmooth fun x => f₂ x.2.1 (f₁ x.1 x₀)\n  -- set_option trace.Meta.synthInstance true in\n  -- set_option maxHeartbeats 1000000 in\n  -- set_option synthInstance.maxHeartbeats 500000 in\n  set_option synthInstance.maxSize 20480 in\n  -- set_option trace.Meta.Tactic.simp.discharge true in\n  example (x₀ : X₀)\n    -- : 𝓑 (λ (w₁,w₂,w₃) => x₀ |> f₁ w₁ |> f₂ w₂ |> f₃ w₃) = 0 :=\n    : 𝓑 (λ (w₁,w₂,w₃) => x₀ |> f₁ w₁ |> f₂ w₂ |> f₃ w₃) = 0 :=\n  by\n    simp\n    conv =>\n      lhs\n      conv =>\n        enter [2,1]\n        simp [reverse_comp, Function.comp]\n      conv =>\n        enter [2,2,2,1]\n        simp [reverse_comp, Function.comp]\n      conv =>\n        enter [2,2,2,2,2]\n        simp [reverse_comp, Function.comp, ReverseDiff.reverse_lmap]\n    . \n    -- simp (config := {singlePass := true})\n\n    -- simp[reverse_diff,Function.uncurry]\n    -- -- unfold hold\n    -- unfold_atomic\n    -- simp[AtomicAdjointFun.adj,ReverseDiff.reverse_lmap]\n    -- unfold hold\n\n    unfold hold\n    admit\n\nend NN\n\n#check Sigma\n\nstructure HArray (Ts : List Type) where\n  data : Array (Sigma (λ T : Type => T))\n  h_len : Ts.length = data.size\n  typed : ∀ i : Fin Ts.length, (data.get (h_len ▸ i)).1 = Ts.get i\n\nnamespace HArray\n\n  variable {n} {Ts : List Type}\n\n  def get (u : HArray Ts) (i : Fin Ts.length) : Ts.get i\n    := u.typed i ▸ (u.data.get (u.h_len ▸ i)).2\n\n  def getOp (self : HArray Ts) (idx : Fin Ts.length) : Ts.get idx\n    := self.typed idx ▸ (self.data.get (self.h_len ▸ idx)).2\n\n  def set (u : HArray Ts) (i : Fin Ts.length) (x : Ts.get i) : HArray Ts\n    := ⟨u.data.set (u.h_len ▸ i) (⟨_, x⟩), sorry, sorry⟩\n\nend HArray\n\nclass HCurryType (n : Nat) (F : Type) where\n  Xs : List Type\n  Y  : Type\n\nattribute [reducible] HCurryType.Xs HCurryType.Y\n\n@[reducible]\ninstance : HCurryType 0 Y where\n  Xs := []\n  Y := Y\n\n@[reducible]\ninstance [t : HCurryType n Y] : HCurryType (n + 1) (X → Y) where\n  Xs := X::t.Xs\n  Y := t.Y\n\nclass HCurryImpl (i : Nat) (Xs' Xs : List Type) (Y : Type) where\n  index_valid : Xs'.length + i = Xs.length\n  types_valid : ∀ j, i + j < Xs.length → Xs'.get ⟨j, sorry⟩ = Xs.get ⟨i + j, sorry⟩\n  G : Type\n  uncurry : G → (HArray Xs → Y)\n\nattribute [reducible] HCurryImpl.G HCurryImpl.uncurry\n\n@[reducible]\ninstance (Xs : List Type) (Y : Type) : HCurryImpl n [] Xs Y where\n  index_valid := sorry\n  types_valid := sorry\n  G := Y\n  uncurry := λ y xs => y\n\n@[reducible]\ninstance [c : HCurryImpl (i+1) (Xs') Xs Y] : HCurryImpl (i) (X'::Xs') Xs Y where\n  index_valid := sorry\n  types_valid := sorry\n  G := X' → c.G\n  uncurry := λ f xs => \n    let h : (Xs.get ⟨i,sorry⟩ = X') := sorry\n    let xi : X' := (h ▸ xs[⟨i,sorry⟩])\n    c.uncurry (f xi) xs\n\ndef huncurry (n : Nat) {F : Type} [HCurryType n F] \n  [ci : HCurryImpl 0 (HCurryType.Xs n F) (HCurryType.Xs n F) (HCurryType.Y n F)] \n  (f : F) := \n    let h : F = ci.G := sorry\n    ci.uncurry (h ▸ f)\n\n-- example : huncurry 3 (λ (i j k : Nat) => i + j) \n--           = \n--           λ xs => xs[⟨0, by decide⟩] + xs[⟨1, by decide⟩] := by simp[huncurry]\n\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/test/basic_reverse_diff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.490897843285852}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module algebra.homology.Module\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Homology.Homotopy\nimport Mathbin.Algebra.Category.Module.Abelian\nimport Mathbin.Algebra.Category.Module.Subobject\nimport Mathbin.CategoryTheory.Limits.ConcreteCategory\n\n/-!\n# Complexes of modules\n\nWe provide some additional API to work with homological complexes in `Module R`.\n-/\n\n\nuniverse v u\n\nopen Classical\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Limits HomologicalComplex\n\nvariable {R : Type v} [Ring R]\n\nvariable {ι : Type _} {c : ComplexShape ι} {C D : HomologicalComplex (ModuleCat.{u} R) c}\n\nnamespace ModuleCat\n\n/-- To prove that two maps out of a homology group are equal,\nit suffices to check they are equal on the images of cycles.\n-/\ntheorem homology_ext {L M N K : ModuleCat R} {f : L ⟶ M} {g : M ⟶ N} (w : f ≫ g = 0)\n    {h k : homology f g w ⟶ K}\n    (w :\n      ∀ x : LinearMap.ker g,\n        h (cokernel.π (imageToKernel _ _ w) (toKernelSubobject x)) =\n          k (cokernel.π (imageToKernel _ _ w) (toKernelSubobject x))) :\n    h = k := by\n  refine' cokernel_funext fun n => _\n  -- Gosh it would be nice if `equiv_rw` could directly use an isomorphism, or an enriched `≃`.\n  equiv_rw(kernel_subobject_iso g ≪≫ ModuleCat.kernelIsoKer g).toLinearEquiv.toEquiv  at n\n  convert w n <;> simp [to_kernel_subobject]\n#align Module.homology_ext ModuleCat.homology_ext\n\n/-- Bundle an element `C.X i` such that `C.d_from i x = 0` as a term of `C.cycles i`. -/\nabbrev toCycles {C : HomologicalComplex (ModuleCat.{u} R) c} {i : ι}\n    (x : LinearMap.ker (C.dFrom i)) : C.cycles i :=\n  toKernelSubobject x\n#align Module.to_cycles ModuleCat.toCycles\n\n@[ext]\ntheorem cycles_ext {C : HomologicalComplex (ModuleCat.{u} R) c} {i : ι} {x y : C.cycles i}\n    (w : (C.cycles i).arrow x = (C.cycles i).arrow y) : x = y :=\n  by\n  apply_fun (C.cycles i).arrow using (ModuleCat.mono_iff_injective _).mp (cycles C i).arrow_mono\n  exact w\n#align Module.cycles_ext ModuleCat.cycles_ext\n\nattribute [local instance] concrete_category.has_coe_to_sort\n\n@[simp]\ntheorem cyclesMap_toCycles (f : C ⟶ D) {i : ι} (x : LinearMap.ker (C.dFrom i)) :\n    (cyclesMap f i) (toCycles x) = toCycles ⟨f.f i x.1, by simp [x.2]⟩ :=\n  by\n  ext\n  simp\n#align Module.cycles_map_to_cycles ModuleCat.cyclesMap_toCycles\n\n/-- Build a term of `C.homology i` from an element `C.X i` such that `C.d_from i x = 0`. -/\nabbrev toHomology {C : HomologicalComplex (ModuleCat.{u} R) c} {i : ι}\n    (x : LinearMap.ker (C.dFrom i)) : C.homology i :=\n  homology.π (C.dTo i) (C.dFrom i) _ (toCycles x)\n#align Module.to_homology ModuleCat.toHomology\n\n@[ext]\ntheorem homology_ext' {M : ModuleCat R} (i : ι) {h k : C.homology i ⟶ M}\n    (w : ∀ x : LinearMap.ker (C.dFrom i), h (toHomology x) = k (toHomology x)) : h = k :=\n  homology_ext _ w\n#align Module.homology_ext' ModuleCat.homology_ext'\n\n/-- We give an alternative proof of `homology_map_eq_of_homotopy`,\nspecialized to the setting of `V = Module R`,\nto demonstrate the use of extensionality lemmas for homology in `Module R`. -/\nexample (f g : C ⟶ D) (h : Homotopy f g) (i : ι) :\n    (homologyFunctor (ModuleCat.{u} R) c i).map f = (homologyFunctor (ModuleCat.{u} R) c i).map g :=\n  by\n  -- To check that two morphisms out of a homology group agree, it suffices to check on cycles:\n  ext\n  simp only [homologyFunctor_map, homology.π_map_apply]\n  -- To check that two elements are equal mod boundaries, it suffices to exhibit a boundary:\n  ext1\n  swap; exact (toPrev i h.hom) x.1\n  -- Moreover, to check that two cycles are equal, it suffices to check their underlying elements:\n  ext1\n  simp only [map_add, imageToKernel_arrow_apply, HomologicalComplex.Hom.sqFrom_left,\n    ModuleCat.toKernelSubobject_arrow, CategoryTheory.Limits.kernelSubobjectMap_arrow_apply,\n    dNext_eq_dFrom_fromNext, Function.comp_apply, zero_add, ModuleCat.coe_comp, LinearMap.add_apply,\n    map_zero, Subtype.val_eq_coe, CategoryTheory.Limits.imageSubobject_arrow_comp_apply,\n    LinearMap.map_coe_ker, prevD_eq_toPrev_dTo, h.comm i, x.2]\n  abel\n\nend ModuleCat\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Homology/Module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.4907447041694754}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang\n\n! This file was ported from Lean 3 source module algebra.module.graded_module\n! leanprover-community/mathlib commit 59cdeb0da2480abbc235b7e611ccd9a7e5603d7c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.RingTheory.GradedAlgebra.Basic\nimport Mathbin.Algebra.GradedMulAction\nimport Mathbin.Algebra.DirectSum.Decomposition\nimport Mathbin.Algebra.Module.BigOperators\n\n/-!\n# Graded Module\n\nGiven an `R`-algebra `A` graded by `𝓐`, a graded `A`-module `M` is expressed as\n`direct_sum.decomposition 𝓜` and `set_like.has_graded_smul 𝓐 𝓜`.\nThen `⨁ i, 𝓜 i` is an `A`-module and is isomorphic to `M`.\n\n## Tags\n\ngraded module\n-/\n\n\nsection\n\nopen DirectSum\n\nvariable {ι : Type _} (A : ι → Type _) (M : ι → Type _)\n\nnamespace DirectSum\n\nopen GradedMonoid\n\n/-- A graded version of `distrib_mul_action`. -/\nclass GdistribMulAction [AddMonoid ι] [GMonoid A] [∀ i, AddMonoid (M i)] extends\n  GMulAction A M where\n  smul_add {i j} (a : A i) (b c : M j) : smul a (b + c) = smul a b + smul a c\n  smul_zero {i j} (a : A i) : smul a (0 : M j) = 0\n#align direct_sum.gdistrib_mul_action DirectSum.GdistribMulAction\n\n/-- A graded version of `module`. -/\nclass Gmodule [AddMonoid ι] [∀ i, AddMonoid (A i)] [∀ i, AddMonoid (M i)] [GMonoid A] extends\n  GdistribMulAction A M where\n  add_smul {i j} (a a' : A i) (b : M j) : smul (a + a') b = smul a b + smul a' b\n  zero_smul {i j} (b : M j) : smul (0 : A i) b = 0\n#align direct_sum.gmodule DirectSum.Gmodule\n\n/-- A graded version of `semiring.to_module`. -/\ninstance Gsemiring.toGmodule [DecidableEq ι] [AddMonoid ι] [∀ i : ι, AddCommMonoid (A i)]\n    [Gsemiring A] : Gmodule A A :=\n  { GMonoid.toGMulAction A with\n    smul_add := fun _ _ => Gsemiring.mul_add\n    smul_zero := fun i j => Gsemiring.mul_zero\n    add_smul := fun i j => Gsemiring.add_mul\n    zero_smul := fun i j => Gsemiring.zero_mul }\n#align direct_sum.gsemiring.to_gmodule DirectSum.Gsemiring.toGmodule\n\nvariable [AddMonoid ι] [∀ i : ι, AddCommMonoid (A i)] [∀ i, AddCommMonoid (M i)]\n\n/-- The piecewise multiplication from the `has_mul` instance, as a bundled homomorphism. -/\n@[simps]\ndef gsmulHom [GMonoid A] [Gmodule A M] {i j} : A i →+ M j →+ M (i + j)\n    where\n  toFun a :=\n    { toFun := fun b => GSmul.smul a b\n      map_zero' := GdistribMulAction.smul_zero _\n      map_add' := GdistribMulAction.smul_add _ }\n  map_zero' := AddMonoidHom.ext fun a => Gmodule.zero_smul a\n  map_add' a₁ a₂ := AddMonoidHom.ext fun b => Gmodule.add_smul _ _ _\n#align direct_sum.gsmul_hom DirectSum.gsmulHom\n\nnamespace Gmodule\n\n/-- For graded monoid `A` and a graded module `M` over `A`. `gmodule.smul_add_monoid_hom` is the\n`⨁ᵢ Aᵢ`-scalar multiplication on `⨁ᵢ Mᵢ` induced by `gsmul_hom`. -/\ndef smulAddMonoidHom [DecidableEq ι] [GMonoid A] [Gmodule A M] :\n    (⨁ i, A i) →+ (⨁ i, M i) →+ ⨁ i, M i :=\n  toAddMonoid fun i =>\n    AddMonoidHom.flip <|\n      toAddMonoid fun j => AddMonoidHom.flip <| (of M _).compHom.comp <| gsmulHom A M\n#align direct_sum.gmodule.smul_add_monoid_hom DirectSum.Gmodule.smulAddMonoidHom\n\nsection\n\nopen GradedMonoid DirectSum Gmodule\n\ninstance [DecidableEq ι] [GMonoid A] [Gmodule A M] : SMul (⨁ i, A i) (⨁ i, M i)\n    where smul x y := smulAddMonoidHom A M x y\n\n@[simp]\ntheorem smul_def [DecidableEq ι] [GMonoid A] [Gmodule A M] (x : ⨁ i, A i) (y : ⨁ i, M i) :\n    x • y = smulAddMonoidHom _ _ x y :=\n  rfl\n#align direct_sum.gmodule.smul_def DirectSum.Gmodule.smul_def\n\n@[simp]\ntheorem smulAddMonoidHom_apply_of_of [DecidableEq ι] [GMonoid A] [Gmodule A M] {i j} (x : A i)\n    (y : M j) :\n    smulAddMonoidHom A M (DirectSum.of A i x) (of M j y) = of M (i + j) (GSmul.smul x y) := by\n  simp [smul_add_monoid_hom]\n#align direct_sum.gmodule.smul_add_monoid_hom_apply_of_of DirectSum.Gmodule.smulAddMonoidHom_apply_of_of\n\n@[simp]\ntheorem of_smul_of [DecidableEq ι] [GMonoid A] [Gmodule A M] {i j} (x : A i) (y : M j) :\n    DirectSum.of A i x • of M j y = of M (i + j) (GSmul.smul x y) :=\n  smulAddMonoidHom_apply_of_of _ _ _ _\n#align direct_sum.gmodule.of_smul_of DirectSum.Gmodule.of_smul_of\n\nopen AddMonoidHom\n\n-- Almost identical to the proof of `direct_sum.one_mul`\nprivate theorem one_smul [DecidableEq ι] [GMonoid A] [Gmodule A M] (x : ⨁ i, M i) :\n    (1 : ⨁ i, A i) • x = x :=\n  by\n  suffices smulAddMonoidHom A M 1 = AddMonoidHom.id (⨁ i, M i) from AddMonoidHom.congr_fun this x\n  apply DirectSum.addHom_ext; intro i xi\n  unfold One.one\n  rw [smul_add_monoid_hom_apply_of_of]\n  exact DirectSum.of_eq_of_gradedMonoid_eq (one_smul (GradedMonoid A) <| GradedMonoid.mk i xi)\n#align direct_sum.gmodule.one_smul direct_sum.gmodule.one_smul\n\n-- Almost identical to the proof of `direct_sum.mul_assoc`\nprivate theorem mul_smul [DecidableEq ι] [Gsemiring A] [Gmodule A M] (a b : ⨁ i, A i)\n    (c : ⨁ i, M i) : (a * b) • c = a • b • c :=\n  by\n  suffices\n    (-- `λ a b c, (a * b) • c` as a bundled hom\n              smulAddMonoidHom\n              A M).compHom.comp\n        (DirectSum.mulHom A) =\n      (AddMonoidHom.compHom AddMonoidHom.flipHom <|\n          (smulAddMonoidHom A M).flip.compHom.comp <| smulAddMonoidHom A M).flip\n    from-- `λ a b c, a • (b • c)` as a bundled hom\n      AddMonoidHom.congr_fun\n      (AddMonoidHom.congr_fun (AddMonoidHom.congr_fun this a) b) c\n  ext (ai ax bi bx ci cx) : 6\n  dsimp only [coe_comp, Function.comp_apply, comp_hom_apply_apply, flip_apply, flip_hom_apply]\n  rw [smul_add_monoid_hom_apply_of_of, smul_add_monoid_hom_apply_of_of, DirectSum.mulHom_of_of,\n    smul_add_monoid_hom_apply_of_of]\n  exact\n    DirectSum.of_eq_of_gradedMonoid_eq\n      (mul_smul (GradedMonoid.mk ai ax) (GradedMonoid.mk bi bx) (GradedMonoid.mk ci cx))\n#align direct_sum.gmodule.mul_smul direct_sum.gmodule.mul_smul\n\n/-- The `module` derived from `gmodule A M`. -/\ninstance module [DecidableEq ι] [Gsemiring A] [Gmodule A M] : Module (⨁ i, A i) (⨁ i, M i)\n    where\n  smul := (· • ·)\n  one_smul := one_smul _ _\n  mul_smul := mul_smul _ _\n  smul_add r := (smulAddMonoidHom A M r).map_add\n  smul_zero r := (smulAddMonoidHom A M r).map_zero\n  add_smul r s x := by simp only [smul_def, map_add, AddMonoidHom.add_apply]\n  zero_smul x := by simp only [smul_def, map_zero, AddMonoidHom.zero_apply]\n#align direct_sum.gmodule.module DirectSum.Gmodule.module\n\nend\n\nend Gmodule\n\nend DirectSum\n\nend\n\nopen DirectSum BigOperators\n\nvariable {ι R A M σ σ' : Type _}\n\nvariable [AddMonoid ι] [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable (𝓐 : ι → σ') [SetLike σ' A]\n\nvariable (𝓜 : ι → σ)\n\nnamespace SetLike\n\ninclude σ' A σ M\n\ninstance gmulAction [AddMonoid M] [DistribMulAction A M] [SetLike σ M] [SetLike.GradedMonoid 𝓐]\n    [SetLike.GradedSmul 𝓐 𝓜] : GradedMonoid.GMulAction (fun i => 𝓐 i) fun i => 𝓜 i :=\n  {\n    SetLike.toGSmul 𝓐\n      𝓜 with\n    one_smul := fun ⟨i, m⟩ => Sigma.subtype_ext (zero_add _) (one_smul _ _)\n    mul_smul := fun ⟨i, a⟩ ⟨j, a'⟩ ⟨k, b⟩ => Sigma.subtype_ext (add_assoc _ _ _) (mul_smul _ _ _) }\n#align set_like.gmul_action SetLike.gmulAction\n\ninstance gdistribMulAction [AddMonoid M] [DistribMulAction A M] [SetLike σ M]\n    [AddSubmonoidClass σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSmul 𝓐 𝓜] :\n    DirectSum.GdistribMulAction (fun i => 𝓐 i) fun i => 𝓜 i :=\n  {\n    SetLike.gmulAction 𝓐\n      𝓜 with\n    smul_add := fun i j a b c => Subtype.ext <| smul_add _ _ _\n    smul_zero := fun i j a => Subtype.ext <| smul_zero _ }\n#align set_like.gdistrib_mul_action SetLike.gdistribMulAction\n\nvariable [AddCommMonoid M] [Module A M] [SetLike σ M] [AddSubmonoidClass σ' A]\n  [AddSubmonoidClass σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSmul 𝓐 𝓜]\n\n/-- `[set_like.graded_monoid 𝓐] [set_like.has_graded_smul 𝓐 𝓜]` is the internal version of graded\n  module, the internal version can be translated into the external version `gmodule`. -/\ninstance gmodule : DirectSum.Gmodule (fun i => 𝓐 i) fun i => 𝓜 i :=\n  {\n    SetLike.gdistribMulAction 𝓐\n      𝓜 with\n    smul := fun i j x y => ⟨(x : A) • (y : M), SetLike.GradedSmul.smul_mem x.2 y.2⟩\n    add_smul := fun i j a a' b => Subtype.ext <| add_smul _ _ _\n    zero_smul := fun i j b => Subtype.ext <| zero_smul _ _ }\n#align set_like.gmodule SetLike.gmodule\n\nend SetLike\n\nnamespace GradedModule\n\ninclude σ' A σ M\n\nvariable [AddCommMonoid M] [Module A M] [SetLike σ M] [AddSubmonoidClass σ' A]\n  [AddSubmonoidClass σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSmul 𝓐 𝓜]\n\n/-- The smul multiplication of `A` on `⨁ i, 𝓜 i` from `(⨁ i, 𝓐 i) →+ (⨁ i, 𝓜 i) →+ ⨁ i, 𝓜 i`\nturns `⨁ i, 𝓜 i` into an `A`-module\n-/\ndef isModule [DecidableEq ι] [GradedRing 𝓐] : Module A (⨁ i, 𝓜 i) :=\n  { Module.compHom _ (DirectSum.decomposeRingEquiv 𝓐 : A ≃+* ⨁ i, 𝓐 i).toRingHom with\n    smul := fun a b => DirectSum.decompose 𝓐 a • b }\n#align graded_module.is_module GradedModule.isModule\n\nattribute [local instance] GradedModule.isModule\n\n/-- `⨁ i, 𝓜 i` and `M` are isomorphic as `A`-modules.\n\"The internal version\" and \"the external version\" are isomorphism as `A`-modules.\n-/\ndef linearEquiv [DecidableEq ι] [GradedRing 𝓐] [DirectSum.Decomposition 𝓜] : M ≃ₗ[A] ⨁ i, 𝓜 i :=\n  {\n    DirectSum.decomposeAddEquiv\n      𝓜 with\n    toFun := DirectSum.decomposeAddEquiv 𝓜\n    map_smul' := fun x y => by\n      classical\n        rw [← DirectSum.sum_support_decompose 𝓐 x, map_sum, Finset.sum_smul, map_sum,\n          Finset.sum_smul, Finset.sum_congr rfl fun i hi => _]\n        rw [RingHom.id_apply, ← DirectSum.sum_support_decompose 𝓜 y, map_sum, Finset.smul_sum,\n          map_sum, Finset.smul_sum, Finset.sum_congr rfl fun j hj => _]\n        simp only [(· • ·), DirectSum.decomposeAddEquiv_apply, DirectSum.decompose_coe,\n          DirectSum.Gmodule.smulAddMonoidHom_apply_of_of]\n        convert DirectSum.decompose_coe 𝓜 _\n        rfl }\n#align graded_module.linear_equiv GradedModule.linearEquiv\n\nend GradedModule\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Module/GradedModule.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.49074470086960637}}
{"text": "def f (x : Nat) : Nat :=\nmatch x with\n| 30  => 31\n| y+1 => y\n| 0   => 10\n\n#eval f 20\n#eval f 0\n#eval f 30\n\nuniverses u\n\ntheorem ex1 {α : Sort u} {a b : α} (h : a ≅ b) : a = b :=\nmatch α, a, b, h with\n| _, _, _, HEq.refl _ => rfl\n\ntheorem ex2 {α : Sort u} {a b : α} (h : a ≅ b) : a = b :=\nmatch a, b, h with\n| _, _, HEq.refl _ => rfl\n\ntheorem ex3 {α : Sort u} {a b : α} (h : a ≅ b) : a = b :=\nmatch b, h with\n| _, HEq.refl _ => rfl\n\ntheorem ex4  {α β : Sort u} {b : β} {a a' : α} (h₁ : a = a') (h₂ : a' ≅ b) : a ≅ b :=\nmatch β, a', b, h₁, h₂ with\n| _, _, _, rfl, HEq.refl _ => HEq.refl _\n\ntheorem ex5  {α β : Sort u} {b : β} {a a' : α} (h₁ : a = a') (h₂ : a' ≅ b) : a ≅ b :=\nmatch a', h₁, h₂ with\n| _, rfl, h₂ => h₂\n\ntheorem ex6  {α β : Sort u} {b : β} {a a' : α} (h₁ : a = a') (h₂ : a' ≅ b) : a ≅ b :=\nby {\n  subst h₁;\n  assumption\n}\n\ntheorem ex7 (a : Bool) (p q : Prop) (h₁ : a = true → p) (h₂ : a = false → q) : p ∨ q :=\n  match (generalizing := false) h:a with\n  | true  => Or.inl $ h₁ h\n  | false => Or.inr $ h₂ h\n\ntheorem ex7' (a : Bool) (p q : Prop) (h₁ : a = true → p) (h₂ : a = false → q) : p ∨ q :=\n  match a with\n  | true  => Or.inl $ h₁ rfl\n  | false => Or.inr $ h₂ rfl\n\ndef head {α} (xs : List α) (h : xs = [] → False) : α :=\n  match he:xs with\n  | []   => by contradiction\n  | x::_ => x\n\nvariable {α : Type u} {p : α → Prop}\n\ntheorem ex8 {a1 a2 : {x // p x}} (h : a1.val = a2.val) : a1 = a2 :=\nmatch a1, a2, h with\n| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl\n\nuniverses v\nvariable {β : α → Type v}\n\ntheorem ex9 {p₁ p₂ : Sigma (fun a => β a)} (h₁ : p₁.1 = p₂.1) (h : p₁.2 ≅ p₂.2) : p₁ = p₂ :=\nmatch p₁, p₂, h₁, h with\n| ⟨_, _⟩, ⟨_, _⟩, rfl, HEq.refl _ => rfl\n\ninductive F : Nat → Type\n| z : {n : Nat} → F (n+1)\n| s : {n : Nat} → F n → F (n+1)\n\ndef f0 {α : Sort u} (x : F 0) : α :=\nnomatch x\n\ndef f0' {α : Sort u} (x : F 0) : α :=\nnomatch id x\n\ndef f1 {α : Sort u} (x : F 0 × Bool) : α :=\nnomatch x\n\ndef f2 {α : Sort u} (x : Sum (F 0) (F 0)) : α :=\nnomatch x\n\ndef f3 {α : Sort u} (x : Bool × F 0) : α :=\nnomatch x\n\ndef f4 (x : Sum (F 0 × Bool) Nat) : Nat :=\nmatch x with\n| Sum.inr x => x\n\n#eval f4 $ Sum.inr 100\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/match3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.4907446949832883}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n\n! This file was ported from Lean 3 source module category_theory.idempotents.functor_extension\n! leanprover-community/mathlib commit 5f68029a863bdf76029fa0f7a519e6163c14152e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Idempotents.Karoubi\n\n/-!\n# Extension of functors to the idempotent completion\n\nIn this file, we construct an extension `functor_extension₁`\nof functors `C ⥤ karoubi D` to functors `karoubi C ⥤ karoubi D`. This results in an\nequivalence `karoubi_universal₁ C D : (C ⥤ karoubi D) ≌ (karoubi C ⥤ karoubi D)`.\n\nWe also construct an extension `functor_extension₂` of functors\n`(C ⥤ D) ⥤ (karoubi C ⥤ karoubi D)`. Moreover,\nwhen `D` is idempotent complete, we get equivalences\n`karoubi_universal₂ C D : C ⥤ D ≌ karoubi C ⥤ karoubi D`\nand `karoubi_universal C D : C ⥤ D ≌ karoubi C ⥤ D`.\n\nWe occasionally state and use equalities of functors because it is\nsometimes convenient to use rewrites when proving properties of\nfunctors obtained using the constructions in this file. Users are\nencouraged to use the corresponding natural isomorphism\nwhenever possible.\n\n-/\n\n\nopen CategoryTheory.Category\n\nopen CategoryTheory.Idempotents.Karoubi\n\nnamespace CategoryTheory\n\nnamespace Idempotents\n\nvariable {C D E : Type _} [Category C] [Category D] [Category E]\n\n/-- A natural transformation between functors `karoubi C ⥤ D` is determined\nby its value on objects coming from `C`. -/\ntheorem nat_trans_eq {F G : Karoubi C ⥤ D} (φ : F ⟶ G) (P : Karoubi C) :\n    φ.app P = F.map (decompIdI P) ≫ φ.app P.pt ≫ G.map (decompIdP P) :=\n  by\n  rw [← φ.naturality, ← assoc, ← F.map_comp]\n  conv =>\n    lhs\n    rw [← id_comp (φ.app P), ← F.map_id]\n  congr\n  apply decomp_id\n#align category_theory.idempotents.nat_trans_eq CategoryTheory.Idempotents.nat_trans_eq\n\nnamespace FunctorExtension₁\n\n/-- The canonical extension of a functor `C ⥤ karoubi D` to a functor\n`karoubi C ⥤ karoubi D` -/\n@[simps]\ndef obj (F : C ⥤ Karoubi D) : Karoubi C ⥤ Karoubi D\n    where\n  obj P :=\n    ⟨(F.obj P.pt).pt, (F.map P.p).f, by simpa only [F.map_comp, hom_ext] using F.congr_map P.idem⟩\n  map P Q f := ⟨(F.map f.f).f, by simpa only [F.map_comp, hom_ext] using F.congr_map f.comm⟩\n#align category_theory.idempotents.functor_extension₁.obj CategoryTheory.Idempotents.FunctorExtension₁.obj\n\n/-- Extension of a natural transformation `φ` between functors\n`C ⥤ karoubi D` to a natural transformation between the\nextension of these functors to `karoubi C ⥤ karoubi D` -/\n@[simps]\ndef map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G\n    where\n  app P :=\n    { f := (F.map P.p).f ≫ (φ.app P.pt).f\n      comm := by\n        have h := φ.naturality P.p\n        have h' := F.congr_map P.idem\n        simp only [hom_ext, karoubi.comp_f, F.map_comp] at h h'\n        simp only [obj_obj_p, assoc, ← h]\n        slice_rhs 1 3 => rw [h', h'] }\n  naturality' P Q f := by\n    ext\n    dsimp [obj]\n    have h := φ.naturality f.f\n    have h' := F.congr_map (comp_p f)\n    have h'' := F.congr_map (p_comp f)\n    simp only [hom_ext, functor.map_comp, comp_f] at h h' h''⊢\n    slice_rhs 2 3 => rw [← h]\n    slice_lhs 1 2 => rw [h']\n    slice_rhs 1 2 => rw [h'']\n#align category_theory.idempotents.functor_extension₁.map CategoryTheory.Idempotents.FunctorExtension₁.map\n\nend FunctorExtension₁\n\nvariable (C D E)\n\n/-- The canonical functor `(C ⥤ karoubi D) ⥤ (karoubi C ⥤ karoubi D)` -/\n@[simps]\ndef functorExtension₁ : (C ⥤ Karoubi D) ⥤ Karoubi C ⥤ Karoubi D\n    where\n  obj := FunctorExtension₁.obj\n  map F G := FunctorExtension₁.map\n  map_id' F := by\n    ext P\n    exact comp_p (F.map P.p)\n  map_comp' F G H φ φ' := by\n    ext P\n    simp only [comp_f, functor_extension₁.map_app_f, nat_trans.comp_app, assoc]\n    have h := φ.naturality P.p\n    have h' := F.congr_map P.idem\n    simp only [hom_ext, comp_f, F.map_comp] at h h'\n    slice_rhs 2 3 => rw [← h]\n    slice_rhs 1 2 => rw [h']\n    simp only [assoc]\n#align category_theory.idempotents.functor_extension₁ CategoryTheory.Idempotents.functorExtension₁\n\ntheorem functorExtension₁_comp_whiskeringLeft_toKaroubi :\n    functorExtension₁ C D ⋙ (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) = 𝟭 _ :=\n  by\n  refine' Functor.ext _ _\n  · intro F\n    refine' Functor.ext _ _\n    · intro X\n      ext\n      · dsimp\n        rw [id_comp, comp_id, F.map_id, id_eq]\n      · rfl\n    · intro X Y f\n      ext\n      dsimp\n      simp only [comp_id, eq_to_hom_f, eq_to_hom_refl, comp_p, functor_extension₁.obj_obj_p,\n        to_karoubi_obj_p, comp_f]\n      dsimp\n      simp only [Functor.map_id, id_eq, p_comp]\n  · intro F G φ\n    ext X\n    dsimp\n    simp only [eq_to_hom_app, F.map_id, comp_f, eq_to_hom_f, id_eq, p_comp, eq_to_hom_refl, comp_id,\n      comp_p, functor_extension₁.obj_obj_p, to_karoubi_obj_p, F.map_id X]\n#align category_theory.idempotents.functor_extension₁_comp_whiskering_left_to_karoubi CategoryTheory.Idempotents.functorExtension₁_comp_whiskeringLeft_toKaroubi\n\n/-- The natural isomorphism expressing that functors `karoubi C ⥤ karoubi D` obtained\nusing `functor_extension₁` actually extends the original functors `C ⥤ karoubi D`. -/\n@[simps]\ndef functorExtension₁CompWhiskeringLeftToKaroubiIso :\n    functorExtension₁ C D ⋙ (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) ≅ 𝟭 _ :=\n  eqToIso (functorExtension₁_comp_whiskeringLeft_toKaroubi C D)\n#align category_theory.idempotents.functor_extension₁_comp_whiskering_left_to_karoubi_iso CategoryTheory.Idempotents.functorExtension₁CompWhiskeringLeftToKaroubiIso\n\n/-- The counit isomorphism of the equivalence `(C ⥤ karoubi D) ≌ (karoubi C ⥤ karoubi D)`. -/\n@[simps]\ndef KaroubiUniversal₁.counitIso :\n    (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) ⋙ functorExtension₁ C D ≅ 𝟭 _ :=\n  NatIso.ofComponents\n    (fun G =>\n      { Hom :=\n          { app := fun P =>\n              { f := (G.map (decompIdP P)).f\n                comm := by\n                  simpa only [hom_ext, G.map_comp, G.map_id] using\n                    G.congr_map\n                      (show P.decomp_id_p = (to_karoubi C).map P.p ≫ P.decomp_id_p ≫ 𝟙 _ by simp) }\n            naturality' := fun P Q f => by\n              simpa only [hom_ext, G.map_comp] using (G.congr_map (decomp_id_p_naturality f)).symm }\n        inv :=\n          { app := fun P =>\n              { f := (G.map (decompIdI P)).f\n                comm := by\n                  simpa only [hom_ext, G.map_comp, G.map_id] using\n                    G.congr_map\n                      (show P.decomp_id_i = 𝟙 _ ≫ P.decomp_id_i ≫ (to_karoubi C).map P.p by simp) }\n            naturality' := fun P Q f => by\n              simpa only [hom_ext, G.map_comp] using G.congr_map (decomp_id_i_naturality f) }\n        hom_inv_id' := by\n          ext P\n          simpa only [hom_ext, G.map_comp, G.map_id] using G.congr_map P.decomp_p.symm\n        inv_hom_id' := by\n          ext P\n          simpa only [hom_ext, G.map_comp, G.map_id] using G.congr_map P.decomp_id.symm })\n    fun G₁ G₂ φ => by\n    ext P\n    dsimp\n    simpa only [nat_trans_eq φ P, comp_f, functor_extension₁.map_app_f, functor.comp_map,\n      whisker_left_app, assoc, P.decomp_p, G₁.map_comp]\n#align category_theory.idempotents.karoubi_universal₁.counit_iso CategoryTheory.Idempotents.KaroubiUniversal₁.counitIso\n\n/-- The equivalence of categories `(C ⥤ karoubi D) ≌ (karoubi C ⥤ karoubi D)`. -/\n@[simps]\ndef karoubiUniversal₁ : C ⥤ Karoubi D ≌ Karoubi C ⥤ Karoubi D\n    where\n  Functor := functorExtension₁ C D\n  inverse := (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C)\n  unitIso := (functorExtension₁CompWhiskeringLeftToKaroubiIso C D).symm\n  counitIso := KaroubiUniversal₁.counitIso C D\n  functor_unitIso_comp' F := by\n    ext P\n    dsimp [functor_extension₁.map, karoubi_universal₁.counit_iso]\n    simpa only [comp_f, eq_to_hom_app, eq_to_hom_f, eq_to_hom_refl, comp_id, hom_ext, F.map_comp,\n      comp_p] using F.congr_map P.idem\n#align category_theory.idempotents.karoubi_universal₁ CategoryTheory.Idempotents.karoubiUniversal₁\n\ntheorem functorExtension₁_comp (F : C ⥤ Karoubi D) (G : D ⥤ Karoubi E) :\n    (functorExtension₁ C E).obj (F ⋙ (functorExtension₁ D E).obj G) =\n      (functorExtension₁ C D).obj F ⋙ (functorExtension₁ D E).obj G :=\n  Functor.ext (by tidy) fun X Y f => by\n    dsimp\n    simpa only [id_comp, comp_id]\n#align category_theory.idempotents.functor_extension₁_comp CategoryTheory.Idempotents.functorExtension₁_comp\n\n/-- The canonical functor `(C ⥤ D) ⥤ (karoubi C ⥤ karoubi D)` -/\n@[simps]\ndef functorExtension₂ : (C ⥤ D) ⥤ Karoubi C ⥤ Karoubi D :=\n  (whiskeringRight C D (Karoubi D)).obj (toKaroubi D) ⋙ functorExtension₁ C D\n#align category_theory.idempotents.functor_extension₂ CategoryTheory.Idempotents.functorExtension₂\n\ntheorem functorExtension₂_comp_whiskeringLeft_toKaroubi :\n    functorExtension₂ C D ⋙ (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) =\n      (whiskeringRight C D (Karoubi D)).obj (toKaroubi D) :=\n  by\n  simp only [functor_extension₂, functor.assoc, functor_extension₁_comp_whiskering_left_to_karoubi,\n    functor.comp_id]\n#align category_theory.idempotents.functor_extension₂_comp_whiskering_left_to_karoubi CategoryTheory.Idempotents.functorExtension₂_comp_whiskeringLeft_toKaroubi\n\n/-- The natural isomorphism expressing that functors `karoubi C ⥤ karoubi D` obtained\nusing `functor_extension₂` actually extends the original functors `C ⥤ D`. -/\n@[simps]\ndef functorExtension₂CompWhiskeringLeftToKaroubiIso :\n    functorExtension₂ C D ⋙ (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) ≅\n      (whiskeringRight C D (Karoubi D)).obj (toKaroubi D) :=\n  eqToIso (functorExtension₂_comp_whiskeringLeft_toKaroubi C D)\n#align category_theory.idempotents.functor_extension₂_comp_whiskering_left_to_karoubi_iso CategoryTheory.Idempotents.functorExtension₂CompWhiskeringLeftToKaroubiIso\n\nsection IsIdempotentComplete\n\nvariable [IsIdempotentComplete D]\n\nnoncomputable instance : IsEquivalence (toKaroubi D) :=\n  toKaroubiIsEquivalence D\n\n/-- The equivalence of categories `(C ⥤ D) ≌ (karoubi C ⥤ karoubi D)` when `D`\nis idempotent complete. -/\n@[simps]\nnoncomputable def karoubiUniversal₂ : C ⥤ D ≌ Karoubi C ⥤ Karoubi D :=\n  (Equivalence.congrRight (toKaroubi D).asEquivalence).trans (karoubiUniversal₁ C D)\n#align category_theory.idempotents.karoubi_universal₂ CategoryTheory.Idempotents.karoubiUniversal₂\n\ntheorem karoubiUniversal₂_functor_eq : (karoubiUniversal₂ C D).Functor = functorExtension₂ C D :=\n  rfl\n#align category_theory.idempotents.karoubi_universal₂_functor_eq CategoryTheory.Idempotents.karoubiUniversal₂_functor_eq\n\nnoncomputable instance : IsEquivalence (functorExtension₂ C D) :=\n  by\n  rw [← karoubi_universal₂_functor_eq]\n  infer_instance\n\n/-- The extension of functors functor `(C ⥤ D) ⥤ (karoubi C ⥤ D)`\nwhen `D` is idempotent compltete. -/\n@[simps]\nnoncomputable def functorExtension : (C ⥤ D) ⥤ Karoubi C ⥤ D :=\n  functorExtension₂ C D ⋙\n    (whiskeringRight (Karoubi C) (Karoubi D) D).obj (toKaroubiIsEquivalence D).inverse\n#align category_theory.idempotents.functor_extension CategoryTheory.Idempotents.functorExtension\n\n/-- The equivalence `(C ⥤ D) ≌ (karoubi C ⥤ D)` when `D` is idempotent complete. -/\n@[simps]\nnoncomputable def karoubiUniversal : C ⥤ D ≌ Karoubi C ⥤ D :=\n  (karoubiUniversal₂ C D).trans (Equivalence.congrRight (toKaroubi D).asEquivalence.symm)\n#align category_theory.idempotents.karoubi_universal CategoryTheory.Idempotents.karoubiUniversal\n\ntheorem karoubiUniversal_functor_eq : (karoubiUniversal C D).Functor = functorExtension C D :=\n  rfl\n#align category_theory.idempotents.karoubi_universal_functor_eq CategoryTheory.Idempotents.karoubiUniversal_functor_eq\n\nnoncomputable instance : IsEquivalence (functorExtension C D) :=\n  by\n  rw [← karoubi_universal_functor_eq]\n  infer_instance\n\nnoncomputable instance : IsEquivalence ((whiskeringLeft C (Karoubi C) D).obj (toKaroubi C)) :=\n  IsEquivalence.cancelCompRight _\n    ((whiskeringRight C _ _).obj (toKaroubi D) ⋙ (whiskeringRight C _ _).obj (toKaroubi D).inv)\n    (IsEquivalence.ofEquivalence\n      (@Equivalence.congrRight _ _ _ _ C _\n        ((toKaroubi D).asEquivalence.trans (toKaroubi D).asEquivalence.symm)))\n    (by\n      change is_equivalence (karoubi_universal C D).inverse\n      infer_instance)\n\nvariable {C D}\n\ntheorem whiskeringLeft_obj_preimage_app {F G : Karoubi C ⥤ D}\n    (τ : toKaroubi _ ⋙ F ⟶ toKaroubi _ ⋙ G) (P : Karoubi C) :\n    (((whiskeringLeft _ _ _).obj (toKaroubi _)).preimage τ).app P =\n      F.map P.decompIdI ≫ τ.app P.pt ≫ G.map P.decompIdP :=\n  by\n  rw [nat_trans_eq]\n  congr 2\n  exact congr_app (((whiskering_left _ _ _).obj (to_karoubi _)).image_preimage τ) P.X\n#align category_theory.idempotents.whiskering_left_obj_preimage_app CategoryTheory.Idempotents.whiskeringLeft_obj_preimage_app\n\nend IsIdempotentComplete\n\nend Idempotents\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Idempotents/FunctorExtension.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484144, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.4907446916834199}}
{"text": "import orthoganality_of_character.orthogonality   \nnoncomputable theory\nset_option pp.generalized_field_notation false\nopen_locale big_operators\nuniverses u v w w'\nopen car_pol\nopen  Schur₂ morphism.from_irreductible equiv_morphism shur₁_comm_ring stability \nopen  Reynold\nopen matrix linear_map character\nnamespace decomposition\nvariables {G : Type u} [group G]  [fintype G][decidable_eq G]\n          {X : Type v} [fintype X][decidable_eq X] \n          (ρ : group_representation G ℂ (X → ℂ))\n          {Y : Type w} [fintype Y][decidable_eq Y]\n          (ι : Type v) [fintype ι][decidable_eq ι] (M : ι → Type w)\n          [Π i, fintype(M i)][Π i,decidable_eq (M i)]\n          (φ : Π i,group_representation G ℂ  (M i → ℂ )) [Π i, Irreductible (φ i) ]\n          {π  : group_representation G ℂ (Y → ℂ)} [Irreductible π  ]\n#check finset\ndef  is_decomposition := χ ρ = ∑ i, χ (φ i)  ---- baby decomposition ! \n#check   subtype (λ i : ι , is_isomorphic ρ (φ i))\nopen_locale classical\ninstance  : fintype { i : ι // is_isomorphic ρ (φ i)  } := begin \n    exact set_fintype (λ (x : ι), nonempty (ρ ≃ᵣ φ x)),\nend\nend decomposition\nopen decomposition\nvariables {G : Type u} [group G]  [fintype G][decidable_eq G]\n          {X : Type v} [fintype X][decidable_eq X] \n          (ρ : group_representation G ℂ (X → ℂ))\n          {Y : Type w} [fintype Y][decidable_eq Y]\n          (ι : Type v) [fintype ι][decidable_eq ι] (M : ι → Type w)\n          [Π i, fintype(M i)][Π i,decidable_eq (M i)]\n          (φ : Π i,group_representation G ℂ  (M i → ℂ )) [Π i, Irreductible (φ i) ]\n          {π  : group_representation G ℂ (Y → ℂ)} [Irreductible π  ]\ntheorem scal (hyp : is_decomposition ρ ι M φ  ) (hyp' : 0 < fintype.card Y ) (hyp'' : fintype.card Y ≠ 0) : \n    scalar_product G ℂ (χ (π )) (χ (ρ )) = (fintype.card { i : ι  | is_isomorphic π   (φ    i)  }) * ↑(fintype.card G)  :=\nbegin \n    unfold is_decomposition at *, rw hyp,\n    rw bilin_form.map_sum_right, \n    let g := λ i,  scalar_product_ite  π (φ i)hyp'  hyp'',\n    conv_lhs{\n        apply_congr,skip,\n        rw g,\n    },\n    rw finset.sum_ite, rw finset.sum_const_zero, rw add_zero,\n    rw finset.sum_const, rw add_monoid.smul_eq_mul, \n    erw fintype.card_of_subtype _, intros,\n    split,  intros, rw finset.mem_filter at a, exact a.2,\n    intros, rw finset.mem_filter, split, exact finset.mem_univ _,\n    exact a,\nend\nnamespace regular\nvariables {Z : Type w} [fintype Y][decidable_eq Y]\n          (t : Type u) [fintype t][decidable_eq t] (Mt : t → Type w)\n          [Π i, fintype(Mt i)][Π i,decidable_eq (Mt i)]\n          (ψ  : Π i,group_representation G ℂ  (Mt i → ℂ )) [Π i, Irreductible (ψ i) ]\ntheorem scal_regular  (hyp : is_decomposition (Regular.Regular_representation G ℂ ) t Mt ψ   )(hyp'' :0 < fintype.card Y ) (hyp' : fintype.card Y ≠ 0): \n\n    (χ π  1) * ↑(fintype.card G) = (fintype.card { i : t | is_isomorphic π   (ψ   i)  }) * ↑(fintype.card G) := \nbegin \n    erw ← scal (Regular.Regular_representation G ℂ ) t Mt ψ hyp _,\n    rw scalar_product_with_regular, by assumption, by assumption, \n    exact hyp'',\n    end\nend regular\n\n", "meta": {"author": "Or7ando", "repo": "group_representation", "sha": "9b576984f17764ebf26c8caa2a542d248f1b50d2", "save_path": "github-repos/lean/Or7ando-group_representation", "path": "github-repos/lean/Or7ando-group_representation/group_representation-9b576984f17764ebf26c8caa2a542d248f1b50d2/group_rep_2/orthoganality_of_character/orthoganality_2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120234, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.49073579658075284}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module combinatorics.additive.ruzsa_covering\n! leanprover-community/mathlib commit 50832daea47b195a48b5b33b1c8b2162c48c3afc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.Pointwise\n\n/-!\n# Ruzsa's covering lemma\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves the Ruzsa covering lemma. This says that, for `s`, `t` finsets, we can cover `s`\nwith at most `(s + t).card /  t.card` copies of `t - t`.\n\n## TODO\n\nMerge this file with other prerequisites to Freiman's theorem once we have them.\n-/\n\n\nopen Pointwise\n\nnamespace Finset\n\nvariable {α : Type _} [DecidableEq α] [CommGroup α] (s : Finset α) {t : Finset α}\n\n/- warning: finset.exists_subset_mul_div -> Finset.exists_subset_mul_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : CommGroup.{u1} α] (s : Finset.{u1} α) {t : Finset.{u1} α}, (Finset.Nonempty.{u1} α t) -> (Exists.{succ u1} (Finset.{u1} α) (fun (u : Finset.{u1} α) => And (LE.le.{0} Nat Nat.hasLe (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} α u) (Finset.card.{u1} α t)) (Finset.card.{u1} α (HMul.hMul.{u1, u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Finset.{u1} α) (instHMul.{u1} (Finset.{u1} α) (Finset.mul.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α (CommGroup.toGroup.{u1} α _inst_2))))))) s t))) (HasSubset.Subset.{u1} (Finset.{u1} α) (Finset.hasSubset.{u1} α) s (HDiv.hDiv.{u1, u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Finset.{u1} α) (instHDiv.{u1} (Finset.{u1} α) (Finset.div.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α (CommGroup.toGroup.{u1} α _inst_2))))) (HMul.hMul.{u1, u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Finset.{u1} α) (instHMul.{u1} (Finset.{u1} α) (Finset.mul.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α (CommGroup.toGroup.{u1} α _inst_2))))))) u t) t))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : CommGroup.{u1} α] (s : Finset.{u1} α) {t : Finset.{u1} α}, (Finset.Nonempty.{u1} α t) -> (Exists.{succ u1} (Finset.{u1} α) (fun (u : Finset.{u1} α) => And (LE.le.{0} Nat instLENat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u1} α u) (Finset.card.{u1} α t)) (Finset.card.{u1} α (HMul.hMul.{u1, u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Finset.{u1} α) (instHMul.{u1} (Finset.{u1} α) (Finset.mul.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α (CommGroup.toGroup.{u1} α _inst_2))))))) s t))) (HasSubset.Subset.{u1} (Finset.{u1} α) (Finset.instHasSubsetFinset.{u1} α) s (HDiv.hDiv.{u1, u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Finset.{u1} α) (instHDiv.{u1} (Finset.{u1} α) (Finset.div.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α (CommGroup.toGroup.{u1} α _inst_2))))) (HMul.hMul.{u1, u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Finset.{u1} α) (instHMul.{u1} (Finset.{u1} α) (Finset.mul.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α (CommGroup.toGroup.{u1} α _inst_2))))))) u t) t))))\nCase conversion may be inaccurate. Consider using '#align finset.exists_subset_mul_div Finset.exists_subset_mul_divₓ'. -/\n/-- **Ruzsa's covering lemma**. -/\n@[to_additive \"**Ruzsa's covering lemma**\"]\ntheorem exists_subset_mul_div (ht : t.Nonempty) :\n    ∃ u : Finset α, u.card * t.card ≤ (s * t).card ∧ s ⊆ u * t / t :=\n  by\n  haveI : ∀ u, Decidable ((u : Set α).PairwiseDisjoint (· • t)) := fun u => Classical.dec _\n  set C := s.powerset.filter fun u => (u : Set α).PairwiseDisjoint (· • t)\n  obtain ⟨u, hu, hCmax⟩ :=\n    C.exists_maximal (filter_nonempty_iff.2 ⟨∅, empty_mem_powerset _, Set.pairwiseDisjoint_empty⟩)\n  rw [mem_filter, mem_powerset] at hu\n  refine'\n    ⟨u,\n      (card_mul_iff.2 <| pairwise_disjoint_smul_iff.1 hu.2).ge.trans\n        (card_le_of_subset <| mul_subset_mul_right hu.1),\n      fun a ha => _⟩\n  rw [mul_div_assoc]\n  by_cases hau : a ∈ u\n  · exact subset_mul_left _ ht.one_mem_div hau\n  by_cases H : ∀ b ∈ u, Disjoint (a • t) (b • t)\n  · refine' (hCmax _ _ <| ssubset_insert hau).elim\n    rw [mem_filter, mem_powerset, insert_subset, coe_insert]\n    exact ⟨⟨ha, hu.1⟩, hu.2.insert fun b hb _ => H _ hb⟩\n  push_neg  at H\n  simp_rw [not_disjoint_iff, ← inv_smul_mem_iff] at H\n  obtain ⟨b, hb, c, hc₁, hc₂⟩ := H\n  exact mem_mul.2 ⟨_, _, hb, mem_div.2 ⟨_, _, hc₂, hc₁, by simp [div_eq_mul_inv a b]⟩, by simp⟩\n#align finset.exists_subset_mul_div Finset.exists_subset_mul_div\n#align finset.exists_subset_add_sub Finset.exists_subset_add_sub\n\nend Finset\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Combinatorics/Additive/RuzsaCovering.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744850834649, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4906986887752517}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport data.equiv.local_equiv\nimport topology.opens\n\n/-!\n# Local homeomorphisms\n\nThis file defines homeomorphisms between open subsets of topological spaces. An element `e` of\n`local_homeomorph α β` is an extension of `local_equiv α β`, i.e., it is a pair of functions\n`e.to_fun` and `e.inv_fun`, inverse of each other on the sets `e.source` and `e.target`.\nAdditionally, we require that these sets are open, and that the functions are continuous on them.\nEquivalently, they are homeomorphisms there.\n\nAs in equivs, we register a coercion to functions, and we use `e x` and `e.symm x` throughout\ninstead of `e.to_fun x` and `e.inv_fun x`.\n\n## Main definitions\n\n`homeomorph.to_local_homeomorph`: associating a local homeomorphism to a homeomorphism, with\n                                  source = target = univ\n`local_homeomorph.symm`  : the inverse of a local homeomorphism\n`local_homeomorph.trans` : the composition of two local homeomorphisms\n`local_homeomorph.refl`  : the identity local homeomorphism\n`local_homeomorph.of_set`: the identity on a set `s`\n`eq_on_source`           : equivalence relation describing the \"right\" notion of equality for local\n                           homeomorphisms\n\n## Implementation notes\n\nMost statements are copied from their local_equiv versions, although some care is required\nespecially when restricting to subsets, as these should be open subsets.\n\nFor design notes, see `local_equiv.lean`.\n\n### Local coding conventions\n\nIf a lemma deals with the intersection of a set with either source or target of a `local_equiv`,\nthen it should use `e.source ∩ s` or `e.target ∩ t`, not `s ∩ e.source` or `t ∩ e.target`.\n-/\n\nopen function set filter topological_space (second_countable_topology)\nopen_locale topological_space\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\n[topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n\n/-- local homeomorphisms, defined on open subsets of the space -/\n@[nolint has_inhabited_instance]\nstructure local_homeomorph (α : Type*) (β : Type*) [topological_space α] [topological_space β]\n  extends local_equiv α β :=\n(open_source        : is_open source)\n(open_target        : is_open target)\n(continuous_to_fun  : continuous_on to_fun source)\n(continuous_inv_fun : continuous_on inv_fun target)\n\n/-- A homeomorphism induces a local homeomorphism on the whole space -/\ndef homeomorph.to_local_homeomorph (e : α ≃ₜ β) :\n  local_homeomorph α β :=\n{ open_source        := is_open_univ,\n  open_target        := is_open_univ,\n  continuous_to_fun  := by { erw ← continuous_iff_continuous_on_univ, exact e.continuous_to_fun },\n  continuous_inv_fun := by { erw ← continuous_iff_continuous_on_univ, exact e.continuous_inv_fun },\n  ..e.to_equiv.to_local_equiv }\n\nnamespace local_homeomorph\n\nvariables (e : local_homeomorph α β) (e' : local_homeomorph β γ)\n\ninstance : has_coe_to_fun (local_homeomorph α β) := ⟨_, λ e, e.to_local_equiv.to_fun⟩\n\n/-- The inverse of a local homeomorphism -/\nprotected def symm : local_homeomorph β α :=\n{ open_source        := e.open_target,\n  open_target        := e.open_source,\n  continuous_to_fun  := e.continuous_inv_fun,\n  continuous_inv_fun := e.continuous_to_fun,\n  ..e.to_local_equiv.symm }\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (e : local_homeomorph α β) : α → β := e\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (e : local_homeomorph α β) : β → α := e.symm\n\ninitialize_simps_projections local_homeomorph\n  (to_local_equiv_to_fun → apply, to_local_equiv_inv_fun → symm_apply,\n   to_local_equiv_source → source, to_local_equiv_target → target, -to_local_equiv)\n\nprotected lemma continuous_on : continuous_on e e.source := e.continuous_to_fun\n\nlemma continuous_on_symm : continuous_on e.symm e.target := e.continuous_inv_fun\n\n@[simp, mfld_simps] lemma mk_coe (e : local_equiv α β) (a b c d) :\n  (local_homeomorph.mk e a b c d : α → β) = e := rfl\n\n@[simp, mfld_simps] lemma mk_coe_symm (e : local_equiv α β) (a b c d) :\n  ((local_homeomorph.mk e a b c d).symm : β → α) = e.symm := rfl\n\n/- Register a few simp lemmas to make sure that `simp` puts the application of a local\nhomeomorphism in its normal form, i.e., in terms of its coercion to a function. -/\n\n@[simp, mfld_simps] lemma to_fun_eq_coe (e : local_homeomorph α β) : e.to_fun = e := rfl\n\n@[simp, mfld_simps] lemma inv_fun_eq_coe (e : local_homeomorph α β) : e.inv_fun = e.symm := rfl\n\n@[simp, mfld_simps] lemma coe_coe : (e.to_local_equiv : α → β) = e := rfl\n\n@[simp, mfld_simps] lemma coe_coe_symm : (e.to_local_equiv.symm : β → α) = e.symm := rfl\n\n@[simp, mfld_simps] lemma map_source {x : α} (h : x ∈ e.source) : e x ∈ e.target :=\ne.map_source' h\n\n@[simp, mfld_simps] lemma map_target {x : β} (h : x ∈ e.target) : e.symm x ∈ e.source :=\ne.map_target' h\n\n@[simp, mfld_simps] lemma left_inv {x : α} (h : x ∈ e.source) : e.symm (e x) = x :=\ne.left_inv' h\n\n@[simp, mfld_simps] lemma right_inv {x : β} (h : x ∈ e.target) : e (e.symm x) = x :=\ne.right_inv' h\n\nprotected lemma maps_to : maps_to e e.source e.target := λ x, e.map_source\nprotected lemma symm_maps_to : maps_to e.symm e.target e.source := e.symm.maps_to\nprotected lemma left_inv_on : left_inv_on e.symm e e.source := λ x, e.left_inv\nprotected lemma right_inv_on : right_inv_on e.symm e e.target := λ x, e.right_inv\nprotected lemma inv_on : inv_on e.symm e e.source e.target := ⟨e.left_inv_on, e.right_inv_on⟩\nprotected lemma inj_on : inj_on e e.source := e.left_inv_on.inj_on\nprotected lemma bij_on : bij_on e e.source e.target := e.inv_on.bij_on e.maps_to e.symm_maps_to\nprotected lemma surj_on : surj_on e e.source e.target := e.bij_on.surj_on\n\n/-- Replace `to_local_equiv` field to provide better definitional equalities. -/\ndef replace_equiv (e : local_homeomorph α β) (e' : local_equiv α β) (h : e.to_local_equiv = e') :\n  local_homeomorph α β :=\n{ to_local_equiv := e',\n  open_source := h ▸ e.open_source,\n  open_target := h ▸ e.open_target,\n  continuous_to_fun := h ▸ e.continuous_to_fun,\n  continuous_inv_fun := h ▸ e.continuous_inv_fun }\n\nlemma replace_equiv_eq_self (e : local_homeomorph α β) (e' : local_equiv α β)\n  (h : e.to_local_equiv = e') :\n  e.replace_equiv e' h = e :=\nby { cases e, subst e', refl }\n\nlemma source_preimage_target : e.source ⊆ e ⁻¹' e.target := e.maps_to\n\nlemma eq_of_local_equiv_eq {e e' : local_homeomorph α β}\n  (h : e.to_local_equiv = e'.to_local_equiv) : e = e' :=\nby { cases e, cases e', cases h, refl }\n\nlemma eventually_left_inverse (e : local_homeomorph α β) {x} (hx : x ∈ e.source) :\n  ∀ᶠ y in 𝓝 x, e.symm (e y) = y :=\n(e.open_source.eventually_mem hx).mono e.left_inv'\n\nlemma eventually_left_inverse' (e : local_homeomorph α β) {x} (hx : x ∈ e.target) :\n  ∀ᶠ y in 𝓝 (e.symm x), e.symm (e y) = y :=\ne.eventually_left_inverse (e.map_target hx)\n\nlemma eventually_right_inverse (e : local_homeomorph α β) {x} (hx : x ∈ e.target) :\n  ∀ᶠ y in 𝓝 x, e (e.symm y) = y :=\n(e.open_target.eventually_mem hx).mono e.right_inv'\n\nlemma eventually_right_inverse' (e : local_homeomorph α β) {x} (hx : x ∈ e.source) :\n  ∀ᶠ y in 𝓝 (e x), e (e.symm y) = y :=\ne.eventually_right_inverse (e.map_source hx)\n\nlemma eventually_ne_nhds_within (e : local_homeomorph α β) {x} (hx : x ∈ e.source) :\n  ∀ᶠ x' in 𝓝[{x}ᶜ] x, e x' ≠ e x :=\neventually_nhds_within_iff.2 $ (e.eventually_left_inverse hx).mono $\n  λ x' hx', mt $ λ h, by rw [mem_singleton_iff, ← e.left_inv hx, ← h, hx']\n\nlemma nhds_within_source_inter {x} (hx : x ∈ e.source) (s : set α) :\n  𝓝[e.source ∩ s] x = 𝓝[s] x :=\nnhds_within_inter_of_mem (mem_nhds_within_of_mem_nhds $ mem_nhds_sets e.open_source hx)\n\nlemma nhds_within_target_inter {x} (hx : x ∈ e.target) (s : set β) :\n  𝓝[e.target ∩ s] x = 𝓝[s] x :=\ne.symm.nhds_within_source_inter hx s\n\nlemma image_eq_target_inter_inv_preimage {s : set α} (h : s ⊆ e.source) :\n  e '' s = e.target ∩ e.symm ⁻¹' s :=\ne.to_local_equiv.image_eq_target_inter_inv_preimage h\n\nlemma image_source_inter_eq' (s : set α) :\n  e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' s :=\ne.to_local_equiv.image_source_inter_eq' s\n\nlemma image_source_inter_eq (s : set α) :\n  e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' (e.source ∩ s) :=\ne.to_local_equiv.image_source_inter_eq s\n\nlemma symm_image_eq_source_inter_preimage {s : set β} (h : s ⊆ e.target) :\n  e.symm '' s = e.source ∩ e ⁻¹' s :=\ne.symm.image_eq_target_inter_inv_preimage h\n\nlemma symm_image_target_inter_eq (s : set β) :\n  e.symm '' (e.target ∩ s) = e.source ∩ e ⁻¹' (e.target ∩ s) :=\ne.symm.image_source_inter_eq _\n\nlemma source_inter_preimage_inv_preimage (s : set α) :\n  e.source ∩ e ⁻¹' (e.symm ⁻¹' s) = e.source ∩ s :=\ne.to_local_equiv.source_inter_preimage_inv_preimage s\n\nlemma target_inter_inv_preimage_preimage (s : set β) :\n  e.target ∩ e.symm ⁻¹' (e ⁻¹' s) = e.target ∩ s :=\ne.symm.source_inter_preimage_inv_preimage _\n\n/-- Two local homeomorphisms are equal when they have equal `to_fun`, `inv_fun` and `source`.\nIt is not sufficient to have equal `to_fun` and `source`, as this only determines `inv_fun` on\nthe target. This would only be true for a weaker notion of equality, arguably the right one,\ncalled `eq_on_source`. -/\n@[ext]\nprotected lemma ext (e' : local_homeomorph α β) (h : ∀x, e x = e' x)\n  (hinv : ∀x, e.symm x = e'.symm x) (hs : e.source = e'.source) : e = e' :=\neq_of_local_equiv_eq (local_equiv.ext h hinv hs)\n\n@[simp, mfld_simps] lemma symm_to_local_equiv : e.symm.to_local_equiv = e.to_local_equiv.symm := rfl\n-- The following lemmas are already simp via local_equiv\nlemma symm_source : e.symm.source = e.target := rfl\nlemma symm_target : e.symm.target = e.source := rfl\n@[simp, mfld_simps] lemma symm_symm : e.symm.symm = e := eq_of_local_equiv_eq $ by simp\n\n/-- A local homeomorphism is continuous at any point of its source -/\nprotected \n\n/-- A local homeomorphism inverse is continuous at any point of its target -/\nlemma continuous_at_symm {x : β} (h : x ∈ e.target) : continuous_at e.symm x :=\ne.symm.continuous_at h\n\nlemma tendsto_symm {x} (hx : x ∈ e.source) :\n  tendsto e.symm (𝓝 (e x)) (𝓝 x) :=\nby simpa only [continuous_at, e.left_inv hx] using e.continuous_at_symm (e.map_source hx)\n\nlemma map_nhds_eq {x} (hx : x ∈ e.source) : map e (𝓝 x) = 𝓝 (e x) :=\nle_antisymm (e.continuous_at hx) $\n  le_map_of_right_inverse (e.eventually_right_inverse' hx) (e.tendsto_symm hx)\n\nlemma symm_map_nhds_eq {x} (hx : x ∈ e.source) :\n  map e.symm (𝓝 (e x)) = 𝓝 x :=\n(e.symm.map_nhds_eq $ e.map_source hx).trans $ by rw e.left_inv hx\n\nlemma image_mem_nhds {x} (hx : x ∈ e.source) {s : set α} (hs : s ∈ 𝓝 x) :\n  e '' s ∈ 𝓝 (e x) :=\ne.map_nhds_eq hx ▸ filter.image_mem_map hs\n\nlemma map_nhds_within_eq (e : local_homeomorph α β) {x} (hx : x ∈ e.source) (s : set α) :\n  map e (𝓝[s] x) = 𝓝[e '' (e.source ∩ s)] (e x) :=\ncalc map e (𝓝[s] x) = map e (𝓝[e.source ∩ s] x) :\n  congr_arg (map e) (e.nhds_within_source_inter hx _).symm\n... = 𝓝[e '' (e.source ∩ s)] (e x) :\n  (e.left_inv_on.mono $ inter_subset_left _ _).map_nhds_within_eq (e.left_inv hx)\n    (e.continuous_at_symm (e.map_source hx)).continuous_within_at\n    (e.continuous_at hx).continuous_within_at\n\nlemma map_nhds_within_preimage_eq (e : local_homeomorph α β) {x} (hx : x ∈ e.source) (s : set β) :\n  map e (𝓝[e ⁻¹' s] x) = 𝓝[s] (e x) :=\nby rw [e.map_nhds_within_eq hx, e.image_source_inter_eq', e.target_inter_inv_preimage_preimage,\n  e.nhds_within_target_inter (e.map_source hx)]\n\nlemma preimage_open_of_open {s : set β} (hs : is_open s) : is_open (e.source ∩ e ⁻¹' s) :=\ne.continuous_on.preimage_open_of_open e.open_source hs\n\n/-!\n### `local_homeomorph.is_image` relation\n\nWe say that `t : set β` is an image of `s : set α` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source ∩ s) = e.target ∩ t`;\n* `e.source ∩ e ⁻¹ t = e.source ∩ s`;\n* `∀ x ∈ e.source, e x ∈ t ↔ x ∈ s` (this one is used in the definition).\n\nThis definition is a restatement of `local_equiv.is_image` for local homeomorphisms. In this section\nwe transfer API about `local_equiv.is_image` to local homeomorphisms and add a few\n`local_homeomorph`-specific lemmas like `local_homeomorph.is_image.closure`.\n-/\n\n/-- We say that `t : set β` is an image of `s : set α` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source ∩ s) = e.target ∩ t`;\n* `e.source ∩ e ⁻¹ t = e.source ∩ s`;\n* `∀ x ∈ e.source, e x ∈ t ↔ x ∈ s` (this one is used in the definition).\n-/\ndef is_image (s : set α) (t : set β) : Prop := ∀ ⦃x⦄, x ∈ e.source → (e x ∈ t ↔ x ∈ s)\n\nnamespace is_image\n\nvariables {e} {s : set α} {t : set β} {x : α} {y : β}\n\nlemma to_local_equiv (h : e.is_image s t) : e.to_local_equiv.is_image s t := h\n\nlemma apply_mem_iff (h : e.is_image s t) (hx : x ∈ e.source) : e x ∈ t ↔ x ∈ s := h hx\n\nprotected lemma symm (h : e.is_image s t) : e.symm.is_image t s := h.to_local_equiv.symm\n\nlemma symm_apply_mem_iff (h : e.is_image s t) (hy : y ∈ e.target) : (e.symm y ∈ s ↔ y ∈ t) :=\nh.symm hy\n\n@[simp] lemma symm_iff : e.symm.is_image t s ↔ e.is_image s t := ⟨λ h, h.symm, λ h, h.symm⟩\n\nprotected lemma maps_to (h : e.is_image s t) : maps_to e (e.source ∩ s) (e.target ∩ t) :=\nh.to_local_equiv.maps_to\n\nlemma symm_maps_to (h : e.is_image s t) : maps_to e.symm (e.target ∩ t) (e.source ∩ s) :=\nh.symm.maps_to\n\nlemma image_eq (h : e.is_image s t) : e '' (e.source ∩ s) = e.target ∩ t :=\nh.to_local_equiv.image_eq\n\nlemma symm_image_eq (h : e.is_image s t) : e.symm '' (e.target ∩ t) = e.source ∩ s :=\nh.symm.image_eq\n\nlemma iff_preimage_eq : e.is_image s t ↔ e.source ∩ e ⁻¹' t = e.source ∩ s :=\nlocal_equiv.is_image.iff_preimage_eq\n\nalias iff_preimage_eq ↔ local_homeomorph.is_image.preimage_eq\n  local_homeomorph.is_image.of_preimage_eq\n\nlemma iff_symm_preimage_eq : e.is_image s t ↔ e.target ∩ e.symm ⁻¹' s = e.target ∩ t :=\nsymm_iff.symm.trans iff_preimage_eq\n\nalias iff_symm_preimage_eq ↔ local_homeomorph.is_image.symm_preimage_eq\n  local_homeomorph.is_image.of_symm_preimage_eq\n\nlemma iff_symm_preimage_eq' :\n  e.is_image s t ↔ e.target ∩ e.symm ⁻¹' (e.source ∩ s) = e.target ∩ t :=\nby rw [iff_symm_preimage_eq, ← image_source_inter_eq, ← image_source_inter_eq']\n\nalias iff_symm_preimage_eq' ↔ local_homeomorph.is_image.symm_preimage_eq'\n  local_homeomorph.is_image.of_symm_preimage_eq'\n\nlemma iff_preimage_eq' : e.is_image s t ↔ e.source ∩ e ⁻¹' (e.target ∩ t) = e.source ∩ s :=\nsymm_iff.symm.trans iff_symm_preimage_eq'\n\nalias iff_preimage_eq' ↔ local_homeomorph.is_image.preimage_eq'\n  local_homeomorph.is_image.of_preimage_eq'\n\nlemma of_image_eq (h : e '' (e.source ∩ s) = e.target ∩ t) : e.is_image s t :=\nlocal_equiv.is_image.of_image_eq h\n\nlemma of_symm_image_eq (h : e.symm '' (e.target ∩ t) = e.source ∩ s) : e.is_image s t :=\nlocal_equiv.is_image.of_symm_image_eq h\n\nprotected lemma compl (h : e.is_image s t) : e.is_image sᶜ tᶜ :=\nλ x hx, not_congr (h hx)\n\nprotected lemma inter {s' t'} (h : e.is_image s t) (h' : e.is_image s' t') :\n  e.is_image (s ∩ s') (t ∩ t') :=\nλ x hx, and_congr (h hx) (h' hx)\n\nprotected lemma union {s' t'} (h : e.is_image s t) (h' : e.is_image s' t') :\n  e.is_image (s ∪ s') (t ∪ t') :=\nλ x hx, or_congr (h hx) (h' hx)\n\nprotected lemma diff {s' t'} (h : e.is_image s t) (h' : e.is_image s' t') :\n  e.is_image (s \\ s') (t \\ t') :=\nh.inter h'.compl\n\nlemma left_inv_on_piecewise {e' : local_homeomorph α β} [∀ i, decidable (i ∈ s)]\n  [∀ i, decidable (i ∈ t)] (h : e.is_image s t) (h' : e'.is_image s t) :\n  left_inv_on (t.piecewise e.symm e'.symm) (s.piecewise e e') (s.ite e.source e'.source) :=\nh.to_local_equiv.left_inv_on_piecewise h'\n\nlemma inter_eq_of_inter_eq_of_eq_on {e' : local_homeomorph α β} (h : e.is_image s t)\n  (h' : e'.is_image s t) (hs : e.source ∩ s = e'.source ∩ s) (Heq : eq_on e e' (e.source ∩ s)) :\n  e.target ∩ t = e'.target ∩ t :=\nh.to_local_equiv.inter_eq_of_inter_eq_of_eq_on h' hs Heq\n\nlemma symm_eq_on_of_inter_eq_of_eq_on {e' : local_homeomorph α β} (h : e.is_image s t)\n  (hs : e.source ∩ s = e'.source ∩ s) (Heq : eq_on e e' (e.source ∩ s)) :\n  eq_on e.symm e'.symm (e.target ∩ t) :=\nh.to_local_equiv.symm_eq_on_of_inter_eq_of_eq_on hs Heq\n\nlemma map_nhds_within_eq (h : e.is_image s t) (hx : x ∈ e.source) :\n  map e (𝓝[s] x) = 𝓝[t] (e x) :=\nby rw [e.map_nhds_within_eq hx, h.image_eq, e.nhds_within_target_inter (e.map_source hx)]\n\nprotected lemma closure (h : e.is_image s t) : e.is_image (closure s) (closure t) :=\nλ x hx, by simp only [mem_closure_iff_nhds_within_ne_bot, ← h.map_nhds_within_eq hx, map_ne_bot_iff]\n\nprotected lemma interior (h : e.is_image s t) : e.is_image (interior s) (interior t) :=\nby simpa only [closure_compl, compl_compl] using h.compl.closure.compl\n\nprotected lemma frontier (h : e.is_image s t) :\n  e.is_image (frontier s) (frontier t) :=\nh.closure.diff h.interior\n\nlemma is_open_iff (h : e.is_image s t) :\n  is_open (e.source ∩ s) ↔ is_open (e.target ∩ t) :=\n⟨λ hs, h.symm_preimage_eq' ▸ e.symm.preimage_open_of_open hs,\n  λ hs, h.preimage_eq' ▸ e.preimage_open_of_open hs⟩\n\n/-- Restrict a `local_homeomorph` to a pair of corresponding open sets. -/\n@[simps to_local_equiv] def restr (h : e.is_image s t) (hs : is_open (e.source ∩ s)) :\n  local_homeomorph α β :=\n{ to_local_equiv := h.to_local_equiv.restr,\n  open_source := hs,\n  open_target := h.is_open_iff.1 hs,\n  continuous_to_fun := e.continuous_on.mono (inter_subset_left _ _),\n  continuous_inv_fun := e.symm.continuous_on.mono (inter_subset_left _ _) }\n\nend is_image\n\nlemma is_image_source_target : e.is_image e.source e.target :=\ne.to_local_equiv.is_image_source_target\n\nlemma is_image_source_target_of_disjoint (e' : local_homeomorph α β)\n  (hs : disjoint e.source e'.source) (ht : disjoint e.target e'.target) :\n  e.is_image e'.source e'.target :=\ne.to_local_equiv.is_image_source_target_of_disjoint e'.to_local_equiv hs ht\n\n/-- Preimage of interior or interior of preimage coincide for local homeomorphisms, when restricted\nto the source. -/\nlemma preimage_interior (s : set β) :\n  e.source ∩ e ⁻¹' (interior s) = e.source ∩ interior (e ⁻¹' s) :=\n(is_image.of_preimage_eq rfl).interior.preimage_eq\n\nlemma preimage_closure (s : set β) :\n  e.source ∩ e ⁻¹' (closure s) = e.source ∩ closure (e ⁻¹' s) :=\n(is_image.of_preimage_eq rfl).closure.preimage_eq\n\nlemma preimage_frontier (s : set β) :\n  e.source ∩ e ⁻¹' (frontier s) = e.source ∩ frontier (e ⁻¹' s) :=\n(is_image.of_preimage_eq rfl).frontier.preimage_eq\n\nlemma preimage_open_of_open_symm {s : set α} (hs : is_open s) :\n  is_open (e.target ∩ e.symm ⁻¹' s) :=\ne.symm.continuous_on.preimage_open_of_open e.open_target hs\n\n/-- The image of an open set in the source is open. -/\nlemma image_open_of_open {s : set α} (hs : is_open s) (h : s ⊆ e.source) : is_open (e '' s) :=\nbegin\n  have : e '' s = e.target ∩ e.symm ⁻¹' s :=\n    e.to_local_equiv.image_eq_target_inter_inv_preimage h,\n  rw this,\n  exact e.continuous_on_symm.preimage_open_of_open e.open_target hs\nend\n\n/-- The image of the restriction of an open set to the source is open. -/\nlemma image_open_of_open' {s : set α} (hs : is_open s) : is_open (e '' (e.source ∩ s)) :=\nimage_open_of_open _ (is_open_inter e.open_source hs) (inter_subset_left _ _)\n\n/-- A `local_equiv` with continuous open forward map and an open source is a `local_homeomorph`. -/\ndef of_continuous_open_restrict (e : local_equiv α β) (hc : continuous_on e e.source)\n  (ho : is_open_map (e.source.restrict e)) (hs : is_open e.source) :\n  local_homeomorph α β :=\n{ to_local_equiv := e,\n  open_source := hs,\n  open_target := by simpa only [range_restrict, e.image_source_eq_target] using ho.is_open_range,\n  continuous_to_fun := hc,\n  continuous_inv_fun := e.image_source_eq_target ▸\n    ho.continuous_on_image_of_left_inv_on e.left_inv_on }\n\n/-- A `local_equiv` with continuous open forward map and an open source is a `local_homeomorph`. -/\ndef of_continuous_open (e : local_equiv α β) (hc : continuous_on e e.source)\n  (ho : is_open_map e) (hs : is_open e.source) :\n  local_homeomorph α β :=\nof_continuous_open_restrict e hc (ho.restrict hs) hs\n\n/-- Restricting a local homeomorphism `e` to `e.source ∩ s` when `s` is open. This is sometimes hard\nto use because of the openness assumption, but it has the advantage that when it can\nbe used then its local_equiv is defeq to local_equiv.restr -/\nprotected def restr_open (s : set α) (hs : is_open s) :\n  local_homeomorph α β :=\n(@is_image.of_symm_preimage_eq α β _ _ e s (e.symm ⁻¹' s) rfl).restr\n  (is_open_inter e.open_source hs)\n\n@[simp, mfld_simps] lemma restr_open_to_local_equiv (s : set α) (hs : is_open s) :\n  (e.restr_open s hs).to_local_equiv = e.to_local_equiv.restr s := rfl\n\n-- Already simp via local_equiv\nlemma restr_open_source (s : set α) (hs : is_open s) :\n  (e.restr_open s hs).source = e.source ∩ s := rfl\n\n/-- Restricting a local homeomorphism `e` to `e.source ∩ interior s`. We use the interior to make\nsure that the restriction is well defined whatever the set s, since local homeomorphisms are by\ndefinition defined on open sets. In applications where `s` is open, this coincides with the\nrestriction of local equivalences -/\n@[simps apply symm_apply (mfld_cfg), simps source target {attrs := []}]\nprotected def restr (s : set α) : local_homeomorph α β :=\ne.restr_open (interior s) is_open_interior\n\n@[simp, mfld_simps] lemma restr_to_local_equiv (s : set α) :\n  (e.restr s).to_local_equiv = (e.to_local_equiv).restr (interior s) := rfl\n\nlemma restr_source' (s : set α) (hs : is_open s) : (e.restr s).source = e.source ∩ s :=\nby rw [e.restr_source, hs.interior_eq]\n\nlemma restr_to_local_equiv' (s : set α) (hs : is_open s):\n  (e.restr s).to_local_equiv = e.to_local_equiv.restr s :=\nby rw [e.restr_to_local_equiv, hs.interior_eq]\n\nlemma restr_eq_of_source_subset {e : local_homeomorph α β} {s : set α} (h : e.source ⊆ s) :\n  e.restr s = e :=\nbegin\n  apply eq_of_local_equiv_eq,\n  rw restr_to_local_equiv,\n  apply local_equiv.restr_eq_of_source_subset,\n  exact interior_maximal h e.open_source\nend\n\n@[simp, mfld_simps] lemma restr_univ {e : local_homeomorph α β} : e.restr univ = e :=\nrestr_eq_of_source_subset (subset_univ _)\n\nlemma restr_source_inter (s : set α) : e.restr (e.source ∩ s) = e.restr s :=\nbegin\n  refine local_homeomorph.ext _ _ (λx, rfl) (λx, rfl) _,\n  simp [e.open_source.interior_eq, ← inter_assoc]\nend\n\n/-- The identity on the whole space as a local homeomorphism. -/\n@[simps apply (mfld_cfg), simps source target {attrs := []}]\nprotected def refl (α : Type*) [topological_space α] : local_homeomorph α α :=\n(homeomorph.refl α).to_local_homeomorph\n\n@[simp, mfld_simps] lemma refl_local_equiv :\n  (local_homeomorph.refl α).to_local_equiv = local_equiv.refl α := rfl\n@[simp, mfld_simps] lemma refl_symm : (local_homeomorph.refl α).symm = local_homeomorph.refl α :=\nrfl\n\nsection\nvariables {s : set α} (hs : is_open s)\n\n/-- The identity local equiv on a set `s` -/\n@[simps apply (mfld_cfg), simps source target {attrs := []}]\ndef of_set (s : set α) (hs : is_open s) : local_homeomorph α α :=\n{ open_source        := hs,\n  open_target        := hs,\n  continuous_to_fun  := continuous_id.continuous_on,\n  continuous_inv_fun := continuous_id.continuous_on,\n  ..local_equiv.of_set s }\n\n@[simp, mfld_simps] lemma of_set_to_local_equiv :\n  (of_set s hs).to_local_equiv = local_equiv.of_set s := rfl\n@[simp, mfld_simps] lemma of_set_symm : (of_set s hs).symm = of_set s hs := rfl\n\n@[simp, mfld_simps] lemma of_set_univ_eq_refl :\n  of_set univ is_open_univ = local_homeomorph.refl α :=\nby ext; simp\n\nend\n\n/-- Composition of two local homeomorphisms when the target of the first and the source of\nthe second coincide. -/\nprotected def trans' (h : e.target = e'.source) : local_homeomorph α γ :=\n{ open_source       := e.open_source,\n  open_target       := e'.open_target,\n  continuous_to_fun := begin\n    apply continuous_on.comp e'.continuous_to_fun e.continuous_to_fun,\n    rw ← h,\n    exact e.to_local_equiv.source_subset_preimage_target\n  end,\n  continuous_inv_fun := begin\n    apply continuous_on.comp e.continuous_inv_fun e'.continuous_inv_fun,\n    rw h,\n    exact e'.to_local_equiv.target_subset_preimage_source\n  end,\n  ..local_equiv.trans' e.to_local_equiv e'.to_local_equiv h }\n\n/-- Composing two local homeomorphisms, by restricting to the maximal domain where their\ncomposition is well defined. -/\nprotected def trans : local_homeomorph α γ :=\n  local_homeomorph.trans' (e.symm.restr_open e'.source e'.open_source).symm\n    (e'.restr_open e.target e.open_target) (by simp [inter_comm])\n\n@[simp, mfld_simps] lemma trans_to_local_equiv :\n  (e.trans e').to_local_equiv = e.to_local_equiv.trans e'.to_local_equiv := rfl\n@[simp, mfld_simps] lemma coe_trans : (e.trans e' : α → γ) = e' ∘ e := rfl\n@[simp, mfld_simps] lemma coe_trans_symm : ((e.trans e').symm : γ → α) = e.symm ∘ e'.symm := rfl\n\nlemma trans_symm_eq_symm_trans_symm : (e.trans e').symm = e'.symm.trans e.symm :=\nby cases e; cases e'; refl\n\n/- This could be considered as a simp lemma, but there are many situations where it makes something\nsimple into something more complicated. -/\nlemma trans_source : (e.trans e').source = e.source ∩ e ⁻¹' e'.source :=\nlocal_equiv.trans_source e.to_local_equiv e'.to_local_equiv\n\nlemma trans_source' : (e.trans e').source = e.source ∩ e ⁻¹' (e.target ∩ e'.source) :=\nlocal_equiv.trans_source' e.to_local_equiv e'.to_local_equiv\n\nlemma trans_source'' : (e.trans e').source = e.symm '' (e.target ∩ e'.source) :=\nlocal_equiv.trans_source'' e.to_local_equiv e'.to_local_equiv\n\nlemma image_trans_source : e '' (e.trans e').source = e.target ∩ e'.source :=\nlocal_equiv.image_trans_source e.to_local_equiv e'.to_local_equiv\n\nlemma trans_target : (e.trans e').target = e'.target ∩ e'.symm ⁻¹' e.target := rfl\n\nlemma trans_target' : (e.trans e').target = e'.target ∩ e'.symm ⁻¹' (e'.source ∩ e.target) :=\ntrans_source' e'.symm e.symm\n\nlemma trans_target'' : (e.trans e').target = e' '' (e'.source ∩ e.target) :=\ntrans_source'' e'.symm e.symm\n\nlemma inv_image_trans_target : e'.symm '' (e.trans e').target = e'.source ∩ e.target :=\nimage_trans_source e'.symm e.symm\n\nlemma trans_assoc (e'' : local_homeomorph γ δ) :\n  (e.trans e').trans e'' = e.trans (e'.trans e'') :=\neq_of_local_equiv_eq $ local_equiv.trans_assoc e.to_local_equiv e'.to_local_equiv e''.to_local_equiv\n\n@[simp, mfld_simps] lemma trans_refl : e.trans (local_homeomorph.refl β) = e :=\neq_of_local_equiv_eq $ local_equiv.trans_refl e.to_local_equiv\n\n@[simp, mfld_simps] lemma refl_trans : (local_homeomorph.refl α).trans e = e :=\neq_of_local_equiv_eq $ local_equiv.refl_trans e.to_local_equiv\n\nlemma trans_of_set {s : set β} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e ⁻¹' s) :=\nlocal_homeomorph.ext _ _ (λx, rfl) (λx, rfl) $\n  by simp [local_equiv.trans_source, (e.preimage_interior _).symm, hs.interior_eq]\n\nlemma trans_of_set' {s : set β} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e.source ∩ e ⁻¹' s) :=\nby rw [trans_of_set, restr_source_inter]\n\nlemma of_set_trans {s : set α} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr s :=\nlocal_homeomorph.ext _ _ (λx, rfl) (λx, rfl) $\n  by simp [local_equiv.trans_source, hs.interior_eq, inter_comm]\n\nlemma of_set_trans' {s : set α} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr (e.source ∩ s) :=\nby rw [of_set_trans, restr_source_inter]\n\n@[simp, mfld_simps] lemma of_set_trans_of_set\n  {s : set α} (hs : is_open s) {s' : set α} (hs' : is_open s') :\n  (of_set s hs).trans (of_set s' hs') = of_set (s ∩ s') (is_open_inter hs hs')  :=\nbegin\n  rw (of_set s hs).trans_of_set hs',\n  ext; simp [hs'.interior_eq]\nend\n\nlemma restr_trans (s : set α) :\n  (e.restr s).trans e' = (e.trans e').restr s :=\neq_of_local_equiv_eq $ local_equiv.restr_trans e.to_local_equiv e'.to_local_equiv (interior s)\n\n/-- `eq_on_source e e'` means that `e` and `e'` have the same source, and coincide there. They\nshould really be considered the same local equiv. -/\ndef eq_on_source (e e' : local_homeomorph α β) : Prop :=\ne.source = e'.source ∧ (eq_on e e' e.source)\n\nlemma eq_on_source_iff (e e' : local_homeomorph α β) :\neq_on_source e e' ↔ local_equiv.eq_on_source e.to_local_equiv e'.to_local_equiv :=\niff.rfl\n\n/-- `eq_on_source` is an equivalence relation -/\ninstance : setoid (local_homeomorph α β) :=\n{ r     := eq_on_source,\n  iseqv := ⟨\n    λe, (@local_equiv.eq_on_source_setoid α β).iseqv.1 e.to_local_equiv,\n    λe e' h, (@local_equiv.eq_on_source_setoid α β).iseqv.2.1 ((eq_on_source_iff e e').1 h),\n    λe e' e'' h h', (@local_equiv.eq_on_source_setoid α β).iseqv.2.2\n      ((eq_on_source_iff e e').1 h) ((eq_on_source_iff e' e'').1 h')⟩ }\n\nlemma eq_on_source_refl : e ≈ e := setoid.refl _\n\n/-- If two local homeomorphisms are equivalent, so are their inverses -/\nlemma eq_on_source.symm' {e e' : local_homeomorph α β} (h : e ≈ e') : e.symm ≈ e'.symm :=\nlocal_equiv.eq_on_source.symm' h\n\n/-- Two equivalent local homeomorphisms have the same source -/\nlemma eq_on_source.source_eq {e e' : local_homeomorph α β} (h : e ≈ e') : e.source = e'.source :=\nh.1\n\n/-- Two equivalent local homeomorphisms have the same target -/\nlemma eq_on_source.target_eq {e e' : local_homeomorph α β} (h : e ≈ e') : e.target = e'.target :=\nh.symm'.1\n\n/-- Two equivalent local homeomorphisms have coinciding `to_fun` on the source -/\nlemma eq_on_source.eq_on {e e' : local_homeomorph α β} (h : e ≈ e') :\n  eq_on e e' e.source :=\nh.2\n\n/-- Two equivalent local homeomorphisms have coinciding `inv_fun` on the target -/\nlemma eq_on_source.symm_eq_on_target {e e' : local_homeomorph α β} (h : e ≈ e') :\n  eq_on e.symm e'.symm e.target :=\nh.symm'.2\n\n/-- Composition of local homeomorphisms respects equivalence -/\nlemma eq_on_source.trans' {e e' : local_homeomorph α β} {f f' : local_homeomorph β γ}\n  (he : e ≈ e') (hf : f ≈ f') : e.trans f ≈ e'.trans f' :=\nlocal_equiv.eq_on_source.trans' he hf\n\n/-- Restriction of local homeomorphisms respects equivalence -/\nlemma eq_on_source.restr {e e' : local_homeomorph α β} (he : e ≈ e') (s : set α) :\n  e.restr s ≈ e'.restr s :=\nlocal_equiv.eq_on_source.restr he _\n\n/-- Composition of a local homeomorphism and its inverse is equivalent to the restriction of the\nidentity to the source -/\nlemma trans_self_symm :\n  e.trans e.symm ≈ local_homeomorph.of_set e.source e.open_source :=\nlocal_equiv.trans_self_symm _\n\nlemma trans_symm_self :\n  e.symm.trans e ≈ local_homeomorph.of_set e.target e.open_target :=\ne.symm.trans_self_symm\n\nlemma eq_of_eq_on_source_univ {e e' : local_homeomorph α β} (h : e ≈ e')\n  (s : e.source = univ) (t : e.target = univ) : e = e' :=\neq_of_local_equiv_eq $ local_equiv.eq_of_eq_on_source_univ _ _ h s t\n\nsection prod\n\n/-- The product of two local homeomorphisms, as a local homeomorphism on the product space. -/\n@[simps to_local_equiv apply (mfld_cfg), simps source target symm_apply {attrs := []}]\ndef prod (e : local_homeomorph α β) (e' : local_homeomorph γ δ) :\n  local_homeomorph (α × γ) (β × δ) :=\n{ open_source := e.open_source.prod e'.open_source,\n  open_target := e.open_target.prod e'.open_target,\n  continuous_to_fun := e.continuous_on.prod_map e'.continuous_on,\n  continuous_inv_fun := e.continuous_on_symm.prod_map e'.continuous_on_symm,\n  to_local_equiv := e.to_local_equiv.prod e'.to_local_equiv }\n\n@[simp, mfld_simps] lemma prod_symm (e : local_homeomorph α β) (e' : local_homeomorph γ δ) :\n  (e.prod e').symm = (e.symm.prod e'.symm) :=\nrfl\n\n@[simp, mfld_simps] lemma prod_trans\n  {η : Type*} {ε : Type*} [topological_space η] [topological_space ε]\n  (e : local_homeomorph α β) (f : local_homeomorph β γ)\n  (e' : local_homeomorph δ η) (f' : local_homeomorph η ε) :\n  (e.prod e').trans (f.prod f') = (e.trans f).prod (e'.trans f') :=\nlocal_homeomorph.eq_of_local_equiv_eq $\n  by dsimp only [trans_to_local_equiv, prod_to_local_equiv]; apply local_equiv.prod_trans\n\nend prod\n\nsection piecewise\n\n/-- Combine two `local_homeomorph`s using `set.piecewise`. The source of the new `local_homeomorph`\nis `s.ite e.source e'.source = e.source ∩ s ∪ e'.source \\ s`, and similarly for target.  The\nfunction sends `e.source ∩ s` to `e.target ∩ t` using `e` and `e'.source \\ s` to `e'.target \\ t`\nusing `e'`, and similarly for the inverse function. To ensure that the maps `to_fun` and `inv_fun`\nare inverse of each other on the new `source` and `target`, the definition assumes that the sets `s`\nand `t` are related both by `e.is_image` and `e'.is_image`. To ensure that the new maps are\ncontinuous on `source`/`target`, it also assumes that `e.source` and `e'.source` meet `frontier s`\non the same set and `e x = e' x` on this intersection. -/\n@[simps to_local_equiv apply {fully_applied := ff}]\ndef piecewise (e e' : local_homeomorph α β) (s : set α) (t : set β)\n  [∀ x, decidable (x ∈ s)] [∀ y, decidable (y ∈ t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source ∩ frontier s = e'.source ∩ frontier s)\n  (Heq : eq_on e e' (e.source ∩ frontier s)) :\n  local_homeomorph α β :=\n{ to_local_equiv := e.to_local_equiv.piecewise e'.to_local_equiv s t H H',\n  open_source := e.open_source.ite e'.open_source Hs,\n  open_target := e.open_target.ite e'.open_target $\n    H.frontier.inter_eq_of_inter_eq_of_eq_on H'.frontier Hs Heq,\n  continuous_to_fun := continuous_on_piecewise_ite e.continuous_on e'.continuous_on Hs Heq,\n  continuous_inv_fun := continuous_on_piecewise_ite e.continuous_on_symm e'.continuous_on_symm\n    (H.frontier.inter_eq_of_inter_eq_of_eq_on H'.frontier Hs Heq)\n    (H.frontier.symm_eq_on_of_inter_eq_of_eq_on Hs Heq) }\n\n@[simp] lemma symm_piecewise (e e' : local_homeomorph α β) {s : set α} {t : set β}\n  [∀ x, decidable (x ∈ s)] [∀ y, decidable (y ∈ t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source ∩ frontier s = e'.source ∩ frontier s)\n  (Heq : eq_on e e' (e.source ∩ frontier s)) :\n  (e.piecewise e' s t H H' Hs Heq).symm =\n    e.symm.piecewise e'.symm t s H.symm H'.symm\n      (H.frontier.inter_eq_of_inter_eq_of_eq_on H'.frontier Hs Heq)\n      (H.frontier.symm_eq_on_of_inter_eq_of_eq_on Hs Heq) :=\nrfl\n\n/-- Combine two `local_homeomorph`s with disjoint sources and disjoint targets. We reuse\n`local_homeomorph.piecewise` then override `to_local_equiv` to `local_equiv.disjoint_union`.\nThis way we have better definitional equalities for `source` and `target`. -/\ndef disjoint_union (e e' : local_homeomorph α β)\n  [∀ x, decidable (x ∈ e.source)] [∀ y, decidable (y ∈ e.target)]\n  (Hs : disjoint e.source e'.source) (Ht : disjoint e.target e'.target) :\n  local_homeomorph α β :=\n(e.piecewise e' e.source e.target e.is_image_source_target\n  (e'.is_image_source_target_of_disjoint e Hs.symm Ht.symm)\n  (by rw [e.open_source.inter_frontier_eq, e'.open_source.inter_frontier_eq_empty_of_disjoint Hs])\n  (by { rw e.open_source.inter_frontier_eq, exact eq_on_empty _ _ })).replace_equiv\n    (e.to_local_equiv.disjoint_union e'.to_local_equiv Hs Ht)\n    (local_equiv.disjoint_union_eq_piecewise _ _ _ _).symm\n\nend piecewise\n\nsection pi\n\nvariables {ι : Type*} [fintype ι] {Xi Yi : ι → Type*} [Π i, topological_space (Xi i)]\n  [Π i, topological_space (Yi i)] (ei : Π i, local_homeomorph (Xi i) (Yi i))\n\n/-- The product of a finite family of `local_homeomorph`s. -/\n@[simps to_local_equiv] def pi : local_homeomorph (Π i, Xi i) (Π i, Yi i) :=\n{ to_local_equiv := local_equiv.pi (λ i, (ei i).to_local_equiv),\n  open_source := is_open_set_pi finite_univ $ λ i hi, (ei i).open_source,\n  open_target := is_open_set_pi finite_univ $ λ i hi, (ei i).open_target,\n  continuous_to_fun := continuous_on_pi.2 $ λ i, (ei i).continuous_on.comp\n    (continuous_apply _).continuous_on (λ f hf, hf i trivial),\n  continuous_inv_fun := continuous_on_pi.2 $ λ i, (ei i).continuous_on_symm.comp\n    (continuous_apply _).continuous_on (λ f hf, hf i trivial) }\n\nend pi\n\nsection continuity\n\n/-- Continuity within a set at a point can be read under right composition with a local\nhomeomorphism, if the point is in its target -/\nlemma continuous_within_at_iff_continuous_within_at_comp_right\n  {f : β → γ} {s : set β} {x : β} (h : x ∈ e.target) :\n  continuous_within_at f s x ↔ continuous_within_at (f ∘ e) (e ⁻¹' s) (e.symm x) :=\nby simp_rw [continuous_within_at, ← @tendsto_map'_iff _ _ _ _ e,\n  e.map_nhds_within_preimage_eq (e.map_target h), (∘), e.right_inv h]\n\n/-- Continuity at a point can be read under right composition with a local homeomorphism, if the\npoint is in its target -/\nlemma continuous_at_iff_continuous_at_comp_right\n  {f : β → γ} {x : β} (h : x ∈ e.target) :\n  continuous_at f x ↔ continuous_at (f ∘ e) (e.symm x) :=\nby rw [← continuous_within_at_univ, e.continuous_within_at_iff_continuous_within_at_comp_right h,\n       preimage_univ, continuous_within_at_univ]\n\n/-- A function is continuous on a set if and only if its composition with a local homeomorphism\non the right is continuous on the corresponding set. -/\nlemma continuous_on_iff_continuous_on_comp_right {f : β → γ} {s : set β} (h : s ⊆ e.target) :\n  continuous_on f s ↔ continuous_on (f ∘ e) (e.source ∩ e ⁻¹' s) :=\nbegin\n  simp only [← e.symm_image_eq_source_inter_preimage h, continuous_on, ball_image_iff],\n  refine forall_congr (λ x, forall_congr $ λ hx, _),\n  rw [e.continuous_within_at_iff_continuous_within_at_comp_right (h hx),\n    e.symm_image_eq_source_inter_preimage h, inter_comm, continuous_within_at_inter],\n  exact mem_nhds_sets e.open_source (e.map_target (h hx))\nend\n\n/-- Continuity within a set at a point can be read under left composition with a local\nhomeomorphism if a neighborhood of the initial point is sent to the source of the local\nhomeomorphism-/\nlemma continuous_within_at_iff_continuous_within_at_comp_left\n  {f : γ → α} {s : set γ} {x : γ} (hx : f x ∈ e.source) (h : f ⁻¹' e.source ∈ 𝓝[s] x) :\n  continuous_within_at f s x ↔ continuous_within_at (e ∘ f) s x :=\nbegin\n  refine ⟨(e.continuous_at hx).tendsto.comp, λ fe_cont, _⟩,\n  rw [← continuous_within_at_inter' h] at fe_cont ⊢,\n  have : continuous_within_at (e.symm ∘ (e ∘ f)) (s ∩ f ⁻¹' e.source) x,\n  { have : continuous_within_at e.symm univ (e (f x))\n      := (e.continuous_at_symm (e.map_source hx)).continuous_within_at,\n    exact continuous_within_at.comp this fe_cont (subset_univ _) },\n  exact this.congr (λy hy, by simp [e.left_inv hy.2]) (by simp [e.left_inv hx])\nend\n\n/-- Continuity at a point can be read under left composition with a local homeomorphism if a\nneighborhood of the initial point is sent to the source of the local homeomorphism-/\nlemma continuous_at_iff_continuous_at_comp_left {f : γ → α} {x : γ} (h : f ⁻¹' e.source ∈ 𝓝 x) :\n  continuous_at f x ↔ continuous_at (e ∘ f) x :=\nbegin\n  have hx : f x ∈ e.source := (mem_of_nhds h : _),\n  have h' : f ⁻¹' e.source ∈ 𝓝[univ] x, by rwa nhds_within_univ,\n  rw [← continuous_within_at_univ, ← continuous_within_at_univ,\n      e.continuous_within_at_iff_continuous_within_at_comp_left hx h']\nend\n\n/-- A function is continuous on a set if and only if its composition with a local homeomorphism\non the left is continuous on the corresponding set. -/\nlemma continuous_on_iff_continuous_on_comp_left {f : γ → α} {s : set γ} (h : s ⊆ f ⁻¹' e.source) :\n  continuous_on f s ↔ continuous_on (e ∘ f) s :=\nforall_congr $ λ x, forall_congr $ λ hx, e.continuous_within_at_iff_continuous_within_at_comp_left\n  (h hx) (mem_sets_of_superset self_mem_nhds_within h)\n\nend continuity\n\n/-- A local homeomrphism defines a homeomorphism between its source and target. -/\ndef to_homeomorph_source_target : e.source ≃ₜ e.target :=\n{ to_fun := e.maps_to.restrict _ _ _,\n  inv_fun := e.symm_maps_to.restrict _ _ _,\n  left_inv := λ x, subtype.eq $ e.left_inv x.2,\n  right_inv := λ x, subtype.eq $ e.right_inv x.2,\n  continuous_to_fun := continuous_subtype_mk _ $\n    continuous_on_iff_continuous_restrict.1 e.continuous_on,\n  continuous_inv_fun := continuous_subtype_mk _ $\n    continuous_on_iff_continuous_restrict.1 e.symm.continuous_on }\n\nlemma second_countable_topology_source [second_countable_topology β]\n  (e : local_homeomorph α β) :\n  second_countable_topology e.source :=\ne.to_homeomorph_source_target.second_countable_topology\n\n/-- If a local homeomorphism has source and target equal to univ, then it induces a homeomorphism\nbetween the whole spaces, expressed in this definition. -/\n@[simps apply symm_apply (mfld_cfg)]\ndef to_homeomorph_of_source_eq_univ_target_eq_univ (h : e.source = (univ : set α))\n  (h' : e.target = univ) : α ≃ₜ β :=\n{ to_fun := e,\n  inv_fun := e.symm,\n  left_inv := λx, e.left_inv $ by { rw h, exact mem_univ _ },\n  right_inv := λx, e.right_inv $ by { rw h', exact mem_univ _ },\n  continuous_to_fun := begin\n    rw [continuous_iff_continuous_on_univ],\n    convert e.continuous_to_fun,\n    rw h\n  end,\n  continuous_inv_fun := begin\n    rw [continuous_iff_continuous_on_univ],\n    convert e.continuous_inv_fun,\n    rw h'\n  end }\n\n/-- A local homeomorphism whose source is all of `α` defines an open embedding of `α` into `β`.  The\nconverse is also true; see `open_embedding.to_local_homeomorph`. -/\nlemma to_open_embedding (h : e.source = set.univ) : open_embedding e :=\nbegin\n  apply open_embedding_of_continuous_injective_open,\n  { apply continuous_iff_continuous_on_univ.mpr,\n    rw ← h,\n    exact e.continuous_to_fun },\n  { apply set.injective_iff_inj_on_univ.mpr,\n    rw ← h,\n    exact e.inj_on },\n  { intros U hU,\n    simpa only [h, subset_univ] with mfld_simps using e.image_open_of_open hU}\nend\n\nend local_homeomorph\n\nnamespace homeomorph\nvariables (e : α ≃ₜ β) (e' : β ≃ₜ γ)\n/- Register as simp lemmas that the fields of a local homeomorphism built from a homeomorphism\ncorrespond to the fields of the original homeomorphism. -/\n\nattribute [simps apply source target {simp_rhs := tt, .. mfld_cfg}] to_local_homeomorph\n\n@[simp, mfld_simps] lemma to_local_homeomorph_coe_symm :\n  (e.to_local_homeomorph.symm : β → α) = e.symm := rfl\n@[simp, mfld_simps] lemma refl_to_local_homeomorph :\n  (homeomorph.refl α).to_local_homeomorph = local_homeomorph.refl α := rfl\n@[simp, mfld_simps] lemma symm_to_local_homeomorph :\n  e.symm.to_local_homeomorph = e.to_local_homeomorph.symm := rfl\n@[simp, mfld_simps] lemma trans_to_local_homeomorph :\n  (e.trans e').to_local_homeomorph = e.to_local_homeomorph.trans e'.to_local_homeomorph :=\nlocal_homeomorph.eq_of_local_equiv_eq $ equiv.trans_to_local_equiv _ _\n\nend homeomorph\n\nnamespace open_embedding\nvariables (f : α → β) (h : open_embedding f)\n\n/-- An open embedding of `α` into `β`, with `α` nonempty, defines a local homeomorphism whose source\nis all of `α`.  The converse is also true; see `local_homeomorph.to_open_embedding`. -/\n@[simps apply source target (mfld_cfg)]\nnoncomputable def to_local_homeomorph [nonempty α] : local_homeomorph α β :=\nlocal_homeomorph.of_continuous_open\n  ((h.to_embedding.inj.inj_on univ).to_local_equiv _ _)\n  h.continuous.continuous_on h.is_open_map is_open_univ\n\nlemma continuous_at_iff\n  {f : α → β} {g : β → γ} (hf : open_embedding f) {x : α} :\n  continuous_at (g ∘ f) x ↔ continuous_at g (f x) :=\nbegin\n  haveI : nonempty α := ⟨x⟩,\n  convert (((hf.to_local_homeomorph f).continuous_at_iff_continuous_at_comp_right) _).symm,\n  { apply (local_homeomorph.left_inv _ _).symm,\n    simp, },\n  { simp, },\nend\n\nend open_embedding\n\nnamespace topological_space.opens\n\nopen topological_space\nvariables (s : opens α) [nonempty s]\n\n/-- The inclusion of an open subset `s` of a space `α` into `α` is a local homeomorphism from the\nsubtype `s` to `α`. -/\nnoncomputable def local_homeomorph_subtype_coe : local_homeomorph s α :=\nopen_embedding.to_local_homeomorph _ s.2.open_embedding_subtype_coe\n\n@[simp, mfld_simps] lemma local_homeomorph_subtype_coe_coe :\n  (s.local_homeomorph_subtype_coe : s → α) = coe := rfl\n\n@[simp, mfld_simps] lemma local_homeomorph_subtype_coe_source :\n  s.local_homeomorph_subtype_coe.source = set.univ := rfl\n\n@[simp, mfld_simps] lemma local_homeomorph_subtype_coe_target :\n  s.local_homeomorph_subtype_coe.target = s :=\nby { simp only [local_homeomorph_subtype_coe, subtype.range_coe_subtype] with mfld_simps, refl }\n\nend topological_space.opens\n\nnamespace local_homeomorph\n\nopen topological_space\nvariables (e : local_homeomorph α β)\nvariables (s : opens α) [nonempty s]\n\n/-- The restriction of a local homeomorphism `e` to an open subset `s` of the domain type produces a\nlocal homeomorphism whose domain is the subtype `s`.-/\nnoncomputable def subtype_restr : local_homeomorph s β := s.local_homeomorph_subtype_coe.trans e\n\nlemma subtype_restr_def : e.subtype_restr s = s.local_homeomorph_subtype_coe.trans e := rfl\n\n@[simp, mfld_simps] lemma subtype_restr_coe : ((e.subtype_restr s : local_homeomorph s β) : s → β)\n  = set.restrict (e : α → β) s := rfl\n\n@[simp, mfld_simps] lemma subtype_restr_source : (e.subtype_restr s).source = coe ⁻¹' e.source :=\nby simp only [subtype_restr_def] with mfld_simps\n\n/- This lemma characterizes the transition functions of an open subset in terms of the transition\nfunctions of the original space. -/\nlemma subtype_restr_symm_trans_subtype_restr (f f' : local_homeomorph α β) :\n  (f.subtype_restr s).symm.trans (f'.subtype_restr s)\n  ≈ (f.symm.trans f').restr (f.target ∩ (f.symm) ⁻¹' s) :=\nbegin\n  simp only [subtype_restr_def, trans_symm_eq_symm_trans_symm],\n  have openness₁ : is_open (f.target ∩ f.symm ⁻¹' s) := f.preimage_open_of_open_symm s.2,\n  rw [← of_set_trans _ openness₁, ← trans_assoc, ← trans_assoc],\n  refine eq_on_source.trans' _ (eq_on_source_refl _),\n  -- f' has been eliminated !!!\n  have sets_identity : f.symm.source ∩ (f.target ∩ (f.symm) ⁻¹' s) = f.symm.source ∩ f.symm ⁻¹' s,\n  { mfld_set_tac },\n  have openness₂ : is_open (s : set α) := s.2,\n  rw [of_set_trans', sets_identity, ← trans_of_set' _ openness₂, trans_assoc],\n  refine eq_on_source.trans' (eq_on_source_refl _) _,\n  -- f has been eliminated !!!\n  refine setoid.trans (trans_symm_self s.local_homeomorph_subtype_coe) _,\n  simp only with mfld_simps,\nend\n\nend local_homeomorph\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/local_homeomorph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.49062906560437786}}
{"text": "import .love08_operational_semantics_demo\n\n\n/-! # LoVe Demo 9: Hoare Logic\n\nWe review a second way to specify the semantics of a programming language: Hoare\nlogic. If operational semantics corresponds to an idealized interpreter,\n__Hoare logic__ (also called __axiomatic semantics__) corresponds to a verifier.\nHoare logic is particularly convenient to reason about concrete programs. -/\n\n\nset_option pp.beta true\nset_option pp.generalized_field_notation false\n\nnamespace LoVe\n\n\n/-! ## First Things First: Formalization Projects\n\nInstead of two of the homework sheets, you can do a verification project, worth\n20 points. If you choose to do so, please send your lecturer a message by email\nby the end of the week. For a fully successful project, we expect about 200 (or\nmore) lines of Lean, including definitions and proofs.\n\nSome ideas for projects follow.\n\nComputer science:\n\n* extended WHILE language with static arrays or other features;\n* functional data structures (e.g., balanced trees);\n* functional algorithms (e.g., bubble sort, merge sort, Tarjan's algorithm);\n* compiler from expressions or imperative programs to, e.g., stack machine;\n* type systems (e.g., Benjamin Pierce's __Types and Programming Languages__);\n* security properties (e.g., Volpano–Smith-style noninterference analysis);\n* theory of first-order terms, including matching, term rewriting;\n* automata theory;\n* normalization of context-free grammars or regular expressions;\n* process algebras and bisimilarity;\n* soundness and possibly completeness of proof systems (e.g., Genzen's sequent\n  calculus, natural deduction, tableaux);\n* separation logic;\n* verified program using Hoare logic.\n\nMathematics:\n\n* graphs;\n* combinatorics;\n* number theory.\n\nEvaluation from 2018–2019:\n\nQ: How did you find the project?\n\nA: Enjoyable.\n\nA: Fun and hard.\n\nA: Good, I think the format was excellent in a way that it gave people the\n   chance to do challenging exercises and hand them in incomplete.\n\nA: I really really liked it. I think it's a great way of learning—find\n   something you like, dig in it a little, get stuck, ask for help. I wish I\n   could do more of that!\n\nA: It was great to have some time to try to work out some stuff you find\n   interesting yourself.\n\nA: lots of fun actually!!!\n\nA: Very helpful. It gave the opportunity to spend some more time on a\n   particular aspect of the course.\n\n\n## Hoare Triples\n\nThe basic judgments of Hoare logic are often called __Hoare triples__. They have\nthe form\n\n    `{P} S {Q}`\n\nwhere `S` is a statement, and `P` and `Q` (called __precondition__ and\n__postcondition__) are logical formulas over the state variables.\n\nIntended meaning:\n\n    If `P` holds before `S` is executed and the execution terminates normally,\n    `Q` holds at termination.\n\nThis is a __partial correctness__ statement: The program is correct if it\nterminates normally (i.e., no run-time error, no infinite loop or divergence).\n\nAll of these Hoare triples are valid (with respect to the intended meaning):\n\n    `{true} b := 4 {b = 4}`\n    `{a = 2} b := 2 * a {a = 2 ∧ b = 4}`\n    `{b ≥ 5} b := b + 1 {b ≥ 6}`\n    `{false} skip {b = 100}`\n    `{true} while i ≠ 100 do i := i + 1 {i = 100}`\n\n\n## Hoare Rules\n\nThe following is a complete set of rules for reasoning about WHILE programs:\n\n    ———————————— Skip\n    {P} skip {P}\n\n    ——————————————————— Asn\n    {Q[a/x]} x := a {Q}\n\n    {P} S {R}   {R} S' {Q}\n    —————————————————————— Seq\n    {P} S; S' {Q}\n\n    {P ∧ b} S {Q}   {P ∧ ¬b} S' {Q}\n    ——————————————————————————————— If\n    {P} if b then S else S' {Q}\n\n    {I ∧ b} S {I}\n    ————————————————————————— While\n    {I} while b do S {I ∧ ¬b}\n\n    P' → P   {P} S {Q}   Q → Q'\n    ——————————————————————————— Conseq\n    {P'} S {Q'}\n\n`Q[a/x]` denotes `Q` with `x` replaced by `a`.\n\nIn the `While` rule, `I` is called an __invariant__.\n\nExcept for `Conseq`, the rules are syntax-driven: by looking at a program, we\nsee immediately which rule to apply.\n\nExample derivations:\n\n    —————————————————————— Asn   —————————————————————— Asn\n    {a = 2} b := a {b = 2}       {b = 2} c := b {c = 2}\n    ——————————————————————————————————————————————————— Seq\n    {a = 2} b := a; c := b {c = 2}\n\n\n                     —————————————————————— Asn\n    x > 10 → x > 5   {x > 5} y := x {y > 5}   y > 5 → y > 0\n    ——————————————————————————————————————————————————————— Conseq\n    {x > 10} y := x {y > 0}\n\nVarious __derived rules__ can be proved to be correct in terms of the standard\nrules. For example, we can derive bidirectional rules for `skip`, `:=`, and\n`while`:\n\n    P → Q\n    ———————————— Skip'\n    {P} skip {Q}\n\n    P → Q[a/x]\n    —————————————— Asn'\n    {P} x := a {Q}\n\n    {P ∧ b} S {P}   P ∧ ¬b → Q\n    —————————————————————————— While'\n    {P} while b do S {Q}\n\n\n## A Semantic Approach to Hoare Logic\n\nWe can, and will, define Hoare triples **semantically** in Lean.\n\nWe will use predicates on states (`state → Prop`) to represent pre- and\npostconditions, following the shallow embedding style. -/\n\ndef partial_hoare (P : state → Prop) (S : stmt)\n  (Q : state → Prop) : Prop :=\n∀s t, P s → (S, s) ⟹ t → Q t\n\nnotation `{* ` P : 1 ` *} ` S : 1 ` {* ` Q : 1 ` *}` :=\npartial_hoare P S Q\n\nnamespace partial_hoare\n\nlemma skip_intro {P} :\n  {* P *} stmt.skip {* P *} :=\nbegin\n  intros s t hs hst,\n  cases' hst,\n  assumption\nend\n\nlemma assign_intro (P : state → Prop) {x} {a : state → ℕ} :\n  {* λs, P (s{x ↦ a s}) *} stmt.assign x a {* P *} :=\nbegin\n  intros s t P hst,\n  cases' hst,\n  assumption\nend\n\nlemma seq_intro {P Q R S T} (hS : {* P *} S {* Q *})\n    (hT : {* Q *} T {* R *}) :\n  {* P *} S ;; T {* R *} :=\nbegin\n  intros s t hs hst,\n  cases' hst,\n  apply hT,\n  { apply hS,\n    { exact hs },\n    { assumption } },\n  { assumption }\nend\n\nlemma ite_intro {b P Q : state → Prop} {S T}\n    (hS : {* λs, P s ∧ b s *} S {* Q *})\n    (hT : {* λs, P s ∧ ¬ b s *} T {* Q *}) :\n  {* P *} stmt.ite b S T {* Q *} :=\nbegin\n  intros s t hs hst,\n  cases' hst,\n  { apply hS,\n    exact and.intro hs hcond,\n    assumption },\n  { apply hT,\n    exact and.intro hs hcond,\n    assumption }\nend\n\nlemma while_intro (P : state → Prop) {b : state → Prop} {S}\n    (h : {* λs, P s ∧ b s *} S {* P *}) :\n  {* P *} stmt.while b S {* λs, P s ∧ ¬ b s *} :=\nbegin\n  intros s t hs hst,\n  induction' hst,\n  case while_true {\n    apply ih_hst_1 P h,\n    exact h _ _ (and.intro hs hcond) hst },\n  case while_false {\n    exact and.intro hs hcond }\nend\n\nlemma consequence {P P' Q Q' : state → Prop} {S}\n    (h : {* P *} S {* Q *}) (hp : ∀s, P' s → P s)\n    (hq : ∀s, Q s → Q' s) :\n  {* P' *} S {* Q' *} :=\nfix s t,\nassume hs : P' s,\nassume hst : (S, s) ⟹ t,\nshow Q' t, from\n  hq _ (h s t (hp s hs) hst)\n\nlemma consequence_left (P' : state → Prop) {P Q S}\n    (h : {* P *} S {* Q *}) (hp : ∀s, P' s → P s) :\n  {* P' *} S {* Q *} :=\nconsequence h hp (by cc)\n\nlemma consequence_right (Q) {Q' : state → Prop} {P S}\n    (h : {* P *} S {* Q *}) (hq : ∀s, Q s → Q' s) :\n  {* P *} S {* Q' *} :=\nconsequence h (by cc) hq\n\nlemma skip_intro' {P Q : state → Prop} (h : ∀s, P s → Q s) :\n  {* P *} stmt.skip {* Q *} :=\nconsequence skip_intro h (by cc)\n\nlemma assign_intro' {P Q : state → Prop} {x} {a : state → ℕ}\n    (h : ∀s, P s → Q (s{x ↦ a s})):\n  {* P *} stmt.assign x a {* Q *} :=\nconsequence (assign_intro Q) h (by cc)\n\nlemma seq_intro' {P Q R S T} (hT : {* Q *} T {* R *})\n    (hS : {* P *} S {* Q *}) :\n  {* P *} S ;; T {* R *} :=\nseq_intro hS hT\n\nlemma while_intro' {b P Q : state → Prop} {S}\n    (I : state → Prop)\n    (hS : {* λs, I s ∧ b s *} S {* I *})\n    (hP : ∀s, P s → I s)\n    (hQ : ∀s, ¬ b s → I s → Q s) :\n  {* P *} stmt.while b S {* Q *} :=\nconsequence (while_intro I hS) hP (by finish)\n\n/-! `finish` applies a combination of techniques, including normalization of\nlogical connectives and quantifiers, simplification, congruence closure, and\nquantifier instantiation. It either fully succeeds or fails. -/\n\nlemma assign_intro_forward (P) {x a} :\n  {* P *}\n  stmt.assign x a\n  {* λs, ∃n₀, P (s{x ↦ n₀}) ∧ s x = a (s{x ↦ n₀}) *} :=\nbegin\n  apply assign_intro',\n  intros s hP,\n  apply exists.intro (s x),\n  simp [*]\nend\n\nlemma assign_intro_backward (Q : state → Prop) {x}\n    {a : state → ℕ} :\n  {* λs, ∃n', Q (s{x ↦ n'}) ∧ n' = a s *}\n  stmt.assign x a\n  {* Q *} :=\nbegin\n  apply assign_intro',\n  intros s hP,\n  cases' hP,\n  cc\nend\n\nend partial_hoare\n\n\n/-! ## First Program: Exchanging Two Variables -/\n\ndef SWAP : stmt :=\nstmt.assign \"t\" (λs, s \"a\") ;;\nstmt.assign \"a\" (λs, s \"b\") ;;\nstmt.assign \"b\" (λs, s \"t\")\n\nlemma SWAP_correct (a₀ b₀ : ℕ) :\n  {* λs, s \"a\" = a₀ ∧ s \"b\" = b₀ *}\n  SWAP\n  {* λs, s \"a\" = b₀ ∧ s \"b\" = a₀ *} :=\nbegin\n  apply partial_hoare.seq_intro',\n  apply partial_hoare.seq_intro',\n  apply partial_hoare.assign_intro,\n  apply partial_hoare.assign_intro,\n  apply partial_hoare.assign_intro',\n  simp { contextual := tt }\nend\n\nlemma SWAP_correct₂ (a₀ b₀ : ℕ) :\n  {* λs, s \"a\" = a₀ ∧ s \"b\" = b₀ *}\n  SWAP\n  {* λs, s \"a\" = b₀ ∧ s \"b\" = a₀ *} :=\nbegin\n  intros s t hP hstep,\n  cases' hstep,\n  cases' hstep,\n  cases' hstep_1,\n  cases' hstep_1_1,\n  cases' hstep_1,\n  finish\nend\n\n\n/-! ## Second Program: Adding Two Numbers -/\n\ndef ADD : stmt :=\nstmt.while (λs, s \"n\" ≠ 0)\n  (stmt.assign \"n\" (λs, s \"n\" - 1) ;;\n   stmt.assign \"m\" (λs, s \"m\" + 1))\n\nlemma ADD_correct (n₀ m₀ : ℕ) :\n  {* λs, s \"n\" = n₀ ∧ s \"m\" = m₀ *}\n  ADD\n  {* λs, s \"n\" = 0 ∧ s \"m\" = n₀ + m₀ *} :=\npartial_hoare.while_intro' (λs, s \"n\" + s \"m\" = n₀ + m₀)\n  begin\n    apply partial_hoare.seq_intro',\n    { apply partial_hoare.assign_intro },\n    { apply partial_hoare.assign_intro',\n      simp,\n      intros s hnm hnz,\n      rw ←hnm,\n      cases s \"n\",\n      { finish },\n      { simp [nat.succ_eq_add_one],\n        linarith } }\n  end\n  (by simp { contextual := true })\n  (by simp { contextual := true })\n\n/-! How did we come up with this invariant? The invariant must\n\n1. be true before we enter the loop;\n\n2. remain true after each iteration of the loop if it was true before the\n   iteration;\n\n3. be strong enough to imply the desired loop postcondition.\n\nThe invariant `true` meets 1 and 2 but usually not 3. Similarly, `false` meets\n2 and 3 but usually not 1. Suitable invariants are often of the form\n\n__work done__ + __work remaining__ = __desired result__\n\nwhere `+` is some suitable operator. When we enter the loop, __work done__ will\noften be `0`. And when we exit the loop, __work remaining__ should be `0`.\n\nFor the `ADD` loop:\n\n* __work done__ is `m`;\n* __work remaining__ is `n`;\n* __desired result__ is `n₀ + m₀`.\n\n\n## A Verification Condition Generator\n\n__Verification condition generators__ (VCGs) are programs that apply Hoare rules\nautomatically, producing __verification conditions__ that must be proved by the\nuser. The user must usually also provide strong enough loop invariants, as an\nannotation in their programs.\n\nWe can use Lean's metaprogramming framework to define a simple VCG.\n\nHundreds of program verification tools are based on these principles.\n\nVCGs typically work backwards from the postcondition, using backward rules\n(rules stated to have an arbitrary `Q` as their postcondition). This works well\nbecause `Asn` is backward. -/\n\ndef stmt.while_inv (I b : state → Prop) (S : stmt) : stmt :=\nstmt.while b S\n\nnamespace partial_hoare\n\nlemma while_inv_intro {b I Q : state → Prop} {S}\n    (hS : {* λs, I s ∧ b s *} S {* I *})\n    (hQ : ∀s, ¬ b s → I s → Q s) :\n  {* I *} stmt.while_inv I b S {* Q *} :=\nwhile_intro' I hS (by cc) hQ\n\nlemma while_inv_intro' {b I P Q : state → Prop} {S}\n    (hS : {* λs, I s ∧ b s *} S {* I *})\n    (hP : ∀s, P s → I s) (hQ : ∀s, ¬ b s → I s → Q s) :\n  {* P *} stmt.while_inv I b S {* Q *} :=\nwhile_intro' I hS hP hQ\n\nend partial_hoare\n\nmeta def vcg : tactic unit :=\ndo\n  t ← tactic.target,\n  match t with\n  | `({* %%P *} %%S {* _ *}) :=\n    match S with\n    | `(stmt.skip)            :=\n      tactic.applyc\n        (if expr.is_mvar P then ``partial_hoare.skip_intro\n         else ``partial_hoare.skip_intro')\n    | `(stmt.assign _ _)      :=\n      tactic.applyc\n        (if expr.is_mvar P then ``partial_hoare.assign_intro\n         else ``partial_hoare.assign_intro')\n    | `(stmt.seq _ _)         :=\n      tactic.applyc ``partial_hoare.seq_intro'; vcg\n    | `(stmt.ite _ _ _)       :=\n      tactic.applyc ``partial_hoare.ite_intro; vcg\n    | `(stmt.while_inv _ _ _) :=\n      tactic.applyc\n        (if expr.is_mvar P then ``partial_hoare.while_inv_intro\n         else ``partial_hoare.while_inv_intro');\n        vcg\n    | _                       :=\n      tactic.fail (to_fmt \"cannot analyze \" ++ to_fmt S)\n    end\n  | _                        := pure ()\n  end\n\nend LoVe\n\n/-! Register `vcg` as a proper tactic: -/\n\nmeta def tactic.interactive.vcg : tactic unit :=\nLoVe.vcg\n\nnamespace LoVe\n\n\n/-! ## Second Program Revisited: Adding Two Numbers -/\n\nlemma ADD_correct₂ (n₀ m₀ : ℕ) :\n  {* λs, s \"n\" = n₀ ∧ s \"m\" = m₀ *}\n  ADD\n  {* λs, s \"n\" = 0 ∧ s \"m\" = n₀ + m₀ *} :=\nshow {* λs, s \"n\" = n₀ ∧ s \"m\" = m₀ *}\n     stmt.while_inv (λs, s \"n\" + s \"m\" = n₀ + m₀)\n       (λs, s \"n\" ≠ 0)\n       (stmt.assign \"n\" (λs, s \"n\" - 1) ;;\n        stmt.assign \"m\" (λs, s \"m\" + 1))\n     {* λs, s \"n\" = 0 ∧ s \"m\" = n₀ + m₀ *}, from\n  begin\n    vcg; simp { contextual := tt },\n    intros s hnm hnz,\n    rw ←hnm,\n    cases s \"n\",\n    { finish },\n    { simp [nat.succ_eq_add_one],\n      linarith }\n  end\n\n\n/-! ## Hoare Triples for Total Correctness\n\n__Total correctness__ asserts that the program not only is partially correct but\nalso that it always terminates normally. Hoare triples for total correctness\nhave the form\n\n    [P] S [Q]\n\nIntended meaning:\n\n    If `P` holds before `S` is executed, the execution terminates normally and\n    `Q` holds in the final state.\n\nFor deterministic programs, an equivalent formulation is as follows:\n\n    If `P` holds before `S` is executed, there exists a state in which execution\n    terminates normally and `Q` holds in that state.\n\nExample:\n\n    `[i ≤ 100] while i ≠ 100 do i := i + 1 [i = 100]`\n\nIn our WHILE language, this only affects while loops, which must now be\nannotated by a __variant__ `V` (a natural number that decreases with each\niteration):\n\n    [I ∧ b ∧ V = v₀] S [I ∧ V < v₀]\n    ——————————————————————————————— While-Var\n    [I] while b do S [I ∧ ¬b]\n\nWhat is a suitable variant for the example above? -/\n\nend LoVe\n", "meta": {"author": "blanchette", "repo": "logical_verification_2021", "sha": "23b469c79afd482fa66da82e4726a317e3a7b5d5", "save_path": "github-repos/lean/blanchette-logical_verification_2021", "path": "github-repos/lean/blanchette-logical_verification_2021/logical_verification_2021-23b469c79afd482fa66da82e4726a317e3a7b5d5/lean/love09_hoare_logic_demo.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.7745833841649233, "lm_q1q2_score": 0.49062906560437786}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\n\nimport category_theory.sites.canonical\n\n/-!\n# Grothendieck Topology and Sheaves on the Category of Types\n\nIn this file we define a Grothendieck topology on the category of types,\nand construct the canonical functor that sends a type to a sheaf over\nthe category of types, and make this an equivalence of categories.\n\nThen we prove that the topology defined is the canonical topology.\n-/\n\nuniverse u\n\nnamespace category_theory\nopen_locale category_theory.Type\n\n/-- A Grothendieck topology associated to the category of all types.\nA sieve is a covering iff it is jointly surjective. -/\ndef types_grothendieck_topology : grothendieck_topology (Type u) :=\n{ sieves := λ α S, ∀ x : α, S (λ _ : punit, x),\n  top_mem' := λ α x, trivial,\n  pullback_stable' := λ α β S f hs x, hs (f x),\n  transitive' := λ α S hs R hr x, hr (hs x) punit.star }\n\n/-- The discrete sieve on a type, which only includes arrows whose image is a subsingleton. -/\n@[simps] def discrete_sieve (α : Type u) : sieve α :=\n{ arrows := λ β f, ∃ x, ∀ y, f y = x,\n  downward_closed' := λ β γ f ⟨x, hx⟩ g, ⟨x, λ y, hx $ g y⟩ }\n\nlemma discrete_sieve_mem (α : Type u) : discrete_sieve α ∈ types_grothendieck_topology α :=\nλ x, ⟨x, λ y, rfl⟩\n\n/-- The discrete presieve on a type, which only includes arrows whose domain is a singleton. -/\ndef discrete_presieve (α : Type u) : presieve α :=\nλ β f, ∃ x : β, ∀ y : β, y = x\n\nlemma generate_discrete_presieve_mem (α : Type u) :\n  sieve.generate (discrete_presieve α) ∈ types_grothendieck_topology α :=\nλ x, ⟨punit, id, λ _, x, ⟨punit.star, λ _, subsingleton.elim _ _⟩, rfl⟩\n\nopen presieve\n\ntheorem is_sheaf_yoneda' {α : Type u} : is_sheaf types_grothendieck_topology (yoneda.obj α) :=\nλ β S hs x hx, ⟨λ y, x _ (hs y) punit.star,\nλ γ f h, funext $ λ z,\n  have _ := congr_fun (hx (𝟙 _) (λ _, z) (hs $ f z) h rfl) punit.star,\n  by { convert this, exact rfl },\nλ f hf, funext $ λ y, by convert congr_fun (hf _ (hs y)) punit.star⟩\n\n/-- The yoneda functor that sends a type to a sheaf over the category of types -/\n@[simps] def yoneda' : Type u ⥤ SheafOfTypes types_grothendieck_topology :=\n{ obj := λ α, ⟨yoneda.obj α, is_sheaf_yoneda'⟩,\n  map := λ α β f, ⟨yoneda.map f⟩ }\n\n@[simp] lemma yoneda'_comp : yoneda'.{u} ⋙ SheafOfTypes_to_presheaf _ = yoneda := rfl\n\nopen opposite\n\n/-- Given a presheaf `P` on the category of types, construct\na map `P(α) → (α → P(*))` for all type `α`. -/\ndef eval (P : (Type u)ᵒᵖ ⥤ Type u) (α : Type u) (s : P.obj (op α)) (x : α) : P.obj (op punit) :=\nP.map (↾λ _, x).op s\n\n/-- Given a sheaf `S` on the category of types, construct a map\n`(α → S(*)) → S(α)` that is inverse to `eval`. -/\nnoncomputable def types_glue (S : (Type u)ᵒᵖ ⥤ Type u)\n  (hs : is_sheaf types_grothendieck_topology S)\n  (α : Type u) (f : α → S.obj (op punit)) : S.obj (op α) :=\n(hs.is_sheaf_for _ _ (generate_discrete_presieve_mem α)).amalgamate\n  (λ β g hg, S.map (↾λ x, punit.star).op $ f $ g $ classical.some hg)\n  (λ β γ δ g₁ g₂ f₁ f₂ hf₁ hf₂ h,\n    (hs.is_sheaf_for _ _ (generate_discrete_presieve_mem δ)).is_separated_for.ext $\n    λ ε g ⟨x, hx⟩, have f₁ (classical.some hf₁) = f₂ (classical.some hf₂),\n      from classical.some_spec hf₁ (g₁ $ g x) ▸ classical.some_spec hf₂ (g₂ $ g x) ▸ congr_fun h _,\n      by { simp_rw [← functor_to_types.map_comp_apply, this, ← op_comp], refl })\n\nlemma eval_types_glue {S hs α} (f) : eval.{u} S α (types_glue S hs α f) = f :=\nfunext $ λ x, (is_sheaf_for.valid_glue _ _ _ $\n  by exact ⟨punit.star, λ _, subsingleton.elim _ _⟩).trans $\nby { convert functor_to_types.map_id_apply _ _, rw ← op_id, congr }\n\nlemma types_glue_eval {S hs α} (s) : types_glue.{u} S hs α (eval S α s) = s :=\n(hs.is_sheaf_for _ _ (generate_discrete_presieve_mem α)).is_separated_for.ext $ λ β f hf,\n(is_sheaf_for.valid_glue _ _ _ hf).trans $ (functor_to_types.map_comp_apply _ _ _ _).symm.trans $\nby { rw ← op_comp, congr' 2, exact funext (λ x, congr_arg f (classical.some_spec hf x).symm) }\n\n/-- Given a sheaf `S`, construct an equivalence `S(α) ≃ (α → S(*))`. -/\n@[simps] noncomputable def eval_equiv (S : (Type u)ᵒᵖ ⥤ Type u)\n  (hs : is_sheaf types_grothendieck_topology S)\n  (α : Type u) : S.obj (op α) ≃ (α → S.obj (op punit)) :=\n{ to_fun := eval S α,\n  inv_fun := types_glue S hs α,\n  left_inv := types_glue_eval,\n  right_inv := eval_types_glue }\n\nlemma eval_map (S : (Type u)ᵒᵖ ⥤ Type u) (α β) (f : β ⟶ α) (s x) :\n  eval S β (S.map f.op s) x = eval S α s (f x) :=\nby { simp_rw [eval, ← functor_to_types.map_comp_apply, ← op_comp], refl }\n\n/-- Given a sheaf `S`, construct an isomorphism `S ≅ [-, S(*)]`. -/\n@[simps] noncomputable def equiv_yoneda (S : (Type u)ᵒᵖ ⥤ Type u)\n  (hs : is_sheaf types_grothendieck_topology S) :\n  S ≅ yoneda.obj (S.obj (op punit)) :=\nnat_iso.of_components (λ α, equiv.to_iso $ eval_equiv S hs $ unop α) $ λ α β f,\nfunext $ λ s, funext $ λ x, eval_map S (unop α) (unop β) f.unop _ _\n\n/-- Given a sheaf `S`, construct an isomorphism `S ≅ [-, S(*)]`. -/\n@[simps] noncomputable def equiv_yoneda'\n  (S : SheafOfTypes types_grothendieck_topology) :\n  S ≅ yoneda'.obj (S.1.obj (op punit)) :=\n{ hom := ⟨(equiv_yoneda S.1 S.2).hom⟩,\n  inv := ⟨(equiv_yoneda S.1 S.2).inv⟩,\n  hom_inv_id' := by { ext1, apply (equiv_yoneda S.1 S.2).hom_inv_id },\n  inv_hom_id' := by { ext1, apply (equiv_yoneda S.1 S.2).inv_hom_id } }\n\n\n\n/-- `yoneda'` induces an equivalence of category between `Type u` and\n`Sheaf types_grothendieck_topology`. -/\n@[simps] noncomputable def type_equiv :\n  Type u ≌ SheafOfTypes types_grothendieck_topology :=\nequivalence.mk\n  yoneda'\n  (SheafOfTypes_to_presheaf _ ⋙ (evaluation _ _).obj (op punit))\n  (nat_iso.of_components\n    (λ α, /- α ≅ punit ⟶ α -/\n      { hom := λ x _, x,\n        inv := λ f, f punit.star,\n        hom_inv_id' := funext $ λ x, rfl,\n        inv_hom_id' := funext $ λ f, funext $ λ y, punit.cases_on y rfl })\n    (λ α β f, rfl))\n  (iso.symm $ nat_iso.of_components\n    (λ S, equiv_yoneda' S)\n    (λ S₁ S₂ f, SheafOfTypes.hom.ext _ _ $\n      nat_trans.ext _ _ $ funext $ λ α, funext $ λ s, funext $ λ x,\n      eval_app S₁ S₂ f (unop α) s x))\n\nlemma subcanonical_types_grothendieck_topology :\n  sheaf.subcanonical types_grothendieck_topology.{u} :=\nsheaf.subcanonical.of_yoneda_is_sheaf _ (λ X, is_sheaf_yoneda')\n\nlemma types_grothendieck_topology_eq_canonical :\n  types_grothendieck_topology.{u} = sheaf.canonical_topology (Type u) :=\nle_antisymm subcanonical_types_grothendieck_topology $ Inf_le ⟨yoneda.obj (ulift bool), ⟨_, rfl⟩,\ngrothendieck_topology.ext $ funext $ λ α, set.ext $ λ S,\n⟨λ hs x, classical.by_contradiction $ λ hsx,\n  have (λ _, ulift.up tt : (yoneda.obj (ulift bool)).obj (op punit)) = λ _, ulift.up ff :=\n    (hs punit (λ _, x)).is_separated_for.ext $ λ β f hf, funext $ λ y, hsx.elim $ S.2 hf $ λ _, y,\n  bool.no_confusion $ ulift.up.inj $ (congr_fun this punit.star : _),\nλ hs β f, is_sheaf_yoneda' _ $ λ y, hs _⟩⟩\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/sites/types.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177518, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4905732798440094}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes Hölzl\n\nLinear structures on function with finit support `α →₀ β` and multivariate polynomials.\n-/\nimport data.matrix\nimport linear_algebra.dimension linear_algebra.tensor_product\nnoncomputable theory\n\nlocal attribute [instance, priority 0] classical.prop_decidable\n\nopen lattice set linear_map submodule\n\nnamespace matrix\nuniverses u v\nvariables {l m n o : Type u} [fintype l] [fintype m] [fintype n] [fintype o]\n\ninstance [decidable_eq m] [decidable_eq n] (α) [fintype α] : fintype (matrix m n α) :=\nby unfold matrix; apply_instance\n\nsection ring\nvariables {α : Type v} [comm_ring α]\n\ndef eval : (matrix m n α) →ₗ[α] ((n → α) →ₗ[α] (m → α)) :=\nbegin\n  refine linear_map.mk₂ α mul_vec _ _ _ _,\n  { assume M N v, funext x,\n    change finset.univ.sum (λy:n, (M x y + N x y) * v y) = _,\n    simp only [_root_.add_mul, finset.sum_add_distrib],\n    refl },\n  { assume c M v, funext x,\n    change finset.univ.sum (λy:n, (c * M x y) * v y) = _,\n    simp only [_root_.mul_assoc, finset.mul_sum.symm],\n    refl },\n  { assume M v w, funext x,\n    change finset.univ.sum (λy:n, M x y * (v y + w y)) = _,\n    simp [_root_.mul_add, finset.sum_add_distrib],\n    refl },\n  { assume c M v, funext x,\n    change finset.univ.sum (λy:n, M x y * (c * v y)) = _,\n    rw [show (λy:n, M x y * (c * v y)) = (λy:n, c * (M x y * v y)), { funext n, ac_refl },\n      ← finset.mul_sum],\n    refl }\nend\n\ndef to_lin : matrix m n α → (n → α) →ₗ[α] (m → α) := eval.to_fun\n\nlemma to_lin_add (M N : matrix m n α) : (M + N).to_lin = M.to_lin + N.to_lin :=\nmatrix.eval.map_add M N\n\n@[simp] lemma to_lin_zero : (0 : matrix m n α).to_lin = 0 :=\nmatrix.eval.map_zero\n\ninstance to_lin.is_linear_map :\n  @is_linear_map α (matrix m n α) ((n → α) →ₗ[α] (m → α)) _ _ _ _ _ to_lin :=\nmatrix.eval.is_linear\n\ninstance to_lin.is_add_monoid_hom :\n  @is_add_monoid_hom (matrix m n α) ((n → α) →ₗ[α] (m → α)) _ _ to_lin :=\n{ map_zero := to_lin_zero, map_add := to_lin_add }\n\n@[simp] lemma to_lin_apply (M : matrix m n α) (v : n → α) :\n  (M.to_lin : (n → α) → (m → α)) v = mul_vec M v := rfl\n\nlemma mul_to_lin [decidable_eq l] (M : matrix m n α) (N : matrix n l α) :\n  (M.mul N).to_lin = M.to_lin.comp N.to_lin :=\nbegin\n  ext v x,\n  simp [to_lin_apply, mul_vec, matrix.mul, finset.sum_mul, finset.mul_sum],\n  rw [finset.sum_comm],\n  congr, funext x, congr, funext y,\n  rw [mul_assoc]\nend\n\nsection\nopen linear_map\n\nlemma proj_diagonal [decidable_eq m] (i : m) (w : m → α) :\n  (proj i).comp (to_lin (diagonal w)) = (w i) • proj i :=\nby ext j; simp [mul_vec_diagonal]\n\nlemma diagonal_comp_std_basis [decidable_eq n] (w : n → α) (i : n) :\n  (diagonal w).to_lin.comp (std_basis α (λ_:n, α) i) = (w i) • std_basis α (λ_:n, α) i :=\nbegin\n  ext a j,\n  simp only [linear_map.comp_apply, smul_apply, to_lin_apply, mul_vec_diagonal, smul_apply,\n    pi.smul_apply, smul_eq_mul],\n  by_cases i = j,\n  { subst h },\n  { rw [std_basis_ne α (λ_:n, α) _ _ (ne.symm h), _root_.mul_zero, _root_.mul_zero] }\nend\nend\n\nend ring\n\nsection vector_space\nvariables {α : Type u} [discrete_field α] -- maybe try to relax the universe constraint\n\nopen linear_map\n\nlemma rank_vec_mul_vec [decidable_eq n] (w : m → α) (v : n → α) :\n  rank (vec_mul_vec w v).to_lin ≤ 1 :=\nbegin\n  rw [vec_mul_vec_eq, mul_to_lin],\n  refine le_trans (rank_comp_le1 _ _) _,\n  refine le_trans (rank_le_domain _) _,\n  rw [dim_fun', ← cardinal.fintype_card],\n  exact le_refl _\nend\n\nset_option class.instance_max_depth 100\n\nlemma diagonal_to_lin [decidable_eq m] (w : m → α) :\n  (diagonal w).to_lin = linear_map.pi (λi, w i • linear_map.proj i) :=\nby ext v j; simp [mul_vec_diagonal]\n\nlemma ker_diagonal_to_lin [decidable_eq m] (w : m → α) :\n  ker (diagonal w).to_lin = (⨆i∈{i | w i = 0 }, range (std_basis α (λi, α) i)) :=\nbegin\n  rw [← comap_bot, ← infi_ker_proj],\n  simp only [comap_infi, (ker_comp _ _).symm, proj_diagonal, ker_smul'],\n  have : univ ⊆ {i : m | w i = 0} ∪ -{i : m | w i = 0}, { rw set.union_compl_self },\n  exact (supr_range_std_basis_eq_infi_ker_proj α (λi:m, α)\n    (disjoint_compl {i | w i = 0}) this (finite.of_fintype _)).symm\nend\n\nlemma range_diagonal [decidable_eq m] (w : m → α) :\n  (diagonal w).to_lin.range = (⨆ i ∈ {i | w i ≠ 0}, (std_basis α (λi, α) i).range) :=\nbegin\n  dsimp only [mem_set_of_eq],\n  rw [← map_top, ← supr_range_std_basis, map_supr],\n  congr, funext i,\n  rw [← linear_map.range_comp, diagonal_comp_std_basis, range_smul'],\nend\n\nlocal attribute [instance] classical.prop_decidable\nlemma rank_diagonal [decidable_eq m] [decidable_eq α] (w : m → α) :\n  rank (diagonal w).to_lin = fintype.card { i // w i ≠ 0 } :=\nbegin\n  have hu : univ ⊆ - {i : m | w i = 0} ∪ {i : m | w i = 0}, { rw set.compl_union_self },\n  have hd : disjoint {i : m | w i ≠ 0} {i : m | w i = 0} := (disjoint_compl {i | w i = 0}).symm,\n  have h₁ := supr_range_std_basis_eq_infi_ker_proj α (λi:m, α) hd hu (finite.of_fintype _),\n  have h₂ := infi_ker_proj_equiv α (λi:m, α) hd hu,\n  rw [rank, range_diagonal, h₁, (linear_equiv.dim_eq.{u u} h₂)],\n  exact dim_fun'\nend\n\nend vector_space\n\nend matrix\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/linear_algebra/matrix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4905732775527237}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport algebra.hom.freiman\nimport analysis.asymptotics.asymptotics\nimport analysis.convex.strict_convex_space\n\n/-!\n# Salem-Spencer sets and Roth numbers\n\nThis file defines Salem-Spencer sets and the Roth number of a set.\n\nA Salem-Spencer set is a set without arithmetic progressions of length `3`. Equivalently, the\naverage of any two distinct elements is not in the set.\n\nThe Roth number of a finset is the size of its biggest Salem-Spencer subset. This is a more general\ndefinition than the one often found in mathematical litterature, where the `n`-th Roth number is\nthe size of the biggest Salem-Spencer subset of `{0, ..., n - 1}`.\n\n## Main declarations\n\n* `mul_salem_spencer`: Predicate for a set to be multiplicative Salem-Spencer.\n* `add_salem_spencer`: Predicate for a set to be additive Salem-Spencer.\n* `mul_roth_number`: The multiplicative Roth number of a finset.\n* `add_roth_number`: The additive Roth number of a finset.\n* `roth_number_nat`: The Roth number of a natural. This corresponds to\n  `add_roth_number (finset.range n)`.\n\n## TODO\n\n* Can `add_salem_spencer_iff_eq_right` be made more general?\n* Generalize `mul_salem_spencer.image` to Freiman homs\n\n## Tags\n\nSalem-Spencer, Roth, arithmetic progression, average, three-free\n-/\n\nopen finset function metric nat\nopen_locale pointwise\n\nvariables {F α β 𝕜 E : Type*}\n\nsection salem_spencer\n\nopen set\n\nsection monoid\nvariables [monoid α] [monoid β] (s t : set α)\n\n/-- A multiplicative Salem-Spencer, aka non averaging, set `s` in a monoid is a set such that the\nmultiplicative average of any two distinct elements is not in the set. -/\n@[to_additive \"A Salem-Spencer, aka non averaging, set `s` in an additive monoid\nis a set such that the average of any two distinct elements is not in the set.\"]\ndef mul_salem_spencer : Prop := ∀ ⦃a b c⦄, a ∈ s → b ∈ s → c ∈ s → a * b = c * c → a = b\n\n/-- Whether a given finset is Salem-Spencer is decidable. -/\n@[to_additive \"Whether a given finset is Salem-Spencer is decidable.\"]\ninstance {α : Type*} [decidable_eq α] [monoid α] {s : finset α} :\n  decidable (mul_salem_spencer (s : set α)) :=\ndecidable_of_iff (∀ a ∈ s, ∀ b ∈ s, ∀ c ∈ s, a * b = c * c → a = b)\n  ⟨λ h a b c ha hb hc, h a ha b hb c hc, λ h a ha b hb c hc, h ha hb hc⟩\n\nvariables {s t}\n\n@[to_additive]\nlemma mul_salem_spencer.mono (h : t ⊆ s) (hs : mul_salem_spencer s) : mul_salem_spencer t :=\nλ a b c ha hb hc, hs (h ha) (h hb) (h hc)\n\n@[simp, to_additive]\nlemma mul_salem_spencer_empty : mul_salem_spencer (∅ : set α) := λ a _ _ ha, ha.elim\n\n@[to_additive]\nlemma set.subsingleton.mul_salem_spencer (hs : s.subsingleton) : mul_salem_spencer s :=\nλ a b _ ha hb _ _, hs ha hb\n\n@[simp, to_additive]\nlemma mul_salem_spencer_singleton (a : α) : mul_salem_spencer ({a} : set α) :=\nsubsingleton_singleton.mul_salem_spencer\n\n@[to_additive add_salem_spencer.prod]\nlemma mul_salem_spencer.prod {t : set β} (hs : mul_salem_spencer s) (ht : mul_salem_spencer t) :\n  mul_salem_spencer (s ×ˢ t) :=\nλ a b c ha hb hc h,\n  prod.ext (hs ha.1 hb.1 hc.1 (prod.ext_iff.1 h).1) (ht ha.2 hb.2 hc.2 (prod.ext_iff.1 h).2)\n\n@[to_additive]\nlemma mul_salem_spencer_pi {ι : Type*} {α : ι → Type*} [Π i, monoid (α i)] {s : Π i, set (α i)}\n  (hs : ∀ i, mul_salem_spencer (s i)) :\n  mul_salem_spencer ((univ : set ι).pi s) :=\nλ a b c ha hb hc h, funext $ λ i, hs i (ha i trivial) (hb i trivial) (hc i trivial) $ congr_fun h i\n\nend monoid\n\nsection comm_monoid\nvariables [comm_monoid α] [comm_monoid β] {s : set α} {a : α}\n\n@[to_additive]\nlemma mul_salem_spencer.of_image [fun_like F α (λ _, β)] [freiman_hom_class F s β 2] (f : F)\n  (hf : s.inj_on f) (h : mul_salem_spencer (f '' s)) :\n  mul_salem_spencer s :=\nλ a b c ha hb hc habc, hf ha hb $ h (mem_image_of_mem _ ha) (mem_image_of_mem _ hb)\n  (mem_image_of_mem _ hc) $ map_mul_map_eq_map_mul_map f ha hb hc hc habc\n\n-- TODO: Generalize to Freiman homs\n@[to_additive]\nlemma mul_salem_spencer.image [mul_hom_class F α β] (f : F) (hf : (s * s).inj_on f)\n  (h : mul_salem_spencer s) :\n  mul_salem_spencer (f '' s) :=\nbegin\n  rintro _ _ _ ⟨a, ha, rfl⟩ ⟨b, hb, rfl⟩ ⟨c, hc, rfl⟩ habc,\n  rw h ha hb hc (hf (mul_mem_mul ha hb) (mul_mem_mul hc hc) $ by rwa [map_mul, map_mul]),\nend\n\nend comm_monoid\n\nsection cancel_comm_monoid\nvariables [cancel_comm_monoid α] {s : set α} {a : α}\n\n@[to_additive]\nlemma mul_salem_spencer_insert :\n  mul_salem_spencer (insert a s) ↔ mul_salem_spencer s ∧\n    (∀ ⦃b c⦄, b ∈ s → c ∈ s → a * b = c * c → a = b) ∧\n    ∀ ⦃b c⦄, b ∈ s → c ∈ s → b * c = a * a → b = c :=\nbegin\n  refine ⟨λ hs, ⟨hs.mono (subset_insert _ _),\n    λ b c hb hc, hs (or.inl rfl) (or.inr hb) (or.inr hc),\n    λ b c hb hc, hs (or.inr hb) (or.inr hc) (or.inl rfl)⟩, _⟩,\n  rintro ⟨hs, ha, ha'⟩ b c d hb hc hd h,\n  rw mem_insert_iff at hb hc hd,\n  obtain rfl | hb := hb;\n  obtain rfl | hc := hc,\n  { refl },\n  all_goals { obtain rfl | hd := hd },\n  { exact (mul_left_cancel h).symm },\n  { exact ha hc hd h },\n  { exact mul_right_cancel h },\n  { exact (ha hb hd $ (mul_comm _ _).trans h).symm },\n  { exact ha' hb hc h },\n  { exact hs hb hc hd h }\nend\n\n@[simp, to_additive]\nlemma mul_salem_spencer_pair (a b : α) : mul_salem_spencer ({a, b} : set α) :=\nbegin\n  rw mul_salem_spencer_insert,\n  refine ⟨mul_salem_spencer_singleton _, _, _⟩,\n  { rintro c d (rfl : c = b) (rfl : d = c),\n    exact mul_right_cancel },\n  { rintro c d (rfl : c = b) (rfl : d = c) _,\n    refl }\nend\n\n@[to_additive]\nlemma mul_salem_spencer.mul_left (hs : mul_salem_spencer s) : mul_salem_spencer ((*) a '' s) :=\nbegin\n  rintro _ _ _ ⟨b, hb, rfl⟩ ⟨c, hc, rfl⟩ ⟨d, hd, rfl⟩ h,\n  rw [mul_mul_mul_comm, mul_mul_mul_comm a d] at h,\n  rw hs hb hc hd (mul_left_cancel h),\nend\n\n@[to_additive]\nlemma mul_salem_spencer.mul_right (hs : mul_salem_spencer s) : mul_salem_spencer ((* a) '' s) :=\nbegin\n  rintro _ _ _ ⟨b, hb, rfl⟩ ⟨c, hc, rfl⟩ ⟨d, hd, rfl⟩ h,\n  rw [mul_mul_mul_comm, mul_mul_mul_comm d] at h,\n  rw hs hb hc hd (mul_right_cancel h),\nend\n\n@[to_additive]\nlemma mul_salem_spencer_mul_left_iff : mul_salem_spencer ((*) a '' s) ↔ mul_salem_spencer s :=\n⟨λ hs b c d hb hc hd h, mul_left_cancel (hs (mem_image_of_mem _ hb) (mem_image_of_mem _ hc)\n  (mem_image_of_mem _ hd) $ by rw [mul_mul_mul_comm, h, mul_mul_mul_comm]),\n  mul_salem_spencer.mul_left⟩\n\n@[to_additive]\nlemma mul_salem_spencer_mul_right_iff :\n  mul_salem_spencer ((* a) '' s) ↔ mul_salem_spencer s :=\n⟨λ hs b c d hb hc hd h, mul_right_cancel (hs (set.mem_image_of_mem _ hb) (set.mem_image_of_mem _ hc)\n  (set.mem_image_of_mem _ hd) $ by rw [mul_mul_mul_comm, h, mul_mul_mul_comm]),\n  mul_salem_spencer.mul_right⟩\n\nend cancel_comm_monoid\n\nsection ordered_cancel_comm_monoid\nvariables [ordered_cancel_comm_monoid α] {s : set α} {a : α}\n\n@[to_additive]\nlemma mul_salem_spencer_insert_of_lt (hs : ∀ i ∈ s, i < a) :\n  mul_salem_spencer (insert a s) ↔ mul_salem_spencer s ∧\n    ∀ ⦃b c⦄, b ∈ s → c ∈ s → a * b = c * c → a = b :=\nbegin\n  refine mul_salem_spencer_insert.trans _,\n  rw ←and_assoc,\n  exact and_iff_left (λ b c hb hc h, ((mul_lt_mul_of_lt_of_lt (hs _ hb) (hs _ hc)).ne h).elim),\nend\n\nend ordered_cancel_comm_monoid\n\nsection cancel_comm_monoid_with_zero\nvariables [cancel_comm_monoid_with_zero α] [no_zero_divisors α] {s : set α} {a : α}\n\nlemma mul_salem_spencer.mul_left₀ (hs : mul_salem_spencer s) (ha : a ≠ 0) :\n  mul_salem_spencer ((*) a '' s) :=\nbegin\n  rintro _ _ _ ⟨b, hb, rfl⟩ ⟨c, hc, rfl⟩ ⟨d, hd, rfl⟩ h,\n  rw [mul_mul_mul_comm, mul_mul_mul_comm a d] at h,\n  rw hs hb hc hd (mul_left_cancel₀ (mul_ne_zero ha ha) h),\nend\n\nlemma mul_salem_spencer.mul_right₀ (hs : mul_salem_spencer s) (ha : a ≠ 0) :\n  mul_salem_spencer ((* a) '' s) :=\nbegin\n  rintro _ _ _ ⟨b, hb, rfl⟩ ⟨c, hc, rfl⟩ ⟨d, hd, rfl⟩ h,\n  rw [mul_mul_mul_comm, mul_mul_mul_comm d] at h,\n  rw hs hb hc hd (mul_right_cancel₀ (mul_ne_zero ha ha) h),\nend\n\nlemma mul_salem_spencer_mul_left_iff₀ (ha : a ≠ 0) :\n  mul_salem_spencer ((*) a '' s) ↔ mul_salem_spencer s :=\n⟨λ hs b c d hb hc hd h, mul_left_cancel₀ ha\n  (hs (set.mem_image_of_mem _ hb) (set.mem_image_of_mem _ hc) (set.mem_image_of_mem _ hd) $\n  by rw [mul_mul_mul_comm, h, mul_mul_mul_comm]),\n  λ hs, hs.mul_left₀ ha⟩\n\nlemma mul_salem_spencer_mul_right_iff₀ (ha : a ≠ 0) :\n  mul_salem_spencer ((* a) '' s) ↔ mul_salem_spencer s :=\n⟨λ hs b c d hb hc hd h, mul_right_cancel₀ ha\n  (hs (set.mem_image_of_mem _ hb) (set.mem_image_of_mem _ hc) (set.mem_image_of_mem _ hd) $\n  by rw [mul_mul_mul_comm, h, mul_mul_mul_comm]),\n  λ hs, hs.mul_right₀ ha⟩\n\nend cancel_comm_monoid_with_zero\n\nsection nat\n\nlemma add_salem_spencer_iff_eq_right {s : set ℕ} :\n  add_salem_spencer s ↔ ∀ ⦃a b c⦄, a ∈ s → b ∈ s → c ∈ s → a + b = c + c → a = c :=\nbegin\n  refine forall₄_congr (λ a b c _, forall₃_congr $ λ _ _ habc, ⟨_, _⟩),\n  { rintro rfl,\n    simp_rw ←two_mul at habc,\n    exact mul_left_cancel₀ two_ne_zero habc },\n  { rintro rfl,\n    exact (add_left_cancel habc).symm }\nend\n\nend nat\n\n/-- The frontier of a closed strictly convex set only contains trivial arithmetic progressions.\nThe idea is that an arithmetic progression is contained on a line and the frontier of a strictly\nconvex set does not contain lines. -/\nlemma add_salem_spencer_frontier [linear_ordered_field 𝕜] [topological_space E] [add_comm_monoid E]\n  [module 𝕜 E] {s : set E} (hs₀ : is_closed s) (hs₁ : strict_convex 𝕜 s) :\n  add_salem_spencer (frontier s) :=\nbegin\n  intros a b c ha hb hc habc,\n  obtain rfl : (1 / 2 : 𝕜) • a + (1 / 2 : 𝕜) • b = c,\n  { rwa [←smul_add, one_div, inv_smul_eq_iff₀ (show (2 : 𝕜) ≠ 0, by norm_num), two_smul] },\n  exact hs₁.eq (hs₀.frontier_subset ha) (hs₀.frontier_subset hb) one_half_pos one_half_pos\n    (add_halves _) hc.2,\nend\n\nlemma add_salem_spencer_sphere [normed_add_comm_group E] [normed_space ℝ E]\n  [strict_convex_space ℝ E] (x : E) (r : ℝ) : add_salem_spencer (sphere x r) :=\nbegin\n  obtain rfl | hr := eq_or_ne r 0,\n  { rw sphere_zero,\n    exact add_salem_spencer_singleton _ },\n  { convert add_salem_spencer_frontier is_closed_ball (strict_convex_closed_ball ℝ x r),\n    exact (frontier_closed_ball _ hr).symm }\nend\n\nend salem_spencer\n\nopen finset\n\nsection roth_number\nvariables [decidable_eq α]\n\nsection monoid\nvariables [monoid α] [decidable_eq β] [monoid β] (s t : finset α)\n\n/-- The multiplicative Roth number of a finset is the cardinality of its biggest multiplicative\nSalem-Spencer subset. -/\n@[to_additive \"The additive Roth number of a finset is the cardinality of its biggest additive\nSalem-Spencer subset. The usual Roth number corresponds to `add_roth_number (finset.range n)`, see\n`roth_number_nat`. \"]\ndef mul_roth_number : finset α →o ℕ :=\n⟨λ s, nat.find_greatest (λ m, ∃ t ⊆ s, t.card = m ∧ mul_salem_spencer (t : set α)) s.card,\nbegin\n  rintro t u htu,\n  refine nat.find_greatest_mono (λ m, _) (card_le_of_subset htu),\n  rintro ⟨v, hvt, hv⟩,\n  exact ⟨v, hvt.trans htu, hv⟩,\nend⟩\n\n@[to_additive]\nlemma mul_roth_number_le : mul_roth_number s ≤ s.card := by convert nat.find_greatest_le s.card\n\n@[to_additive]\nlemma mul_roth_number_spec : ∃ t ⊆ s, t.card = mul_roth_number s ∧ mul_salem_spencer (t : set α) :=\n@nat.find_greatest_spec _ _ (λ m, ∃ t ⊆ s, t.card = m ∧ mul_salem_spencer (t : set α)) _\n  (nat.zero_le _) ⟨∅, empty_subset _, card_empty, mul_salem_spencer_empty⟩\n\nvariables {s t} {n : ℕ}\n\n@[to_additive]\nlemma mul_salem_spencer.le_mul_roth_number (hs : mul_salem_spencer (s : set α)) (h : s ⊆ t) :\n  s.card ≤ mul_roth_number t :=\nle_find_greatest (card_le_of_subset h) ⟨s, h, rfl, hs⟩\n\n@[to_additive]\nlemma mul_salem_spencer.roth_number_eq (hs : mul_salem_spencer (s : set α)) :\n  mul_roth_number s = s.card :=\n(mul_roth_number_le _).antisymm $ hs.le_mul_roth_number $ subset.refl _\n\n@[simp, to_additive]\nlemma mul_roth_number_empty : mul_roth_number (∅ : finset α) = 0 :=\nnat.eq_zero_of_le_zero $ (mul_roth_number_le _).trans card_empty.le\n\n@[simp, to_additive]\nlemma mul_roth_number_singleton (a : α) : mul_roth_number ({a} : finset α) = 1 :=\nbegin\n  convert mul_salem_spencer.roth_number_eq _,\n  rw coe_singleton,\n  exact mul_salem_spencer_singleton a,\nend\n\n@[to_additive]\nlemma mul_roth_number_union_le (s t : finset α) :\n  mul_roth_number (s ∪ t) ≤ mul_roth_number s + mul_roth_number t :=\nlet ⟨u, hus, hcard, hu⟩ := mul_roth_number_spec (s ∪ t) in\ncalc\n  mul_roth_number (s ∪ t)\n      = u.card : hcard.symm\n  ... = (u ∩ s ∪ u ∩ t).card\n      : by rw [←inter_distrib_left, (inter_eq_left_iff_subset _ _).2 hus]\n  ... ≤ (u ∩ s).card + (u ∩ t).card : card_union_le _ _\n  ... ≤ mul_roth_number s + mul_roth_number t\n      : add_le_add ((hu.mono $ inter_subset_left _ _).le_mul_roth_number $ inter_subset_right _ _)\n          ((hu.mono $ inter_subset_left _ _).le_mul_roth_number $ inter_subset_right _ _)\n\n@[to_additive]\nlemma le_mul_roth_number_product (s : finset α) (t : finset β) :\n  mul_roth_number s * mul_roth_number t ≤ mul_roth_number (s ×ˢ t) :=\nbegin\n  obtain ⟨u, hus, hucard, hu⟩ := mul_roth_number_spec s,\n  obtain ⟨v, hvt, hvcard, hv⟩ := mul_roth_number_spec t,\n  rw [←hucard, ←hvcard, ←card_product],\n  refine mul_salem_spencer.le_mul_roth_number _ (product_subset_product hus hvt),\n  rw coe_product,\n  exact hu.prod hv,\nend\n\n@[to_additive]\nlemma mul_roth_number_lt_of_forall_not_mul_salem_spencer\n  (h : ∀ t ∈ powerset_len n s, ¬mul_salem_spencer ((t : finset α) : set α)) :\n  mul_roth_number s < n :=\nbegin\n  obtain ⟨t, hts, hcard, ht⟩ := mul_roth_number_spec s,\n  rw [←hcard, ←not_le],\n  intro hn,\n  obtain ⟨u, hut, rfl⟩ := exists_smaller_set t n hn,\n  exact h _ (mem_powerset_len.2 ⟨hut.trans hts, rfl⟩) (ht.mono hut),\nend\n\nend monoid\n\nsection cancel_comm_monoid\nvariables [cancel_comm_monoid α] (s : finset α) (a : α)\n\n@[simp, to_additive] lemma mul_roth_number_map_mul_left :\n  mul_roth_number (s.map $ mul_left_embedding a) = mul_roth_number s :=\nbegin\n  refine le_antisymm _ _,\n  { obtain ⟨u, hus, hcard, hu⟩ := mul_roth_number_spec (s.map $ mul_left_embedding a),\n    rw subset_map_iff at hus,\n    obtain ⟨u, hus, rfl⟩ := hus,\n    rw coe_map at hu,\n    rw [←hcard, card_map],\n    exact (mul_salem_spencer_mul_left_iff.1 hu).le_mul_roth_number hus },\n  { obtain ⟨u, hus, hcard, hu⟩ := mul_roth_number_spec s,\n    have h : mul_salem_spencer (u.map $ mul_left_embedding a : set α),\n    { rw coe_map,\n      exact hu.mul_left },\n    convert h.le_mul_roth_number (map_subset_map.2 hus),\n    rw [card_map, hcard] }\nend\n\n@[simp, to_additive] lemma mul_roth_number_map_mul_right :\n  mul_roth_number (s.map $ mul_right_embedding a) = mul_roth_number s :=\nby rw [←mul_left_embedding_eq_mul_right_embedding, mul_roth_number_map_mul_left s a]\n\nend cancel_comm_monoid\nend roth_number\n\nsection roth_number_nat\nvariables {s : finset ℕ} {k n : ℕ}\n\n/-- The Roth number of a natural `N` is the largest integer `m` for which there is a subset of\n`range N` of size `m` with no arithmetic progression of length 3.\nTrivially, `roth_number_nat N ≤ N`, but Roth's theorem (proved in 1953) shows that\n`roth_number_nat N = o(N)` and the construction by Behrend gives a lower bound of the form\n`N * exp(-C sqrt(log(N))) ≤ roth_number_nat N`.\nA significant refinement of Roth's theorem by Bloom and Sisask announced in 2020 gives\n`roth_number_nat N = O(N / (log N)^(1+c))` for an absolute constant `c`. -/\ndef roth_number_nat : ℕ →o ℕ :=\n⟨λ n, add_roth_number (range n), add_roth_number.mono.comp range_mono⟩\n\nlemma roth_number_nat_def (n : ℕ) : roth_number_nat n = add_roth_number (range n) := rfl\n\nlemma roth_number_nat_le (N : ℕ) : roth_number_nat N ≤ N :=\n(add_roth_number_le _).trans (card_range _).le\n\nlemma roth_number_nat_spec (n : ℕ) :\n  ∃ t ⊆ range n, t.card = roth_number_nat n ∧ add_salem_spencer (t : set ℕ) :=\nadd_roth_number_spec _\n\n/-- A verbose specialization of `add_salem_spencer.le_add_roth_number`, sometimes convenient in\npractice. -/\nlemma add_salem_spencer.le_roth_number_nat (s : finset ℕ) (hs : add_salem_spencer (s : set ℕ))\n  (hsn : ∀ x ∈ s, x < n) (hsk : s.card = k) :\n  k ≤ roth_number_nat n :=\nhsk.ge.trans $ hs.le_add_roth_number $ λ x hx, mem_range.2 $ hsn x hx\n\n/-- The Roth number is a subadditive function. Note that by Fekete's lemma this shows that\nthe limit `roth_number_nat N / N` exists, but Roth's theorem gives the stronger result that this\nlimit is actually `0`. -/\nlemma roth_number_nat_add_le (M N : ℕ) :\n  roth_number_nat (M + N) ≤ roth_number_nat M + roth_number_nat N :=\nbegin\n  simp_rw roth_number_nat_def,\n  rw [range_add_eq_union, ←add_roth_number_map_add_left (range N) M],\n  exact add_roth_number_union_le _ _,\nend\n\n@[simp] lemma roth_number_nat_zero : roth_number_nat 0 = 0 := rfl\n\nlemma add_roth_number_Ico (a b : ℕ) : add_roth_number (Ico a b) = roth_number_nat (b - a) :=\nbegin\n  obtain h | h := le_total b a,\n  { rw [tsub_eq_zero_of_le h, Ico_eq_empty_of_le h, roth_number_nat_zero, add_roth_number_empty] },\n  convert add_roth_number_map_add_left _ a,\n  rw [range_eq_Ico, map_eq_image],\n  convert (image_add_left_Ico 0 (b - a) _).symm,\n  exact (add_tsub_cancel_of_le h).symm,\nend\n\nopen asymptotics filter\n\nlemma roth_number_nat_is_O_with_id :\n  is_O_with 1 at_top (λ N, (roth_number_nat N : ℝ)) (λ N, (N : ℝ)) :=\nis_O_with_of_le _ $ by simpa only [real.norm_coe_nat, nat.cast_le] using roth_number_nat_le\n\n/-- The Roth number has the trivial bound `roth_number_nat N = O(N)`. -/\nlemma roth_number_nat_is_O_id : (λ N, (roth_number_nat N : ℝ)) =O[at_top] (λ N, (N : ℝ)) :=\nroth_number_nat_is_O_with_id.is_O\n\nend roth_number_nat\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/combinatorics/additive/salem_spencer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132314, "lm_q2_score": 0.7490872131147276, "lm_q1q2_score": 0.4905732775527236}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Kenny Lau, Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.list.pairwise\nimport Mathlib.logic.relation\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\nnamespace list\n\n\n/- chain relation (conjunction of R a b ∧ R b c ∧ R c d ...) -/\n\ntheorem chain_iff {α : Type u} (R : α → α → Prop) :\n    ∀ (ᾰ : α) (ᾰ_1 : List α),\n        chain R ᾰ ᾰ_1 ↔\n          ᾰ_1 = [] ∨\n            Exists fun {b : α} => Exists fun {l : List α} => R ᾰ b ∧ chain R b l ∧ ᾰ_1 = b :: l :=\n  sorry\n\ntheorem rel_of_chain_cons {α : Type u} {R : α → α → Prop} {a : α} {b : α} {l : List α}\n    (p : chain R a (b :: l)) : R a b :=\n  and.left (iff.mp chain_cons p)\n\ntheorem chain_of_chain_cons {α : Type u} {R : α → α → Prop} {a : α} {b : α} {l : List α}\n    (p : chain R a (b :: l)) : chain R b l :=\n  and.right (iff.mp chain_cons p)\n\ntheorem chain.imp' {α : Type u} {R : α → α → Prop} {S : α → α → Prop}\n    (HRS : ∀ {a b : α}, R a b → S a b) {a : α} {b : α} (Hab : ∀ {c : α}, R a c → S b c) {l : List α}\n    (p : chain R a l) : chain S b l :=\n  sorry\n\ntheorem chain.imp {α : Type u} {R : α → α → Prop} {S : α → α → Prop}\n    (H : ∀ (a b : α), R a b → S a b) {a : α} {l : List α} (p : chain R a l) : chain S a l :=\n  chain.imp' H (H a) p\n\ntheorem chain.iff {α : Type u} {R : α → α → Prop} {S : α → α → Prop}\n    (H : ∀ (a b : α), R a b ↔ S a b) {a : α} {l : List α} : chain R a l ↔ chain S a l :=\n  { mp := chain.imp fun (a b : α) => iff.mp (H a b),\n    mpr := chain.imp fun (a b : α) => iff.mpr (H a b) }\n\ntheorem chain.iff_mem {α : Type u} {R : α → α → Prop} {a : α} {l : List α} :\n    chain R a l ↔ chain (fun (x y : α) => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l :=\n  sorry\n\ntheorem chain_singleton {α : Type u} {R : α → α → Prop} {a : α} {b : α} : chain R a [b] ↔ R a b :=\n  sorry\n\ntheorem chain_split {α : Type u} {R : α → α → Prop} {a : α} {b : α} {l₁ : List α} {l₂ : List α} :\n    chain R a (l₁ ++ b :: l₂) ↔ chain R a (l₁ ++ [b]) ∧ chain R b l₂ :=\n  sorry\n\ntheorem chain_map {α : Type u} {β : Type v} {R : α → α → Prop} (f : β → α) {b : β} {l : List β} :\n    chain R (f b) (map f l) ↔ chain (fun (a b : β) => R (f a) (f b)) b l :=\n  sorry\n\ntheorem chain_of_chain_map {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    (f : α → β) (H : ∀ (a b : α), S (f a) (f b) → R a b) {a : α} {l : List α}\n    (p : chain S (f a) (map f l)) : chain R a l :=\n  chain.imp H (iff.mp (chain_map f) p)\n\ntheorem chain_map_of_chain {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    (f : α → β) (H : ∀ (a b : α), R a b → S (f a) (f b)) {a : α} {l : List α} (p : chain R a l) :\n    chain S (f a) (map f l) :=\n  iff.mpr (chain_map f) (chain.imp H p)\n\ntheorem chain_pmap_of_chain {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    {p : α → Prop} {f : (a : α) → p a → β}\n    (H : ∀ (a b : α) (ha : p a) (hb : p b), R a b → S (f a ha) (f b hb)) {a : α} {l : List α}\n    (hl₁ : chain R a l) (ha : p a) (hl₂ : ∀ (a : α), a ∈ l → p a) :\n    chain S (f a ha) (pmap f l hl₂) :=\n  sorry\n\ntheorem chain_of_chain_pmap {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    {p : α → Prop} (f : (a : α) → p a → β) {l : List α} (hl₁ : ∀ (a : α), a ∈ l → p a) {a : α}\n    (ha : p a) (hl₂ : chain S (f a ha) (pmap f l hl₁))\n    (H : ∀ (a b : α) (ha : p a) (hb : p b), S (f a ha) (f b hb) → R a b) : chain R a l :=\n  sorry\n\ntheorem chain_of_pairwise {α : Type u} {R : α → α → Prop} {a : α} {l : List α}\n    (p : pairwise R (a :: l)) : chain R a l :=\n  sorry\n\ntheorem chain_iff_pairwise {α : Type u} {R : α → α → Prop} (tr : transitive R) {a : α}\n    {l : List α} : chain R a l ↔ pairwise R (a :: l) :=\n  sorry\n\ntheorem chain_iff_nth_le {α : Type u} {R : α → α → Prop} {a : α} {l : List α} :\n    chain R a l ↔\n        (∀ (h : 0 < length l), R a (nth_le l 0 h)) ∧\n          ∀ (i : ℕ) (h : i < length l - 1),\n            R (nth_le l i (nat.lt_of_lt_pred h)) (nth_le l (i + 1) (iff.mp nat.lt_pred_iff h)) :=\n  sorry\n\ntheorem chain'.imp {α : Type u} {R : α → α → Prop} {S : α → α → Prop}\n    (H : ∀ (a b : α), R a b → S a b) {l : List α} (p : chain' R l) : chain' S l :=\n  list.cases_on l (fun (p : chain' R []) => trivial)\n    (fun (l_hd : α) (l_tl : List α) (p : chain' R (l_hd :: l_tl)) => chain.imp H p) p\n\ntheorem chain'.iff {α : Type u} {R : α → α → Prop} {S : α → α → Prop}\n    (H : ∀ (a b : α), R a b ↔ S a b) {l : List α} : chain' R l ↔ chain' S l :=\n  { mp := chain'.imp fun (a b : α) => iff.mp (H a b),\n    mpr := chain'.imp fun (a b : α) => iff.mpr (H a b) }\n\ntheorem chain'.iff_mem {α : Type u} {R : α → α → Prop} {l : List α} :\n    chain' R l ↔ chain' (fun (x y : α) => x ∈ l ∧ y ∈ l ∧ R x y) l :=\n  sorry\n\n@[simp] theorem chain'_nil {α : Type u} {R : α → α → Prop} : chain' R [] := trivial\n\n@[simp] theorem chain'_singleton {α : Type u} {R : α → α → Prop} (a : α) : chain' R [a] := chain.nil\n\ntheorem chain'_split {α : Type u} {R : α → α → Prop} {a : α} {l₁ : List α} {l₂ : List α} :\n    chain' R (l₁ ++ a :: l₂) ↔ chain' R (l₁ ++ [a]) ∧ chain' R (a :: l₂) :=\n  sorry\n\ntheorem chain'_map {α : Type u} {β : Type v} {R : α → α → Prop} (f : β → α) {l : List β} :\n    chain' R (map f l) ↔ chain' (fun (a b : β) => R (f a) (f b)) l :=\n  list.cases_on l (iff.refl (chain' R (map f []))) fun (l_hd : β) (l_tl : List β) => chain_map f\n\ntheorem chain'_of_chain'_map {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    (f : α → β) (H : ∀ (a b : α), S (f a) (f b) → R a b) {l : List α} (p : chain' S (map f l)) :\n    chain' R l :=\n  chain'.imp H (iff.mp (chain'_map f) p)\n\ntheorem chain'_map_of_chain' {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    (f : α → β) (H : ∀ (a b : α), R a b → S (f a) (f b)) {l : List α} (p : chain' R l) :\n    chain' S (map f l) :=\n  iff.mpr (chain'_map f) (chain'.imp H p)\n\ntheorem pairwise.chain' {α : Type u} {R : α → α → Prop} {l : List α} : pairwise R l → chain' R l :=\n  sorry\n\ntheorem chain'_iff_pairwise {α : Type u} {R : α → α → Prop} (tr : transitive R) {l : List α} :\n    chain' R l ↔ pairwise R l :=\n  list.cases_on l (idRhs (True ↔ pairwise R []) (iff.symm (iff_true_intro pairwise.nil)))\n    fun (l_hd : α) (l_tl : List α) =>\n      idRhs (chain R l_hd l_tl ↔ pairwise R (l_hd :: l_tl)) (chain_iff_pairwise tr)\n\n@[simp] theorem chain'_cons {α : Type u} {R : α → α → Prop} {x : α} {y : α} {l : List α} :\n    chain' R (x :: y :: l) ↔ R x y ∧ chain' R (y :: l) :=\n  chain_cons\n\ntheorem chain'.cons {α : Type u} {R : α → α → Prop} {x : α} {y : α} {l : List α} (h₁ : R x y)\n    (h₂ : chain' R (y :: l)) : chain' R (x :: y :: l) :=\n  iff.mpr chain'_cons { left := h₁, right := h₂ }\n\ntheorem chain'.tail {α : Type u} {R : α → α → Prop} {l : List α} (h : chain' R l) :\n    chain' R (tail l) :=\n  sorry\n\ntheorem chain'.rel_head {α : Type u} {R : α → α → Prop} {x : α} {y : α} {l : List α}\n    (h : chain' R (x :: y :: l)) : R x y :=\n  rel_of_chain_cons h\n\ntheorem chain'.rel_head' {α : Type u} {R : α → α → Prop} {x : α} {l : List α}\n    (h : chain' R (x :: l)) {y : α} (hy : y ∈ head' l) : R x y :=\n  chain'.rel_head\n    (eq.mp (Eq._oldrec (Eq.refl (chain' R (x :: l))) (Eq.symm (cons_head'_tail hy))) h)\n\ntheorem chain'.cons' {α : Type u} {R : α → α → Prop} {x : α} {l : List α} :\n    chain' R l → (∀ (y : α), y ∈ head' l → R x y) → chain' R (x :: l) :=\n  sorry\n\ntheorem chain'_cons' {α : Type u} {R : α → α → Prop} {x : α} {l : List α} :\n    chain' R (x :: l) ↔ (∀ (y : α), y ∈ head' l → R x y) ∧ chain' R l :=\n  sorry\n\ntheorem chain'.append {α : Type u} {R : α → α → Prop} {l₁ : List α} {l₂ : List α} (h₁ : chain' R l₁)\n    (h₂ : chain' R l₂) (h : ∀ (x : α), x ∈ last' l₁ → ∀ (y : α), y ∈ head' l₂ → R x y) :\n    chain' R (l₁ ++ l₂) :=\n  sorry\n\ntheorem chain'_pair {α : Type u} {R : α → α → Prop} {x : α} {y : α} : chain' R [x, y] ↔ R x y :=\n  sorry\n\ntheorem chain'.imp_head {α : Type u} {R : α → α → Prop} {x : α} {y : α}\n    (h : ∀ {z : α}, R x z → R y z) {l : List α} (hl : chain' R (x :: l)) : chain' R (y :: l) :=\n  chain'.cons' (chain'.tail hl)\n    fun (z : α) (hz : z ∈ head' (tail (x :: l))) => h (chain'.rel_head' hl hz)\n\ntheorem chain'_reverse {α : Type u} {R : α → α → Prop} {l : List α} :\n    chain' R (reverse l) ↔ chain' (flip R) l :=\n  sorry\n\ntheorem chain'_iff_nth_le {α : Type u} {R : α → α → Prop} {l : List α} :\n    chain' R l ↔\n        ∀ (i : ℕ) (h : i < length l - 1),\n          R (nth_le l i (nat.lt_of_lt_pred h)) (nth_le l (i + 1) (iff.mp nat.lt_pred_iff h)) :=\n  sorry\n\n/-- If `l₁ l₂` and `l₃` are lists and `l₁ ++ l₂` and `l₂ ++ l₃` both satisfy\n  `chain' R`, then so does `l₁ ++ l₂ ++ l₃` provided `l₂ ≠ []` -/\ntheorem chain'.append_overlap {α : Type u} {R : α → α → Prop} {l₁ : List α} {l₂ : List α}\n    {l₃ : List α} (h₁ : chain' R (l₁ ++ l₂)) (h₂ : chain' R (l₂ ++ l₃)) (hn : l₂ ≠ []) :\n    chain' R (l₁ ++ l₂ ++ l₃) :=\n  sorry\n\n/--\nIf `a` and `b` are related by the reflexive transitive closure of `r`, then there is a `r`-chain\nstarting from `a` and ending on `b`.\nThe converse of `relation_refl_trans_gen_of_exists_chain`.\n-/\ntheorem exists_chain_of_relation_refl_trans_gen {α : Type u} {r : α → α → Prop} {a : α} {b : α}\n    (h : relation.refl_trans_gen r a b) :\n    ∃ (l : List α), chain r a l ∧ last (a :: l) (cons_ne_nil a l) = b :=\n  sorry\n\n/--\nGiven a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then\nthe predicate is true everywhere in the chain and at `a`.\nThat is, we can propagate the predicate up the chain.\n-/\ntheorem chain.induction {α : Type u} {r : α → α → Prop} {a : α} {b : α} (p : α → Prop) (l : List α)\n    (h : chain r a l) (hb : last (a :: l) (cons_ne_nil a l) = b)\n    (carries : ∀ {x y : α}, r x y → p y → p x) (final : p b) (i : α) (H : i ∈ a :: l) : p i :=\n  sorry\n\n/--\nGiven a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then\nthe predicate is true at `a`.\nThat is, we can propagate the predicate all the way up the chain.\n-/\ntheorem chain.induction_head {α : Type u} {r : α → α → Prop} {a : α} {b : α} (p : α → Prop)\n    (l : List α) (h : chain r a l) (hb : last (a :: l) (cons_ne_nil a l) = b)\n    (carries : ∀ {x y : α}, r x y → p y → p x) (final : p b) : p a :=\n  chain.induction p l h hb carries final a (mem_cons_self a l)\n\n/--\nIf there is an `r`-chain starting from `a` and ending at `b`, then `a` and `b` are related by the\nreflexive transitive closure of `r`. The converse of `exists_chain_of_relation_refl_trans_gen`.\n-/\ntheorem relation_refl_trans_gen_of_exists_chain {α : Type u} {r : α → α → Prop} {a : α} {b : α}\n    (l : List α) (hl₁ : chain r a l) (hl₂ : last (a :: l) (cons_ne_nil a l) = b) :\n    relation.refl_trans_gen r a b :=\n  chain.induction_head (fun (_x : α) => relation.refl_trans_gen r _x b) l hl₁ hl₂\n    (fun (x y : α) => relation.refl_trans_gen.head) relation.refl_trans_gen.refl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/list/chain_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.49057326746169194}}
{"text": "import .global\nuniverses  u\n\nlocal notation `Ring` := CommRing.{u}\nlocal notation `Set` :=  Type u  \n\nnamespace Spec\nvariables (R : Ring)\n\ndef Spec   : Ring  ⥤ Set  := \n{\n  obj :=  λ A : Ring ,   R ⟶  A,\n  map :=  λ A B : Ring, λ ψ : A ⟶ B, λ ζ :  R ⟶ A,  ζ ≫ ψ,  \n}\nlemma Spec.obj.ext (A : Ring) : (Spec R).obj A = (R ⟶ A) := rfl\nlemma Spec.map.ext (A B : Ring)(ψ : A ⟶ B) (ζ : R ⟶ A): (Spec R).map ψ ζ =  ring_hom.comp ψ  ζ  := rfl \n\nend Spec", "meta": {"author": "Or7ando", "repo": "lean", "sha": "d41169cf4e416a0d42092fb6bdc14131cee9dd15", "save_path": "github-repos/lean/Or7ando-lean", "path": "github-repos/lean/Or7ando-lean/lean-d41169cf4e416a0d42092fb6bdc14131cee9dd15/.github/workflows/geo/Spec.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438951025545427, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4905588312945554}}
{"text": "/-\nCopyright (c) 2020 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module tactic.derive_fintype\n! leanprover-community/mathlib commit 6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Fintype.Basic\n\n/-!\n# Derive handler for `fintype` instances\n\nThis file introduces a derive handler to automatically generate `fintype`\ninstances for structures and inductives.\n\n## Implementation notes\n\nTo construct a fintype instance, we need 3 things:\n\n  1. A list `l` of elements\n  2. A proof that `l` has no duplicates\n  3. A proof that every element in the type is in `l`\n\nNow fintype is defined as a finset which enumerates all elements, so steps (1) and (2) are\nbundled together. It is possible to use finset operations that remove duplicates to avoid the need\nto prove (2), but this adds unnecessary functions to the constructed term, which makes it more\nexpensive to compute the list, and it also adds a dependence on decidable equality for the type,\nwhich we want to avoid.\n\nBecause we will rely on fintype instances for constructor arguments, we can't actually build a list\ndirectly, so (1) and (2) are necessarily somewhat intertwined. The inductive types we will be\nproving instances for look something like this:\n\n```\n@[derive fintype]\ninductive foo\n| zero : foo\n| one : bool → foo\n| two : ∀ x : fin 3, bar x → foo\n```\n\nThe list of elements that we generate is\n```\n{foo.zero}\n∪ (finset.univ : bool).map (λ b, finset.one b)\n∪ (finset.univ : Σ' x : fin 3, bar x).map (λ ⟨x, y⟩, finset.two x y)\n```\nexcept that instead of `∪`, that is `finset.union`, we use `finset.disj_union` which doesn't\nrequire any deduplication, but does require a proof that the two parts of the union are disjoint.\nWe use `finset.cons` to append singletons like `foo.zero`.\n\nThe proofs of disjointness would be somewhat expensive since there are quadratically many of them,\nso instead we use a \"discriminant\" function. Essentially, we define\n```\ndef foo.enum : foo → ℕ\n| foo.zero := 0\n| (foo.one _) := 1\n| (foo.two _ _) := 2\n```\nand now the existence of this function implies that foo.zero is not foo.two and so on because they\nmap to different natural numbers. We can prove that sets of natural numbers are mutually disjoint\nmore easily because they have a linear order: `0 < 1 < 2` so `0 ≠ 2`.\n\nTo package this argument up, we define `finset_above foo foo.enum n` to be a finset `s` together\nwith a proof that all elements `a ∈ s` have `n ≤ enum a`. Now we only have to prove that\n`enum foo.zero = 0`, `enum (foo.one _) = 1`, etc. (linearly many proofs, all `rfl`) in order to\nprove that all variants are mutually distinct.\n\nWe mirror the `finset.cons` and `finset.disj_union` functions into `finset_above.cons` and\n`finset_above.union`, and this forms the main part of the finset construction.\n\nThis only handles distinguishing variants of a finset. Now we must enumerate the elements of a\nvariant, for example `{foo.one ff, foo.one tt}`, while at the same time proving that all these\nelements have discriminant `1` in this case. To do that, we use the `finset_in` type, which\nis a finset satisfying a property `P`, here `λ a, foo.enum a = 1`.\n\nWe could use `finset.bind` many times to construct the finset but it turns out to be somewhat\ncomplicated to get good side goals for a naturally nodup version of `finset.bind` in the same way\nas we did with `finset.cons` and `finset.union`. Instead, we tuple up all arguments into one type,\nleveraging the `fintype` instance on `psigma`, and then define a map from this type to the\ninductive type that untuples them and applies the constructor. The injectivity property of the\nconstructor ensures that this function is injective, so we can use `finset.map` to apply it. This\nis the content of the constructor `finset_in.mk`.\n\nThat completes the proofs of (1) and (2). To prove (3), we perform one case analysis over the\ninductive type, proving theorems like\n```\nfoo.one a ∈ {foo.zero}\n  ∪ (finset.univ : bool).map (λ b, finset.one b)\n  ∪ (finset.univ : Σ' x : fin 3, bar x).map (λ ⟨x, y⟩, finset.two x y)\n```\nby seeking to the relevant disjunct and then supplying the constructor arguments. This part of the\nproof is quadratic, but quite simple. (We could do it in `O(n log n)` if we used a balanced tree\nfor the unions.)\n\nThe tactics perform the following parts of this proof scheme:\n* `mk_sigma` constructs the type `Γ` in `finset_in.mk`\n* `mk_sigma_elim` constructs the function `f` in `finset_in.mk`\n* `mk_sigma_elim_inj` proves that `f` is injective\n* `mk_sigma_elim_eq` proves that `∀ a, enum (f a) = k`\n* `mk_finset` constructs the finset `S = {foo.zero} ∪ ...` by recursion on the variants\n* `mk_finset_total` constructs the proof `|- foo.zero ∈ S; |- foo.one a ∈ S; |- foo.two a b ∈ S`\n  by recursion on the subgoals coming out of the initial `cases`\n* `mk_fintype_instance` puts it all together to produce a proof of `fintype foo`.\n  The construction of `foo.enum` is also done in this function.\n\n-/\n\n\nnamespace DeriveFintype\n\n/-- A step in the construction of `finset.univ` for a finite inductive type.\nWe will set `enum` to the discriminant of the inductive type, so a `finset_above`\nrepresents a finset that enumerates all elements in a tail of the constructor list. -/\ndef FinsetAbove (α) (enum : α → ℕ) (n : ℕ) :=\n  { s : Finset α // ∀ x ∈ s, n ≤ enum x }\n#align derive_fintype.finset_above DeriveFintype.FinsetAbove\n\n/-- Construct a fintype instance from a completed `finset_above`. -/\ndef mkFintype {α} (enum : α → ℕ) (s : FinsetAbove α enum 0) (H : ∀ x, x ∈ s.1) : Fintype α :=\n  ⟨s.1, H⟩\n#align derive_fintype.mk_fintype DeriveFintype.mkFintype\n\n/-- This is the case for a simple variant (no arguments) in an inductive type. -/\ndef FinsetAbove.cons {α} {enum : α → ℕ} (n) (a : α) (h : enum a = n)\n    (s : FinsetAbove α enum (n + 1)) : FinsetAbove α enum n :=\n  by\n  refine' ⟨Finset.cons a s.1 _, _⟩\n  · intro h'\n    have := s.2 _ h'\n    rw [h] at this\n    exact Nat.not_succ_le_self n this\n  · intro x h'\n    rcases Finset.mem_cons.1 h' with (rfl | h')\n    · exact ge_of_eq h\n    · exact Nat.le_of_succ_le (s.2 _ h')\n#align derive_fintype.finset_above.cons DeriveFintype.FinsetAbove.cons\n\ntheorem FinsetAbove.mem_cons_self {α} {enum : α → ℕ} {n a h s} :\n    a ∈ (@FinsetAbove.cons α enum n a h s).1 :=\n  Multiset.mem_cons_self _ _\n#align derive_fintype.finset_above.mem_cons_self DeriveFintype.FinsetAbove.mem_cons_self\n\ntheorem FinsetAbove.mem_cons_of_mem {α} {enum : α → ℕ} {n a h s b} :\n    b ∈ (s : FinsetAbove _ _ _).1 → b ∈ (@FinsetAbove.cons α enum n a h s).1 :=\n  Multiset.mem_cons_of_mem\n#align derive_fintype.finset_above.mem_cons_of_mem DeriveFintype.FinsetAbove.mem_cons_of_mem\n\n/-- The base case is when we run out of variants; we just put an empty finset at the end. -/\ndef FinsetAbove.nil {α} {enum : α → ℕ} (n) : FinsetAbove α enum n :=\n  ⟨∅, by rintro _ ⟨⟩⟩\n#align derive_fintype.finset_above.nil DeriveFintype.FinsetAbove.nil\n\ninstance (α enum n) : Inhabited (FinsetAbove α enum n) :=\n  ⟨FinsetAbove.nil _⟩\n\n/-- This is a finset covering a nontrivial variant (with one or more constructor arguments).\nThe property `P` here is `λ a, enum a = n` where `n` is the discriminant for the current\nvariant. -/\n@[nolint has_nonempty_instance]\ndef FinsetIn {α} (P : α → Prop) :=\n  { s : Finset α // ∀ x ∈ s, P x }\n#align derive_fintype.finset_in DeriveFintype.FinsetIn\n\n/-- To construct the finset, we use an injective map from the type `Γ`, which will be the\nsigma over all constructor arguments. We use sigma instances and existing fintype instances\nto prove that `Γ` is a fintype, and construct the function `f` that maps `⟨a, b, c, ...⟩`\nto `C_n a b c ...` where `C_n` is the nth constructor, and `mem` asserts\n`enum (C_n a b c ...) = n`. -/\ndef FinsetIn.mk {α} {P : α → Prop} (Γ) [Fintype Γ] (f : Γ → α) (inj : Function.Injective f)\n    (mem : ∀ x, P (f x)) : FinsetIn P :=\n  ⟨Finset.univ.map ⟨f, inj⟩, fun x h => by\n    rcases Finset.mem_map.1 h with ⟨x, _, rfl⟩ <;> exact mem x⟩\n#align derive_fintype.finset_in.mk DeriveFintype.FinsetIn.mk\n\ntheorem FinsetIn.mem_mk {α} {P : α → Prop} {Γ} {s : Fintype Γ} {f : Γ → α} {inj mem a} (b)\n    (H : f b = a) : a ∈ (@FinsetIn.mk α P Γ s f inj mem).1 :=\n  Finset.mem_map.2 ⟨_, Finset.mem_univ _, H⟩\n#align derive_fintype.finset_in.mem_mk DeriveFintype.FinsetIn.mem_mk\n\n/-- For nontrivial variants, we split the constructor list into a `finset_in` component for the\ncurrent constructor and a `finset_above` for the rest. -/\ndef FinsetAbove.union {α} {enum : α → ℕ} (n) (s : FinsetIn fun a => enum a = n)\n    (t : FinsetAbove α enum (n + 1)) : FinsetAbove α enum n :=\n  by\n  refine' ⟨Finset.disjUnion s.1 t.1 _, _⟩\n  · rw [Finset.disjoint_left]\n    intro a hs ht\n    have := t.2 _ ht\n    rw [s.2 _ hs] at this\n    exact Nat.not_succ_le_self n this\n  · intro x h'\n    rcases Finset.mem_disjUnion.1 h' with (h' | h')\n    · exact ge_of_eq (s.2 _ h')\n    · exact Nat.le_of_succ_le (t.2 _ h')\n#align derive_fintype.finset_above.union DeriveFintype.FinsetAbove.union\n\ntheorem FinsetAbove.mem_union_left {α} {enum : α → ℕ} {n s t a} (H : a ∈ (s : FinsetIn _).1) :\n    a ∈ (@FinsetAbove.union α enum n s t).1 :=\n  Multiset.mem_add.2 (Or.inl H)\n#align derive_fintype.finset_above.mem_union_left DeriveFintype.FinsetAbove.mem_union_left\n\ntheorem FinsetAbove.mem_union_right {α} {enum : α → ℕ} {n s t a}\n    (H : a ∈ (t : FinsetAbove _ _ _).1) : a ∈ (@FinsetAbove.union α enum n s t).1 :=\n  Multiset.mem_add.2 (Or.inr H)\n#align derive_fintype.finset_above.mem_union_right DeriveFintype.FinsetAbove.mem_union_right\n\nend DeriveFintype\n\nnamespace Tactic\n\nopen DeriveFintype Tactic Expr\n\nnamespace DeriveFintype\n\n/-- Construct the term `Σ' (a:A) (b:B a) (c:C a b), unit` from\n`Π (a:A) (b:B a), C a b → T` (the type of a constructor). -/\nunsafe def mk_sigma : expr → tactic expr\n  | expr.pi n bi d b => do\n    let p ← mk_local' n bi d\n    let e ← mk_sigma (expr.instantiate_var b p)\n    tactic.mk_app `` PSigma [d, bind_lambda e p]\n  | _ => pure q(Unit)\n#align tactic.derive_fintype.mk_sigma tactic.derive_fintype.mk_sigma\n\n/-- Prove the goal `(Σ' (a:A) (b:B a) (c:C a b), unit) → T`\n(this is the function `f` in `finset_in.mk`) using recursive `psigma.elim`,\nfinishing with the constructor. The two arguments are the type of the constructor,\nand the constructor term itself; as we recurse we add arguments\nto the constructor application and destructure the pi type of the constructor. We return the number\nof `psigma.elim` applications constructed, which is the number of constructor arguments. -/\nunsafe def mk_sigma_elim : expr → expr → tactic ℕ\n  | expr.pi n bi d b, c => do\n    refine ``(@PSigma.elim $(d) _ _ _)\n    let i ← intro_fresh n\n    (· + 1) <$> mk_sigma_elim (expr.instantiate_var b i) (c i)\n  | _, c => do\n    intro1\n    exact c $> 0\n#align tactic.derive_fintype.mk_sigma_elim tactic.derive_fintype.mk_sigma_elim\n\n/-- Prove the goal `a, b |- f a = f b → g a = g b` where `f` is the function we constructed in\n`mk_sigma_elim`, and `g` is some other term that gets built up and eventually closed by\nreflexivity. Here `a` and `b` have sigma types so the proof approach is to case on `a` and `b`\nuntil the goal reduces to `C_n a1 ... am = C_n b1 ... bm → ⟨a1, ..., am⟩ = ⟨b1, ..., bm⟩`, at which\npoint cases on the equality reduces the problem to reflexivity.\n\nThe arguments are the number `m` returned from `mk_sigma_elim`, and the hypotheses `a,b` that we\nneed to case on. -/\nunsafe def mk_sigma_elim_inj : ℕ → expr → expr → tactic Unit\n  | m + 1, x, y => do\n    let [(_, [x1, x2])] ← cases x\n    let [(_, [y1, y2])] ← cases y\n    mk_sigma_elim_inj m x2 y2\n  | 0, x, y => do\n    cases x\n    cases y\n    let is ← intro1 >>= injection\n    is cases\n    reflexivity\n#align tactic.derive_fintype.mk_sigma_elim_inj tactic.derive_fintype.mk_sigma_elim_inj\n\n/-- Prove the goal `a |- enum (f a) = n`, where `f` is the function constructed in `mk_sigma_elim`,\nand `enum` is a function that reduces to `n` on the constructor `C_n`. Here we just have to case on\n`a` `m` times, and then `reflexivity` finishes the proof. -/\nunsafe def mk_sigma_elim_eq : ℕ → expr → tactic Unit\n  | n + 1, x => do\n    let [(_, [x1, x2])] ← cases x\n    mk_sigma_elim_eq n x2\n  | 0, x => reflexivity\n#align tactic.derive_fintype.mk_sigma_elim_eq tactic.derive_fintype.mk_sigma_elim_eq\n\n/-- Prove the goal `|- finset_above T enum k`, where `T` is the inductive type and `enum` is the\ndiscriminant function. The arguments are `args`, the parameters to the inductive type (and all\nconstructors), `k`, the index of the current variant, and `cs`, the list of constructor names.\nThis uses `finset_above.cons` for basic variants and `finset_above.union` for variants with\narguments, using the auxiliary functions `mk_sigma`, `mk_sigma_elim`, `mk_sigma_elim_inj`,\n`mk_sigma_elim_eq` to close subgoals. -/\nunsafe def mk_finset (ls : List level) (args : List expr) : ℕ → List Name → tactic Unit\n  | k, c :: cs => do\n    let e := (expr.const c ls).mk_app args\n    let t ← infer_type e\n    if is_pi t then do\n        to_expr ``(FinsetAbove.union $(reflect k)) tt ff >>= fun c =>\n            apply c { NewGoals := new_goals.all }\n        let Γ ← mk_sigma t\n        to_expr ``(FinsetIn.mk $(Γ)) tt ff >>= fun c => apply c { NewGoals := new_goals.all }\n        let n ← mk_sigma_elim t e\n        intro1 >>= fun x => intro1 >>= mk_sigma_elim_inj n x\n        intro1 >>= mk_sigma_elim_eq n\n        mk_finset (k + 1) cs\n      else do\n        let c ← to_expr ``(FinsetAbove.cons $(reflect k) $(e)) tt ff\n        apply c { NewGoals := new_goals.all }\n        reflexivity\n        mk_finset (k + 1) cs\n  | k, [] => applyc `` finset_above.nil\n#align tactic.derive_fintype.mk_finset tactic.derive_fintype.mk_finset\n\n/-- Prove the goal `|- Σ' (a:A) (b: B a) (c:C a b), unit` given a list of terms `a, b, c`. -/\nunsafe def mk_sigma_mem : List expr → tactic Unit\n  | x :: xs => (fconstructor >> exact x) >> mk_sigma_mem xs\n  | [] => fconstructor $> ()\n#align tactic.derive_fintype.mk_sigma_mem tactic.derive_fintype.mk_sigma_mem\n\n/-- This function is called to prove `a : T |- a ∈ S.1` where `S` is the `finset_above` constructed\nby `mk_finset`, after the initial cases on `a : T`, producing a list of subgoals. For each case,\nwe have to navigate past all the variants that don't apply (which is what the `tac` input tactic\ndoes), and then call either `finset_above.mem_cons_self` for trivial variants or\n`finset_above.mem_union_left` and `finset_in.mem_mk` for nontrivial variants. Either way the proof\nis quite simple. -/\nunsafe def mk_finset_total : tactic Unit → List (Name × List expr) → tactic Unit\n  | tac, [] => done\n  | tac, (_, xs) :: gs => do\n    tac\n    let b ← succeeds (applyc `` finset_above.mem_cons_self)\n    if b then mk_finset_total (tac >> applyc `` finset_above.mem_cons_of_mem) gs\n      else do\n        applyc `` finset_above.mem_union_left\n        applyc `` finset_in.mem_mk { NewGoals := new_goals.all }\n        mk_sigma_mem xs\n        reflexivity\n        mk_finset_total (tac >> applyc `` finset_above.mem_union_right) gs\n#align tactic.derive_fintype.mk_finset_total tactic.derive_fintype.mk_finset_total\n\nend DeriveFintype\n\nopen Tactic.DeriveFintype\n\n/-- Proves `|- fintype T` where `T` is a non-recursive inductive type with no indices,\nwhere all arguments to all constructors are fintypes. -/\nunsafe def mk_fintype_instance : tactic Unit := do\n  intros\n  let q(Fintype $(e)) ← target >>= whnf\n  let (const I ls, args) ← pure (get_app_fn_args e)\n  let env ← get_env\n  let cs := env.constructors_of I\n  guard (env I = 0) <|> fail \"@[derive fintype]: inductive indices are not supported\"\n  guard ¬env I <|>\n      fail\n        (\"@[derive fintype]: recursive inductive types are \" ++\n          \"not supported (they are also usually infinite)\")\n  applyc `` mk_fintype { NewGoals := new_goals.all }\n  intro1 >>= cases >>= fun gs => gs fun ⟨i, _⟩ => exact (reflect i)\n  mk_finset ls args 0 cs\n  intro1 >>= cases >>= mk_finset_total skip\n#align tactic.mk_fintype_instance tactic.mk_fintype_instance\n\n/-- Tries to derive a `fintype` instance for inductives and structures.\n\nFor example:\n```\n@[derive fintype]\ninductive foo (n m : ℕ)\n| zero : foo\n| one : bool → foo\n| two : fin n → fin m → foo\n```\nHere, `@[derive fintype]` adds the instance `foo.fintype`. The underlying finset\ndefinitionally unfolds to a list that enumerates the elements of the inductive in\nlexicographic order.\n\nIf the structure/inductive has a type parameter `α`, then the generated instance will have an\nargument `fintype α`, even if it is not used.  (This is due to the implementation using\n`instance_derive_handler`.)\n-/\n@[derive_handler]\nunsafe def fintype_instance : derive_handler :=\n  instance_derive_handler `` Fintype mk_fintype_instance\n#align tactic.fintype_instance tactic.fintype_instance\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/DeriveFintype.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.4905128297706964}}
{"text": "/-\nCopyright (c) 2019 Tim Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baanen\n-/\nimport tactic.norm_num\nimport control.traversable.basic\n\n/-!\n# `ring_exp` tactic\n\nA tactic for solving equations in commutative (semi)rings,\nwhere the exponents can also contain variables.\n\nMore precisely, expressions of the following form are supported:\n- constants (non-negative integers)\n- variables\n- coefficients (any rational number, embedded into the (semi)ring)\n- addition of expressions\n- multiplication of expressions\n- exponentiation of expressions (the exponent must have type `ℕ`)\n- subtraction and negation of expressions (if the base is a full ring)\n\nThe motivating example is proving `2 * 2^n * b = b * 2^(n+1)`,\nsomething that the `ring` tactic cannot do, but `ring_exp` can.\n\n## Implementation notes\n\nThe basic approach to prove equalities is to normalise both sides and check for equality.\nThe normalisation is guided by building a value in the type `ex` at the meta level,\ntogether with a proof (at the base level) that the original value is equal to\nthe normalised version.\nThe normalised version and normalisation proofs are also stored in the `ex` type.\n\nThe outline of the file:\n- Define an inductive family of types `ex`, parametrised over `ex_type`,\n  which can represent expressions with `+`, `*`, `^` and rational numerals.\n  The parametrisation over `ex_type` ensures that associativity and distributivity are applied,\n  by restricting which kinds of subexpressions appear as arguments to the various operators.\n- Represent addition, multiplication and exponentiation in the `ex` type,\n  thus allowing us to map expressions to `ex` (the `eval` function drives this).\n  We apply associativity and distributivity of the operators here (helped by `ex_type`)\n  and commutativity as well (by sorting the subterms; unfortunately not helped by anything).\n  Any expression not of the above formats is treated as an atom (the same as a variable).\n\nThere are some details we glossed over which make the plan more complicated:\n- The order on atoms is not initially obvious.\n  We construct a list containing them in order of initial appearance in the expression,\n  then use the index into the list as a key to order on.\n- In the tactic, a normalized expression `ps : ex` lives in the meta-world,\n  but the normalization proofs live in the real world.\n  Thus, we cannot directly say `ps.orig = ps.pretty` anywhere,\n  but we have to carefully construct the proof when we compute `ps`.\n  This was a major source of bugs in development!\n- For `pow`, the exponent must be a natural number, while the base can be any semiring `α`.\n  We swap out operations for the base ring `α` with those for the exponent ring `ℕ`\n  as soon as we deal with exponents.\n  This is accomplished by the `in_exponent` function and is relatively painless since\n  we work in a `reader` monad.\n- The normalized form of an expression is the one that is useful for the tactic,\n  but not as nice to read. To remedy this, the user-facing normalization calls `ex.simp`.\n\n## Caveats and future work\n\nSubtraction cancels out identical terms, but division does not.\nThat is: `a - a = 0 := by ring_exp` solves the goal,\nbut `a / a := 1 by ring_exp` doesn't.\nNote that `0 / 0` is generally defined to be `0`,\nso division cancelling out is not true in general.\n\nMultiplication of powers can be simplified a little bit further:\n`2 ^ n * 2 ^ n = 4 ^ n := by ring_exp` could be implemented\nin a similar way that `2 * a + 2 * a = 4 * a := by ring_exp` already works.\nThis feature wasn't needed yet, so it's not implemented yet.\n\n## Tags\n\nring, semiring, exponent, power\n-/\n\n-- The base ring `α` will have a universe level `u`.\n-- We do not introduce `α` as a variable yet,\n-- in order to make it explicit or implicit as required.\nuniverses u\n\nnamespace tactic.ring_exp\nopen nat\n\n/--\nThe `atom` structure is used to represent atomic expressions:\nthose which `ring_exp` cannot parse any further.\n\nFor instance, `a + (a % b)` has `a` and `(a % b)` as atoms.\nThe `ring_exp_eq` tactic does not normalize the subexpressions in atoms,\nbut `ring_exp` does if `ring_exp_eq` was not sufficient.\n\nAtoms in fact represent equivalence classes of expressions,\nmodulo definitional equality.\nThe field `index : ℕ` should be a unique number for each class,\nwhile `value : expr` contains a representative of this class.\nThe function `resolve_atom` determines the appropriate atom\nfor a given expression.\n-/\nmeta structure atom : Type := (value : expr) (index : ℕ)\n\nnamespace atom\n\n/--\nThe `eq` operation on `atom`s works modulo definitional equality,\nignoring their `value`s.\nThe invariants on `atom` ensure indices are unique per value.\nThus, `eq` indicates equality as long as the `atom`s come from the same context.\n-/\nmeta def eq (a b : atom) : bool := a.index = b.index\n\n/--\nWe order `atom`s on the order of appearance in the main expression.\n-/\nmeta def lt (a b : atom) : bool := a.index < b.index\n\nmeta instance : has_repr atom := ⟨λ x, \"(atom \" ++ repr x.2 ++ \")\"⟩\n\nend atom\n\nsection expression\n/-!\n### `expression` section\n\nIn this section, we define the `ex` type and its basic operations.\n\nFirst, we introduce the supporting types `coeff`, `ex_type` and `ex_info`.\nFor understanding the code, it's easier to check out `ex` itself first,\nthen refer back to the supporting types.\n\nThe arithmetic operations on `ex` need additional definitions,\nso they are defined in a later section.\n-/\n\n/--\nCoefficients in the expression are stored in a wrapper structure,\nallowing for easier modification of the data structures.\nThe modifications might be caching of the result of `expr.of_rat`,\nor using a different meta representation of numerals.\n-/\n@[derive decidable_eq, derive inhabited]\nstructure coeff : Type := (value : ℚ)\n\n/-- The values in `ex_type` are used as parameters to `ex` to control the expression's structure. -/\n@[derive decidable_eq, derive inhabited]\ninductive ex_type : Type\n| base : ex_type\n| sum : ex_type\n| prod : ex_type\n| exp : ex_type\nopen ex_type\n\n/--\nEach `ex` stores information for its normalization proof.\n\nThe `orig` expression is the expression that was passed to `eval`.\n\nThe `pretty` expression is the normalised form that the `ex` represents.\n(I didn't call this something like `norm`, because there are already\ntoo many things called `norm` in mathematics!)\n\nThe field `proof` contains an optional proof term of type `%%orig = %%pretty`.\nThe value `none` for the proof indicates that everything reduces to reflexivity.\n(Which saves space in quite a lot of cases.)\n-/\nmeta structure ex_info : Type :=\n(orig : expr) (pretty : expr) (proof : option expr)\n\n/--\nThe `ex` type is an abstract representation of an expression with `+`, `*` and `^`.\nThose operators are mapped to the `sum`, `prod` and `exp` constructors respectively.\n\nThe `zero` constructor is the base case for `ex sum`, e.g. `1 + 2` is represented\nby (something along the lines of) `sum 1 (sum 2 zero)`.\n\nThe `coeff` constructor is the base case for `ex prod`, and is used for numerals.\nThe code maintains the invariant that the coefficient is never `0`.\n\nThe `var` constructor is the base case for `ex exp`, and is used for atoms.\n\nThe `sum_b` constructor allows for addition in the base of an exponentiation;\nit serves a similar purpose as the parentheses in `(a + b)^c`.\nThe code maintains the invariant that the argument to `sum_b` is not `zero`\nor `sum _ zero`.\n\nAll of the constructors contain an `ex_info` field,\nused to carry around (arguments to) proof terms.\n\nWhile the `ex_type` parameter enforces some simplification invariants,\nthe following ones must be manually maintained at the risk of insufficient power:\n- the argument to `coeff` must be nonzero (to ensure `0 = 0 * 1`)\n- the argument to `sum_b` must be of the form `sum a (sum b bs)` (to ensure `(a + 0)^n = a^n`)\n- normalisation proofs of subexpressions must be `refl ps.pretty`\n- if we replace `sum` with `cons` and `zero` with `nil`, the resulting list is sorted\n  according to the `lt` relation defined further down; similarly for `prod` and `coeff`\n  (to ensure `a + b = b + a`).\n\nThe first two invariants could be encoded in a subtype of `ex`,\nbut aren't (yet) to spare some implementation burden.\nThe other invariants cannot be encoded because we need the `tactic` monad to check them.\n(For example, the correct equality check of `expr` is `is_def_eq : expr → expr → tactic unit`.)\n-/\nmeta inductive ex : ex_type → Type\n| zero  (info : ex_info) : ex sum\n| sum   (info : ex_info) : ex prod → ex sum → ex sum\n| coeff (info : ex_info) : coeff → ex prod\n| prod  (info : ex_info) : ex exp → ex prod → ex prod\n| var   (info : ex_info) : atom → ex base\n| sum_b (info : ex_info) : ex sum → ex base\n| exp   (info : ex_info) : ex base → ex prod → ex exp\n\n/--\nReturn the proof information associated to the `ex`.\n-/\nmeta def ex.info : Π {et : ex_type} (ps : ex et), ex_info\n| sum  (ex.zero  i)     := i\n| sum  (ex.sum   i _ _) := i\n| prod (ex.coeff i _)   := i\n| prod (ex.prod  i _ _) := i\n| base (ex.var   i _)   := i\n| base (ex.sum_b i _)   := i\n| exp  (ex.exp   i _ _) := i\n\n/--\nReturn the original, non-normalized version of this `ex`.\n\nNote that arguments to another `ex` are always \"pre-normalized\":\ntheir `orig` and `pretty` are equal, and their `proof` is reflexivity.\n-/\nmeta def ex.orig {et : ex_type} (ps : ex et) : expr := ps.info.orig\n\n/--\nReturn the normalized version of this `ex`.\n-/\nmeta def ex.pretty {et : ex_type} (ps : ex et) : expr := ps.info.pretty\n\n/--\nReturn the normalisation proof of the given expression.\nIf the proof is `refl`, we give `none` instead,\nwhich helps to control the size of proof terms.\nTo get an actual term, use `ex.proof_term`,\nor use `mk_proof` with the correct set of arguments.\n-/\nmeta def ex.proof {et : ex_type} (ps : ex et) : option expr := ps.info.proof\n\n/--\nUpdate the `orig` and `proof` fields of the `ex_info`.\nIntended for use in `ex.set_info`.\n-/\nmeta def ex_info.set (i : ex_info) (o : option expr) (pf : option expr) : ex_info :=\n{orig := o.get_or_else i.pretty, proof := pf, .. i}\n\n/--\nUpdate the `ex_info` of the given expression.\n\nWe use this to combine intermediate normalisation proofs.\nSince `pretty` only depends on the subexpressions,\nwhich do not change, we do not set `pretty`.\n-/\nmeta def ex.set_info : Π {et : ex_type} (ps : ex et), option expr → option expr → ex et\n| sum  (ex.zero  i)      o pf := ex.zero  (i.set o pf)\n| sum  (ex.sum   i p ps) o pf := ex.sum   (i.set o pf) p ps\n| prod (ex.coeff i x)    o pf := ex.coeff (i.set o pf) x\n| prod (ex.prod  i p ps) o pf := ex.prod  (i.set o pf) p ps\n| base (ex.var   i x)    o pf := ex.var   (i.set o pf) x\n| base (ex.sum_b i ps)   o pf := ex.sum_b (i.set o pf) ps\n| exp  (ex.exp   i p ps) o pf := ex.exp   (i.set o pf) p ps\n\ninstance coeff_has_repr : has_repr coeff := ⟨λ x, repr x.1⟩\n\n/-- Convert an `ex` to a `string`. -/\nmeta def ex.repr : Π {et : ex_type}, ex et → string\n| sum  (ex.zero _)      := \"0\"\n| sum  (ex.sum _ p ps)  := ex.repr p ++ \" + \" ++ ex.repr ps\n| prod (ex.coeff _ x)   := repr x\n| prod (ex.prod _ p ps) := ex.repr p ++ \" * \" ++ ex.repr ps\n| base (ex.var _ x)     := repr x\n| base (ex.sum_b _ ps)  := \"(\" ++ ex.repr ps ++ \")\"\n| exp  (ex.exp _ p ps)  := ex.repr p ++ \" ^ \" ++ ex.repr ps\nmeta instance {et : ex_type} : has_repr (ex et) := ⟨ex.repr⟩\n\n/--\nEquality test for expressions.\n\nSince equivalence of `atom`s is not the same as equality,\nwe cannot make a true `(=)` operator for `ex` either.\n-/\nmeta def ex.eq : Π {et : ex_type}, ex et → ex et → bool\n| sum  (ex.zero _)      (ex.zero _)      := tt\n| sum  (ex.zero _)      (ex.sum _ _ _)   := ff\n| sum  (ex.sum _ _ _)   (ex.zero _)      := ff\n| sum  (ex.sum _ p ps)  (ex.sum _ q qs)  := p.eq q && ps.eq qs\n| prod (ex.coeff _  x)  (ex.coeff _ y)   := x = y\n| prod (ex.coeff _ _)   (ex.prod _ _ _)  := ff\n| prod (ex.prod _ _ _)  (ex.coeff _ _)   := ff\n| prod (ex.prod _ p ps) (ex.prod _ q qs) := p.eq q && ps.eq qs\n| base (ex.var _ x)     (ex.var _ y)     := x.eq y\n| base (ex.var _ _)     (ex.sum_b _ _)   := ff\n| base (ex.sum_b _ _)   (ex.var _ _)     := ff\n| base (ex.sum_b _ ps)  (ex.sum_b _ qs)  := ps.eq qs\n| exp  (ex.exp _ p ps)  (ex.exp _ q qs)  := p.eq q && ps.eq qs\n\n/--\nThe ordering on expressions.\n\nAs for `ex.eq`, this is a linear order only in one context.\n-/\nmeta def ex.lt : Π {et : ex_type}, ex et → ex et → bool\n| sum  _                (ex.zero _)      := ff\n| sum  (ex.zero _)      _                := tt\n| sum  (ex.sum _ p ps)  (ex.sum _ q qs)  := p.lt q || (p.eq q && ps.lt qs)\n| prod (ex.coeff _ x)   (ex.coeff _ y)   := x.1 < y.1\n| prod (ex.coeff _ _)   _                := tt\n| prod _                (ex.coeff _ _)   := ff\n| prod (ex.prod _ p ps) (ex.prod _ q qs) := p.lt q || (p.eq q && ps.lt qs)\n| base (ex.var _ x)     (ex.var _ y)     := x.lt y\n| base (ex.var _ _)     (ex.sum_b _ _)   := tt\n| base (ex.sum_b _ _)   (ex.var _ _)     := ff\n| base (ex.sum_b _ ps)  (ex.sum_b _ qs)  := ps.lt qs\n| exp  (ex.exp _ p ps)  (ex.exp _ q qs)  := p.lt q || (p.eq q && ps.lt qs)\n\nend expression\n\nsection operations\n/-!\n### `operations` section\n\nThis section defines the operations (on `ex`) that use tactics.\nThey live in the `ring_exp_m` monad,\nwhich adds a cache and a list of encountered atoms to the `tactic` monad.\n\nThroughout this section, we will be constructing proof terms.\nThe lemmas used in the construction are all defined over a commutative semiring α.\n-/\nvariables {α : Type u} [comm_semiring α]\n\nopen tactic\nopen ex_type\n\n/--\nStores the information needed in the `eval` function and its dependencies,\nso they can (re)construct expressions.\n\nThe `eval_info` structure stores this information for one type,\nand the `context` combines the two types, one for bases and one for exponents.\n-/\nmeta structure eval_info :=\n(α : expr) (univ : level)\n-- Cache the instances for optimization and consistency\n(csr_instance : expr) (ha_instance : expr) (hm_instance : expr) (hp_instance : expr)\n-- Optional instances (only required for (-) and (/) respectively)\n(ring_instance : option expr) (dr_instance : option expr)\n-- Cache common constants.\n(zero : expr) (one : expr)\n\n/--\nThe `context` contains the full set of information needed for the `eval` function.\n\nThis structure has two copies of `eval_info`:\none is for the base (typically some semiring `α`) and another for the exponent (always `ℕ`).\nWhen evaluating an exponent, we put `info_e` in `info_b`.\n-/\nmeta structure context :=\n(info_b : eval_info) (info_e : eval_info) (transp : transparency)\n\n/--\nThe `ring_exp_m` monad is used instead of `tactic` to store the context.\n-/\n@[derive [monad, alternative]]\nmeta def ring_exp_m (α : Type) : Type := reader_t context (state_t (list atom) tactic) α\n\n/--\nAccess the instance cache.\n-/\nmeta def get_context : ring_exp_m context := reader_t.read\n\n/--\nLift an operation in the `tactic` monad to the `ring_exp_m` monad.\n\nThis operation will not access the cache.\n-/\nmeta def lift {α} (m : tactic α) : ring_exp_m α := reader_t.lift (state_t.lift m)\n\n/--\nChange the context of the given computation,\nso that expressions are evaluated in the exponent ring,\ninstead of the base ring.\n-/\nmeta def in_exponent {α} (mx : ring_exp_m α) : ring_exp_m α := do\n  ctx ← get_context,\n  reader_t.lift $ mx.run ⟨ctx.info_e, ctx.info_e, ctx.transp⟩\n\n/--\nSpecialized version of `mk_app` where the first two arguments are `{α}` `[some_class α]`.\nShould be faster because it can use the cached instances.\n-/\nmeta def mk_app_class (f : name) (inst : expr) (args : list expr) : ring_exp_m expr := do\n  ctx ← get_context,\n  pure $ (@expr.const tt f [ctx.info_b.univ] ctx.info_b.α inst).mk_app args\n\n/--\nSpecialized version of `mk_app` where the first two arguments are `{α}` `[comm_semiring α]`.\nShould be faster because it can use the cached instances.\n -/\nmeta def mk_app_csr (f : name) (args : list expr) : ring_exp_m expr := do\n  ctx ← get_context,\n  mk_app_class f (ctx.info_b.csr_instance) args\n\n/--\nSpecialized version of `mk_app ``has_add.add`.\nShould be faster because it can use the cached instances.\n-/\nmeta def mk_add (args : list expr) : ring_exp_m expr := do\n  ctx ← get_context,\n  mk_app_class ``has_add.add ctx.info_b.ha_instance args\n\n/--\nSpecialized version of `mk_app ``has_mul.mul`.\nShould be faster because it can use the cached instances.\n-/\nmeta def mk_mul (args : list expr) : ring_exp_m expr := do\n  ctx ← get_context,\n  mk_app_class ``has_mul.mul ctx.info_b.hm_instance args\n\n/--\nSpecialized version of `mk_app ``has_pow.pow`.\nShould be faster because it can use the cached instances.\n-/\nmeta def mk_pow (args : list expr) : ring_exp_m expr := do\n  ctx ← get_context,\n  pure $ (@expr.const tt ``has_pow.pow\n    [ctx.info_b.univ, ctx.info_e.univ]\n    ctx.info_b.α ctx.info_e.α\n    ctx.info_b.hp_instance).mk_app args\n\n/-- Construct a normalization proof term or return the cached one. -/\nmeta def ex_info.proof_term (ps : ex_info) : ring_exp_m expr :=\nmatch ps.proof with\n| none := lift $ tactic.mk_eq_refl ps.pretty\n| (some p) := pure p\nend\n/-- Construct a normalization proof term or return the cached one. -/\nmeta def ex.proof_term {et : ex_type} (ps : ex et) : ring_exp_m expr := ps.info.proof_term\n\n/--\nIf all `ex_info` have trivial proofs, return a trivial proof.\nOtherwise, construct all proof terms.\n\nUseful in applications where trivial proofs combine to another trivial proof,\nmost importantly to pass to `mk_proof_or_refl`.\n-/\nmeta def none_or_proof_term : list ex_info → ring_exp_m (option (list expr))\n| [] := pure none\n| (x :: xs) := do\n  xs_pfs ← none_or_proof_term xs,\n  match (x.proof, xs_pfs) with\n  | (none, none) := pure none\n  | (some x_pf, none) := do\n    xs_pfs ← traverse ex_info.proof_term xs,\n    pure (some (x_pf :: xs_pfs))\n  | (_, some xs_pfs) := do\n    x_pf ← x.proof_term,\n    pure (some (x_pf :: xs_pfs))\n  end\n\n/--\nUse the proof terms as arguments to the given lemma.\nIf the lemma could reduce to reflexivity, consider using `mk_proof_or_refl.`\n-/\nmeta def mk_proof (lem : name) (args : list expr) (hs : list ex_info) : ring_exp_m expr := do\n  hs' ← traverse ex_info.proof_term hs,\n  mk_app_csr lem (args ++ hs')\n\n/--\nUse the proof terms as arguments to the given lemma.\nOften, we construct a proof term using congruence where reflexivity suffices.\nTo solve this, the following function tries to get away with reflexivity.\n-/\nmeta def mk_proof_or_refl (term : expr) (lem : name) (args : list expr) (hs : list ex_info) :\nring_exp_m expr := do\n  hs_full ← none_or_proof_term hs,\n  match hs_full with\n  | none := lift $ mk_eq_refl term\n  | (some hs') := mk_app_csr lem (args ++ hs')\n  end\n\n/-- A shortcut for adding the original terms of two expressions. -/\nmeta def add_orig {et et'} (ps : ex et) (qs : ex et') : ring_exp_m expr :=\nmk_add [ps.orig, qs.orig]\n\n/-- A shortcut for multiplying the original terms of two expressions. -/\nmeta def mul_orig {et et'} (ps : ex et) (qs : ex et') : ring_exp_m expr :=\nmk_mul [ps.orig, qs.orig]\n\n/-- A shortcut for exponentiating the original terms of two expressions. -/\nmeta def pow_orig {et et'} (ps : ex et) (qs : ex et') : ring_exp_m expr :=\nmk_pow [ps.orig, qs.orig]\n\n/-- Congruence lemma for constructing `ex.sum`. -/\nlemma sum_congr {p p' ps ps' : α} : p = p' → ps = ps' → p + ps = p' + ps' := by cc\n\n/-- Congruence lemma for constructing `ex.prod`. -/\nlemma prod_congr {p p' ps ps' : α} : p = p' → ps = ps' → p * ps = p' * ps' := by cc\n\n/-- Congruence lemma for constructing `ex.exp`. -/\nlemma exp_congr {p p' : α} {ps ps' : ℕ} : p = p' → ps = ps' → p ^ ps = p' ^ ps' := by cc\n\n/-- Constructs `ex.zero` with the correct arguments. -/\nmeta def ex_zero : ring_exp_m (ex sum) := do\n  ctx ← get_context,\n  pure $ ex.zero ⟨ctx.info_b.zero, ctx.info_b.zero, none⟩\n\n/-- Constructs `ex.sum` with the correct arguments. -/\nmeta def ex_sum (p : ex prod) (ps : ex sum) : ring_exp_m (ex sum) := do\n  pps_o ← add_orig p ps,\n  pps_p ← mk_add [p.pretty, ps.pretty],\n  pps_pf ← mk_proof_or_refl pps_p ``sum_congr\n    [p.orig, p.pretty, ps.orig, ps.pretty]\n    [p.info, ps.info],\n  pure (ex.sum ⟨pps_o, pps_p, pps_pf⟩ (p.set_info none none) (ps.set_info none none))\n\n/--\nConstructs `ex.coeff` with the correct arguments.\n\nThere are more efficient constructors for specific numerals:\nif `x = 0`, you should use `ex_zero`; if `x = 1`, use `ex_one`.\n-/\nmeta def ex_coeff (x : rat) : ring_exp_m (ex prod) := do\n  ctx ← get_context,\n  x_p ← lift $ expr.of_rat ctx.info_b.α x,\n  pure (ex.coeff ⟨x_p, x_p, none⟩ ⟨x⟩)\n\n/--\nConstructs `ex.coeff 1` with the correct arguments.\nThis is a special case for optimization purposes.\n-/\nmeta def ex_one : ring_exp_m (ex prod) := do\n  ctx ← get_context,\n  pure $ ex.coeff ⟨ctx.info_b.one, ctx.info_b.one, none⟩ ⟨1⟩\n\n/-- Constructs `ex.prod` with the correct arguments. -/\nmeta def ex_prod (p : ex exp) (ps : ex prod) : ring_exp_m (ex prod) := do\n  pps_o ← mul_orig p ps,\n  pps_p ← mk_mul [p.pretty, ps.pretty],\n  pps_pf ← mk_proof_or_refl pps_p ``prod_congr\n    [p.orig, p.pretty, ps.orig, ps.pretty]\n    [p.info, ps.info],\n  pure (ex.prod ⟨pps_o, pps_p, pps_pf⟩ (p.set_info none none) (ps.set_info none none))\n\n/-- Constructs `ex.var` with the correct arguments. -/\nmeta def ex_var (p : atom) : ring_exp_m (ex base) := pure (ex.var ⟨p.1, p.1, none⟩ p)\n\n/-- Constructs `ex.sum_b` with the correct arguments. -/\nmeta def ex_sum_b (ps : ex sum) : ring_exp_m (ex base) :=\npure (ex.sum_b ps.info (ps.set_info none none))\n\n/-- Constructs `ex.exp` with the correct arguments. -/\nmeta def ex_exp (p : ex base) (ps : ex prod) : ring_exp_m (ex exp) := do\n  ctx ← get_context,\n  pps_o ← pow_orig p ps,\n  pps_p ← mk_pow [p.pretty, ps.pretty],\n  pps_pf ← mk_proof_or_refl pps_p ``exp_congr\n    [p.orig, p.pretty, ps.orig, ps.pretty]\n    [p.info, ps.info],\n  pure (ex.exp ⟨pps_o, pps_p, pps_pf⟩ (p.set_info none none) (ps.set_info none none))\n\nlemma base_to_exp_pf {p p' : α} : p = p' → p = p' ^ 1 := by simp\n\n/-- Conversion from `ex base` to `ex exp`. -/\nmeta def base_to_exp (p : ex base) : ring_exp_m (ex exp) := do\n  o ← in_exponent $ ex_one,\n  ps ← ex_exp p o,\n  pf ← mk_proof ``base_to_exp_pf [p.orig, p.pretty] [p.info],\n  pure $ ps.set_info p.orig pf\n\nlemma exp_to_prod_pf {p p' : α} : p = p' → p = p' * 1 := by simp\n\n/-- Conversion from `ex exp` to `ex prod`. -/\nmeta def exp_to_prod (p : ex exp) : ring_exp_m (ex prod) := do\n  o ← ex_one,\n  ps ← ex_prod p o,\n  pf ← mk_proof ``exp_to_prod_pf [p.orig, p.pretty] [p.info],\n  pure $ ps.set_info p.orig pf\n\nlemma prod_to_sum_pf {p p' : α} : p = p' → p = p' + 0 := by simp\n\n/-- Conversion from `ex prod` to `ex sum`. -/\nmeta def prod_to_sum (p : ex prod) : ring_exp_m (ex sum) := do\n  z ← ex_zero,\n  ps ← ex_sum p z,\n  pf ← mk_proof ``prod_to_sum_pf [p.orig, p.pretty] [p.info],\n  pure $ ps.set_info p.orig pf\n\nlemma atom_to_sum_pf (p : α) : p = p ^ 1 * 1 + 0 := by simp\n/--\nA more efficient conversion from `atom` to `ex sum`.\n\nThe result should be the same as `ex_var p >>= base_to_exp >>= exp_to_prod >>= prod_to_sum`,\nexcept we need to calculate less intermediate steps.\n-/\nmeta def atom_to_sum (p : atom) : ring_exp_m (ex sum) := do\n  p' ← ex_var p,\n  o ← in_exponent $ ex_one,\n  p' ← ex_exp p' o,\n  o ← ex_one,\n  p' ← ex_prod p' o,\n  z ← ex_zero,\n  p' ← ex_sum p' z,\n  pf ← mk_proof ``atom_to_sum_pf [p.1] [],\n  pure $ p'.set_info p.1 pf\n\n/--\nCompute the sum of two coefficients.\nNote that the result might not be a valid expression:\nif `p = -q`, then the result should be `ex.zero : ex sum` instead.\nThe caller must detect when this happens!\n\nThe returned value is of the form `ex.coeff _ (p + q)`,\nwith the proof of `expr.of_rat p + expr.of_rat q = expr.of_rat (p + q)`.\n-/\nmeta def add_coeff (p_p q_p : expr) (p q : coeff) : ring_exp_m (ex prod) := do\n  ctx ← get_context,\n  pq_o ← mk_add [p_p, q_p],\n  (pq_p, pq_pf) ← lift $ norm_num.eval_field pq_o,\n  pure $ ex.coeff ⟨pq_o, pq_p, pq_pf⟩ ⟨p.1 + q.1⟩\n\nlemma mul_coeff_pf_one_mul (q : α) : 1 * q = q := one_mul q\nlemma mul_coeff_pf_mul_one (p : α) : p * 1 = p := mul_one p\n\n/--\nCompute the product of two coefficients.\n\nThe returned value is of the form `ex.coeff _ (p * q)`,\nwith the proof of `expr.of_rat p * expr.of_rat q = expr.of_rat (p * q)`.\n-/\nmeta def mul_coeff (p_p q_p : expr) (p q : coeff) : ring_exp_m (ex prod) :=\nmatch p.1, q.1 with -- Special case to speed up multiplication with 1.\n| ⟨1, 1, _, _⟩, _ := do\n  ctx ← get_context,\n  pq_o ← mk_mul [p_p, q_p],\n  pf ← mk_app_csr ``mul_coeff_pf_one_mul [q_p],\n  pure $ ex.coeff ⟨pq_o, q_p, pf⟩ ⟨q.1⟩\n| _, ⟨1, 1, _, _⟩ := do\n  ctx ← get_context,\n  pq_o ← mk_mul [p_p, q_p],\n  pf ← mk_app_csr ``mul_coeff_pf_mul_one [p_p],\n  pure $ ex.coeff ⟨pq_o, p_p, pf⟩ ⟨p.1⟩\n| _, _ := do\n  ctx ← get_context,\n  pq' ← mk_mul [p_p, q_p],\n  (pq_p, pq_pf) ← lift $ norm_num.eval_field pq',\n  pure $ ex.coeff ⟨pq_p, pq_p, pq_pf⟩ ⟨p.1 * q.1⟩\nend\n\nsection rewrite\n\n/-! ### `rewrite` section\n\nIn this section we deal with rewriting terms to fit in the basic grammar of `eval`.\nFor example, `nat.succ n` is rewritten to `n + 1` before it is evaluated further.\n-/\n\n/-- Given a proof that the expressions `ps_o` and `ps'.orig` are equal,\nshow that `ps_o` and `ps'.pretty` are equal.\n\nUseful to deal with aliases in `eval`. For instance, `nat.succ p` can be handled\nas an alias of `p + 1` as follows:\n```\n| ps_o@`(nat.succ %%p_o) := do\n  ps' ← eval `(%%p_o + 1),\n  pf ← lift $ mk_app ``nat.succ_eq_add_one [p_o],\n  rewrite ps_o ps' pf\n```\n-/\nmeta def rewrite (ps_o : expr) (ps' : ex sum) (pf : expr) : ring_exp_m (ex sum) :=\ndo\n  ps'_pf ← ps'.info.proof_term,\n  pf ← lift $ mk_eq_trans pf ps'_pf,\n  pure $ ps'.set_info ps_o pf\n\nend rewrite\n\n/--\nRepresents the way in which two products are equal except coefficient.\n\nThis type is used in the function `add_overlap`.\nIn order to deal with equations of the form `a * 2 + a = 3 * a`,\nthe `add` function will add up overlapping products,\nturning `a * 2 + a` into `a * 3`.\nWe need to distinguish `a * 2 + a` from `a * 2 + b` in order to do this,\nand the `overlap` type carries the information on how it overlaps.\n\nThe case `none` corresponds to non-overlapping products, e.g. `a * 2 + b`;\nthe case `nonzero` to overlapping products adding to non-zero, e.g. `a * 2 + a`\n(the `ex prod` field will then look like `a * 3` with a proof that `a * 2 + a = a * 3`);\nthe case `zero` to overlapping products adding to zero, e.g. `a * 2 + a * -2`.\nWe distinguish those two cases because in the second, the whole product reduces to `0`.\n\nA potential extension to the tactic would also do this for the base of exponents,\ne.g. to show `2^n * 2^n = 4^n`.\n-/\nmeta inductive overlap : Type\n| none : overlap\n| nonzero : ex prod → overlap\n| zero : ex sum → overlap\n\nlemma add_overlap_pf {ps qs pq} (p : α) : ps + qs = pq → p * ps + p * qs = p * pq := λ pq_pf, calc\n  p * ps + p * qs = p * (ps + qs) : symm (mul_add _ _ _)\n  ... = p * pq : by rw pq_pf\n\nlemma add_overlap_pf_zero {ps qs} (p : α) : ps + qs = 0 → p * ps + p * qs = 0 := λ pq_pf, calc\n  p * ps + p * qs = p * (ps + qs) : symm (mul_add _ _ _)\n  ... = p * 0 : by rw pq_pf\n  ... = 0 : mul_zero _\n\n/--\nGiven arguments `ps`, `qs` of the form `ps' * x` and `ps' * y` respectively\nreturn `ps + qs = ps' * (x + y)` (with `x` and `y` arbitrary coefficients).\nFor other arguments, return `overlap.none`.\n-/\nmeta def add_overlap : ex prod → ex prod → ring_exp_m overlap\n| (ex.coeff x_i x) (ex.coeff y_i y) := do\n  xy@(ex.coeff _ xy_c) ← add_coeff x_i.pretty y_i.pretty x y\n    | lift $ fail \"internal error: add_coeff should return ex.coeff\",\n  if xy_c.1 = 0\n  then do\n    z ← ex_zero,\n    pure $ overlap.zero (z.set_info xy.orig xy.proof)\n  else pure $ overlap.nonzero xy\n| (ex.prod _ _ _) (ex.coeff _ _) := pure overlap.none\n| (ex.coeff _ _) (ex.prod _ _ _) := pure overlap.none\n| pps@(ex.prod _ p ps) qqs@(ex.prod _ q qs) := if p.eq q\n  then do\n    pq_ol ← add_overlap ps qs,\n    pqs_o ← add_orig pps qqs,\n    match pq_ol with\n    | overlap.none := pure overlap.none\n    | (overlap.nonzero pq) := do\n      pqs ← ex_prod p pq,\n      pf ← mk_proof ``add_overlap_pf\n        [ps.pretty, qs.pretty, pq.pretty, p.pretty]\n        [pq.info],\n      pure $ overlap.nonzero (pqs.set_info pqs_o pf)\n    | (overlap.zero pq) := do\n      z ← ex_zero,\n      pf ← mk_proof ``add_overlap_pf_zero\n        [ps.pretty, qs.pretty, p.pretty]\n        [pq.info],\n      pure $ overlap.zero (z.set_info pqs_o pf)\n    end\n  else pure overlap.none\n\nsection addition\n\nlemma add_pf_z_sum {ps qs qs' : α} : ps = 0 → qs = qs' → ps + qs = qs' := λ ps_pf qs_pf, calc\n  ps + qs = 0 + qs' : by rw [ps_pf, qs_pf]\n  ... = qs' : zero_add _\n\nlemma add_pf_sum_z {ps ps' qs : α} : ps = ps' → qs = 0 → ps + qs = ps' := λ ps_pf qs_pf, calc\n  ps + qs = ps' + 0 : by rw [ps_pf, qs_pf]\n  ... = ps' : add_zero _\n\nlemma add_pf_sum_overlap {pps p ps qqs q qs pq pqs : α} :\n  pps = p + ps → qqs = q + qs → p + q = pq → ps + qs = pqs → pps + qqs = pq + pqs := by cc\n\nlemma add_pf_sum_overlap_zero {pps p ps qqs q qs pqs : α} :\n  pps = p + ps → qqs = q + qs → p + q = 0 → ps + qs = pqs → pps + qqs = pqs :=\nλ pps_pf qqs_pf pq_pf pqs_pf, calc\n  pps + qqs = (p + ps) + (q + qs) : by rw [pps_pf, qqs_pf]\n  ... = (p + q) + (ps + qs) : by cc\n  ... = 0 + pqs : by rw [pq_pf, pqs_pf]\n  ... = pqs : zero_add _\n\nlemma add_pf_sum_lt {pps p ps qqs pqs : α} :\n  pps = p + ps → ps + qqs = pqs → pps + qqs = p + pqs := by cc\n\nlemma add_pf_sum_gt {pps qqs q qs pqs : α} :\n  qqs = q + qs → pps + qs = pqs → pps + qqs = q + pqs := by cc\n\n/--\nAdd two expressions.\n\n* `0 + qs = 0`\n* `ps + 0 = 0`\n* `ps * x + ps * y = ps * (x + y)` (for `x`, `y` coefficients; uses `add_overlap`)\n* `(p + ps) + (q + qs) = p + (ps + (q + qs))` (if `p.lt q`)\n* `(p + ps) + (q + qs) = q + ((p + ps) + qs)` (if not `p.lt q`)\n-/\nmeta def add : ex sum → ex sum → ring_exp_m (ex sum)\n| ps@(ex.zero ps_i) qs := do\n  pf ← mk_proof ``add_pf_z_sum [ps.orig, qs.orig, qs.pretty] [ps.info, qs.info],\n  pqs_o ← add_orig ps qs,\n  pure $ qs.set_info pqs_o pf\n| ps qs@(ex.zero qs_i) := do\n  pf ← mk_proof ``add_pf_sum_z [ps.orig, ps.pretty, qs.orig] [ps.info, qs.info],\n  pqs_o ← add_orig ps qs,\n  pure $ ps.set_info pqs_o pf\n| pps@(ex.sum pps_i p ps) qqs@(ex.sum qqs_i q qs) := do\n  ol ← add_overlap p q,\n  ppqqs_o ← add_orig pps qqs,\n  match ol with\n  | (overlap.nonzero pq) := do\n    pqs ← add ps qs,\n    pqqs ← ex_sum pq pqs,\n    qqs_pf ← qqs.proof_term,\n    pf ← mk_proof ``add_pf_sum_overlap\n      [pps.orig, p.pretty, ps.pretty, qqs.orig, q.pretty, qs.pretty, pq.pretty, pqs.pretty]\n      [pps.info, qqs.info, pq.info, pqs.info],\n    pure $ pqqs.set_info ppqqs_o pf\n  | (overlap.zero pq) := do\n    pqs ← add ps qs,\n    pf ← mk_proof ``add_pf_sum_overlap_zero\n      [pps.orig, p.pretty, ps.pretty, qqs.orig, q.pretty, qs.pretty, pqs.pretty]\n      [pps.info, qqs.info, pq.info, pqs.info],\n    pure $ pqs.set_info ppqqs_o pf\n  | overlap.none := if p.lt q\n  then do\n    pqs ← add ps qqs,\n    ppqs ← ex_sum p pqs,\n    pf ← mk_proof ``add_pf_sum_lt\n      [pps.orig, p.pretty, ps.pretty, qqs.orig, pqs.pretty]\n      [pps.info, pqs.info],\n    pure $ ppqs.set_info ppqqs_o pf\n  else do\n    pqs ← add pps qs,\n    pqqs ← ex_sum q pqs,\n    pf ← mk_proof ``add_pf_sum_gt\n      [pps.orig, qqs.orig, q.pretty, qs.pretty, pqs.pretty]\n      [qqs.info, pqs.info],\n    pure $ pqqs.set_info ppqqs_o pf\n  end\n\nend addition\n\nsection multiplication\nlemma mul_pf_c_c {ps ps' qs qs' pq : α} :\n  ps = ps' → qs = qs' → ps' * qs' = pq → ps * qs = pq := by cc\n\nlemma mul_pf_c_prod {ps qqs q qs pqs : α} :\n  qqs = q * qs → ps * qs = pqs → ps * qqs = q * pqs := by cc\n\nlemma mul_pf_prod_c {pps p ps qs pqs : α} :\n  pps = p * ps → ps * qs = pqs → pps * qs = p * pqs := by cc\n\nlemma mul_pp_pf_overlap {pps p_b ps qqs qs psqs : α} {p_e q_e : ℕ} :\n  pps = p_b ^ p_e * ps → qqs = p_b ^ q_e * qs →\n  p_b ^ (p_e + q_e) * (ps * qs) = psqs → pps * qqs = psqs\n:= λ ps_pf qs_pf psqs_pf, by simp [symm psqs_pf, pow_add, ps_pf, qs_pf]; ac_refl\n\nlemma mul_pp_pf_prod_lt {pps p ps qqs pqs : α} :\n  pps = p * ps → ps * qqs = pqs → pps * qqs = p * pqs := by cc\n\nlemma mul_pp_pf_prod_gt {pps qqs q qs pqs : α} :\n  qqs = q * qs → pps * qs = pqs → pps * qqs = q * pqs := by cc\n\n/--\nMultiply two expressions.\n\n* `x * y = (x * y)` (for `x`, `y` coefficients)\n* `x * (q * qs) = q * (qs * x)` (for `x` coefficient)\n* `(p * ps) * y = p * (ps * y)` (for `y` coefficient)\n* `(p_b^p_e * ps) * (p_b^q_e * qs) = p_b^(p_e + q_e) * (ps * qs)`\n    (if `p_e` and `q_e` are identical except coefficient)\n* `(p * ps) * (q * qs) = p * (ps * (q * qs))` (if `p.lt q`)\n* `(p * ps) * (q * qs) = q * ((p * ps) * qs)` (if not `p.lt q`)\n-/\nmeta def mul_pp : ex prod → ex prod → ring_exp_m (ex prod)\n| ps@(ex.coeff _ x) qs@(ex.coeff _ y) := do\n  pq ← mul_coeff ps.pretty qs.pretty x y,\n  pq_o ← mul_orig ps qs,\n  pf ← mk_proof_or_refl pq.pretty ``mul_pf_c_c\n    [ps.orig, ps.pretty, qs.orig, qs.pretty, pq.pretty]\n    [ps.info, qs.info, pq.info],\n  pure $ pq.set_info pq_o pf\n| ps@(ex.coeff _ x) qqs@(ex.prod _ q qs) := do\n  pqs ← mul_pp ps qs,\n  pqqs ← ex_prod q pqs,\n  pqqs_o ← mul_orig ps qqs,\n  pf ← mk_proof ``mul_pf_c_prod\n    [ps.orig, qqs.orig, q.pretty, qs.pretty, pqs.pretty]\n    [qqs.info, pqs.info],\n  pure $ pqqs.set_info pqqs_o pf\n| pps@(ex.prod _ p ps) qs@(ex.coeff _ y) := do\n  pqs ← mul_pp ps qs,\n  ppqs ← ex_prod p pqs,\n  ppqs_o ← mul_orig pps qs,\n  pf ← mk_proof ``mul_pf_prod_c\n    [pps.orig, p.pretty, ps.pretty, qs.orig, pqs.pretty]\n    [pps.info, pqs.info],\n  pure $ ppqs.set_info ppqs_o pf\n  | pps@(ex.prod _ p@(ex.exp _ p_b p_e) ps) qqs@(ex.prod _ q@(ex.exp _ q_b q_e) qs) := do\n  ppqqs_o ← mul_orig pps qqs,\n  pq_ol ← in_exponent $ add_overlap p_e q_e,\n  match pq_ol, p_b.eq q_b with\n  | (overlap.nonzero pq_e), tt := do\n    psqs ← mul_pp ps qs,\n    pq ← ex_exp p_b pq_e,\n    ppsqqs ← ex_prod pq psqs,\n    pf ← mk_proof ``mul_pp_pf_overlap\n      [pps.orig, p_b.pretty, ps.pretty, qqs.orig, qs.pretty, ppsqqs.pretty, p_e.pretty, q_e.pretty]\n      [pps.info, qqs.info, ppsqqs.info],\n    pure $ ppsqqs.set_info ppqqs_o pf\n  | _, _ := if p.lt q  then do\n    pqs ← mul_pp ps qqs,\n    ppqs ← ex_prod p pqs,\n    pf ← mk_proof ``mul_pp_pf_prod_lt\n      [pps.orig, p.pretty, ps.pretty, qqs.orig, pqs.pretty]\n      [pps.info, pqs.info],\n    pure $ ppqs.set_info ppqqs_o pf\n  else do\n    pqs ← mul_pp pps qs,\n    pqqs ← ex_prod q pqs,\n    pf ← mk_proof ``mul_pp_pf_prod_gt\n      [pps.orig, qqs.orig, q.pretty, qs.pretty, pqs.pretty]\n      [qqs.info, pqs.info],\n    pure $ pqqs.set_info ppqqs_o pf\n  end\n\nlemma mul_p_pf_zero {ps qs : α} : ps = 0 → ps * qs = 0 :=\nλ ps_pf, by rw [ps_pf, zero_mul]\n\nlemma mul_p_pf_sum {pps p ps qs ppsqs : α} : pps = p + ps →\n  p * qs + ps * qs = ppsqs → pps * qs = ppsqs := λ pps_pf ppsqs_pf, calc\n  pps * qs = (p + ps) * qs : by rw [pps_pf]\n  ... = p * qs + ps * qs : add_mul _ _ _\n  ... = ppsqs : ppsqs_pf\n\n/--\nMultiply two expressions.\n\n* `0 * qs = 0`\n* `(p + ps) * qs = (p * qs) + (ps * qs)`\n-/\nmeta def mul_p : ex sum → ex prod → ring_exp_m (ex sum)\n| ps@(ex.zero ps_i) qs := do\n  z ← ex_zero,\n  z_o ← mul_orig ps qs,\n  pf ← mk_proof ``mul_p_pf_zero [ps.orig, qs.orig] [ps.info],\n  pure $ z.set_info z_o pf\n| pps@(ex.sum pps_i p ps) qs := do\n  pqs ← mul_pp p qs >>= prod_to_sum,\n  psqs ← mul_p ps qs,\n  ppsqs ← add pqs psqs,\n  pps_pf ← pps.proof_term,\n  ppsqs_o ← mul_orig pps qs,\n  ppsqs_pf ← ppsqs.proof_term,\n  pf ← mk_proof ``mul_p_pf_sum\n    [pps.orig, p.pretty, ps.pretty, qs.orig, ppsqs.pretty]\n    [pps.info, ppsqs.info],\n  pure $ ppsqs.set_info ppsqs_o pf\n\nlemma mul_pf_zero {ps qs : α} : qs = 0 → ps * qs = 0 :=\nλ qs_pf, by rw [qs_pf, mul_zero]\n\nlemma mul_pf_sum {ps qqs q qs psqqs : α} : qqs = q + qs → ps * q + ps * qs = psqqs →\n  ps * qqs = psqqs := λ qs_pf psqqs_pf, calc\n  ps * qqs = ps * (q + qs) : by rw [qs_pf]\n  ... = ps * q + ps * qs : mul_add _ _ _\n  ... = psqqs : psqqs_pf\n\n/--\nMultiply two expressions.\n\n* `ps * 0 = 0`\n* `ps * (q + qs) = (ps * q) + (ps * qs)`\n-/\nmeta def mul : ex sum → ex sum → ring_exp_m (ex sum)\n| ps qs@(ex.zero qs_i) := do\n  z ← ex_zero,\n  z_o ← mul_orig ps qs,\n  pf ← mk_proof ``mul_pf_zero [ps.orig, qs.orig] [qs.info],\n  pure $ z.set_info z_o pf\n| ps qqs@(ex.sum qqs_i q qs) := do\n  psq ← mul_p ps q,\n  psqs ← mul ps qs,\n  psqqs ← add psq psqs,\n  psqqs_o ← mul_orig ps qqs,\n  pf ← mk_proof ``mul_pf_sum\n    [ps.orig, qqs.orig, q.orig, qs.orig, psqqs.pretty]\n    [qqs.info, psqqs.info],\n  pure $ psqqs.set_info psqqs_o pf\nend multiplication\n\nsection exponentiation\nlemma pow_e_pf_exp {pps p : α} {ps qs psqs : ℕ} :\n  pps = p ^ ps → ps * qs = psqs → pps ^ qs = p ^ psqs :=\nλ pps_pf psqs_pf, calc\n  pps ^ qs = (p ^ ps) ^ qs : by rw [pps_pf]\n  ... = p ^ (ps * qs) : symm (pow_mul _ _ _)\n  ... = p ^ psqs : by rw [psqs_pf]\n\n/--\nCompute the exponentiation of two coefficients.\n\nThe returned value is of the form `ex.coeff _ (p ^ q)`,\nwith the proof of `expr.of_rat p ^ expr.of_rat q = expr.of_rat (p ^ q)`.\n-/\nmeta def pow_coeff (p_p q_p : expr) (p q : coeff) : ring_exp_m (ex prod) := do\n  ctx ← get_context,\n  pq' ← mk_pow [p_p, q_p],\n  (pq_p, pq_pf) ← lift $ norm_num.eval_pow pq',\n  if q.value.denom ≠ 1 then lift $ fail!\"Only integer powers are supported, not {q.value}.\"\n  else pure $ ex.coeff ⟨pq_p, pq_p, pq_pf⟩ ⟨p.1 ^ q.value.num⟩\n\n/--\nExponentiate two expressions.\n\n* `(p ^ ps) ^ qs = p ^ (ps * qs)`\n-/\nmeta def pow_e : ex exp → ex prod → ring_exp_m (ex exp)\n| pps@(ex.exp pps_i p ps) qs := do\n  psqs ← in_exponent $ mul_pp ps qs,\n  ppsqs ← ex_exp p psqs,\n  ppsqs_o ← pow_orig pps qs,\n  pf ← mk_proof ``pow_e_pf_exp\n    [pps.orig, p.pretty, ps.pretty, qs.orig, psqs.pretty]\n    [pps.info, psqs.info],\n  pure $ ppsqs.set_info ppsqs_o pf\n\n\n\nlemma pow_pf_c_c {ps ps' pq : α} {qs qs' : ℕ} :\n  ps = ps' → qs = qs' → ps' ^ qs' = pq → ps ^ qs = pq := by cc\n\nlemma pow_pp_pf_c {ps ps' pqs : α} {qs qs' : ℕ} :\n  ps = ps' → qs = qs' → ps' ^ qs' = pqs → ps ^ qs = pqs * 1 :=\nby simp; cc\n\nlemma pow_pp_pf_prod {pps p ps pqs psqs : α} {qs : ℕ} : pps = p * ps →\n  p ^ qs = pqs → ps ^ qs = psqs → pps ^ qs = pqs * psqs :=\nλ pps_pf pqs_pf psqs_pf, calc\n    pps ^ qs = (p * ps) ^ qs : by rw [pps_pf]\n    ... = p ^ qs * ps ^ qs : mul_pow _ _ _\n    ... = pqs * psqs : by rw [pqs_pf, psqs_pf]\n\n/--\nExponentiate two expressions.\n\n* `1 ^ qs = 1`\n* `x ^ qs = x ^ qs` (for `x` coefficient)\n* `(p * ps) ^ qs = p ^ qs + ps ^ qs`\n-/\nmeta def pow_pp : ex prod → ex prod → ring_exp_m (ex prod)\n| ps@(ex.coeff ps_i ⟨⟨1, 1, _, _⟩⟩) qs := do\n  o ← ex_one,\n  o_o ← pow_orig ps qs,\n  pf ← mk_proof ``pow_pp_pf_one [ps.orig, qs.orig] [ps.info],\n  pure $ o.set_info o_o pf\n| ps@(ex.coeff ps_i x) qs@(ex.coeff qs_i y) := do\n  pq ← pow_coeff ps.pretty qs.pretty x y,\n  pq_o ← pow_orig ps qs,\n  pf ← mk_proof_or_refl pq.pretty ``pow_pf_c_c\n    [ps.orig, ps.pretty, pq.pretty, qs.orig, qs.pretty]\n    [ps.info, qs.info, pq.info],\n  pure $ pq.set_info pq_o pf\n| ps@(ex.coeff ps_i x) qs := do\n  ps'' ← pure ps >>= prod_to_sum >>= ex_sum_b,\n  pqs ← ex_exp ps'' qs,\n  pqs_o ← pow_orig ps qs,\n  pf ← mk_proof_or_refl pqs.pretty ``pow_pp_pf_c\n    [ps.orig, ps.pretty, pqs.pretty, qs.orig, qs.pretty]\n    [ps.info, qs.info, pqs.info],\n  pqs' ← exp_to_prod pqs,\n  pure $ pqs'.set_info pqs_o pf\n| pps@(ex.prod pps_i p ps) qs := do\n  pqs ← pow_e p qs,\n  psqs ← pow_pp ps qs,\n  ppsqs ← ex_prod pqs psqs,\n  ppsqs_o ← pow_orig pps qs,\n  pf ← mk_proof ``pow_pp_pf_prod\n    [pps.orig, p.pretty, ps.pretty, pqs.pretty, psqs.pretty, qs.orig]\n    [pps.info, pqs.info, psqs.info],\n  pure $ ppsqs.set_info ppsqs_o pf\n\nlemma pow_p_pf_one {ps ps' : α} {qs : ℕ} : ps = ps' → qs = succ zero → ps ^ qs = ps' :=\nλ ps_pf qs_pf, calc\n  ps ^ qs = ps' ^ 1 : by rw [ps_pf, qs_pf]\n  ... = ps' : pow_one _\n\nlemma pow_p_pf_zero {ps : α} {qs qs' : ℕ} : ps = 0 → qs = succ qs' → ps ^ qs = 0 :=\nλ ps_pf qs_pf, calc\n  ps ^ qs = 0 ^ (succ qs') : by rw [ps_pf, qs_pf]\n  ... = 0 : zero_pow (succ_pos qs')\n\nlemma pow_p_pf_succ {ps pqqs : α} {qs qs' : ℕ} :\n  qs = succ qs' → ps * ps ^ qs' = pqqs → ps ^ qs = pqqs :=\nλ qs_pf pqqs_pf, calc\n  ps ^ qs = ps ^ succ qs' : by rw [qs_pf]\n  ... = ps * ps ^ qs' : pow_succ _ _\n  ... = pqqs : by rw [pqqs_pf]\n\nlemma pow_p_pf_singleton {pps p pqs : α} {qs : ℕ} :\n  pps = p + 0 → p ^ qs = pqs → pps ^ qs = pqs :=\nλ pps_pf pqs_pf, by rw [pps_pf, add_zero, pqs_pf]\n\nlemma pow_p_pf_cons {ps ps' : α} {qs qs' : ℕ} :\n  ps = ps' → qs = qs' → ps ^ qs = ps' ^ qs' := by cc\n/--\nExponentiate two expressions.\n\n* `ps ^ 1 = ps`\n* `0 ^ qs = 0` (note that this is handled *after* `ps ^ 0 = 1`)\n* `(p + 0) ^ qs = p ^ qs`\n* `ps ^ (qs + 1) = ps * ps ^ qs` (note that this is handled *after* `p + 0 ^ qs = p ^ qs`)\n* `ps ^ qs = ps ^ qs` (otherwise)\n-/\nmeta def pow_p : ex sum → ex prod → ring_exp_m (ex sum)\n| ps qs@(ex.coeff qs_i ⟨⟨1, 1, _, _⟩⟩) := do\n  ps_o ← pow_orig ps qs,\n  pf ← mk_proof ``pow_p_pf_one [ps.orig, ps.pretty, qs.orig] [ps.info, qs.info],\n  pure $ ps.set_info ps_o pf\n| ps@(ex.zero ps_i) qs@(ex.coeff qs_i ⟨⟨succ y, 1, _, _⟩⟩) := do\n  ctx ← get_context,\n  z ← ex_zero,\n  qs_pred ← lift $ expr.of_nat ctx.info_e.α y,\n  pf ← mk_proof ``pow_p_pf_zero [ps.orig, qs.orig, qs_pred] [ps.info, qs.info],\n  z_o ← pow_orig ps qs,\n  pure $ z.set_info z_o pf\n| pps@(ex.sum pps_i p (ex.zero _)) qqs := do\n  pqs ← pow_pp p qqs,\n  pqs_o ← pow_orig pps qqs,\n  pf ← mk_proof ``pow_p_pf_singleton\n    [pps.orig, p.pretty, pqs.pretty, qqs.orig]\n    [pps.info, pqs.info],\n  prod_to_sum $ pqs.set_info pqs_o pf\n| ps qs@(ex.coeff qs_i ⟨⟨int.of_nat (succ n), 1, den_pos, _⟩⟩) := do\n  qs' ← in_exponent $ ex_coeff ⟨int.of_nat n, 1, den_pos, coprime_one_right _⟩,\n  pqs ← pow_p ps qs',\n  pqqs ← mul ps pqs,\n  pqqs_o ← pow_orig ps qs,\n  pf ← mk_proof ``pow_p_pf_succ\n    [ps.orig, pqqs.pretty, qs.orig, qs'.pretty]\n    [qs.info, pqqs.info],\n  pure $ pqqs.set_info pqqs_o pf\n| pps qqs := do -- fallback: treat them as atoms\n  pps' ← ex_sum_b pps,\n  psqs ← ex_exp pps' qqs,\n  psqs_o ← pow_orig pps qqs,\n  pf ← mk_proof_or_refl psqs.pretty ``pow_p_pf_cons\n    [pps.orig, pps.pretty, qqs.orig, qqs.pretty]\n    [pps.info, qqs.info],\n  exp_to_prod (psqs.set_info psqs_o pf) >>= prod_to_sum\n\nlemma pow_pf_zero {ps : α} {qs : ℕ} : qs = 0 → ps ^ qs = 1 := λ qs_pf, calc\n  ps ^ qs = ps ^ 0 : by rw [qs_pf]\n  ... = 1 : pow_zero _\n\nlemma pow_pf_sum {ps psqqs : α} {qqs q qs : ℕ} : qqs = q + qs →\n  ps ^ q * ps ^ qs = psqqs → ps ^ qqs = psqqs := λ qqs_pf psqqs_pf, calc\n    ps ^ qqs = ps ^ (q + qs) : by rw [qqs_pf]\n    ... = ps ^ q * ps ^ qs : pow_add _ _ _\n    ... = psqqs : psqqs_pf\n/--\nExponentiate two expressions.\n\n* `ps ^ 0 = 1`\n* `ps ^ (q + qs) = ps ^ q * ps ^ qs`\n-/\nmeta def pow : ex sum → ex sum → ring_exp_m (ex sum)\n| ps qs@(ex.zero qs_i) := do\n  o ← ex_one,\n  o_o ← pow_orig ps qs,\n  pf ← mk_proof ``pow_pf_zero [ps.orig, qs.orig] [qs.info],\n  prod_to_sum $ o.set_info o_o pf\n| ps qqs@(ex.sum qqs_i q qs) := do\n  psq ← pow_p ps q,\n  psqs ← pow ps qs,\n  psqqs ← mul psq psqs,\n  psqqs_o ← pow_orig ps qqs,\n  pf ← mk_proof ``pow_pf_sum\n    [ps.orig, psqqs.pretty, qqs.orig, q.pretty, qs.pretty]\n    [qqs.info, psqqs.info],\n  pure $ psqqs.set_info psqqs_o pf\n end exponentiation\n\nlemma simple_pf_sum_zero {p p' : α} : p = p' → p + 0 = p' := by simp\n\nlemma simple_pf_prod_one {p p' : α} : p = p' → p * 1 = p' := by simp\n\nlemma simple_pf_prod_neg_one {α} [ring α] {p p' : α} : p = p' → p * -1 = - p' := by simp\n\nlemma simple_pf_var_one (p : α) : p ^ 1 = p := by simp\n\nlemma simple_pf_exp_one {p p' : α} : p = p' → p ^ 1 = p' := by simp\n\n/--\nGive a simpler, more human-readable representation of the normalized expression.\n\nNormalized expressions might have the form `a^1 * 1 + 0`,\nsince the dummy operations reduce special cases in pattern-matching.\nHumans prefer to read `a` instead.\nThis tactic gets rid of the dummy additions, multiplications and exponentiations.\n\nReturns a normalized expression `e'` and a proof that `e.pretty = e'`.\n-/\nmeta def ex.simple : Π {et : ex_type}, ex et → ring_exp_m (expr × expr)\n| sum pps@(ex.sum pps_i p (ex.zero _)) := do\n  (p_p, p_pf) ← p.simple,\n  prod.mk p_p <$> mk_app_csr ``simple_pf_sum_zero [p.pretty, p_p, p_pf]\n| sum (ex.sum pps_i p ps) := do\n  (p_p, p_pf) ← p.simple,\n  (ps_p, ps_pf) ← ps.simple,\n  prod.mk\n    <$> mk_add [p_p, ps_p]\n    <*> mk_app_csr ``sum_congr [p.pretty, p_p, ps.pretty, ps_p, p_pf, ps_pf]\n| prod (ex.prod pps_i p (ex.coeff _ ⟨⟨1, 1, _, _⟩⟩)) := do\n  (p_p, p_pf) ← p.simple,\n  prod.mk p_p <$> mk_app_csr ``simple_pf_prod_one [p.pretty, p_p, p_pf]\n| prod pps@(ex.prod pps_i p (ex.coeff _ ⟨⟨-1, 1, _, _⟩⟩)) := do\n  ctx ← get_context,\n  match ctx.info_b.ring_instance with\n  | none := prod.mk pps.pretty <$> lift (mk_eq_refl pps.pretty)\n  | (some ringi) := do\n    (p_p, p_pf) ← p.simple,\n    prod.mk\n      <$> lift (mk_app ``has_neg.neg [p_p])\n      <*> mk_app_class ``simple_pf_prod_neg_one ringi [p.pretty, p_p, p_pf]\n  end\n| prod (ex.prod pps_i p ps) := do\n  (p_p, p_pf) ← p.simple,\n  (ps_p, ps_pf) ← ps.simple,\n  prod.mk\n    <$> mk_mul [p_p, ps_p]\n    <*> mk_app_csr ``prod_congr [p.pretty, p_p, ps.pretty, ps_p, p_pf, ps_pf]\n| base (ex.sum_b pps_i ps) := ps.simple\n| exp (ex.exp pps_i p (ex.coeff _ ⟨⟨1, 1, _, _⟩⟩)) := do\n  (p_p, p_pf) ← p.simple,\n  prod.mk p_p <$> mk_app_csr ``simple_pf_exp_one [p.pretty, p_p, p_pf]\n| exp (ex.exp pps_i p ps) := do\n  (p_p, p_pf) ← p.simple,\n  (ps_p, ps_pf) ← in_exponent $ ps.simple,\n  prod.mk\n    <$> mk_pow [p_p, ps_p]\n    <*> mk_app_csr ``exp_congr [p.pretty, p_p, ps.pretty, ps_p, p_pf, ps_pf]\n| et ps := prod.mk ps.pretty <$> lift (mk_eq_refl ps.pretty)\n\n/--\nPerforms a lookup of the atom `a` in the list of known atoms,\nor allocates a new one.\n\nIf `a` is not definitionally equal to any of the list's entries,\na new atom is appended to the list and returned.\nThe index of this atom is kept track of in the second inductive argument.\n\nThis function is mostly useful in `resolve_atom`,\nwhich updates the state with the new list of atoms.\n-/\nmeta def resolve_atom_aux (a : expr) : list atom → ℕ → ring_exp_m (atom × list atom)\n| [] n := let atm : atom := ⟨a, n⟩ in pure (atm, [atm])\n| bas@(b :: as) n := do\n  ctx ← get_context,\n  (lift $ is_def_eq a b.value ctx.transp >> pure (b , bas)) <|> do\n  (atm, as') ← resolve_atom_aux as (succ n),\n  pure (atm, b :: as')\n\n/--\nConvert the expression to an atom:\neither look up a definitionally equal atom,\nor allocate it as a new atom.\n\nYou probably want to use `eval_base` if `eval` doesn't work\ninstead of directly calling `resolve_atom`,\nsince `eval_base` can also handle numerals.\n-/\nmeta def resolve_atom (a : expr) : ring_exp_m atom := do\n  atoms ← reader_t.lift $ state_t.get,\n  (atm, atoms') ← resolve_atom_aux a atoms 0,\n  reader_t.lift $ state_t.put atoms',\n  pure atm\n\n/--\nTreat the expression atomically: as a coefficient or atom.\n\nHandles cases where `eval` cannot treat the expression as a known operation\nbecause it is just a number or single variable.\n-/\nmeta def eval_base (ps : expr) : ring_exp_m (ex sum) :=\nmatch ps.to_rat with\n| some ⟨0, 1, _, _⟩ := ex_zero\n| some x := ex_coeff x >>= prod_to_sum\n| none := do\n  a ← resolve_atom ps,\n  atom_to_sum a\nend\n\nlemma negate_pf {α} [ring α] {ps ps' : α} : (-1) * ps = ps' → -ps = ps' := by simp\n\n/--\nNegate an expression by multiplying with `-1`.\n\nOnly works if there is a `ring` instance; otherwise it will `fail`.\n-/\nmeta def negate (ps : ex sum) : ring_exp_m (ex sum) := do\n  ctx ← get_context,\n  match ctx.info_b.ring_instance with\n  | none := lift $ fail \"internal error: negate called in semiring\"\n  | (some ring_instance) := do\n    minus_one ← ex_coeff (-1) >>= prod_to_sum,\n    ps' ← mul minus_one ps,\n    ps_pf ← ps'.proof_term,\n    pf ← mk_app_class ``negate_pf ring_instance [ps.orig, ps'.pretty, ps_pf],\n    ps'_o ← lift $ mk_app ``has_neg.neg [ps.orig],\n    pure $ ps'.set_info ps'_o pf\n  end\n\nlemma inverse_pf {α} [division_ring α] {ps ps_u ps_p e' e'' : α} :\n  ps = ps_u → ps_u = ps_p → ps_p ⁻¹ = e' → e' = e'' → ps ⁻¹ = e'' :=\nby cc\n\n/--\nInvert an expression by simplifying, applying `has_inv.inv` and treating the result as an atom.\n\nOnly works if there is a `division_ring` instance; otherwise it will `fail`.\n-/\nmeta def inverse (ps : ex sum) : ring_exp_m (ex sum) := do\n  ctx ← get_context,\n  dri ← match ctx.info_b.dr_instance with\n  | none := lift $ fail \"division is only supported in a division ring\"\n  | (some dri) := pure dri\n  end,\n  (ps_simple, ps_simple_pf) ← ps.simple,\n  e ← lift $ mk_app ``has_inv.inv [ps_simple],\n  (e', e_pf) ← lift (norm_num.derive e) <|> ((λ e_pf, (e, e_pf)) <$> lift (mk_eq_refl e)),\n  e'' ← eval_base e',\n  ps_pf ← ps.proof_term,\n  e''_pf ← e''.proof_term,\n  pf ← mk_app_class ``inverse_pf dri\n    [ ps.orig, ps.pretty, ps_simple, e', e''.pretty,\n      ps_pf, ps_simple_pf, e_pf, e''_pf],\n  e''_o ← lift $ mk_app ``has_inv.inv [ps.orig],\n  pure $ e''.set_info e''_o pf\n\nlemma sub_pf {α} [ring α] {ps qs psqs : α} (h : ps + -qs = psqs) : ps - qs = psqs :=\nby rwa sub_eq_add_neg\n\nlemma div_pf {α} [division_ring α] {ps qs psqs : α} (h : ps * qs⁻¹ = psqs) : ps / qs = psqs :=\nby rwa div_eq_mul_inv\n\nend operations\n\nsection wiring\n/-!\n### `wiring` section\n\nThis section deals with going from `expr` to `ex` and back.\n\nThe main attraction is `eval`, which uses `add`, `mul`, etc.\nto calculate an `ex` from a given `expr`.\nOther functions use `ex`es to produce `expr`s together with a proof,\nor produce the context to run `ring_exp_m` from an `expr`.\n-/\n\nopen tactic\nopen ex_type\n\n/--\nCompute a normalized form (of type `ex`) from an expression (of type `expr`).\n\nThis is the main driver of the `ring_exp` tactic,\ncalling out to `add`, `mul`, `pow`, etc. to parse the `expr`.\n-/\nmeta def eval : expr → ring_exp_m (ex sum)\n| e@`(%%ps + %%qs) := do\n  ps' ← eval ps,\n  qs' ← eval qs,\n  add ps' qs'\n| ps_o@`(nat.succ %%p_o) := do\n  ps' ← eval `(%%p_o + 1),\n  pf ← lift $ mk_app ``nat.succ_eq_add_one [p_o],\n  rewrite ps_o ps' pf\n| e@`(%%ps - %%qs) := (do\n  ctx ← get_context,\n  ri ← match ctx.info_b.ring_instance with\n  | none := lift $ fail \"subtraction is not directly supported in a semiring\"\n  | (some ri) := pure ri\n  end,\n  ps' ← eval ps,\n  qs' ← eval qs >>= negate,\n  psqs ← add ps' qs',\n  psqs_pf ← psqs.proof_term,\n  pf ← mk_app_class ``sub_pf ri [ps, qs, psqs.pretty, psqs_pf],\n  pure (psqs.set_info e pf)) <|> eval_base e\n| e@`(- %%ps) := do\n  ps' ← eval ps,\n  negate ps' <|> eval_base e\n| e@`(%%ps * %%qs) := do\n  ps' ← eval ps,\n  qs' ← eval qs,\n  mul ps' qs'\n| e@`(has_inv.inv %%ps) := do\n  ps' ← eval ps,\n  inverse ps' <|> eval_base e\n| e@`(%%ps / %%qs) := do\n  ctx ← get_context,\n  dri ← match ctx.info_b.dr_instance with\n  | none := lift $ fail \"division is only directly supported in a division ring\"\n  | (some dri) := pure dri\n  end,\n  ps' ← eval ps,\n  qs' ← eval qs,\n  (do qs'' ← inverse qs',\n  psqs ← mul ps' qs'',\n  psqs_pf ← psqs.proof_term,\n  pf ← mk_app_class ``div_pf dri [ps, qs, psqs.pretty, psqs_pf],\n  pure (psqs.set_info e pf)) <|> eval_base e\n| e@`(@has_pow.pow _ _ %%hp_instance %%ps %%qs) := do\n  ctx ← get_context,\n  ps' ← eval ps,\n  qs' ← in_exponent $ eval qs,\n  psqs ← pow ps' qs',\n  psqs_pf ← psqs.proof_term,\n  (do\n    lift (is_def_eq hp_instance ctx.info_b.hp_instance\n          <|> fail \"has_pow instance must be nat.has_pow or monoid.has_pow\"),\n    has_pow_pf ← lift $ mk_eq_refl e,\n    pf ← lift $ mk_eq_trans has_pow_pf psqs_pf,\n    pure $ psqs.set_info e pf) <|> eval_base e\n| ps := eval_base ps\n\n/--\nRun `eval` on the expression and return the result together with normalization proof.\n\nSee also `eval_simple` if you want something that behaves like `norm_num`.\n-/\nmeta def eval_with_proof (e : expr) : ring_exp_m (ex sum × expr) := do\n  e' ← eval e,\n  prod.mk e' <$> e'.proof_term\n\n/--\nRun `eval` on the expression and simplify the result.\n\nReturns a simplified normalized expression, together with an equality proof.\n\nSee also `eval_with_proof` if you just want to check the equality of two expressions.\n-/\nmeta def eval_simple (e : expr) : ring_exp_m (expr × expr) := do\n  (complicated, complicated_pf) ← eval_with_proof e,\n  (simple, simple_pf) ← complicated.simple,\n  prod.mk simple <$> lift (mk_eq_trans complicated_pf simple_pf)\n\n/-- Compute the `eval_info` for a given type `α`. -/\nmeta def make_eval_info (α : expr) : tactic eval_info := do\n  u ← mk_meta_univ,\n  infer_type α >>= unify (expr.sort (level.succ u)),\n  u ← get_univ_assignment u,\n  csr_instance ← mk_app ``comm_semiring [α] >>= mk_instance,\n  ring_instance ← (some <$> (mk_app ``ring [α] >>= mk_instance) <|> pure none),\n  dr_instance ← (some <$> (mk_app ``division_ring [α] >>= mk_instance) <|> pure none),\n  ha_instance ← mk_app ``has_add [α] >>= mk_instance,\n  hm_instance ← mk_app ``has_mul [α] >>= mk_instance,\n  hp_instance ← mk_mapp ``monoid.has_pow [some α, none],\n  z ← mk_mapp ``has_zero.zero [α, none],\n  o ← mk_mapp ``has_one.one [α, none],\n  pure ⟨α, u, csr_instance, ha_instance, hm_instance, hp_instance, ring_instance, dr_instance, z, o⟩\n\n/-- Use `e` to build the context for running `mx`. -/\nmeta def run_ring_exp {α} (transp : transparency) (e : expr) (mx : ring_exp_m α) : tactic α := do\n  info_b ← infer_type e >>= make_eval_info,\n  info_e ← mk_const ``nat >>= make_eval_info,\n  (λ x : (_ × _), x.1) <$> (state_t.run (reader_t.run mx ⟨info_b, info_e, transp⟩) [])\n\n/-- Repeatedly apply `eval_simple` on (sub)expressions. -/\nmeta def normalize (transp : transparency) (e : expr) : tactic (expr × expr) := do\n  (_, e', pf') ← ext_simplify_core () {}\n  simp_lemmas.mk (λ _, failed) (λ _ _ _ _ e, do\n    (e'', pf) ← run_ring_exp transp e $ eval_simple e,\n    guard (¬ e'' =ₐ e),\n    return ((), e'', some pf, ff))\n  (λ _ _ _ _ _, failed) `eq e,\n  pure (e', pf')\nend wiring\nend tactic.ring_exp\n\nnamespace tactic.interactive\nopen interactive interactive.types lean.parser tactic tactic.ring_exp\n\nlocal postfix (name := parser.optional) `?`:9001 := optional\n\n/--\nTactic for solving equations of *commutative* (semi)rings,\nallowing variables in the exponent.\nThis version of `ring_exp` fails if the target is not an equality.\n\nThe variant `ring_exp_eq!` will use a more aggressive reducibility setting\nto determine equality of atoms.\n-/\nmeta def ring_exp_eq (red : parse (tk \"!\")?) : tactic unit := do\n  `(eq %%ps %%qs) ← target >>= whnf,\n\n  let transp := if red.is_some then semireducible else reducible,\n\n  ((ps', ps_pf), (qs', qs_pf)) ← run_ring_exp transp ps $\n    prod.mk <$> eval_with_proof ps <*> eval_with_proof qs,\n\n  if ps'.eq qs'\n  then do\n    qs_pf_inv ← mk_eq_symm qs_pf,\n    pf ← mk_eq_trans ps_pf qs_pf_inv,\n    tactic.interactive.exact ``(%%pf)\n  else fail \"ring_exp failed to prove equality\"\n\n/--\nTactic for evaluating expressions in *commutative* (semi)rings, allowing for variables in the\nexponent.\n\nThis tactic extends `ring`: it should solve every goal that `ring` can solve.\nAdditionally, it knows how to evaluate expressions with complicated exponents\n(where `ring` only understands constant exponents).\nThe variants `ring_exp!` and `ring_exp_eq!` use a more aggessive reducibility setting to determine\nequality of atoms.\n\nFor example:\n```lean\nexample (n : ℕ) (m : ℤ) : 2^(n+1) * m = 2 * 2^n * m := by ring_exp\nexample (a b : ℤ) (n : ℕ) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring_exp\nexample (x y : ℕ) : x + id y = y + id x := by ring_exp!\n```\n-/\nmeta def ring_exp (red : parse (tk \"!\")?) (loc : parse location) : tactic unit :=\n  match loc with\n  | interactive.loc.ns [none] := ring_exp_eq red\n  | _ := failed\n  end <|>\n  do ns ← loc.get_locals,\n  let transp := if red.is_some then semireducible else reducible,\n  tt ← tactic.replace_at (normalize transp) ns loc.include_goal\n  | fail \"ring_exp failed to simplify\",\n  when loc.include_goal $ try tactic.reflexivity\n\nadd_tactic_doc\n{ name        := \"ring_exp\",\n  category    := doc_category.tactic,\n  decl_names  := [`tactic.interactive.ring_exp],\n  tags        := [\"arithmetic\", \"simplification\", \"decision procedure\"] }\n\nend tactic.interactive\n\nnamespace conv.interactive\nopen conv interactive\nopen tactic tactic.interactive (ring_exp_eq)\nopen tactic.ring_exp (normalize)\n\nlocal postfix (name := parser.optional) `?`:9001 := optional\n\n/--\nNormalises expressions in commutative (semi-)rings inside of a `conv` block using the tactic\n`ring_exp`.\n-/\nmeta def ring_exp (red : parse (lean.parser.tk \"!\")?) : conv unit :=\nlet transp := if red.is_some then semireducible else reducible in\ndischarge_eq_lhs (ring_exp_eq red)\n<|> replace_lhs (normalize transp)\n<|> fail \"ring_exp failed to simplify\"\n\nend conv.interactive\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/tactic/ring_exp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.49051281998835755}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.fintype.big_operators\n! leanprover-community/mathlib commit 327c3c0d9232d80e250dc8f65e7835b82b266ea5\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Fintype.Option\nimport Mathbin.Data.Fintype.Powerset\nimport Mathbin.Data.Fintype.Sigma\nimport Mathbin.Data.Fintype.Sum\nimport Mathbin.Data.Fintype.Vector\nimport Mathbin.Algebra.BigOperators.Ring\nimport Mathbin.Algebra.BigOperators.Option\n\n/-!\nResults about \"big operations\" over a `fintype`, and consequent\nresults about cardinalities of certain types.\n\n## Implementation note\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\nThis content had previously been in `data.fintype.basic`, but was moved here to avoid\nrequiring `algebra.big_operators` (and hence many other imports) as a\ndependency of `fintype`.\n\nHowever many of the results here really belong in `algebra.big_operators.basic`\nand should be moved at some point.\n-/\n\n\nuniverse u v\n\nvariable {α : Type _} {β : Type _} {γ : Type _}\n\nopen BigOperators\n\nnamespace Fintype\n\n/- warning: fintype.prod_bool -> Fintype.prod_bool is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CommMonoid.{u1} α] (f : Bool -> α), Eq.{succ u1} α (Finset.prod.{u1, 0} α Bool _inst_1 (Finset.univ.{0} Bool Bool.fintype) (fun (b : Bool) => f b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (CommMonoid.toMonoid.{u1} α _inst_1)))) (f Bool.true) (f Bool.false))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CommMonoid.{u1} α] (f : Bool -> α), Eq.{succ u1} α (Finset.prod.{u1, 0} α Bool _inst_1 (Finset.univ.{0} Bool Bool.fintype) (fun (b : Bool) => f b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (CommMonoid.toMonoid.{u1} α _inst_1)))) (f Bool.true) (f Bool.false))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_bool Fintype.prod_boolₓ'. -/\n@[to_additive]\ntheorem prod_bool [CommMonoid α] (f : Bool → α) : (∏ b, f b) = f true * f false := by simp\n#align fintype.prod_bool Fintype.prod_bool\n#align fintype.sum_bool Fintype.sum_bool\n\n#print Fintype.card_eq_sum_ones /-\ntheorem card_eq_sum_ones {α} [Fintype α] : Fintype.card α = ∑ a : α, 1 :=\n  Finset.card_eq_sum_ones _\n#align fintype.card_eq_sum_ones Fintype.card_eq_sum_ones\n-/\n\nsection\n\nopen Finset\n\nvariable {ι : Type _} [DecidableEq ι] [Fintype ι]\n\n/- warning: fintype.prod_extend_by_one -> Fintype.prod_extend_by_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} ι] [_inst_2 : Fintype.{u2} ι] [_inst_3 : CommMonoid.{u1} α] (s : Finset.{u2} ι) (f : ι -> α), Eq.{succ u1} α (Finset.prod.{u1, u2} α ι _inst_3 (Finset.univ.{u2} ι _inst_2) (fun (i : ι) => ite.{succ u1} α (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) i s) (Finset.decidableMem.{u2} ι (fun (a : ι) (b : ι) => _inst_1 a b) i s) (f i) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (CommMonoid.toMonoid.{u1} α _inst_3)))))))) (Finset.prod.{u1, u2} α ι _inst_3 s (fun (i : ι) => f i))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} ι] [_inst_2 : Fintype.{u1} ι] [_inst_3 : CommMonoid.{u2} α] (s : Finset.{u1} ι) (f : ι -> α), Eq.{succ u2} α (Finset.prod.{u2, u1} α ι _inst_3 (Finset.univ.{u1} ι _inst_2) (fun (i : ι) => ite.{succ u2} α (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) (Finset.decidableMem.{u1} ι (fun (a : ι) (b : ι) => _inst_1 a b) i s) (f i) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (Monoid.toOne.{u2} α (CommMonoid.toMonoid.{u2} α _inst_3)))))) (Finset.prod.{u2, u1} α ι _inst_3 s (fun (i : ι) => f i))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_extend_by_one Fintype.prod_extend_by_oneₓ'. -/\n@[to_additive]\ntheorem prod_extend_by_one [CommMonoid α] (s : Finset ι) (f : ι → α) :\n    (∏ i, if i ∈ s then f i else 1) = ∏ i in s, f i := by\n  rw [← prod_filter, filter_mem_eq_inter, univ_inter]\n#align fintype.prod_extend_by_one Fintype.prod_extend_by_one\n#align fintype.sum_extend_by_zero Fintype.sum_extend_by_zero\n\nend\n\nsection\n\nvariable {M : Type _} [Fintype α] [CommMonoid M]\n\n/- warning: fintype.prod_eq_one -> Fintype.prod_eq_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : CommMonoid.{u2} M] (f : α -> M), (forall (a : α), Eq.{succ u2} M (f a) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2))))))) -> (Eq.{succ u2} M (Finset.prod.{u2, u1} M α _inst_2 (Finset.univ.{u1} α _inst_1) (fun (a : α) => f a)) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : CommMonoid.{u2} M] (f : α -> M), (forall (a : α), Eq.{succ u2} M (f a) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2))))) -> (Eq.{succ u2} M (Finset.prod.{u2, u1} M α _inst_2 (Finset.univ.{u1} α _inst_1) (fun (a : α) => f a)) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_eq_one Fintype.prod_eq_oneₓ'. -/\n@[to_additive]\ntheorem prod_eq_one (f : α → M) (h : ∀ a, f a = 1) : (∏ a, f a) = 1 :=\n  Finset.prod_eq_one fun a ha => h a\n#align fintype.prod_eq_one Fintype.prod_eq_one\n#align fintype.sum_eq_zero Fintype.sum_eq_zero\n\n#print Fintype.prod_congr /-\n@[to_additive]\ntheorem prod_congr (f g : α → M) (h : ∀ a, f a = g a) : (∏ a, f a) = ∏ a, g a :=\n  Finset.prod_congr rfl fun a ha => h a\n#align fintype.prod_congr Fintype.prod_congr\n#align fintype.sum_congr Fintype.sum_congr\n-/\n\n/- warning: fintype.prod_eq_single -> Fintype.prod_eq_single is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : CommMonoid.{u2} M] {f : α -> M} (a : α), (forall (x : α), (Ne.{succ u1} α x a) -> (Eq.{succ u2} M (f x) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2)))))))) -> (Eq.{succ u2} M (Finset.prod.{u2, u1} M α _inst_2 (Finset.univ.{u1} α _inst_1) (fun (x : α) => f x)) (f a))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : CommMonoid.{u1} M] {f : α -> M} (a : α), (forall (x : α), (Ne.{succ u2} α x a) -> (Eq.{succ u1} M (f x) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_2)))))) -> (Eq.{succ u1} M (Finset.prod.{u1, u2} M α _inst_2 (Finset.univ.{u2} α _inst_1) (fun (x : α) => f x)) (f a))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_eq_single Fintype.prod_eq_singleₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » a) -/\n@[to_additive]\ntheorem prod_eq_single {f : α → M} (a : α) (h : ∀ (x) (_ : x ≠ a), f x = 1) : (∏ x, f x) = f a :=\n  Finset.prod_eq_single a (fun x _ hx => h x hx) fun ha => (ha (Finset.mem_univ a)).elim\n#align fintype.prod_eq_single Fintype.prod_eq_single\n#align fintype.sum_eq_single Fintype.sum_eq_single\n\n/- warning: fintype.prod_eq_mul -> Fintype.prod_eq_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : CommMonoid.{u2} M] {f : α -> M} (a : α) (b : α), (Ne.{succ u1} α a b) -> (forall (x : α), (And (Ne.{succ u1} α x a) (Ne.{succ u1} α x b)) -> (Eq.{succ u2} M (f x) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2)))))))) -> (Eq.{succ u2} M (Finset.prod.{u2, u1} M α _inst_2 (Finset.univ.{u1} α _inst_1) (fun (x : α) => f x)) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2)))) (f a) (f b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : CommMonoid.{u1} M] {f : α -> M} (a : α) (b : α), (Ne.{succ u2} α a b) -> (forall (x : α), (And (Ne.{succ u2} α x a) (Ne.{succ u2} α x b)) -> (Eq.{succ u1} M (f x) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_2)))))) -> (Eq.{succ u1} M (Finset.prod.{u1, u2} M α _inst_2 (Finset.univ.{u2} α _inst_1) (fun (x : α) => f x)) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_2)))) (f a) (f b)))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_eq_mul Fintype.prod_eq_mulₓ'. -/\n@[to_additive]\ntheorem prod_eq_mul {f : α → M} (a b : α) (h₁ : a ≠ b) (h₂ : ∀ x, x ≠ a ∧ x ≠ b → f x = 1) :\n    (∏ x, f x) = f a * f b := by\n  apply Finset.prod_eq_mul a b h₁ fun x _ hx => h₂ x hx <;>\n    exact fun hc => (hc (Finset.mem_univ _)).elim\n#align fintype.prod_eq_mul Fintype.prod_eq_mul\n#align fintype.sum_eq_add Fintype.sum_eq_add\n\n#print Fintype.eq_of_subsingleton_of_prod_eq /-\n/-- If a product of a `finset` of a subsingleton type has a given\nvalue, so do the terms in that product. -/\n@[to_additive\n      \"If a sum of a `finset` of a subsingleton type has a given\\nvalue, so do the terms in that sum.\"]\ntheorem eq_of_subsingleton_of_prod_eq {ι : Type _} [Subsingleton ι] {s : Finset ι} {f : ι → M}\n    {b : M} (h : (∏ i in s, f i) = b) : ∀ i ∈ s, f i = b :=\n  Finset.eq_of_card_le_one_of_prod_eq (Finset.card_le_one_of_subsingleton s) h\n#align fintype.eq_of_subsingleton_of_prod_eq Fintype.eq_of_subsingleton_of_prod_eq\n#align fintype.eq_of_subsingleton_of_sum_eq Fintype.eq_of_subsingleton_of_sum_eq\n-/\n\nend\n\nend Fintype\n\nopen Finset\n\nsection\n\nvariable {M : Type _} [Fintype α] [CommMonoid M]\n\n/- warning: fintype.prod_option -> Fintype.prod_option is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : CommMonoid.{u2} M] (f : (Option.{u1} α) -> M), Eq.{succ u2} M (Finset.prod.{u2, u1} M (Option.{u1} α) _inst_2 (Finset.univ.{u1} (Option.{u1} α) (Option.fintype.{u1} α _inst_1)) (fun (i : Option.{u1} α) => f i)) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_2)))) (f (Option.none.{u1} α)) (Finset.prod.{u2, u1} M α _inst_2 (Finset.univ.{u1} α _inst_1) (fun (i : α) => f (Option.some.{u1} α i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : CommMonoid.{u1} M] (f : (Option.{u2} α) -> M), Eq.{succ u1} M (Finset.prod.{u1, u2} M (Option.{u2} α) _inst_2 (Finset.univ.{u2} (Option.{u2} α) (instFintypeOption.{u2} α _inst_1)) (fun (i : Option.{u2} α) => f i)) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_2)))) (f (Option.none.{u2} α)) (Finset.prod.{u1, u2} M α _inst_2 (Finset.univ.{u2} α _inst_1) (fun (i : α) => f (Option.some.{u2} α i))))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_option Fintype.prod_optionₓ'. -/\n@[simp, to_additive]\ntheorem Fintype.prod_option (f : Option α → M) : (∏ i, f i) = f none * ∏ i, f (some i) :=\n  Finset.prod_insertNone f univ\n#align fintype.prod_option Fintype.prod_option\n#align fintype.sum_option Fintype.sum_option\n\nend\n\nopen Finset\n\n/- warning: fintype.card_sigma -> Fintype.card_sigma is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (β : α -> Type.{u2}) [_inst_1 : Fintype.{u1} α] [_inst_2 : forall (a : α), Fintype.{u2} (β a)], Eq.{1} Nat (Fintype.card.{max u1 u2} (Sigma.{u1, u2} α β) (Sigma.fintype.{u1, u2} α β _inst_1 (fun (a : α) => _inst_2 a))) (Finset.sum.{0, u1} Nat α Nat.addCommMonoid (Finset.univ.{u1} α _inst_1) (fun (a : α) => Fintype.card.{u2} (β a) (_inst_2 a)))\nbut is expected to have type\n  forall {α : Type.{u2}} (β : α -> Type.{u1}) [_inst_1 : Fintype.{u2} α] [_inst_2 : forall (a : α), Fintype.{u1} (β a)], Eq.{1} Nat (Fintype.card.{max u1 u2} (Sigma.{u2, u1} α β) (instFintypeSigma.{u2, u1} α β _inst_1 (fun (a : α) => _inst_2 a))) (Finset.sum.{0, u2} Nat α Nat.addCommMonoid (Finset.univ.{u2} α _inst_1) (fun (a : α) => Fintype.card.{u1} (β a) (_inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align fintype.card_sigma Fintype.card_sigmaₓ'. -/\n@[simp]\ntheorem Fintype.card_sigma {α : Type _} (β : α → Type _) [Fintype α] [∀ a, Fintype (β a)] :\n    Fintype.card (Sigma β) = ∑ a, Fintype.card (β a) :=\n  card_sigma _ _\n#align fintype.card_sigma Fintype.card_sigma\n\n/- warning: finset.card_pi -> Finset.card_pi is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {δ : α -> Type.{u2}} (s : Finset.{u1} α) (t : forall (a : α), Finset.{u2} (δ a)), Eq.{1} Nat (Finset.card.{max u1 u2} (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (δ a)) (Finset.pi.{u1, u2} α (fun (a : α) => δ a) (fun (a : α) (b : α) => _inst_1 a b) s t)) (Finset.prod.{0, u1} Nat α Nat.commMonoid s (fun (a : α) => Finset.card.{u2} (δ a) (t a)))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] {δ : α -> Type.{u1}} (s : Finset.{u2} α) (t : forall (a : α), Finset.{u1} (δ a)), Eq.{1} Nat (Finset.card.{max u2 u1} (forall (a : α), (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a s) -> (δ a)) (Finset.pi.{u1, u2} α (fun (a : α) => δ a) (fun (a : α) (b : α) => _inst_1 a b) s t)) (Finset.prod.{0, u2} Nat α Nat.commMonoid s (fun (a : α) => Finset.card.{u1} (δ a) (t a)))\nCase conversion may be inaccurate. Consider using '#align finset.card_pi Finset.card_piₓ'. -/\n@[simp]\ntheorem Finset.card_pi [DecidableEq α] {δ : α → Type _} (s : Finset α) (t : ∀ a, Finset (δ a)) :\n    (s.pi t).card = ∏ a in s, card (t a) :=\n  Multiset.card_pi _ _\n#align finset.card_pi Finset.card_pi\n\n/- warning: fintype.card_pi_finset -> Fintype.card_piFinset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} α] {δ : α -> Type.{u2}} (t : forall (a : α), Finset.{u2} (δ a)), Eq.{1} Nat (Finset.card.{max u1 u2} (forall (a : α), δ a) (Fintype.piFinset.{u1, u2} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => δ a) t)) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Finset.univ.{u1} α _inst_2) (fun (a : α) => Finset.card.{u2} (δ a) (t a)))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : Fintype.{u2} α] {δ : α -> Type.{u1}} (t : forall (a : α), Finset.{u1} (δ a)), Eq.{1} Nat (Finset.card.{max u2 u1} (forall (a : α), δ a) (Fintype.piFinset.{u2, u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => δ a) t)) (Finset.prod.{0, u2} Nat α Nat.commMonoid (Finset.univ.{u2} α _inst_2) (fun (a : α) => Finset.card.{u1} (δ a) (t a)))\nCase conversion may be inaccurate. Consider using '#align fintype.card_pi_finset Fintype.card_piFinsetₓ'. -/\n@[simp]\ntheorem Fintype.card_piFinset [DecidableEq α] [Fintype α] {δ : α → Type _} (t : ∀ a, Finset (δ a)) :\n    (Fintype.piFinset t).card = ∏ a, card (t a) := by simp [Fintype.piFinset, card_map]\n#align fintype.card_pi_finset Fintype.card_piFinset\n\n#print Fintype.card_pi /-\n@[simp]\ntheorem Fintype.card_pi {β : α → Type _} [DecidableEq α] [Fintype α] [f : ∀ a, Fintype (β a)] :\n    Fintype.card (∀ a, β a) = ∏ a, Fintype.card (β a) :=\n  Fintype.card_piFinset _\n#align fintype.card_pi Fintype.card_pi\n-/\n\n/- warning: fintype.card_fun -> Fintype.card_fun is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} α] [_inst_3 : Fintype.{u2} β], Eq.{1} Nat (Fintype.card.{max u1 u2} (α -> β) (Pi.fintype.{u1, u2} α (fun (ᾰ : α) => β) (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => _inst_3))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (Fintype.card.{u2} β _inst_3) (Fintype.card.{u1} α _inst_2))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : Fintype.{u2} α] [_inst_3 : Fintype.{u1} β], Eq.{1} Nat (Fintype.card.{max u2 u1} (α -> β) (Pi.fintype.{u2, u1} α (fun (ᾰ : α) => β) (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => _inst_3))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (Fintype.card.{u1} β _inst_3) (Fintype.card.{u2} α _inst_2))\nCase conversion may be inaccurate. Consider using '#align fintype.card_fun Fintype.card_funₓ'. -/\n-- FIXME ouch, this should be in the main file.\n@[simp]\ntheorem Fintype.card_fun [DecidableEq α] [Fintype α] [Fintype β] :\n    Fintype.card (α → β) = Fintype.card β ^ Fintype.card α := by\n  rw [Fintype.card_pi, Finset.prod_const] <;> rfl\n#align fintype.card_fun Fintype.card_fun\n\n#print card_vector /-\n@[simp]\ntheorem card_vector [Fintype α] (n : ℕ) : Fintype.card (Vector α n) = Fintype.card α ^ n := by\n  rw [Fintype.ofEquiv_card] <;> simp\n#align card_vector card_vector\n-/\n\n/- warning: finset.prod_attach_univ -> Finset.prod_attach_univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : CommMonoid.{u2} β] (f : (Subtype.{succ u1} α (fun (a : α) => Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a (Finset.univ.{u1} α _inst_1))) -> β), Eq.{succ u2} β (Finset.prod.{u2, u1} β (Subtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x (Finset.univ.{u1} α _inst_1))) _inst_2 (Finset.attach.{u1} α (Finset.univ.{u1} α _inst_1)) (fun (x : Subtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x (Finset.univ.{u1} α _inst_1))) => f x)) (Finset.prod.{u2, u1} β α _inst_2 (Finset.univ.{u1} α _inst_1) (fun (x : α) => f (Subtype.mk.{succ u1} α (fun (a : α) => Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a (Finset.univ.{u1} α _inst_1)) x (Finset.mem_univ.{u1} α _inst_1 x))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : CommMonoid.{u1} β] (f : (Subtype.{succ u2} α (fun (a : α) => Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a (Finset.univ.{u2} α _inst_1))) -> β), Eq.{succ u1} β (Finset.prod.{u1, u2} β (Subtype.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) x (Finset.univ.{u2} α _inst_1))) _inst_2 (Finset.attach.{u2} α (Finset.univ.{u2} α _inst_1)) (fun (x : Subtype.{succ u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) x (Finset.univ.{u2} α _inst_1))) => f x)) (Finset.prod.{u1, u2} β α _inst_2 (Finset.univ.{u2} α _inst_1) (fun (x : α) => f (Subtype.mk.{succ u2} α (fun (a : α) => Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a (Finset.univ.{u2} α _inst_1)) x (Finset.mem_univ.{u2} α _inst_1 x))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_attach_univ Finset.prod_attach_univₓ'. -/\n@[simp, to_additive]\ntheorem Finset.prod_attach_univ [Fintype α] [CommMonoid β] (f : { a : α // a ∈ @univ α _ } → β) :\n    (∏ x in univ.attach, f x) = ∏ x, f ⟨x, mem_univ _⟩ :=\n  Fintype.prod_equiv (Equiv.subtypeUnivEquiv fun x => mem_univ _) _ _ fun x => by simp\n#align finset.prod_attach_univ Finset.prod_attach_univ\n#align finset.sum_attach_univ Finset.sum_attach_univ\n\n/- warning: finset.prod_univ_pi -> Finset.prod_univ_pi is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} α] [_inst_3 : CommMonoid.{u2} β] {δ : α -> Type.{u3}} {t : forall (a : α), Finset.{u3} (δ a)} (f : (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a (Finset.univ.{u1} α _inst_2)) -> (δ a)) -> β), Eq.{succ u2} β (Finset.prod.{u2, max u1 u3} β (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a (Finset.univ.{u1} α _inst_2)) -> (δ a)) _inst_3 (Finset.pi.{u1, u3} α (fun (a : α) => δ a) (fun (a : α) (b : α) => _inst_1 a b) (Finset.univ.{u1} α _inst_2) t) (fun (x : forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a (Finset.univ.{u1} α _inst_2)) -> (δ a)) => f x)) (Finset.prod.{u2, max u1 u3} β (forall (a : α), δ a) _inst_3 (Fintype.piFinset.{u1, u3} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => δ a) t) (fun (x : forall (a : α), δ a) => f (fun (a : α) (_x : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a (Finset.univ.{u1} α _inst_2)) => x a)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u3} α] [_inst_2 : Fintype.{u3} α] [_inst_3 : CommMonoid.{u2} β] {δ : α -> Type.{u1}} {t : forall (a : α), Finset.{u1} (δ a)} (f : (forall (a : α), (Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a (Finset.univ.{u3} α _inst_2)) -> (δ a)) -> β), Eq.{succ u2} β (Finset.prod.{u2, max u3 u1} β (forall (a : α), (Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a (Finset.univ.{u3} α _inst_2)) -> (δ a)) _inst_3 (Finset.pi.{u1, u3} α (fun (a : α) => δ a) (fun (a : α) (b : α) => _inst_1 a b) (Finset.univ.{u3} α _inst_2) t) (fun (x : forall (a : α), (Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a (Finset.univ.{u3} α _inst_2)) -> (δ a)) => f x)) (Finset.prod.{u2, max u1 u3} β (forall (a : α), δ a) _inst_3 (Fintype.piFinset.{u3, u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => δ a) t) (fun (x : forall (a : α), δ a) => f (fun (a : α) (_x : Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a (Finset.univ.{u3} α _inst_2)) => x a)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_univ_pi Finset.prod_univ_piₓ'. -/\n/-- Taking a product over `univ.pi t` is the same as taking the product over `fintype.pi_finset t`.\n  `univ.pi t` and `fintype.pi_finset t` are essentially the same `finset`, but differ\n  in the type of their element, `univ.pi t` is a `finset (Π a ∈ univ, t a)` and\n  `fintype.pi_finset t` is a `finset (Π a, t a)`. -/\n@[to_additive\n      \"Taking a sum over `univ.pi t` is the same as taking the sum over\\n  `fintype.pi_finset t`. `univ.pi t` and `fintype.pi_finset t` are essentially the same `finset`,\\n  but differ in the type of their element, `univ.pi t` is a `finset (Π a ∈ univ, t a)` and\\n  `fintype.pi_finset t` is a `finset (Π a, t a)`.\"]\ntheorem Finset.prod_univ_pi [DecidableEq α] [Fintype α] [CommMonoid β] {δ : α → Type _}\n    {t : ∀ a : α, Finset (δ a)} (f : (∀ a : α, a ∈ (univ : Finset α) → δ a) → β) :\n    (∏ x in univ.pi t, f x) = ∏ x in Fintype.piFinset t, f fun a _ => x a :=\n  prod_bij (fun x _ a => x a (mem_univ _)) (by simp) (by simp)\n    (by simp (config := { contextual := true }) [Function.funext_iff]) fun x hx =>\n    ⟨fun a _ => x a, by simp_all⟩\n#align finset.prod_univ_pi Finset.prod_univ_pi\n#align finset.sum_univ_pi Finset.sum_univ_pi\n\n/- warning: finset.prod_univ_sum -> Finset.prod_univ_sum is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} [_inst_1 : DecidableEq.{succ u_1} α] [_inst_2 : Fintype.{u_1} α] [_inst_3 : CommSemiring.{u_2} β] {δ : α -> Type.{u_1}} [_inst_4 : forall (a : α), DecidableEq.{succ u_1} (δ a)] {t : forall (a : α), Finset.{u_1} (δ a)} {f : forall (a : α), (δ a) -> β}, Eq.{succ u_2} β (Finset.prod.{u_2, u_1} β α (CommSemiring.toCommMonoid.{u_2} β _inst_3) (Finset.univ.{u_1} α _inst_2) (fun (a : α) => Finset.sum.{u_2, u_1} β (δ a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_2} β (Semiring.toNonAssocSemiring.{u_2} β (CommSemiring.toSemiring.{u_2} β _inst_3)))) (t a) (fun (b : δ a) => f a b))) (Finset.sum.{u_2, u_1} β (forall (a : α), δ a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_2} β (Semiring.toNonAssocSemiring.{u_2} β (CommSemiring.toSemiring.{u_2} β _inst_3)))) (Fintype.piFinset.{u_1, u_1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => δ a) t) (fun (p : forall (a : α), δ a) => Finset.prod.{u_2, u_1} β α (CommSemiring.toCommMonoid.{u_2} β _inst_3) (Finset.univ.{u_1} α _inst_2) (fun (x : α) => f x (p x))))\nbut is expected to have type\n  forall {α : Type.{u_2}} {β : Type.{u_3}} [_inst_1 : DecidableEq.{succ u_2} α] [_inst_2 : Fintype.{u_2} α] [_inst_3 : CommSemiring.{u_3} β] {δ : α -> Type.{u_1}} [_inst_4 : forall (a : α), DecidableEq.{succ u_1} (δ a)] {t : forall (a : α), Finset.{u_1} (δ a)} {f : forall (a : α), (δ a) -> β}, Eq.{succ u_3} β (Finset.prod.{u_3, u_2} β α (CommSemiring.toCommMonoid.{u_3} β _inst_3) (Finset.univ.{u_2} α _inst_2) (fun (a : α) => Finset.sum.{u_3, u_1} β (δ a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_3} β (Semiring.toNonAssocSemiring.{u_3} β (CommSemiring.toSemiring.{u_3} β _inst_3)))) (t a) (fun (b : δ a) => f a b))) (Finset.sum.{u_3, max u_1 u_2} β (forall (a : α), δ a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_3} β (Semiring.toNonAssocSemiring.{u_3} β (CommSemiring.toSemiring.{u_3} β _inst_3)))) (Fintype.piFinset.{u_2, u_1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 (fun (a : α) => δ a) t) (fun (p : forall (a : α), δ a) => Finset.prod.{u_3, u_2} β α (CommSemiring.toCommMonoid.{u_3} β _inst_3) (Finset.univ.{u_2} α _inst_2) (fun (x : α) => f x (p x))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_univ_sum Finset.prod_univ_sumₓ'. -/\n/-- The product over `univ` of a sum can be written as a sum over the product of sets,\n  `fintype.pi_finset`. `finset.prod_sum` is an alternative statement when the product is not\n  over `univ` -/\ntheorem Finset.prod_univ_sum [DecidableEq α] [Fintype α] [CommSemiring β] {δ : α → Type u_1}\n    [∀ a : α, DecidableEq (δ a)] {t : ∀ a : α, Finset (δ a)} {f : ∀ a : α, δ a → β} :\n    (∏ a, ∑ b in t a, f a b) = ∑ p in Fintype.piFinset t, ∏ x, f x (p x) := by\n  simp only [Finset.prod_attach_univ, prod_sum, Finset.sum_univ_pi]\n#align finset.prod_univ_sum Finset.prod_univ_sum\n\n/- warning: fintype.sum_pow_mul_eq_add_pow -> Fintype.sum_pow_mul_eq_add_pow is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Fintype.{u1} α] {R : Type.{u2}} [_inst_2 : CommSemiring.{u2} R] (a : R) (b : R), Eq.{succ u2} R (Finset.sum.{u2, u1} R (Finset.{u1} α) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_2)))) (Finset.univ.{u1} (Finset.{u1} α) (Finset.fintype.{u1} α _inst_1)) (fun (s : Finset.{u1} α) => HMul.hMul.{u2, u2, u2} R R R (instHMul.{u2} R (Distrib.toHasMul.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_2)))))) (HPow.hPow.{u2, 0, u2} R Nat R (instHPow.{u2, 0} R Nat (Monoid.Pow.{u2} R (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_2))))) a (Finset.card.{u1} α s)) (HPow.hPow.{u2, 0, u2} R Nat R (instHPow.{u2, 0} R Nat (Monoid.Pow.{u2} R (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_2))))) b (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Fintype.card.{u1} α _inst_1) (Finset.card.{u1} α s))))) (HPow.hPow.{u2, 0, u2} R Nat R (instHPow.{u2, 0} R Nat (Monoid.Pow.{u2} R (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_2))))) (HAdd.hAdd.{u2, u2, u2} R R R (instHAdd.{u2} R (Distrib.toHasAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_2)))))) a b) (Fintype.card.{u1} α _inst_1))\nbut is expected to have type\n  forall (α : Type.{u2}) [_inst_1 : Fintype.{u2} α] {R : Type.{u1}} [_inst_2 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (Finset.sum.{u1, u2} R (Finset.{u2} α) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_2)))) (Finset.univ.{u2} (Finset.{u2} α) (Finset.fintype.{u2} α _inst_1)) (fun (s : Finset.{u2} α) => HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_2))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_2))))) a (Finset.card.{u2} α s)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_2))))) b (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Fintype.card.{u2} α _inst_1) (Finset.card.{u2} α s))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_2))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_2)))))) a b) (Fintype.card.{u2} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align fintype.sum_pow_mul_eq_add_pow Fintype.sum_pow_mul_eq_add_powₓ'. -/\n/-- Summing `a^s.card * b^(n-s.card)` over all finite subsets `s` of a fintype of cardinality `n`\ngives `(a + b)^n`. The \"good\" proof involves expanding along all coordinates using the fact that\n`x^n` is multilinear, but multilinear maps are only available now over rings, so we give instead\na proof reducing to the usual binomial theorem to have a result over semirings. -/\ntheorem Fintype.sum_pow_mul_eq_add_pow (α : Type _) [Fintype α] {R : Type _} [CommSemiring R]\n    (a b : R) :\n    (∑ s : Finset α, a ^ s.card * b ^ (Fintype.card α - s.card)) = (a + b) ^ Fintype.card α :=\n  Finset.sum_pow_mul_eq_add_pow _ _ _\n#align fintype.sum_pow_mul_eq_add_pow Fintype.sum_pow_mul_eq_add_pow\n\n/- warning: function.bijective.prod_comp -> Function.Bijective.prod_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] [_inst_3 : CommMonoid.{u3} γ] {f : α -> β}, (Function.Bijective.{succ u1, succ u2} α β f) -> (forall (g : β -> γ), Eq.{succ u3} γ (Finset.prod.{u3, u1} γ α _inst_3 (Finset.univ.{u1} α _inst_1) (fun (i : α) => g (f i))) (Finset.prod.{u3, u2} γ β _inst_3 (Finset.univ.{u2} β _inst_2) (fun (i : β) => g i)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : Fintype.{u3} α] [_inst_2 : Fintype.{u2} β] [_inst_3 : CommMonoid.{u1} γ] {f : α -> β}, (Function.Bijective.{succ u3, succ u2} α β f) -> (forall (g : β -> γ), Eq.{succ u1} γ (Finset.prod.{u1, u3} γ α _inst_3 (Finset.univ.{u3} α _inst_1) (fun (i : α) => g (f i))) (Finset.prod.{u1, u2} γ β _inst_3 (Finset.univ.{u2} β _inst_2) (fun (i : β) => g i)))\nCase conversion may be inaccurate. Consider using '#align function.bijective.prod_comp Function.Bijective.prod_compₓ'. -/\n@[to_additive]\ntheorem Function.Bijective.prod_comp [Fintype α] [Fintype β] [CommMonoid γ] {f : α → β}\n    (hf : Function.Bijective f) (g : β → γ) : (∏ i, g (f i)) = ∏ i, g i :=\n  Fintype.prod_bijective f hf _ _ fun x => rfl\n#align function.bijective.prod_comp Function.Bijective.prod_comp\n#align function.bijective.sum_comp Function.Bijective.sum_comp\n\n/- warning: equiv.prod_comp -> Equiv.prod_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] [_inst_3 : CommMonoid.{u3} γ] (e : Equiv.{succ u1, succ u2} α β) (f : β -> γ), Eq.{succ u3} γ (Finset.prod.{u3, u1} γ α _inst_3 (Finset.univ.{u1} α _inst_1) (fun (i : α) => f (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} α β) (fun (_x : Equiv.{succ u1, succ u2} α β) => α -> β) (Equiv.hasCoeToFun.{succ u1, succ u2} α β) e i))) (Finset.prod.{u3, u2} γ β _inst_3 (Finset.univ.{u2} β _inst_2) (fun (i : β) => f i))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : Fintype.{u3} α] [_inst_2 : Fintype.{u2} β] [_inst_3 : CommMonoid.{u1} γ] (e : Equiv.{succ u3, succ u2} α β) (f : β -> γ), Eq.{succ u1} γ (Finset.prod.{u1, u3} γ α _inst_3 (Finset.univ.{u3} α _inst_1) (fun (i : α) => f (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (Equiv.{succ u3, succ u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} α β) e i))) (Finset.prod.{u1, u2} γ β _inst_3 (Finset.univ.{u2} β _inst_2) (fun (i : β) => f i))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comp Equiv.prod_compₓ'. -/\n@[to_additive]\ntheorem Equiv.prod_comp [Fintype α] [Fintype β] [CommMonoid γ] (e : α ≃ β) (f : β → γ) :\n    (∏ i, f (e i)) = ∏ i, f i :=\n  e.Bijective.prod_comp f\n#align equiv.prod_comp Equiv.prod_comp\n#align equiv.sum_comp Equiv.sum_comp\n\n/- warning: equiv.prod_comp' -> Equiv.prod_comp' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] [_inst_3 : CommMonoid.{u3} γ] (e : Equiv.{succ u1, succ u2} α β) (f : α -> γ) (g : β -> γ), (forall (i : α), Eq.{succ u3} γ (f i) (g (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} α β) (fun (_x : Equiv.{succ u1, succ u2} α β) => α -> β) (Equiv.hasCoeToFun.{succ u1, succ u2} α β) e i))) -> (Eq.{succ u3} γ (Finset.prod.{u3, u1} γ α _inst_3 (Finset.univ.{u1} α _inst_1) (fun (i : α) => f i)) (Finset.prod.{u3, u2} γ β _inst_3 (Finset.univ.{u2} β _inst_2) (fun (i : β) => g i)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : Fintype.{u3} α] [_inst_2 : Fintype.{u2} β] [_inst_3 : CommMonoid.{u1} γ] (e : Equiv.{succ u3, succ u2} α β) (f : α -> γ) (g : β -> γ), (forall (i : α), Eq.{succ u1} γ (f i) (g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (Equiv.{succ u3, succ u2} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} α β) e i))) -> (Eq.{succ u1} γ (Finset.prod.{u1, u3} γ α _inst_3 (Finset.univ.{u3} α _inst_1) (fun (i : α) => f i)) (Finset.prod.{u1, u2} γ β _inst_3 (Finset.univ.{u2} β _inst_2) (fun (i : β) => g i)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comp' Equiv.prod_comp'ₓ'. -/\n@[to_additive]\ntheorem Equiv.prod_comp' [Fintype α] [Fintype β] [CommMonoid γ] (e : α ≃ β) (f : α → γ) (g : β → γ)\n    (h : ∀ i, f i = g (e i)) : (∏ i, f i) = ∏ i, g i :=\n  (show f = g ∘ e from funext h).symm ▸ e.prod_comp _\n#align equiv.prod_comp' Equiv.prod_comp'\n#align equiv.sum_comp' Equiv.sum_comp'\n\n#print Fin.prod_univ_eq_prod_range /-\n/-- It is equivalent to compute the product of a function over `fin n` or `finset.range n`. -/\n@[to_additive \"It is equivalent to sum a function over `fin n` or `finset.range n`.\"]\ntheorem Fin.prod_univ_eq_prod_range [CommMonoid α] (f : ℕ → α) (n : ℕ) :\n    (∏ i : Fin n, f i) = ∏ i in range n, f i :=\n  calc\n    (∏ i : Fin n, f i) = ∏ i : { x // x ∈ range n }, f i :=\n      (Fin.equivSubtype.trans (Equiv.subtypeEquivRight (by simp))).prod_comp' _ _ (by simp)\n    _ = ∏ i in range n, f i := by rw [← attach_eq_univ, prod_attach]\n    \n#align fin.prod_univ_eq_prod_range Fin.prod_univ_eq_prod_range\n#align fin.sum_univ_eq_sum_range Fin.sum_univ_eq_sum_range\n-/\n\n/- warning: finset.prod_fin_eq_prod_range -> Finset.prod_fin_eq_prod_range is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} [_inst_1 : CommMonoid.{u1} β] {n : Nat} (c : (Fin n) -> β), Eq.{succ u1} β (Finset.prod.{u1, 0} β (Fin n) _inst_1 (Finset.univ.{0} (Fin n) (Fin.fintype n)) (fun (i : Fin n) => c i)) (Finset.prod.{u1, 0} β Nat _inst_1 (Finset.range n) (fun (i : Nat) => dite.{succ u1} β (LT.lt.{0} Nat Nat.hasLt i n) (Nat.decidableLt i n) (fun (h : LT.lt.{0} Nat Nat.hasLt i n) => c (Fin.mk n i h)) (fun (h : Not (LT.lt.{0} Nat Nat.hasLt i n)) => OfNat.ofNat.{u1} β 1 (OfNat.mk.{u1} β 1 (One.one.{u1} β (MulOneClass.toHasOne.{u1} β (Monoid.toMulOneClass.{u1} β (CommMonoid.toMonoid.{u1} β _inst_1))))))))\nbut is expected to have type\n  forall {β : Type.{u1}} [_inst_1 : CommMonoid.{u1} β] {n : Nat} (c : (Fin n) -> β), Eq.{succ u1} β (Finset.prod.{u1, 0} β (Fin n) _inst_1 (Finset.univ.{0} (Fin n) (Fin.fintype n)) (fun (i : Fin n) => c i)) (Finset.prod.{u1, 0} β Nat _inst_1 (Finset.range n) (fun (i : Nat) => dite.{succ u1} β (LT.lt.{0} Nat instLTNat i n) (Nat.decLt i n) (fun (h : LT.lt.{0} Nat instLTNat i n) => c (Fin.mk n i h)) (fun (h : Not (LT.lt.{0} Nat instLTNat i n)) => OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (Monoid.toOne.{u1} β (CommMonoid.toMonoid.{u1} β _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_fin_eq_prod_range Finset.prod_fin_eq_prod_rangeₓ'. -/\n@[to_additive]\ntheorem Finset.prod_fin_eq_prod_range [CommMonoid β] {n : ℕ} (c : Fin n → β) :\n    (∏ i, c i) = ∏ i in Finset.range n, if h : i < n then c ⟨i, h⟩ else 1 :=\n  by\n  rw [← Fin.prod_univ_eq_prod_range, Finset.prod_congr rfl]\n  rintro ⟨i, hi⟩ _\n  simp only [[anonymous], hi, dif_pos]\n#align finset.prod_fin_eq_prod_range Finset.prod_fin_eq_prod_range\n#align finset.sum_fin_eq_sum_range Finset.sum_fin_eq_sum_range\n\n#print Finset.prod_toFinset_eq_subtype /-\n@[to_additive]\ntheorem Finset.prod_toFinset_eq_subtype {M : Type _} [CommMonoid M] [Fintype α] (p : α → Prop)\n    [DecidablePred p] (f : α → M) : (∏ a in { x | p x }.toFinset, f a) = ∏ a : Subtype p, f a :=\n  by\n  rw [← Finset.prod_subtype]\n  simp\n#align finset.prod_to_finset_eq_subtype Finset.prod_toFinset_eq_subtype\n#align finset.sum_to_finset_eq_subtype Finset.sum_toFinset_eq_subtype\n-/\n\n/- warning: finset.prod_fiberwise -> Finset.prod_fiberwise is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u2} β] [_inst_2 : Fintype.{u2} β] [_inst_3 : CommMonoid.{u3} γ] (s : Finset.{u1} α) (f : α -> β) (g : α -> γ), Eq.{succ u3} γ (Finset.prod.{u3, u2} γ β _inst_3 (Finset.univ.{u2} β _inst_2) (fun (b : β) => Finset.prod.{u3, u1} γ α _inst_3 (Finset.filter.{u1} α (fun (a : α) => Eq.{succ u2} β (f a) b) (fun (a : α) => _inst_1 (f a) b) s) (fun (a : α) => g a))) (Finset.prod.{u3, u1} γ α _inst_3 s (fun (a : α) => g a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : DecidableEq.{succ u3} β] [_inst_2 : Fintype.{u3} β] [_inst_3 : CommMonoid.{u2} γ] (s : Finset.{u1} α) (f : α -> β) (g : α -> γ), Eq.{succ u2} γ (Finset.prod.{u2, u3} γ β _inst_3 (Finset.univ.{u3} β _inst_2) (fun (b : β) => Finset.prod.{u2, u1} γ α _inst_3 (Finset.filter.{u1} α (fun (a : α) => Eq.{succ u3} β (f a) b) (fun (a : α) => _inst_1 (f a) b) s) (fun (a : α) => g a))) (Finset.prod.{u2, u1} γ α _inst_3 s (fun (a : α) => g a))\nCase conversion may be inaccurate. Consider using '#align finset.prod_fiberwise Finset.prod_fiberwiseₓ'. -/\n@[to_additive]\ntheorem Finset.prod_fiberwise [DecidableEq β] [Fintype β] [CommMonoid γ] (s : Finset α) (f : α → β)\n    (g : α → γ) : (∏ b : β, ∏ a in s.filterₓ fun a => f a = b, g a) = ∏ a in s, g a :=\n  Finset.prod_fiberwise_of_maps_to (fun x _ => mem_univ _) _\n#align finset.prod_fiberwise Finset.prod_fiberwise\n#align finset.sum_fiberwise Finset.sum_fiberwise\n\n/- warning: fintype.prod_fiberwise -> Fintype.prod_fiberwise is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] [_inst_3 : Fintype.{u2} β] [_inst_4 : CommMonoid.{u3} γ] (f : α -> β) (g : α -> γ), Eq.{succ u3} γ (Finset.prod.{u3, u2} γ β _inst_4 (Finset.univ.{u2} β _inst_3) (fun (b : β) => Finset.prod.{u3, u1} γ (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b)) _inst_4 (Finset.univ.{u1} (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b)) (Subtype.fintype.{u1} α (fun (a : α) => Eq.{succ u2} β (f a) b) (fun (a : α) => _inst_2 (f a) b) _inst_1)) (fun (a : Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b)) => g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b)) α (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b)) α (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b)) α (coeBase.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b)) α (coeSubtype.{succ u1} α (fun (a : α) => Eq.{succ u2} β (f a) b))))) a)))) (Finset.prod.{u3, u1} γ α _inst_4 (Finset.univ.{u1} α _inst_1) (fun (a : α) => g a))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : Fintype.{u3} α] [_inst_2 : DecidableEq.{succ u2} β] [_inst_3 : Fintype.{u2} β] [_inst_4 : CommMonoid.{u1} γ] (f : α -> β) (g : α -> γ), Eq.{succ u1} γ (Finset.prod.{u1, u2} γ β _inst_4 (Finset.univ.{u2} β _inst_3) (fun (b : β) => Finset.prod.{u1, u3} γ (Subtype.{succ u3} α (fun (a : α) => Eq.{succ u2} β (f a) b)) _inst_4 (Finset.univ.{u3} (Subtype.{succ u3} α (fun (a : α) => Eq.{succ u2} β (f a) b)) (Subtype.fintype.{u3} α (fun (a : α) => Eq.{succ u2} β (f a) b) (fun (a : α) => _inst_2 (f a) b) _inst_1)) (fun (a : Subtype.{succ u3} α (fun (a : α) => Eq.{succ u2} β (f a) b)) => g (Subtype.val.{succ u3} α (fun (a : α) => Eq.{succ u2} β (f a) b) a)))) (Finset.prod.{u1, u3} γ α _inst_4 (Finset.univ.{u3} α _inst_1) (fun (a : α) => g a))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_fiberwise Fintype.prod_fiberwiseₓ'. -/\n@[to_additive]\ntheorem Fintype.prod_fiberwise [Fintype α] [DecidableEq β] [Fintype β] [CommMonoid γ] (f : α → β)\n    (g : α → γ) : (∏ b : β, ∏ a : { a // f a = b }, g (a : α)) = ∏ a, g a :=\n  by\n  rw [← (Equiv.sigmaFiberEquiv f).prod_comp, ← univ_sigma_univ, prod_sigma]\n  rfl\n#align fintype.prod_fiberwise Fintype.prod_fiberwise\n#align fintype.sum_fiberwise Fintype.sum_fiberwise\n\n/- warning: fintype.prod_dite -> Fintype.prod_dite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] {p : α -> Prop} [_inst_2 : DecidablePred.{succ u1} α p] [_inst_3 : CommMonoid.{u2} β] (f : forall (a : α), (p a) -> β) (g : forall (a : α), (Not (p a)) -> β), Eq.{succ u2} β (Finset.prod.{u2, u1} β α _inst_3 (Finset.univ.{u1} α _inst_1) (fun (a : α) => dite.{succ u2} β (p a) (_inst_2 a) (f a) (g a))) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (CommMonoid.toMonoid.{u2} β _inst_3)))) (Finset.prod.{u2, u1} β (Subtype.{succ u1} α (fun (a : α) => p a)) _inst_3 (Finset.univ.{u1} (Subtype.{succ u1} α (fun (a : α) => p a)) (Subtype.fintype.{u1} α (fun (a : α) => p a) (fun (a : α) => _inst_2 a) _inst_1)) (fun (a : Subtype.{succ u1} α (fun (a : α) => p a)) => f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} α (fun (a : α) => p a)) α (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => p a)) α (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => p a)) α (coeBase.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => p a)) α (coeSubtype.{succ u1} α (fun (a : α) => p a))))) a) (Subtype.property.{succ u1} α (fun (a : α) => p a) a))) (Finset.prod.{u2, u1} β (Subtype.{succ u1} α (fun (a : α) => Not (p a))) _inst_3 (Finset.univ.{u1} (Subtype.{succ u1} α (fun (a : α) => Not (p a))) (Subtype.fintype.{u1} α (fun (a : α) => Not (p a)) (fun (a : α) => Not.decidable (p a) (_inst_2 a)) _inst_1)) (fun (a : Subtype.{succ u1} α (fun (a : α) => Not (p a))) => g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} α (fun (a : α) => Not (p a))) α (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => Not (p a))) α (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => Not (p a))) α (coeBase.{succ u1, succ u1} (Subtype.{succ u1} α (fun (a : α) => Not (p a))) α (coeSubtype.{succ u1} α (fun (a : α) => Not (p a)))))) a) (Subtype.property.{succ u1} α (fun (a : α) => Not (p a)) a))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] {p : α -> Prop} [_inst_2 : DecidablePred.{succ u2} α p] [_inst_3 : CommMonoid.{u1} β] (f : forall (a : α), (p a) -> β) (g : forall (a : α), (Not (p a)) -> β), Eq.{succ u1} β (Finset.prod.{u1, u2} β α _inst_3 (Finset.univ.{u2} α _inst_1) (fun (a : α) => dite.{succ u1} β (p a) (_inst_2 a) (f a) (g a))) (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (CommMonoid.toMonoid.{u1} β _inst_3)))) (Finset.prod.{u1, u2} β (Subtype.{succ u2} α (fun (a : α) => p a)) _inst_3 (Finset.univ.{u2} (Subtype.{succ u2} α (fun (a : α) => p a)) (Subtype.fintype.{u2} α (fun (a : α) => p a) (fun (a : α) => _inst_2 a) _inst_1)) (fun (a : Subtype.{succ u2} α (fun (a : α) => p a)) => f (Subtype.val.{succ u2} α (fun (a : α) => p a) a) (Subtype.property.{succ u2} α (fun (a : α) => p a) a))) (Finset.prod.{u1, u2} β (Subtype.{succ u2} α (fun (a : α) => Not (p a))) _inst_3 (Finset.univ.{u2} (Subtype.{succ u2} α (fun (a : α) => Not (p a))) (Subtype.fintype.{u2} α (fun (a : α) => Not (p a)) (fun (a : α) => instDecidableNot (p a) (_inst_2 a)) _inst_1)) (fun (a : Subtype.{succ u2} α (fun (a : α) => Not (p a))) => g (Subtype.val.{succ u2} α (fun (a : α) => Not (p a)) a) (Subtype.property.{succ u2} α (fun (a : α) => Not (p a)) a))))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_dite Fintype.prod_diteₓ'. -/\ntheorem Fintype.prod_dite [Fintype α] {p : α → Prop} [DecidablePred p] [CommMonoid β]\n    (f : ∀ (a : α) (ha : p a), β) (g : ∀ (a : α) (ha : ¬p a), β) :\n    (∏ a, dite (p a) (f a) (g a)) = (∏ a : { a // p a }, f a a.2) * ∏ a : { a // ¬p a }, g a a.2 :=\n  by\n  simp only [prod_dite, attach_eq_univ]\n  congr 1\n  · convert(Equiv.subtypeEquivRight _).prod_comp fun x : { x // p x } => f x x.2\n    simp\n  · convert(Equiv.subtypeEquivRight _).prod_comp fun x : { x // ¬p x } => g x x.2\n    simp\n#align fintype.prod_dite Fintype.prod_dite\n\nsection\n\nopen Finset\n\nvariable {α₁ : Type _} {α₂ : Type _} {M : Type _} [Fintype α₁] [Fintype α₂] [CommMonoid M]\n\n/- warning: fintype.prod_sum_elim -> Fintype.prod_sum_elim is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {α₂ : Type.{u2}} {M : Type.{u3}} [_inst_1 : Fintype.{u1} α₁] [_inst_2 : Fintype.{u2} α₂] [_inst_3 : CommMonoid.{u3} M] (f : α₁ -> M) (g : α₂ -> M), Eq.{succ u3} M (Finset.prod.{u3, max u1 u2} M (Sum.{u1, u2} α₁ α₂) _inst_3 (Finset.univ.{max u1 u2} (Sum.{u1, u2} α₁ α₂) (Sum.fintype.{u1, u2} α₁ α₂ _inst_1 _inst_2)) (fun (x : Sum.{u1, u2} α₁ α₂) => Sum.elim.{u1, u2, succ u3} α₁ α₂ M f g x)) (HMul.hMul.{u3, u3, u3} M M M (instHMul.{u3} M (MulOneClass.toHasMul.{u3} M (Monoid.toMulOneClass.{u3} M (CommMonoid.toMonoid.{u3} M _inst_3)))) (Finset.prod.{u3, u1} M α₁ _inst_3 (Finset.univ.{u1} α₁ _inst_1) (fun (a₁ : α₁) => f a₁)) (Finset.prod.{u3, u2} M α₂ _inst_3 (Finset.univ.{u2} α₂ _inst_2) (fun (a₂ : α₂) => g a₂)))\nbut is expected to have type\n  forall {α₁ : Type.{u2}} {α₂ : Type.{u1}} {M : Type.{u3}} [_inst_1 : Fintype.{u2} α₁] [_inst_2 : Fintype.{u1} α₂] [_inst_3 : CommMonoid.{u3} M] (f : α₁ -> M) (g : α₂ -> M), Eq.{succ u3} M (Finset.prod.{u3, max u2 u1} M (Sum.{u2, u1} α₁ α₂) _inst_3 (Finset.univ.{max u2 u1} (Sum.{u2, u1} α₁ α₂) (instFintypeSum.{u2, u1} α₁ α₂ _inst_1 _inst_2)) (fun (x : Sum.{u2, u1} α₁ α₂) => Sum.elim.{u2, u1, succ u3} α₁ α₂ M f g x)) (HMul.hMul.{u3, u3, u3} M M M (instHMul.{u3} M (MulOneClass.toMul.{u3} M (Monoid.toMulOneClass.{u3} M (CommMonoid.toMonoid.{u3} M _inst_3)))) (Finset.prod.{u3, u2} M α₁ _inst_3 (Finset.univ.{u2} α₁ _inst_1) (fun (a₁ : α₁) => f a₁)) (Finset.prod.{u3, u1} M α₂ _inst_3 (Finset.univ.{u1} α₂ _inst_2) (fun (a₂ : α₂) => g a₂)))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_sum_elim Fintype.prod_sum_elimₓ'. -/\n@[to_additive]\ntheorem Fintype.prod_sum_elim (f : α₁ → M) (g : α₂ → M) :\n    (∏ x, Sum.elim f g x) = (∏ a₁, f a₁) * ∏ a₂, g a₂ :=\n  prod_disj_sum _ _ _\n#align fintype.prod_sum_elim Fintype.prod_sum_elim\n#align fintype.sum_sum_elim Fintype.sum_sum_elim\n\n/- warning: fintype.prod_sum_type -> Fintype.prod_sum_type is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Type.{u1}} {α₂ : Type.{u2}} {M : Type.{u3}} [_inst_1 : Fintype.{u1} α₁] [_inst_2 : Fintype.{u2} α₂] [_inst_3 : CommMonoid.{u3} M] (f : (Sum.{u1, u2} α₁ α₂) -> M), Eq.{succ u3} M (Finset.prod.{u3, max u1 u2} M (Sum.{u1, u2} α₁ α₂) _inst_3 (Finset.univ.{max u1 u2} (Sum.{u1, u2} α₁ α₂) (Sum.fintype.{u1, u2} α₁ α₂ _inst_1 _inst_2)) (fun (x : Sum.{u1, u2} α₁ α₂) => f x)) (HMul.hMul.{u3, u3, u3} M M M (instHMul.{u3} M (MulOneClass.toHasMul.{u3} M (Monoid.toMulOneClass.{u3} M (CommMonoid.toMonoid.{u3} M _inst_3)))) (Finset.prod.{u3, u1} M α₁ _inst_3 (Finset.univ.{u1} α₁ _inst_1) (fun (a₁ : α₁) => f (Sum.inl.{u1, u2} α₁ α₂ a₁))) (Finset.prod.{u3, u2} M α₂ _inst_3 (Finset.univ.{u2} α₂ _inst_2) (fun (a₂ : α₂) => f (Sum.inr.{u1, u2} α₁ α₂ a₂))))\nbut is expected to have type\n  forall {α₁ : Type.{u3}} {α₂ : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u3} α₁] [_inst_2 : Fintype.{u2} α₂] [_inst_3 : CommMonoid.{u1} M] (f : (Sum.{u3, u2} α₁ α₂) -> M), Eq.{succ u1} M (Finset.prod.{u1, max u3 u2} M (Sum.{u3, u2} α₁ α₂) _inst_3 (Finset.univ.{max u3 u2} (Sum.{u3, u2} α₁ α₂) (instFintypeSum.{u3, u2} α₁ α₂ _inst_1 _inst_2)) (fun (x : Sum.{u3, u2} α₁ α₂) => f x)) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_3)))) (Finset.prod.{u1, u3} M α₁ _inst_3 (Finset.univ.{u3} α₁ _inst_1) (fun (a₁ : α₁) => f (Sum.inl.{u3, u2} α₁ α₂ a₁))) (Finset.prod.{u1, u2} M α₂ _inst_3 (Finset.univ.{u2} α₂ _inst_2) (fun (a₂ : α₂) => f (Sum.inr.{u3, u2} α₁ α₂ a₂))))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_sum_type Fintype.prod_sum_typeₓ'. -/\n@[simp, to_additive]\ntheorem Fintype.prod_sum_type (f : Sum α₁ α₂ → M) :\n    (∏ x, f x) = (∏ a₁, f (Sum.inl a₁)) * ∏ a₂, f (Sum.inr a₂) :=\n  prod_disj_sum _ _ _\n#align fintype.prod_sum_type Fintype.prod_sum_type\n#align fintype.sum_sum_type Fintype.sum_sum_type\n\nend\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Fintype/BigOperators.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.49051281719486145}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module tactic.abel\n! leanprover-community/mathlib commit ec322deb9ba5aad978f862669053069b7957c31d\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.NormNum\n\n/-!\n# The `abel` tactic\n\nEvaluate expressions in the language of additive, commutative monoids and groups.\n\n\n-/\n\n\nnamespace Tactic\n\nnamespace Abel\n\n/-- The `context` for a call to `abel`.\n\nStores a few options for this call, and caches some common subexpressions\nsuch as typeclass instances and `0 : α`.\n-/\nunsafe structure context where\n  red : Transparency\n  α : expr\n  univ : level\n  α0 : expr\n  is_group : Bool\n  inst : expr\n#align tactic.abel.context tactic.abel.context\n\n/-- Populate a `context` object for evaluating `e`, up to reducibility level `red`. -/\nunsafe def mk_context (red : Transparency) (e : expr) : tactic context := do\n  let α ← infer_type e\n  let c ← mk_app `` AddCommMonoid [α] >>= mk_instance\n  let cg ← try_core (mk_app `` AddCommGroup [α] >>= mk_instance)\n  let u ← mk_meta_univ\n  infer_type α >>= unify (expr.sort (level.succ u))\n  let u ← get_univ_assignment u\n  let α0 ← expr.of_nat α 0\n  match cg with\n    | some cg => return ⟨red, α, u, α0, tt, cg⟩\n    | _ => return ⟨red, α, u, α0, ff, c⟩\n#align tactic.abel.mk_context tactic.abel.mk_context\n\n/-- Apply the function `n : ∀ {α} [inst : add_whatever α], _` to the\nimplicit parameters in the context, and the given list of arguments. -/\nunsafe def context.app (c : context) (n : Name) (inst : expr) : List expr → expr :=\n  (@expr.const true n [c.univ] c.α inst).mk_app\n#align tactic.abel.context.app tactic.abel.context.app\n\n/-- Apply the function `n : ∀ {α} [inst α], _` to the implicit parameters in the\ncontext, and the given list of arguments.\n\nCompared to `context.app`, this takes the name of the typeclass, rather than an\ninferred typeclass instance.\n-/\nunsafe def context.mk_app (c : context) (n inst : Name) (l : List expr) : tactic expr := do\n  let m ← mk_instance ((expr.const inst [c.univ] : expr) c.α)\n  return <| c n m l\n#align tactic.abel.context.mk_app tactic.abel.context.mk_app\n\n/-- Add the letter \"g\" to the end of the name, e.g. turning `term` into `termg`.\n\nThis is used to choose between declarations taking `add_comm_monoid` and those\ntaking `add_comm_group` instances.\n-/\nunsafe def add_g : Name → Name\n  | Name.mk_string s p => Name.mk_string (s ++ \"g\") p\n  | n => n\n#align tactic.abel.add_g tactic.abel.add_g\n\n/-- Apply the function `n : ∀ {α} [add_comm_{monoid,group} α]` to the given\nlist of arguments.\n\nWill use the `add_comm_{monoid,group}` instance that has been cached in the context.\n-/\nunsafe def context.iapp (c : context) (n : Name) : List expr → expr :=\n  c.app (if c.is_group then add_g n else n) c.inst\n#align tactic.abel.context.iapp tactic.abel.context.iapp\n\ndef term {α} [AddCommMonoid α] (n : ℕ) (x a : α) : α :=\n  n • x + a\n#align tactic.abel.term Tactic.Abel.term\n\ndef termg {α} [AddCommGroup α] (n : ℤ) (x a : α) : α :=\n  n • x + a\n#align tactic.abel.termg Tactic.Abel.termg\n\n/-- Evaluate a term with coefficient `n`, atom `x` and successor terms `a`. -/\nunsafe def context.mk_term (c : context) (n x a : expr) : expr :=\n  c.iapp `` term [n, x, a]\n#align tactic.abel.context.mk_term tactic.abel.context.mk_term\n\n/-- Interpret an integer as a coefficient to a term. -/\nunsafe def context.int_to_expr (c : context) (n : ℤ) : tactic expr :=\n  expr.of_int (if c.is_group then q(ℤ) else q(ℕ)) n\n#align tactic.abel.context.int_to_expr tactic.abel.context.int_to_expr\n\nunsafe inductive normal_expr : Type\n  | zero (e : expr) : normal_expr\n  | nterm (e : expr) (n : expr × ℤ) (x : expr) (a : normal_expr) : normal_expr\n#align tactic.abel.normal_expr tactic.abel.normal_expr\n\nunsafe def normal_expr.e : normal_expr → expr\n  | normal_expr.zero e => e\n  | normal_expr.nterm e _ _ _ => e\n#align tactic.abel.normal_expr.e tactic.abel.normal_expr.e\n\nunsafe instance : Coe normal_expr expr :=\n  ⟨normal_expr.e⟩\n\nunsafe instance : CoeFun normal_expr fun _ => expr → expr :=\n  ⟨fun e => ⇑(e : expr)⟩\n\nunsafe def normal_expr.term' (c : context) (n : expr × ℤ) (x : expr) (a : normal_expr) :\n    normal_expr :=\n  normal_expr.nterm (c.mk_term n.1 x a) n x a\n#align tactic.abel.normal_expr.term' tactic.abel.normal_expr.term'\n\nunsafe def normal_expr.zero' (c : context) : normal_expr :=\n  normal_expr.zero c.α0\n#align tactic.abel.normal_expr.zero' tactic.abel.normal_expr.zero'\n\nunsafe def normal_expr.to_list : normal_expr → List (ℤ × expr)\n  | normal_expr.zero _ => []\n  | normal_expr.nterm _ (_, n) x a => (n, x) :: a.toList\n#align tactic.abel.normal_expr.to_list tactic.abel.normal_expr.to_list\n\nopen NormalExpr\n\nunsafe def normal_expr.to_string (e : normal_expr) : String :=\n  \" + \".intercalate <| (to_list e).map fun ⟨n, e⟩ => toString n ++ \" • (\" ++ toString e ++ \")\"\n#align tactic.abel.normal_expr.to_string tactic.abel.normal_expr.to_string\n\nunsafe def normal_expr.pp (e : normal_expr) : tactic format := do\n  let l ←\n    (to_list e).mapM fun ⟨n, e⟩ => do\n        let pe ← pp e\n        return (to_fmt n ++ \" • (\" ++ pe ++ \")\")\n  return <| format.join <| l ↑\" + \"\n#align tactic.abel.normal_expr.pp tactic.abel.normal_expr.pp\n\nunsafe instance : has_to_tactic_format normal_expr :=\n  ⟨normal_expr.pp⟩\n\nunsafe def normal_expr.refl_conv (e : normal_expr) : tactic (normal_expr × expr) := do\n  let p ← mk_eq_refl e\n  return (e, p)\n#align tactic.abel.normal_expr.refl_conv tactic.abel.normal_expr.refl_conv\n\ntheorem const_add_term {α} [AddCommMonoid α] (k n x a a') (h : k + a = a') :\n    k + @term α _ n x a = term n x a' := by simp [h.symm, term] <;> ac_rfl\n#align tactic.abel.const_add_term Tactic.Abel.const_add_term\n\ntheorem const_add_termg {α} [AddCommGroup α] (k n x a a') (h : k + a = a') :\n    k + @termg α _ n x a = termg n x a' := by simp [h.symm, termg] <;> ac_rfl\n#align tactic.abel.const_add_termg Tactic.Abel.const_add_termg\n\ntheorem term_add_const {α} [AddCommMonoid α] (n x a k a') (h : a + k = a') :\n    @term α _ n x a + k = term n x a' := by simp [h.symm, term, add_assoc]\n#align tactic.abel.term_add_const Tactic.Abel.term_add_const\n\ntheorem term_add_constg {α} [AddCommGroup α] (n x a k a') (h : a + k = a') :\n    @termg α _ n x a + k = termg n x a' := by simp [h.symm, termg, add_assoc]\n#align tactic.abel.term_add_constg Tactic.Abel.term_add_constg\n\ntheorem term_add_term {α} [AddCommMonoid α] (n₁ x a₁ n₂ a₂ n' a') (h₁ : n₁ + n₂ = n')\n    (h₂ : a₁ + a₂ = a') : @term α _ n₁ x a₁ + @term α _ n₂ x a₂ = term n' x a' := by\n  simp [h₁.symm, h₂.symm, term, add_nsmul] <;> ac_rfl\n#align tactic.abel.term_add_term Tactic.Abel.term_add_term\n\ntheorem term_add_termg {α} [AddCommGroup α] (n₁ x a₁ n₂ a₂ n' a') (h₁ : n₁ + n₂ = n')\n    (h₂ : a₁ + a₂ = a') : @termg α _ n₁ x a₁ + @termg α _ n₂ x a₂ = termg n' x a' := by\n  simp [h₁.symm, h₂.symm, termg, add_zsmul] <;> ac_rfl\n#align tactic.abel.term_add_termg Tactic.Abel.term_add_termg\n\ntheorem zero_term {α} [AddCommMonoid α] (x a) : @term α _ 0 x a = a := by\n  simp [term, zero_nsmul, one_nsmul]\n#align tactic.abel.zero_term Tactic.Abel.zero_term\n\ntheorem zero_termg {α} [AddCommGroup α] (x a) : @termg α _ 0 x a = a := by simp [termg]\n#align tactic.abel.zero_termg Tactic.Abel.zero_termg\n\nunsafe def eval_add (c : context) : normal_expr → normal_expr → tactic (normal_expr × expr)\n  | zero _, e₂ => do\n    let p ← mk_app `` zero_add [e₂]\n    return (e₂, p)\n  | e₁, zero _ => do\n    let p ← mk_app `` add_zero [e₁]\n    return (e₁, p)\n  | he₁@(nterm e₁ n₁ x₁ a₁), he₂@(nterm e₂ n₂ x₂ a₂) =>\n    (do\n        is_def_eq x₁ x₂ c\n        let (n', h₁) ← mk_app `` Add.add [n₁.1, n₂.1] >>= norm_num.eval_field\n        let (a', h₂) ← eval_add a₁ a₂\n        let k := n₁.2 + n₂.2\n        let p₁ := c.iapp `` term_add_term [n₁.1, x₁, a₁, n₂.1, a₂, n', a', h₁, h₂]\n        if k = 0 then do\n            let p ← mk_eq_trans p₁ (c `` zero_term [x₁, a'])\n            return (a', p)\n          else return (term' c (n', k) x₁ a', p₁)) <|>\n      if expr.lex_lt x₁ x₂ then do\n        let (a', h) ← eval_add a₁ he₂\n        return (term' c n₁ x₁ a', c `` term_add_const [n₁.1, x₁, a₁, e₂, a', h])\n      else do\n        let (a', h) ← eval_add he₁ a₂\n        return (term' c n₂ x₂ a', c `` const_add_term [e₁, n₂.1, x₂, a₂, a', h])\n#align tactic.abel.eval_add tactic.abel.eval_add\n\ntheorem term_neg {α} [AddCommGroup α] (n x a n' a') (h₁ : -n = n') (h₂ : -a = a') :\n    -@termg α _ n x a = termg n' x a' := by simp [h₂.symm, h₁.symm, termg] <;> ac_rfl\n#align tactic.abel.term_neg Tactic.Abel.term_neg\n\nunsafe def eval_neg (c : context) : normal_expr → tactic (normal_expr × expr)\n  | zero e => do\n    let p ← c.mk_app `` neg_zero `` NegZeroClass []\n    return (zero' c, p)\n  | nterm e n x a => do\n    let (n', h₁) ← mk_app `` Neg.neg [n.1] >>= norm_num.eval_field\n    let (a', h₂) ← eval_neg a\n    return (term' c (n', -n.2) x a', c `` term_neg c [n.1, x, a, n', a', h₁, h₂])\n#align tactic.abel.eval_neg tactic.abel.eval_neg\n\ndef natSmulInst {α} [AddCommMonoid α] : SMul ℕ α := by infer_instance\n#align tactic.abel.nat_smul_inst Tactic.Abel.natSmulInst\n\ndef natSmulInstg {α} [AddCommGroup α] : SMul ℕ α := by infer_instance\n#align tactic.abel.nat_smul_instg Tactic.Abel.natSmulInstg\n\ndef intSmulInstg {α} [AddCommGroup α] : SMul ℤ α := by infer_instance\n#align tactic.abel.int_smul_instg Tactic.Abel.intSmulInstg\n\ndef smul {α} [AddCommMonoid α] (n : ℕ) (x : α) : α :=\n  n • x\n#align tactic.abel.smul Tactic.Abel.smul\n\ndef smulg {α} [AddCommGroup α] (n : ℤ) (x : α) : α :=\n  n • x\n#align tactic.abel.smulg Tactic.Abel.smulg\n\ntheorem zero_smul {α} [AddCommMonoid α] (c) : smul c (0 : α) = 0 := by simp [smul, nsmul_zero]\n#align tactic.abel.zero_smul Tactic.Abel.zero_smul\n\ntheorem zero_smulg {α} [AddCommGroup α] (c) : smulg c (0 : α) = 0 := by simp [smulg, zsmul_zero]\n#align tactic.abel.zero_smulg Tactic.Abel.zero_smulg\n\ntheorem term_smul {α} [AddCommMonoid α] (c n x a n' a') (h₁ : c * n = n') (h₂ : smul c a = a') :\n    smul c (@term α _ n x a) = term n' x a' := by\n  simp [h₂.symm, h₁.symm, term, smul, nsmul_add, mul_nsmul']\n#align tactic.abel.term_smul Tactic.Abel.term_smul\n\ntheorem term_smulg {α} [AddCommGroup α] (c n x a n' a') (h₁ : c * n = n') (h₂ : smulg c a = a') :\n    smulg c (@termg α _ n x a) = termg n' x a' := by\n  simp [h₂.symm, h₁.symm, termg, smulg, zsmul_add, mul_zsmul]\n#align tactic.abel.term_smulg Tactic.Abel.term_smulg\n\nunsafe def eval_smul (c : context) (k : expr × ℤ) : normal_expr → tactic (normal_expr × expr)\n  | zero _ => return (zero' c, c.iapp `` zero_smul [k.1])\n  | nterm e n x a => do\n    let (n', h₁) ← mk_app `` Mul.mul [k.1, n.1] >>= norm_num.eval_field\n    let (a', h₂) ← eval_smul a\n    return (term' c (n', k.2 * n.2) x a', c `` term_smul [k.1, n.1, x, a, n', a', h₁, h₂])\n#align tactic.abel.eval_smul tactic.abel.eval_smul\n\ntheorem term_atom {α} [AddCommMonoid α] (x : α) : x = term 1 x 0 := by simp [term]\n#align tactic.abel.term_atom Tactic.Abel.term_atom\n\ntheorem term_atomg {α} [AddCommGroup α] (x : α) : x = termg 1 x 0 := by simp [termg]\n#align tactic.abel.term_atomg Tactic.Abel.term_atomg\n\nunsafe def eval_atom (c : context) (e : expr) : tactic (normal_expr × expr) := do\n  let n1 ← c.int_to_expr 1\n  return (term' c (n1, 1) e (zero' c), c `` term_atom [e])\n#align tactic.abel.eval_atom tactic.abel.eval_atom\n\ntheorem unfold_sub {α} [SubtractionMonoid α] (a b c : α) (h : a + -b = c) : a - b = c := by\n  rw [sub_eq_add_neg, h]\n#align tactic.abel.unfold_sub Tactic.Abel.unfold_sub\n\ntheorem unfold_smul {α} [AddCommMonoid α] (n) (x y : α) (h : smul n x = y) : n • x = y :=\n  h\n#align tactic.abel.unfold_smul Tactic.Abel.unfold_smul\n\ntheorem unfold_smulg {α} [AddCommGroup α] (n : ℕ) (x y : α) (h : smulg (Int.ofNat n) x = y) :\n    (n : ℤ) • x = y :=\n  h\n#align tactic.abel.unfold_smulg Tactic.Abel.unfold_smulg\n\ntheorem unfold_zsmul {α} [AddCommGroup α] (n : ℤ) (x y : α) (h : smulg n x = y) : n • x = y :=\n  h\n#align tactic.abel.unfold_zsmul Tactic.Abel.unfold_zsmul\n\ntheorem subst_into_smul {α} [AddCommMonoid α] (l r tl tr t) (prl : l = tl) (prr : r = tr)\n    (prt : @smul α _ tl tr = t) : smul l r = t := by simp [prl, prr, prt]\n#align tactic.abel.subst_into_smul Tactic.Abel.subst_into_smul\n\ntheorem subst_into_smulg {α} [AddCommGroup α] (l r tl tr t) (prl : l = tl) (prr : r = tr)\n    (prt : @smulg α _ tl tr = t) : smulg l r = t := by simp [prl, prr, prt]\n#align tactic.abel.subst_into_smulg Tactic.Abel.subst_into_smulg\n\ntheorem subst_into_smul_upcast {α} [AddCommGroup α] (l r tl zl tr t) (prl₁ : l = tl)\n    (prl₂ : ↑tl = zl) (prr : r = tr) (prt : @smulg α _ zl tr = t) : smul l r = t := by\n  simp [← prt, prl₁, ← prl₂, prr, smul, smulg]\n#align tactic.abel.subst_into_smul_upcast Tactic.Abel.subst_into_smul_upcast\n\n/-- Normalize a term `orig` of the form `smul e₁ e₂` or `smulg e₁ e₂`.\n  Normalized terms use `smul` for monoids and `smulg` for groups,\n  so there are actually four cases to handle:\n  * Using `smul` in a monoid just simplifies the pieces using `subst_into_smul`\n  * Using `smulg` in a group just simplifies the pieces using `subst_into_smulg`\n  * Using `smul a b` in a group requires converting `a` from a nat to an int and\n    then simplifying `smulg ↑a b` using `subst_into_smul_upcast`\n  * Using `smulg` in a monoid is impossible (or at least out of scope),\n    because you need a group argument to write a `smulg` term -/\nunsafe def eval_smul' (c : context) (eval : expr → tactic (normal_expr × expr)) (is_smulg : Bool)\n    (orig e₁ e₂ : expr) : tactic (normal_expr × expr) := do\n  let (e₁', p₁) ← norm_num.derive e₁ <|> refl_conv e₁\n  match if is_smulg then e₁' else coe <$> e₁' with\n    | some n => do\n      let (e₂', p₂) ← eval e₂\n      if c = is_smulg then do\n          let (e', p) ← eval_smul c (e₁', n) e₂'\n          return (e', c `` subst_into_smul [e₁, e₂, e₁', e₂', e', p₁, p₂, p])\n        else do\n          guardb c\n          let ic ← mk_instance_cache q(ℤ)\n          let nc ← mk_instance_cache q(ℕ)\n          let (ic, zl) ← ic n\n          let (_, _, _, p₁') ← norm_num.prove_nat_uncast ic nc zl\n          let (e', p) ← eval_smul c (zl, n) e₂'\n          return (e', c `` subst_into_smul_upcast c [e₁, e₂, e₁', zl, e₂', e', p₁, p₁', p₂, p])\n    | none => eval_atom c orig\n#align tactic.abel.eval_smul' tactic.abel.eval_smul'\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\nunsafe\n  def\n    eval\n    ( c : context ) : expr → tactic ( normal_expr × expr )\n    |\n        q( $ ( e₁ ) + $ ( e₂ ) )\n        =>\n        do\n          let ( e₁' , p₁ ) ← eval e₁\n            let ( e₂' , p₂ ) ← eval e₂\n            let ( e' , p' ) ← eval_add c e₁' e₂'\n            let\n              p\n                ←\n                c . mk_app\n                  ` ` NormNum.subst_into_add ` ` Add [ e₁ , e₂ , e₁' , e₂' , e' , p₁ , p₂ , p' ]\n            return ( e' , p )\n      |\n        q( $ ( e₁ ) - $ ( e₂ ) )\n        =>\n        do\n          let e₂' ← mk_app ` ` Neg.neg [ e₂ ]\n            let e ← mk_app ` ` Add.add [ e₁ , e₂' ]\n            let ( e' , p ) ← eval e\n            let p' ← c . mk_app ` ` unfold_sub ` ` SubtractionMonoid [ e₁ , e₂ , e' , p ]\n            return ( e' , p' )\n      |\n        q( - $ ( e ) )\n        =>\n        do\n          let ( e₁ , p₁ ) ← eval e\n            let ( e₂ , p₂ ) ← eval_neg c e₁\n            let p ← c . mk_app ` ` NormNum.subst_into_neg ` ` Neg [ e , e₁ , e₂ , p₁ , p₂ ]\n            return ( e₂ , p )\n      |\n        q( AddMonoid.nsmul $ ( e₁ ) $ ( e₂ ) )\n        =>\n        do\n          let n ← if c . is_group then mk_app ` ` Int.ofNat [ e₁ ] else return e₁\n            let ( e' , p ) ← eval <| c . iapp ` ` smul [ n , e₂ ]\n            return ( e' , c ` ` unfold_smul [ e₁ , e₂ , e' , p ] )\n      |\n        q( SubNegMonoid.zsmul $ ( e₁ ) $ ( e₂ ) )\n        =>\n        do\n          guardb c\n            let ( e' , p ) ← eval <| c . iapp ` ` smul [ e₁ , e₂ ]\n            return ( e' , c ` ` unfold_zsmul c [ e₁ , e₂ , e' , p ] )\n      |\n        e @ q( @ SMul.smul Nat $ ( α ) $ ( inst ) $ ( e₁ ) $ ( e₂ ) )\n        =>\n        do\n          let inst' := c . iapp ` ` nat_smul_inst [ ]\n            condM\n              ( succeeds ( is_def_eq inst inst' ) )\n                ( eval_smul' c eval ff e e₁ e₂ )\n                ( eval_atom c e )\n      |\n        e @ q( @ SMul.smul Int $ ( α ) $ ( inst ) $ ( e₁ ) $ ( e₂ ) )\n        =>\n        do\n          let tt ← pure c . is_group | eval_atom c e\n            let inst' := c . app ` ` int_smul_instg c . inst [ ]\n            condM\n              ( succeeds ( is_def_eq inst inst' ) )\n                ( eval_smul' c eval tt e e₁ e₂ )\n                ( eval_atom c e )\n      | e @ q( smul $ ( e₁ ) $ ( e₂ ) ) => eval_smul' c eval false e e₁ e₂\n      | e @ q( smulg $ ( e₁ ) $ ( e₂ ) ) => eval_smul' c eval true e e₁ e₂\n      |\n        e @ q( @ Zero.zero _ _ )\n        =>\n        condM\n          ( succeeds ( is_def_eq e c . α0 ) )\n            ( mk_eq_refl c . α0 >>= fun p => pure ( zero' c , p ) )\n            ( eval_atom c e )\n      | e => eval_atom c e\n#align tactic.abel.eval tactic.abel.eval\n\nunsafe def eval' (c : context) (e : expr) : tactic (expr × expr) := do\n  let (e', p) ← eval c e\n  return (e', p)\n#align tactic.abel.eval' tactic.abel.eval'\n\ninductive NormalizeMode\n  | raw\n  | term\n  deriving has_reflect\n#align tactic.abel.normalize_mode Tactic.Abel.NormalizeMode\n\ninstance : Inhabited NormalizeMode :=\n  ⟨NormalizeMode.term⟩\n\nunsafe def normalize (red : Transparency) (mode := NormalizeMode.term) (e : expr) :\n    tactic (expr × expr) := do\n  let pow_lemma ← simp_lemmas.mk.add_simp `` pow_one\n  let lemmas :=\n    match mode with\n    | normalize_mode.term =>\n      [`` term.equations._eqn_1, `` termg.equations._eqn_1, `` add_zero, `` one_nsmul, `` one_zsmul,\n        `` zsmul_zero]\n    | _ => []\n  let lemmas ← lemmas.foldlM simp_lemmas.add_simp simp_lemmas.mk\n  let (_, e', pr) ←\n    ext_simplify_core () { } simp_lemmas.mk (fun _ => failed)\n        (fun _ _ _ _ e => do\n          let c ← mk_context red e\n          let (new_e, pr) ←\n            (match mode with\n                | normalize_mode.raw => eval' c\n                | normalize_mode.term =>\n                  trans_conv (eval' c) fun e => do\n                    let (e', prf, _) ← simplify lemmas [] e\n                    return (e', prf))\n                e\n          guard ¬new_e == e\n          return ((), new_e, some pr, ff))\n        (fun _ _ _ _ _ => failed) `eq e\n  return (e', pr)\n#align tactic.abel.normalize tactic.abel.normalize\n\nend Abel\n\nnamespace Interactive\n\nopen Tactic.Abel\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/--\n      Tactic for solving equations in the language of\n      *additive*, commutative monoids and groups.\n      This version of `abel` fails if the target is not an equality\n      that is provable by the axioms of commutative monoids/groups.\n      \n      `abel1!` will use a more aggressive reducibility setting to identify atoms.\n      This can prove goals that `abel` cannot, but is more expensive.\n      -/\n    unsafe\n  def\n    abel1\n    ( red : parse ( tk \"!\" ) ? ) : tactic Unit\n    :=\n      do\n        let q( $ ( e₁ ) = $ ( e₂ ) ) ← target\n          let c ← mk_context ( if red . isSome then semireducible else reducible ) e₁\n          let ( e₁' , p₁ ) ← eval c e₁\n          let ( e₂' , p₂ ) ← eval c e₂\n          is_def_eq e₁' e₂'\n          let p ← mk_eq_symm p₂ >>= mk_eq_trans p₁\n          tactic.exact p\n#align tactic.interactive.abel1 tactic.interactive.abel1\n\nunsafe def abel.mode : lean.parser Abel.NormalizeMode :=\n  with_desc \"(raw|term)?\" do\n    let mode ← ident ?\n    match mode with\n      | none => return abel.normalize_mode.term\n      | some `term => return abel.normalize_mode.term\n      | some `raw => return abel.normalize_mode.raw\n      | _ => failed\n#align tactic.interactive.abel.mode tactic.interactive.abel.mode\n\n/-- Evaluate expressions in the language of *additive*, commutative monoids and groups.\nIt attempts to prove the goal outright if there is no `at`\nspecifier and the target is an equality, but if this\nfails, it falls back to rewriting all monoid expressions into a normal form.\nIf there is an `at` specifier, it rewrites the given target into a normal form.\n\n`abel!` will use a more aggressive reducibility setting to identify atoms.\nThis can prove goals that `abel` cannot, but is more expensive.\n```lean\nexample {α : Type*} {a b : α} [add_comm_monoid α] : a + (b + a) = a + a + b := by abel\nexample {α : Type*} {a b : α} [add_comm_group α] : (a + b) - ((b + a) + a) = -a := by abel\nexample {α : Type*} {a b : α} [add_comm_group α] (hyp : a + a - a = b - b) : a = 0 :=\nby { abel at hyp, exact hyp }\nexample {α : Type*} {a b : α} [add_comm_group α] : (a + b) - (id a + b) = 0 := by abel!\n```\n-/\nunsafe def abel (red : parse (tk \"!\")?) (SOP : parse abel.mode) (loc : parse location) :\n    tactic Unit :=\n  (match loc with\n    | Interactive.Loc.ns [none] => abel1 red\n    | _ => failed) <|>\n    do\n    let ns ← loc.get_locals\n    let red := if red.isSome then semireducible else reducible\n    let tt ← tactic.replace_at (normalize red SOP) ns loc.include_goal |\n      fail \"abel failed to simplify\"\n    when loc <| try tactic.reflexivity\n#align tactic.interactive.abel tactic.interactive.abel\n\nadd_tactic_doc\n  { Name := \"abel\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.abel]\n    tags := [\"arithmetic\", \"decision procedure\"] }\n\nend Interactive\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/Abel.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.490512812303692}}
{"text": "/-\nCopyright (c) 2021 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n\n! This file was ported from Lean 3 source module analysis.special_functions.exponential\n! leanprover-community/mathlib commit ccf84e0d918668460a34aa19d02fe2e0e2286da0\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.NormedSpace.Exponential\nimport Mathbin.Analysis.Calculus.FderivAnalytic\nimport Mathbin.Data.Complex.Exponential\nimport Mathbin.Topology.MetricSpace.CauSeqFilter\n\n/-!\n# Calculus results on exponential in a Banach algebra\n\nIn this file, we prove basic properties about the derivative of the exponential map `exp 𝕂`\nin a Banach algebra `𝔸` over a field `𝕂`. We keep them separate from the main file\n`analysis/normed_space/exponential` in order to minimize dependencies.\n\n## Main results\n\nWe prove most result for an arbitrary field `𝕂`, and then specialize to `𝕂 = ℝ` or `𝕂 = ℂ`.\n\n### General case\n\n- `has_strict_fderiv_at_exp_zero_of_radius_pos` : `exp 𝕂` has strict Fréchet-derivative\n  `1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero\n  (see also `has_strict_deriv_at_exp_zero_of_radius_pos` for the case `𝔸 = 𝕂`)\n- `has_strict_fderiv_at_exp_of_lt_radius` : if `𝕂` has characteristic zero and `𝔸` is commutative,\n  then given a point `x` in the disk of convergence, `exp 𝕂` as strict Fréchet-derivative\n  `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x (see also `has_strict_deriv_at_exp_of_lt_radius` for the case\n  `𝔸 = 𝕂`)\n\n### `𝕂 = ℝ` or `𝕂 = ℂ`\n\n- `has_strict_fderiv_at_exp_zero` : `exp 𝕂` has strict Fréchet-derivative `1 : 𝔸 →L[𝕂] 𝔸` at zero\n  (see also `has_strict_deriv_at_exp_zero` for the case `𝔸 = 𝕂`)\n- `has_strict_fderiv_at_exp` : if `𝔸` is commutative, then given any point `x`, `exp 𝕂` as strict\n  Fréchet-derivative `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x (see also `has_strict_deriv_at_exp` for the\n  case `𝔸 = 𝕂`)\n\n### Compatibilty with `real.exp` and `complex.exp`\n\n- `complex.exp_eq_exp_ℂ` : `complex.exp = exp ℂ ℂ`\n- `real.exp_eq_exp_ℝ` : `real.exp = exp ℝ ℝ`\n\n-/\n\n\nopen Filter IsROrC ContinuousMultilinearMap NormedField Asymptotics\n\nopen Nat Topology BigOperators ENNReal\n\nsection AnyFieldAnyAlgebra\n\nvariable {𝕂 𝔸 : Type _} [NontriviallyNormedField 𝕂] [NormedRing 𝔸] [NormedAlgebra 𝕂 𝔸]\n  [CompleteSpace 𝔸]\n\n/-- The exponential in a Banach-algebra `𝔸` over a normed field `𝕂` has strict Fréchet-derivative\n`1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/\ntheorem hasStrictFderivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) :\n    HasStrictFderivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 :=\n  by\n  convert(hasFpowerSeriesAtExpZeroOfRadiusPos h).HasStrictFderivAt\n  ext x\n  change x = expSeries 𝕂 𝔸 1 fun _ => x\n  simp [expSeries_apply_eq]\n#align has_strict_fderiv_at_exp_zero_of_radius_pos hasStrictFderivAt_exp_zero_of_radius_pos\n\n/-- The exponential in a Banach-algebra `𝔸` over a normed field `𝕂` has Fréchet-derivative\n`1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/\ntheorem hasFderivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) :\n    HasFderivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 :=\n  (hasStrictFderivAt_exp_zero_of_radius_pos h).HasFderivAt\n#align has_fderiv_at_exp_zero_of_radius_pos hasFderivAt_exp_zero_of_radius_pos\n\nend AnyFieldAnyAlgebra\n\nsection AnyFieldCommAlgebra\n\nvariable {𝕂 𝔸 : Type _} [NontriviallyNormedField 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸]\n  [CompleteSpace 𝔸]\n\n/-- The exponential map in a commutative Banach-algebra `𝔸` over a normed field `𝕂` of\ncharacteristic zero has Fréchet-derivative `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x` in the\ndisk of convergence. -/\ntheorem hasFderivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸}\n    (hx : x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :\n    HasFderivAt (exp 𝕂) (exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸) x :=\n  by\n  have hpos : 0 < (expSeries 𝕂 𝔸).radius := (zero_le _).trans_lt hx\n  rw [hasFderivAt_iff_isOCat_nhds_zero]\n  suffices\n    (fun h => exp 𝕂 x * (exp 𝕂 (0 + h) - exp 𝕂 0 - ContinuousLinearMap.id 𝕂 𝔸 h)) =ᶠ[𝓝 0] fun h =>\n      exp 𝕂 (x + h) - exp 𝕂 x - exp 𝕂 x • ContinuousLinearMap.id 𝕂 𝔸 h\n    by\n    refine' (is_o.const_mul_left _ _).congr' this (eventually_eq.refl _ _)\n    rw [← hasFderivAt_iff_isOCat_nhds_zero]\n    exact hasFderivAt_exp_zero_of_radius_pos hpos\n  have : ∀ᶠ h in 𝓝 (0 : 𝔸), h ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius :=\n    EMetric.ball_mem_nhds _ hpos\n  filter_upwards [this]with _ hh\n  rw [exp_add_of_mem_ball hx hh, exp_zero, zero_add, ContinuousLinearMap.id_apply, smul_eq_mul]\n  ring\n#align has_fderiv_at_exp_of_mem_ball hasFderivAt_exp_of_mem_ball\n\n/-- The exponential map in a commutative Banach-algebra `𝔸` over a normed field `𝕂` of\ncharacteristic zero has strict Fréchet-derivative `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x` in\nthe disk of convergence. -/\ntheorem hasStrictFderivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸}\n    (hx : x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :\n    HasStrictFderivAt (exp 𝕂) (exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸) x :=\n  let ⟨p, hp⟩ := analyticAt_exp_of_mem_ball x hx\n  hp.HasFderivAt.unique (hasFderivAt_exp_of_mem_ball hx) ▸ hp.HasStrictFderivAt\n#align has_strict_fderiv_at_exp_of_mem_ball hasStrictFderivAt_exp_of_mem_ball\n\nend AnyFieldCommAlgebra\n\nsection deriv\n\nvariable {𝕂 : Type _} [NontriviallyNormedField 𝕂] [CompleteSpace 𝕂]\n\n/-- The exponential map in a complete normed field `𝕂` of characteristic zero has strict derivative\n`exp 𝕂 x` at any point `x` in the disk of convergence. -/\ntheorem hasStrictDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝕂}\n    (hx : x ∈ EMetric.ball (0 : 𝕂) (expSeries 𝕂 𝕂).radius) : HasStrictDerivAt (exp 𝕂) (exp 𝕂 x) x :=\n  by simpa using (hasStrictFderivAt_exp_of_mem_ball hx).HasStrictDerivAt\n#align has_strict_deriv_at_exp_of_mem_ball hasStrictDerivAt_exp_of_mem_ball\n\n/-- The exponential map in a complete normed field `𝕂` of characteristic zero has derivative\n`exp 𝕂 x` at any point `x` in the disk of convergence. -/\ntheorem hasDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝕂}\n    (hx : x ∈ EMetric.ball (0 : 𝕂) (expSeries 𝕂 𝕂).radius) : HasDerivAt (exp 𝕂) (exp 𝕂 x) x :=\n  (hasStrictDerivAt_exp_of_mem_ball hx).HasDerivAt\n#align has_deriv_at_exp_of_mem_ball hasDerivAt_exp_of_mem_ball\n\n/-- The exponential map in a complete normed field `𝕂` of characteristic zero has strict derivative\n`1` at zero, as long as it converges on a neighborhood of zero. -/\ntheorem hasStrictDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝕂).radius) :\n    HasStrictDerivAt (exp 𝕂) (1 : 𝕂) 0 :=\n  (hasStrictFderivAt_exp_zero_of_radius_pos h).HasStrictDerivAt\n#align has_strict_deriv_at_exp_zero_of_radius_pos hasStrictDerivAt_exp_zero_of_radius_pos\n\n/-- The exponential map in a complete normed field `𝕂` of characteristic zero has derivative\n`1` at zero, as long as it converges on a neighborhood of zero. -/\ntheorem hasDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝕂).radius) :\n    HasDerivAt (exp 𝕂) (1 : 𝕂) 0 :=\n  (hasStrictDerivAt_exp_zero_of_radius_pos h).HasDerivAt\n#align has_deriv_at_exp_zero_of_radius_pos hasDerivAt_exp_zero_of_radius_pos\n\nend deriv\n\nsection IsROrCAnyAlgebra\n\nvariable {𝕂 𝔸 : Type _} [IsROrC 𝕂] [NormedRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸]\n\n/-- The exponential in a Banach-algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has strict Fréchet-derivative\n`1 : 𝔸 →L[𝕂] 𝔸` at zero. -/\ntheorem hasStrictFderivAt_exp_zero : HasStrictFderivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 :=\n  hasStrictFderivAt_exp_zero_of_radius_pos (expSeries_radius_pos 𝕂 𝔸)\n#align has_strict_fderiv_at_exp_zero hasStrictFderivAt_exp_zero\n\n/-- The exponential in a Banach-algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has Fréchet-derivative\n`1 : 𝔸 →L[𝕂] 𝔸` at zero. -/\ntheorem hasFderivAt_exp_zero : HasFderivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 :=\n  hasStrictFderivAt_exp_zero.HasFderivAt\n#align has_fderiv_at_exp_zero hasFderivAt_exp_zero\n\nend IsROrCAnyAlgebra\n\nsection IsROrCCommAlgebra\n\nvariable {𝕂 𝔸 : Type _} [IsROrC 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸]\n\n/-- The exponential map in a commutative Banach-algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has strict\nFréchet-derivative `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x`. -/\ntheorem hasStrictFderivAt_exp {x : 𝔸} : HasStrictFderivAt (exp 𝕂) (exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸) x :=\n  hasStrictFderivAt_exp_of_mem_ball ((expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _)\n#align has_strict_fderiv_at_exp hasStrictFderivAt_exp\n\n/-- The exponential map in a commutative Banach-algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has\nFréchet-derivative `exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x`. -/\ntheorem hasFderivAt_exp {x : 𝔸} : HasFderivAt (exp 𝕂) (exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸) x :=\n  hasStrictFderivAt_exp.HasFderivAt\n#align has_fderiv_at_exp hasFderivAt_exp\n\nend IsROrCCommAlgebra\n\nsection DerivROrC\n\nvariable {𝕂 : Type _} [IsROrC 𝕂]\n\n/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has strict derivative `exp 𝕂 x` at any point\n`x`. -/\ntheorem hasStrictDerivAt_exp {x : 𝕂} : HasStrictDerivAt (exp 𝕂) (exp 𝕂 x) x :=\n  hasStrictDerivAt_exp_of_mem_ball ((expSeries_radius_eq_top 𝕂 𝕂).symm ▸ edist_lt_top _ _)\n#align has_strict_deriv_at_exp hasStrictDerivAt_exp\n\n/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has derivative `exp 𝕂 x` at any point `x`. -/\ntheorem hasDerivAt_exp {x : 𝕂} : HasDerivAt (exp 𝕂) (exp 𝕂 x) x :=\n  hasStrictDerivAt_exp.HasDerivAt\n#align has_deriv_at_exp hasDerivAt_exp\n\n/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has strict derivative `1` at zero. -/\ntheorem hasStrictDerivAt_exp_zero : HasStrictDerivAt (exp 𝕂) (1 : 𝕂) 0 :=\n  hasStrictDerivAt_exp_zero_of_radius_pos (expSeries_radius_pos 𝕂 𝕂)\n#align has_strict_deriv_at_exp_zero hasStrictDerivAt_exp_zero\n\n/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has derivative `1` at zero. -/\ntheorem hasDerivAt_exp_zero : HasDerivAt (exp 𝕂) (1 : 𝕂) 0 :=\n  hasStrictDerivAt_exp_zero.HasDerivAt\n#align has_deriv_at_exp_zero hasDerivAt_exp_zero\n\nend DerivROrC\n\ntheorem Complex.exp_eq_exp_ℂ : Complex.exp = exp ℂ :=\n  by\n  refine' funext fun x => _\n  rw [Complex.exp, exp_eq_tsum_div]\n  exact\n    tendsto_nhds_unique x.exp'.tendsto_limit (exp_series_div_summable ℝ x).HasSum.tendsto_sum_nat\n#align complex.exp_eq_exp_ℂ Complex.exp_eq_exp_ℂ\n\ntheorem Real.exp_eq_exp_ℝ : Real.exp = exp ℝ :=\n  by\n  ext x\n  exact_mod_cast congr_fun Complex.exp_eq_exp_ℂ x\n#align real.exp_eq_exp_ℝ Real.exp_eq_exp_ℝ\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Analysis/SpecialFunctions/Exponential.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.49049366270493455}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Jeremy Avigad, Simon Hudon\n-/\nimport data.set.basic\nimport logic.equiv.basic\n\n/-!\n# Partial values of a type\n\nThis file defines `part α`, the partial values of a type.\n\n`o : part α` carries a proposition `o.dom`, its domain, along with a function `get : o.dom → α`, its\nvalue. The rule is then that every partial value has a value but, to access it, you need to provide\na proof of the domain.\n\n`part α` behaves the same as `option α` except that `o : option α` is decidably `none` or `some a`\nfor some `a : α`, while the domain of `o : part α` doesn't have to be decidable. That means you can\ntranslate back and forth between a partial value with a decidable domain and an option, and\n`option α` and `part α` are classically equivalent. In general, `part α` is bigger than `option α`.\n\nIn current mathlib, `part ℕ`, aka `enat`, is used to move decidability of the order to decidability\nof `enat.find` (which is the smallest natural satisfying a predicate, or `∞` if there's none).\n\n## Main declarations\n\n`option`-like declarations:\n* `part.none`: The partial value whose domain is `false`.\n* `part.some a`: The partial value whose domain is `true` and whose value is `a`.\n* `part.of_option`: Converts an `option α` to a `part α` by sending `none` to `none` and `some a` to\n  `some a`.\n* `part.to_option`: Converts a `part α` with a decidable domain to an `option α`.\n* `part.equiv_option`: Classical equivalence between `part α` and `option α`.\n\nMonadic structure:\n* `part.bind`: `o.bind f` has value `(f (o.get _)).get _` (`f o` morally) and is defined when `o`\n  and `f (o.get _)` are defined.\n* `part.map`: Maps the value and keeps the same domain.\n\nOther:\n* `part.restrict`: `part.restrict p o` replaces the domain of `o : part α` by `p : Prop` so long as\n  `p → o.dom`.\n* `part.assert`: `assert p f` appends `p` to the domains of the values of a partial function.\n* `part.unwrap`: Gets the value of a partial value regardless of its domain. Unsound.\n\n## Notation\n\nFor `a : α`, `o : part α`, `a ∈ o` means that `o` is defined and equal to `a`. Formally, it means\n`o.dom` and `o.get _ = a`.\n-/\n\nopen function\n\n/-- `part α` is the type of \"partial values\" of type `α`. It\n  is similar to `option α` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure {u} part (α : Type u) : Type u :=\n(dom : Prop)\n(get : dom → α)\n\nnamespace part\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\n/-- Convert a `part α` with a decidable domain to an option -/\ndef to_option (o : part α) [decidable o.dom] : option α :=\nif h : dom o then some (o.get h) else none\n\n/-- `part` extensionality -/\ntheorem ext' : ∀ {o p : part α}\n  (H1 : o.dom ↔ p.dom)\n  (H2 : ∀h₁ h₂, o.get h₁ = p.get h₂), o = p\n| ⟨od, o⟩ ⟨pd, p⟩ H1 H2 := have t : od = pd, from propext H1,\n  by cases t; rw [show o = p, from funext $ λp, H2 p p]\n\n/-- `part` eta expansion -/\n@[simp] theorem eta : Π (o : part α), (⟨o.dom, λ h, o.get h⟩ : part α) = o\n| ⟨h, f⟩ := rfl\n\n/-- `a ∈ o` means that `o` is defined and equal to `a` -/\nprotected def mem (a : α) (o : part α) : Prop := ∃ h, o.get h = a\n\ninstance : has_mem α (part α) := ⟨part.mem⟩\n\ntheorem mem_eq (a : α) (o : part α) : (a ∈ o) = (∃ h, o.get h = a) :=\nrfl\n\ntheorem dom_iff_mem : ∀ {o : part α}, o.dom ↔ ∃ y, y ∈ o\n| ⟨p, f⟩ := ⟨λh, ⟨f h, h, rfl⟩, λ⟨_, h, rfl⟩, h⟩\n\ntheorem get_mem {o : part α} (h) : get o h ∈ o := ⟨_, rfl⟩\n\n@[simp] lemma mem_mk_iff {p : Prop} {o : p → α} {a : α} : a ∈ part.mk p o ↔ ∃ h, o h = a := iff.rfl\n\n/-- `part` extensionality -/\n@[ext]\ntheorem ext {o p : part α} (H : ∀ a, a ∈ o ↔ a ∈ p) : o = p :=\next' ⟨λ h, ((H _).1 ⟨h, rfl⟩).fst,\n     λ h, ((H _).2 ⟨h, rfl⟩).fst⟩ $\nλ a b, ((H _).2 ⟨_, rfl⟩).snd\n\n/-- The `none` value in `part` has a `false` domain and an empty function. -/\ndef none : part α := ⟨false, false.rec _⟩\n\ninstance : inhabited (part α) := ⟨none⟩\n\n@[simp] theorem not_mem_none (a : α) : a ∉ @none α := λ h, h.fst\n\n/-- The `some a` value in `part` has a `true` domain and the\n  function returns `a`. -/\ndef some (a : α) : part α := ⟨true, λ_, a⟩\n\ntheorem mem_unique : ∀ {a b : α} {o : part α}, a ∈ o → b ∈ o → a = b\n| _ _ ⟨p, f⟩ ⟨h₁, rfl⟩ ⟨h₂, rfl⟩ := rfl\n\ntheorem mem.left_unique : relator.left_unique ((∈) : α → part α → Prop) :=\nλ a o b, mem_unique\n\ntheorem get_eq_of_mem {o : part α} {a} (h : a ∈ o) (h') : get o h' = a :=\nmem_unique ⟨_, rfl⟩ h\n\nprotected theorem subsingleton (o : part α) : set.subsingleton {a | a ∈ o} :=\nλ a ha b hb, mem_unique ha hb\n\n@[simp] theorem get_some {a : α} (ha : (some a).dom) : get (some a) ha = a := rfl\n\ntheorem mem_some (a : α) : a ∈ some a := ⟨trivial, rfl⟩\n\n@[simp] theorem mem_some_iff {a b} : b ∈ (some a : part α) ↔ b = a :=\n⟨λ⟨h, e⟩, e.symm, λ e, ⟨trivial, e.symm⟩⟩\n\ntheorem eq_some_iff {a : α} {o : part α} : o = some a ↔ a ∈ o :=\n⟨λ e, e.symm ▸ mem_some _,\n λ ⟨h, e⟩, e ▸ ext' (iff_true_intro h) (λ _ _, rfl)⟩\n\ntheorem eq_none_iff {o : part α} : o = none ↔ ∀ a, a ∉ o :=\n⟨λ e, e.symm ▸ not_mem_none, λ h, ext (by simpa)⟩\n\ntheorem eq_none_iff' {o : part α} : o = none ↔ ¬ o.dom :=\n⟨λ e, e.symm ▸ id, λ h, eq_none_iff.2 (λ a h', h h'.fst)⟩\n\n@[simp] lemma some_ne_none (x : α) : some x ≠ none :=\nby { intro h, change none.dom, rw [← h], trivial }\n\n@[simp] lemma none_ne_some (x : α) : none ≠ some x :=\n(some_ne_none x).symm\n\nlemma ne_none_iff {o : part α} : o ≠ none ↔ ∃ x, o = some x :=\nbegin\n  split,\n  { rw [ne, eq_none_iff', not_not], exact λ h, ⟨o.get h, eq_some_iff.2 (get_mem h)⟩ },\n  { rintro ⟨x, rfl⟩, apply some_ne_none }\nend\n\nlemma eq_none_or_eq_some (o : part α) : o = none ∨ ∃ x, o = some x :=\nor_iff_not_imp_left.2 ne_none_iff.1\n\nlemma some_injective : injective (@part.some α) :=\nλ a b h, congr_fun (eq_of_heq (part.mk.inj h).2) trivial\n\n@[simp] lemma some_inj {a b : α} : part.some a = some b ↔ a = b := some_injective.eq_iff\n\n@[simp] lemma some_get {a : part α} (ha : a.dom) :\n  part.some (part.get a ha) = a :=\neq.symm (eq_some_iff.2 ⟨ha, rfl⟩)\n\nlemma get_eq_iff_eq_some {a : part α} {ha : a.dom} {b : α} :\n  a.get ha = b ↔ a = some b :=\n⟨λ h, by simp [h.symm], λ h, by simp [h]⟩\n\nlemma get_eq_get_of_eq (a : part α) (ha : a.dom) {b : part α} (h : a = b) :\n  a.get ha = b.get (h ▸ ha) :=\nby { congr, exact h }\n\nlemma get_eq_iff_mem {o : part α} {a : α} (h : o.dom) : o.get h = a ↔ a ∈ o :=\n⟨λ H, ⟨h, H⟩, λ ⟨h', H⟩, H⟩\n\nlemma eq_get_iff_mem {o : part α} {a : α} (h : o.dom) : a = o.get h ↔ a ∈ o :=\neq_comm.trans (get_eq_iff_mem h)\n\n@[simp] lemma none_to_option [decidable (@none α).dom] : (none : part α).to_option = option.none :=\ndif_neg id\n\n@[simp] lemma some_to_option (a : α) [decidable (some a).dom] :\n  (some a).to_option = option.some a :=\ndif_pos trivial\n\ninstance none_decidable : decidable (@none α).dom := decidable.false\ninstance some_decidable (a : α) : decidable (some a).dom := decidable.true\n\n/-- Retrieves the value of `a : part α` if it exists, and return the provided default value\notherwise. -/\ndef get_or_else (a : part α) [decidable a.dom] (d : α) :=\nif ha : a.dom then a.get ha else d\n\n@[simp] lemma get_or_else_none (d : α) [decidable (none : part α).dom] : get_or_else none d = d :=\ndif_neg id\n\n@[simp] lemma get_or_else_some (a : α) (d : α) [decidable (some a).dom] :\n  get_or_else (some a) d = a :=\ndif_pos trivial\n\n@[simp] theorem mem_to_option {o : part α} [decidable o.dom] {a : α} :\n  a ∈ to_option o ↔ a ∈ o :=\nbegin\n  unfold to_option,\n  by_cases h : o.dom; simp [h],\n  { exact ⟨λ h, ⟨_, h⟩, λ ⟨_, h⟩, h⟩ },\n  { exact mt Exists.fst h }\nend\n\nprotected lemma dom.to_option {o : part α} [decidable o.dom] (h : o.dom) : o.to_option = o.get h :=\ndif_pos h\n\nlemma to_option_eq_none_iff {a : part α} [decidable a.dom] : a.to_option = option.none ↔ ¬ a.dom :=\nne.dite_eq_right_iff $ λ h, option.some_ne_none _\n\n@[simp] lemma elim_to_option {α β : Type*} (a : part α) [decidable a.dom] (b : β) (f : α → β) :\n  a.to_option.elim b f = if h : a.dom then f (a.get h) else b :=\nbegin\n  split_ifs,\n  { rw h.to_option,\n    refl },\n  { rw part.to_option_eq_none_iff.2 h,\n    refl }\nend\n\n/-- Converts an `option α` into a `part α`. -/\ndef of_option : option α → part α\n| option.none     := none\n| (option.some a) := some a\n\n@[simp] theorem mem_of_option {a : α} : ∀ {o : option α}, a ∈ of_option o ↔ a ∈ o\n| option.none     := ⟨λ h, h.fst.elim, λ h, option.no_confusion h⟩\n| (option.some b) := ⟨λ h, congr_arg option.some h.snd,\n  λ h, ⟨trivial, option.some.inj h⟩⟩\n\n@[simp] theorem of_option_dom {α} : ∀ (o : option α), (of_option o).dom ↔ o.is_some\n| option.none     := by simp [of_option, none]\n| (option.some a) := by simp [of_option]\n\ntheorem of_option_eq_get {α} (o : option α) : of_option o = ⟨_, @option.get _ o⟩ :=\npart.ext' (of_option_dom o) $ λ h₁ h₂, by cases o; [cases h₁, refl]\n\ninstance : has_coe (option α) (part α) := ⟨of_option⟩\n\n@[simp] theorem mem_coe {a : α} {o : option α} :\n  a ∈ (o : part α) ↔ a ∈ o := mem_of_option\n\n@[simp] theorem coe_none : (@option.none α : part α) = none := rfl\n@[simp] theorem coe_some (a : α) : (option.some a : part α) = some a := rfl\n\n@[elab_as_eliminator] protected lemma induction_on {P : part α → Prop}\n  (a : part α) (hnone : P none) (hsome : ∀ a : α, P (some a)) : P a :=\n(classical.em a.dom).elim\n  (λ h, part.some_get h ▸ hsome _)\n  (λ h, (eq_none_iff'.2 h).symm ▸ hnone)\n\ninstance of_option_decidable : ∀ o : option α, decidable (of_option o).dom\n| option.none     := part.none_decidable\n| (option.some a) := part.some_decidable a\n\n@[simp] theorem to_of_option (o : option α) : to_option (of_option o) = o :=\nby cases o; refl\n\n@[simp] theorem of_to_option (o : part α) [decidable o.dom] : of_option (to_option o) = o :=\next $ λ a, mem_of_option.trans mem_to_option\n\n/-- `part α` is (classically) equivalent to `option α`. -/\nnoncomputable def equiv_option : part α ≃ option α :=\nby haveI := classical.dec; exact\n⟨λ o, to_option o, of_option, λ o, of_to_option o,\n λ o, eq.trans (by dsimp; congr) (to_of_option o)⟩\n\n/-- We give `part α` the order where everything is greater than `none`. -/\ninstance : partial_order (part α) :=\n{ le := λ x y, ∀ i, i ∈ x → i ∈ y,\n  le_refl := λ x y, id,\n  le_trans := λ x y z f g i, g _ ∘ f _,\n  le_antisymm := λ x y f g, part.ext $ λ z, ⟨f _, g _⟩ }\n\ninstance : order_bot (part α) :=\n{ bot := none,\n  bot_le := by { introv x, rintro ⟨⟨_⟩,_⟩, } }\n\nlemma le_total_of_le_of_le {x y : part α} (z : part α) (hx : x ≤ z) (hy : y ≤ z) :\n  x ≤ y ∨ y ≤ x :=\nbegin\n  rcases part.eq_none_or_eq_some x with h | ⟨b, h₀⟩,\n  { rw h, left, apply order_bot.bot_le _ },\n  right, intros b' h₁,\n  rw part.eq_some_iff at h₀,\n  replace hx := hx _ h₀, replace hy := hy _ h₁,\n  replace hx := part.mem_unique hx hy, subst hx,\n  exact h₀\nend\n\n/-- `assert p f` is a bind-like operation which appends an additional condition\n  `p` to the domain and uses `f` to produce the value. -/\ndef assert (p : Prop) (f : p → part α) : part α :=\n⟨∃ h : p, (f h).dom, λha, (f ha.fst).get ha.snd⟩\n\n/-- The bind operation has value `g (f.get)`, and is defined when all the\n  parts are defined. -/\nprotected def bind (f : part α) (g : α → part β) : part β :=\nassert (dom f) (λb, g (f.get b))\n\n/-- The map operation for `part` just maps the value and maintains the same domain. -/\n@[simps] def map (f : α → β) (o : part α) : part β :=\n⟨o.dom, f ∘ o.get⟩\n\ntheorem mem_map (f : α → β) {o : part α} :\n  ∀ {a}, a ∈ o → f a ∈ map f o\n| _ ⟨h, rfl⟩ := ⟨_, rfl⟩\n\n@[simp] theorem mem_map_iff (f : α → β) {o : part α} {b} :\n  b ∈ map f o ↔ ∃ a ∈ o, f a = b :=\n⟨match b with _, ⟨h, rfl⟩ := ⟨_, ⟨_, rfl⟩, rfl⟩ end,\n λ ⟨a, h₁, h₂⟩, h₂ ▸ mem_map f h₁⟩\n\n@[simp] theorem map_none (f : α → β) :\n  map f none = none := eq_none_iff.2 $ λ a, by simp\n\n@[simp] theorem map_some (f : α → β) (a : α) : map f (some a) = some (f a) :=\neq_some_iff.2 $ mem_map f $ mem_some _\n\ntheorem mem_assert {p : Prop} {f : p → part α}\n  : ∀ {a} (h : p), a ∈ f h → a ∈ assert p f\n| _ x ⟨h, rfl⟩ := ⟨⟨x, h⟩, rfl⟩\n\n@[simp] theorem mem_assert_iff {p : Prop} {f : p → part α} {a} :\n  a ∈ assert p f ↔ ∃ h : p, a ∈ f h :=\n⟨match a with _, ⟨h, rfl⟩ := ⟨_, ⟨_, rfl⟩⟩ end,\n λ ⟨a, h⟩, mem_assert _ h⟩\n\nlemma assert_pos {p : Prop} {f : p → part α} (h : p) :\n  assert p f = f h :=\nbegin\n  dsimp [assert],\n  cases h' : f h,\n  simp only [h', h, true_and, iff_self, exists_prop_of_true, eq_iff_iff],\n  apply function.hfunext,\n  { simp only [h,h',exists_prop_of_true] },\n  { cc }\nend\n\nlemma assert_neg {p : Prop} {f : p → part α} (h : ¬ p) :\n  assert p f = none :=\nbegin\n  dsimp [assert,none], congr,\n  { simp only [h, not_false_iff, exists_prop_of_false] },\n  { apply function.hfunext,\n    { simp only [h, not_false_iff, exists_prop_of_false] },\n    cc },\nend\n\ntheorem mem_bind {f : part α} {g : α → part β} :\n  ∀ {a b}, a ∈ f → b ∈ g a → b ∈ f.bind g\n| _ _ ⟨h, rfl⟩ ⟨h₂, rfl⟩ := ⟨⟨h, h₂⟩, rfl⟩\n\n@[simp] theorem mem_bind_iff {f : part α} {g : α → part β} {b} :\n  b ∈ f.bind g ↔ ∃ a ∈ f, b ∈ g a :=\n⟨match b with _, ⟨⟨h₁, h₂⟩, rfl⟩ := ⟨_, ⟨_, rfl⟩, ⟨_, rfl⟩⟩ end,\n λ ⟨a, h₁, h₂⟩, mem_bind h₁ h₂⟩\n\nprotected lemma dom.bind {o : part α} (h : o.dom) (f : α → part β) : o.bind f = f (o.get h) :=\nbegin\n  ext b,\n  simp only [part.mem_bind_iff, exists_prop],\n  refine ⟨_, λ hb, ⟨o.get h, part.get_mem _, hb⟩⟩,\n  rintro ⟨a, ha, hb⟩,\n  rwa part.get_eq_of_mem ha,\nend\n\nlemma dom.of_bind {f : α → part β} {a : part α} (h : (a.bind f).dom) : a.dom := h.some\n\n@[simp] theorem bind_none (f : α → part β) :\n  none.bind f = none := eq_none_iff.2 $ λ a, by simp\n\n@[simp] theorem bind_some (a : α) (f : α → part β) :\n  (some a).bind f = f a := ext $ by simp\n\ntheorem bind_of_mem {o : part α} {a : α} (h : a ∈ o) (f : α → part β) :\n  o.bind f = f a :=\nby rw [eq_some_iff.2 h, bind_some]\n\ntheorem bind_some_eq_map (f : α → β) (x : part α) :\n  x.bind (some ∘ f) = map f x :=\next $ by simp [eq_comm]\n\nlemma bind_to_option (f : α → part β) (o : part α) [decidable o.dom] [Π a, decidable (f a).dom]\n  [decidable (o.bind f).dom] :\n  (o.bind f).to_option = o.to_option.elim option.none (λ a, (f a).to_option) :=\nbegin\n  by_cases o.dom,\n  { simp_rw [h.to_option, h.bind],\n    refl },\n  { rw part.to_option_eq_none_iff.2 h,\n    exact part.to_option_eq_none_iff.2 (λ ho, h ho.of_bind) }\nend\n\ntheorem bind_assoc {γ} (f : part α) (g : α → part β) (k : β → part γ) :\n  (f.bind g).bind k = f.bind (λ x, (g x).bind k) :=\next $ λ a, by simp; exact\n ⟨λ ⟨_, ⟨_, h₁, h₂⟩, h₃⟩, ⟨_, h₁, _, h₂, h₃⟩,\n  λ ⟨_, h₁, _, h₂, h₃⟩, ⟨_, ⟨_, h₁, h₂⟩, h₃⟩⟩\n\n@[simp] theorem bind_map {γ} (f : α → β) (x) (g : β → part γ) :\n  (map f x).bind g = x.bind (λ y, g (f y)) :=\nby rw [← bind_some_eq_map, bind_assoc]; simp\n\n@[simp] theorem map_bind {γ} (f : α → part β) (x : part α) (g : β → γ) :\n  map g (x.bind f) = x.bind (λ y, map g (f y)) :=\nby rw [← bind_some_eq_map, bind_assoc]; simp [bind_some_eq_map]\n\ntheorem map_map (g : β → γ) (f : α → β) (o : part α) :\n  map g (map f o) = map (g ∘ f) o :=\nby rw [← bind_some_eq_map, bind_map, bind_some_eq_map]\n\ninstance : monad part :=\n{ pure := @some,\n  map := @map,\n  bind := @part.bind }\n\ninstance : is_lawful_monad part :=\n{ bind_pure_comp_eq_map := @bind_some_eq_map,\n  id_map := λ β f, by cases f; refl,\n  pure_bind := @bind_some,\n  bind_assoc := @bind_assoc }\n\ntheorem map_id' {f : α → α} (H : ∀ (x : α), f x = x) (o) : map f o = o :=\nby rw [show f = id, from funext H]; exact id_map o\n\n@[simp] theorem bind_some_right (x : part α) : x.bind some = x :=\nby rw [bind_some_eq_map]; simp [map_id']\n\n@[simp] theorem pure_eq_some (a : α) : pure a = some a := rfl\n@[simp] theorem ret_eq_some (a : α) : return a = some a := rfl\n\n@[simp] theorem map_eq_map {α β} (f : α → β) (o : part α) :\n  f <$> o = map f o := rfl\n\n@[simp] theorem bind_eq_bind {α β} (f : part α) (g : α → part β) :\n  f >>= g = f.bind g := rfl\n\nlemma bind_le {α} (x : part α) (f : α → part β) (y : part β) :\n  x >>= f ≤ y ↔ (∀ a, a ∈ x → f a ≤ y) :=\nbegin\n  split; intro h,\n  { intros a h' b, replace h := h b,\n    simp only [and_imp, exists_prop, bind_eq_bind, mem_bind_iff, exists_imp_distrib] at h,\n    apply h _ h' },\n  { intros b h',\n    simp only [exists_prop, bind_eq_bind, mem_bind_iff] at h',\n    rcases h' with ⟨a,h₀,h₁⟩, apply h _ h₀ _ h₁ },\nend\n\ninstance : monad_fail part :=\n{ fail := λ_ _, none, ..part.monad }\n\n/-- `restrict p o h` replaces the domain of `o` with `p`, and is well defined when\n  `p` implies `o` is defined. -/\ndef restrict (p : Prop) (o : part α) (H : p → o.dom) : part α :=\n⟨p, λh, o.get (H h)⟩\n\n@[simp]\ntheorem mem_restrict (p : Prop) (o : part α) (h : p → o.dom) (a : α) :\n  a ∈ restrict p o h ↔ p ∧ a ∈ o :=\nbegin\n  dsimp [restrict, mem_eq], split,\n  { rintro ⟨h₀, h₁⟩, exact ⟨h₀, ⟨_, h₁⟩⟩ },\n  rintro ⟨h₀, h₁, h₂⟩, exact ⟨h₀, h₂⟩\nend\n\n/-- `unwrap o` gets the value at `o`, ignoring the condition. This function is unsound. -/\nmeta def unwrap (o : part α) : α := o.get undefined\n\ntheorem assert_defined {p : Prop} {f : p → part α} :\n  ∀ (h : p), (f h).dom → (assert p f).dom := exists.intro\n\ntheorem bind_defined {f : part α} {g : α → part β} :\n  ∀ (h : f.dom), (g (f.get h)).dom → (f.bind g).dom := assert_defined\n\n@[simp] theorem bind_dom {f : part α} {g : α → part β} :\n  (f.bind g).dom ↔ ∃ h : f.dom, (g (f.get h)).dom := iff.rfl\n\nsection instances\n\n/- We define several instances for constants and operations on `part α` inherited from `α`. -/\n\n@[to_additive] instance [has_one α] : has_one (part α) := { one := pure 1 }\n@[to_additive] instance [has_mul α] : has_mul (part α) := { mul := λ a b, (*) <$> a <*> b }\n@[to_additive] instance [has_inv α] : has_inv (part α) := { inv := map has_inv.inv }\n@[to_additive] instance [has_div α] : has_div (part α) := { div := λ a b, (/) <$> a <*> b }\ninstance [has_mod α] : has_mod (part α) := { mod := λ a b, (%) <$> a <*> b }\ninstance [has_append α] : has_append (part α) := { append := λ a b, (++) <$> a <*> b }\ninstance [has_inter α] : has_inter (part α) := { inter := λ a b, (∩) <$> a <*> b }\ninstance [has_union α] : has_union (part α) := { union := λ a b, (∪) <$> a <*> b }\ninstance [has_sdiff α] : has_sdiff (part α) := { sdiff := λ a b, (\\) <$> a <*> b }\n\n@[to_additive]\nlemma one_mem_one [has_one α] : (1 : α) ∈ (1 : part α) := ⟨trivial, rfl⟩\n\n@[to_additive]\nlemma mul_mem_mul [has_mul α] (a b : part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n  ma * mb ∈ a * b := by tidy\n\n@[to_additive]\nlemma left_dom_of_mul_dom [has_mul α] {a b : part α} (hab : dom (a * b)) :\n  a.dom := by tidy\n\n@[to_additive]\n\n\n@[simp, to_additive]\nlemma mul_get_eq [has_mul α] (a b : part α) (hab : dom (a * b)) :\n  (a * b).get hab = a.get (left_dom_of_mul_dom hab) * b.get (right_dom_of_mul_dom hab) :=\nby tidy\n\n@[to_additive]\nlemma some_mul_some [has_mul α] (a b : α) : some a * some b = some (a * b) := by tidy\n\n@[to_additive]\nlemma inv_mem_inv [has_inv α] (a : part α) (ma : α) (ha : ma ∈ a) : ma⁻¹ ∈ a⁻¹ := by tidy\n\n@[to_additive]\nlemma inv_some [has_inv α] (a : α) : (some a)⁻¹ = some (a⁻¹) := rfl\n\n@[to_additive]\nlemma div_mem_div [has_div α] (a b : part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n  ma / mb ∈ a / b := by tidy\n\n@[to_additive]\nlemma left_dom_of_div_dom [has_div α] {a b : part α} (hab : dom (a / b)) :\n  a.dom := by tidy\n\n@[to_additive]\nlemma right_dom_of_div_dom [has_div α] {a b : part α} (hab : dom (a / b)) :\n  b.dom := by tidy\n\n@[simp, to_additive]\nlemma div_get_eq [has_div α] (a b : part α) (hab : dom (a / b)) :\n  (a / b).get hab = a.get (left_dom_of_div_dom hab) / b.get (right_dom_of_div_dom hab) :=\nby tidy\n\n@[to_additive]\nlemma some_div_some [has_div α] (a b : α) : some a / some b = some (a / b) := by tidy\n\nlemma mod_mem_mod [has_mod α] (a b : part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n  ma % mb ∈ a % b := by tidy\n\nlemma left_dom_of_mod_dom [has_mod α] {a b : part α} (hab : dom (a % b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_mod_dom [has_mod α] {a b : part α} (hab : dom (a % b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma mod_get_eq [has_mod α] (a b : part α) (hab : dom (a % b)) :\n  (a % b).get hab = a.get (left_dom_of_mod_dom hab) % b.get (right_dom_of_mod_dom hab) :=\nby tidy\n\nlemma some_mod_some [has_mod α] (a b : α) : some a % some b = some (a % b) := by tidy\n\nlemma append_mem_append [has_append α] (a b : part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n  ma ++ mb ∈ a ++ b := by tidy\n\nlemma left_dom_of_append_dom [has_append α] {a b : part α} (hab : dom (a ++ b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_append_dom [has_append α] {a b : part α} (hab : dom (a ++ b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma append_get_eq [has_append α] (a b : part α) (hab : dom (a ++ b)) :\n  (a ++ b).get hab = a.get (left_dom_of_append_dom hab) ++ b.get (right_dom_of_append_dom hab) :=\nby tidy\n\nlemma some_append_some [has_append α] (a b : α) : some a ++ some b = some (a ++ b) := by tidy\n\nlemma inter_mem_inter [has_inter α] (a b : part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n  ma ∩ mb ∈ a ∩ b := by tidy\n\nlemma left_dom_of_inter_dom [has_inter α] {a b : part α} (hab : dom (a ∩ b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_inter_dom [has_inter α] {a b : part α} (hab : dom (a ∩ b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma inter_get_eq [has_inter α] (a b : part α) (hab : dom (a ∩ b)) :\n  (a ∩ b).get hab = a.get (left_dom_of_inter_dom hab) ∩ b.get (right_dom_of_inter_dom hab) :=\nby tidy\n\nlemma some_inter_some [has_inter α] (a b : α) : some a ∩ some b = some (a ∩ b) := by tidy\n\nlemma union_mem_union [has_union α] (a b : part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n  ma ∪ mb ∈ a ∪ b := by tidy\n\nlemma left_dom_of_union_dom [has_union α] {a b : part α} (hab : dom (a ∪ b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_union_dom [has_union α] {a b : part α} (hab : dom (a ∪ b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma union_get_eq [has_union α] (a b : part α) (hab : dom (a ∪ b)) :\n  (a ∪ b).get hab = a.get (left_dom_of_union_dom hab) ∪ b.get (right_dom_of_union_dom hab) :=\nby tidy\n\nlemma some_union_some [has_union α] (a b : α) : some a ∪ some b = some (a ∪ b) := by tidy\n\nlemma sdiff_mem_sdiff [has_sdiff α] (a b : part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n  ma \\ mb ∈ a \\ b := by tidy\n\nlemma left_dom_of_sdiff_dom [has_sdiff α] {a b : part α} (hab : dom (a \\ b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_sdiff_dom [has_sdiff α] {a b : part α} (hab : dom (a \\ b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma sdiff_get_eq [has_sdiff α] (a b : part α) (hab : dom (a \\ b)) :\n  (a \\ b).get hab = a.get (left_dom_of_sdiff_dom hab) \\ b.get (right_dom_of_sdiff_dom hab) :=\nby tidy\n\nlemma some_sdiff_some [has_sdiff α] (a b : α) : some a \\ some b = some (a \\ b) := by tidy\n\nend instances\n\nend part\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/data/part.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.4904936591179338}}
{"text": "/-\nCopyright (c) 2020 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n\n! This file was ported from Lean 3 source module algebra.lie.direct_sum\n! leanprover-community/mathlib commit c0cc689babd41c0e9d5f02429211ffbe2403472a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.DirectSum.Module\nimport Mathbin.Algebra.Lie.OfAssociative\nimport Mathbin.Algebra.Lie.Submodule\nimport Mathbin.Algebra.Lie.Basic\n\n/-!\n# Direct sums of Lie algebras and Lie modules\n\nDirect sums of Lie algebras and Lie modules carry natural algebra and module structures.\n\n## Tags\n\nlie algebra, lie module, direct sum\n-/\n\n\nuniverse u v w w₁\n\nnamespace DirectSum\n\nopen Dfinsupp\n\nopen DirectSum\n\nvariable {R : Type u} {ι : Type v} [CommRing R]\n\nsection Modules\n\n/-! The direct sum of Lie modules over a fixed Lie algebra carries a natural Lie module\nstructure. -/\n\n\nvariable {L : Type w₁} {M : ι → Type w}\n\nvariable [LieRing L] [LieAlgebra R L]\n\nvariable [∀ i, AddCommGroup (M i)] [∀ i, Module R (M i)]\n\nvariable [∀ i, LieRingModule L (M i)] [∀ i, LieModule R L (M i)]\n\ninstance : LieRingModule L (⨁ i, M i)\n    where\n  bracket x m := m.mapRange (fun i m' => ⁅x, m'⁆) fun i => lie_zero x\n  add_lie x y m := by\n    ext\n    simp only [map_range_apply, add_apply, add_lie]\n  lie_add x m n := by\n    ext\n    simp only [map_range_apply, add_apply, lie_add]\n  leibniz_lie x y m := by\n    ext\n    simp only [map_range_apply, lie_lie, add_apply, sub_add_cancel]\n\n@[simp]\ntheorem lie_module_bracket_apply (x : L) (m : ⨁ i, M i) (i : ι) : ⁅x, m⁆ i = ⁅x, m i⁆ :=\n  mapRange_apply _ _ m i\n#align direct_sum.lie_module_bracket_apply DirectSum.lie_module_bracket_apply\n\ninstance : LieModule R L (⨁ i, M i)\n    where\n  smul_lie t x m := by\n    ext i\n    simp only [smul_lie, lie_module_bracket_apply, smul_apply]\n  lie_smul t x m := by\n    ext i\n    simp only [lie_smul, lie_module_bracket_apply, smul_apply]\n\nvariable (R ι L M)\n\n/-- The inclusion of each component into a direct sum as a morphism of Lie modules. -/\ndef lieModuleOf [DecidableEq ι] (j : ι) : M j →ₗ⁅R,L⁆ ⨁ i, M i :=\n  { lof R ι M j with\n    map_lie' := fun x m => by\n      ext i; by_cases h : j = i\n      · rw [← h]\n        simp\n      · simp [lof, single_eq_of_ne h] }\n#align direct_sum.lie_module_of DirectSum.lieModuleOf\n\n/-- The projection map onto one component, as a morphism of Lie modules. -/\ndef lieModuleComponent (j : ι) : (⨁ i, M i) →ₗ⁅R,L⁆ M j :=\n  { component R ι M j with\n    map_lie' := fun x m => by\n      simp only [component, lapply_apply, lie_module_bracket_apply, LinearMap.toFun_eq_coe] }\n#align direct_sum.lie_module_component DirectSum.lieModuleComponent\n\nend Modules\n\nsection Algebras\n\n/-! The direct sum of Lie algebras carries a natural Lie algebra structure. -/\n\n\nvariable (L : ι → Type w)\n\nvariable [∀ i, LieRing (L i)] [∀ i, LieAlgebra R (L i)]\n\ninstance lieRing : LieRing (⨁ i, L i) :=\n  {\n    (inferInstance :\n      AddCommGroup\n        _) with\n    bracket := zipWith (fun i => fun x y => ⁅x, y⁆) fun i => lie_zero 0\n    add_lie := fun x y z => by\n      ext\n      simp only [zip_with_apply, add_apply, add_lie]\n    lie_add := fun x y z => by\n      ext\n      simp only [zip_with_apply, add_apply, lie_add]\n    lie_self := fun x => by\n      ext\n      simp only [zip_with_apply, add_apply, lie_self, zero_apply]\n    leibniz_lie := fun x y z => by\n      ext\n      simp only [sub_apply, zip_with_apply, add_apply, zero_apply]\n      apply leibniz_lie }\n#align direct_sum.lie_ring DirectSum.lieRing\n\n@[simp]\ntheorem bracket_apply (x y : ⨁ i, L i) (i : ι) : ⁅x, y⁆ i = ⁅x i, y i⁆ :=\n  zipWith_apply _ _ x y i\n#align direct_sum.bracket_apply DirectSum.bracket_apply\n\ninstance lieAlgebra : LieAlgebra R (⨁ i, L i) :=\n  { (inferInstance : Module R _) with\n    lie_smul := fun c x y => by\n      ext\n      simp only [zip_with_apply, smul_apply, bracket_apply, lie_smul] }\n#align direct_sum.lie_algebra DirectSum.lieAlgebra\n\nvariable (R ι L)\n\n/-- The inclusion of each component into the direct sum as morphism of Lie algebras. -/\n@[simps]\ndef lieAlgebraOf [DecidableEq ι] (j : ι) : L j →ₗ⁅R⁆ ⨁ i, L i :=\n  { lof R ι L j with\n    toFun := of L j\n    map_lie' := fun x y => by\n      ext i\n      by_cases h : j = i\n      · rw [← h]\n        simp [of]\n      · simp [of, single_eq_of_ne h] }\n#align direct_sum.lie_algebra_of DirectSum.lieAlgebraOf\n\n/-- The projection map onto one component, as a morphism of Lie algebras. -/\n@[simps]\ndef lieAlgebraComponent (j : ι) : (⨁ i, L i) →ₗ⁅R⁆ L j :=\n  { component R ι L j with\n    toFun := component R ι L j\n    map_lie' := fun x y => by\n      simp only [component, bracket_apply, lapply_apply, LinearMap.toFun_eq_coe] }\n#align direct_sum.lie_algebra_component DirectSum.lieAlgebraComponent\n\n@[ext]\ntheorem lieAlgebra_ext {x y : ⨁ i, L i}\n    (h : ∀ i, lieAlgebraComponent R ι L i x = lieAlgebraComponent R ι L i y) : x = y :=\n  Dfinsupp.ext h\n#align direct_sum.lie_algebra_ext DirectSum.lieAlgebra_ext\n\ninclude R\n\ntheorem lie_of_of_ne [DecidableEq ι] {i j : ι} (hij : j ≠ i) (x : L i) (y : L j) :\n    ⁅of L i x, of L j y⁆ = 0 := by\n  apply lie_algebra_ext R ι L; intro k\n  rw [LieHom.map_lie]\n  simp only [component, of, lapply_apply, single_add_hom_apply, lie_algebra_component_apply,\n    single_apply, zero_apply]\n  by_cases hik : i = k\n  · simp only [dif_neg, not_false_iff, lie_zero, hik.symm, hij]\n  · simp only [dif_neg, not_false_iff, zero_lie, hik]\n#align direct_sum.lie_of_of_ne DirectSum.lie_of_of_ne\n\ntheorem lie_of_of_eq [DecidableEq ι] {i j : ι} (hij : j = i) (x : L i) (y : L j) :\n    ⁅of L i x, of L j y⁆ = of L i ⁅x, hij.recOn y⁆ :=\n  by\n  have : of L j y = of L i (hij.rec_on y) := Eq.drec (Eq.refl _) hij\n  rw [this, ← lie_algebra_of_apply R ι L i ⁅x, hij.rec_on y⁆, LieHom.map_lie, lie_algebra_of_apply,\n    lie_algebra_of_apply]\n#align direct_sum.lie_of_of_eq DirectSum.lie_of_of_eq\n\n@[simp]\ntheorem lie_of [DecidableEq ι] {i j : ι} (x : L i) (y : L j) :\n    ⁅of L i x, of L j y⁆ = if hij : j = i then lieAlgebraOf R ι L i ⁅x, hij.recOn y⁆ else 0 :=\n  by\n  by_cases hij : j = i\n  · simp only [lie_of_of_eq R ι L hij x y, hij, dif_pos, not_false_iff, lie_algebra_of_apply]\n  · simp only [lie_of_of_ne R ι L hij x y, hij, dif_neg, not_false_iff]\n#align direct_sum.lie_of DirectSum.lie_of\n\nvariable {R L ι}\n\n/-- Given a family of Lie algebras `L i`, together with a family of morphisms of Lie algebras\n`f i : L i →ₗ⁅R⁆ L'` into a fixed Lie algebra `L'`, we have a natural linear map:\n`(⨁ i, L i) →ₗ[R] L'`. If in addition `⁅f i x, f j y⁆ = 0` for any `x ∈ L i` and `y ∈ L j` (`i ≠ j`)\nthen this map is a morphism of Lie algebras. -/\n@[simps]\ndef toLieAlgebra [DecidableEq ι] (L' : Type w₁) [LieRing L'] [LieAlgebra R L']\n    (f : ∀ i, L i →ₗ⁅R⁆ L') (hf : ∀ i j : ι, i ≠ j → ∀ (x : L i) (y : L j), ⁅f i x, f j y⁆ = 0) :\n    (⨁ i, L i) →ₗ⁅R⁆ L' :=\n  {/- The goal is linear in `y`. We can use this to reduce to the case that `y` has only one\n              non-zero component. -/\n      -- Similarly, we can reduce to the case that `x` has only one non-zero component. \n      -- Tidy up and use `lie_of`. \n      -- And finish with trivial case analysis.\n      toModule\n      R ι L' fun i =>\n      (f i : L i →ₗ[R]\n          L') with\n    toFun := toModule R ι L' fun i => (f i : L i →ₗ[R] L')\n    map_lie' := fun x y => by\n      let f' i := (f i : L i →ₗ[R] L')\n      suffices\n        ∀ (i : ι) (y : L i),\n          to_module R ι L' f' ⁅x, of L i y⁆ =\n            ⁅to_module R ι L' f' x, to_module R ι L' f' (of L i y)⁆\n        by\n        simp only [← LieAlgebra.ad_apply R]\n        rw [← LinearMap.comp_apply, ← LinearMap.comp_apply]\n        congr\n        clear y\n        ext (i y)\n        exact this i y\n      suffices\n        ∀ (i j) (y : L i) (x : L j),\n          to_module R ι L' f' ⁅of L j x, of L i y⁆ =\n            ⁅to_module R ι L' f' (of L j x), to_module R ι L' f' (of L i y)⁆\n        by\n        intro i y\n        rw [← lie_skew x, ← lie_skew (to_module R ι L' f' x)]\n        simp only [LinearMap.map_neg, neg_inj, ← LieAlgebra.ad_apply R]\n        rw [← LinearMap.comp_apply, ← LinearMap.comp_apply]\n        congr\n        clear x\n        ext (j x)\n        exact this j i x y\n      intro i j y x\n      simp only [lie_of R, lie_algebra_of_apply, LieHom.coe_toLinearMap, to_add_monoid_of,\n        coe_to_module_eq_coe_to_add_monoid, LinearMap.toAddMonoidHom_coe]\n      rcases eq_or_ne i j with (h | h)\n      · have h' : f j (h.rec_on y) = f i y := Eq.drec (Eq.refl _) h\n        simp only [h, h', LieHom.coe_toLinearMap, dif_pos, LieHom.map_lie, to_add_monoid_of,\n          LinearMap.toAddMonoidHom_coe]\n      · simp only [h, hf j i h.symm x y, dif_neg, not_false_iff, AddMonoidHom.map_zero] }\n#align direct_sum.to_lie_algebra DirectSum.toLieAlgebra\n\nend Algebras\n\nsection Ideals\n\nvariable {L : Type w} [LieRing L] [LieAlgebra R L] (I : ι → LieIdeal R L)\n\n/-- The fact that this instance is necessary seems to be a bug in typeclass inference. See\n[this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/\nTypeclass.20resolution.20under.20binders/near/245151099). -/\ninstance lieRingOfIdeals : LieRing (⨁ i, I i) :=\n  DirectSum.lieRing fun i => ↥(I i)\n#align direct_sum.lie_ring_of_ideals DirectSum.lieRingOfIdeals\n\n/-- See `direct_sum.lie_ring_of_ideals` comment. -/\ninstance lieAlgebraOfIdeals : LieAlgebra R (⨁ i, I i) :=\n  DirectSum.lieAlgebra fun i => ↥(I i)\n#align direct_sum.lie_algebra_of_ideals DirectSum.lieAlgebraOfIdeals\n\nend Ideals\n\nend DirectSum\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Lie/DirectSum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.490493658064845}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport data.rat.order\nimport data.int.char_zero\n\n/-!\n# Casts for Rational Numbers\n\n## Summary\n\nWe define the canonical injection from ℚ into an arbitrary division ring and prove various\ncasting lemmas showing the well-behavedness of this injection.\n\n## Notations\n\n- `/.` is infix notation for `rat.mk`.\n\n## Tags\n\nrat, rationals, field, ℚ, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nnamespace rat\nvariable {α : Type*}\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring α]\n\n/-- Construct the canonical injection from `ℚ` into an arbitrary\n  division ring. If the field has positive characteristic `p`,\n  we define `1 / p = 1 / 0 = 0` for consistency with our\n  division by zero convention. -/\n-- see Note [coercion into rings]\n@[priority 900] instance cast_coe : has_coe_t ℚ α := ⟨λ r, r.1 / r.2⟩\n\ntheorem cast_def (r : ℚ) : (r : α) = r.num / r.denom := rfl\n\n@[simp] theorem cast_of_int (n : ℤ) : (of_int n : α) = n :=\nshow (n / (1:ℕ) : α) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : ℤ) : ((n : ℚ) : α) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : ℕ) : ((n : ℚ) : α) = n := cast_coe_int n\n\n@[simp, norm_cast] theorem cast_zero : ((0 : ℚ) : α) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : ℚ) : α) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : ℚ) (a : α) : commute ↑r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : ℚ) (a : α) : (r : α) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : α) (r : ℚ) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : ℤ)\n  (b0 : (b:α) ≠ 0) : (a /. b : α) = a / b :=\nbegin\n  have b0' : b ≠ 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:α) ≠ 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:ℤ) ∣ b, by rwa e at dd) with k ke,\n    have : (b:α) = (d:α) * (k:α), {rw [ke, int.cast_mul], refl},\n    rw [d0, zero_mul] at this, contradiction },\n  rw [num_denom'] at e,\n  have := congr_arg (coe : ℤ → α) ((mk_eq b0' $ ne_of_gt $ int.coe_nat_pos.2 h).1 e),\n  rw [int.cast_mul, int.cast_mul, int.cast_coe_nat] at this,\n  symmetry, change (a / b : α) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      ← mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m + n : ℚ) : α) = m + n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', add_def d₁0' d₂0'],\n  suffices : (n₁ * (d₂ * (d₂⁻¹ * d₁⁻¹)) +\n    n₂ * (d₁ * d₂⁻¹) * d₁⁻¹ : α) = n₁ * d₁⁻¹ + n₂ * d₂⁻¹,\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, left_distrib, right_distrib, mul_inv_rev₀, d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [← mul_assoc (d₂:α), mul_inv_cancel d₂0, one_mul,\n      (nat.cast_commute _ _).eq], simp [d₁0, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : ∀ n, ((-n : ℚ) : α) = -n\n| ⟨n, d, h, c⟩ := show (↑-n / d : α) = -(n / d),\n  by rw [div_eq_mul_inv, div_eq_mul_inv, int.cast_neg, neg_mul_eq_neg_mul]\n\n@[norm_cast] theorem cast_sub_of_ne_zero {m n : ℚ}\n  (m0 : (m.denom : α) ≠ 0) (n0 : (n.denom : α) ≠ 0) : ((m - n : ℚ) : α) = m - n :=\nhave ((-n).denom : α) ≠ 0, by cases n; exact n0,\nby simp [sub_eq_add_neg, (cast_add_of_ne_zero m0 this)]\n\n@[norm_cast] theorem cast_mul_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m * n : ℚ) : α) = m * n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', mul_def d₁0' d₂0'],\n  suffices : (n₁ * ((n₂ * d₂⁻¹) * d₁⁻¹) : α) = n₁ * (d₁⁻¹ * (n₂ * d₂⁻¹)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_rev₀, d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [(d₁.commute_cast (_:α)).inv_right₀.eq]\nend\n\n@[simp] theorem cast_inv_nat (n : ℕ) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nbegin\n  cases n, { simp },\n  simp_rw [coe_nat_eq_mk, inv_def, mk, mk_nat, dif_neg n.succ_ne_zero, mk_pnat],\n  simp [cast_def]\nend\n\n@[simp] theorem cast_inv_int (n : ℤ) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nbegin\n  cases n,\n  { exact cast_inv_nat _ },\n  { simp only [int.cast_neg_succ_of_nat, ← nat.cast_succ, cast_neg, inv_neg, cast_inv_nat] }\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : ∀ {n : ℚ},\n  (n.num : α) ≠ 0 → (n.denom : α) ≠ 0 → ((n⁻¹ : ℚ) : α) = n⁻¹\n| ⟨n, d, h, c⟩ := λ (n0 : (n:α) ≠ 0) (d0 : (d:α) ≠ 0), begin\n  have n0' : (n:ℤ) ≠ 0 := λ e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d0; exact d0 rfl),\n  rw [num_denom', inv_def],\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, inv_div];\n  simp [n0, d0]\nend\n\n@[norm_cast] theorem cast_div_of_ne_zero {m n : ℚ} (md : (m.denom : α) ≠ 0)\n  (nn : (n.num : α) ≠ 0) (nd : (n.denom : α) ≠ 0) : ((m / n : ℚ) : α) = m / n :=\nhave (n⁻¹.denom : ℤ) ∣ n.num,\nby conv in n⁻¹.denom { rw [←(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n⁻¹.denom : α) = 0 → (n.num : α) = 0, from\nλ h, let ⟨k, e⟩ := this in\n  by have := congr_arg (coe : ℤ → α) e;\n     rwa [int.cast_mul, int.cast_coe_nat, h, zero_mul] at this,\nby rw [division_def, cast_mul_of_ne_zero md (mt this nn), cast_inv_of_ne_zero nn nd, division_def]\n\n@[simp, norm_cast] theorem cast_inj [char_zero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := begin\n  refine ⟨λ h, _, congr_arg _⟩,\n  have d₁0 : d₁ ≠ 0 := ne_of_gt h₁,\n  have d₂0 : d₂ ≠ 0 := ne_of_gt h₂,\n  have d₁a : (d₁:α) ≠ 0 := nat.cast_ne_zero.2 d₁0,\n  have d₂a : (d₂:α) ≠ 0 := nat.cast_ne_zero.2 d₂0,\n  rw [num_denom', num_denom'] at h ⊢,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d₁0, d₂0] at h ⊢,\n  rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂:α)).inv_left₀.eq,\n    ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm,\n    ← int.cast_coe_nat, ← int.cast_mul, ← int.cast_coe_nat, ← int.cast_mul,\n    int.cast_inj, ← mk_eq (int.coe_nat_ne_zero.2 d₁0) (int.coe_nat_ne_zero.2 d₂0)] at h\nend\n\ntheorem cast_injective [char_zero α] : function.injective (coe : ℚ → α)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 :=\nby rw [← cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero α] {n : ℚ} : (n : α) ≠ 0 ↔ n ≠ 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero α] (m n) :\n  ((m + n : ℚ) : α) = m + n :=\ncast_add_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_sub [char_zero α] (m n) :\n  ((m - n : ℚ) : α) = m - n :=\ncast_sub_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_mul [char_zero α] (m n) :\n  ((m * n : ℚ) : α) = m * n :=\ncast_mul_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_bit0 [char_zero α] (n : ℚ) :\n  ((bit0 n : ℚ) : α) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero α] (n : ℚ) :\n  ((bit1 n : ℚ) : α) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariable (α)\n\n/-- Coercion `ℚ → α` as a `ring_hom`. -/\ndef cast_hom [char_zero α] : ℚ →+* α := ⟨coe, cast_one, cast_mul, cast_zero, cast_add⟩\n\nvariable {α}\n\n@[simp] lemma coe_cast_hom [char_zero α] : ⇑(cast_hom α) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv [char_zero α] (n) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\n(cast_hom α).map_inv _\n\n@[simp, norm_cast] theorem cast_div [char_zero α] (m n) :\n  ((m / n : ℚ) : α) = m / n :=\n(cast_hom α).map_div _ _\n\n@[norm_cast] theorem cast_mk [char_zero α] (a b : ℤ) : ((a /. b) : α) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow [char_zero α] (q) (k : ℕ) :\n  ((q ^ k : ℚ) : α) = q ^ k :=\n(cast_hom α).map_pow q k\n\nend with_div_ring\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field α] : ∀ {n : ℚ}, 0 ≤ (n : α) ↔ 0 ≤ n\n| ⟨n, d, h, c⟩ :=\n  by { rw [num_denom', cast_mk, mk_eq_div, div_nonneg_iff, div_nonneg_iff], norm_cast }\n\n@[simp, norm_cast] theorem cast_le [linear_ordered_field α] {m n : ℚ} : (m : α) ≤ n ↔ m ≤ n :=\nby rw [← sub_nonneg, ← cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field α] {m n : ℚ} : (m : α) < n ↔ m < n :=\nby simpa [-cast_le] using not_congr (@cast_le α _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field α] {n : ℚ} : (n : α) ≤ 0 ↔ n ≤ 0 :=\nby rw [← cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field α] {n : ℚ} : (0 : α) < n ↔ 0 < n :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field α] {n : ℚ} : (n : α) < 0 ↔ n < 0 :=\nby rw [← cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : ∀ n : ℚ, ↑n = n\n| ⟨n, d, h, c⟩ := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field α] {a b : ℚ} :\n  (↑(min a b) : α) = min a b :=\nby by_cases a ≤ b; simp [h, min_def]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field α] {a b : ℚ} :\n  (↑(max a b) : α) = max a b :=\nby by_cases b ≤ a; simp [h, max_def]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field α] {q : ℚ} :\n  ((|q| : ℚ) : α) = |q| :=\nby simp [abs_eq_max_neg]\n\nend rat\n\nopen rat ring_hom\n\nlemma ring_hom.eq_rat_cast {k} [division_ring k] (f : ℚ →+* k) (r : ℚ) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [← int.cast_coe_nat, ← mk_eq_div, num_denom]\n     ... = f r.1 / f r.2 : f.map_div _ _\n     ... = r.1 / r.2     : by rw [map_nat_cast, map_int_cast]\n\n-- This seems to be true for a `[char_p k]` too because `k'` must have the same characteristic\n-- but the proof would be much longer\nlemma ring_hom.map_rat_cast {k k'} [division_ring k] [char_zero k] [division_ring k']\n  (f : k →+* k') (r : ℚ) :\n  f r = r :=\n(f.comp (cast_hom k)).eq_rat_cast r\n\nlemma ring_hom.ext_rat {R : Type*} [semiring R] (f g : ℚ →+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let φ : ℤ →+* R := f.comp (int.cast_ring_hom ℚ),\n  let ψ : ℤ →+* R := g.comp (int.cast_ring_hom ℚ),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:ℚ) ≠ 0 := nat.cast_ne_zero.2 b0,\n  have : ∀ n : ℤ, f n = g n := λ n, show φ n = ψ n, by rw [φ.ext_int ψ],\n  calc f (a * b⁻¹)\n      = f a * f b⁻¹ * (g (b:ℤ) * g b⁻¹) :\n        by rw [int.cast_coe_nat, ← g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b⁻¹ * (f (b:ℤ) * g b⁻¹) : by rw [this a, ← this b]\n  ... = g (a * b⁻¹) :\n        by rw [int.cast_coe_nat, mul_assoc, ← mul_assoc (f b⁻¹),\n              ← f.map_mul, inv_mul_cancel b0', f.map_one, one_mul, g.map_mul]\nend\n\ninstance rat.subsingleton_ring_hom {R : Type*} [semiring R] : subsingleton (ℚ →+* R) :=\n⟨ring_hom.ext_rat⟩\n\nnamespace monoid_with_zero_hom\n\nvariables {M : Type*} [group_with_zero M]\n\n/-- If `f` and `g` agree on the integers then they are equal `φ`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : monoid_with_zero_hom ℚ M}\n  (same_on_int : f.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : ∀ k : ℤ, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [← @rat.num_denom x, rat.mk_eq_div, f.map_div, g.map_div,\n    same_on_int' x.num, same_on_int' x.denom],\nend\n\n/-- Positive integer values of a morphism `φ` and its value on `-1` completely determine `φ`. -/\ntheorem ext_rat_on_pnat {f g : monoid_with_zero_hom ℚ M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : ∀ n : ℕ, 0 < n → f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) ‹_›\n\nend monoid_with_zero_hom\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/rat/cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.4904936570117554}}
{"text": "import Cat.Fam.Dual\n\n\n\n/-! # Useful definitions -/\n\nnamespace Cat\n\n\n\n/-! ## Epimorphisms\n\nA morphism `f : α ↠ β` is *epi* iff for any two morphisms `g₁ g₂ : β ↠ γ`, we have\n`g₁∘f ≈ g₂∘f → g₁ ≈ g₂`.\n-/\nsection epi\n  variable\n    {ℂ : Fam.Cat}\n    {α β : ℂ.Obj}\n\n  @[simp]\n  abbrev Fam.Cat.Epic.law'\n    (ℂ : Cat)\n    {α β : ℂ.Obj}\n    (f : α ↠ β)\n  : Prop :=\n    {γ : ℂ.Obj}\n    → (g₁ g₂ : β ↠ γ)\n    → (g₁ ⊚ f) ≈ (g₂ ⊚ f)\n    → g₁ ≈ g₂\n\n  class Fam.Cat.Epic\n    (f : α ↠ β)\n  where\n    law : Epic.law' ℂ f\n\n\n  /-- `True` iff `f` is epic. -/\n  def Fam.Cat.isEpic\n    (f : α ↠ β)\n    [Epic f]\n  : Prop :=\n    true\nend epi\n\n\n\n/-! ## Monomorphisms\n\nA morphism `f : β → γ` is *monic* iff for any two morphisms `g₁ g₂ : α → β`, we have\n`f∘g₁ ≈ f∘g₂ → g₁ ≈ g₂`.\n-/\nsection monic\n  variable\n    {ℂ : Fam.Cat}\n    {β γ : ℂ.Obj}\n\n  @[simp]\n  abbrev Fam.Cat.Monic.law'\n    (ℂ : Fam.Cat)\n    {β γ : ℂ.Obj}\n    (f : β ↠ γ)\n  : Prop :=\n    {α : ℂ.Obj}\n    → (g₁ g₂ : α ↠ β)\n    → f ⊚ g₁ ≈ f ⊚ g₂\n    → g₁ ≈ g₂\n\n  class Fam.Cat.Monic\n    (f : α ↠ β)\n  : Type where\n    law : Monic.law' ℂ f\n\n  /-- `True` iff `f` is monic. -/\n  def Fam.Cat.isMonic\n    (f : α ↠ β)\n    [Monic f]\n  : Prop :=\n    true\nend monic\n\n\n\n/-! ## Isomorphisms\n\nA morphism `f : α → β` is *iso* iff there is a morphism `f⁻¹ : β → α` such that `f⁻¹ ∘ f ≈ id' β`\nand `f ∘ f⁻¹ ≈ id' α`.\n-/\nsection iso\n  variable\n    {ℂ : Fam.Cat}\n    {α β : ℂ.Obj}\n\n  -- @[simp]\n  -- abbrev Fam.Cat.Iso.law'\n  --   (f : α ↠ β)\n  --   (g : β ↠ α)\n  -- : Prop :=\n  --   g ⊚ f ≈ ℂ.id\n\n  class Fam.Cat.Iso\n    (f : α ↠ β)\n  where\n    inv :\n      β ↠ α\n    law_left :\n      f ⊚ inv ≈ ℂ.id\n    law_right :\n      inv ⊚ f ≈ ℂ.id\n\n  abbrev Fam.Cat.isoInv\n    (f : α ↠ β)\n    [inst : Iso f]\n  : β ↠ α :=\n    inst.inv\n\n  /-- Turns a `Iso f` into a `Iso inv`. -/\n  instance instIsoSelfInv\n    (f : α ↠ β)\n    [inst : Fam.Cat.Iso f]\n  : Fam.Cat.Iso (ℂ.isoInv f) where\n    inv :=\n      f\n    law_left :=\n      inst.law_right\n    law_right :=\n      inst.law_left\n\n  /-- `True` iff `f` is iso. -/\n  def Fam.Cat.isIso\n    (f : α ↠ β)\n    [Iso f]\n  : Prop :=\n    true\nend iso\n\n\n\n/-! Isomorphic objects (`≅`, `\\~==`).\n\nTwo objects `α` and `β` are *isomorphic* if they are connected by an *iso*-arrow.\n-/\nsection iso_obj\n  variable\n    {ℂ : Fam.Cat}\n    {α β : ℂ.Obj}\n\n  /-- Packages the isomorphism. -/\n  class Fam.Cat.IsoObj\n    (α β : ℂ.Obj)\n  where rawMk ::\n    iso : α ↠ β\n    instIso : Iso iso\n\n  /-- Bring `Iso i.iso` whenever we manipulate `i : IsoObj α β`. -/\n  @[simp]\n  instance instIso_of_IsoObj\n    [inst : Fam.Cat.IsoObj α β]\n  : Fam.Cat.Iso (inst.iso) :=\n    inst.instIso\n\n  abbrev Fam.Cat.IsoObj.mk\n    (iso : α ↠ β)\n    [instIso : Iso iso]\n  : IsoObj α β :=\n    ⟨iso, instIso⟩\n\n  /-- `True` iff `α` and `β` are isomorphic. -/\n  def Fam.Cat.isIsoObj\n    (α β : ℂ.Obj)\n    [IsoObj α β]\n  : Prop :=\n    true\n\n  infix:10 \" ≅ \" =>\n    Fam.Cat.IsoObj\nend iso_obj\n\n\n\n/-! ## Initial objects\n\nAn object `α` is *initial* iff for any `β` there exists a **unique** arrow in `α ↠ β`.\n-/\nsection initial_obj\n  variable\n    {ℂ : Fam.Cat}\n\n  class Fam.Cat.Initial\n    (α : ℂ.Obj)\n  where\n    arrow {β : ℂ.Obj} :\n      α ↠ β\n    unique {β : ℂ.Obj} (f : α ↠ β) :\n      arrow ≈ f\n\n  /-- If `α` is initial, then any `α → α` is actually `id`. -/\n  theorem Fam.Cat.Initial.equivId\n    [instα : Initial α]\n    (f : α ↠ α)\n  : f ≈ ℂ.id :=\n    let h₁ : f ≈ arrow :=\n      instα.unique f\n      |> Setoid.symm\n    let h₂ : arrow ≈ ℂ.id :=\n      instα.unique ℂ.id\n    Setoid.trans h₁ h₂\n\n  /-- `True` iff `α` is initial. -/\n  def Fam.Cat.isInitial\n    (α : ℂ.Obj)\n    [Initial α]\n  : Prop :=\n    true\nend initial_obj\n\n\n\n/-! ## Terminal objects\n\nAn object `β` is *terminal* iff for any `α` there existst a **unique** arrow in `α ↠ β`.\n-/\nsection terminal_obj\n  variable\n    {ℂ: Fam.Cat}\n\n  class Fam.Cat.Terminal\n    (β : ℂ.Obj)\n  where\n    arrow {α : ℂ.Obj} :\n      α ↠ β\n    unique {α : ℂ.Obj} (f : α ↠ β) :\n      arrow ≈ f\n\n  /-- If `α` is terminal, then any `α → α` is actually `id`. -/\n  theorem Fam.Cat.Terminal.equivId\n    [instα : Terminal α]\n    (f : α ↠ α)\n  : f ≈ ℂ.id :=\n    let h₁ : f ≈ arrow :=\n      instα.unique f\n      |> Setoid.symm\n    let h₂ : arrow ≈ ℂ.id :=\n      instα.unique ℂ.id\n    Setoid.trans h₁ h₂\n\n  /-- `True` iff `β` is terminal. -/\n  def Fam.Cat.isTerminal\n    (β : ℂ.Obj)\n    [Terminal β]\n  : Prop :=\n    true\nend terminal_obj", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/cat/Cat/Fam/CatDefs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.4904936544778443}}
{"text": "example (p q : Prop) : p ∧ q → q ∧ p :=\nbegin\n  intro h,\n  cases h with hp hq,\n  split,\n  show q, from hq,\n  show p, from hp,\nend\n\nexample (p q : Prop) : p ∧ q → q ∧ p :=\nbegin\n  intro h,\n  cases h with hp hq,\n  split,\n  show p, from hp,\n  show q, from hq\nend\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch5/ex0406.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943805178138, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.49049365447784427}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.natural_isomorphism\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ u₃ v₁ v₂ v₃ u₄ v₄ u₅ v₅ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\nIf `α : G ⟶ H` then\n`whisker_left F α : (F ⋙ G) ⟶ (F ⋙ H)` has components `α.app (F.obj X)`.\n-/\n@[simp] theorem whisker_left_app {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ⟶ H) (X : C) :\n    nat_trans.app (whisker_left F α) X = nat_trans.app α (functor.obj F X) :=\n  Eq.refl (nat_trans.app (whisker_left F α) X)\n\n/--\nIf `α : G ⟶ H` then\n`whisker_right α F : (G ⋙ F) ⟶ (G ⋙ F)` has components `F.map (α.app X)`.\n-/\ndef whisker_right {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E]\n    {G : C ⥤ D} {H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) : G ⋙ F ⟶ H ⋙ F :=\n  nat_trans.mk fun (X : C) => functor.map F (nat_trans.app α X)\n\n/--\nLeft-composition gives a functor `(C ⥤ D) ⥤ ((D ⥤ E) ⥤ (C ⥤ E))`.\n\n`(whiskering_lift.obj F).obj G` is `F ⋙ G`, and\n`(whiskering_lift.obj F).map α` is `whisker_left F α`.\n-/\ndef whiskering_left (C : Type u₁) [category C] (D : Type u₂) [category D] (E : Type u₃)\n    [category E] : (C ⥤ D) ⥤ (D ⥤ E) ⥤ C ⥤ E :=\n  functor.mk\n    (fun (F : C ⥤ D) =>\n      functor.mk (fun (G : D ⥤ E) => F ⋙ G) fun (G H : D ⥤ E) (α : G ⟶ H) => whisker_left F α)\n    fun (F G : C ⥤ D) (τ : F ⟶ G) =>\n      nat_trans.mk fun (H : D ⥤ E) => nat_trans.mk fun (c : C) => functor.map H (nat_trans.app τ c)\n\n/--\nRight-composition gives a functor `(D ⥤ E) ⥤ ((C ⥤ D) ⥤ (C ⥤ E))`.\n\n`(whiskering_right.obj H).obj F` is `F ⋙ H`, and\n`(whiskering_right.obj H).map α` is `whisker_right α H`.\n-/\n@[simp] theorem whiskering_right_obj_map (C : Type u₁) [category C] (D : Type u₂) [category D]\n    (E : Type u₃) [category E] (H : D ⥤ E) (_x : C ⥤ D) :\n    ∀ (_x_1 : C ⥤ D) (α : _x ⟶ _x_1),\n        functor.map (functor.obj (whiskering_right C D E) H) α = whisker_right α H :=\n  fun (_x_1 : C ⥤ D) (α : _x ⟶ _x_1) =>\n    Eq.refl (functor.map (functor.obj (whiskering_right C D E) H) α)\n\n@[simp] theorem whisker_left_id {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] (F : C ⥤ D) {G : D ⥤ E} : whisker_left F (nat_trans.id G) = nat_trans.id (F ⋙ G) :=\n  rfl\n\n@[simp] theorem whisker_left_id' {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] (F : C ⥤ D) {G : D ⥤ E} : whisker_left F 𝟙 = 𝟙 :=\n  rfl\n\n@[simp] theorem whisker_right_id {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {G : C ⥤ D} (F : D ⥤ E) :\n    whisker_right (nat_trans.id G) F = nat_trans.id (G ⋙ F) :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_right_id' {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] {G : C ⥤ D} (F : D ⥤ E) : whisker_right 𝟙 F = 𝟙 :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_left_comp {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} {K : D ⥤ E} (α : G ⟶ H)\n    (β : H ⟶ K) : whisker_left F (α ≫ β) = whisker_left F α ≫ whisker_left F β :=\n  rfl\n\n@[simp] theorem whisker_right_comp {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} {K : C ⥤ D} (α : G ⟶ H) (β : H ⟶ K)\n    (F : D ⥤ E) : whisker_right (α ≫ β) F = whisker_right α F ≫ whisker_right β F :=\n  functor.map_comp (functor.obj (whiskering_right C D E) F) α β\n\n/--\nIf `α : G ≅ H` is a natural isomorphism then\n`iso_whisker_left F α : (F ⋙ G) ≅ (F ⋙ H)` has components `α.app (F.obj X)`.\n-/\ndef iso_whisker_left {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ≅ H) : F ⋙ G ≅ F ⋙ H :=\n  functor.map_iso (functor.obj (whiskering_left C D E) F) α\n\n@[simp] theorem iso_whisker_left_hom {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ≅ H) :\n    iso.hom (iso_whisker_left F α) = whisker_left F (iso.hom α) :=\n  rfl\n\n@[simp] theorem iso_whisker_left_inv {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ≅ H) :\n    iso.inv (iso_whisker_left F α) = whisker_left F (iso.inv α) :=\n  rfl\n\n/--\nIf `α : G ≅ H` then\n`iso_whisker_right α F : (G ⋙ F) ≅ (G ⋙ F)` has components `F.map_iso (α.app X)`.\n-/\ndef iso_whisker_right {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) : G ⋙ F ≅ H ⋙ F :=\n  functor.map_iso (functor.obj (whiskering_right C D E) F) α\n\n@[simp] theorem iso_whisker_right_hom {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) :\n    iso.hom (iso_whisker_right α F) = whisker_right (iso.hom α) F :=\n  rfl\n\n@[simp] theorem iso_whisker_right_inv {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) :\n    iso.inv (iso_whisker_right α F) = whisker_right (iso.inv α) F :=\n  rfl\n\nprotected instance is_iso_whisker_left {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ⟶ H) [is_iso α] :\n    is_iso (whisker_left F α) :=\n  is_iso.mk (iso.inv (iso_whisker_left F (as_iso α)))\n\nprotected instance is_iso_whisker_right {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) [is_iso α] :\n    is_iso (whisker_right α F) :=\n  is_iso.mk (iso.inv (iso_whisker_right (as_iso α) F))\n\n@[simp] theorem whisker_left_twice {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] {B : Type u₄} [category B] (F : B ⥤ C) (G : C ⥤ D) {H : D ⥤ E}\n    {K : D ⥤ E} (α : H ⟶ K) : whisker_left F (whisker_left G α) = whisker_left (F ⋙ G) α :=\n  rfl\n\n@[simp] theorem whisker_right_twice {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {E : Type u₃} [category E] {B : Type u₄} [category B] {H : B ⥤ C} {K : B ⥤ C} (F : C ⥤ D)\n    (G : D ⥤ E) (α : H ⟶ K) : whisker_right (whisker_right α F) G = whisker_right α (F ⋙ G) :=\n  rfl\n\ntheorem whisker_right_left {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {B : Type u₄} [category B] (F : B ⥤ C) {G : C ⥤ D} {H : C ⥤ D} (α : G ⟶ H)\n    (K : D ⥤ E) : whisker_right (whisker_left F α) K = whisker_left F (whisker_right α K) :=\n  rfl\n\nnamespace functor\n\n\n/--\nThe left unitor, a natural isomorphism `((𝟭 _) ⋙ F) ≅ F`.\n-/\n@[simp] theorem left_unitor_hom_app {A : Type u₁} [category A] {B : Type u₂} [category B]\n    (F : A ⥤ B) (X : A) : nat_trans.app (iso.hom (left_unitor F)) X = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.hom (left_unitor F)) X)\n\n/--\nThe right unitor, a natural isomorphism `(F ⋙ (𝟭 B)) ≅ F`.\n-/\n@[simp] theorem right_unitor_hom_app {A : Type u₁} [category A] {B : Type u₂} [category B]\n    (F : A ⥤ B) (X : A) : nat_trans.app (iso.hom (right_unitor F)) X = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.hom (right_unitor F)) X)\n\n/--\nThe associator for functors, a natural isomorphism `((F ⋙ G) ⋙ H) ≅ (F ⋙ (G ⋙ H))`.\n\n(In fact, `iso.refl _` will work here, but it tends to make Lean slow later,\nand it's usually best to insert explicit associators.)\n-/\n@[simp] theorem associator_inv_app {A : Type u₁} [category A] {B : Type u₂} [category B]\n    {C : Type u₃} [category C] {D : Type u₄} [category D] (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D)\n    (_x : A) : nat_trans.app (iso.inv (associator F G H)) _x = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.inv (associator F G H)) _x)\n\ntheorem triangle {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃} [category C]\n    (F : A ⥤ B) (G : B ⥤ C) :\n    iso.hom (associator F 𝟭 G) ≫ whisker_left F (iso.hom (left_unitor G)) =\n        whisker_right (iso.hom (right_unitor F)) G :=\n  sorry\n\ntheorem pentagon {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃} [category C]\n    {D : Type u₄} [category D] {E : Type u₅} [category E] (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D)\n    (K : D ⥤ E) :\n    whisker_right (iso.hom (associator F G H)) K ≫\n          iso.hom (associator F (G ⋙ H) K) ≫ whisker_left F (iso.hom (associator G H K)) =\n        iso.hom (associator (F ⋙ G) H K) ≫ iso.hom (associator F G (H ⋙ K)) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/whiskering_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.49049364519766536}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nComputational realization of topological spaces (experimental).\n-/\nimport topology.bases\nimport data.analysis.filter\nopen set\nopen filter (hiding realizer)\nopen_locale topological_space\n\n/-- A `ctop α σ` is a realization of a topology (basis) on `α`,\n  represented by a type `σ` together with operations for the top element and\n  the intersection operation. -/\nstructure ctop (α σ : Type*) :=\n(f : σ → set α)\n(top : α → σ)\n(top_mem : ∀ x : α, x ∈ f (top x))\n(inter : Π a b (x : α), x ∈ f a ∩ f b → σ)\n(inter_mem : ∀ a b x h, x ∈ f (inter a b x h))\n(inter_sub : ∀ a b x h, f (inter a b x h) ⊆ f a ∩ f b)\n\nvariables {α : Type*} {β : Type*} {σ : Type*} {τ : Type*}\n\nnamespace ctop\nsection\nvariables (F : ctop α σ)\n\ninstance : has_coe_to_fun (ctop α σ) (λ _, σ → set α) := ⟨ctop.f⟩\n\n@[simp] theorem coe_mk (f T h₁ I h₂ h₃ a) : (@ctop.mk α σ f T h₁ I h₂ h₃) a = f a := rfl\n\n/-- Map a ctop to an equivalent representation type. -/\ndef of_equiv (E : σ ≃ τ) : ctop α σ → ctop α τ\n| ⟨f, T, h₁, I, h₂, h₃⟩ :=\n  { f         := λ a, f (E.symm a),\n    top       := λ x, E (T x),\n    top_mem   := λ x, by simpa using h₁ x,\n    inter     := λ a b x h, E (I (E.symm a) (E.symm b) x h),\n    inter_mem := λ a b x h, by simpa using h₂ (E.symm a) (E.symm b) x h,\n    inter_sub := λ a b x h, by simpa using h₃ (E.symm a) (E.symm b) x h }\n\n@[simp] theorem of_equiv_val (E : σ ≃ τ) (F : ctop α σ) (a : τ) :\n  F.of_equiv E a = F (E.symm a) := by cases F; refl\n\nend\n\n/-- Every `ctop` is a topological space. -/\ndef to_topsp (F : ctop α σ) : topological_space α :=\ntopological_space.generate_from (set.range F.f)\n\ntheorem to_topsp_is_topological_basis (F : ctop α σ) :\n  @topological_space.is_topological_basis _ F.to_topsp (set.range F.f) :=\nby letI := F.to_topsp; exact\n⟨λ u ⟨a, e₁⟩ v ⟨b, e₂⟩, e₁ ▸ e₂ ▸\n   λ x h, ⟨_, ⟨_, rfl⟩, F.inter_mem a b x h, F.inter_sub a b x h⟩,\neq_univ_iff_forall.2 $ λ x, ⟨_, ⟨_, rfl⟩, F.top_mem x⟩, rfl⟩\n\n@[simp] theorem mem_nhds_to_topsp (F : ctop α σ) {s : set α} {a : α} :\n  s ∈ @nhds _ F.to_topsp a ↔ ∃ b, a ∈ F b ∧ F b ⊆ s :=\n(@topological_space.is_topological_basis.mem_nhds_iff\n  _ F.to_topsp _ _ _ F.to_topsp_is_topological_basis).trans $\n⟨λ ⟨_, ⟨x, rfl⟩, h⟩, ⟨x, h⟩, λ ⟨x, h⟩, ⟨_, ⟨x, rfl⟩, h⟩⟩\n\nend ctop\n\n/-- A `ctop` realizer for the topological space `T` is a `ctop`\n  which generates `T`. -/\nstructure ctop.realizer (α) [T : topological_space α] :=\n(σ : Type*)\n(F : ctop α σ)\n(eq : F.to_topsp = T)\nopen ctop\n\nprotected def ctop.to_realizer (F : ctop α σ) : @ctop.realizer _ F.to_topsp :=\n@ctop.realizer.mk _ F.to_topsp σ F rfl\n\nnamespace ctop.realizer\n\nprotected theorem is_basis [T : topological_space α] (F : realizer α) :\n  topological_space.is_topological_basis (set.range F.F.f) :=\nby have := to_topsp_is_topological_basis F.F; rwa F.eq at this\n\nprotected theorem mem_nhds [T : topological_space α] (F : realizer α) {s : set α} {a : α} :\n  s ∈ 𝓝 a ↔ ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=\nby have := mem_nhds_to_topsp F.F; rwa F.eq at this\n\ntheorem is_open_iff [topological_space α] (F : realizer α) {s : set α} :\n  is_open s ↔ ∀ a ∈ s, ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=\nis_open_iff_mem_nhds.trans $ ball_congr $ λ a h, F.mem_nhds\n\ntheorem is_closed_iff [topological_space α] (F : realizer α) {s : set α} :\n  is_closed s ↔ ∀ a, (∀ b, a ∈ F.F b → ∃ z, z ∈ F.F b ∩ s) → a ∈ s :=\nis_open_compl_iff.symm.trans $ F.is_open_iff.trans $ forall_congr $ λ a,\nshow (a ∉ s → (∃ (b : F.σ), a ∈ F.F b ∧ ∀ z ∈ F.F b, z ∉ s)) ↔ _,\nby haveI := classical.prop_decidable; rw [not_imp_comm];\n   simp [not_exists, not_and, not_forall, and_comm]\n\ntheorem mem_interior_iff [topological_space α] (F : realizer α) {s : set α} {a : α} :\n  a ∈ interior s ↔ ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=\nmem_interior_iff_mem_nhds.trans F.mem_nhds\n\nprotected theorem is_open [topological_space α] (F : realizer α) (s : F.σ) : is_open (F.F s) :=\nis_open_iff_nhds.2 $ λ a m, by simpa using F.mem_nhds.2 ⟨s, m, subset.refl _⟩\n\n\n\ntheorem ext [T : topological_space α] {σ : Type*} {F : ctop α σ}\n  (H₁ : ∀ a, is_open (F a))\n  (H₂ : ∀ a s, s ∈ 𝓝 a → ∃ b, a ∈ F b ∧ F b ⊆ s) :\n  F.to_topsp = T :=\next' $ λ a s, ⟨H₂ a s, λ ⟨b, h₁, h₂⟩, mem_nhds_iff.2 ⟨_, h₂, H₁ _, h₁⟩⟩\n\nvariable [topological_space α]\n\nprotected def id : realizer α := ⟨{x:set α // is_open x},\n{ f            := subtype.val,\n  top          := λ _, ⟨univ, is_open_univ⟩,\n  top_mem      := mem_univ,\n  inter        := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃, ⟨_, h₁.inter h₂⟩,\n  inter_mem    := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a, id,\n  inter_sub    := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃, subset.refl _ },\next subtype.property $ λ x s h,\n  let ⟨t, h, o, m⟩ := mem_nhds_iff.1 h in ⟨⟨t, o⟩, m, h⟩⟩\n\ndef of_equiv (F : realizer α) (E : F.σ ≃ τ) : realizer α :=\n⟨τ, F.F.of_equiv E, ext' (λ a s, F.mem_nhds.trans $\n ⟨λ ⟨s, h⟩, ⟨E s, by simpa using h⟩, λ ⟨t, h⟩, ⟨E.symm t, by simpa using h⟩⟩)⟩\n\n@[simp] theorem of_equiv_σ (F : realizer α) (E : F.σ ≃ τ) : (F.of_equiv E).σ = τ := rfl\n@[simp] theorem of_equiv_F (F : realizer α) (E : F.σ ≃ τ) (s : τ) :\n  (F.of_equiv E).F s = F.F (E.symm s) := by delta of_equiv; simp\n\nprotected def nhds (F : realizer α) (a : α) : (𝓝 a).realizer :=\n⟨{s : F.σ // a ∈ F.F s},\n{ f            := λ s, F.F s.1,\n  pt           := ⟨_, F.F.top_mem a⟩,\n  inf          := λ ⟨x, h₁⟩ ⟨y, h₂⟩, ⟨_, F.F.inter_mem x y a ⟨h₁, h₂⟩⟩,\n  inf_le_left  := λ ⟨x, h₁⟩ ⟨y, h₂⟩ z h, (F.F.inter_sub x y a ⟨h₁, h₂⟩ h).1,\n  inf_le_right := λ ⟨x, h₁⟩ ⟨y, h₂⟩ z h, (F.F.inter_sub x y a ⟨h₁, h₂⟩ h).2 },\nfilter_eq $ set.ext $ λ x,\n⟨λ ⟨⟨s, as⟩, h⟩, mem_nhds_iff.2 ⟨_, h, F.is_open _, as⟩,\n λ h, let ⟨s, h, as⟩ := F.mem_nhds.1 h in ⟨⟨s, h⟩, as⟩⟩⟩\n\n@[simp] theorem nhds_σ (m : α → β) (F : realizer α) (a : α) :\n  (F.nhds a).σ = {s : F.σ // a ∈ F.F s} := rfl\n@[simp] theorem nhds_F (m : α → β) (F : realizer α) (a : α) (s) :\n  (F.nhds a).F s = F.F s.1 := rfl\n\ntheorem tendsto_nhds_iff {m : β → α} {f : filter β} (F : f.realizer) (R : realizer α) {a : α} :\n  tendsto m f (𝓝 a) ↔ ∀ t, a ∈ R.F t → ∃ s, ∀ x ∈ F.F s, m x ∈ R.F t :=\n(F.tendsto_iff _ (R.nhds a)).trans subtype.forall\n\nend ctop.realizer\n\nstructure locally_finite.realizer [topological_space α] (F : realizer α) (f : β → set α) :=\n(bas : ∀ a, {s // a ∈ F.F s})\n(sets : ∀ x:α, fintype {i | (f i ∩ F.F (bas x)).nonempty})\n\ntheorem locally_finite.realizer.to_locally_finite [topological_space α]\n  {F : realizer α} {f : β → set α} (R : locally_finite.realizer F f) :\n  locally_finite f :=\nλ a, ⟨_, F.mem_nhds.2\n  ⟨(R.bas a).1, (R.bas a).2, subset.refl _⟩, ⟨R.sets a⟩⟩\n\ntheorem locally_finite_iff_exists_realizer [topological_space α]\n  (F : realizer α) {f : β → set α} : locally_finite f ↔ nonempty (locally_finite.realizer F f) :=\n⟨λ h, let ⟨g, h₁⟩ := classical.axiom_of_choice h,\n    ⟨g₂, h₂⟩ := classical.axiom_of_choice (λ x,\n       show ∃ (b : F.σ), x ∈ (F.F) b ∧ (F.F) b ⊆ g x, from\n       let ⟨h, h'⟩ := h₁ x in F.mem_nhds.1 h) in\n  ⟨⟨λ x, ⟨g₂ x, (h₂ x).1⟩, λ x, finite.fintype $\n    let ⟨h, h'⟩ := h₁ x in h'.subset $ λ i hi,\n    hi.mono (inter_subset_inter_right _ (h₂ x).2)⟩⟩,\n λ ⟨R⟩, R.to_locally_finite⟩\n\ndef compact.realizer [topological_space α] (R : realizer α) (s : set α) :=\n∀ {f : filter α} (F : f.realizer) (x : F.σ), f ≠ ⊥ →\n  F.F x ⊆ s → {a // a∈s ∧ 𝓝 a ⊓ f ≠ ⊥}\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/analysis/topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312056025699, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.49045513127244666}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.homology.additive\nimport tactic.abel\n\n/-!\n# Chain homotopies\n\nWe define chain homotopies, and prove that homotopic chain maps induce the same map on homology.\n-/\n\nuniverses v u\n\nopen_locale classical\nnoncomputable theory\n\nopen category_theory category_theory.limits homological_complex\n\nvariables {ι : Type*}\nvariables {V : Type u} [category.{v} V] [preadditive V]\n\nvariables {c : complex_shape ι} {C D E : homological_complex V c}\nvariables (f g : C ⟶ D) (h k : D ⟶ E) (i : ι)\n\nsection\n\n/-- The composition of `C.d i i' ≫ f i' i` if there is some `i'` coming after `i`,\nand `0` otherwise. -/\ndef d_next (i : ι) : (Π i j, C.X i ⟶ D.X j) →+ (C.X i ⟶ D.X i) :=\nadd_monoid_hom.mk' (λ f, C.d i (c.next i) ≫ f (c.next i) i) $\nλ f g, preadditive.comp_add _ _ _ _ _ _\n\n/-- `f i' i` if `i'` comes after `i`, and 0 if there's no such `i'`.\nHopefully there won't be much need for this, except in `d_next_eq_d_from_from_next`\nto see that `d_next` factors through `C.d_from i`. -/\ndef from_next (i : ι) : (Π i j, C.X i ⟶ D.X j) →+ (C.X_next i ⟶ D.X i) :=\nadd_monoid_hom.mk' (λ f, f (c.next i) i) $ λ f g, rfl\n\n@[simp]\nlemma d_next_eq_d_from_from_next (f : Π i j, C.X i ⟶ D.X j) (i : ι) :\n  d_next i f = C.d_from i ≫ from_next i f := rfl\n\nlemma d_next_eq (f : Π i j, C.X i ⟶ D.X j) {i i' : ι} (w : c.rel i i') :\n  d_next i f = C.d i i' ≫ f i' i :=\nby { obtain rfl := c.next_eq' w, refl }\n\n@[simp] lemma d_next_comp_left (f : C ⟶ D) (g : Π i j, D.X i ⟶ E.X j) (i : ι) :\n  d_next i (λ i j, f.f i ≫ g i j) = f.f i ≫ d_next i g :=\n(f.comm_assoc _ _ _).symm\n\n@[simp] lemma d_next_comp_right (f : Π i j, C.X i ⟶ D.X j) (g : D ⟶ E) (i : ι) :\n  d_next i (λ i j, f i j ≫ g.f j) = d_next i f ≫ g.f i :=\n(category.assoc _ _ _).symm\n\n/-- The composition of `f j j' ≫ D.d j' j` if there is some `j'` coming before `j`,\nand `0` otherwise. -/\ndef prev_d (j : ι) : (Π i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.X j) :=\nadd_monoid_hom.mk' (λ f, f j (c.prev j) ≫ D.d (c.prev j) j) $\nλ f g, preadditive.add_comp _ _ _ _ _ _\n\n/-- `f j j'` if `j'` comes after `j`, and 0 if there's no such `j'`.\nHopefully there won't be much need for this, except in `d_next_eq_d_from_from_next`\nto see that `d_next` factors through `C.d_from i`. -/\ndef to_prev (j : ι) : (Π i j, C.X i ⟶ D.X j) →+ (C.X j ⟶ D.X_prev j) :=\nadd_monoid_hom.mk' (λ f, f j (c.prev j)) $ λ f g, rfl\n\n@[simp]\nlemma prev_d_eq_to_prev_d_to (f : Π i j, C.X i ⟶ D.X j) (j : ι) :\n  prev_d j f = to_prev j f ≫ D.d_to j := rfl\n\nlemma prev_d_eq (f : Π i j, C.X i ⟶ D.X j) {j j' : ι} (w : c.rel j' j) :\n  prev_d j f = f j j' ≫ D.d j' j :=\nby { obtain rfl := c.prev_eq' w, refl }\n\n@[simp] lemma prev_d_comp_left (f : C ⟶ D) (g : Π i j, D.X i ⟶ E.X j) (j : ι) :\n  prev_d j (λ i j, f.f i ≫ g i j) = f.f j ≫ prev_d j g :=\ncategory.assoc _ _ _\n\n@[simp] lemma prev_d_comp_right (f : Π i j, C.X i ⟶ D.X j) (g : D ⟶ E) (j : ι) :\n  prev_d j (λ i j, f i j ≫ g.f j) = prev_d j f ≫ g.f j :=\nby { dsimp [prev_d], simp only [category.assoc, g.comm] }\n\nlemma d_next_nat (C D : chain_complex V ℕ) (i : ℕ) (f : Π i j, C.X i ⟶ D.X j) :\n  d_next i f = C.d i (i-1) ≫ f (i-1) i :=\nbegin\n  dsimp [d_next],\n  cases i,\n  { simp only [shape, chain_complex.next_nat_zero, complex_shape.down_rel,\n      nat.one_ne_zero, not_false_iff, zero_comp], },\n  { dsimp only [nat.succ_eq_add_one],\n    have : (complex_shape.down ℕ).next (i + 1) = i + 1 - 1,\n    { rw chain_complex.next_nat_succ, refl },\n    congr' 2, }\nend\n\nlemma prev_d_nat (C D : cochain_complex V ℕ) (i : ℕ) (f : Π i j, C.X i ⟶ D.X j) :\n  prev_d i f = f i (i-1) ≫ D.d (i-1) i :=\nbegin\n  dsimp [prev_d],\n  cases i,\n  { simp only [shape, cochain_complex.prev_nat_zero, complex_shape.up_rel,\n      nat.one_ne_zero, not_false_iff, comp_zero]},\n  { dsimp only [nat.succ_eq_add_one],\n    have : (complex_shape.up ℕ).prev (i + 1) = i + 1 - 1,\n    { rw cochain_complex.prev_nat_succ, refl },\n    congr' 2, },\nend\n\n/--\nA homotopy `h` between chain maps `f` and `g` consists of components `h i j : C.X i ⟶ D.X j`\nwhich are zero unless `c.rel j i`, satisfying the homotopy condition.\n-/\n@[ext, nolint has_nonempty_instance]\nstructure homotopy (f g : C ⟶ D) :=\n(hom : Π i j, C.X i ⟶ D.X j)\n(zero' : ∀ i j, ¬ c.rel j i → hom i j = 0 . obviously)\n(comm : ∀ i, f.f i = d_next i hom + prev_d i hom + g.f i . obviously')\n\nvariables {f g}\nnamespace homotopy\n\nrestate_axiom homotopy.zero'\n\n/--\n`f` is homotopic to `g` iff `f - g` is homotopic to `0`.\n-/\ndef equiv_sub_zero : homotopy f g ≃ homotopy (f - g) 0 :=\n{ to_fun := λ h,\n  { hom := λ i j, h.hom i j,\n    zero' := λ i j w, h.zero _ _ w,\n    comm := λ i, by simp [h.comm] },\n  inv_fun := λ h,\n  { hom := λ i j, h.hom i j,\n    zero' := λ i j w, h.zero _ _ w,\n    comm := λ i, by simpa [sub_eq_iff_eq_add] using h.comm i },\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\n/-- Equal chain maps are homotopic. -/\n@[simps]\ndef of_eq (h : f = g) : homotopy f g :=\n{ hom := 0,\n  zero' := λ _ _ _, rfl,\n  comm := λ _, by simp only [add_monoid_hom.map_zero, zero_add, h] }\n\n/-- Every chain map is homotopic to itself. -/\n@[simps, refl]\ndef refl (f : C ⟶ D) : homotopy f f :=\nof_eq (rfl : f = f)\n\n/-- `f` is homotopic to `g` iff `g` is homotopic to `f`. -/\n@[simps, symm]\ndef symm {f g : C ⟶ D} (h : homotopy f g) : homotopy g f :=\n{ hom := -h.hom,\n  zero' := λ i j w, by rw [pi.neg_apply, pi.neg_apply, h.zero i j w, neg_zero],\n  comm := λ i, by rw [add_monoid_hom.map_neg, add_monoid_hom.map_neg, h.comm, ← neg_add,\n      ← add_assoc, neg_add_self, zero_add] }\n\n/-- homotopy is a transitive relation. -/\n@[simps, trans]\ndef trans {e f g : C ⟶ D} (h : homotopy e f) (k : homotopy f g) : homotopy e g :=\n{ hom := h.hom + k.hom,\n  zero' := λ i j w, by rw [pi.add_apply, pi.add_apply, h.zero i j w, k.zero i j w, zero_add],\n  comm := λ i, by { rw [add_monoid_hom.map_add, add_monoid_hom.map_add, h.comm, k.comm], abel }, }\n\n/-- the sum of two homotopies is a homotopy between the sum of the respective morphisms. -/\n@[simps]\ndef add {f₁ g₁ f₂ g₂ : C ⟶ D}\n  (h₁ : homotopy f₁ g₁) (h₂ : homotopy f₂ g₂) : homotopy (f₁+f₂) (g₁+g₂) :=\n{ hom := h₁.hom + h₂.hom,\n  zero' := λ i j hij, by\n    rw [pi.add_apply, pi.add_apply, h₁.zero' i j hij, h₂.zero' i j hij, add_zero],\n  comm := λ i, by\n    { simp only [homological_complex.add_f_apply, h₁.comm, h₂.comm,\n        add_monoid_hom.map_add],\n      abel, }, }\n\n/-- homotopy is closed under composition (on the right) -/\n@[simps]\ndef comp_right {e f : C ⟶ D} (h : homotopy e f) (g : D ⟶ E) : homotopy (e ≫ g) (f ≫ g) :=\n{ hom := λ i j, h.hom i j ≫ g.f j,\n  zero' := λ i j w, by rw [h.zero i j w, zero_comp],\n  comm := λ i, by simp only [h.comm i, d_next_comp_right, preadditive.add_comp,\n    prev_d_comp_right, comp_f], }\n\n/-- homotopy is closed under composition (on the left) -/\n@[simps]\ndef comp_left {f g : D ⟶ E} (h : homotopy f g) (e : C ⟶ D) : homotopy (e ≫ f) (e ≫ g) :=\n{ hom := λ i j, e.f i ≫ h.hom i j,\n  zero' := λ i j w, by rw [h.zero i j w, comp_zero],\n  comm := λ i, by simp only [h.comm i, d_next_comp_left, preadditive.comp_add,\n    prev_d_comp_left, comp_f], }\n\n/-- homotopy is closed under composition -/\n@[simps]\ndef comp {C₁ C₂ C₃ : homological_complex V c} {f₁ g₁ : C₁ ⟶ C₂} {f₂ g₂ : C₂ ⟶ C₃}\n  (h₁ : homotopy f₁ g₁) (h₂ : homotopy f₂ g₂) : homotopy (f₁ ≫ f₂) (g₁ ≫ g₂) :=\n(h₁.comp_right _).trans (h₂.comp_left _)\n\n/-- a variant of `homotopy.comp_right` useful for dealing with homotopy equivalences. -/\n@[simps]\ndef comp_right_id {f : C ⟶ C} (h : homotopy f (𝟙 C)) (g : C ⟶ D) : homotopy (f ≫ g) g :=\n(h.comp_right g).trans (of_eq $ category.id_comp _)\n\n/-- a variant of `homotopy.comp_left` useful for dealing with homotopy equivalences. -/\n@[simps]\ndef comp_left_id {f : D ⟶ D} (h : homotopy f (𝟙 D)) (g : C ⟶ D) : homotopy (g ≫ f) g :=\n(h.comp_left g).trans (of_eq $ category.comp_id _)\n\n/-!\nNull homotopic maps can be constructed using the formula `hd+dh`. We show that\nthese morphisms are homotopic to `0` and provide some convenient simplification\nlemmas that give a degreewise description of `hd+dh`, depending on whether we have\ntwo differentials going to and from a certain degree, only one, or none.\n-/\n\n/-- The null homotopic map associated to a family `hom` of morphisms `C_i ⟶ D_j`.\nThis is the same datum as for the field `hom` in the structure `homotopy`. For\nthis definition, we do not need the field `zero` of that structure\nas this definition uses only the maps `C_i ⟶ C_j` when `c.rel j i`. -/\ndef null_homotopic_map (hom : Π i j, C.X i ⟶ D.X j) : C ⟶ D :=\n{ f      := λ i, d_next i hom + prev_d i hom,\n  comm'  := λ i j hij,\n  begin\n    have eq1 : prev_d i hom ≫ D.d i j = 0,\n    { simp only [prev_d, add_monoid_hom.mk'_apply, category.assoc, d_comp_d, comp_zero], },\n    have eq2 : C.d i j ≫ d_next j hom = 0,\n    { simp only [d_next, add_monoid_hom.mk'_apply, d_comp_d_assoc, zero_comp], },\n    rw [d_next_eq hom hij, prev_d_eq hom hij, preadditive.comp_add, preadditive.add_comp,\n      eq1, eq2, add_zero, zero_add, category.assoc],\n  end }\n\n/-- Variant of `null_homotopic_map` where the input consists only of the\nrelevant maps `C_i ⟶ D_j` such that `c.rel j i`. -/\ndef null_homotopic_map' (h : Π i j, c.rel j i → (C.X i ⟶ D.X j)) : C ⟶ D :=\nnull_homotopic_map (λ i j, dite (c.rel j i) (h i j) (λ _, 0))\n\n/-- Compatibility of `null_homotopic_map` with the postcomposition by a morphism\nof complexes. -/\nlemma null_homotopic_map_comp (hom : Π i j, C.X i ⟶ D.X j) (g : D ⟶ E) :\nnull_homotopic_map hom ≫ g = null_homotopic_map (λ i j, hom i j ≫ g.f j) :=\nbegin\n  ext n,\n  dsimp [null_homotopic_map, from_next, to_prev, add_monoid_hom.mk'_apply],\n  simp only [preadditive.add_comp, category.assoc, g.comm],\nend\n\n/-- Compatibility of `null_homotopic_map'` with the postcomposition by a morphism\nof complexes. -/\nlemma null_homotopic_map'_comp (hom : Π i j, c.rel j i → (C.X i ⟶ D.X j)) (g : D ⟶ E) :\nnull_homotopic_map' hom ≫ g = null_homotopic_map' (λ i j hij, hom i j hij ≫ g.f j) :=\nbegin\n  ext n,\n  erw null_homotopic_map_comp,\n  congr',\n  ext i j,\n  split_ifs,\n  { refl, },\n  { rw zero_comp, },\nend\n\n/-- Compatibility of `null_homotopic_map` with the precomposition by a morphism\nof complexes. -/\nlemma comp_null_homotopic_map (f : C ⟶ D) (hom : Π i j, D.X i ⟶ E.X j) :\nf ≫ null_homotopic_map hom = null_homotopic_map (λ i j, f.f i ≫ hom i j) :=\nbegin\n  ext n,\n  dsimp [null_homotopic_map, from_next, to_prev, add_monoid_hom.mk'_apply],\n  simp only [preadditive.comp_add, category.assoc, f.comm_assoc],\nend\n\n/-- Compatibility of `null_homotopic_map'` with the precomposition by a morphism\nof complexes. -/\nlemma comp_null_homotopic_map' (f : C ⟶ D) (hom : Π i j, c.rel j i → (D.X i ⟶ E.X j)) :\nf ≫ null_homotopic_map' hom = null_homotopic_map' (λ i j hij, f.f i ≫ hom i j hij) :=\nbegin\n  ext n,\n  erw comp_null_homotopic_map,\n  congr',\n  ext i j,\n  split_ifs,\n  { refl, },\n  { rw comp_zero, },\nend\n\n/-- Compatibility of `null_homotopic_map` with the application of additive functors -/\nlemma map_null_homotopic_map {W : Type*} [category W] [preadditive W]\n  (G : V ⥤ W) [G.additive] (hom : Π i j, C.X i ⟶ D.X j) :\n  (G.map_homological_complex c).map (null_homotopic_map hom) =\n  null_homotopic_map (λ i j, G.map (hom i j)) :=\nbegin\n  ext i,\n  dsimp [null_homotopic_map, d_next, prev_d],\n  simp only [G.map_comp, functor.map_add],\nend\n\n/-- Compatibility of `null_homotopic_map'` with the application of additive functors -/\nlemma map_null_homotopic_map' {W : Type*} [category W] [preadditive W]\n  (G : V ⥤ W) [G.additive] (hom : Π i j, c.rel j i → (C.X i ⟶ D.X j)) :\n  (G.map_homological_complex c).map (null_homotopic_map' hom) =\n  null_homotopic_map' (λ i j hij, G.map (hom i j hij)) :=\nbegin\n  ext n,\n  erw map_null_homotopic_map,\n  congr',\n  ext i j,\n  split_ifs,\n  { refl, },\n  { rw G.map_zero, }\nend\n\n/-- Tautological construction of the `homotopy` to zero for maps constructed by\n`null_homotopic_map`, at least when we have the `zero'` condition. -/\n@[simps]\ndef null_homotopy (hom : Π i j, C.X i ⟶ D.X j) (zero' : ∀ i j, ¬ c.rel j i → hom i j = 0) :\n  homotopy (null_homotopic_map hom) 0 :=\n{ hom := hom,\n  zero' := zero',\n  comm := by { intro i, rw [homological_complex.zero_f_apply, add_zero], refl, }, }\n\n/-- Homotopy to zero for maps constructed with `null_homotopic_map'` -/\n@[simps]\ndef null_homotopy' (h : Π i j, c.rel j i → (C.X i ⟶ D.X j)) :\n  homotopy (null_homotopic_map' h) 0 :=\nbegin\n  apply null_homotopy (λ i j, dite (c.rel j i) (h i j) (λ _, 0)),\n  intros i j hij,\n  dsimp,\n  rw [dite_eq_right_iff],\n  intro hij',\n  exfalso,\n  exact hij hij',\nend\n\n/-! This lemma and the following ones can be used in order to compute\nthe degreewise morphisms induced by the null homotopic maps constructed\nwith `null_homotopic_map` or `null_homotopic_map'` -/\n@[simp]\nlemma null_homotopic_map_f {k₂ k₁ k₀ : ι} (r₂₁ : c.rel k₂ k₁) (r₁₀ : c.rel k₁ k₀)\n  (hom : Π i j, C.X i ⟶ D.X j) :\n  (null_homotopic_map hom).f k₁ = C.d k₁ k₀ ≫ hom k₀ k₁ + hom k₁ k₂ ≫ D.d k₂ k₁ :=\nby { dsimp only [null_homotopic_map], rw [d_next_eq hom r₁₀, prev_d_eq hom r₂₁], }\n\n@[simp]\nlemma null_homotopic_map'_f {k₂ k₁ k₀  : ι} (r₂₁ : c.rel k₂ k₁) (r₁₀ : c.rel k₁ k₀)\n  (h : Π i j, c.rel j i → (C.X i ⟶ D.X j)) :\n  (null_homotopic_map' h).f k₁ = C.d k₁ k₀ ≫ h k₀ k₁ r₁₀ + h k₁ k₂ r₂₁ ≫ D.d k₂ k₁ :=\nbegin\n  simp only [← null_homotopic_map'],\n  rw null_homotopic_map_f r₂₁ r₁₀ (λ i j, dite (c.rel j i) (h i j) (λ _, 0)),\n  dsimp,\n  split_ifs,\n  refl,\nend\n\n@[simp]\nlemma null_homotopic_map_f_of_not_rel_left {k₁ k₀ : ι} (r₁₀ : c.rel k₁ k₀)\n  (hk₀ : ∀ l : ι, ¬c.rel k₀ l)\n  (hom : Π i j, C.X i ⟶ D.X j) :\n  (null_homotopic_map hom).f k₀ = hom k₀ k₁ ≫ D.d k₁ k₀ :=\nbegin\n  dsimp only [null_homotopic_map],\n  rw [prev_d_eq hom r₁₀, d_next, add_monoid_hom.mk'_apply, C.shape, zero_comp, zero_add],\n  exact hk₀ _\nend\n\n@[simp]\nlemma null_homotopic_map'_f_of_not_rel_left {k₁ k₀ : ι} (r₁₀ : c.rel k₁ k₀)\n  (hk₀ : ∀ l : ι, ¬c.rel k₀ l)\n  (h : Π i j, c.rel j i → (C.X i ⟶ D.X j)) :\n  (null_homotopic_map' h).f k₀ = h k₀ k₁ r₁₀ ≫ D.d k₁ k₀ :=\nbegin\n  simp only [← null_homotopic_map'],\n  rw null_homotopic_map_f_of_not_rel_left r₁₀ hk₀ (λ i j, dite (c.rel j i) (h i j) (λ _, 0)),\n  dsimp,\n  split_ifs,\n  refl,\nend\n\n@[simp]\nlemma null_homotopic_map_f_of_not_rel_right {k₁ k₀ : ι} (r₁₀ : c.rel k₁ k₀)\n  (hk₁ : ∀ l : ι, ¬c.rel l k₁)\n  (hom : Π i j, C.X i ⟶ D.X j) :\n  (null_homotopic_map hom).f k₁ = C.d k₁ k₀ ≫ hom k₀ k₁ :=\nbegin\n  dsimp only [null_homotopic_map],\n  rw [d_next_eq hom r₁₀, prev_d, add_monoid_hom.mk'_apply, D.shape, comp_zero, add_zero],\n  exact hk₁ _,\nend\n\n@[simp]\nlemma null_homotopic_map'_f_of_not_rel_right {k₁ k₀ : ι} (r₁₀ : c.rel k₁ k₀)\n  (hk₁ : ∀ l : ι, ¬c.rel l k₁)\n  (h : Π i j, c.rel j i → (C.X i ⟶ D.X j)) :\n  (null_homotopic_map' h).f k₁ = C.d k₁ k₀ ≫ h k₀ k₁ r₁₀ :=\nbegin\n  simp only [← null_homotopic_map'],\n  rw null_homotopic_map_f_of_not_rel_right r₁₀ hk₁ (λ i j, dite (c.rel j i) (h i j) (λ _, 0)),\n  dsimp,\n  split_ifs,\n  refl,\nend\n\n@[simp]\nlemma null_homotopic_map_f_eq_zero {k₀ : ι}\n  (hk₀ : ∀ l : ι, ¬c.rel k₀ l) (hk₀' : ∀ l : ι, ¬c.rel l k₀)\n  (hom : Π i j, C.X i ⟶ D.X j) :\n  (null_homotopic_map hom).f k₀ = 0 :=\nbegin\n  dsimp [null_homotopic_map, d_next, prev_d],\n  rw [C.shape, D.shape, zero_comp, comp_zero, add_zero]; apply_assumption,\nend\n\n@[simp]\nlemma null_homotopic_map'_f_eq_zero {k₀ : ι}\n  (hk₀ : ∀ l : ι, ¬c.rel k₀ l) (hk₀' : ∀ l : ι, ¬c.rel l k₀)\n  (h : Π i j, c.rel j i → (C.X i ⟶ D.X j)) :\n  (null_homotopic_map' h).f k₀ = 0 :=\nbegin\n  simp only [← null_homotopic_map'],\n  exact null_homotopic_map_f_eq_zero hk₀ hk₀'\n    (λ i j, dite (c.rel j i) (h i j) (λ _, 0)),\nend\n\n/-!\n`homotopy.mk_inductive` allows us to build a homotopy of chain complexes inductively,\nso that as we construct each component, we have available the previous two components,\nand the fact that they satisfy the homotopy condition.\n\nTo simplify the situation, we only construct homotopies of the form `homotopy e 0`.\n`homotopy.equiv_sub_zero` can provide the general case.\n\nNotice however, that this construction does not have particularly good definitional properties:\nwe have to insert `eq_to_hom` in several places.\nHopefully this is okay in most applications, where we only need to have the existence of some\nhomotopy.\n-/\nsection mk_inductive\n\nvariables {P Q : chain_complex V ℕ}\n\n@[simp] lemma prev_d_chain_complex (f : Π i j, P.X i ⟶ Q.X j) (j : ℕ) :\n  prev_d j f = f j (j+1) ≫ Q.d _ _ :=\nbegin\n  dsimp [prev_d],\n  have : (complex_shape.down ℕ).prev j = j + 1 := chain_complex.prev ℕ j,\n  congr' 2,\nend\n\n@[simp] lemma d_next_succ_chain_complex (f : Π i j, P.X i ⟶ Q.X j) (i : ℕ) :\n  d_next (i+1) f = P.d _ _ ≫ f i (i+1) :=\nbegin\n  dsimp [d_next],\n  have : (complex_shape.down ℕ).next (i + 1) = i := chain_complex.next_nat_succ _,\n  congr' 2,\nend\n\n@[simp] lemma d_next_zero_chain_complex (f : Π i j, P.X i ⟶ Q.X j) :\n  d_next 0 f = 0 :=\nbegin\n  dsimp [d_next],\n  rw [P.shape, zero_comp],\n  rw chain_complex.next_nat_zero, dsimp, dec_trivial,\nend\n\nvariables (e : P ⟶ Q)\n  (zero : P.X 0 ⟶ Q.X 1)\n  (comm_zero : e.f 0 = zero ≫ Q.d 1 0)\n  (one : P.X 1 ⟶ Q.X 2)\n  (comm_one : e.f 1 = P.d 1 0 ≫ zero + one ≫ Q.d 2 1)\n  (succ : ∀ (n : ℕ)\n    (p : Σ' (f : P.X n ⟶ Q.X (n+1)) (f' : P.X (n+1) ⟶ Q.X (n+2)),\n      e.f (n+1) = P.d (n+1) n ≫ f + f' ≫ Q.d (n+2) (n+1)),\n    Σ' f'' : P.X (n+2) ⟶ Q.X (n+3), e.f (n+2) = P.d (n+2) (n+1) ≫ p.2.1 + f'' ≫ Q.d (n+3) (n+2))\n\ninclude comm_one comm_zero\n\n/--\nAn auxiliary construction for `mk_inductive`.\n\nHere we build by induction a family of diagrams,\nbut don't require at the type level that these successive diagrams actually agree.\nThey do in fact agree, and we then capture that at the type level (i.e. by constructing a homotopy)\nin `mk_inductive`.\n\nAt this stage, we don't check the homotopy condition in degree 0,\nbecause it \"falls off the end\", and is easier to treat using `X_next` and `X_prev`,\nwhich we do in `mk_inductive_aux₂`.\n-/\n@[simp, nolint unused_arguments]\ndef mk_inductive_aux₁ :\n  Π n, Σ' (f : P.X n ⟶ Q.X (n+1)) (f' : P.X (n+1) ⟶ Q.X (n+2)),\n    e.f (n+1) = P.d (n+1) n ≫ f + f' ≫ Q.d (n+2) (n+1)\n| 0 := ⟨zero, one, comm_one⟩\n| 1 := ⟨one, (succ 0 ⟨zero, one, comm_one⟩).1, (succ 0 ⟨zero, one, comm_one⟩).2⟩\n| (n+2) :=\n  ⟨(mk_inductive_aux₁ (n+1)).2.1,\n    (succ (n+1) (mk_inductive_aux₁ (n+1))).1,\n    (succ (n+1) (mk_inductive_aux₁ (n+1))).2⟩\n\nsection\n\n/--\nAn auxiliary construction for `mk_inductive`.\n-/\n@[simp]\ndef mk_inductive_aux₂ :\n  Π n, Σ' (f : P.X_next n ⟶ Q.X n) (f' : P.X n ⟶ Q.X_prev n), e.f n = P.d_from n ≫ f + f' ≫ Q.d_to n\n| 0 := ⟨0, zero ≫ (Q.X_prev_iso rfl).inv, by simpa using comm_zero⟩\n| (n+1) := let I := mk_inductive_aux₁ e zero comm_zero one comm_one succ n in\n  ⟨(P.X_next_iso rfl).hom ≫ I.1, I.2.1 ≫ (Q.X_prev_iso rfl).inv, by simpa using I.2.2⟩\n\nlemma mk_inductive_aux₃ (i j : ℕ) (h : i+1 = j) :\n  (mk_inductive_aux₂ e zero comm_zero one comm_one succ i).2.1 ≫ (Q.X_prev_iso h).hom\n    = (P.X_next_iso h).inv ≫ (mk_inductive_aux₂ e zero comm_zero one comm_one succ j).1 :=\nby subst j; rcases i with (_|_|i); { dsimp, simp, }\n\n/--\nA constructor for a `homotopy e 0`, for `e` a chain map between `ℕ`-indexed chain complexes,\nworking by induction.\n\nYou need to provide the components of the homotopy in degrees 0 and 1,\nshow that these satisfy the homotopy condition,\nand then give a construction of each component,\nand the fact that it satisfies the homotopy condition,\nusing as an inductive hypothesis the data and homotopy condition for the previous two components.\n-/\ndef mk_inductive : homotopy e 0 :=\n{ hom := λ i j, if h : i + 1 = j then\n    (mk_inductive_aux₂ e zero comm_zero one comm_one succ i).2.1 ≫ (Q.X_prev_iso h).hom\n  else\n    0,\n  zero' := λ i j w, by rwa dif_neg,\n  comm := λ i, begin\n    dsimp, simp only [add_zero],\n    convert (mk_inductive_aux₂ e zero comm_zero one comm_one succ i).2.2,\n    { cases i,\n      { dsimp [from_next], rw dif_neg,\n        simp only [chain_complex.next_nat_zero, nat.one_ne_zero, not_false_iff], },\n      { dsimp [from_next], rw dif_pos, swap, { simp only [chain_complex.next_nat_succ] },\n        have aux : (complex_shape.down ℕ).next i.succ = i := chain_complex.next_nat_succ i,\n        rw mk_inductive_aux₃ e zero comm_zero one comm_one succ\n          ((complex_shape.down ℕ).next i.succ) (i+1) (by rw aux),\n        dsimp [X_next_iso], erw category.id_comp, } },\n    { dsimp [to_prev], rw dif_pos, swap, { simp only [chain_complex.prev] },\n      dsimp [X_prev_iso], erw category.comp_id, },\n  end, }\n\nend\n\nend mk_inductive\n\n/-!\n`homotopy.mk_coinductive` allows us to build a homotopy of cochain complexes inductively,\nso that as we construct each component, we have available the previous two components,\nand the fact that they satisfy the homotopy condition.\n-/\nsection mk_coinductive\n\nvariables {P Q : cochain_complex V ℕ}\n\n@[simp] lemma d_next_cochain_complex (f : Π i j, P.X i ⟶ Q.X j) (j : ℕ) :\n  d_next j f = P.d _ _ ≫ f (j+1) j :=\nbegin\n  dsimp [d_next],\n  have : (complex_shape.up ℕ).next j = j + 1 := cochain_complex.next ℕ j,\n  congr' 2,\nend\n\n@[simp] lemma prev_d_succ_cochain_complex (f : Π i j, P.X i ⟶ Q.X j) (i : ℕ) :\n  prev_d (i+1) f = f (i+1) _ ≫ Q.d i (i+1) :=\nbegin\n  dsimp [prev_d],\n  have : (complex_shape.up ℕ).prev (i+1) = i := cochain_complex.prev_nat_succ i,\n  congr' 2,\nend\n\n@[simp] lemma prev_d_zero_cochain_complex (f : Π i j, P.X i ⟶ Q.X j) :\n  prev_d 0 f = 0 :=\nbegin\n  dsimp [prev_d],\n  rw [Q.shape, comp_zero],\n  rw [cochain_complex.prev_nat_zero], dsimp, dec_trivial,\nend\n\nvariables (e : P ⟶ Q)\n  (zero : P.X 1 ⟶ Q.X 0)\n  (comm_zero : e.f 0 = P.d 0 1 ≫ zero)\n  (one : P.X 2 ⟶ Q.X 1)\n  (comm_one : e.f 1 = zero ≫ Q.d 0 1 + P.d 1 2 ≫ one)\n  (succ : ∀ (n : ℕ)\n    (p : Σ' (f : P.X (n+1) ⟶ Q.X n) (f' : P.X (n+2) ⟶ Q.X (n+1)),\n      e.f (n+1) = f ≫ Q.d n (n+1) + P.d (n+1) (n+2) ≫ f'),\n    Σ' f'' : P.X (n+3) ⟶ Q.X (n+2), e.f (n+2) = p.2.1 ≫ Q.d (n+1) (n+2) + P.d (n+2) (n+3) ≫ f'')\n\ninclude comm_one comm_zero succ\n\n/--\nAn auxiliary construction for `mk_coinductive`.\n\nHere we build by induction a family of diagrams,\nbut don't require at the type level that these successive diagrams actually agree.\nThey do in fact agree, and we then capture that at the type level (i.e. by constructing a homotopy)\nin `mk_coinductive`.\n\nAt this stage, we don't check the homotopy condition in degree 0,\nbecause it \"falls off the end\", and is easier to treat using `X_next` and `X_prev`,\nwhich we do in `mk_inductive_aux₂`.\n-/\n@[simp, nolint unused_arguments]\ndef mk_coinductive_aux₁ :\n  Π n, Σ' (f : P.X (n+1) ⟶ Q.X n) (f' : P.X (n+2) ⟶ Q.X (n+1)),\n    e.f (n+1) = f ≫ Q.d n (n+1) + P.d (n+1) (n+2) ≫ f'\n| 0 := ⟨zero, one, comm_one⟩\n| 1 := ⟨one, (succ 0 ⟨zero, one, comm_one⟩).1, (succ 0 ⟨zero, one, comm_one⟩).2⟩\n| (n+2) :=\n  ⟨(mk_coinductive_aux₁ (n+1)).2.1,\n    (succ (n+1) (mk_coinductive_aux₁ (n+1))).1,\n    (succ (n+1) (mk_coinductive_aux₁ (n+1))).2⟩\n\nsection\n\n/--\nAn auxiliary construction for `mk_inductive`.\n-/\n@[simp]\ndef mk_coinductive_aux₂ :\n  Π n, Σ' (f : P.X n ⟶ Q.X_prev n) (f' : P.X_next n ⟶ Q.X n),\n    e.f n = f ≫ Q.d_to n + P.d_from n ≫ f'\n| 0 := ⟨0, (P.X_next_iso rfl).hom ≫ zero, by simpa using comm_zero⟩\n| (n+1) := let I := mk_coinductive_aux₁ e zero comm_zero one comm_one succ n in\n  ⟨I.1 ≫ (Q.X_prev_iso rfl).inv, (P.X_next_iso rfl).hom ≫ I.2.1, by simpa using I.2.2⟩\n\nlemma mk_coinductive_aux₃ (i j : ℕ) (h : i + 1 = j) :\n  (P.X_next_iso h).inv ≫ (mk_coinductive_aux₂ e zero comm_zero one comm_one succ i).2.1\n    = (mk_coinductive_aux₂ e zero comm_zero one comm_one succ j).1 ≫ (Q.X_prev_iso h).hom :=\nby subst j; rcases i with (_|_|i); { dsimp, simp, }\n\n/--\nA constructor for a `homotopy e 0`, for `e` a chain map between `ℕ`-indexed cochain complexes,\nworking by induction.\n\nYou need to provide the components of the homotopy in degrees 0 and 1,\nshow that these satisfy the homotopy condition,\nand then give a construction of each component,\nand the fact that it satisfies the homotopy condition,\nusing as an inductive hypothesis the data and homotopy condition for the previous two components.\n-/\ndef mk_coinductive : homotopy e 0 :=\n{ hom := λ i j, if h : j + 1 = i then\n    (P.X_next_iso h).inv ≫ (mk_coinductive_aux₂ e zero comm_zero one comm_one succ j).2.1\n  else\n    0,\n  zero' := λ i j w, by rwa dif_neg,\n  comm := λ i, begin\n    dsimp,\n    rw [add_zero, add_comm],\n    convert (mk_coinductive_aux₂ e zero comm_zero one comm_one succ i).2.2 using 2,\n    { cases i,\n      { dsimp [to_prev], rw dif_neg,\n        simp only [cochain_complex.prev_nat_zero, nat.one_ne_zero, not_false_iff], },\n      { dsimp [to_prev], rw dif_pos, swap, { simp only [cochain_complex.prev_nat_succ] },\n        have aux : (complex_shape.up ℕ).prev i.succ = i := cochain_complex.prev_nat_succ i,\n        rw mk_coinductive_aux₃ e zero comm_zero one comm_one succ\n          ((complex_shape.up ℕ).prev i.succ) (i+1) (by rw aux),\n        dsimp [X_prev_iso], erw category.comp_id, } },\n    { dsimp [from_next], rw dif_pos, swap, { simp only [cochain_complex.next] },\n      dsimp [X_next_iso], erw category.id_comp, },\n  end }\n\nend\n\nend mk_coinductive\n\nend homotopy\n\n/--\nA homotopy equivalence between two chain complexes consists of a chain map each way,\nand homotopies from the compositions to the identity chain maps.\n\nNote that this contains data;\narguably it might be more useful for many applications if we truncated it to a Prop.\n-/\nstructure homotopy_equiv (C D : homological_complex V c) :=\n(hom : C ⟶ D)\n(inv : D ⟶ C)\n(homotopy_hom_inv_id : homotopy (hom ≫ inv) (𝟙 C))\n(homotopy_inv_hom_id : homotopy (inv ≫ hom) (𝟙 D))\n\nnamespace homotopy_equiv\n\n/-- Any complex is homotopy equivalent to itself. -/\n@[refl] def refl (C : homological_complex V c) : homotopy_equiv C C :=\n{ hom := 𝟙 C,\n  inv := 𝟙 C,\n  homotopy_hom_inv_id := by simp,\n  homotopy_inv_hom_id := by simp, }\n\ninstance : inhabited (homotopy_equiv C C) := ⟨refl C⟩\n\n/-- Being homotopy equivalent is a symmetric relation. -/\n@[symm] def symm\n  {C D : homological_complex V c} (f : homotopy_equiv C D) :\n  homotopy_equiv D C :=\n{ hom := f.inv,\n  inv := f.hom,\n  homotopy_hom_inv_id := f.homotopy_inv_hom_id,\n  homotopy_inv_hom_id := f.homotopy_hom_inv_id, }\n\n/-- Homotopy equivalence is a transitive relation. -/\n@[trans] def trans\n  {C D E : homological_complex V c} (f : homotopy_equiv C D) (g : homotopy_equiv D E) :\n  homotopy_equiv C E :=\n{ hom := f.hom ≫ g.hom,\n  inv := g.inv ≫ f.inv,\n  homotopy_hom_inv_id := by simpa using\n    ((g.homotopy_hom_inv_id.comp_right_id f.inv).comp_left f.hom).trans f.homotopy_hom_inv_id,\n  homotopy_inv_hom_id := by simpa using\n    ((f.homotopy_inv_hom_id.comp_right_id g.hom).comp_left g.inv).trans g.homotopy_inv_hom_id, }\n\n/-- An isomorphism of complexes induces a homotopy equivalence. -/\ndef of_iso {ι : Type*} {V : Type u} [category.{v} V] [preadditive V]\n  {c : complex_shape ι} {C D : homological_complex V c} (f : C ≅ D) :\n  homotopy_equiv C D :=\n⟨f.hom, f.inv, homotopy.of_eq f.3, homotopy.of_eq f.4⟩\n\nend homotopy_equiv\n\nvariables [has_equalizers V] [has_cokernels V] [has_images V] [has_image_maps V]\n\n/--\nHomotopic maps induce the same map on homology.\n-/\ntheorem homology_map_eq_of_homotopy (h : homotopy f g) (i : ι) :\n  (homology_functor V c i).map f = (homology_functor V c i).map g :=\nbegin\n  dsimp [homology_functor],\n  apply eq_of_sub_eq_zero,\n  ext,\n  simp only [homology.π_map, comp_zero, preadditive.comp_sub],\n  dsimp [kernel_subobject_map],\n  simp_rw [h.comm i],\n  simp only [zero_add, zero_comp, d_next_eq_d_from_from_next, kernel_subobject_arrow_comp_assoc,\n    preadditive.comp_add],\n  rw [←preadditive.sub_comp],\n  simp only [category_theory.subobject.factor_thru_add_sub_factor_thru_right],\n  erw [subobject.factor_thru_of_le (D.boundaries_le_cycles i)],\n  { simp, },\n  { rw [prev_d_eq_to_prev_d_to, ←category.assoc],\n    apply image_subobject_factors_comp_self, },\nend\n\n/-- Homotopy equivalent complexes have isomorphic homologies. -/\ndef homology_obj_iso_of_homotopy_equiv (f : homotopy_equiv C D) (i : ι) :\n  (homology_functor V c i).obj C ≅ (homology_functor V c i).obj D :=\n{ hom := (homology_functor V c i).map f.hom,\n  inv := (homology_functor V c i).map f.inv,\n  hom_inv_id' := begin\n    rw [←functor.map_comp, homology_map_eq_of_homotopy f.homotopy_hom_inv_id,\n      category_theory.functor.map_id],\n  end,\n  inv_hom_id' := begin\n    rw [←functor.map_comp, homology_map_eq_of_homotopy f.homotopy_inv_hom_id,\n      category_theory.functor.map_id],\n  end, }\n\nend\n\nnamespace category_theory\n\nvariables {W : Type*} [category W] [preadditive W]\n\n/-- An additive functor takes homotopies to homotopies. -/\n@[simps]\ndef functor.map_homotopy (F : V ⥤ W) [F.additive] {f g : C ⟶ D} (h : homotopy f g) :\n  homotopy ((F.map_homological_complex c).map f) ((F.map_homological_complex c).map g) :=\n{ hom := λ i j, F.map (h.hom i j),\n  zero' := λ i j w, by { rw [h.zero i j w, F.map_zero], },\n  comm := λ i, begin\n    dsimp [d_next, prev_d] at *,\n    rw h.comm i,\n    simp only [F.map_add, ← F.map_comp],\n    refl\n  end, }\n\n/-- An additive functor preserves homotopy equivalences. -/\n@[simps]\ndef functor.map_homotopy_equiv (F : V ⥤ W) [F.additive] (h : homotopy_equiv C D) :\n  homotopy_equiv ((F.map_homological_complex c).obj C) ((F.map_homological_complex c).obj D) :=\n{ hom := (F.map_homological_complex c).map h.hom,\n  inv := (F.map_homological_complex c).map h.inv,\n  homotopy_hom_inv_id := begin\n    rw [←(F.map_homological_complex c).map_comp, ←(F.map_homological_complex c).map_id],\n    exact F.map_homotopy h.homotopy_hom_inv_id,\n  end,\n  homotopy_inv_hom_id := begin\n    rw [←(F.map_homological_complex c).map_comp, ←(F.map_homological_complex c).map_id],\n    exact F.map_homotopy h.homotopy_inv_hom_id,\n  end }\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/homology/homotopy.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.787931185683219, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.49045511887346077}}
{"text": "/-\nCopyright (c) 2022 Riccardo Brasca. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Riccardo Brasca, Adam Topaz\n-/\n\nimport category_theory.abelian.homology\nimport category_theory.functor.left_derived\nimport category_theory.abelian.projective\nimport category_theory.limits.constructions.epi_mono\n\n/-!\n# Zeroth left derived functors\n\nIf `F : C ⥤ D` is an additive right exact functor between abelian categories, where `C` has enough\nprojectives, we provide the natural isomorphism `F.left_derived 0 ≅ F`.\n\n## Main definitions\n\n* `category_theory.abelian.functor.left_derived_zero_iso_self`: the natural isomorphism\n  `(F.left_derived 0) ≅ F`.\n\n## Main results\n* `preserves_exact_of_preserves_finite_colimits_of_epi`: if `preserves_finite_colimits F` and\n  `epi g`, then `exact (F.map f) (F.map g)` if `exact f g`.\n\n-/\n\nnoncomputable theory\n\nuniverses w v u\n\nopen category_theory.limits category_theory category_theory.functor\n\nvariables {C : Type u} [category.{w} C] {D : Type u} [category.{w} D]\nvariables (F : C ⥤ D) {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z}\n\nnamespace category_theory.abelian.functor\n\nopen category_theory.preadditive\n\nvariables [abelian C] [abelian D] [additive F]\n\n/-- If `preserves_finite_colimits F` and `epi g`, then `exact (F.map f) (F.map g)` if\n`exact f g`. -/\nlemma preserves_exact_of_preserves_finite_colimits_of_epi [preserves_finite_colimits F] [epi g]\n  (ex : exact f g) : exact (F.map f) (F.map g) :=\nabelian.exact_of_is_cokernel _ _ (by simp [← functor.map_comp, ex.w])\n  $ limits.is_colimit_cofork_map_of_is_colimit' _ ex.w (abelian.is_colimit_of_exact_of_epi _ _ ex)\n\nlemma exact_of_map_projective_resolution (P: ProjectiveResolution X) [preserves_finite_colimits F] :\n  exact (((F.map_homological_complex (complex_shape.down ℕ)).obj P.complex).d_to 0)\n  (F.map (P.π.f 0)) :=\npreadditive.exact_of_iso_of_exact' (F.map (P.complex.d 1 0)) (F.map (P.π.f 0)) _ _\n    (homological_complex.X_prev_iso ((F.map_homological_complex _).obj P.complex) rfl).symm\n    (iso.refl _) (iso.refl _) (by simp) (by simp)\n    (preserves_exact_of_preserves_finite_colimits_of_epi _ (P.exact₀))\n\n/-- Given `P : ProjectiveResolution X`, a morphism `(F.left_derived 0).obj X ⟶ F.obj X`. -/\n@[nolint unused_arguments]\ndef left_derived_zero_to_self_app [enough_projectives C] {X : C}\n  (P : ProjectiveResolution X) : (F.left_derived 0).obj X ⟶ F.obj X :=\n(left_derived_obj_iso F 0 P).hom ≫ homology.desc' _ _ _ (kernel.ι _ ≫ (F.map (P.π.f 0)))\nbegin\n  rw [kernel.lift_ι_assoc, homological_complex.d_to_eq _ (by simp : (complex_shape.down ℕ).rel 1 0),\n    map_homological_complex_obj_d, category.assoc, ← functor.map_comp],\n  simp\nend\n\n/-- Given `P : ProjectiveResolution X`, a morphism `F.obj X ⟶ (F.left_derived 0).obj X` given\n`preserves_finite_colimits F`. -/\ndef left_derived_zero_to_self_app_inv [enough_projectives C] [preserves_finite_colimits F] {X : C}\n  (P : ProjectiveResolution X) : F.obj X ⟶ (F.left_derived 0).obj X :=\nbegin\n  refine ((as_iso (cokernel.desc _ _ (exact_of_map_projective_resolution F P).w)).inv) ≫ _ ≫\n    (homology_iso_cokernel_lift _ _ _).inv ≫ (left_derived_obj_iso F 0 P).inv,\n  exact cokernel.map _ _ (𝟙 _) (kernel.lift _ (𝟙 _) (by simp)) (by { ext, simp }),\nend\n\nlemma left_derived_zero_to_self_app_comp_inv [enough_projectives C] [preserves_finite_colimits F]\n  {X : C} (P : ProjectiveResolution X) : left_derived_zero_to_self_app F P ≫\n  left_derived_zero_to_self_app_inv F P = 𝟙 _ :=\nbegin\n  dsimp [left_derived_zero_to_self_app, left_derived_zero_to_self_app_inv],\n  rw [← category.assoc, ← category.assoc, ← category.assoc, iso.comp_inv_eq, category.id_comp,\n    category.assoc, category.assoc, category.assoc],\n  convert category.comp_id _,\n  rw [← category.assoc, ← category.assoc, iso.comp_inv_eq, category.id_comp],\n  ext,\n  rw [← category.assoc, ← category.assoc, homology.π'_desc', category.assoc, category.assoc,\n    ← category.assoc (F.map _), abelian.cokernel.desc.inv, cokernel.π_desc, homology.π',\n    category.assoc, iso.inv_hom_id, category.comp_id, ← category.assoc],\n  convert category.id_comp _ using 2,\n  ext,\n  rw [category.id_comp, category.assoc, equalizer_as_kernel, kernel.lift_ι, category.comp_id],\nend\n\nlemma left_derived_zero_to_self_app_inv_comp [enough_projectives C] [preserves_finite_colimits F]\n  {X : C} (P : ProjectiveResolution X) : left_derived_zero_to_self_app_inv F P ≫\n  left_derived_zero_to_self_app F P = 𝟙 _ :=\nbegin\n  dsimp [left_derived_zero_to_self_app, left_derived_zero_to_self_app_inv],\n  rw [category.assoc, category.assoc, category.assoc,\n    ← category.assoc (F.left_derived_obj_iso 0 P).inv, iso.inv_hom_id, category.id_comp,\n    is_iso.inv_comp_eq, category.comp_id],\n  ext,\n  simp only [cokernel.π_desc_assoc, category.assoc, cokernel.π_desc, homology.desc'],\n  rw [← category.assoc, ← category.assoc (homology_iso_cokernel_lift _ _ _).inv, iso.inv_hom_id,\n    category.id_comp],\n  simp only [category.assoc, cokernel.π_desc, kernel.lift_ι_assoc, category.id_comp],\nend\n\n/-- Given `P : ProjectiveResolution X`, the isomorphism `(F.left_derived 0).obj X ≅ F.obj X` if\n`preserves_finite_colimits F`. -/\ndef left_derived_zero_to_self_app_iso [enough_projectives C] [preserves_finite_colimits F]\n  {X : C} (P : ProjectiveResolution X) : (F.left_derived 0).obj X ≅ F.obj X :=\n{ hom := left_derived_zero_to_self_app _ P,\n  inv := left_derived_zero_to_self_app_inv _ P,\n  hom_inv_id' := left_derived_zero_to_self_app_comp_inv _ P,\n  inv_hom_id' := left_derived_zero_to_self_app_inv_comp _ P }\n\n/-- Given `P : ProjectiveResolution X` and `Q : ProjectiveResolution Y` and a morphism `f : X ⟶ Y`,\nnaturality of the square given by `left_derived_zero_to_self_obj_hom. -/\nlemma left_derived_zero_to_self_natural [enough_projectives C] {X : C} {Y : C} (f : X ⟶ Y)\n  (P : ProjectiveResolution X) (Q : ProjectiveResolution Y) :\n  (F.left_derived 0).map f ≫ left_derived_zero_to_self_app F Q =\n  left_derived_zero_to_self_app F P ≫ F.map f :=\nbegin\n  dsimp only [left_derived_zero_to_self_app],\n  rw [functor.left_derived_map_eq F 0 f (ProjectiveResolution.lift f P Q) (by simp),\n    category.assoc, category.assoc, ← category.assoc _ (F.left_derived_obj_iso 0 Q).hom,\n    iso.inv_hom_id, category.id_comp, category.assoc, whisker_eq],\n  dsimp only [homology_functor_map],\n  ext,\n  simp only [homological_complex.hom.sq_to_right, map_homological_complex_map_f,\n    homology.π'_map_assoc, homology.π'_desc', kernel.lift_ι_assoc, category.assoc,\n    homology.π'_desc'_assoc, ← map_comp, show (ProjectiveResolution.lift f P Q).f 0 ≫ _ = _ ≫ f,\n    from homological_complex.congr_hom (ProjectiveResolution.lift_commutes f P Q) 0],\nend\n\n/-- Given `preserves_finite_colimits F`, the natural isomorphism `(F.left_derived 0) ≅ F`. -/\ndef left_derived_zero_iso_self [enough_projectives C] [preserves_finite_colimits F] :\n  (F.left_derived 0) ≅ F :=\nnat_iso.of_components (λ X, left_derived_zero_to_self_app_iso _ (ProjectiveResolution.of X))\n  (λ X Y f, left_derived_zero_to_self_natural _ _ _ _)\n\nend category_theory.abelian.functor\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/abelian/left_derived.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311856832191, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.49045511335506153}}
{"text": "import ontology math.fuzzy\nopen set topological_space classical\nlocal attribute [instance] prop_decidable\n\n-- THIS FILE IS VERY MUCH A WORK IN PROGRESS.\n\nnamespace ontology\n\n-- TODO: consider redefining events as observables\n-- later, and changing notation to support it.\n-- This would be a major refactoring, but one\n-- which does not change the essence of the system,\n-- so we defer it to after the project is close\n-- to the end.\n\n  variables (ω : ontology)\n\n  abbreviation observable (α : Sort*) \n                [topological_space α] \n                [has_none α]\n                := ω.world → α\n\n  abbreviation event' := ω.observable Prop\n\n  @[simp]\n  lemma event'_eq_event : ω.event' = ω.event := \n  by simp [ontology.event, set]\n\n  abbreviation quantity := ω.observable (option ℝ)\n\nsection observables\n\n  variables {ω} {α : Type*} [topological_space α] \n            [has_none α] (o : ω.observable α)\n\n  abbreviation observable.perfect := continuous o\n\n  /- observables are coerced to their domain of definition -/\n  instance has_coe_observable_event : has_coe (ω.observable α) ω.event := ⟨λ f x, f x ≠ has_none.none⟩\n\nend observables\n\n  -- We now talk about analogical (fuzzy) events, or \"aevents\" TODO: revise this comment.\n  abbreviation aevent :=  ω.observable fuzzy\n\nnamespace aevent\n\n  variables {ω} (ae : ω.aevent)\n\n  abbreviation aevent.possible := (↑ae : ω.event).possible \n\n  /-- Use `⋄ae` for \"`ae` is possible\" -/\n  instance has_diamond_aevent : has_diamond ω.aevent := ⟨aevent.possible⟩\n\nend aevent\n\nend ontology", "meta": {"author": "maxd13", "repo": "topological_ontology", "sha": "68d21c9a00024fba3aed301e16c31e05733c1786", "save_path": "github-repos/lean/maxd13-topological_ontology", "path": "github-repos/lean/maxd13-topological_ontology/topological_ontology-68d21c9a00024fba3aed301e16c31e05733c1786/src/observables.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473813156295, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4904131983849096}}
{"text": "/-\nCopyright (c) 2020 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.mul_add_aut\nimport Mathlib.logic.function.basic\nimport Mathlib.group_theory.subgroup\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 u_4 u_5 \n\nnamespace Mathlib\n\n/-!\n# Semidirect product\n\nThis file defines semidirect products of groups, and the canonical maps in and out of the\nsemidirect product. The semidirect product of `N` and `G` given a hom `φ` from\n`φ` from `G` to the automorphism group of `N` is the product of sets with the group\n`⟨n₁, g₁⟩ * ⟨n₂, g₂⟩ = ⟨n₁ * φ g₁ n₂, g₁ * g₂⟩`\n\n## Key definitions\n\nThere are two homs into the semidirect product `inl : N →* N ⋊[φ] G` and\n`inr : G →* N ⋊[φ] G`, and `lift` can be used to define maps `N ⋊[φ] G →* H`\nout of the semidirect product given maps `f₁ : N →* H` and `f₂ : G →* H` that satisfy the\ncondition `∀ n g, f₁ (φ g n) = f₂ g * f₁ n * f₂ g⁻¹`\n\n## Notation\n\nThis file introduces the global notation `N ⋊[φ] G` for `semidirect_product N G φ`\n\n## Tags\ngroup, semidirect product\n-/\n\n/-- The semidirect product of groups `N` and `G`, given a map `φ` from `G` to the automorphism\n  group of `N`. It the product of sets with the group operation\n  `⟨n₁, g₁⟩ * ⟨n₂, g₂⟩ = ⟨n₁ * φ g₁ n₂, g₁ * g₂⟩` -/\nstructure semidirect_product (N : Type u_1) (G : Type u_2) [group N] [group G] (φ : G →* mul_aut N) \nwhere\n  left : N\n  right : G\n\nnamespace semidirect_product\n\n\nprotected instance group {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : group (semidirect_product N G φ) :=\n  group.mk mul_aux mul_assoc_aux one_aux one_mul_aux mul_one_aux inv_aux\n    (div_inv_monoid.div._default mul_aux mul_assoc_aux one_aux one_mul_aux mul_one_aux inv_aux) mul_left_inv_aux\n\nprotected instance inhabited {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : Inhabited (semidirect_product N G φ) :=\n  { default := 1 }\n\n@[simp] theorem one_left {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : left 1 = 1 :=\n  rfl\n\n@[simp] theorem one_right {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : right 1 = 1 :=\n  rfl\n\n@[simp] theorem inv_left {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (a : semidirect_product N G φ) : left (a⁻¹) = coe_fn (coe_fn φ (right a⁻¹)) (left a⁻¹) :=\n  rfl\n\n@[simp] theorem inv_right {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (a : semidirect_product N G φ) : right (a⁻¹) = (right a⁻¹) :=\n  rfl\n\n@[simp] theorem mul_left {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (a : semidirect_product N G φ) (b : semidirect_product N G φ) : left (a * b) = left a * coe_fn (coe_fn φ (right a)) (left b) :=\n  rfl\n\n@[simp] theorem mul_right {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (a : semidirect_product N G φ) (b : semidirect_product N G φ) : right (a * b) = right a * right b :=\n  rfl\n\n/-- The canonical map `N →* N ⋊[φ] G` sending `n` to `⟨n, 1⟩` -/\ndef inl {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : N →* semidirect_product N G φ :=\n  monoid_hom.mk (fun (n : N) => mk n 1) sorry sorry\n\n@[simp] theorem left_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (n : N) : left (coe_fn inl n) = n :=\n  rfl\n\n@[simp] theorem right_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (n : N) : right (coe_fn inl n) = 1 :=\n  rfl\n\ntheorem inl_injective {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : function.injective ⇑inl :=\n  iff.mpr function.injective_iff_has_left_inverse (Exists.intro left left_inl)\n\n@[simp] theorem inl_inj {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {n₁ : N} {n₂ : N} : coe_fn inl n₁ = coe_fn inl n₂ ↔ n₁ = n₂ :=\n  function.injective.eq_iff inl_injective\n\n/-- The canonical map `G →* N ⋊[φ] G` sending `g` to `⟨1, g⟩` -/\ndef inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : G →* semidirect_product N G φ :=\n  monoid_hom.mk (fun (g : G) => mk 1 g) sorry sorry\n\n@[simp] theorem left_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (g : G) : left (coe_fn inr g) = 1 :=\n  rfl\n\n@[simp] theorem right_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (g : G) : right (coe_fn inr g) = g :=\n  rfl\n\ntheorem inr_injective {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : function.injective ⇑inr :=\n  iff.mpr function.injective_iff_has_left_inverse (Exists.intro right right_inr)\n\n@[simp] theorem inr_inj {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {g₁ : G} {g₂ : G} : coe_fn inr g₁ = coe_fn inr g₂ ↔ g₁ = g₂ :=\n  function.injective.eq_iff inr_injective\n\ntheorem inl_aut {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (g : G) (n : N) : coe_fn inl (coe_fn (coe_fn φ g) n) = coe_fn inr g * coe_fn inl n * coe_fn inr (g⁻¹) := sorry\n\ntheorem inl_aut_inv {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (g : G) (n : N) : coe_fn inl (coe_fn (coe_fn φ g⁻¹) n) = coe_fn inr (g⁻¹) * coe_fn inl n * coe_fn inr g := sorry\n\n@[simp] theorem mk_eq_inl_mul_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (g : G) (n : N) : mk n g = coe_fn inl n * coe_fn inr g := sorry\n\n@[simp] theorem inl_left_mul_inr_right {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (x : semidirect_product N G φ) : coe_fn inl (left x) * coe_fn inr (right x) = x := sorry\n\n/-- The canonical projection map `N ⋊[φ] G →* G`, as a group hom. -/\ndef right_hom {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : semidirect_product N G φ →* G :=\n  monoid_hom.mk right sorry sorry\n\n@[simp] theorem right_hom_eq_right {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : ⇑right_hom = right :=\n  rfl\n\n@[simp] theorem right_hom_comp_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : monoid_hom.comp right_hom inl = 1 := sorry\n\n@[simp] theorem right_hom_comp_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : monoid_hom.comp right_hom inr = monoid_hom.id G := sorry\n\n@[simp] theorem right_hom_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (n : N) : coe_fn right_hom (coe_fn inl n) = 1 := sorry\n\n@[simp] theorem right_hom_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} (g : G) : coe_fn right_hom (coe_fn inr g) = g := sorry\n\ntheorem right_hom_surjective {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : function.surjective ⇑right_hom :=\n  iff.mpr function.surjective_iff_has_right_inverse (Exists.intro (⇑inr) right_hom_inr)\n\ntheorem range_inl_eq_ker_right_hom {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} : monoid_hom.range inl = monoid_hom.ker right_hom := sorry\n\n/-- Define a group hom `N ⋊[φ] G →* H`, by defining maps `N →* H` and `G →* H`  -/\ndef lift {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {φ : G →* mul_aut N} (f₁ : N →* H) (f₂ : G →* H) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f₂ g))) f₁) : semidirect_product N G φ →* H :=\n  monoid_hom.mk (fun (a : semidirect_product N G φ) => coe_fn f₁ (left a) * coe_fn f₂ (right a)) sorry sorry\n\n@[simp] theorem lift_inl {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {φ : G →* mul_aut N} (f₁ : N →* H) (f₂ : G →* H) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f₂ g))) f₁) (n : N) : coe_fn (lift f₁ f₂ h) (coe_fn inl n) = coe_fn f₁ n := sorry\n\n@[simp] theorem lift_comp_inl {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {φ : G →* mul_aut N} (f₁ : N →* H) (f₂ : G →* H) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f₂ g))) f₁) : monoid_hom.comp (lift f₁ f₂ h) inl = f₁ := sorry\n\n@[simp] theorem lift_inr {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {φ : G →* mul_aut N} (f₁ : N →* H) (f₂ : G →* H) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f₂ g))) f₁) (g : G) : coe_fn (lift f₁ f₂ h) (coe_fn inr g) = coe_fn f₂ g := sorry\n\n@[simp] theorem lift_comp_inr {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {φ : G →* mul_aut N} (f₁ : N →* H) (f₂ : G →* H) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f₂ g))) f₁) : monoid_hom.comp (lift f₁ f₂ h) inr = f₂ := sorry\n\ntheorem lift_unique {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {φ : G →* mul_aut N} (F : semidirect_product N G φ →* H) : F =\n  lift (monoid_hom.comp F inl) (monoid_hom.comp F inr)\n    fun (_x : G) =>\n      monoid_hom.ext\n        fun (x : N) =>\n          eq.mpr\n            (id\n              (Eq.trans\n                (Eq.trans\n                  (Eq.trans\n                    ((fun (a a_1 : H) (e_1 : a = a_1) (ᾰ ᾰ_1 : H) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n                      (coe_fn (monoid_hom.comp (monoid_hom.comp F inl) (mul_equiv.to_monoid_hom (coe_fn φ _x))) x)\n                      (coe_fn F (coe_fn inr _x) * coe_fn F (coe_fn inl x) * (coe_fn F (coe_fn inr _x)⁻¹))\n                      (Eq.trans\n                        (Eq.trans\n                          (Eq.trans\n                            (Eq.trans\n                              (Eq.trans\n                                (Eq.trans\n                                  (congr_fun\n                                    (monoid_hom.coe_comp (monoid_hom.comp F inl)\n                                      (mul_equiv.to_monoid_hom (coe_fn φ _x)))\n                                    x)\n                                  ((fun (f f_1 : N → H) (e_1 : f = f_1) (g g_1 : N → N) (e_2 : g = g_1) (ᾰ ᾰ_1 : N)\n                                      (e_3 : ᾰ = ᾰ_1) => congr (congr (congr_arg function.comp e_1) e_2) e_3)\n                                    (⇑(monoid_hom.comp F inl)) (⇑F ∘ ⇑inl) (monoid_hom.coe_comp F inl)\n                                    (⇑(mul_equiv.to_monoid_hom (coe_fn φ _x))) (⇑(coe_fn φ _x))\n                                    (mul_equiv.coe_to_monoid_hom (coe_fn φ _x)) x x (Eq.refl x)))\n                                (function.comp_app (⇑F ∘ ⇑inl) (⇑(coe_fn φ _x)) x))\n                              (function.comp_app (⇑F) (⇑inl) (coe_fn (coe_fn φ _x) x)))\n                            ((fun (x x_1 : semidirect_product N G φ →* H) (e_1 : x = x_1)\n                                (ᾰ ᾰ_1 : semidirect_product N G φ) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg coe_fn e_1) e_2)\n                              F F (Eq.refl F) (coe_fn inl (coe_fn (coe_fn φ _x) x))\n                              (coe_fn inr _x * coe_fn inl x * (coe_fn inr _x⁻¹))\n                              (Eq.trans (inl_aut _x x)\n                                ((fun (ᾰ ᾰ_1 : semidirect_product N G φ) (e_2 : ᾰ = ᾰ_1)\n                                    (ᾰ_2 ᾰ_3 : semidirect_product N G φ) (e_3 : ᾰ_2 = ᾰ_3) =>\n                                    congr (congr_arg Mul.mul e_2) e_3)\n                                  (coe_fn inr _x * coe_fn inl x) (coe_fn inr _x * coe_fn inl x)\n                                  (Eq.refl (coe_fn inr _x * coe_fn inl x)) (coe_fn inr (_x⁻¹)) (coe_fn inr _x⁻¹)\n                                  (monoid_hom.map_inv inr _x)))))\n                          (monoid_hom.map_mul_inv F (coe_fn inr _x * coe_fn inl x) (coe_fn inr _x)))\n                        ((fun (ᾰ ᾰ_1 : H) (e_2 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : H) (e_3 : ᾰ_2 = ᾰ_3) =>\n                            congr (congr_arg Mul.mul e_2) e_3)\n                          (coe_fn F (coe_fn inr _x * coe_fn inl x)) (coe_fn F (coe_fn inr _x) * coe_fn F (coe_fn inl x))\n                          (monoid_hom.map_mul F (coe_fn inr _x) (coe_fn inl x)) (coe_fn F (coe_fn inr _x)⁻¹)\n                          (coe_fn F (coe_fn inr _x)⁻¹) (Eq.refl (coe_fn F (coe_fn inr _x)⁻¹))))\n                      (coe_fn\n                        (monoid_hom.comp\n                          (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn (monoid_hom.comp F inr) _x)))\n                          (monoid_hom.comp F inl))\n                        x)\n                      (coe_fn F (coe_fn inr _x) * coe_fn F (coe_fn inl x) * (coe_fn F (coe_fn inr _x)⁻¹))\n                      (Eq.trans\n                        (Eq.trans\n                          (Eq.trans\n                            (Eq.trans\n                              (Eq.trans\n                                ((fun (x x_1 : N →* H) (e_1 : x = x_1) (ᾰ ᾰ_1 : N) (e_2 : ᾰ = ᾰ_1) =>\n                                    congr (congr_arg coe_fn e_1) e_2)\n                                  (monoid_hom.comp\n                                    (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn (monoid_hom.comp F inr) _x)))\n                                    (monoid_hom.comp F inl))\n                                  (monoid_hom.comp\n                                    (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x))))\n                                    (monoid_hom.comp F inl))\n                                  ((fun (hnp hnp_1 : H →* H) (e_1 : hnp = hnp_1) (hmn hmn_1 : N →* H)\n                                      (e_2 : hmn = hmn_1) => congr (congr_arg monoid_hom.comp e_1) e_2)\n                                    (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn (monoid_hom.comp F inr) _x)))\n                                    (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x))))\n                                    ((fun (h h_1 : H ≃* H) (e_1 : h = h_1) => congr_arg mul_equiv.to_monoid_hom e_1)\n                                      (coe_fn mul_aut.conj (coe_fn (monoid_hom.comp F inr) _x))\n                                      (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))\n                                      ((fun (x x_1 : H →* mul_aut H) (e_1 : x = x_1) (ᾰ ᾰ_1 : H) (e_2 : ᾰ = ᾰ_1) =>\n                                          congr (congr_arg coe_fn e_1) e_2)\n                                        mul_aut.conj mul_aut.conj (Eq.refl mul_aut.conj)\n                                        (coe_fn (monoid_hom.comp F inr) _x) (coe_fn F (coe_fn inr _x))\n                                        (Eq.trans (congr_fun (monoid_hom.coe_comp F inr) _x)\n                                          (function.comp_app (⇑F) (⇑inr) _x))))\n                                    (monoid_hom.comp F inl) (monoid_hom.comp F inl) (Eq.refl (monoid_hom.comp F inl)))\n                                  x x (Eq.refl x))\n                                (congr_fun\n                                  (monoid_hom.coe_comp\n                                    (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x))))\n                                    (monoid_hom.comp F inl))\n                                  x))\n                              ((fun (f f_1 : H → H) (e_1 : f = f_1) (g g_1 : N → H) (e_2 : g = g_1) (ᾰ ᾰ_1 : N)\n                                  (e_3 : ᾰ = ᾰ_1) => congr (congr (congr_arg function.comp e_1) e_2) e_3)\n                                (⇑(mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))))\n                                (⇑(coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x))))\n                                (mul_equiv.coe_to_monoid_hom (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x))))\n                                (⇑(monoid_hom.comp F inl)) (⇑F ∘ ⇑inl) (monoid_hom.coe_comp F inl) x x (Eq.refl x)))\n                            (function.comp_app (⇑(coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))) (⇑F ∘ ⇑inl) x))\n                          ((fun (x x_1 : H ≃* H) (e_1 : x = x_1) (ᾰ ᾰ_1 : H) (e_2 : ᾰ = ᾰ_1) =>\n                              congr (congr_arg coe_fn e_1) e_2)\n                            (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))\n                            (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))\n                            (Eq.refl (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))) (function.comp (⇑F) (⇑inl) x)\n                            (coe_fn F (coe_fn inl x)) (function.comp_app (⇑F) (⇑inl) x)))\n                        (mul_aut.conj_apply (coe_fn F (coe_fn inr _x)) (coe_fn F (coe_fn inl x)))))\n                    (propext (mul_left_inj (coe_fn F (coe_fn inr _x)⁻¹))))\n                  (propext (mul_left_inj (coe_fn F (coe_fn inl x)))))\n                (propext (eq_self_iff_true (coe_fn F (coe_fn inr _x))))))\n            trivial := sorry\n\n/-- Two maps out of the semidirect product are equal if they're equal after composition\n  with both `inl` and `inr` -/\ntheorem hom_ext {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {φ : G →* mul_aut N} {f : semidirect_product N G φ →* H} {g : semidirect_product N G φ →* H} (hl : monoid_hom.comp f inl = monoid_hom.comp g inl) (hr : monoid_hom.comp f inr = monoid_hom.comp g inr) : f = g := sorry\n\n/-- Define a map from `N ⋊[φ] G` to `N₁ ⋊[φ₁] G₁` given maps `N →* N₁` and `G →* G₁` that\n  satisfy a commutativity condition `∀ n g, f₁ (φ g n) = φ₁ (f₂ g) (f₁ n)`.  -/\ndef map {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) : semidirect_product N G φ →* semidirect_product N₁ G₁ φ₁ :=\n  monoid_hom.mk (fun (x : semidirect_product N G φ) => mk (coe_fn f₁ (left x)) (coe_fn f₂ (right x))) sorry sorry\n\n@[simp] theorem map_left {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) (g : semidirect_product N G φ) : left (coe_fn (map f₁ f₂ h) g) = coe_fn f₁ (left g) :=\n  rfl\n\n@[simp] theorem map_right {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) (g : semidirect_product N G φ) : right (coe_fn (map f₁ f₂ h) g) = coe_fn f₂ (right g) :=\n  rfl\n\n@[simp] theorem right_hom_comp_map {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) : monoid_hom.comp right_hom (map f₁ f₂ h) = monoid_hom.comp f₂ right_hom :=\n  rfl\n\n@[simp] theorem map_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) (n : N) : coe_fn (map f₁ f₂ h) (coe_fn inl n) = coe_fn inl (coe_fn f₁ n) := sorry\n\n@[simp] theorem map_comp_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) : monoid_hom.comp (map f₁ f₂ h) inl = monoid_hom.comp inl f₁ := sorry\n\n@[simp] theorem map_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) (g : G) : coe_fn (map f₁ f₂ h) (coe_fn inr g) = coe_fn inr (coe_fn f₂ g) := sorry\n\n@[simp] theorem map_comp_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {φ : G →* mul_aut N} {N₁ : Type u_4} {G₁ : Type u_5} [group N₁] [group G₁] {φ₁ : G₁ →* mul_aut N₁} (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ (g : G),\n  monoid_hom.comp f₁ (mul_equiv.to_monoid_hom (coe_fn φ g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn φ₁ (coe_fn f₂ g))) f₁) : monoid_hom.comp (map f₁ f₂ h) inr = monoid_hom.comp inr f₂ := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/group_theory/semidirect_product.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.49019262480875836}}
{"text": "/-\nCopyright (c) 2022 Arthur Paulino. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Arthur Paulino\n-/\n\nimport Mathlib.Tactic.Use\nimport Mathlib.Tactic.Basic\n\nexample : ∃ x : Nat, x = x := by use 42\n\nexample : ∃ x : Nat, ∃ y : Nat, x = y := by use 42, 42\n\nexample : ∃ x : String × String, x.1 = x.2 := by use (\"a\", \"a\")\n\nexample : ∃ x : Nat, x = x := by\n  use ?_\n  exact 42\n  rfl\n\nexample (α : Type) : ∃ S : List α, S = S := by use ∅\n\nexample : ∃ x : Int, x = x := by use 42\n\nexample : ∃ a b c : Int, a + b + c = 6 := by\n  use 1, 2, 3\n  rfl\n\nexample : ∃ p : Int × Int, p.1 = 1 := by use ⟨1, 42⟩\n\nexample : ∃ n : Int, n * 3 = 3 * 2 := by\n  use 2\n  rfl\n\n-- FIXME Failing tests ported from mathlib3\n\n-- example : ∃ (n : Nat) (h : n > 0), n = n :=\n-- by\n--   use 1\n--   -- goal should now be `1 > 0 ∧ 1 = 1`, whereas it would be `∃ (H : 1 > 0), 1 = 1` after existsi 1.\n--   guard_target = 1 > 0 ∧ 1 = 1\n--   exact ⟨Nat.zero_lt_one, rfl⟩\n\n-- example : Σ x y : Int, (Int × Int) × Int :=\n-- by use 1, 2, 3, 4, 5\n\n-- inductive foo\n-- | mk : Nat → Bool × Nat → Nat → foo\n\n-- example : foo :=\n-- by use 100, true, 4, 3\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/test/Use.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.4901926248087583}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Jeremy Avigad, Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.filter.cofinite\nimport Mathlib.PostPort\n\nuniverses u_1 l u v \n\nnamespace Mathlib\n\n/-!\n# Ultrafilters\n\nAn ultrafilter is a minimal (maximal in the set order) proper filter.\nIn this file we define\n\n* `ultrafilter.of`: an ultrafilter that is less than or equal to a given filter;\n* `ultrafilter`: subtype of ultrafilters;\n* `ultrafilter.pure`: `pure x` as an `ultrafiler`;\n* `ultrafilter.map`, `ultrafilter.bind`, `ultrafilter.comap` : operations on ultrafilters;\n* `hyperfilter`: the ultrafilter extending the cofinite filter.\n-/\n\n/-- An ultrafilter is a minimal (maximal in the set order) proper filter. -/\nstructure ultrafilter (α : Type u_1) extends filter α where\n  ne_bot' : filter.ne_bot _to_filter\n  le_of_le : ∀ (g : filter α), filter.ne_bot g → g ≤ _to_filter → _to_filter ≤ g\n\nnamespace ultrafilter\n\n\nprotected instance filter.has_coe_t {α : Type u} : has_coe_t (ultrafilter α) (filter α) :=\n  has_coe_t.mk ultrafilter.to_filter\n\nprotected instance has_mem {α : Type u} : has_mem (set α) (ultrafilter α) :=\n  has_mem.mk fun (s : set α) (f : ultrafilter α) => s ∈ ↑f\n\ntheorem unique {α : Type u} (f : ultrafilter α) {g : filter α} (h : g ≤ ↑f)\n    (hne :\n      autoParam (filter.ne_bot g)\n        (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.tactic.apply_instance\")\n          (Lean.Name.mkStr\n            (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"tactic\")\n            \"apply_instance\")\n          [])) :\n    g = ↑f :=\n  le_antisymm h (ultrafilter.le_of_le f g hne h)\n\nprotected instance ne_bot {α : Type u} (f : ultrafilter α) : filter.ne_bot ↑f :=\n  ultrafilter.ne_bot' f\n\n@[simp] theorem mem_coe {α : Type u} {f : ultrafilter α} {s : set α} : s ∈ ↑f ↔ s ∈ f := iff.rfl\n\ntheorem coe_injective {α : Type u} : function.injective coe := sorry\n\n@[simp] theorem coe_le_coe {α : Type u} {f : ultrafilter α} {g : ultrafilter α} : ↑f ≤ ↑g ↔ f = g :=\n  { mp := fun (h : ↑f ≤ ↑g) => coe_injective (unique g h), mpr := fun (h : f = g) => h ▸ le_rfl }\n\n@[simp] theorem coe_inj {α : Type u} {f : ultrafilter α} {g : ultrafilter α} : ↑f = ↑g ↔ f = g :=\n  function.injective.eq_iff coe_injective\n\ntheorem ext {α : Type u} {f : ultrafilter α} {g : ultrafilter α}\n    (h : ∀ (s : set α), s ∈ f ↔ s ∈ g) : f = g :=\n  coe_injective (filter.ext h)\n\ntheorem le_of_inf_ne_bot {α : Type u} (f : ultrafilter α) {g : filter α}\n    (hg : filter.ne_bot (↑f ⊓ g)) : ↑f ≤ g :=\n  le_of_inf_eq (unique f inf_le_left)\n\ntheorem le_of_inf_ne_bot' {α : Type u} (f : ultrafilter α) {g : filter α}\n    (hg : filter.ne_bot (g ⊓ ↑f)) : ↑f ≤ g :=\n  le_of_inf_ne_bot f (eq.mpr (id (Eq._oldrec (Eq.refl (filter.ne_bot (↑f ⊓ g))) inf_comm)) hg)\n\n@[simp] theorem compl_not_mem_iff {α : Type u} {f : ultrafilter α} {s : set α} : ¬sᶜ ∈ f ↔ s ∈ f :=\n  sorry\n\n@[simp] theorem frequently_iff_eventually {α : Type u} {f : ultrafilter α} {p : α → Prop} :\n    filter.frequently (fun (x : α) => p x) ↑f ↔ filter.eventually (fun (x : α) => p x) ↑f :=\n  compl_not_mem_iff\n\ntheorem Mathlib.filter.frequently.eventually {α : Type u} {f : ultrafilter α} {p : α → Prop} :\n    filter.frequently (fun (x : α) => p x) ↑f → filter.eventually (fun (x : α) => p x) ↑f :=\n  iff.mp frequently_iff_eventually\n\ntheorem compl_mem_iff_not_mem {α : Type u} {f : ultrafilter α} {s : set α} : sᶜ ∈ f ↔ ¬s ∈ f :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (sᶜ ∈ f ↔ ¬s ∈ f)) (Eq.symm (propext compl_not_mem_iff))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (¬sᶜᶜ ∈ f ↔ ¬s ∈ f)) (compl_compl s))) (iff.refl (¬s ∈ f)))\n\n/-- If `sᶜ ∉ f ↔ s ∈ f`, then `f` is an ultrafilter. The other implication is given by\n`ultrafilter.compl_not_mem_iff`.  -/\ndef of_compl_not_mem_iff {α : Type u} (f : filter α) (h : ∀ (s : set α), ¬sᶜ ∈ f ↔ s ∈ f) :\n    ultrafilter α :=\n  mk f sorry sorry\n\ntheorem nonempty_of_mem {α : Type u} {f : ultrafilter α} {s : set α} (hs : s ∈ f) :\n    set.nonempty s :=\n  filter.nonempty_of_mem_sets hs\n\ntheorem ne_empty_of_mem {α : Type u} {f : ultrafilter α} {s : set α} (hs : s ∈ f) : s ≠ ∅ :=\n  set.nonempty.ne_empty (nonempty_of_mem hs)\n\n@[simp] theorem empty_not_mem {α : Type u} {f : ultrafilter α} : ¬∅ ∈ f := filter.empty_nmem_sets ↑f\n\ntheorem mem_or_compl_mem {α : Type u} (f : ultrafilter α) (s : set α) : s ∈ f ∨ sᶜ ∈ f :=\n  iff.mpr or_iff_not_imp_left (iff.mpr compl_mem_iff_not_mem)\n\nprotected theorem em {α : Type u} (f : ultrafilter α) (p : α → Prop) :\n    filter.eventually (fun (x : α) => p x) ↑f ∨ filter.eventually (fun (x : α) => ¬p x) ↑f :=\n  mem_or_compl_mem f (set_of fun (x : α) => p x)\n\ntheorem eventually_or {α : Type u} {f : ultrafilter α} {p : α → Prop} {q : α → Prop} :\n    filter.eventually (fun (x : α) => p x ∨ q x) ↑f ↔\n        filter.eventually (fun (x : α) => p x) ↑f ∨ filter.eventually (fun (x : α) => q x) ↑f :=\n  sorry\n\ntheorem union_mem_iff {α : Type u} {f : ultrafilter α} {s : set α} {t : set α} :\n    s ∪ t ∈ f ↔ s ∈ f ∨ t ∈ f :=\n  eventually_or\n\ntheorem eventually_not {α : Type u} {f : ultrafilter α} {p : α → Prop} :\n    filter.eventually (fun (x : α) => ¬p x) ↑f ↔ ¬filter.eventually (fun (x : α) => p x) ↑f :=\n  compl_mem_iff_not_mem\n\ntheorem eventually_imp {α : Type u} {f : ultrafilter α} {p : α → Prop} {q : α → Prop} :\n    filter.eventually (fun (x : α) => p x → q x) ↑f ↔\n        filter.eventually (fun (x : α) => p x) ↑f → filter.eventually (fun (x : α) => q x) ↑f :=\n  sorry\n\ntheorem finite_sUnion_mem_iff {α : Type u} {f : ultrafilter α} {s : set (set α)}\n    (hs : set.finite s) : ⋃₀s ∈ f ↔ ∃ (t : set α), ∃ (H : t ∈ s), t ∈ f :=\n  sorry\n\ntheorem finite_bUnion_mem_iff {α : Type u} {β : Type v} {f : ultrafilter α} {is : set β}\n    {s : β → set α} (his : set.finite is) :\n    (set.Union fun (i : β) => set.Union fun (H : i ∈ is) => s i) ∈ f ↔\n        ∃ (i : β), ∃ (H : i ∈ is), s i ∈ f :=\n  sorry\n\n/-- Pushforward for ultrafilters. -/\ndef map {α : Type u} {β : Type v} (m : α → β) (f : ultrafilter α) : ultrafilter β :=\n  of_compl_not_mem_iff (filter.map m ↑f) sorry\n\n@[simp] theorem coe_map {α : Type u} {β : Type v} (m : α → β) (f : ultrafilter α) :\n    ↑(map m f) = filter.map m ↑f :=\n  rfl\n\n@[simp] theorem mem_map {α : Type u} {β : Type v} {m : α → β} {f : ultrafilter α} {s : set β} :\n    s ∈ map m f ↔ m ⁻¹' s ∈ f :=\n  iff.rfl\n\n/-- The pullback of an ultrafilter along an injection whose range is large with respect to the given\nultrafilter. -/\ndef comap {α : Type u} {β : Type v} {m : α → β} (u : ultrafilter β) (inj : function.injective m)\n    (large : set.range m ∈ u) : ultrafilter α :=\n  mk (filter.comap m ↑u) sorry sorry\n\n/-- The principal ultrafilter associated to a point `x`. -/\nprotected instance has_pure : Pure ultrafilter :=\n  { pure := fun (α : Type u_1) (a : α) => of_compl_not_mem_iff (pure a) sorry }\n\n@[simp] theorem mem_pure_sets {α : Type u} {a : α} {s : set α} : s ∈ pure a ↔ a ∈ s := iff.rfl\n\nprotected instance inhabited {α : Type u} [Inhabited α] : Inhabited (ultrafilter α) :=\n  { default := pure Inhabited.default }\n\n/-- Monadic bind for ultrafilters, coming from the one on filters\ndefined in terms of map and join.-/\ndef bind {α : Type u} {β : Type v} (f : ultrafilter α) (m : α → ultrafilter β) : ultrafilter β :=\n  of_compl_not_mem_iff (filter.bind ↑f fun (x : α) => ↑(m x)) sorry\n\nprotected instance ultrafilter.has_bind : Bind ultrafilter := { bind := bind }\n\nprotected instance ultrafilter.functor : Functor ultrafilter :=\n  { map := map, mapConst := fun (α β : Type u_1) => map ∘ function.const β }\n\nprotected instance ultrafilter.monad : Monad ultrafilter := sorry\n\nprotected instance ultrafilter.is_lawful_monad : is_lawful_monad ultrafilter :=\n  is_lawful_monad.mk\n    (fun (α β : Type u_1) (a : α) (f : α → ultrafilter β) =>\n      coe_injective (filter.pure_bind a (coe ∘ f)))\n    fun (α β γ : Type u_1) (f : ultrafilter α) (m₁ : α → ultrafilter β) (m₂ : β → ultrafilter γ) =>\n      coe_injective (filter.filter_eq rfl)\n\n/-- The ultrafilter lemma: Any proper filter is contained in an ultrafilter. -/\ntheorem exists_le {α : Type u} (f : filter α) [h : filter.ne_bot f] :\n    ∃ (u : ultrafilter α), ↑u ≤ f :=\n  sorry\n\ntheorem Mathlib.filter.exists_ultrafilter_le {α : Type u} (f : filter α) [h : filter.ne_bot f] :\n    ∃ (u : ultrafilter α), ↑u ≤ f :=\n  exists_le\n\n/-- Construct an ultrafilter extending a given filter.\n  The ultrafilter lemma is the assertion that such a filter exists;\n  we use the axiom of choice to pick one. -/\ndef of {α : Type u} (f : filter α) [filter.ne_bot f] : ultrafilter α := classical.some (exists_le f)\n\ntheorem of_le {α : Type u} (f : filter α) [filter.ne_bot f] : ↑(of f) ≤ f :=\n  classical.some_spec (exists_le f)\n\ntheorem of_coe {α : Type u} (f : ultrafilter α) : of ↑f = f := iff.mp coe_inj (unique f (of_le ↑f))\n\ntheorem exists_ultrafilter_of_finite_inter_nonempty {α : Type u} (S : set (set α))\n    (cond : ∀ (T : finset (set α)), ↑T ⊆ S → set.nonempty (⋂₀↑T)) :\n    ∃ (F : ultrafilter α), S ⊆ filter.sets (ultrafilter.to_filter F) :=\n  sorry\n\nend ultrafilter\n\n\nnamespace filter\n\n\ntheorem mem_iff_ultrafilter {α : Type u} {s : set α} {f : filter α} :\n    s ∈ f ↔ ∀ (g : ultrafilter α), ↑g ≤ f → s ∈ g :=\n  sorry\n\ntheorem le_iff_ultrafilter {α : Type u} {f₁ : filter α} {f₂ : filter α} :\n    f₁ ≤ f₂ ↔ ∀ (g : ultrafilter α), ↑g ≤ f₁ → ↑g ≤ f₂ :=\n  sorry\n\n/-- A filter equals the intersection of all the ultrafilters which contain it. -/\ntheorem supr_ultrafilter_le_eq {α : Type u} (f : filter α) :\n    (supr fun (g : ultrafilter α) => supr fun (hg : ↑g ≤ f) => ↑g) = f :=\n  sorry\n\n/-- The `tendsto` relation can be checked on ultrafilters. -/\ntheorem tendsto_iff_ultrafilter {α : Type u} {β : Type v} (f : α → β) (l₁ : filter α)\n    (l₂ : filter β) : tendsto f l₁ l₂ ↔ ∀ (g : ultrafilter α), ↑g ≤ l₁ → tendsto f (↑g) l₂ :=\n  sorry\n\ntheorem exists_ultrafilter_iff {α : Type u} {f : filter α} :\n    (∃ (u : ultrafilter α), ↑u ≤ f) ↔ ne_bot f :=\n  sorry\n\ntheorem forall_ne_bot_le_iff {α : Type u} {g : filter α} {p : filter α → Prop} (hp : monotone p) :\n    (∀ (f : filter α), ne_bot f → f ≤ g → p f) ↔ ∀ (f : ultrafilter α), ↑f ≤ g → p ↑f :=\n  sorry\n\n/-- The ultrafilter extending the cofinite filter. -/\ndef hyperfilter (α : Type u) [infinite α] : ultrafilter α := ultrafilter.of cofinite\n\ntheorem hyperfilter_le_cofinite {α : Type u} [infinite α] : ↑(hyperfilter α) ≤ cofinite :=\n  ultrafilter.of_le cofinite\n\n@[simp] theorem bot_ne_hyperfilter {α : Type u} [infinite α] : ⊥ ≠ ↑(hyperfilter α) :=\n  ne.symm ((fun (this : ne_bot ↑(hyperfilter α)) => this) (ultrafilter.ne_bot (hyperfilter α)))\n\ntheorem nmem_hyperfilter_of_finite {α : Type u} [infinite α] {s : set α} (hf : set.finite s) :\n    ¬s ∈ hyperfilter α :=\n  fun (hy : s ∈ hyperfilter α) =>\n    compl_not_mem_sets hy (hyperfilter_le_cofinite (set.finite.compl_mem_cofinite hf))\n\ntheorem Mathlib.set.finite.nmem_hyperfilter {α : Type u} [infinite α] {s : set α}\n    (hf : set.finite s) : ¬s ∈ hyperfilter α :=\n  nmem_hyperfilter_of_finite\n\ntheorem compl_mem_hyperfilter_of_finite {α : Type u} [infinite α] {s : set α} (hf : set.finite s) :\n    sᶜ ∈ hyperfilter α :=\n  iff.mpr ultrafilter.compl_mem_iff_not_mem (set.finite.nmem_hyperfilter hf)\n\ntheorem Mathlib.set.finite.compl_mem_hyperfilter {α : Type u} [infinite α] {s : set α}\n    (hf : set.finite s) : sᶜ ∈ hyperfilter α :=\n  compl_mem_hyperfilter_of_finite\n\ntheorem mem_hyperfilter_of_finite_compl {α : Type u} [infinite α] {s : set α}\n    (hf : set.finite (sᶜ)) : s ∈ hyperfilter α :=\n  compl_compl s ▸ set.finite.compl_mem_hyperfilter hf\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/order/filter/ultrafilter_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.49019261199187986}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.abelian.exact\nimport Mathlib.category_theory.over\nimport Mathlib.PostPort\n\nuniverses v u \n\nnamespace Mathlib\n\n/-!\n# Pseudoelements in abelian categories\n\nA *pseudoelement* of an object `X` in an abelian category `C` is an equivalence class of arrows\nending in `X`, where two arrows are considered equivalent if we can find two epimorphisms with a\ncommon domain making a commutative square with the two arrows. While the construction shows that\npseudoelements are actually subobjects of `X` rather than \"elements\", it is possible to chase these\npseudoelements through commutative diagrams in an abelian category to prove exactness properties.\nThis is done using some \"diagram-chasing metatheorems\" proved in this file. In many cases, a proof\nin the category of abelian groups can more or less directly be converted into a proof using\npseudoelements.\n\nA classic application of pseudoelements are diagram lemmas like the four lemma or the snake lemma.\n\nPseudoelements are in some ways weaker than actual elements in a concrete category. The most\nimportant limitation is that there is no extensionality principle: If `f g : X ⟶ Y`, then\n`∀ x ∈ X, f x = g x` does not necessarily imply that `f = g` (however, if `f = 0` or `g = 0`,\nit does). A corollary of this is that we can not define arrows in abelian categories by dictating\ntheir action on pseudoelements. Thus, a usual style of proofs in abelian categories is this:\nFirst, we construct some morphism using universal properties, and then we use diagram chasing\nof pseudoelements to verify that is has some desirable property such as exactness.\n\nIt should be noted that the Freyd-Mitchell embedding theorem gives a vastly stronger notion of\npseudoelement (in particular one that gives extensionality). However, this theorem is quite\ndifficult to prove and probably out of reach for a formal proof for the time being.\n\n## Main results\n\nWe define the type of pseudoelements of an object and, in particular, the zero pseudoelement.\n\nWe prove that every morphism maps the zero pseudoelement to the zero pseudoelement (`apply_zero`)\nand that a zero morphism maps every pseudoelement to the zero pseudoelement (`zero_apply`)\n\nHere are the metatheorems we provide:\n* A morphism `f` is zero if and only if it is the zero function on pseudoelements.\n* A morphism `f` is an epimorphism if and only if it is surjective on pseudoelements.\n* A morphism `f` is a monomorphism if and only if it is injective on pseudoelements\n  if and only if `∀ a, f a = 0 → f = 0`.\n* A sequence `f, g` of morphisms is exact if and only if\n  `∀ a, g (f a) = 0` and `∀ b, g b = 0 → ∃ a, f a = b`.\n* If `f` is a morphism and `a, a'` are such that `f a = f a'`, then there is some\n  pseudoelement `a''` such that `f a'' = 0` and for every `g` we have\n  `g a' = 0 → g a = g a''`. We can think of `a''` as `a - a'`, but don't get too carried away\n  by that: pseudoelements of an object do not form an abelian group.\n\n## Notations\n\nWe introduce coercions from an object of an abelian category to the set of its pseudoelements\nand from a morphism to the function it induces on pseudoelements.\n\nThese coercions must be explicitly enabled via local instances:\n`local attribute [instance] object_to_sort hom_to_fun`\n\n## Implementation notes\n\nIt appears that sometimes the coercion from morphisms to functions does not work, i.e.,\nwriting `g a` raises a \"function expected\" error. This error can be fixed by writing\n`(g : X ⟶ Y) a`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n-/\n\nnamespace category_theory.abelian\n\n\n/-- This is just composition of morphisms in `C`. Another way to express this would be\n    `(over.map f).obj a`, but our definition has nicer definitional properties. -/\ndef app {C : Type u} [category C] {P : C} {Q : C} (f : P ⟶ Q) (a : over P) : over Q :=\n  ↑(comma.hom a ≫ f)\n\n@[simp] theorem app_hom {C : Type u} [category C] {P : C} {Q : C} (f : P ⟶ Q) (a : over P) :\n    comma.hom (app f a) = comma.hom a ≫ f :=\n  rfl\n\n/-- Two arrows `f : X ⟶ P` and `g : Y ⟶ P are called pseudo-equal if there is some object\n    `R` and epimorphisms `p : R ⟶ X` and `q : R ⟶ Y` such that `p ≫ f = q ≫ g`. -/\ndef pseudo_equal {C : Type u} [category C] (P : C) (f : over P) (g : over P) :=\n  ∃ (R : C),\n    ∃ (p : R ⟶ comma.left f),\n      ∃ (q : R ⟶ comma.left g), Exists (Exists (p ≫ comma.hom f = q ≫ comma.hom g))\n\ntheorem pseudo_equal_refl {C : Type u} [category C] {P : C} : reflexive (pseudo_equal P) := sorry\n\ntheorem pseudo_equal_symm {C : Type u} [category C] {P : C} : symmetric (pseudo_equal P) := sorry\n\n/-- Pseudoequality is transitive: Just take the pullback. The pullback morphisms will\n    be epimorphisms since in an abelian category, pullbacks of epimorphisms are epimorphisms. -/\ntheorem pseudo_equal_trans {C : Type u} [category C] [abelian C] {P : C} :\n    transitive (pseudo_equal P) :=\n  sorry\n\n/-- The arrows with codomain `P` equipped with the equivalence relation of being pseudo-equal. -/\ndef pseudoelement.setoid {C : Type u} [category C] [abelian C] (P : C) : setoid (over P) :=\n  setoid.mk (pseudo_equal P) sorry\n\n/-- A `pseudoelement` of `P` is just an equivalence class of arrows ending in `P` by being\n    pseudo-equal. -/\ndef pseudoelement {C : Type u} [category C] [abelian C] (P : C) := quotient sorry\n\nnamespace pseudoelement\n\n\n/-- A coercion from an object of an abelian category to its pseudoelements. -/\ndef object_to_sort {C : Type u} [category C] [abelian C] : has_coe_to_sort C :=\n  has_coe_to_sort.mk (Type (max u v)) fun (P : C) => pseudoelement P\n\n/-- A coercion from an arrow with codomain `P` to its associated pseudoelement. -/\ndef over_to_sort {C : Type u} [category C] [abelian C] {P : C} :\n    has_coe (over P) (pseudoelement P) :=\n  has_coe.mk (Quot.mk (pseudo_equal P))\n\ntheorem over_coe_def {C : Type u} [category C] [abelian C] {P : C} {Q : C} (a : Q ⟶ P) :\n    ↑a = quotient.mk ↑a :=\n  rfl\n\n/-- If two elements are pseudo-equal, then their composition with a morphism is, too. -/\ntheorem pseudo_apply_aux {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q)\n    (a : over P) (b : over P) : a ≈ b → app f a ≈ app f b :=\n  sorry\n\n/-- A morphism `f` induces a function `pseudo_apply f` on pseudoelements. -/\ndef pseudo_apply {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) : ↥P → ↥Q :=\n  quotient.map (fun (g : over P) => app f g) (pseudo_apply_aux f)\n\n/-- A coercion from morphisms to functions on pseudoelements -/\ndef hom_to_fun {C : Type u} [category C] [abelian C] {P : C} {Q : C} : has_coe_to_fun (P ⟶ Q) :=\n  has_coe_to_fun.mk (fun (x : P ⟶ Q) => ↥P → ↥Q) pseudo_apply\n\ntheorem pseudo_apply_mk {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q)\n    (a : over P) : coe_fn f (quotient.mk a) = quotient.mk ↑(comma.hom a ≫ f) :=\n  rfl\n\n/-- Applying a pseudoelement to a composition of morphisms is the same as composing\n    with each morphism. Sadly, this is not a definitional equality, but at least it is\n    true. -/\ntheorem comp_apply {C : Type u} [category C] [abelian C] {P : C} {Q : C} {R : C} (f : P ⟶ Q)\n    (g : Q ⟶ R) (a : ↥P) : coe_fn (f ≫ g) a = coe_fn g (coe_fn f a) :=\n  sorry\n\n/-- Composition of functions on pseudoelements is composition of morphisms. -/\ntheorem comp_comp {C : Type u} [category C] [abelian C] {P : C} {Q : C} {R : C} (f : P ⟶ Q)\n    (g : Q ⟶ R) : ⇑g ∘ ⇑f = ⇑(f ≫ g) :=\n  funext fun (x : ↥P) => Eq.symm (comp_apply f g x)\n\n/-!\nIn this section we prove that for every `P` there is an equivalence class that contains\nprecisely all the zero morphisms ending in `P` and use this to define *the* zero\npseudoelement.\n-/\n\n/-- The arrows pseudo-equal to a zero morphism are precisely the zero morphisms -/\ntheorem pseudo_zero_aux {C : Type u} [category C] [abelian C] {P : C} (Q : C) (f : over P) :\n    f ≈ ↑0 ↔ comma.hom f = 0 :=\n  sorry\n\ntheorem zero_eq_zero' {C : Type u} [category C] [abelian C] {P : C} {Q : C} {R : C} :\n    quotient.mk ↑0 = quotient.mk ↑0 :=\n  quotient.sound (iff.mpr (pseudo_zero_aux R ↑0) rfl)\n\n/-- The zero pseudoelement is the class of a zero morphism -/\ndef pseudo_zero {C : Type u} [category C] [abelian C] {P : C} : ↥P := quotient.mk ↑0\n\nprotected instance has_zero {C : Type u} [category C] [abelian C] {P : C} : HasZero ↥P :=\n  { zero := pseudo_zero }\n\nprotected instance inhabited {C : Type u} [category C] [abelian C] {P : C} :\n    Inhabited (pseudoelement P) :=\n  { default := 0 }\n\ntheorem pseudo_zero_def {C : Type u} [category C] [abelian C] {P : C} : 0 = quotient.mk ↑0 := rfl\n\n@[simp] theorem zero_eq_zero {C : Type u} [category C] [abelian C] {P : C} {Q : C} :\n    quotient.mk ↑0 = 0 :=\n  zero_eq_zero'\n\n/-- The pseudoelement induced by an arrow is zero precisely when that arrow is zero -/\ntheorem pseudo_zero_iff {C : Type u} [category C] [abelian C] {P : C} (a : over P) :\n    ↑a = 0 ↔ comma.hom a = 0 :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (↑a = 0 ↔ comma.hom a = 0)) (Eq.symm (propext (pseudo_zero_aux P a)))))\n    quotient.eq\n\n/-- Morphisms map the zero pseudoelement to the zero pseudoelement -/\n@[simp] theorem apply_zero {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) :\n    coe_fn f 0 = 0 :=\n  sorry\n\n/-- The zero morphism maps every pseudoelement to 0. -/\n@[simp] theorem zero_apply {C : Type u} [category C] [abelian C] {P : C} (Q : C) (a : ↥P) :\n    coe_fn 0 a = 0 :=\n  sorry\n\n/-- An extensionality lemma for being the zero arrow. -/\ntheorem zero_morphism_ext {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) :\n    (∀ (a : ↥P), coe_fn f a = 0) → f = 0 :=\n  fun (h : ∀ (a : ↥P), coe_fn f a = 0) =>\n    eq.mpr (id (Eq._oldrec (Eq.refl (f = 0)) (Eq.symm (category.id_comp f))))\n      (iff.mp (pseudo_zero_iff ↑(𝟙 ≫ f)) (h ↑𝟙))\n\ntheorem zero_morphism_ext' {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) :\n    (∀ (a : ↥P), coe_fn f a = 0) → 0 = f :=\n  Eq.symm ∘ zero_morphism_ext f\n\ntheorem eq_zero_iff {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) :\n    f = 0 ↔ ∀ (a : ↥P), coe_fn f a = 0 :=\n  sorry\n\n/-- A monomorphism is injective on pseudoelements. -/\ntheorem pseudo_injective_of_mono {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q)\n    [mono f] : function.injective ⇑f :=\n  sorry\n\n/-- A morphism that is injective on pseudoelements only maps the zero element to zero. -/\ntheorem zero_of_map_zero {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) :\n    function.injective ⇑f → ∀ (a : ↥P), coe_fn f a = 0 → a = 0 :=\n  fun (h : function.injective ⇑f) (a : ↥P) (ha : coe_fn f a = 0) =>\n    h (eq.mp (Eq._oldrec (Eq.refl (coe_fn f a = 0)) (Eq.symm (apply_zero f))) ha)\n\n/-- A morphism that only maps the zero pseudoelement to zero is a monomorphism. -/\ntheorem mono_of_zero_of_map_zero {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) :\n    (∀ (a : ↥P), coe_fn f a = 0 → a = 0) → mono f :=\n  sorry\n\n/-- An epimorphism is surjective on pseudoelements. -/\ntheorem pseudo_surjective_of_epi {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q)\n    [epi f] : function.surjective ⇑f :=\n  sorry\n\n/-- A morphism that is surjective on pseudoelements is an epimorphism. -/\ntheorem epi_of_pseudo_surjective {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) :\n    function.surjective ⇑f → epi f :=\n  sorry\n\n/-- Two morphisms in an exact sequence are exact on pseudoelements. -/\ntheorem pseudo_exact_of_exact {C : Type u} [category C] [abelian C] {P : C} {Q : C} {R : C}\n    {f : P ⟶ Q} {g : Q ⟶ R} [exact f g] :\n    (∀ (a : ↥P), coe_fn g (coe_fn f a) = 0) ∧\n        ∀ (b : ↥Q), coe_fn g b = 0 → ∃ (a : ↥P), coe_fn f a = b :=\n  sorry\n\ntheorem apply_eq_zero_of_comp_eq_zero {C : Type u} [category C] [abelian C] {P : C} {Q : C} {R : C}\n    (f : Q ⟶ R) (a : P ⟶ Q) : a ≫ f = 0 → coe_fn f ↑a = 0 :=\n  sorry\n\n/-- If two morphisms are exact on pseudoelements, they are exact. -/\ntheorem exact_of_pseudo_exact {C : Type u} [category C] [abelian C] {P : C} {Q : C} {R : C}\n    (f : P ⟶ Q) (g : Q ⟶ R) :\n    ((∀ (a : ↥P), coe_fn g (coe_fn f a) = 0) ∧\n          ∀ (b : ↥Q), coe_fn g b = 0 → ∃ (a : ↥P), coe_fn f a = b) →\n        exact f g :=\n  sorry\n\n/-- If two pseudoelements `x` and `y` have the same image under some morphism `f`, then we can form\n    their \"difference\" `z`. This pseudoelement has the properties that `f z = 0` and for all\n    morphisms `g`, if `g y = 0` then `g z = g x`. -/\ntheorem sub_of_eq_image {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P ⟶ Q) (x : ↥P)\n    (y : ↥P) :\n    coe_fn f x = coe_fn f y →\n        ∃ (z : ↥P),\n          coe_fn f z = 0 ∧ ∀ (R : C) (g : P ⟶ R), coe_fn g y = 0 → coe_fn g z = coe_fn g x :=\n  sorry\n\n/-- If `f : P ⟶ R` and `g : Q ⟶ R` are morphisms and `p : P` and `q : Q` are pseudoelements such\n    that `f p = g q`, then there is some `s : pullback f g` such that `fst s = p` and `snd s = q`.\n\n    Remark: Borceux claims that `s` is unique. I was unable to transform his proof sketch into\n    a pen-and-paper proof of this fact, so naturally I was not able to formalize the proof. -/\ntheorem pseudo_pullback {C : Type u} [category C] [abelian C] [limits.has_pullbacks C] {P : C}\n    {Q : C} {R : C} {f : P ⟶ R} {g : Q ⟶ R} {p : ↥P} {q : ↥Q} :\n    coe_fn f p = coe_fn g q →\n        ∃ (s : ↥(limits.pullback f g)),\n          coe_fn limits.pullback.fst s = p ∧ coe_fn limits.pullback.snd s = q :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/abelian/pseudoelements_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.49019261199187986}}
{"text": "/-\nCopyright (c) 2019 Koundinya Vajjha. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Koundinya Vajjha\n\nA meta def called `#depends` which gives the names of all the theorems (the statement of) a given definition/theorem depends on.\n-/\n\nimport data.pfun\n\nopen tactic expr interactive nat native name list lean.parser environment\n\n/--Takes an expr and spits out a list of all the names in that expr -/\nmeta def list_names (e : expr): list name :=\ne.fold [] (λ e _ es, if is_constant e then insert e.const_name es else es)\n\n/-- Takes an environment and naively lists all declarations in it.-/\nmeta def list_all_decls (env : environment) : list name :=\nenv.fold [] $ (λ d ns, d.to_name :: ns)\n\n/-- Takes an environment and lists all declarations in it, much faster. -/\nmeta def list_all_decls' (env : environment) : rb_set name :=\nenv.fold (mk_rb_set) $ (λ d ns, ns.insert d.to_name)\n\n/-- Traces all declarations with prefix `namesp` in the current environment. -/\n/-TODO : optimize using rb_set filters and maps(?)-/\nmeta def trace_all_decls (namesp : name) : tactic unit :=\ndo e ← get_env,\n   let l := list_all_decls' e,\n   let k := l.to_list,\n   let m := list.map (λ h:name, h.get_prefix) k,\n   let f := k.filter (λ h, is_prefix_of namesp h),\n   tactic.trace $ take 150 f,\n   skip\n\n/- TODO : modify this to take structures into account -/\n@[user_command] meta def depends_cmd (meta_info : decl_meta_info) ( _ : parse $ tk \"#depends\")\n : lean.parser unit\n:= do given_name ← ident,\n    resolved ← resolve_constant given_name,\n    d ← get_decl resolved <|> fail (\"declaration \" ++ to_string given_name ++ \" not found\"),\n    tactic.trace $ list_names d.type\n\n/-- Return the direct dependencies of the *type* of a declaration. -/\nmeta def name_dir_deps (n : name) : tactic(list name) :=\ndo env ← get_env,\n    l ← get_decl n,\n    if is_structure env n then\n    do fields ← returnopt $ structure_fields env n,\n        let res := map (λ h, name.append n h) fields,\n        k ← mmap (λ h, do l ← get_decl h, pure $ list_names l.type) res,\n        let clean := list.erase_dup (list.join k),\n        let final := list.filter (λ h, ¬ name.is_prefix_of n h) clean,\n        pure $ final\n    else\n    pure $ list_names l.type\n\n/-- Return the direct dependencies of the *value* of a declaration.-/\nmeta def name_dir_deps_val (n : name) : tactic(list name) :=\ndo env ← get_env,\n    l ← get_decl n,\n    if is_structure env n then\n    do fields ← returnopt $ structure_fields env n,\n        let res := map (λ h, name.append n h) fields,\n        k ← mmap (λ h, do l ← get_decl h, pure $ list_names l.value) res,\n        let clean := list.erase_dup (list.join k),\n        let final := list.filter (λ h, ¬ name.is_prefix_of n h) clean,\n        pure $ final\n    else\n    pure $ list_names l.value\n\n\n/-- Recursively return a joint list of the m-th sub-dependencies of the type of given name.-/\nmeta def name_dir_deps_depth (n : name) : ℕ → tactic(list name)\n| 0 := name_dir_deps n\n| (succ m) :=\n do l ← name_dir_deps_depth m <|> name_dir_deps n,\n    l' ← mmap (λ h, name_dir_deps h) l,\n    let k := list.erase_dup $\n    list.join (l :: l'),\n    -- tactic.trace k.length,\n    pure $ k\n\n/-- Recursively return a joint list of the m-th sub-dependencies of the type of given name.-/\nmeta def name_dir_deps_depth_val (n : name) : ℕ → tactic(list name)\n| 0 := name_dir_deps_val n\n| (succ m) :=\n do l ← name_dir_deps_depth_val m <|> name_dir_deps_val n,\n    l' ← mmap (λ h, name_dir_deps h) l,\n    let k := list.erase_dup $\n    list.join (l :: l'),\n    -- tactic.trace k.length,\n    pure $ k\n\ntheorem foo' : 2+2 = 4 :=\nbegin\n  simp,\nend\n\n\n/- Tests -/\n-- #depends nat.has_one\n-- #depends group.equiv\n-- #depends J4\n-- #depends nat.add._main\n-- #depends mclaughlin.McL\n-- #depends sends_identity_to_1\n\n-- set_option profiler true\n-- run_cmd (name_dir_deps_depth_val `mathieu_group.Aut 10) >>= tactic.trace\n", "meta": {"author": "formalabstracts", "repo": "formalabstracts", "sha": "b0173da1af45421239d44492eeecd54bf65ee0f6", "save_path": "github-repos/lean/formalabstracts-formalabstracts", "path": "github-repos/lean/formalabstracts-formalabstracts/formalabstracts-b0173da1af45421239d44492eeecd54bf65ee0f6/src/tactic/depends.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.4901926079268602}}
{"text": "import GMLInit.Data.Basic\nimport GMLInit.Data.Bool\nimport GMLInit.Data.Fin.Basic\nimport GMLInit.Data.Nat\nimport GMLInit.Logic.ListConnectives\nimport GMLInit.Meta.Basic\n\nnamespace List\n\ninstance {α} : (xs : List α) → Decidable (xs = [])\n| [] => isTrue rfl\n| _::_ => isFalse List.noConfusion\n\ninstance {α} : (xs : List α) → Decidable ([] = xs)\n| [] => isTrue rfl\n| _::_ => isFalse List.noConfusion\n\nprotected def ext'Aux {α} : (as₁ as₂ : List α) → List Prop\n| [], [] => []\n| [], _::_ => [False]\n| _::_, [] => [False]\n| a₁::as₁, a₂::as₂ => (a₁ = a₂) :: List.ext'Aux as₁ as₂\n\nprotected theorem ext' {α} : (as₁ as₂ : List α) → All (List.ext'Aux as₁ as₂) → as₁ = as₂\n| [], [], _ => rfl\n| [], _::_, All.cons h _ => False.elim h\n| _::_₁, [], All.cons h _ => False.elim h\n| _::as₁, _::as₂, All.cons h hs => h ▸ List.ext' as₁ as₂ hs ▸ rfl\n\nprotected theorem ext'Iff {α} (as₁ as₂ : List α) : All (List.ext'Aux as₁ as₂) ↔ as₁ = as₂ := by\n  constr\n  exact List.ext' as₁ as₂\n  intro h\n  cases h\n  induction as₁ with\n  | nil => exact All.nil\n  | cons _ _ H => exact All.cons rfl H\n\nprotected theorem ext'Eq {α} (as₁ as₂ : List α) : All (List.ext'Aux as₁ as₂) = (as₁ = as₂) :=\n  propext (List.ext'Iff as₁ as₂)\n\ninstance (x : α) (xs : List α) : Nat.IsPos (List.length (x :: xs)) := ⟨Nat.zero_lt_succ _⟩\n\nlemma map_pure {α β} (f : α → β) (a : α) : [a].map f = [f a] := rfl\n\nlemma map_comp {α β γ} (f : α → β) (g : β → γ) (as : List α) : as.map (g ∘ f) = (as.map f).map g := by\n  symmetry\n  exact map_map ..\n\n@[simp] lemma pure_bind {α β} (f : α → List β) (a : α) : [a].bind f = f a := by rw [cons_bind, nil_bind, append_nil]\n\nlemma bind_assoc {α β γ} (f : α → List β) (g : β → List γ) (as : List α) : (as.bind f).bind g = as.bind (λ a => (f a).bind g) := by\n  induction as with\n  | nil => rfl\n  | cons a as H => rw [cons_bind, cons_bind, append_bind, H]\n\nlemma all_eq_true_iff_all_true {α} (p : α → Bool) (xs : List α) : xs.all p = true ↔ All (xs.map λ x => p x = true) := by\n  induction xs generalizing p with\n  | nil => rw [all_nil, map_nil]; simp\n  | cons x xs H => rw [all_cons, map_cons, All.cons_eq, ←H, Bool.and_eq_true_iff]\n\nlemma all_eq_false_iff_any_false {α} (p : α → Bool) (xs : List α) : xs.all p = false ↔ Any (xs.map λ x => p x = false) := by\n  induction xs generalizing p with\n  | nil => rw [all_nil, map_nil]; simp\n  | cons x xs H => rw [all_cons, map_cons, Any.cons_eq, ←H, Bool.and_eq_false_iff]\n\nlemma any_eq_true_iff_any_true {α} (p : α → Bool) (xs : List α) : xs.any p = true ↔ Any (xs.map λ x => p x = true) := by\n  induction xs generalizing p with\n  | nil => rw [any_nil, map_nil, Any.nil_eq]; simp\n  | cons x xs H => rw [any_cons, map_cons, Any.cons_eq, ←H, Bool.or_eq_true_iff]\n\nlemma any_eq_false_iff_all_false {α} (p : α → Bool) (xs : List α) : xs.any p = false ↔ All (xs.map λ x => p x = false) := by\n  induction xs generalizing p with\n  | nil => rw [any_nil, map_nil, All.nil_eq]; simp\n  | cons x xs H => rw [any_cons, map_cons, All.cons_eq, ←H, Bool.or_eq_false_iff]\n\n/- take -/\n\ntheorem take_nil {α} (n : Nat) : take n [] = ([] : List α) := by cases n <;> rfl\n\ntheorem take_cons {α} (a : α) (as : List α) (n : Nat) : take (n+1) (a :: as) = a :: take n as := rfl\n\ntheorem take_zero {α} (as : List α) : take 0 as = [] := rfl\n\ntheorem take_all {α} (as : List α) : take as.length as = as := by\n  induction as with\n  | nil => rfl\n  | cons a as ih =>\n    rw [length_cons]\n    rw [take_cons]\n    rw [ih]\n\n/- drop -/\n\ntheorem drop_cons {α} (a : α) (as : List α) (n : Nat) : drop (n+1) (a :: as) = drop n as := rfl\n\ntheorem drop_zero {α} (as : List α) : drop 0 as = as := rfl\n\ntheorem drop_all {α} (as : List α) : as.drop as.length = [] := by\n  induction as with\n  | nil =>\n    rw [drop_nil]\n  | cons a as ih =>\n    rw [length_cons]\n    rw [drop_cons]\n    rw [ih]\n\ntheorem drop_get {α} (as : List α) (n : Nat) (hn : n < as.length) : drop n as = as[n] :: drop (n+1) as := by\n  induction as generalizing n with\n  | nil => absurd hn; exact Nat.not_lt_zero n\n  | cons a as ih =>\n    match n with\n    | 0 =>\n      rw [drop_cons]\n      rw [drop]\n      rw [getElem_eq_get]\n      rw [get_cons_zero]\n      rw [drop]\n    | n+1 =>\n      rw [drop_cons]\n      rw [drop_cons]\n      rw [getElem_eq_get]\n      rw [get_cons_succ]\n      rw [←getElem_eq_get]\n      exact ih ..\n\n/- extract -/\n\ndef extract (as : List α) (start stop : Nat) := (as.drop start).take (stop - start)\n\ntheorem extract_stop (as : List α) (stop : Nat) : as.extract stop stop = [] := by\n  unfold extract\n  rw [Nat.sub_self]\n  rw [take_zero]\n\ntheorem extract_step (as : List α) (start stop : Nat) (hstart : start < stop) (hstop : stop ≤ as.length) :\n  as.extract start stop = as.get ⟨start, Nat.lt_of_lt_of_le hstart hstop⟩ :: as.extract (start+1) stop := by\n  unfold extract\n  induction start, stop using Nat.recDiag generalizing as with\n  | zero_zero => contradiction\n  | succ_zero start => contradiction\n  | zero_succ stop => match as with | a :: as => simp\n  | succ_succ start stop ih =>\n    match as with\n    | a :: as =>\n      simp\n      rw [ih]\n      exact Nat.lt_of_succ_lt_succ hstart\n      exact Nat.le_of_succ_le_succ hstop\n\ntheorem extract_all (as : List α) : as.extract 0 as.length = as := by\n  unfold extract\n  rw [Nat.sub_zero]\n  rw [List.drop]\n  rw [List.take_all]\n\n/- replicate -/\n\ntheorem replicate_zero {α} (a : α) : replicate 0 a = [] := rfl\n\ntheorem replicate_add {α} (a : α) : (m n : Nat) → replicate n a ++ replicate m a = replicate (m + n) a\n| _, 0 => rfl\n| _, _+1 => congrArg (a :: .) (replicate_add ..)\n\n/- dropLast -/\n\ntheorem length_dropLast (as : List α) : as.dropLast.length = as.length - 1 := by\n  cases as <;> simp\n\nprivate theorem get_dropLast.aux {as : List α} {i : Nat} : i < as.dropLast.length → i < as.length :=\n  fun h => Nat.lt_of_lt_of_le h (length_dropLast as ▸ Nat.pred_le as.length)\n\ntheorem get_dropLast (as : List α) (i : Fin as.dropLast.length) :\n  as.dropLast.get i = as.get ⟨i.val, get_dropLast.aux i.isLt⟩ := by\n  induction as with\n  | nil => exact nomatch i\n  | cons a as ih =>\n    match as, i with\n    | [], i => exact nomatch i\n    | _ :: _, ⟨0, _⟩ => simp [dropLast]\n    | _ :: _, ⟨i+1, hi⟩ => simp [dropLast, ih]\n\n/- all/any -/\n\n@[specialize] def allTR : List α → (α → Bool) → Bool\n| [], _ => true\n| x :: xs, p => p x && allTR xs p\n\n@[csimp] theorem all_eq_allTR : @List.all = @List.allTR := by\n  funext α xs p\n  induction xs with\n  | nil => rfl\n  | cons _ _ ih => exact congrArg _ ih\n\n@[specialize] def anyTR : List α → (α → Bool) → Bool\n| [], _ => false\n| x :: xs, p => p x || anyTR xs p\n\n@[csimp] theorem any_eq_anyTR : @List.any = @List.anyTR := by\n  funext α xs p\n  induction xs with\n  | nil => rfl\n  | cons _ _ ih => exact congrArg _ ih\n\ntheorem not_all_eq_any_not (p : α → Bool) (as : List α) : (!as.all p) = as.any fun a => !p a := by\n  induction as with\n  | nil => rfl\n  | cons a as ih =>\n    rw [all_cons]\n    rw [any_cons]\n    rw [Bool.not_and]\n    rw [ih]\n\ntheorem not_any_eq_all_not (p : α → Bool) (as : List α) : (!as.any p) = as.all fun a => !p a := by\n  induction as with\n  | nil => rfl\n  | cons a as ih =>\n    rw [any_cons]\n    rw [all_cons]\n    rw [Bool.not_or]\n    rw [ih]\n\ntheorem or_all_distrib_left (p : α → Bool) (q : Bool) (as : List α) : (q || as.all p) = as.all fun a => q || p a := by\n  induction as with\n  | nil =>\n    rw [all_nil]\n    rw [all_nil]\n    rw [Bool.or_true]\n  | cons a as ih =>\n    rw [all_cons]\n    rw [all_cons]\n    rw [Bool.or_and_distrib_left]\n    rw [ih]\n\ntheorem or_all_distrib_right (p : α → Bool) (q : Bool) (as : List α) : (as.all p || q) = as.all fun a => p a || q := by\n  induction as with\n  | nil =>\n    rw [all_nil]\n    rw [all_nil]\n    rw [Bool.true_or]\n  | cons a as ih =>\n    rw [all_cons]\n    rw [all_cons]\n    rw [Bool.or_and_distrib_right]\n    rw [ih]\n\ntheorem and_any_distrib_left (p : α → Bool) (q : Bool) (as : List α) : (q && as.any p) = as.any fun a => q && p a := by\n  induction as with\n  | nil =>\n    rw [any_nil]\n    rw [any_nil]\n    rw [Bool.and_false]\n  | cons a as ih =>\n    rw [any_cons]\n    rw [any_cons]\n    rw [Bool.and_or_distrib_left]\n    rw [ih]\n\ntheorem and_any_distrib_right (p : α → Bool) (q : Bool) (as : List α) : (as.any p && q) = as.any fun a => p a && q := by\n  induction as with\n  | nil =>\n    rw [any_nil]\n    rw [any_nil]\n    rw [Bool.false_and]\n  | cons a as ih =>\n    rw [any_cons]\n    rw [any_cons]\n    rw [Bool.and_or_distrib_right]\n    rw [ih]\n\n/- ofFun -/\n\n@[inline]\ndef ofFunTR {α n} (f : Fin n → α) : List α :=\n  let rec loop : Fin (n+1) → List α → List α\n  | ⟨0, _⟩, xs => xs\n  | ⟨i+1, hi⟩, xs => loop ⟨i, Nat.lt_trans (Nat.lt_succ_self i) hi⟩ (f ⟨i, Nat.lt_of_succ_lt_succ hi⟩ :: xs)\n  loop ⟨n, Nat.lt_succ_self n⟩ []\n\n@[implemented_by List.ofFunTR]\nprotected def ofFun {α} : {n : Nat} → (f : Fin n → α) → List α\n| 0, _ => []\n| n+1, f => f ⟨0, Nat.zero_lt_succ n⟩ :: List.ofFun fun i => f i.succ\n\ntheorem ofFun_length {α n} (f : Fin n → α) : (List.ofFun f).length = n := by\n  induction n with\n  | zero => rfl\n  | succ n ih =>\n    unfold List.ofFun\n    rw [List.length_cons]\n    rw [ih]\n\ntheorem ofFun_get {α n} (f : Fin n → α) (i : Fin (List.ofFun f).length) : (List.ofFun f).get i = f (ofFun_length f ▸ i) := by\n  induction n with\n  | zero =>\n    match i with\n    | ⟨_,_⟩ => contradiction\n  | succ n ih =>\n    match i with\n    | ⟨0, _⟩ =>\n      transitivity (f ⟨0, Nat.zero_lt_succ n⟩)\n      · simp only [List.ofFun]\n        rfl\n      · congr 1\n        apply Fin.eq\n        rw [Fin.val_ndrec]\n    | ⟨i+1, hi⟩ =>\n      simp only [List.ofFun, getElem]\n      rw [List.get_cons_succ]\n      rw [ih]\n      congr 1\n      apply Fin.eq\n      simp only [Fin.succ, Fin.val_ndrec]\n\nend List\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/List/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.49019259855318154}}
{"text": "import algebra\nimport data.real.basic\nimport data.vector\nimport data.finset\nimport tactic.explode\nimport tactic.find\nimport tactic.induction\nimport tactic.linarith\nimport tactic.rcases\nimport tactic.rewrite\nimport tactic.ring_exp\nimport tactic.tidy\nimport tactic.where\n\nnamespace IncLoLang\n\n/-! ## State-/\n\nmeta def tactic.dec_trivial := `[exact dec_trivial]\n\ndef state: Type := string -> ℕ\n\ndef state.update : string -> ℕ -> state -> state\n| name val σ := (λ name', if name' = name then val else σ name')\n\nnotation s `{` name ` ↦ ` val `}` := state.update name val s\n\n@[simp] lemma state.update_apply (name : string) (val : ℕ) (s : state) :\n  s{name ↦ val} name = val :=\nbegin\n  unfold state.update,\n  finish,\nend\n\n@[simp] lemma state.update_apply_ne (name name' : string) (val : ℕ) (s : state)\n    (h : name' ≠ name) :\n  s{name ↦ val} name' = s name' :=\nbegin\n  unfold state.update,\n  exact if_neg h,\nend\n\n@[simp] lemma state.update_override (name : string) (val₁ val₂ : ℕ) (s : state) :\n  s{name ↦ val₂}{name ↦ val₁} = s{name ↦ val₁} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma state.update_swap (name₁ name₂ : string) (val₁ val₂ : ℕ) (s : state)\n    (h : name₁ ≠ name₂ . tactic.dec_trivial) :\n  s{name₂ ↦ val₂}{name₁ ↦ val₁} = s{name₁ ↦ val₁}{name₂ ↦ val₂} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name₁;\n    by_cases name' = name₂;\n    simp * at *\nend\n\n@[simp] lemma state.update_id (name : string) (s : state) :\n  s{name ↦ s name} = s :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp * at *\nend\n\n@[simp] lemma state.update_same_const (name : string) (val : ℕ) :\n  (λ_, val){name ↦ val} = (λ_, val) :=\nby apply funext; simp\n\n/-! # Propositions -/\n\ndef prop: Type := state -> Prop\n\n/-! # Expression -/\n\ndef expression: Type := state -> ℕ\n\n/-! ## Language -/\n\ninductive stmt : Type\n| skip            : stmt\n| assign          : string → expression → stmt\n| non_det_assign  : string → stmt\n| seq             : stmt → stmt → stmt\n| choice          : stmt → stmt → stmt\n| star            : stmt → stmt\n-- | local_var       : string → stmt → stmt\n| error           : stmt\n| assumes         : prop → stmt\n\n-- Language notation\n\ninfixr ` ;; ` : 90 := stmt.seq\n\ninfixr ` <+> ` : 90 := stmt.choice\n\npostfix `**` : 90 := stmt.star\n\nnotation `[` x ` ↣ ` e `]` := stmt.assign x e\n\nnotation `[loc` x `.` C `]` := stmt.local_var x C\n\n/- This is the definition of P[x'/x] used in the paper -/\ndef prop.update_val (P: prop) (x': ℕ) (x: string) : IncLoLang.state -> Prop :=\n  -- λ σ', ∃ σ, P σ ∧ σ' = σ{x ↦ x'}\n  -- This is the definition given int he paper but it is wrong\n  λ σ', P (σ'{x ↦ x'})\n-- ie, True for σ if P(σ{x ↦ x'})\n\nnotation P `{` name ` ↣ ` val `}` := P.update_val val name\n\n/-! # Language semantics -/\n\ninductive LogicType : Type\n| er\n| ok\n\ndef repeat: IncLoLang.stmt → ℕ → IncLoLang.stmt \n| C nat.zero := IncLoLang.stmt.skip\n| C (nat.succ i) := (repeat C (i)) ;; C\n\ninductive lang_semantics: IncLoLang.stmt → LogicType → IncLoLang.state → IncLoLang.state → Prop\n| skip {s} :\n  lang_semantics IncLoLang.stmt.skip LogicType.ok s s\n| seq_ty {S T s t u ty} (H1: lang_semantics S LogicType.ok s t) (H2: lang_semantics T ty t u) :\n  lang_semantics (S ;; T) ty s u\n| seq_er_1 {S T s t} (H1: lang_semantics S LogicType.er s t): \n  lang_semantics (S ;; T) LogicType.er s t\n| error {s}:\n  lang_semantics IncLoLang.stmt.error LogicType.er s s\n| assign {x s e} :\n  lang_semantics [x ↣ e] LogicType.ok s (s{x ↦ (e s)})\n| non_det_assign {x s} (v: ℕ) :\n  lang_semantics (IncLoLang.stmt.non_det_assign x) LogicType.ok s (s{x ↦ v})\n| assumes_ok {s} {B: prop} (h: B s) :\n  lang_semantics (IncLoLang.stmt.assumes B) LogicType.ok s s\n| choice_left {C₁ C₂ ty s₁ s₂} (h: (lang_semantics C₁ ty s₁ s₂)): \n  lang_semantics (C₁ <+> C₂) ty s₁ s₂\n| choice_right {C₁ C₂ ty s₁ s₂} (h: (lang_semantics C₂ ty s₁ s₂)): \n  lang_semantics (C₁ <+> C₂) ty s₁ s₂\n| star {C s₁ s₂ ty} (i: ℕ) (h: lang_semantics (repeat C i) ty s₁ s₂):\n  lang_semantics (C**) ty s₁ s₂\n-- | local_var {C s₁ s₂ ty} (x: string) (v: ℕ) (h: lang_semantics C ty s₁ s₂):\n--   lang_semantics ([loc x . C]) ty (s₁{x ↦ v}) (s₂{x ↦ v})\n\n/-! # Free-/\n\n-- Perhaps invert\ndef prop.Free (P: prop): set string :=\n  λ x, ∃ σ v, (P σ ∧ ¬(P (σ{x ↦ v})))\n\n-- def expression.Free (e: expression): set string := \n--   λ x, ∃ σ v, e σ ≠ e (σ{x ↦ v})\n\n-- Set of variables x such that if ∀ x, σ x = σ' x, then e σ = e σ' \ndef expression.FreeProp (e: expression): set string → Prop := \n  (λ F, ∀ σ σ': state, (∀ f: F, σ f = σ' f) → e σ = e σ' )\n\ndef expression.Free (e: expression): set string := \n  ⋂₀ (λ A, e.FreeProp A) \n-- WTS expression.free satisfies expression.FreeProp\n-- Freeprop is closed under intersection\n\n-- freeprop {x, y} freeprop {x, z} → freeprop {x}\n-- show binary intersections\n-- show infinite intersections\n-- thus we have what we want\n\n-- infinite intersections in lean?\n\nlemma expression.Free.semantics (e: expression) {x: string}: \n  x ∈ expression.Free e ↔ ∃ σ v, e σ ≠ e (σ{x ↦ v}) := \n  -- λ x, ∃ σ v, e σ ≠ e (σ{x ↦ v})\nbegin\n  split,\n  {\n    intro hx,\n    by_contra,\n    push_neg at h,\n    specialize hx (λ y : string, y ≠ x),\n    have H: e.FreeProp (λ (y : string), y ≠ x), {\n      intros σ σ' hf,\n      have H: ∃ v, σ' = σ{x ↦ v}, {\n        use σ' x,\n        funext z,\n        by_cases z = x,\n        { cases h, rw state.update_apply, },\n        { \n          rw state.update_apply_ne _ _ _ _ h, \n          simp at hf,\n          specialize hf z h,\n          rw hf,\n        },\n      },\n      cases H,\n      rw h σ H_w,\n      rw H_h,\n    },\n    specialize hx H,\n    apply hx,\n    refl,\n  },\n  {\n    intros h F hF,\n    rw expression.FreeProp at hF,\n    cases h with σ h,\n    cases h with v,\n    by_contra,\n    specialize hF σ (σ{x ↦ v}), \n    simp at hF,\n    have H: (∀ (y : string), y ∈ F → σ y = σ{x ↦ v} y), {\n      intros y hy,\n      have H: y ≠ x, {finish,},\n      rw state.update_apply_ne _ _ _ _ H,\n    },\n    specialize hF H,\n    apply h_h,\n    exact hF,\n  }\nend\n\ndef stmt.Free: stmt → set string \n| stmt.skip                 := {}\n| ([z ↣ e₂])                := {z} ∪ e₂.Free\n| (stmt.non_det_assign z)   := {z}\n| (C₁ ;; C₂)                := (stmt.Free C₁) ∪ (stmt.Free C₂)\n| (C₁ <+> C₂)               := (stmt.Free C₁) ∪ (stmt.Free C₂)\n| (C**)                     := stmt.Free C\n-- | [loc z . C]               := (stmt.Free C)\n-- | [loc z . C]               := (stmt.Free C) \\ {z}\n| stmt.error                := {}\n| (stmt.assumes P)          := prop.Free P\n\n/-! # Substitute-/\n\ndef state.substitute : string → string → state → state\n-- | y x := λ σ, σ{y ↦ σ x}\n| y x := λ σ, σ{y ↦ σ x}{x ↦ 0}\n\nnotation σ `⟨` vto `//` vfrom `⟩` :=  state.substitute vto vfrom σ\n\ndef prop.substitute : string → string → prop → prop\n| x s P := λ σ, P (σ⟨ x // s⟩)\n\nnotation P `[` val `//` name `]` :=  prop.substitute name val P\n\ndef expression.substitute : string → string → expression → expression\n| x y e := λ σ, e (σ⟨ x // y ⟩)\n\ndef stmt.substitute : string → string → stmt → stmt\n| x y stmt.skip                 := stmt.skip\n| x y ([z ↣ e₂])                := if x = z then [y ↣ λ σ, ((expression.substitute x y e₂) σ)] else [z ↣ λ σ, ((expression.substitute x y e₂) σ)]  -- PUT X BACK!\n| x y (stmt.non_det_assign z)   := if x = z then stmt.non_det_assign y else stmt.non_det_assign z\n| x y (C₁ ;; C₂)                := (stmt.substitute x y C₁) ;; (stmt.substitute x y C₂)\n| x y (C₁ <+> C₂)               := (stmt.substitute x y C₁) <+> (stmt.substitute x y C₂)\n| x y (C**)                     := (stmt.substitute x y C)**\n-- | x y [loc z . C]               := if x = z then [loc x . C] else [loc z . (stmt.substitute x y C)]\n-- | x y [loc z . C]               := if x = z then [loc x . C] else (if y = z then C else [loc z . (stmt.substitute x y C)])\n| x y stmt.error                := stmt.error\n| x y (stmt.assumes P)          := stmt.assumes (P[y//x])\n\nnotation C `{` exp `//` name `}` :=  stmt.substitute name exp C\n\n/-! ## Mod -/\n\ndef stmt.Mod: stmt → set string\n| (C₁ ;; C₂) := (C₁.Mod) ∪ (C₂.Mod)\n| (C₁ <+> C₂) := (C₁.Mod) ∪ (C₂.Mod)\n| (C**) := (C.Mod)\n| ([x ↣ v]) := {x}\n| (IncLoLang.stmt.skip) := {}\n| (IncLoLang.stmt.non_det_assign x) := {x}\n| (IncLoLang.stmt.assumes _) := {}\n| (IncLoLang.stmt.error) := {}\n-- | (IncLoLang.stmt.local_var x C) := Mod C \\ {x}\n\nlemma mod_elem_left_elem_seq (C₁ C₂: stmt):\n   C₁.Mod ⊆ (C₁ ;; C₂).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma mod_elem_right_elem_seq (C₁ C₂: stmt):\n   C₂.Mod ⊆ (C₁ ;; C₂).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma mod_elem_left_elem_choice (C₁ C₂: stmt):\n   C₁.Mod ⊆ (C₁ <+> C₂).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma mod_elem_right_elem_choice (C₁ C₂: stmt):\n   C₂.Mod ⊆ (C₁ <+> C₂).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma start_seq {C: stmt} {σ σ': state} {ty: LogicType}:\n  IncLoLang.lang_semantics (C** ;; C) ty σ σ' → IncLoLang.lang_semantics (C**) ty σ σ' :=\nbegin\n  intro h,\n  cases h,\n  {\n    have H: ∃ N, lang_semantics (repeat C N) ty σ σ',\n    {\n      cases h_H1,\n      use h_H1_i.succ,\n      rw repeat,\n      exact lang_semantics.seq_ty h_H1_h h_H2,\n    },\n    cases H with N,\n    exact lang_semantics.star N H_h,\n  },\n  { exact h_H1, },\nend\n\n/-! ## Free lemmas -/\n\nlemma mod_sub_free (C: stmt):\n  C.Mod ⊆ C.Free :=\nbegin\n  induction C with v r _ C₁ C₂ hC₁ hC₂ C₁ C₂ hC₁ hC₂ _ h,\n  case stmt.skip {\n    rw stmt.Mod,\n    exact stmt.skip.Free.empty_subset,\n  },\n  case stmt.assign {\n    rw stmt.Mod,\n    rw stmt.Free,\n    exact ({v}: set string).subset_union_left (expression.Free r),\n  },\n  case stmt.non_det_assign {\n    rw stmt.Mod,\n    rw stmt.Free,\n  },\n  case stmt.seq {\n    rw stmt.Mod,\n    rw stmt.Free,\n    exact set.union_subset_union hC₁ hC₂,\n  },\n  case stmt.choice {\n    rw stmt.Mod,\n    rw stmt.Free,\n    exact set.union_subset_union hC₁ hC₂,\n  },\n  case stmt.star {\n    rw stmt.Mod,\n    rw stmt.Free,\n    exact h,\n  },\n  -- case stmt.local_var {\n  --   rw Mod,\n  --   rw stmt.Free,\n  --   exact set.diff_subset_diff_left C_ih,\n  -- },\n  case stmt.error {\n    rw stmt.Mod,\n    rw stmt.Free,\n  },\n  case stmt.assumes {\n    rw stmt.Mod,\n    exact (stmt.assumes C).Free.empty_subset,\n  },\nend\n\nlemma not_free_expression {e: expression} {x}: \n  (¬e.Free x) → ∀ σ v, e σ = e (σ{x ↦ v}) :=\nbegin\n  intro hFree,\n  by_contra H,\n  apply hFree,\n  apply (expression.Free.semantics e).2, \n  push_neg at H,\n  exact H,\nend\n\nlemma not_free_prop {e: prop} {x}: \n  (¬e.Free x) → ∀ σ v, e σ ↔ e (σ{x ↦ v}) :=\nbegin\n  intro h,\n  unfold prop.Free at h,\n  push_neg at h,\n  intros σ v,\n  split,\n  { exact h σ v, },\n  {\n    specialize h (σ{x ↦ v}) (σ x),\n    have H: σ{x ↦ v}{x ↦ σ x} = σ, {\n      funext,\n      by_cases x = name',\n      { finish, },\n      { finish, }\n    },\n    rw H at h,\n    exact h,\n  }\nend\n\nlemma free_language_semantics (C: stmt) (x: string):\n  (¬C.Free x) → (∀ σ σ' ty v, lang_semantics C ty σ σ' → lang_semantics C ty (σ{x ↦ v}) (σ'{x ↦ v})) :=\nbegin\n  induction C with \n    y \n    e y \n    C₁ C₂ C₁h C₂h \n    C₁ C₂ C₁h C₂h\n    C Ch\n    z C,\n  case stmt.skip {\n    intros h₁ σ σ' ty v h,\n    cases h,\n    exact lang_semantics.skip,\n  },\n  case stmt.assign {\n    intros h₁ σ σ' ty v h₂,\n    cases h₂,\n    by_cases x = y,\n    {\n      exfalso,\n      rw stmt.Free at h₁,\n      apply h₁,\n      left,\n      exact set.mem_singleton_iff.mpr h,\n    },\n    {\n      rw ← state.update,\n      rw state.update_swap _ _ _ _ _ (h),\n      -- have H: (λ (name' : string), σ name') = σ, {exact rfl}\n      rw stmt.Free at h₁,\n      have H: e σ = e (σ{x ↦ v}), {\n        by_contra,\n        have H2: x ∈ e.Free, {\n          rw expression.Free.semantics e,\n          use σ,\n          use v,\n        },\n        apply h₁,\n        right,\n        exact H2,\n      },\n      rw H,\n      exact lang_semantics.assign,\n    }\n  },\n  case stmt.non_det_assign {\n    intros h₁ σ σ' ty v h₂,\n    cases h₂,\n    by_cases x = y,\n    {\n      exfalso,\n      rw stmt.Free at h₁,\n      apply h₁,\n      exact set.mem_singleton_iff.mpr h,\n    },\n    {\n      rw ← state.update,\n      rw state.update_swap _ _ _ _ _ h,\n      -- have H: (λ (name' : string), σ name') = σ, {exact rfl}\n      rw stmt.Free at h₁,\n\n      exact lang_semantics.non_det_assign h₂_v,\n    }\n  },\n  case stmt.seq {\n    intros h₁ σ σ' ty v h₂,\n    rw stmt.Free at h₁,\n    specialize C₁h (by {\n      by_contra,\n      apply h₁,\n      left,\n      exact h,\n    }),\n    specialize C₂h (by {\n      by_contra,\n      apply h₁,\n      right,\n      exact h,\n    }),\n    cases h₂,\n    {\n      specialize C₁h σ h₂_t LogicType.ok v h₂_H1,\n      specialize C₂h h₂_t σ' ty v h₂_H2,\n      exact lang_semantics.seq_ty C₁h C₂h,\n    },\n    {\n      specialize C₁h σ σ' LogicType.er v h₂_H1,\n      exact lang_semantics.seq_er_1 C₁h,\n    },\n  },\n  case stmt.choice {\n    intros h₁ σ σ' ty v h₂,\n    rw stmt.Free at h₁,\n\n    cases h₂,\n    {\n      specialize C₁h (by {\n        by_contra,\n        apply h₁,\n        left,\n        exact h,\n      }) σ σ' ty v h₂_h,\n      exact lang_semantics.choice_left C₁h,\n    },\n    {\n      specialize C₂h (by {\n        by_contra,\n        apply h₁,\n        right,\n        exact h,\n      }) σ σ' ty v h₂_h,\n      exact lang_semantics.choice_right C₂h,\n    },\n  },\n  case stmt.star {\n    intros h₁ σ σ' ty v h₂,\n    rw stmt.Free at h₁,\n    specialize Ch h₁,\n    cases h₂,\n    use h₂_i,\n    revert σ σ' ty,\n    induction h₂_i,\n    {\n      intros σ σ' ty h,\n      rw repeat at h,\n      cases h,\n      rw repeat,\n      exact lang_semantics.skip,\n    },\n    {\n      intros σ σ' ty h,\n      rw repeat,\n      rw repeat at h,\n      cases h,\n      {\n        exact lang_semantics.seq_ty \n          (h₂_i_ih σ h_t LogicType.ok h_H1)\n          (Ch h_t σ' ty v h_H2),\n      },\n      { exact lang_semantics.seq_er_1 ( h₂_i_ih σ σ' LogicType.er h_H1 ), }\n    }\n  },\n  -- case stmt.local_var {\n  --   intros h₁ σ σ' ty v,\n  --   rw stmt.Free at h₁,\n  --   by_cases H: x = z,\n  --   {\n  --     cases H,\n  --     intro h,\n  --     cases h,\n  --     rw ← state.update,\n  --     rw ← state.update,\n  --     rw assign_order_eq,\n  --     rw assign_order_eq,\n  --     exact lang_semantics.local_var x v h_h,\n  --   },\n  --   {\n  --     have h₂: x ∉ C.Free, {\n  --       by_contra,\n  --       apply h₁,\n  --       split,\n  --       { exact h, },\n  --       { \n  --         by_contra, \n  --         apply H, \n  --         exact set.mem_singleton_iff.1 h,\n  --       },\n  --     },\n  --     specialize C_ih h₂,\n  --     intro h,\n  --     cases h,\n  --     rw ← state.update,\n  --     rw ← state.update,\n  --     rw assign_order (ne.symm H),\n  --     rw assign_order (ne.symm H),\n  --     exact lang_semantics.local_var _ _ (C_ih h_s₁ h_s₂ ty v h_h)\n  --   },\n  -- },\n  case stmt.error {\n    intros h₁ σ σ' ty v h,\n    cases h,\n    exact lang_semantics.error,\n  },\n  case stmt.assumes {\n    intros h₁ σ σ' ty v h,\n    cases h,\n    rw stmt.Free at h₁,\n    rw prop.Free at h₁,\n    push_neg at h₁,\n    exact lang_semantics.assumes_ok (h₁ σ v h_h),\n  },\nend\n\nlemma assign_semantics {x σ σ' ty} {e: expression}: \n  lang_semantics ([x ↣ e]) ty σ σ' → σ{x ↦ e σ} = σ' ∧ ty = LogicType.ok:=\nbegin\n  intro h,\n  cases h,\n  split,\n  repeat { refl },\nend\n\nlemma non_det_assign_semantics {x σ σ' ty}: \n  lang_semantics (stmt.non_det_assign x) ty σ σ' → ∃ v, σ' = σ{x ↦ v} ∧ ty = LogicType.ok :=\nbegin\n  intro h,\n  cases h,\n  use h_v,\n  split,\n  repeat { refl },\nend\n\nlemma p_thing_free {x: string} {v: ℕ} {P: prop} :\n  prop.Free (P{ x ↣ v }) ⊆ prop.Free P \\ {x} :=\nbegin\n  intros y hy,\n  unfold prop.Free at hy,\n  unfold prop.update_val at hy,\n  cases hy with σ,\n  use σ{x ↦ v},\n  have Hxy: x ≠ y,\n  {\n    by_contra,\n    cases h,\n    cases hy_h with v,\n    rw state.update_override at hy_h_h,\n    finish,\n  },\n  {\n    cases hy_h with n hn,\n    use n,\n    -- rw assign_order Hxy,\n    rw state.update_swap _ _ _ _ _ (ne.symm Hxy),\n    exact hn,\n  },\n  {\n    intro h,\n    finish,\n  },\nend\n\nlemma free_assign {x e}:  (expression.Free e) ∪ {x} ⊆ (stmt.Free ([x ↣ e])):=\nbegin\n  intros y hy,\n  by_cases x = y,\n  {\n    cases h,\n    unfold stmt.Free,\n    left,\n    exact set.mem_singleton x,\n  },\n  {\n    -- rcases hy with ⟨ x, y ⟩, \n    cases hy,\n    {\n      -- rcases hy with ⟨σ, ⟨v, hσ⟩⟩,\n      rw stmt.Free,\n      right, \n      exact hy,\n    },\n    {\n      exfalso, cases hy, apply h, refl,\n    }\n  },\nend\n\nlemma assign_case {ty y x z e} {σ σ' : state} (Hyx: y ≠ x) (Hfreey: y ∉ ([z ↣ e].Free)):\n  lang_semantics ([z ↣ e]) ty (σ) (σ') →  \n    lang_semantics ([z ↣ e]{y // x}) ty (σ⟨ y // x⟩) (σ'⟨ y // x ⟩) :=\nbegin\n  have H := (set.compl_subset_compl.mpr free_assign) Hfreey,\n  have H₁ : y ∉ e.Free, { by_contra, finish, },\n  have H₁ := not_free_expression H₁,\n\n  have H₂ : y ≠ z, {\n    by_contra,\n    finish,\n  },\n\n  intro hls,\n  cases hls,\n  cases hls,\n  rw stmt.substitute,\n\n  by_cases hx: x = z,\n  {\n    rw if_pos hx,\n    cases hx,\n    rw ← state.update,\n    rw expression.substitute,\n    simp,\n\n    have H: σ{x ↦ e σ}⟨y//x⟩= σ⟨y//x⟩{y ↦ (λ (σ : state), e (σ⟨x//y⟩)) (σ⟨y//x⟩)}, \n    {\n      ext z,\n      simp,\n\n      unfold state.update,\n      unfold state.substitute,\n      by_cases hx: x = z,\n      {finish,},\n      {\n        by_cases hy: y = z,\n        {\n          cases hy,\n          simp,\n          finish,\n        },\n        {\n          simp,\n          unfold state.update,\n          finish,\n        },\n      }\n    },\n    \n    rw H,\n    exact lang_semantics.assign,\n  },\n  {\n    rw if_neg hx,\n    rw ← state.update,\n    rw state.substitute,\n    simp,\n    rw state.update_swap _ _ _ _ _ H₂,\n    rw state.update_swap _ _ _ _ _ hx,\n    have H: σ{z ↦ e σ} x = σ x, {\n      funext, finish,\n    },\n    rw H,\n    rw expression.substitute,\n    have H: e σ = (λ (σ : state), e (σ⟨x//y⟩)) (σ{y ↦ σ x}{x ↦ 0}), {\n      simp,\n      rw state.substitute,\n      simp,\n      rw ← state.update_swap _ _ _ _ _ Hyx,\n      rw state.update_override,\n      have H: σ{x ↦ σ{y ↦ σ x}{x ↦ 0} y} = σ, {\n        funext, finish,\n      },\n      rw H,\n      exact H₁ σ 0,\n    },\n    rw H,\n    exact lang_semantics.assign,\n  },\nend\n\nlemma substitution_rule {ty C y x} {σ σ' : state} (Hyx: y ≠ x) (Hfreey: y ∉ stmt.Free C):\n  lang_semantics C ty (σ) (σ') → \n    -- If C can take σ to σ'\n    lang_semantics (C{y // x}) ty (σ⟨ y // x⟩) (σ'⟨ y // x ⟩) :=\n    -- Then C(y/x) can take σ with y set to x's value in σ to σ' with y set to x's value in σ' \nbegin\n  revert ty σ σ',\n\n  induction C with z e z \n    C₁ C₂ hC₁ hC₂\n    C₁ C₂ hC₁ hC₂\n    C hC,\n    -- z C hC,\n  case stmt.skip {\n    -- Skip case is trivial as σ = σ'\n    intros _ σ _ h,\n    cases h,\n    exact lang_semantics.skip,\n  },\n  case stmt.assign {\n    intros ty σ σ' hls,\n    exact assign_case Hyx Hfreey hls,\n  },\n  case stmt.non_det_assign {\n    intros ty σ σ' hls,\n\n    by_cases x = z,\n    {\n      cases h,\n      rw stmt.substitute,\n      cases hls,\n      unfold state.substitute,\n      rw if_pos (rfl),\n      rw ← state.update,\n      rw state.update_swap _ _ _ _ _ Hyx,\n      rw if_pos (rfl),\n      simp,\n      rw ← state.update_swap _ _ _ _ _ Hyx,\n      rw ← state.update_swap _ _ _ _ _ Hyx,\n      have H: σ{x ↦ 0}{y ↦ hls_v} = σ{x ↦ 0}{y ↦ σ x}{y ↦ hls_v}, { rw state.update_override, },\n      rw H,\n      exact lang_semantics.non_det_assign hls_v,\n    },\n    {\n      rw stmt.substitute,\n      cases hls,\n      unfold state.substitute,\n      rw if_neg h,\n      rw ← state.update,\n      rw if_neg h,\n      by_cases H₂: z = y,\n      {\n        cases H₂,\n        rw state.update_override,\n        rw state.update_swap _ _ _ _ _ h,\n        have H: σ{x ↦ 0}{y ↦ σ x} = σ{x ↦ 0}{y ↦ σ x}{y ↦ σ x}, { rw state.update_override, },\n        nth_rewrite 1 H,\n        exact lang_semantics.non_det_assign (σ x),\n      },\n      {\n        rw state.update_swap _ _ _ _ _ (ne.symm H₂),\n        rw state.update_swap _ _ _ _ _ h,\n        exact lang_semantics.non_det_assign hls_v,\n      }\n    },\n  },\n  case stmt.seq {\n    intros ty σ σ' hls,\n    cases hls,\n    {\n      specialize hC₁ (by {\n        by_contra,\n        apply Hfreey,\n        left,\n        exact h,\n      }) hls_H1,\n      specialize hC₂ (by {\n        by_contra,\n        apply Hfreey,\n        right,\n        exact h,\n      }) hls_H2,\n      rw stmt.substitute,\n      exact lang_semantics.seq_ty hC₁ hC₂,\n    },\n    {\n      specialize hC₁ (by {\n        by_contra,\n        apply Hfreey,\n        left,\n        exact h,\n      }) hls_H1,\n      rw stmt.substitute,\n      exact lang_semantics.seq_er_1 hC₁,\n    }\n  },\n  case stmt.choice {\n    intros ty σ σ' hls,\n    cases hls,\n    {\n      specialize hC₁ (by {\n        by_contra,\n        apply Hfreey,\n        left,\n        exact h,\n      }) hls_h,\n      rw stmt.substitute,\n      exact lang_semantics.choice_left hC₁,\n    },\n    {\n      specialize hC₂ (by {\n        by_contra,\n        apply Hfreey,\n        right,\n        exact h,\n      }) hls_h,\n      rw stmt.substitute,\n      exact lang_semantics.choice_right hC₂,\n    }\n  },\n  case stmt.star {\n    intros ty σ σ' hls,\n    cases hls,\n    rw stmt.substitute,\n    use hls_i,\n    revert ty σ σ' ,\n    induction hls_i,\n    {\n      intros ty σ σ' hls_h,\n      rw repeat at hls_h,\n      cases hls_h,\n      rw repeat,\n      exact lang_semantics.skip,\n    },\n    {\n      intros ty σ σ' hls_h,\n      rw repeat at hls_h,\n      cases hls_h,\n      {\n        specialize hls_i_ih hls_h_H1,\n        rw stmt.Free at Hfreey,\n        specialize hC Hfreey hls_h_H2, \n        rw repeat,\n        exact lang_semantics.seq_ty hls_i_ih hC,\n      },\n      {\n        specialize hls_i_ih hls_h_H1,\n        rw repeat,\n        exact lang_semantics.seq_er_1 hls_i_ih,\n      },\n    },\n  },\n  -- case stmt.local_var {\n  --   intros ty σ σ' hls,\n  --   cases hls,\n  --   rw stmt.substitute,\n  --   by_cases x = z,\n  --   {\n  --     cases h,\n  --     rw if_pos h,\n  --     rw stmt.Free at Hfreey,\n  --     have H : y ∉ C.Free, { finish, },\n  --     rw ← state.update,\n  --     rw ← state.update,\n  --     rw state.substitute,\n  --     simp,\n  --     have H₂ := free_language_semantics C y H,\n  --     rw ← assign_order Hyx,\n  --     rw ← assign_order Hyx,\n  --     rw assign_order_eq,\n  --     rw assign_order_eq,\n  --     specialize H₂ hls_s₁ hls_s₂ ty hls_v hls_h, \n  --     exact lang_semantics.local_var _ _ H₂,\n  --   },\n  --   {\n  --     rw if_neg h,\n  --     rw stmt.Free at Hfreey,\n  --     by_cases y = z,\n  --     {\n  --       cases h,\n  --       rw ← state.update,\n  --       rw state.substitute,\n  --       rw ← state.update,\n  --       simp,\n  --       have H1: hls_s₁{y ↦ hls_v} x = hls_s₁ x, { unfold state.update, finish, },\n  --       have H2: hls_s₂{y ↦ hls_v} x = hls_s₂ x, { unfold state.update, finish, },\n  --       rw H1, rw H2,\n  --       sorry,\n  --        -- [loc z. z = 5]\n  --        -- [loc z. x = 5](z//x)\n  --        -- [loc z. z = 5](z//x) !! Need to move to fresh\n  --       -- exact lang_semantic.local_var y hls_v (hC Hfreey hls_h),\n  --       -- rw stmt.substitute,\n  --       -- x ≠ b (σ1, σ2) ∈ ⟦local x . C⟧ and y ∉ Free C ⇒ (σ1(y/b), σ2(y/b)) ∈ ⟦local x . C(y/b)⟧\n  --       -- ({b = 1}, {b = 2}) ∈ ⟦local y . b = 2⟧ ⇒ ({y = 1}, {y = 2}) ∈ ⟦local y . y = 2⟧\n  --     },\n  --     {\n  --       have H: y ∉ C.Free, { by_contra, finish, },\n  --       specialize hC H hls_h,\n  --       rw ← state.update,\n  --       rw ← state.update,\n  --       simp,\n  --       have H1: ∀ σ, ((σ{z ↦ hls_v})⟨y//x⟩) = ((σ⟨y//x⟩){z ↦ hls_v}), {\n  --         intro σ,\n  --         rw state.substitute,\n  --         funext,\n  --         simp,\n  --         unfold state.update,\n  --         by_cases name' = x, { cases h, finish, },\n  --         by_cases name' = y, { cases h, finish, },\n  --         by_cases name' = z, { cases h, finish, },\n  --         finish,\n  --       },\n  --       rw (H1 hls_s₁),\n  --       rw (H1 hls_s₂),\n  --       exact lang_semantics.local_var _ _ hC,\n  --     },\n  --   },\n  -- },\n  {\n    intros ty σ σ' hls,\n    cases hls,\n    rw stmt.substitute,\n    exact lang_semantics.error,  \n  },\n  {\n    intros ty σ σ' hls,\n    cases hls,\n    rw stmt.substitute,\n    have H: (C[y//x]) (σ⟨y//x⟩), { \n      unfold prop.substitute,\n      unfold state.substitute,\n      rw state.update_override,\n      have H: σ{y ↦ σ x}{x ↦ σ{y ↦ σ x}{x ↦ 0} y} = σ{y ↦ σ x}, {\n        unfold state.update,\n        funext,\n        finish,\n      },\n      rw H,\n      rw stmt.Free at Hfreey,\n      simp,\n      apply (not_free_prop Hfreey σ (0)).1,\n      exact hls_h,\n    },\n    exact lang_semantics.assumes_ok H,\n  },\nend\n\nlemma stmt_free_unchanged {x: string} {C: stmt} {σ σ': state} {ty: LogicType}: \n  (lang_semantics C ty σ σ') ∧ (x ∉ C.Free) → σ x = σ' x :=\nbegin \n  revert σ σ' ty,\n  induction C with \n    y e\n    y\n    C₁ C₂ hC₁ hC₂\n    C₁ C₂ hC₁ hC₂\n    C Ch,\n  case stmt.skip {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    cases hls,\n    refl,\n  },\n  case stmt.assign {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    cases hls,\n    unfold stmt.Free at hxFree,\n    have H: x ≠ y, { finish, },\n    simp,\n    rw if_neg H,\n  },\n  case stmt.non_det_assign {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    cases hls,\n    unfold stmt.Free at hxFree,\n    have H: x ≠ y, { finish, },\n    simp,\n    rw if_neg H,\n  },\n  case stmt.seq {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    have H₁: x ∉ C₁.Free, {by_contra, apply hxFree, left, exact h,},\n    have H₂: x ∉ C₂.Free, {by_contra, apply hxFree, right, exact h,},\n    cases hls,\n    {\n      specialize hC₁ (⟨hls_H1, H₁⟩),\n      specialize hC₂ (⟨hls_H2, H₂⟩),\n      rw hC₁,\n      exact hC₂,\n    },\n    { exact hC₁ (⟨hls_H1, H₁⟩), },\n  },\n  case stmt.choice {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    have H₁: x ∉ C₁.Free, {by_contra, apply hxFree, left, exact h,},\n    have H₂: x ∉ C₂.Free, {by_contra, apply hxFree, right, exact h,},\n    cases hls,\n    {\n      specialize hC₁ (⟨hls_h, H₁⟩),\n      exact hC₁,\n    },\n    {\n      specialize hC₂ (⟨hls_h, H₂⟩),\n      exact hC₂,\n    },\n  },\n  case stmt.star {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    cases hls,\n    revert ty σ σ', \n    induction hls_i with n hC' hC',\n    {\n      intros _ _ _ hls_h,\n      rw repeat at hls_h,\n      cases hls_h,\n      refl,\n    },\n    {\n      intros ty σ σ' hls,\n      rw repeat at hls,\n      rw stmt.Free at hxFree,\n      cases hls,\n      {\n        specialize Ch (⟨hls_H2, hxFree⟩),\n        specialize hC' hls_H1,\n        rw hC',\n        exact Ch,\n      },\n      {\n        specialize hC' hls_H1,\n        exact hC',\n      },\n    }\n  },\n  case stmt.error {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    cases hls,\n    refl,\n  },\n  case stmt.assumes {\n    rintros σ σ' ty ⟨ hls, hxFree ⟩,\n    cases hls,\n    refl,\n  },\nend\n\nlemma expression.substitute.x_free {x y} (e: expression) (H: x ≠ y) : \n  x ∉ (expression.substitute x y e).Free :=\nbegin\n  -- unfold expression.Free,\n  by_contra,\n  have H := (expression.Free.semantics (expression.substitute x y e)).1 h,\n  cases H with σ h,\n  rcases h with ⟨v, h⟩,\n  unfold expression.substitute at h,\n  unfold state.substitute at h,\n  simp[H, (ne.symm H)] at h,\n  exact h,\nend\n\nlemma prop.substitute.x_free {x y} (P: prop) (H: x ≠ y) : \n  x ∉ (prop.substitute x y P).Free :=\nbegin\n  unfold prop.Free,\n  by_contra,\n  cases h with σ h,\n  rcases h with ⟨v, ⟨hp, hnp⟩⟩,\n  unfold prop.substitute at hp,\n  unfold prop.substitute at hnp,\n  unfold state.substitute at hp,\n  unfold state.substitute at hnp,\n  simp[ne.symm H] at hnp,\n  simp[ne.symm H] at hp,\n  exact H (false.rec (x = y) (hnp hp)),\nend\n\nlemma stmt.substitution.x_free {x y C} (H: x ≠ y): x ∉ (C{y // x}).Free :=\nbegin\n  -- sorry,\n  induction C with \n    z e \n    z\n    C₁ C₂ hC₁ hC₂\n    C₁ C₂ hC₁ hC₂\n    C hC\n    ,\n  case stmt.skip {\n    rw stmt.substitute,\n    rw stmt.Free,\n    exact set.not_mem_empty x,\n  },\n  case stmt.assign {\n    rw stmt.substitute,\n    by_cases hxz: x = z,\n    {\n      cases hxz,\n      simp,\n      rw stmt.Free,\n      by_contra,\n      simp[H] at h,\n\n      exact expression.substitute.x_free e H h,\n    },\n    {\n      simp[hxz],\n      rw stmt.Free,\n      by_contra,\n      simp[hxz] at h,\n\n      exact expression.substitute.x_free e H h,\n    },\n  },\n  case stmt.non_det_assign {\n    rw stmt.substitute,\n    by_cases hxz: x = z,\n    {\n      cases hxz,\n      simp,\n      rw stmt.Free,\n      exact H,\n    },\n    {\n      simp [hxz],\n      rw stmt.Free,\n      exact hxz,\n    },\n  },\n  case stmt.seq {\n    rw stmt.substitute,\n    rw stmt.Free,\n    by_contra,\n    cases h,\n    { exact hC₁ h, },\n    { exact hC₂ h, },\n  },\n  case stmt.choice {\n    rw stmt.substitute,\n    rw stmt.Free,\n    by_contra,\n    cases h,\n    { exact hC₁ h, },\n    { exact hC₂ h, },\n  },\n  case stmt.star {\n    rw stmt.substitute,\n    rw stmt.Free,\n    exact hC,\n  },\n  case stmt.error {\n    rw stmt.substitute,\n    rw stmt.Free,\n    exact set.not_mem_empty x,\n  },\n  case stmt.assumes {\n    rw stmt.substitute,\n    rw stmt.Free,\n    exact prop.substitute.x_free C H,\n  },\nend\n\nlemma expression.FreeProp.intersection \n  {e: expression} {A B: set string}: \n  e.FreeProp A ∧ e.FreeProp B → e.FreeProp (A ∩ B) := \nbegin\n  rintro ⟨ hA, hB ⟩,\n  unfold expression.FreeProp,\n  intros σ₁ σ₃ h,  \n  classical,\n  let σ₂: state := λ s, if s ∈ A then σ₁ s else σ₃ s,\n  have H₁₂: e σ₁ = e σ₂, {\n    specialize hA σ₁ σ₂,\n    apply hA,\n    intro a,\n    simp[σ₂],\n    simp,\n  },\n  have H₂₃: e σ₂ = e σ₃, {\n    specialize hB σ₂ σ₃,\n    apply hB,\n    intro b,\n    simp,\n    intro hb,\n    have H: ↑b ∈ A ∩ B, { finish, },\n    simp at h,\n    exact h b (hb) (subtype.mem b),\n  },\n  rw H₁₂,\n  exact H₂₃,\nend\n\n-- lemma finite_powerset (B: set string) : B.finite → (𝒫 B).finite := \n-- begin \n--   intro h,\n\n--   have hA := set.finite.exists_finset_coe h,\n--   cases hA,\n\n--   have hB := finset.coe_powerset (hA_w),\n--   rw hA_h at hB,\n\n--   let X : finset (set string) := ((hA_h.powerset).map (⟨coe, finset.coe_injective⟩)),\n  \n--   exact set.finite.of_finset (hA_w.powerset) hB,\n-- end \n\n-- From https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Arguments.20with.20infinite.20sets.20and.20decidability\nlemma finite_powerset {α} {s : set α} (h : s.finite) : (𝒫 s).finite :=\nbegin\n  obtain ⟨s', hs'⟩ := set.finite.exists_finset_coe h,\n  refine set.finite.of_finset (s'.powerset.map (⟨_, finset.coe_injective⟩)) _,\n  simp_rw [←finset.mem_coe, ←set.ext_iff, finset.coe_map, finset.coe_powerset,\n    function.embedding.coe_fn_mk, ←hs', set.image_preimage_eq_iff],\n  intros x hx,\n  rw set.mem_powerset_iff at hx,\n  classical,\n  refine ⟨s'.filter (∈ x), _⟩,\n  rwa [finset.coe_filter, set.sep_mem_eq, set.inter_eq_right_iff_subset],\nend\n\nlemma expression.FreeProp.infIntersection\n  (e: expression): \n  (∃ B: set string,(e.FreeProp B) ∧ B.finite) → (e.FreeProp e.Free) :=\nbegin\n  -- Argument:\n  -- B ∈ A so ⋂₀ A ⊆ B\n  intros h₁,\n  cases h₁ with B h₁,\n\n  -- so ⋂₀ A = ⋂₀ (a ⋂ B, a ∈ A)\n  let AB : set (set string) := (λ (x: set string), (∃ (a: set string), (e.FreeProp a) ∧ x = B ∩ a)),\n  have AB_finite: AB.finite,\n  {\n    let Bp : set (set string) := B.powerset,\n\n    have H1: AB ⊆ Bp, {\n      intros x hx,\n      rcases hx with ⟨ a, ⟨ b, c ⟩ ⟩,\n      rw c,\n      simp,\n    },\n    have H2 := finite_powerset h₁.2,\n    exact set.finite.subset H2 H1,\n  },\n\n  -- but B finite, so this becomes a finite set\n  have H: e.Free = ⋂₀ AB, {\n    have H₁: e.Free ⊆ ⋂₀ AB, {\n      intros a ha t ht, \n      apply ha,\n      rcases ht with ⟨ s, ⟨ hs, ht⟩⟩,\n      rw ht,\n      exact expression.FreeProp.intersection (⟨ h₁.1, hs ⟩),\n    },\n    have H₂: ⋂₀ AB ⊆ e.Free, {\n      intros a ha t ht, \n      have H: t ∩ B ∈ AB, {\n        use t,\n        split,\n        { exact ht, },\n        { exact set.inter_comm t B, },\n      },\n      exact set.mem_of_mem_inter_left (ha (t ∩ B) H),\n    },\n    exact subset_antisymm H₁ H₂,\n  },\n  rw H,\n\n  let prop : set (set string) → Prop := λ A, e.FreeProp (⋂₀ A),\n  have H₀: prop ∅, {\n    intros σ σ' h,\n    simp at h,\n    have H: σ = σ', { exact funext h, },\n    rw H,\n  }, \n  -- So get result by applying above theorem inductively\n  exact set.finite.induction_on' AB_finite (H₀) (by {\n    intros s A hs hA hs' hAi,\n    have H: ⋂₀ insert s A = ⋂₀ A ∩ s, {\n      ext,\n      split,\n      { finish, },\n      { finish, }\n    },\n    rw H,\n    rcases hs with ⟨ t, ⟨ ht, hs ⟩ ⟩,\n    exact expression.FreeProp.intersection (⟨ hAi, \n      (by { rw hs, exact expression.FreeProp.intersection (⟨h₁.1, ht⟩) }) \n    ⟩),\n  }),\nend\n\nlemma for_all_free_expression {e: expression} {σ σ': state } \n  (H: ∀ x ∈ e.Free, σ x = σ' x) (H₂: ∃ A, e.FreeProp A ∧ A.finite): e σ = e σ' :=\nbegin \n  -- if e σ ≠ e σ'\n  -- then must show ∃ x ∈ e.Free st σ x ≠ σ' x \n  -- ?\n\n  -- freeprop {x, y} freeprop {x, z} → freeprop {x}\n  -- show binary intersections\n  -- show infinite intersections\n  -- thus we have what we want\n  -- infinite intersections in lean?\n\n  have H₂: e.FreeProp e.Free, {\n    unfold expression.Free,\n    exact expression.FreeProp.infIntersection e H₂, \n  },\n  \n  unfold expression.FreeProp at H₂,\n  specialize H₂ σ σ',\n  simp at H₂,\n  exact H₂ H,\nend\n\nend IncLoLang\n", "meta": {"author": "AlfGalf", "repo": "Incorrectness_Logic", "sha": "991900a6447f66bfda6f153a247a5ac6a7cd1ab6", "save_path": "github-repos/lean/AlfGalf-Incorrectness_Logic", "path": "github-repos/lean/AlfGalf-Incorrectness_Logic/Incorrectness_Logic-991900a6447f66bfda6f153a247a5ac6a7cd1ab6/lean/language.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4900302511205189}}
{"text": "-- Chapter 9.3 From \"Articol metateoreme\"\n\nimport ProofMining.Proof\nimport ProofMining.Formula\nimport ProofMining.IntuitionisticRules\n\nopen Formula (falsum WellFormed)\nnamespace Proof\n\nset_option maxHeartbeats 1000000\n\ntheorem t19 (A B : Formula) \n  (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) :\n  e ;; Γ ⊢ (A ⋀ B ⟹ B) := \n  let p₁ : e ;; Γ ⊢ (A ⋀ B ⟹ B ⋀ A) := permConj\n  let p₂ : e ;; Γ ⊢ (B ⋀ A ⟹ B) := weakConj\n  syllogism p₁ p₂\n\ntheorem t20 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : e ;; Γ ⊢ (B ⟹ A ⋁ B) := \n  let p₁ : e ;; Γ ⊢ (B ⟹ B ⋁ A) := weakDisj \n  let p₂ : e ;; Γ ⊢ (B ⋁ A ⟹ A ⋁ B) := permDisj \n  syllogism p₁ p₂\n\ntheorem t21 (A : Formula) (_ : WellFormed e A := by autowf) : e ;; Γ ⊢ A ⟹ A :=\n  let p₁ : e ;; Γ ⊢ A ⟹ A ⋀ A := contrConj \n  let p₂ : e ;; Γ ⊢ A ⋀ A ⟹ A := weakConj \n  syllogism p₁ p₂\n\ntheorem t18 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : e ;; Γ ⊢ (∼A ⋀ A ⟹ B) :=\n  let p₁ : e ;; Γ ⊢ (falsum ⟹ B) := exFalso\n  let p₂ : e ;; Γ ⊢ ∼(∼A ⋀ A) := importation (t21 ∼A)\n  syllogism p₂ p₁\n\ntheorem t22 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ A ⟹ (B ⟹ (A ⋀ B)) :=\n  let p₁ : e ;; Γ ⊢ (A ⋀ B) ⟹ (A ⋀ B) := t21 _\n  exportation p₁\n\ntheorem t23 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ A ⟹ (B ⟹ A) :=\n  let p₁ : e ;; Γ ⊢ (A ⋀ B) ⟹ A := weakConj\n  exportation p₁ \n\ntheorem t24 (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; Γ ⊢ (A ⟹ ∼∼A) :=\n  let p₁ : e ;; Γ ⊢ (A ⋀ ∼A ⟹ ∼A ⋀ A) := permConj \n  let p₂ : e ;; Γ ⊢ ∼(A ⋀ ∼A) := syllogism p₁ (t18 A falsum)\n  exportation p₂\n\ntheorem t26a (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; Γ ⊢ ∼A ⟹ ∼∼∼A :=\n  t24 ∼A\n\ntheorem t26b (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; Γ ⊢ ∼∼∼A ⟹ ∼A :=\n  let p₁ : e ;; Γ ⊢ A ⟹ ∼∼∼∼A := syllogism (t24 _) (t24 _)\n  let p₂ : e ;; Γ ⊢ ∼∼∼A ⋀ A ⟹ falsum := syllogism (permConj) (importation p₁)\n  exportation p₂\n\ntheorem t28a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ ∼∼(A ⟹ B) ⟹ (∼∼A ⟹ ∼∼B) :=\n  sorry\n\ntheorem t28b (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ (∼∼A ⟹ ∼∼B) ⟹ ∼∼(A ⟹ B) :=\n  let p₁ : e ;; Γ ⊢ (A ⟹ B) ⟹ ∼∼A ⟹ (A ⟹ B) := t23 _ _\n  let p₂ : e ;; Γ ⊢ (A ⟹ B) ⋀ ∼∼A ⋀ A ⟹ ∼∼B := syllogism (importation (importation p₁)) (t24 B)\n  let p₃ : e ;; Γ ⊢ (A ⟹ B) ⋀ ∼∼A ⟹ (A ⟹ B) ⋀ ∼∼A ⋀ A := sorry\n  let p₄ : e ;; Γ ⊢ (A ⟹ B) ⋀ ∼∼A ⟹ ∼∼B := syllogism p₃ p₂\n  -- let p₅ (h₁: Γ ⊢ A ⟹ B) : Γ ⊢ ∼A ⟹ ∼B := sorry\n  let p₆ : e ;; Γ ⊢ (A ⟹ B) ⟹ (∼∼A ⟹ ∼∼B) := exportation p₄\n  let p₇ : e ;; Γ ⊢ ∼(A ⟹ B) ⟹ ∼(∼∼A ⟹ ∼∼B) := sorry\n  sorry\n\ntheorem t27a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ ∼∼(A ⟹ B) ⟹ (A ⟹ ∼∼B) :=\n  let p₀ : e ;; Γ ⊢ (∼∼(A ⟹ B)) ⋀ ∼∼A ⟹ ∼∼B := importation (t28a _ _)\n  let p₁ : e ;; Γ ⊢ ∼∼A ⋀ (∼∼(A ⟹ B)) ⟹ (∼∼(A ⟹ B)) ⋀ ∼∼A := permConj\n  let p₂ : e ;; Γ ⊢ ∼∼A ⋀ (∼∼(A ⟹ B)) ⟹ ∼∼B := syllogism p₁ p₀\n  let p₃ : e ;; Γ ⊢ ∼∼A ⟹ ∼∼(A ⟹ B) ⟹ ∼∼B := exportation p₂\n  let p₄ : e ;; Γ ⊢ A ⟹ ∼∼(A ⟹ B) ⟹ ∼∼B := syllogism (t24 _) p₃\n  exportation (syllogism (permConj) (importation p₄))\n\n-- theorem t27b (A B : Formula) : Γ ⊢ (A ⟹ ∼∼B) ⟹ ∼∼(A ⟹ B) :=\n--   sorry\n\ntheorem t29a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ (A ⟹ ∼B) ⟹ (∼∼A ⟹ ∼B) :=\n  let p₁ : e ;; Γ ⊢ (A ⟹ ∼B) ⟹ (∼∼A ⟹ ∼∼∼B) := syllogism (t24 _) (t28a _ _)\n  let p₂ : e ;; Γ ⊢ (∼∼A ⟹ ∼∼∼B) ⟹ (∼∼A ⟹ ∼B) := exportation (syllogism (importation (t21 _)) (t26b _))\n  syllogism p₁ p₂\n\n-- theorem t29b (A B : Formula) : Γ ⊢ (∼∼A ⟹ ∼B) ⟹ (A ⟹ ∼B) :=\n--   sorry\n\n-- theorem t30a (A B : Formula) : Γ ⊢ ∼∼(A ⋀ B) ⟹ (∼∼A ⋀ ∼∼B) :=\n--   sorry\n\n-- theorem t30b (A B : Formula) : Γ ⊢ (∼∼A ⋀ ∼∼B) ⟹ ∼∼(A ⋀ B) :=\n--   sorry\n\n-- theorem t31 (A B : Formula) : Γ ⊢ ∼∼(A ⋁ B) ⟹ ∼∼A ⟹ ∼∼B :=\n--   sorry\n\n-- theorem t32a (A B : Formula) : Γ ⊢ ∼∼(A ⋁ B) ⟹ ∼∼(∼A ⋀ ∼B) :=\n--   sorry\n\ntheorem t32b (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ ∼(∼A ⋀ ∼B) ⟹ ∼∼(A ⋁ B) :=\n  sorry\n\ntheorem t25 (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; Γ ⊢ ∼∼(A ⋁ ∼A) := \n  let p₁ : e ;; Γ ⊢ ∼(∼A ⋀ ∼∼A) := syllogism (permConj) (t18 _ _)\n  mpon p₁ (t32b _ _)\n\ntheorem t33a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ ∼(A ⋀ B) ⟹ A ⟹ ∼B :=\n  let p₁ : e ;; Γ ⊢ ∼(A ⋀ B) ⋀ (A ⋀ B) ⟹ falsum := t18 _ _\n  let p₂ : e ;; Γ ⊢ (B ⟹ ∼∼(A ⋀ B)) ⟹ ∼(A ⋀ B) ⟹ ∼B := sorry\n  sorry\n\ntheorem t33b (A B : Formula) : e ;; Γ ⊢ (A ⟹ ∼B) ⟹ ∼(A ⋀ B) :=\n  sorry\n\ntheorem t35 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) :\n  e ;; Γ ⊢ A ⋁ B ⟹ ∼A ⟹ B :=\n  let p₁ : e ;; Γ ⊢ ∼A ⋀ A ⟹ B := t18 _ _\n  let p₂ : e ;; Γ ⊢ A ⟹ ∼A ⟹ B := exportation (syllogism (permConj) p₁)\n  let p₃ : e ;; Γ ⊢ B ⟹ ∼A ⟹ B := t23 _ _\n  r49 p₂ p₃\n\ntheorem t40a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ ∼(A ⋁ B) ⟹ (∼A ⋀ ∼B) :=\n  let p₃ : e ;; Γ ⊢ A ⟹ ∼∼ (A ⋁ B) := syllogism (weakDisj) (t24 (A ⋁ B))\n  let p₄ : e ;; Γ ⊢ ∼(A ⋁ B) ⋀ A ⟹ falsum := syllogism (permConj) (importation p₃)\n  let p₁ : e ;; Γ ⊢ ∼(A ⋁ B) ⟹ ∼A := exportation p₄\n  let p₅ : e ;; Γ ⊢ B ⟹ ∼∼ (A ⋁ B) := syllogism (t20 A B) (t24 (A ⋁ B))\n  let p₆ : e ;; Γ ⊢ ∼(A ⋁ B) ⋀ B ⟹ falsum := syllogism (permConj) (importation p₅)\n  let p₂ : e ;; Γ ⊢ ∼(A ⋁ B) ⟹ ∼B := exportation p₆\n  r45 p₁ p₂\n\ntheorem t40b (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; Γ ⊢ (∼A ⋀ ∼B) ⟹ ∼(A ⋁ B) :=\n  let p₁ : e ;; Γ ⊢ A ⟹ ∼A ⟹ ∼∼B := exportation (syllogism (permConj) (t18 _ _))\n  let p₂ : e ;; Γ ⊢ B ⟹ ∼A ⟹ ∼∼B := exportation (syllogism (permConj) (importation (r44 (t24 _))))\n  let p₃ : e ;; Γ ⊢ A ⋁ B ⟹ ∼A ⟹ ∼∼B := r49 p₁ p₂\n  let p₄ : e ;; Γ ⊢ (∼A ⟹ ∼∼B) ⟹ ∼(∼A ⋀ ∼B) := t33b _ _\n  let p₅ : e ;; Γ ⊢ A ⋁ B ⟹ ∼(∼A ⋀ ∼B) := syllogism p₃ p₄\n  exportation (syllogism (permConj) (importation p₅))", "meta": {"author": "alecvv", "repo": "proof-mining.preview", "sha": "5497aa694b77b4f45b5063a00d23574e0bebed6f", "save_path": "github-repos/lean/alecvv-proof-mining.preview", "path": "github-repos/lean/alecvv-proof-mining.preview/proof-mining.preview-5497aa694b77b4f45b5063a00d23574e0bebed6f/ProofMining/IntuitionisticTheorems.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4900302477199527}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.shapes.finite_limits\nimport category_theory.limits.shapes.products\nimport category_theory.limits.shapes.terminal\n\n/-!\n# Categories with finite (co)products\n\nTypeclasses representing categories with (co)products over finite indexing types.\n-/\n\nuniverses w v u\n\nopen category_theory\nopen_locale classical\n\nnamespace category_theory.limits\n\nvariables (C : Type u) [category.{v} C]\n\n/--\nA category has finite products if there is a chosen limit for every diagram\nwith shape `discrete J`, where we have `[fintype J]`.\n-/\n-- We can't simply make this an abbreviation, as we do with other `has_Xs` limits typeclasses,\n-- because of https://github.com/leanprover-community/lean/issues/429\nclass has_finite_products : Prop :=\n(out (J : Type) [fintype J] : has_limits_of_shape (discrete J) C)\n\ninstance has_limits_of_shape_discrete\n  (J : Type) [fintype J] [has_finite_products C] :\n  has_limits_of_shape (discrete J) C :=\nby { haveI := @has_finite_products.out C _ _ J, apply_instance }\n\n/-- If `C` has finite limits then it has finite products. -/\n@[priority 10]\ninstance has_finite_products_of_has_finite_limits [has_finite_limits C] :\n  has_finite_products C :=\n⟨λ J 𝒥, by { resetI, apply_instance }⟩\n\ninstance has_fintype_products [has_finite_products C] (ι : Type w) [fintype ι] :\n  has_limits_of_shape (discrete ι) C :=\nhas_limits_of_shape_of_equivalence\n  (discrete.equivalence\n    ((show ulift.{0} (fin (fintype.card ι)) ≃ fin (fintype.card ι), by tidy).trans\n      (fintype.equiv_fin ι).symm))\n\n/-- We can now write this for powers. -/\nnoncomputable example [has_finite_products C] (X : C) : C := ∏ (λ (i : fin 5), X)\n\n/--\nIf a category has all products then in particular it has finite products.\n-/\nlemma has_finite_products_of_has_products [has_products.{w} C] : has_finite_products C :=\n⟨λ J _, has_limits_of_shape_of_equivalence (discrete.equivalence (equiv.ulift.{w}))⟩\n\n/--\nA category has finite coproducts if there is a chosen colimit for every diagram\nwith shape `discrete J`, where we have `[fintype J]`.\n-/\nclass has_finite_coproducts : Prop :=\n(out (J : Type) [fintype J] : has_colimits_of_shape (discrete J) C)\n\nattribute [class] has_finite_coproducts\n\ninstance has_colimits_of_shape_discrete\n  (J : Type) [fintype J] [has_finite_coproducts C] :\n  has_colimits_of_shape (discrete J) C :=\nby { haveI := @has_finite_coproducts.out C _ _ J, apply_instance }\n\n/-- If `C` has finite colimits then it has finite coproducts. -/\n@[priority 10]\ninstance has_finite_coproducts_of_has_finite_colimits [has_finite_colimits C] :\n  has_finite_coproducts C :=\n⟨λ J 𝒥, by { resetI, apply_instance }⟩\n\ninstance has_fintype_coproducts [has_finite_coproducts C] (ι : Type w) [fintype ι] :\n  has_colimits_of_shape (discrete ι) C :=\nhas_colimits_of_shape_of_equivalence\n  (discrete.equivalence\n    ((show ulift.{0} (fin (fintype.card ι)) ≃ fin (fintype.card ι), by tidy).trans\n      (fintype.equiv_fin ι).symm))\n\n/--\nIf a category has all coproducts then in particular it has finite coproducts.\n-/\nlemma has_finite_coproducts_of_has_coproducts [has_coproducts.{w} C] : has_finite_coproducts C :=\n⟨λ J _, has_colimits_of_shape_of_equivalence (discrete.equivalence (equiv.ulift.{w}))⟩\n\nend category_theory.limits\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/category_theory/limits/shapes/finite_products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4900302477199527}}
{"text": "example (P Q R S T U: Type)\n(p : P)\n(h : P → Q)\n(i : Q → R)\n(j : Q → T)\n(k : S → T)\n(l : T → U)\n: U :=\nbegin\nhave q := h(p),\nhave t := j(q),\nexact l(t),\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world05/level03.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.49003023732845147}}
{"text": "import data.fintype.basic\n\nnamespace finset\nvariables {α β : Type*} [decidable_eq β]\n\nlemma image_subtype_ne_univ_eq_image_erase [fintype α] (k : β) (b : α → β) :\n  image (λ i : {a // b a ≠ k}, b ↑i) univ = (image b univ).erase k :=\nbegin\n  apply subset_antisymm,\n  { rw image_subset_iff,\n    intros i _,\n    apply mem_erase_of_ne_of_mem i.2 (mem_image_of_mem _ (mem_univ _)) },\n  { intros i hi,\n    rw mem_image,\n    rcases mem_image.1 (erase_subset _ _ hi) with ⟨a, _, ha⟩,\n    subst ha,\n    exact ⟨⟨a, ne_of_mem_erase hi⟩, mem_univ _, rfl⟩ }\nend\n\nlemma image_subtype_univ_ssubset_image_univ [fintype α] (k : β) (b : α → β)\n  (hk : k ∈ image b univ) (p : β → Prop) [decidable_pred p] (hp : ¬ p k) :\n  image (λ i : {a // p (b a)}, b ↑i) univ ⊂ image b univ :=\nbegin\n  split,\n  { intros x hx,\n    rcases mem_image.1 hx with ⟨y, _, hy⟩,\n    exact hy ▸ mem_image_of_mem b (mem_univ y) },\n  { intros h,\n    rw mem_image at hk,\n    rcases hk with ⟨k', _, hk'⟩, subst hk',\n    have := h (mem_image_of_mem b (mem_univ k')),\n    rw mem_image at this,\n    rcases this with ⟨j, hj, hj'⟩,\n    exact hp (hj' ▸ j.2) }\nend\n\nend finset", "meta": {"author": "verified-optimization", "repo": "optlib", "sha": "b5d69678be5a4be8284ed15d376d6d973c64ea72", "save_path": "github-repos/lean/verified-optimization-optlib", "path": "github-repos/lean/verified-optimization-optlib/optlib-b5d69678be5a4be8284ed15d376d6d973c64ea72/src/missing/data/fintype/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.4900302303375168}}
{"text": "/-\nCopyright (c) 2021 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport geometry.manifold.algebra.structures\nimport geometry.manifold.bump_function\nimport topology.paracompact\nimport topology.partition_of_unity\nimport topology.shrinking_lemma\n\n/-!\n# Smooth partition of unity\n\nIn this file we define two structures, `smooth_bump_covering` and `smooth_partition_of_unity`. Both\nstructures describe coverings of a set by a locally finite family of supports of smooth functions\nwith some additional properties. The former structure is mostly useful as an intermediate step in\nthe construction of a smooth partition of unity but some proofs that traditionally deal with a\npartition of unity can use a `smooth_bump_covering` as well.\n\nGiven a real manifold `M` and its subset `s`, a `smooth_bump_covering ι I M s` is a collection of\n`smooth_bump_function`s `f i` indexed by `i : ι` such that\n\n* the center of each `f i` belongs to `s`;\n* the family of sets `support (f i)` is locally finite;\n* for each `x ∈ s`, there exists `i : ι` such that `f i =ᶠ[𝓝 x] 1`.\nIn the same settings, a `smooth_partition_of_unity ι I M s` is a collection of smooth nonnegative\nfunctions `f i : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯`, `i : ι`, such that\n\n* the family of sets `support (f i)` is locally finite;\n* for each `x ∈ s`, the sum `∑ᶠ i, f i x` equals one;\n* for each `x`, the sum `∑ᶠ i, f i x` is less than or equal to one.\n\nWe say that `f : smooth_bump_covering ι I M s` is *subordinate* to a map `U : M → set M` if for each\nindex `i`, we have `closure (support (f i)) ⊆ U (f i).c`. This notion is a bit more general than\nbeing subordinate to an open covering of `M`, because we make no assumption about the way `U x`\ndepends on `x`.\n\nWe prove that on a smooth finitely dimensional real manifold with `σ`-compact Hausdorff topology,\nfor any `U : M → set M` such that `∀ x ∈ s, U x ∈ 𝓝 x` there exists a `smooth_bump_covering ι I M s`\nsubordinate to `U`. Then we use this fact to prove a similar statement about smooth partitions of\nunity.\n\n## Implementation notes\n\n\n\n## TODO\n\n* Build a framework for to transfer local definitions to global using partition of unity and use it\n  to define, e.g., the integral of a differential form over a manifold.\n\n## Tags\n\nsmooth bump function, partition of unity\n-/\n\nuniverses uι uE uH uM\n\nopen function filter finite_dimensional set\nopen_locale topological_space manifold classical filter big_operators\n\nnoncomputable theory\n\nvariables {ι : Type uι}\n{E : Type uE} [normed_group E] [normed_space ℝ E] [finite_dimensional ℝ E]\n{H : Type uH} [topological_space H] (I : model_with_corners ℝ E H)\n{M : Type uM} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M]\n\n/-!\n### Covering by supports of smooth bump functions\n\nIn this section we define `smooth_bump_covering ι I M s` to be a collection of\n`smooth_bump_function`s such that their supports is a locally finite family of sets and for each `x\n∈ s` some function `f i` from the collection is equal to `1` in a neighborhood of `x`. A covering of\nthis type is useful to construct a smooth partition of unity and can be used instead of a partition\nof unity in some proofs.\n\nWe prove that on a smooth finite dimensional real manifold with `σ`-compact Hausdorff topology, for\nany `U : M → set M` such that `∀ x ∈ s, U x ∈ 𝓝 x` there exists a `smooth_bump_covering ι I M s`\nsubordinate to `U`. Then we use this fact to prove a version of the Whitney embedding theorem: any\ncompact real manifold can be embedded into `ℝ^n` for large enough `n`.  -/\n\nvariables (ι M)\n\n/-- We say that a collection of `smooth_bump_function`s is a `smooth_bump_covering` of a set `s` if\n\n* `(f i).c ∈ s` for all `i`;\n* the family `λ i, support (f i)` is locally finite;\n* for each point `x ∈ s` there exists `i` such that `f i =ᶠ[𝓝 x] 1`;\n  in other words, `x` belongs to the interior of `{y | f i y = 1}`;\n\nIf `M` is a finite dimensional real manifold which is a sigma-compact Hausdorff topological space,\nthen for every covering `U : M → set M`, `∀ x, U x ∈ 𝓝 x`, there exists a `smooth_bump_covering`\nsubordinate to `U`, see `smooth_bump_covering.exists_is_subordinate`.\n\nThis covering can be used, e.g., to construct a partition of unity and to prove the weak\nWhitney embedding theorem. -/\n@[nolint has_inhabited_instance]\nstructure smooth_bump_covering (s : set M := univ) :=\n(c : ι → M)\n(to_fun : Π i, smooth_bump_function I (c i))\n(c_mem' : ∀ i, c i ∈ s)\n(locally_finite' : locally_finite (λ i, support (to_fun i)))\n(eventually_eq_one' : ∀ x ∈ s, ∃ i, to_fun i =ᶠ[𝓝 x] 1)\n\n/-- We say that that a collection of functions form a smooth partition of unity on a set `s` if\n\n* all functions are infinitely smooth and nonnegative;\n* the family `λ i, support (f i)` is locally finite;\n* for all `x ∈ s` the sum `∑ᶠ i, f i x` equals one;\n* for all `x`, the sum `∑ᶠ i, f i x` is less than or equal to one. -/\nstructure smooth_partition_of_unity (s : set M := univ) :=\n(to_fun : ι → C^∞⟮I, M; 𝓘(ℝ), ℝ⟯)\n(locally_finite' : locally_finite (λ i, support (to_fun i)))\n(nonneg' : ∀ i x, 0 ≤ to_fun i x)\n(sum_eq_one' : ∀ x ∈ s, ∑ᶠ i, to_fun i x = 1)\n(sum_le_one' : ∀ x, ∑ᶠ i, to_fun i x ≤ 1)\n\nvariables {ι I M}\n\nnamespace smooth_partition_of_unity\n\nvariables {s : set M} (f : smooth_partition_of_unity ι I M s)\n\ninstance {s : set M} : has_coe_to_fun (smooth_partition_of_unity ι I M s)\n  (λ _, ι → C^∞⟮I, M; 𝓘(ℝ), ℝ⟯) :=\n⟨smooth_partition_of_unity.to_fun⟩\n\nprotected lemma locally_finite : locally_finite (λ i, support (f i)) :=\nf.locally_finite'\n\nlemma nonneg (i : ι) (x : M) : 0 ≤ f i x := f.nonneg' i x\n\nlemma sum_eq_one {x} (hx : x ∈ s) : ∑ᶠ i, f i x = 1 := f.sum_eq_one' x hx\n\nlemma sum_le_one (x : M) : ∑ᶠ i, f i x ≤ 1 := f.sum_le_one' x\n\n/-- Reinterpret a smooth partition of unity as a continuous partition of unity. -/\ndef to_partition_of_unity : partition_of_unity ι M s :=\n{ to_fun := λ i, f i, .. f }\n\nlemma smooth_sum : smooth I 𝓘(ℝ) (λ x, ∑ᶠ i, f i x) :=\nsmooth_finsum (λ i, (f i).smooth) f.locally_finite\n\nlemma le_one (i : ι) (x : M) : f i x ≤ 1 := f.to_partition_of_unity.le_one i x\n\nlemma sum_nonneg (x : M) : 0 ≤ ∑ᶠ i, f i x := f.to_partition_of_unity.sum_nonneg x\n\n/-- A smooth partition of unity `f i` is subordinate to a family of sets `U i` indexed by the same\ntype if for each `i` the closure of the support of `f i` is a subset of `U i`. -/\ndef is_subordinate (f : smooth_partition_of_unity ι I M s) (U : ι → set M) :=\n∀ i, closure (support (f i)) ⊆ U i\n\n@[simp] lemma is_subordinate_to_partition_of_unity {f : smooth_partition_of_unity ι I M s}\n  {U : ι → set M} :\n  f.to_partition_of_unity.is_subordinate U ↔ f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_partition_of_unity ↔\n  _ smooth_partition_of_unity.is_subordinate.to_partition_of_unity\n\nend smooth_partition_of_unity\n\nnamespace bump_covering\n\n-- Repeat variables to drop [finite_dimensional ℝ E] and [smooth_manifold_with_corners I M]\nlemma smooth_to_partition_of_unity {E : Type uE} [normed_group E] [normed_space ℝ E]\n  {H : Type uH} [topological_space H] {I : model_with_corners ℝ E H}\n  {M : Type uM} [topological_space M] [charted_space H M] {s : set M}\n  (f : bump_covering ι M s) (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) (i : ι) :\n  smooth I 𝓘(ℝ) (f.to_partition_of_unity i) :=\n(hf i).mul $ smooth_finprod_cond (λ j _, smooth_const.sub (hf j)) $\n  by { simp only [mul_support_one_sub], exact f.locally_finite }\n\nvariables {s : set M}\n\n/-- A `bump_covering` such that all functions in this covering are smooth generates a smooth\npartition of unity.\n\nIn our formalization, not every `f : bump_covering ι M s` with smooth functions `f i` is a\n`smooth_bump_covering`; instead, a `smooth_bump_covering` is a covering by supports of\n`smooth_bump_function`s. So, we define `bump_covering.to_smooth_partition_of_unity`, then reuse it\nin `smooth_bump_covering.to_smooth_partition_of_unity`. -/\ndef to_smooth_partition_of_unity (f : bump_covering ι M s) (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) :\n  smooth_partition_of_unity ι I M s :=\n{ to_fun := λ i, ⟨f.to_partition_of_unity i, f.smooth_to_partition_of_unity hf i⟩,\n  .. f.to_partition_of_unity }\n\n@[simp] lemma to_smooth_partition_of_unity_to_partition_of_unity (f : bump_covering ι M s)\n  (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) :\n  (f.to_smooth_partition_of_unity hf).to_partition_of_unity = f.to_partition_of_unity :=\nrfl\n\n@[simp] lemma coe_to_smooth_partition_of_unity (f : bump_covering ι M s)\n  (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) (i : ι) :\n  ⇑(f.to_smooth_partition_of_unity hf i) = f.to_partition_of_unity i :=\nrfl\n\nlemma is_subordinate.to_smooth_partition_of_unity {f : bump_covering ι M s}\n  {U : ι → set M} (h : f.is_subordinate U) (hf : ∀ i, smooth I 𝓘(ℝ) (f i)) :\n  (f.to_smooth_partition_of_unity hf).is_subordinate U :=\nh.to_partition_of_unity\n\nend bump_covering\n\nnamespace smooth_bump_covering\n\nvariables {s : set M} {U : M → set M} (fs : smooth_bump_covering ι I M s) {I}\n\ninstance : has_coe_to_fun (smooth_bump_covering ι I M s)\n  (λ x, Π (i : ι), smooth_bump_function I (x.c i)) :=\n⟨to_fun⟩\n\n@[simp] lemma coe_mk (c : ι → M) (to_fun : Π i, smooth_bump_function I (c i))\n  (h₁ h₂ h₃) : ⇑(mk c to_fun h₁ h₂ h₃ : smooth_bump_covering ι I M s) = to_fun :=\nrfl\n\n/--\nWe say that `f : smooth_bump_covering ι I M s` is *subordinate* to a map `U : M → set M` if for each\nindex `i`, we have `closure (support (f i)) ⊆ U (f i).c`. This notion is a bit more general than\nbeing subordinate to an open covering of `M`, because we make no assumption about the way `U x`\ndepends on `x`.\n-/\ndef is_subordinate {s : set M} (f : smooth_bump_covering ι I M s) (U : M → set M) :=\n∀ i, closure (support $ f i) ⊆ U (f.c i)\n\nlemma is_subordinate.support_subset {fs : smooth_bump_covering ι I M s} {U : M → set M}\n  (h : fs.is_subordinate U) (i : ι) :\n  support (fs i) ⊆ U (fs.c i) :=\nsubset.trans subset_closure (h i)\n\nvariable (I)\n\n/-- Let `M` be a smooth manifold with corners modelled on a finite dimensional real vector space.\nSuppose also that `M` is a Hausdorff `σ`-compact topological space. Let `s` be a closed set\nin `M` and `U : M → set M` be a collection of sets such that `U x ∈ 𝓝 x` for every `x ∈ s`.\nThen there exists a smooth bump covering of `s` that is subordinate to `U`. -/\nlemma exists_is_subordinate [t2_space M] [sigma_compact_space M] (hs : is_closed s)\n  (hU : ∀ x ∈ s, U x ∈ 𝓝 x) :\n  ∃ (ι : Type uM) (f : smooth_bump_covering ι I M s), f.is_subordinate U :=\nbegin\n  -- First we deduce some missing instances\n  haveI : locally_compact_space H := I.locally_compact,\n  haveI : locally_compact_space M := charted_space.locally_compact H,\n  haveI : normal_space M := normal_of_paracompact_t2,\n  -- Next we choose a covering by supports of smooth bump functions\n  have hB := λ x hx, smooth_bump_function.nhds_basis_support I (hU x hx),\n  rcases refinement_of_locally_compact_sigma_compact_of_nhds_basis_set hs hB\n    with ⟨ι, c, f, hf, hsub', hfin⟩, choose hcs hfU using hf,\n  /- Then we use the shrinking lemma to get a covering by smaller open -/\n  rcases exists_subset_Union_closed_subset hs (λ i, (f i).open_support)\n    (λ x hx, hfin.point_finite x) hsub' with ⟨V, hsV, hVc, hVf⟩,\n  choose r hrR hr using λ i, (f i).exists_r_pos_lt_subset_ball (hVc i) (hVf i),\n  refine ⟨ι, ⟨c, λ i, (f i).update_r (r i) (hrR i), hcs, _, λ x hx, _⟩, λ i, _⟩,\n  { simpa only [smooth_bump_function.support_update_r] },\n  { refine (mem_Union.1 $ hsV hx).imp (λ i hi, _),\n    exact ((f i).update_r _ _).eventually_eq_one_of_dist_lt\n      ((f i).support_subset_source $ hVf _ hi) (hr i hi).2 },\n  { simpa only [coe_mk, smooth_bump_function.support_update_r] using hfU i }\nend\n\nvariables {I M}\n\nprotected lemma locally_finite : locally_finite (λ i, support (fs i)) := fs.locally_finite'\n\nprotected lemma point_finite (x : M) : {i | fs i x ≠ 0}.finite :=\nfs.locally_finite.point_finite x\n\nlemma mem_chart_at_source_of_eq_one {i : ι} {x : M} (h : fs i x = 1) :\n  x ∈ (chart_at H (fs.c i)).source :=\n(fs i).support_subset_source $ by simp [h]\n\nlemma mem_ext_chart_at_source_of_eq_one {i : ι} {x : M} (h : fs i x = 1) :\n  x ∈ (ext_chart_at I (fs.c i)).source :=\nby { rw ext_chart_at_source, exact fs.mem_chart_at_source_of_eq_one h }\n\n/-- Index of a bump function such that `fs i =ᶠ[𝓝 x] 1`. -/\ndef ind (x : M) (hx : x ∈ s) : ι := (fs.eventually_eq_one' x hx).some\n\nlemma eventually_eq_one (x : M) (hx : x ∈ s) : fs (fs.ind x hx) =ᶠ[𝓝 x] 1 :=\n(fs.eventually_eq_one' x hx).some_spec\n\nlemma apply_ind (x : M) (hx : x ∈ s) : fs (fs.ind x hx) x = 1 :=\n(fs.eventually_eq_one x hx).eq_of_nhds\n\nlemma mem_support_ind (x : M) (hx : x ∈ s) : x ∈ support (fs $ fs.ind x hx) :=\nby simp [fs.apply_ind x hx]\n\nlemma mem_chart_at_ind_source (x : M) (hx : x ∈ s) :\n  x ∈ (chart_at H (fs.c (fs.ind x hx))).source :=\nfs.mem_chart_at_source_of_eq_one (fs.apply_ind x hx)\n\nlemma mem_ext_chart_at_ind_source (x : M) (hx : x ∈ s) :\n  x ∈ (ext_chart_at I (fs.c (fs.ind x hx))).source :=\nfs.mem_ext_chart_at_source_of_eq_one (fs.apply_ind x hx)\n\n/-- The index type of a `smooth_bump_covering` of a compact manifold is finite. -/\nprotected def fintype [compact_space M] : fintype ι :=\nfs.locally_finite.fintype_of_compact $ λ i, (fs i).nonempty_support\n\nvariable [t2_space M]\n\n/-- Reinterpret a `smooth_bump_covering` as a continuous `bump_covering`. Note that not every\n`f : bump_covering ι M s` with smooth functions `f i` is a `smooth_bump_covering`. -/\ndef to_bump_covering : bump_covering ι M s :=\n{ to_fun := λ i, ⟨fs i, (fs i).continuous⟩,\n  locally_finite' := fs.locally_finite,\n  nonneg' := λ i x, (fs i).nonneg,\n  le_one' := λ i x, (fs i).le_one,\n  eventually_eq_one' := fs.eventually_eq_one' }\n\n@[simp] lemma is_subordinate_to_bump_covering {f : smooth_bump_covering ι I M s} {U : M → set M} :\n  f.to_bump_covering.is_subordinate (λ i, U (f.c i)) ↔ f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_bump_covering ↔\n  _ smooth_bump_covering.is_subordinate.to_bump_covering\n\n/-- Every `smooth_bump_covering` defines a smooth partition of unity. -/\ndef to_smooth_partition_of_unity : smooth_partition_of_unity ι I M s :=\nfs.to_bump_covering.to_smooth_partition_of_unity (λ i, (fs i).smooth)\n\nlemma to_smooth_partition_of_unity_apply (i : ι) (x : M) :\n  fs.to_smooth_partition_of_unity i x = fs i x * ∏ᶠ j (hj : well_ordering_rel j i), (1 - fs j x) :=\nrfl\n\nlemma to_smooth_partition_of_unity_eq_mul_prod (i : ι) (x : M) (t : finset ι)\n  (ht : ∀ j, well_ordering_rel j i → fs j x ≠ 0 → j ∈ t) :\n  fs.to_smooth_partition_of_unity i x =\n    fs i x * ∏ j in t.filter (λ j, well_ordering_rel j i), (1 - fs j x) :=\nfs.to_bump_covering.to_partition_of_unity_eq_mul_prod i x t ht\n\nlemma exists_finset_to_smooth_partition_of_unity_eventually_eq (i : ι) (x : M) :\n  ∃ t : finset ι, fs.to_smooth_partition_of_unity i =ᶠ[𝓝 x]\n    fs i * ∏ j in t.filter (λ j, well_ordering_rel j i), (1 - fs j) :=\nfs.to_bump_covering.exists_finset_to_partition_of_unity_eventually_eq i x\n\nlemma to_smooth_partition_of_unity_zero_of_zero {i : ι} {x : M} (h : fs i x = 0) :\n  fs.to_smooth_partition_of_unity i x = 0 :=\nfs.to_bump_covering.to_partition_of_unity_zero_of_zero h\n\nlemma support_to_smooth_partition_of_unity_subset (i : ι) :\n  support (fs.to_smooth_partition_of_unity i) ⊆ support (fs i) :=\nfs.to_bump_covering.support_to_partition_of_unity_subset i\n\nlemma is_subordinate.to_smooth_partition_of_unity {f : smooth_bump_covering ι I M s} {U : M → set M}\n  (h : f.is_subordinate U) :\n  f.to_smooth_partition_of_unity.is_subordinate (λ i, U (f.c i)) :=\nh.to_bump_covering.to_partition_of_unity\n\nlemma sum_to_smooth_partition_of_unity_eq (x : M) :\n  ∑ᶠ i, fs.to_smooth_partition_of_unity i x = 1 - ∏ᶠ i, (1 - fs i x) :=\nfs.to_bump_covering.sum_to_partition_of_unity_eq x\n\nend smooth_bump_covering\n\nvariable (I)\n\n/-- Given two disjoint closed sets in a Hausdorff σ-compact finite dimensional manifold, there\nexists an infinitely smooth function that is equal to `0` on one of them and is equal to one on the\nother. -/\nlemma exists_smooth_zero_one_of_closed [t2_space M] [sigma_compact_space M] {s t : set M}\n  (hs : is_closed s) (ht : is_closed t) (hd : disjoint s t) :\n  ∃ f : C^∞⟮I, M; 𝓘(ℝ), ℝ⟯, eq_on f 0 s ∧ eq_on f 1 t ∧ ∀ x, f x ∈ Icc (0 : ℝ) 1 :=\nbegin\n  have : ∀ x ∈ t, sᶜ ∈ 𝓝 x, from λ x hx, hs.is_open_compl.mem_nhds (disjoint_right.1 hd hx),\n  rcases smooth_bump_covering.exists_is_subordinate I ht this with ⟨ι, f, hf⟩,\n  set g := f.to_smooth_partition_of_unity,\n  refine ⟨⟨_, g.smooth_sum⟩, λ x hx, _, λ x, g.sum_eq_one, λ x, ⟨g.sum_nonneg x, g.sum_le_one x⟩⟩,\n  suffices : ∀ i, g i x = 0,\n    by simp only [this, times_cont_mdiff_map.coe_fn_mk, finsum_zero, pi.zero_apply],\n  refine λ i, f.to_smooth_partition_of_unity_zero_of_zero _,\n  exact nmem_support.1 (subset_compl_comm.1 (hf.support_subset i) hx)\nend\n\nvariable {I}\n\nnamespace smooth_partition_of_unity\n\n/-- A `smooth_partition_of_unity` that consists of a single function, uniformly equal to one,\ndefined as an example for `inhabited` instance. -/\ndef single (i : ι) (s : set M) : smooth_partition_of_unity ι I M s :=\n(bump_covering.single i s).to_smooth_partition_of_unity $ λ j,\n  begin\n    rcases eq_or_ne j i with rfl|h,\n    { simp only [smooth_one, continuous_map.coe_one, bump_covering.coe_single, pi.single_eq_same] },\n    { simp only [smooth_zero, bump_covering.coe_single, pi.single_eq_of_ne h,\n        continuous_map.coe_zero] }\n  end\n\ninstance [inhabited ι] (s : set M) : inhabited (smooth_partition_of_unity ι I M s) :=\n⟨single (default ι) s⟩\n\nvariables [t2_space M] [sigma_compact_space M]\n\n/-- If `X` is a paracompact normal topological space and `U` is an open covering of a closed set\n`s`, then there exists a `bump_covering ι X s` that is subordinate to `U`. -/\nlemma exists_is_subordinate {s : set M} (hs : is_closed s) (U : ι → set M) (ho : ∀ i, is_open (U i))\n  (hU : s ⊆ ⋃ i, U i) :\n  ∃ f : smooth_partition_of_unity ι I M s, f.is_subordinate U :=\nbegin\n  haveI : locally_compact_space H := I.locally_compact,\n  haveI : locally_compact_space M := charted_space.locally_compact H,\n  haveI : normal_space M := normal_of_paracompact_t2,\n  rcases bump_covering.exists_is_subordinate_of_prop (smooth I 𝓘(ℝ)) _ hs U ho hU\n    with ⟨f, hf, hfU⟩,\n  { exact ⟨f.to_smooth_partition_of_unity hf, hfU.to_smooth_partition_of_unity hf⟩ },\n  { intros s t hs ht hd,\n    rcases exists_smooth_zero_one_of_closed I hs ht hd with ⟨f, hf⟩,\n    exact ⟨f, f.smooth, hf⟩ }\nend\n\nend smooth_partition_of_unity\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/geometry/manifold/partition_of_unity.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117983401363, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.48996447066416315}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.witt_vector.basic\nimport Mathlib.ring_theory.witt_vector.is_poly\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-! ## The Verschiebung operator -/\n\nnamespace witt_vector\n\n\n-- unfortunately, without this attribute, some of the code breaks for reasons I don't understand\n\n/--\n`verschiebung_fun x` shifts the coefficients of `x` up by one,\nby inserting 0 as the 0th coefficient.\n`x.coeff i` then becomes `(verchiebung_fun x).coeff (i + 1)`.\n\n`verschiebung_fun` is the underlying function of the additive monoid hom `witt_vector.verschiebung`.\n-/\ndef verschiebung_fun {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) : witt_vector p R :=\n  mk p fun (n : ℕ) => ite (n = 0) 0 (coeff x (n - 1))\n\ntheorem verschiebung_fun_coeff {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) :\n    coeff (verschiebung_fun x) n = ite (n = 0) 0 (coeff x (n - 1)) :=\n  sorry\n\ntheorem verschiebung_fun_coeff_zero {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) :\n    coeff (verschiebung_fun x) 0 = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coeff (verschiebung_fun x) 0 = 0)) (verschiebung_fun_coeff x 0)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (ite (0 = 0) 0 (coeff x (0 - 1)) = 0)) (if_pos rfl)))\n      (Eq.refl 0))\n\n@[simp] theorem verschiebung_fun_coeff_succ {p : ℕ} {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (n : ℕ) : coeff (verschiebung_fun x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem ghost_component_zero_verschiebung_fun {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)]\n    [comm_ring R] (x : witt_vector p R) : coe_fn (ghost_component 0) (verschiebung_fun x) = 0 :=\n  sorry\n\ntheorem ghost_component_verschiebung_fun {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)]\n    [comm_ring R] (x : witt_vector p R) (n : ℕ) :\n    coe_fn (ghost_component (n + 1)) (verschiebung_fun x) = ↑p * coe_fn (ghost_component n) x :=\n  sorry\n\n/--\nThe 0th Verschiebung polynomial is 0. For `n > 0`, the `n`th Verschiebung polynomial is the\nvariable `X (n-1)`.\n-/\ndef verschiebung_poly (n : ℕ) : mv_polynomial ℕ ℤ := ite (n = 0) 0 (mv_polynomial.X (n - 1))\n\n@[simp] theorem verschiebung_poly_zero : verschiebung_poly 0 = 0 := rfl\n\ntheorem aeval_verschiebung_poly' {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R)\n    (n : ℕ) :\n    coe_fn (mv_polynomial.aeval (coeff x)) (verschiebung_poly n) = coeff (verschiebung_fun x) n :=\n  sorry\n\n/--\n`witt_vector.verschiebung` has polynomial structure given by `witt_vector.verschiebung_poly`.\n-/\ntheorem verschiebung_fun_is_poly (p : ℕ) :\n    is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => verschiebung_fun :=\n  sorry\n\n/--\n`verschiebung x` shifts the coefficients of `x` up by one, by inserting 0 as the 0th coefficient.\n`x.coeff i` then becomes `(verchiebung x).coeff (i + 1)`.\n\nThis is a additive monoid hom with underlying function `verschiebung_fun`.\n-/\ndef verschiebung {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] :\n    witt_vector p R →+ witt_vector p R :=\n  add_monoid_hom.mk verschiebung_fun sorry sorry\n\n/-- `witt_vector.verschiebung` is a polynomial function. -/\ntheorem verschiebung_is_poly {p : ℕ} [hp : fact (nat.prime p)] :\n    is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => ⇑verschiebung :=\n  verschiebung_fun_is_poly p\n\n/-- verschiebung is a natural transformation -/\n@[simp] theorem map_verschiebung {p : ℕ} {R : Type u_1} {S : Type u_2} [hp : fact (nat.prime p)]\n    [comm_ring R] [comm_ring S] (f : R →+* S) (x : witt_vector p R) :\n    coe_fn (map f) (coe_fn verschiebung x) = coe_fn verschiebung (coe_fn (map f) x) :=\n  sorry\n\ntheorem ghost_component_zero_verschiebung {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)]\n    [comm_ring R] (x : witt_vector p R) : coe_fn (ghost_component 0) (coe_fn verschiebung x) = 0 :=\n  ghost_component_zero_verschiebung_fun x\n\ntheorem ghost_component_verschiebung {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R]\n    (x : witt_vector p R) (n : ℕ) :\n    coe_fn (ghost_component (n + 1)) (coe_fn verschiebung x) = ↑p * coe_fn (ghost_component n) x :=\n  ghost_component_verschiebung_fun x n\n\n@[simp] theorem verschiebung_coeff_zero {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)]\n    [comm_ring R] (x : witt_vector p R) : coeff (coe_fn verschiebung x) 0 = 0 :=\n  rfl\n\n-- simp_nf complains if this is simp\n\ntheorem verschiebung_coeff_add_one {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R]\n    (x : witt_vector p R) (n : ℕ) : coeff (coe_fn verschiebung x) (n + 1) = coeff x n :=\n  rfl\n\n@[simp] theorem verschiebung_coeff_succ {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)]\n    [comm_ring R] (x : witt_vector p R) (n : ℕ) :\n    coeff (coe_fn verschiebung x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem aeval_verschiebung_poly {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R]\n    (x : witt_vector p R) (n : ℕ) :\n    coe_fn (mv_polynomial.aeval (coeff x)) (verschiebung_poly n) =\n        coeff (coe_fn verschiebung x) n :=\n  aeval_verschiebung_poly' x n\n\n@[simp] theorem bind₁_verschiebung_poly_witt_polynomial {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) :\n    coe_fn (mv_polynomial.bind₁ verschiebung_poly) (witt_polynomial p ℤ n) =\n        ite (n = 0) 0 (↑p * witt_polynomial p ℤ (n - 1)) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/verschiebung_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.48993834728766605}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport algebra.homology.additive\nimport category_theory.limits.shapes.biproducts\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {ι : Type*} {V : Type*} [category V] [preadditive V]\nvariable {c : complex_shape ι}\n\nnamespace homological_complex\n\nvariables (X Y : homological_complex V c) [∀ i, has_binary_biproduct (X.X i) (Y.X i)]\nvariables {Z Z': homological_complex V c} (f₁ : X ⟶ Z) (f₂ : Y ⟶ Z) (g₁ : Z' ⟶ X) (g₂ : Z' ⟶ Y)\n\n@[simps]\ndef biprod : homological_complex V c :=\n{ X := λ i, X.X i ⊞ Y.X i,\n  d := λ i j, biprod.desc (biprod.lift (X.d i j) 0) (biprod.lift 0 (Y.d i j)),\n  shape' := λ i j hij, begin\n    ext,\n    { simp only [biprod.inl_desc, biprod.lift_fst, comp_zero, zero_comp, X.shape i j hij], },\n    { simp only [biprod.inl_desc, biprod.lift_snd, comp_zero, zero_comp], },\n    { simp only [biprod.inr_desc, biprod.lift_fst, comp_zero, zero_comp], },\n    { simp only [Y.shape i j hij, biprod.inr_desc, biprod.lift_snd, comp_zero, zero_comp], },\n  end, }\n\nnamespace biprod\n\nvariables {X Y}\n\n@[simps] def inl : X ⟶ biprod X Y := { f := λ i, biprod.inl, }\n@[simps] def inr : Y ⟶ biprod X Y := { f := λ i, biprod.inr, }\n@[simps] def fst : biprod X Y ⟶ X := { f := λ i, biprod.fst, }\n@[simps] def snd : biprod X Y ⟶ Y := { f := λ i, biprod.snd, }\n\n@[simp, reassoc] def inl_fst : (inl : X ⟶ biprod X Y) ≫ fst = 𝟙 _ := by tidy\n@[simp, reassoc] def inl_snd : (inl : X ⟶ biprod X Y) ≫ snd = 0   := by tidy\n@[simp, reassoc] def inr_fst : (inr : Y ⟶ biprod X Y) ≫ fst = 0   := by tidy\n@[simp, reassoc] def inr_snd : (inr : Y ⟶ biprod X Y) ≫ snd = 𝟙 _ := by tidy\n\n@[simps] def desc : biprod X Y ⟶ Z := { f := λ i, biprod.desc (f₁.f i) (f₂.f i), }\n@[simp, reassoc] lemma inl_desc : inl ≫ desc f₁ f₂ = f₁ := by tidy\n@[simp, reassoc] lemma inr_desc : inr ≫ desc f₁ f₂ = f₂ := by tidy\n\n@[simps] def lift : Z' ⟶ biprod X Y := { f := λ i, biprod.lift (g₁.f i) (g₂.f i), }\n@[simp, reassoc] lemma lift_fst : lift g₁ g₂ ≫ fst = g₁ := by tidy\n@[simp, reassoc] lemma lift_snd : lift g₁ g₂ ≫ snd = g₂ := by tidy\n\n@[ext]\nlemma hom_ext (f₁ f₂ : Z' ⟶ biprod X Y) (h₁ : f₁ ≫ biprod.fst = f₂ ≫ biprod.fst)\n  (h₂ : f₁ ≫ biprod.snd = f₂ ≫ biprod.snd ) : f₁ = f₂ :=\nby { ext i, exacts [congr_hom h₁ i, congr_hom h₂ i], }\n\n@[ext]\nlemma hom_ext' (f₁ f₂ : biprod X Y ⟶ Z) (h₁ : biprod.inl ≫ f₁= biprod.inl ≫ f₂)\n  (h₂ : biprod.inr ≫ f₁ = biprod.inr ≫ f₂) : f₁ = f₂ :=\nby { ext i, exacts [congr_hom h₁ i, congr_hom h₂ i], }\n\n@[simp, reassoc]\nlemma lift_desc : lift g₁ g₂ ≫ desc f₁ f₂ = g₁ ≫ f₁ + g₂ ≫ f₂ := by tidy\n\nlemma total : fst ≫ inl + snd ≫ inr = 𝟙 (biprod X Y) :=\nbegin\n  ext1; ext1; simp only [preadditive.comp_add, inl_fst_assoc, inl_snd_assoc,\n    inr_fst_assoc, inr_snd_assoc, zero_comp, zero_add, add_zero, comp_id, biprod.total],\nend\n\nend biprod\n\nend homological_complex\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebra/homology/homological_complex_biprod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.48993834500251904}}
{"text": "/- various properties about pfun and roption -/\n\nimport basic data.pfun\n\nopen set\n\nuniverses u v w\nvariables {α : Type u} {β : Type v} {γ : Type w} {n : ℕ}\n\nnamespace roption\n\ndef compatible (o₁ o₂ : roption α) : Prop := ∀{{x y}}, x ∈ o₁ → y ∈ o₂ → x = y\n\nnamespace compatible\n  variables {o₁ o₂ o₃ : roption α}\n  infix ` =. `:50 := roption.compatible\n  protected lemma compatible_of_eq {x y : α} (h : x = y) :\n    compatible (roption.some x) (roption.some y) :=\n  omitted\n  protected lemma symm (h : o₁ =. o₂) : o₂ =. o₁ := λx y hx hy, (h hy hx).symm\n  -- note: it is not transitive, probably good to use different notation\nend compatible\n\nend roption\n\nnamespace pfun\n\nprotected def empty (α β : Type*) : α →. β := λx, roption.none\nprotected def id : α →. α := pfun.lift id\nprotected def comp (g : β →. γ) (f : α →. β) : α →. γ := λx, roption.bind (f x) g\ninfix ` ∘. `:90 := pfun.comp\n\ndef to_subtype (p : α → Prop) : α →. subtype p := λx, ⟨p x, λ h, ⟨x, h⟩⟩\n\ndef compatible (f g : α →. β) : Prop := ∀x, f x =. g x\n\nnamespace compatible\n  variables {f g h : α →. β}\n  infix ` ~. `:50 := pfun.compatible\n  protected lemma symm (h : f ~. g) : g ~. f := λx, (h x).symm\n  -- note: it is not transitive, probably good to use different notation\nend compatible\n\ndef restrict' (f : α →. β) (p : set α) : α →. β :=\npfun.restrict f (inter_subset_right p (dom f))\n\nend pfun\n\n/- a partial equivalence -/\nopen pfun\nstructure pequiv (α : Type*) (β : Type*) :=\n(to_fun    : α →. β)\n(inv_fun   : β →. α)\n(dom_inv_fun : ∀{{x}} (hx : x ∈ dom to_fun), to_fun.fn x hx ∈ dom inv_fun)\n(dom_to_fun : ∀{{y}} (hy : y ∈ dom inv_fun), inv_fun.fn y hy ∈ dom to_fun)\n(left_inv  : inv_fun ∘. to_fun ~. pfun.id)\n(right_inv : to_fun ∘. inv_fun ~. pfun.id)\n\ninfixr ` ≃. `:25 := pequiv\n\nnamespace equiv\ndef to_pequiv (e : α ≃ β) : α ≃. β :=\n⟨e.to_fun, e.inv_fun, λx hx, trivial, λy hy, trivial, omitted, omitted⟩\n\ndef rfl : α ≃ α := equiv.refl α\nend equiv\n\nnamespace pequiv\n\ninstance : has_coe (α ≃. β) (α →. β) := ⟨pequiv.to_fun⟩\nprotected def rfl : α ≃. α := equiv.rfl.to_pequiv\nprotected def refl (α) : α ≃. α := pequiv.rfl\nprotected def symm (e : α ≃. β) : β ≃. α :=\n⟨e.inv_fun, e.to_fun, e.dom_to_fun, e.dom_inv_fun, e.right_inv, e.left_inv⟩\nprotected def trans (e₁ : α ≃. β) (e₂ : β ≃. γ) : α ≃. γ :=\n⟨e₂.to_fun ∘. e₁.to_fun, e₁.inv_fun ∘. e₂.inv_fun, omitted, omitted, omitted, omitted⟩\n\ndef restrict' (e : α ≃. β) (p : set α) : α ≃. β :=\n⟨e.to_fun.restrict' p, e.inv_fun.restrict' (e.to_fun.image p), omitted, omitted, omitted, omitted⟩\n\ndef subtype_pequiv (p : α → Prop) : subtype p ≃. α :=\n⟨pfun.lift subtype.val, to_subtype p, omitted, omitted, omitted, omitted⟩\n\nend pequiv\n", "meta": {"author": "formalabstracts", "repo": "formalabstracts", "sha": "b0173da1af45421239d44492eeecd54bf65ee0f6", "save_path": "github-repos/lean/formalabstracts-formalabstracts", "path": "github-repos/lean/formalabstracts-formalabstracts/formalabstracts-b0173da1af45421239d44492eeecd54bf65ee0f6/src/data/pfun2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.48993834235130046}}
{"text": "import logic.funrel\n\nopen function\n\nnamespace function\n\n--- Dependent analogue of `curry`\ndefinition dcurry {α : Sort _} {β : α → Sort _} {γ : Π a (b : β a), Sort _} (f : Π a (b : β a), γ a b) : Π (x : sigma β), γ x.fst x.snd :=\n  λ x, f x.fst x.snd\n\n--- Dependent analogue of `uncurry`\ndefinition duncurry {α : Sort _} {β : α → Sort _} {γ : Π (x : sigma β), Sort _} (f : Π (x : sigma β), γ x) : Π a (b : β a), γ ⟨a,b⟩ :=\n  λ a b, f ⟨a,b⟩\n\n--- Composition of retractions is again a retraction.\nlemma left_inverse_comp {α β γ : Sort _} {gr : γ → β} {g : β → γ} {fr : β → α} {f : α → β} : left_inverse gr g → left_inverse fr f → left_inverse (fr∘ gr) (g∘f) :=\n  begin\n    intros hg hf a,\n    dsimp [function.comp],\n    rw [hg, hf]\n  end\n\n--- Composition of sections is again a section.\nlemma right_inverse_comp {α β γ : Sort _} {gr : γ → β} {g : β → γ} {fr : β → α} {f : α → β} : right_inverse gr g → right_inverse fr f → right_inverse (fr∘ gr) (g∘f) :=\n  λ hg hf, left_inverse_comp hf hg\n\n\ndefinition has_inverse {α β : Sort _} (f : α → β) : Prop :=\n  ∃ (g : β → α), left_inverse g f ∧ right_inverse g f\n\ntheorem has_inverse_of_twosided_invertible {α β : Sort _} {f : α → β} : has_left_inverse f → has_right_inverse f → has_inverse f :=\n  begin\n    intros hlinv hrinv,\n    cases hlinv with gl hgl,\n    cases hrinv with gr hgr,\n    existsi gl,\n    split,\n    show ∀ a, gl (f a) = a, { exact hgl },\n    show ∀ b, f (gl b) = b, {\n      intros b,\n      by calc\n        f (gl b)\n            = f (gl (f (gr b))) : by rw [hgr]\n        ... = f (gr b) : by rw [hgl]\n        ... = b : hgr b\n    }\n  end\n\nnamespace has_inverse\n\nlemma has_left_inverse {α β : Sort _} {f : α → β} : has_inverse f → function.has_left_inverse f :=\n  begin\n    intros hinv; cases hinv with g hg,\n    exact ⟨g,hg.left⟩\n  end\n\nlemma has_right_inverse {α β : Sort _} {f : α → β} : has_inverse f → function.has_right_inverse f :=\n  begin\n    intros hinv; cases hinv with g hg,\n    exact ⟨g,hg.right⟩\n  end\n\nlemma bijective {α β : Sort _} {f : α → β} : has_inverse f → bijective f\n| ⟨g, h⟩ := ⟨has_left_inverse.injective ⟨g, h.left⟩, has_right_inverse.surjective ⟨g, h.right⟩⟩\n\nend has_inverse\n\n--- Analogue of `congr` for functions with dependent domain.\ndefinition dcongr {α : Sort _} {C : α → Sort _} {β : Sort _} : ∀ {a b : α} {f : C a → β} {g : C b → β} {x : C a} {y : C b}, a = b → f == g → x == y → f x = g y :=\n  begin\n    intros a b f g x y hab hfg hxy,\n    cases hab,\n    cases hfg,\n    cases hxy,\n    refl\n  end\n\n--- Analogue of `congr_arg` for functions with dependent codomain.\ndefinition hcongr_arg {α : Sort _} {C : α → Sort _} (f : Π a, C a) : ∀ {x y : α}, x=y → f x == f y\n| _ _ rfl := heq.rfl\n\n\nend function\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/function/misc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.48993834235130046}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Sean Leather\n\nFunctions on lists of sigma types.\n-/\nimport data.list.perm\n\nuniverses u v\n\nnamespace list\nvariables {α : Type u} {β : α → Type v}\n\n/- keys -/\n\n/-- List of keys from a list of key-value pairs -/\ndef keys : list (sigma β) → list α :=\nmap sigma.fst\n\n@[simp] theorem keys_nil : @keys α β [] = [] :=\nrfl\n\n@[simp] theorem keys_cons {s} {l : list (sigma β)} : (s :: l).keys = s.1 :: l.keys :=\nrfl\n\ntheorem mem_keys_of_mem {s : sigma β} {l : list (sigma β)} : s ∈ l → s.1 ∈ l.keys :=\nmem_map_of_mem sigma.fst\n\ntheorem exists_of_mem_keys {a} {l : list (sigma β)} (h : a ∈ l.keys) :\n  ∃ (b : β a), sigma.mk a b ∈ l :=\nlet ⟨⟨a', b'⟩, m, e⟩ := exists_of_mem_map h in\neq.rec_on e (exists.intro b' m)\n\ntheorem mem_keys {a} {l : list (sigma β)} : a ∈ l.keys ↔ ∃ (b : β a), sigma.mk a b ∈ l :=\n⟨exists_of_mem_keys, λ ⟨b, h⟩, mem_keys_of_mem h⟩\n\ntheorem not_mem_keys {a} {l : list (sigma β)} : a ∉ l.keys ↔ ∀ b : β a, sigma.mk a b ∉ l :=\n(not_iff_not_of_iff mem_keys).trans not_exists\n\ntheorem not_eq_key {a} {l : list (sigma β)} : a ∉ l.keys ↔ ∀ s : sigma β, s ∈ l → a ≠ s.1 :=\niff.intro\n  (λ h₁ s h₂ e, absurd (mem_keys_of_mem h₂) (by rwa e at h₁))\n  (λ f h₁, let ⟨b, h₂⟩ := exists_of_mem_keys h₁ in f _ h₂ rfl)\n\n/- nodupkeys -/\n\ndef nodupkeys (l : list (sigma β)) : Prop :=\nl.keys.nodup\n\ntheorem nodupkeys_iff_pairwise {l} : nodupkeys l ↔\n  pairwise (λ s s' : sigma β, s.1 ≠ s'.1) l := pairwise_map _\n\n@[simp] theorem nodupkeys_nil : @nodupkeys α β [] := pairwise.nil\n\n@[simp] theorem nodupkeys_cons {s : sigma β} {l : list (sigma β)} :\n  nodupkeys (s::l) ↔ s.1 ∉ l.keys ∧ nodupkeys l :=\nby simp [keys, nodupkeys]\n\ntheorem nodupkeys.eq_of_fst_eq {l : list (sigma β)}\n  (nd : nodupkeys l) {s s' : sigma β} (h : s ∈ l) (h' : s' ∈ l) :\n  s.1 = s'.1 → s = s' :=\n@forall_of_forall_of_pairwise _\n  (λ s s' : sigma β, s.1 = s'.1 → s = s')\n  (λ s s' H h, (H h.symm).symm) _ (λ x h _, rfl)\n  ((nodupkeys_iff_pairwise.1 nd).imp (λ s s' h h', (h h').elim)) _ h _ h'\n\ntheorem nodupkeys.eq_of_mk_mem {a : α} {b b' : β a} {l : list (sigma β)}\n  (nd : nodupkeys l) (h : sigma.mk a b ∈ l) (h' : sigma.mk a b' ∈ l) : b = b' :=\nby cases nd.eq_of_fst_eq h h' rfl; refl\n\ntheorem nodupkeys_singleton (s : sigma β) : nodupkeys [s] := nodup_singleton _\n\ntheorem nodupkeys_of_sublist {l₁ l₂ : list (sigma β)} (h : l₁ <+ l₂) : nodupkeys l₂ → nodupkeys l₁ :=\nnodup_of_sublist (map_sublist_map _ h)\n\ntheorem nodup_of_nodupkeys {l : list (sigma β)} : nodupkeys l → nodup l :=\nnodup_of_nodup_map _\n\ntheorem perm_nodupkeys {l₁ l₂ : list (sigma β)} (h : l₁ ~ l₂) : nodupkeys l₁ ↔ nodupkeys l₂ :=\nperm_nodup $ perm_map _ h\n\ntheorem nodupkeys_join {L : list (list (sigma β))} :\n  nodupkeys (join L) ↔ (∀ l ∈ L, nodupkeys l) ∧ pairwise disjoint (L.map keys) :=\nbegin\n  rw [nodupkeys_iff_pairwise, pairwise_join, pairwise_map],\n  refine and_congr (ball_congr $ λ l h, by simp [nodupkeys_iff_pairwise]) _,\n  apply iff_of_eq, congr', ext l₁ l₂,\n  simp [keys, disjoint_iff_ne]\nend\n\ntheorem nodup_enum_map_fst (l : list α) : (l.enum.map prod.fst).nodup :=\nby simp [list.nodup_range]\n\nvariables [decidable_eq α]\n\n/- lookup -/\n\n/-- `lookup a l` is the first value in `l` corresponding to the key `a`,\n  or `none` if no such element exists. -/\ndef lookup (a : α) : list (sigma β) → option (β a)\n| []             := none\n| (⟨a', b⟩ :: l) := if h : a' = a then some (eq.rec_on h b) else lookup l\n\n@[simp] theorem lookup_nil (a : α) : lookup a [] = @none (β a) := rfl\n\n@[simp] theorem lookup_cons_eq (l) (a : α) (b : β a) : lookup a (⟨a, b⟩::l) = some b :=\ndif_pos rfl\n\n@[simp] theorem lookup_cons_ne (l) {a} :\n  ∀ s : sigma β, a ≠ s.1 → lookup a (s::l) = lookup a l\n| ⟨a', b⟩ h := dif_neg h.symm\n\ntheorem lookup_is_some {a : α} : ∀ {l : list (sigma β)},\n  (lookup a l).is_some ↔ a ∈ l.keys\n| []             := by simp\n| (⟨a', b⟩ :: l) := begin\n  by_cases h : a = a',\n  { subst a', simp },\n  { simp [h, lookup_is_some] },\nend\n\ntheorem lookup_eq_none {a : α} {l : list (sigma β)} :\n  lookup a l = none ↔ a ∉ l.keys :=\nbegin\n  have := not_congr (@lookup_is_some _ _ _ a l),\n  simp at this, refine iff.trans _ this,\n  cases lookup a l; exact dec_trivial\nend\n\ntheorem of_mem_lookup\n  {a : α} {b : β a} : ∀ {l : list (sigma β)}, b ∈ lookup a l → sigma.mk a b ∈ l\n| (⟨a', b'⟩ :: l) H := begin\n  by_cases h : a = a',\n  { subst a', simp at H, simp [H] },\n  { simp [h] at H, exact or.inr (of_mem_lookup H) }\nend\n\ntheorem mem_lookup {a} {b : β a} {l : list (sigma β)} (nd : l.nodupkeys)\n  (h : sigma.mk a b ∈ l) : b ∈ lookup a l :=\nbegin\n  cases option.is_some_iff_exists.mp (lookup_is_some.mpr (mem_keys_of_mem h)) with b' h',\n  cases nd.eq_of_mk_mem h (of_mem_lookup h'),\n  exact h'\nend\n\ntheorem map_lookup_eq_find (a : α) : ∀ l : list (sigma β),\n  (lookup a l).map (sigma.mk a) = find (λ s, a = s.1) l\n| [] := rfl\n| (⟨a', b'⟩ :: l) := begin\n  by_cases h : a = a',\n  { subst a', simp },\n  { simp [h, map_lookup_eq_find] }\nend\n\ntheorem mem_lookup_iff {a : α} {b : β a} {l : list (sigma β)} (nd : l.nodupkeys) :\n  b ∈ lookup a l ↔ sigma.mk a b ∈ l :=\n⟨of_mem_lookup, mem_lookup nd⟩\n\ntheorem perm_lookup (a : α) {l₁ l₂ : list (sigma β)}\n  (nd₁ : l₁.nodupkeys) (nd₂ : l₂.nodupkeys) (p : l₁ ~ l₂) : lookup a l₁ = lookup a l₂ :=\nby ext b; simp [mem_lookup_iff, nd₁, nd₂]; exact mem_of_perm p\n\n/- lookup_all -/\n\n/-- `lookup_all a l` is the list of all values in `l` corresponding to the key `a`. -/\ndef lookup_all (a : α) : list (sigma β) → list (β a)\n| []             := []\n| (⟨a', b⟩ :: l) := if h : a' = a then eq.rec_on h b :: lookup_all l else lookup_all l\n\n@[simp] \n\n@[simp] theorem lookup_all_cons_eq (l) (a : α) (b : β a) :\n  lookup_all a (⟨a, b⟩::l) = b :: lookup_all a l :=\ndif_pos rfl\n\n@[simp] theorem lookup_all_cons_ne (l) {a} :\n  ∀ s : sigma β, a ≠ s.1 → lookup_all a (s::l) = lookup_all a l\n| ⟨a', b⟩ h := dif_neg h.symm\n\ntheorem lookup_all_eq_nil {a : α} : ∀ {l : list (sigma β)},\n  lookup_all a l = [] ↔ ∀ b : β a, sigma.mk a b ∉ l\n| []             := by simp\n| (⟨a', b⟩ :: l) := begin\n  by_cases h : a = a',\n  { subst a', simp, exact λ H, H b (or.inl rfl) },\n  { simp [h, lookup_all_eq_nil] },\nend\n\ntheorem head_lookup_all (a : α) : ∀ l : list (sigma β),\n  head' (lookup_all a l) = lookup a l\n| []             := by simp\n| (⟨a', b⟩ :: l) := by by_cases h : a = a'; [{subst h, simp}, simp *]\n\ntheorem mem_lookup_all {a : α} {b : β a} :\n  ∀ {l : list (sigma β)}, b ∈ lookup_all a l ↔ sigma.mk a b ∈ l\n| []              := by simp\n| (⟨a', b'⟩ :: l) := by by_cases h : a = a'; [{subst h, simp *}, simp *]\n\ntheorem lookup_all_sublist (a : α) :\n  ∀ l : list (sigma β), (lookup_all a l).map (sigma.mk a) <+ l\n| []              := by simp\n| (⟨a', b'⟩ :: l) := begin\n    by_cases h : a = a',\n    { subst h, simp, exact (lookup_all_sublist l).cons2 _ _ _ },\n    { simp [h], exact (lookup_all_sublist l).cons _ _ _ }\n  end\n\ntheorem lookup_all_length_le_one (a : α) {l : list (sigma β)} (h : l.nodupkeys) :\n  length (lookup_all a l) ≤ 1 :=\nby have := nodup_of_sublist (map_sublist_map _ $ lookup_all_sublist a l) h;\n   rw map_map at this; rwa [← nodup_repeat, ← map_const _ a]\n\ntheorem lookup_all_eq_lookup (a : α) {l : list (sigma β)} (h : l.nodupkeys) :\n  lookup_all a l = (lookup a l).to_list :=\nbegin\n  rw ← head_lookup_all,\n  have := lookup_all_length_le_one a h, revert this,\n  rcases lookup_all a l with _|⟨b, _|⟨c, l⟩⟩; intro; try {refl},\n  exact absurd this dec_trivial\nend\n\ntheorem lookup_all_nodup (a : α) {l : list (sigma β)} (h : l.nodupkeys) :\n  (lookup_all a l).nodup :=\nby rw lookup_all_eq_lookup a h; apply option.to_list_nodup\n\ntheorem perm_lookup_all (a : α) {l₁ l₂ : list (sigma β)}\n  (nd₁ : l₁.nodupkeys) (nd₂ : l₂.nodupkeys) (p : l₁ ~ l₂) : lookup_all a l₁ = lookup_all a l₂ :=\nby simp [lookup_all_eq_lookup, nd₁, nd₂, perm_lookup a nd₁ nd₂ p]\n\n/- kreplace -/\n\ndef kreplace (a : α) (b : β a) : list (sigma β) → list (sigma β) :=\nlookmap $ λ s, if h : a = s.1 then some ⟨a, b⟩ else none\n\ntheorem kreplace_of_forall_not (a : α) (b : β a) {l : list (sigma β)}\n  (H : ∀ b : β a, sigma.mk a b ∉ l) : kreplace a b l = l :=\nlookmap_of_forall_not _ $ begin\n  rintro ⟨a', b'⟩ h, dsimp, split_ifs,\n  { subst a', exact H _ h }, {refl}\nend\n\ntheorem kreplace_self {a : α} {b : β a} {l : list (sigma β)}\n  (nd : nodupkeys l) (h : sigma.mk a b ∈ l) : kreplace a b l = l :=\nbegin\n  refine (lookmap_congr _).trans\n    (lookmap_id' (option.guard (λ s, a = s.1)) _ _),\n  { rintro ⟨a', b'⟩ h', dsimp [option.guard], split_ifs,\n    { subst a', exact ⟨rfl, heq_of_eq $ nd.eq_of_mk_mem h h'⟩ },\n    { refl } },\n  { rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩, dsimp [option.guard], split_ifs,\n    { subst a₁, rintro ⟨⟩, simp }, { rintro ⟨⟩ } },\nend\n\ntheorem keys_kreplace (a : α) (b : β a) : ∀ l : list (sigma β),\n  (kreplace a b l).keys = l.keys :=\nlookmap_map_eq _ _ $ by rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩;\n  dsimp; split_ifs; simp [h] {contextual := tt}\n\ntheorem kreplace_nodupkeys (a : α) (b : β a) {l : list (sigma β)} :\n  (kreplace a b l).nodupkeys ↔ l.nodupkeys :=\nby simp [nodupkeys, keys_kreplace]\n\ntheorem perm_kreplace {a : α} {b : β a} {l₁ l₂ : list (sigma β)}\n  (nd : l₁.nodupkeys) : l₁ ~ l₂ →\n  kreplace a b l₁ ~ kreplace a b l₂ :=\nperm_lookmap _ $ begin\n  refine (nodupkeys_iff_pairwise.1 nd).imp _,\n  intros x y h z h₁ w h₂,\n  split_ifs at h₁ h₂; cases h₁; cases h₂,\n  exact (h (h_2.symm.trans h_1)).elim\nend\n\n/- kerase -/\n\n/-- Remove the first pair with the key `a`. -/\ndef kerase (a : α) : list (sigma β) → list (sigma β) :=\nerasep $ λ s, a = s.1\n\n@[simp] theorem kerase_nil {a} : @kerase _ β _ a [] = [] :=\nrfl\n\n@[simp] theorem kerase_cons_eq {a} {s : sigma β} {l : list (sigma β)} (h : a = s.1) :\n  kerase a (s :: l) = l :=\nby simp [kerase, h]\n\n@[simp] theorem kerase_cons_ne {a} {s : sigma β} {l : list (sigma β)} (h : a ≠ s.1) :\n  kerase a (s :: l) = s :: kerase a l :=\nby simp [kerase, h]\n\n@[simp] theorem kerase_of_not_mem_keys {a} {l : list (sigma β)} (h : a ∉ l.keys) :\n  kerase a l = l :=\nby induction l with _ _ ih;\n   [refl, { simp [not_or_distrib] at h, simp [h.1, ih h.2] }]\n\ntheorem kerase_sublist (a : α) (l : list (sigma β)) : kerase a l <+ l :=\nerasep_sublist _\n\ntheorem kerase_keys_subset (a) (l : list (sigma β)) :\n  (kerase a l).keys ⊆ l.keys :=\nsubset_of_sublist (map_sublist_map _ (kerase_sublist a l))\n\ntheorem mem_keys_of_mem_keys_kerase {a₁ a₂} {l : list (sigma β)} :\n  a₁ ∈ (kerase a₂ l).keys → a₁ ∈ l.keys :=\n@kerase_keys_subset _ _ _ _ _ _\n\ntheorem exists_of_kerase {a : α} {l : list (sigma β)} (h : a ∈ l.keys) :\n  ∃ (b : β a) (l₁ l₂ : list (sigma β)),\n    a ∉ l₁.keys ∧\n    l = l₁ ++ ⟨a, b⟩ :: l₂ ∧\n    kerase a l = l₁ ++ l₂ :=\nbegin\n  induction l,\n  case list.nil { cases h },\n  case list.cons : hd tl ih {\n    by_cases e : a = hd.1,\n    { subst e,\n      exact ⟨hd.2, [], tl, by simp, by cases hd; refl, by simp⟩ },\n    { simp at h,\n      cases h,\n      case or.inl : h { exact absurd h e },\n      case or.inr : h {\n        rcases ih h with ⟨b, tl₁, tl₂, h₁, h₂, h₃⟩,\n        exact ⟨b, hd :: tl₁, tl₂, not_mem_cons_of_ne_of_not_mem e h₁,\n               by rw h₂; refl, by simp [e, h₃]⟩ } } }\nend\n\n@[simp] theorem mem_keys_kerase_of_ne {a₁ a₂} {l : list (sigma β)} (h : a₁ ≠ a₂) :\n  a₁ ∈ (kerase a₂ l).keys ↔ a₁ ∈ l.keys :=\niff.intro mem_keys_of_mem_keys_kerase $ λ p,\n  if q : a₂ ∈ l.keys then\n    match l, kerase a₂ l, exists_of_kerase q, p with\n    | _, _, ⟨_, _, _, _, rfl, rfl⟩, p := by simpa [keys, h] using p\n    end\n  else\n    by simp [q, p]\n\ntheorem keys_kerase {a} {l : list (sigma β)} : (kerase a l).keys = l.keys.erase a :=\nby rw [keys, kerase, ←erasep_map sigma.fst l, erase_eq_erasep]\n\ntheorem kerase_nodupkeys (a : α) {l : list (sigma β)} : nodupkeys l → (kerase a l).nodupkeys :=\nnodupkeys_of_sublist $ kerase_sublist _ _\n\ntheorem perm_kerase {a : α} {l₁ l₂ : list (sigma β)}\n  (nd : l₁.nodupkeys) : l₁ ~ l₂ → kerase a l₁ ~ kerase a l₂ :=\nperm_erasep _ $ (nodupkeys_iff_pairwise.1 nd).imp $\nby rintro x y h rfl; exact h\n\n@[simp] theorem not_mem_keys_kerase (a) {l : list (sigma β)} (nd : l.nodupkeys) :\n  a ∉ (kerase a l).keys :=\nbegin\n  induction l,\n  case list.nil { simp },\n  case list.cons : hd tl ih {\n    simp at nd,\n    by_cases h : a = hd.1,\n    { subst h, simp [nd.1] },\n    { simp [h, ih nd.2] } }\nend\n\n@[simp] theorem lookup_kerase (a) {l : list (sigma β)} (nd : l.nodupkeys) :\n  lookup a (kerase a l) = none :=\nlookup_eq_none.mpr (not_mem_keys_kerase a nd)\n\n@[simp] theorem lookup_kerase_ne {a a'} {l : list (sigma β)} (h : a ≠ a') :\n  lookup a (kerase a' l) = lookup a l :=\nbegin\n  induction l,\n  case list.nil { refl },\n  case list.cons : hd tl ih {\n    cases hd with ah bh,\n    by_cases h₁ : a = ah; by_cases h₂ : a' = ah,\n    { substs h₁ h₂, cases ne.irrefl h },\n    { subst h₁, simp [h₂] },\n    { subst h₂, simp [h] },\n    { simp [h₁, h₂, ih] }\n  }\nend\n\ntheorem kerase_append_left {a} : ∀ {l₁ l₂ : list (sigma β)},\n  a ∈ l₁.keys → kerase a (l₁ ++ l₂) = kerase a l₁ ++ l₂\n| []        _  h  := by cases h\n| (s :: l₁) l₂ h₁ :=\n  if h₂ : a = s.1 then\n    by simp [h₂]\n  else\n    by simp at h₁;\n       cases h₁;\n       [exact absurd h₁ h₂, simp [h₂, kerase_append_left h₁]]\n\ntheorem kerase_append_right {a} : ∀ {l₁ l₂ : list (sigma β)},\n  a ∉ l₁.keys → kerase a (l₁ ++ l₂) = l₁ ++ kerase a l₂\n| []        _  h := rfl\n| (_ :: l₁) l₂ h := by simp [not_or_distrib] at h;\n                       simp [h.1, kerase_append_right h.2]\n\ntheorem kerase_comm (a₁ a₂) (l : list (sigma β)) :\n  kerase a₂ (kerase a₁ l) = kerase a₁ (kerase a₂ l) :=\nif h : a₁ = a₂ then\n  by simp [h]\nelse if ha₁ : a₁ ∈ l.keys then\n  if ha₂ : a₂ ∈ l.keys then\n    match l, kerase a₁ l, exists_of_kerase ha₁, ha₂ with\n    | _, _, ⟨b₁, l₁, l₂, a₁_nin_l₁, rfl, rfl⟩, a₂_in_l₁_app_l₂ :=\n      if h' : a₂ ∈ l₁.keys then\n        by simp [kerase_append_left h',\n                 kerase_append_right (mt (mem_keys_kerase_of_ne h).mp a₁_nin_l₁)]\n      else\n        by simp [kerase_append_right h', kerase_append_right a₁_nin_l₁,\n                 @kerase_cons_ne _ _ _ a₂ ⟨a₁, b₁⟩ _ (ne.symm h)]\n    end\n  else\n    by simp [ha₂, mt mem_keys_of_mem_keys_kerase ha₂]\nelse\n  by simp [ha₁, mt mem_keys_of_mem_keys_kerase ha₁]\n\n/- kinsert -/\n\n/-- Insert the pair `⟨a, b⟩` and erase the first pair with the key `a`. -/\ndef kinsert (a : α) (b : β a) (l : list (sigma β)) : list (sigma β) :=\n⟨a, b⟩ :: kerase a l\n\n@[simp] theorem kinsert_def {a} {b : β a} {l : list (sigma β)} :\n  kinsert a b l = ⟨a, b⟩ :: kerase a l := rfl\n\n@[simp] theorem mem_keys_kinsert {a a'} {b' : β a'} {l : list (sigma β)} :\n  a ∈ (kinsert a' b' l).keys ↔ a = a' ∨ a ∈ l.keys :=\nby by_cases h : a = a'; simp [h]\n\ntheorem kinsert_nodupkeys (a) (b : β a) {l : list (sigma β)} (nd : l.nodupkeys) :\n  (kinsert a b l).nodupkeys :=\nnodupkeys_cons.mpr ⟨not_mem_keys_kerase a nd, kerase_nodupkeys a nd⟩\n\ntheorem perm_kinsert {a} {b : β a} {l₁ l₂ : list (sigma β)} (nd₁ : l₁.nodupkeys)\n  (p : l₁ ~ l₂) : kinsert a b l₁ ~ kinsert a b l₂ :=\nperm.skip ⟨a, b⟩ $ perm_kerase nd₁ p\n\n@[simp] theorem lookup_kinsert {a} {b : β a} (l : list (sigma β)) :\n  lookup a (kinsert a b l) = some b :=\nby simp only [kinsert, lookup_cons_eq]\n\n@[simp] theorem lookup_kinsert_ne {a a'} {b' : β a'} {l : list (sigma β)} (h : a ≠ a') :\n  lookup a (kinsert a' b' l) = lookup a l :=\nby simp [h, lookup_cons_ne _ ⟨a', b'⟩ h]\n\n/- kextract -/\n\ndef kextract (a : α) : list (sigma β) → option (β a) × list (sigma β)\n| []     := (none, [])\n| (s::l) := if h : s.1 = a then (some (eq.rec_on h s.2), l) else\n  let (b', l') := kextract l in (b', s :: l')\n\n@[simp] theorem kextract_eq_lookup_kerase (a : α) :\n  ∀ l : list (sigma β), kextract a l = (lookup a l, kerase a l)\n| []     := rfl\n| (⟨a', b⟩::l) := begin\n    simp [kextract], dsimp, split_ifs,\n    { subst a', simp [kerase] },\n    { simp [kextract, ne.symm h, kextract_eq_lookup_kerase l, kerase] }\n  end\n\n/- kunion -/\n\n/-- `kunion l₁ l₂` is the append to l₁ of l₂ after, for each key in l₁, the\nfirst matching pair in l₂ is erased. -/\ndef kunion : list (sigma β) → list (sigma β) → list (sigma β)\n| []        l₂ := l₂\n| (s :: l₁) l₂ := s :: kunion l₁ (kerase s.1 l₂)\n\n@[simp] theorem nil_kunion {l : list (sigma β)} : kunion [] l = l :=\nrfl\n\n@[simp] theorem kunion_nil : ∀ {l : list (sigma β)}, kunion l [] = l\n| []       := rfl\n| (_ :: l) := by rw [kunion, kerase_nil, kunion_nil]\n\n@[simp] theorem kunion_cons {s} {l₁ l₂ : list (sigma β)} :\n  kunion (s :: l₁) l₂ = s :: kunion l₁ (kerase s.1 l₂) :=\nrfl\n\n@[simp] theorem mem_keys_kunion {a} {l₁ l₂ : list (sigma β)} :\n  a ∈ (kunion l₁ l₂).keys ↔ a ∈ l₁.keys ∨ a ∈ l₂.keys :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp },\n  case list.cons : s l₁ ih { by_cases h : a = s.1; [simp [h], simp [h, ih]] }\nend\n\n@[simp] theorem kunion_kerase {a} : ∀ {l₁ l₂ : list (sigma β)},\n  kunion (kerase a l₁) (kerase a l₂) = kerase a (kunion l₁ l₂)\n| []       _ := rfl\n| (s :: _) l := by by_cases h : a = s.1;\n                   simp [h, kerase_comm a s.1 l, kunion_kerase]\n\ntheorem kunion_nodupkeys {l₁ l₂ : list (sigma β)}\n  (nd₁ : l₁.nodupkeys) (nd₂ : l₂.nodupkeys) : (kunion l₁ l₂).nodupkeys :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp only [nil_kunion, nd₂] },\n  case list.cons : s l₁ ih {\n    simp at nd₁,\n    simp [not_or_distrib, nd₁.1, nd₂, ih nd₁.2 (kerase_nodupkeys s.1 nd₂)] }\nend\n\ntheorem perm_kunion_left {l₁ l₂ : list (sigma β)} (p : l₁ ~ l₂) (l) :\n  kunion l₁ l ~ kunion l₂ l :=\nbegin\n  induction p generalizing l,\n  case list.perm.nil { refl },\n  case list.perm.skip : hd tl₁ tl₂ p ih {\n    simp [ih (kerase hd.1 l), perm.skip] },\n  case list.perm.swap : s₁ s₂ l {\n    simp [kerase_comm, perm.swap] },\n  case list.perm.trans : l₁ l₂ l₃ p₁₂ p₂₃ ih₁₂ ih₂₃ {\n    exact perm.trans (ih₁₂ l) (ih₂₃ l) }\nend\n\ntheorem perm_kunion_right : ∀ l {l₁ l₂ : list (sigma β)},\n  l₁.nodupkeys → l₁ ~ l₂ → kunion l l₁ ~ kunion l l₂\n| []       _  _  _   p := p\n| (s :: l) l₁ l₂ nd₁ p :=\n  by simp [perm.skip s\n    (perm_kunion_right l (kerase_nodupkeys s.1 nd₁) (perm_kerase nd₁ p))]\n\ntheorem perm_kunion {l₁ l₂ l₃ l₄ : list (sigma β)} (nd₃ : l₃.nodupkeys)\n  (p₁₂ : l₁ ~ l₂) (p₃₄ : l₃ ~ l₄) : kunion l₁ l₃ ~ kunion l₂ l₄ :=\nperm.trans (perm_kunion_left p₁₂ l₃) (perm_kunion_right l₂ nd₃ p₃₄)\n\n@[simp] theorem lookup_kunion_left {a} {l₁ l₂ : list (sigma β)} (h : a ∈ l₁.keys) :\n  lookup a (kunion l₁ l₂) = lookup a l₁ :=\nbegin\n  induction l₁ with s _ ih generalizing l₂; simp at h; cases h; cases s with a',\n  { subst h, simp },\n  { rw kunion_cons,\n    by_cases h' : a = a',\n    { subst h', simp },\n    { simp [h', ih h] } }\nend\n\n@[simp] theorem lookup_kunion_right {a} {l₁ l₂ : list (sigma β)} (h : a ∉ l₁.keys) :\n  lookup a (kunion l₁ l₂) = lookup a l₂ :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp },\n  case list.cons : _ _ ih { simp [not_or_distrib] at h, simp [h.1, ih h.2] }\nend\n\n@[simp] theorem mem_lookup_kunion {a} {b : β a} {l₁ l₂ : list (sigma β)} :\n  b ∈ lookup a (kunion l₁ l₂) ↔ b ∈ lookup a l₁ ∨ a ∉ l₁.keys ∧ b ∈ lookup a l₂ :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp },\n  case list.cons : s _ ih {\n    cases s with a',\n    by_cases h₁ : a = a',\n    { subst h₁, simp },\n    { let h₂ := @ih (kerase a' l₂), simp [h₁] at h₂, simp [h₁, h₂] } }\nend\n\ntheorem mem_lookup_kunion_middle {a} {b : β a} {l₁ l₂ l₃ : list (sigma β)}\n  (h₁ : b ∈ lookup a (kunion l₁ l₃)) (h₂ : a ∉ keys l₂) :\n  b ∈ lookup a (kunion (kunion l₁ l₂) l₃) :=\nmatch mem_lookup_kunion.mp h₁ with\n| or.inl h := mem_lookup_kunion.mpr (or.inl (mem_lookup_kunion.mpr (or.inl h)))\n| or.inr h := mem_lookup_kunion.mpr $\n  or.inr ⟨mt mem_keys_kunion.mp (not_or_distrib.mpr ⟨h.1, h₂⟩), h.2⟩\nend\n\nend list\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/data/list/sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.7401743563075447, "lm_q1q2_score": 0.4899383385575083}}
{"text": "/-\nCopyright (c) 2022 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\nimport topology.uniform_space.uniform_convergence\nimport topology.uniform_space.pi\n\n/-!\n# Topology and uniform structure of uniform convergence\n\nThis files endows `α → β` with the topologies / uniform structures of\n- uniform convergence on `α` (in the `uniform_convergence` namespace)\n- uniform convergence on a specified family `𝔖` of sets of `α`\n  (in the `uniform_convergence_on` namespace), also called `𝔖`-convergence\n\nUsual examples of the second construction include :\n- the topology of compact convergence, when `𝔖` is the set of compacts of `α`\n- the strong topology on the dual of a TVS `E`, when `𝔖` is the set of Von Neuman bounded subsets\n  of `E`\n- the weak-* topology on the dual of a TVS `E`, when `𝔖` is the set of singletons of `E`.\n\n## Main definitions\n\n* `uniform_convergence.gen` : basis sets for the uniformity of uniform convergence\n* `uniform_convergence.uniform_space` : uniform structure of uniform convergence\n* `uniform_convergence_on.uniform_space` : uniform structure of 𝔖-convergence\n\n## Main statements\n\n* `uniform_convergence.uniform_continuous_eval` : evaluation is uniformly continuous\n* `uniform_convergence.t2_space` : the topology of uniform convergence on `α → β` is T2 if\n  `β` is T2.\n* `uniform_convergence.tendsto_iff_tendsto_uniformly` : `uniform_convergence.uniform_space` is\n  indeed the uniform structure of uniform convergence\n\n* `uniform_convergence_on.uniform_continuous_eval_of_mem` : evaluation at a point contained in a\n  set of `𝔖` is uniformly continuous\n* `uniform_convergence.t2_space` : the topology of `𝔖`-convergence on `α → β` is T2 if\n  `β` is T2 and `𝔖` covers `α`\n* `uniform_convergence_on.tendsto_iff_tendsto_uniformly_on` :\n  `uniform_convergence_on.uniform_space` is indeed the uniform structure of `𝔖`-convergence\n\n## Implementation details\n\nWe do not declare these structures as instances, since they would conflict with `Pi.uniform_space`.\n\n## TODO\n\n* Show that the uniform structure of `𝔖`-convergence is exactly the structure of `𝔖'`-convergence,\n  where `𝔖'` is the bornology generated by `𝔖`.\n* Add a type synonym for `α → β` endowed with the structures of uniform convergence\n\n## References\n\n* [N. Bourbaki, *General Topology*][bourbaki1966]\n\n## Tags\n\nuniform convergence\n-/\n\n\nnoncomputable theory\nopen_locale topological_space classical uniformity filter\n\nlocal attribute [-instance] Pi.uniform_space\n\nopen set filter\n\nnamespace uniform_convergence\n\nvariables (α β : Type*) {γ ι : Type*}\nvariables {F : ι → α → β} {f : α → β} {s s' : set α} {x : α} {p : filter ι} {g : ι → α}\n\n/-- Basis sets for the uniformity of uniform convergence -/\nprotected def gen (V : set (β × β)) : set ((α → β) × (α → β)) :=\n  {uv : (α → β) × (α → β) | ∀ x, (uv.1 x, uv.2 x) ∈ V}\n\nvariables [uniform_space β]\n\nprotected lemma is_basis_gen :\n  is_basis (λ V : set (β × β), V ∈ 𝓤 β) (uniform_convergence.gen α β) :=\n⟨⟨univ, univ_mem⟩, λ U V hU hV, ⟨U ∩ V, inter_mem hU hV, λ uv huv,\n  ⟨λ x, (huv x).left, λ x, (huv x).right⟩⟩⟩\n\n/-- Filter basis for the uniformity of uniform convergence -/\nprotected def uniformity_basis : filter_basis ((α → β) × (α → β)) :=\n(uniform_convergence.is_basis_gen α β).filter_basis\n\n/-- Core of the uniform structure of uniform convergence -/\nprotected def uniform_core : uniform_space.core (α → β) :=\nuniform_space.core.mk_of_basis (uniform_convergence.uniformity_basis α β)\n  (λ U ⟨V, hV, hVU⟩ f, hVU ▸ λ x, refl_mem_uniformity hV)\n  (λ U ⟨V, hV, hVU⟩, hVU ▸ ⟨uniform_convergence.gen α β (prod.swap ⁻¹' V),\n    ⟨prod.swap ⁻¹' V, tendsto_swap_uniformity hV, rfl⟩, λ uv huv x, huv x⟩)\n  (λ U ⟨V, hV, hVU⟩, hVU ▸ let ⟨W, hW, hWV⟩ := comp_mem_uniformity_sets hV in\n    ⟨uniform_convergence.gen α β W, ⟨W, hW, rfl⟩, λ uv ⟨w, huw, hwv⟩ x, hWV\n      ⟨w x, by exact ⟨huw x, hwv x⟩⟩⟩)\n\n/-- Uniform structure of uniform convergence -/\nprotected def uniform_space : uniform_space (α → β) :=\nuniform_space.of_core (uniform_convergence.uniform_core α β)\n\nprotected lemma has_basis_uniformity :\n  (@uniformity (α → β) (uniform_convergence.uniform_space α β)).has_basis (λ V, V ∈ 𝓤 β)\n  (uniform_convergence.gen α β) :=\n(uniform_convergence.is_basis_gen α β).has_basis\n\n/-- Topology of uniform convergence -/\nprotected def topological_space : topological_space (α → β) :=\n(uniform_convergence.uniform_space α β).to_topological_space\n\nprotected lemma has_basis_nhds :\n  (@nhds (α → β) (uniform_convergence.topological_space α β) f).has_basis (λ V, V ∈ 𝓤 β)\n  (λ V, {g | (g, f) ∈ uniform_convergence.gen α β V}) :=\nbegin\n  letI : uniform_space (α → β) := uniform_convergence.uniform_space α β,\n  exact nhds_basis_uniformity (uniform_convergence.has_basis_uniformity α β)\nend\n\nvariables {α}\n\nlemma uniform_continuous_eval (x : α) : @uniform_continuous _ _\n  (uniform_convergence.uniform_space α β) _ (function.eval x) :=\nbegin\n  change _ ≤ _,\n  rw [map_le_iff_le_comap,\n      (uniform_convergence.has_basis_uniformity α β).le_basis_iff ((𝓤 _).basis_sets.comap _)],\n  exact λ U hU, ⟨U, hU, λ uv huv, huv x⟩\nend\n\nvariables {β}\n\nlemma t2_space [t2_space β] : @t2_space _ (uniform_convergence.topological_space α β) :=\n{ t2 :=\n  begin\n    letI : uniform_space (α → β) := uniform_convergence.uniform_space α β,\n    letI : topological_space (α → β) := uniform_convergence.topological_space α β,\n    intros f g h,\n    obtain ⟨x, hx⟩ := not_forall.mp (mt funext h),\n    exact separated_by_continuous (uniform_continuous_eval β x).continuous hx\n  end }\n\nprotected lemma le_Pi : uniform_convergence.uniform_space α β ≤ Pi.uniform_space (λ _, β) :=\nbegin\n  rw [le_iff_uniform_continuous_id, uniform_continuous_pi],\n  intros x,\n  exact uniform_continuous_eval β x\nend\n\nprotected lemma tendsto_iff_tendsto_uniformly :\n  tendsto F p (@nhds _ (uniform_convergence.topological_space α β) f) ↔\n  tendsto_uniformly F f p :=\nbegin\n  letI : uniform_space (α → β) := uniform_convergence.uniform_space α β,\n  rw [(uniform_convergence.has_basis_nhds α β).tendsto_right_iff, tendsto_uniformly],\n  split;\n  { intros h U hU,\n    filter_upwards [h (prod.swap ⁻¹' U) (tendsto_swap_uniformity hU)],\n    exact λ n, id }\nend\n\nvariable {α}\n\nend uniform_convergence\n\nnamespace uniform_convergence_on\n\nvariables (α β : Type*) {γ ι : Type*} [uniform_space β] (𝔖 : set (set α))\nvariables {F : ι → α → β} {f : α → β} {s s' : set α} {x : α} {p : filter ι} {g : ι → α}\n\n/-- Uniform structure of uniform convergence on the sets of `𝔖`. -/\nprotected def uniform_space : uniform_space (α → β) :=\n⨅ (s : set α) (hs : s ∈ 𝔖), uniform_space.comap (λ f, s.restrict f)\n  (uniform_convergence.uniform_space s β)\n\n/-- Topology of uniform convergence on the sets of `𝔖`. -/\nprotected def topological_space : topological_space (α → β) :=\n(uniform_convergence_on.uniform_space α β 𝔖).to_topological_space\n\nprotected lemma topological_space_eq :\n  uniform_convergence_on.topological_space α β 𝔖 = ⨅ (s : set α) (hs : s ∈ 𝔖),\n  topological_space.induced (λ f, s.restrict f) (uniform_convergence.topological_space s β) :=\nbegin\n  simp only [uniform_convergence_on.topological_space, to_topological_space_infi,\n    to_topological_space_infi, to_topological_space_comap],\n  refl\nend\n\nprotected lemma uniform_continuous_restrict (h : s ∈ 𝔖) :\n  @uniform_continuous _ _ (uniform_convergence_on.uniform_space α β 𝔖)\n  (uniform_convergence.uniform_space s β) s.restrict :=\nbegin\n  change _ ≤ _,\n  rw [uniform_convergence_on.uniform_space, map_le_iff_le_comap, uniformity, infi_uniformity],\n  refine infi_le_of_le s _,\n  rw infi_uniformity,\n  exact infi_le _ h,\nend\n\nprotected lemma uniform_space_antitone : antitone (uniform_convergence_on.uniform_space α β) :=\nλ 𝔖₁ 𝔖₂ h₁₂, infi_le_infi_of_subset h₁₂\n\nvariables {α}\n\nlemma uniform_continuous_eval_of_mem {x : α} (hxs : x ∈ s) (hs : s ∈ 𝔖) :\n  @uniform_continuous _ _ (uniform_convergence_on.uniform_space α β 𝔖) _ (function.eval x) :=\nbegin\n  change _ ≤ _,\n  rw [map_le_iff_le_comap, ((𝓤 _).basis_sets.comap _).ge_iff,\n      uniform_convergence_on.uniform_space, infi_uniformity'],\n  intros U hU,\n  refine mem_infi_of_mem s _,\n  rw infi_uniformity',\n  exact mem_infi_of_mem hs (mem_comap.mpr\n    ⟨ uniform_convergence.gen s β U,\n      (uniform_convergence.has_basis_uniformity s β).mem_of_mem hU,\n      λ uv huv, huv ⟨x, hxs⟩ ⟩)\nend\n\nvariables {β}\n\nlemma t2_space_of_covering [t2_space β] (h : ⋃₀ 𝔖 = univ) :\n  @t2_space _ (uniform_convergence_on.topological_space α β 𝔖) :=\n{ t2 :=\n  begin\n    letI : uniform_space (α → β) := uniform_convergence_on.uniform_space α β 𝔖,\n    letI : topological_space (α → β) := uniform_convergence_on.topological_space α β 𝔖,\n    intros f g hfg,\n    obtain ⟨x, hx⟩ := not_forall.mp (mt funext hfg),\n    obtain ⟨s, hs, hxs⟩ : ∃ s ∈ 𝔖, x ∈ s := mem_sUnion.mp (h.symm ▸ true.intro),\n    exact separated_by_continuous (uniform_continuous_eval_of_mem β 𝔖 hxs hs).continuous hx\n  end }\n\nprotected lemma le_Pi_of_covering (h : ⋃₀ 𝔖 = univ) :\n  uniform_convergence_on.uniform_space α β 𝔖 ≤ Pi.uniform_space (λ _, β) :=\nbegin\n  rw [le_iff_uniform_continuous_id, uniform_continuous_pi],\n  intros x,\n  obtain ⟨s, hs, hxs⟩ : ∃ s ∈ 𝔖, x ∈ s := mem_sUnion.mp (h.symm ▸ true.intro),\n  exact uniform_continuous_eval_of_mem β 𝔖 hxs hs\nend\n\nprotected lemma tendsto_iff_tendsto_uniformly_on :\n  tendsto F p (@nhds _ (uniform_convergence_on.topological_space α β 𝔖) f) ↔\n  ∀ s ∈ 𝔖, tendsto_uniformly_on F f p s :=\nbegin\n  letI : uniform_space (α → β) := uniform_convergence_on.uniform_space α β 𝔖,\n  rw [uniform_convergence_on.topological_space_eq, nhds_infi, tendsto_infi],\n  refine forall_congr (λ s, _),\n  rw [nhds_infi, tendsto_infi],\n  refine forall_congr (λ hs, _),\n  rw [nhds_induced, tendsto_comap_iff, tendsto_uniformly_on_iff_tendsto_uniformly_comp_coe,\n      uniform_convergence.tendsto_iff_tendsto_uniformly],\n  refl\nend\n\nend uniform_convergence_on\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/topology/uniform_space/uniform_convergence_topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.4899383374149348}}
{"text": "import .lang\nimport .ualg\n\nnamespace rules\n\nvariables {L : lang} (R : rules L)\nvariables (A : Type*) [has_app L A]\n\nnamespace add\n\ninductive rel : A → A → Prop \n| of {n} {t1 t2 : L.gen n} {as : ftuple A n} : R t1 t2 → rel (applyt t1 as) (applyt t2 as)\n| refl (a) : rel a a\n| symm (a b) : rel a b → rel b a\n| trans (a b c) : rel a b → rel b c → rel a c\n| compat {n} {t : L n} {as bs : ftuple A n} : \n    (∀ i, rel (as i) (bs i)) → rel (applyo t as) (applyo t bs) \n\ndef setoid : setoid A := ⟨rel R A, rel.refl, rel.symm, rel.trans⟩\nend add\n\ndef add := quotient (add.setoid R A)\n\nnamespace add\n\ninstance : has_app L (R.add A) := \n{ app := λ n t, by letI := add.setoid R A; exact ftuple.quotient_lift \n    (λ as, ⟦applyo t as⟧) (λ as bs hyp, quotient.sound (rel.compat hyp)) }\n\ndef univ : A →$[L] (R.add A) := \n{ to_fn := by letI := add.setoid R A; exact λ a, ⟦a⟧,\n  applyo_map' := \n  begin\n    letI := add.setoid R A,\n    intros n t as, \n    dsimp only [],\n    change ftuple.quotient_lift _ _ _ = _,\n    rw ftuple.quotient_lift_beta,\n  end } \n\ninstance : ualg R (R.add A) := \n{ cond_eq := \n  begin\n    intros n t1 t2 as hyp, \n    letI := add.setoid R A,\n    rcases ftuple.exists_rep as (quotient.exists_rep) with ⟨as,rfl⟩,\n    have : as.map (λ a, ⟦a⟧) = as.map (univ R A), by refl,\n    simp_rw this, clear this,\n    simp_rw ralg_hom.applyt_map,\n    exact quotient.sound (rel.of hyp),\n  end } \n\nvariable {A}\ndef lift {B : Type*} [ualg R B] (f : A →$[L] B) : R.add A →$[L] B := \n{ to_fn := by letI := add.setoid R A; exact quotient.lift f \n  begin\n    intros a b h, \n    induction h,\n    { simp_rw ←ralg_hom.applyt_map,\n      apply ualg.cond_eq, \n      assumption },\n    repeat { cc },\n    { dsimp only [] at h_ih,\n      simp_rw ←ralg_hom.applyo_map,\n      apply congr_arg,\n      ext,\n      apply h_ih },\n  end,\n  applyo_map' := \n  begin\n    intros n t as, \n    letI := add.setoid R A,\n    rcases ftuple.exists_rep as (quotient.exists_rep) with ⟨as,rfl⟩,\n    change _ = quotient.lift f _ (applyo _ (as.map (univ R A))),\n    rw ralg_hom.applyo_map,\n    change _ = quotient.lift f _ (quotient.mk _),\n    rw quotient.lift_beta,\n    rw ←ralg_hom.applyo_map,\n    apply congr_arg,\n    ext,\n    simp only [ftuple.map_eval, quotient.lift_beta],\n  end }\n\ntheorem univ_comp_lift {B : Type*} [ualg R B] (f : A →$[L] B) :\n  (univ R A).comp (lift R f) = f := by {ext, refl}\n\ntheorem lift_unique {B : Type*} [ualg R B] (f : A →$[L] B) (g : (R.add A) →$[L] B) :\n  (univ R A).comp g = f → g = lift R f := λ hyp,\nbegin\n  ext,\n  rcases quot.exists_rep x with ⟨x,rfl⟩,\n  letI := add.setoid R A,\n  change g ⟦x⟧ = ((univ R A).comp (lift R f)) x,\n  rw univ_comp_lift,\n  rw ←hyp,\n  refl,\nend\nend add\nend rules", "meta": {"author": "adamtopaz", "repo": "UnivAlg", "sha": "2458d47a6e4fd0525e3a25b07cb7dd518ac173ef", "save_path": "github-repos/lean/adamtopaz-UnivAlg", "path": "github-repos/lean/adamtopaz-UnivAlg/UnivAlg-2458d47a6e4fd0525e3a25b07cb7dd518ac173ef/src/add_rules.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4899278117830565}}
{"text": "import data.set.basic\n\nnamespace set\n\nlemma sep_eq_inter_set_of {α : Type*} (s : set α) (P : α → Prop) :\n  {x ∈ s | P x} = s ∩ {x | P x} :=\nrfl\n\nend set\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/to_mathlib/data/set/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.4899277997400357}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module algebraic_geometry.pullbacks\n! leanprover-community/mathlib commit 7316286ff2942aa14e540add9058c6b0aa1c8070\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.AlgebraicGeometry.Gluing\nimport Mathbin.CategoryTheory.Limits.Opposites\nimport Mathbin.AlgebraicGeometry.AffineScheme\nimport Mathbin.CategoryTheory.Limits.Shapes.Diagonal\n\n/-!\n# Fibred products of schemes\n\nIn this file we construct the fibred product of schemes via gluing.\nWe roughly follow [har77] Theorem 3.3.\n\nIn particular, the main construction is to show that for an open cover `{ Uᵢ }` of `X`, if there\nexist fibred products `Uᵢ ×[Z] Y` for each `i`, then there exists a fibred product `X ×[Z] Y`.\n\nThen, for constructing the fibred product for arbitrary schemes `X, Y, Z`, we can use the\nconstruction to reduce to the case where `X, Y, Z` are all affine, where fibred products are\nconstructed via tensor products.\n\n-/\n\n\nuniverse v u\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Limits AlgebraicGeometry\n\nnamespace AlgebraicGeometry.Scheme\n\nnamespace Pullback\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {X Y Z : Scheme.{u}} (𝒰 : OpenCover.{u} X) (f : X ⟶ Z) (g : Y ⟶ Z)\n\nvariable [∀ i, HasPullback (𝒰.map i ≫ f) g]\n\n/-- The intersection of `Uᵢ ×[Z] Y` and `Uⱼ ×[Z] Y` is given by (Uᵢ ×[Z] Y) ×[X] Uⱼ -/\ndef v (i j : 𝒰.J) : Scheme :=\n  pullback ((pullback.fst : pullback (𝒰.map i ≫ f) g ⟶ _) ≫ 𝒰.map i) (𝒰.map j)\n#align algebraic_geometry.Scheme.pullback.V AlgebraicGeometry.Scheme.Pullback.v\n\n/-- The canonical transition map `(Uᵢ ×[Z] Y) ×[X] Uⱼ ⟶ (Uⱼ ×[Z] Y) ×[X] Uᵢ` given by the fact\nthat pullbacks are associative and symmetric. -/\ndef t (i j : 𝒰.J) : v 𝒰 f g i j ⟶ v 𝒰 f g j i :=\n  by\n  haveI : has_pullback (pullback.snd ≫ 𝒰.map i ≫ f) g :=\n    has_pullback_assoc_symm (𝒰.map j) (𝒰.map i) (𝒰.map i ≫ f) g\n  haveI : has_pullback (pullback.snd ≫ 𝒰.map j ≫ f) g :=\n    has_pullback_assoc_symm (𝒰.map i) (𝒰.map j) (𝒰.map j ≫ f) g\n  refine' (pullback_symmetry _ _).Hom ≫ _\n  refine' (pullback_assoc _ _ _ _).inv ≫ _\n  change pullback _ _ ⟶ pullback _ _\n  refine' _ ≫ (pullback_symmetry _ _).Hom\n  refine' _ ≫ (pullback_assoc _ _ _ _).Hom\n  refine' pullback.map _ _ _ _ (pullback_symmetry _ _).Hom (𝟙 _) (𝟙 _) _ _\n  rw [pullback_symmetry_hom_comp_snd_assoc, pullback.condition_assoc, category.comp_id]\n  rw [category.comp_id, category.id_comp]\n#align algebraic_geometry.Scheme.pullback.t AlgebraicGeometry.Scheme.Pullback.t\n\n@[simp, reassoc.1]\ntheorem t_fst_fst (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.fst ≫ pullback.fst = pullback.snd :=\n  by\n  delta t\n  simp only [category.assoc, id.def, pullback_symmetry_hom_comp_fst_assoc,\n    pullback_assoc_hom_snd_fst, pullback.lift_fst_assoc, pullback_symmetry_hom_comp_snd,\n    pullback_assoc_inv_fst_fst, pullback_symmetry_hom_comp_fst]\n#align algebraic_geometry.Scheme.pullback.t_fst_fst AlgebraicGeometry.Scheme.Pullback.t_fst_fst\n\n@[simp, reassoc.1]\ntheorem t_fst_snd (i j : 𝒰.J) :\n    t 𝒰 f g i j ≫ pullback.fst ≫ pullback.snd = pullback.fst ≫ pullback.snd :=\n  by\n  delta t\n  simp only [pullback_symmetry_hom_comp_snd_assoc, category.comp_id, category.assoc, id.def,\n    pullback_symmetry_hom_comp_fst_assoc, pullback_assoc_hom_snd_snd, pullback.lift_snd,\n    pullback_assoc_inv_snd]\n#align algebraic_geometry.Scheme.pullback.t_fst_snd AlgebraicGeometry.Scheme.Pullback.t_fst_snd\n\n@[simp, reassoc.1]\ntheorem t_snd (i j : 𝒰.J) : t 𝒰 f g i j ≫ pullback.snd = pullback.fst ≫ pullback.fst :=\n  by\n  delta t\n  simp only [pullback_symmetry_hom_comp_snd_assoc, category.assoc, id.def,\n    pullback_symmetry_hom_comp_snd, pullback_assoc_hom_fst, pullback.lift_fst_assoc,\n    pullback_symmetry_hom_comp_fst, pullback_assoc_inv_fst_snd]\n#align algebraic_geometry.Scheme.pullback.t_snd AlgebraicGeometry.Scheme.Pullback.t_snd\n\ntheorem t_id (i : 𝒰.J) : t 𝒰 f g i i = 𝟙 _ :=\n  by\n  apply pullback.hom_ext <;> rw [category.id_comp]\n  apply pullback.hom_ext\n  · rw [← cancel_mono (𝒰.map i)]\n    simp only [pullback.condition, category.assoc, t_fst_fst]\n  · simp only [category.assoc, t_fst_snd]\n  · rw [← cancel_mono (𝒰.map i)]\n    simp only [pullback.condition, t_snd, category.assoc]\n#align algebraic_geometry.Scheme.pullback.t_id AlgebraicGeometry.Scheme.Pullback.t_id\n\n/-- The inclusion map of `V i j = (Uᵢ ×[Z] Y) ×[X] Uⱼ ⟶ Uᵢ ×[Z] Y`-/\nabbrev fV (i j : 𝒰.J) : v 𝒰 f g i j ⟶ pullback (𝒰.map i ≫ f) g :=\n  pullback.fst\n#align algebraic_geometry.Scheme.pullback.fV AlgebraicGeometry.Scheme.Pullback.fV\n\n/-- The map `((Xᵢ ×[Z] Y) ×[X] Xⱼ) ×[Xᵢ ×[Z] Y] ((Xᵢ ×[Z] Y) ×[X] Xₖ)` ⟶\n  `((Xⱼ ×[Z] Y) ×[X] Xₖ) ×[Xⱼ ×[Z] Y] ((Xⱼ ×[Z] Y) ×[X] Xᵢ)` needed for gluing   -/\ndef t' (i j k : 𝒰.J) :\n    pullback (fV 𝒰 f g i j) (fV 𝒰 f g i k) ⟶ pullback (fV 𝒰 f g j k) (fV 𝒰 f g j i) :=\n  by\n  refine' (pullback_right_pullback_fst_iso _ _ _).Hom ≫ _\n  refine' _ ≫ (pullback_symmetry _ _).Hom\n  refine' _ ≫ (pullback_right_pullback_fst_iso _ _ _).inv\n  refine' pullback.map _ _ _ _ (t 𝒰 f g i j) (𝟙 _) (𝟙 _) _ _\n  · simp only [← pullback.condition, category.comp_id, t_fst_fst_assoc]\n  · simp only [category.comp_id, category.id_comp]\n#align algebraic_geometry.Scheme.pullback.t' AlgebraicGeometry.Scheme.Pullback.t'\n\nsection\n\nend\n\n@[simp, reassoc.1]\ntheorem t'_fst_fst_fst (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ pullback.fst ≫ pullback.fst ≫ pullback.fst = pullback.fst ≫ pullback.snd :=\n  by\n  delta t'\n  simp only [category.assoc, pullback_symmetry_hom_comp_fst_assoc,\n    pullback_right_pullback_fst_iso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_fst,\n    pullback_right_pullback_fst_iso_hom_fst_assoc]\n#align algebraic_geometry.Scheme.pullback.t'_fst_fst_fst AlgebraicGeometry.Scheme.Pullback.t'_fst_fst_fst\n\n@[simp, reassoc.1]\ntheorem t'_fst_fst_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ pullback.fst ≫ pullback.fst ≫ pullback.snd =\n      pullback.fst ≫ pullback.fst ≫ pullback.snd :=\n  by\n  delta t'\n  simp only [category.assoc, pullback_symmetry_hom_comp_fst_assoc,\n    pullback_right_pullback_fst_iso_inv_snd_fst_assoc, pullback.lift_fst_assoc, t_fst_snd,\n    pullback_right_pullback_fst_iso_hom_fst_assoc]\n#align algebraic_geometry.Scheme.pullback.t'_fst_fst_snd AlgebraicGeometry.Scheme.Pullback.t'_fst_fst_snd\n\n@[simp, reassoc.1]\ntheorem t'_fst_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ pullback.fst ≫ pullback.snd = pullback.snd ≫ pullback.snd :=\n  by\n  delta t'\n  simp only [category.comp_id, category.assoc, pullback_symmetry_hom_comp_fst_assoc,\n    pullback_right_pullback_fst_iso_inv_snd_snd, pullback.lift_snd,\n    pullback_right_pullback_fst_iso_hom_snd]\n#align algebraic_geometry.Scheme.pullback.t'_fst_snd AlgebraicGeometry.Scheme.Pullback.t'_fst_snd\n\n@[simp, reassoc.1]\ntheorem t'_snd_fst_fst (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ pullback.snd ≫ pullback.fst ≫ pullback.fst = pullback.fst ≫ pullback.snd :=\n  by\n  delta t'\n  simp only [category.assoc, pullback_symmetry_hom_comp_snd_assoc,\n    pullback_right_pullback_fst_iso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_fst,\n    pullback_right_pullback_fst_iso_hom_fst_assoc]\n#align algebraic_geometry.Scheme.pullback.t'_snd_fst_fst AlgebraicGeometry.Scheme.Pullback.t'_snd_fst_fst\n\n@[simp, reassoc.1]\ntheorem t'_snd_fst_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ pullback.snd ≫ pullback.fst ≫ pullback.snd =\n      pullback.fst ≫ pullback.fst ≫ pullback.snd :=\n  by\n  delta t'\n  simp only [category.assoc, pullback_symmetry_hom_comp_snd_assoc,\n    pullback_right_pullback_fst_iso_inv_fst_assoc, pullback.lift_fst_assoc, t_fst_snd,\n    pullback_right_pullback_fst_iso_hom_fst_assoc]\n#align algebraic_geometry.Scheme.pullback.t'_snd_fst_snd AlgebraicGeometry.Scheme.Pullback.t'_snd_fst_snd\n\n@[simp, reassoc.1]\ntheorem t'_snd_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ pullback.snd ≫ pullback.snd = pullback.fst ≫ pullback.fst ≫ pullback.fst :=\n  by\n  delta t'\n  simp only [category.assoc, pullback_symmetry_hom_comp_snd_assoc,\n    pullback_right_pullback_fst_iso_inv_fst_assoc, pullback.lift_fst_assoc, t_snd,\n    pullback_right_pullback_fst_iso_hom_fst_assoc]\n#align algebraic_geometry.Scheme.pullback.t'_snd_snd AlgebraicGeometry.Scheme.Pullback.t'_snd_snd\n\ntheorem cocycle_fst_fst_fst (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst ≫ pullback.fst ≫ pullback.fst =\n      pullback.fst ≫ pullback.fst ≫ pullback.fst :=\n  by simp only [t'_fst_fst_fst, t'_fst_snd, t'_snd_snd]\n#align algebraic_geometry.Scheme.pullback.cocycle_fst_fst_fst AlgebraicGeometry.Scheme.Pullback.cocycle_fst_fst_fst\n\ntheorem cocycle_fst_fst_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst ≫ pullback.fst ≫ pullback.snd =\n      pullback.fst ≫ pullback.fst ≫ pullback.snd :=\n  by simp only [t'_fst_fst_snd]\n#align algebraic_geometry.Scheme.pullback.cocycle_fst_fst_snd AlgebraicGeometry.Scheme.Pullback.cocycle_fst_fst_snd\n\ntheorem cocycle_fst_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.fst ≫ pullback.snd =\n      pullback.fst ≫ pullback.snd :=\n  by simp only [t'_fst_snd, t'_snd_snd, t'_fst_fst_fst]\n#align algebraic_geometry.Scheme.pullback.cocycle_fst_snd AlgebraicGeometry.Scheme.Pullback.cocycle_fst_snd\n\ntheorem cocycle_snd_fst_fst (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd ≫ pullback.fst ≫ pullback.fst =\n      pullback.snd ≫ pullback.fst ≫ pullback.fst :=\n  by\n  rw [← cancel_mono (𝒰.map i)]\n  simp only [pullback.condition_assoc, t'_snd_fst_fst, t'_fst_snd, t'_snd_snd]\n#align algebraic_geometry.Scheme.pullback.cocycle_snd_fst_fst AlgebraicGeometry.Scheme.Pullback.cocycle_snd_fst_fst\n\ntheorem cocycle_snd_fst_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd ≫ pullback.fst ≫ pullback.snd =\n      pullback.snd ≫ pullback.fst ≫ pullback.snd :=\n  by simp only [pullback.condition_assoc, t'_snd_fst_snd]\n#align algebraic_geometry.Scheme.pullback.cocycle_snd_fst_snd AlgebraicGeometry.Scheme.Pullback.cocycle_snd_fst_snd\n\ntheorem cocycle_snd_snd (i j k : 𝒰.J) :\n    t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j ≫ pullback.snd ≫ pullback.snd =\n      pullback.snd ≫ pullback.snd :=\n  by simp only [t'_snd_snd, t'_fst_fst_fst, t'_fst_snd]\n#align algebraic_geometry.Scheme.pullback.cocycle_snd_snd AlgebraicGeometry.Scheme.Pullback.cocycle_snd_snd\n\n-- `by tidy` should solve it, but it times out.\ntheorem cocycle (i j k : 𝒰.J) : t' 𝒰 f g i j k ≫ t' 𝒰 f g j k i ≫ t' 𝒰 f g k i j = 𝟙 _ :=\n  by\n  apply pullback.hom_ext <;> rw [category.id_comp]\n  · apply pullback.hom_ext\n    · apply pullback.hom_ext\n      · simp_rw [category.assoc]\n        exact cocycle_fst_fst_fst 𝒰 f g i j k\n      · simp_rw [category.assoc]\n        exact cocycle_fst_fst_snd 𝒰 f g i j k\n    · simp_rw [category.assoc]\n      exact cocycle_fst_snd 𝒰 f g i j k\n  · apply pullback.hom_ext\n    · apply pullback.hom_ext\n      · simp_rw [category.assoc]\n        exact cocycle_snd_fst_fst 𝒰 f g i j k\n      · simp_rw [category.assoc]\n        exact cocycle_snd_fst_snd 𝒰 f g i j k\n    · simp_rw [category.assoc]\n      exact cocycle_snd_snd 𝒰 f g i j k\n#align algebraic_geometry.Scheme.pullback.cocycle AlgebraicGeometry.Scheme.Pullback.cocycle\n\n/-- Given `Uᵢ ×[Z] Y`, this is the glued fibered product `X ×[Z] Y`. -/\n@[simps]\ndef gluing : Scheme.GlueData.{u} where\n  J := 𝒰.J\n  U i := pullback (𝒰.map i ≫ f) g\n  V := fun ⟨i, j⟩ => v 𝒰 f g i j\n  -- `p⁻¹(Uᵢ ∩ Uⱼ)` where `p : Uᵢ ×[Z] Y ⟶ Uᵢ ⟶ X`.\n  f i j := pullback.fst\n  f_id i := inferInstance\n  f_open := inferInstance\n  t i j := t 𝒰 f g i j\n  t_id i := t_id 𝒰 f g i\n  t' i j k := t' 𝒰 f g i j k\n  t_fac i j k := by\n    apply pullback.hom_ext\n    apply pullback.hom_ext\n    all_goals\n      simp only [t'_snd_fst_fst, t'_snd_fst_snd, t'_snd_snd, t_fst_fst, t_fst_snd, t_snd,\n        category.assoc]\n  cocycle i j k := cocycle 𝒰 f g i j k\n#align algebraic_geometry.Scheme.pullback.gluing AlgebraicGeometry.Scheme.Pullback.gluing\n\n/-- The first projection from the glued scheme into `X`. -/\ndef p1 : (gluing 𝒰 f g).glued ⟶ X :=\n  by\n  fapply multicoequalizer.desc\n  exact fun i => pullback.fst ≫ 𝒰.map i\n  rintro ⟨i, j⟩\n  change pullback.fst ≫ _ ≫ 𝒰.map i = (_ ≫ _) ≫ _ ≫ 𝒰.map j\n  rw [pullback.condition]\n  rw [← category.assoc]\n  congr 1\n  rw [category.assoc]\n  exact (t_fst_fst _ _ _ _ _).symm\n#align algebraic_geometry.Scheme.pullback.p1 AlgebraicGeometry.Scheme.Pullback.p1\n\n/-- The second projection from the glued scheme into `Y`. -/\ndef p2 : (gluing 𝒰 f g).glued ⟶ Y :=\n  by\n  fapply multicoequalizer.desc\n  exact fun i => pullback.snd\n  rintro ⟨i, j⟩\n  change pullback.fst ≫ _ = (_ ≫ _) ≫ _\n  rw [category.assoc]\n  exact (t_fst_snd _ _ _ _ _).symm\n#align algebraic_geometry.Scheme.pullback.p2 AlgebraicGeometry.Scheme.Pullback.p2\n\ntheorem p_comm : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g :=\n  by\n  apply multicoequalizer.hom_ext\n  intro i\n  erw [multicoequalizer.π_desc_assoc, multicoequalizer.π_desc_assoc]\n  rw [category.assoc, pullback.condition]\n#align algebraic_geometry.Scheme.pullback.p_comm AlgebraicGeometry.Scheme.Pullback.p_comm\n\nvariable (s : PullbackCone f g)\n\n/-- (Implementation)\nThe canonical map `(s.X ×[X] Uᵢ) ×[s.X] (s.X ×[X] Uⱼ) ⟶ (Uᵢ ×[Z] Y) ×[X] Uⱼ`\n\nThis is used in `glued_lift`. -/\ndef gluedLiftPullbackMap (i j : 𝒰.J) :\n    pullback ((𝒰.pullbackCover s.fst).map i) ((𝒰.pullbackCover s.fst).map j) ⟶\n      (gluing 𝒰 f g).V ⟨i, j⟩ :=\n  by\n  change pullback pullback.fst pullback.fst ⟶ pullback _ _\n  refine' (pullback_right_pullback_fst_iso _ _ _).Hom ≫ _\n  refine' pullback.map _ _ _ _ _ (𝟙 _) (𝟙 _) _ _\n  ·\n    exact\n      (pullback_symmetry _ _).Hom ≫\n        pullback.map _ _ _ _ (𝟙 _) s.snd f (category.id_comp _).symm s.condition\n  · simpa using pullback.condition\n  · simp only [category.comp_id, category.id_comp]\n#align algebraic_geometry.Scheme.pullback.glued_lift_pullback_map AlgebraicGeometry.Scheme.Pullback.gluedLiftPullbackMap\n\n@[reassoc.1]\ntheorem gluedLiftPullbackMap_fst (i j : 𝒰.J) :\n    gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.fst =\n      pullback.fst ≫\n        (pullbackSymmetry _ _).Hom ≫\n          pullback.map _ _ _ _ (𝟙 _) s.snd f (Category.id_comp _).symm s.condition :=\n  by\n  delta glued_lift_pullback_map\n  simp only [category.assoc, id.def, pullback.lift_fst,\n    pullback_right_pullback_fst_iso_hom_fst_assoc]\n#align algebraic_geometry.Scheme.pullback.glued_lift_pullback_map_fst AlgebraicGeometry.Scheme.Pullback.gluedLiftPullbackMap_fst\n\n@[reassoc.1]\ntheorem gluedLiftPullbackMap_snd (i j : 𝒰.J) :\n    gluedLiftPullbackMap 𝒰 f g s i j ≫ pullback.snd = pullback.snd ≫ pullback.snd :=\n  by\n  delta glued_lift_pullback_map\n  simp only [category.assoc, category.comp_id, id.def, pullback.lift_snd,\n    pullback_right_pullback_fst_iso_hom_snd]\n#align algebraic_geometry.Scheme.pullback.glued_lift_pullback_map_snd AlgebraicGeometry.Scheme.Pullback.gluedLiftPullbackMap_snd\n\n/-- The lifted map `s.X ⟶ (gluing 𝒰 f g).glued` in order to show that `(gluing 𝒰 f g).glued` is\nindeed the pullback.\n\nGiven a pullback cone `s`, we have the maps `s.fst ⁻¹' Uᵢ ⟶ Uᵢ` and\n`s.fst ⁻¹' Uᵢ ⟶ s.X ⟶ Y` that we may lift to a map `s.fst ⁻¹' Uᵢ ⟶ Uᵢ ×[Z] Y`.\n\nto glue these into a map `s.X ⟶ Uᵢ ×[Z] Y`, we need to show that the maps agree on\n`(s.fst ⁻¹' Uᵢ) ×[s.X] (s.fst ⁻¹' Uⱼ) ⟶ Uᵢ ×[Z] Y`. This is achieved by showing that both of these\nmaps factors through `glued_lift_pullback_map`.\n-/\ndef gluedLift : s.pt ⟶ (gluing 𝒰 f g).glued :=\n  by\n  fapply (𝒰.pullback_cover s.fst).glueMorphisms\n  ·\n    exact fun i =>\n      (pullback_symmetry _ _).Hom ≫\n        pullback.map _ _ _ _ (𝟙 _) s.snd f (category.id_comp _).symm s.condition ≫\n          (gluing 𝒰 f g).ι i\n  intro i j\n  rw [← glued_lift_pullback_map_fst_assoc]\n  have : _ = pullback.fst ≫ _ := (gluing 𝒰 f g).glue_condition i j\n  rw [← this, gluing_to_glue_data_t, gluing_to_glue_data_f]\n  simp_rw [← category.assoc]\n  congr 1\n  apply pullback.hom_ext <;> simp_rw [category.assoc]\n  · rw [t_fst_fst, glued_lift_pullback_map_snd]\n    congr 1\n    rw [← iso.inv_comp_eq, pullback_symmetry_inv_comp_snd]\n    erw [pullback.lift_fst]\n    rw [category.comp_id]\n  · rw [t_fst_snd, glued_lift_pullback_map_fst_assoc]\n    erw [pullback.lift_snd, pullback.lift_snd]\n    rw [pullback_symmetry_hom_comp_snd_assoc, pullback_symmetry_hom_comp_snd_assoc]\n    exact pullback.condition_assoc _\n#align algebraic_geometry.Scheme.pullback.glued_lift AlgebraicGeometry.Scheme.Pullback.gluedLift\n\ntheorem gluedLift_p1 : gluedLift 𝒰 f g s ≫ p1 𝒰 f g = s.fst :=\n  by\n  rw [← cancel_epi (𝒰.pullback_cover s.fst).fromGlued]\n  apply multicoequalizer.hom_ext\n  intro b\n  erw [multicoequalizer.π_desc_assoc, multicoequalizer.π_desc_assoc]\n  delta glued_lift\n  simp_rw [← category.assoc]\n  rw [(𝒰.pullback_cover s.fst).ι_glueMorphisms]\n  simp_rw [category.assoc]\n  erw [multicoequalizer.π_desc, pullback.lift_fst_assoc, pullback.condition, category.comp_id]\n  rw [pullback_symmetry_hom_comp_fst_assoc]\n#align algebraic_geometry.Scheme.pullback.glued_lift_p1 AlgebraicGeometry.Scheme.Pullback.gluedLift_p1\n\ntheorem gluedLift_p2 : gluedLift 𝒰 f g s ≫ p2 𝒰 f g = s.snd :=\n  by\n  rw [← cancel_epi (𝒰.pullback_cover s.fst).fromGlued]\n  apply multicoequalizer.hom_ext\n  intro b\n  erw [multicoequalizer.π_desc_assoc, multicoequalizer.π_desc_assoc]\n  delta glued_lift\n  simp_rw [← category.assoc]\n  rw [(𝒰.pullback_cover s.fst).ι_glueMorphisms]\n  simp_rw [category.assoc]\n  erw [multicoequalizer.π_desc, pullback.lift_snd]\n  rw [pullback_symmetry_hom_comp_snd_assoc]\n  rfl\n#align algebraic_geometry.Scheme.pullback.glued_lift_p2 AlgebraicGeometry.Scheme.Pullback.gluedLift_p2\n\n/-- (Implementation)\nThe canonical map `(W ×[X] Uᵢ) ×[W] (Uⱼ ×[Z] Y) ⟶ (Uⱼ ×[Z] Y) ×[X] Uᵢ = V j i` where `W` is\nthe glued fibred product.\n\nThis is used in `lift_comp_ι`. -/\ndef pullbackFstιToV (i j : 𝒰.J) :\n    pullback (pullback.fst : pullback (p1 𝒰 f g) (𝒰.map i) ⟶ _) ((gluing 𝒰 f g).ι j) ⟶\n      v 𝒰 f g j i :=\n  (pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) _).Hom ≫\n    (pullback.congrHom (Multicoequalizer.π_desc _ _ _ _ _) rfl).Hom\n#align algebraic_geometry.Scheme.pullback.pullback_fst_ι_to_V AlgebraicGeometry.Scheme.Pullback.pullbackFstιToV\n\n@[simp, reassoc.1]\ntheorem pullbackFstιToV_fst (i j : 𝒰.J) : pullbackFstιToV 𝒰 f g i j ≫ pullback.fst = pullback.snd :=\n  by\n  delta pullback_fst_ι_to_V\n  simp only [iso.trans_hom, pullback.congr_hom_hom, category.assoc, pullback.lift_fst,\n    category.comp_id, pullback_right_pullback_fst_iso_hom_fst, pullback_symmetry_hom_comp_fst]\n#align algebraic_geometry.Scheme.pullback.pullback_fst_ι_to_V_fst AlgebraicGeometry.Scheme.Pullback.pullbackFstιToV_fst\n\n@[simp, reassoc.1]\ntheorem pullbackFstιToV_snd (i j : 𝒰.J) :\n    pullbackFstιToV 𝒰 f g i j ≫ pullback.snd = pullback.fst ≫ pullback.snd :=\n  by\n  delta pullback_fst_ι_to_V\n  simp only [iso.trans_hom, pullback.congr_hom_hom, category.assoc, pullback.lift_snd,\n    category.comp_id, pullback_right_pullback_fst_iso_hom_snd, pullback_symmetry_hom_comp_snd_assoc]\n#align algebraic_geometry.Scheme.pullback.pullback_fst_ι_to_V_snd AlgebraicGeometry.Scheme.Pullback.pullbackFstιToV_snd\n\n/-- We show that the map `W ×[X] Uᵢ ⟶ Uᵢ ×[Z] Y ⟶ W` is the first projection, where the\nfirst map is given by the lift of `W ×[X] Uᵢ ⟶ Uᵢ` and `W ×[X] Uᵢ ⟶ W ⟶ Y`.\n\nIt suffices to show that the two map agrees when restricted onto `Uⱼ ×[Z] Y`. In this case,\nboth maps factor through `V j i` via `pullback_fst_ι_to_V` -/\ntheorem lift_comp_ι (i : 𝒰.J) :\n    pullback.lift pullback.snd (pullback.fst ≫ p2 𝒰 f g)\n          (by rw [← pullback.condition_assoc, category.assoc, p_comm]) ≫\n        (gluing 𝒰 f g).ι i =\n      (pullback.fst : pullback (p1 𝒰 f g) (𝒰.map i) ⟶ _) :=\n  by\n  apply ((gluing 𝒰 f g).OpenCover.pullbackCover pullback.fst).hom_ext\n  intro j\n  dsimp only [open_cover.pullback_cover]\n  trans pullback_fst_ι_to_V 𝒰 f g i j ≫ fV 𝒰 f g j i ≫ (gluing 𝒰 f g).ι _\n  · rw [← show _ = fV 𝒰 f g j i ≫ _ from (gluing 𝒰 f g).glue_condition j i]\n    simp_rw [← category.assoc]\n    congr 1\n    rw [gluing_to_glue_data_f, gluing_to_glue_data_t]\n    apply pullback.hom_ext <;> simp_rw [category.assoc]\n    · rw [t_fst_fst, pullback.lift_fst, pullback_fst_ι_to_V_snd]\n    · rw [t_fst_snd, pullback.lift_snd, pullback_fst_ι_to_V_fst_assoc, pullback.condition_assoc]\n      erw [multicoequalizer.π_desc]\n  · rw [pullback.condition, ← category.assoc]\n    congr 1\n    apply pullback.hom_ext\n    · simp only [pullback_fst_ι_to_V_fst]\n    · simp only [pullback_fst_ι_to_V_fst]\n#align algebraic_geometry.Scheme.pullback.lift_comp_ι AlgebraicGeometry.Scheme.Pullback.lift_comp_ι\n\n/-- The canonical isomorphism between `W ×[X] Uᵢ` and `Uᵢ ×[X] Y`. That is, the preimage of `Uᵢ` in\n`W` along `p1` is indeed `Uᵢ ×[X] Y`. -/\ndef pullbackP1Iso (i : 𝒰.J) : pullback (p1 𝒰 f g) (𝒰.map i) ≅ pullback (𝒰.map i ≫ f) g :=\n  by\n  fconstructor\n  exact\n    pullback.lift pullback.snd (pullback.fst ≫ p2 𝒰 f g)\n      (by rw [← pullback.condition_assoc, category.assoc, p_comm])\n  refine' pullback.lift ((gluing 𝒰 f g).ι i) pullback.fst (by erw [multicoequalizer.π_desc])\n  · apply pullback.hom_ext\n    · simpa using lift_comp_ι 𝒰 f g i\n    · simp only [category.assoc, pullback.lift_snd, pullback.lift_fst, category.id_comp]\n  · apply pullback.hom_ext\n    · simp only [category.assoc, pullback.lift_fst, pullback.lift_snd, category.id_comp]\n    · simp only [category.assoc, pullback.lift_snd, pullback.lift_fst_assoc, category.id_comp]\n      erw [multicoequalizer.π_desc]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso\n\n@[simp, reassoc.1]\ntheorem pullbackP1Iso_hom_fst (i : 𝒰.J) :\n    (pullbackP1Iso 𝒰 f g i).Hom ≫ pullback.fst = pullback.snd :=\n  by\n  delta pullback_p1_iso\n  simp only [pullback.lift_fst]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso_hom_fst AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso_hom_fst\n\n@[simp, reassoc.1]\ntheorem pullbackP1Iso_hom_snd (i : 𝒰.J) :\n    (pullbackP1Iso 𝒰 f g i).Hom ≫ pullback.snd = pullback.fst ≫ p2 𝒰 f g :=\n  by\n  delta pullback_p1_iso\n  simp only [pullback.lift_snd]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso_hom_snd AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso_hom_snd\n\n@[simp, reassoc.1]\ntheorem pullbackP1Iso_inv_fst (i : 𝒰.J) :\n    (pullbackP1Iso 𝒰 f g i).inv ≫ pullback.fst = (gluing 𝒰 f g).ι i :=\n  by\n  delta pullback_p1_iso\n  simp only [pullback.lift_fst]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso_inv_fst AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso_inv_fst\n\n@[simp, reassoc.1]\ntheorem pullbackP1Iso_inv_snd (i : 𝒰.J) :\n    (pullbackP1Iso 𝒰 f g i).inv ≫ pullback.snd = pullback.fst :=\n  by\n  delta pullback_p1_iso\n  simp only [pullback.lift_snd]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso_inv_snd AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso_inv_snd\n\n@[simp, reassoc.1]\ntheorem pullbackP1Iso_hom_ι (i : 𝒰.J) :\n    (pullbackP1Iso 𝒰 f g i).Hom ≫ (gluing 𝒰 f g).ι i = pullback.fst := by\n  rw [← pullback_p1_iso_inv_fst, iso.hom_inv_id_assoc]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso_hom_ι AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso_hom_ι\n\n/-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/\ndef gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) :=\n  by\n  apply pullback_cone.is_limit_aux'\n  intro s\n  refine' ⟨glued_lift 𝒰 f g s, glued_lift_p1 𝒰 f g s, glued_lift_p2 𝒰 f g s, _⟩\n  intro m h₁ h₂\n  change m ≫ p1 𝒰 f g = _ at h₁\n  change m ≫ p2 𝒰 f g = _ at h₂\n  apply (𝒰.pullback_cover s.fst).hom_ext\n  intro i\n  rw [open_cover.pullback_cover_map]\n  have := pullback_right_pullback_fst_iso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congr_hom h₁ rfl\n  erw [(𝒰.pullback_cover s.fst).ι_glueMorphisms]\n  rw [←\n    cancel_epi\n      (pullback_right_pullback_fst_iso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congr_hom h₁ rfl).Hom,\n    iso.trans_hom, category.assoc, pullback.congr_hom_hom, pullback.lift_fst_assoc,\n    category.comp_id, pullback_right_pullback_fst_iso_hom_fst_assoc, pullback.condition]\n  trans pullback.snd ≫ (pullback_p1_iso 𝒰 f g _).Hom ≫ (gluing 𝒰 f g).ι _\n  · congr 1\n    rw [← pullback_p1_iso_hom_ι]\n  simp_rw [← category.assoc]\n  congr 1\n  apply pullback.hom_ext\n  ·\n    simp only [category.comp_id, pullback_right_pullback_fst_iso_hom_snd, category.assoc,\n      pullback_p1_iso_hom_fst, pullback.lift_snd, pullback.lift_fst, pullback_symmetry_hom_comp_fst]\n  · simp only [category.comp_id, pullback_right_pullback_fst_iso_hom_fst_assoc,\n      pullback_p1_iso_hom_snd, category.assoc, pullback.lift_fst_assoc,\n      pullback_symmetry_hom_comp_snd_assoc, pullback.lift_snd]\n    rw [← pullback.condition_assoc, h₂]\n#align algebraic_geometry.Scheme.pullback.glued_is_limit AlgebraicGeometry.Scheme.Pullback.gluedIsLimit\n\ntheorem hasPullback_of_cover : HasPullback f g :=\n  ⟨⟨⟨_, gluedIsLimit 𝒰 f g⟩⟩⟩\n#align algebraic_geometry.Scheme.pullback.has_pullback_of_cover AlgebraicGeometry.Scheme.Pullback.hasPullback_of_cover\n\ninstance affine_hasPullback {A B C : CommRingCat}\n    (f : spec.obj (Opposite.op A) ⟶ spec.obj (Opposite.op C))\n    (g : spec.obj (Opposite.op B) ⟶ spec.obj (Opposite.op C)) : HasPullback f g :=\n  by\n  rw [← Spec.image_preimage f, ← Spec.image_preimage g]\n  exact\n    ⟨⟨⟨_, is_limit_of_has_pullback_of_preserves_limit Spec (Spec.preimage f) (Spec.preimage g)⟩⟩⟩\n#align algebraic_geometry.Scheme.pullback.affine_has_pullback AlgebraicGeometry.Scheme.Pullback.affine_hasPullback\n\ntheorem affine_affine_hasPullback {B C : CommRingCat} {X : Scheme}\n    (f : X ⟶ spec.obj (Opposite.op C)) (g : spec.obj (Opposite.op B) ⟶ spec.obj (Opposite.op C)) :\n    HasPullback f g :=\n  hasPullback_of_cover X.affineCover f g\n#align algebraic_geometry.Scheme.pullback.affine_affine_has_pullback AlgebraicGeometry.Scheme.Pullback.affine_affine_hasPullback\n\ninstance base_affine_hasPullback {C : CommRingCat} {X Y : Scheme} (f : X ⟶ spec.obj (Opposite.op C))\n    (g : Y ⟶ spec.obj (Opposite.op C)) : HasPullback f g :=\n  @hasPullback_symmetry _ _ _\n    (@hasPullback_of_cover Y.affineCover g f fun i =>\n      @hasPullback_symmetry _ _ _ <| affine_affine_hasPullback _ _)\n#align algebraic_geometry.Scheme.pullback.base_affine_has_pullback AlgebraicGeometry.Scheme.Pullback.base_affine_hasPullback\n\ninstance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)\n    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g :=\n  by\n  let Xᵢ := pullback f (Z.affine_cover.map i)\n  let Yᵢ := pullback g (Z.affine_cover.map i)\n  let W := pullback (pullback.snd : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)\n  have :=\n    big_square_is_pullback (pullback.fst : W ⟶ _) (pullback.fst : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)\n      (Z.affine_cover.map i) pullback.snd pullback.snd g pullback.condition.symm\n      pullback.condition.symm (pullback_cone.flip_is_limit <| pullback_is_pullback _ _)\n      (pullback_cone.flip_is_limit <| pullback_is_pullback _ _)\n  have : has_pullback (pullback.snd ≫ Z.affine_cover.map i : Xᵢ ⟶ _) g := ⟨⟨⟨_, this⟩⟩⟩\n  rw [← pullback.condition] at this\n  exact this\n#align algebraic_geometry.Scheme.pullback.left_affine_comp_pullback_has_pullback AlgebraicGeometry.Scheme.Pullback.left_affine_comp_pullback_hasPullback\n\ninstance {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) : HasPullback f g :=\n  hasPullback_of_cover (Z.affineCover.pullbackCover f) f g\n\ninstance : HasPullbacks Scheme :=\n  hasPullbacks_of_hasLimit_cospan _\n\ninstance {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [IsAffine X] [IsAffine Y] [IsAffine Z] :\n    IsAffine (pullback f g) :=\n  isAffineOfIso\n    (pullback.map f g (spec.map (Γ.map f.op).op) (spec.map (Γ.map g.op).op)\n        (ΓSpec.adjunction.Unit.app X) (ΓSpec.adjunction.Unit.app Y) (ΓSpec.adjunction.Unit.app Z)\n        (ΓSpec.adjunction.Unit.naturality f) (ΓSpec.adjunction.Unit.naturality g) ≫\n      (PreservesPullback.iso spec _ _).inv)\n\n/-- Given an open cover `{ Xᵢ }` of `X`, then `X ×[Z] Y` is covered by `Xᵢ ×[Z] Y`. -/\n@[simps J obj map]\ndef openCoverOfLeft (𝒰 : OpenCover X) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) :=\n  by\n  fapply\n    ((gluing 𝒰 f g).OpenCover.pushforwardIso\n          (limit.iso_limit_cone ⟨_, glued_is_limit 𝒰 f g⟩).inv).copy\n      𝒰.J (fun i => pullback (𝒰.map i ≫ f) g)\n      (fun i => pullback.map _ _ _ _ (𝒰.map i) (𝟙 _) (𝟙 _) (category.comp_id _) (by simp))\n      (Equiv.refl 𝒰.J) fun _ => iso.refl _\n  rintro (i : 𝒰.J)\n  change pullback.map _ _ _ _ _ _ _ _ _ = 𝟙 _ ≫ (gluing 𝒰 f g).ι i ≫ _\n  refine' Eq.trans _ (category.id_comp _).symm\n  apply pullback.hom_ext\n  all_goals\n    dsimp\n    simp only [limit.iso_limit_cone_inv_π, pullback_cone.mk_π_app_left, category.comp_id,\n      pullback_cone.mk_π_app_right, category.assoc, pullback.lift_fst, pullback.lift_snd]\n    symm\n    exact multicoequalizer.π_desc _ _ _ _ _\n#align algebraic_geometry.Scheme.pullback.open_cover_of_left AlgebraicGeometry.Scheme.Pullback.openCoverOfLeft\n\n/-- Given an open cover `{ Yᵢ }` of `Y`, then `X ×[Z] Y` is covered by `X ×[Z] Yᵢ`. -/\n@[simps J obj map]\ndef openCoverOfRight (𝒰 : OpenCover Y) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) :=\n  by\n  fapply\n    ((open_cover_of_left 𝒰 g f).pushforwardIso (pullback_symmetry _ _).Hom).copy 𝒰.J\n      (fun i => pullback f (𝒰.map i ≫ g))\n      (fun i => pullback.map _ _ _ _ (𝟙 _) (𝒰.map i) (𝟙 _) (by simp) (category.comp_id _))\n      (Equiv.refl _) fun i => pullback_symmetry _ _\n  intro i\n  dsimp [open_cover.bind]\n  apply pullback.hom_ext <;> simp\n#align algebraic_geometry.Scheme.pullback.open_cover_of_right AlgebraicGeometry.Scheme.Pullback.openCoverOfRight\n\n/-- Given an open cover `{ Xᵢ }` of `X` and an open cover `{ Yⱼ }` of `Y`, then\n`X ×[Z] Y` is covered by `Xᵢ ×[Z] Yⱼ`. -/\n@[simps J obj map]\ndef openCoverOfLeftRight (𝒰X : X.OpenCover) (𝒰Y : Y.OpenCover) (f : X ⟶ Z) (g : Y ⟶ Z) :\n    (pullback f g).OpenCover :=\n  by\n  fapply\n    ((open_cover_of_left 𝒰X f g).bind fun x => open_cover_of_right 𝒰Y (𝒰X.map x ≫ f) g).copy\n      (𝒰X.J × 𝒰Y.J) (fun ij => pullback (𝒰X.map ij.1 ≫ f) (𝒰Y.map ij.2 ≫ g))\n      (fun ij =>\n        pullback.map _ _ _ _ (𝒰X.map ij.1) (𝒰Y.map ij.2) (𝟙 _) (category.comp_id _)\n          (category.comp_id _))\n      (Equiv.sigmaEquivProd _ _).symm fun _ => iso.refl _\n  rintro ⟨i, j⟩\n  apply pullback.hom_ext <;> simpa\n#align algebraic_geometry.Scheme.pullback.open_cover_of_left_right AlgebraicGeometry.Scheme.Pullback.openCoverOfLeftRight\n\n/-- (Implementation). Use `open_cover_of_base` instead. -/\ndef openCoverOfBase' (𝒰 : OpenCover Z) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) :=\n  by\n  apply (open_cover_of_left (𝒰.pullback_cover f) f g).bind\n  intro i\n  let Xᵢ := pullback f (𝒰.map i)\n  let Yᵢ := pullback g (𝒰.map i)\n  let W := pullback (pullback.snd : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)\n  have :=\n    big_square_is_pullback (pullback.fst : W ⟶ _) (pullback.fst : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)\n      (𝒰.map i) pullback.snd pullback.snd g pullback.condition.symm pullback.condition.symm\n      (pullback_cone.flip_is_limit <| pullback_is_pullback _ _)\n      (pullback_cone.flip_is_limit <| pullback_is_pullback _ _)\n  refine'\n    open_cover_of_is_iso\n      ((pullback_symmetry _ _).Hom ≫\n        (limit.iso_limit_cone ⟨_, this⟩).inv ≫ pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) _ _)\n  · simpa only [category.comp_id, category.id_comp, ← pullback.condition]\n  · simp only [category.comp_id, category.id_comp]\n  infer_instance\n#align algebraic_geometry.Scheme.pullback.open_cover_of_base' AlgebraicGeometry.Scheme.Pullback.openCoverOfBase'\n\n/-- Given an open cover `{ Zᵢ }` of `Z`, then `X ×[Z] Y` is covered by `Xᵢ ×[Zᵢ] Yᵢ`, where\n  `Xᵢ = X ×[Z] Zᵢ` and `Yᵢ = Y ×[Z] Zᵢ` is the preimage of `Zᵢ` in `X` and `Y`. -/\n@[simps J obj map]\ndef openCoverOfBase (𝒰 : OpenCover Z) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) :=\n  by\n  apply\n    (open_cover_of_base' 𝒰 f g).copy 𝒰.J\n      (fun i =>\n        pullback (pullback.snd : pullback f (𝒰.map i) ⟶ _)\n          (pullback.snd : pullback g (𝒰.map i) ⟶ _))\n      (fun i =>\n        pullback.map _ _ _ _ pullback.fst pullback.fst (𝒰.map i) pullback.condition.symm\n          pullback.condition.symm)\n      ((Equiv.prodPUnit 𝒰.J).symm.trans (Equiv.sigmaEquivProd 𝒰.J PUnit).symm) fun _ => iso.refl _\n  intro i\n  change _ = _ ≫ _ ≫ _\n  refine' Eq.trans _ (category.id_comp _).symm\n  apply pullback.hom_ext <;>\n    simp only [category.comp_id, open_cover_of_left_map, open_cover.pullback_cover_map,\n      pullback_cone.mk_π_app_left, open_cover_of_is_iso_map, limit.iso_limit_cone_inv_π_assoc,\n      category.assoc, pullback.lift_fst_assoc, pullback_symmetry_hom_comp_snd_assoc,\n      pullback.lift_fst, limit.iso_limit_cone_inv_π, pullback_cone.mk_π_app_right,\n      pullback_symmetry_hom_comp_fst_assoc, pullback.lift_snd]\n#align algebraic_geometry.Scheme.pullback.open_cover_of_base AlgebraicGeometry.Scheme.Pullback.openCoverOfBase\n\nend Pullback\n\nend AlgebraicGeometry.Scheme\n\nnamespace AlgebraicGeometry\n\ninstance {X Y S X' Y' S' : Scheme} (f : X ⟶ S) (g : Y ⟶ S) (f' : X' ⟶ S') (g' : Y' ⟶ S')\n    (i₁ : X ⟶ X') (i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f') (e₂ : g ≫ i₃ = i₂ ≫ g')\n    [IsOpenImmersion i₁] [IsOpenImmersion i₂] [Mono i₃] :\n    IsOpenImmersion (pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂) :=\n  by\n  rw [pullback_map_eq_pullback_fst_fst_iso_inv]\n  infer_instance\n\nend AlgebraicGeometry\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/AlgebraicGeometry/Pullbacks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.4899277997400357}}
{"text": "/-\nCopyright (c) 2022 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport computational_monads.simulation_semantics.simulate.support\n\n/-!\n# Simulation with Subsingleton State\n\nThis file gives additional lemmas about `simulate` and `simulate'` when\nthe oracle's internal state is a `subsingleton` type.\nIn particular we can often relate simulations to `default_simulate` and `default_simulate'`.\n\n`stateless_oracle` is the biggest example of this, as its internal state type is `unit`\n-/\n\nvariables {α β γ : Type} {spec spec' spec'' : oracle_spec} {S S' : Type}\n\nnamespace oracle_comp\n\nopen oracle_spec\nopen_locale nnreal ennreal\n\nvariables (so : sim_oracle spec spec' S) (so' : sim_oracle spec spec'' S')\nvariables (a : α) (i : spec.ι) (t : spec.domain i)\n  (oa oa' : oracle_comp spec α) (ob ob' : α → oracle_comp spec β) (s : S) (s' : S') (f : α → β)\n\nlemma simulate_eq_default_simulate [subsingleton S] :\n  simulate so oa s = default_simulate so oa := subsingleton.elim so.default_state s ▸ rfl\n\nlemma simulate'_eq_default_simulate' [subsingleton S] :\n  simulate' so oa s = default_simulate' so oa := subsingleton.elim so.default_state s ▸ rfl\n\nsection support\n\n/-- Version of `support_simulate'_eq_support` for `default_simulate`, given a `subsingleton` state.\nHas a weaker requirement for the hypothesis `h` than the more general lemma -/\ntheorem support_simulate'_eq_support_of_subsingleton [subsingleton S] (s : S)\n  (h : ∀ i t, prod.fst '' (so i (t, so.default_state)).support = ⊤) :\n  (simulate' so oa s).support = oa.support :=\nsupport_simulate'_eq_support so oa s (λ i t s, subsingleton.elim so.default_state s ▸ h i t)\n\n/-- Given the state is `subsingleton`, the support of `simulate` is determined by `simulate'` -/\nlemma support_simulate_eq_preimage_support_simulate' [subsingleton S] :\n  (simulate so oa s).support = prod.fst ⁻¹' (default_simulate' so oa).support :=\nbegin\n  rw [support_simulate', subsingleton.elim so.default_state s],\n  exact (set.ext $ λ x, ⟨λ h, ⟨x, h, rfl⟩, λ h, let ⟨y, h, h'⟩ := h in\n    (prod.eq_iff_fst_eq_snd_eq.2 ⟨h', subsingleton.elim y.2 x.2⟩) ▸ h⟩),\nend\n\n/-- If the state has at most one elements, we can express the support of `simulate` in terms\nof only `simulate'`. For example in a `stateless_oracle` or `uniform_oracle`.\nTODO: above is basically the same statement -/\nlemma support_simulate_eq_support_simulate'_of_subsingleton [subsingleton S]\n  (so : sim_oracle spec spec' S) : (simulate so oa s).support =\n    {x | x.1 ∈ (simulate' so oa s).support} :=\nbegin\n  refine set.ext (λ x, _),\n  rw [set.mem_set_of, support_simulate', set.mem_image],\n  refine ⟨λ h, ⟨x, h, rfl⟩, λ h, _⟩,\n  obtain ⟨y, hy, h⟩ := h,\n  rwa [← @prod.mk.eta _ _ x, ← h, subsingleton.elim x.2 y.2, prod.mk.eta],\nend\n\n/-- Given the state is `subsingleton`, membership in `support` of `simulate` can be checked\nby just checking that the first component is in the support of `simulate'` -/\nlemma mem_support_simulate_iff_fst_mem_support_simulate' (x : α × S) [subsingleton S] :\n  x ∈ (simulate so oa s).support ↔ x.fst ∈ (simulate' so oa s).support :=\nbegin\n  refine subsingleton.elim so.default_state s ▸ _,\n  rw [support_simulate_eq_preimage_support_simulate', set.mem_preimage],\nend\n\nlemma support_simulate_eq_support_simulate_of_subsingleton [subsingleton S]\n  (so : sim_oracle spec spec' S) (so' : sim_oracle spec spec'' S) (s s' : S)\n  (h : ∀ i t, prod.fst '' (so i (t, so.default_state)).support =\n    prod.fst '' (so' i (t, so'.default_state)).support) :\n  (simulate so oa s).support = (simulate so' oa s').support :=\nbegin\n  simp only [support_simulate_eq_preimage_support_simulate'],\n  refine congr_arg _ (support_simulate'_eq_support_simulate' _ oa _ _),\n  intros i t s s',\n  rw [subsingleton.elim s so.default_state, subsingleton.elim s' so'.default_state, h i t],\nend\n\nend support\n\nsection eval_dist\n\nlemma eval_dist_simulate_eq_map_eval_dist_simulate'_of_subsingleton [subsingleton S] (s : S) :\n  ⁅simulate so oa s⁆ = ⁅simulate' so oa s⁆.map (λ x, (x, s)) :=\nbegin\n  have : (λ (x : α), (x, s)) ∘ prod.fst = id,\n  from funext (λ x, prod.eq_iff_fst_eq_snd_eq.2 ⟨rfl, subsingleton.elim _ _⟩),\n  rw [eval_dist_simulate', pmf.map_comp, this, pmf.map_id],\nend\n\nlemma eval_dist_simulate_apply_eq_eval_dist_simulate'_apply_of_subsingleton [subsingleton S]\n  (s : S) (x : α × S) : ⁅simulate so oa s⁆ x = ⁅simulate' so oa s⁆ x.1 :=\nbegin\n  rw [eval_dist_simulate_eq_map_eval_dist_simulate'_of_subsingleton, pmf.map_apply],\n  refine trans (tsum_eq_single x.1 $ λ y hy, by simp only [prod.eq_iff_fst_eq_snd_eq,\n    hy.symm, false_and, if_false]) (by simp only [prod.eq_iff_fst_eq_snd_eq, eq_self_iff_true,\n    eq_iff_true_of_subsingleton, and_self, if_true]),\nend\n\nend eval_dist\n\nsection prob_event\n\nlemma prob_event_simulate_eq_prob_event_image_simulate_of_subsingleton [subsingleton S] (s : S)\n  (e : set (α × S)) : ⁅e | simulate so oa s⁆ = ⁅prod.fst '' e | simulate' so oa s⁆ :=\nbegin\n  sorry\nend\n\nend prob_event\n\nend oracle_comp", "meta": {"author": "dtumad", "repo": "lean-crypto-formalization", "sha": "f975a9a9882120b509553a7ced9aa05b745ff154", "save_path": "github-repos/lean/dtumad-lean-crypto-formalization", "path": "github-repos/lean/dtumad-lean-crypto-formalization/lean-crypto-formalization-f975a9a9882120b509553a7ced9aa05b745ff154/src/computational_monads/simulation_semantics/simulate/subsingleton.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.76908023177796, "lm_q1q2_score": 0.48992779106867107}}
{"text": "import combinatorics.simple_graph.coloring\n\n\n--OUTPUT 1\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume h1 : G.colorable 2,\n    have h2 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from sorry,\n    show (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)), from sorry,\n  },\n  {\n    assume h1 : (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)),\n    have h2 : G.colorable 2, from sorry,\n    show G.colorable 2, from sorry,\n  }\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n  have h2 : (A ∩ B) ⊆ A, from sorry,\n  have h3 : (A ∩ B) ⊆ S, from sorry,\n  show (A ∩ B) ∈  𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by sorry\n  ... = x*(x+y) + y*(x+y) : by sorry\n  ... = x*x + x*y + y*x + y*y : by sorry\n  ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n  have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n      have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n      show e = (1 : G), from sorry,     \n    },\n    sorry,\n  }\nend\n\n/--`theorem`\nBipartite Graph is two colorable\nLet $G$ be a graph. Then $G$ is 2-colorable if and only if $G$ is bipartite.\n`proof`\nLet $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue. Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n\nConversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$. Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable.\n\nQED\n\n-/\ntheorem  bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0_max_tokens_2000_n_1/clean_files/Bipartite Graph is two colorable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4899277838409107}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport data.rat.order\nimport data.int.char_zero\nimport algebra.field.opposite\n\n/-!\n# Casts for Rational Numbers\n\n## Summary\n\nWe define the canonical injection from ℚ into an arbitrary division ring and prove various\ncasting lemmas showing the well-behavedness of this injection.\n\n## Notations\n\n- `/.` is infix notation for `rat.mk`.\n\n## Tags\n\nrat, rationals, field, ℚ, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nopen_locale big_operators\n\nvariables {F ι α β : Type*}\n\nnamespace rat\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring α]\n\n/-- Construct the canonical injection from `ℚ` into an arbitrary\n  division ring. If the field has positive characteristic `p`,\n  we define `1 / p = 1 / 0 = 0` for consistency with our\n  division by zero convention. -/\n-- see Note [coercion into rings]\n@[priority 900] instance cast_coe : has_coe_t ℚ α := ⟨λ r, r.1 / r.2⟩\n\ntheorem cast_def (r : ℚ) : (r : α) = r.num / r.denom := rfl\n\n@[simp] theorem cast_of_int (n : ℤ) : (of_int n : α) = n :=\nshow (n / (1:ℕ) : α) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : ℤ) : ((n : ℚ) : α) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : ℕ) : ((n : ℚ) : α) = n :=\nby rw [← int.cast_coe_nat, cast_coe_int, int.cast_coe_nat]\n\n@[simp, norm_cast] theorem cast_zero : ((0 : ℚ) : α) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : ℚ) : α) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : ℚ) (a : α) : commute ↑r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : ℚ) (a : α) : (r : α) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : α) (r : ℚ) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : ℤ)\n  (b0 : (b:α) ≠ 0) : (a /. b : α) = a / b :=\nbegin\n  have b0' : b ≠ 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:α) ≠ 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:ℤ) ∣ b, by rwa e at dd) with k ke,\n    have : (b:α) = (d:α) * (k:α), {rw [ke, int.cast_mul, int.cast_coe_nat]},\n    rw [d0, zero_mul] at this, contradiction },\n  rw [num_denom'] at e,\n  have := congr_arg (coe : ℤ → α) ((mk_eq b0' $ ne_of_gt $ int.coe_nat_pos.2 h).1 e),\n  rw [int.cast_mul, int.cast_mul, int.cast_coe_nat] at this,\n  symmetry, change (a / b : α) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      ← mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m + n : ℚ) : α) = m + n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 nat.cast_zero),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 nat.cast_zero),\n  rw [num_denom', num_denom', add_def d₁0' d₂0'],\n  suffices : (n₁ * (d₂ * (d₂⁻¹ * d₁⁻¹)) +\n    n₂ * (d₁ * d₂⁻¹) * d₁⁻¹ : α) = n₁ * d₁⁻¹ + n₂ * d₂⁻¹,\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, left_distrib, right_distrib, mul_inv_rev, d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [← mul_assoc (d₂:α), mul_inv_cancel d₂0, one_mul,\n      (nat.cast_commute _ _).eq], simp [d₁0, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : ∀ n, ((-n : ℚ) : α) = -n\n| ⟨n, d, h, c⟩ := show (↑-n / d : α) = -(n / d),\n  by rw [div_eq_mul_inv, div_eq_mul_inv, int.cast_neg, neg_mul_eq_neg_mul]\n\n@[norm_cast] theorem cast_sub_of_ne_zero {m n : ℚ}\n  (m0 : (m.denom : α) ≠ 0) (n0 : (n.denom : α) ≠ 0) : ((m - n : ℚ) : α) = m - n :=\nhave ((-n).denom : α) ≠ 0, by cases n; exact n0,\nby simp [sub_eq_add_neg, (cast_add_of_ne_zero m0 this)]\n\n@[norm_cast] theorem cast_mul_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m * n : ℚ) : α) = m * n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 nat.cast_zero),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 nat.cast_zero),\n  rw [num_denom', num_denom', mul_def d₁0' d₂0'],\n  suffices : (n₁ * ((n₂ * d₂⁻¹) * d₁⁻¹) : α) = n₁ * (d₁⁻¹ * (n₂ * d₂⁻¹)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_rev, d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [(d₁.commute_cast (_:α)).inv_right₀.eq]\nend\n\n@[simp] theorem cast_inv_nat (n : ℕ) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nbegin\n  cases n, { simp },\n  simp_rw [coe_nat_eq_mk, inv_def, mk, mk_nat, dif_neg n.succ_ne_zero, mk_pnat],\n  simp [cast_def]\nend\n\n@[simp] theorem cast_inv_int (n : ℤ) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nbegin\n  cases n,\n  { simp [cast_inv_nat] },\n  { simp only [int.cast_neg_succ_of_nat, ← nat.cast_succ, cast_neg, inv_neg, cast_inv_nat] }\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : ∀ {n : ℚ},\n  (n.num : α) ≠ 0 → (n.denom : α) ≠ 0 → ((n⁻¹ : ℚ) : α) = n⁻¹\n| ⟨n, d, h, c⟩ := λ (n0 : (n:α) ≠ 0) (d0 : (d:α) ≠ 0), begin\n  have n0' : (n:ℤ) ≠ 0 := λ e, by rw e at n0; exact n0 int.cast_zero,\n  have d0' : (d:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d0; exact d0 nat.cast_zero),\n  rw [num_denom', inv_def],\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, inv_div];\n  simp [n0, d0]\nend\n\n@[norm_cast] theorem cast_div_of_ne_zero {m n : ℚ} (md : (m.denom : α) ≠ 0)\n  (nn : (n.num : α) ≠ 0) (nd : (n.denom : α) ≠ 0) : ((m / n : ℚ) : α) = m / n :=\nhave (n⁻¹.denom : ℤ) ∣ n.num,\nby conv in n⁻¹.denom { rw [←(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n⁻¹.denom : α) = 0 → (n.num : α) = 0, from\nλ h, let ⟨k, e⟩ := this in\n  by have := congr_arg (coe : ℤ → α) e;\n     rwa [int.cast_mul, int.cast_coe_nat, h, zero_mul] at this,\nby rw [division_def, cast_mul_of_ne_zero md (mt this nn), cast_inv_of_ne_zero nn nd, division_def]\n\n@[simp, norm_cast] theorem cast_inj [char_zero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := begin\n  refine ⟨λ h, _, congr_arg _⟩,\n  have d₁0 : d₁ ≠ 0 := ne_of_gt h₁,\n  have d₂0 : d₂ ≠ 0 := ne_of_gt h₂,\n  have d₁a : (d₁:α) ≠ 0 := nat.cast_ne_zero.2 d₁0,\n  have d₂a : (d₂:α) ≠ 0 := nat.cast_ne_zero.2 d₂0,\n  rw [num_denom', num_denom'] at h ⊢,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d₁0, d₂0] at h ⊢,\n  rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂:α)).inv_left₀.eq,\n    ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm,\n    ← int.cast_coe_nat d₁, ← int.cast_mul, ← int.cast_coe_nat d₂, ← int.cast_mul,\n    int.cast_inj, ← mk_eq (int.coe_nat_ne_zero.2 d₁0) (int.coe_nat_ne_zero.2 d₂0)] at h\nend\n\ntheorem cast_injective [char_zero α] : function.injective (coe : ℚ → α)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 :=\nby rw [← cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero α] {n : ℚ} : (n : α) ≠ 0 ↔ n ≠ 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero α] (m n) :\n  ((m + n : ℚ) : α) = m + n :=\ncast_add_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_sub [char_zero α] (m n) :\n  ((m - n : ℚ) : α) = m - n :=\ncast_sub_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_mul [char_zero α] (m n) :\n  ((m * n : ℚ) : α) = m * n :=\ncast_mul_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_bit0 [char_zero α] (n : ℚ) :\n  ((bit0 n : ℚ) : α) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero α] (n : ℚ) :\n  ((bit1 n : ℚ) : α) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariables (α) [char_zero α]\n\n/-- Coercion `ℚ → α` as a `ring_hom`. -/\ndef cast_hom : ℚ →+* α := ⟨coe, cast_one, cast_mul, cast_zero, cast_add⟩\n\nvariable {α}\n\n@[simp] lemma coe_cast_hom : ⇑(cast_hom α) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv (n) : ((n⁻¹ : ℚ) : α) = n⁻¹ := (cast_hom α).map_inv _\n@[simp, norm_cast] theorem cast_div (m n) : ((m / n : ℚ) : α) = m / n := (cast_hom α).map_div _ _\n\n@[norm_cast] theorem cast_mk (a b : ℤ) : ((a /. b) : α) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow (q) (k : ℕ) : ((q ^ k : ℚ) : α) = q ^ k :=\n(cast_hom α).map_pow q k\n\n@[simp, norm_cast] lemma cast_list_sum (s : list ℚ) : (↑(s.sum) : α) = (s.map coe).sum :=\nmap_list_sum (rat.cast_hom α) _\n\n@[simp, norm_cast] lemma cast_multiset_sum (s : multiset ℚ) : (↑(s.sum) : α) = (s.map coe).sum :=\nmap_multiset_sum (rat.cast_hom α) _\n\n@[simp, norm_cast] lemma cast_sum (s : finset ι) (f : ι → ℚ) :\n  (↑(∑ i in s, f i) : α) = ∑ i in s, f i :=\nmap_sum (rat.cast_hom α) _ _\n\n@[simp, norm_cast] lemma cast_list_prod (s : list ℚ) : (↑(s.prod) : α) = (s.map coe).prod :=\nmap_list_prod (rat.cast_hom α) _\n\nend with_div_ring\n\nsection field\nvariables [field α] [char_zero α]\n\n@[simp, norm_cast] lemma cast_multiset_prod (s : multiset ℚ) : (↑(s.prod) : α) = (s.map coe).prod :=\nmap_multiset_prod (rat.cast_hom α) _\n\n@[simp, norm_cast] lemma cast_prod (s : finset ι) (f : ι → ℚ) :\n  (↑(∏ i in s, f i) : α) = ∏ i in s, f i :=\nmap_prod (rat.cast_hom α) _ _\n\nend field\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field α] : ∀ {n : ℚ}, 0 ≤ (n : α) ↔ 0 ≤ n\n| ⟨n, d, h, c⟩ :=\n  by { rw [num_denom', cast_mk, mk_eq_div, div_nonneg_iff, div_nonneg_iff], norm_cast }\n\n@[simp, norm_cast] theorem cast_le [linear_ordered_field α] {m n : ℚ} : (m : α) ≤ n ↔ m ≤ n :=\nby rw [← sub_nonneg, ← cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field α] {m n : ℚ} : (m : α) < n ↔ m < n :=\nby simpa [-cast_le] using not_congr (@cast_le α _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field α] {n : ℚ} : (n : α) ≤ 0 ↔ n ≤ 0 :=\nby rw [← cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field α] {n : ℚ} : (0 : α) < n ↔ 0 < n :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field α] {n : ℚ} : (n : α) < 0 ↔ n < 0 :=\nby rw [← cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : ∀ n : ℚ, ↑n = n\n| ⟨n, d, h, c⟩ := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp] lemma cast_hom_rat : cast_hom ℚ = ring_hom.id ℚ :=\nring_hom.ext cast_id\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field α] {a b : ℚ} :\n  (↑(min a b) : α) = min a b :=\nby by_cases a ≤ b; simp [h, min_def]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field α] {a b : ℚ} :\n  (↑(max a b) : α) = max a b :=\nby by_cases b ≤ a; simp [h, max_def]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field α] {q : ℚ} :\n  ((|q| : ℚ) : α) = |q| :=\nby simp [abs_eq_max_neg]\n\nend rat\n\nopen rat ring_hom\n\nlemma ring_hom.eq_rat_cast {k} [division_ring k] (f : ℚ →+* k) (r : ℚ) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [← int.cast_coe_nat, ← mk_eq_div, num_denom]\n     ... = f r.1 / f r.2 : f.map_div _ _\n     ... = r.1 / r.2     : by rw [map_nat_cast, map_int_cast]\n\n-- This seems to be true for a `[char_p k]` too because `k'` must have the same characteristic\n-- but the proof would be much longer\n@[simp] lemma map_rat_cast [division_ring α] [division_ring β] [char_zero α] [ring_hom_class F α β]\n  (f : F) (q : ℚ) : f q = q :=\n((f : α →+* β).comp $ cast_hom α).eq_rat_cast q\n\nlemma ring_hom.ext_rat {R : Type*} [semiring R] (f g : ℚ →+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let φ : ℤ →+* R := f.comp (int.cast_ring_hom ℚ),\n  let ψ : ℤ →+* R := g.comp (int.cast_ring_hom ℚ),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:ℚ) ≠ 0 := nat.cast_ne_zero.2 b0,\n  have : ∀ n : ℤ, f n = g n := λ n, show φ n = ψ n, by rw [φ.ext_int ψ],\n  calc f (a * b⁻¹)\n      = f a * f b⁻¹ * (g (b:ℤ) * g b⁻¹) :\n        by rw [int.cast_coe_nat, ← g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b⁻¹ * (f (b:ℤ) * g b⁻¹) : by rw [this a, ← this b]\n  ... = g (a * b⁻¹) :\n        by rw [int.cast_coe_nat, mul_assoc, ← mul_assoc (f b⁻¹),\n              ← f.map_mul, inv_mul_cancel b0', f.map_one, one_mul, g.map_mul]\nend\n\ninstance rat.subsingleton_ring_hom {R : Type*} [semiring R] : subsingleton (ℚ →+* R) :=\n⟨ring_hom.ext_rat⟩\n\nnamespace monoid_with_zero_hom\n\nvariables {M : Type*} [group_with_zero M]\n\n/-- If `f` and `g` agree on the integers then they are equal `φ`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : ℚ →*₀ M}\n  (same_on_int : f.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : ∀ k : ℤ, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [← @rat.num_denom x, rat.mk_eq_div, f.map_div, g.map_div,\n    same_on_int' x.num, same_on_int' x.denom],\nend\n\n/-- Positive integer values of a morphism `φ` and its value on `-1` completely determine `φ`. -/\ntheorem ext_rat_on_pnat {f g : ℚ →*₀ M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : ∀ n : ℕ, 0 < n → f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) ‹_›\n\nend monoid_with_zero_hom\n\nnamespace mul_opposite\n\nvariables [division_ring α]\n\n@[simp, norm_cast] lemma op_rat_cast (r : ℚ) : op (r : α) = (↑r : αᵐᵒᵖ) :=\nby rw [cast_def, div_eq_mul_inv, op_mul, op_inv, op_nat_cast, op_int_cast,\n    (commute.cast_int_right _ r.num).eq, cast_def, div_eq_mul_inv]\n\n@[simp, norm_cast] lemma unop_rat_cast (r : ℚ) : unop (r : αᵐᵒᵖ) = r :=\nby rw [cast_def, div_eq_mul_inv, unop_mul, unop_inv, unop_nat_cast, unop_int_cast,\n    (commute.cast_int_right _ r.num).eq, cast_def, div_eq_mul_inv]\n\nend mul_opposite\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/data/rat/cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.48984167627079245}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module algebraic_geometry.morphisms.basic\n! leanprover-community/mathlib commit 434e2fd21c1900747afc6d13d8be7f4eedba7218\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.AlgebraicGeometry.AffineScheme\nimport Mathbin.AlgebraicGeometry.Pullbacks\nimport Mathbin.CategoryTheory.MorphismProperty\n\n/-!\n# Properties of morphisms between Schemes\n\nWe provide the basic framework for talking about properties of morphisms between Schemes.\n\nA `morphism_property Scheme` is a predicate on morphisms between schemes, and an\n`affine_target_morphism_property` is a predicate on morphisms into affine schemes. Given a\n`P : affine_target_morphism_property`, we may construct a `morphism_property` called\n`target_affine_locally P` that holds for `f : X ⟶ Y` whenever `P` holds for the\nrestriction of `f` on every affine open subset of `Y`.\n\n## Main definitions\n\n- `algebraic_geometry.affine_target_morphism_property.is_local`: We say that `P.is_local` if `P`\nsatisfies the assumptions of the affine communication lemma\n(`algebraic_geometry.of_affine_open_cover`). That is,\n1. `P` respects isomorphisms.\n2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ Y.basic_open r` for any\n  global section `r`.\n3. If `P` holds for `f ∣_ Y.basic_open r` for all `r` in a spanning set of the global sections,\n  then `P` holds for `f`.\n\n- `algebraic_geometry.property_is_local_at_target`: We say that `property_is_local_at_target P` for\n`P : morphism_property Scheme` if\n1. `P` respects isomorphisms.\n2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any `U`.\n3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.\n\n## Main results\n\n- `algebraic_geometry.affine_target_morphism_property.is_local.affine_open_cover_tfae`:\n  If `P.is_local`, then `target_affine_locally P f` iff there exists an affine cover `{ Uᵢ }` of `Y`\n  such that `P` holds for `f ∣_ Uᵢ`.\n- `algebraic_geometry.affine_target_morphism_property.is_local_of_open_cover_imply`:\n  If the existance of an affine cover `{ Uᵢ }` of `Y` such that `P` holds for `f ∣_ Uᵢ` implies\n  `target_affine_locally P f`, then `P.is_local`.\n- `algebraic_geometry.affine_target_morphism_property.is_local.affine_target_iff`:\n  If `Y` is affine and `f : X ⟶ Y`, then `target_affine_locally P f ↔ P f` provided `P.is_local`.\n- `algebraic_geometry.affine_target_morphism_property.is_local.target_affine_locally_is_local` :\n  If `P.is_local`, then `property_is_local_at_target (target_affine_locally P)`.\n- `algebraic_geometry.property_is_local_at_target.open_cover_tfae`:\n  If `property_is_local_at_target P`, then `P f` iff there exists an open cover `{ Uᵢ }` of `Y`\n  such that `P` holds for `f ∣_ Uᵢ`.\n\nThese results should not be used directly, and should be ported to each property that is local.\n\n-/\n\n\nuniverse u\n\nopen TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite\n\nnoncomputable section\n\nnamespace AlgebraicGeometry\n\n/-- An `affine_target_morphism_property` is a class of morphisms from an arbitrary scheme into an\naffine scheme. -/\ndef AffineTargetMorphismProperty :=\n  ∀ ⦃X Y : Scheme⦄ (f : X ⟶ Y) [IsAffine Y], Prop\n#align algebraic_geometry.affine_target_morphism_property AlgebraicGeometry.AffineTargetMorphismProperty\n\n/-- `is_iso` as a `morphism_property`. -/\nprotected def Scheme.isIso : MorphismProperty Scheme :=\n  @IsIso Scheme _\n#align algebraic_geometry.Scheme.is_iso AlgebraicGeometry.Scheme.isIso\n\n/-- `is_iso` as an `affine_morphism_property`. -/\nprotected def Scheme.affineTargetIsIso : AffineTargetMorphismProperty := fun X Y f H => IsIso f\n#align algebraic_geometry.Scheme.affine_target_is_iso AlgebraicGeometry.Scheme.affineTargetIsIso\n\ninstance : Inhabited AffineTargetMorphismProperty :=\n  ⟨Scheme.affineTargetIsIso⟩\n\n/-- A `affine_target_morphism_property` can be extended to a `morphism_property` such that it\n*never* holds when the target is not affine -/\ndef AffineTargetMorphismProperty.toProperty (P : AffineTargetMorphismProperty) :\n    MorphismProperty Scheme := fun X Y f => ∃ h, @P f h\n#align algebraic_geometry.affine_target_morphism_property.to_property AlgebraicGeometry.AffineTargetMorphismProperty.toProperty\n\ntheorem AffineTargetMorphismProperty.toProperty_apply (P : AffineTargetMorphismProperty)\n    {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y] : P.toProperty f ↔ P f :=\n  by\n  delta affine_target_morphism_property.to_property\n  simp [*]\n#align algebraic_geometry.affine_target_morphism_property.to_property_apply AlgebraicGeometry.AffineTargetMorphismProperty.toProperty_apply\n\ntheorem affine_cancel_left_isIso {P : AffineTargetMorphismProperty} (hP : P.toProperty.RespectsIso)\n    {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] [IsAffine Z] : P (f ≫ g) ↔ P g := by\n  rw [← P.to_property_apply, ← P.to_property_apply, hP.cancel_left_is_iso]\n#align algebraic_geometry.affine_cancel_left_is_iso AlgebraicGeometry.affine_cancel_left_isIso\n\ntheorem affine_cancel_right_isIso {P : AffineTargetMorphismProperty} (hP : P.toProperty.RespectsIso)\n    {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] [IsAffine Z] [IsAffine Y] :\n    P (f ≫ g) ↔ P f := by rw [← P.to_property_apply, ← P.to_property_apply, hP.cancel_right_is_iso]\n#align algebraic_geometry.affine_cancel_right_is_iso AlgebraicGeometry.affine_cancel_right_isIso\n\ntheorem AffineTargetMorphismProperty.respectsIso_mk {P : AffineTargetMorphismProperty}\n    (h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))\n    (h₂ :\n      ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y],\n        P f → @P (f ≫ e.hom) (is_affine_of_iso e.inv)) :\n    P.toProperty.RespectsIso := by\n  constructor\n  · rintro X Y Z e f ⟨a, h⟩\n    exact ⟨a, h₁ e f h⟩\n  · rintro X Y Z e f ⟨a, h⟩\n    exact ⟨is_affine_of_iso e.inv, h₂ e f h⟩\n#align algebraic_geometry.affine_target_morphism_property.respects_iso_mk AlgebraicGeometry.AffineTargetMorphismProperty.respectsIso_mk\n\n/-- For a `P : affine_target_morphism_property`, `target_affine_locally P` holds for\n`f : X ⟶ Y` whenever `P` holds for the restriction of `f` on every affine open subset of `Y`. -/\ndef targetAffineLocally (P : AffineTargetMorphismProperty) : MorphismProperty Scheme :=\n  fun {X Y : Scheme} (f : X ⟶ Y) => ∀ U : Y.affineOpens, @P (f ∣_ U) U.Prop\n#align algebraic_geometry.target_affine_locally AlgebraicGeometry.targetAffineLocally\n\ntheorem IsAffineOpen.map_isIso {X Y : Scheme} {U : Opens Y.carrier} (hU : IsAffineOpen U)\n    (f : X ⟶ Y) [IsIso f] : IsAffineOpen ((Opens.map f.1.base).obj U) :=\n  haveI : is_affine _ := hU\n  is_affine_of_iso (f ∣_ U)\n#align algebraic_geometry.is_affine_open.map_is_iso AlgebraicGeometry.IsAffineOpen.map_isIso\n\ntheorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}\n    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso :=\n  by\n  constructor\n  · introv H U\n    rw [morphism_restrict_comp, affine_cancel_left_is_iso hP]\n    exact H U\n  · introv H\n    rintro ⟨U, hU : is_affine_open U⟩\n    dsimp\n    haveI : is_affine _ := hU\n    haveI : is_affine _ := hU.map_is_iso e.hom\n    rw [morphism_restrict_comp, affine_cancel_right_is_iso hP]\n    exact H ⟨(opens.map e.hom.val.base).obj U, hU.map_is_iso e.hom⟩\n#align algebraic_geometry.target_affine_locally_respects_iso AlgebraicGeometry.targetAffineLocally_respectsIso\n\n/-- We say that `P : affine_target_morphism_property` is a local property if\n1. `P` respects isomorphisms.\n2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ Y.basic_open r` for any\n  global section `r`.\n3. If `P` holds for `f ∣_ Y.basic_open r` for all `r` in a spanning set of the global sections,\n  then `P` holds for `f`.\n-/\nstructure AffineTargetMorphismProperty.IsLocal (P : AffineTargetMorphismProperty) : Prop where\n  RespectsIso : P.toProperty.RespectsIso\n  toBasicOpen :\n    ∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (r : Y.Presheaf.obj <| op ⊤),\n      P f → @P (f ∣_ Y.basic_open r) ((top_is_affine_open Y).basicOpen_is_affine _)\n  ofBasicOpenCover :\n    ∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (s : Finset (Y.Presheaf.obj <| op ⊤))\n      (hs : Ideal.span (s : Set (Y.Presheaf.obj <| op ⊤)) = ⊤),\n      (∀ r : s, @P (f ∣_ Y.basic_open r.1) ((top_is_affine_open Y).basicOpen_is_affine _)) → P f\n#align algebraic_geometry.affine_target_morphism_property.is_local AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal\n\ntheorem targetAffineLocallyOfOpenCover {P : AffineTargetMorphismProperty} (hP : P.IsLocal)\n    {X Y : Scheme} (f : X ⟶ Y) (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)]\n    (h𝒰 : ∀ i, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) : targetAffineLocally P f :=\n  by\n  classical\n    let S i :=\n      (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.is_open i).base_open.open_range⟩,\n          range_is_affine_open_of_open_immersion (𝒰.map i)⟩ :\n        Y.affine_opens)\n    intro U\n    apply of_affine_open_cover U (Set.range S)\n    · intro U r h\n      haveI : is_affine _ := U.2\n      have := hP.2 (f ∣_ U.1)\n      replace this := this (Y.presheaf.map (eq_to_hom U.1.openEmbedding_obj_top).op r) h\n      rw [← P.to_property_apply] at this⊢\n      exact (hP.1.arrow_mk_iso_iff (morphism_restrict_restrict_basic_open f _ r)).mp this\n    · intro U s hs H\n      haveI : is_affine _ := U.2\n      apply hP.3 (f ∣_ U.1) (s.image (Y.presheaf.map (eq_to_hom U.1.openEmbedding_obj_top).op))\n      · apply_fun Ideal.comap (Y.presheaf.map (eq_to_hom U.1.openEmbedding_obj_top.symm).op)  at hs\n        rw [Ideal.comap_top] at hs\n        rw [← hs]\n        simp only [eq_to_hom_op, eq_to_hom_map, Finset.coe_image]\n        have :\n          ∀ {R S : CommRingCat} (e : S = R) (s : Set S),\n            Ideal.span (eq_to_hom e '' s) = Ideal.comap (eq_to_hom e.symm) (Ideal.span s) :=\n          by\n          intros\n          subst e\n          simpa\n        apply this\n      · rintro ⟨r, hr⟩\n        obtain ⟨r, hr', rfl⟩ := finset.mem_image.mp hr\n        simp_rw [← P.to_property_apply] at H⊢\n        exact (hP.1.arrow_mk_iso_iff (morphism_restrict_restrict_basic_open f _ r)).mpr (H ⟨r, hr'⟩)\n    · rw [Set.eq_univ_iff_forall]\n      simp only [Set.mem_unionᵢ]\n      intro x\n      exact ⟨⟨_, ⟨𝒰.f x, rfl⟩⟩, 𝒰.covers x⟩\n    · rintro ⟨_, i, rfl⟩\n      simp_rw [← P.to_property_apply] at h𝒰⊢\n      exact (hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)).mpr (h𝒰 i)\n#align algebraic_geometry.target_affine_locally_of_open_cover AlgebraicGeometry.targetAffineLocallyOfOpenCover\n\ntheorem AffineTargetMorphismProperty.IsLocal.affine_openCover_tFAE\n    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :\n    TFAE\n      [targetAffineLocally P f,\n        ∃ (𝒰 : Scheme.OpenCover.{u} Y)(_ : ∀ i, IsAffine (𝒰.obj i)),\n          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullback_cover f).obj i ⟶ 𝒰.obj i),\n        ∀ (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)] (i : 𝒰.J),\n          P (pullback.snd : (𝒰.pullback_cover f).obj i ⟶ 𝒰.obj i),\n        ∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],\n          P (pullback.snd : pullback f g ⟶ U),\n        ∃ (ι : Type u)(U : ι → Opens Y.carrier)(hU : supᵢ U = ⊤)(hU' : ∀ i, IsAffineOpen (U i)),\n          ∀ i, @P (f ∣_ U i) (hU' i)] :=\n  by\n  tfae_have 1 → 4\n  · intro H U g h₁ h₂\n    skip\n    replace H := H ⟨⟨_, h₂.base_open.open_range⟩, range_is_affine_open_of_open_immersion g⟩\n    rw [← P.to_property_apply] at H⊢\n    rwa [← hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n  tfae_have 4 → 3\n  · intro H 𝒰 h𝒰 i\n    skip\n    apply H\n  tfae_have 3 → 2\n  · exact fun H => ⟨Y.affine_cover, inferInstance, H Y.affine_cover⟩\n  tfae_have 2 → 1\n  · rintro ⟨𝒰, h𝒰, H⟩\n    exact target_affine_locally_of_open_cover hP f 𝒰 H\n  tfae_have 5 → 2\n  · rintro ⟨ι, U, hU, hU', H⟩\n    refine' ⟨Y.open_cover_of_supr_eq_top U hU, hU', _⟩\n    intro i\n    specialize H i\n    rw [← P.to_property_apply, ← hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n    rw [← P.to_property_apply] at H\n    convert H\n    all_goals ext1; exact Subtype.range_coe\n  tfae_have 1 → 5\n  · intro H\n    refine'\n      ⟨Y.carrier, fun x => (Y.affine_cover.map x).opensRange, _, fun i =>\n        range_is_affine_open_of_open_immersion _, _⟩\n    · rw [eq_top_iff]\n      intro x _\n      erw [opens.mem_supr]\n      exact ⟨x, Y.affine_cover.covers x⟩\n    · intro i\n      exact H ⟨_, range_is_affine_open_of_open_immersion _⟩\n  tfae_finish\n#align algebraic_geometry.affine_target_morphism_property.is_local.affine_open_cover_tfae AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_openCover_tFAE\n\ntheorem AffineTargetMorphismProperty.isLocalOfOpenCoverImply (P : AffineTargetMorphismProperty)\n    (hP : P.toProperty.RespectsIso)\n    (H :\n      ∀ {X Y : Scheme.{u}} (f : X ⟶ Y),\n        (∃ (𝒰 : Scheme.OpenCover.{u} Y)(_ : ∀ i, IsAffine (𝒰.obj i)),\n            ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullback_cover f).obj i ⟶ 𝒰.obj i)) →\n          ∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],\n            P (pullback.snd : pullback f g ⟶ U)) :\n    P.IsLocal := by\n  refine' ⟨hP, _, _⟩\n  · introv h\n    skip\n    haveI : is_affine _ := (top_is_affine_open Y).basicOpen_is_affine r\n    delta morphism_restrict\n    rw [affine_cancel_left_is_iso hP]\n    refine' @H f ⟨Scheme.open_cover_of_is_iso (𝟙 Y), _, _⟩ (Y.of_restrict _) _inst _\n    · intro i\n      dsimp\n      infer_instance\n    · intro i\n      dsimp\n      rwa [← category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_is_iso hP]\n  · introv hs hs'\n    skip\n    replace hs := ((top_is_affine_open Y).basicOpen_union_eq_self_iff _).mpr hs\n    have := H f ⟨Y.open_cover_of_supr_eq_top _ hs, _, _⟩ (𝟙 _)\n    rwa [← category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_is_iso hP] at\n      this\n    · intro i\n      exact (top_is_affine_open Y).basicOpen_is_affine _\n    · rintro (i : s)\n      specialize hs' i\n      haveI : is_affine _ := (top_is_affine_open Y).basicOpen_is_affine i.1\n      delta morphism_restrict at hs'\n      rwa [affine_cancel_left_is_iso hP] at hs'\n#align algebraic_geometry.affine_target_morphism_property.is_local_of_open_cover_imply AlgebraicGeometry.AffineTargetMorphismProperty.isLocalOfOpenCoverImply\n\ntheorem AffineTargetMorphismProperty.IsLocal.affine_openCover_iff {P : AffineTargetMorphismProperty}\n    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y)\n    [h𝒰 : ∀ i, IsAffine (𝒰.obj i)] :\n    targetAffineLocally P f ↔ ∀ i, @P (pullback.snd : pullback f (𝒰.map i) ⟶ _) (h𝒰 i) :=\n  ⟨fun H =>\n    let h := ((hP.affine_openCover_tFAE f).out 0 2).mp H\n    h 𝒰,\n    fun H =>\n    let h := ((hP.affine_openCover_tFAE f).out 1 0).mp\n    h ⟨𝒰, inferInstance, H⟩⟩\n#align algebraic_geometry.affine_target_morphism_property.is_local.affine_open_cover_iff AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_openCover_iff\n\ntheorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}\n    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] : targetAffineLocally P f ↔ P f :=\n  by\n  rw [hP.affine_open_cover_iff f _]\n  swap; · exact Scheme.open_cover_of_is_iso (𝟙 Y)\n  swap;\n  · intro\n    dsimp\n    infer_instance\n  trans P (pullback.snd : pullback f (𝟙 _) ⟶ _)\n  · exact ⟨fun H => H PUnit.unit, fun H _ => H⟩\n  rw [← category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_is_iso hP.1]\n#align algebraic_geometry.affine_target_morphism_property.is_local.affine_target_iff AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_target_iff\n\n/-- We say that `P : morphism_property Scheme` is local at the target if\n1. `P` respects isomorphisms.\n2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any `U`.\n3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.\n-/\nstructure PropertyIsLocalAtTarget (P : MorphismProperty Scheme) : Prop where\n  RespectsIso : P.RespectsIso\n  restrict : ∀ {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y.carrier), P f → P (f ∣_ U)\n  of_open_cover :\n    ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y),\n      (∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) → P f\n#align algebraic_geometry.property_is_local_at_target AlgebraicGeometry.PropertyIsLocalAtTarget\n\ntheorem AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal\n    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) :\n    PropertyIsLocalAtTarget (targetAffineLocally P) :=\n  by\n  constructor\n  · exact target_affine_locally_respects_iso hP.1\n  · intro X Y f U H V\n    rw [← P.to_property_apply, hP.1.arrow_mk_iso_iff (morphism_restrict_restrict f _ _)]\n    convert H ⟨_, is_affine_open.image_is_open_immersion V.2 (Y.of_restrict _)⟩\n    rw [← P.to_property_apply]\n    rfl\n  · rintro X Y f 𝒰 h𝒰\n    rw [(hP.affine_open_cover_tfae f).out 0 1]\n    refine' ⟨𝒰.bind fun _ => Scheme.affine_cover _, _, _⟩\n    · intro i\n      dsimp [Scheme.open_cover.bind]\n      infer_instance\n    · intro i\n      specialize h𝒰 i.1\n      rw [(hP.affine_open_cover_tfae (pullback.snd : pullback f (𝒰.map i.fst) ⟶ _)).out 0 2] at h𝒰\n      specialize h𝒰 (Scheme.affine_cover _) i.2\n      let e :\n        pullback f ((𝒰.obj i.fst).affineCover.map i.snd ≫ 𝒰.map i.fst) ⟶\n          pullback (pullback.snd : pullback f (𝒰.map i.fst) ⟶ _)\n            ((𝒰.obj i.fst).affineCover.map i.snd) :=\n        by\n        refine' (pullback_symmetry _ _).Hom ≫ _\n        refine' (pullback_right_pullback_fst_iso _ _ _).inv ≫ _\n        refine' (pullback_symmetry _ _).Hom ≫ _\n        refine' pullback.map _ _ _ _ (pullback_symmetry _ _).Hom (𝟙 _) (𝟙 _) _ _ <;>\n          simp only [category.comp_id, category.id_comp, pullback_symmetry_hom_comp_snd]\n      rw [← affine_cancel_left_is_iso hP.1 e] at h𝒰\n      convert h𝒰\n      simp\n#align algebraic_geometry.affine_target_morphism_property.is_local.target_affine_locally_is_local AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal\n\ntheorem PropertyIsLocalAtTarget.openCover_tFAE {P : MorphismProperty Scheme}\n    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) :\n    TFAE\n      [P f,\n        ∃ 𝒰 : Scheme.OpenCover.{u} Y,\n          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),\n        ∀ (𝒰 : Scheme.OpenCover.{u} Y) (i : 𝒰.J),\n          P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),\n        ∀ U : Opens Y.carrier, P (f ∣_ U),\n        ∀ {U : Scheme} (g : U ⟶ Y) [IsOpenImmersion g], P (pullback.snd : pullback f g ⟶ U),\n        ∃ (ι : Type u)(U : ι → Opens Y.carrier)(hU : supᵢ U = ⊤), ∀ i, P (f ∣_ U i)] :=\n  by\n  tfae_have 2 → 1\n  · rintro ⟨𝒰, H⟩\n    exact hP.3 f 𝒰 H\n  tfae_have 1 → 4\n  · intro H U\n    exact hP.2 f U H\n  tfae_have 4 → 3\n  · intro H 𝒰 i\n    rw [← hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n    exact H (𝒰.map i).opensRange\n  tfae_have 3 → 2\n  · exact fun H => ⟨Y.affine_cover, H Y.affine_cover⟩\n  tfae_have 4 → 5\n  · intro H U g hg\n    skip\n    rw [← hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n    apply H\n  tfae_have 5 → 4\n  · intro H U\n    erw [hP.1.cancel_left_isIso]\n    apply H\n  tfae_have 4 → 6\n  · intro H\n    exact ⟨PUnit, fun _ => ⊤, csupᵢ_const, fun _ => H _⟩\n  tfae_have 6 → 2\n  · rintro ⟨ι, U, hU, H⟩\n    refine' ⟨Y.open_cover_of_supr_eq_top U hU, _⟩\n    intro i\n    rw [← hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n    convert H i\n    all_goals ext1; exact Subtype.range_coe\n  tfae_finish\n#align algebraic_geometry.property_is_local_at_target.open_cover_tfae AlgebraicGeometry.PropertyIsLocalAtTarget.openCover_tFAE\n\ntheorem PropertyIsLocalAtTarget.openCover_iff {P : MorphismProperty Scheme}\n    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) :\n    P f ↔ ∀ i, P (pullback.snd : pullback f (𝒰.map i) ⟶ _) :=\n  ⟨fun H =>\n    let h := ((hP.openCover_tFAE f).out 0 2).mp H\n    h 𝒰,\n    fun H =>\n    let h := ((hP.openCover_tFAE f).out 1 0).mp\n    h ⟨𝒰, H⟩⟩\n#align algebraic_geometry.property_is_local_at_target.open_cover_iff AlgebraicGeometry.PropertyIsLocalAtTarget.openCover_iff\n\nnamespace AffineTargetMorphismProperty\n\n/-- A `P : affine_target_morphism_property` is stable under base change if `P` holds for `Y ⟶ S`\nimplies that `P` holds for `X ×ₛ Y ⟶ X` with `X` and `S` affine schemes. -/\ndef StableUnderBaseChange (P : AffineTargetMorphismProperty) : Prop :=\n  ∀ ⦃X Y S : Scheme⦄ [IsAffine S] [IsAffine X] (f : X ⟶ S) (g : Y ⟶ S),\n    P g → P (pullback.fst : pullback f g ⟶ X)\n#align algebraic_geometry.affine_target_morphism_property.stable_under_base_change AlgebraicGeometry.AffineTargetMorphismProperty.StableUnderBaseChange\n\ntheorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange\n    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)\n    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :\n    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) :=\n  by\n  rw [(hP.affine_open_cover_tfae (pullback.fst : pullback f g ⟶ X)).out 0 1]\n  use X.affine_cover, inferInstance\n  intro i\n  let e := pullback_symmetry _ _ ≪≫ pullback_right_pullback_fst_iso f g (X.affine_cover.map i)\n  have : e.hom ≫ pullback.fst = pullback.snd := by simp\n  rw [← this, affine_cancel_left_is_iso hP.1]\n  apply hP' <;> assumption\n#align algebraic_geometry.affine_target_morphism_property.is_local.target_affine_locally_pullback_fst_of_right_of_stable_under_base_change AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange\n\ntheorem IsLocal.stableUnderBaseChange {P : AffineTargetMorphismProperty} (hP : P.IsLocal)\n    (hP' : P.StableUnderBaseChange) : (targetAffineLocally P).StableUnderBaseChange :=\n  MorphismProperty.StableUnderBaseChange.mk (targetAffineLocally_respectsIso hP.RespectsIso)\n    (by\n      intro X Y S f g H\n      rw [(hP.target_affine_locally_is_local.open_cover_tfae (pullback.fst : pullback f g ⟶ X)).out\n          0 1]\n      use S.affine_cover.pullback_cover f\n      intro i\n      rw [(hP.affine_open_cover_tfae g).out 0 3] at H\n      let e :\n        pullback (pullback.fst : pullback f g ⟶ _) ((S.affine_cover.pullback_cover f).map i) ≅ _ :=\n        by\n        refine'\n          pullback_symmetry _ _ ≪≫\n            pullback_right_pullback_fst_iso f g _ ≪≫\n              _ ≪≫\n                (pullback_right_pullback_fst_iso (S.affine_cover.map i) g\n                    (pullback.snd : pullback f (S.affine_cover.map i) ⟶ _)).symm\n        exact\n          as_iso\n            (pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simpa using pullback.condition) (by simp))\n      have : e.hom ≫ pullback.fst = pullback.snd := by simp\n      rw [← this, (target_affine_locally_respects_iso hP.1).cancel_left_isIso]\n      apply hP.target_affine_locally_pullback_fst_of_right_of_stable_under_base_change hP'\n      rw [← pullback_symmetry_hom_comp_snd, affine_cancel_left_is_iso hP.1]\n      apply H)\n#align algebraic_geometry.affine_target_morphism_property.is_local.stable_under_base_change AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.stableUnderBaseChange\n\nend AffineTargetMorphismProperty\n\n/-- The `affine_target_morphism_property` associated to `(target_affine_locally P).diagonal`.\nSee `diagonal_target_affine_locally_eq_target_affine_locally`.\n-/\ndef AffineTargetMorphismProperty.diagonal (P : AffineTargetMorphismProperty) :\n    AffineTargetMorphismProperty := fun X Y f hf =>\n  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [IsAffine U₁] [IsAffine U₂] [IsOpenImmersion f₁]\n    [IsOpenImmersion f₂], P (pullback.map_desc f₁ f₂ f)\n#align algebraic_geometry.affine_target_morphism_property.diagonal AlgebraicGeometry.AffineTargetMorphismProperty.diagonal\n\ntheorem AffineTargetMorphismProperty.diagonal_respectsIso (P : AffineTargetMorphismProperty)\n    (hP : P.toProperty.RespectsIso) : P.diagonal.toProperty.RespectsIso :=\n  by\n  delta affine_target_morphism_property.diagonal\n  apply affine_target_morphism_property.respects_iso_mk\n  · introv H _ _\n    skip\n    rw [pullback.map_desc_comp, affine_cancel_left_is_iso hP, affine_cancel_right_is_iso hP]\n    apply H\n  · introv H _ _\n    skip\n    rw [pullback.map_desc_comp, affine_cancel_right_is_iso hP]\n    apply H\n#align algebraic_geometry.affine_target_morphism_property.diagonal_respects_iso AlgebraicGeometry.AffineTargetMorphismProperty.diagonal_respectsIso\n\ntheorem diagonalTargetAffineLocallyOfOpenCover (P : AffineTargetMorphismProperty) (hP : P.IsLocal)\n    {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]\n    (𝒰' : ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) [∀ i j, IsAffine ((𝒰' i).obj j)]\n    (h𝒰' : ∀ i j k, P (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)) :\n    (targetAffineLocally P).diagonal f :=\n  by\n  refine' (hP.affine_open_cover_iff _ _).mpr _\n  ·\n    exact\n      (Scheme.pullback.open_cover_of_base 𝒰 f f).bind fun i =>\n        Scheme.Pullback.openCoverOfLeftRight.{u, u} (𝒰' i) (𝒰' i) pullback.snd pullback.snd\n  · intro i\n    dsimp at *\n    infer_instance\n  · rintro ⟨i, j, k⟩\n    dsimp\n    convert(affine_cancel_left_is_iso hP.1\n            (pullback_diagonal_map_iso _ _ ((𝒰' i).map j) ((𝒰' i).map k)).inv pullback.snd).mp\n        _\n    pick_goal 3\n    · convert h𝒰' i j k\n      apply pullback.hom_ext <;> simp\n    all_goals\n      apply pullback.hom_ext <;>\n        simp only [category.assoc, pullback.lift_fst, pullback.lift_snd, pullback.lift_fst_assoc,\n          pullback.lift_snd_assoc]\n#align algebraic_geometry.diagonal_target_affine_locally_of_open_cover AlgebraicGeometry.diagonalTargetAffineLocallyOfOpenCover\n\ntheorem AffineTargetMorphismProperty.diagonalOfTargetAffineLocally\n    (P : AffineTargetMorphismProperty) (hP : P.IsLocal) {X Y U : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y)\n    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :\n    P.diagonal (pullback.snd : pullback f g ⟶ _) :=\n  by\n  rintro U V f₁ f₂ _ _ _ _\n  skip\n  replace H := ((hP.affine_open_cover_tfae (pullback.diagonal f)).out 0 3).mp H\n  let g₁ :=\n    pullback.map (f₁ ≫ pullback.snd) (f₂ ≫ pullback.snd) f f (f₁ ≫ pullback.fst) (f₂ ≫ pullback.fst)\n      g (by rw [category.assoc, category.assoc, pullback.condition])\n      (by rw [category.assoc, category.assoc, pullback.condition])\n  let g₂ : pullback f₁ f₂ ⟶ pullback f g := pullback.fst ≫ f₁\n  specialize H g₁\n  rw [← affine_cancel_left_is_iso hP.1 (pullback_diagonal_map_iso f _ f₁ f₂).Hom]\n  convert H\n  ·\n    apply pullback.hom_ext <;>\n      simp only [category.assoc, pullback.lift_fst, pullback.lift_snd, pullback.lift_fst_assoc,\n        pullback.lift_snd_assoc, category.comp_id, pullback_diagonal_map_iso_hom_fst,\n        pullback_diagonal_map_iso_hom_snd]\n#align algebraic_geometry.affine_target_morphism_property.diagonal_of_target_affine_locally AlgebraicGeometry.AffineTargetMorphismProperty.diagonalOfTargetAffineLocally\n\ntheorem AffineTargetMorphismProperty.IsLocal.diagonal_affine_openCover_tFAE\n    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :\n    TFAE\n      [(targetAffineLocally P).diagonal f,\n        ∃ (𝒰 : Scheme.OpenCover.{u} Y)(_ : ∀ i, IsAffine (𝒰.obj i)),\n          ∀ i : 𝒰.J, P.diagonal (pullback.snd : pullback f (𝒰.map i) ⟶ _),\n        ∀ (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)] (i : 𝒰.J),\n          P.diagonal (pullback.snd : pullback f (𝒰.map i) ⟶ _),\n        ∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],\n          P.diagonal (pullback.snd : pullback f g ⟶ _),\n        ∃ (𝒰 : Scheme.OpenCover.{u} Y)(_ : ∀ i, IsAffine (𝒰.obj i))(𝒰' :\n          ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i)))(_ : ∀ i j, IsAffine ((𝒰' i).obj j)),\n          ∀ i j k, P (pullback.map_desc ((𝒰' i).map j) ((𝒰' i).map k) pullback.snd)] :=\n  by\n  tfae_have 1 → 4\n  · introv H hU hg _ _\n    skip\n    apply P.diagonal_of_target_affine_locally <;> assumption\n  tfae_have 4 → 3\n  · introv H h𝒰\n    skip\n    apply H\n  tfae_have 3 → 2\n  · exact fun H => ⟨Y.affine_cover, inferInstance, H Y.affine_cover⟩\n  tfae_have 2 → 5\n  · rintro ⟨𝒰, h𝒰, H⟩\n    skip\n    refine' ⟨𝒰, inferInstance, fun _ => Scheme.affine_cover _, inferInstance, _⟩\n    intro i j k\n    apply H\n  tfae_have 5 → 1\n  · rintro ⟨𝒰, _, 𝒰', _, H⟩\n    exact diagonal_target_affine_locally_of_open_cover P hP f 𝒰 𝒰' H\n  tfae_finish\n#align algebraic_geometry.affine_target_morphism_property.is_local.diagonal_affine_open_cover_tfae AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.diagonal_affine_openCover_tFAE\n\ntheorem AffineTargetMorphismProperty.IsLocal.diagonal {P : AffineTargetMorphismProperty}\n    (hP : P.IsLocal) : P.diagonal.IsLocal :=\n  AffineTargetMorphismProperty.isLocalOfOpenCoverImply P.diagonal (P.diagonal_respectsIso hP.1)\n    fun _ _ f => ((hP.diagonal_affine_openCover_tFAE f).out 1 3).mp\n#align algebraic_geometry.affine_target_morphism_property.is_local.diagonal AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.diagonal\n\ntheorem diagonal_targetAffineLocally_eq_targetAffineLocally (P : AffineTargetMorphismProperty)\n    (hP : P.IsLocal) : (targetAffineLocally P).diagonal = targetAffineLocally P.diagonal :=\n  by\n  ext (_ _ f)\n  exact\n    ((hP.diagonal_affine_open_cover_tfae f).out 0 1).trans\n      ((hP.diagonal.affine_open_cover_tfae f).out 1 0)\n#align algebraic_geometry.diagonal_target_affine_locally_eq_target_affine_locally AlgebraicGeometry.diagonal_targetAffineLocally_eq_targetAffineLocally\n\ntheorem universallyIsLocalAtTarget (P : MorphismProperty Scheme)\n    (hP :\n      ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y),\n        (∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) → P f) :\n    PropertyIsLocalAtTarget P.universally :=\n  by\n  refine'\n    ⟨P.universally_respects_iso, fun X Y f U =>\n      P.universally_stable_under_base_change (is_pullback_morphism_restrict f U).flip, _⟩\n  intro X Y f 𝒰 h X' Y' i₁ i₂ f' H\n  apply hP _ (𝒰.pullback_cover i₂)\n  intro i\n  dsimp\n  apply h i (pullback.lift (pullback.fst ≫ i₁) (pullback.snd ≫ pullback.snd) _) pullback.snd\n  swap\n  · rw [category.assoc, category.assoc, ← pullback.condition, ← pullback.condition_assoc, H.w]\n  refine' (is_pullback.of_right _ (pullback.lift_snd _ _ _) (is_pullback.of_has_pullback _ _)).flip\n  rw [pullback.lift_fst, ← pullback.condition]\n  exact (is_pullback.of_has_pullback _ _).paste_horiz H.flip\n#align algebraic_geometry.universally_is_local_at_target AlgebraicGeometry.universallyIsLocalAtTarget\n\ntheorem universallyIsLocalAtTargetOfMorphismRestrict (P : MorphismProperty Scheme)\n    (hP₁ : P.RespectsIso)\n    (hP₂ :\n      ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → Opens Y.carrier) (hU : supᵢ U = ⊤),\n        (∀ i, P (f ∣_ U i)) → P f) :\n    PropertyIsLocalAtTarget P.universally :=\n  universallyIsLocalAtTarget P\n    (by\n      intro X Y f 𝒰 h𝒰\n      apply hP₂ f (fun i : 𝒰.J => (𝒰.map i).opensRange) 𝒰.supr_opens_range\n      simp_rw [hP₁.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n      exact h𝒰)\n#align algebraic_geometry.universally_is_local_at_target_of_morphism_restrict AlgebraicGeometry.universallyIsLocalAtTargetOfMorphismRestrict\n\n/-- `topologically P` holds for a morphism if the underlying topological map satisfies `P`. -/\ndef MorphismProperty.topologically\n    (P : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α → β), Prop) :\n    MorphismProperty Scheme.{u} := fun X Y f => P f.1.base\n#align algebraic_geometry.morphism_property.topologically AlgebraicGeometry.MorphismProperty.topologically\n\nend AlgebraicGeometry\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/AlgebraicGeometry/Morphisms/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.4898416682378744}}
{"text": "/-\nCopyright (c) 2021 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport ring_theory.noetherian\nimport ring_theory.jacobson_ideal\n/-!\n# Nakayama's lemma\n\nThis file contains some alternative statements of Nakayama's Lemma as found in\n[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).\n\n## Main statements\n\n* `submodule.eq_smul_of_le_smul_of_le_jacobson` - A version of (2) in\n  [Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).,\n  generalising to the Jacobson of any ideal.\n* `submodule.eq_bot_of_le_smul_of_le_jacobson_bot` - Statement (2) in\n  [Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).\n\n* `submodule.smul_sup_eq_smul_sup_of_le_smul_of_le_jacobson` - A version of (4) in\n  [Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).,\n  generalising to the Jacobson of any ideal.\n* `submodule.smul_sup_eq_of_le_smul_of_le_jacobson_bot` - Statement (4) in\n  [Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).\n\nNote that a version of Statement (1) in\n[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV) can be found in\n`ring_theory/noetherian` under the name\n`submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul`\n\n## References\n* [Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV)\n\n## Tags\nNakayama, Jacobson\n-/\nvariables {R M : Type*} [comm_ring R] [add_comm_group M] [module R M]\n\nopen ideal\n\nnamespace submodule\n\n/-- *Nakayama's Lemma** - A slightly more general version of (2) in\n[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).\nSee also `eq_bot_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`.  -/\nlemma eq_smul_of_le_smul_of_le_jacobson {I J : ideal R} {N : submodule R M}\n  (hN : N.fg) (hIN : N ≤ I • N) (hIjac : I ≤ jacobson J) : N = J • N :=\nbegin\n  refine le_antisymm _ (submodule.smul_le.2 (λ _ _ _, submodule.smul_mem _ _)),\n  intros n hn,\n  cases submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul I N hN hIN with r hr,\n  cases exists_mul_sub_mem_of_sub_one_mem_jacobson r (hIjac hr.1) with s hs,\n  have : n = (-(s * r - 1) • n),\n  { rw [neg_sub, sub_smul, mul_smul, hr.2 n hn, one_smul, smul_zero, sub_zero] },\n  rw this,\n  exact submodule.smul_mem_smul (submodule.neg_mem _ hs) hn\nend\n\n/-- *Nakayama's Lemma** - Statement (2) in\n[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).\nSee also `eq_smul_of_le_smul_of_le_jacobson` for a generalisation\nto the `jacobson` of any ideal -/\nlemma eq_bot_of_le_smul_of_le_jacobson_bot (I : ideal R) (N : submodule R M)\n  (hN : N.fg) (hIN : N ≤ I • N) (hIjac : I ≤ jacobson ⊥) : N = ⊥ :=\nby rw [eq_smul_of_le_smul_of_le_jacobson hN hIN hIjac, submodule.bot_smul]\n\n/-- *Nakayama's Lemma** - A slightly more general version of (4) in\n[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).\nSee also `smul_sup_eq_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`.  -/\nlemma smul_sup_eq_smul_sup_of_le_smul_of_le_jacobson {I J : ideal R}\n  {N N' : submodule R M} (hN' : N'.fg) (hIJ : I ≤ jacobson J)\n  (hNN : N ⊔ N' ≤ N ⊔ I • N') : N ⊔ I • N' = N ⊔ J • N' :=\nbegin\n  have hNN' : N ⊔ N' = N ⊔ I • N',\n    from le_antisymm hNN\n      (sup_le_sup_left (submodule.smul_le.2 (λ _ _ _, submodule.smul_mem _ _)) _),\n  have h_comap := submodule.comap_injective_of_surjective (linear_map.range_eq_top.1 (N.range_mkq)),\n  have : (I • N').map N.mkq = N'.map N.mkq,\n  { rw ←h_comap.eq_iff,\n    simpa [comap_map_eq, sup_comm, eq_comm] using hNN' },\n  have := @submodule.eq_smul_of_le_smul_of_le_jacobson _ _ _ _ _ I J\n    (N'.map N.mkq) (hN'.map _)\n    (by rw [← map_smul'', this]; exact le_rfl)\n    hIJ,\n  rw [← map_smul'', ←h_comap.eq_iff, comap_map_eq, comap_map_eq, submodule.ker_mkq, sup_comm,\n        hNN'] at this,\n  rw [this, sup_comm]\nend\n\n/-- *Nakayama's Lemma** - Statement (4) in\n[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).\nSee also `smul_sup_eq_smul_sup_of_le_smul_of_le_jacobson` for a generalisation\nto the `jacobson` of any ideal -/\n\n\nend submodule\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/nakayama.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4898270431189679}}
{"text": "/-\nCopyright (c) 2021 Bhavik Mehta, Thomas Bloom. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Thomas Bloom\n-/\n\nimport for_mathlib.basic_estimates\nimport defs\nimport aux_lemmas\nimport fourier\n\n/-!\n# Title\n\nThis file should contain a formal proof of https://arxiv.org/pdf/2112.03726.pdf, but for now it\ncontains associated results useful for that paper.\n-/\n\nopen_locale big_operators -- this lets me use ∑ and ∏ notation\nopen filter finset real\nopen nat (coprime)\n\nopen_locale arithmetic_function\nopen_locale classical\nnoncomputable theory\n\nlemma good_d (N : ℕ) (M δ : ℝ) (A : finset ℕ) (hA₁ : A ⊆ finset.range (N + 1)) (hM : 0 < M)\n  (hAM : ∀ n ∈ A, M ≤ (n : ℝ)) (hAq : ∀ q ∈ ppowers_in_set A, (2 : ℝ) * δ ≤ rec_sum_local A q)\n  (I : finset ℤ) (q : ℕ) (hq : q ∈ interval_rare_ppowers I A (M * δ)) :\n  δ ≤ rec_sum_local (A.filter (λ n, ∃ x ∈ I, ↑n ∣ x)) q :=\nbegin\n  rw [interval_rare_ppowers, finset.mem_filter] at hq,\n  set nA : finset ℕ := A.filter (λ n, ∀ x ∈ I, ¬ (↑n ∣ x)),\n  have hnA : nA = A.filter (λ n, ¬ ∃ x ∈ I, ↑n ∣ x),\n  { apply finset.filter_congr,\n    simp },\n  have h1 : (rec_sum_local nA q : ℝ) ≤ δ,\n  { rw [rec_sum_local, local_part, finset.filter_comm, ←local_part, rat.cast_sum],\n    refine (finset.sum_le_card_nsmul _ _ ((q : ℝ) / M) _).trans _,\n    { intros i hi,\n      simp only [finset.mem_filter, mem_local_part, and_assoc] at hi,\n      simp only [rat.cast_div, rat.cast_coe_nat],\n      exact div_le_div_of_le_left (nat.cast_nonneg _) hM (hAM _ hi.1) },\n    rw nsmul_eq_mul,\n    refine (mul_le_mul_of_nonneg_right hq.2.le (div_nonneg (nat.cast_nonneg _) hM.le)).trans _,\n    rw [mul_comm M, mul_div_assoc, mul_assoc, div_mul_div_comm, mul_comm M, div_self, mul_one],\n    simp only [mul_eq_zero, nat.cast_eq_zero, hM.ne', ne.def, or_false],\n    rw [mem_ppowers_in_set, and_assoc] at hq,\n    exact hq.1.ne_zero },\n  have h2 : rec_sum_local A q =\n    rec_sum_local (A.filter (λ n, ∃ x ∈ I, ↑n ∣ x)) q + rec_sum_local nA q,\n  { rw [hnA, ←rec_sum_local_disjoint (finset.disjoint_filter_filter_neg _ _),\n      finset.filter_union_filter_neg_eq] },\n  have h4 : 2 * δ ≤ (rec_sum_local (A.filter (λ n, ∃ x ∈ I, ↑n ∣ x)) q) + (rec_sum_local nA q),\n  { rw_mod_cast ← h2, exact hAq _ hq.1, },\n  linarith,\nend\n\nlemma explicit_mertens2 :\n  ∀ᶠ N : ℕ in at_top,\n    ((∑ q in (finset.range (N + 1)).filter is_prime_pow, 1 / q) : ℝ) ≤ (501/500) * log (log N) :=\nbegin\n  obtain ⟨b, hb⟩ := prime_power_reciprocal,\n  obtain ⟨c, hc₀, hc⟩ := hb.exists_pos,\n  filter_upwards [(tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually\n    (eventually_ge_at_top (c : ℝ)), (tendsto_log_at_top.comp (tendsto_log_at_top.comp\n    tendsto_coe_nat_at_top_at_top)).eventually (eventually_ge_at_top (500*(b + 1))),\n    tendsto_coe_nat_at_top_at_top.eventually hc.bound]\n    with N hN₁ hN₂ hN₃,\n  dsimp at hN₁ hN₂,\n  have hN₄ : 0 < log N := hc₀.trans_le hN₁,\n  simp_rw [norm_inv, ←div_eq_mul_inv, ←one_div, norm_eq_abs, abs_of_nonneg hN₄.le,\n    nat.floor_coe] at hN₃,\n  have : c / log N ≤ 1 := div_le_one_of_le hN₁ hN₄.le,\n  have := sub_le_iff_le_add.1 (sub_le_of_abs_sub_le_right (hN₃.trans this)),\n  convert this.trans (show log (log N) + b + 1 ≤ (501/500)  * log (log N), by linarith) using 2,\n  rw [range_eq_Ico, nat.Ico_succ_right],\n  ext n,\n  simpa only [mem_filter, and.congr_left_iff, mem_Icc, zero_le', iff_and_self, true_and] using\n    λ h _, (is_prime_pow.one_lt h).le,\nend\n\nlemma rec_sum_split (A B C E : finset ℕ) (h : 0 ∉ B) (hC : C = A.filter(λ n : ℕ, n ∈ B ∧\n   (∀ q ∈ ppowers_in_set A, n ∈ local_part B q → q ∈ E))):\nrec_sum ((A\\C)∩B) ≤ ∑ q in (ppowers_in_set A)\\E, (rec_sum_local B q)/q\n:=\nbegin\n simp_rw [rec_sum, rec_sum_local, sum_div],\n calc _ ≤ ∑ (x : ℕ) in ppowers_in_set A \\ E, ∑ (x_1 : ℕ) in local_part B x, (1:ℚ) / x_1 :_\n    ... ≤ _ :_,\n refine le_trans _ (sum_bUnion_le_sum_of_nonneg _), refine sum_le_sum_of_subset_of_nonneg _ _,\n intros n hn, rw hC at hn, rw [mem_inter,mem_sdiff, mem_filter, not_and, not_and] at hn,\n have hn' := hn.1.2 hn.1.1 hn.2, rw [not_forall] at hn', rcases hn' with ⟨q,hq⟩,\n rw [not_imp, not_imp] at hq, rw [mem_bUnion], refine ⟨q,_,hq.2.1⟩,\n rw mem_sdiff, refine ⟨hq.1,hq.2.2⟩,\n intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n intros i hi, rw one_div_nonneg, exact nat.cast_nonneg i,\n rw sum_congr, refl, intros x hx, rw sum_congr, refl, intros x1 hx1,\n rw [local_part, mem_filter] at hx1,\n rw [div_div, div_eq_div_iff, one_mul, mul_comm], norm_cast, intro hz, rw hz at hx1,\n exact h hx1.1, intro hz, rw [mul_eq_zero] at hz, apply h, norm_cast at hz,\n cases hz with hz1 hz2, rw hz1 at hx1, exact hx1.1, rw [hz2,zero_dvd_iff] at hx1,\n have := hx1.2.1, rw this at hx1, exact hx1.1,\nend\n\n-- Proposition 6.3\ntheorem force_good_properties :\n  ∀ᶠ (N : ℕ) in at_top, ∀ M : ℝ, ∀ A ⊆ finset.range(N+1),\n  (0 < M) → (M ≤ N) → ((N : ℝ) ≤ M^2) → (0 ∉ A) →\n  (∀ n ∈ A, M ≤ (n:ℝ)) → arith_regular N A →\n  ( (log N)^(-(1/101 : ℝ)) ≤ rec_sum A ) →\n  (∀ q ∈ ppowers_in_set A,\n    ((log N)^(-(1/100 : ℝ)) ≤ rec_sum_local A q )) → (\n  (∃ B ⊆ A, ((rec_sum A) ≤ 3*rec_sum B) ∧\n  ((ppower_rec_sum B : ℝ) ≤ (2/3)* log(log N)))\n  ∨ good_condition A (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) ((M : ℝ)/log N)\n  (M / (2*(log N)^(1/100 : ℝ))) ) :=\nbegin\n  let c := (35 : ℝ)/100,\n  have hthirdpos : (0 : ℝ) < 1/3, { norm_num1, },\n  filter_upwards [\n    eventually_gt_at_top 1,\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually\n        (eventually_gt_at_top (0 : ℝ)),\n    (tendsto_log_at_top.comp (tendsto_log_at_top.comp\n    tendsto_coe_nat_at_top_at_top)).eventually (eventually_ge_at_top ((2:ℝ)/(1/2))),\n    yet_another_large_N, yet_another_large_N',\n    rec_pp_sum_close, find_good_x, explicit_mertens2, div_bound_useful_version hthirdpos],\n  intros N hlarge hlarge0 hlarge4 hlargeNs hlarge5 hrecN hgoodx hmertens hdiv M A hA h0M hMN hNM h0A hMA hreg hrecA  hreclocal,\n  dsimp at hlarge0,\n  have hlarge3 : 0 < log(log N), { refine lt_of_lt_of_le _ hlarge4, norm_num1, },\n  have hlarge1 : 1 ≤ M*(N)^(-(2 : ℝ)/log(log N)), {\n    rw [neg_eq_neg_one_mul, ← mul_div, ← neg_eq_neg_one_mul, rpow_neg, ← one_div,\n         ← div_eq_mul_one_div, one_le_div],\n    calc _ ≤ (N:ℝ)^((1:ℝ)/2) : _\n       ... ≤ M :_,\n    apply rpow_le_rpow_of_exponent_le, exact_mod_cast le_of_lt hlarge,\n    rw [div_le_iff, ← div_le_iff'], exact hlarge4, exact one_half_pos,\n    exact hlarge3, rw [← sqrt_eq_rpow, sqrt_le_iff],\n    refine ⟨le_of_lt h0M, hNM⟩, apply rpow_pos_of_pos,\n    exact_mod_cast (lt_trans zero_lt_one hlarge),\n    exact nat.cast_nonneg N,\n  },\n  have hlarge2 : M * N ^ ((-2) / log (log N)) ≤ N, {\n    calc _ ≤ M : _\n       ... ≤ N : hMN,\n    nth_rewrite 1 ← mul_one M, rw mul_le_mul_left, apply rpow_le_one_of_one_le_of_nonpos,\n    exact_mod_cast (le_of_lt hlarge), apply div_nonpos_of_nonpos_of_nonneg,\n    rw neg_nonpos, exact zero_le_two, exact le_of_lt hlarge3, exact h0M,\n   },\n  rw or_iff_not_imp_left, intro hnoB, rw good_condition,\n  intros t I hI, refine or_iff_not_imp_left.2 (λ hP, _),\n  by_cases hzI : (0:ℤ) ∈ I,\n  use (0:ℤ), refine ⟨hzI,_⟩, intros q hq, refine dvd_zero _,\n  have hIcard0 : (I.card : ℤ) = ⌊t + (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2⌋ + 1 - ⌈t - (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2⌉, {\n    rw [hI, int.card_Icc_of_le], refine le_trans (int.ceil_le_floor_add_one _) _,\n    rw add_le_add_iff_right,  rw int.le_floor, refine le_trans (int.floor_le _) _,\n    rw [sub_le_iff_le_add, add_assoc, add_halves, le_add_iff_nonneg_right],\n    refine mul_nonneg (le_of_lt h0M) _, apply rpow_nonneg_of_nonneg, exact nat.cast_nonneg N,\n  },\n  have hIcardn0 : I.card ≠ 0, {\n    rw [← pos_iff_ne_zero, card_pos, hI, nonempty_Icc, int.ceil_le],\n    refine le_trans _ (le_of_lt (int.sub_one_lt_floor _)),\n    rw [← add_sub, sub_le_iff_le_add, add_assoc, le_add_iff_nonneg_right, sub_add_eq_add_sub,\n      add_halves, sub_nonneg], exact hlarge1,\n   },\n  have hIcard : ((I.card:ℤ):ℝ) ≤ M*(N : ℝ)^(-(2 : ℝ)/log(log N))+1, {\n    rw hIcard0, push_cast,\n    calc _ ≤  t + (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2 + 1 - ⌈t - (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2⌉ : _\n       ... ≤  t + (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2 + 1 - (t - (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2) :_\n       ... = _ :_,\n    rw [sub_le_sub_iff_right, add_le_add_iff_right], refine int.floor_le _,\n    rw [sub_le_sub_iff_left], refine int.le_ceil _, ring_nf,\n  },\n  have hIcard' : (I.card:ℝ) ≤ M*(N : ℝ)^(-(2 : ℝ)/log(log N))+1, { exact_mod_cast hIcard, },\n  have hIcard'' : (I.card:ℝ) ≤ 2*M*(N : ℝ)^(-(2 : ℝ)/log(log N)), {\n    refine le_trans hIcard' _, rw [mul_assoc, two_mul, add_le_add_iff_left], exact hlarge1,\n   },\n  have hlarge9 : (N:ℝ)^(2 * log 2 / log (log N) * (1 + 1/3)) <  M*((log N)^(-(1/101 : ℝ))/6)/(I.card : ℝ), {\n    rw [lt_div_iff, mul_comm, ← lt_div_iff], refine lt_of_le_of_lt hIcard'' _,\n    rw [lt_div_iff, mul_comm (2:ℝ), mul_assoc, mul_assoc, mul_lt_mul_left, ← rpow_add],\n    exact hlargeNs, norm_cast, refine lt_trans zero_lt_one hlarge, exact h0M,\n    apply rpow_pos_of_pos, norm_cast, refine lt_trans zero_lt_one hlarge,\n    apply rpow_pos_of_pos, norm_cast, refine lt_trans zero_lt_one hlarge, norm_cast,\n    rw pos_iff_ne_zero, exact hIcardn0,\n  },\n  have hIclose' :  ∀ x y ∈ I, (|x-y|:ℝ) ≤ N, {\n    intros x hx y hy, refine le_trans (two_in_Icc' I hI hx hy) _,\n    calc _ ≤  t + (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2 - ⌈t - (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2⌉ : _\n       ... ≤  t + (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2 - (t - (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) / 2) :_\n       ... = (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) :_\n       ... ≤ _ : hlarge2,\n    rw [sub_le_sub_iff_right], refine int.floor_le _,\n    rw [sub_le_sub_iff_left], refine int.le_ceil _, ring_nf,\n   },\n\n  have hIclose : ∀ x y ∈ I, (int.nat_abs (x-y)) ≤ N, {\n    intros x hx y hy, specialize hIclose' x hx y hy, rw nat_cast_diff_issue at hIclose',\n    exact_mod_cast hIclose',\n   },\n  clear hIcard0 hIcard,\n  let A_I := A.filter((λ (n : ℕ), ∃ (x ∈ I), (n:ℤ) ∣ x)),\n  let D := interval_rare_ppowers I A (M / (2 * log N ^ ((1 : ℝ) / 100))),\n  let E := (ppowers_in_set A).filter(λ q : ℕ,\n    1 / (2 * log N ^ ((1:ℝ) / 100)) ≤ rec_sum_local A_I q),\n  let K := (M / (2 * log N ^ ((1 : ℝ) / 100))),\n  by_cases hDne : D.nonempty,\n  rcases hDne with ⟨x1,hx1⟩,\n  have hDE : D ⊆ E, {\n    intros q hq, rw mem_filter, refine ⟨interval_rare_ppowers_subset I K hq,_⟩,\n    refine good_d N M (1 / (2 * log N ^ ((1:ℝ) / 100))) A hA h0M hMA _ I q _,\n    intros q hq, rw [two_mul, one_div, ← inv_div_left, add_halves, ← rpow_neg],\n    exact hreclocal q hq, exact le_of_lt hlarge0, rw ← div_eq_mul_one_div, exact hq,\n  },\n  have hlocal : ∀ q ∈ E, ∃ x ∈ I, ((q:ℤ) ∣x) ∧\n   c*log(log N) ≤ ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣x)), 1/r, {\n    intros q hq, specialize hgoodx M A hA h0M hMN h0A hMA hreg t I q\n       (mem_of_mem_filter q hq) hI,\n    apply hgoodx, rw mem_filter at hq, exact hq.2,\n  },\n  clear hgoodx, choose! f hf using hlocal, use f x1,\n  have hfcopy := hf, have hfcopy2 := hf, have hfcopy3 := hf,\n  specialize hf x1 (hDE hx1), refine ⟨hf.1,_⟩, intros x2 hx2, specialize hfcopy2 x2 (hDE hx2),\n  have hclose : ∀ x y ∈ E, |(f x : ℝ)-(f y)| ≤ N, {\n    intros q hq r hr, have hfcopy' := hfcopy,\n    specialize hfcopy q hq, specialize hfcopy' r hr,\n    apply @le_trans _ _ _ ((⌊t + M * N ^ ((-2) / log (log N)) / 2⌋ : ℝ)-⌈t - M * N ^ ((-2) / log (log N)) / 2⌉) N,\n    apply two_in_Icc, rw ← hI, exact hfcopy.1, rw ← hI, exact hfcopy'.1,\n    rw sub_le,\n    apply @le_trans _ _ _ (t - M * N ^ ((-2) / log (log N)) / 2) _,\n    apply sub_left_le_of_le_add, apply @le_trans _ _ _ (t + M * N ^ ((-2) / log (log N)) / 2) _,\n    apply int.floor_le, rw add_sub, rw add_comm (N : ℝ) t, rw ← add_sub, apply add_le_add_left,\n    apply le_sub_left_of_add_le, rw add_halves', exact hlarge2, apply int.le_ceil,\n   },\n  have hsum4 : (ppower_rec_sum A:ℝ) ≤ (501/500)*log(log N), {\n    refine le_trans _ hmertens, rw ppower_rec_sum, push_cast,\n    refine sum_le_sum_of_subset_of_nonneg _ _,  intros r hr,\n    rw [ppowers_in_set,mem_bUnion] at hr,\n    rw [mem_filter, mem_range], rcases hr with ⟨a,ha,hr⟩, rw mem_filter at hr,\n    refine ⟨_,hr.2.1⟩,\n    calc _ ≤ a : _\n       ... < N+1 :_,\n    exact nat.divisor_le hr.1, rw ← mem_range, exact hA ha,\n    intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n  },\n  by_cases htwoxs : f x2 = f x1,\n  obtain hf' := hfcopy2.2.1, rw htwoxs at hf', exact hf',\n  by_cases hthreexs : ∀ x ∈ E, f x = f x1 ∨ f x = f x2,\n  clear hfcopy3, exfalso,\n  let A1 := A.filter( λ n : ℕ, (n:ℤ) ∣ (f x1) ),\n  let A2 := A.filter( λ n : ℕ, (n:ℤ) ∣ (f x2) ),\n  let A0 := A\\(A1∪A2),\n  have h3rec : rec_sum A ≤ rec_sum A1 + rec_sum A2 + rec_sum A0, {\n    refine le_trans _ rec_sum_le_three, refine rec_sum_mono _,\n    intros n hn, rw mem_union, by_cases htemp : n ∈ A1 ∪ A2, left, exact htemp,\n    right, rw mem_sdiff, refine ⟨hn,htemp⟩,\n  },\n  by_cases hAlarge : (rec_sum A ≤ 3*rec_sum A1) ∨ (rec_sum A ≤ 3*rec_sum A2),\n  apply hnoB,\n  have hnum : (502:ℝ) / 500 - 35 / 100 ≤ 2 / 3, by norm_num1,\n  have hrecAs : ∑ q in (ppowers_in_set A).filter(λ n : ℕ, (n:ℤ) ∣ (f x1)), (1:ℝ)/q\n    + ∑ q in (ppowers_in_set A).filter(λ n : ℕ, (n:ℤ) ∣ (f x2)), (1:ℝ)/q ≤\n    (502/500)*log(log N), {\n      calc _ ≤ (ppower_rec_sum A:ℝ) + ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x2 ∧ (n:ℤ)∣f x1)), (1:ℝ)/r :_\n         ... ≤ (ppower_rec_sum A:ℝ) + (1/500)*log(log N) :_\n         ... ≤ (501/500)*log(log N) + (1/500)*log(log N) :_\n         ... = _ :_,\n      rw [sum_add_sum, filter_inter, inter_filter, inter_self, filter_filter,\n         add_le_add_iff_right, ppower_rec_sum], push_cast,\n      refine sum_le_sum_of_subset_of_nonneg _ _,\n      rw [filter_union_right], refine filter_subset _ _, intros i hi1 hi2,\n      rw one_div_nonneg, exact nat.cast_nonneg i, rw add_le_add_iff_left,\n      refine le_trans _ (le_of_lt( hrecN (f x2) (f x1) htwoxs (hclose x2 (hDE hx2) x1 (hDE hx1)))),\n      refine sum_le_sum_of_subset_of_nonneg _ _, intros r hr, rw finset.mem_filter, rw finset.mem_filter at hr,\n      rw [ppowers_in_set,finset.mem_bUnion] at hr, rcases hr.1 with ⟨m,hm1,hm2⟩,\n      rw finset.mem_filter at hm2, refine ⟨_,hm2.2.1,hr.2⟩, rw finset.mem_range,\n      apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw ← finset.mem_range,\n      exact hA hm1, intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n      rw add_le_add_iff_right, exact hsum4, rw ← add_mul, norm_num1, refl,\n     },\n  cases hAlarge with hA1large hA2large,\n  refine ⟨A1,filter_subset _ _,hA1large,_⟩,\n  rw ppower_rec_sum, push_cast,\n  calc _ ≤ ∑ q in (ppowers_in_set A).filter(λ n : ℕ, (n:ℤ) ∣ (f x1)), (1:ℝ)/q :_\n     ... ≤ (502/500)*log(log N) - ∑ q in (ppowers_in_set A).filter(λ n : ℕ, (n:ℤ) ∣f x2 ), (1:ℝ)/q :_\n     ... ≤ (502/500)*log(log N) - (35/100)*log(log N) :_\n     ... ≤ (2/3)*log(log N) :_,\n  refine sum_le_sum_of_subset_of_nonneg _ _, intros q hq,\n  rw [ppowers_in_set, mem_bUnion] at hq, rw [mem_filter, ppowers_in_set, mem_bUnion],\n  rcases hq with ⟨a,ha,hq⟩, use a, refine ⟨mem_of_mem_filter a ha,hq,⟩, rw mem_filter at ha,\n  refine dvd_trans _ ha.2, norm_cast, exact nat.dvd_of_mem_divisors (mem_of_mem_filter q hq),\n  intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n  rw le_sub_iff_add_le, exact hrecAs, rw sub_le_sub_iff_left, exact hfcopy2.2.2,\n  rw [← sub_mul, mul_le_mul_right], exact hnum, exact hlarge3,\n  refine ⟨A2,filter_subset _ _,hA2large,_⟩,\n  rw ppower_rec_sum, push_cast,\n  calc _ ≤ ∑ q in (ppowers_in_set A).filter(λ n : ℕ, (n:ℤ) ∣ (f x2)), (1:ℝ)/q :_\n     ... ≤ (502/500)*log(log N) - ∑ q in (ppowers_in_set A).filter(λ n : ℕ, (n:ℤ) ∣f x1 ), (1:ℝ)/q :_\n     ... ≤ (502/500)*log(log N) - (35/100)*log(log N) :_\n     ... ≤ (2/3)*log(log N) :_,\n  refine sum_le_sum_of_subset_of_nonneg _ _, intros q hq,\n  rw [ppowers_in_set, mem_bUnion] at hq, rw [mem_filter, ppowers_in_set, mem_bUnion],\n  rcases hq with ⟨a,ha,hq⟩, use a, refine ⟨mem_of_mem_filter a ha,hq,⟩, rw mem_filter at ha,\n  refine dvd_trans _ ha.2, norm_cast, exact nat.dvd_of_mem_divisors (mem_of_mem_filter q hq),\n  intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n  rw le_sub_iff_add_le, rw add_comm, exact hrecAs, rw sub_le_sub_iff_left, exact hf.2.2,\n  rw [← sub_mul, mul_le_mul_right], exact hnum, exact hlarge3,\n  let A' := A0.filter(λ n : ℕ, n ∈ A_I ∧\n   (∀ q ∈ ppowers_in_set A0, n ∈ local_part A_I q → q ∈ E)),\n  have hrecaux' : 1/log N + rec_sum ((A0\\A')∩A_I) ≤ (log N)^(-(1/101 : ℝ))/6, {\n    calc _ ≤ 1/log N + ∑ q in (ppowers_in_set A0)\\E, (rec_sum_local (A_I) q)/q :_\n       ... ≤ 1/log N + (1 / (2 * log N ^ ((1:ℝ) / 100)))*∑ q in (ppowers_in_set A0)\\E, 1/q :_\n       ... ≤ 1/log N + (1 / (2 * log N ^ ((1:ℝ) / 100)))*((501/500)*log(log N)) :_\n       ... ≤ _ : hlarge5,\n    rw add_le_add_iff_left, norm_cast,\n    refine rec_sum_split A0 A_I A' E _ _,\n    intro hzA, apply h0A, exact mem_of_mem_filter 0 hzA, refl,\n    rw [add_le_add_iff_left, mul_sum], refine sum_le_sum _, intros q hq,\n    rw [← div_eq_mul_one_div], refine div_le_div_of_le_of_nonneg _ _, rw ← not_lt,\n    intro nlt, rw mem_sdiff at hq, apply hq.2, rw mem_filter,\n    refine ⟨(ppowers_in_set_subset (sdiff_subset _ _)) hq.1,le_of_lt nlt⟩,\n    exact nat.cast_nonneg q, rw [add_le_add_iff_left, mul_le_mul_left],\n    refine le_trans _ hsum4, rw ppower_rec_sum, push_cast,\n    refine sum_le_sum_of_subset_of_nonneg _ _,\n    refine subset_trans (sdiff_subset _ _) (ppowers_in_set_subset (sdiff_subset _ _)),\n    intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i, rw one_div_pos,\n    refine mul_pos zero_lt_two _, apply rpow_pos_of_pos, exact hlarge0,\n  },\n\n    have hrecA0 : (log N)^(-(1/101 : ℝ))/3 ≤ rec_sum A0, {\n    calc _ ≤ (rec_sum A :ℝ)/3 :_\n       ... ≤ _ :_,\n    rw [div_le_div_right], exact hrecA, exact zero_lt_three,\n    rw [div_le_iff', ← add_le_add_iff_left ((3:ℝ)*(rec_sum A2)),\n      ← add_le_add_iff_left ((3:ℝ)*(rec_sum A1))], norm_cast,\n    rw [decidable.not_or_iff_and_not, not_le, not_le] at hAlarge, linarith,\n    exact zero_lt_three,\n  },\n\n  have hrecaux :  (rec_sum (A0\\A') :ℝ) ≤ (log N)^(-(1/101 : ℝ))/6, {\n    calc _ = (rec_sum ((A0\\A')\\A_I) :ℝ) + rec_sum ((A0\\A')∩A_I) :_\n       ... ≤ (rec_sum (A\\A_I) :ℝ) + rec_sum ((A0\\A')∩A_I) :_\n       ... ≤ ((A\\A_I).card:ℝ)/M + rec_sum ((A0\\A')∩A_I) :_\n       ... ≤ 1/log N + rec_sum ((A0\\A')∩A_I) :_\n       ... ≤ _ : hrecaux',\n    norm_cast, rw [← rec_sum_disjoint, sdiff_union_inter], refine disjoint_sdiff_inter _ _,\n    rw add_le_add_iff_right, norm_cast, refine rec_sum_mono _, refine sdiff_subset_sdiff _ _,\n    refine subset_trans (sdiff_subset _ _) _, refine sdiff_subset _ _, refl,\n    rw add_le_add_iff_right, refine rec_sum_le_card_div h0M _,\n    intros n hn, refine hMA n _, refine (sdiff_subset _ _) hn, rw add_le_add_iff_right,\n    rw not_le at hP, rw [div_le_iff', ← div_eq_mul_one_div], refine le_of_lt _,\n    refine lt_of_le_of_lt _ hP, norm_cast, refine card_le_of_subset _,\n    intros n hn, rw mem_sdiff at hn, rw mem_filter, refine ⟨hn.1,_⟩,\n    intros x hx hnx, apply hn.2, rw mem_filter, refine ⟨hn.1,x,hx,hnx⟩, exact h0M,\n  },\n\n  have hrecA' : (log N)^(-(1/101 : ℝ))/6 ≤ rec_sum A', {\n    calc _ ≤ (log N)^(-(1/101 : ℝ))/3 - (log N)^(-(1/101 : ℝ))/6 :_\n       ... ≤ (rec_sum A0:ℝ) - (log N)^(-(1/101 : ℝ))/6 :_\n       ... ≤ (rec_sum A0:ℝ) - rec_sum (A0\\A') :_\n       ... = _ :_,\n    rw [le_sub_iff_add_le, div_add_div_same, ← mul_two, ← div_div_eq_mul_div],\n    norm_num1, refl, rw [sub_le_sub_iff_right], exact hrecA0,\n    rw sub_le_sub_iff_left, exact hrecaux, rw [sub_eq_iff_eq_add], norm_cast,\n    rw [← rec_sum_disjoint, union_sdiff_of_subset], refine filter_subset _ _,\n    exact disjoint_sdiff,\n   },\n  have hA'size : M*((log N)^(-(1/101 : ℝ))/6) ≤ (A').card, {\n    rw ← le_div_iff', refine le_trans hrecA' (rec_sum_le_card_div h0M _),\n    intros n hn, refine hMA n _, refine (sdiff_subset _ _) (mem_of_mem_filter n hn),\n    exact h0M,\n   },\n  have hbadx : ∃ x ∈ I,  M*((log N)^(-(1/101 : ℝ))/6)/(I.card : ℝ) ≤\n     (A'.filter(λ n : ℕ, (n:ℤ) ∣ x )).card, {\n       by_contra, rw ← not_lt at hA'size, apply hA'size,\n       have hA'union : A' = I.bUnion( λ x : ℤ, A'.filter( λ n : ℕ, (n:ℤ) ∣ x)), {\n         ext, refine ⟨_,_⟩, intro hn, have hn' := hn, rw mem_bUnion,\n         rw [mem_filter, mem_filter] at hn, rcases hn.2.1.2 with ⟨x,hx1,hx2⟩,\n         refine ⟨x,hx1,_⟩, rw mem_filter, refine ⟨hn',hx2⟩,\n         intro hn, rw mem_bUnion at hn, rcases hn with ⟨x,hx1,hx2⟩, exact mem_of_mem_filter a hx2,\n        },\n       rw hA'union,\n       refine lt_of_lt_of_le (card_bUnion_lt_card_mul_real (M*((log N)^(-(1/101 : ℝ))/6)/(I.card : ℝ)) _ _) _,\n       intros x hx, rw ← not_le, intro hnle, apply h, use x, refine ⟨hx,hnle⟩,\n       rw [← card_pos, pos_iff_ne_zero], exact hIcardn0,\n       rw mul_div_cancel_of_imp', intro hz, exfalso, norm_cast at hz,\n\n  },\n  rcases hbadx with ⟨x, hx1, hx2⟩,\n  let m := nat.gcd (int.nat_abs x) (int.nat_abs ((f x1)*(f x2))),\n\n  have hmsmall : m ≤ N^2, {\n      have hbadx' : ∃ n ∈ A', (n:ℤ) ∣ x, {\n        have hA'temp : (A'.filter(λ n : ℕ, (n:ℤ) ∣ x )).nonempty, {\n          rw [← finset.card_pos, pos_iff_ne_zero], intro hz, rw hz at hx2, rw ← not_lt at hx2,\n          apply hx2, apply div_pos, refine mul_pos h0M _, refine div_pos _ _,\n          apply rpow_pos_of_pos, exact hlarge0, norm_num1, norm_cast, rw pos_iff_ne_zero,\n          exact hIcardn0,\n        },\n      rcases hA'temp with ⟨n,hn⟩, rw mem_filter at hn,\n      refine ⟨n,hn.1,hn.2⟩,\n      },\n    rcases hbadx' with ⟨ns,hns1,hns2⟩, rw mem_filter at hns1,\n    have hns3 := hns1.1, rw [mem_sdiff, not_mem_union, mem_filter, mem_filter] at hns3,\n    refine le_trans (nat_gcd_prod_le_diff _ _) _,\n    intro hnetemp, rw hnetemp at hns2, apply hns3.2.1, refine ⟨hns3.1,hns2⟩,\n    intro hnetemp, rw hnetemp at hns2, apply hns3.2.2, refine ⟨hns3.1,hns2⟩,\n     rw sq, refine nat.mul_le_mul _ _,\n    refine hIclose _ hx1 _ hf.1, refine hIclose _ hx1 _ hfcopy2.1,\n   },\n  have hdivm : (A'.filter(λ n : ℕ, (n:ℤ) ∣ x )).card ≤ (σ 0 m), {\n    rw divisor_function_eq_card_divisors, refine card_le_of_subset _,\n    intros n hn, rw nat.mem_divisors, refine ⟨_,_⟩,\n    rw dvd_iff_ppowers_dvd', intros q hq1 hq2, rw nat.dvd_gcd_iff,\n    rw mem_filter at hn, refine ⟨_,_⟩,\n    refine dvd_trans hq1 _, rw ← int.coe_nat_dvd_left, exact hn.2,\n    specialize hfcopy q, rw ← int.coe_nat_dvd_left, rw mem_filter at hn,\n    have : q ∈ E, {\n      refine hn.1.2.2 q _ _, rw [ppowers_in_set, mem_bUnion],\n      use n, rw mem_filter,  refine ⟨hn.1.1,_,hq2.1,hq2.2⟩, rw nat.mem_divisors,\n      refine ⟨hq1,_⟩, intro hnz, apply h0A, rw hnz at hn, exact mem_of_mem_filter 0 hn.1.2.1,\n      rw [local_part, mem_filter], refine ⟨hn.1.2.1,hq1,hq2.2⟩,\n     },\n    specialize hfcopy this,  refine dvd_trans hfcopy.2.1 _,\n    specialize hthreexs q this, cases hthreexs with ht1 ht2,\n    rw ht1, refine dvd_mul_right _ _, rw ht2, refine dvd_mul_left _ _,\n    intro hnz, apply h0A,\n    have hbah : A'.filter(λ n : ℕ, (n:ℤ) ∣ x ) ⊆ A, {\n      refine subset_trans (filter_subset _ _) _,\n      refine subset_trans (filter_subset _ _) _,\n      refine sdiff_subset _ _,\n     },\n    rw hnz at hn, exact hbah hn,\n    intro hmz, rw nat.gcd_eq_zero_iff at hmz,\n    have hmz' := int.eq_zero_of_nat_abs_eq_zero hmz.1,\n    rw hmz' at hx1, exact hzI hx1,\n   },\n  specialize hdiv m hmsmall, rw ← not_lt at hdiv, apply hdiv,\n  calc _ < M*((log N)^(-(1/101 : ℝ))/6)/(I.card : ℝ) : hlarge9\n    ... ≤ ((A'.filter(λ n : ℕ, (n:ℤ) ∣ x )).card : ℝ) : hx2\n    ... ≤ _ :_,\n  exact_mod_cast hdivm,\n  rw not_forall at hthreexs, rcases hthreexs with ⟨x3,hx3⟩,\n  rw [not_imp, not_or_distrib] at hx3, specialize hfcopy3 x3 hx3.1, exfalso,\n  let S1 := ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x1)), (1:ℝ)/r,\n  let S2 := ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x2)), (1:ℝ)/r,\n  let S3 := ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x3)), (1:ℝ)/r,\n  have hsum1 :  3*c*log(log N) ≤ S1 + S2 + S3, {\n      calc _ = c*log(log N) + c*log(log N) + c*log(log N) :_\n         ... ≤ _ :_,\n      rw [← add_mul, ← add_mul, mul_eq_mul_right_iff], left,\n      rw [← two_mul, ← sub_eq_iff_eq_add', ← sub_mul], norm_num1, rw one_mul,\n      refine add_le_add _ hfcopy3.2.2, exact add_le_add hf.2.2 hfcopy2.2.2,\n  },\n  let S12 := ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x2 ∧ (n:ℤ)∣f x1)), (1:ℝ)/r,\n  let S23 := ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x3 ∧ (n:ℤ)∣f x2)), (1:ℝ)/r,\n  let S13 := ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x3 ∧ (n:ℤ)∣f x1)), (1:ℝ)/r,\n\n  have hsum2 : (S1+S2+S3) - (S12 + S23 + S13) ≤ ppower_rec_sum A, {\n    rw [sum_add_sum_add_sum, filter_inter, inter_filter, inter_self, filter_filter,\n       filter_inter, inter_filter, inter_self, filter_filter,\n       filter_inter, inter_filter, inter_self, filter_filter,\n       add_sub_right_comm, add_sub_right_comm, add_sub_right_comm, add_sub_right_comm,\n       add_sub_right_comm,  ← sub_sub, ← sub_sub, add_tsub_cancel_right, sub_add_cancel,\n       sub_add_cancel, sub_le_iff_le_add],\n    calc _ ≤ (ppower_rec_sum A : ℝ) :_\n       ... ≤ _ :_,\n    rw ppower_rec_sum, push_cast, refine sum_le_sum_of_subset_of_nonneg _ _,\n    intros q hq, rw [mem_union, mem_union] at hq, cases hq with hq1 hq2,\n    cases hq1 with hq11 hq12, exact mem_of_mem_filter q hq11,\n    exact mem_of_mem_filter q hq12, exact mem_of_mem_filter q hq2,\n    intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n    refine le_add_of_nonneg_right _, refine sum_nonneg _, intros i hi,\n    rw one_div_nonneg, exact nat.cast_nonneg i,\n  },\n  have hsum3 : S12 + S23 + S13 ≤ ((1:ℝ)/500+(1:ℝ)/500+(1:ℝ)/500)*log(log N), {\n    rw add_mul, refine add_le_add _ _, rw add_mul, refine add_le_add _ _,\n    refine le_trans _ (le_of_lt (hrecN (f x2) (f x1) htwoxs (hclose x2 (hDE hx2) x1 (hDE hx1)))),\n    refine sum_le_sum_of_subset_of_nonneg _ _,  intros r hr, rw finset.mem_filter, rw finset.mem_filter at hr,\n    rw [ppowers_in_set,finset.mem_bUnion] at hr, rcases hr.1 with ⟨m,hm1,hm2⟩,\n    rw finset.mem_filter at hm2,  refine ⟨_,hm2.2.1,hr.2⟩, rw finset.mem_range,\n    apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw ← finset.mem_range,\n    exact hA hm1, intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n    refine le_trans _ (le_of_lt (hrecN (f x3) (f x2) hx3.2.2 (hclose x3 hx3.1 x2 (hDE hx2)))),\n    refine sum_le_sum_of_subset_of_nonneg _ _,  intros r hr, rw finset.mem_filter, rw finset.mem_filter at hr,\n    rw [ppowers_in_set,finset.mem_bUnion] at hr, rcases hr.1 with ⟨m,hm1,hm2⟩,\n    rw finset.mem_filter at hm2, refine ⟨_,hm2.2.1,hr.2⟩, rw finset.mem_range,\n    apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw ← finset.mem_range,\n    exact hA hm1, intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n    refine le_trans _ (le_of_lt (hrecN (f x3) (f x1) hx3.2.1 (hclose x3 hx3.1 x1 (hDE hx1)))),\n    refine sum_le_sum_of_subset_of_nonneg _ _,  intros r hr, rw finset.mem_filter, rw finset.mem_filter at hr,\n    rw [ppowers_in_set,finset.mem_bUnion] at hr, rcases hr.1 with ⟨m,hm1,hm2⟩,\n    rw finset.mem_filter at hm2, refine ⟨_,hm2.2.1,hr.2⟩, rw finset.mem_range,\n    apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw ← finset.mem_range,\n    exact hA hm1, intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n  },\n  have hsum5 : ¬  (501/500)*log(log N) < ((102:ℝ)/100)*log(log N) , {\n    rw not_lt,\n    calc _ ≤ 3*c*log(log N) - ((1:ℝ)/500+(1:ℝ)/500+(1:ℝ)/500)*log(log N) :_\n       ... ≤ (S1+S2+S3) - (S12 + S23 + S13) :_\n       ... ≤ (ppower_rec_sum A:ℝ) : hsum2\n       ... ≤ _ : hsum4,\n    rw [← sub_mul, mul_le_mul_right],\n    have hsilly : c = 35/100, { refl, },\n    rw hsilly, norm_num1, exact hlarge3, refine sub_le_sub hsum1 hsum3,\n  },\n  apply hsum5, rw mul_lt_mul_right, norm_num1, exact hlarge3,\n  have hIne : I.nonempty, {\n    rw [hI, finset.nonempty_Icc], rw int.ceil_le,\n    apply @le_trans _ _ _ (t + M * N ^ ((-2) / log (log N)) / 2 - 1) _,\n    rw [le_sub,← sub_add, ← sub_add_eq_add_sub], simp only [zero_add, add_halves', sub_self],\n    exact hlarge1, apply le_of_lt, apply int.sub_one_lt_floor,\n   },\n  rcases hIne with ⟨x,hx⟩, refine ⟨x,hx,_⟩,\n  intros q hq, exfalso, apply hDne, use q, exact hq,\nend\n\n-- Proposition 6.4\ntheorem force_good_properties2 :\n  ∀ᶠ (N : ℕ) in at_top, ∀ M : ℝ, ∀ A ⊆ finset.range(N+1),\n  (0 < M) →  (M ≤ N) → ((N : ℝ) ≤ M^2) → (0 ∉ A) →\n  (∀ n ∈ A, M ≤ (n:ℝ)) → arith_regular N A →\n  (∀ q ∈ ppowers_in_set A,\n    ((log N)^(-(1/100 : ℝ)) ≤ rec_sum_local A q )) →\n  ((ppower_rec_sum A : ℝ) ≤ (2/3)* log(log N)) →\n  good_condition A (M*(N : ℝ)^(-(2 : ℝ)/log(log N))) ((M : ℝ)/log N)\n  (M / (2*(log N)^(1/100 : ℝ)))\n :=\nbegin\n  let c := (35 : ℝ)/100,\n  filter_upwards [\n    eventually_gt_at_top 1,\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually\n        (eventually_gt_at_top (0 : ℝ)),\n    (tendsto_log_at_top.comp (tendsto_log_at_top.comp\n    tendsto_coe_nat_at_top_at_top)).eventually (eventually_ge_at_top ((2:ℝ)/(1/2))),\n    rec_pp_sum_close, find_good_x],\n  intros N hlarge hlarge0 hlarge4 hrecN hgoodx M A hA h0M hMN hNM h0A hMA hreg hreclocal hpprecA,\n  have hlarge3 : 0 < log(log N), { refine lt_of_lt_of_le _ hlarge4, norm_num1, },\n  have hlarge1 : 1 ≤ M*(N)^(-(2 : ℝ)/log(log N)), {\n    rw [neg_eq_neg_one_mul, ← mul_div, ← neg_eq_neg_one_mul, rpow_neg, ← one_div,\n         ← div_eq_mul_one_div, one_le_div],\n    calc _ ≤ (N:ℝ)^((1:ℝ)/2) : _\n       ... ≤ M :_,\n    apply rpow_le_rpow_of_exponent_le, exact_mod_cast le_of_lt hlarge,\n    rw [div_le_iff, ← div_le_iff'], exact hlarge4, exact one_half_pos,\n    exact hlarge3, rw [← sqrt_eq_rpow, sqrt_le_iff],\n    refine ⟨le_of_lt h0M, hNM⟩, apply rpow_pos_of_pos,\n    exact_mod_cast (lt_trans zero_lt_one hlarge),\n    exact nat.cast_nonneg N,\n  },\n  have hlarge2 : M * N ^ ((-2) / log (log N)) ≤ N, {\n    calc _ ≤ M : _\n       ... ≤ N : hMN,\n    nth_rewrite 1 ← mul_one M, rw mul_le_mul_left, apply rpow_le_one_of_one_le_of_nonpos,\n    exact_mod_cast (le_of_lt hlarge), apply div_nonpos_of_nonpos_of_nonneg,\n    rw neg_nonpos, exact zero_le_two, exact le_of_lt hlarge3, exact h0M,\n   },\n  rw good_condition,\n  intros t I hI,\n  refine or_iff_not_imp_left.2 (λ hP, _),\n  let A_I := A.filter((λ (n : ℕ), ∃ (x : ℤ), (n:ℤ) ∣ x)),\n  let D := interval_rare_ppowers I A (M / (2 * log N ^ ((1 : ℝ) / 100))),\n  let K := (M / (2 * log N ^ ((1 : ℝ) / 100))),\n  by_cases hDne : D.nonempty,\n  rcases hDne with ⟨x1,hx1⟩,\n  have hlocal : ∀ q ∈ D, ∃ x ∈ I, ((q:ℤ) ∣x) ∧\n   c*log(log N) ≤ ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣x)), 1/r, {\n    intros q hq, specialize hgoodx M A hA h0M hMN h0A hMA hreg t I q\n       (interval_rare_ppowers_subset I K hq) hI,\n    apply hgoodx,\n    refine good_d N M (1 / (2 * log N ^ ((1:ℝ) / 100))) A hA h0M hMA _ I q _,\n    intros q hq, rw [two_mul, one_div, ← inv_div_left, add_halves, ← rpow_neg],\n    exact hreclocal q hq, exact le_of_lt hlarge0, rw ← div_eq_mul_one_div,\n    exact hq,\n  },\n  clear hgoodx,\n  choose! f hf using hlocal, use f x1,  have hfcopy := hf,\n  specialize hf x1 hx1, refine ⟨hf.1,_⟩, intros q hq, specialize hfcopy q hq,\n  by_cases htwoxs : f q = f x1,\n  obtain hf' := hfcopy.2.1, rw htwoxs at hf', exact hf',  exfalso,\n  have hsum1 :  2*c*log(log N) ≤ ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x1)), 1/r\n    +  ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f q)), 1/r, {\n      rw [two_mul, add_mul], apply add_le_add hf.2.2 hfcopy.2.2,\n     },\n  have hsum2 :\n       ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x1)), (1 : ℝ)/r\n    +  ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f q)), (1 : ℝ)/r\n    -  ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f q ∧ (n:ℤ)∣f x1)), (1 : ℝ)/r\n    ≤ ppower_rec_sum A, {\n      rw ppower_rec_sum, push_cast, rw sum_add_sum,\n      rw [filter_inter,inter_filter, inter_self, filter_filter, ← add_sub, sub_self,\n        add_zero], refine sum_le_sum_of_subset_of_nonneg _ _, intros r hr,\n        rw mem_union at hr, cases hr with hr1 hr2, rw mem_filter at hr1,\n        exact hr1.1, rw mem_filter at hr2, exact hr2.1, intros i hi1 hi2,\n        rw one_div_nonneg, exact nat.cast_nonneg i,\n     },\n  have hsum3 :\n    ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x1)), (1 : ℝ)/r\n    + ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f q)), (1 : ℝ)/r  - ppower_rec_sum A ≤\n    ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f q ∧ (n:ℤ)∣f x1)), (1 : ℝ)/r,\n    { apply  sub_left_le_of_le_add, nth_rewrite 1 add_comm,\n      apply le_add_of_sub_left_le hsum2, },\n  have hsum4 :\n    ((1 : ℝ)/500)*log(log N) ≤\n      ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f q ∧ (n:ℤ)∣f x1)), (1 : ℝ)/r,\n    { refine le_trans _ hsum3, clear hsum3,\n      calc _ ≤ 2*c*log(log N) - ((2 : ℝ)/3)*log(log N) :_\n           ... ≤ ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f x1)), (1 : ℝ)/r\n    +  ∑ r in ((ppowers_in_set A).filter(λ n, (n:ℤ)∣f q)), (1 : ℝ)/r  - ((2 : ℝ)/3)*log(log N) :_\n         ... ≤ _ :_,\n      have hsilly : c = 35/100, { refl, },\n      rw [le_sub_iff_add_le, ← add_mul, mul_le_mul_right, hsilly], norm_num1,\n      exact hlarge3, refine sub_le_sub _ _, exact hsum1, rw mul_le_mul_right,\n      exact hlarge3, rw sub_le_sub_iff_left, exact hpprecA,\n     },\n  have hqx1close : |(f q : ℝ)-(f x1)| ≤ N, {\n    apply @le_trans _ _ _ ((⌊t + M * N ^ ((-2) / log (log N)) / 2⌋ : ℝ)-⌈t - M * N ^ ((-2) / log (log N)) / 2⌉) N,\n    apply two_in_Icc, rw ← hI, exact hfcopy.1, rw ← hI, exact hf.1,\n    rw sub_le,\n    apply @le_trans _ _ _ (t - M * N ^ ((-2) / log (log N)) / 2) _,\n    apply sub_left_le_of_le_add, apply @le_trans _ _ _ (t + M * N ^ ((-2) / log (log N)) / 2) _,\n    apply int.floor_le, rw add_sub, rw add_comm (N : ℝ) t, rw ← add_sub, apply add_le_add_left,\n    apply le_sub_left_of_add_le, rw add_halves', exact hlarge2, apply int.le_ceil,\n   },\n  specialize hrecN (f q) (f x1) htwoxs hqx1close, rw lt_iff_not_ge at hrecN,\n  apply hrecN, apply le_trans hsum4, apply finset.sum_le_sum_of_subset_of_nonneg,\n  intros r hr, rw finset.mem_filter, rw finset.mem_filter at hr,\n  rw [ppowers_in_set,finset.mem_bUnion] at hr, rcases hr.1 with ⟨m,hm1,hm2⟩,\n  rw finset.mem_filter at hm2,  refine ⟨_,hm2.2.1,hr.2⟩, rw finset.mem_range,\n  apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw ← finset.mem_range,\n  exact hA hm1, intros i hi1 hi2, apply div_nonneg, exact zero_le_one,\n  apply nat.cast_nonneg,\n  clear hrecN,\n  have hIne : I.nonempty, {\n    rw [hI, finset.nonempty_Icc], rw int.ceil_le,\n    apply @le_trans _ _ _ (t + M * N ^ ((-2) / log (log N)) / 2 - 1) _,\n    rw [le_sub,← sub_add, ← sub_add_eq_add_sub], simp only [zero_add, add_halves', sub_self],\n    exact hlarge1, apply le_of_lt, apply int.sub_one_lt_floor,\n   },\n  rcases hIne with ⟨x,hx⟩, refine ⟨x,hx,_⟩,\n  intros q hq, exfalso, apply hDne, use q, exact hq,\nend\n\n-- The inductive heart of Lemma 5.5\nlemma pruning_lemma_one_prec (A : finset ℕ) (ε : ℝ) (i : ℕ) :\n  ∃ A_i ⊆ A, ∃ Q_i ⊆ ppowers_in_set A,\n  (disjoint Q_i (ppowers_in_set A_i)) ∧\n  ((rec_sum A : ℝ) - ε * rec_sum Q_i ≤ rec_sum A_i) ∧\n  (i ≤ (A \\ A_i).card ∨ ∀ q ∈ ppowers_in_set A_i, ε < rec_sum_local A_i q) :=\nbegin\n  induction i with i ih,\n  { exact ⟨A, finset.subset.rfl, ∅, by simp⟩ },\n  obtain ⟨A', hA', Q', hQ', hQA', hr, ih⟩ := ih,\n  by_cases hq : ∀ q ∈ ppowers_in_set A', ε < rec_sum_local A' q,\n  { exact ⟨A', hA', Q', hQ', hQA', hr, or.inr hq⟩ },\n  obtain ⟨q', hq', h4⟩ := not_ball.mp hq,\n  have hq'zero : q' ≠ 0 := ne_of_mem_of_not_mem hq' zero_not_mem_ppowers_in_set,\n  have hq'zero' : (q' : ℚ) ≠ 0 := by exact_mod_cast hq'zero,\n  let A'' := A'.filter (λ n, ¬ (q' ∣ n ∧ coprime q' (n / q'))),\n  refine ⟨A'', (A'.filter_subset _).trans hA', _⟩,\n  let Q'' := insert q' Q',\n  have hq'' : q' ∉ Q' := finset.disjoint_right.1 hQA' hq',\n  refine ⟨Q'', _, _, _, _⟩,\n  { exact finset.insert_subset.2 ⟨ppowers_in_set_subset hA' hq', hQ'⟩ },\n  { refine finset.disjoint_insert_left.2 ⟨_, _⟩,\n    { simp [A'', ppowers_in_set] {contextual := tt} },\n    exact hQA'.mono_right (ppowers_in_set_subset (finset.filter_subset _ _)) },\n  { have hrs : (rec_sum Q'' : ℝ) = rec_sum Q' + 1 / q',\n    { rw [rec_sum, rec_sum, finset.sum_insert hq'', add_comm, rat.cast_add, rat.cast_div,\n        rat.cast_coe_nat, rat.cast_one] },\n    have hrs2a : rec_sum A'' + rec_sum_local A' q' / q' = rec_sum A' ,\n    { simp only [rec_sum, rec_sum_local, div_eq_mul_one_div (q' : ℚ)],\n      rw [←finset.mul_sum, mul_div_cancel_left _ hq'zero', add_comm, ←finset.sum_union, local_part,\n        finset.filter_union_filter_neg_eq],\n      exact finset.disjoint_filter_filter_neg _ _ },\n    have hrs3 : (rec_sum A' : ℝ) ≤ rec_sum A'' + ε * (1 / q'),\n    { rw [←hrs2a, rat.cast_add, add_le_add_iff_left, rat.cast_div, mul_one_div, rat.cast_coe_nat],\n      exact (div_le_div_right (by rwa [nat.cast_pos, pos_iff_ne_zero])).2 (le_of_not_lt h4) },\n    rw hrs,\n    linarith only [hrs, hrs3, hr] },\n  left,\n  rw nat.succ_le_iff,\n  refine (ih.resolve_right hq).trans_lt _,\n  apply finset.card_lt_card,\n  rw ssubset_iff_of_subset (sdiff_subset_sdiff subset.rfl (filter_subset _ _)),\n  simp only [ppowers_in_set, mem_bUnion, mem_filter, exists_prop, nat.mem_divisors,\n    and_assoc] at hq',\n  obtain ⟨x, hx₁, hx₂, hx₃, -, hx₅⟩ := hq',\n  refine ⟨x, _⟩,\n  simp [hx₁, hx₂, hx₅, hA' hx₁],\nend\n\n\n\n-- Lemma 5.5\nlemma pruning_lemma_one :\n  ∀ᶠ (N : ℕ) in at_top, ∀ A ⊆ finset.range (N + 1), ∀ ε : ℝ, 0 < ε →\n    ∃ B ⊆ A,\n      ((rec_sum A : ℝ) - ε * 2 * log (log N) ≤ rec_sum B) ∧\n      (∀ q ∈ ppowers_in_set B, ε < rec_sum_local B q) :=\nbegin\n  filter_upwards [explicit_mertens] with N hN A hA ε hε,\n  obtain ⟨B, hB, Q, hQ, haux, h_recsums, h_local⟩ := pruning_lemma_one_prec A ε (A.card + 1),\n  refine ⟨B, hB, _, _⟩,\n  { have hQu : Q ⊆ (finset.range (N + 1)).filter is_prime_pow,\n    { intros q hq,\n      rw [finset.mem_filter, finset.mem_range],\n      have hqA : q ∈ ppowers_in_set A := hQ hq,\n      simp only [ppowers_in_set, finset.mem_bUnion, finset.mem_filter, finset.mem_range, exists_prop,\n        and_assoc] at hqA,\n      obtain ⟨a, ha, hqa, hq', hq''⟩ := hqA,\n      exact ⟨(nat.divisor_le hqa).trans_lt (finset.mem_range.1 (hA ha)), hq'⟩ },\n    have hQt : (rec_sum Q : ℝ) ≤ ∑ q in (finset.range (N + 1)).filter is_prime_pow, 1 / q,\n    { simp only [rec_sum, rat.cast_sum, one_div, rat.cast_inv, rat.cast_coe_nat],\n      exact finset.sum_le_sum_of_subset_of_nonneg hQu (by simp) },\n    nlinarith },\n  refine h_local.resolve_left _,\n  rw [not_le, nat.lt_succ_iff],\n  exact card_le_of_subset (sdiff_subset _ _),\nend\n\n-- Inductive heart of Lemma 5.6\nlemma pruning_lemma_two_ind :\n  ∀ᶠ (N : ℕ) in at_top, ∀ M α ε : ℝ, ∀ A ⊆ finset.range (N + 1),\n  0 < M → M < N → 0 < ε → 4 * ε * log (log N) < α → (∀ n ∈ A, M ≤ ↑n) → α ≤ rec_sum A →\n  (∀ q ∈ ppowers_in_set A, (q : ℝ) ≤ ε * M ∧ ε < rec_sum_local A q) →\n  (∀ i : ℕ, ∃ A_i ⊆ A,\n      (α - 1 / M ≤ rec_sum A_i) ∧\n      (∀ q ∈ ppowers_in_set A_i, ε < rec_sum_local A_i q) ∧\n      (i ≤ (A \\ A_i).card ∨ (rec_sum A_i : ℝ) < α) )\n  :=\nbegin\n  filter_upwards [pruning_lemma_one] with N hN M α ε A hA hM hMN hε hεα hMA hrec hsmooth i,\n  induction i with i ih,\n  { refine ⟨A, subset.rfl, _, λ q hq, (hsmooth _ hq).2, or.inl zero_le'⟩,\n    exact (sub_le_self _ (by simp only [hM.le, one_div, inv_nonneg])).trans hrec },\n  obtain ⟨A_i, hA_i, ih1, ih2, ih3⟩ := ih,\n  by_cases hr : (rec_sum A_i : ℝ) < α,\n  { exact ⟨A_i, hA_i, ih1, ih2, or.inr hr⟩ },\n  have hA_ir : A_i ⊆ finset.range (N + 1) := hA_i.trans hA,\n  let ε' := 2 * ε,\n  obtain ⟨B, hB, hN1, hN2⟩ := hN A_i hA_ir ε' (mul_pos zero_lt_two hε),\n  have ht0 : α ≤ rec_sum A_i := not_lt.1 hr,\n  have hBexists : B.nonempty,\n  { rw finset.nonempty_iff_ne_empty, rintro rfl,\n    simp only [rec_sum_empty, rat.cast_zero, sub_nonpos] at hN1,\n    have ht1 : 4 * ε * log (log N) < ε' * 2 * log (log N),\n    { exact hεα.trans_le (ht0.trans hN1), },\n    rw [mul_right_comm 2 ε] at ht1,\n    linarith only [ht1] },\n  cases hBexists with x hx,\n  have hxA1 : x ∈ A_i := hB hx,\n  have hxA2 : x ∈ A := hA_i hxA1,\n  let A_i' := A_i.erase x,\n  have h3 : A_i' ⊆ A_i := erase_subset _ _,\n  refine ⟨A_i', h3.trans hA_i, _, _, _⟩,\n  { have hrs2 : (rec_sum A_i : ℝ) - 1 / x = rec_sum A_i',\n    { simp only [rec_sum, sub_eq_iff_eq_add, rat.cast_sum, one_div, rat.cast_inv, rat.cast_coe_nat,\n        finset.sum_erase_add _ _ hxA1] },\n    linarith only [ht0, one_div_le_one_div_of_le hM (hMA x (hA_i (hB hx))), hrs2] },\n  { intros q hq,\n    by_cases hxq : q ∣ x ∧ coprime q (x / q),\n    { have hlocalpart : local_part A_i' q = (local_part A_i q).erase x := filter_erase _ _ _,\n      have hlocal : rec_sum_local A_i q = rec_sum_local A_i' q + q / x,\n      { rw [rec_sum_local, rec_sum_local, hlocalpart, finset.sum_erase_add],\n        rw [local_part, finset.mem_filter],\n        exact ⟨hB hx, hxq⟩ },\n      have hlocal2 : rec_sum_local A_i q - q / x = rec_sum_local A_i' q,\n      { rwa [sub_eq_iff_eq_add] },\n      rw ← hlocal2,\n      push_cast,\n      have hppB : q ∈ ppowers_in_set B,\n      { rw [ppowers_in_set, finset.mem_bUnion],\n        refine ⟨x, hx, mem_filter.2 ⟨nat.mem_divisors.2 ⟨hxq.1, _⟩, (mem_ppowers_in_set.1 hq).1,\n          hxq.2⟩⟩,\n        rintro rfl,\n        exact hM.not_le (by simpa only [nat.cast_zero] using hMA _ hxA2) },\n      have hlocal3 : (rec_sum_local B q : ℝ) ≤ rec_sum_local A_i q :=\n        rat.cast_le.2 (rec_sum_local_mono hB),\n      have hll : ε + ε < rec_sum_local A_i q,\n      { rw ←two_mul ε,\n        exact (hN2 q hppB).trans_le hlocal3 },\n      have hll2 : (q : ℝ) / x ≤ ε,\n      { rw (div_le_iff (hM.trans_le (hMA x hxA2))),\n        have hppA : ppowers_in_set A_i' ⊆ ppowers_in_set A := ppowers_in_set_subset (h3.trans hA_i),\n        exact (hsmooth q (hppA hq)).1.trans (mul_le_mul_of_nonneg_left (hMA x hxA2) hε.le) },\n      rw lt_sub,\n      apply hll2.trans_lt,\n      rwa lt_sub_iff_add_lt },\n    have hrecl : rec_sum_local A_i q = rec_sum_local A_i' q,\n    { have hlocalaux : local_part A_i q = local_part A_i' q,\n      { rw [local_part, local_part, filter_erase, erase_eq_of_not_mem],\n        rw [mem_filter, not_and_distrib],\n        exact or.inr hxq },\n    rw [rec_sum_local, rec_sum_local, hlocalaux] },\n    rw ←hrecl,\n    exact ih2 q (ppowers_in_set_subset h3 hq) },\n  left,\n  have hcard : (A \\ A_i).card < (A \\ A_i').card,\n  { rw [card_sdiff hA_i, card_sdiff (h3.trans hA_i),\n      tsub_lt_tsub_iff_left_of_le (card_le_of_subset hA_i)],\n    exact card_erase_lt_of_mem hxA1 },\n  have hcard' : (A \\ A_i).card + 1 ≤ (A \\ A_i').card := nat.succ_le_iff.2 hcard,\n  rw nat.succ_eq_add_one,\n  cases ih3 with hf1 hf2,\n  { linarith },\n  { exfalso, linarith },\nend\n\n-- Lemma 5.6\nlemma pruning_lemma_two :\n  ∀ᶠ (N : ℕ) in at_top, ∀ M α ε: ℝ, ∀ A ⊆ finset.range(N+1),\n  (0 < M) → (M < N) → (ε > 0) → (4*ε*log(log N) < α ) →\n  (∀ n ∈ A, M ≤ (n: ℝ)) →\n  (α + 2*ε*log(log N) ≤ rec_sum A ) →\n  (∀ q ∈ ppowers_in_set A, (q : ℝ) ≤ ε*M) →\n  ∃ B ⊆ A, ( (rec_sum B : ℝ) < α) ∧ ( α - 1/M ≤ rec_sum B) ∧\n  (∀ q ∈ ppowers_in_set B, ε <\n    rec_sum_local B q)\n  :=\nbegin\n  filter_upwards [pruning_lemma_one, pruning_lemma_two_ind],\n  intros N h h2 M α ε A hA hMz hMN hε hεα hMA hrecA hsmooth,\n  rcases h A hA ε hε with ⟨A', hA', hA'1, hA'3⟩,\n  have hA'2 : A' ⊆ finset.range (N + 1) := hA'.trans hA,\n  have hMA' : ∀ n ∈ A', M ≤ (n : ℝ) := λ n hn, hMA n (hA' hn),\n  have hrecA' : α ≤ rec_sum A',\n  { refine (le_sub_right_of_add_le _).trans hA'1, rwa mul_comm ε 2, },\n  have hsmooth2 : ∀ q ∈ ppowers_in_set A', ↑q ≤ ε * M ∧ ε < rec_sum_local A' q :=\n    λ q hq, ⟨hsmooth q ((ppowers_in_set_subset hA') hq), hA'3 q hq⟩,\n  let i := A'.card + 1,\n  rcases h2 M α ε A' hA'2 hMz hMN hε hεα hMA' hrecA' hsmooth2 i with ⟨B, hB, h2, h3, ha⟩,\n  refine ⟨B, hB.trans hA', ha.resolve_left (λ ha1, _), h2, h3⟩,\n  exact not_le.2 (nat.lt_succ_self A'.card) (ha1.trans (card_le_of_subset (sdiff_subset _ _))),\nend\n\nlemma main_tech_lemma_ind :\n  ∀ᶠ (N : ℕ) in at_top, ∀ M ε y w : ℝ, ∀ A ⊆ finset.range (N + 1),\n    0 < M → M < N → 0 < ε → w < 2 * M → 1 / M < ε * log (log N) →\n    1 ≤ y → 2 ≤ w → ⌈y⌉₊ ≤ ⌊w⌋₊ →\n    (3 * ε * log (log N) ≤ 2 / w ^ 2) → (∀ n ∈ A, M ≤ (n : ℝ)) →\n    (2 / y + 2 * ε * log (log N) ≤ rec_sum A) →\n    (∀ q ∈ ppowers_in_set A, (q : ℝ) ≤ ε * M) →\n    (∀ n ∈ A, ∃ d : ℕ, y ≤ d ∧ (d : ℝ) ≤ w ∧ d ∣ n) →\n    (∀ i : ℕ, ∃ A_i ⊆ A, ∃ d_i : ℕ,\n      y ≤ d_i ∧ d_i ≤ ⌈y⌉₊ + i ∧ d_i ≤ ⌊w⌋₊ ∧\n      rec_sum A_i < 2 / d_i ∧ (2 : ℝ) / d_i - 1 / M ≤ rec_sum A_i ∧\n      (∀ q ∈ ppowers_in_set A_i, ε < rec_sum_local A_i q) ∧\n      (∀ n ∈ A_i, ∀ k, k ∣ n → k < d_i → (k : ℝ) < y) ∧\n      ((∃ n ∈ A_i, d_i ∣ n) ∨ (∀ n ∈ A_i, ∀ k, k ∣ n → k ≤ ⌈y⌉₊ + i → k ≤ ⌊w⌋₊ → (k : ℝ) < y))) :=\nbegin\n  have : tendsto (λ N : ℕ, log (log N)) at_top at_top :=\n    tendsto_log_at_top.comp (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top),\n  filter_upwards [pruning_lemma_two, this.eventually (eventually_gt_at_top 0)],\n  intros N hN h_largeN M ε y w A hA hM hMN hε hMw hMN2 hy h2w hyw2 hNw hMA hrec hsmooth hdiv i,\n  have hy01 : 0 < y := by apply lt_of_lt_of_le zero_lt_one hy,\n  have hy12 : 2 ≤ y + 1 := add_le_add_right hy 1,\n  have hobvaux : (⌈y⌉₊ : ℝ) < y + 1 := nat.ceil_lt_add_one hy01.le,\n  have hwzero : 0 < w := by apply lt_of_lt_of_le zero_lt_two h2w,\n  have hqaux : (⌊w⌋₊ : ℝ) ≤ w := nat.floor_le hwzero.le,\n  have hεNaux : 4 * ε * log(log N) < 2 * (3 * ε * log (log N)),\n  { have h₁ : (4 : ℝ) < 2 * 3 := by norm_num1,\n    simpa only [mul_assoc] using (mul_lt_mul_right (mul_pos hε h_largeN)).2 h₁ },\n  have hεNaux2 : 2 * (3 * ε * log (log N)) ≤ 2 * (2 / w ^ 2) := (mul_le_mul_left zero_lt_two).2 hNw,\n  have hwaux : 2 * w ≤ w^2,\n  { rw pow_two, exact mul_le_mul_of_nonneg_right h2w hwzero.le },\n  -- The actual proof begins, by induction\n  induction i,\n  -- The case i=0\n  { let α := (2 : ℚ) / ⌈y⌉₊,\n    have hαaux : (α : ℝ) = 2 / ⌈y⌉₊,\n    { rw [rat.cast_div, rat.cast_bit0, rat.cast_one, rat.cast_coe_nat] },\n    have hα : 4 * ε * log (log N) < α,\n    { have hα1 : 2 * ((2 : ℝ) / w ^ 2) ≤ 2 / ⌈y⌉₊,\n      { rw [←mul_div_assoc, div_le_div_iff (pow_pos hwzero _), mul_assoc, mul_le_mul_left],\n        { refine le_trans (mul_le_mul_of_nonneg_left (le_trans _ hqaux) zero_le_two) hwaux,\n          rwa nat.cast_le },\n        { exact zero_lt_two },\n        { rwa [nat.cast_pos, nat.lt_ceil, nat.cast_zero] } },\n      rw [rat.cast_div, rat.cast_bit0, rat.cast_one, rat.cast_coe_nat],\n      exact hεNaux.trans_le (hεNaux2.trans hα1) },\n    have hrec2 : (α : ℝ) + 2 * ε * log (log N) ≤ rec_sum A,\n    { rw hαaux,\n      exact add_le_of_add_le_right hrec (div_le_div_of_le_left zero_le_two hy01 (nat.le_ceil _)) },\n    rcases hN M α ε A hA hM hMN hε hα hMA hrec2 hsmooth with ⟨B, hB, hB', hB'', hN⟩,\n    refine ⟨B, hB, _, nat.le_ceil y, le_rfl, hyw2, rat.cast_lt.1 hB', by rwa ←hαaux, hN,\n      λ n hn k hk1 hk2, by rwa ←nat.lt_ceil, _⟩,\n    rw or_iff_not_imp_left,\n    intros hp n hn k hk1 hk2 hk3,\n    rw ← nat.lt_ceil,\n    refine lt_of_le_of_ne hk2 _,\n    rintro rfl,\n    exact hp ⟨n, hn, hk1⟩ },\n  -- The inductive case\n  rcases i_ih with ⟨A_i, hA_i, d_i, hstock⟩,\n  obtain hstock1 := hstock.2.2.2.2.2.2.1,\n  by_cases hdiv2 : ∃ n ∈ A_i, d_i ∣ n,\n  { exact ⟨A_i, hA_i, d_i, hstock.1, hstock.2.1.trans (add_le_add_left i_n.le_succ _),\n      hstock.2.2.1, hstock.2.2.2.1, hstock.2.2.2.2.1, hstock.2.2.2.2.2.1, hstock.2.2.2.2.2.2.1,\n      or.inl hdiv2⟩ },\n  let d_i' := min (⌈y⌉₊ + i_n + 1) ⌊w⌋₊,\n  have hd_i' : d_i + 1 ≤ d_i',\n  { rw le_min_iff,\n    refine ⟨add_le_add_right hstock.2.1 _, lt_of_le_of_ne hstock.2.2.1 _⟩,\n    rintro rfl,\n    have hA_in : A_i.nonempty,\n    { rw nonempty_iff_ne_empty,\n      rintro rfl,\n      obtain hstock2 := hstock.2.2.2.2.1,\n      rw [rec_sum_empty, rat.cast_zero, sub_nonpos, div_le_div_iff (hy01.trans_le hstock.1) hM,\n        one_mul] at hstock2,\n      exact (hstock2.trans hqaux).not_lt hMw },\n    obtain ⟨x, hx⟩ := hA_in,\n    cases hdiv x (hA_i hx) with d hdiv,\n    refine (hstock1 x hx d hdiv.2.2 (lt_of_le_of_ne (nat.le_floor hdiv.2.1) _)).not_le hdiv.1,\n    rintro rfl,\n    exact hdiv2 ⟨x, hx, hdiv.2.2⟩ },\n  let α' := (2 : ℚ) / d_i',\n  have hα'aux : (α' : ℝ) = 2 / d_i', by push_cast,\n  have hqaux' : (d_i' : ℝ) ≤ ⌊w⌋₊ := nat.cast_le.2 (min_le_right _ _),\n  have hqaux'' : (d_i' : ℝ) ≤ w := hqaux'.trans hqaux,\n  have hrec5'''aux : (0 : ℝ) < d_i := hy01.trans_le hstock.1,\n  have hrec5''' : 0 < d_i := nat.cast_pos.1 hrec5'''aux,\n  have hqauxx : (1 : ℝ) < d_i' := nat.one_lt_cast.2 ((nat.succ_lt_succ hrec5''').trans_le hd_i'),\n  have hα' : 4 * ε * log (log N) < α',\n  { have hα'1 : 2 * ((2 : ℝ) / w ^ 2) ≤ 2 / d_i',\n    { rw [←mul_div_assoc, div_le_div_iff, mul_assoc, mul_le_mul_left],\n      { exact le_trans (mul_le_mul_of_nonneg_left (le_trans hqaux' hqaux) zero_le_two) hwaux },\n      { exact zero_lt_two },\n      { exact pow_pos hwzero _ },\n      { exact zero_le_one.trans_lt hqauxx } },\n    rw hα'aux,\n    exact hεNaux.trans_le (hεNaux2.trans hα'1) },\n  have hrec2 : (α' : ℝ) + 2 * ε * log (log N) ≤ rec_sum A_i,\n  { rw hα'aux,\n    have hrec3p : (d_i : ℝ) ≤ d_i' - 1,\n    { rwa [le_sub_iff_add_le, ←nat.cast_add_one, nat.cast_le] },\n    have hrec3 : (2 : ℝ) / (d_i' - 1) - 1 / M ≤ rec_sum A_i,\n    { have hrec3' : (2 : ℝ) / (d_i' - 1) ≤ 2 / d_i,\n      { exact div_le_div_of_le_left zero_le_two hrec5'''aux hrec3p },\n      exact le_trans (sub_le_sub_right hrec3' _) hstock.2.2.2.2.1 },\n    have hrec5 : (2 : ℝ)/d_i'^2 ≤ 2/(d_i'-1) - 2/d_i',\n    { rw div_sub_div,\n      have hrec5'' : ((d_i' : ℝ) - 1) * d_i' = d_i' ^ 2 - d_i',\n      { rw [sub_mul, sq, one_mul] },\n      have hrec5' : (2 : ℝ) * d_i' - (d_i' - 1) * 2 = 2,\n      { rw [sub_mul, mul_comm, sub_sub_cancel, one_mul] },\n      rw hrec5',\n      refine div_le_div_of_le_left zero_le_two _ _,\n      rw hrec5'', rw sub_pos, nth_rewrite 0 ← pow_one (d_i' : ℝ),\n      { exact pow_lt_pow hqauxx one_lt_two },\n      { rw hrec5'',\n        apply sub_le_self,\n        exact nat.cast_nonneg _ },\n      { rw sub_ne_zero,\n        exact hqauxx.ne' },\n      { exact (zero_le_one.trans_lt hqauxx).ne' } },\n    have hrec6 :(2 : ℝ)/w^2 ≤ 2/d_i'^2, {\n      refine div_le_div_of_le_left _ _ _, norm_num,\n      apply sq_pos_of_ne_zero, norm_cast, intro hrecaux,\n      rw min_eq_iff at hrecaux,\n      cases hrecaux with hpaux1 hpaux2,\n      obtain hpaux1' := hpaux1.1, linarith,\n      obtain hpaux2' := hpaux2.1, rw nat.floor_eq_zero at hpaux2',\n      linarith, apply sq_le_sq',\n      linarith, linarith, },\n    linarith,\n    },\n  have hA_i' : A_i ⊆ finset.range(N+1),\n  { exact finset.subset.trans hA_i hA, },\n  have hMA' : (∀ (n : ℕ), n ∈ A_i → M ≤ n), {\n    intros n hn, have haux9 : n ∈ A, { exact hA_i hn, },\n    exact hMA n haux9,\n      },\n  have hsmooth' : (∀ q ∈ ppowers_in_set A_i, (q : ℝ) ≤ ε*M), {\n    intros q hq,\n    have hpp' : ppowers_in_set A_i ⊆ ppowers_in_set A,\n    { exact ppowers_in_set_subset hA_i, },\n    have hq' : q ∈ ppowers_in_set A, { exact hpp' hq, },\n    exact hsmooth q hq',},\n  specialize hN M α' ε A_i hA_i' hM hMN hε hα' hMA' hrec2 hsmooth',\n  rcases hN with ⟨B, hB, hN⟩,\n  use B, split, exact finset.subset.trans hB hA_i,\n  use d_i', split, rw ← nat.ceil_le, rw le_min_iff,\n  split, linarith, exact hyw2,\n  split, apply min_le_left, split, apply min_le_right,\n  split, exact_mod_cast hN.1, split,\n  rw ← hα'aux, exact hN.2.1, split, exact hN.2.2,\n  split,\n  intros n hn k hk1 hk2,\n  have hn2 : n ∈ A_i, { exact hB hn, },\n  cases hstock.2.2.2.2.2.2.2 with hnew1 hnew2,\n  exfalso,\n  apply hdiv2 hnew1,\n  have hk2' : k ≤ ⌈y⌉₊ + i_n, { rw lt_min_iff at hk2,\n  apply nat.le_of_lt_succ hk2.1, },\n  have hk2'' : k ≤ ⌊w⌋₊, { rw lt_min_iff at hk2, apply le_of_lt hk2.2,},\n  exact hnew2 n hn2 k hk1 hk2' hk2'',\n  by_cases hd_i'div : (∃ (n : ℕ) (H : n ∈ B), d_i' ∣ n),\n  left, exact hd_i'div, right,\n  intros n hn k hk1 hk2 hk3,\n  have hn2 : n ∈ A_i, { exact hB hn, },\n  cases hstock.2.2.2.2.2.2.2 with hnew1 hnew2,\n  exfalso, apply hdiv2 hnew1,\n  have hk2' : k ≤ d_i', { rw le_min_iff, split,\n   exact hk2, exact hk3, },\n  have hk2'' : k < d_i', {\n   rw ← ne.le_iff_lt, exact hk2', intro hkaux4,\n   apply hd_i'div, use n, split, exact hn,\n   rw ← hkaux4, exact hk1, },\n  have hk2''' : k ≤ ⌈y⌉₊ + i_n, { rw lt_min_iff at hk2'',\n    apply nat.le_of_lt_succ hk2''.1, },\n  have hk2'''' : k ≤ ⌊w⌋₊, {\n    rw lt_min_iff at hk2'', apply le_of_lt hk2''.2,},\n  exact hnew2 n hn2 k hk1 hk2''' hk2'''',\nend\n\nlemma main_tech_lemma :\n  ∀ᶠ (N : ℕ) in at_top, ∀ M ε y w : ℝ, ∀ A ⊆ finset.range(N+1),\n  (0 < M) → (M < N) → (0 < ε) → (2*M > w) → (1/M < ε*log(log N)) →\n  (1 ≤ y) → (2 ≤ w) → (⌈y⌉₊ ≤ ⌊w⌋₊) →\n  (3*ε*log(log N) ≤ 2/(w^2)) → (∀ n ∈ A, M ≤ (n: ℝ)) →\n  (2/y + 2*ε*log(log N) ≤ rec_sum A ) →\n  (∀ q ∈ ppowers_in_set A, (q : ℝ) ≤ ε*M) →\n  (∀ n ∈ A, ∃ d : ℕ, (y ≤ d) ∧ ((d : ℝ) ≤ w) ∧ d ∣ n) →\n  (∃ A' ⊆ A, ∃ d : ℕ, A' ≠ ∅ ∧ (y ≤ d) ∧ ((d : ℝ) ≤ w) ∧ rec_sum A' < 2/d ∧\n  (2 : ℝ)/d-1/M ≤ rec_sum A' ∧ (∀ q ∈ ppowers_in_set A', ε < rec_sum_local A' q)\n  ∧ (∃ n ∈ A', d ∣ n) ∧ (∀ n ∈ A', ∀ k : ℕ, k ∣ n → k < d → (k : ℝ) < y))\n  :=\nbegin\n  have : tendsto (λ N : ℕ, log (log N)) at_top at_top :=\n    tendsto_log_at_top.comp (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top),\n filter_upwards [main_tech_lemma_ind, this (eventually_gt_at_top 0)],\n intros N hN h_largeN M ε y w A hA hM hMN hε hMw hMN2 hy h2w hyw hNw hAM hrec hsmooth hdiv,\n have hy01 : 0 < y, {\n   apply @lt_of_lt_of_le _ _ 0 1 y zero_lt_one hy, },\n have hy12 : 2 ≤ y + 1, {refine add_le_add_right hy 1, },\n have hwzero : 0 < w := by apply lt_of_lt_of_le  zero_lt_two h2w,\n let i := ⌊w⌋₊ - ⌈y⌉₊,\n specialize hN M ε y w A hA hM hMN hε hMw hMN2 hy h2w hyw hNw hAM hrec hsmooth hdiv i,\n rcases hN with ⟨A', hA', d, hN⟩,\n use A', split, exact hA', use d,\n have hdw : (d : ℝ) ≤ w, {\n   have hauxw : (⌊w⌋₊ : ℝ) ≤ w, { apply nat.floor_le (le_of_lt hwzero), },\n  have hauxw2 : (d : ℝ) ≤ (⌊w⌋₊ : ℝ), {exact nat.cast_le.mpr hN.2.2.1, },\n  exact hauxw2.trans hauxw,\n  },\n have hA'ne : A' ≠ ∅, {\n intro hA'em,\n have hreczero : rec_sum A' = 0, {  rw hA'em, apply rec_sum_empty, },\n rw hreczero at hN, norm_cast at hN,\n have haux1 : (2 : ℝ)/d ≤ 1/M, { apply sub_nonpos.mp hN.2.2.2.2.1, },\n have haux2 : (2 : ℝ)/w ≤ 2/d,\n { refine div_le_div_of_le_left zero_le_two _ _,\n   apply @lt_of_lt_of_le _ _ 0 y (d : ℝ), exact hy01, exact hN.1, exact hdw,\n   },\n have haux3 : (2 : ℝ)/w^2 ≤ 2/w,\n { refine div_le_div_of_le_left zero_le_two hwzero _, refine le_self_pow _ one_le_two,\n   apply le_trans one_le_two h2w, },\n have haux4: 3*ε*log(log N) < ε*log(log N), {\n   apply lt_of_le_of_lt hNw, apply lt_of_le_of_lt haux3, apply lt_of_le_of_lt haux2,\n   apply lt_of_le_of_lt haux1 hMN2,\n  },\n rw mul_lt_mul_right at haux4, rw mul_lt_iff_lt_one_left at haux4,\n norm_num at haux4, exact hε, exact h_largeN,},\n split, exact hA'ne, split, exact hN.1,\n split, exact hdw, split, exact hN.2.2.2.1, split, exact hN.2.2.2.2.1,\n split, exact hN.2.2.2.2.2.1, split,\n cases hN.2.2.2.2.2.2.2 with hv1 hv2, exact hv1,\n exfalso,\n have hAexists : ∃ (x : ℕ), x ∈ A', {\n    by_contra, apply hA'ne, rw finset.eq_empty_iff_forall_not_mem,\n    intros x hx, apply h, use x, exact hx,\n    },\n cases hAexists with x hx,\n have hx2 : x ∈ A, {exact hA' hx,},\n specialize hdiv x hx2, cases hdiv with m hdiv,\n have htempw : m ≤ ⌊w⌋₊, {\n   apply nat.le_floor, exact hdiv.2.1,\n  },\n have htemp : m ≤ ⌈y⌉₊ + i, {\n   have hobvious : ⌈y⌉₊ + i = ⌊w⌋₊, {\n     rw ← add_tsub_assoc_of_le, simp only [add_tsub_cancel_left, eq_self_iff_true],\n     exact hyw, },\n   rw hobvious, exact htempw,\n  },\n specialize hv2 x hx m hdiv.2.2 htemp htempw, linarith, exact hN.2.2.2.2.2.2.1,\nend\n\n\nlemma large_enough_Naux1 : (∀ᶠ (N : ℕ) in at_top,\n  (N : ℝ) ^ (1 - (8 : ℝ) / log (log N)) ≤\n   ((N : ℝ) ^ (1 - (1 : ℝ) / log (log N)) / (2 * log N ^ ((1 : ℝ) / 100))) *\n     (((N : ℝ) ^ (1 - (3 : ℝ)/ log (log N)))) ^ 2 / (16 * N ^ 2 * log N ^ 2)) :=\nbegin\n  have haux4: asymptotics.is_O_with ((1 : ℝ) / (2 * log (2 * 16))) at_top log id,\n  { refine is_o_log_id_at_top.def' _,\n    rw one_div_pos,\n    exact mul_pos zero_lt_two (log_pos (by norm_num1)) },\n  have haux5: asymptotics.is_O_with ((1 : ℝ) / ((2 * (2 + 1 / 100)) ^ ((1 : ℝ) / 2))) at_top log\n     (λ x, x^((1 : ℝ) / 2)),\n  { refine (is_o_log_rpow_at_top (half_pos zero_lt_one)).def' _,\n    rw one_div_pos,\n    refine rpow_pos_of_pos _ _,\n    norm_num1, },\n  filter_upwards [tendsto_log_log_coe_at_top.eventually (eventually_ge_at_top 6),\n    tendsto_log_coe_at_top.eventually (eventually_ge_at_top (128^(500 : ℝ))),\n    eventually_ge_at_top 64,\n    tendsto_log_coe_at_top.eventually haux4.bound,\n    tendsto_log_coe_at_top.eventually haux5.bound]\n    with N hN1 hN2 hN3 hN3new4 hN3new5,\n  clear haux4 haux5,\n  have hN4 : 1 < log (log N), { exact hN1.trans_lt' (by norm_num1) },\n  have hN5 : (1 : ℝ) < N, { rw nat.one_lt_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : ℝ) < N := zero_le_one.trans_lt hN5,\n  have hN7 : 0 < log (log N) := zero_le_one.trans_lt hN4,\n  have hN8 : 0 < log N,\n  { apply hN2.trans_lt',\n    apply rpow_pos_of_pos,\n    norm_num1 },\n  have hN12 : 2 * log (2 * 16) * log (log N) ≤ log N,\n  { rwa [norm_of_nonneg hN7.le, id.def, norm_of_nonneg hN8.le, mul_comm,\n      ←div_eq_mul_one_div, le_div_iff'] at hN3new4,\n    refine mul_pos zero_lt_two (log_pos _),\n    norm_num1 },\n  have hN13 : (2 * (2 + 1 / 100)) ^ ((1 : ℝ) / 2) * log (log N) ≤ log N ^ ((1 : ℝ) / 2),\n  { simp_rw [norm_eq_abs] at hN3new5,\n    rw [abs_of_nonneg hN7.le, abs_of_nonneg (rpow_nonneg_of_nonneg hN8.le _), mul_comm, mul_div,\n      mul_one] at hN3new5,\n    rw [mul_comm, ← le_div_iff (rpow_pos_of_pos _ _)],\n    exact hN3new5,\n    norm_num1 },\n  rw le_div_iff,\n  convert_to 16 * ((N : ℝ)^(1 - (8 : ℝ)/(log(log N))) * (N ^ 2)) * (log N) ^ 2 ≤\n    ((↑N ^ (1 - 3 / log (log ↑N))) ^ 2 * (N : ℝ)^(1 - (1 : ℝ)/(log(log N)))) /\n    (2 * (log N)^((1/100 : ℝ)))\n    using 0,\n    { ring_nf, },\n  rw [le_div_iff, ← rpow_two, ← rpow_two, ← rpow_two, ← rpow_add, ← rpow_mul, ← rpow_add],\n  convert_to (2 * 16) * (log N ^ (2 : ℝ) * log N ^ (1 / 100 : ℝ)) * (N : ℝ) ^ (1 - 8 / log (log N) + 2)\n    ≤ (N : ℝ) ^ ((1 - 3 / log (log N)) * 2 + (1 - 1 / log (log N))) using 0,\n    { ring_nf,},\n  rw [← le_div_iff, ← rpow_sub, ← rpow_add],\n  have : (1 - 3 / log (log N)) * 2 + (1 - 1 / log (log N)) - (1 - 8 / log (log N) + 2)\n   = 1 / log (log N),\n   { ring, },\n  rw [this, ← log_le_log, log_rpow, log_mul, log_rpow],\n  nth_rewrite 2 mul_comm,\n  rw [← div_eq_mul_one_div, le_div_iff, add_mul, mul_assoc, ← sq],\n  apply @le_trans _ _ _ ((1/2)*(log N)+(1/2)*(log N)) _,\n  apply add_le_add,\n  rwa [← mul_le_mul_left (zero_lt_two : (0 : ℝ) < 2), ← mul_assoc, ← mul_assoc, mul_one_div_cancel,\n    one_mul],\n  exact two_ne_zero,\n  rw [← mul_le_mul_left (@zero_lt_two ℝ _ _), ← mul_assoc, ← mul_assoc, mul_one_div_cancel,\n   one_mul, ← rpow_two, ← real.sqrt_le_sqrt_iff, real.sqrt_eq_rpow, real.sqrt_eq_rpow,\n   real.mul_rpow, ← rpow_mul, mul_one_div_cancel, rpow_one],\n  exact hN13,\n  refine ne_of_gt zero_lt_two,\n  exact le_of_lt hN7,\n  refine mul_nonneg zero_le_two _,\n  norm_num1,\n  exact rpow_nonneg_of_nonneg hN7.le _,\n  exact le_of_lt hN8,\n  refine ne_of_gt zero_lt_two,\n  rw [mul_comm, mul_div, mul_one, add_halves],\n  exact hN7,\n  exact hN8,\n  norm_num1,\n  apply ne_of_gt,\n  apply rpow_pos_of_pos hN8,\n  exact hN6,\n  apply mul_pos,\n  norm_num1,\n  apply rpow_pos_of_pos hN8,\n  apply rpow_pos_of_pos hN6,\n  exact hN8,\n  exact hN6,\n  apply rpow_pos_of_pos hN6,\n  exact hN6,\n  exact le_of_lt hN6,\n  exact hN6,\n  refine mul_pos zero_lt_two _,\n  apply rpow_pos_of_pos hN8,\n  exact mul_pos (mul_pos (by norm_num1) (sq_pos_of_pos hN6)) (sq_pos_of_pos hN8),\nend\n\nlemma large_enough_Naux2 : ∀ (c: ℝ), (c > 0) → ∀ᶠ (N : ℕ) in at_top,\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ c*(N : ℝ)^(1 - (1 : ℝ)/(log(log N)))/(log N)^((1/500 : ℝ)) ∧\n  (log N)^(-(1/101 : ℝ)) ≤ (2 : ℝ)/((log N)^(1/500 : ℝ)/4) - 1/ (N : ℝ)^(1 - (1 : ℝ)/(log(log N)))\n  :=\nbegin\n  intros c hc,\n  have haux: asymptotics.is_O_with ((1 : ℝ)) at_top (λ (x : ℝ), (log x))\n     (λ (x : ℝ), x^((1 : ℝ)/2)), {\n    refine asymptotics.is_o.def' _ _, refine is_o_log_rpow_at_top _,\n    norm_num1, exact zero_lt_one,\n    },\n  have haux2: asymptotics.is_O_with ((1 : ℝ)) at_top (λ (x : ℝ), (log x))\n     (λ (x : ℝ), x^((1 : ℝ))), {\n    refine asymptotics.is_o.def' _ _, refine is_o_log_rpow_at_top _,\n     norm_num1, norm_num1, },\n  filter_upwards [(tendsto_log_at_top.comp (tendsto_log_at_top.comp\n    tendsto_coe_nat_at_top_at_top)).eventually (eventually_ge_at_top 6),\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually\n    (eventually_ge_at_top (1 : ℝ)), eventually_ge_at_top 64,\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually haux.bound,\n    tendsto_coe_nat_at_top_at_top.eventually haux2.bound,\n    (tendsto_log_at_top.comp (tendsto_log_at_top.comp\n    tendsto_coe_nat_at_top_at_top)).eventually\n       (eventually_ge_at_top (-log c / (7 - 1 / 500)))\n    ] with N hN1 hN2 hN3 hNnew hNnew2 hNnew3,\n  dsimp at hN1 hN2 hNnew3,\n  have hN5 : (1 : ℝ) < N, { norm_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : ℝ) < N, { refine lt_trans zero_lt_one hN5, },\n  have hN7 : 0 < (log(log N)), {refine lt_of_lt_of_le _ hN1, norm_num1, },\n  have hN8 : 0 < log N, { apply lt_of_lt_of_le _ hN2, norm_num1,},\n  have hN9 : log(log N) ≤ (log N)^((1 : ℝ)/2), {\n      simp_rw [norm_eq_abs] at hNnew, rw abs_of_nonneg at hNnew,\n      rw abs_of_nonneg at hNnew, dsimp at hNnew,\n      rw one_mul at hNnew, exact hNnew,\n      apply rpow_nonneg_of_nonneg, dsimp, exact le_of_lt hN8, dsimp,\n      exact le_of_lt hN7,\n   },\n  have hN10 : log N ≤ N, {\n      simp_rw [norm_eq_abs] at hNnew2, rw abs_of_nonneg at hNnew2,\n      rw abs_of_nonneg at hNnew2,\n      rw [one_mul, rpow_one] at hNnew2, exact hNnew2,\n      apply rpow_nonneg_of_nonneg, exact le_of_lt hN6,\n      exact le_of_lt hN8,\n   },\n  split,\n  rw [le_div_iff, mul_comm, ← le_div_iff, ← mul_div, ← rpow_sub],\n  have : 1 - 1 / log (log N) - (1 - 8 / log (log N)) = 7/log(log N) := by ring,\n  rw [this, ← log_le_log, log_rpow, log_mul, log_rpow],\n  nth_rewrite 1 mul_comm, rw mul_div,\n  have hcN : -(7-1/500)*log(log N) ≤ log c, {\n    rw [neg_mul, ← neg_le, ← div_le_iff'], exact hNnew3, norm_num1,},\n  apply @le_trans _ _ _ (-(7-1/500)*log(log N)+(log N)*7/log(log N)) _,\n  rw [neg_mul, neg_add_eq_sub, le_sub_iff_add_le, ← add_mul, add_sub, add_comm,\n    ← add_sub, sub_self, add_zero], nth_rewrite 1 mul_comm,\n  rw [← mul_div, mul_le_mul_left, le_div_iff, ← real.sqrt_le_sqrt_iff, sqrt_mul_self,\n       sqrt_eq_rpow],\n  exact hN9, exact le_of_lt hN7, exact le_of_lt hN8, exact hN7, norm_num1,\n  apply add_le_add_right hcN, exact hN6, apply ne_of_gt hc,\n  apply ne_of_gt, apply rpow_pos_of_pos hN6, exact hN8,\n  apply rpow_pos_of_pos hN8, apply mul_pos hc, apply rpow_pos_of_pos hN6, exact hN6,\n  apply rpow_pos_of_pos hN6, apply rpow_pos_of_pos hN8,\n  apply @le_trans _ _ _ ((7 : ℝ)/((log N)^(1/500 : ℝ))) _,\n  rw [le_div_iff, ← rpow_add], apply @le_trans _ _ _ (1 : ℝ) _,\n  apply rpow_le_one_of_one_le_of_nonpos hN2, norm_num1, norm_num1,\n  exact hN8, apply rpow_pos_of_pos hN8,\n  rw [le_sub, div_div_eq_mul_div, div_sub_div_same], norm_num1,\n  rw one_div_le_one_div,\n  apply @le_trans _ _ _ ((N : ℝ)^(((1 : ℝ)/500))) _,\n  rw rpow_le_rpow_iff, exact hN10, exact le_of_lt hN8, exact le_of_lt hN6,\n  norm_num1, apply rpow_le_rpow_of_exponent_le, exact le_of_lt hN5,\n  rw le_sub, rw one_div_le, apply le_trans _ hN1, norm_num1, exact hN7,\n  norm_num1, apply rpow_pos_of_pos hN6, apply rpow_pos_of_pos hN8,\nend\n\nlemma large_enough_Naux  :  ∀ (c: ℝ), (c > 0) → ∀ᶠ (N : ℕ) in at_top,\nlet M := (N : ℝ)^(1 - (1 : ℝ)/(log(log N))), L := M / (2 * log N ^ ((1 : ℝ)/100)),\n    T := M / log N, ε := (N : ℝ)^(-(5 : ℝ)/(log(log N))),\n    ε' := (log N)^(-(1/100 : ℝ)), K := (N : ℝ)^(1 - (3 : ℝ)/(log(log N)))  in\n  (ε ≤ ε') →\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤  ε'*M ∧\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ (L * K ^ 2 / (16 * N ^ 2 * log N ^ 2)) ∧\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ (T * K ^ 2 / (N ^ 2 * log N)) ∧\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ c*M/(log N)^((1/500 : ℝ)) ∧\n  (log N)^(-(1/101 : ℝ)) ≤ (2 : ℝ)/((log N)^(1/500 : ℝ)/4) - 1/M\n  :=\nbegin\n  intros c hc,\n  obtain hlargeaux1 := large_enough_Naux1,\n  obtain hlargeaux2 := large_enough_Naux2,\n  specialize hlargeaux2 c hc,\n  filter_upwards [(tendsto_log_at_top.comp (tendsto_log_at_top.comp\n    tendsto_coe_nat_at_top_at_top)).eventually (eventually_ge_at_top 6),\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually\n    (eventually_ge_at_top (128^(500 : ℝ))), eventually_ge_at_top 64,\n    hlargeaux2, hlargeaux1\n    ] with N hN1 hN2 hN3 hotheraux hnec,\n  dsimp at hN1 hN2,\n  clear hlargeaux2 hlargeaux1,\n  have hN4 : 1 < (log(log N)), { refine lt_of_lt_of_le _ hN1, norm_num1, },\n  have hN5 : (1 : ℝ) < N, { norm_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : ℝ) < N, { refine lt_trans zero_lt_one hN5, },\n  have hN7 : 0 < (log(log N)), { refine lt_trans zero_lt_one hN4, },\n  have hN8 : 0 < log N, { apply lt_of_lt_of_le _ hN2, apply rpow_pos_of_pos, norm_num1 },\n  intro hT3, split,\n  rw [← div_le_iff, ← rpow_sub], apply le_trans _ hT3,\n  apply rpow_le_rpow_of_exponent_le, exact le_of_lt hN5,\n  convert_to (-7)/log(log N) ≤ (-5)/log(log N) using 0, { ring_nf, },\n  rw div_le_div_right, apply neg_le_neg, norm_num1, exact hN7, exact hN6,\n  apply rpow_pos_of_pos hN6, split,\n  exact hnec, split, apply le_trans hnec,\n  rw [div_le_div_iff, div_eq_mul_inv _ (2 * log ↑N ^ ((1 : ℝ)/100)),div_eq_mul_inv _ (log N)],\n  convert_to (((N : ℝ)^(1 - (1 : ℝ)/log(log N)))*((N : ℝ)^(1 - (3 : ℝ)/log(log N)))^2*(N : ℝ)^2)*((2*(log N)^((1 : ℝ)/100))⁻¹*(log N))\n       ≤  (((N : ℝ)^(1 - (1 : ℝ)/log(log N)))*((N : ℝ)^(1 - (3 : ℝ)/log(log N)))^2*(N : ℝ)^2)*((log N)⁻¹*16*(log N)^2) using 0,\n       { ring_nf, },\n  rw [mul_le_mul_left, ← rpow_neg_one, ← rpow_neg_one,\n      mul_comm ((log N)^(-(1 : ℝ))) 16, mul_assoc, ← rpow_two, ← rpow_add], norm_num1,\n  rw [rpow_one, mul_le_mul_right, rpow_neg_one, inv_le],\n  apply @le_trans _ _ _ (2 : ℝ) _, norm_num1,\n  rw [← mul_one (2 : ℝ), mul_assoc, mul_le_mul_left, one_mul], apply one_le_rpow,\n  apply le_trans _ hN2,\n  { norm_cast,\n    rw nat.add_one_le_iff,\n    apply pow_pos,\n    norm_num1 },\n  norm_num1, exact zero_lt_two, apply mul_pos zero_lt_two,\n  apply rpow_pos_of_pos hN8, exact real.nontrivial, norm_num1, exact hN8, exact hN8,\n  apply mul_pos, apply mul_pos, apply rpow_pos_of_pos hN6,\n  apply sq_pos_of_pos, apply rpow_pos_of_pos hN6, apply sq_pos_of_pos hN6,\n  apply mul_pos, apply mul_pos, norm_num1, apply sq_pos_of_pos hN6,\n  apply sq_pos_of_pos hN8, apply mul_pos, apply sq_pos_of_pos hN6, exact hN8,\n  exact hotheraux,\nend\n\n\n\nlemma large_enough_N  :  ∀ (c: ℝ), (c > 0) → ∀ᶠ (N : ℕ) in at_top,\nlet M := (N : ℝ)^(1 - (1 : ℝ)/(log(log N))), L := M / (2 * log N ^ ((1 : ℝ)/100)),\n    T := M / log N, ε := (N : ℝ)^(-(5 : ℝ)/(log(log N))),\n    ε' := (log N)^(-(1/100 : ℝ)), K := (N : ℝ)^(1 - (3 : ℝ)/(log(log N)))  in\n 1/M < ε*log(log N) ∧ 0 < ε ∧ (N : ℝ) ≤ M^(2 : ℝ) ∧ M < N ∧ 0 < M ∧ (0 : ℝ) < log N ∧\n 8 ≤ K ∧ K < M ∧ (log N)^((1/500 : ℝ)) < 2*M ∧\n  2*ε*log(log N) ≤ (log N)^(-(1/200 : ℝ)) ∧\n  3*ε*log(log N) ≤ 2 / ((log N)^((1/500 : ℝ)))^2 ∧\n  3 * (2 * ε' * log (log ↑N)) + 1 / M ≤ (1/(2*(log N)^((1/500 : ℝ)))) ∧\n  (log N)^((1/500 : ℝ)) ≤ M/192  ∧ 1/M < ε'*log(log N) ∧\n  3*ε'*log(log N) ≤ 2/((log N)^((1/500 : ℝ)))^2 ∧\n   2*ε'*log(log N) ≤ (log N)^(-(1/200 : ℝ)) ∧\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤  ε'*M ∧\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ (L * K ^ 2 / (16 * N ^ 2 * log N ^ 2)) ∧\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ (T * K ^ 2 / (N ^ 2 * log N)) ∧\n  (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ c*M/(log N)^((1/500 : ℝ)) ∧\n  (log N)^(-(1/101 : ℝ)) ≤ (2 : ℝ)/((log N)^(1/500 : ℝ)/4) - 1/M\n  :=\nbegin\n  intros c hc,\n  obtain hlargeaux := large_enough_Naux,\n  specialize hlargeaux c hc,\n  have haux: asymptotics.is_O_with ((1 : ℝ)/24) at_top (λ (x : ℝ), (log x))\n     (λ (x : ℝ), x^((1 : ℝ)/125)),\n  { refine asymptotics.is_o.def' _ _, refine is_o_log_rpow_at_top _,\n     norm_num1, norm_num1, },\n have haux2: asymptotics.is_O_with ((2 : ℝ)/3) at_top (λ (x : ℝ), (log x))\n     (λ (x : ℝ), x^((3 : ℝ)/500)),\n  { refine asymptotics.is_o.def' _ _, refine is_o_log_rpow_at_top _,\n     norm_num1, norm_num1, },\n      have haux3: asymptotics.is_O_with ((1 : ℝ)/2) at_top (λ (x : ℝ), (log x))\n     (λ (x : ℝ), x^((1 : ℝ)/200)),\n  { refine asymptotics.is_o.def' _ _, refine is_o_log_rpow_at_top _,\n     norm_num1, norm_num1, },\n  filter_upwards [(tendsto_log_at_top.comp (tendsto_log_at_top.comp\n    tendsto_coe_nat_at_top_at_top)).eventually (eventually_ge_at_top 6),\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually\n    (eventually_ge_at_top (192^(500 : ℝ))), eventually_ge_at_top 64,\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually haux.bound,\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually haux2.bound,\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top).eventually haux3.bound,\n    hlargeaux\n    ]\n    with N hN1 hN2 hN3 hN3new hN3new2 hN3new3 hotheraux,\n  dsimp at hN1 hN2,\n  clear haux haux2 haux3 hlargeaux,\n  have hN4 : 1 < (log(log N)), { refine lt_of_lt_of_le _ hN1, norm_num1, },\n  have hN5 : (1 : ℝ) < N, { norm_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : ℝ) < N, { refine lt_trans zero_lt_one hN5, },\n  have hN7 : 0 < (log(log N)), { refine lt_trans zero_lt_one hN4, },\n  have hN8 : 0 < log N, { apply lt_of_lt_of_le _ hN2, apply rpow_pos_of_pos, norm_num1,},\n  have hN9 : 24*log(log N) ≤ (log N)^(1/125 : ℝ), {\n      simp_rw [norm_eq_abs] at hN3new, rw abs_of_nonneg at hN3new,\n      rw abs_of_nonneg at hN3new, dsimp at hN3new, rw [mul_comm, ← le_div_iff],\n      rw [mul_comm, mul_div, mul_one] at hN3new, exact hN3new, norm_num1,\n      apply rpow_nonneg_of_nonneg, dsimp, exact le_of_lt hN8, dsimp,\n      exact le_of_lt hN7,\n   },\n     have hN10 : log(log N) ≤ (2/3)*(log N)^(3/500 : ℝ), {\n      simp_rw [norm_eq_abs] at hN3new2, rw abs_of_nonneg at hN3new2,\n      rw abs_of_nonneg at hN3new2, dsimp at hN3new2, exact hN3new2,\n      apply rpow_nonneg_of_nonneg, dsimp, exact le_of_lt hN8, dsimp,\n      exact le_of_lt hN7,\n   },\n        have hN11 : 2*log(log N) ≤ (log N)^(1/200 : ℝ), {\n      simp_rw [norm_eq_abs] at hN3new3, rw abs_of_nonneg at hN3new3,\n      rw abs_of_nonneg at hN3new3, dsimp at hN3new3, rw [mul_comm, ← le_div_iff],\n      rw [mul_comm, mul_div, mul_one] at hN3new3, exact hN3new3, norm_num1,\n      apply rpow_nonneg_of_nonneg, dsimp, exact le_of_lt hN8, dsimp,\n      exact le_of_lt hN7,\n   },\n  clear hN3new hN3new2 hN3new3,\n  have h500 : (0 : ℝ) < 500 := by norm_num1,\n  have h5002 : (0 : ℝ) < 500/2 := by norm_num1,\n    have hTp : 192*(log N)^((1/500 : ℝ)) < (N : ℝ)^(1 - (1 : ℝ)/(log(log N))),\n  { have : 192*(log N)^((1/500 : ℝ)) ≤ (log N)^((1/500 : ℝ))*(log N)^((1/500 : ℝ)),\n    { apply mul_le_mul, rw ← (real.rpow_le_rpow_iff _ _ h500), rw ← rpow_mul,\n    apply le_trans hN2, norm_num1, rw rpow_one, exact le_of_lt hN8, norm_num1,\n    apply rpow_nonneg_of_nonneg (le_of_lt hN8), refl,\n    apply rpow_nonneg_of_nonneg (le_of_lt hN8), apply rpow_nonneg_of_nonneg (le_of_lt hN8),},\n   apply lt_of_le_of_lt this, rw ← rpow_add, rw ← (real.rpow_lt_rpow_iff _ _ h5002),\n   rw ← rpow_mul, norm_num1, rw rpow_one,\n   apply lt_of_le_of_lt (real.log_le_sub_one_of_pos hN6),\n   apply lt_of_lt_of_le (sub_one_lt (N : ℝ)), rw ← rpow_mul, nth_rewrite 0 ← (real.rpow_one N),\n   apply rpow_le_rpow_of_exponent_le (le_of_lt hN5),\n   rw [sub_mul, le_sub, mul_comm, mul_one_div, div_le_iff, mul_comm,← div_le_iff],\n   apply le_trans _ hN1, norm_num1, norm_num1, exact hN7, exact le_of_lt hN6,\n   exact le_of_lt hN8, apply real.rpow_nonneg_of_nonneg (le_of_lt hN8),\n   apply real.rpow_nonneg_of_nonneg (le_of_lt hN6), exact hN8,\n   },\n  have hT : 4*(log N)^(1/500 : ℝ) < (N : ℝ)^(1 - (1 : ℝ)/(log(log N))),\n  { apply lt_of_le_of_lt _ hTp, refine (mul_le_mul_right _).mpr _,\n    apply real.rpow_pos_of_pos hN8, norm_num1,},\n  have hT' : (log N)^(1/500 : ℝ) < (N : ℝ)^(1 - (1 : ℝ)/(log(log N))),\n  { apply lt_of_le_of_lt _ hT, refine (le_mul_iff_one_le_left _).mpr _,\n    apply real.rpow_pos_of_pos hN8, norm_num1,},\n  split, rw [one_div, inv_pos_lt_iff_one_lt_mul, mul_comm, ← mul_assoc],\n  apply one_lt_mul, rw ← real.rpow_add, apply real.one_le_rpow (le_of_lt hN5),\n  rw [sub_add, ← sub_div, sub_nonneg, div_le_one], norm_num1,\n  exact hN1, refine lt_trans zero_lt_one hN4, exact hN6,\n  exact hN4, apply real.rpow_pos_of_pos hN6, split,\n  apply real.rpow_pos_of_pos hN6, split,\n  rw ← rpow_mul, nth_rewrite 0 ← (real.rpow_one N),\n  apply real.rpow_le_rpow_of_exponent_le (le_of_lt hN5),\n  rw [sub_mul, le_sub, mul_comm, mul_one_div], norm_num1, rw div_le_one,\n  refine le_trans _ hN1, norm_num1, exact hN7, apply le_of_lt hN6, split,\n  nth_rewrite 2 ← (real.rpow_one N), apply real.rpow_lt_rpow_of_exponent_lt hN5,\n  apply sub_lt_self, refine div_pos zero_lt_one hN7, split,\n  apply real.rpow_pos_of_pos hN6, split,\n  refine lt_of_lt_of_le _ hN2, apply rpow_pos_of_pos, norm_num1, split,\n  apply @le_trans _ _ 8 ((N : ℝ)^((1 : ℝ)/2)) _,\n  rw ← (real.rpow_le_rpow_iff _ _ zero_lt_two), rw ← rpow_mul, norm_num1,\n  rw rpow_one, norm_cast, exact hN3, apply le_of_lt hN6, norm_num1,\n  apply real.rpow_nonneg_of_nonneg (le_of_lt hN6), apply rpow_le_rpow_of_exponent_le,\n  apply le_of_lt hN5, rw le_sub, norm_num1, rw div_le_div_iff, norm_num1, rw one_mul,\n  exact hN1, exact hN7, exact zero_lt_two, split,\n  apply real.rpow_lt_rpow_of_exponent_lt hN5, apply sub_lt_sub_left,\n  apply div_lt_div_of_lt hN7, norm_num1, split,\n  apply lt_of_lt_of_le hT', refine (le_mul_iff_one_le_left _).mpr one_le_two,\n  apply real.rpow_pos_of_pos hN6,\n  let ε := (N : ℝ)^(-(5 : ℝ)/(log(log N))),\n  let ε' := (log N)^(-(1/100 : ℝ)),\n have hT1 :   3*ε'*log(log N) ≤ 2/((log N)^((1/500 : ℝ)))^2, {\n  rw [le_div_iff, ← real.rpow_two, ← rpow_mul, mul_comm, ← mul_assoc,\n    ← mul_assoc, mul_comm ((log N)^((1/500 : ℝ)*2)),\n    mul_assoc 3 ((log N)^((1/500 : ℝ)*2)), ← rpow_add], norm_num1,\n    rw [mul_comm, ← mul_assoc, ← le_div_iff, mul_comm, div_eq_mul_one_div, one_div,\n      ← real.rpow_neg, neg_neg, ← le_div_iff', div_eq_mul_one_div, mul_comm, ← mul_assoc],\n    norm_num1, exact hN10, exact zero_lt_three, exact le_of_lt hN8,\n    apply rpow_pos_of_pos hN8, exact hN8, exact le_of_lt hN8, apply sq_pos_of_pos,\n    apply rpow_pos_of_pos hN8,\n  },\n have hT2 :  2*ε'*log(log N) ≤ (log N)^(-(1/200 : ℝ)), {\n   rw [real.rpow_neg, ← one_div, le_div_iff, mul_comm, ← mul_assoc,\n   ← mul_assoc, mul_comm ((log N)^((1/200 : ℝ))),\n   mul_assoc 2 ((log N)^((1/200 : ℝ))), ← rpow_add], norm_num1,\n   rw [mul_comm, ← mul_assoc, ← le_div_iff, one_div,\n      ← real.rpow_neg, neg_neg, mul_comm], exact hN11, exact le_of_lt hN8,\n    apply rpow_pos_of_pos hN8, exact hN8, apply rpow_pos_of_pos hN8, exact le_of_lt hN8,\n  },\n have hT3 : ε ≤ ε', {\n   rw [← one_div_le_one_div, one_div, one_div, ← rpow_neg, neg_neg, ← rpow_neg,\n     ← neg_div, neg_neg, ← log_le_log, log_rpow, log_rpow],\n     nth_rewrite 1 mul_comm, rw [mul_div, mul_comm, ← div_eq_mul_one_div,\n    div_le_div_iff],\n    apply @le_trans _ _ _ ((2/3)*(log N)^((3/500 : ℝ))*(2/3)*(log N)^((3/500 : ℝ))) _,\n    rw mul_assoc, apply mul_le_mul, exact hN10, exact hN10, exact le_of_lt hN7,\n    apply mul_nonneg, norm_num1, apply rpow_nonneg_of_nonneg (le_of_lt hN8),\n    convert_to (((log N)^((3/500 : ℝ)))*((log N)^((3/500 : ℝ))))*((2/3)*(2/3)) ≤\n     (log N)*(5*100) using 0,\n     { ring_nf, },\n    apply mul_le_mul, rw ← rpow_add, nth_rewrite 1 ← real.rpow_one (log N),\n    apply real.rpow_le_rpow_of_exponent_le, apply le_trans _ hN2,\n    { norm_cast,\n      rw nat.succ_le_iff,\n      apply pow_pos,\n      norm_num1 },\n    norm_num1, exact hN8, norm_num1, norm_num1, exact le_of_lt hN8,\n    norm_num1, exact hN7, exact hN6, exact hN8, apply rpow_pos_of_pos hN8,\n    apply rpow_pos_of_pos hN6, exact le_of_lt hN6, exact le_of_lt hN8,\n    apply rpow_pos_of_pos hN8, apply rpow_pos_of_pos hN6,\n  },\n split, refine le_trans _ hT2, rw mul_le_mul_right hN7,\n refine (mul_le_mul_left zero_lt_two).mpr hT3, split,\n refine le_trans _ hT1, rw mul_le_mul_right hN7,\n refine (mul_le_mul_left zero_lt_three).mpr hT3, split,\n apply @le_trans _ _ _ ((1/(4*(log N)^((1/500 : ℝ)))+(1/(4*(log N)^((1/500 : ℝ)))))) _,\n apply add_le_add, rw [le_div_iff],\n convert_to (3 * 2 * 4) * (ε' * (log N)^((1/500 : ℝ))) *  log (log N) ≤ 1 using 0,\n   { ring_nf, }, norm_num1, rw ← rpow_add, norm_num1, rw [mul_comm, ← mul_assoc],\n   rw ←  le_div_iff, nth_rewrite 0 one_div,\n   rw [← real.rpow_neg, neg_neg, mul_comm],\n   exact hN9, exact le_of_lt hN8, apply rpow_pos_of_pos hN8, exact hN8,\n   refine mul_pos zero_lt_four _, apply rpow_pos_of_pos hN8,\n   rw [div_le_div_iff, one_mul, one_mul],\n   exact le_of_lt hT,  apply rpow_pos_of_pos hN6,\n   refine mul_pos zero_lt_four _, apply rpow_pos_of_pos hN8,\n   rw [← two_mul, mul_div, div_le_div_iff, mul_one, one_mul, ← mul_assoc],\n   norm_num1, refl, refine mul_pos zero_lt_four _, apply rpow_pos_of_pos hN8,\n  refine mul_pos zero_lt_two _, apply rpow_pos_of_pos hN8,\n  split,\n  apply le_of_lt, rw lt_div_iff, rw mul_comm, exact hTp, norm_num1,\n  split,\n  rw div_lt_iff,\n  have hTq : (log N)^((1/100 : ℝ)) < (N : ℝ)^(1 - (1 : ℝ)/(log(log N))),\n  { have : (0 : ℝ) < 100 := by norm_num1,\n   rw ← (real.rpow_lt_rpow_iff _ _ this),\n   rw ← rpow_mul, norm_num1, rw rpow_one,\n   apply lt_of_le_of_lt (real.log_le_sub_one_of_pos hN6),\n   apply lt_of_lt_of_le (sub_one_lt (N : ℝ)), rw ← rpow_mul, nth_rewrite 0 ← (real.rpow_one N),\n   apply rpow_le_rpow_of_exponent_le (le_of_lt hN5),\n   rw [sub_mul, le_sub, mul_comm, mul_one_div, div_le_iff, mul_comm,← div_le_iff],\n   apply le_trans _ hN1, norm_num1, norm_num1, exact hN7, exact le_of_lt hN6,\n   exact le_of_lt hN8, apply real.rpow_nonneg_of_nonneg (le_of_lt hN8),\n   apply real.rpow_nonneg_of_nonneg (le_of_lt hN6), },\n   rw [mul_assoc, ← div_lt_iff'], nth_rewrite 0 one_div,\n   rw [← real.rpow_neg_one, ← rpow_mul], norm_num1, apply lt_trans hTq,\n   nth_rewrite 0 ← one_mul ((N : ℝ)^(1 - (1 : ℝ)/(log(log N)))),\n   refine (mul_lt_mul_right _).mpr _, apply rpow_pos_of_pos hN6, exact hN4,\n   exact le_of_lt hN8, apply rpow_pos_of_pos hN8, apply rpow_pos_of_pos hN6,\n   refine ⟨hT1, hT2, hotheraux hT3⟩,\nend\n\n-- Proposition 6.6\ntheorem technical_prop :\n  ∀ᶠ (N : ℕ) in at_top, ∀ (A ⊆ finset.range (N+1)) (y z : ℝ),\n  (1 ≤ y) → (4*y + 4 ≤ z) → (z ≤ (log N)^((1/500 : ℝ))) → (0 ∉ A)\n  → (∀ n ∈ A, ( (N : ℝ)^(1 - (1 : ℝ)/(log(log N))) ≤ n ))\n  → 2 / y + (log N)^(-(1/200 : ℝ)) ≤ rec_sum A\n  → (∀ n ∈ A, ∃ d₁ d₂ : ℕ, (d₁ ∣ n) ∧ (d₂ ∣ n) ∧ (y ≤ d₁) ∧ (4*d₁ ≤ d₂) ∧ ((d₂ : ℝ) ≤ z) )\n  → (∀ n ∈ A, is_smooth ((N : ℝ)^(1 - (8 : ℝ)/(log(log N)))) n)\n  → arith_regular N A\n  → ∃ S ⊆ A, ∃ d : ℕ, (y ≤ d) ∧ ((d : ℝ) ≤ z) ∧\n    rec_sum S = 1/d\n  :=\nbegin\n  obtain ⟨c,hc,circle_method⟩ := circle_method_prop2,\n  obtain hlargeN := large_enough_N,\n  specialize hlargeN c hc,\n  filter_upwards [main_tech_lemma, force_good_properties,\n     force_good_properties2, circle_method,hlargeN],\n  clear circle_method,\n  intros N htechlemma hforce1 hforce2 hcircle hlargeN,\n  let M := (N : ℝ)^(1 - (1 : ℝ)/(log(log N))),\n  let ε := (N : ℝ)^(-(5 : ℝ)/(log(log N))),\n  let K := (N : ℝ)^(1 - (3 : ℝ)/(log(log N))),\n  let η := (1 : ℝ)/(2*(log N)^((1 : ℝ)/100)),\n  let L := M / (2 * log N ^ ((1 : ℝ)/100)),\n  let T := M / log N,\n  rcases hlargeN with ⟨hMε, hε, hM3, hM2, hM1, hlogN3, heK, hKM, hlogN4,\n     hlogN5, hlogN6, hlargeNnew, hlargenew2, hε'M, hlarge3, hlarge4, hεε'M,\n     hUhelper, hUhelper2, hUhelper3, hlarge7⟩,\n  have hNMcast : (N:ℝ) ≤ M^2, { rw ← rpow_nat_cast, exact_mod_cast hM3, },\n  have hM2aux : M ≤ N, { apply le_of_lt hM2, },\n  intros A hA y z h1y hyz hzN h0A hA2 hrec hdiv hsmooth hreg,\n  have htemp6 : (N : ℝ)^(1 - (1 : ℝ)/(log(log N)))*(N : ℝ)^(-(2 : ℝ)/(log(log N))) = K, {\n    rw ← rpow_add,\n    have : 1 - (1 : ℝ)/(log(log N))+(-(2 : ℝ)/(log(log N))) = 1 - (3 : ℝ)/(log(log N)),\n     { rw [sub_add_eq_add_sub, ← add_sub, div_sub_div_same, sub_eq_add_neg,\n           sub_eq_add_neg, ← neg_div], norm_num1, refl,\n     },\n     rw this, apply lt_of_lt_of_le hM1 hM2aux, },\n  have hzT : 0 < T, { apply div_pos hM1 hlogN3, },\n  have hzL : 0 < L, {\n    apply div_pos hM1, apply mul_pos, exact zero_lt_two,\n    apply rpow_pos_of_pos hlogN3, },\n  have hyzaux : y ≤ z, { apply @le_trans _ _ y (4*y) z, apply le_mul_of_one_le_left,\n    apply le_trans zero_le_one h1y, apply le_of_lt one_lt_four,\n    apply le_trans _ hyz, apply le_add_of_nonneg_right,\n    refine le_trans zero_le_one _, apply le_of_lt one_lt_four,},\n  have hz_pos : 0 < z, {\n    apply @lt_of_lt_of_le _ _ 0 1 z, exact zero_lt_one, apply le_trans h1y hyzaux, },\n  have hwM : (z/4) < 2*M, {\n    apply @lt_of_lt_of_le _ _ (z/4) z (2*M), rw div_lt_iff,\n    apply lt_mul_of_one_lt_right hz_pos one_lt_four,\n    exact zero_lt_four, apply le_trans hzN, apply le_of_lt hlogN4,\n  },\n  have h8z : 8 ≤ z, { apply le_trans _ hyz, apply add_le_add_right,\n    apply le_mul_of_one_le_right (le_of_lt zero_lt_four) h1y, },\n  have h2z : 2 ≤ z/4, { rw le_div_iff, norm_num1,\n     exact h8z, exact zero_lt_four,  },\n  have hyz' : ⌈y⌉₊ ≤ ⌊z/4⌋₊, {\n    rw nat.ceil_le, apply @le_trans _ _ y (z/4 - 1) _,\n    apply le_sub_right_of_add_le,\n    rw [le_div_iff, add_mul, one_mul, mul_comm],\n    exact hyz, exact zero_lt_four, rw sub_le_iff_le_add,\n    apply @le_trans _ _ (z/4) (⌊z/4⌋₊.succ) _,\n    apply le_of_lt, apply nat.lt_succ_floor, rw nat.succ_eq_add_one,\n    push_cast,\n   },\n  let ε' := (log N)^(-(1/100 : ℝ)),\n  have h0ε' : 0 < ε' := by apply rpow_pos_of_pos hlogN3,\n  have hε'w2 : 3*ε'*log(log N) ≤ 2/(z^2), { apply le_trans hlarge3, rw div_le_div_left,\n    apply sq_le_sq',  apply @le_trans _ _ _ 0 z, rw neg_nonpos, apply rpow_nonneg_of_nonneg,\n    apply le_of_lt hlogN3, apply le_of_lt hz_pos, exact hzN, exact zero_lt_two,\n    apply sq_pos_of_pos, apply rpow_pos_of_pos hlogN3, apply sq_pos_of_pos hz_pos, },\n  have hε'z : 3*ε'*log(log N) ≤ 2/((z/4)^2), {\n    have hεzaux : (z/4)^2 ≤ z^2, {\n      apply sq_le_sq', apply @le_trans _ _ _ 0 (z/4),\n      rw left.neg_nonpos_iff, apply le_of_lt hz_pos,\n      apply le_of_lt (div_pos hz_pos zero_lt_four),\n      rw div_le_iff, rw le_mul_iff_one_le_right,\n      apply le_of_lt one_lt_four, exact hz_pos, exact zero_lt_four,\n    },\n    have hεzaux2 : 0 < (log N)^((1/500 : ℝ)), {\n      apply rpow_pos_of_pos hlogN3, },\n    apply le_trans hε'w2, rw div_le_div_iff, rw mul_le_mul_left,\n    apply le_trans hεzaux, apply sq_le_sq',\n    apply @le_trans _ _ _ 0 z, rw left.neg_nonpos_iff,\n    apply le_of_lt hz_pos, apply le_of_lt hz_pos, refl, exact zero_lt_two,\n    apply sq_pos_of_pos hz_pos, apply sq_pos_of_pos,\n    apply div_pos hz_pos zero_lt_four,\n   },\n  have hrec' : 2/y + 2*ε'*log(log N) ≤ rec_sum A, {\n    apply le_trans _ hrec, apply add_le_add, refl, exact hlarge4, },\n  have hsmooth' : ∀ q ∈ ppowers_in_set A, (q : ℝ) ≤ ε'*M, {\n    intros q hq, rw [ppowers_in_set,finset.mem_bUnion] at hq,\n    rcases hq with ⟨a,ha,hq⟩, rw finset.mem_filter at hq, simp_rw is_smooth at hsmooth,\n    specialize hsmooth a ha q hq.2.1, apply le_trans _ hεε'M,\n    apply hsmooth (nat.dvd_of_mem_divisors hq.1),\n      },\n  have hdiv' : (∀ n ∈ A, ∃ d : ℕ, (y ≤ d) ∧ ((d : ℝ) ≤ (z/4)) ∧ d ∣ n),\n   { intros n hn, specialize hdiv n hn, rcases hdiv with ⟨d_1,d_2,hdiv⟩,\n     refine ⟨d_1,hdiv.2.2.1,_,hdiv.1⟩, rw le_div_iff',\n     apply le_trans _ hdiv.2.2.2.2, exact_mod_cast hdiv.2.2.2.1, exact zero_lt_four, },\n  have htech2 := htechlemma,\n  specialize htechlemma M ε' y (z/4) A hA hM1 hM2 h0ε' hwM hε'M h1y h2z hyz' hε'z\n      hA2 hrec' hsmooth' hdiv',\n  rcases htechlemma with ⟨A',hA',d,htech⟩,\n  have hzd : d ≠ 0, {\n    apply ne_of_gt, apply lt_of_lt_of_le zero_lt_one,\n    exact_mod_cast le_trans h1y htech.2.1, exact nat.nontrivial,\n   },\n  by_cases hgoodsubset : (∃ B ⊆ A', ((rec_sum A') ≤ 3*rec_sum B) ∧\n    ((ppower_rec_sum B : ℝ) ≤ (2/3)* log(log N))),\n  -- The first case\n  clear hforce1,\n  rcases hgoodsubset with ⟨B, hB, hrecB, hppB⟩,\n  have hB2 : B ⊆ finset.range(N+1), { apply subset_trans (subset_trans hB hA') hA, },\n  have hzM : z < 2*M, {\n     apply lt_of_le_of_lt hzN hlogN4, },\n  have h14d : 1 ≤ ((4 : ℝ)*d), {\n    norm_cast, rw nat.one_le_iff_ne_zero, apply mul_ne_zero,\n    refine ne_of_gt zero_lt_four, exact hzd, },\n  have h2z' : 2 ≤ z, { apply le_trans _ h8z, norm_num1, },\n  have hdz : ⌈(4 : ℝ)*d⌉₊ ≤ ⌊z⌋₊, {\n    rw nat.ceil_le, norm_cast, rw nat.le_floor_iff',\n    have : (4 : ℝ)*d ≤ z, {\n      rw ← le_div_iff', exact htech.2.2.1, exact zero_lt_four,},\n    exact_mod_cast this, refine ne_of_gt _,\n    have : (0 : ℝ) < 4*d , { apply lt_of_lt_of_le zero_lt_one h14d, },\n    exact_mod_cast this,\n   },\n  have hB3 : ∀ (n:ℕ), n ∈ B → M ≤ n, { intros n hn,\n  specialize hA2 n, apply hA2 (hA' (hB hn)), },\n  have hrecB : 2/((4 : ℝ)*d) + 2*ε'*log(log N) ≤ rec_sum B, {\n    have : (3 : ℝ)*(2/(4*d)) = (3/2)/d, {\n        rw [div_mul_eq_div_mul_one_div, ← mul_assoc],\n        rw div_eq_mul_one_div ((3 : ℝ)/2) d, norm_num1, refl,\n     },\n    refine (mul_le_mul_left zero_lt_three).mp _,\n    apply @le_trans _ _ _ (rec_sum A' : ℝ) (3*rec_sum B),\n    apply le_trans _ htech.2.2.2.2.1, apply le_sub_right_of_add_le,\n    rw mul_add, rw add_assoc, apply add_le_of_le_sub_left,\n    rw this, rw div_sub_div_same,\n    apply @le_trans _ _ _ ((1 : ℝ)/(2*z)) ((2-3/2)/d),\n    apply @le_trans _ _ _ (1/(2*(log N)^((1/500 : ℝ)))) ((1 : ℝ)/(2*z)),\n    exact hlargeNnew, rw one_div_le_one_div, apply mul_le_mul_of_nonneg_left hzN,\n    exact zero_le_two, refine mul_pos zero_lt_two _,\n    refine lt_of_lt_of_le hz_pos hzN, refine mul_pos zero_lt_two hz_pos,\n    rw [div_le_div_iff,one_mul], apply le_trans htech.2.2.1,\n    rw div_eq_inv_mul, rw ← mul_assoc, rw mul_le_mul_right, norm_num1, exact hz_pos,\n    refine mul_pos zero_lt_two hz_pos, refine lt_of_lt_of_le zero_lt_one _,\n    refine le_trans h1y htech.2.1, exact_mod_cast hrecB,\n   },\n  have hsmoothB : ∀ q ∈ ppowers_in_set B, (q : ℝ) ≤ ε'*M, {\n    intros q hq, specialize hsmooth' q,\n    apply hsmooth' ((ppowers_in_set_subset (subset_trans hB hA')) hq),\n  },\n  have hdivB : (∀ (n : ℕ), n ∈ B → (∃ (d_1 : ℕ), (4 : ℝ)*d ≤ d_1 ∧ (d_1 : ℝ) ≤ z ∧ d_1 ∣ n)),\n    {intros n hn, specialize hdiv n (hA' (hB hn)),\n     rcases hdiv with ⟨d_1,d_2,hdiv⟩,\n     have : d ≤ d_1, {\n       obtain htech' := htech.2.2.2.2.2.2.2,\n       specialize htech' n (hB hn) d_1 hdiv.1,\n       apply le_of_not_gt, intro hfoo, specialize htech' hfoo,\n       apply (not_le.mpr htech') hdiv.2.2.1,\n      },\n     refine ⟨d_2,_,hdiv.2.2.2.2,hdiv.2.1⟩,\n     norm_cast, apply le_trans _ hdiv.2.2.2.1,\n     exact (mul_le_mul_left zero_lt_four).mpr this,\n     },\n  specialize htech2 M ε' ((4 : ℝ)*d) z B hB2 hM1 hM2 h0ε' hzM hε'M\n      h14d h2z' hdz hε'w2 hB3 hrecB hsmoothB hdivB,\n  rcases htech2 with ⟨B',hB',d',htech2⟩,\n  have hB'2 : B' ⊆ finset.range(N+1), { exact subset_trans hB' hB2, },\n  have hB'reg : arith_regular N B' := hreg.subset (subset_trans hB' (subset_trans hB hA')),\n  have hB'3 : (∀ q ∈ ppowers_in_set B',\n    ((log N)^(-(1/100 : ℝ)) ≤ rec_sum_local B' q )), {\n      obtain htech2' := htech2.2.2.2.2.2.1,\n      intros q hq, apply le_of_lt, specialize htech2' q hq,\n      exact htech2',\n     },\n  have hB'4 : (ppower_rec_sum B' : ℝ) ≤ (2/3)* log(log N), {\n    apply le_trans _ hppB, norm_cast, apply ppower_rec_sum_mono hB',\n   },\n  have hB'5 : (∀ (n : ℕ), n ∈ B' → M ≤ n), { intros n hn,\n     specialize hA2 n, apply hA2 (hA' (hB (hB' hn))), },\n  have hB'n0 : 0 ∉ B', { intro hz, exact h0A (hA' (hB (hB' hz))), },\n  specialize hforce2 M B' hB'2 hM1 (le_of_lt hM2) hNMcast hB'n0 hB'5 hB'reg hB'3 hB'4,\n  have hzd' : d' ≠ 0, {\n    apply ne_of_gt, refine lt_of_lt_of_le zero_lt_one _,\n    exact_mod_cast le_trans h14d htech2.2.1,\n   },\n  have hd'M : (d' : ℝ) ≤ M / 192, {\n    apply le_trans htech2.2.2.1, apply le_trans hzN hlargenew2, },\n\n  have hB'6 : (∀ (n : ℕ), n ∈ B' → n ≤ N), {\n    intros n hn, rw [← nat.lt_add_one_iff, ← finset.mem_range],\n    exact hB'2 hn,\n   },\n  have hdB' : d' ∣ B'.lcm id, {\n    rcases htech2.2.2.2.2.2.2.1 with ⟨n,hn,hnew⟩,\n    apply dvd_trans hnew, apply dvd_lcm hn,\n   },\n  let U' := min (L * K ^ 2 / (16 * N ^ 2 * log N ^ 2)) (min (c * M / d') (T * K ^ 2 / (N ^ 2 * log N))),\n  have hU'M : (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ U', {\n    rw le_min_iff, split, exact hUhelper, rw le_min_iff, split,\n    apply @le_trans _ _ _ (c*M/z) _,\n    apply @le_trans _ _ _ (c*M/(log N)^((1/500 : ℝ))) _,\n    exact hUhelper3, rw div_le_div_left, exact hzN, apply mul_pos hc hM1,\n    apply rpow_pos_of_pos hlogN3, exact hz_pos, rw div_le_div_left,\n    exact htech2.2.2.1, apply mul_pos hc hM1, exact hz_pos, norm_num,\n    rw pos_iff_ne_zero, exact hzd', exact hUhelper2,\n     },\n  have hppB' : (∀ (q : ℕ), q ∈ ppowers_in_set B' → (q : ℝ) ≤ U'), {\n    intros q hq, rw [ppowers_in_set,finset.mem_bUnion] at hq,\n    rcases hq with ⟨a,ha,hq⟩, rw finset.mem_filter at hq, simp_rw is_smooth at hsmooth,\n    specialize hsmooth a (hA' (hB (hB' ha))) q hq.2.1, apply le_trans _ hU'M,\n    apply hsmooth (nat.dvd_of_mem_divisors hq.1),\n   },\n  have hgoodB' : good_condition B' K T L, { rw htemp6 at hforce2, exact hforce2,  },\n  specialize @hcircle K L M T d' B' hzT hzL heK hKM hM2aux hzd'\n    hd'M hB'5 hB'6 htech2.2.2.2.1 htech2.2.2.2.2.1 hdB' hppB' hgoodB',\n  rcases hcircle with ⟨S,hS,hcirc⟩,\n  use S, split,\n  exact subset_trans hS (subset_trans hB' (subset_trans hB hA')),\n  refine ⟨d',_,htech2.2.2.1,hcirc⟩, apply le_trans htech.2.1 _,\n  apply le_trans _ htech2.2.1, apply le_mul_of_one_le_left,\n  apply nat.cast_nonneg, norm_num,\n  -- The second case\n  clear hforce2 htech2,\n  have hrangeA' : A' ⊆ finset.range(N+1), { apply subset_trans hA' hA, },\n  have hregA' : arith_regular N A' := hreg.subset hA',\n  have hNA' : (log N)^(-(1/101 : ℝ)) ≤ rec_sum A', {\n    apply le_trans _ htech.2.2.2.2.1,\n    apply @le_trans _ _ _ ((2 : ℝ)/((log N)^(1/500 : ℝ)/4) - 1/M) _,\n    exact hlarge7, apply sub_le_sub_right, rw div_le_div_left,\n    apply le_trans htech.2.2.1, rw div_le_div_right, exact hzN,\n    exact zero_lt_four, exact zero_lt_two,\n    apply div_pos, apply rpow_pos_of_pos hlogN3, exact zero_lt_four,\n    norm_cast, rw pos_iff_ne_zero, exact hzd,\n   },\n  have hppA' : (∀ q ∈ ppowers_in_set A',\n    ((log N)^(-(1/100 : ℝ)) ≤ rec_sum_local A' q )), {\n      obtain htech' := htech.2.2.2.2.2.1,\n      intros q hq, apply le_of_lt, specialize htech' q hq,\n      exact htech',\n     },\n\n  have hA'5 : (∀ (n : ℕ), n ∈ A' → M ≤ n), { intros n hn,\n   specialize hA2 n, apply hA2 (hA' hn), },\n  have hA'n0 : 0 ∉ A', { intro hz, exact h0A (hA' hz), },\n  specialize hforce1 M A' hrangeA' hM1 (le_of_lt hM2) hNMcast hA'n0 hA'5 hregA' hNA' hppA',\n  cases hforce1 with htemp1 htemp2,\n  exfalso, apply hgoodsubset htemp1,\n  have hgoodA' : good_condition A' K T L, { rw htemp6 at htemp2, exact htemp2, },\n  have hdM : (d : ℝ) ≤ M / 192, {\n    apply le_trans htech.2.2.1, apply le_trans _ (le_trans hzN hlargenew2),\n    apply div_le_self, apply le_of_lt hz_pos, apply le_of_lt one_lt_four,\n   },\n  have hA'6 : (∀ (n : ℕ), n ∈ A' → n ≤ N), { intros n hn,\n    rw [← nat.lt_add_one_iff, ← finset.mem_range], exact hrangeA' hn, },\n  have hdA' : d ∣ A'.lcm id, {\n    rcases htech.2.2.2.2.2.2.1 with ⟨n,hn,hnew⟩,\n    apply dvd_trans hnew, apply dvd_lcm hn,\n   },\n  let U := min (L * K ^ 2 / (16 * N ^ 2 * log N ^ 2)) (min (c * M / d) (T * K ^ 2 / (N ^ 2 * log N))),\n  have hUM : (N : ℝ)^(1 - (8 : ℝ)/(log(log N))) ≤ U, {\n    rw le_min_iff, split, exact hUhelper, rw le_min_iff, split,\n    apply @le_trans _ _ _ (c*M/z) _,\n    apply @le_trans _ _ _ (c*M/(log N)^((1/500 : ℝ))) _,\n    exact hUhelper3, rw div_le_div_left, exact hzN, apply mul_pos hc hM1,\n    apply rpow_pos_of_pos hlogN3, exact hz_pos, rw div_le_div_left,\n    apply @le_trans _ _ _ (z/4) z, exact htech.2.2.1, rw div_le_iff,\n    rw le_mul_iff_one_le_right, apply le_of_lt one_lt_four, exact hz_pos,\n    exact zero_lt_four,\n    apply mul_pos hc hM1, exact hz_pos, norm_num,\n    rw pos_iff_ne_zero, exact hzd, exact hUhelper2,\n   },\n  have hppA' : (∀ (q : ℕ), q ∈ ppowers_in_set A' → (q : ℝ) ≤ U), {\n    intros q hq, rw [ppowers_in_set,finset.mem_bUnion] at hq,\n    rcases hq with ⟨a,ha,hq⟩, rw finset.mem_filter at hq, simp_rw is_smooth at hsmooth,\n    specialize hsmooth a (hA' ha) q hq.2.1, apply le_trans _ hUM,\n    apply hsmooth (nat.dvd_of_mem_divisors hq.1),\n   },\n  specialize @hcircle K L M T d A' hzT hzL heK hKM hM2aux hzd\n    hdM hA'5 hA'6 htech.2.2.2.1 htech.2.2.2.2.1 hdA' hppA' hgoodA',\n  rcases hcircle with ⟨S,hS,hcirc⟩,\n  use S, split, exact subset_trans hS hA',\n  refine ⟨d,htech.2.1,_,hcirc⟩,\n  apply le_trans htech.2.2.1, apply div_le_self,\n  apply @le_trans _ _ 0 1 z zero_le_one, apply le_trans h1y hyzaux,\n  norm_num,\nend\n\nlemma prop_one_specialise :\n  ∀ᶠ N : ℕ in at_top, ∀ A ⊆ finset.range (N + 1),\n    (∀ n ∈ A, (N : ℝ) ^ (1 - (1 : ℝ) / log (log N)) ≤ n) → (0 ∉ A)\n  → log N ^ (1 / 500 : ℝ) ≤ (rec_sum A : ℝ)\n  → (∀ n ∈ A, ∃ d₂ : ℕ, d₂ ∣ n ∧ 4 ≤ d₂ ∧ (d₂ : ℝ) ≤ log N ^ (1 / 500 : ℝ))\n  → (∀ n ∈ A, is_smooth ((N : ℝ) ^ (1 - (8 : ℝ) / log (log N))) n)\n  → arith_regular N A\n  → ∃ S ⊆ A, ∃ d : ℕ, 1 ≤ d ∧ (d : ℝ) ≤ log N ^ (1 / 500 : ℝ) ∧ rec_sum S = 1 / d :=\nbegin\n  have hf : tendsto (λ (x : ℕ), log x ^ (1 / 500 : ℝ)) at_top at_top :=\n    tendsto_coe_log_pow_at_top _ (by norm_num1),\n  have hf' : tendsto (λ (x : ℕ), log x ^ (1 / 200 : ℝ)) at_top at_top :=\n    tendsto_coe_log_pow_at_top _ (by norm_num1),\n  filter_upwards [technical_prop, hf (eventually_ge_at_top 8), hf' (eventually_ge_at_top 1),\n    (tendsto_log_at_top.comp tendsto_coe_nat_at_top_at_top) (eventually_ge_at_top 0)],\n  intros N hN hN' hN'' hN''' A A_upper_bound A_lower_bound h0A hA₁ hA₂ hA₃ hA₄,\n  simp only [set.mem_set_of_eq, set.preimage_set_of_eq] at hN' hN'' hN''',\n  exact_mod_cast hN A A_upper_bound 1 _ le_rfl _ le_rfl h0A A_lower_bound _ _ hA₃ hA₄,\n  { exact le_trans (by norm_num1) hN' },\n  { apply (le_trans _ hN').trans hA₁,\n    rw [←le_sub_iff_add_le', rpow_neg],\n    { norm_num1, apply @le_trans _ _ _ (1 : ℝ) 6,\n      exact inv_le_one hN'', norm_num, },\n    { exact hN''' } },\n  intros n hn,\n  obtain ⟨d₂, hd₂, hd₂', hd₂''⟩ := hA₂ n hn,\n  exact ⟨1, d₂, one_dvd _, hd₂, by simp, by simpa, hd₂''⟩,\nend\n\n-- Corollary 1\ntheorem corollary_one :\n  ∀ᶠ (N : ℕ) in at_top, ∀ A ⊆ finset.range (N + 1),\n  (∀ n ∈ A, (N : ℝ) ^ (1 - (1 : ℝ) / log (log N)) ≤ n)\n  → 2 * log N ^ (1 / 500 : ℝ) ≤ rec_sum A\n  → (∀ n ∈ A, ∃ p : ℕ, p ∣ n ∧ 4 ≤ p ∧ (p : ℝ) ≤ log N ^ (1/500 : ℝ))\n  → (∀ n ∈ A, is_smooth ((N : ℝ) ^ (1 - (8 : ℝ) / log (log N))) n)\n  → arith_regular N A\n  → ∃ S ⊆ A, rec_sum S = 1 :=\nbegin\n  filter_upwards [prop_one_specialise, eventually_ge_at_top 1],\n  intros N p1 hN₁ A A_upper_bound A_lower_bound hA₁ hA₂ hA₃ hA₄,\n  -- `good_set` expresses the families of subsets that we like\n  -- instead of saying we have S_1, ..., S_k, I'll say we have k-many subsets (+ same conditions)\n  let good_set : finset (finset ℕ) → Prop :=\n    λ S, (∀ s ∈ S, s ⊆ A) ∧ (S : set (finset ℕ)).pairwise_disjoint id ∧\n      ∀ s, ∃ (d : ℕ), s ∈ S → 1 ≤ d ∧ (d : ℝ) ≤ (log N)^(1/500 : ℝ) ∧ rec_sum s = 1 / d,\n    -- the last condition involving `d` is chosen weirdly so that `choose` later gives a more\n    -- convenient function\n  let P : ℕ → Prop := λ k, ∃ S : finset (finset ℕ), S.card = k ∧ good_set S,\n  let k : ℕ := nat.find_greatest P (A.card + 1), -- A.card is a trivial upper bound\n  have P0 : P 0 := ⟨∅, by simp [good_set]⟩, -- we clearly have that 0 satisfies p by using ∅\n  have Pk : P k := nat.find_greatest_spec (nat.zero_le _) P0,\n  obtain ⟨S, hk, hS₁, hS₂, hS₃⟩ := Pk,\n  choose d' hd'₁ hd'₂ hd'₃ using hS₃,\n  let t : ℕ → ℕ := λ d, (S.filter (λ s, d' s = d)).card,\n  -- If we do have an appropriate d, take it\n  by_cases h : ∃ d : ℕ, 0 < d ∧ d ≤ t d,\n  { obtain ⟨d, d_pos, ht⟩ := h,\n    -- there are ≥ d things with R(s) = 1/d, pick a subset so we have exactly d\n    obtain ⟨T', hT', hd₂⟩ := finset.exists_smaller_set _ _ ht,\n    have hT'S := hT'.trans (finset.filter_subset _ _),\n    refine ⟨T'.bUnion id, _, _⟩,\n    { refine (finset.bUnion_subset_bUnion_of_subset_left _ hT'S).trans _,\n      rwa finset.bUnion_subset },\n    rw [rec_sum_bUnion_disjoint (hS₂.subset hT'S), finset.sum_congr rfl, finset.sum_const, hd₂,\n      nsmul_eq_mul, mul_div_cancel'],\n    { rw nat.cast_ne_zero, exact d_pos.ne' },\n    intros i hi,\n    rw [hd'₃ _ (hT'S hi), (finset.mem_filter.1 (hT' hi)).2] },\n  push_neg at h,\n  exfalso,\n  -- otherwise make A' as in the paper\n  let A' := A \\ S.bUnion id,\n  have hS : (∑ s in S, rec_sum s : ℝ) ≤ (log N)^(1/500 : ℝ),\n  { transitivity (∑ d in finset.Icc 1 ⌊(log N)^(1/500 : ℝ)⌋₊, t d / d : ℝ),\n    { have : ∀ s ∈ S, d' s ∈ finset.Icc 1 ⌊(log N)^(1/500 : ℝ)⌋₊,\n      { intros s hs,\n        simp only [finset.mem_Icc, hd'₁ s hs, nat.le_floor (hd'₂ s hs), and_self] },\n      rw ←finset.sum_fiberwise_of_maps_to this,\n      apply finset.sum_le_sum,\n      intros d hd,\n      rw [div_eq_mul_one_div, ←nsmul_eq_mul],\n      apply finset.sum_le_card_nsmul,\n      intros s hs,\n      simp only [finset.mem_filter] at hs,\n      rw [hd'₃ _ hs.1, hs.2, rat.cast_div, rat.cast_one, rat.cast_coe_nat] },\n    refine (finset.sum_le_card_nsmul _ _ 1 _).trans _,\n    { simp only [one_div, and_imp, finset.mem_Icc],\n      rintro d hd -,\n      exact div_le_one_of_le (nat.cast_le.2 ((h d hd).le)) (nat.cast_nonneg _) },\n    { simp only [nat.add_succ_sub_one, add_zero, nat.card_Icc, nat.smul_one_eq_coe],\n      exact nat.floor_le (rpow_nonneg_of_nonneg (log_nonneg (nat.one_le_cast.2 hN₁)) _) } },\n  have hAS : disjoint A' (S.bUnion id) := finset.sdiff_disjoint,\n  have RA'_ineq : (log N)^(1/500 : ℝ) ≤ rec_sum A',\n  { have : rec_sum A = rec_sum A' + rec_sum (S.bUnion id),\n    { rw [←rec_sum_disjoint hAS, finset.sdiff_union_of_subset],\n      rwa finset.bUnion_subset },\n    rw [this] at hA₁,\n    simp only [rat.cast_add] at hA₁,\n    rw ←sub_le_iff_le_add at hA₁,\n    apply le_trans _ hA₁,\n    rw [rec_sum_bUnion_disjoint hS₂, rat.cast_sum],\n    linarith [hS] },\n  have hA' : A' ⊆ A := finset.sdiff_subset _ _,\n  have h0A' : 0 ∉ A', {\n    intro hz, specialize A_lower_bound 0 (hA' hz), rw ← not_lt at A_lower_bound,\n    apply A_lower_bound, norm_cast, apply rpow_pos_of_pos, norm_cast,\n    exact lt_of_lt_of_le zero_lt_one hN₁,\n  },\n  obtain ⟨S', hS', d, hd, hd', hS'₂⟩ :=\n    p1 A' (hA'.trans A_upper_bound) (λ n hn, A_lower_bound n (hA' hn)) h0A'\n      RA'_ineq (λ n hn, hA₂ n (hA' hn)) (λ n hn, hA₃ n (hA' hn)) (hA₄.subset hA'),\n  have hS'' : ∀ s ∈ S, disjoint S' s :=\n    λ s hs, disjoint.mono hS' (finset.subset_bUnion_of_mem id hs) hAS,\n  have hS''' : S' ∉ S,\n  { intro t,\n    exact (nonempty_of_rec_sum_recip hd hS'₂).ne_empty (disjoint_self.1 (hS'' _ t)) },\n  have : P (k+1),\n  { refine ⟨insert S' S, _, _⟩,\n    { rw [finset.card_insert_of_not_mem hS''', hk] },\n    refine ⟨_, _, _⟩,\n    { simpa [hS'.trans hA'] using hS₁ },\n    { simpa [set.pairwise_disjoint_insert, hS₂] using λ s hs _, hS'' _ hs },\n    intros s,\n    rcases eq_or_ne s S' with rfl | hs,\n    { exact ⟨d, λ _, ⟨hd, hd', hS'₂⟩⟩ },\n    refine ⟨d' s, λ i, _⟩,\n    have : s ∈ S := finset.mem_of_mem_insert_of_ne i hs,\n    exact ⟨hd'₁ _ this, hd'₂ _ this, hd'₃ _ this⟩ },\n  have hk_bound : k + 1 ≤ A.card + 1,\n  { rw [←hk, add_le_add_iff_right],\n    apply le_trans _ (finset.card_le_of_subset (finset.bUnion_subset.2 hS₁)),\n    apply finset.card_le_card_bUnion hS₂,\n    intros s hs,\n    exact nonempty_of_rec_sum_recip (hd'₁ s hs) (hd'₃ s hs) },\n  have : k + 1 ≤ k := nat.le_find_greatest hk_bound this,\n  simpa using this,\nend\n", "meta": {"author": "b-mehta", "repo": "unit-fractions", "sha": "b60c39a3ebd40a84104a4064840b10fc2af15fb8", "save_path": "github-repos/lean/b-mehta-unit-fractions", "path": "github-repos/lean/b-mehta-unit-fractions/unit-fractions-b60c39a3ebd40a84104a4064840b10fc2af15fb8/src/main_results.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125793176222, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.48982704164956814}}
{"text": "import data.real.basic\nimport .affnK\n/-\nAmanda:\n\nGo to line 730ish and find the proof I just copied and pasted in. It is an example basis proof. \nDig into the details and you'll be able to adapt this, or at least some of it.\n-/\nimport linear_algebra.basis\n-- Testing vec_n_basis\n\n/-\nprotected noncomputable def span : basis ι R (span R (range v)) :=\nbasis.mk (linear_independent_span hli) $\nbegin\n  rw eq_top_iff,\n  intros x _,\n  have h₁ : subtype.val '' set.range (λ i, subtype.mk (v i) _) = range v,\n  { rw ← set.range_comp },\n  have h₂ : map (submodule.subtype _) (span R (set.range (λ i, subtype.mk (v i) _)))\n    = span R (range v),\n  { rw [← span_image, submodule.subtype_eq_val, h₁] },\n  have h₃ : (x : M) ∈ map (submodule.subtype _) (span R (set.range (λ i, subtype.mk (v i) _))),\n  { rw h₂, apply subtype.mem x },\n  rcases mem_map.1 h₃ with ⟨y, hy₁, hy₂⟩,\n  have h_x_eq_y : x = y,\n  { rw [subtype.ext_iff, ← hy₂], simp },\n  rwa h_x_eq_y\nend\n-/\n\n\ndef vec_1_basis := vec_n_basis.mk (λ a : fin 1, (λ b : fin 1, vec.mk (1 : ℚ))) begin\n  ext,\n  split,\n  {\n    intro h,\n    dsimp only [has_bot.bot, has_zero.zero, add_zero_class.zero, add_monoid.zero, add_comm_monoid.zero],\n    suffices h' : x = {support := ∅, to_fun := λ (_x : fin 1), semiring.zero, mem_support_to_fun := _},\n    exact h',\n    dsimp only [linear_map.ker, submodule.comap, set.preimage] at h,\n    have h₀ : ⇑(finsupp.total (fin 1) (vec_n ℚ 1) ℚ (λ (a b : fin 1), {coord := 1})) x ∈ ↑⊥ := by exact h,\n    dsimp only [has_bot.bot, has_zero.zero, add_zero_class.zero, add_monoid.zero, add_comm_monoid.zero] at h₀,\n    dsimp only [vec_zero] at h₀,\n    have h₁ : ⇑(finsupp.total (fin 1) (vec_n ℚ 1) ℚ (λ (a b : fin 1), {coord := 1})) x = λ (_x : fin 1), mk_vec ℚ 0 := by exact h₀,\n    dsimp only [finsupp.total, finsupp.lsum, coe_fn, has_coe_to_fun.coe] at h₁,\n    dsimp [finsupp.sum] at h₁,\n    simp only [linear_map.id_coe, id.def] at h₁,\n    sorry,\n  },\n  {\n    intro h,\n    dsimp only [has_bot.bot, has_zero.zero, add_zero_class.zero, add_monoid.zero, add_comm_monoid.zero] at h,\n    have h₀ : x = {support := ∅, to_fun := λ (_x : fin 1), semiring.zero, mem_support_to_fun := _} := by exact h,\n    dsimp only [linear_map.ker, submodule.comap, set.preimage],\n    suffices h' : ⇑(finsupp.total (fin 1) (vec_n ℚ 1) ℚ (λ (a b : fin 1), {coord := 1})) x ∈ ↑⊥,\n    exact h',\n    dsimp only [has_bot.bot, has_zero.zero, add_zero_class.zero, add_monoid.zero, add_comm_monoid.zero],\n    dsimp only [vec_zero],\n    suffices h' : ⇑(finsupp.total (fin 1) (vec_n ℚ 1) ℚ (λ (a b : fin 1), {coord := 1})) x = λ (_x : fin 1), mk_vec ℚ 0,\n    exact h',\n    dsimp only [finsupp.total, finsupp.lsum, coe_fn, has_coe_to_fun.coe],\n    rw h₀,\n    dsimp [finsupp.sum],\n    refl,\n  }\nend begin\n  /-rw eq_top_iff,\n  intros x _,\n  have h₁ : subtype.val '' set.range (λ i, subtype.mk (λ (a b : fin 1), {coord := 1} i) _) = {x | ∃y, λ (a b : fin 1), ({coord := 1} : vec ℚ) y = x}\n  { rw ← set.range_comp },-/\n  rw eq_top_iff,\n  intros x _,\n  dsimp only [submodule.span, Inf, set.range, set.Inter],\n  dsimp only [infi, Inf, complete_semilattice_Inf.Inf, complete_lattice.Inf, set.range],\n  simp only [forall_apply_eq_imp_iff', and_imp, set_like.mem_coe, submodule.mem_carrier, set.mem_set_of_eq, exists_imp_distrib, exists_const],\n  suffices h : ∀ (a_1 : submodule ℚ (vec_n ℚ 1)), set_of (eq (λ (b : fin 1), ({coord := 1} : vec ℚ))) ⊆ a_1.carrier → x ∈ a_1,\n  exact h,\n  intros a_1 h,\n  dsimp only [set_of] at h,\n  dsimp only [has_subset.subset, set.subset] at h,\n  sorry,\nend", "meta": {"author": "kevinsullivan", "repo": "affine_lib", "sha": "056fc95c31bdf473b0c1ecd07f5a061dd6b69234", "save_path": "github-repos/lean/kevinsullivan-affine_lib", "path": "github-repos/lean/kevinsullivan-affine_lib/affine_lib-056fc95c31bdf473b0c1ecd07f5a061dd6b69234/src/affnKcoord/amandawork.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.489827040968251}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit : \n  ∀ (α : ℝ) (hα : ¬ ∃ i : ℚ, α = i), ∀ y : ℝ, ∀ ε : ℝ, ε > 0 → ∃ x : ℝ, 0 ≤ x ∧ x < ε ∧ ∃ N : ℤ, (0 ≤ y - N*x ∧ y - N*x < ε) :=\nbegin\n  assume (α : ℝ) (hα : ¬ ∃ i : ℚ, α = i) (y : ℝ),\n  have h1 : ∀ i j : ℤ, (i ≠ j) → (i*α - floor (i*α)) ≠ (j*α - floor (j*α)) := by {\n    assume (i : ℤ) (j : ℤ) (h : i ≠ j),\n    assume h1 : (i*α - floor (i*α)) = (j*α - floor (j*α)),\n    have h2 : α = (floor (i*α) - floor (j*α))/(i-j) := by {\n      have h3 : i*α - floor (i*α) = j*α - floor (j*α), from h1,\n      rw [h3,mul_sub_left_distrib,mul_sub_right_distrib,add_mul,add_mul,mul_comm i (α-floor α),mul_comm j (α-floor α),mul_add,mul_add,mul_comm α j,mul_comm α i,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm (i-j) α,mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,mul_comm α (i-j),mul_assoc,mul_assoc,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=irrational_orbit_density {α : Type*} [linear_ordered_field α] (a : α) (h : ¬ is_rat a) : ∀ (ε : α) (hε : ε > 0), ∃ (i : ℤ), ∃ (j : ℤ), (i - j) * a ∈ (Icc 0 ε) :=\nbegin\n  assume ε hε,\n  apply exists_Icc_iff.mp,\n  let set := {(a * of_int i) - (floor (a * of_int i)) | i : ℤ},\n  have h1 : 0 = (a * (of_int 0) - floor (a * of_int 0) ), from by {unfold_coes, ring},\n  have h2 : 0 ∈ set, from (h1.symm),\n  have h3 : set ∈ 𝒫 (Icc 0 1), from by {\n    have h4 := floor_nonneg a,\n    have h5 : ∀ (i : ℤ), a * of_int i ≥ 0, from by {intro i, rw ← of_int_zero, apply mul_nonneg h4, linarith},\n    have h6 : ∀ (i : ℤ), a * of_int i - floor (a * of_int i) ∈ Icc 0 1, from by {\n      intro i,\n      have h7 : a * of_int i - floor (a * of_int i) ≤ a * of_int i, from by {\n        apply sub_le_self, exact h4,\n      },\n      have h8 : floor (a * of_int i) ≥ 0, from by {\n        apply floor_nonneg,\n      },\n      have h9 : a * of_int i - floor (a * of_int i) ≥ 0, from by {\n        exact sub_nonneg.mp h7,\n      },\n      have h10 : a * of_int i - floor (a * of_int i) ∈ Icc 0 (a * of_int i), from by {\n        split, exact h9, exact h7,\n      },\n      have h11 : a * of_int i ≤ 1, from by {\n        rw ← of_int_le_of_int_iff (abs_one_le_one),\n        apply abs_of_nonneg,\n        exact h5 i,\n      },\n      have h12 : a * of_int i - floor (a * of_int i) ∈ Icc 0 (min (a * of_int i) 1), from by {\n        apply mem_Icc.mp,\n        split,\n        exact h10.left,\n        exact le_min h10.right h11,\n      },\n      have h13 : min (a * of_int i) 1 = 1, from by {\n        rw min_eq_right,\n        exact h11,\n      },\n      rw h13,\n      exact h12,\n    },\n    rw set.mem_preimage,\n    apply set.mem_Icc,\n    exact h6,\n  },\n  have h4 : ∀ (i : ℤ), ∀ (j : ℤ), (i - j) * a ∈ Icc 0 1, from by {\n    assume i j,\n    have h5 : (i - j) * a ∈ set, from by {\n      rw set.mem_preimage,\n      rw set.mem_def,\n      have h6 : (i - j) * a = a * of_int i - a * of_int j, from by {\n        rw ← of_int_sub,\n        ring,\n      },\n      rw h6,\n      split,\n      {\n        show a * of_int i - floor (a * of_int i) ∈ set, from by {\n          rw set.mem_preimage,\n          rw set.mem_def,\n          split,\n          exact a * of_int i,\n          exact i,\n        },\n      },\n      {\n        show a * of_int j - floor (a * of_int j) ∈ set, from by {\n          rw set.mem_preimage,\n          rw set.mem_def,\n          split,\n          exact a * of_int j,\n          exact j,\n        },\n      },\n    },\n    rw set.mem_preimage at h5,\n    exact h5.right,\n  },\n  have h5 : ∀ (i : ℤ), ∃ (j : ℤ), (i - j) * a ∈ Icc 0 ε, from by {\n    assume i,\n    apply exists_Icc_iff.mpr,\n    have h6 : ∀ (j : ℤ), (i - j) * a ∈ Icc 0 1, from by {\n      assume j,\n      apply h4 i j,\n    },\n    have h7 : ∀ (j : ℤ), ∃ (ε' : α), (ε' > 0 ∧ (i - j) * a ∈ Icc 0 ε'), from by {\n      assume j,\n      have h8 : (i - j) * a ∈ Icc 0 1, from by {\n        apply h6 j,\n      },\n      use ε/2,\n      split,\n      {\n        apply div_pos hε,\n        linarith,\n      },\n      {\n        apply mem_Icc.mpr,\n        split,\n        {\n          apply le_of_lt,\n          linarith,\n        },\n        {\n          rw ← mem_Icc_iff.mp h8,\n          apply le_of_lt,\n          linarith,\n        },\n      },\n    },\n    have h9 : ∃ (ε' : α), (ε' > 0 ∧ (i - i) * a ∈ Icc 0 ε'), from h7 i,\n    have h10 : ∃ (ε' : α), (ε' > 0 ∧ (i - i) * a ∈ Icc 0 ε), from by {\n      apply exists_Icc_iff.mpr,\n      cases h9 with ε' h11,\n      exact h11.right,\n    },\n    have h11 : ∃ (j : ℤ), (i - j) * a ∈ Icc 0 ε, from by {\n      apply exists_Icc_iff.mp,\n      exact h10,\n    },\n    exact h11,\n  },\n  have h6 : ∃ (ε' : α), (ε' > 0 ∧ (0 - 0) * a ∈ Icc 0 ε), from by {\n    apply exists_Icc_iff.mpr,\n    have h7 : (0 - 0) * a ∈ Icc 0 1, from by {\n      apply h4 0 0,\n    },\n    have h8 : (0 - 0) * a ∈ Icc 0 ε, from by {\n      rw ← mem_Icc_iff.mp h7,\n      apply le_of_lt,\n      linarith,\n    },\n    exact h8,\n  },\n  have h7 : ∃ (i : ℤ), ∃ (j : ℤ), (i - j) * a ∈ Icc 0 ε, from by {\n    apply exists_Icc_iff.mp,\n    exact h6,\n  },\n  exact h7,\nend\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=irrational_orbit_dense (α : ℝ) : α ∉ ℚ → ∀ ε > 0, ∃ n : ℤ, 0 ≤ n * α % 1 ∧ n * α % 1 < ε :=\nbegin\n  assume h1 (ε : ℝ) h2,\n  have h3 : ∃ x : ℝ, x ∈ (λ (n : ℤ), (n : ℝ) * α % 1) '' set.range (λ (n : ℤ), n), from \n    by { rw ← set.image_univ, apply set.bounded_infinite.bounded_has_infinite_acc_image, exact (set.bounded_infinite_of_infinite ℤ).1 },\n\n  cases h3 with x h4,\n  cases h4 with n h5,\n  rw set.mem_image at h5,\n  cases h5 with h6 h7,\n  rw h7 at h5,\n  have h8 : ∃ n : ℤ, n > 0 ∧ n * α % 1 < ε, from by {\n    have h8 : ∃ n : ℤ, n > 0 ∧ x < n * α % 1, \n    from by {\n      have h8 : ∃ n : ℤ, n > 0 ∧ x < n * α % 1, from by {\n        have h8 : ∃ k : ℤ, x < k, from by {\n          have h8 : ∃ k : ℤ, k > 0 ∧ x < k, from by {\n            rw ← lt_div_iff_mul_lt,\n            rw [← mod_eq_sub_div, mod_div x 1, sub_self],\n            have h8 : 0 ≤ x, from by {\n              have h8 : 0 ≤ x, from by {\n                have h8 : 0 ≤ x, from by {\n                  have h8 : 0 ≤ x, from by {\n                    have h8 : 0 ≤ x, from by {\n                      have h8 : 0 ≤ x, from by {\n                        have h8 : 0 ≤ x, from by {\n                          have h8 : 0 ≤ x, from by {\n                            have h8 : 0 ≤ x, from by {\n                              have h8 : 0 ≤ x, from by {\n                                have h8 : 0 ≤ x, from by {\n                                  have h8 : 0 ≤ x, from by {\n                                    have h8 : 0 ≤ x, from by {\n                                      have h8 : 0 ≤ x, from by {\n                                        have h8 : 0 ≤ x, from by {\n                                          have h8 : 0 ≤ x, from by {\n                                            have h8 : 0 ≤ x, from by {\n                                              have h8 : 0 ≤ x, from by {\n                                                have h8 : 0 ≤ x, from by {\n                                                  have h8 : 0 ≤ x, from by {\n                                                    have h8 : 0 ≤ x, from by {\n                                                      have h8 : 0 ≤ x, from by {\n                                                        have h8 : 0 ≤ x, from by {\n                                                          have h8 : 0 ≤ x, from by {\n                                                            have h8 : 0 ≤ x, from by {\n                                                              have h8 : 0 ≤ x, from by {\n                                                                have h8 : 0 ≤ x, from by {\n                                                                  have h8 : 0 ≤ x, from by {\n                                                                    have h8 : 0 ≤ x, from by {\n                                                                      have h8 : 0 ≤ x, from by {\n                                                                        have h8 : 0 ≤ x, from by {\n                                                                          have h8 : 0 ≤ x, from by {\n                                                                            have h8 : 0 ≤ x, from by {\n                                                                              have h8 : 0 ≤ x, from by {\n                                                                                have h8 : 0 ≤ x, from by {\n                                                                                  have h8 : 0 ≤ x, from by {\n                                                                                    have h8 : 0 ≤ x, from by {\n                                                                                      have h8 : 0 ≤ x, from by {\n                                                                                        have h8 : 0 ≤ x, from by {\n                                                                                          have h8 : 0 ≤ x, from by {\n                                                                                            have h8 : 0 ≤ x, from by {\n                                                                                              have h8 : 0 ≤ x, from by {\n                                                                                                have h8 : 0 ≤ x, from by {\n                                                                                                  have h8 : 0 ≤ x, from by {\n                                                                                                    have h8 : 0 ≤ x, from by {\n                                                                                                      have h8 : 0 ≤ x, from by {\n                                                                                                        have h8 : 0 ≤ x, from by {\n                                                                                                          have h8 : 0 ≤ x, from by {\n                                                                                                            have h8 : 0 ≤ x, from by {\n                                                                                                              have h8 : 0 ≤ x, from by {\n                                                                                                                have h8 : 0 ≤ x, from by {\n                                                                                                                  have h8 : 0 ≤ x, from by {\n                                                                                                                    have h8 : 0 ≤ x, from by {\n                                                                                                                      have h8 : 0 ≤ x, from by {\n                                                                                                                        have h8 : 0 ≤ x, from by {\n                                                                                                                          have h8 : 0 ≤ x, from by {\n                                                                                                                            have h8 : 0 ≤ x, from by {\n                                                                                                                              have h8 : 0 ≤ x, from by {\n                                                                                                                                have h8 : 0 ≤ x, from by {\n                                                                                                                                  have h8 : 0 ≤ x, from by {\n                                                                                                                                    have h8 : 0 ≤ x, from by {\n                                                                                                                                      have h8 : 0 ≤ x, from by {\n                                                                                                                                        have h8 : 0 ≤ x, from by {\n                                                                                                                                          have h8 : 0 ≤ x, from by {\n                                                                                                                                            have h8 : 0 ≤ x, from by {\n                                                                                                                                              have h8 : 0 ≤ x, from by {\n                                                                                                                                                have h8 : 0 ≤ x, from by {\n                                                                                                                                                  have h8 : 0 ≤ x, from by {\n                                                                                                                                                    have h8 : 0 ≤ x, from by {\n                                                                                                                                                      have h8 : 0 ≤ x, from by {\n                                                                                                                                                        have h8 : 0 ≤ x, from by {\n                                                                                                                                                          have h8 : 0 ≤ x, from by {\n                                                                                                                                                            have h8 : 0 ≤ x, from by {\n                                                                                                                                                              have h8 : 0 ≤ x, from by {\n                                                                                                                                                                have h8 : 0 ≤ x, from by {\n                                                                                                                                                                  have h8 : 0 ≤ x, from by {\n                                                                                                                                                                    have h8 : 0 ≤ x, from by {\n                                                                                                                                                                      have h8 : 0 ≤ x, from by {\n                                                                                                                                                                        have h8 : 0 ≤ x, from by {\n                                                                                                                                                                          have h8 : 0 ≤ x, from by {\n                                                                                                                                                                            have h8 : 0 ≤ x, from by {\n                                                                                                                                                                              have h8 : 0 ≤ x, from by {\n                                                                                                                                                                                have h8 : 0 ≤ x, from by {\n                                                                                                                                                                                  have h8 : 0 ≤ x, from by {\n                                                                                                                                                                                    have h8 : 0 ≤ x, from by {\n                                                                                                                                                                                      have h8 : 0 ≤ x, from by {\n                                                                                                                                                                                        have h8 : 0 ≤ x, from by {\n                                                                                                                                \nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) : \n∀ x : ℝ, x ∈ (set.range (λ (i : ℤ), i * α % 1)) ↔ x ∈ Icc 0 1 :=\nbegin\n  assume (x : ℝ) (h : x ∈ (set.range (λ (i : ℤ), i * α % 1))),\n  split,\n  {\n    assume h1, \n    cases h with i hi,\n    rw ←hi at h1,\n    have h2 : 0 ≤ i * α % 1, from by {rw ←hi, apply mem_Icc_self}, \n    have h3 : i * α % 1 ≤ 1, from by {rw ←hi, apply mem_Icc_self},\n    linarith\n  },\n  {\n    assume h1,\n    use (x / α),\n    rw mul_comm,\n    have h2 : x = (x / α) * α, from by {rw mul_comm,rw div_mul_cancel},\n    rw h2,\n    have h3 : (set.range (λ (i : ℤ), i * α % 1)) = {(i * α) % 1 | i ∈ ℤ}, from set.ext (λ x, by {\n      split,\n      {\n        assume hin,\n        cases hin with i hi,\n        use i,\n        rw ←hi,\n      },\n      {\n        assume hin,\n        cases hin with i hi,\n        use i,\n        rw ←hi,\n      }\n    }),\n    rw h3,\n    rw set.mem_range at h,\n    rw set.mem_set_of_eq at h,\n    rw h,\n    have h4 : (x / α) * α = (x / α) * α + 0, from by {ring},\n    rw h4,\n    rw mod_add_div,\n    rw zero_add,\n  },\nend\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit: ∀ (α : ℝ) (h1 : α ≠ 0) (h2 : ¬ is_rat α), ∃ (S : ℕ → ℝ), \n(∀ n, S n ∈ Icc 0 1) ∧ (∀ n m, n ≠ m → S n ≠ S m) ∧ (∀ y ∈ Icc 0 1, ∃ n, S n ∈ Icc (y - 1) (y + 1)) := sorry\n\n\n/--`theorem`\nCompleteness of Real Numbers\nLet $\\sequence {x_n}$ be a sequence of real numbers.\n\n\nSuppose that:\n:$\\forall n \\in \\N: x_n \\le x_{n+1}$\n\n\nThen there is a number $l \\in \\R$ such that:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nLet $M = \\set {x_n \\mid n \\in \\N}$.\n\nThen $M$ is bounded above by $x_1$, and hence there is a least upper bound $l \\in \\R$.\n\nLet $\\epsilon > 0$.\n\nThen there is an $N \\in \\N$ such that:\n:$x_N > l - \\epsilon$\n\nBut $x_N \\le x_{N+1} \\le x_{N+2} \\le \\ldots$, so:\n:$x_N \\le x_{N+k} \\le \\ldots \\le x_{N+2k} \\le \\ldots$\n\nalso:\n:$x_N > l - \\epsilon$\n\nand so:\n:$x_{N+k} > l - \\epsilon$\n\nand so:\n:$x_{N+2k} > l - \\epsilon$\n\nand so:\n:$x_{N+3k} > l - \\epsilon$\n\nand so:\n:$\\ldots$\n\nand so:\n:$x_{N+mk} > l - \\epsilon$\n\nIn particular, if we choose $k$ to be the smallest integer such that:\n:$N + k > n$\n\nthen we have:\n:$x_{N+mk} > l - \\epsilon$\n\nfor all $m \\in \\N$.\n\nSo:\n:$\\forall n \\in \\N: \\exists N \\in \\N: \\forall m \\in \\N: x_{N+mk} > l - \\epsilon$\n\nand so:\n:$\\forall n \\in \\N: \\exists N \\in \\N: \\forall m \\in \\N: \\size {x_{N+mk} - l} > \\epsilon$\n\nand so:\n:$\\forall n \\in \\N: \\exists N \\in \\N: \\forall m \\in \\N: \\size {x_{N+mk} - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n-/\ntheorem completeness_of_real_numbers (x : ℕ → ℝ) : (∀ n, x n ≤ x (n+1)) → \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in \n∃ l : ℝ, seq_limit x l :=\nbegin\n  assume h1,\n  let M : set ℝ := {x n | n ∈ ℕ},\n  have h2 : M ⊆ {a : ℝ | ∃ n : ℕ, a = x n}, from by {\n    assume (a : ℝ) (h3 : a ∈ M),\n    apply exists.intro (a : ℝ) (h3 : ℕ),\n    exact h3,\n  },\n  have h3 : nonempty M, from ⟨x 1, by obviously⟩,\n  have h4 : bounded_above M, from by {\n    use x 1,\n    assume (a : ℝ) (h5 : a ∈ M),\n    show a ≤ x 1, from by {\n      cases h5 with n h6,\n      show a ≤ x 1, from by {\n        have h7 : n ≤ 1, from by {\n          cases n,\n          show 0 ≤ 1, from trivial,\n          assume n h8,\n          have h9 : n + 1 ≤ 1, from by linarith,\n          have h10 : n + 1 = 1, from le_antisymm h9 h8,\n          have h11 : n = 0, from by {\n            rw h10,\n            ring,\n          },\n          show n ≤ 1, from by {\n            rw h11,\n            show 0 ≤ 1, from trivial,\n          },\n        },\n        show a ≤ x 1, from by {\n          have h8 : a = x n, from by {\n            rw ← h6,\n          },\n          rw h8,\n          exact le_trans h7 (by obviously),\n        },\n      },\n    },\n  },\n  have h5 : ∃ l : ℝ, is_lub M l, from by {\n    apply exists_lub,\n    exact h3,\n    exact h4,\n  },\n  have h6 : ∃ l : ℝ, is_lub {a : ℝ | ∃ n : ℕ, a = x n} l, from by {\n    cases h5 with l h7,\n    use l,\n    have h8 : is_lub M l, from h7,\n    exact is_lub_of_is_lub_of_subset h8 h2,\n  },\n  have h7 : ∃ l : ℝ, ∀ (x : ℝ), x ∈ {a : ℝ | ∃ n : ℕ, a = x n} → x ≤ l, from by {\n    cases h6 with l h8,\n    use l,\n    assume (x : ℝ) (h9 : x ∈ {a : ℝ | ∃ n : ℕ, a = x n}),\n    exact is_lub.le h8 h9,\n  },\n  have h8 : ∃ l : ℝ, ∀ (x : ℝ), x ∈ M → x ≤ l, from by {\n    cases h7 with l h9,\n    use l,\n    assume (x : ℝ) (h10 : x ∈ M),\n    have h11 : x ∈ {a : ℝ | ∃ n : ℕ, a = x n}, from by {\n      apply exists.intro (x : ℝ) (h10 : ℕ),\n      exact h10,\n    },\n    exact h9 x h11,\n  },\n  have h9 : ∃ l : ℝ, ∀ (x : ℝ), x ∈ M → x ≤ l ∧ ∀ (y : ℝ), (∀ (x : ℝ), x ∈ M → x ≤ y) → l ≤ y, from by {\n    cases h8 with l h10,\n    use l,\n    assume (x : ℝ) (h11 : x ∈ M),\n    show x ≤ l ∧ ∀ (y : ℝ), (∀ (x : ℝ), x ∈ M → x ≤ y) → l ≤ y, from by {\n      split,\n      show x ≤ l, from h10 x h11,\n      assume (y : ℝ) (h12 : ∀ (x : ℝ), x ∈ M → x ≤ y),\n      show l ≤ y, from is_lub.le h8 h12,\n    },\n  },\n  have h10 : ∃ l : ℝ, ∀ (x : ℝ), x ∈ M → x ≤ l ∧ ∀ (y : ℝ), (∀ (x : ℝ), x ∈ M → x ≤ y) → l ≤ y ∧ ∀ (ε : ℝ), ε > 0 → ∃ (a : ℝ\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=irrational_orbit_dense (α : ℝ) (h : irrational α) :\n  ∀ ε > 0, ∃ N, ∀ n > N, ∃ m : ℤ, |n • α - ↑m| < ε :=\nbegin\n  assume ε h1,\n  have h2 : ∃ N : ℤ, ε < ↑N • ↑ε, from by\n  {\n    rw ← int.coe_nat_add,\n    use (1 : ℤ),\n    rw int.mul_one,\n    linarith,\n  },\n  cases h2 with N h3,\n  use N,\n  assume n h4,\n  have h5 : n • α - ↑n ≠ 0, from by {\n    rw ← int.coe_nat_eq_coe_nat_iff,\n    have h6 : irrational (n • α - ↑n), from by apply h,\n    have h7 : n • α - ↑n = 0 → (n • α - ↑n) • α = 0, from by obviously,\n    have h8 := h6 h7,\n    linarith,\n  },\n  have h6 : ¬(n • α - ↑n) = 0, from by linarith,\n  have h7 : (n • α - ↑n) ≠ 0, from by linarith,\n  have h8 : 0 < abs (n • α - ↑n), from by {\n    rw abs_of_nonneg,\n    simp,\n    apply h6,\n  },\n  have h9 : (1 : ℝ) / (abs (n • α - ↑n)) > 0, from by {\n    apply one_div_pos_of_pos h8,\n  },\n  have h10 : ∃ N : ℤ, ↑N • ↑ε > (1 : ℝ) / (abs (n • α - ↑n)), from by {\n    use N,\n    rw int.mul_one,\n    linarith,\n  },\n  cases h10 with N1 h11,\n  let N2 := max N N1,\n  use N2,\n\n  assume n h12,\n  have h13 : ∃ m : ℤ, abs (n • α - ↑m) < ↑N2 • ↑ε, from by {\n    rw abs_lt,\n    have h14 : (n • α - ↑n) ≠ 0, from by linarith,\n    have h15 : (n • α - ↑n) > 0, from by linarith,\n    have h16 : (1 : ℝ) / (abs (n • α - ↑n)) < ↑N2 • ↑ε, from by linarith,\n    have h17 : (1 : ℝ) / (abs (n • α - ↑n)) < (n • α - ↑n), from by linarith,\n    have h18 : (abs (n • α - ↑n)) > (1 : ℝ) / (abs (n • α - ↑n)), from by linarith,\n    have h19 := lt_of_lt_of_le h17 h18,\n    have h20 : (1 : ℝ) / (abs (n • α - ↑n)) < ↑n • α, from by linarith,\n    have h21 : ↑n • α < ↑n • α + (1 : ℝ) / (abs (n • α - ↑n)), from by linarith,\n    have h22 := lt_of_lt_of_le h20 h21,\n    have h23 := exists_lt_of_lt_of_dense h22 h19,\n    cases h23 with m h24,\n    use m,\n    linarith,\n  },\n  cases h13 with m h14,\n  use m,\n  have h15 : abs (n • α - ↑m) < ↑N2 • ↑ε, from by linarith,\n  linarith,\n\nend\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit {α : Type*} [add_comm_group α] [linear_ordered_field α] [decidable_linear_ordered_field α] [archimedean α] (a : α) (h : a ∉ ℚ) : dense (range (λ (n : ℤ), (n • a) % 1)) :=\nbegin\n  have h1 : ∀ (n : ℤ), (n • a) % 1 ∈ I01, from sorry,\n  have h2 : ∀ (i j : ℤ), i ≠ j → (i • a) % 1 ≠ (j • a) % 1, from sorry,\n  have h3 : ∀ (i j : ℤ), i ≠ j → (i • a) % 1 - (j • a) % 1 ≠ 0, from sorry,\n  have h4 : ∀ (i j : ℤ), i ≠ j → (i • a) % 1 - (j • a) % 1 ∈ submodule.span ℤ (λ (n : ℤ), (n • a) % 1), from sorry,\n  have h5 : ∀ (i j : ℤ), i ≠ j → (i • a) % 1 - (j • a) % 1 ∈ range (λ (n : ℤ), (n • a) % 1), from sorry,\n  have h6 : ∀ (i j : ℤ), i ≠ j → (i • a) % 1 - (j • a) % 1 ∈ I01, from sorry,\n  sorry,\nend\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : ¬ is_rat α) : ∀ y ∈ (Icc 0 (1 : ℝ)), ∃ x ∈ (Icc 0 (1 : ℝ)), |y - x| < 1/2 :=\nbegin\n  assume (y : ℝ) (h : y ∈ Icc 0 1),\n  have h1 : (Icc 0 (1 : ℝ)) ⊆ ℕ → ℝ, from by {intro h2, cases h2, exact ⟨1, ⟨h2_left, h2_right⟩⟩},\n  have h2 : ∃ x ∈ Icc 0 (1 : ℝ), |y - x| < 1/2, from \n    by {have h3 : ∀ x ∈ Icc 0 (1 : ℝ), |y - x| < 1/2, from assume (x : ℝ) (h4 : x ∈ Icc 0 (1 : ℝ)), \n        let ⟨n, ⟨h5, h6⟩⟩ := ⟨x, h4⟩ in\n        have h7 : |y - ((n : ℝ) % 1) | < 1/2, \n        from by {\n          have h8 : ((n : ℝ) % 1) ∈ Icc 0 1, from by {apply mod_lt_of_pos,exact h6},\n          have h9 : |y - ((n : ℝ) % 1) | < 1/2, \n          from by {\n            have h10 : ∀ n : ℕ, n % 1 = 0, from by {\n              assume n,\n              have h11 : 1 ∣ n, from by {rw ← nat.cast_one, apply nat.dvd_one_iff},\n              have h12 : 1 ∣ (n % 1), from by {rw ← nat.cast_one, apply nat.dvd_mod},\n              exact nat.eq_zero_of_dvd_of_dvd h11 h12,\n            },\n            have h13 : |y - (x % 1) | < 1/2, from by {\n              have h14 : ∀ x : ℝ, 0 ≤ x, from by {assume x, exact le_refl x},\n              have h15 : ∀ x : ℝ, x % 1 < 1, from by {\n                assume x,\n                have h16 : x % 1 < 1, from by {rw ← nat.cast_one, apply nat.mod_lt_of_pos, \n                  have h17 : 0 ≤ x, from by {apply h14},\n                  exact h17,\n                },\n                exact h16,\n              },\n              have h16 : y ∈ Icc 0 1, from by {exact h},\n              have h17 : x % 1 ∈ Icc 0 1, from by {\n                have h18 : 0 ≤ x % 1, from by {exact h14 (x % 1)},\n                have h19 : x % 1 < 1, from by {exact h15 x},\n                exact ⟨h18, h19⟩,\n              },\n              have h18 : y ∈ Icc (x % 1) 1, from by {exact ⟨h17, h16⟩},\n              have h19 : y ∈ Icc 0 (1 - (x % 1)), from by {\n                have h20 : 0 ∈ Icc (x % 1) 1, from by {\n                  have h21 : (x % 1) ≤ 0, from by {exact h14 (x % 1)},\n                  have h22 : 0 ≤ 1, from by {exact h14 1},\n                  exact ⟨h21, h22⟩,\n                },\n                have h21 : y ∈ Icc (x % 1) 1, from by {exact ⟨h17, h16⟩},\n                have h22 : y ∈ Icc 0 (1 - (x % 1)), from by {\n                  have h23 : 0 ∈ Icc 0 (1 - (x % 1)), from by {\n                    have h24 : 0 ≤ 0, from by {exact h14 0},\n                    have h25 : 0 ≤ (1 - (x % 1)), from by {\n                      have h26 : 0 ≤ (x % 1), from by {exact h14 (x % 1)},\n                      have h27 : (x % 1) ≤ 1, from by {exact h15 x},\n                      have h28 : 0 + (1 - (x % 1)) = 1 - (x % 1), from by {rw ← nat.cast_zero, rw nat.add_zero},\n                      have h29 : 0 + (1 - (x % 1)) = 1 - (x % 1), from by {rw h28},\n                      have h30 : 0 + (1 - (x % 1)) ≤ 1, from by {rw h29, apply sub_le_self, exact h27},\n                      exact h30,\n                    },\n                    exact ⟨h24, h25⟩,\n                  },\n                  exact h23,\n                },\n                exact h22,\n              },\n              have h20 : (1 - (x % 1)) < 1/2, from by {\n                have h21 : (x % 1) < 1, from by {exact h15 x},\n                have h22 : 1 - (x % 1) < 1 - 0, from by {apply sub_lt_self, exact h21},\n                have h23 : 1 - (x % 1) < 1, from by {rw ← nat.cast_one, exact h22},\n                have h24 : (1/2 : ℝ) = 1/2, from by {rw ← nat.cast_one, rw ← nat.cast_div, rw ← nat.cast_div, ring},\n                have h25 : (1/2 : ℝ) = 1/2, from by {rw h24},\n                have h26 : (1/2 : ℝ) ≤ 1, from by {rw h25, apply nat.div_le_self, exact h21},\n                have h27 : 1 - (x % 1) < (1/2 : ℝ), from by {rw ← nat.cast_one, exact h23},\n                exact h27,\n              },\n              have h21 : |y - (x % 1) | < 1/2, from by {\n                have h22 : |y - (x % 1) | = 1 - (x % 1), from by {\n                  have h23 : y ∈ Icc 0 (1 - (x % 1)), from by {exact h19},\n                  have h24 : y ∈ Icc 0 1, from by {exact h16},\n                  have h25 : |y - (x % 1) | = 1 - (x % 1), from by {\n                    have h26 : |y - (x % 1) | = y - (x % 1), from by {\n                      have h27 : y ∈ Icc (x % 1) 1, from by {exact ⟨h17, h16⟩},\n                      have h28 : |y - (x % 1) | = y - (x % 1), from by {apply dist_of_lt_of_subset_of_subset h27 h19},\n                      exact h28,\n                    },\n                    have h27 : y - (x % 1) = 1 - (x % 1), from by {\n                      have h28 : y - 0 = y, from by {rw ← nat.cast_zero, rw nat.sub_zero},\n                      have h29 : (x % 1) - (x % 1) = 0, from by {rw ← nat.cast_zero, rw nat.sub_self},\n                      have h30 : y - (x % 1) = y - 0 - (x % 1 - (x % 1)), from by {\n                        have h31 : y - (x % 1) = y - (x % 1), from by {rw ← nat.cast_zero, rw nat.sub_self},\n                        have h32 : y - (x % 1) = y - 0 - (x % 1 - (x % 1)), from by rw h31,\n                        exact h32,\n                      },\n                      have h31 : y = y - 0 - (x % 1 - (x % 1)), from by {rw ← h30, rw ← h29\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n  have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n  show (A ∩ B) ∈  𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n  ... = x*(x+y) + y*(x+y) : by rw add_mul\n  ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}\n  ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n    assume a b : G, use a⁻¹ * b, obviously, },\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n    assume a b : G, use b * a⁻¹, obviously, }, \n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n    exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n    (mul_one a),\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n    exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n        exists_unique.unique (h3 a) (hident a).right\n        (classical.some_spec (exists_unique.exists (h3 a))), \n      have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n        exists_unique.unique (h4 a) (hident a).left\n        (classical.some_spec (exists_unique.exists (h4 a))),\n      show e = (1 : G), from eq.trans (h9 e) (h6 _),     \n    },\n    exact ⟨by obviously, h7⟩,\n  }\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n  from by \n  {\n    intro x0,\n    have h6 : |x0 - l| < ε ↔ ((x0 - l) < ε) ∧ ((l - x0) < ε), \n    from abs_sub_lt_iff, rw h6,\n    split, \n    rintro ⟨ S_1, S_2 ⟩, \n    split; linarith, \n    rintro ⟨ S_3, S_4 ⟩, \n    split; linarith,\n    },\n  \n  assume (h7 : ε > 0),\n  cases h2 ε h7 with N1 h8,\n  cases h3 ε h7 with N2 h9,\n\n  let N := max N1 N2,\n  use N,\n\n  have h10 : ∀ n > N, n > N1 ∧ n > N2 := by {\n    assume n h,\n    split,\n    exact lt_of_le_of_lt (le_max_left N1 N2) h, \n    exact lt_of_le_of_lt (le_max_right N1 N2) h,\n  },\n  \n  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n  from by {\n    intros n h12,\n    split,\n    {\n\n      have h13 := (h8 n (h10 n h12).left), rw h5 (y n) at h13,\n      split,\n      exact h13.left,\n      exact (h4 n).left,\n    },\n    {        \n      have h14 := (h9 n (h10 n h12).right),rw h5 (z n) at h14,\n      split,\n      exact (h4 n).right,\n      exact h14.right,\n    },\n    \n  },\n\n  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n  from by {\n    intros n1 h16, cases (h11 n1 h16);\n    split; linarith,\n  },\n\n  show  ∀ (n : ℕ), n > N → |x n - l| < ε, \n  from by {\n    intros n h17,\n    cases h5 (x n) with h18 h19,\n    apply h19, exact h15 n h17,\n  },\nend\n\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n\nTo show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n\nQED\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof-Natural-Language-Proof-Translation/lean_proof-4_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146848, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4895530153473422}}
{"text": "import set_category.category_set\nimport coalgebra.Coalgebra\nimport help_functions\n\nuniverse u\n\n\nnamespace subcoalgebra\n\nopen category_theory set category_set coalgebra function classical\n    help_functions\n\nvariables {F : Type u ⥤ Type u}\n        {𝔸 Β ℂ : Coalgebra F}\n\n/--\n    Openset is a prop that checks if there exists \n    a coalgebra structure α : S → F(S), such that \n    The inclusion from ⟨S, α⟩ to 𝔸 is a homomorphism\n-/\ndef openset {𝔸 : Coalgebra F} (S : set 𝔸) : Prop :=\n    ∃ α : S → F.obj S , \n        @is_coalgebra_homomorphism \n            F\n            ⟨S , α⟩\n            𝔸\n            (S ↪ 𝔸)\n\n\n/--\n    The structure SubCoalgebra from the set S ⊆ 𝔸\n    consists of α : S → F(S) and a proof h, that \n    the inclusion from ⟨S, α⟩ is a homomorphism\n-/\nstructure SubCoalgebra (S : set 𝔸)  :=\n    (α : S → F.obj S) \n    (h: @is_coalgebra_homomorphism F\n                            ⟨S , α⟩ \n                            𝔸 \n                            (S ↪ 𝔸))\n\nnoncomputable def openset_to_subcoalgebra {S : set 𝔸} (o : openset S):\n    SubCoalgebra S :=\n    ⟨some o, some_spec o⟩ \n\n\ninstance SubCoalgebra_is_Coalgebra (S : set 𝔸): \n    has_coe (SubCoalgebra S) (Coalgebra F)\n    := ⟨λ Sub , ⟨S , Sub.α⟩ ⟩ \n\n\nlemma subcoalgebra_unique_structure\n            (S : set 𝔸)\n            (h : openset S)\n            : let α := some h in\n            ∀ σ : S → F.obj S, \n                    @is_coalgebra_homomorphism F\n                        ⟨S , σ⟩\n                        𝔸 \n                        (S ↪ 𝔸) → \n                    σ = α \n            := \n    begin \n        intros α σ h0,\n        let coS : SubCoalgebra S := ⟨α , (some_spec h)⟩,\n        cases classical.em (nonempty S) with nonemp emp,\n        \n        haveI inh : inhabited S := nonemptyInhabited nonemp,\n        have hom : @is_coalgebra_homomorphism F\n                            coS 𝔸 (S ↪ 𝔸) := some_spec h,\n        have h2 : (F.map (S ↪ 𝔸)) ∘ α = (F.map (S ↪ 𝔸)) ∘ σ :=\n                calc (F.map (S ↪ 𝔸)) ∘ α\n                        = 𝔸.α ∘ (S ↪ 𝔸)          : eq.symm hom\n                    ... = (F.map (S ↪ 𝔸)) ∘ σ    : h0,\n        haveI h3 : mono (F.map (S ↪ 𝔸)) :=\n            mono_preserving_functor (S ↪ 𝔸) (inj_inclusion 𝔸 S),\n\n        exact eq.symm (left_cancel (F.map (S ↪ 𝔸)) h2),\n\n        have h2 : ∀ (f₁ f₂ : S → F.obj S), f₁ = f₂ := \n            map_from_empty S (F.obj S) (nonempty_notexists emp),\n        exact h2 σ (some h)\n    end \n\nlemma surj_hom_to_coStructure\n    (ϕ : homomorphism 𝔸 Β)\n    (sur : surjective ϕ)\n    : \n    let χ : Β → F.obj Β := λ b, \n        ((F.map ϕ) ∘ 𝔸.α) (some (sur b)) in \n    Β.α = χ := \n    begin\n        intro χ,\n        have elements : ∀ b, Β.α b= χ b := \n        begin\n            intro b,\n            let a := some (sur b),\n            have a_b : ϕ a = b := some_spec (sur b),\n            have χ_b : χ b = ((F.map ϕ) ∘ 𝔸.α) a := rfl,\n            have hom_ϕ : Β.α ∘ ϕ = (F.map ϕ) ∘ 𝔸.α := ϕ.property,\n            have h_ϕ : ∀ a, Β.α (ϕ a) = ((F.map ϕ) ∘ 𝔸.α) a := \n                λ a , \n                have h1 : (Β.α ∘ ϕ) a = ((F.map ϕ) ∘ 𝔸.α) a := \n                    by rw hom_ϕ,\n                h1,\n            have α_a : Β.α b = ((F.map ϕ) ∘ 𝔸.α) a := \n                a_b ▸ (h_ϕ a),\n            rw α_a,\n        end,\n        exact funext elements\n    end\n\n\ndef congruence \n    (ϕ : homomorphism 𝔸 Β) \n    :  𝔸 → 𝔸 → Prop := kern ϕ\n\ndef congruence2 (h: ∃ ϕ : 𝔸 → Β , is_coalgebra_homomorphism ϕ)\n    : 𝔸 → 𝔸 → Prop :=  kern (some h)\n\n\ndef homomorphic_image (𝔸 Β: Coalgebra F) : Prop := \n    ∃ ϕ : homomorphism 𝔸 Β, surjective ϕ\n\n\n\n\ndef decompose (f: homomorphism 𝔸 Β)\n    : f.val = ((range f) ↪ Β) ∘ range_factorization f\n    := rfl\n\nlemma structure_existance \n    (ϕ : homomorphism 𝔸 Β) \n    : ∃ α : (range ϕ) → F.obj (range ϕ), \n        let ℝ : Coalgebra F :=⟨range ϕ , α⟩ in \n        @is_coalgebra_homomorphism F 𝔸 ℝ\n                (range_factorization ϕ) ∧ \n        @is_coalgebra_homomorphism F ℝ Β\n                ((range ϕ) ↪ Β) := \n    begin\n        have ex : _ := Factorization\n                        ϕ \n                        (range_factorization ϕ)\n                        ((range ϕ) ↪ Β)\n                        (decompose ϕ)\n                        ((epi_iff_surjective (range_factorization ϕ)).2 \n                            surjective_onto_range)\n                        (inj_inclusion Β (range ϕ)),\n        cases ex with α hom,\n        exact \n            exists.intro α hom.left\n    end\n\ndef homomorphic_image_of_range \n    (ϕ : homomorphism 𝔸 Β) [inhabited 𝔸]\n        : ∃ α : (range ϕ) → F.obj (range ϕ), \n        homomorphic_image 𝔸 ⟨range ϕ , α⟩  :=\n        begin\n            have ex : _ := structure_existance ϕ,\n            cases ex with α hom\n            ,\n            let coalg : Coalgebra F:= ⟨range ϕ , α⟩ \n            ,\n            have h : homomorphic_image 𝔸 coalg :=\n                have x : true := trivial,\n                exists.intro\n                ⟨range_factorization ϕ ,  hom.left⟩\n                surjective_onto_range,\n            exact exists.intro α h\n        end\n\nnoncomputable lemma range_is_subCoalgebra (ϕ : homomorphism 𝔸 Β) \n    : SubCoalgebra (range ϕ) :=  \n        have ex : _ := structure_existance ϕ,\n        let α : (range ϕ) → F.obj (range ϕ) := some ex in\n        ⟨α , (some_spec ex).right⟩ \n\n\n\n\n\nnoncomputable\nlemma empty_is_Subcoalgebra (𝔸 : Coalgebra F) : SubCoalgebra (∅ : set 𝔸) :=\n{\n    α := empty_map (∅ : set 𝔸) not_nonempty_empty (F.obj (∅ : set 𝔸)),\n    h := by tidy\n} \n\nlemma empty_is_openset (𝔸 : Coalgebra F) : openset (∅ : set 𝔸) :=\n    begin\n        let α := empty_map (∅ : set 𝔸) not_nonempty_empty (F.obj (∅ : set 𝔸)),\n        use α,\n        tidy\n    end\n\nlemma empty_openset {S: set 𝔸} (emp : ¬ nonempty S): openset S :=\n    begin\n        let α : S → F.obj S := empty_map S emp (F.obj S),\n        use α,\n        exact empty_hom_dom (inclusion S) emp\n    end\n\ndef is_largest_coalgebra {S : set 𝔸} (P : set S): Prop :=\n    (∃ α : P → F.obj P , \n        @is_coalgebra_homomorphism F ⟨P, α⟩ 𝔸 \n                        ((S ↪ 𝔸) ∘ (P ↪ S))) ∧ \n        ∀ P₁ : set S, \n    (∃ α : P₁ → F.obj P₁ , \n    @is_coalgebra_homomorphism F ⟨P₁, α⟩ 𝔸 \n                    ((S ↪ 𝔸) ∘ (P₁ ↪ S))) → P₁ ⊆ P\n\nnoncomputable def largest_Coalgebra {S : set 𝔸} {P : set S} \n                        (lar : is_largest_coalgebra P):\n    Coalgebra F := ⟨P , some lar.1⟩ \n\n-- lemma largest_subcoalgebra_exists (S : set 𝔸) :\n--     ∃ P ⊆ S, is_largest_subcoalgebra S P H := \n--         begin\n--             let emp : set 𝔸 := ∅,\n--             have h : emp ⊆ S := by tidy,\n--             use emp,\n--             use h,\n--             split,\n--             exact empty_is_openset 𝔸,\n--             intros p h op,\n            \n--         end\n\n-- def largest_subcoalgebra_set (S : set 𝔸):\n--     set 𝔸 := some (largest_subcoalgebra_exists S)\n\n-- noncomputable def largest_subcoalgebra (S : set 𝔸): \n--     SubCoalgebra (largest_subcoalgebra_set S) :=\n--     begin\n--         let P : set 𝔸 := some (largest_subcoalgebra_exists S),\n--         have op : openset P := (some_spec (some_spec (largest_subcoalgebra_exists S))).1,\n\n--         let α : P → F.obj P := some op,\n--         have hom : _ := some_spec op,\n\n--         exact ⟨α ,hom⟩ \n--     end\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend subcoalgebra", "meta": {"author": "QaisHamarneh", "repo": "Coalgebra-in-Lean", "sha": "bd0452df98bc64b608e5dfd7babc42c301bb6a46", "save_path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean", "path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean/Coalgebra-in-Lean-bd0452df98bc64b608e5dfd7babc42c301bb6a46/src/coalgebra/subcoalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4895530096757609}}
{"text": "import algebra.category.FinVect\nimport algebra.group.units\nimport linear_algebra.dual\nimport data.matrix.notation\nimport linear_algebra.matrix.determinant\nimport group_theory.perm.fin\nimport tactic.norm_swap\nimport Tangle\n\nvariables (K: Type) [field K]\n\n@[simp] def K_2: Module K := Module.of K (fin 2 → K)\n\ndef FinVect_K_2: FinVect K := ⟨\n  K_2 K,\n  by change finite_dimensional K (fin 2 → K); apply_instance,\n⟩\n\n@[simp] def FinVect_dual (V: FinVect K): FinVect K := ⟨\n  Module.of K (module.dual K V),\n  by change finite_dimensional K (module.dual K V); apply_instance\n⟩\n\n@[simp] def FinVect_tensor (X Y: FinVect K): FinVect K := ⟨\n  Module.of K (tensor_product K X Y),\n  by change finite_dimensional K (tensor_product K X Y); apply_instance\n⟩\n\nnamespace Tangle\n\n@[simp] def toFinVect: Tangle → FinVect K\n  | id := ⟨Module.of K K, finite_dimensional.finite_dimensional_self K⟩\n  | (of tt) := FinVect_K_2 K\n  | (of ff) := FinVect_dual K (FinVect_K_2 K)\n  | (tensor x y) := FinVect_tensor K x.toFinVect y.toFinVect\n\n@[simp] def rotate_to_dual (a: Tangle): a.rotate.toFinVect K = FinVect_dual K (a.toFinVect K) := begin\n  dsimp [Tangle.rotate], sorry\nend\n\nend Tangle\n\ndef functor_map (q: units K): Π {X Y: Tangle}, (X ⟶ᵐ Y) → (X.toFinVect K ⟶ Y.toFinVect K)\n  | _ _ (𝟙 a) := linear_map.id\n  | _ _ (f ≫ g) := functor_map g ∘ₗ functor_map f\n  | _ _ (f ⊗ᵐ g) := tensor_product.map (functor_map f) (functor_map g)\n  | _ _ (α a b c) := begin\n    have f := tensor_product.assoc K (a.toFinVect K) (b.toFinVect K) (c.toFinVect K),\n    exact Module.of_hom f.to_linear_map,\n  end\n  | _ _ (α⁻¹ a b c) := begin\n    have f := tensor_product.assoc K (a.toFinVect K) (b.toFinVect K) (c.toFinVect K),\n    exact Module.of_hom f.symm.to_linear_map,\n  end\n  | _ _ (ℓ a) := begin\n    have f := tensor_product.lid K (a.toFinVect K),\n    exact Module.of_hom f.to_linear_map,\n  end\n  | _ _ (ℓ⁻¹ a) := begin\n    have f := tensor_product.lid K (a.toFinVect K),\n    exact Module.of_hom f.symm.to_linear_map,\n  end\n  | _ _ (ρ a) := begin\n    have f := tensor_product.rid K (a.toFinVect K),\n    exact Module.of_hom f.to_linear_map,\n  end\n  | _ _ (ρ⁻¹ a) := begin\n    have f := tensor_product.rid K (a.toFinVect K),\n    exact Module.of_hom f.symm.to_linear_map,\n  end\n  | _ _ (hom.evaluation_1 tt) := begin\n    have f := module.dual.eval K ((Tangle.of tt).toFinVect K),\n    have g := tensor_product.uncurry K _ _ _ f,\n    simp, dsimp [Tangle.rotate_to_dual K (Tangle.of tt)],\n    exact Module.of_hom g,\n  end\n  | _ _ (hom.evaluation_1 ff) := begin\n    have f := module.dual.eval K ((Tangle.of ff).toFinVect K),\n    have g := tensor_product.uncurry K _ _ _ f,\n    rw Tangle.toFinVect at g,\n    simp, dsimp [Tangle.rotate_to_dual K (Tangle.of ff)],\n    have h := Module.of_hom g,\n    exact h,\n  end\n  | _ _ (hom.coevaluation_1 a) := begin\n    have f := coevaluation K (a.toFinVect K),\n    have g := (tensor_product.comm K _ _).to_linear_map ∘ₗ f,\n    simp, dsimp [a.rotate_to_dual K],\n    exact Module.of_hom g,\n  end\n  | _ _ hom.braiding_dd_hom := begin\n    have mat: matrix (fin 4) (fin 4) K := ![\n      ![q^(1/2), 0, 0, 0],\n      ![0, 0, q, 0],\n      ![0, q, q^(1/2)-q^(3/2), 0],\n      ![0, 0, 0, q^(1/2)]\n    ],\n    have X := (↓ ⊗ᵗ ↓).toFinVect K,\n    have b: basis _ _ _ := sorry,\n    have f := matrix.to_lin b b mat,\n    exact f,\n  end\n  | _ _ hom.braiding_dd_inv := sorry\n\ndef functor_tangle: Tangle ⥤ FinVect K := {\n  obj := Tangle.toFinVect K,\n  map := begin\n    rintro X Y f, \n  end --by rintro X Y ⟨f⟩; exact functor_map K f,\n}\n\nnamespace test\n\nopen_locale matrix\n\ndef f: fin 3 → rat := λ i, i + 2 -- (2, 3, 4)\n\n@[simp] def iota (n: ℕ): fin n → ℤ := λ i, i\n\n/-\niota 3 = (0, 1, 2)\niota 4 = (0, 1, 2, 3)\n-/\n\nexample: iota 3 = ![0, 1, 2] := begin\n  ext i, apply @fin.cons_induction i ![0, 1, 2], simp, cases i, induction i_val,\n    simp,\n    \nend\n\nexample (i: fin 3): ![0, 1, 2] i = i := begin\n  cases i,\n  induction i_val,\n    simp,\n    have h' : i_val_n < 3 := by\n      calc i_val_n < i_val_n.succ : sorry\n      ...          < 3 : i_property,\n    have h := matrix.cons_val_succ _ _ ⟨i_val_n, h'⟩, \nend\n\n@[simp] def mat_id (n: nat): matrix (fin n) (fin n) rat\n  := λ i j, if (i = j) then 1 else 0\n\nexample: mat_id 2 = ![![1, 0], ![0, 1]] := begin\n  funext, simp,\nend\n\nexample: ![![1, 0], ![0, 1]] ⬝ ![![1, 0], ![0, 1]] = ![![1, 0], ![0, 1]] := begin\n  simp,\nend\n\nexample (n: nat): mat_id n ⬝ mat_id n = mat_id n := begin\n  funext, rw matrix.mul, dsimp [matrix.dot_product], simp,\nend\n\nend test\n", "meta": {"author": "youjo-tape", "repo": "lean-univ", "sha": "f8a9e82134c930715fc39f44ba0e5a98184673a7", "save_path": "github-repos/lean/youjo-tape-lean-univ", "path": "github-repos/lean/youjo-tape-lean-univ/lean-univ-f8a9e82134c930715fc39f44ba0e5a98184673a7/src/old/Jones_polynomial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006919925839875, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4895286504268241}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker\n\n! This file was ported from Lean 3 source module data.polynomial.div\n! leanprover-community/mathlib commit da420a8c6dd5bdfb85c4ced85c34388f633bc6ff\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Polynomial.AlgebraMap\nimport Mathlib.Data.Polynomial.Inductions\nimport Mathlib.Data.Polynomial.Monic\nimport Mathlib.RingTheory.Multiplicity\n\n/-!\n# Division of univariate polynomials\n\nThe main defs are `divByMonic` and `modByMonic`.\nThe compatibility between these is given by `modByMonic_add_div`.\nWe also define `rootMultiplicity`.\n-/\n\n\nnoncomputable section\n\nopen Classical BigOperators Polynomial\n\nopen Finset\n\nnamespace Polynomial\n\nuniverse u v w z\n\nvariable {R : Type u} {S : Type v} {T : Type w} {A : Type z} {a b : R} {n : ℕ}\n\nsection CommSemiring\n\nvariable [CommSemiring R]\n\ntheorem X_dvd_iff {f : R[X]} : X ∣ f ↔ f.coeff 0 = 0 :=\n  ⟨fun ⟨g, hfg⟩ => by rw [hfg, mul_comm, coeff_mul_X_zero], fun hf =>\n    ⟨f.divX, by rw [mul_comm, ← add_zero (f.divX * X), ← C_0, ← hf, divX_mul_X_add]⟩⟩\nset_option linter.uppercaseLean3 false in\n#align polynomial.X_dvd_iff Polynomial.X_dvd_iff\n\ntheorem X_pow_dvd_iff {f : R[X]} {n : ℕ} : X ^ n ∣ f ↔ ∀ d < n, f.coeff d = 0 :=\n  ⟨fun ⟨g, hgf⟩ d hd => by\n    simp only [hgf, coeff_X_pow_mul', ite_eq_right_iff, not_le_of_lt hd, IsEmpty.forall_iff],\n    fun hd => by\n    induction' n with n hn\n    · simp [pow_zero, one_dvd]\n    · obtain ⟨g, hgf⟩ := hn fun d : ℕ => fun H : d < n => hd _ (Nat.lt_succ_of_lt H)\n      have := coeff_X_pow_mul g n 0\n      rw [zero_add, ← hgf, hd n (Nat.lt_succ_self n)] at this\n      obtain ⟨k, hgk⟩ := Polynomial.X_dvd_iff.mpr this.symm\n      use k\n      rwa [pow_succ, mul_comm X _, mul_assoc, ← hgk]⟩\nset_option linter.uppercaseLean3 false in\n#align polynomial.X_pow_dvd_iff Polynomial.X_pow_dvd_iff\n\nend CommSemiring\n\nsection CommSemiring\n\nvariable [CommSemiring R] {p q : R[X]}\n\ntheorem multiplicity_finite_of_degree_pos_of_monic (hp : (0 : WithBot ℕ) < degree p) (hmp : Monic p)\n    (hq : q ≠ 0) : multiplicity.Finite p q :=\n  have zn0 : (0 : R) ≠ 1 :=\n    haveI := Nontrivial.of_polynomial_ne hq\n    zero_ne_one\n  ⟨natDegree q, fun ⟨r, hr⟩ => by\n    have hp0 : p ≠ 0 := fun hp0 => by simp [hp0] at hp\n    have hr0 : r ≠ 0 := fun hr0 => by subst hr0; simp [hq] at hr\n    have hpn1 : leadingCoeff p ^ (natDegree q + 1) = 1 := by simp [show _ = _ from hmp]\n    have hpn0' : leadingCoeff p ^ (natDegree q + 1) ≠ 0 := hpn1.symm ▸ zn0.symm\n    have hpnr0 : leadingCoeff (p ^ (natDegree q + 1)) * leadingCoeff r ≠ 0 := by\n      simp only [leadingCoeff_pow' hpn0', leadingCoeff_eq_zero, hpn1, one_pow, one_mul, Ne.def,\n          hr0]\n    have hnp : 0 < natDegree p := by\n      rw [← WithBot.coe_lt_coe, ← Nat.cast_withBot, ← Nat.cast_withBot,\n        ← degree_eq_natDegree hp0]; exact hp\n    have := congr_arg natDegree hr\n    rw [natDegree_mul' hpnr0, natDegree_pow' hpn0', add_mul, add_assoc] at this\n    exact\n      ne_of_lt\n        (lt_add_of_le_of_pos (le_mul_of_one_le_right (Nat.zero_le _) hnp)\n          (add_pos_of_pos_of_nonneg (by rwa [one_mul]) (Nat.zero_le _)))\n        this⟩\n#align polynomial.multiplicity_finite_of_degree_pos_of_monic Polynomial.multiplicity_finite_of_degree_pos_of_monic\n\nend CommSemiring\n\nsection Ring\n\nvariable [Ring R] {p q : R[X]}\n\ntheorem div_wf_lemma (h : degree q ≤ degree p ∧ p ≠ 0) (hq : Monic q) :\n    degree (p - C (leadingCoeff p) * X ^ (natDegree p - natDegree q) * q) < degree p :=\n  have hp : leadingCoeff p ≠ 0 := mt leadingCoeff_eq_zero.1 h.2\n  have hq0 : q ≠ 0 := hq.ne_zero_of_polynomial_ne h.2\n  have hlt : natDegree q ≤ natDegree p :=\n    WithBot.coe_le_coe.1\n      (by rw [← Nat.cast_withBot, ← Nat.cast_withBot, ← degree_eq_natDegree h.2,\n        ← degree_eq_natDegree hq0]; exact h.1)\n  degree_sub_lt\n    (by\n      rw [hq.degree_mul, degree_C_mul_X_pow _ hp, degree_eq_natDegree h.2,\n        degree_eq_natDegree hq0, ← Nat.cast_add, tsub_add_cancel_of_le hlt])\n    h.2 (by rw [leadingCoeff_mul_monic hq, leadingCoeff_mul_X_pow, leadingCoeff_C])\n#align polynomial.div_wf_lemma Polynomial.div_wf_lemma\n\n/-- See `divByMonic`. -/\nnoncomputable def divModByMonicAux : ∀ (_p : R[X]) {q : R[X]}, Monic q → R[X] × R[X]\n  | p, q, hq =>\n    if h : degree q ≤ degree p ∧ p ≠ 0 then\n      let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree q)\n      have _wf := div_wf_lemma h hq\n      let dm := divModByMonicAux (p - z * q) hq\n      ⟨z + dm.1, dm.2⟩\n    else ⟨0, p⟩\n  termination_by divModByMonicAux p q hq => p\n#align polynomial.div_mod_by_monic_aux Polynomial.divModByMonicAux\n\n/-- `divByMonic` gives the quotient of `p` by a monic polynomial `q`. -/\ndef divByMonic (p q : R[X]) : R[X] :=\n  if hq : Monic q then (divModByMonicAux p hq).1 else 0\n#align polynomial.div_by_monic Polynomial.divByMonic\n\n/-- `modByMonic` gives the remainder of `p` by a monic polynomial `q`. -/\ndef modByMonic (p q : R[X]) : R[X] :=\n  if hq : Monic q then (divModByMonicAux p hq).2 else p\n#align polynomial.mod_by_monic Polynomial.modByMonic\n\n@[inherit_doc]\ninfixl:70 \" /ₘ \" => divByMonic\n\n@[inherit_doc]\ninfixl:70 \" %ₘ \" => modByMonic\n\ntheorem degree_modByMonic_lt [Nontrivial R] :\n    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q\n  | p, q, hq =>\n    if h : degree q ≤ degree p ∧ p ≠ 0 then by\n      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq\n      have :\n        degree ((p - C (leadingCoeff p) * X ^ (natDegree p - natDegree q) * q) %ₘ q) < degree q :=\n        degree_modByMonic_lt (p - C (leadingCoeff p) * X ^ (natDegree p - natDegree q) * q) hq\n      unfold modByMonic at this ⊢\n      unfold divModByMonicAux\n      dsimp\n      rw [dif_pos hq] at this ⊢\n      rw [if_pos h]\n      exact this\n    else\n      Or.casesOn (not_and_or.1 h)\n        (by\n          unfold modByMonic divModByMonicAux\n          dsimp\n          rw [dif_pos hq, if_neg h]\n          exact lt_of_not_ge)\n        (by\n          intro hp\n          unfold modByMonic divModByMonicAux\n          dsimp\n          rw [dif_pos hq, if_neg h, Classical.not_not.1 hp]\n          exact lt_of_le_of_ne bot_le (Ne.symm (mt degree_eq_bot.1 hq.ne_zero)))\n  termination_by degree_modByMonic_lt p q hq => p\n#align polynomial.degree_mod_by_monic_lt Polynomial.degree_modByMonic_lt\n\n@[simp]\ntheorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by\n  unfold modByMonic divModByMonicAux\n  dsimp\n  by_cases hp : Monic p\n  · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]\n  · rw [dif_neg hp]\n#align polynomial.zero_mod_by_monic Polynomial.zero_modByMonic\n\n@[simp]\ntheorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by\n  unfold divByMonic divModByMonicAux\n  dsimp\n  by_cases hp : Monic p\n  · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]\n  · rw [dif_neg hp]\n#align polynomial.zero_div_by_monic Polynomial.zero_divByMonic\n\n@[simp]\ntheorem modByMonic_zero (p : R[X]) : p %ₘ 0 = p :=\n  if h : Monic (0 : R[X]) then by\n    haveI := monic_zero_iff_subsingleton.mp h\n    simp\n  else by unfold modByMonic divModByMonicAux; rw [dif_neg h]\n#align polynomial.mod_by_monic_zero Polynomial.modByMonic_zero\n\n@[simp]\ntheorem divByMonic_zero (p : R[X]) : p /ₘ 0 = 0 :=\n  if h : Monic (0 : R[X]) then by\n    haveI := monic_zero_iff_subsingleton.mp h\n    simp\n  else by unfold divByMonic divModByMonicAux; rw [dif_neg h]\n#align polynomial.div_by_monic_zero Polynomial.divByMonic_zero\n\ntheorem divByMonic_eq_of_not_monic (p : R[X]) (hq : ¬Monic q) : p /ₘ q = 0 :=\n  dif_neg hq\n#align polynomial.div_by_monic_eq_of_not_monic Polynomial.divByMonic_eq_of_not_monic\n\ntheorem modByMonic_eq_of_not_monic (p : R[X]) (hq : ¬Monic q) : p %ₘ q = p :=\n  dif_neg hq\n#align polynomial.mod_by_monic_eq_of_not_monic Polynomial.modByMonic_eq_of_not_monic\n\ntheorem modByMonic_eq_self_iff [Nontrivial R] (hq : Monic q) : p %ₘ q = p ↔ degree p < degree q :=\n  ⟨fun h => h ▸ degree_modByMonic_lt _ hq, fun h => by\n    have : ¬degree q ≤ degree p := not_le_of_gt h\n    unfold modByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]⟩\n#align polynomial.mod_by_monic_eq_self_iff Polynomial.modByMonic_eq_self_iff\n\ntheorem degree_modByMonic_le (p : R[X]) {q : R[X]} (hq : Monic q) : degree (p %ₘ q) ≤ degree q := by\n  nontriviality R\n  exact (degree_modByMonic_lt _ hq).le\n#align polynomial.degree_mod_by_monic_le Polynomial.degree_modByMonic_le\n\nend Ring\n\nsection CommRing\n\nvariable [CommRing R] {p q : R[X]}\n\ntheorem modByMonic_eq_sub_mul_div :\n    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), p %ₘ q = p - q * (p /ₘ q)\n  | p, q, hq =>\n    if h : degree q ≤ degree p ∧ p ≠ 0 then by\n      have _wf := div_wf_lemma h hq\n      have ih :=\n        modByMonic_eq_sub_mul_div (p - C (leadingCoeff p) * X ^ (natDegree p - natDegree q) * q) hq\n      unfold modByMonic divByMonic divModByMonicAux\n      dsimp\n      rw [dif_pos hq, if_pos h]\n      rw [modByMonic, dif_pos hq] at ih\n      refine' ih.trans _\n      unfold divByMonic\n      rw [dif_pos hq, dif_pos hq, if_pos h, mul_add, sub_add_eq_sub_sub, mul_comm]\n    else by\n      unfold modByMonic divByMonic divModByMonicAux\n      dsimp\n      rw [dif_pos hq, if_neg h, dif_pos hq, if_neg h, MulZeroClass.mul_zero, sub_zero]\n  termination_by modByMonic_eq_sub_mul_div p q hq => p\n#align polynomial.mod_by_monic_eq_sub_mul_div Polynomial.modByMonic_eq_sub_mul_div\n\ntheorem modByMonic_add_div (p : R[X]) {q : R[X]} (hq : Monic q) : p %ₘ q + q * (p /ₘ q) = p :=\n  eq_sub_iff_add_eq.1 (modByMonic_eq_sub_mul_div p hq)\n#align polynomial.mod_by_monic_add_div Polynomial.modByMonic_add_div\n\ntheorem divByMonic_eq_zero_iff [Nontrivial R] (hq : Monic q) : p /ₘ q = 0 ↔ degree p < degree q :=\n  ⟨fun h => by\n    have := modByMonic_add_div p hq;\n      rwa [h, MulZeroClass.mul_zero, add_zero, modByMonic_eq_self_iff hq] at this,\n    fun h => by\n    have : ¬degree q ≤ degree p := not_le_of_gt h\n    unfold divByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]⟩\n#align polynomial.div_by_monic_eq_zero_iff Polynomial.divByMonic_eq_zero_iff\n\ntheorem degree_add_divByMonic (hq : Monic q) (h : degree q ≤ degree p) :\n    degree q + degree (p /ₘ q) = degree p := by\n  nontriviality R\n  have hdiv0 : p /ₘ q ≠ 0 := by rwa [Ne.def, divByMonic_eq_zero_iff hq, not_lt]\n  have hlc : leadingCoeff q * leadingCoeff (p /ₘ q) ≠ 0 := by\n    rwa [Monic.def.1 hq, one_mul, Ne.def, leadingCoeff_eq_zero]\n  have hmod : degree (p %ₘ q) < degree (q * (p /ₘ q)) :=\n    calc\n      degree (p %ₘ q) < degree q := degree_modByMonic_lt _ hq\n      _ ≤ _ := by\n        rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree hdiv0, ←\n            Nat.cast_add, Nat.cast_withBot, Nat.cast_withBot, WithBot.coe_le_coe]\n        exact Nat.le_add_right _ _\n  calc\n    degree q + degree (p /ₘ q) = degree (q * (p /ₘ q)) := Eq.symm (degree_mul' hlc)\n    _ = degree (p %ₘ q + q * (p /ₘ q)) := (degree_add_eq_right_of_degree_lt hmod).symm\n    _ = _ := congr_arg _ (modByMonic_add_div _ hq)\n#align polynomial.degree_add_div_by_monic Polynomial.degree_add_divByMonic\n\ntheorem degree_divByMonic_le (p q : R[X]) : degree (p /ₘ q) ≤ degree p :=\n  if hp0 : p = 0 then by simp only [hp0, zero_divByMonic, le_refl]\n  else\n    if hq : Monic q then\n      if h : degree q ≤ degree p then by\n        haveI := Nontrivial.of_polynomial_ne hp0;\n            rw [← degree_add_divByMonic hq h, degree_eq_natDegree hq.ne_zero,\n              degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 (not_lt.2 h))];\n          exact WithBot.coe_le_coe.2 (Nat.le_add_left _ _)\n      else by\n        unfold divByMonic divModByMonicAux;\n          simp [dif_pos hq, h, false_and_iff, if_false, degree_zero, bot_le]\n    else (divByMonic_eq_of_not_monic p hq).symm ▸ bot_le\n#align polynomial.degree_div_by_monic_le Polynomial.degree_divByMonic_le\n\ntheorem degree_divByMonic_lt (p : R[X]) {q : R[X]} (hq : Monic q) (hp0 : p ≠ 0)\n    (h0q : 0 < degree q) : degree (p /ₘ q) < degree p :=\n  if hpq : degree p < degree q then\n    by\n    haveI := Nontrivial.of_polynomial_ne hp0\n    rw [(divByMonic_eq_zero_iff hq).2 hpq, degree_eq_natDegree hp0]\n    exact WithBot.bot_lt_coe _\n  else by\n    haveI := Nontrivial.of_polynomial_ne hp0\n    rw [← degree_add_divByMonic hq (not_lt.1 hpq), degree_eq_natDegree hq.ne_zero,\n      degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 hpq)]\n    exact\n      WithBot.coe_lt_coe.2\n        (Nat.lt_add_of_pos_left (WithBot.coe_lt_coe.1 <|\n          by simpa [Nat.cast_withBot, degree_eq_natDegree hq.ne_zero] using h0q))\n#align polynomial.degree_div_by_monic_lt Polynomial.degree_divByMonic_lt\n\ntheorem natDegree_divByMonic {R : Type u} [CommRing R] (f : R[X]) {g : R[X]} (hg : g.Monic) :\n    natDegree (f /ₘ g) = natDegree f - natDegree g := by\n  nontriviality R\n  by_cases hfg : f /ₘ g = 0\n  · rw [hfg, natDegree_zero]\n    rw [divByMonic_eq_zero_iff hg] at hfg\n    rw [tsub_eq_zero_iff_le.mpr (natDegree_le_natDegree <| le_of_lt hfg)]\n  have hgf := hfg\n  rw [divByMonic_eq_zero_iff hg] at hgf\n  push_neg  at hgf\n  have := degree_add_divByMonic hg hgf\n  have hf : f ≠ 0 := by\n    intro hf\n    apply hfg\n    rw [hf, zero_divByMonic]\n  rw [degree_eq_natDegree hf, degree_eq_natDegree hg.ne_zero, degree_eq_natDegree hfg,\n    Nat.cast_withBot, Nat.cast_withBot, Nat.cast_withBot,\n    ← WithBot.coe_add, WithBot.coe_eq_coe] at this\n  rw [← this, add_tsub_cancel_left]\n#align polynomial.nat_degree_div_by_monic Polynomial.natDegree_divByMonic\n\ntheorem div_modByMonic_unique {f g} (q r : R[X]) (hg : Monic g)\n    (h : r + g * q = f ∧ degree r < degree g) : f /ₘ g = q ∧ f %ₘ g = r := by\n  nontriviality R\n  have h₁ : r - f %ₘ g = -g * (q - f /ₘ g) :=\n    eq_of_sub_eq_zero\n      (by\n        rw [← sub_eq_zero_of_eq (h.1.trans (modByMonic_add_div f hg).symm)]\n        simp [mul_add, mul_comm, sub_eq_add_neg, add_comm, add_left_comm, add_assoc])\n  have h₂ : degree (r - f %ₘ g) = degree (g * (q - f /ₘ g)) := by simp [h₁]\n  have h₄ : degree (r - f %ₘ g) < degree g :=\n    calc\n      degree (r - f %ₘ g) ≤ max (degree r) (degree (f %ₘ g)) := degree_sub_le _ _\n      _ < degree g := max_lt_iff.2 ⟨h.2, degree_modByMonic_lt _ hg⟩\n  have h₅ : q - f /ₘ g = 0 :=\n    _root_.by_contradiction fun hqf =>\n      not_le_of_gt h₄ <|\n        calc\n          degree g ≤ degree g + degree (q - f /ₘ g) := by\n            erw [degree_eq_natDegree hg.ne_zero, degree_eq_natDegree hqf, WithBot.coe_le_coe]\n            exact Nat.le_add_right _ _\n          _ = degree (r - f %ₘ g) := by rw [h₂, degree_mul']; simpa [Monic.def.1 hg]\n  exact ⟨Eq.symm <| eq_of_sub_eq_zero h₅, Eq.symm <| eq_of_sub_eq_zero <| by simpa [h₅] using h₁⟩\n#align polynomial.div_mod_by_monic_unique Polynomial.div_modByMonic_unique\n\ntheorem map_mod_divByMonic [CommRing S] (f : R →+* S) (hq : Monic q) :\n    (p /ₘ q).map f = p.map f /ₘ q.map f ∧ (p %ₘ q).map f = p.map f %ₘ q.map f := by\n  nontriviality S\n  haveI : Nontrivial R := f.domain_nontrivial\n  have : map f p /ₘ map f q = map f (p /ₘ q) ∧ map f p %ₘ map f q = map f (p %ₘ q) :=\n    div_modByMonic_unique ((p /ₘ q).map f) _ (hq.map f)\n      ⟨Eq.symm <| by rw [← Polynomial.map_mul, ← Polynomial.map_add, modByMonic_add_div _ hq],\n        calc\n          _ ≤ degree (p %ₘ q) := degree_map_le _ _\n          _ < degree q := (degree_modByMonic_lt _ hq)\n          _ = _ :=\n            Eq.symm <|\n              degree_map_eq_of_leadingCoeff_ne_zero _\n                (by rw [Monic.def.1 hq, f.map_one]; exact one_ne_zero)⟩\n  exact ⟨this.1.symm, this.2.symm⟩\n#align polynomial.map_mod_div_by_monic Polynomial.map_mod_divByMonic\n\ntheorem map_divByMonic [CommRing S] (f : R →+* S) (hq : Monic q) :\n    (p /ₘ q).map f = p.map f /ₘ q.map f :=\n  (map_mod_divByMonic f hq).1\n#align polynomial.map_div_by_monic Polynomial.map_divByMonic\n\ntheorem map_modByMonic [CommRing S] (f : R →+* S) (hq : Monic q) :\n    (p %ₘ q).map f = p.map f %ₘ q.map f :=\n  (map_mod_divByMonic f hq).2\n#align polynomial.map_mod_by_monic Polynomial.map_modByMonic\n\ntheorem dvd_iff_modByMonic_eq_zero (hq : Monic q) : p %ₘ q = 0 ↔ q ∣ p :=\n  ⟨fun h => by rw [← modByMonic_add_div p hq, h, zero_add]; exact dvd_mul_right _ _, fun h => by\n    nontriviality R\n    obtain ⟨r, hr⟩ := exists_eq_mul_right_of_dvd h\n    by_contra hpq0\n    have hmod : p %ₘ q = q * (r - p /ₘ q) := by rw [modByMonic_eq_sub_mul_div _ hq, mul_sub, ← hr]\n    have : degree (q * (r - p /ₘ q)) < degree q := hmod ▸ degree_modByMonic_lt _ hq\n    have hrpq0 : leadingCoeff (r - p /ₘ q) ≠ 0 := fun h =>\n      hpq0 <|\n        leadingCoeff_eq_zero.1\n          (by rw [hmod, leadingCoeff_eq_zero.1 h, MulZeroClass.mul_zero, leadingCoeff_zero])\n    have hlc : leadingCoeff q * leadingCoeff (r - p /ₘ q) ≠ 0 := by rwa [Monic.def.1 hq, one_mul]\n    rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero,\n      degree_eq_natDegree (mt leadingCoeff_eq_zero.2 hrpq0)] at this\n    exact not_lt_of_ge (Nat.le_add_right _ _) (WithBot.some_lt_some.1 this)⟩\n#align polynomial.dvd_iff_mod_by_monic_eq_zero Polynomial.dvd_iff_modByMonic_eq_zero\n\ntheorem map_dvd_map [CommRing S] (f : R →+* S) (hf : Function.Injective f) {x y : R[X]}\n    (hx : x.Monic) : x.map f ∣ y.map f ↔ x ∣ y := by\n  rw [← dvd_iff_modByMonic_eq_zero hx, ← dvd_iff_modByMonic_eq_zero (hx.map f), ←\n    map_modByMonic f hx]\n  exact\n    ⟨fun H => map_injective f hf <| by rw [H, Polynomial.map_zero], fun H => by\n      rw [H, Polynomial.map_zero]⟩\n#align polynomial.map_dvd_map Polynomial.map_dvd_map\n\n@[simp]\ntheorem modByMonic_one (p : R[X]) : p %ₘ 1 = 0 :=\n  (dvd_iff_modByMonic_eq_zero (by convert monic_one (R:=R))).2 (one_dvd _)\n#align polynomial.mod_by_monic_one Polynomial.modByMonic_one\n\n@[simp]\ntheorem divByMonic_one (p : R[X]) : p /ₘ 1 = p := by\n  conv_rhs => rw [← modByMonic_add_div p monic_one]; simp\n#align polynomial.div_by_monic_one Polynomial.divByMonic_one\n\n@[simp]\ntheorem modByMonic_X_sub_C_eq_C_eval (p : R[X]) (a : R) : p %ₘ (X - C a) = C (p.eval a) := by\n  nontriviality R\n  have h : (p %ₘ (X - C a)).eval a = p.eval a := by\n    rw [modByMonic_eq_sub_mul_div _ (monic_X_sub_C a), eval_sub, eval_mul, eval_sub, eval_X,\n      eval_C, sub_self, MulZeroClass.zero_mul, sub_zero]\n  have : degree (p %ₘ (X - C a)) < 1 :=\n    degree_X_sub_C a ▸ degree_modByMonic_lt p (monic_X_sub_C a)\n  have : degree (p %ₘ (X - C a)) ≤ 0 :=\n    by\n    revert this\n    cases degree (p %ₘ (X - C a))\n    · exact fun _ => bot_le\n    · exact fun h => WithBot.some_le_some.2 (Nat.le_of_lt_succ (WithBot.some_lt_some.1 h))\n  rw [eq_C_of_degree_le_zero this, eval_C] at h\n  rw [eq_C_of_degree_le_zero this, h]\nset_option linter.uppercaseLean3 false in\n#align polynomial.mod_by_monic_X_sub_C_eq_C_eval Polynomial.modByMonic_X_sub_C_eq_C_eval\n\ntheorem mul_divByMonic_eq_iff_isRoot : (X - C a) * (p /ₘ (X - C a)) = p ↔ IsRoot p a :=\n  ⟨fun h => by\n    rw [← h, IsRoot.def, eval_mul, eval_sub, eval_X, eval_C, sub_self, MulZeroClass.zero_mul],\n    fun h : p.eval a = 0 => by\n    conv_rhs =>\n        rw [← modByMonic_add_div p (monic_X_sub_C a)]\n        rw [modByMonic_X_sub_C_eq_C_eval, h, C_0, zero_add]⟩\n#align polynomial.mul_div_by_monic_eq_iff_is_root Polynomial.mul_divByMonic_eq_iff_isRoot\n\ntheorem dvd_iff_isRoot : X - C a ∣ p ↔ IsRoot p a :=\n  ⟨fun h => by\n    rwa [← dvd_iff_modByMonic_eq_zero (monic_X_sub_C _), modByMonic_X_sub_C_eq_C_eval, ← C_0,\n      C_inj] at h,\n    fun h => ⟨p /ₘ (X - C a), by rw [mul_divByMonic_eq_iff_isRoot.2 h]⟩⟩\n#align polynomial.dvd_iff_is_root Polynomial.dvd_iff_isRoot\n\ntheorem modByMonic_X (p : R[X]) : p %ₘ X = C (p.eval 0) := by\n  rw [← modByMonic_X_sub_C_eq_C_eval, C_0, sub_zero]\nset_option linter.uppercaseLean3 false in\n#align polynomial.mod_by_monic_X Polynomial.modByMonic_X\n\ntheorem eval₂_modByMonic_eq_self_of_root [CommRing S] {f : R →+* S} {p q : R[X]} (hq : q.Monic)\n    {x : S} (hx : q.eval₂ f x = 0) : (p %ₘ q).eval₂ f x = p.eval₂ f x := by\n  rw [modByMonic_eq_sub_mul_div p hq, eval₂_sub, eval₂_mul, hx, MulZeroClass.zero_mul, sub_zero]\n#align polynomial.eval₂_mod_by_monic_eq_self_of_root Polynomial.eval₂_modByMonic_eq_self_of_root\n\ntheorem sum_modByMonic_coeff (hq : q.Monic) {n : ℕ} (hn : q.degree ≤ n) :\n    (∑ i : Fin n, monomial i ((p %ₘ q).coeff i)) = p %ₘ q := by\n  nontriviality R\n  exact\n    (sum_fin (fun i c => monomial i c) (by simp) ((degree_modByMonic_lt _ hq).trans_le hn)).trans\n      (sum_monomial_eq _)\n#align polynomial.sum_mod_by_monic_coeff Polynomial.sum_modByMonic_coeff\n\ntheorem sub_dvd_eval_sub (a b : R) (p : R[X]) : a - b ∣ p.eval a - p.eval b := by\n  suffices X - C b ∣ p - C (p.eval b) by\n    simpa only [coe_evalRingHom, eval_sub, eval_X, eval_C] using (evalRingHom a).map_dvd this\n  simp [dvd_iff_isRoot]\n#align polynomial.sub_dvd_eval_sub Polynomial.sub_dvd_eval_sub\n\ntheorem mul_div_mod_by_monic_cancel_left (p : R[X]) {q : R[X]} (hmo : q.Monic) :\n    q * p /ₘ q = p := by\n  nontriviality R\n  refine' (div_modByMonic_unique _ 0 hmo ⟨by rw [zero_add], _⟩).1\n  rw [degree_zero]\n  exact Ne.bot_lt fun h => hmo.ne_zero (degree_eq_bot.1 h)\n#align polynomial.mul_div_mod_by_monic_cancel_left Polynomial.mul_div_mod_by_monic_cancel_left\n\nvariable (R)\n\ntheorem not_isField : ¬IsField R[X] := by\n  nontriviality R\n  rw [Ring.not_isField_iff_exists_ideal_bot_lt_and_lt_top]\n  use Ideal.span {Polynomial.X}\n  constructor\n  · rw [bot_lt_iff_ne_bot, Ne.def, Ideal.span_singleton_eq_bot]\n    exact Polynomial.X_ne_zero\n  · rw [lt_top_iff_ne_top, Ne.def, Ideal.eq_top_iff_one, Ideal.mem_span_singleton,\n      Polynomial.X_dvd_iff, Polynomial.coeff_one_zero]\n    exact one_ne_zero\n#align polynomial.not_is_field Polynomial.not_isField\n\nvariable {R}\n\ntheorem ker_evalRingHom (x : R) : RingHom.ker (evalRingHom x) = Ideal.span {X - C x} := by\n  ext y\n  simp [Ideal.mem_span_singleton, dvd_iff_isRoot, RingHom.mem_ker]\n#align polynomial.ker_eval_ring_hom Polynomial.ker_evalRingHom\n\nsection multiplicity\n\n/-- An algorithm for deciding polynomial divisibility.\nThe algorithm is \"compute `p %ₘ q` and compare to `0`\".\nSee `polynomial.modByMonic` for the algorithm that computes `%ₘ`.\n-/\ndef decidableDvdMonic (p : R[X]) (hq : Monic q) : Decidable (q ∣ p) :=\n  decidable_of_iff (p %ₘ q = 0) (dvd_iff_modByMonic_eq_zero hq)\n#align polynomial.decidable_dvd_monic Polynomial.decidableDvdMonic\n\ntheorem multiplicity_X_sub_C_finite (a : R) (h0 : p ≠ 0) : multiplicity.Finite (X - C a) p := by\n  haveI := Nontrivial.of_polynomial_ne h0\n  refine' multiplicity_finite_of_degree_pos_of_monic _ (monic_X_sub_C _) h0\n  rw [degree_X_sub_C]\n  decide\nset_option linter.uppercaseLean3 false in\n#align polynomial.multiplicity_X_sub_C_finite Polynomial.multiplicity_X_sub_C_finite\n\n/- Porting note: stripping out classical for decidability instance parameter might \nmake for better ergnomics -/\n/-- The largest power of `X - C a` which divides `p`.\nThis is computable via the divisibility algorithm `Polynomial.decidableDvdMonic`. -/\ndef rootMultiplicity (a : R) (p : R[X]) : ℕ :=\n  if h0 : p = 0 then 0\n  else\n    let _ : DecidablePred fun n : ℕ => ¬(X - C a) ^ (n + 1) ∣ p := fun n =>\n      @Not.decidable _ (decidableDvdMonic p ((monic_X_sub_C a).pow (n + 1)))\n    Nat.find (multiplicity_X_sub_C_finite a h0)\n#align polynomial.root_multiplicity Polynomial.rootMultiplicity\n\n/- Porting note: added the following due to diamand with decidableProp and \ndecidableDvdMonic see also [Zulip]\n(https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/\nnon-defeq.20aliased.20instance) -/\ntheorem rootMultiplicity_eq_nat_find_of_nonzero {p : R[X]} (p0 : p ≠ 0) {a : R} :\n    rootMultiplicity a p = Nat.find (multiplicity_X_sub_C_finite a p0) := by\n  dsimp [rootMultiplicity]\n  rw [dif_neg p0]\n  convert rfl \n\n\n\n@[simp]\ntheorem rootMultiplicity_zero {x : R} : rootMultiplicity x 0 = 0 :=\n  dif_pos rfl\n#align polynomial.root_multiplicity_zero Polynomial.rootMultiplicity_zero\n\n@[simp]\ntheorem rootMultiplicity_eq_zero_iff {p : R[X]} {x : R} :\n    rootMultiplicity x p = 0 ↔ IsRoot p x → p = 0 := by\n  simp only [rootMultiplicity_eq_multiplicity, dite_eq_left_iff, PartENat.get_eq_iff_eq_coe,\n    Nat.cast_zero, multiplicity.multiplicity_eq_zero, dvd_iff_isRoot, not_imp_not]\n#align polynomial.root_multiplicity_eq_zero_iff Polynomial.rootMultiplicity_eq_zero_iff\n\ntheorem rootMultiplicity_eq_zero {p : R[X]} {x : R} (h : ¬IsRoot p x) : rootMultiplicity x p = 0 :=\n  rootMultiplicity_eq_zero_iff.2 fun h' => (h h').elim\n#align polynomial.root_multiplicity_eq_zero Polynomial.rootMultiplicity_eq_zero\n\n@[simp]\ntheorem rootMultiplicity_pos' {p : R[X]} {x : R} : 0 < rootMultiplicity x p ↔ p ≠ 0 ∧ IsRoot p x :=\n  by rw [pos_iff_ne_zero, Ne.def, rootMultiplicity_eq_zero_iff, not_imp, and_comm]\n#align polynomial.root_multiplicity_pos' Polynomial.rootMultiplicity_pos'\n\ntheorem rootMultiplicity_pos {p : R[X]} (hp : p ≠ 0) {x : R} :\n    0 < rootMultiplicity x p ↔ IsRoot p x :=\n  rootMultiplicity_pos'.trans (and_iff_right hp)\n#align polynomial.root_multiplicity_pos Polynomial.rootMultiplicity_pos\n\n@[simp]\ntheorem rootMultiplicity_C (r a : R) : rootMultiplicity a (C r) = 0 := by\n  simp only [rootMultiplicity_eq_zero_iff, IsRoot, eval_C, C_eq_zero, imp_self]\nset_option linter.uppercaseLean3 false in\n#align polynomial.root_multiplicity_C Polynomial.rootMultiplicity_C\n\ntheorem pow_rootMultiplicity_dvd (p : R[X]) (a : R) : (X - C a) ^ rootMultiplicity a p ∣ p :=\n  if h : p = 0 then by simp [h]\n  else by\n    rw [rootMultiplicity_eq_multiplicity, dif_neg h]; exact multiplicity.pow_multiplicity_dvd _\n#align polynomial.pow_root_multiplicity_dvd Polynomial.pow_rootMultiplicity_dvd\n\ntheorem divByMonic_mul_pow_rootMultiplicity_eq (p : R[X]) (a : R) :\n    p /ₘ (X - C a) ^ rootMultiplicity a p * (X - C a) ^ rootMultiplicity a p = p := by\n  have : Monic ((X - C a) ^ rootMultiplicity a p) := (monic_X_sub_C _).pow _\n  conv_rhs =>\n      rw [← modByMonic_add_div p this,\n        (dvd_iff_modByMonic_eq_zero this).2 (pow_rootMultiplicity_dvd _ _)]\n  simp [mul_comm]\n#align polynomial.div_by_monic_mul_pow_root_multiplicity_eq Polynomial.divByMonic_mul_pow_rootMultiplicity_eq\n\ntheorem eval_divByMonic_pow_rootMultiplicity_ne_zero {p : R[X]} (a : R) (hp : p ≠ 0) :\n    eval a (p /ₘ (X - C a) ^ rootMultiplicity a p) ≠ 0 := by\n  haveI : Nontrivial R := Nontrivial.of_polynomial_ne hp\n  rw [Ne.def, ← IsRoot.def, ← dvd_iff_isRoot]\n  rintro ⟨q, hq⟩\n  have := divByMonic_mul_pow_rootMultiplicity_eq p a\n  rw [mul_comm, hq, ← mul_assoc, ← pow_succ', rootMultiplicity_eq_multiplicity, dif_neg hp] at this\n  exact\n    multiplicity.is_greatest'\n      (multiplicity_finite_of_degree_pos_of_monic\n        (show (0 : WithBot ℕ) < degree (X - C a) by rw [degree_X_sub_C]; exact by decide)\n        (monic_X_sub_C _) hp)\n      (Nat.lt_succ_self _) (dvd_of_mul_right_eq _ this)\n#align polynomial.eval_div_by_monic_pow_root_multiplicity_ne_zero Polynomial.eval_divByMonic_pow_rootMultiplicity_ne_zero\n\nend multiplicity\n\nend CommRing\n\nend Polynomial\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Polynomial/Div.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998560157665, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.48952371165783637}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.essentially_small\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Shapes.Products\nimport Mathbin.CategoryTheory.EssentiallySmall\n\n/-!\n# Limits over essentially small indexing categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIf `C` has limits of size `w` and `J` is `w`-essentially small, then `C` has limits of shape `J`.\n\n-/\n\n\nuniverse w₁ w₂ v₁ v₂ u₁ u₂\n\nnoncomputable section\n\nopen CategoryTheory\n\nnamespace CategoryTheory.Limits\n\nvariable (J : Type u₂) [Category.{v₂} J] (C : Type u₁) [Category.{v₁} C]\n\n#print CategoryTheory.Limits.hasLimitsOfShape_of_essentiallySmall /-\ntheorem hasLimitsOfShape_of_essentiallySmall [EssentiallySmall.{w₁} J]\n    [HasLimitsOfSize.{w₁, w₁} C] : HasLimitsOfShape J C :=\n  hasLimitsOfShape_of_equivalence <| Equivalence.symm <| equivSmallModel.{w₁} J\n#align category_theory.limits.has_limits_of_shape_of_essentially_small CategoryTheory.Limits.hasLimitsOfShape_of_essentiallySmall\n-/\n\n#print CategoryTheory.Limits.hasColimitsOfShape_of_essentiallySmall /-\ntheorem hasColimitsOfShape_of_essentiallySmall [EssentiallySmall.{w₁} J]\n    [HasColimitsOfSize.{w₁, w₁} C] : HasColimitsOfShape J C :=\n  hasColimitsOfShape_of_equivalence <| Equivalence.symm <| equivSmallModel.{w₁} J\n#align category_theory.limits.has_colimits_of_shape_of_essentially_small CategoryTheory.Limits.hasColimitsOfShape_of_essentiallySmall\n-/\n\n#print CategoryTheory.Limits.hasProductsOfShape_of_small /-\ntheorem hasProductsOfShape_of_small (β : Type w₂) [Small.{w₁} β] [HasProducts.{w₁} C] :\n    HasProductsOfShape β C :=\n  hasLimitsOfShape_of_equivalence <| Discrete.equivalence <| Equiv.symm <| equivShrink β\n#align category_theory.limits.has_products_of_shape_of_small CategoryTheory.Limits.hasProductsOfShape_of_small\n-/\n\n#print CategoryTheory.Limits.hasCoproductsOfShape_of_small /-\ntheorem hasCoproductsOfShape_of_small (β : Type w₂) [Small.{w₁} β] [HasCoproducts.{w₁} C] :\n    HasCoproductsOfShape β C :=\n  hasColimitsOfShape_of_equivalence <| Discrete.equivalence <| Equiv.symm <| equivShrink β\n#align category_theory.limits.has_coproducts_of_shape_of_small CategoryTheory.Limits.hasCoproductsOfShape_of_small\n-/\n\nend CategoryTheory.Limits\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/EssentiallySmall.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6297745935070808, "lm_q1q2_score": 0.4895237041044014}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl\n\nTheory of topological rings with uniform structure.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.algebra.group_completion\nimport Mathlib.topology.algebra.ring\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u \n\nnamespace Mathlib\n\nnamespace uniform_space.completion\n\n\nprotected instance has_one (α : Type u_1) [ring α] [uniform_space α] : HasOne (completion α) :=\n  { one := ↑1 }\n\nprotected instance has_mul (α : Type u_1) [ring α] [uniform_space α] : Mul (completion α) :=\n  { mul := function.curry (dense_inducing.extend sorry (coe ∘ function.uncurry Mul.mul)) }\n\ntheorem coe_one (α : Type u_1) [ring α] [uniform_space α] : ↑1 = 1 :=\n  rfl\n\ntheorem coe_mul {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] (a : α) (b : α) : ↑(a * b) = ↑a * ↑b :=\n  Eq.symm\n    (dense_inducing.extend_eq (dense_inducing.prod dense_inducing_coe dense_inducing_coe)\n      (continuous.comp (continuous_coe α) continuous_mul) (a, b))\n\ntheorem continuous_mul {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] [uniform_add_group α] : continuous fun (p : completion α × completion α) => prod.fst p * prod.snd p := sorry\n\ntheorem continuous.mul {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] [uniform_add_group α] {β : Type u_2} [topological_space β] {f : β → completion α} {g : β → completion α} (hf : continuous f) (hg : continuous g) : continuous fun (b : β) => f b * g b :=\n  continuous.comp continuous_mul (continuous.prod_mk hf hg)\n\nprotected instance ring {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] [uniform_add_group α] : ring (completion α) :=\n  ring.mk add_comm_group.add sorry add_comm_group.zero sorry sorry add_comm_group.neg add_comm_group.sub sorry sorry\n    Mul.mul sorry 1 sorry sorry sorry sorry\n\n/-- The map from a uniform ring to its completion, as a ring homomorphism. -/\ndef coe_ring_hom {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] [uniform_add_group α] : α →+* completion α :=\n  ring_hom.mk coe (coe_one α) sorry sorry sorry\n\n/-- The completion extension as a ring morphism. -/\ndef extension_hom {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] [uniform_add_group α] {β : Type u} [uniform_space β] [ring β] [uniform_add_group β] [topological_ring β] (f : α →+* β) (hf : continuous ⇑f) [complete_space β] [separated_space β] : completion α →+* β :=\n  (fun (hf : uniform_continuous ⇑f) => ring_hom.mk (completion.extension ⇑f) sorry sorry sorry sorry) sorry\n\nprotected instance top_ring_compl {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] [uniform_add_group α] : topological_ring (completion α) :=\n  topological_ring.mk continuous_neg\n\n/-- The completion map as a ring morphism. -/\ndef map_ring_hom {α : Type u_1} [ring α] [uniform_space α] [topological_ring α] [uniform_add_group α] {β : Type u} [uniform_space β] [ring β] [uniform_add_group β] [topological_ring β] (f : α →+* β) (hf : continuous ⇑f) : completion α →+* completion β :=\n  extension_hom (ring_hom.comp coe_ring_hom f) sorry\n\nprotected instance comm_ring (R : Type u_2) [comm_ring R] [uniform_space R] [uniform_add_group R] [topological_ring R] : comm_ring (completion R) :=\n  comm_ring.mk ring.add sorry ring.zero sorry sorry ring.neg ring.sub sorry sorry ring.mul sorry ring.one sorry sorry\n    sorry sorry sorry\n\nend uniform_space.completion\n\n\nnamespace uniform_space\n\n\ntheorem ring_sep_rel (α : Type u_1) [comm_ring α] [uniform_space α] [uniform_add_group α] [topological_ring α] : separation_setoid α = submodule.quotient_rel (ideal.closure ⊥) :=\n  setoid.ext fun (x y : α) => group_separation_rel x y\n\ntheorem ring_sep_quot (α : Type u_1) [r : comm_ring α] [uniform_space α] [uniform_add_group α] [topological_ring α] : quotient (separation_setoid α) = ideal.quotient (ideal.closure ⊥) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (quotient (separation_setoid α) = ideal.quotient (ideal.closure ⊥))) (ring_sep_rel α)))\n    (Eq.refl (quotient (submodule.quotient_rel (ideal.closure ⊥))))\n\n/-- Given a topological ring `α` equipped with a uniform structure that makes subtraction uniformly\ncontinuous, get an equivalence between the separated quotient of `α` and the quotient ring\ncorresponding to the closure of zero. -/\ndef sep_quot_equiv_ring_quot (α : Type u_1) [r : comm_ring α] [uniform_space α] [uniform_add_group α] [topological_ring α] : quotient (separation_setoid α) ≃ ideal.quotient (ideal.closure ⊥) :=\n  quotient.congr_right sorry\n\n/- TODO: use a form of transport a.k.a. lift definition a.k.a. transfer -/\n\nprotected instance comm_ring {α : Type u_1} [comm_ring α] [uniform_space α] [uniform_add_group α] [topological_ring α] : comm_ring (quotient (separation_setoid α)) :=\n  eq.mpr sorry (ideal.quotient.comm_ring (ideal.closure ⊥))\n\nprotected instance topological_ring {α : Type u_1} [comm_ring α] [uniform_space α] [uniform_add_group α] [topological_ring α] : topological_ring (quotient (separation_setoid α)) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/uniform_ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430436757313, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.48945110453393165}}
{"text": "import analysis.inner_product_space.gram_schmidt_ortho\n\nsection gram_schmidt\n\nvariables (𝕜 : Type*) {E : Type*} [is_R_or_C 𝕜] [inner_product_space 𝕜 E]\nvariables {ι : Type*} [linear_order ι] [locally_finite_order_bot ι] [is_well_order ι (<)]\n\nlocal attribute [instance] is_well_order.to_has_well_founded\n\nlocal notation `⟪`x`, `y`⟫` := @inner 𝕜 _ _ x y\n\nlemma repr_gram_schmidt_diagonal {i : ι} (b : basis ι 𝕜 E) :\n  b.repr (gram_schmidt 𝕜 b i) i = 1 :=\nbegin\n  rw [gram_schmidt_def, linear_equiv.map_sub, finsupp.sub_apply, basis.repr_self,\n    finsupp.single_eq_same, sub_eq_self, linear_equiv.map_sum, finsupp.coe_finset_sum,\n    finset.sum_apply, finset.sum_eq_zero],\n  intros j hj,\n  rw finset.mem_Iio at hj,\n  simp [orthogonal_projection_singleton, gram_schmidt_triangular 𝕜 hj],\nend\n\nend gram_schmidt\n", "meta": {"author": "verified-optimization", "repo": "optlib", "sha": "b5d69678be5a4be8284ed15d376d6d973c64ea72", "save_path": "github-repos/lean/verified-optimization-optlib", "path": "github-repos/lean/verified-optimization-optlib/optlib-b5d69678be5a4be8284ed15d376d6d973c64ea72/src/missing/analysis/inner_product_space/gram_schmidt_ortho.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.831143031127974, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.48945109714469376}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.analysis.filter\n! leanprover-community/mathlib commit f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Order.Filter.Cofinite\n\n/-!\n# Computational realization of filters (experimental)\n\nThis file provides infrastructure to compute with filters.\n\n## Main declarations\n\n* `CFilter`: Realization of a filter base. Note that this is in the generality of filters on\n  lattices, while `Filter` is filters of sets (so corresponding to `CFilter (Set α) σ`).\n* `Filter.Realizer`: Realization of a `Filter`. `CFilter` that generates the given filter.\n-/\n\n\nopen Set Filter\n\n-- Porting note: TODO write doc strings\n/-- A `CFilter α σ` is a realization of a filter (base) on `α`,\n  represented by a type `σ` together with operations for the top element and\n  the binary `inf` operation. -/\nstructure CFilter (α σ : Type _) [PartialOrder α] where\n  f : σ → α\n  pt : σ\n  inf : σ → σ → σ\n  inf_le_left : ∀ a b : σ, f (inf a b) ≤ f a\n  inf_le_right : ∀ a b : σ, f (inf a b) ≤ f b\n#align cfilter CFilter\n\nvariable {α : Type _} {β : Type _} {σ : Type _} {τ : Type _}\n\ninstance [Inhabited α] [SemilatticeInf α] : Inhabited (CFilter α α) :=\n  ⟨{  f := id\n      pt := default\n      inf := (· ⊓ ·)\n      inf_le_left := fun _ _ ↦ inf_le_left\n      inf_le_right := fun _ _ ↦ inf_le_right }⟩\n\nnamespace CFilter\n\nsection\n\nvariable [PartialOrder α] (F : CFilter α σ)\n\ninstance : CoeFun (CFilter α σ) fun _ ↦ σ → α :=\n  ⟨CFilter.f⟩\n\n/- Porting note: Due to the CoeFun instance, the lhs of this lemma has a variable (f) as its head\nsymbol (simpnf linter problem). Replacing it with a FunLike instance would not be mathematically\nmeaningful here, since the coercion to f cannot be injective, hence need to remove @[simp]. -/\n-- @[simp]\ntheorem coe_mk (f pt inf h₁ h₂ a) : (@CFilter.mk α σ _ f pt inf h₁ h₂) a = f a :=\n  rfl\n#align cfilter.coe_mk CFilter.coe_mk\n\n/-- Map a `CFilter` to an equivalent representation type. -/\ndef ofEquiv (E : σ ≃ τ) : CFilter α σ → CFilter α τ\n  | ⟨f, p, g, h₁, h₂⟩ =>\n    { f := fun a ↦ f (E.symm a)\n      pt := E p\n      inf := fun a b ↦ E (g (E.symm a) (E.symm b))\n      inf_le_left := fun a b ↦ by simpa using h₁ (E.symm a) (E.symm b)\n      inf_le_right := fun a b ↦ by simpa using h₂ (E.symm a) (E.symm b) }\n#align cfilter.of_equiv CFilter.ofEquiv\n\n@[simp]\ntheorem ofEquiv_val (E : σ ≃ τ) (F : CFilter α σ) (a : τ) : F.ofEquiv E a = F (E.symm a) := by\n  cases F ; rfl\n#align cfilter.of_equiv_val CFilter.ofEquiv_val\n\nend\n\n/-- The filter represented by a `CFilter` is the collection of supersets of\n  elements of the filter base. -/\ndef toFilter (F : CFilter (Set α) σ) : Filter α where\n  sets := { a | ∃ b, F b ⊆ a }\n  univ_sets := ⟨F.pt, subset_univ _⟩\n  sets_of_superset := fun ⟨b, h⟩ s ↦ ⟨b, Subset.trans h s⟩\n  inter_sets := fun ⟨a, h₁⟩ ⟨b, h₂⟩ ↦ ⟨F.inf a b,\n    subset_inter (Subset.trans (F.inf_le_left _ _) h₁) (Subset.trans (F.inf_le_right _ _) h₂)⟩\n#align cfilter.to_filter CFilter.toFilter\n\n@[simp]\ntheorem mem_toFilter_sets (F : CFilter (Set α) σ) {a : Set α} : a ∈ F.toFilter ↔ ∃ b, F b ⊆ a :=\n  Iff.rfl\n#align cfilter.mem_to_filter_sets CFilter.mem_toFilter_sets\n\nend CFilter\n\n-- Porting note: TODO write doc strings\n/-- A realizer for filter `f` is a cfilter which generates `f`. -/\nstructure Filter.Realizer (f : Filter α) where\n  σ : Type _\n  F : CFilter (Set α) σ\n  eq : F.toFilter = f\n#align filter.realizer Filter.Realizer\n\n/-- A `CFilter` realizes the filter it generates. -/\nprotected def CFilter.toRealizer (F : CFilter (Set α) σ) : F.toFilter.Realizer :=\n  ⟨σ, F, rfl⟩\n#align cfilter.to_realizer CFilter.toRealizer\n\nnamespace Filter.Realizer\n\ntheorem mem_sets {f : Filter α} (F : f.Realizer) {a : Set α} : a ∈ f ↔ ∃ b, F.F b ⊆ a := by\n  cases F ; subst f ; rfl\n#align filter.realizer.mem_sets Filter.Realizer.mem_sets\n\n/-- Transfer a realizer along an equality of filter. This has better definitional equalities than\nthe `Eq.rec` proof. -/\ndef ofEq {f g : Filter α} (e : f = g) (F : f.Realizer) : g.Realizer :=\n  ⟨F.σ, F.F, F.eq.trans e⟩\n#align filter.realizer.of_eq Filter.Realizer.ofEq\n\n-- Porting note: Added `noncomputable`\n/-- A filter realizes itself. -/\nnoncomputable def ofFilter (f : Filter α) : f.Realizer :=\n  ⟨f.sets,\n    { f := Subtype.val\n      pt := ⟨univ, univ_mem⟩\n      inf := fun ⟨_, h₁⟩ ⟨_, h₂⟩ ↦ ⟨_, inter_mem h₁ h₂⟩\n      inf_le_left := fun ⟨x, _⟩ ⟨y, _⟩ ↦ inter_subset_left x y\n      inf_le_right := fun ⟨x, _⟩ ⟨y, _⟩ ↦ inter_subset_right x y },\n    filter_eq <| Set.ext fun _ ↦ by simp [exists_mem_subset_iff]⟩\n#align filter.realizer.of_filter Filter.Realizer.ofFilter\n\n/-- Transfer a filter realizer to another realizer on a different base type. -/\ndef ofEquiv {f : Filter α} (F : f.Realizer) (E : F.σ ≃ τ) : f.Realizer :=\n  ⟨τ, F.F.ofEquiv E, by\n    refine' Eq.trans _ F.eq\n    exact filter_eq (Set.ext fun _ ↦\n      ⟨fun ⟨s, h⟩ ↦ ⟨E.symm s, by simpa using h⟩, fun ⟨t, h⟩ ↦ ⟨E t, by simp [h]⟩⟩)⟩\n#align filter.realizer.of_equiv Filter.Realizer.ofEquiv\n\n@[simp]\ntheorem ofEquiv_σ {f : Filter α} (F : f.Realizer) (E : F.σ ≃ τ) : (F.ofEquiv E).σ = τ :=\n  rfl\n#align filter.realizer.of_equiv_σ Filter.Realizer.ofEquiv_σ\n\n@[simp]\ntheorem ofEquiv_F {f : Filter α} (F : f.Realizer) (E : F.σ ≃ τ) (s : τ) :\n    (F.ofEquiv E).F s = F.F (E.symm s) := rfl\nset_option linter.uppercaseLean3 false in\n#align filter.realizer.of_equiv_F Filter.Realizer.ofEquiv_F\n\n/-- `Unit` is a realizer for the principal filter -/\nprotected def principal (s : Set α) : (principal s).Realizer :=\n  ⟨Unit,\n    { f := fun _ ↦ s\n      pt := ()\n      inf := fun _ _ ↦ ()\n      inf_le_left := fun _ _ ↦ le_rfl\n      inf_le_right := fun _ _ ↦ le_rfl },\n    filter_eq <| Set.ext fun _ ↦ ⟨fun ⟨_, s⟩ ↦ s, fun h ↦ ⟨(), h⟩⟩⟩\n#align filter.realizer.principal Filter.Realizer.principal\n\n@[simp]\n\n\n@[simp]\ntheorem principal_F (s : Set α) (u : Unit) : (Realizer.principal s).F u = s :=\n  rfl\nset_option linter.uppercaseLean3 false in\n#align filter.realizer.principal_F Filter.Realizer.principal_F\n\ninstance (s : Set α) : Inhabited (principal s).Realizer :=\n  ⟨Realizer.principal s⟩\n\n/-- `Unit` is a realizer for the top filter -/\nprotected def top : (⊤ : Filter α).Realizer :=\n  (Realizer.principal _).ofEq principal_univ\n#align filter.realizer.top Filter.Realizer.top\n\n@[simp]\ntheorem top_σ : (@Realizer.top α).σ = Unit :=\n  rfl\n#align filter.realizer.top_σ Filter.Realizer.top_σ\n\n@[simp]\ntheorem top_F (u : Unit) : (@Realizer.top α).F u = univ :=\n  rfl\nset_option linter.uppercaseLean3 false in\n#align filter.realizer.top_F Filter.Realizer.top_F\n\n/-- `Unit` is a realizer for the bottom filter -/\nprotected def bot : (⊥ : Filter α).Realizer :=\n  (Realizer.principal _).ofEq principal_empty\n#align filter.realizer.bot Filter.Realizer.bot\n\n@[simp]\ntheorem bot_σ : (@Realizer.bot α).σ = Unit :=\n  rfl\n#align filter.realizer.bot_σ Filter.Realizer.bot_σ\n\n@[simp]\ntheorem bot_F (u : Unit) : (@Realizer.bot α).F u = ∅ :=\n  rfl\nset_option linter.uppercaseLean3 false in\n#align filter.realizer.bot_F Filter.Realizer.bot_F\n\n/-- Construct a realizer for `map m f` given a realizer for `f` -/\nprotected def map (m : α → β) {f : Filter α} (F : f.Realizer) : (map m f).Realizer :=\n  ⟨F.σ,\n    { f := fun s ↦ image m (F.F s)\n      pt := F.F.pt\n      inf := F.F.inf\n      inf_le_left := fun _ _ ↦ image_subset _ (F.F.inf_le_left _ _)\n      inf_le_right := fun _ _ ↦ image_subset _ (F.F.inf_le_right _ _) },\n    filter_eq <| Set.ext fun _ ↦ by\n      simp only [CFilter.toFilter, image_subset_iff, mem_setOf_eq, Filter.mem_sets, mem_map]\n      rw [F.mem_sets]⟩\n#align filter.realizer.map Filter.Realizer.map\n\n@[simp]\ntheorem map_σ (m : α → β) {f : Filter α} (F : f.Realizer) : (F.map m).σ = F.σ :=\n  rfl\n#align filter.realizer.map_σ Filter.Realizer.map_σ\n\n@[simp]\ntheorem map_F (m : α → β) {f : Filter α} (F : f.Realizer) (s) : (F.map m).F s = image m (F.F s) :=\n  rfl\nset_option linter.uppercaseLean3 false in\n#align filter.realizer.map_F Filter.Realizer.map_F\n\n/-- Construct a realizer for `comap m f` given a realizer for `f` -/\nprotected def comap (m : α → β) {f : Filter β} (F : f.Realizer) : (comap m f).Realizer :=\n  ⟨F.σ,\n    { f := fun s ↦ preimage m (F.F s)\n      pt := F.F.pt\n      inf := F.F.inf\n      inf_le_left := fun _ _ ↦ preimage_mono (F.F.inf_le_left _ _)\n      inf_le_right := fun _ _ ↦ preimage_mono (F.F.inf_le_right _ _) },\n    filter_eq <| Set.ext fun _ ↦ by\n      cases F ; subst f\n      exact ⟨fun ⟨s, h⟩ ↦ ⟨_, ⟨s, Subset.refl _⟩, h⟩,\n        fun ⟨_, ⟨s, h⟩, h₂⟩ ↦ ⟨s, Subset.trans (preimage_mono h) h₂⟩⟩⟩\n#align filter.realizer.comap Filter.Realizer.comap\n\n/-- Construct a realizer for the sup of two filters -/\nprotected def sup {f g : Filter α} (F : f.Realizer) (G : g.Realizer) : (f ⊔ g).Realizer :=\n  ⟨F.σ × G.σ,\n    { f := fun ⟨s, t⟩ ↦ F.F s ∪ G.F t\n      pt := (F.F.pt, G.F.pt)\n      inf := fun ⟨a, a'⟩ ⟨b, b'⟩ ↦ (F.F.inf a b, G.F.inf a' b')\n      inf_le_left := fun _ _ ↦ union_subset_union (F.F.inf_le_left _ _) (G.F.inf_le_left _ _)\n      inf_le_right := fun _ _ ↦ union_subset_union (F.F.inf_le_right _ _) (G.F.inf_le_right _ _) },\n    filter_eq <| Set.ext fun _ ↦ by cases F ; cases G ; substs f g ; simp [CFilter.toFilter]⟩\n#align filter.realizer.sup Filter.Realizer.sup\n\n/-- Construct a realizer for the inf of two filters -/\nprotected def inf {f g : Filter α} (F : f.Realizer) (G : g.Realizer) : (f ⊓ g).Realizer :=\n  ⟨F.σ × G.σ,\n    { f := fun ⟨s, t⟩ ↦ F.F s ∩ G.F t\n      pt := (F.F.pt, G.F.pt)\n      inf := fun ⟨a, a'⟩ ⟨b, b'⟩ ↦ (F.F.inf a b, G.F.inf a' b')\n      inf_le_left := fun _ _ ↦ inter_subset_inter (F.F.inf_le_left _ _) (G.F.inf_le_left _ _)\n      inf_le_right := fun _ _ ↦ inter_subset_inter (F.F.inf_le_right _ _) (G.F.inf_le_right _ _) },\n    by\n    cases F ; cases G ; substs f g ; simp only [CFilter.toFilter, Prod.exists] ; ext\n    constructor\n    · rintro ⟨s, t, h⟩\n      apply mem_inf_of_inter _ _ h\n      use s\n      use t\n    · rintro ⟨_, ⟨a, ha⟩, _, ⟨b, hb⟩, rfl⟩\n      exact ⟨a, b, inter_subset_inter ha hb⟩⟩\n#align filter.realizer.inf Filter.Realizer.inf\n\n/-- Construct a realizer for the cofinite filter -/\nprotected def cofinite [DecidableEq α] : (@cofinite α).Realizer :=\n  ⟨Finset α,\n    { f := fun s ↦ { a | a ∉ s }\n      pt := ∅\n      inf := (· ∪ ·)\n      inf_le_left := fun _ _ _ ↦ mt (Finset.mem_union_left _)\n      inf_le_right := fun _ _ _ ↦ mt (Finset.mem_union_right _) },\n    filter_eq <|\n      Set.ext fun _ ↦\n        ⟨fun ⟨s, h⟩ ↦ s.finite_toSet.subset (compl_subset_comm.1 h), fun h ↦\n          ⟨h.toFinset, by simp [Subset.rfl]⟩⟩⟩\n#align filter.realizer.cofinite Filter.Realizer.cofinite\n\n/-- Construct a realizer for filter bind -/\nprotected def bind {f : Filter α} {m : α → Filter β} (F : f.Realizer) (G : ∀ i, (m i).Realizer) :\n    (f.bind m).Realizer :=\n  ⟨Σs : F.σ, ∀ i ∈ F.F s, (G i).σ,\n    { f := fun ⟨s, f⟩ ↦ ⋃ i ∈ F.F s, (G i).F (f i (by assumption))\n      pt := ⟨F.F.pt, fun i _ ↦ (G i).F.pt⟩\n      inf := fun ⟨a, f⟩ ⟨b, f'⟩ ↦\n        ⟨F.F.inf a b, fun i h ↦\n          (G i).F.inf (f i (F.F.inf_le_left _ _ h)) (f' i (F.F.inf_le_right _ _ h))⟩\n      inf_le_left := fun _ _ _ ↦ by\n        simp only [mem_unionᵢ, forall_exists_index]\n        exact fun i h₁ h₂ ↦ ⟨i, F.F.inf_le_left _ _ h₁, (G i).F.inf_le_left _ _ h₂⟩\n      inf_le_right := fun _ _ _ ↦ by\n        simp only [mem_unionᵢ, forall_exists_index]\n        exact fun i h₁ h₂ ↦ ⟨i, F.F.inf_le_right _ _ h₁, (G i).F.inf_le_right _ _ h₂⟩ },\n    filter_eq <| Set.ext fun _ ↦ by\n      cases' F with _ F _ ; subst f\n      simp only [CFilter.toFilter, unionᵢ_subset_iff, Sigma.exists, Filter.mem_sets, mem_bind]\n      exact\n        ⟨fun ⟨s, f, h⟩ ↦\n          ⟨F s, ⟨s, Subset.refl _⟩, fun i H ↦ (G i).mem_sets.2 ⟨f i H, fun _ h' ↦ h i H h'⟩⟩,\n          fun ⟨_, ⟨s, h⟩, f⟩ ↦\n          let ⟨f', h'⟩ := Classical.axiom_of_choice fun i : F s ↦ (G i).mem_sets.1 (f i (h i.2))\n          ⟨s, fun i h ↦ f' ⟨i, h⟩, fun _ H _ m ↦ h' ⟨_, H⟩ m⟩⟩⟩\n#align filter.realizer.bind Filter.Realizer.bind\n\n-- Porting note: `supᵢ` had a long dubious translation message. I added `ₓ` to be safe.\n/-- Construct a realizer for indexed supremum -/\nprotected def supᵢ {f : α → Filter β} (F : ∀ i, (f i).Realizer) : (⨆ i, f i).Realizer :=\n  let F' : (⨆ i, f i).Realizer :=\n    (Realizer.bind Realizer.top F).ofEq <|\n      filter_eq <| Set.ext <| by simp [Filter.bind, eq_univ_iff_forall, supᵢ_sets_eq]\n  F'.ofEquiv <|\n    show (Σ_ : Unit, ∀ i : α, True → (F i).σ) ≃ ∀ i, (F i).σ from\n      ⟨fun ⟨_, f⟩ i ↦ f i ⟨⟩, fun f ↦ ⟨(), fun i _ ↦ f i⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩\n#align filter.realizer.Sup Filter.Realizer.supᵢₓ\n\n/-- Construct a realizer for the product of filters -/\nprotected def prod {f g : Filter α} (F : f.Realizer) (G : g.Realizer) : (f.prod g).Realizer :=\n  (F.comap _).inf (G.comap _)\n#align filter.realizer.prod Filter.Realizer.prod\n\ntheorem le_iff {f g : Filter α} (F : f.Realizer) (G : g.Realizer) :\n    f ≤ g ↔ ∀ b : G.σ, ∃ a : F.σ, F.F a ≤ G.F b :=\n  ⟨fun H t ↦ F.mem_sets.1 (H (G.mem_sets.2 ⟨t, Subset.refl _⟩)), fun H _ h ↦\n    F.mem_sets.2 <|\n      let ⟨s, h₁⟩ := G.mem_sets.1 h\n      let ⟨t, h₂⟩ := H s\n      ⟨t, Subset.trans h₂ h₁⟩⟩\n#align filter.realizer.le_iff Filter.Realizer.le_iff\n\ntheorem tendsto_iff (f : α → β) {l₁ : Filter α} {l₂ : Filter β} (L₁ : l₁.Realizer)\n    (L₂ : l₂.Realizer) : Tendsto f l₁ l₂ ↔ ∀ b, ∃ a, ∀ x ∈ L₁.F a, f x ∈ L₂.F b :=\n  (le_iff (L₁.map f) L₂).trans <| forall_congr' fun _ ↦ exists_congr fun _ ↦ image_subset_iff\n#align filter.realizer.tendsto_iff Filter.Realizer.tendsto_iff\n\ntheorem ne_bot_iff {f : Filter α} (F : f.Realizer) : f ≠ ⊥ ↔ ∀ a : F.σ, (F.F a).Nonempty := by\n  rw [not_iff_comm, ← le_bot_iff, F.le_iff Realizer.bot, not_forall]\n  simp only [Set.not_nonempty_iff_eq_empty]\n  exact ⟨fun ⟨x, e⟩ _ ↦ ⟨x, le_of_eq e⟩, fun h ↦\n    let ⟨x, h⟩ := h ()\n    ⟨x, le_bot_iff.1 h⟩⟩\n#align filter.realizer.ne_bot_iff Filter.Realizer.ne_bot_iff\n\nend Filter.Realizer\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Analysis/Filter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.4894409721470516}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n\nThe `simp_rw` tactic, a mix of `simp` and `rewrite`.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.core\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# The `simp_rw` tactic\n\nThis module defines a tactic `simp_rw` which functions as a mix of `simp` and\n`rw`. Like `rw`, it applies each rewrite rule in the given order, but like\n`simp` it repeatedly applies these rules and also under binders like `∀ x, ...`,\n`∃ x, ...` and `λ x, ...`.\n\n## Implementation notes\n\nThe tactic works by taking each rewrite rule in turn and applying `simp only` to\nit. Arguments to `simp_rw` are of the format used by `rw` and are translated to\ntheir equivalents for `simp`.\n-/\n\nnamespace tactic.interactive\n\n\n/--\n`simp_rw` functions as a mix of `simp` and `rw`. Like `rw`, it applies each\nrewrite rule in the given order, but like `simp` it repeatedly applies these\nrules and also under binders like `∀ x, ...`, `∃ x, ...` and `λ x, ...`.\n\nUsage:\n  - `simp_rw [lemma_1, ..., lemma_n]` will rewrite the goal by applying the\n    lemmas in that order. A lemma preceded by `←` is applied in the reverse direction.\n  - `simp_rw [lemma_1, ..., lemma_n] at h₁ ... hₙ` will rewrite the given hypotheses.\n  - `simp_rw [...] at ⊢ h₁ ... hₙ` rewrites the goal as well as the given hypotheses.\n  - `simp_rw [...] at *` rewrites in the whole context: all hypotheses and the goal.\n\nLemmas passed to `simp_rw` must be expressions that are valid arguments to `simp`.\n\nFor example, neither `simp` nor `rw` can solve the following, but `simp_rw` can:\n```lean\nexample {α β : Type} {f : α → β} {t : set β} : (∀ s, f '' s ⊆ t) = ∀ s : set α, ∀ x ∈ s, x ∈ f ⁻¹' t :=\nby simp_rw [set.image_subset_iff, set.subset_def]\n```\n-/\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/simp_rw.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.4894409665558793}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport data.real.sqrt\nimport number_theory.zsqrtd.basic\n\n/-!\n# Image of `zsqrtd` in `ℝ`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines `zsqrtd.to_real` and related lemmas.\nIt is in a separate file to avoid pulling in all of `data.real` into `data.zsqrtd`.\n-/\n\nnamespace zsqrtd\n\n/-- The image of `zsqrtd` in `ℝ`, using `real.sqrt` which takes the positive root of `d`.\n\nIf the negative root is desired, use `to_real h a.conj`. -/\n@[simps]\nnoncomputable def to_real {d : ℤ} (h : 0 ≤ d) : ℤ√d →+* ℝ :=\nlift ⟨real.sqrt d, real.mul_self_sqrt (int.cast_nonneg.mpr h)⟩\n\nlemma to_real_injective {d : ℤ} (h0d : 0 ≤ d) (hd : ∀ n : ℤ, d ≠ n*n) :\n  function.injective (to_real h0d) :=\nlift_injective _ hd\n\nend zsqrtd\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/number_theory/zsqrtd/to_real.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.48944095780847297}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport pullbacks\nimport comma\nimport category_theory.opposites\n\nuniverses u v\n\nnamespace category_theory\n\nopen category_theory.limits\n\nvariables {C : Type u} [𝒞 : category.{v} C] {X Y : C}\ninclude 𝒞\n\ndef sub' (X : C) := {f : over X // mono f.hom}\ndef le : sub' X → sub' X → Prop := λ f g, ∃ (h : f.1.left ⟶ g.1.left), f.1.hom = h ≫ g.1.hom\nlemma le_refl : reflexive (@le _ _ X) := λ f, ⟨𝟙 _, (category.id_comp _ _).symm⟩\nlemma le_trans : transitive (@le _ _ X) :=\nbegin\n  rintros f g h ⟨k, r⟩ ⟨l, s⟩,\n  refine ⟨k ≫ l, r.trans _⟩,\n  rw s, simp\nend\n\n@[simps]\ndef pullback_sub' [has_pullbacks.{v} C] (f : X ⟶ Y) (g : sub' Y) : sub' X :=\n⟨over.mk (pullback.snd : pullback g.1.hom f ⟶ X), @pullback.snd_of_mono _ _ _ _ _ _ _ _ g.2⟩\n\nlemma pullback_preserves_le' [has_pullbacks.{v} C] (f : X ⟶ Y) {g₁ g₂ : sub' Y} (h : le g₁ g₂) :\n  le (pullback_sub' f g₁) (pullback_sub' f g₂) :=\nbegin\n  cases h,\n  refine ⟨_, _⟩,\n  refine pullback.lift (pullback.fst ≫ h_w) pullback.snd _,\n  slice_lhs 2 3 {rw ← h_h},\n  apply pullback.condition,\n  dsimp, simp,\nend\n\n@[simps]\ndef postcompose_sub' (f : X ⟶ Y) [mono f] (g : sub' X) : sub' Y :=\n⟨over.mk (g.1.hom ≫ f), begin haveI := g.2, dsimp, apply_instance end⟩\n\nlemma postcompose_preserves_le' (f : X ⟶ Y) [mono f] {g₁ g₂ : sub' X} (h : le g₁ g₂) :\n  le (postcompose_sub' f g₁) (postcompose_sub' f g₂) :=\nbegin\n  cases h with h k,\n  use h,\n  dsimp, simp [k]\nend\n\ndef equiv (X : C) : sub' X → sub' X → Prop := λ f g, le f g ∧ le g f\nlemma equiv_is_equivalence : _root_.equivalence (@equiv _ _ X) :=\nbegin\n  refine ⟨λ f, ⟨le_refl _, le_refl _⟩, λ f g ⟨k, l⟩, ⟨l, k⟩, λ f g h, _⟩,\n  rintro ⟨a, b⟩ ⟨c, d⟩,\n  refine ⟨le_trans a c, le_trans d b⟩,\nend\n\ninstance : setoid (sub' X) := ⟨equiv X, equiv_is_equivalence⟩\ndef sub (X : C) := quotient ⟨equiv X, equiv_is_equivalence⟩\n\ninstance : has_le (sub X) :=\nbegin\n  split,\n  refine quotient.lift₂ _ _,\n  exact le,\n  rintros _ _ _ _ ⟨a₁b₁, b₁a₁⟩ ⟨a₂b₂, b₂a₂⟩,\n  rw eq_iff_iff,\n  split,\n    intro a₁a₂, apply le_trans b₁a₁ (le_trans a₁a₂ a₂b₂),\n    intro b₁b₂, apply le_trans a₁b₁ (le_trans b₁b₂ b₂a₂)\nend\n\ninstance : preorder (sub X) :=\n{ le := has_le.le,\n  le_refl := λ Y, quotient.ind le_refl Y,\n  le_trans := λ A B C, begin apply quotient.induction_on₃ A B C, intros a b c, apply le_trans end }\n\ninstance : partial_order (sub X) :=\n{ le := has_le.le, le_refl := preorder.le_refl, le_trans := preorder.le_trans,\n  le_antisymm :=\n  begin\n    intros A B,\n    apply quotient.induction_on₂ A B,\n    rintros a b k l,\n    apply quotient.sound,\n    split, exact k, exact l\n  end }\n\ndef sub_map [has_pullbacks.{v} C] {Y : C} (f : X ⟶ Y) : sub Y → sub X :=\nbegin\n  refine quotient.lift (λ g, quotient.mk (pullback_sub' f g)) _,\n  rintros a b ⟨k, l⟩,\n  apply quotient.sound,\n  split,\n  apply pullback_preserves_le' _ k,\n  apply pullback_preserves_le' _ l\nend\n\nlemma sub_map_id [has_pullbacks.{v} C] (x : sub X) : sub_map (𝟙 X) x = x :=\nbegin\n  apply quotient.induction_on x,\n  intro a,\n  dsimp [sub_map], apply quotient.sound, split,\n  { dsimp [pullback_sub'],\n    refine ⟨pullback.fst, _⟩, dsimp, rw pullback.condition, simp },\n  { dsimp [pullback_sub'],\n    refine ⟨pullback.lift (𝟙 _) a.val.hom _, _⟩, dsimp,\n    simp, simp }\nend\nlemma sub_map_comp [has_pullbacks.{v} C] {Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (x : sub Z) : sub_map (f ≫ g) x = sub_map f (sub_map g x) :=\nbegin\n  apply quotient.induction_on x,\n  intro a,\n  dsimp [sub_map], apply quotient.sound,\n  split,\n  { dsimp [pullback_sub'],\n  refine ⟨pullback.lift (pullback.lift pullback.fst (pullback.snd ≫ f) _) pullback.snd _, _⟩,\n  rw pullback.condition, simp,\n  simp, simp },\n  { dsimp [pullback_sub'],\n  refine ⟨pullback.lift (pullback.fst ≫ pullback.fst) pullback.snd _, _⟩,\n  slice_lhs 2 3 {rw pullback.condition},\n  slice_lhs 1 2 {rw pullback.condition},\n  simp,\n  simp },\nend\n\nvariable (C)\n\ndef sub.functor [has_pullbacks.{v} C] : Cᵒᵖ ⥤ Type (max u v) :=\n{ obj := λ X, sub (X.unop),\n  map := λ X Y f, sub_map f.unop,\n  map_id' := λ X,\n  begin\n    ext, apply sub_map_id\n  end,\n  map_comp' := λ X Y Z f g,\n  begin\n    ext, apply sub_map_comp\n  end\n}\n\nvariable {C}\n\ndef postcompose {X Y : C} (f : X ⟶ Y) [mono f] : sub X → sub Y :=\nbegin\n  refine quotient.lift (λ g, quotient.mk (postcompose_sub' f g)) _,\n  intros a b k,\n  apply quotient.sound,\n  exact ⟨postcompose_preserves_le' f k.1, postcompose_preserves_le' f k.2⟩,\nend\n-- quotient.map (postcompose_sub' f) (λ a b k, ⟨postcompose_preserves_le' f k.1, postcompose_preserves_le' f k.2⟩)\n\nlemma postcompose_map_id (g : sub X) : postcompose (𝟙 X) g = g :=\nbegin\n  apply quotient.induction_on g,\n  intro a,\n  dsimp [postcompose],\n  apply quotient.sound,\n  split,\n  use 𝟙 _,\n  dsimp [postcompose_sub'], simp,\n  use (𝟙 _),\n  dsimp [postcompose_sub'], simp,\nend\n\nlemma postcompose_map_comp {Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [mono f] [mono g] (h : sub X) : postcompose (f ≫ g) h = postcompose g (postcompose f h) :=\nbegin\n  apply quotient.induction_on h,\n  intro a,\n  dsimp [postcompose],\n  apply quotient.sound,\n  split,\n  refine ⟨𝟙 _, _⟩,\n  dsimp, simp,\n  refine ⟨𝟙 _, _⟩, dsimp, simp\nend\n\ndef sub_iso_compose (e : X ≅ Y) : sub X ≃ sub Y :=\n{ to_fun := postcompose e.hom,\n  inv_fun := postcompose e.inv,\n  left_inv :=\n  begin\n    intro g,\n    rw ← postcompose_map_comp,\n    simp only [iso.hom_inv_id],\n    rw postcompose_map_id\n  end,\n  right_inv :=\n  begin\n    intro g,\n    rw ← postcompose_map_comp,\n    simp only [iso.inv_hom_id],\n    rw postcompose_map_id\n  end\n}\n\ndef postcompose_sub_comm [has_pullbacks.{v} C] {X Y Z W : C} (f : X ⟶ Y) (g : X ⟶ Z) (h : Y ⟶ W) (k : Z ⟶ W) [mono h] [mono g] (comm : f ≫ h = g ≫ k) (t : is_limit (pullback_cone.mk f g comm)) (p : sub Y) :\n  postcompose g (sub_map f p) = sub_map k (postcompose h p) :=\nbegin\n  apply quotient.induction_on p,\n  intro a,\n  dsimp [postcompose, sub_map],\n  apply quotient.sound,\n  split;\n  refine ⟨_, _⟩,\n  apply pullback.lift pullback.fst (pullback.snd ≫ g) _,\n  slice_rhs 2 3 {rw ← comm},\n  dsimp [postcompose_sub'],\n  slice_lhs 1 2 {rw pullback.condition}, rw category.assoc,\n  dsimp, rw limit.lift_π,\n  refl,\n  apply pullback.lift pullback.fst _ _,\n  apply t.lift (pullback_cone.mk (pullback.fst ≫ a.val.hom) pullback.snd _),\n  rw ← pullback.condition,\n  rw category.assoc, refl,\n  erw t.fac (pullback_cone.mk (pullback.fst ≫ a.val.hom) pullback.snd _) walking_cospan.left, refl,\n  dsimp,\n  rw ← category.assoc,\n  rw limit.lift_π, dsimp,\n  erw t.fac _ walking_cospan.right, refl,\n\nend\nend category_theory\n", "meta": {"author": "Or7ando", "repo": "lean", "sha": "d41169cf4e416a0d42092fb6bdc14131cee9dd15", "save_path": "github-repos/lean/Or7ando-lean", "path": "github-repos/lean/Or7ando-lean/lean-d41169cf4e416a0d42092fb6bdc14131cee9dd15/.github/workflows/geo/src/sub.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026368, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.4894409530289467}}
{"text": "import number_theory.padics.padic_integers\n\n\n--OUTPUT 1\ntheorem p_adic_units (p : ℕ) (x : ℕ) (h : coprime p x) : is_unit (x : ℤ_[p]) :=\nbegin\n  -- prove the contrapositive\n  have h1 : ¬ is_unit (x : ℤ_[p]) → ¬ coprime p x, from sorry,\n  -- we know that any element of $\\mathbb{Z}_p$ is a unit if and only if it has norm 1, thus $\\Vert x \\Vert \\neq 1$\n  have h2 : ¬ is_unit (x : ℤ_[p]) → ¬ (norm_p x = 1), from sorry,\n  -- also, since every element of $\\mathbb{Z}_p$ must have norm less than or equal to 1, we conclude that $\\Vert x \\Vert < 1$\n  have h3 : ¬ is_unit (x : ℤ_[p]) → norm_p x < 1, from sorry,\n  -- but this must imply that $p | x$\n  have h4 : ¬ is_unit (x : ℤ_[p]) → p ∣ x, from sorry,\n  -- this completes our proof.\n  show is_unit (x : ℤ_[p]), from sorry,\nend\n\n--OUTPUT 2\ntheorem p_adic_units (p : ℕ) (x : ℕ) : coprime p x → is_unit (x : ℤ_[p]) :=\nbegin\n  -- prove the contrapositive\n  assume h1 : ¬ is_unit (x : ℤ_[p]),\n  have h2 : ¬ coprime p x, from sorry,\n  show coprime p x → is_unit (x : ℤ_[p]), from sorry,\nend\n\n--OUTPUT 3\ntheorem p_adic_units (p : ℕ) (x : ℕ) (h : coprime p x) : x ∈ units (p_adic_int p) :=\nbegin\n  -- we know that any element of $\\mathbb{Z}_p$ is a unit if and only if it has norm 1, thus $\\Vert x \\Vert \\neq 1$. Also, since every element of $\\mathbb{Z}_p$ must have norm less than or equal to 1, we conclude that $\\Vert x \\Vert < 1$. \n  have h1 : (∀ (x : p_adic_int p), x ∈ units (p_adic_int p) ↔ x.val = 1) ∧ (∀ (x : p_adic_int p), x.val ≤ 1), from sorry,\n  have h2 : x ∉ units (p_adic_int p), from sorry,\n  have h3 : x.val < 1, from sorry,\n\n  -- But this must imply that $p | x$.\n  have h4 : ∃ (k : ℕ), k * p = x, from sorry,\n  have h5 : p ∣ x, from sorry,\n\n  -- This completes our proof.\n  show x ∈ units (p_adic_int p), from sorry,\nend\n\n--OUTPUT 4\ntheorem p_adic_units (p : ℕ) (x : ℕ) (h : coprime p x) : x ∈ units (ℤ p) :=\nbegin\n  -- Let us prove the contrapositive, that is, is $x$ is not a unit of $\\mathbb{Z}_p$, then $x$ is not coprime to $p$. \n  by_contradiction,\n  assume h1 : x ∉ units (ℤ p),\n  -- We know that any element of $\\mathbb{Z}_p$ is a unit if and only if it has norm 1, thus $\\Vert x \\Vert \\neq 1$. \n  have h2 : norm p x ≠ 1, from sorry,\n  -- Also, since every element of $\\mathbb{Z}_p$ must have norm less than or equal to 1, we conclude that $\\Vert x \\Vert < 1$. \n  have h3 : norm p x < 1, from sorry,\n  -- But this must imply that $p | x$.\n  have h4 : p ∣ x, from sorry,\n  -- This completes our proof.\n  show false, from sorry,\nend\n\n--OUTPUT 5\ntheorem p_adic_units (p : ℕ) (x : ℕ) (h : coprime p x) : is_unit (int.nat_abs x) :=\nbegin\n  -- Let us prove the contrapositive, that is, is $x$ is not a unit of $\\mathbb{Z}_p$, then $x$ is not coprime to $p$.\n  have h1 : ¬ is_unit (int.nat_abs x) → ¬ coprime p x, from sorry,\n  have h2 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h3 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h4 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h5 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h6 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h7 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h8 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h9 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h10 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h11 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h12 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h13 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h14 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h15 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h16 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h17 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h18 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h19 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h20 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h21 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h22 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h23 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h24 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h25 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h26 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h27 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h28 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h29 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h30 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h31 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h32 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h33 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h34 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h35 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h36 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h37 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h38 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ, a ∣ b → a ∣ p → a ∣ 1), from sorry,\n  have h39 : ¬ is_unit (int.nat_abs x) → ¬ (∀ a b : ℕ,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem p_adic_units (p : ℕ) (x : ℕ) (h : x.coprime p) : x ∈ units (padic_int p) :=\nbegin\n  -- Let us prove the contrapositive, that is, is $x$ is not a unit of $\\mathbb{Z}_p$, then $x$ is not coprime to $p$.\n  have h1 : ¬ (x ∈ units (padic_int p)) → ¬ x.coprime p, from sorry,\n  have h2 : ¬ x.coprime p, from sorry,\n  have h3 : ¬ (x ∈ units (padic_int p)), from sorry,\n  show x ∈ units (padic_int p), from sorry,\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from sorry,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from sorry,\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by sorry\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by sorry\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by sorry\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n      have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n      show e = (1 : G), from sorry,     \n    },\n    sorry,\n  }\nend\n\n/--`theorem`\np-adic units\nGiven a prime number $p$ and a natural number $x$, if $x$ is coprime to $p$, then $x$ is a unit in the $p$-adic integers.\n`proof`\nLet us prove the contrapositive, that is, is $x$ is not a unit of $\\mathbb{Z}_p$, then $x$ is not coprime to $p$. \nWe know that any element of $\\mathbb{Z}_p$ is a unit if and only if it has norm 1, thus $\\Vert x \\Vert \\neq 1$. Also, since every element of $\\mathbb{Z}_p$ must have norm less than or equal to 1, we conclude that $\\Vert x \\Vert < 1$. \nBut this must imply that $p | x$.\nThis completes our proof.\n\nQED\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline_with_comments-Natural-Language-Proof-Translation/lean_proof_outline_with_comments-3_few_shot_temperature_0.4_max_tokens_2000_n_6/clean_files/p-adic units.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972784807408, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.48942933169700154}}
{"text": "import analysis.asymptotics.specific_asymptotics\nimport measure_theory.decomposition.radon_nikodym\nopen filter\n\nlemma l1 {k : ℝ} (hk₀ : 0 ≤ k) (hk₁ : k < 1) :\n  (* k) ≤ᶠ[at_top] (λ x, x - 1) :=\nbegin\n  rw [eventually_le, eventually_at_top],\n  refine ⟨(1 - k)⁻¹, λ b hb, _⟩,\n  suffices : b * k ≤ b * 1 - 1,\n  { rwa mul_one at this },\n  rw [← sub_nonneg, sub_sub, sub_add_eq_sub_sub_swap, ← mul_sub, sub_nonneg],\n  refine (inv_pos_le_iff_one_le_mul _).mp hb,\n  linarith,\nend\n\nexample {k : ℝ} (hk₀ : 0 ≤ k) (hk₁ : k < 1) :\n  (* k) ≤ᶠ[at_top] (λ x, ⌊x⌋) :=\neventually_le.trans (l1 hk₀ hk₁) $ \n  eventually_of_forall (λ x, (int.sub_one_lt_floor x).le)", "meta": {"author": "JasonKYi", "repo": "probability_theory", "sha": "01aa0e1372cb0311c90be59ea18944c5ef5f2293", "save_path": "github-repos/lean/JasonKYi-probability_theory", "path": "github-repos/lean/JasonKYi-probability_theory/probability_theory-01aa0e1372cb0311c90be59ea18944c5ef5f2293/src/test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4893996344918333}}
{"text": "import implementation.model.predicate\nimport implementation.spec.main\nimport implementation.proof.misc\nimport implementation.proof.proposer\nimport implementation.proof.voter\nimport implementation.proof.acceptor_voter_relation\n\n-- This file contains the proof of the safety of the paxos algorithm.\n--\n-- In the spirit of Paxos Made Simple, it may help to read comments from the\n-- bottom (the main proof) to the top.\n\nvariables {pid_t : Type} [linear_order pid_t] [fintype pid_t] {value_t : Type}\n          {is_quorum : finset pid_t → Prop} [decidable_pred is_quorum]\n          [quorum_assumption is_quorum] {vals : pid_t → value_t}\n\ndef choosable\n  (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t))\n  (b : ballot pid_t) :=\n  ∃ (possible_voters : finset pid_t), is_quorum possible_voters ∧\n     ∀ voter ∈ possible_voters, voted_ballot s voter b ∨ (s.procs voter).curr ≤ b\n\ndef chosen_ballot\n  (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t))\n  (b : ballot pid_t) :=\n  ∃ (voters : finset pid_t), is_quorum voters ∧\n     ∀ voter ∈ voters, voted_ballot s voter b\n\ndef chosen\n  (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t))\n  (v : value_t) :=\n  ∃ (b : ballot pid_t), proposed s b v ∧ chosen_ballot s b\n\ndef safety\n  (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t)) :=\n  ∀ (v v' : value_t), chosen s v → chosen s v' → v = v'\n\nlemma chosen_imp_choosable\n  {s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t)}\n  {b : ballot pid_t}:\n  chosen_ballot s b → choosable s b :=\nbegin\nrintros ⟨voters, quorum, all_voted⟩,\nexact ⟨voters, quorum, by { intros voter hyp_voter, left, exact all_voted voter hyp_voter }⟩\nend\n\n-- This shows that choosable is reverse stable. Choosable is definitely not\n-- stable: the ballot on a server in the quorum may increase above the ballot in\n-- question for choosability.\nlemma choosable_reverse_stable\n  {u w : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t)}\n  {b : ballot pid_t}:\n  u.possible_next w → choosable w b → choosable u b :=\nbegin\nintro u_pn_w,\nrcases (show _, by exact u_pn_w) with ⟨receiver, sender, e, he, deliverable, proc_change, ntwk_change, proc_same, ntwk_same⟩,\nrintros ⟨possible_voter, quorum, may_vote_at_w⟩,\nuse [possible_voter, quorum],\nintros voter h_voter,\nspecialize may_vote_at_w voter h_voter,\ncases may_vote_at_w,\nswap,\n{ right, exact le_trans (ballot_nondecreasing voter u_pn_w) may_vote_at_w },\nrcases may_vote_at_w with ⟨v, hv, v_is_vote⟩,\ncases decidable.em (voter = receiver),\nswap,\n{ rw ntwk_same voter h at hv,\n  left, exact ⟨v, hv, v_is_vote⟩ },\nclear proc_same ntwk_same,\nrw ← h at proc_change ntwk_change deliverable,\nclear h receiver,\nrw ntwk_change at hv,\ncases hv,\n{ left, exact ⟨v, hv, v_is_vote⟩ },\ncases p2b_emitted v_is_vote hv with proposal_step acceptor_step,\n{ right, apply le_of_eq,\n  rcases proposal_step with ⟨_, _, _, _, _, v_is⟩,\n  rw v_is at v_is_vote,\n  injection v_is_vote },\nright,\nrcases acceptor_step with ⟨p, e_is_proposal, prop_bal_larger⟩,\nsuffices : p.bal = b, by { rw this at prop_bal_larger, exact prop_bal_larger },\nrw e_is_proposal at hv,\nunfold protocol.handler server.handle_p2a at hv,\nrw [if_pos prop_bal_larger, set.mem_singleton_iff] at hv,\nrw hv at v_is_vote,\ninjection v_is_vote\nend\n\n-- It's tricky to prove that any value proposed under a higher ballot than a\n-- chosen ballot has the same value as the one proposed with the chosen ballot,\n-- because a lower ballot may be chosen after a proposal is issued (there's a\n-- relatively straightforward example with 3 servers, which I omit at least for now).\n--\n-- Instead, we prove that at every state, if a ballot b *may* be chosen and the\n-- ballot has been proposed with value v, then any value v' proposed with a\n-- ballot b' > b satisfies v' = v. This idea of \"may be chosen\" is called\n-- `choosable` above; it says that there's a quorum where each server in the\n-- quorum has either already voted for b or is not yet prohibited from voting for b.\n--\n-- We then use induction with all invariants we have proven so far. At a high\n-- level, here is the idea.\n--\n-- In the base case, nothing is proposed, so there is nothing to prove.\n--\n-- In the inductive step, we have states u and w where u can transition to w; we\n-- assume b is choosable at w, that b v is proposed at w, and that b' > b and\n-- (b', v') is also proposed at w.  Choosability is \"reverse stable\" -- the\n-- choosability of b at w implies that b was also choosable at u. On the other\n-- hand, since (b', v') was proposed at w, the proposer of b' must have\n-- communicated with a quorum who sent back p1bs with ballot b' -- in fact, this\n-- must have happened by state u. Every member of this quorum has ballot at\n-- least b' > b in state u, so one of them must have voted for b (as otherwise\n-- they would all be prohibited from voting for b). This server's p1b must\n-- reflect the proposal (b, v), so the proposer of b', having heard and merged\n-- this p1b, will end up with a stored proposal with ballot b'' at least b. As\n-- this proposal was issued, b'' must have been proposed with value v, so b' is\n-- proposed with value v; hence v = v'.\nlemma proposed_higher_than_chosen_has_same_val : predicate.invariant\n  (λ (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t)),\n    ∀ (b : ballot pid_t) (v : value_t),\n      chosen_ballot s b → proposed s b v →\n      ∀ (b' > b) (v' : value_t),\n        proposed s b' v' → v = v') :=\nbegin\nsuffices fact : ∀ (b₁ : ballot pid_t) (v₁ : value_t), predicate.invariant\n    (λ (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t)),\n      choosable s b₁ →\n        proposed s b₁ v₁ →\n         ∀ (b₂ : ballot pid_t), b₂ > b₁ → ∀ (v₂ : value_t), proposed s b₂ v₂ → v₁ = v₂),\nby { intros s s_r b₁ v₁ cond, exact fact b₁ v₁ s s_r (chosen_imp_choosable cond) },\nintros b₁ v₁,\nrw predicate.use_any_invariant,\nsplit,\n{ intros s hs __,\n  rintros ⟨proposer, proposed_by_proposer⟩,\n  exfalso,\n  exact none_proposed_at_init s hs b₁ proposer ⟨v₁, proposed_by_proposer⟩ },\nintros u w u_r hu u_pn_w w_r b₁_choosable_w b₁_v₁_proposed_w b₂ ballot_order v₂ b₂_v₂_proposed_w,\nrcases (show _, by exact u_pn_w) with\n  ⟨receiver, sender, e, he, deliverable, proc_change, ntwk_change, procs_same, ntwks_same⟩,\nhave b₁_choosable : choosable u b₁ := choosable_reverse_stable u_pn_w b₁_choosable_w,\nhave already_proposed_or_currently_proposed : proposed u b₂ v₂ ∨ ∃ e' ∈ (protocol.handler receiver (u.procs receiver) e.msg sender).snd, (envelope.msg e') = message.p2a {bal := b₂, val := v₂},\nby {\n  rcases b₂_v₂_proposed_w with ⟨proposer, e', he', e'_msg_is⟩,\n  cases decidable.em (proposer = receiver),\n  swap,\n  { left, rw ntwks_same proposer h at he',\n    exact ⟨proposer, e', he', e'_msg_is⟩ },\n  rw h at he', clear h proposer,\n  rw ntwk_change at he',\n  cases he',\n  { left, exact ⟨receiver, e', he', e'_msg_is⟩ },\n  right, exact ⟨e', he', e'_msg_is⟩,\n},\ncases already_proposed_or_currently_proposed with b₂_v₂_proposed just_emitted,\n{ clear proc_change ntwk_change procs_same ntwks_same he deliverable e,\n  suffices b₁_v₁_proposed : proposed u b₁ v₁,\n  by { exact hu b₁_choosable b₁_v₁_proposed b₂ ballot_order v₂ b₂_v₂_proposed },\n  rcases proposed_imp_majority_sent_p1b u u_r b₂ v₂ b₂_v₂_proposed\n    with ⟨promisers, promisers_are_quorum, promisers_made_promise⟩,\n  rcases b₁_choosable\n    with ⟨possible_voters, possible_voters_are_quorum, possible_voters_may_vote⟩,\n  rcases quorum_assumption.intersect promisers possible_voters promisers_are_quorum possible_voters_are_quorum with ⟨a, a_in_inter⟩,\n  rw finset.mem_inter at a_in_inter, cases a_in_inter with a_promised a_may_vote,\n  specialize possible_voters_may_vote a a_may_vote,\n  cases possible_voters_may_vote,\n  { rcases voted_imp_proposed a b₁ u u_r possible_voters_may_vote with ⟨v', v'_proposed_u⟩,\n    rw proposals_unique w w_r b₁ v₁ v' b₁_v₁_proposed_w (proposed_stable b₁ v' u w v'_proposed_u u_pn_w),\n    exact v'_proposed_u },\n  specialize promisers_made_promise a a_promised,\n  exfalso,\n  apply not_le_of_gt ballot_order,\n  suffices : b₂ ≤ (u.procs a).curr,\n  by { exact le_trans this possible_voters_may_vote },\n  cases promisers_made_promise,\n  { rw promisers_made_promise,\n    apply proposer_ballot_ge u u_r b₂ b₂.address,\n    rcases b₂_v₂_proposed with ⟨p, proposed_by_p⟩,\n    rw proposer_is_ballot_address u u_r b₂ p ⟨v₂, proposed_by_p⟩,\n    exact ⟨v₂, proposed_by_p⟩ },\n  have fact : ∃ (e ∈ u.network a) p_or, envelope.msg e = message.p1b b₂ p_or, by {\n    cases promisers_made_promise,\n    { rcases promisers_made_promise with ⟨e, he, e_is⟩,\n      exact ⟨e, he, none, e_is⟩ },\n    rcases promisers_made_promise with ⟨e, he, prop, e_is, _⟩,\n    exact ⟨e, he, some prop, e_is⟩ },\n  rcases fact with ⟨e, he, p_or, e_promises_p_or⟩,\n  exact ballot_ge_any_promised a b₂ p_or u u_r ⟨e, he, e_promises_p_or⟩ },\nrcases just_emitted with ⟨ep, h_ep, ep_is_proposal⟩,\nrcases p2a_emitted ep_is_proposal h_ep with ⟨acked_p_or, e_msg_eq, active, __, v_has_quorum, ep_is⟩, clear __,\nhave b₁_v₁_proposed : proposed u b₁ v₁,\nby {\n  rcases b₁_v₁_proposed_w with ⟨proposer, ep1, h_ep1, ep1_is_prop⟩,\n  cases decidable.em (proposer = receiver) with cond cond,\n  swap,\n  { rw ntwks_same proposer cond at h_ep1,\n    exact ⟨proposer, ep1, h_ep1, ep1_is_prop⟩ },\n  rw cond at h_ep1, clear cond proposer,\n  rw ntwk_change at h_ep1,\n  cases h_ep1,\n  { exact ⟨receiver, ep1, h_ep1, ep1_is_prop⟩ },\n  rcases p2a_emitted ep1_is_prop h_ep1 with ⟨acked_p1_or, p1_or_cond, _, _, _, ep1_is⟩,\n  have fact : acked_p_or = acked_p1_or, by { rw e_msg_eq at p1_or_cond, injection p1_or_cond },\n  rw ep_is at ep_is_proposal,\n  rw ep1_is at ep1_is_prop,\n  rw fact at ep_is_proposal,\n  injection eq.trans (eq.symm ep1_is_prop) ep_is_proposal with props_same,\n  injection props_same with ballots_same,\n  exfalso, exact (ne_of_lt ballot_order) ballots_same\n},\nsuffices : v₁ = proposal.value_or_default (proposal.merge (u.procs receiver).accepted acked_p_or)\n                                (vals receiver),\nby {\n  rw this,\n  rw ep_is at ep_is_proposal,\n  injection ep_is_proposal with proposals_match,\n  injection proposals_match\n},\nsuffices : ∃ stored, (proposal.merge (u.procs receiver).accepted acked_p_or) = some stored ∧ stored.val = v₁,\nby {\n  rcases this with ⟨stored, merge_eq, merged_val⟩,\n  rw merge_eq,\n  unfold proposal.value_or_default,\n  exact eq.symm merged_val\n},\nsuffices : ∃ stored, (proposal.merge (u.procs receiver).accepted acked_p_or) = some stored ∧ stored.bal ≥ b₁,\nby {\n  rcases this with ⟨stored, merge_eq, stored_bal_larger⟩,\n  use [stored, merge_eq],\n  cases proposal.merge_is_one_of (u.procs receiver).accepted acked_p_or with is_from is_from;\n  rw is_from at merge_eq,\n  { have stored_proposed_at_u := (accepted_means_issued u u_r).left receiver stored merge_eq,\n    cases le_iff_lt_or_eq.mp stored_bal_larger,\n    { specialize hu b₁_choosable b₁_v₁_proposed stored.bal h stored.val stored_proposed_at_u,\n      exact eq.symm hu },\n    rw h at b₁_v₁_proposed_w,\n    exact proposals_unique w w_r stored.bal stored.val v₁ (proposed_stable stored.bal stored.val u w stored_proposed_at_u u_pn_w) b₁_v₁_proposed_w },\n  have stored_proposed_at_u : proposed u stored.bal stored.val, by\n  { apply (accepted_means_issued u u_r).right sender e he (u.procs receiver).curr stored,\n    rw e_msg_eq, rw merge_eq },\n  cases le_iff_lt_or_eq.mp stored_bal_larger,\n  { specialize hu b₁_choosable b₁_v₁_proposed stored.bal h stored.val stored_proposed_at_u,\n    exact eq.symm hu },\n  rw h at b₁_v₁_proposed_w,\n  exact proposals_unique w w_r stored.bal stored.val v₁ (proposed_stable stored.bal stored.val u w stored_proposed_at_u u_pn_w) b₁_v₁_proposed_w\n},\nhave u_curr_ballot_is_b₂: (u.procs receiver).curr = b₂, by {\n  rw ep_is at ep_is_proposal,\n  injection ep_is_proposal with proposals_eq,\n  injection proposals_eq\n},\nclear ep_is ep_is_proposal h_ep ep procs_same ntwks_same,\nrcases b₁_choosable with ⟨poss_voters, poss_voters_quorum, all_voted_or_may_vote⟩,\nrcases quorum_assumption.intersect poss_voters ((u.procs receiver).followers ∪ {sender}) poss_voters_quorum v_has_quorum with ⟨a, a_in_both⟩,\nrw finset.mem_inter at a_in_both,\ncases a_in_both with a_is_possible_voter a_is_follower,\nspecialize all_voted_or_may_vote a a_is_possible_voter, clear a_is_possible_voter,\nrw finset.mem_union at a_is_follower,\nclear poss_voters_quorum poss_voters,\ncases a_is_follower,\nswap,\n{ rw finset.mem_singleton at a_is_follower,\n  cases all_voted_or_may_vote with voted impossible,\n  { rw ← a_is_follower at he,\n    cases none_voted_between_p1b u u_r a b₁ (u.procs receiver).curr acked_p_or voted\n                                 ⟨e, he, e_msg_eq⟩,\n    { rw u_curr_ballot_is_b₂ at h, exact (not_le_of_lt ballot_order h).elim, },\n    rcases h with ⟨p, ack_eq, p_bal_ge⟩,\n    rw ack_eq,\n    rcases proposal.merge_ballot_ge_right (u.procs receiver).accepted p\n      with ⟨stored, stored_eq, stored_ge⟩,\n    exact ⟨stored, stored_eq, le_trans p_bal_ge stored_ge⟩ },\n  exfalso,\n  have key := ballot_ge_any_promised sender (u.procs receiver).curr acked_p_or u u_r ⟨e, he, e_msg_eq⟩,\n  rw a_is_follower at impossible,\n  rw u_curr_ballot_is_b₂ at key,\n  exact not_le_of_lt ballot_order (le_trans key impossible) },\nhave fact := followers_sent_p1b u u_r receiver active a a_is_follower,\nclear a_is_follower,\ncases fact,\n{ rw fact at all_voted_or_may_vote, clear fact a,\n  cases all_voted_or_may_vote with voted impossible,\n  { rcases accepted_ge_any_voted receiver b₁ u u_r voted\n      with ⟨old_stored, old_stored_eq, old_stored_ge⟩,\n    rw old_stored_eq, clear old_stored_eq,\n    rcases proposal.merge_ballot_ge_left old_stored acked_p_or\n      with ⟨stored, stored_eq, stored_ge⟩,\n    exact ⟨stored, stored_eq, le_trans old_stored_ge stored_ge⟩ },\n  rw u_curr_ballot_is_b₂ at impossible,\n  exfalso,\n  exact not_le_of_lt ballot_order impossible },\ncases fact,\n{ exfalso,\n  cases all_voted_or_may_vote with impossible impossible,\n  { cases none_voted_between_p1b u u_r a b₁ (u.procs receiver).curr none impossible fact,\n    { rw u_curr_ballot_is_b₂ at h,\n      exact not_le_of_lt ballot_order h },\n    rcases h with ⟨_, bad, _⟩, injection bad },\n  have key := ballot_ge_any_promised a (u.procs receiver).curr none u u_r fact,\n  rw u_curr_ballot_is_b₂ at key,\n  exact not_le_of_lt ballot_order (le_trans key impossible) },\nrcases fact with ⟨e', he', prop, e'_msg_eq, old_stored, accepted_eq_old_stored, old_stored_ge⟩,\nrw accepted_eq_old_stored,\ncases all_voted_or_may_vote with voted impossible,\n{ cases none_voted_between_p1b u u_r a b₁ (u.procs receiver).curr (some prop) voted ⟨e', he', e'_msg_eq⟩,\n  { rw u_curr_ballot_is_b₂ at h,\n    exact (not_le_of_lt ballot_order h).elim },\n  rcases h with ⟨p, p_eq_prop_tmp, p_ge_bal⟩,\n  have p_eq_prop : prop = p, by { injection p_eq_prop_tmp },\n  rw ← p_eq_prop at p_ge_bal,\n  clear p_eq_prop_tmp p_eq_prop p,\n  rcases proposal.merge_ballot_ge_left old_stored acked_p_or\n    with ⟨stored, stored_eq, ge_old_stored⟩,\n  exact ⟨stored, stored_eq, le_trans p_ge_bal (le_trans old_stored_ge ge_old_stored)⟩ },\nexfalso,\nhave key := ballot_ge_any_promised a (u.procs receiver).curr (some prop) u u_r ⟨e', he', e'_msg_eq⟩,\nrw u_curr_ballot_is_b₂ at key,\nexact not_le_of_lt ballot_order (le_trans key impossible)\nend\n\n-- The safety of paxos: if two values are chosen at a state, then both values are the same.\n--\n-- The argument is as follows: the values are chosen because two proposals are\n-- chosen. If the proposals have the same ballot, then they have the same value\n-- and we are done.\n--\n-- So assume they don't have the same ballot; then all we need to show is that\n-- if two proposals are chosen and one has a higher ballot than the other, then\n-- the two proposals have the same value. To do that, it suffices to show that\n-- if b < b' are ballots proposed with values v and v', and ballot b is chosen,\n-- then v = v' (regardless of whether ballot b' is chosen). This is shown in\n-- proposed_higher_than_chosen_has_same_val.\ntheorem at_most_one_value_chosen : predicate.invariant\n  (λ s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t),\n    safety s) :=\nbegin\nintros u u_r v v',\nrintros ⟨b, proposed_b_v, chosen_b⟩,\nrintros ⟨b', proposed_b'_v', chosen_b'⟩,\ncases lt_trichotomy b b' with b_lt_b' b_ge_b',\nswap,\ncases b_ge_b' with b_eq_b' b_gt_b',\n{ have proposed_b_v' : proposed u b v', by { rw b_eq_b', exact proposed_b'_v' },\n  exact proposals_unique u u_r b v v' proposed_b_v proposed_b_v' },\nswap,\n{ exact proposed_higher_than_chosen_has_same_val\n        u u_r b v chosen_b proposed_b_v b' b_lt_b' v' proposed_b'_v' },\nsymmetry,\nexact proposed_higher_than_chosen_has_same_val\n      u u_r b' v' chosen_b' proposed_b'_v' b b_gt_b' v proposed_b_v\nend\n", "meta": {"author": "gnanabite", "repo": "colocated-paxos", "sha": "f60308e27d3013665809077fe80a4b2af8a42278", "save_path": "github-repos/lean/gnanabite-colocated-paxos", "path": "github-repos/lean/gnanabite-colocated-paxos/colocated-paxos-f60308e27d3013665809077fe80a4b2af8a42278/src/implementation/proof/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4893996344918333}}
{"text": "import Src.Prover.Logic\n\nnamespace prover\nnoncomputable section\n\naxiom some {α : Type} [Inhabited α] (P : α → Prop) : α\naxiom some_spec {α : Type} [Inhabited α] {P : α → Prop}\n  (h : ∃ (x : α), P x) : P (some P)\n\ndef someu {α : Type} [Inhabited α] (P : α → Prop) : α :=\nsome # λ a => P a ∧ ∀ b, P b → b = a\n\ndef some' {α : Type} [Inhabited α] {P : α → Prop} (h : ∃ (x : α), P x) : α :=\nsome P\n\ndef someu' {α : Type} [Inhabited α] {P : α → Prop} (h : ∃! (x : α), P x) : α :=\nsomeu P\n\ntheorem someu_spec {α : Type} [Inhabited α] {P : α → Prop}\n  (h : ∃! (x : α), P x) : P (someu P) :=\nand_left # !some_spec # mp exiu_iff h\n\nsection Conditional\n\ntheorem exi_ite_val {α : Type} (P : Prop) (x y : α) :\n  ∃ (z : α), (P → z = x) ∧ (¬P → z = y) :=\nprop_rec (λ m => ∃ (z : α), (m → z = x) ∧ (¬m → z = y))\n(exi_intro x # and_intro (λ _ => rfl) (λ h => exfalso # h trivial))\n(exi_intro y # and_intro exfalso (λ _ => rfl))\n\ndef ite {α : Type} [Inhabited α] (P : Prop) (x y : α) : α :=\nsome' # exi_ite_val P x y\n\ntheorem if_pos {α : Type} [Inhabited α] {P : Prop} {x y : α} (h : P) : ite P x y = x :=\nand_left (!some_spec # exi_ite_val P x y) h\n\ntheorem if_neg {α : Type} [Inhabited α] {P : Prop} {x y : α} (h : ¬P) : ite P x y = y :=\nand_right (!some_spec # exi_ite_val P x y) h\n\ntheorem split_ifs {α : Type} [Inhabited α] (F : α → Prop) {P : Prop} {x y : α}\n  (h₁ : P → F x) (h₂ : ¬P → F y) : F (ite P x y) :=\nor_elim (@em P)\n(λ h₃ => eq_rec' F (if_pos h₃) # h₁ h₃)\n(λ h₃ => eq_rec' F (if_neg h₃) # h₂ h₃)\n\nend Conditional", "meta": {"author": "user7230724", "repo": "lean-projects4", "sha": "4a93eca4f46cbeb17796d746ab93c60bfb26a881", "save_path": "github-repos/lean/user7230724-lean-projects4", "path": "github-repos/lean/user7230724-lean-projects4/lean-projects4-4a93eca4f46cbeb17796d746ab93c60bfb26a881/Src/Prover/Choice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680199891789, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.48931483519985136}}
{"text": "/-\nCopyright (c) 2018 Alexander Bentkamp. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alexander Bentkamp\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.module.pi\nimport Mathlib.algebra.big_operators.basic\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\n/-!\n# Basic properties of holors\n\nHolors are indexed collections of tensor coefficients. Confusingly,\nthey are often called tensors in physics and in the neural network\ncommunity.\n\nA holor is simply a multidimensional array of values. The size of a\nholor is specified by a `list ℕ`, whose length is called the dimension\nof the holor.\n\nThe tensor product of `x₁ : holor α ds₁` and `x₂ : holor α ds₂` is the\nholor given by `(x₁ ⊗ x₂) (i₁ ++ i₂) = x₁ i₁ * x₂ i₂`. A holor is \"of\nrank at most 1\" if it is a tensor product of one-dimensional holors.\nThe CP rank of a holor `x` is the smallest N such that `x` is the sum\nof N holors of rank at most 1.\n\nBased on the tensor library found in <https://www.isa-afp.org/entries/Deep_Learning.html>\n\n## References\n\n* <https://en.wikipedia.org/wiki/Tensor_rank_decomposition>\n-/\n\n/-- `holor_index ds` is the type of valid index tuples to identify an entry of a holor of dimensions `ds` -/\ndef holor_index (ds : List ℕ) :=\n  Subtype fun (is : List ℕ) => list.forall₂ Less is ds\n\nnamespace holor_index\n\n\ndef take {ds₂ : List ℕ} {ds₁ : List ℕ} : holor_index (ds₁ ++ ds₂) → holor_index ds₁ :=\n  sorry\n\ndef drop {ds₂ : List ℕ} {ds₁ : List ℕ} : holor_index (ds₁ ++ ds₂) → holor_index ds₂ :=\n  sorry\n\ntheorem cast_type {ds₁ : List ℕ} {ds₂ : List ℕ} (is : List ℕ) (eq : ds₁ = ds₂) (h : list.forall₂ Less is ds₁) : subtype.val (cast (congr_arg holor_index eq) { val := is, property := h }) = is :=\n  eq.drec (Eq.refl (subtype.val (cast (congr_arg holor_index (Eq.refl ds₁)) { val := is, property := h }))) eq\n\ndef assoc_right {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} : holor_index (ds₁ ++ ds₂ ++ ds₃) → holor_index (ds₁ ++ (ds₂ ++ ds₃)) :=\n  cast sorry\n\ndef assoc_left {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} : holor_index (ds₁ ++ (ds₂ ++ ds₃)) → holor_index (ds₁ ++ ds₂ ++ ds₃) :=\n  cast sorry\n\ntheorem take_take {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} (t : holor_index (ds₁ ++ ds₂ ++ ds₃)) : take (assoc_right t) = take (take t) := sorry\n\ntheorem drop_take {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} (t : holor_index (ds₁ ++ ds₂ ++ ds₃)) : take (drop (assoc_right t)) = drop (take t) := sorry\n\ntheorem drop_drop {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} (t : holor_index (ds₁ ++ ds₂ ++ ds₃)) : drop (drop (assoc_right t)) = drop t := sorry\n\nend holor_index\n\n\n/-- Holor (indexed collections of tensor coefficients) -/\ndef holor (α : Type u) (ds : List ℕ) :=\n  holor_index ds → α\n\nnamespace holor\n\n\nprotected instance inhabited {α : Type} {ds : List ℕ} [Inhabited α] : Inhabited (holor α ds) :=\n  { default := fun (t : holor_index ds) => Inhabited.default }\n\nprotected instance has_zero {α : Type} {ds : List ℕ} [HasZero α] : HasZero (holor α ds) :=\n  { zero := fun (t : holor_index ds) => 0 }\n\nprotected instance has_add {α : Type} {ds : List ℕ} [Add α] : Add (holor α ds) :=\n  { add := fun (x y : holor α ds) (t : holor_index ds) => x t + y t }\n\nprotected instance has_neg {α : Type} {ds : List ℕ} [Neg α] : Neg (holor α ds) :=\n  { neg := fun (a : holor α ds) (t : holor_index ds) => -a t }\n\nprotected instance add_semigroup {α : Type} {ds : List ℕ} [add_semigroup α] : add_semigroup (holor α ds) :=\n  add_semigroup.mk (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_semigroup.add (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2))\n    sorry\n\nprotected instance add_comm_semigroup {α : Type} {ds : List ℕ} [add_comm_semigroup α] : add_comm_semigroup (holor α ds) :=\n  add_comm_semigroup.mk\n    (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_comm_semigroup.add (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2)) sorry sorry\n\nprotected instance add_monoid {α : Type} {ds : List ℕ} [add_monoid α] : add_monoid (holor α ds) :=\n  add_monoid.mk (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_monoid.add (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2)) sorry\n    (id fun (ᾰ : holor_index ds) => add_monoid.zero) sorry sorry\n\nprotected instance add_comm_monoid {α : Type} {ds : List ℕ} [add_comm_monoid α] : add_comm_monoid (holor α ds) :=\n  add_comm_monoid.mk (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_comm_monoid.add (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2))\n    sorry (id fun (ᾰ : holor_index ds) => add_comm_monoid.zero) sorry sorry sorry\n\nprotected instance add_group {α : Type} {ds : List ℕ} [add_group α] : add_group (holor α ds) :=\n  add_group.mk (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_group.add (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2)) sorry\n    (id fun (ᾰ : holor_index ds) => add_group.zero) sorry sorry\n    (fun (ᾰ : holor α ds) => id fun (ᾰ_1 : holor_index ds) => add_group.neg (ᾰ ᾰ_1))\n    (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_group.sub (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2)) sorry\n\nprotected instance add_comm_group {α : Type} {ds : List ℕ} [add_comm_group α] : add_comm_group (holor α ds) :=\n  add_comm_group.mk (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_comm_group.add (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2))\n    sorry (id fun (ᾰ : holor_index ds) => add_comm_group.zero) sorry sorry\n    (fun (ᾰ : holor α ds) => id fun (ᾰ_1 : holor_index ds) => add_comm_group.neg (ᾰ ᾰ_1))\n    (fun (ᾰ ᾰ_1 : holor α ds) => id fun (ᾰ_2 : holor_index ds) => add_comm_group.sub (ᾰ ᾰ_2) (ᾰ_1 ᾰ_2)) sorry sorry\n\n/- scalar product -/\n\nprotected instance has_scalar {α : Type} {ds : List ℕ} [Mul α] : has_scalar α (holor α ds) :=\n  has_scalar.mk fun (a : α) (x : holor α ds) (t : holor_index ds) => a * x t\n\nprotected instance semimodule {α : Type} {ds : List ℕ} [semiring α] : semimodule α (holor α ds) :=\n  pi.semimodule (holor_index ds) (fun (ᾰ : holor_index ds) => α) α\n\n/-- The tensor product of two holors. -/\ndef mul {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} [s : Mul α] (x : holor α ds₁) (y : holor α ds₂) : holor α (ds₁ ++ ds₂) :=\n  fun (t : holor_index (ds₁ ++ ds₂)) => x (holor_index.take t) * y (holor_index.drop t)\n\ntheorem cast_type {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} (eq : ds₁ = ds₂) (a : holor α ds₁) : cast (congr_arg (holor α) eq) a = fun (t : holor_index ds₂) => a (cast (congr_arg holor_index (Eq.symm eq)) t) :=\n  eq.drec (Eq.refl (cast (congr_arg (holor α) (Eq.refl ds₁)) a)) eq\n\ndef assoc_right {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} : holor α (ds₁ ++ ds₂ ++ ds₃) → holor α (ds₁ ++ (ds₂ ++ ds₃)) :=\n  cast sorry\n\ndef assoc_left {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} : holor α (ds₁ ++ (ds₂ ++ ds₃)) → holor α (ds₁ ++ ds₂ ++ ds₃) :=\n  cast sorry\n\ntheorem mul_assoc0 {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} [semigroup α] (x : holor α ds₁) (y : holor α ds₂) (z : holor α ds₃) : mul (mul x y) z = assoc_left (mul x (mul y z)) := sorry\n\ntheorem mul_assoc {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} {ds₃ : List ℕ} [semigroup α] (x : holor α ds₁) (y : holor α ds₂) (z : holor α ds₃) : mul (mul x y) z == mul x (mul y z) := sorry\n\ntheorem mul_left_distrib {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} [distrib α] (x : holor α ds₁) (y : holor α ds₂) (z : holor α ds₂) : mul x (y + z) = mul x y + mul x z :=\n  funext\n    fun (t : holor_index (ds₁ ++ ds₂)) =>\n      left_distrib (x (holor_index.take t)) (y (holor_index.drop t)) (z (holor_index.drop t))\n\ntheorem mul_right_distrib {α : Type} {ds₁ : List ℕ} {ds₂ : List ℕ} [distrib α] (x : holor α ds₁) (y : holor α ds₁) (z : holor α ds₂) : mul (x + y) z = mul x z + mul y z :=\n  funext\n    fun (t : holor_index (ds₁ ++ ds₂)) =>\n      right_distrib (x (holor_index.take t)) (y (holor_index.take t)) (z (holor_index.drop t))\n\n@[simp] theorem zero_mul {ds₁ : List ℕ} {ds₂ : List ℕ} {α : Type} [ring α] (x : holor α ds₂) : mul 0 x = 0 :=\n  funext fun (t : holor_index (ds₁ ++ ds₂)) => zero_mul (x (holor_index.drop t))\n\n@[simp] theorem mul_zero {ds₁ : List ℕ} {ds₂ : List ℕ} {α : Type} [ring α] (x : holor α ds₁) : mul x 0 = 0 :=\n  funext fun (t : holor_index (ds₁ ++ ds₂)) => mul_zero (x (holor_index.take t))\n\ntheorem mul_scalar_mul {α : Type} {ds : List ℕ} [monoid α] (x : holor α []) (y : holor α ds) : mul x y = x { val := [], property := list.forall₂.nil } • y := sorry\n\n/- holor slices -/\n\n/-- A slice is a subholor consisting of all entries with initial index i. -/\ndef slice {α : Type} {d : ℕ} {ds : List ℕ} (x : holor α (d :: ds)) (i : ℕ) (h : i < d) : holor α ds :=\n  fun (is : holor_index ds) => x { val := i :: subtype.val is, property := sorry }\n\n/-- The 1-dimensional \"unit\" holor with 1 in the `j`th position. -/\ndef unit_vec {α : Type} [monoid α] [add_monoid α] (d : ℕ) (j : ℕ) : holor α [d] :=\n  fun (ti : holor_index [d]) => ite (subtype.val ti = [j]) 1 0\n\ntheorem holor_index_cons_decomp {d : ℕ} {ds : List ℕ} (p : holor_index (d :: ds) → Prop) (t : holor_index (d :: ds)) : (∀ (i : ℕ) (is : List ℕ) (h : subtype.val t = i :: is),\n    p\n      { val := i :: is,\n        property :=\n          eq.mpr (id (Eq._oldrec (Eq.refl (list.forall₂ Less (i :: is) (d :: ds))) (Eq.symm h)))\n            (subtype.property t) }) →\n  p t := sorry\n\n/-- Two holors are equal if all their slices are equal. -/\ntheorem slice_eq {α : Type} {d : ℕ} {ds : List ℕ} (x : holor α (d :: ds)) (y : holor α (d :: ds)) (h : slice x = slice y) : x = y := sorry\n\ntheorem slice_unit_vec_mul {α : Type} {d : ℕ} {ds : List ℕ} [ring α] {i : ℕ} {j : ℕ} (hid : i < d) (x : holor α ds) : slice (mul (unit_vec d j) x) i hid = ite (i = j) x 0 := sorry\n\ntheorem slice_add {α : Type} {d : ℕ} {ds : List ℕ} [Add α] (i : ℕ) (hid : i < d) (x : holor α (d :: ds)) (y : holor α (d :: ds)) : slice x i hid + slice y i hid = slice (x + y) i hid := sorry\n\ntheorem slice_zero {α : Type} {d : ℕ} {ds : List ℕ} [HasZero α] (i : ℕ) (hid : i < d) : slice 0 i hid = 0 :=\n  rfl\n\ntheorem slice_sum {α : Type} {d : ℕ} {ds : List ℕ} [add_comm_monoid α] {β : Type} (i : ℕ) (hid : i < d) (s : finset β) (f : β → holor α (d :: ds)) : (finset.sum s fun (x : β) => slice (f x) i hid) = slice (finset.sum s fun (x : β) => f x) i hid := sorry\n\n/-- The original holor can be recovered from its slices by multiplying with unit vectors and summing up. -/\n@[simp] theorem sum_unit_vec_mul_slice {α : Type} {d : ℕ} {ds : List ℕ} [ring α] (x : holor α (d :: ds)) : (finset.sum (finset.attach (finset.range d))\n    fun (i : Subtype fun (x : ℕ) => x ∈ finset.range d) =>\n      mul (unit_vec d ↑i) (slice x (↑i) (nat.succ_le_of_lt (iff.mp finset.mem_range (subtype.prop i))))) =\n  x := sorry\n\n/- CP rank -/\n\n/-- `cprank_max1 x` means `x` has CP rank at most 1, that is,\n  it is the tensor product of 1-dimensional holors. -/\ninductive cprank_max1 {α : Type} [Mul α] : {ds : List ℕ} → holor α ds → Prop\nwhere\n| nil : ∀ (x : holor α []), cprank_max1 x\n| cons : ∀ {d : ℕ} {ds : List ℕ} (x : holor α [d]) (y : holor α ds), cprank_max1 y → cprank_max1 (mul x y)\n\n/-- `cprank_max N x` means `x` has CP rank at most `N`, that is,\n  it can be written as the sum of N holors of rank at most 1. -/\ninductive cprank_max {α : Type} [Mul α] [add_monoid α] : ℕ → {ds : List ℕ} → holor α ds → Prop\nwhere\n| zero : ∀ {ds : List ℕ}, cprank_max 0 0\n| succ : ∀ (n : ℕ) {ds : List ℕ} (x y : holor α ds), cprank_max1 x → cprank_max n y → cprank_max (n + 1) (x + y)\n\ntheorem cprank_max_nil {α : Type} [monoid α] [add_monoid α] (x : holor α []) : cprank_max 1 x := sorry\n\ntheorem cprank_max_1 {α : Type} {ds : List ℕ} [monoid α] [add_monoid α] {x : holor α ds} (h : cprank_max1 x) : cprank_max 1 x := sorry\n\ntheorem cprank_max_add {α : Type} {ds : List ℕ} [monoid α] [add_monoid α] {m : ℕ} {n : ℕ} {x : holor α ds} {y : holor α ds} : cprank_max m x → cprank_max n y → cprank_max (m + n) (x + y) := sorry\n\ntheorem cprank_max_mul {α : Type} {d : ℕ} {ds : List ℕ} [ring α] (n : ℕ) (x : holor α [d]) (y : holor α ds) : cprank_max n y → cprank_max n (mul x y) := sorry\n\ntheorem cprank_max_sum {α : Type} {ds : List ℕ} [ring α] {β : Type u_1} {n : ℕ} (s : finset β) (f : β → holor α ds) : (∀ (x : β), x ∈ s → cprank_max n (f x)) → cprank_max (finset.card s * n) (finset.sum s fun (x : β) => f x) := sorry\n\ntheorem cprank_max_upper_bound {α : Type} [ring α] {ds : List ℕ} (x : holor α ds) : cprank_max (list.prod ds) x := sorry\n\n/-- The CP rank of a holor `x`: the smallest N such that\n  `x` can be written as the sum of N holors of rank at most 1. -/\ndef cprank {α : Type} {ds : List ℕ} [ring α] (x : holor α ds) : ℕ :=\n  nat.find sorry\n\ntheorem cprank_upper_bound {α : Type} [ring α] {ds : List ℕ} (x : holor α ds) : cprank x ≤ list.prod ds :=\n  nat.find_min'\n    (Exists.intro (list.prod ds) ((fun (this : cprank_max (list.prod ds) x) => this) (cprank_max_upper_bound x)))\n    (cprank_max_upper_bound x)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/holor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680199891789, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.48931483519985136}}
{"text": "import analysis.special_functions.pow\n\nimport to_mathlib.logic.basic\nimport to_mathlib.data.nat.basic\nimport to_mathlib.topology.germ\nimport to_mathlib.order.filter.basic\n\nimport notations\nimport indexing\n\nnoncomputable theory\n\nopen set filter\nopen_locale topology\n\nprivate def T : ℕ → ℝ := λ n, nat.rec 0 (λ k x, x + 1/(2 : ℝ)^(k+1)) n\n\nopen_locale big_operators\n\n-- Note this is more painful than Patrick hoped for. Maybe this should be the definition of T.\nprivate lemma T_eq (n : ℕ) : T n = 1- (1/(2: ℝ))^n :=\nbegin\n  have : T n = ∑ k in finset.range n, 1/(2: ℝ)^(k+1),\n  { induction n with n hn,\n    { simp only [T, finset.range_zero, finset.sum_empty] },\n    change T n + _ = _,\n    rw [hn, finset.sum_range_succ] },\n  simp_rw [this, ← one_div_pow, pow_succ, ← finset.mul_sum, geom_sum_eq (by norm_num : 1/(2:ℝ) ≠ 1) n],\n  field_simp,\n  norm_num,\n  apply div_eq_of_eq_mul,\n  apply neg_ne_zero.mpr,\n  apply ne_of_gt,\n  positivity,\n  ring\nend\n\nprivate lemma T_lt (n : ℕ) : T n < 1 :=\nbegin\n  rw T_eq,\n  have : (0 : ℝ) < (1 / 2) ^ n, by positivity,\n  linarith\nend\n\nprivate lemma T_lt_succ (n : ℕ) : T n < T (n+1) :=\nlt_add_of_le_of_pos le_rfl (one_div_pos.mpr (pow_pos zero_lt_two _))\n\nprivate lemma T_le_succ (n : ℕ) : T n ≤ T (n+1) := (T_lt_succ n).le\n\nprivate lemma T_succ_sub (n : ℕ) : T (n+1) - T n = 1/2^(n+1) :=\nbegin\n  change T n + _ - T n = _,\n  simp\nend\n\nprivate lemma mul_T_succ_sub (n : ℕ) : 2^(n+1)*(T (n+1) - T n) = 1 :=\nbegin\n  rw T_succ_sub,\n  field_simp\nend\n\nprivate lemma T_one : T 1 = 1/2 :=\nby simp [T]\n\nprivate lemma not_T_succ_le (n : ℕ) : ¬ T (n + 1) ≤ 0 :=\nbegin\n  rw [T_eq, not_le],\n  have : (1 / (2 : ℝ)) ^ (n + 1) < 1,\n  apply pow_lt_one ; norm_num,\n  linarith,\nend\n\nlemma inductive_htpy_construction_aux {X Y : Type*} [topological_space X]\n  {N : ℕ} {U K : index_type N → set X}\n  (P₀ P₁ : Π x : X, germ (𝓝 x) Y → Prop) (P₂ : Π p : ℝ × X, germ (𝓝 p) Y → Prop)\n  (hP₂ : ∀ a b (p : ℝ × X) (f : ℝ × X → Y), P₂ (a*p.1+b, p.2) f → P₂ p (λ p : ℝ × X, f (a*p.1+b, p.2)))\n  {f₀ : X → Y} (init : ∀ x, P₀ x f₀)\n  (ind : ∀ (i : index_type N) (f : X → Y), (∀ x, P₀ x f) → (∀ᶠ x near ⋃ j < i, K j, P₁ x f) →\n    ∃ F : ℝ → X → Y, (∀ t, ∀ x, P₀ x $ F t) ∧ (∀ᶠ x near ⋃ j ≤ i, K j, P₁ x $ F 1) ∧\n                     (∀ p, P₂ p ↿F) ∧ (∀ t, ∀ x ∉ U i, F t x = f x) ∧\n                     (∀ᶠ t near Iic 0, F t = f) ∧ (∀ᶠ t near Ici 1, F t = F 1)) :\n  ∃ f : ℕ → ℝ × X → Y, ∀ n,\n    ((∀ p : ℝ × X, P₀ p.2 (filter.germ.slice_right (f n)) ∧ P₂ p (f n)) ∧\n    (∀ᶠ x near (⋃ i ≤ (n : index_type N) , K i), P₁ x (filter.germ.slice_right (f n : (𝓝 (T (n+1), x)).germ Y))) ∧\n    (∀ t ≥ T (n+1), ∀ x, f n (t, x) = f n (T (n+1), x)) ∧ (∀ x, f n (0, x) = f₀ x) ∧\n    (∀ᶠ t in 𝓝 (T $ n+1), ∀ x, f n (t, x) = f n (T (n+1), x))) ∧\n    ((((n+1:ℕ) : index_type N) = n → f (n+1) = f n) ∧\n      ∀ x ∉ U (n + 1 : ℕ), ∀ t, f (n+1) (t, x) = f n (t, x))\n   :=\nbegin\n  let P₀' : Π p : ℝ × X, germ (𝓝 p) Y → Prop := λ p φ, P₀ p.2 φ.slice_right ∧ P₂ p φ,\n  let P₁' : Π p : ℝ × X, germ (𝓝 p) Y → Prop := λ p φ, P₁ p.2 φ.slice_right,\n  let P : ℕ → (ℝ × X → Y) → Prop :=\n    λ n f, (∀ p, P₀' p f) ∧ (∀ᶠ x near (⋃ i ≤ (n : index_type N) , K i), P₁' (T (n+1), x) f) ∧\n           (∀ t ≥ T (n+1), ∀ x, f (t, x) = f (T (n+1), x)) ∧ (∀ x, f (0, x) = f₀ x) ∧\n           (∀ᶠ t in 𝓝 (T $ n+1), ∀ x, f (t, x) = f (T (n+1), x)),\n  let Q : ℕ → (ℝ × X → Y) → (ℝ × X → Y) → Prop :=\n    λ n f f', ((((n+1:ℕ) : index_type N) = n) → f' = f) ∧\n              (∀ x ∉ U (n + 1 : ℕ), ∀ t, f' (t, x) = f (t, x)),\n  change ∃ f : ℕ → ℝ × X → Y, ∀ n, P n (f n) ∧ Q n (f n) (f $ n + 1),\n  apply exists_by_induction',\n  { dsimp only [P],\n    rcases ind 0 f₀ init _ with ⟨f', h₀f', h₁f', hf'₂, hf'not, hf'0, hf'1⟩,\n    refine ⟨λ p, f' (2*p.1) p.2, λ p, ⟨_, _⟩, _, _, _, _⟩,\n    { exact h₀f' (2*p.1) p.2 },\n    { simpa using hP₂ 2 0 p ↿f' (hf'₂ _) },\n    { apply h₁f'.mono,\n      intros x hx,\n      change P₁ x (λ x' : X, f' (2*T (0 + 1)) x'),\n      simpa [T] using hx },\n    { simp only [T, zero_add, one_div, nat.rec_add_one, algebra_map.coe_zero, nat.rec_zero,\n                  pow_one, real.rpow_one, ge_iff_le, mul_inv_cancel_of_invertible],\n      intros t ht x,\n      rw ← hf'1.on_set (2*t) _,\n      change 1 ≤ 2*t,\n      field_simp at ht,\n      linarith only [ht] },\n    { intros x,\n      rw hf'0.on_set,\n      simp },\n    { dsimp only,\n      have : 2 * T (0 + 1) = 1, by simp [T_one],\n      rw [this, zero_add],\n      have : 𝓝 (1 : ℝ) ≤ 𝓝ˢ (Ici 1),\n            { exact nhds_le_nhds_set left_mem_Ici },\n      have : f' =ᶠ[𝓝 1] λ t, f' 1 := hf'1.filter_mono this,\n      have lim : tendsto (λ t : ℝ, 2*t) (𝓝 $ T 1) (𝓝 1),\n      { rw [T_one],\n        convert tendsto_id.const_mul (2 : ℝ),\n        simp },\n      apply (this.comp_fun lim).mono (λ t ht, _),\n      intro x',\n      apply congr_fun ht },\n    { simp [index_type.not_lt_zero] } },\n  { rintros n f ⟨h₀'f, h₁f, hinvf, hf0, hfTn1⟩,\n    rcases index_type.lt_or_eq_succ N n with hn | hn,\n    { simp_rw index_type.le_or_lt_succ hn at h₁f,\n      rcases ind (n+1 : ℕ) (λ x, f (T (n+1), x)) (λ x, (h₀'f (T (n+1), x)).1) h₁f with\n        ⟨f', h₀f', h₁f', hf'₂, hf'not, hf'0, hf'1⟩,\n      refine ⟨λ p, if p.1 ≥ T (n+1) then f' (2^(n+2)*(p.1 - T (n+1))) p.2 else f p, ⟨λ p, ⟨_, _⟩, _, _, _, _⟩, _, _⟩,\n      { by_cases ht : (T $ n+1) ≤ p.1,\n        { convert h₀f' (2^(n+2)*(p.1-T (n+1))) p.2 using 1,\n          apply quotient.sound,\n          simp [ht] },\n        { convert (h₀'f p).1 using 1,\n          apply quotient.sound,\n          simp [ht] } },\n      { rcases lt_trichotomy (T $ n+1) p.1 with ht|ht|ht,\n        { convert hP₂ (2^(n+2)) (-2^(n+2)*T (n+1)) p ↿f' (hf'₂ _) using 1,\n          apply quotient.sound,\n          have hp : ∀ᶠ (q : ℝ × X) in 𝓝 p, T (n+1) ≤ q.1,\n          { cases p with t x,\n            apply mem_of_superset (prod_mem_nhds (Ioi_mem_nhds ht) univ_mem),\n            rintros ⟨t', x'⟩ ⟨ht', hx'⟩,\n            exact le_of_lt ht' },\n          apply hp.mono (λ q hq, _),\n          simp [if_pos hq, mul_sub, neg_mul],\n          refl },\n        { let g : ℝ × X → Y := λ p, f' (2 ^ (n + 2) * (p.fst - T (n + 1))) p.snd,\n          have hg : P₂ p g,\n          { convert hP₂ (2^(n+2)) (-2^(n+2)*T (n+1)) p ↿f' (hf'₂ _) using 2,\n            ext q,\n            dsimp only [g],\n            ring_nf },\n          convert hg using 1,\n          apply quotient.sound,\n          apply filter.eventually_eq.eventually_eq_ite,\n          cases p with t x,\n          have hf : f =ᶠ[𝓝 (t, x)] λ q : ℝ × X, f (T (n + 1), q.2),\n          { change T (n+1) = t at ht,\n            rw ← ht,\n            apply mem_of_superset (prod_mem_nhds hfTn1 univ_mem),\n            rintros ⟨t', x'⟩ ⟨ht', hx'⟩,\n            exact ht' x' },\n          replace hf'0 : ↿f' =ᶠ[𝓝 (0, x)] λ q : ℝ × X, f (T (n + 1), q.2),\n          { have : 𝓝 (0 : ℝ) ≤ 𝓝ˢ (Iic 0),\n            { exact nhds_le_nhds_set right_mem_Iic },\n            apply mem_of_superset (prod_mem_nhds (hf'0.filter_mono this) univ_mem),\n            rintros ⟨t', x'⟩ ⟨ht', hx'⟩,\n            exact (congr_fun ht' x' : _) },\n          have : tendsto (λ (x : ℝ × X), (2 ^ (n + 2) * (x.1 - T (n + 1)), x.2)) (𝓝 (t, x)) (𝓝 (0, x)),\n          { rw [nhds_prod_eq, nhds_prod_eq],\n            have limt : tendsto (λ t, 2 ^ (n + 2) * (t - T (n + 1))) (𝓝 t) (𝓝 0),\n            { rw [show (0 : ℝ) = 2^(n+2)*(T (n+1) - T (n+1)), by simp, ht],\n              apply tendsto.const_mul,\n              exact tendsto_id.sub_const _ },\n            exact limt.prod_map tendsto_id },\n          have := hf'0.comp_fun this,\n          rw show (λ (q : ℝ × X), f (T (n + 1), q.2)) ∘\n            (λ (x : ℝ × X), (2 ^ (n + 2) * (x.1 - T (n + 1)), x.2)) =\n            λ q : ℝ × X, f (T (n + 1), q.2),\n          by { ext, refl } at this,\n          exact this.trans hf.symm },\n        { have hp : ∀ᶠ (q : ℝ × X) in 𝓝 p, ¬ T (n+1) ≤ q.1,\n          { cases p with t x,\n            apply mem_of_superset (prod_mem_nhds (Iio_mem_nhds ht) univ_mem),\n            rintros ⟨t', x'⟩ ⟨ht', hx'⟩,\n            simpa using ht' },\n          convert (h₀'f p).2 using 1,\n          apply quotient.sound,\n          apply hp.mono (λ q hq, _),\n          simp [if_neg hq] } },\n      { apply h₁f'.mono,\n        intros x hx,\n        change P₁ x (λ x', if T (n+2) ≥ T (n+1) then f' (2^(n+2)*(T (n+2) - T (n+1))) x' else _),\n        convert hx using 2,\n        ext x',\n        simp [if_pos (T_le_succ $ n+1), T_succ_sub] },\n      { rintros t ht x,\n        dsimp only,\n        simp only [if_pos ((T_le_succ $ n+1).trans ht), if_pos (T_le_succ $ n+1),\n                    T_succ_sub, one_div, mul_inv_cancel_of_invertible],\n        replace ht : 1 / 2 ^ (n + 2) ≤ t - T (n+1) := le_sub_iff_add_le'.mpr ht,\n        rw ← hf'1.on_set _ _,\n        exact (div_le_iff' (by positivity)).mp ht },\n      { intros x,\n        simp [not_T_succ_le, hf0] },\n      { suffices : (λ t x, f' (2 ^ (n + 2) * (t - T (n + 1))) x) =ᶠ[𝓝 (T (n + 2))] (λ t x, f' (2 ^ (n + 2) * (T (n+2) - T (n + 1))) x),\n        { have hle : ∀ᶠ (t : ℝ) in 𝓝 (T (n + 1 + 1)), t ≥ T (n+1),\n            from eventually_ge_of_tendsto_gt (T_lt_succ _) tendsto_id,\n          apply (hle.and this).mono,\n          rintros t ⟨ht, ht'⟩ x,\n          dsimp only,\n          rw [if_pos ht, if_pos (T_le_succ _)],\n          apply congr_fun ht' },\n        have : 𝓝 (1 : ℝ) ≤ 𝓝ˢ (Ici 1),\n            { exact nhds_le_nhds_set left_mem_Ici },\n        rw mul_T_succ_sub,\n        have : f' =ᶠ[𝓝 1] λ t, f' 1 := hf'1.filter_mono this,\n        apply this.comp_fun,\n        conv { congr, congr, skip, rw ← mul_T_succ_sub (n+1) },\n        exact (tendsto_id.sub_const _).const_mul _ },\n      { exact λ hn', (hn.ne hn'.symm).elim },\n      { intros x hx t,\n        dsimp only,\n        split_ifs with ht,\n        { rw [hf'not _ _ hx, hinvf _ ht] },\n        { refl }, } },\n    { simp only [hn] at h₁f,\n      refine ⟨f, ⟨h₀'f, _, _, hf0, _⟩, _, _⟩,\n      { apply h₁f.mono,\n        intros x hx,\n        change P₁ x (λ x, f (T (n+2), x)),\n        convert hx using 2,\n        ext x',\n        apply  hinvf,\n        apply T_le_succ },\n      { intros t ht x,\n        rw [hinvf (T $ n+1+1) (T_le_succ _), hinvf _ ((T_le_succ $ n+1).trans ht)] },\n      { have hle : ∀ᶠ (t : ℝ) in 𝓝 (T (n + 1 + 1)), t ≥ T (n+1),\n            from eventually_ge_of_tendsto_gt (T_lt_succ _) tendsto_id,\n        apply hle.mono (λ t ht, _),\n        intro x,\n        rw [hinvf t ht, hinvf (T $ n+2) (T_le_succ _)] },\n      { simp },\n      { simp } } }\nend\n\n/- TODO: think whether `∀ x ∈ ⋃ j < i, K j, P₁ x f` should be something more general. -/\nlemma inductive_htpy_construction {X Y : Type*} [topological_space X]\n  {N : ℕ} {U K : index_type N → set X}\n  (P₀ P₁ : Π x : X, germ (𝓝 x) Y → Prop) (P₂ : Π p : ℝ × X, germ (𝓝 p) Y → Prop)\n  (hP₂ : ∀ a b (p : ℝ × X) (f : ℝ × X → Y), P₂ (a*p.1+b, p.2) f → P₂ p (λ p : ℝ × X, f (a*p.1+b, p.2)))\n  (U_fin : locally_finite U) (K_cover : (⋃ i, K i) = univ)\n  {f₀ : X → Y} (init : ∀ x, P₀ x f₀)\n  (ind : ∀ (i : index_type N) (f : X → Y), (∀ x, P₀ x f) → (∀ᶠ x near ⋃ j < i, K j, P₁ x f) →\n    ∃ F : ℝ → X → Y, (∀ t, ∀ x, P₀ x $ F t) ∧ (∀ᶠ x near ⋃ j ≤ i, K j, P₁ x $ F 1) ∧\n                     (∀ p, P₂ p ↿F) ∧ (∀ t, ∀ x ∉ U i, F t x = f x) ∧\n                     (∀ᶠ t near Iic 0, F t = f) ∧ (∀ᶠ t near Ici 1, F t = F 1)) :\n  ∃ F : ℝ → X → Y, F 0 = f₀ ∧ (∀ t x, P₀ x (F t)) ∧ (∀ x, P₁ x (F 1)) ∧ (∀ p, P₂ p ↿F) :=\nbegin\n  let P₀' : Π p : ℝ × X, germ (𝓝 p) Y → Prop := λ p φ, P₀ p.2 φ.slice_right ∧ P₂ p φ,\n  let P₁' : Π p : ℝ × X, germ (𝓝 p) Y → Prop := λ p φ, P₁ p.2 φ.slice_right,\n  let P : ℕ → (ℝ × X → Y) → Prop :=\n    λ n f, (∀ p, P₀' p f) ∧ (∀ᶠ x near (⋃ i ≤ (n : index_type N) , K i), P₁' (T (n+1), x) f) ∧\n           (∀ t ≥ T (n+1), ∀ x, f (t, x) = f (T (n+1), x)) ∧ (∀ x, f (0, x) = f₀ x) ∧\n           (∀ᶠ t in 𝓝 (T $ n+1), ∀ x, f (t, x) = f (T (n+1), x)),\n  let Q : ℕ → (ℝ × X → Y) → (ℝ × X → Y) → Prop :=\n    λ n f f', ((((n+1:ℕ) : index_type N) = n) → f' = f) ∧\n              (∀ x ∉ U (n + 1 : ℕ), ∀ t, f' (t, x) = f (t, x)),\n  obtain ⟨f, hf⟩ : ∃ f : ℕ → ℝ × X → Y, ∀ n, P n (f n) ∧ Q n (f n) (f $ n + 1),\n  { apply inductive_htpy_construction_aux; assumption },\n  simp only [P, Q, forall_and_distrib, forall₂_and_distrib] at hf,\n  rcases hf with ⟨⟨⟨h₀f, h₂f⟩, h₁f, hinvf, hf0, hfTsucc⟩, hf₁, hf₃⟩,\n  choose W W_in hW using U_fin,\n  choose i₀ hi₀ using λ x, (hW x).bdd_above,\n  have : ∀ x, ∃ n : ℕ, x ∈ K n,\n  { intros x,\n    rcases eq_univ_iff_forall.mp K_cover x with ⟨-, ⟨i, rfl⟩, hi⟩,\n    use indexing.to_nat i,\n    simpa using hi },\n  choose nK hnK using this,\n  let n₀ : X → ℕ := λ x, max (nK x) (indexing.to_nat (i₀ x)),\n  have key : ∀ {x : X} {n}, n ≥ n₀ x → ∀ {q : ℝ × X}, q.2 ∈ W x → f n q = f (n₀ x) q,\n  { intros x₀ n hn,\n    rcases le_iff_exists_add.mp hn with ⟨k, rfl⟩, clear hn,\n    rintros ⟨t, x⟩ (hx : x ∈ _),\n    induction k with k hk,\n    { rw add_zero },\n    rw ← hk, clear hk,\n    let π :  ℕ → index_type N := indexing.from_nat,\n    have : ∀ n, π n < π (n+1) ∨ π n = π (n+1),\n    exact λ n, lt_or_eq_of_le (indexing.mono_from n.le_succ),\n    rcases this (n₀ x₀ + k) with H | H ; clear this,\n    { have ineq : i₀ x₀ < π (n₀ x₀ + k + 1),\n      { suffices : i₀ x₀ ≤ π (n₀ x₀ + k), from lt_of_le_of_lt this H,\n        rw ← indexing.from_to (i₀ x₀),\n        exact indexing.mono_from ((le_max_right _ _).trans le_self_add) },\n      apply hf₃,\n      intros hx',\n      exact lt_irrefl _ (ineq.trans_le $ hi₀ x₀ ⟨x, ⟨hx', hx⟩⟩) },\n    { rw [← nat.add_one, ← add_assoc, hf₁ _ H.symm] } },\n  have key' : ∀ p : ℝ × X, ∀ n ≥ n₀ p.2, f n =ᶠ[𝓝 p] λ q, f (n₀ q.2) q,\n  { rintros ⟨t, x⟩ n hn,\n    apply mem_of_superset (prod_mem_nhds univ_mem $ W_in x) (λ p hp, _),\n    dsimp only [mem_set_of],\n    calc f n p = f (n₀ x) p : key hn hp.2\n    ... = f (max (n₀ x) (n₀ p.2)) p : (key (le_max_left (n₀ x) _) hp.2).symm\n    ... = f (n₀ p.2) p : key (le_max_right _ _) (mem_of_mem_nhds $ W_in _) },\n  have key'' : ∀ p : ℝ × X, ∀ᶠ (n : ℕ) in at_top, f n =ᶠ[𝓝 p] λ q, f (n₀ q.2) q,\n  { exact λ p, (eventually_ge_at_top (n₀ p.2)).mono (λ n hn, key' p n hn) },\n  refine ⟨λ t x, f (n₀ x) (t, x), _, _, _, _⟩,\n  { ext x,\n    rw hf0 },\n  { intros t x,\n    convert h₀f (n₀ x) (t, x) using 1,\n    apply quotient.sound,\n    exact ((key' (t, x) _ le_rfl).comp_fun (continuous.prod.mk t).continuous_at).symm },\n  { intro x,\n    convert (h₁f (n₀ x)).on_set x (mem_Union₂_of_mem (indexing.coe_mono $ le_max_left _ _) $ hnK x) using 1,\n    apply quotient.sound,\n    change (λ x', f (n₀ x') (1, x')) =ᶠ[𝓝 x] λ (x' : X), f (n₀ x) (T (n₀ x + 1), x'),\n    simp_rw ← hinvf (n₀ x) 1 (T_lt _).le,\n    exact ((key' (1, x) _ le_rfl).comp_fun (continuous.prod.mk 1).continuous_at).symm },\n  { rintros p,\n    convert h₂f (n₀ p.2) p using 1,\n    apply quotient.sound,\n    rw show ↿(λ t x, f (n₀ x) (t, x)) = λ p : ℝ × X, f (n₀ p.2) p, by ext ⟨s, y⟩ ; refl,\n    exact (key' p _ le_rfl).symm }\nend\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/global/inductive_htpy_construction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.4893148277092345}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Reid Barton\n-/\nimport category_theory.limits.shapes.images\nimport category_theory.filtered\nimport tactic.equiv_rw\n\n/-!\n# Limits in the category of types.\n\nWe show that the category of types has all (co)limits, by providing the usual concrete models.\n\nWe also give a characterisation of filtered colimits in `Type`, via\n`colimit.ι F i xi = colimit.ι F j xj ↔ ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj`.\n\nFinally, we prove the category of types has categorical images,\nand that these agree with the range of a function.\n-/\n\nuniverses v u\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory.limits.types\n\nvariables {J : Type v} [small_category J]\n\n/--\n(internal implementation) the limit cone of a functor,\nimplemented as flat sections of a pi type\n-/\ndef limit_cone (F : J ⥤ Type (max v u)) : cone F :=\n{ X := F.sections,\n  π := { app := λ j u, u.val j } }\n\nlocal attribute [elab_simple] congr_fun\n/-- (internal implementation) the fact that the proposed limit cone is the limit -/\ndef limit_cone_is_limit (F : J ⥤ Type (max v u)) : is_limit (limit_cone F) :=\n{ lift := λ s v, ⟨λ j, s.π.app j v, λ j j' f, congr_fun (cone.w s f) _⟩,\n  uniq' := by { intros, ext x j, exact congr_fun (w j) x } }\n\n/--\nThe category of types has all limits.\n\nSee <https://stacks.math.columbia.edu/tag/002U>.\n-/\ninstance has_limits_of_size : has_limits_of_size.{v} (Type (max v u)) :=\n{ has_limits_of_shape := λ J 𝒥, by exactI\n  { has_limit := λ F, has_limit.mk\n    { cone := limit_cone F, is_limit := limit_cone_is_limit F } } }\n\ninstance : has_limits (Type u) := types.has_limits_of_size.{u u}\n\n/--\nThe equivalence between a limiting cone of `F` in `Type u` and the \"concrete\" definition as the\nsections of `F`.\n-/\ndef is_limit_equiv_sections {F : J ⥤ Type (max v u)} {c : cone F} (t : is_limit c) :\n  c.X ≃ F.sections :=\n(is_limit.cone_point_unique_up_to_iso t (limit_cone_is_limit F)).to_equiv\n\n@[simp]\nlemma is_limit_equiv_sections_apply\n  {F : J ⥤ Type (max v u)} {c : cone F} (t : is_limit c) (j : J) (x : c.X) :\n  (((is_limit_equiv_sections t) x) : Π j, F.obj j) j = c.π.app j x :=\nrfl\n\n@[simp]\nlemma is_limit_equiv_sections_symm_apply\n  {F : J ⥤ Type (max v u)} {c : cone F} (t : is_limit c) (x : F.sections) (j : J) :\n  c.π.app j ((is_limit_equiv_sections t).symm x) = (x : Π j, F.obj j) j :=\nbegin\n  equiv_rw (is_limit_equiv_sections t).symm at x,\n  simp,\nend\n\n/--\nThe equivalence between the abstract limit of `F` in `Type u`\nand the \"concrete\" definition as the sections of `F`.\n-/\nnoncomputable\ndef limit_equiv_sections (F : J ⥤ Type (max v u)) : (limit F : Type (max v u)) ≃ F.sections :=\nis_limit_equiv_sections (limit.is_limit _)\n\n@[simp]\nlemma limit_equiv_sections_apply (F : J ⥤ Type (max v u)) (x : limit F) (j : J) :\n  (((limit_equiv_sections F) x) : Π j, F.obj j) j = limit.π F j x :=\nrfl\n\n@[simp]\nlemma limit_equiv_sections_symm_apply (F : J ⥤ Type (max v u)) (x : F.sections) (j : J) :\n  limit.π F j ((limit_equiv_sections F).symm x) = (x : Π j, F.obj j) j :=\nis_limit_equiv_sections_symm_apply _ _ _\n\n@[simp]\nlemma limit_equiv_sections_symm_apply' (F : J ⥤ Type v) (x : F.sections) (j : J) :\n  limit.π F j ((limit_equiv_sections.{v v} F).symm x) = (x : Π j, F.obj j) j :=\nis_limit_equiv_sections_symm_apply _ _ _\n\n/--\nConstruct a term of `limit F : Type u` from a family of terms `x : Π j, F.obj j`\nwhich are \"coherent\": `∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j'`.\n-/\n@[ext]\nnoncomputable\ndef limit.mk (F : J ⥤ Type (max v u)) (x : Π j, F.obj j)\n  (h : ∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j') : (limit F : Type (max v u)) :=\n(limit_equiv_sections F).symm ⟨x, h⟩\n\n@[simp]\nlemma limit.π_mk (F : J ⥤ Type (max v u)) (x : Π j, F.obj j)\n  (h : ∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j') (j) : limit.π F j (limit.mk F x h) = x j :=\nby { dsimp [limit.mk], simp, }\n\n@[simp]\nlemma limit.π_mk' (F : J ⥤ Type v) (x : Π j, F.obj j)\n  (h : ∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j') (j) :\n  limit.π F j (limit.mk.{v v} F x h) = x j :=\nby { dsimp [limit.mk], simp, }\n\n-- PROJECT: prove this for concrete categories where the forgetful functor preserves limits\n@[ext]\nlemma limit_ext (F : J ⥤ Type (max v u)) (x y : limit F) (w : ∀ j, limit.π F j x = limit.π F j y) :\n  x = y :=\nbegin\n  apply (limit_equiv_sections F).injective,\n  ext j,\n  simp [w j],\nend\n\n@[ext]\nlemma limit_ext' (F : J ⥤ Type v) (x y : limit F) (w : ∀ j, limit.π F j x = limit.π F j y) :\n  x = y :=\nbegin\n  apply (limit_equiv_sections.{v v} F).injective,\n  ext j,\n  simp [w j],\nend\n\nlemma limit_ext_iff (F : J ⥤ Type (max v u)) (x y : limit F) :\n  x = y ↔ (∀ j, limit.π F j x = limit.π F j y) :=\n⟨λ t _, t ▸ rfl, limit_ext _ _ _⟩\n\nlemma limit_ext_iff' (F : J ⥤ Type v) (x y : limit F) :\n  x = y ↔ (∀ j, limit.π F j x = limit.π F j y) :=\n⟨λ t _, t ▸ rfl, limit_ext _ _ _⟩\n\n-- TODO: are there other limits lemmas that should have `_apply` versions?\n-- Can we generate these like with `@[reassoc]`?\n-- PROJECT: prove these for any concrete category where the forgetful functor preserves limits?\n\n@[simp]\nlemma limit.w_apply {F : J ⥤ Type (max v u)} {j j' : J} {x : limit F} (f : j ⟶ j') :\n  F.map f (limit.π F j x) = limit.π F j' x :=\ncongr_fun (limit.w F f) x\n\n@[simp]\nlemma limit.lift_π_apply (F : J ⥤ Type (max v u)) (s : cone F) (j : J) (x : s.X) :\n  limit.π F j (limit.lift F s x) = s.π.app j x :=\ncongr_fun (limit.lift_π s j) x\n\n@[simp]\nlemma limit.map_π_apply {F G : J ⥤ Type (max v u)} (α : F ⟶ G) (j : J) (x) :\n  limit.π G j (lim_map α x) = α.app j (limit.π F j x) :=\ncongr_fun (lim_map_π α j) x\n\n@[simp]\nlemma limit.w_apply' {F : J ⥤ Type v} {j j' : J} {x : limit F} (f : j ⟶ j') :\n  F.map f (limit.π F j x) = limit.π F j' x :=\ncongr_fun (limit.w F f) x\n\n@[simp]\nlemma limit.lift_π_apply' (F : J ⥤ Type v) (s : cone F) (j : J) (x : s.X) :\n  limit.π F j (limit.lift F s x) = s.π.app j x :=\ncongr_fun (limit.lift_π s j) x\n\n@[simp]\nlemma limit.map_π_apply' {F G : J ⥤ Type v} (α : F ⟶ G) (j : J) (x) :\n  limit.π G j (lim_map α x) = α.app j (limit.π F j x) :=\ncongr_fun (lim_map_π α j) x\n\n/--\nThe relation defining the quotient type which implements the colimit of a functor `F : J ⥤ Type u`.\nSee `category_theory.limits.types.quot`.\n-/\ndef quot.rel (F : J ⥤ Type (max v u)) : (Σ j, F.obj j) → (Σ j, F.obj j) → Prop :=\n(λ p p', ∃ f : p.1 ⟶ p'.1, p'.2 = F.map f p.2)\n\n/--\nA quotient type implementing the colimit of a functor `F : J ⥤ Type u`,\nas pairs `⟨j, x⟩` where `x : F.obj j`, modulo the equivalence relation generated by\n`⟨j, x⟩ ~ ⟨j', x'⟩` whenever there is a morphism `f : j ⟶ j'` so `F.map f x = x'`.\n-/\n@[nolint has_inhabited_instance]\ndef quot (F : J ⥤ Type (max v u)) : Type (max v u) :=\n@quot (Σ j, F.obj j) (quot.rel F)\n\n/--\n(internal implementation) the colimit cocone of a functor,\nimplemented as a quotient of a sigma type\n-/\ndef colimit_cocone (F : J ⥤ Type (max v u)) : cocone F :=\n{ X := quot F,\n  ι :=\n  { app := λ j x, quot.mk _ ⟨j, x⟩,\n    naturality' := λ j j' f, funext $ λ x, eq.symm (quot.sound ⟨f, rfl⟩) } }\n\nlocal attribute [elab_with_expected_type] quot.lift\n\n/-- (internal implementation) the fact that the proposed colimit cocone is the colimit -/\ndef colimit_cocone_is_colimit (F : J ⥤ Type (max v u)) : is_colimit (colimit_cocone F) :=\n{ desc := λ s, quot.lift (λ (p : Σ j, F.obj j), s.ι.app p.1 p.2)\n    (assume ⟨j, x⟩ ⟨j', x'⟩ ⟨f, hf⟩, by rw hf; exact (congr_fun (cocone.w s f) x).symm) }\n\n/--\nThe category of types has all colimits.\n\nSee <https://stacks.math.columbia.edu/tag/002U>.\n-/\ninstance has_colimits_of_size : has_colimits_of_size.{v} (Type (max v u)) :=\n{ has_colimits_of_shape := λ J 𝒥, by exactI\n  { has_colimit := λ F, has_colimit.mk\n    { cocone := colimit_cocone F, is_colimit := colimit_cocone_is_colimit F } } }\n\ninstance : has_colimits (Type u) := types.has_colimits_of_size.{u u}\n\n/--\nThe equivalence between the abstract colimit of `F` in `Type u`\nand the \"concrete\" definition as a quotient.\n-/\nnoncomputable\ndef colimit_equiv_quot (F : J ⥤ Type (max v u)) : (colimit F : Type (max v u)) ≃ quot F :=\n(is_colimit.cocone_point_unique_up_to_iso\n  (colimit.is_colimit F)\n  (colimit_cocone_is_colimit F)).to_equiv\n\n@[simp]\nlemma colimit_equiv_quot_symm_apply (F : J ⥤ Type (max v u)) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F).symm (quot.mk _ ⟨j, x⟩) = colimit.ι F j x :=\nrfl\n\n@[simp]\nlemma colimit_equiv_quot_apply (F : J ⥤ Type (max v u)) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F) (colimit.ι F j x) = quot.mk _ ⟨j, x⟩ :=\nbegin\n  apply (colimit_equiv_quot F).symm.injective,\n  simp,\nend\n\n@[simp]\nlemma colimit.w_apply {F : J ⥤ Type (max v u)} {j j' : J} {x : F.obj j} (f : j ⟶ j') :\n  colimit.ι F j' (F.map f x) = colimit.ι F j x :=\ncongr_fun (colimit.w F f) x\n\n@[simp]\nlemma colimit.ι_desc_apply (F : J ⥤ Type (max v u)) (s : cocone F) (j : J) (x : F.obj j) :\n  colimit.desc F s (colimit.ι F j x) = s.ι.app j x :=\ncongr_fun (colimit.ι_desc s j) x\n\n@[simp]\nlemma colimit.ι_map_apply {F G : J ⥤ Type (max v u)} (α : F ⟶ G) (j : J) (x) :\n  colim.map α (colimit.ι F j x) = colimit.ι G j (α.app j x) :=\ncongr_fun (colimit.ι_map α j) x\n\n@[simp]\nlemma colimit.w_apply' {F : J ⥤ Type v} {j j' : J} {x : F.obj j} (f : j ⟶ j') :\n  colimit.ι F j' (F.map f x) = colimit.ι F j x :=\ncongr_fun (colimit.w F f) x\n\n@[simp]\nlemma colimit.ι_desc_apply' (F : J ⥤ Type v) (s : cocone F) (j : J) (x : F.obj j) :\n  colimit.desc F s (colimit.ι F j x) = s.ι.app j x :=\ncongr_fun (colimit.ι_desc s j) x\n\n@[simp]\nlemma colimit.ι_map_apply' {F G : J ⥤ Type v} (α : F ⟶ G) (j : J) (x) :\n  colim.map α (colimit.ι F j x) = colimit.ι G j (α.app j x) :=\ncongr_fun (colimit.ι_map α j) x\n\nlemma colimit_sound\n  {F : J ⥤ Type (max v u)} {j j' : J} {x : F.obj j} {x' : F.obj j'}\n  (f : j ⟶ j') (w : F.map f x = x') : colimit.ι F j x = colimit.ι F j' x' :=\nbegin\n  rw [←w],\n  simp,\nend\n\nlemma colimit_sound'\n  {F : J ⥤ Type (max v u)} {j j' : J} {x : F.obj j} {x' : F.obj j'} {j'' : J}\n  (f : j ⟶ j'') (f' : j' ⟶ j'') (w : F.map f x = F.map f' x') :\n  colimit.ι F j x = colimit.ι F j' x' :=\nbegin\n  rw [←colimit.w _ f, ←colimit.w _ f'],\n  rw [types_comp_apply, types_comp_apply, w],\nend\n\nlemma colimit_eq {F : J ⥤ Type (max v u)} {j j' : J} {x : F.obj j} {x' : F.obj j'}\n  (w : colimit.ι F j x = colimit.ι F j' x') : eqv_gen (quot.rel F) ⟨j, x⟩ ⟨j', x'⟩ :=\nbegin\n  apply quot.eq.1,\n  simpa using congr_arg (colimit_equiv_quot F) w,\nend\n\nlemma jointly_surjective (F : J ⥤ Type (max v u)) {t : cocone F} (h : is_colimit t)\n  (x : t.X) : ∃ j y, t.ι.app j y = x :=\nbegin\n  suffices : (λ (x : t.X), ulift.up (∃ j y, t.ι.app j y = x)) = (λ _, ulift.up true),\n  { have := congr_fun this x,\n    have H := congr_arg ulift.down this,\n    dsimp at H,\n    rwa eq_true at H },\n  refine h.hom_ext _,\n  intro j, ext y,\n  erw iff_true,\n  exact ⟨j, y, rfl⟩\nend\n\n/-- A variant of `jointly_surjective` for `x : colimit F`. -/\nlemma jointly_surjective' {F : J ⥤ Type (max v u)}\n  (x : colimit F) : ∃ j y, colimit.ι F j y = x :=\njointly_surjective F (colimit.is_colimit _) x\n\nnamespace filtered_colimit\n/- For filtered colimits of types, we can give an explicit description\n  of the equivalence relation generated by the relation used to form\n  the colimit.  -/\n\nvariables (F : J ⥤ Type (max v u))\n\n/--\nAn alternative relation on `Σ j, F.obj j`,\nwhich generates the same equivalence relation as we use to define the colimit in `Type` above,\nbut that is more convenient when working with filtered colimits.\n\nElements in `F.obj j` and `F.obj j'` are equivalent if there is some `k : J` to the right\nwhere their images are equal.\n-/\nprotected def rel (x y : Σ j, F.obj j) : Prop :=\n∃ k (f : x.1 ⟶ k) (g : y.1 ⟶ k), F.map f x.2 = F.map g y.2\n\n\n\nlemma eqv_gen_quot_rel_of_rel (x y : Σ j, F.obj j) :\n  filtered_colimit.rel F x y → eqv_gen (quot.rel F) x y :=\nλ ⟨k, f, g, h⟩, eqv_gen.trans _ ⟨k, F.map f x.2⟩ _ (eqv_gen.rel _ _ ⟨f, rfl⟩)\n  (eqv_gen.symm _ _ (eqv_gen.rel _ _ ⟨g, h⟩))\n\nlocal attribute [elab_simple] nat_trans.app\n\n/-- Recognizing filtered colimits of types. -/\nnoncomputable def is_colimit_of (t : cocone F) (hsurj : ∀ (x : t.X), ∃ i xi, x = t.ι.app i xi)\n  (hinj : ∀ i j xi xj, t.ι.app i xi = t.ι.app j xj →\n   ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj) : is_colimit t :=\n-- Strategy: Prove that the map from \"the\" colimit of F (defined above) to t.X\n-- is a bijection.\nbegin\n  apply is_colimit.of_iso_colimit (colimit.is_colimit F),\n  refine cocones.ext (equiv.to_iso (equiv.of_bijective _ _)) _,\n  { exact colimit.desc F t },\n  { split,\n    { show function.injective _,\n      intros a b h,\n      rcases jointly_surjective F (colimit.is_colimit F) a with ⟨i, xi, rfl⟩,\n      rcases jointly_surjective F (colimit.is_colimit F) b with ⟨j, xj, rfl⟩,\n      change (colimit.ι F i ≫ colimit.desc F t) xi = (colimit.ι F j ≫ colimit.desc F t) xj at h,\n      rw [colimit.ι_desc, colimit.ι_desc] at h,\n      rcases hinj i j xi xj h with ⟨k, f, g, h'⟩,\n      change colimit.ι F i xi = colimit.ι F j xj,\n      rw [←colimit.w F f, ←colimit.w F g],\n      change colimit.ι F k (F.map f xi) = colimit.ι F k (F.map g xj),\n      rw h' },\n    { show function.surjective _,\n      intro x,\n      rcases hsurj x with ⟨i, xi, rfl⟩,\n      use colimit.ι F i xi,\n      simp } },\n  { intro j, apply colimit.ι_desc }\nend\n\nvariables [is_filtered_or_empty J]\n\nprotected lemma rel_equiv : equivalence (filtered_colimit.rel F) :=\n⟨λ x, ⟨x.1, 𝟙 x.1, 𝟙 x.1, rfl⟩,\n λ x y ⟨k, f, g, h⟩, ⟨k, g, f, h.symm⟩,\n λ x y z ⟨k, f, g, h⟩ ⟨k', f', g', h'⟩,\n   let ⟨l, fl, gl, _⟩ := is_filtered_or_empty.cocone_objs k k',\n       ⟨m, n, hn⟩ := is_filtered_or_empty.cocone_maps (g ≫ fl) (f' ≫ gl) in\n   ⟨m, f ≫ fl ≫ n, g' ≫ gl ≫ n, calc\n      F.map (f ≫ fl ≫ n) x.2\n          = F.map (fl ≫ n) (F.map f x.2)  : by simp\n      ... = F.map (fl ≫ n) (F.map g y.2)  : by rw h\n      ... = F.map ((g ≫ fl) ≫ n) y.2      : by simp\n      ... = F.map ((f' ≫ gl) ≫ n) y.2     : by rw hn\n      ... = F.map (gl ≫ n) (F.map f' y.2) : by simp\n      ... = F.map (gl ≫ n) (F.map g' z.2) : by rw h'\n      ... = F.map (g' ≫ gl ≫ n) z.2       : by simp⟩⟩\n\nprotected lemma rel_eq_eqv_gen_quot_rel :\n  filtered_colimit.rel F = eqv_gen (quot.rel F) :=\nbegin\n  ext ⟨j, x⟩ ⟨j', y⟩,\n  split,\n  { apply eqv_gen_quot_rel_of_rel },\n  { rw ←(filtered_colimit.rel_equiv F).eqv_gen_iff,\n    exact eqv_gen.mono (rel_of_quot_rel F) }\nend\n\nlemma colimit_eq_iff_aux {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  (colimit_cocone F).ι.app i xi = (colimit_cocone F).ι.app j xj ↔\n    filtered_colimit.rel F ⟨i, xi⟩ ⟨j, xj⟩ :=\nbegin\n  change quot.mk _ _ = quot.mk _ _ ↔ _,\n  rw [quot.eq, filtered_colimit.rel_eq_eqv_gen_quot_rel],\nend\n\nlemma is_colimit_eq_iff {t : cocone F} (ht : is_colimit t) {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  t.ι.app i xi = t.ι.app j xj ↔ ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj :=\nlet t' := colimit_cocone F,\n    e : t' ≅ t := is_colimit.unique_up_to_iso (colimit_cocone_is_colimit F) ht,\n    e' : t'.X ≅ t.X := (cocones.forget _).map_iso e in\nbegin\n  refine iff.trans _ (colimit_eq_iff_aux F),\n  convert e'.to_equiv.apply_eq_iff_eq; rw ←e.hom.w; refl\nend\n\nlemma colimit_eq_iff {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  colimit.ι F i xi = colimit.ι F j xj ↔ ∃ k (f : i ⟶ k) (g : j ⟶ k), F.map f xi = F.map g xj :=\nis_colimit_eq_iff _ (colimit.is_colimit F)\n\nend filtered_colimit\n\nvariables {α β : Type u} (f : α ⟶ β)\n\nsection -- implementation of `has_image`\n/-- the image of a morphism in Type is just `set.range f` -/\ndef image : Type u := set.range f\n\ninstance [inhabited α] : inhabited (image f) :=\n{ default := ⟨f default, ⟨_, rfl⟩⟩ }\n\n/-- the inclusion of `image f` into the target -/\ndef image.ι : image f ⟶ β := subtype.val\n\ninstance : mono (image.ι f) :=\n(mono_iff_injective _).2 subtype.val_injective\n\nvariables {f}\n\n/-- the universal property for the image factorisation -/\nnoncomputable def image.lift (F' : mono_factorisation f) : image f ⟶ F'.I :=\n(λ x, F'.e (classical.indefinite_description _ x.2).1 : image f → F'.I)\n\nlemma image.lift_fac (F' : mono_factorisation f) : image.lift F' ≫ F'.m = image.ι f :=\nbegin\n  ext x,\n  change (F'.e ≫ F'.m) _ = _,\n  rw [F'.fac, (classical.indefinite_description _ x.2).2],\n  refl,\nend\nend\n\n/-- the factorisation of any morphism in Type through a mono. -/\ndef mono_factorisation : mono_factorisation f :=\n{ I := image f,\n  m := image.ι f,\n  e := set.range_factorization f }\n\n/-- the facorisation through a mono has the universal property of the image. -/\nnoncomputable def is_image : is_image (mono_factorisation f) :=\n{ lift := image.lift,\n  lift_fac' := image.lift_fac }\n\ninstance : has_image f :=\nhas_image.mk ⟨_, is_image f⟩\n\ninstance : has_images (Type u) :=\n{ has_image := by apply_instance }\n\ninstance : has_image_maps (Type u) :=\n{ has_image_map := λ f g st, has_image_map.transport st (mono_factorisation f.hom) (is_image g.hom)\n    (λ x, ⟨st.right x.1, ⟨st.left (classical.some x.2),\n      begin\n        have p := st.w,\n        replace p := congr_fun p (classical.some x.2),\n        simp only [functor.id_map, types_comp_apply, subtype.val_eq_coe] at p,\n        erw [p, classical.some_spec x.2],\n      end⟩⟩) rfl }\n\nend category_theory.limits.types\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/types.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.7431680143008301, "lm_q1q2_score": 0.48931482647334157}}
{"text": "/-\nCopyright (c) 2023 Bruno Bentzen. All rights reserved.\nReleased under the Apache License 2.0 (see \"License\");\nAuthor: Bruno Bentzen\n-/\n\nimport ..encoding.encode .theory .semantics\n\nopen nat set classical\n\nlocal attribute [instance, priority 0] prop_decidable\n\n/- maximal set of a context -/\n\nnamespace  ctx\n\ndef is_closed (Γ :  set form) := \n∀ {p : form}, (Γ ⊢ᵢ p) → p ∈ Γ\n\ndef has_disj (Γ :  set form) := \n∀ {p q : form}, ((p ∨ q) ∈ Γ) → ((p ∈ Γ) ∨ (q ∈ Γ))\n\ndef is_max (Γ :  set form) := \nis_closed Γ ∧ has_disj Γ\n\n/-- extension -/\n\ndef insert_form (Γ :  set form) (p q r : form) :  set form :=\nif (Γ ⸴ p ⊢ᵢ r) then Γ ⸴ q else Γ ⸴ p\n\n@[simp]\ndef insert_code (Γ :  set form) (r : form) (n : nat) :  set form :=\nmatch encodable.decode (form) n with\n| none := Γ\n| some (p ∨ q) := if Γ ⊢ᵢ p ∨ q then insert_form Γ p q r else Γ\n| some _ := Γ\nend\n\n@[simp]\ndef insertn (Γ :  set form) (r : form) : nat →  set form\n| 0     := Γ \n| (n+1) := insert_code (insertn n) r n \n\n@[simp]\ndef maxn (Γ :  set form) (r : form) : nat →  set form\n| 0     := Γ\n| (n+1) := ⋃ i, insertn (maxn n) r i \n\n@[simp]\ndef max (Γ :  set form) (r : form) :  set form := \n⋃ n, maxn Γ r n\n\n/- max extends the original set -/\n\nlemma subset_insert_code {Γ :  set form} {r : form} (n) :\n  Γ ⊆ insert_code Γ r n :=\nbegin\n  intros v hv, simp, \n  cases (encodable.decode (form) _),\n    { assumption },\n    { induction val,\n      repeat { assumption },\n      unfold insert_code ite,\n      induction (prop_decidable _),\n      { assumption },\n      { unfold insert_form ite, \n      induction (prop_decidable _),\n        repeat { right, assumption } } }\nend\n\nlemma maxn_subset_max {Γ :  set form} {r : form} (n) :\n  maxn Γ r n ⊆ max Γ r :=\nsubset_Union _ _\n\nlemma subset_insertn {Γ :  set form} {r : form} {n} :\n  Γ ⊆ insertn Γ r n :=\nbegin\n  induction n,\n  { simp }, \n  { simp, cases (encodable.decode (form) _) with p,\n    { assumption },\n      induction p,\n        repeat {assumption},\n      { simp [ite], \n        induction (prop_decidable _),\n        { simp, assumption },\n        { simp [insert_form, ite], \n          induction (prop_decidable _),\n            repeat {intros q hq, right, exact n_ih hq} } } }\nend\n\nlemma subset_max_self {Γ :  set form} {r : form} :\n  Γ ⊆ max Γ r :=\nmaxn_subset_max 0\n\nlemma insertn_sub_maxn {Γ :  set form} {r : form} {n m : nat} :\n  insertn (maxn Γ r n) r m ⊆ maxn Γ r (n+1) :=\nsubset_Union _ _\n\nlemma insertn_to_max {Γ :  set form} {r : form} {n m : nat} :\n  insertn (maxn Γ r n) r m ⊆ max Γ r :=\nby induction m; \n[ apply maxn_subset_max, \n  exact subset.trans insertn_sub_maxn (maxn_subset_max _) ]\n\n/- max has the disjunction property -/\n\nlemma in_max_in_maxn {Γ :  set form} {p r : form} :\n  (p ∈ max Γ r ) → ∃ n, p ∈ maxn Γ r n :=\nmem_Union.1\n\nlemma in_maxn_in_insertn {Γ :  set form} {p r : form} {n} :\n  (p ∈ maxn Γ r (n+1) ) → ∃ i, p ∈ insertn (maxn Γ r n) r i :=\nmem_Union.1\n\nlemma maxn_subset_succ {Γ :  set form} {r : form} {n : nat} :\n  maxn Γ r n ⊆ maxn Γ r (n+1) :=\nbegin\n  apply subset.trans,\n  { apply subset_insertn,\n    repeat {assumption} },\n  { exact subset_Union _ _}\nend\n\nlemma maxn_mono {Γ :  set form} {r : form} {m n : nat} (h : n ≤ m) :\n  maxn Γ r n ⊆ maxn Γ r m :=\nby induction h; [refl, exact subset.trans h_ih maxn_subset_succ ]\n\nlemma insertn_mono {Γ :  set form} {r : form} {m n : nat} (h : n ≤ m) :\n  insertn Γ r n ⊆ insertn Γ r m :=\nby induction h; [refl, exact subset.trans h_ih (subset_insert_code _)]\n\ndef maxn_sub_prf {Γ :  set form} {p r : form} : \n  (max Γ r ⊢ᵢ p) → ∃ n, maxn Γ r n ⊢ᵢ p :=\nbegin\n  generalize eq : max Γ r = Γ',\n  intro h, induction h; subst eq,\n  { cases in_max_in_maxn h_h with n hpq,\n    exact ⟨n, prf.ax hpq⟩ }, \n\n  repeat {\n      constructor,\n      apply prf.k <|> apply prf.s <|> apply prf.exf <|>\n      apply prf.pr1 <|> apply prf.pr2 <|> apply prf.pair <|> \n      apply prf.inr <|> apply prf.inl <|> apply prf.case,\n      exact 0\n    },\n\n  { cases h_ih_hpq rfl with i h_ext_pq,\n    cases h_ih_hp rfl with j h_ext_p,\n    cases (prop_decidable (i ≤ j)),\n    { have hn: j ≤ i :=\n        begin\n          cases nat.le_total,\n          assumption,\n          contradiction\n      end,\n      constructor,\n      { apply prf.mp,\n        { assumption },\n        { apply prf.sub_weak,\n          { exact h_ext_p },\n          { apply maxn_mono,\n            assumption } } } },\n    { constructor,\n      { apply prf.mp,\n        { apply prf.sub_weak,\n          { exact h_ext_pq },\n          { apply maxn_mono,\n            assumption } },\n          assumption } } }\nend\n\nlemma prf_maxn_prf_insertn {Γ :  set form} {p r : form} {n} :\n  (maxn Γ r (n+1) ⊢ᵢ p) → ∃ i, insertn (maxn Γ r n) r i ⊢ᵢ p :=\nbegin\n  generalize eq : maxn Γ r (n+1) = Γ',\n  intro h, induction h; subst eq,\n  { cases in_maxn_in_insertn h_h with n hpq,\n    exact ⟨n, prf.ax hpq⟩ },\n\n    repeat {\n      constructor,\n      apply prf.k <|> apply prf.s <|> apply prf.exf <|>\n      apply prf.pr1 <|> apply prf.pr2 <|> apply prf.pair <|> \n      apply prf.inr <|> apply prf.inl <|> apply prf.case,\n      exact 0\n    },\n\n    { cases h_ih_hpq rfl with i h_ext_pq,\n      cases h_ih_hp rfl with j h_ext_p,\n      cases (prop_decidable (i ≤ j)),\n      { have hn: j ≤ i :=\n              begin\n                cases nat.le_total,\n                assumption,\n                contradiction\n            end,\n        constructor,\n        { apply prf.mp,\n          { assumption },\n          { apply prf.sub_weak,\n            { exact h_ext_p },\n            { apply insertn_mono,\n              assumption } } } },\n      { constructor,\n        { apply prf.mp,\n          { apply prf.sub_weak,\n            { exact h_ext_pq },\n            { apply insertn_mono, assumption } },\n          { assumption } } } }\nend\n\ndef max_insertn_disj {Γ :  set form} {p q r : form} (h : (p ∨ q) ∈ max Γ r) : \n  ∃ n, p ∈ (insertn (maxn Γ r n) r (encodable.encode (p ∨ q)+1)) ∨ \n       q ∈ (insertn (maxn Γ r n) r (encodable.encode (p ∨ q)+1)) :=\nbegin\n  cases in_max_in_maxn h with n hpq,\n  fapply exists.intro,\n  { exact n },\n  { unfold insertn insert_code,\n    rw (encodable.encodek ((p ∨ q))),\n    simp [insert_code, ite], \n    induction (prop_decidable _) with h1 h2,\n    { exact false.elim (h1 (prf.sub_weak (prf.ax hpq) (subset_insertn))) },\n    { simp [insert_form, ite],\n      induction (prop_decidable _),\n        { left,left, refl },\n        { right,left, refl } } }\nend\n\ndef max_has_disj {Γ :  set form} {p q r : form} : \n  ((p ∨ q) ∈ max Γ r) → p ∈ max Γ r ∨ q ∈ max Γ r :=\nbegin\n  intro h, cases max_insertn_disj h with n hpq, cases hpq,\n  { left, apply insertn_to_max hpq },\n  { right, apply insertn_to_max hpq }\nend\n\n/- max is closed -/\n\nlemma max_prf_disj_self {Γ :  set form} {p r : form} : \n  (max Γ r ⊢ᵢ r ∨ p) → ∃ n, p ∈ (insertn (maxn Γ r n) r (encodable.encode (r ∨ p)+1)) :=\nbegin\n  intros h,\n  cases maxn_sub_prf h with n hpq,\n  constructor,\n    unfold insertn insert_code,\n    rw (encodable.encodek ((r ∨ p))),\n    simp [insert_code, ite],\n    induction (prop_decidable _) with h1 h2,\n    { exact false.elim (h1 (prf.sub_weak hpq (subset_insertn))) },\n    { simp [insert_form, ite],\n      induction (prop_decidable _) with h1' h2',\n      { apply false.elim,\n        apply h1',\n        apply prf.ax, \n        { left, refl} },\n      { left, refl } }\nend\n\ndef max_is_closed {Γ :  set form} {p q r : form} : \n  (max Γ r ⊢ᵢ p) → p ∈ max Γ r :=\nby { intros h, cases max_prf_disj_self (prf.or_intro2 r h), apply insertn_to_max, repeat {assumption} }\n\n/- max preserves consistency -/\n\nlemma insertn_prf {Γ :  set form} {p : form} {i} : \n  (insertn Γ p i ⊢ᵢ p) → (Γ ⊢ᵢ p) :=\nbegin\n  induction i,\n  { simp }, \n  { simp [insertn, insert_code],\n    cases (encodable.decode (form) _) with p,\n    { assumption },\n    { induction p,\n        repeat {assumption},\n        { simp [ite], \n          induction (prop_decidable _),\n            { assumption },\n            { simp [insert_form, ite],\n              induction (prop_decidable _),\n              { intro, contradiction },\n              { intro, apply i_ih, \n                apply prf.or_elim,\n                repeat {assumption } } } } } }\nend\n\n-- these two are better (positive)\n\ndef maxn_not_prfn {Γ :  set form} {p : form} {n} : \n  (maxn Γ p n ⊢ᵢ p) → (Γ ⊢ᵢ p) :=\nbegin\n  induction n with k ih,\n    simp,\n\n    unfold maxn,\n    intro h,\n    cases prf_maxn_prf_insertn h,\n    apply ih, apply insertn_prf h_1\nend\n\ndef max_not_prf {Γ :  set form} {p : form} : \n  (max Γ p ⊢ᵢ p) → (Γ ⊢ᵢ p) :=\nbegin\n  intros hm,\n  cases maxn_sub_prf hm,\n  apply maxn_not_prfn h\nend\n\n-- Closure under derivability\n\nend  ctx\n\nlemma max_of_max {Γ :  set form} {r : form} : \n ctx.is_max (ctx.max Γ r) :=\nbegin\n  split,\n    intro, apply ctx.max_is_closed, assumption,\n    intros p q, apply ctx.max_has_disj\nend\n\nlemma max_no_prf {Γ :  set form} {r : form} (h : Γ ⊬ᵢ r) : \n ctx.max Γ r ⊬ᵢ r :=\nλ hm, h (ctx.max_not_prf hm)\n\n/- the canonical model construction -/\n\n-- domain\n\nnamespace canonical\n\ndef is_consist (Γ :  set form) := Γ ⊬ᵢ ⊥\n\ndef domain : set (wrld) := {w | is_consist w ∧  ctx.is_max w}\n\n-- accessibility\n\ndef access : wrld → wrld → Prop :=\nλ w v, w ⊆ v\n\n-- valuation\n\ndef val : ℕ → wrld → Prop :=\nλ q w, w ∈ domain ∧ (#q) ∈ w\n\n-- reflexivity\n\nlemma access.refl :\n  ∀ w ∈ domain, access w w :=\nbegin\n  intros, unfold access\nend\n\n-- transitivity\n\nlemma access.trans : ∀ w ∈ domain, ∀ v ∈ domain, ∀ u ∈ domain,\n  access w v → access v u → access w u :=\nbegin\n  unfold access,\n  intros _ hw _ hu u  hu hwv hvu q hq,\n  apply hvu, apply hwv, assumption\nend\n\ndef model : @model :=\nbegin\n  fapply model.mk,\n    apply domain,\n    apply access,\n    apply val,\n    apply access.refl,\n    apply access.trans\nend\n\n/- simple lemmas -/\n\nlemma consist_of_not_prf {Γ :  set form} {p : form} : \n  (Γ ⊬ᵢ p) → is_consist Γ :=\nλ nhp nc, nhp (prf.mp prf.exf nc)\n\n/- truth is membership in the canonical model -/\n\nlemma model_tt_iff_prf {p : form} : \n  ∀ (w ∈ domain), (w ⊩⦃model⦄ p) ↔ (w ⊢ᵢ p) :=\nbegin\n  induction p with p p q hp hq p q hp hq p q hp hq,\n  -- atom \n  { intros, \n    split, \n    { intro h, exact prf.ax h.right },\n    { intro,\n      split, \n      { assumption },\n      { apply H.2.1, assumption } } },\n  -- ⊥\n  { simp [forces_form],\n    intros w H hn, exact H.1 hn },\n  -- ⊃\n  intros,\n  split,\n  { intro Hw,\n    cases (em _),\n    { assumption },\n    { have hd : ctx.max (w ⸴ p) q ∈ domain :=\n        begin\n          split,\n          exact consist_of_not_prf (max_no_prf (prf.contradeduction h)),\n          apply max_of_max,\n        end,\n      apply false.elim,\n      apply max_no_prf (prf.contradeduction h),\n      cases hq ( ctx.max (w ⸴ p) q) _,\n      apply mp,\n      apply Hw _ hd,\n      { exact H },\n      intros p Hp,\n      apply ctx.subset_max_self,\n      { right, assumption },\n      { apply (hp (ctx.max (w ⸴ p) q) _).2,\n        { apply prf.ax,\n          apply ctx.subset_max_self,\n          left, simp },\n        exact hd },\n      exact hd } },\n  { intro hpq,\n    intros v Hv Hw hwv hp2,\n    apply (hq v Hv).2,\n    apply prf.mp,\n    { apply prf.sub_weak, assumption, assumption },\n    { apply (hp v Hv).1, assumption } },\n    -- &\n    { intros, split,\n      { intro hpq,\n        apply prf.mp, apply prf.mp, apply prf.pair,\n        apply (hp w H).1,\n        exact hpq.1,\n        apply (hq w H).1,\n        exact hpq.2 },\n      { intro hpq, split,\n        apply (hp w H).2,\n        apply prf.and_elim1 hpq,\n        apply (hq w H).2,\n        apply prf.and_elim2 hpq } },\n    -- ∨ \n  { intros,\n    split,\n    { intro hpq,\n      cases hpq,\n      { apply prf.or_intro1,\n        apply (hp w H).1 hpq },\n      { apply prf.or_intro2,\n        apply (hq w H).1 hpq } },\n    { intro hpq,\n      cases (H.2.2 (H.2.1 hpq)),\n      { left, apply (hp w H).2,\n        apply prf.ax, assumption },\n      { right, apply (hq w H).2,\n        apply prf.ax, assumption } } },\nend\n\nlemma ctx_tt_of_prf {Γ :  set form} (wm : Γ ∈ domain) : \n  (Γ ⊩⦃model⦄ Γ) :=\nby { intros p hp, apply (model_tt_iff_prf Γ wm).2, apply prf.ax, assumption }\n\n/- the completeness theorem -/\n\ntheorem completeness {Γ :  set form} {p : form} : \n  (Γ ⊨ᵢ p) → (Γ ⊢ᵢ p) :=\nbegin\n  apply (@not_imp_not (Γ ⊢ᵢ p) (Γ ⊨ᵢ p) (prop_decidable _)).1,\n  intros nhp hp,\n  have hd: ctx.max Γ p ∈ domain :=\n    begin\n      split,\n      apply consist_of_not_prf,\n      exact max_no_prf nhp, \n      apply (max_of_max)\n    end,\n  apply absurd,\n  fapply hp,\n  { exact model },\n  { exact ctx.max Γ p },\n  { exact hd },\n\n  { apply ctx_tt_to_subctx_tt,\n    apply ctx_tt_of_prf hd,\n    apply ctx.subset_max_self },\n\n  { intro hpm,\n    apply max_no_prf nhp,\n    exact (model_tt_iff_prf _ hd).1 hpm },\nend\n\nend canonical\n", "meta": {"author": "bbentzen", "repo": "ipl", "sha": "a5226c554aa3d75137ef2ebd6d20aa76883cbcfc", "save_path": "github-repos/lean/bbentzen-ipl", "path": "github-repos/lean/bbentzen-ipl/ipl-a5226c554aa3d75137ef2ebd6d20aa76883cbcfc/src/completeness/completeness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.4893148177468319}}
{"text": "import category_theory.abelian.homology\nimport algebra.homology.homology\nimport for_mathlib.has_homology\n\nnoncomputable theory\n\nuniverses v\n\nopen category_theory category_theory.limits opposite\n\nvariables {C : Type*} [category.{v} C] [abelian C]\nvariables {D : Type*} [category.{v} D] [abelian D]\n\nvariables {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (H : C) (w : f ≫ g = 0)\n\n/- Eventually, all of this should be refactored using `short_complex`. -/\n\n/-- This structure expresses that there is a candidate `H` for the\nhomology of composable maps `f : X ⟶ Y` and `g : Y ⟶ Z`.\nWhen `0 ⟶ K ⟶ Y ⟶ Z` and `X ⟶ K ⟶ Q ⟶ 0` are exact, this\nwill give a `h : homology_iso_datum f g H` and there shall\nbe an isomorphism `h.iso : H ≅ homology f g h.w`. The differences with\n`has_homology f g H` are :\n* this definition is not self dual: the homology is thought as the\nquotient of cycles by boundaries;\n* the object `K` can be any choice for the kernel of `Y ⟶ Z` and\n`H` can be any choice of cokernel for `X ⟶ K`. -/\n@[nolint has_inhabited_instance]\nstructure homology_iso_predatum :=\n(w : f ≫ g = 0)\n(K : C) (ι : K ⟶ Y) (f' : X ⟶ K) (fac' : f' ≫ ι = f) (zero₁' : ι ≫ g = 0)\n(π : K ⟶ H) (zero₂' : f' ≫ π = 0)\n\nnamespace homology_iso_predatum\n\nrestate_axiom fac'\nrestate_axiom zero₁'\nrestate_axiom zero₂'\nattribute [simp, reassoc] fac zero₁ zero₂\n\n@[simps]\ndef tautological : homology_iso_predatum f g (cokernel (kernel.lift g f w)) :=\n{ w := w,\n  K := kernel g,\n  ι := kernel.ι _,\n  f' := kernel.lift g f w,\n  fac' := kernel.lift_ι _ _ _,\n  zero₁' := kernel.condition _,\n  π := cokernel.π _,\n  zero₂' := cokernel.condition _, }\n\n@[simps]\ndef tautological' : homology_iso_predatum f g (homology f g w):=\n{ w := w,\n  K := kernel g,\n  ι := kernel.ι _,\n  f' := kernel.lift g f w,\n  fac' := kernel.lift_ι _ _ _,\n  zero₁' := kernel.condition _,\n  π := homology.π' f g w,\n  zero₂' := homology.condition_π' _ _ _, }\n\nvariables {f g}\n\nvariables {H} (h : homology_iso_predatum f g H)\n\n@[simps]\ndef fork : kernel_fork g := kernel_fork.of_ι h.ι h.zero₁\n\n@[simps]\ndef cofork : cokernel_cofork h.f' := cokernel_cofork.of_π h.π h.zero₂\n\n@[simps]\ndef apply_functor {D : Type*} [category D] [abelian D] (F : C ⥤ D) [F.additive] :\n  homology_iso_predatum (F.map f) (F.map g) (F.obj H):=\n{ w := by rw [← F.map_comp, h.w, F.map_zero],\n  K := F.obj h.K,\n  ι := F.map h.ι,\n  f' := F.map h.f',\n  fac' := by rw [← F.map_comp, h.fac],\n  zero₁' := by simp only [← F.map_comp, zero₁, F.map_zero],\n  π := F.map h.π,\n  zero₂' := by simp only [← F.map_comp, zero₂, F.map_zero], }\n\ninclude h\n\n@[simps]\ndef map_iso {X' Y' Z' : C} (f' : X' ⟶ Y') (g' : Y' ⟶ Z') (e₁ : arrow.mk f ≅ arrow.mk f')\n  (e₂ : arrow.mk g ≅ arrow.mk g') (eq : e₁.hom.right = e₂.hom.left) :\n  homology_iso_predatum f' g' H :=\nbegin\n  have comm₁ : e₁.hom.left ≫ f' = f ≫ e₁.hom.right := arrow.w e₁.hom,\n  have comm₂ : e₂.hom.left ≫ g' = g ≫ e₂.hom.right := arrow.w e₂.hom,\n  have h₁ : e₁.inv.left ≫ e₁.hom.left = 𝟙 X',\n  { rw [← comma.comp_left, e₁.inv_hom_id, arrow.id_left], refl, },\n  exact\n  { w := by { rw [← cancel_epi e₁.hom.left, ← category.assoc, comm₁, eq, category.assoc, comm₂,\n      ← category.assoc, h.w, zero_comp, comp_zero], },\n    K := h.K,\n    ι := h.ι ≫ e₁.hom.right,\n    f' := e₁.inv.left ≫ h.f',\n    fac' := begin\n      slice_lhs 2 3 { rw h.fac', },\n      rw [← comm₁, ← category.assoc, h₁, category.id_comp],\n    end,\n    zero₁' := by rw [eq, category.assoc, comm₂, ← category.assoc, h.zero₁', zero_comp],\n    π := h.π,\n    zero₂' := by rw [category.assoc, h.zero₂', comp_zero], }\nend\n\nomit h\n\nend homology_iso_predatum\n\n@[nolint has_inhabited_instance]\nstructure homology_iso_datum (H : C) extends homology_iso_predatum f g H :=\n(fork_is_limit : is_limit to_homology_iso_predatum.fork)\n(cofork_is_colimit : is_colimit to_homology_iso_predatum.cofork)\n\nnamespace homology_iso_datum\n\nvariables {H f g}\n\n@[protected]\ndef H (h : homology_iso_datum f g H) : C := H\nvariables (f g)\n\n@[simps]\ndef tautological : homology_iso_datum f g (cokernel (kernel.lift g f w)) :=\n{ to_homology_iso_predatum := homology_iso_predatum.tautological f g w,\n  fork_is_limit := by apply kernel_is_kernel,\n  cofork_is_colimit := by apply cokernel_is_cokernel, }\n\n@[simps]\ndef tautological' : homology_iso_datum f g (homology f g w) :=\n{ to_homology_iso_predatum := homology_iso_predatum.tautological' f g w,\n  fork_is_limit := by apply kernel_is_kernel,\n  cofork_is_colimit := begin\n    dsimp [homology_iso_predatum.cofork],\n    refine is_colimit.of_iso_colimit (cokernel_is_cokernel (kernel.lift g f w)) _ ,\n    refine cocones.ext (homology_iso_cokernel_lift f g w).symm _,\n    rintro (_|_),\n    tidy,\n  end, }\n\nvariables {f g} (h : homology_iso_datum f g H)\n\ndef map_iso {X' Y' Z' : C} (f' : X' ⟶ Y') (g' : Y' ⟶ Z') (e₁ : arrow.mk f ≅ arrow.mk f')\n  (e₂ : arrow.mk g ≅ arrow.mk g') (eq : e₁.hom.right = e₂.hom.left) :\n  homology_iso_datum f' g' H :=\n{ to_homology_iso_predatum := h.to_homology_iso_predatum.map_iso f' g' e₁ e₂ eq,\n  fork_is_limit := begin\n    refine (is_limit.equiv_of_nat_iso_of_iso _ _ _ _).to_fun h.fork_is_limit,\n    { refine parallel_pair.ext (arrow.right_func.map_iso e₁) (arrow.right_func.map_iso e₂)\n       _ (by simp),\n      have h₂ := arrow.w e₂.hom,\n      dsimp at h₂ ⊢,\n      rw [eq, h₂], },\n    { refine cones.ext (iso.refl _) _,\n      rintro (_|_),\n      tidy, },\n  end,\n  cofork_is_colimit := begin\n    refine (is_colimit.equiv_of_nat_iso_of_iso _ _ _ _).to_fun h.cofork_is_colimit,\n    { refine parallel_pair.ext ((arrow.left_func.map_iso e₁)) (iso.refl _) _ (by tidy),\n      { dsimp,\n        have h₁ : e₁.hom.left ≫ e₁.inv.left = 𝟙 X,\n        { rw [← comma.comp_left, e₁.hom_inv_id, arrow.id_left], refl, },\n        rw [category.comp_id, ← category.assoc, h₁, category.id_comp], }, },\n    { refine cocones.ext (iso.refl _) _,\n      rintro (_|_),\n      tidy, },\n  end, }\n\ndef iso₁ : h.K ≅ kernel g :=\nis_limit.cone_point_unique_up_to_iso h.fork_is_limit (limit_cone.is_limit _)\n\n@[simp, reassoc]\nlemma iso₁_hom_kernel_ι : h.iso₁.hom ≫ kernel.ι g = h.ι :=\nis_limit.cone_point_unique_up_to_iso_hom_comp _ _ _\n\ninstance : mono h.ι := by { rw ← h.iso₁_hom_kernel_ι, apply_instance, }\n\n@[simp, reassoc]\nlemma f'_iso₁_hom : h.f' ≫ h.iso₁.hom = kernel.lift g f h.w :=\nbegin\n  ext,\n  simp only [category.assoc, iso₁_hom_kernel_ι, homology_iso_predatum.fac, kernel.lift_ι],\nend\n\ndef iso₂ : H ≅ cokernel h.f' :=\nis_colimit.cocone_point_unique_up_to_iso h.cofork_is_colimit (colimit_cocone.is_colimit _)\n\n@[simp, reassoc]\nlemma cokernel_π_iso₂_inv : cokernel.π h.f' ≫ h.iso₂.inv = h.π :=\nis_colimit.comp_cocone_point_unique_up_to_iso_inv _ _ _\n\n@[reassoc]\nlemma cokernel_f'_eq_π_iso₂_hom : cokernel.π h.f' = h.π ≫ h.iso₂.hom :=\nby rw [← cokernel_π_iso₂_inv, category.assoc, h.iso₂.inv_hom_id, category.comp_id]\n\ninstance : epi h.π := by { rw ← h.cokernel_π_iso₂_inv, apply epi_comp, }\n\ndef iso₃ : cokernel h.f' ≅ cokernel (kernel.lift g f h.w) :=\ncokernel.map_iso _ _ (iso.refl _) h.iso₁\n  (by simp only [f'_iso₁_hom, iso.refl_hom, category.id_comp])\n\n@[simp, reassoc]\nlemma cokernel_π_iso₃_hom :\n  cokernel.π h.f' ≫ h.iso₃.hom = h.iso₁.hom ≫ cokernel.π (kernel.lift g f h.w) :=\nbegin\n  dsimp only [iso₃],\n  simp only [cokernel.map_iso_hom, cokernel.π_desc],\nend\n\nvariables (f g)\n\n@[simp]\nlemma tautological_iso₁ : (tautological f g w).iso₁ = iso.refl _ :=\nbegin\n  ext,\n  dsimp only [iso₁],\n  simp only [equalizer_as_kernel, iso.refl_hom, category.id_comp],\n  change kernel.lift _ _ _ ≫ _ = _,\n  simpa only [equalizer_as_kernel, kernel.lift_ι],\nend\n\n@[simp]\nlemma tautological'_iso₁ : (tautological' f g w).iso₁ = iso.refl _ :=\nbegin\n  ext,\n  dsimp only [iso₁],\n  simp only [equalizer_as_kernel, iso.refl_hom, category.id_comp],\n  change kernel.lift _ _ _ ≫ _ = _,\n  simpa only [equalizer_as_kernel, kernel.lift_ι],\nend\n\n@[simp]\nlemma tautological_iso₂ : (tautological f g w).iso₂ = iso.refl _ :=\nbegin\n  suffices : (tautological f g w).iso₂.symm = iso.refl _,\n  { change (tautological f g w).iso₂.symm.symm = _,\n    simpa only [this], },\n  ext,\n  simpa only [iso.symm_hom, cokernel_π_iso₂_inv, iso.refl_hom, category.comp_id],\nend\n\n@[simp]\nlemma tautological_iso₃ : (tautological f g w).iso₃ = iso.refl _ :=\nbegin\n  ext,\n  simpa only [cokernel_π_iso₃_hom, tautological_iso₁, iso.refl_hom, category.id_comp, category.comp_id],\nend\n\nvariables {f g}\n\ndef iso : H ≅ homology f g h.w :=\nh.iso₂ ≪≫ h.iso₃ ≪≫ (homology_iso_cokernel_lift f g h.w).symm\n\nvariables (f g)\n\n@[simp]\nlemma tautological_iso : (tautological f g w).iso =\n  (homology_iso_cokernel_lift f g w).symm :=\nby { dsimp only [iso], simp only [tautological_iso₂, tautological_iso₃, iso.refl_trans], }\n\nlemma tautological_iso_hom : (tautological f g w).iso.hom =\n  (homology_iso_cokernel_lift f g w).inv :=\nby simp only [tautological_iso, iso.symm_hom]\n\nvariables {f g}\n\n@[nolint has_inhabited_instance]\nstructure change {H₁ H₂ : C} (h₁ : homology_iso_datum f g H₁)\n  (h₂ : homology_iso_datum f g H₂) :=\n(κ : h₁.K ⟶ h₂.K) (fac₁' : h₁.f' ≫ κ = h₂.f') (fac₂' : κ ≫ h₂.ι = h₁.ι)\n(η : H₁ ⟶ H₂) (fac₃' : h₁.π ≫ η = κ ≫ h₂.π)\n\nnamespace change\n\nrestate_axiom fac₁'\nrestate_axiom fac₂'\nrestate_axiom fac₃'\nattribute [simp, reassoc] fac₁ fac₂\nattribute [reassoc] fac₃\n\nvariables {H₁ H₂ : C} {h₁ : homology_iso_datum f g H₁}\n  {h₂ : homology_iso_datum f g H₂} (c : change h₁ h₂)\n\n@[simp, reassoc]\nlemma fac_iso₁ : c.κ ≫ h₂.iso₁.hom = h₁.iso₁.hom :=\nby { ext, simp only [category.assoc, iso₁_hom_kernel_ι, fac₂], }\n\ninstance : is_iso c.κ := is_iso.of_is_iso_fac_right (c.fac_iso₁)\n\ndef coker_iso : cokernel h₁.f' ≅ cokernel h₂.f' :=\ncokernel.map_iso _ _ (iso.refl _) (as_iso c.κ)\n(by simp only [as_iso_hom, fac₁, iso.refl_hom, category.id_comp])\n\n@[simp, reassoc]\nlemma coker_iso_comm : cokernel.π h₁.f' ≫ c.coker_iso.hom = c.κ ≫ cokernel.π h₂.f' :=\nbegin\n  dsimp only [coker_iso],\n  simp only [as_iso_hom, cokernel.map_iso_hom, cokernel.π_desc],\nend\n\n@[reassoc]\nlemma fac_iso₂ : c.coker_iso.hom ≫ h₂.iso₂.inv = h₁.iso₂.inv ≫ c.η :=\nbegin\n  ext,\n  simp only [coker_iso_comm_assoc, cokernel_π_iso₂_inv, cokernel_π_iso₂_inv_assoc,\n    fac₃],\nend\n\ninstance : is_iso c.η :=\nbegin\n  haveI : is_iso (h₁.iso₂.inv ≫ c.η) := by { rw ← fac_iso₂, apply_instance, },\n  apply is_iso.of_is_iso_comp_left (h₁.iso₂.inv),\nend\n\n@[simp, reassoc]\nlemma coker_iso_iso₃_hom : c.coker_iso.hom ≫ h₂.iso₃.hom = h₁.iso₃.hom :=\nbegin\n  ext,\n  simp only [coker_iso_comm_assoc, cokernel_π_iso₃_hom, fac_iso₁_assoc],\nend\n\n@[simp, reassoc]\nlemma η_iso₂_hom_iso₃_hom : c.η ≫ h₂.iso₂.hom ≫ h₂.iso₃.hom = h₁.iso₂.hom ≫ h₁.iso₃.hom :=\nby rw [← cancel_epi h₁.iso₂.inv, iso.inv_hom_id_assoc, ← c.coker_iso_iso₃_hom,\n  ← fac_iso₂_assoc, iso.inv_hom_id_assoc]\n\n@[simp, reassoc]\nlemma η_iso_hom : c.η ≫ h₂.iso.hom = h₁.iso.hom :=\nbegin\n  dsimp only [iso],\n  simp only [iso.trans_hom, η_iso₂_hom_iso₃_hom_assoc],\nend\n\nlemma η_iso : as_iso c.η ≪≫ h₂.iso = h₁.iso :=\nby { ext, simp only [iso.trans_hom, as_iso_hom, η_iso_hom], }\n\nvariables (f g)\n\n@[simps]\ndef tautological : change (homology_iso_datum.tautological' f g w)\n  (homology_iso_datum.tautological f g w) :=\n{ κ := 𝟙 _,\n  η := (homology_iso_cokernel_lift f g w).hom,\n  fac₁' := category.comp_id _,\n  fac₂' := category.id_comp _,\n  fac₃' := begin\n    dsimp [homology.π', homology_iso_cokernel_lift, homology_iso_cokernel_image_to_kernel'],\n    simp only [cokernel_iso_of_eq_inv_comp_desc, cokernel.π_desc_assoc, category.assoc,\n      π_comp_cokernel_iso_of_eq_hom, iso.inv_hom_id_assoc, category.id_comp],\n  end, }\n\nend change\n\nvariables (f g)\n\n@[simp]\nlemma tautological'_iso : (tautological' f g w).iso = iso.refl _ :=\nbegin\n  ext1,\n  rw ← (change.tautological f g w).η_iso_hom,\n  simp only [← (change.tautological f g w).η_iso_hom, change.tautological_η,\n    iso.refl_hom, tautological_iso, iso.symm_hom, iso.hom_inv_id],\nend\n\nvariables {f g}\n\nsection apply_exact_functor\n\nvariables (F : C ⥤ D) [functor.additive F]\n\nvariables [preserves_finite_limits F] [preserves_finite_colimits F]\n\n@[simps]\ndef apply_exact_functor : homology_iso_datum (F.map f) (F.map g) (F.obj H) :=\n{ to_homology_iso_predatum := h.to_homology_iso_predatum.apply_functor F,\n  fork_is_limit := begin\n    let e : parallel_pair g 0 ⋙ F ≅ parallel_pair (F.map g) 0 :=\n      parallel_pair.ext (iso.refl _) (iso.refl _) (by simp) (by simp),\n    have hF := (is_limit.postcompose_inv_equiv e.symm _).inv_fun\n      (is_limit_of_preserves F h.fork_is_limit),\n    refine is_limit.of_iso_limit hF (cones.ext (iso.refl _) _),\n    rintro (_|_),\n    tidy,\n  end,\n  cofork_is_colimit := begin\n    let e : parallel_pair h.f' 0 ⋙ F ≅ parallel_pair (F.map h.f') 0 :=\n      parallel_pair.ext (iso.refl _) (iso.refl _) (by simp) (by simp),\n    have hF := (is_colimit.precompose_inv_equiv e _).inv_fun\n      (is_colimit_of_preserves F h.cofork_is_colimit),\n    refine is_colimit.of_iso_colimit hF (cocones.ext (iso.refl _) _),\n    rintro (_|_),\n    tidy,\n  end, }\n\nend apply_exact_functor\n\nsection homological_complex\n\nvariables {A : Type*} [category A] [abelian A]\nvariables {M : Type*} {c : complex_shape M}\n\ndef of_homological_complex (X : homological_complex A c) (i j k : M)\n  (hij : c.rel i j) (hjk : c.rel j k) :\n  homology_iso_datum (X.d i j) (X.d j k) (X.homology j) :=\nbegin\n  refine (homology_iso_datum.tautological' (X.d_to j) (X.d_from j)\n    (X.d_to_comp_d_from j)).map_iso _ _ _ _ _,\n  { refine arrow.iso_mk (X.X_prev_iso hij) (iso.refl _) _,\n    dsimp,\n    simp only [X.d_to_eq hij, category.comp_id], },\n  { refine arrow.iso_mk (iso.refl _) (X.X_next_iso hjk) _,\n    dsimp,\n    simp only [X.d_from_eq hjk, category.id_comp, category.assoc, iso.inv_hom_id,\n      category.comp_id], },\n  { refl, },\nend\n\nopen_locale zero_object\n\nend homological_complex\n\nsection has_homology\n\nvariables (f g)\n\nlemma homology_iso_cokernel_lift_comp_ι :\n  (homology_iso_cokernel_lift f g w).inv ≫ homology.ι f g w =\n  cokernel.map _ _ (𝟙 X) (kernel.ι g) (by simp only [kernel.lift_ι, category.id_comp]) :=\nbegin\n  ext,\n  dsimp [homology_iso_cokernel_lift, homology.ι,\n    homology_iso_cokernel_image_to_kernel', homology_iso_kernel_desc],\n  simp only [cokernel_iso_of_eq_inv_comp_desc, category.assoc, cokernel.π_desc_assoc, cokernel.π_desc,\n    cokernel_iso_of_eq_hom_comp_desc_assoc, kernel.lift_ι, kernel_subobject_arrow_assoc,\n    kernel_subobject_arrow'_assoc],\nend\n\nlemma homology_ι_eq :\n  homology.ι f g w = (homology_iso_cokernel_lift f g w).hom ≫\n    cokernel.map _ _ (𝟙 X) (kernel.ι g) (by simp only [kernel.lift_ι, category.id_comp]) :=\nby simp only [← homology_iso_cokernel_lift_comp_ι, iso.hom_inv_id_assoc]\n\nvariables {f g}\n\nlemma iso_hom_homology_ι_eq_iso₂_hom_cokernel_map :\n  h.iso.hom ≫ homology.ι f g h.w = h.iso₂.hom ≫ cokernel.map h.f' f (𝟙 X) h.ι (by simp) :=\nbegin\n  dsimp only [iso, iso₂, iso₃],\n  simp only [homology_ι_eq f g h.w, iso.refl_hom, iso.trans_hom, cokernel.map_iso_hom,\n    iso.symm_hom, category.assoc, iso.inv_hom_id_assoc, iso.cancel_iso_hom_left],\n  ext,\n  simp only [cokernel.π_desc_assoc, category.assoc, cokernel.π_desc, iso₁_hom_kernel_ι_assoc],\nend\n\nlemma homology_π'_eq :\n  homology.π' f g h.w = h.iso₁.inv ≫ h.π ≫ h.iso.hom :=\nbegin\n  rw ← cancel_mono (homology.ι f g h.w),\n  dsimp only [iso],\n  simp only [homology.π'_ι, category.assoc, iso.trans_hom, iso.symm_hom,\n    homology_iso_cokernel_lift_comp_ι, ← cokernel_π_iso₂_inv, iso.inv_hom_id_assoc,\n    cokernel_π_iso₃_hom_assoc, cokernel.π_desc],\nend\n\nlemma iso_inv : h.iso.inv = homology.desc' f g h.w (h.iso₁.inv ≫ h.π)\n  (by simp only [← h.f'_iso₁_hom, category.assoc, h.iso₁.hom_inv_id_assoc,\n    homology_iso_predatum.zero₂]) :=\nby rw [← cancel_epi (homology.π' f g h.w), homology.π'_desc', homology_π'_eq,\n    category.assoc, category.assoc, h.iso.hom_inv_id, category.comp_id]\n\nlemma iso_hom : h.iso.hom = homology.lift f g h.w\n  (h.iso₂.hom ≫ cokernel.map h.f' f (𝟙 X) h.ι (by simp))\n  begin\n    rw ← cancel_epi h.iso₂.inv,\n    ext,\n    simp only [category.assoc, iso.inv_hom_id_assoc, cokernel.π_desc_assoc,\n      cokernel.π_desc, homology_iso_predatum.zero₁, comp_zero],\n  end :=\nbegin\n  rw [← cancel_epi h.iso.inv, h.iso.inv_hom_id, h.iso_inv,\n    ← cancel_mono (homology.ι f g h.w), ← cancel_epi (homology.π' f g h.w),\n    ← cancel_epi h.iso₁.hom],\n  simp only [category.assoc, category.id_comp, homology.π'_ι, homology.lift_ι,\n    homology.π'_desc'_assoc, h.iso₁.hom_inv_id_assoc, h.iso₁_hom_kernel_ι_assoc,\n    ← cokernel_π_iso₂_inv, h.iso₂.inv_hom_id_assoc, cokernel.π_desc],\nend\n\n@[simps]\ndef has_homology : has_homology f g H :=\n{ w := h.w,\n  π := h.iso₁.inv ≫ h.π,\n  ι := h.iso₂.hom ≫ cokernel.map h.f' f (𝟙 X) h.ι (by simp),\n  π_ι := by simp only [category.assoc, ← cokernel_π_iso₂_inv_assoc, iso.inv_hom_id_assoc,\n      cokernel.π_desc, ← h.iso₁_hom_kernel_ι],\n  ex_π := begin\n    refine preadditive.exact_of_iso_of_exact (kernel.lift g f h.w)\n      (cokernel.π (kernel.lift g f h.w)) _ _ (iso.refl _) _ _ (abelian.exact_cokernel _),\n    { refine arrow.iso_mk (iso.refl _) (h.iso₃.symm ≪≫ h.iso₂.symm) _,\n      dsimp,\n      simp only [← cancel_mono h.iso₂.hom, ← cancel_mono h.iso₃.hom,\n        category.id_comp, category.assoc, ← cokernel_π_iso₂_inv,\n        iso.inv_hom_id_assoc, cokernel_π_iso₃_hom,\n        iso.inv_hom_id, category.comp_id], },\n    { refl, },\n  end,\n  ι_ex := begin\n    refine preadditive.exact_of_iso_of_exact (homology.ι f g h.w) (cokernel.desc f g h.w)\n      _ _ _ (iso.refl _) _ (homology.has f g h.w).ι_ex,\n    { refine arrow.iso_mk h.iso.symm (iso.refl _) _,\n      dsimp,\n      simp only [← h.iso_hom_homology_ι_eq_iso₂_hom_cokernel_map,\n        iso.inv_hom_id_assoc, category.comp_id], },\n    { refl, },\n  end,\n  epi_π := epi_comp _ _,\n  mono_ι := begin\n    rw ← iso_hom_homology_ι_eq_iso₂_hom_cokernel_map,\n    apply_instance,\n  end, }\n\nend has_homology\n\nvariables (f g)\n\n@[simps]\ndef of_f_is_zero (hf : f = 0) : homology_iso_datum f g (kernel g) :=\n{ w := by rw [hf, zero_comp],\n  K := kernel g,\n  ι := kernel.ι g,\n  f' := 0,\n  fac' := by rw [hf, zero_comp],\n  zero₁' := kernel.condition g,\n  π := 𝟙 _,\n  zero₂' := by rw zero_comp,\n  fork_is_limit := kernel_is_kernel g,\n  cofork_is_colimit := is_colimit_aux _ (λ s, s.π) (λ s, by apply category.id_comp)\n    (λ s m hm, begin rw [← hm], symmetry, apply category.id_comp, end), }\n\n@[simps]\ndef of_g_is_zero (hg : g = 0) : homology_iso_datum f g (cokernel f) :=\n{ w := by rw [hg, comp_zero],\n  K := Y,\n  ι := 𝟙 Y,\n  f' := f,\n  fac' := category.comp_id _,\n  zero₁' := by rw [hg, comp_zero],\n  π := cokernel.π f,\n  zero₂' := cokernel.condition f,\n  fork_is_limit := is_limit_aux _ (λ s, s.ι) (λ s, by apply category.comp_id)\n    (λ s m hm, begin rw [← hm], symmetry, apply category.comp_id, end),\n  cofork_is_colimit := by apply cokernel_is_cokernel, }\n\n@[simps]\ndef of_both_zeros (hf : f = 0) (hg : g = 0) : homology_iso_datum f g Y :=\n{ w := by rw [hg, comp_zero],\n  K := Y,\n  ι := 𝟙 Y,\n  f' := 0,\n  fac' := by rw [hf, zero_comp] ,\n  zero₁' := by rw [hg, comp_zero],\n  π := 𝟙 Y,\n  zero₂' := zero_comp,\n  fork_is_limit := is_limit_aux _ (λ s, s.ι) (λ s, by apply category.comp_id)\n    (λ s m hm, begin rw [← hm], symmetry, apply category.comp_id, end),\n  cofork_is_colimit := is_colimit_aux _ (λ s, s.π) (λ s, by apply category.id_comp)\n    (λ s m hm, begin rw [← hm], symmetry, dsimp, apply category.id_comp, end), }\n\nend homology_iso_datum\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/homology_iso_datum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696748, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4891646934740854}}
{"text": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\n\nimport ring_theory.adjoin_root\nimport algebra.direct_limit\nimport set_theory.schroeder_bernstein\nimport ring_theory.integral_closure\n\nuniverses u v w\nopen polynomial zorn set function\nvariables {K : Type u} [discrete_field K]\nnoncomputable theory\n\n/- Turn down the instance priority for subtype.decidable_eq and use classical.dec_eq everywhere,\n  to avoid diamonds -/\nlocal attribute [instance, priority 0] subtype.decidable_eq\n\nlemma injective_eq {α : Sort*} : injective (eq : α → α → Prop) :=\nλ _ _ h, h.symm ▸ rfl\n\nsection minimal_polynomial\n/- To be moved -/\nvariables {α : Type u} {β : Type v} [discrete_field α] [discrete_field β] [algebra α β]\n\ndef minimal_polynomial {x : β} (hx : is_integral α x) : polynomial α := sorry\n\nlemma minimal_polynomial_irreducible {x : β} (hx : is_integral α x) :\n  irreducible (minimal_polynomial hx) := sorry\n\nlemma minimal_polynomial_monic {x : β} (hx : is_integral α x) : monic (minimal_polynomial hx) := sorry\n\n@[simp] lemma aeval_minimal_polynomial {x : β} (hx : is_integral α x) :\n  aeval α β x (minimal_polynomial hx) = 0 := sorry\n\nlemma root_minimal_polynomial {x : β} (hx : is_integral α x) {y : α}\n  (h : (minimal_polynomial hx).eval y = 0) : algebra_map β y = x := sorry\n\nend minimal_polynomial\n\n@[instance] lemma equiv.is_ring_hom {α β : Type*} [ring β] (e : α ≃ β) :\n  @is_ring_hom β α _ (equiv.ring e) e.symm :=\nby split; simp [equiv.mul_def, equiv.add_def, equiv.one_def]\n\ninstance equiv.is_ring_hom.symm {α β : Type*} [ring β] (e : α ≃ β) :\n  @is_ring_hom α β (equiv.ring e) _ e :=\nby split; simp [equiv.mul_def, equiv.add_def, equiv.one_def]\n\ndef equiv.ring_equiv {α β : Type*} [ring β] (e : α ≃ β) :\n  @ring_equiv α β (equiv.ring e) _ :=\n{ hom := by apply_instance, ..e }\n\nlemma exists_root_of_equiv {α β : Type*} [comm_ring α] [comm_ring β] [decidable_eq α]\n  [decidable_eq β] (e : α ≃r β) {f : polynomial α} {x : β} (hx : f.eval₂ e.to_equiv x = 0) :\n  f.eval (e.symm.to_equiv x) = 0 :=\nbegin\n  letI : is_ring_hom e.to_equiv := e.hom,\n  rw [← e.to_equiv.injective.eq_iff,\n    ← eval₂_hom e.to_equiv, ring_equiv.to_equiv_symm,\n    equiv.apply_symm_apply, is_ring_hom.map_zero e.to_equiv, hx],\nend\n\nset_option old_structure_cmd true\n\nstructure alg_equiv (α β γ : Type*) [comm_ring α] [ring β] [ring γ]\n  [algebra α β] [algebra α γ] extends alg_hom α β γ, equiv β γ\n\nset_option old_structure_cmd false\n\ninfix ` ≃ₐ `:25 := alg_equiv _\nnotation A ` ≃ₐ[`:25 R `] ` B := alg_equiv R A B\n\nnamespace alg_equiv\nvariables {α : Type u} {β : Type v} {γ : Type w} [comm_ring α] [ring β] [ring γ]\n  [algebra α β] [algebra α γ]\n\nprotected def symm (e : β ≃ₐ[α] γ) : γ ≃ₐ[α] β := sorry\n\nend alg_equiv\n\nsection thing\n\nlocal attribute [instance] classical.dec\n\nprivate lemma thing_aux {X : Type u} {Y : Type v} {Z : Type w} (fxy : X ↪ Y) (fxz : X ↪ Z)\n  (hYZ : (Z ↪ Y) → false) : ↥-range fxy.1 ↪ ↥-range fxz.1 :=\nclassical.choice $ or.resolve_left embedding.total $\n  λ ⟨f⟩, hYZ $\n    calc Z ↪ range fxz ⊕ ↥-range fxz :\n      (equiv.set.sum_compl _).symm.to_embedding\n    ... ↪ range fxy ⊕ ↥-range fxy :\n      embedding.sum_congr\n        (((equiv.set.range _ fxz.2).symm.to_embedding).trans\n          (equiv.set.range _ fxy.2).to_embedding)\n        f\n    ... ↪ Y : (equiv.set.sum_compl _).to_embedding\n\nprivate def thing {X : Type u} {Y : Type v} {Z : Type w} (fxy : X ↪ Y) (fxz : X ↪ Z)\n  (hYZ : (Z ↪ Y) → false) : Y ↪ Z :=\ncalc Y ↪ range fxy ⊕ ↥-range fxy : (equiv.set.sum_compl _).symm.to_embedding\n... ↪ range fxz ⊕ ↥-range fxz : embedding.sum_congr\n  ((equiv.set.range _ fxy.2).symm.to_embedding.trans\n    (equiv.set.range _ fxz.2).to_embedding)\n  (thing_aux fxy fxz hYZ)\n... ↪ Z : (equiv.set.sum_compl _).to_embedding\n\nprivate lemma thing_commutes {X : Type u} {Y : Type v} {Z : Type w}  (fxy : X ↪ Y) (fxz : X ↪ Z)\n  (hYZ : (Z ↪ Y) → false) (x : X) : thing fxy fxz hYZ (fxy x) = fxz x :=\nhave (⟨fxy x, mem_range_self _⟩ : range fxy) = equiv.set.range _ fxy.2 x, from rfl,\nbegin\n  dsimp only [thing, embedding.trans_apply, equiv.trans_apply, function.comp,\n    equiv.to_embedding_coe_fn],\n  simp only [equiv.set.sum_compl_symm_apply_of_mem (mem_range_self _),\n    embedding.sum_congr_apply_inl, equiv.set.sum_compl_apply_inl,\n    embedding.trans_apply, equiv.to_embedding_coe_fn, this, equiv.symm_apply_apply],\n  refl\nend\n\nend thing\n\nclass is_algebraically_closed (K : Type u) [nonzero_comm_ring K] [decidable_eq K] :=\n(exists_root : ∀ f : polynomial K, 0 < degree f → ∃ x, is_root f x)\n\nsection is_algebraically_closed\n\nlemma is_algebraically_closed_of_irreducible_has_root\n  (h : ∀ f : polynomial K, irreducible f → ∃ x, is_root f x) :\n  is_algebraically_closed K :=\n⟨λ f hf0, let ⟨g, hg⟩ := is_noetherian_ring.exists_irreducible_factor\n  (show ¬ is_unit f, from λ h, by rw [is_unit_iff_degree_eq_zero] at h;\n    rw h at hf0; exact lt_irrefl _ hf0)\n  (λ h, by rw ← degree_eq_bot at h;\n    rw h at hf0; exact absurd hf0 dec_trivial) in\n  let ⟨x, hx⟩ := h g hg.1 in\n  let ⟨i, hi⟩ := hg.2 in\n  ⟨x, by rw [hi, is_root.def, eval_mul, show _ = _, from hx, zero_mul]⟩⟩\n\n-- /- An algebraic extension of -/\n-- lemma equiv_of_algebraic\n\nend is_algebraically_closed\n\nnamespace algebraic_closure\n\nsection classical\n\nlocal attribute [instance, priority 1] classical.dec\n\n/-- The `big_type` with cardinality strictly larger than any algebraic extension -/\nprivate def big_type (K : Type u) [discrete_field K] := set (ℕ × polynomial K)\n\nprivate def algebraic_embedding_aux {L : Type*} [discrete_field L] [algebra K L]\n  (h : ∀ l : L, is_integral K l) (x : L) : ℕ × polynomial K :=\nlet f := classical.some (h x) in\n⟨list.index_of x (quotient.out ((f.map (algebra_map L)).roots.1)), f⟩\n\nprivate lemma algebraic_embedding_aux_injective\n  {L : Type*} [discrete_field L] [algebra K L]\n  (h : ∀ l : L, is_integral K l) : injective (algebraic_embedding_aux h) :=\nλ x y hxy,\nlet f := classical.some (h x) in\nlet g := classical.some (h y) in\nhave hf : monic f ∧ aeval K L x f = 0, from classical.some_spec (h x),\nhave hg : monic g ∧ aeval K L y g = 0, from classical.some_spec (h y),\nhave hfg : f = g, from (prod.ext_iff.1 hxy).2,\nhave hfg' : list.index_of x (quotient.out ((f.map (algebra_map L)).roots.1)) =\n    list.index_of y (quotient.out ((f.map (algebra_map L)).roots.1)),\n  from (prod.ext_iff.1 hxy).1.trans (hfg.symm ▸ rfl),\nhave hx : x ∈ quotient.out ((f.map (algebra_map L)).roots.1),\n  from multiset.mem_coe.1 begin\n    show x ∈ quotient.mk _,\n    rw [quotient.out_eq, ← finset.mem_def, mem_roots (mt (map_eq_zero (algebra_map L)).1\n      (ne_zero_of_monic hf.1)), is_root.def, eval_map, ← aeval_def, hf.2],\n  end,\nhave hy : y ∈ quotient.out ((g.map (algebra_map L)).roots.1),\n  from multiset.mem_coe.1 begin\n    show y ∈ quotient.mk _,\n    rw [quotient.out_eq, ← finset.mem_def, mem_roots (mt (map_eq_zero (algebra_map L)).1\n      (ne_zero_of_monic hg.1)), is_root.def, eval_map, ← aeval_def, hg.2],\n  end,\n(list.index_of_inj hx (by rwa hfg)).1 hfg'\n\nprivate def algebraic_embedding_big_type {L : Type*} [discrete_field L] [algebra K L]\n  (h : ∀ l : L, is_integral K l) : L ↪ big_type K :=\n⟨_, injective_comp injective_eq $ algebraic_embedding_aux_injective h⟩\n\nprivate def algebraic_embedding {L : Type*} [discrete_field L] [algebra K L]\n  (h : ∀ l : L, is_integral K l) : L ↪ ℕ × polynomial K :=\n⟨_, algebraic_embedding_aux_injective h⟩\n\nprivate def bembedding (K : Type u) [discrete_field K] : K ↪ big_type K :=\n⟨λ a, show set _, from {(0, X - C a)}, λ a b, by simp [C_inj]⟩\n\ninstance range_bembedding.discrete_field : discrete_field (set.range (bembedding K)) :=\nequiv.discrete_field (equiv.set.range _ (bembedding K).2).symm\n\nprivate structure extension (K : Type u) [discrete_field K] : Type u :=\n(carrier : set (big_type K))\n[field : discrete_field ↥carrier]\n[algebra : algebra K ↥carrier]\n(algebraic : ∀ x : carrier, is_integral K x)\n\nattribute [instance] extension.field extension.algebra\n\nprivate def base_extension (K : Type u) [discrete_field K] : extension K :=\n{ carrier := set.range (bembedding K),\n  algebra := algebra.of_ring_hom (equiv.set.range _ (bembedding K).2).symm.symm\n    (by apply_instance),\n  algebraic := sorry } --a field is algebraic over an isomorphic field\n\n/-- not used but might help woth sorries -/\nprivate def extension.of_algebraic {L : Type v} [discrete_field L] [algebra K L]\n  (hL : ∀ x : L, is_integral K x) : extension K :=\n{ carrier := set.range (algebraic_embedding_big_type hL),\n  field := equiv.discrete_field (equiv.set.range _ (algebraic_embedding_big_type hL).2).symm,\n  algebra := sorry, -- a field isomorphic to an algebra is an algebra\n  algebraic := sorry -- a field isomorphic to an algebraic extension is algebraic\n  }\n\ninstance : preorder (extension K) :=\n{ le := λ L M, ∃ hLM : L.carrier ⊆ M.carrier, is_ring_hom (inclusion hLM),\n  le_refl := λ _, ⟨set.subset.refl _, by convert is_ring_hom.id; ext; simp⟩,\n  le_trans := λ L M N ⟨hLM₁, hLM₂⟩ ⟨hMN₁, hMN₂⟩, ⟨set.subset.trans hLM₁ hMN₁,\n    by resetI; convert is_ring_hom.comp (inclusion hLM₁) (inclusion hMN₁)⟩ }\n\nprivate structure chain' (c : set (extension K)) : Prop :=\n(chain : chain (≤) c)\n\nlocal attribute [class] chain'\n\nprivate lemma is_chain (c : set (extension K)) [chain' c]: chain (≤) c :=\nchain'.chain (by apply_instance)\n\nsection chain\n\nvariables (c : set (extension K)) [hcn : nonempty c]\ninclude c  hcn\n\nvariable [hcn' : chain' c]\ninclude hcn'\n\ninstance chain_directed_order : directed_order c :=\n⟨λ ⟨i, hi⟩ ⟨j, hj⟩, let ⟨k, hkc, hk⟩ := chain.directed_on\n  (is_chain c) i hi j hj in ⟨⟨k, hkc⟩, hk⟩⟩\n\nprivate def chain_map (i j : c) (hij : i ≤ j) : i.1.carrier → j.1.carrier :=\ninclusion (exists.elim hij (λ h _, h))\n\ninstance chain_field_hom (i j : c) (hij : i ≤ j) : is_field_hom (chain_map c i j hij) :=\nexists.elim hij (λ _, id)\n\ninstance chain_directed_system : directed_system (λ i : c, i.1.carrier) (chain_map c) :=\nby split; intros; simp [chain_map]\n\nprivate def chain_limit : Type u := ring.direct_limit (λ i : c, i.1.carrier) (chain_map c)\n\nprivate lemma of_eq_of (x : big_type K) (i j : c) (hi : x ∈ i.1.carrier) (hj : x ∈ j.1.carrier) :\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map c) i ⟨x, hi⟩ =\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map c) j ⟨x, hj⟩ :=\nhave hij : i ≤ j ∨ j ≤ i,\n  from show i.1 ≤ j.1 ∨ j.1 ≤ i.1, from chain.total (is_chain c) i.2 j.2,\nhij.elim\n  (λ hij, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map c) _\n      _ _ _ hij,\n    simp [chain_map, inclusion]\n  end)\n  (λ hij, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map c) _\n      _ _ _ hij,\n    simp [chain_map, inclusion]\n  end)\n\nprivate lemma injective_aux (i j : c)\n  (x y : ⋃ i : c, i.1.carrier) (hx : x.1 ∈ i.1.carrier) (hy : y.1 ∈ j.1.carrier) :\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map c) i ⟨x, hx⟩ =\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map c) j ⟨y, hy⟩ →\n  x = y :=\nhave hij : i ≤ j ∨ j ≤ i,\n  from show i.1 ≤ j.1 ∨ j.1 ≤ i.1, from chain.total (is_chain c) i.2 j.2,\nhave hinj : ∀ (i j : c) (hij : i ≤ j), injective (chain_map c i j hij),\n  from λ _ _ _, is_field_hom.injective _,\nhij.elim\n  (λ hij h, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map c) _\n      _ _ _ hij at h,\n    simpa [chain_map, inclusion, subtype.coe_ext.symm] using ring.direct_limit.of_inj hinj j h,\n  end)\n  (λ hji h, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map c) _\n      _ _ _ hji at h,\n    simpa [chain_map, inclusion, subtype.coe_ext.symm] using ring.direct_limit.of_inj hinj i h,\n  end)\n\nprivate def equiv_direct_limit : (⋃ (i : c), i.1.carrier) ≃\n  ring.direct_limit (λ i : c, i.1.carrier) (chain_map c) :=\n@equiv.of_bijective (⋃ i : c, i.1.carrier)\n  (ring.direct_limit (λ i : c, i.1.carrier) (chain_map c))\n  (λ x, ring.direct_limit.of _ _ (classical.some (set.mem_Union.1 x.2))\n    ⟨_, classical.some_spec (set.mem_Union.1 x.2)⟩)\n  ⟨λ x y, injective_aux _ _ _ _ _ _ _,\n    λ x, let ⟨i, ⟨y, hy⟩, hy'⟩ := ring.direct_limit.exists_of x in\n      ⟨⟨y, _, ⟨i, rfl⟩, hy⟩, begin\n        convert hy',\n        exact of_eq_of _ _ _ _ _ _\n      end⟩⟩\n\ninstance Union_field : discrete_field (⋃ i : c, i.1.carrier) :=\n@equiv.discrete_field _ _ (equiv_direct_limit c)\n  (field.direct_limit.discrete_field _ _)\n\nset_option class.instance_max_depth 50\n\ninstance is_field_hom_Union (i : c) : is_field_hom\n  (inclusion (set.subset_Union (λ i : c, i.1.carrier) i)) :=\nsuffices inclusion (set.subset_Union (λ i : c, i.1.carrier) i) =\n    ((equiv_direct_limit c).symm ∘\n    ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map c) i),\n  by rw this; exact is_ring_hom.comp _ _,\nfunext $ λ ⟨_, _⟩,\n  (equiv_direct_limit c).injective $\n    by rw [function.comp_app, equiv.apply_symm_apply];\n      exact of_eq_of _ _ _ _ _ _\n\nend chain\n\n--def maximal_extension (c : set (extension K)) (hc : chain (≤) c) : extension K :=\n\nprivate def maximal_extension_chain (c : set (extension K)) (hc : chain (≤) c) :\n  { ub : extension K // ∀ L, L ∈ c → L ≤ ub } :=\nif h : nonempty c\n  then by letI : chain' c := ⟨hc⟩; exact\n    ⟨{ carrier := ⋃ (i : c), i.1.carrier,\n       /- of_ring_hom probably works here. Field is isomorphic to direct limit of a bunch of extensions -/\n        algebra := sorry,\n        algebraic := sorry }, -- Field is isomorphic to direct limit of some algebraic extensions\n    λ e he, ⟨by convert subset_Union _ (⟨e, he⟩ : c); refl,\n      algebraic_closure.is_field_hom_Union c ⟨e, he⟩⟩⟩\n  else ⟨base_extension K, λ a ha, (h ⟨⟨a, ha⟩⟩).elim⟩\n\nsection adjoin_root\nvariables {L : extension K} (f : polynomial L.carrier) [hif : irreducible f]\ninclude hif\n\n-- instance adjoin_root_algebraic_closure.field :\n--   discrete_field (adjoin_root f) := adjoin_root.field\n\n-- instance adjoin_root_algebraic_closure.is_ring_hom :\n--   is_ring_hom (@adjoin_root.of _ _ _ f) := adjoin_root.is_ring_hom\n\n-- uncommenting the above instance fixes this\nprivate def adjoin_root.of_embedding : L.carrier ↪ adjoin_root f :=\n⟨adjoin_root.of, @is_field_hom.injective _ _ _ _ _ $ by apply_instance⟩\n\n/- TODO: move -/\ninstance adjoin_root.algebra : algebra K (adjoin_root f) :=\nalgebra.of_ring_hom (adjoin_root.of ∘ algebra_map _) (is_ring_hom.comp _ _)\n\nvariable (K)\n\nprivate def adjoin_root_extension_map : adjoin_root f ↪ big_type K :=\nthing (adjoin_root.of_embedding f) ⟨subtype.val, subtype.val_injective⟩\n  (λ i, let e : big_type K ↪ ℕ × polynomial K := i.trans\n      (algebraic_embedding sorry) in --adjoining a root to an algebraic extension gives an algebraic extension\n    cantor_injective e.1 e.2)\n\nprivate lemma adjoin_root_extension_map_apply (x : L.carrier) :\n  (adjoin_root_extension_map K f) (@adjoin_root.of _ _ _ f x) = x.val :=\nthing_commutes _ _ _ _\n\ninstance range_adjoin_root_extension_map.discrete_field :\n  discrete_field (set.range (@adjoin_root_extension_map K _ _ f _)) :=\nequiv.discrete_field (equiv.set.range _ (embedding.inj _)).symm\n\nprivate def adjoin_root_extension : extension K :=\n{ carrier := set.range (@adjoin_root_extension_map K _ _ f _),\n  algebra := algebra.of_ring_hom\n    ((equiv.set.range _ (embedding.inj' (adjoin_root_extension_map K f))).symm.symm ∘\n      algebra_map _) (is_ring_hom.comp _ _),\n  algebraic := sorry } -- adjoining a root to an algebraic extension gives an algebraic extension\n\nvariable {L}\nprivate lemma subset_adjoin_root_extension : L.carrier ⊆ (adjoin_root_extension K f).carrier :=\nλ x h, ⟨adjoin_root.of_embedding f ⟨x, h⟩, thing_commutes _ _ _ _⟩\n\nprivate lemma adjoin_root_inclusion_eq : inclusion (subset_adjoin_root_extension K f) =\n  ((equiv.set.range _ (adjoin_root_extension_map K f).2).symm.symm ∘ adjoin_root.of_embedding f) :=\nfunext $ λ ⟨_, _⟩, subtype.eq $ eq.symm $ adjoin_root_extension_map_apply _ _ _\n\nprivate lemma le_adjoin_root_extension : L ≤ adjoin_root_extension K f :=\n⟨subset_adjoin_root_extension K f,\n  by rw [adjoin_root_inclusion_eq]; dsimp [adjoin_root.of_embedding]; exact is_ring_hom.comp _ _⟩\n\nprivate def equiv_adjoin_root_of_le (h : adjoin_root_extension K f ≤ L) :\n  L.carrier ≃r adjoin_root f :=\nhave left_inv : left_inverse (inclusion h.fst ∘ (equiv.set.range _\n    (adjoin_root_extension_map K f).2)) adjoin_root.of,\n  from λ _, by simp [adjoin_root_extension_map_apply, inclusion],\n{ to_fun := coe,\n  inv_fun := inclusion h.fst ∘ (equiv.set.range _ (adjoin_root_extension_map K f).2),\n  left_inv := left_inv,\n  right_inv := right_inverse_of_injective_of_left_inverse\n    (injective_comp (inclusion_injective _) (equiv.injective _))\n    left_inv,\n  hom := by apply_instance }\n\nprivate def adjoin_root_equiv_adjoin_root_extension : adjoin_root f ≃r (adjoin_root_extension K f).carrier :=\n(equiv.set.range _ (adjoin_root_extension_map K f).2).symm.ring_equiv.symm\n\nend adjoin_root\n\nprivate lemma exists_algebraic_closure (K : Type u) [discrete_field K] :\n  ∃ m : extension K, ∀ a, m ≤ a → a ≤ m :=\nzorn (λ c hc, (maximal_extension_chain c hc).exists_of_subtype) (λ _ _ _, le_trans)\n\nprivate def closed_extension (K : Type u) [discrete_field K] :=\nclassical.some (exists_algebraic_closure K)\n\ndef algebraic_closure (K : Type u) [discrete_field K] : Type u :=\n((classical.some (exists_algebraic_closure K))).carrier\n\nend classical\n\nsection is_algebraically_closed\n/- In this section we prove the algebraic closure is algebraically closed -/\n\nlocal attribute [reducible] algebraic_closure\n\nvariables (f : polynomial (algebraic_closure K)) [hif : irreducible f]\ninclude hif\n\nvariable (K)\n\ndef algebraic_closure_equiv_adjoin_root : algebraic_closure K ≃r adjoin_root f :=\nequiv_adjoin_root_of_le K f $\n  classical.some_spec (exists_algebraic_closure K) _ (le_adjoin_root_extension _ _)\n\ninstance ring_equiv.is_semiring_hom {α β : Type*} [ring α] [ring β] (e : α ≃r β) :\n  is_semiring_hom (e.to_equiv : α → β) :=\nis_ring_hom.is_semiring_hom _\n\nomit hif\n\nprivate def is_algebraically_closed_aux : is_algebraically_closed (algebraic_closure K) :=\nis_algebraically_closed_of_irreducible_has_root $\nλ f hf, let e := by exactI algebraic_closure_equiv_adjoin_root K f in\n⟨_, exists_root_of_equiv e (adjoin_root.eval₂_root f)⟩\n\nend is_algebraically_closed\n\n/- To avoid diamonds, the `decidable_eq` instance is set to `classical.dec_eq`,\n  as opposed to the (noncomputable, but not def-eq to `classical.dec_eq`) instance given by\n  `(closed_extension K).field` -/\ninstance : discrete_field (algebraic_closure K) :=\n{ has_decidable_eq := classical.dec_eq _,\n  ..(closed_extension K).field }\n\ninstance : algebra K (algebraic_closure K) := (closed_extension K).algebra\n\ninstance : is_algebraically_closed (algebraic_closure K) :=\nby convert is_algebraically_closed_aux K\n\nprotected def is_integral : ∀ x : algebraic_closure K, is_integral K x :=\n(closed_extension K).algebraic\n\nattribute [irreducible] algebraic_closure closed_extension algebraic_closure.algebra\n\nsection lift\n/- In this section, the homomorphism from any algebraic extension into an algebraically\n  closed extension is proven to exist. The assumption that M is algebraically closed could probably\n  easily be switched to an assumption that M contains all the roots of polynomials in K -/\nvariables {L : Type v} {M : Type w} [discrete_field L] [algebra K L]\n  [discrete_field M] [algebra K M] [is_algebraically_closed M] (hL : ∀ x : L, is_integral K x)\n\n/-- This structure is used to prove the existence of a homomorphism from any algebraic extension\n  into an algebraic closure -/\nvariables (K L M)\ninclude hL\n\nprivate structure subfield_and_hom extends extension K :=\n( to_algebraically_closed : carrier →ₐ[K] M )\n( to_field : carrier →ₐ[K] L )\n\nvariables {K L M}\n\ninstance subfield_and_hom.preorder : preorder (subfield_and_hom K L M hL) :=\npreorder.lift subfield_and_hom.to_extension (by apply_instance)\n\nprivate def maximal_subfield_and_hom_chain (c : set (subfield_and_hom K L M hL)) (hc : chain (≤) c) :\n  ∃ ub : subfield_and_hom K L M hL, ∀ N, N ∈ c → N ≤ ub :=\nlet ub := (maximal_extension_chain (subfield_and_hom.to_extension '' c) (chain.image (≤) _ _ (λ _ _, id) hc)) in\n⟨{ to_algebraically_closed := sorry, --field in question is direct limit of a bunch of fields with\n      --algebra homs into M\n    to_field := sorry, -- direct limit of a bunch of subfields is also a subfield\n    ..ub.1 },\n   λ n hN, ub.2 _ (mem_image_of_mem _ hN)⟩\n\nprivate lemma exists_maximal_subfield_and_hom : ∃ N : subfield_and_hom K L M hL,\n  ∀ O, N ≤ O → O ≤ N :=\nzorn (maximal_subfield_and_hom_chain _) (λ _ _ _, le_trans)\n\nvariable (M)\n\nprivate def maximal_subfield_and_hom : subfield_and_hom K L M hL :=\nclassical.some (exists_maximal_subfield_and_hom hL)\n\ninstance akgh : algebra (maximal_subfield_and_hom M hL).carrier L :=\nalgebra.of_ring_hom (maximal_subfield_and_hom M hL).to_field (by apply_instance)\n\n-- Given K:L:M, if M is algebraic over K it is algebraic over L (names are different)\nprivate lemma is_integral_over_maximal (x : L) : is_integral (maximal_subfield_and_hom M hL).carrier x := sorry\n\nvariables (f : polynomial (maximal_subfield_and_hom M hL).carrier) [hif : irreducible f]\n  {x : L} (hxf : f.eval₂ (maximal_subfield_and_hom M hL).to_field x = 0)\n\ninclude hif hxf\n\nprivate def adjoin_root_subfield_and_hom : subfield_and_hom K L M hL :=\n{ to_algebraically_closed := sorry, -- should be adjoin_root.lift composed with an isomorphism\n  to_field := sorry, --\n  ..adjoin_root_extension K f }\n\nprivate lemma le_adjoin_root_subfield_and_hom : maximal_subfield_and_hom M hL ≤\n  adjoin_root_subfield_and_hom M hL f hxf :=\nle_adjoin_root_extension _ _\n\nprivate def maximal_subfield_and_hom_equiv_adjoin_root :=\nequiv_adjoin_root_of_le K f $\n  classical.some_spec (exists_maximal_subfield_and_hom hL) _\n    (le_adjoin_root_subfield_and_hom M hL f hxf)\n\nomit hif hxf\n\nprivate lemma surjective_maximal_subfield_and_hom_to_field :\n  function.surjective (maximal_subfield_and_hom M hL).to_field :=\nλ x, let hx := is_integral_over_maximal M hL x in\nby letI := minimal_polynomial_irreducible hx; exact\n⟨_, root_minimal_polynomial hx\n  (exists_root_of_equiv (maximal_subfield_and_hom_equiv_adjoin_root M hL _\n    (aeval_minimal_polynomial hx)) (adjoin_root.eval₂_root _))⟩\n\nprivate def equiv_maximal_subfield_and_hom :\n  (maximal_subfield_and_hom M hL).carrier ≃ₐ[K] L :=\n{ ..(maximal_subfield_and_hom M hL).to_field,\n  ..equiv.of_bijective\n    ⟨is_field_hom.injective _, surjective_maximal_subfield_and_hom_to_field _ _⟩ }\n\n/-- The hom from an algebraic extension of K into an algebraic closure -/\ndef lift : L →ₐ[K] M :=\n(maximal_subfield_and_hom M hL).to_algebraically_closed.comp\n(equiv_maximal_subfield_and_hom M hL).symm.to_alg_hom\n\nend lift\n\nend algebraic_closure", "meta": {"author": "ChrisHughes24", "repo": "type_class", "sha": "b582b60bdc84b7cd17b4243600088143afddc65c", "save_path": "github-repos/lean/ChrisHughes24-type_class", "path": "github-repos/lean/ChrisHughes24-type_class/type_class-b582b60bdc84b7cd17b4243600088143afddc65c/current_mathlib/src/algebraic_closure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696748, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4891646934740854}}
{"text": "/-\nCopyright (c) 2017 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Mario Carneiro\n-/\n\nimport Mathlib.Tactic.NormNum\n\n/-!\n# Tests for `norm_num` extensions\n-/\n\n-- We deliberately mock R and C here so that we don't have to import the deps\naxiom Real : Type\nnotation \"ℝ\" => Real\n@[instance] axiom Real.linearOrderedRing : LinearOrderedField ℝ\n\naxiom Complex : Type\nnotation \"ℂ\" => Complex\n@[instance] axiom Complex.field : Field ℂ\n@[instance] axiom Complex.charZero : CharZero ℂ\n\nexample : 43 ≤ 74 + (33 : ℤ) := by norm_num1\n-- example : 374 + (32 - (2 * 8123) : ℤ) - 61 * 50 = 86 + 32 * 32 - 4 * 5000\n--       ∧ 43 ≤ 74 + (33 : ℤ) := by norm_num1\n\nexample : ¬ (7-2)/(2*3) ≥ (1:ℝ) + 2/(3^2) := by norm_num1\nexample : (6:ℝ) + 9 = 15 := by norm_num1\nexample : (2:ℝ)/4 + 4 = 3*3/2 := by norm_num1\nexample : (((3:ℝ)/4)-12)<6 := by norm_num1\nexample : (5:ℝ) ≠ 8 := by norm_num1\nexample : (10:ℝ) > 7 := by norm_num1\nexample : (2:ℝ) * 2 + 3 = 7 := by norm_num1\nexample : (6:ℝ) < 10 := by norm_num1\nexample : (7:ℝ)/2 > 3 := by norm_num1\nexample : (4:ℝ)⁻¹ < 1 := by norm_num1\nexample : ((1:ℝ) / 2)⁻¹ = 2 := by norm_num1\n-- example : 2 ^ 17 - 1 = 131071 := by norm_num1\n-- example : (3 : ℝ) ^ (-2 : ℤ) = 1/9 := by norm_num1\n-- example : (3 : ℝ) ^ (-2 : ℤ) = 1/9 := by norm_num1\n-- example : (-3 : ℝ) ^ (0 : ℤ) = 1 := by norm_num1\n-- example : (-3 : ℝ) ^ (-1 : ℤ) = -1/3 := by norm_num1\n-- example : (-3 : ℝ) ^ (2 : ℤ) = 9 := by norm_num1\n\nsection InvLit\n\nvariable [DivisionRing α]\n\nexample : (0 : α)⁻¹ = 0 := by norm_num1\nexample : (1 : α)⁻¹ = 1 := by norm_num1\nexample : (-1 : α)⁻¹ = -1 := by norm_num1\n\nend InvLit\n\nexample (h : x = 1) : x = (1/5 + 4/5 : ℚ) := by norm_num1; exact h\nexample (h : x = 1) : x = (5 * 5⁻¹ : ℚ) := by norm_num1; exact h\nexample (h : x = 1) : x = (6/5 - 1/5 : ℚ) := by norm_num1; exact h\nexample (h : x = 1) : x = ((6/5) ^ 0 : ℚ) := by norm_num1; exact h\n\n/-\n# `=` and `≠`\n-/\n\nsection Equality\n\nsection Bool\n\nexample : True := by norm_num1\nexample (h : False) : ¬True := by norm_num1; guard_target =ₛ False; exact h\nexample : ¬¬¬¬True := by norm_num1\nexample : ¬False := by norm_num1\n\nend Bool\n\nsection Nat\n\nvariable [AddMonoidWithOne α] [CharZero α]\n\n-- Normalize to True\nexample : 1 = 1 := by norm_num1\nexample : 1 ≠ 2 := by norm_num1\n\nexample : (1 : α) ≠ 2 := by norm_num1\n\n-- Normalize to False\nexample : ¬(1 = 2) := by norm_num1\nexample : ¬((1 : α) = 2) := by norm_num1\n\nexample : ¬((1 : α) ≠ 1) := by norm_num1\n\nend Nat\n\nsection Semiring\n\nvariable [Semiring α] [CharZero α]\n\nexample : (1 : α) ≠ 2 := by norm_num1\n\nend Semiring\n\nsection Int\n\nvariable [Ring α] [CharZero α]\n\n-- Normalize to True\nexample : (1 : ℤ) = 1 := by norm_num1\nexample : (-1 : ℤ) = -1 := by norm_num1\nexample : (1 : α) = 1 := by norm_num1\nexample : (-1 : α) = -1 := by norm_num1\n\nexample : (1 : ℤ) ≠ 2 := by norm_num1\nexample : (1 : ℤ) ≠ -2 := by norm_num1\nexample : (-1 : ℤ) ≠ -2 := by norm_num1\nexample : (1 : α) ≠ 2 := by norm_num1\nexample : (-1 : α) ≠ 2 := by norm_num1\nexample : (-1 : α) ≠ -2 := by norm_num1\n\n-- Normalize to False\nexample : ((1 : ℤ) = 2) = False := by norm_num1\nexample : ((-1 : ℤ) = 2) = False := by norm_num1\nexample : ((1 : α) = 2) = False := by norm_num1\nexample : ((-1 : α) = 2) = False := by norm_num1\n\nexample : ((1 : ℤ) ≠ 1) = False := by norm_num1\nexample : ((-1 : ℤ) ≠ -1) = False := by norm_num1\nexample : ((1 : α) ≠ 1) = False := by norm_num1\nexample : ((-1 : α) = 2) = False := by norm_num1\n\nend Int\n\nsection Rat\n\nvariable [DivisionRing α] [CharZero α]\n\n-- Normalize to True\nexample : (1 : ℚ) = 1 := by norm_num1\nexample : (-1 : ℚ) = -1 := by norm_num1\nexample : (1/2 : ℚ) = 1/2 := by norm_num1\nexample : (-1/2 : ℚ) = -1/2 := by norm_num1\nexample : (-1/(-2) : ℚ) = -1/(-2) := by norm_num1\nexample : (1 : α) = 1 := by norm_num1\nexample : (-1 : α) = -1 := by norm_num1\nexample : (1/2 : α) = 1/2 := by norm_num1\nexample : (-1/2 : α) = -1/2 := by norm_num1\nexample : (-1/(-2) : α) = -1/(-2) := by norm_num1\n\nexample : (1 : ℚ) ≠ 2 := by norm_num1\nexample : (1 : ℚ) ≠ -2 := by norm_num1\nexample : (-1 : ℚ) ≠ -2 := by norm_num1\nexample : (1/2 : ℚ) ≠ 1 := by norm_num1\nexample : (1/2 : ℚ) ≠ -1 := by norm_num1\nexample : (1/2 : ℚ) ≠ 1/3 := by norm_num1\nexample : (1/2 : ℚ) ≠ 5/2 := by norm_num1\nexample : (1/2 : α) ≠ 1/3 := by norm_num1\nexample : (1/2 : α) ≠ 5/2 := by norm_num1\nexample : (1/2 : α) ≠ -2 := by norm_num1\nexample : (-1 : α) ≠ 2 := by norm_num1\nexample : (1 : α) / 3 ≠ 0 := by norm_num1\nexample : (1 : α) / 3 ≠ 2 / 7 := by norm_num1\n\n-- Normalize to False\nexample : ((1 : ℚ) = 2) = False := by norm_num1\nexample : ((-1 : ℚ) = 2) = False := by norm_num1\nexample : ((1/2 : ℚ) = 2) = False := by norm_num1\nexample : ((1 : α) = 2) = False := by norm_num1\nexample : ((-1 : α) = 2) = False := by norm_num1\nexample : ((1/2 : α) = 2) = False := by norm_num1\n\nexample : ((1 : ℚ) ≠ 1) = False := by norm_num1\nexample : ((-1 : ℚ) ≠ -1) = False := by norm_num1\nexample : ((1/2 : ℚ) ≠ 1/2) = False := by norm_num1\nexample : ((1/2 : α) ≠ 1/2) = False := by norm_num1\n\nend Rat\n\nend Equality\n\n/-\n# `<` and `≤`\n-/\n\nsection Order\n\nsection Nat\n\nvariable [OrderedSemiring α] [CharZero α]\n\n-- Normalize to True\nexample : 1 ≤ 1 := by norm_num1\nexample : (1 : α) ≤ 2 := by norm_num1\n\nexample : 1 < 2 := by norm_num1\nexample : (1 : α) < 2 := by norm_num1\n\n-- Normalize to False\nexample : ¬(2 ≤ 1) := by norm_num1\nexample : ¬((2 : α) ≤ 1) := by norm_num1\n\nexample : ¬(1 < 1) := by norm_num1\nexample : ¬((2 : α) < 2) := by norm_num1\n\nend Nat\n\nsection Int\n\nvariable [OrderedRing α] [Nontrivial α]\n\n-- Normalize to True\nexample : (1 : ℤ) ≤ 1 := by norm_num1\nexample : (-1 : ℤ) ≤ -1 := by norm_num1\nexample : (-1 : ℤ) ≤ 1 := by norm_num1\nexample : (1 : α) ≤ 1 := by norm_num1\nexample : (-1 : α) ≤ -1 := by norm_num1\nexample : (-1 : α) ≤ 1 := by norm_num1\n\nexample : (1 : ℤ) < 2 := by norm_num1\nexample : (-2 : ℤ) < 1 := by norm_num1\nexample : (-1 : ℤ) < 1 := by norm_num1\nexample : (1 : α) < 2 := by norm_num1\nexample : (-1 : α) < 2 := by norm_num1\nexample : (-1 : α) < 1 := by norm_num1\n\n-- Normalize to False\nexample : ¬((2 : ℤ) ≤ 1) := by norm_num1\nexample : ¬((2 : ℤ) ≤ -1) := by norm_num1\nexample : ¬((2 : α) ≤ 1) := by norm_num1\nexample : ¬((2 : α) ≤ -1) := by norm_num1\n\nexample : ¬((2 : ℤ) < 1) := by norm_num1\nexample : ¬((2 : ℤ) < -1) := by norm_num1\nexample : ¬((2 : α) < 1) := by norm_num1\nexample : ¬((2 : α) < -1) := by norm_num1\n\nend Int\n\nsection OrderedCharZeroRing\n\nvariable [OrderedRing α] [CharZero α]\n\nexample : (-1 : α) < 2 := by norm_num1\n\nend OrderedCharZeroRing\n\nsection LinearOrderedRing\n\nvariable [LinearOrderedRing α]\n\nexample : (1 : α) ≤ 1 := by norm_num1\nexample : (-1 : α) ≤ -1 := by norm_num1\nexample : (-1 : α) ≤ 1 := by norm_num1\n\nexample : (1 : α) < 2 := by norm_num1\nexample : (-1 : α) < 2 := by norm_num1\nexample : (-1 : α) < 1 := by norm_num1\n\nend LinearOrderedRing\n\nsection Rat\n\nvariable [LinearOrderedField α] [Nontrivial α]\n\n-- Normalize to True\nexample : (1 : ℚ) ≤ 1 := by norm_num1\nexample : (-1 : ℚ) ≤ -1 := by norm_num1\nexample : (-1 : ℚ) ≤ 1 := by norm_num1\nexample : (-1/2 : ℚ) ≤ 1 := by norm_num1\nexample : (1/2 : ℚ) ≤ 5/4 := by norm_num1\nexample : (1 : α) ≤ 1 := by norm_num1\nexample : (-1 : α) ≤ -1 := by norm_num1\nexample : (-1 : α) ≤ 1 := by norm_num1\nexample : (-1/2 : α) ≤ 1 := by norm_num1\nexample : (1/2 : α) ≤ 5/4 := by norm_num1\n\nexample : (1 : ℤ) < 2 := by norm_num1\nexample : (-2 : ℤ) < 1 := by norm_num1\nexample : (-1 : ℤ) < 1 := by norm_num1\nexample : (-1/2 : ℚ) < 1 := by norm_num1\nexample : (1/2 : ℚ) < 5/4 := by norm_num1\nexample : (1 : α) < 2 := by norm_num1\nexample : (-1 : α) < 2 := by norm_num1\nexample : (-1 : α) < 1 := by norm_num1\nexample : (-1/2 : α) < 1 := by norm_num1\nexample : (1/2 : α) < 5/4 := by norm_num1\n\n-- Normalize to False\nexample : ¬((2 : ℚ) ≤ 1) := by norm_num1\nexample : ¬((2 : ℚ) ≤ -1) := by norm_num1\nexample : ¬((1/2 : ℚ) ≤ -1) := by norm_num1\nexample : ¬((2 : α) ≤ 1) := by norm_num1\nexample : ¬((2 : α) ≤ -1) := by norm_num1\nexample : ¬((1/2 : α) ≤ -1) := by norm_num1\n\nexample : ¬((2 : ℚ) < 1) := by norm_num1\nexample : ¬((2 : ℚ) < -1) := by norm_num1\nexample : ¬((1/2 : ℚ) < -1) := by norm_num1\nexample : ¬((2 : α) < 1) := by norm_num1\nexample : ¬((2 : α) < -1) := by norm_num1\nexample : ¬((1/2 : α) < -1) := by norm_num1\n\nend Rat\n\nend Order\n\nexample : (1:ℂ) ≠ 2 := by norm_num1\nexample : (1:ℂ) / 3 ≠ 2 / 7 := by norm_num1\n\nexample : (1:ℝ) ≠ 2 := by norm_num1\n\n-- example : (5 / 2:ℕ) = 2 := by norm_num1\n-- example : (5 / -2:ℤ) < -1 := by norm_num1\n-- example : (0 + 1) / 2 < 0 + 1 := by norm_num1\n-- example : Nat.succ (Nat.succ (2 ^ 3)) = 10 := by norm_num1\n-- example : 10 = (-1 : ℤ) % 11 := by norm_num1 -- [fixme] ⊢ False ???\nexample : (12321 - 2 : ℤ) = 12319 := by norm_num1\nexample : (63:ℚ) ≥ 5 := by norm_num1\n\nexample (x : ℤ) (h : 1000 + 2000 < x) : 100 * 30 < x :=\nby norm_num at *; exact h\n\nexample : (1103 : ℤ) ≤ (2102 : ℤ) := by norm_num1\nexample : (110474 : ℤ) ≤ (210485 : ℤ) := by norm_num1\nexample : (11047462383473829263 : ℤ) ≤ (21048574677772382462 : ℤ) := by norm_num1\nexample : (210485742382937847263 : ℤ) ≤ (1104857462382937847262 : ℤ) := by norm_num1\nexample : (210485987642382937847263 : ℕ) ≤ (11048512347462382937847262 : ℕ) := by norm_num1\nexample : (210485987642382937847263 : ℚ) ≤ (11048512347462382937847262 : ℚ) := by norm_num1\nexample : (2 * 12868 + 25705) * 11621 ^ 2 ≤ 23235 ^ 2 * 12868 := by norm_num1\n\n-- example (x : ℕ) : ℕ := by\n--   let n : ℕ := by apply_normed (2^32 - 71)\n--   exact n\n\nexample (a : ℚ) (h : 3⁻¹ * a = a) : True := by\n  norm_num1 at h\n  guard_hyp h : 1 / 3 * a = a\n  trivial\n\n-- example (h : (5 : ℤ) ∣ 2) : False := by norm_num1 at h\nexample (h : False) : False := by norm_num1 at h\nexample : True := by norm_num1\n-- example : True ∧ True := by norm_num1\n\n/-!\n# Nat operations\n-/\n\nsection Nat.sub\n\nexample : 10 - 1 = 9 := by norm_num1\nexample : 12 - 5 = 3 + 4 := by norm_num1\nexample : 5 - 20 = 0 := by norm_num1\nexample : 0 - 2 = 0 := by norm_num1\nexample : 4 - (5 - 10) = 2 + (3 - 1) := by norm_num1\nexample : 0 - 0 = 0 := by norm_num1\nexample : 100 - 100 = 0 := by norm_num1\nexample : 5 * (2 - 3) = 0 := by norm_num1\nexample : 10 - 5 * 5 + (7 - 3) * 6 = 27 - 3 := by norm_num1\n\nend Nat.sub\n\nsection Nat.mod\n\nexample : 10 % 1 = 0 := by norm_num1\nexample : 5 % 4 = 1 := by norm_num1\nexample : (9 % 4) % (12 % 8) = 1 := by norm_num1\nexample : 0 % 10 = 0 := by norm_num1\nexample : 10 % 0 = 10 := by norm_num1\nexample : 1 % 1 = 0 := by norm_num1\n\nend Nat.mod\n\n/-!\n# Numbers in algebraic structures\n-/\n\n-- noncomputable def foo : ℝ := 1\n\n-- example : foo = 1 := by norm_num [foo]\n\nsection\n  variable [AddMonoidWithOne α]\n  example : (1 + 0 : α) = (0 + 1 : α) := by norm_num1\n  example : (0 + (2 + 3) + 1 : α) = 6 := by norm_num1\nend\n\nsection\n  variable [Semiring α]\n  example : (70 * (33 + 2) : α) = 2450 := by norm_num1\n  example : (8 + 2 ^ 2 * 3 : α) = 20 := by norm_num1\n  example : ((2 * 1 + 1) ^ 2 : α) = (3 * 3 : α) := by norm_num1\nend\nsection\n  variable [Ring α]\n\n  example : (-1 : α) * 1 = -1 := by norm_num1\n  example : (-2 : α) * 1 = -2 := by norm_num1\n  example : (-2 : α) * -1 = 2 := by norm_num1\n  example : (-2 : α) * -2 = 4 := by norm_num1\n  example : (1 : α) * 0 = 0 := by norm_num1\n\n  example : ((1 : α) + 1) * 5 = 6 + 4 := by norm_num1\n\n  example : (1 : α) = 0 + 1 := by norm_num1\n  example : (1 : α) = 1 + 0 := by norm_num1\n  example : (2 : α) = 1 + 1 := by norm_num1\n  example : (2 : α) = 0 + 2 := by norm_num1\n  example : (3 : α) = 1 + 2 := by norm_num1\n  example : (3 : α) = 2 + 1 := by norm_num1\n  example : (4 : α) = 3 + 1 := by norm_num1\n  example : (4 : α) = 2 + 2 := by norm_num1\n  example : (5 : α) = 4 + 1 := by norm_num1\n  example : (5 : α) = 3 + 2 := by norm_num1\n  example : (5 : α) = 2 + 3 := by norm_num1\n  example : (6 : α) = 0 + 6 := by norm_num1\n  example : (6 : α) = 3 + 3 := by norm_num1\n  example : (6 : α) = 4 + 2 := by norm_num1\n  example : (6 : α) = 5 + 1 := by norm_num1\n  example : (7 : α) = 4 + 3 := by norm_num1\n  example : (7 : α) = 1 + 6 := by norm_num1\n  example : (7 : α) = 6 + 1 := by norm_num1\n  example : 33 = 5 + (28 : α) := by norm_num1\n\n  example : (12 : α) = 0 + (2 + 3) + 7 := by norm_num1\n  example : (105 : α) = 70 + (33 + 2) := by norm_num1\n\n  example : (45000000000 : α) = 23000000000 + 22000000000 := by norm_num1\n\n  example : (0 : α) - 3 = -3 := by norm_num1\n  example : (0 : α) - 2 = -2 := by norm_num1\n  example : (1 : α) - 3 = -2 := by norm_num1\n  example : (1 : α) - 1 = 0 := by norm_num1\n  example : (0 : α) - 3 = -3 := by norm_num1\n  example : (0 : α) - 3 = -3 := by norm_num1\n  example : (12 : α) - 4 - (5 + -2) = 5 := by norm_num1\n  example : (12 : α) - 4 - (5 + -2) - 20 = -15 := by norm_num1\n\n  example : (0 : α) * 0 = 0 := by norm_num1\n  example : (0 : α) * 1 = 0 := by norm_num1\n  example : (0 : α) * 2 = 0 := by norm_num1\n  example : (2 : α) * 0 = 0 := by norm_num1\n  example : (1 : α) * 0 = 0 := by norm_num1\n  example : (1 : α) * 1 = 1 := by norm_num1\n  example : (2 : α) * 1 = 2 := by norm_num1\n  example : (1 : α) * 2 = 2 := by norm_num1\n  example : (2 : α) * 2 = 4 := by norm_num1\n  example : (3 : α) * 2 = 6 := by norm_num1\n  example : (2 : α) * 3 = 6 := by norm_num1\n  example : (4 : α) * 1 = 4 := by norm_num1\n  example : (1 : α) * 4 = 4 := by norm_num1\n  example : (3 : α) * 3 = 9 := by norm_num1\n  example : (3 : α) * 4 = 12 := by norm_num1\n  example : (4 : α) * 4 = 16 := by norm_num1\n  example : (11 : α) * 2 = 22 := by norm_num1\n  example : (15 : α) * 6 = 90 := by norm_num1\n  example : (123456 : α) * 123456 = 15241383936 := by norm_num1\nend\n\nsection\n  variable [LinearOrderedField α]\n  example : (4 : α) / 2 = 2 := by norm_num1\n  example : (4 : α) / 1 = 4 := by norm_num1\n  example : (4 : α) / 3 = 4 / 3 := by norm_num1\n  example : (50 : α) / 5 = 10 := by norm_num1\n  example : (1056 : α) / 1 = 1056 := by norm_num1\n  example : (6 : α) / 4 = 3/2 := by norm_num1\n  example : (0 : α) / 3 = 0 := by norm_num1\n  example : (3 : α) / 0 = 0 := by norm_num1\n  example : (9 * 9 * 9) * (12 : α) / 27 = 81 * (2 + 2) := by norm_num1\n  example : (-2 : α) * 4 / 3 = -8 / 3 := by norm_num1\n  example : - (-4 / 3) = 1 / (3 / (4 : α)) := by norm_num1\nend\n\nsection Transparency\n\nexample : Add.add 10 2 = 12 := by norm_num1\nexample : Nat.sub 10 1 = 9 := by norm_num1\nexample : Nat.mod 10 5 = 0 := by norm_num1\nexample : Sub.sub 10 1 = 9 := by norm_num1\nexample : Sub.sub 10 (-2) = 12 := by norm_num1\nexample : Mul.mul 10 1 = 10 := by norm_num1\nexample : (Div.div 10 1 : ℚ) = 10 := by norm_num1\n\nend Transparency\n\n-- user command\n\n#norm_num 1 = 1\nexample : 1 = 1 := by norm_num1\n-- #norm_num 2^4-1 ∣ 2^16-1\n-- example : 2^4-1 ∣ 2^16-1 := by norm_num1\n-- #norm_num (3 : Real) ^ (-2 : ℤ) = 1/9\n-- example : (3 : Real) ^ (-2 : ℤ) = 1/9 := by norm_num1\n\nsection norm_num_cmd_variable\n\n-- [fixme] obsolete?\n-- variables (x y : ℕ)\n-- #norm_num bit0 x < bit0 (y + x) ↔ 0 < y\n-- example : bit0 x < bit0 (y + x) ↔ 0 < y := by norm_num1\n-- #norm_num bit0 x < bit0 (y + (2^10%11 - 1) + x) ↔ 0 < y\n-- example : bit0 x < bit0 (y + (2^10%11 - 1) + x) ↔ 0 < y := by norm_num1\n-- #norm_num bit0 x < bit0 (y + (2^10%11 - 1) + x) + 3*2-6 ↔ 0 < y\n-- example : bit0 x < bit0 (y + (2^10%11 - 1) + x) + 3*2-6 ↔ 0 < y := by norm_num1\n\nend norm_num_cmd_variable\n\nsection norm_num_erase\n\nexample : 3 ^ 3 + 4 = 31 := by norm_num1\n\nattribute [-norm_num] Mathlib.Meta.NormNum.evalPow in\nexample : 3 ^ 3 + 4 = 31 := by\n  norm_num1\n  guard_target =ₛ 3 ^ 3 + 4 = 31\n  rfl\n\n/- Check that the scoping above works: -/\nexample : 3 ^ 3 + 4 = 31 := by norm_num1\n\nattribute [-norm_num] Mathlib.Meta.NormNum.evalPow\n/-\n  If run, the following commented line of code will produce the error\n  \"'Mathlib.Meta.NormNum.evalPow' does not have [norm_num] attribute\".\n\n  This checks that the `norm_num` attribute is indeed considered to be erased from\n  `Mathlib.Meta.NormNum.evalPow` in this scope.\n-/\n-- attribute [-norm_num] Mathlib.Meta.NormNum.evalPow\n\nend norm_num_erase\n\n-- auto gen tests\nvariable [LinearOrderedField α]\nexample : ((25 * (1 / 1)) + (30 - 16)) = (39 : α) := by norm_num1\nexample : ((19 * (- 2 - 3)) / 6) = (-95/6 : α) := by norm_num1\nexample : - (3 * 28) = (-84 : α) := by norm_num1\nexample : - - (16 / ((11 / (- - (6 * 19) + 12)) * 21)) = (96/11 : α) := by norm_num1\nexample : (- (- 21 + 24) - - (- - (28 + (- 21 / - (16 / ((1 * 26) * ((0 * - 11) + 13))))) * 21)) =\n  (79209/8 : α) := by norm_num1\nexample : (27 * (((16 + - (12 + 4)) + (22 - - 19)) - 23)) = (486 : α) := by norm_num1\nexample : - (13 * (- 30 / ((7 / 24) + - 7))) = (-9360/161 : α) := by norm_num1\nexample : - (0 + 20) = (-20 : α) := by norm_num1\nexample : (- 2 - (27 + (((2 / 14) - (7 + 21)) + (16 - - - 14)))) = (-22/7 : α) := by norm_num1\nexample : (25 + ((8 - 2) + 16)) = (47 : α) := by norm_num1\nexample : (- - 26 / 27) = (26/27 : α) := by norm_num1\nexample : ((((16 * (22 / 14)) - 18) / 11) + 30) = (2360/77 : α) := by norm_num1\nexample : (((- 28 * 28) / (29 - 24)) * 24) = (-18816/5 : α) := by norm_num1\nexample : ((- (18 - ((- - (10 + - 2) - - (23 / 5)) / 5)) - (21 * 22)) -\n  (((20 / - ((((19 + 18) + 15) + 3) + - 22)) + 14) / 17)) = (-394571/825 : α) := by norm_num1\nexample : ((3 + 25) - - 4) = (32 : α) := by norm_num1\nexample : ((1 - 0) - 22) = (-21 : α) := by norm_num1\nexample : (((- (8 / 7) / 14) + 20) + 22) = (2054/49 : α) := by norm_num1\nexample : ((21 / 20) - 29) = (-559/20 : α) := by norm_num1\nexample : - - 20 = (20 : α) := by norm_num1\nexample : (24 - (- 9 / 4)) = (105/4 : α) := by norm_num1\nexample : (((7 / ((23 * 19) + (27 * 10))) - ((28 - - 15) * 24)) + (9 / - (10 * - 3))) =\n  (-1042007/1010 : α) := by norm_num1\nexample : (26 - (- 29 + (12 / 25))) = (1363/25 : α) := by norm_num1\nexample : ((11 * 27) / (4 - 5)) = (-297 : α) := by norm_num1\nexample : (24 - (9 + 15)) = (0 : α) := by norm_num1\nexample : (- 9 - - 0) = (-9 : α) := by norm_num1\nexample : (- 10 / (30 + 10)) = (-1/4 : α) := by norm_num1\nexample : (22 - (6 * (28 * - 8))) = (1366 : α) := by norm_num1\nexample : ((- - 2 * (9 * - 3)) + (22 / 30)) = (-799/15 : α) := by norm_num1\nexample : - (26 / ((3 + 7) / - (27 * (12 / - 16)))) = (-1053/20 : α) := by norm_num1\nexample : ((- 29 / 1) + 28) = (-1 : α) := by norm_num1\nexample : ((21 * ((10 - (((17 + 28) - - 0) + 20)) + 26)) + ((17 + - 16) * 7)) = (-602 : α) :=\nby norm_num1\nexample : (((- 5 - ((24 + - - 8) + 3)) + 20) + - 23) = (-43 : α) := by norm_num1\nexample : ((- ((14 - 15) * (14 + 8)) + ((- (18 - 27) - 0) + 12)) - 11) = (32 : α) := by norm_num1\nexample : (((15 / 17) * (26 / 27)) + 28) = (4414/153 : α) := by norm_num1\nexample : (14 - ((- 16 - 3) * - (20 * 19))) = (-7206 : α) := by norm_num1\nexample : (21 - - - (28 - (12 * 11))) = (125 : α) := by norm_num1\nexample : ((0 + (7 + (25 + 8))) * - (11 * 27)) = (-11880 : α) := by norm_num1\nexample : (19 * - 5) = (-95 : α) := by norm_num1\nexample : (29 * - 8) = (-232 : α) := by norm_num1\nexample : ((22 / 9) - 29) = (-239/9 : α) := by norm_num1\nexample : (3 + (19 / 12)) = (55/12 : α) := by norm_num1\nexample : - (13 + 30) = (-43 : α) := by norm_num1\nexample : - - - (((21 * - - ((- 25 - (- (30 - 5) / (- 5 - 5))) /\n  (((6 + ((25 * - 13) + 22)) - 3) / 2))) / (- 3 / 10)) * (- 8 - 0)) = (-308/3 : α) := by norm_num1\nexample : - (2 * - (- 24 * 22)) = (-1056 : α) := by norm_num1\nexample : - - (((28 / - ((- 13 * - 5) / - (((7 - 30) / 16) + 6))) * 0) - 24) = (-24 : α) :=\nby norm_num1\nexample : ((13 + 24) - (27 / (21 * 13))) = (3358/91 : α) := by norm_num1\nexample : ((3 / - 21) * 25) = (-25/7 : α) := by norm_num1\nexample : (17 - (29 - 18)) = (6 : α) := by norm_num1\nexample : ((28 / 20) * 15) = (21 : α) := by norm_num1\nexample : ((((26 * (- (23 - 13) - 3)) / 20) / (14 - (10 + 20))) / ((16 / 6) / (16 * - (3 / 28)))) =\n(-1521/2240 : α) := by norm_num1\n\nexample : (46 / (- ((- 17 * 28) - 77) + 87)) = (23/320 : α) := by norm_num1\nexample : (73 * - (67 - (74 * - - 11))) = (54531 : α) := by norm_num1\nexample : ((8 * (25 / 9)) + 59) = (731/9 : α) := by norm_num1\nexample : - ((59 + 85) * - 70) = (10080 : α) := by norm_num1\nexample : (66 + (70 * 58)) = (4126 : α) := by norm_num1\nexample : (- - 49 * 0) = (0 : α) := by norm_num1\nexample : ((- 78 - 69) * 9) = (-1323 : α) := by norm_num1\nexample : - - (7 - - (50 * 79)) = (3957 : α) := by norm_num1\nexample : - (85 * (((4 * 93) * 19) * - 31)) = (18624180 : α) := by norm_num1\nexample : (21 + (- 5 / ((74 * 85) / 45))) = (26373/1258 : α) := by norm_num1\nexample : (42 - ((27 + 64) + 26)) = (-75 : α) := by norm_num1\nexample : (- ((38 - - 17) + 86) - (74 + 58)) = (-273 : α) := by norm_num1\nexample : ((29 * - (75 + - 68)) + (- 41 / 28)) = (-5725/28 : α) := by norm_num1\nexample : (- - (40 - 11) - (68 * 86)) = (-5819 : α) := by norm_num1\nexample : (6 + ((65 - 14) + - 89)) = (-32 : α) := by norm_num1\nexample : (97 * - (29 * 35)) = (-98455 : α) := by norm_num1\nexample : - (66 / 33) = (-2 : α) := by norm_num1\nexample : - ((94 * 89) + (79 - (23 - (((- 1 / 55) + 95) * (28 - (54 / - - - 22)))))) =\n(-1369070/121 : α) := by norm_num1\nexample : (- 23 + 61) = (38 : α) := by norm_num1\nexample : - (93 / 69) = (-31/23 : α) := by norm_num1\nexample : (- - ((68 / (39 + (((45 * - (59 - (37 + 35))) / (53 - 75)) -\n - (100 + - (50 / (- 30 - 59)))))) - (69 - (23 * 30))) / (57 + 17)) = (137496481/16368578 : α) :=\nby norm_num1\nexample : (- 19 * - - (75 * - - 41)) = (-58425 : α) := by norm_num1\nexample : ((3 / ((- 28 * 45) * (19 + ((- (- 88 - (- (- 1 + 90) + 8)) + 87) * 48)))) + 1) =\n  (1903019/1903020 : α) := by norm_num1\nexample : ((- - (28 + 48) / 75) + ((- 59 - 14) - 0)) = (-5399/75 : α) := by norm_num1\nexample : (- ((- (((66 - 86) - 36) / 94) - 3) / - - (77 / (56 - - - 79))) + 87) =\n  (312254/3619 : α) := by norm_num1\n\n-- example : 2 ^ 13 - 1 = Int.ofNat 8191 := by norm_num1\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/test/norm_num.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.754914997895581, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4890325954751754}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n\n! This file was ported from Lean 3 source module analysis.special_functions.non_integrable\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.SpecialFunctions.Integrals\nimport Mathbin.Analysis.Calculus.FderivMeasurable\n\n/-!\n# Non integrable functions\n\nIn this file we prove that the derivative of a function that tends to infinity is not interval\nintegrable, see `interval_integral.not_integrable_has_deriv_at_of_tendsto_norm_at_top_filter` and\n`interval_integral.not_integrable_has_deriv_at_of_tendsto_norm_at_top_punctured`.  Then we apply the\nlatter lemma to prove that the function `λ x, x⁻¹` is integrable on `a..b` if and only if `a = b` or\n`0 ∉ [a, b]`.\n\n## Main results\n\n* `not_interval_integrable_of_tendsto_norm_at_top_of_deriv_is_O_punctured`: if `f` tends to infinity\n  along `𝓝[≠] c` and `f' = O(g)` along the same filter, then `g` is not interval integrable on any\n  nontrivial integral `a..b`, `c ∈ [a, b]`.\n\n* `not_interval_integrable_of_tendsto_norm_at_top_of_deriv_is_O_filter`: a version of\n  `not_interval_integrable_of_tendsto_norm_at_top_of_deriv_is_O_punctured` that works for one-sided\n  neighborhoods;\n\n* `not_interval_integrable_of_sub_inv_is_O_punctured`: if `1 / (x - c) = O(f)` as `x → c`, `x ≠ c`,\n  then `f` is not interval integrable on any nontrivial interval `a..b`, `c ∈ [a, b]`;\n\n* `interval_integrable_sub_inv_iff`, `interval_integrable_inv_iff`: integrability conditions for\n  `(x - c)⁻¹` and `x⁻¹`.\n\n## Tags\n\nintegrable function\n-/\n\n\nopen MeasureTheory Topology Interval NNReal ENNReal\n\nopen MeasureTheory TopologicalSpace Set Filter Asymptotics intervalIntegral\n\nvariable {E F : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [SecondCountableTopology E]\n  [CompleteSpace E] [NormedAddCommGroup F]\n\n/-- If `f` is eventually differentiable along a nontrivial filter `l : filter ℝ` that is generated\nby convex sets, the norm of `f` tends to infinity along `l`, and `f' = O(g)` along `l`, where `f'`\nis the derivative of `f`, then `g` is not integrable on any interval `a..b` such that\n`[a, b] ∈ l`. -/\ntheorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_filter {f : ℝ → E} {g : ℝ → F}\n    {a b : ℝ} (l : Filter ℝ) [NeBot l] [TendstoIxxClass Icc l l] (hl : [a, b] ∈ l)\n    (hd : ∀ᶠ x in l, DifferentiableAt ℝ f x) (hf : Tendsto (fun x => ‖f x‖) l atTop)\n    (hfg : deriv f =O[l] g) : ¬IntervalIntegrable g volume a b :=\n  by\n  intro hgi\n  obtain ⟨C, hC₀, s, hsl, hsub, hfd, hg⟩ :\n    ∃ (C : ℝ)(hC₀ : 0 ≤ C),\n      ∃ s ∈ l,\n        (∀ x ∈ s, ∀ y ∈ s, [x, y] ⊆ [a, b]) ∧\n          (∀ x ∈ s, ∀ y ∈ s, ∀ z ∈ [x, y], DifferentiableAt ℝ f z) ∧\n            ∀ x ∈ s, ∀ y ∈ s, ∀ z ∈ [x, y], ‖deriv f z‖ ≤ C * ‖g z‖ :=\n    by\n    rcases hfg.exists_nonneg with ⟨C, C₀, hC⟩\n    have h :\n      ∀ᶠ x : ℝ × ℝ in l.prod l,\n        ∀ y ∈ [x.1, x.2], (DifferentiableAt ℝ f y ∧ ‖deriv f y‖ ≤ C * ‖g y‖) ∧ y ∈ [a, b] :=\n      (tendsto_fst.uIcc tendsto_snd).Eventually ((hd.and hC.bound).And hl).smallSets\n    rcases mem_prod_self_iff.1 h with ⟨s, hsl, hs⟩\n    simp only [prod_subset_iff, mem_set_of_eq] at hs\n    exact\n      ⟨C, C₀, s, hsl, fun x hx y hy z hz => (hs x hx y hy z hz).2, fun x hx y hy z hz =>\n        (hs x hx y hy z hz).1.1, fun x hx y hy z hz => (hs x hx y hy z hz).1.2⟩\n  replace hgi : IntervalIntegrable (fun x => C * ‖g x‖) volume a b\n  · convert hgi.norm.smul C\n  obtain ⟨c, hc, d, hd, hlt⟩ : ∃ c ∈ s, ∃ d ∈ s, (‖f c‖ + ∫ y in Ι a b, C * ‖g y‖) < ‖f d‖ :=\n    by\n    rcases Filter.nonempty_of_mem hsl with ⟨c, hc⟩\n    have : ∀ᶠ x in l, (‖f c‖ + ∫ y in Ι a b, C * ‖g y‖) < ‖f x‖ :=\n      hf.eventually (eventually_gt_at_top _)\n    exact ⟨c, hc, (this.and hsl).exists.imp fun d hd => ⟨hd.2, hd.1⟩⟩\n  specialize hsub c hc d hd\n  specialize hfd c hc d hd\n  replace hg : ∀ x ∈ Ι c d, ‖deriv f x‖ ≤ C * ‖g x‖\n  exact fun z hz => hg c hc d hd z ⟨hz.1.le, hz.2⟩\n  have hg_ae : ∀ᵐ x ∂volume.restrict (Ι c d), ‖deriv f x‖ ≤ C * ‖g x‖ :=\n    (ae_restrict_mem measurableSet_uIoc).mono hg\n  have hsub' : Ι c d ⊆ Ι a b := uIoc_subset_uIoc_of_uIcc_subset_uIcc hsub\n  have hfi : IntervalIntegrable (deriv f) volume c d :=\n    (hgi.mono_set hsub).monoFun' (aeStronglyMeasurableDeriv _ _) hg_ae\n  refine' hlt.not_le (sub_le_iff_le_add'.1 _)\n  calc\n    ‖f d‖ - ‖f c‖ ≤ ‖f d - f c‖ := norm_sub_norm_le _ _\n    _ = ‖∫ x in c..d, deriv f x‖ := (congr_arg _ (integral_deriv_eq_sub hfd hfi).symm)\n    _ = ‖∫ x in Ι c d, deriv f x‖ := (norm_integral_eq_norm_integral_Ioc _)\n    _ ≤ ∫ x in Ι c d, ‖deriv f x‖ := (norm_integral_le_integral_norm _)\n    _ ≤ ∫ x in Ι c d, C * ‖g x‖ :=\n      (set_integral_mono_on hfi.norm.def (hgi.def.mono_set hsub') measurableSet_uIoc hg)\n    _ ≤ ∫ x in Ι a b, C * ‖g x‖ :=\n      set_integral_mono_set hgi.def (ae_of_all _ fun x => mul_nonneg hC₀ (norm_nonneg _))\n        hsub'.eventually_le\n    \n#align not_interval_integrable_of_tendsto_norm_at_top_of_deriv_is_O_filter not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_filter\n\n/-- If `a ≠ b`, `c ∈ [a, b]`, `f` is differentiable in the neighborhood of `c` within\n`[a, b] \\ {c}`, `‖f x‖ → ∞` as `x → c` within `[a, b] \\ {c}`, and `f' = O(g)` along\n`𝓝[[a, b] \\ {c}] c`, where `f'` is the derivative of `f`, then `g` is not interval integrable on\n`a..b`. -/\ntheorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_within_diff_singleton {f : ℝ → E}\n    {g : ℝ → F} {a b c : ℝ} (hne : a ≠ b) (hc : c ∈ [a, b])\n    (h_deriv : ∀ᶠ x in 𝓝[[a, b] \\ {c}] c, DifferentiableAt ℝ f x)\n    (h_infty : Tendsto (fun x => ‖f x‖) (𝓝[[a, b] \\ {c}] c) atTop)\n    (hg : deriv f =O[𝓝[[a, b] \\ {c}] c] g) : ¬IntervalIntegrable g volume a b :=\n  by\n  obtain ⟨l, hl, hl', hle, hmem⟩ :\n    ∃ l : Filter ℝ, tendsto_Ixx_class Icc l l ∧ l.ne_bot ∧ l ≤ 𝓝 c ∧ [a, b] \\ {c} ∈ l :=\n    by\n    cases' (min_lt_max.2 hne).lt_or_lt c with hlt hlt\n    · refine' ⟨𝓝[<] c, inferInstance, inferInstance, inf_le_left, _⟩\n      rw [← Iic_diff_right]\n      exact diff_mem_nhdsWithin_diff (Icc_mem_nhdsWithin_Iic ⟨hlt, hc.2⟩) _\n    · refine' ⟨𝓝[>] c, inferInstance, inferInstance, inf_le_left, _⟩\n      rw [← Ici_diff_left]\n      exact diff_mem_nhdsWithin_diff (Icc_mem_nhdsWithin_Ici ⟨hc.1, hlt⟩) _\n  skip\n  have : l ≤ 𝓝[[a, b] \\ {c}] c := le_inf hle (le_principal_iff.2 hmem)\n  exact\n    not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_filter l\n      (mem_of_superset hmem (diff_subset _ _)) (h_deriv.filter_mono this) (h_infty.mono_left this)\n      (hg.mono this)\n#align not_interval_integrable_of_tendsto_norm_at_top_of_deriv_is_O_within_diff_singleton not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_within_diff_singleton\n\n/-- If `f` is differentiable in a punctured neighborhood of `c`, `‖f x‖ → ∞` as `x → c` (more\nformally, along the filter `𝓝[≠] c`), and `f' = O(g)` along `𝓝[≠] c`, where `f'` is the derivative\nof `f`, then `g` is not interval integrable on any nontrivial interval `a..b` such that\n`c ∈ [a, b]`. -/\ntheorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_punctured {f : ℝ → E} {g : ℝ → F}\n    {a b c : ℝ} (h_deriv : ∀ᶠ x in 𝓝[≠] c, DifferentiableAt ℝ f x)\n    (h_infty : Tendsto (fun x => ‖f x‖) (𝓝[≠] c) atTop) (hg : deriv f =O[𝓝[≠] c] g) (hne : a ≠ b)\n    (hc : c ∈ [a, b]) : ¬IntervalIntegrable g volume a b :=\n  have : 𝓝[[a, b] \\ {c}] c ≤ 𝓝[≠] c := nhdsWithin_mono _ (inter_subset_right _ _)\n  not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_within_diff_singleton hne hc\n    (h_deriv.filter_mono this) (h_infty.mono_left this) (hg.mono this)\n#align not_interval_integrable_of_tendsto_norm_at_top_of_deriv_is_O_punctured not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_punctured\n\n/-- If `f` grows in the punctured neighborhood of `c : ℝ` at least as fast as `1 / (x - c)`,\nthen it is not interval integrable on any nontrivial interval `a..b`, `c ∈ [a, b]`. -/\ntheorem not_intervalIntegrable_of_sub_inv_isO_punctured {f : ℝ → F} {a b c : ℝ}\n    (hf : (fun x => (x - c)⁻¹) =O[𝓝[≠] c] f) (hne : a ≠ b) (hc : c ∈ [a, b]) :\n    ¬IntervalIntegrable f volume a b :=\n  by\n  have A : ∀ᶠ x in 𝓝[≠] c, HasDerivAt (fun x => Real.log (x - c)) (x - c)⁻¹ x :=\n    by\n    filter_upwards [self_mem_nhdsWithin]with x hx\n    simpa using ((hasDerivAt_id x).sub_const c).log (sub_ne_zero.2 hx)\n  have B : tendsto (fun x => ‖Real.log (x - c)‖) (𝓝[≠] c) at_top :=\n    by\n    refine' tendsto_abs_at_bot_at_top.comp (real.tendsto_log_nhds_within_zero.comp _)\n    rw [← sub_self c]\n    exact ((hasDerivAt_id c).sub_const c).tendsto_punctured_nhds one_ne_zero\n  exact\n    not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_punctured\n      (A.mono fun x hx => hx.DifferentiableAt) B\n      (hf.congr' (A.mono fun x hx => hx.deriv.symm) eventually_eq.rfl) hne hc\n#align not_interval_integrable_of_sub_inv_is_O_punctured not_intervalIntegrable_of_sub_inv_isO_punctured\n\n/-- The function `λ x, (x - c)⁻¹` is integrable on `a..b` if and only if `a = b` or `c ∉ [a, b]`. -/\n@[simp]\ntheorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :\n    IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [a, b] :=\n  by\n  constructor\n  · refine' fun h => or_iff_not_imp_left.2 fun hne hc => _\n    exact not_intervalIntegrable_of_sub_inv_isO_punctured (is_O_refl _ _) hne hc h\n  · rintro (rfl | h₀)\n    exacts[IntervalIntegrable.refl,\n      interval_integrable_inv (fun x hx => sub_ne_zero.2 <| ne_of_mem_of_not_mem hx h₀)\n        (continuous_on_id.sub continuousOn_const)]\n#align interval_integrable_sub_inv_iff intervalIntegrable_sub_inv_iff\n\n/-- The function `λ x, x⁻¹` is integrable on `a..b` if and only if `a = b` or `0 ∉ [a, b]`. -/\n@[simp]\ntheorem intervalIntegrable_inv_iff {a b : ℝ} :\n    IntervalIntegrable (fun x => x⁻¹) volume a b ↔ a = b ∨ (0 : ℝ) ∉ [a, b] := by\n  simp only [← intervalIntegrable_sub_inv_iff, sub_zero]\n#align interval_integrable_inv_iff intervalIntegrable_inv_iff\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Analysis/SpecialFunctions/NonIntegrable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.48903257806509354}}
{"text": "import analysis.convex.specific_functions\nimport analysis.special_functions.trigonometric.complex\nimport algebra.is_prime_pow\n\nlemma int.Ico_succ_right {a b : ℤ} : finset.Ico a (b+1) = finset.Icc a b :=\nby { ext x, simp only [finset.mem_Icc, finset.mem_Ico, int.lt_add_one_iff] }\n\nlemma int.Ioc_succ_right {a b : ℤ} (h : a ≤ b) :\n  finset.Ioc a (b+1) = insert (b+1) (finset.Ioc a b) :=\nbegin\n  ext x,\n  simp only [finset.mem_Ioc, finset.mem_insert],\n  rw [le_iff_lt_or_eq, int.lt_add_one_iff, or_comm, and_or_distrib_left, or_congr_left'],\n  rw and_iff_right_of_imp,\n  rintro rfl,\n  exact int.lt_add_one_iff.2 h\nend\n\nlemma int.insert_Ioc_succ_left {a b : ℤ} (h : a < b) :\n  insert (a+1) (finset.Ioc (a+1) b) = finset.Ioc a b :=\nbegin\n  ext x,\n  simp only [finset.mem_Ioc, finset.mem_insert],\n  rw [or_and_distrib_left, eq_comm, ←le_iff_eq_or_lt, int.add_one_le_iff, and_congr_right'],\n  rw or_iff_right_of_imp,\n  rintro rfl,\n  rwa int.add_one_le_iff,\nend\n\nlemma int.Ioc_succ_left {a b : ℤ} (h : a < b) :\n  finset.Ioc (a+1) b = (finset.Ioc a b).erase (a+1) :=\nbegin\n  rw [←@int.insert_Ioc_succ_left a b h, finset.erase_insert],\n  simp only [finset.left_not_mem_Ioc, not_false_iff],\nend\n\nlemma int.Ioc_succ_succ {a b : ℤ} (h : a ≤ b) :\n  finset.Ioc (a+1) (b+1) = (insert (b+1) (finset.Ioc a b)).erase (a+1) :=\nbegin\n  rw [int.Ioc_succ_left, int.Ioc_succ_right h],\n  rwa int.lt_add_one_iff,\nend\n\nlemma finset.Icc_subset_range_add_one {x y : ℕ} : finset.Icc x y ⊆ finset.range (y+1) :=\nbegin\n  rw [finset.range_eq_Ico, nat.Ico_succ_right],\n  exact finset.Icc_subset_Icc_left (nat.zero_le _),\nend\n\nlemma finset.Ico_union_Icc_eq_Icc {x y z : ℕ} (h₁ : x ≤ y) (h₂ : y ≤ z) :\n  finset.Ico x y ∪ finset.Icc y z = finset.Icc x z :=\nby rw [←finset.coe_inj, finset.coe_union, finset.coe_Ico, finset.coe_Icc, finset.coe_Icc,\n    set.Ico_union_Icc_eq_Icc h₁ h₂]\n\n@[simp] lemma Ico_inter_Icc_consecutive {α : Type*} [linear_order α]\n  [locally_finite_order α] (a b c : α) : finset.Ico a b ∩ finset.Icc b c = ∅ :=\nbegin\n  refine finset.eq_empty_of_forall_not_mem (λ x hx, _),\n  rw [finset.mem_inter, finset.mem_Ico, finset.mem_Icc] at hx,\n  exact hx.1.2.not_le hx.2.1,\nend\n\nlemma Ico_disjoint_Icc_consecutive {α : Type*} [linear_order α]\n  [locally_finite_order α] (a b c : α) : disjoint (finset.Ico a b) (finset.Icc b c) :=\n(Ico_inter_Icc_consecutive a b c).le\n\nlemma finset.Icc_sdiff_Icc_right {x y z : ℕ} (h₁ : x ≤ y) (h₂ : y ≤ z) :\n  finset.Icc x z \\ finset.Icc y z = finset.Ico x y :=\nbegin\n  rw ←finset.Ico_union_Icc_eq_Icc h₁ h₂,\n  rw finset.union_sdiff_self,\n  rw finset.sdiff_eq_self_of_disjoint,\n  apply Ico_disjoint_Icc_consecutive,\nend\n\nlemma finset.Icc_sdiff_Icc_left {x y z : ℕ} (h₁ : z ≤ y) (h₂ : x ≤ z) :\n  finset.Icc x y \\ finset.Icc x z = finset.Ioc z y :=\nbegin\n  ext m,\n  simp only [finset.mem_Icc, finset.mem_sdiff, finset.mem_Ioc, not_and, not_le],\n  exact ⟨λ h, ⟨h.2 h.1.1, h.1.2⟩, λ h, ⟨⟨h₂.trans h.1.le, h.2⟩, λ _, h.1⟩⟩,\nend\n\nlemma range_sdiff_Icc {x y : ℕ} (h : x ≤ y) :\n  finset.range (y+1) \\ finset.Icc x y = finset.Ico 0 x :=\nbegin\n  rw [finset.range_eq_Ico, nat.Ico_succ_right, finset.Icc_sdiff_Icc_right (nat.zero_le _) h],\nend\n\nlemma Ici_diff_Icc {a b : ℝ} (hab : a ≤ b) : set.Ici a \\ set.Icc a b = set.Ioi b :=\nbegin\n  rw [←set.Icc_union_Ioi_eq_Ici hab, set.union_diff_left, set.diff_eq_self],\n  rintro x ⟨⟨_, hx⟩, hx'⟩,\n  exact not_le_of_lt hx' hx,\nend\n\nlemma Ioi_diff_Icc {a b : ℝ} (hab : a ≤ b) : set.Ioi a \\ set.Ioc a b = set.Ioi b :=\nbegin\n  rw [←set.Ioc_union_Ioi_eq_Ioi hab, set.union_diff_left, set.diff_eq_self, set.subset_def],\n  simp,\nend\n\nopen_locale big_operators\n\n@[simp, norm_cast] lemma rat.cast_sum {α β : Type*} [division_ring β] [char_zero β] (s : finset α)\n  (f : α → ℚ) :\n  ↑(∑ x in s, f x : ℚ) = (∑ x in s, (f x : β)) :=\n(rat.cast_hom β).map_sum f s\n\nlemma finset.prod_rpow {ι : Type*} {s : finset ι} {f : ι → ℝ}\n  (c : ℝ) (hf : ∀ x ∈ s, 0 ≤ f x) :\n  (∏ i in s, f i) ^ c = ∏ i in s, f i ^ c :=\nbegin\n  induction s using finset.cons_induction_on with a s has ih generalizing hf,\n  { simp },\n  simp only [finset.mem_cons, forall_eq_or_imp] at hf,\n  rw [finset.prod_cons has, real.mul_rpow hf.1 (finset.prod_nonneg hf.2),\n    finset.prod_cons has, ih hf.2],\nend\n\nlemma one_le_prod {ι R : Type*} [ordered_comm_semiring R] {f : ι → R} {s : finset ι}\n  (h1 : ∀ i ∈ s, 1 ≤ f i) : 1 ≤ ∏ i in s, f i :=\n(finset.prod_le_prod (λ _ _, zero_le_one) h1).trans' (by simp)\n\nlemma finset.filter_comm {α : Type*} (p q : α → Prop) [decidable_eq α]\n  [decidable_pred p] [decidable_pred q] (s : finset α) :\n  (s.filter p).filter q = (s.filter q).filter p :=\nby simp only [finset.filter_filter, and_comm]\n\nlemma real.le_rpow_self_of_one_le {x r : ℝ} (hx : 1 ≤ x) (hr : 1 ≤ r) :\n  x ≤ x ^ r :=\nby simpa using real.rpow_le_rpow_of_exponent_le hx hr\n\nlemma real.le_rpow_self_of {x : ℝ} {r : ℝ} (hx₀ : 0 ≤ x) (hx₁ : x ≤ 1) (h_one_le : r ≤ 1) :\n  x ≤ x ^ r :=\nbegin\n  rcases eq_or_ne r 0 with rfl | hr,\n  { simp [hx₁] },\n  rcases eq_or_lt_of_le hx₀ with rfl | hx₀,\n  { rw real.zero_rpow hr },\n  simpa using real.rpow_le_rpow_of_exponent_ge hx₀ hx₁ h_one_le\nend\n\n@[to_additive]\nlemma prod_powerset_compl {α β : Type*} [decidable_eq α] [comm_monoid β]\n  (s : finset α) (f : finset α → β) :\n  ∏ x in s.powerset, f (s \\ x) = ∏ x in s.powerset, f x :=\nbegin\n  refine finset.prod_bij' (λ x _, s \\ x) (by simp) (λ _ _, rfl) (λ x _, s \\ x) (by simp) _ _;\n  simp [finset.inter_eq_right_iff_subset],\nend\n", "meta": {"author": "b-mehta", "repo": "unit-fractions", "sha": "b60c39a3ebd40a84104a4064840b10fc2af15fb8", "save_path": "github-repos/lean/b-mehta-unit-fractions", "path": "github-repos/lean/b-mehta-unit-fractions/unit-fractions-b60c39a3ebd40a84104a4064840b10fc2af15fb8/src/for_mathlib/misc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802471698041, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.48899064668894193}}
{"text": "-- Tarski's axioms formalized\nimport tactic\n\nnoncomputable theory\nopen_locale classical\n\nconstant Point : Type  -- There is a type called point\n\n-- There is an infinite hierarchy of types\n-- Type 0 == Type\n-- Type 1\n-- Type 2\n-- .....\n\n-- This is the Betweenness relation.\n-- This is saying \"y\" is in between \"x\" and \"z\".\nconstant B (x y z : Point) : Prop\n\n-- Axioms for betweenness that Tarski asked us to include\n@[refl] axiom B_includes_end1 (x z : Point) : B x x z\n@[refl] axiom B_includes_end2 (x z : Point) : B x z z\n\n-- Congruence relation between 4 points.\n-- A Segment just contains two pieces of data, i.e. the two end point.\nstructure Segment : Type := (p1 p2 : Point)\n-- Lean automatically makes a definition for Segment.mk\nconstant C (s1 s2 : Segment) : Prop  -- s1 has the same length as s2\n\n/-\n-- Let us make some segments\nvariables x y : Point\n#check Segment.mk x y\n#check ({p1 := x,  p2 := y} : Segment)-/\n\n-- We are defining our own operator here\nlocal infix ` ≃ `:55 := C  -- \\ equiv == equivalence/congruence\nlocal infix `⬝`:56 := Segment.mk  -- \\ cdot == center-dot\n\n--- Next, we look at congruence axioms.\n\n--- xy is congruent to yx\n@[symm] axiom C_swap (x y : Point) : x⬝y ≃ y⬝x\n@[tidy] axiom C_iden (x y z : Point) :  x⬝y ≃ z⬝z → x = y\n@[trans] axiom C_trans (u v w x y z : Point) : (u⬝v ≃ z⬝w) → (u⬝v ≃ x⬝y) → z⬝w ≃ x⬝y\n-- used to be (u⬝v ≃ z⬝w) ∧ (u⬝v ≃ x⬝y) → z⬝w ≃ x⬝y\n\n--- Equivalence relations: (~ means is related to)\n-- 1. Reflexive x ~ x\n-- 2. Symmetric x ~ y → y ~ x\n-- 3. Transitive x ~ y ∧ y ~ z → x ~ z\n--- Example : Equality =\n--- Non-example : Less-than-or-equal relation \"≤\"\n\n--  Tarski is claiming that the congruence relation is an equivalence relation\n-- Marking this lemma with a \"refl\" attribute.\n-- This means, we are training the Lean AI called \"refl\" to learn this lemma\n-- and apply it wherever appropriate.\n\n\n\n@[refl] lemma C_refl (s : Segment) : s ≃ s :=\nbegin\n  cases s with x y,  -- s is made of 2 points. Let's call these x and y.\n  fapply C_trans,    -- fapply means apply the C_trans axiom.\n  use y,\n  use x,\n  repeat {symmetry},     -- simmplify. Same as apply C_swap.\nend\n\n@[symm] lemma C_symm (s1 s2 : Segment) : s1 ≃ s2 → s2 ≃ s1 :=\nbegin\n  intro H,\n  cases s1 with x1 y1,\n  cases s2 with x2 y2,\n  fapply C_trans, \n    use x1,\n    use y1,\n    assumption, -- \"use statements from the hypothesis\". Same as apply H,\n    refl,      -- \"refl\" means this is true by definition. Same as apply C_refl.\nend\n\n\n@[trans] lemma C_trans2 (s1 s2 s3 : Segment): s1 ≃ s2 → s2 ≃ s3 → s1 ≃ s3 :=\nbegin\n  intros H1 H2,\n  cases s1 with x1 y1,\n  cases s2 with x2 y2,\n  cases s3 with x3 y3,\n  fapply C_trans,\n    use x2,\n    use y2,\n    -- {...} helps us separate the proof of the two goals.\n    { symmetry,  -- uses lemmas tagged with @[symm]. Same as apply C_symm.\n      assumption}, -- Same as apply H1,\n    { assumption},\nend\n\nlemma C_equiv : equivalence C :=\nbegin\n  unfold equivalence,  -- replace with the definition of equivalence in the Goal\n  split,\n    { exact C_refl},\n    split,\n      { exact C_symm},\n      { exact C_trans2},\nend\n\n\n@[symm] lemma C_swap_right (x y w z : Point) : x⬝y ≃ z⬝w → x⬝y ≃ w⬝z :=\nbegin\n  intro H,\n  transitivity,\n    apply H,  -- this means use z⬝w for the unknown variable.\n    exact C_swap z w,\nend\n\n@[symm] lemma C_swap_left (x y w z : Point) : x⬝y ≃ z⬝w → y⬝x ≃ z⬝w :=\nbegin\n  intro H,\n  fapply C_trans,\n    use x,\n    use y,\n    { symmetry, refl},\n    { exact H},\nend\n\n@[symm] lemma C_swap_both (x y w z : Point) : x⬝y ≃ z⬝w → y⬝x ≃ w⬝z :=\nbegin\n  intro H,\n  apply C_swap_right,\n  apply C_swap_left,\n  apply H,\nend\n\n\n-- Betweeness Axioms:\n-- The only point on the line segment xx is itself\naxiom B_id (x y : Point) : B x y x → x = y\n\n-- Pasch's axiom\n-- If uvxy is a quadrilateral then its diagonals must meet at a point \"a\".\naxiom pasch (u v x y z : Point) :\n  (B x u z) → (B y v z) → ∃ (a : Point), B u a y ∧ B v a x \n\n-- Defining the axiom schema\n-- Phi and Psi are just some \"properties\"\naxiom dedekind_cut (φ ψ : Point → Prop) :\n    ∃ (a : Point), ∀ (x y : Point), φ x ∧ ψ y → B a x y\n  → ∃ (b : Point), ∀ (x y : Point), φ x ∧ ψ y → B x b y\n--  a--------x-------y  (this is the hypothesis)\n--  Then we can find a point b such that\n--  a--------x---b---y\n\n-- This means our geometry has more than 1 dimension\naxiom plane_geom1 : ∃ (a b c : Point),\n  (¬ B a b c) ∧ (¬ B b a a) ∧ (¬ B c a b)\n\n-- This means our geometry has less than 3 dimensions\naxiom plane_geom2 (u v x y z : Point) :\n  (x⬝u ≃ x⬝v) → (y⬝u ≃ z⬝v) → (z⬝u ≃ z⬝v) → (u ≠ v)\n  → (B x y z) ∨ (B y z x) ∨ (B z x y)\n\n\n-- # Axioms of Euclid\n---------------------\naxiom euclid_a (u v w x y z : Point) :\n     B x y w → x⬝y ≃ y⬝w\n  → B x u v → x⬝u ≃ u⬝v\n  → B y u z → y⬝u ≃ z⬝u\n  → y⬝z ≃ v⬝w\n\n\n\nlemma euclid_b (x y z : Point) :\n  (B x y z) ∨ (B y z x) ∨ (B z x y) ∨ (∃ a : Point, (x⬝a ≃ y⬝a) ∧ (x⬝a ≃ z⬝a)) :=\nbegin\n  have euclid_a := euclid_a,\n  right,\n  right,\n  right,\n  tidy,\n   { exact x},\n   { apply euclid_a, tidy, repeat {sorry}},\n   { apply euclid_a, tidy, repeat {sorry}},\nend\n\n\n-- We need to prove Euclid variant C starting with varint B\nlemma euclid_c (u v x y z : Point) :\n  B x u v → B y u z →  x ≠ u\n  → ∃ (a b : Point), (B x y a ∧ B x z b ∧ B a v b) :=\nbegin\n  have euclid_b, from euclid_b,\n  sorry\nend\n\n\n\n-- Axiom of five segments\naxiom five_segments (x y z u x' y' z' u' : Point) :\n  (x ≠ y) → (B x y z) → (B x' y' z')\n  → (x⬝y ≃ x'⬝y') → (y⬝z ≃ y'⬝z') → (x⬝u ≃ x'⬝u') → (y⬝u ≃ y'⬝u')\n  → (z⬝u ≃ z'⬝u')\n\n\n-- Axiom of segment construction\naxiom segment_construct (x y a b : Point) :\n  ∃ z : Point, (B x y z) ∧ (y⬝z ≃ a⬝b)\n\n\n-- More results:\n@[refl] lemma B_refl (x y : Point) : B x x y :=\n  by fapply B_includes_end1\n\n\n@[symm] lemma B_symm (x y z : Point) : B x y z → B z y x := \nbegin\n   intro H,\n   hint,\n    sorry,\nend\n\n\n\n@[trans] lemma B_trans (w x y z : Point) : B x y w → B y z w → B x y z :=\nbegin\n   intros hp hq,\n   sorry,\nend\n\nlemma B_connect (w x y z : Point) : B x y w → B x z w → B x y z ∨ B x z y :=\nsorry\n\n-- TODO: Need to figure out how Bxyz can translate to a total order?\n-- lemma total_order_segment : is_total B :=  sorry\n\nlemma zero_segments_are_congruent (y v : Point) : y⬝y ≃ v⬝v :=\nbegin\n  have h := segment_construct v y v y,\n  choose x h using h,\n  cases h with h₁ h₂,\n  have h₃ : v⬝y ≃ y⬝x,\n    {exact C_symm (y⬝x) (v⬝y) h₂},\n  fapply euclid_a,\n  use y,\n  use x,\n    repeat {solve_by_elim},\n    repeat {refl},\nend\n\n-- TFAE is short for \"the following are equivalent\"\n-- The usual strategy to prove such results is to prove a cycle:\n-- Either show 1 → 2 → 3 → 1, or show 1 → 3 → 2 → 1.\ntheorem extend_identity (x y z : Point): tfae [(x⬝y ≃ z⬝z), (x=y), (B x y x)] :=\nbegin\n  tfae_have: 1 → 2,\n    apply C_iden,\n  tfae_have: 2 → 3,\n    intro H,\n    rw H,\n    fapply B_includes_end1,\n  tfae_have: 3 → 2,\n    apply B_id,\n  tfae_have: 2 → 1,\n    intro H,\n    rw H,\n    fapply zero_segments_are_congruent,\n  tfae_finish,\nend\n", "meta": {"author": "vaibhavkarve", "repo": "leanteach2020", "sha": "c77ca235e3ecdf31aa551c1dfe6c1d40036bbc56", "save_path": "github-repos/lean/vaibhavkarve-leanteach2020", "path": "github-repos/lean/vaibhavkarve-leanteach2020/leanteach2020-c77ca235e3ecdf31aa551c1dfe6c1d40036bbc56/src/tarski.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.4889906466889419}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov\n\n! This file was ported from Lean 3 source module topology.order.basic\n! leanprover-community/mathlib commit c985ae9840e06836a71db38de372f20acb49b790\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Intervals.Pi\nimport Mathbin.Data.Set.Pointwise.Interval\nimport Mathbin.Order.Filter.Interval\nimport Mathbin.Topology.Support\nimport Mathbin.Topology.Algebra.Order.LeftRight\n\n/-!\n# Theory of topology on ordered spaces\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n## Main definitions\n\nThe order topology on an ordered space is the topology generated by all open intervals (or\nequivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `preorder.topology α`.\nHowever, we do *not* register it as an instance (as many existing ordered types already have\ntopologies, which would be equal but not definitionally equal to `preorder.topology α`). Instead,\nwe introduce a class `order_topology α` (which is a `Prop`, also known as a mixin) saying that on\nthe type `α` having already a topological space structure and a preorder structure, the topological\nstructure is equal to the order topology.\n\nWe also introduce another (mixin) class `order_closed_topology α` saying that the set of points\n`(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear\norder with the order topology.\n\nWe prove many basic properties of such topologies.\n\n## Main statements\n\nThis file contains the proofs of the following facts. For exact requirements\n(`order_closed_topology` vs `order_topology`, `preorder` vs `partial_order` vs `linear_order` etc)\nsee their statements.\n\n### Open / closed sets\n\n* `is_open_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open;\n* `is_open_Iio`, `is_open_Ioi`, `is_open_Ioo` : open intervals are open;\n* `is_closed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed;\n* `is_closed_Iic`, `is_closed_Ici`, `is_closed_Icc` : closed intervals are closed;\n* `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}`\n  and `{x | f x < g x}` are included by `{x | f x = g x}`;\n* `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any\n  neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood\n  of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`.\n\n### Convergence and inequalities\n\n* `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually\n  `f x ≤ g x`, then `a ≤ b`\n* `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b`\n  (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a); we also provide primed versions\n  that assume the inequalities to hold for all `x`.\n\n### Min, max, `Sup` and `Inf`\n\n* `continuous.min`, `continuous.max`: pointwise `min`/`max` of two continuous functions is\n  continuous.\n* `tendsto.min`, `tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise\n  `min`/`max` tend to `min a b` and `max a b`, respectively.\n* `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem,\n  sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h`\n  both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`.\n\n## Implementation notes\n\nWe do _not_ register the order topology as an instance on a preorder (or even on a linear order).\nIndeed, on many such spaces, a topology has already been constructed in a different way (think\nof the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`),\nand is in general not defeq to the one generated by the intervals. We make it available as a\ndefinition `preorder.topology α` though, that can be registered as an instance when necessary, or\nfor specific types.\n-/\n\n\nopen Set Filter TopologicalSpace\n\nopen Function\n\nopen OrderDual (toDual ofDual)\n\nopen Topology Classical Filter\n\nuniverse u v w\n\nvariable {α : Type u} {β : Type v} {γ : Type w}\n\n#print OrderClosedTopology /-\n/-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the\nset of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin.\nThis property is satisfied for the order topology on a linear order, but it can be satisfied more\ngenerally, and suffices to derive many interesting properties relating order and topology. -/\nclass OrderClosedTopology (α : Type _) [TopologicalSpace α] [Preorder α] : Prop where\n  isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 }\n#align order_closed_topology OrderClosedTopology\n-/\n\ninstance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ :=\n  h\n\ninstance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ :=\n  h\n\n#print Dense.orderDual /-\ntheorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) :\n    Dense (OrderDual.ofDual ⁻¹' s) :=\n  hs\n#align dense.order_dual Dense.orderDual\n-/\n\nsection OrderClosedTopology\n\nsection Preorder\n\nvariable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α]\n\ninclude t\n\nnamespace Subtype\n\ninstance {p : α → Prop} : OrderClosedTopology (Subtype p) :=\n  have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) :=\n    (continuous_subtype_val.comp continuous_fst).prod_mk\n      (continuous_subtype_val.comp continuous_snd)\n  OrderClosedTopology.mk (t.isClosed_le'.Preimage this)\n\nend Subtype\n\n/- warning: is_closed_le_prod -> isClosed_le_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderClosedTopology.{u1} α _inst_1 _inst_2], IsClosed.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderClosedTopology.{u1} α _inst_1 _inst_2], IsClosed.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)))\nCase conversion may be inaccurate. Consider using '#align is_closed_le_prod isClosed_le_prodₓ'. -/\ntheorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } :=\n  t.isClosed_le'\n#align is_closed_le_prod isClosed_le_prod\n\n#print isClosed_le /-\ntheorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) :\n    IsClosed { b | f b ≤ g b } :=\n  continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod\n#align is_closed_le isClosed_le\n-/\n\n#print isClosed_le' /-\ntheorem isClosed_le' (a : α) : IsClosed { b | b ≤ a } :=\n  isClosed_le continuous_id continuous_const\n#align is_closed_le' isClosed_le'\n-/\n\n#print isClosed_Iic /-\ntheorem isClosed_Iic {a : α} : IsClosed (Iic a) :=\n  isClosed_le' a\n#align is_closed_Iic isClosed_Iic\n-/\n\n#print isClosed_ge' /-\ntheorem isClosed_ge' (a : α) : IsClosed { b | a ≤ b } :=\n  isClosed_le continuous_const continuous_id\n#align is_closed_ge' isClosed_ge'\n-/\n\n#print isClosed_Ici /-\ntheorem isClosed_Ici {a : α} : IsClosed (Ici a) :=\n  isClosed_ge' a\n#align is_closed_Ici isClosed_Ici\n-/\n\ninstance : OrderClosedTopology αᵒᵈ :=\n  ⟨(@OrderClosedTopology.isClosed_le' α _ _ _).Preimage continuous_swap⟩\n\n#print isClosed_Icc /-\ntheorem isClosed_Icc {a b : α} : IsClosed (Icc a b) :=\n  IsClosed.inter isClosed_Ici isClosed_Iic\n#align is_closed_Icc isClosed_Icc\n-/\n\n#print closure_Icc /-\n@[simp]\ntheorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b :=\n  isClosed_Icc.closure_eq\n#align closure_Icc closure_Icc\n-/\n\n#print closure_Iic /-\n@[simp]\ntheorem closure_Iic (a : α) : closure (Iic a) = Iic a :=\n  isClosed_Iic.closure_eq\n#align closure_Iic closure_Iic\n-/\n\n#print closure_Ici /-\n@[simp]\ntheorem closure_Ici (a : α) : closure (Ici a) = Ici a :=\n  isClosed_Ici.closure_eq\n#align closure_Ici closure_Ici\n-/\n\n#print le_of_tendsto_of_tendsto /-\ntheorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b]\n    (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ :=\n  have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := by\n    rw [nhds_prod_eq] <;> exact hf.prod_mk hg\n  show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h\n#align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto\n-/\n\nalias le_of_tendsto_of_tendsto ← tendsto_le_of_eventuallyLE\n#align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE\n\n#print le_of_tendsto_of_tendsto' /-\ntheorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b]\n    (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ :=\n  le_of_tendsto_of_tendsto hf hg (eventually_of_forall h)\n#align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto'\n-/\n\n#print le_of_tendsto /-\ntheorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))\n    (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b :=\n  le_of_tendsto_of_tendsto limUnder tendsto_const_nhds h\n#align le_of_tendsto le_of_tendsto\n-/\n\n#print le_of_tendsto' /-\ntheorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))\n    (h : ∀ c, f c ≤ b) : a ≤ b :=\n  le_of_tendsto limUnder (eventually_of_forall h)\n#align le_of_tendsto' le_of_tendsto'\n-/\n\n#print ge_of_tendsto /-\ntheorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))\n    (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a :=\n  le_of_tendsto_of_tendsto tendsto_const_nhds limUnder h\n#align ge_of_tendsto ge_of_tendsto\n-/\n\n#print ge_of_tendsto' /-\ntheorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a))\n    (h : ∀ c, b ≤ f c) : b ≤ a :=\n  ge_of_tendsto limUnder (eventually_of_forall h)\n#align ge_of_tendsto' ge_of_tendsto'\n-/\n\n#print closure_le_eq /-\n@[simp]\ntheorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) :\n    closure { b | f b ≤ g b } = { b | f b ≤ g b } :=\n  (isClosed_le hf hg).closure_eq\n#align closure_le_eq closure_le_eq\n-/\n\n#print closure_lt_subset_le /-\ntheorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f)\n    (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } :=\n  (closure_minimal fun x => le_of_lt) <| isClosed_le hf hg\n#align closure_lt_subset_le closure_lt_subset_le\n-/\n\n#print ContinuousWithinAt.closure_le /-\ntheorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β}\n    (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x)\n    (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x :=\n  show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from\n    OrderClosedTopology.isClosed_le'.closure_subset ((hf.Prod hg).mem_closure hx h)\n#align continuous_within_at.closure_le ContinuousWithinAt.closure_le\n-/\n\n#print IsClosed.isClosed_le /-\n/-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`,\nthen the set `{x ∈ s | f x ≤ g x}` is a closed set. -/\ntheorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s)\n    (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) :=\n  (hf.Prod hg).preimage_closed_of_closed hs OrderClosedTopology.isClosed_le'\n#align is_closed.is_closed_le IsClosed.isClosed_le\n-/\n\n#print le_on_closure /-\ntheorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x)\n    (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) :\n    f x ≤ g x :=\n  have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩\n  (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2\n#align le_on_closure le_on_closure\n-/\n\n/- warning: is_closed.epigraph -> IsClosed.epigraph is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderClosedTopology.{u1} α _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} β] {f : β -> α} {s : Set.{u2} β}, (IsClosed.{u2} β _inst_3 s) -> (ContinuousOn.{u2, u1} β α _inst_3 _inst_1 f s) -> (IsClosed.{max u2 u1} (Prod.{u2, u1} β α) (Prod.topologicalSpace.{u2, u1} β α _inst_3 _inst_1) (setOf.{max u2 u1} (Prod.{u2, u1} β α) (fun (p : Prod.{u2, u1} β α) => And (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) (Prod.fst.{u2, u1} β α p) s) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (f (Prod.fst.{u2, u1} β α p)) (Prod.snd.{u2, u1} β α p)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderClosedTopology.{u1} α _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} β] {f : β -> α} {s : Set.{u2} β}, (IsClosed.{u2} β _inst_3 s) -> (ContinuousOn.{u2, u1} β α _inst_3 _inst_1 f s) -> (IsClosed.{max u1 u2} (Prod.{u2, u1} β α) (instTopologicalSpaceProd.{u2, u1} β α _inst_3 _inst_1) (setOf.{max u1 u2} (Prod.{u2, u1} β α) (fun (p : Prod.{u2, u1} β α) => And (Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) (Prod.fst.{u2, u1} β α p) s) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (f (Prod.fst.{u2, u1} β α p)) (Prod.snd.{u2, u1} β α p)))))\nCase conversion may be inaccurate. Consider using '#align is_closed.epigraph IsClosed.epigraphₓ'. -/\ntheorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s)\n    (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } :=\n  (hs.Preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd\n#align is_closed.epigraph IsClosed.epigraph\n\n/- warning: is_closed.hypograph -> IsClosed.hypograph is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderClosedTopology.{u1} α _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} β] {f : β -> α} {s : Set.{u2} β}, (IsClosed.{u2} β _inst_3 s) -> (ContinuousOn.{u2, u1} β α _inst_3 _inst_1 f s) -> (IsClosed.{max u2 u1} (Prod.{u2, u1} β α) (Prod.topologicalSpace.{u2, u1} β α _inst_3 _inst_1) (setOf.{max u2 u1} (Prod.{u2, u1} β α) (fun (p : Prod.{u2, u1} β α) => And (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) (Prod.fst.{u2, u1} β α p) s) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (Prod.snd.{u2, u1} β α p) (f (Prod.fst.{u2, u1} β α p))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderClosedTopology.{u1} α _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} β] {f : β -> α} {s : Set.{u2} β}, (IsClosed.{u2} β _inst_3 s) -> (ContinuousOn.{u2, u1} β α _inst_3 _inst_1 f s) -> (IsClosed.{max u1 u2} (Prod.{u2, u1} β α) (instTopologicalSpaceProd.{u2, u1} β α _inst_3 _inst_1) (setOf.{max u1 u2} (Prod.{u2, u1} β α) (fun (p : Prod.{u2, u1} β α) => And (Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) (Prod.fst.{u2, u1} β α p) s) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (Prod.snd.{u2, u1} β α p) (f (Prod.fst.{u2, u1} β α p))))))\nCase conversion may be inaccurate. Consider using '#align is_closed.hypograph IsClosed.hypographₓ'. -/\ntheorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s)\n    (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } :=\n  (hs.Preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl)\n#align is_closed.hypograph IsClosed.hypograph\n\nomit t\n\n#print nhdsWithin_Ici_neBot /-\ntheorem nhdsWithin_Ici_neBot {a b : α} (H₂ : a ≤ b) : NeBot (𝓝[Ici a] b) :=\n  nhdsWithin_neBot_of_mem H₂\n#align nhds_within_Ici_ne_bot nhdsWithin_Ici_neBot\n-/\n\n#print nhdsWithin_Ici_self_neBot /-\n@[instance]\ntheorem nhdsWithin_Ici_self_neBot (a : α) : NeBot (𝓝[≥] a) :=\n  nhdsWithin_Ici_neBot (le_refl a)\n#align nhds_within_Ici_self_ne_bot nhdsWithin_Ici_self_neBot\n-/\n\n#print nhdsWithin_Iic_neBot /-\ntheorem nhdsWithin_Iic_neBot {a b : α} (H : a ≤ b) : NeBot (𝓝[Iic b] a) :=\n  nhdsWithin_neBot_of_mem H\n#align nhds_within_Iic_ne_bot nhdsWithin_Iic_neBot\n-/\n\n#print nhdsWithin_Iic_self_neBot /-\n@[instance]\ntheorem nhdsWithin_Iic_self_neBot (a : α) : NeBot (𝓝[≤] a) :=\n  nhdsWithin_Iic_neBot (le_refl a)\n#align nhds_within_Iic_self_ne_bot nhdsWithin_Iic_self_neBot\n-/\n\nend Preorder\n\nsection PartialOrder\n\nvariable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α]\n\ninclude t\n\n#print OrderClosedTopology.to_t2Space /-\n-- see Note [lower instance priority]\ninstance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α :=\n  t2_iff_isClosed_diagonal.2 <| by\n    simpa only [diagonal, le_antisymm_iff] using\n      t.is_closed_le'.inter (isClosed_le continuous_snd continuous_fst)\n#align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space\n-/\n\nend PartialOrder\n\nsection LinearOrder\n\nvariable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α]\n\n/- warning: is_open_lt_prod -> isOpen_lt_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))], IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))], IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)))\nCase conversion may be inaccurate. Consider using '#align is_open_lt_prod isOpen_lt_prodₓ'. -/\ntheorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } :=\n  by\n  simp_rw [← isClosed_compl_iff, compl_set_of, not_lt]\n  exact isClosed_le continuous_snd continuous_fst\n#align is_open_lt_prod isOpen_lt_prod\n\n#print isOpen_lt /-\ntheorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) :\n    IsOpen { b | f b < g b } := by\n  simp [lt_iff_not_ge, -not_le] <;> exact (isClosed_le hg hf).isOpen_compl\n#align is_open_lt isOpen_lt\n-/\n\nvariable {a b : α}\n\n#print isOpen_Iio /-\ntheorem isOpen_Iio : IsOpen (Iio a) :=\n  isOpen_lt continuous_id continuous_const\n#align is_open_Iio isOpen_Iio\n-/\n\n#print isOpen_Ioi /-\ntheorem isOpen_Ioi : IsOpen (Ioi a) :=\n  isOpen_lt continuous_const continuous_id\n#align is_open_Ioi isOpen_Ioi\n-/\n\n#print isOpen_Ioo /-\ntheorem isOpen_Ioo : IsOpen (Ioo a b) :=\n  IsOpen.inter isOpen_Ioi isOpen_Iio\n#align is_open_Ioo isOpen_Ioo\n-/\n\n#print interior_Ioi /-\n@[simp]\ntheorem interior_Ioi : interior (Ioi a) = Ioi a :=\n  isOpen_Ioi.interior_eq\n#align interior_Ioi interior_Ioi\n-/\n\n#print interior_Iio /-\n@[simp]\ntheorem interior_Iio : interior (Iio a) = Iio a :=\n  isOpen_Iio.interior_eq\n#align interior_Iio interior_Iio\n-/\n\n#print interior_Ioo /-\n@[simp]\ntheorem interior_Ioo : interior (Ioo a b) = Ioo a b :=\n  isOpen_Ioo.interior_eq\n#align interior_Ioo interior_Ioo\n-/\n\n#print Ioo_subset_closure_interior /-\ntheorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by\n  simp only [interior_Ioo, subset_closure]\n#align Ioo_subset_closure_interior Ioo_subset_closure_interior\n-/\n\n#print Iio_mem_nhds /-\ntheorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a :=\n  IsOpen.mem_nhds isOpen_Iio h\n#align Iio_mem_nhds Iio_mem_nhds\n-/\n\n#print Ioi_mem_nhds /-\ntheorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b :=\n  IsOpen.mem_nhds isOpen_Ioi h\n#align Ioi_mem_nhds Ioi_mem_nhds\n-/\n\n#print Iic_mem_nhds /-\ntheorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a :=\n  mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self\n#align Iic_mem_nhds Iic_mem_nhds\n-/\n\n#print Ici_mem_nhds /-\ntheorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b :=\n  mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self\n#align Ici_mem_nhds Ici_mem_nhds\n-/\n\n#print Ioo_mem_nhds /-\ntheorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x :=\n  IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩\n#align Ioo_mem_nhds Ioo_mem_nhds\n-/\n\n#print Ioc_mem_nhds /-\ntheorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x :=\n  mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self\n#align Ioc_mem_nhds Ioc_mem_nhds\n-/\n\n#print Ico_mem_nhds /-\ntheorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x :=\n  mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self\n#align Ico_mem_nhds Ico_mem_nhds\n-/\n\n#print Icc_mem_nhds /-\ntheorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x :=\n  mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self\n#align Icc_mem_nhds Icc_mem_nhds\n-/\n\n#print eventually_lt_of_tendsto_lt /-\ntheorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u)\n    (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u :=\n  tendsto_nhds.1 h (· < u) isOpen_Iio hv\n#align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt\n-/\n\n#print eventually_gt_of_tendsto_gt /-\ntheorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v)\n    (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a :=\n  tendsto_nhds.1 h (· > u) isOpen_Ioi hv\n#align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt\n-/\n\n#print eventually_le_of_tendsto_lt /-\ntheorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u)\n    (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u :=\n  (eventually_lt_of_tendsto_lt hv h).mono fun v => le_of_lt\n#align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt\n-/\n\n#print eventually_ge_of_tendsto_gt /-\ntheorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v)\n    (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a :=\n  (eventually_gt_of_tendsto_gt hv h).mono fun v => le_of_lt\n#align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt\n-/\n\nvariable [TopologicalSpace γ]\n\n/-!\n### Neighborhoods to the left and to the right on an `order_closed_topology`\n\nLimits to the left and to the right of real functions are defined in terms of neighborhoods to\nthe left and to the right, either open or closed, i.e., members of `𝓝[>] a` and\n`𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all\nright-neighborhoods of a point are equal, and we'll prove later other useful characterizations which\nrequire the stronger hypothesis `order_topology α` -/\n\n\n/-!\n#### Right neighborhoods, point excluded\n-/\n\n\n#print Ioo_mem_nhdsWithin_Ioi /-\ntheorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b :=\n  mem_nhdsWithin.2\n    ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio] <;> exact Ioo_subset_Ioo_left H.1⟩\n#align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi\n-/\n\n#print Ioc_mem_nhdsWithin_Ioi /-\ntheorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self\n#align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi\n-/\n\n#print Ico_mem_nhdsWithin_Ioi /-\ntheorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self\n#align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi\n-/\n\n#print Icc_mem_nhdsWithin_Ioi /-\ntheorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self\n#align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi\n-/\n\n#print nhdsWithin_Ioc_eq_nhdsWithin_Ioi /-\n@[simp]\ntheorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a :=\n  le_antisymm (nhdsWithin_mono _ Ioc_subset_Ioi_self) <|\n    nhdsWithin_le_of_mem <| Ioc_mem_nhdsWithin_Ioi <| left_mem_Ico.2 h\n#align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi\n-/\n\n#print nhdsWithin_Ioo_eq_nhdsWithin_Ioi /-\n@[simp]\ntheorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a :=\n  le_antisymm (nhdsWithin_mono _ Ioo_subset_Ioi_self) <|\n    nhdsWithin_le_of_mem <| Ioo_mem_nhdsWithin_Ioi <| left_mem_Ico.2 h\n#align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi\n-/\n\n#print continuousWithinAt_Ioc_iff_Ioi /-\n@[simp]\ntheorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) :\n    ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by\n  simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h]\n#align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi\n-/\n\n#print continuousWithinAt_Ioo_iff_Ioi /-\n@[simp]\ntheorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) :\n    ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by\n  simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h]\n#align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi\n-/\n\n/-!\n#### Left neighborhoods, point excluded\n-/\n\n\n#print Ioo_mem_nhdsWithin_Iio /-\ntheorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by\n  simpa only [dual_Ioo] using\n    Ioo_mem_nhdsWithin_Ioi (show to_dual b ∈ Ico (to_dual c) (to_dual a) from H.symm)\n#align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio\n-/\n\n#print Ico_mem_nhdsWithin_Iio /-\ntheorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self\n#align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio\n-/\n\n#print Ioc_mem_nhdsWithin_Iio /-\ntheorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self\n#align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio\n-/\n\n#print Icc_mem_nhdsWithin_Iio /-\ntheorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self\n#align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio\n-/\n\n#print nhdsWithin_Ico_eq_nhdsWithin_Iio /-\n@[simp]\ntheorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by\n  simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual\n#align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio\n-/\n\n#print nhdsWithin_Ioo_eq_nhdsWithin_Iio /-\n@[simp]\ntheorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by\n  simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual\n#align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio\n-/\n\n#print continuousWithinAt_Ico_iff_Iio /-\n@[simp]\ntheorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) :\n    ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by\n  simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h]\n#align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio\n-/\n\n#print continuousWithinAt_Ioo_iff_Iio /-\n@[simp]\ntheorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) :\n    ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by\n  simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h]\n#align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio\n-/\n\n/-!\n#### Right neighborhoods, point included\n-/\n\n\n#print Ioo_mem_nhdsWithin_Ici /-\ntheorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b :=\n  mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H\n#align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici\n-/\n\n#print Ioc_mem_nhdsWithin_Ici /-\ntheorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self\n#align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici\n-/\n\n#print Ico_mem_nhdsWithin_Ici /-\ntheorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b :=\n  mem_nhdsWithin.2\n    ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩\n#align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici\n-/\n\n#print Icc_mem_nhdsWithin_Ici /-\ntheorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b :=\n  mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self\n#align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici\n-/\n\n#print nhdsWithin_Icc_eq_nhdsWithin_Ici /-\n@[simp]\ntheorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a :=\n  le_antisymm (nhdsWithin_mono _ Icc_subset_Ici_self) <|\n    nhdsWithin_le_of_mem <| Icc_mem_nhdsWithin_Ici <| left_mem_Ico.2 h\n#align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici\n-/\n\n#print nhdsWithin_Ico_eq_nhdsWithin_Ici /-\n@[simp]\ntheorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a :=\n  le_antisymm (nhdsWithin_mono _ fun x => And.left) <|\n    nhdsWithin_le_of_mem <| Ico_mem_nhdsWithin_Ici <| left_mem_Ico.2 h\n#align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici\n-/\n\n#print continuousWithinAt_Icc_iff_Ici /-\n@[simp]\ntheorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) :\n    ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by\n  simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h]\n#align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici\n-/\n\n#print continuousWithinAt_Ico_iff_Ici /-\n@[simp]\ntheorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) :\n    ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by\n  simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h]\n#align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici\n-/\n\n/-!\n#### Left neighborhoods, point included\n-/\n\n\n#print Ioo_mem_nhdsWithin_Iic /-\ntheorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b :=\n  mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H\n#align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic\n-/\n\n#print Ico_mem_nhdsWithin_Iic /-\ntheorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b :=\n  mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self\n#align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic\n-/\n\n#print Ioc_mem_nhdsWithin_Iic /-\ntheorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by\n  simpa only [dual_Ico] using\n    Ico_mem_nhdsWithin_Ici (show to_dual b ∈ Ico (to_dual c) (to_dual a) from H.symm)\n#align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic\n-/\n\n#print Icc_mem_nhdsWithin_Iic /-\ntheorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b :=\n  mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self\n#align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic\n-/\n\n#print nhdsWithin_Icc_eq_nhdsWithin_Iic /-\n@[simp]\ntheorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by\n  simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual\n#align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic\n-/\n\n#print nhdsWithin_Ioc_eq_nhdsWithin_Iic /-\n@[simp]\ntheorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by\n  simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual\n#align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic\n-/\n\n#print continuousWithinAt_Icc_iff_Iic /-\n@[simp]\ntheorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) :\n    ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by\n  simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h]\n#align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic\n-/\n\n#print continuousWithinAt_Ioc_iff_Iic /-\n@[simp]\ntheorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) :\n    ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by\n  simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h]\n#align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic\n-/\n\nend LinearOrder\n\nsection LinearOrder\n\nvariable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α}\n\nsection\n\nvariable [TopologicalSpace β]\n\n#print lt_subset_interior_le /-\ntheorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) :\n    { b | f b < g b } ⊆ interior { b | f b ≤ g b } :=\n  (interior_maximal fun p => le_of_lt) <| isOpen_lt hf hg\n#align lt_subset_interior_le lt_subset_interior_le\n-/\n\n#print frontier_le_subset_eq /-\ntheorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) :\n    frontier { b | f b ≤ g b } ⊆ { b | f b = g b } :=\n  by\n  rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg]\n  rintro b ⟨hb₁, hb₂⟩\n  refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _)\n  convert hb₂ using 2; simp only [not_le.symm]; rfl\n#align frontier_le_subset_eq frontier_le_subset_eq\n-/\n\n#print frontier_Iic_subset /-\ntheorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} :=\n  frontier_le_subset_eq (@continuous_id α _) continuous_const\n#align frontier_Iic_subset frontier_Iic_subset\n-/\n\n#print frontier_Ici_subset /-\ntheorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} :=\n  @frontier_Iic_subset αᵒᵈ _ _ _ _\n#align frontier_Ici_subset frontier_Ici_subset\n-/\n\n#print frontier_lt_subset_eq /-\ntheorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) :\n    frontier { b | f b < g b } ⊆ { b | f b = g b } := by\n  rw [← frontier_compl] <;> convert frontier_le_subset_eq hg hf <;> simp [ext_iff, eq_comm]\n#align frontier_lt_subset_eq frontier_lt_subset_eq\n-/\n\n#print continuous_if_le /-\ntheorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ}\n    (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x })\n    (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) :\n    Continuous fun x => if f x ≤ g x then f' x else g' x :=\n  by\n  refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _)\n  · rwa [(isClosed_le hf hg).closure_eq]\n  · simp only [not_le]\n    exact closure_lt_subset_le hg hf\n#align continuous_if_le continuous_if_le\n-/\n\n#print Continuous.if_le /-\ntheorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ}\n    (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g)\n    (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x :=\n  continuous_if_le hf hg hf'.ContinuousOn hg'.ContinuousOn hfg\n#align continuous.if_le Continuous.if_le\n-/\n\n#print Filter.Tendsto.eventually_lt /-\ntheorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y))\n    (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x :=\n  by\n  by_cases h : y ⋖ z\n  · filter_upwards [hf (Iio_mem_nhds hyz), hg (Ioi_mem_nhds hyz)]\n    rw [h.Iio_eq]\n    exact fun x hfx hgx => lt_of_le_of_lt hfx hgx\n  · obtain ⟨w, hyw, hwz⟩ := (not_covby_iff hyz).mp h\n    filter_upwards [hf (Iio_mem_nhds hyw), hg (Ioi_mem_nhds hwz)]\n    exact fun x => lt_trans\n#align tendsto.eventually_lt Filter.Tendsto.eventually_lt\n-/\n\n#print ContinuousAt.eventually_lt /-\ntheorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀)\n    (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x :=\n  Filter.Tendsto.eventually_lt hf hg hfg\n#align continuous_at.eventually_lt ContinuousAt.eventually_lt\n-/\n\n/- warning: continuous.min -> Continuous.min is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {g : β -> α} [_inst_4 : TopologicalSpace.{u2} β], (Continuous.{u2, u1} β α _inst_4 _inst_1 f) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 g) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 (fun (b : β) => LinearOrder.min.{u1} α _inst_2 (f b) (g b)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {g : β -> α} [_inst_4 : TopologicalSpace.{u2} β], (Continuous.{u2, u1} β α _inst_4 _inst_1 f) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 g) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 (fun (b : β) => Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) (f b) (g b)))\nCase conversion may be inaccurate. Consider using '#align continuous.min Continuous.minₓ'. -/\n@[continuity]\ntheorem Continuous.min (hf : Continuous f) (hg : Continuous g) :\n    Continuous fun b => min (f b) (g b) :=\n  by\n  simp only [min_def]\n  exact hf.if_le hg hf hg fun x => id\n#align continuous.min Continuous.min\n\n/- warning: continuous.max -> Continuous.max is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {g : β -> α} [_inst_4 : TopologicalSpace.{u2} β], (Continuous.{u2, u1} β α _inst_4 _inst_1 f) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 g) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 (fun (b : β) => LinearOrder.max.{u1} α _inst_2 (f b) (g b)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {g : β -> α} [_inst_4 : TopologicalSpace.{u2} β], (Continuous.{u2, u1} β α _inst_4 _inst_1 f) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 g) -> (Continuous.{u2, u1} β α _inst_4 _inst_1 (fun (b : β) => Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) (f b) (g b)))\nCase conversion may be inaccurate. Consider using '#align continuous.max Continuous.maxₓ'. -/\n@[continuity]\ntheorem Continuous.max (hf : Continuous f) (hg : Continuous g) :\n    Continuous fun b => max (f b) (g b) :=\n  @Continuous.min αᵒᵈ _ _ _ _ _ _ _ hf hg\n#align continuous.max Continuous.max\n\nend\n\n/- warning: continuous_min -> continuous_min is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))], Continuous.{u1, u1} (Prod.{u1, u1} α α) α (Prod.topologicalSpace.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => LinearOrder.min.{u1} α _inst_2 (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))], Continuous.{u1, u1} (Prod.{u1, u1} α α) α (instTopologicalSpaceProd.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nCase conversion may be inaccurate. Consider using '#align continuous_min continuous_minₓ'. -/\ntheorem continuous_min : Continuous fun p : α × α => min p.1 p.2 :=\n  continuous_fst.min continuous_snd\n#align continuous_min continuous_min\n\n/- warning: continuous_max -> continuous_max is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))], Continuous.{u1, u1} (Prod.{u1, u1} α α) α (Prod.topologicalSpace.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => LinearOrder.max.{u1} α _inst_2 (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))], Continuous.{u1, u1} (Prod.{u1, u1} α α) α (instTopologicalSpaceProd.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nCase conversion may be inaccurate. Consider using '#align continuous_max continuous_maxₓ'. -/\ntheorem continuous_max : Continuous fun p : α × α => max p.1 p.2 :=\n  continuous_fst.max continuous_snd\n#align continuous_max continuous_max\n\n/- warning: filter.tendsto.max -> Filter.Tendsto.max is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {g : β -> α} {b : Filter.{u2} β} {a₁ : α} {a₂ : α}, (Filter.Tendsto.{u2, u1} β α f b (nhds.{u1} α _inst_1 a₁)) -> (Filter.Tendsto.{u2, u1} β α g b (nhds.{u1} α _inst_1 a₂)) -> (Filter.Tendsto.{u2, u1} β α (fun (b : β) => LinearOrder.max.{u1} α _inst_2 (f b) (g b)) b (nhds.{u1} α _inst_1 (LinearOrder.max.{u1} α _inst_2 a₁ a₂)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {g : β -> α} {b : Filter.{u2} β} {a₁ : α} {a₂ : α}, (Filter.Tendsto.{u2, u1} β α f b (nhds.{u1} α _inst_1 a₁)) -> (Filter.Tendsto.{u2, u1} β α g b (nhds.{u1} α _inst_1 a₂)) -> (Filter.Tendsto.{u2, u1} β α (fun (b : β) => Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) (f b) (g b)) b (nhds.{u1} α _inst_1 (Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) a₁ a₂)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.max Filter.Tendsto.maxₓ'. -/\ntheorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁))\n    (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) :=\n  (continuous_max.Tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg)\n#align filter.tendsto.max Filter.Tendsto.max\n\n/- warning: filter.tendsto.min -> Filter.Tendsto.min is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {g : β -> α} {b : Filter.{u2} β} {a₁ : α} {a₂ : α}, (Filter.Tendsto.{u2, u1} β α f b (nhds.{u1} α _inst_1 a₁)) -> (Filter.Tendsto.{u2, u1} β α g b (nhds.{u1} α _inst_1 a₂)) -> (Filter.Tendsto.{u2, u1} β α (fun (b : β) => LinearOrder.min.{u1} α _inst_2 (f b) (g b)) b (nhds.{u1} α _inst_1 (LinearOrder.min.{u1} α _inst_2 a₁ a₂)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {g : β -> α} {b : Filter.{u2} β} {a₁ : α} {a₂ : α}, (Filter.Tendsto.{u2, u1} β α f b (nhds.{u1} α _inst_1 a₁)) -> (Filter.Tendsto.{u2, u1} β α g b (nhds.{u1} α _inst_1 a₂)) -> (Filter.Tendsto.{u2, u1} β α (fun (b : β) => Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) (f b) (g b)) b (nhds.{u1} α _inst_1 (Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) a₁ a₂)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.min Filter.Tendsto.minₓ'. -/\ntheorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁))\n    (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) :=\n  (continuous_min.Tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg)\n#align filter.tendsto.min Filter.Tendsto.min\n\n/- warning: filter.tendsto.max_right -> Filter.Tendsto.max_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.max.{u1} α _inst_2 a (f i)) l (nhds.{u1} α _inst_1 a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) a (f i)) l (nhds.{u1} α _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.max_right Filter.Tendsto.max_rightₓ'. -/\ntheorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :\n    Tendsto (fun i => max a (f i)) l (𝓝 a) :=\n  by\n  convert((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).Tendsto a).comp h\n  simp\n#align filter.tendsto.max_right Filter.Tendsto.max_right\n\n/- warning: filter.tendsto.max_left -> Filter.Tendsto.max_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.max.{u1} α _inst_2 (f i) a) l (nhds.{u1} α _inst_1 a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) (f i) a) l (nhds.{u1} α _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.max_left Filter.Tendsto.max_leftₓ'. -/\ntheorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :\n    Tendsto (fun i => max (f i) a) l (𝓝 a) :=\n  by\n  simp_rw [max_comm _ a]\n  exact h.max_right\n#align filter.tendsto.max_left Filter.Tendsto.max_left\n\n/- warning: filter.tendsto_nhds_max_right -> Filter.tendsto_nhds_max_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.max.{u1} α _inst_2 a (f i)) l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) a (f i)) l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_rightₓ'. -/\ntheorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) :\n    Tendsto (fun i => max a (f i)) l (𝓝[>] a) :=\n  by\n  obtain ⟨h₁ : tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhds_within_iff.mp h\n  exact tendsto_nhds_within_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩\n#align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right\n\n/- warning: filter.tendsto_nhds_max_left -> Filter.tendsto_nhds_max_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.max.{u1} α _inst_2 (f i) a) l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_2) (f i) a) l (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_leftₓ'. -/\ntheorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) :\n    Tendsto (fun i => max (f i) a) l (𝓝[>] a) :=\n  by\n  simp_rw [max_comm _ a]\n  exact Filter.tendsto_nhds_max_right h\n#align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left\n\n/- warning: filter.tendsto.min_right -> Filter.Tendsto.min_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.min.{u1} α _inst_2 a (f i)) l (nhds.{u1} α _inst_1 a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) a (f i)) l (nhds.{u1} α _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.min_right Filter.Tendsto.min_rightₓ'. -/\ntheorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :\n    Tendsto (fun i => min a (f i)) l (𝓝 a) :=\n  @Filter.Tendsto.max_right αᵒᵈ β _ _ _ f l a h\n#align filter.tendsto.min_right Filter.Tendsto.min_right\n\n/- warning: filter.tendsto.min_left -> Filter.Tendsto.min_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.min.{u1} α _inst_2 (f i) a) l (nhds.{u1} α _inst_1 a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 a)) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) (f i) a) l (nhds.{u1} α _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.min_left Filter.Tendsto.min_leftₓ'. -/\ntheorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) :\n    Tendsto (fun i => min (f i) a) l (𝓝 a) :=\n  @Filter.Tendsto.max_left αᵒᵈ β _ _ _ f l a h\n#align filter.tendsto.min_left Filter.Tendsto.min_left\n\n/- warning: filter.tendsto_nhds_min_right -> Filter.tendsto_nhds_min_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.min.{u1} α _inst_2 a (f i)) l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) a (f i)) l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_rightₓ'. -/\ntheorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) :\n    Tendsto (fun i => min a (f i)) l (𝓝[<] a) :=\n  @Filter.tendsto_nhds_max_right αᵒᵈ β _ _ _ f l a h\n#align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right\n\n/- warning: filter.tendsto_nhds_min_left -> Filter.tendsto_nhds_min_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => LinearOrder.min.{u1} α _inst_2 (f i) a) l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {f : β -> α} {l : Filter.{u2} β} {a : α}, (Filter.Tendsto.{u2, u1} β α f l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} β α (fun (i : β) => Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_2) (f i) a) l (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_leftₓ'. -/\ntheorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) :\n    Tendsto (fun i => min (f i) a) l (𝓝[<] a) :=\n  @Filter.tendsto_nhds_max_left αᵒᵈ β _ _ _ f l a h\n#align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left\n\n/- warning: dense.exists_lt -> Dense.exists_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) y x)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) y x)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_lt Dense.exists_ltₓ'. -/\ntheorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x :=\n  hs.exists_mem_open isOpen_Iio (exists_lt x)\n#align dense.exists_lt Dense.exists_lt\n\n/- warning: dense.exists_gt -> Dense.exists_gt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x y)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x y)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_gt Dense.exists_gtₓ'. -/\ntheorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y :=\n  hs.OrderDual.exists_lt x\n#align dense.exists_gt Dense.exists_gt\n\n/- warning: dense.exists_le -> Dense.exists_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) y x)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) y x)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_le Dense.exists_leₓ'. -/\ntheorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x :=\n  (hs.exists_lt x).imp fun y hy => ⟨hy.fst, hy.snd.le⟩\n#align dense.exists_le Dense.exists_le\n\n/- warning: dense.exists_ge -> Dense.exists_ge is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x y)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x y)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_ge Dense.exists_geₓ'. -/\ntheorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y :=\n  hs.OrderDual.exists_le x\n#align dense.exists_ge Dense.exists_ge\n\n/- warning: dense.exists_le' -> Dense.exists_le' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), (IsBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) y x)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), (IsBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) y x)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_le' Dense.exists_le'ₓ'. -/\ntheorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) :\n    ∃ y ∈ s, y ≤ x := by\n  by_cases hx : IsBot x\n  · exact ⟨x, hbot x hx, le_rfl⟩\n  · simp only [IsBot, not_forall, not_le] at hx\n    rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩\n    exact ⟨y, hys, hy.le⟩\n#align dense.exists_le' Dense.exists_le'\n\n/- warning: dense.exists_ge' -> Dense.exists_ge' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), (IsTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y s) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x y)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall (x : α), (IsTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) -> (forall (x : α), Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y s) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x y)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_ge' Dense.exists_ge'ₓ'. -/\ntheorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) :\n    ∃ y ∈ s, x ≤ y :=\n  hs.OrderDual.exists_le' htop x\n#align dense.exists_ge' Dense.exists_ge'\n\n/- warning: dense.exists_between -> Dense.exists_between is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall {x : α} {y : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x y) -> (Exists.{succ u1} α (fun (z : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z s) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) x y)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderClosedTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {s : Set.{u1} α}, (Dense.{u1} α _inst_1 s) -> (forall {x : α} {y : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x y) -> (Exists.{succ u1} α (fun (z : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z s) (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) z (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) x y)))))\nCase conversion may be inaccurate. Consider using '#align dense.exists_between Dense.exists_betweenₓ'. -/\ntheorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) :\n    ∃ z ∈ s, z ∈ Ioo x y :=\n  hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h)\n#align dense.exists_between Dense.exists_between\n\nvariable [Nonempty α] [TopologicalSpace β]\n\n#print IsCompact.bddBelow /-\n/-- A compact set is bounded below -/\ntheorem IsCompact.bddBelow {s : Set α} (hs : IsCompact s) : BddBelow s :=\n  by\n  by_contra H\n  rcases hs.elim_finite_subcover_image (fun x (_ : x ∈ s) => @isOpen_Ioi _ _ _ _ x) _ with\n    ⟨t, st, ft, ht⟩\n  · refine' H (ft.bdd_below.imp fun C hC y hy => _)\n    rcases mem_Union₂.1 (ht hy) with ⟨x, hx, xy⟩\n    exact le_trans (hC hx) (le_of_lt xy)\n  · refine' fun x hx => mem_Union₂.2 (not_imp_comm.1 _ H)\n    exact fun h => ⟨x, fun y hy => le_of_not_lt (h.imp fun ys => ⟨_, hy, ys⟩)⟩\n#align is_compact.bdd_below IsCompact.bddBelow\n-/\n\n#print IsCompact.bddAbove /-\n/-- A compact set is bounded above -/\ntheorem IsCompact.bddAbove {s : Set α} (hs : IsCompact s) : BddAbove s :=\n  @IsCompact.bddBelow αᵒᵈ _ _ _ _ _ hs\n#align is_compact.bdd_above IsCompact.bddAbove\n-/\n\n#print IsCompact.bddBelow_image /-\n/-- A continuous function is bounded below on a compact set. -/\ntheorem IsCompact.bddBelow_image {f : β → α} {K : Set β} (hK : IsCompact K)\n    (hf : ContinuousOn f K) : BddBelow (f '' K) :=\n  (hK.image_of_continuousOn hf).BddBelow\n#align is_compact.bdd_below_image IsCompact.bddBelow_image\n-/\n\n#print IsCompact.bddAbove_image /-\n/-- A continuous function is bounded above on a compact set. -/\ntheorem IsCompact.bddAbove_image {f : β → α} {K : Set β} (hK : IsCompact K)\n    (hf : ContinuousOn f K) : BddAbove (f '' K) :=\n  @IsCompact.bddBelow_image αᵒᵈ _ _ _ _ _ _ _ _ hK hf\n#align is_compact.bdd_above_image IsCompact.bddAbove_image\n-/\n\n#print Continuous.bddBelow_range_of_hasCompactMulSupport /-\n/-- A continuous function with compact support is bounded below. -/\n@[to_additive \" A continuous function with compact support is bounded below. \"]\ntheorem Continuous.bddBelow_range_of_hasCompactMulSupport [One α] {f : β → α} (hf : Continuous f)\n    (h : HasCompactMulSupport f) : BddBelow (range f) :=\n  (h.isCompact_range hf).BddBelow\n#align continuous.bdd_below_range_of_has_compact_mul_support Continuous.bddBelow_range_of_hasCompactMulSupport\n#align continuous.bdd_below_range_of_has_compact_support Continuous.bddBelow_range_of_hasCompactSupport\n-/\n\n#print Continuous.bddAbove_range_of_hasCompactMulSupport /-\n/-- A continuous function with compact support is bounded above. -/\n@[to_additive \" A continuous function with compact support is bounded above. \"]\ntheorem Continuous.bddAbove_range_of_hasCompactMulSupport [One α] {f : β → α} (hf : Continuous f)\n    (h : HasCompactMulSupport f) : BddAbove (range f) :=\n  @Continuous.bddBelow_range_of_hasCompactMulSupport αᵒᵈ _ _ _ _ _ _ _ _ hf h\n#align continuous.bdd_above_range_of_has_compact_mul_support Continuous.bddAbove_range_of_hasCompactMulSupport\n#align continuous.bdd_above_range_of_has_compact_support Continuous.bddAbove_range_of_hasCompactSupport\n-/\n\nend LinearOrder\n\nend OrderClosedTopology\n\ninstance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β]\n    [OrderClosedTopology β] : OrderClosedTopology (α × β) :=\n  ⟨(isClosed_le (continuous_fst.comp continuous_fst) (continuous_fst.comp continuous_snd)).inter\n      (isClosed_le (continuous_snd.comp continuous_fst) (continuous_snd.comp continuous_snd))⟩\n\ninstance {ι : Type _} {α : ι → Type _} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)]\n    [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) :=\n  by\n  constructor\n  simp only [Pi.le_def, set_of_forall]\n  exact\n    isClosed_interᵢ fun i =>\n      isClosed_le ((continuous_apply i).comp continuous_fst)\n        ((continuous_apply i).comp continuous_snd)\n\n#print Pi.orderClosedTopology' /-\ninstance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] :\n    OrderClosedTopology (α → β) :=\n  Pi.orderClosedTopology\n#align pi.order_closed_topology' Pi.orderClosedTopology'\n-/\n\n#print OrderTopology /-\n/-- The order topology on an ordered type is the topology generated by open intervals. We register\nit on a preorder, but it is mostly interesting in linear orders, where it is also order-closed.\nWe define it as a mixin. If you want to introduce the order topology on a preorder, use\n`preorder.topology`. -/\nclass OrderTopology (α : Type _) [t : TopologicalSpace α] [Preorder α] : Prop where\n  topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a }\n#align order_topology OrderTopology\n-/\n\n#print Preorder.topology /-\n/-- (Order) topology on a partial order `α` generated by the subbase of open intervals\n`(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an\ninstance as many ordered sets are already endowed with the same topology, most often in a non-defeq\nway though. Register as a local instance when necessary. -/\ndef Preorder.topology (α : Type _) [Preorder α] : TopologicalSpace α :=\n  generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } }\n#align preorder.topology Preorder.topology\n-/\n\nsection OrderTopology\n\nsection Preorder\n\nvariable [TopologicalSpace α] [Preorder α] [t : OrderTopology α]\n\ninclude t\n\ninstance : OrderTopology αᵒᵈ :=\n  ⟨by\n    convert@OrderTopology.topology_eq_generate_intervals α _ _ _ <;>\n        conv in _ ∨ _ => rw [or_comm] <;>\n      rfl⟩\n\n#print isOpen_iff_generate_intervals /-\ntheorem isOpen_iff_generate_intervals {s : Set α} :\n    IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by\n  rw [t.topology_eq_generate_intervals] <;> rfl\n#align is_open_iff_generate_intervals isOpen_iff_generate_intervals\n-/\n\n#print isOpen_lt' /-\ntheorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := by\n  rw [@isOpen_iff_generate_intervals α _ _ t] <;> exact generate_open.basic _ ⟨a, Or.inl rfl⟩\n#align is_open_lt' isOpen_lt'\n-/\n\n#print isOpen_gt' /-\ntheorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := by\n  rw [@isOpen_iff_generate_intervals α _ _ t] <;> exact generate_open.basic _ ⟨a, Or.inr rfl⟩\n#align is_open_gt' isOpen_gt'\n-/\n\n#print lt_mem_nhds /-\ntheorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x :=\n  IsOpen.mem_nhds (isOpen_lt' _) h\n#align lt_mem_nhds lt_mem_nhds\n-/\n\n#print le_mem_nhds /-\ntheorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x :=\n  (𝓝 b).sets_of_superset (lt_mem_nhds h) fun b hb => le_of_lt hb\n#align le_mem_nhds le_mem_nhds\n-/\n\n#print gt_mem_nhds /-\ntheorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b :=\n  IsOpen.mem_nhds (isOpen_gt' _) h\n#align gt_mem_nhds gt_mem_nhds\n-/\n\n#print ge_mem_nhds /-\ntheorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b :=\n  (𝓝 a).sets_of_superset (gt_mem_nhds h) fun b hb => le_of_lt hb\n#align ge_mem_nhds ge_mem_nhds\n-/\n\n/- warning: nhds_eq_order -> nhds_eq_order is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderTopology.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 a) (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (b : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b (Set.Iio.{u1} α _inst_2 a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b (Set.Iio.{u1} α _inst_2 a)) => Filter.principal.{u1} α (Set.Ioi.{u1} α _inst_2 b)))) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (b : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b (Set.Ioi.{u1} α _inst_2 a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b (Set.Ioi.{u1} α _inst_2 a)) => Filter.principal.{u1} α (Set.Iio.{u1} α _inst_2 b)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderTopology.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 a) (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (b : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b (Set.Iio.{u1} α _inst_2 a)) (fun (H : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b (Set.Iio.{u1} α _inst_2 a)) => Filter.principal.{u1} α (Set.Ioi.{u1} α _inst_2 b)))) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (b : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b (Set.Ioi.{u1} α _inst_2 a)) (fun (H : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b (Set.Ioi.{u1} α _inst_2 a)) => Filter.principal.{u1} α (Set.Iio.{u1} α _inst_2 b)))))\nCase conversion may be inaccurate. Consider using '#align nhds_eq_order nhds_eq_orderₓ'. -/\ntheorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by\n  rw [t.topology_eq_generate_intervals, nhds_generate_from] <;>\n    exact\n      le_antisymm\n        (le_inf\n          (le_infᵢ₂ fun b hb => infᵢ_le_of_le { c : α | b < c } <| infᵢ_le _ ⟨hb, b, Or.inl rfl⟩)\n          (le_infᵢ₂ fun b hb => infᵢ_le_of_le { c : α | c < b } <| infᵢ_le _ ⟨hb, b, Or.inr rfl⟩))\n        (le_infᵢ fun s =>\n          le_infᵢ fun ⟨ha, b, hs⟩ =>\n            match s, ha, hs with\n            | _, h, Or.inl rfl => inf_le_of_left_le <| infᵢ_le_of_le b <| infᵢ_le _ h\n            | _, h, Or.inr rfl => inf_le_of_right_le <| infᵢ_le_of_le b <| infᵢ_le _ h)\n#align nhds_eq_order nhds_eq_order\n\n#print tendsto_order /-\ntheorem tendsto_order {f : β → α} {a : α} {x : Filter β} :\n    Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by\n  simp [nhds_eq_order a, tendsto_inf, tendsto_infi, tendsto_principal]\n#align tendsto_order tendsto_order\n-/\n\n#print tendstoIccClassNhds /-\ninstance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) :=\n  by\n  simp only [nhds_eq_order, infᵢ_subtype']\n  refine'\n    ((has_basis_infi_principal_finite _).inf (has_basis_infi_principal_finite _)).TendstoIxxClass\n      fun s hs => _\n  refine' ((ord_connected_bInter _).inter (ord_connected_bInter _)).out <;> intro _ _\n  exacts[ord_connected_Ioi, ord_connected_Iio]\n#align tendsto_Icc_class_nhds tendstoIccClassNhds\n-/\n\n#print tendstoIcoClassNhds /-\ninstance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) :=\n  tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self\n#align tendsto_Ico_class_nhds tendstoIcoClassNhds\n-/\n\n#print tendstoIocClassNhds /-\ninstance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) :=\n  tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self\n#align tendsto_Ioc_class_nhds tendstoIocClassNhds\n-/\n\n#print tendstoIooClassNhds /-\ninstance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) :=\n  tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self\n#align tendsto_Ioo_class_nhds tendstoIooClassNhds\n-/\n\n#print tendsto_of_tendsto_of_tendsto_of_le_of_le' /-\n/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities\nhold eventually for the filter. -/\ntheorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α}\n    (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b)\n    (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) :=\n  (hg.Icc hh).of_smallSets <| hgf.And hfh\n#align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le'\n-/\n\n#print tendsto_of_tendsto_of_tendsto_of_le_of_le /-\n/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities\nhold everywhere. -/\ntheorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α}\n    (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) :\n    Tendsto f b (𝓝 a) :=\n  tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf)\n    (eventually_of_forall hfh)\n#align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le\n-/\n\n/- warning: nhds_order_unbounded -> nhds_order_unbounded is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderTopology.{u1} α _inst_1 _inst_2] {a : α}, (Exists.{succ u1} α (fun (u : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u)) -> (Exists.{succ u1} α (fun (l : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 a) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) => infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (u : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) => Filter.principal.{u1} α (Set.Ioo.{u1} α _inst_2 l u)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [t : OrderTopology.{u1} α _inst_1 _inst_2] {a : α}, (Exists.{succ u1} α (fun (u : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u)) -> (Exists.{succ u1} α (fun (l : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 a) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) => infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (u : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) => Filter.principal.{u1} α (Set.Ioo.{u1} α _inst_2 l u)))))))\nCase conversion may be inaccurate. Consider using '#align nhds_order_unbounded nhds_order_unboundedₓ'. -/\ntheorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) :\n    𝓝 a = ⨅ (l) (h₂ : l < a) (u) (h₂ : a < u), 𝓟 (Ioo l u) :=\n  by\n  have : ∃ u, u ∈ Ioi a := hu\n  have : ∃ l, l ∈ Iio a := hl\n  simp only [nhds_eq_order, inf_binfᵢ, binfᵢ_inf, *, inf_principal, Ioi_inter_Iio]\n  rfl\n#align nhds_order_unbounded nhds_order_unbounded\n\n#print tendsto_order_unbounded /-\ntheorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u)\n    (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) :\n    Tendsto f x (𝓝 a) := by\n  rw [nhds_order_unbounded hu hl] <;>\n    exact\n      tendsto_infi.2 fun l =>\n        tendsto_infi.2 fun hl =>\n          tendsto_infi.2 fun u => tendsto_infi.2 fun hu => tendsto_principal.2 <| h l u hl hu\n#align tendsto_order_unbounded tendsto_order_unbounded\n-/\n\nend Preorder\n\n#print tendstoIxxNhdsWithin /-\ninstance tendstoIxxNhdsWithin {α : Type _} [Preorder α] [TopologicalSpace α] (a : α) {s t : Set α}\n    {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] :\n    TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) :=\n  Filter.tendstoIxxClass_inf\n#align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin\n-/\n\n#print tendstoIccClassNhdsPi /-\ninstance tendstoIccClassNhdsPi {ι : Type _} {α : ι → Type _} [∀ i, Preorder (α i)]\n    [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) :\n    TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by\n  constructor\n  conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi]\n  simp only [small_sets_infi, small_sets_comap, tendsto_infi, tendsto_lift', (· ∘ ·),\n    mem_powerset_iff]\n  intro i s hs\n  have : tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).Tendsto f\n  refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _\n  exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩\n#align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi\n-/\n\n/- warning: induced_order_topology' -> induced_orderTopology' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [ta : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderTopology.{u2} β ta _inst_2] (f : α -> β), (forall {x : α} {y : α}, Iff (LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) (f x) (f y)) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) x y)) -> (forall {a : α} {x : β}, (LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) x (f a)) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) b a) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) b a) => LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) x (f b))))) -> (forall {a : α} {x : β}, (LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) (f a) x) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (GT.gt.{u1} α (Preorder.toLT.{u1} α _inst_1) b a) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α _inst_1) b a) => LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) (f b) x)))) -> (OrderTopology.{u1} α (TopologicalSpace.induced.{u1, u2} α β f ta) _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [ta : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderTopology.{u2} β ta _inst_2] (f : α -> β), (forall {x : α} {y : α}, Iff (LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) (f x) (f y)) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) x y)) -> (forall {a : α} {x : β}, (LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) x (f a)) -> (Exists.{succ u1} α (fun (b : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) b a) (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) x (f b))))) -> (forall {a : α} {x : β}, (LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) (f a) x) -> (Exists.{succ u1} α (fun (b : α) => And (GT.gt.{u1} α (Preorder.toLT.{u1} α _inst_1) b a) (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) (f b) x)))) -> (OrderTopology.{u1} α (TopologicalSpace.induced.{u1, u2} α β f ta) _inst_1)\nCase conversion may be inaccurate. Consider using '#align induced_order_topology' induced_orderTopology'ₓ'. -/\ntheorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β]\n    [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y)\n    (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) :\n    @OrderTopology _ (induced f ta) _ :=\n  by\n  letI := induced f ta\n  refine' ⟨eq_of_nhds_eq_nhds fun a => _⟩\n  rw [nhds_induced, nhds_generate_from, nhds_eq_order (f a)]\n  apply le_antisymm\n  · refine' le_infᵢ fun s => le_infᵢ fun hs => le_principal_iff.2 _\n    rcases hs with ⟨ab, b, rfl | rfl⟩\n    ·\n      exact\n        mem_comap.2\n          ⟨{ x | f b < x },\n            mem_inf_of_left <|\n              mem_infi_of_mem _ <| mem_infi_of_mem (hf.2 ab) <| mem_principal_self _,\n            fun x => hf.1⟩\n    ·\n      exact\n        mem_comap.2\n          ⟨{ x | x < f b },\n            mem_inf_of_right <|\n              mem_infi_of_mem _ <| mem_infi_of_mem (hf.2 ab) <| mem_principal_self _,\n            fun x => hf.1⟩\n  · rw [← map_le_iff_le_comap]\n    refine' le_inf _ _ <;> refine' le_infᵢ fun x => le_infᵢ fun h => le_principal_iff.2 _ <;> simp\n    · rcases H₁ h with ⟨b, ab, xb⟩\n      refine' mem_infi_of_mem _ (mem_infi_of_mem ⟨ab, b, Or.inl rfl⟩ (mem_principal.2 _))\n      exact fun c hc => lt_of_le_of_lt xb (hf.2 hc)\n    · rcases H₂ h with ⟨b, ab, xb⟩\n      refine' mem_infi_of_mem _ (mem_infi_of_mem ⟨ab, b, Or.inr rfl⟩ (mem_principal.2 _))\n      exact fun c hc => lt_of_lt_of_le (hf.2 hc) xb\n#align induced_order_topology' induced_orderTopology'\n\n#print induced_orderTopology /-\ntheorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β]\n    [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y)\n    (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ :=\n  induced_orderTopology' f (@hf)\n    (fun a x xa =>\n      let ⟨b, xb, ba⟩ := H xa\n      ⟨b, hf.1 ba, le_of_lt xb⟩)\n    fun a x ax =>\n    let ⟨b, ab, bx⟩ := H ax\n    ⟨b, hf.1 ab, le_of_lt bx⟩\n#align induced_order_topology induced_orderTopology\n-/\n\n#print orderTopology_of_ordConnected /-\n/-- On an `ord_connected` subset of a linear order, the order topology for the restriction of the\norder is the same as the restriction to the subset of the order topology. -/\ninstance orderTopology_of_ordConnected {α : Type u} [ta : TopologicalSpace α] [LinearOrder α]\n    [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t :=\n  by\n  letI := induced (coe : t → α) ta\n  refine' ⟨eq_of_nhds_eq_nhds fun a => _⟩\n  rw [nhds_induced, nhds_generate_from, nhds_eq_order (a : α)]\n  apply le_antisymm\n  · refine' le_infᵢ fun s => le_infᵢ fun hs => le_principal_iff.2 _\n    rcases hs with ⟨ab, b, rfl | rfl⟩\n    · refine' ⟨Ioi b, _, fun _ => id⟩\n      refine' mem_inf_of_left (mem_infi_of_mem b _)\n      exact mem_infi_of_mem ab (mem_principal_self (Ioi ↑b))\n    · refine' ⟨Iio b, _, fun _ => id⟩\n      refine' mem_inf_of_right (mem_infi_of_mem b _)\n      exact mem_infi_of_mem ab (mem_principal_self (Iio b))\n  · rw [← map_le_iff_le_comap]\n    refine' le_inf _ _\n    · refine' le_infᵢ fun x => le_infᵢ fun h => le_principal_iff.2 _\n      by_cases hx : x ∈ t\n      · refine' mem_infi_of_mem (Ioi ⟨x, hx⟩) (mem_infi_of_mem ⟨h, ⟨⟨x, hx⟩, Or.inl rfl⟩⟩ _)\n        exact fun _ => id\n      simp only [SetCoe.exists, mem_set_of_eq, mem_map']\n      convert univ_sets _\n      suffices hx' : ∀ y : t, ↑y ∈ Ioi x\n      · simp [hx']\n      intro y\n      revert hx\n      contrapose!\n      -- here we use the `ord_connected` hypothesis\n      exact fun hx => ht.out y.2 a.2 ⟨le_of_not_gt hx, le_of_lt h⟩\n    · refine' le_infᵢ fun x => le_infᵢ fun h => le_principal_iff.2 _\n      by_cases hx : x ∈ t\n      · refine' mem_infi_of_mem (Iio ⟨x, hx⟩) (mem_infi_of_mem ⟨h, ⟨⟨x, hx⟩, Or.inr rfl⟩⟩ _)\n        exact fun _ => id\n      simp only [SetCoe.exists, mem_set_of_eq, mem_map']\n      convert univ_sets _\n      suffices hx' : ∀ y : t, ↑y ∈ Iio x\n      · simp [hx']\n      intro y\n      revert hx\n      contrapose!\n      -- here we use the `ord_connected` hypothesis\n      exact fun hx => ht.out a.2 y.2 ⟨le_of_lt h, le_of_not_gt hx⟩\n#align order_topology_of_ord_connected orderTopology_of_ordConnected\n-/\n\n/- warning: nhds_within_Ici_eq'' -> nhdsWithin_Ici_eq'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (u : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) (fun (hu : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) => Filter.principal.{u1} α (Set.Iio.{u1} α _inst_2 u)))) (Filter.principal.{u1} α (Set.Ici.{u1} α _inst_2 a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (u : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) (fun (hu : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) => Filter.principal.{u1} α (Set.Iio.{u1} α _inst_2 u)))) (Filter.principal.{u1} α (Set.Ici.{u1} α _inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Ici_eq'' nhdsWithin_Ici_eq''ₓ'. -/\ntheorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) :\n    𝓝[≥] a = (⨅ (u) (hu : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) :=\n  by\n  rw [nhdsWithin, nhds_eq_order]\n  refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right)\n  exact inf_le_right.trans (le_infᵢ₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl)\n#align nhds_within_Ici_eq'' nhdsWithin_Ici_eq''\n\n/- warning: nhds_within_Iic_eq'' -> nhdsWithin_Iic_eq'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) => Filter.principal.{u1} α (Set.Ioi.{u1} α _inst_2 l)))) (Filter.principal.{u1} α (Set.Iic.{u1} α _inst_2 a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) => Filter.principal.{u1} α (Set.Ioi.{u1} α _inst_2 l)))) (Filter.principal.{u1} α (Set.Iic.{u1} α _inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Iic_eq'' nhdsWithin_Iic_eq''ₓ'. -/\ntheorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) :\n    𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) :=\n  nhdsWithin_Ici_eq'' (toDual a)\n#align nhds_within_Iic_eq'' nhdsWithin_Iic_eq''\n\n/- warning: nhds_within_Ici_eq' -> nhdsWithin_Ici_eq' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] {a : α}, (Exists.{succ u1} α (fun (u : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u)) -> (Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α _inst_2 a)) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (u : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) (fun (hu : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) => Filter.principal.{u1} α (Set.Ico.{u1} α _inst_2 a u)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] {a : α}, (Exists.{succ u1} α (fun (u : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u)) -> (Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α _inst_2 a)) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (u : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) (fun (hu : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a u) => Filter.principal.{u1} α (Set.Ico.{u1} α _inst_2 a u)))))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Ici_eq' nhdsWithin_Ici_eq'ₓ'. -/\ntheorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}\n    (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (hu : a < u), 𝓟 (Ico a u) := by\n  simp only [nhdsWithin_Ici_eq'', binfᵢ_inf ha, inf_principal, Iio_inter_Ici]\n#align nhds_within_Ici_eq' nhdsWithin_Ici_eq'\n\n/- warning: nhds_within_Iic_eq' -> nhdsWithin_Iic_eq' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] {a : α}, (Exists.{succ u1} α (fun (l : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α _inst_2 a)) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) => Filter.principal.{u1} α (Set.Ioc.{u1} α _inst_2 l a)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 _inst_2] {a : α}, (Exists.{succ u1} α (fun (l : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} α) (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α _inst_2 a)) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l a) => Filter.principal.{u1} α (Set.Ioc.{u1} α _inst_2 l a)))))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Iic_eq' nhdsWithin_Iic_eq'ₓ'. -/\ntheorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}\n    (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by\n  simp only [nhdsWithin_Iic_eq'', binfᵢ_inf ha, inf_principal, Ioi_inter_Iic]\n#align nhds_within_Iic_eq' nhdsWithin_Iic_eq'\n\n#print nhdsWithin_Ici_basis' /-\ntheorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}\n    (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=\n  (nhdsWithin_Ici_eq' ha).symm ▸\n    hasBasis_binfᵢ_principal\n      (fun b hb c hc =>\n        ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _),\n          Ico_subset_Ico_right (min_le_right _ _)⟩)\n      ha\n#align nhds_within_Ici_basis' nhdsWithin_Ici_basis'\n-/\n\n#print nhdsWithin_Iic_basis' /-\ntheorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}\n    (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a :=\n  by\n  convert@nhdsWithin_Ici_basis' αᵒᵈ _ _ _ (to_dual a) ha\n  exact funext fun x => (@dual_Ico _ _ _ _).symm\n#align nhds_within_Iic_basis' nhdsWithin_Iic_basis'\n-/\n\n#print nhdsWithin_Ici_basis /-\ntheorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α]\n    (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=\n  nhdsWithin_Ici_basis' (exists_gt a)\n#align nhds_within_Ici_basis nhdsWithin_Ici_basis\n-/\n\n#print nhdsWithin_Iic_basis /-\ntheorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α]\n    (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a :=\n  nhdsWithin_Iic_basis' (exists_lt a)\n#align nhds_within_Iic_basis nhdsWithin_Iic_basis\n-/\n\n/- warning: nhds_top_order -> nhds_top_order is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTop.{u1} α (Preorder.toLE.{u1} α _inst_2)] [_inst_4 : OrderTopology.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 (Top.top.{u1} α (OrderTop.toHasTop.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l (Top.top.{u1} α (OrderTop.toHasTop.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l (Top.top.{u1} α (OrderTop.toHasTop.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) => Filter.principal.{u1} α (Set.Ioi.{u1} α _inst_2 l))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderTop.{u1} α (Preorder.toLE.{u1} α _inst_2)] [_inst_4 : OrderTopology.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 (Top.top.{u1} α (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l (Top.top.{u1} α (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) l (Top.top.{u1} α (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) => Filter.principal.{u1} α (Set.Ioi.{u1} α _inst_2 l))))\nCase conversion may be inaccurate. Consider using '#align nhds_top_order nhds_top_orderₓ'. -/\ntheorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] :\n    𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)]\n#align nhds_top_order nhds_top_order\n\n/- warning: nhds_bot_order -> nhds_bot_order is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderBot.{u1} α (Preorder.toLE.{u1} α _inst_2)] [_inst_4 : OrderTopology.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3)) l) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3)) l) => Filter.principal.{u1} α (Set.Iio.{u1} α _inst_2 l))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : OrderBot.{u1} α (Preorder.toLE.{u1} α _inst_2)] [_inst_4 : OrderTopology.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 (Bot.bot.{u1} α (OrderBot.toBot.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3))) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (l : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) (Bot.bot.{u1} α (OrderBot.toBot.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3)) l) (fun (h₂ : LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) (Bot.bot.{u1} α (OrderBot.toBot.{u1} α (Preorder.toLE.{u1} α _inst_2) _inst_3)) l) => Filter.principal.{u1} α (Set.Iio.{u1} α _inst_2 l))))\nCase conversion may be inaccurate. Consider using '#align nhds_bot_order nhds_bot_orderₓ'. -/\ntheorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] :\n    𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)]\n#align nhds_bot_order nhds_bot_order\n\n/- warning: nhds_top_basis -> nhds_top_basis is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_5 : Nontrivial.{u1} α], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Top.top.{u1} α (OrderTop.toHasTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a (Top.top.{u1} α (OrderTop.toHasTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3))) (fun (a : α) => Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_5 : Nontrivial.{u1} α], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Top.top.{u1} α (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a (Top.top.{u1} α (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3))) (fun (a : α) => Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)\nCase conversion may be inaccurate. Consider using '#align nhds_top_basis nhds_top_basisₓ'. -/\ntheorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α]\n    [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a :=\n  by\n  have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top\n  simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this\n#align nhds_top_basis nhds_top_basis\n\n/- warning: nhds_bot_basis -> nhds_bot_basis is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_5 : Nontrivial.{u1} α], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3)) a) (fun (a : α) => Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_5 : Nontrivial.{u1} α], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Bot.bot.{u1} α (OrderBot.toBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) (Bot.bot.{u1} α (OrderBot.toBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3)) a) (fun (a : α) => Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)\nCase conversion may be inaccurate. Consider using '#align nhds_bot_basis nhds_bot_basisₓ'. -/\ntheorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]\n    [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a :=\n  @nhds_top_basis αᵒᵈ _ _ _ _ _\n#align nhds_bot_basis nhds_bot_basis\n\n/- warning: nhds_top_basis_Ici -> nhds_top_basis_Ici is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_5 : Nontrivial.{u1} α] [_inst_6 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Top.top.{u1} α (OrderTop.toHasTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a (Top.top.{u1} α (OrderTop.toHasTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3))) (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_5 : Nontrivial.{u1} α] [_inst_6 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Top.top.{u1} α (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a (Top.top.{u1} α (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3))) (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align nhds_top_basis_Ici nhds_top_basis_Iciₓ'. -/\ntheorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α]\n    [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici :=\n  nhds_top_basis.to_hasBasis\n    (fun a ha =>\n      let ⟨b, hab, hb⟩ := exists_between ha\n      ⟨b, hb, Ici_subset_Ioi.mpr hab⟩)\n    fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩\n#align nhds_top_basis_Ici nhds_top_basis_Ici\n\n/- warning: nhds_bot_basis_Iic -> nhds_bot_basis_Iic is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_5 : Nontrivial.{u1} α] [_inst_6 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) _inst_3)) a) (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_4 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_5 : Nontrivial.{u1} α] [_inst_6 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (Bot.bot.{u1} α (OrderBot.toBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3))) (fun (a : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) (Bot.bot.{u1} α (OrderBot.toBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) _inst_3)) a) (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align nhds_bot_basis_Iic nhds_bot_basis_Iicₓ'. -/\ntheorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]\n    [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic :=\n  @nhds_top_basis_Ici αᵒᵈ _ _ _ _ _ _\n#align nhds_bot_basis_Iic nhds_bot_basis_Iic\n\n/- warning: tendsto_nhds_top_mono -> tendsto_nhds_top_mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderTop.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toHasTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} α β (Preorder.toLE.{u2} β _inst_2) l f g) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toHasTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderTop.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} α β (Preorder.toLE.{u2} β _inst_2) l f g) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_top_mono tendsto_nhds_top_monoₓ'. -/\ntheorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β]\n    {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) :=\n  by\n  simp only [nhds_top_order, tendsto_infi, tendsto_principal] at hf⊢\n  intro x hx\n  filter_upwards [hf x hx, hg]with _ using lt_of_lt_of_le\n#align tendsto_nhds_top_mono tendsto_nhds_top_mono\n\n/- warning: tendsto_nhds_bot_mono -> tendsto_nhds_bot_mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderBot.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toHasBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} α β (Preorder.toLE.{u2} β _inst_2) l g f) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toHasBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderBot.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} α β (Preorder.toLE.{u2} β _inst_2) l g f) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_bot_mono tendsto_nhds_bot_monoₓ'. -/\ntheorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β]\n    {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) :=\n  @tendsto_nhds_top_mono α βᵒᵈ _ _ _ _ _ _ _ hf hg\n#align tendsto_nhds_bot_mono tendsto_nhds_bot_mono\n\n/- warning: tendsto_nhds_top_mono' -> tendsto_nhds_top_mono' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderTop.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toHasTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (α -> β) (Pi.hasLe.{u1, u2} α (fun (ᾰ : α) => β) (fun (i : α) => Preorder.toLE.{u2} β _inst_2)) f g) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toHasTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderTop.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (α -> β) (Pi.hasLe.{u1, u2} α (fun (ᾰ : α) => β) (fun (i : α) => Preorder.toLE.{u2} β _inst_2)) f g) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Top.top.{u2} β (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_top_mono' tendsto_nhds_top_mono'ₓ'. -/\ntheorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β]\n    {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) :=\n  tendsto_nhds_top_mono hf (eventually_of_forall hg)\n#align tendsto_nhds_top_mono' tendsto_nhds_top_mono'\n\n/- warning: tendsto_nhds_bot_mono' -> tendsto_nhds_bot_mono' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderBot.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toHasBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (α -> β) (Pi.hasLe.{u1, u2} α (fun (ᾰ : α) => β) (fun (i : α) => Preorder.toLE.{u2} β _inst_2)) g f) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toHasBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} β] [_inst_2 : Preorder.{u2} β] [_inst_3 : OrderBot.{u2} β (Preorder.toLE.{u2} β _inst_2)] [_inst_4 : OrderTopology.{u2} β _inst_1 _inst_2] {l : Filter.{u1} α} {f : α -> β} {g : α -> β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (α -> β) (Pi.hasLe.{u1, u2} α (fun (ᾰ : α) => β) (fun (i : α) => Preorder.toLE.{u2} β _inst_2)) g f) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β _inst_1 (Bot.bot.{u2} β (OrderBot.toBot.{u2} β (Preorder.toLE.{u2} β _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono'ₓ'. -/\ntheorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β]\n    {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) :=\n  tendsto_nhds_bot_mono hf (eventually_of_forall hg)\n#align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono'\n\nsection LinearOrder\n\nvariable [TopologicalSpace α] [LinearOrder α]\n\nsection OrderClosedTopology\n\nvariable [OrderClosedTopology α] {a b : α}\n\n#print eventually_le_nhds /-\ntheorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b :=\n  eventually_iff.mpr (mem_nhds_iff.mpr ⟨Iio b, Iio_subset_Iic_self, isOpen_Iio, hab⟩)\n#align eventually_le_nhds eventually_le_nhds\n-/\n\n#print eventually_lt_nhds /-\ntheorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b :=\n  eventually_iff.mpr (mem_nhds_iff.mpr ⟨Iio b, rfl.Subset, isOpen_Iio, hab⟩)\n#align eventually_lt_nhds eventually_lt_nhds\n-/\n\n#print eventually_ge_nhds /-\ntheorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x :=\n  eventually_iff.mpr (mem_nhds_iff.mpr ⟨Ioi b, Ioi_subset_Ici_self, isOpen_Ioi, hab⟩)\n#align eventually_ge_nhds eventually_ge_nhds\n-/\n\n#print eventually_gt_nhds /-\ntheorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x :=\n  eventually_iff.mpr (mem_nhds_iff.mpr ⟨Ioi b, rfl.Subset, isOpen_Ioi, hab⟩)\n#align eventually_gt_nhds eventually_gt_nhds\n-/\n\nend OrderClosedTopology\n\nsection OrderTopology\n\nvariable [OrderTopology α]\n\n#print order_separated /-\ntheorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) :\n    ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ :=\n  match dense_or_discrete a₁ a₂ with\n  | Or.inl ⟨a, ha₁, ha₂⟩ =>\n    ⟨{ a' | a' < a }, { a' | a < a' }, isOpen_gt' a, isOpen_lt' a, ha₁, ha₂, fun b₁ h₁ b₂ h₂ =>\n      lt_trans h₁ h₂⟩\n  | Or.inr ⟨h₁, h₂⟩ =>\n    ⟨{ a | a < a₂ }, { a | a₁ < a }, isOpen_gt' a₂, isOpen_lt' a₁, h, h, fun b₁ hb₁ b₂ hb₂ =>\n      calc\n        b₁ ≤ a₁ := h₂ _ hb₁\n        _ < a₂ := h\n        _ ≤ b₂ := h₁ _ hb₂\n        ⟩\n#align order_separated order_separated\n-/\n\n#print OrderTopology.to_orderClosedTopology /-\n-- see Note [lower instance priority]\ninstance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α\n    where isClosed_le' :=\n    isOpen_compl_iff.1 <|\n      isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) =>\n        have h : a₂ < a₁ := lt_of_not_ge h\n        let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h\n        ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩\n#align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology\n-/\n\n/- warning: exists_Ioc_subset_of_mem_nhds -> exists_Ioc_subset_of_mem_nhds is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {s : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (l : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l a)) -> (Exists.{succ u1} α (fun (l : α) => Exists.{0} (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l a) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l a) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (l : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) l a)) -> (Exists.{succ u1} α (fun (l : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) l a) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s)))\nCase conversion may be inaccurate. Consider using '#align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhdsₓ'. -/\ntheorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) :\n    ∃ l < a, Ioc l a ⊆ s :=\n  (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs)\n#align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds\n\n/- warning: exists_Ioc_subset_of_mem_nhds' -> exists_Ioc_subset_of_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {s : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (forall {l : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l a) -> (Exists.{succ u1} α (fun (l' : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l' (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l' (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l' a) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (forall {l : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) l a) -> (Exists.{succ u1} α (fun (l' : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l' (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l' a) s))))\nCase conversion may be inaccurate. Consider using '#align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds'ₓ'. -/\ntheorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) :\n    ∃ l' ∈ Ico l a, Ioc l' a ⊆ s :=\n  let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩\n  ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩,\n    (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩\n#align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds'\n\n/- warning: exists_Ico_subset_of_mem_nhds' -> exists_Ico_subset_of_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {s : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (forall {u : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u) -> (Exists.{succ u1} α (fun (u' : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u' (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u' (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u') s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (forall {u : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a u) -> (Exists.{succ u1} α (fun (u' : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u' (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u') s))))\nCase conversion may be inaccurate. Consider using '#align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds'ₓ'. -/\ntheorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) :\n    ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by\n  simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using\n    exists_Ioc_subset_of_mem_nhds' (show of_dual ⁻¹' s ∈ 𝓝 (to_dual a) from hs) hu.dual\n#align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds'\n\n/- warning: exists_Ico_subset_of_mem_nhds -> exists_Ico_subset_of_mem_nhds is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {s : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (u : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u)) -> (Exists.{succ u1} α (fun (u : α) => Exists.{0} (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u) (fun (_x : LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (u : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a u)) -> (Exists.{succ u1} α (fun (u : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a u) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s)))\nCase conversion may be inaccurate. Consider using '#align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhdsₓ'. -/\ntheorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) :\n    ∃ (u : _)(_ : a < u), Ico a u ⊆ s :=\n  let ⟨l', hl'⟩ := h\n  let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl'\n  ⟨l, hl.fst.1, hl.snd⟩\n#align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds\n\n/- warning: exists_Icc_mem_subset_of_mem_nhds_within_Ici -> exists_Icc_mem_subset_of_mem_nhdsWithin_Ici is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {s : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) (fun (_x : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) => And (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b) (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) -> (Exists.{succ u1} α (fun (b : α) => And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) (And (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b) (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b) s))))\nCase conversion may be inaccurate. Consider using '#align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Iciₓ'. -/\ntheorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) :\n    ∃ (b : _)(_ : a ≤ b), Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s :=\n  by\n  rcases(em (IsMax a)).imp_right not_is_max_iff.mp with (ha | ha)\n  · use a\n    simpa [ha.Ici_eq] using hs\n  · rcases(nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩\n    rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩)\n    · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty]\n      exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici <| left_mem_Ico.2 hab, hbs⟩⟩\n    · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici <| left_mem_Ico.mpr hac, _⟩\n      exact (Icc_subset_Ico_right hcb).trans hbs\n#align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici\n\n/- warning: exists_Icc_mem_subset_of_mem_nhds_within_Iic -> exists_Icc_mem_subset_of_mem_nhdsWithin_Iic is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {s : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) (fun (H : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) => And (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b a) (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b a) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) -> (Exists.{succ u1} α (fun (b : α) => And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) b a) (And (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b a) (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b a) s))))\nCase conversion may be inaccurate. Consider using '#align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iicₓ'. -/\ntheorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) :\n    ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by\n  simpa only [dual_Icc, to_dual.surjective.exists] using\n    @exists_Icc_mem_subset_of_mem_nhdsWithin_Ici αᵒᵈ _ _ _ (to_dual a) _ hs\n#align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic\n\n#print exists_Icc_mem_subset_of_mem_nhds /-\ntheorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) :\n    ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s :=\n  by\n  rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with\n    ⟨b, hba, hb_nhds, hbs⟩\n  rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with\n    ⟨c, hac, hc_nhds, hcs⟩\n  refine' ⟨b, c, ⟨hba, hac⟩, _⟩\n  rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right]\n  exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩\n#align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds\n-/\n\n#print IsOpen.exists_Ioo_subset /-\ntheorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) :\n    ∃ a b, a < b ∧ Ioo a b ⊆ s :=\n  by\n  obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h\n  obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x\n  rcases lt_trichotomy x y with (H | rfl | H)\n  · obtain ⟨u, xu, hu⟩ : ∃ (u : α)(hu : x < u), Ico x u ⊆ s :=\n      exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩\n    exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩\n  · exact (hy rfl).elim\n  · obtain ⟨l, lx, hl⟩ : ∃ (l : α)(hl : l < x), Ioc l x ⊆ s :=\n      exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩\n    exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩\n#align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset\n-/\n\n/- warning: dense_of_exists_between -> dense_of_exists_between is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : Nontrivial.{u1} α] {s : Set.{u1} α}, (forall {{a : α}} {{b : α}}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) -> (Exists.{succ u1} α (fun (c : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) c s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) c s) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) c b))))) -> (Dense.{u1} α _inst_1 s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : Nontrivial.{u1} α] {s : Set.{u1} α}, (forall {{a : α}} {{b : α}}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) -> (Exists.{succ u1} α (fun (c : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) c s) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) c b))))) -> (Dense.{u1} α _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align dense_of_exists_between dense_of_exists_betweenₓ'. -/\ntheorem dense_of_exists_between [Nontrivial α] {s : Set α}\n    (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s :=\n  by\n  apply dense_iff_inter_open.2 fun U U_open U_nonempty => _\n  obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty\n  obtain ⟨x, xs, hx⟩ : ∃ (x : α)(H : x ∈ s), a < x ∧ x < b := h hab\n  exact ⟨x, ⟨H hx, xs⟩⟩\n#align dense_of_exists_between dense_of_exists_between\n\n/- warning: dense_iff_exists_between -> dense_iff_exists_between is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_5 : Nontrivial.{u1} α] {s : Set.{u1} α}, Iff (Dense.{u1} α _inst_1 s) (forall (a : α) (b : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) -> (Exists.{succ u1} α (fun (c : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) c s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) c s) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) c b)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_5 : Nontrivial.{u1} α] {s : Set.{u1} α}, Iff (Dense.{u1} α _inst_1 s) (forall (a : α) (b : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) -> (Exists.{succ u1} α (fun (c : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) c s) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) c b)))))\nCase conversion may be inaccurate. Consider using '#align dense_iff_exists_between dense_iff_exists_betweenₓ'. -/\n/-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only\nif for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass\nassumptions. -/\ntheorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} :\n    Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b :=\n  ⟨fun h a b hab => h.exists_between hab, dense_of_exists_between⟩\n#align dense_iff_exists_between dense_iff_exists_between\n\n#print mem_nhds_iff_exists_Ioo_subset' /-\n/-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`,\nprovided `a` is neither a bottom element nor a top element. -/\ntheorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) :\n    s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s :=\n  by\n  constructor\n  · intro h\n    rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩\n    rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩\n    exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩\n  · rintro ⟨l, u, ha, h⟩\n    apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h\n#align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset'\n-/\n\n#print mem_nhds_iff_exists_Ioo_subset /-\n/-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`.\n-/\ntheorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} :\n    s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s :=\n  mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a)\n#align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset\n-/\n\n#print nhds_basis_Ioo' /-\ntheorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) :\n    (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 :=\n  ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩\n#align nhds_basis_Ioo' nhds_basis_Ioo'\n-/\n\n#print nhds_basis_Ioo /-\ntheorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) :\n    (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 :=\n  nhds_basis_Ioo' (exists_lt a) (exists_gt a)\n#align nhds_basis_Ioo nhds_basis_Ioo\n-/\n\n#print Filter.Eventually.exists_Ioo_subset /-\ntheorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop}\n    (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } :=\n  mem_nhds_iff_exists_Ioo_subset.1 hp\n#align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset\n-/\n\n#print countable_of_isolated_right' /-\n/-- The set of points which are isolated on the right is countable when the space is\nsecond-countable. -/\ntheorem countable_of_isolated_right' [SecondCountableTopology α] :\n    Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } :=\n  by\n  nontriviality α\n  let s := { x : α | ∃ y, x < y ∧ Ioo x y = ∅ }\n  have : ∀ x ∈ s, ∃ y, x < y ∧ Ioo x y = ∅ := fun x => id\n  choose! y hy h'y using this\n  have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x :=\n    by\n    intro x z xs hz\n    have A : Ioo x (y x) = ∅ := h'y _ xs\n    contrapose! A\n    exact nonempty.ne_empty ⟨z, A, hz⟩\n  suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a }\n  · have : s ⊆ ⋃ a ∈ countable_basis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } :=\n      by\n      intro x hx\n      rcases(is_basis_countable_basis α).exists_mem_of_ne (hy x hx).Ne with ⟨a, ab, xa, ya⟩\n      simp only [mem_set_of_eq, mem_Union]\n      exact ⟨a, ab, hx, xa, ya⟩\n    apply countable.mono this\n    refine' countable.bUnion (countable_countable_basis α) fun a ha => H _ _\n    exact is_open_of_mem_countable_basis ha\n  intro a ha\n  suffices H : Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x }\n  · have :\n      { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } ⊆\n        { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } ∪ { x | IsBot x } :=\n      by\n      intro x hx\n      by_cases h'x : IsBot x\n      · simp only [h'x, mem_set_of_eq, mem_union, not_true, and_false_iff, false_or_iff]\n      ·\n        simpa only [h'x, hx.2.1, hx.2.2, mem_set_of_eq, mem_union, not_false_iff, and_true_iff,\n          or_false_iff] using hx.left\n    exact countable.mono this (H.union (subsingleton_is_bot α).Countable)\n  let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x }\n  have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by\n    intro x hx\n    apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1)\n    simpa only [IsBot, not_forall, not_le] using hx.right.right.right\n  choose! z hz h'z using this\n  have : pairwise_disjoint t fun x => Ioc (z x) x :=\n    by\n    intro x xt x' x't hxx'\n    rcases lt_or_gt_of_ne hxx' with (h' | h')\n    · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _\n      refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩\n      by_contra' H\n      exact False.elim (lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h'))\n    · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _\n      refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩\n      by_contra' H\n      exact False.elim (lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h'))\n  refine' this.countable_of_is_open (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩\n  suffices H : Ioc (z x) x = Ioo (z x) (y x)\n  · rw [H]\n    exact isOpen_Ioo\n  exact subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1)) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩\n#align countable_of_isolated_right countable_of_isolated_right'\n-/\n\n#print countable_of_isolated_left' /-\n/-- The set of points which are isolated on the left is countable when the space is\nsecond-countable. -/\ntheorem countable_of_isolated_left' [SecondCountableTopology α] :\n    Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } :=\n  by\n  convert@countable_of_isolated_right' αᵒᵈ _ _ _ _\n  have : ∀ x y : α, Ioo x y = { z | z < y ∧ x < z } :=\n    by\n    simp_rw [and_comm', Ioo]\n    simp only [eq_self_iff_true, forall₂_true_iff]\n  simp_rw [this]\n  rfl\n#align countable_of_isolated_left countable_of_isolated_left'\n-/\n\n/- warning: set.pairwise_disjoint.countable_of_Ioo -> Set.PairwiseDisjoint.countable_of_Ioo is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : TopologicalSpace.SecondCountableTopology.{u1} α _inst_1] {y : α -> α} {s : Set.{u1} α}, (Set.PairwiseDisjoint.{u1, u1} (Set.{u1} α) α (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) s (fun (x : α) => Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) x (y x))) -> (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x (y x))) -> (Set.Countable.{u1} α s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : TopologicalSpace.SecondCountableTopology.{u1} α _inst_1] {y : α -> α} {s : Set.{u1} α}, (Set.PairwiseDisjoint.{u1, u1} (Set.{u1} α) α (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) s (fun (x : α) => Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) x (y x))) -> (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x (y x))) -> (Set.Countable.{u1} α s)\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Iooₓ'. -/\n/-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space.\nThen the family is countable.\nThis is not a straightforward consequence of second-countability as some of these intervals might be\nempty (but in fact this can happen only for countably many of them). -/\ntheorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α}\n    (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable :=\n  by\n  let t := { x | x ∈ s ∧ (Ioo x (y x)).Nonempty }\n  have t_count : t.countable :=\n    haveI : t ⊆ s := fun x hx => hx.1\n    (h.subset this).countable_of_isOpen (fun x hx => isOpen_Ioo) fun x hx => hx.2\n  have : s ⊆ t ∪ { x : α | ∃ x', x < x' ∧ Ioo x x' = ∅ } :=\n    by\n    intro x hx\n    by_cases h'x : (Ioo x (y x)).Nonempty\n    · exact Or.inl ⟨hx, h'x⟩\n    · exact Or.inr ⟨y x, h' x hx, not_nonempty_iff_eq_empty.1 h'x⟩\n  exact countable.mono this (t_count.union countable_of_isolated_right')\n#align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo\n\nsection Pi\n\n/-!\n### Intervals in `Π i, π i` belong to `𝓝 x`\n\nFor each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because\nsometimes Lean fails to unify different instances while trying to apply the dependent version to,\ne.g., `ι → ℝ`.\n-/\n\n\nvariable {ι : Type _} {π : ι → Type _} [Finite ι] [∀ i, LinearOrder (π i)]\n  [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α}\n\n#print pi_Iic_mem_nhds /-\ntheorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x :=\n  pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun i _ => Iic_mem_nhds (ha _)\n#align pi_Iic_mem_nhds pi_Iic_mem_nhds\n-/\n\n/- warning: pi_Iic_mem_nhds' -> pi_Iic_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {x' : ι -> α}, (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (x' i) (a' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Iic.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {x' : ι -> α}, (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (x' i) (a' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Iic.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Iic_mem_nhds' pi_Iic_mem_nhds'ₓ'. -/\ntheorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' :=\n  pi_Iic_mem_nhds ha\n#align pi_Iic_mem_nhds' pi_Iic_mem_nhds'\n\n#print pi_Ici_mem_nhds /-\ntheorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x :=\n  pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun i _ => Ici_mem_nhds (ha _)\n#align pi_Ici_mem_nhds pi_Ici_mem_nhds\n-/\n\n/- warning: pi_Ici_mem_nhds' -> pi_Ici_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {x' : ι -> α}, (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (a' i) (x' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Ici.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {x' : ι -> α}, (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (a' i) (x' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Ici.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ici_mem_nhds' pi_Ici_mem_nhds'ₓ'. -/\ntheorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' :=\n  pi_Ici_mem_nhds ha\n#align pi_Ici_mem_nhds' pi_Ici_mem_nhds'\n\n#print pi_Icc_mem_nhds /-\ntheorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x :=\n  pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun i _ => Icc_mem_nhds (ha _) (hb _)\n#align pi_Icc_mem_nhds pi_Icc_mem_nhds\n-/\n\n/- warning: pi_Icc_mem_nhds' -> pi_Icc_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α}, (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Icc.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α}, (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Icc.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Icc_mem_nhds' pi_Icc_mem_nhds'ₓ'. -/\ntheorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' :=\n  pi_Icc_mem_nhds ha hb\n#align pi_Icc_mem_nhds' pi_Icc_mem_nhds'\n\nvariable [Nonempty ι]\n\n#print pi_Iio_mem_nhds /-\ntheorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x :=\n  by\n  refine' mem_of_superset (set_pi_mem_nhds (Set.toFinite _) fun i _ => _) (pi_univ_Iio_subset a)\n  exact Iio_mem_nhds (ha i)\n#align pi_Iio_mem_nhds pi_Iio_mem_nhds\n-/\n\n/- warning: pi_Iio_mem_nhds' -> pi_Iio_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u2} ι], (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (x' i) (a' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Iio.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u1} ι], (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (x' i) (a' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Iio.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Iio_mem_nhds' pi_Iio_mem_nhds'ₓ'. -/\ntheorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' :=\n  pi_Iio_mem_nhds ha\n#align pi_Iio_mem_nhds' pi_Iio_mem_nhds'\n\n#print pi_Ioi_mem_nhds /-\ntheorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x :=\n  @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha\n#align pi_Ioi_mem_nhds pi_Ioi_mem_nhds\n-/\n\n/- warning: pi_Ioi_mem_nhds' -> pi_Ioi_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u2} ι], (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (a' i) (x' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Ioi.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u1} ι], (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (a' i) (x' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Ioi.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds'ₓ'. -/\ntheorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' :=\n  pi_Ioi_mem_nhds ha\n#align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds'\n\n#print pi_Ioc_mem_nhds /-\ntheorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x :=\n  by\n  refine' mem_of_superset (set_pi_mem_nhds (Set.toFinite _) fun i _ => _) (pi_univ_Ioc_subset a b)\n  exact Ioc_mem_nhds (ha i) (hb i)\n#align pi_Ioc_mem_nhds pi_Ioc_mem_nhds\n-/\n\n/- warning: pi_Ioc_mem_nhds' -> pi_Ioc_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u2} ι], (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Ioc.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u1} ι], (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Ioc.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds'ₓ'. -/\ntheorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' :=\n  pi_Ioc_mem_nhds ha hb\n#align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds'\n\n#print pi_Ico_mem_nhds /-\ntheorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x :=\n  by\n  refine' mem_of_superset (set_pi_mem_nhds (Set.toFinite _) fun i _ => _) (pi_univ_Ico_subset a b)\n  exact Ico_mem_nhds (ha i) (hb i)\n#align pi_Ico_mem_nhds pi_Ico_mem_nhds\n-/\n\n/- warning: pi_Ico_mem_nhds' -> pi_Ico_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u2} ι], (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Ico.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u1} ι], (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Ico.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ico_mem_nhds' pi_Ico_mem_nhds'ₓ'. -/\ntheorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' :=\n  pi_Ico_mem_nhds ha hb\n#align pi_Ico_mem_nhds' pi_Ico_mem_nhds'\n\n#print pi_Ioo_mem_nhds /-\ntheorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x :=\n  by\n  refine' mem_of_superset (set_pi_mem_nhds (Set.toFinite _) fun i _ => _) (pi_univ_Ioo_subset a b)\n  exact Ioo_mem_nhds (ha i) (hb i)\n#align pi_Ioo_mem_nhds pi_Ioo_mem_nhds\n-/\n\n/- warning: pi_Ioo_mem_nhds' -> pi_Ioo_mem_nhds' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {ι : Type.{u2}} [_inst_4 : Finite.{succ u2} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u2} ι], (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (Filter.hasMem.{max u2 u1} (ι -> α)) (Set.Ioo.{max u2 u1} (ι -> α) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : LinearOrder.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_1 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))] {ι : Type.{u1}} [_inst_4 : Finite.{succ u1} ι] {a' : ι -> α} {b' : ι -> α} {x' : ι -> α} [_inst_8 : Nonempty.{succ u1} ι], (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (a' i) (x' i)) -> (forall (i : ι), LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (ι -> α)) (Filter.{max u2 u1} (ι -> α)) (instMembershipSetFilter.{max u2 u1} (ι -> α)) (Set.Ioo.{max u2 u1} (ι -> α) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_2)))))) a' b') (nhds.{max u2 u1} (ι -> α) (Pi.topologicalSpace.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (a : ι) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds'ₓ'. -/\ntheorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' :=\n  pi_Ioo_mem_nhds ha hb\n#align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds'\n\nend Pi\n\n/- warning: disjoint_nhds_at_top -> disjoint_nhds_atTop is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] (x : α), Disjoint.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (nhds.{u1} α _inst_1 x) (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] (x : α), Disjoint.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (nhds.{u1} α _inst_1 x) (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align disjoint_nhds_at_top disjoint_nhds_atTopₓ'. -/\ntheorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop :=\n  by\n  rcases exists_gt x with ⟨y, hy : x < y⟩\n  refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_at_top y)\n  exact disjoint_left.mpr fun z => not_le.2\n#align disjoint_nhds_at_top disjoint_nhds_atTop\n\n/- warning: inf_nhds_at_top -> inf_nhds_atTop is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] (x : α), Eq.{succ u1} (Filter.{u1} α) (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) (nhds.{u1} α _inst_1 x) (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] (x : α), Eq.{succ u1} (Filter.{u1} α) (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (nhds.{u1} α _inst_1 x) (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align inf_nhds_at_top inf_nhds_atTopₓ'. -/\n@[simp]\ntheorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ :=\n  disjoint_iff.1 (disjoint_nhds_atTop x)\n#align inf_nhds_at_top inf_nhds_atTop\n\n/- warning: disjoint_nhds_at_bot -> disjoint_nhds_atBot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] (x : α), Disjoint.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (nhds.{u1} α _inst_1 x) (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] (x : α), Disjoint.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (nhds.{u1} α _inst_1 x) (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align disjoint_nhds_at_bot disjoint_nhds_atBotₓ'. -/\ntheorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot :=\n  @disjoint_nhds_atTop αᵒᵈ _ _ _ _ x\n#align disjoint_nhds_at_bot disjoint_nhds_atBot\n\n/- warning: inf_nhds_at_bot -> inf_nhds_atBot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] (x : α), Eq.{succ u1} (Filter.{u1} α) (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) (nhds.{u1} α _inst_1 x) (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] (x : α), Eq.{succ u1} (Filter.{u1} α) (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (nhds.{u1} α _inst_1 x) (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align inf_nhds_at_bot inf_nhds_atBotₓ'. -/\n@[simp]\ntheorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ :=\n  @inf_nhds_atTop αᵒᵈ _ _ _ _ x\n#align inf_nhds_at_bot inf_nhds_atBot\n\n#print not_tendsto_nhds_of_tendsto_atTop /-\ntheorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α}\n    (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) :=\n  hf.not_tendsto (disjoint_nhds_atTop x).symm\n#align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop\n-/\n\n#print not_tendsto_atTop_of_tendsto_nhds /-\ntheorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α}\n    {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop :=\n  hf.not_tendsto (disjoint_nhds_atTop x)\n#align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds\n-/\n\n#print not_tendsto_nhds_of_tendsto_atBot /-\ntheorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α}\n    (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) :=\n  hf.not_tendsto (disjoint_nhds_atBot x).symm\n#align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot\n-/\n\n#print not_tendsto_atBot_of_tendsto_nhds /-\ntheorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α}\n    {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot :=\n  hf.not_tendsto (disjoint_nhds_atBot x)\n#align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds\n-/\n\n/-!\n### Neighborhoods to the left and to the right on an `order_topology`\n\nWe've seen some properties of left and right neighborhood of a point in an `order_closed_topology`.\nIn an `order_topology`, such neighborhoods can be characterized as the sets containing suitable\nintervals to the right or to the left of `a`. We give now these characterizations. -/\n\n\n/- warning: tfae_mem_nhds_within_Ioi -> TFAE_mem_nhdsWithin_Ioi is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))) (List.nil.{0} Prop)))))))\nCase conversion may be inaccurate. Consider using '#align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioiₓ'. -/\n-- NB: If you extend the list, append to the end please to avoid breaking the API\n/-- The following statements are equivalent:\n\n0. `s` is a neighborhood of `a` within `(a, +∞)`\n1. `s` is a neighborhood of `a` within `(a, b]`\n2. `s` is a neighborhood of `a` within `(a, b)`\n3. `s` includes `(a, u)` for some `u ∈ (a, b]`\n4. `s` includes `(a, u)` for some `u > a` -/\ntheorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) :\n    TFAE\n      [s ∈ 𝓝[>] a,-- 0 : `s` is a neighborhood of `a` within `(a, +∞)`\n          s ∈\n          𝓝[Ioc a b] a,-- 1 : `s` is a neighborhood of `a` within `(a, b]`\n          s ∈\n          𝓝[Ioo a b] a,-- 2 : `s` is a neighborhood of `a` within `(a, b)`\n        ∃ u ∈ Ioc a b, Ioo a u ⊆ s,-- 3 : `s` includes `(a, u)` for some `u ∈ (a, b]`\n        ∃ u ∈ Ioi a, Ioo a u ⊆ s] :=\n  by\n  -- 4 : `s` includes `(a, u)` for some `u > a`\n  tfae_have 1 ↔ 2;\n  · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab]\n  tfae_have 1 ↔ 3; · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab]\n  tfae_have 4 → 5; exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩\n  tfae_have 5 → 1\n  · rintro ⟨u, hau, hu⟩\n    exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu\n  tfae_have 1 → 4\n  · intro h\n    rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩\n    rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩\n    refine' ⟨u, au, fun x hx => _⟩\n    refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩\n    exact hx.1\n  tfae_finish\n#align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi\n\n/- warning: mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset -> mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u')) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u')) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u')) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subsetₓ'. -/\ntheorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') :\n    s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s :=\n  (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3\n#align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset\n\n/- warning: mem_nhds_within_Ioi_iff_exists_Ioo_subset' -> mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset'ₓ'. -/\n/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)`\nwith `a < u < u'`, provided `a` is not a top element. -/\ntheorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') :\n    s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s :=\n  (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4\n#align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset'\n\n/- warning: mem_nhds_within_Ioi_iff_exists_Ioo_subset -> mem_nhdsWithin_Ioi_iff_exists_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s)))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subsetₓ'. -/\n/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} :\n    s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s :=\n  let ⟨u', hu'⟩ := exists_gt a\n  mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu'\n#align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset\n\n/- warning: mem_nhds_within_Ioi_iff_exists_Ioc_subset -> mem_nhdsWithin_Ioi_iff_exists_Ioc_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_5 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_5 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s)))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Ioi_iff_exists_Ioc_subset mem_nhdsWithin_Ioi_iff_exists_Ioc_subsetₓ'. -/\n/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α}\n    {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s :=\n  by\n  rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset]\n  constructor\n  · rintro ⟨u, au, as⟩\n    rcases exists_between au with ⟨v, hv⟩\n    exact ⟨v, hv.1, fun x hx => as ⟨hx.1, lt_of_le_of_lt hx.2 hv.2⟩⟩\n  · rintro ⟨u, au, as⟩\n    exact ⟨u, au, subset.trans Ioo_subset_Ioc_self as⟩\n#align mem_nhds_within_Ioi_iff_exists_Ioc_subset mem_nhdsWithin_Ioi_iff_exists_Ioc_subset\n\n/- warning: tfae_mem_nhds_within_Iio -> TFAE_mem_nhdsWithin_Iio is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l b) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l b) s))) (List.nil.{0} Prop)))))))\nCase conversion may be inaccurate. Consider using '#align tfae_mem_nhds_within_Iio TFAE_mem_nhdsWithin_Iioₓ'. -/\n/-- The following statements are equivalent:\n\n0. `s` is a neighborhood of `b` within `(-∞, b)`\n1. `s` is a neighborhood of `b` within `[a, b)`\n2. `s` is a neighborhood of `b` within `(a, b)`\n3. `s` includes `(l, b)` for some `l ∈ [a, b)`\n4. `s` includes `(l, b)` for some `l < b` -/\ntheorem TFAE_mem_nhdsWithin_Iio {a b : α} (h : a < b) (s : Set α) :\n    TFAE\n      [s ∈ 𝓝[<] b,-- 0 : `s` is a neighborhood of `b` within `(-∞, b)`\n          s ∈\n          𝓝[Ico a b] b,-- 1 : `s` is a neighborhood of `b` within `[a, b)`\n          s ∈\n          𝓝[Ioo a b] b,-- 2 : `s` is a neighborhood of `b` within `(a, b)`\n        ∃ l ∈ Ico a b, Ioo l b ⊆ s,-- 3 : `s` includes `(l, b)` for some `l ∈ [a, b)`\n        ∃ l ∈ Iio b, Ioo l b ⊆ s] :=\n  by-- 4 : `s` includes `(l, b)` for some `l < b`\n  simpa only [exists_prop, OrderDual.exists, dual_Ioi, dual_Ioc, dual_Ioo] using\n    TFAE_mem_nhdsWithin_Ioi h.dual (of_dual ⁻¹' s)\n#align tfae_mem_nhds_within_Iio TFAE_mem_nhdsWithin_Iio\n\n/- warning: mem_nhds_within_Iio_iff_exists_mem_Ico_Ioo_subset -> mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l' a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l' a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l' a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Iio_iff_exists_mem_Ico_Ioo_subset mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subsetₓ'. -/\ntheorem mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset {a l' : α} {s : Set α} (hl' : l' < a) :\n    s ∈ 𝓝[<] a ↔ ∃ l ∈ Ico l' a, Ioo l a ⊆ s :=\n  (TFAE_mem_nhdsWithin_Iio hl' s).out 0 3\n#align mem_nhds_within_Iio_iff_exists_mem_Ico_Ioo_subset mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset\n\n/- warning: mem_nhds_within_Iio_iff_exists_Ioo_subset' -> mem_nhdsWithin_Iio_iff_exists_Ioo_subset' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Iio_iff_exists_Ioo_subset' mem_nhdsWithin_Iio_iff_exists_Ioo_subset'ₓ'. -/\n/-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `(l, a)`\nwith `l < a`, provided `a` is not a bottom element. -/\ntheorem mem_nhdsWithin_Iio_iff_exists_Ioo_subset' {a l' : α} {s : Set α} (hl' : l' < a) :\n    s ∈ 𝓝[<] a ↔ ∃ l ∈ Iio a, Ioo l a ⊆ s :=\n  (TFAE_mem_nhdsWithin_Iio hl' s).out 0 4\n#align mem_nhds_within_Iio_iff_exists_Ioo_subset' mem_nhdsWithin_Iio_iff_exists_Ioo_subset'\n\n/- warning: mem_nhds_within_Iio_iff_exists_Ioo_subset -> mem_nhdsWithin_Iio_iff_exists_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s)))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Iio_iff_exists_Ioo_subset mem_nhdsWithin_Iio_iff_exists_Ioo_subsetₓ'. -/\n/-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `(l, a)`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iio_iff_exists_Ioo_subset [NoMinOrder α] {a : α} {s : Set α} :\n    s ∈ 𝓝[<] a ↔ ∃ l ∈ Iio a, Ioo l a ⊆ s :=\n  let ⟨l', hl'⟩ := exists_lt a\n  mem_nhdsWithin_Iio_iff_exists_Ioo_subset' hl'\n#align mem_nhds_within_Iio_iff_exists_Ioo_subset mem_nhdsWithin_Iio_iff_exists_Ioo_subset\n\n/- warning: mem_nhds_within_Iio_iff_exists_Ico_subset -> mem_nhdsWithin_Iio_iff_exists_Ico_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_5 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_5 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s)))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Iio_iff_exists_Ico_subset mem_nhdsWithin_Iio_iff_exists_Ico_subsetₓ'. -/\n/-- A set is a neighborhood of `a` within `(-∞, a)` if and only if it contains an interval `[l, a)`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iio_iff_exists_Ico_subset [NoMinOrder α] [DenselyOrdered α] {a : α}\n    {s : Set α} : s ∈ 𝓝[<] a ↔ ∃ l ∈ Iio a, Ico l a ⊆ s :=\n  by\n  have : of_dual ⁻¹' s ∈ 𝓝[>] to_dual a ↔ _ := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset\n  simpa only [OrderDual.exists, exists_prop, dual_Ioc] using this\n#align mem_nhds_within_Iio_iff_exists_Ico_subset mem_nhdsWithin_Iio_iff_exists_Ico_subset\n\n/- warning: tfae_mem_nhds_within_Ici -> TFAE_mem_nhdsWithin_Ici is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))) (List.nil.{0} Prop)))))))\nCase conversion may be inaccurate. Consider using '#align tfae_mem_nhds_within_Ici TFAE_mem_nhdsWithin_Iciₓ'. -/\n/-- The following statements are equivalent:\n\n0. `s` is a neighborhood of `a` within `[a, +∞)`\n1. `s` is a neighborhood of `a` within `[a, b]`\n2. `s` is a neighborhood of `a` within `[a, b)`\n3. `s` includes `[a, u)` for some `u ∈ (a, b]`\n4. `s` includes `[a, u)` for some `u > a` -/\ntheorem TFAE_mem_nhdsWithin_Ici {a b : α} (hab : a < b) (s : Set α) :\n    TFAE\n      [s ∈ 𝓝[≥] a,-- 0 : `s` is a neighborhood of `a` within `[a, +∞)`\n          s ∈\n          𝓝[Icc a b] a,-- 1 : `s` is a neighborhood of `a` within `[a, b]`\n          s ∈\n          𝓝[Ico a b] a,-- 2 : `s` is a neighborhood of `a` within `[a, b)`\n        ∃ u ∈ Ioc a b, Ico a u ⊆ s,-- 3 : `s` includes `[a, u)` for some `u ∈ (a, b]`\n        ∃ u ∈ Ioi a, Ico a u ⊆ s] :=\n  by\n  -- 4 : `s` includes `[a, u)` for some `u > a`\n  tfae_have 1 ↔ 2;\n  · rw [nhdsWithin_Icc_eq_nhdsWithin_Ici hab]\n  tfae_have 1 ↔ 3; · rw [nhdsWithin_Ico_eq_nhdsWithin_Ici hab]\n  tfae_have 1 ↔ 5; exact (nhdsWithin_Ici_basis' ⟨b, hab⟩).mem_iff\n  tfae_have 4 → 5; exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩\n  tfae_have 5 → 4\n  · rintro ⟨u, hua, hus⟩\n    exact\n      ⟨min u b, ⟨lt_min hua hab, min_le_right _ _⟩,\n        (Ico_subset_Ico_right <| min_le_left _ _).trans hus⟩\n  tfae_finish\n#align tfae_mem_nhds_within_Ici TFAE_mem_nhdsWithin_Ici\n\n/- warning: mem_nhds_within_Ici_iff_exists_mem_Ioc_Ico_subset -> mem_nhdsWithin_Ici_iff_exists_mem_Ioc_Ico_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u')) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u')) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u')) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Ici_iff_exists_mem_Ioc_Ico_subset mem_nhdsWithin_Ici_iff_exists_mem_Ioc_Ico_subsetₓ'. -/\ntheorem mem_nhdsWithin_Ici_iff_exists_mem_Ioc_Ico_subset {a u' : α} {s : Set α} (hu' : a < u') :\n    s ∈ 𝓝[≥] a ↔ ∃ u ∈ Ioc a u', Ico a u ⊆ s :=\n  (TFAE_mem_nhdsWithin_Ici hu' s).out 0 3 (by norm_num) (by norm_num)\n#align mem_nhds_within_Ici_iff_exists_mem_Ioc_Ico_subset mem_nhdsWithin_Ici_iff_exists_mem_Ioc_Ico_subset\n\n/- warning: mem_nhds_within_Ici_iff_exists_Ico_subset' -> mem_nhdsWithin_Ici_iff_exists_Ico_subset' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {u' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Ici_iff_exists_Ico_subset' mem_nhdsWithin_Ici_iff_exists_Ico_subset'ₓ'. -/\n/-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u)`\nwith `a < u < u'`, provided `a` is not a top element. -/\ntheorem mem_nhdsWithin_Ici_iff_exists_Ico_subset' {a u' : α} {s : Set α} (hu' : a < u') :\n    s ∈ 𝓝[≥] a ↔ ∃ u ∈ Ioi a, Ico a u ⊆ s :=\n  (TFAE_mem_nhdsWithin_Ici hu' s).out 0 4 (by norm_num) (by norm_num)\n#align mem_nhds_within_Ici_iff_exists_Ico_subset' mem_nhdsWithin_Ici_iff_exists_Ico_subset'\n\n/- warning: mem_nhds_within_Ici_iff_exists_Ico_subset -> mem_nhdsWithin_Ici_iff_exists_Ico_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (u : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Ici.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (u : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) u (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a u) s)))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Ici_iff_exists_Ico_subset mem_nhdsWithin_Ici_iff_exists_Ico_subsetₓ'. -/\n/-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u)`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ici_iff_exists_Ico_subset [NoMaxOrder α] {a : α} {s : Set α} :\n    s ∈ 𝓝[≥] a ↔ ∃ u ∈ Ioi a, Ico a u ⊆ s :=\n  let ⟨u', hu'⟩ := exists_gt a\n  mem_nhdsWithin_Ici_iff_exists_Ico_subset' hu'\n#align mem_nhds_within_Ici_iff_exists_Ico_subset mem_nhdsWithin_Ici_iff_exists_Ico_subset\n\n#print nhdsWithin_Ici_basis_Ico /-\ntheorem nhdsWithin_Ici_basis_Ico [NoMaxOrder α] (a : α) :\n    (𝓝[≥] a).HasBasis (fun u => a < u) (Ico a) :=\n  ⟨fun s => mem_nhdsWithin_Ici_iff_exists_Ico_subset⟩\n#align nhds_within_Ici_basis_Ico nhdsWithin_Ici_basis_Ico\n-/\n\n#print mem_nhdsWithin_Ici_iff_exists_Icc_subset /-\n/-- A set is a neighborhood of `a` within `[a, +∞)` if and only if it contains an interval `[a, u]`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ici_iff_exists_Icc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α}\n    {s : Set α} : s ∈ 𝓝[≥] a ↔ ∃ u, a < u ∧ Icc a u ⊆ s :=\n  by\n  rw [mem_nhdsWithin_Ici_iff_exists_Ico_subset]\n  constructor\n  · rintro ⟨u, au, as⟩\n    rcases exists_between au with ⟨v, hv⟩\n    exact ⟨v, hv.1, fun x hx => as ⟨hx.1, lt_of_le_of_lt hx.2 hv.2⟩⟩\n  · rintro ⟨u, au, as⟩\n    exact ⟨u, au, subset.trans Ico_subset_Icc_self as⟩\n#align mem_nhds_within_Ici_iff_exists_Icc_subset mem_nhdsWithin_Ici_iff_exists_Icc_subset\n-/\n\n/- warning: tfae_mem_nhds_within_Iic -> TFAE_mem_nhdsWithin_Iic is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l b) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) -> (forall (s : Set.{u1} α), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 b (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l b) s))) (List.nil.{0} Prop)))))))\nCase conversion may be inaccurate. Consider using '#align tfae_mem_nhds_within_Iic TFAE_mem_nhdsWithin_Iicₓ'. -/\n/-- The following statements are equivalent:\n\n0. `s` is a neighborhood of `b` within `(-∞, b]`\n1. `s` is a neighborhood of `b` within `[a, b]`\n2. `s` is a neighborhood of `b` within `(a, b]`\n3. `s` includes `(l, b]` for some `l ∈ [a, b)`\n4. `s` includes `(l, b]` for some `l < b` -/\ntheorem TFAE_mem_nhdsWithin_Iic {a b : α} (h : a < b) (s : Set α) :\n    TFAE\n      [s ∈ 𝓝[≤] b,-- 0 : `s` is a neighborhood of `b` within `(-∞, b]`\n          s ∈\n          𝓝[Icc a b] b,-- 1 : `s` is a neighborhood of `b` within `[a, b]`\n          s ∈\n          𝓝[Ioc a b] b,-- 2 : `s` is a neighborhood of `b` within `(a, b]`\n        ∃ l ∈ Ico a b, Ioc l b ⊆ s,-- 3 : `s` includes `(l, b]` for some `l ∈ [a, b)`\n        ∃ l ∈ Iio b, Ioc l b ⊆ s] :=\n  by-- 4 : `s` includes `(l, b]` for some `l < b`\n  simpa only [exists_prop, OrderDual.exists, dual_Ici, dual_Ioc, dual_Icc, dual_Ico] using\n    TFAE_mem_nhdsWithin_Ici h.dual (of_dual ⁻¹' s)\n#align tfae_mem_nhds_within_Iic TFAE_mem_nhdsWithin_Iic\n\n/- warning: mem_nhds_within_Iic_iff_exists_mem_Ico_Ioc_subset -> mem_nhdsWithin_Iic_iff_exists_mem_Ico_Ioc_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l' a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l' a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l' a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Iic_iff_exists_mem_Ico_Ioc_subset mem_nhdsWithin_Iic_iff_exists_mem_Ico_Ioc_subsetₓ'. -/\ntheorem mem_nhdsWithin_Iic_iff_exists_mem_Ico_Ioc_subset {a l' : α} {s : Set α} (hl' : l' < a) :\n    s ∈ 𝓝[≤] a ↔ ∃ l ∈ Ico l' a, Ioc l a ⊆ s :=\n  (TFAE_mem_nhdsWithin_Iic hl' s).out 0 3 (by norm_num) (by norm_num)\n#align mem_nhds_within_Iic_iff_exists_mem_Ico_Ioc_subset mem_nhdsWithin_Iic_iff_exists_mem_Ico_Ioc_subset\n\n/- warning: mem_nhds_within_Iic_iff_exists_Ioc_subset' -> mem_nhdsWithin_Iic_iff_exists_Ioc_subset' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] {a : α} {l' : α} {s : Set.{u1} α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s))))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Iic_iff_exists_Ioc_subset' mem_nhdsWithin_Iic_iff_exists_Ioc_subset'ₓ'. -/\n/-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `(l, a]`\nwith `l < a`, provided `a` is not a bottom element. -/\ntheorem mem_nhdsWithin_Iic_iff_exists_Ioc_subset' {a l' : α} {s : Set α} (hl' : l' < a) :\n    s ∈ 𝓝[≤] a ↔ ∃ l ∈ Iio a, Ioc l a ⊆ s :=\n  (TFAE_mem_nhdsWithin_Iic hl' s).out 0 4 (by norm_num) (by norm_num)\n#align mem_nhds_within_Iic_iff_exists_Ioc_subset' mem_nhdsWithin_Iic_iff_exists_Ioc_subset'\n\n/- warning: mem_nhds_within_Iic_iff_exists_Ioc_subset -> mem_nhdsWithin_Iic_iff_exists_Ioc_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Exists.{succ u1} α (fun (l : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhdsWithin.{u1} α _inst_1 a (Set.Iic.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Exists.{succ u1} α (fun (l : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) l (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) l a) s)))\nCase conversion may be inaccurate. Consider using '#align mem_nhds_within_Iic_iff_exists_Ioc_subset mem_nhdsWithin_Iic_iff_exists_Ioc_subsetₓ'. -/\n/-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `(l, a]`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iic_iff_exists_Ioc_subset [NoMinOrder α] {a : α} {s : Set α} :\n    s ∈ 𝓝[≤] a ↔ ∃ l ∈ Iio a, Ioc l a ⊆ s :=\n  let ⟨l', hl'⟩ := exists_lt a\n  mem_nhdsWithin_Iic_iff_exists_Ioc_subset' hl'\n#align mem_nhds_within_Iic_iff_exists_Ioc_subset mem_nhdsWithin_Iic_iff_exists_Ioc_subset\n\n#print mem_nhdsWithin_Iic_iff_exists_Icc_subset /-\n/-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `[l, a]`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iic_iff_exists_Icc_subset [NoMinOrder α] [DenselyOrdered α] {a : α}\n    {s : Set α} : s ∈ 𝓝[≤] a ↔ ∃ l, l < a ∧ Icc l a ⊆ s :=\n  by\n  convert@mem_nhdsWithin_Ici_iff_exists_Icc_subset αᵒᵈ _ _ _ _ _ _ _\n  simp_rw [show ∀ u : αᵒᵈ, @Icc αᵒᵈ _ a u = @Icc α _ u a from fun u => dual_Icc]\n  rfl\n#align mem_nhds_within_Iic_iff_exists_Icc_subset mem_nhdsWithin_Iic_iff_exists_Icc_subset\n-/\n\nend OrderTopology\n\nend LinearOrder\n\nsection LinearOrderedAddCommGroup\n\nvariable [TopologicalSpace α] [LinearOrderedAddCommGroup α] [OrderTopology α]\n\nvariable {l : Filter β} {f g : β → α}\n\n/- warning: nhds_eq_infi_abs_sub -> nhds_eq_infᵢ_abs_sub is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 a) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (r : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) r (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))))) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) r (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))))) => Filter.principal.{u1} α (setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) a b)) r)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] (a : α), Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_1 a) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (r : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) r (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) r (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) => Filter.principal.{u1} α (setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) a b)) r)))))\nCase conversion may be inaccurate. Consider using '#align nhds_eq_infi_abs_sub nhds_eq_infᵢ_abs_subₓ'. -/\ntheorem nhds_eq_infᵢ_abs_sub (a : α) : 𝓝 a = ⨅ r > 0, 𝓟 { b | |a - b| < r } :=\n  by\n  simp only [le_antisymm_iff, nhds_eq_order, le_inf_iff, le_infᵢ_iff, le_principal_iff, mem_Ioi,\n    mem_Iio, abs_sub_lt_iff, @sub_lt_iff_lt_add _ _ _ _ _ _ a, @sub_lt_comm _ _ _ _ a, set_of_and]\n  refine' ⟨_, _, _⟩\n  · intro ε ε0\n    exact\n      inter_mem_inf\n        (mem_infi_of_mem (a - ε) <| mem_infi_of_mem (sub_lt_self a ε0) (mem_principal_self _))\n        (mem_infi_of_mem (ε + a) <| mem_infi_of_mem (by simpa) (mem_principal_self _))\n  · intro b hb\n    exact mem_infi_of_mem (a - b) (mem_infi_of_mem (sub_pos.2 hb) (by simp [Ioi]))\n  · intro b hb\n    exact mem_infi_of_mem (b - a) (mem_infi_of_mem (sub_pos.2 hb) (by simp [Iio]))\n#align nhds_eq_infi_abs_sub nhds_eq_infᵢ_abs_sub\n\n/- warning: order_topology_of_nhds_abs -> orderTopology_of_nhds_abs is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_4 : TopologicalSpace.{u1} α] [_inst_5 : LinearOrderedAddCommGroup.{u1} α], (forall (a : α), Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_4 a) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) α (fun (r : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))) r (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5))))))))))) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))) r (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5))))))))))) => Filter.principal.{u1} α (setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_5))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))))) a b)) r)))))) -> (OrderTopology.{u1} α _inst_4 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_4 : TopologicalSpace.{u1} α] [_inst_5 : LinearOrderedAddCommGroup.{u1} α], (forall (a : α), Eq.{succ u1} (Filter.{u1} α) (nhds.{u1} α _inst_4 a) (infᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) α (fun (r : α) => infᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))) r (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))))))))) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))) r (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))))))))) => Filter.principal.{u1} α (setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5))))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_5)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5)))))) a b)) r)))))) -> (OrderTopology.{u1} α _inst_4 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_5))))\nCase conversion may be inaccurate. Consider using '#align order_topology_of_nhds_abs orderTopology_of_nhds_absₓ'. -/\ntheorem orderTopology_of_nhds_abs {α : Type _} [TopologicalSpace α] [LinearOrderedAddCommGroup α]\n    (h_nhds : ∀ a : α, 𝓝 a = ⨅ r > 0, 𝓟 { b | |a - b| < r }) : OrderTopology α :=\n  by\n  refine' ⟨eq_of_nhds_eq_nhds fun a => _⟩\n  rw [h_nhds]\n  letI := Preorder.topology α; letI : OrderTopology α := ⟨rfl⟩\n  exact (nhds_eq_infᵢ_abs_sub a).symm\n#align order_topology_of_nhds_abs orderTopology_of_nhds_abs\n\n/- warning: linear_ordered_add_comm_group.tendsto_nhds -> LinearOrderedAddCommGroup.tendsto_nhds is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {f : β -> α} {x : Filter.{u2} β} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α f x (nhds.{u1} α _inst_1 a)) (forall (ε : α), (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) ε (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))))) -> (Filter.Eventually.{u2} β (fun (b : β) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) (f b) a)) ε) x))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {f : β -> α} {x : Filter.{u2} β} {a : α}, Iff (Filter.Tendsto.{u2, u1} β α f x (nhds.{u1} α _inst_1 a)) (forall (ε : α), (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) ε (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) -> (Filter.Eventually.{u2} β (fun (b : β) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) (f b) a)) ε) x))\nCase conversion may be inaccurate. Consider using '#align linear_ordered_add_comm_group.tendsto_nhds LinearOrderedAddCommGroup.tendsto_nhdsₓ'. -/\ntheorem LinearOrderedAddCommGroup.tendsto_nhds {x : Filter β} {a : α} :\n    Tendsto f x (𝓝 a) ↔ ∀ ε > (0 : α), ∀ᶠ b in x, |f b - a| < ε := by\n  simp [nhds_eq_infᵢ_abs_sub, abs_sub_comm a]\n#align linear_ordered_add_comm_group.tendsto_nhds LinearOrderedAddCommGroup.tendsto_nhds\n\n/- warning: eventually_abs_sub_lt -> eventually_abs_sub_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] (a : α) {ε : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) ε) -> (Filter.Eventually.{u1} α (fun (x : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) x a)) ε) (nhds.{u1} α _inst_1 a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] (a : α) {ε : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))) ε) -> (Filter.Eventually.{u1} α (fun (x : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) x a)) ε) (nhds.{u1} α _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align eventually_abs_sub_lt eventually_abs_sub_ltₓ'. -/\ntheorem eventually_abs_sub_lt (a : α) {ε : α} (hε : 0 < ε) : ∀ᶠ x in 𝓝 a, |x - a| < ε :=\n  (nhds_eq_infᵢ_abs_sub a).symm ▸\n    mem_infᵢ_of_mem ε (mem_infᵢ_of_mem hε <| by simp only [abs_sub_comm, mem_principal_self])\n#align eventually_abs_sub_lt eventually_abs_sub_lt\n\n/- warning: filter.tendsto.add_at_top -> Filter.Tendsto.add_atTop is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α g l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α g l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.add_at_top Filter.Tendsto.add_atTopₓ'. -/\n/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to `C`\nand `g` tends to `at_top` then `f + g` tends to `at_top`. -/\ntheorem Filter.Tendsto.add_atTop {C : α} (hf : Tendsto f l (𝓝 C)) (hg : Tendsto g l atTop) :\n    Tendsto (fun x => f x + g x) l atTop :=\n  by\n  nontriviality α\n  obtain ⟨C', hC'⟩ : ∃ C', C' < C := exists_lt C\n  refine' tendsto_at_top_add_left_of_le' _ C' _ hg\n  exact (hf.eventually (lt_mem_nhds hC')).mono fun x => le_of_lt\n#align filter.tendsto.add_at_top Filter.Tendsto.add_atTop\n\n/- warning: filter.tendsto.add_at_bot -> Filter.Tendsto.add_atBot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α g l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α g l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.add_at_bot Filter.Tendsto.add_atBotₓ'. -/\n/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to `C`\nand `g` tends to `at_bot` then `f + g` tends to `at_bot`. -/\ntheorem Filter.Tendsto.add_atBot {C : α} (hf : Tendsto f l (𝓝 C)) (hg : Tendsto g l atBot) :\n    Tendsto (fun x => f x + g x) l atBot :=\n  @Filter.Tendsto.add_atTop αᵒᵈ _ _ _ _ _ _ _ _ hf hg\n#align filter.tendsto.add_at_bot Filter.Tendsto.add_atBot\n\n/- warning: filter.tendsto.at_top_add -> Filter.Tendsto.atTop_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α g l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α g l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.at_top_add Filter.Tendsto.atTop_addₓ'. -/\n/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to\n`at_top` and `g` tends to `C` then `f + g` tends to `at_top`. -/\ntheorem Filter.Tendsto.atTop_add {C : α} (hf : Tendsto f l atTop) (hg : Tendsto g l (𝓝 C)) :\n    Tendsto (fun x => f x + g x) l atTop :=\n  by\n  conv in _ + _ => rw [add_comm]\n  exact hg.add_at_top hf\n#align filter.tendsto.at_top_add Filter.Tendsto.atTop_add\n\n/- warning: filter.tendsto.at_bot_add -> Filter.Tendsto.atBot_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α g l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] {l : Filter.{u2} β} {f : β -> α} {g : β -> α} {C : α}, (Filter.Tendsto.{u2, u1} β α f l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) -> (Filter.Tendsto.{u2, u1} β α g l (nhds.{u1} α _inst_1 C)) -> (Filter.Tendsto.{u2, u1} β α (fun (x : β) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.at_bot_add Filter.Tendsto.atBot_addₓ'. -/\n/-- In a linearly ordered additive commutative group with the order topology, if `f` tends to\n`at_bot` and `g` tends to `C` then `f + g` tends to `at_bot`. -/\ntheorem Filter.Tendsto.atBot_add {C : α} (hf : Tendsto f l atBot) (hg : Tendsto g l (𝓝 C)) :\n    Tendsto (fun x => f x + g x) l atBot :=\n  by\n  conv in _ + _ => rw [add_comm]\n  exact hg.add_at_bot hf\n#align filter.tendsto.at_bot_add Filter.Tendsto.atBot_add\n\n/- warning: nhds_basis_Ioo_pos -> nhds_basis_Ioo_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] [_inst_5 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] (a : α), Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 a) (fun (ε : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) ε) (fun (ε : α) => Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) a ε) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) a ε))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] (_inst_5 : α), Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 _inst_5) (fun (ε : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))) ε) (fun (ε : α) => Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) _inst_5 ε) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) _inst_5 ε))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_Ioo_pos nhds_basis_Ioo_posₓ'. -/\ntheorem nhds_basis_Ioo_pos [NoMinOrder α] [NoMaxOrder α] (a : α) :\n    (𝓝 a).HasBasis (fun ε : α => (0 : α) < ε) fun ε => Ioo (a - ε) (a + ε) :=\n  ⟨by\n    refine' fun t => (nhds_basis_Ioo a).mem_iff.trans ⟨_, _⟩\n    · rintro ⟨⟨l, u⟩, ⟨hl : l < a, hu : a < u⟩, h' : Ioo l u ⊆ t⟩\n      refine' ⟨min (a - l) (u - a), by apply lt_min <;> rwa [sub_pos], _⟩\n      rintro x ⟨hx, hx'⟩\n      apply h'\n      rw [sub_lt_comm, lt_min_iff, sub_lt_sub_iff_left] at hx\n      rw [← sub_lt_iff_lt_add', lt_min_iff, sub_lt_sub_iff_right] at hx'\n      exact ⟨hx.1, hx'.2⟩\n    · rintro ⟨ε, ε_pos, h⟩\n      exact ⟨(a - ε, a + ε), by simp [ε_pos], h⟩⟩\n#align nhds_basis_Ioo_pos nhds_basis_Ioo_pos\n\n/- warning: nhds_basis_abs_sub_lt -> nhds_basis_abs_sub_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] [_inst_5 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] (a : α), Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 a) (fun (ε : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) ε) (fun (ε : α) => setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) b a)) ε))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] (_inst_5 : α), Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 _inst_5) (fun (ε : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))) ε) (fun (ε : α) => setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) b _inst_5)) ε))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_abs_sub_lt nhds_basis_abs_sub_ltₓ'. -/\ntheorem nhds_basis_abs_sub_lt [NoMinOrder α] [NoMaxOrder α] (a : α) :\n    (𝓝 a).HasBasis (fun ε : α => (0 : α) < ε) fun ε => { b | |b - a| < ε } :=\n  by\n  convert nhds_basis_Ioo_pos a\n  · ext ε\n    change |x - a| < ε ↔ a - ε < x ∧ x < a + ε\n    simp [abs_lt, sub_lt_iff_lt_add, add_comm ε a, add_comm x ε]\n#align nhds_basis_abs_sub_lt nhds_basis_abs_sub_lt\n\nvariable (α)\n\n/- warning: nhds_basis_zero_abs_sub_lt -> nhds_basis_zero_abs_sub_lt is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] [_inst_5 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))))) (fun (ε : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) ε) (fun (ε : α) => setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2))))) b) ε))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))], Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) (fun (ε : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))) ε) (fun (ε : α) => setOf.{u1} α (fun (b : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedAddCommGroup.toLinearOrder.{u1} α _inst_2)))))) b) ε))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_zero_abs_sub_lt nhds_basis_zero_abs_sub_ltₓ'. -/\ntheorem nhds_basis_zero_abs_sub_lt [NoMinOrder α] [NoMaxOrder α] :\n    (𝓝 (0 : α)).HasBasis (fun ε : α => (0 : α) < ε) fun ε => { b | |b| < ε } := by\n  simpa using nhds_basis_abs_sub_lt (0 : α)\n#align nhds_basis_zero_abs_sub_lt nhds_basis_zero_abs_sub_lt\n\nvariable {α}\n\n/- warning: nhds_basis_Ioo_pos_of_pos -> nhds_basis_Ioo_pos_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] [_inst_5 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) a) -> (Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 a) (fun (ε : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))))) ε) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) ε a)) (fun (ε : α) => Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) a ε) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) a ε)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrderedAddCommGroup.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))] [_inst_4 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))] {_inst_5 : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))) _inst_5) -> (Filter.HasBasis.{u1, succ u1} α α (nhds.{u1} α _inst_1 _inst_5) (fun (ε : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (NegZeroClass.toZero.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (SubtractionCommMonoid.toSubtractionMonoid.{u1} α (AddCommGroup.toDivisionAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))))))))) ε) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))) ε _inst_5)) (fun (ε : α) => Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))) _inst_5 ε) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} α _inst_2)))))))) _inst_5 ε)))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_Ioo_pos_of_pos nhds_basis_Ioo_pos_of_posₓ'. -/\n/-- If `a` is positive we can form a basis from only nonnegative `Ioo` intervals -/\ntheorem nhds_basis_Ioo_pos_of_pos [NoMinOrder α] [NoMaxOrder α] {a : α} (ha : 0 < a) :\n    (𝓝 a).HasBasis (fun ε : α => (0 : α) < ε ∧ ε ≤ a) fun ε => Ioo (a - ε) (a + ε) :=\n  ⟨fun t =>\n    (nhds_basis_Ioo_pos a).mem_iff.trans\n      ⟨fun h =>\n        let ⟨i, hi, hit⟩ := h\n        ⟨min i a, ⟨lt_min hi ha, min_le_right i a⟩,\n          trans\n            (Ioo_subset_Ioo (sub_le_sub_left (min_le_left i a) a)\n              (add_le_add_left (min_le_left i a) a))\n            hit⟩,\n        fun h =>\n        let ⟨i, hi, hit⟩ := h\n        ⟨i, hi.1, hit⟩⟩⟩\n#align nhds_basis_Ioo_pos_of_pos nhds_basis_Ioo_pos_of_pos\n\nend LinearOrderedAddCommGroup\n\n/- warning: preimage_neg -> preimage_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : AddGroup.{u1} α], Eq.{succ u1} ((Set.{u1} α) -> (Set.{u1} α)) (Set.preimage.{u1, u1} α α (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α _inst_1)))) (Set.image.{u1, u1} α α (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : AddGroup.{u1} α], Eq.{succ u1} ((Set.{u1} α) -> (Set.{u1} α)) (Set.preimage.{u1, u1} α α (Neg.neg.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (AddGroup.toSubtractionMonoid.{u1} α _inst_1)))))) (Set.image.{u1, u1} α α (Neg.neg.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (AddGroup.toSubtractionMonoid.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align preimage_neg preimage_negₓ'. -/\ntheorem preimage_neg [AddGroup α] : preimage (Neg.neg : α → α) = image (Neg.neg : α → α) :=\n  (image_eq_preimage_of_inverse neg_neg neg_neg).symm\n#align preimage_neg preimage_neg\n\n/- warning: filter.map_neg_eq_comap_neg -> Filter.map_neg_eq_comap_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : AddGroup.{u1} α], Eq.{succ u1} ((Filter.{u1} α) -> (Filter.{u1} α)) (Filter.map.{u1, u1} α α (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α _inst_1)))) (Filter.comap.{u1, u1} α α (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : AddGroup.{u1} α], Eq.{succ u1} ((Filter.{u1} α) -> (Filter.{u1} α)) (Filter.map.{u1, u1} α α (Neg.neg.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (AddGroup.toSubtractionMonoid.{u1} α _inst_1)))))) (Filter.comap.{u1, u1} α α (Neg.neg.{u1} α (NegZeroClass.toNeg.{u1} α (SubNegZeroMonoid.toNegZeroClass.{u1} α (SubtractionMonoid.toSubNegZeroMonoid.{u1} α (AddGroup.toSubtractionMonoid.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align filter.map_neg_eq_comap_neg Filter.map_neg_eq_comap_negₓ'. -/\ntheorem Filter.map_neg_eq_comap_neg [AddGroup α] :\n    map (Neg.neg : α → α) = comap (Neg.neg : α → α) :=\n  funext fun f => map_eq_comap_of_inverse (funext neg_neg) (funext neg_neg)\n#align filter.map_neg_eq_comap_neg Filter.map_neg_eq_comap_neg\n\nsection OrderTopology\n\nvariable [TopologicalSpace α] [TopologicalSpace β] [LinearOrder α] [LinearOrder β] [OrderTopology α]\n  [OrderTopology β]\n\n#print IsLUB.frequently_mem /-\ntheorem IsLUB.frequently_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) :\n    ∃ᶠ x in 𝓝[≤] a, x ∈ s := by\n  rcases hs with ⟨a', ha'⟩\n  intro h\n  rcases(ha.1 ha').eq_or_lt with (rfl | ha'a)\n  · exact h.self_of_nhds_within le_rfl ha'\n  · rcases(mem_nhdsWithin_Iic_iff_exists_Ioc_subset' ha'a).1 h with ⟨b, hba, hb⟩\n    rcases ha.exists_between hba with ⟨b', hb's, hb'⟩\n    exact hb hb' hb's\n#align is_lub.frequently_mem IsLUB.frequently_mem\n-/\n\n#print IsLUB.frequently_nhds_mem /-\ntheorem IsLUB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) :\n    ∃ᶠ x in 𝓝 a, x ∈ s :=\n  (ha.frequently_mem hs).filter_mono inf_le_left\n#align is_lub.frequently_nhds_mem IsLUB.frequently_nhds_mem\n-/\n\n#print IsGLB.frequently_mem /-\ntheorem IsGLB.frequently_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) :\n    ∃ᶠ x in 𝓝[≥] a, x ∈ s :=\n  @IsLUB.frequently_mem αᵒᵈ _ _ _ _ _ ha hs\n#align is_glb.frequently_mem IsGLB.frequently_mem\n-/\n\n#print IsGLB.frequently_nhds_mem /-\ntheorem IsGLB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) :\n    ∃ᶠ x in 𝓝 a, x ∈ s :=\n  (ha.frequently_mem hs).filter_mono inf_le_left\n#align is_glb.frequently_nhds_mem IsGLB.frequently_nhds_mem\n-/\n\n#print IsLUB.mem_closure /-\ntheorem IsLUB.mem_closure {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) : a ∈ closure s :=\n  (ha.frequently_nhds_mem hs).mem_closure\n#align is_lub.mem_closure IsLUB.mem_closure\n-/\n\n#print IsGLB.mem_closure /-\ntheorem IsGLB.mem_closure {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : a ∈ closure s :=\n  (ha.frequently_nhds_mem hs).mem_closure\n#align is_glb.mem_closure IsGLB.mem_closure\n-/\n\n#print IsLUB.nhdsWithin_neBot /-\ntheorem IsLUB.nhdsWithin_neBot {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) :\n    NeBot (𝓝[s] a) :=\n  mem_closure_iff_nhdsWithin_neBot.1 (ha.mem_closure hs)\n#align is_lub.nhds_within_ne_bot IsLUB.nhdsWithin_neBot\n-/\n\n#print IsGLB.nhdsWithin_neBot /-\ntheorem IsGLB.nhdsWithin_neBot : ∀ {a : α} {s : Set α}, IsGLB s a → s.Nonempty → NeBot (𝓝[s] a) :=\n  @IsLUB.nhdsWithin_neBot αᵒᵈ _ _ _\n#align is_glb.nhds_within_ne_bot IsGLB.nhdsWithin_neBot\n-/\n\n/- warning: is_lub_of_mem_nhds -> isLUB_of_mem_nhds is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_3 : LinearOrder.{u1} α] [_inst_5 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_3))))] {s : Set.{u1} α} {a : α} {f : Filter.{u1} α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (upperBounds.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_3)))) s)) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s f) -> (forall [_inst_7 : Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) f (nhds.{u1} α _inst_1 a))], IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_3)))) s a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_3 : LinearOrder.{u1} α] [_inst_5 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_3)))))] {s : Set.{u1} α} {a : α} {f : Filter.{u1} α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (upperBounds.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_3))))) s)) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s f) -> (forall [_inst_7 : Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) f (nhds.{u1} α _inst_1 a))], IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_3))))) s a)\nCase conversion may be inaccurate. Consider using '#align is_lub_of_mem_nhds isLUB_of_mem_nhdsₓ'. -/\ntheorem isLUB_of_mem_nhds {s : Set α} {a : α} {f : Filter α} (hsa : a ∈ upperBounds s) (hsf : s ∈ f)\n    [NeBot (f ⊓ 𝓝 a)] : IsLUB s a :=\n  ⟨hsa, fun b hb =>\n    not_lt.1 fun hba =>\n      have : s ∩ { a | b < a } ∈ f ⊓ 𝓝 a := inter_mem_inf hsf (IsOpen.mem_nhds (isOpen_lt' _) hba)\n      let ⟨x, ⟨hxs, hxb⟩⟩ := Filter.nonempty_of_mem this\n      have : b < b := lt_of_lt_of_le hxb <| hb hxs\n      lt_irrefl b this⟩\n#align is_lub_of_mem_nhds isLUB_of_mem_nhds\n\n#print isLUB_of_mem_closure /-\ntheorem isLUB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ upperBounds s) (hsf : a ∈ closure s) :\n    IsLUB s a := by\n  rw [mem_closure_iff_clusterPt, ClusterPt, inf_comm] at hsf\n  haveI : (𝓟 s ⊓ 𝓝 a).ne_bot := hsf\n  exact isLUB_of_mem_nhds hsa (mem_principal_self s)\n#align is_lub_of_mem_closure isLUB_of_mem_closure\n-/\n\n/- warning: is_glb_of_mem_nhds -> isGLB_of_mem_nhds is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_3 : LinearOrder.{u1} α] [_inst_5 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_3))))] {s : Set.{u1} α} {a : α} {f : Filter.{u1} α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (lowerBounds.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_3)))) s)) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s f) -> (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) f (nhds.{u1} α _inst_1 a))) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_3)))) s a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_3 : LinearOrder.{u1} α] [_inst_5 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_3)))))] {s : Set.{u1} α} {a : α} {f : Filter.{u1} α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (lowerBounds.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_3))))) s)) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s f) -> (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) f (nhds.{u1} α _inst_1 a))) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_3))))) s a)\nCase conversion may be inaccurate. Consider using '#align is_glb_of_mem_nhds isGLB_of_mem_nhdsₓ'. -/\ntheorem isGLB_of_mem_nhds :\n    ∀ {s : Set α} {a : α} {f : Filter α}, a ∈ lowerBounds s → s ∈ f → NeBot (f ⊓ 𝓝 a) → IsGLB s a :=\n  @isLUB_of_mem_nhds αᵒᵈ _ _ _\n#align is_glb_of_mem_nhds isGLB_of_mem_nhds\n\n#print isGLB_of_mem_closure /-\ntheorem isGLB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ lowerBounds s) (hsf : a ∈ closure s) :\n    IsGLB s a :=\n  @isLUB_of_mem_closure αᵒᵈ _ _ _ s a hsa hsf\n#align is_glb_of_mem_closure isGLB_of_mem_closure\n-/\n\n#print IsLUB.mem_upperBounds_of_tendsto /-\ntheorem IsLUB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]\n    {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsLUB s a)\n    (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) :=\n  by\n  rintro _ ⟨x, hx, rfl⟩\n  replace ha := ha.inter_Ici_of_mem hx\n  haveI := ha.nhds_within_ne_bot ⟨x, hx, le_rfl⟩\n  refine' ge_of_tendsto (hb.mono_left (nhdsWithin_mono _ (inter_subset_left s (Ici x)))) _\n  exact mem_of_superset self_mem_nhdsWithin fun y hy => hf hx hy.1 hy.2\n#align is_lub.mem_upper_bounds_of_tendsto IsLUB.mem_upperBounds_of_tendsto\n-/\n\n#print IsLUB.isLUB_of_tendsto /-\n-- For a version of this theorem in which the convergence considered on the domain `α` is as `x : α`\n-- tends to infinity, rather than tending to a point `x` in `α`, see `is_lub_of_tendsto_at_top`\ntheorem IsLUB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ}\n    {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsLUB s a) (hs : s.Nonempty)\n    (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : IsLUB (f '' s) b :=\n  haveI := ha.nhds_within_ne_bot hs\n  ⟨ha.mem_upper_bounds_of_tendsto hf hb, fun b' hb' =>\n    le_of_tendsto hb (mem_of_superset self_mem_nhdsWithin fun x hx => hb' <| mem_image_of_mem _ hx)⟩\n#align is_lub.is_lub_of_tendsto IsLUB.isLUB_of_tendsto\n-/\n\n#print IsGLB.mem_lowerBounds_of_tendsto /-\ntheorem IsGLB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]\n    {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsGLB s a)\n    (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) :=\n  @IsLUB.mem_upperBounds_of_tendsto αᵒᵈ γᵒᵈ _ _ _ _ _ _ _ _ _ _ hf.dual ha hb\n#align is_glb.mem_lower_bounds_of_tendsto IsGLB.mem_lowerBounds_of_tendsto\n-/\n\n#print IsGLB.isGLB_of_tendsto /-\n-- For a version of this theorem in which the convergence considered on the domain `α` is as\n-- `x : α` tends to negative infinity, rather than tending to a point `x` in `α`, see\n-- `is_glb_of_tendsto_at_bot`\ntheorem IsGLB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ}\n    {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) :\n    IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b :=\n  @IsLUB.isLUB_of_tendsto αᵒᵈ γᵒᵈ _ _ _ _ _ _ f s a b hf.dual\n#align is_glb.is_glb_of_tendsto IsGLB.isGLB_of_tendsto\n-/\n\n#print IsLUB.mem_lowerBounds_of_tendsto /-\ntheorem IsLUB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]\n    {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsLUB s a)\n    (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) :=\n  @IsLUB.mem_upperBounds_of_tendsto α γᵒᵈ _ _ _ _ _ _ _ _ _ _ hf ha hb\n#align is_lub.mem_lower_bounds_of_tendsto IsLUB.mem_lowerBounds_of_tendsto\n-/\n\n#print IsLUB.isGLB_of_tendsto /-\ntheorem IsLUB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] :\n    ∀ {f : α → γ} {s : Set α} {a : α} {b : γ},\n      AntitoneOn f s → IsLUB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b :=\n  @IsLUB.isLUB_of_tendsto α γᵒᵈ _ _ _ _ _ _\n#align is_lub.is_glb_of_tendsto IsLUB.isGLB_of_tendsto\n-/\n\n#print IsGLB.mem_upperBounds_of_tendsto /-\ntheorem IsGLB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ]\n    {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsGLB s a)\n    (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) :=\n  @IsGLB.mem_lowerBounds_of_tendsto α γᵒᵈ _ _ _ _ _ _ _ _ _ _ hf ha hb\n#align is_glb.mem_upper_bounds_of_tendsto IsGLB.mem_upperBounds_of_tendsto\n-/\n\n#print IsGLB.isLUB_of_tendsto /-\ntheorem IsGLB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] :\n    ∀ {f : α → γ} {s : Set α} {a : α} {b : γ},\n      AntitoneOn f s → IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsLUB (f '' s) b :=\n  @IsGLB.isGLB_of_tendsto α γᵒᵈ _ _ _ _ _ _\n#align is_glb.is_lub_of_tendsto IsGLB.isLUB_of_tendsto\n-/\n\n#print IsLUB.mem_of_isClosed /-\ntheorem IsLUB.mem_of_isClosed {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty)\n    (sc : IsClosed s) : a ∈ s :=\n  sc.closure_subset <| ha.mem_closure hs\n#align is_lub.mem_of_is_closed IsLUB.mem_of_isClosed\n-/\n\nalias IsLUB.mem_of_isClosed ← IsClosed.isLUB_mem\n#align is_closed.is_lub_mem IsClosed.isLUB_mem\n\n#print IsGLB.mem_of_isClosed /-\ntheorem IsGLB.mem_of_isClosed {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty)\n    (sc : IsClosed s) : a ∈ s :=\n  sc.closure_subset <| ha.mem_closure hs\n#align is_glb.mem_of_is_closed IsGLB.mem_of_isClosed\n-/\n\nalias IsGLB.mem_of_isClosed ← IsClosed.isGLB_mem\n#align is_closed.is_glb_mem IsClosed.isGLB_mem\n\n/-!\n### Existence of sequences tending to Inf or Sup of a given set\n-/\n\n\n#print IsLUB.exists_seq_strictMono_tendsto_of_not_mem /-\ntheorem IsLUB.exists_seq_strictMono_tendsto_of_not_mem {t : Set α} {x : α}\n    [IsCountablyGenerated (𝓝 x)] (htx : IsLUB t x) (not_mem : x ∉ t) (ht : t.Nonempty) :\n    ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t :=\n  by\n  rcases ht with ⟨l, hl⟩\n  have hl : l < x := (htx.1 hl).eq_or_lt.resolve_left fun h => (not_mem <| h ▸ hl).elim\n  obtain ⟨s, hs⟩ : ∃ s : ℕ → Set α, (𝓝 x).HasBasis (fun _x : ℕ => True) s :=\n    let ⟨s, hs⟩ := (𝓝 x).exists_antitone_basis\n    ⟨s, hs.to_hasBasis⟩\n  have : ∀ n k, k < x → ∃ y, Icc y x ⊆ s n ∧ k < y ∧ y < x ∧ y ∈ t :=\n    by\n    intro n k hk\n    obtain ⟨L, hL, h⟩ : ∃ (L : α)(hL : L ∈ Ico k x), Ioc L x ⊆ s n :=\n      exists_Ioc_subset_of_mem_nhds' (hs.mem_of_mem trivial) hk\n    obtain ⟨y, hy⟩ : ∃ y : α, L < y ∧ y < x ∧ y ∈ t :=\n      by\n      rcases htx.exists_between' not_mem hL.2 with ⟨y, yt, hy⟩\n      refine' ⟨y, hy.1, hy.2, yt⟩\n    exact ⟨y, fun z hz => h ⟨hy.1.trans_le hz.1, hz.2⟩, hL.1.trans_lt hy.1, hy.2⟩\n  choose! f hf using this\n  let u : ℕ → α := fun n => Nat.recOn n (f 0 l) fun n h => f n.succ h\n  have I : ∀ n, u n < x := by\n    intro n\n    induction' n with n IH\n    · exact (hf 0 l hl).2.2.1\n    · exact (hf n.succ _ IH).2.2.1\n  have S : StrictMono u := strictMono_nat_of_lt_succ fun n => (hf n.succ _ (I n)).2.1\n  refine' ⟨u, S, I, hs.tendsto_right_iff.2 fun n _ => _, fun n => _⟩\n  · simp only [ge_iff_le, eventually_at_top]\n    refine' ⟨n, fun p hp => _⟩\n    have up : u p ∈ Icc (u n) x := ⟨S.monotone hp, (I p).le⟩\n    have : Icc (u n) x ⊆ s n := by\n      cases n\n      · exact (hf 0 l hl).1\n      · exact (hf n.succ (u n) (I n)).1\n    exact this up\n  · cases n\n    · exact (hf 0 l hl).2.2.2\n    · exact (hf n.succ _ (I n)).2.2.2\n#align is_lub.exists_seq_strict_mono_tendsto_of_not_mem IsLUB.exists_seq_strictMono_tendsto_of_not_mem\n-/\n\n#print IsLUB.exists_seq_monotone_tendsto /-\ntheorem IsLUB.exists_seq_monotone_tendsto {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)]\n    (htx : IsLUB t x) (ht : t.Nonempty) :\n    ∃ u : ℕ → α, Monotone u ∧ (∀ n, u n ≤ x) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t :=\n  by\n  by_cases h : x ∈ t\n  · exact ⟨fun n => x, monotone_const, fun n => le_rfl, tendsto_const_nhds, fun n => h⟩\n  · rcases htx.exists_seq_strict_mono_tendsto_of_not_mem h ht with ⟨u, hu⟩\n    exact ⟨u, hu.1.Monotone, fun n => (hu.2.1 n).le, hu.2.2⟩\n#align is_lub.exists_seq_monotone_tendsto IsLUB.exists_seq_monotone_tendsto\n-/\n\n#print exists_seq_strictMono_tendsto' /-\ntheorem exists_seq_strictMono_tendsto' {α : Type _} [LinearOrder α] [TopologicalSpace α]\n    [DenselyOrdered α] [OrderTopology α] [FirstCountableTopology α] {x y : α} (hy : y < x) :\n    ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n ∈ Ioo y x) ∧ Tendsto u atTop (𝓝 x) :=\n  by\n  have hx : x ∉ Ioo y x := fun h => (lt_irrefl x h.2).elim\n  have ht : Set.Nonempty (Ioo y x) := nonempty_Ioo.2 hy\n  rcases(isLUB_Ioo hy).exists_seq_strictMono_tendsto_of_not_mem hx ht with ⟨u, hu⟩\n  exact ⟨u, hu.1, hu.2.2.symm⟩\n#align exists_seq_strict_mono_tendsto' exists_seq_strictMono_tendsto'\n-/\n\n#print exists_seq_strictMono_tendsto /-\ntheorem exists_seq_strictMono_tendsto [DenselyOrdered α] [NoMinOrder α] [FirstCountableTopology α]\n    (x : α) : ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝 x) :=\n  by\n  obtain ⟨y, hy⟩ : ∃ y, y < x := exists_lt x\n  rcases exists_seq_strictMono_tendsto' hy with ⟨u, hu_mono, hu_mem, hux⟩\n  exact ⟨u, hu_mono, fun n => (hu_mem n).2, hux⟩\n#align exists_seq_strict_mono_tendsto exists_seq_strictMono_tendsto\n-/\n\n#print exists_seq_strictMono_tendsto_nhdsWithin /-\ntheorem exists_seq_strictMono_tendsto_nhdsWithin [DenselyOrdered α] [NoMinOrder α]\n    [FirstCountableTopology α] (x : α) :\n    ∃ u : ℕ → α, StrictMono u ∧ (∀ n, u n < x) ∧ Tendsto u atTop (𝓝[<] x) :=\n  let ⟨u, hu, hx, h⟩ := exists_seq_strictMono_tendsto x\n  ⟨u, hu, hx, tendsto_nhdsWithin_mono_right (range_subset_iff.2 hx) <| tendsto_nhdsWithin_range.2 h⟩\n#align exists_seq_strict_mono_tendsto_nhds_within exists_seq_strictMono_tendsto_nhdsWithin\n-/\n\n/- warning: exists_seq_tendsto_Sup -> exists_seq_tendsto_supₛ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} α _inst_8] {S : Set.{u1} α}, (Set.Nonempty.{u1} α S) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) S) -> (Exists.{succ u1} (Nat -> α) (fun (u : Nat -> α) => And (Monotone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat α u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{u1} α _inst_8 (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)) S))) (forall (n : Nat), Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (u n) S))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} α _inst_8] {S : Set.{u1} α}, (Set.Nonempty.{u1} α S) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) S) -> (Exists.{succ u1} (Nat -> α) (fun (u : Nat -> α) => And (Monotone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat α u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{u1} α _inst_8 (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)) S))) (forall (n : Nat), Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (u n) S))))\nCase conversion may be inaccurate. Consider using '#align exists_seq_tendsto_Sup exists_seq_tendsto_supₛₓ'. -/\ntheorem exists_seq_tendsto_supₛ {α : Type _} [ConditionallyCompleteLinearOrder α]\n    [TopologicalSpace α] [OrderTopology α] [FirstCountableTopology α] {S : Set α} (hS : S.Nonempty)\n    (hS' : BddAbove S) : ∃ u : ℕ → α, Monotone u ∧ Tendsto u atTop (𝓝 (supₛ S)) ∧ ∀ n, u n ∈ S :=\n  by\n  rcases(isLUB_csupₛ hS hS').exists_seq_monotone_tendsto hS with ⟨u, hu⟩\n  exact ⟨u, hu.1, hu.2.2⟩\n#align exists_seq_tendsto_Sup exists_seq_tendsto_supₛ\n\n#print IsGLB.exists_seq_strictAnti_tendsto_of_not_mem /-\ntheorem IsGLB.exists_seq_strictAnti_tendsto_of_not_mem {t : Set α} {x : α}\n    [IsCountablyGenerated (𝓝 x)] (htx : IsGLB t x) (not_mem : x ∉ t) (ht : t.Nonempty) :\n    ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t :=\n  @IsLUB.exists_seq_strictMono_tendsto_of_not_mem αᵒᵈ _ _ _ t x _ htx not_mem ht\n#align is_glb.exists_seq_strict_anti_tendsto_of_not_mem IsGLB.exists_seq_strictAnti_tendsto_of_not_mem\n-/\n\n#print IsGLB.exists_seq_antitone_tendsto /-\ntheorem IsGLB.exists_seq_antitone_tendsto {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)]\n    (htx : IsGLB t x) (ht : t.Nonempty) :\n    ∃ u : ℕ → α, Antitone u ∧ (∀ n, x ≤ u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t :=\n  @IsLUB.exists_seq_monotone_tendsto αᵒᵈ _ _ _ t x _ htx ht\n#align is_glb.exists_seq_antitone_tendsto IsGLB.exists_seq_antitone_tendsto\n-/\n\n#print exists_seq_strictAnti_tendsto' /-\ntheorem exists_seq_strictAnti_tendsto' [DenselyOrdered α] [FirstCountableTopology α] {x y : α}\n    (hy : x < y) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, u n ∈ Ioo x y) ∧ Tendsto u atTop (𝓝 x) := by\n  simpa only [dual_Ioo] using exists_seq_strictMono_tendsto' (OrderDual.toDual_lt_toDual.2 hy)\n#align exists_seq_strict_anti_tendsto' exists_seq_strictAnti_tendsto'\n-/\n\n#print exists_seq_strictAnti_tendsto /-\ntheorem exists_seq_strictAnti_tendsto [DenselyOrdered α] [NoMaxOrder α] [FirstCountableTopology α]\n    (x : α) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) :=\n  @exists_seq_strictMono_tendsto αᵒᵈ _ _ _ _ _ _ x\n#align exists_seq_strict_anti_tendsto exists_seq_strictAnti_tendsto\n-/\n\n#print exists_seq_strictAnti_tendsto_nhdsWithin /-\ntheorem exists_seq_strictAnti_tendsto_nhdsWithin [DenselyOrdered α] [NoMaxOrder α]\n    [FirstCountableTopology α] (x : α) :\n    ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝[>] x) :=\n  @exists_seq_strictMono_tendsto_nhdsWithin αᵒᵈ _ _ _ _ _ _ _\n#align exists_seq_strict_anti_tendsto_nhds_within exists_seq_strictAnti_tendsto_nhdsWithin\n-/\n\n#print exists_seq_strictAnti_strictMono_tendsto /-\ntheorem exists_seq_strictAnti_strictMono_tendsto [DenselyOrdered α] [FirstCountableTopology α]\n    {x y : α} (h : x < y) :\n    ∃ u v : ℕ → α,\n      StrictAnti u ∧\n        StrictMono v ∧\n          (∀ k, u k ∈ Ioo x y) ∧\n            (∀ l, v l ∈ Ioo x y) ∧\n              (∀ k l, u k < v l) ∧ Tendsto u atTop (𝓝 x) ∧ Tendsto v atTop (𝓝 y) :=\n  by\n  rcases exists_seq_strictAnti_tendsto' h with ⟨u, hu_anti, hu_mem, hux⟩\n  rcases exists_seq_strictMono_tendsto' (hu_mem 0).2 with ⟨v, hv_mono, hv_mem, hvy⟩\n  exact\n    ⟨u, v, hu_anti, hv_mono, hu_mem, fun l => ⟨(hu_mem 0).1.trans (hv_mem l).1, (hv_mem l).2⟩,\n      fun k l => (hu_anti.antitone (zero_le k)).trans_lt (hv_mem l).1, hux, hvy⟩\n#align exists_seq_strict_anti_strict_mono_tendsto exists_seq_strictAnti_strictMono_tendsto\n-/\n\n/- warning: exists_seq_tendsto_Inf -> exists_seq_tendsto_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} α _inst_8] {S : Set.{u1} α}, (Set.Nonempty.{u1} α S) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) S) -> (Exists.{succ u1} (Nat -> α) (fun (u : Nat -> α) => And (Antitone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat α u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{u1} α _inst_8 (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)) S))) (forall (n : Nat), Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (u n) S))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} α _inst_8] {S : Set.{u1} α}, (Set.Nonempty.{u1} α S) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) S) -> (Exists.{succ u1} (Nat -> α) (fun (u : Nat -> α) => And (Antitone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat α u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{u1} α _inst_8 (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_7)) S))) (forall (n : Nat), Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (u n) S))))\nCase conversion may be inaccurate. Consider using '#align exists_seq_tendsto_Inf exists_seq_tendsto_infₛₓ'. -/\ntheorem exists_seq_tendsto_infₛ {α : Type _} [ConditionallyCompleteLinearOrder α]\n    [TopologicalSpace α] [OrderTopology α] [FirstCountableTopology α] {S : Set α} (hS : S.Nonempty)\n    (hS' : BddBelow S) : ∃ u : ℕ → α, Antitone u ∧ Tendsto u atTop (𝓝 (infₛ S)) ∧ ∀ n, u n ∈ S :=\n  @exists_seq_tendsto_supₛ αᵒᵈ _ _ _ _ S hS hS'\n#align exists_seq_tendsto_Inf exists_seq_tendsto_infₛ\n\nend OrderTopology\n\nsection DenselyOrdered\n\nvariable [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [DenselyOrdered α] {a b : α}\n  {s : Set α}\n\n#print closure_Ioi' /-\n/-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`, unless `a` is a top\nelement. -/\ntheorem closure_Ioi' {a : α} (h : (Ioi a).Nonempty) : closure (Ioi a) = Ici a :=\n  by\n  apply subset.antisymm\n  · exact closure_minimal Ioi_subset_Ici_self isClosed_Ici\n  · rw [← diff_subset_closure_iff, Ici_diff_Ioi_same, singleton_subset_iff]\n    exact is_glb_Ioi.mem_closure h\n#align closure_Ioi' closure_Ioi'\n-/\n\n#print closure_Ioi /-\n/-- The closure of the interval `(a, +∞)` is the closed interval `[a, +∞)`. -/\n@[simp]\ntheorem closure_Ioi (a : α) [NoMaxOrder α] : closure (Ioi a) = Ici a :=\n  closure_Ioi' nonempty_Ioi\n#align closure_Ioi closure_Ioi\n-/\n\n#print closure_Iio' /-\n/-- The closure of the interval `(-∞, a)` is the closed interval `(-∞, a]`, unless `a` is a bottom\nelement. -/\ntheorem closure_Iio' (h : (Iio a).Nonempty) : closure (Iio a) = Iic a :=\n  @closure_Ioi' αᵒᵈ _ _ _ _ _ h\n#align closure_Iio' closure_Iio'\n-/\n\n#print closure_Iio /-\n/-- The closure of the interval `(-∞, a)` is the interval `(-∞, a]`. -/\n@[simp]\ntheorem closure_Iio (a : α) [NoMinOrder α] : closure (Iio a) = Iic a :=\n  closure_Iio' nonempty_Iio\n#align closure_Iio closure_Iio\n-/\n\n#print closure_Ioo /-\n/-- The closure of the open interval `(a, b)` is the closed interval `[a, b]`. -/\n@[simp]\ntheorem closure_Ioo {a b : α} (hab : a ≠ b) : closure (Ioo a b) = Icc a b :=\n  by\n  apply subset.antisymm\n  · exact closure_minimal Ioo_subset_Icc_self isClosed_Icc\n  · cases' hab.lt_or_lt with hab hab\n    · rw [← diff_subset_closure_iff, Icc_diff_Ioo_same hab.le]\n      have hab' : (Ioo a b).Nonempty := nonempty_Ioo.2 hab\n      simp only [insert_subset, singleton_subset_iff]\n      exact ⟨(isGLB_Ioo hab).mem_closure hab', (isLUB_Ioo hab).mem_closure hab'⟩\n    · rw [Icc_eq_empty_of_lt hab]\n      exact empty_subset _\n#align closure_Ioo closure_Ioo\n-/\n\n#print closure_Ioc /-\n/-- The closure of the interval `(a, b]` is the closed interval `[a, b]`. -/\n@[simp]\ntheorem closure_Ioc {a b : α} (hab : a ≠ b) : closure (Ioc a b) = Icc a b :=\n  by\n  apply subset.antisymm\n  · exact closure_minimal Ioc_subset_Icc_self isClosed_Icc\n  · apply subset.trans _ (closure_mono Ioo_subset_Ioc_self)\n    rw [closure_Ioo hab]\n#align closure_Ioc closure_Ioc\n-/\n\n#print closure_Ico /-\n/-- The closure of the interval `[a, b)` is the closed interval `[a, b]`. -/\n@[simp]\ntheorem closure_Ico {a b : α} (hab : a ≠ b) : closure (Ico a b) = Icc a b :=\n  by\n  apply subset.antisymm\n  · exact closure_minimal Ico_subset_Icc_self isClosed_Icc\n  · apply subset.trans _ (closure_mono Ioo_subset_Ico_self)\n    rw [closure_Ioo hab]\n#align closure_Ico closure_Ico\n-/\n\n#print interior_Ici' /-\n@[simp]\ntheorem interior_Ici' {a : α} (ha : (Iio a).Nonempty) : interior (Ici a) = Ioi a := by\n  rw [← compl_Iio, interior_compl, closure_Iio' ha, compl_Iic]\n#align interior_Ici' interior_Ici'\n-/\n\n#print interior_Ici /-\ntheorem interior_Ici [NoMinOrder α] {a : α} : interior (Ici a) = Ioi a :=\n  interior_Ici' nonempty_Iio\n#align interior_Ici interior_Ici\n-/\n\n#print interior_Iic' /-\n@[simp]\ntheorem interior_Iic' {a : α} (ha : (Ioi a).Nonempty) : interior (Iic a) = Iio a :=\n  @interior_Ici' αᵒᵈ _ _ _ _ _ ha\n#align interior_Iic' interior_Iic'\n-/\n\n#print interior_Iic /-\ntheorem interior_Iic [NoMaxOrder α] {a : α} : interior (Iic a) = Iio a :=\n  interior_Iic' nonempty_Ioi\n#align interior_Iic interior_Iic\n-/\n\n#print interior_Icc /-\n@[simp]\ntheorem interior_Icc [NoMinOrder α] [NoMaxOrder α] {a b : α} : interior (Icc a b) = Ioo a b := by\n  rw [← Ici_inter_Iic, interior_inter, interior_Ici, interior_Iic, Ioi_inter_Iio]\n#align interior_Icc interior_Icc\n-/\n\n#print interior_Ico /-\n@[simp]\ntheorem interior_Ico [NoMinOrder α] {a b : α} : interior (Ico a b) = Ioo a b := by\n  rw [← Ici_inter_Iio, interior_inter, interior_Ici, interior_Iio, Ioi_inter_Iio]\n#align interior_Ico interior_Ico\n-/\n\n#print interior_Ioc /-\n@[simp]\ntheorem interior_Ioc [NoMaxOrder α] {a b : α} : interior (Ioc a b) = Ioo a b := by\n  rw [← Ioi_inter_Iic, interior_inter, interior_Ioi, interior_Iic, Ioi_inter_Iio]\n#align interior_Ioc interior_Ioc\n-/\n\n#print closure_interior_Icc /-\ntheorem closure_interior_Icc {a b : α} (h : a ≠ b) : closure (interior (Icc a b)) = Icc a b :=\n  (closure_minimal interior_subset isClosed_Icc).antisymm <|\n    calc\n      Icc a b = closure (Ioo a b) := (closure_Ioo h).symm\n      _ ⊆ closure (interior (Icc a b)) :=\n        closure_mono (interior_maximal Ioo_subset_Icc_self isOpen_Ioo)\n      \n#align closure_interior_Icc closure_interior_Icc\n-/\n\n#print Ioc_subset_closure_interior /-\ntheorem Ioc_subset_closure_interior (a b : α) : Ioc a b ⊆ closure (interior (Ioc a b)) :=\n  by\n  rcases eq_or_ne a b with (rfl | h)\n  · simp\n  ·\n    calc\n      Ioc a b ⊆ Icc a b := Ioc_subset_Icc_self\n      _ = closure (Ioo a b) := (closure_Ioo h).symm\n      _ ⊆ closure (interior (Ioc a b)) :=\n        closure_mono (interior_maximal Ioo_subset_Ioc_self isOpen_Ioo)\n      \n#align Ioc_subset_closure_interior Ioc_subset_closure_interior\n-/\n\n#print Ico_subset_closure_interior /-\ntheorem Ico_subset_closure_interior (a b : α) : Ico a b ⊆ closure (interior (Ico a b)) := by\n  simpa only [dual_Ioc] using Ioc_subset_closure_interior (OrderDual.toDual b) (OrderDual.toDual a)\n#align Ico_subset_closure_interior Ico_subset_closure_interior\n-/\n\n#print frontier_Ici' /-\n@[simp]\ntheorem frontier_Ici' {a : α} (ha : (Iio a).Nonempty) : frontier (Ici a) = {a} := by\n  simp [frontier, ha]\n#align frontier_Ici' frontier_Ici'\n-/\n\n#print frontier_Ici /-\ntheorem frontier_Ici [NoMinOrder α] {a : α} : frontier (Ici a) = {a} :=\n  frontier_Ici' nonempty_Iio\n#align frontier_Ici frontier_Ici\n-/\n\n#print frontier_Iic' /-\n@[simp]\ntheorem frontier_Iic' {a : α} (ha : (Ioi a).Nonempty) : frontier (Iic a) = {a} := by\n  simp [frontier, ha]\n#align frontier_Iic' frontier_Iic'\n-/\n\n#print frontier_Iic /-\ntheorem frontier_Iic [NoMaxOrder α] {a : α} : frontier (Iic a) = {a} :=\n  frontier_Iic' nonempty_Ioi\n#align frontier_Iic frontier_Iic\n-/\n\n#print frontier_Ioi' /-\n@[simp]\ntheorem frontier_Ioi' {a : α} (ha : (Ioi a).Nonempty) : frontier (Ioi a) = {a} := by\n  simp [frontier, closure_Ioi' ha, Iic_diff_Iio, Icc_self]\n#align frontier_Ioi' frontier_Ioi'\n-/\n\n#print frontier_Ioi /-\ntheorem frontier_Ioi [NoMaxOrder α] {a : α} : frontier (Ioi a) = {a} :=\n  frontier_Ioi' nonempty_Ioi\n#align frontier_Ioi frontier_Ioi\n-/\n\n#print frontier_Iio' /-\n@[simp]\ntheorem frontier_Iio' {a : α} (ha : (Iio a).Nonempty) : frontier (Iio a) = {a} := by\n  simp [frontier, closure_Iio' ha, Iic_diff_Iio, Icc_self]\n#align frontier_Iio' frontier_Iio'\n-/\n\n#print frontier_Iio /-\ntheorem frontier_Iio [NoMinOrder α] {a : α} : frontier (Iio a) = {a} :=\n  frontier_Iio' nonempty_Iio\n#align frontier_Iio frontier_Iio\n-/\n\n#print frontier_Icc /-\n@[simp]\ntheorem frontier_Icc [NoMinOrder α] [NoMaxOrder α] {a b : α} (h : a ≤ b) :\n    frontier (Icc a b) = {a, b} := by simp [frontier, h, Icc_diff_Ioo_same]\n#align frontier_Icc frontier_Icc\n-/\n\n#print frontier_Ioo /-\n@[simp]\ntheorem frontier_Ioo {a b : α} (h : a < b) : frontier (Ioo a b) = {a, b} := by\n  rw [frontier, closure_Ioo h.ne, interior_Ioo, Icc_diff_Ioo_same h.le]\n#align frontier_Ioo frontier_Ioo\n-/\n\n#print frontier_Ico /-\n@[simp]\ntheorem frontier_Ico [NoMinOrder α] {a b : α} (h : a < b) : frontier (Ico a b) = {a, b} := by\n  rw [frontier, closure_Ico h.ne, interior_Ico, Icc_diff_Ioo_same h.le]\n#align frontier_Ico frontier_Ico\n-/\n\n#print frontier_Ioc /-\n@[simp]\ntheorem frontier_Ioc [NoMaxOrder α] {a b : α} (h : a < b) : frontier (Ioc a b) = {a, b} := by\n  rw [frontier, closure_Ioc h.ne, interior_Ioc, Icc_diff_Ioo_same h.le]\n#align frontier_Ioc frontier_Ioc\n-/\n\n#print nhdsWithin_Ioi_neBot' /-\ntheorem nhdsWithin_Ioi_neBot' {a b : α} (H₁ : (Ioi a).Nonempty) (H₂ : a ≤ b) : NeBot (𝓝[Ioi a] b) :=\n  mem_closure_iff_nhdsWithin_neBot.1 <| by rwa [closure_Ioi' H₁]\n#align nhds_within_Ioi_ne_bot' nhdsWithin_Ioi_neBot'\n-/\n\n#print nhdsWithin_Ioi_neBot /-\ntheorem nhdsWithin_Ioi_neBot [NoMaxOrder α] {a b : α} (H : a ≤ b) : NeBot (𝓝[Ioi a] b) :=\n  nhdsWithin_Ioi_neBot' nonempty_Ioi H\n#align nhds_within_Ioi_ne_bot nhdsWithin_Ioi_neBot\n-/\n\n#print nhdsWithin_Ioi_self_neBot' /-\ntheorem nhdsWithin_Ioi_self_neBot' {a : α} (H : (Ioi a).Nonempty) : NeBot (𝓝[>] a) :=\n  nhdsWithin_Ioi_neBot' H (le_refl a)\n#align nhds_within_Ioi_self_ne_bot' nhdsWithin_Ioi_self_neBot'\n-/\n\n#print nhdsWithin_Ioi_self_neBot /-\n@[instance]\ntheorem nhdsWithin_Ioi_self_neBot [NoMaxOrder α] (a : α) : NeBot (𝓝[>] a) :=\n  nhdsWithin_Ioi_neBot (le_refl a)\n#align nhds_within_Ioi_self_ne_bot nhdsWithin_Ioi_self_neBot\n-/\n\n/- warning: filter.eventually.exists_gt -> Filter.Eventually.exists_gt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_5 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {p : α -> Prop}, (Filter.Eventually.{u1} α (fun (x : α) => p x) (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) => p b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_5 : NoMaxOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {p : α -> Prop}, (Filter.Eventually.{u1} α (fun (x : α) => p x) (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (b : α) => And (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) b a) (p b)))\nCase conversion may be inaccurate. Consider using '#align filter.eventually.exists_gt Filter.Eventually.exists_gtₓ'. -/\ntheorem Filter.Eventually.exists_gt [NoMaxOrder α] {a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) :\n    ∃ b > a, p b := by\n  simpa only [exists_prop, gt_iff_lt, and_comm'] using\n    ((h.filter_mono (@nhdsWithin_le_nhds _ _ a (Ioi a))).And self_mem_nhdsWithin).exists\n#align filter.eventually.exists_gt Filter.Eventually.exists_gt\n\n#print nhdsWithin_Iio_neBot' /-\ntheorem nhdsWithin_Iio_neBot' {b c : α} (H₁ : (Iio c).Nonempty) (H₂ : b ≤ c) : NeBot (𝓝[Iio c] b) :=\n  mem_closure_iff_nhdsWithin_neBot.1 <| by rwa [closure_Iio' H₁]\n#align nhds_within_Iio_ne_bot' nhdsWithin_Iio_neBot'\n-/\n\n#print nhdsWithin_Iio_neBot /-\ntheorem nhdsWithin_Iio_neBot [NoMinOrder α] {a b : α} (H : a ≤ b) : NeBot (𝓝[Iio b] a) :=\n  nhdsWithin_Iio_neBot' nonempty_Iio H\n#align nhds_within_Iio_ne_bot nhdsWithin_Iio_neBot\n-/\n\n#print nhdsWithin_Iio_self_neBot' /-\ntheorem nhdsWithin_Iio_self_neBot' {b : α} (H : (Iio b).Nonempty) : NeBot (𝓝[<] b) :=\n  nhdsWithin_Iio_neBot' H (le_refl b)\n#align nhds_within_Iio_self_ne_bot' nhdsWithin_Iio_self_neBot'\n-/\n\n#print nhdsWithin_Iio_self_neBot /-\n@[instance]\ntheorem nhdsWithin_Iio_self_neBot [NoMinOrder α] (a : α) : NeBot (𝓝[<] a) :=\n  nhdsWithin_Iio_neBot (le_refl a)\n#align nhds_within_Iio_self_ne_bot nhdsWithin_Iio_self_neBot\n-/\n\n/- warning: filter.eventually.exists_lt -> Filter.Eventually.exists_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_5 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {p : α -> Prop}, (Filter.Eventually.{u1} α (fun (x : α) => p x) (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) => p b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_5 : NoMinOrder.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {p : α -> Prop}, (Filter.Eventually.{u1} α (fun (x : α) => p x) (nhds.{u1} α _inst_1 a)) -> (Exists.{succ u1} α (fun (b : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) b a) (p b)))\nCase conversion may be inaccurate. Consider using '#align filter.eventually.exists_lt Filter.Eventually.exists_ltₓ'. -/\ntheorem Filter.Eventually.exists_lt [NoMinOrder α] {a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) :\n    ∃ b < a, p b :=\n  @Filter.Eventually.exists_gt αᵒᵈ _ _ _ _ _ _ _ h\n#align filter.eventually.exists_lt Filter.Eventually.exists_lt\n\n#print right_nhdsWithin_Ico_neBot /-\ntheorem right_nhdsWithin_Ico_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ico a b] b) :=\n  (isLUB_Ico H).nhdsWithin_neBot (nonempty_Ico.2 H)\n#align right_nhds_within_Ico_ne_bot right_nhdsWithin_Ico_neBot\n-/\n\n#print left_nhdsWithin_Ioc_neBot /-\ntheorem left_nhdsWithin_Ioc_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ioc a b] a) :=\n  (isGLB_Ioc H).nhdsWithin_neBot (nonempty_Ioc.2 H)\n#align left_nhds_within_Ioc_ne_bot left_nhdsWithin_Ioc_neBot\n-/\n\n#print left_nhdsWithin_Ioo_neBot /-\ntheorem left_nhdsWithin_Ioo_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ioo a b] a) :=\n  (isGLB_Ioo H).nhdsWithin_neBot (nonempty_Ioo.2 H)\n#align left_nhds_within_Ioo_ne_bot left_nhdsWithin_Ioo_neBot\n-/\n\n#print right_nhdsWithin_Ioo_neBot /-\ntheorem right_nhdsWithin_Ioo_neBot {a b : α} (H : a < b) : NeBot (𝓝[Ioo a b] b) :=\n  (isLUB_Ioo H).nhdsWithin_neBot (nonempty_Ioo.2 H)\n#align right_nhds_within_Ioo_ne_bot right_nhdsWithin_Ioo_neBot\n-/\n\n/- warning: comap_coe_nhds_within_Iio_of_Ioo_subset -> comap_coe_nhdsWithin_Iio_of_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {b : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b)) -> ((Set.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (a : α) => Exists.{0} (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (Filter.comap.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) (nhdsWithin.{u1} α _inst_1 b (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b))) (Filter.atTop.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {b : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b)) -> ((Set.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (a : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s))) (Filter.comap.{u1, u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (nhdsWithin.{u1} α _inst_1 b (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b))) (Filter.atTop.{u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s))))\nCase conversion may be inaccurate. Consider using '#align comap_coe_nhds_within_Iio_of_Ioo_subset comap_coe_nhdsWithin_Iio_of_Ioo_subsetₓ'. -/\ntheorem comap_coe_nhdsWithin_Iio_of_Ioo_subset (hb : s ⊆ Iio b)\n    (hs : s.Nonempty → ∃ a < b, Ioo a b ⊆ s) : comap (coe : s → α) (𝓝[<] b) = atTop :=\n  by\n  nontriviality\n  haveI : Nonempty s := nontrivial_iff_nonempty.1 ‹_›\n  rcases hs (nonempty_subtype.1 ‹_›) with ⟨a, h, hs⟩\n  ext u; constructor\n  · rintro ⟨t, ht, hts⟩\n    obtain ⟨x, ⟨hxa : a ≤ x, hxb : x < b⟩, hxt : Ioo x b ⊆ t⟩ :=\n      (mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset h).mp ht\n    obtain ⟨y, hxy, hyb⟩ := exists_between hxb\n    refine' mem_of_superset (mem_at_top ⟨y, hs ⟨hxa.trans_lt hxy, hyb⟩⟩) _\n    rintro ⟨z, hzs⟩ (hyz : y ≤ z)\n    refine' hts (hxt ⟨hxy.trans_le _, hb _⟩) <;> assumption\n  · intro hu\n    obtain ⟨x : s, hx : ∀ z, x ≤ z → z ∈ u⟩ := mem_at_top_sets.1 hu\n    exact ⟨Ioo x b, Ioo_mem_nhdsWithin_Iio (right_mem_Ioc.2 <| hb x.2), fun z hz => hx _ hz.1.le⟩\n#align comap_coe_nhds_within_Iio_of_Ioo_subset comap_coe_nhdsWithin_Iio_of_Ioo_subset\n\n/- warning: comap_coe_nhds_within_Ioi_of_Ioo_subset -> comap_coe_nhdsWithin_Ioi_of_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) -> ((Set.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (Filter.comap.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a))) (Filter.atBot.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) -> ((Set.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (b : α) => And (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) b a) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s))) (Filter.comap.{u1, u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a))) (Filter.atBot.{u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s))))\nCase conversion may be inaccurate. Consider using '#align comap_coe_nhds_within_Ioi_of_Ioo_subset comap_coe_nhdsWithin_Ioi_of_Ioo_subsetₓ'. -/\ntheorem comap_coe_nhdsWithin_Ioi_of_Ioo_subset (ha : s ⊆ Ioi a)\n    (hs : s.Nonempty → ∃ b > a, Ioo a b ⊆ s) : comap (coe : s → α) (𝓝[>] a) = atBot :=\n  comap_coe_nhdsWithin_Iio_of_Ioo_subset (show ofDual ⁻¹' s ⊆ Iio (toDual a) from ha) fun h => by\n    simpa only [OrderDual.exists, dual_Ioo] using hs h\n#align comap_coe_nhds_within_Ioi_of_Ioo_subset comap_coe_nhdsWithin_Ioi_of_Ioo_subset\n\n/- warning: map_coe_at_top_of_Ioo_subset -> map_coe_atTop_of_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {b : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b)) -> (forall (a' : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a' b) -> (Exists.{succ u1} α (fun (a : α) => Exists.{0} (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) (fun (H : LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) a b) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} α) (Filter.map.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) (Filter.atTop.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))) (nhdsWithin.{u1} α _inst_1 b (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {b : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b)) -> (forall (a' : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a' b) -> (Exists.{succ u1} α (fun (a : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) a b) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} α) (Filter.map.{u1, u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (Filter.atTop.{u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)))) (nhdsWithin.{u1} α _inst_1 b (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) b)))\nCase conversion may be inaccurate. Consider using '#align map_coe_at_top_of_Ioo_subset map_coe_atTop_of_Ioo_subsetₓ'. -/\ntheorem map_coe_atTop_of_Ioo_subset (hb : s ⊆ Iio b) (hs : ∀ a' < b, ∃ a < b, Ioo a b ⊆ s) :\n    map (coe : s → α) atTop = 𝓝[<] b :=\n  by\n  rcases eq_empty_or_nonempty (Iio b) with (hb' | ⟨a, ha⟩)\n  · rw [filter_eq_bot_of_is_empty at_top, Filter.map_bot, hb', nhdsWithin_empty]\n    exact ⟨fun x => hb'.subset (hb x.2)⟩\n  · rw [← comap_coe_nhdsWithin_Iio_of_Ioo_subset hb fun _ => hs a ha, map_comap_of_mem]\n    rw [Subtype.range_coe]\n    exact (mem_nhdsWithin_Iio_iff_exists_Ioo_subset' ha).2 (hs a ha)\n#align map_coe_at_top_of_Ioo_subset map_coe_atTop_of_Ioo_subset\n\n/- warning: map_coe_at_bot_of_Ioo_subset -> map_coe_atBot_of_Ioo_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] {a : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)) -> (forall (b' : α), (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b' a) -> (Exists.{succ u1} α (fun (b : α) => Exists.{0} (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) (fun (H : GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) b a) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} α) (Filter.map.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) (Filter.atBot.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))) (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] {a : α} {s : Set.{u1} α}, (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)) -> (forall (b' : α), (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) b' a) -> (Exists.{succ u1} α (fun (b : α) => And (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) b a) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} α) (Filter.map.{u1, u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (Filter.atBot.{u1} (Subtype.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)))) (nhdsWithin.{u1} α _inst_1 a (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align map_coe_at_bot_of_Ioo_subset map_coe_atBot_of_Ioo_subsetₓ'. -/\ntheorem map_coe_atBot_of_Ioo_subset (ha : s ⊆ Ioi a) (hs : ∀ b' > a, ∃ b > a, Ioo a b ⊆ s) :\n    map (coe : s → α) atBot = 𝓝[>] a :=\n  by\n  -- the elaborator gets stuck without `(... : _)`\n  refine'\n    (map_coe_atTop_of_Ioo_subset (show of_dual ⁻¹' s ⊆ Iio (to_dual a) from ha) fun b' hb' => _ : _)\n  simpa only [OrderDual.exists, dual_Ioo] using hs b' hb'\n#align map_coe_at_bot_of_Ioo_subset map_coe_atBot_of_Ioo_subset\n\n#print comap_coe_Ioo_nhdsWithin_Iio /-\n/-- The `at_top` filter for an open interval `Ioo a b` comes from the left-neighbourhoods filter at\nthe right endpoint in the ambient order. -/\ntheorem comap_coe_Ioo_nhdsWithin_Iio (a b : α) : comap (coe : Ioo a b → α) (𝓝[<] b) = atTop :=\n  comap_coe_nhdsWithin_Iio_of_Ioo_subset Ioo_subset_Iio_self fun h =>\n    ⟨a, nonempty_Ioo.1 h, Subset.refl _⟩\n#align comap_coe_Ioo_nhds_within_Iio comap_coe_Ioo_nhdsWithin_Iio\n-/\n\n#print comap_coe_Ioo_nhdsWithin_Ioi /-\n/-- The `at_bot` filter for an open interval `Ioo a b` comes from the right-neighbourhoods filter at\nthe left endpoint in the ambient order. -/\ntheorem comap_coe_Ioo_nhdsWithin_Ioi (a b : α) : comap (coe : Ioo a b → α) (𝓝[>] a) = atBot :=\n  comap_coe_nhdsWithin_Ioi_of_Ioo_subset Ioo_subset_Ioi_self fun h =>\n    ⟨b, nonempty_Ioo.1 h, Subset.refl _⟩\n#align comap_coe_Ioo_nhds_within_Ioi comap_coe_Ioo_nhdsWithin_Ioi\n-/\n\n#print comap_coe_Ioi_nhdsWithin_Ioi /-\ntheorem comap_coe_Ioi_nhdsWithin_Ioi (a : α) : comap (coe : Ioi a → α) (𝓝[>] a) = atBot :=\n  comap_coe_nhdsWithin_Ioi_of_Ioo_subset (Subset.refl _) fun ⟨x, hx⟩ => ⟨x, hx, Ioo_subset_Ioi_self⟩\n#align comap_coe_Ioi_nhds_within_Ioi comap_coe_Ioi_nhdsWithin_Ioi\n-/\n\n#print comap_coe_Iio_nhdsWithin_Iio /-\ntheorem comap_coe_Iio_nhdsWithin_Iio (a : α) : comap (coe : Iio a → α) (𝓝[<] a) = atTop :=\n  @comap_coe_Ioi_nhdsWithin_Ioi αᵒᵈ _ _ _ _ a\n#align comap_coe_Iio_nhds_within_Iio comap_coe_Iio_nhdsWithin_Iio\n-/\n\n#print map_coe_Ioo_atTop /-\n@[simp]\ntheorem map_coe_Ioo_atTop {a b : α} (h : a < b) : map (coe : Ioo a b → α) atTop = 𝓝[<] b :=\n  map_coe_atTop_of_Ioo_subset Ioo_subset_Iio_self fun _ _ => ⟨_, h, Subset.refl _⟩\n#align map_coe_Ioo_at_top map_coe_Ioo_atTop\n-/\n\n#print map_coe_Ioo_atBot /-\n@[simp]\ntheorem map_coe_Ioo_atBot {a b : α} (h : a < b) : map (coe : Ioo a b → α) atBot = 𝓝[>] a :=\n  map_coe_atBot_of_Ioo_subset Ioo_subset_Ioi_self fun _ _ => ⟨_, h, Subset.refl _⟩\n#align map_coe_Ioo_at_bot map_coe_Ioo_atBot\n-/\n\n#print map_coe_Ioi_atBot /-\n@[simp]\ntheorem map_coe_Ioi_atBot (a : α) : map (coe : Ioi a → α) atBot = 𝓝[>] a :=\n  map_coe_atBot_of_Ioo_subset (Subset.refl _) fun b hb => ⟨b, hb, Ioo_subset_Ioi_self⟩\n#align map_coe_Ioi_at_bot map_coe_Ioi_atBot\n-/\n\n#print map_coe_Iio_atTop /-\n@[simp]\ntheorem map_coe_Iio_atTop (a : α) : map (coe : Iio a → α) atTop = 𝓝[<] a :=\n  @map_coe_Ioi_atBot αᵒᵈ _ _ _ _ _\n#align map_coe_Iio_at_top map_coe_Iio_atTop\n-/\n\nvariable {l : Filter β} {f : α → β}\n\n#print tendsto_comp_coe_Ioo_atTop /-\n@[simp]\ntheorem tendsto_comp_coe_Ioo_atTop (h : a < b) :\n    Tendsto (fun x : Ioo a b => f x) atTop l ↔ Tendsto f (𝓝[<] b) l := by\n  rw [← map_coe_Ioo_atTop h, tendsto_map'_iff]\n#align tendsto_comp_coe_Ioo_at_top tendsto_comp_coe_Ioo_atTop\n-/\n\n#print tendsto_comp_coe_Ioo_atBot /-\n@[simp]\ntheorem tendsto_comp_coe_Ioo_atBot (h : a < b) :\n    Tendsto (fun x : Ioo a b => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by\n  rw [← map_coe_Ioo_atBot h, tendsto_map'_iff]\n#align tendsto_comp_coe_Ioo_at_bot tendsto_comp_coe_Ioo_atBot\n-/\n\n#print tendsto_comp_coe_Ioi_atBot /-\n@[simp]\ntheorem tendsto_comp_coe_Ioi_atBot :\n    Tendsto (fun x : Ioi a => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by\n  rw [← map_coe_Ioi_atBot, tendsto_map'_iff]\n#align tendsto_comp_coe_Ioi_at_bot tendsto_comp_coe_Ioi_atBot\n-/\n\n#print tendsto_comp_coe_Iio_atTop /-\n@[simp]\ntheorem tendsto_comp_coe_Iio_atTop :\n    Tendsto (fun x : Iio a => f x) atTop l ↔ Tendsto f (𝓝[<] a) l := by\n  rw [← map_coe_Iio_atTop, tendsto_map'_iff]\n#align tendsto_comp_coe_Iio_at_top tendsto_comp_coe_Iio_atTop\n-/\n\n#print tendsto_Ioo_atTop /-\n@[simp]\ntheorem tendsto_Ioo_atTop {f : β → Ioo a b} :\n    Tendsto f l atTop ↔ Tendsto (fun x => (f x : α)) l (𝓝[<] b) := by\n  rw [← comap_coe_Ioo_nhdsWithin_Iio, tendsto_comap_iff]\n#align tendsto_Ioo_at_top tendsto_Ioo_atTop\n-/\n\n#print tendsto_Ioo_atBot /-\n@[simp]\ntheorem tendsto_Ioo_atBot {f : β → Ioo a b} :\n    Tendsto f l atBot ↔ Tendsto (fun x => (f x : α)) l (𝓝[>] a) := by\n  rw [← comap_coe_Ioo_nhdsWithin_Ioi, tendsto_comap_iff]\n#align tendsto_Ioo_at_bot tendsto_Ioo_atBot\n-/\n\n#print tendsto_Ioi_atBot /-\n@[simp]\ntheorem tendsto_Ioi_atBot {f : β → Ioi a} :\n    Tendsto f l atBot ↔ Tendsto (fun x => (f x : α)) l (𝓝[>] a) := by\n  rw [← comap_coe_Ioi_nhdsWithin_Ioi, tendsto_comap_iff]\n#align tendsto_Ioi_at_bot tendsto_Ioi_atBot\n-/\n\n#print tendsto_Iio_atTop /-\n@[simp]\ntheorem tendsto_Iio_atTop {f : β → Iio a} :\n    Tendsto f l atTop ↔ Tendsto (fun x => (f x : α)) l (𝓝[<] a) := by\n  rw [← comap_coe_Iio_nhdsWithin_Iio, tendsto_comap_iff]\n#align tendsto_Iio_at_top tendsto_Iio_atTop\n-/\n\ninstance (x : α) [Nontrivial α] : NeBot (𝓝[≠] x) :=\n  by\n  apply forall_mem_nonempty_iff_ne_bot.1 fun s hs => _\n  obtain ⟨u, u_open, xu, us⟩ : ∃ u : Set α, IsOpen u ∧ x ∈ u ∧ u ∩ {x}ᶜ ⊆ s := mem_nhdsWithin.1 hs\n  obtain ⟨a, b, a_lt_b, hab⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ u := u_open.exists_Ioo_subset ⟨x, xu⟩\n  obtain ⟨y, hy⟩ : ∃ y, a < y ∧ y < b := exists_between a_lt_b\n  rcases ne_or_eq x y with (xy | rfl)\n  · exact ⟨y, us ⟨hab hy, xy.symm⟩⟩\n  obtain ⟨z, hz⟩ : ∃ z, a < z ∧ z < x := exists_between hy.1\n  exact ⟨z, us ⟨hab ⟨hz.1, hz.2.trans hy.2⟩, hz.2.Ne⟩⟩\n\n/- warning: dense.exists_countable_dense_subset_no_bot_top -> Dense.exists_countable_dense_subset_no_bot_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2)))))] [_inst_5 : Nontrivial.{u1} α] {s : Set.{u1} α} [_inst_6 : TopologicalSpace.SeparableSpace.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) _inst_1)], (Dense.{u1} α _inst_1 s) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) (fun (H : HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) t s) => And (Set.Countable.{u1} α t) (And (Dense.{u1} α _inst_1 t) (And (forall (x : α), (IsBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x) -> (Not (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x t))) (forall (x : α), (IsTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))) x) -> (Not (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x t))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : LinearOrder.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2))))))] [_inst_5 : Nontrivial.{u1} α] {s : Set.{u1} α} [_inst_6 : TopologicalSpace.SeparableSpace.{u1} (Set.Elem.{u1} α s) (instTopologicalSpaceSubtype.{u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) _inst_1)], (Dense.{u1} α _inst_1 s) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) t s) (And (Set.Countable.{u1} α t) (And (Dense.{u1} α _inst_1 t) (And (forall (x : α), (IsBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x) -> (Not (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x t))) (forall (x : α), (IsTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x) -> (Not (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x t))))))))\nCase conversion may be inaccurate. Consider using '#align dense.exists_countable_dense_subset_no_bot_top Dense.exists_countable_dense_subset_no_bot_topₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/\n/-- Let `s` be a dense set in a nontrivial dense linear order `α`. If `s` is a\nseparable space (e.g., if `α` has a second countable topology), then there exists a countable\ndense subset `t ⊆ s` such that `t` does not contain bottom/top elements of `α`. -/\ntheorem Dense.exists_countable_dense_subset_no_bot_top [Nontrivial α] {s : Set α} [SeparableSpace s]\n    (hs : Dense s) :\n    ∃ (t : _)(_ : t ⊆ s), t.Countable ∧ Dense t ∧ (∀ x, IsBot x → x ∉ t) ∧ ∀ x, IsTop x → x ∉ t :=\n  by\n  rcases hs.exists_countable_dense_subset with ⟨t, hts, htc, htd⟩\n  refine' ⟨t \\ ({ x | IsBot x } ∪ { x | IsTop x }), _, _, _, _, _⟩\n  · exact (diff_subset _ _).trans hts\n  · exact htc.mono (diff_subset _ _)\n  · exact htd.diff_finite ((subsingleton_is_bot α).Finite.union (subsingleton_is_top α).Finite)\n  · intro x hx\n    simp [hx]\n  · intro x hx\n    simp [hx]\n#align dense.exists_countable_dense_subset_no_bot_top Dense.exists_countable_dense_subset_no_bot_top\n\nvariable (α)\n\n#print exists_countable_dense_no_bot_top /-\n/-- If `α` is a nontrivial separable dense linear order, then there exists a\ncountable dense set `s : set α` that contains neither top nor bottom elements of `α`.\nFor a dense set containing both bot and top elements, see\n`exists_countable_dense_bot_top`. -/\ntheorem exists_countable_dense_no_bot_top [SeparableSpace α] [Nontrivial α] :\n    ∃ s : Set α, s.Countable ∧ Dense s ∧ (∀ x, IsBot x → x ∉ s) ∧ ∀ x, IsTop x → x ∉ s := by\n  simpa using dense_univ.exists_countable_dense_subset_no_bot_top\n#align exists_countable_dense_no_bot_top exists_countable_dense_no_bot_top\n-/\n\nend DenselyOrdered\n\nsection CompleteLinearOrder\n\nvariable [CompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α] [CompleteLinearOrder β]\n  [TopologicalSpace β] [OrderClosedTopology β] [Nonempty γ]\n\n/- warning: Sup_mem_closure -> supₛ_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))) s) (closure.{u1} α _inst_8 s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_9)))) s) (closure.{u1} α _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align Sup_mem_closure supₛ_mem_closureₓ'. -/\ntheorem supₛ_mem_closure {α : Type u} [TopologicalSpace α] [CompleteLinearOrder α] [OrderTopology α]\n    {s : Set α} (hs : s.Nonempty) : supₛ s ∈ closure s :=\n  (isLUB_supₛ s).mem_closure hs\n#align Sup_mem_closure supₛ_mem_closure\n\n/- warning: Inf_mem_closure -> infₛ_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))) s) (closure.{u1} α _inst_8 s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_9)))) s) (closure.{u1} α _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align Inf_mem_closure infₛ_mem_closureₓ'. -/\ntheorem infₛ_mem_closure {α : Type u} [TopologicalSpace α] [CompleteLinearOrder α] [OrderTopology α]\n    {s : Set α} (hs : s.Nonempty) : infₛ s ∈ closure s :=\n  (isGLB_infₛ s).mem_closure hs\n#align Inf_mem_closure infₛ_mem_closure\n\n/- warning: is_closed.Sup_mem -> IsClosed.supₛ_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (IsClosed.{u1} α _inst_8 s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))) s) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (IsClosed.{u1} α _inst_8 s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_9)))) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.Sup_mem IsClosed.supₛ_memₓ'. -/\ntheorem IsClosed.supₛ_mem {α : Type u} [TopologicalSpace α] [CompleteLinearOrder α]\n    [OrderTopology α] {s : Set α} (hs : s.Nonempty) (hc : IsClosed s) : supₛ s ∈ s :=\n  (isLUB_supₛ s).mem_of_isClosed hs hc\n#align is_closed.Sup_mem IsClosed.supₛ_mem\n\n/- warning: is_closed.Inf_mem -> IsClosed.infₛ_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (IsClosed.{u1} α _inst_8 s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))) s) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} α] [_inst_9 : CompleteLinearOrder.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_8 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_9))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (IsClosed.{u1} α _inst_8 s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_9)))) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.Inf_mem IsClosed.infₛ_memₓ'. -/\ntheorem IsClosed.infₛ_mem {α : Type u} [TopologicalSpace α] [CompleteLinearOrder α]\n    [OrderTopology α] {s : Set α} (hs : s.Nonempty) (hc : IsClosed s) : infₛ s ∈ s :=\n  (isGLB_infₛ s).mem_of_isClosed hs hc\n#align is_closed.Inf_mem IsClosed.infₛ_mem\n\n/- warning: monotone.map_Sup_of_continuous_at' -> Monotone.map_supₛ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Sup_of_continuous_at' Monotone.map_supₛ_of_continuousAt'ₓ'. -/\n/-- A monotone function continuous at the supremum of a nonempty set sends this supremum to\nthe supremum of the image of this set. -/\ntheorem Monotone.map_supₛ_of_continuousAt' {f : α → β} {s : Set α} (Cf : ContinuousAt f (supₛ s))\n    (Mf : Monotone f) (hs : s.Nonempty) : f (supₛ s) = supₛ (f '' s) :=\n  ((--This is a particular case of the more general is_lub.is_lub_of_tendsto\n              isLUB_supₛ\n              _).isLUB_of_tendsto\n          (fun x hx y hy xy => Mf xy) hs <|\n        Cf.mono_left inf_le_left).supₛ_eq.symm\n#align monotone.map_Sup_of_continuous_at' Monotone.map_supₛ_of_continuousAt'\n\n/- warning: monotone.map_Sup_of_continuous_at -> Monotone.map_supₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Bot.bot.{u1} α (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) (Bot.bot.{u2} β (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Bot.bot.{u1} α (ConditionallyCompleteLinearOrderBot.toBot.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) (Bot.bot.{u2} β (ConditionallyCompleteLinearOrderBot.toBot.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Sup_of_continuous_at Monotone.map_supₛ_of_continuousAtₓ'. -/\n/-- A monotone function `f` sending `bot` to `bot` and continuous at the supremum of a set sends\nthis supremum to the supremum of the image of this set. -/\ntheorem Monotone.map_supₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (supₛ s))\n    (Mf : Monotone f) (fbot : f ⊥ = ⊥) : f (supₛ s) = supₛ (f '' s) :=\n  by\n  cases' s.eq_empty_or_nonempty with h h\n  · simp [h, fbot]\n  · exact Mf.map_Sup_of_continuous_at' Cf h\n#align monotone.map_Sup_of_continuous_at Monotone.map_supₛ_of_continuousAt\n\n/- warning: monotone.map_supr_of_continuous_at' -> Monotone.map_supᵢ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} [_inst_8 : Nonempty.{u3} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι (fun (i : ι) => g i))) (supᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (fun (i : ι) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} [_inst_8 : Nonempty.{u1} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Monotone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι (fun (i : ι) => g i))) (supᵢ.{u3, u1} β (ConditionallyCompleteLattice.toSupSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (fun (i : ι) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_supr_of_continuous_at' Monotone.map_supᵢ_of_continuousAt'ₓ'. -/\n/-- A monotone function continuous at the indexed supremum over a nonempty `Sort` sends this indexed\nsupremum to the indexed supremum of the composition. -/\ntheorem Monotone.map_supᵢ_of_continuousAt' {ι : Sort _} [Nonempty ι] {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (supᵢ g)) (Mf : Monotone f) : f (⨆ i, g i) = ⨆ i, f (g i) := by\n  rw [supᵢ, Mf.map_Sup_of_continuous_at' Cf (range_nonempty g), ← range_comp, supᵢ]\n#align monotone.map_supr_of_continuous_at' Monotone.map_supᵢ_of_continuousAt'\n\n/- warning: monotone.map_supr_of_continuous_at -> Monotone.map_supᵢ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Bot.bot.{u1} α (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) (Bot.bot.{u2} β (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι (fun (i : ι) => g i))) (supᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (fun (i : ι) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Monotone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (Bot.bot.{u2} α (ConditionallyCompleteLinearOrderBot.toBot.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) (Bot.bot.{u3} β (ConditionallyCompleteLinearOrderBot.toBot.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) -> (Eq.{succ u3} β (f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι (fun (i : ι) => g i))) (supᵢ.{u3, u1} β (ConditionallyCompleteLattice.toSupSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (fun (i : ι) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_supr_of_continuous_at Monotone.map_supᵢ_of_continuousAtₓ'. -/\n/-- If a monotone function sending `bot` to `bot` is continuous at the indexed supremum over\na `Sort`, then it sends this indexed supremum to the indexed supremum of the composition. -/\ntheorem Monotone.map_supᵢ_of_continuousAt {ι : Sort _} {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (supᵢ g)) (Mf : Monotone f) (fbot : f ⊥ = ⊥) :\n    f (⨆ i, g i) = ⨆ i, f (g i) := by\n  rw [supᵢ, Mf.map_Sup_of_continuous_at Cf fbot, ← range_comp, supᵢ]\n#align monotone.map_supr_of_continuous_at Monotone.map_supᵢ_of_continuousAt\n\n/- warning: monotone.map_Inf_of_continuous_at' -> Monotone.map_infₛ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Inf_of_continuous_at' Monotone.map_infₛ_of_continuousAt'ₓ'. -/\n/-- A monotone function continuous at the infimum of a nonempty set sends this infimum to\nthe infimum of the image of this set. -/\ntheorem Monotone.map_infₛ_of_continuousAt' {f : α → β} {s : Set α} (Cf : ContinuousAt f (infₛ s))\n    (Mf : Monotone f) (hs : s.Nonempty) : f (infₛ s) = infₛ (f '' s) :=\n  @Monotone.map_supₛ_of_continuousAt' αᵒᵈ βᵒᵈ _ _ _ _ _ _ f s Cf Mf.dual hs\n#align monotone.map_Inf_of_continuous_at' Monotone.map_infₛ_of_continuousAt'\n\n/- warning: monotone.map_Inf_of_continuous_at -> Monotone.map_infₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Top.top.{u1} α (CompleteLattice.toHasTop.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (Top.top.{u2} β (CompleteLattice.toHasTop.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Top.top.{u1} α (CompleteLattice.toTop.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (Top.top.{u2} β (CompleteLattice.toTop.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Inf_of_continuous_at Monotone.map_infₛ_of_continuousAtₓ'. -/\n/-- A monotone function `f` sending `top` to `top` and continuous at the infimum of a set sends\nthis infimum to the infimum of the image of this set. -/\ntheorem Monotone.map_infₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (infₛ s))\n    (Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (infₛ s) = infₛ (f '' s) :=\n  @Monotone.map_supₛ_of_continuousAt αᵒᵈ βᵒᵈ _ _ _ _ _ _ f s Cf Mf.dual ftop\n#align monotone.map_Inf_of_continuous_at Monotone.map_infₛ_of_continuousAt\n\n/- warning: monotone.map_infi_of_continuous_at' -> Monotone.map_infᵢ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} [_inst_8 : Nonempty.{u3} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι (fun (i : ι) => g i))) (infᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (fun (i : ι) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} [_inst_8 : Nonempty.{u1} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Monotone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι (fun (i : ι) => g i))) (infᵢ.{u3, u1} β (ConditionallyCompleteLattice.toInfSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (fun (i : ι) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_infi_of_continuous_at' Monotone.map_infᵢ_of_continuousAt'ₓ'. -/\n/-- A monotone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed\ninfimum to the indexed infimum of the composition. -/\ntheorem Monotone.map_infᵢ_of_continuousAt' {ι : Sort _} [Nonempty ι] {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (infᵢ g)) (Mf : Monotone f) : f (⨅ i, g i) = ⨅ i, f (g i) :=\n  @Monotone.map_supᵢ_of_continuousAt' αᵒᵈ βᵒᵈ _ _ _ _ _ _ ι _ f g Cf Mf.dual\n#align monotone.map_infi_of_continuous_at' Monotone.map_infᵢ_of_continuousAt'\n\n/- warning: monotone.map_infi_of_continuous_at -> Monotone.map_infᵢ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Top.top.{u1} α (CompleteLattice.toHasTop.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (Top.top.{u2} β (CompleteLattice.toHasTop.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) (infᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (Function.comp.{u3, succ u1, succ u2} ι α β f g)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Monotone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (Top.top.{u2} α (CompleteLattice.toTop.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (Top.top.{u3} β (CompleteLattice.toTop.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) -> (Eq.{succ u3} β (f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) (infᵢ.{u3, u1} β (ConditionallyCompleteLattice.toInfSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (Function.comp.{u1, succ u2, succ u3} ι α β f g)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_infi_of_continuous_at Monotone.map_infᵢ_of_continuousAtₓ'. -/\n/-- If a monotone function sending `top` to `top` is continuous at the indexed infimum over\na `Sort`, then it sends this indexed infimum to the indexed infimum of the composition. -/\ntheorem Monotone.map_infᵢ_of_continuousAt {ι : Sort _} {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (infᵢ g)) (Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (infᵢ g) = infᵢ (f ∘ g) :=\n  @Monotone.map_supᵢ_of_continuousAt αᵒᵈ βᵒᵈ _ _ _ _ _ _ ι f g Cf Mf.dual ftop\n#align monotone.map_infi_of_continuous_at Monotone.map_infᵢ_of_continuousAt\n\n/- warning: antitone.map_Sup_of_continuous_at' -> Antitone.map_supₛ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Sup_of_continuous_at' Antitone.map_supₛ_of_continuousAt'ₓ'. -/\n/-- An antitone function continuous at the supremum of a nonempty set sends this supremum to\nthe infimum of the image of this set. -/\ntheorem Antitone.map_supₛ_of_continuousAt' {f : α → β} {s : Set α} (Cf : ContinuousAt f (supₛ s))\n    (Af : Antitone f) (hs : s.Nonempty) : f (supₛ s) = infₛ (f '' s) :=\n  Monotone.map_supₛ_of_continuousAt' (show ContinuousAt (OrderDual.toDual ∘ f) (supₛ s) from Cf) Af\n    hs\n#align antitone.map_Sup_of_continuous_at' Antitone.map_supₛ_of_continuousAt'\n\n/- warning: antitone.map_Sup_of_continuous_at -> Antitone.map_supₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Bot.bot.{u1} α (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) (Top.top.{u2} β (CompleteLattice.toHasTop.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Bot.bot.{u1} α (ConditionallyCompleteLinearOrderBot.toBot.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) (Top.top.{u2} β (CompleteLattice.toTop.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Sup_of_continuous_at Antitone.map_supₛ_of_continuousAtₓ'. -/\n/-- An antitone function `f` sending `bot` to `top` and continuous at the supremum of a set sends\nthis supremum to the infimum of the image of this set. -/\ntheorem Antitone.map_supₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (supₛ s))\n    (Af : Antitone f) (fbot : f ⊥ = ⊤) : f (supₛ s) = infₛ (f '' s) :=\n  Monotone.map_supₛ_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (supₛ s) from Cf) Af\n    fbot\n#align antitone.map_Sup_of_continuous_at Antitone.map_supₛ_of_continuousAt\n\n/- warning: antitone.map_supr_of_continuous_at' -> Antitone.map_supᵢ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} [_inst_8 : Nonempty.{u3} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι (fun (i : ι) => g i))) (infᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (fun (i : ι) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} [_inst_8 : Nonempty.{u1} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Antitone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι (fun (i : ι) => g i))) (infᵢ.{u3, u1} β (ConditionallyCompleteLattice.toInfSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (fun (i : ι) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_supr_of_continuous_at' Antitone.map_supᵢ_of_continuousAt'ₓ'. -/\n/-- An antitone function continuous at the indexed supremum over a nonempty `Sort` sends this\nindexed supremum to the indexed infimum of the composition. -/\ntheorem Antitone.map_supᵢ_of_continuousAt' {ι : Sort _} [Nonempty ι] {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (supᵢ g)) (Af : Antitone f) : f (⨆ i, g i) = ⨅ i, f (g i) :=\n  Monotone.map_supᵢ_of_continuousAt' (show ContinuousAt (OrderDual.toDual ∘ f) (supᵢ g) from Cf) Af\n#align antitone.map_supr_of_continuous_at' Antitone.map_supᵢ_of_continuousAt'\n\n/- warning: antitone.map_supr_of_continuous_at -> Antitone.map_supᵢ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Bot.bot.{u1} α (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) (Top.top.{u2} β (CompleteLattice.toHasTop.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι (fun (i : ι) => g i))) (infᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasInf.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (fun (i : ι) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Antitone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (Bot.bot.{u2} α (ConditionallyCompleteLinearOrderBot.toBot.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) (Top.top.{u3} β (CompleteLattice.toTop.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) -> (Eq.{succ u3} β (f (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι (fun (i : ι) => g i))) (infᵢ.{u3, u1} β (ConditionallyCompleteLattice.toInfSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (fun (i : ι) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_supr_of_continuous_at Antitone.map_supᵢ_of_continuousAtₓ'. -/\n/-- An antitone function sending `bot` to `top` is continuous at the indexed supremum over\na `Sort`, then it sends this indexed supremum to the indexed supremum of the composition. -/\ntheorem Antitone.map_supᵢ_of_continuousAt {ι : Sort _} {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (supᵢ g)) (Af : Antitone f) (fbot : f ⊥ = ⊤) :\n    f (⨆ i, g i) = ⨅ i, f (g i) :=\n  Monotone.map_supᵢ_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (supᵢ g) from Cf) Af\n    fbot\n#align antitone.map_supr_of_continuous_at Antitone.map_supᵢ_of_continuousAt\n\n/- warning: antitone.map_Inf_of_continuous_at' -> Antitone.map_infₛ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Set.Nonempty.{u1} α s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Inf_of_continuous_at' Antitone.map_infₛ_of_continuousAt'ₓ'. -/\n/-- An antitone function continuous at the infimum of a nonempty set sends this infimum to\nthe supremum of the image of this set. -/\ntheorem Antitone.map_infₛ_of_continuousAt' {f : α → β} {s : Set α} (Cf : ContinuousAt f (infₛ s))\n    (Af : Antitone f) (hs : s.Nonempty) : f (infₛ s) = supₛ (f '' s) :=\n  Monotone.map_infₛ_of_continuousAt' (show ContinuousAt (OrderDual.toDual ∘ f) (infₛ s) from Cf) Af\n    hs\n#align antitone.map_Inf_of_continuous_at' Antitone.map_infₛ_of_continuousAt'\n\n/- warning: antitone.map_Inf_of_continuous_at -> Antitone.map_infₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Top.top.{u1} α (CompleteLattice.toHasTop.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (Bot.bot.{u2} β (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Top.top.{u1} α (CompleteLattice.toTop.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (Bot.bot.{u2} β (ConditionallyCompleteLinearOrderBot.toBot.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} α _inst_1)))) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Inf_of_continuous_at Antitone.map_infₛ_of_continuousAtₓ'. -/\n/-- An antitone function `f` sending `top` to `bot` and continuous at the infimum of a set sends\nthis infimum to the supremum of the image of this set. -/\ntheorem Antitone.map_infₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (infₛ s))\n    (Af : Antitone f) (ftop : f ⊤ = ⊥) : f (infₛ s) = supₛ (f '' s) :=\n  Monotone.map_infₛ_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (infₛ s) from Cf) Af\n    ftop\n#align antitone.map_Inf_of_continuous_at Antitone.map_infₛ_of_continuousAt\n\n/- warning: antitone.map_infi_of_continuous_at' -> Antitone.map_infᵢ_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} [_inst_8 : Nonempty.{u3} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι (fun (i : ι) => g i))) (supᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (fun (i : ι) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} [_inst_8 : Nonempty.{u1} ι] {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Antitone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι (fun (i : ι) => g i))) (supᵢ.{u3, u1} β (ConditionallyCompleteLattice.toSupSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (fun (i : ι) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_infi_of_continuous_at' Antitone.map_infᵢ_of_continuousAt'ₓ'. -/\n/-- An antitone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed\ninfimum to the indexed supremum of the composition. -/\ntheorem Antitone.map_infᵢ_of_continuousAt' {ι : Sort _} [Nonempty ι] {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (infᵢ g)) (Af : Antitone f) : f (⨅ i, g i) = ⨆ i, f (g i) :=\n  Monotone.map_infᵢ_of_continuousAt' (show ContinuousAt (OrderDual.toDual ∘ f) (infᵢ g) from Cf) Af\n#align antitone.map_infi_of_continuous_at' Antitone.map_infᵢ_of_continuousAt'\n\n/- warning: antitone.map_infi_of_continuous_at -> Antitone.map_infᵢ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))))] {ι : Sort.{u3}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (CompleteSemilatticeInf.toPartialOrder.{u2} β (CompleteLattice.toCompleteSemilatticeInf.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4)))) f) -> (Eq.{succ u2} β (f (Top.top.{u1} α (CompleteLattice.toHasTop.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1)))) (Bot.bot.{u2} β (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} β _inst_4)))) -> (Eq.{succ u2} β (f (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (CompleteLinearOrder.toCompleteLattice.{u1} α _inst_1))) ι g)) (supᵢ.{u2, u3} β (ConditionallyCompleteLattice.toHasSup.{u2} β (CompleteLattice.toConditionallyCompleteLattice.{u2} β (CompleteLinearOrder.toCompleteLattice.{u2} β _inst_4))) ι (Function.comp.{u3, succ u1, succ u2} ι α β f g)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} α] [_inst_2 : TopologicalSpace.{u2} α] [_inst_3 : OrderTopology.{u2} α _inst_2 (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} β] [_inst_5 : TopologicalSpace.{u3} β] [_inst_6 : OrderClosedTopology.{u3} β _inst_5 (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4))))] {ι : Sort.{u1}} {f : α -> β} {g : ι -> α}, (ContinuousAt.{u2, u3} α β _inst_2 _inst_5 f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) -> (Antitone.{u2, u3} α β (PartialOrder.toPreorder.{u2} α (CompleteSemilatticeInf.toPartialOrder.{u2} α (CompleteLattice.toCompleteSemilatticeInf.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (PartialOrder.toPreorder.{u3} β (CompleteSemilatticeInf.toPartialOrder.{u3} β (CompleteLattice.toCompleteSemilatticeInf.{u3} β (CompleteLinearOrder.toCompleteLattice.{u3} β _inst_4)))) f) -> (Eq.{succ u3} β (f (Top.top.{u2} α (CompleteLattice.toTop.{u2} α (CompleteLinearOrder.toCompleteLattice.{u2} α _inst_1)))) (Bot.bot.{u3} β (ConditionallyCompleteLinearOrderBot.toBot.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) -> (Eq.{succ u3} β (f (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} α (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} α (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} α _inst_1)))) ι g)) (supᵢ.{u3, u1} β (ConditionallyCompleteLattice.toSupSet.{u3} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} β (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} β (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} β _inst_4)))) ι (Function.comp.{u1, succ u2, succ u3} ι α β f g)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_infi_of_continuous_at Antitone.map_infᵢ_of_continuousAtₓ'. -/\n/-- If an antitone function sending `top` to `bot` is continuous at the indexed infimum over\na `Sort`, then it sends this indexed infimum to the indexed supremum of the composition. -/\ntheorem Antitone.map_infᵢ_of_continuousAt {ι : Sort _} {f : α → β} {g : ι → α}\n    (Cf : ContinuousAt f (infᵢ g)) (Af : Antitone f) (ftop : f ⊤ = ⊥) : f (infᵢ g) = supᵢ (f ∘ g) :=\n  Monotone.map_infᵢ_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (infᵢ g) from Cf) Af\n    ftop\n#align antitone.map_infi_of_continuous_at Antitone.map_infᵢ_of_continuousAt\n\nend CompleteLinearOrder\n\nsection ConditionallyCompleteLinearOrder\n\nvariable [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α]\n  [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderClosedTopology β] [Nonempty γ]\n\n/- warning: cSup_mem_closure -> csupₛ_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) (closure.{u1} α _inst_2 s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) (closure.{u1} α _inst_2 s))\nCase conversion may be inaccurate. Consider using '#align cSup_mem_closure csupₛ_mem_closureₓ'. -/\ntheorem csupₛ_mem_closure {s : Set α} (hs : s.Nonempty) (B : BddAbove s) : supₛ s ∈ closure s :=\n  (isLUB_csupₛ hs B).mem_closure hs\n#align cSup_mem_closure csupₛ_mem_closure\n\n/- warning: cInf_mem_closure -> cinfₛ_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) (closure.{u1} α _inst_2 s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) (closure.{u1} α _inst_2 s))\nCase conversion may be inaccurate. Consider using '#align cInf_mem_closure cinfₛ_mem_closureₓ'. -/\ntheorem cinfₛ_mem_closure {s : Set α} (hs : s.Nonempty) (B : BddBelow s) : infₛ s ∈ closure s :=\n  (isGLB_cinfₛ hs B).mem_closure hs\n#align cInf_mem_closure cinfₛ_mem_closure\n\n/- warning: is_closed.cSup_mem -> IsClosed.csupₛ_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (IsClosed.{u1} α _inst_2 s) -> (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (IsClosed.{u1} α _inst_2 s) -> (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.cSup_mem IsClosed.csupₛ_memₓ'. -/\ntheorem IsClosed.csupₛ_mem {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) (B : BddAbove s) :\n    supₛ s ∈ s :=\n  (isLUB_csupₛ hs B).mem_of_isClosed hs hc\n#align is_closed.cSup_mem IsClosed.csupₛ_mem\n\n/- warning: is_closed.cInf_mem -> IsClosed.cinfₛ_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (IsClosed.{u1} α _inst_2 s) -> (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] {s : Set.{u1} α}, (IsClosed.{u1} α _inst_2 s) -> (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.cInf_mem IsClosed.cinfₛ_memₓ'. -/\ntheorem IsClosed.cinfₛ_mem {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) (B : BddBelow s) :\n    infₛ s ∈ s :=\n  (isGLB_cinfₛ hs B).mem_of_isClosed hs hc\n#align is_closed.cInf_mem IsClosed.cinfₛ_mem\n\n/- warning: monotone.map_cSup_of_continuous_at -> Monotone.map_csupₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toHasSup.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_cSup_of_continuous_at Monotone.map_csupₛ_of_continuousAtₓ'. -/\n/-- If a monotone function is continuous at the supremum of a nonempty bounded above set `s`,\nthen it sends this supremum to the supremum of the image of `s`. -/\ntheorem Monotone.map_csupₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (supₛ s))\n    (Mf : Monotone f) (ne : s.Nonempty) (H : BddAbove s) : f (supₛ s) = supₛ (f '' s) :=\n  by\n  refine' ((isLUB_csupₛ (ne.image f) (Mf.map_bdd_above H)).unique _).symm\n  refine' (isLUB_csupₛ Ne H).isLUB_of_tendsto (fun x hx y hy xy => Mf xy) Ne _\n  exact Cf.mono_left inf_le_left\n#align monotone.map_cSup_of_continuous_at Monotone.map_csupₛ_of_continuousAt\n\n/- warning: monotone.map_csupr_of_continuous_at -> Monotone.map_csupr_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (supᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toHasSup.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (supᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_csupr_of_continuous_at Monotone.map_csupr_of_continuousAtₓ'. -/\n/-- If a monotone function is continuous at the indexed supremum of a bounded function on\na nonempty `Sort`, then it sends this supremum to the supremum of the composition. -/\ntheorem Monotone.map_csupr_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨆ i, g i))\n    (Mf : Monotone f) (H : BddAbove (range g)) : f (⨆ i, g i) = ⨆ i, f (g i) := by\n  rw [supᵢ, Mf.map_cSup_of_continuous_at Cf (range_nonempty _) H, ← range_comp, supᵢ]\n#align monotone.map_csupr_of_continuous_at Monotone.map_csupr_of_continuousAt\n\n/- warning: monotone.map_cInf_of_continuous_at -> Monotone.map_cinfₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toHasInf.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_cInf_of_continuous_at Monotone.map_cinfₛ_of_continuousAtₓ'. -/\n/-- If a monotone function is continuous at the infimum of a nonempty bounded below set `s`,\nthen it sends this infimum to the infimum of the image of `s`. -/\ntheorem Monotone.map_cinfₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (infₛ s))\n    (Mf : Monotone f) (ne : s.Nonempty) (H : BddBelow s) : f (infₛ s) = infₛ (f '' s) :=\n  @Monotone.map_csupₛ_of_continuousAt αᵒᵈ βᵒᵈ _ _ _ _ _ _ f s Cf Mf.dual Ne H\n#align monotone.map_cInf_of_continuous_at Monotone.map_cinfₛ_of_continuousAt\n\n/- warning: monotone.map_cinfi_of_continuous_at -> Monotone.map_cinfᵢ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (infᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toHasInf.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (infᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_cinfi_of_continuous_at Monotone.map_cinfᵢ_of_continuousAtₓ'. -/\n/-- A continuous monotone function sends indexed infimum to indexed infimum in conditionally\ncomplete linear order, under a boundedness assumption. -/\ntheorem Monotone.map_cinfᵢ_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨅ i, g i))\n    (Mf : Monotone f) (H : BddBelow (range g)) : f (⨅ i, g i) = ⨅ i, f (g i) :=\n  @Monotone.map_csupr_of_continuousAt αᵒᵈ βᵒᵈ _ _ _ _ _ _ _ _ _ _ Cf Mf.dual H\n#align monotone.map_cinfi_of_continuous_at Monotone.map_cinfᵢ_of_continuousAt\n\n/- warning: antitone.map_cSup_of_continuous_at -> Antitone.map_csupₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toHasInf.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_cSup_of_continuous_at Antitone.map_csupₛ_of_continuousAtₓ'. -/\n/-- If an antitone function is continuous at the supremum of a nonempty bounded above set `s`,\nthen it sends this supremum to the infimum of the image of `s`. -/\ntheorem Antitone.map_csupₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (supₛ s))\n    (Af : Antitone f) (ne : s.Nonempty) (H : BddAbove s) : f (supₛ s) = infₛ (f '' s) :=\n  Monotone.map_csupₛ_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (supₛ s) from Cf) Af\n    Ne H\n#align antitone.map_cSup_of_continuous_at Antitone.map_csupₛ_of_continuousAt\n\n/- warning: antitone.map_csupr_of_continuous_at -> Antitone.map_csupr_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (infᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toHasInf.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddAbove.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (supᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (infᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toInfSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_csupr_of_continuous_at Antitone.map_csupr_of_continuousAtₓ'. -/\n/-- If an antitone function is continuous at the indexed supremum of a bounded function on\na nonempty `Sort`, then it sends this supremum to the infimum of the composition. -/\ntheorem Antitone.map_csupr_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨆ i, g i))\n    (Af : Antitone f) (H : BddAbove (range g)) : f (⨆ i, g i) = ⨅ i, f (g i) :=\n  Monotone.map_csupr_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (⨆ i, g i) from Cf)\n    Af H\n#align antitone.map_csupr_of_continuous_at Antitone.map_csupr_of_continuousAt\n\n/- warning: antitone.map_cInf_of_continuous_at -> Antitone.map_cinfₛ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toHasSup.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] {f : α -> β} {s : Set.{u1} α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (Set.Nonempty.{u1} α s) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s) -> (Eq.{succ u2} β (f (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) s)) (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_cInf_of_continuous_at Antitone.map_cinfₛ_of_continuousAtₓ'. -/\n/-- If an antitone function is continuous at the infimum of a nonempty bounded below set `s`,\nthen it sends this infimum to the supremum of the image of `s`. -/\ntheorem Antitone.map_cinfₛ_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (infₛ s))\n    (Af : Antitone f) (ne : s.Nonempty) (H : BddBelow s) : f (infₛ s) = supₛ (f '' s) :=\n  Monotone.map_cinfₛ_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (infₛ s) from Cf) Af\n    Ne H\n#align antitone.map_cInf_of_continuous_at Antitone.map_cinfₛ_of_continuousAt\n\n/- warning: antitone.map_cinfi_of_continuous_at -> Antitone.map_cinfᵢ_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (supᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toHasSup.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_5 : TopologicalSpace.{u2} β] [_inst_6 : OrderClosedTopology.{u2} β _inst_5 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)))))] [_inst_7 : Nonempty.{succ u3} γ] {f : α -> β} {g : γ -> α}, (ContinuousAt.{u1, u2} α β _inst_2 _inst_5 f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) -> (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4))))) f) -> (BddBelow.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (Set.range.{u1, succ u3} α γ g)) -> (Eq.{succ u2} β (f (infᵢ.{u1, succ u3} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) γ (fun (i : γ) => g i))) (supᵢ.{u2, succ u3} β (ConditionallyCompleteLattice.toSupSet.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_4)) γ (fun (i : γ) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_cinfi_of_continuous_at Antitone.map_cinfᵢ_of_continuousAtₓ'. -/\n/-- A continuous antitone function sends indexed infimum to indexed supremum in conditionally\ncomplete linear order, under a boundedness assumption. -/\ntheorem Antitone.map_cinfᵢ_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨅ i, g i))\n    (Af : Antitone f) (H : BddBelow (range g)) : f (⨅ i, g i) = ⨆ i, f (g i) :=\n  Monotone.map_cinfᵢ_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (⨅ i, g i) from Cf)\n    Af H\n#align antitone.map_cinfi_of_continuous_at Antitone.map_cinfᵢ_of_continuousAt\n\n/- warning: monotone.tendsto_nhds_within_Iio -> Monotone.tendsto_nhdsWithin_Iio is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_8 : LinearOrder.{u1} α] [_inst_9 : TopologicalSpace.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_9 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_12 : TopologicalSpace.{u2} β] [_inst_13 : OrderTopology.{u2} β _inst_12 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_11)))))] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8)))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_11))))) f) -> (forall (x : α), Filter.Tendsto.{u1, u2} α β f (nhdsWithin.{u1} α _inst_9 x (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8)))) x)) (nhds.{u2} β _inst_12 (SupSet.supₛ.{u2} β (ConditionallyCompleteLattice.toHasSup.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_11)) (Set.image.{u1, u2} α β f (Set.Iio.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8)))) x)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_8 : LinearOrder.{u2} α] [_inst_9 : TopologicalSpace.{u2} α] [_inst_10 : OrderTopology.{u2} α _inst_9 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8)))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u1} β] [_inst_12 : TopologicalSpace.{u1} β] [_inst_13 : OrderTopology.{u1} β _inst_12 (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_11)))))] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8))))) (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_11))))) f) -> (forall (x : α), Filter.Tendsto.{u2, u1} α β f (nhdsWithin.{u2} α _inst_9 x (Set.Iio.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8))))) x)) (nhds.{u1} β _inst_12 (SupSet.supₛ.{u1} β (ConditionallyCompleteLattice.toSupSet.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_11)) (Set.image.{u2, u1} α β f (Set.Iio.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8))))) x)))))\nCase conversion may be inaccurate. Consider using '#align monotone.tendsto_nhds_within_Iio Monotone.tendsto_nhdsWithin_Iioₓ'. -/\n/-- A monotone map has a limit to the left of any point `x`, equal to `Sup (f '' (Iio x))`. -/\ntheorem Monotone.tendsto_nhdsWithin_Iio {α β : Type _} [LinearOrder α] [TopologicalSpace α]\n    [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β]\n    {f : α → β} (Mf : Monotone f) (x : α) : Tendsto f (𝓝[<] x) (𝓝 (supₛ (f '' Iio x))) :=\n  by\n  rcases eq_empty_or_nonempty (Iio x) with (h | h); · simp [h]\n  refine' tendsto_order.2 ⟨fun l hl => _, fun m hm => _⟩\n  · obtain ⟨z, zx, lz⟩ : ∃ a : α, a < x ∧ l < f a := by\n      simpa only [mem_image, exists_prop, exists_exists_and_eq_and] using\n        exists_lt_of_lt_csupₛ (nonempty_image_iff.2 h) hl\n    exact\n      (mem_nhdsWithin_Iio_iff_exists_Ioo_subset' zx).2 ⟨z, zx, fun y hy => lz.trans_le (Mf hy.1.le)⟩\n  · filter_upwards [self_mem_nhdsWithin]with _ hy\n    apply lt_of_le_of_lt _ hm\n    exact le_csupₛ (Mf.map_bdd_above bddAbove_Iio) (mem_image_of_mem _ hy)\n#align monotone.tendsto_nhds_within_Iio Monotone.tendsto_nhdsWithin_Iio\n\n/- warning: monotone.tendsto_nhds_within_Ioi -> Monotone.tendsto_nhdsWithin_Ioi is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_8 : LinearOrder.{u1} α] [_inst_9 : TopologicalSpace.{u1} α] [_inst_10 : OrderTopology.{u1} α _inst_9 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u2} β] [_inst_12 : TopologicalSpace.{u2} β] [_inst_13 : OrderTopology.{u2} β _inst_12 (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_11)))))] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8)))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_11))))) f) -> (forall (x : α), Filter.Tendsto.{u1, u2} α β f (nhdsWithin.{u1} α _inst_9 x (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8)))) x)) (nhds.{u2} β _inst_12 (InfSet.infₛ.{u2} β (ConditionallyCompleteLattice.toHasInf.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_11)) (Set.image.{u1, u2} α β f (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_8)))) x)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_8 : LinearOrder.{u2} α] [_inst_9 : TopologicalSpace.{u2} α] [_inst_10 : OrderTopology.{u2} α _inst_9 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8)))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u1} β] [_inst_12 : TopologicalSpace.{u1} β] [_inst_13 : OrderTopology.{u1} β _inst_12 (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_11)))))] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8))))) (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_11))))) f) -> (forall (x : α), Filter.Tendsto.{u2, u1} α β f (nhdsWithin.{u2} α _inst_9 x (Set.Ioi.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8))))) x)) (nhds.{u1} β _inst_12 (InfSet.infₛ.{u1} β (ConditionallyCompleteLattice.toInfSet.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_11)) (Set.image.{u2, u1} α β f (Set.Ioi.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_8))))) x)))))\nCase conversion may be inaccurate. Consider using '#align monotone.tendsto_nhds_within_Ioi Monotone.tendsto_nhdsWithin_Ioiₓ'. -/\n/-- A monotone map has a limit to the right of any point `x`, equal to `Inf (f '' (Ioi x))`. -/\ntheorem Monotone.tendsto_nhdsWithin_Ioi {α β : Type _} [LinearOrder α] [TopologicalSpace α]\n    [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β]\n    {f : α → β} (Mf : Monotone f) (x : α) : Tendsto f (𝓝[>] x) (𝓝 (infₛ (f '' Ioi x))) :=\n  @Monotone.tendsto_nhdsWithin_Iio αᵒᵈ βᵒᵈ _ _ _ _ _ _ f Mf.dual x\n#align monotone.tendsto_nhds_within_Ioi Monotone.tendsto_nhdsWithin_Ioi\n\nend ConditionallyCompleteLinearOrder\n\nsection NhdsWithPos\n\nsection LinearOrderedAddCommGroup\n\nvariable [LinearOrder α] [Zero α] [TopologicalSpace α] [OrderTopology α]\n\n#print eventually_nhdsWithin_pos_mem_Ioo /-\ntheorem eventually_nhdsWithin_pos_mem_Ioo {ε : α} (h : 0 < ε) : ∀ᶠ x in 𝓝[>] 0, x ∈ Ioo 0 ε :=\n  Ioo_mem_nhdsWithin_Ioi (left_mem_Ico.2 h)\n#align eventually_nhds_within_pos_mem_Ioo eventually_nhdsWithin_pos_mem_Ioo\n-/\n\n#print eventually_nhdsWithin_pos_mem_Ioc /-\ntheorem eventually_nhdsWithin_pos_mem_Ioc {ε : α} (h : 0 < ε) : ∀ᶠ x in 𝓝[>] 0, x ∈ Ioc 0 ε :=\n  Ioc_mem_nhdsWithin_Ioi (left_mem_Ico.2 h)\n#align eventually_nhds_within_pos_mem_Ioc eventually_nhdsWithin_pos_mem_Ioc\n-/\n\nend LinearOrderedAddCommGroup\n\nend NhdsWithPos\n\nend OrderTopology\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Order/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934765, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.4889567585176552}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monoidal.braided\nimport Mathlib.category_theory.limits.shapes.binary_products\nimport Mathlib.category_theory.limits.shapes.terminal\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# The natural monoidal structure on any category with finite (co)products.\n\nA category with a monoidal structure provided in this way is sometimes called a (co)cartesian category,\nalthough this is also sometimes used to mean a finitely complete category.\n(See <https://ncatlab.org/nlab/show/cartesian+category>.)\n\nAs this works with either products or coproducts,\nand sometimes we want to think of a different monoidal structure entirely,\nwe don't set up either construct as an instance.\n\n## Implementation\nWe had previously chosen to rely on `has_terminal` and `has_binary_products` instead of\n`has_finite_products`, because we were later relying on the definitional form of the tensor product.\nNow that `has_limit` has been refactored to be a `Prop`,\nthis issue is irrelevant and we could simplify the construction here.\n\nSee `category_theory.monoidal.of_chosen_finite_products` for a variant of this construction\nwhich allows specifying a particular choice of terminal object and binary products.\n-/\n\nnamespace category_theory\n\n\n/-- A category with a terminal object and binary products has a natural monoidal structure. -/\ndef monoidal_of_has_finite_products (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] : monoidal_category C :=\n  monoidal_category.mk (fun (X Y : C) => X ⨯ Y)\n    (fun (_x _x_1 _x_2 _x_3 : C) (f : _x ⟶ _x_1) (g : _x_2 ⟶ _x_3) => limits.prod.map f g) (⊤_C)\n    limits.prod.associator (fun (P : C) => limits.prod.left_unitor P)\n    fun (P : C) => limits.prod.right_unitor P\n\n/--\nThe monoidal structure coming from finite products is symmetric.\n-/\n@[simp] theorem symmetric_of_has_finite_products_to_braided_category_braiding (C : Type u)\n    [category C] [limits.has_terminal C] [limits.has_binary_products C] (X : C) (Y : C) :\n    β_ = limits.prod.braiding X Y :=\n  Eq.refl β_\n\nnamespace monoidal_of_has_finite_products\n\n\n@[simp] theorem tensor_obj (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] (X : C) (Y : C) : X ⊗ Y = (X ⨯ Y) :=\n  rfl\n\n@[simp] theorem tensor_hom (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) (g : Y ⟶ Z) :\n    f ⊗ g = limits.prod.map f g :=\n  rfl\n\n@[simp] theorem left_unitor_hom (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] (X : C) : iso.hom λ_ = limits.prod.snd :=\n  rfl\n\n@[simp] theorem left_unitor_inv (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] (X : C) :\n    iso.inv λ_ = limits.prod.lift (limits.terminal.from X) 𝟙 :=\n  rfl\n\n@[simp] theorem right_unitor_hom (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] (X : C) : iso.hom ρ_ = limits.prod.fst :=\n  rfl\n\n-- We don't mark this as a simp lemma, even though in many particular\n\n@[simp] theorem right_unitor_inv (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] (X : C) :\n    iso.inv ρ_ = limits.prod.lift 𝟙 (limits.terminal.from X) :=\n  rfl\n\n-- categories the right hand side will simplify significantly further.\n\n-- For now, we'll plan to create specialised simp lemmas in each particular category.\n\ntheorem associator_hom (C : Type u) [category C] [limits.has_terminal C]\n    [limits.has_binary_products C] (X : C) (Y : C) (Z : C) :\n    iso.hom α_ =\n        limits.prod.lift (limits.prod.fst ≫ limits.prod.fst)\n          (limits.prod.lift (limits.prod.fst ≫ limits.prod.snd) limits.prod.snd) :=\n  rfl\n\nend monoidal_of_has_finite_products\n\n\n/-- A category with an initial object and binary coproducts has a natural monoidal structure. -/\ndef monoidal_of_has_finite_coproducts (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] : monoidal_category C :=\n  monoidal_category.mk (fun (X Y : C) => X ⨿ Y)\n    (fun (_x _x_1 _x_2 _x_3 : C) (f : _x ⟶ _x_1) (g : _x_2 ⟶ _x_3) => limits.coprod.map f g) (⊥_C)\n    limits.coprod.associator limits.coprod.left_unitor limits.coprod.right_unitor\n\n/--\nThe monoidal structure coming from finite coproducts is symmetric.\n-/\ndef symmetric_of_has_finite_coproducts (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] : symmetric_category C :=\n  symmetric_category.mk\n\nnamespace monoidal_of_has_finite_coproducts\n\n\n@[simp] theorem tensor_obj (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] (X : C) (Y : C) : X ⊗ Y = (X ⨿ Y) :=\n  rfl\n\n@[simp] theorem tensor_hom (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] {W : C} {X : C} {Y : C} {Z : C} (f : W ⟶ X) (g : Y ⟶ Z) :\n    f ⊗ g = limits.coprod.map f g :=\n  rfl\n\n@[simp] theorem left_unitor_hom (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] (X : C) :\n    iso.hom λ_ = limits.coprod.desc (limits.initial.to X) 𝟙 :=\n  rfl\n\n@[simp] theorem right_unitor_hom (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] (X : C) :\n    iso.hom ρ_ = limits.coprod.desc 𝟙 (limits.initial.to X) :=\n  rfl\n\n@[simp] theorem left_unitor_inv (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] (X : C) : iso.inv λ_ = limits.coprod.inr :=\n  rfl\n\n-- We don't mark this as a simp lemma, even though in many particular\n\n@[simp] theorem right_unitor_inv (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] (X : C) : iso.inv ρ_ = limits.coprod.inl :=\n  rfl\n\n-- categories the right hand side will simplify significantly further.\n\n-- For now, we'll plan to create specialised simp lemmas in each particular category.\n\ntheorem associator_hom (C : Type u) [category C] [limits.has_initial C]\n    [limits.has_binary_coproducts C] (X : C) (Y : C) (Z : C) :\n    iso.hom α_ =\n        limits.coprod.desc\n          (limits.coprod.desc limits.coprod.inl (limits.coprod.inl ≫ limits.coprod.inr))\n          (limits.coprod.inr ≫ limits.coprod.inr) :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/of_has_finite_products_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.48895674098774067}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.pfun\nimport Mathlib.tactic.norm_num\nimport Mathlib.data.equiv.mul_add\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# Natural numbers with infinity\n\nThe natural numbers and an extra `top` element `⊤`.\n\n## Main definitions\n\nThe following instances are defined:\n\n* `ordered_add_comm_monoid enat`\n* `canonically_ordered_add_monoid enat`\n\nThere is no additive analogue of `monoid_with_zero`; if there were then `enat` could\nbe an `add_monoid_with_top`.\n\n* `to_with_top` : the map from `enat` to `with_top ℕ`, with theorems that it plays well\nwith `+` and `≤`.\n\n* `with_top_add_equiv : enat ≃+ with_top ℕ`\n* `with_top_order_iso : enat ≃o with_top ℕ`\n\n## Implementation details\n\n`enat` is defined to be `roption ℕ`.\n\n`+` and `≤` are defined on `enat`, but there is an issue with `*` because it's not\nclear what `0 * ⊤` should be. `mul` is hence left undefined. Similarly `⊤ - ⊤` is ambiguous\nso there is no `-` defined on `enat`.\n\nBefore the `open_locale classical` line, various proofs are made with decidability assumptions.\nThis can cause issues -- see for example the non-simp lemma `to_with_top_zero` proved by `rfl`,\nfollowed by `@[simp] lemma to_with_top_zero'` whose proof uses `convert`.\n\n\n## Tags\n\nenat, with_top ℕ\n-/\n\n/-- Type of natural numbers with infinity (`⊤`) -/\ndef enat :=\n  roption ℕ\n\nnamespace enat\n\n\nprotected instance has_zero : HasZero enat :=\n  { zero := roption.some 0 }\n\nprotected instance inhabited : Inhabited enat :=\n  { default := 0 }\n\nprotected instance has_one : HasOne enat :=\n  { one := roption.some 1 }\n\nprotected instance has_add : Add enat :=\n  { add :=\n      fun (x y : enat) =>\n        roption.mk (roption.dom x ∧ roption.dom y)\n          fun (h : roption.dom x ∧ roption.dom y) => roption.get x sorry + roption.get y sorry }\n\nprotected instance has_coe : has_coe ℕ enat :=\n  has_coe.mk roption.some\n\nprotected instance dom.decidable (n : ℕ) : Decidable (roption.dom ↑n) :=\n  is_true trivial\n\n@[simp] theorem coe_inj {x : ℕ} {y : ℕ} : ↑x = ↑y ↔ x = y :=\n  roption.some_inj\n\n@[simp] theorem dom_coe (x : ℕ) : roption.dom ↑x :=\n  trivial\n\nprotected instance add_comm_monoid : add_comm_monoid enat :=\n  add_comm_monoid.mk Add.add sorry 0 sorry sorry sorry\n\nprotected instance has_le : HasLessEq enat :=\n  { LessEq :=\n      fun (x y : enat) =>\n        ∃ (h : roption.dom y → roption.dom x), ∀ (hy : roption.dom y), roption.get x (h hy) ≤ roption.get y hy }\n\nprotected instance has_top : has_top enat :=\n  has_top.mk roption.none\n\nprotected instance has_bot : has_bot enat :=\n  has_bot.mk 0\n\nprotected instance has_sup : has_sup enat :=\n  has_sup.mk\n    fun (x y : enat) =>\n      roption.mk (roption.dom x ∧ roption.dom y)\n        fun (h : roption.dom x ∧ roption.dom y) => roption.get x sorry ⊔ roption.get y sorry\n\ntheorem le_def (x : enat) (y : enat) : x ≤ y ↔ ∃ (h : roption.dom y → roption.dom x), ∀ (hy : roption.dom y), roption.get x (h hy) ≤ roption.get y hy :=\n  iff.rfl\n\nprotected theorem cases_on {P : enat → Prop} (a : enat) : P ⊤ → (∀ (n : ℕ), P ↑n) → P a :=\n  roption.induction_on\n\n@[simp] theorem top_add (x : enat) : ⊤ + x = ⊤ :=\n  roption.ext' (false_and (roption.dom x)) fun (h : roption.dom (⊤ + x)) => false.elim (and.left h)\n\n@[simp] theorem add_top (x : enat) : x + ⊤ = ⊤ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (x + ⊤ = ⊤)) (add_comm x ⊤)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (⊤ + x = ⊤)) (top_add x))) (Eq.refl ⊤))\n\n@[simp] theorem coe_zero : ↑0 = 0 :=\n  rfl\n\n@[simp] theorem coe_one : ↑1 = 1 :=\n  rfl\n\n@[simp] theorem coe_add (x : ℕ) (y : ℕ) : ↑(x + y) = ↑x + ↑y :=\n  roption.ext' (iff.symm (and_true (roption.dom ↑(x + y))))\n    fun (_x : roption.dom ↑(x + y)) (_x_1 : roption.dom (↑x + ↑y)) => rfl\n\ntheorem get_coe {x : ℕ} : roption.get (↑x) True.intro = x :=\n  rfl\n\n@[simp] theorem get_coe' (x : ℕ) (h : roption.dom ↑x) : roption.get (↑x) h = x :=\n  rfl\n\ntheorem coe_add_get {x : ℕ} {y : enat} (h : roption.dom (↑x + y)) : roption.get (↑x + y) h = x + roption.get y (and.right h) :=\n  rfl\n\n@[simp] theorem get_add {x : enat} {y : enat} (h : roption.dom (x + y)) : roption.get (x + y) h = roption.get x (and.left h) + roption.get y (and.right h) :=\n  rfl\n\n@[simp] theorem coe_get {x : enat} (h : roption.dom x) : ↑(roption.get x h) = x :=\n  roption.ext' (iff_of_true trivial h) fun (_x : roption.dom ↑(roption.get x h)) (_x_1 : roption.dom x) => rfl\n\n@[simp] theorem get_zero (h : roption.dom 0) : roption.get 0 h = 0 :=\n  rfl\n\n@[simp] theorem get_one (h : roption.dom 1) : roption.get 1 h = 1 :=\n  rfl\n\ntheorem dom_of_le_of_dom {x : enat} {y : enat} : x ≤ y → roption.dom y → roption.dom x := sorry\n\ntheorem dom_of_le_some {x : enat} {y : ℕ} (h : x ≤ ↑y) : roption.dom x :=\n  dom_of_le_of_dom h trivial\n\nprotected instance decidable_le (x : enat) (y : enat) [Decidable (roption.dom x)] [Decidable (roption.dom y)] : Decidable (x ≤ y) :=\n  dite (roption.dom x)\n    (fun (hx : roption.dom x) =>\n      decidable_of_decidable_of_iff\n        ((fun (this : Decidable (∀ (hy : roption.dom y), roption.get x hx ≤ roption.get y hy)) => this)\n          (Mathlib.forall_prop_decidable fun (hy : roption.dom y) => roption.get x hx ≤ roption.get y hy))\n        sorry)\n    fun (hx : ¬roption.dom x) =>\n      dite (roption.dom y) (fun (hy : roption.dom y) => isFalse sorry) fun (hy : ¬roption.dom y) => is_true sorry\n\n/-- The coercion `ℕ → enat` preserves `0` and addition. -/\ndef coe_hom : ℕ →+ enat :=\n  add_monoid_hom.mk coe coe_zero coe_add\n\nprotected instance partial_order : partial_order enat :=\n  partial_order.mk LessEq (preorder.lt._default LessEq) sorry sorry sorry\n\ntheorem lt_def (x : enat) (y : enat) : x < y ↔ ∃ (hx : roption.dom x), ∀ (hy : roption.dom y), roption.get x hx < roption.get y hy := sorry\n\n@[simp] theorem coe_le_coe {x : ℕ} {y : ℕ} : ↑x ≤ ↑y ↔ x ≤ y := sorry\n\n@[simp] theorem coe_lt_coe {x : ℕ} {y : ℕ} : ↑x < ↑y ↔ x < y := sorry\n\n@[simp] theorem get_le_get {x : enat} {y : enat} {hx : roption.dom x} {hy : roption.dom y} : roption.get x hx ≤ roption.get y hy ↔ x ≤ y := sorry\n\ntheorem le_coe_iff (x : enat) (n : ℕ) : x ≤ ↑n ↔ ∃ (h : roption.dom x), roption.get x h ≤ n := sorry\n\ntheorem lt_coe_iff (x : enat) (n : ℕ) : x < ↑n ↔ ∃ (h : roption.dom x), roption.get x h < n := sorry\n\ntheorem coe_le_iff (n : ℕ) (x : enat) : ↑n ≤ x ↔ ∀ (h : roption.dom x), n ≤ roption.get x h := sorry\n\ntheorem coe_lt_iff (n : ℕ) (x : enat) : ↑n < x ↔ ∀ (h : roption.dom x), n < roption.get x h := sorry\n\nprotected theorem zero_lt_one : 0 < 1 := sorry\n\nprotected instance semilattice_sup_bot : semilattice_sup_bot enat :=\n  semilattice_sup_bot.mk ⊥ partial_order.le partial_order.lt partial_order.le_refl partial_order.le_trans\n    partial_order.le_antisymm sorry has_sup.sup sorry sorry sorry\n\nprotected instance order_top : order_top enat :=\n  order_top.mk ⊤ semilattice_sup_bot.le semilattice_sup_bot.lt semilattice_sup_bot.le_refl semilattice_sup_bot.le_trans\n    semilattice_sup_bot.le_antisymm sorry\n\ntheorem dom_of_lt {x : enat} {y : enat} : x < y → roption.dom x :=\n  enat.cases_on x not_top_lt fun (_x : ℕ) (_x : ↑_x < y) => trivial\n\ntheorem top_eq_none : ⊤ = roption.none :=\n  rfl\n\n@[simp] theorem coe_lt_top (x : ℕ) : ↑x < ⊤ :=\n  lt_of_le_of_ne le_top fun (h : ↑x = ⊤) => absurd (congr_arg roption.dom h) true_ne_false\n\n@[simp] theorem coe_ne_top (x : ℕ) : ↑x ≠ ⊤ :=\n  ne_of_lt (coe_lt_top x)\n\ntheorem ne_top_iff {x : enat} : x ≠ ⊤ ↔ ∃ (n : ℕ), x = ↑n :=\n  roption.ne_none_iff\n\ntheorem ne_top_iff_dom {x : enat} : x ≠ ⊤ ↔ roption.dom x :=\n  iff.mp not_iff_comm (iff.symm roption.eq_none_iff')\n\ntheorem ne_top_of_lt {x : enat} {y : enat} (h : x < y) : x ≠ ⊤ :=\n  ne_of_lt (lt_of_lt_of_le h le_top)\n\ntheorem eq_top_iff_forall_lt (x : enat) : x = ⊤ ↔ ∀ (n : ℕ), ↑n < x := sorry\n\ntheorem eq_top_iff_forall_le (x : enat) : x = ⊤ ↔ ∀ (n : ℕ), ↑n ≤ x :=\n  iff.trans (eq_top_iff_forall_lt x)\n    { mp := fun (h : ∀ (n : ℕ), ↑n < x) (n : ℕ) => has_lt.lt.le (h n),\n      mpr := fun (h : ∀ (n : ℕ), ↑n ≤ x) (n : ℕ) => lt_of_lt_of_le (iff.mpr coe_lt_coe (nat.lt_succ_self n)) (h (n + 1)) }\n\ntheorem pos_iff_one_le {x : enat} : 0 < x ↔ 1 ≤ x := sorry\n\nprotected instance linear_order : linear_order enat :=\n  linear_order.mk partial_order.le partial_order.lt partial_order.le_refl partial_order.le_trans partial_order.le_antisymm\n    sorry (classical.dec_rel LessEq) Mathlib.decidable_eq_of_decidable_le Mathlib.decidable_lt_of_decidable_le\n\nprotected instance bounded_lattice : bounded_lattice enat :=\n  bounded_lattice.mk semilattice_sup_bot.sup order_top.le order_top.lt order_top.le_refl order_top.le_trans\n    order_top.le_antisymm semilattice_sup_bot.le_sup_left semilattice_sup_bot.le_sup_right semilattice_sup_bot.sup_le min\n    min_le_left min_le_right sorry order_top.top order_top.le_top semilattice_sup_bot.bot semilattice_sup_bot.bot_le\n\ntheorem sup_eq_max {a : enat} {b : enat} : a ⊔ b = max a b :=\n  le_antisymm (sup_le (le_max_left a b) (le_max_right a b)) (max_le le_sup_left le_sup_right)\n\ntheorem inf_eq_min {a : enat} {b : enat} : a ⊓ b = min a b :=\n  rfl\n\nprotected instance ordered_add_comm_monoid : ordered_add_comm_monoid enat :=\n  ordered_add_comm_monoid.mk add_comm_monoid.add add_comm_monoid.add_assoc add_comm_monoid.zero add_comm_monoid.zero_add\n    add_comm_monoid.add_zero add_comm_monoid.add_comm linear_order.le linear_order.lt linear_order.le_refl\n    linear_order.le_trans linear_order.le_antisymm sorry sorry\n\nprotected instance canonically_ordered_add_monoid : canonically_ordered_add_monoid enat :=\n  canonically_ordered_add_monoid.mk ordered_add_comm_monoid.add ordered_add_comm_monoid.add_assoc\n    ordered_add_comm_monoid.zero ordered_add_comm_monoid.zero_add ordered_add_comm_monoid.add_zero\n    ordered_add_comm_monoid.add_comm semilattice_sup_bot.le semilattice_sup_bot.lt semilattice_sup_bot.le_refl\n    semilattice_sup_bot.le_trans semilattice_sup_bot.le_antisymm ordered_add_comm_monoid.add_le_add_left\n    ordered_add_comm_monoid.lt_of_add_lt_add_left semilattice_sup_bot.bot semilattice_sup_bot.bot_le sorry\n\nprotected theorem add_lt_add_right {x : enat} {y : enat} {z : enat} (h : x < y) (hz : z ≠ ⊤) : x + z < y + z := sorry\n\nprotected theorem add_lt_add_iff_right {x : enat} {y : enat} {z : enat} (hz : z ≠ ⊤) : x + z < y + z ↔ x < y :=\n  { mp := lt_of_add_lt_add_right, mpr := fun (h : x < y) => enat.add_lt_add_right h hz }\n\nprotected theorem add_lt_add_iff_left {x : enat} {y : enat} {z : enat} (hz : z ≠ ⊤) : z + x < z + y ↔ x < y := sorry\n\nprotected theorem lt_add_iff_pos_right {x : enat} {y : enat} (hx : x ≠ ⊤) : x < x + y ↔ 0 < y := sorry\n\ntheorem lt_add_one {x : enat} (hx : x ≠ ⊤) : x < x + 1 := sorry\n\ntheorem le_of_lt_add_one {x : enat} {y : enat} (h : x < y + 1) : x ≤ y := sorry\n\ntheorem add_one_le_of_lt {x : enat} {y : enat} (h : x < y) : x + 1 ≤ y := sorry\n\ntheorem add_one_le_iff_lt {x : enat} {y : enat} (hx : x ≠ ⊤) : x + 1 ≤ y ↔ x < y := sorry\n\ntheorem lt_add_one_iff_lt {x : enat} {y : enat} (hx : x ≠ ⊤) : x < y + 1 ↔ x ≤ y := sorry\n\ntheorem add_eq_top_iff {a : enat} {b : enat} : a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤ := sorry\n\nprotected theorem add_right_cancel_iff {a : enat} {b : enat} {c : enat} (hc : c ≠ ⊤) : a + c = b + c ↔ a = b := sorry\n\nprotected theorem add_left_cancel_iff {a : enat} {b : enat} {c : enat} (ha : a ≠ ⊤) : a + b = a + c ↔ b = c := sorry\n\n/-- Computably converts an `enat` to a `with_top ℕ`. -/\ndef to_with_top (x : enat) [Decidable (roption.dom x)] : with_top ℕ :=\n  roption.to_option x\n\ntheorem to_with_top_top : to_with_top ⊤ = ⊤ :=\n  rfl\n\n@[simp] theorem to_with_top_top' {h : Decidable (roption.dom ⊤)} : to_with_top ⊤ = ⊤ := sorry\n\ntheorem to_with_top_zero : to_with_top 0 = 0 :=\n  rfl\n\n@[simp] theorem to_with_top_zero' {h : Decidable (roption.dom 0)} : to_with_top 0 = 0 := sorry\n\ntheorem to_with_top_coe (n : ℕ) : to_with_top ↑n = ↑n :=\n  rfl\n\n@[simp] theorem to_with_top_coe' (n : ℕ) {h : Decidable (roption.dom ↑n)} : to_with_top ↑n = ↑n := sorry\n\n@[simp] theorem to_with_top_le {x : enat} {y : enat} [Decidable (roption.dom x)] [Decidable (roption.dom y)] : to_with_top x ≤ to_with_top y ↔ x ≤ y := sorry\n\n@[simp] theorem to_with_top_lt {x : enat} {y : enat} [Decidable (roption.dom x)] [Decidable (roption.dom y)] : to_with_top x < to_with_top y ↔ x < y :=\n  lt_iff_lt_of_le_iff_le to_with_top_le\n\n@[simp] theorem to_with_top_add {x : enat} {y : enat} : to_with_top (x + y) = to_with_top x + to_with_top y := sorry\n\n/-- `equiv` between `enat` and `with_top ℕ` (for the order isomorphism see `with_top_order_iso`). -/\ndef with_top_equiv : enat ≃ with_top ℕ :=\n  equiv.mk (fun (x : enat) => to_with_top x) (fun (x : with_top ℕ) => sorry) sorry sorry\n\n@[simp] theorem with_top_equiv_top : coe_fn with_top_equiv ⊤ = ⊤ :=\n  to_with_top_top'\n\n@[simp] theorem with_top_equiv_coe (n : ℕ) : coe_fn with_top_equiv ↑n = ↑n :=\n  to_with_top_coe' n\n\n@[simp] theorem with_top_equiv_zero : coe_fn with_top_equiv 0 = 0 :=\n  with_top_equiv_coe 0\n\n@[simp] theorem with_top_equiv_le {x : enat} {y : enat} : coe_fn with_top_equiv x ≤ coe_fn with_top_equiv y ↔ x ≤ y :=\n  to_with_top_le\n\n@[simp] theorem with_top_equiv_lt {x : enat} {y : enat} : coe_fn with_top_equiv x < coe_fn with_top_equiv y ↔ x < y :=\n  to_with_top_lt\n\n/-- `to_with_top` induces an order isomorphism between `enat` and `with_top ℕ`. -/\ndef with_top_order_iso : enat ≃o with_top ℕ :=\n  rel_iso.mk (equiv.mk (equiv.to_fun with_top_equiv) (equiv.inv_fun with_top_equiv) sorry sorry) sorry\n\n@[simp] theorem with_top_equiv_symm_top : coe_fn (equiv.symm with_top_equiv) ⊤ = ⊤ :=\n  rfl\n\n@[simp] theorem with_top_equiv_symm_coe (n : ℕ) : coe_fn (equiv.symm with_top_equiv) ↑n = ↑n :=\n  rfl\n\n@[simp] theorem with_top_equiv_symm_zero : coe_fn (equiv.symm with_top_equiv) 0 = 0 :=\n  rfl\n\n@[simp] theorem with_top_equiv_symm_le {x : with_top ℕ} {y : with_top ℕ} : coe_fn (equiv.symm with_top_equiv) x ≤ coe_fn (equiv.symm with_top_equiv) y ↔ x ≤ y := sorry\n\n@[simp] theorem with_top_equiv_symm_lt {x : with_top ℕ} {y : with_top ℕ} : coe_fn (equiv.symm with_top_equiv) x < coe_fn (equiv.symm with_top_equiv) y ↔ x < y := sorry\n\n/-- `to_with_top` induces an additive monoid isomorphism between `enat` and `with_top ℕ`. -/\ndef with_top_add_equiv : enat ≃+ with_top ℕ :=\n  add_equiv.mk (equiv.to_fun with_top_equiv) (equiv.inv_fun with_top_equiv) sorry sorry sorry\n\ntheorem lt_wf : well_founded Less := sorry\n\nprotected instance has_well_founded : has_well_founded enat :=\n  has_well_founded.mk Less lt_wf\n\n/-- The smallest `enat` satisfying a (decidable) predicate `P : ℕ → Prop` -/\ndef find (P : ℕ → Prop) [decidable_pred P] : enat :=\n  roption.mk (∃ (n : ℕ), P n) nat.find\n\n@[simp] theorem find_get (P : ℕ → Prop) [decidable_pred P] (h : roption.dom (find P)) : roption.get (find P) h = nat.find h :=\n  rfl\n\ntheorem find_dom (P : ℕ → Prop) [decidable_pred P] (h : ∃ (n : ℕ), P n) : roption.dom (find P) :=\n  h\n\ntheorem lt_find (P : ℕ → Prop) [decidable_pred P] (n : ℕ) (h : ∀ (m : ℕ), m ≤ n → ¬P m) : ↑n < find P := sorry\n\ntheorem lt_find_iff (P : ℕ → Prop) [decidable_pred P] (n : ℕ) : ↑n < find P ↔ ∀ (m : ℕ), m ≤ n → ¬P m := sorry\n\ntheorem find_le (P : ℕ → Prop) [decidable_pred P] (n : ℕ) (h : P n) : find P ≤ ↑n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (find P ≤ ↑n)) (propext (le_coe_iff (find P) n))))\n    (Exists.intro (Exists.intro n h) (nat.find_min' (Exists.intro n h) h))\n\ntheorem find_eq_top_iff (P : ℕ → Prop) [decidable_pred P] : find P = ⊤ ↔ ∀ (n : ℕ), ¬P n :=\n  iff.trans (eq_top_iff_forall_lt (find P))\n    { mp := fun (h : ∀ (n : ℕ), ↑n < find P) (n : ℕ) => iff.mp (lt_find_iff P n) (h n) n le_rfl,\n      mpr := fun (h : ∀ (n : ℕ), ¬P n) (n : ℕ) => lt_find P n fun (_x : ℕ) (_x_1 : _x ≤ n) => h _x }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/nat/enat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.4889316420304224}}
{"text": "/-\nCopyright (c) 2019 Jean Lo. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jean Lo, Bhavik Mehta, Yaël Dillies\n\n! This file was ported from Lean 3 source module analysis.locally_convex.basic\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.Convex.Basic\nimport Mathbin.Analysis.Convex.Hull\nimport Mathbin.Analysis.NormedSpace.Basic\n\n/-!\n# Local convexity\n\nThis file defines absorbent and balanced sets.\n\nAn absorbent set is one that \"surrounds\" the origin. The idea is made precise by requiring that any\npoint belongs to all large enough scalings of the set. This is the vector world analog of a\ntopological neighborhood of the origin.\n\nA balanced set is one that is everywhere around the origin. This means that `a • s ⊆ s` for all `a`\nof norm less than `1`.\n\n## Main declarations\n\nFor a module over a normed ring:\n* `absorbs`: A set `s` absorbs a set `t` if all large scalings of `s` contain `t`.\n* `absorbent`: A set `s` is absorbent if every point eventually belongs to all large scalings of\n  `s`.\n* `balanced`: A set `s` is balanced if `a • s ⊆ s` for all `a` of norm less than `1`.\n\n## References\n\n* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]\n\n## Tags\n\nabsorbent, balanced, locally convex, LCTVS\n-/\n\n\nopen Set\n\nopen Pointwise Topology\n\nvariable {𝕜 𝕝 E : Type _} {ι : Sort _} {κ : ι → Sort _}\n\nsection SeminormedRing\n\nvariable [SeminormedRing 𝕜]\n\nsection SMul\n\nvariable (𝕜) [SMul 𝕜 E]\n\n/-- A set `A` absorbs another set `B` if `B` is contained in all scalings of `A` by elements of\nsufficiently large norm. -/\ndef Absorbs (A B : Set E) :=\n  ∃ r, 0 < r ∧ ∀ a : 𝕜, r ≤ ‖a‖ → B ⊆ a • A\n#align absorbs Absorbs\n\nvariable {𝕜} {s t u v A B : Set E}\n\n@[simp]\ntheorem absorbs_empty {s : Set E} : Absorbs 𝕜 s (∅ : Set E) :=\n  ⟨1, one_pos, fun a ha => Set.empty_subset _⟩\n#align absorbs_empty absorbs_empty\n\ntheorem Absorbs.mono (hs : Absorbs 𝕜 s u) (hst : s ⊆ t) (hvu : v ⊆ u) : Absorbs 𝕜 t v :=\n  let ⟨r, hr, h⟩ := hs\n  ⟨r, hr, fun a ha => hvu.trans <| (h _ ha).trans <| smul_set_mono hst⟩\n#align absorbs.mono Absorbs.mono\n\ntheorem Absorbs.mono_left (hs : Absorbs 𝕜 s u) (h : s ⊆ t) : Absorbs 𝕜 t u :=\n  hs.mono h Subset.rfl\n#align absorbs.mono_left Absorbs.mono_left\n\ntheorem Absorbs.mono_right (hs : Absorbs 𝕜 s u) (h : v ⊆ u) : Absorbs 𝕜 s v :=\n  hs.mono Subset.rfl h\n#align absorbs.mono_right Absorbs.mono_right\n\ntheorem Absorbs.union (hu : Absorbs 𝕜 s u) (hv : Absorbs 𝕜 s v) : Absorbs 𝕜 s (u ∪ v) :=\n  by\n  obtain ⟨a, ha, hu⟩ := hu\n  obtain ⟨b, hb, hv⟩ := hv\n  exact\n    ⟨max a b, lt_max_of_lt_left ha, fun c hc =>\n      union_subset (hu _ <| le_of_max_le_left hc) (hv _ <| le_of_max_le_right hc)⟩\n#align absorbs.union Absorbs.union\n\n@[simp]\ntheorem absorbs_union : Absorbs 𝕜 s (u ∪ v) ↔ Absorbs 𝕜 s u ∧ Absorbs 𝕜 s v :=\n  ⟨fun h => ⟨h.mono_right <| subset_union_left _ _, h.mono_right <| subset_union_right _ _⟩,\n    fun h => h.1.union h.2⟩\n#align absorbs_union absorbs_union\n\ntheorem absorbs_unionᵢ_finset {ι : Type _} {t : Finset ι} {f : ι → Set E} :\n    Absorbs 𝕜 s (⋃ i ∈ t, f i) ↔ ∀ i ∈ t, Absorbs 𝕜 s (f i) := by\n  classical\n    induction' t using Finset.induction_on with i t ht hi\n    ·\n      simp only [Finset.not_mem_empty, Set.unionᵢ_false, Set.unionᵢ_empty, absorbs_empty,\n        IsEmpty.forall_iff, imp_true_iff]\n    rw [Finset.set_bunionᵢ_insert, absorbs_union, hi]\n    constructor <;> intro h\n    · refine' fun _ hi' => (finset.mem_insert.mp hi').elim _ (h.2 _)\n      exact fun hi'' => by\n        rw [hi'']\n        exact h.1\n    exact ⟨h i (Finset.mem_insert_self i t), fun i' hi' => h i' (Finset.mem_insert_of_mem hi')⟩\n#align absorbs_Union_finset absorbs_unionᵢ_finset\n\ntheorem Set.Finite.absorbs_unionᵢ {ι : Type _} {s : Set E} {t : Set ι} {f : ι → Set E}\n    (hi : t.Finite) : Absorbs 𝕜 s (⋃ i ∈ t, f i) ↔ ∀ i ∈ t, Absorbs 𝕜 s (f i) :=\n  by\n  lift t to Finset ι using hi\n  simp only [Finset.mem_coe]\n  exact absorbs_unionᵢ_finset\n#align set.finite.absorbs_Union Set.Finite.absorbs_unionᵢ\n\nvariable (𝕜)\n\n/-- A set is absorbent if it absorbs every singleton. -/\ndef Absorbent (A : Set E) :=\n  ∀ x, ∃ r, 0 < r ∧ ∀ a : 𝕜, r ≤ ‖a‖ → x ∈ a • A\n#align absorbent Absorbent\n\nvariable {𝕜}\n\ntheorem Absorbent.subset (hA : Absorbent 𝕜 A) (hAB : A ⊆ B) : Absorbent 𝕜 B :=\n  by\n  refine' forall_imp (fun x => _) hA\n  exact Exists.imp fun r => And.imp_right <| forall₂_imp fun a ha hx => Set.smul_set_mono hAB hx\n#align absorbent.subset Absorbent.subset\n\ntheorem absorbent_iff_forall_absorbs_singleton : Absorbent 𝕜 A ↔ ∀ x, Absorbs 𝕜 A {x} := by\n  simp_rw [Absorbs, Absorbent, singleton_subset_iff]\n#align absorbent_iff_forall_absorbs_singleton absorbent_iff_forall_absorbs_singleton\n\ntheorem Absorbent.absorbs (hs : Absorbent 𝕜 s) {x : E} : Absorbs 𝕜 s {x} :=\n  absorbent_iff_forall_absorbs_singleton.1 hs _\n#align absorbent.absorbs Absorbent.absorbs\n\ntheorem absorbent_iff_nonneg_lt :\n    Absorbent 𝕜 A ↔ ∀ x, ∃ r, 0 ≤ r ∧ ∀ ⦃a : 𝕜⦄, r < ‖a‖ → x ∈ a • A :=\n  forall_congr' fun x =>\n    ⟨fun ⟨r, hr, hx⟩ => ⟨r, hr.le, fun a ha => hx a ha.le⟩, fun ⟨r, hr, hx⟩ =>\n      ⟨r + 1, add_pos_of_nonneg_of_pos hr zero_lt_one, fun a ha =>\n        hx ((lt_add_of_pos_right r zero_lt_one).trans_le ha)⟩⟩\n#align absorbent_iff_nonneg_lt absorbent_iff_nonneg_lt\n\ntheorem Absorbent.absorbs_finite {s : Set E} (hs : Absorbent 𝕜 s) {v : Set E} (hv : v.Finite) :\n    Absorbs 𝕜 s v := by\n  rw [← Set.bunionᵢ_of_singleton v]\n  exact hv.absorbs_Union.mpr fun _ _ => hs.absorbs\n#align absorbent.absorbs_finite Absorbent.absorbs_finite\n\nvariable (𝕜)\n\n/-- A set `A` is balanced if `a • A` is contained in `A` whenever `a` has norm at most `1`. -/\ndef Balanced (A : Set E) :=\n  ∀ a : 𝕜, ‖a‖ ≤ 1 → a • A ⊆ A\n#align balanced Balanced\n\nvariable {𝕜}\n\ntheorem balanced_iff_smul_mem : Balanced 𝕜 s ↔ ∀ ⦃a : 𝕜⦄, ‖a‖ ≤ 1 → ∀ ⦃x : E⦄, x ∈ s → a • x ∈ s :=\n  forall₂_congr fun a ha => smul_set_subset_iff\n#align balanced_iff_smul_mem balanced_iff_smul_mem\n\nalias balanced_iff_smul_mem ↔ Balanced.smul_mem _\n#align balanced.smul_mem Balanced.smul_mem\n\n@[simp]\ntheorem balanced_empty : Balanced 𝕜 (∅ : Set E) := fun _ _ => by rw [smul_set_empty]\n#align balanced_empty balanced_empty\n\n@[simp]\ntheorem balanced_univ : Balanced 𝕜 (univ : Set E) := fun a ha => subset_univ _\n#align balanced_univ balanced_univ\n\ntheorem Balanced.union (hA : Balanced 𝕜 A) (hB : Balanced 𝕜 B) : Balanced 𝕜 (A ∪ B) := fun a ha =>\n  smul_set_union.Subset.trans <| union_subset_union (hA _ ha) <| hB _ ha\n#align balanced.union Balanced.union\n\ntheorem Balanced.inter (hA : Balanced 𝕜 A) (hB : Balanced 𝕜 B) : Balanced 𝕜 (A ∩ B) := fun a ha =>\n  smul_set_inter_subset.trans <| inter_subset_inter (hA _ ha) <| hB _ ha\n#align balanced.inter Balanced.inter\n\ntheorem balanced_unionᵢ {f : ι → Set E} (h : ∀ i, Balanced 𝕜 (f i)) : Balanced 𝕜 (⋃ i, f i) :=\n  fun a ha => (smul_set_Union _ _).Subset.trans <| unionᵢ_mono fun _ => h _ _ ha\n#align balanced_Union balanced_unionᵢ\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/\ntheorem balanced_Union₂ {f : ∀ i, κ i → Set E} (h : ∀ i j, Balanced 𝕜 (f i j)) :\n    Balanced 𝕜 (⋃ (i) (j), f i j) :=\n  balanced_unionᵢ fun _ => balanced_unionᵢ <| h _\n#align balanced_Union₂ balanced_Union₂\n\ntheorem balanced_interᵢ {f : ι → Set E} (h : ∀ i, Balanced 𝕜 (f i)) : Balanced 𝕜 (⋂ i, f i) :=\n  fun a ha => (smul_set_interᵢ_subset _ _).trans <| interᵢ_mono fun _ => h _ _ ha\n#align balanced_Inter balanced_interᵢ\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/\ntheorem balanced_Inter₂ {f : ∀ i, κ i → Set E} (h : ∀ i j, Balanced 𝕜 (f i j)) :\n    Balanced 𝕜 (⋂ (i) (j), f i j) :=\n  balanced_interᵢ fun _ => balanced_interᵢ <| h _\n#align balanced_Inter₂ balanced_Inter₂\n\nvariable [SMul 𝕝 E] [SMulCommClass 𝕜 𝕝 E]\n\ntheorem Balanced.smul (a : 𝕝) (hs : Balanced 𝕜 s) : Balanced 𝕜 (a • s) := fun b hb =>\n  (smul_comm _ _ _).Subset.trans <| smul_set_mono <| hs _ hb\n#align balanced.smul Balanced.smul\n\nend SMul\n\nsection Module\n\nvariable [AddCommGroup E] [Module 𝕜 E] {s s₁ s₂ t t₁ t₂ : Set E}\n\ntheorem Absorbs.neg : Absorbs 𝕜 s t → Absorbs 𝕜 (-s) (-t) :=\n  Exists.imp fun r =>\n    And.imp_right <| forall₂_imp fun _ _ h => (neg_subset_neg.2 h).trans (smul_set_neg _ _).Superset\n#align absorbs.neg Absorbs.neg\n\ntheorem Balanced.neg : Balanced 𝕜 s → Balanced 𝕜 (-s) :=\n  forall₂_imp fun _ _ h => (smul_set_neg _ _).Subset.trans <| neg_subset_neg.2 h\n#align balanced.neg Balanced.neg\n\ntheorem Absorbs.add : Absorbs 𝕜 s₁ t₁ → Absorbs 𝕜 s₂ t₂ → Absorbs 𝕜 (s₁ + s₂) (t₁ + t₂) :=\n  fun ⟨r₁, hr₁, h₁⟩ ⟨r₂, hr₂, h₂⟩ =>\n  ⟨max r₁ r₂, lt_max_of_lt_left hr₁, fun a ha =>\n    (add_subset_add (h₁ _ <| le_of_max_le_left ha) <| h₂ _ <| le_of_max_le_right ha).trans\n      (smul_add _ _ _).Superset⟩\n#align absorbs.add Absorbs.add\n\ntheorem Balanced.add (hs : Balanced 𝕜 s) (ht : Balanced 𝕜 t) : Balanced 𝕜 (s + t) := fun a ha =>\n  (smul_add _ _ _).Subset.trans <| add_subset_add (hs _ ha) <| ht _ ha\n#align balanced.add Balanced.add\n\ntheorem Absorbs.sub (h₁ : Absorbs 𝕜 s₁ t₁) (h₂ : Absorbs 𝕜 s₂ t₂) : Absorbs 𝕜 (s₁ - s₂) (t₁ - t₂) :=\n  by\n  simp_rw [sub_eq_add_neg]\n  exact h₁.add h₂.neg\n#align absorbs.sub Absorbs.sub\n\ntheorem Balanced.sub (hs : Balanced 𝕜 s) (ht : Balanced 𝕜 t) : Balanced 𝕜 (s - t) :=\n  by\n  simp_rw [sub_eq_add_neg]\n  exact hs.add ht.neg\n#align balanced.sub Balanced.sub\n\ntheorem balanced_zero : Balanced 𝕜 (0 : Set E) := fun a ha => (smul_zero _).Subset\n#align balanced_zero balanced_zero\n\nend Module\n\nend SeminormedRing\n\nsection NormedField\n\nvariable [NormedField 𝕜] [NormedRing 𝕝] [NormedSpace 𝕜 𝕝] [AddCommGroup E] [Module 𝕜 E]\n  [SMulWithZero 𝕝 E] [IsScalarTower 𝕜 𝕝 E] {s t u v A B : Set E} {x : E} {a b : 𝕜}\n\n/-- Scalar multiplication (by possibly different types) of a balanced set is monotone. -/\ntheorem Balanced.smul_mono (hs : Balanced 𝕝 s) {a : 𝕝} {b : 𝕜} (h : ‖a‖ ≤ ‖b‖) : a • s ⊆ b • s :=\n  by\n  obtain rfl | hb := eq_or_ne b 0\n  · rw [norm_zero] at h\n    rw [norm_eq_zero.1 (h.antisymm <| norm_nonneg _)]\n    obtain rfl | h := s.eq_empty_or_nonempty\n    · simp_rw [smul_set_empty]\n    · simp_rw [zero_smul_set h]\n  rintro _ ⟨x, hx, rfl⟩\n  refine' ⟨b⁻¹ • a • x, _, smul_inv_smul₀ hb _⟩\n  rw [← smul_assoc]\n  refine' hs _ _ (smul_mem_smul_set hx)\n  rw [norm_smul, norm_inv, ← div_eq_inv_mul]\n  exact div_le_one_of_le h (norm_nonneg _)\n#align balanced.smul_mono Balanced.smul_mono\n\n/-- A balanced set absorbs itself. -/\ntheorem Balanced.absorbs_self (hA : Balanced 𝕜 A) : Absorbs 𝕜 A A :=\n  by\n  refine' ⟨1, zero_lt_one, fun a ha x hx => _⟩\n  rw [mem_smul_set_iff_inv_smul_mem₀ (norm_pos_iff.1 <| zero_lt_one.trans_le ha)]\n  refine' hA a⁻¹ _ (smul_mem_smul_set hx)\n  rw [norm_inv]\n  exact inv_le_one ha\n#align balanced.absorbs_self Balanced.absorbs_self\n\ntheorem Balanced.subset_smul (hA : Balanced 𝕜 A) (ha : 1 ≤ ‖a‖) : A ⊆ a • A :=\n  by\n  refine' (subset_set_smul_iff₀ _).2 (hA a⁻¹ _)\n  · rintro rfl\n    rw [norm_zero] at ha\n    exact zero_lt_one.not_le ha\n  · rw [norm_inv]\n    exact inv_le_one ha\n#align balanced.subset_smul Balanced.subset_smul\n\ntheorem Balanced.smul_eq (hA : Balanced 𝕜 A) (ha : ‖a‖ = 1) : a • A = A :=\n  (hA _ ha.le).antisymm <| hA.subset_smul ha.ge\n#align balanced.smul_eq Balanced.smul_eq\n\ntheorem Balanced.mem_smul_iff (hs : Balanced 𝕜 s) (h : ‖a‖ = ‖b‖) : a • x ∈ s ↔ b • x ∈ s :=\n  by\n  obtain rfl | hb := eq_or_ne b 0\n  · rw [norm_zero, norm_eq_zero] at h\n    rw [h]\n  have ha : a ≠ 0 := norm_ne_zero_iff.1 (ne_of_eq_of_ne h <| norm_ne_zero_iff.2 hb)\n  constructor <;> intro h' <;> [rw [← inv_mul_cancel_right₀ ha b],\n      rw [← inv_mul_cancel_right₀ hb a]] <;>\n    · rw [← smul_eq_mul, smul_assoc]\n      refine' hs.smul_mem _ h'\n      simp [← h, ha]\n#align balanced.mem_smul_iff Balanced.mem_smul_iff\n\ntheorem Balanced.neg_mem_iff (hs : Balanced 𝕜 s) : -x ∈ s ↔ x ∈ s := by\n  convert hs.mem_smul_iff (norm_neg 1) <;> simp only [neg_smul, one_smul]\n#align balanced.neg_mem_iff Balanced.neg_mem_iff\n\ntheorem Absorbs.inter (hs : Absorbs 𝕜 s u) (ht : Absorbs 𝕜 t u) : Absorbs 𝕜 (s ∩ t) u :=\n  by\n  obtain ⟨a, ha, hs⟩ := hs\n  obtain ⟨b, hb, ht⟩ := ht\n  have h : 0 < max a b := lt_max_of_lt_left ha\n  refine' ⟨max a b, lt_max_of_lt_left ha, fun c hc => _⟩\n  rw [smul_set_inter₀ (norm_pos_iff.1 <| h.trans_le hc)]\n  exact subset_inter (hs _ <| le_of_max_le_left hc) (ht _ <| le_of_max_le_right hc)\n#align absorbs.inter Absorbs.inter\n\n@[simp]\ntheorem absorbs_inter : Absorbs 𝕜 (s ∩ t) u ↔ Absorbs 𝕜 s u ∧ Absorbs 𝕜 t u :=\n  ⟨fun h => ⟨h.mono_left <| inter_subset_left _ _, h.mono_left <| inter_subset_right _ _⟩, fun h =>\n    h.1.inter h.2⟩\n#align absorbs_inter absorbs_inter\n\ntheorem absorbent_univ : Absorbent 𝕜 (univ : Set E) :=\n  by\n  refine' fun x => ⟨1, zero_lt_one, fun a ha => _⟩\n  rw [smul_set_univ₀ (norm_pos_iff.1 <| zero_lt_one.trans_le ha)]\n  exact trivial\n#align absorbent_univ absorbent_univ\n\nvariable [TopologicalSpace E] [ContinuousSMul 𝕜 E]\n\n/-- Every neighbourhood of the origin is absorbent. -/\ntheorem absorbent_nhds_zero (hA : A ∈ 𝓝 (0 : E)) : Absorbent 𝕜 A :=\n  by\n  intro x\n  obtain ⟨w, hw₁, hw₂, hw₃⟩ := mem_nhds_iff.mp hA\n  have hc : Continuous fun t : 𝕜 => t • x := continuous_id.smul continuous_const\n  obtain ⟨r, hr₁, hr₂⟩ :=\n    metric.is_open_iff.mp (hw₂.preimage hc) 0 (by rwa [mem_preimage, zero_smul])\n  have hr₃ := inv_pos.mpr (half_pos hr₁)\n  refine' ⟨(r / 2)⁻¹, hr₃, fun a ha₁ => _⟩\n  have ha₂ : 0 < ‖a‖ := hr₃.trans_le ha₁\n  refine' (mem_smul_set_iff_inv_smul_mem₀ (norm_pos_iff.mp ha₂) _ _).2 (hw₁ <| hr₂ _)\n  rw [Metric.mem_ball, dist_zero_right, norm_inv]\n  calc\n    ‖a‖⁻¹ ≤ r / 2 := (inv_le (half_pos hr₁) ha₂).mp ha₁\n    _ < r := half_lt_self hr₁\n    \n#align absorbent_nhds_zero absorbent_nhds_zero\n\n/-- The union of `{0}` with the interior of a balanced set is balanced. -/\ntheorem balanced_zero_union_interior (hA : Balanced 𝕜 A) : Balanced 𝕜 ((0 : Set E) ∪ interior A) :=\n  by\n  intro a ha\n  obtain rfl | h := eq_or_ne a 0\n  · rw [zero_smul_set]\n    exacts[subset_union_left _ _, ⟨0, Or.inl rfl⟩]\n  · rw [← image_smul, image_union]\n    apply union_subset_union\n    · rw [image_zero, smul_zero]\n      rfl\n    ·\n      calc\n        a • interior A ⊆ interior (a • A) := (isOpenMap_smul₀ h).image_interior_subset A\n        _ ⊆ interior A := interior_mono (hA _ ha)\n        \n#align balanced_zero_union_interior balanced_zero_union_interior\n\n/-- The interior of a balanced set is balanced if it contains the origin. -/\ntheorem Balanced.interior (hA : Balanced 𝕜 A) (h : (0 : E) ∈ interior A) :\n    Balanced 𝕜 (interior A) :=\n  by\n  rw [← union_eq_self_of_subset_left (singleton_subset_iff.2 h)]\n  exact balanced_zero_union_interior hA\n#align balanced.interior Balanced.interior\n\ntheorem Balanced.closure (hA : Balanced 𝕜 A) : Balanced 𝕜 (closure A) := fun a ha =>\n  (image_closure_subset_closure_image <| continuous_id.const_smul _).trans <|\n    closure_mono <| hA _ ha\n#align balanced.closure Balanced.closure\n\nend NormedField\n\nsection NontriviallyNormedField\n\nvariable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] {s : Set E}\n\ntheorem absorbs_zero_iff : Absorbs 𝕜 s 0 ↔ (0 : E) ∈ s :=\n  by\n  refine' ⟨_, fun h => ⟨1, zero_lt_one, fun a _ => zero_subset.2 <| zero_mem_smul_set h⟩⟩\n  rintro ⟨r, hr, h⟩\n  obtain ⟨a, ha⟩ := NormedSpace.exists_lt_norm 𝕜 𝕜 r\n  have := h _ ha.le\n  rwa [zero_subset, zero_mem_smul_set_iff] at this\n  exact norm_ne_zero_iff.1 (hr.trans ha).ne'\n#align absorbs_zero_iff absorbs_zero_iff\n\ntheorem Absorbent.zero_mem (hs : Absorbent 𝕜 s) : (0 : E) ∈ s :=\n  absorbs_zero_iff.1 <| absorbent_iff_forall_absorbs_singleton.1 hs _\n#align absorbent.zero_mem Absorbent.zero_mem\n\nvariable [Module ℝ E] [SMulCommClass ℝ 𝕜 E]\n\ntheorem balanced_convexHull_of_balanced (hs : Balanced 𝕜 s) : Balanced 𝕜 (convexHull ℝ s) :=\n  by\n  suffices Convex ℝ { x | ∀ a : 𝕜, ‖a‖ ≤ 1 → a • x ∈ convexHull ℝ s }\n    by\n    rw [balanced_iff_smul_mem] at hs⊢\n    refine' fun a ha x hx => convexHull_min _ this hx a ha\n    exact fun y hy a ha => subset_convexHull ℝ s (hs ha hy)\n  intro x hx y hy u v hu hv huv a ha\n  simp only [smul_add, ← smul_comm]\n  exact convex_convexHull ℝ s (hx a ha) (hy a ha) hu hv huv\n#align balanced_convex_hull_of_balanced balanced_convexHull_of_balanced\n\nend NontriviallyNormedField\n\nsection Real\n\nvariable [AddCommGroup E] [Module ℝ E] {s : Set E}\n\ntheorem balanced_iff_neg_mem (hs : Convex ℝ s) : Balanced ℝ s ↔ ∀ ⦃x⦄, x ∈ s → -x ∈ s :=\n  by\n  refine' ⟨fun h x => h.neg_mem_iff.2, fun h a ha => smul_set_subset_iff.2 fun x hx => _⟩\n  rw [Real.norm_eq_abs, abs_le] at ha\n  rw [show a = -((1 - a) / 2) + (a - -1) / 2 by ring, add_smul, neg_smul, ← smul_neg]\n  exact\n    hs (h hx) hx (div_nonneg (sub_nonneg_of_le ha.2) zero_le_two)\n      (div_nonneg (sub_nonneg_of_le ha.1) zero_le_two) (by ring)\n#align balanced_iff_neg_mem balanced_iff_neg_mem\n\nend Real\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Analysis/LocallyConvex/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.48893163316985827}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad, Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.pfunctor.multivariate.basic\nimport Mathlib.PostPort\n\nuniverses u l u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# The W construction as a multivariate polynomial functor.\n\nW types are well-founded tree-like structures. They are defined\nas the least fixpoint of a polynomial functor.\n\n## Main definitions\n\n * `W_mk`     - constructor\n * `W_dest    - destructor\n * `W_rec`    - recursor: basis for defining functions by structural recursion on `P.W α`\n * `W_rec_eq` - defining equation for `W_rec`\n * `W_ind`    - induction principle for `P.W α`\n\n## Implementation notes\n\nThree views of M-types:\n\n * `Wp`: polynomial functor\n * `W`: data type inductively defined by a triple: shape of the root, data in the root and children of the root\n * `W`: least fixed point of a polynomial functor\n\nSpecifically, we define the polynomial functor `Wp` as:\n\n * A := a tree-like structure without information in the nodes\n * B := given the tree-like structure `t`, `B t` is a valid path\n   (specified inductively by `W_path`) from the root of `t` to any given node.\n\nAs a result `Wp.obj α` is made of a dataless tree and a function from\nits valid paths to values of `α`\n\n## Reference\n\n * [Jeremy Avigad, Mario M. Carneiro and Simon Hudon, *Data Types as Quotients of Polynomial Functors*][avigad-carneiro-hudon2019]\n-/\n\nnamespace mvpfunctor\n\n\n/-- A path from the root of a tree to one of its node -/\ninductive W_path {n : ℕ} (P : mvpfunctor (n + 1)) : pfunctor.W (last P) → fin2 n → Type u\nwhere\n| root : (a : A P) →\n  (f : pfunctor.B (last P) a → pfunctor.W (last P)) → (i : fin2 n) → B (drop P) a i → W_path P (W_type.mk a f) i\n| child : (a : A P) →\n  (f : pfunctor.B (last P) a → pfunctor.W (last P)) →\n    (i : fin2 n) → (j : pfunctor.B (last P) a) → W_path P (f j) i → W_path P (W_type.mk a f) i\n\nprotected instance W_path.inhabited {n : ℕ} (P : mvpfunctor (n + 1)) (x : pfunctor.W (last P)) {i : fin2 n} [I : Inhabited (B (drop P) (pfunctor.W.head x) i)] : Inhabited (W_path P x i) :=\n  { default := sorry }\n\n/-- Specialized destructor on `W_path` -/\ndef W_path_cases_on {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {a : A P} {f : pfunctor.B (last P) a → pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) α) (g : (j : pfunctor.B (last P) a) → typevec.arrow (W_path P (f j)) α) : typevec.arrow (W_path P (W_type.mk a f)) α := sorry\n\n/-- Specialized destructor on `W_path` -/\ndef W_path_dest_left {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {a : A P} {f : pfunctor.B (last P) a → pfunctor.W (last P)} (h : typevec.arrow (W_path P (W_type.mk a f)) α) : typevec.arrow (B (drop P) a) α :=\n  fun (i : fin2 n) (c : B (drop P) a i) => h i (W_path.root a f i c)\n\n/-- Specialized destructor on `W_path` -/\ndef W_path_dest_right {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {a : A P} {f : pfunctor.B (last P) a → pfunctor.W (last P)} (h : typevec.arrow (W_path P (W_type.mk a f)) α) (j : pfunctor.B (last P) a) : typevec.arrow (W_path P (f j)) α :=\n  fun (i : fin2 n) (c : W_path P (f j) i) => h i (W_path.child a f i j c)\n\ntheorem W_path_dest_left_W_path_cases_on {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {a : A P} {f : pfunctor.B (last P) a → pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) α) (g : (j : pfunctor.B (last P) a) → typevec.arrow (W_path P (f j)) α) : W_path_dest_left P (W_path_cases_on P g' g) = g' :=\n  rfl\n\ntheorem W_path_dest_right_W_path_cases_on {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {a : A P} {f : pfunctor.B (last P) a → pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) α) (g : (j : pfunctor.B (last P) a) → typevec.arrow (W_path P (f j)) α) : W_path_dest_right P (W_path_cases_on P g' g) = g :=\n  rfl\n\ntheorem W_path_cases_on_eta {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {a : A P} {f : pfunctor.B (last P) a → pfunctor.W (last P)} (h : typevec.arrow (W_path P (W_type.mk a f)) α) : W_path_cases_on P (W_path_dest_left P h) (W_path_dest_right P h) = h := sorry\n\ntheorem comp_W_path_cases_on {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {β : typevec n} (h : typevec.arrow α β) {a : A P} {f : pfunctor.B (last P) a → pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) α) (g : (j : pfunctor.B (last P) a) → typevec.arrow (W_path P (f j)) α) : typevec.comp h (W_path_cases_on P g' g) =\n  W_path_cases_on P (typevec.comp h g') fun (i : pfunctor.B (last P) a) => typevec.comp h (g i) := sorry\n\n/-- Polynomial functor for the W-type of `P`. `A` is a data-less well-founded\ntree whereas, for a given `a : A`, `B a` is a valid path in tree `a` so\nthat `Wp.obj α` is made of a tree and a function from its valid paths to\nthe values it contains  -/\ndef Wp {n : ℕ} (P : mvpfunctor (n + 1)) : mvpfunctor n :=\n  mk (pfunctor.W (last P)) (W_path P)\n\n/-- W-type of `P` -/\ndef W {n : ℕ} (P : mvpfunctor (n + 1)) (α : typevec n) :=\n  obj (Wp P) α\n\nprotected instance mvfunctor_W {n : ℕ} (P : mvpfunctor (n + 1)) : mvfunctor (W P) :=\n  id (obj.mvfunctor (Wp P))\n\n/-!\nFirst, describe operations on `W` as a polynomial functor.\n-/\n\n/-- Constructor for `Wp` -/\ndef Wp_mk {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} (a : A P) (f : pfunctor.B (last P) a → pfunctor.W (last P)) (f' : typevec.arrow (W_path P (W_type.mk a f)) α) : W P α :=\n  sigma.mk (W_type.mk a f) f'\n\n/-- Recursor for `Wp` -/\ndef Wp_rec {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {C : Type u_2} (g : (a : A P) →\n  (f : pfunctor.B (last P) a → pfunctor.W (last P)) →\n    typevec.arrow (W_path P (W_type.mk a f)) α → (pfunctor.B (last P) a → C) → C) (x : pfunctor.W (last P)) (f' : typevec.arrow (W_path P x) α) : C :=\n  sorry\n\ntheorem Wp_rec_eq {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {C : Type u_2} (g : (a : A P) →\n  (f : pfunctor.B (last P) a → pfunctor.W (last P)) →\n    typevec.arrow (W_path P (W_type.mk a f)) α → (pfunctor.B (last P) a → C) → C) (a : A P) (f : pfunctor.B (last P) a → pfunctor.W (last P)) (f' : typevec.arrow (W_path P (W_type.mk a f)) α) : Wp_rec P g (W_type.mk a f) f' = g a f f' fun (i : pfunctor.B (last P) a) => Wp_rec P g (f i) (W_path_dest_right P f' i) :=\n  rfl\n\n-- Note: we could replace Prop by Type* and obtain a dependent recursor\n\ntheorem Wp_ind {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {C : (x : pfunctor.W (last P)) → typevec.arrow (W_path P x) α → Prop} (ih : ∀ (a : A P) (f : pfunctor.B (last P) a → pfunctor.W (last P)) (f' : typevec.arrow (W_path P (W_type.mk a f)) α),\n  (∀ (i : pfunctor.B (last P) a), C (f i) (W_path_dest_right P f' i)) → C (W_type.mk a f) f') (x : pfunctor.W (last P)) (f' : typevec.arrow (W_path P x) α) : C x f' := sorry\n\n/-!\nNow think of W as defined inductively by the data ⟨a, f', f⟩ where\n- `a  : P.A` is the shape of the top node\n- `f' : P.drop.B a ⟹ α` is the contents of the top node\n- `f  : P.last.B a → P.last.W` are the subtrees\n -/\n\n/-- Constructor for `W` -/\ndef W_mk {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α) : W P α :=\n  let g : pfunctor.B (last P) a → pfunctor.W (last P) := fun (i : pfunctor.B (last P) a) => sigma.fst (f i);\n  let g' : typevec.arrow (W_path P (W_type.mk a g)) α :=\n    W_path_cases_on P f' fun (i : pfunctor.B (last P) a) => sigma.snd (f i);\n  sigma.mk (W_type.mk a g) g'\n\n/-- Recursor for `W` -/\ndef W_rec {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {C : Type u_1} (g : (a : A P) → typevec.arrow (B (drop P) a) α → (pfunctor.B (last P) a → W P α) → (pfunctor.B (last P) a → C) → C) : W P α → C :=\n  sorry\n\n/-- Defining equation for the recursor of `W` -/\ntheorem W_rec_eq {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {C : Type u_1} (g : (a : A P) → typevec.arrow (B (drop P) a) α → (pfunctor.B (last P) a → W P α) → (pfunctor.B (last P) a → C) → C) (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α) : W_rec P g (W_mk P a f' f) = g a f' f fun (i : pfunctor.B (last P) a) => W_rec P g (f i) := sorry\n\n/-- Induction principle for `W` -/\ntheorem W_ind {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {C : W P α → Prop} (ih : ∀ (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α),\n  (∀ (i : pfunctor.B (last P) a), C (f i)) → C (W_mk P a f' f)) (x : W P α) : C x := sorry\n\ntheorem W_cases {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {C : W P α → Prop} (ih : ∀ (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α), C (W_mk P a f' f)) (x : W P α) : C x :=\n  W_ind P\n    fun (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α)\n      (ih' : ∀ (i : pfunctor.B (last P) a), C (f i)) => ih a f' f\n\n/-- W-types are functorial -/\ndef W_map {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {β : typevec n} (g : typevec.arrow α β) : W P α → W P β :=\n  fun (x : W P α) => mvfunctor.map g x\n\ntheorem W_mk_eq {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} (a : A P) (f : pfunctor.B (last P) a → pfunctor.W (last P)) (g' : typevec.arrow (B (drop P) a) α) (g : (j : pfunctor.B (last P) a) → typevec.arrow (W_path P (f j)) α) : (W_mk P a g' fun (i : pfunctor.B (last P) a) => sigma.mk (f i) (g i)) =\n  sigma.mk (W_type.mk a f) (W_path_cases_on P g' g) :=\n  rfl\n\ntheorem W_map_W_mk {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {β : typevec n} (g : typevec.arrow α β) (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α) : mvfunctor.map g (W_mk P a f' f) = W_mk P a (typevec.comp g f') fun (i : pfunctor.B (last P) a) => mvfunctor.map g (f i) := sorry\n\n-- TODO: this technical theorem is used in one place in constructing the initial algebra.\n\n-- Can it be avoided?\n\n/-- Constructor of a value of `P.obj (α ::: β)` from components.\nUseful to avoid complicated type annotation -/\ndef obj_append1 {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {β : Type u} (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → β) : obj P (α ::: β) :=\n  sigma.mk a (typevec.split_fun f' f)\n\ntheorem map_obj_append1 {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {γ : typevec n} (g : typevec.arrow α γ) (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α) : mvfunctor.map (g ::: W_map P g) (obj_append1 P a f' f) =\n  obj_append1 P a (typevec.comp g f') fun (x : pfunctor.B (last P) a) => W_map P g (f x) := sorry\n\n/-!\nYet another view of the W type: as a fixed point for a multivariate polynomial functor.\nThese are needed to use the W-construction to construct a fixed point of a qpf, since\nthe qpf axioms are expressed in terms of `map` on `P`.\n-/\n\n/-- Constructor for the W-type of `P` -/\ndef W_mk' {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} : obj P (α ::: W P α) → W P α :=\n  sorry\n\n/-- Destructor for the W-type of `P` -/\ndef W_dest' {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} : W P α → obj P (α ::: W P α) :=\n  W_rec P\n    fun (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α)\n      (_x : pfunctor.B (last P) a → obj P (α ::: W P α)) => sigma.mk a (typevec.split_fun f' f)\n\ntheorem W_dest'_W_mk {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} (a : A P) (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → W P α) : W_dest' P (W_mk P a f' f) = sigma.mk a (typevec.split_fun f' f) := sorry\n\ntheorem W_dest'_W_mk' {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} (x : obj P (α ::: W P α)) : W_dest' P (W_mk' P x) = x := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/pfunctor/multivariate/W.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355188, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.48889361081537575}}
{"text": "inductive two\n| c21\n| c22\n\ninductive three\n| c31\n| c32\n| c33\n\nlemma two_has_two_elements (a b c: two): a = b ∨ b = c ∨ c = a :=\nbegin\n    cases a; cases b; cases c; repeat {refl <|> {left, refl} <|> right },\nend\n\nexample : two ≠ three :=\nbegin\n    intro,\n    have h := two_has_two_elements,\n    rw a at h,\n    have := h three.c31 three.c32 three.c33,\n    simp at this,\n    assumption,\nend\n", "meta": {"author": "zeptometer", "repo": "LearnLean", "sha": "bb84d5dbe521127ba134d4dbf9559b294a80b9f7", "save_path": "github-repos/lean/zeptometer-LearnLean", "path": "github-repos/lean/zeptometer-LearnLean/LearnLean-bb84d5dbe521127ba134d4dbf9559b294a80b9f7/bluejam/topprover/27.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.48889359882554745}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Andrew Yang\n-/\nimport category_theory.limits.shapes.terminal\nimport category_theory.limits.shapes.pullbacks\nimport category_theory.limits.shapes.binary_products\n\n/-!\n# Constructing binary product from pullbacks and terminal object.\n\nThe product is the pullback over the terminal objects. In particular, if a category\nhas pullbacks and a terminal object, then it has binary products.\n\nWe also provide the dual.\n-/\n\nuniverses v u\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u} [category.{v} C]\n\n/-- The pullback over the terminal object is the product -/\ndef is_product_of_is_terminal_is_pullback {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_terminal Z)\n  (H₂ : is_limit (pullback_cone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _))) :\n  is_limit (binary_fan.mk h k) :=\n{ lift := λ c, H₂.lift (pullback_cone.mk\n    (c.π.app ⟨walking_pair.left⟩) (c.π.app ⟨walking_pair.right⟩) (H₁.hom_ext _ _)),\n  fac' := λ c j,\n  begin\n    cases j,\n    convert H₂.fac (pullback_cone.mk (c.π.app ⟨walking_pair.left⟩)\n      (c.π.app ⟨walking_pair.right⟩) (H₁.hom_ext _ _)) (some j) using 1,\n    rcases j; refl,\n  end,\n  uniq' := λ c m hm,\n  begin\n    apply pullback_cone.is_limit.hom_ext H₂,\n    { exact (hm ⟨walking_pair.left⟩).trans (H₂.fac (pullback_cone.mk (c.π.app ⟨walking_pair.left⟩)\n        (c.π.app ⟨walking_pair.right⟩) (H₁.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm ⟨walking_pair.right⟩).trans (H₂.fac (pullback_cone.mk (c.π.app ⟨walking_pair.left⟩)\n        (c.π.app ⟨walking_pair.right⟩) (H₁.hom_ext _ _)) walking_cospan.right).symm },\n  end }\n\n/-- The product is the pullback over the terminal object. -/\ndef is_pullback_of_is_terminal_is_product {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_terminal Z)\n  (H₂ : is_limit (binary_fan.mk h k)) :\n  is_limit (pullback_cone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _)) :=\nbegin\n  apply pullback_cone.is_limit_aux',\n  intro s,\n  use H₂.lift (binary_fan.mk s.fst s.snd),\n  use H₂.fac (binary_fan.mk s.fst s.snd) ⟨walking_pair.left⟩,\n  use H₂.fac (binary_fan.mk s.fst s.snd) ⟨walking_pair.right⟩,\n  intros m h₁ h₂,\n  apply H₂.hom_ext,\n  rintro ⟨⟨⟩⟩,\n  { exact h₁.trans (H₂.fac (binary_fan.mk s.fst s.snd) ⟨walking_pair.left⟩).symm },\n  { exact h₂.trans (H₂.fac (binary_fan.mk s.fst s.snd) ⟨walking_pair.right⟩).symm }\nend\n\n/-- Any category with pullbacks and a terminal object has a limit cone for each walking pair. -/\nnoncomputable def limit_cone_of_terminal_and_pullbacks [has_terminal C] [has_pullbacks C]\n  (F : discrete walking_pair ⥤ C) : limit_cone F :=\n{ cone :=\n  { X := pullback (terminal.from (F.obj ⟨walking_pair.left⟩))\n                  (terminal.from (F.obj ⟨walking_pair.right⟩)),\n    π := discrete.nat_trans (λ x, discrete.cases_on x\n      (λ x, walking_pair.cases_on x pullback.fst pullback.snd)) },\n  is_limit :=\n  { lift := λ c, pullback.lift ((c.π).app ⟨walking_pair.left⟩)\n                                ((c.π).app ⟨walking_pair.right⟩)\n                                (subsingleton.elim _ _),\n    fac' := λ s c, discrete.cases_on c\n      (λ c, walking_pair.cases_on c (limit.lift_π _ _) (limit.lift_π _ _)),\n    uniq' := λ s m J,\n              begin\n                rw [←J, ←J],\n                ext;\n                rw limit.lift_π;\n                refl\n              end } }\n\nvariable (C)\n\n/-- Any category with pullbacks and terminal object has binary products. -/\n-- This is not an instance, as it is not always how one wants to construct binary products!\nlemma has_binary_products_of_terminal_and_pullbacks\n  [has_terminal C] [has_pullbacks C] :\n  has_binary_products C :=\n{ has_limit := λ F, has_limit.mk (limit_cone_of_terminal_and_pullbacks F) }\n\n/-- In a category with a terminal object and pullbacks,\na product of objects `X` and `Y` is isomorphic to a pullback. -/\nnoncomputable\ndef prod_iso_pullback [has_terminal C] [has_pullbacks C] (X Y : C) [has_binary_product X Y] :\n  X ⨯ Y ≅ pullback (terminal.from X) (terminal.from Y) :=\nlimit.iso_limit_cone (limit_cone_of_terminal_and_pullbacks _)\n\nvariable {C}\n\n/-- The pushout under the initial object is the coproduct -/\ndef is_coproduct_of_is_initial_is_pushout {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_initial W)\n  (H₂ : is_colimit (pushout_cocone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _))) :\n  is_colimit (binary_cofan.mk f g) :=\n{ desc := λ c, H₂.desc (pushout_cocone.mk\n    (c.ι.app ⟨walking_pair.left⟩) (c.ι.app ⟨walking_pair.right⟩) (H₁.hom_ext _ _)),\n  fac' := λ c j,\n  begin\n    cases j,\n    convert H₂.fac (pushout_cocone.mk (c.ι.app ⟨walking_pair.left⟩) (c.ι.app ⟨walking_pair.right⟩)\n      (H₁.hom_ext _ _)) (some j) using 1,\n    cases j; refl\n  end,\n  uniq' := λ c m hm,\n  begin\n    apply pushout_cocone.is_colimit.hom_ext H₂,\n    { exact (hm ⟨walking_pair.left⟩).trans (H₂.fac (pushout_cocone.mk (c.ι.app ⟨walking_pair.left⟩)\n        (c.ι.app ⟨walking_pair.right⟩) (H₁.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm ⟨walking_pair.right⟩).trans (H₂.fac (pushout_cocone.mk (c.ι.app ⟨walking_pair.left⟩)\n        (c.ι.app ⟨walking_pair.right⟩) (H₁.hom_ext _ _)) walking_cospan.right).symm },\n  end }\n\n/-- The coproduct is the pushout under the initial object. -/\ndef is_pushout_of_is_initial_is_coproduct {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_initial W)\n  (H₂ : is_colimit (binary_cofan.mk f g)) :\n  is_colimit (pushout_cocone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _)) :=\nbegin\n  apply pushout_cocone.is_colimit_aux',\n  intro s,\n  use H₂.desc (binary_cofan.mk s.inl s.inr),\n  use H₂.fac (binary_cofan.mk s.inl s.inr) ⟨walking_pair.left⟩,\n  use H₂.fac (binary_cofan.mk s.inl s.inr) ⟨walking_pair.right⟩,\n  intros m h₁ h₂,\n  apply H₂.hom_ext,\n  rintro ⟨⟨⟩⟩,\n  { exact h₁.trans (H₂.fac (binary_cofan.mk s.inl s.inr) ⟨walking_pair.left⟩).symm },\n  { exact h₂.trans (H₂.fac (binary_cofan.mk s.inl s.inr) ⟨walking_pair.right⟩).symm }\nend\n\n/-- Any category with pushouts and an initial object has a colimit cocone for each walking pair. -/\nnoncomputable def colimit_cocone_of_initial_and_pushouts [has_initial C] [has_pushouts C]\n  (F : discrete walking_pair ⥤ C) : colimit_cocone F :=\n{ cocone :=\n  { X := pushout (initial.to (F.obj ⟨walking_pair.left⟩))\n                  (initial.to (F.obj ⟨walking_pair.right⟩)),\n    ι := discrete.nat_trans (λ x, discrete.cases_on x\n      (λ x, walking_pair.cases_on x pushout.inl pushout.inr)) },\n  is_colimit :=\n  { desc := λ c, pushout.desc (c.ι.app ⟨walking_pair.left⟩)\n                              (c.ι.app ⟨walking_pair.right⟩)\n                              (subsingleton.elim _ _),\n    fac' := λ s c, discrete.cases_on c\n      (λ c, walking_pair.cases_on c (colimit.ι_desc _ _) (colimit.ι_desc _ _)),\n    uniq' := λ s m J,\n              begin\n                rw [←J, ←J],\n                ext;\n                rw colimit.ι_desc;\n                refl\n              end } }\n\nvariable (C)\n\n/-- Any category with pushouts and initial object has binary coproducts. -/\n-- This is not an instance, as it is not always how one wants to construct binary coproducts!\nlemma has_binary_coproducts_of_initial_and_pushouts\n  [has_initial C] [has_pushouts C] :\n  has_binary_coproducts C :=\n{ has_colimit := λ F, has_colimit.mk (colimit_cocone_of_initial_and_pushouts F) }\n\n/-- In a category with an initial object and pushouts,\na coproduct of objects `X` and `Y` is isomorphic to a pushout. -/\nnoncomputable\ndef coprod_iso_pushout [has_initial C] [has_pushouts C] (X Y : C) [has_binary_coproduct X Y] :\n  X ⨿ Y ≅ pushout (initial.to X) (initial.to Y) :=\ncolimit.iso_colimit_cocone (colimit_cocone_of_initial_and_pushouts _)\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/constructions/binary_products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.705785040214066, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4888563454427844}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport analysis.convex.basic\nimport topology.algebra.order.basic\n\n/-!\n# Strictly convex sets\n\nThis file defines strictly convex sets.\n\nA set is strictly convex if the open segment between any two distinct points lies in its interior.\n-/\n\nopen set\nopen_locale convex pointwise\n\nvariables {𝕜 𝕝 E F β : Type*}\n\nopen function set\nopen_locale convex\n\nsection ordered_semiring\nvariables [ordered_semiring 𝕜] [topological_space E] [topological_space F]\n\nsection add_comm_monoid\nvariables [add_comm_monoid E] [add_comm_monoid F]\n\nsection has_scalar\nvariables (𝕜) [has_scalar 𝕜 E] [has_scalar 𝕜 F] (s : set E)\n\n/-- A set is strictly convex if the open segment between any two distinct points lies is in its\ninterior. This basically means \"convex and not flat on the boundary\". -/\ndef strict_convex : Prop :=\ns.pairwise $ λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 → a • x + b • y ∈ interior s\n\nvariables {𝕜 s} {x y : E}\n\nlemma strict_convex_iff_open_segment_subset :\n  strict_convex 𝕜 s ↔ s.pairwise (λ x y, open_segment 𝕜 x y ⊆ interior s) :=\nforall₅_congr $ λ x hx y hy hxy, (open_segment_subset_iff 𝕜).symm\n\nlemma strict_convex.open_segment_subset (hs : strict_convex 𝕜 s) (hx : x ∈ s) (hy : y ∈ s)\n  (h : x ≠ y) :\n  open_segment 𝕜 x y ⊆ interior s :=\nstrict_convex_iff_open_segment_subset.1 hs hx hy h\n\nlemma strict_convex_empty : strict_convex 𝕜 (∅ : set E) := pairwise_empty _\n\nlemma strict_convex_univ : strict_convex 𝕜 (univ : set E) :=\nbegin\n  intros x hx y hy hxy a b ha hb hab,\n  rw interior_univ,\n  exact mem_univ _,\nend\n\nprotected lemma strict_convex.inter {t : set E} (hs : strict_convex 𝕜 s) (ht : strict_convex 𝕜 t) :\n  strict_convex 𝕜 (s ∩ t) :=\nbegin\n  intros x hx y hy hxy a b ha hb hab,\n  rw interior_inter,\n  exact ⟨hs hx.1 hy.1 hxy ha hb hab, ht hx.2 hy.2 hxy ha hb hab⟩,\nend\n\nlemma directed.strict_convex_Union {ι : Sort*} {s : ι → set E} (hdir : directed (⊆) s)\n  (hs : ∀ ⦃i : ι⦄, strict_convex 𝕜 (s i)) :\n  strict_convex 𝕜 (⋃ i, s i) :=\nbegin\n  rintro x hx y hy hxy a b ha hb hab,\n  rw mem_Union at hx hy,\n  obtain ⟨i, hx⟩ := hx,\n  obtain ⟨j, hy⟩ := hy,\n  obtain ⟨k, hik, hjk⟩ := hdir i j,\n  exact interior_mono (subset_Union s k) (hs (hik hx) (hjk hy) hxy ha hb hab),\nend\n\nlemma directed_on.strict_convex_sUnion {S : set (set E)} (hdir : directed_on (⊆) S)\n  (hS : ∀ s ∈ S, strict_convex 𝕜 s) :\n  strict_convex 𝕜 (⋃₀ S) :=\nbegin\n  rw sUnion_eq_Union,\n  exact (directed_on_iff_directed.1 hdir).strict_convex_Union (λ s, hS _ s.2),\nend\n\nend has_scalar\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 F] {s : set E}\n\nprotected lemma strict_convex.convex (hs : strict_convex 𝕜 s) : convex 𝕜 s :=\nconvex_iff_pairwise_pos.2 $ λ x hx y hy hxy a b ha hb hab, interior_subset $ hs hx hy hxy ha hb hab\n\n/-- An open convex set is strictly convex. -/\nprotected lemma convex.strict_convex (h : is_open s) (hs : convex 𝕜 s) : strict_convex 𝕜 s :=\nλ x hx y hy _ a b ha hb hab, h.interior_eq.symm ▸ hs hx hy ha.le hb.le hab\n\nlemma is_open.strict_convex_iff (h : is_open s) : strict_convex 𝕜 s ↔ convex 𝕜 s :=\n⟨strict_convex.convex, convex.strict_convex h⟩\n\nlemma strict_convex_singleton (c : E) : strict_convex 𝕜 ({c} : set E) := pairwise_singleton _ _\n\nlemma set.subsingleton.strict_convex (hs : s.subsingleton) : strict_convex 𝕜 s := hs.pairwise _\n\nlemma strict_convex.linear_image [semiring 𝕝] [module 𝕝 E] [module 𝕝 F]\n  [linear_map.compatible_smul E F 𝕜 𝕝] (hs : strict_convex 𝕜 s) (f : E →ₗ[𝕝] F)\n  (hf : is_open_map f) :\n  strict_convex 𝕜 (f '' s) :=\nbegin\n  rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ hxy a b ha hb hab,\n  refine hf.image_interior_subset _ ⟨a • x + b • y, hs hx hy (ne_of_apply_ne _ hxy) ha hb hab, _⟩,\n  rw [map_add, f.map_smul_of_tower a, f.map_smul_of_tower b]\nend\n\nlemma strict_convex.is_linear_image (hs : strict_convex 𝕜 s) {f : E → F} (h : is_linear_map 𝕜 f)\n  (hf : is_open_map f) :\n  strict_convex 𝕜 (f '' s) :=\nhs.linear_image (h.mk' f) hf\n\nlemma strict_convex.linear_preimage {s : set F} (hs : strict_convex 𝕜 s) (f : E →ₗ[𝕜] F)\n  (hf : continuous f) (hfinj : injective f) :\n  strict_convex 𝕜 (s.preimage f) :=\nbegin\n  intros x hx y hy hxy a b ha hb hab,\n  refine preimage_interior_subset_interior_preimage hf _,\n  rw [mem_preimage, f.map_add, f.map_smul, f.map_smul],\n  exact hs hx hy (hfinj.ne hxy) ha hb hab,\nend\n\nlemma strict_convex.is_linear_preimage {s : set F} (hs : strict_convex 𝕜 s) {f : E → F}\n  (h : is_linear_map 𝕜 f) (hf : continuous f) (hfinj : injective f) :\n  strict_convex 𝕜 (s.preimage f) :=\nhs.linear_preimage (h.mk' f) hf hfinj\n\nsection linear_ordered_cancel_add_comm_monoid\nvariables [topological_space β] [linear_ordered_cancel_add_comm_monoid β] [order_topology β]\n  [module 𝕜 β] [ordered_smul 𝕜 β]\n\nlemma strict_convex_Iic (r : β) : strict_convex 𝕜 (Iic r) :=\nbegin\n  rintro x (hx : x ≤ r) y (hy : y ≤ r) hxy a b ha hb hab,\n  refine (subset_interior_iff_subset_of_open is_open_Iio).2 Iio_subset_Iic_self _,\n  rw ←convex.combo_self hab r,\n  obtain rfl | hx := hx.eq_or_lt,\n  { exact add_lt_add_left (smul_lt_smul_of_pos (hy.lt_of_ne hxy.symm) hb) _ },\n  obtain rfl | hy := hy.eq_or_lt,\n  { exact add_lt_add_right (smul_lt_smul_of_pos hx ha) _ },\n  { exact add_lt_add (smul_lt_smul_of_pos hx ha) (smul_lt_smul_of_pos hy hb) }\nend\n\nlemma strict_convex_Ici (r : β) : strict_convex 𝕜 (Ici r) :=\n@strict_convex_Iic 𝕜 (order_dual β) _ _ _ _ _ _ r\n\nlemma strict_convex_Icc (r s : β) : strict_convex 𝕜 (Icc r s) :=\n(strict_convex_Ici r).inter $ strict_convex_Iic s\n\nlemma strict_convex_Iio (r : β) : strict_convex 𝕜 (Iio r) :=\n(convex_Iio r).strict_convex is_open_Iio\n\nlemma strict_convex_Ioi (r : β) : strict_convex 𝕜 (Ioi r) :=\n(convex_Ioi r).strict_convex is_open_Ioi\n\nlemma strict_convex_Ioo (r s : β) : strict_convex 𝕜 (Ioo r s) :=\n(strict_convex_Ioi r).inter $ strict_convex_Iio s\n\nlemma strict_convex_Ico (r s : β) : strict_convex 𝕜 (Ico r s) :=\n(strict_convex_Ici r).inter $ strict_convex_Iio s\n\nlemma strict_convex_Ioc (r s : β) : strict_convex 𝕜 (Ioc r s) :=\n(strict_convex_Ioi r).inter $ strict_convex_Iic s\n\nlemma strict_convex_interval (r s : β) : strict_convex 𝕜 (interval r s) :=\nstrict_convex_Icc _ _\n\nend linear_ordered_cancel_add_comm_monoid\nend module\nend add_comm_monoid\n\nsection add_cancel_comm_monoid\nvariables [add_cancel_comm_monoid E] [has_continuous_add E] [module 𝕜 E] {s : set E}\n\n/-- The translation of a strictly convex set is also strictly convex. -/\nlemma strict_convex.preimage_add_right (hs : strict_convex 𝕜 s) (z : E) :\n  strict_convex 𝕜 ((λ x, z + x) ⁻¹' s) :=\nbegin\n  intros x hx y hy hxy a b ha hb hab,\n  refine preimage_interior_subset_interior_preimage (continuous_add_left _) _,\n  have h := hs hx hy ((add_right_injective _).ne hxy) ha hb hab,\n  rwa [smul_add, smul_add, add_add_add_comm, ←add_smul, hab, one_smul] at h,\nend\n\n/-- The translation of a strictly convex set is also strictly convex. -/\nlemma strict_convex.preimage_add_left (hs : strict_convex 𝕜 s) (z : E) :\n  strict_convex 𝕜 ((λ x, x + z) ⁻¹' s) :=\nby simpa only [add_comm] using hs.preimage_add_right z\n\nend add_cancel_comm_monoid\n\nsection add_comm_group\nvariables [add_comm_group E] [add_comm_group F] [module 𝕜 E] [module 𝕜 F]\n\nsection continuous_add\nvariables [has_continuous_add E] {s t : set E}\n\nlemma strict_convex.add (hs : strict_convex 𝕜 s) (ht : strict_convex 𝕜 t) :\n  strict_convex 𝕜 (s + t) :=\nbegin\n  rintro _ ⟨v, w, hv, hw, rfl⟩ _ ⟨x, y, hx, hy, rfl⟩ h a b ha hb hab,\n  rw [smul_add, smul_add, add_add_add_comm],\n  obtain rfl | hvx := eq_or_ne v x,\n  { refine interior_mono (add_subset_add (singleton_subset_iff.2 hv) subset.rfl) _,\n    rw [convex.combo_self hab, singleton_add],\n    exact (is_open_map_add_left _).image_interior_subset _\n      (mem_image_of_mem _ $ ht hw hy (ne_of_apply_ne _ h) ha hb hab) },\n  exact subset_interior_add_left (add_mem_add (hs hv hx hvx ha hb hab) $\n    ht.convex hw hy ha.le hb.le hab)\nend\n\nlemma strict_convex.add_left (hs : strict_convex 𝕜 s) (z : E) :\n  strict_convex 𝕜 ((λ x, z + x) '' s) :=\nby simpa only [singleton_add] using (strict_convex_singleton z).add hs\n\nlemma strict_convex.add_right (hs : strict_convex 𝕜 s) (z : E) :\n  strict_convex 𝕜 ((λ x, x + z) '' s) :=\nby simpa only [add_comm] using hs.add_left z\n\n/-- The translation of a strictly convex set is also strictly convex. -/\nlemma strict_convex.vadd (hs : strict_convex 𝕜 s) (x : E) : strict_convex 𝕜 (x +ᵥ s) :=\nhs.add_left x\n\nend continuous_add\n\nsection continuous_smul\nvariables [linear_ordered_field 𝕝] [module 𝕝 E] [has_continuous_const_smul 𝕝 E]\n  [linear_map.compatible_smul E E 𝕜 𝕝] {s : set E} {x : E}\n\nlemma strict_convex.smul (hs : strict_convex 𝕜 s) (c : 𝕝) : strict_convex 𝕜 (c • s) :=\nbegin\n  obtain rfl | hc := eq_or_ne c 0,\n  { exact (subsingleton_zero_smul_set _).strict_convex },\n  { exact hs.linear_image (linear_map.lsmul _ _ c) (is_open_map_smul₀ hc) }\nend\n\nlemma strict_convex.affinity [has_continuous_add E] (hs : strict_convex 𝕜 s) (z : E) (c : 𝕝) :\n  strict_convex 𝕜 (z +ᵥ c • s) :=\n(hs.smul c).vadd z\n\nend continuous_smul\nend add_comm_group\nend ordered_semiring\n\nsection ordered_comm_semiring\nvariables [ordered_comm_semiring 𝕜] [topological_space E]\n\nsection add_comm_group\nvariables [add_comm_group E] [module 𝕜 E] [no_zero_smul_divisors 𝕜 E]\n  [has_continuous_const_smul 𝕜 E] {s : set E}\n\nlemma strict_convex.preimage_smul (hs : strict_convex 𝕜 s) (c : 𝕜) :\n  strict_convex 𝕜 ((λ z, c • z) ⁻¹' s) :=\nbegin\n  classical,\n  obtain rfl | hc := eq_or_ne c 0,\n  { simp_rw [zero_smul, preimage_const],\n    split_ifs,\n    { exact strict_convex_univ },\n    { exact strict_convex_empty } },\n  refine hs.linear_preimage (linear_map.lsmul _ _ c) _ (smul_right_injective E hc),\n  unfold linear_map.lsmul linear_map.mk₂ linear_map.mk₂' linear_map.mk₂'ₛₗ,\n  exact continuous_const_smul _,\nend\n\nend add_comm_group\nend ordered_comm_semiring\n\nsection ordered_ring\nvariables [ordered_ring 𝕜] [topological_space E] [topological_space F]\n\nsection add_comm_group\nvariables [add_comm_group E] [add_comm_group F] [module 𝕜 E] [module 𝕜 F] {s : set E} {x y : E}\n\nlemma strict_convex.eq_of_open_segment_subset_frontier [nontrivial 𝕜] [densely_ordered 𝕜]\n  (hs : strict_convex 𝕜 s) (hx : x ∈ s) (hy : y ∈ s) (h : open_segment 𝕜 x y ⊆ frontier s) :\n  x = y :=\nbegin\n  obtain ⟨a, ha₀, ha₁⟩ := densely_ordered.dense (0 : 𝕜) 1 zero_lt_one,\n  classical,\n  by_contra hxy,\n  exact (h ⟨a, 1 - a, ha₀, sub_pos_of_lt ha₁, add_sub_cancel'_right _ _, rfl⟩).2\n    (hs hx hy hxy ha₀ (sub_pos_of_lt ha₁) $ add_sub_cancel'_right _ _),\nend\n\nlemma strict_convex.add_smul_mem (hs : strict_convex 𝕜 s) (hx : x ∈ s) (hxy : x + y ∈ s)\n  (hy : y ≠ 0) {t : 𝕜} (ht₀ : 0 < t) (ht₁ : t < 1) :\n  x + t • y ∈ interior s :=\nbegin\n  have h : x + t • y = (1 - t) • x + t • (x + y),\n  { rw [smul_add, ←add_assoc, ←add_smul, sub_add_cancel, one_smul] },\n  rw h,\n  refine hs hx hxy (λ h, hy $ add_left_cancel _) (sub_pos_of_lt ht₁) ht₀ (sub_add_cancel _ _),\n  exact x,\n  rw [←h, add_zero],\nend\n\nlemma strict_convex.smul_mem_of_zero_mem (hs : strict_convex 𝕜 s) (zero_mem : (0 : E) ∈ s)\n  (hx : x ∈ s) (hx₀ : x ≠ 0) {t : 𝕜} (ht₀ : 0 < t) (ht₁ : t < 1) :\n  t • x ∈ interior s :=\nby simpa using hs.add_smul_mem zero_mem (by simpa using hx) hx₀ ht₀ ht₁\n\nlemma strict_convex.add_smul_sub_mem (h : strict_convex 𝕜 s) (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y)\n  {t : 𝕜} (ht₀ : 0 < t) (ht₁ : t < 1) : x + t • (y - x) ∈ interior s :=\nbegin\n  apply h.open_segment_subset hx hy hxy,\n  rw open_segment_eq_image',\n  exact mem_image_of_mem _ ⟨ht₀, ht₁⟩,\nend\n\n/-- The preimage of a strictly convex set under an affine map is strictly convex. -/\nlemma strict_convex.affine_preimage {s : set F} (hs : strict_convex 𝕜 s) {f : E →ᵃ[𝕜] F}\n  (hf : continuous f) (hfinj : injective f) :\n  strict_convex 𝕜 (f ⁻¹' s) :=\nbegin\n  intros x hx y hy hxy a b ha hb hab,\n  refine preimage_interior_subset_interior_preimage hf _,\n  rw [mem_preimage, convex.combo_affine_apply hab],\n  exact hs hx hy (hfinj.ne hxy) ha hb hab,\nend\n\n/-- The image of a strictly convex set under an affine map is strictly convex. -/\nlemma strict_convex.affine_image (hs : strict_convex 𝕜 s) {f : E →ᵃ[𝕜] F} (hf : is_open_map f) :\n  strict_convex 𝕜 (f '' s) :=\nbegin\n  rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ hxy a b ha hb hab,\n  exact hf.image_interior_subset _ ⟨a • x + b • y, ⟨hs hx hy (ne_of_apply_ne _ hxy) ha hb hab,\n    convex.combo_affine_apply hab⟩⟩,\nend\n\nlemma strict_convex.neg [topological_add_group E] (hs : strict_convex 𝕜 s) :\n  strict_convex 𝕜 ((λ z, -z) '' s) :=\nhs.is_linear_image is_linear_map.is_linear_map_neg (homeomorph.neg E).is_open_map\n\nlemma strict_convex.neg_preimage [topological_add_group E] (hs : strict_convex 𝕜 s) :\n  strict_convex 𝕜 ((λ z, -z) ⁻¹' s) :=\nhs.is_linear_preimage is_linear_map.is_linear_map_neg continuous_id.neg neg_injective\n\nend add_comm_group\nend ordered_ring\n\nsection linear_ordered_field\nvariables [linear_ordered_field 𝕜] [topological_space E]\n\nsection add_comm_group\nvariables [add_comm_group E] [add_comm_group F] [module 𝕜 E] [module 𝕜 F] {s : set E} {x : E}\n\n/-- Alternative definition of set strict convexity, using division. -/\nlemma strict_convex_iff_div :\n  strict_convex 𝕜 s ↔ s.pairwise\n    (λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → (a / (a + b)) • x + (b / (a + b)) • y ∈ interior s) :=\n⟨λ h x hx y hy hxy a b ha hb, begin\n  apply h hx hy hxy (div_pos ha $ add_pos ha hb) (div_pos hb $ add_pos ha hb),\n  rw ←add_div,\n  exact div_self (add_pos ha hb).ne',\nend, λ h x hx y hy hxy a b ha hb hab, by convert h hx hy hxy ha hb; rw [hab, div_one] ⟩\n\nlemma strict_convex.mem_smul_of_zero_mem (hs : strict_convex 𝕜 s) (zero_mem : (0 : E) ∈ s)\n  (hx : x ∈ s) (hx₀ : x ≠ 0) {t : 𝕜} (ht : 1 < t) :\n  x ∈ t • interior s :=\nbegin\n  rw mem_smul_set_iff_inv_smul_mem₀ (zero_lt_one.trans ht).ne',\n  exact hs.smul_mem_of_zero_mem zero_mem hx hx₀ (inv_pos.2 $ zero_lt_one.trans ht)  (inv_lt_one ht),\nend\n\nend add_comm_group\nend linear_ordered_field\n\n/-!\n#### Convex sets in an ordered space\n\nRelates `convex` and `set.ord_connected`.\n-/\n\nsection\nvariables [topological_space E]\n\n/-- A set in a linear ordered field is strictly convex if and only if it is convex. -/\n@[simp] lemma strict_convex_iff_convex [linear_ordered_field 𝕜] [topological_space 𝕜]\n  [order_topology 𝕜] {s : set 𝕜} :\n  strict_convex 𝕜 s ↔ convex 𝕜 s :=\nbegin\n  refine ⟨strict_convex.convex, λ hs, strict_convex_iff_open_segment_subset.2 (λ x hx y hy hxy, _)⟩,\n  obtain h | h := hxy.lt_or_lt,\n  { refine (open_segment_subset_Ioo h).trans _,\n    rw ←interior_Icc,\n    exact interior_mono (Icc_subset_segment.trans $ hs.segment_subset hx hy) },\n  { rw open_segment_symm,\n    refine (open_segment_subset_Ioo h).trans _,\n    rw ←interior_Icc,\n    exact interior_mono (Icc_subset_segment.trans $ hs.segment_subset hy hx) }\nend\n\nlemma strict_convex_iff_ord_connected [linear_ordered_field 𝕜] [topological_space 𝕜]\n  [order_topology 𝕜] {s : set 𝕜} :\n  strict_convex 𝕜 s ↔ s.ord_connected :=\nstrict_convex_iff_convex.trans convex_iff_ord_connected\n\nalias strict_convex_iff_ord_connected ↔ strict_convex.ord_connected _\n\nend\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/analysis/convex/strict.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.4888563413478325}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.data.subtype.basic\nimport Mathlib.Lean3Lib.init.funext\n \n\nuniverses u v \n\nnamespace Mathlib\n\nnamespace classical\n\n\n/- the axiom -/\n\naxiom choice {α : Sort u} : Nonempty α → αtheorem indefinite_description {α : Sort u} (p : α → Prop) (h : ∃ (x : α), p x) : Subtype fun (x : α) => p x := sorry\n\ndef some {α : Sort u} {p : α → Prop} (h : ∃ (x : α), p x) : α :=\n  subtype.val (indefinite_description p h)\n\ntheorem some_spec {α : Sort u} {p : α → Prop} (h : ∃ (x : α), p x) : p (some h) :=\n  subtype.property (indefinite_description p h)\n\n/- Diaconescu's theorem: using function extensionality and propositional extensionality,\n   we can get excluded middle from this. -/\n\n/- TODO(Leo): check why the code generator is not ignoring (some exU)\n   when we mark u as def. -/\n\ntheorem em (p : Prop) : p ∨ ¬p :=\n  or.elim (not_uv_or_p p) (fun (hne : u p ≠ v p) => Or.inr (mt (p_implies_uv p) hne)) Or.inl\n\ntheorem exists_true_of_nonempty {α : Sort u} : Nonempty α → ∃ (x : α), True :=\n  fun (ᾰ : Nonempty α) => nonempty.dcases_on ᾰ fun (ᾰ : α) => idRhs (∃ (x : α), True) (Exists.intro ᾰ trivial)\n\ndef inhabited_of_nonempty {α : Sort u} (h : Nonempty α) : Inhabited α :=\n  { default := Classical.choice h }\n\ndef inhabited_of_exists {α : Sort u} {p : α → Prop} (h : ∃ (x : α), p x) : Inhabited α :=\n  inhabited_of_nonempty sorry\n\n/- all propositions are decidable -/\n\ndef prop_decidable (a : Prop) : Decidable a :=\n  Classical.choice sorry\n\ndef decidable_inhabited (a : Prop) : Inhabited (Decidable a) :=\n  { default := prop_decidable a }\n\ndef type_decidable_eq (α : Sort u) : DecidableEq α :=\n  fun (x y : α) => prop_decidable (x = y)\n\ndef type_decidable (α : Sort u) : psum α (α → False) :=\n  sorry\n\ntheorem strong_indefinite_description {α : Sort u} (p : α → Prop) (h : Nonempty α) : Subtype fun (x : α) => (∃ (y : α), p y) → p x := sorry\n\n/- the Hilbert epsilon function -/\n\ndef epsilon {α : Sort u} [h : Nonempty α] (p : α → Prop) : α :=\n  subtype.val (strong_indefinite_description p h)\n\ntheorem epsilon_spec_aux {α : Sort u} (h : Nonempty α) (p : α → Prop) : (∃ (y : α), p y) → p (epsilon p) :=\n  subtype.property (strong_indefinite_description p h)\n\ntheorem epsilon_spec {α : Sort u} {p : α → Prop} (hex : ∃ (y : α), p y) : p (epsilon p) :=\n  epsilon_spec_aux (nonempty_of_exists hex) p hex\n\ntheorem epsilon_singleton {α : Sort u} (x : α) : (epsilon fun (y : α) => y = x) = x :=\n  epsilon_spec (Exists.intro x rfl)\n\n/- the axiom of choice -/\n\ntheorem axiom_of_choice {α : Sort u} {β : α → Sort v} {r : (x : α) → β x → Prop} (h : ∀ (x : α), ∃ (y : β x), r x y) : ∃ (f : (x : α) → β x), ∀ (x : α), r x (f x) :=\n  Exists.intro (fun (x : α) => some (h x)) fun (x : α) => some_spec (h x)\n\ntheorem skolem {α : Sort u} {b : α → Sort v} {p : (x : α) → b x → Prop} : (∀ (x : α), ∃ (y : b x), p x y) ↔ ∃ (f : (x : α) → b x), ∀ (x : α), p x (f x) := sorry\n\ntheorem prop_complete (a : Prop) : a = True ∨ a = False :=\n  or.elim (em a) (fun (t : a) => Or.inl (eq_true_intro t)) fun (f : ¬a) => Or.inr (eq_false_intro f)\n\ndef eq_true_or_eq_false (a : Prop) : a = True ∨ a = False :=\n  prop_complete\n\ntheorem cases_true_false (p : Prop → Prop) (h1 : p True) (h2 : p False) (a : Prop) : p a :=\n  or.elim (prop_complete a) (fun (ht : a = True) => Eq.symm ht ▸ h1) fun (hf : a = False) => Eq.symm hf ▸ h2\n\ntheorem cases_on (a : Prop) {p : Prop → Prop} (h1 : p True) (h2 : p False) : p a :=\n  cases_true_false p h1 h2 a\n\n-- this supercedes by_cases in decidable\n\ndef by_cases {p : Prop} {q : Prop} (hpq : p → q) (hnpq : ¬p → q) : q :=\n  decidable.by_cases hpq hnpq\n\n-- this supercedes by_contradiction in decidable\n\ntheorem by_contradiction {p : Prop} (h : ¬p → False) : p :=\n  decidable.by_contradiction h\n\ntheorem eq_false_or_eq_true (a : Prop) : a = False ∨ a = True :=\n  or.symm (prop_complete a)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/classical.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.48885633706139847}}
{"text": "/-\nCopyright (c) 2019 Alexander Bentkamp. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alexander Bentkamp, François Dupuis\n-/\nimport analysis.convex.basic\nimport tactic.field_simp\nimport tactic.linarith\nimport tactic.ring\n\n/-!\n# Convex and concave functions\n\nThis file defines convex and concave functions in vector spaces and proves the finite Jensen\ninequality. The integral version can be found in `analysis.convex.integral`.\n\nA function `f : E → β` is `convex_on` a set `s` if `s` is itself a convex set, and for any two\npoints `x y ∈ s`, the segment joining `(x, f x)` to `(y, f y)` is above the graph of `f`.\nEquivalently, `convex_on 𝕜 f s` means that the epigraph `{p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2}` is\na convex set.\n\n## Main declarations\n\n* `convex_on 𝕜 s f`: The function `f` is convex on `s` with scalars `𝕜`.\n* `concave_on 𝕜 s f`: The function `f` is concave on `s` with scalars `𝕜`.\n* `strict_convex_on 𝕜 s f`: The function `f` is strictly convex on `s` with scalars `𝕜`.\n* `strict_concave_on 𝕜 s f`: The function `f` is strictly concave on `s` with scalars `𝕜`.\n-/\n\nopen finset linear_map set\nopen_locale big_operators classical convex pointwise\n\nvariables {𝕜 E F β ι : Type*}\n\nsection ordered_semiring\nvariables [ordered_semiring 𝕜]\n\nsection add_comm_monoid\nvariables [add_comm_monoid E] [add_comm_monoid F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection has_smul\nvariables (𝕜) [has_smul 𝕜 E] [has_smul 𝕜 β] (s : set E) (f : E → β)\n\n/-- Convexity of functions -/\ndef convex_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 →\n    f (a • x + b • y) ≤ a • f x + b • f y\n\n/-- Concavity of functions -/\ndef concave_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 →\n    a • f x + b • f y ≤ f (a • x + b • y)\n\n/-- Strict convexity of functions -/\ndef strict_convex_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) < a • f x + b • f y\n\n/-- Strict concavity of functions -/\ndef strict_concave_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    a • f x + b • f y < f (a • x + b • y)\n\nvariables {𝕜 s f}\n\nopen order_dual (to_dual of_dual)\n\nlemma convex_on.dual (hf : convex_on 𝕜 s f) : concave_on 𝕜 s (to_dual ∘ f) := hf\n\nlemma concave_on.dual (hf : concave_on 𝕜 s f) : convex_on 𝕜 s (to_dual ∘ f) := hf\n\nlemma strict_convex_on.dual (hf : strict_convex_on 𝕜 s f) : strict_concave_on 𝕜 s (to_dual ∘ f) :=\nhf\n\nlemma strict_concave_on.dual (hf : strict_concave_on 𝕜 s f) : strict_convex_on 𝕜 s (to_dual ∘ f) :=\nhf\n\nlemma convex_on_id {s : set β} (hs : convex 𝕜 s) : convex_on 𝕜 s id := ⟨hs, by { intros, refl }⟩\n\nlemma concave_on_id {s : set β} (hs : convex 𝕜 s) : concave_on 𝕜 s id := ⟨hs, by { intros, refl }⟩\n\nlemma convex_on.subset {t : set E} (hf : convex_on 𝕜 t f) (hst : s ⊆ t) (hs : convex 𝕜 s) :\n  convex_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma concave_on.subset {t : set E} (hf : concave_on 𝕜 t f) (hst : s ⊆ t) (hs : convex 𝕜 s) :\n  concave_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma strict_convex_on.subset {t : set E} (hf : strict_convex_on 𝕜 t f) (hst : s ⊆ t)\n  (hs : convex 𝕜 s) :\n  strict_convex_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma strict_concave_on.subset {t : set E} (hf : strict_concave_on 𝕜 t f) (hst : s ⊆ t)\n  (hs : convex 𝕜 s) :\n  strict_concave_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nend has_smul\n\nsection distrib_mul_action\nvariables [has_smul 𝕜 E] [distrib_mul_action 𝕜 β] {s : set E} {f g : E → β}\n\nlemma convex_on.add (hf : convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) ≤ (a • f x + b • f y) + (a • g x + b • g y)\n      : add_le_add (hf.2 hx hy ha hb hab) (hg.2 hx hy ha hb hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma concave_on.add (hf : concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  concave_on 𝕜 s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [has_smul 𝕜 E] [module 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on_const (c : β) (hs : convex 𝕜 s) : convex_on 𝕜 s (λ x:E, c) :=\n⟨hs, λ x y _ _ a b _ _ hab, (convex.combo_self hab c).ge⟩\n\nlemma concave_on_const (c : β) (hs : convex 𝕜 s) : concave_on 𝕜 s (λ x:E, c) :=\n@convex_on_const _ _ βᵒᵈ _ _ _ _ _ _ c hs\n\nlemma convex_on_of_convex_epigraph (h : convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2}) :\n  convex_on 𝕜 s f :=\n⟨λ x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) ⟨hx, le_rfl⟩ ⟨hy, le_rfl⟩ a b ha hb hab).1,\n  λ x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) ⟨hx, le_rfl⟩ ⟨hy, le_rfl⟩ a b ha hb hab).2⟩\n\nlemma concave_on_of_convex_hypograph (h : convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1}) :\n  concave_on 𝕜 s f :=\n@convex_on_of_convex_epigraph 𝕜  E βᵒᵈ _ _ _ _ _ _ _ h\n\nend module\n\nsection ordered_smul\nvariables [has_smul 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.convex_le (hf : convex_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | f x ≤ r} :=\nλ x y hx hy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha hb hab,\n  calc\n    f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx.1 hy.1 ha hb hab\n                  ... ≤ a • r + b • r     : add_le_add (smul_le_smul_of_nonneg hx.2 ha)\n                                              (smul_le_smul_of_nonneg hy.2 hb)\n                  ... = r                 : convex.combo_self hab r⟩\n\nlemma concave_on.convex_ge (hf : concave_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | r ≤ f x} :=\nhf.dual.convex_le r\n\nlemma convex_on.convex_epigraph (hf : convex_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2} :=\nbegin\n  rintro ⟨x, r⟩ ⟨y, t⟩ ⟨hx, hr⟩ ⟨hy, ht⟩ a b ha hb hab,\n  refine ⟨hf.1 hx hy ha hb hab, _⟩,\n  calc f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx hy ha hb hab\n  ... ≤ a • r + b • t : add_le_add (smul_le_smul_of_nonneg hr ha)\n                            (smul_le_smul_of_nonneg ht hb)\nend\n\nlemma concave_on.convex_hypograph (hf : concave_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1} :=\nhf.dual.convex_epigraph\n\nlemma convex_on_iff_convex_epigraph :\n  convex_on 𝕜 s f ↔ convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2} :=\n⟨convex_on.convex_epigraph, convex_on_of_convex_epigraph⟩\n\nlemma concave_on_iff_convex_hypograph :\n  concave_on 𝕜 s f ↔ convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1} :=\n@convex_on_iff_convex_epigraph 𝕜 E βᵒᵈ _ _ _ _ _ _ _ f\n\nend ordered_smul\n\nsection module\nvariables [module 𝕜 E] [has_smul 𝕜 β] {s : set E} {f : E → β}\n\n/-- Right translation preserves convexity. -/\nlemma convex_on.translate_right (hf : convex_on 𝕜 s f) (c : E) :\n  convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\n⟨hf.1.translate_preimage_right _, λ x y hx hy a b ha hb hab,\n  calc\n    f (c + (a • x + b • y)) = f (a • (c + x) + b • (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... ≤ a • f (c + x) + b • f (c + y) : hf.2 hx hy ha hb hab⟩\n\n/-- Right translation preserves concavity. -/\nlemma concave_on.translate_right (hf : concave_on 𝕜 s f) (c : E) :\n  concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves convexity. -/\nlemma convex_on.translate_left (hf : convex_on 𝕜 s f) (c : E) :\n  convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\n/-- Left translation preserves concavity. -/\nlemma concave_on.translate_left (hf : concave_on 𝕜 s f) (c : E) :\n  concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nhf.dual.translate_left _\n\nend module\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β]\n\nlemma convex_on_iff_forall_pos {s : set E} {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧\n    ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → f (a • x + b • y) ≤ a • f x + b • f y :=\nbegin\n  refine and_congr_right' ⟨λ h x y hx hy a b ha hb hab, h hx hy ha.le hb.le hab,\n    λ h x y hx hy a b ha hb hab, _⟩,\n  obtain rfl | ha' := ha.eq_or_lt,\n  { rw [zero_add] at hab, subst b, simp_rw [zero_smul, zero_add, one_smul] },\n  obtain rfl | hb' := hb.eq_or_lt,\n  { rw [add_zero] at hab, subst a, simp_rw [zero_smul, add_zero, one_smul] },\n  exact h hx hy ha' hb' hab,\nend\n\nlemma concave_on_iff_forall_pos {s : set E} {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧\n    ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → a • f x + b • f y ≤ f (a • x + b • y) :=\n@convex_on_iff_forall_pos 𝕜 E βᵒᵈ _ _ _ _ _ _ _\n\nlemma convex_on_iff_pairwise_pos {s : set E} {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧\n    s.pairwise (λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → f (a • x + b • y) ≤ a • f x + b • f y) :=\nbegin\n  rw convex_on_iff_forall_pos,\n  refine and_congr_right' ⟨λ h x hx y hy _ a b ha hb hab, h hx hy ha hb hab,\n    λ h x y hx hy a b ha hb hab, _⟩,\n  obtain rfl | hxy := eq_or_ne x y,\n  { rw [convex.combo_self hab, convex.combo_self hab] },\n  exact h hx hy hxy ha hb hab,\nend\n\nlemma concave_on_iff_pairwise_pos {s : set E} {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧\n   s.pairwise (λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → a • f x + b • f y ≤ f (a • x + b • y)) :=\n@convex_on_iff_pairwise_pos 𝕜 E βᵒᵈ _ _ _ _ _ _ _\n\n/-- A linear map is convex. -/\nlemma linear_map.convex_on (f : E →ₗ[𝕜] β) {s : set E} (hs : convex 𝕜 s) : convex_on 𝕜 s f :=\n⟨hs, λ _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]⟩\n\n/-- A linear map is concave. -/\nlemma linear_map.concave_on (f : E →ₗ[𝕜] β) {s : set E} (hs : convex 𝕜 s) : concave_on 𝕜 s f :=\n⟨hs, λ _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]⟩\n\nlemma strict_convex_on.convex_on {s : set E} {f : E → β} (hf : strict_convex_on 𝕜 s f) :\n  convex_on 𝕜 s f :=\nconvex_on_iff_pairwise_pos.mpr ⟨hf.1, λ x hx y hy hxy a b ha hb hab, (hf.2 hx hy hxy ha hb hab).le⟩\n\nlemma strict_concave_on.concave_on {s : set E} {f : E → β} (hf : strict_concave_on 𝕜 s f) :\n  concave_on 𝕜 s f :=\nhf.dual.convex_on\n\nsection ordered_smul\nvariables [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma strict_convex_on.convex_lt (hf : strict_convex_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | f x < r} :=\nconvex_iff_pairwise_pos.2 $ λ x hx y hy hxy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a • x + b • y) < a • f x + b • f y : hf.2 hx.1 hy.1 hxy ha hb hab\n                  ... ≤ a • r + b • r     : add_le_add (smul_lt_smul_of_pos hx.2 ha).le\n                                              (smul_lt_smul_of_pos hy.2 hb).le\n                  ... = r                 : convex.combo_self hab r⟩\n\nlemma strict_concave_on.convex_gt (hf : strict_concave_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | r < f x} :=\nhf.dual.convex_lt r\n\nend ordered_smul\n\nsection linear_order\nvariables [linear_order E] {s : set E} {f : E → β}\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is convex, it suffices to\nverify the inequality `f (a • x + b • y) ≤ a • f x + b • f y` only for `x < y` and positive `a`,\n`b`. The main use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order.\n-/\nlemma linear_order.convex_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) ≤ a • f x + b • f y) : convex_on 𝕜 s f :=\nbegin\n  refine convex_on_iff_pairwise_pos.2 ⟨hs, λ x hx y hy hxy a b ha hb hab, _⟩,\n  wlog h : x ≤ y using [x y a b, y x b a],\n  { exact le_total _ _ },\n  exact hf hx hy (h.lt_of_ne hxy) ha hb hab,\nend\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is concave it suffices to\nverify the inequality `a • f x + b • f y ≤ f (a • x + b • y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = ℝ` however one can apply it, e.g., to `ℝ^n` with lexicographic order. -/\nlemma linear_order.concave_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n     a • f x + b • f y ≤ f (a • x + b • y)) : concave_on 𝕜 s f :=\n@linear_order.convex_on_of_lt _ _ βᵒᵈ _ _ _ _ _ _ s f hs hf\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is convex, it suffices to\nverify the inequality `f (a • x + b • y) ≤ a • f x + b • f y` for `x < y` and positive `a`, `b`. The\nmain use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order. -/\nlemma linear_order.strict_convex_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) < a • f x + b • f y) : strict_convex_on 𝕜 s f :=\nbegin\n  refine ⟨hs, λ x y hx hy hxy a b ha hb hab, _⟩,\n  wlog h : x ≤ y using [x y a b, y x b a],\n  { exact le_total _ _ },\n  exact hf hx hy (h.lt_of_ne hxy) ha hb hab,\nend\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is concave it suffices to\nverify the inequality `a • f x + b • f y ≤ f (a • x + b • y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order. -/\nlemma linear_order.strict_concave_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n     a • f x + b • f y < f (a • x + b • y)) : strict_concave_on 𝕜 s f :=\n@linear_order.strict_convex_on_of_lt _ _ βᵒᵈ _ _ _ _ _ _ _ _ hs hf\n\nend linear_order\nend module\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 F] [has_smul 𝕜 β]\n\n/-- If `g` is convex on `s`, so is `(f ∘ g)` on `f ⁻¹' s` for a linear `f`. -/\nlemma convex_on.comp_linear_map {f : F → β} {s : set F} (hf : convex_on 𝕜 s f) (g : E →ₗ[𝕜] F) :\n  convex_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\n⟨hf.1.linear_preimage _, λ x y hx hy a b ha hb hab,\n  calc\n    f (g (a • x + b • y)) = f (a • (g x) + b • (g y)) : by rw [g.map_add, g.map_smul, g.map_smul]\n                      ... ≤ a • f (g x) + b • f (g y) : hf.2 hx hy ha hb hab⟩\n\n/-- If `g` is concave on `s`, so is `(g ∘ f)` on `f ⁻¹' s` for a linear `f`. -/\nlemma concave_on.comp_linear_map {f : F → β} {s : set F} (hf : concave_on 𝕜 s f) (g : E →ₗ[𝕜] F) :\n  concave_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\nhf.dual.comp_linear_map g\n\nend module\nend ordered_add_comm_monoid\n\nsection ordered_cancel_add_comm_monoid\nvariables [ordered_cancel_add_comm_monoid β]\n\nsection distrib_mul_action\nvariables [has_smul 𝕜 E] [distrib_mul_action 𝕜 β] {s : set E} {f g : E → β}\n\nlemma strict_convex_on.add_convex_on (hf : strict_convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) < (a • f x + b • f y) + (a • g x + b • g y)\n      : add_lt_add_of_lt_of_le (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy ha.le hb.le hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma convex_on.add_strict_convex_on (hf : convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f + g) :=\n(add_comm g f) ▸ hg.add_convex_on hf\n\nlemma strict_convex_on.add (hf : strict_convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) < (a • f x + b • f y) + (a • g x + b • g y)\n      : add_lt_add (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy hxy ha hb hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma strict_concave_on.add_concave_on (hf : strict_concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f + g) :=\nhf.dual.add_convex_on hg.dual\n\nlemma concave_on.add_strict_concave_on (hf : concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f + g) :=\nhf.dual.add_strict_convex_on hg.dual\n\nlemma strict_concave_on.add (hf : strict_concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.convex_lt (hf : convex_on 𝕜 s f) (r : β) : convex 𝕜 {x ∈ s | f x < r} :=\nconvex_iff_forall_pos.2 $ λ x y hx hy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a • x + b • y)\n        ≤ a • f x + b • f y : hf.2 hx.1 hy.1 ha.le hb.le hab\n    ... < a • r + b • r     : add_lt_add_of_lt_of_le (smul_lt_smul_of_pos hx.2 ha)\n                                (smul_le_smul_of_nonneg hy.2.le hb.le)\n    ... = r                 : convex.combo_self hab _⟩\n\nlemma concave_on.convex_gt (hf : concave_on 𝕜 s f) (r : β) : convex 𝕜 {x ∈ s | r < f x} :=\nhf.dual.convex_lt r\n\nlemma convex_on.open_segment_subset_strict_epigraph (hf : convex_on 𝕜 s f) (p q : E × β)\n  (hp : p.1 ∈ s ∧ f p.1 < p.2) (hq : q.1 ∈ s ∧ f q.1 ≤ q.2) :\n  open_segment 𝕜 p q ⊆ {p : E × β | p.1 ∈ s ∧ f p.1 < p.2} :=\nbegin\n  rintro _ ⟨a, b, ha, hb, hab, rfl⟩,\n  refine ⟨hf.1 hp.1 hq.1 ha.le hb.le hab, _⟩,\n  calc f (a • p.1 + b • q.1) ≤ a • f p.1 + b • f q.1 : hf.2 hp.1 hq.1 ha.le hb.le hab\n  ... < a • p.2 + b • q.2 :\n    add_lt_add_of_lt_of_le (smul_lt_smul_of_pos hp.2 ha) (smul_le_smul_of_nonneg hq.2 hb.le)\nend\n\nlemma concave_on.open_segment_subset_strict_hypograph (hf : concave_on 𝕜 s f) (p q : E × β)\n  (hp : p.1 ∈ s ∧ p.2 < f p.1) (hq : q.1 ∈ s ∧ q.2 ≤ f q.1) :\n  open_segment 𝕜 p q ⊆ {p : E × β | p.1 ∈ s ∧ p.2 < f p.1} :=\nhf.dual.open_segment_subset_strict_epigraph p q hp hq\n\nlemma convex_on.convex_strict_epigraph (hf : convex_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 < p.2} :=\nconvex_iff_open_segment_subset.mpr $\n  λ p q hp hq, hf.open_segment_subset_strict_epigraph p q hp ⟨hq.1, hq.2.le⟩\n\nlemma concave_on.convex_strict_hypograph (hf : concave_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 < f p.1} :=\nhf.dual.convex_strict_epigraph\n\nend module\nend ordered_cancel_add_comm_monoid\n\nsection linear_ordered_add_comm_monoid\nvariables [linear_ordered_add_comm_monoid β] [has_smul 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β]\n  {s : set E} {f g : E → β}\n\n/-- The pointwise maximum of convex functions is convex. -/\nlemma convex_on.sup (hf : convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  convex_on 𝕜 s (f ⊔ g) :=\nbegin\n  refine ⟨hf.left, λ x y hx hy a b ha hb hab, sup_le _ _⟩,\n  { calc f (a • x + b • y) ≤ a • f x + b • f y : hf.right hx hy ha hb hab\n     ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n     (smul_le_smul_of_nonneg le_sup_left ha)\n     (smul_le_smul_of_nonneg le_sup_left hb) },\n  { calc g (a • x + b • y) ≤ a • g x + b • g y : hg.right hx hy ha hb hab\n     ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n     (smul_le_smul_of_nonneg le_sup_right ha)\n     (smul_le_smul_of_nonneg le_sup_right hb) }\nend\n\n/-- The pointwise minimum of concave functions is concave. -/\nlemma concave_on.inf (hf : concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  concave_on 𝕜 s (f ⊓ g) :=\nhf.dual.sup hg\n\n/-- The pointwise maximum of strictly convex functions is strictly convex. -/\nlemma strict_convex_on.sup (hf : strict_convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f ⊔ g) :=\n⟨hf.left, λ x y hx hy hxy a b ha hb hab, max_lt\n  (calc f (a • x + b • y) < a • f x + b • f y : hf.2 hx hy hxy ha hb hab\n    ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n    (smul_le_smul_of_nonneg le_sup_left ha.le)\n    (smul_le_smul_of_nonneg le_sup_left hb.le))\n  (calc g (a • x + b • y) < a • g x + b • g y : hg.2 hx hy hxy ha hb hab\n    ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n    (smul_le_smul_of_nonneg le_sup_right ha.le)\n    (smul_le_smul_of_nonneg le_sup_right hb.le))⟩\n\n/-- The pointwise minimum of strictly concave functions is strictly concave. -/\nlemma strict_concave_on.inf (hf : strict_concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n   strict_concave_on 𝕜 s (f ⊓ g) :=\nhf.dual.sup hg\n\n/-- A convex function on a segment is upper-bounded by the max of its endpoints. -/\nlemma convex_on.le_on_segment' (hf : convex_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) :\n  f (a • x + b • y) ≤ max (f x) (f y) :=\ncalc\n  f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx hy ha hb hab\n  ... ≤ a • max (f x) (f y) + b • max (f x) (f y) :\n    add_le_add (smul_le_smul_of_nonneg (le_max_left _ _) ha)\n      (smul_le_smul_of_nonneg (le_max_right _ _) hb)\n  ... = max (f x) (f y) : convex.combo_self hab _\n\n/-- A concave function on a segment is lower-bounded by the min of its endpoints. -/\nlemma concave_on.ge_on_segment' (hf : concave_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) :\n  min (f x) (f y) ≤ f (a • x + b • y) :=\nhf.dual.le_on_segment' hx hy ha hb hab\n\n/-- A convex function on a segment is upper-bounded by the max of its endpoints. -/\nlemma convex_on.le_on_segment (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s) (hy : y ∈ s)\n  (hz : z ∈ [x -[𝕜] y]) :\n  f z ≤ max (f x) (f y) :=\nlet ⟨a, b, ha, hb, hab, hz⟩ := hz in hz ▸ hf.le_on_segment' hx hy ha hb hab\n\n/-- A concave function on a segment is lower-bounded by the min of its endpoints. -/\nlemma concave_on.ge_on_segment (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s) (hy : y ∈ s)\n  (hz : z ∈ [x -[𝕜] y]) :\n  min (f x) (f y) ≤ f z :=\nhf.dual.le_on_segment hx hy hz\n\n/-- A strictly convex function on an open segment is strictly upper-bounded by the max of its\nendpoints. -/\nlemma strict_convex_on.lt_on_open_segment' (hf : strict_convex_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  f (a • x + b • y) < max (f x) (f y) :=\ncalc\n  f (a • x + b • y) < a • f x + b • f y : hf.2 hx hy hxy ha hb hab\n  ... ≤ a • max (f x) (f y) + b • max (f x) (f y) :\n    add_le_add (smul_le_smul_of_nonneg (le_max_left _ _) ha.le)\n      (smul_le_smul_of_nonneg (le_max_right _ _) hb.le)\n  ... = max (f x) (f y) : convex.combo_self hab _\n\n/-- A strictly concave function on an open segment is strictly lower-bounded by the min of its\nendpoints. -/\nlemma strict_concave_on.lt_on_open_segment' (hf : strict_concave_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  min (f x) (f y) < f (a • x + b • y) :=\nhf.dual.lt_on_open_segment' hx hy hxy ha hb hab\n\n/-- A strictly convex function on an open segment is strictly upper-bounded by the max of its\nendpoints. -/\nlemma strict_convex_on.lt_on_open_segment (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) (hz : z ∈ open_segment 𝕜 x y) :\n  f z < max (f x) (f y) :=\nlet ⟨a, b, ha, hb, hab, hz⟩ := hz in hz ▸ hf.lt_on_open_segment' hx hy hxy ha hb hab\n\n/-- A strictly concave function on an open segment is strictly lower-bounded by the min of its\nendpoints. -/\nlemma strict_concave_on.lt_on_open_segment (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) (hz : z ∈ open_segment 𝕜 x y) :\n  min (f x) (f y) < f z :=\nhf.dual.lt_on_open_segment hx hy hxy hz\n\nend linear_ordered_add_comm_monoid\n\nsection linear_ordered_cancel_add_comm_monoid\nvariables [linear_ordered_cancel_add_comm_monoid β]\n\nsection ordered_smul\nvariables [has_smul 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f g : E → β}\n\nlemma convex_on.le_left_of_right_le' (hf : convex_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) (hfy : f y ≤ f (a • x + b • y)) :\n  f (a • x + b • y) ≤ f x :=\nle_of_not_lt $ λ h, lt_irrefl (f (a • x + b • y)) $\n  calc\n    f (a • x + b • y)\n        ≤ a • f x + b • f y : hf.2 hx hy ha.le hb hab\n    ... < a • f (a • x + b • y) + b • f (a • x + b • y)\n        : add_lt_add_of_lt_of_le (smul_lt_smul_of_pos h ha) (smul_le_smul_of_nonneg hfy hb)\n    ... = f (a • x + b • y) : convex.combo_self hab _\n\nlemma concave_on.left_le_of_le_right' (hf : concave_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) (hfy : f (a • x + b • y) ≤ f y) :\n  f x ≤ f (a • x + b • y) :=\nhf.dual.le_left_of_right_le' hx hy ha hb hab hfy\n\nlemma convex_on.le_right_of_left_le' (hf : convex_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x ≤ f (a • x + b • y)) :\n  f (a • x + b • y) ≤ f y :=\nbegin\n  rw add_comm at ⊢ hab hfx,\n  exact hf.le_left_of_right_le' hy hx hb ha hab hfx,\nend\n\nlemma concave_on.right_le_of_le_left' (hf : concave_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a • x + b • y) ≤ f x) :\n  f y ≤ f (a • x + b • y) :=\nhf.dual.le_right_of_left_le' hx hy ha hb hab hfx\n\nlemma convex_on.le_left_of_right_le (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f y ≤ f z) :\n  f z ≤ f x :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.le_left_of_right_le' hx hy ha hb.le hab hyz,\nend\n\nlemma concave_on.left_le_of_le_right (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f z ≤ f y) :\n  f x ≤ f z :=\nhf.dual.le_left_of_right_le hx hy hz hyz\n\nlemma convex_on.le_right_of_left_le (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f x ≤ f z) :\n  f z ≤ f y :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.le_right_of_left_le' hx hy ha.le hb hab hxz,\nend\n\nlemma concave_on.right_le_of_le_left (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f z ≤ f x) :\n  f y ≤ f z :=\nhf.dual.le_right_of_left_le hx hy hz hxz\n\nend ordered_smul\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f g : E → β}\n\n/- The following lemmas don't require `module 𝕜 E` if you add the hypothesis `x ≠ y`. At the time of\nthe writing, we decided the resulting lemmas wouldn't be useful. Feel free to reintroduce them. -/\nlemma strict_convex_on.lt_left_of_right_lt' (hf : strict_convex_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f y < f (a • x + b • y)) :\n  f (a • x + b • y) < f x :=\nnot_le.1 $ λ h, lt_irrefl (f (a • x + b • y)) $\n  calc\n    f (a • x + b • y)\n        < a • f x + b • f y : hf.2 hx hy begin\n            rintro rfl,\n            rw convex.combo_self hab at hfy,\n            exact lt_irrefl _ hfy,\n          end ha hb hab\n    ... < a • f (a • x + b • y) + b • f (a • x + b • y)\n        : add_lt_add_of_le_of_lt (smul_le_smul_of_nonneg h ha.le) (smul_lt_smul_of_pos hfy hb)\n    ... = f (a • x + b • y) : convex.combo_self hab _\n\nlemma strict_concave_on.left_lt_of_lt_right' (hf : strict_concave_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f (a • x + b • y) < f y) :\n  f x < f (a • x + b • y) :=\nhf.dual.lt_left_of_right_lt' hx hy ha hb hab hfy\n\nlemma strict_convex_on.lt_right_of_left_lt' (hf : strict_convex_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x < f (a • x + b • y)) :\n  f (a • x + b • y) < f y :=\nbegin\n  rw add_comm at ⊢ hab hfx,\n  exact hf.lt_left_of_right_lt' hy hx hb ha hab hfx,\nend\n\nlemma strict_concave_on.lt_right_of_left_lt' (hf : strict_concave_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a • x + b • y) < f x) :\n  f y < f (a • x + b • y) :=\nhf.dual.lt_right_of_left_lt' hx hy ha hb hab hfx\n\nlemma strict_convex_on.lt_left_of_right_lt (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f y < f z) :\n  f z < f x :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.lt_left_of_right_lt' hx hy ha hb hab hyz,\nend\n\nlemma strict_concave_on.left_lt_of_lt_right (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f z < f y) :\n  f x < f z :=\nhf.dual.lt_left_of_right_lt hx hy hz hyz\n\nlemma strict_convex_on.lt_right_of_left_lt (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f x < f z) :\n  f z < f y :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.lt_right_of_left_lt' hx hy ha hb hab hxz,\nend\n\nlemma strict_concave_on.lt_right_of_left_lt (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f z < f x) :\n  f y < f z :=\nhf.dual.lt_right_of_left_lt hx hy hz hxz\n\nend module\nend linear_ordered_cancel_add_comm_monoid\n\nsection ordered_add_comm_group\nvariables [ordered_add_comm_group β] [has_smul 𝕜 E] [module 𝕜 β] {s : set E} {f g : E → β}\n\n/-- A function `-f` is convex iff `f` is concave. -/\n@[simp] lemma neg_convex_on_iff : convex_on 𝕜 s (-f) ↔ concave_on 𝕜 s f :=\nbegin\n  split,\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy a b ha hb hab, _⟩,\n    simp [neg_apply, neg_le, add_comm] at h,\n    exact h hx hy ha hb hab },\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy a b ha hb hab, _⟩,\n    rw ←neg_le_neg_iff,\n    simp_rw [neg_add, pi.neg_apply, smul_neg, neg_neg],\n    exact h hx hy ha hb hab }\nend\n\n/-- A function `-f` is concave iff `f` is convex. -/\n@[simp] lemma neg_concave_on_iff : concave_on 𝕜 s (-f) ↔ convex_on 𝕜 s f:=\nby rw [← neg_convex_on_iff, neg_neg f]\n\n/-- A function `-f` is strictly convex iff `f` is strictly concave. -/\n@[simp] lemma neg_strict_convex_on_iff : strict_convex_on 𝕜 s (-f) ↔ strict_concave_on 𝕜 s f :=\nbegin\n  split,\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy hxy a b ha hb hab, _⟩,\n    simp [neg_apply, neg_lt, add_comm] at h,\n    exact h hx hy hxy ha hb hab },\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy hxy a b ha hb hab, _⟩,\n    rw ←neg_lt_neg_iff,\n    simp_rw [neg_add, pi.neg_apply, smul_neg, neg_neg],\n    exact h hx hy hxy ha hb hab }\nend\n\n/-- A function `-f` is strictly concave iff `f` is strictly convex. -/\n@[simp] lemma neg_strict_concave_on_iff : strict_concave_on 𝕜 s (-f) ↔ strict_convex_on 𝕜 s f :=\nby rw [← neg_strict_convex_on_iff, neg_neg f]\n\nalias neg_convex_on_iff ↔ _ concave_on.neg\nalias neg_concave_on_iff ↔ _ convex_on.neg\nalias neg_strict_convex_on_iff ↔ _ strict_concave_on.neg\nalias neg_strict_concave_on_iff ↔ _ strict_convex_on.neg\n\nlemma convex_on.sub (hf : convex_on 𝕜 s f) (hg : concave_on 𝕜 s g) : convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma concave_on.sub (hf : concave_on 𝕜 s f) (hg : convex_on 𝕜 s g) : concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma strict_convex_on.sub (hf : strict_convex_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma strict_concave_on.sub (hf : strict_concave_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add hg.neg\n\nlemma convex_on.sub_strict_concave_on (hf : convex_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_strict_convex_on hg.neg\n\nlemma concave_on.sub_strict_convex_on (hf : concave_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_strict_concave_on hg.neg\n\nlemma strict_convex_on.sub_concave_on (hf : strict_convex_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_convex_on hg.neg\n\nlemma strict_concave_on.sub_convex_on (hf : strict_concave_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f - g) :=\n(sub_eq_add_neg f g).symm ▸ hf.add_concave_on hg.neg\n\nend ordered_add_comm_group\nend add_comm_monoid\n\nsection add_cancel_comm_monoid\nvariables [add_cancel_comm_monoid E] [ordered_add_comm_monoid β] [module 𝕜 E] [has_smul 𝕜 β]\n  {s : set E} {f : E → β}\n\n/-- Right translation preserves strict convexity. -/\nlemma strict_convex_on.translate_right (hf : strict_convex_on 𝕜 s f) (c : E) :\n  strict_convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\n⟨hf.1.translate_preimage_right _, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (c + (a • x + b • y)) = f (a • (c + x) + b • (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... < a • f (c + x) + b • f (c + y) : hf.2 hx hy ((add_right_injective c).ne hxy) ha hb hab⟩\n\n/-- Right translation preserves strict concavity. -/\nlemma strict_concave_on.translate_right (hf : strict_concave_on 𝕜 s f) (c : E) :\n  strict_concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves strict convexity. -/\nlemma strict_convex_on.translate_left (hf : strict_convex_on 𝕜 s f) (c : E) :\n  strict_convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\n/-- Left translation preserves strict concavity. -/\nlemma strict_concave_on.translate_left (hf : strict_concave_on 𝕜 s f) (c : E) :\n  strict_concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\nend add_cancel_comm_monoid\nend ordered_semiring\n\nsection ordered_comm_semiring\nvariables [ordered_comm_semiring 𝕜] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection module\nvariables [has_smul 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.smul {c : 𝕜} (hc : 0 ≤ c) (hf : convex_on 𝕜 s f) : convex_on 𝕜 s (λ x, c • f x) :=\n⟨hf.1, λ x y hx hy a b ha hb hab,\n  calc\n    c • f (a • x + b • y) ≤ c • (a • f x + b • f y)\n      : smul_le_smul_of_nonneg (hf.2 hx hy ha hb hab) hc\n    ... = a • (c • f x) + b • (c • f y)\n      : by rw [smul_add, smul_comm c, smul_comm c]; apply_instance⟩\n\nlemma concave_on.smul {c : 𝕜} (hc : 0 ≤ c) (hf : concave_on 𝕜 s f) :\n  concave_on 𝕜 s (λ x, c • f x) :=\nhf.dual.smul hc\n\nend module\nend ordered_add_comm_monoid\nend ordered_comm_semiring\n\nsection ordered_ring\nvariables [linear_ordered_field 𝕜] [add_comm_group E] [add_comm_group F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 F] [has_smul 𝕜 β]\n\n/-- If a function is convex on `s`, it remains convex when precomposed by an affine map. -/\nlemma convex_on.comp_affine_map {f : F → β} (g : E →ᵃ[𝕜] F) {s : set F} (hf : convex_on 𝕜 s f) :\n  convex_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\n⟨hf.1.affine_preimage _, λ x y hx hy a b ha hb hab,\n  calc\n    (f ∘ g) (a • x + b • y) = f (g (a • x + b • y))         : rfl\n                       ...  = f (a • (g x) + b • (g y))     : by rw [convex.combo_affine_apply hab]\n                       ...  ≤ a • f (g x) + b • f (g y)     : hf.2 hx hy ha hb hab⟩\n\n/-- If a function is concave on `s`, it remains concave when precomposed by an affine map. -/\nlemma concave_on.comp_affine_map {f : F → β} (g : E →ᵃ[𝕜] F) {s : set F} (hf : concave_on 𝕜 s f) :\n  concave_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\nhf.dual.comp_affine_map g\n\nend module\nend ordered_add_comm_monoid\nend ordered_ring\n\nsection linear_ordered_field\nvariables [linear_ordered_field 𝕜] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection has_smul\nvariables [has_smul 𝕜 E] [has_smul 𝕜 β] {s : set E}\n\nlemma convex_on_iff_div {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → 0 < a + b\n  → f ((a/(a+b)) • x + (b/(a+b)) • y) ≤ (a/(a+b)) • f x + (b/(a+b)) • f y :=\nand_congr iff.rfl\n⟨begin\n  intros h x y hx hy a b ha hb hab,\n  apply h hx hy (div_nonneg ha hab.le) (div_nonneg hb hab.le),\n  rw [←add_div, div_self hab.ne'],\nend,\nbegin\n  intros h x y hx hy a b ha hb hab,\n  simpa [hab, zero_lt_one] using h hx hy ha hb,\nend⟩\n\nlemma concave_on_iff_div {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b\n  → 0 < a + b → (a/(a+b)) • f x + (b/(a+b)) • f y ≤ f ((a/(a+b)) • x + (b/(a+b)) • y) :=\n@convex_on_iff_div _ _ βᵒᵈ _ _ _ _ _ _ _\n\nlemma strict_convex_on_iff_div {f : E → β} :\n  strict_convex_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a\n    → 0 < b → f ((a/(a+b)) • x + (b/(a+b)) • y) < (a/(a+b)) • f x + (b/(a+b)) • f y :=\nand_congr iff.rfl\n⟨begin\n  intros h x y hx hy hxy a b ha hb,\n  have hab := add_pos ha hb,\n  apply h hx hy hxy (div_pos ha hab) (div_pos hb hab),\n  rw [←add_div, div_self hab.ne'],\nend,\nbegin\n  intros h x y hx hy hxy a b ha hb hab,\n  simpa [hab, zero_lt_one] using h hx hy hxy ha hb,\nend⟩\n\nlemma strict_concave_on_iff_div {f : E → β} :\n  strict_concave_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a\n    → 0 < b → (a/(a+b)) • f x + (b/(a+b)) • f y < f ((a/(a+b)) • x + (b/(a+b)) • y) :=\n@strict_convex_on_iff_div _ _ βᵒᵈ _ _ _ _ _ _ _\n\nend has_smul\nend ordered_add_comm_monoid\nend linear_ordered_field\n\nsection\n\nvariables [linear_ordered_field 𝕜] [linear_ordered_cancel_add_comm_monoid β] [module 𝕜 β]\n  [ordered_smul 𝕜 β] {x y z : 𝕜} {s : set 𝕜} {f : 𝕜 → β}\n\nlemma convex_on.le_right_of_left_le'' (hf : convex_on 𝕜 s f) (hx : x ∈ s) (hz : z ∈ s)\n  (hxy : x < y) (hyz : y ≤ z) (h : f x ≤ f y) : f y ≤ f z :=\nhyz.eq_or_lt.elim (λ hyz, (congr_arg f hyz).le)\n  (λ hyz, hf.le_right_of_left_le hx hz (Ioo_subset_open_segment ⟨hxy, hyz⟩) h)\n\nlemma convex_on.le_left_of_right_le'' (hf : convex_on 𝕜 s f) (hx : x ∈ s) (hz : z ∈ s)\n  (hxy : x ≤ y) (hyz : y < z) (h : f z ≤ f y) : f y ≤ f x :=\nhxy.eq_or_lt.elim (λ hxy, (congr_arg f hxy).ge)\n  (λ hxy, hf.le_left_of_right_le hx hz (Ioo_subset_open_segment ⟨hxy, hyz⟩) h)\n\nlemma concave_on.right_le_of_le_left'' (hf : concave_on 𝕜 s f) (hx : x ∈ s) (hz : z ∈ s)\n  (hxy : x < y) (hyz : y ≤ z) (h : f y ≤ f x) : f z ≤ f y :=\nhf.dual.le_right_of_left_le'' hx hz hxy hyz h\n\nlemma concave_on.left_le_of_le_right'' (hf : concave_on 𝕜 s f) (hx : x ∈ s) (hz : z ∈ s)\n  (hxy : x ≤ y) (hyz : y < z) (h : f y ≤ f z) : f x ≤ f y :=\nhf.dual.le_left_of_right_le'' hx hz hxy hyz h\n\nend\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/analysis/convex/function.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.4888563327749645}}
{"text": "import .deduct\nimport .function_update_ite\n\n\nset_option pp.parens true\n\n\nopen formula\n\n\ndef formula.is_atomic : formula → Prop\n| (true_) := false\n| (pred_ name args) := true\n| (eq_ x y) := true\n| (not_ P) := false\n| (imp_ P Q) := false\n| (forall_ x P) := true\n\n\ndef formula.atomic_set : formula → finset formula\n| (true_) := ∅ \n| (pred_ name args) := {pred_ name args}\n| (eq_ x y) := {eq_ x y}\n| (not_ P) := P.atomic_set\n| (imp_ P Q) := P.atomic_set ∪ Q.atomic_set\n| (forall_ x P) := {forall_ x P}\n\n\ndef formula.subst_atomic (σ : formula → formula) : formula → formula\n| (true_) := true_\n| (pred_ name args) := σ (pred_ name args)\n| (eq_ x y) := σ (eq_ x y)\n| (not_ P) := not_ P.subst_atomic\n| (imp_ P Q) := imp_ P.subst_atomic Q.subst_atomic\n| (forall_ x P) := σ (forall_ x P)\n\n\n@[derive inhabited]\ndef valuation : Type := formula → bool\n\ndef formula.eval_atomic (val : valuation) : formula → bool\n| (true_) := bool.tt\n| (pred_ name args) := val (pred_ name args)\n| (eq_ x y) := val (eq_ x y)\n| (not_ P) := ! P.eval_atomic\n| (imp_ P Q) := (! P.eval_atomic) || Q.eval_atomic\n| (forall_ x P) := val (forall_ x P)\n\ndef formula.is_tauto_atomic (P : formula) : Prop :=\n  ∀ (val : valuation), P.eval_atomic val = bool.tt\n\ndef eval_atomic_ff_to_not (val : valuation) (P : formula) : formula :=\nif formula.eval_atomic val P = bool.tt then P else P.not_\n\n\nlemma eval_atomic_atomic\n  (P : formula)\n  (val : valuation)\n  (h1 : P.is_atomic) :\n  P.eval_atomic val = val P :=\nbegin\n  induction P,\n  case [formula.true_, formula.not_, formula.imp_]\n  {\n    all_goals\n    {\n      unfold formula.is_atomic at h1,\n\n      contradiction,\n    }\n  },\n  case [formula.pred_, formula.eq_, formula.forall_]\n  {\n    all_goals\n    {\n      refl,\n    }\n  },\nend\n\n\nexample\n  (P : formula)\n  (val val' : valuation)\n  (h1 : ∀ (Q : formula), Q ∈ P.atomic_set → val Q = val' Q) :\n  P.eval_atomic val = P.eval_atomic val' :=\nbegin\n  induction P,\n  case formula.true_\n  {\n    unfold formula.eval_atomic,\n  },\n  case [formula.pred_, formula.eq_, formula.forall_]\n  {\n    all_goals\n    {\n      unfold formula.atomic_set at h1,\n\n      unfold formula.eval_atomic,\n      apply h1,\n      simp only [finset.mem_singleton, eq_self_iff_true, and_self],\n    },\n  },\n  case formula.not_ : P P_ih\n  {\n    unfold formula.atomic_set at h1,\n\n    unfold formula.eval_atomic,\n    congr' 1,\n    exact P_ih h1,\n  },\n  case formula.imp_ : P Q P_ih Q_ih\n  {\n    unfold formula.atomic_set at h1,\n    simp only [finset.mem_union] at h1,\n\n    unfold formula.eval_atomic,\n    congr' 1,\n    {\n      congr' 1,\n      apply P_ih,\n      intros Q' a1,\n      apply h1,\n      left,\n      exact a1,\n    },\n    {\n      apply Q_ih,\n      intros Q' a1,\n      apply h1,\n      right,\n      exact a1,\n    }\n  },\nend\n\n\nlemma eval_atomic_subst_atomic_eq_eval_atomic_eval_atomic\n  (P : formula)\n  (σ : formula → formula)\n  (val : valuation) :\n  (P.subst_atomic σ).eval_atomic val =\n    P.eval_atomic (fun (Q : formula), (σ Q).eval_atomic val) :=\nbegin\n  induction P,\n  case [formula.true_, formula.pred_, formula.eq_, formula.forall_]\n  {\n    all_goals\n    {\n      refl,\n    }\n  },\n  case formula.not_ : P P_ih\n  {\n    unfold formula.subst_atomic,\n    unfold formula.eval_atomic,\n    congr,\n    exact P_ih,\n  },\n  case formula.imp_ : P Q P_ih Q_ih\n  {\n    unfold formula.subst_atomic,\n    unfold formula.eval_atomic,\n    congr,\n    {\n      exact P_ih,\n    },\n    {\n      exact Q_ih,\n    }\n  },\nend\n\n\ntheorem is_tauto_atomic_imp_is_tauto_atomic_subst_atomic\n  (P : formula)\n  (h1 : P.is_tauto_atomic)\n  (σ : formula → formula) :\n  (formula.subst_atomic σ P).is_tauto_atomic :=\nbegin\n  unfold formula.is_tauto_atomic at h1,\n\n  unfold formula.is_tauto_atomic,\n  intros val,\n  simp only [eval_atomic_subst_atomic_eq_eval_atomic_eval_atomic P σ val],\n  apply h1,\nend\n\n\nexample\n  (P Q R S : formula)\n  (val : valuation)\n  (σ : formula → formula)\n  (h1 : P.eval_atomic val = Q.eval_atomic val) :\n  (S.subst_atomic (function.update_ite σ R P)).eval_atomic val =\n    (S.subst_atomic (function.update_ite σ R Q)).eval_atomic val :=\nbegin\n  simp only [eval_atomic_subst_atomic_eq_eval_atomic_eval_atomic],\n  congr' 1,\n  funext Q',\n  unfold function.update_ite,\n  split_ifs,\n  {\n    exact h1,\n  },\n  {\n    refl,\n  }\nend\n\n\ntheorem T_13_5\n  (P : formula) :\n  is_proof (P.imp_ P) :=\nbegin\n  unfold is_proof,\n\n  apply is_deduct.mp_,\n  {\n    apply is_deduct.mp_,\n    {\n      apply is_deduct.axiom_,\n      exact is_axiom.prop_2_ P (P.imp_ P) P,\n    },\n    {\n      apply is_deduct.axiom_,\n      exact is_axiom.prop_1_ P (P.imp_ P),\n    }\n  },\n  {\n    apply is_deduct.axiom_,\n    exact is_axiom.prop_1_ P P,\n  },\nend\n\nalias T_13_5 <- prop_id\n\n\ntheorem T_13_6\n  (P Q : formula) :\n  is_proof (P.not_.imp_ (P.imp_ Q)) :=\nbegin\n  unfold is_proof,\n\n  apply is_deduct.mp_,\n  {\n    apply is_deduct.mp_,\n    {\n      apply is_deduct.axiom_,\n      exact is_axiom.prop_2_ P.not_ (Q.not_.imp_ P.not_) (P.imp_ Q),\n    },\n    {\n      apply is_deduct.mp_,\n      {\n        apply is_deduct.axiom_,\n        exact is_axiom.prop_1_ ((Q.not_.imp_ P.not_).imp_ (P.imp_ Q)) P.not_,\n      },\n      {\n        apply is_deduct.axiom_,\n        exact is_axiom.prop_3_ Q P,\n      }\n    }\n  },\n  {\n    apply is_deduct.axiom_,\n    exact is_axiom.prop_1_ P.not_ Q.not_,\n  },\nend\n\n\n-- Deduction Theorem\n\ntheorem T_14_3\n  (P Q : formula)\n  (Δ : set formula)\n  (h1 : is_deduct (Δ ∪ {P}) Q) :\n  is_deduct Δ (P.imp_ Q) :=\nbegin\n  induction h1,\n  case is_deduct.axiom_ : h1_P h1_1\n  {\n    apply is_deduct.mp_,\n    {\n      apply is_deduct.axiom_,\n      exact is_axiom.prop_1_ h1_P P,\n    },\n    {\n      apply is_deduct.axiom_,\n      exact h1_1,\n    },\n  },\n  case is_deduct.assume_ : h1_P h1_1\n  {\n    simp only [set.union_singleton, set.mem_insert_iff] at h1_1,\n    cases h1_1,\n    {\n      subst h1_1,\n      apply proof_imp_deduct,\n      exact prop_id h1_P,\n    },\n    {\n      apply is_deduct.mp_,\n      {\n        apply is_deduct.axiom_,\n        exact is_axiom.prop_1_ h1_P P,\n      },\n      {\n        apply is_deduct.assume_,\n        exact h1_1,\n      },\n    }\n  },\n  case is_deduct.mp_ : h1_P h1_Q h1_1 h1_2 h1_ih_1 h1_ih_2\n  {\n    apply is_deduct.mp_,\n    {\n      apply is_deduct.mp_,\n      {\n        apply is_deduct.axiom_,\n        exact is_axiom.prop_2_ P h1_P h1_Q,\n      },\n      {\n        exact h1_ih_1,\n      }\n    },\n    {\n      exact h1_ih_2,\n    },\n  },\nend\n\nalias T_14_3 <- deduction_theorem\n\n\nexample\n  (P Q : formula) :\n  is_proof (P.not_.imp_ (P.imp_ Q)) :=\nbegin\n  unfold is_proof,\n\n  apply deduction_theorem,\n  apply is_deduct.mp_,\n  {\n    apply is_deduct.axiom_,\n    exact is_axiom.prop_3_ Q P,\n  },\n  {\n    apply is_deduct.mp_,\n    {\n      apply is_deduct.axiom_,\n      exact is_axiom.prop_1_ P.not_ Q.not_,\n    },\n    {\n      apply is_deduct.assume_,\n      simp only [set.union_singleton, insert_emptyc_eq, set.mem_singleton],\n    },\n  },\nend\n\n\ntheorem T_14_5\n  (P : formula) :\n  is_proof (P.not_.not_.imp_ P) :=\nbegin\n  unfold is_proof,\n\n  apply deduction_theorem,\n  apply is_deduct.mp_ P.not_.not_,\n  {\n    apply is_deduct.mp_ (P.not_.imp_ P.not_.not_.not_),\n    {\n      apply is_deduct.axiom_,\n      apply is_axiom.prop_3_,\n    },\n    {\n      apply is_deduct.mp_ P.not_.not_,\n      {\n        apply proof_imp_deduct,\n        apply T_13_6,\n      },\n      {\n        apply is_deduct.assume_,\n        simp only [set.union_singleton, insert_emptyc_eq, set.mem_singleton],\n      }\n    }\n  },\n  {\n    apply is_deduct.assume_,\n    simp only [set.union_singleton, insert_emptyc_eq, set.mem_singleton_iff],\n  }\nend\n\n\ntheorem T_14_6\n  (P : formula) :\n  is_proof (P.imp_ P.not_.not_) :=\nbegin\n  unfold is_proof,\n\n  apply is_deduct.mp_ (P.not_.not_.not_.imp_ P.not_),\n  {\n    apply is_deduct.axiom_,\n    exact is_axiom.prop_3_ P.not_.not_ P,\n  },\n  {\n    apply proof_imp_deduct,\n    exact T_14_5 P.not_,\n  }\nend\n\n\ntheorem T_14_7\n  (P Q : formula) :\n  is_proof ((P.imp_ Q).imp_ (Q.not_.imp_ P.not_)) :=\nbegin\n  unfold is_proof,\n\n  apply deduction_theorem,\n  apply is_deduct.mp_,\n  {\n    apply is_deduct.axiom_,\n    apply is_axiom.prop_3_,\n  },\n  {\n    apply deduction_theorem,\n    apply is_deduct.mp_,\n    {\n      apply proof_imp_deduct,\n      apply T_14_6,\n    },\n    {\n      apply is_deduct.mp_,\n      {\n        apply is_deduct.assume_,\n        simp only [set.union_singleton, insert_emptyc_eq, set.mem_insert_iff, set.mem_singleton_iff, eq_self_iff_true, and_true,\n  false_or],\n      },\n      {\n        apply is_deduct.mp_,\n        {\n          apply proof_imp_deduct,\n          apply T_14_5,\n        },\n        {\n          apply is_deduct.assume_,\n          simp only [set.union_singleton, insert_emptyc_eq, set.mem_insert_iff, set.mem_singleton_iff, or_false],\n        }\n      }\n    }\n  }\nend\n\n\ntheorem T_14_8\n  (Q R : formula) :\n  is_proof (Q.imp_ (R.not_.imp_ ((Q.imp_ R).not_))) :=\nbegin\n  unfold is_proof,\n\n  apply deduction_theorem,\n  apply is_deduct.mp_,\n  {\n    apply proof_imp_deduct,\n    apply T_14_7,\n  },\n  {\n    apply deduction_theorem,\n    apply is_deduct.mp_ Q R,\n    {\n      apply is_deduct.assume_,\n      simp only [set.union_singleton, set.mem_insert_iff, eq_self_iff_true, and_self, true_or],\n    },\n    {\n      apply is_deduct.assume_,\n      simp only [set.union_singleton, insert_emptyc_eq, set.mem_insert_iff, set.mem_singleton, or_true],\n    }\n  }\nend\n\n\ntheorem T_14_9\n  (P S : formula) :\n  is_proof ((S.imp_ P).imp_ ((S.not_.imp_ P).imp_ P)) :=\nbegin\n  unfold is_proof,\n\n  apply deduction_theorem,\n  apply is_deduct.mp_,\n  {\n    apply is_deduct.axiom_,\n    apply is_axiom.prop_3_,\n  },\n  {\n    apply deduction_theorem,\n    apply is_deduct.mp_,\n    {\n      apply is_deduct.mp_,\n      {\n        apply proof_imp_deduct,\n        apply T_14_8,\n      },\n      {\n        apply is_deduct.mp_,\n        {\n          apply is_deduct.mp_ (S.imp_ P),\n          {\n            apply proof_imp_deduct,\n            apply T_14_7,\n          },\n          {\n            apply is_deduct.assume_,\n            simp only [set.union_singleton, insert_emptyc_eq, set.mem_insert_iff, set.mem_singleton, false_or],\n          }\n        },\n        {\n          apply is_deduct.assume_,\n          simp only [set.union_singleton, insert_emptyc_eq, set.mem_insert_iff, set.mem_singleton_iff, or_false],\n        }\n      }\n    },\n    {\n      apply is_deduct.assume_,\n      simp only [set.union_singleton, insert_emptyc_eq, set.mem_insert_iff, set.mem_singleton_iff, or_false],\n    }\n  }\nend\n\n\ntheorem T_14_10\n  (Q : formula)\n  (Δ : set formula)\n  (h1 : is_deduct Δ Q) :\n  ∀ (Γ : set formula), is_deduct (Δ ∪ Γ) Q :=\nbegin\n  intros Γ,\n  induction h1,\n  case is_deduct.axiom_ : h1_P h1_1\n  {\n    apply is_deduct.axiom_,\n    exact h1_1,\n  },\n  case is_deduct.assume_ : h1_P h1_1\n  {\n    apply is_deduct.assume_,\n    simp only [set.mem_union_eq],\n    apply or.intro_left,\n    exact h1_1,\n  },\n  case is_deduct.mp_ : h1_P h1_Q h1_1 h1_2 h1_ih_1 h1_ih_2\n  {\n    apply is_deduct.mp_ h1_P h1_Q,\n    {\n      exact h1_ih_1,\n    },\n    {\n      exact h1_ih_2,\n    }\n  },\nend\n\n\ntheorem deduction_theorem_converse\n  (P Q : formula)\n  (Δ : set formula)\n  (h1 : is_deduct Δ (P.imp_ Q)) :\n  is_deduct (Δ ∪ {P}) Q :=\nbegin\n  have s1 : is_deduct (Δ ∪ {P}) (P.imp_ Q),\n  exact T_14_10 (P.imp_ Q) Δ h1 {P},\n\n  have s2 : is_deduct (Δ ∪ {P}) P,\n  apply is_deduct.assume_,\n  simp only [set.union_singleton, set.mem_insert_iff, eq_self_iff_true, true_or],\n\n  exact is_deduct.mp_ P Q s1 s2,\nend\n\n\ntheorem C_14_11\n  (Q : formula)\n  (h1 : is_proof Q) :\n  ∀ (Γ : set formula), is_deduct Γ Q :=\nbegin\n  unfold is_proof at h1,\n\n  intros Γ,\n  rewrite <- set.union_empty Γ,\n  rewrite set.union_comm,\n  exact T_14_10 Q ∅ h1 Γ,\nend\n\n\nexample :\n  C_14_11 = proof_imp_deduct :=\nbegin\n  refl,\nend\n\n\ntheorem T_14_12\n  (P Q : formula)\n  (Δ Γ : set formula)\n  (h1 : is_deduct Δ P)\n  (h2 : is_deduct Γ (P.imp_ Q)) :\n  is_deduct (Δ ∪ Γ) Q :=\nbegin\n  have s1 : is_deduct (Δ ∪ Γ) P,\n  apply T_14_10,\n  exact h1,\n\n  have s2 : is_deduct (Δ ∪ Γ) (P.imp_ Q),\n  rewrite set.union_comm,\n  apply T_14_10,\n  exact h2,\n\n  exact is_deduct.mp_ P Q s2 s1,\nend\n\n\ntheorem C_14_13\n  (P Q : formula)\n  (Δ : set formula)\n  (h1 : is_deduct Δ P)\n  (h2 : is_deduct Δ (P.imp_ Q)) :\n  is_deduct Δ Q :=\nbegin\n  have s1 : is_deduct (Δ ∪ Δ) Q, \n  exact T_14_12 P Q Δ Δ h1 h2,\n\n  simp only [set.union_self] at s1,\n  exact s1,\nend\n\n\ntheorem C_14_13'\n  (P Q : formula)\n  (Δ : set formula)\n  (h1 : is_deduct Δ P)\n  (h2 : is_deduct Δ (P.imp_ Q)) :\n  is_deduct Δ Q :=\nbegin\n  exact is_deduct.mp_ P Q h2 h1,\nend\n\n\ntheorem C_14_14\n  (P Q : formula)\n  (Γ : set formula)\n  (h1 : is_proof P)\n  (h2 : is_deduct Γ (P.imp_ Q)) :\n  is_deduct Γ Q :=\nbegin\n  have s1 : is_deduct Γ P,\n  exact C_14_11 P h1 Γ,\n\n  exact is_deduct.mp_ P Q h2 s1,\nend\n\nalias C_14_14 <- mp_proof_deduct\n\n\ntheorem C_14_15\n  (P Q : formula)\n  (Δ : set formula)\n  (h1 : is_deduct Δ P)\n  (h2 : is_proof (P.imp_ Q)) :\n  is_deduct Δ Q :=\nbegin\n  have s1 : is_deduct Δ (P.imp_ Q),\n  exact C_14_11 (P.imp_ Q) h2 Δ,\n\n  exact is_deduct.mp_ P Q s1 h1,\nend\n\nalias C_14_15 <- mp_deduct_proof\n\n\ntheorem T_14_16\n  (Q : formula)\n  (Δ Γ : set formula)\n  (h1 : is_deduct Γ Q)\n  (h2 : ∀ (P : formula), P ∈ Γ → is_deduct Δ P) :\n  is_deduct Δ Q :=\nbegin\n  induction h1,\n  case is_deduct.axiom_ : h1_P h1_1\n  {\n    apply is_deduct.axiom_,\n    exact h1_1,\n  },\n  case is_deduct.assume_ : h1_P h1_1\n  {\n    exact h2 h1_P h1_1,\n  },\n  case is_deduct.mp_ : h1_P h1_Q h1_1 h1_2 h1_ih_1 h1_ih_2\n  {\n    exact is_deduct.mp_ h1_P h1_Q h1_ih_1 h1_ih_2,\n  },\nend\n\n\ntheorem C_14_17\n  (Q : formula)\n  (Γ : set formula)\n  (h1 : is_deduct Γ Q)\n  (h2 : ∀ (P : formula), P ∈ Γ → is_proof P) :\n  is_proof Q :=\nbegin\n  unfold is_proof at h2,\n\n  unfold is_proof,\n  exact T_14_16 Q ∅ Γ h1 h2,\nend\n\n\ntheorem eval_not\n  (P : formula)\n  (val : valuation) :\n  formula.eval_atomic val (not_ P) = bool.tt ↔\n    ¬ (formula.eval_atomic val P = bool.tt) :=\nbegin\n  unfold formula.eval_atomic,\n  cases formula.eval_atomic val P;\n  exact dec_trivial,\nend\n\n\ntheorem eval_imp\n  (P Q : formula)\n  (val : valuation) :\n  formula.eval_atomic val (imp_ P Q) = bool.tt ↔\n    ((formula.eval_atomic val P = bool.tt) → (formula.eval_atomic val Q = bool.tt)) :=\nbegin\n  unfold formula.eval_atomic,\n  cases formula.eval_atomic val P;\n  cases formula.eval_atomic val Q;\n  exact dec_trivial,\nend\n\n\ntheorem is_tauto_prop_true :\n  true_.is_tauto_atomic :=\nbegin\n  unfold formula.is_tauto_atomic,\n  intro val,\n  unfold formula.eval_atomic,\nend\n\n\ntheorem is_tauto_prop_1\n  (P Q : formula) :\n  (P.imp_ (Q.imp_ P)).is_tauto_atomic :=\nbegin\n  unfold formula.is_tauto_atomic,\n  intro val,\n  simp only [eval_imp],\n  tauto,\nend\n\n\ntheorem is_tauto_prop_2\n  (P Q R : formula) :\n  ((P.imp_ (Q.imp_ R)).imp_ ((P.imp_ Q).imp_ (P.imp_ R))).is_tauto_atomic :=\nbegin\n  unfold formula.is_tauto_atomic,\n  intro val,\n  simp only [eval_imp],\n  tauto,\nend\n\n\ntheorem is_tauto_prop_3\n  (P Q : formula) :\n  (((not_ P).imp_ (not_ Q)).imp_ (Q.imp_ P)).is_tauto_atomic :=\nbegin\n  unfold formula.is_tauto_atomic,\n  intro val,\n  simp only [eval_not, eval_imp],\n  tauto,\nend\n\n\ntheorem is_tauto_mp\n  (P Q : formula)\n  (h1 : (P.imp_ Q).is_tauto_atomic)\n  (h2 : P.is_tauto_atomic) :\n  Q.is_tauto_atomic :=\nbegin\n  unfold formula.is_tauto_atomic at h1,\n  unfold formula.is_tauto_atomic at h2,\n\n  unfold formula.is_tauto_atomic,\n  intro val,\n  simp only [eval_imp] at h1,\n  apply h1,\n  exact h2 val,\nend\n\n\nexample\n  (P : formula)\n  (h1 : is_prop_proof P) :\n  P.is_tauto_atomic :=\nbegin\n  induction h1,\n  case is_prop_deduct.axiom_ : h1_P h1_1\n  {\n    induction h1_1,\n    case is_prop_axiom.prop_true_ :\n    {\n      exact is_tauto_prop_true,\n    },\n    case is_prop_axiom.prop_1_ : h1_1_P h1_1_Q\n    {\n      exact is_tauto_prop_1 h1_1_P h1_1_Q,\n    },\n    case is_prop_axiom.prop_2_ : h1_1_P h1_1_Q h1_1_R\n    {\n      exact is_tauto_prop_2 h1_1_P h1_1_Q h1_1_R,\n    },\n    case is_prop_axiom.prop_3_ : h1_1_P h1_1_Q\n    {\n      exact is_tauto_prop_3 h1_1_P h1_1_Q,\n    },\n  },\n  case is_prop_deduct.assume_ : h1_P h1_1\n  {\n    simp only [set.mem_empty_eq] at h1_1,\n    contradiction,\n  },\n  case is_prop_deduct.mp_ : h1_P h1_Q h1_1 h1_2 h1_ih_1 h1_ih_2\n  {\n    exact is_tauto_mp h1_P h1_Q h1_ih_1 h1_ih_2,\n  },\nend\n\n\nlemma mem_atomic_set_is_atomic\n  (P P' : formula)\n  (h1 : P' ∈ P.atomic_set) :\n  P'.is_atomic :=\nbegin\n  induction P,\n  case formula.true_\n  {\n    unfold formula.atomic_set at h1,\n    simp only [finset.not_mem_empty] at h1,\n\n    contradiction,\n  },\n  case [formula.pred_, formula.eq_, formula.forall_]\n  {\n    all_goals\n    {\n      unfold formula.atomic_set at h1,\n      simp only [finset.mem_singleton] at h1,\n\n      subst h1,\n      unfold formula.is_atomic,\n    }\n  },\n  case formula.not_ : P P_ih\n  {\n    unfold formula.atomic_set at h1,\n\n    exact P_ih h1,\n  },\n  case formula.imp_ : P Q P_ih Q_ih\n  {\n    unfold formula.atomic_set at h1,\n    simp only [finset.mem_union] at h1,\n\n    tauto,\n  },\nend\n\n\nlemma bnot_eq_tt_iff_not_eq_tt\n  (b : bool) :\n  !b = bool.tt ↔ ¬ b = bool.tt :=\nbegin\n  simp only [bnot_eq_true_eq_eq_ff, eq_ff_eq_not_eq_tt],\nend\n\n\nlemma L_15_7\n  (P P' : formula)\n  (Δ_U : set formula)\n  (val : valuation)\n  (Δ_U' : set formula)\n  (h1 : coe P.atomic_set ⊆ Δ_U)\n  (h2 : Δ_U' = Δ_U.image (eval_atomic_ff_to_not val))\n  (h3 : P' = eval_atomic_ff_to_not val P) :\n  is_deduct Δ_U' P' :=\nbegin\n  subst h2,\n  subst h3,\n  induction P,\n  case formula.true_\n  {\n    apply is_deduct.axiom_,\n    apply is_axiom.prop_true_,\n  },\n  case formula.pred_ : name args\n  {\n    let P := pred_ name args,\n\n    unfold formula.atomic_set at h1,\n    simp only [finset.coe_singleton, set.singleton_subset_iff] at h1,\n\n    unfold eval_atomic_ff_to_not,\n    unfold formula.eval_atomic,\n    apply is_deduct.assume_,\n    simp only [finset.coe_image, set.mem_image, finset.mem_coe],\n    apply exists.intro P,\n    tauto,\n  },\n  case formula.eq_ : x y\n  {\n    let P := eq_ x y,\n\n    unfold formula.atomic_set at h1,\n    simp only [finset.coe_singleton, set.singleton_subset_iff] at h1,\n\n    unfold eval_atomic_ff_to_not,\n    unfold formula.eval_atomic,\n    apply is_deduct.assume_,\n    simp only [finset.coe_image, set.mem_image, finset.mem_coe],\n    apply exists.intro P,\n    tauto,\n  },\n  case formula.not_ : P P_ih\n  {\n    unfold formula.atomic_set at h1,\n\n    unfold eval_atomic_ff_to_not at P_ih,\n\n    unfold eval_atomic_ff_to_not,\n    unfold formula.eval_atomic,\n\n    simp only [bnot_eq_tt_iff_not_eq_tt],\n    split_ifs,\n    {\n      simp only [if_pos h] at P_ih,\n      apply is_deduct.mp_ P,\n      {\n        apply proof_imp_deduct,\n        apply T_14_6,\n      },\n      {\n        exact P_ih h1,\n      },\n    },\n    {\n      simp only [if_neg h] at P_ih,\n      exact P_ih h1,\n    },\n  },\n  case formula.imp_ : P Q P_ih Q_ih\n  {\n    unfold formula.atomic_set at h1,\n    simp only [finset.coe_union, set.union_subset_iff] at h1,\n    cases h1,\n\n    unfold eval_atomic_ff_to_not at P_ih,\n    unfold eval_atomic_ff_to_not at Q_ih,\n\n    unfold eval_atomic_ff_to_not,\n    unfold formula.eval_atomic,\n    simp only [bor_eq_true_eq_eq_tt_or_eq_tt],\n    simp only [bnot_eq_tt_iff_not_eq_tt],\n    split_ifs,\n    {\n      cases h,\n      {\n        simp only [if_neg h] at P_ih,\n        apply is_deduct.mp_ P.not_,\n        {\n          apply proof_imp_deduct,\n          apply T_13_6,\n        },\n        {\n          exact P_ih h1_left,\n        },\n      },\n      {\n        simp only [if_pos h] at Q_ih,\n\n        apply is_deduct.mp_ Q,\n        {\n          apply is_deduct.axiom_,\n          apply is_axiom.prop_1_,\n        },\n        {\n          exact Q_ih h1_right,\n        },\n      }\n    },\n    {\n      push_neg at h,\n      dsimp at h,\n      cases h,\n      simp only [if_pos h_left] at P_ih,\n      simp only [if_neg h_right] at Q_ih,\n      apply is_deduct.mp_ Q.not_,\n      {\n        apply is_deduct.mp_ P,\n        {\n          apply proof_imp_deduct,\n          apply T_14_8,\n        },\n        {\n          exact P_ih h1_left,\n        }\n      },\n      {\n        exact Q_ih h1_right,\n      },\n    }\n  },\n  case formula.forall_ : x P P_ih\n  {\n    let P := forall_ x P,\n\n    unfold formula.atomic_set at h1,\n    simp only [finset.coe_singleton, set.singleton_subset_iff] at h1,\n\n    unfold eval_atomic_ff_to_not,\n    unfold formula.eval_atomic,\n    apply is_deduct.assume_,\n    simp only [finset.coe_image, set.mem_image, finset.mem_coe],\n    apply exists.intro P,\n    tauto,\n  },\nend\n\n\nlemma T_14_9_deduct\n  (P U : formula)\n  (Δ : set formula)\n  (h1 : is_deduct (Δ ∪ {U}) P)\n  (h2 : is_deduct (Δ ∪ {U.not_}) P) :\n  is_deduct Δ P :=\nbegin\n  apply is_deduct.mp_ (U.not_.imp_ P),\n  {\n    apply is_deduct.mp_ (U.imp_ P),\n    {\n      apply proof_imp_deduct,\n      apply T_14_9,\n    },\n    {\n      apply deduction_theorem,\n      exact h1,\n    },\n  },\n  {\n    apply deduction_theorem,\n    exact h2,\n  }\nend\n\n\nlemma eval_atomic_ff_to_not_of_function_update_ite_tt\n  (P P' : formula)\n  (val : valuation)\n  (h1 : P.is_atomic) :\n  eval_atomic_ff_to_not (function.update_ite val P' bool.tt) P =\n    function.update_ite (eval_atomic_ff_to_not val) P' P P :=\nbegin\n  induction P,\n  case formula.true_\n  {\n    unfold function.update_ite,\n    unfold eval_atomic_ff_to_not,\n    tauto,\n  },\n  case [formula.pred_, formula.eq_, formula.forall_]\n  {\n    all_goals\n    {\n      unfold function.update_ite,\n      unfold eval_atomic_ff_to_not,\n      unfold formula.eval_atomic,\n      unfold function.update_ite,\n      split_ifs; tauto,\n    }\n  },\n  case [formula.not_, formula.imp_]\n  {\n    all_goals\n    {\n      unfold formula.is_atomic at h1,\n\n      contradiction,\n    }\n  },\nend\n\n\nlemma eval_atomic_ff_to_not_of_function_update_ite_ff\n  (P P' : formula)\n  (val : valuation)\n  (h1 : P.is_atomic) :\n  eval_atomic_ff_to_not (function.update_ite val P' bool.ff) P =\n    function.update_ite (eval_atomic_ff_to_not val) P' P.not_ P :=\nbegin\n  induction P,\n  case formula.true_\n  {\n    unfold function.update_ite,\n    unfold eval_atomic_ff_to_not,\n    tauto,\n  },\n  case [formula.pred_, formula.eq_, formula.forall_]\n  {\n    all_goals\n    {\n      unfold function.update_ite,\n      unfold eval_atomic_ff_to_not,\n      unfold formula.eval_atomic,\n      unfold function.update_ite,\n      split_ifs; tauto,\n    }\n  },\n  case [formula.not_, formula.imp_]\n  {\n    all_goals\n    {\n      unfold formula.is_atomic at h1,\n\n      contradiction,\n    }\n  },\nend\n\n\nlemma image_of_eval_atomic_ff_to_not_of_function_update_ite\n  (U : formula)\n  (Δ : set formula)\n  (val : valuation)\n  (b : bool)\n  (h1_Δ: ∀ (U' : formula), (U' ∈ Δ) → U'.is_atomic)\n  (h1_U: U.is_atomic)\n  (h2: U ∉ Δ) :\n  Δ.image (eval_atomic_ff_to_not (function.update_ite val U b)) =\n    Δ.image (eval_atomic_ff_to_not val) :=\nbegin\n  apply set.image_congr,\n  intros U' a1,\n  specialize h1_Δ U' a1,\n  cases b,\n  {\n    simp only [eval_atomic_ff_to_not_of_function_update_ite_ff U' U val h1_Δ],\n    unfold function.update_ite,\n    simp only [ite_eq_right_iff],\n    intros a2,\n    subst a2,\n    contradiction,\n  },\n  {\n    simp only [eval_atomic_ff_to_not_of_function_update_ite_tt U' U val h1_Δ],\n    unfold function.update_ite,\n    simp only [ite_eq_right_iff],\n    intros a2,\n    subst a2,\n    contradiction,\n  }\nend\n\n\nlemma prop_complete_aux_aux\n  (P U : formula)\n  (Δ : set formula)\n  (h1_Δ : ∀ (U' : formula), U' ∈ Δ → U'.is_atomic)\n  (h1_U : U.is_atomic)\n  (h2 : U ∉ Δ)\n  (h3 : ∀ (val : valuation), is_deduct ((Δ.image (eval_atomic_ff_to_not val)) ∪ {eval_atomic_ff_to_not val U}) P) :\n  ∀ (val : valuation), is_deduct (Δ.image (eval_atomic_ff_to_not val)) P :=\nbegin\n  intros val,\n  apply T_14_9_deduct P U (Δ.image (eval_atomic_ff_to_not val)),\n  {\n    specialize h3 (function.update_ite val U bool.tt),\n    simp only [image_of_eval_atomic_ff_to_not_of_function_update_ite U Δ val bool.tt h1_Δ h1_U h2] at h3,\n    simp only [eval_atomic_ff_to_not_of_function_update_ite_tt U U val h1_U] at h3,\n    unfold function.update_ite at h3,\n    simp only [eq_self_iff_true, if_true] at h3,\n    exact h3,\n  },\n  {\n    specialize h3 (function.update_ite val U bool.ff),\n    simp only [image_of_eval_atomic_ff_to_not_of_function_update_ite U Δ val bool.ff h1_Δ h1_U h2] at h3,\n    simp only [eval_atomic_ff_to_not_of_function_update_ite_ff U U val h1_U] at h3,\n    unfold function.update_ite at h3,\n    simp only [eq_self_iff_true, if_true] at h3,\n    exact h3,\n  }\nend\n\n\ntheorem prop_complete_aux\n  (P : formula)\n  (Δ_U : finset formula)\n  (h1 : P.is_tauto_atomic)\n  (h2 : Δ_U ⊆ P.atomic_set)\n  (h3 : ∀ (val : valuation), is_deduct (Δ_U.image (eval_atomic_ff_to_not val)) P) :\n  is_deduct ∅ P :=\nbegin\n  induction Δ_U using finset.induction_on,\n  case h₁\n  {\n    simp only [finset.image_empty, finset.coe_empty, forall_const] at h3,\n\n    exact h3,\n  },\n  case h₂ : U Δ_U Δ_U_1 Δ_U_2\n  {\n    apply Δ_U_2,\n    {\n      simp only [finset.insert_subset] at h2,\n      cases h2,\n\n      exact h2_right,\n    },\n    {\n      simp only [finset.insert_subset] at h2,\n      cases h2,\n\n      simp only [finset.image_insert, finset.coe_insert, finset.coe_image] at h3,\n\n      simp only [finset.coe_image],\n      apply prop_complete_aux_aux P U Δ_U,\n      {\n        intros U' a1,\n        apply mem_atomic_set_is_atomic P U',\n        apply h2_right,\n        exact a1,\n      },\n      {\n        apply mem_atomic_set_is_atomic P U,\n        exact h2_left,\n      },\n      {\n        exact Δ_U_1,\n      },\n      {\n        simp only [set.union_singleton],\n        exact h3,\n      }\n    }\n  },\nend\n\n\ntheorem prop_complete\n  (P : formula)\n  (h1 : P.is_tauto_atomic) :\n  is_proof P :=\nbegin\n  unfold is_proof,\n\n  apply prop_complete_aux P P.atomic_set h1,\n  {\n    refl,\n  },\n  {\n    intros val,\n    apply L_15_7 P P P.atomic_set val (P.atomic_set.image (eval_atomic_ff_to_not val)),\n    {\n      refl,\n    },\n    {\n      simp only [finset.coe_image],\n    },\n    {\n      unfold formula.is_tauto_atomic at h1,\n\n      unfold eval_atomic_ff_to_not,\n      specialize h1 val,\n      simp only [if_pos h1],\n    }\n  }\nend\n", "meta": {"author": "pthomas505", "repo": "lean3", "sha": "eb449be2b9a92becda4be38aac76e080194e3f7c", "save_path": "github-repos/lean/pthomas505-lean3", "path": "github-repos/lean/pthomas505-lean3/lean3-eb449be2b9a92becda4be38aac76e080194e3f7c/src/metalogic/fol/prop.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.488856332392001}}
{"text": "import data.complex.is_R_or_C\nimport analysis.inner_product_space.pi_L2\n\nvariables {m n : ℕ}\n\nvariables (𝕜 : Type*)\n[is_R_or_C 𝕜]\n\nopen_locale big_operators complex_conjugate matrix topological_space\n\nlocal notation `𝕜^n` := (euclidean_space 𝕜 (fin n))\n\nlocal notation `M_n` := (matrix (fin n) (fin n) 𝕜)\n\nlocal notation `U_n` := matrix.unitary_group (fin n) 𝕜\n\nvariables (A B : ℕ → M_n) (L : M_n)\n\n\n/-\nmatrix_SVD should look like this:\n-/\nnoncomputable def matrix_SVD (M : M_n) : (fin 3) → M_n := sorry\n\n\ntheorem limit_svd_is_svd (h_lim : filter.tendsto A filter.at_top (𝓝 L))", "meta": {"author": "hparshall", "repo": "lean-matrix-analysis", "sha": "cc1b9949065257b6c19f047a5a996bfac29f178e", "save_path": "github-repos/lean/hparshall-lean-matrix-analysis", "path": "github-repos/lean/hparshall-lean-matrix-analysis/lean-matrix-analysis-cc1b9949065257b6c19f047a5a996bfac29f178e/src/svd_limit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835452961425, "lm_q2_score": 0.585101154203231, "lm_q1q2_score": 0.4888423866705805}}
{"text": "import order\n\nimport lib.list\n\nimport etv.defs\nimport etv.label\n\nopen order_dual\n\nvariables {α : Type*} [linear_order α] (C : config α)\n\nlemma config.join_n2_n2_case_ff\n  (S : finset α) (n : ℕ) (a x b : α) (c1 c2 : list α) (lab : C.label S)\n  (a_in_S : a ∈ S) (x_in_S : x ∈ S) (b_in_S : b ∈ S)\n  (hc1 : C.ncup (n+2) (c1 ++ [a, x])) (c1_in_S : c1.in S)\n  (hc2 : C.ncup (n+2) (x :: b :: c2)) (c2_in_S : c2.in S)\n  (sab : ¬lab.slope a b) : \n  C.has_ngon (n+3) S :=\nbegin\n  have hax : a < x := by simp [config.cup, config.ncup] at hc1; tauto,\n  have hxb : x < b := by simp [config.cup, config.ncup] at hc2; tauto,\n  have hab : a < b := has_lt.lt.trans hax hxb,\n  have h_b_c2 : b :: c2 ≠ [] := by simp,\n  rcases list.take_last h_b_c2 with ⟨c, c3, eq_c2⟩,\n  rw eq_c2 at hc2,\n  have hxc : x < c := by\n    apply hc2.head'_lt_last' x c; simp; dec_trivial,\n  have c_in_S : c ∈ S := begin\n    have h_in : (b :: c2).in S := by simp; tauto,\n    rw eq_c2 at h_in, simp at h_in, tauto,\n  end,\n  by_cases haxc : C.cup3 a x c,\n  { apply ncup_is_ngon, dec_trivial,\n    use c1 ++ [a, x, c], split, split,\n    simp, rw config.ncup at hc1, tauto,\n    simp, simp [config.ncup] at hc1, tauto,\n    simp, tauto },\n  { use [[a, x, c], a :: (c3 ++ [c])],\n    refine ⟨⟨_, _⟩, _, _⟩; try {simp}; try {tauto},\n    split, tauto, split, dec_trivial,\n    rw ←eq_c2, rw ←eq_c2 at hc2,\n    have hbc2 := hc2.tail.left, simp at hbc2,\n    apply hbc2.extend_left sab; try {tauto},\n    simp, tauto, simp [config.ncup] at hc2, \n    ring_nf, ring_nf at hc2, simp, simp at hc2, \n    exact hc2.right, split, assumption,\n    have hh : (b :: c2).in S := by simp; tauto,\n    rw eq_c2 at hh, simp at hh, exact hh },\nend\n\nlemma config.join_n2_n2_case_tt\n  (S : finset α) (n : ℕ) (a x b : α) (c1 c2 : list α) (lab : C.label S)\n  (a_in_S : a ∈ S) (x_in_S : x ∈ S) (b_in_S : b ∈ S)\n  (hc1 : C.ncup (n+2) (c1 ++ [a, x])) (c1_in_S : c1.in S)\n  (hc2 : C.ncup (n+2) (x :: b :: c2)) (c2_in_S : c2.in S)\n  (hab : lab.slope a b) : \n  C.has_ngon (n+3) S :=\nbegin\n  rw ←finset.mem_mirror at a_in_S x_in_S b_in_S,\n  rw ←mirror.ncup at hc1 hc2,\n  rw ←list.mirror_in at c1_in_S c2_in_S,\n  simp at hc1 hc2,\n  have hba := hab, rw ←mirror_slope at hba,\n  \n  have mirrored_goal :=\n    (C.mirror).join_n2_n2_case_ff \n      S.mirror n \n      (to_dual b) (to_dual x) (to_dual a)\n      c2.mirror c1.mirror lab.mirror\n      b_in_S x_in_S a_in_S hc2 c2_in_S hc1 c1_in_S hba,\n  rw mirror.has_ngon at mirrored_goal,\n  tauto\nend\n\nlemma config.join_n2_n2 (S : finset α)\n  {n : ℕ} \n  (cap4_free : ¬C.has_ncap 4 S)\n  {c1 : list α} (hc1 : C.ncup (n+2) c1) (c1_in_S : c1.in S)\n  {c2 : list α} (hc2 : C.ncup (n+2) c2) (c2_in_S : c2.in S)\n  (x : α) (hx1 : x ∈ c1.last') (hx2 : x ∈ c2.head') : C.has_ngon (n+3) S :=\nbegin\n  -- Introduce variables\n  have c1_size2 : 2 ≤ c1.length := by cases hc1; linarith,\n  rcases list.take_last2 c1_size2 with ⟨a, x, c1', eq_c1⟩, \n  subst eq_c1, simp at hx1, subst hx1,\n  have c2_size2 : 2 ≤ c2.length := by cases hc2; linarith,\n  rcases list.take_head2 c2_size2 with ⟨x, b, c2', eq_c2⟩,\n  subst eq_c2, simp at hx2, subst hx2,\n\n  have lab := cap4_free_label cap4_free,\n  by_cases hl : lab.slope a b,\n  { apply C.join_n2_n2_case_tt S n a x b c1' c2' lab;\n    simp at c1_in_S c2_in_S; tauto },\n  { apply C.join_n2_n2_case_ff S n a x b c1' c2' lab;\n    simp at c1_in_S c2_in_S; tauto }, \nend ", "meta": {"author": "jcpaik", "repo": "erdos-tuza-valtr", "sha": "7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef", "save_path": "github-repos/lean/jcpaik-erdos-tuza-valtr", "path": "github-repos/lean/jcpaik-erdos-tuza-valtr/erdos-tuza-valtr-7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef/src/main/lemmas/join_n2_n2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085859124002, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4888226571741068}}
{"text": "import .interp\nimport .expr\n\nopen arith\nopen arith.var\n\n-- variables\n\ndef X := Δ 0\ndef Y := Δ 1\ndef Z := Δ 2\ndef W := Δ 0  -- W and X are the same variable\n\n-- an interpretation\n\ndef init : var → nat\n| v := nat.zero\n\n-- test interpretation override \n\nexample : init X = 0 := rfl\nexample : init Y = 0 := rfl\nexample : init Z = 0 := rfl\n\n-- \"assignment operation\"\n-- {X = 0, Y = 0, Z = 0}\ndef st_1 := override init X 2\n-- {X = 2, Y = 0, Z = 0}\n\nexample : st_1 X = 2 := rfl\nexample : st_1 Y = 0 := rfl\nexample : st_1 Z = 0 := rfl\n\n-- \"assignment operation\"\n-- {X = 2, Y = 0, Z = 0}\ndef st_2 := override (st_1) Z 5\n-- {X = 2, Y = 0, Z = 5}\n\nexample : st_2 X = 2 := rfl\nexample : st_2 Y = 0 := rfl\nexample : st_2 Z = 5 := rfl\n\n-- example expressions\n\ndef e1 := [0] -- overloaded []: literal expresion\ndef e2 := e1 + e1\ndef e3 := e2++\ndef e4 := ⟨ X ⟩   -- []: \"var\" expression\n\n-- test evaluation\n\nexample : eval e3 init = 1 := rfl\nexample : eval e4 st_2 = 7 := rfl\n\n", "meta": {"author": "kevinsullivan", "repo": "cs6501s22", "sha": "c55d342145b127e7b7bf396c660966034e80a944", "save_path": "github-repos/lean/kevinsullivan-cs6501s22", "path": "github-repos/lean/kevinsullivan-cs6501s22/cs6501s22-c55d342145b127e7b7bf396c660966034e80a944/src/assignments/hw5_expr_langs/arith/test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4888226540464714}}
{"text": "/-\nCopyright (c) 2022 OpenAI. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Daniel Selsam\n-/\nimport logic.function.basic\nimport data.finset.card\nimport data.fintype.basic\n\n/--\nFive different awards are to be given to three students. \nEach student will receive at least one award. \nIn how many different ways can the awards be distributed?\n-/\ntheorem amc8_2020_p23 : \n  (finset.filter function.surjective finset.univ : finset (fin 5 → fin 3)).card = 150 := \nbegin\n  dec_trivial\nend", "meta": {"author": "leanprover-community", "repo": "mathzoo", "sha": "87e9b492daeb929838706942aaa2437621b34a0e", "save_path": "github-repos/lean/leanprover-community-mathzoo", "path": "github-repos/lean/leanprover-community-mathzoo/mathzoo-87e9b492daeb929838706942aaa2437621b34a0e/src/mathzoo/olympiads/amc/8/2020/p23.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577680977182186, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.48880142478320465}}
{"text": "example (P Q F : Type) : (P → Q) → ((Q → F) → (P → F)) :=\nbegin\n    intro pq,\n    intro qf,\n    intro p,\n    apply qf,\n    apply pq,\n    exact p,\nend\n", "meta": {"author": "nomoid", "repo": "lean-proofs", "sha": "b9f03a24623d1a1d111d6c2bbf53c617e2596d6a", "save_path": "github-repos/lean/nomoid-lean-proofs", "path": "github-repos/lean/nomoid-lean-proofs/lean-proofs-b9f03a24623d1a1d111d6c2bbf53c617e2596d6a/src/world5/level7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.488730875851778}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nA model of ZFC in Lean.\n-/\nimport data.set.basic\n\nuniverses u v\n\n/-- The type of `n`-ary functions `α → α → ... → α`. -/\ndef arity (α : Type u) : nat → Type u\n| 0     := α\n| (n+1) := α → arity n\n\nnamespace arity\n\n/-- Constant `n`-ary function with value `a`. -/\ndef const {α : Type u} (a : α) : ∀ n, arity α n\n| 0 := a\n| (n+1) := λ _, const n\n\ninstance arity.inhabited {α n} [inhabited α] : inhabited (arity α n) :=\n⟨const (default _) _⟩\n\nend arity\n\n/-- The type of pre-sets in universe `u`. A pre-set\n  is a family of pre-sets indexed by a type in `Type u`.\n  The ZFC universe is defined as a quotient of this\n  to ensure extensionality. -/\ninductive pSet : Type (u+1)\n| mk (α : Type u) (A : α → pSet) : pSet\n\nnamespace pSet\n\n/-- The underlying type of a pre-set -/\ndef type : pSet → Type u\n| ⟨α, A⟩ := α\n\n/-- The underlying pre-set family of a pre-set -/\ndef func : Π (x : pSet), x.type → pSet\n| ⟨α, A⟩ := A\n\ntheorem mk_type_func : Π (x : pSet), mk x.type x.func = x\n| ⟨α, A⟩ := rfl\n\n/-- Two pre-sets are extensionally equivalent if every\n  element of the first family is extensionally equivalent to\n  some element of the second family and vice-versa. -/\ndef equiv (x y : pSet) : Prop :=\npSet.rec (λα z m ⟨β, B⟩, (∀a, ∃b, m a (B b)) ∧ (∀b, ∃a, m a (B b))) x y\n\ntheorem equiv.refl (x) : equiv x x :=\npSet.rec_on x $ λα A IH, ⟨λa, ⟨a, IH a⟩, λa, ⟨a, IH a⟩⟩\n\ntheorem equiv.euc {x} : Π {y z}, equiv x y → equiv z y → equiv x z :=\npSet.rec_on x $ λα A IH y, pSet.cases_on y $ λβ B ⟨γ, Γ⟩ ⟨αβ, βα⟩ ⟨γβ, βγ⟩,\n⟨λa, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, IH a ab bc⟩,\n  λc, let ⟨b, cb⟩ := γβ c, ⟨a, ba⟩ := βα b in ⟨a, IH a ba cb⟩⟩\n\ntheorem equiv.symm {x y} : equiv x y → equiv y x :=\nequiv.euc (equiv.refl y)\n\ntheorem equiv.trans {x y z} (h1 : equiv x y) (h2 : equiv y z) : equiv x z :=\nequiv.euc h1 (equiv.symm h2)\n\ninstance setoid : setoid pSet :=\n⟨pSet.equiv, equiv.refl, λx y, equiv.symm, λx y z, equiv.trans⟩\n\nprotected def subset : pSet → pSet → Prop\n| ⟨α, A⟩ ⟨β, B⟩ := ∀a, ∃b, equiv (A a) (B b)\n\ninstance : has_subset pSet := ⟨pSet.subset⟩\n\ntheorem equiv.ext : Π (x y : pSet), equiv x y ↔ (x ⊆ y ∧ y ⊆ x)\n| ⟨α, A⟩ ⟨β, B⟩ :=\n  ⟨λ⟨αβ, βα⟩, ⟨αβ, λb, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩,\n    λ⟨αβ, βα⟩, ⟨αβ, λb, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩⟩\n\ntheorem subset.congr_left : Π {x y z : pSet}, equiv x y → (x ⊆ z ↔ y ⊆ z)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=\n  ⟨λαγ b, let ⟨a, ba⟩ := βα b, ⟨c, ac⟩ := αγ a in ⟨c, equiv.trans (equiv.symm ba) ac⟩,\n    λβγ a, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, equiv.trans ab bc⟩⟩\n\ntheorem subset.congr_right : Π {x y z : pSet}, equiv x y → (z ⊆ x ↔ z ⊆ y)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=\n  ⟨λγα c, let ⟨a, ca⟩ := γα c, ⟨b, ab⟩ := αβ a in ⟨b, equiv.trans ca ab⟩,\n    λγβ c, let ⟨b, cb⟩ := γβ c, ⟨a, ab⟩ := βα b in ⟨a, equiv.trans cb (equiv.symm ab)⟩⟩\n\n/-- `x ∈ y` as pre-sets if `x` is extensionally equivalent to a member\n  of the family `y`. -/\ndef mem : pSet → pSet → Prop\n| x ⟨β, B⟩ := ∃b, equiv x (B b)\ninstance : has_mem pSet.{u} pSet.{u} := ⟨mem⟩\n\ntheorem mem.mk {α: Type u} (A : α → pSet) (a : α) : A a ∈ mk α A :=\nshow mem (A a) ⟨α, A⟩, from ⟨a, equiv.refl (A a)⟩\n\ntheorem mem.ext : Π {x y : pSet.{u}}, (∀w:pSet.{u}, w ∈ x ↔ w ∈ y) → equiv x y\n| ⟨α, A⟩ ⟨β, B⟩ h := ⟨λa, (h (A a)).1 (mem.mk A a),\n    λb, let ⟨a, ha⟩ := (h (B b)).2 (mem.mk B b) in ⟨a, equiv.symm ha⟩⟩\n\ntheorem mem.congr_right : Π {x y : pSet.{u}}, equiv x y → (∀{w:pSet.{u}}, w ∈ x ↔ w ∈ y)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩ w :=\n  ⟨λ⟨a, ha⟩, let ⟨b, hb⟩ := αβ a in ⟨b, equiv.trans ha hb⟩,\n    λ⟨b, hb⟩, let ⟨a, ha⟩ := βα b in ⟨a, equiv.euc hb ha⟩⟩\n\ntheorem equiv_iff_mem {x y : pSet.{u}} : equiv x y ↔ (∀{w:pSet.{u}}, w ∈ x ↔ w ∈ y) :=\n⟨mem.congr_right, match x, y with\n| ⟨α, A⟩, ⟨β, B⟩, h := ⟨λ a, h.1 (mem.mk A a), λ b,\n  let ⟨a, h⟩ := h.2 (mem.mk B b) in ⟨a, h.symm⟩⟩\nend⟩\n\ntheorem mem.congr_left : Π {x y : pSet.{u}}, equiv x y → (∀{w : pSet.{u}}, x ∈ w ↔ y ∈ w)\n| x y h ⟨α, A⟩ := ⟨λ⟨a, ha⟩, ⟨a, equiv.trans (equiv.symm h) ha⟩, λ⟨a, ha⟩, ⟨a, equiv.trans h ha⟩⟩\n\n/-- Convert a pre-set to a `set` of pre-sets. -/\ndef to_set (u : pSet.{u}) : set pSet.{u} := {x | x ∈ u}\n\n/-- Two pre-sets are equivalent iff they have the same members. -/\ntheorem equiv.eq {x y : pSet} : equiv x y ↔ to_set x = to_set y :=\nequiv_iff_mem.trans set.ext_iff.symm\n\ninstance : has_coe pSet (set pSet) := ⟨to_set⟩\n\n/-- The empty pre-set -/\nprotected def empty : pSet := ⟨ulift empty, λe, match e with end⟩\n\ninstance : has_emptyc pSet := ⟨pSet.empty⟩\n\ninstance : inhabited pSet := ⟨∅⟩\n\ntheorem mem_empty (x : pSet.{u}) : x ∉ (∅:pSet.{u}) := λe, match e with end\n\n/-- Insert an element into a pre-set -/\nprotected def insert : pSet → pSet → pSet\n| u ⟨α, A⟩ := ⟨option α, λo, option.rec u A o⟩\n\ninstance : has_insert pSet pSet := ⟨pSet.insert⟩\n\ninstance : has_singleton pSet pSet := ⟨λ s, insert s ∅⟩\n\ninstance : is_lawful_singleton pSet pSet := ⟨λ _, rfl⟩\n\n/-- The n-th von Neumann ordinal -/\ndef of_nat : ℕ → pSet\n| 0     := ∅\n| (n+1) := pSet.insert (of_nat n) (of_nat n)\n\n/-- The von Neumann ordinal ω -/\ndef omega : pSet := ⟨ulift ℕ, λn, of_nat n.down⟩\n\n/-- The separation operation `{x ∈ a | p x}` -/\nprotected def sep (p : set pSet) : pSet → pSet\n| ⟨α, A⟩ := ⟨{a // p (A a)}, λx, A x.1⟩\n\ninstance : has_sep pSet pSet := ⟨pSet.sep⟩\n\n/-- The powerset operator -/\ndef powerset : pSet → pSet\n| ⟨α, A⟩ := ⟨set α, λp, ⟨{a // p a}, λx, A x.1⟩⟩\n\ntheorem mem_powerset : Π {x y : pSet}, y ∈ powerset x ↔ y ⊆ x\n| ⟨α, A⟩ ⟨β, B⟩ := ⟨λ⟨p, e⟩, (subset.congr_left e).2 $ λ⟨a, pa⟩, ⟨a, equiv.refl (A a)⟩,\n  λβα, ⟨{a | ∃b, equiv (B b) (A a)}, λb, let ⟨a, ba⟩ := βα b in ⟨⟨a, b, ba⟩, ba⟩,\n    λ⟨a, b, ba⟩, ⟨b, ba⟩⟩⟩\n\n/-- The set union operator -/\ndef Union : pSet → pSet\n| ⟨α, A⟩ := ⟨Σx, (A x).type, λ⟨x, y⟩, (A x).func y⟩\n\ntheorem mem_Union : Π {x y : pSet.{u}}, y ∈ Union x ↔ ∃ z:pSet.{u}, ∃_:z ∈ x, y ∈ z\n| ⟨α, A⟩ y :=\n  ⟨λ⟨⟨a, c⟩, (e : equiv y ((A a).func c))⟩,\n    have func (A a) c ∈ mk (A a).type (A a).func, from mem.mk (A a).func c,\n    ⟨_, mem.mk _ _, (mem.congr_left e).2 (by rwa mk_type_func at this)⟩,\n  λ⟨⟨β, B⟩, ⟨a, (e:equiv (mk β B) (A a))⟩, ⟨b, yb⟩⟩,\n    by rw ←(mk_type_func (A a)) at e; exact\n    let ⟨βt, tβ⟩ := e, ⟨c, bc⟩ := βt b in ⟨⟨a, c⟩, equiv.trans yb bc⟩⟩\n\n/-- The image of a function -/\ndef image (f : pSet.{u} → pSet.{u}) : pSet.{u} → pSet\n| ⟨α, A⟩ := ⟨α, λa, f (A a)⟩\n\ntheorem mem_image {f : pSet.{u} → pSet.{u}} (H : ∀{x y}, equiv x y → equiv (f x) (f y)) :\n  Π {x y : pSet.{u}}, y ∈ image f x ↔ ∃z ∈ x, equiv y (f z)\n| ⟨α, A⟩ y := ⟨λ⟨a, ya⟩, ⟨A a, mem.mk A a, ya⟩, λ⟨z, ⟨a, za⟩, yz⟩, ⟨a, equiv.trans yz (H za)⟩⟩\n\n/-- Universe lift operation -/\nprotected def lift : pSet.{u} → pSet.{max u v}\n| ⟨α, A⟩ := ⟨ulift α, λ⟨x⟩, lift (A x)⟩\n\n/-- Embedding of one universe in another -/\ndef embed : pSet.{max (u+1) v} := ⟨ulift.{v u+1} pSet, λ⟨x⟩, pSet.lift.{u (max (u+1) v)} x⟩\n\ntheorem lift_mem_embed : Π (x : pSet.{u}), pSet.lift.{u (max (u+1) v)} x ∈ embed.{u v} :=\nλx, ⟨⟨x⟩, equiv.refl _⟩\n\n/-- Function equivalence is defined so that `f ~ g` iff\n  `∀ x y, x ~ y → f x ~ g y`. This extends to equivalence of n-ary\n  functions. -/\ndef arity.equiv : Π {n}, arity pSet.{u} n → arity pSet.{u} n → Prop\n| 0     a b := equiv a b\n| (n+1) a b := ∀ x y, equiv x y → arity.equiv (a x) (b y)\n\nlemma arity.equiv_const {a : pSet.{u}} : ∀ n, arity.equiv (arity.const a n) (arity.const a n)\n| 0 := equiv.refl _\n| (n+1) := λ x y h, arity.equiv_const _\n\n/-- `resp n` is the collection of n-ary functions on `pSet` that respect\n  equivalence, i.e. when the inputs are equivalent the output is as well. -/\ndef resp (n) := { x : arity pSet.{u} n // arity.equiv x x }\n\ninstance resp.inhabited {n} : inhabited (resp n) :=\n⟨⟨arity.const (default _) _, arity.equiv_const _⟩⟩\n\ndef resp.f {n} (f : resp (n+1)) (x : pSet) : resp n :=\n⟨f.1 x, f.2 _ _ $ equiv.refl x⟩\n\ndef resp.equiv {n} (a b : resp n) : Prop := arity.equiv a.1 b.1\n\ntheorem resp.refl {n} (a : resp n) : resp.equiv a a := a.2\n\ntheorem resp.euc : Π {n} {a b c : resp n}, resp.equiv a b → resp.equiv c b → resp.equiv a c\n| 0     a b c hab hcb := equiv.euc hab hcb\n| (n+1) a b c hab hcb := by delta resp.equiv; simp [arity.equiv]; exact λx y h,\n  @resp.euc n (a.f x) (b.f y) (c.f y) (hab _ _ h) (hcb _ _ $ equiv.refl y)\n\ninstance resp.setoid {n} : setoid (resp n) :=\n⟨resp.equiv, resp.refl, λx y h, resp.euc (resp.refl y) h,\n  λx y z h1 h2, resp.euc h1 $ resp.euc (resp.refl z) h2⟩\n\nend pSet\n\n/-- The ZFC universe of sets consists of the type of pre-sets,\n  quotiented by extensional equivalence. -/\ndef Set : Type (u+1) := quotient pSet.setoid.{u}\n\nnamespace pSet\n\nnamespace resp\n\ndef eval_aux : Π {n}, {f : resp n → arity Set.{u} n // ∀ (a b : resp n), resp.equiv a b → f a = f b}\n| 0     := ⟨λa, ⟦a.1⟧, λa b h, quotient.sound h⟩\n| (n+1) := let F : resp (n + 1) → arity Set (n + 1) := λa, @quotient.lift _ _ pSet.setoid\n    (λx, eval_aux.1 (a.f x)) (λb c h, eval_aux.2 _ _ (a.2 _ _ h)) in\n  ⟨F, λb c h, funext $ @quotient.ind _ _ (λq, F b q = F c q) $ λz,\n  eval_aux.2 (resp.f b z) (resp.f c z) (h _ _ (equiv.refl z))⟩\n\n/-- An equivalence-respecting function yields an n-ary Set function. -/\ndef eval (n) : resp n → arity Set.{u} n := eval_aux.1\n\ntheorem eval_val {n f x} : (@eval (n+1) f : Set → arity Set n) ⟦x⟧ = eval n (resp.f f x) := rfl\n\nend resp\n\n/-- A set function is \"definable\" if it is the image of some n-ary pre-set\n  function. This isn't exactly definability, but is useful as a sufficient\n  condition for functions that have a computable image. -/\nclass inductive definable (n) : arity Set.{u} n → Type (u+1)\n| mk (f) : definable (resp.eval _ f)\nattribute [instance] definable.mk\n\ndef definable.eq_mk {n} (f) : Π {s : arity Set.{u} n} (H : resp.eval _ f = s), definable n s\n| ._ rfl := ⟨f⟩\n\ndef definable.resp {n} : Π (s : arity Set.{u} n) [definable n s], resp n\n| ._ ⟨f⟩ := f\n\ntheorem definable.eq {n} :\n  Π (s : arity Set.{u} n) [H : definable n s], (@definable.resp n s H).eval _ = s\n| ._ ⟨f⟩ := rfl\n\nend pSet\n\nnamespace classical\nopen pSet\n\nnoncomputable def all_definable : Π {n} (F : arity Set.{u} n), definable n F\n| 0     F := let p := @quotient.exists_rep pSet _ F in\n              definable.eq_mk ⟨some p, equiv.refl _⟩ (some_spec p)\n| (n+1) (F : arity Set.{u} (n + 1)) := begin\n    have I := λx, (all_definable (F x)),\n    refine definable.eq_mk ⟨λx:pSet, (@definable.resp _ _ (I ⟦x⟧)).1, _⟩ _,\n    { dsimp [arity.equiv],\n      introsI x y h,\n      rw @quotient.sound pSet _ _ _ h,\n      exact (definable.resp (F ⟦y⟧)).2 },\n    exact funext (λq, quotient.induction_on q $ λx,\n      by simp [resp.eval_val, resp.f]; exact @definable.eq _ (F ⟦x⟧) (I ⟦x⟧))\n  end\n\nend classical\n\nnamespace Set\nopen pSet\n\ndef mk : pSet → Set := quotient.mk\n\n@[simp] theorem mk_eq (x : pSet) : @eq Set ⟦x⟧ (mk x) := rfl\n\n@[simp] lemma eval_mk {n f x} :\n  (@resp.eval (n+1) f : Set → arity Set n) (mk x) = resp.eval n (resp.f f x) :=\nrfl\n\ndef mem : Set → Set → Prop :=\nquotient.lift₂ pSet.mem\n  (λx y x' y' hx hy, propext (iff.trans (mem.congr_left hx) (mem.congr_right hy)))\n\ninstance : has_mem Set Set := ⟨mem⟩\n\n/-- Convert a ZFC set into a `set` of sets -/\ndef to_set (u : Set.{u}) : set Set.{u} := {x | x ∈ u}\n\nprotected def subset (x y : Set.{u}) :=\n∀ ⦃z⦄, z ∈ x → z ∈ y\n\ninstance has_subset : has_subset Set :=\n⟨Set.subset⟩\n\nlemma subset_def {x y : Set.{u}} : x ⊆ y ↔ ∀ ⦃z⦄, z ∈ x → z ∈ y := iff.rfl\n\ntheorem subset_iff : Π (x y : pSet), mk x ⊆ mk y ↔ x ⊆ y\n| ⟨α, A⟩ ⟨β, B⟩ := ⟨λh a, @h ⟦A a⟧ (mem.mk A a),\n  λh z, quotient.induction_on z (λz ⟨a, za⟩, let ⟨b, ab⟩ := h a in ⟨b, equiv.trans za ab⟩)⟩\n\ntheorem ext {x y : Set.{u}} : (∀z:Set.{u}, z ∈ x ↔ z ∈ y) → x = y :=\nquotient.induction_on₂ x y (λu v h, quotient.sound (mem.ext (λw, h ⟦w⟧)))\n\ntheorem ext_iff {x y : Set.{u}} : (∀z:Set.{u}, z ∈ x ↔ z ∈ y) ↔ x = y :=\n⟨ext, λh, by simp [h]⟩\n\n/-- The empty set -/\ndef empty : Set := mk ∅\ninstance : has_emptyc Set := ⟨empty⟩\ninstance : inhabited Set := ⟨∅⟩\n\n@[simp] theorem mem_empty (x) : x ∉ (∅:Set.{u}) :=\nquotient.induction_on x pSet.mem_empty\n\ntheorem eq_empty (x : Set.{u}) : x = ∅ ↔ ∀y:Set.{u}, y ∉ x :=\n⟨λh, by rw h; exact mem_empty,\nλh, ext (λy, ⟨λyx, absurd yx (h y), λy0, absurd y0 (mem_empty _)⟩)⟩\n\n/-- `insert x y` is the set `{x} ∪ y` -/\nprotected def insert : Set → Set → Set :=\nresp.eval 2 ⟨pSet.insert, λu v uv ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λo, match o with\n   | some a := let ⟨b, hb⟩ := αβ a in ⟨some b, hb⟩\n   | none := ⟨none, uv⟩\n   end, λo, match o with\n   | some b := let ⟨a, ha⟩ := βα b in ⟨some a, ha⟩\n   | none := ⟨none, uv⟩\n   end⟩⟩\n\ninstance : has_insert Set Set := ⟨Set.insert⟩\n\ninstance : has_singleton Set Set := ⟨λ x, insert x ∅⟩\n\ninstance : is_lawful_singleton Set Set := ⟨λ x, rfl⟩\n\n@[simp] theorem mem_insert {x y z : Set.{u}} : x ∈ insert y z ↔ x = y ∨ x ∈ z :=\nquotient.induction_on₃ x y z\n (λx y ⟨α, A⟩, show x ∈ pSet.mk (option α) (λo, option.rec y A o) ↔\n    mk x = mk y ∨ x ∈ pSet.mk α A, from\n  ⟨λm, match m with\n  | ⟨some a, ha⟩ := or.inr ⟨a, ha⟩\n  | ⟨none, h⟩ := or.inl (quotient.sound h)\n  end, λm, match m with\n  | or.inr ⟨a, ha⟩ := ⟨some a, ha⟩\n  | or.inl h := ⟨none, quotient.exact h⟩\n  end⟩)\n\n@[simp] theorem mem_singleton {x y : Set.{u}} : x ∈ @singleton Set.{u} Set.{u} _ y ↔ x = y :=\niff.trans mem_insert ⟨λo, or.rec (λh, h) (λn, absurd n (mem_empty _)) o, or.inl⟩\n\n@[simp] theorem mem_pair {x y z : Set.{u}} : x ∈ ({y, z} : Set) ↔ x = y ∨ x = z :=\niff.trans mem_insert $ or_congr iff.rfl mem_singleton\n\n/-- `omega` is the first infinite von Neumann ordinal -/\ndef omega : Set := mk omega\n\n@[simp] theorem omega_zero : ∅ ∈ omega :=\nshow pSet.mem ∅ pSet.omega, from ⟨⟨0⟩, equiv.refl _⟩\n\n@[simp] theorem omega_succ {n} : n ∈ omega.{u} → insert n n ∈ omega.{u} :=\nquotient.induction_on n (λx ⟨⟨n⟩, h⟩, ⟨⟨n+1⟩,\n  have Set.insert ⟦x⟧ ⟦x⟧ = Set.insert ⟦of_nat n⟧ ⟦of_nat n⟧, by rw (@quotient.sound pSet _ _ _ h),\n  quotient.exact this⟩)\n\n/-- `{x ∈ a | p x}` is the set of elements in `a` satisfying `p` -/\nprotected def sep (p : Set → Prop) : Set → Set :=\nresp.eval 1 ⟨pSet.sep (λy, p ⟦y⟧), λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λ⟨a, pa⟩, let ⟨b, hb⟩ := αβ a in ⟨⟨b, by rwa ←(@quotient.sound pSet _ _ _ hb)⟩, hb⟩,\n   λ⟨b, pb⟩, let ⟨a, ha⟩ := βα b in ⟨⟨a, by rwa (@quotient.sound pSet _ _ _ ha)⟩, ha⟩⟩⟩\n\ninstance : has_sep Set Set := ⟨Set.sep⟩\n\n@[simp] theorem mem_sep {p : Set.{u} → Prop} {x y : Set.{u}} : y ∈ {y ∈ x | p y} ↔ y ∈ x ∧ p y :=\nquotient.induction_on₂ x y (λ⟨α, A⟩ y,\n  ⟨λ⟨⟨a, pa⟩, h⟩, ⟨⟨a, h⟩, by rw (@quotient.sound pSet _ _ _ h); exact pa⟩,\n  λ⟨⟨a, h⟩, pa⟩, ⟨⟨a, by rw ←(@quotient.sound pSet _ _ _ h); exact pa⟩, h⟩⟩)\n\n/-- The powerset operation, the collection of subsets of a set -/\ndef powerset : Set → Set :=\nresp.eval 1 ⟨powerset, λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λp, ⟨{b | ∃a, p a ∧ equiv (A a) (B b)},\n    λ⟨a, pa⟩, let ⟨b, ab⟩ := αβ a in ⟨⟨b, a, pa, ab⟩, ab⟩,\n    λ⟨b, a, pa, ab⟩, ⟨⟨a, pa⟩, ab⟩⟩,\n   λq, ⟨{a | ∃b, q b ∧ equiv (A a) (B b)},\n    λ⟨a, b, qb, ab⟩, ⟨⟨b, qb⟩, ab⟩,\n    λ⟨b, qb⟩, let ⟨a, ab⟩ := βα b in ⟨⟨a, b, qb, ab⟩, ab⟩⟩⟩⟩\n\n@[simp] theorem mem_powerset {x y : Set} : y ∈ powerset x ↔ y ⊆ x :=\nquotient.induction_on₂ x y (λ⟨α, A⟩ ⟨β, B⟩,\n  show (⟨β, B⟩ : pSet) ∈ (pSet.powerset ⟨α, A⟩) ↔ _,\n    by simp [mem_powerset, subset_iff])\n\ntheorem Union_lem {α β : Type u} (A : α → pSet) (B : β → pSet)\n  (αβ : ∀a, ∃b, equiv (A a) (B b)) : ∀a, ∃b, (equiv ((Union ⟨α, A⟩).func a) ((Union ⟨β, B⟩).func b))\n| ⟨a, c⟩ := let ⟨b, hb⟩ := αβ a in\n  begin\n    induction ea : A a with γ Γ,\n    induction eb : B b with δ Δ,\n    rw [ea, eb] at hb,\n    cases hb with γδ δγ,\n    exact\n    let c : type (A a) := c, ⟨d, hd⟩ := γδ (by rwa ea at c) in\n    have equiv ((A a).func c) ((B b).func (eq.rec d (eq.symm eb))), from\n    match A a, B b, ea, eb, c, d, hd with ._, ._, rfl, rfl, x, y, hd := hd end,\n    ⟨⟨b, eq.rec d (eq.symm eb)⟩, this⟩\n  end\n\n/-- The union operator, the collection of elements of elements of a set -/\ndef Union : Set → Set :=\nresp.eval 1 ⟨pSet.Union, λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨Union_lem A B αβ, λa, exists.elim (Union_lem B A (λb,\n    exists.elim (βα b) (λc hc, ⟨c, equiv.symm hc⟩)) a) (λb hb, ⟨b, equiv.symm hb⟩)⟩⟩\n\nnotation `⋃` := Union\n\n@[simp] theorem mem_Union {x y : Set.{u}} : y ∈ Union x ↔ ∃ z ∈ x, y ∈ z :=\nquotient.induction_on₂ x y (λx y, iff.trans mem_Union\n  ⟨λ⟨z, h⟩, ⟨⟦z⟧, h⟩, λ⟨z, h⟩, quotient.induction_on z (λz h, ⟨z, h⟩) h⟩)\n\n@[simp] theorem Union_singleton {x : Set.{u}} : Union {x} = x :=\next $ λy, by simp; exact ⟨λ⟨z, zx, yz⟩, by subst z; exact yz, λyx, ⟨x, by simp, yx⟩⟩\n\ntheorem singleton_inj {x y : Set.{u}} (H : ({x} : Set) = {y}) : x = y :=\nlet this := congr_arg Union H in by rwa [Union_singleton, Union_singleton] at this\n\n/-- The binary union operation -/\nprotected def union (x y : Set.{u}) : Set.{u} := ⋃ {x, y}\n\n/-- The binary intersection operation -/\nprotected def inter (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∈ y}\n\n/-- The set difference operation -/\nprotected def diff (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∉ y}\n\ninstance : has_union Set := ⟨Set.union⟩\ninstance : has_inter Set := ⟨Set.inter⟩\ninstance : has_sdiff Set := ⟨Set.diff⟩\n\n@[simp] theorem mem_union {x y z : Set.{u}} : z ∈ x ∪ y ↔ z ∈ x ∨ z ∈ y :=\niff.trans mem_Union\n ⟨λ⟨w, wxy, zw⟩, match mem_pair.1 wxy with\n  | or.inl wx := or.inl (by rwa ←wx)\n  | or.inr wy := or.inr (by rwa ←wy)\n  end, λzxy, match zxy with\n  | or.inl zx := ⟨x, mem_pair.2 (or.inl rfl), zx⟩\n  | or.inr zy := ⟨y, mem_pair.2 (or.inr rfl), zy⟩\n  end⟩\n\n@[simp] theorem mem_inter {x y z : Set.{u}} : z ∈ x ∩ y ↔ z ∈ x ∧ z ∈ y :=\n@@mem_sep (λz:Set.{u}, z ∈ y)\n\n@[simp] theorem mem_diff {x y z : Set.{u}} : z ∈ x \\ y ↔ z ∈ x ∧ z ∉ y :=\n@@mem_sep (λz:Set.{u}, z ∉ y)\n\ntheorem induction_on {p : Set → Prop} (x) (h : ∀x, (∀y ∈ x, p y) → p x) : p x :=\nquotient.induction_on x $ λu, pSet.rec_on u $ λα A IH, h _ $ λy,\nshow @has_mem.mem _ _ Set.has_mem y ⟦⟨α, A⟩⟧ → p y, from\nquotient.induction_on y (λv ⟨a, ha⟩, by rw (@quotient.sound pSet _ _ _ ha); exact IH a)\n\ntheorem regularity (x : Set.{u}) (h : x ≠ ∅) : ∃ y ∈ x, x ∩ y = ∅ :=\nclassical.by_contradiction $ λne, h $ (eq_empty x).2 $ λy,\ninduction_on y $ λz (IH : ∀w:Set.{u}, w ∈ z → w ∉ x), show z ∉ x, from λzx,\nne ⟨z, zx, (eq_empty _).2 (λw wxz, let ⟨wx, wz⟩ := mem_inter.1 wxz in IH w wz wx)⟩\n\n/-- The image of a (definable) set function -/\ndef image (f : Set → Set) [H : definable 1 f] : Set → Set :=\nlet r := @definable.resp 1 f _ in\nresp.eval 1 ⟨image r.1, λx y e, mem.ext $ λz,\n  iff.trans (mem_image r.2) $ iff.trans (by exact\n   ⟨λ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).1 h1, h2⟩,\n    λ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).2 h1, h2⟩⟩) $\n  iff.symm (mem_image r.2)⟩\n\ntheorem image.mk :\n  Π (f : Set.{u} → Set.{u}) [H : definable 1 f] (x) {y} (h : y ∈ x), f y ∈ @image f H x\n| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ⟨α, A⟩ y ⟨a, ya⟩, ⟨a, F.2 _ _ ya⟩\n\n@[simp] theorem mem_image :\n  Π {f : Set.{u} → Set.{u}} [H : definable 1 f] {x y : Set.{u}}, y ∈ @image f H x ↔ ∃z ∈ x, f z = y\n| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ⟨α, A⟩ y,\n  ⟨λ⟨a, ya⟩, ⟨⟦A a⟧, mem.mk A a, eq.symm $ quotient.sound ya⟩,\n  λ⟨z, hz, e⟩, e ▸ image.mk _ _ hz⟩\n\n/-- Kuratowski ordered pair -/\ndef pair (x y : Set.{u}) : Set.{u} := {{x}, {x, y}}\n\n/-- A subset of pairs `{(a, b) ∈ x × y | p a b}` -/\ndef pair_sep (p : Set.{u} → Set.{u} → Prop) (x y : Set.{u}) : Set.{u} :=\n{z ∈ powerset (powerset (x ∪ y)) | ∃a ∈ x, ∃b ∈ y, z = pair a b ∧ p a b}\n\n@[simp] theorem mem_pair_sep {p} {x y z : Set.{u}} :\n  z ∈ pair_sep p x y ↔ ∃a ∈ x, ∃b ∈ y, z = pair a b ∧ p a b :=\nbegin\n  refine mem_sep.trans ⟨and.right, λe, ⟨_, e⟩⟩,\n  rcases e with ⟨a, ax, b, bY, rfl, pab⟩,\n  simp only [mem_powerset, subset_def, mem_union, pair, mem_pair],\n  rintros u (rfl|rfl) v; simp only [mem_singleton, mem_pair],\n  { rintro rfl, exact or.inl ax },\n  { rintro (rfl|rfl); [left, right]; assumption }\nend\n\ntheorem pair_inj {x y x' y' : Set.{u}} (H : pair x y = pair x' y') : x = x' ∧ y = y' := begin\n  have ae := ext_iff.2 H,\n  simp [pair] at ae,\n  have : x = x',\n  { cases (ae {x}).1 (by simp) with h h,\n    { exact singleton_inj h },\n    { have m : x' ∈ ({x} : Set),\n      { rw h, simp },\n      simp at m, simp [*] } },\n  subst x',\n  have he : y = x → y = y',\n  { intro yx, subst y,\n    cases (ae {x, y'}).2 (by simp) with xy'x xy'xx,\n    { have y'x : y' ∈ ({x} : Set) := by rw ← xy'x; simp,\n      simp at y'x, simp [*] },\n    { have yxx := (ext_iff.2 xy'xx y').1 (by simp),\n      simp at yxx, subst y' } },\n  have xyxy' := (ae {x, y}).1 (by simp),\n  cases xyxy' with xyx xyy',\n  { have yx := (ext_iff.2 xyx y).1 (by simp),\n    simp at yx, simp [he yx] },\n  { have yxy' := (ext_iff.2 xyy' y).1 (by simp),\n    simp at yxy',\n    cases yxy' with yx yy',\n    { simp [he yx] },\n    { simp [yy'] } }\nend\n\n/-- The cartesian product, `{(a, b) | a ∈ x, b ∈ y}` -/\ndef prod : Set.{u} → Set.{u} → Set.{u} := pair_sep (λa b, true)\n\n@[simp] theorem mem_prod {x y z : Set.{u}} : z ∈ prod x y ↔ ∃a ∈ x, ∃b ∈ y, z = pair a b :=\nby simp [prod]\n\n@[simp] theorem pair_mem_prod {x y a b : Set.{u}} : pair a b ∈ prod x y ↔ a ∈ x ∧ b ∈ y :=\n⟨λh, let ⟨a', a'x, b', b'y, e⟩ := mem_prod.1 h in\n  match a', b', pair_inj e, a'x, b'y with ._, ._, ⟨rfl, rfl⟩, ax, bY := ⟨ax, bY⟩ end,\nλ⟨ax, bY⟩, by simp; exact ⟨a, ax, b, bY, rfl⟩⟩\n\n/-- `is_func x y f` is the assertion `f : x → y` where `f` is a ZFC function\n  (a set of ordered pairs) -/\ndef is_func (x y f : Set.{u}) : Prop :=\nf ⊆ prod x y ∧ ∀z:Set.{u}, z ∈ x → ∃! w, pair z w ∈ f\n\n/-- `funs x y` is `y ^ x`, the set of all set functions `x → y` -/\ndef funs (x y : Set.{u}) : Set.{u} :=\n{f ∈ powerset (prod x y) | is_func x y f}\n\n@[simp] theorem mem_funs {x y f : Set.{u}} : f ∈ funs x y ↔ is_func x y f :=\nby simp [funs, is_func]\n\n-- TODO(Mario): Prove this computably\nnoncomputable instance map_definable_aux (f : Set → Set) [H : definable 1 f] :\n  definable 1 (λy, pair y (f y)) :=\n@classical.all_definable 1 _\n\n/-- Graph of a function: `map f x` is the ZFC function which maps `a ∈ x` to `f a` -/\nnoncomputable def map (f : Set → Set) [H : definable 1 f] : Set → Set :=\nimage (λy, pair y (f y))\n\n@[simp] theorem mem_map {f : Set → Set} [H : definable 1 f] {x y : Set} :\n  y ∈ map f x ↔ ∃z ∈ x, pair z (f z) = y :=\nmem_image\n\ntheorem map_unique {f : Set.{u} → Set.{u}} [H : definable 1 f] {x z : Set.{u}} (zx : z ∈ x) :\n  ∃! w, pair z w ∈ map f x :=\n⟨f z, image.mk _ _ zx, λy yx, let ⟨w, wx, we⟩ := mem_image.1 yx, ⟨wz, fy⟩ := pair_inj we in\n  by rw[←fy, wz]⟩\n\n@[simp] theorem map_is_func {f : Set → Set} [H : definable 1 f] {x y : Set} :\n  is_func x y (map f x) ↔ ∀z ∈ x, f z ∈ y :=\n⟨λ⟨ss, h⟩ z zx, let ⟨t, t1, t2⟩ := h z zx in by rw (t2 (f z) (image.mk _ _ zx));\n  exact (pair_mem_prod.1 (ss t1)).right,\nλh, ⟨λy yx, let ⟨z, zx, ze⟩ := mem_image.1 yx in by rw ←ze; exact pair_mem_prod.2 ⟨zx, h z zx⟩,\n     λz, map_unique⟩⟩\n\nend Set\n\ndef Class := set Set\n\nnamespace Class\n\ninstance : has_subset Class     := ⟨set.subset⟩\ninstance : has_sep Set Class    := ⟨set.sep⟩\ninstance : has_emptyc Class     := ⟨λ a, false⟩\ninstance : inhabited Class      := ⟨∅⟩\ninstance : has_insert Set Class := ⟨set.insert⟩\ninstance : has_union Class      := ⟨set.union⟩\ninstance : has_inter Class      := ⟨set.inter⟩\ninstance : has_neg Class        := ⟨set.compl⟩\ninstance : has_sdiff Class      := ⟨set.diff⟩\n\n/-- Coerce a set into a class -/\ndef of_Set (x : Set.{u}) : Class.{u} := {y | y ∈ x}\ninstance : has_coe Set Class := ⟨of_Set⟩\n\n/-- The universal class -/\ndef univ : Class := set.univ\n\n/-- Assert that `A` is a set satisfying `p` -/\ndef to_Set (p : Set.{u} → Prop) (A : Class.{u}) : Prop := ∃x, ↑x = A ∧ p x\n\n/-- `A ∈ B` if `A` is a set which is a member of `B` -/\nprotected def mem (A B : Class.{u}) : Prop := to_Set.{u} B A\ninstance : has_mem Class Class := ⟨Class.mem⟩\n\ntheorem mem_univ {A : Class.{u}} : A ∈ univ.{u} ↔ ∃ x : Set.{u}, ↑x = A :=\nexists_congr $ λx, and_true _\n\n/-- Convert a conglomerate (a collection of classes) into a class -/\ndef Cong_to_Class (x : set Class.{u}) : Class.{u} := {y | ↑y ∈ x}\n\n/-- Convert a class into a conglomerate (a collection of classes) -/\ndef Class_to_Cong (x : Class.{u}) : set Class.{u} := {y | y ∈ x}\n\n/-- The power class of a class is the class of all subclasses that are sets -/\ndef powerset (x : Class) : Class := Cong_to_Class (set.powerset x)\n\n/-- The union of a class is the class of all members of sets in the class -/\ndef Union (x : Class) : Class := set.sUnion (Class_to_Cong x)\nnotation `⋃` := Union\n\ntheorem of_Set.inj {x y : Set.{u}} (h : (x : Class.{u}) = y) : x = y :=\nSet.ext $ λz, by change (x : Class.{u}) z ↔ (y : Class.{u}) z; simp [*]\n\n@[simp] theorem to_Set_of_Set (p : Set.{u} → Prop) (x : Set.{u}) : to_Set p x ↔ p x :=\n⟨λ⟨y, yx, py⟩, by rwa of_Set.inj yx at py, λpx, ⟨x, rfl, px⟩⟩\n\n@[simp] theorem mem_hom_left (x : Set.{u}) (A : Class.{u}) : (x : Class.{u}) ∈ A ↔ A x :=\nto_Set_of_Set _ _\n\n@[simp] theorem mem_hom_right (x y : Set.{u}) : (y : Class.{u}) x ↔ x ∈ y := iff.rfl\n\n@[simp] theorem subset_hom (x y : Set.{u}) : (x : Class.{u}) ⊆ y ↔ x ⊆ y := iff.rfl\n\n@[simp] theorem sep_hom (p : Set.{u} → Prop) (x : Set.{u}) :\n  (↑{y ∈ x | p y} : Class.{u}) = {y ∈ x | p y} :=\nset.ext $ λy, Set.mem_sep\n\n@[simp] theorem empty_hom : ↑(∅ : Set.{u}) = (∅ : Class.{u}) :=\nset.ext $ λy, show _ ↔ false, by simp; exact Set.mem_empty y\n\n@[simp] theorem insert_hom (x y : Set.{u}) : (@insert Set.{u} Class.{u} _ x y) = ↑(insert x y) :=\nset.ext $ λz, iff.symm Set.mem_insert\n\n@[simp] theorem union_hom (x y : Set.{u}) : (x : Class.{u}) ∪ y = (x ∪ y : Set.{u}) :=\nset.ext $ λz, iff.symm Set.mem_union\n\n@[simp] theorem inter_hom (x y : Set.{u}) : (x : Class.{u}) ∩ y = (x ∩ y : Set.{u}) :=\nset.ext $ λz, iff.symm Set.mem_inter\n\n@[simp] theorem diff_hom (x y : Set.{u}) : (x : Class.{u}) \\ y = (x \\ y : Set.{u}) :=\nset.ext $ λz, iff.symm Set.mem_diff\n\n@[simp] theorem powerset_hom (x : Set.{u}) : powerset.{u} x = Set.powerset x :=\nset.ext $ λz, iff.symm Set.mem_powerset\n\n@[simp] theorem Union_hom (x : Set.{u}) : Union.{u} x = Set.Union x :=\nset.ext $ λz, by refine iff.trans _ (iff.symm Set.mem_Union); exact\n⟨λ⟨._, ⟨a, rfl, ax⟩, za⟩, ⟨a, ax, za⟩, λ⟨a, ax, za⟩, ⟨_, ⟨a, rfl, ax⟩, za⟩⟩\n\n/-- The definite description operator, which is {x} if `{a | p a} = {x}`\n  and ∅ otherwise -/\ndef iota (p : Set → Prop) : Class := Union {x | ∀y, p y ↔ y = x}\n\ntheorem iota_val (p : Set → Prop) (x : Set) (H : ∀y, p y ↔ y = x) : iota p = ↑x :=\nset.ext $ λy, ⟨λ⟨._, ⟨x', rfl, h⟩, yx'⟩, by rwa ←((H x').1 $ (h x').2 rfl),\n  λyx, ⟨_, ⟨x, rfl, H⟩, yx⟩⟩\n\n/-- Unlike the other set constructors, the `iota` definite descriptor\n  is a set for any set input, but not constructively so, so there is no\n  associated `(Set → Prop) → Set` function. -/\ntheorem iota_ex (p) : iota.{u} p ∈ univ.{u} :=\nmem_univ.2 $ or.elim (classical.em $ ∃x, ∀y, p y ↔ y = x)\n (λ⟨x, h⟩, ⟨x, eq.symm $ iota_val p x h⟩)\n (λhn, ⟨∅, by simp; exact set.ext (λz, ⟨false.rec _, λ⟨._, ⟨x, rfl, H⟩, zA⟩, hn ⟨x, H⟩⟩)⟩)\n\n/-- Function value -/\ndef fval (F A : Class.{u}) : Class.{u} := iota (λy, to_Set (λx, F (Set.pair x y)) A)\ninfixl `′`:100 := fval\n\ntheorem fval_ex (F A : Class.{u}) : F ′ A ∈ univ.{u} := iota_ex _\n\nend Class\n\nnamespace Set\n\n@[simp] theorem map_fval {f : Set.{u} → Set.{u}} [H : pSet.definable 1 f]\n  {x y : Set.{u}} (h : y ∈ x) :\n  (Set.map f x ′ y : Class.{u}) = f y :=\nClass.iota_val _ _ (λz, by simp; exact\n  ⟨λ⟨w, wz, pr⟩, let ⟨wy, fw⟩ := Set.pair_inj pr in by rw[←fw, wy],\n  λe, by cases e; exact ⟨_, h, rfl⟩⟩)\n\nvariables (x : Set.{u}) (h : ∅ ∉ x)\n\n/-- A choice function on the set of nonempty sets `x` -/\nnoncomputable def choice : Set :=\n@map (λy, classical.epsilon (λz, z ∈ y)) (classical.all_definable _) x\n\ninclude h\ntheorem choice_mem_aux (y : Set.{u}) (yx : y ∈ x) : classical.epsilon (λz:Set.{u}, z ∈ y) ∈ y :=\n@classical.epsilon_spec _ (λz:Set.{u}, z ∈ y) $ classical.by_contradiction $ λn, h $\nby rwa ←((eq_empty y).2 $ λz zx, n ⟨z, zx⟩)\n\ntheorem choice_is_func : is_func x (Union x) (choice x) :=\n(@map_is_func _ (classical.all_definable _) _ _).2 $\n  λy yx, by simp; exact ⟨y, yx, choice_mem_aux x h y yx⟩\n\ntheorem choice_mem (y : Set.{u}) (yx : y ∈ x) : (choice x ′ y : Class.{u}) ∈ (y : Class.{u}) :=\nby delta choice; rw map_fval yx; simp [choice_mem_aux x h y yx]\n\nend Set\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/set_theory/zfc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.488730866513921}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nWithout loss of generality tactic.\n-/\nimport data.list.perm\n\nopen expr tactic lean lean.parser\n\nlocal postfix `?`:9001 := optional\nlocal postfix *:9001 := many\n\nnamespace tactic\n\nprivate meta def update_pp_name : expr → name → expr\n| (local_const n _ bi d) pp := local_const n pp bi d\n| e n := e\n\nprivate meta def elim_or : ℕ → expr → tactic (list expr)\n| 0       h := fail \"zero cases\"\n| 1       h := return [h]\n| (n + 1) h := do\n  [(_, [hl], []), (_, [hr], [])] ← induction h, -- there should be no dependent terms\n  [gl, gr] ← get_goals,\n  set_goals [gr],\n  hsr ← elim_or n hr,\n  gsr ← get_goals,\n  set_goals (gl :: gsr),\n  return (hl :: hsr)\n\nprivate meta def dest_or : expr → tactic (list expr) | e := do\n  `(%%a ∨ %%b) ← whnf e | return [e],\n  lb ← dest_or b,\n  return (a :: lb)\n\nprivate meta def match_perms (pat : pattern) : expr → tactic (list $ list expr) | t :=\n  (do\n    m ← match_pattern pat t,\n    guard (m.2.all expr.is_local_constant),\n    return [m.2]) <|>\n  (do\n    `(%%l ∨ %%r) ← whnf t,\n    m ← match_pattern pat l,\n    rs ← match_perms r,\n    return (m.2 :: rs))\n\nmeta def wlog (vars' : list expr) (h_cases fst_case : expr) (perms : list (list expr)) :\n  tactic unit := do\n  guard h_cases.is_local_constant,\n\n  -- reorder s.t. context is Γ ⬝ vars ⬝ cases ⊢ ∀deps, …\n  nr ← revert_lst (vars' ++ [h_cases]),\n  vars ← intron' vars'.length,\n  h_cases ← intro h_cases.local_pp_name,\n\n  cases ← infer_type h_cases,\n  h_fst_case ←\n    mk_local_def h_cases.local_pp_name\n      (fst_case.instantiate_locals $ (vars'.zip vars).map $ λ⟨o, n⟩, (o.local_uniq_name, n)),\n  ((), pr) ← solve_aux cases (repeat $ exact h_fst_case <|> left >> skip),\n\n  t ← target,\n  fixed_vars ← vars.mmap update_type,\n  let t' := (instantiate_local h_cases.local_uniq_name pr t).pis (fixed_vars ++ [h_fst_case]),\n\n  (h, [g]) ← local_proof `this t' (do\n    clear h_cases,\n    vars.mmap clear,\n    intron nr),\n\n  h₀ :: hs ← elim_or perms.length h_cases,\n\n  solve1 (do\n    exact (h.mk_app $ vars ++ [h₀])),\n\n  focus ((hs.zip perms.tail).map $ λ⟨h_case, perm⟩, do\n    let p_v := (vars'.zip vars).map (λ⟨p, v⟩, (p.local_uniq_name, v)),\n    let p := perm.map (λp, p.instantiate_locals p_v),\n    note `this none (h.mk_app $ p ++ [h_case]),\n    clear h,\n    return ()),\n  gs ← get_goals,\n  set_goals (g :: gs)\n\nnamespace interactive\nopen interactive interactive.types expr\n\nprivate meta def parse_permutations : option (list (list name)) → tactic (list (list expr))\n| none                    := return []\n| (some [])               := return []\n| (some perms@(p₀ :: ps)) := do\n  (guard p₀.nodup <|>\n    fail \"No permutation `xs_i` in `using [xs_1, …, xs_n]` should contain the same variable twice.\"),\n  (guard (perms.all $ λp, p.perm p₀) <|>\n    fail \"The permutations `xs_i` in `using [xs_1, …, xs_n]` must be permutations of the same variables.\"),\n  perms.mmap (λp, p.mmap get_local)\n\n/-- Without loss of generality: reduces to one goal under variables permutations.\n\nGiven a goal of the form `g xs`, a predicate `p` over a set of variables, as well as variable\npermutations `xs_i`. Then `wlog` produces goals of the form\n\nThe case goal, i.e. the permutation `xs_i` covers all possible cases:\n  `⊢ p xs_0 ∨ ⋯ ∨ p xs_n`\nThe main goal, i.e. the goal reduced to `xs_0`:\n  `(h : p xs_0) ⊢ g xs_0`\nThe invariant goals, i.e. `g` is invariant under `xs_i`:\n  `(h : p xs_i) (this : g xs_0) ⊢ gs xs_i`\n\nEither the permutation is provided, or a proof of the disjunction is provided to compute the\npermutation. The disjunction need to be in assoc normal form, e.g. `p₀ ∨ (p₁ ∨ p₂)`. In many cases\nthe invariant goals can be solved by AC rewriting using `cc` etc.\n\nExample:\n  On a state `(n m : ℕ) ⊢ p n m` the tactic `wlog h : n ≤ m using [n m, m n]` produces the following\n  states:\n    `(n m : ℕ) ⊢ n ≤ m ∨ m ≤ n`\n    `(n m : ℕ) (h : n ≤ m) ⊢ p n m`\n    `(n m : ℕ) (h : m ≤ n) (this : p n m) ⊢ p m n`\n\n`wlog` supports different calling conventions. The name `h` is used to give a name to the introduced\ncase hypothesis. If the name is avoided, the default will be `case`.\n\n(1) `wlog : p xs0 using [xs0, …, xsn]`\n  Results in the case goal `p xs0 ∨ ⋯ ∨ ps xsn`, the main goal `(case : p xs0) ⊢ g xs0` and the\n  invariance goals `(case : p xsi) (this : g xs0) ⊢ g xsi`.\n\n(2) `wlog : p xs0 := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 ∨ ⋯ ∨ p xsi`, it is also used to compute the\n  variable permutations.\n\n(3) `wlog := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 ∨ ⋯ ∨ p xsi`, it is also used to compute the\n  variable permutations. This is not as stable as (2), for example `p` cannot be a disjunction.\n\n(4) `wlog : R x y using x y` and `wlog : R x y`\n  Produces the case `R x y ∨ R y x`. If `R` is ≤, then the disjunction discharged using linearity.\n  If `using x y` is avoided then `x` and `y` are the last two variables appearing in the\n  expression `R x y`. -/\nmeta def wlog\n  (h : parse ident?)\n  (pat : parse (tk \":\" *> texpr)?)\n  (cases : parse (tk \":=\" *> texpr)?)\n  (perms : parse (tk \"using\" *> (list_of (ident*) <|> (λx, [x]) <$> ident*))?)\n  (discharger : tactic unit :=\n    (tactic.solve_by_elim <|> tactic.tautology {classical := tt} <|>\n      using_smt (smt_tactic.intros >> smt_tactic.solve_goals))) :\n  tactic unit := do\nperms ← parse_permutations perms,\n(pat, cases_pr, cases_goal, vars, perms) ← (match cases with\n| some r := do\n  vars::_ ← return perms |\n    fail \"At least one set of variables expected, i.e. `using x y` or `using [x y, y x]`.\",\n  cases_pr ← to_expr r,\n  cases_pr ← (if cases_pr.is_local_constant\n    then return $ match h with some n := update_pp_name cases_pr n | none := cases_pr end\n    else do\n      note (h.get_or_else `case) none cases_pr),\n  cases ← infer_type cases_pr,\n  (pat, perms') ← match pat with\n  | some pat := do\n    pat ← to_expr pat,\n    let vars' := vars.filter $ λv, v.occurs pat,\n    case_pat ← mk_pattern [] vars' pat [] vars',\n    perms' ← match_perms case_pat cases,\n    return (pat, perms')\n  | none := do\n    (p :: ps) ← dest_or cases,\n    let vars' := vars.filter $ λv, v.occurs p,\n    case_pat ← mk_pattern [] vars' p [] vars',\n    perms' ← (p :: ps).mmap (λp, do m ← match_pattern case_pat p, return m.2),\n    return (p, perms')\n  end,\n  let vars_name := vars.map local_uniq_name,\n  guard (perms'.all $ λp, p.all $ λv, v.is_local_constant ∧ v.local_uniq_name ∈ vars_name) <|>\n    fail \"Cases contains variables not declared in `using x y z`\",\n  perms ← (if perms.length = 1\n    then do\n      return (perms'.map $ λp, p ++ vars.filter (λv, p.all (λv', v'.local_uniq_name ≠ v.local_uniq_name)))\n    else do\n      guard (perms.length = perms'.length) <|>\n        fail \"The provided permutation list has a different length then the provided cases.\",\n      return perms),\n  return (pat, cases_pr, @none expr, vars, perms)\n\n| none   := do\n  let name_h := h.get_or_else `case,\n  some pat ← return pat | fail \"Either specify cases or a pattern with permutations\",\n  pat ← to_expr pat,\n  (do\n    [x, y] ← match perms with\n    | []  := return pat.list_local_consts\n    | [l] := return l\n    | _   := failed\n    end,\n    let cases := mk_or_lst [pat, pat.instantiate_locals [(x.local_uniq_name, y), (y.local_uniq_name, x)]],\n    (do\n      `(%%x' ≤ %%y') ← return pat,\n      (cases_pr, []) ← local_proof name_h cases (exact ``(le_total %%x' %%y')),\n      return (pat, cases_pr, none, [x, y], [[x, y], [y, x]]))\n    <|>\n    (do\n      (cases_pr, [g]) ← local_proof name_h cases skip,\n      return (pat, cases_pr, some g, [x, y], [[x, y], [y, x]]))) <|>\n  (do\n    guard (perms.length ≥ 2) <|>\n      fail (\"To generate cases at least two permutations are required, i.e. `using [x y, y x]`\" ++\n        \" or exactly 0 or 2 variables\"),\n    (vars :: perms') ← return perms,\n    let names := vars.map local_uniq_name,\n    let cases := mk_or_lst (pat :: perms'.map (λp, pat.instantiate_locals (names.zip p))),\n    (cases_pr, [g]) ← local_proof name_h cases skip,\n    return (pat, cases_pr, some g, vars, perms))\nend),\nlet name_fn :=\n  (if perms.length = 2 then λi, `invariant else λi, mk_simple_name (\"invariant_\" ++ to_string (i + 1))),\nwith_enable_tags $ tactic.focus1 $ do\n  t ← get_main_tag,\n  tactic.wlog vars cases_pr pat perms,\n  tactic.focus (set_main_tag (mk_num_name `_case 0 :: `main :: t) ::\n    (list.range (perms.length - 1)).map (λi, do\n      set_main_tag (mk_num_name `_case 0 :: name_fn i :: t),\n      try discharger)),\n  match cases_goal with\n  | some g := do\n    set_tag g (mk_num_name `_case 0 :: `cases :: t),\n    gs ← get_goals,\n    set_goals (g :: gs)\n  | none := skip\n  end\n\nadd_tactic_doc\n{ name := \"wlog\",\n  category := doc_category.tactic,\n  decl_names := [``wlog],\n  tags := [\"logic\"] }\n\nend interactive\n\nend tactic\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/tactic/wlog.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.48873086284996026}}
{"text": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport order.well_founded\nimport algebra.group.pi\nimport algebra.order.group.defs\n\n\n/-!\n# Lexicographic order on Pi types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the lexicographic order for Pi types. `a` is less than `b` if `a i = b i` for all\n`i` up to some point `k`, and `a k < b k`.\n\n## Notation\n\n* `Πₗ i, α i`: Pi type equipped with the lexicographic order. Type synonym of `Π i, α i`.\n\n## See also\n\nRelated files are:\n* `data.finset.colex`: Colexicographic order on finite sets.\n* `data.list.lex`: Lexicographic order on lists.\n* `data.sigma.order`: Lexicographic order on `Σₗ i, α i`.\n* `data.psigma.order`: Lexicographic order on `Σₗ' i, α i`.\n* `data.prod.lex`: Lexicographic order on `α × β`.\n-/\n\nvariables {ι : Type*} {β : ι → Type*} (r : ι → ι → Prop)\n  (s : Π {i}, β i → β i → Prop)\n\nnamespace pi\n\ninstance {α : Type*} : Π [inhabited α], inhabited (lex α) := id\n\n/-- The lexicographic relation on `Π i : ι, β i`, where `ι` is ordered by `r`,\n  and each `β i` is ordered by `s`. -/\nprotected def lex (x y : Π i, β i) : Prop :=\n∃ i, (∀ j, r j i → x j = y j) ∧ s (x i) (y i)\n\n/- This unfortunately results in a type that isn't delta-reduced, so we keep the notation out of the\nbasic API, just in case -/\nnotation `Πₗ` binders `, ` r:(scoped p, lex (Π i, p i)) := r\n\n@[simp] lemma to_lex_apply (x : Π i, β i) (i : ι) : to_lex x i = x i := rfl\n@[simp] lemma of_lex_apply (x : lex (Π i, β i)) (i : ι) : of_lex x i = x i := rfl\n\nlemma lex_lt_of_lt_of_preorder [Π i, preorder (β i)] {r} (hwf : well_founded r)\n  {x y : Π i, β i} (hlt : x < y) : ∃ i, (∀ j, r j i → x j ≤ y j ∧ y j ≤ x j) ∧ x i < y i :=\nlet h' := pi.lt_def.1 hlt, ⟨i, hi, hl⟩ := hwf.has_min _ h'.2 in\n  ⟨i, λ j hj, ⟨h'.1 j, not_not.1 $ λ h, hl j (lt_of_le_not_le (h'.1 j) h) hj⟩, hi⟩\n\nlemma lex_lt_of_lt [Π i, partial_order (β i)] {r} (hwf : well_founded r)\n  {x y : Π i, β i} (hlt : x < y) : pi.lex r (λ i, (<)) x y :=\nby { simp_rw [pi.lex, le_antisymm_iff], exact lex_lt_of_lt_of_preorder hwf hlt }\n\nlemma is_trichotomous_lex [∀ i, is_trichotomous (β i) s] (wf : well_founded r) :\n  is_trichotomous (Π i, β i) (pi.lex r @s) :=\n{ trichotomous := λ a b,\n    begin\n      cases eq_or_ne a b with hab hab,\n      { exact or.inr (or.inl hab) },\n      { rw function.ne_iff at hab,\n        let i := wf.min _ hab,\n        have hri : ∀ j, r j i → a j = b j,\n        { intro j, rw ← not_imp_not,\n          exact λ h', wf.not_lt_min _ _ h' },\n        have hne : a i ≠ b i, from wf.min_mem _ hab,\n        cases trichotomous_of s (a i) (b i) with hi hi,\n        exacts [or.inl ⟨i, hri, hi⟩,\n          or.inr $ or.inr $ ⟨i, λ j hj, (hri j hj).symm, hi.resolve_left hne⟩] },\n    end }\n\ninstance [has_lt ι] [Π a, has_lt (β a)] : has_lt (lex (Π i, β i)) := ⟨pi.lex (<) (λ _, (<))⟩\n\ninstance lex.is_strict_order [linear_order ι] [∀ a, partial_order (β a)] :\n  is_strict_order (lex (Π i, β i)) (<) :=\n{ irrefl := λ a ⟨k, hk₁, hk₂⟩, lt_irrefl (a k) hk₂,\n  trans :=\n    begin\n      rintro a b c ⟨N₁, lt_N₁, a_lt_b⟩ ⟨N₂, lt_N₂, b_lt_c⟩,\n      rcases lt_trichotomy N₁ N₂ with (H|rfl|H),\n      exacts [⟨N₁, λ j hj, (lt_N₁ _ hj).trans (lt_N₂ _ $ hj.trans H), lt_N₂ _ H ▸ a_lt_b⟩,\n        ⟨N₁, λ j hj, (lt_N₁ _ hj).trans (lt_N₂ _ hj), a_lt_b.trans b_lt_c⟩,\n        ⟨N₂, λ j hj, (lt_N₁ _ (hj.trans H)).trans (lt_N₂ _ hj), (lt_N₁ _ H).symm ▸ b_lt_c⟩]\n    end }\n\ninstance [linear_order ι] [Π a, partial_order (β a)] : partial_order (lex (Π i, β i)) :=\npartial_order_of_SO (<)\n\n/-- `Πₗ i, α i` is a linear order if the original order is well-founded. -/\nnoncomputable instance [linear_order ι] [is_well_order ι (<)] [∀ a, linear_order (β a)] :\n  linear_order (lex (Π i, β i)) :=\n@linear_order_of_STO (Πₗ i, β i) (<)\n  { to_is_trichotomous := is_trichotomous_lex _ _ is_well_founded.wf } (classical.dec_rel _)\n\nsection partial_order\nvariables [linear_order ι] [is_well_order ι (<)] [Π i, partial_order (β i)] {x y : Π i, β i} {i : ι}\n  {a b : β i}\n\nopen function\n\nlemma to_lex_monotone : monotone (@to_lex (Π i, β i)) :=\nλ a b h, or_iff_not_imp_left.2 $ λ hne,\n  let ⟨i, hi, hl⟩ := is_well_founded.wf.has_min {i | a i ≠ b i} (function.ne_iff.1 hne) in\n  ⟨i, λ j hj, by { contrapose! hl, exact ⟨j, hl, hj⟩ }, (h i).lt_of_ne hi⟩\n\nlemma to_lex_strict_mono : strict_mono (@to_lex (Π i, β i)) :=\nλ a b h, let ⟨i, hi, hl⟩ := is_well_founded.wf.has_min {i | a i ≠ b i} (function.ne_iff.1 h.ne) in\n  ⟨i, λ j hj, by { contrapose! hl, exact ⟨j, hl, hj⟩ }, (h.le i).lt_of_ne hi⟩\n\n@[simp] lemma lt_to_lex_update_self_iff : to_lex x < to_lex (update x i a) ↔ x i < a :=\nbegin\n  refine ⟨_, λ h, to_lex_strict_mono $ lt_update_self_iff.2 h⟩,\n  rintro ⟨j, hj, h⟩,\n  dsimp at h,\n  obtain rfl : j = i,\n  { by_contra H,\n    rw update_noteq H at h,\n    exact h.false },\n  { rwa update_same at h }\nend\n\n@[simp] lemma to_lex_update_lt_self_iff : to_lex (update x i a) < to_lex x ↔ a < x i :=\nbegin\n  refine ⟨_, λ h, to_lex_strict_mono $ update_lt_self_iff.2 h⟩,\n  rintro ⟨j, hj, h⟩,\n  dsimp at h,\n  obtain rfl : j = i,\n  { by_contra H,\n    rw update_noteq H at h,\n    exact h.false },\n  { rwa update_same at h }\nend\n\n@[simp] lemma le_to_lex_update_self_iff : to_lex x ≤ to_lex (update x i a) ↔ x i ≤ a :=\nby simp_rw [le_iff_lt_or_eq, lt_to_lex_update_self_iff, to_lex_inj, eq_update_self_iff]\n\n@[simp] lemma to_lex_update_le_self_iff : to_lex (update x i a) ≤ to_lex x ↔ a ≤ x i :=\nby simp_rw [le_iff_lt_or_eq, to_lex_update_lt_self_iff, to_lex_inj, update_eq_self_iff]\n\nend partial_order\n\ninstance [linear_order ι] [is_well_order ι (<)] [Π a, partial_order (β a)]\n  [Π a, order_bot (β a)] : order_bot (lex (Π a, β a)) :=\n{ bot := to_lex ⊥,\n  bot_le := λ f, to_lex_monotone bot_le }\n\ninstance [linear_order ι] [is_well_order ι (<)] [Π a, partial_order (β a)]\n  [Π a, order_top (β a)] : order_top (lex (Π a, β a)) :=\n{ top := to_lex ⊤,\n  le_top := λ f, to_lex_monotone le_top }\n\ninstance [linear_order ι] [is_well_order ι (<)] [Π a, partial_order (β a)]\n  [Π a, bounded_order (β a)] : bounded_order (lex (Π a, β a)) :=\n{ .. pi.lex.order_bot, .. pi.lex.order_top }\n\ninstance [preorder ι] [Π i, has_lt (β i)] [Π i, densely_ordered (β i)] :\n  densely_ordered (lex (Π i, β i)) :=\n⟨begin\n  rintro _ _ ⟨i, h, hi⟩,\n  obtain ⟨a, ha₁, ha₂⟩ := exists_between hi,\n  classical,\n  refine ⟨a₂.update _ a, ⟨i, λ j hj, _, _⟩, i, λ j hj, _, _⟩,\n  rw h j hj,\n  iterate 2 { { rw a₂.update_noteq hj.ne a }, { rwa a₂.update_same i a } },\nend⟩\n\nlemma lex.no_max_order' [preorder ι] [Π i, has_lt (β i)] (i : ι) [no_max_order (β i)] :\n  no_max_order (lex (Π i, β i)) :=\n⟨λ a, begin\n  classical,\n  obtain ⟨b, hb⟩ := exists_gt (a i),\n  exact ⟨a.update i b, i, λ j hj, (a.update_noteq hj.ne b).symm, by rwa a.update_same i b⟩\nend⟩\n\ninstance [linear_order ι] [is_well_order ι (<)] [nonempty ι] [Π i, partial_order (β i)]\n  [Π i, no_max_order (β i)] :\n  no_max_order (lex (Π i, β i)) :=\n⟨λ a, let ⟨b, hb⟩ := exists_gt (of_lex a) in ⟨_, to_lex_strict_mono hb⟩⟩\n\ninstance [linear_order ι] [is_well_order ι (<)] [nonempty ι] [Π i, partial_order (β i)]\n  [Π i, no_min_order (β i)] :\n  no_min_order (lex (Π i, β i)) :=\n⟨λ a, let ⟨b, hb⟩ := exists_lt (of_lex a) in ⟨_, to_lex_strict_mono hb⟩⟩\n\n--we might want the analog of `pi.ordered_cancel_comm_monoid` as well in the future\n@[to_additive]\ninstance lex.ordered_comm_group [linear_order ι] [∀ a, ordered_comm_group (β a)] :\n  ordered_comm_group (lex (Π i, β i)) :=\n{ mul_le_mul_left := λ x y hxy z,\n    hxy.elim\n      (λ hxyz, hxyz ▸ le_rfl)\n      (λ ⟨i, hi⟩,\n        or.inr ⟨i, λ j hji, show z j * x j = z j * y j, by rw hi.1 j hji,\n          mul_lt_mul_left' hi.2 _⟩),\n  ..pi.lex.partial_order,\n  ..pi.comm_group }\n\n/-- If we swap two strictly decreasing values in a function, then the result is lexicographically\nsmaller than the original function. -/\nlemma lex_desc {α} [preorder ι] [decidable_eq ι] [preorder α] {f : ι → α} {i j : ι}\n  (h₁ : i < j) (h₂ : f j < f i) :\n  to_lex (f ∘ equiv.swap i j) < to_lex f :=\n⟨i, λ k hik, congr_arg f (equiv.swap_apply_of_ne_of_ne hik.ne (hik.trans h₁).ne),\n  by simpa only [pi.to_lex_apply, function.comp_app, equiv.swap_apply_left] using h₂⟩\n\nend pi\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/pi/lex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389986757758, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4886425023911946}}
{"text": "/-\nCopyright (c) 2020 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\nimport analysis.calculus.mean_value\n\n/-!\n# L'Hôpital's rule for 0/0 indeterminate forms\n\nIn this file, we prove several forms of \"L'Hopital's rule\" for computing 0/0\nindeterminate forms. The proof of `has_deriv_at.lhopital_zero_right_on_Ioo`\nis based on the one given in the corresponding\n[Wikibooks](https://en.wikibooks.org/wiki/Calculus/L%27H%C3%B4pital%27s_Rule)\nchapter, and all other statements are derived from this one by composing by\ncarefully chosen functions.\n\nNote that the filter `f'/g'` tends to isn't required to be one of `𝓝 a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `ℝ`.\n\nEach statement is available in a `has_deriv_at` form and a `deriv` form, which\nis denoted by each statement being in either the `has_deriv_at` or the `deriv`\nnamespace.\n\n## Tags\n\nL'Hôpital's rule, L'Hopital's rule\n-/\n\nopen filter set\nopen_locale filter topology pointwise\n\nvariables {a b : ℝ} (hab : a < b) {l : filter ℝ} {f f' g g' : ℝ → ℝ}\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' ≠ 0`) have\nto be satisfied on an explicitly-provided interval.\n-/\n\nnamespace has_deriv_at\n\ninclude hab\n\ntheorem lhopital_zero_right_on_Ioo\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  have sub : ∀ x ∈ Ioo a b, Ioo a x ⊆ Ioo a b := λ x hx, Ioo_subset_Ioo (le_refl a) (le_of_lt hx.2),\n  have hg : ∀ x ∈ (Ioo a b), g x ≠ 0,\n  { intros x hx h,\n    have : tendsto g (𝓝[<] x) (𝓝 0),\n    { rw [← h, ← nhds_within_Ioo_eq_nhds_within_Iio hx.1],\n      exact ((hgg' x hx).continuous_at.continuous_within_at.mono $ sub x hx).tendsto },\n    obtain ⟨y, hyx, hy⟩ : ∃ c ∈ Ioo a x, g' c = 0,\n      from exists_has_deriv_at_eq_zero' hx.1 hga this (λ y hy, hgg' y $ sub x hx hy),\n    exact hg' y (sub x hx hyx) hy },\n  have : ∀ x ∈ Ioo a b, ∃ c ∈ Ioo a x, (f x) * (g' c) = (g x) * (f' c),\n  { intros x hx,\n    rw [← sub_zero (f x), ← sub_zero (g x)],\n    exact exists_ratio_has_deriv_at_eq_ratio_slope' g g' hx.1 f f'\n      (λ y hy, hgg' y $ sub x hx hy) (λ y hy, hff' y $ sub x hx hy) hga hfa\n      (tendsto_nhds_within_of_tendsto_nhds (hgg' x hx).continuous_at.tendsto)\n      (tendsto_nhds_within_of_tendsto_nhds (hff' x hx).continuous_at.tendsto) },\n  choose! c hc using this,\n  have : ∀ x ∈ Ioo a b, ((λ x', (f' x') / (g' x')) ∘ c) x = f x / g x,\n  { intros x hx,\n    rcases hc x hx with ⟨h₁, h₂⟩,\n    field_simp [hg x hx, hg' (c x) ((sub x hx) h₁)],\n    simp only [h₂],\n    rwa mul_comm },\n  have cmp : ∀ x ∈ Ioo a b, a < c x ∧ c x < x,\n    from λ x hx, (hc x hx).1,\n  rw ← nhds_within_Ioo_eq_nhds_within_Ioi hab,\n  apply tendsto_nhds_within_congr this,\n  simp only,\n  apply hdiv.comp,\n  refine tendsto_nhds_within_of_tendsto_nhds_of_eventually_within _\n    (tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds\n      (tendsto_nhds_within_of_tendsto_nhds tendsto_id) _ _) _,\n  all_goals\n  { apply eventually_nhds_within_of_forall,\n    intros x hx,\n    have := cmp x hx,\n    try {simp},\n    linarith [this] }\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [← hfa, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcf a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\n  { rw [← hga, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcg a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\nend\n\ntheorem lhopital_zero_left_on_Ioo\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfb : tendsto f (𝓝[<] b) (𝓝 0)) (hgb : tendsto g (𝓝[<] b) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[<] b) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[<] b) l :=\nbegin\n  -- Here, we essentially compose by `has_neg.neg`. The following is mostly technical details.\n  have hdnf : ∀ x ∈ -Ioo a b, has_deriv_at (f ∘ has_neg.neg) (f' (-x) * (-1)) x,\n    from λ x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : ∀ x ∈ -Ioo a b, has_deriv_at (g ∘ has_neg.neg) (g' (-x) * (-1)) x,\n    from λ x hx, comp x (hgg' (-x) hx) (has_deriv_at_neg x),\n  rw preimage_neg_Ioo at hdnf,\n  rw preimage_neg_Ioo at hdng,\n  have := lhopital_zero_right_on_Ioo (neg_lt_neg hab) hdnf hdng\n    (by { intros x hx h,\n          apply hg' _ (by {rw ← preimage_neg_Ioo at hx, exact hx}),\n          rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h })\n    (hfb.comp tendsto_neg_nhds_within_Ioi_neg)\n    (hgb.comp tendsto_neg_nhds_within_Ioi_neg)\n    (by { simp only [neg_div_neg_eq, mul_one, mul_neg],\n          exact (tendsto_congr $ λ x, rfl).mp (hdiv.comp tendsto_neg_nhds_within_Ioi_neg) }),\n  have := this.comp tendsto_neg_nhds_within_Iio,\n  unfold function.comp at this,\n  simpa only [neg_neg]\nend\n\ntheorem lhopital_zero_left_on_Ioc\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hcf : continuous_on f (Ioc a b)) (hcg : continuous_on g (Ioc a b))\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfb : f b = 0) (hgb : g b = 0)\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[<] b) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[<] b) l :=\nbegin\n  refine lhopital_zero_left_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [← hfb, ← nhds_within_Ioo_eq_nhds_within_Iio hab],\n    exact ((hcf b $ right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto },\n  { rw [← hgb, ← nhds_within_Ioo_eq_nhds_within_Iio hab],\n    exact ((hcg b $ right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto },\nend\n\nomit hab\n\ntheorem lhopital_zero_at_top_on_Ioi\n  (hff' : ∀ x ∈ Ioi a, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioi a, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioi a, g' x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  obtain ⟨ a', haa', ha'⟩ : ∃ a', a < a' ∧ 0 < a' :=\n    ⟨1 + max a 0, ⟨lt_of_le_of_lt (le_max_left a 0) (lt_one_add _),\n                   lt_of_le_of_lt (le_max_right a 0) (lt_one_add _)⟩⟩,\n  have fact1 : ∀ (x:ℝ), x ∈ Ioo 0 a'⁻¹ → x ≠ 0 := λ _ hx, (ne_of_lt hx.1).symm,\n  have fact2 : ∀ x ∈ Ioo 0 a'⁻¹, a < x⁻¹,\n    from λ _ hx, lt_trans haa' ((lt_inv ha' hx.1).mpr hx.2),\n  have hdnf : ∀ x ∈ Ioo 0 a'⁻¹, has_deriv_at (f ∘ has_inv.inv) (f' (x⁻¹) * (-(x^2)⁻¹)) x,\n    from λ x hx, comp x (hff' (x⁻¹) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have hdng : ∀ x ∈ Ioo 0 a'⁻¹, has_deriv_at (g ∘ has_inv.inv) (g' (x⁻¹) * (-(x^2)⁻¹)) x,\n    from λ x hx, comp x (hgg' (x⁻¹) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have := lhopital_zero_right_on_Ioo (inv_pos.mpr ha') hdnf hdng\n    (by { intros x hx,\n          refine mul_ne_zero _ (neg_ne_zero.mpr $ inv_ne_zero $ pow_ne_zero _ $ fact1 x hx),\n          exact hg' _ (fact2 x hx) })\n    (hftop.comp tendsto_inv_zero_at_top)\n    (hgtop.comp tendsto_inv_zero_at_top)\n    (by { refine (tendsto_congr' _).mp (hdiv.comp tendsto_inv_zero_at_top),\n          rw eventually_eq_iff_exists_mem,\n          use [Ioi 0, self_mem_nhds_within],\n          intros x hx,\n          unfold function.comp,\n          erw mul_div_mul_right,\n          refine neg_ne_zero.mpr (inv_ne_zero $ pow_ne_zero _ $ ne_of_gt hx) }),\n  have := this.comp tendsto_inv_at_top_zero',\n  unfold function.comp at this,\n  simpa only [inv_inv],\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hff' : ∀ x ∈ Iio a, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Iio a, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Iio a, g' x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  -- Here, we essentially compose by `has_neg.neg`. The following is mostly technical details.\n  have hdnf : ∀ x ∈ -Iio a, has_deriv_at (f ∘ has_neg.neg) (f' (-x) * (-1)) x,\n    from λ x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : ∀ x ∈ -Iio a, has_deriv_at (g ∘ has_neg.neg) (g' (-x) * (-1)) x,\n    from λ x hx, comp x (hgg' (-x) hx) (has_deriv_at_neg x),\n  rw preimage_neg_Iio at hdnf,\n  rw preimage_neg_Iio at hdng,\n  have := lhopital_zero_at_top_on_Ioi hdnf hdng\n    (by { intros x hx h,\n          apply hg' _ (by {rw ← preimage_neg_Iio at hx, exact hx}),\n          rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h })\n    (hfbot.comp tendsto_neg_at_top_at_bot)\n    (hgbot.comp tendsto_neg_at_top_at_bot)\n    (by { simp only [mul_one, mul_neg, neg_div_neg_eq],\n          exact (tendsto_congr $ λ x, rfl).mp (hdiv.comp tendsto_neg_at_top_at_bot) }),\n  have := this.comp tendsto_neg_at_bot_at_top,\n  unfold function.comp at this,\n  simpa only [neg_neg],\nend\n\nend has_deriv_at\n\nnamespace deriv\n\ninclude hab\n\ntheorem lhopital_zero_right_on_Ioo\n  (hdf : differentiable_on ℝ f (Ioo a b)) (hg' : ∀ x ∈ Ioo a b, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  have hdf : ∀ x ∈ Ioo a b, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : ∀ x ∈ Ioo a b, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_right_on_Ioo hab (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfa hga hdiv\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hdf : differentiable_on ℝ f (Ioo a b))\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : ∀ x ∈ (Ioo a b), (deriv g) x ≠ 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hdf hg' _ _ hdiv,\n  { rw [← hfa, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcf a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\n  { rw [← hga, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcg a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\nend\n\ntheorem lhopital_zero_left_on_Ioo\n  (hdf : differentiable_on ℝ f (Ioo a b))\n  (hg' : ∀ x ∈ (Ioo a b), (deriv g) x ≠ 0)\n  (hfb : tendsto f (𝓝[<] b) (𝓝 0)) (hgb : tendsto g (𝓝[<] b) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[<] b) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[<] b) l :=\nbegin\n  have hdf : ∀ x ∈ Ioo a b, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : ∀ x ∈ Ioo a b, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_left_on_Ioo hab (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfb hgb hdiv\nend\n\nomit hab\n\ntheorem lhopital_zero_at_top_on_Ioi\n  (hdf : differentiable_on ℝ f (Ioi a))\n  (hg' : ∀ x ∈ (Ioi a), (deriv g) x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  have hdf : ∀ x ∈ Ioi a, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioi_mem_nhds hx),\n  have hdg : ∀ x ∈ Ioi a, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_top_on_Ioi (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hftop hgtop hdiv,\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hdf : differentiable_on ℝ f (Iio a))\n  (hg' : ∀ x ∈ (Iio a), (deriv g) x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdf : ∀ x ∈ Iio a, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Iio_mem_nhds hx),\n  have hdg : ∀ x ∈ Iio a, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_bot_on_Iio (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfbot hgbot hdiv,\nend\n\nend deriv\n\n/-!\n## Generic versions\n\nThe following statements no longer any explicit interval, as they only require\nconditions holding eventually.\n-/\n\nnamespace has_deriv_at\n\n/-- L'Hôpital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right\n  (hff' : ∀ᶠ x in 𝓝[>] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[>] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[>] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ 𝓝[>] a := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_nhds_within_Ioi_iff_exists_Ioo_subset at hs,\n  rcases hs with ⟨u, hau, hu⟩,\n  refine lhopital_zero_right_on_Ioo hau _ _ _ hfa hga hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hu hx).1.1 <|> exact (hu hx).1.2 <|> exact (hu hx).2\nend\n\n/-- L'Hôpital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left\n  (hff' : ∀ᶠ x in 𝓝[<] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[<] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[<] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[<] a) (𝓝 0)) (hga : tendsto g (𝓝[<] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[<] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[<] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ 𝓝[<] a := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_nhds_within_Iio_iff_exists_Ioo_subset at hs,\n  rcases hs with ⟨l, hal, hl⟩,\n  refine lhopital_zero_left_on_Ioo hal _ _ _ hfa hga hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl hx).1.1 <|> exact (hl hx).1.2 <|> exact (hl hx).2\nend\n\n/-- L'Hôpital's rule for approaching a real, `has_deriv_at` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds'\n  (hff' : ∀ᶠ x in 𝓝[≠] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[≠] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[≠] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[≠] a) (𝓝 0)) (hga : tendsto g (𝓝[≠] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[≠] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[≠] a) l :=\nbegin\n  simp only [←Iio_union_Ioi, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact ⟨lhopital_zero_nhds_left hff'.1 hgg'.1 hg'.1 hfa.1 hga.1 hdiv.1,\n          lhopital_zero_nhds_right hff'.2 hgg'.2 hg'.2 hfa.2 hga.2 hdiv.2⟩\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds\n  (hff' : ∀ᶠ x in 𝓝 a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝 a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝 a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝 a) (𝓝 0)) (hga : tendsto g (𝓝 a) (𝓝 0))\n  (hdiv : tendsto (λ x, f' x / g' x) (𝓝 a) l) :\n  tendsto (λ x, f x / g x) (𝓝[≠] a) l :=\nbegin\n  apply @lhopital_zero_nhds' _ _ _ f' _ g';\n  apply eventually_nhds_within_of_eventually_nhds <|> apply tendsto_nhds_within_of_tendsto_nhds;\n  assumption\nend\n\n/-- L'Hôpital's rule for approaching +∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top\n  (hff' : ∀ᶠ x in at_top, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in at_top, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in at_top, g' x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ at_top := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_at_top_sets at hs,\n  rcases hs with ⟨l, hl⟩,\n  have hl' : Ioi l ⊆ s := λ x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_top_on_Ioi _ _ (λ x hx, hg' x $ (hl' hx).2) hftop hgtop hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl' hx).1.1 <|> exact (hl' hx).1.2\nend\n\n/-- L'Hôpital's rule for approaching -∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot\n  (hff' : ∀ᶠ x in at_bot, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in at_bot, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in at_bot, g' x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ at_bot := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_at_bot_sets at hs,\n  rcases hs with ⟨l, hl⟩,\n  have hl' : Iio l ⊆ s := λ x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_bot_on_Iio _ _ (λ x hx, hg' x $ (hl' hx).2) hfbot hgbot hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl' hx).1.1 <|> exact (hl' hx).1.2\nend\n\nend has_deriv_at\n\nnamespace deriv\n\n/-- **L'Hôpital's rule** for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right\n  (hdf : ∀ᶠ x in 𝓝[>] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[>] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  have hdg : ∀ᶠ x in 𝓝[>] a, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in 𝓝[>] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in 𝓝[>] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_nhds_right hdf' hdg' hg' hfa hga hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left\n  (hdf : ∀ᶠ x in 𝓝[<] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[<] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[<] a) (𝓝 0)) (hga : tendsto g (𝓝[<] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[<] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[<] a) l :=\nbegin\n  have hdg : ∀ᶠ x in 𝓝[<] a, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in 𝓝[<] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in 𝓝[<] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_nhds_left hdf' hdg' hg' hfa hga hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `deriv` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds'\n  (hdf : ∀ᶠ x in 𝓝[≠] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[≠] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[≠] a) (𝓝 0)) (hga : tendsto g (𝓝[≠] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[≠] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[≠] a) l :=\nbegin\n  simp only [←Iio_union_Ioi, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact ⟨lhopital_zero_nhds_left hdf.1 hg'.1 hfa.1 hga.1 hdiv.1,\n          lhopital_zero_nhds_right hdf.2 hg'.2 hfa.2 hga.2 hdiv.2⟩,\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds\n  (hdf : ∀ᶠ x in 𝓝 a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝 a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝 a) (𝓝 0)) (hga : tendsto g (𝓝 a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝 a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[≠] a) l :=\nbegin\n  apply lhopital_zero_nhds';\n  apply eventually_nhds_within_of_eventually_nhds <|> apply tendsto_nhds_within_of_tendsto_nhds;\n  assumption\nend\n\n/-- **L'Hôpital's rule** for approaching +∞, `deriv` version -/\ntheorem lhopital_zero_at_top\n  (hdf : ∀ᶠ (x : ℝ) in at_top, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ (x : ℝ) in at_top, deriv g x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  have hdg : ∀ᶠ x in at_top, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in at_top, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in at_top, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_at_top hdf' hdg' hg' hftop hgtop hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching -∞, `deriv` version -/\ntheorem lhopital_zero_at_bot\n  (hdf : ∀ᶠ (x : ℝ) in at_bot, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ (x : ℝ) in at_bot, deriv g x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdg : ∀ᶠ x in at_bot, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in at_bot, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in at_bot, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_at_bot hdf' hdg' hg' hfbot hgbot hdiv\nend\n\nend deriv\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/analysis/calculus/lhopital.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4886424963261615}}
{"text": "-- Introducción del condicional en Lean\n-- ====================================\n\n-- ----------------------------------------------------\n-- Ej. 1. (p. 9) Demostrar que\n--    P → P\n-- ----------------------------------------------------\n\nimport tactic\nvariable (P : Prop)\n\n-- 1ª demostración\nexample : P → P :=\nassume h : P,\nshow P, from h\n\n-- 2ª demostración\nexample : P → P :=\nassume : P,\nshow P, from this\n\n-- 3ª demostración\nexample : P → P :=\nassume : P,\nshow P, from ‹P›\n\n-- 4ª demostración\nexample : P → P :=\nassume h : P, h\n\n-- 5ª demostración\nexample : P → P :=\nλ h, h\n\n-- 6ª demostración\nexample : P → P :=\n-- by library_search\nid\n\n-- 7ª demostración\nexample : P → P :=\nbegin\n  intro h,\n  exact h,\nend\n\n-- 8ª demostración\nexample : P → P :=\nbegin\n  intro,\n  exact ‹P›,\nend\n\n-- 9ª demostración\nexample : P → P :=\nbegin\n  intro h,\n  assumption,\nend\n\n-- 10ª demostración\nexample : P → P :=\nbegin\n  intro,\n  assumption,\nend\n\n-- 11ª demostración\nexample : P → P :=\n-- by hint\nby tauto\n\n-- 12ª demostración\nexample : P → P :=\nby finish\n\n-- 13ª demostración\nexample : P → P :=\nby simp\n", "meta": {"author": "jaalonso", "repo": "Logica_con_Lean", "sha": "beb6765c6ff3c05590a03f45722eda0c815a25cd", "save_path": "github-repos/lean/jaalonso-Logica_con_Lean", "path": "github-repos/lean/jaalonso-Logica_con_Lean/Logica_con_Lean-beb6765c6ff3c05590a03f45722eda0c815a25cd/src/1_Proposicional/Introduccion_del_condicional.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7461389817407016, "lm_q1q2_score": 0.4886424862748457}}
{"text": "/-\nCopyright 2021 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\n\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.sum\nimport formal_ml.lattice\nimport formal_ml.measurable_space\nimport formal_ml.classical\nimport data.equiv.list\nimport formal_ml.prod_measure\nimport formal_ml.finite_pi_measure\nimport formal_ml.probability_space\nimport formal_ml.monotone_class\nimport formal_ml.independent_events\n\n/-!\n  This file focuses on more esoteric proofs that random variables are identical.\n  In particular, given two random variables X Y with a common measurable space as a codomain,\n  where the codomain is generated by some set of measurable sets S.\n  X and Y are identical if they are identical on measurable sets in S, assuming S\n  has some particular properties. The first is that S is an algebra, i.e. S has the \n  universal set and is closed under set difference.\n\n  An alternative is that S is (basically) a semi-algebra, i.e. it has the empty set \n  and is closed under intersection, and semi-closed under complement. Normally, a \n  semi-algebra would require the universal set, but that is not required for this\n  purpose.\n\n  This is most useful for proving independent and identical random variables, when\n  considered as an aggregate random variable, are identical.\n\n  The core is the monotone class theorem, measurable_space.generate_from_monotone_class,\n  defined in formal_ml.monotone_class.\n-/\n\n\n\nlemma independent_event_pair_forall \n  {Ω:Type*} {P:probability_space Ω} {A:event P} {f : ℕ → event P}:\n                           (∀ (i:ℕ), (f i.succ).val ⊆ (f i).val) →  \n   (∀ (i:ℕ), independent_event_pair A (f i)) →\n   (independent_event_pair A (∀ᵣ i, f i)) := begin\n  intros h1 h2,\n  unfold independent_event_pair,\n  rw Pr_forall_eq_infi h1,\n  have h3:(A∧∀ᵣ (i : ℕ), f i) = (∀ᵣ (i : ℕ), A ∧ f i),\n  { apply event.eq, simp, ext ω, split; intros h3_1; simp at h3_1; simp [h3_1],\n    apply (h3_1 0).left },\n  rw h3,\n  rw Pr_forall_eq_infi,\n  rw nnreal.mul_infi,\n  unfold independent_event_pair at h2,\n  have h4:(λ i, Pr[A ∧ (f i)]) = (λ i, Pr[A] * Pr[f i]),\n  { ext i, rw h2 i },\n  rw h4,\n  intros i,\n  simp,\n  apply set.subset.trans,\n  apply set.inter_subset_right,\n  apply h1,\nend\n\n\nlemma independent_event_pair_exists_monotone \n  {Ω:Type*} {P:probability_space Ω} {A:event P} {f : ℕ → event P}:\n                           monotone (λ (i:ℕ), (f i).val) →  \n   (∀ (i:ℕ), independent_event_pair A (f i)) →\n   (independent_event_pair A (∃ᵣ i, f i)) := begin\n  intros h1 h2,\n  unfold independent_event_pair,\n  rw Pr_exists_eq_supr h1,\n  have h3:(A∧∃ᵣ (i : ℕ), f i) = (∃ᵣ (i : ℕ), A ∧ f i),\n  { apply event.eq, simp, ext ω, split; intros h3_1, \n    { simp at h3_1, simp [h3_1] },\n    { simp at h3_1, simp [h3_1] }, },\n  rw h3,\n  rw Pr_exists_eq_supr,\n  rw nnreal.mul_supr,\n  unfold independent_event_pair at h2,\n  have h4:(λ i, Pr[A ∧ (f i)]) = (λ i, Pr[A] * Pr[f i]),\n  { ext i, rw h2 i },\n  rw h4,\n  { simp [bdd_above], rw set.nonempty_def,\n    apply exists.intro (1:nnreal),\n    rw mem_upper_bounds,\n    intros x h_mem,\n    simp at h_mem,\n    cases h_mem with i h_mem,\n    subst x,\n    apply Pr_le_one },\n  { intros i j h_le, simp,\n    apply set.subset.trans,\n    apply set.inter_subset_right,\n    apply h1, apply h_le },\nend\n\nlemma random_variable_independent_pair_on_algebra {Ω α₁ α₂:Type*} (s₁: set (set α₁)) (s₂:set (set α₂))\n  (A₁:s₁.is_algebra) (A₂:s₂.is_algebra)\n  {P:probability_space Ω}\n  {X₁:P →ᵣ (measurable_space.generate_from s₁)}\n  {X₂:P →ᵣ (measurable_space.generate_from s₂)}:\n  (∀ (T₁:measurable_setB (measurable_space.generate_from s₁))\n     (T₂:measurable_setB (measurable_space.generate_from s₂)),\n     T₁.val ∈ s₁ → T₂.val ∈ s₂ \n     → independent_event_pair (X₁ ∈ᵣ T₁) (X₂ ∈ᵣ T₂)) → \n  random_variable_independent_pair X₁ X₂ := begin\n  intros h1 U₁,\n  cases U₁,\n  have AM₁ := A₁.monotone_class,\n  have AM₂ := A₂.monotone_class,\n\n  have h_meas₁:∀ {T':set α₁}, s₁.monotone_class T' →\n          (measurable_space.generate_from s₁).measurable_set' T',\n  { intros T' h_1, \n    rw measurable_space.generate_from_monotone_class at h_1,\n    simp [measurable_space.generate_from],\n    apply h_1, apply A₁ },\n  have h_meas₂:∀ {T':set α₂}, s₂.monotone_class T' →\n          (measurable_space.generate_from s₂).measurable_set' T',\n  { intros T' h_1, \n    rw measurable_space.generate_from_monotone_class at h_1,\n    simp [measurable_space.generate_from],\n    apply h_1, apply A₂ },\n  have h_mono_1:s₁.monotone_class U₁_val,\n  { rw measurable_space.generate_from_monotone_class,\n    simp [measurable_space.generate_from] at U₁_property,\n    apply U₁_property, apply A₁ },\n  induction h_mono_1 with U₁' h_U₁' f₁ h_rec₁ h_mono₁ h_ind₁ f₁ h_rec₁ h_mono₁ h_ind₁,\n  -- The base case for U₁, solved by induction on U₂.\n  intros U₂, cases U₂, \n  have h_mono_2:s₂.monotone_class U₂_val,\n  { rw measurable_space.generate_from_monotone_class,\n    simp [measurable_space.generate_from] at U₂_property,\n    apply U₂_property, apply A₂ },\n  induction h_mono_2 with U₂' h_U₂' f₂ h_rec₂ h_mono₂ h_ind₂ f₂ h_rec₂ h_mono₂ h_ind₂,\n  -- The base base case.\n  { apply h1, apply h_U₁', apply h_U₂' },\n  { have h_Inter:(X₂ ∈ᵣ ⟨set.Inter f₂, U₂_property⟩)\n                 = (∀ᵣ i, (X₂ ∈ᵣ ⟨f₂ i, h_meas₂ (h_rec₂ i)⟩)), \n    { apply event.eq, ext1 ω, split; intros h_Inter; simp at h_Inter;\n      simp [h_Inter] },\n    rw h_Inter,\n    apply independent_event_pair_forall,\n    { intros i, have h_mono_i := h_mono₂ i,\n      simp, intros ω, apply h_mono_i },\n    { intros i, have h_ind_i := h_ind₂ i,\n      apply h_ind_i } },\n  { have h_Union: (X₂ ∈ᵣ ⟨set.Union f₂, U₂_property⟩)\n                  = (∃ᵣ i, (X₂ ∈ᵣ ⟨f₂ i, h_meas₂ (h_rec₂ i)⟩)),\n    { apply event.eq, ext1 ω, split; intros h_Union_1; simp at h_Union_1;\n      simp [h_Union_1] },\n    rw h_Union,\n    apply independent_event_pair_exists_monotone,\n    { intros i j h_le, have h_mono_i := h_mono₂ h_le,\n      simp, intros ω, apply h_mono_i },\n    { intros i, have h_ind_i := h_ind₂ i,\n      apply h_ind_i } },\n  -- The base case of T₁ is resolved. Now we continue...     \n  { intros T₁, apply independent_event_pair.symm,\n    have h_Inter:(X₁ ∈ᵣ ⟨set.Inter f₁, U₁_property⟩)\n                 = (∀ᵣ i, (X₁ ∈ᵣ ⟨f₁ i, h_meas₁ (h_rec₁ i)⟩)), \n    { apply event.eq, ext1 ω, split; intros h_Inter; simp at h_Inter;\n      simp [h_Inter] },\n    rw h_Inter,\n    apply independent_event_pair_forall,\n    { intros i, have h_mono_i := h_mono₁ i,\n      simp, intros ω, apply h_mono_i },\n    { intros i, apply independent_event_pair.symm,\n      have h_ind_i := h_ind₁ i,\n      apply h_ind_i } },  \n  { intros T₁, apply independent_event_pair.symm,\n    have h_Union: (X₁ ∈ᵣ ⟨set.Union f₁, U₁_property⟩)\n                  = (∃ᵣ i, (X₁ ∈ᵣ ⟨f₁ i, h_meas₁ (h_rec₁ i)⟩)),\n    { apply event.eq, ext1 ω, split; intros h_Union_1; simp at h_Union_1;\n      simp [h_Union_1] },\n    rw h_Union,\n    apply independent_event_pair_exists_monotone,\n    { intros i j h_le, have h_mono_i := h_mono₁ h_le,\n      simp, intros ω, apply h_mono_i },\n    { intros i, apply independent_event_pair.symm,\n      have h_ind_i := h_ind₁ i,\n      apply h_ind_i } },     \nend\n\n\n/- This allows for the measurable space to be generated from a different\n   set. -/\nlemma random_variable_independent_pair_on_algebra' {Ω α₁ α₂:Type*} (s₁: set (set α₁)) (s₂:set (set α₂))\n  (A₁:s₁.is_algebra) (A₂:s₂.is_algebra)\n  (M₁:measurable_space α₁)\n  (M₂:measurable_space α₂)\n  {P:probability_space Ω}\n  {X₁:P →ᵣ M₁}\n  {X₂:P →ᵣ M₂}:\n  (M₁ = measurable_space.generate_from s₁) →\n  (M₂ = measurable_space.generate_from s₂) →\n  (∀ (T₁:measurable_setB M₁)\n     (T₂:measurable_setB M₂),\n     T₁.val ∈ s₁ → T₂.val ∈ s₂ \n     → independent_event_pair (X₁ ∈ᵣ T₁) (X₂ ∈ᵣ T₂)) → \n  random_variable_independent_pair X₁ X₂ := begin\n  intros h1 h2 h3 T₁ T₂,\n  tactic.unfreeze_local_instances,\n  subst M₁,\n  subst M₂,\n  apply random_variable_independent_pair_on_algebra,\n  apply A₁,\n  apply A₂,\n  apply h3,\nend\n\nlemma measurable_space.generate_from_disjoint_union_closure {α:Type*}\n  {s:set (set α)}:\n  measurable_space.generate_from s = measurable_space.generate_from s.disjoint_union_closure :=\nbegin\n  apply le_antisymm,\n  { apply measurable_space.generate_from_le,\n    intros t h_t, simp [measurable_space.generate_from],\n    apply measurable_space.generate_measurable.basic,\n    apply set.disjoint_union_closure_self,\n    apply h_t },\n  { apply measurable_space.generate_from_le,\n    intros t h_t, rw set.mem_disjoint_union_closure_iff at h_t,\n    cases h_t with m h_t,\n    cases h_t with f h_t,\n    cases h_t with h_in_s h_t,\n    cases h_t with h_pairwise h_f_def,\n    subst t,\n    haveI E:encodable (fin m) := fintype.encodable (fin m),\n    apply measurable_set.Union, intros b, \n    apply measurable_space.measurable_set_generate_from, apply h_in_s },\nend\n\nlemma random_variable_independent_pair_on_semialgebra {Ω α₁ α₂:Type*} (s₁: set (set α₁)) \n  (s₂:set (set α₂))\n  (A₁:s₁.is_semialgebra) (A₂:s₂.is_semialgebra)\n  {P:probability_space Ω}\n  {X₁:P →ᵣ (measurable_space.generate_from s₁)}\n  {X₂:P →ᵣ (measurable_space.generate_from s₂)}:\n  (∀ (T₁:measurable_setB (measurable_space.generate_from s₁))\n     (T₂:measurable_setB (measurable_space.generate_from s₂)),\n     T₁.val ∈ s₁ → T₂.val ∈ s₂ \n     → independent_event_pair (X₁ ∈ᵣ T₁) (X₂ ∈ᵣ T₂)) → \n  random_variable_independent_pair X₁ X₂ := begin\n  intros h1,\n  have CA₁ := A₁.disjoint_union_closure,\n  have CA₂ := A₂.disjoint_union_closure,\n  apply random_variable_independent_pair_on_algebra' (s₁.disjoint_union_closure)\n    (s₂.disjoint_union_closure) (A₁.disjoint_union_closure) (A₂.disjoint_union_closure),\n  apply measurable_space.generate_from_disjoint_union_closure,\n  apply measurable_space.generate_from_disjoint_union_closure,\n  intros T₁ T₂ h_T₁ h_T₂,\n  rw set.mem_disjoint_union_closure_iff at h_T₁,\n  cases h_T₁ with m₁ h_T₁,\n  cases h_T₁ with f₁ h_T₁,\n  cases h_T₁ with h_f₁_in_s h_T₁,\n  cases h_T₁ with h_pairwise₁ h_def₁,\n  rw set.mem_disjoint_union_closure_iff at h_T₂,\n  cases h_T₂ with m₂ h_T₂,\n  cases h_T₂ with f₂ h_T₂,\n  cases h_T₂ with h_f₂_in_s h_T₂,\n  cases h_T₂ with h_pairwise₂ h_def₂,\n  cases T₁,\n  cases T₂,\n  simp at h_def₁,\n  simp at h_def₂,\n  subst T₁_val,\n  subst T₂_val,\n  have h_meas₁:∀ (i:fin m₁), (measurable_space.generate_from s₁).measurable_set' (f₁ i),\n  { intros i, apply measurable_space.measurable_set_generate_from, apply h_f₁_in_s },\n  have h_meas₂:∀ (i:fin m₂), (measurable_space.generate_from s₂).measurable_set' (f₂ i),\n  { intros i, apply measurable_space.measurable_set_generate_from, apply h_f₂_in_s },\n  have h_union1: (X₁ ∈ᵣ ⟨set.Union f₁, T₁_property⟩) = (∃ᵣ i, X₁ ∈ᵣ ⟨f₁ i, h_meas₁ i⟩),\n  { apply event.eq, ext ω, split; intros h_union1_1; simp at h_union1_1; simp [h_union1_1] },\n  have h_union2: (X₂ ∈ᵣ ⟨set.Union f₂, T₂_property⟩) = (∃ᵣ i, X₂ ∈ᵣ ⟨f₂ i, h_meas₂ i⟩),\n  { apply event.eq, ext ω, split; intros h_union2_1; simp at h_union2_1; simp [h_union2_1] },\n  rw h_union1,\n  rw h_union2,\n  classical,\n  apply independent_event_pair_exists,\n  intros i h_i,\n  apply independent_event_pair.symm,\n  apply independent_event_pair_exists,\n  intros j h_j,\n  apply independent_event_pair.symm,\n  apply h1,\n  { simp, apply h_f₁_in_s },\n  { simp, apply h_f₂_in_s },\n  { intros i h_i_in_univ j h_j_in_univ h_ne, simp [function.on_fun],\n    have h_pairwise_ij := h_pairwise₁ i j h_ne,\n    simp [function.on_fun] at h_pairwise_ij, rw disjoint_iff, rw disjoint_iff at h_pairwise_ij,\n    simp at h_pairwise_ij, simp [h_pairwise_ij], rw ← set.subset_empty_iff, rw set.subset_def,\n    intros ω h_ω, simp at h_ω, rw ← set.subset_empty_iff at h_pairwise_ij, rw set.subset_def\n    at h_pairwise_ij, have h_X := h_pairwise_ij (X₁.val ω), simp at h_X, exfalso, apply h_X,\n    simp [h_ω], simp [h_ω] },\n  { intros i h_i_univ j h_j_univ h_ne, simp [function.on_fun],\n    have h_pairwise_ij := h_pairwise₂ i j h_ne,\n    simp [function.on_fun] at h_pairwise_ij, rw disjoint_iff, rw disjoint_iff at h_pairwise_ij,\n    simp at h_pairwise_ij, simp [h_pairwise_ij], rw ← set.subset_empty_iff, rw set.subset_def,\n    intros ω h_ω, simp at h_ω, rw ← set.subset_empty_iff at h_pairwise_ij, rw set.subset_def\n    at h_pairwise_ij, have h_X := h_pairwise_ij (X₂.val ω), simp at h_X, exfalso, apply h_X,\n    simp [h_ω], simp [h_ω] },\nend\n\n\nlemma random_variable_independent_pair_on_semialgebra' {Ω α₁ α₂:Type*} (s₁: set (set α₁)) \n  (s₂:set (set α₂))\n  (A₁:s₁.is_semialgebra) (A₂:s₂.is_semialgebra)\n  (M₁:measurable_space α₁)\n  (M₂:measurable_space α₂)\n  {P:probability_space Ω}\n  {X₁:P →ᵣ M₁}\n  {X₂:P →ᵣ M₂}:\n  (M₁ = measurable_space.generate_from s₁) →\n  (M₂ = measurable_space.generate_from s₂) →\n  (∀ (T₁:measurable_setB M₁)\n     (T₂:measurable_setB M₂),\n     T₁.val ∈ s₁ → T₂.val ∈ s₂ \n     → independent_event_pair (X₁ ∈ᵣ T₁) (X₂ ∈ᵣ T₂)) → \n  random_variable_independent_pair X₁ X₂ := begin\n  intros h1 h2 h3 T₁ T₂,\n  tactic.unfreeze_local_instances,\n  subst M₁,\n  subst M₂,\n  apply random_variable_independent_pair_on_semialgebra,\n  apply A₁,\n  apply A₂,\n  apply h3,\nend\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/random_variable_independent_pair.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.48855528776320334}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Patrick Massot, Eric Wieser\n-/\nimport group_theory.group_action.defs\nimport algebra.group.prod\n\n/-!\n# Prod instances for additive and multiplicative actions\n\nThis file defines instances for binary product of additive and multiplicative actions\n-/\n\nvariables {M N α β : Type*}\n\nnamespace prod\n\nsection\n\nvariables [has_scalar M α] [has_scalar M β] [has_scalar N α] [has_scalar N β] (a : M) (x : α × β)\n\n@[to_additive prod.has_vadd] instance : has_scalar M (α × β) := ⟨λa p, (a • p.1, a • p.2)⟩\n\n@[simp, to_additive] theorem smul_fst : (a • x).1 = a • x.1 := rfl\n@[simp, to_additive] theorem smul_snd : (a • x).2 = a • x.2 := rfl\n@[simp, to_additive] theorem smul_mk (a : M) (b : α) (c : β) : a • (b, c) = (a • b, a • c) := rfl\n\ninstance [has_scalar M N] [is_scalar_tower M N α] [is_scalar_tower M N β] :\n  is_scalar_tower M N (α × β) :=\n⟨λ x y z, mk.inj_iff.mpr ⟨smul_assoc _ _ _, smul_assoc _ _ _⟩⟩\n\n@[to_additive] instance [smul_comm_class M N α] [smul_comm_class M N β] :\n  smul_comm_class M N (α × β) :=\n{ smul_comm := λ r s x, mk.inj_iff.mpr ⟨smul_comm _ _ _, smul_comm _ _ _⟩ }\n\nend\n\n@[to_additive] instance {m : monoid M} [mul_action M α] [mul_action M β] : mul_action M (α × β) :=\n{ mul_smul  := λ a₁ a₂ p, mk.inj_iff.mpr ⟨mul_smul _ _ _, mul_smul _ _ _⟩,\n  one_smul  := λ ⟨b, c⟩, mk.inj_iff.mpr ⟨one_smul _ _, one_smul _ _⟩ }\n\ninstance {R M N : Type*} {r : monoid R} [add_monoid M] [add_monoid N]\n  [distrib_mul_action R M] [distrib_mul_action R N] : distrib_mul_action R (M × N) :=\n{ smul_add  := λ a p₁ p₂, mk.inj_iff.mpr ⟨smul_add _ _ _, smul_add _ _ _⟩,\n  smul_zero := λ a, mk.inj_iff.mpr ⟨smul_zero _, smul_zero _⟩ }\n\nend prod\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/group_theory/group_action/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.48855528699784606}}
{"text": "theorem zero_lt_of_lt : {a b : Nat} → a < b → 0 < b\n| 0,   _, h => h\n| a+1, b, h =>\n  have : a < b := Nat.lt_trans (Nat.lt_succ_self _) h\n  zero_lt_of_lt this\n\ndef fold {m α β} [Monad m] (as : Array α) (b : β) (f : α → β → m β) : m β := do\nlet rec loop : (i : Nat) → i ≤ as.size → β → m β\n  | 0,   h, b => pure b\n  | i+1, h, b => do\n    have h' : i < as.size          := Nat.lt_of_lt_of_le (Nat.lt_succ_self i) h\n    have : as.size - 1 < as.size     := Nat.sub_lt (zero_lt_of_lt h') (by decide)\n    have : as.size - 1 - i < as.size := Nat.lt_of_le_of_lt (Nat.sub_le (as.size - 1) i) this\n    let b ← f (as.get ⟨as.size - 1 - i, this⟩) b\n    loop i (Nat.le_of_lt h') b\nloop as.size (Nat.le_refl _) b\n\n#eval Id.run $ fold #[1, 2, 3, 4] 0 (pure $ · + ·)\n\ntheorem ex : (Id.run $ fold #[1, 2, 3, 4] 0 (pure $ · + ·)) = 10 :=\nrfl\n\ndef fold2 {m α β} [Monad m] (as : Array α) (b : β) (f : α → β → m β) : m β :=\nlet rec loop (i : Nat) (h : i ≤ as.size) (b : β) : m β := do\n  match i, h with\n  | 0,   h => return b\n  | i+1, h =>\n    have h' : i < as.size          := Nat.lt_of_lt_of_le (Nat.lt_succ_self i) h\n    have : as.size - 1 < as.size     := Nat.sub_lt (zero_lt_of_lt h') (by decide)\n    have : as.size - 1 - i < as.size := Nat.lt_of_le_of_lt (Nat.sub_le (as.size - 1) i) this\n    let b ← f (as.get ⟨as.size - 1 - i, this⟩) b\n    loop i (Nat.le_of_lt h') b\nloop as.size (Nat.le_refl _) b\n\ndef f (x : Nat) (ref : IO.Ref Nat) : IO Nat := do\nlet mut x := x\nif x == 0 then\n  x ← ref.get\nIO.println x\nreturn x + 1\n\ndef fTest : IO Unit := do\nunless (← f 0 (← IO.mkRef 10)) == 11 do throw $ IO.userError \"unexpected\"\nunless (← f 1 (← IO.mkRef 10)) == 2 do throw $ IO.userError \"unexpected\"\n\ndef g (x y : Nat) (ref : IO.Ref (Nat × Nat)) : IO (Nat × Nat) := do\n  let mut (x, y) := (x, y)\n  if x == 0 then\n    (x, y) ← ref.get\n  IO.println (\"x: \" ++ toString x ++ \", y: \" ++ toString y)\n  return (x, y)\n\ndef gTest : IO Unit := do\nunless (← g 2 1 (← IO.mkRef (10, 20))) == (2, 1)   do throw $ IO.userError \"unexpected\"\nunless (← g 0 1 (← IO.mkRef (10, 20))) == (10, 20) do throw $ IO.userError \"unexpected\"\nreturn ()\n\n#eval gTest\n\nmacro \"ret!\" x:term : doElem => `(doElem| return $x)\n\ndef f1 (x : Nat) : Nat := Id.run <| do\n  let mut x := x\n  if x == 0 then\n    ret! 100\n  x := x + 1\n  ret! x\n\ntheorem ex1 : f1 0 = 100 := rfl\ntheorem ex2 : f1 1 = 2 := rfl\ntheorem ex3 : f1 3 = 4 := rfl\n\nsyntax \"inc!\" ident : doElem\n\nmacro_rules\n| `(doElem| inc! $x) => `(doElem| $x:ident := $x + 1)\n\ndef f2 (x : Nat) : Nat := Id.run <| do\n  let mut x := x\n  inc! x\n  ret! x\n\ntheorem ex4 : f2 0 = 1 := rfl\ntheorem ex5 : f2 3 = 4 := rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/doNotation3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.488555286997846}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Keeley Hoek, Scott Morrison\n-/\n\nimport tactic.rewrite_search.explain\nimport tactic.rewrite_search.discovery\nimport tactic.rewrite_search.search\n\n/-!\n# `rewrite_search`: solving goals by searching for a series of rewrites.\n\n`rewrite_search` is a tactic for solving equalities or iff statements by searching for a\nsequence of rewrite tactic applications.\n\n## Algorithm sketch\n\nThe fundamental data structure behind the search algorithm is a graph of expressions. Each\nvertex represents one expression, and an edge in the graph represents a way to rewrite one\nexpression into another with a single application of a rewrite tactic. Thus, a path in the\ngraph represents a way to rewrite one expression into another with multiple applications of\na rewrite tactic.\n\nThe graph starts out with two vertices, one for the left hand side of the equality, and one\nfor the right hand side of the equality. The basic loop of the algorithm is to repeatedly add\nedges to the graph by taking vertices in the graph and applying a possible rewrite to them.\nThrough this process, the graph is made up of two connected components; one component contains\nexpressions that are equivalent to the left hand side, and one component contains expressions\nthat are equivalent to the right hand side. The algorithm completes when we discover an\nedge that connects the two components, creating a path of rewrites that connects the\nleft hand side and right hand side of the graph. For more detail, see Keeley's report at\nhttps://hoek.io/res/2018.s2.lean.report.pdf, although note that the edit distance mechanism\ndescribed is currently not implemented, only plain breadth-first search.\n\nThis algorithm is generally superior to one that only expands nodes starting from a single\nside, because it is replacing one tree of depth `2d` with two trees of depth `d`. This is\na quadratic speedup for regular trees; our trees aren't regular but it's still probably\na much better algorithm. We can only use this specific algorithm for rewrite-type tactics,\nthough, not general sequences of tactics, because it relies on the fact that any rewrite\ncan be reversed.\n\n## File structure\n\n* `discovery.lean` contains the logic for figuring out which rewrite rules to consider.\n* `search.lean` contains the graph algorithms to find a successful sequence of tactics.\n* `explain.lean` generates concise Lean code to run a tactic, from the autogenerated sequence\n  of tactics.\n* `frontend.lean` contains the user-facing interface to the `rewrite_search` tactics.\n* `types.lean` contains data structures shared across multiple of these components.\n-/\n\nnamespace tactic.interactive\n\nopen lean.parser interactive interactive.types tactic.rewrite_search\n\n/--\nParse a specification for a single rewrite rule.\nThe name of a lemma indicates using it as a rewrite. Prepending a \"←\" reverses the direction.\n-/\nprivate meta def rws_parser : lean.parser (pexpr × bool) :=\ndo flipped ← optional $ tk \"←\",\n   pexp ← lean.parser.pexpr 0,\n   return (pexp, flipped.is_some)\n\n/--\nSearch for a chain of rewrites to prove an equation or iff statement.\n\nCollects rewrite rules, runs a graph search to find a chain of rewrites to prove the\ncurrent target, and generates a string explanation for it.\n\nTakes an optional list of rewrite rules specified in the same way as the `rw` tactic accepts.\n-/\nmeta def rewrite_search (explain : parse $ optional (tk \"?\"))\n  (rs : parse $ optional (list_of rws_parser)) (cfg : config := {}) : tactic unit :=\ndo t ← tactic.target,\n  if t.has_meta_var then\n    tactic.fail \"rewrite_search is not suitable for goals containing metavariables\"\n  else tactic.skip,\n  implicit_rules ← collect_rules,\n  explicit_rules ← (rs.get_or_else []).mmap (λ ⟨pe, dir⟩, do e ← to_expr' pe, return (e, dir)),\n  let rules := implicit_rules ++ explicit_rules,\n  g ← mk_graph cfg rules t,\n  (_, proof, steps) ← g.find_proof,\n  tactic.exact proof,\n  if explain.is_some then explain_search_result cfg rules proof steps else skip\n\n\nadd_tactic_doc\n{ name        := \"rewrite_search\",\n  category    := doc_category.tactic,\n  decl_names  := [`tactic.interactive.rewrite_search],\n  tags        := [\"rewrite\", \"automation\"] }\n\nend tactic.interactive\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/tactic/rewrite_search/frontend.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4885552786180003}}
{"text": "/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n\n! This file was ported from Lean 3 source module topology.bornology.basic\n! leanprover-community/mathlib commit a11f9106a169dd302a285019e5165f8ab32ff433\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Filter.Cofinite\n\n/-!\n# Basic theory of bornology\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe develop the basic theory of bornologies. Instead of axiomatizing bounded sets and defining\nbornologies in terms of those, we recognize that the cobounded sets form a filter and define a\nbornology as a filter of cobounded sets which contains the cofinite filter.  This allows us to make\nuse of the extensive library for filters, but we also provide the relevant connecting results for\nbounded sets.\n\nThe specification of a bornology in terms of the cobounded filter is equivalent to the standard\none (e.g., see [Bourbaki, *Topological Vector Spaces*][bourbaki1987], **covering bornology**, now\noften called simply **bornology**) in terms of bounded sets (see `bornology.of_bounded`,\n`is_bounded.union`, `is_bounded.subset`), except that we do not allow the empty bornology (that is,\nwe require that *some* set must be bounded; equivalently, `∅` is bounded). In the literature the\ncobounded filter is generally referred to as the *filter at infinity*.\n\n## Main definitions\n\n- `bornology α`: a class consisting of `cobounded : filter α` and a proof that this filter\n  contains the `cofinite` filter.\n- `bornology.is_cobounded`: the predicate that a set is a member of the `cobounded α` filter. For\n  `s : set α`, one should prefer `bornology.is_cobounded s` over `s ∈ cobounded α`.\n- `bornology.is_bounded`: the predicate that states a set is bounded (i.e., the complement of a\n  cobounded set). One should prefer `bornology.is_bounded s` over `sᶜ ∈ cobounded α`.\n- `bounded_space α`: a class extending `bornology α` with the condition\n  `bornology.is_bounded (set.univ : set α)`\n\nAlthough use of `cobounded α` is discouraged for indicating the (co)boundedness of individual sets,\nit is intended for regular use as a filter on `α`.\n-/\n\n\nopen Set Filter\n\nvariable {ι α β : Type _}\n\n#print Bornology /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`cobounded] [] -/\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`le_cofinite] [] -/\n/-- A **bornology** on a type `α` is a filter of cobounded sets which contains the cofinite filter.\nSuch spaces are equivalently specified by their bounded sets, see `bornology.of_bounded`\nand `bornology.ext_iff_is_bounded`-/\n@[ext]\nclass Bornology (α : Type _) where\n  cobounded : Filter α\n  le_cofinite : cobounded ≤ cofinite\n#align bornology Bornology\n-/\n\n/- warning: bornology.of_bounded -> Bornology.ofBounded is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (B : Set.{u1} (Set.{u1} α)), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α)) B) -> (forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s₂ s₁) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B))) -> (forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s₁ s₂) B))) -> (forall (x : α), Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x) B) -> (Bornology.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} (B : Set.{u1} (Set.{u1} α)), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α)) B) -> (forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s₂ s₁) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B))) -> (forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s₁ s₂) B))) -> (forall (x : α), Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x) B) -> (Bornology.{u1} α)\nCase conversion may be inaccurate. Consider using '#align bornology.of_bounded Bornology.ofBoundedₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (s₁ s₂ «expr ∈ » B) -/\n/-- A constructor for bornologies by specifying the bounded sets,\nand showing that they satisfy the appropriate conditions. -/\n@[simps]\ndef Bornology.ofBounded {α : Type _} (B : Set (Set α)) (empty_mem : ∅ ∈ B)\n    (subset_mem : ∀ s₁ ∈ B, ∀ s₂ : Set α, s₂ ⊆ s₁ → s₂ ∈ B)\n    (union_mem : ∀ (s₁) (_ : s₁ ∈ B) (s₂) (_ : s₂ ∈ B), s₁ ∪ s₂ ∈ B)\n    (singleton_mem : ∀ x, {x} ∈ B) : Bornology α\n    where\n  cobounded :=\n    { sets := { s : Set α | sᶜ ∈ B }\n      univ_sets := by rwa [← compl_univ] at empty_mem\n      sets_of_superset := fun x y hx hy => subset_mem (xᶜ) hx (yᶜ) (compl_subset_compl.mpr hy)\n      inter_sets := fun x y hx hy => by simpa [compl_inter] using union_mem (xᶜ) hx (yᶜ) hy }\n  le_cofinite := by\n    rw [le_cofinite_iff_compl_singleton_mem]\n    intro x\n    change {x}ᶜᶜ ∈ B\n    rw [compl_compl]\n    exact singleton_mem x\n#align bornology.of_bounded Bornology.ofBounded\n\n/- warning: bornology.of_bounded' -> Bornology.ofBounded' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (B : Set.{u1} (Set.{u1} α)), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α)) B) -> (forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s₂ s₁) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B))) -> (forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s₁ s₂) B))) -> (Eq.{succ u1} (Set.{u1} α) (Set.unionₛ.{u1} α B) (Set.univ.{u1} α)) -> (Bornology.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} (B : Set.{u1} (Set.{u1} α)), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α)) B) -> (forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s₂ s₁) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B))) -> (forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s₁ s₂) B))) -> (Eq.{succ u1} (Set.{u1} α) (Set.unionₛ.{u1} α B) (Set.univ.{u1} α)) -> (Bornology.{u1} α)\nCase conversion may be inaccurate. Consider using '#align bornology.of_bounded' Bornology.ofBounded'ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (s₁ s₂ «expr ∈ » B) -/\n/-- A constructor for bornologies by specifying the bounded sets,\nand showing that they satisfy the appropriate conditions. -/\n@[simps]\ndef Bornology.ofBounded' {α : Type _} (B : Set (Set α)) (empty_mem : ∅ ∈ B)\n    (subset_mem : ∀ s₁ ∈ B, ∀ s₂ : Set α, s₂ ⊆ s₁ → s₂ ∈ B)\n    (union_mem : ∀ (s₁) (_ : s₁ ∈ B) (s₂) (_ : s₂ ∈ B), s₁ ∪ s₂ ∈ B) (sUnion_univ : ⋃₀ B = univ) :\n    Bornology α :=\n  Bornology.ofBounded B empty_mem subset_mem union_mem fun x =>\n    by\n    rw [sUnion_eq_univ_iff] at sUnion_univ\n    rcases sUnion_univ x with ⟨s, hs, hxs⟩\n    exact subset_mem s hs {x} (singleton_subset_iff.mpr hxs)\n#align bornology.of_bounded' Bornology.ofBounded'\n\nnamespace Bornology\n\nsection\n\nvariable [Bornology α] {s t : Set α} {x : α}\n\n#print Bornology.IsCobounded /-\n/-- `is_cobounded` is the predicate that `s` is in the filter of cobounded sets in the ambient\nbornology on `α` -/\ndef IsCobounded (s : Set α) : Prop :=\n  s ∈ cobounded α\n#align bornology.is_cobounded Bornology.IsCobounded\n-/\n\n#print Bornology.IsBounded /-\n/-- `is_bounded` is the predicate that `s` is bounded relative to the ambient bornology on `α`. -/\ndef IsBounded (s : Set α) : Prop :=\n  IsCobounded (sᶜ)\n#align bornology.is_bounded Bornology.IsBounded\n-/\n\n#print Bornology.isCobounded_def /-\ntheorem isCobounded_def {s : Set α} : IsCobounded s ↔ s ∈ cobounded α :=\n  Iff.rfl\n#align bornology.is_cobounded_def Bornology.isCobounded_def\n-/\n\n/- warning: bornology.is_bounded_def -> Bornology.isBounded_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α _inst_1 s) (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) (Bornology.cobounded.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α _inst_1 s) (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) (Bornology.cobounded.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_def Bornology.isBounded_defₓ'. -/\ntheorem isBounded_def {s : Set α} : IsBounded s ↔ sᶜ ∈ cobounded α :=\n  Iff.rfl\n#align bornology.is_bounded_def Bornology.isBounded_def\n\n/- warning: bornology.is_bounded_compl_iff -> Bornology.isBounded_compl_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s)) (Bornology.IsCobounded.{u1} α _inst_1 s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s)) (Bornology.IsCobounded.{u1} α _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_compl_iff Bornology.isBounded_compl_iffₓ'. -/\n@[simp]\ntheorem isBounded_compl_iff : IsBounded (sᶜ) ↔ IsCobounded s := by\n  rw [is_bounded_def, is_cobounded_def, compl_compl]\n#align bornology.is_bounded_compl_iff Bornology.isBounded_compl_iff\n\n/- warning: bornology.is_cobounded_compl_iff -> Bornology.isCobounded_compl_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsCobounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s)) (Bornology.IsBounded.{u1} α _inst_1 s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, Iff (Bornology.IsCobounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s)) (Bornology.IsBounded.{u1} α _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_compl_iff Bornology.isCobounded_compl_iffₓ'. -/\n@[simp]\ntheorem isCobounded_compl_iff : IsCobounded (sᶜ) ↔ IsBounded s :=\n  Iff.rfl\n#align bornology.is_cobounded_compl_iff Bornology.isCobounded_compl_iff\n\n/- warning: bornology.is_bounded.of_compl -> Bornology.IsBounded.of_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsBounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s)) -> (Bornology.IsCobounded.{u1} α _inst_1 s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsBounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s)) -> (Bornology.IsCobounded.{u1} α _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded.of_compl Bornology.IsBounded.of_complₓ'. -/\n/- warning: bornology.is_cobounded.compl -> Bornology.IsCobounded.compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsCobounded.{u1} α _inst_1 s) -> (Bornology.IsBounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsCobounded.{u1} α _inst_1 s) -> (Bornology.IsBounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded.compl Bornology.IsCobounded.complₓ'. -/\nalias is_bounded_compl_iff ↔ is_bounded.of_compl is_cobounded.compl\n#align bornology.is_bounded.of_compl Bornology.IsBounded.of_compl\n#align bornology.is_cobounded.compl Bornology.IsCobounded.compl\n\n/- warning: bornology.is_cobounded.of_compl -> Bornology.IsCobounded.of_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsCobounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s)) -> (Bornology.IsBounded.{u1} α _inst_1 s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsCobounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s)) -> (Bornology.IsBounded.{u1} α _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded.of_compl Bornology.IsCobounded.of_complₓ'. -/\n/- warning: bornology.is_bounded.compl -> Bornology.IsBounded.compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsBounded.{u1} α _inst_1 s) -> (Bornology.IsCobounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α}, (Bornology.IsBounded.{u1} α _inst_1 s) -> (Bornology.IsCobounded.{u1} α _inst_1 (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded.compl Bornology.IsBounded.complₓ'. -/\nalias is_cobounded_compl_iff ↔ is_cobounded.of_compl is_bounded.compl\n#align bornology.is_cobounded.of_compl Bornology.IsCobounded.of_compl\n#align bornology.is_bounded.compl Bornology.IsBounded.compl\n\n#print Bornology.isBounded_empty /-\n@[simp]\ntheorem isBounded_empty : IsBounded (∅ : Set α) :=\n  by\n  rw [is_bounded_def, compl_empty]\n  exact univ_mem\n#align bornology.is_bounded_empty Bornology.isBounded_empty\n-/\n\n#print Bornology.isBounded_singleton /-\n@[simp]\ntheorem isBounded_singleton : IsBounded ({x} : Set α) :=\n  by\n  rw [is_bounded_def]\n  exact le_cofinite _ (finite_singleton x).compl_mem_cofinite\n#align bornology.is_bounded_singleton Bornology.isBounded_singleton\n-/\n\n#print Bornology.isCobounded_univ /-\n@[simp]\ntheorem isCobounded_univ : IsCobounded (univ : Set α) :=\n  univ_mem\n#align bornology.is_cobounded_univ Bornology.isCobounded_univ\n-/\n\n/- warning: bornology.is_cobounded_inter -> Bornology.isCobounded_inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Bornology.IsCobounded.{u1} α _inst_1 (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) s t)) (And (Bornology.IsCobounded.{u1} α _inst_1 s) (Bornology.IsCobounded.{u1} α _inst_1 t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Bornology.IsCobounded.{u1} α _inst_1 (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) s t)) (And (Bornology.IsCobounded.{u1} α _inst_1 s) (Bornology.IsCobounded.{u1} α _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_inter Bornology.isCobounded_interₓ'. -/\n@[simp]\ntheorem isCobounded_inter : IsCobounded (s ∩ t) ↔ IsCobounded s ∧ IsCobounded t :=\n  inter_mem_iff\n#align bornology.is_cobounded_inter Bornology.isCobounded_inter\n\n/- warning: bornology.is_cobounded.inter -> Bornology.IsCobounded.inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Bornology.IsCobounded.{u1} α _inst_1 s) -> (Bornology.IsCobounded.{u1} α _inst_1 t) -> (Bornology.IsCobounded.{u1} α _inst_1 (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) s t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Bornology.IsCobounded.{u1} α _inst_1 s) -> (Bornology.IsCobounded.{u1} α _inst_1 t) -> (Bornology.IsCobounded.{u1} α _inst_1 (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) s t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded.inter Bornology.IsCobounded.interₓ'. -/\ntheorem IsCobounded.inter (hs : IsCobounded s) (ht : IsCobounded t) : IsCobounded (s ∩ t) :=\n  isCobounded_inter.2 ⟨hs, ht⟩\n#align bornology.is_cobounded.inter Bornology.IsCobounded.inter\n\n/- warning: bornology.is_bounded_union -> Bornology.isBounded_union is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t)) (And (Bornology.IsBounded.{u1} α _inst_1 s) (Bornology.IsBounded.{u1} α _inst_1 t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Bornology.IsBounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t)) (And (Bornology.IsBounded.{u1} α _inst_1 s) (Bornology.IsBounded.{u1} α _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_union Bornology.isBounded_unionₓ'. -/\n@[simp]\ntheorem isBounded_union : IsBounded (s ∪ t) ↔ IsBounded s ∧ IsBounded t := by\n  simp only [← is_cobounded_compl_iff, compl_union, is_cobounded_inter]\n#align bornology.is_bounded_union Bornology.isBounded_union\n\n/- warning: bornology.is_bounded.union -> Bornology.IsBounded.union is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Bornology.IsBounded.{u1} α _inst_1 s) -> (Bornology.IsBounded.{u1} α _inst_1 t) -> (Bornology.IsBounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u1} α} {t : Set.{u1} α}, (Bornology.IsBounded.{u1} α _inst_1 s) -> (Bornology.IsBounded.{u1} α _inst_1 t) -> (Bornology.IsBounded.{u1} α _inst_1 (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded.union Bornology.IsBounded.unionₓ'. -/\ntheorem IsBounded.union (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s ∪ t) :=\n  isBounded_union.2 ⟨hs, ht⟩\n#align bornology.is_bounded.union Bornology.IsBounded.union\n\n#print Bornology.IsCobounded.superset /-\ntheorem IsCobounded.superset (hs : IsCobounded s) (ht : s ⊆ t) : IsCobounded t :=\n  mem_of_superset hs ht\n#align bornology.is_cobounded.superset Bornology.IsCobounded.superset\n-/\n\n#print Bornology.IsBounded.subset /-\ntheorem IsBounded.subset (ht : IsBounded t) (hs : s ⊆ t) : IsBounded s :=\n  ht.Superset (compl_subset_compl.mpr hs)\n#align bornology.is_bounded.subset Bornology.IsBounded.subset\n-/\n\n#print Bornology.unionₛ_bounded_univ /-\n@[simp]\ntheorem unionₛ_bounded_univ : ⋃₀ { s : Set α | IsBounded s } = univ :=\n  unionₛ_eq_univ_iff.2 fun a => ⟨{a}, isBounded_singleton, mem_singleton a⟩\n#align bornology.sUnion_bounded_univ Bornology.unionₛ_bounded_univ\n-/\n\n/- warning: bornology.comap_cobounded_le_iff -> Bornology.comap_cobounded_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Bornology.{u1} α] [_inst_2 : Bornology.{u2} β] {f : α -> β}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (Filter.comap.{u1, u2} α β f (Bornology.cobounded.{u2} β _inst_2)) (Bornology.cobounded.{u1} α _inst_1)) (forall {{s : Set.{u1} α}}, (Bornology.IsBounded.{u1} α _inst_1 s) -> (Bornology.IsBounded.{u2} β _inst_2 (Set.image.{u1, u2} α β f s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Bornology.{u1} α] [_inst_2 : Bornology.{u2} β] {f : α -> β}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Filter.comap.{u1, u2} α β f (Bornology.cobounded.{u2} β _inst_2)) (Bornology.cobounded.{u1} α _inst_1)) (forall {{s : Set.{u1} α}}, (Bornology.IsBounded.{u1} α _inst_1 s) -> (Bornology.IsBounded.{u2} β _inst_2 (Set.image.{u1, u2} α β f s)))\nCase conversion may be inaccurate. Consider using '#align bornology.comap_cobounded_le_iff Bornology.comap_cobounded_le_iffₓ'. -/\ntheorem comap_cobounded_le_iff [Bornology β] {f : α → β} :\n    (cobounded β).comap f ≤ cobounded α ↔ ∀ ⦃s⦄, IsBounded s → IsBounded (f '' s) :=\n  by\n  refine'\n    ⟨fun h s hs => _, fun h t ht =>\n      ⟨(f '' tᶜ)ᶜ, h <| is_cobounded.compl ht, compl_subset_comm.1 <| subset_preimage_image _ _⟩⟩\n  obtain ⟨t, ht, hts⟩ := h hs.compl\n  rw [subset_compl_comm, ← preimage_compl] at hts\n  exact (is_cobounded.compl ht).Subset ((image_subset f hts).trans <| image_preimage_subset _ _)\n#align bornology.comap_cobounded_le_iff Bornology.comap_cobounded_le_iff\n\nend\n\n#print Bornology.ext_iff' /-\ntheorem ext_iff' {t t' : Bornology α} :\n    t = t' ↔ ∀ s, (@cobounded α t).sets s ↔ (@cobounded α t').sets s :=\n  (ext_iff _ _).trans Filter.ext_iff\n#align bornology.ext_iff' Bornology.ext_iff'\n-/\n\n#print Bornology.ext_iff_isBounded /-\ntheorem ext_iff_isBounded {t t' : Bornology α} :\n    t = t' ↔ ∀ s, @IsBounded α t s ↔ @IsBounded α t' s :=\n  ⟨fun h s => h ▸ Iff.rfl, fun h => by\n    ext\n    simpa only [is_bounded_def, compl_compl] using h (sᶜ)⟩\n#align bornology.ext_iff_is_bounded Bornology.ext_iff_isBounded\n-/\n\nvariable {s : Set α}\n\n/- warning: bornology.is_cobounded_of_bounded_iff -> Bornology.isCobounded_ofBounded_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} α} (B : Set.{u1} (Set.{u1} α)) {empty_mem : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α)) B} {subset_mem : forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s₂ s₁) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B))} {union_mem : forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s₁ s₂) B))} {sUnion_univ : forall (x : α), Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x) B}, Iff (Bornology.IsCobounded.{u1} α (Bornology.ofBounded.{u1} α B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) B)\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} α} (B : Set.{u1} (Set.{u1} α)) {empty_mem : Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α)) B} {subset_mem : forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s₂ s₁) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B))} {union_mem : forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s₁ s₂) B))} {sUnion_univ : forall (x : α), Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x) B}, Iff (Bornology.IsCobounded.{u1} α (Bornology.ofBounded.{u1} α B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) B)\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_of_bounded_iff Bornology.isCobounded_ofBounded_iffₓ'. -/\ntheorem isCobounded_ofBounded_iff (B : Set (Set α)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsCobounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s ↔ sᶜ ∈ B :=\n  Iff.rfl\n#align bornology.is_cobounded_of_bounded_iff Bornology.isCobounded_ofBounded_iff\n\n/- warning: bornology.is_bounded_of_bounded_iff -> Bornology.isBounded_ofBounded_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} α} (B : Set.{u1} (Set.{u1} α)) {empty_mem : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α)) B} {subset_mem : forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s₂ s₁) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B))} {union_mem : forall (s₁ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s₂ B) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s₁ s₂) B))} {sUnion_univ : forall (x : α), Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) x) B}, Iff (Bornology.IsBounded.{u1} α (Bornology.ofBounded.{u1} α B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) s B)\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} α} (B : Set.{u1} (Set.{u1} α)) {empty_mem : Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.instEmptyCollectionSet.{u1} α)) B} {subset_mem : forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s₂ s₁) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B))} {union_mem : forall (s₁ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₁ B) -> (forall (s₂ : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s₂ B) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s₁ s₂) B))} {sUnion_univ : forall (x : α), Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) x) B}, Iff (Bornology.IsBounded.{u1} α (Bornology.ofBounded.{u1} α B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) s B)\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_of_bounded_iff Bornology.isBounded_ofBounded_iffₓ'. -/\ntheorem isBounded_ofBounded_iff (B : Set (Set α)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsBounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s ↔ s ∈ B := by\n  rw [is_bounded_def, ← Filter.mem_sets, of_bounded_cobounded_sets, Set.mem_setOf_eq, compl_compl]\n#align bornology.is_bounded_of_bounded_iff Bornology.isBounded_ofBounded_iff\n\nvariable [Bornology α]\n\n/- warning: bornology.is_cobounded_bInter -> Bornology.isCobounded_binterᵢ is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Bornology.{u2} α] {s : Set.{u1} ι} {f : ι -> (Set.{u2} α)}, (Set.Finite.{u1} ι s) -> (Iff (Bornology.IsCobounded.{u2} α _inst_1 (Set.interᵢ.{u2, succ u1} α ι (fun (i : ι) => Set.interᵢ.{u2, 0} α (Membership.Mem.{u1, u1} ι (Set.{u1} ι) (Set.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Set.{u1} ι) (Set.hasMem.{u1} ι) i s) => f i)))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Set.{u1} ι) (Set.hasMem.{u1} ι) i s) -> (Bornology.IsCobounded.{u2} α _inst_1 (f i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u2} ι} {f : ι -> (Set.{u1} α)}, (Set.Finite.{u2} ι s) -> (Iff (Bornology.IsCobounded.{u1} α _inst_1 (Set.interᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.interᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) => f i)))) (forall (i : ι), (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) -> (Bornology.IsCobounded.{u1} α _inst_1 (f i))))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_bInter Bornology.isCobounded_binterᵢₓ'. -/\ntheorem isCobounded_binterᵢ {s : Set ι} {f : ι → Set α} (hs : s.Finite) :\n    IsCobounded (⋂ i ∈ s, f i) ↔ ∀ i ∈ s, IsCobounded (f i) :=\n  binterᵢ_mem hs\n#align bornology.is_cobounded_bInter Bornology.isCobounded_binterᵢ\n\n/- warning: bornology.is_cobounded_bInter_finset -> Bornology.isCobounded_binterᵢ_finset is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Bornology.{u2} α] (s : Finset.{u1} ι) {f : ι -> (Set.{u2} α)}, Iff (Bornology.IsCobounded.{u2} α _inst_1 (Set.interᵢ.{u2, succ u1} α ι (fun (i : ι) => Set.interᵢ.{u2, 0} α (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => f i)))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Bornology.IsCobounded.{u2} α _inst_1 (f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] (s : Finset.{u2} ι) {f : ι -> (Set.{u1} α)}, Iff (Bornology.IsCobounded.{u1} α _inst_1 (Set.interᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.interᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) => f i)))) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Bornology.IsCobounded.{u1} α _inst_1 (f i)))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_bInter_finset Bornology.isCobounded_binterᵢ_finsetₓ'. -/\n@[simp]\ntheorem isCobounded_binterᵢ_finset (s : Finset ι) {f : ι → Set α} :\n    IsCobounded (⋂ i ∈ s, f i) ↔ ∀ i ∈ s, IsCobounded (f i) :=\n  binterᵢ_finset_mem s\n#align bornology.is_cobounded_bInter_finset Bornology.isCobounded_binterᵢ_finset\n\n/- warning: bornology.is_cobounded_Inter -> Bornology.isCobounded_interᵢ is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Bornology.{u2} α] [_inst_2 : Finite.{succ u1} ι] {f : ι -> (Set.{u2} α)}, Iff (Bornology.IsCobounded.{u2} α _inst_1 (Set.interᵢ.{u2, succ u1} α ι (fun (i : ι) => f i))) (forall (i : ι), Bornology.IsCobounded.{u2} α _inst_1 (f i))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] [_inst_2 : Finite.{succ u2} ι] {f : ι -> (Set.{u1} α)}, Iff (Bornology.IsCobounded.{u1} α _inst_1 (Set.interᵢ.{u1, succ u2} α ι (fun (i : ι) => f i))) (forall (i : ι), Bornology.IsCobounded.{u1} α _inst_1 (f i))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_Inter Bornology.isCobounded_interᵢₓ'. -/\n@[simp]\ntheorem isCobounded_interᵢ [Finite ι] {f : ι → Set α} :\n    IsCobounded (⋂ i, f i) ↔ ∀ i, IsCobounded (f i) :=\n  interᵢ_mem\n#align bornology.is_cobounded_Inter Bornology.isCobounded_interᵢ\n\n#print Bornology.isCobounded_interₛ /-\ntheorem isCobounded_interₛ {S : Set (Set α)} (hs : S.Finite) :\n    IsCobounded (⋂₀ S) ↔ ∀ s ∈ S, IsCobounded s :=\n  interₛ_mem hs\n#align bornology.is_cobounded_sInter Bornology.isCobounded_interₛ\n-/\n\n/- warning: bornology.is_bounded_bUnion -> Bornology.isBounded_bunionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Bornology.{u2} α] {s : Set.{u1} ι} {f : ι -> (Set.{u2} α)}, (Set.Finite.{u1} ι s) -> (Iff (Bornology.IsBounded.{u2} α _inst_1 (Set.unionᵢ.{u2, succ u1} α ι (fun (i : ι) => Set.unionᵢ.{u2, 0} α (Membership.Mem.{u1, u1} ι (Set.{u1} ι) (Set.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Set.{u1} ι) (Set.hasMem.{u1} ι) i s) => f i)))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Set.{u1} ι) (Set.hasMem.{u1} ι) i s) -> (Bornology.IsBounded.{u2} α _inst_1 (f i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] {s : Set.{u2} ι} {f : ι -> (Set.{u1} α)}, (Set.Finite.{u2} ι s) -> (Iff (Bornology.IsBounded.{u1} α _inst_1 (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) => f i)))) (forall (i : ι), (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) -> (Bornology.IsBounded.{u1} α _inst_1 (f i))))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_bUnion Bornology.isBounded_bunionᵢₓ'. -/\ntheorem isBounded_bunionᵢ {s : Set ι} {f : ι → Set α} (hs : s.Finite) :\n    IsBounded (⋃ i ∈ s, f i) ↔ ∀ i ∈ s, IsBounded (f i) := by\n  simp only [← is_cobounded_compl_iff, compl_Union, is_cobounded_bInter hs]\n#align bornology.is_bounded_bUnion Bornology.isBounded_bunionᵢ\n\n/- warning: bornology.is_bounded_bUnion_finset -> Bornology.isBounded_bunionᵢ_finset is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Bornology.{u2} α] (s : Finset.{u1} ι) {f : ι -> (Set.{u2} α)}, Iff (Bornology.IsBounded.{u2} α _inst_1 (Set.unionᵢ.{u2, succ u1} α ι (fun (i : ι) => Set.unionᵢ.{u2, 0} α (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => f i)))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Bornology.IsBounded.{u2} α _inst_1 (f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] (s : Finset.{u2} ι) {f : ι -> (Set.{u1} α)}, Iff (Bornology.IsBounded.{u1} α _inst_1 (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) => f i)))) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Bornology.IsBounded.{u1} α _inst_1 (f i)))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_bUnion_finset Bornology.isBounded_bunionᵢ_finsetₓ'. -/\ntheorem isBounded_bunionᵢ_finset (s : Finset ι) {f : ι → Set α} :\n    IsBounded (⋃ i ∈ s, f i) ↔ ∀ i ∈ s, IsBounded (f i) :=\n  isBounded_bunionᵢ s.finite_toSet\n#align bornology.is_bounded_bUnion_finset Bornology.isBounded_bunionᵢ_finset\n\n#print Bornology.isBounded_unionₛ /-\ntheorem isBounded_unionₛ {S : Set (Set α)} (hs : S.Finite) :\n    IsBounded (⋃₀ S) ↔ ∀ s ∈ S, IsBounded s := by rw [sUnion_eq_bUnion, is_bounded_bUnion hs]\n#align bornology.is_bounded_sUnion Bornology.isBounded_unionₛ\n-/\n\n/- warning: bornology.is_bounded_Union -> Bornology.isBounded_unionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Bornology.{u2} α] [_inst_2 : Finite.{succ u1} ι] {s : ι -> (Set.{u2} α)}, Iff (Bornology.IsBounded.{u2} α _inst_1 (Set.unionᵢ.{u2, succ u1} α ι (fun (i : ι) => s i))) (forall (i : ι), Bornology.IsBounded.{u2} α _inst_1 (s i))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Bornology.{u1} α] [_inst_2 : Finite.{succ u2} ι] {s : ι -> (Set.{u1} α)}, Iff (Bornology.IsBounded.{u1} α _inst_1 (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => s i))) (forall (i : ι), Bornology.IsBounded.{u1} α _inst_1 (s i))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_Union Bornology.isBounded_unionᵢₓ'. -/\n@[simp]\ntheorem isBounded_unionᵢ [Finite ι] {s : ι → Set α} : IsBounded (⋃ i, s i) ↔ ∀ i, IsBounded (s i) :=\n  by rw [← sUnion_range, is_bounded_sUnion (finite_range s), forall_range_iff]\n#align bornology.is_bounded_Union Bornology.isBounded_unionᵢ\n\nend Bornology\n\nopen Bornology\n\n#print Set.Finite.isBounded /-\ntheorem Set.Finite.isBounded [Bornology α] {s : Set α} (hs : s.Finite) : IsBounded s :=\n  Bornology.le_cofinite α hs.compl_mem_cofinite\n#align set.finite.is_bounded Set.Finite.isBounded\n-/\n\ninstance : Bornology PUnit :=\n  ⟨⊥, bot_le⟩\n\n#print Bornology.cofinite /-\n/-- The cofinite filter as a bornology -/\n@[reducible]\ndef Bornology.cofinite : Bornology α\n    where\n  cobounded := cofinite\n  le_cofinite := le_rfl\n#align bornology.cofinite Bornology.cofinite\n-/\n\n#print BoundedSpace /-\n/-- A space with a `bornology` is a **bounded space** if `set.univ : set α` is bounded. -/\nclass BoundedSpace (α : Type _) [Bornology α] : Prop where\n  bounded_univ : Bornology.IsBounded (univ : Set α)\n#align bounded_space BoundedSpace\n-/\n\nnamespace Bornology\n\nvariable [Bornology α]\n\n#print Bornology.isBounded_univ /-\ntheorem isBounded_univ : IsBounded (univ : Set α) ↔ BoundedSpace α :=\n  ⟨fun h => ⟨h⟩, fun h => h.1⟩\n#align bornology.is_bounded_univ Bornology.isBounded_univ\n-/\n\n/- warning: bornology.cobounded_eq_bot_iff -> Bornology.cobounded_eq_bot_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α], Iff (Eq.{succ u1} (Filter.{u1} α) (Bornology.cobounded.{u1} α _inst_1) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α)))) (BoundedSpace.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Bornology.{u1} α], Iff (Eq.{succ u1} (Filter.{u1} α) (Bornology.cobounded.{u1} α _inst_1) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α)))) (BoundedSpace.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align bornology.cobounded_eq_bot_iff Bornology.cobounded_eq_bot_iffₓ'. -/\ntheorem cobounded_eq_bot_iff : cobounded α = ⊥ ↔ BoundedSpace α := by\n  rw [← is_bounded_univ, is_bounded_def, compl_univ, empty_mem_iff_bot]\n#align bornology.cobounded_eq_bot_iff Bornology.cobounded_eq_bot_iff\n\nvariable [BoundedSpace α]\n\n#print Bornology.IsBounded.all /-\ntheorem IsBounded.all (s : Set α) : IsBounded s :=\n  BoundedSpace.bounded_univ.Subset s.subset_univ\n#align bornology.is_bounded.all Bornology.IsBounded.all\n-/\n\n#print Bornology.IsCobounded.all /-\ntheorem IsCobounded.all (s : Set α) : IsCobounded s :=\n  compl_compl s ▸ IsBounded.all (sᶜ)\n#align bornology.is_cobounded.all Bornology.IsCobounded.all\n-/\n\nvariable (α)\n\n/- warning: bornology.cobounded_eq_bot -> Bornology.cobounded_eq_bot is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Bornology.{u1} α] [_inst_2 : BoundedSpace.{u1} α _inst_1], Eq.{succ u1} (Filter.{u1} α) (Bornology.cobounded.{u1} α _inst_1) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α)))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Bornology.{u1} α] [_inst_2 : BoundedSpace.{u1} α _inst_1], Eq.{succ u1} (Filter.{u1} α) (Bornology.cobounded.{u1} α _inst_1) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align bornology.cobounded_eq_bot Bornology.cobounded_eq_botₓ'. -/\n@[simp]\ntheorem cobounded_eq_bot : cobounded α = ⊥ :=\n  cobounded_eq_bot_iff.2 ‹_›\n#align bornology.cobounded_eq_bot Bornology.cobounded_eq_bot\n\nend Bornology\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Bornology/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.7122321720225279, "lm_q1q2_score": 0.48855527023815426}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Kenny Lau\n-/\n\nimport data.finset.basic\n\n/-!\n# Finsets of ordered types\n-/\n\nuniverses u v w\nvariables {α : Type u}\n\ntheorem directed.finset_le {r : α → α → Prop} [is_trans α r]\n  {ι} [hι : nonempty ι] {f : ι → α} (D : directed r f) (s : finset ι) :\n  ∃ z, ∀ i ∈ s, r (f i) (f z) :=\nshow ∃ z, ∀ i ∈ s.1, r (f i) (f z), from\nmultiset.induction_on s.1 (let ⟨z⟩ := hι in ⟨z, λ _, false.elim⟩) $\nλ i s ⟨j, H⟩, let ⟨k, h₁, h₂⟩ := D i j in\n⟨k, λ a h, or.cases_on (multiset.mem_cons.1 h)\n  (λ h, h.symm ▸ h₁)\n  (λ h, trans (H _ h) h₂)⟩\n\ntheorem finset.exists_le {α : Type u} [nonempty α] [directed_order α] (s : finset α) :\n  ∃ M, ∀ i ∈ s, i ≤ M :=\ndirected.finset_le directed_order.directed s\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/finset/order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4884908845815975}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\n\nimport Std.Logic\nimport Mathlib.Init.Logic\n\n/-! Lemmas use by the congruence closure module -/\n\ntheorem iff_eq_of_eq_true_left {a b : Prop} (h : a = True) : (a ↔ b) = b :=\n  h.symm ▸ propext true_iff_iff\n\ntheorem iff_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a ↔ b) = a :=\n  h.symm ▸ propext iff_true_iff\n\ntheorem iff_eq_true_of_eq {a b : Prop} (h : a = b) : (a ↔ b) = True :=\n  h ▸ propext (iff_self_iff _)\n\ntheorem and_eq_of_eq_true_left {a b : Prop} (h : a = True) : (a ∧ b) = b :=\n  h.symm ▸ propext (true_and_iff _)\n\ntheorem and_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a ∧ b) = a :=\n  h.symm ▸ propext (and_true_iff _)\n\ntheorem and_eq_of_eq_false_left {a b : Prop} (h : a = False) : (a ∧ b) = False :=\n  h.symm ▸ propext (false_and_iff _)\n\ntheorem and_eq_of_eq_false_right {a b : Prop} (h : b = False) : (a ∧ b) = False :=\n  h.symm ▸ propext (and_false_iff _)\n\ntheorem and_eq_of_eq {a b : Prop} (h : a = b) : (a ∧ b) = a :=\n  h ▸ propext (and_self_iff _)\n\ntheorem or_eq_of_eq_true_left {a b : Prop} (h : a = True) : (a ∨ b) = True :=\n  h.symm ▸ propext (true_or_iff _)\n\ntheorem or_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a ∨ b) = True :=\n  h.symm ▸ propext (or_true_iff _)\n\ntheorem or_eq_of_eq_false_left {a b : Prop} (h : a = False) : (a ∨ b) = b :=\n  h.symm ▸ propext (false_or_iff _)\n\ntheorem or_eq_of_eq_false_right {a b : Prop} (h : b = False) : (a ∨ b) = a :=\n  h.symm ▸ propext (or_false_iff _)\n\ntheorem or_eq_of_eq {a b : Prop} (h : a = b) : (a ∨ b) = a :=\n  h ▸ propext (or_self_iff _)\n\ntheorem imp_eq_of_eq_true_left {a b : Prop} (h : a = True) : (a → b) = b :=\n  h.symm ▸ propext ⟨fun h ↦ h trivial, fun h₁ _ ↦ h₁⟩\n\ntheorem imp_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a → b) = True :=\n  h.symm ▸ propext ⟨fun _ ↦ trivial, fun h₁ _ ↦ h₁⟩\n\ntheorem imp_eq_of_eq_false_left {a b : Prop} (h : a = False) : (a → b) = True :=\n  h.symm ▸ propext ⟨fun _ ↦ trivial, fun _ h₂ ↦ False.elim h₂⟩\n\ntheorem imp_eq_of_eq_false_right {a b : Prop} (h : b = False) : (a → b) = Not a :=\n  h.symm ▸ propext ⟨fun h ↦ h, fun hna ha ↦ hna ha⟩\n\n/- Remark: the congruence closure module will only use the following lemma is\n   cc_config.em is tt. -/\ntheorem not_imp_eq_of_eq_false_right {a b : Prop} (h : b = False) : (Not a → b) = a :=\n  h.symm ▸ propext (Iff.intro (\n    fun h' ↦ Classical.byContradiction fun hna ↦ h' hna) fun ha hna ↦ hna ha)\n\ntheorem imp_eq_true_of_eq {a b : Prop} (h : a = b) : (a → b) = True :=\n  h ▸ propext ⟨fun _ ↦ trivial, fun _ ha ↦ ha⟩\n\ntheorem not_eq_of_eq_true {a : Prop} (h : a = True) : Not a = False :=\n  h.symm ▸ propext not_true\n\ntheorem not_eq_of_eq_false {a : Prop} (h : a = False) : Not a = True :=\n  h.symm ▸ propext not_false_iff\n\ntheorem false_of_a_eq_not_a {a : Prop} (h : a = Not a) : False :=\n  have : Not a := fun ha ↦ absurd ha (Eq.mp h ha)\n  absurd (Eq.mpr h this) this\n\nuniverse u\n\ntheorem if_eq_of_eq_true {c : Prop} [d : Decidable c] {α : Sort u} (t e : α) (h : c = True) :\n  @ite α c d t e = t :=\n  if_pos (of_eq_true h)\n\ntheorem if_eq_of_eq_false {c : Prop} [d : Decidable c] {α : Sort u} (t e : α) (h : c = False) :\n  @ite α c d t e = e :=\n  if_neg (not_of_eq_false h)\n\ntheorem if_eq_of_eq (c : Prop) [d : Decidable c] {α : Sort u} {t e : α} (h : t = e) :\n  @ite α c d t e = t :=\n  match d with\n  | isTrue _ => rfl\n  | isFalse _ => Eq.symm h\n\ntheorem eq_true_of_and_eq_true_left {a b : Prop} (h : (a ∧ b) = True) : a = True :=\n  eq_true (And.left (of_eq_true h))\n\ntheorem eq_true_of_and_eq_true_right {a b : Prop} (h : (a ∧ b) = True) : b = True :=\n  eq_true (And.right (of_eq_true h))\n\ntheorem eq_false_of_or_eq_false_left {a b : Prop} (h : (a ∨ b) = False) : a = False :=\n  eq_false fun ha ↦ False.elim (Eq.mp h (Or.inl ha))\n\ntheorem eq_false_of_or_eq_false_right {a b : Prop} (h : (a ∨ b) = False) : b = False :=\n  eq_false fun hb ↦ False.elim (Eq.mp h (Or.inr hb))\n\ntheorem eq_false_of_not_eq_true {a : Prop} (h : Not a = True) : a = False :=\n  eq_false fun ha ↦ absurd ha (Eq.mpr h trivial)\n\n/- Remark: the congruence closure module will only use the following lemma is\n   cc_config.em is tt. -/\ntheorem eq_true_of_not_eq_false {a : Prop} (h : Not a = False) : a = True :=\n  eq_true (Classical.byContradiction fun hna ↦ Eq.mp h hna)\n\ntheorem ne_of_eq_of_ne {α : Sort u} {a b c : α} (h₁ : a = b) (h₂ : b ≠ c) : a ≠ c :=\n  h₁.symm ▸ h₂\n\nalias ne_of_eq_of_ne ← Eq.trans_ne\n#align eq.trans_ne Eq.trans_ne\n\ntheorem ne_of_ne_of_eq {α : Sort u} {a b c : α} (h₁ : a ≠ b) (h₂ : b = c) : a ≠ c :=\n  h₂ ▸ h₁\n\nalias ne_of_ne_of_eq ← Ne.trans_eq\n#align ne.trans_eq Ne.trans_eq\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Init/CcLemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4884908787103135}}
{"text": "\nlemma notFalse: ¬false :=\nbegin\n  assume pfFalse,\n  assumption,\nend\n\nlemma falseImpliesAnything{anything: Prop}:\n  false → anything :=\nbegin\n  assume pfFalse,\n  have pfAnything: anything := false.elim pfFalse,\n  assumption,\nend\n\nlemma tru: true :=\nbegin\n  exact true.intro,\nend\n", "meta": {"author": "kevinsullivan", "repo": "uva-cs-dm-s19", "sha": "3e7177682acdb56a2d16914e0344c10335583dcf", "save_path": "github-repos/lean/kevinsullivan-uva-cs-dm-s19", "path": "github-repos/lean/kevinsullivan-uva-cs-dm-s19/uva-cs-dm-s19-3e7177682acdb56a2d16914e0344c10335583dcf/examples/false_true_properties.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929104825007, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4883724193197655}}
{"text": "/-\nCopyright (c) 2019 The Flypitch Project. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n\nAuthors: Jesse Han, Floris van Doorn\n-/\nimport order.complete_boolean_algebra order.zorn .pSet_ordinal .bv_tauto\n\nlocal infix ` ⟹ `:65 := lattice.imp\n\nlocal infix ` ⇔ `:50 := lattice.biimp\n\n-- uncomment in case of emergency\n-- @[tidy] meta def big_bertha : tactic unit := `[finish]\n\nnamespace lattice\n\nsection natded\nvariables {𝔹 : Type*} [complete_boolean_algebra 𝔹]\n\nlemma supr_imp_eq {ι : Type*} {s : ι → 𝔹} {b : 𝔹} :\n  (⨆(i:ι), s i) ⟹ b = (⨅(i:ι), s i ⟹ b) :=\nby {unfold imp, rw[neg_supr, infi_sup_eq]}\n\nlemma imp_infi_eq {ι : Type*} {s : ι → 𝔹} {b : 𝔹} :\n  (b ⟹ (⨅i, s i)) = (⨅i, b ⟹ s i) :=\nby {unfold imp, rw[sup_infi_eq]}\n\nlemma bv_Or_elim  {ι : Type*} {s : ι → 𝔹} {c : 𝔹} :\n(∀ i : ι, (s i ≤ c)) → ((⨆(i:ι), s i) ≤ c) :=\nλ H, by apply supr_le; from H\n\nlemma bv_And_intro {ι : Type*} {s : ι → 𝔹} {b c : 𝔹} :\n(∀ i : ι, (c ≤ s i)) → (c ≤ ⨅(i:ι), s i) :=\nλ H, by {apply le_infi, from H} -- this is superceded by tactic.interactive.bv_intro\n\nlemma bv_or_elim {b₁ b₂ c : 𝔹} {h : b₁ ≤ c} {h' : b₂ ≤ c} : b₁ ⊔ b₂ ≤ c :=\n  by apply sup_le; assumption\n\nlemma bv_or_elim_left {b₁ b₂ c d : 𝔹} {h₁ : b₁ ⊓ d ≤ c} {h₂ : b₂ ⊓ d ≤ c} : (b₁ ⊔ b₂) ⊓ d ≤ c :=\n  by {rw[deduction], apply bv_or_elim; rw[<-deduction]; from ‹_›}\n\nlemma bv_or_elim_right {b₁ b₂ c d : 𝔹} {h₁ : d ⊓ b₁ ≤ c} {h₂ : d ⊓ b₂ ≤ c} : d ⊓ (b₁ ⊔ b₂) ≤ c :=\n  by {rw[inf_comm] at ⊢ h₁ h₂; apply bv_or_elim_left; assumption}\n\nlemma bv_exfalso {a b : 𝔹} (h : a ≤ ⊥) : a ≤ b :=\nle_trans h bot_le\n\nlemma bv_cases_left {ι : Type*} {s : ι → 𝔹} {c b : 𝔹} {h : ∀ i : ι, (s i ⊓ c ≤ b)} :\n  ((⨆(i:ι), s i) ⊓ c) ≤ b :=\nby {rw[deduction], apply supr_le, intro i, rw[<-deduction], revert i, from ‹_›}\n\nlemma bv_cases_right {ι : Type*} {s : ι → 𝔹} {c b : 𝔹} {h : ∀ i : ι, (c ⊓ s i ≤ b)} :\n  (c ⊓ (⨆(i:ι), s i)) ≤ b :=\nby {rw[inf_comm], apply bv_cases_left, simpa only [inf_comm]}\n\nlemma bv_specialize {ι : Type*} {s : ι → 𝔹} (i : ι) {b : 𝔹} {h : s i ≤ b} :\n(⨅(i:ι), s i) ≤ b := infi_le_of_le i h\n\n--TODO(jesse) write the version of this for an arbitrary list of instantiations\nlemma bv_specialize_twice {ι : Type*} {s : ι → 𝔹} (i j : ι) {b : 𝔹} {h : s i ⊓ s j ≤ b} :\n(⨅(i:ι), s i) ≤ b :=\nbegin\n  apply le_trans', apply infi_le, from i, apply le_trans', apply inf_le_left_of_le,\n  apply infi_le, from j, apply le_trans _ h, apply inf_le_inf, apply inf_le_right, refl\nend\n\nlemma bv_specialize_left {ι : Type*} {s : ι → 𝔹} {c b : 𝔹} (i : ι)\n  {h : s i ⊓ c ≤ b} : (⨅(i:ι), s i) ⊓ c ≤ b :=\nby {rw[deduction], apply bv_specialize i, rwa[<-deduction]}\n\nlemma bv_specialize_left_twice {ι : Type*} {s : ι → 𝔹} {c b : 𝔹} (i j : ι)\n  {h : s i ⊓ s j ⊓ c ≤ b} : (⨅(i:ι), s i) ⊓ c ≤ b :=\nbegin\n  rw[deduction], apply bv_specialize_twice i j, rwa[<-deduction]\nend\n\nlemma bv_specialize_right {ι : Type*} {s :ι → 𝔹} {c b : 𝔹} (i : ι)\n  {h : c ⊓ s i ≤ b} : c ⊓ (⨅(i:ι), s i) ≤ b :=\nby {rw[inf_comm], apply bv_specialize_left i, rwa[inf_comm]}\n\nlemma bv_specialize_right_twice {ι : Type*} {s : ι → 𝔹} {c b : 𝔹} (i j : ι)\n  {h : c ⊓ (s i ⊓ s j) ≤ b} : c ⊓ (⨅(i:ι), s i) ≤ b :=\nbegin\n  rw[inf_comm], apply bv_specialize_left_twice i j, rwa[<-inf_comm]\nend\n\nlemma bv_imp_elim {a b : 𝔹} : (a ⟹ b) ⊓ a ≤ b :=\nby simp[imp, inf_sup_right]\n\nlemma bv_imp_elim' {a b : 𝔹} : (a ⟹ b) ⊓ a ≤ a ⊓ b :=\nby {simp[imp, inf_sup_right]}\n\nlemma bv_cancel_antecedent {a b c : 𝔹} (h : b ≤ c) : a ⟹ b ≤ a ⟹ c :=\nby {rw[<-deduction], apply le_trans, apply bv_imp_elim, from ‹_›}\n\nlemma bv_imp_iff {Γ b₁ b₂ : 𝔹} : Γ ≤ b₁ ⟹ b₂ ↔ (∀ {Γ'} (H_le : Γ' ≤ Γ), Γ' ≤ b₁ → Γ' ≤ b₂) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { intros Γ' H_le H', rw ←deduction at H,\n      exact le_trans (le_inf ‹_› ‹_›) H },\n    { bv_imp_intro H', apply H,\n      { dsimp[Γ_1], from inf_le_right },\n      { from ‹_› } }\nend\n\nlemma bv_biimp_iff {b₁ b₂ : 𝔹} {Γ : 𝔹} : (Γ ≤ (b₁ ⇔ b₂)) ↔ (∀ {Γ'} (H_le : Γ' ≤ Γ), Γ' ≤ b₁ ↔ Γ' ≤ b₂) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { bv_split_at H,\n      intros Γ' H_le, refine ⟨_,_⟩,\n        { rw bv_imp_iff at *, solve_by_elim },\n        { rw bv_imp_iff at *, solve_by_elim }},\n    { refine le_inf _ _,\n      { rw bv_imp_iff, intros, exact (H ‹_›).mp ‹_› },\n      { rw bv_imp_iff, intros, exact (H ‹_›).mpr ‹_› }}\nend\n\n-- example {a b c : 𝔹} (h : b ≤ c) : a ⟹ b ≤ a ⟹ c :=\n-- by {tidy_context, bv_imp_intro, apply (poset_yoneda_inv _ h), from a_1 ‹_›}\n\nlemma bv_and_intro {a b₁ b₂ : 𝔹} (h₁ : a ≤ b₁) (h₂ : a ≤ b₂) : a ≤ b₁ ⊓ b₂ := le_inf h₁ h₂\n\nlemma bv_or_left {a b₁ b₂ : 𝔹} (h₁ : a ≤ b₁) : a ≤ b₁ ⊔ b₂ := le_sup_left_of_le h₁\n\nlemma bv_or_right {a b₁ b₂ : 𝔹} (h₂ : a ≤ b₂) : a ≤ b₁ ⊔ b₂ := le_sup_right_of_le h₂\n\nlemma bv_and.left {a b : 𝔹} {Γ} (H : Γ ≤ a ⊓ b) : Γ ≤ a :=\nle_trans H inf_le_left\n\nlemma bv_and.right {a b : 𝔹} {Γ} (H : Γ ≤ a ⊓ b) : Γ ≤ b :=\nle_trans H inf_le_right\n\nlemma from_empty_context {a b : 𝔹} (h : ⊤ ≤ b) : a ≤ b :=\n  by refine le_trans _ h; apply le_top\n\nlemma bv_imp_intro {a b c : 𝔹} {h : a ⊓ b ≤ c} :\n  a ≤ b ⟹ c := by rwa[deduction] at h\n\nlemma bv_have {a b c : 𝔹} (h : a ≤ b) {h' : a ⊓ b ≤ c} : a ≤ c :=\nby {rw[(inf_self.symm : a = _)], apply le_trans, apply inf_le_inf, refl, exact h, exact h'}\n\nlemma bv_have_true {a b c : 𝔹} (h₁ : ⊤ ≤ b) (h₂ : a ⊓ b ≤ c) : a ≤ c :=\nby {rw[top_le_iff] at h₁, rw[h₁] at h₂, from le_trans (by rw[inf_top_eq]) h₂}\n\nlemma bv_use {ι} (i : ι) {s : ι → 𝔹} {b : 𝔹}  {h : b ≤ s i} : b ≤ ⨆(j:ι), s j :=\n  le_supr_of_le i h\n\nlemma bv_context_apply {β : Type*} [complete_boolean_algebra β] {Γ a₁ a₂ : β}\n  (h₁ : Γ ≤ a₁ ⟹ a₂) (h₂ : Γ ≤ a₁) : Γ ≤ a₂ := h₁ ‹_›\n\nlemma bv_Or_imp {Γ : 𝔹} {ι} {ϕ₁ ϕ₂ : ι → 𝔹} (H_sub : Γ ≤ ⨅ x, ϕ₁ x ⟹ ϕ₂ x) (H : Γ ≤ ⨆x, ϕ₁ x)  : Γ ≤ ⨆x, ϕ₂ x :=\nby {bv_cases_at H x, apply bv_use x, from H_sub x ‹_›}\n\nlemma bv_iff.neg {b₁ b₂ : 𝔹} (H : ∀{Γ}, Γ ≤ b₁ ↔ Γ ≤ b₂) : ∀ {Γ}, Γ ≤ -(b₁) ↔ Γ ≤ -(b₂) :=\nbegin\n  intro Γ, refine ⟨_,_⟩; intro H',\n    { apply bv_by_contra, bv_imp_intro H_contra, rw lattice.neg_neg at H_contra, rw ←imp_bot at H',\n      refine H' _, rwa H },\n    { apply bv_by_contra, bv_imp_intro H_contra, rw lattice.neg_neg at H_contra, rw ←imp_bot at H',\n      refine H' _, rwa ←H }\nend\n\nend natded\nend lattice\n\nopen lattice\n\nuniverse u\n\nnamespace pSet\n\n/-- If two pre-sets `x` and `y` are not equivalent, then either there exists a member of x\nwhich is not equivalent to any member of y, or there exists a member of y which is not\nequivalent to any member of x -/\nlemma not_equiv {x y : pSet} (h_neq : ¬ pSet.equiv x y) :\n  (∃ a : x.type, ∀ a' : y.type, ¬ pSet.equiv (x.func a) (y.func a')) ∨\n  (∃ a' : y.type, ∀ a : x.type, ¬ pSet.equiv (x.func a) (y.func a')) :=\nbegin\n  cases x, cases y, unfold equiv, safe,\n  suffices : equiv (mk x_α x_A) (mk y_α y_A), by contradiction,\n  constructor; assumption\nend\n\nend pSet\n\n\n/- A 𝔹-valued model of ZFC -/\n\n-- τ is a B-name if and only if τ is a set of pairs of the form ⟨σ, b⟩, where σ is\n-- a B-name and b ∈ B.\ninductive bSet (𝔹 : Type u) [complete_boolean_algebra 𝔹] : Type (u+1)\n| mk (α : Type u) (A : α → bSet) (B : α → 𝔹) : bSet\n\nnamespace bSet\nvariables {𝔹 : Type u} [nontrivial_complete_boolean_algebra 𝔹]\n\nnoncomputable instance decidable_eq_𝔹 : decidable_eq 𝔹 := λ _ _, classical.prop_decidable _\n\nrun_cmd mk_simp_attr `cleanup\n\n/-- The underlying type of a bSet -/\n@[simp, cleanup]def type : bSet 𝔹 → Type u\n| ⟨α, _, _⟩ := α\n\n@[simp, cleanup]lemma type_infi {α : Type*} {A : α → bSet 𝔹} {B C : α → 𝔹} : (⨅(a : type (mk α A B)), C a) = ⨅(a : α), C a := rfl\n\n@[simp, cleanup]lemma type_supr {α : Type*} {A : α → bSet 𝔹} {B C : α → 𝔹} : (⨆(a : type (mk α A B)), C a) = ⨆(a : α), C a := rfl\n\n/-- The indexing function of a bSet -/\n@[simp, cleanup]def func : ∀ x : bSet 𝔹, x.type → bSet 𝔹\n| ⟨_, A, _⟩ := A\n\n/-- The boolean truth-value function of a bSet -/\n@[simp, cleanup]def bval : ∀ x : bSet 𝔹, x.type → 𝔹\n| ⟨_, _, B⟩ := B\n\n@[simp, cleanup]def mk_type_func_bval : ∀ x : bSet 𝔹, mk x.type x.func x.bval = x :=\n  λ x, by cases x; refl\n\ndef empty : bSet 𝔹 :=\n  ⟨ulift empty, empty.elim ∘ ulift.down, empty.elim ∘ ulift.down⟩\n\ninstance nonempty_bSet : nonempty $ @bSet 𝔹 _ :=\n  ⟨empty⟩\n\ninstance has_empty_bSet : has_emptyc (bSet 𝔹) := ⟨empty⟩\n\n@[simp]lemma forall_over_empty (ϕ : (type (∅ : bSet 𝔹)) → 𝔹) : (⨅a, ϕ a) = ⊤ :=\n  by {apply top_unique, bv_intro a, repeat{cases a}}\n\n@[simp]lemma exists_over_empty (ϕ : (type (∅ : bSet 𝔹)) → 𝔹) : (⨆a, ϕ a) = ⊥ :=\n by {apply bot_unique, apply bv_Or_elim, intro i, repeat{cases i}}\n\n/-- Two Boolean-valued pre-sets are extensionally equivalent if every\nelement of the first family is extensionally equivalent to\n  some element of the second family and vice-versa. -/\ndef bv_eq : ∀ (x y : bSet 𝔹), 𝔹\n| ⟨α, A, B⟩ ⟨α', A', B'⟩ :=\n             (⨅a : α, B a ⟹ ⨆a', B' a' ⊓ bv_eq (A a) (A' a')) ⊓\n               (⨅a' : α', B' a' ⟹ ⨆a, B a ⊓ bv_eq (A a) (A' a'))\n\ninfix ` =ᴮ `:79 := bv_eq\n\n-- note: for every Γ : 𝔹, λ x y, Γ ≤ x =ᴮ y is an equivalence relation\n\ndef bv_eq' (Γ : 𝔹) : bSet 𝔹 → bSet 𝔹 → Prop := λ x y, Γ ≤ x=ᴮ y\n\nexample : (@bv_eq 𝔹 _) (empty) (empty) = ⊤ :=\n  by unfold empty bv_eq;\n  {simp only [lattice.inf_eq_top_iff, lattice.infi_eq_top], fsplit; intros i; cases i; cases i}\n\nopen lattice\n\n@[simp]theorem bv_eq_refl : ∀ x, @bv_eq 𝔹 _ x x = ⊤ :=\nbegin\n  intro x, induction x, simp[bv_eq, -imp_top_iff_le], split; intros;\n  {apply top_unique, simp only [lattice.top_le_iff, lattice.imp_top_iff_le],\n    apply le_supr_of_le i, have := x_ih i, simp[this]}\nend\n\n@[simp]lemma bv_refl {Γ : 𝔹} {x} : Γ ≤ x =ᴮ x := le_trans le_top (by simp)\n\n@[simp]lemma bv_eq_top_of_eq {x y : bSet 𝔹} (h_eq : x = y) : x =ᴮ y = ⊤ :=\nby simp*\n\n/- empty' is the singleton bSet {⟨∅, ⊥⟩}, i.e. a set whose only member is ∅ which has\n   a zero probability of actually being an element. It should be equivalent to ∅. -/\n@[reducible]def empty' : bSet 𝔹 := mk punit (λ _, ∅) (λ _, ⊥)\n\nexample : empty =ᴮ empty = (⊤ : 𝔹) := by simp\n\nexample : ⊤ ≤ empty =ᴮ (empty' : bSet 𝔹) :=\nby simp[empty, empty', bv_eq]; exact dec_trivial\n\n/-- `x ∈ y` as Boolean-valued pre-sets if `x` is extensionally equivalent to a member\n  of the family `y`. -/\ndef mem : bSet 𝔹 → bSet 𝔹 → 𝔹\n| a (mk α' A' B') := ⨆a', B' a' ⊓ a =ᴮ A' a'\n\n@[reducible]def empty'' : bSet 𝔹 :=\n  mk (ulift bool) (λ x, ∅) (λ x, by {repeat{cases x}, exact ⊥, exact ⊤})\n\ninfix ` ∈ᴮ `:80 := mem\n\nlemma mem_unfold {u v : bSet 𝔹} : u ∈ᴮ v = ⨆(i : v.type), v.bval i ⊓ u =ᴮ v.func i :=\nby cases v; simp[mem,bv_eq]\n\n/-- ∅ appears in empty'' with probability 0 and 1, with the higher probability winning the\n    vote of membership. This demonstrates why the inequality in the following theorem is\n    necessary. -/\nexample : ∅ ∈ᴮ empty'' = (⊤ : 𝔹) :=\n  by {apply top_unique, apply le_supr_of_le ⊤, swap, exact ⟨⟨(tt)⟩⟩, simp}\n\ntheorem mem.mk {α : Type*} (A : α → bSet 𝔹) (B : α → 𝔹) (a : α) : B a ≤ A a ∈ᴮ mk α A B :=\n  le_supr_of_le a $ by simp\n\ntheorem mem.mk' (x : bSet 𝔹) (a : x.type) : x.bval a ≤ x.func a ∈ᴮ x :=\nby cases x; from mem.mk _ _ _\n\n-- the Γ-generalized version of mem.mk uses two primes because mem.mk' already existed\n@[simp]theorem mem.mk'' {x : bSet 𝔹} {a : x.type} {Γ} : Γ ≤ x.bval a → Γ ≤ x.func a ∈ᴮ x :=\nposet_yoneda_inv Γ (mem.mk' x a)\n\n@[reducible]protected def subset : bSet 𝔹 → bSet 𝔹 → 𝔹\n| (mk α A B) b := ⨅a:α, B a ⟹ (A a ∈ᴮ b)\n\ninfix ` ⊆ᴮ `:80 := bSet.subset\n\nlemma subset_unfold {x u : bSet 𝔹} : x ⊆ᴮ u = (⨅(j : x.type), x.bval j ⟹ x.func j ∈ᴮ u) :=\nby induction x; dsimp[bSet.subset]; congr\n\n@[simp]protected def insert : bSet 𝔹 → 𝔹 → bSet 𝔹 → bSet 𝔹\n| u b ⟨α, A, B⟩ := ⟨option α, λo, option.rec u A o, λo, option.rec b B o⟩\n\nprotected def insert' : bSet 𝔹 → 𝔹 → bSet 𝔹 → bSet 𝔹\n| u b ⟨α, A, B⟩ := ⟨unit ⊕ α, λ o, sum.rec (λ_, u) A o, λ o, sum.rec (λ_, b) B o⟩\n\n@[reducible]protected def insert1 : bSet 𝔹 → bSet 𝔹 → bSet 𝔹\n| u v := bSet.insert u ⊤ v\n\nlemma insert1_unfold {u v : bSet 𝔹} :\n  bSet.insert1 u v = ⟨option v.type, λo, option.rec u v.func o, λ o, option.rec ⊤ v.bval o⟩ :=\nby {induction v, simp[bSet.insert1]}\n\n-- @[simp]lemma insert1_type {u v : bSet 𝔹} : (bSet.insert1 u v).type = option v.type := by simp[insert1_unfold]\n\ninstance insert_bSet : has_insert (bSet 𝔹) (bSet 𝔹) :=\n  ⟨λ u v, bSet.insert1 u v⟩\n\n@[simp]lemma insert_unfold {y z : bSet 𝔹} : insert y z = bSet.insert y ⊤ z :=\n  by refl\n\n@[simp]theorem mem_insert {x y z : bSet 𝔹} {b : 𝔹} :\n  x ∈ᴮ bSet.insert y b z = (b ⊓ x =ᴮ y) ⊔ x ∈ᴮ z :=\n  by induction y; induction z; simp[bv_eq,mem]\n\n@[simp]theorem mem_insert1 {x y z : bSet 𝔹} : x ∈ᴮ insert y z = x =ᴮ y ⊔ x ∈ᴮ z :=\n  by simp\n\n@[simp]theorem mem_insert1' { x y z : bSet 𝔹 } { Γ : 𝔹 } : Γ ≤ x ∈ᴮ insert y z ↔ Γ ≤ x =ᴮ y ⊔ x ∈ᴮ z :=\nby simp\n\n-- example : {∅} =ᴮ empty'' = (⊤ : 𝔹) :=\n-- begin\n--   simp[empty'', singleton, insert, has_insert.insert,mem,bv_eq],\n--   simp[has_emptyc.emptyc, empty,bSet.insert1],\n--   refine ⟨_, by intro i; repeat{cases i}⟩, apply top_unique,\n--  have : ⊤ = (ulift.rec (bool.rec ⊥ ⊤) : ulift bool → 𝔹) (ulift.up tt),\n--    by refl,\n--  rw[this], apply le_supr\n-- end\n\ntheorem bv_eq_symm {x y : bSet 𝔹} : x =ᴮ y = y =ᴮ x :=\nbegin\n  induction x with α A B generalizing y, induction y with α' A' B',\n  suffices : ∀ a : α, ∀ a' : α', A' a' =ᴮ A a = A a =ᴮ A' a',\n    by {simp[bv_eq, this, inf_comm]}, from λ _ _, by simp[x_ih ‹α›]\nend\n\ntheorem bv_eq_unfold (x y : bSet 𝔹) :\n  x =ᴮ y = (⨅(a : x.type), x.bval a ⟹ (x.func a ∈ᴮ y))\n          ⊓ (⨅(a' : y.type), (y.bval a' ⟹ (y.func a' ∈ᴮ x))) :=\n by induction x; induction y; simp[mem,bv_eq,bv_eq_symm]\n\ntheorem bSet_axiom_of_extensionality (x y : bSet 𝔹) :\n(⨅(z : bSet 𝔹), (z ∈ᴮ x ⟹ z ∈ᴮ y) ⊓ (z ∈ᴮ y ⟹ z ∈ᴮ x)) ≤ x =ᴮ y :=\nbegin\n  rw[bv_eq_unfold],\n  apply le_inf; apply le_infi; intro i,\n  {fapply infi_le_of_le (x.func i), apply inf_le_left_of_le,\n   induction x, unfold mem, simp only with cleanup,\n   by apply imp_le_of_left_le; apply le_supr_of_le i;\n   exact le_inf (by refl) (by rw[bv_eq_refl]; apply le_top)},\n  {fapply infi_le_of_le (y.func i), apply inf_le_right_of_le,\n   induction y, unfold mem, simp only with cleanup,\n   by apply imp_le_of_left_le; apply le_supr_of_le i;\n   exact le_inf (by refl) (by rw[bv_eq_refl]; apply le_top)},\nend\n\nlemma eq_of_subset_subset (x y : bSet 𝔹) : x ⊆ᴮ y ⊓ y ⊆ᴮ x ≤ x =ᴮ y :=\nbegin\n  simp[subset_unfold, bv_eq_unfold], tidy;\n  [apply inf_le_left_of_le, apply inf_le_right_of_le]; apply bv_specialize i; refl\nend\n\nlemma subset_subset_of_eq (x y : bSet 𝔹) : x =ᴮ y ≤ x ⊆ᴮ y ⊓ y ⊆ᴮ x :=\nbegin\n  simp[subset_unfold, bv_eq_unfold], tidy;\n  [apply inf_le_left_of_le, apply inf_le_right_of_le]; apply bv_specialize i; refl\nend\n\ntheorem eq_iff_subset_subset {x y : bSet 𝔹} : x =ᴮ y = x ⊆ᴮ y ⊓ y ⊆ᴮ x :=\nby apply le_antisymm; [apply subset_subset_of_eq, apply eq_of_subset_subset]\n\nlemma subset_subset_of_eq' {x y : bSet 𝔹} {Γ} (H : Γ ≤ x =ᴮ y) : Γ ≤ x ⊆ᴮ y ∧ Γ ≤ y ⊆ᴮ x :=\nby {rw[eq_iff_subset_subset] at H, bv_split, exact ⟨‹_›,‹_›⟩}\n\nlemma subset_of_eq {x y} {Γ : 𝔹} (H : Γ ≤ x =ᴮ y) : Γ ≤ x ⊆ᴮ y :=\n(subset_subset_of_eq' H).left\n\n@[simp]lemma subset_self {x : bSet 𝔹} {Γ : 𝔹} : Γ ≤ x ⊆ᴮ x :=\nby { apply le_trans, apply le_top,\n     rw[show ⊤ = x =ᴮ x, by simp[bv_eq_refl]], rw[eq_iff_subset_subset], exact inf_le_left }\n\ntheorem subset_ext {x y : bSet 𝔹} {Γ : 𝔹} (h₁ : Γ ≤ x ⊆ᴮ y) (h₂ : Γ ≤ y ⊆ᴮ x) : Γ ≤ x =ᴮ y :=\nbegin\n  apply bv_have h₂, rw[deduction], apply bv_have h₁, rw[<-deduction],\n  ac_change Γ ⊓ (x ⊆ᴮ y ⊓ y ⊆ᴮ x) ≤ x =ᴮ y, apply inf_le_right_of_le,\n  apply eq_of_subset_subset\nend\n\ntheorem bv_eq_trans {x y z : bSet 𝔹} : (x =ᴮ y ⊓ y =ᴮ z) ≤ x =ᴮ z :=\nbegin\n    induction x with α A B generalizing y z,\n    cases y with α' A' B',\n    induction z with α'' A'' B'',\n    have H1 : ∀ a : α, ∀ a' : α', ∀ a'' : α'',\n           (((A a =ᴮ A' a') ⊓ (A' a' =ᴮ A'' a'')) ⊓ B'' a'') ≤ (A a =ᴮ A'' a'' ⊓ B'' a''),\n      by {intros a a' a'', refine inf_le_inf _ (by refl), exact @x_ih a (A' a') (A'' a'')},\n    have H2 : ∀ i'' : α'', ∀ a' : α', ∀ a : α,\n           A'' i'' =ᴮ A' a' ⊓ A' a' =ᴮ A a ⊓ B a ≤ A'' i'' =ᴮ A a ⊓ B a,\n      by {intros a'' a' a, refine inf_le_inf _ (by refl),\n        convert @x_ih a (A' a') (A'' a'') using 1; simp[bv_eq_symm], ac_refl},\n    apply le_inf,\n      {bv_intro i, apply deduction.mp,\n        change _ ≤ (A i) ∈ᴮ ⟨α'', A'', B''⟩,\n       have this1 : ⟨α, A, B⟩ =ᴮ ⟨α', A', B'⟩ ⊓ B i ≤ A i ∈ᴮ ⟨α', A', B'⟩,\n       by  {rw[deduction], from inf_le_left_of_le (infi_le _ _)},\n       suffices : A i ∈ᴮ ⟨α', A', B'⟩ ⊓ ⟨α', A', B'⟩ =ᴮ ⟨α'', A'', B''⟩ ≤ A i ∈ᴮ ⟨α'', A'', B''⟩,\n         by {have := le_trans (inf_le_inf this1 (by refl)) this,\n              convert this using 1, ac_refl },\n       suffices : ∀ a', ⟨α', A', B'⟩ =ᴮ ⟨α'', A'', B''⟩ ⊓ A i =ᴮ A' a' ⊓ B' a' ≤ A i ∈ᴮ ⟨α'', A'', B''⟩,\n         by {convert (supr_le this) using 1, simp[mem, inf_comm, inf_supr_eq],\n            congr, ext, ac_refl},\n       have this2 : ∀ a', ⟨α', A', B'⟩ =ᴮ ⟨α'', A'', B''⟩ ⊓ B' a' ≤ A' a' ∈ᴮ ⟨α'', A'', B''⟩,\n         by {intro a', rw[deduction], apply inf_le_left_of_le, apply infi_le},\n       suffices : ∀ a', A i =ᴮ A' a' ⊓ A' a' ∈ᴮ ⟨α'', A'', B''⟩ ≤ A i ∈ᴮ ⟨α'', A'', B''⟩,\n         by {intro a', have := le_trans (inf_le_inf (by refl) (this2 a')) (this a'),\n         convert this using 1, ac_refl},\n       intro a', erw[inf_supr_eq], apply supr_le, intro a'',\n       conv {to_lhs, congr, skip, rw[inf_comm]},\n       suffices : A i =ᴮ A' a' ⊓ (A' a' =ᴮ A'' a'' ⊓ B'' a'')\n         = A i =ᴮ A' a' ⊓ A' a' =ᴮ A'' a'' ⊓ B'' a'',\n         by {rw[this], clear this, apply le_trans, exact (H1 i a' a''),\n         apply le_supr_of_le a'', rw[inf_comm]},\n       ac_refl},\n      {bv_intro i'', apply deduction.mp,\n        conv {to_rhs, congr, funext, rw[bv_eq_symm]}, change _ ≤ (A'' i'') ∈ᴮ ⟨α, A, B⟩,\n        have this1 : ⟨α'', A'', B''⟩ =ᴮ ⟨α', A', B'⟩ ⊓ B'' i'' ≤ A'' i'' ∈ᴮ ⟨α', A', B'⟩,\n          by {rw[deduction], apply inf_le_left_of_le, apply infi_le},\n        suffices : A'' i'' ∈ᴮ ⟨α', A', B'⟩ ⊓ ⟨α', A', B'⟩ =ᴮ ⟨α, A, B⟩ ≤ A'' i'' ∈ᴮ ⟨α, A, B⟩,\n         by {have := le_trans (inf_le_inf this1 (by refl)) this,\n              convert this using 1, simp[bv_eq_symm], ac_refl},\n        suffices : ∀ a', ⟨α', A', B'⟩ =ᴮ ⟨α, A, B⟩ ⊓ A'' i'' =ᴮ A' a' ⊓ B' a' ≤ A'' i'' ∈ᴮ ⟨α, A, B⟩,\n          by {convert (supr_le this) using 1, simp[mem, inf_comm, inf_supr_eq],\n            congr, ext, ac_refl},\n        have this2 : ∀ a', ⟨α', A', B'⟩ =ᴮ ⟨α, A, B⟩ ⊓ B' a' ≤ A' a' ∈ᴮ ⟨α, A, B⟩,\n          by {intro a', rw[deduction], apply inf_le_left_of_le, apply infi_le},\n        suffices : ∀ a', A'' i'' =ᴮ A' a' ⊓ A' a' ∈ᴮ ⟨α, A, B⟩ ≤ A'' i'' ∈ᴮ ⟨α, A, B⟩,\n          by {intro a', have := le_trans (inf_le_inf (by refl) (this2 a')) (this a'),\n         convert this using 1, ac_refl},\n        intro a', erw[inf_supr_eq], apply supr_le, intro a,\n        conv {to_lhs, congr, skip, rw[inf_comm]},\n        suffices : A'' i'' =ᴮ A' a' ⊓ (A' a' =ᴮ A a ⊓ B a)\n          = A'' i'' =ᴮ A' a' ⊓ A' a' =ᴮ A a ⊓ B a,\n          by {rw[this], clear this, apply le_trans, exact (H2 i'' a' a),\n          apply le_supr_of_le a, rw[inf_comm]},\n        ac_refl}\nend\n\nlemma bv_trans {Γ : 𝔹} {a₁ a₂ a₃ : bSet 𝔹} (H₁ : Γ ≤ a₁ =ᴮ a₂) (H₂ : Γ ≤ a₂ =ᴮ a₃) :\n  Γ ≤ a₁ =ᴮ a₃ :=\nle_trans (le_inf_iff.mpr ⟨H₁,H₂⟩) bv_eq_trans\n\n@[symm]lemma bv_symm {Γ} {x y : bSet 𝔹} (H : Γ ≤ x =ᴮ y) : Γ ≤ y =ᴮ x := by rwa[bv_eq_symm]\n\nlemma bv_rw {x y : bSet 𝔹} (H : x =ᴮ y = ⊤) (ϕ : bSet 𝔹 → 𝔹) {h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y} : ϕ y = ϕ x :=\nbegin\n  apply le_antisymm, swap, rw[show ϕ x = ϕ x ⊓ ⊤, by simp], rw[<-H, inf_comm], apply h_congr,\n  rw[show ϕ y = ϕ y ⊓ ⊤, by simp], rw[<-H, inf_comm, bv_eq_symm], apply h_congr\nend\n\n/-- If u = v and u ∈ w, then this implies that v ∈ w -/\nlemma subst_congr_mem_left {u v w : bSet 𝔹} : u =ᴮ v ⊓ u ∈ᴮ w ≤ v ∈ᴮ w :=\nbegin\n  simp only [mem_unfold], tidy_context,\n  bv_cases_at a_right i, apply bv_use i, bv_split,\n  from le_inf ‹_› (bv_trans (bv_symm ‹_›) ‹_›)\nend\n\n-- to derive primed versions of lemmas, use poset_yoneda_inv\n@[simp]lemma subst_congr_mem_left' {Γ : 𝔹} {u v w : bSet 𝔹} : Γ ≤ u =ᴮ v → Γ ≤ u ∈ᴮ w → Γ ≤ v ∈ᴮ w :=\n  λ _ _, poset_yoneda_inv _ subst_congr_mem_left $ le_inf ‹_› ‹_›\n\n-- example {u v w : bSet 𝔹} : u =ᴮ v ⊓ u ∈ᴮ w ≤ v ∈ᴮ w :=\n-- begin\n--   simp only [mem_unfold], tidy_context,\n--   bv_cases_at a_right i, apply bv_use i, bv_split, refine le_inf ‹_› _,\n--   from bv_trans (bv_symm a_left) ‹_›\n-- end\n\n/-- If v = w and u ∈ v, then this implies that u ∈ w -/\nlemma subst_congr_mem_right {u v w : bSet 𝔹} : (v =ᴮ w ⊓ u ∈ᴮ v) ≤ u ∈ᴮ w :=\nbegin\n  induction v, erw[inf_supr_eq], apply supr_le, intro i,\n  suffices : mk v_α ‹_› ‹_› =ᴮ w ⊓ v_B i ≤ v_A i ∈ᴮ w,\n  have := le_trans (inf_le_inf this (by refl : u =ᴮ v_A i ≤ u =ᴮ v_A i)) _,\n  rw[<-inf_assoc], convert this using 1,\n  rw[bv_eq_symm, inf_comm], apply subst_congr_mem_left,\n  rw[deduction], cases w, apply inf_le_left_of_le, apply infi_le\nend\n\n@[simp]lemma subst_congr_mem_right' {Γ : 𝔹} {u v w : bSet 𝔹} : Γ ≤ w =ᴮ v → Γ ≤ u ∈ᴮ w → Γ ≤ u ∈ᴮ v :=\n  λ _ _, poset_yoneda_inv _ subst_congr_mem_right $ le_inf ‹_› ‹_›\n\n/- Use rw[bounded_forall] and rw[bounded_exists] to pass from restricted quantifiers to the FOL interpretation of the quantifiers -/\nlemma bounded_forall {v : bSet 𝔹} {ϕ : bSet 𝔹 → 𝔹 } {h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y} :\n  (⨅(i_x : v.type), (v.bval i_x ⟹ ϕ (v.func i_x))) = (⨅(x : bSet 𝔹), x ∈ᴮ v ⟹ ϕ x)  :=\nbegin\n  apply le_antisymm,\n    {bv_intro x, cases v, simp only with cleanup, erw[supr_imp_eq],\n     bv_intro i_y, apply infi_le_of_le i_y,\n     rw[<-deduction,<-inf_assoc], apply le_trans, apply inf_le_inf,\n     apply bv_imp_elim, refl, rw[inf_comm, bv_eq_symm], apply h_congr},\n         {bv_intro i_x', apply infi_le_of_le (func v i_x'), apply imp_le_of_left_le,\n     cases v, simp only with cleanup, apply le_supr_of_le i_x',\n       apply le_inf, refl, rw[bv_eq_refl], apply le_top}\nend\n\nlemma bounded_exists {v : bSet 𝔹} {ϕ : bSet 𝔹 → 𝔹} {h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y} :\n  (⨆(i_x : v.type), (v.bval i_x ⊓ ϕ(v.func i_x))) = (⨆(x : bSet 𝔹), x ∈ᴮ v ⊓ ϕ x) :=\nbegin\n  apply le_antisymm,\n    {apply bv_Or_elim, intro i_x, apply bv_use (v.func i_x),\n      apply inf_le_inf, apply mem.mk', refl},\n    {apply bv_Or_elim, intro x, simp only [mem_unfold],\n      apply bv_cases_left, intro i_x, apply bv_use i_x,\n      ac_change bval v i_x ⊓ (x =ᴮ func v i_x ⊓ ϕ x) ≤ bval v i_x ⊓ ϕ (func v i_x),\n      apply inf_le_inf, refl, apply h_congr}\nend\n\n-- foo_unfold' means that the definition foo will be unfolded using global quantifiers\nlemma mem_unfold' {u v : bSet 𝔹} : u ∈ᴮ v = ⨆z, z ∈ᴮ v ⊓ u =ᴮ z :=\nby {rw[<-bounded_exists, mem_unfold], intros x y,\n    ac_change y =ᴮ x ⊓ x =ᴮ u ≤ y =ᴮ u,\n    simp[bv_eq_symm], exact bv_eq_symm, exact bv_eq_trans }\n\nlemma subset_unfold' {x u : bSet 𝔹} : x ⊆ᴮ u = ⨅(w : bSet 𝔹), w ∈ᴮ x ⟹ w ∈ᴮ u :=\nbegin\n  simp only [subset_unfold], have := @bounded_forall 𝔹 _ x (λ y, y∈ᴮ u),\n  dsimp at this, rw[this], intros, apply subst_congr_mem_left\nend\n\nlemma bv_eq_unfold' {x y : bSet 𝔹} : x =ᴮ y = (⨅ z, z ∈ᴮ x ⟹ z ∈ᴮ y) ⊓ (⨅ z, z ∈ᴮ y ⟹ z ∈ᴮ x) :=\nbegin\n  rw eq_iff_subset_subset, rw [subset_unfold', subset_unfold']\nend\n\ntheorem mem_ext {x y : bSet 𝔹} {Γ : 𝔹} (h₁ : Γ ≤ ⨅z, z ∈ᴮ x ⟹ z ∈ᴮ y) (h₂ : Γ ≤ ⨅z, z ∈ᴮ y ⟹ z ∈ᴮ x) : Γ ≤ x =ᴮ y :=\nby {[smt] eblast_using [subset_ext, subset_unfold']}\n\n@[simp]lemma subset_self_eq_top {x : bSet 𝔹} : x ⊆ᴮ x = ⊤ :=\ntop_unique subset_self\n\nlemma subset_trans {x y z : bSet 𝔹} : x ⊆ᴮ y ⊓ y ⊆ᴮ z ≤ x ⊆ᴮ z :=\nbegin\n  simp[subset_unfold'], intro i_z, apply bv_specialize_left i_z,\n  apply bv_specialize_right i_z, rw[<-deduction],\n  ac_change (i_z ∈ᴮ x ⟹ i_z ∈ᴮ y)  ⊓ i_z ∈ᴮ x ⊓ (i_z ∈ᴮ y ⟹ i_z ∈ᴮ z) ≤ i_z ∈ᴮ z,\n  rw[deduction], let H := _, change ((H ⟹ _) ⊓ H : 𝔹) ≤ _,\n  apply le_trans, apply bv_imp_elim, rw[<-deduction], rw[inf_comm],\n  apply le_trans, apply bv_imp_elim, refl\nend\n\nlemma subset_trans' {x y z : bSet 𝔹} {Γ : 𝔹} (H₁ : Γ ≤ x ⊆ᴮ y) (H₂ : Γ ≤ y ⊆ᴮ z) : Γ ≤ x ⊆ᴮ z :=\nposet_yoneda_inv Γ subset_trans $ le_inf ‹_› ‹_›\n\n-- lemma subset_trans_context {x y z : bSet 𝔹} {c : 𝔹} {h₁ : c ≤ x ⊆ᴮ y} {h₂ : c ≤ y ⊆ᴮ z} : c ≤ x ⊆ᴮ z :=\n-- begin\n--   apply bv_have h₂, rw[deduction], apply bv_have h₁, rw[<-deduction],\n--   ac_change c ⊓ (x ⊆ᴮ y ⊓ y ⊆ᴮ z) ≤ x ⊆ᴮ z, apply inf_le_right_of_le,\n--   apply subset_trans\n-- end\n\n-- TODO(jesse): mark this as simp\nlemma mem_of_mem_subset {x y z : bSet 𝔹} {Γ} (H₂ : Γ ≤ y ⊆ᴮ z) (H₁ : Γ ≤ x ∈ᴮ y) : Γ ≤ x ∈ᴮ z :=\nby {rw[subset_unfold'] at H₂, from H₂ x ‹_›}\n\n-- lemma bounded_forall' {ϕ : bSet 𝔹 → 𝔹 } {h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y} {v : bSet 𝔹} :\n--   (⨅(i_x : v.type), (v.bval i_x ⟹ ϕ (v.func i_x))) = (⨅(x : bSet 𝔹), x ∈ᴮ v ⟹ ϕ x)  :=\n-- begin\n--   apply le_antisymm,\n--     {bv_intro x, cases v, simp, rw[supr_imp_eq],\n--      bv_intro i_y, apply infi_le_of_le i_y,\n--      rw[<-deduction,<-inf_assoc], apply le_trans, apply inf_le_inf,\n--      apply bv_imp_elim, refl, rw[inf_comm, bv_eq_symm], apply h_congr},\n--          {bv_intro i_x', apply infi_le_of_le (func v i_x'), apply imp_le_of_left_le,\n--      cases v, simp, apply le_supr_of_le i_x',\n--        apply le_inf, refl, rw[bv_eq_refl], apply le_top}\n-- end\n\nlemma subst_congr_subset_left {x v u} : ((v ⊆ᴮ u) ⊓ (x =ᴮ v) : 𝔹) ≤ (x ⊆ᴮ u) :=\nbegin\n  simp only [subset_unfold],\n  have H₁ := @bounded_forall _ _ v (λ x, x ∈ᴮ u)\n    (by {intros, apply subst_congr_mem_left}),\n  have H₂ := @bounded_forall _ _ x (λ x, x ∈ᴮ u)\n    (by {intros, apply subst_congr_mem_left}),\n  rw[H₁, H₂], dsimp, bv_intro z, rw[deduction],\n  apply infi_le_of_le z, rw[<-deduction, <-deduction], rw[inf_assoc],\n  apply le_trans, apply inf_le_inf, refl, apply subst_congr_mem_right,\n  apply bv_imp_elim -- todo write tactics to make these calculations easier\nend\n\nlemma subst_congr_subset_right {x v u} : ((v ⊆ᴮ u) ⊓ (u =ᴮ x) : 𝔹) ≤ (v ⊆ᴮ x) :=\nbegin\n  simp only [subset_unfold], bv_intro j, apply bv_specialize_left j,\n  rw[<-deduction], ac_change ((bval v j ⟹ func v j ∈ᴮ u) ⊓ bval v j) ⊓  u =ᴮ x ≤ func v j ∈ᴮ x,\n  rw[deduction], apply le_trans, apply bv_imp_elim, rw[<-deduction, inf_comm],\n  apply subst_congr_mem_right\nend\n\n-- use `apply bv_rw' (H : Γ ≤ x =ᴮ y)` for rewriting the `x` to `y` in the goal\n-- if Lean is able to infer the motive, this will generate a B_ext proof obligation which will usually be `by simp`\nlemma bv_rw'₀ {x y : bSet 𝔹} {Γ : 𝔹} (H : Γ ≤ x =ᴮ y) {ϕ : bSet 𝔹 → 𝔹} {h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y} {H_new : Γ ≤ ϕ y} : Γ ≤ ϕ x :=\nbegin\n  have : Γ ≤ y =ᴮ x ⊓ ϕ y,\n    by {apply le_inf, rw[bv_eq_symm], from ‹_›, from ‹_›},\n  from (poset_yoneda_inv _ (h_congr _ _) this)\nend\n\n-- TODO(jesse) maybe replace this with typeclasses instead?\n@[reducible]def B_ext (ϕ : bSet 𝔹 → 𝔹) : Prop :=\n  ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y\n\n-- use `apply bv_rw' (H : Γ ≤ x =ᴮ y)` for rewriting the `x` to `y` in the goal\n-- if Lean is able to infer the motive, this will generate a B_ext proof obligation which will usually be `by simp`\nlemma bv_rw' {x y : bSet 𝔹} {Γ : 𝔹} (H : Γ ≤ x =ᴮ y) {ϕ : bSet 𝔹 → 𝔹} {h_congr : B_ext ϕ} {H_new : Γ ≤ ϕ y} : Γ ≤ ϕ x :=\nby apply bv_rw'₀; from ‹_›\n\n@[simp]lemma B_ext_bv_eq_left {y : bSet 𝔹} : B_ext (λ x, x =ᴮ y) :=\nby {unfold B_ext, intros, rw[bv_eq_symm], apply bv_eq_trans}\n\n@[simp]lemma B_ext_bv_eq_right {x : bSet 𝔹} : B_ext (λ y, x =ᴮ y) :=\nby {unfold B_ext, intros, rw[inf_comm], apply bv_eq_trans}\n\n@[simp]lemma B_ext_mem_left {y : bSet 𝔹} : B_ext (λ x, x ∈ᴮ y) :=\nby unfold B_ext; intros; apply subst_congr_mem_left\n\n@[simp]lemma B_ext_mem_right {x : bSet 𝔹} : B_ext (λ y, x ∈ᴮ y) :=\nby unfold B_ext; intros; apply subst_congr_mem_right\n\n@[simp]lemma B_ext_subset_left {y : bSet 𝔹} : B_ext (λ x, x ⊆ᴮ y) :=\nby {unfold B_ext, intros, rw[inf_comm, bv_eq_symm], apply subst_congr_subset_left}\n\n@[simp]lemma B_ext_subset_right {x : bSet 𝔹} : B_ext (λ y, x ⊆ᴮ y) :=\nby {unfold B_ext, intros, rw[inf_comm], apply subst_congr_subset_right}\n\n@[simp]lemma B_ext_sup {ϕ₁ ϕ₂ : bSet 𝔹 → 𝔹} {h₁ : B_ext ϕ₁} {h₂ : B_ext ϕ₂} :\n  B_ext (λ x, ϕ₁ x ⊔ ϕ₂ x) :=\nbegin\n  intros x y, dsimp, rw[inf_comm, deduction], apply bv_or_elim;\n  apply bv_imp_intro; [apply le_sup_left_of_le, apply le_sup_right_of_le];\n  rw[inf_comm]; [apply h₁, apply h₂]\nend\n\n@[simp]lemma B_ext_inf {ϕ₁ ϕ₂ : bSet 𝔹 → 𝔹} (h₁ : B_ext ϕ₁) (h₂ : B_ext ϕ₂) :\n  B_ext (λ x, ϕ₁ x ⊓ ϕ₂ x) :=\nbegin\n  intros x y, tidy_context, refine ⟨_,_⟩,\n    { apply bv_rw' (bv_symm a_left); from ‹_› },\n    { apply bv_rw' (bv_symm a_left); from ‹_› }\nend\n\n@[simp]lemma B_ext_imp {ϕ₁ ϕ₂ : bSet 𝔹 → 𝔹} {h₁ : B_ext ϕ₁} {h₂ : B_ext ϕ₂} :\n  B_ext (λ x, ϕ₁ x ⟹ ϕ₂ x) :=\nbegin\n  intros x y, rw[<-deduction],\n  tidy_context, apply bv_rw' (bv_symm a_left_left), from ‹_›,\n  refine a_left_right _, apply bv_rw' a_left_left; from ‹_›\nend\n\n@[simp]lemma B_ext_const {b : 𝔹} : B_ext (λ x, b) :=\nby tidy\n\n@[simp]lemma B_ext_neg {ϕ₁ : bSet 𝔹 → 𝔹} {h : B_ext ϕ₁} : B_ext (λ x, - ϕ₁ x) :=\nby {simp only [imp_bot.symm], apply B_ext_imp, simpa, from B_ext_const}\n\n@[simp]lemma B_ext_infi {ι : Type*} {Ψ : ι → (bSet 𝔹 → 𝔹)} {h : ∀ i, B_ext $ Ψ i} : B_ext (λ x, ⨅i, Ψ i x) :=\nby {intros x y, dsimp, bv_intro i, apply bv_specialize_right i, apply h}\n\n@[simp]lemma B_ext_supr {ι : Type*} {ψ : ι → (bSet 𝔹 → 𝔹)} {h : ∀i, B_ext $ ψ i} : B_ext (λ x, ⨆i, ψ i x) :=\nby {intros x y, dsimp, apply bv_cases_right, intro i, apply bv_use i, apply h}\n\nexample {y : bSet 𝔹} : B_ext (λ x : bSet 𝔹, x ∈ᴮ y ⊔ y ∈ᴮ x) := by change B_ext _; simp\n\n@[reducible]def B_congr (t : bSet 𝔹 → bSet 𝔹) : Prop := ∀ {x₁ x₂}, ∀ {Γ : 𝔹}, Γ ≤ x₁ =ᴮ x₂ → Γ ≤ t x₁ =ᴮ t x₂\n\nmeta def H_congr_handler : tactic unit := `[simp]\n\n@[simp]lemma B_ext_term (ϕ : bSet 𝔹 → 𝔹) (t : bSet 𝔹 → bSet 𝔹) (H : B_ext ϕ . H_congr_handler) (H' : B_congr t . H_congr_handler) :\n  B_ext (λ z, ϕ ((λ w, t w) z) ) :=\nbegin\n  intros x y, tidy_context,\n  suffices : Γ ≤ t x =ᴮ t y,\n    by {apply bv_rw' (bv_symm this), from ‹_›, from ‹_›},\n  exact H' ‹_›\nend\n\n-- use for rewriting in the second argument using the first\nlemma bv_rw'' {x y : bSet 𝔹} {Γ : 𝔹} (H : Γ ≤ x =ᴮ y) {ϕ : bSet 𝔹 → 𝔹} (H_new : Γ ≤ ϕ x) (h_congr : B_ext ϕ . H_congr_handler) : Γ ≤ ϕ y :=\nbegin\n  have : Γ ≤ x =ᴮ y ⊓ ϕ x,\n    by {apply le_inf, from ‹_›, from ‹_›},\n  from (poset_yoneda_inv _ (h_congr _ _) this)\nend\n\nlemma mem_congr {Γ : 𝔹} {x₁ x₂ y₁ y₂ : bSet 𝔹} (H₁ : Γ ≤ x₁ =ᴮ y₁) (H₂ : Γ ≤ x₂ =ᴮ y₂) (H₃ : Γ ≤ x₁ ∈ᴮ x₂) :\n  Γ ≤ y₁ ∈ᴮ y₂ :=\nby {rw[bv_eq_symm] at H₁ H₂, apply bv_rw' H₁, simp, apply bv_rw' H₂, simpa}\n\n@[instance]def b_setoid (Γ : 𝔹) : setoid (bSet 𝔹) :=\n{ r := bv_eq' Γ,\n  iseqv := ⟨λ _, bv_refl, λ _ _, bv_symm, λ _ _ _, bv_trans⟩ }\n\nlemma bv_cc.mk_iff {Γ} {x y : bSet 𝔹} : Γ ≤ x =ᴮ y ↔ (@quotient.mk _ (b_setoid Γ) x) = (@quotient.mk _ (b_setoid Γ) y) := by rw [quotient.eq]; refl\n\nlemma bv_cc.mk {Γ} {x y : bSet 𝔹} (H : Γ ≤ x =ᴮ y) : (@quotient.mk _ (b_setoid Γ) x) = (@quotient.mk _ (b_setoid Γ) y) := bv_cc.mk_iff.mp ‹_›\n\n-- TODO(jesse): automate the generation of these lemmas with typeclasses\ndef b_setoid_mem (Γ : 𝔹) : quotient (b_setoid Γ) → quotient (b_setoid Γ) → Prop :=\n@quotient.lift₂ (bSet 𝔹) (bSet 𝔹) Prop (b_setoid Γ) (b_setoid Γ) (λ x y, Γ ≤ x ∈ᴮ y)\n  begin\n    intros a₁ a₂ b₁ b₂ H_eqv₁ H_eqv₂, dsimp, apply propext,\n    refine ⟨_,_⟩; intro H,\n      all_goals { rw[<-quotient.eq, <-bv_cc.mk_iff] at H_eqv₁ H_eqv₂},\n      { exact mem_congr ‹_› ‹_› ‹_› },\n      { exact mem_congr (bv_symm H_eqv₁) (bv_symm H_eqv₂) ‹_› }\n  end\n\nlemma bv_cc.mk_mem_iff {Γ} {x y : bSet 𝔹} :\n  Γ ≤ x ∈ᴮ y ↔ b_setoid_mem Γ (@quotient.mk _ (b_setoid Γ) x) (@quotient.mk _ (b_setoid Γ) y) :=\nby rw b_setoid_mem; refl\n\nlemma bv_cc.mk_mem {Γ} {x y : bSet 𝔹} (H : Γ ≤ x ∈ᴮ y) :\n  b_setoid_mem Γ (@quotient.mk _ (b_setoid Γ) x) (@quotient.mk _ (b_setoid Γ) y) :=\nbv_cc.mk_mem_iff.mp ‹_›\n\nexample {x y z : bSet 𝔹} {Γ : 𝔹} (H1 : Γ ≤ x =ᴮ y) (H2 : Γ ≤ y =ᴮ z) : Γ ≤ x =ᴮ z :=\nbegin\n  replace H1 := bv_cc.mk H1,\n  replace H2 := bv_cc.mk H2,\n  rw[bv_cc.mk_iff], cc\nend\n\nend bSet\n\nnamespace tactic\nnamespace interactive\nsection bv_cc\nopen lean.parser lean interactive.types interactive\nlocal postfix `?`:9001 := optional\n\n/--\n`apply_at (H : α) F` assumes that F's first explicit argument is of type `α`\nand replaces the assumption H with F H.\n-/\nmeta def apply_at (H_tgt : parse ident) (H : parse texpr) : tactic unit :=\n do e_tgt <- resolve_name H_tgt,\n    tactic.replace H_tgt ``(%%H %%e_tgt)\n\nmeta def apply_all (H : parse texpr) : tactic unit :=\ndo ctx <- local_context,\n   let mk_new_hyp (e : expr) : tactic unit :=\n     let n_e := get_name e in\n       tactic.try (do n <- get_unused_name n_e, to_expr ``(%%H %%e) >>= note n none)\n   in (list.mmap' mk_new_hyp ctx)\n\nmeta def bv_cc : tactic unit := do\n   apply_all ``(bSet.bv_cc.mk),\n   try `[rw[bSet.bv_cc.mk_iff]],\n   apply_all ``(bSet.bv_cc.mk_mem),\n   try `[rw[bSet.bv_cc.mk_mem_iff]],\n   cc\n\nend bv_cc\nend interactive\nend tactic\n\nexample {𝔹} [nontrivial_complete_boolean_algebra 𝔹] {a b c : 𝔹} : ( a ⟹ b ) ⊓ ( b ⟹ c ) ≤ a ⟹ c :=\nbegin\n  tidy_context, bv_tauto\nend\n\nexample {α β : Type} (f : α → β) (P : α → Prop) (Q : β → Prop) {a : α} (H : P a) (H' : P a) (C : ∀ {a}, P a → Q (f a)) : true :=\nbegin\n  apply_at H C,\n  apply_all C, triv\nend\n\nnamespace bSet\n\nvariables {𝔹 : Type u} [nontrivial_complete_boolean_algebra 𝔹]\n\nexample {x y z x₁ y₁ z₁: bSet 𝔹} {Γ : 𝔹} (H1 : Γ ≤ x =ᴮ y) (H2 : Γ ≤ y =ᴮ z)\n  (H3 : Γ ≤ z =ᴮ z₁) (H4 : Γ ≤ z₁ =ᴮ y₁) (H5 : Γ ≤ y₁ =ᴮ x₁)\n: Γ ≤ x =ᴮ x₁ :=\nby bv_cc -- :^)\n\nexample {x₁ y₁ x₂ y₂ : bSet 𝔹} {Γ} (H₁ : Γ ≤ x₁ ∈ᴮ y₁) (H₂ : Γ ≤ x₁ =ᴮ x₂) (H₂ : Γ ≤ y₁ =ᴮ y₂) : Γ ≤ x₂ ∈ᴮ y₂ :=\nby bv_cc -- :^)\n\nexample {a b c d e : bSet 𝔹} : (a =ᴮ b) ⊓ (b =ᴮ c) ⊓ (c =ᴮ d) ⊓ (d =ᴮ e) ≤ a =ᴮ e :=\nby tidy_context; bv_cc\n\ndef is_definite (u : bSet 𝔹) : Prop := ∀ i : u.type, u.bval i = ⊤\n\nlemma eq_empty {u : bSet 𝔹} : u =ᴮ ∅ = -⨆i, u.bval i :=\nbegin\n  simp only [bv_eq_unfold], simp only [mem_unfold],\n  simp only [inf_top_eq, bSet.forall_over_empty, bSet.exists_over_empty,imp_bot, neg_supr]\nend\n\n@[simp]lemma empty_subset {x : bSet 𝔹} {Γ : 𝔹} : Γ ≤ ∅ ⊆ᴮ x :=\nby rw[subset_unfold]; bv_intro; repeat{cases i}\n\nlemma empty_spec {x : bSet 𝔹} {Γ : 𝔹} : Γ ≤ -(x ∈ᴮ ∅) := by simp[mem_unfold]\n\nlemma bot_of_mem_empty {x : bSet 𝔹} {Γ : 𝔹} (H : Γ ≤ x ∈ᴮ ∅) : Γ ≤ ⊥ :=\nby {have := @empty_spec 𝔹 _ x Γ, rw[<-imp_bot] at this, from this H}\n\n@[simp]lemma subst_congr_insert1_left {u w v : bSet 𝔹} : u =ᴮ w ≤ bSet.insert1 u v =ᴮ bSet.insert1 w v :=\nbegin\n  rcases v with ⟨α,A,B⟩, simp[bSet.insert1, bv_eq, mem], split; intro i; apply bv_imp_intro;\n  refine le_sup_right_of_le _; apply bv_use i; rw[inf_comm]; simp\nend\n\n@[simp]lemma subst_congr_insert1_left' {u w v : bSet 𝔹} {c : 𝔹} {h : c ≤ u =ᴮ w} : c ≤ bSet.insert1 u v =ᴮ bSet.insert1 w v :=\nby apply le_trans h; simp\n\n@[simp]lemma subst_congr_insert1_left'' {u w v : bSet 𝔹} {c : 𝔹} {h : c ≤ u =ᴮ w} : c ≤ {v, u} =ᴮ {v, w} :=\n  by {unfold has_insert.insert, apply subst_congr_insert1_left', from ‹_›}\n\n@[simp]lemma subst_congr_insert1_right {u w v : bSet 𝔹} : u=ᴮw ≤ bSet.insert1 v u =ᴮ bSet.insert1 v w :=\nby {rcases u with ⟨α,A,B⟩, rcases w with ⟨α',A',B'⟩, simp[bSet.insert1, bv_eq, mem]; split; intro i; apply bv_imp_intro,\n    apply le_sup_right_of_le, apply le_trans, apply inf_le_inf, refl, apply mem.mk, from A, change _ ⊓ _  ≤ A i ∈ᴮ ⟨α',A',B'⟩, rw ← bv_eq,\n    apply subst_congr_mem_right,\n    apply le_sup_right_of_le, apply le_trans, apply inf_le_inf, refl, apply mem.mk, from A', conv {to_rhs, congr, funext,rw[bv_eq_symm]},\n    change _ ≤ A' i ∈ᴮ ⟨α,A,B⟩, rw[←bv_eq, bv_eq_symm], apply subst_congr_mem_right}\n\n@[simp]lemma subst_congr_insert1_right' {u w v : bSet 𝔹} {c : 𝔹} {h : c ≤ u =ᴮ w} : c ≤ bSet.insert1 v u =ᴮ bSet.insert1 v w :=\nby {apply le_trans h, apply subst_congr_insert1_right}\n\n@[simp]lemma subst_congr_insert1_right'' {u w v : bSet 𝔹} {c : 𝔹} {h : c ≤ u =ᴮ w} : c ≤ {u,v} =ᴮ {w,v} :=\n  by {unfold has_insert.insert, apply subst_congr_insert1_right', apply subst_congr_insert1_left', from ‹_›}\n\n/- some singleton lemmas -/\n\n@[simp]lemma eq_singleton_of_eq {x y : bSet 𝔹} {c : 𝔹} {h : c ≤ x =ᴮ y} : c ≤ {x} =ᴮ {y} :=\nby {apply subst_congr_insert1_left', from ‹_›}\n\nlemma eq_of_eq_singleton {x y : bSet 𝔹} {c : 𝔹} {h : c ≤ {x} =ᴮ {y}} : c ≤ x =ᴮ y :=\nbegin\n  apply le_trans h, simp[singleton, has_insert.insert], simp only [insert1_unfold],\n  simp only [bv_eq_unfold],\n  simp only [lattice.le_inf_iff, lattice.infi_option, lattice.inf_top_eq,\n bSet.mem, lattice.top_inf_eq, lattice.supr_option, lattice.top_imp, lattice.sup_bot_eq,\n lattice.le_infi_iff, bSet.forall_over_empty, bSet.exists_over_empty] with cleanup,\n  split; intro i; [apply inf_le_left_of_le, apply inf_le_right_of_le];\n  rw[bv_eq_unfold]; apply inf_le_left_of_le; apply bv_specialize i; refl\nend\n\nlemma eq_singleton_iff_eq {x y : bSet 𝔹} {c : 𝔹} : c ≤ {x} =ᴮ {y} ↔ c ≤ x =ᴮ y :=\nby {split; intros; [apply eq_of_eq_singleton, apply eq_singleton_of_eq]; from ‹_›}\n\nlemma singleton_unfold {x : bSet 𝔹} : {x} = bSet.insert1 x ∅ := rfl\n\n@[simp]lemma singleton_type {x : bSet 𝔹} : type ({x} : bSet 𝔹) = option (ulift _root_.empty) := rfl\n\n@[simp]lemma singleton_func {x : bSet 𝔹} {o} : func ({x} : bSet 𝔹) o = option.rec_on o x (empty.elim ∘ ulift.down) := rfl\n\n@[simp]lemma singleton_bval {x : bSet 𝔹} {o} : bval ({x} : bSet 𝔹) o = option.rec_on o ⊤ (empty.elim ∘ ulift.down) := rfl\n\n@[simp]lemma singleton_bval_none {x : bSet 𝔹} : bval ({x} : bSet 𝔹) none = ⊤ := rfl\n\n-- @[simp]lemma eq_of_eq_insert_right {u w v : bSet 𝔹} {c : 𝔹} {h : c ≤ bSet.insert1 v u =ᴮ bSet.insert1 v w} : c ≤ u =ᴮ w :=\n-- begin\n--   apply le_trans h, simp only [insert1_unfold, bv_eq_unfold], simp, split; intro i; [apply inf_le_left_of_le, apply inf_le_right_of_le],\n--   {apply bv_specialize i, apply bv_cancel_antecedent, apply bv_or_elim, },\n--   {sorry}\n-- end\n\n/-- ϕ (x) is true if and only if the Boolean truth-value of ϕ(x̌) is ⊤-/\n/- To even state this theorem, we need to set up more general machinery for\n   Boolean-valued structures and the interpretation of formulas within them -/\n-- theorem check_transfer : sorry := sorry\n\ndef mixture {ι : Type u} (a : ι → 𝔹) (u : ι → bSet 𝔹) : bSet 𝔹 :=\n  ⟨Σ(i : ι), (u i).type,\n    λx, (u x.fst).func x.snd,\n      λx, ⨆(j:ι), a j ⊓ ((u x.fst).func x.snd) ∈ᴮ u j⟩\n\n/-- Given a₁ a₂ : 𝔹, return the canonical map from ulift bool to 𝔹 given by ff ↦ a₁ and tt ↦ a₂-/\n@[reducible]def bool.map {α : Type*} (a₁ a₂ : α) : (ulift bool) → α :=\n  λ x, bool.rec_on (x.down) a₁ a₂\n\ndef two_term_mixture (a₁ a₂ : 𝔹) (h_anti : a₁ ⊓ a₂ = ⊥) (u₁ u₂ : bSet 𝔹) : bSet 𝔹 :=\n@mixture 𝔹 _ (ulift bool) (bool.map a₁ a₂) (bool.map u₁ u₂)\n\n-- @[simp]lemma two_term_mixture_type (a₁ a₂ : 𝔹) (h_anti : a₁ ⊓ a₂ = ⊥) (u₁ u₂ : bSet 𝔹) :\n--   (two_term_mixture a₁ a₂ h_anti u₁ u₂).type = (Σ(i : ulift bool), ((bool.map u₁ u₂) i).type) := sorry\n\nlemma two_term_mixture_h_star (a₁ a₂ : 𝔹) (h_anti : a₁ ⊓ a₂ = ⊥) (u₁ u₂ : bSet 𝔹) :\n  ∀ i j : (ulift bool), (bool.map a₁ a₂) i ⊓ (bool.map a₁ a₂) j ≤ (bool.map u₁ u₂) i =ᴮ (bool.map u₁ u₂) j :=\nbegin\n  intros i j, cases i, cases j, cases i; cases j; try{simp*},\n  change a₂ ⊓ a₁ ≤ _, rw[inf_comm, h_anti], apply bot_le\nend\n\n@[simp]lemma bval_mixture {ι : Type u} {a : ι → 𝔹} {u : ι → bSet 𝔹} :\n  (mixture a u).bval = λx, ⨆(j:ι), a j ⊓ ((u x.fst).func x.snd) ∈ᴮ u j :=\n  by refl\n\n@[simp]lemma two_term_mixture_bval (a₁ a₂ : 𝔹) (h_anti : a₁ ⊓ a₂ = ⊥) (u₁ u₂ : bSet 𝔹) : ∀ i,\n  (two_term_mixture a₁ a₂ h_anti u₁ u₂).bval i = (a₁ ⊓ ((two_term_mixture a₁ a₂ h_anti u₁ u₂).func i ∈ᴮ u₁)) ⊔ (a₂ ⊓ ((two_term_mixture a₁ a₂ h_anti u₁ u₂).func i ∈ᴮ u₂)) := λ i,\nbegin\n  dsimp[two_term_mixture], tidy, apply le_antisymm, apply supr_le, intro j, repeat{cases j},\n  apply le_sup_left_of_le, refl, apply le_sup_right_of_le, refl,\n  apply bv_or_elim; [apply bv_use (ulift.up ff), apply bv_use (ulift.up tt)]; refl\nend\n\ndef floris_mixture {ι : Type u} (a : ι → 𝔹) (u : ι → bSet 𝔹) : bSet 𝔹 :=\n  ⟨Σ(i : ι), (u i).type, λx, (u x.fst).func x.snd, λx, a x.fst ⊓ (u x.fst).bval x.snd⟩\n\n/-- Mixing lemma, c.f. Bell's book or Lemma 1 of Hamkins-Seabold -/\nlemma mixing_lemma' {ι : Type u} (a : ι → 𝔹) (τ : ι → bSet 𝔹) (h_star : ∀ i j : ι, a i ⊓ a j ≤ τ i =ᴮ τ j) : ∀ i : ι, a i ≤ (mixture a τ) =ᴮ τ i := λ i,\nbegin\nrw[bv_eq_unfold],\n  apply le_inf,\n    {bv_intro i_z, apply bv_imp_intro,\n    simp only [bSet.bval, bSet.mem, bSet.func, bSet.type, bSet.bval_mixture],\n    rw[inf_supr_eq], apply bv_Or_elim,\n    intro j, rw[<-inf_assoc],\n    have : a i ⊓ a j ⊓ func (τ (i_z.fst)) (i_z.snd) ∈ᴮ τ j ≤ (τ i =ᴮ τ j) ⊓ func (τ (i_z.fst)) (i_z.snd) ∈ᴮ τ j,\n      by {apply inf_le_inf (h_star i j), refl},\n    apply le_trans this, rw[bv_eq_symm], apply subst_congr_mem_right},\n  {bv_intro i_z, rw[<-deduction], refine le_supr_of_le (sigma.mk i i_z) _,\n  simp only [bv_eq_top_of_eq, mem, type, inf_top_eq, bval, func],\n  refine le_supr_of_le i _, refine inf_le_inf (by refl : a i ≤ a i) _, dsimp only,\n  cases (τ i), refine le_supr_of_le i_z _, from le_inf (by refl) (by simp)}\nend\n\nlemma mixing_lemma {ι : Type u} (a : ι → 𝔹) (τ : ι → bSet 𝔹) (h_star : ∀ i j : ι, a i ⊓ a j ≤ τ i =ᴮ τ j) : ∃ x, ∀ i : ι, a i ≤ x =ᴮ τ i :=\n by refine ⟨mixture a τ, λ i, _⟩; apply mixing_lemma'; assumption\n\nlemma mixing_lemma_two_term (a₁ a₂ : 𝔹) (h_anti : a₁ ⊓ a₂ = ⊥) (u₁ u₂ : bSet 𝔹) :\n  a₁ ≤ (two_term_mixture a₁ a₂ h_anti u₁ u₂ =ᴮ u₁) ∧ a₂ ≤ (two_term_mixture a₁ a₂ h_anti u₁ u₂ =ᴮ u₂) :=\nbegin\n  have := mixing_lemma' (bool.map a₁ a₂) (bool.map u₁ u₂)\n    (by {apply two_term_mixture_h_star, exact h_anti}),\n  split; [specialize this (ulift.up ff), specialize this (ulift.up tt)]; exact this\nend\n\n-- TODO(jesse) try proving mixing_lemma with floris_mixture and see if anything goes wrong\n\n/-- In particular, the mixing lemma applies when the weights (a_i) form an antichain and the indexing is injective -/\nlemma h_star_of_antichain_injective {ι : Type u} {a : ι → 𝔹} {τ : ι → bSet 𝔹} {h_anti : antichain (a '' set.univ)} {h_inj : function.injective a} :\n  ∀ i j : ι, a i ⊓ a j ≤ τ i =ᴮ τ j :=\nbegin\n  intros i j, by_cases a i = a j, simp[h_inj h],\n  have := h_anti _ _ _ _ h, simp[this], tidy\nend\n\n/- Note: this is the special condition assumed of indexed antichains by Bell-/\nlemma h_star_of_antichain_index {ι : Type u} {a : ι → 𝔹} {τ : ι → bSet 𝔹} {h_anti : antichain (a '' set.univ)} {h_index : ∀ i j : ι, i ≠ j → a i ⊓ a j = ⊥} :\n  ∀ i j : ι, a i ⊓ a j ≤ τ i =ᴮ τ j :=\n  λ i j, by {haveI : decidable_eq ι := λ _ _,\n  by apply classical.prop_decidable _,\n    by_cases i = j, simp[h], finish[h_index i j]}\n\n/- The next two lemmas use the fact that 𝔹 : Type u to extract a small set witnessing quantification over all of bSet 𝔹 -/\n\n/- i.e., in bSet 𝔹, any existential quantification is equivalent to a bounded existential quantification. this is one place where it's crucial that 𝔹 lives in the type universe out of which bSet 𝔹 is being built -/\nsection smallness\nvariable {ϕ : bSet 𝔹 → 𝔹}\n\n@[reducible, simp]noncomputable def fiber_lift (b : ϕ '' set.univ) :=\nclassical.indefinite_description (λ a : bSet 𝔹, ϕ a = b.val) $\n  by {cases b.property, use w, exact h.right}\n\nnoncomputable def B_small_witness : bSet 𝔹 :=\n⟨ϕ '' set.univ, λ b, (fiber_lift b).val, λ _, ⊤⟩\n\n@[simp]lemma B_small_witness_spec : ∀ b, ϕ ((@B_small_witness _ _ ϕ).func b) = b.val :=\n  λ b, (fiber_lift b).property\n\nlemma B_small_witness_supr : (⨆(x : bSet 𝔹), ϕ x) = ⨆(b : (@B_small_witness _ _ ϕ).type), ϕ (B_small_witness.func b) :=\nbegin\n apply le_antisymm,\n apply supr_le, intro x, let b : type B_small_witness :=\n   by {use ϕ x, simp only [set.image_univ, set.mem_range], exact ⟨x, rfl⟩},\n fapply le_supr_of_le, exact b, have := B_small_witness_spec b, dsimp at this, rw[this],\n apply supr_le, intro b, apply le_supr_of_le, swap, exact (fiber_lift b).val, refl\nend\n\n@[reducible, simp]def not_b (b : 𝔹) : set 𝔹 := λ y, y ≠ b\n\nsection well_ordering\nvariables {α : Type*} (r : α → α → Prop) [is_well_order α r]\nlocal infix `≺`:50 := r\n\ndef down_set (a : α) : set α := {a' | a' ≺ a}\n\ndef down_set' (a : α) : set α := insert a $ down_set r a\n\nlemma down_set_trans {a b} {h : a ≺ b} : down_set r a ⊆ down_set r b :=\nbegin\n  intros x H, have := is_well_order.is_trans r, cases this, apply this,\n  exact H, exact h\nend\n\nend well_ordering\n\nvariable (r : type (@B_small_witness _ _ ϕ) → type (@B_small_witness _ _ ϕ) → Prop)\nvariable [is_well_order _ r]\nlocal infix `≺`:50 := r\n\nlemma down_set_mono_supr {a b} {h : a ≺ b} {s : type (@B_small_witness _ _ ϕ) → 𝔹} :\n (⨆(i ∈ down_set r a), s i) ≤ (⨆(i ∈ down_set r b), s i) :=\nbegin\n  apply supr_le_supr, intro i, apply supr_le, intro H, apply le_supr_of_le,\n  apply down_set_trans, exact h, exact H, refl\nend\n\nlemma down_set'_mono_supr {a b} {h : a ≺ b} {s : type (@B_small_witness _ _ ϕ) → 𝔹} :\n (⨆(i ∈ down_set' r a), s i) ≤ (⨆(i ∈ down_set' r b), s i) :=\nbegin\n  apply supr_le_supr, intro i, apply supr_le, intro H,\n apply le_supr_of_le,\n  cases H, apply or.inr, rw[H], exact h, apply or.inr,\n  apply down_set_trans, exact h, exact H, refl\nend\n\ndef witness_antichain : _ → 𝔹 :=\n(λ b : type (@B_small_witness _ _ ϕ), b.val - (⨆(b' : (down_set r b)), b'.val.val))\n\ndef trichotomy := (is_well_order.is_trichotomous r).trichotomous\n\nlemma dichotomy_of_neq (x y) : x ≠ y → x ≺ y ∨ y ≺ x :=\nλ H, by {[smt] eblast_using [trichotomy r x y]}\n\nlemma not_ge_of_in_down_set (a b) : a ∈ down_set r b → ¬ b ≺ a :=\nbegin\n  intros H H', have H'' : a ≺ b, by {simpa[down_set]},\n  cases (show (is_asymm _ r), by apply_instance),\n  specialize asymm a b H'', contradiction\nend\n\ndef witness_antichain_index : ∀ {i j}, i ≠ j → (@witness_antichain _ _ ϕ r _) i ⊓ (@witness_antichain _ _ ϕ r _) j = ⊥ :=\nλ x y h_neq,\nbegin\n  dsimp[witness_antichain], simp[sub_eq, neg_supr],\n  apply bot_unique, cases dichotomy_of_neq r _ _ h_neq,\n  {/- `tidy_context` says -/ apply poset_yoneda, intros Γ a,\n    simp only [le_inf_iff] at *, cases a, cases a_right, cases a_left,\n     replace a_right_right := a_right_right ⟨x,‹_›⟩, dsimp at a_right_right,\n     bv_contradiction},\n  { /- `tidy_context` says -/ apply poset_yoneda, intros Γ a,\n    simp only [le_inf_iff] at *, cases a, cases a_right, cases a_left,\n     replace a_left_right := a_left_right ⟨y,‹_›⟩, dsimp at a_left_right,\n     bv_contradiction}\nend\n\nlemma witness_antichain_antichain : antichain ((@witness_antichain _ _ ϕ r _) '' set.univ) :=\nbegin\n  intros x h_x y h_y h_neq, simp at h_x h_y, rcases h_y with ⟨w_y, h_y⟩,\n  rcases h_x with ⟨w_x, h_x⟩, rw[<-h_y, <-h_x],\n  apply witness_antichain_index, by_contra, cc\nend\n\nlemma witness_antichain_property : ∀ b, (@witness_antichain _ _ ϕ r _) b ≤ b.val :=\n  λ b, by simp[witness_antichain, sub_eq]\n\nlemma supr_antichain2_contains : (⨆ (b' : type (@B_small_witness _ _ ϕ)), ϕ (func (@B_small_witness _ _ ϕ) b')) ≤\n    ⨆ (b : type (@B_small_witness _ _ ϕ)), witness_antichain r b :=\nbegin\n  apply supr_le, intro i, apply le_supr_of_le'', fsplit,\n  exact down_set' r i, rw[B_small_witness_spec i],\n  have := (is_well_order.wf r).apply i, induction this,\n  intros,\n rw[down_set',supr_insert], unfold witness_antichain,\n  rw[sub_eq], rw[sup_inf_right], apply le_inf, apply le_sup_left,\n  -- simp[neg_supr, sub_eq],\n  apply le_trans (@le_top _ _ this_x.val),\n     let A := _, change ⊤ ≤ (A ⊔ _ : 𝔹), apply le_trans (by simp : ⊤ ≤ A ⊔ -A), apply sup_le_sup, refl, dsimp[A],\n   rw[lattice.neg_neg],\n   apply supr_le, intro j,\n   apply le_trans (this_ih j j.property), unfold witness_antichain,\n   apply supr_le_supr, intro i', apply supr_le, intro H',\n   cases H', subst H', apply le_supr_of_le, exact j.property, refl,\n   apply le_supr_of_le, apply down_set_trans, exact j.property, exact H',\n   refl\nend\nend smallness\n\nlemma maximum_principle (ϕ : bSet 𝔹 → 𝔹) (h_congr : B_ext ϕ) : ∃ u, (⨆(x:bSet 𝔹), ϕ x) = ϕ u :=\nbegin\n  have := classical.indefinite_description _ (@ordinal.well_ordering_thm (type (@B_small_witness _ _ ϕ))),\n  cases this with r inst_r,\n  haveI : is_well_order _ r := by assumption,\n  let w := @B_small_witness _ _ ϕ,\n    have from_mixing_lemma := mixing_lemma ((witness_antichain r)) (w.func)\n      (λ i j, by {by_cases i = j, finish, simp[witness_antichain_index r h]}),\n    rcases from_mixing_lemma with ⟨u, H_w⟩,\n    use u, fapply le_antisymm,\n    {rw[B_small_witness_supr],\n     have H1 : (⨆(b : type B_small_witness), (witness_antichain r) b) ≤ ϕ u,\n     apply supr_le, intro ξ,\n    have this'' : ∀ b, (witness_antichain r) b ≤ u =ᴮ func w b ⊓ b.val,\n      by {intro b, apply le_inf, apply H_w b, apply witness_antichain_property},\n    have this''' : ∀ b, u =ᴮ func w b ⊓ (ϕ (func B_small_witness b)) ≤ ϕ u,\n      intro b, dsimp[w], rw[bv_eq_symm], apply h_congr, apply le_trans,\n      exact this'' ξ, convert this''' ξ, apply (B_small_witness_spec _).symm,\n   suffices H2 : (⨆(b' : type (@B_small_witness _ _ ϕ)), ϕ (func B_small_witness b')) ≤ ⨆(b : type (@B_small_witness _ _ ϕ)), (witness_antichain r) b,\n   from le_trans H2 H1, apply supr_antichain2_contains},\n    {apply le_supr}\nend\n\n/--  extract an element witnessing a 𝔹-valued existential -/\nlemma exists_convert {ϕ : bSet 𝔹 → 𝔹} {Γ : 𝔹} (H : Γ ≤ ⨆x, ϕ x) (H_congr : B_ext ϕ . H_congr_handler) : ∃ u, Γ ≤ ϕ u :=\nby {rcases (maximum_principle ϕ ‹_›) with ⟨u, Hu⟩, use u, finish}\n\nlemma maximum_principle_verbose {ϕ : bSet 𝔹 → 𝔹} {h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y} {b : 𝔹} (h_eq_top L : (⨆(x:bSet 𝔹), ϕ x) = b) : ∃ u, ϕ u = b :=\n by cases maximum_principle ϕ h_congr with w h; from ⟨w, by finish⟩\n\n/-- \"∃ x ∈ u, ϕ x implies ∃ x : bSet 𝔹, ϕ x\", but this time, say it in Boolean -/\nlemma weaken_ex_scope {α : Type*} (A : α → bSet 𝔹) (ϕ : bSet 𝔹 → 𝔹)  : (⨆(a : α), ϕ (A a)) ≤ (⨆(x : bSet 𝔹), ϕ x) :=\nsupr_le $ λ a, le_supr_of_le (A a) (by refl)\n\nlemma maximum_principle_bounded_top {ϕ : bSet 𝔹 → 𝔹} {h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y} {α : Type*} {A : α → bSet 𝔹} (h_eq_top : (⨆(a:α), ϕ (A a)) = ⊤) : ∃ u, ϕ u = ⊤ :=\n@maximum_principle_verbose 𝔹 (by apply_instance) ϕ h_congr ⊤ (by {have := weaken_ex_scope A ϕ, finish}) (by {have := weaken_ex_scope A ϕ, finish})\n\n/-- Convert a Boolean-valued ∀∃-statement into a Prop-valued ∀∃-statement\n  Given A : α → bSet 𝔹, a binary function ϕ : bSet 𝔹 → bSet 𝔹 → 𝔹, a truth-value assignment\n  B : α → 𝔹, ∀ i : α, there exists a y_i : bSet 𝔹, such that\n  (B i ⟹ ϕ (A i) y_i) ≥ ⨅(i:α), B i ⟹ ⨆(y : bSet 𝔹), ϕ(A i, bSet 𝔹)\n\n  A more verbose, but maybe clearer way to see this is:\n  if there is an equality (⨅i-⨆j body i j) = b,\n  then for all i, there exists j, such that body i j ≥ b\n\n  This is a consequence of the maximum principle.\n-/\nlemma AE_convert {α 𝔹 : Type*} [nontrivial_complete_boolean_algebra 𝔹] (A : α → bSet 𝔹)\n  (B : α → 𝔹) (ϕ : bSet 𝔹 → bSet 𝔹 → 𝔹) (h_congr : ∀ z, B_ext (λ x, ϕ z x)) :\n  ∀ i : α, ∃ y : bSet 𝔹, (⨅(j:α), (B j ⟹ ⨆(z : bSet 𝔹), ϕ (A j) z)) ≤ (B i ⟹ ϕ (A i) y) :=\nλ i,\n  by {have := maximum_principle (λ y, ϕ (A i) y)\n                (by {intros x y, apply h_congr}),\n      rcases this with ⟨u', H'⟩, use u', apply infi_le_of_le i,\n      apply imp_le_of_right_le, from le_of_eq H'}\n\nlemma AE_convert' (ϕ : bSet 𝔹 → bSet 𝔹 → 𝔹) (h_congr : ∀ z, B_ext (λ x, ϕ z x)) (x : bSet 𝔹) :\n  ∀ v : bSet 𝔹, ∃ w : bSet 𝔹, ∀ {Γ : 𝔹}, (Γ ≤ ⨅ z, z ∈ᴮ x ⟹ ⨆ w, ϕ z w) → Γ ≤ v ∈ᴮ x → Γ ≤ ϕ v w :=\nbegin\n  intro v, have := maximum_principle (λ y, ϕ v y) (by simp*),\n  rcases this with ⟨u, Hu⟩, use u, intros Γ H_AE H_mem, dsimp at Hu, rw ←Hu,\n  change _ ≤ ⨆ y, _,\n  exact (H_AE v ‹_›)\nend\n\nsection mixing_corollaries\n-- The lemmas in this section are corollaries of the mixing lemma\nvariables (X u₁ u₂ : bSet 𝔹) (a₁ a₂ : 𝔹) (h_anti : a₁ ⊓ a₂ = ⊥) (h_partition : a₁ ⊔ a₂ = ⊤)\n\ninclude h_partition\nlemma two_term_mixture_mem_top (h₁ : u₁ ∈ᴮ X = ⊤) (h₂ : u₂ ∈ᴮ X = ⊤) :\n  two_term_mixture a₁ a₂ h_anti u₁ u₂ ∈ᴮ X = ⊤:=\nbegin\n  let U := _, change U ∈ᴮ X= _, apply top_unique,\n  have : ⊤ ≤ U =ᴮ u₁ ⊔ U =ᴮ u₂,\n    by {rw[h_partition.symm],\n       have := mixing_lemma_two_term a₁ a₂ h_anti u₁ u₂,apply sup_le_sup, tidy},\n  have : ⊤ ≤ (U =ᴮ u₁ ⊔ U =ᴮ u₂) ⊓ (u₁ ∈ᴮ X ⊓ u₂ ∈ᴮ X),\n    by finish,\n  apply le_trans this, apply bv_or_elim_left;\n    [rw[<-inf_assoc], ac_change (U =ᴮ u₂ ⊓ u₂ ∈ᴮ X) ⊓ u₁ ∈ᴮ X ≤ U ∈ᴮ X];\n    apply inf_le_left_of_le; rw[bv_eq_symm]; apply subst_congr_mem_left\nend\n\nlemma two_term_mixture_subset_top (H : a₁ = u₂ ⊆ᴮ u₁) :\n  ⊤ ≤ u₂ ⊆ᴮ (two_term_mixture a₁ a₂ h_anti u₁ u₂) :=\nbegin\n  let U := _, change _ ≤ u₂ ⊆ᴮ U,\n  rw[subset_unfold'], bv_intro w, apply bv_imp_intro,\n  rw[top_inf_eq], simp only [mem_unfold], apply bv_Or_elim,\n  intro i, fapply bv_use, exact ⟨ulift.up tt,i⟩, refine inf_le_inf _ (by refl),\n  simp, rw[sup_inf_left_right_eq], repeat{apply bv_and_intro},\n  {rw[h_partition], apply le_top},\n  {apply le_sup_right_of_le, cases u₂, apply mem.mk},\n  {have : a₂ = - a₁, by apply eq_neg_of_partition; assumption,\n   conv {to_rhs, congr, skip, rw[this, H]}, rw[sup_comm], change _ ≤ _ ⟹ _,\n   apply bv_imp_intro, rw[inf_comm], simp only [subset_unfold],\n   apply bv_specialize_left i, apply bv_imp_elim},\n  {apply le_sup_right_of_le, cases u₂, apply mem.mk}\nend\nend mixing_corollaries\n\nlemma core_aux_lemma (ϕ : bSet 𝔹 → 𝔹) (h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y) (h_definite : (⨆(w : bSet 𝔹), ϕ w) = ⊤) (v : bSet 𝔹) :\n  ∃ u : bSet 𝔹, ϕ u = ⊤ ∧ ϕ v = u =ᴮ v :=\nbegin\n  have := maximum_principle ϕ h_congr, cases this with w H_w,\n  let b := ϕ v, let u := two_term_mixture b (- b) (by simp) v w, use u,\n  have h_partition : b ⊔ (- b) = ⊤, by simp,\n  have H_max : ϕ u = ⊤,\n    by {apply top_unique, rw[<-h_partition], apply le_trans,\n    apply sup_le_sup, apply le_inf, apply (mixing_lemma_two_term _ _ _ _ _).left, exact -b, simp,\n    exact v, exact w, refl, apply le_inf, apply (mixing_lemma_two_term _ _ _ _ _).right, exact b,\n    simp, exact v, exact w, swap, exact ϕ w, rw[<-H_w, h_definite], apply le_top,\n    apply bv_or_elim; rw[bv_eq_symm]; apply h_congr},\n  refine ⟨H_max, _⟩,\n  apply le_antisymm,\n    {apply (mixing_lemma_two_term _ _ _ _ _).left},\n    {suffices : u =ᴮ v ⊓ ϕ u ≤ ϕ v,\n      by {rw[H_max] at this, finish}, by apply h_congr}\nend\n\nlemma core_aux_lemma2 (ϕ ψ : bSet 𝔹 → 𝔹) (h_congrϕ : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y)\n  (h_congrψ : ∀ x y, x =ᴮ y ⊓ ψ x ≤ ψ y) (h_sub : ∀ u, ϕ u = ⊤ → ψ u = ⊤)\n  (h_definite : (⨆(w : bSet 𝔹), ϕ w) = ⊤) :\n  (⨅(x : bSet 𝔹), ϕ x ⟹ ψ x) = ⊤ :=\nbegin\n  simp, intro x, have := core_aux_lemma ϕ h_congrϕ h_definite x,\n  rcases this with ⟨u, ⟨h₁, h₂⟩⟩,\n  have := h_sub u ‹_›, rw[show ϕ x = ϕ x ⊓ ⊤, by simp],\n  rw[<-this, h₂], apply h_congrψ\nend\n\nsection smallness'\nvariables {α : Type u} (ϕ : bSet 𝔹 → α)\n-- in this section we prove the smallness-type arguments required for showing that cores always exist.\n@[reducible, simp]noncomputable def fiber_lift' (b : ϕ '' set.univ) : {x : bSet 𝔹 // ϕ x = b.val} :=\nclassical.indefinite_description (λ a : bSet 𝔹, ϕ a = b.val) $\n  by {cases b.property, use w, exact h.right}\n\nend smallness'\n\nsection cores\n@[reducible]def pullback_eq_rel {α β : Type*} (f : α → β) (E : β → β → Prop) : α → α → Prop :=\nλ a₁ a₂, E (f a₁) (f a₂)\n\ndef core {α : Type u} (u : bSet 𝔹) (S : α → bSet 𝔹) : Prop :=\n(∀ x : α, S x ∈ᴮ u = ⊤) ∧ (∀ y : bSet 𝔹, y ∈ᴮ u = ⊤ → ∃! x_y : α, y =ᴮ S x_y = ⊤)\n\nnoncomputable def core_witness {α : Type u} {u : bSet 𝔹} {S : α → bSet 𝔹} (h_core : core u S) (x : bSet 𝔹) (h_X : x ∈ᴮ u = ⊤) :\n  Σ' (x_y : α), x =ᴮ S x_y = ⊤ :=\nbegin\n  cases h_core, specialize h_core_right x h_X, have := classical.indefinite_description _ h_core_right, use this.val, tidy\nend\n\nlemma core_inj {α : Type u} (u : bSet 𝔹) (S : α → bSet 𝔹) (h_core : core u S) : function.injective S :=\nbegin\n  intros x y H, cases h_core, have h_left₁ := h_core_left x, have h_left₂ := h_core_left y,\n  have this_right₁ := h_core_right (S x) h_left₁,\n  have this_right₂:= h_core_right (S y) h_left₂,\n  rcases this_right₁ with ⟨w₁, ⟨H₁, H₂⟩⟩, rcases this_right₂ with ⟨w₂, ⟨H₁', H₂'⟩⟩,\n  have Q₂ := H₂ y, have Q₃ := H₂ x (by apply bv_eq_refl), dsimp at *, rw[Q₂], swap, simpa[H]\nend\n\n/-- `core_inj` says that if a b : α satisfy S a =ᴮ S b = ⊤, then a = b -/\nlemma core_inj' {α : Type u} {u : bSet 𝔹} {S : α → bSet 𝔹} (h_core : core u S) : ∀ a b : α, S a =ᴮ S b = ⊤ → a = b :=\nbegin\n  intros x y H, cases h_core, have h_left₁ := h_core_left x, have h_left₂ := h_core_left y,\n  have this_right₁ := h_core_right (S x) h_left₁,\n  have this_right₂:= h_core_right (S y) h_left₂,\n  rcases this_right₁ with ⟨w₁, ⟨H₁, H₂⟩⟩, rcases this_right₂ with ⟨w₂, ⟨H₁', H₂'⟩⟩,\n  have Q₂ := H₂ y H, have Q₂ := H₂ x (by apply bv_eq_refl), cc\nend\n\n/-- This is the \"f_x\" in the notes. We are free to use function types since universes are inaccessible. -/\ndef core.mk_ϕ (u : bSet 𝔹) : bSet 𝔹 → (u.type → 𝔹) :=\nλ x, (λ a, (u.bval a) ⊓ x =ᴮ u.func a )\n\nlemma core.mk_ϕ_inj (u : bSet 𝔹) (x y : bSet 𝔹) : (x ∈ᴮ u = ⊤) → (y ∈ᴮ u = ⊤) → core.mk_ϕ u x = core.mk_ϕ u y → x =ᴮ y = ⊤ :=\nbegin\n  intros h₁ h₂ H, unfold core.mk_ϕ at H, replace H := congr_fun H,\n  apply top_unique,\n  have : ∀ i_z : u.type, u.bval i_z ⊓ x =ᴮ u.func i_z ⊓ u.bval i_z ⊓ u.func i_z =ᴮ y  ≤ x =ᴮ y :=\n    λ i_z, by {tidy_context, from bv_trans (‹_› : Γ ≤ x =ᴮ func u i_z) ‹_›},\n    dsimp at H, simp[H] at this, rw[<-supr_le_iff] at this, rw[eq_top_iff] at h₂,\n    refine le_trans _ this, convert h₂, rw[mem_unfold], congr' 1, ext,\n    refine le_antisymm _ _; tidy_context, from ⟨⟨⟨‹_›,‹_›⟩,‹_›⟩, bv_symm ‹_›⟩\nend\n\nnoncomputable def core.S' (u : bSet 𝔹) : (core.mk_ϕ u '' set.univ) → bSet 𝔹 :=\n  λ x, (fiber_lift' (core.mk_ϕ u) x).val\n\ndef core.α_S'' (u : bSet 𝔹) : Type u := {i : core.mk_ϕ u '' set.univ // core.S' u i ∈ᴮ u = ⊤}\n\nnoncomputable def core.S'' (u : bSet 𝔹) : core.α_S'' u → bSet 𝔹 := λ x, core.S' u x.val\n\nlemma core.S'_spec (u : bSet 𝔹) (x : core.mk_ϕ u '' set.univ) : core.mk_ϕ u (core.S' u x) = x.val :=\n by unfold core.S'; simp[(fiber_lift' (core.mk_ϕ u) x).property]\n\ndef core.bv_eq_top : bSet 𝔹 → bSet 𝔹 → Prop :=\n  λ x₁ x₂, x₁ =ᴮ x₂ = ⊤\n\ndef core.bv_eq_top_setoid : setoid $ bSet 𝔹 :=\n{ r := core.bv_eq_top,\n  iseqv :=\nbegin\n  repeat{split},\n  {apply bv_eq_refl},\n  {dsimp[core.bv_eq_top], tidy, rwa[bv_eq_symm]},\n  {dsimp[core.bv_eq_top], tidy, apply top_unique, rw[show ⊤ = x =ᴮ y ⊓ y =ᴮ z, by finish],\n   apply bv_eq_trans}\nend}\n\ninstance core.S''_setoid (u : bSet 𝔹) : setoid $ core.α_S'' u :=\n{ r := pullback_eq_rel (core.S'' u) core.bv_eq_top,\n  iseqv :=\nbegin\n  repeat{split}, intro x, apply bv_eq_refl,\n  intros x y, intro H, unfold pullback_eq_rel core.bv_eq_top, rwa[bv_eq_symm],\n  intros x y z, unfold pullback_eq_rel core.bv_eq_top, intros H₁ H₂, apply top_unique,\n  rw[show ⊤ = (core.S'' u x) =ᴮ (core.S'' u y) ⊓ (core.S'' u y) =ᴮ (core.S'' u z), by finish],\n  apply bv_eq_trans\nend}\n\nnoncomputable def core.mk_aux (u : bSet 𝔹) : (quotient (@core.S''_setoid 𝔹 _ u)) → bSet 𝔹 :=\n  λ x, (core.S'' u) (@quotient.out _ (core.S''_setoid u ) x)\n\n@[reducible]private def image.mk {α β : Type*} {f : α → β} (a : α) : f '' set.univ :=\n  ⟨f a, by tidy⟩\n\nlemma core.mk (u : bSet 𝔹) : ∃ α : Type u, ∃ S : α → bSet 𝔹, core u S :=\nbegin\n  repeat{split}, show _ → bSet 𝔹, exact core.mk_aux u,\n  {dsimp, intro x,unfold core.mk_aux, let y := _, change core.S'' u y ∈ᴮ u = _, apply y.property},\n  {intros y H_y, let y' := (core.S' u (image.mk y)),\n   have H_y' : core.mk_ϕ u y = core.mk_ϕ u y',\n     by rw[core.S'_spec],\n   have H_y'2 : y' ∈ᴮ u = ⊤,\n     by {unfold core.mk_ϕ at H_y', have := congr_fun H_y',\n         simp only [mem_unfold], apply top_unique,\n         conv {to_rhs, congr, rw[<-H_y']},\n         simpa[mem_unfold] using H_y},\n\n   let y'' := (core.mk_aux u ⟦by split; exact H_y'2⟧),\n   have H_y'' : y'' =ᴮ y' = ⊤,\n     by {dsimp[y''], unfold core.mk_aux, have := quotient.mk_out,\n      show setoid _, exact core.S''_setoid u, apply this},\n   have H₃ : y =ᴮ y' = ⊤,\n     by {apply core.mk_ϕ_inj, repeat{assumption}},\n   have H₁ : y =ᴮ y'' = ⊤,\n     by {apply top_unique, apply le_trans, show 𝔹, from y =ᴮ y' ⊓ y' =ᴮ y'',\n           apply le_inf,\n             {rw[<-eq_top_iff], exact H₃},\n             {rw[<-eq_top_iff], convert H_y'' using 1, apply bv_eq_symm},\n         apply bv_eq_trans},\n   split, refine ⟨H₁, _⟩, intros i H_y''',\n   suffices : core.mk_aux u i =ᴮ y' = ⊤,\n     by {have : core.mk_aux u i =ᴮ y'' = ⊤, by {apply top_unique, rw[eq_top_iff] at *,\n         apply bv_trans this, convert H_y'' using 1, apply bv_eq_symm},\n         dsimp[y''] at this, unfold core.mk_aux at this_1,\n         have : ⟦quotient.out i⟧ = ⟦quotient.out ⟦⟨image.mk y, H_y'2⟩⟧⟧,\n           by {apply quotient.sound, exact this_1},\n         convert this using 1; rw[quotient.out_eq]},\n   apply top_unique, rw[bv_eq_symm] at H_y''',\n     rw[show ⊤ = (core.mk_aux u i =ᴮ y ⊓ y =ᴮ y'), by {dsimp at H_y''', rw [H₃, H_y'''], simp}],\n   apply bv_eq_trans}\nend\n/-- Given a subset C of α, and an α-indexed core S, return the bSet whose underlying type is C,\n    such that A is the canonical inclusion and B is always ⊤. -/\ndef bSet_of_core_set {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} (h : core u S) (C : set α) : bSet 𝔹 :=\n⟨C, λ x, S x, λ x, ⊤⟩\n\ndef bSet_of_core {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} (h : core u S) : bSet 𝔹 :=\n  bSet_of_core_set h set.univ\n\n@[simp]lemma of_core_type {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} {h : core u S} {C : set α} :\n  (bSet_of_core_set h C).type = C := rfl\n@[simp]lemma of_core_bval {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} {h : core u S} {C : set α} {i} :\n  (bSet_of_core_set h C).bval i = ⊤ := rfl\n\nlemma of_core_mem {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} {h : core u S} {C : set α} {i} :\n  ⊤ ≤ (bSet_of_core_set h C).func i ∈ᴮ u :=\ntop_le_iff.mpr (h.left _)\n\n/-- Given a core S for u, pull back the ordering -/\ndef subset' {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} (h : core u S) : α → α → Prop :=\n  λ a₁ a₂, S a₁ ⊆ᴮ S a₂ = ⊤\n\nopen classical zorn\n\ndef subset'_partial_order {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} (h : core u S) : partial_order α :=\n{ le := subset' h,\n  lt := λ a₁ a₂, (subset' h a₁ a₂) ∧ a₁ ≠ a₂,\n  le_refl := by {simp[subset']},\n  le_trans := by {intros a b c, simp only [subset'], intros, rw[eq_top_iff] at a_1 a_2 ⊢,\n                   from subset_trans' ‹_› ‹_›},\n  lt_iff_le_not_le :=\n    begin\n      /- `tidy` says -/ intros a b, cases h, dsimp at *, fsplit,\n      work_on_goal 0 { intros a_1, cases a_1, fsplit,\n        work_on_goal 0 { assumption }, intros a_1 },\n      work_on_goal 1 { intros a_1, cases a_1, fsplit,\n        work_on_goal 0 { assumption }, intros a_1, induction a_1, solve_by_elim },\n      dsimp[subset'] at *,\n      suffices : S a = S b,\n        by {have := core_inj u _ ⟨h_left, h_right⟩ this, contradiction},\n      suffices : a = b, by rw[this]; refl, apply core_inj' ⟨h_left, h_right⟩, dsimp,\n      rw[eq_top_iff] at a_1_left a_1 ⊢, from subset_ext ‹_› ‹_›\n    end,\n  le_antisymm :=\n    begin\n      intros a b H₁ H₂, apply core_inj' h, unfold subset' at H₁ H₂, rw[eq_top_iff] at H₁ H₂ ⊢,\n      from subset_ext ‹_› ‹_›\n    end}\n\nlocal attribute [instance] subset'_partial_order\n\nlemma subset'_trans {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} {h : core u S} : by haveI := subset'_partial_order h; from ∀ a b c : α, a ≤ b → b ≤ c → a ≤ c :=\n  by apply partial_order.le_trans\n\nlemma subset'_unfold {u : bSet 𝔹} {α : Type u} {S : α → bSet 𝔹} {h : core u S} {a₁ a₂ : α} :\n  by {haveI := subset'_partial_order h, from a₁ ≤ a₂ → (S a₁ ⊆ᴮ S a₂ = ⊤)} := by tidy\n\n@[reducible]def exists_mem (x : bSet 𝔹) : 𝔹 := ⨆ (y : bSet 𝔹), y ∈ᴮ x\n\n@[reducible]def not_empty (x : bSet 𝔹) : 𝔹 := - (x =ᴮ ∅)\n\n-- note: nonempty means \"not empty\"\nlemma exists_mem_of_nonempty (u : bSet 𝔹) {Γ : 𝔹} (H : Γ ≤ -(u =ᴮ ∅)) : Γ ≤ ⨆x, x∈ᴮ u :=\nby {apply le_trans H, simp[eq_empty], intro x, apply bv_use (u.func x), apply mem.mk'}\n\nlemma nonempty_of_exists_mem (u : bSet 𝔹) {Γ : 𝔹} (H : Γ ≤ (⨆x, x ∈ᴮ u)) : Γ ≤ -(u =ᴮ ∅) :=\nbegin\n  {apply le_trans H, simp[eq_empty], intro x, rw[mem_unfold], apply bv_Or_elim, intro i, apply bv_use i, apply inf_le_left}\nend\n\nlemma nonempty_iff_exists_mem {u : bSet 𝔹} {Γ : 𝔹} : Γ ≤ -(u =ᴮ ∅) ↔ Γ ≤ ⨆x, x ∈ᴮ u :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { exact exists_mem_of_nonempty _ ‹_› },\n    { exact nonempty_of_exists_mem _ ‹_› }\nend\n\nlemma empty_iff_forall_not_mem {u : bSet 𝔹} {Γ : 𝔹} : Γ ≤ u=ᴮ ∅ ↔ Γ ≤ ⨅ x, -(x ∈ᴮ u) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { apply bv_by_contra, bv_imp_intro H_contra, simp only with bv_push_neg at H_contra,\n      rw ←nonempty_iff_exists_mem at H_contra, bv_contradiction },\n    { apply bv_by_contra, bv_imp_intro H_contra, rw nonempty_iff_exists_mem at H_contra,\n      rw ←neg_supr at H, bv_contradiction }\nend\n\nlemma core_aux_lemma3 (u : bSet 𝔹) (h_nonempty : -(u =ᴮ ∅) = ⊤) {α : Type u} (S : α → bSet 𝔹) (h_core : core u S) : ∀ x, ∃ y ∈ S '' set.univ, x =ᴮ y = x ∈ᴮ u :=\nbegin\n  intro x, have := core_aux_lemma (λ z, z∈ᴮu) (by intros; apply subst_congr_mem_left)\n    (by {apply top_unique, apply exists_mem_of_nonempty, simpa}) x,\n    rcases this with ⟨y, ⟨H₁, H₂⟩⟩, cases h_core with H_left H_right,\n    specialize H_right y H₁, cases H_right with y' H_y',\n    use S y', specialize H_left y', split, use y', finish,\n    dsimp at H₁ H₂, rw[H₂], cases H_y', have := bv_rw H_y'_left (λ z, x =ᴮ z),\n    simpa[bv_eq_symm] using this, intros x₁ y₁, dsimp, rw[inf_comm], exact bv_eq_trans\nend\n\nlemma core_mem_of_mem_image {u y} {α : Type u} {S : α → bSet 𝔹} (h_core : core u S) :\n  y ∈ S '' set.univ → y ∈ᴮ u = ⊤ := by tidy\n\nend cores\n\nsection check_names\n/- `check` is the canonical embedding of pSet into bSet.\nnote that a check-name is not only definite, but recursively definite\n-/\n@[simp]def check : (pSet.{u}) → bSet 𝔹\n| ⟨α,A⟩ := ⟨α, λ a, check (A a), λ a, ⊤⟩\n\npostfix `̌ `:8999 := check\n\n@[simp, cleanup]lemma check_type {α : Type u} {A : α → pSet} :\n  bSet.type ((pSet.mk α A)̌  : bSet 𝔹) = α := rfl\n\n@[simp, cleanup]lemma check_type_infi {α : Type u} {A : α → pSet} {s : α → 𝔹} :\n  (⨅(a : bSet.type ((pSet.mk α A)̌  : bSet 𝔹)), s a) = (⨅(a : α), s a : 𝔹) :=\nby refl\n\n@[simp, cleanup]lemma check_type_supr {α : Type u} {A : α → pSet} {s : α → 𝔹} :\n(⨆(a : bSet.type ((pSet.mk α A)̌   : bSet 𝔹)), s a) = (⨆(a : α), s a : 𝔹) := rfl\n\n@[simp, cleanup]lemma pSet.type_mk {α : Type u} {A : α → pSet} : pSet.type (pSet.mk α A) = α\n:= rfl\n\n@[simp, cleanup]lemma check_type' {x : pSet.{u}} : bSet.type (x̌ : bSet 𝔹) = x.type :=\nby {induction x, simp}\n\n@[simp, cleanup]lemma check_type'_set {x : pSet} : set (bSet.type (x̌ : bSet 𝔹)) = set (x.type) :=\nby {induction x, simp}\n\n@[reducible, simp]def check_cast {x : pSet} (i : (x̌ : bSet 𝔹).type) : x.type :=\ncast check_type' i\n\n@[reducible, simp]def check_cast.symm {x : pSet} (i : x.type) : (x̌ : bSet 𝔹).type :=\ncast check_type'.symm i\n\n@[reducible, simp] def check_cast_set {x : pSet} (S : set (x̌ : bSet 𝔹).type) : set (x.type) :=\ncast check_type'_set S\n\nlemma check_func {x : pSet} {i} :\n  (x̌ : bSet 𝔹).func i = (x.func (check_cast i))̌  :=\nby induction x; refl\n\nlemma check_unfold {x : pSet.{u}} : (x̌ : bSet 𝔹) = bSet.mk x.type (λ i, (x.func i)̌ ) (λ i, ⊤) :=\nby induction x; refl\n\n@[simp]lemma check_bval_top (x : pSet) {i} : (x̌ : bSet 𝔹).bval i = ⊤ := by induction x; refl\n\n@[simp]lemma check_bval_mk {α : Type u} {A : α → pSet} {i} : ((pSet.mk α A)̌ ).bval i = (⊤ : 𝔹) := rfl\n\n@[simp]lemma check_empty_eq_empty : (∅ : pSet)̌ = (∅ : bSet 𝔹) :=\nby {change mk _ _ _ = mk _ _ _, congr, tidy}\n\n -- this is essentially a restatement of mem.mk/mem.mk', but will be useful later\n@[simp]lemma mem_top_of_bval_top {u : bSet 𝔹} {i : u.type} {H_top : u.bval i = ⊤} : u.func i ∈ᴮ u = ⊤ :=\nby {apply top_unique, rw[<-H_top], apply mem.mk'}\n\n@[simp]lemma check_mem_top {x : pSet} {i : (x̌ : bSet 𝔹).type} : (x̌).func i ∈ᴮ x̌ = ⊤ :=\nby simp\n\n/--\nTODO(jesse): this name should really belong to check_mem instead\n-/\n@[simp]lemma mem_check_of_mem {x : pSet} {i : x.type} {Γ : 𝔹} : Γ ≤ ((x.func i) ̌) ∈ᴮ (x̌) :=\nbegin\n  rw[mem_unfold], apply bv_use (check_cast.symm i),\n  simp only [true_and, type, le_inf_iff, bval, le_top, func, check,\n             check_cast.symm, check_bval_top],\n  convert bv_refl, cases x, refl\nend\n\nlemma check_bv_eq_top_of_equiv {x y : pSet} :\n  pSet.equiv x y → x̌ =ᴮ y̌ = (⊤ : 𝔹) :=\nbegin\n  induction x generalizing y, cases y,\n  dsimp[check, bv_eq], simp only [pSet.equiv, lattice.top_le_iff, bSet.check,\n  lattice.top_inf_eq, lattice.imp_top_iff_le, lattice.inf_eq_top_iff, lattice.infi_eq_top],\n  intros a, cases a, split; intro i;\n  apply top_unique; [rcases a_left i with ⟨w, h⟩, rcases a_right i with ⟨w,h⟩];\n  apply le_supr_of_le w; simp only [lattice.top_le_iff, bSet.check]; apply (x_ih _); exact h\nend\n\n-- deprecated, use check_eq\nlemma check_bv_eq {x y : pSet} {Γ : 𝔹}  (H : pSet.equiv x y) :\n    (Γ : 𝔹) ≤ x̌ =ᴮ y̌ :=\nle_trans (le_top) $ by {simp only [top_le_iff], apply check_bv_eq_top_of_equiv ‹_›}\n\nlemma check_eq {x y : pSet} {Γ : 𝔹}  (H : pSet.equiv x y) :\n    (Γ : 𝔹) ≤ x̌ =ᴮ y̌ := check_bv_eq H\n\n-- deprecated, use check_not_eq\nlemma check_bv_eq_bot_of_not_equiv {x y : pSet} :\n  (¬ pSet.equiv x y) → (x̌ =ᴮ y̌) = (⊥ : 𝔹) :=\nbegin\n  induction x generalizing y, cases y, dsimp[check], intro H, apply bot_unique,\n  cases pSet.not_equiv H with H H; cases H with w H_w;\n  [apply inf_le_left_of_le, apply inf_le_right_of_le]; apply infi_le_of_le (w); simp[-le_bot_iff];\n  intro a'; rw[le_bot_iff]; apply x_ih; apply H_w\nend\n\nlemma check_bv_eq_dichotomy (x y : pSet) :\n  (x̌ =ᴮ y̌ = (⊤ : 𝔹)) ∨ (x̌ =ᴮ y̌ = (⊥ : 𝔹)) :=\nbegin\n  haveI : decidable (pSet.equiv x y) := by apply classical.prop_decidable,\n  by_cases pSet.equiv x y; [left, right];\n  [apply check_bv_eq_top_of_equiv, apply check_bv_eq_bot_of_not_equiv]; assumption\nend\n\nlemma check_bv_eq_iff {x y : pSet}\n: pSet.equiv x y ↔ x̌ =ᴮ y̌ = (⊤ : 𝔹) :=\nbegin\n  induction x generalizing y, cases y,\n  dsimp[check, bv_eq], simp only [pSet.equiv, lattice.top_le_iff, bSet.check,\n    lattice.top_inf_eq, lattice.imp_top_iff_le, lattice.inf_eq_top_iff, lattice.infi_eq_top],\n  fsplit,\n  work_on_goal 0 { intros a, cases a, fsplit, work_on_goal 0 { intros i },\n  work_on_goal 1 { intros i } }, work_on_goal 2 { intros a, cases a, fsplit,\n  work_on_goal 0 { intros a}}, work_on_goal 3 {intros b},\n  {apply top_unique, rcases a_left i with ⟨w, h⟩,  apply le_supr_of_le w,\n   simp only [lattice.top_le_iff, bSet.check], apply (x_ih _).mp, exact h},\n  {apply top_unique, rcases a_right i with ⟨w, h⟩,  apply le_supr_of_le w,\n   simp only [lattice.top_le_iff, bSet.check], apply (x_ih _).mp, exact h},\n   all_goals{have := supr_eq_top_max, cases this with w h, use w, apply (x_ih _).mpr, apply h,\n   exact nontrivial.bot_lt_top}, apply a_left, work_on_goal 1 {apply a_right},\n   all_goals{intros a' H, have := check_bv_eq_dichotomy (x_A ‹x_α›) (y_A ‹y_α›), tidy}\nend\n\nlemma not_check_bv_eq_iff {x y : pSet} : ¬ pSet.equiv x y ↔ x̌ =ᴮ y̌ = (⊥ : 𝔹) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { exact check_bv_eq_bot_of_not_equiv ‹_› },\n    { intro H_equiv, have := check_bv_eq_top_of_equiv ‹_›,\n      suffices this : ⊥ < (⊥ : 𝔹), by exact lt_irrefl' this,\n      rw[this] at H, conv{to_rhs, rw[<-H]}, simp }\nend\n\nlemma check_not_eq {x y : pSet.{u}} (H : ¬ pSet.equiv x y) {Γ : 𝔹} : Γ ≤ -(x̌ =ᴮ y̌) :=\nby {rw[not_check_bv_eq_iff.mp H], simp}\n\nlemma check_bv_eq_nonzero_iff_eq_top {x y : pSet} : (⊥ : 𝔹) < x̌ =ᴮ y̌  ↔ x̌ =ᴮ y̌ = (⊤ : 𝔹) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { by_contra, finish[or.resolve_left (check_bv_eq_dichotomy x y) ‹_›] },\n    { simp* }\nend\n\nlemma check_eq_reflect {x y : pSet} {Γ : 𝔹} (H_lt : ⊥ < Γ) (H_mem : Γ ≤ x̌ =ᴮ y̌) : pSet.equiv x y  :=\nbegin\n  have := check_bv_eq_nonzero_iff_eq_top.mp (lt_of_lt_of_le H_lt H_mem),\n  rwa ←check_bv_eq_iff at this\nend\n\n@[simp]lemma check_insert (a b : pSet) : (pSet.insert a b)̌  = (bSet.insert1 (ǎ) (b̌) : bSet 𝔹) :=\nby {induction a, induction b, simp[pSet.insert, bSet.insert1], split; ext; cases x; simp}\n\nlemma mem_check_witness {y x : pSet.{u}} {Γ : 𝔹} (h_nonzero : ⊥ < Γ) (H : Γ ≤ y̌ ∈ᴮ (x̌)) : ∃ i : x.type, Γ ≤ y̌ =ᴮ (x.func i)̌  :=\nbegin\n  rw[mem_unfold] at H, simp at H,\n  have := supr_eq_Gamma_max _ _ _, cases this with w h,\n  use w, tactic.rotate 3, from λ a, (y̌ : bSet 𝔹) =ᴮ (x.func a)̌, from Γ,\n  from ‹_›, cases x, from H, swap, from ‹_›,\n  intros a H, by_contra,\n  cases (@check_bv_eq_dichotomy 𝔹 _ y (pSet.func x a)),\n    { finish },\n    { contradiction }\nend\n\nlemma check_mem_iff {x y : pSet} : x ∈ y ↔ x̌ ∈ᴮ y̌ = (⊤ : 𝔹) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { cases y, unfold has_mem.mem pSet.mem at H,\n      cases H with b Hb, rw[<-top_le_iff], apply bv_use b,\n      refine le_inf (by refl) (by rwa[top_le_iff, <-check_bv_eq_iff]) },\n    { cases y, rw[<-top_le_iff] at H, replace H := mem_check_witness (by simp) H,\n      cases H with b Hb, exact ⟨b, by rwa[top_le_iff, <-check_bv_eq_iff] at Hb⟩}\nend\n\nlemma not_check_mem_iff {x y : pSet} : x ∉ y ↔ x̌ ∈ᴮ y̌ = (⊥ : 𝔹) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { rw[<-le_bot_iff, mem_unfold], rw[supr_le_iff],\n      intro i, tidy_context, cases y, unfold has_mem.mem pSet.mem at H, push_neg at H,\n      have := check_bv_eq_bot_of_not_equiv (H i), convert a_right, exact this.symm },\n    { intro this, replace this := check_mem_iff.mp this,\n      suffices this : ⊥ < (⊥ : 𝔹), by exact lt_irrefl' this,\n      rw[this] at H, conv{to_rhs, rw[<-H]}, simp }\nend\n\n-- TODO(jesse): refactor this so that the conclusion is simply Γ ≤ ¬ (x̌ ∈ᴮ y̌)\nlemma check_not_mem {x y : pSet} : x ∉ y → ∀ {Γ : 𝔹}, Γ ≤ x̌ ∈ᴮ y̌ → Γ ≤ ⊥ :=\nby {intro H, replace H := not_check_mem_iff.mp H, intros Γ HΓ, rwa ←H}\n\nlemma check_mem_dichotomy (x y : pSet) : (x̌ ∈ᴮ y̌ = (⊤ : 𝔹)) ∨ (x̌ ∈ᴮ y̌ = (⊥ : 𝔹)) :=\nbegin\n  haveI := classical.prop_decidable, by_cases (x ∈ y);\n  {[smt] eblast_using [check_mem_iff, not_check_mem_iff]}\nend\n\nlemma check_mem_nonzero_iff_eq_top {x y : pSet} : (⊥ : 𝔹) < x̌ ∈ᴮ y̌  ↔ x̌ ∈ᴮ y̌ = (⊤ : 𝔹) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { by_contra, finish[or.resolve_left (check_mem_dichotomy x y) ‹_›] },\n    { simp* }\nend\n\nlemma check_mem_reflect {x y : pSet} {Γ : 𝔹} (H_lt : ⊥ < Γ) (H_mem : Γ ≤ (x̌ : bSet 𝔹) ∈ᴮ y̌) : x ∈ y :=\nbegin\n  have := check_mem_nonzero_iff_eq_top.mp (lt_of_lt_of_le H_lt H_mem),\n  rwa ←check_mem_iff at this\nend\n\n@[simp]lemma check_mem {x y : pSet} {Γ} (h_mem : x ∈ y) : (Γ : 𝔹) ≤ x̌ ∈ᴮ y̌ :=\nbegin\n  rw[mem_unfold], cases y, unfold has_mem.mem pSet.mem at h_mem,\n  cases h_mem with w_y H_w_y, apply bv_use w_y,\n  apply le_inf, simp, from check_bv_eq ‹_›\nend\n\n@[simp]lemma check_subset_of_subset {x y : pSet} (h_subset : x ⊆ y) : (⊤ : 𝔹) ≤ x̌ ⊆ᴮ y̌ :=\nbegin\n  rw[subset_unfold], unfold has_subset.subset pSet.subset at h_subset,\n  bv_intro x_j, bv_imp_intro H_x_j, cases x with α A, cases y with β B,\n  rcases (h_subset ‹_›) with ⟨b , Hb⟩,\n  apply bv_use b, convert (check_bv_eq ‹_›), simpa[check_func]\nend\n\nlemma check_subset {x y : pSet} {Γ : 𝔹} (h_subset : x ⊆ y) : Γ ≤ x̌ ⊆ᴮ y̌ :=\n  le_trans le_top (check_subset_of_subset ‹_›)\n\nlemma check_not_subset {x y : pSet} (H : ¬ x ⊆ y) {Γ} : (Γ : 𝔹) ≤ -(x̌ ⊆ᴮ y̌) :=\nbegin\n  rw[subset_unfold], simp only with bv_push_neg,\n  rw pSet.subset_iff_all_mem at H, push_neg at H,\n  rcases H with ⟨z,Hz₁,Hz₂⟩, rw pSet.mem_unfold at Hz₁,\n  cases Hz₁ with j Hj, apply bv_use (check_cast.symm j),\n  refine le_inf (by simp) _, rw ←imp_bot, bv_imp_intro H,\n  apply check_not_mem Hz₂, change _ ≤ (λ w, w ∈ᴮ y̌) _, apply bv_rw' (check_eq Hj),\n  simp, cases x, exact H\nend\n\n@[simp]lemma check_exists_mem {y : pSet} (H_exists_mem : ∃ z, z ∈ y ) {Γ : 𝔹} : Γ ≤ exists_mem y̌ :=\nby { rcases H_exists_mem with ⟨z,Hz⟩, apply bv_use ž, simp* }\n\n-- note(jesse): this lemma is not true; one also requires that x is a check-name\n-- lemma definite_mem_definite_iff_of_subset_check {x y : bSet 𝔹} (H_definite₁ : is_definite x) (H_definite₂ : is_definite y) (H_sub : ∃ z : pSet, ⊤ ≤ y ⊆ᴮ ž)  : ⊤ ≤ x ∈ᴮ y ↔ ∃ j : y.type, ⊤ ≤ x =ᴮ y.func j :=\n-- begin\n--   refine ⟨_,_⟩; intro H,\n--     { rw[mem_unfold] at H, haveI := classical.prop_decidable, by_contra H', push_neg at H',\n--       simp only [lt_top_iff_not_top_le.symm] at H',\n--       suffices this : (⨆ (i : type y), bval y i ⊓ x =ᴮ func y i) ≤ ⊥,\n--         by {rw[le_bot_iff] at this, rw[this] at H, convert H, simp, },\n--       replace H := (by refl : (⨆ (i : type y), bval y i ⊓ x =ᴮ func y i) ≤ ⨆ (i : type y), bval y i ⊓ x =ᴮ func y i),\n--       bv_cases_at H j, specialize H' j,\n--       suffices this : x =ᴮ func y j ≤ ⊥,\n--         by {transitivity bval y j ⊓ x =ᴮ func y j, from ‹_›, rw[le_bot_iff] at this, simp[this]},\n--       sorry\n--     },\n--     { cases H with j Hj, rw[mem_unfold], apply bv_use j, exact le_inf (by {unfold is_definite at H_definite₂, simp* }) (Hj) }\n-- end\n\n-- lemma instantiate_existential_over_check\n-- {ϕ : bSet 𝔹 → 𝔹} (H_congr : B_ext ϕ) (x : pSet) {Γ} (H_nonzero : ⊥ < Γ) (H_ex : Γ ≤ ⨆y, (y ∈ᴮ (x̌) ⊓ ϕ (y))) :\n--   ∃ (Γ' : 𝔹) (H_nonzero : ⊥ < Γ') (H : Γ' ≤ Γ) (z) (H_mem : z ∈ x), Γ' ≤ ϕ (ž) :=\n-- begin\n--   rw[<-@bounded_exists] at H_ex, swap, by change B_ext _; simpa,\n--   cases (nonzero_inf_of_nonzero_le_supr H_nonzero H_ex) with i Hi,\n--   refine ⟨_, Hi, _, _, _, _⟩,\n--     { tidy_context },\n--     { exact (x.func (cast (by cases x; refl) i)) },\n--     { convert pSet.mem.mk _ _, simp, },\n--     { tidy_context, cases x, exact a_right_right }\n-- end\n\nlemma instantiate_existential_over_check_aux {ϕ : bSet 𝔹 → 𝔹} (H_congr : B_ext ϕ) (x : pSet) {Γ} (H_nonzero : ⊥ < Γ) (H_ex : Γ ≤ ⨆y, (y ∈ᴮ (x̌) ⊓ ϕ (y))) : ∃ i : x.type, ⊥ < (ϕ ((x.func i)̌ ) ⊓ Γ) :=\nbegin\n  simp only [inf_comm],\n  rw[<-@bounded_exists] at H_ex, swap, by change B_ext _; simpa,\n  cases (nonzero_inf_of_nonzero_le_supr H_nonzero H_ex) with i Hi,\n  refine ⟨cast check_type' i,_⟩, dsimp at Hi, rw[check_bval_top _, top_inf_eq] at Hi,\n  cases x, exact Hi\nend\n\nnoncomputable def instantiate_existential_over_check\n{ϕ : bSet 𝔹 → 𝔹} (H_congr : B_ext ϕ) (x : pSet) {Γ} (H_nonzero : ⊥ < Γ) (H_ex : Γ ≤ ⨆y, (y ∈ᴮ (x̌) ⊓ ϕ (y))) : x.type :=\nbegin\n  apply @classical.some _ (λ i : x.type, ⊥ < ϕ ((x.func i)̌ ) ⊓ Γ),\n  apply instantiate_existential_over_check_aux; from ‹_›\nend\n\nlemma instantiate_existential_over_check_spec {ϕ : bSet 𝔹 → 𝔹} (H_congr : B_ext ϕ) (x : pSet) {Γ} (H_nonzero : ⊥ < Γ) (H_ex : Γ ≤ ⨆y, (y ∈ᴮ (x̌) ⊓ ϕ (y))) :\n ⊥ < (ϕ ((x.func $ instantiate_existential_over_check ‹_› x ‹_› ‹_›)̌ ) ⊓ Γ) :=\n   by {unfold instantiate_existential_over_check, exact classical.some_spec (instantiate_existential_over_check_aux H_congr x H_nonzero ‹_›)}\n\nlemma instantiate_existential_over_check_spec₂ (ϕ : bSet 𝔹 → 𝔹) (H_congr : B_ext ϕ) (x : pSet) {Γ} (H_nonzero : ⊥ < Γ) (H_ex : Γ ≤ ⨆y, (y ∈ᴮ (x̌) ⊓ ϕ (y))) :\n  ⊥ < (ϕ ((x.func $ instantiate_existential_over_check ‹_› x ‹_› ‹_›)̌ )) :=\nbot_lt_resolve_right H_nonzero (instantiate_existential_over_check_spec ‹_› x ‹_› ‹_›)\n\n/--\n  This corresponds to Property 4 in Moore's The method of forcing\n-/\n\n-- we really need the stronger version\nlemma eq_check_of_mem_check {Γ : 𝔹} (h_nonzero : ⊥ < Γ) {x : pSet.{u}} {y : bSet 𝔹} (H_mem : Γ ≤ y ∈ᴮ x̌) :\n  ∃ (i : x.type) (Γ' : 𝔹) (H_nonzero : ⊥ < Γ') (H_le : Γ' ≤ Γ), Γ' ≤ y =ᴮ (x.func i)̌  :=\nbegin\n  let ϕ : bSet 𝔹 → 𝔹 := λ z, y =ᴮ z,\n  let H_congr : B_ext ϕ := (by simp),\n  have H_ex : Γ ≤ ⨆ (y : bSet 𝔹), y ∈ᴮ x̌  ⊓ ϕ y,\n    by {apply bv_use y, from le_inf ‹_› bv_refl},\n  let i : x.type := instantiate_existential_over_check H_congr x ‹_› H_ex,\n    refine  ⟨i,y =ᴮ (x.func i)̌  ⊓ Γ,_,inf_le_right,inf_le_left⟩,\n    { exact instantiate_existential_over_check_spec H_congr _ ‹_› H_ex }\nend\n\nlemma eq_check_of_mem_check₂ {Γ : 𝔹} (h_nonzero : ⊥ < Γ) (x : pSet.{u}) (y : bSet 𝔹) (H_mem : Γ ≤ y ∈ᴮ x̌) :\n  ∃ i : x.type, ⊥ < y =ᴮ (x.func i)̌  :=\n  -- ∃ Γ' (H_le : Γ' ≤ Γ) (z) (H_mem : z ∈ x), (Γ' ≤ y =ᴮ ž) :=\nbegin\n  rcases (eq_check_of_mem_check ‹_› ‹_›) with ⟨i, Γ', HΓ'₁, HΓ'₂, HΓ'₃⟩,\n  use i, from lt_of_lt_of_le HΓ'₁ ‹_›\nend\n\nend check_names\n\nsection collect\nvariables\n(ϕ : bSet 𝔹 → bSet 𝔹 → 𝔹) (h_congr_right : ∀ x y z, x =ᴮ y ⊓ ϕ z x ≤ ϕ z y) (h_congr_left : ∀ x y z, x =ᴮ y ⊓ ϕ x z ≤ ϕ y z) (u : bSet 𝔹)\ninclude ϕ h_congr_right h_congr_left u\n\nnoncomputable def collect.func : u.type → bSet 𝔹 :=\nclassical.some $ (classical.axiom_of_choice (AE_convert u.func u.bval ϕ (by { intros z x y, exact h_congr_right x y z })))\n\nlemma collect.func_spec (Γ : 𝔹) (H : Γ ≤ ⨅ (j : type u), bval u j ⟹ ⨆ (z : bSet 𝔹), ϕ (func u j) z) : Γ ≤ ⨅ x : u.type, bval u x ⟹ ϕ (func u x) (collect.func ϕ h_congr_right h_congr_left u x) :=\nbegin\n  bv_intro i, bv_imp_intro Hi, let p := (collect.func._proof_1 ϕ h_congr_right u), have := classical.some_spec p,\n  specialize this i,\n  exact poset_yoneda_inv Γ_1 this ‹_› ‹_›\nend\n\nnoncomputable def collect : bSet 𝔹 := ⟨u.type, collect.func ϕ h_congr_right h_congr_left u, u.bval⟩\n\nlemma collect_spec₁ {Γ : 𝔹} (H_AE : Γ ≤ ⨅ i : u.type, u.bval i ⟹ ⨆ w, ϕ (u.func i) w) :\n  Γ ≤ ⨅ z, z ∈ᴮ u ⟹ ⨆ w, w ∈ᴮ collect ϕ h_congr_right h_congr_left u ⊓ ϕ z w :=\nbegin\n  bv_intro z, bv_imp_intro Hz_mem, rw mem_unfold at Hz_mem,\n  bv_cases_at Hz_mem i Hi, bv_split, apply bv_use (collect.func ϕ ‹_› ‹_› u i),\n  refine le_inf _ _,\n    { unfold collect, rw mem_unfold, apply bv_use i, simp* },\n    { apply bv_rw' Hi_right, {intros x y, solve_by_elim},\n      exact collect.func_spec ϕ ‹_› ‹_› u Γ_2 ‹_› i ‹_› }\nend\n\nlemma collect_spec₂ {Γ : 𝔹} (H_AE : Γ ≤ ⨅ i : u.type, u.bval i ⟹ ⨆ w, ϕ (u.func i) w) :\n  Γ ≤ ⨅ w, w ∈ᴮ collect ϕ h_congr_right h_congr_left u ⟹ ⨆ z, z ∈ᴮ u ⊓ ϕ z w :=\nbegin -- TODO(jesse):  prove mem_collect_iff\n  bv_intro w, bv_imp_intro Hw_mem, rw mem_unfold at Hw_mem, bv_cases_at Hw_mem i Hi,\n  apply bv_use (u.func i), bv_split, apply bv_rw' Hi_right,\n    { refine B_ext_inf _ _,\n      { simp },\n      { intros x y, solve_by_elim }},\n    { refine le_inf _ _,\n      { apply mem.mk'', from ‹_› },\n      { exact collect.func_spec ϕ ‹_› ‹_› u Γ_2 ‹_› i ‹_› }}\nend\nend collect\n\n-- /-- The (strong) axiom of collection says that for every ϕ(x,y),\n--     for every set u, ∀ x ∈ u, ∃ y ϕ (x,y) implies there exists a set v\n--     such that ∀ x ∈ u, ∃ y ∈ v, ϕ (x,y) and all elements of v are obtained\n--     from an element x in this way. With the other axioms,\n--     this is equivalent to the usual axiom of replacement. -/\ntheorem bSet_axiom_of_collection (ϕ : bSet 𝔹 → bSet 𝔹 → 𝔹)\n  (h_congr_right : ∀ x y z, x =ᴮ y ⊓ ϕ z x ≤ ϕ z y)\n  (h_congr_left : ∀ x y z, x =ᴮ y ⊓ ϕ x z ≤ ϕ y z) :\n  ⊤ ≤ ⨅u, (⨅x, x ∈ᴮ u ⟹ ⨆y, ϕ x y) ⟹ ⨆v, (⨅w, w ∈ᴮ u ⟹ ⨆w', w' ∈ᴮ v ⊓ ϕ w w') ⊓\n    ⨅w', w' ∈ᴮ v ⟹ ⨆w, w ∈ᴮ u ⊓ ϕ w w' :=\nbegin\n  bv_intro u, bv_imp_intro,\n  refine le_supr_of_le (collect ϕ h_congr_right h_congr_left u) _,\n  have : Γ ≤ ⨅ (i : type u), bval u i ⟹ ⨆ (w : bSet 𝔹), ϕ (func u i) w,\n  { bv_intro i, bv_imp_intro, exact H (func u i) (mem.mk'' ‹_›) },\n  apply le_inf,\n  { apply collect_spec₁, exact this },\n  { apply collect_spec₂, exact this }\nend\n\n/-- The boolean-valued unionset operator -/\ndef bv_union (u : bSet 𝔹) : bSet 𝔹 :=\n  ⟨Σ(i : u.type), (u.func i).type, λ x, (u.func x.1).func x.2,\n       λ x, ⨆(y : u.type), u.bval y ⊓ (u.func x.1).func x.2 ∈ᴮ (u.func y)⟩\n\nlemma func_cast {u x : bSet 𝔹} {i_y : u.type} {α : Type u} {A : α → bSet 𝔹} {B : α → 𝔹} {h : func u i_y = mk α A B} {i_x' : α} : func (func u i_y) (eq.mpr (by rw[h]; refl) i_x') = A i_x' :=\nbegin\n  change _ = (mk α A B).func i_x',\n  have : func (mk α A B) (eq.mpr rfl i_x') = func (mk α A B) i_x', by refl,\n  convert this\nend\n\nlemma bv_union_spec (u : bSet 𝔹) : ⊤ ≤ ⨅ (x : bSet 𝔹), (x ∈ᴮ bv_union u ⟹ ⨆ (y : type u), u.bval y ⊓ x ∈ᴮ func u y) ⊓\n        ((⨆ (y : type u), u.bval y ⊓ x ∈ᴮ func u y) ⟹ x ∈ᴮ bv_union u) :=\nbegin\n  bv_intro x, apply le_inf,\n    {simp only [bv_union, lattice.top_le_iff, lattice.imp_top_iff_le,\n     sigma.forall, lattice.supr_le_iff], apply bv_Or_elim, rintro ⟨a,i⟩, apply bv_cases_left,\n     intro a', apply bv_use a', simp only [inf_assoc],\n    apply inf_le_inf, refl, rw[inf_comm,bv_eq_symm], apply B_ext_mem_left},\n    {simp only [lattice.top_le_iff, bSet.bval, bSet.mem, mem_unfold,\n               lattice.imp_top_iff_le, bSet.func, bSet.type, lattice.supr_le_iff, bv_union],\n     intro i, dsimp, apply bv_cases_right, intro i_1, fapply bv_use, use i, from i_1,\n     apply le_inf,\n       {apply bv_use i, apply inf_le_inf, refl, apply bv_use i_1,\n       apply inf_le_inf, apply refl, simp[bv_eq_refl]},\n       {rw[<-inf_assoc], apply inf_le_right_of_le, refl}},\nend\n\nlemma bv_union_spec' (u : bSet 𝔹) {Γ} : Γ ≤ ⨅ (x : bSet 𝔹), (x ∈ᴮ bv_union u ⟹ ⨆ y, y ∈ᴮ u ⊓ x ∈ᴮ y) ⊓\n        ((⨆ y, y ∈ᴮ u ⊓ x ∈ᴮ y) ⟹ x ∈ᴮ bv_union u) :=\nbegin\n  have := bv_union_spec u,\n  bv_intro x, apply le_inf,\n    replace this := this x, bv_split_at this,\n    from le_trans (le_top) (by {bv_imp_intro, replace this_left := this_left ‹_›,\n    bv_cases_at this_left i_y, apply bv_use (u.func i_y), bv_split,\n    from le_inf (mem.mk'' ‹_›) ‹_›}),\n  replace this := this x, bv_split_at this,\n  bv_imp_intro, specialize_context_at this_right Γ_1,\n  replace this_1_1 := this_right _, from ‹_›,\n  rw[@bounded_exists 𝔹 _ u (λ z, x ∈ᴮ z)], from ‹_›,\n  change B_ext _, simp\nend\n\nlemma bv_union_spec_split (u : bSet 𝔹) {Γ} (x : bSet 𝔹) : (Γ ≤ x ∈ᴮ bv_union u) ↔ (Γ ≤ ⨆ y, y ∈ᴮ u ⊓ x ∈ᴮ y) :=\nbegin\n  have := bv_union_spec' u, show 𝔹, from Γ, replace this := this x,\n  dsimp at this, bv_split_at this, split; intro, from this_left ‹_›,\n  from this_right ‹_›\nend\n\nlemma mem_bv_union_iff {u : bSet 𝔹} {Γ} {x : bSet 𝔹} : (Γ ≤ x ∈ᴮ bv_union u) ↔ (Γ ≤ ⨆ y, y ∈ᴮ u ⊓ x ∈ᴮ y) :=\nby apply bv_union_spec_split\n\n/-- For every x ∈ u, x ⊆ᴮ ⋃ u.-/\nlemma bv_union_spec'' (u : bSet 𝔹) : ⊤ ≤ ⨅(x : bSet 𝔹), (x ∈ᴮ u) ⟹ (x ⊆ᴮ bv_union u) :=\nbegin\n  bv_intro x, rw[<-deduction], simp[subset_unfold], intro i_v, rw[<-deduction, inf_comm],\n  apply le_trans, apply inf_le_inf, apply mem.mk', refl,\n  have := bv_union_spec u,\n  apply bv_have, apply le_trans, apply le_top, exact this,\n  apply bv_specialize_right (x.func i_v), rw[inf_comm],\n  ac_change (func x i_v ∈ᴮ bv_union u ⟹ ⨆ (y : type u), u.bval y ⊓ func x i_v ∈ᴮ func u y) ⊓\n        (((⨆ (y : type u), u.bval y ⊓ func x i_v ∈ᴮ func u y) ⟹ func x i_v ∈ᴮ bv_union u) ⊓\n      (func x i_v ∈ᴮ x ⊓ x ∈ᴮ u)) ≤\n    func x i_v ∈ᴮ bv_union u, apply inf_le_right_of_le,\n    suffices : (func x i_v ∈ᴮ x ⊓ x ∈ᴮ u) ≤ (⨆ (y : type u), bval u y ⊓ func x i_v ∈ᴮ func u y),\n      by {apply le_trans, apply inf_le_inf, refl, exact this, apply bv_imp_elim},\n    conv in (x ∈ᴮ u) {simp only [mem_unfold]}, apply bv_cases_right, intro y,\n    apply bv_use y,\n    ac_change bval u y ⊓ (func x i_v ∈ᴮ x ⊓ x =ᴮ func u y) ≤ u.bval y ⊓ (func x i_v ∈ᴮ func u y),\n    apply inf_le_inf, refl, rw[inf_comm], apply subst_congr_mem_right\nend\n\nlemma bv_union_congr {x y : bSet 𝔹} {Γ} (H_eq : Γ ≤ x =ᴮ y) : Γ ≤ bv_union x =ᴮ bv_union y :=\nbegin\n  apply mem_ext; bv_intro z; bv_imp_intro,\n    have := bv_union_spec x z, bv_split,\n    specialize_context_at this_left Γ_1,\n    specialize_context_at this_right Γ_1,\n    replace this_left := this_left H,\n    have := bv_union_spec y z, bv_split,\n    specialize_context_at this_left_1 Γ_1,\n    specialize_context_at this_right_1 Γ_1,\n    replace this_right_1 := this_right_1 _, from ‹_›,\n    rw[@bounded_exists 𝔹 _ y (λ w, z ∈ᴮ w)],\n    rw[@bounded_exists 𝔹 _ x (λ w, z ∈ᴮ w)] at this_left,\n    bv_cases_at this_left w, bv_split_at this_left_2,\n    apply bv_use w, apply le_inf,\n    apply bv_rw' (bv_symm H_eq), simp, from ‹_›,\n    from ‹_›, change B_ext _, simp, change B_ext _, simp,\n\n    have := bv_union_spec y z, bv_split,\n    specialize_context_at this_left Γ_1,\n    specialize_context_at this_right Γ_1,\n    replace this_left := this_left H,\n    have := bv_union_spec x z, bv_split,\n    specialize_context_at this_left_1 Γ_1,\n    specialize_context_at this_right_1 Γ_1,\n    replace this_right_1 := this_right_1 _, from ‹_›,\n    rw[@bounded_exists 𝔹 _ x (λ w, z ∈ᴮ w)],\n    rw[@bounded_exists 𝔹 _ y (λ w, z ∈ᴮ w)] at this_left,\n    bv_cases_at this_left w, bv_split_at this_left_2,\n    apply bv_use w, apply le_inf,\n    apply bv_rw' (H_eq), simp, from ‹_›,\n    from ‹_›, change B_ext _, simp, change B_ext _, simp\nend\n\n@[simp]lemma B_congr_bv_union : B_congr (bv_union : bSet 𝔹 → bSet 𝔹) :=\nby apply bv_union_congr\n\ntheorem bSet_axiom_of_union : (⨅ (u : bSet 𝔹), (⨆v, ⨅x,\n  (x ∈ᴮ v ⇔ (⨆(y : u.type), u.bval y ⊓ x ∈ᴮ u.func y)))) = ⊤ :=\nbegin\n  simp only [bSet.mem, lattice.biimp, bSet.func, lattice.infi_eq_top, bSet.type],intro u,\n  apply top_unique, apply bv_use (bv_union u), exact @bv_union_spec 𝔹 _ u\nend\n\n@[simp]def set_of_indicator {u : bSet 𝔹} (f : u.type → 𝔹) : bSet 𝔹 :=\n  ⟨u.type, u.func, f⟩\n\n@[simp, cleanup]lemma set_of_indicator.type {u} {f} :\n  (@set_of_indicator 𝔹 _ u f).type = u.type := rfl\n\n@[simp, cleanup]lemma set_of_indicator.func {u} {f} {i}:\n  (@set_of_indicator 𝔹 _ u f).func i = u.func i := rfl\n\n@[simp, cleanup]lemma set_of_indicator.bval {u} {f} {i} :\n  (@set_of_indicator 𝔹 _ u f).bval i = f i := rfl\n\n-- @[reducible, simp]def set_of_indicator' {u : bSet 𝔹} (f : u.type → 𝔹) : bSet 𝔹 :=\n--   ⟨u.type, u.func, λ i, f i ⊓ u.bval i⟩\n\ndef bv_powerset (u : bSet 𝔹) : bSet 𝔹 :=\n⟨u.type → 𝔹, λ f, set_of_indicator f, λ f, set_of_indicator f ⊆ᴮ u⟩\n\nprefix `𝒫`:80 := bv_powerset\n\n-- def bv_powerset' (u : bSet 𝔹) : bSet 𝔹 :=\n-- ⟨u.type → 𝔹, λ f, set_of_indicator' f, λ f, ⊤⟩\n\n--TODO (jesse) try proving bv_powerset and bv_powerset' are equivalent\n\n-- example {u : bSet 𝔹} : bv_powerset u =ᴮ bv_powerset' u = ⊤ :=\n-- begin\n--   apply top_unique, apply le_trans, swap, apply bSet_axiom_of_extensionality,\n--   bv_intro z, apply le_inf; apply bv_imp_intro; simp[top_inf_eq],\n--   {unfold bv_powerset, dsimp, apply supr_le, intro f,\n--   unfold bv_powerset', simp, apply le_supr_of_le f,\n--    refine le_trans _ (by apply bSet_axiom_of_extensionality),\n--    bv_intro z',\n--    have := @bounded_forall _ _ (set_of_indicator f) (λ x, x ∈ᴮ u), dsimp[set_of_indicator] at this, simp[subset_unfold], rw[this],\n--    rw[deduction], apply infi_le_of_le z', rw[supr_imp_eq],\n--    apply bv_imp_intro, apply le_inf, apply bv_imp_intro,\n--    ac_change  (⨅ (i : type u), f i ⊓ z' =ᴮ func u i ⟹ z' ∈ᴮ u) ⊓ (z =ᴮ mk (type u) (func u) f ⊓ z' ∈ᴮ z) ≤ z' ∈ᴮ mk (type u) (func u) (λ (i : type u), f i ⊓ bval u i),\n--    apply le_trans, apply inf_le_inf, refl, apply subst_congr_mem_right,\n--    rw[inf_comm], rw[deduction], apply supr_le, intro i',\n--    rw[<-deduction], apply le_supr_of_le i', dsimp,\n--    repeat{apply le_inf}, apply inf_le_left_of_le, apply inf_le_left_of_le, refl,\n--    repeat{sorry}\n\n-- },\n--   {sorry}\n-- end\n\n\nlemma bSet_axiom_of_powerset' {Γ : 𝔹} (u : bSet 𝔹) : Γ ≤ ⨅(x : bSet 𝔹), x∈ᴮ 𝒫 u ⇔ ⨅(y : x.type), x.bval y ⟹ (x.func y ∈ᴮ u) :=\nbegin\n  bv_intro x, apply le_inf,\n  {apply le_trans le_top,\n   rw[<-deduction, top_inf_eq],\n   unfold bv_powerset, apply supr_le, intro χ,\n   suffices : ((set_of_indicator χ) ⊆ᴮ u ⊓ (x =ᴮ (set_of_indicator χ)) : 𝔹) ≤ x ⊆ᴮ u,\n     by {convert this, simp[subset_unfold]},\n   apply subst_congr_subset_left},\n  {apply le_trans le_top,\n    have := @bounded_forall _ _ x (λ y, (y ∈ᴮ u))\n      (by {intros x y, apply subst_congr_mem_left}), rw[this],\n  dsimp,\n  unfold bv_powerset, simp[subset_unfold], fapply le_supr_of_le,\n  from λ i, u.func i ∈ᴮ x,\n  have this' := @bounded_forall _ _ (set_of_indicator (λ y, (u.func y ∈ᴮ x))) (λ y, (y ∈ᴮ u))\n    (by {intros x y, apply subst_congr_mem_left}), dsimp at this', dsimp, rw[this'],\n  apply le_inf, bv_intro a', apply infi_le_of_le a', erw[supr_imp_eq],\n  bv_intro i_y, apply imp_le_of_left_right_le, swap, refl,\n  rw[inf_comm, bv_eq_symm], apply subst_congr_mem_left,\n\n  rw[bv_eq_unfold], apply le_inf,\n  {conv {to_rhs, dsimp[mem, bv_eq]}, have := @bounded_forall _ _ x (λ y, ⨆ (a' :    type u), func u a' ∈ᴮ x ⊓ y =ᴮ func u a'), rw[this], swap,\n  intros a₁ a₂, dsimp, rw[inf_supr_eq], apply supr_le, intro i,\n\n  apply le_supr_of_le i,\n  ac_change (a₂ =ᴮ a₁ ⊓  a₁ =ᴮ func u i) ⊓ func u i ∈ᴮ x ≤ func u i ∈ᴮ x ⊓ a₂ =ᴮ func u i,\n    rw[bv_eq_symm], ac_refl,\n\n  apply le_trans, apply inf_le_inf, apply bv_eq_trans, refl, rw[inf_comm],\n\n  {bv_intro a₁, dsimp, apply infi_le_of_le a₁, rw[<-deduction],\n   apply le_trans, apply bv_imp_elim', rw[inf_comm, deduction],\n   rw[mem_unfold], apply supr_le, intro i, rw[<-deduction],\n   apply le_supr_of_le i,\n   apply le_inf, rw[inf_assoc], apply inf_le_right_of_le,\n   apply subst_congr_mem_left,\n   ac_change a₁ =ᴮ func u i ⊓ (bval u i ⊓ a₁ ∈ᴮ x) ≤ a₁ =ᴮ func u i,\n   apply inf_le_left_of_le, refl}},\n\n   {have := @bounded_forall _ _ (set_of_indicator (λ y, func _ y ∈ᴮ x)) (λ y, y ∈ᴮ x),\n   erw[this], swap, simp[subst_congr_mem_left],\n   bv_intro a₁, apply infi_le_of_le a₁,\n   unfold set_of_indicator, dsimp[mem, bv_eq], rw[supr_imp_eq],\n   bv_intro i, apply from_empty_context,\n   rw[inf_comm, bv_eq_symm], simp[-bv_eq_symm,subst_congr_mem_left]}}\nend\n\ntheorem bSet_axiom_of_powerset : (⨅(u : bSet 𝔹), ⨆(v : _), ⨅(x : bSet 𝔹), x∈ᴮ v ⇔ ⨅(y : x.type), x.bval y ⟹ (x.func y ∈ᴮ u)) = ⊤:=\nbegin\n  apply top_unique, bv_intro u, apply bv_use (𝒫 u),\n  apply bSet_axiom_of_powerset'\nend\n\nlemma bv_powerset_spec {u x : bSet 𝔹} {Γ : 𝔹} : Γ ≤ x ⊆ᴮ u ↔ Γ ≤ x ∈ᴮ 𝒫 u :=\nbegin\n  have := bSet_axiom_of_powerset' u, show 𝔹, from Γ,\n  simp only [lattice.biimp] at this,\n  replace this := this x, bv_split, rw[subset_unfold],\n  fsplit; intro H; [from this_right ‹_›, from this_left ‹_›]\nend\n\nlemma mem_powerset_iff {u x : bSet 𝔹} {Γ : 𝔹} : Γ ≤ x ∈ᴮ (𝒫 u) ↔ Γ ≤ x ⊆ᴮ u :=\nbv_powerset_spec.symm\n\nlemma bv_powerset_congr {Γ : 𝔹} {x y : bSet 𝔹} : Γ ≤ x =ᴮ y → Γ ≤ 𝒫 x =ᴮ 𝒫 y :=\nbegin\n  intro H, apply mem_ext; bv_intro z; bv_imp_intro,\n  rw[<-bv_powerset_spec], apply bv_rw' (bv_symm H), simp,\n  rwa[bv_powerset_spec], rw[<-bv_powerset_spec],\n  apply bv_rw' H, simp, rwa[bv_powerset_spec]\nend\n\n@[simp]lemma set_of_indicator_mem.mk {x : bSet 𝔹} {i : x.type} {χ : x.type → 𝔹} {Γ} (H_Γ : Γ ≤ χ i) : Γ ≤ (x.func i) ∈ᴮ (set_of_indicator χ) :=\nby {rw[mem_unfold], apply bv_use i, exact le_inf H_Γ (bv_refl)}\n\n@[simp]lemma set_of_indicator_subset {x : bSet 𝔹} {χ : x.type → 𝔹} {Γ} (H_χ : ∀ i, χ i ≤ x.bval i) : Γ ≤ set_of_indicator χ ⊆ᴮ x :=\nbegin\n  rw[subset_unfold], bv_intro j, bv_imp_intro H,\n  simpa using le_trans (le_trans H (by solve_by_elim)) (mem.mk' _ _)\nend\n\n@[reducible, simp]def subset.mk {u : bSet 𝔹} (χ : u.type → 𝔹) : bSet 𝔹 :=\nset_of_indicator (λ i, χ i ⊓ (u.bval i))\n\n@[simp]lemma subset.mk_subset {u : bSet 𝔹} {χ : u.type → 𝔹} {Γ : 𝔹} : Γ ≤ subset.mk χ ⊆ᴮ u :=\nset_of_indicator_subset $ by simp\n\nlemma check_set_of_indicator_subset {x : pSet} {χ : x̌.type → 𝔹} {Γ} :\n  Γ ≤ set_of_indicator χ ⊆ᴮ x̌ :=\nset_of_indicator_subset $ by simp\n\ninstance subset_to_pi {z x y : bSet 𝔹} {Γ : 𝔹} : has_coe_to_fun (Γ ≤ x ⊆ᴮ y) :=\n{ F := λ H, (Γ ≤ z ∈ᴮ x → Γ ≤ z ∈ᴮ y),\n  coe := λ H₁ H₂, mem_of_mem_subset H₁ H₂ }\n\nlemma mem_set_of_indicator_iff {x : bSet 𝔹} {χ : x.type → 𝔹} {z : bSet 𝔹} {Γ : 𝔹} (H_χ : ∀ i, χ i ≤ x.bval i)\n : Γ ≤ z ∈ᴮ set_of_indicator χ  ↔ Γ ≤ ⨆(i : x.type), z =ᴮ (x.func i) ⊓ χ i :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { rw[mem_unfold] at H, bv_cases_at H i Hi, apply bv_use i,\n      exact le_inf (bv_and.right Hi) (bv_and.left Hi) },\n    { bv_cases_at H i Hi,\n      bv_split, apply bv_rw' Hi_left, simp, apply set_of_indicator_mem.mk, from ‹_› }\nend\n\nlemma mem_subset.mk_iff {x : bSet 𝔹} {χ : x.type → 𝔹} {z : bSet 𝔹} {Γ : 𝔹}\n  : Γ ≤ z ∈ᴮ subset.mk χ ↔ Γ ≤ ⨆ (i : x.type), z =ᴮ (x.func i) ⊓ (χ i ⊓ (x.bval i)) :=\nmem_set_of_indicator_iff $ by simp\n\n-- same as mem_subset.mk_iff, but with better ordering of terms on the RHS\nlemma mem_subset.mk_iff₂ {x : bSet 𝔹} {χ : x .type → 𝔹} {z : bSet 𝔹} {Γ : 𝔹}\n  : Γ ≤ z ∈ᴮ subset.mk χ ↔ Γ ≤ ⨆ (i : x.type), x.bval i ⊓ (z =ᴮ (x.func i) ⊓ χ i) :=\nby { rw mem_subset.mk_iff, congr' 3, ext, ac_refl }\n\n@[simp]lemma mem_of_mem_subset.mk {x : bSet 𝔹} {χ : x.type → 𝔹} {z} {Γ} (Hz : Γ ≤ z ∈ᴮ subset.mk χ) : Γ ≤ z ∈ᴮ x :=\nmem_of_mem_subset (subset.mk_subset) ‹_›\n\n/--\n For x an injective pSet and χ : x̌.type → 𝔹, ⊤ ≤ (x.func i) ∈ set_of_indicator χ iff χ i = ⊤.\n-/\nlemma check_mem_set_of_indicator_iff {x : pSet} (H_inj : ∀ i₁ i₂ : x.type, pSet.equiv (x.func i₁) (x.func i₂) → i₁ = i₂) (i : x.type) {χ : x̌.type → 𝔹} : (∀{Γ}, Γ ≤ (x.func i)̌  ∈ᴮ set_of_indicator χ) ↔ (∀ {Γ}, Γ ≤ χ (cast check_type'.symm i)) :=\nbegin\n  refine ⟨_,_⟩; intro H,\n    { intro Γ, have H' := @H Γ, bv_cases_at H' j, bv_split,\n\n      haveI := classical.prop_decidable, by_cases i = (cast check_type' j),\n        { subst h, convert H'_1_left, cases x, refl },\n        { replace H_inj := mt (H_inj i (cast check_type' j)) ‹_›,\n          have := check_bv_eq_bot_of_not_equiv ‹_›,\n          transitivity ⊥,\n            { rw[<-this], convert H'_1_right, cases x, refl },\n            { exact bot_le }}},\n    { intro Γ, specialize @H Γ, apply bv_use (cast check_type'.symm i),\n      cases x, exact le_inf ‹_› bv_refl }\nend\n\nlemma subset_of_pointwise_bounded {Γ : 𝔹} {x : bSet 𝔹} {p : x.type → 𝔹} {p' : x.type → 𝔹} (H_bd : ∀ i : x.type, p i ≤ p' i) : Γ ≤ set_of_indicator p ⊆ᴮ set_of_indicator p' :=\nbegin\n  simp[subset_unfold], intro i, bv_imp_intro, apply bv_use i,\n  from le_inf (le_trans H (by simp*)) bv_refl\nend\n\nlemma pointwise_bounded_of_check_subset_check {x : pSet} {p₁ p₂ : x̌.type → 𝔹} (H_inj : ∀ i₁ i₂ : x.type, pSet.equiv (x.func i₁) (x.func i₂) → i₁ = i₂)(H_eq : ∀ {Γ}, Γ ≤ (set_of_indicator p₁ ⊆ᴮ set_of_indicator p₂)) : ∀ i, p₁ i ≤ p₂ i :=\nbegin\n  intro i, have : (p₁ i) ≤ (set_of_indicator p₁ ⊆ᴮ set_of_indicator p₂) := H_eq,\n  unfold set_of_indicator at this, rw[subset_unfold] at this,\n  replace this := this i (by refl), refine le_trans this _,\n  simp[mem, bv_eq], intro j, haveI := classical.prop_decidable, by_cases i = j,\n    { subst h, simp },\n    { specialize H_inj (cast check_type' i) (cast check_type' j),\n      replace H_inj := mt H_inj,\n      suffices this : ¬pSet.equiv (pSet.func x (cast check_type' i)) (pSet.func x (cast check_type' j)),\n        by {refine inf_le_right_of_le _, convert bot_le,\n            convert check_bv_eq_bot_of_not_equiv ‹_›; cases x; simp; refl},\n      exact (H_inj (by cases x; from ‹_›))}\nend\n\nlemma pointwise_eq_of_eq_set_of_indicator {x : pSet} {p₁ p₂ : x̌.type → 𝔹} (H_inj : ∀ i₁ i₂ : x.type, pSet.equiv (x.func i₁) (x.func i₂) → i₁ = i₂) (H_eq : ∀ {Γ}, Γ ≤ (set_of_indicator p₁ =ᴮ set_of_indicator p₂)) : ∀ i, p₁ i = p₂ i :=\nbegin\n  rw[eq_iff_subset_subset] at H_eq, refine (λ i, le_antisymm _ _);\n    { apply pointwise_bounded_of_check_subset_check, from ‹_›,\n      intro Γ, specialize @H_eq Γ, bv_split, from ‹_› }\nend\n\nlemma set_of_indicator_eq_iff_pointwise_eq {x : pSet} {p₁ p₂ : x̌.type → 𝔹} (H_inj : ∀ i₁ i₂ : x.type, pSet.equiv (x.func i₁) (x.func i₂) → i₁ = i₂) :\n(∀ {Γ}, Γ ≤ (set_of_indicator p₁ =ᴮ set_of_indicator p₂)) ↔ (∀i, p₁ i = p₂ i)  :=\nbegin\n  refine ⟨_,_⟩,\n    { intro H_eq, apply pointwise_eq_of_eq_set_of_indicator; from ‹_› },\n    { intros H_eq Γ, rw[show p₁ = p₂, from funext H_eq], simp }\nend\n\nsection infinity\nlocal notation `ω` := pSet.omega\n\n@[simp]lemma check_omega_type : (ω̌ : bSet 𝔹).type = ulift ℕ := rfl\n@[simp]lemma check_omega_func : (ω̌: bSet 𝔹).func = λ x, check (pSet.of_nat x.down) := rfl\n\npostfix `̃ `:70 := pSet.of_nat -- i'm a bit skeptical of this notation\n\n@[simp, reducible]def axiom_of_infinity_spec (u : bSet 𝔹) : 𝔹 :=\n  (∅∈ᴮ u) ⊓ (⨅(i_x : u.type), ⨆(i_y : u.type), (u.func i_x ∈ᴮ u.func i_y))\n\n@[reducible]def contains_empty (u : bSet 𝔹) : 𝔹 := ∅ ∈ᴮ u\n\n@[reducible]def contains_succ (u : bSet 𝔹) : 𝔹 := (⨅(i_x : u.type), ⨆(i_y : u.type), (u.func i_x ∈ᴮ u.func i_y))\n\nlemma infinity_of_empty_succ {u : bSet 𝔹} {c} (h₁ : c ≤ contains_empty u)\n  (h₂ : c ≤ contains_succ u) : c ≤ axiom_of_infinity_spec u :=\nle_inf ‹_› ‹_›\n\nlemma contains_empty_check_omega : (⊤ : 𝔹) ≤ contains_empty (ω̌) :=\nby {dsimp[pSet.omega,check, contains_empty], apply bv_use (ulift.up nat.zero), simp[pSet.of_nat]}\n\nlemma contains_succ_check_omega : (⊤ : 𝔹) ≤ contains_succ (ω̌) :=\nbegin\n  bv_intro n, induction n, apply bv_use (ulift.up (n + 1)),\n  simp only [lattice.top_le_iff, bSet.check_omega_func, bSet.check,\n  bSet.mem, bSet.func, bSet.type], induction n; simp[pSet.of_nat, *]\nend\n\ntheorem bSet_axiom_of_infinity : (⨆(u : bSet 𝔹), axiom_of_infinity_spec u) = ⊤ :=\nbegin\n  apply top_unique, apply bv_use (ω̌), apply infinity_of_empty_succ,\n  exacts [contains_empty_check_omega, contains_succ_check_omega]\nend\n\n@[reducible]def omega := (ω̌ : bSet 𝔹)\n\n@[simp, cleanup]lemma omega_type : (omega : bSet 𝔹).type = ulift ℕ := rfl\n\n/-- The n-th von Neumann ordinal in bSet 𝔹 is just the check-name of the n-th von Neumann ordinal in pSet -/\n@[reducible]def of_nat : ℕ → bSet 𝔹 := λ n, (pSet.of_nat n)̌\n\n@[simp, cleanup]lemma omega_func {k} : (omega : bSet 𝔹).func k = of_nat k.down :=\nby refl\n\nlemma omega_definite {n : ℕ} {Γ : 𝔹} : Γ ≤ of_nat n ∈ᴮ omega :=\nbegin\nsuffices : of_nat n ∈ᴮ omega = (⊤ : 𝔹), from le_trans le_top (by rwa[top_le_iff]),\n  induction n, {apply top_unique, apply bv_use (ulift.up 0), simp},\n  {apply top_unique, apply bv_use (ulift.up (n_n + 1)), simp}\nend\n\nlemma of_nat_mem_omega {n : ℕ} {Γ : 𝔹} : Γ ≤ of_nat n ∈ᴮ omega := omega_definite\n\ninstance has_zero_bSet : has_zero (bSet 𝔹) := ⟨of_nat 0⟩\n\ninstance has_one_bSet : has_one (bSet 𝔹) := ⟨of_nat 1⟩\n\n@[reducible]def two : bSet 𝔹 := of_nat 2\n\nnotation `𝟚` := bSet.two\n\nlemma zero_eq_empty {Γ : 𝔹} : Γ ≤ 0 =ᴮ ∅ :=\nbegin\n  unfold has_zero.zero, unfold bSet.of_nat,\n  rw ←check_empty_eq_empty, apply check_eq, refl\nend\n\n@[simp]lemma zero_mem_one {Γ : 𝔹} : Γ ≤ 0 ∈ᴮ 1 :=\nby {unfold has_zero.zero, apply bv_use none, simp}\n\nlemma one_eq_singleton_zero {Γ : 𝔹} : Γ ≤ 1 =ᴮ {0} :=\nbegin\n  unfold has_one.one,\n  unfold singleton, unfold has_insert.insert,\n  change Γ ≤ (pSet.insert _ _)̌  =ᴮ _,\n  have := check_insert (0̃ ) (0̃ ),\n  rw this,\n  change _ ≤ bSet.insert1 0 0 =ᴮ bSet.insert1 0 ∅,\n  convert bv_refl, unfold has_zero.zero, unfold of_nat, unfold pSet.of_nat, rw check_empty_eq_empty\nend\n--TODO(jesse): add simp lemmas ensuing (0 : bSet 𝔹) is the simp normal form of (∅̌), (of_nat 0), etc\n\nlemma forall_empty {Γ : 𝔹} {ϕ : bSet 𝔹 → 𝔹} : Γ ≤ ⨅ x, x ∈ᴮ ∅ ⟹ ϕ x :=\nbegin\n  bv_intro x, bv_imp_intro H_mem, refine le_trans _ bot_le,\n  exact bot_of_mem_empty ‹_›\nend\n\n@[simp, cleanup]lemma omega_bval {k} : (omega : bSet 𝔹).bval k = ⊤ :=\nby refl\n\ntheorem bSet_axiom_of_infinity' :\n  (⊤ : 𝔹) ≤ (∅ ∈ᴮ omega) ⊓ (⨅x, x ∈ᴮ omega ⟹ ⨆y, y ∈ᴮ omega ⊓ x ∈ᴮ y) :=\nbegin\n  apply le_inf, apply contains_empty_check_omega,\n  rw [←bounded_forall],\n  rw [infi_congr], swap,\n  intro n, rw [←bounded_exists, omega_bval, top_imp,\n                @supr_congr _ _ _ (λ m, func omega n ∈ᴮ func omega m)],\n  intro m, rw [omega_bval, top_inf_eq],\n  { intros, apply subst_congr_mem_right },\n  { exact contains_succ_check_omega },\n  { change B_ext _, simp }\nend\n\nexample {w : bSet 𝔹} : let ϕ := λ x, ⨅ z, z ∈ᴮ w ⊓ z ⊆ᴮ x ⊓ x ⊆ᴮ z in B_ext ϕ :=\nby simp\n\nend infinity\n\ntheorem bSet_epsilon_induction (ϕ : bSet 𝔹 → 𝔹) (h_congr : ∀ x y, x =ᴮ y ⊓ ϕ x ≤ ϕ y) :\n  (⨅(x : bSet 𝔹), ((⨅(y : bSet 𝔹), y ∈ᴮ x ⟹ ϕ y) ⟹ ϕ x)) ⟹ (⨅(z : bSet 𝔹), ϕ z) = ⊤ :=\nbegin\n  apply top_unique, apply bv_imp_intro, rw[top_inf_eq],\n  bv_intro x, let b := _, change b ≤ _,\n  induction x with α A B ih, dsimp at *,\n  have : b ≤ ⨅(i_y:α), B i_y ⟹ ϕ (A i_y),\n    by {bv_intro i_y, specialize ih i_y, apply le_trans ih,\n    rw[<-deduction], apply inf_le_left},\n  have h := @bounded_forall _ _ (mk α A B) ϕ h_congr,\n  simp only with cleanup at h, rw[h] at this,\n  apply bv_have this,\n  have : b ≤ (⨅ (y : bSet 𝔹), (y) ∈ᴮ (mk α A B) ⟹ ϕ (y)) ⟹ ϕ (mk α A B),\n    by {apply bv_specialize (mk α A B), refl},\n  rw[deduction], apply le_trans this, rw[<-deduction], apply bv_imp_elim\nend\n\n-- the natural induction principle for bSet 𝔹 will always suffice where regularity/epsilon_induction are required\nlemma epsilon_induction {Γ} (ϕ : bSet 𝔹 → 𝔹) (h_congr : B_ext ϕ) (H_ih : ∀ x, Γ ≤ ((⨅(y : bSet 𝔹), y ∈ᴮ x ⟹ ϕ y) ⟹ ϕ x)) :\n∀ z, Γ ≤ ϕ z  :=\nbegin\n  have := bSet_epsilon_induction ϕ h_congr, rw[eq_top_iff] at this,\n  intro z,\n  have H_a : Γ ≤ (⨅ (x : bSet 𝔹), (⨅ (y : bSet 𝔹), y ∈ᴮ x ⟹ ϕ y) ⟹ ϕ x),\n  bv_intro x, specialize H_ih x, from ‹_›,\n  have := le_trans (le_top) this,\n  bv_imp_elim_at this H_a, bv_specialize_at H z, exact H_1\nend\n\n@[elab_as_eliminator]protected lemma rec_on' {C : bSet 𝔹 → Sort*} (y : bSet 𝔹) : (Π(x : bSet 𝔹), (Π(a : x.type), C (x.func a)) → C x) → C y :=\nby {induction y, intro IH, apply IH, from λ a, y_ih a ‹_›}\n\n@[elab_as_eliminator]protected lemma rec' {C : bSet 𝔹 → Sort*} : (Π(x : bSet 𝔹), (Π(a : x.type), C (x.func a)) → C x) → Π(y : bSet 𝔹), C y :=\nby {intro H, intro y, induction y with α A B, solve_by_elim}\n\nlemma regularity_aux (x : bSet 𝔹) {Γ : 𝔹} : Γ ≤ ⨅u, x ∈ᴮ u ⟹ (⨆y, y ∈ᴮ u ⊓ (⨅z', z' ∈ᴮ u ⟹ (-(z' ∈ᴮ y)))) :=\nbegin\n  apply bSet.rec_on' x, clear x, intros x IH,\n    bv_intro u, bv_imp_intro,\n    have := bv_em_aux Γ_1 (⨅z', z' ∈ᴮ u ⟹ (-(z' ∈ᴮ x))),\n    bv_or_elim_at this, apply bv_use x, from le_inf ‹_› ‹_›,\n    rw[neg_infi] at this.right, bv_cases_at this.right x_a,\n    rw[neg_imp] at this.right_1, bv_split,\n    rw[lattice.neg_neg] at this.right_1_right,\n    rw[mem_unfold] at this.right_1_right, bv_cases_at this.right_1_right a,\n    bv_split, have H_in : Γ_4 ≤ (func x a) ∈ᴮ u,\n    rw[bv_eq_symm] at this.right_1_right_1_right,\n    apply @bv_rw' 𝔹 _ _ _ _  this.right_1_right_1_right (λ z, z ∈ᴮ u) (by simp) _, from ‹_›,\n    from (le_trans (by {dsimp*, simp[inf_le_right_of_le]} : Γ_4 ≤ Γ) (IH a u)) ‹_›\nend\n\ntheorem bSet_axiom_of_regularity (x : bSet 𝔹) {Γ : 𝔹} (H : Γ ≤ -(x =ᴮ ∅)) : Γ ≤ (⨆y, y ∈ᴮ x ⊓ (⨅z', z' ∈ᴮ x ⟹ (-(z' ∈ᴮ y)))) :=\nbegin\n  rw nonempty_iff_exists_mem at H,\n  bv_cases_at H u Hu,\n  have : Γ_1 ≤ _ := (regularity_aux (u : bSet 𝔹)),\n  exact this x ‹_›\nend\n\n/-- ∃! x, ϕ x ↔ ∃ x ∀ y, ϕ(x) ⊓ ϕ (y) → y = x -/\n@[reducible]def bv_exists_unique (ϕ : bSet 𝔹 → 𝔹) : 𝔹 :=\n  ⨆(x:bSet 𝔹), (⨅(y : bSet 𝔹), ϕ y ⟹ (y =ᴮ x))\n\nlocal notation `⨆!` binders `, ` r:(scoped f, bv_exists_unique f) := r\n\nsection zorns_lemma\nopen classical zorn\n\nlemma B_ext_subset_or_subset_left (y : bSet 𝔹) : B_ext (λ x, x ⊆ᴮ y ⊔ y ⊆ᴮ x) := by simp\n\nlemma B_ext_subset_or_subset_right (x : bSet 𝔹) : B_ext (λ y, x ⊆ᴮ y ⊔ y ⊆ᴮ x) := by simp\n\nlemma forall_forall_reindex (ϕ : bSet 𝔹 → bSet 𝔹 → 𝔹) {h₁ : ∀ x, B_ext (λ y, ϕ x y)}\n  {h₂ : ∀ y, B_ext (λ x, ϕ x y)} {C : bSet 𝔹} :\n  (⨅(i₁:C.type), (C.bval i₁ ⟹ ⨅(i₂ : C.type), C.bval i₂ ⟹ ϕ (C.func i₁) (C.func i₂))) =\n  ⨅(w₁ w₂ : bSet 𝔹), w₁∈ᴮ C ⊓ w₂ ∈ᴮ C ⟹ ϕ w₁ w₂ :=\nbegin\n  have := @bounded_forall _ _ C (λ x, ⨅(i₂ : C.type), bval C i₂ ⟹ ϕ x (func C i₂)),\n  rw[this], dsimp at *, apply le_antisymm,\n  bv_intro w₁, bv_intro w₂, apply bv_specialize w₁, rw[<-deduction],\n  simp only [inf_assoc.symm], rw[deduction], apply le_trans, apply bv_imp_elim,\n  have := @bounded_forall _ _ C (λ z, ϕ w₁ z), rw[this], apply bv_specialize w₂,\n  apply bv_imp_intro, apply le_trans, apply bv_imp_elim, refl,\n  intros w₁ w₂, apply h₁, bv_intro w₁, apply infi_le_of_le w₁, apply bv_imp_intro,\n  have := @bounded_forall _ _ C (λ z, ϕ w₁ z), rw[this],\n  bv_intro w₂, apply bv_specialize_left w₂, apply bv_imp_intro, simp only [inf_assoc],\n  apply le_trans, apply bv_imp_elim, refl, intros w₁ w₂, apply h₁,\n  intros w₁ w₂, apply B_ext_infi, intro j,\n  apply B_ext_imp; simp*\nend\n\nlemma subset'_inductive (X : bSet 𝔹) (H : ⊤ ≤ (⨅y, (y ⊆ᴮ X ⊓ (⨅(w₁ : bSet 𝔹), ⨅(w₂ : bSet 𝔹),\n  w₁ ∈ᴮ y ⊓ w₂ ∈ᴮ y ⟹ (w₁ ⊆ᴮ w₂ ⊔ w₂ ⊆ᴮ w₁))) ⟹ (bv_union y ∈ᴮ X))) {α : Type*} {S : α → bSet 𝔹} (h_core : core X S) :\n   by {haveI := subset'_partial_order h_core, from ∀c:set α, @chain α (≤) c → ∃ub, ∀a∈c, a ≤ ub} :=\nbegin\n  intros C C_chain, let C' := bSet_of_core_set h_core C,\n  /- First, we show that C' is internally a chain -/\n  have H_internal_chain : ⊤ ≤ ⨅ i₁ : C'.type, C'.bval i₁ ⟹ ⨅ i₂ : C'.type, C'.bval i₂ ⟹ (C'.func i₁ ⊆ᴮ C'.func i₂ ⊔ C'.func i₂ ⊆ᴮ C'.func i₁),\n  by {simp[subset_unfold], intros i₁ i₂,\n  simp[chain, set.pairwise_on] at C_chain,\n  cases i₁ with i₁ H₁, cases i₂ with i₂ H₂,\n  specialize C_chain i₁ H₁ i₂ H₂,\n  haveI : decidable_eq α := λ _ _, prop_decidable _,\n  by_cases i₁ = i₂,\n    subst h, apply top_unique, apply le_sup_left_of_le,\n      bv_intro j, apply bv_imp_intro, rw[top_inf_eq], apply mem.mk',\n    specialize C_chain h, cases C_chain; apply top_unique;\n    [apply le_sup_left_of_le, apply le_sup_right_of_le];\n    have := subset'_unfold C_chain; rw[eq_top_iff] at this;\n    convert this using 1; simp only [subset_unfold]; refl},\n\n  have H_in_X : ⊤ ≤ ⨅(u : C'.type), C'.bval u ⟹ C'.func u ∈ᴮ X,\n    by {bv_intro i_u, rw[of_core_bval, top_imp], apply of_core_mem},\n    /- Show that ⋃C' is in X -/\n  have H_internal_ub_mem : ⊤ ≤ (bv_union C') ∈ᴮ X,\n    by {rw[le_infi_iff] at H, specialize H C', apply bv_context_apply H, apply le_inf,\n\n         {apply le_trans H_in_X, simp only [subset_unfold]},\n\n         {apply le_trans H_internal_chain,\n          rw[forall_forall_reindex (λ z₁ z₂, ((z₁ ⊆ᴮ z₂) ⊔ (z₂ ⊆ᴮ z₁) : 𝔹))]; simp}},\n /- Show that ⋃C' is an upper bound on C' in X -/\n  have H_internal_ub_spec : ⊤ ≤ ⨅(i_w : C'.type), C'.bval i_w ⟹ C'.func i_w ⊆ᴮ (bv_union C'),\n    by {have := bv_union_spec'' C', apply le_trans this,\n        have := @bounded_forall 𝔹 _ C' (λ w, w ⊆ᴮ bv_union C'), dsimp only at this, rw[this_1],\n        intros x y, rw[inf_comm, bv_eq_symm], apply subst_congr_subset_left},\n\n  have := core_witness h_core (bv_union C') (by {rw[eq_top_iff], exact H_internal_ub_mem}),\n  cases this with w w_property, use w, intros x_w' H_x_w', change S (x_w') ⊆ᴮ S w = ⊤,\n  apply top_unique, apply le_trans H_internal_ub_spec, apply bv_specialize, swap,\n  use x_w', from H_x_w', rw[of_core_bval, top_imp],\n  fapply bv_have, exact bv_union C' =ᴮ S w, rw[w_property], apply le_top,\n  apply subst_congr_subset_right\nend\n\n/- ∀ x, x ≠ ∅ ∧ ((∀ y, y ⊆ x ∧ ∀ w₁ w₂ ∈ y, w₁ ⊆ w₂ ∨ w₂ ⊆ w₁) → (⋃y) ∈ x)\n      → ∃ c ∈ x, ∀ z ∈ x, c ⊆ z → c = z -/\ntheorem bSet_zorns_lemma (X : bSet 𝔹) (H_nonempty : -(X =ᴮ ∅) = ⊤) (H : ⊤ ≤ (⨅y, (y ⊆ᴮ X ⊓ (⨅(w₁ : bSet 𝔹), ⨅(w₂ : bSet 𝔹),\n  w₁ ∈ᴮ y ⊓ w₂ ∈ᴮ y ⟹ (w₁ ⊆ᴮ w₂ ⊔ w₂ ⊆ᴮ w₁))) ⟹ (bv_union y ∈ᴮ X))) :\n  ⊤ ≤ (⨆c, c ∈ᴮ X ⊓ (⨅z, z ∈ᴮ X ⟹ (c ⊆ᴮ z ⟹ c =ᴮ z))) :=\nbegin\n  have := core.mk X, rcases this with ⟨α, ⟨S, h_core⟩⟩,\n  have H_zorn := exists_maximal_of_chains_bounded (subset'_inductive X H h_core) (by apply subset'_trans),\n  rcases H_zorn with ⟨c, H_c⟩, rcases h_core with ⟨h_core_l, h_core_r⟩,\n  have H_c_in_X := h_core_l c, apply bv_use (S c), rw[H_c_in_X],\n  rw[top_inf_eq], bv_intro x, apply bv_imp_intro, rw[top_inf_eq],\n  have := core_aux_lemma3 X H_nonempty S ⟨h_core_l, h_core_r⟩ x,\n  rcases this with ⟨y, ⟨H₁_y, H₂_y⟩⟩, rw[<-H₂_y], apply bv_imp_intro,\n  conv in (S c =ᴮ _) {rw[bv_eq_symm]},\n  suffices : x =ᴮ y ⊓ (S c ⊆ᴮ y) ≤ x =ᴮ S c,\n    by {apply le_trans, show 𝔹, from x =ᴮ y ⊓ S c ⊆ᴮ y,\n        apply le_inf, apply inf_le_left, apply B_ext_subset_right, from this},\n  suffices : S c ⊆ᴮ y ≤ y =ᴮ S c,\n    by {apply le_trans, apply inf_le_inf, refl, from this, apply bv_eq_trans},\n  let a := S c ⊆ᴮ y, have h_a_bot : a ⊓ (-a) = ⊥, by apply inf_neg_eq_bot,\n  have h_a_top : a ⊔ (-a) = ⊤, by apply sup_neg_eq_top,\n  let v := two_term_mixture a (-a) h_a_bot y (S c),\n  have claim_1 : v ∈ᴮ X = ⊤,\n    by {apply two_term_mixture_mem_top, from h_a_top, apply core_mem_of_mem_image ⟨‹_›,‹_›⟩ ‹_›,\n    from ‹_›},\n  have claim_2 : Σ' z : α, v =ᴮ S z = ⊤ := core_witness ⟨‹_›,‹_›⟩ v claim_1,\n  rcases claim_2 with ⟨z, H_z⟩,\n  have claim_3 : ⊤ ≤ S c ⊆ᴮ v,\n    by {apply two_term_mixture_subset_top, from ‹_›, refl},\n  have claim_4 : by haveI := subset'_partial_order ⟨h_core_l,h_core_r⟩; from c ≤ z,\n    by {apply top_unique, apply le_trans' claim_3, rw[<-H_z], apply B_ext_subset_right},\n  have claim_5 : S c =ᴮ S z = ⊤,\n    by {have : S z ⊆ᴮ S c = ⊤, apply H_c z claim_4,\n        apply top_unique, rw[eq_iff_subset_subset], apply le_inf,\n        rw[top_le_iff], from ‹_›, rw[<-this]},\n  change a ≤ _, apply le_trans, apply (mixing_lemma_two_term a (-a) ‹_› y (S c)).left,\n  change v =ᴮ _ ≤ _, rw[bv_eq_symm], apply le_trans', show 𝔹, from v =ᴮ S z, rw[H_z],\n  apply le_top, apply le_trans, apply bv_eq_trans, apply bv_have (le_top : y =ᴮ _ ≤ _),\n  rw[bv_eq_symm] at claim_5, simp[claim_5.symm, bv_eq_trans]\nend\nend zorns_lemma\n\nsection comprehension\nvariables (ϕ : bSet 𝔹 → 𝔹) (x : bSet 𝔹) (H_congr : B_ext ϕ)\n\n@[reducible]def comprehend : bSet 𝔹 := subset.mk (λ i : x.type, ϕ (x.func i))\n\ninclude ϕ x H_congr\n\nlemma mem_comprehend_iff : ∀ {z x : bSet 𝔹} {Γ}, Γ ≤ z ∈ᴮ comprehend ϕ x ↔ Γ ≤ ⨆ (i : x.type), x.bval i ⊓ (z =ᴮ (x.func i) ⊓ (λ i : x.type, ϕ (x.func i)) i) :=\nby intros; exact mem_subset.mk_iff₂\n\nlemma mem_comprehend_iff₂ : ∀ {z : bSet 𝔹} {Γ}, Γ ≤ z ∈ᴮ comprehend ϕ x ↔ Γ ≤ ⨆ w, w ∈ᴮ x ⊓ (z =ᴮ w ⊓ (λ v, ϕ v) w) :=\nbegin\n  intros z Γ, rw ←bounded_exists, apply mem_comprehend_iff, from z, from ‹_›,\n  change B_ext _, simp*\nend\n\nlemma B_congr_comprehend {ϕ} {H_congr : B_ext ϕ} : B_congr (λ x : bSet 𝔹, (comprehend ϕ x)) :=\nbegin\n  intros x y Γ H_eq, refine mem_ext _ _,\n    { bv_intro z, bv_imp_intro Hz, rw mem_comprehend_iff₂ at Hz ⊢,\n      apply bv_rw' (bv_symm H_eq), simp*, repeat { from ‹_› }  },\n    { bv_intro z, bv_imp_intro Hz, rw mem_comprehend_iff₂ at Hz ⊢,\n      apply bv_rw' H_eq, simp*, repeat { from ‹_› }  }\nend\n\nvariables {ϕ} {H_congr}\nlemma comprehend_subset {Γ : 𝔹} : Γ ≤ comprehend ϕ x ⊆ᴮ x :=\nbegin\n  rw subset_unfold', bv_intro z, bv_imp_intro Hz, rw mem_comprehend_iff₂ at Hz, bv_cases_at Hz w Hw, bv_split, bv_split, bv_cc, from ‹_›\nend\n\n/--\nFor any ϕ and x, there is a subset y of x such that ∀ z, z ∈ y ↔ z ∈ x ∧ ϕ z\n-/\n\nvariables (ϕ) (H_congr)\nlemma bSet_axiom_of_comprehension {Γ : 𝔹} : Γ ≤ ⨆ y, y ⊆ᴮ x ⊓ ⨅ z, z ∈ᴮ y ⇔ (z ∈ᴮ x ⊓ ϕ z) :=\nbegin\n  apply bv_use (comprehend ϕ x),\n  refine le_inf _ _,\n    { apply subset.mk_subset },\n    { bv_intro z, refine le_inf _ _,\n      { bv_imp_intro H, rw[mem_subset.mk_iff] at H, bv_cases_at H i Hi,\n        bv_split_at Hi, refine le_inf _ _,\n          { apply bv_rw' Hi_left, simp, apply mem.mk'', from bv_and.right Hi_right },\n          { apply bv_rw' Hi_left, simp*, from bv_and.left Hi_right }},\n      { bv_imp_intro H, rw[mem_subset.mk_iff₂],  rw @bounded_exists _ _ _ (λ w, z =ᴮ w ⊓ ϕ w),\n        swap, {change B_ext _, simp* /- nice job, simp! -/ },\n        apply bv_use z, exact le_inf (bv_and.left ‹_›) (le_inf bv_refl $ bv_and.right ‹_›) }}\nend\n\nend comprehension\n\n-- /-- This is the abbreviated version of AC found at http://us.metamath.org/mpeuni/ac3.html\n--     It is provably equivalent over ZF to the usual formulation of AC\n--     After we have the Boolean soundness theorem, we can transport the proof via completeness\n--     from the 2-valued setting to the 𝔹-valued setting -/\n-- -- ∀x ∃𝑦 ∀𝑧 ∈ 𝑥 (𝑧 ≠ ∅ → ∃!𝑤 ∈ 𝑧 ∃𝑣 ∈ 𝑦 (𝑧 ∈ 𝑣 ∧ 𝑤 ∈ 𝑣))\n-- theorem bSet_axiom_of_choice :\n-- (⨅(x : bSet 𝔹), ⨆(y : bSet 𝔹), ⨅(z : bSet 𝔹),\n--   z ∈ᴮ x ⟹ ((- (z =ᴮ ∅)) ⟹\n--   (⨆!(w : bSet 𝔹), w ∈ᴮ z ⟹\n--     ⨆(v : bSet 𝔹), v ∈ᴮ y ⟹ (z ∈ᴮ v ⊓ w ∈ᴮ v)))) = ⊤ := sorry\n\n-- def check_shadow : Π (x : bSet 𝔹), (bSet 𝔹)\n-- | (bSet.mk α A B) := ⟨α, λ i, check_shadow (A i), λ _, ⊤⟩\n\n-- lemma check_shadow_check : Π {x : pSet.{u}}, check_shadow (x̌) = (x̌ : bSet 𝔹)\n-- | ⟨α,A⟩ := by simp[check, check_shadow,check_shadow_check]\n\ndef dom : ∀ x : bSet 𝔹, pSet.{u}\n| ⟨α,A,B⟩ := ⟨α, λ i, dom (A i)⟩\n\n-- lemma dom_spec : Π {x : bSet 𝔹}, (dom x)̌  = check_shadow x\n-- | ⟨α,A,B⟩ := by simp[dom, check_shadow, *]\n\n@[reducible]def check_shadow : bSet 𝔹 → bSet 𝔹 := λ x, (dom x)̌\n\nlemma check_shadow_type {x : bSet 𝔹} : (check_shadow x).type = x.type := by cases x; refl\n\n@[reducible]def check_shadow_cast {x : bSet 𝔹} : (check_shadow x).type → x.type := cast check_shadow_type\n\n@[reducible]def check_shadow_cast_symm {x : bSet 𝔹} : x.type → (check_shadow x).type := cast (check_shadow_type.symm)\n\n-- bSet 𝔹 retracts onto pSet\nlemma dom_check : Π {x : pSet.{u}}, dom (x̌ : bSet 𝔹) = x\n| ⟨α,A⟩ := by simp[dom,*]\n\nlemma dom_left_inv_check : function.left_inverse dom (check : pSet.{u} → bSet 𝔹) :=\nλ x, dom_check\n\nlemma check_injective : function.injective (check : pSet.{u} → bSet 𝔹) :=\nfunction.injective_of_left_inverse dom_left_inv_check\n\n-- -- should follow from maximum principle + induction (every member of a dom is a dom)\n-- @[simp]lemma dom_congr : ∀ x y : bSet 𝔹, (∀ {Γ}, Γ ≤ x =ᴮ y) → pSet.equiv (dom x) (dom y)\n-- | x@⟨α,A,B⟩ x'@⟨α',A',B'⟩ H :=\n-- begin\n--   sorry\n-- end\n\n-- should follow from induction (every member of a check_shadow is a check_shadow)\n-- @[simp]lemma B_congr_check_shadow : B_congr (check_shadow : bSet 𝔹 → bSet 𝔹)\n-- | x@⟨α,A,B⟩ x'@⟨α',A',B'⟩ Γ H :=\n-- begin\n--   unfold check_shadow, rw[bv_eq_unfold] at H ⊢, refine le_inf _ _; bv_intro i; simp at ⊢ H; cases H with H H',\n--     { sorry },\n--     { sorry },\n-- end\n\nend bSet\n", "meta": {"author": "flypitch", "repo": "flypitch", "sha": "aea5800db1f4cce53fc4a113711454b27388ecf8", "save_path": "github-repos/lean/flypitch-flypitch", "path": "github-repos/lean/flypitch-flypitch/flypitch-aea5800db1f4cce53fc4a113711454b27388ecf8/src/bvm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6261241842048092, "lm_q1q2_score": 0.48837241835714573}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n\nDimension of modules and vector spaces.\n-/\nimport linear_algebra.basic\nimport linear_algebra.linear_map_module\nimport linear_algebra.prod_module\nimport linear_algebra.quotient_module\nimport set_theory.ordinal\nnoncomputable theory\n\nlocal attribute [instance] classical.prop_decidable\n\nuniverses u v w\nvariables {α : Type u} {β γ : Type v}\n\nnamespace vector_space\nvariables [field α] [vector_space α β]\n\nvariables (α β)\ndef dim : cardinal :=\ncardinal.min\n  (nonempty_subtype.2 (@exists_is_basis α β _ _))\n  (λ b, cardinal.mk b.1)\nvariables {α β}\n\ninclude α\ntheorem basis_le_span (I J : set β) (h1 : is_basis I) (h2 : ∀x, x ∈ span J) : cardinal.mk I ≤ cardinal.mk J :=\nor.cases_on (le_or_lt cardinal.omega $ cardinal.mk J)\n(assume h4 : cardinal.omega ≤ cardinal.mk J,\nle_of_not_lt $ assume h3 : cardinal.mk I > cardinal.mk J,\nlet h5 : J → set β := λ j, (h1.1.repr j).support.to_set in\nhave h6 : ¬I ⊆ ⋃ j, h5 j,\n  from λ H, @not_lt_of_le _ _ (cardinal.mk I) (cardinal.mk (⋃ j, h5 j))\n    (⟨set.embedding_of_subset H⟩) $\n  calc  cardinal.mk (⋃ j, h5 j)\n      ≤ cardinal.sum (λ j, cardinal.mk (h5 j)) : cardinal.mk_Union_le_sum_mk\n  ... ≤ cardinal.sum (λ j : J, cardinal.omega.{v}) : cardinal.sum_le_sum _ _ $ λ j,\n    le_of_lt $ cardinal.lt_omega_iff_finite.2 $ finset.finite_to_set _\n  ... = cardinal.mk J * cardinal.omega : cardinal.sum_const _ _\n  ... = max (cardinal.mk J) (cardinal.omega) : cardinal.mul_eq_max h4 (le_refl _)\n  ... = cardinal.mk J : max_eq_left h4\n  ... < cardinal.mk I : h3,\nlet ⟨i₀, h7⟩ := not_forall.1 h6 in\nlet ⟨h7, h8⟩ := not_imp.1 h7 in\nhave h9 : _ := λ j : J, not_exists.1 (mt set.mem_Union.2 h8) j,\nhave h9 : _ := λ j : J, by_contradiction $ mt (finsupp.mem_support_iff (h1.1.repr j) i₀).2 $ h9 j,\nlet ⟨h10, h11, h12⟩ := h2 i₀ in\nhave h13 : _ := (repr_eq_single h1.1 h7).symm.trans $\n  (congr_arg h1.1.repr h12).trans $\n  repr_finsupp_sum _ $ λ j _, h1.2 _,\nhave h14 : ((finsupp.single i₀ (1:α) : lc α β) : β → α) i₀ = _,\n  from congr_fun (congr_arg finsupp.to_fun h13) i₀,\nbegin\n  rw [finsupp.sum_apply, finsupp.single_eq_same, finsupp.sum] at h14,\n  rw [← finset.sum_subset (finset.empty_subset _), finset.sum_empty] at h14,\n  { exact zero_ne_one h14.symm },\n  intros v h15 h16,\n  have h17 := by_contradiction (mt (h11 v) ((finsupp.mem_support_iff _ _).1 h15)),\n  have h18 : (linear_independent.repr (h1.left) v) i₀ = 0 := h9 ⟨v, h17⟩,\n  rw [repr_smul h1.1 (h1.2 _), finsupp.smul_apply, h18, smul_eq_mul, mul_zero]\nend)\n(assume h4 : cardinal.mk J < cardinal.omega,\nlet ⟨h5, h6⟩ := exists_finite_card_le_of_finite_of_linear_independent_of_span\n  (cardinal.lt_omega_iff_finite.1 h4) h1.1 (λ _ _, h2 _) in\nby rwa [← cardinal.nat_cast_le, cardinal.finset_card, cardinal.finset_card, finset.coe_to_finset, finset.coe_to_finset] at h6)\n\n/-- dimension theorem -/\ntheorem mk_eq_mk_of_basis {I J : set β} (h1 : is_basis I) (h2 : is_basis J) : cardinal.mk I = cardinal.mk J :=\nle_antisymm (basis_le_span _ _ h1 h2.2) (basis_le_span _ _ h2 h1.2)\n\ntheorem mk_basis {b : set β} (h : is_basis b) : cardinal.mk b = dim α β :=\nbegin\n  cases (show ∃ b', dim α β = _, from cardinal.min_eq _ _) with b' e,\n  refine mk_eq_mk_of_basis h _,\n  generalize : classical.some _ = b1,\n  exact b1.2,\nend\n\nvariables [vector_space α γ]\n\ntheorem dim_eq_of_linear_equiv (f : β ≃ₗ γ) : dim α β = dim α γ :=\nlet ⟨b, hb⟩ := exists_is_basis β in\n(mk_basis hb).symm.trans $ (cardinal.mk_eq_of_injective f.to_equiv.bijective.1).symm.trans $\nmk_basis $ hb.linear_equiv\n\ntheorem dim_prod : dim α (β × γ) = dim α β + dim α γ :=\nlet ⟨b, hb⟩ := exists_is_basis β in\nlet ⟨c, hc⟩ := exists_is_basis γ in\nhave H1 : _ := prod.is_basis_inl_union_inr hb hc,\nhave H2 : _ := @mk_basis.{u v} _ (β × γ) _ _ _ H1,\nbegin\n  rw [← mk_basis hb, ← mk_basis hc, ← H2, cardinal.mk_union_of_disjiont],\n  rw [cardinal.mk_eq_of_injective prod.injective_inl.{v v}], \n  rw [cardinal.mk_eq_of_injective prod.injective_inr.{v v}],\n  intros z h,\n  rcases h with ⟨⟨x, h1, h2⟩, ⟨y, h3, h4⟩⟩,\n  subst h4,\n  cases prod.inl_eq_inr.1 h2 with h4 h5,\n  substs h4 h5,\n  exact zero_not_mem_of_linear_independent (@zero_ne_one α _) hb.1 h1\nend\n\ntheorem dim_quotient {s : set β} [is_submodule s] : dim α (quotient_module.quotient β s) + dim α s = dim α β :=\nnonempty.rec_on (quotient_module.quotient_prod_linear_equiv s) $ λ f,\ndim_prod.symm.trans $ dim_eq_of_linear_equiv f\n\n/-- rank-nullity theorem -/\ntheorem dim_im_add_dim_ker (f : linear_map β γ) : dim α f.im + dim α f.ker = dim α β :=\nby rw [← dim_eq_of_linear_equiv (linear_map.quot_ker_equiv_im f), dim_quotient]\n\nend vector_space\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/linear_algebra/dimension.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.48837241291552075}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module category_theory.category.Kleisli\n! leanprover-community/mathlib commit 70d50ecfd4900dd6d328da39ab7ebd516abe4025\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\n\nimport Mathlib.CategoryTheory.Category.Basic\n\n/-!\n# The Kleisli construction on the Type category\n\nDefine the Kleisli category for (control) monads.\n`CategoryTheory/Monad/Kleisli` defines the general version for a monad on `C`, and demonstrates\nthe equivalence between the two.\n\n## TODO\n\nGeneralise this to work with CategoryTheory.Monad\n-/\n\n\nuniverse u v\n\nnamespace CategoryTheory\n\n-- This file is about Lean 3 declaration \"Kleisli\".\nset_option linter.uppercaseLean3 false\n\n/-- The Kleisli category on the (type-)monad `m`. Note that the monad is not assumed to be lawful\nyet. -/\n@[nolint unusedArguments]\ndef KleisliCat (_ : Type u → Type v) :=\n  Type u\n#align category_theory.Kleisli CategoryTheory.KleisliCat\n\n/-- Construct an object of the Kleisli category from a type. -/\ndef KleisliCat.mk (m) (α : Type u) : KleisliCat m :=\n  α\n#align category_theory.Kleisli.mk CategoryTheory.KleisliCat.mk\n\ninstance KleisliCat.categoryStruct {m} [Monad.{u, v} m] :\n    CategoryStruct (KleisliCat m) where\n  Hom α β := α → m β\n  id _ x := pure x\n  comp f g := f >=> g\n#align category_theory.Kleisli.category_struct CategoryTheory.KleisliCat.categoryStruct\n\ninstance KleisliCat.category {m} [Monad.{u, v} m] [LawfulMonad m] : Category (KleisliCat m) := by\n  -- Porting note: was\n  -- refine' { id_comp' := _, comp_id' := _, assoc' := _ } <;> intros <;> ext <;> unfold_projs <;>\n  --  simp only [(· >=> ·), functor_norm]\n  refine' { id_comp := _, comp_id := _, assoc := _ } <;> intros <;> refine funext (fun x => ?_) <;>\n  simp [CategoryStruct.id, CategoryStruct.comp, (· >=> ·)]\n#align category_theory.Kleisli.category CategoryTheory.KleisliCat.category\n\n@[simp]\ntheorem KleisliCat.id_def {m} [Monad m] (α : KleisliCat m) : 𝟙 α = @pure m _ α :=\n  rfl\n#align category_theory.Kleisli.id_def CategoryTheory.KleisliCat.id_def\n\ntheorem KleisliCat.comp_def {m} [Monad m] (α β γ : KleisliCat m) (xs : α ⟶ β) (ys : β ⟶ γ) (a : α) :\n    (xs ≫ ys) a = xs a >>= ys :=\n  rfl\n#align category_theory.Kleisli.comp_def CategoryTheory.KleisliCat.comp_def\n\ninstance : Inhabited (KleisliCat id) :=\n  ⟨PUnit⟩\n\ninstance {α : Type u} [Inhabited α] : Inhabited (KleisliCat.mk id α) :=\n  ⟨show α from default⟩\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Category/KleisliCat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.48832964601242007}}
{"text": "def foo1mk (_ : ∀ (α : Type) (a : α), a = a) : Nat := 37\ndef foo2mk (_ : ∀ {α : Type} (a : α), a = a) : Nat := 37 -- implicit binder\n\nexample (x) : foo1mk x = foo1mk x := rfl -- works\nexample (x : ∀ {α : Type} (a : α), a = a) : 37 = foo2mk x := rfl -- works\nexample (x) : 37 = foo2mk @x := rfl -- works\nexample (x) : foo1mk x = foo1mk x := rfl -- works\nexample (x : ∀ {α : Type} (a : α), a = a) : foo2mk x = foo2mk x := rfl -- works\nexample (x) : foo2mk x = foo2mk x := rfl -- works\nexample (x) : foo2mk x = 37 := rfl -- works\nexample (x) : foo2mk x = foo2mk x := rfl  -- works\n\nuniverse u v w\n\nstructure ApplicativeTransformation (F : Type u → Type v) [Applicative F] [LawfulApplicative F]\n  (G : Type u → Type w) [Applicative G] [LawfulApplicative G] : Type max (u + 1) v w where\n  app : ∀ α : Type u, F α → G α\n  preserves_pure' : ∀ {α : Type u} (x : α), app _ (pure x) = pure x\n  preserves_seq' : ∀ {α β : Type u} (x : F (α → β)) (y : F α), app _ (x <*> y) = app _ x <*> app _ y\n\nvariable (F : Type u → Type v) [Applicative F] [LawfulApplicative F]\n\nvariable (G : Type u → Type w) [Applicative G] [LawfulApplicative G]\n\ninstance : CoeFun (ApplicativeTransformation F G) fun _ => ∀ {α}, F α → G α :=\n  ⟨ApplicativeTransformation.app⟩\n\nvariable {F G}\n\n@[simp]\ntheorem coe_mk (f : ∀ (α : Type u), F α → G α) (pp ps) :\n  (ApplicativeTransformation.mk f pp ps) = f :=\n  rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/implicitLambdaLocalWithoutType.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.4883296377293476}}
{"text": "/-\nCopyright (c) 2020 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport ring_theory.localization.away\nimport ring_theory.ideal.over\nimport ring_theory.jacobson_ideal\n\n/-!\n# Jacobson Rings\nThe following conditions are equivalent for a ring `R`:\n1. Every radical ideal `I` is equal to its Jacobson radical\n2. Every radical ideal `I` can be written as an intersection of maximal ideals\n3. Every prime ideal `I` is equal to its Jacobson radical\nAny ring satisfying any of these equivalent conditions is said to be Jacobson.\nSome particular examples of Jacobson rings are also proven.\n`is_jacobson_quotient` says that the quotient of a Jacobson ring is Jacobson.\n`is_jacobson_localization` says the localization of a Jacobson ring to a single element is Jacobson.\n`is_jacobson_polynomial_iff_is_jacobson` says polynomials over a Jacobson ring form a Jacobson ring.\n## Main definitions\nLet `R` be a commutative ring. Jacobson Rings are defined using the first of the above conditions\n* `is_jacobson R` is the proposition that `R` is a Jacobson ring. It is a class,\n  implemented as the predicate that for any ideal, `I.is_radical` implies `I.jacobson = I`.\n\n## Main statements\n* `is_jacobson_iff_prime_eq` is the equivalence between conditions 1 and 3 above.\n* `is_jacobson_iff_Inf_maximal` is the equivalence between conditions 1 and 2 above.\n* `is_jacobson_of_surjective` says that if `R` is a Jacobson ring and `f : R →+* S` is surjective,\n  then `S` is also a Jacobson ring\n* `is_jacobson_mv_polynomial` says that multi-variate polynomials over a Jacobson ring are Jacobson.\n## Tags\nJacobson, Jacobson Ring\n-/\n\nnamespace ideal\n\nopen polynomial\nopen_locale polynomial\n\nsection is_jacobson\nvariables {R S : Type*} [comm_ring R] [comm_ring S] {I : ideal R}\n\n/-- A ring is a Jacobson ring if for every radical ideal `I`,\n the Jacobson radical of `I` is equal to `I`.\n See `is_jacobson_iff_prime_eq` and `is_jacobson_iff_Inf_maximal` for equivalent definitions. -/\nclass is_jacobson (R : Type*) [comm_ring R] : Prop :=\n(out' : ∀ (I : ideal R), I.is_radical → I.jacobson = I)\n\ntheorem is_jacobson_iff {R} [comm_ring R] :\n  is_jacobson R ↔ ∀ (I : ideal R), I.is_radical → I.jacobson = I :=\n⟨λ h, h.1, λ h, ⟨h⟩⟩\n\ntheorem is_jacobson.out {R} [comm_ring R] :\n  is_jacobson R → ∀ {I : ideal R}, I.is_radical → I.jacobson = I := is_jacobson_iff.1\n\n/--  A ring is a Jacobson ring if and only if for all prime ideals `P`,\n the Jacobson radical of `P` is equal to `P`. -/\nlemma is_jacobson_iff_prime_eq : is_jacobson R ↔ ∀ P : ideal R, is_prime P → P.jacobson = P :=\nbegin\n  refine is_jacobson_iff.trans ⟨λ h I hI, h I hI.is_radical, _⟩,\n  refine λ h I hI, le_antisymm (λ x hx, _) (λ x hx, mem_Inf.mpr (λ _ hJ, hJ.left hx)),\n  rw [← hI.radical, radical_eq_Inf I, mem_Inf],\n  intros P hP,\n  rw set.mem_set_of_eq at hP,\n  erw mem_Inf at hx,\n  erw [← h P hP.right, mem_Inf],\n  exact λ J hJ, hx ⟨le_trans hP.left hJ.left, hJ.right⟩\nend\n\n/-- A ring `R` is Jacobson if and only if for every prime ideal `I`,\n `I` can be written as the infimum of some collection of maximal ideals.\n Allowing ⊤ in the set `M` of maximal ideals is equivalent, but makes some proofs cleaner. -/\nlemma is_jacobson_iff_Inf_maximal : is_jacobson R ↔\n  ∀ {I : ideal R}, I.is_prime → ∃ M : set (ideal R), (∀ J ∈ M, is_maximal J ∨ J = ⊤) ∧ I = Inf M :=\n⟨λ H I h, eq_jacobson_iff_Inf_maximal.1 (H.out h.is_radical),\n  λ H, is_jacobson_iff_prime_eq.2 (λ P hP, eq_jacobson_iff_Inf_maximal.2 (H hP))⟩\n\nlemma is_jacobson_iff_Inf_maximal' : is_jacobson R ↔\n  ∀ {I : ideal R}, I.is_prime → ∃ M : set (ideal R),\n  (∀ (J ∈ M) (K : ideal R), J < K → K = ⊤) ∧ I = Inf M :=\n⟨λ H I h, eq_jacobson_iff_Inf_maximal'.1 (H.out h.is_radical),\n  λ H, is_jacobson_iff_prime_eq.2 (λ P hP, eq_jacobson_iff_Inf_maximal'.2 (H hP))⟩\n\nlemma radical_eq_jacobson [H : is_jacobson R] (I : ideal R) : I.radical = I.jacobson :=\nle_antisymm (le_Inf (λ J ⟨hJ, hJ_max⟩, (is_prime.radical_le_iff hJ_max.is_prime).mpr hJ))\n            (H.out (radical_is_radical I) ▸ jacobson_mono le_radical)\n\n/-- Fields have only two ideals, and the condition holds for both of them.  -/\n@[priority 100]\ninstance is_jacobson_field {K : Type*} [field K] : is_jacobson K :=\n⟨λ I hI, or.rec_on (eq_bot_or_top I)\n(λ h, le_antisymm (Inf_le ⟨le_rfl, h.symm ▸ bot_is_maximal⟩) (h.symm ▸ bot_le))\n(λ h, by rw [h, jacobson_eq_top_iff])⟩\n\ntheorem is_jacobson_of_surjective [H : is_jacobson R] :\n  (∃ (f : R →+* S), function.surjective f) → is_jacobson S :=\nbegin\n  rintros ⟨f, hf⟩,\n  rw is_jacobson_iff_Inf_maximal,\n  intros p hp,\n  use map f '' {J : ideal R | comap f p ≤ J ∧ J.is_maximal },\n  use λ j ⟨J, hJ, hmap⟩, hmap ▸ (map_eq_top_or_is_maximal_of_surjective f hf hJ.right).symm,\n  have : p = map f (comap f p).jacobson :=\n    (is_jacobson.out' _ $ hp.is_radical.comap f).symm ▸ (map_comap_of_surjective f hf p).symm,\n  exact this.trans (map_Inf hf (λ J ⟨hJ, _⟩, le_trans (ideal.ker_le_comap f) hJ)),\nend\n\n@[priority 100]\ninstance is_jacobson_quotient [is_jacobson R] : is_jacobson (R ⧸ I) :=\nis_jacobson_of_surjective ⟨quotient.mk I, (by rintro ⟨x⟩; use x; refl)⟩\n\nlemma is_jacobson_iso (e : R ≃+* S) : is_jacobson R ↔ is_jacobson S :=\n⟨λ h, @is_jacobson_of_surjective _ _ _ _ h ⟨(e : R →+* S), e.surjective⟩,\n  λ h, @is_jacobson_of_surjective _ _ _ _ h ⟨(e.symm : S →+* R), e.symm.surjective⟩⟩\n\nlemma is_jacobson_of_is_integral [algebra R S] (hRS : algebra.is_integral R S)\n  (hR : is_jacobson R) : is_jacobson S :=\nbegin\n  rw is_jacobson_iff_prime_eq,\n  introsI P hP,\n  by_cases hP_top : comap (algebra_map R S) P = ⊤,\n  { simp [comap_eq_top_iff.1 hP_top] },\n  { haveI : nontrivial (R ⧸ comap (algebra_map R S) P) := quotient.nontrivial hP_top,\n    rw jacobson_eq_iff_jacobson_quotient_eq_bot,\n    refine eq_bot_of_comap_eq_bot (is_integral_quotient_of_is_integral hRS) _,\n    rw [eq_bot_iff, ← jacobson_eq_iff_jacobson_quotient_eq_bot.1 ((is_jacobson_iff_prime_eq.1 hR)\n      (comap (algebra_map R S) P) (comap_is_prime _ _)), comap_jacobson],\n    refine Inf_le_Inf (λ J hJ, _),\n    simp only [true_and, set.mem_image, bot_le, set.mem_set_of_eq],\n    haveI : J.is_maximal, { simpa using hJ },\n    exact exists_ideal_over_maximal_of_is_integral (is_integral_quotient_of_is_integral hRS) J\n      (comap_bot_le_of_injective _ algebra_map_quotient_injective) }\nend\n\nlemma is_jacobson_of_is_integral' (f : R →+* S) (hf : f.is_integral)\n  (hR : is_jacobson R) : is_jacobson S :=\n@is_jacobson_of_is_integral _ _ _ _ f.to_algebra hf hR\n\nend is_jacobson\n\n\nsection localization\nopen is_localization submonoid\nvariables {R S : Type*} [comm_ring R] [comm_ring S] {I : ideal R}\nvariables (y : R) [algebra R S] [is_localization.away y S]\n\nlemma disjoint_powers_iff_not_mem (hI : I.is_radical) :\n  disjoint ((submonoid.powers y) : set R) ↑I ↔ y ∉ I.1 :=\nbegin\n  refine ⟨λ h, set.disjoint_left.1 h (mem_powers _), λ h, disjoint_iff.mpr (eq_bot_iff.mpr _)⟩,\n  rintros x ⟨⟨n, rfl⟩, hx'⟩,\n  exact h (hI $ mem_radical_of_pow_mem $ le_radical hx')\nend\n\nvariables (S)\n\n/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`\ncorrespond to maximal ideals in the original ring `R` that don't contain `y`.\nThis lemma gives the correspondence in the particular case of an ideal and its comap.\nSee `le_rel_iso_of_maximal` for the more general relation isomorphism -/\nlemma is_maximal_iff_is_maximal_disjoint [H : is_jacobson R] (J : ideal S) :\n  J.is_maximal ↔ (comap (algebra_map R S) J).is_maximal ∧ y ∉ ideal.comap (algebra_map R S) J :=\nbegin\n  split,\n  { refine λ h, ⟨_, λ hy, h.ne_top (ideal.eq_top_of_is_unit_mem _ hy\n      (map_units _ ⟨y, submonoid.mem_powers _⟩))⟩,\n    have hJ : J.is_prime := is_maximal.is_prime h,\n    rw is_prime_iff_is_prime_disjoint (submonoid.powers y) at hJ,\n    have : y ∉ (comap (algebra_map R S) J).1 :=\n      set.disjoint_left.1 hJ.right (submonoid.mem_powers _),\n    erw [← H.out hJ.left.is_radical, mem_Inf] at this,\n    push_neg at this,\n    rcases this with ⟨I, hI, hI'⟩,\n    convert hI.right,\n    by_cases hJ : J = map (algebra_map R S) I,\n    { rw [hJ, comap_map_of_is_prime_disjoint (powers y) S I (is_maximal.is_prime hI.right)],\n      rwa disjoint_powers_iff_not_mem y hI.right.is_prime.is_radical },\n    { have hI_p : (map (algebra_map R S) I).is_prime,\n      { refine is_prime_of_is_prime_disjoint (powers y) _ I hI.right.is_prime _,\n        rwa disjoint_powers_iff_not_mem y hI.right.is_prime.is_radical },\n      have : J ≤ map (algebra_map R S) I :=\n        (map_comap (submonoid.powers y) S J) ▸ (map_mono hI.left),\n      exact absurd (h.1.2 _ (lt_of_le_of_ne this hJ)) hI_p.1 } },\n  { refine λ h, ⟨⟨λ hJ, h.1.ne_top (eq_top_iff.2 _), λ I hI, _⟩⟩,\n    { rwa [eq_top_iff, ← (is_localization.order_embedding (powers y) S).le_iff_le] at hJ },\n    { have := congr_arg (map (algebra_map R S)) (h.1.1.2 _ ⟨comap_mono (le_of_lt hI), _⟩),\n      rwa [map_comap (powers y) S I, map_top] at this,\n      refine λ hI', hI.right _,\n      rw [← map_comap (powers y) S I, ← map_comap (powers y) S J],\n      exact map_mono hI' } }\nend\n\nvariables {S}\n\n/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`\ncorrespond to maximal ideals in the original ring `R` that don't contain `y`.\nThis lemma gives the correspondence in the particular case of an ideal and its map.\nSee `le_rel_iso_of_maximal` for the more general statement, and the reverse of this implication -/\nlemma is_maximal_of_is_maximal_disjoint [is_jacobson R] (I : ideal R) (hI : I.is_maximal)\n  (hy : y ∉ I) : (map (algebra_map R S) I).is_maximal :=\nbegin\n  rw [is_maximal_iff_is_maximal_disjoint S y,\n    comap_map_of_is_prime_disjoint (powers y) S I (is_maximal.is_prime hI)\n    ((disjoint_powers_iff_not_mem y hI.is_prime.is_radical).2 hy)],\n  exact ⟨hI, hy⟩\nend\n\n/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`\ncorrespond to maximal ideals in the original ring `R` that don't contain `y` -/\ndef order_iso_of_maximal [is_jacobson R] :\n  {p : ideal S // p.is_maximal} ≃o {p : ideal R // p.is_maximal ∧ y ∉ p} :=\n{ to_fun := λ p,\n    ⟨ideal.comap (algebra_map R S) p.1, (is_maximal_iff_is_maximal_disjoint S y p.1).1 p.2⟩,\n  inv_fun := λ p,\n    ⟨ideal.map (algebra_map R S) p.1, is_maximal_of_is_maximal_disjoint y p.1 p.2.1 p.2.2⟩,\n  left_inv := λ J, subtype.eq (map_comap (powers y) S J),\n  right_inv := λ I, subtype.eq (comap_map_of_is_prime_disjoint _ _ I.1 (is_maximal.is_prime I.2.1)\n    ((disjoint_powers_iff_not_mem y I.2.1.is_prime.is_radical).2 I.2.2)),\n  map_rel_iff' := λ I I', ⟨λ h, (show I.val ≤ I'.val,\n    from (map_comap (powers y) S I.val) ▸ (map_comap (powers y) S I'.val) ▸ (ideal.map_mono h)),\n    λ h x hx, h hx⟩ }\n\ninclude y\n\n/-- If `S` is the localization of the Jacobson ring `R` at the submonoid generated by `y : R`, then\n`S` is Jacobson. -/\nlemma is_jacobson_localization [H : is_jacobson R] : is_jacobson S :=\nbegin\n  rw is_jacobson_iff_prime_eq,\n  refine λ P' hP', le_antisymm _ le_jacobson,\n  obtain ⟨hP', hPM⟩ := (is_localization.is_prime_iff_is_prime_disjoint (powers y) S P').mp hP',\n  have hP := H.out hP'.is_radical,\n  refine (is_localization.map_comap (powers y) S P'.jacobson).ge.trans\n    ((map_mono _).trans (is_localization.map_comap (powers y) S P').le),\n  have : Inf { I : ideal R | comap (algebra_map R S) P' ≤ I ∧ I.is_maximal ∧ y ∉ I } ≤\n    comap (algebra_map R S) P',\n  { intros x hx,\n    have hxy : x * y ∈ (comap (algebra_map R S) P').jacobson,\n    { rw [ideal.jacobson, mem_Inf],\n      intros J hJ,\n      by_cases y ∈ J,\n      { exact J.mul_mem_left x h },\n      { exact J.mul_mem_right y ((mem_Inf.1 hx) ⟨hJ.left, ⟨hJ.right, h⟩⟩) } },\n    rw hP at hxy,\n    cases hP'.mem_or_mem hxy with hxy hxy,\n    { exact hxy },\n    { exact (hPM.le_bot ⟨submonoid.mem_powers _, hxy⟩).elim } },\n  refine le_trans _ this,\n  rw [ideal.jacobson, comap_Inf', Inf_eq_infi],\n  refine infi_le_infi_of_subset (λ I hI, ⟨map (algebra_map R S) I, ⟨_, _⟩⟩),\n  { exact ⟨le_trans (le_of_eq ((is_localization.map_comap (powers y) S P').symm)) (map_mono hI.1),\n    is_maximal_of_is_maximal_disjoint y _ hI.2.1 hI.2.2⟩ },\n  { exact is_localization.comap_map_of_is_prime_disjoint _ S I (is_maximal.is_prime hI.2.1)\n    ((disjoint_powers_iff_not_mem y hI.2.1.is_prime.is_radical).2 hI.2.2) }\nend\n\nend localization\n\nnamespace polynomial\nopen polynomial\n\nsection comm_ring\nvariables {R S : Type*} [comm_ring R] [comm_ring S] [is_domain S]\nvariables {Rₘ Sₘ : Type*} [comm_ring Rₘ] [comm_ring Sₘ]\n\n/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,\n  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leading_coeff`.\n  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,\n  so integrality of the entire extension follows by closure under addition and multiplication. -/\nlemma is_integral_is_localization_polynomial_quotient\n  (P : ideal R[X]) (pX : R[X]) (hpX : pX ∈ P)\n  [algebra (R ⧸ P.comap (C : R →+* _)) Rₘ]\n  [is_localization.away (pX.map (quotient.mk (P.comap (C : R →+* R[X])))).leading_coeff Rₘ]\n  [algebra (R[X] ⧸ P) Sₘ]\n  [is_localization ((submonoid.powers (pX.map\n    (quotient.mk (P.comap (C : R →+* R[X])))).leading_coeff).map\n    (quotient_map P C le_rfl) : submonoid (R[X] ⧸ P)) Sₘ] :\n  (is_localization.map Sₘ (quotient_map P C le_rfl)\n    ((submonoid.powers\n      (pX.map (quotient.mk (P.comap (C : R →+* R[X])))).leading_coeff).le_comap_map) : Rₘ →+* _)\n    .is_integral :=\nbegin\n  let P' : ideal R := P.comap C,\n  let M : submonoid (R ⧸ P') :=\n  submonoid.powers (pX.map (quotient.mk (P.comap (C : R →+* R[X])))).leading_coeff,\n  let M' : submonoid (R[X] ⧸ P) :=\n  (submonoid.powers (pX.map (quotient.mk (P.comap (C : R →+* R[X])))).leading_coeff).map\n    (quotient_map P C le_rfl),\n  let φ : R ⧸ P' →+* R[X] ⧸ P := quotient_map P C le_rfl,\n  let φ' : Rₘ →+* Sₘ := is_localization.map Sₘ φ M.le_comap_map,\n  have hφ' : φ.comp (quotient.mk P') = (quotient.mk P).comp C := rfl,\n  intro p,\n  obtain ⟨⟨p', ⟨q, hq⟩⟩, hp⟩ := is_localization.surj M' p,\n  suffices : φ'.is_integral_elem (algebra_map _ _ p'),\n  { obtain ⟨q', hq', rfl⟩ := hq,\n    obtain ⟨q'', hq''⟩ := is_unit_iff_exists_inv'.1 (is_localization.map_units Rₘ (⟨q', hq'⟩ : M)),\n    refine φ'.is_integral_of_is_integral_mul_unit p (algebra_map _ _ (φ q')) q'' _ (hp.symm ▸ this),\n    convert trans (trans (φ'.map_mul _ _).symm (congr_arg φ' hq'')) φ'.map_one using 2,\n    rw [← φ'.comp_apply, is_localization.map_comp, ring_hom.comp_apply, subtype.coe_mk] },\n  refine is_integral_of_mem_closure''\n    (((algebra_map _ Sₘ).comp (quotient.mk P)) '' (insert X {p | p.degree ≤ 0})) _ _ _,\n  { rintros x ⟨p, hp, rfl⟩,\n    refine hp.rec_on (λ hy, _) (λ hy, _),\n    { refine hy.symm ▸ (φ.is_integral_elem_localization_at_leading_coeff ((quotient.mk P) X)\n        (pX.map (quotient.mk P')) _ M ⟨1, pow_one _⟩),\n      rwa [eval₂_map, hφ', ← hom_eval₂, quotient.eq_zero_iff_mem, eval₂_C_X] },\n    { rw [set.mem_set_of_eq, degree_le_zero_iff] at hy,\n      refine hy.symm ▸ ⟨X - C (algebra_map _ _ ((quotient.mk P') (p.coeff 0))), monic_X_sub_C _, _⟩,\n      simp only [eval₂_sub, eval₂_C, eval₂_X],\n      rw [sub_eq_zero, ← φ'.comp_apply, is_localization.map_comp],\n      refl } },\n  { obtain ⟨p, rfl⟩ := quotient.mk_surjective p',\n    refine polynomial.induction_on p\n      (λ r, subring.subset_closure $ set.mem_image_of_mem _ (or.inr degree_C_le))\n      (λ _ _ h1 h2, _) (λ n _ hr, _),\n    { convert subring.add_mem _ h1 h2,\n      rw [ring_hom.map_add, ring_hom.map_add] },\n    { rw [pow_succ X n, mul_comm X, ← mul_assoc, ring_hom.map_mul, ring_hom.map_mul],\n      exact subring.mul_mem _ hr (subring.subset_closure (set.mem_image_of_mem _ (or.inl rfl))) } },\nend\n\n/-- If `f : R → S` descends to an integral map in the localization at `x`,\n  and `R` is a Jacobson ring, then the intersection of all maximal ideals in `S` is trivial -/\nlemma jacobson_bot_of_integral_localization\n  {R : Type*} [comm_ring R] [is_domain R] [is_jacobson R]\n  (Rₘ Sₘ : Type*) [comm_ring Rₘ] [comm_ring Sₘ]\n  (φ : R →+* S) (hφ : function.injective φ) (x : R) (hx : x ≠ 0)\n  [algebra R Rₘ] [is_localization.away x Rₘ]\n  [algebra S Sₘ] [is_localization ((submonoid.powers x).map φ : submonoid S) Sₘ]\n  (hφ' : ring_hom.is_integral\n    (is_localization.map Sₘ φ (submonoid.powers x).le_comap_map : Rₘ →+* Sₘ)) :\n  (⊥ : ideal S).jacobson = (⊥ : ideal S) :=\nbegin\n  have hM : ((submonoid.powers x).map φ : submonoid S) ≤ non_zero_divisors S :=\n    map_le_non_zero_divisors_of_injective φ hφ (powers_le_non_zero_divisors_of_no_zero_divisors hx),\n  letI : is_domain Sₘ := is_localization.is_domain_of_le_non_zero_divisors _ hM,\n  let φ' : Rₘ →+* Sₘ := is_localization.map _ φ (submonoid.powers x).le_comap_map,\n  suffices : ∀ I : ideal Sₘ, I.is_maximal → (I.comap (algebra_map S Sₘ)).is_maximal,\n  { have hϕ' : comap (algebra_map S Sₘ) (⊥ : ideal Sₘ) = (⊥ : ideal S),\n    { rw [← ring_hom.ker_eq_comap_bot, ← ring_hom.injective_iff_ker_eq_bot],\n      exact is_localization.injective Sₘ hM },\n    have hSₘ : is_jacobson Sₘ := is_jacobson_of_is_integral' φ' hφ' (is_jacobson_localization x),\n    refine eq_bot_iff.mpr (le_trans _ (le_of_eq hϕ')),\n    rw [← hSₘ.out is_radical_bot_of_no_zero_divisors, comap_jacobson],\n    exact Inf_le_Inf (λ j hj, ⟨bot_le, let ⟨J, hJ⟩ := hj in hJ.2 ▸ this J hJ.1.2⟩) },\n  introsI I hI,\n  -- Remainder of the proof is pulling and pushing ideals around the square and the quotient square\n  haveI : (I.comap (algebra_map S Sₘ)).is_prime := comap_is_prime _ I,\n  haveI : (I.comap φ').is_prime := comap_is_prime φ' I,\n  haveI : (⊥ : ideal (S ⧸ I.comap (algebra_map S Sₘ))).is_prime := bot_prime,\n  have hcomm: φ'.comp (algebra_map R Rₘ) = (algebra_map S Sₘ).comp φ := is_localization.map_comp _,\n  let f := quotient_map (I.comap (algebra_map S Sₘ)) φ le_rfl,\n  let g := quotient_map I (algebra_map S Sₘ) le_rfl,\n  have := is_maximal_comap_of_is_integral_of_is_maximal' φ' hφ' I hI,\n  have := ((is_maximal_iff_is_maximal_disjoint Rₘ x _).1 this).left,\n  have : ((I.comap (algebra_map S Sₘ)).comap φ).is_maximal,\n  { rwa [comap_comap, hcomm, ← comap_comap] at this },\n  rw ← bot_quotient_is_maximal_iff at this ⊢,\n  refine is_maximal_of_is_integral_of_is_maximal_comap' f _ ⊥\n    ((eq_bot_iff.2 (comap_bot_le_of_injective f quotient_map_injective)).symm ▸ this),\n  exact f.is_integral_tower_bot_of_is_integral g quotient_map_injective\n    ((comp_quotient_map_eq_of_comp_eq hcomm I).symm ▸\n    (ring_hom.is_integral_trans _ _ (ring_hom.is_integral_of_surjective _\n      (is_localization.surjective_quotient_map_of_maximal_of_localization (submonoid.powers x) Rₘ\n      (by rwa [comap_comap, hcomm, ← bot_quotient_is_maximal_iff])))\n      (ring_hom.is_integral_quotient_of_is_integral _ hφ'))),\nend\n\n/-- Used to bootstrap the proof of `is_jacobson_polynomial_iff_is_jacobson`.\n  That theorem is more general and should be used instead of this one. -/\nprivate lemma is_jacobson_polynomial_of_domain\n  (R : Type*) [comm_ring R] [is_domain R] [hR : is_jacobson R]\n  (P : ideal R[X]) [is_prime P] (hP : ∀ (x : R), C x ∈ P → x = 0) :\n  P.jacobson = P :=\nbegin\n  by_cases Pb : P = ⊥,\n  { exact Pb.symm ▸ jacobson_bot_polynomial_of_jacobson_bot\n      (hR.out is_radical_bot_of_no_zero_divisors) },\n  { rw jacobson_eq_iff_jacobson_quotient_eq_bot,\n    haveI : (P.comap (C : R →+* R[X])).is_prime := comap_is_prime C P,\n    obtain ⟨p, pP, p0⟩ := exists_nonzero_mem_of_ne_bot Pb hP,\n    let x := (polynomial.map (quotient.mk (comap (C : R →+* _) P)) p).leading_coeff,\n    have hx : x ≠ 0 := by rwa [ne.def, leading_coeff_eq_zero],\n    refine jacobson_bot_of_integral_localization\n      (localization.away x)\n      (localization ((submonoid.powers x).map (P.quotient_map C le_rfl) :\n        submonoid (R[X] ⧸ P)))\n      (quotient_map P C le_rfl) quotient_map_injective\n      x hx\n      _,\n    -- `convert` is noticeably faster than `exact` here:\n    convert is_integral_is_localization_polynomial_quotient P p pP }\nend\n\nlemma is_jacobson_polynomial_of_is_jacobson (hR : is_jacobson R) :\n  is_jacobson R[X] :=\nbegin\n  refine is_jacobson_iff_prime_eq.mpr (λ I, _),\n  introI hI,\n  let R' : subring (R[X] ⧸ I) := ((quotient.mk I).comp C).range,\n  let i : R →+* R' := ((quotient.mk I).comp C).range_restrict,\n  have hi : function.surjective (i : R → R') := ((quotient.mk I).comp C).range_restrict_surjective,\n  have hi' : (polynomial.map_ring_hom i : R[X] →+* R'[X]).ker ≤ I,\n  { refine λ f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (λ n, _),\n    replace hf := congr_arg (λ (g : polynomial (((quotient.mk I).comp C).range)), g.coeff n) hf,\n    change (polynomial.map ((quotient.mk I).comp C).range_restrict f).coeff n = 0 at hf,\n    rw [coeff_map, subtype.ext_iff] at hf,\n    rwa [mem_comap, ← quotient.eq_zero_iff_mem, ← ring_hom.comp_apply], },\n  haveI := map_is_prime_of_surjective\n    (show function.surjective (map_ring_hom i), from map_surjective i hi) hi',\n  suffices : (I.map (polynomial.map_ring_hom i)).jacobson = (I.map (polynomial.map_ring_hom i)),\n  { replace this := congr_arg (comap (polynomial.map_ring_hom i)) this,\n    rw [← map_jacobson_of_surjective _ hi',\n      comap_map_of_surjective _ _, comap_map_of_surjective _ _] at this,\n    refine le_antisymm (le_trans (le_sup_of_le_left le_rfl)\n      (le_trans (le_of_eq this) (sup_le le_rfl hi'))) le_jacobson,\n    all_goals {exact polynomial.map_surjective i hi} },\n  exact @is_jacobson_polynomial_of_domain R' _ _ (is_jacobson_of_surjective ⟨i, hi⟩)\n    (map (map_ring_hom i) I) _ (eq_zero_of_polynomial_mem_map_range I),\nend\n\ntheorem is_jacobson_polynomial_iff_is_jacobson :\n  is_jacobson R[X] ↔ is_jacobson R :=\nbegin\n  refine ⟨_, is_jacobson_polynomial_of_is_jacobson⟩,\n  introI H,\n  exact is_jacobson_of_surjective ⟨eval₂_ring_hom (ring_hom.id _) 1, λ x,\n    ⟨C x, by simp only [coe_eval₂_ring_hom, ring_hom.id_apply, eval₂_C]⟩⟩,\nend\n\ninstance [is_jacobson R] : is_jacobson R[X] :=\nis_jacobson_polynomial_iff_is_jacobson.mpr ‹is_jacobson R›\n\nend comm_ring\n\nsection\nvariables {R : Type*} [comm_ring R] [is_jacobson R]\nvariables (P : ideal R[X]) [hP : P.is_maximal]\n\ninclude P hP\n\nlemma is_maximal_comap_C_of_is_maximal [nontrivial R] (hP' : ∀ (x : R), C x ∈ P → x = 0) :\n  is_maximal (comap (C : R →+* R[X]) P : ideal R) :=\nbegin\n  haveI hp'_prime : (P.comap (C : R →+* R[X]) : ideal R).is_prime := comap_is_prime C P,\n  obtain ⟨m, hm⟩ := submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_is_field),\n  have : (m : R[X]) ≠ 0, rwa [ne.def, submodule.coe_eq_zero],\n  let φ : R ⧸ P.comap (C : R →+* R[X])  →+* R[X] ⧸ P := quotient_map P (C : R →+* R[X]) le_rfl,\n  let M : submonoid (R ⧸ P.comap C) :=\n    submonoid.powers ((m : R[X]).map\n      (quotient.mk (P.comap (C : R →+* R[X]) : ideal R))).leading_coeff,\n  rw ← bot_quotient_is_maximal_iff,\n  have hp0 : ((m : R[X]).map\n    (quotient.mk (P.comap (C : R →+* R[X]) : ideal R))).leading_coeff ≠ 0 :=\n    λ hp0', this $ map_injective (quotient.mk (P.comap (C : R →+* R[X]) : ideal R))\n      ((injective_iff_map_eq_zero (quotient.mk (P.comap (C : R →+* R[X]) : ideal R))).2 (λ x hx,\n      by rwa [quotient.eq_zero_iff_mem, (by rwa eq_bot_iff : (P.comap C : ideal R) = ⊥)] at hx))\n      (by simpa only [leading_coeff_eq_zero, polynomial.map_zero] using hp0'),\n  have hM : (0 : R ⧸ P.comap C) ∉ M := λ ⟨n, hn⟩, hp0 (pow_eq_zero hn),\n  suffices : (⊥ : ideal (localization M)).is_maximal,\n  { rw ← is_localization.comap_map_of_is_prime_disjoint M (localization M) ⊥ bot_prime\n        (disjoint_iff_inf_le.mpr $ λ x hx, hM (hx.2 ▸ hx.1)),\n    refine ((is_maximal_iff_is_maximal_disjoint (localization M) _ _).mp (by rwa map_bot)).1,\n    swap, exact localization.is_localization },\n  let M' : submonoid (R[X] ⧸ P) := M.map φ,\n  have hM' : (0 : R[X] ⧸ P) ∉ M' :=\n    λ ⟨z, hz⟩, hM (quotient_map_injective (trans hz.2 φ.map_zero.symm) ▸ hz.1),\n  haveI : is_domain (localization M') :=\n    is_localization.is_domain_localization (le_non_zero_divisors_of_no_zero_divisors hM'),\n  suffices : (⊥ : ideal (localization M')).is_maximal,\n  { rw le_antisymm bot_le (comap_bot_le_of_injective _ (is_localization.map_injective_of_injective\n      M (localization M) (localization M') quotient_map_injective )),\n    refine is_maximal_comap_of_is_integral_of_is_maximal' _ _ ⊥ this,\n    apply is_integral_is_localization_polynomial_quotient P _ (submodule.coe_mem m) },\n  rw (map_bot.symm : (⊥ : ideal (localization M')) =\n                     map (algebra_map (R[X] ⧸ P) (localization M')) ⊥),\n  let bot_maximal := ((bot_quotient_is_maximal_iff _).mpr hP),\n  refine map.is_maximal (algebra_map _ _) (is_field.localization_map_bijective hM' _) bot_maximal,\n  rwa [← quotient.maximal_ideal_iff_is_field_quotient, ← bot_quotient_is_maximal_iff],\nend\n\n/-- Used to bootstrap the more general `quotient_mk_comp_C_is_integral_of_jacobson` -/\nprivate lemma quotient_mk_comp_C_is_integral_of_jacobson' [nontrivial R] (hR : is_jacobson R)\n  (hP' : ∀ (x : R), C x ∈ P → x = 0) :\n  ((quotient.mk P).comp C : R →+* R[X] ⧸ P).is_integral :=\nbegin\n  refine (is_integral_quotient_map_iff _).mp _,\n  let P' : ideal R := P.comap C,\n  obtain ⟨pX, hpX, hp0⟩ :=\n    exists_nonzero_mem_of_ne_bot (ne_of_lt (bot_lt_of_maximal P polynomial_not_is_field)).symm hP',\n  let M : submonoid (R ⧸ P') := submonoid.powers (pX.map (quotient.mk P')).leading_coeff,\n  let φ : R ⧸ P' →+* R[X] ⧸ P := quotient_map P C le_rfl,\n  haveI hp'_prime : P'.is_prime := comap_is_prime C P,\n  have hM : (0 : R ⧸ P') ∉ M := λ ⟨n, hn⟩, hp0 $ leading_coeff_eq_zero.mp (pow_eq_zero hn),\n  let M' : submonoid (R[X] ⧸ P) := M.map (quotient_map P C le_rfl),\n  refine ((quotient_map P C le_rfl).is_integral_tower_bot_of_is_integral\n    (algebra_map _ (localization M')) _ _),\n  { refine is_localization.injective (localization M')\n      (show M' ≤ _, from le_non_zero_divisors_of_no_zero_divisors (λ hM', hM _)),\n    exact (let ⟨z, zM, z0⟩ := hM' in (quotient_map_injective (trans z0 φ.map_zero.symm)) ▸ zM) },\n  { rw ← is_localization.map_comp M.le_comap_map,\n    refine ring_hom.is_integral_trans (algebra_map (R ⧸ P') (localization M))\n      (is_localization.map (localization M') _ M.le_comap_map) _ _,\n    { exact (algebra_map (R ⧸ P') (localization M)).is_integral_of_surjective\n      (is_field.localization_map_bijective hM ((quotient.maximal_ideal_iff_is_field_quotient _).mp\n                                               (is_maximal_comap_C_of_is_maximal P hP'))).2 },\n    { -- `convert` here is faster than `exact`, and this proof is near the time limit.\n      convert is_integral_is_localization_polynomial_quotient P pX hpX } }\nend\n\n/-- If `R` is a Jacobson ring, and `P` is a maximal ideal of `R[X]`,\n  then `R → R[X]/P` is an integral map. -/\nlemma quotient_mk_comp_C_is_integral_of_jacobson :\n  ((quotient.mk P).comp C : R →+* R[X] ⧸ P).is_integral :=\nbegin\n  let P' : ideal R := P.comap C,\n  haveI : P'.is_prime := comap_is_prime C P,\n  let f : R[X] →+* polynomial (R ⧸ P') := polynomial.map_ring_hom (quotient.mk P'),\n  have hf : function.surjective f := map_surjective (quotient.mk P') quotient.mk_surjective,\n  have hPJ : P = (P.map f).comap f,\n  { rw comap_map_of_surjective _ hf,\n    refine le_antisymm (le_sup_of_le_left le_rfl) (sup_le le_rfl _),\n    refine λ p hp, polynomial_mem_ideal_of_coeff_mem_ideal P p (λ n, quotient.eq_zero_iff_mem.mp _),\n    simpa only [coeff_map, coe_map_ring_hom] using (polynomial.ext_iff.mp hp) n },\n  refine ring_hom.is_integral_tower_bot_of_is_integral _ _ (injective_quotient_le_comap_map P) _,\n  rw ← quotient_mk_maps_eq,\n  refine ring_hom.is_integral_trans _ _\n    ((quotient.mk P').is_integral_of_surjective quotient.mk_surjective) _,\n  apply quotient_mk_comp_C_is_integral_of_jacobson' _ _ (λ x hx, _),\n  any_goals { exact ideal.is_jacobson_quotient },\n  { exact or.rec_on (map_eq_top_or_is_maximal_of_surjective f hf hP)\n    (λ h, absurd (trans (h ▸ hPJ : P = comap f ⊤) comap_top : P = ⊤) hP.ne_top) id },\n  { apply_instance, },\n  { obtain ⟨z, rfl⟩ := quotient.mk_surjective x,\n    rwa [quotient.eq_zero_iff_mem, mem_comap, hPJ, mem_comap, coe_map_ring_hom, map_C] }\nend\n\nlemma is_maximal_comap_C_of_is_jacobson :\n  (P.comap (C : R →+* R[X])).is_maximal :=\nbegin\n  rw [← @mk_ker _ _ P, ring_hom.ker_eq_comap_bot, comap_comap],\n  exact is_maximal_comap_of_is_integral_of_is_maximal' _\n    (quotient_mk_comp_C_is_integral_of_jacobson P) ⊥ ((bot_quotient_is_maximal_iff _).mpr hP),\nend\n\nomit P hP\n\nlemma comp_C_integral_of_surjective_of_jacobson\n  {S : Type*} [field S] (f : R[X] →+* S) (hf : function.surjective f) :\n  (f.comp C).is_integral :=\nbegin\n  haveI : (f.ker).is_maximal := ring_hom.ker_is_maximal_of_surjective f hf,\n  let g : R[X] ⧸ f.ker →+* S := ideal.quotient.lift f.ker f (λ _ h, h),\n  have hfg : (g.comp (quotient.mk f.ker)) = f := ring_hom_ext' rfl rfl,\n  rw [← hfg, ring_hom.comp_assoc],\n  refine ring_hom.is_integral_trans _ g (quotient_mk_comp_C_is_integral_of_jacobson f.ker)\n    (g.is_integral_of_surjective _), --(quotient.lift_surjective f.ker f _ hf)),\n  rw [← hfg] at hf,\n  exact function.surjective.of_comp hf,\nend\n\nend\n\nend polynomial\n\nopen mv_polynomial ring_hom\n\nnamespace mv_polynomial\n\nlemma is_jacobson_mv_polynomial_fin {R : Type*} [comm_ring R] [H : is_jacobson R] :\n  ∀ (n : ℕ), is_jacobson (mv_polynomial (fin n) R)\n| 0 := ((is_jacobson_iso ((rename_equiv R\n  (equiv.equiv_pempty (fin 0))).to_ring_equiv.trans (is_empty_ring_equiv R pempty))).mpr H)\n| (n+1) := (is_jacobson_iso (fin_succ_equiv R n).to_ring_equiv).2\n  (polynomial.is_jacobson_polynomial_iff_is_jacobson.2 (is_jacobson_mv_polynomial_fin n))\n\n/-- General form of the nullstellensatz for Jacobson rings, since in a Jacobson ring we have\n  `Inf {P maximal | P ≥ I} = Inf {P prime | P ≥ I} = I.radical`. Fields are always Jacobson,\n  and in that special case this is (most of) the classical Nullstellensatz,\n  since `I(V(I))` is the intersection of maximal ideals containing `I`, which is then `I.radical` -/\ninstance is_jacobson {R : Type*} [comm_ring R] {ι : Type*} [finite ι] [is_jacobson R] :\n  is_jacobson (mv_polynomial ι R) :=\nbegin\n  casesI nonempty_fintype ι,\n  haveI := classical.dec_eq ι,\n  let e := fintype.equiv_fin ι,\n  rw is_jacobson_iso (rename_equiv R e).to_ring_equiv,\n  exact is_jacobson_mv_polynomial_fin _\nend\n\nvariables {n : ℕ}\n\nlemma quotient_mk_comp_C_is_integral_of_jacobson\n  {R : Type*} [comm_ring R] [is_jacobson R]\n  (P : ideal (mv_polynomial (fin n) R)) [P.is_maximal] :\n  ((quotient.mk P).comp mv_polynomial.C : R →+* mv_polynomial _ R ⧸ P).is_integral :=\nbegin\n  unfreezingI {induction n with n IH},\n  { refine ring_hom.is_integral_of_surjective _ (function.surjective.comp quotient.mk_surjective _),\n    exact C_surjective (fin 0) },\n  { rw [← fin_succ_equiv_comp_C_eq_C, ← ring_hom.comp_assoc, ← ring_hom.comp_assoc,\n      ← quotient_map_comp_mk le_rfl, ring_hom.comp_assoc (polynomial.C),\n      ← quotient_map_comp_mk le_rfl, ring_hom.comp_assoc, ring_hom.comp_assoc,\n      ← quotient_map_comp_mk le_rfl, ← ring_hom.comp_assoc (quotient.mk _)],\n    refine ring_hom.is_integral_trans _ _ _ _,\n    { refine ring_hom.is_integral_trans _ _ (is_integral_of_surjective _ quotient.mk_surjective) _,\n      refine ring_hom.is_integral_trans _ _ _ _,\n      { apply (is_integral_quotient_map_iff _).mpr (IH _),\n        apply polynomial.is_maximal_comap_C_of_is_jacobson _,\n        { exact mv_polynomial.is_jacobson_mv_polynomial_fin n },\n        { apply comap_is_maximal_of_surjective,\n          exact (fin_succ_equiv R n).symm.surjective } },\n      { refine (is_integral_quotient_map_iff _).mpr _,\n        rw ← quotient_map_comp_mk le_rfl,\n        refine ring_hom.is_integral_trans _ _ _ ((is_integral_quotient_map_iff _).mpr _),\n        { exact ring_hom.is_integral_of_surjective _ quotient.mk_surjective },\n        { apply polynomial.quotient_mk_comp_C_is_integral_of_jacobson _,\n          { exact mv_polynomial.is_jacobson_mv_polynomial_fin n },\n          { exact comap_is_maximal_of_surjective _ (fin_succ_equiv R n).symm.surjective } } } },\n    { refine (is_integral_quotient_map_iff _).mpr _,\n      refine ring_hom.is_integral_trans _ _ _ (is_integral_of_surjective _ quotient.mk_surjective),\n      exact ring_hom.is_integral_of_surjective _ (fin_succ_equiv R n).symm.surjective } }\nend\n\nlemma comp_C_integral_of_surjective_of_jacobson\n  {R : Type*} [comm_ring R] [is_jacobson R]\n  {σ : Type*} [finite σ] {S : Type*} [field S] (f : mv_polynomial σ R →+* S)\n  (hf : function.surjective f) : (f.comp C).is_integral :=\nbegin\n  casesI nonempty_fintype σ,\n  have e := (fintype.equiv_fin σ).symm,\n  let f' : mv_polynomial (fin _) R →+* S :=\n    f.comp (rename_equiv R e).to_ring_equiv.to_ring_hom,\n  have hf' : function.surjective f' :=\n    ((function.surjective.comp hf (rename_equiv R e).surjective)),\n  have : (f'.comp C).is_integral,\n  { haveI : (f'.ker).is_maximal := ker_is_maximal_of_surjective f' hf',\n    let g : mv_polynomial _ R ⧸ f'.ker →+* S := ideal.quotient.lift f'.ker f' (λ _ h, h),\n    have hfg : (g.comp (quotient.mk f'.ker)) = f' := ring_hom_ext (λ r, rfl) (λ i, rfl),\n    rw [← hfg, ring_hom.comp_assoc],\n    refine ring_hom.is_integral_trans _ g (quotient_mk_comp_C_is_integral_of_jacobson f'.ker)\n      (g.is_integral_of_surjective _),\n    rw ← hfg at hf',\n    exact function.surjective.of_comp hf' },\n  rw ring_hom.comp_assoc at this,\n  convert this,\n  refine ring_hom.ext (λ x, _),\n  exact ((rename_equiv R e).commutes' x).symm,\nend\n\nend mv_polynomial\n\nend ideal\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/jacobson.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.4883296377293476}}
{"text": "/-\nCopyright (c) 2016 Leonardo de Moura. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport data.set.lattice\n\n/-!\n# Functoriality of `set`\n\nThis file defines the functor structure of `set`.\n-/\n\nuniverses u\n\nopen function\n\nnamespace set\nvariables {α β : Type u} {s : set α} {f : α → set β} {g : set (α → β)}\n\ninstance : monad.{u} set :=\n{ pure       := λ α a, {a},\n  bind       := λ α β s f, ⋃ i ∈ s, f i,\n  seq        := λ α β, set.seq,\n  map        := λ α β, set.image }\n\n@[simp] lemma bind_def : s >>= f = ⋃ i ∈ s, f i := rfl\n@[simp] lemma fmap_eq_image (f : α → β) : f <$> s = f '' s := rfl\n@[simp] lemma seq_eq_set_seq (s : set (α → β)) (t : set α) : s <*> t = s.seq t := rfl\n@[simp] lemma pure_def (a : α) : (pure a : set α) = {a} := rfl\n\ninstance : is_lawful_monad set :=\n{ id_map                := λ α, image_id,\n  comp_map              := λ α β γ f g s, image_comp _ _ _,\n  pure_bind             := λ α β, bUnion_singleton,\n  bind_assoc            := λ α β γ s f g, by simp only [bind_def, bUnion_Union],\n  bind_pure_comp_eq_map := λ α β f s, (image_eq_Union _ _).symm,\n  bind_map_eq_seq       := λ α β s t, seq_def.symm }\n\ninstance : is_comm_applicative (set : Type u → Type u) :=\n⟨ λ α β s t, prod_image_seq_comm s t ⟩\n\ninstance : alternative set :=\n{ orelse := λ α, (∪),\n  failure := λ α, ∅,\n  .. set.monad }\n\nend set\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/data/set/functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.4883296284901122}}
{"text": "/-\nCopyright (c) 2022 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport computational_monads.oracle_spec\n\n/-!\n# Computations with Oracle Access\n\nThis file defines a representation of a computation with access to a set of oracles,\ngiven by some `oracle_spec`. `oracle_comp spec α` will represent a computation\nusing the oracles of `spec : oracle_spec`, returning values of type `α`.\nThe definion is similar to a free monad, having built in `bind` and `pure` operations,\nand an additional constructor for oracle queries.\n\nWe give probability distribution semantics for such a computation as `eval_dist` and `prob_event`.\n`simulate` and `simulate'` will give semantics for running a computation by simulating the\noracles, using a (potentially empty) different set of oracles.\n\nNotationally, we tend towards using `return` and `>>=` for the monadic operations,\nand do-notation for specifying longer computations.\n\nWe additionally define a `decidable` typeclass for computations for which return values\nall have `decidable_eq` instances, which will later be used to define `fin_support`.\n\nNote that we don't have a constructor for unbounded recursion such as a fixpoint.\nThis creates issues with the distributional semantics since without termination it may not exist.\nIn theory this could be solved by introducing a typeclass for finite computation,\nand only defining distributions on computations with such an instance.\nHowever without a clear use case, we avoid doing this for simplicity.\n-/\n\nvariables {α β γ : Type} {spec spec' : oracle_spec}\n\nopen oracle_spec\n\n/-- Type to represent computations with access so oracles specified by and `oracle_spec`. -/\ninductive oracle_comp (spec : oracle_spec) : Type → Type 1\n| pure' (α : Type) (a : α) : oracle_comp α\n| bind' (α β : Type) (oa : oracle_comp α) (ob : α → oracle_comp β) : oracle_comp β\n| query (i : spec.ι) (t : spec.domain i) : oracle_comp (spec.range i)\n\nnamespace oracle_comp\n\ninstance nonempty (spec : oracle_spec) (α : Type) [h : nonempty α] :\n  nonempty (oracle_comp spec α) := h.elim (λ x, ⟨pure' α x⟩)\n\ninstance inhabited (spec : oracle_spec) (α : Type) [h : inhabited α] :\n  inhabited (oracle_comp spec α) := ⟨pure' α default⟩\n\n/-- Simple computation for qurying a coin-flipping oracle for a single result. -/\n@[reducible, inline] def coin : oracle_comp coin_spec bool := query () ()\n\nsection monad\n\n/-- Natural monad structure on `oracle_comp`.\nSimplification lemmas will tend towards `return` and `>>=` over `pure'` and `bind'`. -/\ninstance monad (spec : oracle_spec) : monad (oracle_comp spec) :=\n{ pure := oracle_comp.pure', bind := oracle_comp.bind' }\n\n@[simp] lemma pure'_eq_return (spec) (a : α) :\n  (pure' α a : oracle_comp spec α) = return a := rfl\n\n@[simp] lemma pure_eq_return (spec) (a : α) :\n  (pure a : oracle_comp spec α) = return a := rfl\n\n@[simp] lemma bind'_eq_bind (oa : oracle_comp spec α) (ob : α → oracle_comp spec β) :\n  bind' α β oa ob = (oa >>= ob) := rfl\n\nlemma map_eq_bind_return_comp (oa : oracle_comp spec α) (f : α → β) :\n  f <$> oa = oa >>= return ∘ f := rfl\n\n/-- Simple computation flipping two coins and returning a value based on them -/\nexample : oracle_comp coin_spec ℕ :=\ndo { b ← coin, b' ← coin,\n  x ← return (if b && b' then 2 else 3),\n  y ← return (if b || b' then 3 else 4),\n  return (x * y) }\n\nend monad\n\n/-- Slightly nicer induction priciple, avoiding use of `bind'` and `pure'`.\n  Use as induction principle with `induction oa using oracle_comp.induction_on` -/\n@[elab_as_eliminator] def induction_on {C : Π {α : Type}, oracle_comp spec α → Sort*}\n  {α : Type} (oa : oracle_comp spec α)\n  (h_return : ∀ {α : Type} (a : α), C (return a))\n  (h_bind : ∀ {α β : Type} {oa : oracle_comp spec α} {ob : α → oracle_comp spec β},\n    C oa → (∀ a, C (ob a)) → C (oa >>= ob) )\n  (h_query : ∀ i t, C (query i t)) : C oa :=\nbegin\n  induction oa with α a α β oa ob hoa hob i t,\n  { exact h_return _ },\n  { exact h_bind hoa hob },\n  { exact h_query i t }\nend\n\n/-- Check that the induction principal works properly. -/\nexample (oa : oracle_comp spec α) : true := by induction oa using oracle_comp.induction_on; trivial\n\n/-- Constructing an `oracle_comp` implies the existence of some element of the underlying type.\n  The assumption that the range of the oracles is `inhabited` is the key point for this. -/\ndef inhabited_base (oa : oracle_comp spec α) : inhabited α :=\nbegin\n  induction oa with α a α β oa ob hoa hob i t,\n  { exact ⟨a⟩ },\n  { exact let ⟨a⟩ := hoa in hob a },\n  { exact ⟨arbitrary (spec.range i)⟩ }\nend\n\n/-- Shorthand for querying the left side of two available oracles. -/\n@[inline, reducible] def query₁ {spec spec' : oracle_spec}\n  (i : spec.ι) (t : spec.domain i) : oracle_comp (spec ++ spec') (spec.range i) :=\n@query (spec ++ spec') (sum.inl i) t\n\n/-- Shorthand for querying the right side of two available oracles. -/\n@[inline, reducible] def query₂ {spec spec' : oracle_spec}\n  (i : spec'.ι) (t : spec'.domain i) : oracle_comp (spec ++ spec') (spec'.range i) :=\n@query (spec ++ spec') (sum.inr i) t\n\nsection decidable\n\n/-- Inductive definition for computations that only return values of types with `decidable_eq`.\nIn this case we can explicitly calculate the `support` as a `finset` rather than a `set`.\nTODO: this seems like bad naming? overlaps? `decidable_comp`? -/\nclass inductive decidable : Π {α : Type}, oracle_comp spec α → Type 1\n| decidable_pure' (α : Type) (a : α) (h : decidable_eq α) : decidable (pure' α a)\n| decidable_bind' (α β : Type) (oa : oracle_comp spec α) (ob : α → oracle_comp spec β)\n    (hoa : decidable oa) (hob : ∀ α, decidable (ob α)) : decidable (bind' α β oa ob)\n| decidable_query (i : spec.ι) (t : spec.domain i) : decidable (query i t)\n\nopen decidable\n\n/-- Version of `decidable_eq_of_decidable` taking an explicit `decidable` argument -/\ndef decidable_eq_of_decidable' : Π {α : Type} {oa : oracle_comp spec α}\n  (h : decidable oa), decidable_eq α\n| _ _ (decidable_pure' α a h) := h\n| _ _ (decidable_bind' α β oa ob hoa hob) := decidable_eq_of_decidable' (hob (inhabited_base oa).1)\n| _ _ (decidable_query i t) := spec.range_decidable_eq i\n\n/-- Given a `decidable` instance on an `oracle_comp`, we can extract a\n  `decidable_eq` instance on the resutlt type of the computation -/\ndef decidable_eq_of_decidable (oa : oracle_comp spec α) [h : oa.decidable] :\n  decidable_eq α := decidable_eq_of_decidable' h\n\ninstance decidable_return [h : decidable_eq α] (a : α) :\n  decidable (return a : oracle_comp spec α) := decidable_pure' α a h\n\ninstance decidable_pure' [h : decidable_eq α] (a : α) :\n  decidable (pure' α a : oracle_comp spec α) := decidable_pure' α a h\n\ninstance decidable_pure [h : decidable_eq α] (a : α) :\n  decidable (pure a : oracle_comp spec α) := decidable_pure' α a h\n\ninstance decidable_bind (oa : oracle_comp spec α) (ob : α → oracle_comp spec β) [h : decidable oa]\n  [h' : ∀ a, decidable (ob a)] : decidable (oa >>= ob) := decidable_bind' α β oa ob h h'\n\ninstance decidable_bind' (oa : oracle_comp spec α) (ob : α → oracle_comp spec β) [h : decidable oa]\n  [h' : ∀ a, decidable (ob a)] : decidable (bind' α β oa ob) := decidable_bind' α β oa ob h h'\n\ninstance decidable_map [h : decidable_eq β] (oa : oracle_comp spec α) [h' : oa.decidable]\n  (f : α → β) : decidable (f <$> oa) := decidable_bind' α β oa _ h' (λ a, decidable_pure' β _ h)\n\ninstance decidable_query (i : spec.ι) (t : spec.domain i) :\n  decidable (query i t) := decidable_query i t\n\ninstance decidable_coin : decidable coin := decidable_query _ _\n\ndef decidable_of_decidable_bind_fst {oa : oracle_comp spec α} {ob : α → oracle_comp spec β} :\n  Π (h : decidable (oa >>= ob)), oa.decidable\n| (decidable_bind' α β _ _ hoa hob) := hoa\n\ndef decidable_of_decidable_bind_snd {oa : oracle_comp spec α} {ob : α → oracle_comp spec β}\n  (a : α) : Π (h : decidable (oa >>= ob)), (ob a).decidable\n| (decidable_bind' α β _ _ hoa hob) := hob a\n\nend decidable\n\n/-- Simple computations should have automatic decidable instances -/\nexample :\ndo {b ← coin, b' ← coin,\n    x ← return (b && b'),\n    y ← return (b || b'),\n    return (if x then 1 else if y then 2 else 3)}.decidable := by apply_instance\n\nend oracle_comp", "meta": {"author": "dtumad", "repo": "lean-crypto-formalization", "sha": "f975a9a9882120b509553a7ced9aa05b745ff154", "save_path": "github-repos/lean/dtumad-lean-crypto-formalization", "path": "github-repos/lean/dtumad-lean-crypto-formalization/lean-crypto-formalization-f975a9a9882120b509553a7ced9aa05b745ff154/src/computational_monads/oracle_comp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.4883296284901122}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nuniverses u w\n\ndef buffer (α : Type u) := Σ n, array n α\n\ndef mk_buffer {α : Type u} : buffer α :=\n⟨0, {data := λ i, fin.elim0 i}⟩\n\ndef array.to_buffer {α : Type u} {n : nat} (a : array n α) : buffer α :=\n⟨n, a⟩\n\nnamespace buffer\nvariables {α : Type u} {β : Type w}\n\ndef nil : buffer α :=\nmk_buffer\n\ndef size (b : buffer α) : nat :=\nb.1\n\ndef to_array (b : buffer α) : array (b.size) α :=\nb.2\n\ndef push_back : buffer α → α → buffer α\n| ⟨n, a⟩ v := ⟨n+1, a.push_back v⟩\n\ndef pop_back : buffer α → buffer α\n| ⟨0, a⟩   := ⟨0, a⟩\n| ⟨n+1, a⟩ := ⟨n, a.pop_back⟩\n\ndef read : Π (b : buffer α), fin b.size → α\n| ⟨n, a⟩ i := a.read i\n\ndef write : Π (b : buffer α), fin b.size → α → buffer α\n| ⟨n, a⟩ i v := ⟨n, a.write i v⟩\n\ndef read' [inhabited α] : buffer α → nat → α\n| ⟨n, a⟩ i := a.read' i\n\ndef write' : buffer α → nat → α → buffer α\n| ⟨n, a⟩ i v := ⟨n, a.write' i v⟩\n\nlemma read_eq_read' [inhabited α] (b : buffer α) (i : nat) (h : i < b.size) :\n  read b ⟨i, h⟩ = read' b i :=\nby cases b; unfold read read'; simp [array.read_eq_read']\n\nlemma write_eq_write' (b : buffer α) (i : nat) (h : i < b.size) (v : α) :\n  write b ⟨i, h⟩ v = write' b i v :=\nby cases b; unfold write write'; simp [array.write_eq_write']\n\ndef to_list (b : buffer α) : list α :=\nb.to_array.to_list\n\nprotected def to_string (b : buffer char) : string :=\nb.to_array.to_list.as_string\n\ndef append_list {α : Type u} : buffer α → list α → buffer α\n| b []      := b\n| b (v::vs) := append_list (b.push_back v) vs\n\ndef append_string (b : buffer char) (s : string) : buffer char :=\nb.append_list s.to_list\n\nlemma lt_aux_1 {a b c : nat} (h : a + c < b) : a < b :=\nlt_of_le_of_lt (nat.le_add_right a c) h\n\nlemma lt_aux_2 {n : nat} (h : 0 < n) : n - 1 < n :=\nnat.sub_lt h (nat.succ_pos 0)\n\nlemma lt_aux_3 {n i} (h : i + 1 < n) : n - 2 - i < n  :=\nhave n > 0,     from lt_trans (nat.zero_lt_succ i) h,\nhave n - 2 < n, from nat.sub_lt this (dec_trivial),\nlt_of_le_of_lt (nat.sub_le _ _) this\n\ndef append_array {α : Type u} {n : nat} (nz : 0 < n) :\n  buffer α → array n α → ∀ i : nat, i < n → buffer α\n| ⟨m, b⟩ a 0     _ :=\n  let i : fin n := ⟨n - 1, lt_aux_2 nz⟩ in\n  ⟨m+1, b.push_back (a.read i)⟩\n| ⟨m, b⟩ a (j+1) h :=\n  let i : fin n := ⟨n - 2 - j, lt_aux_3 h⟩ in\n  append_array ⟨m+1, b.push_back (a.read i)⟩ a j (lt_aux_1 h)\n\nprotected def append {α : Type u} : buffer α → buffer α → buffer α\n| b ⟨0, a⟩   := b\n| b ⟨n+1, a⟩ := append_array (nat.zero_lt_succ _) b a n (nat.lt_succ_self _)\n\ndef iterate : Π b : buffer α, β → (fin b.size → α → β → β) → β\n| ⟨_, a⟩ b f := a.iterate b f\n\ndef foreach : Π b : buffer α, (fin b.size → α → α) → buffer α\n| ⟨n, a⟩ f := ⟨n, a.foreach f⟩\n\n/-- Monadically map a function over the buffer. -/\n@[inline]\ndef mmap {m} [monad m] (b : buffer α) (f : α → m β) : m (buffer β) :=\ndo b' ← b.2.mmap f, return b'.to_buffer\n\n/-- Map a function over the buffer. -/\n@[inline]\ndef map : buffer α → (α → β) → buffer β\n| ⟨n, a⟩ f := ⟨n, a.map f⟩\n\ndef foldl : buffer α → β → (α → β → β) → β\n| ⟨_, a⟩ b f := a.foldl b f\n\ndef rev_iterate : Π (b : buffer α), β → (fin b.size → α → β → β) → β\n| ⟨_, a⟩ b f := a.rev_iterate b f\n\ndef take (b : buffer α) (n : nat) : buffer α :=\nif h : n ≤ b.size then ⟨n, b.to_array.take n h⟩ else b\n\ndef take_right (b : buffer α) (n : nat) : buffer α :=\nif h : n ≤ b.size then ⟨n, b.to_array.take_right n h⟩ else b\n\ndef drop (b : buffer α) (n : nat) : buffer α :=\nif h : n ≤ b.size then ⟨_, b.to_array.drop n h⟩ else b\n\ndef reverse (b : buffer α) : buffer α :=\n⟨b.size, b.to_array.reverse⟩\n\nprotected def mem (v : α) (a : buffer α) : Prop := ∃i, read a i = v\n\ninstance : has_mem α (buffer α) := ⟨buffer.mem⟩\n\ninstance : has_append (buffer α) :=\n⟨buffer.append⟩\n\ninstance [has_repr α] : has_repr (buffer α) :=\n⟨repr ∘ to_list⟩\n\nmeta instance [has_to_format α] : has_to_format (buffer α) :=\n⟨to_fmt ∘ to_list⟩\n\nmeta instance [has_to_tactic_format α] : has_to_tactic_format (buffer α) :=\n⟨tactic.pp ∘ to_list⟩\n\nend buffer\n\ndef list.to_buffer {α : Type u} (l : list α) : buffer α :=\nmk_buffer.append_list l\n\n@[reducible] def char_buffer := buffer char\n\n/-- Convert a format object into a character buffer with the provided\n    formatting options. -/\nmeta constant format.to_buffer : format → options → buffer char\n\ndef string.to_char_buffer (s : string) : char_buffer :=\nbuffer.nil.append_string s\n", "meta": {"author": "subfish-zhou", "repo": "N2Lean", "sha": "8e858cc5b01f1ad921094dc355db3cb9473a42fd", "save_path": "github-repos/lean/subfish-zhou-N2Lean", "path": "github-repos/lean/subfish-zhou-N2Lean/N2Lean-8e858cc5b01f1ad921094dc355db3cb9473a42fd/library/data/buffer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4883296238704944}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.eq_to_hom\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ u₃ u₄ v₃ v₄ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\n`prod C D` gives the cartesian product of two categories.\n\nSee https://stacks.math.columbia.edu/tag/001K.\n-/\nprotected instance prod (C : Type u₁) [category C] (D : Type u₂) [category D] : category (C × D) :=\n  category.mk\n\n-- rfl lemmas for category.prod\n\n@[simp] theorem prod_id (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C) (Y : D) : 𝟙 = (𝟙, 𝟙) :=\n  rfl\n\n@[simp] theorem prod_comp (C : Type u₁) [category C] (D : Type u₂) [category D] {P : C} {Q : C} {R : C} {S : D} {T : D} {U : D} (f : (P, S) ⟶ (Q, T)) (g : (Q, T) ⟶ (R, U)) : f ≫ g = (prod.fst f ≫ prod.fst g, prod.snd f ≫ prod.snd g) :=\n  rfl\n\n@[simp] theorem prod_id_fst (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) : prod.fst 𝟙 = 𝟙 :=\n  rfl\n\n@[simp] theorem prod_id_snd (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) : prod.snd 𝟙 = 𝟙 :=\n  rfl\n\n@[simp] theorem prod_comp_fst (C : Type u₁) [category C] (D : Type u₂) [category D] {X : C × D} {Y : C × D} {Z : C × D} (f : X ⟶ Y) (g : Y ⟶ Z) : prod.fst (f ≫ g) = prod.fst f ≫ prod.fst g :=\n  rfl\n\n@[simp] theorem prod_comp_snd (C : Type u₁) [category C] (D : Type u₂) [category D] {X : C × D} {Y : C × D} {Z : C × D} (f : X ⟶ Y) (g : Y ⟶ Z) : prod.snd (f ≫ g) = prod.snd f ≫ prod.snd g :=\n  rfl\n\n/--\n`prod.category.uniform C D` is an additional instance specialised so both factors have the same\nuniverse levels. This helps typeclass resolution.\n-/\nprotected instance uniform_prod (C : Type u₁) [category C] (D : Type u₁) [category D] : category (C × D) :=\n  category_theory.prod C D\n\n-- Next we define the natural functors into and out of product categories. For now this doesn't\n\n-- address the universal properties.\n\nnamespace prod\n\n\n/-- `sectl C Z` is the functor `C ⥤ C × D` given by `X ↦ (X, Z)`. -/\n@[simp] theorem sectl_obj (C : Type u₁) [category C] {D : Type u₂} [category D] (Z : D) (X : C) : functor.obj (sectl C Z) X = (X, Z) :=\n  Eq.refl (functor.obj (sectl C Z) X)\n\n/-- `sectr Z D` is the functor `D ⥤ C × D` given by `Y ↦ (Z, Y)` . -/\ndef sectr {C : Type u₁} [category C] (Z : C) (D : Type u₂) [category D] : D ⥤ C × D :=\n  functor.mk (fun (X : D) => (Z, X)) fun (X Y : D) (f : X ⟶ Y) => (𝟙, f)\n\n/-- `fst` is the functor `(X, Y) ↦ X`. -/\n@[simp] theorem fst_obj (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) : functor.obj (fst C D) X = prod.fst X :=\n  Eq.refl (functor.obj (fst C D) X)\n\n/-- `snd` is the functor `(X, Y) ↦ Y`. -/\n@[simp] theorem snd_map (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) (Y : C × D) (f : X ⟶ Y) : functor.map (snd C D) f = prod.snd f :=\n  Eq.refl (functor.map (snd C D) f)\n\n/-- The functor swapping the factors of a cartesian product of categories, `C × D ⥤ D × C`. -/\n@[simp] theorem swap_map (C : Type u₁) [category C] (D : Type u₂) [category D] (_x : C × D) : ∀ (_x_1 : C × D) (f : _x ⟶ _x_1), functor.map (swap C D) f = (prod.snd f, prod.fst f) :=\n  fun (_x_1 : C × D) (f : _x ⟶ _x_1) => Eq.refl (functor.map (swap C D) f)\n\n/--\nSwapping the factors of a cartesion product of categories twice is naturally isomorphic\nto the identity functor.\n-/\n@[simp] theorem symmetry_hom_app (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) : nat_trans.app (iso.hom (symmetry C D)) X = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.hom (symmetry C D)) X)\n\n/--\nThe equivalence, given by swapping factors, between `C × D` and `D × C`.\n-/\n@[simp] theorem braiding_counit_iso_inv_app (C : Type u₁) [category C] (D : Type u₂) [category D] (X : D × C) : nat_trans.app (iso.inv (equivalence.counit_iso (braiding C D))) X = inv (eq_to_hom (braiding._proof_3 C D X)) :=\n  Eq.refl (inv (eq_to_hom (braiding._proof_3 C D X)))\n\nprotected instance swap_is_equivalence (C : Type u₁) [category C] (D : Type u₂) [category D] : is_equivalence (swap C D) :=\n  is_equivalence.of_equivalence (braiding C D)\n\nend prod\n\n\n/--\nThe \"evaluation at `X`\" functor, such that\n`(evaluation.obj X).obj F = F.obj X`,\nwhich is functorial in both `X` and `F`.\n-/\ndef evaluation (C : Type u₁) [category C] (D : Type u₂) [category D] : C ⥤ (C ⥤ D) ⥤ D :=\n  functor.mk\n    (fun (X : C) => functor.mk (fun (F : C ⥤ D) => functor.obj F X) fun (F G : C ⥤ D) (α : F ⟶ G) => nat_trans.app α X)\n    fun (X Y : C) (f : X ⟶ Y) => nat_trans.mk fun (F : C ⥤ D) => functor.map F f\n\n/--\nThe \"evaluation of `F` at `X`\" functor,\nas a functor `C × (C ⥤ D) ⥤ D`.\n-/\n@[simp] theorem evaluation_uncurried_obj (C : Type u₁) [category C] (D : Type u₂) [category D] (p : C × (C ⥤ D)) : functor.obj (evaluation_uncurried C D) p = functor.obj (prod.snd p) (prod.fst p) :=\n  Eq.refl (functor.obj (evaluation_uncurried C D) p)\n\nnamespace functor\n\n\n/-- The cartesian product of two functors. -/\n@[simp] theorem prod_obj {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃} [category C] {D : Type u₄} [category D] (F : A ⥤ B) (G : C ⥤ D) (X : A × C) : obj (prod F G) X = (obj F (prod.fst X), obj G (prod.snd X)) :=\n  Eq.refl (obj (prod F G) X)\n\n/- Because of limitations in Lean 3's handling of notations, we do not setup a notation `F × G`.\n   You can use `F.prod G` as a \"poor man's infix\", or just write `functor.prod F G`. -/\n\nend functor\n\n\nnamespace nat_trans\n\n\n/-- The cartesian product of two natural transformations. -/\n@[simp] theorem prod_app {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃} [category C] {D : Type u₄} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D} (α : F ⟶ G) (β : H ⟶ I) (X : A × C) : app (prod α β) X = (app α (prod.fst X), app β (prod.snd X)) :=\n  Eq.refl (app (prod α β) X)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/products/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4883296238704944}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module ring_theory.ideal.associated_prime\n! leanprover-community/mathlib commit a652f6c3cd9ec14a56fe56229010f0fe0217a07c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.Span\nimport Mathbin.RingTheory.Ideal.Operations\nimport Mathbin.RingTheory.Finiteness\nimport Mathbin.RingTheory.Localization.Ideal\nimport Mathbin.RingTheory.Ideal.MinimalPrime\n\n/-!\n\n# Associated primes of a module\n\nWe provide the definition and related lemmas about associated primes of modules.\n\n## Main definition\n- `is_associated_prime`: `is_associated_prime I M` if the prime ideal `I` is the\n  annihilator of some `x : M`.\n- `associated_primes`: The set of associated primes of a module.\n\n## Main results\n- `exists_le_is_associated_prime_of_is_noetherian_ring`: In a noetherian ring, any `ann(x)` is\n  contained in an associated prime for `x ≠ 0`.\n- `associated_primes.eq_singleton_of_is_primary`: In a noetherian ring, `I.radical` is the only\n  associated prime of `R ⧸ I` when `I` is primary.\n\n## Todo\n\nGeneralize this to a non-commutative setting once there are annihilator for non-commutative rings.\n\n-/\n\n\nvariable {R : Type _} [CommRing R] (I J : Ideal R) (M : Type _) [AddCommGroup M] [Module R M]\n\n/-- `is_associated_prime I M` if the prime ideal `I` is the annihilator of some `x : M`. -/\ndef IsAssociatedPrime : Prop :=\n  I.IsPrime ∧ ∃ x : M, I = (R ∙ x).annihilator\n#align is_associated_prime IsAssociatedPrime\n\nvariable (R)\n\n/-- The set of associated primes of a module. -/\ndef associatedPrimes : Set (Ideal R) :=\n  { I | IsAssociatedPrime I M }\n#align associated_primes associatedPrimes\n\nvariable {I J M R} (h : IsAssociatedPrime I M)\n\nvariable {M' : Type _} [AddCommGroup M'] [Module R M'] (f : M →ₗ[R] M')\n\ntheorem AssociatePrimes.mem_iff : I ∈ associatedPrimes R M ↔ IsAssociatedPrime I M :=\n  Iff.rfl\n#align associate_primes.mem_iff AssociatePrimes.mem_iff\n\ntheorem IsAssociatedPrime.isPrime : I.IsPrime :=\n  h.1\n#align is_associated_prime.is_prime IsAssociatedPrime.isPrime\n\ntheorem IsAssociatedPrime.map_of_injective (h : IsAssociatedPrime I M) (hf : Function.Injective f) :\n    IsAssociatedPrime I M' := by\n  obtain ⟨x, rfl⟩ := h.2\n  refine' ⟨h.1, ⟨f x, _⟩⟩\n  ext r\n  rw [Submodule.mem_annihilator_span_singleton, Submodule.mem_annihilator_span_singleton, ←\n    map_smul, ← f.map_zero, hf.eq_iff]\n#align is_associated_prime.map_of_injective IsAssociatedPrime.map_of_injective\n\ntheorem LinearEquiv.isAssociatedPrime_iff (l : M ≃ₗ[R] M') :\n    IsAssociatedPrime I M ↔ IsAssociatedPrime I M' :=\n  ⟨fun h => h.map_of_injective l l.Injective, fun h => h.map_of_injective l.symm l.symm.Injective⟩\n#align linear_equiv.is_associated_prime_iff LinearEquiv.isAssociatedPrime_iff\n\ntheorem not_isAssociatedPrime_of_subsingleton [Subsingleton M] : ¬IsAssociatedPrime I M :=\n  by\n  rintro ⟨hI, x, hx⟩\n  apply hI.ne_top\n  rwa [Subsingleton.elim x 0, submodule.span_singleton_eq_bot.mpr rfl, Submodule.annihilator_bot] at\n    hx\n#align not_is_associated_prime_of_subsingleton not_isAssociatedPrime_of_subsingleton\n\nvariable (R)\n\ntheorem exists_le_isAssociatedPrime_of_isNoetherianRing [H : IsNoetherianRing R] (x : M)\n    (hx : x ≠ 0) : ∃ P : Ideal R, IsAssociatedPrime P M ∧ (R ∙ x).annihilator ≤ P :=\n  by\n  have : (R ∙ x).annihilator ≠ ⊤ := by\n    rwa [Ne.def, Ideal.eq_top_iff_one, Submodule.mem_annihilator_span_singleton, one_smul]\n  obtain ⟨P, ⟨l, h₁, y, rfl⟩, h₃⟩ :=\n    set_has_maximal_iff_noetherian.mpr H\n      { P | (R ∙ x).annihilator ≤ P ∧ P ≠ ⊤ ∧ ∃ y : M, P = (R ∙ y).annihilator }\n      ⟨(R ∙ x).annihilator, rfl.le, this, x, rfl⟩\n  refine' ⟨_, ⟨⟨h₁, _⟩, y, rfl⟩, l⟩\n  intro a b hab\n  rw [or_iff_not_imp_left]\n  intro ha\n  rw [Submodule.mem_annihilator_span_singleton] at ha hab\n  have H₁ : (R ∙ y).annihilator ≤ (R ∙ a • y).annihilator :=\n    by\n    intro c hc\n    rw [Submodule.mem_annihilator_span_singleton] at hc⊢\n    rw [smul_comm, hc, smul_zero]\n  have H₂ : (Submodule.span R {a • y}).annihilator ≠ ⊤ := by\n    rwa [Ne.def, Submodule.annihilator_eq_top_iff, Submodule.span_singleton_eq_bot]\n  rwa [← h₃ (R ∙ a • y).annihilator ⟨l.trans H₁, H₂, _, rfl⟩ H₁,\n    Submodule.mem_annihilator_span_singleton, smul_comm, smul_smul]\n#align exists_le_is_associated_prime_of_is_noetherian_ring exists_le_isAssociatedPrime_of_isNoetherianRing\n\nvariable {R}\n\ntheorem associatedPrimes.subset_of_injective (hf : Function.Injective f) :\n    associatedPrimes R M ⊆ associatedPrimes R M' := fun I h => h.map_of_injective f hf\n#align associated_primes.subset_of_injective associatedPrimes.subset_of_injective\n\ntheorem LinearEquiv.AssociatedPrimes.eq (l : M ≃ₗ[R] M') :\n    associatedPrimes R M = associatedPrimes R M' :=\n  le_antisymm (associatedPrimes.subset_of_injective l l.Injective)\n    (associatedPrimes.subset_of_injective l.symm l.symm.Injective)\n#align linear_equiv.associated_primes.eq LinearEquiv.AssociatedPrimes.eq\n\ntheorem associatedPrimes.eq_empty_of_subsingleton [Subsingleton M] : associatedPrimes R M = ∅ := by\n  ext; simp only [Set.mem_empty_iff_false, iff_false_iff];\n  apply not_isAssociatedPrime_of_subsingleton\n#align associated_primes.eq_empty_of_subsingleton associatedPrimes.eq_empty_of_subsingleton\n\nvariable (R M)\n\ntheorem associatedPrimes.nonempty [IsNoetherianRing R] [Nontrivial M] :\n    (associatedPrimes R M).Nonempty :=\n  by\n  obtain ⟨x, hx⟩ := exists_ne (0 : M)\n  obtain ⟨P, hP, _⟩ := exists_le_isAssociatedPrime_of_isNoetherianRing R x hx\n  exact ⟨P, hP⟩\n#align associated_primes.nonempty associatedPrimes.nonempty\n\nvariable {R M}\n\ntheorem IsAssociatedPrime.annihilator_le (h : IsAssociatedPrime I M) :\n    (⊤ : Submodule R M).annihilator ≤ I :=\n  by\n  obtain ⟨hI, x, rfl⟩ := h\n  exact Submodule.annihilator_mono le_top\n#align is_associated_prime.annihilator_le IsAssociatedPrime.annihilator_le\n\ntheorem IsAssociatedPrime.eq_radical (hI : I.IsPrimary) (h : IsAssociatedPrime J (R ⧸ I)) :\n    J = I.radical := by\n  obtain ⟨hJ, x, e⟩ := h\n  have : x ≠ 0 := by\n    rintro rfl\n    apply hJ.1\n    rwa [submodule.span_singleton_eq_bot.mpr rfl, Submodule.annihilator_bot] at e\n  obtain ⟨x, rfl⟩ := Ideal.Quotient.mkₐ_surjective R _ x\n  replace e : ∀ {y}, y ∈ J ↔ x * y ∈ I\n  · intro y\n    rw [e, Submodule.mem_annihilator_span_singleton, ← map_smul, smul_eq_mul, mul_comm,\n      Ideal.Quotient.mkₐ_eq_mk, ← Ideal.Quotient.mk_eq_mk, Submodule.Quotient.mk_eq_zero]\n  apply le_antisymm\n  · intro y hy\n    exact (hI.2 <| e.mp hy).resolve_left ((Submodule.Quotient.mk_eq_zero I).Not.mp this)\n  · rw [hJ.radical_le_iff]\n    intro y hy\n    exact e.mpr (I.mul_mem_left x hy)\n#align is_associated_prime.eq_radical IsAssociatedPrime.eq_radical\n\ntheorem associatedPrimes.eq_singleton_of_isPrimary [IsNoetherianRing R] (hI : I.IsPrimary) :\n    associatedPrimes R (R ⧸ I) = {I.radical} :=\n  by\n  ext J\n  rw [Set.mem_singleton_iff]\n  refine' ⟨IsAssociatedPrime.eq_radical hI, _⟩\n  rintro rfl\n  haveI : Nontrivial (R ⧸ I) := ⟨⟨(I.Quotient.mk : _) 1, (I.Quotient.mk : _) 0, _⟩⟩\n  obtain ⟨a, ha⟩ := associatedPrimes.nonempty R (R ⧸ I)\n  exact ha.eq_radical hI ▸ ha\n  rw [Ne.def, Ideal.Quotient.eq, sub_zero, ← Ideal.eq_top_iff_one]\n  exact hI.1\n#align associated_primes.eq_singleton_of_is_primary associatedPrimes.eq_singleton_of_isPrimary\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/Ideal/AssociatedPrime.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.682573734412324, "lm_q1q2_score": 0.4883296202070396}}
{"text": "import sylow.cauchy orbit.normalizer\n\nnamespace mygroup\n\nvariables {G : Type} [group G]\nopen classical function set mygroup.subgroup mygroup.group mygroup.group_hom\n  lagrange\n\n-- Definition of p-group for finite groups, not using definition of order of \n-- an element explicitly\n-- class p_group [fintype G] (p : ℕ) extends group G :=\n-- (card_pow_p: ∃ n : ℕ , fincard G = p^n)\n\n-- -- A p-subgroup is a subgroup of a group G which is itself a p-group\n-- class p_subgroup (G : Type) [group G] [fintype G] (p : ℕ) extends subgroup G :=\n-- (card_pow_p: ∃ n : ℕ , fincard (carrier) = p^n)\n\ndef is_p_subgroup (H : subgroup G) (p : ℕ) := ∃ n : ℕ , fincard H = p ^ n \n\ndef dumb_fun' (H : subgroup G) (g : G) (X : set G) : set G :=\n  {t | ∃ x ∈ X , t = g * x}\n\nlemma dumb_fun_lcoset_eq (g h : G) (H : subgroup G) : \n  dumb_fun' H h (g ⋆ H) = h * g ⋆ H :=\nbegin\n  ext, split, \n  { rintro ⟨x, ⟨h', hh', rfl⟩, rfl⟩,\n    exact ⟨h', hh', (group.mul_assoc _ _ _).symm⟩ },\n  { rintro ⟨h', hh', rfl⟩,\n    refine ⟨g * h', ⟨h', hh', rfl⟩, group.mul_assoc _ _ _⟩ }\nend\n\ndef dumb_fun (H : subgroup G) (g : G) (X : lcosets H) : lcosets H :=\n⟨dumb_fun' H g X.1, \n  begin\n  rcases X with ⟨g', ⟨w, rfl⟩⟩, \n  use g * w, ext, split,\n    { intro hx,\n      rcases hx with ⟨hx_w, ⟨h, hh, rfl⟩, rfl⟩,\n      use h,\n      simpa [group.mul_assoc] },\n    { rintro ⟨h, hh, rfl⟩,\n      use w * h,\n      simpa [group.mul_assoc] }\n  end⟩\n\ndef laction.comap {H : Type} [group H] (f : H →* G) (S : Type) (μ : laction G S) :\n  laction H S := \n{ to_fun := λ h s, f h •[μ] s,\n  map_one' := λ s, (map_one f).symm ▸ μ.map_one s,\n  map_assoc' := λ g h s, (map_mul f g h).symm ▸ μ.map_assoc' _ _ _ }\n\ndef dumb_action (H : subgroup  G) : laction G (lcosets H) := \n{ to_fun := dumb_fun H,\n  map_one' := \n  begin \n    intro S, unfold dumb_fun, dsimp, unfold dumb_fun', simp\n  end,  \n  map_assoc' := \n  begin\n    rintros g h ⟨_, g', rfl⟩,\n    unfold dumb_fun, unfold dumb_fun',\n    norm_num, ext1, norm_num, split,\n      { rintro ⟨_, ⟨t, ⟨s, ⟨hs, ht⟩⟩, rfl⟩, rfl⟩,\n        use t, split, use [s, hs], exact ht,\n        rw group.mul_assoc },\n      { rintro ⟨_, ⟨s, hs, rfl⟩, rfl⟩,\n        iterate 3 { split }, use [s, hs], \n        simp [group.mul_assoc] }    \n  end }\n\ndef dumb_action' (H : subgroup G) : laction H (lcosets H) :=\nlaction.comap (𝒾 H) (lcosets H) (dumb_action H)\n\ndef normal_in_normalizer_of_set (H : subgroup G) : normal (normalizer_of_set H.carrier) := \n{ conj_mem' := \n    begin \n      intros n hnorm g,\n      dsimp at *,   \n      cases g with g hg,\n      cases n with n hn,\n      rw mem_coe,\n      rw mem_comap',\n      norm_num,\n      change g ∈ normalizer_of_set H.carrier at hg,\n      rw mem_normalizer_of_set_iff at hg,\n      specialize hg n,\n      rw ← hg,\n      unfold comap at hnorm,\n      rw mem_preimage at hnorm,\n      change n ∈ H at hnorm,\n      assumption,\n    end,\n  .. comap (𝒾 (normalizer_of_set H.carrier)) H }\n\ndef to_lcosets (g : G) (H : subgroup G) : lcosets H := ⟨g ⋆ H, ⟨g, rfl⟩⟩\n\nlemma aux_lemma [fintype G] (H : subgroup G) (g : G) :\n  (H : set G) ≤ conjugate_subgroup g H ↔ g ∈ normalizer H :=\n⟨begin\n  intro h,\n  show conjugate_subgroup g H = H,\n  apply subgroup.ext',\n  symmetry,\n  apply fincard.eq_of_card_eq_subset,\n    exact h,\n  change fincard H = fincard (conjugate_subgroup g H),\n  apply fincard.of_equiv,\n  apply mul_equiv.to_equiv,\n  apply mul_equiv_of_is_conjugate,\n  exact conjugate_is_conjugate g H\nend, begin\n  intro h,\n  change conjugate_subgroup g H = H at h,\n  conv_lhs {rw ←h},\n  apply subset.refl\nend⟩\n\nlemma foo [fintype G] (H : subgroup G) (g : G):\nto_lcosets g H  ∈ (fixed_points (dumb_action' H)) ↔ g ∈ normalizer H :=\nbegin\n  rw ←aux_lemma,\n  unfold fixed_points, \n  unfold to_lcosets,\n  unfold dumb_action', \n  unfold dumb_action,\n  unfold laction.comap,\n  simp,\n  unfold dumb_fun,\n  simp,\n  unfold dumb_fun',\n  unfold conjugate_subgroup,\n  simp,\n  unfold_coes,\n  simp,\n  split,\n  { intros h1 h hh,\n    specialize h1 ⟨h, hh⟩,\n    simp * at *,\n    use g⁻¹ * h * g,\n    rw ext_iff at h1,\n    specialize h1 (h * g),\n    have h2 : h * g ∈ g ⋆ H,\n      rw ←h1,\n      use g,\n      use 1,\n      use H.one_mem,\n      rw group.mul_one,\n      rcases h2 with ⟨j, hj1, hj2⟩,\n      rw group.mul_assoc,\n      rw hj2,\n      rw [← group.mul_assoc, group.mul_left_inv, group.one_mul],\n      use hj1,\n      rw ← hj2,\n      simp [group.mul_assoc] },\n  { rintros h1 ⟨h, hh⟩,\n    ext x, split,\n    { rintro ⟨_, ⟨k, hk1, rfl⟩, rfl⟩,\n      rcases h1 hh with ⟨w, hw, rfl⟩,\n      show g * w * g⁻¹ * _ ∈ _,\n      use w * k,\n      use H.mul_mem hw hk1,\n      simp [group.mul_assoc]\n    },\n    { rintro ⟨j, hx, rfl⟩,\n      rw set.mem_set_of_eq,\n      rcases h1 hh with ⟨w, hw, rfl⟩,\n      use g*w⁻¹*j,\n      split,\n        use w⁻¹*j,\n        split,\n          apply H.mul_mem (H.inv_mem hw) hx,\n        rw group.mul_assoc,\n      simp [group.mul_assoc] } }\nend\n\ndef projection [fintype G] (H : subgroup G) :\n  normalizer H → fixed_points (dumb_action' H) :=\nλ h, ⟨to_lcosets h.1 H, (foo H h.1).2 h.2⟩\n\nlemma proj_eq_coset [fintype G] (H : subgroup G) (b : fixed_points (dumb_action' H)) :\n  ∃ g, (𝒾 (normalizer H)) '' ((projection H) ⁻¹' {b}) = g ⋆ H :=\nbegin\n  rcases b with ⟨⟨_, g, rfl⟩, hg⟩,\n  use g,\n  change to_lcosets g H ∈ _ at hg,\n  rw foo at hg,\n  ext x,\n  split,\n    rintro ⟨⟨k, hk⟩, hk2, rfl⟩,\n    rw mem_preimage at hk2,\n    rw mem_singleton_iff at hk2,\n    unfold projection at hk2,\n    unfold to_lcosets at hk2,\n    rw subtype.mk_eq_mk at hk2,\n    rw subtype.mk_eq_mk at hk2,\n    rw ←hk2,\n    use 1,\n    use H.one_mem,\n    rw group.mul_one,\n    refl,\n  rintro ⟨a, ha, rfl⟩,\n  use g * a,\n    apply subgroup.mul_mem _ hg,\n    apply le_normalizer H,\n    exact ha,\n  split,\n  rw mem_preimage,\n  rw mem_singleton_iff,\n    unfold projection,\n    unfold to_lcosets,\n    rw subtype.mk_eq_mk,\n    rw subtype.mk_eq_mk,\n    rw lagrange.lcoset_eq,\n    convert ha,\n    simp [group.mul_assoc],\n  refl\nend\n\n--lemma card_eq_card_of_injective ()\nlemma proj_fincard [fintype G] (H : subgroup G) (b : fixed_points (dumb_action' H)) :\n  fincard ((projection H) ⁻¹' {b}) = fincard H :=\nbegin\n  cases proj_eq_coset H b with g hg,\n  rw @lagrange.eq_card_of_lcoset _ _ H g,\n  have h := fincard.card_eq_image_of_injective (𝒾 (normalizer H)) injective_𝒾,\n  rw ← hg,\n  rw ← h\nend\n\n\nnoncomputable instance boo36 [fintype G] (H : subgroup G) : fintype H := fintype.of_injective (𝒾 H) injective_𝒾\n\ndef ZZZ [fintype G] (H : subgroup G) := fincard.finsum_fibres (projection H)\n\ndef lcosets_to_sets  (H : subgroup G): lcosets H → { B | ∃ g : G, B = lcoset g H } := id\n\nopen_locale classical\n\nnoncomputable instance boo38 [fintype G] (H : subgroup G) : fintype (lcosets H) :=\nfintype.of_surjective (λ g, to_lcosets g H) begin\n  rintro ⟨C_val, g, rfl⟩,\n  use g,\n  refl\nend\n\nlemma card_subgroup_eq_card_carrier (H : subgroup G) : fincard H = fincard H.carrier := \nbegin\n  apply fincard.of_equiv,\n  use [id, id];\n  {intros x, refl}\nend  \n\nlemma zero_lt_card_subgroup [fintype G] (H : subgroup G): 0 < fincard H  := \nbegin\n  suffices: fincard H ≠ 0,\n  exact nat.pos_of_ne_zero this,\n  intro h,\n  rw [card_subgroup_eq_card_carrier, fincard.card_eq_zero_iff H.carrier] at h,\n  rw [← mem_empty_eq (1 : G), ← h],\n  exact H.one_mem,\nend \n\nlemma index_normalizer_congr_index_modp [fintype G] \n  {p : ℕ} (hp: p.prime) (H : subgroup G) (h: is_p_subgroup H p) :\n  index' (normalizer_of_set (H : set G)) H ≡ index H [MOD p] := \n  begin\n    have claim: ∀ g : G, to_lcosets g H ∈ (fixed_points (dumb_action' H)) ↔ \n      g ∈ normalizer_of_set H.carrier,\n      { intro g,\n        rw normalizer_of_set_eq_normalizer,\n        exact foo H g },\n    have h2 : fincard (fixed_points (dumb_action' H)) = \n      (index' (normalizer_of_set (H : set G)) H),\n      { cases h with n hn,\n        unfold index',\n        erw normalizer_of_set_eq_normalizer,\n        rw ← fincard.finsum_fibres (projection H),\n        simp_rw proj_fincard,\n        rw ← finsum_in_eq_finsum (λ _, fincard H),\n        rw @finsum_const_nat _ _ _ (fincard H),\n        rw nat.mul_div_cancel,\n        exact zero_lt_card_subgroup H,\n        simp,\n        apply_instance },\n    have h3 : index H = fincard (lcosets H),\n      { unfold index,\n        rw @lagrange.lagrange _ _ H,\n        rw _root_.mul_comm,\n        rw nat.mul_div_cancel,\n        exact zero_lt_card_subgroup H },\n    have : index H ≡ (index' (normalizer_of_set (H : set G)) H) [MOD p],\n      rw h3,\n      rw ←h2,\n      cases h with n hn,\n      apply card_set_congr_card_fixed_points_mod_prime (dumb_action' H) _ hp n hn,  \n    exact this.symm\n  end    \n\nlemma p_div_index_div_normalizer_of_set [fintype G](H : subgroup G) {p : ℕ} (hp: p.prime) (h: is_p_subgroup H p):\np ∣ index H → p ∣ (index' (normalizer_of_set (H : set G)) H):=\nbegin\n  intro hH,\n  have h1: index' (normalizer_of_set (H : set G)) H  ≡ H.index [MOD p],\n    {apply index_normalizer_congr_index_modp hp H h},\n  refine nat.modeq.modeq_zero_iff.mp _,\n    apply nat.modeq.trans h1,\n    apply nat.modeq.symm,\n    apply nat.modeq.modeq_of_dvd,\n    rw [int.coe_nat_zero, sub_zero],\n    norm_cast,\n    exact hH,\nend  \n\nlemma normalizer_neq_subgroup [fintype G] \n  (H : subgroup G) {p : ℕ} (hp: p.prime) (h: is_p_subgroup H p) : \n  p ∣ index H → normalizer_of_set (H : set G) ≠ H := \nbegin\n  intro hH,\n  have h1: index' (normalizer_of_set (H : set G)) H  ≡ H.index [MOD p],\n    { apply index_normalizer_congr_index_modp hp H h },\n  have h2: p ∣ (index' (normalizer_of_set (H : set G)) H),\n    { apply p_div_index_div_normalizer_of_set H hp h, assumption },\n  have h3: (index' (normalizer_of_set (H : set G)) H) ≠ 1,\n    { intro hfalse,\n      rw hfalse at h2,\n      exact nat.prime.not_dvd_one hp h2 },\n  have h4: fincard (normalizer_of_set (H : set G)) ≠ fincard H,\n    { unfold index' at h3,\n      intro hfalse,\n      rw hfalse at h3,\n      apply h3,\n      apply nat.div_self,\n      apply zero_lt_card_subgroup },\n  intro hfalse, \n  apply h4,\n  rw hfalse, \nend  \n\nlemma index_eq_card_quotient [fintype G] (H : normal G): index (H : subgroup G) = fincard (G /ₘ H) := \nbegin\n  unfold index,\n  rw lagrange.card_quotient_eq_mul H,\n  change _ /fincard H = _,\n  rw nat.mul_comm,\n  rw nat.mul_div_assoc,\n  rw nat.div_self,\n  rw nat.mul_one,\n  apply zero_lt_card_subgroup,\n  refl,\nend  \n\nnoncomputable instance boo54 [fintype G] (N : normal G) : fintype (G /ₘ N) :=\nfintype.of_surjective (quotient.mk N) begin\n  exact quotient.is_surjective_mk\nend\n\ndef equiv_comap_of_sub (K : subgroup G) (H : normal G)\n  (h : H.to_subgroup ≤ K) : normal.comap (𝒾 K) H ≃ H := \n{ to_fun := λ g, ⟨g.1.1, \n    begin\n      rcases g with ⟨⟨g, _⟩, hg⟩,\n      exact hg\n    end⟩,\n  inv_fun := λ g, ⟨⟨g.1, h g.2⟩, g.2⟩,\n  left_inv := by rintro ⟨⟨_, _⟩, _⟩; simp,\n  right_inv := by rintro ⟨_, _⟩; simp }\n\ndef equiv_comap_of_sub' (H K : subgroup G)\n  (h : H ≤ K) : subgroup.comap (𝒾 K) H ≃ H := \n{ to_fun := λ g, ⟨g.1.1, \n    begin\n      rcases g with ⟨⟨g, _⟩, hg⟩,\n      exact hg\n    end⟩,\n  inv_fun := λ g, ⟨⟨g.1, h g.2⟩, g.2⟩,\n  left_inv := by rintro ⟨⟨_, _⟩, _⟩; simp,\n  right_inv := by rintro ⟨_, _⟩; simp }\n\ndef equiv_map_of_sub (H : subgroup G) (K : subgroup H) :\n  map (𝒾 H) K ≃ K := \n{ to_fun := λ k,\n    begin\n      refine ⟨⟨k.1, _⟩, _⟩;\n        rcases k with ⟨k, ⟨_, hk⟩, hk', rfl⟩,\n        exact hk,\n        exact hk',\n    end,\n  inv_fun := λ k, ⟨k.1, k, k.2, rfl⟩,\n  left_inv := by rintro ⟨_, _, _, _⟩; simp,\n  right_inv := by rintro ⟨_, _⟩; simp }\n\nlemma index_eq_index' [fintype G] (H K : subgroup G) (h: K ≤ H):\n  index (comap (𝒾 H) K) = index' H K :=\nbegin\n  unfold index,\n  unfold index',\n  rw fincard.of_equiv (equiv_comap_of_sub' K H h)\nend\n\nlemma index'_eq_card_quotient [fintype G] (H : subgroup G) (K : normal H): \n  index' H (map (𝒾 H) K) = fincard (H /ₘ K) :=\nbegin\n  unfold index',\n  have h := lagrange.card_quotient_eq_mul K,\n  rw h,\n  rw fincard.of_equiv (equiv_map_of_sub H ↑K),\n  rw _root_.mul_comm,\n  convert nat.mul_div_cancel _ _,\n  exact zero_lt_card_subgroup _,\nend\n\ntheorem sylow_one [fintype G] \n  {p m n: ℕ} {hp : p.prime}{hG : fincard G = p ^ n * m} {hdiv : ¬ p ∣ m} : \n  ∀ (i ≤ n), ∃ H : subgroup G, fincard H = p ^ i := \nbegin\n  intros i hin,\n  induction i with i hi,   \n  { use ⊥ ,\n    rw nat.pow_zero,\n    exact fincard_bot },\n  rw nat.succ_eq_add_one at hin,\n  have useful : 0 < n - i := nat.le_sub_left_of_add_le hin,\n  have useful2 : i ≤ n,\n    refine le_trans _ hin, simp,\n  specialize hi useful2,\n  cases hi with H hH,\n  \n  have fact0: p ∣ index H,\n  { unfold index,\n    rw [hG, hH, show n = i + (n - i), by simp [← nat.add_sub_assoc useful2 _], \n        nat.pow_add, nat.mul_assoc, nat.mul_comm, \n        nat.mul_div_assoc _ (show p ^ i ∣ p ^ i, by refl), \n        nat.div_self (nat.pow_pos (nat.prime.pos hp) i), \n        nat.mul_assoc, nat.mul_one],\n    use p^(n - i - 1) * m, ring,\n    rw nat.mul_assoc, congr,\n    rw ← nat.pow_succ, congr,\n    rw nat.succ_eq_add_one,\n    generalize h : n - i = w,\n    rw h at useful,\n    refine (nat.sub_add_cancel _).symm,\n    linarith },\n  have fact1: index' (normalizer_of_set (H : set G)) H  ≡ H.index [MOD p],\n  {  refine index_normalizer_congr_index_modp hp H _ ,\n    use i, exact hH }, \n  have fact2: p ∣ (index' (normalizer_of_set (H : set G)) H),\n  {  refine (p_div_index_div_normalizer_of_set H hp _ _),\n    use i, exact hH, exact fact0},  \n  have fact3: p ∣ fincard (normalizer_of_set (H : set G) /ₘ normal_in_normalizer_of_set H),\n    { rw ← index'_eq_card_quotient,\n      cases fact2 with k hk,\n      use k,\n      rw ← hk, \n      unfold index',\n      congr' 1,\n      rw fincard.of_equiv (equiv_map_of_sub _ _),\n      unfold normal_in_normalizer_of_set,\n      convert fincard.of_equiv (equiv_comap_of_sub' _ _ _),\n      rw normalizer_of_set_eq_normalizer,\n      exact le_normalizer H\n    },\n  have fact4: ∃ (K : subgroup (normalizer_of_set (H : set G) /ₘ normal_in_normalizer_of_set H)), fincard K = p,\n    { refine @cauchy _ _ _ p hp fact3, },\n  cases fact4 with K hK,\n  have := quotient.quotient.comap_iso _ K,\n  use map (𝒾 (normalizer_of_set H.carrier)) (quotient.comap (normal_in_normalizer_of_set H) K), \n  unfold map,\n  rw card_subgroup_eq_card_carrier,\n  simp,\n  rw ← fincard.card_eq_image_of_injective (𝒾 (normalizer_of_set H.carrier)),\n  change fincard (quotient.comap (normal_in_normalizer_of_set H) K).carrier = p ^ i.succ,\n  rw ←  card_subgroup_eq_card_carrier,\n  rw @quotient.comap_card_eq _ _ _ (normal_in_normalizer_of_set H) K,\n  rw hK,\n  rw nat.pow_succ,\n  congr,\n  rw ← hH,\n  apply fincard.of_equiv,\n  refine equiv.trans (equiv_comap_of_sub _ _ _) _,\n  { rintro h hh,\n    unfold quotient.comap,\n    rw mem_coe,\n    rw mem_comap',\n    convert K.one_mem,\n    rw ← mem_kernel,\n    rw quotient.kernel_mk,\n    exact hh\n  },\n  { unfold normal_in_normalizer_of_set,\n      convert (equiv_comap_of_sub' _ _ _),\n    rw normalizer_of_set_eq_normalizer,\n    exact le_normalizer H,\n  },\n  exact injective_𝒾,  \nend    \n\ndef conjugate_iso (g : G) (H : subgroup G) : H ≅ conjugate_subgroup g H :=\n{ to_fun := λ (h : H) , ⟨g * h * g⁻¹, begin use [h, h.2] end⟩,\n  map_mul' := \n    begin\n      rintro ⟨x, hx⟩ ⟨y, hy⟩,\n      congr' 1,\n      change g * (x * y) * g⁻¹ = _,\n      simp [group.mul_assoc],   \n    end,\n  is_bijective := \n    begin\n      split,\n      { intros x y hxy ,\n        dsimp at *,\n        cases y with y hy, \n        cases x with x hx, \n        rw subtype.mk_eq_mk at hxy,\n        simpa using hxy,        \n        },\n      { unfold surjective,\n        rintro ⟨b, h, hh, rfl⟩,\n        use ⟨h, hh⟩, \n        simp }\n    end }\n\nlemma conjugates_eq_cardinality (g : G) (H : subgroup G) :\n  fincard H = fincard (conjugate_subgroup g H) := \nfincard.of_equiv (group_hom.mul_equiv_of_iso (conjugate_iso g H)).to_equiv\n  \ndef is_sylow_p_subgroup [fintype G] {p m n: ℕ} (hp : p.prime)(hG : fincard G = p ^ n * m)\n (hdiv : ¬ p ∣ m) (K : subgroup G): Prop := fincard K = p ^ n\n\ndef dumb_action2 (H K: subgroup G) : laction K (lcosets H) :=\nlaction.comap (𝒾 K) (lcosets H) (dumb_action H)\n\ntheorem sylow_two [fintype G]{p m n: ℕ} (hp : p.prime)(hG : fincard G = p ^ n * m)\n (hdiv : ¬ p ∣ m) (H K : subgroup G) (h₁ : is_sylow_p_subgroup hp hG hdiv H)(h₂ : is_sylow_p_subgroup hp hG hdiv K) : \n∃ (g : G), H = conjugate_subgroup g K  :=\nbegin\n  have claim: ¬ p ∣ index H,\n  { unfold index,\n    unfold is_sylow_p_subgroup at h₁,\n    rw [hG, h₁, nat.mul_comm, nat.mul_div_assoc, nat.div_self, nat.mul_one],\n    exact hdiv,\n    apply nat.pow_pos (nat.prime.pos hp), \n    simp},\n  have fact: ¬ H.index ≡ 0 [MOD p],\n  { intro h, apply claim,\n    apply nat.modeq.modeq_zero_iff.1, exact h },\n\n  have claim3: H.index ≡ fincard (fixed_points (dumb_action2 H K)) [MOD p],\n  { unfold is_sylow_p_subgroup at * ,\n    --apply card_set_congr_card_fixed_points_mod_prime dumb_action2 p hp h₂\n    sorry}, \n  sorry\nend    \n\n\n\n-- Consider the action of K on the set X of cosets of H in G μ: K × X → X, (y, xH) ↦ yxH. \n--Consider the points fixed by the action. Notice that since H is a Sylow p subgroup then p does not divide \n--fincard X = index H, hence fincard (fixed points μ) ≠ 0. We then want to show that xH ∈ fixed_points μ \n--implies that the conjugate of K by x is a subgroup of H. Since conjugates are isomorphic they have the same cardinality.\n--Hence x K x⁻¹ = H.\n\n\n\n--Define the number of Sylow p-subgroups of G. \n-- noncomputable def number_sylow_p (G : Type) [group G] {p : ℕ} (hp : p.prime) := \n-- fincard {K : subgroup G // is_sylow_p_subgroup K hp}\n\n-- theorem sylow_three_part1 [fintype G]{p m n: ℕ}{hp : p.prime}\n--   {hG : fincard G = p ^ n * m} {hdiv : ¬ p ∣ m}:\n-- number_sylow_p G hp ≡ 1 [MOD p] := sorry \n-- theorem sylow_three_part2 [fintype G]{p m n: ℕ} {hp : p.prime}{hG : fincard G = p ^ n * m} {hdiv : ¬ p ∣ m}:\n-- number_sylow_p G hp ∣ m := sorry \n--By Sylow 1 ∃ a Sylow p-subgroup P, so we set X = Sylp(G) = {Sylow p-groups in G}\n--Then P acts on X by μ : P × X → X, (x, Q) ↦ xQx⁻¹ (this is what we defined conjugate_action to be)\n--By card_set_congr_card_fixed_points_mod_prime we have\n-- number_sylow_p = fincard X ≡ fincard (fixed points μ) [MOD p]. Want to show fincard (fixed points μ) = 1.\n--Let P ∈ fixed points μ and Q ∈ fixed points μ. Then P is a subgroup of normalizer_of_set Q\n--Both P and Q are Sylow p-subgroups of normalizer_of_set Q, so ∃ x ∈ normalizer_of_set Q s.t. xQx⁻¹ = P (Sylow 2)\n--By def of normalizer_of_set Q we have Q = P, so fixed_points μ = {P}, proving the first part of the theorem.end\n--Now if P acts on X by conjugation ∃ ! orbit such that X = orbit G P (Sylow 2).\n--By orbit-stabilizer number_sylow_p = (fincard X) ∣ (fincard G)=p^n *m which implies it divides m.\n\nend mygroup", "meta": {"author": "ImperialCollegeLondon", "repo": "group-theory-game", "sha": "152ec4a92ad67b6174a3d240c63fa56a6df6017e", "save_path": "github-repos/lean/ImperialCollegeLondon-group-theory-game", "path": "github-repos/lean/ImperialCollegeLondon-group-theory-game/group-theory-game-152ec4a92ad67b6174a3d240c63fa56a6df6017e/src/sylow/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834734, "lm_q2_score": 0.6825737214979746, "lm_q1q2_score": 0.4883296192508767}}
{"text": "import GMLInit.Data.Index.Basic\nimport GMLInit.Data.Index.Map\n\nprotected abbrev List.option {α} (xs : List α) : List (Option α) := none :: xs.map some\n\nnamespace Index\nvariable {α} {xs : List α}\n\ndef option : Option (Index xs) → Index xs.option\n| none => head\n| some i => tail (i.map some)\n\ndef unoption (k : Index xs.option) : Option (Index xs) :=\n  match k with\n  | head => none\n  | tail i => i.unmap some\n\ntheorem unoption_option : (i : Option (Index xs)) → unoption (option i) = i\n| none => rfl\n| some i => congrArg some (unmap_map some i)\n\ntheorem option_unoption : (k : Index (List.option xs)) → option (unoption k) = k\n| head => rfl\n| tail k => congrArg tail (map_unmap some k)\n\ntheorem option_eq_iff_eq_unoption (i : Option (Index xs)) (k : Index (List.option xs)) : option i = k ↔ i = unoption k := by\n  constr\n  · intro h; rw [←h, unoption_option]\n  · intro h; rw [h, option_unoption]\n\ntheorem unoption_eq_iff_eq_option (k : Index (List.option xs)) (i : Option (Index xs)) : unoption k = i ↔ k = option i := by\n  constr\n  · intro h; rw [←h, option_unoption]\n  · intro h; rw [h, unoption_option]\n\ndef optionEquiv (xs : List α) : Equiv (Option (Index xs)) (Index (List.option xs)) where\n  fwd := option\n  rev := unoption\n  spec := by\n    intros\n    constr\n    · intro | rfl => exact unoption_option ..\n    · intro | rfl => exact option_unoption ..\n\ntheorem val_option (i : Option (Index xs)) : (match i with | none => none | some i => some i.val) = (option i).val := by\n  match i with\n  | none => rfl\n  | some i => rw [option, val_map]\n\ntheorem val_unoption (k : Index (List.option xs)) : k.val = (match k.unoption with | none => none | some k => some k.val) := by\n  rw [←option_unoption k, val_option, unoption_option]\n\nend Index\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/Index/Option.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145997, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.48819016657697323}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Jeremy Avigad, Floris van Doorn, Mario Carneiro\n-/\nimport Std.Tactic.Basic\nimport Std.Tactic.Lint.Misc\n\ninstance {f : α → β} [DecidablePred p] : DecidablePred (p ∘ f) :=\n  inferInstanceAs <| DecidablePred fun x => p (f x)\n\n/-! ## not -/\n\ntheorem Not.intro {a : Prop} (h : a → False) : ¬a := h\n\n/-- Ex falso for negation. From `¬a` and `a` anything follows. This is the same as `absurd` with\nthe arguments flipped, but it is in the `not` namespace so that projection notation can be used. -/\ndef Not.elim {α : Sort _} (H1 : ¬a) (H2 : a) : α := absurd H2 H1\n\ntheorem Not.imp {a b : Prop} (H2 : ¬b) (H1 : a → b) : ¬a := mt H1 H2\n\ntheorem not_congr (h : a ↔ b) : ¬a ↔ ¬b := ⟨mt h.2, mt h.1⟩\n\ntheorem not_not_not : ¬¬¬a ↔ ¬a := ⟨mt not_not_intro, not_not_intro⟩\n\ntheorem not_not_of_not_imp : ¬(a → b) → ¬¬a := mt Not.elim\n\ntheorem not_of_not_imp {a : Prop} : ¬(a → b) → ¬b := mt fun h _ => h\n\n@[simp] theorem imp_not_self : (a → ¬a) ↔ ¬a := ⟨fun h ha => h ha ha, fun h _ => h⟩\n\n/-! ## iff -/\n\ntheorem iff_def : (a ↔ b) ↔ (a → b) ∧ (b → a) := iff_iff_implies_and_implies ..\n\ntheorem iff_def' : (a ↔ b) ↔ (b → a) ∧ (a → b) := iff_def.trans And.comm\n\n/-- Non-dependent eliminator for `Iff`. -/\ndef Iff.elim (f : (a → b) → (b → a) → α) (h : a ↔ b) : α := f h.1 h.2\n\ntheorem Eq.to_iff : a = b → (a ↔ b) | rfl => Iff.rfl\n\ntheorem iff_of_eq : a = b → (a ↔ b) := Eq.to_iff\n\ntheorem neq_of_not_iff : ¬(a ↔ b) → a ≠ b := mt Eq.to_iff\n\ntheorem iff_iff_eq : (a ↔ b) ↔ a = b := ⟨propext, iff_of_eq⟩\n\n@[simp] theorem eq_iff_iff {p q : Prop} : (p = q) ↔ (p ↔ q) := iff_iff_eq.symm\n\ntheorem of_iff_true (h : a ↔ True) : a := h.2 ⟨⟩\n\ntheorem not_of_iff_false : (a ↔ False) → ¬a := Iff.mp\n\ntheorem iff_of_true (ha : a) (hb : b) : a ↔ b := ⟨fun _ => hb, fun _ => ha⟩\n\ntheorem iff_of_false (ha : ¬a) (hb : ¬b) : a ↔ b := ⟨ha.elim, hb.elim⟩\n\ntheorem iff_true_left (ha : a) : (a ↔ b) ↔ b := ⟨fun h => h.1 ha, iff_of_true ha⟩\n\ntheorem iff_true_right (ha : a) : (b ↔ a) ↔ b := Iff.comm.trans (iff_true_left ha)\n\ntheorem iff_false_left (ha : ¬a) : (a ↔ b) ↔ ¬b := ⟨fun h => mt h.2 ha, iff_of_false ha⟩\n\ntheorem iff_false_right (ha : ¬a) : (b ↔ a) ↔ ¬b := Iff.comm.trans (iff_false_left ha)\n\ntheorem iff_true_intro (h : a) : a ↔ True := iff_of_true h ⟨⟩\n\ntheorem iff_false_intro (h : ¬a) : a ↔ False := iff_of_false h id\n\ntheorem not_iff_false_intro (h : a) : ¬a ↔ False := iff_false_intro (not_not_intro h)\n\ntheorem iff_congr (h₁ : a ↔ c) (h₂ : b ↔ d) : (a ↔ b) ↔ (c ↔ d) :=\n  ⟨fun h => h₁.symm.trans <| h.trans h₂, fun h => h₁.trans <| h.trans h₂.symm⟩\n\n@[simp] theorem not_true : (¬True) ↔ False := iff_false_intro (not_not_intro ⟨⟩)\n\n@[simp] theorem not_false_iff : (¬False) ↔ True := iff_true_intro not_false\n\ntheorem ne_self_iff_false (a : α) : a ≠ a ↔ False := not_iff_false_intro rfl\n\ntheorem eq_self_iff_true (a : α) : a = a ↔ True := iff_true_intro rfl\n\ntheorem heq_self_iff_true (a : α) : HEq a a ↔ True := iff_true_intro HEq.rfl\n\ntheorem iff_not_self : ¬(a ↔ ¬a) | H => let f h := H.1 h h; f (H.2 f)\n\n@[simp] theorem not_iff_self : ¬(¬a ↔ a) | H => iff_not_self H.symm\n\ntheorem true_iff_false : (True ↔ False) ↔ False := iff_false_intro (fun h => h.1 ⟨⟩)\n\ntheorem false_iff_true : (False ↔ True) ↔ False := iff_false_intro (fun h => h.2 ⟨⟩)\n\ntheorem false_of_true_iff_false : (True ↔ False) → False := fun h => h.1 ⟨⟩\n\ntheorem false_of_true_eq_false : (True = False) → False := fun h => h ▸ trivial\n\ntheorem true_eq_false_of_false : False → (True = False) := False.elim\n\ntheorem eq_comm {a b : α} : a = b ↔ b = a := ⟨Eq.symm, Eq.symm⟩\n\n/-! ## implies -/\n\n@[nolint unusedArguments]\ntheorem imp_intro {α β : Prop} (h : α) : β → α := fun _ => h\n\ntheorem imp_imp_imp {a b c d : Prop} (h₀ : c → a) (h₁ : b → d) : (a → b) → (c → d) := (h₁ ∘ · ∘ h₀)\n\ntheorem imp_iff_right {a : Prop} (ha : a) : (a → b) ↔ b := ⟨fun f => f ha, imp_intro⟩\n\n-- This is not marked `@[simp]` because we have `implies_true : (α → True) = True` in core.\ntheorem imp_true_iff (α : Sort u) : (α → True) ↔ True := iff_true_intro fun _ => trivial\n\ntheorem false_imp_iff (a : Prop) : (False → a) ↔ True := iff_true_intro False.elim\n\ntheorem true_imp_iff (α : Prop) : (True → α) ↔ α := ⟨fun h => h trivial, fun h _ => h⟩\n\n@[simp] theorem imp_self : (a → a) ↔ True := iff_true_intro id\n\ntheorem imp_false : (a → False) ↔ ¬a := Iff.rfl\n\ntheorem imp.swap : (a → b → c) ↔ (b → a → c) := ⟨flip, flip⟩\n\ntheorem imp_not_comm : (a → ¬b) ↔ (b → ¬a) := imp.swap\n\ntheorem imp_congr_left (h : a ↔ b) : (a → c) ↔ (b → c) :=\n  ⟨fun hac ha => hac (h.2 ha), fun hbc ha => hbc (h.1 ha)⟩\n\ntheorem imp_congr_right (h : a → (b ↔ c)) : (a → b) ↔ (a → c) :=\n  ⟨fun hab ha => (h ha).1 (hab ha), fun hcd ha => (h ha).2 (hcd ha)⟩\n\ntheorem imp_congr_ctx (h₁ : a ↔ c) (h₂ : c → (b ↔ d)) : (a → b) ↔ (c → d) :=\n  (imp_congr_left h₁).trans (imp_congr_right h₂)\n\ntheorem imp_congr (h₁ : a ↔ c) (h₂ : b ↔ d) : (a → b) ↔ (c → d) := imp_congr_ctx h₁ fun _ => h₂\n\ntheorem imp_iff_not (hb : ¬b) : a → b ↔ ¬a := imp_congr_right fun _ => iff_false_intro hb\n\n/-! ## and -/\n\n/-- Non-dependent eliminator for `And`. -/\nabbrev And.elim (f : a → b → α) (h : a ∧ b) : α := f h.1 h.2\n\ntheorem And.symm : a ∧ b → b ∧ a | ⟨ha, hb⟩ => ⟨hb, ha⟩\n\ntheorem And.imp (f : a → c) (g : b → d) (h : a ∧ b) : c ∧ d := ⟨f h.1, g h.2⟩\n\ntheorem And.imp_left (h : a → b) : a ∧ c → b ∧ c := .imp h id\n\ntheorem And.imp_right (h : a → b) : c ∧ a → c ∧ b := .imp id h\n\ntheorem and_congr (h₁ : a ↔ c) (h₂ : b ↔ d) : a ∧ b ↔ c ∧ d :=\n  ⟨And.imp h₁.1 h₂.1, And.imp h₁.2 h₂.2⟩\n\ntheorem and_comm : a ∧ b ↔ b ∧ a := And.comm\n\ntheorem and_congr_right (h : a → (b ↔ c)) : a ∧ b ↔ a ∧ c :=\n⟨fun ⟨ha, hb⟩ => ⟨ha, (h ha).1 hb⟩, fun ⟨ha, hb⟩ => ⟨ha, (h ha).2 hb⟩⟩\n\ntheorem and_congr_left (h : c → (a ↔ b)) : a ∧ c ↔ b ∧ c :=\n  and_comm.trans <| (and_congr_right h).trans and_comm\n\ntheorem and_congr_left' (h : a ↔ b) : a ∧ c ↔ b ∧ c := and_congr h .rfl\n\ntheorem and_congr_right' (h : b ↔ c) : a ∧ b ↔ a ∧ c := and_congr .rfl h\n\ntheorem and_congr_right_eq (h : a → b = c) : (a ∧ b) = (a ∧ c) :=\n  propext <| and_congr_right fun hc => h hc ▸ .rfl\n\ntheorem and_congr_left_eq (h : c → a = b) : (a ∧ c) = (b ∧ c) :=\n  propext <| and_congr_left fun hc => h hc ▸ .rfl\n\ntheorem and_assoc : (a ∧ b) ∧ c ↔ a ∧ (b ∧ c) :=\n  ⟨fun ⟨⟨ha, hb⟩, hc⟩ => ⟨ha, hb, hc⟩, fun ⟨ha, hb, hc⟩ => ⟨⟨ha, hb⟩, hc⟩⟩\n\ntheorem and_left_comm : a ∧ (b ∧ c) ↔ b ∧ (a ∧ c) := by\n  rw [← and_assoc, ← and_assoc, @and_comm a b]\n\ntheorem and_right_comm : (a ∧ b) ∧ c ↔ (a ∧ c) ∧ b := by\n  simp only [and_left_comm, and_comm]\n\ntheorem and_rotate : a ∧ b ∧ c ↔ b ∧ c ∧ a := by\n  simp only [and_left_comm, and_comm]\n\ntheorem and_and_and_comm : (a ∧ b) ∧ c ∧ d ↔ (a ∧ c) ∧ b ∧ d := by\n  rw [← and_assoc, @and_right_comm a, and_assoc]\n\ntheorem and_and_left : a ∧ b ∧ c ↔ (a ∧ b) ∧ a ∧ c := by\n  rw [and_and_and_comm, and_self]\n\ntheorem and_and_right : (a ∧ b) ∧ c ↔ (a ∧ c) ∧ b ∧ c := by\n  rw [and_and_and_comm, and_self]\n\ntheorem and_iff_left_of_imp (h : a → b) : (a ∧ b) ↔ a :=\n  ⟨And.left, fun ha => ⟨ha, h ha⟩⟩\n\ntheorem and_iff_right_of_imp (h : b → a) : (a ∧ b) ↔ b :=\n  ⟨And.right, fun hb => ⟨h hb, hb⟩⟩\n\ntheorem and_iff_left (hb : b) : a ∧ b ↔ a := and_iff_left_of_imp fun _ => hb\n\ntheorem and_iff_right (ha : a) : a ∧ b ↔ b := and_iff_right_of_imp fun _ => ha\n\n@[simp] theorem and_iff_left_iff_imp : ((a ∧ b) ↔ a) ↔ (a → b) :=\n  ⟨fun h ha => (h.2 ha).2, and_iff_left_of_imp⟩\n\n@[simp] theorem and_iff_right_iff_imp : ((a ∧ b) ↔ b) ↔ (b → a) :=\n  ⟨fun h ha => (h.2 ha).1, and_iff_right_of_imp⟩\n\n@[simp] theorem iff_self_and : (p ↔ p ∧ q) ↔ (p → q) := by\n  rw [@Iff.comm p, and_iff_left_iff_imp]\n\n@[simp] theorem iff_and_self : (p ↔ q ∧ p) ↔ (p → q) := by rw [and_comm, iff_self_and]\n\n@[simp] theorem and_congr_right_iff : (a ∧ b ↔ a ∧ c) ↔ (a → (b ↔ c)) :=\n  ⟨fun h ha => by simp [ha] at h; exact h, and_congr_right⟩\n\n@[simp] theorem and_congr_left_iff : (a ∧ c ↔ b ∧ c) ↔ c → (a ↔ b) := by\n  simp only [and_comm, ← and_congr_right_iff]\n\n@[simp] theorem and_self_left : a ∧ a ∧ b ↔ a ∧ b :=\n  ⟨fun h => ⟨h.1, h.2.2⟩, fun h => ⟨h.1, h.1, h.2⟩⟩\n\n@[simp] theorem and_self_right : (a ∧ b) ∧ b ↔ a ∧ b :=\n  ⟨fun h => ⟨h.1.1, h.2⟩, fun h => ⟨⟨h.1, h.2⟩, h.2⟩⟩\n\ntheorem not_and_of_not_left (b : Prop) : ¬a → ¬(a ∧ b) := mt And.left\n\ntheorem not_and_of_not_right (a : Prop) {b : Prop} : ¬b → ¬(a ∧ b) := mt And.right\n\n@[simp] theorem and_not_self : ¬(a ∧ ¬a) | ⟨ha, hn⟩ => hn ha\n\n@[simp] theorem not_and_self : ¬(¬a ∧ a) | ⟨hn, ha⟩ => hn ha\n\ntheorem and_not_self_iff (a : Prop) : a ∧ ¬a ↔ False := iff_false_intro and_not_self\n\ntheorem not_and_self_iff (a : Prop) : ¬a ∧ a ↔ False := iff_false_intro not_and_self\n\n/-! ## or -/\n\ntheorem not_not_em (a : Prop) : ¬¬(a ∨ ¬a) := fun h => h (.inr (h ∘ .inl))\n\ntheorem Or.symm : a ∨ b → b ∨ a := .rec .inr .inl\n\ntheorem Or.imp (f : a → c) (g : b → d) (h : a ∨ b) : c ∨ d := h.elim (inl ∘ f) (inr ∘ g)\n\ntheorem Or.imp_left (f : a → b) : a ∨ c → b ∨ c := .imp f id\n\ntheorem Or.imp_right (f : b → c) : a ∨ b → a ∨ c := .imp id f\n\ntheorem or_congr (h₁ : a ↔ c) (h₂ : b ↔ d) : (a ∨ b) ↔ (c ∨ d) := ⟨.imp h₁.1 h₂.1, .imp h₁.2 h₂.2⟩\n\ntheorem or_congr_left (h : a ↔ b) : a ∨ c ↔ b ∨ c := or_congr h .rfl\n\ntheorem or_congr_right (h : b ↔ c) : a ∨ b ↔ a ∨ c := or_congr .rfl h\n\ntheorem Or.comm : a ∨ b ↔ b ∨ a := ⟨Or.symm, Or.symm⟩\n\ntheorem or_comm : a ∨ b ↔ b ∨ a := Or.comm\n\ntheorem or_assoc : (a ∨ b) ∨ c ↔ a ∨ (b ∨ c) :=\n  ⟨.rec (.imp_right .inl) (.inr ∘ .inr), .rec (.inl ∘ .inl) (.imp_left .inr)⟩\n\ntheorem Or.resolve_left {a b : Prop} (h: a ∨ b) (na : ¬a) : b := h.elim (absurd · na) id\n\ntheorem Or.neg_resolve_left (h : ¬a ∨ b) (ha : a) : b := h.elim (absurd ha) id\n\ntheorem Or.resolve_right {a b : Prop} (h: a ∨ b) (nb : ¬b) : a := h.elim id (absurd · nb)\n\ntheorem Or.neg_resolve_right (h : a ∨ ¬b) (nb : b) : a := h.elim id (absurd nb)\n\ntheorem or_left_comm : a ∨ (b ∨ c) ↔ b ∨ (a ∨ c) := by rw [← or_assoc, ← or_assoc, @or_comm a b]\n\ntheorem or_right_comm : (a ∨ b) ∨ c ↔ (a ∨ c) ∨ b := by rw [or_assoc, or_assoc, @or_comm b]\n\ntheorem or_or_or_comm : (a ∨ b) ∨ c ∨ d ↔ (a ∨ c) ∨ b ∨ d := by\n  rw [← or_assoc, @or_right_comm a, or_assoc]\n\ntheorem or_or_distrib_left : a ∨ b ∨ c ↔ (a ∨ b) ∨ a ∨ c := by rw [or_or_or_comm, or_self]\n\ntheorem or_or_distrib_right : (a ∨ b) ∨ c ↔ (a ∨ c) ∨ b ∨ c := by rw [or_or_or_comm, or_self]\n\ntheorem or_rotate : a ∨ b ∨ c ↔ b ∨ c ∨ a := by simp only [or_left_comm, Or.comm]\n\ntheorem or_iff_right_of_imp (ha : a → b) : (a ∨ b) ↔ b := ⟨Or.rec ha id, .inr⟩\n\ntheorem or_iff_left_of_imp (hb : b → a) : (a ∨ b) ↔ a := ⟨Or.rec id hb, .inl⟩\n\ntheorem not_or_intro {a b : Prop} (ha : ¬a) (hb : ¬b) : ¬(a ∨ b) := (·.elim ha hb)\n\n@[simp] theorem or_iff_left_iff_imp : (a ∨ b ↔ a) ↔ (b → a) :=\n  ⟨fun h hb => h.1 (Or.inr hb), or_iff_left_of_imp⟩\n\n@[simp] theorem or_iff_right_iff_imp : (a ∨ b ↔ b) ↔ (a → b) := by\n  rw [or_comm, or_iff_left_iff_imp]\n\ntheorem or_iff_left (hb : ¬b) : a ∨ b ↔ a := or_iff_left_iff_imp.2 hb.elim\n\ntheorem or_iff_right (ha : ¬a) : a ∨ b ↔ b := or_iff_right_iff_imp.2 ha.elim\n\n/-! ## distributivity -/\n\ntheorem not_imp_of_and_not : a ∧ ¬b → ¬(a → b)\n  | ⟨ha, hb⟩, h => hb <| h ha\n\ntheorem imp_and {α} : (α → b ∧ c) ↔ (α → b) ∧ (α → c) :=\n  ⟨fun h => ⟨fun ha => (h ha).1, fun ha => (h ha).2⟩, fun h ha => ⟨h.1 ha, h.2 ha⟩⟩\n\n@[simp] theorem and_imp : (a ∧ b → c) ↔ (a → b → c) :=\n  ⟨fun h ha hb => h ⟨ha, hb⟩, fun h ⟨ha, hb⟩ => h ha hb⟩\n\n@[simp] theorem not_and : ¬(a ∧ b) ↔ (a → ¬b) := and_imp\n\ntheorem not_and' : ¬(a ∧ b) ↔ b → ¬a := not_and.trans imp_not_comm\n\n/-- `∧` distributes over `∨` (on the left). -/\ntheorem and_or_left : a ∧ (b ∨ c) ↔ (a ∧ b) ∨ (a ∧ c) :=\n  ⟨fun ⟨ha, hbc⟩ => hbc.imp (.intro ha) (.intro ha), Or.rec (.imp_right .inl) (.imp_right .inr)⟩\n\n/-- `∧` distributes over `∨` (on the right). -/\ntheorem or_and_right : (a ∨ b) ∧ c ↔ (a ∧ c) ∨ (b ∧ c) := by\n  simp [and_comm, and_or_left]\n\n/-- `∨` distributes over `∧` (on the left). -/\ntheorem or_and_left : a ∨ (b ∧ c) ↔ (a ∨ b) ∧ (a ∨ c) :=\n  ⟨Or.rec (fun ha => ⟨.inl ha, .inl ha⟩) (.imp .inr .inr),\n   And.rec <| .rec (fun _ => .inl ·) (.imp_right ∘ .intro)⟩\n\n/-- `∨` distributes over `∧` (on the right). -/\ntheorem and_or_right : (a ∧ b) ∨ c ↔ (a ∨ c) ∧ (b ∨ c) := by\n  simp [or_comm, or_and_left]\n\ntheorem or_imp : (a ∨ b → c) ↔ (a → c) ∧ (b → c) :=\n  ⟨fun h => ⟨h ∘ .inl, h ∘ .inr⟩, fun ⟨ha, hb⟩ => Or.rec ha hb⟩\n\ntheorem not_or : ¬(p ∨ q) ↔ ¬p ∧ ¬q := or_imp\n\ntheorem not_and_of_not_or_not (h : ¬a ∨ ¬b) : ¬(a ∧ b) := h.elim (mt (·.1)) (mt (·.2))\n\n@[simp] theorem or_self_left : a ∨ a ∨ b ↔ a ∨ b := ⟨.rec .inl id, .rec .inl (.inr ∘ .inr)⟩\n\n@[simp] theorem or_self_right : (a ∨ b) ∨ b ↔ a ∨ b := ⟨.rec id .inr, .rec (.inl ∘ .inl) .inr⟩\n\n/-! ## exists and forall -/\n\nsection quantifiers\nvariable {p q : α → Prop} {b : Prop}\n\ntheorem forall_imp (h : ∀ a, p a → q a) : (∀ a, p a) → ∀ a, q a :=\nfun h' a => h a (h' a)\n\n@[simp] theorem forall_exists_index {q : (∃ x, p x) → Prop} :\n    (∀ h, q h) ↔ ∀ x (h : p x), q ⟨x, h⟩ :=\n  ⟨fun h x hpx => h ⟨x, hpx⟩, fun h ⟨x, hpx⟩ => h x hpx⟩\n\ntheorem Exists.imp (h : ∀ a, p a → q a) : (∃ a, p a) → ∃ a, q a\n  | ⟨a, hp⟩ => ⟨a, h a hp⟩\n\ntheorem Exists.imp' {β} {q : β → Prop} (f : α → β) (hpq : ∀ a, p a → q (f a)) :\n    (∃ a, p a) → ∃ b, q b\n  | ⟨_, hp⟩ => ⟨_, hpq _ hp⟩\n\ntheorem exists_imp : ((∃ x, p x) → b) ↔ ∀ x, p x → b := forall_exists_index\n\nsection forall_congr\n\n-- Port note: this is `forall_congr` from Lean 3. In Lean 4, there is already something\n-- with that name and a slightly different type.\ntheorem forall_congr' (h : ∀ a, p a ↔ q a) : (∀ a, p a) ↔ ∀ a, q a :=\n  ⟨fun H a => (h a).1 (H a), fun H a => (h a).2 (H a)⟩\n\ntheorem exists_congr (h : ∀ a, p a ↔ q a) : (∃ a, p a) ↔ ∃ a, q a :=\n  ⟨Exists.imp fun x => (h x).1, Exists.imp fun x => (h x).2⟩\n\nvariable {β : α → Sort _}\ntheorem forall₂_congr {p q : ∀ a, β a → Prop} (h : ∀ a b, p a b ↔ q a b) :\n    (∀ a b, p a b) ↔ ∀ a b, q a b :=\n  forall_congr' fun a => forall_congr' <| h a\n\ntheorem exists₂_congr {p q : ∀ a, β a → Prop} (h : ∀ a b, p a b ↔ q a b) :\n    (∃ a b, p a b) ↔ ∃ a b, q a b :=\n  exists_congr fun a => exists_congr <| h a\n\nvariable {γ : ∀ a, β a → Sort _}\ntheorem forall₃_congr {p q : ∀ a b, γ a b → Prop} (h : ∀ a b c, p a b c ↔ q a b c) :\n    (∀ a b c, p a b c) ↔ ∀ a b c, q a b c :=\n  forall_congr' fun a => forall₂_congr <| h a\n\ntheorem exists₃_congr {p q : ∀ a b, γ a b → Prop} (h : ∀ a b c, p a b c ↔ q a b c) :\n    (∃ a b c, p a b c) ↔ ∃ a b c, q a b c :=\n  exists_congr fun a => exists₂_congr <| h a\n\nvariable {δ : ∀ a b, γ a b → Sort _}\ntheorem forall₄_congr {p q : ∀ a b c, δ a b c → Prop} (h : ∀ a b c d, p a b c d ↔ q a b c d) :\n    (∀ a b c d, p a b c d) ↔ ∀ a b c d, q a b c d :=\n  forall_congr' fun a => forall₃_congr <| h a\n\ntheorem exists₄_congr {p q : ∀ a b c, δ a b c → Prop} (h : ∀ a b c d, p a b c d ↔ q a b c d) :\n    (∃ a b c d, p a b c d) ↔ ∃ a b c d, q a b c d :=\n  exists_congr fun a => exists₃_congr <| h a\n\nvariable {ε : ∀ a b c, δ a b c → Sort _}\ntheorem forall₅_congr {p q : ∀ a b c d, ε a b c d → Prop}\n    (h : ∀ a b c d e, p a b c d e ↔ q a b c d e) :\n    (∀ a b c d e, p a b c d e) ↔ ∀ a b c d e, q a b c d e :=\n  forall_congr' fun a => forall₄_congr <| h a\n\ntheorem exists₅_congr {p q : ∀ a b c d, ε a b c d → Prop}\n    (h : ∀ a b c d e, p a b c d e ↔ q a b c d e) :\n    (∃ a b c d e, p a b c d e) ↔ ∃ a b c d e, q a b c d e :=\n  exists_congr fun a => exists₄_congr <| h a\n\nend forall_congr\n\n@[simp] theorem not_exists : (¬∃ x, p x) ↔ ∀ x, ¬p x := exists_imp\n\ntheorem forall_not_of_not_exists (hne : ¬∃ x, p x) (x) : ¬p x | hp => hne ⟨x, hp⟩\n\ntheorem forall_and : (∀ x, p x ∧ q x) ↔ (∀ x, p x) ∧ (∀ x, q x) :=\n  ⟨fun h => ⟨fun x => (h x).1, fun x => (h x).2⟩, fun ⟨h₁, h₂⟩ x => ⟨h₁ x, h₂ x⟩⟩\n\ntheorem exists_or : (∃ x, p x ∨ q x) ↔ (∃ x, p x) ∨ ∃ x, q x :=\n  ⟨fun | ⟨x, .inl h⟩ => .inl ⟨x, h⟩ | ⟨x, .inr h⟩ => .inr ⟨x, h⟩,\n   fun | .inl ⟨x, h⟩ => ⟨x, .inl h⟩ | .inr ⟨x, h⟩ => ⟨x, .inr h⟩⟩\n\n@[simp] theorem exists_false : ¬(∃ _a : α, False) := fun ⟨_, h⟩ => h\n\n@[simp] theorem forall_const (α : Sort _) [i : Nonempty α] : (α → b) ↔ b :=\n  ⟨i.elim, fun hb _ => hb⟩\n\ntheorem Exists.nonempty : (∃ x, p x) → Nonempty α | ⟨x, _⟩ => ⟨x⟩\n\n/-- Extract an element from a existential statement, using `Classical.choose`. -/\n-- This enables projection notation.\n@[reducible] noncomputable def Exists.choose (P : ∃ a, p a) : α := Classical.choose P\n\n/-- Show that an element extracted from `P : ∃ a, p a` using `P.choose` satisfies `p`. -/\ntheorem Exists.choose_spec {p : α → Prop} (P : ∃ a, p a) : p P.choose := Classical.choose_spec P\n\ntheorem not_forall_of_exists_not {p : α → Prop} : (∃ x, ¬p x) → ¬∀ x, p x\n  | ⟨x, hn⟩, h => hn (h x)\n\n@[simp] theorem forall_eq {p : α → Prop} {a' : α} : (∀ a, a = a' → p a) ↔ p a' :=\n  ⟨fun h => h a' rfl, fun h _ e => e.symm ▸ h⟩\n\n@[simp] theorem forall_eq' {a' : α} : (∀ a, a' = a → p a) ↔ p a' := by simp [@eq_comm _ a']\n\n@[simp] theorem exists_eq : ∃ a, a = a' := ⟨_, rfl⟩\n\n@[simp] theorem exists_eq' : ∃ a, a' = a := ⟨_, rfl⟩\n\n@[simp] theorem exists_eq_left : (∃ a, a = a' ∧ p a) ↔ p a' :=\n  ⟨fun ⟨_, e, h⟩ => e ▸ h, fun h => ⟨_, rfl, h⟩⟩\n\n@[simp] theorem exists_eq_right : (∃ a, p a ∧ a = a') ↔ p a' :=\n  (exists_congr <| by exact fun a => And.comm).trans exists_eq_left\n\n@[simp] theorem exists_and_left : (∃ x, b ∧ p x) ↔ b ∧ (∃ x, p x) :=\n  ⟨fun ⟨x, h, hp⟩ => ⟨h, x, hp⟩, fun ⟨h, x, hp⟩ => ⟨x, h, hp⟩⟩\n\n@[simp] theorem exists_and_right : (∃ x, p x ∧ b) ↔ (∃ x, p x) ∧ b := by simp [And.comm]\n\n@[simp] theorem exists_eq_left' : (∃ a, a' = a ∧ p a) ↔ p a' := by simp [@eq_comm _ a']\n\n-- this theorem is needed to simplify the output of `list.mem_cons_iff`\n@[simp] theorem forall_eq_or_imp : (∀ a, a = a' ∨ q a → p a) ↔ p a' ∧ ∀ a, q a → p a := by\n  simp only [or_imp, forall_and, forall_eq]\n\n@[simp] theorem exists_eq_or_imp : (∃ a, (a = a' ∨ q a) ∧ p a) ↔ p a' ∨ ∃ a, q a ∧ p a := by\n  simp only [or_and_right, exists_or, exists_eq_left]\n\n@[simp] theorem exists_eq_right_right : (∃ (a : α), p a ∧ b ∧ a = a') ↔ p a' ∧ b := by\n  simp [← and_assoc]\n\n@[simp] theorem exists_eq_right_right' : (∃ (a : α), p a ∧ b ∧ a' = a) ↔ p a' ∧ b := by\n  (conv in _=_ => rw [eq_comm]); simp\n\n@[simp] theorem exists_prop : (∃ _h : a, b) ↔ a ∧ b :=\n  ⟨fun ⟨hp, hq⟩ => ⟨hp, hq⟩, fun ⟨hp, hq⟩ => ⟨hp, hq⟩⟩\n\n@[simp] theorem exists_apply_eq_apply (f : α → β) (a' : α) : ∃ a, f a = f a' := ⟨a', rfl⟩\n\ntheorem forall_prop_of_true {p : Prop} {q : p → Prop} (h : p) : (∀ h' : p, q h') ↔ q h :=\n  @forall_const (q h) p ⟨h⟩\n\nend quantifiers\n\n/-! ## decidable -/\n\ntheorem Decidable.not_not [Decidable p] : ¬¬p ↔ p := ⟨of_not_not, not_not_intro⟩\n\n/-- Construct a non-Prop by cases on an `Or`, when the left conjunct is decidable. -/\nprotected def Or.by_cases [Decidable p] {α : Sort u} (h : p ∨ q) (h₁ : p → α) (h₂ : q → α) : α :=\n  if hp : p then h₁ hp else h₂ (h.resolve_left hp)\n\n/-- Construct a non-Prop by cases on an `Or`, when the right conjunct is decidable. -/\nprotected def Or.by_cases' [Decidable q] {α : Sort u} (h : p ∨ q) (h₁ : p → α) (h₂ : q → α) : α :=\n  if hq : q then h₂ hq else h₁ (h.resolve_right hq)\n\ninstance exists_prop_decidable {p} (P : p → Prop)\n  [Decidable p] [∀ h, Decidable (P h)] : Decidable (∃ h, P h) :=\nif h : p then\n  decidable_of_decidable_of_iff ⟨fun h2 => ⟨h, h2⟩, fun ⟨_, h2⟩ => h2⟩\nelse isFalse fun ⟨h', _⟩ => h h'\n\ninstance forall_prop_decidable {p} (P : p → Prop)\n  [Decidable p] [∀ h, Decidable (P h)] : Decidable (∀ h, P h) :=\nif h : p then\n  decidable_of_decidable_of_iff ⟨fun h2 _ => h2, fun al => al h⟩\nelse isTrue fun h2 => absurd h2 h\n\ntheorem decide_eq_true_iff (p : Prop) [Decidable p] : (decide p = true) ↔ p := by simp\n\n@[simp] theorem decide_eq_false_iff_not (p : Prop) [Decidable p] : (decide p = false) ↔ ¬p :=\n  ⟨of_decide_eq_false, decide_eq_false⟩\n\n@[simp] theorem decide_eq_decide {p q : Prop} [Decidable p] [Decidable q] :\n    decide p = decide q ↔ (p ↔ q) :=\n  ⟨fun h => by rw [← decide_eq_true_iff p, h, decide_eq_true_iff], fun h => by simp [h]⟩\n\ntheorem Decidable.of_not_imp [Decidable a] (h : ¬(a → b)) : a :=\n  byContradiction (not_not_of_not_imp h)\n\ntheorem Decidable.not_imp_symm [Decidable a] (h : ¬a → b) (hb : ¬b) : a :=\n  byContradiction <| hb ∘ h\n\ntheorem Decidable.not_imp_comm [Decidable a] [Decidable b] : (¬a → b) ↔ (¬b → a) :=\n  ⟨not_imp_symm, not_imp_symm⟩\n\ntheorem Decidable.not_imp_self [Decidable a] : (¬a → a) ↔ a := by\n  have := @imp_not_self (¬a); rwa [not_not] at this\n\ntheorem Decidable.or_iff_not_imp_left [Decidable a] : a ∨ b ↔ (¬a → b) :=\n  ⟨Or.resolve_left, fun h => dite _ .inl (.inr ∘ h)⟩\n\ntheorem Decidable.or_iff_not_imp_right [Decidable b] : a ∨ b ↔ (¬b → a) :=\nor_comm.trans or_iff_not_imp_left\n\ntheorem Decidable.not_imp_not [Decidable a] : (¬a → ¬b) ↔ (b → a) :=\n⟨fun h hb => byContradiction (h · hb), mt⟩\n\ntheorem Decidable.not_or_of_imp [Decidable a] (h : a → b) : ¬a ∨ b :=\n  if ha : a then .inr (h ha) else .inl ha\n\ntheorem Decidable.imp_iff_not_or [Decidable a] : (a → b) ↔ (¬a ∨ b) :=\n  ⟨not_or_of_imp, Or.neg_resolve_left⟩\n\ntheorem Decidable.imp_iff_or_not [Decidable b] : b → a ↔ a ∨ ¬b :=\n  Decidable.imp_iff_not_or.trans or_comm\n\ntheorem Decidable.imp_or [Decidable a] : (a → b ∨ c) ↔ (a → b) ∨ (a → c) := by\n  by_cases a <;> simp_all\n\ntheorem Decidable.imp_or' [Decidable b] : (a → b ∨ c) ↔ (a → b) ∨ (a → c) :=\n  if h : b then by simp [h] else by\n    rw [eq_false h, false_or]; exact (or_iff_right_of_imp fun hx x => (hx x).elim).symm\n\ntheorem Decidable.not_imp [Decidable a] : ¬(a → b) ↔ a ∧ ¬b :=\n  ⟨fun h => ⟨of_not_imp h, not_of_not_imp h⟩, not_imp_of_and_not⟩\n\ntheorem Decidable.peirce (a b : Prop) [Decidable a] : ((a → b) → a) → a :=\n  if ha : a then fun _ => ha else fun h => h ha.elim\n\ntheorem peirce' {a : Prop} (H : ∀ b : Prop, (a → b) → a) : a := H _ id\n\ntheorem Decidable.not_iff_not [Decidable a] [Decidable b] : (¬a ↔ ¬b) ↔ (a ↔ b) := by\n  rw [@iff_def (¬a), @iff_def' a]; exact and_congr not_imp_not not_imp_not\n\ntheorem Decidable.not_iff_comm [Decidable a] [Decidable b] : (¬a ↔ b) ↔ (¬b ↔ a) := by\n  rw [@iff_def (¬a), @iff_def (¬b)]; exact and_congr not_imp_comm imp_not_comm\n\ntheorem Decidable.not_iff [Decidable b] : ¬(a ↔ b) ↔ (¬a ↔ b) := by\n  by_cases h : b <;> simp [h, iff_true, iff_false]\n\ntheorem Decidable.iff_not_comm [Decidable a] [Decidable b] : (a ↔ ¬b) ↔ (b ↔ ¬a) := by\n  rw [@iff_def a, @iff_def b]; exact and_congr imp_not_comm not_imp_comm\n\ntheorem Decidable.iff_iff_and_or_not_and_not [Decidable b] : (a ↔ b) ↔ (a ∧ b) ∨ (¬a ∧ ¬b) :=\n  ⟨fun e => if h : b then .inl ⟨e.2 h, h⟩ else .inr ⟨mt e.1 h, h⟩,\n   Or.rec (And.rec iff_of_true) (And.rec iff_of_false)⟩\n\ntheorem Decidable.iff_iff_not_or_and_or_not [Decidable a] [Decidable b] :\n    (a ↔ b) ↔ (¬a ∨ b) ∧ (a ∨ ¬b) := by\n  rw [iff_iff_implies_and_implies a b]; simp only [imp_iff_not_or, Or.comm]\n\ntheorem Decidable.not_and_not_right [Decidable b] : ¬(a ∧ ¬b) ↔ (a → b) :=\n  ⟨fun h ha => not_imp_symm (And.intro ha) h, fun h ⟨ha, hb⟩ => hb <| h ha⟩\n\ntheorem Decidable.not_and [Decidable a] : ¬(a ∧ b) ↔ ¬a ∨ ¬b :=\n  ⟨fun h => if ha : a then .inr (h ⟨ha, ·⟩) else .inl ha, not_and_of_not_or_not⟩\n\ntheorem Decidable.not_and' [Decidable b] : ¬(a ∧ b) ↔ ¬a ∨ ¬b :=\n  ⟨fun h => if hb : b then .inl (h ⟨·, hb⟩) else .inr hb, not_and_of_not_or_not⟩\n\ntheorem Decidable.or_iff_not_and_not [Decidable a] [Decidable b] : a ∨ b ↔ ¬(¬a ∧ ¬b) := by\n  rw [← not_or, not_not]\n\ntheorem Decidable.and_iff_not_or_not [Decidable a] [Decidable b] : a ∧ b ↔ ¬(¬a ∨ ¬b) := by\n  rw [← not_and, not_not]\n\ntheorem Decidable.imp_iff_right_iff [Decidable a] : (a → b ↔ b) ↔ a ∨ b :=\n  ⟨fun H => (Decidable.em a).imp_right fun ha' => H.1 fun ha => (ha' ha).elim,\n   fun H => H.elim imp_iff_right fun hb => iff_of_true (fun _ => hb) hb⟩\n\ntheorem Decidable.and_or_imp [Decidable a] : a ∧ b ∨ (a → c) ↔ a → b ∨ c :=\n  if ha : a then by simp only [ha, true_and, true_imp_iff]\n  else by simp only [ha, false_or, false_and, false_imp_iff]\n\ntheorem Decidable.or_congr_left' [Decidable c] (h : ¬c → (a ↔ b)) : a ∨ c ↔ b ∨ c := by\n  rw [or_iff_not_imp_right, or_iff_not_imp_right]; exact imp_congr_right h\n\ntheorem Decidable.or_congr_right' [Decidable a] (h : ¬a → (b ↔ c)) : a ∨ b ↔ a ∨ c := by\n  rw [or_iff_not_imp_left, or_iff_not_imp_left]; exact imp_congr_right h\n\n/-- Transfer decidability of `a` to decidability of `b`, if the propositions are equivalent.\n**Important**: this function should be used instead of `rw` on `decidable b`, because the\nkernel will get stuck reducing the usage of `propext` otherwise,\nand `dec_trivial` will not work. -/\n@[inline] def decidable_of_iff (a : Prop) (h : a ↔ b) [Decidable a] : Decidable b :=\n  decidable_of_decidable_of_iff h\n\n/-- Transfer decidability of `b` to decidability of `a`, if the propositions are equivalent.\nThis is the same as `decidable_of_iff` but the iff is flipped. -/\n@[inline] def decidable_of_iff' (b : Prop) (h : a ↔ b) [Decidable b] : Decidable a :=\n  decidable_of_decidable_of_iff h.symm\n\ninstance Decidable.predToBool (p : α → Prop) [DecidablePred p] :\n    CoeDep (α → Prop) p (α → Bool) := ⟨fun b => decide <| p b⟩\n\ntheorem Bool.ff_ne_tt : false ≠ true := fun.\n\n/-- Prove that `a` is decidable by constructing a boolean `b` and a proof that `b ↔ a`.\n(This is sometimes taken as an alternate definition of decidability.) -/\ndef decidable_of_bool : ∀ (b : Bool), (b ↔ a) → Decidable a\n  | true, h => isTrue (h.1 rfl)\n  | false, h => isFalse (mt h.2 Bool.ff_ne_tt)\n\n/-! ## classical logic -/\n\nnamespace Classical\n\n/-- The Double Negation Theorem: `¬¬P` is equivalent to `P`.\nThe left-to-right direction, double negation elimination (DNE),\nis classically true but not constructively. -/\n@[scoped simp] theorem not_not : ¬¬a ↔ a := Decidable.not_not\n\nend Classical\n\n/-! ## equality -/\n\ntheorem heq_iff_eq : HEq a b ↔ a = b := ⟨eq_of_heq, heq_of_eq⟩\n\ntheorem proof_irrel_heq {p q : Prop} (hp : p) (hq : q) : HEq hp hq := by\n  cases propext (iff_of_true hp hq); rfl\n\n@[simp] theorem eq_rec_constant {α : Sort _} {a a' : α} {β : Sort _} (y : β) (h : a = a') :\n    (@Eq.rec α a (fun α _ => β) y a' h) = y := by cases h; rfl\n\ntheorem congrArg₂ (f : α → β → γ) {x x' : α} {y y' : β}\n    (hx : x = x') (hy : y = y') : f x y = f x' y' := by subst hx hy; rfl\n\n/-! ## membership -/\n\nsection Mem\nvariable [Membership α β] {s t : β} {a b : α}\n\ntheorem ne_of_mem_of_not_mem (h : a ∈ s) : b ∉ s → a ≠ b := mt fun e => e ▸ h\n\ntheorem ne_of_mem_of_not_mem' (h : a ∈ s) : a ∉ t → s ≠ t := mt fun e => e ▸ h\n\nend Mem\n\n/-! ## if-then-else -/\n\n@[simp] theorem if_true {h : Decidable True} (t e : α) : ite True t e = t := if_pos trivial\n\n@[simp] theorem if_false {h : Decidable False} (t e : α) : ite False t e = e := if_neg id\n\ntheorem ite_id [Decidable c] {α} (t : α) : (if c then t else t) = t := by split <;> rfl\n\n/-- A function applied to a `dite` is a `dite` of that function applied to each of the branches. -/\ntheorem apply_dite (f : α → β) (P : Prop) [Decidable P] (x : P → α) (y : ¬P → α) :\n    f (dite P x y) = dite P (fun h => f (x h)) (fun h => f (y h)) := by\n  by_cases h : P <;> simp [h]\n\n/-- A function applied to a `ite` is a `ite` of that function applied to each of the branches. -/\ntheorem apply_ite (f : α → β) (P : Prop) [Decidable P] (x y : α) :\n    f (ite P x y) = ite P (f x) (f y) :=\n  apply_dite f P (fun _ => x) (fun _ => y)\n\n/-- Negation of the condition `P : Prop` in a `dite` is the same as swapping the branches. -/\n@[simp] theorem dite_not (P : Prop) [Decidable P]  (x : ¬P → α) (y : ¬¬P → α) :\n    dite (¬P) x y = dite P (fun h => y (not_not_intro h)) x := by\n  by_cases h : P <;> simp [h]\n\n/-- Negation of the condition `P : Prop` in a `ite` is the same as swapping the branches. -/\n@[simp] theorem ite_not (P : Prop) [Decidable P] (x y : α) : ite (¬P) x y = ite P y x :=\n  dite_not P (fun _ => x) (fun _ => y)\n\n/-! ## miscellaneous -/\n\nattribute [simp] inline\n\n/-- Ex falso, the nondependent eliminator for the `Empty` type. -/\ndef Empty.elim : Empty → C := fun.\n\ninstance : Subsingleton Empty := ⟨fun a => a.elim⟩\n\ninstance : DecidableEq Empty := fun a => a.elim\n\n/-- Ex falso, the nondependent eliminator for the `PEmpty` type. -/\ndef PEmpty.elim : PEmpty → C := fun.\n\ninstance : Subsingleton PEmpty := ⟨fun a => a.elim⟩\n\ninstance : DecidableEq PEmpty := fun a => a.elim\n\n@[simp] theorem not_nonempty_empty : ¬Nonempty Empty := fun ⟨h⟩ => h.elim\n\n@[simp] theorem not_nonempty_pempty : ¬Nonempty PEmpty := fun ⟨h⟩ => h.elim\n\ninstance [Subsingleton α] [Subsingleton β] : Subsingleton (α × β) :=\n  ⟨fun {..} {..} => by congr <;> apply Subsingleton.elim⟩\n\ninstance : Inhabited (Sort _) := ⟨PUnit⟩\n\ninstance : Inhabited default := ⟨PUnit.unit⟩\n\ninstance {α β} [Inhabited α] : Inhabited (PSum α β) := ⟨PSum.inl default⟩\n\ninstance {α β} [Inhabited β] : Inhabited (PSum α β) := ⟨PSum.inr default⟩\n\n-- TODO(Mario): profile first, this is a dangerous instance\n-- instance (priority := 10) {α} [Subsingleton α] : DecidableEq α\n--   | a, b => isTrue (Subsingleton.elim a b)\n\n-- @[simp] -- TODO(Mario): profile\ntheorem eq_iff_true_of_subsingleton [Subsingleton α] (x y : α) : x = y ↔ True :=\n  iff_true_intro (Subsingleton.elim ..)\n\n/-- If all points are equal to a given point `x`, then `α` is a subsingleton. -/\ntheorem subsingleton_of_forall_eq (x : α) (h : ∀ y, y = x) : Subsingleton α :=\n  ⟨fun a b => h a ▸ h b ▸ rfl⟩\n\ntheorem subsingleton_iff_forall_eq (x : α) : Subsingleton α ↔ ∀ y, y = x :=\n  ⟨fun _ y => Subsingleton.elim y x, subsingleton_of_forall_eq x⟩\n\nexample [Subsingleton α] (p : α → Prop) : Subsingleton (Subtype p) :=\n  ⟨fun ⟨x, _⟩ ⟨y, _⟩ => by congr; exact Subsingleton.elim x y⟩\n\ntheorem false_ne_true : False ≠ True := fun h => h.symm ▸ trivial\n\ntheorem Bool.eq_false_or_eq_true : (b : Bool) → b = true ∨ b = false\n  | true => .inl rfl\n  | false => .inr rfl\n\ntheorem Bool.eq_false_iff {b : Bool} : b = false ↔ b ≠ true :=\n  ⟨ne_true_of_eq_false, eq_false_of_ne_true⟩\n\ntheorem ne_comm {α} {a b : α} : a ≠ b ↔ b ≠ a := ⟨Ne.symm, Ne.symm⟩\n", "meta": {"author": "leanprover", "repo": "std4", "sha": "5507f9d8409f93b984ce04eccf4914d534e6fca2", "save_path": "github-repos/lean/leanprover-std4", "path": "github-repos/lean/leanprover-std4/std4-5507f9d8409f93b984ce04eccf4914d534e6fca2/Std/Logic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477015, "lm_q2_score": 0.7577943658046609, "lm_q1q2_score": 0.4881901663577589}}
{"text": "import ring_theory.algebraic\n-- import data.finset\n-- import algebra.field\n-- import field_theory.subfield\nimport field_theory.algebraic_closure\n-- import order.zorn\nimport Rings.ToMathlib\n-- import data.mv_polynomial.equiv\n-- import data.equiv.fin\n\nopen classical\nlocal attribute [instance] prop_decidable\n\nuniverses u v\n\n\nsection nttn\n\nvariables\n  (K : Type u)\n\n@[simp] def algebra.image (L : Type v) [comm_semiring K] [semiring L] [algebra K L] : set L :=\nset.range (algebra_map K L)\n\n@[simp] def subfield_generated {L : Type v} [field K] [field L] [algebra K L] (S : set L)\n  : subfield L :=\nsubfield.closure (S ∪ algebra.image K L)\n\nlemma subfield_generated.subset_closure\n  {K : Type u} {L : Type v} [field K] [field L] [algebra K L] {S : set L} :\n  S ⊆ subfield_generated K S :=\nbegin\n  intros _ hs,\n  simp only [algebra.image, subfield_generated, set_like.mem_coe],\n  apply subfield.subset_closure,\n  left,\n  exact hs,\nend\n\nend nttn\n\nnamespace transcendent\n\nvariables\n  (K : Type u) {L : Type u} [field K] [field L] [algebra K L]\n\ndef indep (S : set L) : Prop :=\nΠ (n : ℕ) (f : mv_polynomial (fin n) K) (as : fin n → L),\n(Π k, as k ∈ S) → mv_polynomial.eval as (f : mv_polynomial (fin n) L) = 0 → f = 0\n\nlemma indep_subset (S T : set L) (hST : S ⊆ T) : indep K T → indep K S :=\nbegin\n  intros hT _ f as has hf,\n  have has' : Π k, as k ∈ T := λ k, hST (has k),\n  exact hT _ f as has' hf,\nend\n\n\nlemma indep_empty : indep K (∅ : set L)\n| nat.zero f as has hf :=\nbegin\n  apply @mv_polynomial.map_injective K L (fin 0) _ _ (algebra_map K L) (ring_hom.injective _),\n  simp,\n  rw mv_polynomial.is_empty (fin.is_empty) (mv_polynomial.map (algebra_map K L) f) as,\n  rw ← mv_polynomial.C_0,\n  rw (mv_polynomial.C_inj L),\n  rw ← hf,\n  simp only [mv_polynomial.eval, mv_polynomial.eval_map],\n  unfold_coes,\nend\n| (nat.succ n) f as has hf :=\nbegin\n  exfalso,\n  rw ← set.mem_empty_eq (as 0),\n  {apply has},\nend\n\nlemma indep_sUnion_chain {c : set (set L)} (hchain : zorn.chain has_subset.subset c)\n  (h0 : c.nonempty)\n  (hc : Π (S : set L) (hS : S ∈ c), indep K S) :\n  indep K ⋃₀ c :=\nbegin\n  intros k f as has hf,\n  cases zorn.fin_range_sub_mem_chain_of_sub_union hchain h0 as has with S hS,\n  cases hS with hSc hS,\n  apply hc S hSc _ _ as _ hf,\n  exact hS,\nend\n\ndef basis (B : set L) : Prop := indep K B ∧ Π (S : set L), indep K S → B ⊆ S → S = B\n\nlemma extend_to_basis_aux (S : set L) (hindS : indep K S) :\n  ∃ (B : set L) (H : B ∈ {T : set L | S ⊆ T ∧ indep K T}),\n  S ⊆ B ∧ Π (T : set L), T ∈ {T : set L | S ⊆ T ∧ indep K T} → B ⊆ T → T = B :=\n(@zorn.zorn_subset_nonempty L { T : set L | S ⊆ T ∧ indep K T }\n  (λ c hcsub hchain hc0,\n    ⟨\n      -- the upper bound by taking union\n      ⋃₀ c ,\n      ⟨\n        let hScup : S ⊆ ⋃₀ c :=\n        begin\n          cases hc0 with T hT,\n          cases hcsub hT with hST hand,\n          have hTcup : T ⊆ ⋃₀ c := λ t ht , ⟨ T , hT , ht ⟩,\n          exact set.subset.trans hST hTcup,\n        end in\n        ⟨ -- the upper bound is in the set\n          hScup ,\n          indep_sUnion_chain K hchain hc0 (λ S hs, (hcsub hs).2)\n        ⟩ ,\n        (λ S hS s hs, ⟨ S , hS , hs ⟩) -- showing the maximal element is in the set\n      ⟩\n    ⟩\n  )\n  S -- give U for the set being non-empty\n  ⟨ set.subset.refl _ , hindS ⟩)\n\n#check is_algebraic_algebra_map\n\nlemma subfield_mem (a : L) (K : subfield L) (haK : a ∈ K) :\n  a = algebra_map K L (⟨ a , haK ⟩ : K) := rfl\n\nlemma is_algebraic_subfield {a : L} {K : subfield L} (haK : a ∈ K) : is_algebraic K a :=\n⟨\n  polynomial.X - polynomial.C (⟨ a , haK ⟩ : K) ,\n  polynomial.X_sub_C_ne_zero _ ,\n  begin\n    simp only [polynomial.aeval_X, polynomial.aeval_C, alg_hom.map_sub],\n    rw ← subfield_mem a K haK,\n    simp,\n  end\n⟩\n\n#check ite\n\nlemma algebraic_over_basis (B : set L) (hB : basis K B) :\n  algebra.is_algebraic (subfield_generated K B) L :=\nbegin\n  intro x,\n  by_cases hind : indep K (B ∪ {x}),\n  {\n    have hBx := hB.2 (B ∪ {x}) hind (by simp),\n    have hxBx : x ∈ subfield_generated K B,\n    {apply subfield.subset_closure, left, rw ← hBx, right, exact set.mem_singleton x},\n    apply is_algebraic_subfield hxBx,\n  },\n  {\n    simp only [indep, not_forall] at hind,\n    cases hind with n hind,\n    cases hind with f hind,\n    cases hind with as hind,\n    cases hind with has hind,\n    cases hind with hf hf0,\n    have bs : fin n → polynomial (subfield_generated K B) :=\n    λ k, @decidable.rec_on (as k ∈ B) (λ k, polynomial (subfield_generated K B)) _\n      (λ _, polynomial.X)\n      (λ h, polynomial.C (⟨ as k , subfield_generated.subset_closure h ⟩ : subfield_generated K B)),\n\n    -- have p : polynomial (subfield_generated K B) := mv_polynomial.eval₂ _ _,\n\n  }\nend\n\nvariables (K) (L)\n\nlemma extend_to_basis (S : set L) (hindS : indep K S) :\n    ∃ (B : set L), S ⊆ B ∧ basis K B :=\nbegin\n  cases extend_to_basis_aux K S hindS with B hB,\n  cases hB with hmem hB,\n  cases hB with hSB hbasis,\n  use B,\n  split,\n  {exact hSB},\n  {\n    split,\n    {exact hmem.2},\n    {\n      intros T hindT hBT,\n      apply hbasis T _ hBT,\n      exact ⟨ set.subset.trans hSB hBT , hindT ⟩,\n    }\n  }\nend\n\nlemma basis_ex : ∃ (B : set L), basis K B :=\nbegin\n  cases extend_to_basis K L ∅ (indep_empty K) with B hB,\n  use B,\n  exact hB.2,\nend\n\nlemma basis_some : set L := @classical.some (set L) (λ S, basis K S) (basis_ex K L)\n\nlemma degree : cardinal.{u} := cardinal.mk (basis_some K L)\n\n\nend transcendent\n\n\nnamespace field_theory\n\nvariables\n  {K L0 L1 : Type u}\n  [field K] [field L0] [field L1]\n  [algebra K L0] [algebra K L1]\n\nopen transcendent algebra\n\nlemma iso_of_bij_indep (S0 : set L0) (S1 : set L1) :\n  indep K S0 → indep K S1 → equiv S0 S1 →\n  subfield_generated K S0 ≃+* subfield_generated K S1 :=\nsorry\n\nlemma iso_of_alg_closed_algebraic\n  {K0 K1 L0 L1: Type u} [field K0] [field K1] [field L0] [field L1]\n  [is_alg_closed L0] [is_alg_closed L1]\n  [algebra K0 L0] [algebra K1 L1] : K0 ≃+* K1 →\n  is_algebraic K0 L0 → is_algebraic K1 L1 → L0 ≃+* L1 := sorry\n\nlemma iso_of_alg_closed_of_eq_trans_deg [is_alg_closed L0] [is_alg_closed L1]\n  (B0 : set L0) (B1 : set L1) : transcendent.basis K B0 → transcendent.basis K B1 →\n  equiv B0 B1\n  → L0 ≃+* L1 :=\nbegin\n  intros hB0 hB1 htdeg,\n  apply iso_of_alg_closed_algebraic _\n  (algebraic_over_basis K B0 hB0)\n  (algebraic_over_basis K B1 hB1),\n  apply iso_of_bij_indep B0 B1 hB0.1 hB1.1 htdeg,\nend\n\n\n\nend field_theory\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/TranscendenceDegree (19 Aug).lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.48815264826031607}}
{"text": "/-\nCopyright (c) 2018 Luca Gerolla. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Luca Gerolla, Mario Carneiro, Kevin Buzzard\nDefinition of path, loop and basic properties. \n-/\nimport analysis.topology.continuity\nimport analysis.topology.topological_space\nimport analysis.topology.infinite_sum\nimport analysis.topology.topological_structures\nimport analysis.topology.uniform_space\nimport analysis.real\nimport data.real.basic tactic.norm_num\nimport data.set.basic\nimport Topology.Material.pasting_lemma\nimport Topology.Material.real_results\n\nuniverse u\n\nopen set filter lattice classical\n\nnoncomputable theory \n\nnamespace path\n\n\n---- PATH and I01 DEFINITION\n/- The following definition of path was created by Mario Carneiro -/\n\nvariables {α  : Type*} [topological_space α ] \n\n\ndef I01 := {x : ℝ | 0 ≤ x ∧ x ≤ 1}\n\n\ninstance : topological_space I01 := by unfold I01; apply_instance\ninstance : has_zero I01 := ⟨⟨0, le_refl _, zero_le_one⟩⟩\ninstance : has_one I01 := ⟨⟨1, zero_le_one, le_refl _⟩⟩\n\n                                                                                                \n\nstructure path (x y : α) :=\n(to_fun : I01 → α)\n(at_zero : to_fun 0 = x)\n(at_one : to_fun 1 = y)\n(cont : continuous to_fun)\n\n\n\ninstance {α} [topological_space α] (x y : α) : has_coe_to_fun (path x y) := ⟨_, path.to_fun⟩ \n\n\n\n----------\n\n--attribute [class] path \n\n\n\n-- PATH INTERFACE\n\n@[simp]\nlemma start_pt_path { x y : α } ( f : path x y ) : f.to_fun 0 = x := f.2\n\n@[simp]\nlemma end_pt_path { x y : α } ( f : path x y ) : f.to_fun 1 = y := f.3\n\n\n-- for later paths homotopy -- checking ending points -- Can Remove \ndef equal_of_pts (f g : I01 → α ) : Prop := f 0 = g 0 ∧ f 1 = g 1\n\ndef equal_of_pts_path { z w x y : α } ( g1 : path x y ) ( g2 : path z w) : Prop := equal_of_pts g1 g2\n\ndef check_pts ( x y : α ) ( g : I01 → α ) := g 0 = x ∧ g 1 = y\n\ndef check_pts_of_path ( x y : α ) { z w : α } ( h : path z w ) := check_pts x y h.to_fun\n------\n\n-- For equality of path, necessary and sufficient equality of constructor \ntheorem path_equal { x y : α } { f g : path x y } : f = g  ↔  f.to_fun = g.to_fun := \nbegin split, intro h₁, rw h₁, intro h₂, cases f, cases g, cc  end \n\n-- for later paths homotopy\ndef is_path ( x y : α ) ( f : I01 → α ) : Prop := f 0 = x ∧ f 1 = y ∧ continuous f \n\n\ndef to_path' { x y : α} ( f : I01 → α ) ( H : is_path x y f) : path x y := \n{  to_fun := f,\n   at_zero := H.left,\n   at_one := H.right.left,\n   cont := H.right.right  \n}\n\ndef to_path { x y : α} ( f : I01 → α ) ( h : is_path x y f) : path x y := \npath.mk f h.1 h.2.1 h.2.2\n\n--- Can Remove\nlemma cont_of_path { z w : α }( g : path z w ) : continuous g.to_fun := g.cont \n\n--- Can Remove\ndef fun_of_path {α} [topological_space α ]  { x1 x2 : α  } ( g : path x1 x2 ) : I01 → α   := g.to_fun  \n\n--------------------\n\n\n\n--- COMPOSITION OF PATHS\n\n-- Unit interval is closed\nlemma is_closed_I01 : is_closed I01 := \nbegin exact @is_closed_int_clos 0 1 (by norm_num) end \n\n-- Define closed subintervals of I01 = [0, 1] \ndefinition T ( a b : ℝ ) ( Hab : a < b ) : set I01 :=  { x : I01 | a ≤ x.val ∧ x.val ≤ b }  \n\n-- Prove any T r s Hrs is closed in I01\nlemma T_is_closed  { r s : ℝ } ( Hrs : r < s )  : is_closed (T r s Hrs) := \nbegin \n  let R := {x : ↥I01 | r ≤ x.val }, let L := {x : ↥I01 |  x.val ≤ s } , \n  have C1 : is_closed L, \n    { rw is_closed_induced_iff,\n    existsi {x : ℝ | 0 ≤ x ∧ x ≤ (min 1 s)},\n    split,\n      exact is_closed_inter (is_closed_ge' 0)  (is_closed_le' _),\n      apply set.ext, intro x,\n      show x.val ≤ s ↔ 0 ≤ x.val ∧ x.val ≤ min 1 s,\n      split,\n        intro H,\n        split,\n          exact x.property.1,\n          apply le_min,exact x.property.2,assumption,\n        intro H,\n      exact le_trans H.2 (min_le_right _ _), }, \n  have C2 : is_closed R, \n    {rw is_closed_induced_iff,\n    existsi {x : ℝ | (max 0 r) ≤ x ∧ x ≤ 1},\n    split, \n      exact is_closed_inter (is_closed_ge' _)  (is_closed_le' 1), \n      apply set.ext, intro x,\n      show r ≤ x.val ↔ max 0 r ≤ x.val ∧ x.val ≤ 1, \n      split, \n        intro H, \n        split, \n          exact max_le x.2.1 H, \n          exact x.2.2, \n        intro H, exact (max_le_iff.1 H.1).2,  }, \n  have Int : T r s Hrs = set.inter R L, unfold T set.inter, simp, \n  exact (is_closed_inter C2 C1), \nend \n\n-- Reparametrisation from T _ _ _ to I01\ndefinition par {r s : ℝ} (Hrs : r < s) : T r s Hrs → I01 :=  \nλ x, ⟨ (x.val - r)/(s - r) , \nbegin \n  have D1 : 0 < (s - r) , by apply sub_pos.2 Hrs, \n  have D2 : 0 < (s - r)⁻¹, by exact inv_pos D1,   \n  have N1 : 0 ≤ ((x.val : ℝ ) - r), \n      by exact sub_nonneg.2 (x.property.1), \n  have N2 : (x.val : ℝ )- r ≤ s - r,\n      { have this : -r ≤ -r, trivial, \n      show (x.val : ℝ ) + - r ≤ s + - r,\n      exact add_le_add (x.property.2) this,}, \n  split, \n    show 0 ≤ ((x.val : ℝ ) - r) * (s - r)⁻¹, \n      by exact mul_nonneg N1 (le_of_lt D2),  \n    have H1 : 0 < (s - r), by exact sub_pos.2 Hrs,\n    have H2 : ((x.val : ℝ ) - r) / (s - r) ≤ (s - r) / (s - r),\n      by exact @div_le_div_of_le_of_pos _ _ ((x.val : ℝ ) - r) (s - r) (s - r) N2 H1,\n    rwa [@div_self _ _ (s - r) (ne.symm ( @ne_of_lt _ _ 0 (s - r) H1) ) ] at H2\nend ⟩  \n\n\n\n-- Continuity of reparametrisation (later employed in compositions of path/homotopy)\nlemma continuous_par {r s : ℝ} (Hrs : r < s) : continuous ( par Hrs ) := \nbegin \n  unfold par, apply continuous_subtype_mk,\n  show continuous (λ (x :  ↥(T r s Hrs)), ((x.1:ℝ ) - r) / (s - r)),\n  show continuous ((λ ( y: ℝ ), (y - r) / (s - r)) ∘ (λ (x : ↥(T r s Hrs)), x.val.val)), \n  have H : continuous (λ (x : ↥(T r s Hrs)), x.val.val), \n    exact continuous.comp continuous_subtype_val continuous_subtype_val , \n  exact continuous.comp H (real.continuous_scale (-r) (s-r)), \nend \n\n\n\n-----------------\n\n\n-- Define T1 = [0, 1/2] and  T2 = [1/2, 1] \nlemma zero_lt_half : 0 < (1 / 2 : ℝ ) := by norm_num\n\nlemma half_lt_one : (1 / 2 : ℝ ) < 1 := by norm_num\n\ndef T1 : set I01 := T 0 ( 1/2: ℝ ) ( zero_lt_half )\n\ndef T2 : set I01 := T ( 1/2: ℝ ) 1 ( half_lt_one  )\n\nlemma T1_is_closed : is_closed T1 := \nbegin unfold T1, exact T_is_closed _, end \n\nlemma T2_is_closed : is_closed T2 := \nbegin unfold T2, exact T_is_closed _, end \n\nlemma help_T1 : (0 : I01) ∈ T 0 (1/2) zero_lt_half := \nbegin unfold T, rw mem_set_of_eq, show 0 ≤ (0:ℝ)  ∧ ( 0:ℝ ) ≤ 1 / 2, norm_num,  end \n\nlemma help_T2 : (1 : I01) ∈ T (1 / 2) 1 half_lt_one := \nbegin unfold T, rw mem_set_of_eq, split, show 1/2 ≤ (1:ℝ) , norm_num, show (1:ℝ )≤ 1, norm_num,  end \n\n\nlemma help_01 : (1 / 2 :ℝ) ∈ I01 := begin unfold I01, rw mem_set_of_eq, norm_num end\n\nlemma help_02 : (1:I01) ∉ T1 := \nbegin unfold T1 T,rw mem_set_of_eq, show ¬(0 ≤ (1:ℝ ) ∧ (1:ℝ) ≤ 1 / 2) , norm_num  end \n\nlemma help_half_T1 : ( ⟨ 1/2, help_01⟩ : I01) ∈ T 0 (1/2) zero_lt_half := \nbegin \n  unfold T, exact set.mem_sep \n    (begin dsimp [has_mem.mem, -one_div_eq_inv], unfold set.mem, norm_num, end ) \n    (begin norm_num end ), \nend \n\n\nlemma help_half_T2 : ( ⟨ 1/2, help_01⟩  : I01) ∈ T (1/2) 1 half_lt_one := \nbegin \n  unfold T, exact set.mem_sep \n    (begin dsimp [has_mem.mem, -one_div_eq_inv], unfold set.mem, norm_num, end ) \n    (begin norm_num end ), \nend \n\n--- Intersection and covering of T1, T2\n\nlemma inter_T : set.inter T1 T2 = { x : I01 | x.val = 1/2 } := \nbegin \n  unfold T1 T2 T set.inter, dsimp [mem_set_of_eq, -one_div_eq_inv], apply set.ext, intro x, split, \n    {rw mem_set_of_eq , rw mem_set_of_eq, simp [-one_div_eq_inv], intros A B C D, \n    have H : x.val < 1 / 2 ∨ x.val = 1/2, by exact lt_or_eq_of_le B, \n    exact le_antisymm  B C, },    \n    rw mem_set_of_eq , rw mem_set_of_eq, intro H, rw H, norm_num,\nend\n\n\nlemma cover_I01 : T1 ∪ T2 = set.univ := \nbegin \n  unfold univ, unfold has_union.union , unfold T1 T2 T, apply set.ext, intro x,unfold set.union,  simp [mem_set_of_eq , -one_div_eq_inv], \n    split, intro H, simp [has_mem.mem], \n  intro B, simp [has_mem.mem] at B, unfold set.mem at B, \n  have H : 0≤ x.val ∧ x.val ≤ 1, exact x.property, simp [or_iff_not_imp_left, -one_div_eq_inv], \n  intro nL, have H2 : (1 / 2 :ℝ )< x.val, exact nL H.1, exact ⟨ le_of_lt H2, H.2 ⟩ ,\nend \n\nlemma T2_of_not_T1 { s : I01} : (s ∉ T1) → s ∈ T2 := \nbegin \n  intro H, have H2 : T1 ∪ T2 = @set.univ I01, exact cover_I01, unfold T1 T2 T at *, simp [-one_div_eq_inv],\n  rw mem_set_of_eq at H, rw not_and at H, have H3 : 1/2 < s.val, have H4 : ¬s.val ≤ 1 / 2, exact  H (s.2.1), exact lt_of_not_ge H4,\n  exact ⟨ le_of_lt H3, s.2.2⟩ , \nend\n\n---- Lemmas to simplify evaluations of par \n@[simp]\nlemma eqn_start : par zero_lt_half ⟨0, help_T1⟩ = 0 := \nbegin unfold par, simp [-one_div_eq_inv], exact subtype.mk_eq_mk.2 (begin exact zero_div _,  end  ), end  \n\n@[simp]\nlemma eqn_1 : par zero_lt_half ⟨⟨1 / 2, begin unfold I01, rw mem_set_of_eq, norm_num end⟩, begin unfold T, rw mem_set_of_eq, show 0 ≤ (1/2 : ℝ ) ∧ (1/2 : ℝ ) ≤ 1 / 2 ,  norm_num end ⟩ \n= 1 :=  begin unfold par, simp [-one_div_eq_inv], exact subtype.mk_eq_mk.2 (begin exact div_self (begin norm_num, end), end) end \n\n@[simp]\nlemma eqn_2 : par half_lt_one ⟨⟨1 / 2, help_01  ⟩, begin unfold T, rw mem_set_of_eq, show 1/2 ≤ (1/2 : ℝ ) ∧ (1/2 : ℝ ) ≤ 1  ,  norm_num end⟩ \n= 0 := begin unfold par, simp [-one_div_eq_inv], exact subtype.mk_eq_mk.2 (by refl) end \n\n@[simp]\nlemma eqn_end : par half_lt_one ⟨1, help_T2 ⟩ = 1 :=  \nbegin unfold par, exact subtype.mk_eq_mk.2 ( begin show ( ( 1:ℝ ) - 1 / 2) / (1 - 1 / 2) = 1,  norm_num, end ),  end \n\n-------------------------------------\n\n-- Definition and continuity of general / T1 / T2 reparametrisation of path function (path.to_fun)\n---------- to be used with cont_of_paste for path/homotopy composition \n\ndef fgen_path { x y : α } {r s : ℝ} (Hrs : r < s) (f : path x y ) : T r s Hrs → α := \nλ t, f.to_fun ( par Hrs t)\n\nlemma pp_cont { x y : α }{r s : ℝ} (Hrs : r < s)(f : path x y ) : continuous (fgen_path Hrs f) := \nbegin unfold fgen_path, exact continuous.comp (continuous_par Hrs) f.cont, end \n\ndefinition fa_path { x y : α } (f : path x y ) : T1 → α := λ t, f.to_fun (par zero_lt_half t)\n\nlemma CA { x y : α } (f : path x y ) : continuous ( fa_path f):= \nbegin unfold fa_path, exact continuous.comp (continuous_par zero_lt_half ) f.cont, end \n\ndefinition fb_path { x y : α } (f : path x y ) : T2 → α := λ t, f.to_fun (par half_lt_one t)\n\nlemma CB { x y : α } (f : path x y ) :  continuous ( fb_path f):= \nbegin unfold fb_path, exact continuous.comp (continuous_par half_lt_one ) f.cont, \nend \n\nlemma match_lemma { x y z : α } ( f : path x y ) ( g : path y z ) : \n  match_of_fun (fa_path f) (fb_path g) :=\nbegin\n  unfold match_of_fun,  intros x B1 B2,\n  have Int : x ∈ set.inter T1 T2, exact ⟨ B1 , B2 ⟩ , \n  rwa [inter_T] at Int, \n  have V : x.val = 1/2, rwa [mem_set_of_eq] at Int, \n  have xeq : x = (⟨ 1/2 , help_01 ⟩ : I01 ) , apply subtype.eq, rw V, \n  unfold fa_path fb_path, simp [xeq, -one_div_eq_inv], \n  show f.to_fun (par zero_lt_half ⟨⟨1 / 2, help_01⟩, help_half_T1⟩) = \n    g.to_fun (par half_lt_one ⟨⟨1 / 2, help_01⟩, help_half_T2⟩),\n  simp [eqn_1, eqn_2, -one_div_eq_inv], \nend\n\n----- Composition of Path function \n\ndefinition comp_of_path  { x y z : α } ( f : path x y )( g : path y z ) : path x z :=  \n{   to_fun := λ t, ( paste  cover_I01 ( fa_path f ) ( fb_path g ) ) t ,  \n\n    at_zero := \n    begin unfold paste, rw dif_pos, unfold fa_path, rw eqn_start, exact f.at_zero end, \n\n    at_one := \n    begin unfold paste, rw dif_neg, unfold fb_path,\n      show g.to_fun (par half_lt_one ⟨1,  help_T2 ⟩) = z, by simp [eqn_end],  \n      exact help_02, \n    end,\n    \n    cont := \n      cont_of_paste (T1_is_closed) (T2_is_closed) (match_lemma f g) (CA f) (CB g)\n\n}\n\n----------------------------------------------------\n\n--- INVERSE OF PATH\n\n--- Similarly to Composition of Path: define par_inv, prove continuity and create some [simp] lemmas\n\nlemma inv_in_I01 (x : I01) : 1 - x.val ∈ I01 := \nbegin unfold I01, rw mem_set_of_eq, split, simp [-sub_eq_add_neg] , exact x.2.2, simp, exact x.2.1, end   \n\ndefinition par_inv : I01 → I01 :=  λ x, ⟨ 1 - x.val , inv_in_I01 x ⟩ \n\n@[simp] lemma eqn_1_par_inv : par_inv 0 = 1 :=  by refl\n\n@[simp] lemma eqn_2_par_inv : par_inv 1 = 0 := by refl \n\n\nlemma help_inv (y : ℝ ) : ( 1 - y) = (-1) * y + 1 := by simp \n\ntheorem continuous_par_inv : continuous (par_inv ) := \nbegin \n  unfold par_inv, apply continuous_subtype_mk,\n  show continuous ((λ ( y: ℝ ), 1 - y ) ∘ (λ (x : ↥I01), x.val)), \n  refine continuous.comp continuous_subtype_val _, --\n  conv in ( (1:ℝ)-_) \n    begin \n    rw help_inv,\n    end , \n  exact continuous.comp (real.continuous_mul_const (-1) ) (real.continuous_add_const 1), \nend\n\n\ndefinition inv_of_path { x y : α } ( f : path x y ) : path y x :=  \n{   to_fun := λ t , f.to_fun ( par_inv t ) , --  or better f.to_fun ∘ par_inv\n\n    at_zero := begin rw eqn_1_par_inv, exact f.at_one end , \n   \n    at_one := begin rw eqn_2_par_inv, exact f.at_zero end, \n\n    cont := by exact continuous.comp continuous_par_inv f.cont \n\n}\n\n------------------------------------\n\n-- LOOP \n\n-- function to check loop (can be removed)\ndef is_loop { x y : α } ( g : path x y) : Prop := x = y \n\n\ndef loop (x0 : α) : Type* := path x0 x0 \n\n\ndef loop_const (x0 : α) : loop x0 := \n{   to_fun:= λ t, x0 ,  \n    at_zero :=  by refl , \n    at_one := by refl, \n    cont := continuous_const   \n} \n\n\nend path ", "meta": {"author": "ImperialCollegeLondon", "repo": "xena-UROP-2018", "sha": "b111fb87f343cf79eca3b886f99ee15c1dd9884b", "save_path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018", "path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018/xena-UROP-2018-b111fb87f343cf79eca3b886f99ee15c1dd9884b/src/Topology/Material/path.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.4881526467408631}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\n! This file was ported from Lean 3 source module data.rat.big_operators\n! leanprover-community/mathlib commit 327c3c0d9232d80e250dc8f65e7835b82b266ea5\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Rat.Cast\nimport Mathbin.Algebra.BigOperators.Basic\n\n/-! # Casting lemmas for rational numbers involving sums and products\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nopen BigOperators\n\nvariable {ι α : Type _}\n\nnamespace Rat\n\nsection WithDivRing\n\nvariable [DivisionRing α] [CharZero α]\n\n/- warning: rat.cast_list_sum -> Rat.cast_list_sum is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DivisionRing.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1))))] (s : List.{0} Rat), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α _inst_1)))) (List.sum.{0} Rat Rat.hasAdd Rat.hasZero s)) (List.sum.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (DivisionRing.toRing.{u1} α _inst_1))) (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α _inst_1)))))) (List.map.{0, u1} Rat α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α _inst_1))))) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DivisionRing.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1)))] (s : List.{0} Rat), Eq.{succ u1} α (Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1) (List.sum.{0} Rat Rat.instAddRat (CommMonoidWithZero.toZero.{0} Rat (CommGroupWithZero.toCommMonoidWithZero.{0} Rat Rat.commGroupWithZero)) s)) (List.sum.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α _inst_1)))))) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (DivisionSemiring.toSemiring.{u1} α (DivisionRing.toDivisionSemiring.{u1} α _inst_1)))) (List.map.{0, u1} Rat α (Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_list_sum Rat.cast_list_sumₓ'. -/\n@[simp, norm_cast]\ntheorem cast_list_sum (s : List ℚ) : (↑s.Sum : α) = (s.map coe).Sum :=\n  map_list_sum (Rat.castHom α) _\n#align rat.cast_list_sum Rat.cast_list_sum\n\n/- warning: rat.cast_multiset_sum -> Rat.cast_multiset_sum is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DivisionRing.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1))))] (s : Multiset.{0} Rat), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α _inst_1)))) (Multiset.sum.{0} Rat Rat.addCommMonoid s)) (Multiset.sum.{u1} α (AddCommGroup.toAddCommMonoid.{u1} α (NonUnitalNonAssocRing.toAddCommGroup.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α _inst_1))))) (Multiset.map.{0, u1} Rat α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α _inst_1))))) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DivisionRing.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1)))] (s : Multiset.{0} Rat), Eq.{succ u1} α (Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1) (Multiset.sum.{0} Rat Rat.addCommMonoid s)) (Multiset.sum.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α _inst_1))))) (Multiset.map.{0, u1} Rat α (Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_multiset_sum Rat.cast_multiset_sumₓ'. -/\n@[simp, norm_cast]\ntheorem cast_multiset_sum (s : Multiset ℚ) : (↑s.Sum : α) = (s.map coe).Sum :=\n  map_multiset_sum (Rat.castHom α) _\n#align rat.cast_multiset_sum Rat.cast_multiset_sum\n\n/- warning: rat.cast_sum -> Rat.cast_sum is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : DivisionRing.{u2} α] [_inst_2 : CharZero.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (AddCommGroupWithOne.toAddGroupWithOne.{u2} α (Ring.toAddCommGroupWithOne.{u2} α (DivisionRing.toRing.{u2} α _inst_1))))] (s : Finset.{u1} ι) (f : ι -> Rat), Eq.{succ u2} α ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u2} Rat α (CoeTCₓ.coe.{1, succ u2} Rat α (Rat.castCoe.{u2} α (DivisionRing.toHasRatCast.{u2} α _inst_1)))) (Finset.sum.{0, u1} Rat ι Rat.addCommMonoid s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} α ι (AddCommGroup.toAddCommMonoid.{u2} α (NonUnitalNonAssocRing.toAddCommGroup.{u2} α (NonAssocRing.toNonUnitalNonAssocRing.{u2} α (Ring.toNonAssocRing.{u2} α (DivisionRing.toRing.{u2} α _inst_1))))) s (fun (i : ι) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u2} Rat α (CoeTCₓ.coe.{1, succ u2} Rat α (Rat.castCoe.{u2} α (DivisionRing.toHasRatCast.{u2} α _inst_1)))) (f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : DivisionRing.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1)))] (s : Finset.{u2} ι) (f : ι -> Rat), Eq.{succ u1} α (Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1) (Finset.sum.{0, u2} Rat ι Rat.addCommMonoid s (fun (i : ι) => f i))) (Finset.sum.{u1, u2} α ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α _inst_1))))) s (fun (i : ι) => Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1) (f i)))\nCase conversion may be inaccurate. Consider using '#align rat.cast_sum Rat.cast_sumₓ'. -/\n@[simp, norm_cast]\ntheorem cast_sum (s : Finset ι) (f : ι → ℚ) : (↑(∑ i in s, f i) : α) = ∑ i in s, f i :=\n  map_sum (Rat.castHom α) _ _\n#align rat.cast_sum Rat.cast_sum\n\n/- warning: rat.cast_list_prod -> Rat.cast_list_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DivisionRing.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1))))] (s : List.{0} Rat), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α _inst_1)))) (List.prod.{0} Rat Rat.hasMul Rat.hasOne s)) (List.prod.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (DivisionRing.toRing.{u1} α _inst_1))) (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1))))) (List.map.{0, u1} Rat α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α _inst_1))))) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DivisionRing.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α _inst_1)))] (s : List.{0} Rat), Eq.{succ u1} α (Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1) (List.prod.{0} Rat Rat.instMulRat (NonAssocRing.toOne.{0} Rat (Ring.toNonAssocRing.{0} Rat (StrictOrderedRing.toRing.{0} Rat (LinearOrderedRing.toStrictOrderedRing.{0} Rat Rat.instLinearOrderedRingRat)))) s)) (List.prod.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α _inst_1)))) (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α _inst_1))) (List.map.{0, u1} Rat α (Rat.cast.{u1} α (DivisionRing.toRatCast.{u1} α _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_list_prod Rat.cast_list_prodₓ'. -/\n@[simp, norm_cast]\ntheorem cast_list_prod (s : List ℚ) : (↑s.Prod : α) = (s.map coe).Prod :=\n  map_list_prod (Rat.castHom α) _\n#align rat.cast_list_prod Rat.cast_list_prod\n\nend WithDivRing\n\nsection Field\n\nvariable [Field α] [CharZero α]\n\n/- warning: rat.cast_multiset_prod -> Rat.cast_multiset_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Field.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α _inst_1)))))] (s : Multiset.{0} Rat), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α (Field.toDivisionRing.{u1} α _inst_1))))) (Multiset.prod.{0} Rat Rat.commMonoid s)) (Multiset.prod.{u1} α (CommRing.toCommMonoid.{u1} α (Field.toCommRing.{u1} α _inst_1)) (Multiset.map.{0, u1} Rat α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u1} Rat α (CoeTCₓ.coe.{1, succ u1} Rat α (Rat.castCoe.{u1} α (DivisionRing.toHasRatCast.{u1} α (Field.toDivisionRing.{u1} α _inst_1)))))) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Field.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α _inst_1))))] (s : Multiset.{0} Rat), Eq.{succ u1} α (Rat.cast.{u1} α (Field.toRatCast.{u1} α _inst_1) (Multiset.prod.{0} Rat Rat.commMonoid s)) (Multiset.prod.{u1} α (CommRing.toCommMonoid.{u1} α (Field.toCommRing.{u1} α _inst_1)) (Multiset.map.{0, u1} Rat α (Rat.cast.{u1} α (Field.toRatCast.{u1} α _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_multiset_prod Rat.cast_multiset_prodₓ'. -/\n@[simp, norm_cast]\ntheorem cast_multiset_prod (s : Multiset ℚ) : (↑s.Prod : α) = (s.map coe).Prod :=\n  map_multiset_prod (Rat.castHom α) _\n#align rat.cast_multiset_prod Rat.cast_multiset_prod\n\n/- warning: rat.cast_prod -> Rat.cast_prod is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Field.{u2} α] [_inst_2 : CharZero.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (AddCommGroupWithOne.toAddGroupWithOne.{u2} α (Ring.toAddCommGroupWithOne.{u2} α (DivisionRing.toRing.{u2} α (Field.toDivisionRing.{u2} α _inst_1)))))] (s : Finset.{u1} ι) (f : ι -> Rat), Eq.{succ u2} α ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u2} Rat α (CoeTCₓ.coe.{1, succ u2} Rat α (Rat.castCoe.{u2} α (DivisionRing.toHasRatCast.{u2} α (Field.toDivisionRing.{u2} α _inst_1))))) (Finset.prod.{0, u1} Rat ι Rat.commMonoid s (fun (i : ι) => f i))) (Finset.prod.{u2, u1} α ι (CommRing.toCommMonoid.{u2} α (Field.toCommRing.{u2} α _inst_1)) s (fun (i : ι) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat α (HasLiftT.mk.{1, succ u2} Rat α (CoeTCₓ.coe.{1, succ u2} Rat α (Rat.castCoe.{u2} α (DivisionRing.toHasRatCast.{u2} α (Field.toDivisionRing.{u2} α _inst_1))))) (f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Field.{u1} α] [_inst_2 : CharZero.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α _inst_1))))] (s : Finset.{u2} ι) (f : ι -> Rat), Eq.{succ u1} α (Rat.cast.{u1} α (Field.toRatCast.{u1} α _inst_1) (Finset.prod.{0, u2} Rat ι Rat.commMonoid s (fun (i : ι) => f i))) (Finset.prod.{u1, u2} α ι (CommRing.toCommMonoid.{u1} α (Field.toCommRing.{u1} α _inst_1)) s (fun (i : ι) => Rat.cast.{u1} α (Field.toRatCast.{u1} α _inst_1) (f i)))\nCase conversion may be inaccurate. Consider using '#align rat.cast_prod Rat.cast_prodₓ'. -/\n@[simp, norm_cast]\ntheorem cast_prod (s : Finset ι) (f : ι → ℚ) : (↑(∏ i in s, f i) : α) = ∏ i in s, f i :=\n  map_prod (Rat.castHom α) _ _\n#align rat.cast_prod Rat.cast_prod\n\nend Field\n\nend Rat\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Rat/BigOperators.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.48815264449926254}}
{"text": "/-\nCopyright (c) 2021-2022 Julien Marquet. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Julien Marquet\n-/\n\nimport Flows.Term\n\nopen Classical\n\nset_option codegen false\n\ndef Subst (α : Type u) (β : Type u) := { f : β → Term α β // finite { x : β // f x ≠ Term.Var x } }\n\nprivate theorem comp_carrier {f g : β → Term α β} {x : β} :\n  ((f * g) x ≠ Term.Var x) → f x ≠ Term.Var x ∨ g x ≠ Term.Var x := by\n  rw [← Decidable.not_and_iff_or_not]\n  apply contrapose\n  exact λ ⟨ h₁, h₂ ⟩ => by simp [HMul.hMul, Mul.mul, comp, map_reduce, h₁, h₂]\n\nprivate def carriers_arrow (f g : β → Term α β) : ({ x : β // (f * g) x ≠ Term.Var x }) →\n  { x // f x ≠ Term.Var x } ⊕ { x // g x ≠ Term.Var x } :=\n  λ ⟨ x, p ⟩ =>\n    if hf : f x ≠ Term.Var x then Sum.inl ⟨ x, hf ⟩\n    else if hg : g x ≠ Term.Var x then Sum.inr ⟨ x, hg ⟩\n    else False.elim <| match comp_carrier p with\n    | Or.inl p => hf p\n    | Or.inr p => hg p\n\nprivate theorem carriers_arrow_inj (f g : β → Term α β) (x y : {x // (f * g) x ≠ Term.Var x})\n  (h : carriers_arrow f g x = carriers_arrow f g y) : x = y := by\n  revert x y\n  intro ⟨ x, hx ⟩ ⟨ y, hy ⟩ h\n  apply Subtype.eq\n  simp [carriers_arrow] at h\n  have x_nontriv : {P : Prop} → ¬ f x ≠ Term.Var x → ¬ g x ≠ Term.Var x → P :=\n    λ p q => False.elim <| match comp_carrier hx with | Or.inl r => p r | Or.inr r => q r\n  have y_nontriv : {P : Prop} → ¬ f y ≠ Term.Var y → ¬ g y ≠ Term.Var y → P :=\n    λ p q => False.elim <| match comp_carrier hy with | Or.inl r => p r | Or.inr r => q r\n  by_cases p₁ : f x ≠ Term.Var x <;> by_cases p₂ : g x ≠ Term.Var x\n    <;> by_cases p₃ : f y ≠ Term.Var y <;> by_cases p₄ : g y ≠ Term.Var y\n    <;> simp [dif_pos p₁, dif_neg p₁, dif_pos p₂, dif_neg p₂,\n      dif_pos p₃, dif_neg p₃, dif_pos p₄, dif_neg p₄] at h\n    <;> first\n      | assumption\n      | apply x_nontriv; assumption; assumption\n      | apply y_nontriv; assumption; assumption\n\ninstance : Monoid (Subst α β) where\n  one := ⟨ Term.Var, ⟨ [], λ ⟨ _, p ⟩ => False.elim <| p rfl ⟩ ⟩\n  mul := λ ⟨ f, pf ⟩ ⟨ g, pg ⟩ =>\n    ⟨ f * g, invimage_finite_of_inj (sum_finite pf pg) (carriers_arrow_inj f g) ⟩\n  one_mul := λ ⟨ _, _ ⟩ => rfl\n  mul_one := λ ⟨ _, _ ⟩ => Subtype.eq <| fun_monoid.mul_one _\n  mul_assoc := λ ⟨ _, _ ⟩ ⟨ _, _ ⟩ ⟨ _, _ ⟩ => Subtype.eq <| fun_monoid.mul_assoc _ _ _\n\ninstance subst_self_action : RAction (Subst α β) (Subst α β) := self_action _\n\ninstance subst_term_action : RAction (Term α β) (Subst α β) where\n  smul := λ x ⟨ f, hf ⟩ => x • f\n  smul_one := term_action.smul_one\n  smul_mul := λ _ ⟨ _, _ ⟩ ⟨ _, _ ⟩ => term_action.smul_mul _ _ _\n\ndef Subst.ext {θ φ : Subst α β} : θ = φ\n  ↔ ∀ x, (Term.Var x : Term α β) • θ = (Term.Var x : Term α β) • φ := by\n  apply Iff.intro (by intro h _; rw [h])\n  intro h\n  match θ with\n  | ⟨ θ, _ ⟩ => match φ with\n    | ⟨ φ, _ ⟩ =>\n      apply Subtype.eq\n      funext x\n      exact h x\n\ndef Subst.elementary {x : β} {u : Term α β} (h : Term.Var x ≠ u) : Subst α β :=\n  ⟨ λ z => if z = x then u else Term.Var z, by\n    apply Exists.intro [⟨ x, by simp [h.symm] ⟩]\n    intro ⟨ z, hz ⟩\n    rw [List.mem_head_or_mem_tail]\n    apply Or.inl\n    apply Subtype.eq\n    apply byContradiction\n    intro h'\n    simp [h'] at hz ⟩\n\ntheorem Subst.elementary_spec₁ {x : β} {u : Term α β} (h : Term.Var x ≠ u) :\n  (Term.Var x : Term α β) • (elementary h : Subst α β) = u := by\n  simp [RSMul.smul, elementary, map_reduce]\n\ntheorem Subst.elementary_spec₂ {x z : β} {u : Term α β} (h : Term.Var x ≠ u) (h' : z ≠ x) :\n  (Term.Var z : Term α β) • (elementary h : Subst α β) = Term.Var z := by\n  simp [RSMul.smul, elementary, map_reduce, h']\n\ndef subst_simple (x : β) (u : Term α β) :=\n  if p : Term.Var x = u then 1\n  else Subst.elementary p\n\n@[simp]\ntheorem subst_simple_spec {x y : β} {u : Term α β} :\n  Term.Var y • subst_simple x u =\n    if y = x then u\n    else Term.Var y :=\n  if h₁ : Term.Var x = u then\n    if h₂ : y = x then by\n      simp [subst_simple, h₁, h₂, RAction.smul_one]\n    else by\n      simp [subst_simple, h₁, h₂, RAction.smul_one]\n  else\n    if h₂ : y = x then by\n      simp only [h₂, subst_simple, h₁]\n      exact Subst.elementary_spec₁ h₁\n    else by\n      simp only [subst_simple, h₁, h₂]\n      exact Subst.elementary_spec₂ h₁ h₂\n\n@[simp]\ntheorem subst_simple_trivial {x : β} : subst_simple x (Term.Var x : Term α β) = 1 := by\n  simp [subst_simple]\n\n@[simp]\ntheorem subst_cons {u v : Term α β} {θ : Subst α β} :\n  Term.Cons u v • θ = Term.Cons (u • θ) (v • θ) := by\n  cases θ; rfl\n\ndef carrier (θ : Subst α β) : Fintype β :=\n  match θ with\n  | ⟨ θ, h ⟩ =>\n    let π : {x // θ x ≠ Term.Var x} → β := λ ⟨ x, _ ⟩ => x\n    Fintype.mk <| List.map π (epsilon <| λ l => ∀ a, a ∈ l)\n\ndef carrier_spec {θ : Subst α β} {y : β} :\n  y ∈ carrier θ ↔ (Term.Var y : Term α β) • θ ≠ Term.Var y :=\n  match θ with\n  | ⟨ θ, hθ ⟩ => by\n    apply Iff.intro\n    focus\n      intro h\n      let ⟨ ⟨ x, hx ⟩, ⟨ _, h₂ ⟩ ⟩ := List.mem_map_iff_image.1 h\n      exact h₂ ▸ hx\n    focus\n      let π : {x // θ x ≠ Term.Var x} → β := λ ⟨ x, _ ⟩ => x\n      intro h'\n      rw [show y = π ⟨ y, h' ⟩ from rfl]\n      apply List.mem_map\n      apply epsilon_spec hθ\n\ntheorem is_one_iff_empty_carrier {θ : Subst α β} : θ = 1 ↔ carrier θ = ∅ := by\n  apply Iff.intro\n  focus\n    intro h\n    rw [h, Fintype.ext]\n    intro x\n    apply Iff.intro _ (False.elim ∘ Fintype.not_mem_empty _)\n    rw [carrier_spec]\n    exact λ h => False.elim <| h rfl\n  focus\n    intro h\n    rw [Subst.ext]\n    intro x\n    apply byContradiction\n    intro h'\n    apply Fintype.not_mem_empty x\n    rw [← h, carrier_spec]\n    exact h'\n\ntheorem carrier_one : carrier (1 : Subst α β) = ∅ :=\n  is_one_iff_empty_carrier.1 rfl\n\ntheorem is_one_iff_not_modifying (θ : Subst α β) :\n  θ = 1 ↔ ∀ x, (Term.Var x : Term α β) • θ = Term.Var x := Subst.ext\n\ntheorem not_one_iff_modifying (θ : Subst α β) :\n  θ ≠ 1 ↔ ∃ x, (Term.Var x : Term α β) • θ ≠ Term.Var x := by\n  apply Iff.intro\n  focus\n    intro h\n    apply byContradiction\n    intro h'\n    apply h\n    rw [Subst.ext]\n    intro x\n    apply byContradiction\n    intro h''\n    exact h' ⟨ x, h'' ⟩\n  focus\n    intro ⟨ x, h ⟩ h'\n    rw [is_one_iff_not_modifying] at h'\n    exact h (h' x)\n\ntheorem elementary_carrier {x : β} {u : Term α β} {h : Term.Var x ≠ u} :\n  carrier (Subst.elementary h : Subst α β) = Fintype.mk [x] := by\n  apply Fintype.ext.2\n  intro y\n  rw [carrier_spec]\n  apply Iff.intro\n  focus\n    by_cases p : y = x\n    focus\n      rw [p]\n      intro _\n      simp [Fintype.mem_mk_iff]\n      apply List.Mem.head\n    focus\n      intro h'\n      apply False.elim ∘ h'\n      simp [Subst.elementary, RSMul.smul, map_reduce, p]\n  focus\n    rw [Fintype.mem_mk_iff]\n    intro p\n    rw [show y = x by cases p <;> trivial, Subst.elementary_spec₁]\n    exact Ne.symm h\n\ntheorem carrier_cons (θ φ : Subst α β) : carrier (θ * φ) ⊆ carrier θ ∪ carrier φ := by\n  intro x\n  rw [Fintype.mem_union_iff]\n  simp only [carrier_spec]\n  match θ with\n  | ⟨ θ, _ ⟩ => match φ with\n    | ⟨ φ, _ ⟩ => exact comp_carrier\n\n", "meta": {"author": "thejohncrafter", "repo": "flows", "sha": "f4732e6784aa6ea13b07dc042be2c3816a73fa84", "save_path": "github-repos/lean/thejohncrafter-flows", "path": "github-repos/lean/thejohncrafter-flows/flows-f4732e6784aa6ea13b07dc042be2c3816a73fa84/Flows/Subst.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936484231889, "lm_q2_score": 0.6370307806984443, "lm_q1q2_score": 0.48815264109928325}}
{"text": "example : Int → Nat\n| (_ : Nat)     => 0\n| Int.negSucc n => 0\n\nprotected theorem Int.add_comm : ∀ a b : Int, a + b = b + a\n| (n : Nat), (m : Nat)         => sorry\n| (_ : Nat), Int.negSucc _     => rfl\n| Int.negSucc _, (_ : Nat)     => rfl\n| Int.negSucc _, Int.negSucc _ => sorry\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/inaccessibleAnnotDefEqIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342624, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.48805912929516143}}
{"text": "import .preterm \n--..simp_omega \n..logic\n\nnamespace int\n\n@[derive has_reflect]\ninductive form \n| eq  : preterm → preterm → form\n| le  : preterm → preterm → form\n| not : form → form\n| or  : form → form → form\n| and : form → form → form\n\nnotation x `=*` y := form.eq x y\nnotation x `≤*` y := form.le x y\nnotation `¬*` p := form.not p\nnotation p `∨*` q := form.or p q\nnotation p `∧*` q := form.and p q\n\n-- | (t =* s) :=\n-- | (t ≤* s) :=\n-- | (¬* p)   :=\n-- | (p ∨* q) := \n-- | (p ∧* q) := \n\ndef valuation.cons (i : int) (v : nat → int) : nat → int\n| 0     := i \n| (k+1) := v k\n\nnotation i `::` v := valuation.cons i v\n\nopen tactic\n\nnamespace form\n\n@[omega] def holds (v : nat → int) : form → Prop \n| (t =* s) := t.val v = s.val v\n| (t ≤* s) := t.val v ≤ s.val v\n| (¬* p)   := ¬ p.holds\n| (p ∨* q) := p.holds ∨ q.holds\n| (p ∧* q) := p.holds ∧ q.holds\n\nend form\n\n@[omega] def uniclo (p : form) : (nat → int) → nat → Prop \n| v 0     := p.holds v\n| v (k+1) := ∀ i : int, uniclo (i::v) k \n\nnamespace form\n\ndef fresh_idx : form → nat \n| (t =* s) := max t.fresh_idx s.fresh_idx\n| (t ≤* s) := max t.fresh_idx s.fresh_idx\n| (¬* p)   := p.fresh_idx\n| (p ∨* q) := max p.fresh_idx q.fresh_idx\n| (p ∧* q) := max p.fresh_idx q.fresh_idx\n\n--def uniclo (p : form) : Prop := \n--uniclo_core p p.fresh_idx (λ _, 0)\n\ndef valid (p : form) : Prop := \n∀ v, holds v p\n\ndef sat (p : form) : Prop := \n∃ v, holds v p\n\ndef implies (p q : form) : Prop := \n∀ v, (holds v p → holds v q)\n\ndef equiv (p q : form) : Prop := \n∀ v, (holds v p ↔ holds v q)\n\nlemma sat_of_implies_of_sat {p q} :\n  implies p q → sat p → sat q :=\nbegin intros h1 h2, apply exists_of_exists h1 h2 end\n\nlemma sat_or {p q : form} :\n  sat (p ∨* q) ↔ sat p ∨ sat q :=\nbegin\n  constructor; intro h1,\n  { cases h1 with v h1, cases h1 with h1 h1;\n    [left,right]; refine ⟨v,_⟩; assumption },\n  { cases h1 with h1 h1; cases h1 with v h1;\n    refine ⟨v,_⟩; [left,right]; assumption }\nend\n\ndef unsat (p : form) : Prop := ¬ sat p\n\ndef repr : form → string \n| (t =* s) := \"(\" ++ t.repr ++ \" = \" ++ s.repr ++ \")\"\n| (t ≤* s) := \"(\" ++ t.repr ++ \" ≤ \" ++ s.repr ++ \")\"\n| (¬* p)   := \"¬\" ++ p.repr\n| (p ∨* q) := \"(\" ++ p.repr ++ \" ∨  \" ++ q.repr ++ \")\"\n| (p ∧* q) := \"(\" ++ p.repr ++ \" ∧ \" ++ q.repr ++ \")\"\n\ninstance has_repr : has_repr form := ⟨repr⟩ \nmeta instance has_to_format : has_to_format form := ⟨λ x, x.repr⟩ \n\nend form\n\nlemma uniclo_of_valid {p : form} : \n  ∀ {m v}, p.valid → uniclo p v m \n| 0 v h1     := h1 _ \n| (m+1) v h1 := λ i, uniclo_of_valid h1\n\n--lemma uniclo_of_valid {p : form} (h : p.valid) : p.uniclo := \n--uniclo_core_of_valid h \n\nlemma valid_of_unsat_not {p : form} : (¬*p).unsat → p.valid := \nbegin\n  simp only [form.sat, form.unsat, form.valid, form.holds], \n  rw classical.not_exists_not, intro h, assumption\nend\n\nmeta def form.induce (t : tactic unit := skip) : tactic unit := \n`[ intro p, induction p with t s t s p ih p q ihp ihq p q ihp ihq; t]\n\nend int", "meta": {"author": "skbaek", "repo": "omega", "sha": "715e384ed14e8eb177a326700066e7c98269e078", "save_path": "github-repos/lean/skbaek-omega", "path": "github-repos/lean/skbaek-omega/omega-715e384ed14e8eb177a326700066e7c98269e078/int/form.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238982, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4880540129671752}}
{"text": "import Mathlib.Data.Fintype.Basic\nimport Mathlib.Tactic.LibrarySearch\nimport Mathlib.Tactic.Linarith\n\nabbrev DecidableSet.{u} {α : Type u} (r : Set α) := (a : α) → Decidable (a ∈ r)\ninstance {α} (s : Set α) [DecidableSet s] : DecidableSet s.compl := λ _ => show Decidable (¬_) from inferInstance\ninstance {α} [DecidableEq α] (j : α) : DecidableSet {j} := λ _ => show Decidable (_ = _) from inferInstance\n\n\nnoncomputable\ndef Set.size {α} [i : Fintype α] [DecidableEq α] (s : Set α) [DecidableSet s] : Nat :=\n  (i.elems.filter (decide $ . ∈ s)).toList.length\n\nstructure SimpleGraph (α) [Fintype α] [DecidableEq α] where\n  isEdge : α → α → Bool\n\nsection\n  variable {α} [Fintype α] [DecidableEq α]\n  -- instance : ∀ i j, Decidable (graph.isEdge i j) := graph.decidable_isEdge\n  -- instance : ∀ i, DecidableSet (graph.isEdge i) := graph.decidable_isEdge\n\n  namespace SimpleGraph\n  section\n    variable (graph : SimpleGraph α)\n    abbrev nodesOutOf (i : α) : Set α := (graph.isEdge i . = true)\n    abbrev nodesInto (j : α) : Set α := (graph.isEdge . j = true)\n    -- def degreeOutOf (i) := (graph.nodesOutOf i).size\n    -- def degreeInto (i) := (graph.nodesInto i).size\n    -- def IsLeaf (i) := graph.degreeOutOf i = 1\n\n    def induce (s : Set α) [DecidableSet s] : SimpleGraph { x : α // x ∈ s } where\n      isEdge | ⟨i, _⟩, ⟨j, _⟩ => graph.isEdge i j \n  end\n\n  variable (graph : SimpleGraph α) in\n  inductive Walk : α → α → Type where\n  | nil (i) : Walk i i -- path with 0 moves from i to i. Not a path with 1 move along edge i->i\n  | cons (i k) (w : Walk i k) (j) (h : graph.isEdge k j = true) : Walk i j\n\n  def WalkIn (graph : SimpleGraph α) (s : Set α) [DecidableSet s] (i j : { x : α // x ∈ s }) :=\n    (graph.induce s).Walk i j\n  def WalkNotIn (graph : SimpleGraph α) (s : Set α) [DecidableSet s] := graph.WalkIn s.compl\n\n  section\n    variable {graph : SimpleGraph α}\n    namespace Walk\n    def length {i j} : graph.Walk i j → Nat\n      | nil i => 0\n      | cons i k w j h => w.length + 1\n\n    def nodeList {i j} : graph.Walk i j → List α\n      | nil i => [i]\n      | cons i k w j h => j :: w.nodeList\n\n    def nodes {i j} : graph.Walk i j → Set α\n      | nil i => {i}\n      | cons i k w j h => w.nodes ∪ {j}\n    \n    theorem first_mem_nodeList {i j} (w : graph.Walk i j) : i ∈ w.nodeList :=\n      match w with\n      | nil _ => List.Mem.head []\n      | cons _ _ w _ _ => List.Mem.tail _ w.first_mem_nodeList\n    theorem last_mem_nodeList {i j} (w : graph.Walk i j) : j ∈ w.nodeList :=\n      match w with\n      | nil _ => List.Mem.head []\n      | cons _ _ _ _ _ => List.Mem.head _\n    def WalkNotIn_of_notIn_nodeList {i j} (w : graph.Walk i j) {a} (h : a ∉ w.nodeList) :=\n      graph.WalkNotIn {a}\n        ⟨i, λ c => by subst c; exact h w.first_mem_nodeList⟩\n        ⟨j, λ c => by subst c; exact h w.last_mem_nodeList⟩\n    def to_WalkNotIn_of_notIn_nodeList {i j} (w : graph.Walk i j) {a} (h : a ∉ w.nodeList)\n      : w.WalkNotIn_of_notIn_nodeList h :=\n      match w, h with\n      | Walk.nil _, h => Walk.nil _\n      | Walk.cons _ k w _ hks, h =>\n        let r := (to_WalkNotIn_of_notIn_nodeList w λ c => h $ List.mem_cons.mpr $ Or.inr c)\n        Walk.cons _ _ r _ hks\n    theorem to_WalkNotIn_of_notIn_nodeList_preserves_nodeList {i j} (w : graph.Walk i j) {a} (h : a ∉ w.nodeList)\n      : (w.to_WalkNotIn_of_notIn_nodeList h).nodeList.map Subtype.val = w.nodeList := \n      match w, h with\n      | Walk.nil _, h => rfl\n      | Walk.cons i k w j hks, h => \n        congrArg (List.cons j) $ \n        to_WalkNotIn_of_notIn_nodeList_preserves_nodeList w λ c => h $ List.mem_cons.mpr $ Or.inr c\n\n    theorem first_mem_nodes {i j} (w : graph.Walk i j) : i ∈ w.nodes :=\n      match w with\n      | nil _ => rfl\n      | cons _ k w _ h => Or.inl w.first_mem_nodes\n    theorem last_mem_nodes {i j} (w : graph.Walk i j) : j ∈ w.nodes :=\n      match w with\n      | nil _ => rfl\n      | cons _ k w _ h => Or.inr rfl\n    def to_WalkIn_of_Subset {i j} (w : graph.Walk i j) {s} [DecidableSet s] (h : w.nodes ⊆ s)\n      : graph.WalkIn s ⟨i, h w.first_mem_nodes⟩ ⟨j, h w.last_mem_nodes⟩ :=\n      match w, h with\n      | Walk.nil _, h => Walk.nil _\n      | Walk.cons _ k w _ hks, h =>\n        let r := w.to_WalkIn_of_Subset λ _ hx => h (Or.inl hx)\n        Walk.cons _ _ r _ hks\n    theorem to_WalkIn_of_Subset_preserves {i j} (w : graph.Walk i j) {s} [DecidableSet s] (h : w.nodes ⊆ s)\n      : (w.to_WalkIn_of_Subset h).nodes = sorry := sorry\n\n\n    end Walk\n\n  end\n\n\n  def Path (graph : SimpleGraph α) (i j) := { w : graph.Walk i j // List.Nodup w.nodeList }\n\n  def Path2 (graph : SimpleGraph α) (i j) := { w : graph.Walk i j // ∀ i, i ∈ w.nodes → False }\n  #exit\n\n  section\n    variable {graph : SimpleGraph α}\n    namespace Path\n    def cons  {i k : α} (p : graph.Path i k) {j : α} (h : graph.isEdge k j = true) (hj : j ∉ p.val.nodeList)\n      : graph.Path i j :=\n      ⟨Walk.cons _ _ p.val _ h, List.nodup_cons.mpr ⟨hj, p.property⟩⟩\n\n    def to_PathNotIn_of_notIn_nodeList {i j} (p : graph.Path i j) {a} (h : a ∉ p.val.nodeList)\n      : (graph.induce (Set.compl {a})).Path\n          ⟨i, λ c => by subst c; exact h p.val.first_mem_nodeList⟩\n          ⟨j, λ c => by subst c; exact h p.val.last_mem_nodeList⟩ :=\n      match i, j, p, h with\n      | _, _, ⟨Walk.nil _, _⟩, h => ⟨Walk.nil _, List.nodup_singleton _⟩\n      | i, j, ⟨Walk.cons _ k w _ hks, hn⟩, h =>\n        have hn := List.nodup_cons.mp hn\n        let wr : Walk .. := (w.to_WalkNotIn_of_notIn_nodeList λ c => h $ List.mem_cons.mpr $ Or.inr c)\n        have hr : wr.nodeList.map _ = w.nodeList := w.to_WalkNotIn_of_notIn_nodeList_preserves_nodeList _\n        have : List.Nodup wr.nodeList := sorry -- from hn, via hr using the fact that map is injective\n        let r : Path .. := ⟨wr, this⟩\n        r.cons hks $ show _ ∉ wr.nodeList from sorry -- from hn using hr\n\n    def to_PathIn_of_Subset {i j} (p : graph.Path i j) {s} [DecidableSet s] (h : p.val.nodes ⊆ s)\n      : (graph.induce s).Path ⟨i, h p.val.first_mem_nodes⟩ ⟨j, h p.val.last_mem_nodes⟩ :=\n      match i, j, p, h with\n      | _, _, ⟨Walk.nil _, _⟩, h => ⟨Walk.nil _, List.nodup_singleton _⟩\n      | i, j, ⟨Walk.cons _ k w _ hks, hn⟩, h =>\n      sorry\n\n#exit\n\n    end Path\n  end\n  \n  example (a : List α) (b : List β) (f : α → β) (hf : f.Injective) (h : a.map f = b) (ha : a.Nodup) : b.Nodup :=\n    sorry\n\n  #exit\n\n  section\n    variable (graph : SimpleGraph α)\n\n    def Connected := ∀ i j, Nonempty (graph.Walk i j)\n    def Cycle (i) := { w : graph.Walk i i // w.length ≠ 0 }\n    def Acyclic := ∀ i, graph.Cycle i → False\n\n    theorem exists_nil_Walk_iff (i j) : (∃ w : graph.Walk i j, w.length = 0) ↔ i = j :=\n      ⟨λ ⟨w, _⟩ => match w with | Walk.nil i => rfl, λ h => h ▸ ⟨Walk.nil i, rfl⟩⟩\n\n    theorem exists_Walk_iff (i j) (m)\n      : (∃ w : graph.Walk i j, w.length = m + 1) ↔ ∃ k, (∃ w : graph.Walk i k, w.length = m) ∧ graph.isEdge k j :=\n    ⟨λ ⟨Walk.cons i k w _ hkj, hw⟩ => ⟨k, ⟨⟨w, Nat.succ.inj hw⟩, hkj⟩⟩\n    , λ ⟨k, ⟨⟨w, hw⟩, hkj⟩⟩ => ⟨Walk.cons i k w j hkj, congrArg (. + 1) hw⟩⟩\n\n    def decidable_exists_nonnil_Walk (i j) (m : Nat) : Decidable (∃ w : graph.Walk i j, w.length = m + 1) := by\n        rw [graph.exists_Walk_iff i j m]\n        suffices ∀ k, Decidable ((∃ w : graph.Walk i k, w.length = m) ∧ graph.isEdge k j) from Fintype.decidableExistsFintype\n        intro k\n        match m with\n        | 0 => rw [graph.exists_nil_Walk_iff]; infer_instance\n        | m + 1 => let _ := decidable_exists_nonnil_Walk i k m; infer_instance\n\n    def decidable_exists_Walk (i j) (m : Nat) : Decidable (∃ w : graph.Walk i j, w.length = m) := match m with\n      | 0 => by rw [graph.exists_nil_Walk_iff i j]; infer_instance\n      | m  + 1 => graph.decidable_exists_nonnil_Walk i j m\n\n    -- use the fact that graph is finite so there must be a finite length walk that explores all possibilities\n    def decidable_Nonempty_Walk (i j) : Decidable $ Nonempty (graph.Walk i j) :=\n        sorry\n    \n\n    -- theorem exists_nil_Path_iff (i j) : (∃ w : graph.Walk i j, w.length = 0) ↔ i = j :=\n    --   ⟨λ ⟨w, _⟩ => match w with | Walk.nil i => rfl, λ h => h ▸ ⟨Walk.nil i, rfl⟩⟩\n\n    theorem exists_Path_iff (i j) (m)\n      : (∃ w : graph.Path i j, w.val.length = m + 1) ↔ ∃ k, (∃ w : graph.Path i k, j ∉ w.val.nodeList ∧ w.val.length = m) ∧ graph.isEdge k j :=\n    ⟨λ ⟨⟨Walk.cons i k w _ hkj, pw⟩, hw⟩ => \n      have pw := List.nodup_cons.mp pw\n      ⟨k, ⟨⟨⟨w, pw.2⟩, ⟨pw.1, Nat.succ.inj hw⟩⟩, hkj⟩⟩\n    , λ ⟨k, ⟨⟨w, ⟨pw, hw⟩⟩, hkj⟩⟩ =>\n      have pw := List.nodup_cons.mpr ⟨pw, w.prop⟩\n      ⟨⟨Walk.cons i k w.val j hkj, pw⟩, congrArg (. + 1) hw⟩⟩\n\n    theorem exists_Path_iff2 (i j) (m)\n      : (∃ w : graph.Path i j, w.val.length = m + 1) ↔ ∃ k, (∃ w : (graph.cutNodes {j}).Path ⟨i, sorry⟩ ⟨k, sorry⟩, w.val.length = m) ∧ graph.isEdge k j :=\n    ⟨λ ⟨⟨Walk.cons i k w _ hkj, pw⟩, hw⟩ => \n      have pw := List.nodup_cons.mp pw\n      ⟨k, ⟨⟨⟨sorry, sorry⟩, sorry⟩, hkj⟩⟩,\n    sorry⟩\n\n\n\n    def decidable_exists_nonnil_Path {α} [Fintype α] [DecidableEq α] (graph : SimpleGraph α)\n      (i j) (m : Nat) : Decidable (∃ w : graph.Path i j, w.val.length = m + 1) := by\n        rw [graph.exists_Path_iff i j m]\n        suffices ∀ k, Decidable ((∃ w : graph.Path i k, j ∉ w.val.nodeList ∧ w.val.length = m) ∧ graph.isEdge k j) from Fintype.decidableExistsFintype\n        intro k\n        match m with\n        | 0 => sorry\n        | m + 1 => \n          let g := graph.cutNodes {j} \n          let inst := decidable_exists_nonnil_Path g ⟨i, sorry⟩ ⟨k, sorry⟩ m\n          -- infer_instance\n          sorry\n\n\n\n    -- theorem degreeInto_ge_1_of_Connected_and_ge_2 (hn : n ≥ 2) (hc : graph.Connected) (i : Fin n)\n    --   : graph.degreeInto i ≥ 1 :=\n    --   let j : Fin n := if i = ⟨0, by linarith⟩ then ⟨1, by linarith⟩ else ⟨0, by linarith⟩\n    --   have : i.1 ≠ j.1 := sorry\n    --   match (hc j i).some with\n    --   | .cons _ k w i h => sorry\n\n    -- def findLeaf (hn : n ≥ 2) (hc : graph.Connected) (ha : graph.Acyclic) : Fin n :=\n    --   match n, hn with\n    --   | 2, _ => 0\n    --   | n + 1, _ =>\n    --     sorry\n  end\n  end SimpleGraph\nend", "meta": {"author": "michelsol", "repo": "lean-playground", "sha": "0bfffb7bd41729fb9f95974e93f6ecbc0b6e59ca", "save_path": "github-repos/lean/michelsol-lean-playground", "path": "github-repos/lean/michelsol-lean-playground/lean-playground-0bfffb7bd41729fb9f95974e93f6ecbc0b6e59ca/Playground/Data/Graph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.48805400478100575}}
{"text": "/-\nCopyright (c) 2022 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport data.fintype.card\n\n/-!\n# Specification of Oracle Access For a Computation\n\nThis file defines a type to represent the set of oracles available to a computation.\nThe `oracle_spec` type specifies an indexing set for the available oracles,\nand input and output types for each oracle. We also require that the range of the oracle\nis nonempty so it has at least one possible output, and that the range of the oracle\nis finite so that each *particular* oracle has a finite number of outputs.\n\nWe choose to include `decidable_eq` assumptions for the types in the structure rather than\nas further typeclasses on `oracle_spec` for simplicity, but generally these could be seperated.\n\nWe also define a number of basic constructions for common oracles:\n- `singleton_spec` represents a single oracle with a specified input and output type.\n- `empty_spec` represents a lack of any oracles.\n- `append` represents bringing together two sets of oracles into one combined set of oracles.\n- `coin_spec` represents access to a coin flipping oracle\n- `uniform_selecting` represents access to a uniformly random oracle on a numeric range.\n-/\n\n/-- Specification of the various oracles available to a computation.\n`ι` is an indexing set of oracles (i.e. `ι := ℕ` gives a different oracle for each `n : ℕ`).\n`domain range : ι → Type` give the input and output types of the oracle corresponding to an index.\nWe also require for the output types to be nonempty (ensuring `oracle_comp.support` is nonempty).\n`decidable_eq` and `fintype` instances are also required for each oracle index, in order\nto define things like `fin_support`. Note that this is only required *per index*, the\ntotal number of oracle outputs may be infinite, it must only be finite for any *specific* index. -/\nstructure oracle_spec : Type 1 :=\n(ι : Type)\n(domain range : ι → Type)\n(range_inhabited (i : ι) : inhabited $ range i)\n(ι_decidable_eq : decidable_eq ι)\n(domain_decidable_eq (i : ι) : decidable_eq $ domain i)\n(range_decidable_eq (i : ι) : decidable_eq $ range i)\n(range_fintype (i : ι) : fintype $ range i)\n\n/-- Example of a simple `oracle_spec` for a pair of oracles,\neach taking a natural `n : ℕ` as input, returning a value of type `fin 100` or `bool` respectively.\nIn practice the instances like `range_inhabited` will usually be derived automatically,\nbut we expand them here to show the explicit definitions.  -/\nexample : oracle_spec :=\n{ ι := unit ⊕ unit,\n  domain := λ _, ℕ,\n  range := λ x, match x with | (sum.inl ()) := fin 100 | (sum.inr ()) := bool end,\n  range_inhabited := λ x, match x with\n  | (sum.inl ()) := fin.inhabited\n  | (sum.inr ()) := bool.inhabited\n  end,\n  ι_decidable_eq := sum.decidable_eq unit unit,\n  domain_decidable_eq := λ _, nat.decidable_eq,\n  range_decidable_eq := λ x, match x with\n  | (sum.inl ()) := fin.decidable_eq 100\n  | (sum.inr ()) := bool.decidable_eq\n  end,\n  range_fintype := λ x, match x with\n  | (sum.inl ()) := fin.fintype 100\n  | (sum.inr ()) := bool.fintype\n  end }\n\nnamespace oracle_spec\n\nsection instances\n\ninstance range.inhabited {spec : oracle_spec} (i : spec.ι) : inhabited (spec.range i) :=\nspec.range_inhabited i\n\nvariables (spec : oracle_spec)\n\ninstance ι.decidable_eq' : decidable_eq spec.ι := spec.ι_decidable_eq\n\ninstance domain.decidable_eq' (i : spec.ι) :\n  decidable_eq (spec.domain i) := spec.domain_decidable_eq i\n\ninstance range.decidable_eq' (i : spec.ι) :\n  decidable_eq (spec.range i) := spec.range_decidable_eq i\n\ninstance range.fintype' (i : spec.ι) :\n  fintype (spec.range i) := spec.range_fintype i\n\nend instances\n\nsection singleton_spec\n\n/-- `oracle_spec` representing access to a single oracle with input type `T` and output type `U`.\nWe use the `unit` type as the index since there is exactly one unique oracle available. -/\n@[simps] def singleton_spec (T U : Type) [hU : inhabited U] [hT : decidable_eq T]\n  [hU' : decidable_eq U] [hU'' : fintype U] : oracle_spec :=\n{ ι := unit,\n  domain := λ _, T,\n  range := λ _, U,\n  range_inhabited := λ _, hU,\n  ι_decidable_eq := punit.decidable_eq,\n  domain_decidable_eq := λ _, hT,\n  range_decidable_eq := λ _, hU',\n  range_fintype := λ _, hU'' }\n\ninfixl` ↦ₒ `:25 := singleton_spec\n\nvariables (T U : Type) [inhabited U] [decidable_eq T] [decidable_eq U] [fintype U]\n\ninstance singleton_spec_ι_subsingleton : subsingleton (T ↦ₒ U).ι := punit.subsingleton\n\nend singleton_spec\n\nsection empty_spec\n\n/-- No access to any oracles. Represented by an empty indexing set via the `empty` type.\nSince `empty` is uninhabited, it isn't possible to construct a query to this oracle,\nand therefore any computation with this `oracle_spec` can be evaluated explicitly (`run_comp`). -/\n@[simps] def empty_spec : oracle_spec :=\n{ ι := empty,\n  domain := λ _, unit,\n  range := λ _, unit,\n  range_inhabited := λ _, by apply_instance,\n  ι_decidable_eq := empty.decidable_eq,\n  domain_decidable_eq := λ i, i.elim,\n  range_decidable_eq := λ i, i.elim,\n  range_fintype := λ i, i.elim }\n\nnotation `[]ₒ` := empty_spec\n\ninstance empty_spec_ι_subsingleton : subsingleton empty_spec.ι := empty.subsingleton\n\n-- instance empty_spec_domain_unique (i : empty_spec.ι) : unique (empty_spec.domain i) := punit.unique\n\n-- instance empty_spec_range_unique (i : empty_spec.ι) : unique (empty_spec.range i) := punit.unique\n\nend empty_spec\n\ninstance inhabited : inhabited oracle_spec := ⟨[]ₒ⟩\n\nsection append\n\n/-- Combine two specifications using a `sum` type to index the different specs.\nGiven `spec spec' : oracle_spec`, `spec ++ spec'` gives access to the combined set of oracles,\nwith `sum.inl` corresponding to the left oracle and `sum.inr` corresponding to the right oracle. -/\ninstance has_append : has_append oracle_spec :=\n{ append := λ spec spec',\n  { ι := spec.ι ⊕ spec'.ι,\n    domain := sum.elim spec.domain spec'.domain,\n    range := sum.elim spec.range spec'.range,\n    range_inhabited := λ i, by induction i; simp; apply_instance,\n    ι_decidable_eq := sum.decidable_eq spec.ι spec'.ι,\n    domain_decidable_eq := λ i, sum.rec_on i spec.domain_decidable_eq spec'.domain_decidable_eq,\n    range_decidable_eq := λ i, sum.rec_on i spec.range_decidable_eq spec'.range_decidable_eq,\n    range_fintype := λ i, sum.rec_on i spec.range_fintype spec'.range_fintype } }\n\nvariables (spec spec' : oracle_spec)\n\n@[simp] lemma append.domain_inl (i : spec.ι) :\n  (spec ++ spec').domain (sum.inl i) = spec.domain i := rfl\n\n@[simp] lemma append.domain_inr (i : spec'.ι) :\n  (spec ++ spec').domain (sum.inr i) = spec'.domain i := rfl\n\n@[simp] lemma append.range_inl (i : spec.ι) :\n  (spec ++ spec').range (sum.inl i) = spec.range i := rfl\n\n@[simp] lemma append.range_inr (i : spec'.ι) :\n  (spec ++ spec').range (sum.inr i) = spec'.range i := rfl\n\nend append\n\nsection coin_spec\n\n/-- Access to a single oracle, returning a `bool` to each oracle query.\nThe probability distribution associated to the oracle will eventually be 50/50 for `tt` and `ff`,\nrepresenting oracle access to a fair coin flip. -/\n@[simps] def coin_spec : oracle_spec := unit ↦ₒ bool\n\n@[simp] lemma card_range_coin_spec (i : unit) : fintype.card (coin_spec.range i) = 2 := rfl\n\nend coin_spec\n\nsection uniform_selecting\n\n/-- Access to a `fin n` oracle for each `n : ℕ`, representing an oracle for evenly sampling\nfrom a range of numbers. The output of the `n` query is actually in `fin (n + 1)`,\navoiding a return type of the empty `fin 0` type. -/\n@[simps] def uniform_selecting : oracle_spec :=\n{ ι := ℕ,\n  domain := λ n, unit,\n  range := λ n, fin (n + 1),\n  range_inhabited := λ n, ⟨0⟩,\n  ι_decidable_eq := nat.decidable_eq,\n  domain_decidable_eq := λ _, punit.decidable_eq,\n  range_decidable_eq := λ n, fin.decidable_eq (n + 1),\n  range_fintype := λ n, fin.fintype (n + 1) }\n\n@[simp] lemma card_range_uniform_selecting (n : ℕ) :\n  fintype.card (uniform_selecting.range n) = n + 1 := finset.card_fin (n + 1)\n\nend uniform_selecting\n\nend oracle_spec", "meta": {"author": "dtumad", "repo": "lean-crypto-formalization", "sha": "f975a9a9882120b509553a7ced9aa05b745ff154", "save_path": "github-repos/lean/dtumad-lean-crypto-formalization", "path": "github-repos/lean/dtumad-lean-crypto-formalization/lean-crypto-formalization-f975a9a9882120b509553a7ced9aa05b745ff154/src/computational_monads/oracle_spec.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.488054000687921}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.category\nimport data.equiv.functor\n\n/-!\n# Functions functorial with respect to equivalences\n\nAn `equiv_functor` is a function from `Type → Type` equipped with the additional data of\ncoherently mapping equivalences to equivalences.\n\nIn categorical language, it is an endofunctor of the \"core\" of the category `Type`.\n-/\n\nuniverses u₀ u₁ u₂ v₀ v₁ v₂\n\nopen function\n\n/--\nAn `equiv_functor` is only functorial with respect to equivalences.\n\nTo construct an `equiv_functor`, it suffices to supply just the function `f α → f β` from\nan equivalence `α ≃ β`, and then prove the functor laws. It's then a consequence that\nthis function is part of an equivalence, provided by `equiv_functor.map_equiv`.\n-/\nclass equiv_functor (f : Type u₀ → Type u₁) :=\n(map : Π {α β}, (α ≃ β) → (f α → f β))\n(map_refl' : Π α, map (equiv.refl α) = @id (f α) . obviously)\n(map_trans' : Π {α β γ} (k : α ≃ β) (h : β ≃ γ),\n  map (k.trans h) = (map h) ∘ (map k) . obviously)\n\nrestate_axiom equiv_functor.map_refl'\nrestate_axiom equiv_functor.map_trans'\nattribute [simp] equiv_functor.map_refl\n\nnamespace equiv_functor\n\nsection\nvariables (f : Type u₀ → Type u₁) [equiv_functor f] {α β : Type u₀} (e : α ≃ β)\n\n/-- An `equiv_functor` in fact takes every equiv to an equiv. -/\ndef map_equiv :\n  f α ≃ f β :=\n{ to_fun := equiv_functor.map e,\n  inv_fun := equiv_functor.map e.symm,\n  left_inv := λ x, by { convert (congr_fun (equiv_functor.map_trans e e.symm) x).symm, simp, },\n  right_inv := λ y, by { convert (congr_fun (equiv_functor.map_trans e.symm e) y).symm, simp, }, }\n\n@[simp] lemma map_equiv_apply (x : f α) :\n  map_equiv f e x = equiv_functor.map e x := rfl\n\nlemma map_equiv_symm_apply (y : f β) :\n  (map_equiv f e).symm y = equiv_functor.map e.symm y := rfl\n\n@[simp] lemma map_equiv_refl (α) :\n  map_equiv f (equiv.refl α) = equiv.refl (f α) :=\nby simpa [equiv_functor.map_equiv]\n\n@[simp] lemma map_equiv_symm :\n  (map_equiv f e).symm = map_equiv f e.symm :=\nequiv.ext $ map_equiv_symm_apply f e\n\n/--\nThe composition of `map_equiv`s is carried over the `equiv_functor`.\nFor plain `functor`s, this lemma is named `map_map` when applied\nor `map_comp_map` when not applied.\n-/\n@[simp] lemma map_equiv_trans {γ : Type u₀} (ab : α ≃ β) (bc : β ≃ γ) :\n  (map_equiv f ab).trans (map_equiv f bc) = map_equiv f (ab.trans bc) :=\nequiv.ext $ λ x, by simp [map_equiv, map_trans']\n\nend\n\n@[priority 100]\ninstance of_is_lawful_functor\n  (f : Type u₀ → Type u₁) [functor f] [is_lawful_functor f] : equiv_functor f :=\n{ map := λ α β e, functor.map e,\n  map_refl' := λ α, by { ext, apply is_lawful_functor.id_map, },\n  map_trans' := λ α β γ k h, by { ext x, apply (is_lawful_functor.comp_map k h x), } }\n\nlemma map_equiv.injective\n  (f : Type u₀ → Type u₁) [applicative f] [is_lawful_applicative f] {α β : Type u₀}\n  (h : ∀ γ, function.injective (pure : γ → f γ)) :\n  function.injective (@equiv_functor.map_equiv f _ α β) :=\nλ e₁ e₂ H, equiv.ext $ λ x, h β (by simpa [equiv_functor.map] using equiv.congr_fun H (pure x))\n\nend equiv_functor\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/control/equiv_functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4880540001146142}}
{"text": "import tactic\nimport lib.attempt\n\nopen function\n\ntheorem challenge4 (X Y Z : Type) (f : X → Y) (g : Y → Z) : surjective (g ∘ f) → surjective g :=\nattempt begin\n  unfold surjective,\n  intros h b,\n  cases h b with a hh,\n  use f a,\n  exact hh,\nend $\nλ h b, let ⟨ a, h ⟩ := h b in ⟨ f a, h ⟩\n\n", "meta": {"author": "AtnNn", "repo": "lean-sandbox", "sha": "8c68afbdc09213173aef1be195da7a9a86060a97", "save_path": "github-repos/lean/AtnNn-lean-sandbox", "path": "github-repos/lean/AtnNn-lean-sandbox/lean-sandbox-8c68afbdc09213173aef1be195da7a9a86060a97/src/xena_challenge/challenge4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.4880539954482225}}
{"text": "import tactic\nimport fol\nimport Rings.Notation\nimport Rings.ToMathlib\nimport Rings.ToMathlib.fol\nimport Rings.ToMathlib.dvector\nimport Rings.ToMathlib.fin\nimport data.polynomial.eval\nimport data.mv_polynomial\n\nuniverse u\n\nlocal infix ` ≃ `:64 := fol.bounded_preformula.bd_equal\n\nnamespace Rings\n\nlocal notation h :: t  := dvector.cons h t\nlocal notation `[` l:(foldr `, ` (h t, dvector.cons h t) dvector.nil `]`) := l\n\n/-- The constant symbols in RingSignature -/\ninductive ring_consts : Type*\n| zero : ring_consts\n| one : ring_consts\n\n/-- The unary function symbols in RingSignature-/\ninductive ring_unaries : Type*\n| neg : ring_unaries\n\n/-- The binary function symbols in RingSignature-/\ninductive ring_binaries : Type*\n| add : ring_binaries\n| mul : ring_binaries\n\n/-- All function symbols in RingSignature-/\ndef ring_funcs : ℕ → Type*\n| 0 := ring_consts\n| 1 := ring_unaries\n| 2 := ring_binaries\n| (n + 3) := pempty\n\ninstance : inhabited ring_consts := ⟨ ring_consts.zero ⟩\ninstance : inhabited ring_unaries := ⟨ ring_unaries.neg ⟩\ninstance : inhabited ring_binaries := ⟨ ring_binaries.add ⟩\n\nopen fol\n\n/-- The language of rings -/\ndef ring_signature : Language :=\n(Language.mk) (ring_funcs) (λ n, pempty)\n\n@[reducible] def bounded_ring_formula (n : ℕ) := bounded_formula ring_signature n\n@[reducible] def bounded_ring_term (n : ℕ) := bounded_term ring_signature n\n@[reducible] def bounded_ring_term' (n : ℕ) := bounded_preterm ring_signature n 0\n@[reducible] def realize_bounded_ring_term := @realize_bounded_term ring_signature\n\nnamespace ring_signature\n\n/- The following instances allow us to use symbols 0 1 - + *-/\n/- to write down terms in the language-/\n\n-- @[simp] def zero {n} : bounded_ring_term n := bd_func ring_consts.zero\n@[reducible] instance bounded_ring_term_has_zero {n} :\n  has_zero (bounded_ring_term n) := ⟨ bd_func ring_consts.zero ⟩\n@[reducible] instance bounded_ring_term_has_zero' {n} :\n  has_zero (bounded_ring_term' n) := ⟨ bd_func ring_consts.zero ⟩\n\n-- @[simp] def one {n} : bounded_ring_term n := bd_func ring_consts.one\n@[reducible] instance bounded_ring_term_has_one {n} :\n  has_one (bounded_ring_term n) := ⟨ bd_func ring_consts.one ⟩\n@[reducible] instance bounded_ring_term_has_one' {n} :\n  has_one (bounded_ring_term' n) := ⟨ bd_func ring_consts.one ⟩\n\n-- @[simp] def neg {n} : bounded_ring_term n → bounded_ring_term n := bd_app (bd_func ring_unaries.neg)\n@[reducible] instance bounded_ring_term_has_neg {n} : has_neg (bounded_ring_term n) :=\n⟨ bd_app (bd_func ring_unaries.neg) ⟩\n@[reducible] instance bounded_ring_term_has_neg' {n} : has_neg (bounded_ring_term' n) :=\n⟨ bd_app (bd_func ring_unaries.neg) ⟩\n\n-- @[simp] def add {n} (x : bounded_ring_term n) : bounded_ring_term n → bounded_ring_term n :=\n--   bd_app (bd_app (bd_func ring_binaries.add) x)\n@[reducible] instance bounded_ring_term_has_add {n} : has_add (bounded_ring_term n) :=\n⟨ λ x, bd_app (bd_app (bd_func ring_binaries.add) x) ⟩\n@[reducible] instance bounded_ring_term_has_add' {n} : has_add (bounded_ring_term'  n) :=\n⟨ λ x, bd_app (bd_app (bd_func ring_binaries.add) x) ⟩\n\n-- @[simp] def mul {n} (x : bounded_ring_term n) : bounded_ring_term n → bounded_ring_term n :=\n--   bd_app (bd_app (bd_func ring_binaries.mul) x)\n@[reducible] instance bounded_ring_term_has_mul {n} : has_mul (bounded_ring_term n) :=\n⟨ λ x, bd_app (bd_app (bd_func ring_binaries.mul) x) ⟩\n@[reducible] instance bounded_ring_term_has_mul' {n} : has_mul (bounded_ring_term' n) :=\n⟨ λ x, bd_app (bd_app (bd_func ring_binaries.mul) x) ⟩\n\n-- has_pow comes for free by having instances of mul and 1 (see ToMathlib) -- input x ^ n\n\n@[simp] lemma pow_zero {n} (t : bounded_ring_term n) : npow_rec 0 t = 1 := rfl\n@[simp] lemma pow_succ {n m} (t : bounded_ring_term m) :\n  npow_rec (n + 1) t = t * npow_rec n t := rfl\n\n\n-- with has_one and has_add you can write any natural and lean will know what term you mean\n-- with has_neg you can write any integer etc.\n\n/-\n-- variables x0 , x1 in the signature\n-- (they are only variables in bounded terms that have up to n + 1, n + 2 variables)\nexample {n} : bounded_term ring_signature (n + 1) := x_ 0\n-- for example {n} : bounded_term ring_signature n := x_ 0 doesn't work\n-- since fin n doesn't have an instance of 0 in general (when n = 0)\nexample {n} : bounded_term ring_signature (n + 2) := x_ 1\n-- actually example {n} : bounded_term ring_signature (n + 1) := x_ 1 also works because\n-- fin (n + 1) is implemented mod (n + 1), in particular 1 = 0 ∈ fin 1\n-- but let's avoid that\n\n-- neg x\nexample {n} : bounded_ring_term (n + 1) := - (x_ 0)\nexample {n} : bounded_ring_term (n + 1) := (x_ 0) + 1\nexample {n} : bounded_ring_term (n + 2):= (- x_ 0) * x_ 1\nexample {n} : bounded_ring_term (n + 1) := x_ 0 + x_ 0\n-/\n\n/-- Part of the definition of ring_term_rec -/\n@[simp] def ring_func_rec {n} {C : bounded_term ring_signature n → Sort*}\n  (cvar : Π (k : fin n), C (x_ k))\n  (c0 : C 0) (c1 : C 1)\n  (cneg : Π {t}, C t → C (- t))\n  (cadd : Π {s t}, C s → C t → C (s + t)) (cmul : Π {s t}, C s → C t → C (s * t)) :\n  Π {l : ℕ} (f : ring_signature.functions l) (ts : dvector (bounded_term ring_signature n) l),\n  (Π (t : bounded_ring_term n), dvector.pmem t ts → C t)\n  → C (bd_apps (bd_func f) ts)\n| 0 (ring_consts.zero) ([]) h := c0\n| 0 (ring_consts.one) ([]) h := c1\n| 1 (ring_unaries.neg) ([t]) h := cneg (h t (psum.inl rfl))\n| 2 (ring_binaries.add) ([s,t]) h := cadd (h s (psum.inl rfl)) (h t (psum.inr (psum.inl rfl)))\n| 2 (ring_binaries.mul) ([s,t]) h := cmul (h s (psum.inl rfl)) (h t (psum.inr (psum.inl rfl)))\n| (n + 3) f ts h := pempty.elim f\n\n/-- An interface for mapping out of bounded_ring_term n (basically bounded_term.rec) -/\ndef ring_term_rec {n : ℕ} {C : bounded_ring_term n → Sort*}\n  (cvar : Π (k : fin n), C (x_ k))\n  (c0 : C 0) (c1 : C 1)\n  (cneg : Π {t}, C t → C (- t))\n  (cadd : Π {s t}, C s → C t → C (s + t)) (cmul : Π {s t}, C s → C t → C (s * t))\n  : Π (t : bounded_ring_term n), C t :=\n@bounded_term.rec ring_signature n C\n(λ k, cvar k)\n(λ l, ring_func_rec cvar c0 c1 @cneg @cadd @cmul)\n\n-- def ring_term_ind {n : ℕ} {C : bounded_ring_term n → Prop}\n--   (cvar : Π (k : fin n), C (x_ k))\n--   (c0 : C 0) (c1 : C 1)\n--   (cneg : Π {t}, C t → C (- t))\n--   (cadd : Π {s t}, C s → C t → C (s + t)) (cmul : Π {s t}, C s → C t → C (s * t))\n--   : Π (t : bounded_ring_term n), C t :=\n-- @bounded_term.rec ring_signature n C\n-- (λ k, cvar k)\n-- (λ l, ring_func_rec cvar c0 c1 @cneg @cadd @cmul)\n\n/- Sentences for the theory of rings: commutative group under addition -/\n\n/-- Assosiativity of addition -/\ndef add_assoc : sentence ring_signature :=\n  ∀' ∀' ∀' ( (x_ 0 + x_ 1) + x_ 2 ≃ x_ 0 + (x_ 1 + x_ 2) )\n\n/-- Identity for addition -/\ndef add_id : sentence ring_signature := ∀' ( x_ 0 + 0 ≃ x_ 0 )\n-- def add_id : sentence ring_signature := ∀' (   &'0 r+ r0 ≃ &'0   ⊓   r0 r+ &'0 ≃ &'0   )\n\n/-- Inverse for addition -/\ndef add_inv : sentence ring_signature := ∀' ( - x_ 0 + x_ 0 ≃ 0 )\n-- def add_inv : sentence ring_signature := ∀' (  &'0 r+ r- &'0 ≃ r0  ⊓  r- &'0 r+ &'0 ≃ r0  )\n\n/-- Commutativity of addition-/\ndef add_comm : sentence ring_signature := ∀' ∀' ( x_ 0 + x_ 1 ≃ x_ 1 + x_ 0 )\n\n/- Sentences for theory of rings: commutative monoid under multiplication -/\n\n/-- Associativity of multiplication -/\ndef mul_assoc : sentence ring_signature :=\n∀' ∀' ∀' ( (x_ 0 * x_ 1) * x_ 2 ≃ x_ 0 * (x_ 1 * x_ 2) )\n\n/-- Identity of multiplication -/\ndef mul_id : sentence ring_signature :=  ∀' ( x_ 0 * 1 ≃ x_ 0 )\n-- def mul_id : sentence ring_signature :=  ∀' (   &'0 r× r1 ≃ &'0   )\n\n/-- Commutativity of multiplication -/\ndef mul_comm : sentence ring_signature := ∀' ∀' ( x_ 0 * x_ 1 ≃ x_ 1 * x_ 0   )\n\n/-- Distributibity -/\ndef add_mul : sentence ring_signature := ∀' ∀' ∀' ( (x_ 0 + x_ 1) * x_ 2 ≃ x_ 0 * x_ 2 + x_ 1 * x_ 2 )\n\n/-- The theory of rings -/\ndef ring_theory : Theory ring_signature :=\n{add_assoc, add_id, add_inv, add_comm, mul_assoc, mul_id, mul_comm, add_mul}\n\nlemma add_assoc_in_ring_theory : add_assoc ∈ ring_theory :=\nbegin unfold ring_theory, left, refl end\n\nlemma add_id_in_ring_theory : add_id ∈ ring_theory :=\nbegin unfold ring_theory, iterate 1 {right}, left, refl end\n\nlemma add_inv_in_ring_theory : add_inv ∈ ring_theory :=\nbegin unfold ring_theory, iterate 2 {right}, left, refl end\n\nlemma add_comm_in_ring_theory : add_comm ∈ ring_theory :=\nbegin unfold ring_theory, iterate 3 {right}, left, refl end\n\nlemma mul_assoc_in_ring_theory : mul_assoc ∈ ring_theory :=\nbegin unfold ring_theory, iterate 4 {right}, left, refl end\n\nlemma mul_id_in_ring_theory : mul_id ∈ ring_theory :=\nbegin unfold ring_theory, iterate 5 {right}, left, refl end\n\nlemma mul_comm_in_ring_theory : mul_comm ∈ ring_theory :=\nbegin unfold ring_theory, iterate 6 {right}, left, refl end\n\nlemma add_mul_in_ring_theory : add_mul ∈ ring_theory :=\nbegin unfold ring_theory, iterate 7 {right}, exact set.mem_singleton _, end\n\nend ring_signature\n\nnamespace struc_to_ring_struc\n-- We make any (type theoretic) structure A,0,1,-,+,* into a\n-- (model theoretic) Structure in ring_signature\n\nvariable {A : Type*}\n\n-- Interpreting consant symbols from ring_signature -/\n@[simp] def const_map [has_zero A] [has_one A] : ring_consts → (dvector A 0) → A\n| ring_consts.zero _ := 0\n| ring_consts.one  _ := 1\n\n/-- Interpreting unary function symbols from ring_signature -/\n@[simp] def unaries_map [has_neg A] : ring_unaries → (dvector A 1) → A\n| ring_unaries.neg a := - (dvector.last a)\n\n/-- Interpreting binary function symbols from ring_signature -/\n@[simp] def binaries_map [has_add A] [has_mul A] : ring_binaries → (dvector A 2) → A\n| ring_binaries.add   (a :: b) := a + dvector.last b\n| ring_binaries.mul  (a :: b) := a * dvector.last b\n\nvariables [has_zero A] [has_one A] [has_neg A] [has_add A] [has_mul A]\n\n/-- Interpreting all symbols from ring_signature-/\n@[simp] def func_map : Π (n : ℕ), (ring_funcs n) → (dvector A n) → A\n| 0       := const_map\n| 1       := unaries_map\n| 2       := binaries_map\n| (n + 3) := pempty.elim\n\nvariable (A)\n\n/-- Interpreting the symbols -/\n@[reducible] def Structure : Structure ring_signature :=\nStructure.mk A func_map (λ n, pempty.elim)\n\nvariable {A}\n\n@[simp] lemma realize_zero {n} {vec : dvector A n} :\n  @realize_bounded_ring_term (struc_to_ring_struc.Structure A) n vec 0\n    (@bd_func ring_signature _ 0 ring_consts.zero) dvector.nil = 0 := rfl\n\nlemma apps_zero {n} : Π {t_ : dvector (bounded_ring_term n) 0},\n  bd_apps (@bd_func ring_signature _ 0 ring_consts.zero) t_ = 0\n| [] := rfl\n\n@[simp] lemma realize_one {n} {vec : dvector A n} :\n  @realize_bounded_ring_term (Structure A) n vec 0\n    (@bd_func ring_signature _ 0 ring_consts.one) dvector.nil = 1 := rfl\n\nlemma realize_nat {as} : Π (n : ℕ),\n@realize_bounded_term _ (Structure A) _ as _ (n : bounded_ring_term 0) dvector.nil\n= n\n| 0 := rfl\n| (n+1) :=\nby simpa only [const_map, realize_bounded_term,\n      nat.cast_succ, realize_nat n]\n\nlemma apps_one {n} : Π {t_ : dvector (bounded_ring_term n) 0},\n  bd_apps (@bd_func ring_signature _ 0 ring_consts.one) t_ = 1\n| [] := rfl\n\nlemma app_neg {n} {t : bounded_ring_term n} :\n  bd_app (@bd_func ring_signature _ 1 ring_unaries.neg) t = - t := rfl\n\nlemma apps_neg {n} {t : bounded_ring_term n} :\n   bd_apps (@bd_func ring_signature _ 1 ring_unaries.neg) ([t]) = - t := rfl\n\nlemma app_add {n} {s t : bounded_ring_term n} :\n  ((@bd_func ring_signature _ 2 ring_binaries.add).bd_app t).bd_app s = t + s := rfl\n\nlemma apps_add {n} {s t : bounded_ring_term n} :\n   bd_apps (@bd_func ring_signature _ 2 ring_binaries.add) ([s,t]) = s + t := rfl\n\nlemma app_mul {n} {s t : bounded_ring_term n} :\n  ((@bd_func ring_signature _ 2 ring_binaries.mul).bd_app t).bd_app s = t * s := rfl\n\nlemma apps_mul {n} {s t : bounded_ring_term n} :\n   bd_apps (@bd_func ring_signature _ 2 ring_binaries.mul) ([s,t]) = s * t := rfl\n\n  -- lemma preterm_upper_bound {n} : bounded_preterm ring_signature n 3 → false := _\n\nend struc_to_ring_struc\n\nnamespace comm_ring_to_model\n\n  variables (A : Type*) [comm_ring A]\n\n  lemma realize_ring_theory :\n    (struc_to_ring_struc.Structure A) ⊨ ring_signature.ring_theory :=\n  begin\n    intros ϕ h,\n    repeat {cases h},\n    { intros a b c,\n      simp[add_assoc] },\n    { intro a,\n      simp },\n    { intro a,\n      simp },\n    { intros a b,\n      simp [add_comm] },\n    { intros a b c,\n      simp [mul_assoc] },\n    { intro a,\n      simp [mul_one] },\n    { intros a b,\n      simp [mul_comm] },\n    { intros a b c,\n      simp [add_mul] }\n  end\n\n  /-- Commutative rings model the theory of rings -/\n  def model : Model ring_signature.ring_theory :=\n  ⟨ struc_to_ring_struc.Structure A ,  realize_ring_theory A ⟩\n\nend comm_ring_to_model\n\nnamespace mv_polynomial\n\n  variable {σ : Type}\n\n  open ring_signature\n\n  /-- Terms in the ring_signature are multivariable polynomials over ℤ -/\n  noncomputable def term {n} :\n    bounded_ring_term n → mv_polynomial (fin n) ℤ :=\n  @ring_term_rec n (λ _, mv_polynomial (fin n) ℤ)\n    mv_polynomial.X 0 1\n    (λ _ p, - p)\n    (λ _ _ p q, p + q)\n    (λ _ _ p q, p * q)\n\n  @[simp] lemma term_x {n} {k : fin n} : term (x_ k) = mv_polynomial.X k := rfl\n  @[simp] lemma term_zero {n} : @term n (bd_func ring_consts.zero) = 0 := rfl\n  @[simp] lemma term_one {n} : @term n (bd_func ring_consts.one) = 1 := rfl\n  @[simp] lemma term_neg {n} {t : bounded_ring_term n} :\n    term (- t) = - term t := rfl\n  @[simp] lemma term_add {n} {s t : bounded_ring_term n} :\n    term (s + t) = term s + term t := rfl\n  @[simp] lemma term_mul {n} {s t : bounded_ring_term n} :\n    term (s * t) = term s * term t := rfl\n\n  variables {A : Type*} [comm_ring A]\n\n  @[reducible] private def AStruc := struc_to_ring_struc.Structure A\n\n  /-- terms realized at values in A are the corresponding polynomials -/\n  /- evaluated at those values -/\n  lemma realized_term_is_evaluated_poly {n} {as : dvector A n} :\n  Π (t : bounded_ring_term n),\n    @realize_bounded_term _ AStruc _ as _ t dvector.nil\n    = mv_polynomial.eval (dvector.fin_val as) (term t) :=\n  @ring_term_rec n (λ (t : bounded_ring_term n),\n    @realize_bounded_term _ AStruc _ as _ t dvector.nil\n      = mv_polynomial.eval (dvector.fin_val as) (term t))\n    (begin intro k, simpa, end) -- variables\n    (by simpa)\n    (by simp)\n    (begin -- neg\n      intros t h,\n      unfold_coes,\n      simp only [struc_to_ring_struc.unaries_map, struc_to_ring_struc.func_map,\n        dvector.last, realize_bounded_term, dvector.nth, mv_polynomial.coe_mv_poly_neg],\n      unfold_coes at h,\n      simp only [ring_hom.to_fun_eq_coe, mv_polynomial.eval_map] at h,\n      simp only [term_neg, h, ring_hom.to_fun_eq_coe, ring_hom.map_neg,\n        mv_polynomial.eval_map, neg_inj, struc_to_ring_struc.apps_neg],\n    end)\n    (begin -- add\n      intros s t hs ht,\n      unfold_coes,\n      simp only [term_add, struc_to_ring_struc.binaries_map, dvector.last,\n        struc_to_ring_struc.func_map, dvector.last, realize_bounded_term,\n        dvector.nth, mv_polynomial.coe_mv_poly_neg, hs, ht],\n      unfold_coes,\n      simp,\n    end)\n    (begin -- mul\n      intros s t hs ht,\n      unfold_coes,\n      simp only [term_mul, struc_to_ring_struc.binaries_map, dvector.last,\n        struc_to_ring_struc.func_map, dvector.last, realize_bounded_term,\n        dvector.nth, mv_polynomial.coe_mv_poly_neg, hs, ht],\n      unfold_coes,\n      simp,\n    end)\n\nend mv_polynomial\n\nnamespace polynomial\n\n  variables {A : Type*} [comm_ring A]\n\n  @[reducible] private def AStruc := struc_to_ring_struc.Structure A\n\n  /-- Takes a term in variables x₀ ⋯ xₙ and values a₁ ⋯ aₙ : A and returns\n    a polynomial in A[X] such that x₀ ↦ X and otherwise xₙ ↦ aₙ -/\n  @[reducible] noncomputable def term_evaluated_at_coeffs {n} (as : dvector A n)\n    (t : bounded_ring_term n.succ) : polynomial A :=\n  let σ : fin n.succ → polynomial A :=\n  @fin.cases n (λ _, polynomial A) polynomial.X (λ i, polynomial.C (dvector.nth' as i)) in\n  mv_polynomial.eval σ (mv_polynomial.term t)\n\n  /-- Evaluating the polynomial term_evaluated_at_coeffs at a₀ : A produces the same\n    term in A as realising the term at a₀ a₁ ⋯ aₙ -/\n  lemma eval_term_evaluated_at_coeffs_eq_realize_bounded_term\n    {n} {as : dvector A n} {x : A} (t : bounded_term ring_signature n.succ) :\n    (polynomial.eval x (term_evaluated_at_coeffs as t)\n      = @realize_bounded_term _ AStruc n.succ (x::as) _ t dvector.nil) :=\n  begin\n    rw [mv_polynomial.realized_term_is_evaluated_poly,\n      dvector.fin_val_eq_x_val,\n      mv_polynomial.eval_eq_poly_eval_mv_coeffs],\n    simp only [dvector.fin_val, function.comp_app, fin.x_val,\n      mv_polynomial.to_polynomial, term_evaluated_at_coeffs],\n    unfold_coes,\n    have hcoes : int.cast_ring_hom (polynomial A) =\n      polynomial.C.comp (int.cast_ring_hom AStruc) := by simp,\n    rw hcoes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_X {n} {as : dvector A n} :\n    term_evaluated_at_coeffs as (x_ ⟨ 0 , nat.zero_lt_succ _ ⟩) = polynomial.X :=\n  begin\n    simp only [term_evaluated_at_coeffs],\n    unfold_coes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_coeff\n  {n} {as : dvector A n} {k : fin n} :\n    term_evaluated_at_coeffs as (x_ ⟨ k.1.succ , nat.succ_lt_succ k.2 ⟩)\n    = polynomial.C (dvector.nth' as k) :=\n  begin\n    simp only [term_evaluated_at_coeffs],\n    unfold_coes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_zero {n} {as : dvector A n} :\n    term_evaluated_at_coeffs as (bd_func ring_consts.zero) = 0 :=\n  begin\n    simp only [term_evaluated_at_coeffs],\n    unfold_coes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_one {n} {as : dvector A n} :\n    term_evaluated_at_coeffs as (bd_func ring_consts.one) = 1 :=\n  begin\n    simp only [term_evaluated_at_coeffs],\n    unfold_coes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_neg {n} {as : dvector A n} {t : bounded_ring_term n.succ} :\n    term_evaluated_at_coeffs as (- t) = - term_evaluated_at_coeffs as t :=\n  begin\n    simp only [term_evaluated_at_coeffs],\n    unfold_coes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_add {n} {as : dvector A n} {s t : bounded_ring_term n.succ} :\n    term_evaluated_at_coeffs as (s + t) = term_evaluated_at_coeffs as s + term_evaluated_at_coeffs as t :=\n  begin\n    simp only [term_evaluated_at_coeffs],\n    unfold_coes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_mul {n} {as : dvector A n} {s t : bounded_ring_term n.succ} :\n    term_evaluated_at_coeffs as (s * t) = term_evaluated_at_coeffs as s * term_evaluated_at_coeffs as t :=\n  begin\n    simp only [term_evaluated_at_coeffs],\n    unfold_coes,\n    simp,\n  end\n\n  lemma term_evaluated_at_coeffs_pow {n : ℕ} : Π {m : ℕ} {as : dvector A n},\n    polynomial.term_evaluated_at_coeffs as (npow_rec m x_ ⟨ 0 , nat.zero_lt_succ _ ⟩)\n    = polynomial.X ^ m\n  | 0       _ :=\n  by simpa only [ring_signature.pow_zero, term_evaluated_at_coeffs_one]\n  | (m + 1) as :=\n  by rw [ring_signature.pow_succ, term_evaluated_at_coeffs_mul,\n      @term_evaluated_at_coeffs_pow m as, pow_succ, term_evaluated_at_coeffs_X]\n\n  lemma term_evaluated_at_coeffs_monomial {n : ℕ} {m : ℕ} {as : dvector A n} {k : fin n} :\n    polynomial.term_evaluated_at_coeffs as\n      (x_ ⟨ k.1.succ , nat.succ_lt_succ k.2 ⟩ *\n      npow_rec m x_ ⟨ 0 , nat.zero_lt_succ _ ⟩)\n      = polynomial.monomial m (dvector.nth' as k) :=\n  by rw [term_evaluated_at_coeffs_mul, term_evaluated_at_coeffs_coeff,\n     term_evaluated_at_coeffs_pow, polynomial.monomial_eq_C_mul_X]\n\n  lemma term_evaluated_at_coeffs_monomial'\n    {n m k : ℕ} {as : dvector A n} (hk : k < n) :\n    polynomial.term_evaluated_at_coeffs as\n      (x_ ⟨ k.succ , nat.succ_lt_succ hk ⟩ *\n      npow_rec m x_ ⟨ 0 , nat.zero_lt_succ _ ⟩)\n      = polynomial.monomial m (dvector.nth as k hk) :=\n  begin\n    rw term_evaluated_at_coeffs_mul,\n    have h : term_evaluated_at_coeffs as x_⟨k.succ, _⟩\n      =  polynomial.C (dvector.nth as k hk),\n    { unfold_coes,\n      simp [term_evaluated_at_coeffs, dvector.nth'] },\n    rw [h, term_evaluated_at_coeffs_pow, polynomial.monomial_eq_C_mul_X],\n  end\n\n  lemma lift_succ_remove_last {n : ℕ} :\n  Π {t : bounded_ring_term (n + 1)} {as : dvector A (n + 1)},\n    polynomial.term_evaluated_at_coeffs as (lift_succ t)\n    = polynomial.term_evaluated_at_coeffs (dvector.remove_mth (n + 2) as) t :=\n  @ring_signature.ring_term_rec (n + 1)\n  (λ {t : bounded_ring_term (n + 1)}, Π {as : dvector A (n + 1)},\n    polynomial.term_evaluated_at_coeffs as (lift_succ t)\n    = polynomial.term_evaluated_at_coeffs (dvector.remove_mth (n + 2) as) t)\n    (begin -- variables\n      intros k as,\n      rw lift_succ_x_k,\n      cases k with k hk,\n      cases k,\n      { simp [term_evaluated_at_coeffs] },\n      {\n        simp only [mv_polynomial.eval_X, polynomial.C_inj,\n          fin.coe_eq_cast_succ, fin.cases_succ', mv_polynomial.coe_mv_poly_X,\n          fin.cast_succ_mk, mv_polynomial.term_x, term_evaluated_at_coeffs,\n          dvector.nth'],\n        rw dvector.nth_eq_succ_nth,\n      },\n    end)\n    (by { intro, simp [lift_succ, term_evaluated_at_coeffs_zero] })\n    (by { intro, simp [lift_succ, term_evaluated_at_coeffs_one] })\n    (by { intros _ h _,\n      simp [lift_succ, struc_to_ring_struc.app_neg,\n        term_evaluated_at_coeffs_neg, h] })\n    (by { intros s t hs ht as,\n      simp only [lift_succ, struc_to_ring_struc.app_add,\n        term_evaluated_at_coeffs_add, hs, ht] })\n    (by { intros s t hs ht as,\n      simp only [lift_succ, struc_to_ring_struc.app_mul,\n        term_evaluated_at_coeffs_mul, hs, ht] })\n\nend polynomial\n\nnamespace models_ring_theory_to_comm_ring\n\n  variable {M : Structure ring_signature}\n\n  def zero : ↥ M := @Structure.fun_map _ M 0 ring_consts.zero dvector.nil\n  def one : ↥ M := @Structure.fun_map _ M 0 ring_consts.one dvector.nil\n  def neg (a : M.carrier) : M.carrier := @Structure.fun_map _ M 1 ring_unaries.neg ([a])\n  def add (a b : M.carrier) : M.carrier := @Structure.fun_map _ M 2 ring_binaries.add ([a , b])\n  def mul (a b : M.carrier) : M.carrier := @Structure.fun_map _ M 2 ring_binaries.mul ([a , b])\n\n  instance : has_zero M := ⟨ zero ⟩\n  instance : has_one M := ⟨ one ⟩\n  instance : has_neg M := ⟨ neg ⟩\n  instance : has_add M := ⟨ add ⟩\n  instance : has_mul M := ⟨ mul ⟩\n\n  @[simp] lemma realize_zero {n} {vec : dvector M.carrier n} :\n    realize_bounded_term vec (@bd_func ring_signature _ 0 ring_consts.zero) dvector.nil = 0 := rfl\n\n  @[simp] lemma realize_one {n} {vec : dvector M.carrier n} :\n    realize_bounded_term vec (@bd_func ring_signature _ 0 ring_consts.one) dvector.nil = 1 := rfl\n\n  @[simp] lemma realize_neg {a : M.carrier} :\n    @Structure.fun_map _ M 1 ring_unaries.neg ([a]) = - a := rfl\n\n  @[simp] lemma realize_add {a b : M.carrier} :\n    @Structure.fun_map _ M 2 ring_binaries.add ([a , b]) = a + b := rfl\n\n  @[simp] lemma realize_mul {a b : M.carrier} :\n    @Structure.fun_map _ M 2 ring_binaries.mul ([a , b]) = a * b := rfl\n\n  lemma realize_pow {a : M.carrier} : ∀ {m n} {vec : dvector M.carrier n},\n  realize_bounded_term (a :: vec) (npow_rec m (x_ 0)) dvector.nil\n  = npow_rec m a\n  | 0 n vec := rfl\n  | (m+1) n vec :=\n  by simp only [npow_rec, realize_bounded_term, realize_mul,\n        fin.val_zero, dvector.nth, @realize_pow m]\n\n  lemma realize_nat {M : fol.Structure ring_signature} {as : dvector M 0} :\n  Π (n : ℕ),\n  @realize_bounded_term _ M _ as _ (n : bounded_ring_term 0) dvector.nil\n  = n\n  | 0 := rfl\n  | (n+1) :=\n  by simpa only [realize_bounded_term, nat.cast_succ, realize_nat n, realize_one]\n\n  variable (h : M ⊨ ring_signature.ring_theory)\n\n  include h\n\n  lemma add_assoc (a b c : M) : (a + b) + c = a + (b + c) :=\n  begin\n    have hAssoc := h ring_signature.add_assoc_in_ring_theory,\n    have habc := hAssoc c b a,\n    simpa [habc]\n  end\n\n  lemma add_comm (a b : M) : a + b = b + a :=\n  begin\n    have hId := h ring_signature.add_comm_in_ring_theory,\n    have hab := hId b a,\n    simpa [hab]\n  end\n\n  lemma add_zero (a : M) : a + 0 = a :=\n  begin\n    have hId := h ring_signature.add_id_in_ring_theory,\n    have ha := hId a,\n    simpa [ha]\n  end\n\n  lemma zero_add (a : M) : 0 + a = a :=\n  begin\n    rw add_comm h, apply add_zero h,\n  end\n\n  lemma left_neg (a : M) : - a + a = 0 :=\n  begin\n    have hInv := h ring_signature.add_inv_in_ring_theory,\n    have ha := hInv a,\n    simpa [ha]\n  end\n\n  lemma mul_assoc (a b c : M) : (a * b) * c = a * (b * c) :=\n  begin\n    have hAssoc := h ring_signature.mul_assoc_in_ring_theory,\n    have habc := hAssoc c b a,\n    simpa [habc]\n  end\n\n  lemma mul_comm (a b : M) : a * b = b * a :=\n  begin\n    have hId := h ring_signature.mul_comm_in_ring_theory,\n    have hab := hId b a,\n    simpa [hab]\n  end\n\n  lemma mul_one (a : M) : a * 1 = a :=\n  begin\n    have hId := h ring_signature.mul_id_in_ring_theory, have ha := hId a, simpa using ha\n  end\n\n  lemma one_mul (a : M) : 1 * a = a :=\n  by rw [mul_comm h, mul_one h]\n\n  lemma add_mul (a b c : M) : (a + b) * c = a * c + b * c :=\n  begin\n    have hAM := h ring_signature.add_mul_in_ring_theory,\n    have habc := hAM c b a,\n    simpa [habc]\n  end\n\n  lemma mul_add (c a b : M) : c * (a + b) = c * a + c * b :=\n  begin\n    rw [mul_comm h c (a + b), mul_comm h c a, mul_comm h c b],\n    exact add_mul h a b c,\n  end\n\n  instance comm_ring : comm_ring M :=\n  {\n    add            := add,\n    add_assoc      := add_assoc h,\n    zero           := zero,\n    zero_add       := zero_add h,\n    add_zero       := add_zero h,\n    neg            := neg,\n    add_left_neg   := left_neg h,\n    add_comm       := add_comm h,\n    mul            := mul,\n    mul_assoc      := mul_assoc h,\n    one            := one,\n    one_mul        := one_mul h,\n    mul_one        := mul_one h,\n    left_distrib   := mul_add h,\n    right_distrib  := add_mul h,\n    mul_comm       := mul_comm h,\n  }\n\nend models_ring_theory_to_comm_ring\n\nnamespace instances\n\nopen ulift\n\ndef pℕ : Type* := ulift ℕ\n\ndef nat_ring_consts :\n  ring_consts → dvector pℕ 0 → pℕ\n| ring_consts.zero as := up 0\n| ring_consts.one as := up 1\n\ndef nat_ring_structure_funcs :\n  Π {n}, ring_signature.functions n → dvector pℕ n → pℕ\n| 0 ring_consts.zero as := up 0\n| 0 ring_consts.one as := up 1\n| 1 ring_unaries.neg as := up 0\n| 2 ring_binaries.add (dvector.cons a (dvector.cons b nil)) :=\n  up ( down a + down b)\n| 2 ring_binaries.mul (dvector.cons a (dvector.cons b nil)) :=\n  up ( down a * down b)\n| (n+3) f as := pempty.elim f\n\ndef nat_ring_structure : fol.Structure ring_signature :=\n⟨ pℕ , λ _, nat_ring_structure_funcs , λ _, pempty.elim ⟩\n\nlemma nat_ring_structure_realize_nat :\n  Π (n : ℕ) {k : ℕ} (v : dvector nat_ring_structure k),\n  realize_bounded_ring_term v\n    (n : fol.bounded_preterm ring_signature k 0) dvector.nil = up n\n| 0 _ _ := rfl\n| (n+1) k v :=\nbegin\n  have h := @nat_ring_structure_realize_nat n k v,\n  rw [realize_bounded_ring_term] at h,\n  simpa only [nat.cast_succ, realize_bounded_ring_term,\n    fol.realize_bounded_term, h],\nend\n\nlemma nat_cast_bd_ring_term_inj {k n m : ℕ} :\n  (n : fol.bounded_preterm ring_signature.{u} k 0) = m → n = m :=\nbegin\n  let v : dvector nat_ring_structure k := dvector.of_fn (λ i, 0),\n  intro hnm,\n  rw [← down_up n, ← down_up m, ← nat_ring_structure_realize_nat n v,\n    ← nat_ring_structure_realize_nat m v],\n  apply congr_arg down.{u},\n  exact @congr_arg (fol.bounded_preterm ring_signature k 0)\n    nat_ring_structure n m\n    (λ t : fol.bounded_preterm ring_signature k 0,\n      realize_bounded_ring_term v t dvector.nil) hnm,\nend\n\nend instances\n\nend Rings\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/Rings/Rings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.679178686187839, "lm_q1q2_score": 0.4880539954482223}}
{"text": "\nnoncomputable \ndef Quot.repr {S : α → α → Prop} (a : Quot S) : α := Classical.choose a.exists_rep\n\nnamespace SciLean\n\n  abbrev Rel (α : Type u) := α → α → Prop\n\n  class IsQHom (S : Rel α) (R : Rel β) (f : α → β) where\n    is_hom : ∀ a a', S a a' → R (f a) (f a')\n\n  class IsQHom₂ (S : Rel α) (R : Rel β) (T : Rel γ) (f : α → β → γ) where\n    is_hom : ∀ a a' b b', S a a' → R b b' → T (f a b) (f a' b')\n\n  notation \"⟦\" x \"⟧\" => Quot.mk _ x\n  notation \"⟦\" x \", \" S \"⟧\" => Quot.mk S x\n\n  def IsQHom.sound {S : Rel α} {R : Rel β} (f : α → β) [IsQHom S R f] \n    : ∀ a a', S a a' → ⟦f a⟧ = ⟦f a', R⟧\n    := \n  by\n    intros a a' h;\n    apply Quot.sound;\n    apply IsQHom.is_hom a a' h\n    done\n\n  def IsQHom₂.sound {S : Rel α} {R : Rel β} {T : Rel γ} (f : α → β → γ) [IsQHom₂ S R T f] \n    : ∀ a a' b b', S a a' → R b b' → ⟦f a b⟧ = ⟦f a' b', T⟧\n    :=\n  by\n    intros a a' b b' h h';\n    apply Quot.sound;\n    apply IsQHom₂.is_hom a a' b b' h h'\n    done\n\n  notation \"⟦\" f \"⟧\" => Quot.lift (λ x => Quot.mk _ (f x)) (IsQHom.sound f)\n  notation \"⟦\" f \", \" S \", \" R\"⟧\" => Quot.lift (r := S) (λ x => Quot.mk R (f x)) (IsQHom.sound f)\n\n  instance : Coe α (Quot (Eq : α → α → Prop)) := \n  ⟨ λ a => Quot.mk _ a ⟩\n\n  -- This one seem to be dangerous :(\n  -- instance : Coe (Quot (Eq : α → α → Prop)) α := \n  -- ⟨ λ a => Quot.lift id (by intro a b h; apply h; done) a ⟩\n\n  ---------------------\n\n  instance (f : α → β) : IsQHom Eq Eq f := sorry\n\n  instance (S : Rel α) : IsQHom S S (λ x => x) := sorry\n\n  instance (S : Rel α) (R : Rel β) (T : Rel γ) \n    (f : β → γ) (g : α → β)\n    [IsQHom R T f] [IsQHom S R g]\n    : IsQHom S T (f ∘ g)\n    := sorry\n\n  ---------------------\n\n  @[simp]\n  theorem quot_comp\n    (S : Rel α) (R : Rel β) (T : Rel γ) \n    (f : β → γ) (g : α → β) [IsQHom R T f] [IsQHom S R g]\n    :\n    ⟦f, R, T⟧ ∘ ⟦g, S, R⟧ = ⟦f ∘ g, S, T⟧\n    := \n    sorry\n\n  @[simp]\n  theorem quot_apply {S : Rel α} {R : Rel β} (f : α → β) [IsQHom S R f] (a : Quot S)\n    : ⟦f a.repr, R⟧ = ⟦f⟧ a\n    := sorry\n\n  ---------------------\n \n  variable {f : α → β} {S : Rel α} {R : Rel β} {a : α} [IsQHom S R f]\n\n  #check Eq\n\n  #check ⟦f, Eq, Eq⟧ ⟦a, Eq⟧\n  #check ⟦f, Eq, Eq⟧ ⟦a⟧\n  #check ⟦f, Eq, Eq⟧ a\n\n  #check ⟦f, S, R⟧ ⟦a, S⟧\n  #check ⟦f, S, R⟧ ⟦a⟧\n\n  #check ⟦f, S, R⟧\n  #check (⟦f⟧ ⟦a⟧ : Quot R)\n\n  -- ⟦f⟧ ∘ ⟦g⟧ = ⟦f ∘ g⟧\n  -- ⟦f x.repr⟧ = ⟦f⟧ x\n  -- ⟦f⟧ ⟦x⟧ = ⟦f x⟧\n\nend SciLean\n\n\n\n\n\n\n\n\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Quot/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527631, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.48801751405474586}}
{"text": "universe u\n\nclass ordinal (α : Type u) extends\n  decidable_linear_order α, has_zero α, has_add α, has_mul α :=\n(omega : α)\n(succ : α → α)\n(zero_le : ∀ x : α, 0 ≤ x)\n(zero_lt_omega : 0 < omega)\n(zero_or_succ_of_lt_omega : ∀ x : α, x < omega → (x = 0 ∨ ∃ y, x = succ y))\n(succ_ne_zero : ∀ x : α, succ x ≠ 0)\n(succ_ne_omega : ∀ x : α, succ x ≠ omega)\n(lt_succ : ∀ x : α, x < succ x)\n(le_of_lt_succ : ∀ {x y : α}, x < succ y → x ≤ y)\n(add_zero : ∀ x : α, x + 0 = x)\n(add_limit_le : ∀ {x y z : α}, y ≠ 0 → (∀ w : α, w < y → x + w < z) → x + y ≤ z)\n(add_limit_gt : ∀ {x y z u : α}, u < y → x + u < z → x + y ≤ z)\n(add_lt_add_left : ∀ {x y : α}, x < y → ∀ z, z + x < z + y)\n(mul_zero : ∀ x : α, x * 0 = 0)\n(mul_succ : ∀ x y : α, x * succ y = x * y + x)\n(mul_limit : ∀ {x y z : α}, y ≠ 0 → (∀ w : α, w < y → x * y < z) → x * y ≤ z)\n(transfinite_induction : ∀ (x: α) (φ : α → Prop), (∀ y : α, (∀ z : α, z < y → φ z) → φ y) → φ x)\n\nlemma lt_of_lt_of_lt {α : Type u} [preorder α] :\n∀ {a b c : α}, a < b → b < c → a < c\n| a b c hab hbc := lt_of_lt_of_le hab $ le_of_lt hbc\n\nnamespace ordinal\n\nvariables {α : Type u} [ordinal α] {x y z u : α}\n\ndef ω := omega α\n\ninstance : has_one α := ⟨succ 0⟩\n\ntheorem lt_succ_of_le : x ≤ y → x < succ y\n| hxy := lt_of_le_of_lt hxy $ lt_succ y\n\ntheorem le_iff_lt_succ : x ≤ y ↔ x < succ y :=\n⟨lt_succ_of_le, le_of_lt_succ⟩\n\ntheorem lt_of_succ_le : succ y ≤ x → y < x\n| hyx := lt_of_lt_of_le (lt_succ y) hyx\n\ntheorem succ_le_of_lt : y < x → succ y ≤ x\n| hyx := le_of_not_gt $ λ hxy, not_le_of_gt hyx $ le_of_lt_succ hxy\n\ntheorem lt_iff_succ_le : y < x ↔ succ y ≤ x :=\n⟨succ_le_of_lt, lt_of_succ_le⟩\n\ntheorem succ_lt : x < y → succ x < succ y\n| hxy := lt_succ_of_le $ succ_le_of_lt hxy\n\ntheorem succ_le : x ≤ y → succ x ≤ succ y\n| hxy := succ_le_of_lt $ lt_succ_of_le hxy\n\ntheorem lt_of_succ_lt : succ x < succ y → x < y\n| hxy := lt_of_succ_le $ le_of_lt_succ hxy\n\ntheorem le_of_succ_le : succ x ≤ succ y → x ≤ y\n| hxy := le_of_lt_succ $ lt_of_succ_le hxy\n\ntheorem succ_inj : succ x = succ y → x = y\n| hxy := le_antisymm\n         (le_of_succ_le $ le_of_eq hxy)\n         (le_of_succ_le $ le_of_eq hxy.symm)\n\ntheorem succ_lt_of_lt_of_limit : (∀ w, succ w ≠ x) → y < x → succ y < x\n| hx hyx := lt_of_le_of_ne (le_of_lt_succ $ succ_lt hyx) $ hx y\n\ntheorem add_succ : x + succ y = succ (x + y) :=\nbegin\n  apply transfinite_induction y,\n  intros z hy,\n  apply le_antisymm,\n  apply add_limit_le,\n  exact succ_ne_zero z,\n  intros w hwz,\n  cases lt_or_eq_of_le (le_of_lt_succ hwz),\n  apply lt_of_lt_of_lt (add_lt_add_left a x),\n  apply lt_succ,\n  rw a,\n  apply lt_succ,\n  apply le_of_lt_succ,\n  apply succ_lt,\n  apply add_lt_add_left,\n  exact lt_succ z\nend\n\ntheorem add_le_add_right : x < y → x + z ≤ y + z :=\nbegin\n  intro hxy,\n  apply transfinite_induction z,\n  intros z' hz',\n  cases decidable_linear_order.decidable_eq α z' 0,\n  apply add_limit_le a,\n  intros w hwz',\n  apply lt_of_le_of_lt,\n  exact hz' w hwz',\n  exact add_lt_add_left hwz' y,\n  rw [a,add_zero,add_zero],\n  exact le_of_lt hxy\nend\n\ntheorem zero_add : 0 + x = x :=\nbegin\n  apply transfinite_induction x,\n  intros y hy,\n  cases decidable_linear_order.decidable_eq α y 0,\n  apply le_antisymm,\n  apply add_limit_le,\n  exact a,\n  intros w hwy,\n  rw hy w, exact hwy, exact hwy,\n  apply le_of_not_gt,\n  intro hy2,\n  apply ne_of_lt (add_lt_add_left hy2 0),\n  apply hy _ hy2,\n  rw a, exact add_zero 0\nend\n\ntheorem one_add : x ≤ 1 + x :=\n@transfinite_induction α _ x (λ x, x ≤ 1 + x) $ λ y hy,\nle_of_not_gt $ λ hy2, not_le_of_gt (add_lt_add_left hy2 1) (hy _ hy2)\n\ntheorem one_add_eq_succ_of_lt_omega : x < ω → 1 + x = succ x :=\nbegin\n  apply transfinite_induction x (λ x, x < ω → 1 + x = succ x),\n  intros y hy,\n  intro hyω,\n  cases zero_or_succ_of_lt_omega _ hyω,\n  rw [a,add_zero], unfold has_one.one,\n  cases a,\n  rw [a_1,add_succ],\n  apply congr_arg,\n  apply hy,\n  rw a_1,\n  apply lt_succ,\n  apply lt_of_lt_of_lt,\n  apply lt_succ,\n  rw ←a_1,\n  exact hyω\nend\n\ntheorem one_add_omega : (1:α) + ω = ω :=\nbegin\n  apply le_antisymm,\n  apply add_limit_le,\n  apply ne_of_gt,\n  exact zero_lt_omega α,\n  intro w,\n  apply transfinite_induction w (λ w, w < ω → 1 + w < ω),\n  intros y hy hyω,\n  cases zero_or_succ_of_lt_omega _ hyω,\n  rw [a,add_zero],\n  apply succ_lt_of_lt_of_limit succ_ne_omega,\n  apply zero_lt_omega α,\n  cases a,\n  rw [a_1,add_succ],\n  apply succ_lt_of_lt_of_limit succ_ne_omega,\n  rw one_add_eq_succ_of_lt_omega,\n  rw ←a_1, apply hyω,\n  apply lt_of_lt_of_lt,\n  apply lt_succ,\n  rw ←a_1,\n  exact hyω,\n  apply one_add\nend\n\nend ordinal\n", "meta": {"author": "kckennylau", "repo": "Lean", "sha": "907d0a4d2bd8f23785abd6142ad53d308c54fdcb", "save_path": "github-repos/lean/kckennylau-Lean", "path": "github-repos/lean/kckennylau-Lean/Lean-907d0a4d2bd8f23785abd6142ad53d308c54fdcb/ordinal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672089305841, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4880175112632648}}
{"text": "import category_theory.category.default\nimport game.world1.level4\n\nuniverses v u  -- The order in this declaration matters: v often needs to be explicitly specified while u often can be omitted\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/-\n# Category world\n\n## Level 5: More tactic reviews\n-/\n\n/-blah blah\n\n-/\n\n/- Lemma\nIf $$f : X ⟶ Y$$ and $$g : X ⟶ Y$$ are morphisms such that $$f = g$$, then $$f ≫ h = g ≫ h$$.\n-/\nlemma id_of_comp_right_id' (X : C) (f : X ⟶ X) (w : ∀ {Y : C} (g : Y ⟶ X), g ≫ f = g) : f = 𝟙 X :=\nbegin\n    apply eq_of_comp_right_eq'',\n    intros Z h,\n    rw category.comp_id h,\n    apply w,\nend\n\nend category_theory", "meta": {"author": "agusakov", "repo": "category-theory-game", "sha": "652dd7e90ae706643b2a597e2c938403653e167d", "save_path": "github-repos/lean/agusakov-category-theory-game", "path": "github-repos/lean/agusakov-category-theory-game/category-theory-game-652dd7e90ae706643b2a597e2c938403653e167d/src/game/world1/level6.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.48801750847178366}}
{"text": "import analysis.normed_space.exponential\nimport analysis.specific_limits.normed\nimport analysis.special_functions.exponential\nimport data.complex.exponential\nimport probability.probability_mass_function.basic\n\nnamespace pmf\n\nnoncomputable theory\n\nopen nat\nopen_locale classical big_operators nnreal ennreal\n\ndef bernoulli (p : ℝ≥0∞) (h : p ≤ 1) : pmf bool :=\n⟨λ b, cond b p (1 - p), by simp [summable.has_sum_iff, tsum_bool, add_comm, h]⟩\n\nexample (f : ℝ → ℝ) (h : ∀ a, 0 ≤ f a) (h' : summable (λ (a : ℝ), f a)):\n∑' (a : ℝ), ennreal.of_real (f a) = ennreal.of_real ∑' (a : ℝ), f a :=\nbegin\n  exact (ennreal.of_real_tsum_of_nonneg h h').symm,\nend\n\nexample {l : ℝ} : ∑' (n : ℕ), l ^ n / ↑(n.factorial) = real.exp l :=\nbegin\n  rw [real.exp_eq_exp_ℝ, exp_eq_tsum_div],\nend\n\ndef poisson (l : ℝ) (h : 0 < l) : pmf ℕ :=\n⟨ λ k, ennreal.of_real $ (real.exp $ -l) * ((l : ℝ) ^ k) / factorial k,\n  by { simp [summable.has_sum_iff],\n    rw ← ennreal.of_real_tsum_of_nonneg,\n    { rw [show 1 = ennreal.of_real (real.exp (-l) * real.exp l),\n          by rw [real.exp_eq_exp_ℝ, ← exp_add, neg_add_self, exp_zero, ennreal.of_real_one]],\n      congr,\n      suffices : ∑' (n : ℕ), (λ k, l ^ k / ↑(factorial k)) n * real.exp (-l)\n                 = real.exp (-l) * real.exp l,\n      { rw ← this, congr, funext, ring_nf, },\n      rw [mul_comm],\n      simp_rw [← smul_eq_mul],\n      rw [tsum_smul_const, real.exp_eq_exp_ℝ, exp_eq_tsum_div],\n      exact exp_series_div_summable ℝ l, },\n    { intro n,\n      apply div_nonneg,\n      apply mul_nonneg,\n      exact le_of_lt (real.exp_pos _),\n      exact pow_nonneg (le_of_lt h) n,\n      rw ← cast_zero,\n      exact cast_le.2 (le_of_lt (factorial_pos n)), },\n    { have : summable (λ (n : ℕ), real.exp (-l) • (λ i, l ^ i / ↑(factorial i)) n),\n      { apply summable.const_smul, simp [real.summable_pow_div_factorial l], },\n      simp at this,\n      simp_rw [← mul_div, this], }, }⟩\n\nend pmf", "meta": {"author": "grhkm21", "repo": "lean", "sha": "52fe0ba1b5c78344c640b0813f11db71338fcba2", "save_path": "github-repos/lean/grhkm21-lean", "path": "github-repos/lean/grhkm21-lean/lean-52fe0ba1b5c78344c640b0813f11db71338fcba2/sketch/pmf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867873410141, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.48799701310186816}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport topology.sheaves.sheaf_condition.sites\nimport category_theory.sites.limits\nimport category_theory.adjunction\nimport category_theory.limits.functor_category\n\n/-!\n# Presheaves in `C` have limits and colimits when `C` does.\n-/\n\nnoncomputable theory\n\nuniverses v u\n\nopen category_theory\nopen category_theory.limits\n\nvariables {C : Type u} [category.{v} C] {J : Type v} [small_category J]\n\nnamespace Top\n\ninstance [has_limits C] (X : Top) : has_limits (presheaf C X) :=\nlimits.functor_category_has_limits_of_size.{v v}\n\ninstance [has_colimits C] (X : Top) : has_colimits_of_size.{v} (presheaf C X) :=\nlimits.functor_category_has_colimits_of_size\n\ninstance [has_limits C] (X : Top) : creates_limits (sheaf.forget C X) :=\n(@@creates_limits_of_nat_iso _ _\n  (presheaf.Sheaf_spaces_equiv_sheaf_sites_inverse_forget C X))\n  (@@category_theory.comp_creates_limits _ _ _ _ _ _\n    Sheaf.category_theory.Sheaf_to_presheaf.category_theory.creates_limits.{u v v})\n\n\ninstance [has_limits C] (X : Top) : has_limits_of_size.{v} (sheaf.{v} C X) :=\nhas_limits_of_has_limits_creates_limits (sheaf.forget C X)\n\nlemma is_sheaf_of_is_limit [has_limits C] {X : Top} (F : J ⥤ presheaf.{v} C X)\n  (H : ∀ j, (F.obj j).is_sheaf) {c : cone F} (hc : is_limit c) : c.X.is_sheaf :=\nbegin\n  let F' : J ⥤ sheaf C X := { obj := λ j, ⟨F.obj j, H j⟩, map := F.map },\n  let e : F' ⋙ sheaf.forget C X ≅ F := nat_iso.of_components (λ _, iso.refl _) (by tidy),\n  exact presheaf.is_sheaf_of_iso ((is_limit_of_preserves (sheaf.forget C X)\n      (limit.is_limit F')).cone_points_iso_of_nat_iso hc e) (limit F').2\nend\n\nlemma limit_is_sheaf [has_limits C] {X : Top} (F : J ⥤ presheaf.{v} C X)\n  (H : ∀ j, (F.obj j).is_sheaf) : (limit F).is_sheaf :=\nis_sheaf_of_is_limit F H (limit.is_limit F)\n\nend Top\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/topology/sheaves/limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867825403177, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.48799701016680885}}
{"text": "import defs.dynamics\nimport defs.statics\n\ntheorem bool_canonical_forms\n  {Γ: env} {e: exp} (value: val e)\n  (et: has_typ Γ e typ.bool)\n  : e = exp.true ∨ e = exp.false :=\nbegin\n  cases value,\n  repeat {cases et},\n  left,\n  refl,\n  right,\n  refl,\nend\n\ntheorem arrow_canonical_forms\n  {Γ: env} {e: exp} {τ1 τ2: typ} (value: val e)\n  (et: has_typ Γ e (typ.arrow τ1 τ2))\n  : ∃ (x: var) (e': exp), e = exp.fn x τ1 e' :=\nbegin\n  cases value,\n  repeat {cases et},\n  existsi [value_x, value_e],\n  refl,\nend\n\ntheorem pair_canonical_forms\n  {Γ: env} {e: exp} {τ1 τ2: typ} (value: val e)\n  (et: has_typ Γ e (typ.pair τ1 τ2))\n  : ∃ (e1 e2: exp), e = exp.pair e1 e2 :=\nbegin\n  cases value,\n  repeat {cases et},\n  existsi [value_e1, value_e2],\n  refl,\nend\n\ntheorem never_canonical_forms\n  {Γ: env} {e: exp} (value: val e)\n  (et: has_typ Γ e typ.never)\n  : false :=\nbegin\n  cases value,\n  repeat {cases et},\nend\n\ntheorem either_canonical_forms\n  {Γ: env} {e: exp} {τ1 τ2: typ} (value: val e)\n  (et: has_typ Γ e (typ.either τ1 τ2))\n  : ∃ (e': exp), (e = exp.either_left τ2 e') ∨ (e = exp.either_right τ1 e') :=\nbegin\n  cases value,\n  repeat {cases et},\n  existsi value_e,\n  left,\n  refl,\n  existsi value_e,\n  right,\n  refl,\nend\n", "meta": {"author": "azdavis", "repo": "hatsugen", "sha": "a18f70f9ea4ce30c0baf0c40748aad5ccd176c60", "save_path": "github-repos/lean/azdavis-hatsugen", "path": "github-repos/lean/azdavis-hatsugen/hatsugen-a18f70f9ea4ce30c0baf0c40748aad5ccd176c60/src/lemmas/canonical_forms.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867681382279, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4879970013616308}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.list.perm\nimport data.list.prod_monoid\n\n/-!\n# Multisets\nThese are implemented as the quotient of a list by permutations.\n## Notation\nWe define the global infix notation `::ₘ` for `multiset.cons`.\n-/\n\nopen list subtype nat\n\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\n/-- `multiset α` is the quotient of `list α` by list permutation. The result\n  is a type of finite sets with duplicates allowed.  -/\ndef {u} multiset (α : Type u) : Type u :=\nquotient (list.is_setoid α)\n\nnamespace multiset\n\ninstance : has_coe (list α) (multiset α) := ⟨quot.mk _⟩\n\n@[simp] theorem quot_mk_to_coe (l : list α) : @eq (multiset α) ⟦l⟧ l := rfl\n\n@[simp] theorem quot_mk_to_coe' (l : list α) : @eq (multiset α) (quot.mk (≈) l) l := rfl\n\n@[simp] theorem quot_mk_to_coe'' (l : list α) : @eq (multiset α) (quot.mk setoid.r l) l := rfl\n\n@[simp] theorem coe_eq_coe {l₁ l₂ : list α} : (l₁ : multiset α) = l₂ ↔ l₁ ~ l₂ := quotient.eq\n\ninstance has_decidable_eq [decidable_eq α] : decidable_eq (multiset α)\n| s₁ s₂ := quotient.rec_on_subsingleton₂ s₁ s₂ $ λ l₁ l₂,\n  decidable_of_iff' _ quotient.eq\n\n/-- defines a size for a multiset by referring to the size of the underlying list -/\nprotected def sizeof [has_sizeof α] (s : multiset α) : ℕ :=\nquot.lift_on s sizeof $ λ l₁ l₂, perm.sizeof_eq_sizeof\n\ninstance has_sizeof [has_sizeof α] : has_sizeof (multiset α) := ⟨multiset.sizeof⟩\n\n/-! ### Empty multiset -/\n\n/-- `0 : multiset α` is the empty set -/\nprotected def zero : multiset α := @nil α\n\ninstance : has_zero (multiset α)   := ⟨multiset.zero⟩\ninstance : has_emptyc (multiset α) := ⟨0⟩\ninstance inhabited_multiset : inhabited (multiset α)  := ⟨0⟩\n\n@[simp] theorem coe_nil_eq_zero : (@nil α : multiset α) = 0 := rfl\n@[simp] theorem empty_eq_zero : (∅ : multiset α) = 0 := rfl\n\ntheorem coe_eq_zero (l : list α) : (l : multiset α) = 0 ↔ l = [] :=\niff.trans coe_eq_coe perm_nil\n\n/-! ### `multiset.cons` -/\n\n/-- `cons a s` is the multiset which contains `s` plus one more\n  instance of `a`. -/\ndef cons (a : α) (s : multiset α) : multiset α :=\nquot.lift_on s (λ l, (a :: l : multiset α))\n  (λ l₁ l₂ p, quot.sound (p.cons a))\n\ninfixr ` ::ₘ `:67  := multiset.cons\n\ninstance : has_insert α (multiset α) := ⟨cons⟩\n\n@[simp] theorem insert_eq_cons (a : α) (s : multiset α) :\n  insert a s = a ::ₘ s := rfl\n\n@[simp] theorem cons_coe (a : α) (l : list α) :\n  (a ::ₘ l : multiset α) = (a::l : list α) := rfl\n\ntheorem singleton_coe (a : α) : (a ::ₘ 0 : multiset α) = ([a] : list α) := rfl\n\n@[simp] theorem cons_inj_left {a b : α} (s : multiset α) :\n  a ::ₘ s = b ::ₘ s ↔ a = b :=\n⟨quot.induction_on s $ λ l e,\n  have [a] ++ l ~ [b] ++ l, from quotient.exact e,\n  singleton_perm_singleton.1 $ (perm_append_right_iff _).1 this, congr_arg _⟩\n\n@[simp] theorem cons_inj_right (a : α) : ∀{s t : multiset α}, a ::ₘ s = a ::ₘ t ↔ s = t :=\nby rintros ⟨l₁⟩ ⟨l₂⟩; simp\n\n@[recursor 5] protected theorem induction {p : multiset α → Prop}\n  (h₁ : p 0) (h₂ : ∀ ⦃a : α⦄ {s : multiset α}, p s → p (a ::ₘ s)) : ∀s, p s :=\nby rintros ⟨l⟩; induction l with _ _ ih; [exact h₁, exact h₂ ih]\n\n@[elab_as_eliminator] protected theorem induction_on {p : multiset α → Prop}\n  (s : multiset α) (h₁ : p 0) (h₂ : ∀ ⦃a : α⦄ {s : multiset α}, p s → p (a ::ₘ s)) : p s :=\nmultiset.induction h₁ h₂ s\n\ntheorem cons_swap (a b : α) (s : multiset α) : a ::ₘ b ::ₘ s = b ::ₘ a ::ₘ s :=\nquot.induction_on s $ λ l, quotient.sound $ perm.swap _ _ _\n\nsection rec\nvariables {C : multiset α → Sort*}\n\n/-- Dependent recursor on multisets.\nTODO: should be @[recursor 6], but then the definition of `multiset.pi` fails with a stack\noverflow in `whnf`.\n-/\nprotected def rec\n  (C_0 : C 0)\n  (C_cons : Πa m, C m → C (a ::ₘ m))\n  (C_cons_heq : ∀ a a' m b, C_cons a (a' ::ₘ m) (C_cons a' m b) ==\n    C_cons a' (a ::ₘ m) (C_cons a m b))\n  (m : multiset α) : C m :=\nquotient.hrec_on m (@list.rec α (λl, C ⟦l⟧) C_0 (λa l b, C_cons a ⟦l⟧ b)) $\n  assume l l' h,\n  h.rec_heq\n    (assume a l l' b b' hl, have ⟦l⟧ = ⟦l'⟧, from quot.sound hl, by cc)\n    (assume a a' l, C_cons_heq a a' ⟦l⟧)\n\n/-- Companion to `multiset.rec` with more convenient argument order. -/\n@[elab_as_eliminator]\nprotected def rec_on (m : multiset α)\n  (C_0 : C 0)\n  (C_cons : Πa m, C m → C (a ::ₘ m))\n  (C_cons_heq : ∀a a' m b, C_cons a (a' ::ₘ m) (C_cons a' m b) ==\n      C_cons a' (a ::ₘ m) (C_cons a m b)) :\n  C m :=\nmultiset.rec C_0 C_cons C_cons_heq m\n\nvariables {C_0 : C 0} {C_cons : Πa m, C m → C (a ::ₘ m)}\n  {C_cons_heq : ∀a a' m b, C_cons a (a' ::ₘ m) (C_cons a' m b) ==\n    C_cons a' (a ::ₘ m) (C_cons a m b)}\n\n@[simp] lemma rec_on_0 : @multiset.rec_on α C (0:multiset α) C_0 C_cons C_cons_heq = C_0 :=\nrfl\n\n@[simp] lemma rec_on_cons (a : α) (m : multiset α) :\n  (a ::ₘ m).rec_on C_0 C_cons C_cons_heq = C_cons a m (m.rec_on C_0 C_cons C_cons_heq) :=\nquotient.induction_on m $ assume l, rfl\n\nend rec\n\nsection mem\n\n/-- `a ∈ s` means that `a` has nonzero multiplicity in `s`. -/\ndef mem (a : α) (s : multiset α) : Prop :=\nquot.lift_on s (λ l, a ∈ l) (λ l₁ l₂ (e : l₁ ~ l₂), propext $ e.mem_iff)\n\ninstance : has_mem α (multiset α) := ⟨mem⟩\n\n@[simp] lemma mem_coe {a : α} {l : list α} : a ∈ (l : multiset α) ↔ a ∈ l := iff.rfl\n\ninstance decidable_mem [decidable_eq α] (a : α) (s : multiset α) : decidable (a ∈ s) :=\nquot.rec_on_subsingleton s $ list.decidable_mem a\n\n@[simp] theorem mem_cons {a b : α} {s : multiset α} : a ∈ b ::ₘ s ↔ a = b ∨ a ∈ s :=\nquot.induction_on s $ λ l, iff.rfl\n\nlemma mem_cons_of_mem {a b : α} {s : multiset α} (h : a ∈ s) : a ∈ b ::ₘ s :=\nmem_cons.2 $ or.inr h\n\n@[simp] theorem mem_cons_self (a : α) (s : multiset α) : a ∈ a ::ₘ s :=\nmem_cons.2 (or.inl rfl)\n\ntheorem forall_mem_cons {p : α → Prop} {a : α} {s : multiset α} :\n  (∀ x ∈ (a ::ₘ s), p x) ↔ p a ∧ ∀ x ∈ s, p x :=\nquotient.induction_on' s $ λ L, list.forall_mem_cons\n\ntheorem exists_cons_of_mem {s : multiset α} {a : α} : a ∈ s → ∃ t, s = a ::ₘ t :=\nquot.induction_on s $ λ l (h : a ∈ l),\nlet ⟨l₁, l₂, e⟩ := mem_split h in\ne.symm ▸ ⟨(l₁++l₂ : list α), quot.sound perm_middle⟩\n\n@[simp] theorem not_mem_zero (a : α) : a ∉ (0 : multiset α) := id\n\ntheorem eq_zero_of_forall_not_mem {s : multiset α} : (∀x, x ∉ s) → s = 0 :=\nquot.induction_on s $ λ l H, by rw eq_nil_iff_forall_not_mem.mpr H; refl\n\ntheorem eq_zero_iff_forall_not_mem {s : multiset α} : s = 0 ↔ ∀ a, a ∉ s :=\n⟨λ h, h.symm ▸ λ _, not_false, eq_zero_of_forall_not_mem⟩\n\ntheorem exists_mem_of_ne_zero {s : multiset α} : s ≠ 0 → ∃ a : α, a ∈ s :=\nquot.induction_on s $ assume l hl,\n  match l, hl with\n  | [] := assume h, false.elim $ h rfl\n  | (a :: l) := assume _, ⟨a, by simp⟩\n  end\n\n@[simp] lemma zero_ne_cons {a : α} {m : multiset α} : 0 ≠ a ::ₘ m :=\nassume h, have a ∈ (0:multiset α), from h.symm ▸ mem_cons_self _ _, not_mem_zero _ this\n\n@[simp] lemma cons_ne_zero {a : α} {m : multiset α} : a ::ₘ m ≠ 0 := zero_ne_cons.symm\n\nlemma cons_eq_cons {a b : α} {as bs : multiset α} :\n  a ::ₘ as = b ::ₘ bs ↔ ((a = b ∧ as = bs) ∨ (a ≠ b ∧ ∃cs, as = b ::ₘ cs ∧ bs = a ::ₘ cs)) :=\nbegin\n  haveI : decidable_eq α := classical.dec_eq α,\n  split,\n  { assume eq,\n    by_cases a = b,\n    { subst h, simp * at * },\n    { have : a ∈ b ::ₘ bs, from eq ▸ mem_cons_self _ _,\n      have : a ∈ bs, by simpa [h],\n      rcases exists_cons_of_mem this with ⟨cs, hcs⟩,\n      simp [h, hcs],\n      have : a ::ₘ as = b ::ₘ a ::ₘ cs, by simp [eq, hcs],\n      have : a ::ₘ as = a ::ₘ b ::ₘ cs, by rwa [cons_swap],\n      simpa using this } },\n  { assume h,\n    rcases h with ⟨eq₁, eq₂⟩ | ⟨h, cs, eq₁, eq₂⟩,\n    { simp * },\n    { simp [*, cons_swap a b] } }\nend\n\nend mem\n\n/-! ### `multiset.subset` -/\nsection subset\n\n/-- `s ⊆ t` is the lift of the list subset relation. It means that any\n  element with nonzero multiplicity in `s` has nonzero multiplicity in `t`,\n  but it does not imply that the multiplicity of `a` in `s` is less or equal than in `t`;\n  see `s ≤ t` for this relation. -/\nprotected def subset (s t : multiset α) : Prop := ∀ ⦃a : α⦄, a ∈ s → a ∈ t\n\ninstance : has_subset (multiset α) := ⟨multiset.subset⟩\n\n@[simp] theorem coe_subset {l₁ l₂ : list α} : (l₁ : multiset α) ⊆ l₂ ↔ l₁ ⊆ l₂ := iff.rfl\n\n@[simp] theorem subset.refl (s : multiset α) : s ⊆ s := λ a h, h\n\ntheorem subset.trans {s t u : multiset α} : s ⊆ t → t ⊆ u → s ⊆ u :=\nλ h₁ h₂ a m, h₂ (h₁ m)\n\ntheorem subset_iff {s t : multiset α} : s ⊆ t ↔ (∀⦃x⦄, x ∈ s → x ∈ t) := iff.rfl\n\ntheorem mem_of_subset {s t : multiset α} {a : α} (h : s ⊆ t) : a ∈ s → a ∈ t := @h _\n\n@[simp] theorem zero_subset (s : multiset α) : 0 ⊆ s :=\nλ a, (not_mem_nil a).elim\n\n@[simp] theorem cons_subset {a : α} {s t : multiset α} : (a ::ₘ s) ⊆ t ↔ a ∈ t ∧ s ⊆ t :=\nby simp [subset_iff, or_imp_distrib, forall_and_distrib]\n\ntheorem eq_zero_of_subset_zero {s : multiset α} (h : s ⊆ 0) : s = 0 :=\neq_zero_of_forall_not_mem h\n\ntheorem subset_zero {s : multiset α} : s ⊆ 0 ↔ s = 0 :=\n⟨eq_zero_of_subset_zero, λ xeq, xeq.symm ▸ subset.refl 0⟩\n\nlemma induction_on' {p : multiset α → Prop} (S : multiset α)\n  (h₁ : p ∅) (h₂ : ∀ {a s}, a ∈ S → s ⊆ S → p s → p (insert a s)) : p S :=\n@multiset.induction_on α (λ T, T ⊆ S → p T) S (λ _, h₁) (λ a s hps hs,\n  let ⟨hS, sS⟩ := cons_subset.1 hs in h₂ hS sS (hps sS)) (subset.refl S)\n\nend subset\n\nsection to_list\n\n/-- Produces a list of the elements in the multiset using choice. -/\n@[reducible] noncomputable def to_list {α : Type*} (s : multiset α) :=\nclassical.some (quotient.exists_rep s)\n\n@[simp] lemma to_list_zero {α : Type*} : (multiset.to_list 0 : list α) = [] :=\n(multiset.coe_eq_zero _).1 (classical.some_spec (quotient.exists_rep multiset.zero))\n\n@[simp, norm_cast]\nlemma coe_to_list {α : Type*} (s : multiset α) : (s.to_list : multiset α) = s :=\nclassical.some_spec (quotient.exists_rep _)\n\n@[simp]\nlemma mem_to_list {α : Type*} (a : α) (s : multiset α) : a ∈ s.to_list ↔ a ∈ s :=\nby rw [←multiset.mem_coe, multiset.coe_to_list]\n\nend to_list\n\n/-! ### Partial order on `multiset`s -/\n\n/-- `s ≤ t` means that `s` is a sublist of `t` (up to permutation).\n  Equivalently, `s ≤ t` means that `count a s ≤ count a t` for all `a`. -/\nprotected def le (s t : multiset α) : Prop :=\nquotient.lift_on₂ s t (<+~) $ λ v₁ v₂ w₁ w₂ p₁ p₂,\n  propext (p₂.subperm_left.trans p₁.subperm_right)\n\ninstance : partial_order (multiset α) :=\n{ le          := multiset.le,\n  le_refl     := by rintros ⟨l⟩; exact subperm.refl _,\n  le_trans    := by rintros ⟨l₁⟩ ⟨l₂⟩ ⟨l₃⟩; exact @subperm.trans _ _ _ _,\n  le_antisymm := by rintros ⟨l₁⟩ ⟨l₂⟩ h₁ h₂; exact quot.sound (subperm.antisymm h₁ h₂) }\n\ntheorem subset_of_le {s t : multiset α} : s ≤ t → s ⊆ t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, subperm.subset\n\ntheorem mem_of_le {s t : multiset α} {a : α} (h : s ≤ t) : a ∈ s → a ∈ t :=\nmem_of_subset (subset_of_le h)\n\n@[simp] theorem coe_le {l₁ l₂ : list α} : (l₁ : multiset α) ≤ l₂ ↔ l₁ <+~ l₂ := iff.rfl\n\n@[elab_as_eliminator] theorem le_induction_on {C : multiset α → multiset α → Prop}\n  {s t : multiset α} (h : s ≤ t)\n  (H : ∀ {l₁ l₂ : list α}, l₁ <+ l₂ → C l₁ l₂) : C s t :=\nquotient.induction_on₂ s t (λ l₁ l₂ ⟨l, p, s⟩,\n  (show ⟦l⟧ = ⟦l₁⟧, from quot.sound p) ▸ H s) h\n\ntheorem zero_le (s : multiset α) : 0 ≤ s :=\nquot.induction_on s $ λ l, (nil_sublist l).subperm\n\ntheorem le_zero {s : multiset α} : s ≤ 0 ↔ s = 0 :=\n⟨λ h, le_antisymm h (zero_le _), le_of_eq⟩\n\ntheorem lt_cons_self (s : multiset α) (a : α) : s < a ::ₘ s :=\nquot.induction_on s $ λ l,\nsuffices l <+~ a :: l ∧ (¬l ~ a :: l),\n  by simpa [lt_iff_le_and_ne],\n⟨(sublist_cons _ _).subperm,\n λ p, ne_of_lt (lt_succ_self (length l)) p.length_eq⟩\n\ntheorem le_cons_self (s : multiset α) (a : α) : s ≤ a ::ₘ s :=\nle_of_lt $ lt_cons_self _ _\n\ntheorem cons_le_cons_iff (a : α) {s t : multiset α} : a ::ₘ s ≤ a ::ₘ t ↔ s ≤ t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, subperm_cons a\n\ntheorem cons_le_cons (a : α) {s t : multiset α} : s ≤ t → a ::ₘ s ≤ a ::ₘ t :=\n(cons_le_cons_iff a).2\n\ntheorem le_cons_of_not_mem {a : α} {s t : multiset α} (m : a ∉ s) : s ≤ a ::ₘ t ↔ s ≤ t :=\nbegin\n  refine ⟨_, λ h, le_trans h $ le_cons_self _ _⟩,\n  suffices : ∀ {t'} (_ : s ≤ t') (_ : a ∈ t'), a ::ₘ s ≤ t',\n  { exact λ h, (cons_le_cons_iff a).1 (this h (mem_cons_self _ _)) },\n  introv h, revert m, refine le_induction_on h _,\n  introv s m₁ m₂,\n  rcases mem_split m₂ with ⟨r₁, r₂, rfl⟩,\n  exact perm_middle.subperm_left.2 ((subperm_cons _).2 $\n    ((sublist_or_mem_of_sublist s).resolve_right m₁).subperm)\nend\n\n/-! ### Singleton -/\ninstance : has_singleton α (multiset α) := ⟨λ a, a ::ₘ 0⟩\n\ninstance : is_lawful_singleton α (multiset α) := ⟨λ a, rfl⟩\n\ntheorem singleton_eq_cons (a : α) : singleton a = a ::ₘ 0 := rfl\n\n@[simp] theorem mem_singleton {a b : α} : b ∈ ({a} : multiset α) ↔ b = a :=\nby simp only [singleton_eq_cons, mem_cons, iff_self, or_false, not_mem_zero]\n\ntheorem mem_singleton_self (a : α) : a ∈ ({a} : multiset α) :=\nby { rw singleton_eq_cons, exact mem_cons_self _ _ }\n\ntheorem singleton_inj {a b : α} : ({a} : multiset α) = {b} ↔ a = b :=\nby { simp_rw [singleton_eq_cons], exact cons_inj_left _ }\n\n@[simp] theorem singleton_ne_zero (a : α) : ({a} : multiset α) ≠ 0 :=\nne_of_gt (lt_cons_self _ _)\n\n@[simp] theorem singleton_le {a : α} {s : multiset α} : {a} ≤ s ↔ a ∈ s :=\n⟨λ h, mem_of_le h (mem_singleton_self _),\n λ h, let ⟨t, e⟩ := exists_cons_of_mem h in e.symm ▸ cons_le_cons _ (zero_le _)⟩\n\n/-! ### Additive monoid -/\n\n/-- The sum of two multisets is the lift of the list append operation.\n  This adds the multiplicities of each element,\n  i.e. `count a (s + t) = count a s + count a t`. -/\nprotected def add (s₁ s₂ : multiset α) : multiset α :=\nquotient.lift_on₂ s₁ s₂ (λ l₁ l₂, ((l₁ ++ l₂ : list α) : multiset α)) $\n  λ v₁ v₂ w₁ w₂ p₁ p₂, quot.sound $ p₁.append p₂\n\ninstance : has_add (multiset α) := ⟨multiset.add⟩\n\n@[simp] theorem coe_add (s t : list α) : (s + t : multiset α) = (s ++ t : list α) := rfl\n\nprotected theorem add_comm (s t : multiset α) : s + t = t + s :=\nquotient.induction_on₂ s t $ λ l₁ l₂, quot.sound perm_append_comm\n\nprotected theorem zero_add (s : multiset α) : 0 + s = s :=\nquot.induction_on s $ λ l, rfl\n\ntheorem singleton_add (a : α) (s : multiset α) : {a} + s = a ::ₘ s := rfl\n\nprotected theorem add_le_add_left (s) {t u : multiset α} : s + t ≤ s + u ↔ t ≤ u :=\nquotient.induction_on₃ s t u $ λ l₁ l₂ l₃, subperm_append_left _\n\nprotected theorem add_left_cancel (s) {t u : multiset α} (h : s + t = s + u) : t = u :=\nle_antisymm ((multiset.add_le_add_left _).1 (le_of_eq h))\n  ((multiset.add_le_add_left _).1 (le_of_eq h.symm))\n\ninstance : ordered_cancel_add_comm_monoid (multiset α) :=\n{ zero                  := 0,\n  add                   := (+),\n  add_comm              := multiset.add_comm,\n  add_assoc             := λ s₁ s₂ s₃, quotient.induction_on₃ s₁ s₂ s₃ $ λ l₁ l₂ l₃,\n    congr_arg coe $ append_assoc l₁ l₂ l₃,\n  zero_add              := multiset.zero_add,\n  add_zero              := λ s, by rw [multiset.add_comm, multiset.zero_add],\n  add_left_cancel       := multiset.add_left_cancel,\n  add_le_add_left       := λ s₁ s₂ h s₃, (multiset.add_le_add_left _).2 h,\n  le_of_add_le_add_left := λ s₁ s₂ s₃, (multiset.add_le_add_left _).1,\n  ..@multiset.partial_order α }\n\ntheorem le_add_right (s t : multiset α) : s ≤ s + t :=\nby simpa using add_le_add_left (zero_le t) s\n\ntheorem le_add_left (s t : multiset α) : s ≤ t + s :=\nby simpa using add_le_add_right (zero_le t) s\ntheorem le_iff_exists_add {s t : multiset α} : s ≤ t ↔ ∃ u, t = s + u :=\n⟨λ h, le_induction_on h $ λ l₁ l₂ s,\n  let ⟨l, p⟩ := s.exists_perm_append in ⟨l, quot.sound p⟩,\n λ ⟨u, e⟩, e.symm ▸ le_add_right _ _⟩\n\ninstance : order_bot (multiset α) :=\n{ bot                   := 0,\n  bot_le                := multiset.zero_le }\n\ninstance : canonically_ordered_add_monoid (multiset α) :=\n{ le_iff_exists_add     := @le_iff_exists_add _,\n  ..multiset.order_bot,\n  ..multiset.ordered_cancel_add_comm_monoid }\n\n@[simp] theorem cons_add (a : α) (s t : multiset α) : a ::ₘ s + t = a ::ₘ (s + t) :=\nby rw [← singleton_add, ← singleton_add, add_assoc]\n\n@[simp] theorem add_cons (a : α) (s t : multiset α) : s + a ::ₘ t = a ::ₘ (s + t) :=\nby rw [add_comm, cons_add, add_comm]\n\n@[simp] theorem mem_add {a : α} {s t : multiset α} : a ∈ s + t ↔ a ∈ s ∨ a ∈ t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, mem_append\n\nlemma mem_of_mem_nsmul {a : α} {s : multiset α} {n : ℕ} (h : a ∈ n • s) : a ∈ s :=\nbegin\n  induction n with n ih,\n  { rw zero_nsmul at h,\n    exact absurd h (not_mem_zero _) },\n  { rw [succ_nsmul, mem_add] at h,\n    exact h.elim id ih },\nend\n\n@[simp]\nlemma mem_nsmul {a : α} {s : multiset α} {n : ℕ} (h0 : n ≠ 0) : a ∈ n • s ↔ a ∈ s :=\nbegin\n  refine ⟨mem_of_mem_nsmul, λ h, _⟩,\n  obtain ⟨n, rfl⟩ := exists_eq_succ_of_ne_zero h0,\n  rw [succ_nsmul, mem_add],\n  exact or.inl h\nend\n\nlemma nsmul_cons {s : multiset α} (n : ℕ) (a : α) : n • (a ::ₘ s) = n • {a} + n • s :=\nby rw [←singleton_add, nsmul_add]\n\n/-! ### Cardinality -/\n\n/-- The cardinality of a multiset is the sum of the multiplicities\n  of all its elements, or simply the length of the underlying list. -/\ndef card : multiset α →+ ℕ :=\n{ to_fun := λ s, quot.lift_on s length $ λ l₁ l₂, perm.length_eq,\n  map_zero' := rfl,\n  map_add' := λ s t, quotient.induction_on₂ s t length_append }\n\n@[simp] theorem coe_card (l : list α) : card (l : multiset α) = length l := rfl\n\n@[simp] theorem card_zero : @card α 0 = 0 := rfl\n\ntheorem card_add (s t : multiset α) : card (s + t) = card s + card t :=\ncard.map_add s t\n\nlemma card_nsmul (s : multiset α) (n : ℕ) :\n  (n • s).card = n * s.card :=\nby rw [card.map_nsmul s n, nat.nsmul_eq_mul]\n\n@[simp] theorem card_cons (a : α) (s : multiset α) : card (a ::ₘ s) = card s + 1 :=\nquot.induction_on s $ λ l, rfl\n\n@[simp] theorem card_singleton (a : α) : card ({a} : multiset α) = 1 :=\nby simp only [singleton_eq_cons, card_zero, eq_self_iff_true, zero_add, card_cons]\n\ntheorem card_eq_one {s : multiset α} : card s = 1 ↔ ∃ a, s = {a} :=\n⟨quot.induction_on s $ λ l h,\n  (list.length_eq_one.1 h).imp $ λ a, congr_arg coe,\n λ ⟨a, e⟩, e.symm ▸ rfl⟩\n\ntheorem card_le_of_le {s t : multiset α} (h : s ≤ t) : card s ≤ card t :=\nle_induction_on h $ λ l₁ l₂, length_le_of_sublist\n\ntheorem eq_of_le_of_card_le {s t : multiset α} (h : s ≤ t) : card t ≤ card s → s = t :=\nle_induction_on h $ λ l₁ l₂ s h₂, congr_arg coe $ eq_of_sublist_of_length_le s h₂\n\ntheorem card_lt_of_lt {s t : multiset α} (h : s < t) : card s < card t :=\nlt_of_not_ge $ λ h₂, ne_of_lt h $ eq_of_le_of_card_le (le_of_lt h) h₂\n\ntheorem lt_iff_cons_le {s t : multiset α} : s < t ↔ ∃ a, a ::ₘ s ≤ t :=\n⟨quotient.induction_on₂ s t $ λ l₁ l₂ h,\n  subperm.exists_of_length_lt (le_of_lt h) (card_lt_of_lt h),\nλ ⟨a, h⟩, lt_of_lt_of_le (lt_cons_self _ _) h⟩\n\n@[simp] theorem card_eq_zero {s : multiset α} : card s = 0 ↔ s = 0 :=\n⟨λ h, (eq_of_le_of_card_le (zero_le _) (le_of_eq h)).symm, λ e, by simp [e]⟩\n\ntheorem card_pos {s : multiset α} : 0 < card s ↔ s ≠ 0 :=\npos_iff_ne_zero.trans $ not_congr card_eq_zero\n\ntheorem card_pos_iff_exists_mem {s : multiset α} : 0 < card s ↔ ∃ a, a ∈ s :=\nquot.induction_on s $ λ l, length_pos_iff_exists_mem\n\nlemma card_eq_two {s : multiset α} : s.card = 2 ↔ ∃ x y, s = {x, y} :=\n⟨quot.induction_on s (λ l h, (list.length_eq_two.mp h).imp\n  (λ a, Exists.imp (λ b, congr_arg coe))), λ ⟨a, b, e⟩, e.symm ▸ rfl⟩\n\nlemma card_eq_three {s : multiset α} : s.card = 3 ↔ ∃ x y z, s = {x, y, z} :=\n⟨quot.induction_on s (λ l h, (list.length_eq_three.mp h).imp\n  (λ a, Exists.imp (λ b, Exists.imp (λ c, congr_arg coe)))), λ ⟨a, b, c, e⟩, e.symm ▸ rfl⟩\n\n/-! ### Induction principles -/\n\n/-- A strong induction principle for multisets:\nIf you construct a value for a particular multiset given values for all strictly smaller multisets,\nyou can construct a value for any multiset.\n-/\n@[elab_as_eliminator] def strong_induction_on {p : multiset α → Sort*} :\n  ∀ (s : multiset α), (∀ s, (∀t < s, p t) → p s) → p s\n| s := λ ih, ih s $ λ t h,\n  have card t < card s, from card_lt_of_lt h,\n  strong_induction_on t ih\nusing_well_founded {rel_tac := λ _ _, `[exact ⟨_, measure_wf card⟩]}\n\ntheorem strong_induction_eq {p : multiset α → Sort*}\n  (s : multiset α) (H) : @strong_induction_on _ p s H =\n    H s (λ t h, @strong_induction_on _ p t H) :=\nby rw [strong_induction_on]\n@[elab_as_eliminator] lemma case_strong_induction_on {p : multiset α → Prop}\n  (s : multiset α) (h₀ : p 0) (h₁ : ∀ a s, (∀t ≤ s, p t) → p (a ::ₘ s)) : p s :=\nmultiset.strong_induction_on s $ assume s,\nmultiset.induction_on s (λ _, h₀) $ λ a s _ ih, h₁ _ _ $\nλ t h, ih _ $ lt_of_le_of_lt h $ lt_cons_self _ _\n\n/-- Suppose that, given that `p t` can be defined on all supersets of `s` of cardinality less than\n`n`, one knows how to define `p s`. Then one can inductively define `p s` for all multisets `s` of\ncardinality less than `n`, starting from multisets of card `n` and iterating. This\ncan be used either to define data, or to prove properties. -/\ndef strong_downward_induction {p : multiset α → Sort*} {n : ℕ} (H : ∀ t₁, (∀ {t₂ : multiset α},\n  t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n → p t₁) :\n  ∀ (s : multiset α), s.card ≤ n → p s\n| s := H s (λ t ht h, have n - card t < n - card s,\n     from (tsub_lt_tsub_iff_left_of_le ht).2 (card_lt_of_lt h),\n  strong_downward_induction t ht)\nusing_well_founded {rel_tac := λ _ _, `[exact ⟨_, measure_wf (λ (t : multiset α), n - t.card)⟩]}\n\nlemma strong_downward_induction_eq {p : multiset α → Sort*} {n : ℕ} (H : ∀ t₁, (∀ {t₂ : multiset α},\n  t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n → p t₁) (s : multiset α) :\n  strong_downward_induction H s = H s (λ t ht hst, strong_downward_induction H t ht) :=\nby rw strong_downward_induction\n\n/-- Analogue of `strong_downward_induction` with order of arguments swapped. -/\n@[elab_as_eliminator] def strong_downward_induction_on {p : multiset α → Sort*} {n : ℕ} :\n  ∀ (s : multiset α), (∀ t₁, (∀ {t₂ : multiset α}, t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n →\n  p t₁) → s.card ≤ n → p s :=\nλ s H, strong_downward_induction H s\n\nlemma strong_downward_induction_on_eq {p : multiset α → Sort*} (s : multiset α) {n : ℕ} (H : ∀ t₁,\n  (∀ {t₂ : multiset α}, t₂.card ≤ n → t₁ < t₂ → p t₂) → t₁.card ≤ n → p t₁) :\n  s.strong_downward_induction_on H = H s (λ t ht h, t.strong_downward_induction_on H ht) :=\nby { dunfold strong_downward_induction_on, rw strong_downward_induction }\n\n/-- Another way of expressing `strong_induction_on`: the `(<)` relation is well-founded. -/\nlemma well_founded_lt : well_founded ((<) : multiset α → multiset α → Prop) :=\nsubrelation.wf (λ _ _, multiset.card_lt_of_lt) (measure_wf multiset.card)\n\n/-! ### `multiset.repeat` -/\n\n/-- `repeat a n` is the multiset containing only `a` with multiplicity `n`. -/\ndef repeat (a : α) (n : ℕ) : multiset α := repeat a n\n\n@[simp] lemma repeat_zero (a : α) : repeat a 0 = 0 := rfl\n\n@[simp] lemma repeat_succ (a : α) (n) : repeat a (n+1) = a ::ₘ repeat a n := by simp [repeat]\n\n@[simp] lemma repeat_one (a : α) : repeat a 1 = {a} :=\nby simp only [repeat_succ, singleton_eq_cons, eq_self_iff_true, repeat_zero, cons_inj_right]\n\n@[simp] lemma card_repeat : ∀ (a : α) n, card (repeat a n) = n := length_repeat\n\ntheorem eq_of_mem_repeat {a b : α} {n} : b ∈ repeat a n → b = a := eq_of_mem_repeat\n\ntheorem eq_repeat' {a : α} {s : multiset α} : s = repeat a s.card ↔ ∀ b ∈ s, b = a :=\nquot.induction_on s $ λ l, iff.trans ⟨λ h,\n  (perm_repeat.1 $ (quotient.exact h)), congr_arg coe⟩ eq_repeat'\n\ntheorem eq_repeat_of_mem {a : α} {s : multiset α} : (∀ b ∈ s, b = a) → s = repeat a s.card :=\neq_repeat'.2\n\ntheorem eq_repeat {a : α} {n} {s : multiset α} : s = repeat a n ↔ card s = n ∧ ∀ b ∈ s, b = a :=\n⟨λ h, h.symm ▸ ⟨card_repeat _ _, λ b, eq_of_mem_repeat⟩,\n λ ⟨e, al⟩, e ▸ eq_repeat_of_mem al⟩\n\ntheorem repeat_injective (a : α) : function.injective (repeat a) :=\nλ m n h, by rw [← (eq_repeat.1 h).1, card_repeat]\n\ntheorem repeat_subset_singleton : ∀ (a : α) n, repeat a n ⊆ {a} := repeat_subset_singleton\n\ntheorem repeat_le_coe {a : α} {n} {l : list α} : repeat a n ≤ l ↔ list.repeat a n <+ l :=\n⟨λ ⟨l', p, s⟩, (perm_repeat.1 p) ▸ s, sublist.subperm⟩\n\ntheorem nsmul_singleton (a : α) (n) : n • ({a} : multiset α) = repeat a n :=\nbegin\n  refine eq_repeat.mpr ⟨_, λ b hb, mem_singleton.mp (mem_of_mem_nsmul hb)⟩,\n  rw [card_nsmul, card_singleton, mul_one]\nend\n\nlemma nsmul_repeat {a : α} (n m : ℕ) : n • (repeat a m) = repeat a (n * m) :=\nbegin\n  rw eq_repeat,\n  split,\n  { rw [card_nsmul, card_repeat] },\n  { exact λ b hb, eq_of_mem_repeat (mem_of_mem_nsmul hb) },\nend\n\n/-! ### Erasing one copy of an element -/\nsection erase\nvariables [decidable_eq α] {s t : multiset α} {a b : α}\n\n/-- `erase s a` is the multiset that subtracts 1 from the\n  multiplicity of `a`. -/\ndef erase (s : multiset α) (a : α) : multiset α :=\nquot.lift_on s (λ l, (l.erase a : multiset α))\n  (λ l₁ l₂ p, quot.sound (p.erase a))\n\n@[simp] theorem coe_erase (l : list α) (a : α) :\n  erase (l : multiset α) a = l.erase a := rfl\n\n@[simp] theorem erase_zero (a : α) : (0 : multiset α).erase a = 0 := rfl\n\n@[simp] theorem erase_cons_head (a : α) (s : multiset α) : (a ::ₘ s).erase a = s :=\nquot.induction_on s $ λ l, congr_arg coe $ erase_cons_head a l\n\n@[simp, priority 990]\ntheorem erase_cons_tail {a b : α} (s : multiset α) (h : b ≠ a) :\n  (b ::ₘ s).erase a = b ::ₘ s.erase a :=\nquot.induction_on s $ λ l, congr_arg coe $ erase_cons_tail l h\n\n@[simp, priority 980]\ntheorem erase_of_not_mem {a : α} {s : multiset α} : a ∉ s → s.erase a = s :=\nquot.induction_on s $ λ l h, congr_arg coe $ erase_of_not_mem h\n\n@[simp, priority 980]\ntheorem cons_erase {s : multiset α} {a : α} : a ∈ s → a ::ₘ s.erase a = s :=\nquot.induction_on s $ λ l h, quot.sound (perm_cons_erase h).symm\n\ntheorem le_cons_erase (s : multiset α) (a : α) : s ≤ a ::ₘ s.erase a :=\nif h : a ∈ s then le_of_eq (cons_erase h).symm\nelse by rw erase_of_not_mem h; apply le_cons_self\n\ntheorem erase_add_left_pos {a : α} {s : multiset α} (t) : a ∈ s → (s + t).erase a = s.erase a + t :=\nquotient.induction_on₂ s t $ λ l₁ l₂ h, congr_arg coe $ erase_append_left l₂ h\n\ntheorem erase_add_right_pos {a : α} (s) {t : multiset α} (h : a ∈ t) :\n  (s + t).erase a = s + t.erase a :=\nby rw [add_comm, erase_add_left_pos s h, add_comm]\n\ntheorem erase_add_right_neg {a : α} {s : multiset α} (t) :\n  a ∉ s → (s + t).erase a = s + t.erase a :=\nquotient.induction_on₂ s t $ λ l₁ l₂ h, congr_arg coe $ erase_append_right l₂ h\n\ntheorem erase_add_left_neg {a : α} (s) {t : multiset α} (h : a ∉ t) :\n  (s + t).erase a = s.erase a + t :=\nby rw [add_comm, erase_add_right_neg s h, add_comm]\n\ntheorem erase_le (a : α) (s : multiset α) : s.erase a ≤ s :=\nquot.induction_on s $ λ l, (erase_sublist a l).subperm\n\n@[simp] theorem erase_lt {a : α} {s : multiset α} : s.erase a < s ↔ a ∈ s :=\n⟨λ h, not_imp_comm.1 erase_of_not_mem (ne_of_lt h),\n λ h, by simpa [h] using lt_cons_self (s.erase a) a⟩\n\ntheorem erase_subset (a : α) (s : multiset α) : s.erase a ⊆ s :=\nsubset_of_le (erase_le a s)\n\ntheorem mem_erase_of_ne {a b : α} {s : multiset α} (ab : a ≠ b) : a ∈ s.erase b ↔ a ∈ s :=\nquot.induction_on s $ λ l, list.mem_erase_of_ne ab\n\ntheorem mem_of_mem_erase {a b : α} {s : multiset α} : a ∈ s.erase b → a ∈ s :=\nmem_of_subset (erase_subset _ _)\n\ntheorem erase_comm (s : multiset α) (a b : α) : (s.erase a).erase b = (s.erase b).erase a :=\nquot.induction_on s $ λ l, congr_arg coe $ l.erase_comm a b\n\ntheorem erase_le_erase {s t : multiset α} (a : α) (h : s ≤ t) : s.erase a ≤ t.erase a :=\nle_induction_on h $ λ l₁ l₂ h, (h.erase _).subperm\n\ntheorem erase_le_iff_le_cons {s t : multiset α} {a : α} : s.erase a ≤ t ↔ s ≤ a ::ₘ t :=\n⟨λ h, le_trans (le_cons_erase _ _) (cons_le_cons _ h),\n λ h, if m : a ∈ s\n  then by rw ← cons_erase m at h; exact (cons_le_cons_iff _).1 h\n  else le_trans (erase_le _ _) ((le_cons_of_not_mem m).1 h)⟩\n\n@[simp] theorem card_erase_of_mem {a : α} {s : multiset α} :\n  a ∈ s → card (s.erase a) = pred (card s) :=\nquot.induction_on s $ λ l, length_erase_of_mem\n\ntheorem card_erase_lt_of_mem {a : α} {s : multiset α} : a ∈ s → card (s.erase a) < card s :=\nλ h, card_lt_of_lt (erase_lt.mpr h)\n\ntheorem card_erase_le {a : α} {s : multiset α} : card (s.erase a) ≤ card s :=\ncard_le_of_le (erase_le a s)\n\ntheorem card_erase_eq_ite {a : α} {s : multiset α} :\n  card (s.erase a) = if a ∈ s then pred (card s) else card s :=\nbegin\n  by_cases h : a ∈ s,\n  { rwa [card_erase_of_mem h, if_pos] },\n  { rwa [erase_of_not_mem h, if_neg] }\nend\n\nend erase\n\n@[simp] theorem coe_reverse (l : list α) : (reverse l : multiset α) = l :=\nquot.sound $ reverse_perm _\n\n/-! ### `multiset.map` -/\n\n/-- `map f s` is the lift of the list `map` operation. The multiplicity\n  of `b` in `map f s` is the number of `a ∈ s` (counting multiplicity)\n  such that `f a = b`. -/\ndef map (f : α → β) (s : multiset α) : multiset β :=\nquot.lift_on s (λ l : list α, (l.map f : multiset β))\n  (λ l₁ l₂ p, quot.sound (p.map f))\n\ntheorem forall_mem_map_iff {f : α → β} {p : β → Prop} {s : multiset α} :\n  (∀ y ∈ s.map f, p y) ↔ (∀ x ∈ s, p (f x)) :=\nquotient.induction_on' s $ λ L, list.forall_mem_map_iff\n\n@[simp] theorem coe_map (f : α → β) (l : list α) : map f ↑l = l.map f := rfl\n\n@[simp] theorem map_zero (f : α → β) : map f 0 = 0 := rfl\n\n@[simp] theorem map_cons (f : α → β) (a s) : map f (a ::ₘ s) = f a ::ₘ map f s :=\nquot.induction_on s $ λ l, rfl\n\n@[simp] theorem map_singleton (f : α → β) (a : α) : ({a} : multiset α).map f = {f a} := rfl\n\ntheorem map_repeat (f : α → β) (a : α) (k : ℕ) : (repeat a k).map f = repeat (f a) k := by\n{ induction k, simp, simpa }\n\n@[simp] theorem map_add (f : α → β) (s t) : map f (s + t) = map f s + map f t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, congr_arg coe $ map_append _ _ _\n\n/-- If each element of `s : multiset α` can be lifted to `β`, then `s` can be lifted to\n`multiset β`. -/\ninstance [can_lift α β] : can_lift (multiset α) (multiset β) :=\n{ cond := λ s, ∀ x ∈ s, can_lift.cond β x,\n  coe := map can_lift.coe,\n  prf := by { rintro ⟨l⟩ hl, lift l to list β using hl, exact ⟨l, coe_map _ _⟩ } }\n\n/-- `multiset.map` as an `add_monoid_hom`. -/\ndef map_add_monoid_hom (f : α → β) : multiset α →+ multiset β :=\n{ to_fun := map f,\n  map_zero' := map_zero _,\n  map_add' := map_add _ }\n\n@[simp] lemma coe_map_add_monoid_hom (f : α → β) :\n  (map_add_monoid_hom f : multiset α → multiset β) = map f := rfl\n\ntheorem map_nsmul (f : α → β) (n : ℕ) (s) : map f (n • s) = n • (map f s) :=\n(map_add_monoid_hom f).map_nsmul _ _\n\n@[simp] theorem mem_map {f : α → β} {b : β} {s : multiset α} :\n  b ∈ map f s ↔ ∃ a, a ∈ s ∧ f a = b :=\nquot.induction_on s $ λ l, mem_map\n\n@[simp] theorem card_map (f : α → β) (s) : card (map f s) = card s :=\nquot.induction_on s $ λ l, length_map _ _\n\n@[simp] theorem map_eq_zero {s : multiset α} {f : α → β} : s.map f = 0 ↔ s = 0 :=\nby rw [← multiset.card_eq_zero, multiset.card_map, multiset.card_eq_zero]\n\ntheorem mem_map_of_mem (f : α → β) {a : α} {s : multiset α} (h : a ∈ s) : f a ∈ map f s :=\nmem_map.2 ⟨_, h, rfl⟩\n\nlemma map_eq_singleton {f : α → β} {s : multiset α} {b : β} :\n  map f s = {b} ↔ ∃ a : α, s = {a} ∧ f a = b :=\nbegin\n  split,\n  { intro h,\n    obtain ⟨a, ha⟩ : ∃ a, s = {a},\n    { rw [←card_eq_one, ←card_map, h, card_singleton] },\n    refine ⟨a, ha, _⟩,\n    rw [←mem_singleton, ←h, ha, map_singleton, mem_singleton] },\n  { rintro ⟨a, rfl, rfl⟩,\n    simp }\nend\n\ntheorem mem_map_of_injective {f : α → β} (H : function.injective f) {a : α} {s : multiset α} :\n  f a ∈ map f s ↔ a ∈ s :=\nquot.induction_on s $ λ l, mem_map_of_injective H\n\n@[simp] theorem map_map (g : β → γ) (f : α → β) (s : multiset α) :\n  map g (map f s) = map (g ∘ f) s :=\nquot.induction_on s $ λ l, congr_arg coe $ list.map_map _ _ _\n\ntheorem map_id (s : multiset α) : map id s = s :=\nquot.induction_on s $ λ l, congr_arg coe $ map_id _\n\n@[simp] lemma map_id' (s : multiset α) : map (λx, x) s = s := map_id s\n\n@[simp] theorem map_const (s : multiset α) (b : β) : map (function.const α b) s = repeat b s.card :=\nquot.induction_on s $ λ l, congr_arg coe $ map_const _ _\n\n@[congr] theorem map_congr {f g : α → β} {s : multiset α} :\n  (∀ x ∈ s, f x = g x) → map f s = map g s :=\nquot.induction_on s $ λ l H, congr_arg coe $ map_congr H\n\nlemma map_hcongr {β' : Type*} {m : multiset α} {f : α → β} {f' : α → β'}\n  (h : β = β') (hf : ∀a∈m, f a == f' a) : map f m == map f' m :=\nbegin subst h, simp at hf, simp [map_congr hf] end\n\ntheorem eq_of_mem_map_const {b₁ b₂ : β} {l : list α} (h : b₁ ∈ map (function.const α b₂) l) :\n  b₁ = b₂ :=\neq_of_mem_repeat $ by rwa map_const at h\n\n@[simp] theorem map_le_map {f : α → β} {s t : multiset α} (h : s ≤ t) : map f s ≤ map f t :=\nle_induction_on h $ λ l₁ l₂ h, (h.map f).subperm\n\n@[simp] theorem map_subset_map {f : α → β} {s t : multiset α} (H : s ⊆ t) : map f s ⊆ map f t :=\nλ b m, let ⟨a, h, e⟩ := mem_map.1 m in mem_map.2 ⟨a, H h, e⟩\n\nlemma map_erase [decidable_eq α] [decidable_eq β]\n  (f : α → β) (hf : function.injective f) (x : α) (s : multiset α) :\n  (s.erase x).map f = (s.map f).erase (f x) :=\nbegin\n  induction s using multiset.induction_on with y s ih,\n  { simp },\n  by_cases hxy : y = x,\n  { cases hxy, simp },\n  { rw [s.erase_cons_tail hxy, map_cons, map_cons, (s.map f).erase_cons_tail (hf.ne hxy), ih] }\nend\n\n/-! ### `multiset.fold` -/\n\n/-- `foldl f H b s` is the lift of the list operation `foldl f b l`,\n  which folds `f` over the multiset. It is well defined when `f` is right-commutative,\n  that is, `f (f b a₁) a₂ = f (f b a₂) a₁`. -/\ndef foldl (f : β → α → β) (H : right_commutative f) (b : β) (s : multiset α) : β :=\nquot.lift_on s (λ l, foldl f b l)\n  (λ l₁ l₂ p, p.foldl_eq H b)\n\n@[simp] theorem foldl_zero (f : β → α → β) (H b) : foldl f H b 0 = b := rfl\n\n@[simp] theorem foldl_cons (f : β → α → β) (H b a s) :\n  foldl f H b (a ::ₘ s) = foldl f H (f b a) s :=\nquot.induction_on s $ λ l, rfl\n\n@[simp] theorem foldl_add (f : β → α → β) (H b s t) :\n  foldl f H b (s + t) = foldl f H (foldl f H b s) t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, foldl_append _ _ _ _\n\n/-- `foldr f H b s` is the lift of the list operation `foldr f b l`,\n  which folds `f` over the multiset. It is well defined when `f` is left-commutative,\n  that is, `f a₁ (f a₂ b) = f a₂ (f a₁ b)`. -/\ndef foldr (f : α → β → β) (H : left_commutative f) (b : β) (s : multiset α) : β :=\nquot.lift_on s (λ l, foldr f b l)\n  (λ l₁ l₂ p, p.foldr_eq H b)\n\n@[simp] theorem foldr_zero (f : α → β → β) (H b) : foldr f H b 0 = b := rfl\n\n@[simp] theorem foldr_cons (f : α → β → β) (H b a s) :\n  foldr f H b (a ::ₘ s) = f a (foldr f H b s) :=\nquot.induction_on s $ λ l, rfl\n\n@[simp] theorem foldr_singleton (f : α → β → β) (H b a) :\n  foldr f H b ({a} : multiset α) = f a b :=\nrfl\n\n@[simp] theorem foldr_add (f : α → β → β) (H b s t) :\n  foldr f H b (s + t) = foldr f H (foldr f H b t) s :=\nquotient.induction_on₂ s t $ λ l₁ l₂, foldr_append _ _ _ _\n\n@[simp] theorem coe_foldr (f : α → β → β) (H : left_commutative f) (b : β) (l : list α) :\n  foldr f H b l = l.foldr f b := rfl\n\n@[simp] theorem coe_foldl (f : β → α → β) (H : right_commutative f) (b : β) (l : list α) :\n  foldl f H b l = l.foldl f b := rfl\n\ntheorem coe_foldr_swap (f : α → β → β) (H : left_commutative f) (b : β) (l : list α) :\n  foldr f H b l = l.foldl (λ x y, f y x) b :=\n(congr_arg (foldr f H b) (coe_reverse l)).symm.trans $ foldr_reverse _ _ _\n\ntheorem foldr_swap (f : α → β → β) (H : left_commutative f) (b : β) (s : multiset α) :\n  foldr f H b s = foldl (λ x y, f y x) (λ x y z, (H _ _ _).symm) b s :=\nquot.induction_on s $ λ l, coe_foldr_swap _ _ _ _\n\ntheorem foldl_swap (f : β → α → β) (H : right_commutative f) (b : β) (s : multiset α) :\n  foldl f H b s = foldr (λ x y, f y x) (λ x y z, (H _ _ _).symm) b s :=\n(foldr_swap _ _ _ _).symm\n\nlemma foldr_induction' (f : α → β → β) (H : left_commutative f) (x : β) (q : α → Prop)\n  (p : β → Prop) (s : multiset α) (hpqf : ∀ a b, q a → p b → p (f a b)) (px : p x)\n  (q_s : ∀ a ∈ s, q a) :\n  p (foldr f H x s) :=\nbegin\n  revert s,\n  refine multiset.induction (by simp [px]) _,\n  intros a s hs hsa,\n  rw foldr_cons,\n  have hps : ∀ (x : α), x ∈ s → q x, from λ x hxs, hsa x (mem_cons_of_mem hxs),\n  exact hpqf a (foldr f H x s) (hsa a (mem_cons_self a s)) (hs hps),\nend\n\nlemma foldr_induction (f : α → α → α) (H : left_commutative f) (x : α) (p : α → Prop)\n  (s : multiset α) (p_f : ∀ a b, p a → p b → p (f a b)) (px : p x) (p_s : ∀ a ∈ s, p a) :\n  p (foldr f H x s) :=\nfoldr_induction' f H x p p s p_f px p_s\n\nlemma foldl_induction' (f : β → α → β) (H : right_commutative f) (x : β) (q : α → Prop)\n  (p : β → Prop) (s : multiset α) (hpqf : ∀ a b, q a → p b → p (f b a)) (px : p x)\n  (q_s : ∀ a ∈ s, q a) :\n  p (foldl f H x s) :=\nbegin\n  rw foldl_swap,\n  exact foldr_induction' (λ x y, f y x) (λ x y z, (H _ _ _).symm) x q p s hpqf px q_s,\nend\n\nlemma foldl_induction (f : α → α → α) (H : right_commutative f) (x : α) (p : α → Prop)\n  (s : multiset α) (p_f : ∀ a b, p a → p b → p (f b a)) (px : p x) (p_s : ∀ a ∈ s, p a) :\n  p (foldl f H x s) :=\nfoldl_induction' f H x p p s p_f px p_s\n\n/-- Product of a multiset given a commutative monoid structure on `α`.\n  `prod {a, b, c} = a * b * c` -/\n@[to_additive \"Sum of a multiset given a commutative additive monoid structure on `α`.\n  `sum {a, b, c} = a + b + c`\"]\ndef prod [comm_monoid α] : multiset α → α :=\nfoldr (*) (λ x y z, by simp [mul_left_comm]) 1\n\n@[to_additive]\ntheorem prod_eq_foldr [comm_monoid α] (s : multiset α) :\n  prod s = foldr (*) (λ x y z, by simp [mul_left_comm]) 1 s := rfl\n\n@[to_additive]\ntheorem prod_eq_foldl [comm_monoid α] (s : multiset α) :\n  prod s = foldl (*) (λ x y z, by simp [mul_right_comm]) 1 s :=\n(foldr_swap _ _ _ _).trans (by simp [mul_comm])\n\n@[simp, norm_cast, to_additive]\ntheorem coe_prod [comm_monoid α] (l : list α) : prod ↑l = l.prod :=\nprod_eq_foldl _\n\n@[simp, to_additive] theorem prod_to_list [comm_monoid α] (s : multiset α) :\n  s.to_list.prod = s.prod :=\nbegin\n  conv_rhs { rw ←coe_to_list s, },\n  rw coe_prod,\nend\n\n@[simp, to_additive]\ntheorem prod_zero [comm_monoid α] : @prod α _ 0 = 1 := rfl\n\n@[simp, to_additive]\ntheorem prod_cons [comm_monoid α] (a : α) (s) : prod (a ::ₘ s) = a * prod s :=\nfoldr_cons _ _ _ _ _\n\n@[simp, to_additive]\ntheorem prod_singleton [comm_monoid α] (a : α) : prod {a} = a :=\nby simp only [mul_one, prod_cons, singleton_eq_cons, eq_self_iff_true, prod_zero]\n\n@[simp, to_additive]\ntheorem prod_add [comm_monoid α] (s t : multiset α) : prod (s + t) = prod s * prod t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, by simp\n\n\n/-- `multiset.sum`, the sum of the elements of a multiset, promoted to a morphism of\n`add_comm_monoid`s. -/\ndef sum_add_monoid_hom [add_comm_monoid α] : multiset α →+ α :=\n{ to_fun := sum,\n  map_zero' := sum_zero,\n  map_add' := sum_add }\n\n@[simp] lemma coe_sum_add_monoid_hom [add_comm_monoid α] :\n  (sum_add_monoid_hom : multiset α → α) = sum := rfl\n\nlemma prod_nsmul {α : Type*} [comm_monoid α] (m : multiset α) :\n  ∀ (n : ℕ), (n • m).prod = m.prod ^ n\n| 0       := by { rw [zero_nsmul, pow_zero], refl }\n| (n + 1) :=\n  by rw [add_nsmul, one_nsmul, pow_add, pow_one, prod_add, prod_nsmul n]\n\n@[simp, to_additive] theorem prod_repeat [comm_monoid α] (a : α) (n : ℕ) :\n  prod (multiset.repeat a n) = a ^ n :=\nby simp [repeat, list.prod_repeat]\n\n@[to_additive]\nlemma prod_map_one [comm_monoid γ] {m : multiset α} :\n  prod (m.map (λa, (1 : γ))) = (1 : γ) :=\nby simp\n\n@[simp, to_additive]\nlemma prod_map_mul [comm_monoid γ] {m : multiset α} {f g : α → γ} :\n  prod (m.map $ λa, f a * g a) = prod (m.map f) * prod (m.map g) :=\nmultiset.induction_on m (by simp) (assume a m ih, by simp [ih]; cc)\n\n@[to_additive]\nlemma prod_map_prod_map [comm_monoid γ] (m : multiset α) (n : multiset β) {f : α → β → γ} :\n  prod (m.map $ λa, prod $ n.map $ λb, f a b) = prod (n.map $ λb, prod $ m.map $ λa, f a b) :=\nmultiset.induction_on m (by simp) (assume a m ih, by simp [ih])\n\nlemma sum_map_mul_left [semiring β] {b : β} {s : multiset α} {f : α → β} :\n  sum (s.map (λa, b * f a)) = b * sum (s.map f) :=\nmultiset.induction_on s (by simp) (assume a s ih, by simp [ih, mul_add])\n\nlemma sum_map_mul_right [semiring β] {b : β} {s : multiset α} {f : α → β} :\n  sum (s.map (λa, f a * b)) = sum (s.map f) * b :=\nmultiset.induction_on s (by simp) (assume a s ih, by simp [ih, add_mul])\n\nlemma prod_eq_zero {M₀ : Type*} [comm_monoid_with_zero M₀] {s : multiset M₀} (h : (0 : M₀) ∈ s) :\n  multiset.prod s = 0 :=\nbegin\n  rcases multiset.exists_cons_of_mem h with ⟨s', hs'⟩,\n  simp [hs', multiset.prod_cons]\nend\n\nlemma prod_eq_zero_iff {M₀ : Type*} [comm_monoid_with_zero M₀] [no_zero_divisors M₀] [nontrivial M₀]\n  {s : multiset M₀} :\n  multiset.prod s = 0 ↔ (0 : M₀) ∈ s :=\nby { rcases s with ⟨l⟩, simp }\n\ntheorem prod_ne_zero {M₀ : Type*} [comm_monoid_with_zero M₀] [no_zero_divisors M₀] [nontrivial M₀]\n  {m : multiset M₀} (h : (0 : M₀) ∉ m) : m.prod ≠ 0 :=\nmt prod_eq_zero_iff.1 h\n\n@[to_additive]\nlemma prod_hom [comm_monoid α] [comm_monoid β] (s : multiset α) (f : α →* β) :\n  (s.map f).prod = f s.prod :=\nquotient.induction_on s $ λ l, by simp only [l.prod_hom f, quot_mk_to_coe, coe_map, coe_prod]\n\n@[to_additive]\ntheorem prod_hom_rel [comm_monoid β] [comm_monoid γ] (s : multiset α) {r : β → γ → Prop}\n  {f : α → β} {g : α → γ} (h₁ : r 1 1) (h₂ : ∀⦃a b c⦄, r b c → r (f a * b) (g a * c)) :\n  r (s.map f).prod (s.map g).prod :=\nquotient.induction_on s $ λ l,\n  by simp only [l.prod_hom_rel h₁ h₂, quot_mk_to_coe, coe_map, coe_prod]\n\n@[simp] lemma coe_inv_monoid_hom {G : Type*} [comm_group G] :\n  (comm_group.inv_monoid_hom : G → G) = has_inv.inv := rfl\n\n@[simp, to_additive]\nlemma prod_map_inv {G : Type*} [comm_group G] (m : multiset G) :\n  (m.map has_inv.inv).prod = m.prod⁻¹ :=\nm.prod_hom comm_group.inv_monoid_hom\n\nlemma dvd_prod [comm_monoid α] {a : α} {s : multiset α} : a ∈ s → a ∣ s.prod :=\nquotient.induction_on s (λ l a h, by simpa using list.dvd_prod h) a\n\nlemma prod_dvd_prod [comm_monoid α] {s t : multiset α} (h : s ≤ t) :\n  s.prod ∣ t.prod :=\nbegin\n  rcases multiset.le_iff_exists_add.1 h with ⟨z, rfl⟩,\n  simp,\nend\n\nlemma prod_nonneg [ordered_comm_semiring α] {m : multiset α} (h : ∀ a ∈ m, (0 : α) ≤ a) :\n  0 ≤ m.prod :=\nbegin\n  revert h,\n  refine m.induction_on _ _,\n  { rintro -, rw prod_zero, exact zero_le_one },\n  { intros a s hs ih,\n    rw prod_cons,\n    apply mul_nonneg,\n    { exact ih _ (mem_cons_self _ _) },\n    { exact hs (λ a ha, ih _ (mem_cons_of_mem ha)) } }\nend\n\n@[to_additive sum_nonneg]\nlemma one_le_prod_of_one_le [ordered_comm_monoid α] {m : multiset α} :\n  (∀ x ∈ m, (1 : α) ≤ x) → 1 ≤ m.prod :=\nquotient.induction_on m $ λ l hl, by simpa using list.one_le_prod_of_one_le hl\n\n@[to_additive]\nlemma single_le_prod [ordered_comm_monoid α] {m : multiset α} :\n  (∀ x ∈ m, (1 : α) ≤ x) → ∀ x ∈ m, x ≤ m.prod :=\nquotient.induction_on m $ λ l hl x hx, by simpa using list.single_le_prod hl x hx\n\n@[to_additive]\nlemma prod_le_of_forall_le [ordered_comm_monoid α] (l : multiset α) (n : α) (h : ∀ (x ∈ l), x ≤ n) :\n  l.prod ≤ n ^ l.card :=\nbegin\n  induction l using quotient.induction_on,\n  simpa using list.prod_le_of_forall_le _ _ h\nend\n\n@[to_additive all_zero_of_le_zero_le_of_sum_eq_zero]\nlemma all_one_of_le_one_le_of_prod_eq_one [ordered_comm_monoid α] {m : multiset α} :\n  (∀ x ∈ m, (1 : α) ≤ x) → m.prod = 1 → (∀ x ∈ m, x = (1 : α)) :=\nbegin\n  apply quotient.induction_on m,\n  simp only [quot_mk_to_coe, coe_prod, mem_coe],\n  exact λ l, all_one_of_le_one_le_of_prod_eq_one,\nend\n\nlemma sum_eq_zero_iff [canonically_ordered_add_monoid α] {m : multiset α} :\n  m.sum = 0 ↔ ∀ x ∈ m, x = (0 : α) :=\nquotient.induction_on m $ λ l, by simpa using list.sum_eq_zero_iff l\n\n@[to_additive]\nlemma prod_induction {M : Type*} [comm_monoid M] (p : M → Prop) (s : multiset M)\n  (p_mul : ∀ a b, p a → p b → p (a * b)) (p_one : p 1) (p_s : ∀ a ∈ s, p a) :\n  p s.prod :=\nbegin\n  rw prod_eq_foldr,\n  exact foldr_induction (*) (λ x y z, by simp [mul_left_comm]) 1 p s p_mul p_one p_s,\nend\n\n@[to_additive le_sum_of_subadditive_on_pred]\nlemma le_prod_of_submultiplicative_on_pred [comm_monoid α] [ordered_comm_monoid β]\n  (f : α → β) (p : α → Prop) (h_one : f 1 = 1) (hp_one : p 1)\n  (h_mul : ∀ a b, p a → p b → f (a * b) ≤ f a * f b)\n  (hp_mul : ∀ a b, p a → p b → p (a * b)) (s : multiset α) (hps : ∀ a, a ∈ s → p a) :\n  f s.prod ≤ (s.map f).prod :=\nbegin\n  revert s,\n  refine multiset.induction _ _,\n  { simp [le_of_eq h_one], },\n  intros a s hs hpsa,\n  have hps : ∀ x, x ∈ s → p x, from λ x hx, hpsa x (mem_cons_of_mem hx),\n  have hp_prod : p s.prod, from prod_induction p s hp_mul hp_one hps,\n  rw [prod_cons, map_cons, prod_cons],\n  exact (h_mul a s.prod (hpsa a (mem_cons_self a s)) hp_prod).trans (mul_le_mul_left' (hs hps) _),\nend\n\n@[to_additive le_sum_of_subadditive]\nlemma le_prod_of_submultiplicative [comm_monoid α] [ordered_comm_monoid β]\n  (f : α → β) (h_one : f 1 = 1) (h_mul : ∀ a b, f (a * b) ≤ f a * f b) (s : multiset α) :\n  f s.prod ≤ (s.map f).prod :=\nle_prod_of_submultiplicative_on_pred f (λ i, true) h_one trivial (λ x y _ _ , h_mul x y) (by simp)\n  s (by simp)\n\n@[to_additive]\nlemma prod_induction_nonempty {M : Type*} [comm_monoid M] (p : M → Prop)\n  (p_mul : ∀ a b, p a → p b → p (a * b)) {s : multiset M} (hs_nonempty : s ≠ ∅)\n  (p_s : ∀ a ∈ s, p a) :\n  p s.prod :=\nbegin\n  revert s,\n  refine multiset.induction _ _,\n  { intro h,\n    exfalso,\n    simpa using h, },\n  intros a s hs hsa hpsa,\n  rw prod_cons,\n  by_cases hs_empty : s = ∅,\n  { simp [hs_empty, hpsa a], },\n  have hps : ∀ (x : M), x ∈ s → p x, from λ x hxs, hpsa x (mem_cons_of_mem hxs),\n  exact p_mul a s.prod (hpsa a (mem_cons_self a s)) (hs hs_empty hps),\nend\n\n@[to_additive le_sum_nonempty_of_subadditive_on_pred]\nlemma le_prod_nonempty_of_submultiplicative_on_pred [comm_monoid α] [ordered_comm_monoid β]\n  (f : α → β) (p : α → Prop) (h_mul : ∀ a b, p a → p b → f (a * b) ≤ f a * f b)\n  (hp_mul : ∀ a b, p a → p b → p (a * b)) (s : multiset α) (hs_nonempty : s ≠ ∅)\n  (hs : ∀ a, a ∈ s → p a) :\n  f s.prod ≤ (s.map f).prod :=\nbegin\n  revert s,\n  refine multiset.induction _ _,\n  { intro h,\n    exfalso,\n    exact h rfl, },\n  rintros a s hs hsa_nonempty hsa_prop,\n  rw [prod_cons, map_cons, prod_cons],\n  by_cases hs_empty : s = ∅,\n  { simp [hs_empty], },\n  have hsa_restrict : (∀ x, x ∈ s → p x), from λ x hx, hsa_prop x (mem_cons_of_mem hx),\n  have hp_sup : p s.prod,\n    from prod_induction_nonempty p hp_mul hs_empty hsa_restrict,\n  have hp_a : p a, from hsa_prop a (mem_cons_self a s),\n  exact (h_mul a _ hp_a hp_sup).trans (mul_le_mul_left' (hs hs_empty hsa_restrict) _),\nend\n\n@[to_additive le_sum_nonempty_of_subadditive]\nlemma le_prod_nonempty_of_submultiplicative [comm_monoid α] [ordered_comm_monoid β]\n  (f : α → β) (h_mul : ∀ a b, f (a * b) ≤ f a * f b) (s : multiset α) (hs_nonempty : s ≠ ∅) :\n  f s.prod ≤ (s.map f).prod :=\nle_prod_nonempty_of_submultiplicative_on_pred f (λ i, true) (by simp [h_mul]) (by simp) s\n  hs_nonempty (by simp)\n\ntheorem dvd_sum [comm_semiring α] {a : α} {s : multiset α} : (∀ x ∈ s, a ∣ x) → a ∣ s.sum :=\nmultiset.induction_on s (λ _, dvd_zero _)\n  (λ x s ih h, by rw sum_cons; exact dvd_add\n    (h _ (mem_cons_self _ _)) (ih (λ y hy, h _ (mem_cons.2 (or.inr hy)))))\n\n@[simp] theorem sum_map_singleton (s : multiset α) : (s.map (λ a, ({a} : multiset α))).sum = s :=\nmultiset.induction_on s (by simp) (by simp [singleton_eq_cons])\n\ntheorem abs_sum_le_sum_abs [linear_ordered_add_comm_group α] {s : multiset α} :\n  abs s.sum ≤ (s.map abs).sum :=\nle_sum_of_subadditive _ abs_zero abs_add s\n\n/-! ### Join -/\n\n/-- `join S`, where `S` is a multiset of multisets, is the lift of the list join\n  operation, that is, the union of all the sets.\n     join {{1, 2}, {1, 2}, {0, 1}} = {0, 1, 1, 1, 2, 2} -/\ndef join : multiset (multiset α) → multiset α := sum\n\ntheorem coe_join : ∀ L : list (list α),\n  join (L.map (@coe _ (multiset α) _) : multiset (multiset α)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (λ s : multiset α, ↑l + s) (coe_join L)\n\n@[simp] theorem join_zero : @join α 0 = 0 := rfl\n\n@[simp] theorem join_cons (s S) : @join α (s ::ₘ S) = s + join S :=\nsum_cons _ _\n\n@[simp] theorem join_add (S T) : @join α (S + T) = join S + join T :=\nsum_add _ _\n\n@[simp] theorem singleton_join (a) : join ({a} : multiset (multiset α)) = a :=\nsum_singleton _\n\n@[simp] theorem mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s :=\nmultiset.induction_on S (by simp) $\n  by simp [or_and_distrib_right, exists_or_distrib] {contextual := tt}\n\n@[simp] theorem card_join (S) : card (@join α S) = sum (map card S) :=\nmultiset.induction_on S (by simp) (by simp)\n\n/-! ### `multiset.bind` -/\n\n/-- `bind s f` is the monad bind operation, defined as `join (map f s)`.\n  It is the union of `f a` as `a` ranges over `s`. -/\ndef bind (s : multiset α) (f : α → multiset β) : multiset β :=\njoin (map f s)\n\n@[simp] theorem coe_bind (l : list α) (f : α → list β) :\n  @bind α β l (λ a, f a) = l.bind f :=\nby rw [list.bind, ← coe_join, list.map_map]; refl\n\n@[simp] theorem zero_bind (f : α → multiset β) : bind 0 f = 0 := rfl\n\n@[simp] theorem cons_bind (a s) (f : α → multiset β) : bind (a ::ₘ s) f = f a + bind s f :=\nby simp [bind]\n\n@[simp] theorem singleton_bind (a) (f : α → multiset β) : bind {a} f = f a :=\nby simp [bind]\n\n@[simp] theorem add_bind (s t) (f : α → multiset β) : bind (s + t) f = bind s f + bind t f :=\nby simp [bind]\n\n@[simp] theorem bind_zero (s : multiset α) : bind s (λa, 0 : α → multiset β) = 0 :=\nby simp [bind, join, nsmul_zero]\n\n@[simp] theorem bind_add (s : multiset α) (f g : α → multiset β) :\n  bind s (λa, f a + g a) = bind s f + bind s g :=\nby simp [bind, join]\n\n@[simp] theorem bind_cons (s : multiset α) (f : α → β) (g : α → multiset β) :\n  bind s (λa, f a ::ₘ g a) = map f s + bind s g :=\nmultiset.induction_on s (by simp) (by simp [add_comm, add_left_comm] {contextual := tt})\n\n@[simp] theorem bind_singleton (s : multiset α) (f : α → β) :\n  bind s (λ x, ({f x} : multiset β)) = map f s :=\nmultiset.induction_on s (by rw [zero_bind, map_zero]) (by simp [singleton_add])\n\n@[simp] theorem mem_bind {b s} {f : α → multiset β} : b ∈ bind s f ↔ ∃ a ∈ s, b ∈ f a :=\nby simp [bind]; simp [-exists_and_distrib_right, exists_and_distrib_right.symm];\n   rw exists_swap; simp [and_assoc]\n\n@[simp] theorem card_bind (s) (f : α → multiset β) : card (bind s f) = sum (map (card ∘ f) s) :=\nby simp [bind]\n\nlemma bind_congr {f g : α → multiset β} {m : multiset α} :\n  (∀a∈m, f a = g a) → bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {β' : Type*} {m : multiset α} {f : α → multiset β} {f' : α → multiset β'}\n  (h : β = β') (hf : ∀a∈m, f a == f' a) : bind m f == bind m f' :=\nbegin subst h, simp at hf, simp [bind_congr hf] end\n\nlemma map_bind (m : multiset α) (n : α → multiset β) (f : β → γ) :\n  map f (bind m n) = bind m (λa, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset α) (n : β → multiset γ) (f : α → β) :\n  bind (map f m) n = bind m (λa, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset α} {f : α → multiset β} {g : β → multiset γ} :\n  (s.bind f).bind g = s.bind (λa, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset α) (n : multiset β) {f : α → β → multiset γ} :\n  (bind m $ λa, bind n $ λb, f a b) = (bind n $ λb, bind m $ λa, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset α) (n : multiset β) {f : α → β → γ} :\n  (bind m $ λa, n.map $ λb, f a b) = (bind n $ λb, m.map $ λa, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid β] (s : multiset α) (t : α → multiset β) :\n  prod (bind s t) = prod (s.map $ λa, prod (t a)) :=\nmultiset.induction_on s (by simp) (assume a s ih, by simp [ih, cons_bind])\n\n/-! ### Product of two `multiset`s -/\n\n/-- The multiplicity of `(a, b)` in `product s t` is\n  the product of the multiplicity of `a` in `s` and `b` in `t`. -/\ndef product (s : multiset α) (t : multiset β) : multiset (α × β) :=\ns.bind $ λ a, t.map $ prod.mk a\n\n@[simp] theorem coe_product (l₁ : list α) (l₂ : list β) :\n  @product α β l₁ l₂ = l₁.product l₂ :=\nby rw [product, list.product, ← coe_bind]; simp\n\n@[simp] theorem zero_product (t) : @product α β 0 t = 0 := rfl\n\n@[simp] theorem cons_product (a : α) (s : multiset α) (t : multiset β) :\n  product (a ::ₘ s) t = map (prod.mk a) t + product s t :=\nby simp [product]\n\n@[simp] theorem product_singleton (a : α) (b : β) :\n  product ({a} : multiset α) ({b} : multiset β) = {(a,b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] theorem add_product (s t : multiset α) (u : multiset β) :\n  product (s + t) u = product s u + product t u :=\nby simp [product]\n\n@[simp] theorem product_add (s : multiset α) : ∀ t u : multiset β,\n  product s (t + u) = product s t + product s u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] theorem mem_product {s t} : ∀ {p : α × β}, p ∈ @product α β s t ↔ p.1 ∈ s ∧ p.2 ∈ t\n| (a, b) := by simp [product, and.left_comm]\n\n@[simp] theorem card_product (s : multiset α) (t : multiset β) :\n  card (product s t) = card s * card t :=\nby simp [product, repeat, (∘), mul_comm]\n\n/-! ### Sigma multiset -/\nsection\nvariable {σ : α → Type*}\n\n/-- `sigma s t` is the dependent version of `product`. It is the sum of\n  `(a, b)` as `a` ranges over `s` and `b` ranges over `t a`. -/\nprotected def sigma (s : multiset α) (t : Π a, multiset (σ a)) : multiset (Σ a, σ a) :=\ns.bind $ λ a, (t a).map $ sigma.mk a\n\n@[simp] theorem coe_sigma (l₁ : list α) (l₂ : Π a, list (σ a)) :\n  @multiset.sigma α σ l₁ (λ a, l₂ a) = l₁.sigma l₂ :=\nby rw [multiset.sigma, list.sigma, ← coe_bind]; simp\n\n@[simp] theorem zero_sigma (t) : @multiset.sigma α σ 0 t = 0 := rfl\n\n@[simp] theorem cons_sigma (a : α) (s : multiset α) (t : Π a, multiset (σ a)) :\n  (a ::ₘ s).sigma t = map (sigma.mk a) (t a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] theorem sigma_singleton (a : α) (b : α → β) :\n  ({a} : multiset α).sigma (λ a, ({b a} : multiset β)) = {⟨a, b a⟩} := rfl\n\n@[simp] theorem add_sigma (s t : multiset α) (u : Π a, multiset (σ a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] theorem sigma_add (s : multiset α) : ∀ t u : Π a, multiset (σ a),\n  s.sigma (λ a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] theorem mem_sigma {s t} : ∀ {p : Σ a, σ a},\n  p ∈ @multiset.sigma α σ s t ↔ p.1 ∈ s ∧ p.2 ∈ t p.1\n| ⟨a, b⟩ := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] theorem card_sigma (s : multiset α) (t : Π a, multiset (σ a)) :\n  card (s.sigma t) = sum (map (λ a, card (t a)) s) :=\nby simp [multiset.sigma, (∘)]\n\nend\n\n/-! ### Map for partial functions -/\n\n/-- Lift of the list `pmap` operation. Map a partial function `f` over a multiset\n  `s` whose elements are all in the domain of `f`. -/\ndef pmap {p : α → Prop} (f : Π a, p a → β) (s : multiset α) : (∀ a ∈ s, p a) → multiset β :=\nquot.rec_on s (λ l H, ↑(pmap f l H)) $ λ l₁ l₂ (pp : l₁ ~ l₂),\nfunext $ λ (H₂ : ∀ a ∈ l₂, p a),\nhave H₁ : ∀ a ∈ l₁, p a, from λ a h, H₂ a (pp.subset h),\nhave ∀ {s₂ e H}, @eq.rec (multiset α) l₁\n  (λ s, (∀ a ∈ s, p a) → multiset β) (λ _, ↑(pmap f l₁ H₁))\n  s₂ e H = ↑(pmap f l₁ H₁), by intros s₂ e _; subst e,\nthis.trans $ quot.sound $ pp.pmap f\n\n@[simp] theorem coe_pmap {p : α → Prop} (f : Π a, p a → β)\n  (l : list α) (H : ∀ a ∈ l, p a) : pmap f l H = l.pmap f H := rfl\n\n@[simp] lemma pmap_zero {p : α → Prop} (f : Π a, p a → β) (h : ∀a∈(0:multiset α), p a) :\n  pmap f 0 h = 0 := rfl\n\n@[simp] lemma pmap_cons {p : α → Prop} (f : Π a, p a → β) (a : α) (m : multiset α) :\n  ∀(h : ∀b∈a ::ₘ m, p b), pmap f (a ::ₘ m) h =\n    f a (h a (mem_cons_self a m)) ::ₘ pmap f m (λa ha, h a $ mem_cons_of_mem ha) :=\nquotient.induction_on m $ assume l h, rfl\n\n/-- \"Attach\" a proof that `a ∈ s` to each element `a` in `s` to produce\n  a multiset on `{x // x ∈ s}`. -/\ndef attach (s : multiset α) : multiset {x // x ∈ s} := pmap subtype.mk s (λ a, id)\n\n@[simp] theorem coe_attach (l : list α) :\n @eq (multiset {x // x ∈ l}) (@attach α l) l.attach := rfl\n\ntheorem sizeof_lt_sizeof_of_mem [has_sizeof α] {x : α} {s : multiset α} (hx : x ∈ s) :\n  sizeof x < sizeof s := by\n{ induction s with l a b, exact list.sizeof_lt_sizeof_of_mem hx, refl }\n\ntheorem pmap_eq_map (p : α → Prop) (f : α → β) (s : multiset α) :\n  ∀ H, @pmap _ _ p (λ a _, f a) s H = map f s :=\nquot.induction_on s $ λ l H, congr_arg coe $ pmap_eq_map p f l H\n\ntheorem pmap_congr {p q : α → Prop} {f : Π a, p a → β} {g : Π a, q a → β}\n  (s : multiset α) {H₁ H₂} (h : ∀ a h₁ h₂, f a h₁ = g a h₂) :\n  pmap f s H₁ = pmap g s H₂ :=\nquot.induction_on s (λ l H₁ H₂, congr_arg coe $ pmap_congr l h) H₁ H₂\n\ntheorem map_pmap {p : α → Prop} (g : β → γ) (f : Π a, p a → β)\n  (s) : ∀ H, map g (pmap f s H) = pmap (λ a h, g (f a h)) s H :=\nquot.induction_on s $ λ l H, congr_arg coe $ map_pmap g f l H\n\ntheorem pmap_eq_map_attach {p : α → Prop} (f : Π a, p a → β)\n  (s) : ∀ H, pmap f s H = s.attach.map (λ x, f x.1 (H _ x.2)) :=\nquot.induction_on s $ λ l H, congr_arg coe $ pmap_eq_map_attach f l H\n\ntheorem attach_map_val (s : multiset α) : s.attach.map subtype.val = s :=\nquot.induction_on s $ λ l, congr_arg coe $ attach_map_val l\n\n@[simp] theorem mem_attach (s : multiset α) : ∀ x, x ∈ s.attach :=\nquot.induction_on s $ λ l, mem_attach _\n\n@[simp] theorem mem_pmap {p : α → Prop} {f : Π a, p a → β}\n  {s H b} : b ∈ pmap f s H ↔ ∃ a (h : a ∈ s), f a (H a h) = b :=\nquot.induction_on s (λ l H, mem_pmap) H\n\n@[simp] theorem card_pmap {p : α → Prop} (f : Π a, p a → β)\n  (s H) : card (pmap f s H) = card s :=\nquot.induction_on s (λ l H, length_pmap) H\n\n@[simp] theorem card_attach {m : multiset α} : card (attach m) = card m := card_pmap _ _ _\n\n@[simp] lemma attach_zero : (0 : multiset α).attach = 0 := rfl\n\nlemma attach_cons (a : α) (m : multiset α) :\n  (a ::ₘ m).attach = ⟨a, mem_cons_self a m⟩ ::ₘ (m.attach.map $ λp, ⟨p.1, mem_cons_of_mem p.2⟩) :=\nquotient.induction_on m $ assume l, congr_arg coe $ congr_arg (list.cons _) $\n  by rw [list.map_pmap]; exact list.pmap_congr _ (assume a' h₁ h₂, subtype.eq rfl)\n\nsection decidable_pi_exists\nvariables {m : multiset α}\n\n/-- If `p` is a decidable predicate,\nso is the predicate that all elements of a multiset satisfy `p`. -/\nprotected def decidable_forall_multiset {p : α → Prop} [hp : ∀a, decidable (p a)] :\n  decidable (∀a∈m, p a) :=\nquotient.rec_on_subsingleton m (λl, decidable_of_iff (∀a∈l, p a) $ by simp)\n\ninstance decidable_dforall_multiset {p : Πa∈m, Prop} [hp : ∀a (h : a ∈ m), decidable (p a h)] :\n  decidable (∀a (h : a ∈ m), p a h) :=\ndecidable_of_decidable_of_iff\n  (@multiset.decidable_forall_multiset {a // a ∈ m} m.attach (λa, p a.1 a.2) _)\n  (iff.intro (assume h a ha, h ⟨a, ha⟩ (mem_attach _ _)) (assume h ⟨a, ha⟩ _, h _ _))\n\n/-- decidable equality for functions whose domain is bounded by multisets -/\ninstance decidable_eq_pi_multiset {β : α → Type*} [h : ∀a, decidable_eq (β a)] :\n  decidable_eq (Πa∈m, β a) :=\nassume f g, decidable_of_iff (∀a (h : a ∈ m), f a h = g a h) (by simp [function.funext_iff])\n\n/-- If `p` is a decidable predicate,\nso is the existence of an element in a multiset satisfying `p`. -/\ndef decidable_exists_multiset {p : α → Prop} [decidable_pred p] :\n  decidable (∃ x ∈ m, p x) :=\nquotient.rec_on_subsingleton m list.decidable_exists_mem\n\ninstance decidable_dexists_multiset {p : Πa∈m, Prop} [hp : ∀a (h : a ∈ m), decidable (p a h)] :\n  decidable (∃a (h : a ∈ m), p a h) :=\ndecidable_of_decidable_of_iff\n  (@multiset.decidable_exists_multiset {a // a ∈ m} m.attach (λa, p a.1 a.2) _)\n  (iff.intro (λ ⟨⟨a, ha₁⟩, _, ha₂⟩, ⟨a, ha₁, ha₂⟩)\n    (λ ⟨a, ha₁, ha₂⟩, ⟨⟨a, ha₁⟩, mem_attach _ _, ha₂⟩))\n\nend decidable_pi_exists\n\n/-! ### Subtraction -/\nsection\nvariables [decidable_eq α] {s t u : multiset α} {a b : α}\n\n/-- `s - t` is the multiset such that `count a (s - t) = count a s - count a t` for all `a`\n  (note that it is truncated subtraction, so it is `0` if `count a t ≥ count a s`). -/\nprotected def sub (s t : multiset α) : multiset α :=\nquotient.lift_on₂ s t (λ l₁ l₂, (l₁.diff l₂ : multiset α)) $ λ v₁ v₂ w₁ w₂ p₁ p₂,\n  quot.sound $ p₁.diff p₂\n\ninstance : has_sub (multiset α) := ⟨multiset.sub⟩\n\n@[simp] theorem coe_sub (s t : list α) : (s - t : multiset α) = (s.diff t : list α) := rfl\n\n/-- This is a special case of `tsub_zero`, which should be used instead of this.\n  This is needed to prove `has_ordered_sub (multiset α)`. -/\nprotected theorem sub_zero (s : multiset α) : s - 0 = s :=\nquot.induction_on s $ λ l, rfl\n\n@[simp] theorem sub_cons (a : α) (s t : multiset α) : s - a ::ₘ t = s.erase a - t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, congr_arg coe $ diff_cons _ _ _\n\n/-- This is a special case of `tsub_le_iff_right`, which should be used instead of this.\n  This is needed to prove `has_ordered_sub (multiset α)`. -/\nprotected theorem sub_le_iff_le_add : s - t ≤ u ↔ s ≤ u + t :=\nby revert s; exact\nmultiset.induction_on t (by simp [multiset.sub_zero])\n  (λ a t IH s, by simp [IH, erase_le_iff_le_cons])\n\ninstance : has_ordered_sub (multiset α) :=\n⟨λ n m k, multiset.sub_le_iff_le_add⟩\n\ntheorem sub_eq_fold_erase (s t : multiset α) : s - t = foldl erase erase_comm s t :=\nquotient.induction_on₂ s t $ λ l₁ l₂,\nshow ↑(l₁.diff l₂) = foldl erase erase_comm ↑l₁ ↑l₂,\nby { rw diff_eq_foldl l₁ l₂, symmetry, exact foldl_hom _ _ _ _ _ (λ x y, rfl) }\n\n@[simp] theorem card_sub {s t : multiset α} (h : t ≤ s) : card (s - t) = card s - card t :=\n(tsub_eq_of_eq_add_rev $ by rw [add_comm, ← card_add, tsub_add_cancel_of_le h]).symm\n\n/-! ### Union -/\n\n/-- `s ∪ t` is the lattice join operation with respect to the\n  multiset `≤`. The multiplicity of `a` in `s ∪ t` is the maximum\n  of the multiplicities in `s` and `t`. -/\ndef union (s t : multiset α) : multiset α := s - t + t\n\ninstance : has_union (multiset α) := ⟨union⟩\n\ntheorem union_def (s t : multiset α) : s ∪ t = s - t + t := rfl\n\ntheorem le_union_left (s t : multiset α) : s ≤ s ∪ t := le_tsub_add\n\ntheorem le_union_right (s t : multiset α) : t ≤ s ∪ t := le_add_left _ _\n\ntheorem eq_union_left : t ≤ s → s ∪ t = s := tsub_add_cancel_of_le\n\ntheorem union_le_union_right (h : s ≤ t) (u) : s ∪ u ≤ t ∪ u :=\nadd_le_add_right (tsub_le_tsub_right h _) u\n\ntheorem union_le (h₁ : s ≤ u) (h₂ : t ≤ u) : s ∪ t ≤ u :=\nby rw ← eq_union_left h₂; exact union_le_union_right h₁ t\n\n@[simp] theorem mem_union : a ∈ s ∪ t ↔ a ∈ s ∨ a ∈ t :=\n⟨λ h, (mem_add.1 h).imp_left (mem_of_le tsub_le_self),\n or.rec (mem_of_le $ le_union_left _ _) (mem_of_le $ le_union_right _ _)⟩\n\n@[simp] theorem map_union [decidable_eq β] {f : α → β} (finj : function.injective f)\n  {s t : multiset α} :\n  map f (s ∪ t) = map f s ∪ map f t :=\nquotient.induction_on₂ s t $ λ l₁ l₂,\ncongr_arg coe (by rw [list.map_append f, list.map_diff finj])\n\n/-! ### Intersection -/\n\n/-- `s ∩ t` is the lattice meet operation with respect to the\n  multiset `≤`. The multiplicity of `a` in `s ∩ t` is the minimum\n  of the multiplicities in `s` and `t`. -/\ndef inter (s t : multiset α) : multiset α :=\nquotient.lift_on₂ s t (λ l₁ l₂, (l₁.bag_inter l₂ : multiset α)) $ λ v₁ v₂ w₁ w₂ p₁ p₂,\n  quot.sound $ p₁.bag_inter p₂\n\ninstance : has_inter (multiset α) := ⟨inter⟩\n\n@[simp] theorem inter_zero (s : multiset α) : s ∩ 0 = 0 :=\nquot.induction_on s $ λ l, congr_arg coe l.bag_inter_nil\n\n@[simp] theorem zero_inter (s : multiset α) : 0 ∩ s = 0 :=\nquot.induction_on s $ λ l, congr_arg coe l.nil_bag_inter\n\n@[simp] theorem cons_inter_of_pos {a} (s : multiset α) {t} :\n  a ∈ t → (a ::ₘ s) ∩ t = a ::ₘ s ∩ t.erase a :=\nquotient.induction_on₂ s t $ λ l₁ l₂ h,\ncongr_arg coe $ cons_bag_inter_of_pos _ h\n\n@[simp] theorem cons_inter_of_neg {a} (s : multiset α) {t} :\n  a ∉ t → (a ::ₘ s) ∩ t = s ∩ t :=\nquotient.induction_on₂ s t $ λ l₁ l₂ h,\ncongr_arg coe $ cons_bag_inter_of_neg _ h\n\ntheorem inter_le_left (s t : multiset α) : s ∩ t ≤ s :=\nquotient.induction_on₂ s t $ λ l₁ l₂,\n(bag_inter_sublist_left _ _).subperm\n\ntheorem inter_le_right (s : multiset α) : ∀ t, s ∩ t ≤ t :=\nmultiset.induction_on s (λ t, (zero_inter t).symm ▸ zero_le _) $\nλ a s IH t, if h : a ∈ t\n  then by simpa [h] using cons_le_cons a (IH (t.erase a))\n  else by simp [h, IH]\n\ntheorem le_inter (h₁ : s ≤ t) (h₂ : s ≤ u) : s ≤ t ∩ u :=\nbegin\n  revert s u, refine multiset.induction_on t _ (λ a t IH, _); intros,\n  { simp [h₁] },\n  by_cases a ∈ u,\n  { rw [cons_inter_of_pos _ h, ← erase_le_iff_le_cons],\n    exact IH (erase_le_iff_le_cons.2 h₁) (erase_le_erase _ h₂) },\n  { rw cons_inter_of_neg _ h,\n    exact IH ((le_cons_of_not_mem $ mt (mem_of_le h₂) h).1 h₁) h₂ }\nend\n\n@[simp] theorem mem_inter : a ∈ s ∩ t ↔ a ∈ s ∧ a ∈ t :=\n⟨λ h, ⟨mem_of_le (inter_le_left _ _) h, mem_of_le (inter_le_right _ _) h⟩,\n λ ⟨h₁, h₂⟩, by rw [← cons_erase h₁, cons_inter_of_pos _ h₂]; apply mem_cons_self⟩\n\ninstance : lattice (multiset α) :=\n{ sup          := (∪),\n  sup_le       := @union_le _ _,\n  le_sup_left  := le_union_left,\n  le_sup_right := le_union_right,\n  inf          := (∩),\n  le_inf       := @le_inter _ _,\n  inf_le_left  := inter_le_left,\n  inf_le_right := inter_le_right,\n  ..@multiset.partial_order α }\n\n@[simp] theorem sup_eq_union (s t : multiset α) : s ⊔ t = s ∪ t := rfl\n@[simp] theorem inf_eq_inter (s t : multiset α) : s ⊓ t = s ∩ t := rfl\n\n@[simp] theorem le_inter_iff : s ≤ t ∩ u ↔ s ≤ t ∧ s ≤ u := le_inf_iff\n@[simp] theorem union_le_iff : s ∪ t ≤ u ↔ s ≤ u ∧ t ≤ u := sup_le_iff\n\ntheorem union_comm (s t : multiset α) : s ∪ t = t ∪ s := sup_comm\ntheorem inter_comm (s t : multiset α) : s ∩ t = t ∩ s := inf_comm\n\ntheorem eq_union_right (h : s ≤ t) : s ∪ t = t :=\nby rw [union_comm, eq_union_left h]\n\ntheorem union_le_union_left (h : s ≤ t) (u) : u ∪ s ≤ u ∪ t :=\nsup_le_sup_left h _\n\ntheorem union_le_add (s t : multiset α) : s ∪ t ≤ s + t :=\nunion_le (le_add_right _ _) (le_add_left _ _)\n\ntheorem union_add_distrib (s t u : multiset α) : (s ∪ t) + u = (s + u) ∪ (t + u) :=\nby simpa [(∪), union, eq_comm, add_assoc] using show s + u - (t + u) = s - t,\nby rw [add_comm t, tsub_add_eq_tsub_tsub, add_tsub_cancel_right]\n\ntheorem add_union_distrib (s t u : multiset α) : s + (t ∪ u) = (s + t) ∪ (s + u) :=\nby rw [add_comm, union_add_distrib, add_comm s, add_comm s]\n\ntheorem cons_union_distrib (a : α) (s t : multiset α) : a ::ₘ (s ∪ t) = (a ::ₘ s) ∪ (a ::ₘ t) :=\nby simpa using add_union_distrib (a ::ₘ 0) s t\n\ntheorem inter_add_distrib (s t u : multiset α) : (s ∩ t) + u = (s + u) ∩ (t + u) :=\nbegin\n  by_contra h,\n  cases lt_iff_cons_le.1 (lt_of_le_of_ne (le_inter\n    (add_le_add_right (inter_le_left s t) u)\n    (add_le_add_right (inter_le_right s t) u)) h) with a hl,\n  rw ← cons_add at hl,\n  exact not_le_of_lt (lt_cons_self (s ∩ t) a) (le_inter\n    (le_of_add_le_add_right (le_trans hl (inter_le_left _ _)))\n    (le_of_add_le_add_right (le_trans hl (inter_le_right _ _))))\nend\n\ntheorem add_inter_distrib (s t u : multiset α) : s + (t ∩ u) = (s + t) ∩ (s + u) :=\nby rw [add_comm, inter_add_distrib, add_comm s, add_comm s]\n\ntheorem cons_inter_distrib (a : α) (s t : multiset α) : a ::ₘ (s ∩ t) = (a ::ₘ s) ∩ (a ::ₘ t) :=\nby simp\n\ntheorem union_add_inter (s t : multiset α) : s ∪ t + s ∩ t = s + t :=\nbegin\n  apply le_antisymm,\n  { rw union_add_distrib,\n    refine union_le (add_le_add_left (inter_le_right _ _) _) _,\n    rw add_comm, exact add_le_add_right (inter_le_left _ _) _ },\n  { rw [add_comm, add_inter_distrib],\n    refine le_inter (add_le_add_right (le_union_right _ _) _) _,\n    rw add_comm, exact add_le_add_right (le_union_left _ _) _ }\nend\n\ntheorem sub_add_inter (s t : multiset α) : s - t + s ∩ t = s :=\nbegin\n  rw [inter_comm],\n  revert s, refine multiset.induction_on t (by simp) (λ a t IH s, _),\n  by_cases a ∈ s,\n  { rw [cons_inter_of_pos _ h, sub_cons, add_cons, IH, cons_erase h] },\n  { rw [cons_inter_of_neg _ h, sub_cons, erase_of_not_mem h, IH] }\nend\n\ntheorem sub_inter (s t : multiset α) : s - (s ∩ t) = s - t :=\nadd_right_cancel $ by rw [sub_add_inter s t, tsub_add_cancel_of_le (inter_le_left s t)]\n\nend\n\n/-! ### `multiset.filter` -/\nsection\nvariables (p : α → Prop) [decidable_pred p]\n\n/-- `filter p s` returns the elements in `s` (with the same multiplicities)\n  which satisfy `p`, and removes the rest. -/\ndef filter (s : multiset α) : multiset α :=\nquot.lift_on s (λ l, (filter p l : multiset α))\n  (λ l₁ l₂ h, quot.sound $ h.filter p)\n\n@[simp] theorem coe_filter (l : list α) : filter p (↑l) = l.filter p := rfl\n\n@[simp] theorem filter_zero : filter p 0 = 0 := rfl\n\nlemma filter_congr {p q : α → Prop} [decidable_pred p] [decidable_pred q]\n  {s : multiset α} : (∀ x ∈ s, p x ↔ q x) → filter p s = filter q s :=\nquot.induction_on s $ λ l h, congr_arg coe $ filter_congr h\n\n@[simp] theorem filter_add (s t : multiset α) : filter p (s + t) = filter p s + filter p t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, congr_arg coe $ filter_append _ _\n\n@[simp] theorem filter_le (s : multiset α) : filter p s ≤ s :=\nquot.induction_on s $ λ l, (filter_sublist _).subperm\n\n@[simp] theorem filter_subset (s : multiset α) : filter p s ⊆ s :=\nsubset_of_le $ filter_le _ _\n\ntheorem filter_le_filter {s t} (h : s ≤ t) : filter p s ≤ filter p t :=\nle_induction_on h $ λ l₁ l₂ h, (h.filter p).subperm\n\nlemma monotone_filter_left :\n  monotone (filter p) :=\nλ s t, filter_le_filter p\n\nlemma monotone_filter_right (s : multiset α) ⦃p q : α → Prop⦄\n  [decidable_pred p] [decidable_pred q] (h : p ≤ q) :\n  s.filter p ≤ s.filter q :=\nquotient.induction_on s (λ l, (l.monotone_filter_right h).subperm)\n\nvariable {p}\n\n@[simp] theorem filter_cons_of_pos {a : α} (s) : p a → filter p (a ::ₘ s) = a ::ₘ filter p s :=\nquot.induction_on s $ λ l h, congr_arg coe $ filter_cons_of_pos l h\n\n@[simp] theorem filter_cons_of_neg {a : α} (s) : ¬ p a → filter p (a ::ₘ s) = filter p s :=\nquot.induction_on s $ λ l h, @congr_arg _ _ _ _ coe $ filter_cons_of_neg l h\n\n@[simp] theorem mem_filter {a : α} {s} : a ∈ filter p s ↔ a ∈ s ∧ p a :=\nquot.induction_on s $ λ l, mem_filter\n\ntheorem of_mem_filter {a : α} {s} (h : a ∈ filter p s) : p a :=\n(mem_filter.1 h).2\n\ntheorem mem_of_mem_filter {a : α} {s} (h : a ∈ filter p s) : a ∈ s :=\n(mem_filter.1 h).1\n\ntheorem mem_filter_of_mem {a : α} {l} (m : a ∈ l) (h : p a) : a ∈ filter p l :=\nmem_filter.2 ⟨m, h⟩\n\ntheorem filter_eq_self {s} : filter p s = s ↔ ∀ a ∈ s, p a :=\nquot.induction_on s $ λ l, iff.trans ⟨λ h,\n  eq_of_sublist_of_length_eq (filter_sublist _) (@congr_arg _ _ _ _ card h),\n  congr_arg coe⟩ filter_eq_self\n\ntheorem filter_eq_nil {s} : filter p s = 0 ↔ ∀ a ∈ s, ¬p a :=\nquot.induction_on s $ λ l, iff.trans ⟨λ h,\n  eq_nil_of_length_eq_zero (@congr_arg _ _ _ _ card h),\n  congr_arg coe⟩ filter_eq_nil\n\ntheorem le_filter {s t} : s ≤ filter p t ↔ s ≤ t ∧ ∀ a ∈ s, p a :=\n⟨λ h, ⟨le_trans h (filter_le _ _), λ a m, of_mem_filter (mem_of_le h m)⟩,\n λ ⟨h, al⟩, filter_eq_self.2 al ▸ filter_le_filter p h⟩\n\ntheorem filter_cons {a : α} (s : multiset α) :\n  filter p (a ::ₘ s) = (if p a then {a} else 0) + filter p s :=\nbegin\n  split_ifs with h,\n  { rw [filter_cons_of_pos _ h, singleton_add] },\n  { rw [filter_cons_of_neg _ h, zero_add] },\nend\n\nlemma filter_nsmul (s : multiset α) (n : ℕ) :\n  filter p (n • s) = n • filter p s :=\nbegin\n  refine s.induction_on _ _,\n  { simp only [filter_zero, nsmul_zero] },\n  { intros a ha ih,\n    rw [nsmul_cons, filter_add, ih, filter_cons, nsmul_add],\n    congr,\n    split_ifs with hp;\n    { simp only [filter_eq_self, nsmul_zero, filter_eq_nil],\n      intros b hb,\n      rwa (mem_singleton.mp (mem_of_mem_nsmul hb)) } }\nend\n\nvariable (p)\n\n@[simp] theorem filter_sub [decidable_eq α] (s t : multiset α) :\n  filter p (s - t) = filter p s - filter p t :=\nbegin\n  revert s, refine multiset.induction_on t (by simp) (λ a t IH s, _),\n  rw [sub_cons, IH],\n  by_cases p a,\n  { rw [filter_cons_of_pos _ h, sub_cons], congr,\n    by_cases m : a ∈ s,\n    { rw [← cons_inj_right a, ← filter_cons_of_pos _ h,\n          cons_erase (mem_filter_of_mem m h), cons_erase m] },\n    { rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)] } },\n  { rw [filter_cons_of_neg _ h],\n    by_cases m : a ∈ s,\n    { rw [(by rw filter_cons_of_neg _ h : filter p (erase s a) = filter p (a ::ₘ erase s a)),\n          cons_erase m] },\n    { rw [erase_of_not_mem m] } }\nend\n\n@[simp] theorem filter_union [decidable_eq α] (s t : multiset α) :\n  filter p (s ∪ t) = filter p s ∪ filter p t :=\nby simp [(∪), union]\n\n@[simp] theorem filter_inter [decidable_eq α] (s t : multiset α) :\n  filter p (s ∩ t) = filter p s ∩ filter p t :=\nle_antisymm (le_inter\n    (filter_le_filter _ $ inter_le_left _ _)\n    (filter_le_filter _ $ inter_le_right _ _)) $ le_filter.2\n⟨inf_le_inf (filter_le _ _) (filter_le _ _),\n  λ a h, of_mem_filter (mem_of_le (inter_le_left _ _) h)⟩\n\n@[simp] theorem filter_filter (q) [decidable_pred q] (s : multiset α) :\n  filter p (filter q s) = filter (λ a, p a ∧ q a) s :=\nquot.induction_on s $ λ l, congr_arg coe $ filter_filter p q l\n\ntheorem filter_add_filter (q) [decidable_pred q] (s : multiset α) :\n  filter p s + filter q s = filter (λ a, p a ∨ q a) s + filter (λ a, p a ∧ q a) s :=\nmultiset.induction_on s rfl $ λ a s IH,\nby by_cases p a; by_cases q a; simp *\n\ntheorem filter_add_not (s : multiset α) :\n  filter p s + filter (λ a, ¬ p a) s = s :=\nby rw [filter_add_filter, filter_eq_self.2, filter_eq_nil.2]; simp [decidable.em]\n\ntheorem map_filter (f : β → α) (s : multiset β) :\n  filter p (map f s) = map f (filter (p ∘ f) s) :=\nquot.induction_on s (λ l, by simp [map_filter])\n\n/-! ### Simultaneously filter and map elements of a multiset -/\n\n/-- `filter_map f s` is a combination filter/map operation on `s`.\n  The function `f : α → option β` is applied to each element of `s`;\n  if `f a` is `some b` then `b` is added to the result, otherwise\n  `a` is removed from the resulting multiset. -/\ndef filter_map (f : α → option β) (s : multiset α) : multiset β :=\nquot.lift_on s (λ l, (filter_map f l : multiset β))\n  (λ l₁ l₂ h, quot.sound $ h.filter_map f)\n\n@[simp] theorem coe_filter_map (f : α → option β) (l : list α) :\n  filter_map f l = l.filter_map f := rfl\n\n@[simp] theorem filter_map_zero (f : α → option β) : filter_map f 0 = 0 := rfl\n\n@[simp] theorem filter_map_cons_none {f : α → option β} (a : α) (s : multiset α) (h : f a = none) :\n  filter_map f (a ::ₘ s) = filter_map f s :=\nquot.induction_on s $ λ l, @congr_arg _ _ _ _ coe $ filter_map_cons_none a l h\n\n@[simp] theorem filter_map_cons_some (f : α → option β)\n  (a : α) (s : multiset α) {b : β} (h : f a = some b) :\n  filter_map f (a ::ₘ s) = b ::ₘ filter_map f s :=\nquot.induction_on s $ λ l, @congr_arg _ _ _ _ coe $ filter_map_cons_some f a l h\n\ntheorem filter_map_eq_map (f : α → β) : filter_map (some ∘ f) = map f :=\nfunext $ λ s, quot.induction_on s $ λ l,\n@congr_arg _ _ _ _ coe $ congr_fun (filter_map_eq_map f) l\n\ntheorem filter_map_eq_filter : filter_map (option.guard p) = filter p :=\nfunext $ λ s, quot.induction_on s $ λ l,\n@congr_arg _ _ _ _ coe $ congr_fun (filter_map_eq_filter p) l\n\ntheorem filter_map_filter_map (f : α → option β) (g : β → option γ) (s : multiset α) :\n  filter_map g (filter_map f s) = filter_map (λ x, (f x).bind g) s :=\nquot.induction_on s $ λ l, congr_arg coe $ filter_map_filter_map f g l\n\ntheorem map_filter_map (f : α → option β) (g : β → γ) (s : multiset α) :\n  map g (filter_map f s) = filter_map (λ x, (f x).map g) s :=\nquot.induction_on s $ λ l, congr_arg coe $ map_filter_map f g l\n\ntheorem filter_map_map (f : α → β) (g : β → option γ) (s : multiset α) :\n  filter_map g (map f s) = filter_map (g ∘ f) s :=\nquot.induction_on s $ λ l, congr_arg coe $ filter_map_map f g l\n\ntheorem filter_filter_map (f : α → option β) (p : β → Prop) [decidable_pred p] (s : multiset α) :\n  filter p (filter_map f s) = filter_map (λ x, (f x).filter p) s :=\nquot.induction_on s $ λ l, congr_arg coe $ filter_filter_map f p l\n\ntheorem filter_map_filter (f : α → option β) (s : multiset α) :\n  filter_map f (filter p s) = filter_map (λ x, if p x then f x else none) s :=\nquot.induction_on s $ λ l, congr_arg coe $ filter_map_filter p f l\n\n@[simp] theorem filter_map_some (s : multiset α) : filter_map some s = s :=\nquot.induction_on s $ λ l, congr_arg coe $ filter_map_some l\n\n@[simp] theorem mem_filter_map (f : α → option β) (s : multiset α) {b : β} :\n  b ∈ filter_map f s ↔ ∃ a, a ∈ s ∧ f a = some b :=\nquot.induction_on s $ λ l, mem_filter_map f l\n\ntheorem map_filter_map_of_inv (f : α → option β) (g : β → α)\n  (H : ∀ x : α, (f x).map g = some x) (s : multiset α) :\n  map g (filter_map f s) = s :=\nquot.induction_on s $ λ l, congr_arg coe $ map_filter_map_of_inv f g H l\n\ntheorem filter_map_le_filter_map (f : α → option β) {s t : multiset α}\n  (h : s ≤ t) : filter_map f s ≤ filter_map f t :=\nle_induction_on h $ λ l₁ l₂ h, (h.filter_map _).subperm\n\n/-! ### countp -/\n\n/-- `countp p s` counts the number of elements of `s` (with multiplicity) that\n  satisfy `p`. -/\ndef countp (s : multiset α) : ℕ :=\nquot.lift_on s (countp p) (λ l₁ l₂, perm.countp_eq p)\n\n@[simp] theorem coe_countp (l : list α) : countp p l = l.countp p := rfl\n\n@[simp] theorem countp_zero : countp p 0 = 0 := rfl\n\nvariable {p}\n\n@[simp] theorem countp_cons_of_pos {a : α} (s) : p a → countp p (a ::ₘ s) = countp p s + 1 :=\nquot.induction_on s $ countp_cons_of_pos p\n\n@[simp] theorem countp_cons_of_neg {a : α} (s) : ¬ p a → countp p (a ::ₘ s) = countp p s :=\nquot.induction_on s $ countp_cons_of_neg p\n\nvariable (p)\n\ntheorem countp_cons (b : α) (s) : countp p (b ::ₘ s) = countp p s + (if p b then 1 else 0) :=\nbegin\n  split_ifs with h;\n  simp only [h, multiset.countp_cons_of_pos, add_zero, multiset.countp_cons_of_neg, not_false_iff],\nend\n\ntheorem countp_eq_card_filter (s) : countp p s = card (filter p s) :=\nquot.induction_on s $ λ l, countp_eq_length_filter _ _\n\n@[simp] theorem countp_add (s t) : countp p (s + t) = countp p s + countp p t :=\nby simp [countp_eq_card_filter]\n\n/-- `countp p`, the number of elements of a multiset satisfying `p`, promoted to an\n`add_monoid_hom`. -/\ndef countp_add_monoid_hom : multiset α →+ ℕ :=\n{ to_fun := countp p,\n  map_zero' := countp_zero _,\n  map_add' := countp_add _ }\n\n@[simp] lemma coe_countp_add_monoid_hom :\n  (countp_add_monoid_hom p : multiset α → ℕ) = countp p := rfl\n\n@[simp] theorem countp_sub [decidable_eq α] {s t : multiset α} (h : t ≤ s) :\n  countp p (s - t) = countp p s - countp p t :=\nby simp [countp_eq_card_filter, h, filter_le_filter]\n\ntheorem countp_le_of_le {s t} (h : s ≤ t) : countp p s ≤ countp p t :=\nby simpa [countp_eq_card_filter] using card_le_of_le (filter_le_filter p h)\n\n@[simp] theorem countp_filter (q) [decidable_pred q] (s : multiset α) :\n  countp p (filter q s) = countp (λ a, p a ∧ q a) s :=\nby simp [countp_eq_card_filter]\n\ntheorem countp_map (f : α → β) (s : multiset α) (p : β → Prop) [decidable_pred p] :\n  countp p (map f s) = (s.filter (λ a, p (f a))).card :=\nbegin\n  refine multiset.induction_on s _ (λ a t IH, _),\n  { rw [map_zero, countp_zero, filter_zero, card_zero] },\n  { rw [map_cons, countp_cons, IH, filter_cons, card_add, apply_ite card, card_zero,\n      card_singleton, add_comm] },\nend\n\nvariable {p}\n\ntheorem countp_pos {s} : 0 < countp p s ↔ ∃ a ∈ s, p a :=\nby simp [countp_eq_card_filter, card_pos_iff_exists_mem]\n\ntheorem countp_pos_of_mem {s a} (h : a ∈ s) (pa : p a) : 0 < countp p s :=\ncountp_pos.2 ⟨_, h, pa⟩\n\nend\n\n/-! ### Multiplicity of an element -/\n\nsection\nvariable [decidable_eq α]\n\n/-- `count a s` is the multiplicity of `a` in `s`. -/\ndef count (a : α) : multiset α → ℕ := countp (eq a)\n\n@[simp] theorem coe_count (a : α) (l : list α) : count a (↑l) = l.count a := coe_countp _ _\n\n@[simp] theorem count_zero (a : α) : count a 0 = 0 := rfl\n\n@[simp] theorem count_cons_self (a : α) (s : multiset α) : count a (a ::ₘ s) = succ (count a s) :=\ncountp_cons_of_pos _ rfl\n\n@[simp, priority 990]\ntheorem count_cons_of_ne {a b : α} (h : a ≠ b) (s : multiset α) : count a (b ::ₘ s) = count a s :=\ncountp_cons_of_neg _ h\n\ntheorem count_le_of_le (a : α) {s t} : s ≤ t → count a s ≤ count a t :=\ncountp_le_of_le _\n\ntheorem count_le_count_cons (a b : α) (s : multiset α) : count a s ≤ count a (b ::ₘ s) :=\ncount_le_of_le _ (le_cons_self _ _)\n\ntheorem count_cons (a b : α) (s : multiset α) :\n  count a (b ::ₘ s) = count a s + (if a = b then 1 else 0) :=\nby by_cases h : a = b; simp [h]\n\ntheorem count_singleton_self (a : α) : count a ({a} : multiset α) = 1 :=\nby simp only [count_cons_self, singleton_eq_cons, eq_self_iff_true, count_zero]\n\ntheorem count_singleton (a b : α) : count a ({b} : multiset α) = if a = b then 1 else 0 :=\nby simp only [count_cons, singleton_eq_cons, count_zero, zero_add]\n\n@[simp] theorem count_add (a : α) : ∀ s t, count a (s + t) = count a s + count a t :=\ncountp_add _\n\n/-- `count a`, the multiplicity of `a` in a multiset, promoted to an `add_monoid_hom`. -/\ndef count_add_monoid_hom (a : α) : multiset α →+ ℕ := countp_add_monoid_hom (eq a)\n\n@[simp] lemma coe_count_add_monoid_hom {a : α} :\n  (count_add_monoid_hom a : multiset α → ℕ) = count a := rfl\n\n@[simp] theorem count_nsmul (a : α) (n s) : count a (n • s) = n * count a s :=\nby induction n; simp [*, succ_nsmul', succ_mul, zero_nsmul]\n\ntheorem count_pos {a : α} {s : multiset α} : 0 < count a s ↔ a ∈ s :=\nby simp [count, countp_pos]\n\n@[simp, priority 980]\ntheorem count_eq_zero_of_not_mem {a : α} {s : multiset α} (h : a ∉ s) : count a s = 0 :=\nby_contradiction $ λ h', h $ count_pos.1 (nat.pos_of_ne_zero h')\n\n@[simp] theorem count_eq_zero {a : α} {s : multiset α} : count a s = 0 ↔ a ∉ s :=\niff_not_comm.1 $ count_pos.symm.trans pos_iff_ne_zero\n\ntheorem count_ne_zero {a : α} {s : multiset α} : count a s ≠ 0 ↔ a ∈ s :=\nby simp [ne.def, count_eq_zero]\n\n@[simp] theorem count_repeat_self (a : α) (n : ℕ) : count a (repeat a n) = n :=\nby simp [repeat]\n\ntheorem count_repeat (a b : α) (n : ℕ)  :\n  count a (repeat b n) = if (a = b) then n else 0 :=\nbegin\n  split_ifs with h₁,\n  { rw [h₁, count_repeat_self] },\n  { rw [count_eq_zero],\n    apply mt eq_of_mem_repeat h₁ },\nend\n\n@[simp] theorem count_erase_self (a : α) (s : multiset α) :\n  count a (erase s a) = pred (count a s) :=\nbegin\n  by_cases a ∈ s,\n  { rw [(by rw cons_erase h : count a s = count a (a ::ₘ erase s a)),\n        count_cons_self]; refl },\n  { rw [erase_of_not_mem h, count_eq_zero.2 h]; refl }\nend\n\n@[simp, priority 980] theorem count_erase_of_ne {a b : α} (ab : a ≠ b) (s : multiset α) :\n  count a (erase s b) = count a s :=\nbegin\n  by_cases b ∈ s,\n  { rw [← count_cons_of_ne ab, cons_erase h] },\n  { rw [erase_of_not_mem h] }\nend\n\n@[simp] theorem count_sub (a : α) (s t : multiset α) : count a (s - t) = count a s - count a t :=\nbegin\n  revert s, refine multiset.induction_on t (by simp) (λ b t IH s, _),\n  rw [sub_cons, IH],\n  by_cases ab : a = b,\n  { subst b, rw [count_erase_self, count_cons_self, sub_succ, pred_sub] },\n  { rw [count_erase_of_ne ab, count_cons_of_ne ab] }\nend\n\n@[simp] theorem count_union (a : α) (s t : multiset α) :\n  count a (s ∪ t) = max (count a s) (count a t) :=\nby simp [(∪), union, tsub_add_eq_max, -add_comm]\n\n@[simp] theorem count_inter (a : α) (s t : multiset α) :\n  count a (s ∩ t) = min (count a s) (count a t) :=\nbegin\n  apply @nat.add_left_cancel (count a (s - t)),\n  rw [← count_add, sub_add_inter, count_sub, tsub_add_min],\nend\n\nlemma count_sum {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (map f m).sum = sum (m.map $ λb, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (bind m f) = sum (m.map $ λb, count a $ f b) := count_sum\n\ntheorem le_count_iff_repeat_le {a : α} {s : multiset α} {n : ℕ} : n ≤ count a s ↔ repeat a n ≤ s :=\nquot.induction_on s $ λ l, le_count_iff_repeat_sublist.trans repeat_le_coe.symm\n\n@[simp] theorem count_filter_of_pos {p} [decidable_pred p]\n  {a} {s : multiset α} (h : p a) : count a (filter p s) = count a s :=\nquot.induction_on s $ λ l, count_filter h\n\n@[simp] theorem count_filter_of_neg {p} [decidable_pred p]\n  {a} {s : multiset α} (h : ¬ p a) : count a (filter p s) = 0 :=\nmultiset.count_eq_zero_of_not_mem (λ t, h (of_mem_filter t))\n\ntheorem ext {s t : multiset α} : s = t ↔ ∀ a, count a s = count a t :=\nquotient.induction_on₂ s t $ λ l₁ l₂, quotient.eq.trans perm_iff_count\n\n@[ext]\ntheorem ext' {s t : multiset α} : (∀ a, count a s = count a t) → s = t :=\next.2\n\n@[simp] theorem coe_inter (s t : list α) : (s ∩ t : multiset α) = (s.bag_inter t : list α) :=\nby ext; simp\n\ntheorem le_iff_count {s t : multiset α} : s ≤ t ↔ ∀ a, count a s ≤ count a t :=\n⟨λ h a, count_le_of_le a h, λ al,\n by rw ← (ext.2 (λ a, by simp [max_eq_right (al a)]) : s ∪ t = t);\n    apply le_union_left⟩\n\ninstance : distrib_lattice (multiset α) :=\n{ le_sup_inf := λ s t u, le_of_eq $ eq.symm $\n    ext.2 $ λ a, by simp only [max_min_distrib_left,\n      multiset.count_inter, multiset.sup_eq_union, multiset.count_union, multiset.inf_eq_inter],\n  ..multiset.lattice }\n\ntheorem repeat_inf (s : multiset α) (a : α) (n : ℕ) :\n  (repeat a n) ⊓ s = repeat a (min (s.count a) n) :=\nbegin\n  ext x,\n  rw [inf_eq_inter, count_inter, count_repeat, count_repeat],\n  by_cases x = a,\n    simp only [min_comm, h, if_true, eq_self_iff_true],\n    simp only [h, if_false, zero_min],\nend\n\n/-- `multiset.map f` preserves `count` if `f` is injective on the set of elements contained in\nthe multiset -/\ntheorem count_map_eq_count [decidable_eq β] (f : α → β) (s : multiset α)\n (hf : set.inj_on f {x : α | x ∈ s}) (x ∈ s) : (s.map f).count (f x) = s.count x :=\nbegin\n  suffices : (filter (λ (a : α), f x = f a) s).count x = card (filter (λ (a : α), f x = f a) s),\n  { rw [count, countp_map, ← this],\n    exact count_filter_of_pos rfl },\n  { rw eq_repeat.2 ⟨rfl, λ b hb, eq_comm.1 ((hf H (mem_filter.1 hb).left) (mem_filter.1 hb).right)⟩,\n    simp only [count_repeat, eq_self_iff_true, if_true, card_repeat]},\nend\n\nend\n\n/-! ### Lift a relation to `multiset`s -/\n\nsection rel\n\n/-- `rel r s t` -- lift the relation `r` between two elements to a relation between `s` and `t`,\ns.t. there is a one-to-one mapping betweem elements in `s` and `t` following `r`. -/\n@[mk_iff] inductive rel (r : α → β → Prop) : multiset α → multiset β → Prop\n| zero : rel 0 0\n| cons {a b as bs} : r a b → rel as bs → rel (a ::ₘ as) (b ::ₘ bs)\n\nvariables {δ : Type*} {r : α → β → Prop} {p : γ → δ → Prop}\n\nprivate lemma rel_flip_aux {s t} (h : rel r s t) : rel (flip r) t s :=\nrel.rec_on h rel.zero (assume _ _ _ _ h₀ h₁ ih, rel.cons h₀ ih)\n\nlemma rel_flip {s t} : rel (flip r) s t ↔ rel r t s :=\n⟨rel_flip_aux, rel_flip_aux⟩\n\nlemma rel_refl_of_refl_on {m : multiset α} {r : α → α → Prop} :\n  (∀ x ∈ m, r x x) → rel r m m :=\nbegin\n  apply m.induction_on,\n  { intros, apply rel.zero },\n  { intros a m ih h,\n    exact rel.cons (h _ (mem_cons_self _ _)) (ih (λ _ ha, h _ (mem_cons_of_mem ha))) }\nend\n\nlemma rel_eq_refl {s : multiset α} : rel (=) s s :=\nrel_refl_of_refl_on (λ x hx, rfl)\n\nlemma rel_eq {s t : multiset α} : rel (=) s t ↔ s = t :=\nbegin\n  split,\n  { assume h, induction h; simp * },\n  { assume h, subst h, exact rel_eq_refl }\nend\n\nlemma rel.mono {r p : α → β → Prop} {s t} (hst : rel r s t) (h : ∀(a ∈ s) (b ∈ t), r a b → p a b) :\n  rel p s t :=\nbegin\n  induction hst,\n  case rel.zero { exact rel.zero },\n  case rel.cons : a b s t hab hst ih\n  { apply rel.cons (h a (mem_cons_self _ _) b (mem_cons_self _ _) hab),\n    exact ih (λ a' ha' b' hb' h', h a' (mem_cons_of_mem ha') b' (mem_cons_of_mem hb') h') }\nend\n\nlemma rel.add {s t u v} (hst : rel r s t) (huv : rel r u v) : rel r (s + u) (t + v) :=\nbegin\n  induction hst,\n  case rel.zero { simpa using huv },\n  case rel.cons : a b s t hab hst ih { simpa using ih.cons hab }\nend\n\nlemma rel_flip_eq  {s t : multiset α} : rel (λa b, b = a) s t ↔ s = t :=\nshow rel (flip (=)) s t ↔ s = t, by rw [rel_flip, rel_eq, eq_comm]\n\n@[simp] lemma rel_zero_left {b : multiset β} : rel r 0 b ↔ b = 0 :=\nby rw [rel_iff]; simp\n\n@[simp] lemma rel_zero_right {a : multiset α} : rel r a 0 ↔ a = 0 :=\nby rw [rel_iff]; simp\n\nlemma rel_cons_left {a as bs} :\n  rel r (a ::ₘ as) bs ↔ (∃b bs', r a b ∧ rel r as bs' ∧ bs = b ::ₘ bs') :=\nbegin\n  split,\n  { generalize hm : a ::ₘ as = m,\n    assume h,\n    induction h generalizing as,\n    case rel.zero { simp at hm, contradiction },\n    case rel.cons : a' b as' bs ha'b h ih\n    { rcases cons_eq_cons.1 hm with ⟨eq₁, eq₂⟩ | ⟨h, cs, eq₁, eq₂⟩,\n      { subst eq₁, subst eq₂, exact ⟨b, bs, ha'b, h, rfl⟩ },\n      { rcases ih eq₂.symm with ⟨b', bs', h₁, h₂, eq⟩,\n        exact ⟨b', b ::ₘ bs', h₁, eq₁.symm ▸ rel.cons ha'b h₂, eq.symm ▸ cons_swap _ _ _⟩ } } },\n  { exact assume ⟨b, bs', hab, h, eq⟩, eq.symm ▸ rel.cons hab h }\nend\n\nlemma rel_cons_right {as b bs} :\n  rel r as (b ::ₘ bs) ↔ (∃a as', r a b ∧ rel r as' bs ∧ as = a ::ₘ as') :=\nbegin\n  rw [← rel_flip, rel_cons_left],\n  apply exists_congr, assume a,\n  apply exists_congr, assume as',\n  rw [rel_flip, flip]\nend\n\nlemma rel_add_left {as₀ as₁} :\n  ∀{bs}, rel r (as₀ + as₁) bs ↔ (∃bs₀ bs₁, rel r as₀ bs₀ ∧ rel r as₁ bs₁ ∧ bs = bs₀ + bs₁) :=\nmultiset.induction_on as₀ (by simp)\n  begin\n    assume a s ih bs,\n    simp only [ih, cons_add, rel_cons_left],\n    split,\n    { assume h,\n      rcases h with ⟨b, bs', hab, h, rfl⟩,\n      rcases h with ⟨bs₀, bs₁, h₀, h₁, rfl⟩,\n      exact ⟨b ::ₘ bs₀, bs₁, ⟨b, bs₀, hab, h₀, rfl⟩, h₁, by simp⟩ },\n    { assume h,\n      rcases h with ⟨bs₀, bs₁, h, h₁, rfl⟩,\n      rcases h with ⟨b, bs, hab, h₀, rfl⟩,\n      exact ⟨b, bs + bs₁, hab, ⟨bs, bs₁, h₀, h₁, rfl⟩, by simp⟩ }\n  end\n\nlemma rel_add_right {as bs₀ bs₁} :\n  rel r as (bs₀ + bs₁) ↔ (∃as₀ as₁, rel r as₀ bs₀ ∧ rel r as₁ bs₁ ∧ as = as₀ + as₁) :=\nby rw [← rel_flip, rel_add_left]; simp [rel_flip]\n\nlemma rel_map_left {s : multiset γ} {f : γ → α} :\n  ∀{t}, rel r (s.map f) t ↔ rel (λa b, r (f a) b) s t :=\nmultiset.induction_on s (by simp) (by simp [rel_cons_left] {contextual := tt})\n\nlemma rel_map_right {s : multiset α} {t : multiset γ} {f : γ → β} :\n  rel r s (t.map f) ↔ rel (λa b, r a (f b)) s t :=\nby rw [← rel_flip, rel_map_left, ← rel_flip]; refl\n\nlemma rel_join {s t} (h : rel (rel r) s t) : rel r s.join t.join :=\nbegin\n  induction h,\n  case rel.zero { simp },\n  case rel.cons : a b s t hab hst ih { simpa using hab.add ih }\nend\n\nlemma rel_map {s : multiset α} {t : multiset β} {f : α → γ} {g : β → δ} :\n  rel p (s.map f) (t.map g) ↔ rel (λa b, p (f a) (g b)) s t :=\nrel_map_left.trans rel_map_right\n\nlemma rel_bind {p : γ → δ → Prop} {s t} {f : α → multiset γ} {g : β → multiset δ}\n  (h : (r ⇒ rel p) f g) (hst : rel r s t) :\n  rel p (s.bind f) (t.bind g) :=\nby { apply rel_join, rw rel_map, exact hst.mono (λ a ha b hb hr, h hr) }\n\nlemma card_eq_card_of_rel {r : α → β → Prop} {s : multiset α} {t : multiset β} (h : rel r s t) :\n  card s = card t :=\nby induction h; simp [*]\n\nlemma exists_mem_of_rel_of_mem {r : α → β → Prop} {s : multiset α} {t : multiset β}\n  (h : rel r s t) :\n  ∀ {a : α} (ha : a ∈ s), ∃ b ∈ t, r a b :=\nbegin\n  induction h with x y s t hxy hst ih,\n  { simp },\n  { assume a ha,\n    cases mem_cons.1 ha with ha ha,\n    { exact ⟨y, mem_cons_self _ _, ha.symm ▸ hxy⟩ },\n    { rcases ih ha with ⟨b, hbt, hab⟩,\n      exact ⟨b, mem_cons.2 (or.inr hbt), hab⟩ } }\nend\n\nlemma rel_of_forall {m1 m2 : multiset α} {r : α → α → Prop} (h : ∀ a b, a ∈ m1 → b ∈ m2 → r a b)\n   (hc : card m1 = card m2) :\n   m1.rel r m2 :=\nbegin\n  revert m1,\n  apply m2.induction_on,\n  { intros m h hc,\n    rw [rel_zero_right, ← card_eq_zero, hc, card_zero] },\n  { intros a t ih m h hc,\n    rw card_cons at hc,\n    obtain ⟨b, hb⟩ := card_pos_iff_exists_mem.1 (show 0 < card m, from hc.symm ▸ (nat.succ_pos _)),\n    obtain ⟨m', rfl⟩ := exists_cons_of_mem hb,\n    refine rel_cons_right.mpr ⟨b, m', h _ _ hb (mem_cons_self _ _), ih _ _, rfl⟩,\n    { exact λ _ _ ha hb, h _ _ (mem_cons_of_mem ha) (mem_cons_of_mem hb) },\n    { simpa using hc } }\nend\n\nlemma rel_repeat_left {m : multiset α} {a : α} {r : α → α → Prop} {n : ℕ} :\n  (repeat a n).rel r m ↔ m.card = n ∧ ∀ x, x ∈ m → r a x :=\n⟨λ h, ⟨(card_eq_card_of_rel h).symm.trans (card_repeat _ _), λ x hx, begin\n    obtain ⟨b, hb1, hb2⟩ := exists_mem_of_rel_of_mem (rel_flip.2 h) hx,\n    rwa eq_of_mem_repeat hb1 at hb2,\n  end⟩,\n  λ h, rel_of_forall (λ x y hx hy, (eq_of_mem_repeat hx).symm ▸ (h.2 _ hy))\n  (eq.trans (card_repeat _ _) h.1.symm)⟩\n\nlemma rel_repeat_right {m : multiset α} {a : α} {r : α → α → Prop} {n : ℕ} :\n  m.rel r (repeat a n) ↔ m.card = n ∧ ∀ x, x ∈ m → r x a :=\nby { rw [← rel_flip], exact rel_repeat_left }\n\nlemma sum_le_sum_of_rel_le [ordered_add_comm_monoid α]\n  {m1 m2 : multiset α} (h : m1.rel (≤) m2) : m1.sum ≤ m2.sum :=\nbegin\n  induction h with _ _ _ _ rh _ rt,\n  { refl },\n  { rw [sum_cons, sum_cons],\n    exact add_le_add rh rt }\nend\n\nend rel\n\nsection sum_inequalities\n\nlemma le_sum_of_mem [canonically_ordered_add_monoid α] {m : multiset α} {a : α}\n  (h : a ∈ m) : a ≤ m.sum :=\nbegin\n  obtain ⟨m', rfl⟩ := exists_cons_of_mem h,\n  rw [sum_cons],\n  exact _root_.le_add_right (le_refl a),\nend\n\nvariables [ordered_add_comm_monoid α]\n\nlemma sum_map_le_sum\n  {m : multiset α} (f : α → α) (h : ∀ x, x ∈ m → f x ≤ x) : (m.map f).sum ≤ m.sum :=\nsum_le_sum_of_rel_le (rel_map_left.2 (rel_refl_of_refl_on h))\n\nlemma sum_le_sum_map\n  {m : multiset α} (f : α → α) (h : ∀ x, x ∈ m → x ≤ f x) : m.sum ≤ (m.map f).sum :=\n@sum_map_le_sum (order_dual α) _ _ f h\n\nlemma card_nsmul_le_sum {b : α}\n  {m : multiset α} (h : ∀ x, x ∈ m → b ≤ x) : (card m) • b ≤ m.sum :=\nbegin\n  rw [←multiset.sum_repeat, ←multiset.map_const],\n  exact sum_map_le_sum _ h,\nend\n\nlemma sum_le_card_nsmul {b : α}\n  {m : multiset α} (h : ∀ x, x ∈ m → x ≤ b) : m.sum ≤ (card m) • b :=\nbegin\n  rw [←multiset.sum_repeat, ←multiset.map_const],\n  exact sum_le_sum_map _ h,\nend\n\nend sum_inequalities\n\nsection map\n\ntheorem map_eq_map {f : α → β} (hf : function.injective f) {s t : multiset α} :\n  s.map f = t.map f ↔ s = t :=\nby { rw [← rel_eq, ← rel_eq, rel_map], simp only [hf.eq_iff] }\n\ntheorem map_injective {f : α → β} (hf : function.injective f) :\n  function.injective (multiset.map f) :=\nassume x y, (map_eq_map hf).1\n\nend map\n\nsection quot\n\ntheorem map_mk_eq_map_mk_of_rel {r : α → α → Prop} {s t : multiset α} (hst : s.rel r t) :\n s.map (quot.mk r) = t.map (quot.mk r) :=\nrel.rec_on hst rfl $ assume a b s t hab hst ih, by simp [ih, quot.sound hab]\n\ntheorem exists_multiset_eq_map_quot_mk {r : α → α → Prop} (s : multiset (quot r)) :\n  ∃t:multiset α, s = t.map (quot.mk r) :=\nmultiset.induction_on s ⟨0, rfl⟩ $\n  assume a s ⟨t, ht⟩, quot.induction_on a $ assume a, ht.symm ▸ ⟨a ::ₘ t, (map_cons _ _ _).symm⟩\n\ntheorem induction_on_multiset_quot\n  {r : α → α → Prop} {p : multiset (quot r) → Prop} (s : multiset (quot r)) :\n  (∀s:multiset α, p (s.map (quot.mk r))) → p s :=\nmatch s, exists_multiset_eq_map_quot_mk s with _, ⟨t, rfl⟩ := assume h, h _ end\n\nend quot\n\n/-! ### Disjoint multisets -/\n\n/-- `disjoint s t` means that `s` and `t` have no elements in common. -/\ndef disjoint (s t : multiset α) : Prop := ∀ ⦃a⦄, a ∈ s → a ∈ t → false\n\n@[simp] theorem coe_disjoint (l₁ l₂ : list α) : @disjoint α l₁ l₂ ↔ l₁.disjoint l₂ := iff.rfl\n\ntheorem disjoint.symm {s t : multiset α} (d : disjoint s t) : disjoint t s\n| a i₂ i₁ := d i₁ i₂\n\ntheorem disjoint_comm {s t : multiset α} : disjoint s t ↔ disjoint t s :=\n⟨disjoint.symm, disjoint.symm⟩\n\ntheorem disjoint_left {s t : multiset α} : disjoint s t ↔ ∀ {a}, a ∈ s → a ∉ t := iff.rfl\n\ntheorem disjoint_right {s t : multiset α} : disjoint s t ↔ ∀ {a}, a ∈ t → a ∉ s :=\ndisjoint_comm\n\ntheorem disjoint_iff_ne {s t : multiset α} : disjoint s t ↔ ∀ a ∈ s, ∀ b ∈ t, a ≠ b :=\nby simp [disjoint_left, imp_not_comm]\n\ntheorem disjoint_of_subset_left {s t u : multiset α} (h : s ⊆ u) (d : disjoint u t) : disjoint s t\n| x m₁ := d (h m₁)\n\ntheorem disjoint_of_subset_right {s t u : multiset α} (h : t ⊆ u) (d : disjoint s u) : disjoint s t\n| x m m₁ := d m (h m₁)\n\ntheorem disjoint_of_le_left {s t u : multiset α} (h : s ≤ u) : disjoint u t → disjoint s t :=\ndisjoint_of_subset_left (subset_of_le h)\n\ntheorem disjoint_of_le_right {s t u : multiset α} (h : t ≤ u) : disjoint s u → disjoint s t :=\ndisjoint_of_subset_right (subset_of_le h)\n\n@[simp] theorem zero_disjoint (l : multiset α) : disjoint 0 l\n| a := (not_mem_nil a).elim\n\n@[simp, priority 1100]\ntheorem singleton_disjoint {l : multiset α} {a : α} : disjoint {a} l ↔ a ∉ l :=\nby simp [disjoint]; refl\n\n@[simp, priority 1100]\ntheorem disjoint_singleton {l : multiset α} {a : α} : disjoint l {a} ↔ a ∉ l :=\nby rw [disjoint_comm, singleton_disjoint]\n\n@[simp] theorem disjoint_add_left {s t u : multiset α} :\n  disjoint (s + t) u ↔ disjoint s u ∧ disjoint t u :=\nby simp [disjoint, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_add_right {s t u : multiset α} :\n  disjoint s (t + u) ↔ disjoint s t ∧ disjoint s u :=\nby rw [disjoint_comm, disjoint_add_left]; tauto\n\n@[simp] theorem disjoint_cons_left {a : α} {s t : multiset α} :\n  disjoint (a ::ₘ s) t ↔ a ∉ t ∧ disjoint s t :=\n(@disjoint_add_left _ {a} s t).trans $ by rw singleton_disjoint\n\n@[simp] theorem disjoint_cons_right {a : α} {s t : multiset α} :\n  disjoint s (a ::ₘ t) ↔ a ∉ s ∧ disjoint s t :=\nby rw [disjoint_comm, disjoint_cons_left]; tauto\n\ntheorem inter_eq_zero_iff_disjoint [decidable_eq α] {s t : multiset α} : s ∩ t = 0 ↔ disjoint s t :=\nby rw ← subset_zero; simp [subset_iff, disjoint]\n\n@[simp] theorem disjoint_union_left [decidable_eq α] {s t u : multiset α} :\n  disjoint (s ∪ t) u ↔ disjoint s u ∧ disjoint t u :=\nby simp [disjoint, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_union_right [decidable_eq α] {s t u : multiset α} :\n  disjoint s (t ∪ u) ↔ disjoint s t ∧ disjoint s u :=\nby simp [disjoint, or_imp_distrib, forall_and_distrib]\n\nlemma add_eq_union_iff_disjoint [decidable_eq α] {s t : multiset α} :\n  s + t = s ∪ t ↔ disjoint s t :=\nby simp_rw [←inter_eq_zero_iff_disjoint, ext, count_add, count_union, count_inter, count_zero,\n            nat.min_eq_zero_iff, nat.add_eq_max_iff]\n\nlemma disjoint_map_map {f : α → γ} {g : β → γ} {s : multiset α} {t : multiset β} :\n  disjoint (s.map f) (t.map g) ↔ (∀a∈s, ∀b∈t, f a ≠ g b) :=\nby { simp [disjoint, @eq_comm _ (f _) (g _)], refl }\n\n/-- `pairwise r m` states that there exists a list of the elements s.t. `r` holds pairwise on this\nlist. -/\ndef pairwise (r : α → α → Prop) (m : multiset α) : Prop :=\n∃l:list α, m = l ∧ l.pairwise r\n\nlemma pairwise_coe_iff_pairwise {r : α → α → Prop} (hr : symmetric r) {l : list α} :\n  multiset.pairwise r l ↔ l.pairwise r :=\niff.intro\n  (assume ⟨l', eq, h⟩, ((quotient.exact eq).pairwise_iff hr).2 h)\n  (assume h, ⟨l, rfl, h⟩)\n\nend multiset\n\nnamespace multiset\n\nsection choose\nvariables (p : α → Prop) [decidable_pred p] (l : multiset α)\n\n/-- Given a proof `hp` that there exists a unique `a ∈ l` such that `p a`, `choose_x p l hp` returns\nthat `a` together with proofs of `a ∈ l` and `p a`. -/\ndef choose_x : Π hp : (∃! a, a ∈ l ∧ p a), { a // a ∈ l ∧ p a } :=\nquotient.rec_on l (λ l' ex_unique, list.choose_x p l' (exists_of_exists_unique ex_unique)) begin\n  intros,\n  funext hp,\n  suffices all_equal : ∀ x y : { t // t ∈ b ∧ p t }, x = y,\n  { apply all_equal },\n  { rintros ⟨x, px⟩ ⟨y, py⟩,\n    rcases hp with ⟨z, ⟨z_mem_l, pz⟩, z_unique⟩,\n    congr,\n    calc x = z : z_unique x px\n    ...    = y : (z_unique y py).symm }\nend\n\n/-- Given a proof `hp` that there exists a unique `a ∈ l` such that `p a`, `choose p l hp` returns\nthat `a`. -/\ndef choose (hp : ∃! a, a ∈ l ∧ p a) : α := choose_x p l hp\n\nlemma choose_spec (hp : ∃! a, a ∈ l ∧ p a) : choose p l hp ∈ l ∧ p (choose p l hp) :=\n(choose_x p l hp).property\n\nlemma choose_mem (hp : ∃! a, a ∈ l ∧ p a) : choose p l hp ∈ l := (choose_spec _ _ _).1\n\nlemma choose_property (hp : ∃! a, a ∈ l ∧ p a) : p (choose p l hp) := (choose_spec _ _ _).2\n\nend choose\n\nvariable (α)\n\n/-- The equivalence between lists and multisets of a subsingleton type. -/\ndef subsingleton_equiv [subsingleton α] : list α ≃ multiset α :=\n{ to_fun := coe,\n  inv_fun := quot.lift id $ λ (a b : list α) (h : a ~ b),\n    list.ext_le h.length_eq $ λ n h₁ h₂, subsingleton.elim _ _,\n  left_inv := λ l, rfl,\n  right_inv := λ m, quot.induction_on m $ λ l, rfl }\n\nvariable {α}\n\n@[simp]\nlemma coe_subsingleton_equiv [subsingleton α] :\n  (subsingleton_equiv α : list α → multiset α) = coe :=\nrfl\n\nend multiset\n\n@[to_additive]\ntheorem monoid_hom.map_multiset_prod [comm_monoid α] [comm_monoid β] (f : α →* β) (s : multiset α) :\n  f s.prod = (s.map f).prod :=\n(s.prod_hom f).symm\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/multiset/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.7490872187162396, "lm_q1q2_score": 0.4879216141094223}}
{"text": "import order.basic\nimport data.finset.lattice\nimport data.rat\n\nnamespace o_minimal\n\nset_option old_structure_cmd true\n\n/-- A DUNLO is a dense unbounded nonempty linear order.\nThis is the setting in which we can talk about o-minimal structures.\nSee [vdD], §1.3, first italicized paragraph.\n-/\nclass DUNLO (R : Type*) extends linear_order R :=\n[dense : densely_ordered R]\n[unbounded_below : no_bot_order R]\n[unbounded_above : no_top_order R]\n[nonempty : nonempty R]\n\n-- These classes are all `Prop`s so these instances should be harmless.\nattribute [instance] DUNLO.dense DUNLO.unbounded_below DUNLO.unbounded_above DUNLO.nonempty\n\ninstance : DUNLO ℚ :=\n{ .. show linear_order ℚ, by apply_instance }\n\n-- TODO: for_mathlib\n/-- In a DUNLO, a system of constraints Lᵢ < x, x < Uⱼ is solvable\nif and only if Lᵢ < Uⱼ for every i and j. Here i and j range over\npossibly empty finite sets I and J respectively.\n(In fact, this property characterizes DUNLOs.) -/\nlemma order_constraints_feasible_iff {R : Type*} [DUNLO R] (lower upper : finset R) :\n  (∃ x, (∀ g ∈ lower, g < x) ∧ (∀ h ∈ upper, x < h)) ↔\n  ∀ (g ∈ lower) (h ∈ upper), g < h :=\nbegin\n  split,\n  { rintro ⟨x, hx₁, hx₂⟩ g Hg h Hh,\n    exact lt_trans (hx₁ g Hg) (hx₂ h Hh) },\n  { -- TODO: maybe reformulate all this into a useful lemma:\n    -- (s : finset R) : s = ∅ ∨ ∃ max ∈ s, ∀ i ∈ s, i ≤ max\n    -- Pretty similar to `exists_max_image`.\n    cases hlower : lower.max with lmax;\n      [{ rw finset.max_eq_none at hlower, subst lower },\n       { have le_lmax : ∀ g ∈ lower, g ≤ lmax,\n         { intros g H, apply finset.le_max_of_mem H hlower } }],\n    all_goals {                 -- TODO: can't we write it using `;`?\n    cases hupper : upper.min with umin;\n      [{ rw finset.min_eq_none at hupper, subst upper },\n       { have umin_le : ∀ h ∈ upper, umin ≤ h,\n         { intros h H, apply finset.min_le_of_mem H hupper } }] },\n    { simp },\n    { suffices : ∃ (x : R), ∀ (h : R), h ∈ upper → x < h, { simpa },\n      obtain ⟨x, hx⟩ := no_bot umin,\n      exact ⟨x, λ h H, lt_of_lt_of_le hx (umin_le h H)⟩ },\n    { suffices : ∃ (x : R), ∀ (g : R), g ∈ lower → g < x, { simpa },\n      obtain ⟨x, hx⟩ := no_top lmax,\n      exact ⟨x, λ g H, lt_of_le_of_lt (le_lmax g H) hx⟩ },\n    { intro Hgh,\n      specialize Hgh lmax (finset.mem_of_max hlower) umin (finset.mem_of_min hupper),\n      obtain ⟨x, hx₁, hx₂⟩ := exists_between Hgh,\n      exact ⟨x,\n        λ g H, lt_of_le_of_lt (le_lmax g H) hx₁,\n        λ h H, lt_of_lt_of_le hx₂ (umin_le h H)⟩ } }\nend\n\nend o_minimal\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/src/o_minimal/dunlo.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.4879216053911326}}
{"text": "-- import data.set\nimport tactic\n\n-- dEAduction imports\nimport structures2\n\n-- General principles :\n-- Type should be defined as parameters, in order to be implicit everywhere\n-- other parameters are implicit in definitions, i.e. defined using '{}' (e.g. {A : set X} )\n-- but explicit everywhere else, i.e. defined using '()' (e.g. (A : set X) )\n-- each definition must be an iff statement (since it will be called with 'rw' or 'symp_rw')\n\n-- no Magic button (\"compute\")\n/- dEAduction\nDefaultAvailableProof\n    NONE\nDefaultAvailableMagic\n    Assumption\n-/\n\n\n-- logic names ['and', 'or', 'negate', 'implicate', 'iff', 'forall', 'exists']\n-- proofs names ['proof_methods', 'new_object', 'apply']\n-- magic names ['compute', 'assumption']\n\n\nlocal attribute [instance] classical.prop_decidable\n---------------------------------------------\n-- global parameters = implicit variables --\n---------------------------------------------\nsection course\nvariables (P Q R: Prop) -- NOT global\nnotation [parsing_only] P ` \\and ` Q := P ∧ Q\nnotation [parsing_only]  P ` \\or ` Q := P ∨ Q\nnotation [parsing_only]  ` \\not ` P := ¬ P\nnotation [parsing_only]  P ` \\implies ` Q := P → Q\nnotation [parsing_only]  P ` \\iff ` Q := P ↔ Q\n\n\n------------------\n-- COURSE TITLE --\n------------------\nnamespace Logique_propositionnelle\n\nlemma exercise.tautologie :\nP → P\n:=\n/- dEAduction\nPrettyName\n    La tautologie\nDescription\n    Le bouton \"=>\" permet de démontrer une implication : pour montrer\n    \"P => Q\", on suppose P, et on montre Q.\nAvailableLogic\n    implicate\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.et :\nP ∧ Q → P\n:=\n/- dEAduction\nPrettyName\n    P et Q implique P\nDescription\n    Le bouton \"ET\" permet de découper une hypothèse\nAvailableLogic\n    and implicate\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.et_commutatif_I :\nP ∧ Q → Q ∧ P\n:=\n/- dEAduction\nPrettyName\n    Le \"ET\" est commutatif (version faible)\nDescription\n    Le bouton \"ET\" permet aussi de découper le but en deux buts distincts\nAvailableLogic\n    and implicate\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.et_commutatif_II :\nP ∧ Q ↔ Q ∧ P\n:=\n/- dEAduction\nPrettyName\n    Le \"ET\" est commutatif\nDescription\n    Le bouton \"↔\" permet de découper le but en deux implications.\n    On peut alors appliquer le résultat de l'exercice précédent en le\n    sélectionnant dans la liste...\nAvailableLogic\n    and iff implicate\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.ou_commutatif :\nP ∨ Q ↔ Q ∨ P\n:=\n/- dEAduction\nPrettyName\n    Le \"OU\" est commutatif\nDescription\n    Pour utiliser l'hypothèse \"P OU Q\", on sépare les cas :\n    dans le premier cas on suppose P, dans le second cas on suppose Q.\n    Pour démontrer \"Q OU P\", on doit démontrer soit P, soit Q.\nAvailableLogic\n    and or implicate iff\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.non_non :\n¬ ¬ P ↔ P\n:=\n/- dEAduction\nPrettyName\n    Double négation\nDescription\n    Le bouton \"NON\" permet d'utiliser les règles logiques du \"NON\".\n    On peut l'utiliser uniquement sur les propriétés qui sont des négations,\n    c'est-à-dire de la forme \"NON (...)\".\nAvailableLogic\n    and or negate implicate iff\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.non_ET :\n¬ (P ∧ Q) ↔ (¬ P) ∨ (¬ Q)\n:=\n/- dEAduction\nPrettyName\n    Négation d'un \"ET\"\nDescription\n    En général, le bouton \"NON\" tente de \"pousser\" la négation le long de la\n    propriété.\nAvailableLogic\n    and or negate implicate iff\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\n\nlemma exercise.contradiction :\nR ∨ ¬ R\n:=\n/- dEAduction\nPrettyName\n    Le tiers exclu : l'une des deux propriétés \"R\" et \"NON R\" est vraie\nDescription\n    Le mécanisme de preuve inclus le tiers exclu, de façon un peu cachée...\nAvailableLogic\n    and or negate implicate iff\nAvailableProof\n    use_proof_methods\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.contraposition :\n(P → Q) ↔ (¬ Q → ¬ P)\n:=\n/- dEAduction\nPrettyName\n    Contraposition\nDescription\n    Le bouton \"=>\" permet également d'appliquer une implication \"P => Q\" à la\n    propriété \"P\" pour obtenir la propriété \"Q\". Attention, avant de\n    l'actionner il faut sélectionner toutes les propriétés requises !\nAvailableLogic\n    and or negate implicate iff\nAvailableProof\n    use_proof_methods apply\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.ou_implication_I :\n(P → Q) ↔ (¬ P ∨ Q)\n:=\n/- dEAduction\nPrettyName\n    Implication sous forme de \"OU\"\nDescription\n    Cette propriété permet de transformer une implication en une disjonction\nAvailableLogic\n    and or negate implicate iff\nAvailableProof\n    use_proof_methods apply\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.ou_implication_II :\n(P ∨ Q) ↔ (¬ P → Q)\n:=\n/- dEAduction\nPrettyName\n    \"OU\" sous forme d'implication\nDescription\n    Cette propriété est très proche de la précédente.\n    On peut la redémontrer entièrement, mais on peut aussi tenter d'appliquer\n    le résultat de l'exercice précédent. Pour cela, il faudra introduire\n    un nouvel objet, avant de lui appliquer le résultat précédent...\nAvailableLogic\n    and or negate implicate iff\nAvailableProof\n    use_proof_methods new_object apply\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\n\n\nend Logique_propositionnelle\n\nend course\n\n", "meta": {"author": "dEAduction", "repo": "dEAduction-lean", "sha": "4fe1d642078fc94f9081ccbed08e047e86a741fd", "save_path": "github-repos/lean/dEAduction-dEAduction-lean", "path": "github-repos/lean/dEAduction-dEAduction-lean/dEAduction-lean-4fe1d642078fc94f9081ccbed08e047e86a741fd/snippets/exercises_under_design/exercices_logique_propositionnelle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.4879216053911326}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module topology.local_at_target\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Topology.Sets.Opens\n\n/-!\n# Properties of maps that are local at the target.\n\nWe show that the following properties of continuous maps are local at the target :\n- `inducing`\n- `embedding`\n- `open_embedding`\n- `closed_embedding`\n\n-/\n\n\nopen TopologicalSpace Set Filter\n\nopen Topology Filter\n\nvariable {α β : Type _} [TopologicalSpace α] [TopologicalSpace β] {f : α → β}\n\nvariable {s : Set β} {ι : Type _} {U : ι → Opens β} (hU : supᵢ U = ⊤)\n\ntheorem Set.restrictPreimage_inducing (s : Set β) (h : Inducing f) :\n    Inducing (s.restrictPreimage f) :=\n  by\n  simp_rw [inducing_coe.inducing_iff, inducing_iff_nhds, restrict_preimage, maps_to.coe_restrict,\n    restrict_eq, ← @Filter.comap_comap _ _ _ _ coe f] at h⊢\n  intro a\n  rw [← h, ← inducing_coe.nhds_eq_comap]\n#align set.restrict_preimage_inducing Set.restrictPreimage_inducing\n\nalias Set.restrictPreimage_inducing ← Inducing.restrictPreimage\n#align inducing.restrict_preimage Inducing.restrictPreimage\n\ntheorem Set.restrictPreimage_embedding (s : Set β) (h : Embedding f) :\n    Embedding (s.restrictPreimage f) :=\n  ⟨h.1.restrictPreimage s, h.2.restrictPreimage s⟩\n#align set.restrict_preimage_embedding Set.restrictPreimage_embedding\n\nalias Set.restrictPreimage_embedding ← Embedding.restrictPreimage\n#align embedding.restrict_preimage Embedding.restrictPreimage\n\ntheorem Set.restrictPreimage_openEmbedding (s : Set β) (h : OpenEmbedding f) :\n    OpenEmbedding (s.restrictPreimage f) :=\n  ⟨h.1.restrictPreimage s,\n    (s.range_restrictPreimage f).symm ▸ continuous_subtype_val.isOpen_preimage _ h.2⟩\n#align set.restrict_preimage_open_embedding Set.restrictPreimage_openEmbedding\n\nalias Set.restrictPreimage_openEmbedding ← OpenEmbedding.restrictPreimage\n#align open_embedding.restrict_preimage OpenEmbedding.restrictPreimage\n\ntheorem Set.restrictPreimage_closedEmbedding (s : Set β) (h : ClosedEmbedding f) :\n    ClosedEmbedding (s.restrictPreimage f) :=\n  ⟨h.1.restrictPreimage s,\n    (s.range_restrictPreimage f).symm ▸ inducing_subtype_val.isClosed_preimage _ h.2⟩\n#align set.restrict_preimage_closed_embedding Set.restrictPreimage_closedEmbedding\n\nalias Set.restrictPreimage_closedEmbedding ← ClosedEmbedding.restrictPreimage\n#align closed_embedding.restrict_preimage ClosedEmbedding.restrictPreimage\n\ntheorem Set.restrictPreimage_isClosedMap (s : Set β) (H : IsClosedMap f) :\n    IsClosedMap (s.restrictPreimage f) :=\n  by\n  rintro t ⟨u, hu, e⟩\n  refine' ⟨⟨_, (H _ (IsOpen.isClosed_compl hu)).1, _⟩⟩\n  rw [← (congr_arg HasCompl.compl e).trans (compl_compl t)]\n  simp only [Set.preimage_compl, compl_inj_iff]\n  ext ⟨x, hx⟩\n  suffices (∃ y, y ∉ u ∧ f y = x) ↔ ∃ y, f y ∈ s ∧ y ∉ u ∧ f y = x by\n    simpa [Set.restrictPreimage, ← Subtype.coe_inj]\n  exact ⟨fun ⟨a, b, c⟩ => ⟨a, c.symm ▸ hx, b, c⟩, fun ⟨a, _, b, c⟩ => ⟨a, b, c⟩⟩\n#align set.restrict_preimage_is_closed_map Set.restrictPreimage_isClosedMap\n\ninclude hU\n\ntheorem isOpen_iff_inter_of_supᵢ_eq_top (s : Set β) : IsOpen s ↔ ∀ i, IsOpen (s ∩ U i) :=\n  by\n  constructor\n  · exact fun H i => H.inter (U i).2\n  · intro H\n    have : (⋃ i, (U i : Set β)) = Set.univ :=\n      by\n      convert congr_arg coe hU\n      simp\n    rw [← s.inter_univ, ← this, Set.inter_unionᵢ]\n    exact isOpen_unionᵢ H\n#align is_open_iff_inter_of_supr_eq_top isOpen_iff_inter_of_supᵢ_eq_top\n\ntheorem isOpen_iff_coe_preimage_of_supᵢ_eq_top (s : Set β) :\n    IsOpen s ↔ ∀ i, IsOpen (coe ⁻¹' s : Set (U i)) :=\n  by\n  simp_rw [(U _).2.openEmbedding_subtype_val.open_iff_image_open, Set.image_preimage_eq_inter_range,\n    Subtype.range_coe]\n  apply isOpen_iff_inter_of_supᵢ_eq_top\n  assumption\n#align is_open_iff_coe_preimage_of_supr_eq_top isOpen_iff_coe_preimage_of_supᵢ_eq_top\n\ntheorem isClosed_iff_coe_preimage_of_supᵢ_eq_top (s : Set β) :\n    IsClosed s ↔ ∀ i, IsClosed (coe ⁻¹' s : Set (U i)) := by\n  simpa using isOpen_iff_coe_preimage_of_supᵢ_eq_top hU (sᶜ)\n#align is_closed_iff_coe_preimage_of_supr_eq_top isClosed_iff_coe_preimage_of_supᵢ_eq_top\n\ntheorem isClosedMap_iff_isClosedMap_of_supᵢ_eq_top :\n    IsClosedMap f ↔ ∀ i, IsClosedMap ((U i).1.restrictPreimage f) :=\n  by\n  refine' ⟨fun h i => Set.restrictPreimage_isClosedMap _ h, _⟩\n  rintro H s hs\n  rw [isClosed_iff_coe_preimage_of_supᵢ_eq_top hU]\n  intro i\n  convert H i _ ⟨⟨_, hs.1, eq_compl_comm.mpr rfl⟩⟩\n  ext ⟨x, hx⟩\n  suffices (∃ y, y ∈ s ∧ f y = x) ↔ ∃ y, f y ∈ U i ∧ y ∈ s ∧ f y = x by\n    simpa [Set.restrictPreimage, ← Subtype.coe_inj]\n  exact ⟨fun ⟨a, b, c⟩ => ⟨a, c.symm ▸ hx, b, c⟩, fun ⟨a, _, b, c⟩ => ⟨a, b, c⟩⟩\n#align is_closed_map_iff_is_closed_map_of_supr_eq_top isClosedMap_iff_isClosedMap_of_supᵢ_eq_top\n\ntheorem inducing_iff_inducing_of_supᵢ_eq_top (h : Continuous f) :\n    Inducing f ↔ ∀ i, Inducing ((U i).1.restrictPreimage f) :=\n  by\n  simp_rw [inducing_coe.inducing_iff, inducing_iff_nhds, restrict_preimage, maps_to.coe_restrict,\n    restrict_eq, ← @Filter.comap_comap _ _ _ _ coe f]\n  constructor\n  · intro H i x\n    rw [← H, ← inducing_coe.nhds_eq_comap]\n  · intro H x\n    obtain ⟨i, hi⟩ :=\n      opens.mem_supr.mp\n        (show f x ∈ supᵢ U by\n          rw [hU]\n          triv)\n    erw [← OpenEmbedding.map_nhds_eq (h.1 _ (U i).2).openEmbedding_subtype_val ⟨x, hi⟩]\n    rw [(H i) ⟨x, hi⟩, Filter.subtype_coe_map_comap, Function.comp_apply, Subtype.coe_mk,\n      inf_eq_left, Filter.le_principal_iff]\n    exact Filter.preimage_mem_comap ((U i).2.mem_nhds hi)\n#align inducing_iff_inducing_of_supr_eq_top inducing_iff_inducing_of_supᵢ_eq_top\n\ntheorem embedding_iff_embedding_of_supᵢ_eq_top (h : Continuous f) :\n    Embedding f ↔ ∀ i, Embedding ((U i).1.restrictPreimage f) :=\n  by\n  simp_rw [embedding_iff]\n  rw [forall_and]\n  apply and_congr\n  · apply inducing_iff_inducing_of_supᵢ_eq_top <;> assumption\n  · apply Set.injective_iff_injective_of_unionᵢ_eq_univ\n    convert congr_arg coe hU\n    simp\n#align embedding_iff_embedding_of_supr_eq_top embedding_iff_embedding_of_supᵢ_eq_top\n\ntheorem openEmbedding_iff_openEmbedding_of_supᵢ_eq_top (h : Continuous f) :\n    OpenEmbedding f ↔ ∀ i, OpenEmbedding ((U i).1.restrictPreimage f) :=\n  by\n  simp_rw [openEmbedding_iff]\n  rw [forall_and]\n  apply and_congr\n  · apply embedding_iff_embedding_of_supᵢ_eq_top <;> assumption\n  · simp_rw [Set.range_restrictPreimage]\n    apply isOpen_iff_coe_preimage_of_supᵢ_eq_top hU\n#align open_embedding_iff_open_embedding_of_supr_eq_top openEmbedding_iff_openEmbedding_of_supᵢ_eq_top\n\ntheorem closedEmbedding_iff_closedEmbedding_of_supᵢ_eq_top (h : Continuous f) :\n    ClosedEmbedding f ↔ ∀ i, ClosedEmbedding ((U i).1.restrictPreimage f) :=\n  by\n  simp_rw [closedEmbedding_iff]\n  rw [forall_and]\n  apply and_congr\n  · apply embedding_iff_embedding_of_supᵢ_eq_top <;> assumption\n  · simp_rw [Set.range_restrictPreimage]\n    apply isClosed_iff_coe_preimage_of_supᵢ_eq_top hU\n#align closed_embedding_iff_closed_embedding_of_supr_eq_top closedEmbedding_iff_closedEmbedding_of_supᵢ_eq_top\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/LocalAtTarget.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7490872131147276, "lm_q1q2_score": 0.4879216003214152}}
{"text": "import tactic\nimport combinatorics.simple_graph.connectivity\nimport graph_theory.basic graph_theory.pushforward\nopen relation relation.refl_trans_gen\n\nnamespace simple_graph\n\nvariables {V V' : Type*} {G G₁ G₂ : simple_graph V} {G' : simple_graph V'} {u v x y z : V}\nvariables {e : G.dart} {p : walk G x y} {p' : walk G y z} {p'' : walk G z u}\nvariables {h : G.adj y z} {h' : G.adj u x} {h'' : G.adj z v}\n\nnamespace walk\n\ninfixr ` :: ` := cons\ninfix  ` ++ ` := append\n\nlemma point_of_size_0 : p.length = 0 → x = y :=\nby { intro h, cases p, refl, contradiction }\n\nlemma mem_edges (h : e ∈ darts p) : e.fst ∈ p.support ∧ e.snd ∈ p.support :=\n⟨p.dart_fst_mem_support_of_mem_darts h, p.dart_snd_mem_support_of_mem_darts h⟩\n\nlemma mem_of_edges (h : 0 < p.length) : u ∈ p.support ↔ ∃ e ∈ darts p, u ∈ dart.edge e :=\nbegin\n  induction p with u u v w h p ih,\n  { simp only [length_nil, nat.not_lt_zero] at h, contradiction },\n  { clear h, cases nat.eq_zero_or_pos (length p),\n    { cases p,\n      simp only [darts, dart.edge, support_cons, support_nil, list.mem_cons_iff,\n        list.mem_singleton, sym2.mem_iff, exists_prop, exists_eq_left],\n      simp only [length_cons, nat.succ_ne_zero] at h_1, contradiction },\n    { specialize ih h_1, clear h_1, simp only [dart.edge, sym2.mem_iff] at ih, split,\n      { simp only [darts, dart.edge, support_cons, list.mem_cons_iff, sym2.mem_iff, exists_prop],\n        intro h1, cases h1,\n        { subst h1, use ⟨(u,v),h⟩, simp only [eq_self_iff_true, and_self, true_or, sym2.mem_iff] },\n        { obtain ⟨e,h2,h3⟩ := ih.mp h1, exact ⟨e, or.inr h2, h3⟩ } },\n      { simp only [darts, dart.edge, list.mem_cons_iff, sym2.mem_iff, support_cons,\n        forall_exists_index, and_imp, forall_eq_or_imp],\n        exact ⟨(λ h, or.cases_on h or.inl (λ h, by { subst h, exact or.inr (start_mem_support _) })),\n        (λ e he h1, or.inr (ih.mpr ⟨e,he,h1⟩))⟩ } } }\nend\n\nlemma nodup_concat : (append p p').support.nodup ↔\n  p.support.nodup ∧ p'.support.nodup ∧ (∀ u, u ∈ p.support → u ∈ p'.support → u = y) :=\nbegin\n  induction p with a a b c h q ih,\n  { simp },\n  { simp only [cons_append, support_cons, list.nodup_cons, mem_support_append_iff,\n    list.mem_cons_iff, forall_eq_or_imp],\n    push_neg, split,\n    { rintros ⟨⟨h1,h2⟩,h3⟩, replace ih := ih.mp h3, refine ⟨⟨h1,ih.1⟩,ih.2.1,_,λ u h4 h5, _⟩,\n      intro, contradiction, exact ih.2.2 u h4 h5 },\n    { rintros ⟨⟨h1,h2⟩,h3,h4,h5⟩, refine ⟨⟨h1,_⟩,_⟩,\n      intro h5, apply h1, rw h4 h5, exact end_mem_support _,\n      refine ih.mpr ⟨h2,h3,_⟩, intros u hu h'u, exact h5 u hu h'u } }\nend\n\nend walk\nend simple_graph\n", "meta": {"author": "vbeffara", "repo": "lean", "sha": "0004b1d502ac3f4ccd213dbd23589d4c4f9fece8", "save_path": "github-repos/lean/vbeffara-lean", "path": "github-repos/lean/vbeffara-lean/lean-0004b1d502ac3f4ccd213dbd23589d4c4f9fece8/src/graph_theory/path.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.48792160032141507}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport category_theory.single_obj\nimport category_theory.limits.shapes.products\nimport category_theory.pi.basic\nimport category_theory.limits.is_limit\n\n/-!\n# Category of groupoids\n\nThis file contains the definition of the category `Groupoid` of all groupoids.\nIn this category objects are groupoids and morphisms are functors\nbetween these groupoids.\n\nWe also provide two “forgetting” functors: `objects : Groupoid ⥤ Type`\nand `forget_to_Cat : Groupoid ⥤ Cat`.\n\n## Implementation notes\n\nThough `Groupoid` is not a concrete category, we use `bundled` to define\nits carrier type.\n-/\n\nuniverses v u\n\nnamespace category_theory\n\n/-- Category of groupoids -/\n@[nolint check_univs] -- intended to be used with explicit universe parameters\ndef Groupoid := bundled groupoid.{v u}\n\nnamespace Groupoid\n\ninstance : inhabited Groupoid := ⟨bundled.of (single_obj punit)⟩\n\ninstance str (C : Groupoid.{v u}) : groupoid.{v u} C.α := C.str\n\ninstance : has_coe_to_sort Groupoid Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `Groupoid` from the underlying type and the typeclass. -/\ndef of (C : Type u) [groupoid.{v} C] : Groupoid.{v u} := bundled.of C\n\n@[simp] lemma coe_of (C : Type u) [groupoid C] : (of C : Type u) = C := rfl\n\n/-- Category structure on `Groupoid` -/\ninstance category : large_category.{max v u} Groupoid.{v u} :=\n{ hom := λ C D, C ⥤ D,\n  id := λ C, 𝟭 C,\n  comp := λ C D E F G, F ⋙ G,\n  id_comp' := λ C D F, by cases F; refl,\n  comp_id' := λ C D F, by cases F; refl,\n  assoc' := by intros; refl }\n\n/-- Functor that gets the set of objects of a groupoid. It is not\ncalled `forget`, because it is not a faithful functor. -/\ndef objects : Groupoid.{v u} ⥤ Type u :=\n{ obj := bundled.α,\n  map := λ C D F, F.obj }\n\n/-- Forgetting functor to `Cat` -/\ndef forget_to_Cat : Groupoid.{v u} ⥤ Cat.{v u} :=\n{ obj := λ C, Cat.of C,\n  map := λ C D, id }\n\ninstance forget_to_Cat_full : full forget_to_Cat :=\n{ preimage := λ C D, id }\n\ninstance forget_to_Cat_faithful : faithful forget_to_Cat := { }\n\n/-- Convert arrows in the category of groupoids to functors,\nwhich sometimes helps in applying simp lemmas -/\nlemma hom_to_functor {C D E : Groupoid.{v u}} (f : C ⟶ D) (g : D ⟶ E) : f ≫ g = f ⋙ g := rfl\n\n/-- Converts identity in the category of groupoids to the functor identity -/\nlemma id_to_functor {C : Groupoid.{v u}} : 𝟭 C = 𝟙 C := rfl\n\nsection products\n\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- Construct the product over an indexed family of groupoids, as a fan. -/\ndef pi_limit_fan ⦃J : Type u⦄ (F : J → Groupoid.{u u}) : limits.fan F :=\nlimits.fan.mk (@of (Π j : J, F j) _) (λ j, category_theory.pi.eval _ j)\n\n/-- The product fan over an indexed family of groupoids, is a limit cone. -/\ndef pi_limit_fan_is_limit ⦃J : Type u⦄ (F : J → Groupoid.{u u}) :\n  limits.is_limit (pi_limit_fan F) :=\nlimits.mk_fan_limit (pi_limit_fan F)\n(λ s, functor.pi' (λ j, s.proj j))\n(by { intros, dunfold pi_limit_fan, simp [hom_to_functor], })\nbegin\n  intros s m w,\n  apply functor.pi_ext,\n  intro j, specialize w j,\n  simpa,\nend\n\ninstance has_pi : limits.has_products Groupoid.{u u} :=\nlimits.has_products_of_limit_fans pi_limit_fan pi_limit_fan_is_limit\n\n/-- The product of a family of groupoids is isomorphic\nto the product object in the category of Groupoids -/\nnoncomputable def pi_iso_pi (J : Type u) (f : J → Groupoid.{u u}) : @of (Π j, f j) _ ≅ ∏ f :=\nlimits.is_limit.cone_point_unique_up_to_iso\n  (pi_limit_fan_is_limit f)\n  (limits.limit.is_limit (discrete.functor f))\n\n@[simp]\nlemma pi_iso_pi_hom_π (J : Type u) (f : J → Groupoid.{u u}) (j : J) :\n  (pi_iso_pi J f).hom ≫ (limits.pi.π f j) = category_theory.pi.eval _ j :=\nby { simp [pi_iso_pi], refl, }\n\nend products\n\nend Groupoid\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/category/Groupoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.48792160032141507}}
{"text": "/-\nAuthor: <Redacted for anonymized submission>\n-/\n-- import snarks.groth16.declarations\nimport ...attributes\nimport ...integral_domain_tactic\nimport ...general_lemmas.polynomial_degree\nimport ...general_lemmas.monomial_pow\nimport data.mv_polynomial.basic\nimport data.mv_polynomial.funext\nimport data.polynomial.field_division\nimport algebra.polynomial.big_operators\n-- import ...attributes\nimport .vars\n\n/-!\n# Knowledge Soundness\n\nThis file proves the knowledge-soundness property of the Groth16 system for type III pairings, as \npresented in \"Another Look at Extraction and Randomization of Groth’s zk-SNARK\" by \n[Baghery et al.](https://eprint.iacr.org/2020/811.pdf).\n\n-/\n\nopen_locale big_operators classical\n\nsection lipmaa\n\n-- TODO we open mv_polynomial, so we should be able to delete a lot of `mv_polynomial.`\nopen mv_polynomial\n\nnoncomputable theory\n\nuniverses u\n\n\n/-- The finite field parameter of our SNARK -/\nparameter {F : Type u}\nparameter [field F]\n\n/-- The naturals representing:\n  n_stmt - the statement size, \n  n_wit - the witness size -/ \nparameters {n_stmt n_wit n_var : ℕ}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt → (polynomial F) }\nparameter {u_wit : fin n_wit → (polynomial F) }\nparameter {v_stmt : fin n_stmt → (polynomial F) }\nparameter {v_wit : fin n_wit → (polynomial F) }\nparameter {w_stmt : fin n_stmt → (polynomial F) }\nparameter {w_wit : fin n_wit → (polynomial F) }\n\n-- Defined as integers the exponents are:\n-- def α := 0 \n-- def β := 1\n-- def γ := −6\n-- def δ := 4\n-- def η := −1\n\n-- To sidestep the use of Laurent Polynomials, we instead use\ndef α : ℕ := 6 \ndef β : ℕ := 7\ndef γ : ℕ := 0\ndef δ : ℕ := 10\ndef η : ℕ := 5\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit → F} \n/-- l is the polynomial divisibility by which is used to verify satisfaction of the QAP -/\ndef l : polynomial F := ∏ i in (finset.fin_range n_wit), (polynomial.X - polynomial.C (r i))\n-- TODO this could potentially be spun off into a mathlib definition\n\n\n/-- Checks whether a statement witness pair satisfies the QAP -/\ndef satisfying (a_stmt : fin n_stmt → F ) (a_wit : fin n_wit → F) := \n((∑ i in (finset.fin_range n_stmt), a_stmt i • u_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • u_wit i))\n  * \n(∑ i in (finset.fin_range n_stmt), a_stmt i • v_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • v_wit i))\n  -\n(∑ i in (finset.fin_range n_stmt), a_stmt i • w_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • w_wit i)))\n   %ₘ l = 0\n\nrun_cmd mk_simp_attr `crs\nrun_cmd tactic.add_doc_string `simp_attr.crs \"Attribute for defintions of CRS elements\"\n\n/-- The modified CRS elements, see fig 3 of the paper  -/\n@[crs]\ndef crs'_P_all_wit_1 (i : fin n_wit) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (β - α + δ) * C (u_wit i) \n + (X vars.y) ^ (β - α + γ) * C (v_wit i) \n + (X vars.y) ^ (2 * β - α) * C (w_wit i) \n@[crs]\ndef crs'_P_α_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ α\n@[crs]\ndef crs'_P_powers_1 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ β * C (polynomial.X ^ (i : ℕ)) \n@[crs]\ndef crs'_P_l_1 (i : fin (n_var - 1)) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (2 * β - α) * C l * C (polynomial.X ^ (i : ℕ)) \n-- @[crs]\n-- def crs'_P_γ_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ γ\n@[crs]\ndef crs'_P_δ_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ δ\n@[crs]\ndef crs'_P_se_α_z_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ α * (X vars.z) -- Only in S_qap^se\n@[crs]\ndef crs'_P_se_powers_1 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ β * (X vars.z) * C (polynomial.X ^ (i : ℕ))  -- Only in S_qap^se\n-- @[crs]\n-- def crs'_P_α_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ α\n@[crs]\ndef crs'_P_powers_2 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ β * C (polynomial.X ^ (i : ℕ)) -- same as crs'_P_powers_1\n\n@[crs]\ndef crs'_V_all_stmt_1 (i : fin n_stmt) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (β - η + δ) * C (u_stmt i) \n + (X vars.y) ^ (β - η + γ) * C (v_stmt i) \n + (X vars.y) ^ (2 * β - η) * C (w_stmt i) \n-- @[crs]\n-- def crs'_V_γ_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ γ -- Same as crs'_P_γ_1\n@[crs]\ndef crs'_V_se_z_1 : mv_polynomial vars (polynomial F) := \n  (X vars.z) -- Only in S_qap^se\n-- @[crs]\n-- def crs'_V_α_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ α\n@[crs]\ndef crs'_V_δ_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ δ\n@[crs]\ndef crs'_V_η_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ η\n@[crs]\ndef crs'_V_γ_δ_T : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ (γ + δ)\n\n-- Elements both prover and verifier use\n\n@[crs]\ndef crs'_γ_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ γ\n@[crs]\ndef crs'_α_2 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ α\n\n\nparameters {A_comp_crs'_P_all_wit_1 : fin n_wit → F}\nparameters {A_comp_crs'_P_α_1 : F}\nparameters {A_comp_crs'_P_powers_1 : fin n_var → F}\nparameters {A_comp_crs'_P_l_1 : fin (n_var - 1) → F}\nparameters {A_comp_crs'_γ_1 : F}\nparameters {A_comp_crs'_P_δ_1 : F}\n-- parameters {A_comp_crs'_P_se_α_z_1 : F}\n-- parameters {A_comp_crs'_P_se_powers_1 : fin n_var → F}\nparameters {A_comp_crs'_V_all_stmt_1 : fin n_stmt → F}\n-- parameters {A_comp_crs'_V_γ_1 : F} -- Same as previous\n-- parameters {A_comp_crs'_V_se_z_1 : F}\n\n\n/-- Polynomial form of A in the adversary's proof representation -/\ndef A' : mv_polynomial vars (polynomial F) := \n  ∑ i in (finset.fin_range n_wit), (crs'_P_all_wit_1 i) * C (polynomial.C (A_comp_crs'_P_all_wit_1 i))\n  +\n  crs'_P_α_1 * C (polynomial.C (A_comp_crs'_P_α_1))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  ∑ i in (finset.fin_range (n_var - 1)), (crs'_P_l_1 i) * C (polynomial.C (A_comp_crs'_P_l_1 i))\n  +\n  crs'_γ_1 * C (polynomial.C (A_comp_crs'_γ_1))\n  +\n  crs'_P_δ_1 * C (polynomial.C (A_comp_crs'_P_δ_1))\n  +\n  ∑ i in (finset.fin_range n_stmt), (crs'_V_all_stmt_1 i) * C (polynomial.C (A_comp_crs'_V_all_stmt_1 i))\n\n\nparameters {B_comp_crs'_α_2 : F}\nparameters {B_comp_crs'_P_powers_2 : fin n_var → F}\n-- parameters {B_comp_crs'_V_α_2 : F} -- Same as previous\nparameters {B_comp_crs'_V_δ_2 : F}\nparameters {B_comp_crs'_V_η_2 : F}\n\n/-- Polynomial form of B in the adversary's proof representation -/\ndef B' : mv_polynomial vars (polynomial F) := \n  crs'_α_2 * C (polynomial.C (B_comp_crs'_α_2))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_2 i) * C (polynomial.C (B_comp_crs'_P_powers_2 i))\n  +\n  crs'_V_δ_2 * C (polynomial.C (B_comp_crs'_V_δ_2))\n  +\n  crs'_V_η_2 * C (polynomial.C (B_comp_crs'_V_η_2))\n\n\nparameters {C_comp_crs'_P_all_wit_1 : fin n_wit → F}\nparameters {C_comp_crs'_P_α_1 : F}\nparameters {C_comp_crs'_P_powers_1 : fin n_var → F}\nparameters {C_comp_crs'_P_l_1 : fin (n_var - 1) → F}\nparameters {C_comp_crs'_P_γ_1 : F}\nparameters {C_comp_crs'_P_δ_1 : F}\n-- parameters {C_comp_crs'_P_se_α_z_1 : F}\n-- parameters {C_comp_crs'_P_se_powers_1 : fin n_var → F}\nparameters {C_comp_crs'_V_all_stmt_1 : fin n_stmt → F}\n-- parameters {C_comp_crs'_V_γ_1 : F} -- Same as previous\n-- parameters {C_comp_crs'_V_se_z_1 : F}\n\n/-- Polynomial form of C in the adversary's proof representation -/\ndef C' : mv_polynomial vars (polynomial F) := \n  ∑ i in (finset.fin_range n_wit), (crs'_P_all_wit_1 i) * C (polynomial.C (C_comp_crs'_P_all_wit_1 i))\n  +\n  crs'_P_α_1 * C (polynomial.C (C_comp_crs'_P_α_1))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (C_comp_crs'_P_powers_1 i))\n  +\n  ∑ i in (finset.fin_range (n_var - 1)), (crs'_P_l_1 i) * C (polynomial.C (C_comp_crs'_P_l_1 i))\n  +\n  crs'_γ_1 * C (polynomial.C (C_comp_crs'_P_γ_1))\n  +\n  crs'_P_δ_1 * C (polynomial.C (C_comp_crs'_P_δ_1))\n  +\n  ∑ i in (finset.fin_range n_stmt), (crs'_V_all_stmt_1 i) * C (polynomial.C (C_comp_crs'_V_all_stmt_1 i))\n\n\n\ndef verified' (a_stmt : fin n_stmt → F ) : Prop :=\n  (∑ i in finset.fin_range n_stmt, C (polynomial.C (a_stmt i)) * crs'_V_all_stmt_1 i ) * crs'_V_η_2 \n  +\n  C' * crs'_α_2 \n  =\n  (A' + crs'_γ_1) * (B' + crs'_V_δ_2) - crs'_V_γ_δ_T \n\n-- A, modified to be more like what we see in Baghery et al. - this includes athe extra y^γ we see \n-- that the verifier adds.\n\ndef A_mod_comp_crs_P_γ_1 := A_comp_crs'_γ_1 + 1\n\nlemma A_mod_transform : \n  A' + crs'_γ_1 =\n   ∑ i in (finset.fin_range n_wit), (crs'_P_all_wit_1 i) * C (polynomial.C (A_comp_crs'_P_all_wit_1 i))\n  +\n  crs'_P_α_1 * C (polynomial.C (A_comp_crs'_P_α_1))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  ∑ i in (finset.fin_range (n_var - 1)), (crs'_P_l_1 i) * C (polynomial.C (A_comp_crs'_P_l_1 i))\n  +\n  crs'_γ_1 * C (polynomial.C (A_mod_comp_crs_P_γ_1))\n  +\n  crs'_P_δ_1 * C (polynomial.C (A_comp_crs'_P_δ_1))\n  +\n  ∑ i in (finset.fin_range n_stmt), (crs'_V_all_stmt_1 i) * C (polynomial.C (A_comp_crs'_V_all_stmt_1 i)) :=\nbegin\n  rw [A', A_mod_comp_crs_P_γ_1],\n  simp only [mv_polynomial.C_add, ring_hom.map_add, ring_hom.map_one, mv_polynomial.C_1, mul_add, mul_one],\n  abel,\nend\n\n-- B, modified to be more like what we see in Baghery et al. - this includes athe extra y^γ we see \n-- that the verifier adds. \n\ndef B_mod_comp_crs_V_δ_2 := B_comp_crs'_V_δ_2 + 1\n\nlemma B_mod_transform : \n  B' + crs'_V_δ_2 =\n  crs'_α_2 * C (polynomial.C (B_comp_crs'_α_2))\n  +\n  ∑ i in (finset.fin_range n_var), (crs'_P_powers_2 i) * C (polynomial.C (B_comp_crs'_P_powers_2 i))\n  +\n  crs'_V_δ_2 * C (polynomial.C (B_mod_comp_crs_V_δ_2))\n  +\n  crs'_V_η_2 * C (polynomial.C (B_comp_crs'_V_η_2)) :=\nbegin\n  rw [B', B_mod_comp_crs_V_δ_2],\n  simp only [mv_polynomial.C_add, ring_hom.map_add, ring_hom.map_one, mv_polynomial.C_1, mul_add, mul_one],\n  abel,\nend\n\n\n-- TODO use this for lots of profiling data\n-- set_option profiler true\n\nopen finsupp\n\n-- TODO Add to Mathlib next to C_eq_zero\n@[simp] lemma polynomial.C_eq_one (a : F) : polynomial.C a = 1 ↔ a = 1 :=\ncalc polynomial.C a = 1 ↔ polynomial.C a = polynomial.C 1 : by rw polynomial.C_1\n         ... ↔ a = 1 : polynomial.C_inj\n\n\nlemma simplifier1 (x : fin n_stmt) (a_stmt : fin n_stmt → F ) \n  : polynomial.C (a_stmt x) * u_stmt x = u_stmt x * polynomial.C (a_stmt x)\n  :=\n  by ring\n\nlemma simplifier2 (x : fin n_stmt) (a_stmt : fin n_stmt → F ) \n  : polynomial.C (a_stmt x) * v_stmt x = v_stmt x * polynomial.C (a_stmt x)\n  :=\n  by ring\n\nlemma polynomial.mul_mod_by_monic (t p : polynomial F) (mt : t.monic) : (t * p) %ₘ t = 0 :=\nbegin\n  rw polynomial.dvd_iff_mod_by_monic_eq_zero,\n  apply dvd_mul_right,\n  exact mt,\nend\n\nlemma A_mod_comp_crs_P_γ_1_mul (p : polynomial F) : p * polynomial.C A_mod_comp_crs_P_γ_1  = polynomial.C A_mod_comp_crs_P_γ_1 * p := by ring\n\nlemma B_mod_comp_crs_V_δ_2_mul (p : polynomial F) : p * polynomial.C B_mod_comp_crs_V_δ_2  = polynomial.C B_mod_comp_crs_V_δ_2 * p := by ring\n\n\n/-- The main theorem for the soundness of the Lipmaa SNARK. Due to the error in the number of necessary monomials, the proof doesn't go through. -/\ntheorem soundness (a_stmt : fin n_stmt → F ) : \n  verified' a_stmt\n  -> (satisfying a_stmt C_comp_crs'_P_all_wit_1)\n:=\nbegin\n  \n  intros eqn',\n\n  rw satisfying,\n  simp only [polynomial.smul_eq_C_mul, rearrange_constants_right_hard],\n  suffices : \n    (∑ (i : fin n_stmt) in finset.fin_range n_stmt, u_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.fin_range n_wit, u_wit i * polynomial.C (C_comp_crs'_P_all_wit_1  i)) \n    * \n    (∑ (i : fin n_stmt) in finset.fin_range n_stmt, v_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.fin_range n_wit, v_wit i * polynomial.C (C_comp_crs'_P_all_wit_1  i)) \n    = \n    (∑ (i : fin n_stmt) in finset.fin_range n_stmt, w_stmt i * polynomial.C (a_stmt i) + ∑ (i : fin n_wit) in finset.fin_range n_wit, w_wit i * polynomial.C (C_comp_crs'_P_all_wit_1  i)) \n    +\n    ∑ (x : fin (n_var - 1)) in finset.fin_range (n_var - 1), l * polynomial.X ^ (x : ℕ) * polynomial.C (C_comp_crs'_P_l_1 x),\n  {\n    rw <-sub_eq_iff_eq_add' at this,\n    have h := congr_arg (%ₘ l) this,\n    simp only at h,\n    rw h,\n    clear this h,\n    conv\n    begin\n      to_lhs,\n      congr,\n      congr,\n      skip,\n      funext,\n      rw mul_comm,   \n      rw <-mul_assoc,\n      skip,   \n    end,\n    simp_rw mul_comm _ l,\n    simp_rw mul_assoc,\n    simp_rw mul_comm l _,\n    rw <-finset.sum_mul,\n    rw mul_comm,\n    apply polynomial.mul_mod_by_monic,\n    rw l,\n    apply monic_of_product_form,\n  },\n  \n  rw verified' at eqn',\n  rw [A_mod_transform, B_mod_transform, C'] at eqn',\n  simp only [] with crs at eqn',\n  -- simp only [] with polynomial_nf_3 at eqn',\n  simp only [α, β, γ, δ, η, algebra.id.smul_eq_mul, nat.succ_sub_succ, nat.sub_zero, nat.zero_mul, nat.mul_zero, nat.zero_add, nat.add_zero, nat.mul_succ, nat.add_succ] at eqn',\n  -- done,\n  simp only [mv_polynomial.X, C_apply, mv_polynomial.monomial_mul, mv_polynomial.monomial_pow, finsupp.smul_single, one_pow, one_mul, mul_one, add_zero, zero_add, finset.sum_add_distrib, finset.sum_hom, mul_add, add_mul, sum_monomial_hom] at eqn',\n\n  -- have h0 := congr_arg (coeff (single vars.y 0)) eqn',\n  -- -- have h1 := congr_arg (coeff (single vars.y 1)) eqn',\n  -- -- have h2 := congr_arg (coeff (single vars.y 2)) eqn',\n  -- -- have h3 := congr_arg (coeff (single vars.y 3)) eqn',\n  -- -- have h4 := congr_arg (coeff (single vars.y 4)) eqn',\n  -- have h5 := congr_arg (coeff (single vars.y 5)) eqn',\n  -- -- have h6 := congr_arg (coeff (single vars.y 6)) eqn',\n  -- have h7 := congr_arg (coeff (single vars.y 7)) eqn',\n  -- -- have h8 := congr_arg (coeff (single vars.y 8)) eqn',\n  -- -- have h9 := congr_arg (coeff (single vars.y 9)) eqn',\n  -- have h10 := congr_arg (coeff (single vars.y 10)) eqn',\n  -- -- have h11 := congr_arg (coeff (single vars.y 11)) eqn',\n  -- -- have h12 := congr_arg (coeff (single vars.y 12)) eqn',\n  -- -- have h13 := congr_arg (coeff (single vars.y 13)) eqn',\n  -- have h14 := congr_arg (coeff (single vars.y 14)) eqn',\n  -- -- have h15 := congr_arg (coeff (single vars.y 15)) eqn',\n  -- -- have h16 := congr_arg (coeff (single vars.y 16)) eqn',\n  -- have h17 := congr_arg (coeff (single vars.y 17)) eqn',\n  -- have h18 := congr_arg (coeff (single vars.y 18)) eqn',\n  -- -- have h19 := congr_arg (coeff (single vars.y 19)) eqn',\n  -- have h20 := congr_arg (coeff (single vars.y 20)) eqn',\n  -- -- have h21 := congr_arg (coeff (single vars.y 21)) eqn',\n  -- -- have h22 := congr_arg (coeff (single vars.y 22)) eqn',\n  -- -- have h23 := congr_arg (coeff (single vars.y 23)) eqn',\n  -- -- have h24 := congr_arg (coeff (single vars.y 24)) eqn',\n  -- -- have h25 := congr_arg (coeff (single vars.y 25)) eqn',\n  -- -- have h26 := congr_arg (coeff (single vars.y 26)) eqn',\n  -- -- have h27 := congr_arg (coeff (single vars.y 27)) eqn',\n\n\n-- def α : ℕ := 26 \n-- def β : ℕ := 27\n-- def γ : ℕ := 0\n-- def δ : ℕ := 40\n-- def η : ℕ := 24\n\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 0 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 1 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 2 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 2 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 0 + (δ-β) * 2 - (β-η) * 2 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 2\n  -- -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 0 - (β-η) * 2 - (β-α) * 3\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 1 - (β-η) * 1 - (β-α) * 2\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 1\n  -- #eval 2 * β - (β-γ) * 1 + (δ-β) * 1 - (β-η) * 2 - (β-α) * 2,\n\n\n  have h0012 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 0 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h0021 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 0 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h0022 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 0 + (β-η) * 0 + (β-α) * 0))) eqn',\n  -- have h0022 := congr_arg (coeff (single vars.y (46))) eqn',\n  have h0112 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 1 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h0121 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h0122 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 0))) eqn',\n  have h0212 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 2 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h0221 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 2 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h0222 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 0 + (δ-β) * 2 + (β-η) * 0 + (β-α) * 0))) eqn',\n  have h1022 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 0 + (β-η) * 0 + (β-α) * 0))) eqn',\n  -- have h1023 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 0 + (β-η) * 0 - (β-α) * 3))) eqn',\n  have h1112 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 1 + (β-η) * 1 + (β-α) * 0))) eqn',\n  have h1121 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 1))) eqn',\n  have h1122 := congr_arg (coeff (single vars.y (2 * β - (β-γ) * 1 + (δ-β) * 1 + (β-η) * 0 + (β-α) * 0))) eqn',\n\n  simp only [α, β, η, δ, γ, algebra.id.smul_eq_mul, nat.succ_sub_succ, nat.sub_zero, nat.zero_mul, nat.mul_zero, nat.zero_add, nat.add_zero, nat.mul_succ, nat.add_succ] at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n  -- done,\n\n\n  clear eqn',\n  -- clear h0012 h0021 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n  -- done,\n\n\n  simp only [finsupp_vars_eq_ext, mv_polynomial.coeff_sub] with coeff_simp finsupp_eq at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n  -- simp only [finsupp_vars_eq_ext, mv_polynomial.coeff_sub] with coeff_simp finsupp_eq at h0022,\n\n  -- simp only [algebra.id.smul_eq_mul, nat.succ_sub_succ, nat.sub_zero, nat.zero_mul, nat.mul_zero, nat.mul_succ, nat.add_succ] with finsupp_simp at h0022,\n  simp only [algebra.id.smul_eq_mul, nat.succ_sub_succ, sub_zero, nat.zero_mul, nat.mul_zero, nat.mul_succ, nat.add_succ] with finsupp_simp at h0012 h0021 h0022 h0112 h0121 h0122 h0212 h0221 h0222 h1022 h1112 h1121 h1122,\n\n\n  -- abel at *,\n  rw sub_eq_zero at h1122,\n\n\n\n\n  done,\n\n  -- Step 2: Recursively simplify and case-analyze the equations\n  \n  trace \"Moving Cs right\",\n  simp only [simplifier1, simplifier2] at *,\n\n  trace \"Grouping distributivity\",\n  simp only [<-mul_add, <-add_mul, <-add_assoc, add_mul_distrib, add_mul_distrib'] at *,\n\n  have h1022' : \n    polynomial.C A_mod_comp_crs_P_γ_1 *\n      ∑ (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : ℕ) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n      (∑ (x : fin n_stmt) in finset.fin_range n_stmt, v_stmt x * polynomial.C (A_comp_crs'_V_all_stmt_1 x)) *\n        polynomial.C B_comp_crs'_V_η_2 +\n    (∑ (x : fin n_wit) in finset.fin_range n_wit, v_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) *\n          polynomial.C B_comp_crs'_α_2 =\n    ∑ (x : fin n_stmt) in finset.fin_range n_stmt, v_stmt x * polynomial.C (a_stmt x) +\n      ∑ (x : fin n_wit) in finset.fin_range n_wit, v_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x),\n  {\n    rw h1022,\n    ring,\n  },\n\n  have h0122' : \n    polynomial.C A_comp_crs'_P_δ_1 *\n      ∑ (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : ℕ) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (∑ (x : fin n_var) in finset.fin_range n_var,\n       polynomial.X ^ (x : ℕ) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n            polynomial.C B_mod_comp_crs_V_δ_2 +\n    (∑ (x : fin n_stmt) in finset.fin_range n_stmt, u_stmt x * polynomial.C (A_comp_crs'_V_all_stmt_1 x)) *\n        polynomial.C B_comp_crs'_V_η_2 +\n    (∑ (x : fin n_wit) in finset.fin_range n_wit, u_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) *\n              polynomial.C B_comp_crs'_α_2  =\n    ∑ (x : fin n_stmt) in finset.fin_range n_stmt, u_stmt x * polynomial.C (a_stmt x) +\n      ∑ (x : fin n_wit) in finset.fin_range n_wit, u_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x),\n  {\n    rw h0122,\n    ring,\n  },\n\n  have h0022' : \n    (∑ (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : ℕ) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n    ∑ (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : ℕ) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (∑ (x : fin n_stmt) in finset.fin_range n_stmt, w_stmt x * polynomial.C (A_comp_crs'_V_all_stmt_1 x)) *\n        polynomial.C B_comp_crs'_V_η_2 +\n    polynomial.C B_comp_crs'_α_2  * \n      ((∑ (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) +\n       (∑ (x : fin (n_var - 1)) in finset.fin_range (n_var - 1),\n         l * polynomial.X ^ (x : ℕ) * polynomial.C (A_comp_crs'_P_l_1 x)))\n    =\n    ∑ (x : fin n_stmt) in finset.fin_range n_stmt, w_stmt x * polynomial.C (a_stmt x) +\n        ∑ (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x) +\n      ∑ (x : fin (n_var - 1)) in\n        finset.fin_range (n_var - 1),\n        l * polynomial.X ^ (x : ℕ) * polynomial.C (C_comp_crs'_P_l_1 x),\n  {\n    rw h0022,\n    ring,\n  },\n\n  clear h0122 h1022 h0022,\n\n  -- hack rewrites to get things the same as in the groth16typeIII \n  rw eq_comm at h0012 h0021 h0112 h0121 h0212 h0221 h0222 h1112 h1121 h1122 h0122' h1022' h0022',\n\n  rw eq_comm at h0021 h0022' h0121 h0012 h0112 h0122' h1022' h0212 h0221 h0222 h1112 h1121 h1122,\n\n  -- done,\n\n  trace \"Main simplification\",\n  simp only [*] with integral_domain_simp at *,\n\n  -- have hγη : (1 + polynomial.C A_comp_crs'_P_γ_1) * polynomial.C B_comp_crs'_V_η_2 = 0,\n  -- { rw add_mul, rw <-h5, ring, },\n  -- rw mul_eq_zero at hγη,\n\n  -- have hδδ : polynomial.C A_comp_crs'_P_δ_1 * (1 + polynomial.C B_comp_crs'_V_δ_2) = 0,\n  -- { rw mul_add, rw <-h0222, ring, },\n  -- rw mul_eq_zero at hδδ,\n\n  -- have hγδ : (1 + polynomial.C A_comp_crs'_P_γ_1) * (1 + polynomial.C B_comp_crs'_V_δ_2) = 1,\n  -- { rw <-sub_eq_zero, rw <-h1122, ring, },\n\n  -- have hββ := h14,\n  -- have hβγ := h7,\n  -- have hβδ := h17,\n  -- have hγγ := h0,\n  -- have hγδ := h10,\n\n  -- clear h0 h5 h7 h10 h14 h17 h20,\n\n\n\n\n  tactic.integral_domain_tactic_v4,\n\n  -- rw <-hβγ,\n  -- rw <-hβδ,\n  -- rw <-hββ,\n\n\n  -- done,\n\n  -- Solve remaining four cases by hand\n  { rw [<-h1022', <-h0122', <-h0022'],\n    simp only [B_mod_comp_crs_V_δ_2_mul],\n    simp only [<-mul_assoc],\n    simp only [A_mod_comp_crs_P_γ_1_mul],\n    simp only [<-mul_assoc],\n    rw h1122,\n    ring, },\n\n\n\n\nend \n\nend lipmaa\n\n\n\n", "meta": {"author": "BoltonBailey", "repo": "formal-snarks-project", "sha": "154414784f90a1e257162fcbdd7e805ecb2a49c2", "save_path": "github-repos/lean/BoltonBailey-formal-snarks-project", "path": "github-repos/lean/BoltonBailey-formal-snarks-project/formal-snarks-project-154414784f90a1e257162fcbdd7e805ecb2a49c2/src/snarks/lipmaa/knowledge_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4878735017891767}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen\n-/\nimport linear_algebra.multilinear.basis\nimport linear_algebra.matrix.reindex\nimport ring_theory.algebra_tower\nimport tactic.field_simp\nimport linear_algebra.matrix.nonsingular_inverse\nimport linear_algebra.matrix.basis\n\n/-!\n# Determinant of families of vectors\n\nThis file defines the determinant of an endomorphism, and of a family of vectors\nwith respect to some basis. For the determinant of a matrix, see the file\n`linear_algebra.matrix.determinant`.\n\n## Main definitions\n\nIn the list below, and in all this file, `R` is a commutative ring (semiring\nis sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite\ntypes used for indexing.\n\n * `basis.det`: the determinant of a family of vectors with respect to a basis,\n   as a multilinear map\n * `linear_map.det`: the determinant of an endomorphism `f : End R M` as a\n   multiplicative homomorphism (if `M` does not have a finite `R`-basis, the\n   result is `1` instead)\n * `linear_equiv.det`: the determinant of an isomorphism `f : M ≃ₗ[R] M` as a\n   multiplicative homomorphism (if `M` does not have a finite `R`-basis, the\n   result is `1` instead)\n\n## Tags\n\nbasis, det, determinant\n-/\n\nnoncomputable theory\n\nopen_locale big_operators\nopen_locale matrix\n\nopen linear_map\nopen submodule\n\nuniverses u v w\n\nopen linear_map matrix set function\n\nvariables {R : Type*} [comm_ring R]\nvariables {M : Type*} [add_comm_group M] [module R M]\nvariables {M' : Type*} [add_comm_group M'] [module R M']\nvariables {ι : Type*} [decidable_eq ι] [fintype ι]\nvariables (e : basis ι R M)\n\nsection conjugate\n\nvariables {A : Type*} [comm_ring A]\nvariables {m n : Type*} [fintype m] [fintype n]\n\n/-- If `R^m` and `R^n` are linearly equivalent, then `m` and `n` are also equivalent. -/\ndef equiv_of_pi_lequiv_pi {R : Type*} [comm_ring R] [is_domain R]\n  (e : (m → R) ≃ₗ[R] (n → R)) : m ≃ n :=\nbasis.index_equiv (basis.of_equiv_fun e.symm) (pi.basis_fun _ _)\n\nnamespace matrix\n\n/-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to\nequivalence of types. -/\ndef index_equiv_of_inv [is_domain A] [decidable_eq m] [decidable_eq n]\n  {M : matrix m n A} {M' : matrix n m A}\n  (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :\n  m ≃ n :=\nequiv_of_pi_lequiv_pi (to_lin'_of_inv hMM' hM'M)\n\nlemma det_comm [decidable_eq n] (M N : matrix n n A) : det (M ⬝ N) = det (N ⬝ M) :=\nby rw [det_mul, det_mul, mul_comm]\n\n/-- If there exists a two-sided inverse `M'` for `M` (indexed differently),\nthen `det (N ⬝ M) = det (M ⬝ N)`. -/\nlemma det_comm' [is_domain A] [decidable_eq m] [decidable_eq n]\n  {M : matrix n m A} {N : matrix m n A} {M' : matrix m n A}\n  (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :\n  det (M ⬝ N) = det (N ⬝ M) :=\n-- Although `m` and `n` are different a priori, we will show they have the same cardinality.\n-- This turns the problem into one for square matrices, which is easy.\nlet e := index_equiv_of_inv hMM' hM'M in\nby rw [← det_minor_equiv_self e, ← minor_mul_equiv _ _ _ (equiv.refl n) _, det_comm,\n  minor_mul_equiv, equiv.coe_refl, minor_id_id]\n\n/-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M ⬝ N ⬝ M') = det N`. -/\nlemma det_conj [is_domain A] [decidable_eq m] [decidable_eq n]\n  {M : matrix m n A} {M' : matrix n m A} {N : matrix n n A}\n  (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :\n  det (M ⬝ N ⬝ M') = det N :=\nby rw [← det_comm' hM'M hMM', ← matrix.mul_assoc, hM'M, matrix.one_mul]\n\nend matrix\n\nend conjugate\n\nnamespace linear_map\n\n/-! ### Determinant of a linear map -/\n\nvariables {A : Type*} [comm_ring A] [is_domain A] [module A M]\nvariables {κ : Type*} [fintype κ]\n\n/-- The determinant of `linear_map.to_matrix` does not depend on the choice of basis. -/\nlemma det_to_matrix_eq_det_to_matrix [decidable_eq κ]\n  (b : basis ι A M) (c : basis κ A M) (f : M →ₗ[A] M) :\n  det (linear_map.to_matrix b b f) = det (linear_map.to_matrix c c f) :=\nby rw [← linear_map_to_matrix_mul_basis_to_matrix c b c,\n       ← basis_to_matrix_mul_linear_map_to_matrix b c b,\n       matrix.det_conj]; rw [basis.to_matrix_mul_to_matrix, basis.to_matrix_self]\n\n/-- The determinant of an endomorphism given a basis.\n\nSee `linear_map.det` for a version that populates the basis non-computably.\n\nAlthough the `trunc (basis ι A M)` parameter makes it slightly more convenient to switch bases,\nthere is no good way to generalize over universe parameters, so we can't fully state in `det_aux`'s\ntype that it does not depend on the choice of basis. Instead you can use the `det_aux_def'` lemma,\nor avoid mentioning a basis at all using `linear_map.det`.\n-/\ndef det_aux : trunc (basis ι A M) → (M →ₗ[A] M) →* A :=\ntrunc.lift\n  (λ b : basis ι A M,\n    (det_monoid_hom).comp (to_matrix_alg_equiv b : (M →ₗ[A] M) →* matrix ι ι A))\n  (λ b c, monoid_hom.ext $ det_to_matrix_eq_det_to_matrix b c)\n\n/-- Unfold lemma for `det_aux`.\n\nSee also `det_aux_def'` which allows you to vary the basis.\n-/\nlemma det_aux_def (b : basis ι A M) (f : M →ₗ[A] M) :\n  linear_map.det_aux (trunc.mk b) f = matrix.det (linear_map.to_matrix b b f) :=\nrfl\n\n-- Discourage the elaborator from unfolding `det_aux` and producing a huge term.\nattribute [irreducible] linear_map.det_aux\n\nlemma det_aux_def' {ι' : Type*} [fintype ι'] [decidable_eq ι']\n  (tb : trunc $ basis ι A M) (b' : basis ι' A M) (f : M →ₗ[A] M) :\n  linear_map.det_aux tb f = matrix.det (linear_map.to_matrix b' b' f) :=\nby { apply trunc.induction_on tb, intro b, rw [det_aux_def, det_to_matrix_eq_det_to_matrix b b'] }\n\n@[simp]\nlemma det_aux_id (b : trunc $ basis ι A M) : linear_map.det_aux b (linear_map.id) = 1 :=\n(linear_map.det_aux b).map_one\n\n@[simp]\nlemma det_aux_comp (b : trunc $ basis ι A M) (f g : M →ₗ[A] M) :\n  linear_map.det_aux b (f.comp g) = linear_map.det_aux b f * linear_map.det_aux b g :=\n(linear_map.det_aux b).map_mul f g\n\nsection\nopen_locale classical\n\n-- Discourage the elaborator from unfolding `det` and producing a huge term by marking it\n-- as irreducible.\n/-- The determinant of an endomorphism independent of basis.\n\nIf there is no finite basis on `M`, the result is `1` instead.\n-/\n@[irreducible] protected def det : (M →ₗ[A] M) →* A :=\nif H : ∃ (s : finset M), nonempty (basis s A M)\nthen linear_map.det_aux (trunc.mk H.some_spec.some)\nelse 1\n\nlemma coe_det [decidable_eq M] : ⇑(linear_map.det : (M →ₗ[A] M) →* A) =\n  if H : ∃ (s : finset M), nonempty (basis s A M)\n  then linear_map.det_aux (trunc.mk H.some_spec.some)\n  else 1 :=\nby { ext, unfold linear_map.det,\n     split_ifs,\n     { congr }, -- use the correct `decidable_eq` instance\n     refl }\n\nend\n\n-- Auxiliary lemma, the `simp` normal form goes in the other direction\n-- (using `linear_map.det_to_matrix`)\nlemma det_eq_det_to_matrix_of_finset [decidable_eq M]\n  {s : finset M} (b : basis s A M) (f : M →ₗ[A] M) :\n  f.det = matrix.det (linear_map.to_matrix b b f) :=\nhave ∃ (s : finset M), nonempty (basis s A M),\nfrom ⟨s, ⟨b⟩⟩,\nby rw [linear_map.coe_det, dif_pos, det_aux_def' _ b]; assumption\n\n@[simp] lemma det_to_matrix\n  (b : basis ι A M) (f : M →ₗ[A] M) :\n  matrix.det (to_matrix b b f) = f.det :=\nby { haveI := classical.dec_eq M,\n     rw [det_eq_det_to_matrix_of_finset b.reindex_finset_range, det_to_matrix_eq_det_to_matrix b] }\n\n@[simp] lemma det_to_matrix' {ι : Type*} [fintype ι] [decidable_eq ι]\n  (f : (ι → A) →ₗ[A] (ι → A)) :\n  det f.to_matrix' = f.det :=\nby simp [← to_matrix_eq_to_matrix']\n\n/-- To show `P f.det` it suffices to consider `P (to_matrix _ _ f).det` and `P 1`. -/\n@[elab_as_eliminator]\nlemma det_cases [decidable_eq M] {P : A → Prop} (f : M →ₗ[A] M)\n  (hb : ∀ (s : finset M) (b : basis s A M), P (to_matrix b b f).det) (h1 : P 1) :\n  P f.det :=\nbegin\n  unfold linear_map.det,\n  split_ifs with h,\n  { convert hb _ h.some_spec.some,\n    apply det_aux_def' },\n  { exact h1 }\nend\n\n@[simp]\nlemma det_comp (f g : M →ₗ[A] M) : (f.comp g).det = f.det * g.det :=\nlinear_map.det.map_mul f g\n\n@[simp]\nlemma det_id : (linear_map.id : M →ₗ[A] M).det = 1 :=\nlinear_map.det.map_one\n\n/-- Multiplying a map by a scalar `c` multiplies its determinant by `c ^ dim M`. -/\n@[simp] lemma det_smul {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]\n  (c : 𝕜) (f : M →ₗ[𝕜] M) :\n  linear_map.det (c • f) = c ^ (finite_dimensional.finrank 𝕜 M) * linear_map.det f :=\nbegin\n  by_cases H : ∃ (s : finset M), nonempty (basis s 𝕜 M),\n  { haveI : finite_dimensional 𝕜 M,\n    { rcases H with ⟨s, ⟨hs⟩⟩, exact finite_dimensional.of_finset_basis hs },\n    simp only [← det_to_matrix (finite_dimensional.fin_basis 𝕜 M), linear_equiv.map_smul,\n              fintype.card_fin, det_smul] },\n  { classical,\n    have : finite_dimensional.finrank 𝕜 M = 0 := finrank_eq_zero_of_not_exists_basis H,\n    simp [coe_det, H, this] }\nend\n\nlemma det_zero' {ι : Type*} [fintype ι] [nonempty ι] (b : basis ι A M) :\n  linear_map.det (0 : M →ₗ[A] M) = 0 :=\nby { haveI := classical.dec_eq ι,\n     rw [← det_to_matrix b, linear_equiv.map_zero, det_zero],\n     assumption }\n\n/-- In a finite-dimensional vector space, the zero map has determinant `1` in dimension `0`,\nand `0` otherwise. We give a formula that also works in infinite dimension, where we define\nthe determinant to be `1`. -/\n@[simp] lemma det_zero {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M] :\n  linear_map.det (0 : M →ₗ[𝕜] M) = (0 : 𝕜) ^ (finite_dimensional.finrank 𝕜 M) :=\nby simp only [← zero_smul 𝕜 (1 : M →ₗ[𝕜] M), det_smul, mul_one, monoid_hom.map_one]\n\n/-- Conjugating a linear map by a linear equiv does not change its determinant. -/\n@[simp] lemma det_conj {N : Type*} [add_comm_group N] [module A N]\n  (f : M →ₗ[A] M) (e : M ≃ₗ[A] N) :\n  linear_map.det ((e : M →ₗ[A] N) ∘ₗ (f ∘ₗ (e.symm : N →ₗ[A] M))) = linear_map.det f :=\nbegin\n  classical,\n  by_cases H : ∃ (s : finset M), nonempty (basis s A M),\n  { rcases H with ⟨s, ⟨b⟩⟩,\n    rw [← det_to_matrix b f, ← det_to_matrix (b.map e), to_matrix_comp (b.map e) b (b.map e),\n        to_matrix_comp (b.map e) b b, ← matrix.mul_assoc, matrix.det_conj],\n    { rw [← to_matrix_comp, linear_equiv.comp_coe, e.symm_trans_self,\n          linear_equiv.refl_to_linear_map, to_matrix_id] },\n    { rw [← to_matrix_comp, linear_equiv.comp_coe, e.self_trans_symm,\n          linear_equiv.refl_to_linear_map, to_matrix_id] } },\n  { have H' : ¬ (∃ (t : finset N), nonempty (basis t A N)),\n    { contrapose! H,\n      rcases H with ⟨s, ⟨b⟩⟩,\n      exact ⟨_, ⟨(b.map e.symm).reindex_finset_range⟩⟩ },\n    simp only [coe_det, H, H', pi.one_apply, dif_neg, not_false_iff] }\nend\n\n/-- If a linear map is invertible, so is its determinant. -/\nlemma is_unit_det {A : Type*} [comm_ring A] [is_domain A] [module A M]\n  (f : M →ₗ[A] M) (hf : is_unit f) : is_unit f.det :=\nbegin\n  obtain ⟨g, hg⟩ : ∃ g, f.comp g = 1 := hf.exists_right_inv,\n  have : linear_map.det f * linear_map.det g = 1,\n    by simp only [← linear_map.det_comp, hg, monoid_hom.map_one],\n  exact is_unit_of_mul_eq_one _ _ this,\nend\n\n/-- If a linear map has determinant different from `1`, then the space is finite-dimensional. -/\n\n\n/-- If the determinant of a map vanishes, then the map is not onto. -/\nlemma range_lt_top_of_det_eq_zero {𝕜 : Type*} [field 𝕜] [module 𝕜 M]\n  {f : M →ₗ[𝕜] M} (hf : f.det = 0) : f.range < ⊤ :=\nbegin\n  haveI : finite_dimensional 𝕜 M, by simp [f.finite_dimensional_of_det_ne_one, hf],\n  contrapose hf,\n  simp only [lt_top_iff_ne_top, not_not, ← is_unit_iff_range_eq_top] at hf,\n  exact is_unit_iff_ne_zero.1 (f.is_unit_det hf)\nend\n\n/-- If the determinant of a map vanishes, then the map is not injective. -/\nlemma bot_lt_ker_of_det_eq_zero {𝕜 : Type*} [field 𝕜] [module 𝕜 M]\n  {f : M →ₗ[𝕜] M} (hf : f.det = 0) : ⊥ < f.ker :=\nbegin\n  haveI : finite_dimensional 𝕜 M, by simp [f.finite_dimensional_of_det_ne_one, hf],\n  contrapose hf,\n  simp only [bot_lt_iff_ne_bot, not_not, ← is_unit_iff_ker_eq_bot] at hf,\n  exact is_unit_iff_ne_zero.1 (f.is_unit_det hf)\nend\n\nend linear_map\n\nnamespace linear_equiv\n\nvariables [is_domain R]\n\n/-- On a `linear_equiv`, the domain of `linear_map.det` can be promoted to `Rˣ`. -/\nprotected def det : (M ≃ₗ[R] M) →* Rˣ :=\n(units.map (linear_map.det : (M →ₗ[R] M) →* R)).comp\n  (linear_map.general_linear_group.general_linear_equiv R M).symm.to_monoid_hom\n\n@[simp] lemma coe_det (f : M ≃ₗ[R] M) : ↑f.det = linear_map.det (f : M →ₗ[R] M) := rfl\n@[simp] lemma coe_inv_det (f : M ≃ₗ[R] M) : ↑(f.det⁻¹) = linear_map.det (f.symm : M →ₗ[R] M) := rfl\n\n@[simp] lemma det_refl : (linear_equiv.refl R M).det = 1 := units.ext $ linear_map.det_id\n\n@[simp] lemma det_trans (f g : M ≃ₗ[R] M) : (f.trans g).det = g.det * f.det := map_mul _ g f\n\n@[simp] lemma det_symm (f : M ≃ₗ[R] M) : f.symm.det = f.det⁻¹ := map_inv _ f\n\n/-- Conjugating a linear equiv by a linear equiv does not change its determinant. -/\n@[simp] lemma det_conj (f : M ≃ₗ[R] M) (e : M ≃ₗ[R] M') :\n  ((e.symm.trans f).trans e).det = f.det :=\nby rw [←units.eq_iff, coe_det, coe_det, ←comp_coe, ←comp_coe, linear_map.det_conj]\n\nend linear_equiv\n\n/-- The determinants of a `linear_equiv` and its inverse multiply to 1. -/\n@[simp] lemma linear_equiv.det_mul_det_symm {A : Type*} [comm_ring A] [is_domain A] [module A M]\n  (f : M ≃ₗ[A] M) : (f : M →ₗ[A] M).det * (f.symm : M →ₗ[A] M).det = 1 :=\nby simp [←linear_map.det_comp]\n\n/-- The determinants of a `linear_equiv` and its inverse multiply to 1. -/\n@[simp] lemma linear_equiv.det_symm_mul_det {A : Type*} [comm_ring A] [is_domain A] [module A M]\n  (f : M ≃ₗ[A] M) : (f.symm : M →ₗ[A] M).det * (f : M →ₗ[A] M).det = 1 :=\nby simp [←linear_map.det_comp]\n\n-- Cannot be stated using `linear_map.det` because `f` is not an endomorphism.\nlemma linear_equiv.is_unit_det (f : M ≃ₗ[R] M') (v : basis ι R M) (v' : basis ι R M') :\n  is_unit (linear_map.to_matrix v v' f).det :=\nbegin\n  apply is_unit_det_of_left_inverse,\n  simpa using (linear_map.to_matrix_comp v v' v f.symm f).symm\nend\n\n/-- Specialization of `linear_equiv.is_unit_det` -/\nlemma linear_equiv.is_unit_det' {A : Type*} [comm_ring A] [is_domain A] [module A M]\n  (f : M ≃ₗ[A] M) : is_unit (linear_map.det (f : M →ₗ[A] M)) :=\nis_unit_of_mul_eq_one _ _ f.det_mul_det_symm\n\n/-- The determinant of `f.symm` is the inverse of that of `f` when `f` is a linear equiv. -/\nlemma linear_equiv.det_coe_symm {𝕜 : Type*} [field 𝕜] [module 𝕜 M]\n  (f : M ≃ₗ[𝕜] M) : (f.symm : M →ₗ[𝕜] M).det = (f : M →ₗ[𝕜] M).det ⁻¹ :=\nby field_simp [is_unit.ne_zero f.is_unit_det']\n\n/-- Builds a linear equivalence from a linear map whose determinant in some bases is a unit. -/\n@[simps]\ndef linear_equiv.of_is_unit_det {f : M →ₗ[R] M'} {v : basis ι R M} {v' : basis ι R M'}\n  (h : is_unit (linear_map.to_matrix v v' f).det) : M ≃ₗ[R] M' :=\n{ to_fun := f,\n  map_add' := f.map_add,\n  map_smul' := f.map_smul,\n  inv_fun := to_lin v' v (to_matrix v v' f)⁻¹,\n  left_inv := λ x,\n    calc to_lin v' v (to_matrix v v' f)⁻¹ (f x)\n        = to_lin v v ((to_matrix v v' f)⁻¹ ⬝ to_matrix v v' f) x :\n      by { rw [to_lin_mul v v' v, to_lin_to_matrix, linear_map.comp_apply] }\n    ... = x : by simp [h],\n  right_inv := λ x,\n    calc f (to_lin v' v (to_matrix v v' f)⁻¹ x)\n        = to_lin v' v' (to_matrix v v' f ⬝ (to_matrix v v' f)⁻¹) x :\n      by { rw [to_lin_mul v' v v', linear_map.comp_apply, to_lin_to_matrix v v'] }\n    ... = x : by simp [h] }\n\n@[simp] lemma linear_equiv.coe_of_is_unit_det {f : M →ₗ[R] M'} {v : basis ι R M} {v' : basis ι R M'}\n  (h : is_unit (linear_map.to_matrix v v' f).det) :\n  (linear_equiv.of_is_unit_det h : M →ₗ[R] M') = f :=\nby { ext x, refl }\n\n/-- Builds a linear equivalence from a linear map on a finite-dimensional vector space whose\ndeterminant is nonzero. -/\n@[reducible] def linear_map.equiv_of_det_ne_zero\n  {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]\n  [finite_dimensional 𝕜 M] (f : M →ₗ[𝕜] M) (hf : linear_map.det f ≠ 0) :\n  M ≃ₗ[𝕜] M :=\nhave is_unit (linear_map.to_matrix (finite_dimensional.fin_basis 𝕜 M)\n  (finite_dimensional.fin_basis 𝕜 M) f).det :=\n    by simp only [linear_map.det_to_matrix, is_unit_iff_ne_zero.2 hf],\nlinear_equiv.of_is_unit_det this\n\n/-- The determinant of a family of vectors with respect to some basis, as an alternating\nmultilinear map. -/\ndef basis.det : alternating_map R M R ι :=\n{ to_fun := λ v, det (e.to_matrix v),\n  map_add' := begin\n    intros v i x y,\n    simp only [e.to_matrix_update, linear_equiv.map_add],\n    apply det_update_column_add\n  end,\n  map_smul' := begin\n    intros u i c x,\n    simp only [e.to_matrix_update, algebra.id.smul_eq_mul, linear_equiv.map_smul],\n    apply det_update_column_smul\n  end,\n  map_eq_zero_of_eq' := begin\n    intros v i j h hij,\n    rw [←function.update_eq_self i v, h, ←det_transpose, e.to_matrix_update,\n        ←update_row_transpose, ←e.to_matrix_transpose_apply],\n    apply det_zero_of_row_eq hij,\n    rw [update_row_ne hij.symm, update_row_self],\n  end }\n\nlemma basis.det_apply (v : ι → M) : e.det v = det (e.to_matrix v) := rfl\n\nlemma basis.det_self : e.det e = 1 :=\nby simp [e.det_apply]\n\n/-- `basis.det` is not the zero map. -/\nlemma basis.det_ne_zero [nontrivial R] : e.det ≠ 0 :=\nλ h, by simpa [h] using e.det_self\n\nlemma is_basis_iff_det {v : ι → M} :\n  linear_independent R v ∧ span R (set.range v) = ⊤ ↔ is_unit (e.det v) :=\nbegin\n  split,\n  { rintro ⟨hli, hspan⟩,\n    set v' := basis.mk hli hspan with v'_eq,\n    rw e.det_apply,\n    convert linear_equiv.is_unit_det (linear_equiv.refl _ _) v' e using 2,\n    ext i j,\n    simp },\n  { intro h,\n    rw [basis.det_apply, basis.to_matrix_eq_to_matrix_constr] at h,\n    set v' := basis.map e (linear_equiv.of_is_unit_det h) with v'_def,\n    have : ⇑ v' = v,\n    { ext i, rw [v'_def, basis.map_apply, linear_equiv.of_is_unit_det_apply, e.constr_basis] },\n    rw ← this,\n    exact ⟨v'.linear_independent, v'.span_eq⟩ },\nend\n\nlemma basis.is_unit_det (e' : basis ι R M) : is_unit (e.det e') :=\n(is_basis_iff_det e).mp ⟨e'.linear_independent, e'.span_eq⟩\n\n/-- Any alternating map to `R` where `ι` has the cardinality of a basis equals the determinant\nmap with respect to that basis, multiplied by the value of that alternating map on that basis. -/\nlemma alternating_map.eq_smul_basis_det (f : alternating_map R M R ι) : f = f e • e.det :=\nbegin\n  refine basis.ext_alternating e (λ i h, _),\n  let σ : equiv.perm ι := equiv.of_bijective i (fintype.injective_iff_bijective.1 h),\n  change f (e ∘ σ) = (f e • e.det) (e ∘ σ),\n  simp [alternating_map.map_perm, basis.det_self]\nend\n\n@[simp] lemma alternating_map.map_basis_eq_zero_iff (f : alternating_map R M R ι) :\n  f e = 0 ↔ f = 0 :=\n⟨λ h, by simpa [h] using f.eq_smul_basis_det e, λ h, h.symm ▸ alternating_map.zero_apply _⟩\n\nlemma alternating_map.map_basis_ne_zero_iff (f : alternating_map R M R ι) :\n  f e ≠ 0 ↔ f ≠ 0 :=\nnot_congr $ f.map_basis_eq_zero_iff e\n\nvariables {A : Type*} [comm_ring A] [is_domain A] [module A M]\n\n@[simp] lemma basis.det_comp (e : basis ι A M) (f : M →ₗ[A] M) (v : ι → M) :\n  e.det (f ∘ v) = f.det * e.det v :=\nby { rw [basis.det_apply, basis.det_apply, ← f.det_to_matrix e, ← matrix.det_mul,\n         e.to_matrix_eq_to_matrix_constr (f ∘ v), e.to_matrix_eq_to_matrix_constr v,\n         ← to_matrix_comp, e.constr_comp] }\n\nlemma basis.det_reindex {ι' : Type*} [fintype ι'] [decidable_eq ι']\n  (b : basis ι R M) (v : ι' → M) (e : ι ≃ ι') :\n  (b.reindex e).det v = b.det (v ∘ e) :=\nby rw [basis.det_apply, basis.to_matrix_reindex', det_reindex_alg_equiv, basis.det_apply]\n\nlemma basis.det_reindex_symm {ι' : Type*} [fintype ι'] [decidable_eq ι']\n  (b : basis ι R M) (v : ι → M) (e : ι' ≃ ι) :\n  (b.reindex e.symm).det (v ∘ e) = b.det v :=\nby rw [basis.det_reindex, function.comp.assoc, e.self_comp_symm, function.comp.right_id]\n\n@[simp]\nlemma basis.det_map (b : basis ι R M) (f : M ≃ₗ[R] M') (v : ι → M') :\n  (b.map f).det v = b.det (f.symm ∘ v) :=\nby { rw [basis.det_apply, basis.to_matrix_map, basis.det_apply] }\n\nlemma basis.det_map' (b : basis ι R M) (f : M ≃ₗ[R] M') :\n  (b.map f).det = b.det.comp_linear_map f.symm :=\nalternating_map.ext $ b.det_map f\n\n@[simp] lemma pi.basis_fun_det : (pi.basis_fun R ι).det = matrix.det_row_alternating :=\nbegin\n  ext M,\n  rw [basis.det_apply, basis.coe_pi_basis_fun.to_matrix_eq_transpose, det_transpose],\nend\n\n/-- If we fix a background basis `e`, then for any other basis `v`, we can characterise the\ncoordinates provided by `v` in terms of determinants relative to `e`. -/\nlemma basis.det_smul_mk_coord_eq_det_update {v : ι → M}\n  (hli : linear_independent R v) (hsp : span R (range v) = ⊤) (i : ι) :\n  (e.det v) • (basis.mk hli hsp).coord i = e.det.to_multilinear_map.to_linear_map v i :=\nbegin\n  apply (basis.mk hli hsp).ext,\n  intros k,\n  rcases eq_or_ne k i with rfl | hik;\n  simp only [algebra.id.smul_eq_mul, basis.coe_mk, linear_map.smul_apply, linear_map.coe_mk,\n    multilinear_map.to_linear_map_apply],\n  { rw [basis.mk_coord_apply_eq, mul_one, update_eq_self], congr, },\n  { rw [basis.mk_coord_apply_ne hik, mul_zero, eq_comm],\n    exact e.det.map_eq_zero_of_eq _ (by simp [hik, function.update_apply]) hik, },\nend\n\n/-- The determinant of a basis constructed by `units_smul` is the product of the given units. -/\n@[simp] lemma basis.det_units_smul (w : ι → Rˣ) : e.det (e.units_smul w) = ∏ i, w i :=\nby simp [basis.det_apply]\n\n/-- The determinant of a basis constructed by `is_unit_smul` is the product of the given units. -/\n@[simp] lemma basis.det_is_unit_smul {w : ι → R} (hw : ∀ i, is_unit (w i)) :\n  e.det (e.is_unit_smul hw) = ∏ i, w i :=\ne.det_units_smul _\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/linear_algebra/determinant.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059560743422, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4878298417187868}}
{"text": "/-\nCopyright (c) 2021 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn\n-/\nimport category_theory.action\nimport combinatorics.quiver\nimport group_theory.is_free_group\n/-!\n# The Nielsen-Schreier theorem\n\nThis file proves that a subgroup of a free group is itself free.\n\n## Main result\n\n- `subgroup_is_free_of_is_free H`: an instance saying that a subgroup of a free group is free.\n\n## Proof overview\n\nThe proof is analogous to the proof using covering spaces and fundamental groups of graphs,\nbut we work directly with groupoids instead of topological spaces. Under this analogy,\n\n- `is_free_groupoid G` corresponds to saying that a space is a graph.\n- `End_mul_equiv_subgroup H` plays the role of replacing 'subgroup of fundamental group' with\n  'fundamental group of covering space'.\n- `action_category_is_free G A` corresponds to the fact that a covering of a (single-vertex)\n  graph is a graph.\n- `End_is_free_group_of_arborescence` corresponds to the fact that, given a spanning tree of a\n  graph, its fundamental group is free (generated by loops from the complement of the tree).\n\n## Implementation notes\n\nOur definition of `is_free_groupoid` is nonstandard. Normally one would require that functors\n`G ⥤ X` to any _groupoid_ `X` are given by graph homomorphisms from the generators, but we only\nconsider _groups_ `X`. This simplifies the argument since functor equality is complicated in\ngeneral, but simple for functors to single object categories.\n\n## References\n\nhttps://ncatlab.org/nlab/show/Nielsen-Schreier+theorem\n\n## Tags\n\nfree group, free groupoid, Nielsen-Schreier\n\n-/\n\nnoncomputable theory\nopen_locale classical\nuniverses v u\n\nopen category_theory category_theory.action_category category_theory.single_obj quiver\n  is_free_group as fgp\n\n/-- `is_free_groupoid.generators G` is a type synonym for `G`. We think of this as\nthe vertices of the generating quiver of `G` when `G` is free. We can't use `G` directly,\nsince `G` already has a quiver instance from being a groupoid. -/\n@[nolint unused_arguments has_inhabited_instance]\ndef is_free_groupoid.generators (G) [groupoid G] := G\n\n/-- A groupoid `G` is free when we have the following data:\n - a quiver on `is_free_groupoid.generators G` (a type synonym for `G`)\n - a function `of` taking a generating arrow to a morphism in `G`\n - such that a functor from `G` to any group `X` is uniquely determined\n   by assigning labels in `X` to the generating arrows.\n\n   This definition is nonstandard. Normally one would require that functors `G ⥤ X`\n   to any _groupoid_ `X` are given by graph homomorphisms from `generators`. -/\nclass is_free_groupoid (G) [groupoid.{v} G] :=\n(quiver_generators : quiver.{v+1} (is_free_groupoid.generators G))\n(of : Π {a b : is_free_groupoid.generators G}, (a ⟶ b) → ((show G, from a) ⟶ b))\n(unique_lift : ∀ {X : Type v} [group X] (f : labelling (is_free_groupoid.generators G) X),\n                ∃! F : G ⥤ single_obj X, ∀ a b (g : a ⟶ b),\n                  F.map (of g) = f g)\n\nnamespace is_free_groupoid\n\nattribute [instance] quiver_generators\n\n/-- Two functors from a free groupoid to a group are equal when they agree on the generating\nquiver. -/\n@[ext]\nlemma ext_functor {G} [groupoid.{v} G] [is_free_groupoid G] {X : Type v} [group X]\n  (f g : G ⥤ single_obj X)\n  (h : ∀ a b (e : a ⟶ b), f.map (of e) = g.map (of e)) :\n  f = g :=\nlet ⟨_, _, u⟩ := @unique_lift G _ _ X _ (λ (a b : generators G) (e : a ⟶ b), g.map (of e)) in\ntrans (u _ h) (u _ (λ _ _ _, rfl)).symm\n\n/-- An action groupoid over a free froup is free. More generally, one could show that the groupoid\nof elements over a free groupoid is free, but this version is easier to prove and suffices for our\npurposes.\n\nAnalogous to the fact that a covering space of a graph is a graph. (A free groupoid is like a graph,\nand a groupoid of elements is like a covering space.) -/\ninstance action_groupoid_is_free {G A : Type u} [group G] [is_free_group G] [mul_action G A] :\n  is_free_groupoid (action_category G A) :=\n{ quiver_generators := ⟨λ a b, { e : fgp.generators G // fgp.of e • a.back = b.back }⟩,\n  of := λ a b e, ⟨fgp.of e, e.property⟩,\n  unique_lift := begin\n    introsI X _ f,\n    let f' : fgp.generators G → (A → X) ⋊[mul_aut_arrow] G :=\n      λ e, ⟨λ b, @f ⟨(), _⟩ ⟨(), b⟩ ⟨e, smul_inv_smul _ b⟩, fgp.of e⟩,\n    rcases fgp.unique_lift f' with ⟨F', hF', uF'⟩,\n    refine ⟨uncurry F' _, _, _⟩,\n    { suffices : semidirect_product.right_hom.comp F' = monoid_hom.id _,\n      { exact monoid_hom.ext_iff.mp this },\n      ext,\n      rw [monoid_hom.comp_apply, hF'],\n      refl },\n    { rintros ⟨⟨⟩, a : A⟩ ⟨⟨⟩, b⟩ ⟨e, h : fgp.of e • a = b⟩,\n      change (F' (fgp.of _)).left _ = _,\n      rw hF',\n      cases (inv_smul_eq_iff.mpr h.symm),\n      refl },\n    { intros E hE,\n      have : curry E = F',\n      { apply uF',\n        intro e,\n        ext,\n        { convert hE _ _ _, refl },\n        { refl } },\n      apply functor.hext,\n      { intro, apply unit.ext },\n      { refine action_category.cases _, intros,\n        simp only [←this, uncurry_map, curry_apply_left, coe_back, hom_of_pair.val] } },\n  end }\n\nnamespace spanning_tree\n/- In this section, we suppose we have a free groupoid with a spanning tree for its generating\nquiver. The goal is to prove that the vertex group at the root is free. A picture to have in mind\nis that we are 'pulling' the endpoints of all the edges of the quiver along the spanning tree to\nthe root. -/\nvariables {G : Type u} [groupoid.{u} G] [is_free_groupoid G]\n  (T : wide_subquiver (symmetrify $ generators G)) [arborescence T]\n\n/-- The root of `T`, except its type is `G` instead of the type synonym `T`. -/\nprivate def root' : G := show T, from root T\n\n/-- A path in the tree gives a hom, by composition. -/\n-- this has to be marked noncomputable, see issue #451.\n-- It might be nicer to define this in terms of `compose_path`\nnoncomputable def hom_of_path : Π {a : G}, path (root T) a → (root' T ⟶ a)\n| _ path.nil := 𝟙 _\n| a (path.cons p f) := hom_of_path p ≫ sum.rec_on f.val (λ e, of e) (λ e, inv (of e))\n\n/-- For every vertex `a`, there is a canonical hom from the root, given by the path in the tree. -/\ndef tree_hom (a : G) : root' T ⟶ a := hom_of_path T (default _)\n\n/-- Any path to `a` gives `tree_hom T a`, since paths in the tree are unique. -/\nlemma tree_hom_eq {a : G} (p : path (root T) a) : tree_hom T a = hom_of_path T p :=\nby rw [tree_hom, unique.default_eq]\n\n@[simp] lemma tree_hom_root : tree_hom T (root' T) = 𝟙 _ :=\n-- this should just be `tree_hom_eq T path.nil`, but Lean treats `hom_of_path` with suspicion.\ntrans (tree_hom_eq T path.nil) rfl\n\n/-- Any hom in `G` can be made into a loop, by conjugating with `tree_hom`s. -/\ndef loop_of_hom {a b : G} (p : a ⟶ b) : End (root' T) :=\ntree_hom T a ≫ p ≫ inv (tree_hom T b)\n\n/-- Turning an edge in the spanning tree into a loop gives the indentity loop. -/\nlemma loop_of_hom_eq_id {a b : generators G} (e ∈ wide_subquiver_symmetrify T a b) :\n  loop_of_hom T (of e) = 𝟙 (root' T) :=\nbegin\n  rw [loop_of_hom, ←category.assoc, is_iso.comp_inv_eq, category.id_comp],\n  cases H,\n  { rw [tree_hom_eq T (path.cons (default _) ⟨sum.inl e, H⟩), hom_of_path], refl },\n  { rw [tree_hom_eq T (path.cons (default _) ⟨sum.inr e, H⟩), hom_of_path],\n    simp only [is_iso.inv_hom_id, category.comp_id, category.assoc, tree_hom] }\nend\n\n/-- Since a hom gives a loop, any homomorphism from the vertex group at the root\n    extends to a functor on the whole groupoid. -/\n@[simps] def functor_of_monoid_hom {X} [monoid X] (f : End (root' T) →* X) :\n  G ⥤ single_obj X :=\n{ obj := λ _, (),\n  map := λ a b p, f (loop_of_hom T p),\n  map_id' := begin\n    intro a,\n    rw [loop_of_hom, category.id_comp, is_iso.hom_inv_id, ←End.one_def, f.map_one, id_as_one],\n end,\n  map_comp' := begin\n    intros,\n    rw [comp_as_mul, ←f.map_mul],\n    simp only [is_iso.inv_hom_id_assoc, loop_of_hom, End.mul_def, category.assoc]\n  end }\n\n/-- Given a free groupoid and an arborescence of its generating quiver, the vertex\n    group at the root is freely generated by loops coming from generating arrows\n    in the complement of the tree. -/\ndef End_is_free : is_free_group (End (root' T)) :=\n{ generators := set.compl (wide_subquiver_equiv_set_total $ wide_subquiver_symmetrify T),\n  of := λ e, loop_of_hom T (of e.val.hom),\n  unique_lift' := begin\n    introsI X _ f,\n    let f' : labelling (generators G) X := λ a b e,\n      if h : e ∈ wide_subquiver_symmetrify T a b then 1\n      else f ⟨⟨a, b, e⟩, h⟩,\n    rcases unique_lift f' with ⟨F', hF', uF'⟩,\n    refine ⟨F'.map_End _, _, _⟩,\n    { suffices : ∀ {x y} (q : x ⟶ y), F'.map (loop_of_hom T q) = (F'.map q : X),\n      { rintro ⟨⟨a, b, e⟩, h⟩,\n        rw [functor.map_End_apply, this, hF'],\n        exact dif_neg h },\n      intros,\n      suffices : ∀ {a} (p : path (root' T) a), F'.map (hom_of_path T p) = 1,\n      { simp only [this, tree_hom, comp_as_mul, inv_as_inv, loop_of_hom,\n        one_inv, mul_one, one_mul, functor.map_inv, functor.map_comp] },\n      intros a p, induction p with b c p e ih,\n      { rw [hom_of_path, F'.map_id, id_as_one] },\n      rw [hom_of_path, F'.map_comp, comp_as_mul, ih, mul_one],\n      rcases e with ⟨e | e, eT⟩,\n      { rw hF', exact dif_pos (or.inl eT) },\n      { rw [F'.map_inv, inv_as_inv, inv_eq_one, hF'], exact dif_pos (or.inr eT) } },\n    { intros E hE,\n      ext,\n      suffices : (functor_of_monoid_hom T E).map x = F'.map x,\n      { simpa only [loop_of_hom, functor_of_monoid_hom_map, is_iso.inv_id, tree_hom_root,\n          category.id_comp, category.comp_id] using this },\n      congr,\n      apply uF',\n      intros a b e,\n      change E (loop_of_hom T _) = dite _ _ _,\n      split_ifs,\n      { rw [loop_of_hom_eq_id T e h, ←End.one_def, E.map_one] },\n      { exact hE ⟨⟨a, b, e⟩, h⟩ } }\n  end }\n\nend spanning_tree\n\n/-- Another name for the identity function `G → G`, to help type checking. -/\nprivate def symgen {G : Type u} [groupoid.{v} G] [is_free_groupoid G] :\n  G → symmetrify (generators G) := id\n\n/-- If there exists a morphism `a → b` in a free groupoid, then there also exists a zigzag\nfrom `a` to `b` in the generating quiver. -/\nlemma path_nonempty_of_hom {G} [groupoid.{u u} G] [is_free_groupoid G] {a b : G} :\n  nonempty (a ⟶ b) → nonempty (path (symgen a) (symgen b)) :=\nbegin\n  rintro ⟨p⟩,\n  rw [←weakly_connected_component.eq, eq_comm, ←free_group.of_injective.eq_iff, ←mul_inv_eq_one],\n  let X := free_group (weakly_connected_component $ symmetrify $ generators G),\n  let f : G → X := λ g, free_group.of ↑(symgen g),\n  let F : G ⥤ single_obj X := single_obj.difference_functor f,\n  change F.map p = ((category_theory.functor.const G).obj ()).map p,\n  congr, ext,\n  rw [functor.const.obj_map, id_as_one, difference_functor_map, mul_inv_eq_one],\n  apply congr_arg free_group.of,\n  rw weakly_connected_component.eq,\n  exact ⟨hom.to_path (sum.inr e)⟩,\nend\n\n/-- Given a connected free groupoid, its generating quiver is rooted-connected. -/\ninstance generators_connected (G) [groupoid.{u u} G] [is_connected G] [is_free_groupoid G]\n  (r : G) : rooted_connected (symgen r) :=\n⟨λ b, path_nonempty_of_hom (category_theory.nonempty_hom_of_connected_groupoid r b)⟩\n\n/-- A vertex group in a free connected groupoid is free. With some work one could drop the\nconnectedness assumption, by looking at connected components. -/\ninstance End_is_free_of_connected_free {G} [groupoid G] [is_connected G] [is_free_groupoid G]\n  (r : G) : is_free_group (End r) :=\nspanning_tree.End_is_free $ geodesic_subtree (symgen r)\n\nend is_free_groupoid\n\n/-- The Nielsen-Schreier theorem: a subgroup of a free group is free. -/\ninstance subgroup_is_free_of_is_free {G : Type u} [group G] [is_free_group G]\n  (H : subgroup G) : is_free_group H :=\nis_free_group.of_mul_equiv (End_mul_equiv_subgroup H)\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/group_theory/nielsen_schreier.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059560743422, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4878298417187868}}
{"text": "lemma example3 (a b : mynat) (h : succ a = b) : succ(succ(a)) = succ(b) :=\nbegin\nrw h,\nrefl,\nend\n", "meta": {"author": "chanha-park", "repo": "naturalNumberGame", "sha": "4e0d7100ce4575e1add92feefa38b1250431b879", "save_path": "github-repos/lean/chanha-park-naturalNumberGame", "path": "github-repos/lean/chanha-park-naturalNumberGame/naturalNumberGame-4e0d7100ce4575e1add92feefa38b1250431b879/Tutorial/3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4878298387108655}}
{"text": "import topology.sheaves.sheaf\nimport topology.category.Top.opens\nimport algebra.category.CommRing\nimport cats\n\nopen category_theory Top topological_space opposite\n\nstructure PresheafOfModules1 (X : Top) :=\n(𝒪 : presheaf CommRing X) \n(ℱ : presheaf AddCommGroup X)\n[is_module : Π (U : (opens X)ᵒᵖ), module (𝒪.obj U) (ℱ.obj U)]\n(res_compatible : Π (U V : (opens X)ᵒᵖ) (h : U ⟶ V) (r : 𝒪.obj U) (a: ℱ.obj U),\n  ℱ.map h (r • a) = 𝒪.map h r • ℱ.map h a)\n\n-- Now I believe this is not the correct definition, because for `h : U ⟶ V`, `ℱ.map h` is only an `AddCommGroup`-map not a `Module`-map\n\n\nopen restriction_of_scalar\n\n/--\nThis is a presheaf of Modules over ℱ ⋙ BundledModule.forget\n\nIf `h : U ⊆ V`, then `ℱ.map h` is a pair `⟨res₁, res₂⟩`, and `res₁` is the restriction map of sheaf of ring while `res₂` is the restriction map of sheaf of module.\n-/\n\nclass PresheafOfModules2 {X : Top} (ℱ : @presheaf BundledModule BundledModule.is_cat X):=\n(res_compatible : Π (U V : (opens X)ᵒᵖ) (h : U ⟶ V) (r : (ℱ.obj U).R) (m : (ℱ.obj U).M), (ℱ.map h).2 (r • m) = (r • (ℱ.map h).2 m))\n\nopen ulift\n\n@[reducible] instance int_as_cring.has_add : has_add (ulift ℤ) :=\n⟨λ x y, up (down x + down y)⟩\n\n@[simp] lemma int_as_cring.add_def (x y : ℤ) : (up x) + (up y) = up (x + y) := rfl\n\n@[reducible] instance int_as_cring.has_neg : has_neg (ulift ℤ) :=\n⟨λ x, up (- down x)⟩\n\n@[simp] lemma int_as_cring.neg_def (z : ℤ) : -(up z) = up (- z) := rfl\n\n@[reducible] instance int_as_cring.has_mul : has_mul (ulift ℤ) :=\n⟨λ x y, up (down x * down y)⟩\n\n@[simp] lemma int_as_cring.mul_def (x y : ℤ) : up x * up y = up (x * y) := rfl\n\ndef int_as_cring : CommRing :=\n{ α := ulift ℤ,\n  str := { add_assoc := λ a b c, begin\n             cases a, cases b, cases c,\n             dsimp only, rw add_assoc,\n           end,\n\n           zero := up 0,\n           add_zero := λ a, begin\n             cases a,\n             dsimp only, rw add_zero,\n           end,\n           zero_add := λ a, begin\n             cases a, dsimp only, rw zero_add,\n           end,\n\n           neg := λ r, up (- down r),\n           add_left_neg := λ a, \n           begin\n             cases a, rw [int_as_cring.neg_def, int_as_cring.add_def, int.add_left_neg], \n             refl,\n           end,\n\n           add_comm := λ x y, begin\n             cases x, cases y,\n             rw [int_as_cring.add_def, add_comm, int_as_cring.add_def],\n           end,\n\n           mul_assoc := λ x y z, begin \n             cases x, cases y, cases z,\n             rw [int_as_cring.mul_def, int_as_cring.mul_def, mul_assoc],\n           end,\n           mul_comm := λ x y, begin\n             cases x, cases y,\n             rw [int_as_cring.mul_def, mul_comm, int_as_cring.mul_def],\n           end,\n\n           one := up 1,\n           one_mul := λ a, begin\n             cases a, rw [int_as_cring.mul_def, one_mul],\n           end,\n           mul_one := λ a, begin\n             cases a, rw [int_as_cring.mul_def, mul_one],\n           end,\n\n           left_distrib := λ a b c, begin\n             cases a, cases b, cases c,\n             rw [int_as_cring.add_def, int_as_cring.mul_def, mul_add],\n           end,\n           right_distrib := λ a b c, begin\n             cases a, cases b, cases c,\n             rw [int_as_cring.add_def, int_as_cring.mul_def, add_mul],\n           end,\n           ..(int_as_cring.has_add),\n           ..(int_as_cring.has_neg),\n           ..(int_as_cring.has_mul) } }\n\n@[simp] lemma lift_int.add_down (x y : int_as_cring) : (x + y).down = x.down + y.down := rfl\n@[simp] lemma lift_int.zero_down : (0 : int_as_cring).down = 0 := rfl\n\ninstance int_as_cring.distrib_mul_action (A : AddCommGroup) : distrib_mul_action (int_as_cring) A :=\n{ smul := λ x y, x.1 • y,\n  one_smul := λ x, by erw one_zsmul,\n  mul_smul := λ x y r, begin \n    cases x, cases y,\n    rw [int_as_cring.mul_def, mul_zsmul],\n  end,\n  smul_add := λ r x y, by rw zsmul_add,\n  smul_zero := λ r, by rw zsmul_zero }\n\n@[simp] lemma lift_int.zsmul (A : AddCommGroup) (r : int_as_cring) (a : A) : r • a = r.1 • a := rfl\n\ninstance is_int_module (A : AddCommGroup) : module int_as_cring A :=\n{ add_smul := λ x y r, begin\n    cases x, cases y,\n    unfold has_scalar.smul,\n    simp only [zsmul_eq_smul],\n    rw [lift_int.add_down], dsimp only, rw add_smul,\n  end,\n  zero_smul := λ x, begin\n    unfold has_scalar.smul,\n    simp only [zsmul_eq_smul],\n    rw [lift_int.zero_down, zero_smul],\n  end}\n\ndef as_int_module (A : AddCommGroup) : module ℤ A := by apply_instance\n\n-- @[reducible] def psh_m {X : Top} (𝒪 : presheaf AddCommGroup X) :\n--   @presheaf BundledModule BundledModule.is_cat X :=\n-- { obj := λ U, { R := int_as_cring, M := { carrier := 𝒪.obj U, is_module := is_int_module (𝒪.obj U)} },\n--   map := λ U V h,\n--     ⟨𝟙 _, { to_fun := λ m, 𝒪.map h m,\n--             map_add' := λ x y, by rw add_monoid_hom.map_add,\n--             map_smul' := λ r m, begin\n--             dsimp only at *,\n--             rw [ring_hom.id_apply],\n--             erw add_monoid_hom.map_zsmul,\n--             erw [lift_int.zsmul],\n--           end }⟩ }\n\n\n-- instance {X : Top} (𝒪 : presheaf AddCommGroup X) :\n--   (PresheafOfModules2 (psh_m 𝒪)) :=\n-- { res_compatible := λ U V h r m, begin\n--     dsimp only,\n--     erw [smul_def', id_apply, add_monoid_hom.map_zsmul, lift_int.zsmul],\n--   end }\n\nexample (X : Top) (ℱ : @presheaf BundledModule BundledModule.is_cat X) [PresheafOfModules2 ℱ]: PresheafOfModules1 X :=\n{ 𝒪 := { obj := λ U, (ℱ.obj U).R,\n         map := λ _ _ h, (ℱ.map h).1 },\n  ℱ :=\n    { obj := λ U, AddCommGroup.of (ℱ.obj U).M,\n      map := λ U V h, @AddCommGroup.of_hom (AddCommGroup.of (ℱ.obj U).M) (AddCommGroup.of (ℱ.obj V).M) _ _\n        { to_fun := (ℱ.map h).2,\n          map_zero' :=  linear_map.map_zero _,\n          map_add' := λ m m', begin\n            -- rw linear_map.map_add,\n            sorry,\n          end, }, },\n  is_module := λ U, begin\n    dsimp only [AddCommGroup.coe_of], apply_instance,\n  end,\n  res_compatible := λ U V h r m, begin\n    dsimp only [AddCommGroup.coe_of, linear_map.map_zero, functor.map_comp, functor.map_id] at *,\n    erw PresheafOfModules2.res_compatible U V h r m,\n    erw [smul_def'],\n  end}\n\n@[reducible] def convert_to2 (X : Top) (psofm : PresheafOfModules1 X) : @presheaf BundledModule BundledModule.is_cat X :=\n{ obj := λ U,{ R := psofm.𝒪.obj U,\n               M := { carrier := psofm.ℱ.obj U,\n               is_module := psofm.is_module U } },\n  map := λ U V h, ⟨psofm.𝒪.map h,\n        { to_fun := λ m, psofm.ℱ.map h m,\n          map_add' := λ m m', begin\n            dsimp only at *,\n            simp only [add_monoid_hom.map_add],\n          end,\n          map_smul' := λ r m, begin\n            dsimp only at *,\n            rw [ring_hom.id_apply, psofm.res_compatible _ _ h],\n            -- erw (smul_def' (psofm.𝒪.map h) r { carrier := psofm.ℱ.obj V,\n            --    is_module := psofm.is_module V } (psofm.ℱ.map h m)).symm,\n\n            sorry,\n          end}⟩ }\n\ninstance (X : Top) (psofm : PresheafOfModules1 X) : PresheafOfModules2 (convert_to2 X psofm) :=\n{ res_compatible := λ U V h r m, begin\n  dsimp only [convert_to2] at *,\n  rw smul_def',\n  erw psofm.res_compatible, refl,\nend }", "meta": {"author": "jjaassoonn", "repo": "sheaf_of_modules", "sha": "4c7d9a4fd11cf53a34b0e5f27ab3915d8395b381", "save_path": "github-repos/lean/jjaassoonn-sheaf_of_modules", "path": "github-repos/lean/jjaassoonn-sheaf_of_modules/sheaf_of_modules-4c7d9a4fd11cf53a34b0e5f27ab3915d8395b381/src/sheaf_of_modules.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4878298387108655}}
{"text": "import separation.heap.lemmas\nimport util.meta.tactic\n\nuniverses u\n\nnamespace heap\n\ndef heap.le (hp₀ hp₁ : heap) : Prop :=\n∃ hp, some hp₁ = part (some hp₀) hp\n\ninstance : has_le heap :=\n⟨ heap.le ⟩\n\ninstance : partial_order heap :=\n{ le := heap.le\n, le_refl := by { intro x, existsi (some heap.emp), simp, }\n, le_trans := by { introv,\n                   simp [has_le.le,heap.le],\n                   intros hp₀ h₀ hp₁ h₁,\n                   -- have : hp₀ ## hp₁, admit,\n                   existsi part hp₀ hp₁,\n                   simp [h₁,h₀], ac_refl }\n, le_antisymm := by { introv,\n                      simp [has_le.le,heap.le],\n                      intros hp₀ h₀ hp₁ h₁,\n                      simp [h₀,part_assoc] at h₁,\n                      simp [h₁.left] at h₀,\n                      subst b, }\n}\n\nlemma part'_delete_maplet (p : pointer) (v : word) (hp : heap)\n  (h : heap.delete p 1 hp ## maplet p v)\n  (h' : maplet p v ≤ hp)\n: part' (heap.delete p 1 hp) (maplet p v) = hp :=\nbegin\n  funext p',\n  by_cases h : (p = p'),\n  { simp [part', heap.delete, maplet, if_pos, h],\n    unfold has_le.le heap.le at h',\n    cases h' with hp' h', cases hp' with hp',\n    { contradiction },\n    have h₂ := eq_part'_of_some_eq_part _ _ _ h',\n    rw [h₂,part',maplet,if_pos h],\n    simp },\n  { simp [part', heap.delete, maplet, if_neg, h] }\nend\n\nend heap\n", "meta": {"author": "unitb", "repo": "separation-logic", "sha": "bdde6fc8f16fd43932aea9827d6c63cadd91c2e8", "save_path": "github-repos/lean/unitb-separation-logic", "path": "github-repos/lean/unitb-separation-logic/separation-logic-bdde6fc8f16fd43932aea9827d6c63cadd91c2e8/src/separation/heap/instances.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4878129358998035}}
{"text": "/-\nCopyright (c) 2023 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Wojciech Nawrocki\n-/\n\nimport Mathlib.Data.Finset.Card\nimport Mathlib.Data.Finset.Powerset\nimport Mathlib.Data.PNat.Basic\nimport Mathlib.Algebra.BigOperators.Basic\nimport ProofChecker.Data.ICnf\nimport ProofChecker.Model.PropVars\n\nopen Nat\nabbrev Cube := Array ILit\n\nnamespace ILit\n\ntheorem mkPos_var_true (l : ILit) (h : l.polarity = true) :\n    mkPos (var l) = l := by\n  conv => rhs; rw [←eta l]; simp [h, mk]\n\ntheorem mkPos_var_false (l : ILit) (h : l.polarity = false) :\n    mkPos (var l) = -l := by\n  conv => rhs; rw [←eta_neg l]; simp [h, mk]\n\nend ILit\n\nnamespace PropForm\n\ndef partitioned [DecidableEq ν]: PropForm ν → Prop\n  | tr         => True\n  | fls        => True\n  | var _      => True\n  | neg φ      => φ.partitioned\n  | disj φ ψ   => φ.partitioned ∧ ψ.partitioned ∧ ∀ v, ¬ (φ.eval v ∧ ψ.eval v)\n  | conj φ ψ   => φ.partitioned ∧ ψ.partitioned ∧ (φ.vars ∩ ψ.vars = ∅)\n  | impl _ _   => False\n  | biImpl _ _ => False\n\ndef listConj (φs : List (PropForm Var)) : PropForm Var :=\n  φs.foldr (init := .tr) (f := .conj)\n\ndef listConjTerm' (φs : List (PropForm Var)) : PropTerm Var :=\n  φs.foldr (init := ⊤) (f := (⟦·⟧ ⊓ ·)) -- fold using the monocle capybara operator\n\ndef listConjTerm (φs : List (PropTerm Var)) : PropTerm Var :=\n  φs.foldr (init := ⊤) (f := (· ⊓ ·)) \n\nopen PropTerm in\ntheorem satisfies_listConjTerm (φs : List (PropTerm Var)) (τ : PropAssignment Var) :\n    τ ⊨ listConjTerm φs ↔ ∀ φ ∈ φs, τ ⊨ φ := by\n  dsimp [listConjTerm]\n  induction φs <;> simp_all\n  \n@[simp]\ntheorem listConjTerm_nil : listConjTerm [] = ⊤ := rfl\n\nlemma mem_vars_foldr_conj (φs : List (PropForm Var)) (x : Var) :\n    x ∈ (φs.foldr (init := PropForm.tr) (f := .conj)).vars ↔\n      ∃ i : Fin (φs.length), x ∈ (φs.get i).vars := by\n  induction φs\n  . simp [PropForm.vars]\n  . next φ φs ih =>\n    simp [PropForm.vars, ih, Fin.exists_fin_succ]\n    \ntheorem partitioned_listConj (φs : List (PropForm Var)) :\n    (listConj φs).partitioned ↔\n      ∀ i : Fin φs.length, (φs.get i).partitioned ∧\n      ∀ j : Fin φs.length, i ≠ j → (φs.get i).vars ∩ (φs.get j).vars = ∅ := by\n  induction φs\n  . dsimp [listConj, partitioned]; simp\n  . next φ φs ih =>\n    dsimp [listConj, partitioned] at *\n    simp only [ih, Finset.inter_self, List.get, not_true, IsEmpty.forall_iff, true_and,\n      add_eq, add_zero, Fin.eta, mem_vars_foldr_conj, Fin.forall_fin_succ]\n    have aux : vars φ ∩ vars (List.foldr conj tr φs) = ∅ ↔\n        ∀ i : Fin (List.length φs), vars φ ∩ vars (List.get φs i) = ∅ := by\n      simp only [Finset.eq_empty_iff_forall_not_mem, Finset.mem_inter, not_and, mem_vars_foldr_conj,\n        not_exists]\n      aesop\n    have aux2 : ∀ i : Fin (List.length φs),\n        vars (List.get φs i) ∩ vars φ = vars φ ∩ vars (List.get φs i) := by\n      intro i; rw [Finset.inter_comm]\n    have aux3 : ∀ i : Fin (List.length φs), ¬ 0 = Fin.succ i := by\n      intro i; apply Ne.symm; apply Fin.succ_ne_zero\n    aesop\n\ndef arrayConj (φs : Array (PropForm Var)) : PropForm Var := listConj φs.data\n\ntheorem mem_vars_arrayConj (φs : Array (PropForm Var)) (x : Var) :\n    x ∈ (arrayConj φs).vars ↔ ∃ i : Fin φs.size, x ∈ φs[i].vars :=\n  mem_vars_foldr_conj φs.data x\n\ntheorem partitioned_arrayConj (φs : Array (PropForm Var)) :\n    (arrayConj φs).partitioned ↔\n      ∀ i : Fin φs.size, φs[i].partitioned ∧\n      ∀ j : Fin φs.size, i ≠ j → φs[i].vars ∩ φs[j].vars = ∅ := by\n  dsimp [arrayConj]; rw [partitioned_listConj]; rfl\n\ndef arrayConjTerm (φs : Array (PropForm Var)) : PropTerm Var :=\n  φs.data.foldr (init := ⊤) (f := fun φ acc => ⟦φ⟧ ⊓ acc)\n  \ntheorem arrayConjTerm_eq_listConjTerm_data (φs : Array (PropForm Var)) :\n    arrayConjTerm φs = listConjTerm (φs.data.map (⟦·⟧)) := by\n  dsimp [arrayConjTerm, listConjTerm]\n  induction φs.data <;> simp_all\n\n@[simp]\ntheorem mk_arrayConj (φs : Array (PropForm Var)) : ⟦arrayConj φs⟧ = arrayConjTerm φs := by\n  dsimp [arrayConj, listConj, arrayConjTerm]\n  induction φs.data <;> simp_all\n\nopen PropTerm in\ntheorem satisfies_arrayConjTerm (φs : Array (PropForm Var)) (τ : PropAssignment Var) :\n    τ ⊨ arrayConjTerm φs ↔ ∀ φ ∈ φs.data, τ ⊨ ⟦φ⟧ := by\n  dsimp [arrayConjTerm]\n  induction φs.data <;> aesop\n\ndef withPolarity (p : PropForm Var) (l : ILit) := cond (l.polarity) p p.neg\n\n@[simp] theorem withPolarity_mkPos (p : PropForm Var) (x : Var) :\n  withPolarity p (.mkPos x) = p := by simp [withPolarity]\n\n@[simp] theorem withPolarity_mkNeg (p : PropForm Var) (x : Var) :\n  withPolarity p (.mkNeg x) = p.neg := by simp [withPolarity]\n\nend PropForm\n\n/-\nThe current implementation assumes that nodes are added consecutively, without gaps, and throws an\nexception otherwise. This enables us to maintain the invariant that the variable (possibly an\nextension variable) corresponding to the entry at index `n` is `n + 1`.\n\nWe nonetheless store the variable anyhow, to make it easier to loosen that requirement in the\nfuture. We can do that straightforwardly by adding a hashmap that maps each variable to the\ncorresponding index.\n-/\n\ninductive PogElt where\n  | var  : Var → PogElt\n  | disj : Var → ILit → ILit → PogElt\n  | conj : Var → Cube → PogElt\nderiving Repr, DecidableEq, Inhabited\n\nnamespace PogElt\n\ndef varNum : PogElt → Var\n  | var x      => x\n  | disj x _ _ => x\n  | conj x _   => x\n\n-- If we generalize to let variables come in any order, we need only change this to add the indexing\n-- function and require `index left.var < index n`, etc.\n\ndef args_decreasing : PogElt → Prop\n  | var _             => true\n  | disj n left right => left.var < n ∧ right.var < n\n  | conj n args       =>  ∀ i : Fin args.size, args[i].var < n\n\nend PogElt\n\n-- To generalize this, add a hashmap for the indexing function.\n\nstructure Pog where\n  elts : Array PogElt\n  wf : ∀ i : Fin elts.size, elts[i].args_decreasing\n  inv : ∀ i : Fin elts.size, i = elts[i].varNum.natPred\n\ndef PogError := String\n\ninstance : ToString PogError where\n  toString := id\n\nnamespace Pog\nopen PogElt\n\ndef empty : Pog where\n  elts := #[]\n  wf := fun i => i.elim0\n  inv := fun i => i.elim0\n\ndef push (pog : Pog) (pogElt : PogElt)\n    (hwf : pogElt.args_decreasing) (hinv : pogElt.varNum = succPNat pog.elts.size) : Pog where\n  elts := pog.elts.push pogElt\n  wf := by\n    intro ⟨i, h'⟩\n    rw [Array.size_push] at h'\n    cases (lt_or_eq_of_le (le_of_lt_succ h'))\n    . case inl h' =>\n      dsimp; rw [Array.get_push_lt _ _ _ h']\n      apply pog.wf ⟨i, h'⟩\n    . case inr h' =>\n      dsimp; cases h'; rw [Array.get_push_eq]\n      exact hwf\n  inv := by\n      intro ⟨i, h'⟩\n      rw [Array.size_push] at h'\n      cases (lt_or_eq_of_le (le_of_lt_succ h'))\n      . case inl h' =>\n        dsimp; rw [Array.get_push_lt _ _ _ h']\n        apply pog.inv ⟨i, h'⟩\n      . case inr h' =>\n        cases h'; dsimp\n        rw [Array.get_push_eq, hinv, natPred_succPNat]\n\ntheorem get_push_elts_lt (pog : Pog) (pogElt : PogElt)\n      (hwf : pogElt.args_decreasing) (hinv : pogElt.varNum = succPNat pog.elts.size)\n      (i : Nat) (h : i < pog.elts.size) (h' : i < (pog.push pogElt hwf hinv).elts.size) :\n    (pog.push pogElt hwf hinv).elts[i] = pog.elts[i] :=\n  Array.get_push_lt _ _ _ h\n\nlemma get_push_elts_nat_Pred_varNum (pog : Pog) (pogElt : PogElt)\n      (hwf : pogElt.args_decreasing) (hinv : pogElt.varNum = succPNat pog.elts.size)\n      (h' : PNat.natPred (varNum pogElt) < Array.size (push pog pogElt hwf hinv).elts) :\n    (pog.push pogElt hwf hinv).elts[PNat.natPred pogElt.varNum] = pogElt := by\n  simp only [hinv, natPred_succPNat]\n  apply Array.get_push_eq\n\ndef size_push_elts (pog : Pog) (pogElt : PogElt)\n      (hwf : pogElt.args_decreasing) (hinv : pogElt.varNum = succPNat pog.elts.size) :\n    (pog.push pogElt hwf hinv).elts.size = pog.elts.size + 1 :=\n  Array.size_push _ _\n\ndef addVar (pog : Pog) (x : Var) : Except PogError Pog :=\n  if h : x = succPNat pog.elts.size then\n    .ok <| pog.push (var x) (by trivial) h\n  else\n    .error s!\"Pog variable {x} added, {pog.elts.size + 1} expected\"\n\ndef addDisj (pog : Pog) (x : Var) (left right : ILit) : Except PogError Pog :=\n  if h : x = succPNat pog.elts.size then\n    if hleft : left.var < x then\n      if hright : right.var < x then\n        .ok <| pog.push (disj x left right) ⟨hleft, hright⟩ h\n      else\n        .error s!\"Pog disjunction {x} added, right argument {right} missing\"\n    else\n      .error s!\"Pog disjunction {x} added, left argument {left} missing\"\n  else\n    .error s!\"Pog disjunction {x} added, {pog.elts.size + 1} expected\"\n\ndef addConj (pog : Pog)(x : Var) (args : Cube)  : Except PogError Pog :=\n  if h : x = succPNat pog.elts.size then\n    if hargs : ∀ i : Fin args.size, args[i].var < x then\n      .ok <| pog.push (conj x args) hargs h\n    else\n      .error s!\"Pog conjunction {x} added, argument missing\"\n  else\n    .error s!\"Pog conjunction {x} added, {pog.elts.size + 1} expected\"\n\n/-- This avoids having to repeat a calculation. -/\nlemma lt_aux {n : Nat} {y : Var} (hlt: y < x) (hinv: n = x.natPred) :\n  y.natPred < n := by rwa [hinv, PNat.natPred_lt_natPred]\n\ndef toPropForm (pog : Pog) (l : ILit) : PropForm Var :=\n  if h : l.var.natPred < pog.elts.size then\n    aux l.var.natPred h |>.withPolarity l\n  else\n    l.toPropForm\nwhere\n  aux : (i : Nat) → i < pog.elts.size → PropForm Var\n  | i, h =>\n    match pog.elts[i], pog.wf ⟨i, h⟩, pog.inv ⟨i, h⟩ with\n    | var x, _, _ => PropForm.var x\n    | disj x left right, ⟨hleft, hright⟩, hinv =>\n        have h_left_lt : left.var.natPred < i := lt_aux hleft hinv\n        have h_right_lt : right.var.natPred < i := lt_aux hright hinv\n        .disj (aux _ (h_left_lt.trans h) |>.withPolarity left)\n              (aux _ (h_right_lt.trans h) |>.withPolarity right)\n    | conj x args, hwf, hinv =>\n        .arrayConj <| Array.ofFn fun (j : Fin args.size) =>\n          have h_lt : args[j].var.natPred < i := lt_aux (hwf j) hinv\n          aux args[j].var.natPred (h_lt.trans h) |>.withPolarity args[j]\n\ntheorem toPropForm_of_polarity_eq_false (pog : Pog) (l : ILit) (hl : l.polarity = false) :\n    pog.toPropForm l = .neg (pog.toPropForm (-l)) := by\n  rw [toPropForm]\n  split\n  . next h =>\n    rw [toPropForm, ILit.var_negate, dif_pos h, PropForm.withPolarity, hl, cond_false,\n      PropForm.withPolarity, ILit.polarity_negate, hl, Bool.not_false, cond_true]\n  . next h =>\n    rw [toPropForm, ILit.var_negate, dif_neg h]\n    rw [ILit.toPropForm, hl]; simp only [ite_false, PropForm.neg.injEq]\n    rw [ILit.toPropForm, ILit.polarity_negate, hl]; simp only [ILit.var_negate, ite_true]\n\ntheorem toPropForm_aux_eq (pog : Pog) (i : Nat) (h : i < pog.elts.size) :\n  toPropForm.aux pog i h =\n    match pog.elts[i] with\n      | var x => PropForm.var x\n      | disj _ left right => .disj (pog.toPropForm left) (pog.toPropForm right)\n      | conj _ args =>\n          .arrayConj <| Array.ofFn fun (j : Fin args.size) => pog.toPropForm args[j] := by\n  rw [toPropForm.aux]\n  split\n  . simp [*]\n  . next x left right hleft hright hinv heq _ _ =>\n    simp only [heq]\n    have h_left_lt : left.var.natPred < i := lt_aux hleft hinv\n    have h_right_lt : right.var.natPred < i := lt_aux hright hinv\n    rw [toPropForm, dif_pos (h_left_lt.trans h), toPropForm, dif_pos (h_right_lt.trans h)]\n  . next x args hwf hinv heq _ _ =>\n    simp only [heq]\n    congr; ext j\n    have h_lt : args[j].var.natPred < i := lt_aux (hwf j) hinv\n    rw [toPropForm, dif_pos (h_lt.trans h)]\n\ntheorem toPropForm_push_of_lt (pog : Pog) (pogElt : PogElt)\n      (hwf : pogElt.args_decreasing) (hinv : pogElt.varNum = succPNat pog.elts.size)\n      (l : ILit) (hl : PNat.natPred l.var < pog.elts.size) :\n    (pog.push pogElt hwf hinv).toPropForm l = pog.toPropForm l := by\n  have hl' : PNat.natPred l.var < (pog.push pogElt hwf hinv).elts.size := by\n    dsimp [Pog.push]; rw [Array.size_push]; exact hl.trans (lt_succ_self _)\n  rw [toPropForm, toPropForm, dif_pos hl, dif_pos hl', aux]\nwhere\n  aux :\n    (i : Nat) → (h : i < pog.elts.size) → (h' : i < (pog.push pogElt hwf hinv).elts.size) →\n     toPropForm.aux (pog.push pogElt hwf hinv) i h' = toPropForm.aux pog i h\n  | i, h, h' => by\n    rw [toPropForm.aux]; conv => rhs; rw [toPropForm.aux]\n    have heq := pog.get_push_elts_lt pogElt hwf hinv i h h'\n    split <;> split <;> simp [*] at heq <;> try { injection heq } <;> try { simp only [heq] }\n    . next x left right hleft hright hinv' _ _ _ =>\n      simp only [heq]\n      have _ : left.var.natPred < i := by\n        dsimp at hinv'; rwa [hinv', PNat.natPred_lt_natPred]\n      have _ : right.var.natPred < i := by\n        dsimp at hinv'; rwa [hinv', PNat.natPred_lt_natPred]\n      rw [aux (PNat.natPred (ILit.var left)), aux (PNat.natPred (ILit.var right))]\n    . next x args hargs hinv' _ _ _ _ _ _ x' args' _ _ _ _ _ =>\n      cases heq.2\n      cases heq.1\n      apply congr_arg PropForm.arrayConj\n      apply congr_arg Array.ofFn\n      ext j; dsimp\n      have _ : args[j].var.natPred < i := by\n        dsimp at hinv'; rw [hinv', PNat.natPred_lt_natPred]\n        exact hargs j\n      rw [aux (PNat.natPred (ILit.var _))]\n\ntheorem toPropForm_push_of_ne (y : Var) (pog : Pog) (pogElt : PogElt)\n      (hwf : pogElt.args_decreasing) (hinv : pogElt.varNum = succPNat pog.elts.size)\n      (hne : pogElt.varNum ≠ y) :\n    (pog.push pogElt hwf hinv).toPropForm (.mkPos y) = pog.toPropForm (.mkPos y) := by\n  rw [toPropForm, toPropForm]\n  simp only [ILit.var_mkPos, PropForm.withPolarity_mkPos]\n  cases le_or_gt pogElt.varNum y\n  case inl hle =>\n    have : Array.size pog.elts ≤ PNat.natPred y :=\n      by rwa [←succPNat_le_succPNat, ←hinv, PNat.succPNat_natPred]\n    rw [dif_neg (not_lt_of_le this), dif_neg]\n    rw [not_lt, size_push_elts, succ_le_iff]\n    apply (lt_of_le_of_ne this)\n    contrapose! hne\n    rw [hinv, hne, PNat.succPNat_natPred]\n  case inr hle =>\n    have : PNat.natPred y < Array.size pog.elts :=\n      by rwa [←succPNat_lt_succPNat, ←hinv, PNat.succPNat_natPred]\n    rw [dif_pos this, dif_pos, toPropForm_push_of_lt.aux]\n    rw [size_push_elts]\n    apply lt_succ_of_lt this\n\ntheorem toPropForm_empty (l : ILit) : empty.toPropForm l = l.toPropForm := by\n  dsimp [toPropForm]\n  split\n  next h =>\n    simp [empty] at h\n  next =>\n    rfl\n\ntheorem toPropForm_neg (p : Pog) (x : Var) :\n    p.toPropForm (.mkNeg x) = .neg (p.toPropForm (.mkPos x)) := by\n  rw [toPropForm, toPropForm]; simp; split <;> simp [ILit.toPropForm]\n\ntheorem toPropForm_addVar (p p' : Pog) (x : Var) :\n    p.addVar x = .ok p' →\n    p'.toPropForm (.mkPos x) = .var x := by\n  rw [addVar]\n  split\n  . next h =>\n    intro h'\n    injection h' with h'\n    rw [←h', toPropForm]\n    split\n    . next h'' =>\n      rw [toPropForm.aux]\n      have heq : ∀ h1 h2,\n          (push p (var x) h1 h2).elts[PNat.natPred (ILit.var (ILit.mkPos x))] = var x :=\n        fun h1 h2 => get_push_elts_nat_Pred_varNum _ _ _ _ _\n      split <;> simp only [heq] at *\n      next x' _ _ _ _ heq' =>\n        injection heq' with heq'\n        simp [heq']\n    . simp [ILit.toPropForm]\n  . intro; contradiction\n\ntheorem toPropForm_addVar_lit (p p' : Pog) (l : ILit) :\n    p.addVar l.var = .ok p' →\n    p'.toPropForm l = l.toPropForm := by\n  cases l.mkPos_or_mkNeg <;>\n    next hMk =>\n      intro h\n      rw [hMk]\n      have := toPropForm_addVar _ _ _ h\n      simp [toPropForm_neg, this]\n\ntheorem toPropForm_addVar_of_ne (x y : Var) (p p' : Pog) :\n    p.addVar x = .ok p' → x ≠ y →\n    p'.toPropForm (.mkPos y) = p.toPropForm (.mkPos y) := by\n  rw [addVar]\n  split\n  . next h =>\n    intro h'\n    injection h' with h'\n    intro hne\n    rw [←h']\n    apply toPropForm_push_of_ne\n    exact hne\n  . intro; contradiction\n\ntheorem toPropForm_addVar_lit_of_ne (x : Var) (l : ILit) (p p' : Pog) :\n    p.addVar x = .ok p' → x ≠ l.var →\n    p'.toPropForm l = p.toPropForm l := by\n  cases l.mkPos_or_mkNeg <;>\n    next hMk =>\n      intro h hNe\n      rw [hMk]\n      have := toPropForm_addVar_of_ne _ _ _ _ h hNe\n      simp [toPropForm_neg, this]\n\ntheorem toPropForm_addDisj (x : Var) (l₁ l₂ : ILit) (p p' : Pog) :\n    p.addDisj x l₁ l₂ = .ok p' →\n    p'.toPropForm (.mkPos x) = .disj (p.toPropForm l₁) (p.toPropForm l₂) := by\n  rw [addDisj]\n  split\n  . next h =>\n    split\n    . next hleft =>\n      split\n      . next hright =>\n          intro h'\n          injection h' with h'\n          rw [←h', toPropForm]\n          split\n          . next h'' =>\n            rw [toPropForm.aux]\n            have heq : ∀ h1 h2,\n                (push p (disj x l₁ l₂) h1 h2).elts[PNat.natPred (ILit.var (ILit.mkPos x))] =\n                  disj x l₁ l₂ :=\n              fun h1 h2 => get_push_elts_nat_Pred_varNum _ _ _ _ _\n            split <;> simp only [heq] at *\n            next x' left' right' _ _ _ _ _ heq' =>\n              injection heq' with heq₁ heq₂ heq₃\n              cases heq₁\n              cases heq₂\n              cases heq₃\n              simp only [PropForm.withPolarity_mkPos, PropForm.disj.injEq]\n              constructor\n              . rw [toPropForm, dif_pos, toPropForm_push_of_lt.aux]\n                rwa [←succPNat_lt_succPNat, PNat.succPNat_natPred, ←h]\n              . rw [toPropForm, dif_pos, toPropForm_push_of_lt.aux]\n                rwa [←succPNat_lt_succPNat, PNat.succPNat_natPred, ←h]\n          . next h'' =>\n            exfalso\n            apply h''\n            rw [size_push_elts, h, ILit.var_mkPos, natPred_succPNat]\n            exact lt_succ_self _\n      . intro; contradiction\n    . intro; contradiction\n  . intro; contradiction\n\ntheorem toPropForm_addDisj_of_ne (x y : Var) (l₁ l₂ : ILit) (p p' : Pog) :\n    p.addDisj x l₁ l₂ = .ok p' → x ≠ y →\n    p'.toPropForm (.mkPos y) = p.toPropForm (.mkPos y) := by\n  rw [addDisj]\n  split\n  . next h =>\n    split\n    . next hleft =>\n      split\n      . next hright =>\n          intro h'\n          injection h' with h'\n          intro hne\n          rw [←h']\n          apply toPropForm_push_of_ne\n          exact hne\n      . intro; contradiction\n    . intro; contradiction\n  . intro; contradiction\n\ntheorem toPropForm_addDisj_lit_of_ne (x : Var) (l l₁ l₂ : ILit) (p p' : Pog) :\n    p.addDisj x l₁ l₂ = .ok p' → x ≠ l.var →\n    p'.toPropForm l = p.toPropForm l := by\n  cases l.mkPos_or_mkNeg <;>\n    next hMk =>\n      intro h hNe\n      rw [hMk]\n      have := p.toPropForm_addDisj_of_ne _ _ _ _ _ h hNe\n      simp [toPropForm_neg, this]\n\ntheorem toPropForm_addConj (x : Var) (ls : Array ILit) (p p' : Pog) :\n    p.addConj x ls = .ok p' →\n    p'.toPropForm (.mkPos x) = .arrayConj (ls.map p.toPropForm) := by\n  rw [addConj]\n  split\n  . next h =>\n    split\n    . next hargs =>\n        intro h'\n        injection h' with h'\n        rw [←h', toPropForm]\n        split\n        . next h'' =>\n          rw [toPropForm.aux]\n          have heq : ∀ h1 h2,\n              (push p (conj x ls) h1 h2).elts[PNat.natPred (ILit.var (ILit.mkPos x))] =\n                conj x ls :=\n            fun h1 h2 => get_push_elts_nat_Pred_varNum _ _ _ _ _\n          split <;> simp only [heq] at *\n          next x' ls' _ _ _ _ _ heq' =>\n            injection heq' with heq₁ heq₂\n            cases heq₁\n            cases heq₂\n            simp only [PropForm.withPolarity_mkPos, PropForm.conj.injEq]\n            congr\n            apply Array.ext\n            . rw [Array.size_map, Array.size_ofFn]\n            . intro j hj₁ hj₂\n              simp only [getElem_fin, Array.getElem_ofFn, Array.getElem_map]\n              rw [toPropForm, dif_pos, toPropForm_push_of_lt.aux]\n              rw [←succPNat_lt_succPNat, PNat.succPNat_natPred, ←h]\n              rw [Array.size_ofFn] at hj₁\n              apply hargs ⟨j, hj₁⟩\n        . next h'' =>\n          exfalso\n          apply h''\n          rw [size_push_elts, h, ILit.var_mkPos, natPred_succPNat]\n          exact lt_succ_self _\n    . intro; contradiction\n  . intro; contradiction\n\ntheorem toPropForm_addConj_of_ne (x y : Var) (ls : Array ILit) (p p' : Pog) :\n    p.addConj x ls = .ok p' → x ≠ y →\n    p'.toPropForm (.mkPos y) = p.toPropForm (.mkPos y) := by\n  rw [addConj]\n  split\n  . next h =>\n    split\n    . next args =>\n        intro h'\n        injection h' with h'\n        intro hne\n        rw [←h']\n        apply toPropForm_push_of_ne\n        exact hne\n    . intro; contradiction\n  . intro; contradiction\n\ntheorem toPropForm_addConj_lit_of_ne (x : Var) (l : ILit) (ls : Array ILit) (p p' : Pog) :\n    p.addConj x ls = .ok p' → x ≠ l.var →\n    p'.toPropForm l = p.toPropForm l := by\n  cases l.mkPos_or_mkNeg <;>\n    next hMk =>\n      intro h hNe\n      rw [hMk]\n      have := p.toPropForm_addConj_of_ne _ _ _ _ h hNe\n      simp [toPropForm_neg, this]\n\n/-\nEven though we are not using this now, a Pog can keep track of its variables, and if the client\ncan ensure that conjunctions and disjunctions refer to previous variables, we can eliminate the\nchecks in `addDisj` and `addConj`.\n-/\n\ndef vars (pog : Pog) : Finset Var := Finset.range pog.elts.size |>.image succPNat\n\ntheorem mem_vars_aux {pog : Pog} {n : Var} : n ∈ pog.vars ↔ n ≤ pog.elts.size := by\n  simp only [Pog.vars, Finset.mem_image, Finset.mem_range]\n  constructor\n  . rintro ⟨m, hm, rfl⟩\n    exact hm\n  . rintro hle\n    use n.natPred\n    rw [lt_iff_add_one_le, ←succ_eq_add_one, ←succPNat_coe, PNat.succPNat_natPred]\n    exact ⟨hle, rfl⟩\n\ntheorem mem_vars {pog : Pog} {n : Var} :\n    n ∈ pog.vars ↔ ∃ i : Fin pog.elts.size, pog.elts[i].varNum = n := by\n  rw [mem_vars_aux]\n  constructor\n  . intro hle\n    have : n.natPred < pog.elts.size := by\n      apply lt_of_succ_le\n      rw [←succPNat_coe, PNat.succPNat_natPred]\n      exact hle\n    use ⟨n.natPred, this⟩\n    rw [←PNat.natPred_inj]\n    symm; apply pog.inv ⟨n.natPred, this⟩\n  . rintro ⟨i, rfl⟩\n    have := congr_arg succPNat (pog.inv i)\n    rw [PNat.succPNat_natPred] at this\n    rw [←this, succPNat_coe]\n    exact i.isLt\n\ntheorem vars_push (pog : Pog) (pogElt : PogElt)\n      (hwf : args_decreasing pogElt) (hinv : pogElt.varNum = succPNat pog.elts.size) :\n    vars (pog.push pogElt hwf hinv) = insert (succPNat pog.elts.size) pog.vars := by\n  ext i\n  rw [mem_vars_aux, Pog.push, Array.size_push, Finset.mem_insert, mem_vars_aux,\n          le_iff_eq_or_lt, ←Nat.lt_succ, ←succ_eq_add_one, ←succPNat_coe, PNat.coe_inj]\n\ntheorem vars_addVar {pog newPog : Pog} {n : Var} (h : (pog.addVar n) = .ok newPog) :\n    newPog.vars = insert n pog.vars := by\n  rw [addVar] at h\n  split at h\n  case inr h' =>\n    contradiction\n  case inl h' =>\n    ext i\n    injection h with h\n    rw [←h, vars_push, h']\n\ntheorem vars_addDisj {pog newPog : Pog} {n : Var} (left right : ILit)\n      (h : (pog.addDisj n left right) = .ok newPog) :\n    newPog.vars = insert n pog.vars := by\n  rw [addDisj] at h\n  split at h <;> try { contradiction }\n  split at h <;> try { contradiction }\n  split at h <;> try { contradiction }\n  next h' _ _ =>\n    ext i\n    injection h with h\n    rw [←h, vars_push, h']\n\ntheorem vars_addConj {pog newPog : Pog} {n : Var} (args : Array ILit)\n      (h : (pog.addConj n args) = .ok newPog) :\n    newPog.vars = insert n pog.vars := by\n  rw [addConj] at h\n  split at h <;> try { contradiction }\n  split at h <;> try { contradiction }\n  next h' _ =>\n    ext i\n    injection h with h\n    rw [←h, vars_push, h']\n\nend Pog", "meta": {"author": "rebryant", "repo": "cpog", "sha": "5e39029ce71de532fd4407c4768e7c2bf97798c8", "save_path": "github-repos/lean/rebryant-cpog", "path": "github-repos/lean/rebryant-cpog/cpog-5e39029ce71de532fd4407c4768e7c2bf97798c8/VerifiedChecker/ProofChecker/Data/Pog.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.7217432182679956, "lm_q1q2_score": 0.4877285179310754}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Sébastien Gouëzel, Zhouhang Zhou, Reid Barton\n-/\nimport logic.equiv.fin\nimport topology.dense_embedding\nimport topology.support\n\n/-!\n# Homeomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines homeomorphisms between two topological spaces. They are bijections with both\ndirections continuous. We denote homeomorphisms with the notation `≃ₜ`.\n\n# Main definitions\n\n* `homeomorph α β`: The type of homeomorphisms from `α` to `β`.\n  This type can be denoted using the following notation: `α ≃ₜ β`.\n\n# Main results\n\n* Pretty much every topological property is preserved under homeomorphisms.\n* `homeomorph.homeomorph_of_continuous_open`: A continuous bijection that is\n  an open map is a homeomorphism.\n\n-/\n\nopen set filter\nopen_locale topology\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\n\n/-- Homeomorphism between `α` and `β`, also called topological isomorphism -/\n@[nolint has_nonempty_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (α : Type*) (β : Type*) [topological_space α] [topological_space β]\n  extends α ≃ β :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` ≃ₜ `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n\ninstance : has_coe_to_fun (α ≃ₜ β) (λ _, α → β) := ⟨λe, e.to_equiv⟩\n\n@[simp] lemma homeomorph_mk_coe (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c) : α → β) = a :=\nrfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : α ≃ₜ β) : β ≃ₜ α :=\n{ continuous_to_fun  := h.continuous_inv_fun,\n  continuous_inv_fun := h.continuous_to_fun,\n  to_equiv := h.to_equiv.symm }\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : α ≃ₜ β) : α → β := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : α ≃ₜ β) : β → α := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply, -to_equiv)\n\n@[simp] lemma coe_to_equiv (h : α ≃ₜ β) : ⇑h.to_equiv = h := rfl\n@[simp] lemma coe_symm_to_equiv (h : α ≃ₜ β) : ⇑h.to_equiv.symm = h.symm := rfl\n\nlemma to_equiv_injective : function.injective (to_equiv : α ≃ₜ β → α ≃ β)\n| ⟨e, h₁, h₂⟩ ⟨e', h₁', h₂'⟩ rfl := rfl\n\n@[ext] lemma ext {h h' : α ≃ₜ β} (H : ∀ x, h x = h' x) : h = h' :=\nto_equiv_injective $ equiv.ext H\n\n@[simp] lemma symm_symm (h : α ≃ₜ β) : h.symm.symm = h := ext $ λ _, rfl\n\n/-- Identity map as a homeomorphism. -/\n@[simps apply {fully_applied := ff}]\nprotected def refl (α : Type*) [topological_space α] : α ≃ₜ α :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl α }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) : α ≃ₜ γ :=\n{ continuous_to_fun  := h₂.continuous_to_fun.comp h₁.continuous_to_fun,\n  continuous_inv_fun := h₁.continuous_inv_fun.comp h₂.continuous_inv_fun,\n  to_equiv := equiv.trans h₁.to_equiv h₂.to_equiv }\n\n@[simp] lemma trans_apply (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) (a : α) : h₁.trans h₂ a = h₂ (h₁ a) := rfl\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c).symm : β → α) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl α).symm = homeomorph.refl α := rfl\n\n@[continuity]\nprotected lemma continuous (h : α ≃ₜ β) : continuous h := h.continuous_to_fun\n\n@[continuity] -- otherwise `by continuity` can't prove continuity of `h.to_equiv.symm`\nprotected lemma continuous_symm (h : α ≃ₜ β) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : α ≃ₜ β) (x : β) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : α ≃ₜ β) (x : α) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\n@[simp] lemma self_trans_symm (h : α ≃ₜ β) : h.trans h.symm = homeomorph.refl α :=\nby { ext, apply symm_apply_apply }\n\n@[simp] lemma symm_trans_self (h : α ≃ₜ β) : h.symm.trans h = homeomorph.refl β :=\nby { ext, apply apply_symm_apply }\n\nprotected lemma bijective (h : α ≃ₜ β) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : α ≃ₜ β) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : α ≃ₜ β) : function.surjective h := h.to_equiv.surjective\n\n/-- Change the homeomorphism `f` to make the inverse function definitionally equal to `g`. -/\ndef change_inv (f : α ≃ₜ β) (g : β → α) (hg : function.right_inverse g f) : α ≃ₜ β :=\nhave g = f.symm, from funext (λ x, calc g x = f.symm (f (g x)) : (f.left_inv (g x)).symm\n                                        ... = f.symm x : by rw hg x),\n{ to_fun := f,\n  inv_fun := g,\n  left_inv := by convert f.left_inv,\n  right_inv := by convert f.right_inv,\n  continuous_to_fun := f.continuous,\n  continuous_inv_fun := by convert f.symm.continuous }\n\n@[simp] lemma symm_comp_self (h : α ≃ₜ β) : ⇑h.symm ∘ ⇑h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : α ≃ₜ β) : ⇑h ∘ ⇑h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : α ≃ₜ β) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : α ≃ₜ β) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : α ≃ₜ β) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : α ≃ₜ β) (s : set β) : h '' (h ⁻¹' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : α ≃ₜ β) (s : set α) : h ⁻¹' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : α ≃ₜ β) : inducing h :=\ninducing_of_inducing_compose h.continuous h.symm.continuous $\n  by simp only [symm_comp_self, inducing_id]\n\nlemma induced_eq (h : α ≃ₜ β) : topological_space.induced h ‹_› = ‹_› := h.inducing.1.symm\n\nprotected lemma quotient_map (h : α ≃ₜ β) : quotient_map h :=\nquotient_map.of_quotient_map_compose h.symm.continuous h.continuous $\n  by simp only [self_comp_symm, quotient_map.id]\n\nlemma coinduced_eq (h : α ≃ₜ β) : topological_space.coinduced h ‹_› = ‹_› :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : α ≃ₜ β) : embedding h :=\n⟨h.inducing, h.injective⟩\n\n/-- Homeomorphism given an embedding. -/\nnoncomputable def of_embedding (f : α → β) (hf : embedding f) : α ≃ₜ (set.range f) :=\n{ continuous_to_fun := hf.continuous.subtype_mk _,\n  continuous_inv_fun := by simp [hf.continuous_iff, continuous_subtype_coe],\n  to_equiv := equiv.of_injective f hf.inj }\n\nprotected lemma second_countable_topology [topological_space.second_countable_topology β]\n  (h : α ≃ₜ β) :\n  topological_space.second_countable_topology α :=\nh.inducing.second_countable_topology\n\nlemma is_compact_image {s : set α} (h : α ≃ₜ β) : is_compact (h '' s) ↔ is_compact s :=\nh.embedding.is_compact_iff_is_compact_image.symm\n\nlemma is_compact_preimage {s : set β} (h : α ≃ₜ β) : is_compact (h ⁻¹' s) ↔ is_compact s :=\nby rw ← image_symm; exact h.symm.is_compact_image\n\n@[simp] lemma comap_cocompact (h : α ≃ₜ β) : comap h (cocompact β) = cocompact α :=\n(comap_cocompact_le h.continuous).antisymm $\n  (has_basis_cocompact.le_basis_iff (has_basis_cocompact.comap h)).2 $ λ K hK,\n    ⟨h ⁻¹' K, h.is_compact_preimage.2 hK, subset.rfl⟩\n\n@[simp] lemma map_cocompact (h : α ≃ₜ β) : map h (cocompact α) = cocompact β :=\nby rw [← h.comap_cocompact, map_comap_of_surjective h.surjective]\n\nprotected lemma compact_space [compact_space α] (h : α ≃ₜ β) : compact_space β :=\n{ is_compact_univ := by { rw [← image_univ_of_surjective h.surjective, h.is_compact_image],\n    apply compact_space.is_compact_univ } }\n\nprotected lemma t0_space [t0_space α] (h : α ≃ₜ β) : t0_space β :=\nh.symm.embedding.t0_space\n\nprotected lemma t1_space [t1_space α] (h : α ≃ₜ β) : t1_space β :=\nh.symm.embedding.t1_space\n\nprotected lemma t2_space [t2_space α] (h : α ≃ₜ β) : t2_space β :=\nh.symm.embedding.t2_space\n\nprotected lemma t3_space [t3_space α] (h : α ≃ₜ β) : t3_space β :=\nh.symm.embedding.t3_space\n\nprotected lemma dense_embedding (h : α ≃ₜ β) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : α ≃ₜ β) {s : set β} : is_open (h ⁻¹' s) ↔ is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : α ≃ₜ β) {s : set α} : is_open (h '' s) ↔ is_open s :=\nby rw [← preimage_symm, is_open_preimage]\n\nprotected lemma is_open_map (h : α ≃ₜ β) : is_open_map h := λ s, h.is_open_image.2\n\n@[simp] lemma is_closed_preimage (h : α ≃ₜ β) {s : set β} : is_closed (h ⁻¹' s) ↔ is_closed s :=\nby simp only [← is_open_compl_iff, ← preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : α ≃ₜ β) {s : set α} : is_closed (h '' s) ↔ is_closed s :=\nby rw [← preimage_symm, is_closed_preimage]\n\nprotected lemma is_closed_map (h : α ≃ₜ β) : is_closed_map h := λ s, h.is_closed_image.2\n\nprotected lemma open_embedding (h : α ≃ₜ β) : open_embedding h :=\nopen_embedding_of_embedding_open h.embedding h.is_open_map\n\nprotected lemma closed_embedding (h : α ≃ₜ β) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\nprotected lemma normal_space [normal_space α] (h : α ≃ₜ β) : normal_space β :=\nh.symm.closed_embedding.normal_space\n\nlemma preimage_closure (h : α ≃ₜ β) (s : set β) : h ⁻¹' (closure s) = closure (h ⁻¹' s) :=\nh.is_open_map.preimage_closure_eq_closure_preimage h.continuous _\n\nlemma image_closure (h : α ≃ₜ β) (s : set α) : h '' (closure s) = closure (h '' s) :=\nby rw [← preimage_symm, preimage_closure]\n\n\n\nlemma image_interior (h : α ≃ₜ β) (s : set α) : h '' (interior s) = interior (h '' s) :=\nby rw [← preimage_symm, preimage_interior]\n\nlemma preimage_frontier (h : α ≃ₜ β) (s : set β) : h ⁻¹' (frontier s) = frontier (h ⁻¹' s) :=\nh.is_open_map.preimage_frontier_eq_frontier_preimage h.continuous _\n\nlemma image_frontier (h : α ≃ₜ β) (s : set α) : h '' frontier s = frontier (h '' s) :=\nby rw [←preimage_symm, preimage_frontier]\n\n@[to_additive]\nlemma _root_.has_compact_mul_support.comp_homeomorph {M} [has_one M] {f : β → M}\n  (hf : has_compact_mul_support f) (φ : α ≃ₜ β) : has_compact_mul_support (f ∘ φ) :=\nhf.comp_closed_embedding φ.closed_embedding\n\n@[simp] lemma map_nhds_eq (h : α ≃ₜ β) (x : α) : map h (𝓝 x) = 𝓝 (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : α ≃ₜ β) (x : α) : map h.symm (𝓝 (h x)) = 𝓝 x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : α ≃ₜ β) (x : α) : 𝓝 x = comap h (𝓝 (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : α ≃ₜ β) (y : β) : comap h (𝓝 y) = 𝓝 (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : α ≃ β` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : α ≃ β) (h₁ : continuous e) (h₂ : is_open_map e) :\n  α ≃ₜ β :=\n{ continuous_to_fun := h₁,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert ← h₂ s hs using 1,\n    apply e.image_eq_preimage\n  end,\n  to_equiv := e }\n\n@[simp] lemma comp_continuous_on_iff (h : α ≃ₜ β) (f : γ → α) (s : set γ) :\n  continuous_on (h ∘ f) s ↔ continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : α ≃ₜ β) {f : γ → α} :\n  continuous (h ∘ f) ↔ continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : α ≃ₜ β) {f : β → γ} :\n  continuous (f ∘ h) ↔ continuous f :=\nh.quotient_map.continuous_iff.symm\n\nlemma comp_continuous_at_iff (h : α ≃ₜ β) (f : γ → α) (x : γ) :\n  continuous_at (h ∘ f) x ↔ continuous_at f x :=\nh.inducing.continuous_at_iff.symm\n\nlemma comp_continuous_at_iff' (h : α ≃ₜ β) (f : β → γ) (x : α) :\n  continuous_at (f ∘ h) x ↔ continuous_at f (h x) :=\nh.inducing.continuous_at_iff' (by simp)\n\nlemma comp_continuous_within_at_iff (h : α ≃ₜ β) (f : γ → α) (s : set γ) (x : γ) :\n  continuous_within_at f s x ↔ continuous_within_at (h ∘ f) s x :=\nh.inducing.continuous_within_at_iff\n\n@[simp] lemma comp_is_open_map_iff (h : α ≃ₜ β) {f : γ → α} :\n  is_open_map (h ∘ f) ↔ is_open_map f :=\nbegin\n  refine ⟨_, λ hf, h.is_open_map.comp hf⟩,\n  intros hf,\n  rw [← function.comp.left_id f, ← h.symm_comp_self, function.comp.assoc],\n  exact h.symm.is_open_map.comp hf,\nend\n\n@[simp] lemma comp_is_open_map_iff' (h : α ≃ₜ β) {f : β → γ} :\n  is_open_map (f ∘ h) ↔ is_open_map f :=\nbegin\n  refine ⟨_, λ hf, hf.comp h.is_open_map⟩,\n  intros hf,\n  rw [← function.comp.right_id f, ← h.self_comp_symm, ← function.comp.assoc],\n  exact hf.comp h.symm.is_open_map,\nend\n\n/-- If two sets are equal, then they are homeomorphic. -/\ndef set_congr {s t : set α} (h : s = t) : s ≃ₜ t :=\n{ continuous_to_fun := continuous_inclusion h.subset,\n  continuous_inv_fun := continuous_inclusion h.symm.subset,\n  to_equiv := equiv.set_congr h }\n\n/-- Sum of two homeomorphisms. -/\ndef sum_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α ⊕ γ ≃ₜ β ⊕ δ :=\n{ continuous_to_fun  := h₁.continuous.sum_map h₂.continuous,\n  continuous_inv_fun := h₁.symm.continuous.sum_map h₂.symm.continuous,\n  to_equiv := h₁.to_equiv.sum_congr h₂.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α × γ ≃ₜ β × δ :=\n{ continuous_to_fun  := (h₁.continuous.comp continuous_fst).prod_mk\n    (h₂.continuous.comp continuous_snd),\n  continuous_inv_fun := (h₁.symm.continuous.comp continuous_fst).prod_mk\n    (h₂.symm.continuous.comp continuous_snd),\n  to_equiv := h₁.to_equiv.prod_congr h₂.to_equiv }\n\n@[simp] lemma prod_congr_symm (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  (h₁.prod_congr h₂).symm = h₁.symm.prod_congr h₂.symm := rfl\n\n@[simp] lemma coe_prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  ⇑(h₁.prod_congr h₂) = prod.map h₁ h₂ := rfl\n\nsection\nvariables (α β γ)\n\n/-- `α × β` is homeomorphic to `β × α`. -/\ndef prod_comm : α × β ≃ₜ β × α :=\n{ continuous_to_fun  := continuous_snd.prod_mk continuous_fst,\n  continuous_inv_fun := continuous_snd.prod_mk continuous_fst,\n  to_equiv := equiv.prod_comm α β }\n\n@[simp] lemma prod_comm_symm : (prod_comm α β).symm = prod_comm β α := rfl\n@[simp] lemma coe_prod_comm : ⇑(prod_comm α β) = prod.swap := rfl\n\n/-- `(α × β) × γ` is homeomorphic to `α × (β × γ)`. -/\ndef prod_assoc : (α × β) × γ ≃ₜ α × (β × γ) :=\n{ continuous_to_fun  := (continuous_fst.comp continuous_fst).prod_mk\n    ((continuous_snd.comp continuous_fst).prod_mk continuous_snd),\n  continuous_inv_fun := (continuous_fst.prod_mk (continuous_fst.comp continuous_snd)).prod_mk\n    (continuous_snd.comp continuous_snd),\n  to_equiv := equiv.prod_assoc α β γ }\n\n/-- `α × {*}` is homeomorphic to `α`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : α × punit ≃ₜ α :=\n{ to_equiv := equiv.prod_punit α,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} × α` is homeomorphic to `α`. -/\ndef punit_prod : punit × α ≃ₜ α :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : ⇑(punit_prod α) = prod.snd := rfl\n\n/-- If both `α` and `β` have a unique element, then `α ≃ₜ β`. -/\n@[simps] def _root_.homeomorph.homeomorph_of_unique [unique α] [unique β] : α ≃ₜ β :=\n{ continuous_to_fun := @continuous_const α β _ _ default,\n  continuous_inv_fun := @continuous_const β α _ _ default,\n  .. equiv.equiv_of_unique α β }\n\nend\n\n/-- If each `β₁ i` is homeomorphic to `β₂ i`, then `Π i, β₁ i` is homeomorphic to `Π i, β₂ i`. -/\n@[simps apply to_equiv] def Pi_congr_right {ι : Type*} {β₁ β₂ : ι → Type*}\n  [Π i, topological_space (β₁ i)] [Π i, topological_space (β₂ i)] (F : Π i, β₁ i ≃ₜ β₂ i) :\n  (Π i, β₁ i) ≃ₜ (Π i, β₂ i) :=\n{ continuous_to_fun := continuous_pi (λ i, (F i).continuous.comp $ continuous_apply i),\n  continuous_inv_fun := continuous_pi (λ i, (F i).symm.continuous.comp $ continuous_apply i),\n  to_equiv := equiv.Pi_congr_right (λ i, (F i).to_equiv) }\n\n@[simp] lemma Pi_congr_right_symm {ι : Type*} {β₁ β₂ : ι → Type*} [Π i, topological_space (β₁ i)]\n  [Π i, topological_space (β₂ i)] (F : Π i, β₁ i ≃ₜ β₂ i) :\n  (Pi_congr_right F).symm = Pi_congr_right (λ i, (F i).symm) := rfl\n\n/-- `ulift α` is homeomorphic to `α`. -/\ndef {u v} ulift {α : Type u} [topological_space α] : ulift.{v u} α ≃ₜ α :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(α ⊕ β) × γ` is homeomorphic to `α × γ ⊕ β × γ`. -/\ndef sum_prod_distrib : (α ⊕ β) × γ ≃ₜ α × γ ⊕ β × γ :=\nhomeomorph.symm $ homeomorph_of_continuous_open (equiv.sum_prod_distrib α β γ).symm\n  ((continuous_inl.prod_map continuous_id).sum_elim (continuous_inr.prod_map continuous_id)) $\n  (is_open_map_inl.prod is_open_map.id).sum_elim (is_open_map_inr.prod is_open_map.id)\n\n/-- `α × (β ⊕ γ)` is homeomorphic to `α × β ⊕ α × γ`. -/\ndef prod_sum_distrib : α × (β ⊕ γ) ≃ₜ α × β ⊕ α × γ :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {ι : Type*} {σ : ι → Type*} [Π i, topological_space (σ i)]\n\n/-- `(Σ i, σ i) × β` is homeomorphic to `Σ i, (σ i × β)`. -/\ndef sigma_prod_distrib : ((Σ i, σ i) × β) ≃ₜ (Σ i, (σ i × β)) :=\nhomeomorph.symm $ homeomorph_of_continuous_open (equiv.sigma_prod_distrib σ β).symm\n  (continuous_sigma $ λ i, continuous_sigma_mk.fst'.prod_mk continuous_snd)\n  (is_open_map_sigma.2 $ λ i, is_open_map_sigma_mk.prod is_open_map.id)\n\nend distrib\n\n/-- If `ι` has a unique element, then `ι → α` is homeomorphic to `α`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (ι α : Type*) [unique ι] [topological_space α] : (ι → α) ≃ₜ α :=\n{ to_equiv := equiv.fun_unique ι α,\n  continuous_to_fun := continuous_apply _,\n  continuous_inv_fun := continuous_pi (λ _, continuous_id) }\n\n/-- Homeomorphism between dependent functions `Π i : fin 2, α i` and `α 0 × α 1`. -/\n@[simps { fully_applied := ff }]\ndef {u} pi_fin_two (α : fin 2 → Type u) [Π i, topological_space (α i)] : (Π i, α i) ≃ₜ α 0 × α 1 :=\n{ to_equiv := pi_fin_two_equiv α,\n  continuous_to_fun := (continuous_apply 0).prod_mk (continuous_apply 1),\n  continuous_inv_fun := continuous_pi $ fin.forall_fin_two.2 ⟨continuous_fst, continuous_snd⟩ }\n\n/-- Homeomorphism between `α² = fin 2 → α` and `α × α`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 → α) ≃ₜ α × α :=\n{ to_equiv := fin_two_arrow_equiv α, ..  pi_fin_two (λ _, α) }\n\n/--\nA subset of a topological space is homeomorphic to its image under a homeomorphism.\n-/\n@[simps] def image (e : α ≃ₜ β) (s : set α) : s ≃ₜ e '' s :=\n{ continuous_to_fun := by continuity!,\n  continuous_inv_fun := by continuity!,\n  to_equiv := e.to_equiv.image s, }\n\n/-- `set.univ α` is homeomorphic to `α`. -/\n@[simps { fully_applied := ff }]\ndef set.univ (α : Type*) [topological_space α] : (univ : set α) ≃ₜ α :=\n{ to_equiv := equiv.set.univ α,\n  continuous_to_fun := continuous_subtype_coe,\n  continuous_inv_fun := continuous_id.subtype_mk _ }\n\n/-- `s ×ˢ t` is homeomorphic to `s × t`. -/\n@[simps] def set.prod (s : set α) (t : set β) : ↥(s ×ˢ t) ≃ₜ s × t :=\n{ to_equiv := equiv.set.prod s t,\n  continuous_to_fun := (continuous_subtype_coe.fst.subtype_mk _).prod_mk\n    (continuous_subtype_coe.snd.subtype_mk _),\n  continuous_inv_fun := (continuous_subtype_coe.fst'.prod_mk\n    continuous_subtype_coe.snd').subtype_mk _ }\n\nsection\n\nvariable {ι : Type*}\n\n/-- The topological space `Π i, β i` can be split as a product by separating the indices in ι\n  depending on whether they satisfy a predicate p or not.-/\n@[simps] def pi_equiv_pi_subtype_prod (p : ι → Prop) (β : ι → Type*) [Π i, topological_space (β i)]\n  [decidable_pred p] : (Π i, β i) ≃ₜ (Π i : {x // p x}, β i) × Π i : {x // ¬p x}, β i :=\n{ to_equiv := equiv.pi_equiv_pi_subtype_prod p β,\n  continuous_to_fun := by apply continuous.prod_mk; exact continuous_pi (λ j, continuous_apply j),\n  continuous_inv_fun := continuous_pi $ λ j, begin\n    dsimp only [equiv.pi_equiv_pi_subtype_prod], split_ifs,\n    exacts [(continuous_apply _).comp continuous_fst, (continuous_apply _).comp continuous_snd],\n  end }\n\nvariables [decidable_eq ι] (i : ι)\n\n/-- A product of topological spaces can be split as the binary product of one of the spaces and\n  the product of all the remaining spaces. -/\n@[simps] def pi_split_at (β : ι → Type*) [Π j, topological_space (β j)] :\n  (Π j, β j) ≃ₜ β i × Π j : {j // j ≠ i}, β j :=\n{ to_equiv := equiv.pi_split_at i β,\n  continuous_to_fun := (continuous_apply i).prod_mk (continuous_pi $ λ j, continuous_apply j),\n  continuous_inv_fun := continuous_pi $ λ j, by { dsimp only [equiv.pi_split_at],\n    split_ifs, subst h, exacts [continuous_fst, (continuous_apply _).comp continuous_snd] } }\n\n/-- A product of copies of a topological space can be split as the binary product of one copy and\n  the product of all the remaining copies. -/\n@[simps] def fun_split_at : (ι → β) ≃ₜ β × ({j // j ≠ i} → β) := pi_split_at i _\n\nend\n\nend homeomorph\n\n/-- An inducing equiv between topological spaces is a homeomorphism. -/\n@[simps] def equiv.to_homeomorph_of_inducing [topological_space α] [topological_space β] (f : α ≃ β)\n  (hf : inducing f) :\n  α ≃ₜ β :=\n{ continuous_to_fun := hf.continuous,\n  continuous_inv_fun := hf.continuous_iff.2 $ by simpa using continuous_id,\n  .. f }\n\nnamespace continuous\nvariables [topological_space α] [topological_space β]\n\nlemma continuous_symm_of_equiv_compact_to_t2 [compact_space α] [t2_space β]\n  {f : α ≃ β} (hf : continuous f) : continuous f.symm :=\nbegin\n  rw continuous_iff_is_closed,\n  intros C hC,\n  have hC' : is_closed (f '' C) := (hC.is_compact.image hf).is_closed,\n  rwa equiv.image_eq_preimage at hC',\nend\n\n/-- Continuous equivalences from a compact space to a T2 space are homeomorphisms.\n\nThis is not true when T2 is weakened to T1\n(see `continuous.homeo_of_equiv_compact_to_t2.t1_counterexample`). -/\n@[simps]\ndef homeo_of_equiv_compact_to_t2 [compact_space α] [t2_space β]\n  {f : α ≃ β} (hf : continuous f) : α ≃ₜ β :=\n{ continuous_to_fun := hf,\n  continuous_inv_fun := hf.continuous_symm_of_equiv_compact_to_t2,\n  ..f }\n\nend continuous\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/homeomorph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4877285098419044}}
{"text": "/-\nCopyright (c) 2022 Yuma Mizuno. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuma Mizuno, Junyan Xu\n-/\nimport category_theory.path_category\nimport category_theory.functor.fully_faithful\nimport category_theory.bicategory.free\nimport category_theory.bicategory.locally_discrete\n/-!\n# The coherence theorem for bicategories\n\nIn this file, we prove the coherence theorem for bicategories, stated in the following form: the\nfree bicategory over any quiver is locally thin.\n\nThe proof is almost the same as the proof of the coherence theorem for monoidal categories that\nhas been previously formalized in mathlib, which is based on the proof described by Ilya Beylin\nand Peter Dybjer. The idea is to view a path on a quiver as a normal form of a 1-morphism in the\nfree bicategory on the same quiver. A normalization procedure is then described by\n`normalize : pseudofunctor (free_bicategory B) (locally_discrete (paths B))`, which is a\npseudofunctor from the free bicategory to the locally discrete bicategory on the path category.\nIt turns out that this pseudofunctor is locally an equivalence of categories, and the coherence\ntheorem follows immediately from this fact.\n\n## Main statements\n\n* `locally_thin` : the free bicategory is locally thin, that is, there is at most one\n  2-morphism between two fixed 1-morphisms.\n\n## References\n\n* [Ilya Beylin and Peter Dybjer, Extracting a proof of coherence for monoidal categories from a\n   proof of normalization for monoids][beylin1996]\n-/\n\nopen quiver (path) quiver.path\n\nnamespace category_theory\n\nopen bicategory category\nopen_locale bicategory\n\nuniverses v u\n\nnamespace free_bicategory\n\nvariables {B : Type u} [quiver.{v+1} B]\n\n/-- Auxiliary definition for `inclusion_path`. -/\n@[simp]\ndef inclusion_path_aux {a : B} : ∀ {b : B}, path a b → hom a b\n| _ nil         := hom.id a\n| _ (cons p f)  := (inclusion_path_aux p).comp (hom.of f)\n\n/--\nThe discrete category on the paths includes into the category of 1-morphisms in the free\nbicategory.\n-/\ndef inclusion_path (a b : B) : discrete (path.{v+1} a b) ⥤ hom a b :=\ndiscrete.functor inclusion_path_aux\n\n/--\nThe inclusion from the locally discrete bicategory on the path category into the free bicategory\nas a prelax functor. This will be promoted to a pseudofunctor after proving the coherence theorem.\nSee `inclusion`.\n-/\ndef preinclusion (B : Type u) [quiver.{v+1} B] :\n  prelax_functor (locally_discrete (paths B)) (free_bicategory B) :=\n{ obj   := id,\n  map   := λ a b, (inclusion_path a b).obj,\n  map₂  := λ a b f g η, (inclusion_path a b).map η }\n\n@[simp]\nlemma preinclusion_obj (a : B) :\n  (preinclusion B).obj a = a :=\nrfl\n\n@[simp]\nlemma preinclusion_map₂ {a b : B} (f g : discrete (path.{v+1} a b)) (η : f ⟶ g) :\n  (preinclusion B).map₂ η = eq_to_hom (congr_arg _ (discrete.ext _ _ (discrete.eq_of_hom η))) :=\nbegin\n  rcases η with ⟨⟨⟩⟩,\n  cases discrete.ext _ _ η,\n  exact (inclusion_path a b).map_id _\nend\n\n/--\nThe normalization of the composition of `p : path a b` and `f : hom b c`.\n`p` will eventually be taken to be `nil` and we then get the normalization\nof `f` alone, but the auxiliary `p` is necessary for Lean to accept the definition of\n`normalize_iso` and the `whisker_left` case of `normalize_aux_congr` and `normalize_naturality`.\n-/\n@[simp]\ndef normalize_aux {a : B} : ∀ {b c : B}, path a b → hom b c → path a c\n| _ _ p (hom.of f)      := p.cons f\n| _ _ p (hom.id b)      := p\n| _ _ p (hom.comp f g)  := normalize_aux (normalize_aux p f) g\n\n/-\nWe may define\n```\ndef normalize_aux' : ∀ {a b : B}, hom a b → path a b\n| _ _ (hom.of f) := f.to_path\n| _ _ (hom.id b) := nil\n| _ _ (hom.comp f g) := (normalize_aux' f).comp (normalize_aux' g)\n```\nand define `normalize_aux p f` to be `p.comp (normalize_aux' f)` and this will be\nequal to the above definition, but the equality proof requires `comp_assoc`, and it\nthus lacks the correct definitional property to make the definition of `normalize_iso`\ntypecheck.\n```\nexample {a b c : B} (p : path a b) (f : hom b c) :\n  normalize_aux p f = p.comp (normalize_aux' f) :=\nby { induction f, refl, refl,\n  case comp : _ _ _ _ _ ihf ihg { rw [normalize_aux, ihf, ihg], apply comp_assoc } }\n```\n-/\n\n/--\nA 2-isomorphism between a partially-normalized 1-morphism in the free bicategory to the\nfully-normalized 1-morphism.\n-/\n@[simp]\ndef normalize_iso {a : B} : ∀ {b c : B} (p : path a b) (f : hom b c),\n  (preinclusion B).map ⟨p⟩ ≫ f ≅ (preinclusion B).map ⟨normalize_aux p f⟩\n| _ _ p (hom.of f)      := iso.refl _\n| _ _ p (hom.id b)      := ρ_ _\n| _ _ p (hom.comp f g)  := (α_ _ _ _).symm ≪≫\n    whisker_right_iso (normalize_iso p f) g ≪≫ normalize_iso (normalize_aux p f) g\n\n/--\nGiven a 2-morphism between `f` and `g` in the free bicategory, we have the equality\n`normalize_aux p f = normalize_aux p g`.\n-/\nlemma normalize_aux_congr {a b c : B} (p : path a b) {f g : hom b c} (η : f ⟶ g) :\n  normalize_aux p f = normalize_aux p g :=\nbegin\n  rcases η,\n  apply @congr_fun _ _ (λ p, normalize_aux p f),\n  clear p,\n  induction η,\n  case vcomp { apply eq.trans; assumption },\n  /- p ≠ nil required! See the docstring of `normalize_aux`. -/\n  case whisker_left  : _ _ _ _ _ _ _ ih { funext, apply congr_fun ih },\n  case whisker_right : _ _ _ _ _ _ _ ih { funext, apply congr_arg2 _ (congr_fun ih p) rfl },\n  all_goals { funext, refl }\nend\n\n/-- The 2-isomorphism `normalize_iso p f` is natural in `f`. -/\nlemma normalize_naturality {a b c : B} (p : path a b) {f g : hom b c} (η : f ⟶ g) :\n  (preinclusion B).map ⟨p⟩ ◁ η ≫ (normalize_iso p g).hom =\n    (normalize_iso p f).hom ≫\n      (preinclusion B).map₂ (eq_to_hom (discrete.ext _ _ (normalize_aux_congr p η))) :=\nbegin\n  rcases η, induction η,\n  case id : { simp },\n  case vcomp : _ _ _ _ _ _ _ ihf ihg\n  { rw [mk_vcomp, bicategory.whisker_left_comp],\n    slice_lhs 2 3 { rw ihg },\n    slice_lhs 1 2 { rw ihf },\n    simp },\n  case whisker_left : _ _ _ _ _ _ _ ih\n  /- p ≠ nil required! See the docstring of `normalize_aux`. -/\n  { dsimp, simp_rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc, ih, assoc] },\n  case whisker_right : _ _ _ _ _ h η ih\n  { dsimp,\n    rw [associator_inv_naturality_middle_assoc, ←comp_whisker_right_assoc, ih, comp_whisker_right],\n    have := dcongr_arg (λ x, (normalize_iso x h).hom) (normalize_aux_congr p (quot.mk _ η)),\n    dsimp at this, simp [this] },\n  all_goals { dsimp, dsimp [id_def, comp_def], simp }\nend\n\n@[simp]\nlemma normalize_aux_nil_comp {a b c : B} (f : hom a b) (g : hom b c) :\n  normalize_aux nil (f.comp g) = (normalize_aux nil f).comp (normalize_aux nil g) :=\nbegin\n  induction g generalizing a,\n  case id { refl },\n  case of { refl },\n  case comp : _ _ _ g _ ihf ihg { erw [ihg (f.comp g), ihf f, ihg g, comp_assoc] }\nend\n\n/-- The normalization pseudofunctor for the free bicategory on a quiver `B`. -/\ndef normalize (B : Type u) [quiver.{v+1} B] :\n  pseudofunctor (free_bicategory B) (locally_discrete (paths B)) :=\n{ obj       := id,\n  map       := λ a b f, ⟨normalize_aux nil f⟩,\n  map₂      := λ a b f g η, eq_to_hom $ discrete.ext _ _ $ normalize_aux_congr nil η,\n  map_id    := λ a, eq_to_iso $ discrete.ext _ _ rfl,\n  map_comp  := λ a b c f g, eq_to_iso $ discrete.ext _ _ $ normalize_aux_nil_comp f g }\n\n/-- Auxiliary definition for `normalize_equiv`. -/\ndef normalize_unit_iso (a b : free_bicategory B) :\n  𝟭 (a ⟶ b) ≅ (normalize B).map_functor a b ⋙ inclusion_path a b :=\nnat_iso.of_components (λ f, (λ_ f).symm ≪≫ normalize_iso nil f)\nbegin\n  intros f g η,\n  erw [left_unitor_inv_naturality_assoc, assoc],\n  congr' 1,\n  exact normalize_naturality nil η\nend\n\n/-- Normalization as an equivalence of categories. -/\ndef normalize_equiv (a b : B) : hom a b ≌ discrete (path.{v+1} a b) :=\nequivalence.mk ((normalize _).map_functor a b) (inclusion_path a b)\n  (normalize_unit_iso a b)\n  (discrete.nat_iso (λ f, eq_to_iso (by { induction f; induction f; tidy })))\n\n/-- The coherence theorem for bicategories. -/\ninstance locally_thin {a b : free_bicategory B} : quiver.is_thin (a ⟶ b) :=\nλ _ _, ⟨λ η θ, (normalize_equiv a b).functor.map_injective (subsingleton.elim _ _)⟩\n\n/-- Auxiliary definition for `inclusion`. -/\ndef inclusion_map_comp_aux {a b : B} : ∀ {c : B} (f : path a b) (g : path b c),\n  (preinclusion _).map (⟨f⟩ ≫ ⟨g⟩) ≅ (preinclusion _).map ⟨f⟩ ≫ (preinclusion _).map ⟨g⟩\n| _ f nil := (ρ_ ((preinclusion _).map ⟨f⟩)).symm\n| _ f (cons g₁ g₂) := whisker_right_iso (inclusion_map_comp_aux f g₁) (hom.of g₂) ≪≫ α_ _ _ _\n\n/--\nThe inclusion pseudofunctor from the locally discrete bicategory on the path category into the\nfree bicategory.\n-/\ndef inclusion (B : Type u) [quiver.{v+1} B] :\n  pseudofunctor (locally_discrete (paths B)) (free_bicategory B) :=\n{ map_id    := λ a, iso.refl (𝟙 a),\n  map_comp  := λ a b c f g, inclusion_map_comp_aux f.as g.as,\n  -- All the conditions for 2-morphisms are trivial thanks to the coherence theorem!\n  .. preinclusion B }\n\nend free_bicategory\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/bicategory/coherence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975978, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.4877285051289994}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.fintype.basic\n! leanprover-community/mathlib commit d78597269638367c3863d40d45108f52207e03cf\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.Image\n\n/-!\n# Finite types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines a typeclass to state that a type is finite.\n\n## Main declarations\n\n* `fintype α`:  Typeclass saying that a type is finite. It takes as fields a `finset` and a proof\n  that all terms of type `α` are in it.\n* `finset.univ`: The finset of all elements of a fintype.\n\nSee `data.fintype.card` for the cardinality of a fintype,\nthe equivalence with `fin (fintype.card α)`, and pigeonhole principles.\n\n## Instances\n\nInstances for `fintype` for\n* `{x // p x}` are in this file as `fintype.subtype`\n* `option α` are in `data.fintype.option`\n* `α × β` are in `data.fintype.prod`\n* `α ⊕ β` are in `data.fintype.sum`\n* `Σ (a : α), β a` are in `data.fintype.sigma`\n\nThese files also contain appropriate `infinite` instances for these types.\n\n`infinite` instances for `ℕ`, `ℤ`, `multiset α`, and `list α` are in `data.fintype.lattice`.\n\nTypes which have a surjection from/an injection to a `fintype` are themselves fintypes.\nSee `fintype.of_injective` and `fintype.of_surjective`.\n-/\n\n\nopen Function\n\nopen Nat\n\nuniverse u v\n\nvariable {α β γ : Type _}\n\n#print Fintype /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`elems] [] -/\n/-- `fintype α` means that `α` is finite, i.e. there are only\n  finitely many distinct elements of type `α`. The evidence of this\n  is a finset `elems` (a list up to permutation without duplicates),\n  together with a proof that everything of type `α` is in the list. -/\nclass Fintype (α : Type _) where\n  elems : Finset α\n  complete : ∀ x : α, x ∈ elems\n#align fintype Fintype\n-/\n\nnamespace Finset\n\nvariable [Fintype α] {s t : Finset α}\n\n#print Finset.univ /-\n/-- `univ` is the universal finite set of type `finset α` implied from\n  the assumption `fintype α`. -/\ndef univ : Finset α :=\n  Fintype.elems α\n#align finset.univ Finset.univ\n-/\n\n#print Finset.mem_univ /-\n@[simp]\ntheorem mem_univ (x : α) : x ∈ (univ : Finset α) :=\n  Fintype.complete x\n#align finset.mem_univ Finset.mem_univ\n-/\n\n#print Finset.mem_univ_val /-\n@[simp]\ntheorem mem_univ_val : ∀ x, x ∈ (univ : Finset α).1 :=\n  mem_univ\n#align finset.mem_univ_val Finset.mem_univ_val\n-/\n\n#print Finset.eq_univ_iff_forall /-\ntheorem eq_univ_iff_forall : s = univ ↔ ∀ x, x ∈ s := by simp [ext_iff]\n#align finset.eq_univ_iff_forall Finset.eq_univ_iff_forall\n-/\n\n#print Finset.eq_univ_of_forall /-\ntheorem eq_univ_of_forall : (∀ x, x ∈ s) → s = univ :=\n  eq_univ_iff_forall.2\n#align finset.eq_univ_of_forall Finset.eq_univ_of_forall\n-/\n\n#print Finset.coe_univ /-\n@[simp, norm_cast]\ntheorem coe_univ : ↑(univ : Finset α) = (Set.univ : Set α) := by ext <;> simp\n#align finset.coe_univ Finset.coe_univ\n-/\n\n#print Finset.coe_eq_univ /-\n@[simp, norm_cast]\ntheorem coe_eq_univ : (s : Set α) = Set.univ ↔ s = univ := by rw [← coe_univ, coe_inj]\n#align finset.coe_eq_univ Finset.coe_eq_univ\n-/\n\n#print Finset.Nonempty.eq_univ /-\ntheorem Nonempty.eq_univ [Subsingleton α] : s.Nonempty → s = univ :=\n  by\n  rintro ⟨x, hx⟩\n  refine' eq_univ_of_forall fun y => by rwa [Subsingleton.elim y x]\n#align finset.nonempty.eq_univ Finset.Nonempty.eq_univ\n-/\n\n#print Finset.univ_nonempty_iff /-\ntheorem univ_nonempty_iff : (univ : Finset α).Nonempty ↔ Nonempty α := by\n  rw [← coe_nonempty, coe_univ, Set.nonempty_iff_univ_nonempty]\n#align finset.univ_nonempty_iff Finset.univ_nonempty_iff\n-/\n\n#print Finset.univ_nonempty /-\ntheorem univ_nonempty [Nonempty α] : (univ : Finset α).Nonempty :=\n  univ_nonempty_iff.2 ‹_›\n#align finset.univ_nonempty Finset.univ_nonempty\n-/\n\n#print Finset.univ_eq_empty_iff /-\ntheorem univ_eq_empty_iff : (univ : Finset α) = ∅ ↔ IsEmpty α := by\n  rw [← not_nonempty_iff, ← univ_nonempty_iff, not_nonempty_iff_eq_empty]\n#align finset.univ_eq_empty_iff Finset.univ_eq_empty_iff\n-/\n\n#print Finset.univ_eq_empty /-\n@[simp]\ntheorem univ_eq_empty [IsEmpty α] : (univ : Finset α) = ∅ :=\n  univ_eq_empty_iff.2 ‹_›\n#align finset.univ_eq_empty Finset.univ_eq_empty\n-/\n\n#print Finset.univ_unique /-\n@[simp]\ntheorem univ_unique [Unique α] : (univ : Finset α) = {default} :=\n  Finset.ext fun x => iff_of_true (mem_univ _) <| mem_singleton.2 <| Subsingleton.elim x default\n#align finset.univ_unique Finset.univ_unique\n-/\n\n#print Finset.subset_univ /-\n@[simp]\ntheorem subset_univ (s : Finset α) : s ⊆ univ := fun a _ => mem_univ a\n#align finset.subset_univ Finset.subset_univ\n-/\n\ninstance : BoundedOrder (Finset α) :=\n  { Finset.orderBot with\n    top := univ\n    le_top := subset_univ }\n\n/- warning: finset.top_eq_univ -> Finset.top_eq_univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α], Eq.{succ u1} (Finset.{u1} α) (Top.top.{u1} (Finset.{u1} α) (OrderTop.toHasTop.{u1} (Finset.{u1} α) (Preorder.toLE.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))) (BoundedOrder.toOrderTop.{u1} (Finset.{u1} α) (Preorder.toLE.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))) (Finset.boundedOrder.{u1} α _inst_1)))) (Finset.univ.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α], Eq.{succ u1} (Finset.{u1} α) (Top.top.{u1} (Finset.{u1} α) (OrderTop.toTop.{u1} (Finset.{u1} α) (Preorder.toLE.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))) (BoundedOrder.toOrderTop.{u1} (Finset.{u1} α) (Preorder.toLE.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))) (Finset.boundedOrder.{u1} α _inst_1)))) (Finset.univ.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align finset.top_eq_univ Finset.top_eq_univₓ'. -/\n@[simp]\ntheorem top_eq_univ : (⊤ : Finset α) = univ :=\n  rfl\n#align finset.top_eq_univ Finset.top_eq_univ\n\n#print Finset.ssubset_univ_iff /-\ntheorem ssubset_univ_iff {s : Finset α} : s ⊂ univ ↔ s ≠ univ :=\n  @lt_top_iff_ne_top _ _ _ s\n#align finset.ssubset_univ_iff Finset.ssubset_univ_iff\n-/\n\n#print Finset.codisjoint_left /-\ntheorem codisjoint_left : Codisjoint s t ↔ ∀ ⦃a⦄, a ∉ s → a ∈ t := by\n  classical simp [codisjoint_iff, eq_univ_iff_forall, or_iff_not_imp_left]\n#align finset.codisjoint_left Finset.codisjoint_left\n-/\n\n#print Finset.codisjoint_right /-\ntheorem codisjoint_right : Codisjoint s t ↔ ∀ ⦃a⦄, a ∉ t → a ∈ s :=\n  Codisjoint_comm.trans codisjoint_left\n#align finset.codisjoint_right Finset.codisjoint_right\n-/\n\nsection BooleanAlgebra\n\nvariable [DecidableEq α] {a : α}\n\ninstance : BooleanAlgebra (Finset α) :=\n  GeneralizedBooleanAlgebra.toBooleanAlgebra\n\n#print Finset.sdiff_eq_inter_compl /-\ntheorem sdiff_eq_inter_compl (s t : Finset α) : s \\ t = s ∩ tᶜ :=\n  sdiff_eq\n#align finset.sdiff_eq_inter_compl Finset.sdiff_eq_inter_compl\n-/\n\n#print Finset.compl_eq_univ_sdiff /-\ntheorem compl_eq_univ_sdiff (s : Finset α) : sᶜ = univ \\ s :=\n  rfl\n#align finset.compl_eq_univ_sdiff Finset.compl_eq_univ_sdiff\n-/\n\n#print Finset.mem_compl /-\n@[simp]\ntheorem mem_compl : a ∈ sᶜ ↔ a ∉ s := by simp [compl_eq_univ_sdiff]\n#align finset.mem_compl Finset.mem_compl\n-/\n\n#print Finset.not_mem_compl /-\ntheorem not_mem_compl : a ∉ sᶜ ↔ a ∈ s := by rw [mem_compl, Classical.not_not]\n#align finset.not_mem_compl Finset.not_mem_compl\n-/\n\n/- warning: finset.coe_compl -> Finset.coe_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Set.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s)) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Set.{u1} α) (Finset.toSet.{u1} α (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s)) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) (Finset.toSet.{u1} α s))\nCase conversion may be inaccurate. Consider using '#align finset.coe_compl Finset.coe_complₓ'. -/\n@[simp, norm_cast]\ntheorem coe_compl (s : Finset α) : ↑(sᶜ) = (↑s : Set α)ᶜ :=\n  Set.ext fun x => mem_compl\n#align finset.coe_compl Finset.coe_compl\n\n#print Finset.compl_empty /-\n@[simp]\ntheorem compl_empty : (∅ : Finset α)ᶜ = univ :=\n  compl_bot\n#align finset.compl_empty Finset.compl_empty\n-/\n\n#print Finset.compl_univ /-\n@[simp]\ntheorem compl_univ : (univ : Finset α)ᶜ = ∅ :=\n  compl_top\n#align finset.compl_univ Finset.compl_univ\n-/\n\n#print Finset.compl_eq_empty_iff /-\n@[simp]\ntheorem compl_eq_empty_iff (s : Finset α) : sᶜ = ∅ ↔ s = univ :=\n  compl_eq_bot\n#align finset.compl_eq_empty_iff Finset.compl_eq_empty_iff\n-/\n\n#print Finset.compl_eq_univ_iff /-\n@[simp]\ntheorem compl_eq_univ_iff (s : Finset α) : sᶜ = univ ↔ s = ∅ :=\n  compl_eq_top\n#align finset.compl_eq_univ_iff Finset.compl_eq_univ_iff\n-/\n\n#print Finset.union_compl /-\n@[simp]\ntheorem union_compl (s : Finset α) : s ∪ sᶜ = univ :=\n  sup_compl_eq_top\n#align finset.union_compl Finset.union_compl\n-/\n\n#print Finset.inter_compl /-\n@[simp]\ntheorem inter_compl (s : Finset α) : s ∩ sᶜ = ∅ :=\n  inf_compl_eq_bot\n#align finset.inter_compl Finset.inter_compl\n-/\n\n#print Finset.compl_union /-\n@[simp]\ntheorem compl_union (s t : Finset α) : (s ∪ t)ᶜ = sᶜ ∩ tᶜ :=\n  compl_sup\n#align finset.compl_union Finset.compl_union\n-/\n\n#print Finset.compl_inter /-\n@[simp]\ntheorem compl_inter (s t : Finset α) : (s ∩ t)ᶜ = sᶜ ∪ tᶜ :=\n  compl_inf\n#align finset.compl_inter Finset.compl_inter\n-/\n\n#print Finset.compl_erase /-\n@[simp]\ntheorem compl_erase : s.eraseₓ aᶜ = insert a (sᶜ) :=\n  by\n  ext\n  simp only [or_iff_not_imp_left, mem_insert, not_and, mem_compl, mem_erase]\n#align finset.compl_erase Finset.compl_erase\n-/\n\n#print Finset.compl_insert /-\n@[simp]\ntheorem compl_insert : insert a sᶜ = sᶜ.eraseₓ a :=\n  by\n  ext\n  simp only [not_or, mem_insert, iff_self_iff, mem_compl, mem_erase]\n#align finset.compl_insert Finset.compl_insert\n-/\n\n#print Finset.insert_compl_self /-\n@[simp]\ntheorem insert_compl_self (x : α) : insert x ({x}ᶜ : Finset α) = univ := by\n  rw [← compl_erase, erase_singleton, compl_empty]\n#align finset.insert_compl_self Finset.insert_compl_self\n-/\n\n#print Finset.compl_filter /-\n@[simp]\ntheorem compl_filter (p : α → Prop) [DecidablePred p] [∀ x, Decidable ¬p x] :\n    univ.filterₓ pᶜ = univ.filterₓ fun x => ¬p x :=\n  (filter_not _ _).symm\n#align finset.compl_filter Finset.compl_filter\n-/\n\n#print Finset.compl_ne_univ_iff_nonempty /-\ntheorem compl_ne_univ_iff_nonempty (s : Finset α) : sᶜ ≠ univ ↔ s.Nonempty := by\n  simp [eq_univ_iff_forall, Finset.Nonempty]\n#align finset.compl_ne_univ_iff_nonempty Finset.compl_ne_univ_iff_nonempty\n-/\n\n#print Finset.compl_singleton /-\ntheorem compl_singleton (a : α) : ({a} : Finset α)ᶜ = univ.eraseₓ a := by\n  rw [compl_eq_univ_sdiff, sdiff_singleton_eq_erase]\n#align finset.compl_singleton Finset.compl_singleton\n-/\n\n#print Finset.insert_inj_on' /-\ntheorem insert_inj_on' (s : Finset α) : Set.InjOn (fun a => insert a s) (sᶜ : Finset α) :=\n  by\n  rw [coe_compl]\n  exact s.insert_inj_on\n#align finset.insert_inj_on' Finset.insert_inj_on'\n-/\n\n#print Finset.image_univ_of_surjective /-\ntheorem image_univ_of_surjective [Fintype β] {f : β → α} (hf : Surjective f) :\n    univ.image f = univ :=\n  eq_univ_of_forall <| hf.forall.2 fun _ => mem_image_of_mem _ <| mem_univ _\n#align finset.image_univ_of_surjective Finset.image_univ_of_surjective\n-/\n\nend BooleanAlgebra\n\n#print Finset.map_univ_of_surjective /-\ntheorem map_univ_of_surjective [Fintype β] {f : β ↪ α} (hf : Surjective f) : univ.map f = univ :=\n  eq_univ_of_forall <| hf.forall.2 fun _ => mem_map_of_mem _ <| mem_univ _\n#align finset.map_univ_of_surjective Finset.map_univ_of_surjective\n-/\n\n#print Finset.map_univ_equiv /-\n@[simp]\ntheorem map_univ_equiv [Fintype β] (f : β ≃ α) : univ.map f.toEmbedding = univ :=\n  map_univ_of_surjective f.Surjective\n#align finset.map_univ_equiv Finset.map_univ_equiv\n-/\n\n#print Finset.univ_inter /-\n@[simp]\ntheorem univ_inter [DecidableEq α] (s : Finset α) : univ ∩ s = s :=\n  ext fun a => by simp\n#align finset.univ_inter Finset.univ_inter\n-/\n\n#print Finset.inter_univ /-\n@[simp]\ntheorem inter_univ [DecidableEq α] (s : Finset α) : s ∩ univ = s := by rw [inter_comm, univ_inter]\n#align finset.inter_univ Finset.inter_univ\n-/\n\n/- warning: finset.piecewise_univ -> Finset.piecewise_univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] [_inst_2 : forall (i : α), Decidable (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) i (Finset.univ.{u1} α _inst_1))] {δ : α -> Sort.{u2}} (f : forall (i : α), δ i) (g : forall (i : α), δ i), Eq.{imax (succ u1) u2} (forall (i : α), δ i) (Finset.piecewise.{u1, u2} α (fun (i : α) => δ i) (Finset.univ.{u1} α _inst_1) f g (fun (j : α) => _inst_2 j)) f\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : Fintype.{u2} α] [_inst_2 : forall (i : α), Decidable (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) i (Finset.univ.{u2} α _inst_1))] {δ : α -> Sort.{u1}} (f : forall (i : α), δ i) (g : forall (i : α), δ i), Eq.{imax (succ u2) u1} (forall (i : α), δ i) (Finset.piecewise.{u2, u1} α (fun (i : α) => δ i) (Finset.univ.{u2} α _inst_1) f g (fun (j : α) => _inst_2 j)) f\nCase conversion may be inaccurate. Consider using '#align finset.piecewise_univ Finset.piecewise_univₓ'. -/\n@[simp]\ntheorem piecewise_univ [∀ i : α, Decidable (i ∈ (univ : Finset α))] {δ : α → Sort _}\n    (f g : ∀ i, δ i) : univ.piecewise f g = f :=\n  by\n  ext i\n  simp [piecewise]\n#align finset.piecewise_univ Finset.piecewise_univ\n\n/- warning: finset.piecewise_compl -> Finset.piecewise_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u1} α] (s : Finset.{u1} α) [_inst_3 : forall (i : α), Decidable (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) i s)] [_inst_4 : forall (i : α), Decidable (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) i (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s))] {δ : α -> Sort.{u2}} (f : forall (i : α), δ i) (g : forall (i : α), δ i), Eq.{imax (succ u1) u2} (forall (i : α), δ i) (Finset.piecewise.{u1, u2} α (fun (i : α) => δ i) (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s) f g (fun (j : α) => _inst_4 j)) (Finset.piecewise.{u1, u2} α (fun (i : α) => δ i) s g f (fun (j : α) => _inst_3 j))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u2} α] (s : Finset.{u2} α) [_inst_3 : forall (i : α), Decidable (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) i s)] [_inst_4 : forall (i : α), Decidable (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) i (HasCompl.compl.{u2} (Finset.{u2} α) (BooleanAlgebra.toHasCompl.{u2} (Finset.{u2} α) (Finset.booleanAlgebra.{u2} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s))] {δ : α -> Sort.{u1}} (f : forall (i : α), δ i) (g : forall (i : α), δ i), Eq.{imax (succ u2) u1} (forall (i : α), δ i) (Finset.piecewise.{u2, u1} α (fun (i : α) => δ i) (HasCompl.compl.{u2} (Finset.{u2} α) (BooleanAlgebra.toHasCompl.{u2} (Finset.{u2} α) (Finset.booleanAlgebra.{u2} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s) f g (fun (j : α) => _inst_4 j)) (Finset.piecewise.{u2, u1} α (fun (i : α) => δ i) s g f (fun (j : α) => _inst_3 j))\nCase conversion may be inaccurate. Consider using '#align finset.piecewise_compl Finset.piecewise_complₓ'. -/\ntheorem piecewise_compl [DecidableEq α] (s : Finset α) [∀ i : α, Decidable (i ∈ s)]\n    [∀ i : α, Decidable (i ∈ sᶜ)] {δ : α → Sort _} (f g : ∀ i, δ i) :\n    sᶜ.piecewise f g = s.piecewise g f := by\n  ext i\n  simp [piecewise]\n#align finset.piecewise_compl Finset.piecewise_compl\n\n#print Finset.piecewise_erase_univ /-\n@[simp]\ntheorem piecewise_erase_univ {δ : α → Sort _} [DecidableEq α] (a : α) (f g : ∀ a, δ a) :\n    (Finset.univ.eraseₓ a).piecewise f g = Function.update f a (g a) := by\n  rw [← compl_singleton, piecewise_compl, piecewise_singleton]\n#align finset.piecewise_erase_univ Finset.piecewise_erase_univ\n-/\n\n/- warning: finset.univ_map_equiv_to_embedding -> Finset.univ_map_equiv_to_embedding is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_2 : Fintype.{u1} α] [_inst_3 : Fintype.{u2} β] (e : Equiv.{succ u1, succ u2} α β), Eq.{succ u2} (Finset.{u2} β) (Finset.map.{u1, u2} α β (Equiv.toEmbedding.{succ u1, succ u2} α β e) (Finset.univ.{u1} α _inst_2)) (Finset.univ.{u2} β _inst_3)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_2 : Fintype.{u2} α] [_inst_3 : Fintype.{u1} β] (e : Equiv.{succ u2, succ u1} α β), Eq.{succ u1} (Finset.{u1} β) (Finset.map.{u2, u1} α β (Equiv.toEmbedding.{succ u2, succ u1} α β e) (Finset.univ.{u2} α _inst_2)) (Finset.univ.{u1} β _inst_3)\nCase conversion may be inaccurate. Consider using '#align finset.univ_map_equiv_to_embedding Finset.univ_map_equiv_to_embeddingₓ'. -/\ntheorem univ_map_equiv_to_embedding {α β : Type _} [Fintype α] [Fintype β] (e : α ≃ β) :\n    univ.map e.toEmbedding = univ :=\n  eq_univ_iff_forall.mpr fun b => mem_map.mpr ⟨e.symm b, mem_univ _, by simp⟩\n#align finset.univ_map_equiv_to_embedding Finset.univ_map_equiv_to_embedding\n\n#print Finset.univ_filter_exists /-\n@[simp]\ntheorem univ_filter_exists (f : α → β) [Fintype β] [DecidablePred fun y => ∃ x, f x = y]\n    [DecidableEq β] : (Finset.univ.filterₓ fun y => ∃ x, f x = y) = Finset.univ.image f :=\n  by\n  ext\n  simp\n#align finset.univ_filter_exists Finset.univ_filter_exists\n-/\n\n#print Finset.univ_filter_mem_range /-\n/-- Note this is a special case of `(finset.image_preimage f univ _).symm`. -/\ntheorem univ_filter_mem_range (f : α → β) [Fintype β] [DecidablePred fun y => y ∈ Set.range f]\n    [DecidableEq β] : (Finset.univ.filterₓ fun y => y ∈ Set.range f) = Finset.univ.image f :=\n  univ_filter_exists f\n#align finset.univ_filter_mem_range Finset.univ_filter_mem_range\n-/\n\n#print Finset.coe_filter_univ /-\ntheorem coe_filter_univ (p : α → Prop) [DecidablePred p] : (univ.filterₓ p : Set α) = { x | p x } :=\n  by rw [coe_filter, coe_univ, Set.sep_univ]\n#align finset.coe_filter_univ Finset.coe_filter_univ\n-/\n\nend Finset\n\nopen Finset Function\n\nnamespace Fintype\n\n#print Fintype.decidablePiFintype /-\ninstance decidablePiFintype {α} {β : α → Type _} [∀ a, DecidableEq (β a)] [Fintype α] :\n    DecidableEq (∀ a, β a) := fun f g =>\n  decidable_of_iff (∀ a ∈ Fintype.elems α, f a = g a)\n    (by simp [Function.funext_iff, Fintype.complete])\n#align fintype.decidable_pi_fintype Fintype.decidablePiFintype\n-/\n\n#print Fintype.decidableForallFintype /-\ninstance decidableForallFintype {p : α → Prop} [DecidablePred p] [Fintype α] :\n    Decidable (∀ a, p a) :=\n  decidable_of_iff (∀ a ∈ @univ α _, p a) (by simp)\n#align fintype.decidable_forall_fintype Fintype.decidableForallFintype\n-/\n\n#print Fintype.decidableExistsFintype /-\ninstance decidableExistsFintype {p : α → Prop} [DecidablePred p] [Fintype α] :\n    Decidable (∃ a, p a) :=\n  decidable_of_iff (∃ a ∈ @univ α _, p a) (by simp)\n#align fintype.decidable_exists_fintype Fintype.decidableExistsFintype\n-/\n\n#print Fintype.decidableMemRangeFintype /-\ninstance decidableMemRangeFintype [Fintype α] [DecidableEq β] (f : α → β) :\n    DecidablePred (· ∈ Set.range f) := fun x => Fintype.decidableExistsFintype\n#align fintype.decidable_mem_range_fintype Fintype.decidableMemRangeFintype\n-/\n\nsection BundledHoms\n\n#print Fintype.decidableEqEquivFintype /-\ninstance decidableEqEquivFintype [DecidableEq β] [Fintype α] : DecidableEq (α ≃ β) := fun a b =>\n  decidable_of_iff (a.1 = b.1) Equiv.coe_fn_injective.eq_iff\n#align fintype.decidable_eq_equiv_fintype Fintype.decidableEqEquivFintype\n-/\n\n#print Fintype.decidableEqEmbeddingFintype /-\ninstance decidableEqEmbeddingFintype [DecidableEq β] [Fintype α] : DecidableEq (α ↪ β) := fun a b =>\n  decidable_of_iff ((a : α → β) = b) Function.Embedding.coe_injective.eq_iff\n#align fintype.decidable_eq_embedding_fintype Fintype.decidableEqEmbeddingFintype\n-/\n\n#print Fintype.decidableEqOneHomFintype /-\n@[to_additive]\ninstance decidableEqOneHomFintype [DecidableEq β] [Fintype α] [One α] [One β] :\n    DecidableEq (OneHom α β) := fun a b =>\n  decidable_of_iff ((a : α → β) = b) (Injective.eq_iff OneHom.coe_inj)\n#align fintype.decidable_eq_one_hom_fintype Fintype.decidableEqOneHomFintype\n#align fintype.decidable_eq_zero_hom_fintype Fintype.decidableEqZeroHomFintype\n-/\n\n#print Fintype.decidableEqMulHomFintype /-\n@[to_additive]\ninstance decidableEqMulHomFintype [DecidableEq β] [Fintype α] [Mul α] [Mul β] :\n    DecidableEq (α →ₙ* β) := fun a b =>\n  decidable_of_iff ((a : α → β) = b) (Injective.eq_iff MulHom.coe_inj)\n#align fintype.decidable_eq_mul_hom_fintype Fintype.decidableEqMulHomFintype\n#align fintype.decidable_eq_add_hom_fintype Fintype.decidableEqAddHomFintype\n-/\n\n#print Fintype.decidableEqMonoidHomFintype /-\n@[to_additive]\ninstance decidableEqMonoidHomFintype [DecidableEq β] [Fintype α] [MulOneClass α] [MulOneClass β] :\n    DecidableEq (α →* β) := fun a b =>\n  decidable_of_iff ((a : α → β) = b) (Injective.eq_iff MonoidHom.coe_inj)\n#align fintype.decidable_eq_monoid_hom_fintype Fintype.decidableEqMonoidHomFintype\n#align fintype.decidable_eq_add_monoid_hom_fintype Fintype.decidableEqAddMonoidHomFintype\n-/\n\n#print Fintype.decidableEqMonoidWithZeroHomFintype /-\ninstance decidableEqMonoidWithZeroHomFintype [DecidableEq β] [Fintype α] [MulZeroOneClass α]\n    [MulZeroOneClass β] : DecidableEq (α →*₀ β) := fun a b =>\n  decidable_of_iff ((a : α → β) = b) (Injective.eq_iff MonoidWithZeroHom.coe_inj)\n#align fintype.decidable_eq_monoid_with_zero_hom_fintype Fintype.decidableEqMonoidWithZeroHomFintype\n-/\n\n#print Fintype.decidableEqRingHomFintype /-\ninstance decidableEqRingHomFintype [DecidableEq β] [Fintype α] [Semiring α] [Semiring β] :\n    DecidableEq (α →+* β) := fun a b =>\n  decidable_of_iff ((a : α → β) = b) (Injective.eq_iff RingHom.coe_inj)\n#align fintype.decidable_eq_ring_hom_fintype Fintype.decidableEqRingHomFintype\n-/\n\nend BundledHoms\n\n#print Fintype.decidableInjectiveFintype /-\ninstance decidableInjectiveFintype [DecidableEq α] [DecidableEq β] [Fintype α] :\n    DecidablePred (Injective : (α → β) → Prop) := fun x => by unfold injective <;> infer_instance\n#align fintype.decidable_injective_fintype Fintype.decidableInjectiveFintype\n-/\n\n#print Fintype.decidableSurjectiveFintype /-\ninstance decidableSurjectiveFintype [DecidableEq β] [Fintype α] [Fintype β] :\n    DecidablePred (Surjective : (α → β) → Prop) := fun x => by unfold surjective <;> infer_instance\n#align fintype.decidable_surjective_fintype Fintype.decidableSurjectiveFintype\n-/\n\n#print Fintype.decidableBijectiveFintype /-\ninstance decidableBijectiveFintype [DecidableEq α] [DecidableEq β] [Fintype α] [Fintype β] :\n    DecidablePred (Bijective : (α → β) → Prop) := fun x => by unfold bijective <;> infer_instance\n#align fintype.decidable_bijective_fintype Fintype.decidableBijectiveFintype\n-/\n\n#print Fintype.decidableRightInverseFintype /-\ninstance decidableRightInverseFintype [DecidableEq α] [Fintype α] (f : α → β) (g : β → α) :\n    Decidable (Function.RightInverse f g) :=\n  show Decidable (∀ x, g (f x) = x) by infer_instance\n#align fintype.decidable_right_inverse_fintype Fintype.decidableRightInverseFintype\n-/\n\n#print Fintype.decidableLeftInverseFintype /-\ninstance decidableLeftInverseFintype [DecidableEq β] [Fintype β] (f : α → β) (g : β → α) :\n    Decidable (Function.LeftInverse f g) :=\n  show Decidable (∀ x, f (g x) = x) by infer_instance\n#align fintype.decidable_left_inverse_fintype Fintype.decidableLeftInverseFintype\n-/\n\n#print Fintype.ofMultiset /-\n/-- Construct a proof of `fintype α` from a universal multiset -/\ndef ofMultiset [DecidableEq α] (s : Multiset α) (H : ∀ x : α, x ∈ s) : Fintype α :=\n  ⟨s.toFinset, by simpa using H⟩\n#align fintype.of_multiset Fintype.ofMultiset\n-/\n\n#print Fintype.ofList /-\n/-- Construct a proof of `fintype α` from a universal list -/\ndef ofList [DecidableEq α] (l : List α) (H : ∀ x : α, x ∈ l) : Fintype α :=\n  ⟨l.toFinset, by simpa using H⟩\n#align fintype.of_list Fintype.ofList\n-/\n\ninstance (α : Type _) : Subsingleton (Fintype α) :=\n  ⟨fun ⟨s₁, h₁⟩ ⟨s₂, h₂⟩ => by congr <;> simp [Finset.ext_iff, h₁, h₂]⟩\n\n#print Fintype.subtype /-\n/-- Given a predicate that can be represented by a finset, the subtype\nassociated to the predicate is a fintype. -/\nprotected def subtype {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s ↔ p x) :\n    Fintype { x // p x } :=\n  ⟨⟨s.1.pmap Subtype.mk fun x => (H x).1, s.Nodup.pmap fun a _ b _ => congr_arg Subtype.val⟩,\n    fun ⟨x, px⟩ => Multiset.mem_pmap.2 ⟨x, (H x).2 px, rfl⟩⟩\n#align fintype.subtype Fintype.subtype\n-/\n\n#print Fintype.ofFinset /-\n/-- Construct a fintype from a finset with the same elements. -/\ndef ofFinset {p : Set α} (s : Finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) : Fintype p :=\n  Fintype.subtype s H\n#align fintype.of_finset Fintype.ofFinset\n-/\n\n#print Fintype.ofBijective /-\n/-- If `f : α → β` is a bijection and `α` is a fintype, then `β` is also a fintype. -/\ndef ofBijective [Fintype α] (f : α → β) (H : Function.Bijective f) : Fintype β :=\n  ⟨univ.map ⟨f, H.1⟩, fun b =>\n    let ⟨a, e⟩ := H.2 b\n    e ▸ mem_map_of_mem _ (mem_univ _)⟩\n#align fintype.of_bijective Fintype.ofBijective\n-/\n\n#print Fintype.ofSurjective /-\n/-- If `f : α → β` is a surjection and `α` is a fintype, then `β` is also a fintype. -/\ndef ofSurjective [DecidableEq β] [Fintype α] (f : α → β) (H : Function.Surjective f) : Fintype β :=\n  ⟨univ.image f, fun b =>\n    let ⟨a, e⟩ := H b\n    e ▸ mem_image_of_mem _ (mem_univ _)⟩\n#align fintype.of_surjective Fintype.ofSurjective\n-/\n\nend Fintype\n\nnamespace Finset\n\nvariable [Fintype α] [DecidableEq α] {s t : Finset α}\n\n#print Finset.decidableCodisjoint /-\ninstance decidableCodisjoint : Decidable (Codisjoint s t) :=\n  decidable_of_iff _ codisjoint_left.symm\n#align finset.decidable_codisjoint Finset.decidableCodisjoint\n-/\n\n#print Finset.decidableIsCompl /-\ninstance decidableIsCompl : Decidable (IsCompl s t) :=\n  decidable_of_iff' _ isCompl_iff\n#align finset.decidable_is_compl Finset.decidableIsCompl\n-/\n\nend Finset\n\nsection Inv\n\nnamespace Function\n\nvariable [Fintype α] [DecidableEq β]\n\nnamespace Injective\n\nvariable {f : α → β} (hf : Function.Injective f)\n\n#print Function.Injective.invOfMemRange /-\n/-- The inverse of an `hf : injective` function `f : α → β`, of the type `↥(set.range f) → α`.\nThis is the computable version of `function.inv_fun` that requires `fintype α` and `decidable_eq β`,\nor the function version of applying `(equiv.of_injective f hf).symm`.\nThis function should not usually be used for actual computation because for most cases,\nan explicit inverse can be stated that has better computational properties.\nThis function computes by checking all terms `a : α` to find the `f a = b`, so it is O(N) where\n`N = fintype.card α`.\n-/\ndef invOfMemRange : Set.range f → α := fun b =>\n  Finset.choose (fun a => f a = b) Finset.univ\n    ((existsUnique_congr (by simp)).mp (hf.exists_unique_of_mem_range b.property))\n#align function.injective.inv_of_mem_range Function.Injective.invOfMemRange\n-/\n\n#print Function.Injective.left_inv_of_invOfMemRange /-\ntheorem left_inv_of_invOfMemRange (b : Set.range f) : f (hf.invOfMemRange b) = b :=\n  (Finset.choose_spec (fun a => f a = b) _ _).right\n#align function.injective.left_inv_of_inv_of_mem_range Function.Injective.left_inv_of_invOfMemRange\n-/\n\n/- warning: function.injective.right_inv_of_inv_of_mem_range -> Function.Injective.right_inv_of_invOfMemRange is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] {f : α -> β} (hf : Function.Injective.{succ u1, succ u2} α β f) (a : α), Eq.{succ u1} α (Function.Injective.invOfMemRange.{u1, u2} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f hf (Subtype.mk.{succ u2} β (fun (x : β) => Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) x (Set.range.{u2, succ u1} β α f)) (f a) (Set.mem_range_self.{u2, succ u1} β α f a))) a\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] {f : α -> β} (hf : Function.Injective.{succ u2, succ u1} α β f) (a : α), Eq.{succ u2} α (Function.Injective.invOfMemRange.{u2, u1} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f hf (Subtype.mk.{succ u1} β (fun (x : β) => Membership.mem.{u1, u1} β (Set.{u1} β) (Set.instMembershipSet.{u1} β) x (Set.range.{u1, succ u2} β α f)) (f a) (Set.mem_range_self.{succ u2, u1} β α f a))) a\nCase conversion may be inaccurate. Consider using '#align function.injective.right_inv_of_inv_of_mem_range Function.Injective.right_inv_of_invOfMemRangeₓ'. -/\n@[simp]\ntheorem right_inv_of_invOfMemRange (a : α) : hf.invOfMemRange ⟨f a, Set.mem_range_self a⟩ = a :=\n  hf (Finset.choose_spec (fun a' => f a' = f a) _ _).right\n#align function.injective.right_inv_of_inv_of_mem_range Function.Injective.right_inv_of_invOfMemRange\n\n/- warning: function.injective.inv_fun_restrict -> Function.Injective.invFun_restrict is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] {f : α -> β} (hf : Function.Injective.{succ u1, succ u2} α β f) [_inst_3 : Nonempty.{succ u1} α], Eq.{max (succ u2) (succ u1)} ((coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.range.{u2, succ u1} β α f)) -> α) (Set.restrict.{u2, u1} β (fun (ᾰ : β) => α) (Set.range.{u2, succ u1} β α f) (Function.invFun.{succ u1, succ u2} α β _inst_3 f)) (Function.Injective.invOfMemRange.{u1, u2} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f hf)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] {f : α -> β} (hf : Function.Injective.{succ u2, succ u1} α β f) [_inst_3 : Nonempty.{succ u2} α], Eq.{max (succ u2) (succ u1)} ((Set.Elem.{u1} β (Set.range.{u1, succ u2} β α f)) -> α) (Set.restrict.{u1, u2} β (fun (ᾰ : β) => α) (Set.range.{u1, succ u2} β α f) (Function.invFun.{succ u2, succ u1} α β _inst_3 f)) (Function.Injective.invOfMemRange.{u2, u1} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f hf)\nCase conversion may be inaccurate. Consider using '#align function.injective.inv_fun_restrict Function.Injective.invFun_restrictₓ'. -/\ntheorem invFun_restrict [Nonempty α] : (Set.range f).restrict (invFun f) = hf.invOfMemRange :=\n  by\n  ext ⟨b, h⟩\n  apply hf\n  simp [hf.left_inv_of_inv_of_mem_range, @inv_fun_eq _ _ _ f b (set.mem_range.mp h)]\n#align function.injective.inv_fun_restrict Function.Injective.invFun_restrict\n\n#print Function.Injective.invOfMemRange_surjective /-\ntheorem invOfMemRange_surjective : Function.Surjective hf.invOfMemRange := fun a =>\n  ⟨⟨f a, Set.mem_range_self a⟩, by simp⟩\n#align function.injective.inv_of_mem_range_surjective Function.Injective.invOfMemRange_surjective\n-/\n\nend Injective\n\nnamespace Embedding\n\nvariable (f : α ↪ β) (b : Set.range f)\n\n#print Function.Embedding.invOfMemRange /-\n/-- The inverse of an embedding `f : α ↪ β`, of the type `↥(set.range f) → α`.\nThis is the computable version of `function.inv_fun` that requires `fintype α` and `decidable_eq β`,\nor the function version of applying `(equiv.of_injective f f.injective).symm`.\nThis function should not usually be used for actual computation because for most cases,\nan explicit inverse can be stated that has better computational properties.\nThis function computes by checking all terms `a : α` to find the `f a = b`, so it is O(N) where\n`N = fintype.card α`.\n-/\ndef invOfMemRange : α :=\n  f.Injective.invOfMemRange b\n#align function.embedding.inv_of_mem_range Function.Embedding.invOfMemRange\n-/\n\n#print Function.Embedding.left_inv_of_invOfMemRange /-\n@[simp]\ntheorem left_inv_of_invOfMemRange : f (f.invOfMemRange b) = b :=\n  f.Injective.left_inv_of_invOfMemRange b\n#align function.embedding.left_inv_of_inv_of_mem_range Function.Embedding.left_inv_of_invOfMemRange\n-/\n\n/- warning: function.embedding.right_inv_of_inv_of_mem_range -> Function.Embedding.right_inv_of_invOfMemRange is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] (f : Function.Embedding.{succ u1, succ u2} α β) (a : α), Eq.{succ u1} α (Function.Embedding.invOfMemRange.{u1, u2} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f (Subtype.mk.{succ u2} β (fun (x : β) => Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) x (Set.range.{u2, succ u1} β α (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f))) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f a) (Set.mem_range_self.{u2, succ u1} β α (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f) a))) a\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] (f : Function.Embedding.{succ u2, succ u1} α β) (a : α), Eq.{succ u2} α (Function.Embedding.invOfMemRange.{u2, u1} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f (Subtype.mk.{succ u1} β (fun (x : β) => Membership.mem.{u1, u1} β (Set.{u1} β) (Set.instMembershipSet.{u1} β) x (Set.range.{u1, succ u2} β α (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f a) (Set.mem_range_self.{succ u2, u1} β α (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f) a))) a\nCase conversion may be inaccurate. Consider using '#align function.embedding.right_inv_of_inv_of_mem_range Function.Embedding.right_inv_of_invOfMemRangeₓ'. -/\n@[simp]\ntheorem right_inv_of_invOfMemRange (a : α) : f.invOfMemRange ⟨f a, Set.mem_range_self a⟩ = a :=\n  f.Injective.right_inv_of_invOfMemRange a\n#align function.embedding.right_inv_of_inv_of_mem_range Function.Embedding.right_inv_of_invOfMemRange\n\n/- warning: function.embedding.inv_fun_restrict -> Function.Embedding.invFun_restrict is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] (f : Function.Embedding.{succ u1, succ u2} α β) [_inst_3 : Nonempty.{succ u1} α], Eq.{max (succ u2) (succ u1)} ((coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.range.{u2, succ u1} β α (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f))) -> α) (Set.restrict.{u2, u1} β (fun (ᾰ : β) => α) (Set.range.{u2, succ u1} β α (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f)) (Function.invFun.{succ u1, succ u2} α β _inst_3 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f))) (Function.Embedding.invOfMemRange.{u1, u2} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] (f : Function.Embedding.{succ u2, succ u1} α β) [_inst_3 : Nonempty.{succ u2} α], Eq.{max (succ u2) (succ u1)} ((Set.Elem.{u1} β (Set.range.{u1, succ u2} β α (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f))) -> α) (Set.restrict.{u1, u2} β (fun (ᾰ : β) => α) (Set.range.{u1, succ u2} β α (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f)) (Function.invFun.{succ u2, succ u1} α β _inst_3 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f))) (Function.Embedding.invOfMemRange.{u2, u1} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.inv_fun_restrict Function.Embedding.invFun_restrictₓ'. -/\ntheorem invFun_restrict [Nonempty α] : (Set.range f).restrict (invFun f) = f.invOfMemRange :=\n  by\n  ext ⟨b, h⟩\n  apply f.injective\n  simp [f.left_inv_of_inv_of_mem_range, @inv_fun_eq _ _ _ f b (set.mem_range.mp h)]\n#align function.embedding.inv_fun_restrict Function.Embedding.invFun_restrict\n\n#print Function.Embedding.invOfMemRange_surjective /-\ntheorem invOfMemRange_surjective : Function.Surjective f.invOfMemRange := fun a =>\n  ⟨⟨f a, Set.mem_range_self a⟩, by simp⟩\n#align function.embedding.inv_of_mem_range_surjective Function.Embedding.invOfMemRange_surjective\n-/\n\nend Embedding\n\nend Function\n\nend Inv\n\nnamespace Fintype\n\n#print Fintype.ofInjective /-\n/-- Given an injective function to a fintype, the domain is also a\nfintype. This is noncomputable because injectivity alone cannot be\nused to construct preimages. -/\nnoncomputable def ofInjective [Fintype β] (f : α → β) (H : Function.Injective f) : Fintype α :=\n  letI := Classical.dec\n  if hα : Nonempty α then\n    letI := Classical.inhabited_of_nonempty hα\n    of_surjective (inv_fun f) (inv_fun_surjective H)\n  else ⟨∅, fun x => (hα ⟨x⟩).elim⟩\n#align fintype.of_injective Fintype.ofInjective\n-/\n\n#print Fintype.ofEquiv /-\n/-- If `f : α ≃ β` and `α` is a fintype, then `β` is also a fintype. -/\ndef ofEquiv (α : Type _) [Fintype α] (f : α ≃ β) : Fintype β :=\n  ofBijective _ f.Bijective\n#align fintype.of_equiv Fintype.ofEquiv\n-/\n\n#print Fintype.ofSubsingleton /-\n/-- Any subsingleton type with a witness is a fintype (with one term). -/\ndef ofSubsingleton (a : α) [Subsingleton α] : Fintype α :=\n  ⟨{a}, fun b => Finset.mem_singleton.2 (Subsingleton.elim _ _)⟩\n#align fintype.of_subsingleton Fintype.ofSubsingleton\n-/\n\n#print Fintype.univ_ofSubsingleton /-\n@[simp]\ntheorem univ_ofSubsingleton (a : α) [Subsingleton α] : @univ _ (ofSubsingleton a) = {a} :=\n  rfl\n#align fintype.univ_of_subsingleton Fintype.univ_ofSubsingleton\n-/\n\n#print Fintype.ofIsEmpty /-\n-- see Note [lower instance priority]\ninstance (priority := 100) ofIsEmpty [IsEmpty α] : Fintype α :=\n  ⟨∅, isEmptyElim⟩\n#align fintype.of_is_empty Fintype.ofIsEmpty\n-/\n\n#print Fintype.univ_of_isEmpty /-\n-- no-lint since while `finset.univ_eq_empty` can prove this, it isn't applicable for `dsimp`.\n/-- Note: this lemma is specifically about `fintype.of_is_empty`. For a statement about\narbitrary `fintype` instances, use `finset.univ_eq_empty`. -/\n@[simp, nolint simp_nf]\ntheorem univ_of_isEmpty [IsEmpty α] : @univ α _ = ∅ :=\n  rfl\n#align fintype.univ_of_is_empty Fintype.univ_of_isEmpty\n-/\n\nend Fintype\n\nnamespace Set\n\nvariable {s t : Set α}\n\n#print Set.toFinset /-\n/-- Construct a finset enumerating a set `s`, given a `fintype` instance.  -/\ndef toFinset (s : Set α) [Fintype s] : Finset α :=\n  (@Finset.univ s _).map <| Function.Embedding.subtype _\n#align set.to_finset Set.toFinset\n-/\n\n#print Set.toFinset_congr /-\n@[congr]\ntheorem toFinset_congr {s t : Set α} [Fintype s] [Fintype t] (h : s = t) :\n    toFinset s = toFinset t := by cc\n#align set.to_finset_congr Set.toFinset_congr\n-/\n\n#print Set.mem_toFinset /-\n@[simp]\ntheorem mem_toFinset {s : Set α} [Fintype s] {a : α} : a ∈ s.toFinset ↔ a ∈ s := by simp [to_finset]\n#align set.mem_to_finset Set.mem_toFinset\n-/\n\n#print Set.toFinset_ofFinset /-\n/-- Many `fintype` instances for sets are defined using an extensionally equal `finset`.\nRewriting `s.to_finset` with `set.to_finset_of_finset` replaces the term with such a `finset`. -/\ntheorem toFinset_ofFinset {p : Set α} (s : Finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) :\n    @Set.toFinset _ p (Fintype.ofFinset s H) = s :=\n  Finset.ext fun x => by rw [mem_to_finset, H]\n#align set.to_finset_of_finset Set.toFinset_ofFinset\n-/\n\n#print Set.decidableMemOfFintype /-\n/-- Membership of a set with a `fintype` instance is decidable.\n\nUsing this as an instance leads to potential loops with `subtype.fintype` under certain decidability\nassumptions, so it should only be declared a local instance. -/\ndef decidableMemOfFintype [DecidableEq α] (s : Set α) [Fintype s] (a) : Decidable (a ∈ s) :=\n  decidable_of_iff _ mem_toFinset\n#align set.decidable_mem_of_fintype Set.decidableMemOfFintype\n-/\n\n#print Set.coe_toFinset /-\n@[simp]\ntheorem coe_toFinset (s : Set α) [Fintype s] : (↑s.toFinset : Set α) = s :=\n  Set.ext fun _ => mem_toFinset\n#align set.coe_to_finset Set.coe_toFinset\n-/\n\n#print Set.toFinset_nonempty /-\n@[simp]\ntheorem toFinset_nonempty {s : Set α} [Fintype s] : s.toFinset.Nonempty ↔ s.Nonempty := by\n  rw [← Finset.coe_nonempty, coe_to_finset]\n#align set.to_finset_nonempty Set.toFinset_nonempty\n-/\n\n#print Set.toFinset_inj /-\n@[simp]\ntheorem toFinset_inj {s t : Set α} [Fintype s] [Fintype t] : s.toFinset = t.toFinset ↔ s = t :=\n  ⟨fun h => by rw [← s.coe_to_finset, h, t.coe_to_finset], fun h => by simp [h] <;> congr ⟩\n#align set.to_finset_inj Set.toFinset_inj\n-/\n\n#print Set.toFinset_subset_toFinset /-\n@[mono]\ntheorem toFinset_subset_toFinset [Fintype s] [Fintype t] : s.toFinset ⊆ t.toFinset ↔ s ⊆ t := by\n  simp [Finset.subset_iff, Set.subset_def]\n#align set.to_finset_subset_to_finset Set.toFinset_subset_toFinset\n-/\n\n/- warning: set.to_finset_ssubset -> Set.toFinset_ssubset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} α} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] {t : Finset.{u1} α}, Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) (Set.toFinset.{u1} α s _inst_1) t) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.hasSsubset.{u1} α) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) t))\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} α} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} α s)] {t : Finset.{u1} α}, Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.instHasSSubsetFinset.{u1} α) (Set.toFinset.{u1} α s _inst_1) t) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.instHasSSubsetSet.{u1} α) s (Finset.toSet.{u1} α t))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_ssubset Set.toFinset_ssubsetₓ'. -/\n@[simp]\ntheorem toFinset_ssubset [Fintype s] {t : Finset α} : s.toFinset ⊂ t ↔ s ⊂ t := by\n  rw [← Finset.coe_ssubset, coe_to_finset]\n#align set.to_finset_ssubset Set.toFinset_ssubset\n\n#print Set.subset_toFinset /-\n@[simp]\ntheorem subset_toFinset {s : Finset α} [Fintype t] : s ⊆ t.toFinset ↔ ↑s ⊆ t := by\n  rw [← Finset.coe_subset, coe_to_finset]\n#align set.subset_to_finset Set.subset_toFinset\n-/\n\n/- warning: set.ssubset_to_finset -> Set.ssubset_toFinset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {t : Set.{u1} α} {s : Finset.{u1} α} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) s (Set.toFinset.{u1} α t _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.hasSsubset.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) s) t)\nbut is expected to have type\n  forall {α : Type.{u1}} {t : Set.{u1} α} {s : Finset.{u1} α} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} α t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.instHasSSubsetFinset.{u1} α) s (Set.toFinset.{u1} α t _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.instHasSSubsetSet.{u1} α) (Finset.toSet.{u1} α s) t)\nCase conversion may be inaccurate. Consider using '#align set.ssubset_to_finset Set.ssubset_toFinsetₓ'. -/\n@[simp]\ntheorem ssubset_toFinset {s : Finset α} [Fintype t] : s ⊂ t.toFinset ↔ ↑s ⊂ t := by\n  rw [← Finset.coe_ssubset, coe_to_finset]\n#align set.ssubset_to_finset Set.ssubset_toFinset\n\n/- warning: set.to_finset_ssubset_to_finset -> Set.toFinset_ssubset_toFinset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) (Set.toFinset.{u1} α s _inst_1) (Set.toFinset.{u1} α t _inst_2)) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.hasSsubset.{u1} α) s t)\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.instHasSSubsetFinset.{u1} α) (Set.toFinset.{u1} α s _inst_1) (Set.toFinset.{u1} α t _inst_2)) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.instHasSSubsetSet.{u1} α) s t)\nCase conversion may be inaccurate. Consider using '#align set.to_finset_ssubset_to_finset Set.toFinset_ssubset_toFinsetₓ'. -/\n@[mono]\ntheorem toFinset_ssubset_toFinset [Fintype s] [Fintype t] : s.toFinset ⊂ t.toFinset ↔ s ⊂ t := by\n  simp only [Finset.ssubset_def, to_finset_subset_to_finset, ssubset_def]\n#align set.to_finset_ssubset_to_finset Set.toFinset_ssubset_toFinset\n\n#print Set.toFinset_subset /-\n@[simp]\ntheorem toFinset_subset [Fintype s] {t : Finset α} : s.toFinset ⊆ t ↔ s ⊆ t := by\n  rw [← Finset.coe_subset, coe_to_finset]\n#align set.to_finset_subset Set.toFinset_subset\n-/\n\nalias to_finset_subset_to_finset ↔ _ to_finset_mono\n#align set.to_finset_mono Set.toFinset_mono\n\n/- warning: set.to_finset_strict_mono -> Set.toFinset_strict_mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)], (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.hasSsubset.{u1} α) s t) -> (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) (Set.toFinset.{u1} α s _inst_1) (Set.toFinset.{u1} α t _inst_2))\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α t)], (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.instHasSSubsetSet.{u1} α) s t) -> (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.instHasSSubsetFinset.{u1} α) (Set.toFinset.{u1} α s _inst_1) (Set.toFinset.{u1} α t _inst_2))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_strict_mono Set.toFinset_strict_monoₓ'. -/\nalias to_finset_ssubset_to_finset ↔ _ to_finset_strict_mono\n#align set.to_finset_strict_mono Set.toFinset_strict_mono\n\n/- warning: set.disjoint_to_finset -> Set.disjoint_toFinset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)], Iff (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) (Set.toFinset.{u1} α s _inst_1) (Set.toFinset.{u1} α t _inst_2)) (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) s t)\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α t)], Iff (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) (Set.toFinset.{u1} α s _inst_1) (Set.toFinset.{u1} α t _inst_2)) (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) s t)\nCase conversion may be inaccurate. Consider using '#align set.disjoint_to_finset Set.disjoint_toFinsetₓ'. -/\n@[simp]\ntheorem disjoint_toFinset [Fintype s] [Fintype t] : Disjoint s.toFinset t.toFinset ↔ Disjoint s t :=\n  by simp only [← disjoint_coe, coe_to_finset]\n#align set.disjoint_to_finset Set.disjoint_toFinset\n\nsection DecidableEq\n\nvariable [DecidableEq α] (s t) [Fintype s] [Fintype t]\n\n/- warning: set.to_finset_inter -> Set.toFinset_inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) s t) _inst_4) (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} α t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) s t) _inst_4) (Inter.inter.{u1} (Finset.{u1} α) (Finset.instInterFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_inter Set.toFinset_interₓ'. -/\n@[simp]\ntheorem toFinset_inter [Fintype ↥(s ∩ t)] : (s ∩ t).toFinset = s.toFinset ∩ t.toFinset :=\n  by\n  ext\n  simp\n#align set.to_finset_inter Set.toFinset_inter\n\n/- warning: set.to_finset_union -> Set.toFinset_union is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t) _inst_4) (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} α t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} α (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t) _inst_4) (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_union Set.toFinset_unionₓ'. -/\n@[simp]\ntheorem toFinset_union [Fintype ↥(s ∪ t)] : (s ∪ t).toFinset = s.toFinset ∪ t.toFinset :=\n  by\n  ext\n  simp\n#align set.to_finset_union Set.toFinset_union\n\n/- warning: set.to_finset_diff -> Set.toFinset_diff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (SDiff.sdiff.{u1} (Set.{u1} α) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s t) _inst_4) (SDiff.sdiff.{u1} (Finset.{u1} α) (Finset.hasSdiff.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} α t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} α (SDiff.sdiff.{u1} (Set.{u1} α) (Set.instSDiffSet.{u1} α) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (SDiff.sdiff.{u1} (Set.{u1} α) (Set.instSDiffSet.{u1} α) s t) _inst_4) (SDiff.sdiff.{u1} (Finset.{u1} α) (Finset.instSDiffFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_diff Set.toFinset_diffₓ'. -/\n@[simp]\ntheorem toFinset_diff [Fintype ↥(s \\ t)] : (s \\ t).toFinset = s.toFinset \\ t.toFinset :=\n  by\n  ext\n  simp\n#align set.to_finset_diff Set.toFinset_diff\n\n/- warning: set.to_finset_symm_diff -> Set.toFinset_symmDiff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (symmDiff.{u1} (Set.{u1} α) (SemilatticeSup.toHasSup.{u1} (Set.{u1} α) (Lattice.toSemilatticeSup.{u1} (Set.{u1} α) (CompleteLattice.toLattice.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α))))))) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (symmDiff.{u1} (Set.{u1} α) (SemilatticeSup.toHasSup.{u1} (Set.{u1} α) (Lattice.toSemilatticeSup.{u1} (Set.{u1} α) (CompleteLattice.toLattice.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α))))))) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s t) _inst_4) (symmDiff.{u1} (Finset.{u1} α) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} α) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} α) (Finset.lattice.{u1} α (fun (a : α) (b : α) => _inst_1 a b)))) (Finset.hasSdiff.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} α t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} α (symmDiff.{u1} (Set.{u1} α) (SemilatticeSup.toSup.{u1} (Set.{u1} α) (Lattice.toSemilatticeSup.{u1} (Set.{u1} α) (CompleteLattice.toLattice.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α))))))) (Set.instSDiffSet.{u1} α) s t))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (symmDiff.{u1} (Set.{u1} α) (SemilatticeSup.toSup.{u1} (Set.{u1} α) (Lattice.toSemilatticeSup.{u1} (Set.{u1} α) (CompleteLattice.toLattice.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α))))))) (Set.instSDiffSet.{u1} α) s t) _inst_4) (symmDiff.{u1} (Finset.{u1} α) (SemilatticeSup.toSup.{u1} (Finset.{u1} α) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} α) (Finset.instLatticeFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)))) (Finset.instSDiffFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u1} α t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_symm_diff Set.toFinset_symmDiffₓ'. -/\n@[simp]\ntheorem toFinset_symmDiff [Fintype ↥(s ∆ t)] : (s ∆ t).toFinset = s.toFinset ∆ t.toFinset :=\n  by\n  ext\n  simp [mem_symm_diff, Finset.mem_symmDiff]\n#align set.to_finset_symm_diff Set.toFinset_symmDiff\n\n/- warning: set.to_finset_compl -> Set.toFinset_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_4 : Fintype.{u1} α] [_inst_5 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) _inst_5) (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_4 (fun (a : α) (b : α) => _inst_1 a b))) (Set.toFinset.{u1} α s _inst_2))\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Set.{u1} α) [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_4 : Fintype.{u1} α] [_inst_5 : Fintype.{u1} (Set.Elem.{u1} α (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) _inst_5) (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_4 (fun (a : α) (b : α) => _inst_1 a b))) (Set.toFinset.{u1} α s _inst_2))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_compl Set.toFinset_complₓ'. -/\n@[simp]\ntheorem toFinset_compl [Fintype α] [Fintype ↥(sᶜ)] : sᶜ.toFinset = s.toFinsetᶜ :=\n  by\n  ext\n  simp\n#align set.to_finset_compl Set.toFinset_compl\n\nend DecidableEq\n\n#print Set.toFinset_empty /-\n-- TODO The `↥` circumvents an elaboration bug. See comment on `set.to_finset_univ`.\n@[simp]\ntheorem toFinset_empty [Fintype ↥(∅ : Set α)] : (∅ : Set α).toFinset = ∅ :=\n  by\n  ext\n  simp\n#align set.to_finset_empty Set.toFinset_empty\n-/\n\n#print Set.toFinset_univ /-\n/- TODO Without the coercion arrow (`↥`) there is an elaboration bug in the following two;\nit essentially infers `fintype.{v} (set.univ.{u} : set α)` with `v` and `u` distinct.\nReported in leanprover-community/lean#672 -/\n@[simp]\ntheorem toFinset_univ [Fintype α] [Fintype ↥(Set.univ : Set α)] :\n    (Set.univ : Set α).toFinset = Finset.univ :=\n  by\n  ext\n  simp\n#align set.to_finset_univ Set.toFinset_univ\n-/\n\n#print Set.toFinset_eq_empty /-\n@[simp]\ntheorem toFinset_eq_empty [Fintype s] : s.toFinset = ∅ ↔ s = ∅ := by\n  rw [← to_finset_empty, to_finset_inj]\n#align set.to_finset_eq_empty Set.toFinset_eq_empty\n-/\n\n#print Set.toFinset_eq_univ /-\n@[simp]\ntheorem toFinset_eq_univ [Fintype α] [Fintype s] : s.toFinset = Finset.univ ↔ s = univ := by\n  rw [← coe_inj, coe_to_finset, coe_univ]\n#align set.to_finset_eq_univ Set.toFinset_eq_univ\n-/\n\n#print Set.toFinset_setOf /-\n@[simp]\ntheorem toFinset_setOf [Fintype α] (p : α → Prop) [DecidablePred p] [Fintype { x | p x }] :\n    { x | p x }.toFinset = Finset.univ.filterₓ p :=\n  by\n  ext\n  simp\n#align set.to_finset_set_of Set.toFinset_setOf\n-/\n\n/- warning: set.to_finset_ssubset_univ -> Set.toFinset_ssubset_univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] {s : Set.{u1} α} [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) (Set.toFinset.{u1} α s _inst_2) (Finset.univ.{u1} α _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.hasSsubset.{u1} α) s (Set.univ.{u1} α))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] {s : Set.{u1} α} [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α s)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.instHasSSubsetFinset.{u1} α) (Set.toFinset.{u1} α s _inst_2) (Finset.univ.{u1} α _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} α) (Set.instHasSSubsetSet.{u1} α) s (Set.univ.{u1} α))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_ssubset_univ Set.toFinset_ssubset_univₓ'. -/\n@[simp]\ntheorem toFinset_ssubset_univ [Fintype α] {s : Set α} [Fintype s] :\n    s.toFinset ⊂ Finset.univ ↔ s ⊂ univ := by rw [← coe_ssubset, coe_to_finset, coe_univ]\n#align set.to_finset_ssubset_univ Set.toFinset_ssubset_univ\n\n#print Set.toFinset_image /-\n@[simp]\ntheorem toFinset_image [DecidableEq β] (f : α → β) (s : Set α) [Fintype s] [Fintype (f '' s)] :\n    (f '' s).toFinset = s.toFinset.image f :=\n  Finset.coe_injective <| by simp\n#align set.to_finset_image Set.toFinset_image\n-/\n\n/- warning: set.to_finset_range -> Set.toFinset_range is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u2} β] (f : β -> α) [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.range.{u1, succ u2} α β f))], Eq.{succ u1} (Finset.{u1} α) (Set.toFinset.{u1} α (Set.range.{u1, succ u2} α β f) _inst_3) (Finset.image.{u2, u1} β α (fun (a : α) (b : α) => _inst_1 a b) f (Finset.univ.{u2} β _inst_2))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : Fintype.{u1} β] (f : β -> α) [_inst_3 : Fintype.{u2} (Set.Elem.{u2} α (Set.range.{u2, succ u1} α β f))], Eq.{succ u2} (Finset.{u2} α) (Set.toFinset.{u2} α (Set.range.{u2, succ u1} α β f) _inst_3) (Finset.image.{u1, u2} β α (fun (a : α) (b : α) => _inst_1 a b) f (Finset.univ.{u1} β _inst_2))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_range Set.toFinset_rangeₓ'. -/\n@[simp]\ntheorem toFinset_range [DecidableEq α] [Fintype β] (f : β → α) [Fintype (Set.range f)] :\n    (Set.range f).toFinset = Finset.univ.image f :=\n  by\n  ext\n  simp\n#align set.to_finset_range Set.toFinset_range\n\n#print Set.toFinset_singleton /-\n-- TODO The `↥` circumvents an elaboration bug. See comment on `set.to_finset_univ`.\ntheorem toFinset_singleton (a : α) [Fintype ↥({a} : Set α)] : ({a} : Set α).toFinset = {a} :=\n  by\n  ext\n  simp\n#align set.to_finset_singleton Set.toFinset_singleton\n-/\n\n#print Set.toFinset_insert /-\n-- TODO The `↥` circumvents an elaboration bug. See comment on `set.to_finset_univ`.\n@[simp]\ntheorem toFinset_insert [DecidableEq α] {a : α} {s : Set α} [Fintype ↥(insert a s : Set α)]\n    [Fintype s] : (insert a s).toFinset = insert a s.toFinset :=\n  by\n  ext\n  simp\n#align set.to_finset_insert Set.toFinset_insert\n-/\n\n#print Set.filter_mem_univ_eq_toFinset /-\ntheorem filter_mem_univ_eq_toFinset [Fintype α] (s : Set α) [Fintype s] [DecidablePred (· ∈ s)] :\n    Finset.univ.filterₓ (· ∈ s) = s.toFinset := by\n  ext\n  simp only [mem_filter, Finset.mem_univ, true_and_iff, mem_to_finset]\n#align set.filter_mem_univ_eq_to_finset Set.filter_mem_univ_eq_toFinset\n-/\n\nend Set\n\n#print Finset.toFinset_coe /-\n@[simp]\ntheorem Finset.toFinset_coe (s : Finset α) [Fintype ↥(s : Set α)] : (s : Set α).toFinset = s :=\n  ext fun _ => Set.mem_toFinset\n#align finset.to_finset_coe Finset.toFinset_coe\n-/\n\ninstance (n : ℕ) : Fintype (Fin n) :=\n  ⟨⟨List.finRange n, List.nodup_finRange n⟩, List.mem_finRange⟩\n\n#print Fin.univ_def /-\ntheorem Fin.univ_def (n : ℕ) : (univ : Finset (Fin n)) = ⟨List.finRange n, List.nodup_finRange n⟩ :=\n  rfl\n#align fin.univ_def Fin.univ_def\n-/\n\n/- warning: fin.image_succ_above_univ -> Fin.image_succAbove_univ is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))), Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b) (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))))) (Fin.succAbove n i)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.booleanAlgebra.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b))) (Singleton.singleton.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasSingleton.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) i))\nbut is expected to have type\n  forall {n : Nat} (i : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))), Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => instDecidableEqFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) a b) (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succAbove n i))) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.booleanAlgebra.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => instDecidableEqFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) a b))) (Singleton.singleton.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.instSingletonFinset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) i))\nCase conversion may be inaccurate. Consider using '#align fin.image_succ_above_univ Fin.image_succAbove_univₓ'. -/\n@[simp]\ntheorem Fin.image_succAbove_univ {n : ℕ} (i : Fin (n + 1)) : univ.image i.succAbove = {i}ᶜ :=\n  by\n  ext m\n  simp\n#align fin.image_succ_above_univ Fin.image_succAbove_univ\n\n/- warning: fin.image_succ_univ -> Fin.image_succ_univ is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat), Eq.{1} (Finset.{0} (Fin (Nat.succ n))) (Finset.image.{0, 0} (Fin n) (Fin (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => Fin.decidableEq (Nat.succ n) a b) (Fin.succ n) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => Fin.decidableEq (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))))\nbut is expected to have type\n  forall (n : Nat), Eq.{1} (Finset.{0} (Fin (Nat.succ n))) (Finset.image.{0, 0} (Fin n) (Fin (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b) (Fin.succ n) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))))\nCase conversion may be inaccurate. Consider using '#align fin.image_succ_univ Fin.image_succ_univₓ'. -/\n@[simp]\ntheorem Fin.image_succ_univ (n : ℕ) : (univ : Finset (Fin n)).image Fin.succ = {0}ᶜ := by\n  rw [← Fin.succAbove_zero, Fin.image_succAbove_univ]\n#align fin.image_succ_univ Fin.image_succ_univ\n\n/- warning: fin.image_cast_succ -> Fin.image_castSucc is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat), Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b) (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))) (Fin.castSucc n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.booleanAlgebra.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b))) (Singleton.singleton.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasSingleton.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Fin.last n)))\nbut is expected to have type\n  forall (n : Nat), Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => instDecidableEqFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) a b) (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.castSucc n))) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.booleanAlgebra.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => instDecidableEqFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) a b))) (Singleton.singleton.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.instSingletonFinset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin.last n)))\nCase conversion may be inaccurate. Consider using '#align fin.image_cast_succ Fin.image_castSuccₓ'. -/\n@[simp]\ntheorem Fin.image_castSucc (n : ℕ) : (univ : Finset (Fin n)).image Fin.castSucc = {Fin.last n}ᶜ :=\n  by rw [← Fin.succAbove_last, Fin.image_succAbove_univ]\n#align fin.image_cast_succ Fin.image_castSucc\n\n/- warning: fin.univ_succ -> Fin.univ_succ is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat), Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.univ.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.cons.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (Eq.mpr.{0} (Not (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))))) True (id_tag Tactic.IdTag.simp (Eq.{1} Prop (Not (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))))) True) (Eq.trans.{1} Prop (Not (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))))) (Not False) True ((fun (a : Prop) (a_1 : Prop) (e_1 : Eq.{1} Prop a a_1) => congr_arg.{1, 1} Prop Prop a a_1 Not e_1) (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) False (Eq.trans.{1} Prop (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (Not True) False (Eq.trans.{1} Prop (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (Not (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))))) (Not True) (Eq.trans.{1} Prop (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => Fin.decidableEq (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))))) (Not (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))))) ((fun [self : Membership.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))] (ᾰ : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (ᾰ_1 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (e_2 : Eq.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) ᾰ ᾰ_1) (ᾰ_2 : Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (ᾰ_3 : Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (e_3 : Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) ᾰ_2 ᾰ_3) => congr.{1, 1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) Prop (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) self ᾰ) (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) self ᾰ_1) ᾰ_2 ᾰ_3 (congr_arg.{1, 1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) ((Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) -> Prop) ᾰ ᾰ_1 (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) self) e_2) e_3) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (rfl.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => Fin.decidableEq (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n))))))) (Eq.trans.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b) (Fin.succ n) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => Fin.decidableEq (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n))))))) (Eq.trans.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b) a b) (coeFn.{1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (fun (_x : Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Function.Embedding.hasCoeToFun.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n))) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b) (Fin.succ n) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (Finset.map_eq_image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) ((fun [_inst_1 : DecidableEq.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))] (f : (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (f_1 : (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (e_2 : Eq.{1} ((Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) f f_1) (s : Finset.{0} (Fin n)) (s_1 : Finset.{0} (Fin n)) (e_3 : Eq.{1} (Finset.{0} (Fin n)) s s_1) => congr.{1, 1} (Finset.{0} (Fin n)) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) _inst_1 f) (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) _inst_1 f_1) s s_1 (congr_arg.{1, 1} ((Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) ((Finset.{0} (Fin n)) -> (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))) f f_1 (Finset.image.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) _inst_1) e_2) e_3) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) a b) (coeFn.{1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (fun (_x : Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Function.Embedding.hasCoeToFun.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n))) (Fin.succ n) (Function.Embedding.coeFn_mk.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)) (rfl.{1} (Finset.{0} (Fin n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))))) (Fin.image_succ_univ n))) (propext (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (HasCompl.compl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.booleanAlgebra.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (Nat.succ n) a b) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))))) (Not (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))))) (Finset.mem_compl.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (b : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => Fin.decidableEq (Nat.succ n) a b) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))))) ((fun (a : Prop) (a_1 : Prop) (e_1 : Eq.{1} Prop a a_1) => congr_arg.{1, 1} Prop Prop a a_1 Not e_1) (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.hasSingleton.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n))))))) True (Eq.trans.{1} Prop (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Singleton.singleton.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasSingleton.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n))))))) (Eq.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))) True (propext (Membership.Mem.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasMem.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (Singleton.singleton.{0, 0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.hasSingleton.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n))))))) (Eq.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))) (Finset.mem_singleton.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))))) (propext (Eq.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))) True (eq_self_iff_true.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))))))) (propext (Not True) False not_true))) (propext (Not False) True not_false_iff))) trivial))\nbut is expected to have type\n  forall (n : Nat), Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.univ.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.cons.{0} (Fin (Nat.succ n)) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (of_eq_true (Not (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))))) (Eq.trans.{1} Prop (Not (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))))) (Not False) True (congrArg.{1, 1} Prop Prop (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) False Not (Eq.trans.{1} Prop (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (Not True) False (Eq.trans.{1} Prop (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (Not (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))))) (Not True) (Eq.trans.{1} Prop (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))))) (Not (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))))) (congrArg.{1, 1} (Finset.{0} (Fin (Nat.succ n))) Prop (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))))) (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))) (Eq.trans.{1} (Finset.{0} (Fin (Nat.succ n))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (Finset.image.{0, 0} (Fin n) (Fin (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b) (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (Nat.succ n))) (Fin n) (fun (a : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (Nat.succ n)) a) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (Nat.succ n))) (Fin n) (Fin (Nat.succ n)) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (Nat.succ n)))) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n))) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (HasCompl.compl.{0} (Finset.{0} (Fin (Nat.succ n))) (BooleanAlgebra.toHasCompl.{0} (Finset.{0} (Fin (Nat.succ n))) (Finset.booleanAlgebra.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))))) (Finset.map_eq_image.{0, 0} (Fin n) (Fin (Nat.succ n)) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b) (Function.Embedding.mk.{1, 1} (Fin n) (Fin (Nat.succ n)) (Fin.succ n) (Fin.succ_injective n)) (Finset.univ.{0} (Fin n) (Fin.fintype n))) (Fin.image_succ_univ n))) (Mathlib.Data.Fintype.Basic._auxLemma.8.{0} (Fin (Nat.succ n)) (Fin.fintype (Nat.succ n)) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))) (fun (a : Fin (Nat.succ n)) (b : Fin (Nat.succ n)) => instDecidableEqFin (Nat.succ n) a b) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))))) (congrArg.{1, 1} Prop Prop (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))))) True Not (Eq.trans.{1} Prop (Membership.mem.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instMembershipFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (Singleton.singleton.{0, 0} (Fin (Nat.succ n)) (Finset.{0} (Fin (Nat.succ n))) (Finset.instSingletonFinset.{0} (Fin (Nat.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))))) (Eq.{1} (Fin (Nat.succ n)) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))) True (Mathlib.Data.Finset.Basic._auxLemma.26.{0} (Fin (Nat.succ n)) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))) (eq_self.{1} (Fin (Nat.succ n)) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n))))))) Std.Logic._auxLemma.3)) Std.Logic._auxLemma.4)))\nCase conversion may be inaccurate. Consider using '#align fin.univ_succ Fin.univ_succₓ'. -/\n/- The following three lemmas use `finset.cons` instead of `insert` and `finset.map` instead of\n`finset.image` to reduce proof obligations downstream. -/\n/-- Embed `fin n` into `fin (n + 1)` by prepending zero to the `univ` -/\ntheorem Fin.univ_succ (n : ℕ) :\n    (univ : Finset (Fin (n + 1))) =\n      cons 0 (univ.map ⟨Fin.succ, Fin.succ_injective _⟩) (by simp [map_eq_image]) :=\n  by simp [map_eq_image]\n#align fin.univ_succ Fin.univ_succ\n\n#print Fin.univ_castSucc /-\n/-- Embed `fin n` into `fin (n + 1)` by appending a new `fin.last n` to the `univ` -/\ntheorem Fin.univ_castSucc (n : ℕ) :\n    (univ : Finset (Fin (n + 1))) =\n      cons (Fin.last n) (univ.map Fin.castSucc.toEmbedding) (by simp [map_eq_image]) :=\n  by simp [map_eq_image]\n#align fin.univ_cast_succ Fin.univ_castSucc\n-/\n\n#print Fin.univ_succAbove /-\n/-- Embed `fin n` into `fin (n + 1)` by inserting\naround a specified pivot `p : fin (n + 1)` into the `univ` -/\ntheorem Fin.univ_succAbove (n : ℕ) (p : Fin (n + 1)) :\n    (univ : Finset (Fin (n + 1))) = cons p (univ.map <| (Fin.succAbove p).toEmbedding) (by simp) :=\n  by simp [map_eq_image]\n#align fin.univ_succ_above Fin.univ_succAbove\n-/\n\n#print Unique.fintype /-\n@[instance]\ndef Unique.fintype {α : Type _} [Unique α] : Fintype α :=\n  Fintype.ofSubsingleton default\n#align unique.fintype Unique.fintype\n-/\n\n#print Fintype.subtypeEq /-\n/-- Short-circuit instance to decrease search for `unique.fintype`,\nsince that relies on a subsingleton elimination for `unique`. -/\ninstance Fintype.subtypeEq (y : α) : Fintype { x // x = y } :=\n  Fintype.subtype {y} (by simp)\n#align fintype.subtype_eq Fintype.subtypeEq\n-/\n\n#print Fintype.subtypeEq' /-\n/-- Short-circuit instance to decrease search for `unique.fintype`,\nsince that relies on a subsingleton elimination for `unique`. -/\ninstance Fintype.subtypeEq' (y : α) : Fintype { x // y = x } :=\n  Fintype.subtype {y} (by simp [eq_comm])\n#align fintype.subtype_eq' Fintype.subtypeEq'\n-/\n\n#print Fintype.univ_empty /-\n@[simp]\ntheorem Fintype.univ_empty : @univ Empty _ = ∅ :=\n  rfl\n#align fintype.univ_empty Fintype.univ_empty\n-/\n\n#print Fintype.univ_pempty /-\n@[simp]\ntheorem Fintype.univ_pempty : @univ PEmpty _ = ∅ :=\n  rfl\n#align fintype.univ_pempty Fintype.univ_pempty\n-/\n\ninstance : Fintype Unit :=\n  Fintype.ofSubsingleton ()\n\n#print Fintype.univ_unit /-\ntheorem Fintype.univ_unit : @univ Unit _ = {()} :=\n  rfl\n#align fintype.univ_unit Fintype.univ_unit\n-/\n\ninstance : Fintype PUnit :=\n  Fintype.ofSubsingleton PUnit.unit\n\n#print Fintype.univ_punit /-\n@[simp]\ntheorem Fintype.univ_punit : @univ PUnit _ = {PUnit.unit} :=\n  rfl\n#align fintype.univ_punit Fintype.univ_punit\n-/\n\ninstance : Fintype Bool :=\n  ⟨⟨{true, false}, by simp⟩, fun x => by cases x <;> simp⟩\n\n#print Fintype.univ_bool /-\n@[simp]\ntheorem Fintype.univ_bool : @univ Bool _ = {true, false} :=\n  rfl\n#align fintype.univ_bool Fintype.univ_bool\n-/\n\n#print Additive.fintype /-\ninstance Additive.fintype : ∀ [Fintype α], Fintype (Additive α) :=\n  id\n#align additive.fintype Additive.fintype\n-/\n\n#print Multiplicative.fintype /-\ninstance Multiplicative.fintype : ∀ [Fintype α], Fintype (Multiplicative α) :=\n  id\n#align multiplicative.fintype Multiplicative.fintype\n-/\n\n#print Fintype.prodLeft /-\n/-- Given that `α × β` is a fintype, `α` is also a fintype. -/\ndef Fintype.prodLeft {α β} [DecidableEq α] [Fintype (α × β)] [Nonempty β] : Fintype α :=\n  ⟨(Fintype.elems (α × β)).image Prod.fst, fun a =>\n    by\n    let ⟨b⟩ := ‹Nonempty β›\n    simp <;> exact ⟨b, Fintype.complete _⟩⟩\n#align fintype.prod_left Fintype.prodLeft\n-/\n\n#print Fintype.prodRight /-\n/-- Given that `α × β` is a fintype, `β` is also a fintype. -/\ndef Fintype.prodRight {α β} [DecidableEq β] [Fintype (α × β)] [Nonempty α] : Fintype β :=\n  ⟨(Fintype.elems (α × β)).image Prod.snd, fun b =>\n    by\n    let ⟨a⟩ := ‹Nonempty α›\n    simp <;> exact ⟨a, Fintype.complete _⟩⟩\n#align fintype.prod_right Fintype.prodRight\n-/\n\ninstance (α : Type _) [Fintype α] : Fintype (ULift α) :=\n  Fintype.ofEquiv _ Equiv.ulift.symm\n\ninstance (α : Type _) [Fintype α] : Fintype (PLift α) :=\n  Fintype.ofEquiv _ Equiv.plift.symm\n\ninstance (α : Type _) [Fintype α] : Fintype αᵒᵈ :=\n  ‹Fintype α›\n\ninstance (α : Type _) [Finite α] : Finite αᵒᵈ :=\n  ‹Finite α›\n\ninstance (α : Type _) [Fintype α] : Fintype (Lex α) :=\n  ‹Fintype α›\n\nsection Finset\n\n/-! ### `fintype (s : finset α)` -/\n\n\n#print Finset.fintypeCoeSort /-\ninstance Finset.fintypeCoeSort {α : Type u} (s : Finset α) : Fintype s :=\n  ⟨s.attach, s.mem_attach⟩\n#align finset.fintype_coe_sort Finset.fintypeCoeSort\n-/\n\n#print Finset.univ_eq_attach /-\n@[simp]\ntheorem Finset.univ_eq_attach {α : Type u} (s : Finset α) : (univ : Finset s) = s.attach :=\n  rfl\n#align finset.univ_eq_attach Finset.univ_eq_attach\n-/\n\nend Finset\n\n/- warning: fintype.coe_image_univ -> Fintype.coe_image_univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] {f : α -> β}, Eq.{succ u2} (Set.{u2} β) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} β) (Set.{u2} β) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (Finset.Set.hasCoeT.{u2} β))) (Finset.image.{u1, u2} α β (fun (a : β) (b : β) => _inst_2 a b) f (Finset.univ.{u1} α _inst_1))) (Set.range.{u2, succ u1} β α f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] {f : α -> β}, Eq.{succ u1} (Set.{u1} β) (Finset.toSet.{u1} β (Finset.image.{u2, u1} α β (fun (a : β) (b : β) => _inst_2 a b) f (Finset.univ.{u2} α _inst_1))) (Set.range.{u1, succ u2} β α f)\nCase conversion may be inaccurate. Consider using '#align fintype.coe_image_univ Fintype.coe_image_univₓ'. -/\ntheorem Fintype.coe_image_univ [Fintype α] [DecidableEq β] {f : α → β} :\n    ↑(Finset.image f Finset.univ) = Set.range f :=\n  by\n  ext x\n  simp\n#align fintype.coe_image_univ Fintype.coe_image_univ\n\n#print List.Subtype.fintype /-\ninstance List.Subtype.fintype [DecidableEq α] (l : List α) : Fintype { x // x ∈ l } :=\n  Fintype.ofList l.attach l.mem_attach\n#align list.subtype.fintype List.Subtype.fintype\n-/\n\n#print Multiset.Subtype.fintype /-\ninstance Multiset.Subtype.fintype [DecidableEq α] (s : Multiset α) : Fintype { x // x ∈ s } :=\n  Fintype.ofMultiset s.attach s.mem_attach\n#align multiset.subtype.fintype Multiset.Subtype.fintype\n-/\n\n#print Finset.Subtype.fintype /-\ninstance Finset.Subtype.fintype (s : Finset α) : Fintype { x // x ∈ s } :=\n  ⟨s.attach, s.mem_attach⟩\n#align finset.subtype.fintype Finset.Subtype.fintype\n-/\n\n#print FinsetCoe.fintype /-\ninstance FinsetCoe.fintype (s : Finset α) : Fintype (↑s : Set α) :=\n  Finset.Subtype.fintype s\n#align finset_coe.fintype FinsetCoe.fintype\n-/\n\n#print Finset.attach_eq_univ /-\ntheorem Finset.attach_eq_univ {s : Finset α} : s.attach = Finset.univ :=\n  rfl\n#align finset.attach_eq_univ Finset.attach_eq_univ\n-/\n\n#print PLift.fintypeProp /-\ninstance PLift.fintypeProp (p : Prop) [Decidable p] : Fintype (PLift p) :=\n  ⟨if h : p then {⟨h⟩} else ∅, fun ⟨h⟩ => by simp [h]⟩\n#align plift.fintype_Prop PLift.fintypeProp\n-/\n\n#print Prop.fintype /-\ninstance Prop.fintype : Fintype Prop :=\n  ⟨⟨{True, False}, by simp [true_ne_false]⟩, Classical.cases (by simp) (by simp)⟩\n#align Prop.fintype Prop.fintype\n-/\n\n/- warning: fintype.univ_Prop -> Fintype.univ_Prop is a dubious translation:\nlean 3 declaration is\n  Eq.{1} (Finset.{0} Prop) (Finset.univ.{0} Prop Prop.fintype) (Insert.insert.{0, 0} Prop (Finset.{0} Prop) (Finset.hasInsert.{0} Prop (fun (a : Prop) (b : Prop) => Eq.decidable.{0} Prop Prop.linearOrder a b)) True (Singleton.singleton.{0, 0} Prop (Finset.{0} Prop) (Finset.hasSingleton.{0} Prop) False))\nbut is expected to have type\n  Eq.{1} (Finset.{0} Prop) (Finset.univ.{0} Prop Prop.fintype) (Insert.insert.{0, 0} Prop (Finset.{0} Prop) (Finset.instInsertFinset.{0} Prop (fun (a : Prop) (b : Prop) => instDecidableEq.{0} Prop Prop.linearOrder a b)) True (Singleton.singleton.{0, 0} Prop (Finset.{0} Prop) (Finset.instSingletonFinset.{0} Prop) False))\nCase conversion may be inaccurate. Consider using '#align fintype.univ_Prop Fintype.univ_Propₓ'. -/\n@[simp]\ntheorem Fintype.univ_Prop : (Finset.univ : Finset Prop) = {True, False} :=\n  Finset.eq_of_veq <| by simp <;> rfl\n#align fintype.univ_Prop Fintype.univ_Prop\n\n#print Subtype.fintype /-\ninstance Subtype.fintype (p : α → Prop) [DecidablePred p] [Fintype α] : Fintype { x // p x } :=\n  Fintype.subtype (univ.filterₓ p) (by simp)\n#align subtype.fintype Subtype.fintype\n-/\n\n#print setFintype /-\n/-- A set on a fintype, when coerced to a type, is a fintype. -/\ndef setFintype [Fintype α] (s : Set α) [DecidablePred (· ∈ s)] : Fintype s :=\n  Subtype.fintype fun x => x ∈ s\n#align set_fintype setFintype\n-/\n\nsection\n\nvariable (α)\n\n/- warning: units_equiv_prod_subtype -> unitsEquivProdSubtype is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Monoid.{u1} α], Equiv.{succ u1, succ u1} (Units.{u1} α _inst_1) (Subtype.{succ u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => And (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)))))) (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Prod.snd.{u1, u1} α α p) (Prod.fst.{u1, u1} α α p)) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Monoid.{u1} α], Equiv.{succ u1, succ u1} (Units.{u1} α _inst_1) (Subtype.{succ u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => And (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α _inst_1)))) (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Prod.snd.{u1, u1} α α p) (Prod.fst.{u1, u1} α α p)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Monoid.toOne.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align units_equiv_prod_subtype unitsEquivProdSubtypeₓ'. -/\n/-- The `αˣ` type is equivalent to a subtype of `α × α`. -/\n@[simps]\ndef unitsEquivProdSubtype [Monoid α] : αˣ ≃ { p : α × α // p.1 * p.2 = 1 ∧ p.2 * p.1 = 1 }\n    where\n  toFun u := ⟨(u, ↑u⁻¹), u.val_inv, u.inv_val⟩\n  invFun p := Units.mk (p : α × α).1 (p : α × α).2 p.Prop.1 p.Prop.2\n  left_inv u := Units.ext rfl\n  right_inv p := Subtype.ext <| Prod.ext rfl rfl\n#align units_equiv_prod_subtype unitsEquivProdSubtype\n\n/- warning: units_equiv_ne_zero -> unitsEquivNeZero is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : GroupWithZero.{u1} α], Equiv.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_1))) (Subtype.{succ u1} α (fun (a : α) => Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_1)))))))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : GroupWithZero.{u1} α], Equiv.{succ u1, succ u1} (Units.{u1} α (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_1))) (Subtype.{succ u1} α (fun (a : α) => Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align units_equiv_ne_zero unitsEquivNeZeroₓ'. -/\n/-- In a `group_with_zero` `α`, the unit group `αˣ` is equivalent to the subtype of nonzero\nelements. -/\n@[simps]\ndef unitsEquivNeZero [GroupWithZero α] : αˣ ≃ { a : α // a ≠ 0 } :=\n  ⟨fun a => ⟨a, a.NeZero⟩, fun a => Units.mk0 _ a.Prop, fun _ => Units.ext rfl, fun _ =>\n    Subtype.ext rfl⟩\n#align units_equiv_ne_zero unitsEquivNeZero\n\nend\n\nnamespace Fintype\n\n#print Fintype.finsetEquivSet /-\n/-- Given `fintype α`, `finset_equiv_set` is the equiv between `finset α` and `set α`. (All\nsets on a finite type are finite.) -/\nnoncomputable def finsetEquivSet [Fintype α] : Finset α ≃ Set α\n    where\n  toFun := coe\n  invFun := by classical exact fun s => s.toFinset\n  left_inv s := by convert Finset.toFinset_coe s\n  right_inv s := by classical exact s.coe_to_finset\n#align fintype.finset_equiv_set Fintype.finsetEquivSet\n-/\n\n#print Fintype.finsetEquivSet_apply /-\n@[simp]\ntheorem finsetEquivSet_apply [Fintype α] (s : Finset α) : finsetEquivSet s = s :=\n  rfl\n#align fintype.finset_equiv_set_apply Fintype.finsetEquivSet_apply\n-/\n\n#print Fintype.finsetEquivSet_symm_apply /-\n@[simp]\ntheorem finsetEquivSet_symm_apply [Fintype α] (s : Set α) [Fintype s] :\n    finsetEquivSet.symm s = s.toFinset := by convert rfl\n#align fintype.finset_equiv_set_symm_apply Fintype.finsetEquivSet_symm_apply\n-/\n\nend Fintype\n\n#print Quotient.fintype /-\ninstance Quotient.fintype [Fintype α] (s : Setoid α) [DecidableRel ((· ≈ ·) : α → α → Prop)] :\n    Fintype (Quotient s) :=\n  Fintype.ofSurjective Quotient.mk' fun x => Quotient.inductionOn x fun x => ⟨x, rfl⟩\n#align quotient.fintype Quotient.fintype\n-/\n\n#print PSigma.fintypePropLeft /-\ninstance PSigma.fintypePropLeft {α : Prop} {β : α → Type _} [Decidable α] [∀ a, Fintype (β a)] :\n    Fintype (Σ'a, β a) :=\n  if h : α then Fintype.ofEquiv (β h) ⟨fun x => ⟨h, x⟩, PSigma.snd, fun _ => rfl, fun ⟨_, _⟩ => rfl⟩\n  else ⟨∅, fun x => h x.1⟩\n#align psigma.fintype_prop_left PSigma.fintypePropLeft\n-/\n\n#print PSigma.fintypePropRight /-\ninstance PSigma.fintypePropRight {α : Type _} {β : α → Prop} [∀ a, Decidable (β a)] [Fintype α] :\n    Fintype (Σ'a, β a) :=\n  Fintype.ofEquiv { a // β a }\n    ⟨fun ⟨x, y⟩ => ⟨x, y⟩, fun ⟨x, y⟩ => ⟨x, y⟩, fun ⟨x, y⟩ => rfl, fun ⟨x, y⟩ => rfl⟩\n#align psigma.fintype_prop_right PSigma.fintypePropRight\n-/\n\n#print PSigma.fintypePropProp /-\ninstance PSigma.fintypePropProp {α : Prop} {β : α → Prop} [Decidable α] [∀ a, Decidable (β a)] :\n    Fintype (Σ'a, β a) :=\n  if h : ∃ a, β a then ⟨{⟨h.fst, h.snd⟩}, fun ⟨_, _⟩ => by simp⟩ else ⟨∅, fun ⟨x, y⟩ => h ⟨x, y⟩⟩\n#align psigma.fintype_prop_prop PSigma.fintypePropProp\n-/\n\n#print pfunFintype /-\ninstance pfunFintype (p : Prop) [Decidable p] (α : p → Type _) [∀ hp, Fintype (α hp)] :\n    Fintype (∀ hp : p, α hp) :=\n  if hp : p then Fintype.ofEquiv (α hp) ⟨fun a _ => a, fun f => f hp, fun _ => rfl, fun _ => rfl⟩\n  else ⟨singleton fun h => (hp h).elim, by simp [hp, Function.funext_iff]⟩\n#align pfun_fintype pfunFintype\n-/\n\n/- warning: mem_image_univ_iff_mem_range -> mem_image_univ_iff_mem_range is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] {f : α -> β} {b : β}, Iff (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) b (Finset.image.{u1, u2} α β (fun (a : β) (b : β) => _inst_2 a b) f (Finset.univ.{u1} α _inst_1))) (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) b (Set.range.{u2, succ u1} β α f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] {f : α -> β} {b : β}, Iff (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) b (Finset.image.{u2, u1} α β (fun (a : β) (b : β) => _inst_2 a b) f (Finset.univ.{u2} α _inst_1))) (Membership.mem.{u1, u1} β (Set.{u1} β) (Set.instMembershipSet.{u1} β) b (Set.range.{u1, succ u2} β α f))\nCase conversion may be inaccurate. Consider using '#align mem_image_univ_iff_mem_range mem_image_univ_iff_mem_rangeₓ'. -/\ntheorem mem_image_univ_iff_mem_range {α β : Type _} [Fintype α] [DecidableEq β] {f : α → β}\n    {b : β} : b ∈ univ.image f ↔ b ∈ Set.range f := by simp\n#align mem_image_univ_iff_mem_range mem_image_univ_iff_mem_range\n\nnamespace Fintype\n\nsection Choose\n\nopen Fintype Equiv\n\nvariable [Fintype α] (p : α → Prop) [DecidablePred p]\n\n#print Fintype.chooseX /-\n/-- Given a fintype `α` and a predicate `p`, associate to a proof that there is a unique element of\n`α` satisfying `p` this unique element, as an element of the corresponding subtype. -/\ndef chooseX (hp : ∃! a : α, p a) : { a // p a } :=\n  ⟨Finset.choose p univ (by simp <;> exact hp), Finset.choose_property _ _ _⟩\n#align fintype.choose_x Fintype.chooseX\n-/\n\n#print Fintype.choose /-\n/-- Given a fintype `α` and a predicate `p`, associate to a proof that there is a unique element of\n`α` satisfying `p` this unique element, as an element of `α`. -/\ndef choose (hp : ∃! a, p a) : α :=\n  chooseX p hp\n#align fintype.choose Fintype.choose\n-/\n\n#print Fintype.choose_spec /-\ntheorem choose_spec (hp : ∃! a, p a) : p (choose p hp) :=\n  (chooseX p hp).property\n#align fintype.choose_spec Fintype.choose_spec\n-/\n\n#print Fintype.choose_subtype_eq /-\n@[simp]\ntheorem choose_subtype_eq {α : Type _} (p : α → Prop) [Fintype { a : α // p a }] [DecidableEq α]\n    (x : { a : α // p a })\n    (h : ∃! a : { a // p a }, (a : α) = x :=\n      ⟨x, rfl, fun y hy => by simpa [Subtype.ext_iff] using hy⟩) :\n    Fintype.choose (fun y : { a : α // p a } => (y : α) = x) h = x := by\n  rw [Subtype.ext_iff, Fintype.choose_spec (fun y : { a : α // p a } => (y : α) = x) _]\n#align fintype.choose_subtype_eq Fintype.choose_subtype_eq\n-/\n\nend Choose\n\nsection BijectionInverse\n\nopen Function\n\nvariable [Fintype α] [DecidableEq β] {f : α → β}\n\n#print Fintype.bijInv /-\n/-- `bij_inv f` is the unique inverse to a bijection `f`. This acts\n  as a computable alternative to `function.inv_fun`. -/\ndef bijInv (f_bij : Bijective f) (b : β) : α :=\n  Fintype.choose (fun a => f a = b)\n    (by\n      rcases f_bij.right b with ⟨a', fa_eq_b⟩\n      rw [← fa_eq_b]\n      exact ⟨a', ⟨rfl, fun a h => f_bij.left h⟩⟩)\n#align fintype.bij_inv Fintype.bijInv\n-/\n\n/- warning: fintype.left_inverse_bij_inv -> Fintype.leftInverse_bijInv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] {f : α -> β} (f_bij : Function.Bijective.{succ u1, succ u2} α β f), Function.LeftInverse.{succ u1, succ u2} α β (Fintype.bijInv.{u1, u2} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f f_bij) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] {f : α -> β} (f_bij : Function.Bijective.{succ u2, succ u1} α β f), Function.LeftInverse.{succ u2, succ u1} α β (Fintype.bijInv.{u2, u1} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f f_bij) f\nCase conversion may be inaccurate. Consider using '#align fintype.left_inverse_bij_inv Fintype.leftInverse_bijInvₓ'. -/\ntheorem leftInverse_bijInv (f_bij : Bijective f) : LeftInverse (bijInv f_bij) f := fun a =>\n  f_bij.left (choose_spec (fun a' => f a' = f a) _)\n#align fintype.left_inverse_bij_inv Fintype.leftInverse_bijInv\n\n/- warning: fintype.right_inverse_bij_inv -> Fintype.rightInverse_bijInv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] {f : α -> β} (f_bij : Function.Bijective.{succ u1, succ u2} α β f), Function.RightInverse.{succ u1, succ u2} α β (Fintype.bijInv.{u1, u2} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f f_bij) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] {f : α -> β} (f_bij : Function.Bijective.{succ u2, succ u1} α β f), Function.RightInverse.{succ u2, succ u1} α β (Fintype.bijInv.{u2, u1} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f f_bij) f\nCase conversion may be inaccurate. Consider using '#align fintype.right_inverse_bij_inv Fintype.rightInverse_bijInvₓ'. -/\ntheorem rightInverse_bijInv (f_bij : Bijective f) : RightInverse (bijInv f_bij) f := fun b =>\n  choose_spec (fun a' => f a' = b) _\n#align fintype.right_inverse_bij_inv Fintype.rightInverse_bijInv\n\n/- warning: fintype.bijective_bij_inv -> Fintype.bijective_bijInv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u2} β] {f : α -> β} (f_bij : Function.Bijective.{succ u1, succ u2} α β f), Function.Bijective.{succ u2, succ u1} β α (Fintype.bijInv.{u1, u2} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f f_bij)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : DecidableEq.{succ u1} β] {f : α -> β} (f_bij : Function.Bijective.{succ u2, succ u1} α β f), Function.Bijective.{succ u1, succ u2} β α (Fintype.bijInv.{u2, u1} α β _inst_1 (fun (a : β) (b : β) => _inst_2 a b) f f_bij)\nCase conversion may be inaccurate. Consider using '#align fintype.bijective_bij_inv Fintype.bijective_bijInvₓ'. -/\ntheorem bijective_bijInv (f_bij : Bijective f) : Bijective (bijInv f_bij) :=\n  ⟨(rightInverse_bijInv _).Injective, (leftInverse_bijInv _).Surjective⟩\n#align fintype.bijective_bij_inv Fintype.bijective_bijInv\n\nend BijectionInverse\n\nend Fintype\n\nsection Trunc\n\n#print truncOfMultisetExistsMem /-\n/-- For `s : multiset α`, we can lift the existential statement that `∃ x, x ∈ s` to a `trunc α`.\n-/\ndef truncOfMultisetExistsMem {α} (s : Multiset α) : (∃ x, x ∈ s) → Trunc α :=\n  Quotient.recOnSubsingleton s fun l h =>\n    match l, h with\n    | [], _ => False.elim (by tauto)\n    | a :: _, _ => Trunc.mk a\n#align trunc_of_multiset_exists_mem truncOfMultisetExistsMem\n-/\n\n#print truncOfNonemptyFintype /-\n/-- A `nonempty` `fintype` constructively contains an element.\n-/\ndef truncOfNonemptyFintype (α) [Nonempty α] [Fintype α] : Trunc α :=\n  truncOfMultisetExistsMem Finset.univ.val (by simp)\n#align trunc_of_nonempty_fintype truncOfNonemptyFintype\n-/\n\n#print truncSigmaOfExists /-\n/-- By iterating over the elements of a fintype, we can lift an existential statement `∃ a, P a`\nto `trunc (Σ' a, P a)`, containing data.\n-/\ndef truncSigmaOfExists {α} [Fintype α] {P : α → Prop} [DecidablePred P] (h : ∃ a, P a) :\n    Trunc (Σ'a, P a) :=\n  @truncOfNonemptyFintype (Σ'a, P a) (Exists.elim h fun a ha => ⟨⟨a, ha⟩⟩) _\n#align trunc_sigma_of_exists truncSigmaOfExists\n-/\n\nend Trunc\n\nnamespace Multiset\n\nvariable [Fintype α] [DecidableEq α]\n\n#print Multiset.count_univ /-\n@[simp]\ntheorem count_univ (a : α) : count a Finset.univ.val = 1 :=\n  count_eq_one_of_mem Finset.univ.Nodup (Finset.mem_univ _)\n#align multiset.count_univ Multiset.count_univ\n-/\n\nend Multiset\n\n#print seqOfForallFinsetExistsAux /-\n/-- Auxiliary definition to show `exists_seq_of_forall_finset_exists`. -/\nnoncomputable def seqOfForallFinsetExistsAux {α : Type _} [DecidableEq α] (P : α → Prop)\n    (r : α → α → Prop) (h : ∀ s : Finset α, ∃ y, (∀ x ∈ s, P x) → P y ∧ ∀ x ∈ s, r x y) : ℕ → α\n  | n =>\n    Classical.choose\n      (h\n        (Finset.image (fun i : Fin n => seqOfForallFinsetExistsAux i)\n          (Finset.univ : Finset (Fin n))))decreasing_by\n  exact i.2\n#align seq_of_forall_finset_exists_aux seqOfForallFinsetExistsAux\n-/\n\n#print exists_seq_of_forall_finset_exists /-\n/-- Induction principle to build a sequence, by adding one point at a time satisfying a given\nrelation with respect to all the previously chosen points.\n\nMore precisely, Assume that, for any finite set `s`, one can find another point satisfying\nsome relation `r` with respect to all the points in `s`. Then one may construct a\nfunction `f : ℕ → α` such that `r (f m) (f n)` holds whenever `m < n`.\nWe also ensure that all constructed points satisfy a given predicate `P`. -/\ntheorem exists_seq_of_forall_finset_exists {α : Type _} (P : α → Prop) (r : α → α → Prop)\n    (h : ∀ s : Finset α, (∀ x ∈ s, P x) → ∃ y, P y ∧ ∀ x ∈ s, r x y) :\n    ∃ f : ℕ → α, (∀ n, P (f n)) ∧ ∀ m n, m < n → r (f m) (f n) := by\n  classical\n    have : Nonempty α := by\n      rcases h ∅ (by simp) with ⟨y, hy⟩\n      exact ⟨y⟩\n    choose! F hF using h\n    have h' : ∀ s : Finset α, ∃ y, (∀ x ∈ s, P x) → P y ∧ ∀ x ∈ s, r x y := fun s => ⟨F s, hF s⟩\n    set f := seqOfForallFinsetExistsAux P r h' with hf\n    have A : ∀ n : ℕ, P (f n) := by\n      intro n\n      induction' n using Nat.strong_induction_on with n IH\n      have IH' : ∀ x : Fin n, P (f x) := fun n => IH n.1 n.2\n      rw [hf, seqOfForallFinsetExistsAux]\n      exact\n        (Classical.choose_spec\n            (h' (Finset.image (fun i : Fin n => f i) (Finset.univ : Finset (Fin n))))\n            (by simp [IH'])).1\n    refine' ⟨f, A, fun m n hmn => _⟩\n    nth_rw 2 [hf]\n    rw [seqOfForallFinsetExistsAux]\n    apply\n      (Classical.choose_spec\n          (h' (Finset.image (fun i : Fin n => f i) (Finset.univ : Finset (Fin n)))) (by simp [A])).2\n    exact Finset.mem_image.2 ⟨⟨m, hmn⟩, Finset.mem_univ _, rfl⟩\n#align exists_seq_of_forall_finset_exists exists_seq_of_forall_finset_exists\n-/\n\n#print exists_seq_of_forall_finset_exists' /-\n/-- Induction principle to build a sequence, by adding one point at a time satisfying a given\nsymmetric relation with respect to all the previously chosen points.\n\nMore precisely, Assume that, for any finite set `s`, one can find another point satisfying\nsome relation `r` with respect to all the points in `s`. Then one may construct a\nfunction `f : ℕ → α` such that `r (f m) (f n)` holds whenever `m ≠ n`.\nWe also ensure that all constructed points satisfy a given predicate `P`. -/\ntheorem exists_seq_of_forall_finset_exists' {α : Type _} (P : α → Prop) (r : α → α → Prop)\n    [IsSymm α r] (h : ∀ s : Finset α, (∀ x ∈ s, P x) → ∃ y, P y ∧ ∀ x ∈ s, r x y) :\n    ∃ f : ℕ → α, (∀ n, P (f n)) ∧ ∀ m n, m ≠ n → r (f m) (f n) :=\n  by\n  rcases exists_seq_of_forall_finset_exists P r h with ⟨f, hf, hf'⟩\n  refine' ⟨f, hf, fun m n hmn => _⟩\n  rcases lt_trichotomy m n with (h | rfl | h)\n  · exact hf' m n h\n  · exact (hmn rfl).elim\n  · apply symm\n    exact hf' n m h\n#align exists_seq_of_forall_finset_exists' exists_seq_of_forall_finset_exists'\n-/\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Fintype/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592641, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.48772850446067983}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport algebra.category.Mon.basic\nimport category_theory.endomorphism\n\n/-!\n# Category instances for group, add_group, comm_group, and add_comm_group.\n\nWe introduce the bundled categories:\n* `Group`\n* `AddGroup`\n* `CommGroup`\n* `AddCommGroup`\nalong with the relevant forgetful functors between them, and to the bundled monoid categories.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of groups and group morphisms. -/\n@[to_additive AddGroup]\ndef Group : Type (u+1) := bundled group\n\n/-- The category of additive groups and group morphisms -/\nadd_decl_doc AddGroup\n\nnamespace Group\n\n@[to_additive]\ninstance : bundled_hom.parent_projection group.to_monoid := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] Group\nattribute [to_additive] Group.large_category Group.concrete_category\n\n@[to_additive] instance : has_coe_to_sort Group Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `Group` from the underlying type and typeclass. -/\n@[to_additive] def of (X : Type u) [group X] : Group := bundled.of X\n\n/-- Construct a bundled `AddGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddGroup.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `Group`. -/\n@[to_additive] def of_hom {X Y : Type u} [group X] [group Y] (f : X →* Y) : of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddGroup`. -/\nadd_decl_doc AddGroup.of_hom\n\n@[simp, to_additive] lemma of_hom_apply {X Y : Type*} [group X] [group Y] (f : X →* Y) (x : X) :\n  of_hom f x = f x := rfl\n\n@[to_additive]\ninstance (G : Group) : group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [group R] : (Group.of R : Type u) = R := rfl\n\n@[to_additive]\ninstance : inhabited Group := ⟨Group.of punit⟩\n\n@[to_additive]\ninstance of_unique (G : Type*) [group G] [i : unique G] : unique (Group.of G) := i\n\n@[simp, to_additive]\nlemma one_apply (G H : Group) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[ext, to_additive]\n\n\n@[to_additive has_forget_to_AddMon]\ninstance has_forget_to_Mon : has_forget₂ Group Mon := bundled_hom.forget₂ _ _\n\n@[to_additive] instance : has_coe Group.{u} Mon.{u} :=\n{ coe := (forget₂ Group Mon).obj, }\n\nend Group\n\n/-- The category of commutative groups and group morphisms. -/\n@[to_additive AddCommGroup]\ndef CommGroup : Type (u+1) := bundled comm_group\n\n/-- The category of additive commutative groups and group morphisms. -/\nadd_decl_doc AddCommGroup\n\n/-- `Ab` is an abbreviation for `AddCommGroup`, for the sake of mathematicians' sanity. -/\nabbreviation Ab := AddCommGroup\n\nnamespace CommGroup\n\n@[to_additive]\ninstance : bundled_hom.parent_projection comm_group.to_group := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommGroup\nattribute [to_additive] CommGroup.large_category CommGroup.concrete_category\n\n@[to_additive] instance : has_coe_to_sort CommGroup Type* := bundled.has_coe_to_sort\n\n\n/-- Construct a bundled `CommGroup` from the underlying type and typeclass. -/\n@[to_additive] def of (G : Type u) [comm_group G] : CommGroup := bundled.of G\n\n/-- Construct a bundled `AddCommGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddCommGroup.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `CommGroup`. -/\n@[to_additive] def of_hom {X Y : Type u} [comm_group X] [comm_group Y] (f : X →* Y) :\n  of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddCommGroup`. -/\nadd_decl_doc AddCommGroup.of_hom\n\n@[simp, to_additive] lemma of_hom_apply {X Y : Type*} [comm_group X] [comm_group Y] (f : X →* Y)\n  (x : X) : of_hom f x = f x := rfl\n\n@[to_additive]\ninstance comm_group_instance (G : CommGroup) : comm_group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [comm_group R] : (CommGroup.of R : Type u) = R := rfl\n\n@[to_additive]\ninstance : inhabited CommGroup := ⟨CommGroup.of punit⟩\n\n@[to_additive]\ninstance of_unique (G : Type*) [comm_group G] [i : unique G] : unique (CommGroup.of G) := i\n\n@[simp, to_additive]\nlemma one_apply (G H : CommGroup) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[ext, to_additive]\nlemma ext (G H : CommGroup) (f₁ f₂ : G ⟶ H) (w : ∀ x, f₁ x = f₂ x) : f₁ = f₂ :=\nby { ext1, apply w }\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget₂ CommGroup Group := bundled_hom.forget₂ _ _\n\n@[to_additive] instance : has_coe CommGroup.{u} Group.{u} :=\n{ coe := (forget₂ CommGroup Group).obj, }\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget₂ CommGroup CommMon :=\ninduced_category.has_forget₂ (λ G : CommGroup, CommMon.of G)\n\n@[to_additive] instance : has_coe CommGroup.{u} CommMon.{u} :=\n{ coe := (forget₂ CommGroup CommMon).obj, }\n\nend CommGroup\n\n-- This example verifies an improvement possible in Lean 3.8.\n-- Before that, to have `monoid_hom.map_map` usable by `simp` here,\n-- we had to mark all the concrete category `has_coe_to_sort` instances reducible.\n-- Now, it just works.\n@[to_additive]\nexample {R S : CommGroup} (i : R ⟶ S) (r : R) (h : r = 1) : i r = 1 :=\nby simp [h]\n\nnamespace AddCommGroup\n\n/-- Any element of an abelian group gives a unique morphism from `ℤ` sending\n`1` to that element. -/\n-- Note that because `ℤ : Type 0`, this forces `G : AddCommGroup.{0}`,\n-- so we write this explicitly to be clear.\n-- TODO generalize this, requiring a `ulift_instances.lean` file\ndef as_hom {G : AddCommGroup.{0}} (g : G) : (AddCommGroup.of ℤ) ⟶ G :=\nzmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : ℤ) : (as_hom g) i = i • g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\nλ h k w, by convert congr_arg (λ k : (AddCommGroup.of ℤ) ⟶ G, (k : ℤ → G) (1 : ℤ)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of ℤ) ⟶ G) (w : f (1 : ℤ) = g (1 : ℤ)) : f = g :=\nadd_monoid_hom.ext_int w\n\n-- TODO: this argument should be generalised to the situation where\n-- the forgetful functor is representable.\nlemma injective_of_mono {G H : AddCommGroup.{0}} (f : G ⟶ H) [mono f] : function.injective f :=\nλ g₁ g₂ h,\nbegin\n  have t0 : as_hom g₁ ≫ f = as_hom g₂ ≫ f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g₁ = as_hom g₂ := (cancel_mono _).1 t0,\n  apply as_hom_injective t1,\nend\n\nend AddCommGroup\n\n/-- Build an isomorphism in the category `Group` from a `mul_equiv` between `group`s. -/\n@[to_additive add_equiv.to_AddGroup_iso, simps]\ndef mul_equiv.to_Group_iso {X Y : Group} (e : X ≃* Y) : X ≅ Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddGroup` from an `add_equiv` between `add_group`s. -/\nadd_decl_doc add_equiv.to_AddGroup_iso\n\n/-- Build an isomorphism in the category `CommGroup` from a `mul_equiv` between `comm_group`s. -/\n@[to_additive add_equiv.to_AddCommGroup_iso, simps]\ndef mul_equiv.to_CommGroup_iso {X Y : CommGroup} (e : X ≃* Y) : X ≅ Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddCommGroup` from a `add_equiv` between\n`add_comm_group`s. -/\nadd_decl_doc add_equiv.to_AddCommGroup_iso\n\nnamespace category_theory.iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Group`. -/\n@[to_additive AddGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism in the category\n`AddGroup`.\", simps]\ndef Group_iso_to_mul_equiv {X Y : Group} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\n/-- Build a `mul_equiv` from an isomorphism in the category `CommGroup`. -/\n@[to_additive AddCommGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism\nin the category `AddCommGroup`.\", simps]\ndef CommGroup_iso_to_mul_equiv {X Y : CommGroup} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\nend category_theory.iso\n\n/-- multiplicative equivalences between `group`s are the same as (isomorphic to) isomorphisms\nin `Group` -/\n@[to_additive add_equiv_iso_AddGroup_iso \"additive equivalences between `add_group`s are the same\nas (isomorphic to) isomorphisms in `AddGroup`\"]\ndef mul_equiv_iso_Group_iso {X Y : Group.{u}} : (X ≃* Y) ≅ (X ≅ Y) :=\n{ hom := λ e, e.to_Group_iso,\n  inv := λ i, i.Group_iso_to_mul_equiv, }\n\n/-- multiplicative equivalences between `comm_group`s are the same as (isomorphic to) isomorphisms\nin `CommGroup` -/\n@[to_additive add_equiv_iso_AddCommGroup_iso \"additive equivalences between `add_comm_group`s are\nthe same as (isomorphic to) isomorphisms in `AddCommGroup`\"]\ndef mul_equiv_iso_CommGroup_iso {X Y : CommGroup.{u}} : X ≃* Y ≅ (X ≅ Y) :=\n{ hom := λ e, e.to_CommGroup_iso,\n  inv := λ i, i.CommGroup_iso_to_mul_equiv, }\n\nnamespace category_theory.Aut\n\n/-- The (bundled) group of automorphisms of a type is isomorphic to the (bundled) group\nof permutations. -/\ndef iso_perm {α : Type u} : Group.of (Aut α) ≅ Group.of (equiv.perm α) :=\n{ hom := ⟨λ g, g.to_equiv, (by tidy), (by tidy)⟩,\n  inv := ⟨λ g, g.to_iso, (by tidy), (by tidy)⟩ }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {α : Type u} : Aut α ≃* equiv.perm α :=\niso_perm.Group_iso_to_mul_equiv\n\nend category_theory.Aut\n\n@[to_additive]\ninstance Group.forget_reflects_isos : reflects_isomorphisms (forget Group.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Group_iso).1⟩,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommGroup_iso).1⟩,\n  end }\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/category/Group/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592641, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4877285004160944}}
{"text": "import analysis.complex.isometry\nimport analysis.complex.real_deriv\nimport analysis.calculus.conformal\n\nnoncomputable theory\n\nopen complex linear_isometry linear_isometry_equiv continuous_linear_map\n     finite_dimensional linear_map\n\nsection A\n  \nvariables (𝕜 : Type*) [nondiscrete_normed_field 𝕜]\nvariables {𝕜' : Type*} [nondiscrete_normed_field 𝕜'] [normed_algebra 𝕜 𝕜']\nvariables {E : Type*} [normed_group E] [normed_space 𝕜 E] [normed_space 𝕜' E]\nvariables [is_scalar_tower 𝕜 𝕜' E]\nvariables {F : Type*} [normed_group F] [normed_space 𝕜 F] [normed_space 𝕜' F]\nvariables [is_scalar_tower 𝕜 𝕜' F]\nvariables {f : E → F} {f' : E →L[𝕜'] F} {s : set E} {x : E}\n\nlemma differentiable_at_iff_exists_linear_map (hf : differentiable_at 𝕜 f x) :\n  differentiable_at 𝕜' f x ↔ ∃ (g' : E →L[𝕜'] F), g'.restrict_scalars 𝕜 = fderiv 𝕜 f x :=\nsorry\n\nend A\n\nsection B\n\nvariables {E : Type*} [normed_group E] [normed_space ℝ E] [normed_space ℂ E]\n  [is_scalar_tower ℝ ℂ E] {z : ℂ} {g : ℂ →L[ℝ] E} {f : ℂ → E}\n\nlemma is_conformal_map_of_complex_linear\n  {map : ℂ →L[ℂ] E} (nonzero : map ≠ 0) : is_conformal_map (map.restrict_scalars ℝ) :=\nsorry\n\n\nlemma conformal_at_of_holomorph_or_antiholomorph_at_aux\n  (hf : differentiable_at ℝ f z) (hf' : fderiv ℝ f z ≠ 0)\n  (h : differentiable_at ℂ f z ∨ differentiable_at ℂ (f ∘ conj) (conj z)) :\n  conformal_at f z :=\nbegin\n  rw [conformal_at_iff_is_conformal_map_fderiv],\n  cases h with h₁ h₂,\n  { rw [differentiable_at_iff_exists_linear_map ℝ hf] at h₁;\n       [skip, apply_instance, apply_instance, apply_instance],\n    rcases h₁ with ⟨map, hmap⟩,\n    have minor₁ : fderiv ℝ f z = map.restrict_scalars ℝ := hmap.symm,\n    rw minor₁,\n    refine is_conformal_map_of_complex_linear _,},\nend\n\nend B", "meta": {"author": "justadzr", "repo": "lean-2021", "sha": "dfc6b30de2f27bdba5fbc51183e2b84e73a920d1", "save_path": "github-repos/lean/justadzr-lean-2021", "path": "github-repos/lean/justadzr-lean-2021/lean-2021-dfc6b30de2f27bdba5fbc51183e2b84e73a920d1/src/experiment.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.487628517141828}}
{"text": "import set_category.diagram_lemmas\nimport set_category.category_set\nimport set_category.limits.Equalizer\nimport help_functions\nimport coalgebra.Coalgebra\nimport coalgebra.subcoalgebra\n\n\n\nimport tactic.tidy\n\nuniverses u\n\n\n\nnamespace coalgebra_equalizer\n\nopen category_theory \n     set \n     coalgebra\n     classical\n     function\n     help_functions\n     Equalizer\n     coalgebra.Coalgebra\n     category_set\n     subcoalgebra\n     \n\nlocal notation f ` ⊚ `:80 g:80 := category_struct.comp g f\n\nvariables   {F : Type u ⥤ Type u}\n            {𝔸 Β: Coalgebra F}\n            (ϕ ψ : 𝔸 ⟶ Β)\n\ntheorem largest_subcoalgebra_equalizer \n    {C : set (equalizer_set ϕ ψ)}\n    (lar : is_largest_coalgebra C):\n    let E := equalizer_set ϕ ψ in\n    let e : E → 𝔸 := (E ↪ 𝔸) in\n    let ℂ : Coalgebra F := ⟨C , some lar.1⟩  in\n    let σ : ℂ ⟶ 𝔸 := ⟨(e ∘ (C ↪ E))  , some_spec lar.1⟩ in\n    is_equalizer ϕ ψ σ := \n    begin \n        intros E e ℂ σ,\n\n        split,\n\n        exact eq_in_set.1 \n            (funext (λ c, ((C ↪ E) c).property)),\n        \n        intros Q q ϕq_ψq,\n\n        have is_eq := (eqaulizer_set_is_equalizer ϕ ψ).2 q \n                    (eq_in_set.2 ϕq_ψq),\n\n        let f : Q → E := some is_eq,\n        have eq_f := some_spec is_eq,\n\n        have fact : q.val = e ∘ f := eq_f.1,\n\n        let f₁ : Q → (range f) := range_factorization f,\n\n        let e₁ : range f → 𝔸 := e ∘ (range f ↪ E),\n\n        have inj_e₁ : injective e₁ := \n            begin\n                intros a₁ a₂ k,\n                have inj_e : ∀ r₁ r₂, e r₁ = e r₂ → r₁ = r₂ := \n                    inj_inclusion 𝔸 E,\n                have ra : (range f ↪ E) a₁ = (range f ↪ E) a₂ :=\n                    inj_e a₁ a₂ k,\n                have inj_r : ∀ q₁ q₂, \n                    (range f ↪ E) q₁ = (range f ↪ E) q₂ → q₁ = q₂ := \n                        inj_inclusion E (range f),\n                exact (inj_r) a₁ a₂ ra,\n            end,\n\n        have inj_σ : injective σ := \n            begin\n                intros a₁ a₂ k,\n                have inj_e : ∀ r₁ r₂, e r₁ = e r₂ → r₁ = r₂ := \n                    inj_inclusion 𝔸 E,\n                have ra : (C ↪ E) a₁ = (C ↪ E) a₂ :=\n                    inj_e a₁ a₂ k,\n                have inj_r : ∀ q₁ q₂, (C ↪ E) q₁ = (C ↪ E) q₂ → q₁ = q₂ := \n                    inj_inclusion E C,\n                exact inj_r a₁ a₂ ra,\n            end,\n\n        have ex := Factorization q f₁ e₁ fact\n            ((epi_iff_surjective f₁).2 surjective_onto_range) inj_e₁,\n\n        let α_ℝ : range f → F.obj (range f) := some ex,\n\n        have Rf_C : range f ⊆ C := \n            lar.2 (range f) (exists.intro α_ℝ (some_spec ex).1.2),\n\n        let fc : Q.carrier → ℂ.carrier := λ q₁ , ⟨f q₁, Rf_C (f₁ q₁).property ⟩, \n\n        have f_fc : ∀ q₁, f q₁ = fc q₁ := λ q₁, rfl,\n\n        have q_fc_σ_el : ∀ q₁ , q.val q₁ = (σ ∘ fc) q₁ := \n            λ q₁, \n            have s0 : (σ ∘ fc) q₁ = (e ∘ f) q₁ := rfl,\n            by rw [fact, s0],\n        \n        have q_fc_σ : q.val = σ ∘ fc := funext q_fc_σ_el,\n        \n        have hom_σ_fc : @is_coalgebra_homomorphism F Q 𝔸 (σ ∘ fc) :=\n            q_fc_σ ▸ q.property,\n\n        have hom_fc : @is_coalgebra_homomorphism F Q ℂ fc :=\n            inj_to_hom fc σ hom_σ_fc σ.property inj_σ,\n        \n        let h_fc : Q ⟶ ℂ := ⟨fc , hom_fc ⟩,\n\n        use h_fc, \n        have s1 : q.val = (σ ⊚ h_fc).val := q_fc_σ,\n        split,\n        exact eq_in_set.1 s1,\n\n        intros g q_σ_g,\n\n        let σ₁ : ℂ.carrier ⟶ 𝔸.carrier := σ.val,\n\n        have inj_σ₁ : injective σ₁ := inj_σ,\n\n        haveI mo : mono σ₁ := (mono_iff_injective σ).2 inj_σ₁, \n\n        have s2 : (σ ⊚ g).val = (σ ⊚ h_fc).val := \n             q_σ_g ▸ s1,\n\n        have s3 : σ.val ∘ g.val = σ.val ∘ h_fc.val := \n             s2,\n        \n        have s4 : g.val = h_fc.val :=  left_cancel σ₁ s3,\n\n        exact eq_in_set.1 s4\n\n    end\n\n    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend coalgebra_equalizer", "meta": {"author": "QaisHamarneh", "repo": "Coalgebra-in-Lean", "sha": "bd0452df98bc64b608e5dfd7babc42c301bb6a46", "save_path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean", "path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean/Coalgebra-in-Lean-bd0452df98bc64b608e5dfd7babc42c301bb6a46/src/coalgebra/limits/coalgebra_equalizer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.48757918254300536}}
{"text": "import algebra.order.monoid\nimport data.rat.basic\nimport topology.algebra.infinite_sum\n\nopen function\n\nvariables {M : Type*} {N : Type*}\n\ndef with_top.cast_fun (f : M → N) : with_top M → with_top N\n| ⊤ := ⊤\n| (x : M) := f x\n\nvariables [hM : add_monoid M] [hN : add_monoid N] {f : add_monoid_hom M N}\ninclude hM hN \n\nlemma with_top.cast_fun_zero : with_top.cast_fun f (0 : M) = 0:=\nby { rw with_top.cast_fun, rw map_zero, refl }\n\nlemma with_top.cast_fun_add :\n∀ a b : with_top M, (a + b).cast_fun f = a.cast_fun f + b.cast_fun f\n| ⊤ b := show _ = ⊤ + _, by simp only [with_top.top_add]; refl\n| a ⊤ := show _ = _ + ⊤, by simp only [with_top.add_top]; refl \n| (a : M) (b : M) := \nby rw [← with_top.coe_add, with_top.cast_fun, with_top.cast_fun, with_top.cast_fun,\n    ← with_top.coe_add, with_top.coe_eq_coe, map_add]\n\nlemma with_top.cast_fun_eq_top : ∀ {x : with_top M}, x.cast_fun f = ⊤ → x = ⊤\n| ⊤ := λ h, rfl \n| (x : M) := λ h, absurd h with_top.coe_ne_top\n\nlemma with_top.cast_fun_inj (hf : injective f) : injective (with_top.cast_fun f)\n| ⊤ y h := (with_top.cast_fun_eq_top h.symm).symm\n| x ⊤ h := with_top.cast_fun_eq_top h  \n| (x : M) (y : M) h := \nby { injections, exact with_top.coe_eq_coe.mpr ((injective.eq_iff hf).mp h_1)}\n\nvariable (f)\n\ndef with_top.cast_add_monoid_hom : with_top M →+ with_top N :=\n{ to_fun   := with_top.cast_fun f,\n  map_zero' := with_top.cast_fun_zero,\n  map_add' := with_top.cast_fun_add }\n\ndef mulcast : multiplicative (order_dual (with_top M)) →*\n  multiplicative (order_dual (with_top N)) :=\n{ to_fun   := with_top.cast_fun f,\n  map_one' := with_top.cast_fun_zero,\n  map_mul' := with_top.cast_fun_add }\n\nomit hM hN\n\ndef mulcast' {E F : Type*} [linear_ordered_add_comm_monoid E] [linear_ordered_add_comm_monoid F]\n  (g : add_monoid_hom E F) : multiplicative (order_dual (with_top E)) →*₀\n  multiplicative (order_dual (with_top F)) := \n{ to_fun  := with_top.cast_fun g,\n  map_zero' := rfl,\n  map_one'  := with_top.cast_fun_zero,\n  map_mul'  := with_top.cast_fun_add }\n\nvariable {f}\n\nlemma mulcast_injective (hf : injective f) : function.injective (mulcast f):=\nwith_top.cast_fun_inj hf\n\nsection comm_group\nvariables (f) [linear_ordered_add_comm_group M] [linear_ordered_add_comm_group N]\n\nlemma mulcast_map_zero : mulcast f 0 = 0 := rfl\n\nvariable {f}\n\nlemma mulcast_eq_zero_iff (hf : injective f) (x : multiplicative (order_dual (with_top M))) :  \n  mulcast f x = 0 ↔ x = 0 :=\nbegin\n  rw [← mulcast_map_zero f],\n  exact ⟨λ h, mulcast_injective hf h, congr_arg _⟩\nend\n\n/- lemma mulcast_map_gen : \n  mulcast (mul_gen (with_top ℤ)) = mul_gen (with_top ℚ) :=\nshow ↑_ = ↑_, by rw int.cast_one -/\n\nlemma with_top_cast_le_with_top_cast (hf : strict_mono f) : ∀ (x y : with_top M),\n  with_top.cast_fun f x ≤ with_top.cast_fun f y ↔  x ≤ y\n| ⊤ b := \nby erw [top_le_iff, top_le_iff]; exact ⟨with_top.cast_fun_eq_top, λ h, h.symm ▸ rfl⟩\n| a ⊤ := ⟨λ h, le_top, λ h, le_top⟩\n| (a : M) (b : M) := by { rw [with_top.cast_fun, with_top.cast_fun, with_top.coe_le_coe,\n  with_top.coe_le_coe], exact hf.le_iff_le}\n\nlemma with_top_cast_lt_with_top_cast (hf : strict_mono f) : ∀ (x y : with_top M),\n  with_top.cast_fun f x < with_top.cast_fun f y ↔  x < y\n| ⊤ ⊤ := by simp only [lt_self_iff_false]\n| ⊤ (b : M) := by { simp only [not_top_lt, iff_false, not_lt], exact le_top } \n| (a : M) ⊤ := ⟨λ h, with_top.coe_lt_top _, λ h, with_top.coe_lt_top _⟩\n| (a : M) (b : M) := \nby { rw [with_top.cast_fun, with_top.cast_fun, with_top.coe_lt_coe, with_top.coe_lt_coe],\n  exact hf.lt_iff_lt }\n\nlemma mulcast_le_mulcast (hf : strict_mono f) (x y : multiplicative (order_dual (with_top M))) : \n  mulcast f x ≤ mulcast f y ↔ x ≤ y :=\nwith_top_cast_le_with_top_cast hf _ _\n\nlemma mulcast_lt_mulcast (hf : strict_mono f) (x y : multiplicative (order_dual (with_top M))) : \n  mulcast f x < mulcast f y ↔ x < y :=\nwith_top_cast_lt_with_top_cast hf _ _\n\nend comm_group\n\nsection ring\n\nvariables [linear_ordered_comm_ring M] -- [linear_ordered_comm_ring N]\n\nlemma with_top_add_mul (m : M) (hm : m ≠ 0) : ∀ a b : with_top M,\n  (a + b) * m = a * m + b * m\n| ⊤ _ :=\nby rw [top_add, with_top.top_mul (show (m : with_top M) ≠ 0, by norm_cast; exact hm), top_add]\n| _ ⊤ :=\nby rw [add_top, with_top.top_mul (show (m : with_top M) ≠ 0, by norm_cast; exact hm), add_top]\n| (some a) (some b) :=\nby simp only [with_top.some_eq_coe, ←with_top.coe_add, ←with_top.coe_mul, add_mul]\n\nlemma mul_eq_top_iff (m : M) (hm : m ≠ 0) : ∀ a : with_top M,\n  a * m = ⊤ ↔ a = ⊤\n| ⊤ := ⟨λ h, rfl, λ h, by rw [with_top.top_mul]; norm_cast; exact hm⟩\n| (some m) := \n⟨λ h, absurd (by rwa [with_top.some_eq_coe, ←with_top.coe_mul] at h) with_top.coe_ne_top, \n λ h, absurd h with_top.coe_ne_top⟩\n\nlemma succ_nsmul_top (m : ℕ) : ((m + 1) • ⊤ : with_top M) = ⊤ :=\nbegin\n  induction m with m hm,\n  { simp only [one_nsmul] },\n  { simp only [succ_nsmul, with_top.top_add] },\nend\n\nlemma nsmul_top_mul (m : ℕ) (q : M) :\n  (m • (⊤ : with_top M)) * q = ⊤ * (m * q : M) :=\nbegin  \n  induction m with m hm,\n  { simp only [zero_smul, zero_mul, nat.cast_zero, with_top.coe_zero, mul_zero], },  \n  { rw succ_nsmul_top,\n    by_cases q = 0,\n    { simp only [h, with_top.coe_zero, mul_zero] },\n    { rw with_top.top_mul (show (q : with_top M) ≠ 0, by norm_cast; exact h),\n      refine (with_top.top_mul _).symm,\n      norm_cast,\n      exact (λ hn, h $ or.resolve_left (mul_eq_zero.1 hn)\n        (by norm_cast; exact nat.succ_ne_zero _))}}\nend\n\nlemma zero_le_mul_inv (m : M) (hm : 0 < m) : ∀ x : with_top M,\n  0 ≤ x ↔ 0 ≤ x * m\n| ⊤ := by {rw with_top.top_mul, norm_cast, linarith }\n| (some a) := \nbegin\n  simp only [with_top.some_eq_coe, ←with_top.coe_zero, ←with_top.coe_mul, \n    with_top.coe_le_coe, zero_le_mul_right hm],\nend\n\nlemma nsmul_coe (m : ℕ) (x : M) : m • (x : with_top M) = m * x :=\nbegin\n  induction m with m hm,\n  { rw [zero_smul, nat.cast_zero, zero_mul] },\n  { rw [succ_nsmul, hm],\n    norm_cast,\n    rw [nat.cast_succ, add_mul, one_mul, add_comm] }\nend\n\nlemma nsmul_top (m : ℕ) : m • (⊤ : with_top M) = m * ⊤ :=\nbegin\n  induction m with m hm,\n  { simp only [zero_smul, nat.cast_zero, zero_mul] },\n  { rw [succ_nsmul_top,  with_top.mul_top],\n    exact nat.cast_ne_zero.mpr (nat.succ_ne_zero _) }\nend\n\nlemma nsmul_with_top (m : ℕ) : ∀ (x : with_top M), m • x = m * x \n| ⊤ := nsmul_top _ \n| (some x) := nsmul_coe _ _\n\nlemma nsmul_coe_mul (m : ℕ) (x q : M) :\n  (m • (x : with_top M)) * q = x * (m * q : M) :=\nbegin\n  rw [nsmul_coe, mul_comm ↑m, mul_assoc],\n  congr,\n  norm_cast,\nend \n\nlemma nsmul_mul (m : ℕ) (q : M) : ∀ x : with_top M,\n  (m • x : with_top M) * q = x * (m * q : M) \n| ⊤ := nsmul_top_mul _ _\n| (some x) := nsmul_coe_mul m x q\n\nlemma nsmul_comm (m : ℕ) (q : M) (x : with_top M) :\n  (m • x : with_top M) * q = m • (x * q) := \nbegin \n  rw [nsmul_mul, with_top.coe_mul, ←mul_assoc, mul_comm x, mul_assoc, nsmul_with_top],\n  congr' 1,\nend\n\nlemma mul_coe_one (x : with_top M) :\n  x * (1 : M) = x := mul_one _\n\ninstance multiplicative_order_dual.has_pow :\n  has_pow (multiplicative (order_dual (with_top M))) M := \n⟨λ x y, ((x : with_top M) * y : with_top M)⟩ \n\nlemma mulM_mul_pow {m : M} (hm : m ≠ 0) (g h : multiplicative (order_dual (with_top M)))  : \n  (g * h) ^ m = g ^ m * h ^ m :=\nwith_top_add_mul _ hm _ _\n\nlemma mulM_zero_pow (n : M) (h : n ≠ 0) : (0 : multiplicative (order_dual (with_top M))) ^ n = 0 := \nwith_top.top_mul (by norm_cast; exact h)\n\nlemma mulM_one_pow (n : M) : (1 : multiplicative (order_dual (with_top M))) ^ n = 1 := zero_mul _ \n\nlemma mulM_pow_one (x : multiplicative (order_dual (with_top M))) : x ^ (1 : M) = x := \nmul_coe_one x \n\nlemma mulM_pow_le_one (q : M) (h : 0 < q) (x : multiplicative (order_dual (with_top M))) :\n x ≤ 1 ↔ x ^ q ≤ 1 :=\nzero_le_mul_inv _ h _\n\nlemma mulM_pow_eq_zero_iff (x : multiplicative (order_dual (with_top M))) {q : M} (h : q ≠ 0) :\n  x ^ q = 0 ↔ x = 0 :=\nmul_eq_top_iff _ h _ \n\nlemma mulM_pow_mul (n : ℕ) (q : M) (x : multiplicative (order_dual (with_top M))) :\n  (x ^ n) ^ q = x ^ ((n : M) * q) :=\nnsmul_mul _ _ _\n\nlemma mulM_pow_comm (n : ℕ) (q : M) (x : multiplicative (order_dual (with_top M))) :\n  (x ^ n) ^ q = (x ^ q) ^ n :=\nnsmul_comm _ _ _\n\nend ring\n\nsection field\n\nvariable [linear_ordered_field M]\n\nlemma mul_inv_le_mul_inv (m : ℕ) (h : m ≠ 0) :\n  ∀ g h : with_top M, g ≤ h → g * (m⁻¹ : M) ≤ h * (m⁻¹ : M) \n| ⊤ a H := \nbegin\n  rw [top_le_iff.1 H, with_top.top_mul],\n  { exact le_refl _},\n  { simp [h] }\nend\n| a ⊤ H := \nbegin\n  rw with_top.top_mul,\n  { exact le_top },\n  { simp [h] }\nend\n| (some a) (some b) H := by { simp only [with_top.some_eq_coe, ←with_top.coe_mul,\n    with_top.coe_le_coe, with_top.some_eq_coe] at ⊢ H,\n    exact (mul_le_mul_right (by {rw [inv_pos], norm_cast, exact pos_iff_ne_zero.2 h})).2 H }\n\nlemma mulM_pow_le_of_le {m : ℕ} {g h : multiplicative (order_dual (with_top M))} (hm : m ≠ 0)\n  (H : h ≤ g) : h ^ (m⁻¹ : M) ≤ g ^ (m⁻¹ : M) :=\nmul_inv_le_mul_inv m hm g h H\n\nend field\n\n--#lint", "meta": {"author": "mariainesdff", "repo": "local_fields", "sha": "53a20ab87cf8f6ab27eedef2d9da929898951d82", "save_path": "github-repos/lean/mariainesdff-local_fields", "path": "github-repos/lean/mariainesdff-local_fields/local_fields-53a20ab87cf8f6ab27eedef2d9da929898951d82/old_lean_files/with_top.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.78793120560257, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.48755641316307297}}
{"text": "import util.control.applicative\n\nuniverses u v\n\nvariable {m : Type u → Type v}\nvariable [monad m]\nvariables {α β γ : Type u}\n\nopen functor nat\n\nnamespace monad\n\nlemma map_bind (f : γ → β) (x : m α) (g : α → m γ)\n: f <$> (x >>= g) = x >>= (map f ∘ g) :=\nsorry\n\nlemma bind_map (f : α → β) (x : m α) (g : β → m γ)\n: f <$> x >>= g = x >>= g ∘ f :=\nsorry\n\ndef mmap₂  (f : α → β → m γ) : list α → list β → m (list γ)\n| (x :: xs) (y :: ys) := (::) <$> f x y <*> mmap₂ xs ys\n| [] _ := pure []\n| _ [] := pure []\n\ndef mmap₂'  (f : α → β → m γ) : list α → list β → m punit\n| (x :: xs) (y :: ys) := f x y *> mmap₂' xs ys\n| [] _ := pure punit.star\n| _ [] := pure punit.star\n\nend monad\n\nopen applicative\n\ndef monad.mrepeat : ℕ → m α → m (list α)\n | 0 _ := return []\n | (succ n) m := lift₂ (::) m (monad.mrepeat n m)\n\ndef monad.mrepeat' : ℕ → m α → m punit\n | 0 _ := return punit.star\n | (succ n) m := m *> monad.mrepeat' n m\n", "meta": {"author": "unitb", "repo": "lean-lib", "sha": "439b80e606b4ebe4909a08b1d77f4f5c0ee3dee9", "save_path": "github-repos/lean/unitb-lean-lib", "path": "github-repos/lean/unitb-lean-lib/lean-lib-439b80e606b4ebe4909a08b1d77f4f5c0ee3dee9/src/util/control/monad.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312056025699, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4875564131630729}}
{"text": "import FirstOrderLeaning\n\nopen Classical\n\ninductive Asrt where\n  | literal : Bool → Asrt\n  | emp : Asrt\n  | singleton : Nat → Nat → Asrt\n  | sep : Asrt → Asrt → Asrt\n--  | sepimp : Asrt → Asrt → Asrt\nopen Asrt\n\ndef Partial (A B : Type): Type := A → Option B\n\ndef Store : Type := Nat → Nat\ndef Heap : Type := Partial Nat Nat\n\ndef Subset (A : Type) : Type := A → Prop\n\ndef empty_set {A : Type} : Subset A :=\nλ x => false\n\ndef set_union {A : Type} (s1 s2 : Subset A) : Subset A :=\nλ x => (s1 x) ∨ (s2 x)\n\ndef set_intersection {A : Type} (s1 s2 : Subset A) : Subset A :=\nλ x => (s1 x) ∧ (s2 x)\n\ndef set_disjoint {A : Type} (s1 s2 : Subset A) : Prop :=\n∀ x , ¬((s1 x) ∧ (s2 x))\n\ndef set_subset {A : Type} (s1 s2 : Subset A) : Prop :=\n∀ x , (s1 x) → (s2 x)\n\n-- s1 / s2\ndef set_difference {A : Type} (s1 s2 : Subset A) : Subset A :=\nλ x => (s1 x) ∧ ¬(s2 x)\n\n@[simp] def equal {A : Type} (s1 s2 : Subset A) : Prop :=\n  ∀ x , s1 x ↔ s2 x\n\n@[simp] def dom {A B : Type}  (p : Partial A B) : Subset A := λ a => (p a).isSome\n\ndef empty_partial {A B : Type} : Partial A B := λ x => none\n\nnoncomputable def singleton_partial {A B : Type} (a : A) (b : B) : Partial A B := λ x => if (x = a) then some b else none\n\nnoncomputable def singleton_partial_some {A B : Type} (a : A) (b : Option B) : Partial A B := match b with\n  | some x => singleton_partial a x\n  | none => empty_partial\n\ndef disjoint {A B : Type} (p1 p2 : Partial A B) : Prop :=\nset_intersection (dom p1) (dom p2) = empty_set\n\ninfix:60 \" ⊥ \" => disjoint\n\ntheorem disjoint_symm {A B : Type} {p1 p2 : Partial A B} : p1 ⊥ p2 ↔ p2 ⊥ p1 := by {\n  simp[disjoint];\n  simp[set_intersection];\n  simp[empty_set];\n  apply Iff.intro;\n  case mp  => {\n    intro lhs;\n    rw[← lhs];\n    apply funext;\n    intro x;\n    rw[and_symm];\n  }\n  case mpr => {\n    intro lhs;\n    rw[← lhs];\n    apply funext;\n    intro x;\n    rw[and_symm];\n  }\n}\n\n@[simp]\ndef in_partial {A B : Type} (a : A) (p : Partial A B) : Prop := (p a).isSome\n\ndef partial_of {A B : Type} (p1 p2 : Partial A B) : Prop :=\n  ∀ x , match p1 x with\n  | some y => (p2 x) = some y\n  | none   => True\n\ninfix:60 \" ⊆ \" => partial_of\n\n@[simp] theorem partial_of_emp {A B : Type} (p : Partial A B) : empty_partial ⊆ p := by {\n  simp[partial_of, empty_partial];\n}\n\n@[simp] theorem partial_of_singleton {A B : Type} (a : A) (b : B) (p : Partial A B) : ((singleton_partial a b) ⊆ p) ↔ (p a = some b) := by {\n  simp [partial_of];\n  simp [singleton_partial];\n  apply Iff.intro;\n  case mp  => {\n    intro precondition ;\n    have p1 := precondition a;\n    simp at p1;\n    exact p1;\n  }\n  case mpr => {\n    intro pred a1;\n    apply Or.elim (Classical.em (a1 = a));\n    case left => {\n      intro temp;\n      simp[temp];\n      exact pred;\n    }\n    case right => {\n      intro temp;\n      simp[temp];\n    }\n  }\n}\n\ntheorem partial_of_self (p : Partial A B) : p ⊆ p := by {\n  simp[partial_of];\n  intro x;\n  apply Or.elim (Classical.em (p x).isSome);\n  case left  => {\n    rw[is_some];\n    intro ⟨ witness, proof ⟩;\n    rw[proof];\n  }\n  case right => {\n    rw[is_not_some];\n    intro p_x_none;\n    rw[p_x_none];\n    simp;\n  }\n}\n\ntheorem partial_of_transitive {p1 p2 p3 : Partial A B} : p1 ⊆ p2 → p2 ⊆ p3 → p1 ⊆ p3 := by {\n  simp[partial_of];\n  intro p1_p2 p2_p3;\n  intro x;\n  have := p1_p2 x;\n  apply Or.elim (Classical.em (p1 x).isSome);\n  case left  => {\n    simp[is_some];\n    intro ⟨ witness, proof ⟩;\n    rw[proof];\n    simp;\n    rw[proof] at this;\n    simp at this;\n    have p2_x := this;\n    have := p2_p3 x;\n    rw[p2_x] at this;\n    simp at this;\n    exact this;\n  }\n  case right => {\n    rw[is_not_some];\n    intro not_p1_x;\n    rw[not_p1_x];\n    simp;\n  }\n}\n\ntheorem disjoint_partial {p1 p2 p1' : Partial A B} : p1 ⊥ p2 → p1' ⊆ p1 → p1' ⊥ p2 := by {\n  simp[disjoint, partial_of, set_intersection, empty_set];\n  intro disjoint_proof;\n  intro partial_proof;\n  apply funext;\n  intro x;\n  have partial_proof1 := partial_proof x;\n  have disjoint_proof1 := congrFun disjoint_proof x;\n  apply Or.elim (Classical.em (p1' x).isSome);\n  case left  => {\n    intro temp;\n    simp[temp];\n    revert temp;\n    rw[is_some];\n    intro ⟨ witness, proof ⟩;\n    revert disjoint_proof1;\n    simp[proof] at partial_proof1;\n    simp[partial_proof1];\n    simp[Option.isSome];\n    split <;> simp;\n  }\n  case right => {\n    intro temp;\n    simp[temp];\n  }\n}\n\nnoncomputable def union {A : Type} (p1 p2 : Partial A B) : Partial A B :=\nλ x => if (p1 x) = none then (p2 x) else (p1 x)\n\ninfix:60 \" ∪ \" => union\n\ntheorem union_disjoint_symm : p1 ⊥ p2 → p1 ∪ p2 = p2 ∪ p1 := by {\n  simp[disjoint, union, set_intersection, empty_set];\n  intro disjoint_proof;\n  apply funext;\n  intro x;\n  have disjoint_proof1 := congrFun disjoint_proof x;\n  simp[de_morgan''] at disjoint_proof1;\n  simp[is_not_some''] at disjoint_proof1;\n  apply Or.elim (Classical.em (p1 x).isSome);\n  case left  => {\n    simp[is_some];\n    intro ⟨ witness, proof ⟩;\n    simp[proof];\n    simp[proof] at disjoint_proof1;\n    simp[disjoint_proof1];\n  }\n  case right => {\n    simp[is_not_some''];\n    intro temp;\n    simp[temp];\n    match p2 x with\n    | some _ => simp;\n    | none   => simp;\n  }\n}\n\ntheorem partial_of_p1_union : p1 ⊥ p2 → p = p1 ∪ p2 → p1 ⊆ p := by {\n  simp[union];\n  intro disjoint_proof p_defn;\n  simp[partial_of];\n  rw[p_defn];\n  intro x;\n  apply Or.elim (Classical.em (p1 x).isSome);\n  case left  => {\n    simp[is_some];\n    intro ⟨ witness, proof ⟩;\n    rw[proof];\n    simp;\n  }\n  case right => {\n    simp[is_not_some''];\n    intro h1x_none;\n    simp[h1x_none];\n  }\n}\n\ntheorem partial_of_union : p1 ⊥ p2 → p = p1 ∪ p2 → p1 ⊆ p ∧ p2 ⊆ p := by {\n  intro disjoint_proof_p1_p2 p_p1_p2;\n  have disjoint_proof_p2_p1 := (disjoint_symm.mp disjoint_proof_p1_p2);\n  have p_p2_p1 : p = (union p2 p1) := by { rw[(union_disjoint_symm disjoint_proof_p1_p2)] at p_p1_p2; exact p_p1_p2;};\n  apply And.intro (partial_of_p1_union disjoint_proof_p1_p2 p_p1_p2)\n                  (partial_of_p1_union disjoint_proof_p2_p1 p_p2_p1);\n}\n\nnoncomputable def partial_difference {A B : Type} (p1 p2 : Partial A B) : Partial A B :=\nλ x => match (p2 x) with\n  | some _ => none\n  | none => p1 x\n\ninfix:60 \"\\\\\" => partial_difference\n\ntheorem eq_false'' {A : Prop} : (A = False) → ¬ A := by {\n  intro a_false;\n  intro a;\n  rw[a_false] at a;\n  exact a;\n}\n\ntheorem exists_witness {A : Type} : (witness : A) → (∃ (a : A) , witness = a) := by {\n  intro witness;\n  apply Exists.intro witness;\n  simp;\n}\n\ntheorem partial_of_disjoint_subtraction {A B : Type} {p1 p2 p3 : Partial A B} : p1 ⊆ p3 ∧ disjoint p1 p2 → p1 ⊆ (partial_difference p3 p2) := by {\n  simp [partial_of, partial_difference, disjoint, set_intersection, empty_set];\n  intro ⟨ partial_p1_p3 , disjoint_p1_p2 ⟩ x;\n  have partial_p1_p3_x := partial_p1_p3 x;\n  apply Or.elim (Classical.em (p1 x).isSome);\n  case left  => {\n    rw[is_some];\n    intro ⟨ witness, proof⟩;\n    rw[proof];\n    simp;\n    rw[proof] at partial_p1_p3_x;\n    simp at partial_p1_p3_x;\n    have := (congrFun disjoint_p1_p2) x;\n    rw[proof] at this;\n    rw[is_some] at this;\n    simp at this;\n    have := eq_false'' this;\n    simp[(exists_witness witness)] at this;\n    rw[is_not_some''] at this;\n    simp[this];\n    assumption;\n  }\n  case right => {\n    rw[is_not_some];\n    intro p1_x_none;\n    rw[p1_x_none];\n    simp;\n  }\n}\n\ntheorem partial_of_difference_self {A B : Type} (p1 p2 : Partial A B) : partial_difference p1 p2 ⊆ p1 := by {\n  simp[partial_of, partial_difference];\n  intro x;\n  apply Or.elim (Classical.em (p2 x).isSome);\n  case left  => {\n    rw[is_some];\n    intro ⟨ proof , witness ⟩;\n    simp[witness];\n  }\n  case right => {\n    rw[is_not_some];\n    intro not_p2_x;\n    simp[not_p2_x];\n    apply Or.elim (Classical.em (p1 x).isSome);\n    case left  => {\n      rw[is_some];\n      intro ⟨ witness , proof ⟩;\n      simp[proof];\n    }\n    case right => {\n      rw[is_not_some];\n      intro not_p1_x;\n      simp[not_p1_x];\n    }\n  }\n}\n\ntheorem difference_disjoint {A B : Type} (p1 p2 : Partial A B) : partial_difference p1 p2 ⊥ p2 := by {\n  simp[partial_difference, disjoint, set_intersection, empty_set];\n  apply funext;\n  intro x;\n  apply Or.elim (Classical.em (p2 x).isSome);\n  case left  => {\n    rw[is_some];\n    intro ⟨ witness, proof ⟩;\n    rw[proof];\n    simp[Option.isSome];\n  }\n  case right => {\n    rw[is_not_some];\n    intro p2_x_none;\n    simp[p2_x_none, Option.isSome];\n  }\n}\n\ntheorem difference_union_opposite {p1 p2 : Partial A B} : p2 ⊆ p1 → p1 = (partial_difference p1 p2) ∪ p2 := by {\n  simp[partial_difference, union, partial_of];\n  intro p2_p1;\n  apply funext;\n  intro x;\n  apply Or.elim (Classical.em (p2 x).isSome);\n  case left  => {\n    rw[is_some];\n    intro ⟨ witness, proof ⟩;\n    simp[proof];\n    have := p2_p1 x;\n    rw[proof] at this;\n    simp at this;\n    exact this;\n  }\n  case right => {\n    rw[is_not_some];\n    intro p2_x_none;\n    simp[p2_x_none];\n    apply Or.elim (Classical.em (p1 x).isSome);\n    · rw[is_some]; intro ⟨ witness , proof ⟩ ; simp[proof];\n    · rw[is_not_some]; intro temp; simp[temp];\n  }\n}\n\ntheorem difference_union_opposite' {p1 p2 : Partial A B} : p2 ⊆ p1 → p1 = p2 ∪ (partial_difference p1 p2) := by {\n  rw[union_disjoint_symm];\n  exact difference_union_opposite;\n  exact disjoint_symm.mp (difference_disjoint p1 p2);\n}\n\ndef asrt (q : Asrt) (s : Store) (h : Heap) : Prop := match q with\n  | literal b => b\n  | emp       => ∀ x , (dom h) x = false\n  | singleton v1 v2 => h (s v1) = some (s v2) ∧ ∀ x , (dom h) x ↔ (x = (s v1))\n  | sep q1 q2 => ∃ h1 h2 , (asrt q1 s h1) ∧ (asrt q2 s h2) ∧ (disjoint h1 h2) ∧ h = (union h1 h2)\n--  | sepimp q1 q2 => ∀ h' , (asrt q1 s h') ∧ disjoint h h' -> asrt q2 s (union h h')\n\n@[simp]\nnoncomputable def check (q : Asrt) (s : Store) (h : Heap) : (Prop × Heap) := match q with\n  | literal b => (b , empty_partial)\n  | emp       => (True, empty_partial)\n  | singleton v1 v2 => (h (s v1) = some (s v2) , singleton_partial_some (s v1) (h (s v1)))\n  | sep q1 q2 => let ⟨ b1 , m1 ⟩ := (check q1 s h); let ⟨ b2 , m2 ⟩ := (check q2 s h); (b1 ∧ b2 ∧ (disjoint m1 m2) , (union m1 m2))\n--  | sepimp q1 q2 => let ⟨ b1 , m1 , t1 ⟩ := (check q1 s h); let ⟨ b2 , m2 , t2 ⟩ := (check q2 s h); (b1 → b2 ∧ m1 ⊆ m2 , partial_difference m2 m1 , sorry)\n\ndef tight (q : Asrt) : Prop := match q with\n  | literal lit => False\n  | emp => True\n  | singleton v1 v2 => True\n  | sep q1 q2 => tight q1 ∧ tight q2\n--  | sepimp q1 q2 => False;\n\ntheorem partiality (q : Asrt) (s : Store) (h_tilde : Heap) : (check q s h_tilde).2 ⊆ h_tilde := by {\n  match q with\n  | literal lit => simp;\n  | emp => simp;\n  | singleton v1 v2 => {\n    simp[check];\n    simp[singleton_partial_some];\n    apply Or.elim (Classical.em (h_tilde (s v1)).isSome);\n    case left => {\n      rw[is_some];\n      intro ⟨ a, b ⟩;\n      simp[b];\n    }\n    case right => {\n      rw[is_not_some];\n      intro temp;\n      rw [temp];\n      simp;\n    }\n  }\n  | sep q1 q2 => {\n    have partial1 := partiality q1 s h_tilde;\n    have partial2 := partiality q2 s h_tilde;\n    simp[check];\n    simp[partial_of];\n    intro x;\n    simp[union];\n    simp[partial_of] at partial1;\n    have partial1_1 := partial1 x;\n    simp[partial_of] at partial2;\n    have partial2_1 := partial2 x;\n    apply Or.elim (Classical.em ((check q1 s h_tilde).2 x = none));\n    case left  => {\n      apply Or.elim (Classical.em ((check q2 s h_tilde).2 x = none));\n      case left => intro temp1 temp2; simp[temp1, temp2];\n      case right => {\n        intro temp1 temp2;\n        rw[← is_not_some] at temp1;\n        simp[dne] at temp1;\n        rw[is_some] at temp1;\n        have ⟨ witness, proof ⟩ := temp1;\n        simp[proof, temp2];\n        rw[proof] at partial2_1;\n        simp at partial2_1;\n        exact partial2_1;\n      }\n    }\n    case right => {\n      apply Or.elim (Classical.em ((check q2 s h_tilde).2 x = none));\n      case left  => {\n        intro temp1 temp2;\n        simp[temp1, temp2];\n        rw[← is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have ⟨ witness, proof ⟩ := temp2;\n        simp[proof];\n        rw[proof] at partial1_1;\n        simp at partial1_1;\n        exact partial1_1;\n      }\n      case right => {\n        intro temp1 temp2;\n        simp[temp1, temp2];\n        rw[← is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have ⟨ witness, proof ⟩ := temp2;\n        simp[proof];\n        rw[proof] at partial1_1;\n        simp at partial1_1;\n        exact partial1_1;\n      }\n    }\n  }\n/-  | sepimp q1 q2 => {\n    have partial1 := partiality q1 s h_tilde;\n    have partial2 := partiality q2 s h_tilde;\n    simp[check];\n    simp[partial_of];\n    intro x;\n    simp[partial_difference];\n    simp[partial_of] at partial1;\n    have partial1_1 := partial1 x;\n    simp[partial_of] at partial2;\n    have partial2_1 := partial2 x;\n    apply Or.elim (Classical.em ((check q1 s h_tilde).2.1 x = none));\n    case left  => {\n      apply Or.elim (Classical.em ((check q2 s h_tilde).2.1 x = none));\n      case left => intro temp1 temp2; simp[temp1, temp2];\n      case right => {\n        intro temp1 temp2;\n        rw[← is_not_some] at temp1;\n        simp[dne] at temp1;\n        rw[is_some] at temp1;\n        have ⟨ witness, proof ⟩ := temp1;\n        simp[proof, temp2];\n        rw[proof] at partial2_1;\n        simp at partial2_1;\n        exact partial2_1;\n      }\n    }\n    case right => {\n      apply Or.elim (Classical.em ((check q2 s h_tilde).2.1 x = none));\n      case left  => {\n        intro temp1 temp2;\n        simp[temp1, temp2];\n        rw[← is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have ⟨ witness, proof ⟩ := temp2;\n        simp[proof];\n      }\n      case right => {\n        intro temp1 temp2;\n        simp[temp1, temp2];\n        rw[← is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have ⟨ witness, proof ⟩ := temp2;\n        simp[proof];\n      }\n    }\n  }-/\n}\n\ntheorem uniqueness :\n  (check q s h_tilde).1 ∧ tight q → ∀ h h' , (asrt q s h ∧ asrt q s h' → h = h') := by {\n    match q with\n  | literal lit => simp[asrt, tight];\n  | emp => {\n    intro ⟨ a, b ⟩ h h';\n    simp[asrt];\n    simp[is_not_some'];\n    intro ⟨ hx , h'x ⟩;\n    apply funext;\n    intro x;\n    rw[(hx x)];\n    rw[(h'x x)];\n  }\n  | singleton v1 v2 => {\n    simp[asrt];\n    intro points;\n    intro h h';\n    intro ⟨ ⟨ a , b ⟩ , c , d ⟩;\n    apply funext;\n    intro x;\n    have bx := b x;\n    have dx := d x;\n    have p := partiality q s h_tilde;\n    apply Or.elim (Classical.em (x = s v1));\n    case left  => {\n      intro xsv1;\n      simp[xsv1];\n      simp[a, c];\n    }\n    case right => {\n      intro xnsv1;\n      simp[xnsv1] at bx;\n      simp[xnsv1] at dx;\n      simp[is_not_some''] at bx;\n      simp[is_not_some''] at dx;\n      simp[bx, dx];\n    }\n  }\n  | sep q1 q2 => {\n    simp[asrt];\n    intro ⟨ ⟨ a1 , a2, a3  ⟩, b, c ⟩ h h' ⟨ ⟨ h1 , h2 , q1h1 , q2h2 , h1_disj_h2 , h_h1_h2 ⟩ , ⟨ h1' , h2' , q1h1' , q2h2' , h1_disj_h2' , h_h1_h2' ⟩ ⟩;\n    have q1_uniqueness := uniqueness (And.intro a1 b);\n    have q2_uniqueness := uniqueness (And.intro a2 c);\n    have h1_same := q1_uniqueness h1 h1' (And.intro q1h1 q1h1');\n    have h2_same := q2_uniqueness h2 h2' (And.intro q2h2 q2h2');\n    simp[h_h1_h2, h_h1_h2', h1_same, h2_same];\n  }\n  /-\n  | sepimp q1 q2 => {\n    simp;\n    sorry;\n  }-/\n}\n\ntheorem check_of_superset : (check q s h).1 ∧ h ⊆ h_tilde → (check q s h) = (check q s h_tilde) := by {\n  match q with\n  | literal lit => simp[check];\n  | emp => simp[check];\n  | singleton v1 v2 => {\n    simp[check, partial_of];\n    intro ⟨ points, subset ⟩;\n    have proof := subset (s v1);\n    simp[points] at proof;\n    simp[points, proof];\n  }\n  | sep q1 q2 => {\n    simp[check];--, partial_of];\n    intro ⟨ ⟨ a1 , a2 , a3 ⟩ , b ⟩;\n    have c1 := check_of_superset (And.intro a1 b);\n    have c2 := check_of_superset (And.intro a2 b);\n    simp[c1, c2];\n  }\n--  | sepimp q1 q2 => sorry;\n}\n\ntheorem no_false_neg : (asrt q s h) → (check q s h).1 := by {\n    match q with\n  | literal lit => simp[asrt, check]; intro; assumption;\n  | emp => simp[asrt, check];\n  | singleton v1 v2 => simp[asrt, check]; intro ⟨ a, b ⟩; exact a;\n  | sep q1 q2 => {\n    simp[asrt, check];\n    intro ⟨ h1, h2 , q1h1 , q2h2 , disjoint_h1_h2 , h_h1_h2 ⟩;\n\n    apply And.intro;\n    case left  => {\n      have q1h1_b := (no_false_neg q1h1)\n      have q1h := check_of_superset (And.intro q1h1_b (partial_of_union disjoint_h1_h2 h_h1_h2).1);\n      rw[← q1h];\n      exact q1h1_b;\n    }\n    case right => {\n      apply And.intro;\n      case left  => {\n        have q2h2_b := (no_false_neg q2h2)\n        have q2h := check_of_superset (And.intro q2h2_b (partial_of_union disjoint_h1_h2 h_h1_h2).2);\n        rw[← q2h];\n        exact q2h2_b;\n      }\n      case right => {\n        have c_q1h1_b := no_false_neg q1h1;\n        have q1_equiv := check_of_superset (And.intro c_q1h1_b (partial_of_union disjoint_h1_h2 h_h1_h2).1);\n        have subset_1 := partiality q1 s h1;\n        rw[q1_equiv] at subset_1;\n\n        have c_q2h2_b := no_false_neg q2h2;\n        have q2_equiv := check_of_superset (And.intro c_q2h2_b (partial_of_union disjoint_h1_h2 h_h1_h2).2);\n        have subset_2 := partiality q2 s h2;\n        rw[q2_equiv] at subset_2;\n\n        have temp := disjoint_partial disjoint_h1_h2 subset_1;\n        rw[disjoint_symm] at temp;\n        have temp2 := disjoint_partial temp subset_2;\n        rw[disjoint_symm] at temp2;\n        exact temp2;\n      }\n    }\n  }\n--  | sepimp q1 q2 => sorry;\n}\n\ntheorem no_false_pos : let ⟨ b, m ⟩ := (check q s h_tilde); b → asrt q s m := by {\n  match q with\n  | literal lit =>   simp[check, asrt]; intro; assumption;\n  | emp => simp[check, asrt, empty_partial];\n  | singleton v1 v2 => {\n    simp[check, asrt, singleton_partial_some, singleton_partial];\n    intro points;\n    rw[points];\n    simp;\n    intro x;\n    apply Or.elim (Classical.em (x = s v1));\n    case left  => {\n      intro x_s_v1;\n      simp[x_s_v1, Option.isSome];\n    }\n    case right => {\n      intro not_x_s_v1;\n      simp[not_x_s_v1];\n    }\n  }\n  | sep q1 q2 => {\n    simp[check, asrt];\n    intro ⟨ b1 , b2 , disjoint_m1_m2 ⟩ ;\n    apply Exists.intro (check q1 s h_tilde).2;\n    apply Exists.intro (check q2 s h_tilde).2;\n    apply And.intro (no_false_pos b1);\n    apply And.intro (no_false_pos b2);\n    apply And.intro (disjoint_m1_m2);\n    simp;\n  }\n}\n\nvariable (q : Asrt)\nvariable (s : Store)\nvariable (h_tilde : Heap)\nvariable (b : (check q s h_tilde).1)\n\ntheorem tightness {q s h_tilde} : let ⟨ b , m ⟩ := (check q s h_tilde); (b ∧ ¬ tight q) → ∀ h : Heap , m ⊆ h ∧ h ⊆ h_tilde → asrt q s h := by {\n  match q with\n  | literal lit => simp[asrt, check]; intro ⟨ _ , _ ⟩ _ _; assumption;\n  | emp => simp[asrt, check, tight];\n  | singleton v1 v2 => simp[tight];\n  | sep q1 q2 => {\n    simp[check, tight];\n    intro ⟨ ⟨ b1 , b2 , disjoint_m1_m2 ⟩ , not_both_tight ⟩ h;\n    rw [de_morgan] at not_both_tight;\n    intro ⟨ partial_m_h , partial_h_h_tilde ⟩;\n    have check_q_s_h_tilde : (check (sep q1 q2) s h_tilde).1 := And.intro b1 (And.intro b2 disjoint_m1_m2);\n    have check_q_s_m : (check (sep q1 q2) s (check (sep q1 q2) s h_tilde).2).1 := no_false_neg (no_false_pos check_q_s_h_tilde);\n    have partial_m1_h := partial_of_transitive (partial_of_union disjoint_m1_m2 rfl).left  partial_m_h;\n    have partial_m2_h := partial_of_transitive (partial_of_union disjoint_m1_m2 rfl).right partial_m_h;\n    apply Or.elim not_both_tight;\n    case left  => {\n      intro not_tight_q1;\n      apply Exists.intro (partial_difference h (check q2 s h_tilde).2);\n      apply Exists.intro (check q2 s h_tilde).2;\n      have partial_m1_diff := partial_of_disjoint_subtraction (And.intro partial_m1_h disjoint_m1_m2);\n      have b1_m1_eq_check_q1_s_diff := check_of_superset (And.intro (no_false_neg (no_false_pos b1)) partial_m1_diff);\n      apply And.intro (tightness (And.intro b1 not_tight_q1) (partial_difference h (check q2 s h_tilde).2) (And.intro partial_m1_diff (partial_of_transitive (partial_of_difference_self h (check q2 s h_tilde).2) partial_h_h_tilde)));\n      apply And.intro (no_false_pos b2);\n      apply And.intro (difference_disjoint h (check q2 s h_tilde).2);\n      exact (difference_union_opposite partial_m2_h);\n    }\n    case right => {\n      intro not_tight_q2;\n      apply Exists.intro (check q1 s h_tilde).2;\n      apply Exists.intro (partial_difference h (check q1 s h_tilde).2);\n      have partial_m2_diff := partial_of_disjoint_subtraction (And.intro partial_m2_h (disjoint_symm.mp disjoint_m1_m2));\n      have b2_m2_eq_check_q2_s_diff := check_of_superset (And.intro (no_false_neg (no_false_pos b2)) partial_m2_diff);\n      apply And.intro (no_false_pos b1);\n      apply And.intro (tightness (And.intro b2 not_tight_q2) (partial_difference h (check q1 s h_tilde).2) (And.intro partial_m2_diff (partial_of_transitive (partial_of_difference_self h (check q1 s h_tilde).2) partial_h_h_tilde)));\n      apply And.intro (disjoint_symm.mp (difference_disjoint h (check q1 s h_tilde).2));\n      exact (difference_union_opposite' partial_m1_h);\n    }\n  }\n--  | sepimp q1 q2 => False;\n}\n\ntheorem equivalence (s : Store) (h_tilde : Heap) : let ⟨ b , m ⟩ := (check q s h_tilde); asrt q s h_tilde ↔ b ∧ (tight q → h_tilde = m) := by {\n  simp;\n  apply Iff.intro;\n  case mp  => {\n    intro asrt_q_s_h_tilde;\n    have b := no_false_neg asrt_q_s_h_tilde;\n    apply And.intro b;\n    intro tight_q;\n    have uniqueness_of_heaps := uniqueness (And.intro b tight_q);\n    have asrt_q_s_m := no_false_pos b;\n    have h_tilde_equal_m := uniqueness_of_heaps h_tilde (check q s h_tilde).2 (And.intro asrt_q_s_h_tilde asrt_q_s_m);\n    exact h_tilde_equal_m;\n  }\n  case mpr => {\n    intro ⟨ b, tight_implies_h_tilde_equal_m ⟩;\n    have asrt_q_s_m := no_false_pos b;\n    apply Or.elim (Classical.em (tight q));\n    case left  => {\n      intro tight_q;\n      have h_tilde_equal_m := tight_implies_h_tilde_equal_m tight_q;\n      revert asrt_q_s_m;\n      rw[← h_tilde_equal_m];\n      intro; assumption;\n    }\n    case right => {\n      intro not_tight_q;\n      have partial_implies_asrt_q_s_h_tilde := (tightness (And.intro b not_tight_q)) h_tilde;\n      have partial_m_h_tilde := And.intro (partiality q s h_tilde) (partial_of_self h_tilde);\n      exact (partial_implies_asrt_q_s_h_tilde partial_m_h_tilde);\n    }\n  }\n}\n\n", "meta": {"author": "RosieBaish", "repo": "lean-sep-logic", "sha": "4900eadb35436b55c490c7e99e8e3a9cbc847f30", "save_path": "github-repos/lean/RosieBaish-lean-sep-logic", "path": "github-repos/lean/RosieBaish-lean-sep-logic/lean-sep-logic-4900eadb35436b55c490c7e99e8e3a9cbc847f30/SepLogic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6723317123102955, "lm_q1q2_score": 0.48735327398480144}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module linear_algebra.clifford_algebra.even_equiv\n! leanprover-community/mathlib commit 2196ab363eb097c008d4497125e0dde23fb36db2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.CliffordAlgebra.Conjugation\nimport Mathbin.LinearAlgebra.CliffordAlgebra.Even\nimport Mathbin.LinearAlgebra.QuadraticForm.Prod\n\n/-!\n# Isomorphisms with the even subalgebra of a Clifford algebra\n\nThis file provides some notable isomorphisms regarding the even subalgebra, `clifford_algebra.even`.\n\n## Main definitions\n\n* `clifford_algebra.equiv_even`: Every Clifford algebra is isomorphic as an algebra to the even\n  subalgebra of a Clifford algebra with one more dimension.\n  * `clifford_algebra.even_equiv.Q'`: The quadratic form used by this \"one-up\" algebra.\n  * `clifford_algebra.to_even`: The simp-normal form of the forward direction of this isomorphism.\n  * `clifford_algebra.of_even`: The simp-normal form of the reverse direction of this isomorphism.\n\n* `clifford_algebra.even_equiv_even_neg`: Every even subalgebra is isomorphic to the even subalgebra\n  of the Clifford algebra with negated quadratic form.\n  * `clifford_algebra.even_to_neg`: The simp-normal form of each direction of this isomorphism.\n\n## Main results\n\n* `clifford_algebra.coe_to_even_reverse_involute`: the behavior of `clifford_algebra.to_even` on the\n  \"Clifford conjugate\", that is `clifford_algebra.reverse` composed with\n  `clifford_algebra.involute`.\n-/\n\n\nnamespace CliffordAlgebra\n\nvariable {R M : Type _} [CommRing R] [AddCommGroup M] [Module R M]\n\nvariable (Q : QuadraticForm R M)\n\n/-! ### Constructions needed for `clifford_algebra.equiv_even` -/\n\n\nnamespace EquivEven\n\n/-- The quadratic form on the augmented vector space `M × R` sending `v + r•e0` to `Q v - r^2`. -/\n@[reducible]\ndef q' : QuadraticForm R (M × R) :=\n  Q.Prod <| -@QuadraticForm.sq R _\n#align clifford_algebra.equiv_even.Q' CliffordAlgebra.EquivEven.q'\n\ntheorem q'_apply (m : M × R) : q' Q m = Q m.1 - m.2 * m.2 :=\n  (sub_eq_add_neg _ _).symm\n#align clifford_algebra.equiv_even.Q'_apply CliffordAlgebra.EquivEven.q'_apply\n\n/-- The unit vector in the new dimension -/\ndef e0 : CliffordAlgebra (q' Q) :=\n  ι (q' Q) (0, 1)\n#align clifford_algebra.equiv_even.e0 CliffordAlgebra.EquivEven.e0\n\n/-- The embedding from the existing vector space -/\ndef v : M →ₗ[R] CliffordAlgebra (q' Q) :=\n  ι (q' Q) ∘ₗ LinearMap.inl _ _ _\n#align clifford_algebra.equiv_even.v CliffordAlgebra.EquivEven.v\n\ntheorem ι_eq_v_add_smul_e0 (m : M) (r : R) : ι (q' Q) (m, r) = v Q m + r • e0 Q := by\n  rw [e0, v, LinearMap.comp_apply, LinearMap.inl_apply, ← LinearMap.map_smul, Prod.smul_mk,\n    smul_zero, smul_eq_mul, mul_one, ← LinearMap.map_add, Prod.mk_add_mk, zero_add, add_zero]\n#align clifford_algebra.equiv_even.ι_eq_v_add_smul_e0 CliffordAlgebra.EquivEven.ι_eq_v_add_smul_e0\n\ntheorem e0_mul_e0 : e0 Q * e0 Q = -1 :=\n  (ι_sq_scalar _ _).trans <| by simp\n#align clifford_algebra.equiv_even.e0_mul_e0 CliffordAlgebra.EquivEven.e0_mul_e0\n\ntheorem v_sq_scalar (m : M) : v Q m * v Q m = algebraMap _ _ (Q m) :=\n  (ι_sq_scalar _ _).trans <| by simp\n#align clifford_algebra.equiv_even.v_sq_scalar CliffordAlgebra.EquivEven.v_sq_scalar\n\ntheorem neg_e0_mul_v (m : M) : -(e0 Q * v Q m) = v Q m * e0 Q :=\n  by\n  refine' neg_eq_of_add_eq_zero_right ((ι_mul_ι_add_swap _ _).trans _)\n  dsimp [QuadraticForm.polar]\n  simp only [add_zero, MulZeroClass.mul_zero, mul_one, zero_add, neg_zero, QuadraticForm.map_zero,\n    add_sub_cancel, sub_self, map_zero, zero_sub]\n#align clifford_algebra.equiv_even.neg_e0_mul_v CliffordAlgebra.EquivEven.neg_e0_mul_v\n\ntheorem neg_v_mul_e0 (m : M) : -(v Q m * e0 Q) = e0 Q * v Q m :=\n  by\n  rw [neg_eq_iff_eq_neg]\n  exact (neg_e0_mul_v _ m).symm\n#align clifford_algebra.equiv_even.neg_v_mul_e0 CliffordAlgebra.EquivEven.neg_v_mul_e0\n\n@[simp]\ntheorem e0_mul_v_mul_e0 (m : M) : e0 Q * v Q m * e0 Q = v Q m := by\n  rw [← neg_v_mul_e0, ← neg_mul, mul_assoc, e0_mul_e0, mul_neg_one, neg_neg]\n#align clifford_algebra.equiv_even.e0_mul_v_mul_e0 CliffordAlgebra.EquivEven.e0_mul_v_mul_e0\n\n@[simp]\ntheorem reverse_v (m : M) : reverse (v Q m) = v Q m :=\n  reverse_ι _\n#align clifford_algebra.equiv_even.reverse_v CliffordAlgebra.EquivEven.reverse_v\n\n@[simp]\ntheorem involute_v (m : M) : involute (v Q m) = -v Q m :=\n  involute_ι _\n#align clifford_algebra.equiv_even.involute_v CliffordAlgebra.EquivEven.involute_v\n\n@[simp]\ntheorem reverse_e0 : reverse (e0 Q) = e0 Q :=\n  reverse_ι _\n#align clifford_algebra.equiv_even.reverse_e0 CliffordAlgebra.EquivEven.reverse_e0\n\n@[simp]\ntheorem involute_e0 : involute (e0 Q) = -e0 Q :=\n  involute_ι _\n#align clifford_algebra.equiv_even.involute_e0 CliffordAlgebra.EquivEven.involute_e0\n\nend EquivEven\n\nopen EquivEven\n\n/-- The embedding from the smaller algebra into the new larger one. -/\ndef toEven : CliffordAlgebra Q →ₐ[R] CliffordAlgebra.even (q' Q) :=\n  by\n  refine' CliffordAlgebra.lift Q ⟨_, fun m => _⟩\n  · refine' LinearMap.codRestrict _ _ fun m => Submodule.mem_supᵢ_of_mem ⟨2, rfl⟩ _\n    exact (LinearMap.mulLeft R <| e0 Q).comp (v Q)\n    rw [Subtype.coe_mk, pow_two]\n    exact Submodule.mul_mem_mul (LinearMap.mem_range_self _ _) (LinearMap.mem_range_self _ _)\n  · ext1\n    dsimp only [Subalgebra.coe_mul, LinearMap.codRestrict_apply, LinearMap.comp_apply,\n      LinearMap.mulLeft_apply, LinearMap.inl_apply, Subalgebra.coe_algebraMap]\n    rw [← mul_assoc, e0_mul_v_mul_e0, v_sq_scalar]\n#align clifford_algebra.to_even CliffordAlgebra.toEven\n\n@[simp]\ntheorem toEven_ι (m : M) : (toEven Q (ι Q m) : CliffordAlgebra (q' Q)) = e0 Q * v Q m :=\n  by\n  rw [to_even, CliffordAlgebra.lift_ι_apply, LinearMap.codRestrict_apply]\n  rfl\n#align clifford_algebra.to_even_ι CliffordAlgebra.toEven_ι\n\n/-- The embedding from the even subalgebra with an extra dimension into the original algebra. -/\ndef ofEven : CliffordAlgebra.even (q' Q) →ₐ[R] CliffordAlgebra Q :=\n  by\n  /-\n    Recall that we need:\n     * `f ⟨0,1⟩ ⟨x,0⟩ = ι x`\n     * `f ⟨x,0⟩ ⟨0,1⟩ = -ι x`\n     * `f ⟨x,0⟩ ⟨y,0⟩ = ι x * ι y`\n     * `f ⟨0,1⟩ ⟨0,1⟩ = -1`\n    -/\n  let f : M × R →ₗ[R] M × R →ₗ[R] CliffordAlgebra Q :=\n    ((LinearMap.Algebra.lmul R (CliffordAlgebra Q)).toLinearMap.comp <|\n          (ι Q).comp (LinearMap.fst _ _ _) +\n            (Algebra.linearMap R _).comp (LinearMap.snd _ _ _)).compl₂\n      ((ι Q).comp (LinearMap.fst _ _ _) - (Algebra.linearMap R _).comp (LinearMap.snd _ _ _))\n  have f_apply : ∀ x y, f x y = (ι Q x.1 + algebraMap R _ x.2) * (ι Q y.1 - algebraMap R _ y.2) :=\n    fun x y => rfl\n  have hc : ∀ (r : R) (x : CliffordAlgebra Q), Commute (algebraMap _ _ r) x := Algebra.commutes\n  have hm :\n    ∀ m : M × R,\n      ι Q m.1 * ι Q m.1 - algebraMap R _ m.2 * algebraMap R _ m.2 = algebraMap R _ (Q' Q m) :=\n    by\n    intro m\n    rw [ι_sq_scalar, ← RingHom.map_mul, ← RingHom.map_sub, sub_eq_add_neg, Q'_apply, sub_eq_add_neg]\n  refine' even.lift (Q' Q) ⟨f, _, _⟩ <;> simp_rw [f_apply]\n  · intro m\n    rw [← (hc _ _).symm.mul_self_sub_mul_self_eq, hm]\n  · intro m₁ m₂ m₃\n    rw [← mul_smul_comm, ← mul_assoc, mul_assoc (_ + _), ← (hc _ _).symm.mul_self_sub_mul_self_eq',\n      Algebra.smul_def, ← mul_assoc, hm]\n#align clifford_algebra.of_even CliffordAlgebra.ofEven\n\ntheorem ofEven_ι (x y : M × R) :\n    ofEven Q ((even.ι _).bilin x y) =\n      (ι Q x.1 + algebraMap R _ x.2) * (ι Q y.1 - algebraMap R _ y.2) :=\n  even.lift_ι _ _ _ _\n#align clifford_algebra.of_even_ι CliffordAlgebra.ofEven_ι\n\ntheorem toEven_comp_ofEven : (toEven Q).comp (ofEven Q) = AlgHom.id R _ :=\n  even.algHom_ext (q' Q) <|\n    EvenHom.ext _ _ <|\n      LinearMap.ext fun m₁ =>\n        LinearMap.ext fun m₂ =>\n          Subtype.ext <|\n            let ⟨m₁, r₁⟩ := m₁\n            let ⟨m₂, r₂⟩ := m₂\n            calc\n              ↑(toEven Q (ofEven Q ((even.ι (q' Q)).bilin (m₁, r₁) (m₂, r₂)))) =\n                  (e0 Q * v Q m₁ + algebraMap R _ r₁) * (e0 Q * v Q m₂ - algebraMap R _ r₂) :=\n                by\n                rw [of_even_ι, AlgHom.map_mul, AlgHom.map_add, AlgHom.map_sub, AlgHom.commutes,\n                  AlgHom.commutes, Subalgebra.coe_mul, Subalgebra.coe_add, Subalgebra.coe_sub,\n                  to_even_ι, to_even_ι, Subalgebra.coe_algebraMap, Subalgebra.coe_algebraMap]\n              _ =\n                  e0 Q * v Q m₁ * (e0 Q * v Q m₂) + r₁ • e0 Q * v Q m₂ - r₂ • e0 Q * v Q m₁ -\n                    algebraMap R _ (r₁ * r₂) :=\n                by\n                rw [mul_sub, add_mul, add_mul, ← Algebra.commutes, ← Algebra.smul_def, ← map_mul, ←\n                  Algebra.smul_def, sub_add_eq_sub_sub, smul_mul_assoc, smul_mul_assoc]\n              _ =\n                  v Q m₁ * v Q m₂ + r₁ • e0 Q * v Q m₂ + v Q m₁ * r₂ • e0 Q +\n                    r₁ • e0 Q * r₂ • e0 Q :=\n                by\n                have h1 : e0 Q * v Q m₁ * (e0 Q * v Q m₂) = v Q m₁ * v Q m₂ := by\n                  rw [← mul_assoc, e0_mul_v_mul_e0]\n                have h2 : -(r₂ • e0 Q * v Q m₁) = v Q m₁ * r₂ • e0 Q := by\n                  rw [mul_smul_comm, smul_mul_assoc, ← smul_neg, neg_e0_mul_v]\n                have h3 : -algebraMap R _ (r₁ * r₂) = r₁ • e0 Q * r₂ • e0 Q := by\n                  rw [Algebra.algebraMap_eq_smul_one, smul_mul_smul, e0_mul_e0, smul_neg]\n                rw [sub_eq_add_neg, sub_eq_add_neg, h1, h2, h3]\n              _ = ι _ (m₁, r₁) * ι _ (m₂, r₂) := by\n                rw [ι_eq_v_add_smul_e0, ι_eq_v_add_smul_e0, mul_add, add_mul, add_mul, add_assoc]\n              \n#align clifford_algebra.to_even_comp_of_even CliffordAlgebra.toEven_comp_ofEven\n\ntheorem ofEven_comp_toEven : (ofEven Q).comp (toEven Q) = AlgHom.id R _ :=\n  CliffordAlgebra.hom_ext <|\n    LinearMap.ext fun m =>\n      calc\n        ofEven Q (toEven Q (ι Q m)) = ofEven Q ⟨_, (toEven Q (ι Q m)).Prop⟩ := by\n          rw [Subtype.coe_eta]\n        _ = (ι Q 0 + algebraMap R _ 1) * (ι Q m - algebraMap R _ 0) :=\n          by\n          simp_rw [to_even_ι]\n          exact of_even_ι Q _ _\n        _ = ι Q m := by rw [map_one, map_zero, map_zero, sub_zero, zero_add, one_mul]\n        \n#align clifford_algebra.of_even_comp_to_even CliffordAlgebra.ofEven_comp_toEven\n\n/-- Any clifford algebra is isomorphic to the even subalgebra of a clifford algebra with an extra\ndimension (that is, with vector space `M × R`), with a quadratic form evaluating to `-1` on that new\nbasis vector. -/\n@[simps]\ndef equivEven : CliffordAlgebra Q ≃ₐ[R] CliffordAlgebra.even (q' Q) :=\n  AlgEquiv.ofAlgHom (toEven Q) (ofEven Q) (toEven_comp_ofEven Q) (ofEven_comp_toEven Q)\n#align clifford_algebra.equiv_even CliffordAlgebra.equivEven\n\n/-- The representation of the clifford conjugate (i.e. the reverse of the involute) in the even\nsubalgebra is just the reverse of the representation. -/\ntheorem coe_toEven_reverse_involute (x : CliffordAlgebra Q) :\n    ↑(toEven Q (reverse (involute x))) = reverse (toEven Q x : CliffordAlgebra (q' Q)) :=\n  by\n  induction x using CliffordAlgebra.induction\n  case h_grade0 r => simp only [AlgHom.commutes, Subalgebra.coe_algebraMap, reverse.commutes]\n  case h_grade1 m =>\n    simp only [involute_ι, Subalgebra.coe_neg, to_even_ι, reverse.map_mul, reverse_v, reverse_e0,\n      reverse_ι, neg_e0_mul_v, map_neg]\n  case h_mul x y hx hy => simp only [map_mul, Subalgebra.coe_mul, reverse.map_mul, hx, hy]\n  case h_add x y hx hy => simp only [map_add, Subalgebra.coe_add, hx, hy]\n#align clifford_algebra.coe_to_even_reverse_involute CliffordAlgebra.coe_toEven_reverse_involute\n\n/-! ### Constructions needed for `clifford_algebra.even_equiv_even_neg` -/\n\n\n/-- One direction of `clifford_algebra.even_equiv_even_neg` -/\ndef evenToNeg (Q' : QuadraticForm R M) (h : Q' = -Q) :\n    CliffordAlgebra.even Q →ₐ[R] CliffordAlgebra.even Q' :=\n  even.lift Q\n    { bilin := -(even.ι Q' : _).bilin\n      contract := fun m => by\n        simp_rw [LinearMap.neg_apply, even_hom.contract, h, QuadraticForm.neg_apply, map_neg,\n          neg_neg]\n      contract_mid := fun m₁ m₂ m₃ => by\n        simp_rw [LinearMap.neg_apply, neg_mul_neg, even_hom.contract_mid, h,\n          QuadraticForm.neg_apply, smul_neg, neg_smul] }\n#align clifford_algebra.even_to_neg CliffordAlgebra.evenToNeg\n\n@[simp]\ntheorem evenToNeg_ι (Q' : QuadraticForm R M) (h : Q' = -Q) (m₁ m₂ : M) :\n    evenToNeg Q Q' h ((even.ι Q).bilin m₁ m₂) = -(even.ι Q').bilin m₁ m₂ :=\n  even.lift_ι _ _ m₁ m₂\n#align clifford_algebra.even_to_neg_ι CliffordAlgebra.evenToNeg_ι\n\ntheorem evenToNeg_comp_evenToNeg (Q' : QuadraticForm R M) (h : Q' = -Q) (h' : Q = -Q') :\n    (evenToNeg Q' Q h').comp (evenToNeg Q Q' h) = AlgHom.id R _ :=\n  by\n  ext (m₁ m₂) : 4\n  dsimp only [even_hom.compr₂_bilin, LinearMap.compr₂_apply, AlgHom.toLinearMap_apply,\n    AlgHom.comp_apply, AlgHom.id_apply]\n  rw [even_to_neg_ι, map_neg, even_to_neg_ι, neg_neg]\n#align clifford_algebra.even_to_neg_comp_even_to_neg CliffordAlgebra.evenToNeg_comp_evenToNeg\n\n/-- The even subalgebras of the algebras with quadratic form `Q` and `-Q` are isomorphic.\n\nStated another way, `𝒞ℓ⁺(p,q,r)` and `𝒞ℓ⁺(q,p,r)` are isomorphic. -/\n@[simps]\ndef evenEquivEvenNeg : CliffordAlgebra.even Q ≃ₐ[R] CliffordAlgebra.even (-Q) :=\n  AlgEquiv.ofAlgHom (evenToNeg Q _ rfl) (evenToNeg (-Q) _ (neg_neg _).symm)\n    (evenToNeg_comp_evenToNeg _ _ _ _) (evenToNeg_comp_evenToNeg _ _ _ _)\n#align clifford_algebra.even_equiv_even_neg CliffordAlgebra.evenEquivEvenNeg\n\nend CliffordAlgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6723317123102955, "lm_q1q2_score": 0.48735327398480144}}
{"text": "\nimport Lib.Tactic\n\nnamespace Decidable\n\nvariable {P Q} [Hdec : Decidable P]\nvariable (h : P ↔ Q)\n\ndef congr : Decidable Q :=\nmatch Hdec with\n| isTrue hp => isTrue <| h.mp hp\n| isFalse hnp => isFalse <| mt h.mpr hnp\n\nend Decidable\n\n\nnamespace Classical\n\ntheorem iff_iff_and_or_and {p q} :\n  (p ↔ q) ↔ (p ∧ q) ∨ (¬ p ∧ ¬ q) := by\nconstructor <;> intros h\n. simp [h, and_self, Classical.em]\n. cases h <;> auto\n\n@[simp]\ntheorem not_exists (p : α → Prop) :\n  ¬ (∃ x, p x) ↔ ∀ x, ¬ p x := by\nconstructor <;> intros h\nnext =>\n  intros x Hp\n  apply h; clear h\n  exists x\nnext =>\n  intros h'\n  cases h' with | intro y h' =>\n  apply (h _ h')\n\n@[simp low]\ntheorem not_forall (p : α → Prop) :\n  ¬ (∀ x, p x) ↔ ∃ x, ¬ p x := by\nconstructor <;> intros h\nnext =>\n  apply byContradiction; intros h₀\n  apply h; clear h; intro x\n  apply byContradiction; intros h₁\n  apply h₀; clear h₀\n  exists x\nnext =>\n  intros h₀\n  cases h with | intro x h =>\n  apply h; clear h\n  apply h₀\n\n@[simp mid]\ntheorem not_implies {p q : Prop} :\n  ¬ (p → q) ↔ p ∧ ¬ q := by\nrw [not_forall]\nconstructor <;> intros h <;> cases h\n<;> constructor <;> assumption\n\n@[simp]\ntheorem not_not (p : Prop) : ¬ ¬ p ↔ p := by\nconstructor <;> intros h\nnext =>\n  apply byContradiction; intro h'\n  apply (h h')\nnext =>\n  intros h'\n  apply h' h\n\n@[simp]\ntheorem not_iff_not (p q : Prop) :\n  (¬ p ↔ ¬ q) ↔ (p ↔ q) := by\nconstructor <;> intros h\nfocus\n  rw [← not_not p, h, not_not]\n  apply Iff.refl\nfocus\n  rw [h]\n  apply Iff.refl\n\n@[simp]\ntheorem not_or (p q : Prop) : ¬ (p ∨ q) ↔ ¬ p ∧ ¬ q := by\nconstructor\nfocus\n  intros h₀; constructor <;>\n    intros h₁ <;>\n    apply h₀\n  { left; assumption }\n  { right; assumption }\nfocus\n  intros h hpq; cases h with | intro hp hq =>\n  cases hpq <;> contradiction\n\n@[simp]\ntheorem not_and (p q : Prop) : ¬ (p ∧ q) ↔ ¬ p ∨ ¬ q := by\nrw [← not_iff_not, not_or]\nrepeat rw [not_not]\napply Iff.refl\n\ntheorem not_and_iff_implies (p q : Prop) : ¬ (p ∧ q) ↔ p → ¬ q := by\nrw [not_and]\nby_cases h : p <;>\nsimp only [h, false_or, true_or, true_implies, false_implies, iff_self]\n\ntheorem not_implies_self_implies :\n  (¬ p → p) → p := by\nby_cases h : p <;> auto\n\nmacro \"negate_goal \" h:ident : tactic =>\n  `(apply not_implies_self_implies; intro $h)\n\nend Classical\n", "meta": {"author": "cipher1024", "repo": "lean4-prog", "sha": "49f7416ee19df921bfea1b4914404b9d07619d64", "save_path": "github-repos/lean/cipher1024-lean4-prog", "path": "github-repos/lean/cipher1024-lean4-prog/lean4-prog-49f7416ee19df921bfea1b4914404b9d07619d64/lib/lib/Logic/Classical.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4873532692256622}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.functor\n\n/-!\n# Isomorphisms\n\nThis file defines isomorphisms between objects of a category.\n\n## Main definitions\n\n- `structure iso` : a bundled isomorphism between two objects of a category;\n- `class is_iso` : an unbundled version of `iso`;\n  note that `is_iso f` is a `Prop`, and only asserts the existence of an inverse.\n  Of course, this inverse is unique, so it doesn't cost us much to use choice to retrieve it.\n- `inv f`, for the inverse of a morphism with `[is_iso f]`\n- `as_iso` : convert from `is_iso` to `iso` (noncomputable);\n- `of_iso` : convert from `iso` to `is_iso`;\n- standard operations on isomorphisms (composition, inverse etc)\n\n## Notations\n\n- `X ≅ Y` : same as `iso X Y`;\n- `α ≪≫ β` : composition of two isomorphisms; it is called `iso.trans`\n\n## Tags\n\ncategory, category theory, isomorphism\n-/\n\nuniverses v u -- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen category\n\n/--\nAn isomorphism (a.k.a. an invertible morphism) between two objects of a category.\nThe inverse morphism is bundled.\n\nSee also `category_theory.core` for the category with the same objects and isomorphisms playing\nthe role of morphisms.\n\nSee https://stacks.math.columbia.edu/tag/0017.\n-/\nstructure iso {C : Type u} [category.{v} C] (X Y : C) :=\n(hom : X ⟶ Y)\n(inv : Y ⟶ X)\n(hom_inv_id' : hom ≫ inv = 𝟙 X . obviously)\n(inv_hom_id' : inv ≫ hom = 𝟙 Y . obviously)\n\nrestate_axiom iso.hom_inv_id'\nrestate_axiom iso.inv_hom_id'\nattribute [simp, reassoc] iso.hom_inv_id iso.inv_hom_id\n\ninfixr ` ≅ `:10  := iso             -- type as \\cong or \\iso\n\nvariables {C : Type u} [category.{v} C]\nvariables {X Y Z : C}\n\nnamespace iso\n\n@[ext] lemma ext ⦃α β : X ≅ Y⦄ (w : α.hom = β.hom) : α = β :=\nsuffices α.inv = β.inv, by cases α; cases β; cc,\ncalc α.inv\n    = α.inv ≫ (β.hom ≫ β.inv) : by rw [iso.hom_inv_id, category.comp_id]\n... = (α.inv ≫ α.hom) ≫ β.inv : by rw [category.assoc, ←w]\n... = β.inv                   : by rw [iso.inv_hom_id, category.id_comp]\n\n/-- Inverse isomorphism. -/\n@[symm] def symm (I : X ≅ Y) : Y ≅ X :=\n{ hom := I.inv,\n  inv := I.hom,\n  hom_inv_id' := I.inv_hom_id',\n  inv_hom_id' := I.hom_inv_id' }\n\n@[simp] lemma symm_hom (α : X ≅ Y) : α.symm.hom = α.inv := rfl\n@[simp] lemma symm_inv (α : X ≅ Y) : α.symm.inv = α.hom := rfl\n\n@[simp] lemma symm_mk {X Y : C} (hom : X ⟶ Y) (inv : Y ⟶ X) (hom_inv_id) (inv_hom_id) :\n  iso.symm {hom := hom, inv := inv, hom_inv_id' := hom_inv_id, inv_hom_id' := inv_hom_id} =\n    {hom := inv, inv := hom, hom_inv_id' := inv_hom_id, inv_hom_id' := hom_inv_id} := rfl\n\n@[simp] lemma symm_symm_eq {X Y : C} (α : X ≅ Y) : α.symm.symm = α :=\nby cases α; refl\n\n@[simp] lemma symm_eq_iff {X Y : C} {α β : X ≅ Y} : α.symm = β.symm ↔ α = β :=\n⟨λ h, symm_symm_eq α ▸ symm_symm_eq β ▸ congr_arg symm h, congr_arg symm⟩\n\n/-- Identity isomorphism. -/\n@[refl, simps] def refl (X : C) : X ≅ X :=\n{ hom := 𝟙 X,\n  inv := 𝟙 X }\n\ninstance : inhabited (X ≅ X) := ⟨iso.refl X⟩\n\n@[simp] lemma refl_symm (X : C) : (iso.refl X).symm = iso.refl X := rfl\n\n/-- Composition of two isomorphisms -/\n@[trans, simps] def trans (α : X ≅ Y) (β : Y ≅ Z) : X ≅ Z :=\n{ hom := α.hom ≫ β.hom,\n  inv := β.inv ≫ α.inv }\n\ninfixr ` ≪≫ `:80 := iso.trans -- type as `\\ll \\gg`.\n\n@[simp] lemma trans_mk {X Y Z : C}\n  (hom : X ⟶ Y) (inv : Y ⟶ X) (hom_inv_id) (inv_hom_id)\n  (hom' : Y ⟶ Z) (inv' : Z ⟶ Y) (hom_inv_id') (inv_hom_id') (hom_inv_id'') (inv_hom_id'') :\n  iso.trans\n    {hom := hom, inv := inv, hom_inv_id' := hom_inv_id, inv_hom_id' := inv_hom_id}\n    {hom := hom', inv := inv', hom_inv_id' := hom_inv_id', inv_hom_id' := inv_hom_id'} =\n  { hom := hom ≫ hom', inv := inv' ≫ inv, hom_inv_id' := hom_inv_id'',\n    inv_hom_id' := inv_hom_id''} :=\nrfl\n\n@[simp] lemma trans_symm (α : X ≅ Y) (β : Y ≅ Z) : (α ≪≫ β).symm = β.symm ≪≫ α.symm := rfl\n@[simp] lemma trans_assoc {Z' : C} (α : X ≅ Y) (β : Y ≅ Z) (γ : Z ≅ Z') :\n  (α ≪≫ β) ≪≫ γ = α ≪≫ β ≪≫ γ :=\nby ext; simp only [trans_hom, category.assoc]\n\n@[simp] lemma refl_trans (α : X ≅ Y) : (iso.refl X) ≪≫ α = α := by ext; apply category.id_comp\n@[simp] lemma trans_refl (α : X ≅ Y) : α ≪≫ (iso.refl Y) = α := by ext; apply category.comp_id\n\n@[simp] lemma symm_self_id (α : X ≅ Y) : α.symm ≪≫ α = iso.refl Y := ext α.inv_hom_id\n@[simp] lemma self_symm_id (α : X ≅ Y) : α ≪≫ α.symm = iso.refl X := ext α.hom_inv_id\n\n@[simp] lemma symm_self_id_assoc (α : X ≅ Y) (β : Y ≅ Z) : α.symm ≪≫ α ≪≫ β = β :=\nby rw [← trans_assoc, symm_self_id, refl_trans]\n\n@[simp] lemma self_symm_id_assoc (α : X ≅ Y) (β : X ≅ Z) : α ≪≫ α.symm ≪≫ β = β :=\nby rw [← trans_assoc, self_symm_id, refl_trans]\n\nlemma inv_comp_eq (α : X ≅ Y) {f : X ⟶ Z} {g : Y ⟶ Z} : α.inv ≫ f = g ↔ f = α.hom ≫ g :=\n⟨λ H, by simp [H.symm], λ H, by simp [H]⟩\n\nlemma eq_inv_comp (α : X ≅ Y) {f : X ⟶ Z} {g : Y ⟶ Z} : g = α.inv ≫ f ↔ α.hom ≫ g = f :=\n(inv_comp_eq α.symm).symm\n\nlemma comp_inv_eq (α : X ≅ Y) {f : Z ⟶ Y} {g : Z ⟶ X} : f ≫ α.inv = g ↔ f = g ≫ α.hom :=\n⟨λ H, by simp [H.symm], λ H, by simp [H]⟩\n\nlemma eq_comp_inv (α : X ≅ Y) {f : Z ⟶ Y} {g : Z ⟶ X} : g = f ≫ α.inv ↔ g ≫ α.hom = f :=\n(comp_inv_eq α.symm).symm\n\nlemma inv_eq_inv (f g : X ≅ Y) : f.inv = g.inv ↔ f.hom = g.hom :=\nhave ∀{X Y : C} (f g : X ≅ Y), f.hom = g.hom → f.inv = g.inv, from λ X Y f g h, by rw [ext h],\n⟨this f.symm g.symm, this f g⟩\n\nlemma hom_comp_eq_id (α : X ≅ Y) {f : Y ⟶ X} : α.hom ≫ f = 𝟙 X ↔ f = α.inv :=\nby rw [←eq_inv_comp, comp_id]\n\nlemma comp_hom_eq_id (α : X ≅ Y) {f : Y ⟶ X} : f ≫ α.hom = 𝟙 Y ↔ f = α.inv :=\nby rw [←eq_comp_inv, id_comp]\n\nlemma hom_eq_inv (α : X ≅ Y) (β : Y ≅ X) : α.hom = β.inv ↔ β.hom = α.inv :=\nby { erw [inv_eq_inv α.symm β, eq_comm], refl }\n\nend iso\n\n/-- `is_iso` typeclass expressing that a morphism is invertible. -/\nclass is_iso (f : X ⟶ Y) : Prop :=\n(out : ∃ inv : Y ⟶ X, f ≫ inv = 𝟙 X ∧ inv ≫ f = 𝟙 Y)\n\n/--\nThe inverse of a morphism `f` when we have `[is_iso f]`.\n-/\nnoncomputable def inv (f : X ⟶ Y) [I : is_iso f] := classical.some I.1\n\nnamespace is_iso\n\n@[simp, reassoc] lemma hom_inv_id (f : X ⟶ Y) [I : is_iso f] : f ≫ inv f = 𝟙 X :=\n(classical.some_spec I.1).left\n@[simp, reassoc] lemma inv_hom_id (f : X ⟶ Y) [I : is_iso f] : inv f ≫ f = 𝟙 Y :=\n(classical.some_spec I.1).right\n\nend is_iso\n\nopen is_iso\n\n/-- Reinterpret a morphism `f` with an `is_iso f` instance as an `iso`. -/\nnoncomputable\ndef as_iso (f : X ⟶ Y) [h : is_iso f] : X ≅ Y := ⟨f, inv f, hom_inv_id f, inv_hom_id f⟩\n\n@[simp] lemma as_iso_hom (f : X ⟶ Y) [is_iso f] : (as_iso f).hom = f := rfl\n@[simp] lemma as_iso_inv (f : X ⟶ Y) [is_iso f] : (as_iso f).inv = inv f := rfl\n\nnamespace is_iso\n\n@[priority 100] -- see Note [lower instance priority]\ninstance epi_of_iso (f : X ⟶ Y) [is_iso f] : epi f  :=\n{ left_cancellation := λ Z g h w,\n  -- This is an interesting test case for better rewrite automation.\n  by rw [← is_iso.inv_hom_id_assoc f g, w, is_iso.inv_hom_id_assoc f h] }\n@[priority 100] -- see Note [lower instance priority]\ninstance mono_of_iso (f : X ⟶ Y) [is_iso f] : mono f :=\n{ right_cancellation := λ Z g h w,\n  by rw [← category.comp_id g, ← category.comp_id h, ← is_iso.hom_inv_id f, ← category.assoc, w,\n    ← category.assoc] }\n\n@[ext] lemma inv_eq_of_hom_inv_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (hom_inv_id : f ≫ g = 𝟙 X) : inv f = g :=\nbegin\n  apply (cancel_epi f).mp,\n  simp [hom_inv_id],\nend\n\nlemma inv_eq_of_inv_hom_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (inv_hom_id : g ≫ f = 𝟙 Y) : inv f = g :=\nbegin\n  apply (cancel_mono f).mp,\n  simp [inv_hom_id],\nend\n\n@[ext] lemma eq_inv_of_hom_inv_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (hom_inv_id : f ≫ g = 𝟙 X) : g = inv f :=\n(inv_eq_of_hom_inv_id hom_inv_id).symm\n\nlemma eq_inv_of_inv_hom_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (inv_hom_id : g ≫ f = 𝟙 Y) : g = inv f :=\n(inv_eq_of_inv_hom_id inv_hom_id).symm\n\n\ninstance id (X : C) : is_iso (𝟙 X) :=\n⟨⟨𝟙 X, by simp⟩⟩\n\ninstance of_iso (f : X ≅ Y) : is_iso f.hom :=\n⟨⟨f.inv, by simp⟩⟩\n\ninstance of_iso_inv (f : X ≅ Y) : is_iso f.inv :=\nis_iso.of_iso f.symm\n\nvariables {f g : X ⟶ Y} {h : Y ⟶ Z}\n\ninstance inv_is_iso [is_iso f] : is_iso (inv f) :=\nis_iso.of_iso_inv (as_iso f)\n\ninstance comp_is_iso [is_iso f] [is_iso h] : is_iso (f ≫ h) :=\nis_iso.of_iso $ (as_iso f) ≪≫ (as_iso h)\n\n@[simp] lemma inv_id : inv (𝟙 X) = 𝟙 X := by { ext, simp, }\n@[simp] lemma inv_comp [is_iso f] [is_iso h] : inv (f ≫ h) = inv h ≫ inv f := by { ext, simp, }\n@[simp] lemma inv_inv [is_iso f] : inv (inv f) = f := by { ext, simp, }\n@[simp] lemma iso.inv_inv (f : X ≅ Y) : inv (f.inv) = f.hom := by { ext, simp, }\n@[simp] lemma iso.inv_hom (f : X ≅ Y) : inv (f.hom) = f.inv := by { ext, simp, }\n\n@[simp]\nlemma inv_comp_eq (α : X ⟶ Y) [is_iso α] {f : X ⟶ Z} {g : Y ⟶ Z} : inv α ≫ f = g ↔ f = α ≫ g :=\n(as_iso α).inv_comp_eq\n\n@[simp]\nlemma eq_inv_comp (α : X ⟶ Y) [is_iso α] {f : X ⟶ Z} {g : Y ⟶ Z} : g = inv α ≫ f ↔ α ≫ g = f :=\n(as_iso α).eq_inv_comp\n\n@[simp]\nlemma comp_inv_eq (α : X ⟶ Y) [is_iso α] {f : Z ⟶ Y} {g : Z ⟶ X} : f ≫ inv α = g ↔ f = g ≫ α :=\n(as_iso α).comp_inv_eq\n\n@[simp]\nlemma eq_comp_inv (α : X ⟶ Y) [is_iso α] {f : Z ⟶ Y} {g : Z ⟶ X} : g = f ≫ inv α ↔ g ≫ α = f :=\n(as_iso α).eq_comp_inv\n\nend is_iso\n\nopen is_iso\n\nlemma eq_of_inv_eq_inv {f g : X ⟶ Y} [is_iso f] [is_iso g] (p : inv f = inv g) : f = g :=\nbegin\n  apply (cancel_epi (inv f)).1,\n  erw [inv_hom_id, p, inv_hom_id],\nend\n\nlemma is_iso.inv_eq_inv {f g : X ⟶ Y} [is_iso f] [is_iso g] : inv f = inv g ↔ f = g :=\niso.inv_eq_inv (as_iso f) (as_iso g)\n\nlemma hom_comp_eq_id (g : X ⟶ Y) [is_iso g] {f : Y ⟶ X} : g ≫ f = 𝟙 X ↔ f = inv g :=\n(as_iso g).hom_comp_eq_id\n\nlemma comp_hom_eq_id (g : X ⟶ Y) [is_iso g] {f : Y ⟶ X} : f ≫ g = 𝟙 Y ↔ f = inv g :=\n(as_iso g).comp_hom_eq_id\n\nnamespace iso\n\n@[ext] lemma inv_ext {f : X ≅ Y} {g : Y ⟶ X}\n  (hom_inv_id : f.hom ≫ g = 𝟙 X) : f.inv = g :=\nbegin\n  apply (cancel_epi f.hom).mp,\n  simp [hom_inv_id],\nend\n\n@[ext] lemma inv_ext' {f : X ≅ Y} {g : Y ⟶ X}\n  (hom_inv_id : f.hom ≫ g = 𝟙 X) : g = f.inv :=\nby { symmetry, ext, assumption, }\n\n/-!\nAll these cancellation lemmas can be solved by `simp [cancel_mono]` (or `simp [cancel_epi]`),\nbut with the current design `cancel_mono` is not a good `simp` lemma,\nbecause it generates a typeclass search.\n\nWhen we can see syntactically that a morphism is a `mono` or an `epi`\nbecause it came from an isomorphism, it's fine to do the cancellation via `simp`.\n\nIn the longer term, it might be worth exploring making `mono` and `epi` structures,\nrather than typeclasses, with coercions back to `X ⟶ Y`.\nPresumably we could write `X ↪ Y` and `X ↠ Y`.\n-/\n\n@[simp] lemma cancel_iso_hom_left {X Y Z : C} (f : X ≅ Y) (g g' : Y ⟶ Z) :\n  f.hom ≫ g = f.hom ≫ g' ↔ g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_inv_left {X Y Z : C} (f : Y ≅ X) (g g' : Y ⟶ Z) :\n  f.inv ≫ g = f.inv ≫ g' ↔ g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_hom_right {X Y Z : C} (f f' : X ⟶ Y) (g : Y ≅ Z) :\n  f ≫ g.hom = f' ≫ g.hom ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right {X Y Z : C} (f f' : X ⟶ Y) (g : Z ≅ Y) :\n  f ≫ g.inv = f' ≫ g.inv ↔ f = f' :=\nby simp only [cancel_mono]\n\n/-\nUnfortunately cancelling an isomorphism from the right of a chain of compositions is awkward.\nWe would need separate lemmas for each chain length (worse: for each pair of chain lengths).\n\nWe provide two more lemmas, for case of three morphisms, because this actually comes up in practice,\nbut then stop.\n-/\n\n@[simp] lemma cancel_iso_hom_right_assoc {W X X' Y Z : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y)\n  (h : Y ≅ Z) :\n  f ≫ g ≫ h.hom = f' ≫ g' ≫ h.hom ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right_assoc {W X X' Y Z : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y)\n  (h : Z ≅ Y) :\n  f ≫ g ≫ h.inv = f' ≫ g' ≫ h.inv ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\nend iso\n\nnamespace functor\n\nuniverses u₁ v₁ u₂ v₂\nvariables {D : Type u₂}\n\nvariables [category.{v₂} D]\n\n/-- A functor `F : C ⥤ D` sends isomorphisms `i : X ≅ Y` to isomorphisms `F.obj X ≅ F.obj Y` -/\n@[simps]\ndef map_iso (F : C ⥤ D) {X Y : C} (i : X ≅ Y) : F.obj X ≅ F.obj Y :=\n{ hom := F.map i.hom,\n  inv := F.map i.inv,\n  hom_inv_id' := by rw [←map_comp, iso.hom_inv_id, ←map_id],\n  inv_hom_id' := by rw [←map_comp, iso.inv_hom_id, ←map_id] }\n\n@[simp] lemma map_iso_symm (F : C ⥤ D) {X Y : C} (i : X ≅ Y) :\n  F.map_iso i.symm = (F.map_iso i).symm :=\nrfl\n\n@[simp] lemma map_iso_trans (F : C ⥤ D) {X Y Z : C} (i : X ≅ Y) (j : Y ≅ Z) :\n  F.map_iso (i ≪≫ j) = (F.map_iso i) ≪≫ (F.map_iso j) :=\nby ext; apply functor.map_comp\n\n@[simp] lemma map_iso_refl (F : C ⥤ D) (X : C) : F.map_iso (iso.refl X) = iso.refl (F.obj X) :=\niso.ext $ F.map_id X\n\ninstance map_is_iso (F : C ⥤ D) (f : X ⟶ Y) [is_iso f] : is_iso (F.map f) :=\nis_iso.of_iso $ F.map_iso (as_iso f)\n\n@[simp] \n\nlemma map_hom_inv (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [is_iso f] :\n  F.map f ≫ F.map (inv f) = 𝟙 (F.obj X) :=\nby simp\n\nlemma map_inv_hom (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [is_iso f] :\n  F.map (inv f) ≫ F.map f = 𝟙 (F.obj Y) :=\nby simp\n\nend functor\n\nsection partial_order\nvariables {α β : Type*} [partial_order α] [partial_order β]\n\nlemma iso.to_eq {X Y : α} (f : X ≅ Y) : X = Y :=\nle_antisymm (le_of_hom f.hom) (le_of_hom f.inv)\n\nend partial_order\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/isomorphism.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.4873532659926905}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\n \n\nuniverses u \n\nnamespace Mathlib\n\nnamespace rbnode\n\n\ninductive is_node_of {α : Type u} : rbnode α → rbnode α → α → rbnode α → Prop\nwhere\n| of_red : ∀ (l : rbnode α) (v : α) (r : rbnode α), is_node_of (red_node l v r) l v r\n| of_black : ∀ (l : rbnode α) (v : α) (r : rbnode α), is_node_of (black_node l v r) l v r\n\ndef lift {α : Type u} (lt : α → α → Prop) : Option α → Option α → Prop :=\n  sorry\n\ninductive is_searchable {α : Type u} (lt : α → α → Prop) : rbnode α → Option α → Option α → Prop\nwhere\n| leaf_s : ∀ {lo hi : Option α}, lift lt lo hi → is_searchable lt leaf lo hi\n| red_s : ∀ {l r : rbnode α} {v : α} {lo hi : Option α},\n  is_searchable lt l lo (some v) → is_searchable lt r (some v) hi → is_searchable lt (red_node l v r) lo hi\n| black_s : ∀ {l r : rbnode α} {v : α} {lo hi : Option α},\n  is_searchable lt l lo (some v) → is_searchable lt r (some v) hi → is_searchable lt (black_node l v r) lo hi\n\ntheorem lo_lt_hi {α : Type u} {t : rbnode α} {lt : α → α → Prop} [is_trans α lt] {lo : Option α} {hi : Option α} : is_searchable lt t lo hi → lift lt lo hi := sorry\n\ntheorem is_searchable_of_is_searchable_of_incomp {α : Type u} {lt : α → α → Prop} [DecidableRel lt] [is_strict_weak_order α lt] {t : rbnode α} {lo : Option α} {hi : α} {hi' : α} (hc : ¬lt hi' hi ∧ ¬lt hi hi') (hs : is_searchable lt t lo (some hi)) : is_searchable lt t lo (some hi') := sorry\n\ntheorem is_searchable_of_incomp_of_is_searchable {α : Type u} {lt : α → α → Prop} [DecidableRel lt] [is_strict_weak_order α lt] {t : rbnode α} {lo : α} {lo' : α} {hi : Option α} (hc : ¬lt lo' lo ∧ ¬lt lo lo') (hs : is_searchable lt t (some lo) hi) : is_searchable lt t (some lo') hi := sorry\n\ntheorem is_searchable_some_low_of_is_searchable_of_lt {α : Type u} {lt : α → α → Prop} [DecidableRel lt] {t : rbnode α} [is_trans α lt] {lo : α} {hi : Option α} {lo' : α} (hlt : lt lo' lo) (hs : is_searchable lt t (some lo) hi) : is_searchable lt t (some lo') hi := sorry\n\ntheorem is_searchable_none_low_of_is_searchable_some_low {α : Type u} {lt : α → α → Prop} [DecidableRel lt] {t : rbnode α} {y : α} {hi : Option α} (hlt : is_searchable lt t (some y) hi) : is_searchable lt t none hi := sorry\n\ntheorem is_searchable_some_high_of_is_searchable_of_lt {α : Type u} {lt : α → α → Prop} [DecidableRel lt] {t : rbnode α} [is_trans α lt] {lo : Option α} {hi : α} {hi' : α} (hlt : lt hi hi') (hs : is_searchable lt t lo (some hi)) : is_searchable lt t lo (some hi') := sorry\n\ntheorem is_searchable_none_high_of_is_searchable_some_high {α : Type u} {lt : α → α → Prop} [DecidableRel lt] {t : rbnode α} {lo : Option α} {y : α} (hlt : is_searchable lt t lo (some y)) : is_searchable lt t lo none := sorry\n\ntheorem range {α : Type u} {lt : α → α → Prop} [DecidableRel lt] [is_strict_weak_order α lt] {t : rbnode α} {x : α} {lo : Option α} {hi : Option α} : is_searchable lt t lo hi → mem lt x t → lift lt lo (some x) ∧ lift lt (some x) hi := sorry\n\ntheorem lt_of_mem_left {α : Type u} {lt : α → α → Prop} [DecidableRel lt] [is_strict_weak_order α lt] {y : α} {t : rbnode α} {l : rbnode α} {r : rbnode α} {lo : Option α} {hi : Option α} : is_searchable lt t lo hi → is_node_of t l y r → ∀ {x : α}, mem lt x l → lt x y := sorry\n\ntheorem lt_of_mem_right {α : Type u} {lt : α → α → Prop} [DecidableRel lt] [is_strict_weak_order α lt] {y : α} {t : rbnode α} {l : rbnode α} {r : rbnode α} {lo : Option α} {hi : Option α} : is_searchable lt t lo hi → is_node_of t l y r → ∀ {z : α}, mem lt z r → lt y z := sorry\n\ntheorem lt_of_mem_left_right {α : Type u} {lt : α → α → Prop} [DecidableRel lt] [is_strict_weak_order α lt] {y : α} {t : rbnode α} {l : rbnode α} {r : rbnode α} {lo : Option α} {hi : Option α} : is_searchable lt t lo hi → is_node_of t l y r → ∀ {x z : α}, mem lt x l → mem lt z r → lt x z := sorry\n\ninductive is_red_black {α : Type u} : rbnode α → color → ℕ → Prop\nwhere\n| leaf_rb : is_red_black leaf color.black 0\n| red_rb : ∀ {v : α} {l r : rbnode α} {n : ℕ},\n  is_red_black l color.black n → is_red_black r color.black n → is_red_black (red_node l v r) color.red n\n| black_rb : ∀ {v : α} {l r : rbnode α} {n : ℕ} {c₁ c₂ : color},\n  is_red_black l c₁ n → is_red_black r c₂ n → is_red_black (black_node l v r) color.black (Nat.succ n)\n\ntheorem depth_min {α : Type u} {c : color} {n : ℕ} {t : rbnode α} : is_red_black t c n → depth min t ≥ n := sorry\n\ntheorem depth_max' {α : Type u} {c : color} {n : ℕ} {t : rbnode α} : is_red_black t c n → depth max t ≤ upper c n := sorry\n\ntheorem depth_max {α : Type u} {c : color} {n : ℕ} {t : rbnode α} (h : is_red_black t c n) : depth max t ≤ bit0 1 * n + 1 :=\n  le_trans (depth_max' h) (upper_le c n)\n\ntheorem balanced {α : Type u} {c : color} {n : ℕ} {t : rbnode α} (h : is_red_black t c n) : bit0 1 * depth min t + 1 ≥ depth max t :=\n  le_trans (depth_max h) (nat.succ_le_succ (nat.mul_le_mul_left (bit0 1) (depth_min h)))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/data/rbtree/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.4873532644665231}}
{"text": "/-\nCopyright (c) 2021 Alena Gusakov, Bhavik Mehta, Kyle Miller. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alena Gusakov, Bhavik Mehta, Kyle Miller\n-/\nimport data.fintype.basic\nimport data.set.finite\n\n/-!\n# Hall's Marriage Theorem for finite index types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis module proves the basic form of Hall's theorem.\nIn constrast to the theorem described in `combinatorics.hall.basic`, this\nversion requires that the indexed family `t : ι → finset α` have `ι` be finite.\nThe `combinatorics.hall.basic` module applies a compactness argument to this version\nto remove the `finite` constraint on `ι`.\n\nThe modules are split like this since the generalized statement\ndepends on the topology and category theory libraries, but the finite\ncase in this module has few dependencies.\n\nA description of this formalization is in [Gusakov2021].\n\n## Main statements\n\n* `finset.all_card_le_bUnion_card_iff_exists_injective'` is Hall's theorem with\n  a finite index set.  This is elsewhere generalized to\n  `finset.all_card_le_bUnion_card_iff_exists_injective`.\n\n## Tags\n\nHall's Marriage Theorem, indexed families\n-/\n\nopen finset\n\nuniverses u v\n\nnamespace hall_marriage_theorem\n\nvariables {ι : Type u} {α : Type v} [decidable_eq α] {t : ι → finset α}\n\nsection fintype\nvariables [fintype ι]\n\nlemma hall_cond_of_erase {x : ι} (a : α)\n  (ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card)\n  (s' : finset {x' : ι | x' ≠ x}) :\n  s'.card ≤ (s'.bUnion (λ x', (t x').erase a)).card :=\nbegin\n  haveI := classical.dec_eq ι,\n  specialize ha (s'.image coe),\n  rw [nonempty.image_iff, finset.card_image_of_injective s' subtype.coe_injective] at ha,\n  by_cases he : s'.nonempty,\n  { have ha' : s'.card < (s'.bUnion (λ x, t x)).card,\n    { convert ha he (λ h, by simpa [←h] using mem_univ x) using 2,\n      ext x,\n      simp only [mem_image, mem_bUnion, exists_prop, set_coe.exists,\n                 exists_and_distrib_right, exists_eq_right, subtype.coe_mk], },\n    rw ←erase_bUnion,\n    by_cases hb : a ∈ s'.bUnion (λ x, t x),\n    { rw card_erase_of_mem hb,\n      exact nat.le_pred_of_lt ha' },\n    { rw erase_eq_of_not_mem hb,\n      exact nat.le_of_lt ha' }, },\n  { rw [nonempty_iff_ne_empty, not_not] at he,\n    subst s',\n    simp },\nend\n\n/--\nFirst case of the inductive step: assuming that\n`∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_A {n : ℕ} (hn : fintype.card ι = n + 1)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),\n        by exactI fintype.card ι' ≤ n →\n                  (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                  ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)\n  (ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  haveI : nonempty ι := fintype.card_pos_iff.mp (hn.symm ▸ nat.succ_pos _),\n  haveI := classical.dec_eq ι,\n  /- Choose an arbitrary element `x : ι` and `y : t x`. -/\n  let x := classical.arbitrary ι,\n  have tx_ne : (t x).nonempty,\n  { rw ←finset.card_pos,\n    calc 0 < 1 : nat.one_pos\n       ... ≤ (finset.bUnion {x} t).card : ht {x}\n       ... = (t x).card : by rw finset.singleton_bUnion, },\n  choose y hy using tx_ne,\n  /- Restrict to everything except `x` and `y`. -/\n  let ι' := {x' : ι | x' ≠ x},\n  let t' : ι' → finset α := λ x', (t x').erase y,\n  have card_ι' : fintype.card ι' = n :=\n    calc fintype.card ι' = fintype.card ι - 1 : set.card_ne_eq _\n                     ... = n : by { rw [hn, nat.add_succ_sub_one, add_zero], },\n  rcases ih t' card_ι'.le (hall_cond_of_erase y ha) with ⟨f', hfinj, hfr⟩,\n  /- Extend the resulting function. -/\n  refine ⟨λ z, if h : z = x then y else f' ⟨z, h⟩, _, _⟩,\n  { rintro z₁ z₂,\n    have key : ∀ {x}, y ≠ f' x,\n    { intros x h,\n      simpa [←h] using hfr x, },\n    by_cases h₁ : z₁ = x; by_cases h₂ : z₂ = x; simp [h₁, h₂, hfinj.eq_iff, key, key.symm], },\n  { intro z,\n    split_ifs with hz,\n    { rwa hz },\n    { specialize hfr ⟨z, hz⟩,\n      rw mem_erase at hfr,\n      exact hfr.2, }, },\nend\n\nlemma hall_cond_of_restrict {ι : Type u} {t : ι → finset α} {s : finset ι}\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (s' : finset (s : set ι)) :\n  s'.card ≤ (s'.bUnion (λ a', t a')).card :=\nbegin\n  classical,\n  rw ← card_image_of_injective s' subtype.coe_injective,\n  convert ht (s'.image coe) using 1,\n  apply congr_arg,\n  ext y,\n  simp,\nend\n\nlemma hall_cond_of_compl {ι : Type u} {t : ι → finset α} {s : finset ι}\n  (hus : s.card = (s.bUnion t).card)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (s' : finset (sᶜ : set ι)) :\n  s'.card ≤ (s'.bUnion (λ x', t x' \\ s.bUnion t)).card :=\nbegin\n  haveI := classical.dec_eq ι,\n  have disj : disjoint s (s'.image coe),\n  { simp only [disjoint_left, not_exists, mem_image, exists_prop, set_coe.exists,\n               exists_and_distrib_right, exists_eq_right, subtype.coe_mk],\n    intros x hx hc h,\n    exact absurd hx hc, },\n  have : s'.card = (s ∪ s'.image coe).card - s.card,\n  { simp [disj, card_image_of_injective _ subtype.coe_injective], },\n  rw [this, hus],\n  refine (tsub_le_tsub_right (ht _) _).trans _,\n  rw ← card_sdiff,\n  { refine (card_le_of_subset _).trans le_rfl,\n    intros t,\n    simp only [mem_bUnion, mem_sdiff, not_exists, mem_image, and_imp, mem_union,\n               exists_and_distrib_right, exists_imp_distrib],\n    rintro x (hx | ⟨x', hx', rfl⟩) rat hs,\n    { exact (hs x hx rat).elim },\n    { exact ⟨⟨x', hx', rat⟩, hs⟩, } },\n  { apply bUnion_subset_bUnion_of_subset_left,\n    apply subset_union_left }\nend\n\n/--\nSecond case of the inductive step: assuming that\n`∃ (s : finset ι), s ≠ univ → s.card = (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_B {n : ℕ} (hn : fintype.card ι = n + 1)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),\n        by exactI fintype.card ι' ≤ n →\n                  (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                  ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)\n  (s : finset ι)\n  (hs : s.nonempty)\n  (hns : s ≠ univ)\n  (hus : s.card = (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  haveI := classical.dec_eq ι,\n  /- Restrict to `s` -/\n  let t' : s → finset α := λ x', t x',\n  rw nat.add_one at hn,\n  have card_ι'_le : fintype.card s ≤ n,\n  { apply nat.le_of_lt_succ,\n    calc fintype.card s = s.card : fintype.card_coe _\n                    ... < fintype.card ι : (card_lt_iff_ne_univ _).mpr hns\n                    ... = n.succ : hn },\n  rcases ih t' card_ι'_le (hall_cond_of_restrict ht) with ⟨f', hf', hsf'⟩,\n  /- Restrict to `sᶜ` in the domain and `(s.bUnion t)ᶜ` in the codomain. -/\n  set ι'' := (s : set ι)ᶜ with ι''_def,\n  let t'' : ι'' → finset α := λ a'', t a'' \\ s.bUnion t,\n  have card_ι''_le : fintype.card ι'' ≤ n,\n  { simp_rw [← nat.lt_succ_iff, ← hn, ι'', ← finset.coe_compl, coe_sort_coe],\n    rwa [fintype.card_coe, card_compl_lt_iff_nonempty] },\n  rcases ih t'' card_ι''_le (hall_cond_of_compl hus ht) with ⟨f'', hf'', hsf''⟩,\n  /- Put them together -/\n  have f'_mem_bUnion : ∀ {x'} (hx' : x' ∈ s), f' ⟨x', hx'⟩ ∈ s.bUnion t,\n  { intros x' hx',\n    rw mem_bUnion,\n    exact ⟨x', hx', hsf' _⟩, },\n  have f''_not_mem_bUnion : ∀ {x''} (hx'' : ¬ x'' ∈ s), ¬ f'' ⟨x'', hx''⟩ ∈ s.bUnion t,\n  { intros x'' hx'',\n    have h := hsf'' ⟨x'', hx''⟩,\n    rw mem_sdiff at h,\n    exact h.2, },\n  have im_disj : ∀ (x' x'' : ι) (hx' : x' ∈ s) (hx'' : ¬x'' ∈ s), f' ⟨x', hx'⟩ ≠ f'' ⟨x'', hx''⟩,\n  { intros _ _ hx' hx'' h,\n    apply f''_not_mem_bUnion hx'',\n    rw ←h,\n    apply f'_mem_bUnion, },\n  refine ⟨λ x, if h : x ∈ s then f' ⟨x, h⟩ else f'' ⟨x, h⟩, _, _⟩,\n  { exact hf'.dite _ hf'' im_disj },\n  { intro x,\n    split_ifs with h,\n    { exact hsf' ⟨x, h⟩ },\n    { exact sdiff_subset _ _ (hsf'' ⟨x, h⟩) } }\nend\n\n\nend fintype\n\nvariables [finite ι]\n\n/--\nHere we combine the two inductive steps into a full strong induction proof,\ncompleting the proof the harder direction of **Hall's Marriage Theorem**.\n-/\ntheorem hall_hard_inductive\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  casesI nonempty_fintype ι,\n  unfreezingI\n  { induction hn : fintype.card ι using nat.strong_induction_on with n ih generalizing ι },\n  rcases n with _|_,\n  { rw fintype.card_eq_zero_iff at hn,\n    exactI ⟨is_empty_elim, is_empty_elim, is_empty_elim⟩, },\n  { have ih' : ∀ (ι' : Type u) [fintype ι'] (t' : ι' → finset α),\n                 by exactI fintype.card ι' ≤ n →\n                    (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                    ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x,\n    { introsI ι' _ _ hι' ht',\n      exact ih _ (nat.lt_succ_of_le hι') ht' _ rfl },\n    by_cases h : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card,\n    { exact hall_hard_inductive_step_A hn ht ih' h, },\n    { push_neg at h,\n      rcases h with ⟨s, sne, snu, sle⟩,\n      exact hall_hard_inductive_step_B hn ht ih' s sne snu (nat.le_antisymm (ht _) sle), } },\nend\n\nend hall_marriage_theorem\n\n/--\nThis is the version of **Hall's Marriage Theorem** in terms of indexed\nfamilies of finite sets `t : ι → finset α` with `ι` finite.\nIt states that there is a set of distinct representatives if and only\nif every union of `k` of the sets has at least `k` elements.\n\nSee `finset.all_card_le_bUnion_card_iff_exists_injective` for a version\nwhere the `finite ι` constraint is removed.\n-/\ntheorem finset.all_card_le_bUnion_card_iff_exists_injective'\n  {ι α : Type*} [finite ι] [decidable_eq α] (t : ι → finset α) :\n  (∀ (s : finset ι), s.card ≤ (s.bUnion t).card) ↔\n    (∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x) :=\nbegin\n  split,\n  { exact hall_marriage_theorem.hall_hard_inductive },\n  { rintro ⟨f, hf₁, hf₂⟩ s,\n    rw ←card_image_of_injective s hf₁,\n    apply card_le_of_subset,\n    intro _,\n    rw [mem_image, mem_bUnion],\n    rintros ⟨x, hx, rfl⟩,\n    exact ⟨x, hx, hf₂ x⟩, },\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/combinatorics/hall/finite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4873532564744121}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.fin_category\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.shapes.equalizers\nimport category_theory.limits.shapes.wide_pullbacks\nimport category_theory.limits.shapes.pullbacks\nimport data.fintype.basic\n\n/-!\n# Categories with finite limits.\n\nA typeclass for categories with all finite (co)limits.\n-/\n\nuniverses v' u' v u\n\nnoncomputable theory\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables (C : Type u) [category.{v} C]\n\n/--\nA category has all finite limits if every functor `J ⥤ C` with a `fin_category J` instance\nhas a limit.\n\nThis is often called 'finitely complete'.\n-/\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\nclass has_finite_limits : Prop :=\n(out (J : Type v) [𝒥 : small_category J] [@fin_category J 𝒥] : @has_limits_of_shape J 𝒥 C _)\n\n@[priority 100]\ninstance has_limits_of_shape_of_has_finite_limits\n  (J : Type v) [small_category J] [fin_category J] [has_finite_limits C] :\n  has_limits_of_shape J C := has_finite_limits.out J\n\n@[priority 100]\ninstance has_finite_limits_of_has_limits_of_size [has_limits_of_size.{v' u'} C] :\n  has_finite_limits C :=\n⟨λ J hJ hJ', by { haveI := has_limits_of_size_shrink.{0 0} C,\n  exact has_limits_of_shape_of_equivalence (fin_category.equiv_as_type J) }⟩\n\n/-- If `C` has all limits, it has finite limits. -/\n@[priority 100]\ninstance has_finite_limits_of_has_limits [has_limits C] : has_finite_limits C := infer_instance\n\n/--\nA category has all finite colimits if every functor `J ⥤ C` with a `fin_category J` instance\nhas a colimit.\n\nThis is often called 'finitely cocomplete'.\n-/\nclass has_finite_colimits : Prop :=\n(out (J : Type v) [𝒥 : small_category J] [@fin_category J 𝒥] : @has_colimits_of_shape J 𝒥 C _)\n\n@[priority 100]\ninstance has_limits_of_shape_of_has_finite_colimits\n  (J : Type v) [small_category J] [fin_category J] [has_finite_colimits C] :\n  has_colimits_of_shape J C := has_finite_colimits.out J\n\n@[priority 100]\ninstance has_finite_colimits_of_has_colimits_of_size [has_colimits_of_size.{v' u'} C] :\n  has_finite_colimits C :=\n⟨λ J hJ hJ', by { haveI := has_colimits_of_size_shrink.{0 0} C,\n  exact has_colimits_of_shape_of_equivalence (fin_category.equiv_as_type J) }⟩\n\n/-- If `C` has all colimits, it has finite colimits. -/\n@[priority 100]\ninstance has_finite_colimits_of_has_colimits [has_colimits C] : has_finite_colimits C :=\ninfer_instance\n\nsection\n\nopen walking_parallel_pair walking_parallel_pair_hom\n\ninstance fintype_walking_parallel_pair : fintype walking_parallel_pair :=\n{ elems := [walking_parallel_pair.zero, walking_parallel_pair.one].to_finset,\n  complete := λ x, by { cases x; simp } }\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance (j j' : walking_parallel_pair) : fintype (walking_parallel_pair_hom j j') :=\n{ elems := walking_parallel_pair.rec_on j\n    (walking_parallel_pair.rec_on j' [walking_parallel_pair_hom.id zero].to_finset\n      [left, right].to_finset)\n    (walking_parallel_pair.rec_on j' ∅ [walking_parallel_pair_hom.id one].to_finset),\n  complete := by tidy }\n\nend\n\ninstance : fin_category walking_parallel_pair := { }\n\n/-- Equalizers are finite limits, so if `C` has all finite limits, it also has all equalizers -/\nexample [has_finite_limits C] : has_equalizers C := by apply_instance\n\n/-- Coequalizers are finite colimits, of if `C` has all finite colimits, it also has all\n    coequalizers -/\nexample [has_finite_colimits C] : has_coequalizers C := by apply_instance\n\nvariables {J : Type v}\n\nlocal attribute [tidy] tactic.case_bash\n\nnamespace wide_pullback_shape\n\ninstance fintype_obj [fintype J] : fintype (wide_pullback_shape J) :=\nby { rw wide_pullback_shape, apply_instance }\n\ninstance fintype_hom (j j' : wide_pullback_shape J) :\n  fintype (j ⟶ j') :=\n{ elems :=\n  begin\n    cases j',\n    { cases j,\n      { exact {hom.id none} },\n      { exact {hom.term j} } },\n    { by_cases some j' = j,\n      { rw h,\n        exact {hom.id j} },\n      { exact ∅ } }\n  end,\n  complete := by tidy }\n\nend wide_pullback_shape\n\nnamespace wide_pushout_shape\n\ninstance fintype_obj [fintype J] : fintype (wide_pushout_shape J) :=\nby { rw wide_pushout_shape, apply_instance }\n\ninstance fintype_hom (j j' : wide_pushout_shape J) :\n  fintype (j ⟶ j') :=\n{ elems :=\n  begin\n    cases j,\n    { cases j',\n      { exact {hom.id none} },\n      { exact {hom.init j'} } },\n    { by_cases some j = j',\n      { rw h,\n        exact {hom.id j'} },\n      { exact ∅ } }\n  end,\n  complete := by tidy }\n\nend wide_pushout_shape\n\ninstance fin_category_wide_pullback [fintype J] :\n  fin_category (wide_pullback_shape J) :=\n{ fintype_hom := wide_pullback_shape.fintype_hom }\n\ninstance fin_category_wide_pushout [fintype J] :\n  fin_category (wide_pushout_shape J) :=\n{ fintype_hom := wide_pushout_shape.fintype_hom }\n\n/--\n`has_finite_wide_pullbacks` represents a choice of wide pullback\nfor every finite collection of morphisms\n-/\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\nclass has_finite_wide_pullbacks : Prop :=\n(out (J : Type v) [fintype J] : has_limits_of_shape (wide_pullback_shape J) C)\n\ninstance has_limits_of_shape_wide_pullback_shape\n  (J : Type v) [fintype J] [has_finite_wide_pullbacks C] :\n  has_limits_of_shape (wide_pullback_shape J) C :=\nby { haveI := @has_finite_wide_pullbacks.out C _ _ J, apply_instance }\n\n/--\n`has_finite_wide_pushouts` represents a choice of wide pushout\nfor every finite collection of morphisms\n-/\nclass has_finite_wide_pushouts : Prop :=\n(out (J : Type v) [fintype J] : has_colimits_of_shape (wide_pushout_shape J) C)\n\ninstance has_colimits_of_shape_wide_pushout_shape\n  (J : Type v) [fintype J] [has_finite_wide_pushouts C] :\n  has_colimits_of_shape (wide_pushout_shape J) C :=\nby { haveI := @has_finite_wide_pushouts.out C _ _ J, apply_instance }\n\n/--\nFinite wide pullbacks are finite limits, so if `C` has all finite limits,\nit also has finite wide pullbacks\n-/\n\n\n/--\nFinite wide pushouts are finite colimits, so if `C` has all finite colimits,\nit also has finite wide pushouts\n-/\nlemma has_finite_wide_pushouts_of_has_finite_limits [has_finite_colimits C] :\n  has_finite_wide_pushouts C :=\n⟨λ J _, by exactI has_finite_colimits.out _⟩\n\ninstance fintype_walking_pair : fintype walking_pair :=\n{ elems := {walking_pair.left, walking_pair.right},\n  complete := λ x, by { cases x; simp } }\n\n/-- Pullbacks are finite limits, so if `C` has all finite limits, it also has all pullbacks -/\nexample [has_finite_wide_pullbacks C] : has_pullbacks C := by apply_instance\n\n/-- Pushouts are finite colimits, so if `C` has all finite colimits, it also has all pushouts -/\nexample [has_finite_wide_pushouts C] : has_pushouts C := by apply_instance\n\nend category_theory.limits\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/shapes/finite_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4873532517152729}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport topology.sheaves.presheaf\nimport category_theory.sites.sheaf\nimport category_theory.sites.spaces\n\n/-!\n# Sheaves\n\nWe define sheaves on a topological space, with values in an arbitrary category.\n\nA presheaf on a topological space `X` is a sheaf presicely when it is a sheaf under the\ngrothendieck topology on `opens X`, which expands out to say: For each open cover `{ Uᵢ }` of\n`U`, and a family of compatible functions `A ⟶ F(Uᵢ)` for an `A : X`, there exists an unique\ngluing `A ⟶ F(U)` compatible with the restriction.\n\nSee the docstring of `Top.presheaf.is_sheaf` for an explanation on the design descisions and a list\nof equivalent conditions.\n\nWe provide the instance `category (sheaf C X)` as the full subcategory of presheaves,\nand the fully faithful functor `sheaf.forget : sheaf C X ⥤ presheaf C X`.\n\n-/\n\nuniverses w v u\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\nopen topological_space\nopen opposite\nopen topological_space.opens\n\nnamespace Top\n\nvariables {C : Type u} [category.{v} C]\nvariables {X : Top.{w}} (F : presheaf C X) {ι : Type v} (U : ι → opens X)\n\nnamespace presheaf\n\n/--\nThe sheaf condition has several different equivalent formulations.\nThe official definition chosen here is in terms of grothendieck topologies so that the results on\nsites could be applied here easily, and this condition does not require additional constraints on\nthe value category.\nThe equivalent formulations of the sheaf condition on `presheaf C X` are as follows :\n\n1. `Top.presheaf.is_sheaf`: (the official definition)\n  It is a sheaf with respect to the grothendieck topology on `opens X`, which is to say:\n  For each open cover `{ Uᵢ }` of `U`, and a family of compatible functions `A ⟶ F(Uᵢ)` for an\n  `A : X`, there exists an unique gluing `A ⟶ F(U)` compatible with the restriction.\n\n2. `Top.presheaf.is_sheaf_equalizer_products`: (requires `C` to have all products)\n  For each open cover `{ Uᵢ }` of `U`, `F(U) ⟶ ∏ F(Uᵢ)` is the equalizer of the two morphisms\n  `∏ F(Uᵢ) ⟶ ∏ F(Uᵢ ∩ Uⱼ)`.\n  See `Top.presheaf.is_sheaf_iff_is_sheaf_equalizer_products`.\n\n3. `Top.presheaf.is_sheaf_opens_le_cover`:\n  For each open cover `{ Uᵢ }` of `U`, `F(U)` is the limit of the diagram consisting of arrows\n  `F(V₁) ⟶ F(V₂)` for every pair of open sets `V₁ ⊇ V₂` that are contained in some `Uᵢ`.\n  See `Top.presheaf.is_sheaf_iff_is_sheaf_opens_le_cover`.\n\n4. `Top.presheaf.is_sheaf_pairwise_intersections`:\n  For each open cover `{ Uᵢ }` of `U`, `F(U)` is the limit of the diagram consisting of arrows\n  from `F(Uᵢ)` and `F(Uⱼ)` to `F(Uᵢ ∩ Uⱼ)` for each pair `(i, j)`.\n  See `Top.presheaf.is_sheaf_iff_is_sheaf_pairwise_intersections`.\n\nThe following requires `C` to be concrete and complete, and `forget C` to reflect isomorphisms and\npreserve limits. This applies to most \"algebraic\" categories, e.g. groups, abelian groups and rings.\n\n5. `Top.presheaf.is_sheaf_unique_gluing`:\n  (requires `C` to be concrete and complete; `forget C` to reflect isomorphisms and preserve limits)\n  For each open cover `{ Uᵢ }` of `U`, and a compatible family of elements `x : F(Uᵢ)`, there exists\n  a unique gluing `x : F(U)` that restricts to the given elements.\n  See `Top.presheaf.is_sheaf_iff_is_sheaf_unique_gluing`.\n\n6. The underlying sheaf of types is a sheaf.\n  See `Top.presheaf.is_sheaf_iff_is_sheaf_comp` and\n  `category_theory.presheaf.is_sheaf_iff_is_sheaf_forget`.\n-/\ndef is_sheaf (F : presheaf.{w v u} C X) : Prop :=\npresheaf.is_sheaf (opens.grothendieck_topology X) F\n\n/--\nThe presheaf valued in `unit` over any topological space is a sheaf.\n-/\nlemma is_sheaf_unit (F : presheaf (category_theory.discrete unit) X) : F.is_sheaf :=\nλ x U S hS x hx, ⟨eq_to_hom (subsingleton.elim _ _), by tidy, by tidy⟩\n\nlemma is_sheaf_iso_iff {F G : presheaf C X} (α : F ≅ G) : F.is_sheaf ↔ G.is_sheaf :=\npresheaf.is_sheaf_of_iso_iff α\n\n/--\nTransfer the sheaf condition across an isomorphism of presheaves.\n-/\nlemma is_sheaf_of_iso {F G : presheaf C X} (α : F ≅ G) (h : F.is_sheaf) : G.is_sheaf :=\n(is_sheaf_iso_iff α).1 h\n\nend presheaf\n\nvariables (C X)\n\n/--\nA `sheaf C X` is a presheaf of objects from `C` over a (bundled) topological space `X`,\nsatisfying the sheaf condition.\n-/\n@[derive category]\ndef sheaf : Type (max u v w) := Sheaf (opens.grothendieck_topology X) C\n\nvariables {C X}\n\n/-- The underlying presheaf of a sheaf -/\nabbreviation sheaf.presheaf (F : X.sheaf C) : Top.presheaf C X := F.1\n\nvariables (C X)\n\n-- Let's construct a trivial example, to keep the inhabited linter happy.\ninstance sheaf_inhabited : inhabited (sheaf (category_theory.discrete punit) X) :=\n⟨⟨functor.star _, presheaf.is_sheaf_unit _⟩⟩\n\nnamespace sheaf\n\n/--\nThe forgetful functor from sheaves to presheaves.\n-/\n@[derive [full, faithful]]\ndef forget : Top.sheaf C X ⥤ Top.presheaf C X :=\nSheaf_to_presheaf _ _\n\n-- Note: These can be proved by simp.\n\n\nend sheaf\n\nend Top\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/sheaves/sheaf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.48734376335583907}}
{"text": "import polyhedral_lattice.basic\nimport normed_group.pseudo_normed_group\nimport pseudo_normed_group.profinitely_filtered\n\nnoncomputable theory\nopen_locale nnreal big_operators\n\nnamespace polyhedral_lattice\n\nopen pseudo_normed_group normed_group\n\nvariables (Λ : Type*) [polyhedral_lattice Λ]\n\nlemma filtration_finite (ε : ℝ≥0) : (filtration Λ ε).finite :=\nbegin\n  classical,\n  obtain ⟨ι, _ι_inst, l, hl, hl'⟩ := polyhedral_lattice.polyhedral Λ, resetI,\n  let n : ι → ℕ := λ i, ⌈(ε / ∥l i∥₊ : ℝ)⌉.nat_abs + 1,\n  let S := finset.univ.pi (λ i, finset.range (n i)),\n  let S' : finset Λ := S.image (λ x, ∑ i, x i (finset.mem_univ _) • l i),\n  apply S'.finite_to_set.subset,\n  intros l₀ H,\n  obtain ⟨c, h1, h2⟩ := hl.generates_nnnorm l₀,\n  simp only [S', set.mem_image, finset.mem_univ, finset.mem_pi, forall_true_left, finset.mem_range,\n    finset.mem_coe, finset.coe_image],\n  refine ⟨λ i _, c i, _, h1.symm⟩,\n  intro i,\n  apply nat.succ_le_succ,\n  contrapose! H,\n  simp only [not_le, semi_normed_group.mem_filtration_iff, h2],\n  have aux : 0 < ∥l i∥₊,\n  { rw [zero_lt_iff, ne.def, nnnorm_eq_zero], exact hl' i },\n  calc ε\n      ≤ (⌈(ε / ∥l i∥₊ : ℝ)⌉.nat_abs : ℝ≥0) * ∥l i∥₊ : _\n  ... < ↑(c i) * ∥l i∥₊ : _\n  ... ≤ ∑ (i : ι), ↑(c i) * ∥l i∥₊ : _,\n  { rw [← nnreal.div_le_iff aux.ne', ← nnreal.coe_le_coe],\n    simp only [coe_nnnorm, nnreal.coe_nat_abs, nnreal.coe_div],\n    refine (int.le_ceil _).trans (le_abs_self _), },\n  { rw mul_lt_mul_right aux,\n    { exact_mod_cast H }, },\n  { refine @finset.single_le_sum _ _ _ _ _ _ i (finset.mem_univ _),\n    exact λ _ _, zero_le', }\nend\n\nopen metric semi_normed_group\n\ninstance : discrete_topology Λ :=\ndiscrete_topology_of_open_singleton_zero $\nbegin\n  classical,\n  have aux := filtration_finite Λ 1,\n  let s := aux.to_finset,\n  let s₀ := s.erase 0,\n  by_cases hs₀ : s₀.nonempty,\n  { let ε : ℝ≥0 := finset.min' (s₀.image $ nnnorm) (hs₀.image _),\n    obtain ⟨a, has₀, ha⟩ : ∃ a ∈ s₀, ∥a∥₊ = ε,\n    { rw ← finset.mem_image, apply finset.min'_mem },\n    have H : 0 < ∥a∥ := by simpa only [norm_pos_iff] using finset.ne_of_mem_erase has₀,\n    have h0ε : 0 < ε, { simpa only [← ha] },\n    have hε1 : ε ≤ 1,\n    { replace has₀ := finset.mem_of_mem_erase has₀,\n      simp only [set.finite.mem_to_finset, mem_filtration_iff] at has₀,\n      rwa [← ha] },\n    suffices : ({0} : set Λ) = ball (0:Λ) ε,\n    { rw this, apply is_open_ball },\n    ext,\n    simp only [metric.mem_ball, set.mem_singleton_iff, dist_zero_right],\n    split,\n    { rintro rfl, rw norm_zero, exact_mod_cast h0ε },\n    intro h,\n    have hx : x ∈ s,\n    { simp only [set.finite.mem_to_finset, mem_filtration_iff],\n      exact le_of_lt (lt_of_lt_of_le h hε1) },\n    by_contra hx0,\n    replace hx := finset.mem_erase_of_ne_of_mem hx0 hx,\n    have := finset.min'_le (s₀.image $ nnnorm),\n    refine not_lt.2 (this ∥x∥₊ _) h,\n    simp only [exists_prop, set.finite.mem_to_finset, finset.mem_image],\n    use ⟨x, ⟨hx, rfl⟩⟩ },\n  { suffices : ({0} : set Λ) = ball (0:Λ) 1,\n    { rw this, apply is_open_ball },\n    ext,\n    simp only [metric.mem_ball, set.mem_singleton_iff, dist_zero_right],\n    split,\n    { rintro rfl, rw norm_zero, exact zero_lt_one },\n    intro h,\n    contrapose! hs₀,\n    refine ⟨x, _⟩,\n    simp only [set.finite.mem_to_finset, finset.mem_erase, mem_filtration_iff, nnreal.coe_one],\n    exact ⟨hs₀, h.le⟩ }\nend\n\ninstance filtration_fintype (c : ℝ≥0) : fintype (filtration Λ c) :=\n(filtration_finite Λ c).fintype\n\n-- we don't need this\ninstance : profinitely_filtered_pseudo_normed_group Λ :=\n{ compact := λ c, by apply_instance, -- compact of finite\n  continuous_add' := λ _ _, continuous_of_discrete_topology,\n  continuous_neg' := λ _, continuous_of_discrete_topology,\n  continuous_cast_le := λ _ _ _, continuous_of_discrete_topology,\n  .. (show pseudo_normed_group Λ, by apply_instance) }\n\nend polyhedral_lattice\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/polyhedral_lattice/topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.48734376098096976}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Kevin Buzzard, Scott Morrison, Johan Commelin, Chris Hughes,\n  Johannes Hölzl, Yury Kudryashov\n-/\nimport algebra.group.commute\nimport algebra.group_with_zero.defs\nimport data.fun_like.basic\n\n/-!\n# Monoid and group homomorphisms\n\nThis file defines the bundled structures for monoid and group homomorphisms. Namely, we define\n`monoid_hom` (resp., `add_monoid_hom`) to be bundled homomorphisms between multiplicative (resp.,\nadditive) monoids or groups.\n\nWe also define coercion to a function, and  usual operations: composition, identity homomorphism,\npointwise multiplication and pointwise inversion.\n\nThis file also defines the lesser-used (and notation-less) homomorphism types which are used as\nbuilding blocks for other homomorphisms:\n\n* `zero_hom`\n* `one_hom`\n* `add_hom`\n* `mul_hom`\n* `monoid_with_zero_hom`\n\n## Notations\n\n* `→+`: Bundled `add_monoid` homs. Also use for `add_group` homs.\n* `→*`: Bundled `monoid` homs. Also use for `group` homs.\n* `→*₀`: Bundled `monoid_with_zero` homs. Also use for `group_with_zero` homs.\n* `→ₙ*`: Bundled `semigroup` homs.\n\n## Implementation notes\n\nThere's a coercion from bundled homs to fun, and the canonical\nnotation is to use the bundled hom as a function via this coercion.\n\nThere is no `group_hom` -- the idea is that `monoid_hom` is used.\nThe constructor for `monoid_hom` needs a proof of `map_one` as well\nas `map_mul`; a separate constructor `monoid_hom.mk'` will construct\ngroup homs (i.e. monoid homs between groups) given only a proof\nthat multiplication is preserved,\n\nImplicit `{}` brackets are often used instead of type class `[]` brackets.  This is done when the\ninstances can be inferred because they are implicit arguments to the type `monoid_hom`.  When they\ncan be inferred from the type it is faster to use this method than to use type class inference.\n\nHistorically this file also included definitions of unbundled homomorphism classes; they were\ndeprecated and moved to `deprecated/group`.\n\n## Tags\n\nmonoid_hom, add_monoid_hom\n\n-/\n\nvariables {α β M N P : Type*} -- monoids\nvariables {G : Type*} {H : Type*} -- groups\nvariables {F : Type*} -- homs\n\n-- for easy multiple inheritance\nset_option old_structure_cmd true\n\nsection zero\n\n/-- `zero_hom M N` is the type of functions `M → N` that preserve zero.\n\nWhen possible, instead of parametrizing results over `(f : zero_hom M N)`,\nyou should parametrize over `(F : Type*) [zero_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to also extend `zero_hom_class`.\n-/\nstructure zero_hom (M : Type*) (N : Type*) [has_zero M] [has_zero N] :=\n(to_fun : M → N)\n(map_zero' : to_fun 0 = 0)\n\n/-- `zero_hom_class F M N` states that `F` is a type of zero-preserving homomorphisms.\n\nYou should extend this typeclass when you extend `zero_hom`.\n-/\nclass zero_hom_class (F : Type*) (M N : out_param $ Type*)\n  [has_zero M] [has_zero N] extends fun_like F M (λ _, N) :=\n(map_zero : ∀ (f : F), f 0 = 0)\n\n-- Instances and lemmas are defined below through `@[to_additive]`.\n\nend zero\n\nsection add\n\n\n/-- `add_hom M N` is the type of functions `M → N` that preserve addition.\n\nWhen possible, instead of parametrizing results over `(f : add_hom M N)`,\nyou should parametrize over `(F : Type*) [add_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `add_hom_class`.\n-/\nstructure add_hom (M : Type*) (N : Type*) [has_add M] [has_add N] :=\n(to_fun : M → N)\n(map_add' : ∀ x y, to_fun (x + y) = to_fun x + to_fun y)\n\n/-- `add_hom_class F M N` states that `F` is a type of addition-preserving homomorphisms.\nYou should declare an instance of this typeclass when you extend `add_hom`.\n-/\nclass add_hom_class (F : Type*) (M N : out_param $ Type*)\n  [has_add M] [has_add N] extends fun_like F M (λ _, N) :=\n(map_add : ∀ (f : F) (x y : M), f (x + y) = f x + f y)\n\n-- Instances and lemmas are defined below through `@[to_additive]`.\n\nend add\n\nsection add_zero\n\n/-- `M →+ N` is the type of functions `M → N` that preserve the `add_zero_class` structure.\n\n`add_monoid_hom` is also used for group homomorphisms.\n\nWhen possible, instead of parametrizing results over `(f : M →+ N)`,\nyou should parametrize over `(F : Type*) [add_monoid_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `add_monoid_hom_class`.\n-/\n@[ancestor zero_hom add_hom]\nstructure add_monoid_hom (M : Type*) (N : Type*) [add_zero_class M] [add_zero_class N]\n  extends zero_hom M N, add_hom M N\n\nattribute [nolint doc_blame] add_monoid_hom.to_add_hom\nattribute [nolint doc_blame] add_monoid_hom.to_zero_hom\n\ninfixr ` →+ `:25 := add_monoid_hom\n\n/-- `add_monoid_hom_class F M N` states that `F` is a type of `add_zero_class`-preserving\nhomomorphisms.\n\nYou should also extend this typeclass when you extend `add_monoid_hom`.\n-/\n@[ancestor add_hom_class zero_hom_class]\nclass add_monoid_hom_class (F : Type*) (M N : out_param $ Type*)\n  [add_zero_class M] [add_zero_class N]\n  extends add_hom_class F M N, zero_hom_class F M N\n\n-- Instances and lemmas are defined below through `@[to_additive]`.\n\nend add_zero\n\nsection one\n\nvariables [has_one M] [has_one N]\n\n/-- `one_hom M N` is the type of functions `M → N` that preserve one.\n\nWhen possible, instead of parametrizing results over `(f : one_hom M N)`,\nyou should parametrize over `(F : Type*) [one_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to also extend `one_hom_class`.\n-/\n@[to_additive]\nstructure one_hom (M : Type*) (N : Type*) [has_one M] [has_one N] :=\n(to_fun : M → N)\n(map_one' : to_fun 1 = 1)\n\n/-- `one_hom_class F M N` states that `F` is a type of one-preserving homomorphisms.\nYou should extend this typeclass when you extend `one_hom`.\n-/\n@[to_additive]\nclass one_hom_class (F : Type*) (M N : out_param $ Type*)\n  [has_one M] [has_one N]\n  extends fun_like F M (λ _, N) :=\n(map_one : ∀ (f : F), f 1 = 1)\n\n@[to_additive]\ninstance one_hom.one_hom_class : one_hom_class (one_hom M N) M N :=\n{ coe := one_hom.to_fun,\n  coe_injective' := λ f g h, by cases f; cases g; congr',\n  map_one := one_hom.map_one' }\n\n@[simp, to_additive] lemma map_one [one_hom_class F M N] (f : F) : f 1 = 1 :=\none_hom_class.map_one f\n\n@[to_additive] lemma map_eq_one_iff [one_hom_class F M N] (f : F)\n  (hf : function.injective f) {x : M} : f x = 1 ↔ x = 1 :=\nhf.eq_iff' (map_one f)\n\n@[to_additive]\nlemma map_ne_one_iff {R S F : Type*} [has_one R] [has_one S] [one_hom_class F R S]\n  (f : F) (hf : function.injective f) {x : R} :\n  f x ≠ 1 ↔ x ≠ 1 :=\n(map_eq_one_iff f hf).not\n\n@[to_additive]\nlemma ne_one_of_map {R S F : Type*} [has_one R] [has_one S] [one_hom_class F R S]\n  {f : F} {x : R} (hx : f x ≠ 1) : x ≠ 1 :=\nne_of_apply_ne f $ ne_of_ne_of_eq hx (map_one f).symm\n\n@[to_additive]\ninstance [one_hom_class F M N] : has_coe_t F (one_hom M N) :=\n⟨λ f, { to_fun := f, map_one' := map_one f }⟩\n\nend one\n\nsection mul\n\nvariables [has_mul M] [has_mul N]\n\n/-- `M →ₙ* N` is the type of functions `M → N` that preserve multiplication. The `ₙ` in the notation\nstands for \"non-unital\" because it is intended to match the notation for `non_unital_alg_hom` and\n`non_unital_ring_hom`, so a `mul_hom` is a non-unital monoid hom.\n\nWhen possible, instead of parametrizing results over `(f : M →ₙ* N)`,\nyou should parametrize over `(F : Type*) [mul_hom_class F M N] (f : F)`.\nWhen you extend this structure, make sure to extend `mul_hom_class`.\n-/\n@[to_additive]\nstructure mul_hom (M : Type*) (N : Type*) [has_mul M] [has_mul N] :=\n(to_fun : M → N)\n(map_mul' : ∀ x y, to_fun (x * y) = to_fun x * to_fun y)\n\ninfixr ` →ₙ* `:25 := mul_hom\n\n/-- `mul_hom_class F M N` states that `F` is a type of multiplication-preserving homomorphisms.\n\nYou should declare an instance of this typeclass when you extend `mul_hom`.\n-/\n@[to_additive]\nclass mul_hom_class (F : Type*) (M N : out_param $ Type*)\n  [has_mul M] [has_mul N] extends fun_like F M (λ _, N) :=\n(map_mul : ∀ (f : F) (x y : M), f (x * y) = f x * f y)\n\n@[to_additive]\ninstance mul_hom.mul_hom_class : mul_hom_class (M →ₙ* N) M N :=\n{ coe := mul_hom.to_fun,\n  coe_injective' := λ f g h, by cases f; cases g; congr',\n  map_mul := mul_hom.map_mul' }\n\n@[simp, to_additive] lemma map_mul [mul_hom_class F M N] (f : F) (x y : M) :\n  f (x * y) = f x * f y :=\nmul_hom_class.map_mul f x y\n\n@[to_additive]\ninstance [mul_hom_class F M N] : has_coe_t F (M →ₙ* N) :=\n⟨λ f, { to_fun := f, map_mul' := map_mul f }⟩\n\nend mul\n\nsection mul_one\n\nvariables [mul_one_class M] [mul_one_class N]\n\n/-- `M →* N` is the type of functions `M → N` that preserve the `monoid` structure.\n`monoid_hom` is also used for group homomorphisms.\n\nWhen possible, instead of parametrizing results over `(f : M →+ N)`,\nyou should parametrize over `(F : Type*) [monoid_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `monoid_hom_class`.\n-/\n@[ancestor one_hom mul_hom, to_additive]\nstructure monoid_hom (M : Type*) (N : Type*) [mul_one_class M] [mul_one_class N]\n  extends one_hom M N, M →ₙ* N\n\nattribute [nolint doc_blame] monoid_hom.to_mul_hom\nattribute [nolint doc_blame] monoid_hom.to_one_hom\n\ninfixr ` →* `:25 := monoid_hom\n\n/-- `monoid_hom_class F M N` states that `F` is a type of `monoid`-preserving homomorphisms.\nYou should also extend this typeclass when you extend `monoid_hom`. -/\n@[ancestor mul_hom_class one_hom_class, to_additive\n\"`add_monoid_hom_class F M N` states that `F` is a type of `add_monoid`-preserving homomorphisms.\nYou should also extend this typeclass when you extend `add_monoid_hom`.\"]\nclass monoid_hom_class (F : Type*) (M N : out_param $ Type*)\n  [mul_one_class M] [mul_one_class N]\n  extends mul_hom_class F M N, one_hom_class F M N\n\n@[to_additive]\ninstance monoid_hom.monoid_hom_class : monoid_hom_class (M →* N) M N :=\n{ coe := monoid_hom.to_fun,\n  coe_injective' := λ f g h, by cases f; cases g; congr',\n  map_mul := monoid_hom.map_mul',\n  map_one := monoid_hom.map_one' }\n\n@[to_additive]\ninstance [monoid_hom_class F M N] : has_coe_t F (M →* N) :=\n⟨λ f, { to_fun := f, map_one' := map_one f, map_mul' := map_mul f }⟩\n\n@[to_additive]\nlemma map_mul_eq_one [monoid_hom_class F M N] (f : F) {a b : M} (h : a * b = 1) :\n  f a * f b = 1 :=\nby rw [← map_mul, h, map_one]\n\n@[to_additive]\nlemma map_div' [div_inv_monoid G] [div_inv_monoid H] [monoid_hom_class F G H] (f : F)\n  (hf : ∀ a, f a⁻¹ = (f a)⁻¹) (a b : G) : f (a / b) = f a / f b :=\nby rw [div_eq_mul_inv, div_eq_mul_inv, map_mul, hf]\n\n/-- Group homomorphisms preserve inverse. -/\n@[simp, to_additive \"Additive group homomorphisms preserve negation.\"]\nlemma map_inv [group G] [division_monoid H] [monoid_hom_class F G H] (f : F) (a : G) :\n  f a⁻¹ = (f a)⁻¹ :=\neq_inv_of_mul_eq_one_left $ map_mul_eq_one f $ inv_mul_self _\n\n/-- Group homomorphisms preserve division. -/\n@[simp, to_additive \"Additive group homomorphisms preserve subtraction.\"]\nlemma map_mul_inv [group G] [division_monoid H] [monoid_hom_class F G H] (f : F) (a b : G) :\n  f (a * b⁻¹) = f a * (f b)⁻¹ :=\nby rw [map_mul, map_inv]\n\n/-- Group homomorphisms preserve division. -/\n@[simp, to_additive \"Additive group homomorphisms preserve subtraction.\"]\nlemma map_div [group G] [division_monoid H] [monoid_hom_class F G H] (f : F) :\n  ∀ a b, f (a / b) = f a / f b :=\nmap_div' _ $ map_inv f\n\n-- to_additive puts the arguments in the wrong order, so generate an auxiliary lemma, then\n-- swap its arguments.\n@[to_additive map_nsmul.aux, simp] theorem map_pow [monoid G] [monoid H] [monoid_hom_class F G H]\n  (f : F) (a : G) :\n  ∀ (n : ℕ), f (a ^ n) = (f a) ^ n\n| 0     := by rw [pow_zero, pow_zero, map_one]\n| (n+1) := by rw [pow_succ, pow_succ, map_mul, map_pow]\n\n@[simp] theorem map_nsmul [add_monoid G] [add_monoid H] [add_monoid_hom_class F G H]\n  (f : F) (n : ℕ) (a : G) : f (n • a) = n • (f a) :=\nmap_nsmul.aux f a n\n\nattribute [to_additive_reorder 8, to_additive] map_pow\n\n@[to_additive]\ntheorem map_zpow' [div_inv_monoid G] [div_inv_monoid H] [monoid_hom_class F G H]\n  (f : F) (hf : ∀ (x : G), f (x⁻¹) = (f x)⁻¹) (a : G) :\n  ∀ n : ℤ, f (a ^ n) = (f a) ^ n\n| (n : ℕ) := by rw [zpow_coe_nat, map_pow, zpow_coe_nat]\n| -[1+n]  := by rw [zpow_neg_succ_of_nat, hf, map_pow, ← zpow_neg_succ_of_nat]\n\n-- to_additive puts the arguments in the wrong order, so generate an auxiliary lemma, then\n-- swap its arguments.\n/-- Group homomorphisms preserve integer power. -/\n@[to_additive map_zsmul.aux, simp]\ntheorem map_zpow [group G] [division_monoid H] [monoid_hom_class F G H] (f : F) (g : G) (n : ℤ) :\n  f (g ^ n) = (f g) ^ n :=\nmap_zpow' f (map_inv f) g n\n\n/-- Additive group homomorphisms preserve integer scaling. -/\ntheorem map_zsmul [add_group G] [subtraction_monoid H] [add_monoid_hom_class F G H] (f : F)\n  (n : ℤ) (g : G) :\n  f (n • g) = n • f g :=\nmap_zsmul.aux f g n\n\nattribute [to_additive_reorder 8, to_additive] map_zpow\n\nend mul_one\n\nsection mul_zero_one\n\nvariables [mul_zero_one_class M] [mul_zero_one_class N]\n\n/-- `M →*₀ N` is the type of functions `M → N` that preserve\nthe `monoid_with_zero` structure.\n\n`monoid_with_zero_hom` is also used for group homomorphisms.\n\nWhen possible, instead of parametrizing results over `(f : M →*₀ N)`,\nyou should parametrize over `(F : Type*) [monoid_with_zero_hom_class F M N] (f : F)`.\n\nWhen you extend this structure, make sure to extend `monoid_with_zero_hom_class`.\n-/\n@[ancestor zero_hom monoid_hom]\nstructure monoid_with_zero_hom (M : Type*) (N : Type*) [mul_zero_one_class M] [mul_zero_one_class N]\n  extends zero_hom M N, monoid_hom M N\n\nattribute [nolint doc_blame] monoid_with_zero_hom.to_monoid_hom\nattribute [nolint doc_blame] monoid_with_zero_hom.to_zero_hom\n\ninfixr ` →*₀ `:25 := monoid_with_zero_hom\n\n/-- `monoid_with_zero_hom_class F M N` states that `F` is a type of\n`monoid_with_zero`-preserving homomorphisms.\n\nYou should also extend this typeclass when you extend `monoid_with_zero_hom`.\n-/\nclass monoid_with_zero_hom_class (F : Type*) (M N : out_param $ Type*)\n  [mul_zero_one_class M] [mul_zero_one_class N]\n  extends monoid_hom_class F M N, zero_hom_class F M N\n\ninstance monoid_with_zero_hom.monoid_with_zero_hom_class :\n  monoid_with_zero_hom_class (M →*₀ N) M N :=\n{ coe := monoid_with_zero_hom.to_fun,\n  coe_injective' := λ f g h, by cases f; cases g; congr',\n  map_mul := monoid_with_zero_hom.map_mul',\n  map_one := monoid_with_zero_hom.map_one',\n  map_zero := monoid_with_zero_hom.map_zero' }\n\ninstance [monoid_with_zero_hom_class F M N] : has_coe_t F (M →*₀ N) :=\n⟨λ f, { to_fun := f, map_one' := map_one f, map_zero' := map_zero f, map_mul' := map_mul f }⟩\n\nend mul_zero_one\n\n-- completely uninteresting lemmas about coercion to function, that all homs need\nsection coes\n\n/-! Bundled morphisms can be down-cast to weaker bundlings -/\n@[to_additive]\ninstance monoid_hom.has_coe_to_one_hom {mM : mul_one_class M} {mN : mul_one_class N} :\n  has_coe (M →* N) (one_hom M N) := ⟨monoid_hom.to_one_hom⟩\n@[to_additive]\ninstance monoid_hom.has_coe_to_mul_hom {mM : mul_one_class M} {mN : mul_one_class N} :\n  has_coe (M →* N) (M →ₙ* N) := ⟨monoid_hom.to_mul_hom⟩\ninstance monoid_with_zero_hom.has_coe_to_monoid_hom\n  {mM : mul_zero_one_class M} {mN : mul_zero_one_class N} :\n  has_coe (M →*₀ N) (M →* N) := ⟨monoid_with_zero_hom.to_monoid_hom⟩\ninstance monoid_with_zero_hom.has_coe_to_zero_hom\n  {mM : mul_zero_one_class M} {mN : mul_zero_one_class N} :\n  has_coe (M →*₀ N) (zero_hom M N) := ⟨monoid_with_zero_hom.to_zero_hom⟩\n\n/-! The simp-normal form of morphism coercion is `f.to_..._hom`. This choice is primarily because\nthis is the way things were before the above coercions were introduced. Bundled morphisms defined\nelsewhere in Mathlib may choose `↑f` as their simp-normal form instead. -/\n@[simp, to_additive]\nlemma monoid_hom.coe_eq_to_one_hom {mM : mul_one_class M} {mN : mul_one_class N} (f : M →* N) :\n  (f : one_hom M N) = f.to_one_hom := rfl\n@[simp, to_additive]\nlemma monoid_hom.coe_eq_to_mul_hom {mM : mul_one_class M} {mN : mul_one_class N} (f : M →* N) :\n  (f : M →ₙ* N) = f.to_mul_hom := rfl\n@[simp]\nlemma monoid_with_zero_hom.coe_eq_to_monoid_hom\n  {mM : mul_zero_one_class M} {mN : mul_zero_one_class N} (f : M →*₀ N) :\n  (f : M →* N) = f.to_monoid_hom := rfl\n@[simp]\nlemma monoid_with_zero_hom.coe_eq_to_zero_hom\n  {mM : mul_zero_one_class M} {mN : mul_zero_one_class N} (f : M →*₀ N) :\n  (f : zero_hom M N) = f.to_zero_hom := rfl\n\n-- Fallback `has_coe_to_fun` instances to help the elaborator\n@[to_additive]\ninstance {mM : has_one M} {mN : has_one N} : has_coe_to_fun (one_hom M N) (λ _, M → N) :=\n⟨one_hom.to_fun⟩\n@[to_additive]\ninstance {mM : has_mul M} {mN : has_mul N} : has_coe_to_fun (M →ₙ* N) (λ _, M → N) :=\n⟨mul_hom.to_fun⟩\n@[to_additive]\ninstance {mM : mul_one_class M} {mN : mul_one_class N} : has_coe_to_fun (M →* N) (λ _, M → N) :=\n⟨monoid_hom.to_fun⟩\ninstance {mM : mul_zero_one_class M} {mN : mul_zero_one_class N} :\n  has_coe_to_fun (M →*₀ N) (λ _, M → N) :=\n⟨monoid_with_zero_hom.to_fun⟩\n\n-- these must come after the coe_to_fun definitions\ninitialize_simps_projections zero_hom (to_fun → apply)\ninitialize_simps_projections add_hom (to_fun → apply)\ninitialize_simps_projections add_monoid_hom (to_fun → apply)\n\ninitialize_simps_projections one_hom (to_fun → apply)\ninitialize_simps_projections mul_hom (to_fun → apply)\ninitialize_simps_projections monoid_hom (to_fun → apply)\ninitialize_simps_projections monoid_with_zero_hom (to_fun → apply)\n\n@[simp, to_additive]\nlemma one_hom.to_fun_eq_coe [has_one M] [has_one N] (f : one_hom M N) : f.to_fun = f := rfl\n@[simp, to_additive]\nlemma mul_hom.to_fun_eq_coe [has_mul M] [has_mul N] (f : M →ₙ* N) : f.to_fun = f := rfl\n@[simp, to_additive]\nlemma monoid_hom.to_fun_eq_coe [mul_one_class M] [mul_one_class N]\n  (f : M →* N) : f.to_fun = f := rfl\n@[simp]\nlemma monoid_with_zero_hom.to_fun_eq_coe [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M →*₀ N) : f.to_fun = f := rfl\n\n@[simp, to_additive]\nlemma one_hom.coe_mk [has_one M] [has_one N]\n  (f : M → N) (h1) : (one_hom.mk f h1 : M → N) = f := rfl\n@[simp, to_additive]\nlemma mul_hom.coe_mk [has_mul M] [has_mul N]\n  (f : M → N) (hmul) : (mul_hom.mk f hmul : M → N) = f := rfl\n@[simp, to_additive]\nlemma monoid_hom.coe_mk [mul_one_class M] [mul_one_class N]\n  (f : M → N) (h1 hmul) : (monoid_hom.mk f h1 hmul : M → N) = f := rfl\n@[simp]\nlemma monoid_with_zero_hom.coe_mk [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M → N) (h0 h1 hmul) : (monoid_with_zero_hom.mk f h0 h1 hmul : M → N) = f := rfl\n\n@[simp, to_additive]\nlemma monoid_hom.to_one_hom_coe [mul_one_class M] [mul_one_class N] (f : M →* N) :\n  (f.to_one_hom : M → N) = f := rfl\n@[simp, to_additive]\nlemma monoid_hom.to_mul_hom_coe [mul_one_class M] [mul_one_class N] (f : M →* N) :\n  (f.to_mul_hom : M → N) = f := rfl\n@[simp]\nlemma monoid_with_zero_hom.to_zero_hom_coe [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M →*₀ N) :\n  (f.to_zero_hom : M → N) = f := rfl\n@[simp]\nlemma monoid_with_zero_hom.to_monoid_hom_coe [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M →*₀ N) :\n  (f.to_monoid_hom : M → N) = f := rfl\n\n@[ext, to_additive]\nlemma one_hom.ext [has_one M] [has_one N] ⦃f g : one_hom M N⦄ (h : ∀ x, f x = g x) : f = g :=\nfun_like.ext _ _ h\n@[ext, to_additive]\nlemma mul_hom.ext [has_mul M] [has_mul N] ⦃f g : M →ₙ* N⦄ (h : ∀ x, f x = g x) : f = g :=\nfun_like.ext _ _ h\n@[ext, to_additive]\nlemma monoid_hom.ext [mul_one_class M] [mul_one_class N]\n  ⦃f g : M →* N⦄ (h : ∀ x, f x = g x) : f = g :=\nfun_like.ext _ _ h\n@[ext]\nlemma monoid_with_zero_hom.ext [mul_zero_one_class M] [mul_zero_one_class N] ⦃f g : M →*₀ N⦄\n  (h : ∀ x, f x = g x) : f = g :=\nfun_like.ext _ _ h\n\nsection deprecated\n\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_fun` instead.\"]\ntheorem one_hom.congr_fun [has_one M] [has_one N]\n  {f g : one_hom M N} (h : f = g) (x : M) : f x = g x :=\nfun_like.congr_fun h x\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_fun` instead.\"]\ntheorem mul_hom.congr_fun [has_mul M] [has_mul N]\n  {f g : M →ₙ* N} (h : f = g) (x : M) : f x = g x :=\nfun_like.congr_fun h x\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_fun` instead.\"]\ntheorem monoid_hom.congr_fun [mul_one_class M] [mul_one_class N]\n  {f g : M →* N} (h : f = g) (x : M) : f x = g x :=\nfun_like.congr_fun h x\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\ntheorem monoid_with_zero_hom.congr_fun [mul_zero_one_class M] [mul_zero_one_class N] {f g : M →*₀ N}\n  (h : f = g) (x : M) : f x = g x :=\nfun_like.congr_fun h x\n\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_arg` instead.\"]\ntheorem one_hom.congr_arg [has_one M] [has_one N]\n  (f : one_hom M N) {x y : M} (h : x = y) : f x = f y :=\nfun_like.congr_arg f h\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_arg` instead.\"]\ntheorem mul_hom.congr_arg [has_mul M] [has_mul N]\n  (f : M →ₙ* N) {x y : M} (h : x = y) : f x = f y :=\nfun_like.congr_arg f h\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\n@[to_additive \"Deprecated: use `fun_like.congr_arg` instead.\"]\ntheorem monoid_hom.congr_arg [mul_one_class M] [mul_one_class N]\n  (f : M →* N) {x y : M} (h : x = y) : f x = f y :=\nfun_like.congr_arg f h\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\ntheorem monoid_with_zero_hom.congr_arg [mul_zero_one_class M] [mul_zero_one_class N] (f : M →*₀ N)\n  {x y : M} (h : x = y) : f x = f y :=\nfun_like.congr_arg f h\n\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\n@[to_additive \"Deprecated: use `fun_like.coe_injective` instead.\"]\nlemma one_hom.coe_inj [has_one M] [has_one N] ⦃f g : one_hom M N⦄ (h : (f : M → N) = g) : f = g :=\nfun_like.coe_injective h\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\n@[to_additive \"Deprecated: use `fun_like.coe_injective` instead.\"]\nlemma mul_hom.coe_inj [has_mul M] [has_mul N] ⦃f g : M →ₙ* N⦄ (h : (f : M → N) = g) : f = g :=\nfun_like.coe_injective h\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\n@[to_additive \"Deprecated: use `fun_like.coe_injective` instead.\"]\nlemma monoid_hom.coe_inj [mul_one_class M] [mul_one_class N]\n  ⦃f g : M →* N⦄ (h : (f : M → N) = g) : f = g :=\nfun_like.coe_injective h\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\nlemma monoid_with_zero_hom.coe_inj [mul_zero_one_class M] [mul_zero_one_class N]\n  ⦃f g : M →*₀ N⦄ (h : (f : M → N) = g) : f = g :=\nfun_like.coe_injective h\n\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\n@[to_additive \"Deprecated: use `fun_like.ext_iff` instead.\"]\nlemma one_hom.ext_iff [has_one M] [has_one N] {f g : one_hom M N} : f = g ↔ ∀ x, f x = g x :=\nfun_like.ext_iff\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\n@[to_additive]\nlemma mul_hom.ext_iff [has_mul M] [has_mul N] {f g : M →ₙ* N} : f = g ↔ ∀ x, f x = g x :=\nfun_like.ext_iff\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\n@[to_additive]\nlemma monoid_hom.ext_iff [mul_one_class M] [mul_one_class N]\n  {f g : M →* N} : f = g ↔ ∀ x, f x = g x :=\nfun_like.ext_iff\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\nlemma monoid_with_zero_hom.ext_iff [mul_zero_one_class M] [mul_zero_one_class N] {f g : M →*₀ N} :\n  f = g ↔ ∀ x, f x = g x :=\nfun_like.ext_iff\nend deprecated\n\n@[simp, to_additive]\nlemma one_hom.mk_coe [has_one M] [has_one N]\n  (f : one_hom M N) (h1) : one_hom.mk f h1 = f :=\none_hom.ext $ λ _, rfl\n@[simp, to_additive]\nlemma mul_hom.mk_coe [has_mul M] [has_mul N]\n  (f : M →ₙ* N) (hmul) : mul_hom.mk f hmul = f :=\nmul_hom.ext $ λ _, rfl\n@[simp, to_additive]\nlemma monoid_hom.mk_coe [mul_one_class M] [mul_one_class N]\n  (f : M →* N) (h1 hmul) : monoid_hom.mk f h1 hmul = f :=\nmonoid_hom.ext $ λ _, rfl\n@[simp]\nlemma monoid_with_zero_hom.mk_coe [mul_zero_one_class M] [mul_zero_one_class N] (f : M →*₀ N)\n  (h0 h1 hmul) : monoid_with_zero_hom.mk f h0 h1 hmul = f :=\nmonoid_with_zero_hom.ext $ λ _, rfl\n\nend coes\n\n/-- Copy of a `one_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\n@[to_additive \"Copy of a `zero_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities.\"]\nprotected def one_hom.copy {hM : has_one M} {hN : has_one N} (f : one_hom M N) (f' : M → N)\n  (h : f' = f) : one_hom M N :=\n{ to_fun := f',\n  map_one' := h.symm ▸ f.map_one' }\n\n/-- Copy of a `mul_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\n@[to_additive \"Copy of an `add_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities.\"]\nprotected def mul_hom.copy {hM : has_mul M} {hN : has_mul N} (f : M →ₙ* N) (f' : M → N)\n  (h : f' = f) : M →ₙ* N :=\n{ to_fun := f',\n  map_mul' := h.symm ▸ f.map_mul' }\n\n/-- Copy of a `monoid_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\n@[to_additive \"Copy of an `add_monoid_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities.\"]\nprotected def monoid_hom.copy {hM : mul_one_class M} {hN : mul_one_class N} (f : M →* N)\n  (f' : M → N) (h : f' = f) : M →* N :=\n{ ..f.to_one_hom.copy f' h, ..f.to_mul_hom.copy f' h }\n\n/-- Copy of a `monoid_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\nprotected def monoid_with_zero_hom.copy {hM : mul_zero_one_class M} {hN : mul_zero_one_class N}\n  (f : M →*₀ N) (f' : M → N) (h : f' = f) : M →* N :=\n{ ..f.to_zero_hom.copy f' h, ..f.to_monoid_hom.copy f' h }\n\n@[to_additive]\nprotected lemma one_hom.map_one [has_one M] [has_one N] (f : one_hom M N) : f 1 = 1 := f.map_one'\n/-- If `f` is a monoid homomorphism then `f 1 = 1`. -/\n@[to_additive]\nprotected lemma monoid_hom.map_one [mul_one_class M] [mul_one_class N] (f : M →* N) :\n  f 1 = 1 := f.map_one'\nprotected lemma monoid_with_zero_hom.map_one [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M →*₀ N) : f 1 = 1 := f.map_one'\n\n/-- If `f` is an additive monoid homomorphism then `f 0 = 0`. -/\nadd_decl_doc add_monoid_hom.map_zero\nprotected lemma monoid_with_zero_hom.map_zero [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M →*₀ N) : f 0 = 0 := f.map_zero'\n\n@[to_additive]\nprotected lemma mul_hom.map_mul [has_mul M] [has_mul N]\n  (f : M →ₙ* N) (a b : M) : f (a * b) = f a * f b := f.map_mul' a b\n/-- If `f` is a monoid homomorphism then `f (a * b) = f a * f b`. -/\n@[to_additive]\nprotected lemma monoid_hom.map_mul [mul_one_class M] [mul_one_class N]\n  (f : M →* N) (a b : M) : f (a * b) = f a * f b := f.map_mul' a b\nprotected lemma monoid_with_zero_hom.map_mul [mul_zero_one_class M] [mul_zero_one_class N]\n  (f :  M →*₀ N) (a b : M) : f (a * b) = f a * f b := f.map_mul' a b\n\n/-- If `f` is an additive monoid homomorphism then `f (a + b) = f a + f b`. -/\nadd_decl_doc add_monoid_hom.map_add\n\nnamespace monoid_hom\nvariables {mM : mul_one_class M} {mN : mul_one_class N} [monoid_hom_class F M N]\n\ninclude mM mN\n\n/-- Given a monoid homomorphism `f : M →* N` and an element `x : M`, if `x` has a right inverse,\nthen `f x` has a right inverse too. For elements invertible on both sides see `is_unit.map`. -/\n@[to_additive \"Given an add_monoid homomorphism `f : M →+ N` and an element `x : M`, if `x` has\na right inverse, then `f x` has a right inverse too.\"]\nlemma map_exists_right_inv (f : F) {x : M} (hx : ∃ y, x * y = 1) :\n  ∃ y, f x * y = 1 :=\nlet ⟨y, hy⟩ := hx in ⟨f y, map_mul_eq_one f hy⟩\n\n/-- Given a monoid homomorphism `f : M →* N` and an element `x : M`, if `x` has a left inverse,\nthen `f x` has a left inverse too. For elements invertible on both sides see `is_unit.map`. -/\n@[to_additive \"Given an add_monoid homomorphism `f : M →+ N` and an element `x : M`, if `x` has\na left inverse, then `f x` has a left inverse too. For elements invertible on both sides see\n`is_add_unit.map`.\"]\nlemma map_exists_left_inv (f : F) {x : M} (hx : ∃ y, y * x = 1) :\n  ∃ y, y * f x = 1 :=\nlet ⟨y, hy⟩ := hx in ⟨f y, map_mul_eq_one f hy⟩\n\nend monoid_hom\n\nsection division_comm_monoid\nvariables [division_comm_monoid α]\n\n/-- Inversion on a commutative group, considered as a monoid homomorphism. -/\n@[to_additive \"Negation on a commutative additive group, considered as an additive monoid\nhomomorphism.\"]\ndef inv_monoid_hom : α →* α :=\n{ to_fun := has_inv.inv,\n  map_one' := inv_one,\n  map_mul' := mul_inv }\n\n@[simp] lemma coe_inv_monoid_hom : (inv_monoid_hom : α → α) = has_inv.inv := rfl\n@[simp] lemma inv_monoid_hom_apply (a : α) : inv_monoid_hom a = a⁻¹ := rfl\n\nend division_comm_monoid\n\n/-- The identity map from a type with 1 to itself. -/\n@[to_additive, simps]\ndef one_hom.id (M : Type*) [has_one M] : one_hom M M :=\n{ to_fun := λ x, x, map_one' := rfl, }\n/-- The identity map from a type with multiplication to itself. -/\n@[to_additive, simps]\ndef mul_hom.id (M : Type*) [has_mul M] : M →ₙ* M :=\n{ to_fun := λ x, x, map_mul' := λ _ _, rfl, }\n/-- The identity map from a monoid to itself. -/\n@[to_additive, simps]\ndef monoid_hom.id (M : Type*) [mul_one_class M] : M →* M :=\n{ to_fun := λ x, x, map_one' := rfl, map_mul' := λ _ _, rfl, }\n/-- The identity map from a monoid_with_zero to itself. -/\n@[simps]\ndef monoid_with_zero_hom.id (M : Type*) [mul_zero_one_class M] : M →*₀ M :=\n{ to_fun := λ x, x, map_zero' := rfl, map_one' := rfl, map_mul' := λ _ _, rfl, }\n\n/-- The identity map from an type with zero to itself. -/\nadd_decl_doc zero_hom.id\n/-- The identity map from an type with addition to itself. -/\nadd_decl_doc add_hom.id\n/-- The identity map from an additive monoid to itself. -/\nadd_decl_doc add_monoid_hom.id\n\n/-- Composition of `one_hom`s as a `one_hom`. -/\n@[to_additive]\ndef one_hom.comp [has_one M] [has_one N] [has_one P]\n  (hnp : one_hom N P) (hmn : one_hom M N) : one_hom M P :=\n{ to_fun := hnp ∘ hmn, map_one' := by simp, }\n/-- Composition of `mul_hom`s as a `mul_hom`. -/\n@[to_additive]\ndef mul_hom.comp [has_mul M] [has_mul N] [has_mul P]\n  (hnp : N →ₙ* P) (hmn : M →ₙ* N) : M →ₙ* P :=\n{ to_fun := hnp ∘ hmn, map_mul' := by simp, }\n\n/-- Composition of monoid morphisms as a monoid morphism. -/\n@[to_additive]\ndef monoid_hom.comp [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  (hnp : N →* P) (hmn : M →* N) : M →* P :=\n{ to_fun := hnp ∘ hmn, map_one' := by simp, map_mul' := by simp, }\n\n/-- Composition of `monoid_with_zero_hom`s as a `monoid_with_zero_hom`. -/\ndef monoid_with_zero_hom.comp [mul_zero_one_class M] [mul_zero_one_class N] [mul_zero_one_class P]\n  (hnp : N →*₀ P) (hmn : M →*₀ N) : M →*₀ P :=\n{ to_fun := hnp ∘ hmn, map_zero' := by simp, map_one' := by simp, map_mul' := by simp, }\n\n/-- Composition of `zero_hom`s as a `zero_hom`. -/\nadd_decl_doc zero_hom.comp\n/-- Composition of `add_hom`s as a `add_hom`. -/\nadd_decl_doc add_hom.comp\n/-- Composition of additive monoid morphisms as an additive monoid morphism. -/\nadd_decl_doc add_monoid_hom.comp\n\n@[simp, to_additive] lemma one_hom.coe_comp [has_one M] [has_one N] [has_one P]\n  (g : one_hom N P) (f : one_hom M N) :\n  ⇑(g.comp f) = g ∘ f := rfl\n@[simp, to_additive] lemma mul_hom.coe_comp [has_mul M] [has_mul N] [has_mul P]\n  (g : N →ₙ* P) (f : M →ₙ* N) :\n  ⇑(g.comp f) = g ∘ f := rfl\n@[simp, to_additive] lemma monoid_hom.coe_comp [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  (g : N →* P) (f : M →* N) :\n  ⇑(g.comp f) = g ∘ f := rfl\n@[simp] lemma monoid_with_zero_hom.coe_comp [mul_zero_one_class M] [mul_zero_one_class N]\n  [mul_zero_one_class P] (g : N →*₀ P) (f : M →*₀ N) :\n  ⇑(g.comp f) = g ∘ f := rfl\n\n@[to_additive] lemma one_hom.comp_apply [has_one M] [has_one N] [has_one P]\n  (g : one_hom N P) (f : one_hom M N) (x : M) :\n  g.comp f x = g (f x) := rfl\n@[to_additive] lemma mul_hom.comp_apply [has_mul M] [has_mul N] [has_mul P]\n  (g : N →ₙ* P) (f : M →ₙ* N) (x : M) :\n  g.comp f x = g (f x) := rfl\n@[to_additive] lemma monoid_hom.comp_apply [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  (g : N →* P) (f : M →* N) (x : M) :\n  g.comp f x = g (f x) := rfl\nlemma monoid_with_zero_hom.comp_apply [mul_zero_one_class M] [mul_zero_one_class N]\n  [mul_zero_one_class P] (g : N →*₀ P) (f : M →*₀ N) (x : M) :\n  g.comp f x = g (f x) := rfl\n\n/-- Composition of monoid homomorphisms is associative. -/\n@[to_additive] lemma one_hom.comp_assoc {Q : Type*} [has_one M] [has_one N] [has_one P] [has_one Q]\n  (f : one_hom M N) (g : one_hom N P) (h : one_hom P Q) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[to_additive] lemma mul_hom.comp_assoc {Q : Type*} [has_mul M] [has_mul N] [has_mul P] [has_mul Q]\n  (f : M →ₙ* N) (g : N →ₙ* P) (h : P →ₙ* Q) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[to_additive] lemma monoid_hom.comp_assoc {Q : Type*}\n  [mul_one_class M] [mul_one_class N] [mul_one_class P] [mul_one_class Q]\n  (f : M →* N) (g : N →* P) (h : P →* Q) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\nlemma monoid_with_zero_hom.comp_assoc {Q : Type*}\n  [mul_zero_one_class M] [mul_zero_one_class N] [mul_zero_one_class P] [mul_zero_one_class Q]\n  (f : M →*₀ N) (g : N →*₀ P) (h : P →*₀ Q) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n\n@[to_additive]\nlemma one_hom.cancel_right [has_one M] [has_one N] [has_one P]\n  {g₁ g₂ : one_hom N P} {f : one_hom M N} (hf : function.surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, one_hom.ext $ hf.forall.2 (one_hom.ext_iff.1 h), λ h, h ▸ rfl⟩\n@[to_additive]\nlemma mul_hom.cancel_right [has_mul M] [has_mul N] [has_mul P]\n  {g₁ g₂ : N →ₙ* P} {f : M →ₙ* N} (hf : function.surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, mul_hom.ext $ hf.forall.2 (mul_hom.ext_iff.1 h), λ h, h ▸ rfl⟩\n@[to_additive]\nlemma monoid_hom.cancel_right\n  [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  {g₁ g₂ : N →* P} {f : M →* N} (hf : function.surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, monoid_hom.ext $ hf.forall.2 (monoid_hom.ext_iff.1 h), λ h, h ▸ rfl⟩\nlemma monoid_with_zero_hom.cancel_right [mul_zero_one_class M] [mul_zero_one_class N]\n  [mul_zero_one_class P] {g₁ g₂ : N →*₀ P} {f : M →*₀ N} (hf : function.surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, monoid_with_zero_hom.ext $ hf.forall.2 (monoid_with_zero_hom.ext_iff.1 h),\n λ h, h ▸ rfl⟩\n\n@[to_additive]\nlemma one_hom.cancel_left [has_one M] [has_one N] [has_one P]\n  {g : one_hom N P} {f₁ f₂ : one_hom M N} (hg : function.injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, one_hom.ext $ λ x, hg $ by rw [← one_hom.comp_apply, h, one_hom.comp_apply],\n λ h, h ▸ rfl⟩\n@[to_additive]\nlemma mul_hom.cancel_left [has_mul M] [has_mul N] [has_mul P]\n  {g : N →ₙ* P} {f₁ f₂ : M →ₙ* N} (hg : function.injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, mul_hom.ext $ λ x, hg $ by rw [← mul_hom.comp_apply, h, mul_hom.comp_apply],\n λ h, h ▸ rfl⟩\n@[to_additive]\nlemma monoid_hom.cancel_left [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  {g : N →* P} {f₁ f₂ : M →* N} (hg : function.injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, monoid_hom.ext $ λ x, hg $ by rw [← monoid_hom.comp_apply, h, monoid_hom.comp_apply],\n λ h, h ▸ rfl⟩\nlemma monoid_with_zero_hom.cancel_left [mul_zero_one_class M] [mul_zero_one_class N]\n  [mul_zero_one_class P] {g : N →*₀ P} {f₁ f₂ : M →*₀ N} (hg : function.injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, monoid_with_zero_hom.ext $ λ x, hg $ by rw [\n        ← monoid_with_zero_hom.comp_apply, h, monoid_with_zero_hom.comp_apply],\n λ h, h ▸ rfl⟩\n\n@[to_additive]\nlemma monoid_hom.to_one_hom_injective [mul_one_class M] [mul_one_class N] :\n  function.injective (monoid_hom.to_one_hom : (M →* N) → one_hom M N) :=\nλ f g h, monoid_hom.ext $ one_hom.ext_iff.mp h\n@[to_additive]\nlemma monoid_hom.to_mul_hom_injective [mul_one_class M] [mul_one_class N] :\n  function.injective (monoid_hom.to_mul_hom : (M →* N) → M →ₙ* N) :=\nλ f g h, monoid_hom.ext $ mul_hom.ext_iff.mp h\nlemma monoid_with_zero_hom.to_monoid_hom_injective [mul_zero_one_class M] [mul_zero_one_class N] :\n  function.injective (monoid_with_zero_hom.to_monoid_hom : (M →*₀ N) → M →* N) :=\nλ f g h, monoid_with_zero_hom.ext $ monoid_hom.ext_iff.mp h\nlemma monoid_with_zero_hom.to_zero_hom_injective [mul_zero_one_class M] [mul_zero_one_class N] :\n  function.injective (monoid_with_zero_hom.to_zero_hom : (M →*₀ N) → zero_hom M N) :=\nλ f g h, monoid_with_zero_hom.ext $ zero_hom.ext_iff.mp h\n\n@[simp, to_additive] lemma one_hom.comp_id [has_one M] [has_one N]\n  (f : one_hom M N) : f.comp (one_hom.id M) = f := one_hom.ext $ λ x, rfl\n@[simp, to_additive] lemma mul_hom.comp_id [has_mul M] [has_mul N]\n  (f : M →ₙ* N) : f.comp (mul_hom.id M) = f := mul_hom.ext $ λ x, rfl\n@[simp, to_additive] lemma monoid_hom.comp_id [mul_one_class M] [mul_one_class N]\n  (f : M →* N) : f.comp (monoid_hom.id M) = f := monoid_hom.ext $ λ x, rfl\n@[simp] lemma monoid_with_zero_hom.comp_id [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M →*₀ N) : f.comp (monoid_with_zero_hom.id M) = f :=\nmonoid_with_zero_hom.ext $ λ x, rfl\n\n@[simp, to_additive] lemma one_hom.id_comp [has_one M] [has_one N]\n  (f : one_hom M N) : (one_hom.id N).comp f = f := one_hom.ext $ λ x, rfl\n@[simp, to_additive] lemma mul_hom.id_comp [has_mul M] [has_mul N]\n  (f : M →ₙ* N) : (mul_hom.id N).comp f = f := mul_hom.ext $ λ x, rfl\n@[simp, to_additive] lemma monoid_hom.id_comp [mul_one_class M] [mul_one_class N]\n  (f : M →* N) : (monoid_hom.id N).comp f = f := monoid_hom.ext $ λ x, rfl\n@[simp] lemma monoid_with_zero_hom.id_comp [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M →*₀ N) : (monoid_with_zero_hom.id N).comp f = f :=\nmonoid_with_zero_hom.ext $ λ x, rfl\n\n@[to_additive add_monoid_hom.map_nsmul]\nprotected theorem monoid_hom.map_pow [monoid M] [monoid N] (f : M →* N) (a : M) (n : ℕ) :\n  f (a ^ n) = (f a) ^ n :=\nmap_pow f a n\n\n@[to_additive]\nprotected theorem monoid_hom.map_zpow' [div_inv_monoid M] [div_inv_monoid N] (f : M →* N)\n  (hf : ∀ x, f (x⁻¹) = (f x)⁻¹) (a : M) (n : ℤ) :\n  f (a ^ n) = (f a) ^ n :=\nmap_zpow' f hf a n\n\nsection End\n\nnamespace monoid\n\nvariables (M) [mul_one_class M]\n\n/-- The monoid of endomorphisms. -/\nprotected def End := M →* M\n\nnamespace End\n\ninstance : monoid (monoid.End M) :=\n{ mul := monoid_hom.comp,\n  one := monoid_hom.id M,\n  mul_assoc := λ _ _ _, monoid_hom.comp_assoc _ _ _,\n  mul_one := monoid_hom.comp_id,\n  one_mul := monoid_hom.id_comp }\n\ninstance : inhabited (monoid.End M) := ⟨1⟩\n\ninstance : has_coe_to_fun (monoid.End M) (λ _, M → M) := ⟨monoid_hom.to_fun⟩\n\nend End\n\n@[simp] lemma coe_one : ((1 : monoid.End M) : M → M) = id := rfl\n@[simp] lemma coe_mul (f g) : ((f * g : monoid.End M) : M → M) = f ∘ g := rfl\n\nend monoid\n\nnamespace add_monoid\n\nvariables (A : Type*) [add_zero_class A]\n\n/-- The monoid of endomorphisms. -/\nprotected def End := A →+ A\n\nnamespace End\n\ninstance : monoid (add_monoid.End A) :=\n{ mul := add_monoid_hom.comp,\n  one := add_monoid_hom.id A,\n  mul_assoc := λ _ _ _, add_monoid_hom.comp_assoc _ _ _,\n  mul_one := add_monoid_hom.comp_id,\n  one_mul := add_monoid_hom.id_comp }\n\ninstance : inhabited (add_monoid.End A) := ⟨1⟩\n\ninstance : has_coe_to_fun (add_monoid.End A) (λ _, A → A) := ⟨add_monoid_hom.to_fun⟩\n\nend End\n\n@[simp] lemma coe_one : ((1 : add_monoid.End A) : A → A) = id := rfl\n@[simp] lemma coe_mul (f g) : ((f * g : add_monoid.End A) : A → A) = f ∘ g := rfl\n\nend add_monoid\n\nend End\n\n/-- `1` is the homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [has_one M] [has_one N] : has_one (one_hom M N) := ⟨⟨λ _, 1, rfl⟩⟩\n/-- `1` is the multiplicative homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [has_mul M] [mul_one_class N] : has_one (M →ₙ* N) :=\n⟨⟨λ _, 1, λ _ _, (one_mul 1).symm⟩⟩\n/-- `1` is the monoid homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [mul_one_class M] [mul_one_class N] : has_one (M →* N) :=\n⟨⟨λ _, 1, rfl, λ _ _, (one_mul 1).symm⟩⟩\n\n/-- `0` is the homomorphism sending all elements to `0`. -/\nadd_decl_doc zero_hom.has_zero\n/-- `0` is the additive homomorphism sending all elements to `0`. -/\nadd_decl_doc add_hom.has_zero\n/-- `0` is the additive monoid homomorphism sending all elements to `0`. -/\nadd_decl_doc add_monoid_hom.has_zero\n\n@[simp, to_additive] lemma one_hom.one_apply [has_one M] [has_one N]\n  (x : M) : (1 : one_hom M N) x = 1 := rfl\n@[simp, to_additive] lemma monoid_hom.one_apply [mul_one_class M] [mul_one_class N]\n  (x : M) : (1 : M →* N) x = 1 := rfl\n\n@[simp, to_additive] lemma one_hom.one_comp [has_one M] [has_one N] [has_one P] (f : one_hom M N) :\n  (1 : one_hom N P).comp f = 1 := rfl\n@[simp, to_additive] lemma one_hom.comp_one [has_one M] [has_one N] [has_one P] (f : one_hom N P) :\n  f.comp (1 : one_hom M N) = 1 :=\nby { ext, simp only [one_hom.map_one, one_hom.coe_comp, function.comp_app, one_hom.one_apply] }\n\n@[to_additive]\ninstance [has_one M] [has_one N] : inhabited (one_hom M N) := ⟨1⟩\n@[to_additive]\ninstance [has_mul M] [mul_one_class N] : inhabited (M →ₙ* N) := ⟨1⟩\n@[to_additive]\ninstance [mul_one_class M] [mul_one_class N] : inhabited (M →* N) := ⟨1⟩\n-- unlike the other homs, `monoid_with_zero_hom` does not have a `1` or `0`\ninstance [mul_zero_one_class M] : inhabited (M →*₀ M) := ⟨monoid_with_zero_hom.id M⟩\n\nnamespace mul_hom\n\n/-- Given two mul morphisms `f`, `g` to a commutative semigroup, `f * g` is the mul morphism\nsending `x` to `f x * g x`. -/\n@[to_additive]\ninstance [has_mul M] [comm_semigroup N] : has_mul (M →ₙ* N) :=\n⟨λ f g,\n  { to_fun := λ m, f m * g m,\n    map_mul' := begin intros, show f (x * y) * g (x * y) = f x * g x * (f y * g y),\n      rw [f.map_mul, g.map_mul, ←mul_assoc, ←mul_assoc, mul_right_comm (f x)], end }⟩\n\n/-- Given two additive morphisms `f`, `g` to an additive commutative semigroup, `f + g` is the\nadditive morphism sending `x` to `f x + g x`. -/\nadd_decl_doc add_hom.has_add\n\n@[simp, to_additive] lemma mul_apply {M N} {mM : has_mul M} {mN : comm_semigroup N}\n  (f g : M →ₙ* N) (x : M) :\n  (f * g) x = f x * g x := rfl\n\n@[to_additive] lemma mul_comp [has_mul M] [has_mul N] [comm_semigroup P]\n  (g₁ g₂ : N →ₙ* P) (f : M →ₙ* N) :\n  (g₁ * g₂).comp f = g₁.comp f * g₂.comp f := rfl\n@[to_additive] lemma comp_mul [has_mul M] [comm_semigroup N] [comm_semigroup P]\n  (g : N →ₙ* P) (f₁ f₂ : M →ₙ* N) :\n  g.comp (f₁ * f₂) = g.comp f₁ * g.comp f₂ :=\nby { ext, simp only [mul_apply, function.comp_app, map_mul, coe_comp] }\n\nend mul_hom\n\nnamespace monoid_hom\nvariables [mM : mul_one_class M] [mN : mul_one_class N] [mP : mul_one_class P]\nvariables [group G] [comm_group H]\n\n/-- Given two monoid morphisms `f`, `g` to a commutative monoid, `f * g` is the monoid morphism\nsending `x` to `f x * g x`. -/\n@[to_additive]\ninstance {M N} {mM : mul_one_class M} [comm_monoid N] : has_mul (M →* N) :=\n⟨λ f g,\n  { to_fun := λ m, f m * g m,\n    map_one' := show f 1 * g 1 = 1, by simp,\n    map_mul' := begin intros, show f (x * y) * g (x * y) = f x * g x * (f y * g y),\n      rw [f.map_mul, g.map_mul, ←mul_assoc, ←mul_assoc, mul_right_comm (f x)], end }⟩\n\n/-- Given two additive monoid morphisms `f`, `g` to an additive commutative monoid, `f + g` is the\nadditive monoid morphism sending `x` to `f x + g x`. -/\nadd_decl_doc add_monoid_hom.has_add\n\n@[simp, to_additive] lemma mul_apply {M N} {mM : mul_one_class M} {mN : comm_monoid N}\n  (f g : M →* N) (x : M) :\n  (f * g) x = f x * g x := rfl\n\n@[simp, to_additive] lemma one_comp [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  (f : M →* N) : (1 : N →* P).comp f = 1 := rfl\n@[simp, to_additive] lemma comp_one [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  (f : N →* P) : f.comp (1 : M →* N) = 1 :=\nby { ext, simp only [map_one, coe_comp, function.comp_app, one_apply] }\n\n@[to_additive] lemma mul_comp [mul_one_class M] [mul_one_class N] [comm_monoid P]\n  (g₁ g₂ : N →* P) (f : M →* N) :\n  (g₁ * g₂).comp f = g₁.comp f * g₂.comp f := rfl\n@[to_additive] lemma comp_mul [mul_one_class M] [comm_monoid N] [comm_monoid P]\n  (g : N →* P) (f₁ f₂ : M →* N) :\n  g.comp (f₁ * f₂) = g.comp f₁ * g.comp f₂ :=\nby { ext, simp only [mul_apply, function.comp_app, map_mul, coe_comp] }\n\n/-- If two homomorphism from a group to a monoid are equal at `x`, then they are equal at `x⁻¹`. -/\n@[to_additive \"If two homomorphism from an additive group to an additive monoid are equal at `x`,\nthen they are equal at `-x`.\" ]\nlemma eq_on_inv {G} [group G] [monoid M] [monoid_hom_class F G M] {f g : F} {x : G}\n  (h : f x = g x) : f x⁻¹ = g x⁻¹ :=\nleft_inv_eq_right_inv (map_mul_eq_one f $ inv_mul_self x) $\n  h.symm ▸ map_mul_eq_one g $ mul_inv_self x\n\n/-- Group homomorphisms preserve inverse. -/\n@[to_additive \"Additive group homomorphisms preserve negation.\"]\nprotected lemma map_inv [group α] [division_monoid β] (f : α →* β) (a : α) : f a⁻¹ = (f a)⁻¹ :=\nmap_inv f _\n\n/-- Group homomorphisms preserve integer power. -/\n@[to_additive \"Additive group homomorphisms preserve integer scaling.\"]\nprotected theorem map_zpow [group α] [division_monoid β] (f : α →* β) (g : α) (n : ℤ) :\n  f (g ^ n) = (f g) ^ n :=\nmap_zpow f g n\n\n/-- Group homomorphisms preserve division. -/\n@[to_additive \"Additive group homomorphisms preserve subtraction.\"]\nprotected theorem map_div [group α] [division_monoid β] (f : α →* β) (g h : α) :\n  f (g / h) = f g / f h :=\nmap_div f g h\n\n/-- Group homomorphisms preserve division. -/\n@[to_additive \"Additive group homomorphisms preserve subtraction.\"]\nprotected theorem map_mul_inv [group α] [division_monoid β] (f : α →* β) (g h : α) :\n  f (g * h⁻¹) = (f g) * (f h)⁻¹ :=\nmap_mul_inv f g h\n\n/-- A homomorphism from a group to a monoid is injective iff its kernel is trivial.\nFor the iff statement on the triviality of the kernel, see `injective_iff_map_eq_one'`.  -/\n@[to_additive \"A homomorphism from an additive group to an additive monoid is injective iff\nits kernel is trivial. For the iff statement on the triviality of the kernel,\nsee `injective_iff_map_eq_zero'`.\"]\nlemma _root_.injective_iff_map_eq_one {G H} [group G] [mul_one_class H] [monoid_hom_class F G H]\n  (f : F) : function.injective f ↔ (∀ a, f a = 1 → a = 1) :=\n⟨λ h x, (map_eq_one_iff f h).mp,\n λ h x y hxy, mul_inv_eq_one.1 $ h _ $ by rw [map_mul, hxy, ← map_mul, mul_inv_self, map_one]⟩\n\n/-- A homomorphism from a group to a monoid is injective iff its kernel is trivial,\nstated as an iff on the triviality of the kernel.\nFor the implication, see `injective_iff_map_eq_one`. -/\n@[to_additive \"A homomorphism from an additive group to an additive monoid is injective iff its\nkernel is trivial, stated as an iff on the triviality of the kernel. For the implication, see\n`injective_iff_map_eq_zero`.\"]\nlemma _root_.injective_iff_map_eq_one' {G H} [group G] [mul_one_class H] [monoid_hom_class F G H]\n  (f : F) : function.injective f ↔ (∀ a, f a = 1 ↔ a = 1) :=\n(injective_iff_map_eq_one f).trans $ forall_congr $ λ a, ⟨λ h, ⟨h, λ H, H.symm ▸ map_one f⟩, iff.mp⟩\n\ninclude mM\n/-- Makes a group homomorphism from a proof that the map preserves multiplication. -/\n@[to_additive \"Makes an additive group homomorphism from a proof that the map preserves addition.\",\n  simps {fully_applied := ff}]\ndef mk' (f : M → G) (map_mul : ∀ a b : M, f (a * b) = f a * f b) : M →* G :=\n{ to_fun := f,\n  map_mul' := map_mul,\n  map_one' := mul_left_eq_self.1 $ by rw [←map_mul, mul_one] }\n\nomit mM\n\n/-- Makes a group homomorphism from a proof that the map preserves right division `λ x y, x * y⁻¹`.\nSee also `monoid_hom.of_map_div` for a version using `λ x y, x / y`.\n-/\n@[to_additive \"Makes an additive group homomorphism from a proof that the map preserves\nthe operation `λ a b, a + -b`. See also `add_monoid_hom.of_map_sub` for a version using\n`λ a b, a - b`.\"]\ndef of_map_mul_inv {H : Type*} [group H] (f : G → H)\n  (map_div : ∀ a b : G, f (a * b⁻¹) = f a * (f b)⁻¹) :\n  G →* H :=\nmk' f $ λ x y,\ncalc f (x * y) = f x * (f $ 1 * 1⁻¹ * y⁻¹)⁻¹ : by simp only [one_mul, inv_one, ← map_div, inv_inv]\n... = f x * f y : by { simp only [map_div], simp only [mul_right_inv, one_mul, inv_inv] }\n\n@[simp, to_additive] lemma coe_of_map_mul_inv {H : Type*} [group H] (f : G → H)\n  (map_div : ∀ a b : G, f (a * b⁻¹) = f a * (f b)⁻¹) :\n  ⇑(of_map_mul_inv f map_div) = f :=\nrfl\n\n/-- Define a morphism of additive groups given a map which respects ratios. -/\n@[to_additive /-\"Define a morphism of additive groups given a map which respects difference.\"-/]\ndef of_map_div {H : Type*} [group H] (f : G → H) (hf : ∀ x y, f (x / y) = f x / f y) : G →* H :=\nof_map_mul_inv f (by simpa only [div_eq_mul_inv] using hf)\n\n@[simp, to_additive]\nlemma coe_of_map_div {H : Type*} [group H] (f : G → H) (hf : ∀ x y, f (x / y) = f x / f y) :\n  ⇑(of_map_div f hf) = f :=\nrfl\n\n/-- If `f` is a monoid homomorphism to a commutative group, then `f⁻¹` is the homomorphism sending\n`x` to `(f x)⁻¹`. -/\n@[to_additive]\ninstance {M G} [mul_one_class M] [comm_group G] : has_inv (M →* G) :=\n⟨λ f, mk' (λ g, (f g)⁻¹) $ λ a b, by rw [←mul_inv, f.map_mul]⟩\n\n/-- If `f` is an additive monoid homomorphism to an additive commutative group, then `-f` is the\nhomomorphism sending `x` to `-(f x)`. -/\nadd_decl_doc add_monoid_hom.has_neg\n\n@[simp, to_additive] lemma inv_apply {M G} {mM : mul_one_class M} {gG : comm_group G}\n  (f : M →* G) (x : M) :\n  f⁻¹ x = (f x)⁻¹ := rfl\n\n@[simp, to_additive] lemma inv_comp {M N A} {mM : mul_one_class M} {gN : mul_one_class N}\n  {gA : comm_group A} (φ : N →* A) (ψ : M →* N) : φ⁻¹.comp ψ = (φ.comp ψ)⁻¹ :=\nby { ext, simp only [function.comp_app, inv_apply, coe_comp] }\n\n@[simp, to_additive] lemma comp_inv {M A B} {mM : mul_one_class M} {mA : comm_group A}\n  {mB : comm_group B} (φ : A →* B) (ψ : M →* A) : φ.comp ψ⁻¹ = (φ.comp ψ)⁻¹ :=\nby { ext, simp only [function.comp_app, inv_apply, map_inv, coe_comp] }\n\n/-- If `f` and `g` are monoid homomorphisms to a commutative group, then `f / g` is the homomorphism\nsending `x` to `(f x) / (g x)`. -/\n@[to_additive]\ninstance {M G} [mul_one_class M] [comm_group G] : has_div (M →* G) :=\n⟨λ f g, mk' (λ x, f x / g x) $ λ a b,\n  by simp [div_eq_mul_inv, mul_assoc, mul_left_comm, mul_comm]⟩\n\n/-- If `f` and `g` are monoid homomorphisms to an additive commutative group, then `f - g`\nis the homomorphism sending `x` to `(f x) - (g x)`. -/\nadd_decl_doc add_monoid_hom.has_sub\n\n@[simp, to_additive] lemma div_apply {M G} {mM : mul_one_class M} {gG : comm_group G}\n  (f g : M →* G) (x : M) :\n  (f / g) x = f x / g x := rfl\n\nend monoid_hom\n\n/-- Given two monoid with zero morphisms `f`, `g` to a commutative monoid, `f * g` is the monoid\nwith zero morphism sending `x` to `f x * g x`. -/\ninstance {M N} {hM : mul_zero_one_class M} [comm_monoid_with_zero N] : has_mul (M →*₀ N) :=\n⟨λ f g,\n  { to_fun := λ a, f a * g a,\n    map_zero' := by rw [map_zero, zero_mul],\n    ..(f * g : M →* N) }⟩\n\nsection commute\n\nvariables [has_mul M] [has_mul N] {a x y : M}\n\n@[simp, to_additive]\nprotected lemma semiconj_by.map [mul_hom_class F M N] (h : semiconj_by a x y) (f : F) :\n  semiconj_by (f a) (f x) (f y) :=\nby simpa only [semiconj_by, map_mul] using congr_arg f h\n\n@[simp, to_additive]\nprotected lemma commute.map [mul_hom_class F M N] (h : commute x y) (f : F) :\n  commute (f x) (f y) :=\nh.map f\n\nend commute\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/hom/group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7401743677704878, "lm_q1q2_score": 0.4873437572072686}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport algebra.group.inj_surj\nimport algebra.group.commute\nimport algebra.hom.equiv.basic\nimport algebra.opposites\nimport data.int.cast.defs\n\n/-!\n# Group structures on the multiplicative and additive opposites\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\nuniverses u v\nvariables (α : Type u)\n\nnamespace mul_opposite\n\n/-!\n### Additive structures on `αᵐᵒᵖ`\n-/\n\n@[to_additive] instance [has_nat_cast α] : has_nat_cast αᵐᵒᵖ := ⟨λ n, op n⟩\n@[to_additive] instance [has_int_cast α] : has_int_cast αᵐᵒᵖ := ⟨λ n, op n⟩\n\ninstance [add_semigroup α] : add_semigroup (αᵐᵒᵖ) :=\nunop_injective.add_semigroup _ (λ x y, rfl)\n\ninstance [add_left_cancel_semigroup α] : add_left_cancel_semigroup αᵐᵒᵖ :=\nunop_injective.add_left_cancel_semigroup _ (λ x y, rfl)\n\ninstance [add_right_cancel_semigroup α] : add_right_cancel_semigroup αᵐᵒᵖ :=\nunop_injective.add_right_cancel_semigroup _ (λ x y, rfl)\n\ninstance [add_comm_semigroup α] : add_comm_semigroup αᵐᵒᵖ :=\nunop_injective.add_comm_semigroup _ (λ x y, rfl)\n\ninstance [add_zero_class α] : add_zero_class αᵐᵒᵖ :=\nunop_injective.add_zero_class _ rfl (λ x y, rfl)\n\ninstance [add_monoid α] : add_monoid αᵐᵒᵖ :=\nunop_injective.add_monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_comm_monoid α] : add_comm_monoid αᵐᵒᵖ :=\nunop_injective.add_comm_monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_monoid_with_one α] : add_monoid_with_one αᵐᵒᵖ :=\n{ nat_cast_zero := show op ((0 : ℕ) : α) = 0, by rw [nat.cast_zero, op_zero],\n  nat_cast_succ := show ∀ n, op ((n + 1 : ℕ) : α) = op (n : ℕ) + 1, by simp,\n  .. mul_opposite.add_monoid α, .. mul_opposite.has_one α, ..mul_opposite.has_nat_cast _ }\n\ninstance [add_comm_monoid_with_one α] : add_comm_monoid_with_one αᵐᵒᵖ :=\n{ .. mul_opposite.add_monoid_with_one α, ..mul_opposite.add_comm_monoid α }\n\ninstance [sub_neg_monoid α] : sub_neg_monoid αᵐᵒᵖ :=\nunop_injective.sub_neg_monoid _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_group α] : add_group αᵐᵒᵖ :=\nunop_injective.add_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_comm_group α] : add_comm_group αᵐᵒᵖ :=\nunop_injective.add_comm_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_group_with_one α] : add_group_with_one αᵐᵒᵖ :=\n{ int_cast := λ n, op n,\n  int_cast_of_nat := λ n, show op ((n : ℤ) : α) = op n, by rw int.cast_coe_nat,\n  int_cast_neg_succ_of_nat := λ n, show op _ = op (- unop (op ((n + 1 : ℕ) : α))),\n    by erw [unop_op, int.cast_neg_succ_of_nat]; refl,\n  .. mul_opposite.add_monoid_with_one α, .. mul_opposite.add_group α }\n\ninstance [add_comm_group_with_one α] : add_comm_group_with_one αᵐᵒᵖ :=\n{ .. mul_opposite.add_group_with_one α, ..mul_opposite.add_comm_group α }\n\n/-!\n### Multiplicative structures on `αᵐᵒᵖ`\n\nWe also generate additive structures on `αᵃᵒᵖ` using `to_additive`\n-/\n\n@[to_additive] instance [semigroup α] : semigroup αᵐᵒᵖ :=\n{ mul_assoc := λ x y z, unop_injective $ eq.symm $ mul_assoc (unop z) (unop y) (unop x),\n  .. mul_opposite.has_mul α }\n\n@[to_additive] instance [right_cancel_semigroup α] : left_cancel_semigroup αᵐᵒᵖ :=\n{ mul_left_cancel := λ x y z H, unop_injective $ mul_right_cancel $ op_injective H,\n  .. mul_opposite.semigroup α }\n\n@[to_additive] instance [left_cancel_semigroup α] : right_cancel_semigroup αᵐᵒᵖ :=\n{ mul_right_cancel := λ x y z H, unop_injective $ mul_left_cancel $ op_injective H,\n  .. mul_opposite.semigroup α }\n\n@[to_additive] instance [comm_semigroup α] : comm_semigroup αᵐᵒᵖ :=\n{ mul_comm := λ x y, unop_injective $ mul_comm (unop y) (unop x),\n  .. mul_opposite.semigroup α }\n\n@[to_additive] instance [mul_one_class α] : mul_one_class αᵐᵒᵖ :=\n{ one_mul := λ x, unop_injective $ mul_one $ unop x,\n  mul_one := λ x, unop_injective $ one_mul $ unop x,\n  .. mul_opposite.has_mul α, .. mul_opposite.has_one α }\n\n@[to_additive] instance [monoid α] : monoid αᵐᵒᵖ :=\n{ npow := λ n x, op $ x.unop ^ n,\n  npow_zero' := λ x, unop_injective $ monoid.npow_zero' x.unop,\n  npow_succ' := λ n x, unop_injective $ pow_succ' x.unop n,\n  .. mul_opposite.semigroup α, .. mul_opposite.mul_one_class α }\n\n@[to_additive] instance [right_cancel_monoid α] : left_cancel_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.left_cancel_semigroup α, .. mul_opposite.monoid α }\n\n@[to_additive] instance [left_cancel_monoid α] : right_cancel_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.right_cancel_semigroup α, .. mul_opposite.monoid α }\n\n@[to_additive] instance [cancel_monoid α] : cancel_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.right_cancel_monoid α, .. mul_opposite.left_cancel_monoid α }\n\n@[to_additive] instance [comm_monoid α] : comm_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.monoid α, .. mul_opposite.comm_semigroup α }\n\n@[to_additive] instance [cancel_comm_monoid α] : cancel_comm_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.cancel_monoid α, .. mul_opposite.comm_monoid α }\n\n@[to_additive add_opposite.sub_neg_monoid] instance [div_inv_monoid α] : div_inv_monoid αᵐᵒᵖ :=\n{ zpow := λ n x, op $ x.unop ^ n,\n  zpow_zero' := λ x, unop_injective $ div_inv_monoid.zpow_zero' x.unop,\n  zpow_succ' := λ n x, unop_injective $\n    by rw [unop_op, zpow_of_nat, zpow_of_nat, pow_succ', unop_mul, unop_op],\n  zpow_neg' := λ z x, unop_injective $ div_inv_monoid.zpow_neg' z x.unop,\n  .. mul_opposite.monoid α, .. mul_opposite.has_inv α }\n\n@[to_additive add_opposite.subtraction_monoid] instance [division_monoid α] :\n  division_monoid αᵐᵒᵖ :=\n{ mul_inv_rev := λ a b, unop_injective $ mul_inv_rev _ _,\n  inv_eq_of_mul := λ a b h, unop_injective $ inv_eq_of_mul_eq_one_left $ congr_arg unop h,\n  .. mul_opposite.div_inv_monoid α, .. mul_opposite.has_involutive_inv α }\n\n@[to_additive add_opposite.subtraction_comm_monoid] instance [division_comm_monoid α] :\n  division_comm_monoid αᵐᵒᵖ :=\n{ ..mul_opposite.division_monoid α, ..mul_opposite.comm_semigroup α }\n\n@[to_additive] instance [group α] : group αᵐᵒᵖ :=\n{ mul_left_inv := λ x, unop_injective $ mul_inv_self $ unop x,\n  .. mul_opposite.div_inv_monoid α, }\n\n@[to_additive] instance [comm_group α] : comm_group αᵐᵒᵖ :=\n{ .. mul_opposite.group α, .. mul_opposite.comm_monoid α }\n\nvariable {α}\n\n@[simp, norm_cast, to_additive] lemma op_nat_cast [has_nat_cast α] (n : ℕ) : op (n : α) = n := rfl\n@[simp, norm_cast, to_additive] lemma op_int_cast [has_int_cast α] (n : ℤ) : op (n : α) = n := rfl\n\n@[simp, norm_cast, to_additive]\nlemma unop_nat_cast [has_nat_cast α] (n : ℕ) : unop (n : αᵐᵒᵖ) = n := rfl\n\n@[simp, norm_cast, to_additive]\nlemma unop_int_cast [has_int_cast α] (n : ℤ) : unop (n : αᵐᵒᵖ) = n := rfl\n\n@[simp, to_additive] lemma unop_div [div_inv_monoid α] (x y : αᵐᵒᵖ) :\n  unop (x / y) = (unop y)⁻¹ * unop x :=\nrfl\n\n@[simp, to_additive] lemma op_div [div_inv_monoid α] (x y : α) :\n  op (x / y) = (op y)⁻¹ * op x :=\nby simp [div_eq_mul_inv]\n\n@[simp, to_additive] lemma semiconj_by_op [has_mul α] {a x y : α} :\n  semiconj_by (op a) (op y) (op x) ↔ semiconj_by a x y :=\nby simp only [semiconj_by, ← op_mul, op_inj, eq_comm]\n\n@[simp, to_additive] lemma semiconj_by_unop [has_mul α] {a x y : αᵐᵒᵖ} :\n  semiconj_by (unop a) (unop y) (unop x) ↔ semiconj_by a x y :=\nby conv_rhs { rw [← op_unop a, ← op_unop x, ← op_unop y, semiconj_by_op] }\n\n@[to_additive] lemma _root_.semiconj_by.op [has_mul α] {a x y : α} (h : semiconj_by a x y) :\n  semiconj_by (op a) (op y) (op x) :=\nsemiconj_by_op.2 h\n\n@[to_additive] lemma _root_.semiconj_by.unop [has_mul α] {a x y : αᵐᵒᵖ} (h : semiconj_by a x y) :\n  semiconj_by (unop a) (unop y) (unop x) :=\nsemiconj_by_unop.2 h\n\n@[to_additive] lemma _root_.commute.op [has_mul α] {x y : α} (h : commute x y) :\n  commute (op x) (op y) := h.op\n\n@[to_additive] lemma commute.unop [has_mul α] {x y : αᵐᵒᵖ} (h : commute x y) :\n  commute (unop x) (unop y) := h.unop\n\n@[simp, to_additive] lemma commute_op [has_mul α] {x y : α} :\n  commute (op x) (op y) ↔ commute x y :=\nsemiconj_by_op\n\n@[simp, to_additive] lemma commute_unop [has_mul α] {x y : αᵐᵒᵖ} :\n  commute (unop x) (unop y) ↔ commute x y :=\nsemiconj_by_unop\n\n/-- The function `mul_opposite.op` is an additive equivalence. -/\n@[simps { fully_applied := ff, simp_rhs := tt }]\ndef op_add_equiv [has_add α] : α ≃+ αᵐᵒᵖ :=\n{ map_add' := λ a b, rfl, .. op_equiv }\n\n@[simp] lemma op_add_equiv_to_equiv [has_add α] :\n  (op_add_equiv : α ≃+ αᵐᵒᵖ).to_equiv = op_equiv :=\nrfl\n\nend mul_opposite\n\n/-!\n### Multiplicative structures on `αᵃᵒᵖ`\n-/\n\nnamespace add_opposite\n\ninstance [semigroup α] : semigroup (αᵃᵒᵖ) :=\nunop_injective.semigroup _ (λ x y, rfl)\n\ninstance [left_cancel_semigroup α] : left_cancel_semigroup αᵃᵒᵖ :=\nunop_injective.left_cancel_semigroup _ (λ x y, rfl)\n\ninstance [right_cancel_semigroup α] : right_cancel_semigroup αᵃᵒᵖ :=\nunop_injective.right_cancel_semigroup _ (λ x y, rfl)\n\ninstance [comm_semigroup α] : comm_semigroup αᵃᵒᵖ :=\nunop_injective.comm_semigroup _ (λ x y, rfl)\n\ninstance [mul_one_class α] : mul_one_class αᵃᵒᵖ :=\nunop_injective.mul_one_class _ rfl (λ x y, rfl)\n\ninstance {β} [has_pow α β] : has_pow αᵃᵒᵖ β := { pow := λ a b, op (unop a ^ b) }\n\n@[simp] lemma op_pow {β} [has_pow α β] (a : α) (b : β) : op (a ^ b) = op a ^ b := rfl\n@[simp] lemma unop_pow {β} [has_pow α β] (a : αᵃᵒᵖ) (b : β) : unop (a ^ b) = unop a ^ b := rfl\n\ninstance [monoid α] : monoid αᵃᵒᵖ :=\nunop_injective.monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [comm_monoid α] : comm_monoid αᵃᵒᵖ :=\nunop_injective.comm_monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [div_inv_monoid α] : div_inv_monoid αᵃᵒᵖ :=\nunop_injective.div_inv_monoid _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [group α] : group αᵃᵒᵖ :=\nunop_injective.group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [comm_group α] : comm_group αᵃᵒᵖ :=\nunop_injective.comm_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\n-- NOTE: `add_monoid_with_one α → add_monoid_with_one αᵃᵒᵖ` does not hold\n\ninstance [add_comm_monoid_with_one α] : add_comm_monoid_with_one αᵃᵒᵖ :=\n{ nat_cast_zero := show op ((0 : ℕ) : α) = 0, by rw [nat.cast_zero, op_zero],\n  nat_cast_succ := show ∀ n, op ((n + 1 : ℕ) : α) = op (n : ℕ) + 1, by simp [add_comm],\n  ..add_opposite.add_comm_monoid α, ..add_opposite.has_one, ..add_opposite.has_nat_cast _ }\n\ninstance [add_comm_group_with_one α] : add_comm_group_with_one αᵃᵒᵖ :=\n{ int_cast_of_nat := λ n, congr_arg op $ int.cast_of_nat n,\n  int_cast_neg_succ_of_nat := λ _, congr_arg op $ int.cast_neg_succ_of_nat _,\n  ..add_opposite.add_comm_monoid_with_one _, ..add_opposite.add_comm_group α,\n  ..add_opposite.has_int_cast α }\n\nvariable {α}\n\n/-- The function `add_opposite.op` is a multiplicative equivalence. -/\n@[simps { fully_applied := ff, simp_rhs := tt }]\ndef op_mul_equiv [has_mul α] : α ≃* αᵃᵒᵖ :=\n{ map_mul' := λ a b, rfl, .. op_equiv }\n\n@[simp] lemma op_mul_equiv_to_equiv [has_mul α] :\n  (op_mul_equiv : α ≃* αᵃᵒᵖ).to_equiv = op_equiv :=\nrfl\n\nend add_opposite\n\nopen mul_opposite\n\n/-- Inversion on a group is a `mul_equiv` to the opposite group. When `G` is commutative, there is\n`mul_equiv.inv`. -/\n@[to_additive \"Negation on an additive group is an `add_equiv` to the opposite group. When `G`\nis commutative, there is `add_equiv.inv`.\", simps { fully_applied := ff, simp_rhs := tt }]\ndef mul_equiv.inv' (G : Type*) [division_monoid G] : G ≃* Gᵐᵒᵖ :=\n{ map_mul' := λ x y, unop_injective $ mul_inv_rev x y,\n  .. (equiv.inv G).trans op_equiv }\n\n/-- A semigroup homomorphism `f : M →ₙ* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism to `Nᵐᵒᵖ`. -/\n@[to_additive \"An additive semigroup homomorphism `f : add_hom M N` such that `f x` additively\ncommutes with `f y` for all `x, y` defines an additive semigroup homomorphism to `Sᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.to_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M →ₙ* N)\n  (hf : ∀ x y, commute (f x) (f y)) : M →ₙ* Nᵐᵒᵖ :=\n{ to_fun := mul_opposite.op ∘ f,\n  map_mul' := λ x y, by simp [(hf x y).eq] }\n\n/-- A semigroup homomorphism `f : M →ₙ* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism from `Mᵐᵒᵖ`. -/\n@[to_additive \"An additive semigroup homomorphism `f : add_hom M N` such that `f x` additively\ncommutes with `f y` for all `x`, `y` defines an additive semigroup homomorphism from `Mᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.from_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M →ₙ* N)\n  (hf : ∀ x y, commute (f x) (f y)) : Mᵐᵒᵖ →ₙ* N :=\n{ to_fun := f ∘ mul_opposite.unop,\n  map_mul' := λ x y, (f.map_mul _ _).trans (hf _ _).eq }\n\n/-- A monoid homomorphism `f : M →* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism to `Nᵐᵒᵖ`. -/\n@[to_additive \"An additive monoid homomorphism `f : M →+ N` such that `f x` additively commutes\nwith `f y` for all `x, y` defines an additive monoid homomorphism to `Sᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.to_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M →* N)\n  (hf : ∀ x y, commute (f x) (f y)) : M →* Nᵐᵒᵖ :=\n{ to_fun := mul_opposite.op ∘ f,\n  map_one' := congr_arg op f.map_one,\n  map_mul' := λ x y, by simp [(hf x y).eq] }\n\n/-- A monoid homomorphism `f : M →* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism from `Mᵐᵒᵖ`. -/\n@[to_additive \"An additive monoid homomorphism `f : M →+ N` such that `f x` additively commutes\nwith `f y` for all `x`, `y` defines an additive monoid homomorphism from `Mᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.from_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M →* N)\n  (hf : ∀ x y, commute (f x) (f y)) : Mᵐᵒᵖ →* N :=\n{ to_fun := f ∘ mul_opposite.unop,\n  map_one' := f.map_one,\n  map_mul' := λ x y, (f.map_mul _ _).trans (hf _ _).eq }\n\n/-- The units of the opposites are equivalent to the opposites of the units. -/\n@[to_additive \"The additive units of the additive opposites are equivalent to the additive opposites\nof the additive units.\"]\ndef units.op_equiv {M} [monoid M] : (Mᵐᵒᵖ)ˣ ≃* (Mˣ)ᵐᵒᵖ :=\n{ to_fun := λ u, op ⟨unop u, unop ↑(u⁻¹), op_injective u.4, op_injective u.3⟩,\n  inv_fun := mul_opposite.rec $ λ u, ⟨op ↑(u), op ↑(u⁻¹), unop_injective $ u.4, unop_injective u.3⟩,\n  map_mul' := λ x y, unop_injective $ units.ext $ rfl,\n  left_inv := λ x, units.ext $ by simp,\n  right_inv := λ x, unop_injective $ units.ext $ rfl }\n\n@[simp, to_additive]\nlemma units.coe_unop_op_equiv {M} [monoid M] (u : (Mᵐᵒᵖ)ˣ) :\n  ((units.op_equiv u).unop : M) = unop (u : Mᵐᵒᵖ) :=\nrfl\n\n@[simp, to_additive]\nlemma units.coe_op_equiv_symm {M} [monoid M] (u : (Mˣ)ᵐᵒᵖ) :\n  (units.op_equiv.symm u : Mᵐᵒᵖ) = op (u.unop : M) :=\nrfl\n\n/-- A semigroup homomorphism `M →ₙ* N` can equivalently be viewed as a semigroup homomorphism\n`Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[to_additive \"An additive semigroup homomorphism `add_hom M N` can equivalently be viewed as an\nadditive semigroup homomorphism `add_hom Mᵃᵒᵖ Nᵃᵒᵖ`. This is the action of the (fully faithful)\n`ᵃᵒᵖ`-functor on morphisms.\", simps]\ndef mul_hom.op {M N} [has_mul M] [has_mul N] :\n  (M →ₙ* N) ≃ (Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun   := op ∘ f ∘ unop,\n                      map_mul' := λ x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := λ f, { to_fun   := unop ∘ f ∘ op,\n                      map_mul' := λ x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext x, simp } }\n\n/-- The 'unopposite' of a semigroup homomorphism `Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ`. Inverse to `mul_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive semigroup homomorphism `Mᵃᵒᵖ →ₙ+ Nᵃᵒᵖ`. Inverse\nto `add_hom.op`.\"]\ndef mul_hom.unop {M N} [has_mul M] [has_mul N] :\n  (Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ) ≃ (M →ₙ* N) := mul_hom.op.symm\n\n/-- An additive semigroup homomorphism `add_hom M N` can equivalently be viewed as an additive\nhomomorphism `add_hom Mᵐᵒᵖ Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on\nmorphisms. -/\n@[simps]\ndef add_hom.mul_op {M N} [has_add M] [has_add N] :\n  (add_hom M N) ≃ (add_hom Mᵐᵒᵖ Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun    := op ∘ f ∘ unop,\n                      map_add'  := λ x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := λ f, { to_fun    := unop ∘ f ∘ op,\n                      map_add'  := λ x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive semigroup hom `αᵐᵒᵖ →+ βᵐᵒᵖ`. Inverse to\n`add_hom.mul_op`. -/\n@[simp] def add_hom.mul_unop {α β} [has_add α] [has_add β] :\n  (add_hom αᵐᵒᵖ βᵐᵒᵖ) ≃ (add_hom α β) := add_hom.mul_op.symm\n\n/-- A monoid homomorphism `M →* N` can equivalently be viewed as a monoid homomorphism\n`Mᵐᵒᵖ →* Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[to_additive \"An additive monoid homomorphism `M →+ N` can equivalently be viewed as an\nadditive monoid homomorphism `Mᵃᵒᵖ →+ Nᵃᵒᵖ`. This is the action of the (fully faithful)\n`ᵃᵒᵖ`-functor on morphisms.\", simps]\ndef monoid_hom.op {M N} [mul_one_class M] [mul_one_class N] :\n  (M →* N) ≃ (Mᵐᵒᵖ →* Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun   := op ∘ f ∘ unop,\n                      map_one' := congr_arg op f.map_one,\n                      map_mul' := λ x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := λ f, { to_fun   := unop ∘ f ∘ op,\n                      map_one' := congr_arg unop f.map_one,\n                      map_mul' := λ x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext x, simp } }\n\n/-- The 'unopposite' of a monoid homomorphism `Mᵐᵒᵖ →* Nᵐᵒᵖ`. Inverse to `monoid_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive monoid homomorphism `Mᵃᵒᵖ →+ Nᵃᵒᵖ`. Inverse to\n`add_monoid_hom.op`.\"]\ndef monoid_hom.unop {M N} [mul_one_class M] [mul_one_class N] :\n  (Mᵐᵒᵖ →* Nᵐᵒᵖ) ≃ (M →* N) := monoid_hom.op.symm\n\n/-- An additive homomorphism `M →+ N` can equivalently be viewed as an additive homomorphism\n`Mᵐᵒᵖ →+ Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[simps]\ndef add_monoid_hom.mul_op {M N} [add_zero_class M] [add_zero_class N] :\n  (M →+ N) ≃ (Mᵐᵒᵖ →+ Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun    := op ∘ f ∘ unop,\n                      map_zero' := unop_injective f.map_zero,\n                      map_add'  := λ x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := λ f, { to_fun    := unop ∘ f ∘ op,\n                      map_zero' := congr_arg unop f.map_zero,\n                      map_add'  := λ x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive monoid hom `αᵐᵒᵖ →+ βᵐᵒᵖ`. Inverse to\n`add_monoid_hom.mul_op`. -/\n@[simp] def add_monoid_hom.mul_unop {α β} [add_zero_class α] [add_zero_class β] :\n  (αᵐᵒᵖ →+ βᵐᵒᵖ) ≃ (α →+ β) := add_monoid_hom.mul_op.symm\n\n/-- A iso `α ≃+ β` can equivalently be viewed as an iso `αᵐᵒᵖ ≃+ βᵐᵒᵖ`. -/\n@[simps]\ndef add_equiv.mul_op {α β} [has_add α] [has_add β] :\n  (α ≃+ β) ≃ (αᵐᵒᵖ ≃+ βᵐᵒᵖ) :=\n{ to_fun    := λ f, op_add_equiv.symm.trans (f.trans op_add_equiv),\n  inv_fun   := λ f, op_add_equiv.trans (f.trans op_add_equiv.symm),\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `αᵐᵒᵖ ≃+ βᵐᵒᵖ`. Inverse to `add_equiv.mul_op`. -/\n@[simp] def add_equiv.mul_unop {α β} [has_add α] [has_add β] :\n  (αᵐᵒᵖ ≃+ βᵐᵒᵖ) ≃ (α ≃+ β) := add_equiv.mul_op.symm\n\n/-- A iso `α ≃* β` can equivalently be viewed as an iso `αᵐᵒᵖ ≃* βᵐᵒᵖ`. -/\n@[to_additive \"A iso `α ≃+ β` can equivalently be viewed as an iso `αᵃᵒᵖ ≃+ βᵃᵒᵖ`.\", simps]\ndef mul_equiv.op {α β} [has_mul α] [has_mul β] :\n  (α ≃* β) ≃ (αᵐᵒᵖ ≃* βᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun   := op ∘ f ∘ unop,\n                      inv_fun  := op ∘ f.symm ∘ unop,\n                      left_inv := λ x, unop_injective (f.symm_apply_apply x.unop),\n                      right_inv := λ x, unop_injective (f.apply_symm_apply x.unop),\n                      map_mul' := λ x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := λ f, { to_fun   := unop ∘ f ∘ op,\n                      inv_fun  := unop ∘ f.symm ∘ op,\n                      left_inv := λ x, by simp,\n                      right_inv := λ x, by simp,\n                      map_mul' := λ x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `αᵐᵒᵖ ≃* βᵐᵒᵖ`. Inverse to `mul_equiv.op`. -/\n@[simp, to_additive \"The 'unopposite' of an iso `αᵃᵒᵖ ≃+ βᵃᵒᵖ`. Inverse to `add_equiv.op`.\"]\ndef mul_equiv.unop {α β} [has_mul α] [has_mul β] :\n  (αᵐᵒᵖ ≃* βᵐᵒᵖ) ≃ (α ≃* β) := mul_equiv.op.symm\n\nsection ext\n\n/-- This ext lemma change equalities on `αᵐᵒᵖ →+ β` to equalities on `α →+ β`.\nThis is useful because there are often ext lemmas for specific `α`s that will apply\nto an equality of `α →+ β` such as `finsupp.add_hom_ext'`. -/\n@[ext]\nlemma add_monoid_hom.mul_op_ext {α β} [add_zero_class α] [add_zero_class β]\n  (f g : αᵐᵒᵖ →+ β)\n  (h : f.comp (op_add_equiv : α ≃+ αᵐᵒᵖ).to_add_monoid_hom =\n       g.comp (op_add_equiv : α ≃+ αᵐᵒᵖ).to_add_monoid_hom) : f = g :=\nadd_monoid_hom.ext $ mul_opposite.rec $ λ x, (add_monoid_hom.congr_fun h : _) x\n\nend ext\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/group/opposite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.48734375580843636}}
{"text": "import analysis.special_functions.pow\nimport analysis.special_functions.log.basic\nimport analysis.specific_limits.basic\nimport category_theory.Fintype\nimport analysis.normed_space.basic\n\nimport laurent_measures.bounded\nimport pseudo_normed_group.basic\nimport pseudo_normed_group.category\n\nuniverse u\n\nnoncomputable theory\nopen_locale big_operators nnreal classical\n\n/-\nstructure c_measures (r : ℝ≥0) (c : ℝ≥0) (S : Fintype) :=\n(to_fun     : S → ℤ → ℤ)\n(summable   : ∀ s, summable (λ n, (∥ to_fun s n ∥₊ * r ^ n)))\n(bdd        : ∀ s, tsum (λ n, (∥ to_fun s n ∥₊ * r ^ n)) ≤ c)\n-/\n\n/-- A term of type `laurent_measures r S` is, for each `s : S`, a function `φ : ℤ → ℤ`\n  (typically thought of as a power series `∑ φ(n)Tⁿ`) such that `∑ |φ(n)|rⁿ` converges.\n  Note that if `0<r<1` then the support of φ can only contain finitely many negative integers.  -/\nstructure laurent_measures (r : ℝ≥0) (S : Fintype) :=\n(to_fun    : S → ℤ → ℤ)\n(summable' : ∀ s, summable (λ n, ∥to_fun s n∥₊ * r ^ n))\n\nvariables {r : ℝ≥0} {S S' : Fintype.{u}}\n\nlocal notation `ℒ` := laurent_measures r\n\nnamespace laurent_measures\n\ninstance : has_coe_to_fun (ℒ S) (λ F, S → ℤ → ℤ) :=\n⟨λ F, F.to_fun⟩\n\n@[simp] lemma coe_mk (f : S → ℤ → ℤ) (hf) (s : S) (n : ℤ) :\n  (@laurent_measures.mk r S f hf) s n = f s n := rfl\n\n@[ext]\nlemma ext (F G : ℒ S) : (F : S → ℤ → ℤ) = G → F = G :=\nby { intros h, cases F, cases G, simpa }\n\nlemma ext_iff (F G : ℒ S) : F = G ↔ ∀ s n, F s n = G s n :=\n⟨λ h, by intros; rw h, λ h, laurent_measures.ext F G $ by ext; apply h⟩\n\nprotected lemma nnreal_summable (F : ℒ S) (s : S) : summable (λ n, ∥F s n∥₊ * r ^ n) :=\nF.2 _\n\nprotected lemma summable (F : ℒ S) (s : S) : summable (λ n, ∥F s n∥ * r ^ n) :=\nbegin\n  simpa only [← nnreal.summable_coe, nnreal.coe_mul, coe_nnnorm, nnreal.coe_zpow]\n    using F.nnreal_summable s\nend\n\n-- Move me\nlemma nonneg_of_norm_mul_zpow (k n : ℤ) (r : ℝ≥0) : 0 ≤ ∥ k ∥ * (r : ℝ)^n :=\nmul_nonneg (norm_nonneg _) (zpow_nonneg (nnreal.coe_nonneg _) _)\n\ndef map (f : S ⟶ S') : ℒ S → ℒ S' := λ F,\n{ to_fun := λ s' k, ∑ s in finset.univ.filter (λ t, f t = s'), F s k,\n  summable' := begin\n    intros s',\n    have : ∀ n : ℤ, ∥∑ s in finset.univ.filter (λ t, f t = s'), F s n∥₊ * r^n ≤\n      ∑ s in finset.univ.filter (λ t, f t = s'), ∥F s n∥₊ * r^n := λ n,\n    calc ∥∑ s in finset.univ.filter (λ t, f t = s'), F s n∥₊ * r^n ≤\n      (∑ s in finset.univ.filter (λ t, f t = s'), ∥F s n∥₊) * r^n :\n        mul_le_mul' (nnnorm_sum_le _ _) le_rfl\n      ... = _ : by rw finset.sum_mul,\n    exact nnreal.summable_of_le this (summable_sum $ λ (s : S) _, F.nnreal_summable s),\n  end }\n\n@[simp] lemma map_apply (f : S ⟶ S') (F : ℒ S) (s' : S') (k : ℤ) :\n  map f F s' k = ∑ s in finset.univ.filter (λ t, f t = s'), F s k := rfl\n\n@[simp] lemma map_id : (map (𝟙 S) : ℒ S → ℒ S) = id :=\nbegin\n  ext F s k,\n  simp only [map_apply, Fintype.id_apply, id.def, finset.sum_filter,\n    finset.sum_ite_eq', finset.mem_univ, if_true],\nend\n\n@[simp] lemma map_comp {S'' : Fintype.{u}} (f : S ⟶ S') (g : S' ⟶ S'') :\n  (map (f ≫ g) : ℒ S → ℒ S'') = map g ∘ map f :=\nbegin\n  ext F s k,\n  simp only [function.comp_app, map_apply, finset.sum_congr],\n  rw ← finset.sum_bUnion,\n  { apply finset.sum_congr,\n    { change finset.univ.filter (λ t, g (f t) = s) = _,\n      ext i,\n      split;\n      { intro hi, simpa only [finset.mem_bUnion, finset.mem_filter, finset.mem_univ, true_and,\n          exists_prop, exists_eq_right'] using hi } },\n    { intros, refl } },\n  { intros i hi j hj h k hk,\n    simp only [finset.inf_eq_inter, finset.mem_inter, finset.mem_filter, finset.mem_univ, true_and,\n      finset.coe_filter, finset.coe_univ, set.sep_univ, set.mem_set_of_eq] at hi hj hk,\n    refine h _,\n    rw [← hk.1, ← hk.2] }\nend\n\ndef add : ℒ S → ℒ S → ℒ S := λ F G,\n{ to_fun := F + G,\n  summable' := λ s, begin\n    refine nnreal.summable_of_le _ ((F.nnreal_summable s).add (G.nnreal_summable s)),\n    intros n,\n    rw ← add_mul,\n    exact mul_le_mul' (nnnorm_add_le _ _) le_rfl,\n  end }\n\ninstance : has_add (ℒ S) := ⟨add⟩\n\n@[simp]\nlemma add_apply (F G : ℒ S) (s : S) (n : ℤ) : (F + G) s n = F s n + G s n := rfl\n\ndef zero : ℒ S :=\n{ to_fun := 0,\n  summable' := λ s, by simp [summable_zero] }\n\ninstance : has_zero (ℒ S) := ⟨zero⟩\n\n@[simp] lemma zero_apply (s : S) (n : ℤ) : (0 : ℒ S) s n = 0 := rfl\n\ndef neg : ℒ S → ℒ S := λ F,\n{ to_fun := - F,\n  summable' := λ s, by simp [F.nnreal_summable] }\n\ninstance : has_neg (ℒ S) := ⟨neg⟩\n\n@[simp] lemma neg_apply (F : ℒ S) (s : S) (n : ℤ) : (-F) s n = - (F s n) := rfl\n\ndef sub : ℒ S → ℒ S → ℒ S := λ F G,\n{ to_fun := F - G,\n  summable' := (add F (neg G)).nnreal_summable }\n\ninstance : has_sub (ℒ S) := ⟨sub⟩\n\n@[simp] lemma sub_apply (F G : ℒ S) (s : S) (n : ℤ) : (F - G) s n = F s n - G s n := rfl\n\nexample (a m : ℤ) : (-a)*m=a*(-m) := neg_mul_comm a m\n\n-- move me\ninstance : has_continuous_smul ℕ ℝ≥0 :=\n{ continuous_smul := begin\n    let f : ℕ × ℝ≥0 → ℝ≥0 × ℝ≥0 := prod.map coe id,\n    have hf : continuous f := continuous.prod_map continuous_bot continuous_id,\n    simpa only [nsmul_eq_mul] using continuous_mul.comp hf,\nend }\n\n-- move me\n@[simp] lemma _root_.int.norm_mul (m n : ℤ) : ∥m * n∥ = ∥m∥ * ∥n∥ :=\nby simp only [int.norm_eq_abs, int.cast_mul, abs_mul]\n\n-- move me\n@[simp] lemma _root_.int.nnnorm_mul (m n : ℤ) : ∥m * n∥₊ = ∥m∥₊ * ∥n∥₊ :=\nby ext; simp only [coe_nnnorm, int.norm_mul, nonneg.coe_mul]\n\n-- move me\n@[simp] lemma _root_.nat.norm_coe_int (n : ℕ) : ∥(n : ℤ)∥ = n :=\nby simp only [int.norm_eq_abs, int.cast_coe_nat, nat.abs_cast]\n\n-- move me\n@[simp] lemma _root_.nat.nnnorm_coe_int (n : ℕ) : ∥(n : ℤ)∥₊ = n :=\nby ext; simp only [coe_nnnorm, nat.norm_coe_int, nnreal.coe_nat_cast]\n\ninstance : add_comm_monoid (ℒ S) :=\n{ add_assoc := λ a b c, by { ext, simp only [add_assoc, add_apply] },\n  add_comm := λ F G, by { ext, simp only [add_comm, add_apply] },\n  zero_add := λ a, by { ext, simp only [zero_add, add_apply, zero_apply] },\n  add_zero := λ a, by { ext, simp only [add_zero, add_apply, zero_apply] },\n  nsmul := λ n F,\n  { to_fun := λ s k, n • (F s k),\n    summable' := λ s, begin\n      -- aahrg, why is `n` an implicit variable here???\n      have := @summable.const_smul _ _ _ _ _ _ _ _ _ n (F.nnreal_summable s),\n      simpa only [nsmul_eq_mul, int.nnnorm_mul, nat.nnnorm_coe_int, mul_assoc],\n    end },\n  nsmul_zero' := λ F, by { ext, refl },\n  nsmul_succ' := λ n F, by { ext, refl },\n  ..(infer_instance : has_add _),\n  ..(infer_instance : has_zero _) }\n\ninstance : add_comm_group (ℒ S) :=\n{ neg := neg,\n  sub := sub,\n  sub_eq_add_neg := λ F G, by { ext, refl },\n  zsmul := λ n F,\n  { to_fun := λ s m, n • (F s m),\n    summable' := λ s, begin\n      -- aahrg, why is `n.nat_abs` an implicit variable here???\n      have := @summable.const_smul _ _ _ _ _ _ _ _ _ n.nat_abs (F.nnreal_summable s),\n      simpa only [nsmul_eq_mul, nnreal.coe_nat_abs, algebra.id.smul_eq_mul,\n        int.nnnorm_mul, mul_assoc],\n    end },\n  zsmul_zero' := λ F, by { ext, simp only [algebra.id.smul_eq_mul, zero_mul, coe_mk, zero_apply], },\n  zsmul_succ' := λ n F, by { ext, simp only [add_apply, int.coe_nat_succ, int.of_nat_eq_coe,\n    zsmul_eq_smul, smul_eq_mul, add_mul, add_comm, one_mul, coe_mk], },\n  zsmul_neg' := λ n F, by { ext, rw neg_apply, simp only [neg_apply, int.coe_nat_succ, int.of_nat_eq_coe,\n    int.neg_succ_of_nat_coe, add_comm, zsmul_eq_smul, smul_eq_mul], dsimp, ring_nf},\n  add_left_neg := λ F, by { ext, simp only [zero_apply, add_apply, neg_apply, add_left_neg], },\n  add_comm := λ a b, by { ext, dsimp, rw add_comm },\n  ..(infer_instance : add_comm_monoid _),\n  ..(infer_instance : has_neg _),\n  ..(infer_instance : has_sub _) }.\n\ninstance : has_norm (ℒ S) :=\n⟨λ F, ∑ s, ∑' n, ∥F s n∥ * (r : ℝ) ^ n⟩\n\nlemma norm_def (F : ℒ S) : ∥F∥ = ∑ s, ∑' n, ∥F s n∥ * (r : ℝ)^n := rfl\n\ninstance : has_nnnorm (ℒ S) :=\n⟨λ F, ∑ s, ∑' n, ∥F s n∥₊ * r ^ n⟩\n\nlemma nnnorm_def (F : ℒ S) : ∥F∥₊ = ∑ s, ∑' n, ∥F s n∥₊ * r^n := rfl\n\n@[simp] lemma coe_nnnorm (F : ℒ S) : (∥F∥₊ : ℝ) = ∥F∥ :=\nby simp only [nnnorm_def, norm_def, nnreal.coe_sum, nnreal.coe_tsum,\n  nonneg.coe_mul, coe_nnnorm, nnreal.coe_zpow]\n\n@[simp] lemma laurent_measures.norm_nonneg (F : ℒ S) : 0 ≤ ∥F∥ :=\nby rw [← coe_nnnorm]; exact ∥F∥₊.coe_nonneg\n\n@[simp] lemma nnnorm_neg (F : ℒ S) : ∥-F∥₊ = ∥F∥₊ :=\nby simp only [nnnorm_def, neg_apply, nnnorm_neg]\n\nlemma nnnorm_add (F G : ℒ S) : ∥F + G∥₊ ≤ ∥F∥₊ + ∥G∥₊ :=\nbegin\n  simp only [nnnorm_def, ← finset.sum_add_distrib],\n  apply finset.sum_le_sum,\n  rintro s -,\n  rw ← tsum_add (F.nnreal_summable _) (G.nnreal_summable _),\n  refine tsum_le_tsum _ ((F + G).nnreal_summable _)\n    ((F.nnreal_summable s).add (G.nnreal_summable s)),\n  intro b,\n  simp [← add_mul],\n  refine mul_le_mul' (nnnorm_add_le _ _) le_rfl\nend\n\nlemma norm_add (F G : ℒ S) : ∥F + G∥ ≤ ∥F∥ + ∥G∥ :=\nby simpa only [← coe_nnnorm, ← nnreal.coe_add, nnreal.coe_le_coe] using nnnorm_add F G\n\n@[simp] lemma nsmul_apply (k : ℕ) (F : ℒ S) (s : S) (n : ℤ) : (k • F) s n = k • (F s n) := rfl\n\n@[simp] lemma zsmul_apply (k : ℤ) (F : ℒ S) (s : S) (n : ℤ) : (k • F) s n = k • (F s n) := rfl\n\nsection\nopen finset\n\nlemma map_bound (f : S ⟶ S') (F : ℒ S) : ∥map f F∥₊ ≤ ∥F∥₊ := calc\n∥map f F∥₊ = ∑ s', ∑' n, ∥∑ s in univ.filter (λ t, f t = s'), F s n∥₊ * _ : rfl\n... ≤ ∑ s', ∑' n, ∑ s in univ.filter (λ t, f t = s'), ∥F s n∥₊ * r^n : begin\n  apply sum_le_sum,\n  rintros s' -,\n  have h1 : summable (λ n : ℤ, ∑ (s : S.α) in univ.filter (λ t, f t = s'), ∥F s n∥₊ * r^n) :=\n    summable_sum (λ s _, F.nnreal_summable s),\n  have h2 : ∀ b : ℤ,\n    ∥∑ (s : S.α) in univ.filter (λ t, f t = s'), F s b∥₊ * r ^ b ≤\n      ∑ (s : S.α) in univ.filter (λ t, f t = s'), ∥F s b∥₊ * r ^ b,\n  { intros b, rw ← sum_mul, exact mul_le_mul' (nnnorm_sum_le _ _) le_rfl },\n  apply tsum_le_tsum h2 (nnreal.summable_of_le h2 h1) h1,\nend\n... = ∑ s', ∑ s in univ.filter (λ t, f t = s'), ∑' n, ∥F s n∥₊ * r^n :\n  sum_congr rfl (λ s' _, tsum_sum $ λ s _, F.nnreal_summable _)\n... = _ : begin\n  rw [← sum_bUnion],\n  refine sum_congr _ _,\n  { ext s, simp only [mem_bUnion, mem_univ, mem_filter, true_and, exists_true_left, exists_eq'] },\n  { intros, refl },\n  { rintro x - y - h i hi,\n    apply h,\n    simp only [inf_eq_inter, mem_inter, mem_filter, mem_univ, true_and] at hi,\n    rw [← hi.1, ← hi.2] }\nend\n\nend\n\nlemma map_bound' (f : S ⟶ S') (F : ℒ S) : ∥map f F∥ ≤ ∥F∥ :=\nby simpa only [← coe_nnnorm, ← nnreal.coe_add, nnreal.coe_le_coe] using map_bound f F\n\n\n/-\nlemma exists_c (F : ℒ S) : ∃ (c : ℝ≥0),\n  ∀ s : S, ∑' n, ∥ F s n ∥ * r ^ n ≤ c :=\nbegin\n  use ∑ s, ∑' n, ∥ F s n ∥ * r ^ n,\n  { apply finset.sum_nonneg,\n    rintros s -,\n    apply tsum_nonneg,\n    intros n,\n    refine mul_nonneg (norm_nonneg _) (zpow_nonneg _ _),\n    exact nnreal.coe_nonneg r, },\n  { admit },\nend\n-/\n\n/-- This lemma puts bounds on where `F s n` can be nonzero. -/\nlemma eq_zero_of_filtration (F : ℒ S) (c : ℝ≥0) :\n  ∥F∥₊ ≤ c → ∀ (s : S) (n : ℤ), c < r^n → F s n = 0 :=\nbegin\n  intros hF s n h,\n  suffices : ∥F s n∥₊ < 1,\n  { change abs (F s n : ℝ) < 1 at this,\n    norm_cast at this,\n    rwa ← int.abs_lt_one_iff },\n  have : ∥F s n∥₊ * r ^ n ≤ ∑' k, ∥F s k∥₊ * r ^ k,\n  { exact le_tsum (F.nnreal_summable s) _ (λ k _, zero_le'), },\n  replace this := lt_of_le_of_lt (this.trans _) h,\n  { have hr₁ : 0 < r^n := lt_of_le_of_lt zero_le' h,\n    have hr₂ : r^n ≠ 0 := hr₁.ne',\n    convert mul_lt_mul this (le_refl (r ^ n)⁻¹) _ hr₁.le,\n    { exact (mul_inv_cancel_right₀ hr₂ _).symm },\n    { exact (mul_inv_cancel hr₂).symm },\n    { rwa nnreal.inv_pos }, },\n  { refine le_trans _ hF,\n    apply @finset.single_le_sum S ℝ≥0 _ (λ s, ∑' n, ∥F s n∥₊ * r^n),\n    { rintros s -, exact zero_le', },\n    { exact finset.mem_univ _ } }\nend\n\n-- move me\nlemma zpow_strict_anti {K : Type} [linear_ordered_field K] {x : K} (hx₀ : 0 < x) (hx₁ : x < 1) :\n  strict_anti (λ n:ℤ, x ^ n) :=\nbegin\n  intros n m H,\n  rw [← inv_inv x],\n  simp only [inv_zpow x⁻¹, inv_lt_inv (zpow_pos_of_pos (inv_pos.mpr hx₀) _)\n    (zpow_pos_of_pos (inv_pos.mpr hx₀) _)],\n  exact zpow_strict_mono (one_lt_inv hx₀ hx₁) H,\nend\n\nopen real\n\n--For every F, d F is a bound whose existence is established in `eq_zero_of_filtration`\nlemma exists_bdd_filtration {S : Fintype} (hr₀ : 0 < (r : ℝ)) (hr₁ : (r : ℝ) < 1) (F : ℒ S) :\n  ∃ d : ℤ, ∀ s : S, ∀ (n : ℤ), n < d → F s n = 0 :=\nbegin\n  have h_logr : (log r) < 0 := log_neg hr₀ hr₁,\n  let d := if log ∥ F ∥ ≥ 0 then ⌊ (log ∥ F ∥ / log (r : ℝ)) ⌋ - 1 else -1,\n  use d,\n  intros s n hn,\n  have H1 := zpow_strict_anti hr₀ hr₁ hn,\n  suffices H2 : ∥F∥₊ < r ^ d,\n  { refine eq_zero_of_filtration F (∥F∥₊) le_rfl s n (H2.trans _),\n    rw [← nnreal.coe_lt_coe, nnreal.coe_zpow, nnreal.coe_zpow],\n    exact zpow_strict_anti hr₀ hr₁ hn, },\n  have hd1 : 0 < -(d : ℝ),\n  { rw [lt_neg, neg_zero, ← int.cast_zero, int.cast_lt],\n    apply int.lt_of_le_sub_one,\n    dsimp only [d],\n    split_ifs,\n    { rw [tsub_le_iff_right, sub_add, sub_self, sub_zero],\n      exact int.floor_nonpos (div_nonpos_of_nonneg_of_nonpos h(le_of_lt h_logr)) },\n    { simp only [zero_sub] } },\n  have hFd1 : (log ∥ F ∥) < d * (log (r : ℝ)),\n  { rw ← zsmul_eq_mul,\n    rw ite_smul,\n    split_ifs,\n    { rw zsmul_eq_mul,\n      calc (log ∥F∥)\n          = (log ∥F∥/log r) * log r : (div_mul_cancel (log ∥F∥) (ne_of_lt h_logr)).symm\n      ... ≤ ⌊ (log ∥F∥)/log r⌋ * log r : (mul_le_mul_right_of_neg h_logr).mpr (int.floor_le _)\n      ... < (⌊ (log ∥F∥)/log r⌋ - 1) * log r : (mul_lt_mul_right_of_neg h_logr).mpr (sub_one_lt _)\n      ... = ↑(⌊ (log ∥F∥)/log r⌋ - 1) * log r : by simp only [int.cast_one, int.cast_sub] },\n    { rw [neg_smul, one_smul],\n      rw [ge_iff_le, not_le] at h,\n      apply h.trans,\n      rwa [lt_neg, neg_zero] } },\n  rw [← nnreal.coe_lt_coe, nnreal.coe_zpow, coe_nnnorm],\n  have := (real.lt_rpow_of_log_lt (laurent_measures.norm_nonneg F) hr₀ hFd1),\n  rwa [real.rpow_int_cast _ d] at this,\nend\n\ndef bdd_filtration {S : Fintype} (hr₀ : 0 < (r : ℝ)) (hr₁ : (r : ℝ) < 1) (F : ℒ S) : ℤ :=\n(exists_bdd_filtration hr₀ hr₁ F).some\n\ndef bdd_filtration_spec {S : Fintype} (hr₀ : 0 < (r : ℝ)) (hr₁ : (r : ℝ) < 1) (F : ℒ S) :\n∀ s n, n < bdd_filtration hr₀ hr₁ F → F s n = 0 := (exists_bdd_filtration hr₀ hr₁ F).some_spec\n\nsection profinite_structure\n\n@[simps] def truncate {c : ℝ≥0} (A : finset ℤ) :\n  { F : ℒ S | ∥F∥₊ ≤ c } → laurent_measures_bdd r S A c := λ F,\n{ to_fun := λ s i, F s i,\n  bound' := begin\n    refine (finset.sum_le_sum $ λ s _, _).trans F.2,\n    convert sum_le_tsum A _ ((F : ℒ S).nnreal_summable s) using 1,\n    { conv_rhs { rw ← finset.sum_attach }, refl },\n    { intros b hb, exact zero_le', },\n  end }\n\nlemma eq_iff_truncate_eq (c : ℝ≥0) (F G : {F : ℒ S | ∥F∥₊ ≤ c}) :\n  (∀ k, truncate k F = truncate k G) → F = G :=\nbegin\n  intros h,\n  ext s i,\n  specialize h {i},\n  apply_fun (λ e, e s ⟨i, by simp⟩) at h,\n  exact h,\nend\n\n\ndef finset_map {A B : finset ℤ} (h : B ≤ A) : B → A :=\nλ i, ⟨i, h i.2⟩\n\ndef transition {c : ℝ≥0} {A B : finset ℤ} (h : B ≤ A) :\n  laurent_measures_bdd r S A c → laurent_measures_bdd r S B c := λ F,\n⟨λ s i, F s (finset_map h i), begin\n  refine (finset.sum_le_sum $ λ s _, _).trans F.2,\n  have : ∑ i : B, ∥F s (finset_map h i)∥₊ * r^(i : ℤ) =\n    ∑ i in finset.univ.image (finset_map h), ∥F s i∥₊ * r^(i : ℤ),\n  { rw finset.sum_image,\n    { refl },\n    { rintros i - j - hh,\n      apply subtype.ext,\n      apply_fun (λ e, e.val) at hh,\n      exact hh } },\n  rw this,\n  refine finset.sum_le_sum_of_subset_of_nonneg (finset.subset_univ _) (λ _ _ _, zero_le'),\nend⟩\n\ndef mk_seq {c} (F : Π (A : finset ℤ), laurent_measures_bdd r S A c) :\n  S → ℤ → ℤ := λ s i, F {i} s ⟨i, by simp⟩\n\nlemma mk_seq_compat {c} (F : Π (A : finset ℤ), laurent_measures_bdd r S A c)\n  (compat : ∀ (A B : finset ℤ) (h : B ≤ A), transition h (F _) = F _) (s : S)\n  (A : finset ℤ) (i : A) : mk_seq F s i = F A s i :=\nbegin\n  have : ({i} : finset ℤ) ≤ A, { simp },\n  specialize compat _ _ this,\n  dsimp [mk_seq],\n  rw ← compat,\n  change (F A) s _ = _,\n  congr,\n  ext,\n  refl,\nend\n\nlemma mk_seq_compat_summable {c} (F : Π (A : finset ℤ), laurent_measures_bdd r S A c)\n  (compat : ∀ (A B : finset ℤ) (h : B ≤ A), transition h (F _) = F _) (s : S) :\n  summable (λ k : ℤ, ∥mk_seq F s k∥ * (r:ℝ)^k) :=\nbegin\n  apply summable_of_sum_le,\n  { intro k,\n    dsimp,\n    refine mul_nonneg (norm_nonneg _) (zpow_nonneg (nnreal.coe_nonneg _) _) },\n  { intros A,\n    rw ← finset.sum_attach,\n    refine le_trans _ (F A).bound,\n    simp_rw mk_seq_compat _ compat,\n    simp only [laurent_measures_bdd.nnnorm_def, finset.univ_eq_attach, nnreal.coe_sum,\n      nnreal.coe_mul, nnreal.coe_zpow],\n    apply @finset.single_le_sum S ℝ _ (λ s, ∑ (i : A), ∥ F A s i ∥ * (r : ℝ)^(i : ℤ)),\n    swap, { simp },\n    rintro s -,\n    apply finset.sum_nonneg,\n    rintros a -,\n    refine mul_nonneg (norm_nonneg _) (zpow_nonneg (nnreal.coe_nonneg _) _) },\nend\n\nlemma mk_seq_compat_nnreal_summable {c} (F : Π (A : finset ℤ), laurent_measures_bdd r S A c)\n  (compat : ∀ (A B : finset ℤ) (h : B ≤ A), transition h (F _) = F _) (s : S) :\n  summable (λ k : ℤ, ∥mk_seq F s k∥₊ * r^k) :=\nbegin\n  rw ← nnreal.summable_coe,\n  simpa only [nonneg.coe_mul, coe_nnnorm, nnreal.coe_zpow] using mk_seq_compat_summable F compat s\nend\n\nlemma mk_seq_compat_sum_le {c} (F : Π (A : finset ℤ), laurent_measures_bdd r S A c)\n  (compat : ∀ (A B : finset ℤ) (h : B ≤ A), transition h (F _) = F _)  :\n  ∑ (s : S), ∑' (k : ℤ), ∥mk_seq F s k∥₊ * r^k ≤ c :=\nbegin\n  rw ← tsum_sum,\n  swap, { intros s hs, apply mk_seq_compat_nnreal_summable _ compat },\n  have : ∀ A : finset ℤ,\n    ∑ (b : A), ∑ (s : S), ∥F A s b∥₊ * r^(b : ℤ) ≤ c,\n  { intros A,\n    rw finset.sum_comm,\n    exact (F A).bound },\n  apply tsum_le_of_sum_le,\n  { apply summable_sum,\n    intros s hs,\n    apply mk_seq_compat_nnreal_summable _ compat },\n  intros I,\n  rw finset.sum_comm,\n  convert (F I).bound using 1,\n  dsimp,\n  apply finset.sum_congr rfl,\n  rintros s -,\n  rw ← finset.sum_attach,\n  apply finset.sum_congr rfl,\n  rintros i -,\n  simp_rw [mk_seq_compat _ compat],\nend\n\nlemma exists_of_compat {c} (F : Π (A : finset ℤ), laurent_measures_bdd r S A c)\n  (compat : ∀ (A B : finset ℤ) (h : B ≤ A),\n    transition h (F _) = F _) :\n  ∃ (G : {H : ℒ S | ∥H∥₊ ≤ c }), ∀ (k : finset ℤ), truncate k G = F k :=\nbegin\n  let G : ℒ S := ⟨mk_seq F, mk_seq_compat_nnreal_summable _ compat⟩,\n  use G,\n  { apply mk_seq_compat_sum_le _ compat },\n  { intros k,\n    ext s i,\n    change F _ _ _ = _,\n    have := compat k {i} (by simp),\n    apply_fun (λ e, e s ⟨i, by simp⟩) at this,\n    erw ← this,\n    change F k _ _ = F k _ _,\n    congr,\n    ext, refl }\nend\n\nvariables (r S)\nopen category_theory\n/-- `laurent_measures_bdd_functor r S c` is the contravariant functor sending `T : finset ℤ` to\n  the finite type `laurent_measures_bdd r S T c`. Morphisms are given by throwing away\n  coefficients. -/\ndef laurent_measures_bdd_functor (c : ℝ≥0) [fact (0 < r)] :\n  (as_small (finset ℤ))ᵒᵖ ⥤ Fintype :=\n{ obj := λ A, Fintype.of $ laurent_measures_bdd r S (ulift.down A.unop) c,\n  map := λ A B f, transition (le_of_hom $ ulift.down f.unop) }.\n\n/-- The `equiv` between Laurent measures with norm at most `c` and the projective limit\nover `T : finset ℤ` of the finite types `laurent_measures_bdd r S T c`. -/\ndef laurent_measures_bdd_equiv (c : ℝ≥0) [fact (0 < r)] : { F : ℒ S | ∥F∥₊ ≤ c } ≃\n  (Profinite.limit_cone (laurent_measures_bdd_functor r S c ⋙ Fintype.to_Profinite)).X :=\nequiv.of_bijective (λ F, ⟨λ A, truncate (ulift.down A.unop) F, λ A B f, by { ext, refl }⟩)\nbegin\n  split,\n  { intros F G h,\n    apply eq_iff_truncate_eq,\n    intros k,\n    dsimp at h,\n    apply_fun (λ e, e.1 (opposite.op ⟨k⟩)) at h,\n    exact h },\n  { rintros ⟨F, hF⟩,\n    dsimp at F hF,\n    obtain ⟨G,hG⟩ := exists_of_compat (λ A, F (opposite.op ⟨A⟩)) _,\n    { use G,\n      ext : 2,\n      dsimp,\n      have := hG (ulift.down x.unop),\n      convert this,\n      rw ← x.op_unop,\n      congr' 1,\n      ext,\n      refl },\n    { intros A B h,\n      let e : (opposite.op $ as_small.up.obj A) ⟶ (opposite.op $ as_small.up.obj B) :=\n        quiver.hom.op (as_small.up.map (hom_of_le h)),\n      exact hF e } }\nend\n\n/-- The profinite topology on the Laurent measures with norm at most `c`. -/\ninstance (c : ℝ≥0) [fact (0 < r)] : topological_space {F : ℒ S | ∥F∥₊ ≤ c} :=\ntopological_space.induced (laurent_measures_bdd_equiv r S c) infer_instance\n\ndef laurent_measures_bdd_homeo (c : ℝ≥0) [fact (0 < r)] : { F : ℒ S | ∥F∥₊ ≤ c } ≃ₜ\n  (Profinite.limit_cone (laurent_measures_bdd_functor r S c ⋙ Fintype.to_Profinite)).X :=\n{ continuous_to_fun := continuous_induced_dom,\n  continuous_inv_fun := begin\n    have : inducing (laurent_measures_bdd_equiv r S c) := ⟨rfl⟩,\n    rw this.continuous_iff,\n    dsimp,\n    simp only [equiv.self_comp_symm],\n    exact continuous_id,\n  end,\n  ..(laurent_measures_bdd_equiv _ _ _) }\n\ninstance (c : ℝ≥0) [fact (0 < r)] : t2_space { F : ℒ S | ∥F∥₊ ≤ c } :=\n(laurent_measures_bdd_homeo r S c).symm.t2_space\n\ninstance (c : ℝ≥0) [fact (0 < r)] : totally_disconnected_space { F : ℒ S | ∥F∥₊ ≤ c } :=\n(laurent_measures_bdd_homeo r S c).symm.totally_disconnected_space\n\ninstance (c : ℝ≥0) [fact (0 < r)] : compact_space {F : ℒ S | ∥F∥₊ ≤ c} :=\n(laurent_measures_bdd_homeo r S c).symm.compact_space\n\n@[continuity]\nlemma truncate_continuous (c : ℝ≥0) [fact (0 < r)] (A : finset ℤ) :\n  continuous (truncate A : _ → laurent_measures_bdd r S _ c) :=\nbegin\n  let g₁ :=\n    (Profinite.limit_cone (laurent_measures_bdd_functor.{u} r S c ⋙ Fintype.to_Profinite)).π.app\n    (opposite.op $ ulift.up A),\n  let g₂ := (laurent_measures_bdd_homeo r S c),\n  change continuous (g₁ ∘ g₂),\n  continuity,\nend\n\nlemma continuous_iff (c : ℝ≥0) [fact (0 < r)] {α : Type*} [topological_space α]\n  (f : α → { F : ℒ S | ∥F∥₊ ≤ c }) :\n  continuous f ↔ ∀ (A : finset ℤ), continuous ((truncate A) ∘ f) :=\nbegin\n  split,\n  { intros hf A, continuity },\n  { intros h,\n    rw ← (laurent_measures_bdd_homeo r S c).comp_continuous_iff,\n    apply continuous.subtype_mk,\n    apply continuous_pi,\n    intros A,\n    apply h }\nend\n\nend profinite_structure\n\n/-\n--should this be a coercion?\ndef c_measures_to_oc (r : ℝ≥0) (c : ℝ≥0) (S : Type*) (hS : fintype S) :\n  c_measures r c S hS → ℒ S hS := λ f, ⟨f.to_fun, f.summable⟩\n\nlemma laurent_measures_are_c (r : ℝ≥0) (S : Type*) (hS : fintype S) (F : ℒ S hS) :\n  ∃ (c : ℝ≥0) (f : c_measures r c S hS),\n  c_measures_to_oc r c S hS f = F := by admit\n-/\n\n--needed?\ninstance : pseudo_normed_group (ℒ S) :=\n{ filtration := λ c, { F | ∥F∥₊ ≤ c },\n  filtration_mono := λ c₁ c₂ h F hF, by {dsimp at *, exact le_trans hF h},\n  zero_mem_filtration := λ c, by simp [nnnorm_def],\n  neg_mem_filtration := λ c F h, (nnnorm_neg F).le.trans h,\n  add_mem_filtration := λ c₁ c₂ F₁ F₂ h₁ h₂, (nnnorm_add _ _).trans (add_le_add h₁ h₂) }\n\n@[simp] lemma mem_filtration_iff (F : ℒ S) (c : ℝ≥0) :\n  F ∈ pseudo_normed_group.filtration (ℒ S) c ↔ ∥F∥₊ ≤ c := iff.rfl\n\ninstance [fact (0 < r)] : profinitely_filtered_pseudo_normed_group (ℒ S) :=\n{ continuous_add' := begin\n    intros c₁ c₂,\n    rw continuous_iff,\n    intros A,\n    let E : laurent_measures_bdd r S A c₁ × laurent_measures_bdd r S A c₂ →\n      laurent_measures_bdd r S A (c₁ + c₂) := λ G, ⟨G.1 + G.2, _⟩,\n    swap, {\n      refine le_trans _ (add_le_add G.fst.2 G.snd.2),\n      rw ← finset.sum_add_distrib,\n      apply finset.sum_le_sum,\n      intros i hi,\n      rw ← finset.sum_add_distrib,\n      apply finset.sum_le_sum,\n      intros j hj,\n      rw ← add_mul,\n      refine mul_le_mul' (norm_add_le _ _) le_rfl, },\n    have :\n      (truncate A : _ → laurent_measures_bdd r S A (c₁ + c₂)) ∘ pseudo_normed_group.add' =\n      E ∘ (prod.map (truncate A) (truncate A)),\n    { ext, refl },\n    rw this,\n    apply continuous.comp,\n    { exact continuous_of_discrete_topology },\n    { apply continuous.prod_map,\n      all_goals {apply truncate_continuous} }\n  end,\n  continuous_neg' := begin\n    intros c,\n    rw continuous_iff,\n    intros A,\n    let E : laurent_measures_bdd r S A c → laurent_measures_bdd r S A c :=\n      λ G, ⟨- G, _⟩,\n    swap, {\n      convert G.2 using 1,\n      apply finset.sum_congr rfl,\n      intros s hs,\n      apply finset.sum_congr rfl,\n      intros x hx,\n      congr' 1,\n      simpa },\n    have : (truncate A : _ → laurent_measures_bdd r S A c) ∘ pseudo_normed_group.neg' =\n      E ∘ truncate A,\n    { ext, refl },\n    rw this,\n    apply continuous.comp,\n    { exact continuous_of_discrete_topology },\n    { apply truncate_continuous }\n  end,\n  continuous_cast_le := begin\n    introsI c₁ c₂ h,\n    rw continuous_iff,\n    intros A,\n    let g : laurent_measures_bdd r S A c₁ → laurent_measures_bdd r S A c₂ :=\n      λ g, ⟨g, le_trans g.2 h.out⟩,\n    have : (truncate A : _ → laurent_measures_bdd r S A c₂) ∘ pseudo_normed_group.cast_le =\n      g ∘ truncate A,\n    { ext, refl },\n    rw this,\n    apply continuous.comp,\n    { exact continuous_of_discrete_topology },\n    { apply truncate_continuous }\n  end,\n  ..(infer_instance : (pseudo_normed_group (ℒ S))) }\n.\n\n/-- The additive group homomorphism on Laurent measures induced by division by `T^k` on `ℤ((T))ᵣ` -/\n@[simps] def shift_add_monoid_hom [hr : fact (0 < r)] (k : ℤ) : ℒ S →+ ℒ S :=\nadd_monoid_hom.mk' (λ F,\n{ to_fun := λ s n, F s (n+k),\n  summable' := λ s, begin\n    convert (nnreal.summable_comp_injective\n      (F.nnreal_summable s) (add_left_injective (k:ℤ))).mul_right (r ^ -k),\n    ext n,\n    simp only [function.comp, ← zpow_add₀ hr.out.ne', mul_assoc, add_neg_cancel_right],\n  end })\n(λ F G, by { ext, refl })\n.\n\n-- move me\n@[simp, to_additive] lemma _root_.finset.prod_attach' {α M : Type*} [comm_monoid M]\n  (s : finset α) (f : s → M) :\n  ∏ a in s.attach, f a = ∏ a in s, if h : a ∈ s then f ⟨a, h⟩ else 1 :=\nbegin\n  rw [eq_comm, ← finset.prod_attach, finset.prod_congr rfl],\n  intros, simp only [finset.coe_mem, finset.mk_coe, dite_eq_ite, if_true],\nend\n\n@[simps]\ndef shift [hr : fact (0 < r)] (k : ℤ) : comphaus_filtered_pseudo_normed_group_hom (ℒ S) (ℒ S) :=\ncomphaus_filtered_pseudo_normed_group_hom.mk_of_bound (shift_add_monoid_hom k) (r ^ -k)\nbegin\n  abstract shift_spec {\n  intro c,\n  have H : _ := _,\n  refine ⟨H, _⟩,\n  { rw continuous_iff,\n    intro A,\n    let B : finset ℤ := A.map (equiv.to_embedding (equiv.add_left (k:ℤ))),\n    let g : laurent_measures_bdd r S B c → laurent_measures_bdd r S A (r ^ -k * c) := λ F,\n    { to_fun := λ s a, F s ⟨a+k, _⟩,\n      bound' := _, },\n    { suffices : truncate A ∘ _ = g ∘ truncate B,\n      { rw this, exact continuous_of_discrete_topology.comp (truncate_continuous r S _ B) },\n      ext F s a, refl },\n    { simp only [finset.mem_map_equiv, equiv.add_left_symm, neg_neg, equiv.coe_add_left,\n        neg_add_cancel_comm_assoc, finset.coe_mem], },\n    { refine le_trans _ (mul_le_mul' le_rfl F.bound),\n      rw [laurent_measures_bdd.nnnorm_def, mul_comm, finset.sum_mul],\n      refine finset.sum_le_sum (λ s hs, _),\n      simp only [B, finset.univ_eq_attach],\n      erw [finset.sum_mul, finset.sum_attach', finset.sum_attach', finset.sum_map],\n      refine finset.sum_le_sum (λ n hn, _),\n      simp only [finset.mem_map_equiv, equiv.add_left_symm, equiv.coe_add_left, subtype.coe_mk,\n        equiv.to_embedding_apply, neg_add_cancel_left],\n      simp only [add_comm k, mul_assoc, ← zpow_add₀ hr.out.ne', add_neg_cancel_right], } },\n  { intros F hF,\n    rw mul_comm,\n    refine le_trans _ (mul_le_mul' hF le_rfl),\n    simp only [nnnorm_def, finset.sum_mul],\n    refine finset.sum_le_sum (λ s _, le_of_eq _),\n    transitivity ∑' n, ∥F s n∥₊ * r^n * (r ^ -k),\n    { refine ((equiv.add_left (-k:ℤ)).tsum_eq _).symm.trans _,\n      simp only [equiv.coe_add_left, shift_add_monoid_hom_apply_to_fun, neg_add_cancel_comm,\n        zpow_add₀ hr.out.ne', zpow_neg_one, mul_comm (r ^ -k), mul_assoc], },\n    ext,\n    simp only [nonneg.coe_mul, nnreal.coe_tsum, coe_nnnorm, nnreal.coe_zpow, tsum_mul_right], } }\nend\n.\n\ninstance [fact (0 < r)] :\n  profinitely_filtered_pseudo_normed_group_with_Tinv r (ℒ S) :=\n{ Tinv := shift 1,\n  Tinv_mem_filtration := λ c F hF, begin\n    refine comphaus_filtered_pseudo_normed_group_hom.mk_of_bound_bound_by _ _ _ hF,\n    intro c',\n    have := @shift.shift_spec r S _ 1 c',\n    rwa [zpow_neg_one] at this,\n  end,\n  .. (_: profinitely_filtered_pseudo_normed_group (ℒ S))}\n\n@[simp] lemma Tinv_apply [fact (0 < r)] (F : ℒ S) :\n  comphaus_filtered_pseudo_normed_group_with_Tinv.Tinv F = shift 1 F := rfl\n\nvariable {α : Type*}\n\nopen pseudo_normed_group profinitely_filtered_pseudo_normed_group\n  comphaus_filtered_pseudo_normed_group\n\n@[simps]\ndef map_hom [fact (0 < r)] (f : S ⟶ S') :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r (ℒ S) (ℒ S') :=\n{ to_fun := map f,\n  map_zero' := by { ext, simp only [map_apply, zero_apply, finset.sum_const_zero], },\n  map_add' := λ F G, by { ext s i, simp only [←finset.sum_add_distrib, map_apply, add_apply], },\n  map_Tinv' := λ F, by { ext s i, simp only [map_apply, Tinv_apply, shift_to_fun_to_fun] },\n  strict' := λ c F (hF : ∥F∥₊ ≤ c), (map_bound _ _).trans hF,\n  continuous' := λ c, begin\n    rw continuous_iff,\n    intros T,\n    let f₀ : (filtration (laurent_measures r S) c) → (filtration (laurent_measures r S') c) :=\n      level (map f) (λ c F (hF : ∥F∥₊ ≤ c), (map_bound f F).trans hF) c,\n    have : truncate T ∘ f₀ = laurent_measures_bdd.map f ∘ truncate T, { ext F s' t, refl },\n    rw this,\n    exact continuous_of_discrete_topology.comp (truncate_continuous r S _ T),\n  end }\n\n/--  Let `F : ℒ S` be a Laurent measure.  `laurent_measures.d` chooses a bound `d ∈ ℤ` for `F`,\nsuch that, for all `s : S`, the sequence `F s` is zero from `d-1` and below. -/\ndef d [h0 : fact (0 < r)] [h1 : fact (r < 1)] (F : ℒ S) : ℤ :=\n(exists_bdd_filtration h0.out h1.out F).some\n\nlemma lt_d_eq_zero [h0 : fact (0 < r)] [h1 : fact (r < 1)] (F : ℒ S) (s : S) (n : ℤ) :\n  n < F.d → F s n = 0 := (exists_bdd_filtration h0.out h1.out F).some_spec s n\n\nlemma lt_d_eq_zero' [h0 : fact (0 < r)] [h1 : fact (r < 1)] (F : ℒ S) (s : S) (n : ℤ) :\n  n < F.d → (F s n : ℝ) = 0 := by exact_mod_cast lt_d_eq_zero F s n\n\nend laurent_measures\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/laurent_measures/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.48730009850228284}}
{"text": "\nimport topology.basic\nimport topology.compact_open\nimport data.nat.prime\nimport data.real.basic\nimport data.real.irrational\nimport data.complex.basic\nimport data.fin.basic\nimport geometry.euclidean.basic\nimport analysis.inner_product_space.pi_L2\nimport algebra.group.defs\nimport algebra.field.basic\nimport combinatorics.configuration\nimport ring_theory.polynomial.basic\nimport group_theory.free_group\nimport combinatorics.simple_graph.basic\nimport ring_theory.integral_closure\nimport data.fintype.card\nimport category_theory.category.basic\nimport ring_theory.discrete_valuation_ring\nimport group_theory.torsion\nimport linear_algebra.matrix.charpoly.basic\nimport algebra.order.absolute_value\nimport analysis.convex.basic\nimport topology.uniform_space.uniform_convergence_topology\nimport topology.sequences\nimport analysis.normed.group.infinite_sum\nimport data.nat.choose.sum\nimport group_theory.specific_groups.cyclic\nimport group_theory.order_of_element\nimport analysis.mean_inequalities\nimport analysis.normed_space.banach\nimport topology.algebra.continuous_monoid_hom\nimport linear_algebra.matrix.symmetric\nimport analysis.inner_product_space.spectrum\nimport ring_theory.class_group\nimport ring_theory.dedekind_domain.basic\nimport ring_theory.principal_ideal_domain\nimport model_theory.satisfiability\nimport probability.integration\nimport ring_theory.simple_module\nimport category_theory.preadditive.schur\nimport representation_theory.maschke\nimport topology.paracompact\nimport combinatorics.simple_graph.coloring\n--Prove that \\mathbb{R}^n is paracompact in Lean mathlib\n \n--OUTPUT 1\ntheorem paracompact_real_space : paracompact_space ℝ :=\nbegin\n  sorry,\n\n--OUTPUT 2\ntheorem is_paracompact (n : ℕ) : paracompact_space (euclidean_space n) :=\nbegin\n  --Let \\mathcal{U} be an open cover of \\mathbb{R}^n\n  rintro ⟨U, hU⟩,\n  --Since \\mathbb{R}^n is second-countable, we can pick a countable subcover\n  -- \\mathcal{V} of \\mathcal{U}\n  have : countable_cover (euclidean_space n) U := countable_cover_of_second_countable_space (euclidean_space n),\n  rcases this with ⟨V, hV⟩,\n  --Define a function f : \\mathbb{R}^n \\to \\mathbb{N} by f(x) = \\min\\{n \\in \\mathbb{N} \\mid x \\in V_n\\}\n  let f : euclidean_space n → ℕ := λ x, nat.find (λ n, x ∈ V n),\n  --Since V is a cover, f is well-defined\n  have hf : ∀ x, x ∈ ⋃ i, V i := λ x, nat.find_spec (λ n, x ∈ V n),\n  --Define a function g : \\mathbb{N} \\to \\mathcal{V} by g(n) = V_n\n  let g : ℕ → set (euclidean_space n) := λ n, V n,\n  --Since V is a cover, g is well-defined\n  have hg : ∀ n, g n ∈ U := λ n, hV n,\n  --Define a function h : \\mathbb{N} \\to \\mathcal{U} by h(n) = U_n\n  let h : ℕ → set (euclidean_space n) := λ n, U n,\n  --Since U is a cover, h is well-defined\n  have hh : ∀ n, h n ∈ U := λ n, hU n,\n  --Define a function k : \\mathbb{N} \\to \\mathbb{N} by k(n) = \\min\\{m \\in \\mathbb{N} \\mid V_n \\subseteq U_m\\}\n  let k : ℕ → ℕ := λ n, nat.find (λ m, V n ⊆ U m),\n  --Since V is a cover, k is well-defined\n  have hk : ∀ n, V n ⊆ U (k n) := λ n, nat.find_spec (λ m, V n ⊆ U m),\n  --Define a function l : \\mathbb{N} \\to \\mathbb{N} by l(n) = \\min\\{m \\in \\mathbb{N} \\mid U_n \\subseteq U_m\\}\n  let l : ℕ → ℕ := λ n, nat.find (λ m, U n ⊆ U m),\n  --Since U is a cover, l is well-defined\n  have hl : ∀ n, U n ⊆ U (l n) := λ n, nat.find_spec (λ m, U n ⊆ U m),\n  --Define a function m : \\mathbb{N} \\to \\mathbb{N} by m(n) = \\min\\{k(n), l(n)\\}\n  let m : ℕ → ℕ := λ n, nat.min (k n) (l n),\n  --Define a function p : \\mathbb{N} \\to \\mathcal{U} by p(n) = U_{m(n)}\n  let p : ℕ → set (euclidean_space n) := λ n, U (m n),\n  --Since U is a cover, p is well-defined\n  have hp : ∀ n, p n ∈ U := λ n, hU (m n),\n  --Define a function q : \\mathbb{N} \\to \\mathcal{V} by q(n) = V_{m(n)}\n  let q : ℕ → set (euclidean_space n) := λ n, V (m n),\n  --Since V is a cover, q is well-defined\n  have hq : ∀ n, q n ∈ U := λ n, hV (m n),\n  --Define a function r : \\mathbb{N} \\to \\mathbb{N} by r(n) = \\min\\{m \\in \\mathbb{N} \\mid V_{m(n)} \\subseteq U_n\\}\n  let r : ℕ → ℕ := λ n, nat.find (λ m, V (m n) ⊆ U n),\n  --Since V is a cover, r is well-defined\n  have hr : ∀ n, V (m n) ⊆ U (r n) := λ n, nat.find_spec (λ m, V (m n) ⊆ U n),\n  --Define a function s : \\mathbb{N} \\to \\mathbb{N} by s(n) = \\min\\{m \\in \\mathbb{N} \\mid U_{m(n)} \\subseteq U_n\\}\n  let s : ℕ → ℕ := λ n, nat.find (λ m, U (m n) ⊆ U n),\n  --Since U is a cover, s is well-defined\n  have hs : ∀ n, U (m n) ⊆ U (s n) := λ n, nat.find_spec (λ m, U (m n) ⊆ U n),\n  --Define a function t : \\mathbb{N} \\to \\mathbb{N} by t(n) = \\min\\{r(n), s(n)\\}\n  let t : ℕ → ℕ := λ n, nat.min (r n) (s n),\n  --Define a function u : \\mathbb{N} \\to \\mathcal{U} by u(n) = U_{t(n)}\n  let u : ℕ → set (euclidean_space n) := λ n, U (t n),\n  --Since U is a cover, u is well-defined\n  have hu : ∀ n, u n ∈ U := λ n, hU (t n),\n  --Define a function v : \\mathbb{N} \\to \\mathcal{V} by v(n) = V_{t(n)}\n  let v : ℕ → set (euclidean_space n) := λ n, V (t n),\n  --Since V is a cover, v is well-defined\n  have hv : ∀ n, v n ∈ U := λ n, hV (t n),\n  --Define a function w : \\mathbb{N} \\to \\mathbb{N} by w(n) = \\min\\{m \\in \\mathbb{N} \\mid V_{t(n)} \\subseteq U_m\\}\n  let w : ℕ → ℕ := λ n, nat.find (λ m, V (t n) ⊆ U m),\n  --Since V is a cover, w is well-defined\n  have hw : ∀ n, V (t n) ⊆ U (w n) := λ n, nat.find_spec (λ m, V (t n) ⊆ U m),\n  --Define a function x : \\mathbb{N} \\to \\mathbb{N} by x(n) = \\min\\{m \\in \\mathbb{N} \\mid U_{t(n)} \\subseteq U_m\\}\n  let x : ℕ → ℕ := λ n, nat.find (λ m, U (t n) ⊆ U m),\n  --Since U is a cover, x is well-defined\n  have hx : ∀ n, U (t n) ⊆ U (x n) := λ n, nat.find_spec (λ m, U (t n) ⊆ U m),\n  --Define a function y : \\mathbb{N} \\to \\mathbb{N} by y(n\n\n--OUTPUT 3\ntheorem R_n_is_paracompact (n : ℕ) : paracompact_space (euclidean_space n) :=\nbegin\n  --First we prove that it is a normal space\n  apply normal_space_iff_normal_separation.mpr,\n  --We prove that the space is normal by proving the separation axioms\n  apply normal_separation_iff_normal_separation_of_closed_of_open.mpr,\n  --We prove the separation axioms by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove the separation axioms by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving that the space is normal for any open set and any closed set\n  apply normal_separation_of_open_of_closed_iff_normal_separation.mpr,\n  --We prove that the space is normal for any open set and any closed set by proving\n\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/Zero-shot-theorem-names/Zero-Shot-prompts_temperature_0.4_max_tokens_2000_n_3/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4873000915502977}}
{"text": "open classical\n\nvariables A B C D: Prop\n\nexample (h : ¬ A ∧ ¬ B) : ¬ (A ∨ B) :=\nbegin\n  intro,\n  cases ᾰ,\n    apply h.left,\n      assumption,\n    apply h.right,\n      assumption\nend\n\n", "meta": {"author": "faustoUrtiz", "repo": "learning-leanprover", "sha": "3acddd0ffb952ce32b0135b8f49de5e930c9820a", "save_path": "github-repos/lean/faustoUrtiz-learning-leanprover", "path": "github-repos/lean/faustoUrtiz-learning-leanprover/learning-leanprover-3acddd0ffb952ce32b0135b8f49de5e930c9820a/test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4873000845983122}}
{"text": "namespace hidden\nuniverses u v\n\ninductive list (α : Type u)\n| nil {} : list\n| cons : α → list → list\n\nnamespace list\nvariable {α : Type}\n\nnotation h :: t := cons h t\n\ndef append (s t : list α) : list α :=\nlist.rec t (λ x l u, x::u) s\n\nnotation s ++ t := append s t\n\ntheorem nil_append (t : list α) : nil ++ t = t := rfl\ntheorem cons_append (x : α) (s t : list α) :\n    x :: s ++ t = x :: (s ++ t) := rfl\n\nnotation `[` l:(foldr `,` (h t, cons h t) nil) `]` := l\n\nsection\n    open nat\n    #check [1, 2, 3, 4, 5]\n    #check ([1,2,3,4,5] : list int)\nend\n\n-- exercise\n\ntheorem append_nil (t : list α) : t ++ nil = t :=\nlist.rec_on t\n    (show (@nil α) ++ nil = nil, from rfl)\n    (\n        assume h,\n        assume l,\n        assume ih: l ++ nil = l,\n        calc (h :: l) ++ nil = h :: (l ++ nil) : cons_append h l nil\n        ... = h :: l : by rw ih\n    )\n\ntheorem append_assoc (r s t : list α) : (r ++ s) ++ t = r ++ (s ++ t) :=\nlist.rec_on r\n    (\n        calc (nil ++ s) ++ t = s ++ t : by rw nil_append\n        ... = nil ++ (s ++ t) : by rw nil_append\n    )\n    (\n        assume h,\n        assume l,\n        assume ih: (l ++ s) ++ t = l ++ (s ++ t),\n        calc (h :: l) ++ s ++ t = h :: (l ++ s) ++ t : by rw cons_append\n        ... = h :: (l ++ s ++ t) : by rw cons_append\n        ... = h :: (l ++ (s ++ t)) : by rw ih\n        ... = (h :: l) ++ (s ++ t) : by rw cons_append\n    )\n\ndef length : Π {α : Type u}, list α → ℕ :=\nλ t l, list.rec_on l 0 (λ h x n, n + 1)\n\ntheorem append_length (s t : list α) : length (s ++ t) = length s + length t :=\nlist.rec_on s\n    (\n        show length (nil ++ t) = length nil + length t, from\n        calc length (nil ++ t) = length t : by rw nil_append\n        ... = 0 + length t : by rw zero_add\n        ... = length nil + length t : rfl\n    )\n    (\n        assume h,\n        assume l,\n        assume ih: length (l ++ t) = length l + length t,\n        show length (h :: l ++ t) = length (h :: l) + length t, from\n        calc length ((h :: l) ++ t) = length (h :: (l ++ t)) : by rw cons_append\n        ... = length (l ++ t) + 1 : rfl\n        ... = length l + length t + 1 : by rw ih\n        ... = length l + 1 + length t : by simp\n        ... = length (h :: l) + length t : by rw length\n    )\n\ndef reverse (s : list α) : list α :=\nlist.rec_on s nil (λ h l t, t ++ [h])\n\nexample (h : α) (s : list α) : reverse (h :: s) = (reverse s) ++ [h] :=\nrfl\n\nexample (t: list α) : length (reverse t) = length t :=\nlist.rec_on t\n    (show length (reverse nil) = length nil, from rfl)\n    (\n        assume h,\n        assume l : list α,\n        assume ih : length (reverse l) = length l,\n        show length (reverse (h :: l)) = length (h :: l), from\n        calc length (reverse (h :: l))\n            = length (reverse l ++ [h]) : rfl\n        ... = length (reverse l) + length [h] : by rw append_length\n        ... = length l + length [h] : by rw ih\n    )\n\ntheorem reverse_append (s t : list α) : reverse (s ++ t) = reverse t ++ reverse s :=\nlist.rec_on s\n    (\n        show reverse (nil ++ t) = reverse t ++ reverse nil, from\n        calc reverse (nil ++ t) = reverse t : by rw nil_append\n        ... = reverse t ++ nil : by rw append_nil\n        ... = reverse t ++ reverse nil : rfl\n    )\n    (\n        assume h,\n        assume l,\n        assume ih : reverse (l ++ t) = reverse t ++ reverse l,\n        show reverse ((h :: l) ++ t) = reverse t ++ reverse (h :: l), from\n        calc reverse ((h :: l) ++ t)\n            = reverse (h :: (l ++ t)) : by rw cons_append\n        ... = reverse (l ++ t) ++ [h] : rfl\n        ... = reverse t ++ reverse l ++ [h] : by rw ih\n        ... = reverse t ++ (reverse l ++ [h]) : by rw append_assoc\n        ... = reverse t ++ reverse (h :: l) : rfl\n    )\n\nexample (t : list α) : reverse (reverse t) = t :=\nlist.rec_on t\n    (show reverse (reverse nil) = nil, from rfl)\n    (\n        assume h,\n        assume l : list α,\n        assume ih : reverse (reverse l) = l,\n        show reverse (reverse (h :: l)) = h :: l, from\n        calc reverse (reverse (h :: l))\n            = reverse (reverse l ++ [h]) : rfl\n        ... = reverse [h] ++ reverse (reverse l) : by rw reverse_append\n        ... = [h] ++ reverse (reverse l) : rfl\n        ... = [h] ++ l : by rw ih\n        ... = h :: l : by rw [append]\n    )\n\nend list\n\nend hidden\n", "meta": {"author": "zeptometer", "repo": "LearnLean", "sha": "bb84d5dbe521127ba134d4dbf9559b294a80b9f7", "save_path": "github-repos/lean/zeptometer-LearnLean", "path": "github-repos/lean/zeptometer-LearnLean/LearnLean-bb84d5dbe521127ba134d4dbf9559b294a80b9f7/bluejam/chap7/exercise7.2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.4871755663613465}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Johan Commelin, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.mv_polynomial.rename\nimport Mathlib.data.equiv.fin\nimport Mathlib.PostPort\n\nuniverses u u_1 v w x \n\nnamespace Mathlib\n\n/-!\n# Equivalences between polynomial rings\n\nThis file establishes a number of equivalences between polynomial rings,\nbased on equivalences between the underlying types.\n\n## Notation\n\nAs in other polynomial files, we typically use the notation:\n\n+ `σ : Type*` (indexing the variables)\n\n+ `R : Type*` `[comm_semiring R]` (the coefficients)\n\n+ `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set.\nThis will give rise to a monomial in `mv_polynomial σ R` which mathematicians might call `X^s`\n\n+ `a : R`\n\n+ `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians\n\n+ `p : mv_polynomial σ R`\n\n## Tags\n\nequivalence, isomorphism, morphism, ring hom, hom\n\n-/\n\nnamespace mv_polynomial\n\n\n/-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/\ndef pempty_ring_equiv (R : Type u) [comm_semiring R] : mv_polynomial pempty R ≃+* R :=\n  ring_equiv.mk (eval₂ (ring_hom.id R) pempty.elim) ⇑C sorry sorry sorry sorry\n\n/-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/\n@[simp] theorem pempty_alg_equiv_symm_apply (R : Type u) [comm_semiring R] : ∀ (ᾰ : R), coe_fn (alg_equiv.symm (pempty_alg_equiv R)) ᾰ = coe_fn C ᾰ :=\n  fun (ᾰ : R) => Eq.refl (coe_fn (alg_equiv.symm (pempty_alg_equiv R)) ᾰ)\n\n/--\nThe ring isomorphism between multivariable polynomials in a single variable and\npolynomials over the ground ring.\n-/\n@[simp] theorem punit_ring_equiv_symm_apply (R : Type u) [comm_semiring R] (p : polynomial R) : coe_fn (ring_equiv.symm (punit_ring_equiv R)) p = polynomial.eval₂ C (X PUnit.unit) p :=\n  Eq.refl (coe_fn (ring_equiv.symm (punit_ring_equiv R)) p)\n\n/-- The ring isomorphism between multivariable polynomials induced by an equivalence of the variables.  -/\n@[simp] theorem ring_equiv_of_equiv_symm_apply (R : Type u) {S₁ : Type v} {S₂ : Type w} [comm_semiring R] (e : S₁ ≃ S₂) : ∀ (ᾰ : mv_polynomial S₂ R), coe_fn (ring_equiv.symm (ring_equiv_of_equiv R e)) ᾰ = coe_fn (rename ⇑(equiv.symm e)) ᾰ :=\n  fun (ᾰ : mv_polynomial S₂ R) => Eq.refl (coe_fn (ring_equiv.symm (ring_equiv_of_equiv R e)) ᾰ)\n\n/-- The algebra isomorphism between multivariable polynomials induced by an equivalence of the variables.  -/\n@[simp] theorem alg_equiv_of_equiv_symm_apply (R : Type u) {S₁ : Type v} {S₂ : Type w} [comm_semiring R] (e : S₁ ≃ S₂) : ∀ (ᾰ : mv_polynomial S₂ R), coe_fn (alg_equiv.symm (alg_equiv_of_equiv R e)) ᾰ = coe_fn (rename ⇑(equiv.symm e)) ᾰ :=\n  fun (ᾰ : mv_polynomial S₂ R) => Eq.refl (coe_fn (alg_equiv.symm (alg_equiv_of_equiv R e)) ᾰ)\n\n/-- The ring isomorphism between multivariable polynomials induced by a ring isomorphism of the ground ring. -/\ndef ring_equiv_congr (R : Type u) {S₁ : Type v} {S₂ : Type w} [comm_semiring R] [comm_semiring S₂] (e : R ≃+* S₂) : mv_polynomial S₁ R ≃+* mv_polynomial S₁ S₂ :=\n  ring_equiv.mk ⇑(map ↑e) ⇑(map ↑(ring_equiv.symm e)) sorry sorry sorry sorry\n\n/--\nThe function from multivariable polynomials in a sum of two types,\nto multivariable polynomials in one of the types,\nwith coefficents in multivariable polynomials in the other type.\n\nSee `sum_ring_equiv` for the ring isomorphism.\n-/\ndef sum_to_iter (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] : mv_polynomial (S₁ ⊕ S₂) R →+* mv_polynomial S₁ (mv_polynomial S₂ R) :=\n  eval₂_hom (ring_hom.comp C C) fun (bc : S₁ ⊕ S₂) => sum.rec_on bc X (⇑C ∘ X)\n\nprotected instance is_semiring_hom_sum_to_iter (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] : is_semiring_hom ⇑(sum_to_iter R S₁ S₂) :=\n  eval₂.is_semiring_hom (ring_hom.comp C C) fun (n : S₁ ⊕ S₂) => (fun (bc : S₁ ⊕ S₂) => sum.rec_on bc X (⇑C ∘ X)) n\n\n@[simp] theorem sum_to_iter_C (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] (a : R) : coe_fn (sum_to_iter R S₁ S₂) (coe_fn C a) = coe_fn C (coe_fn C a) :=\n  eval₂_C (ring_hom.comp C C) (fun (n : S₁ ⊕ S₂) => (fun (bc : S₁ ⊕ S₂) => sum.rec_on bc X (⇑C ∘ X)) n) a\n\n@[simp] theorem sum_to_iter_Xl (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] (b : S₁) : coe_fn (sum_to_iter R S₁ S₂) (X (sum.inl b)) = X b :=\n  eval₂_X (ring_hom.comp C C) (fun (n : S₁ ⊕ S₂) => (fun (bc : S₁ ⊕ S₂) => sum.rec_on bc X (⇑C ∘ X)) n) (sum.inl b)\n\n@[simp] theorem sum_to_iter_Xr (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] (c : S₂) : coe_fn (sum_to_iter R S₁ S₂) (X (sum.inr c)) = coe_fn C (X c) :=\n  eval₂_X (ring_hom.comp C C) (fun (n : S₁ ⊕ S₂) => (fun (bc : S₁ ⊕ S₂) => sum.rec_on bc X (⇑C ∘ X)) n) (sum.inr c)\n\n/--\nThe function from multivariable polynomials in one type,\nwith coefficents in multivariable polynomials in another type,\nto multivariable polynomials in the sum of the two types.\n\nSee `sum_ring_equiv` for the ring isomorphism.\n-/\ndef iter_to_sum (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] : mv_polynomial S₁ (mv_polynomial S₂ R) →+* mv_polynomial (S₁ ⊕ S₂) R :=\n  eval₂_hom (ring_hom.of (eval₂ C (X ∘ sum.inr))) (X ∘ sum.inl)\n\ntheorem iter_to_sum_C_C (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] (a : R) : coe_fn (iter_to_sum R S₁ S₂) (coe_fn C (coe_fn C a)) = coe_fn C a :=\n  Eq.trans (eval₂_C (ring_hom.of (eval₂ C (X ∘ sum.inr))) (fun (n : S₁) => function.comp X sum.inl n) (coe_fn C a))\n    (eval₂_C C (fun (n : S₂) => function.comp X sum.inr n) a)\n\ntheorem iter_to_sum_X (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] (b : S₁) : coe_fn (iter_to_sum R S₁ S₂) (X b) = X (sum.inl b) :=\n  eval₂_X (ring_hom.of (eval₂ C (X ∘ sum.inr))) (fun (n : S₁) => function.comp X sum.inl n) b\n\ntheorem iter_to_sum_C_X (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] (c : S₂) : coe_fn (iter_to_sum R S₁ S₂) (coe_fn C (X c)) = X (sum.inr c) :=\n  Eq.trans (eval₂_C (ring_hom.of (eval₂ C (X ∘ sum.inr))) (fun (n : S₁) => function.comp X sum.inl n) (X c))\n    (eval₂_X C (fun (n : S₂) => function.comp X sum.inr n) c)\n\n/-- A helper function for `sum_ring_equiv`. -/\n@[simp] theorem mv_polynomial_equiv_mv_polynomial_apply (R : Type u) (S₁ : Type v) (S₂ : Type w) (S₃ : Type x) [comm_semiring R] [comm_semiring S₃] (f : mv_polynomial S₁ R →+* mv_polynomial S₂ S₃) (g : mv_polynomial S₂ S₃ →+* mv_polynomial S₁ R) (hfgC : ∀ (a : S₃), coe_fn f (coe_fn g (coe_fn C a)) = coe_fn C a) (hfgX : ∀ (n : S₂), coe_fn f (coe_fn g (X n)) = X n) (hgfC : ∀ (a : R), coe_fn g (coe_fn f (coe_fn C a)) = coe_fn C a) (hgfX : ∀ (n : S₁), coe_fn g (coe_fn f (X n)) = X n) : ∀ (ᾰ : mv_polynomial S₁ R), coe_fn (mv_polynomial_equiv_mv_polynomial R S₁ S₂ S₃ f g hfgC hfgX hgfC hgfX) ᾰ = coe_fn f ᾰ :=\n  fun (ᾰ : mv_polynomial S₁ R) =>\n    Eq.refl (coe_fn (mv_polynomial_equiv_mv_polynomial R S₁ S₂ S₃ f g hfgC hfgX hgfC hgfX) ᾰ)\n\n/--\nThe ring isomorphism between multivariable polynomials in a sum of two types,\nand multivariable polynomials in one of the types,\nwith coefficents in multivariable polynomials in the other type.\n-/\ndef sum_ring_equiv (R : Type u) (S₁ : Type v) (S₂ : Type w) [comm_semiring R] : mv_polynomial (S₁ ⊕ S₂) R ≃+* mv_polynomial S₁ (mv_polynomial S₂ R) :=\n  mv_polynomial_equiv_mv_polynomial R (S₁ ⊕ S₂) S₁ (mv_polynomial S₂ R) (sum_to_iter R S₁ S₂) (iter_to_sum R S₁ S₂) sorry\n    sorry sorry sorry\n\n/--\nThe ring isomorphism between multivariable polynomials in `option S₁` and\npolynomials with coefficients in `mv_polynomial S₁ R`.\n-/\ndef option_equiv_left (R : Type u) (S₁ : Type v) [comm_semiring R] : mv_polynomial (Option S₁) R ≃+* polynomial (mv_polynomial S₁ R) :=\n  ring_equiv.trans (ring_equiv_of_equiv R (equiv.trans (equiv.option_equiv_sum_punit S₁) (equiv.sum_comm S₁ PUnit)))\n    (ring_equiv.trans (sum_ring_equiv R PUnit S₁) (punit_ring_equiv (mv_polynomial S₁ R)))\n\n/--\nThe ring isomorphism between multivariable polynomials in `option S₁` and\nmultivariable polynomials with coefficients in polynomials.\n-/\ndef option_equiv_right (R : Type u) (S₁ : Type v) [comm_semiring R] : mv_polynomial (Option S₁) R ≃+* mv_polynomial S₁ (polynomial R) :=\n  ring_equiv.trans (ring_equiv_of_equiv R (equiv.option_equiv_sum_punit S₁))\n    (ring_equiv.trans (sum_ring_equiv R S₁ Unit) (ring_equiv_congr (mv_polynomial Unit R) (punit_ring_equiv R)))\n\n/--\nThe ring isomorphism between multivariable polynomials in `fin (n + 1)` and\npolynomials over multivariable polynomials in `fin n`.\n-/\ndef fin_succ_equiv (R : Type u) [comm_semiring R] (n : ℕ) : mv_polynomial (fin (n + 1)) R ≃+* polynomial (mv_polynomial (fin n) R) :=\n  ring_equiv.trans (ring_equiv_of_equiv R (fin_succ_equiv n)) (option_equiv_left R (fin n))\n\ntheorem fin_succ_equiv_eq (R : Type u) [comm_semiring R] (n : ℕ) : ↑(fin_succ_equiv R n) =\n  eval₂_hom (ring_hom.comp polynomial.C C)\n    fun (i : fin (n + 1)) => fin.cases polynomial.X (fun (k : fin n) => coe_fn polynomial.C (X k)) i := sorry\n\n@[simp] theorem fin_succ_equiv_apply (R : Type u) [comm_semiring R] (n : ℕ) (p : mv_polynomial (fin (n + 1)) R) : coe_fn (fin_succ_equiv R n) p =\n  coe_fn\n    (eval₂_hom (ring_hom.comp polynomial.C C)\n      fun (i : fin (n + 1)) => fin.cases polynomial.X (fun (k : fin n) => coe_fn polynomial.C (X k)) i)\n    p := sorry\n\ntheorem fin_succ_equiv_comp_C_eq_C {R : Type u} [comm_semiring R] (n : ℕ) : ring_hom.comp (ring_equiv.to_ring_hom (ring_equiv.symm (fin_succ_equiv R n))) (ring_hom.comp polynomial.C C) = C := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/mv_polynomial/equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.6224593171945416, "lm_q1q2_score": 0.48717555224283277}}
{"text": "import data.nat.nth\n\n/-! # IMO 2017 C7 -/\n\nnamespace IMOSL\nnamespace IMO2017C7\n\nopen finset function\n\nnoncomputable def nth_notin (X : finset ℕ) := nat.nth (λ n, n ∉ X)\nnoncomputable def cup_mul (X Y : finset ℕ) := X ∪ image (nth_notin X) Y\nnoncomputable def cup_pow (X : finset ℕ) (k : ℕ) := nat.iterate (λ Y, cup_mul X Y) k ∅\nlocal infix ` ** `:80 := cup_mul\nlocal infix ` ^^ `:100 := cup_pow\n\n\n\nsection strict_mono\n\nprivate lemma strict_mono_eq_at_large_comm {f g : ℕ → ℕ} (hf : strict_mono f) (hg : strict_mono g)\n  (h : ∃ N : ℕ, ∀ n : ℕ, N ≤ n → f n = g n) (h0 : f ∘ g = g ∘ f) : f = g :=\nbegin\n  cases h with N h,\n  ext n; have h1 := n.zero_le; revert h1 n,\n  refine nat.decreasing_induction (λ k h1 n h2, _) N.zero_le h,\n  rw [le_iff_lt_or_eq, ← nat.add_one_le_iff] at h2,\n  rcases h2 with h2 | rfl,\n  exact h1 n h2,\n  cases eq_or_lt_of_le (hf.id_le k) with h3 h3,\n  cases eq_or_lt_of_le (hg.id_le k) with h4 h4,\n  rw [← h3, ← h4],\n  { replace h1 := h1 (g k) h4,\n    rw [← comp_app f, h0, comp_app] at h1,\n    exact hg.injective h1 },\n  { replace h1 := h1 (f k) h3,\n    rw [← comp_app g, ← h0, comp_app] at h1,\n    exact hf.injective h1 }\nend\n\nend strict_mono\n\n\n\nsection prop_lemmas\n\nprivate lemma count_true : nat.count (λ _, true) = id :=\nbegin\n ext n; induction n with n n_ih,\n rw [nat.count_zero, id.def],\n rw [nat.count_succ, n_ih, if_true, id.def, id.def]\nend\n\nprivate lemma nth_true : nat.nth (λ _, true) = id :=\nbegin\n  ext n; have h := nat.nth_count (λ _, true) (trivial : (λ _, true) n),\n  rwa count_true at h\nend\n\nvariables {p q : ℕ → Prop} [decidable_pred p] [decidable_pred q]\n\nprivate lemma count_prop_inj (h : ∀ n : ℕ, nat.count p n = nat.count q n) : p = q :=\n  by ext n; rw [← @nat.count_succ_eq_succ_count_iff p, h, h, nat.count_succ_eq_succ_count_iff]\n\nprivate lemma nth_prop_inj (hp : (set_of p).infinite) (hq : (set_of q).infinite) :\n  nat.nth p = nat.nth q ↔ p = q :=\nbegin\n  symmetry; split,\n  intros h; rw h,\n  intros h; refine count_prop_inj (λ n, _),\n  exact galois_connection.l_unique (nat.count_nth_gc _ hp) (nat.count_nth_gc _ hq) (λ b, by rw h)\nend\n\nend prop_lemmas\n\n\n\nsection finset_lemmas\n\nvariables (X Y : finset ℕ)\n\nprivate lemma nat_finset_infinite_compl : {n : ℕ | n ∉ X}.infinite :=\nbegin\n  have h := set.finite.infinite_compl ((X : set ℕ).to_finite),\n  rwa set.compl_def at h\nend\n\nprivate lemma range_nth_notin_eq_compl : set.range (nth_notin X) = Xᶜ :=\nbegin\n  ext n; rw [set.mem_range, set.mem_compl_iff, mem_coe],\n  refine ⟨_, (λ h, ⟨nat.count (λ n, n ∉ X) n, _⟩)⟩,\n  rintros ⟨y, rfl⟩,\n  exact nat.nth_mem_of_infinite (λ n, n ∉ X) (nat_finset_infinite_compl X) y,\n  exact nat.nth_count (λ (n : ℕ), n ∉ X) h\nend\n\nprivate lemma range_nth_notin_eq_univ_diff : set.range (nth_notin X) = set.univ \\ X :=\n  by rw [range_nth_notin_eq_compl, set.compl_eq_univ_diff]\n\nprivate lemma nth_notin_inj : nth_notin X = nth_notin Y ↔ X = Y :=\nbegin\n  unfold nth_notin,\n  rw nth_prop_inj (nat_finset_infinite_compl X) (nat_finset_infinite_compl Y),\n  symmetry; split,\n  intros h; rw h,\n  intros h; ext n,\n  replace h := congr_fun h n,\n  simp only [eq_iff_iff] at h,\n  rwa [← not_iff_not, ← mem_coe, set.not_not_mem, ← mem_coe, set.not_not_mem] at h\nend\n\nprivate lemma nth_notin_strict_mono : strict_mono (nth_notin X) :=\n  nat.nth_strict_mono _ (nat_finset_infinite_compl X)\n\nprivate lemma nth_notin_fn_inj : injective (nth_notin X) :=\n  strict_mono.injective (nth_notin_strict_mono X)\n\nprivate lemma nth_notin_empty : nth_notin ∅ = id :=\n  by simp [nth_notin, nth_true]\n\nprivate lemma count_notin_large {n : ℕ} (h : X.sup id < n) :\n  nat.count (λ x, x ∉ X) (n + X.card) = n :=\nbegin\n  have h0 := congr_arg card (filter_union_filter_neg_eq (λ x, x ∈ X) (range (n + X.card))),\n  rw [card_range, card_union_eq, ← nat.count_eq_card_filter_range,\n      ← nat.count_eq_card_filter_range, nat.count_eq_card_fintype] at h0,\n  work_on_goal 2 { rw disjoint_iff_inter_eq_empty, exact filter_inter_filter_neg_eq _ _ _ },\n  rw [← add_left_inj X.card, add_comm]; convert h0 using 2; clear h0,\n  suffices : ∀ k : ℕ, k ∈ X ↔ (k < n + X.card ∧ k ∈ X),\n    rw eq_comm; convert fintype.subtype_card X this, -- Why doesn't it work with `exact`???\n  simp only [iff_and_self]; intros k h0,\n  refine lt_of_le_of_lt (le_sup h0) (lt_trans h _),\n  rw [lt_add_iff_pos_right, pos_iff_ne_zero, ne.def, card_eq_zero],\n  rintros rfl; exact h0\nend\n\nprivate lemma nth_notin_large {n : ℕ} (h : X.sup id < n) : nth_notin X n = n + X.card :=\nbegin\n  have h0 := nat_finset_infinite_compl X,\n  rw [nth_notin, eq_comm, eq_iff_le_not_lt]; split,\n  rw [← nat.count_le_iff_le_nth _ h0, count_notin_large X h],\n  rw [← nat.succ_le_iff, ← nat.count_le_iff_le_nth _ h0, nat.count_succ, count_notin_large X h,\n      add_le_iff_nonpos_right, nonpos_iff_eq_zero, ← ne.def, ite_ne_right_iff, and_comm],\n  refine ⟨one_ne_zero, λ h1, _⟩,\n  replace h1 : id (n + X.card) ≤ X.sup id := le_sup h1,\n  rw [id.def, ← not_lt] at h1,\n  exact h1 (lt_of_lt_of_le h le_self_add)\nend\n\nend finset_lemmas\n\n\n\nsection cup_mul_lemmas\n\nlemma cup_mul_empty (X : finset ℕ) : X ** ∅ = X :=\n  by rw [cup_mul, image_empty, union_empty]\n  \nlemma empty_cup_mul (X : finset ℕ) : ∅ ** X = X :=\n  by rw [cup_mul, empty_union, nth_notin_empty, image_id]\n\n/-- For any `X Y : finset ℕ`, `|X ** Y| = |X| + |Y|`. -/\nlemma cup_mul_card (X Y : finset ℕ) : (X ** Y).card = X.card + Y.card :=\nbegin\n  rw [cup_mul, card_disjoint_union, card_image_of_injective Y (nth_notin_fn_inj X)],\n  rw disjoint_right; intros a h1 h0,\n  rw ← mem_coe at h1,\n  replace h1 : a ∈ set.range (nth_notin X) := coe_image_subset_range h1,\n  rw [range_nth_notin_eq_compl, set.mem_compl_iff, finset.mem_coe] at h1,\n  exact h1 h0\nend\n\n/-- Lemma 1 in the official solution: `f_{X ** Y} = f_X ∘ f_Y` -/\nlemma cup_mul_range (X Y : finset ℕ) : nth_notin (X ** Y) = nth_notin X ∘ nth_notin Y :=\nbegin\n  rw ← well_founded.eq_strict_mono_iff_eq_range is_well_founded.wf (nth_notin_strict_mono _),\n  work_on_goal 2 { exact strict_mono.comp (nth_notin_strict_mono _) (nth_notin_strict_mono _) },\n  rw [range_nth_notin_eq_compl, set.range_comp, range_nth_notin_eq_univ_diff, set.image_diff,\n      set.image_univ, range_nth_notin_eq_univ_diff, set.diff_diff, ← set.compl_eq_univ_diff,\n      compl_inj_iff, cup_mul, coe_union, coe_image],\n  exact nth_notin_fn_inj X\nend\n\n/-- The `cup_mul` operation is associative. -/\ntheorem cup_mul_assoc (X Y Z : finset ℕ) : X ** Y ** Z = X ** (Y ** Z) :=\n  by rw ← nth_notin_inj; repeat { rw cup_mul_range }\n\n/-- Lemma 2 in the official solution: if X ** Y = Y ** X and |X| = |Y| then X = Y -/\nlemma cup_mul_comm_card_eq {X Y : finset ℕ} (h : X.card = Y.card) (h0 : X ** Y = Y ** X) : X = Y :=\nbegin\n  rw ← nth_notin_inj at h0 ⊢,\n  rw [cup_mul_range, cup_mul_range] at h0,\n  refine strict_mono_eq_at_large_comm (nth_notin_strict_mono X) (nth_notin_strict_mono Y) _ h0,\n  use max (X.sup id) (Y.sup id) + 1; intros n h1,\n  rw [nat.succ_le_iff, max_lt_iff] at h1,\n  cases h1 with h1 h2,\n  rw [nth_notin_large X h1, nth_notin_large Y h2, h]\nend\n\nend cup_mul_lemmas\n\n\n\nsection cup_pow_lemmas\n\nlemma cup_pow_zero (X : finset ℕ) : X ^^ 0 = ∅ := rfl\n\nlemma cup_pow_succ (X : finset ℕ) (k : ℕ) : X ^^ k.succ = X ** X ^^ k :=\n  by rw [cup_pow, cup_pow, iterate_succ', comp_app]\n\n/- For any `X : finset ℕ` and `k : ℕ`, `|X^^k| = k |X|`. -/\nlemma cup_pow_card (X : finset ℕ) (k : ℕ) : (X ^^ k).card = k * X.card :=\nbegin\n  induction k with k k_ih,\n  rw [cup_pow_zero, card_empty, zero_mul],\n  rw [cup_pow_succ, cup_mul_card, k_ih, nat.succ_mul, add_comm]\nend\n\n/- If `X` commutes with `Y`, then `X^^k` commutes with `Y` for any `k`. -/\nlemma cup_pow_comm' {X Y : finset ℕ} (h : X ** Y = Y ** X) (k : ℕ) :\n  X ^^ k ** Y = Y ** X ^^ k :=\nbegin\n  induction k with k k_ih,\n  rw [cup_pow_zero, cup_mul_empty, empty_cup_mul],\n  rw [cup_pow_succ, cup_mul_assoc, k_ih, ← cup_mul_assoc, ← cup_mul_assoc, h]\nend\n\n/- If `X` commutes with `Y`, then `X^^k` commutes with `Y^^m` for any `k` and `m`. -/\nlemma cup_pow_comm {X Y : finset ℕ} (h : X ** Y = Y ** X) (k m : ℕ) :\n  X ^^ k ** Y ^^ m = Y ^^ m ** X ^^ k :=\n  cup_pow_comm' (eq_comm.mp (cup_pow_comm' (eq_comm.mp h) m)) k\n\nend cup_pow_lemmas\n\n\n\n/- Final solution -/\ntheorem final_solution (X Y : finset ℕ) (h : X ** Y = Y ** X) : X ^^ Y.card = Y ^^ X.card :=\nbegin\n  refine cup_mul_comm_card_eq _ (cup_pow_comm h _ _),\n  rw [cup_pow_card, cup_pow_card, mul_comm]\nend\n\nend IMO2017C7\nend IMOSL\n", "meta": {"author": "mortarsanjaya", "repo": "imo-A-and-N", "sha": "645a924da7442f41d56ee6a0d96dc4d777b593a9", "save_path": "github-repos/lean/mortarsanjaya-imo-A-and-N", "path": "github-repos/lean/mortarsanjaya-imo-A-and-N/imo-A-and-N-645a924da7442f41d56ee6a0d96dc4d777b593a9/src/IMO2017/C7/C7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.48715240515917657}}
{"text": "/-\nCopyright (c) 2022 James Gallicchio.\n\nAuthors: James Gallicchio\n-/\n\nimport LeanColls.AuxLemmas\nimport LeanColls.Classes\n\nnamespace LeanColls\n\n/-!\n# Finger Trees\n\nTODO: Describe\n\n## References\n\nSee [Sozeau2007], section 4 and [Claessen2020]\n\n-/\nnamespace FingerTree\n\ninductive Digit (τ : Type u)\n| _1 : τ → Digit τ\n| _2 : τ → τ → Digit τ\n| _3 : τ → τ → τ → Digit τ\n\nnamespace Digit\n\n@[inline]\ndef tryAddLeft (d : Digit τ) (a : τ) (sc : Digit τ → α) (fc : τ → τ → τ → α) : α :=\n  match d with\n  | _1 b     => sc (_2 a b)\n  | _2 b c   => sc (_3 a b c)\n  | _3 b c d => fc b c d\n\n@[inline]\ndef tryFront (d : Digit τ) (sc : τ → Digit τ → α) (fc : τ → α) : α :=\n  match d with\n  | _1 a       => fc a\n  | _2 a b     => sc a (_1 b)\n  | _3 a b c   => sc a (_2 b c)\n\n@[inline]\ndef tryAddRight (d : Digit τ) (z : τ) (sc : Digit τ → α) (fc : τ → τ → τ → α) : α :=\n  match h':d with\n  | _1 y        => sc (_2 y z)\n  | _2 x y      => sc (_3 x y z)\n  | _3 w x y  => fc w x y\n\n@[inline]\ndef tryBack (d : Digit τ) (sc : τ → Digit τ → α) (fc : τ → α) : α :=\n  match d with\n  | _1 z       => fc z\n  | _2 y z     => sc z (_1 y)\n  | _3 x y z   => sc z (_2 x y)\n\ndef toList : Digit τ → List τ\n| _1 a       => [a]\n| _2 a b     => [a,b]\n| _3 a b c   => [a,b,c]\n\nend Digit\n\n\ninductive Node (τ : Type u)\n| _2 : τ → τ → Node τ \n| _3 : τ → τ → τ → Node τ\n\nnamespace Node\n\ndef toDigit : Node τ → Digit τ\n| _2 a b => Digit._2 a b\n| _3 a b c => Digit._3 a b c\n\ndef toList : Node τ → List τ\n| _2 a b     => [a,b]\n| _3 a b c   => [a,b,c]\n\ntheorem toList_toDigit {n : Node τ}\n  : n.toDigit.toList = n.toList\n  := by\n  cases n\n  repeat { simp [Digit.toList, toDigit, toList] }\n\nend Node\n\nopen Node\n\ndef NodeTree (τ : Type u) : Nat → Type u\n| 0 => τ\n| (n+1) => Node (NodeTree τ n)\n\nend FingerTree\n\nopen FingerTree\n\ninductive FingerTree (τ : Type u) : (n : Nat) → Type u\n| Empty : FingerTree τ n\n| Single : NodeTree τ n → FingerTree τ n\n| Deep : Digit (NodeTree τ n) → FingerTree τ (n+1) → Digit (NodeTree τ n) → FingerTree τ n\n\nnamespace FingerTree\n\ndef empty : FingerTree τ 0 := Empty\n\ndef toList : FingerTree τ n → List (NodeTree τ n)\n| Empty => []\n| Single x => [x]\n| Deep pr tr sf =>\n  pr.toList ++\n  (tr.toList.bind Node.toList : List (NodeTree τ n)) ++\n  sf.toList\n\n@[inline]\ndef cons (f : FingerTree τ n) (a : NodeTree τ n) : FingerTree τ n :=\n  match f with\n  | Empty => Single a\n  | Single b => Deep (Digit._1 a) Empty (Digit._1 b)\n  | Deep pr tr sf =>\n    Digit.tryAddLeft pr a\n      (λ pr' => Deep pr' tr sf)\n      (λ b c d => Deep (Digit._2 a b) (tr.cons (Node._2 c d)) sf)\n\n@[inline]\ndef front? (f : FingerTree τ n) : Option (NodeTree τ n × FingerTree τ n) :=\n  match f with\n  | Empty         => none\n  | Single a      => some (a, Empty)\n  | Deep pr tr sf => some (\n    Digit.tryFront pr\n      (λ a pr' => (a, Deep pr' tr sf))\n      (λ a => /- pr = Digit1 a -/ (a,\n        match front? tr with\n        | some (n, tr') => Deep n.toDigit tr' sf\n        | none => /- tr empty -/\n          Digit.tryFront sf\n            (λ b sf' => Deep (Digit._1 b) Empty sf')\n            (λ b => /- sf = Digit1 b -/\n              Single b))))\n\n@[simp]\ntheorem toList_cons (f : FingerTree τ n) (a : NodeTree τ n)\n  : (f.cons a).toList = a :: f.toList\n  := by\n  induction f\n  simp [cons, toList]\n  simp [cons, toList, Digit.toList, List.bind, List.map, List.join]\n  case Deep pr tr sf ih =>\n  simp [cons, Digit.tryAddLeft]\n  split\n  simp [toList, Digit.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, List.bind, List.map, List.join]\n  case h_3 b c d =>\n  simp [toList, Digit.toList, List.bind, List.map, List.join, ih]\n  split\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join]\n\n@[simp]\ntheorem toList_front (f : FingerTree τ n)\n  : f.front?.map (λ (a,f') => (a,f'.toList)) = f.toList.front?\n  := by\n  induction f\n  simp [front?, toList, List.front?, Option.map, Option.bind]\n  simp [front?, toList, List.front?, Option.map, Option.bind]\n  case Deep pr tr sf ih =>\n  match pr with\n  | Digit._2 a b     => simp [front?, toList, List.front?, Digit.tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append]\n  | Digit._3 a b c   => simp [front?, toList, List.front?, Digit.tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append]\n  | Digit._1 a =>\n    match h:front? tr with\n    | some (t,tr') =>\n      rw [h] at ih\n      simp [Option.map, Option.bind, List.front?] at ih\n      split at ih\n      contradiction\n      case h_2 x h_tr =>\n      cases ih\n      simp [h,h_tr,front?, toList, List.front?, Digit.tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append, List.bind, List.map, List.join]\n      cases t\n      repeat {simp [Digit.toList, Node.toDigit, Node.toList]}\n    | none =>\n      rw [h] at ih\n      simp [Option.map, Option.bind, List.front?] at ih\n      split at ih\n      focus {\n        case h_1 x h_tr =>\n        simp [h,h_tr,front?, toList, List.front?, Digit.tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append, List.bind, List.map, List.join]\n        split\n        repeat { simp [Digit.toList, toList, List.bind, List.join, List.map] }\n      }\n      contradiction\n\ndef snoc (f : FingerTree τ n) (z : NodeTree τ n) : FingerTree τ n :=\n  match f with\n  | Empty => Single z\n  | Single b => Deep (Digit._1 b) Empty (Digit._1 z)\n  | Deep pr tr sf =>\n    Digit.tryAddRight sf z\n      (λ sf' => Deep pr tr sf')\n      (λ a b c => Deep pr (tr.snoc (Node._3 a b c)) (Digit._1 z))\n\ndef back? (f : FingerTree τ n) : Option (FingerTree τ n × NodeTree τ n) :=\n  match f with\n  | Empty         => none\n  | Single z      => some (Empty, z)\n  | Deep pr tr sf => some (\n    Digit.tryBack sf\n      (λ z sf' => (Deep pr tr sf', z))\n      (λ z => /- sf = Digit1 z -/ (\n        match back? tr with\n        | some (tr', n) => Deep pr tr' n.toDigit\n        | none => /- tr empty -/\n          Digit.tryBack pr\n            (λ y pr' => Deep pr' Empty (Digit._1 y))\n            (λ y => /- pr = Digit1 y -/\n              Single y),\n        z)))\n\n@[simp]\ntheorem toList_snoc (f : FingerTree τ n) (a : NodeTree τ n)\n  : (f.snoc a).toList = f.toList.concat a\n  := by\n  induction f\n  simp [snoc, toList, List.concat]\n  simp [snoc, toList, Digit.toList, List.bind, List.map, List.join, List.concat]\n  case Deep pr tr sf ih =>\n  simp [snoc, Digit.tryAddRight]\n  split\n  simp [toList, Digit.toList, List.bind, List.map, List.join, List.concat_append, List.concat]\n  simp [toList, Digit.toList, List.bind, List.map, List.join, List.concat_append, List.concat]\n  case h_3 b c d e =>\n  simp [toList, Digit.toList, List.bind, List.map, List.join, ih, List.concat_append, List.concat]\n  split\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join, List.concat_append, List.concat, List.map_concat, List.join_concat, List.append_assoc]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join, List.concat_append, List.concat, List.map_concat, List.join_concat, List.append_assoc]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join, List.concat_append, List.concat, List.map_concat, List.join_concat, List.append_assoc]\n\n@[simp]\ntheorem toList_back (f : FingerTree τ n)\n  : f.back?.map (λ (f',a) => (f'.toList,a)) = f.toList.back?\n  := by\n  induction f\n  simp [back?, toList, List.back?, Option.map, Option.bind]\n  simp [back?, toList, List.back?, Option.map, Option.bind]\n  case Deep pr tr sf ih =>\n  match sf with\n  | Digit._2 a b =>\n    simp [toList, Digit.toList]\n    have : [a,b] = [a].concat b := by rfl\n    rw [this, ←List.concat_append, List.back_concat]\n    simp [back?, Option.map, Option.bind, Digit.tryBack, toList, Digit.toList]\n  | Digit._3 a b c =>\n    simp [toList, Digit.toList]\n    have : [a,b,c] = [a,b].concat c := by rfl\n    rw [this, ←List.concat_append, List.back_concat]\n    simp [back?, Option.map, Option.bind, Digit.tryBack, toList, Digit.toList]\n  | Digit._1 a =>\n    match h:back? tr with\n    | some (tr',t) =>\n      rw [h] at ih\n      simp [Option.map, Option.bind] at ih\n      have : toList tr = (toList tr').concat t :=\n        (List.back_some_iff_concat _).mp ih.symm\n      simp [this, back?, Digit.tryBack, Option.map, Option.bind, h, toList]\n      have : Digit.toList (Digit._1 a) = [].concat a := by rfl\n      rw [this]\n      rw [←List.concat_append,List.back_concat]\n      simp [List.bind, Node.toList_toDigit, List.append_assoc]\n    | none =>\n      rw [h] at ih\n      simp [Option.map, Option.bind] at ih\n      have : tr = Empty := by\n        match tr with\n        | Empty => rfl\n        | Single _ => contradiction\n        | Deep _ _ _ => contradiction\n      simp [Option.map, Option.bind, back?, this, Digit.tryBack]\n      simp [toList, Digit.toList, List.bind, List.map, List.join]\n      have : [a] = [].concat a := by rfl\n      rw [this]\n      rw [←List.concat_append,List.back_concat]\n      simp\n      split\n      repeat { simp [Digit.toList, toList, List.bind, List.join, List.map] }\n\ntheorem length_toList_deep {tr : FingerTree τ (n+1)}\n  : List.length (toList tr) ≤ List.length (List.bind (toList tr) Node.toList)\n  := by\n  generalize toList tr = L\n  simp [List.bind]\n  induction L with\n  | nil => simp [List.map, List.join]\n  | cons l ls ih =>\n  simp [List.map, List.join]\n  suffices 1 ≤ List.length (Node.toList l) by\n    have := Nat.add_le_add this ih\n    rw [←Nat.add_one, Nat.add_comm]\n    exact this\n  simp [Node.toList]; split <;> simp\n\ndef append (f1 f2 : FingerTree τ n) : FingerTree τ n :=\n  match f1, f2 with\n  | f1, Empty => f1\n  | Empty, f2 => f2\n  | f1, Single z => f1.snoc z\n  | Single a, f1 => f1.cons a\n  | Deep pr1 tr1 sf1, Deep pr2 tr2 sf2 =>\n    have : List.length (toList tr1) ≤ List.length (List.bind (toList tr1) Node.toList)\n      := length_toList_deep\n    have : List.length (toList tr2) ≤ List.length (List.bind (toList tr2) Node.toList)\n      := length_toList_deep\n    let tr' := match sf1, pr2 with\n    | Digit._1 a,     Digit._1 b     => (tr1.snoc (Node._2 a b)).append tr2\n    | Digit._2 a b,   Digit._1 c     => (tr1.snoc (Node._3 a b c)).append tr2\n    | Digit._1 a,     Digit._2 b c   => tr1.append (tr2.cons (Node._3 a b c))\n    | Digit._3 a b c, Digit._1 d     => (tr1.snoc (Node._2 a b)).append (tr2.cons (Node._2 c d))\n    | Digit._2 a b,   Digit._2 c d   => (tr1.snoc (Node._2 a b)).append (tr2.cons (Node._2 c d))\n    | Digit._1 a,     Digit._3 b c d => (tr1.snoc (Node._2 a b)).append (tr2.cons (Node._2 c d))\n    | Digit._3 a b c, Digit._2 d e   => (tr1.snoc (Node._3 a b c)).append (tr2.cons (Node._2 d e))\n    | Digit._2 a b,   Digit._3 c d e => (tr1.snoc (Node._2 a b)).append (tr2.cons (Node._3 c d e))\n    | Digit._3 a b c, Digit._3 d e f => (tr1.snoc (Node._3 a b c)).append (tr2.cons (Node._3 d e f))\n\n    Deep pr1 tr' sf2\n  termination_by _ f1 f2 => f1.toList.length + f2.toList.length\n  decreasing_by\n    sorry\n\ninstance {α} : Enumerable (FingerTree α 0) α where\n  ρ := FingerTree α 0\n  fromEnumerator := id\n  insert := λ\n    | none => empty\n    | some (x,ft) => ft.cons x\n\ninstance {α} : Iterable (FingerTree α 0) α where\n  ρ := FingerTree α 0\n  toIterator := id\n  step := front?\n\nend FingerTree", "meta": {"author": "JamesGallicchio", "repo": "LeanColls", "sha": "9cb0a0c9a838bea24be80eace168bcc5f9481596", "save_path": "github-repos/lean/JamesGallicchio-LeanColls", "path": "github-repos/lean/JamesGallicchio-LeanColls/LeanColls-9cb0a0c9a838bea24be80eace168bcc5f9481596/LeanColls/FingerTree/FingerTree.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.63341027751814, "lm_q2_score": 0.7690802370707283, "lm_q1q2_score": 0.48714332639668695}}
{"text": "/-\nCopyright (c) 2021 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport category_theory.preadditive.basic\n\n/-!\n# Preadditive structure on functor categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIf `C` and `D` are categories and `D` is preadditive,\nthen `C ⥤ D` is also preadditive.\n\n-/\n\nopen_locale big_operators\n\nnamespace category_theory\nopen category_theory.limits preadditive\n\nvariables {C D : Type*} [category C] [category D] [preadditive D]\n\ninstance functor_category_preadditive : preadditive (C ⥤ D) :=\n{ hom_group := λ F G,\n  { add := λ α β,\n    { app := λ X, α.app X + β.app X,\n      naturality' := by { intros, rw [comp_add, add_comp, α.naturality, β.naturality] } },\n    zero := { app := λ X, 0, naturality' := by { intros, rw [zero_comp, comp_zero] } },\n    neg := λ α,\n    { app := λ X, -α.app X,\n      naturality' := by { intros, rw [comp_neg, neg_comp, α.naturality] } },\n    sub := λ α β,\n    { app := λ X, α.app X - β.app X,\n      naturality' := by { intros, rw [comp_sub, sub_comp, α.naturality, β.naturality] } },\n    add_assoc := by { intros, ext, apply add_assoc },\n    zero_add := by { intros, ext, apply zero_add },\n    add_zero := by { intros, ext, apply add_zero },\n    sub_eq_add_neg := by { intros, ext, apply sub_eq_add_neg },\n    add_left_neg := by { intros, ext, apply add_left_neg },\n    add_comm := by { intros, ext, apply add_comm } },\n  add_comp' := by { intros, ext, apply add_comp },\n  comp_add' := by { intros, ext, apply comp_add } }\n\nnamespace nat_trans\n\nvariables {F G : C ⥤ D}\n\n/-- Application of a natural transformation at a fixed object,\nas group homomorphism -/\n@[simps] def app_hom (X : C) : (F ⟶ G) →+ (F.obj X ⟶ G.obj X) :=\n{ to_fun := λ α, α.app X,\n  map_zero' := rfl,\n  map_add' := λ _ _, rfl }\n\n@[simp] lemma app_zero (X : C) : (0 : F ⟶ G).app X = 0 := rfl\n\n@[simp] \n\n@[simp] lemma app_sub (X : C) (α β : F ⟶ G) : (α - β).app X = α.app X - β.app X := rfl\n\n@[simp] lemma app_neg (X : C) (α : F ⟶ G) : (-α).app X = -α.app X := rfl\n\n@[simp] lemma app_nsmul (X : C) (α : F ⟶ G) (n : ℕ) : (n • α).app X = n • α.app X :=\n(app_hom X).map_nsmul α n\n\n@[simp] lemma app_zsmul (X : C) (α : F ⟶ G) (n : ℤ) : (n • α).app X = n • α.app X :=\n(app_hom X : (F ⟶ G) →+ (F.obj X ⟶ G.obj X)).map_zsmul α n\n\n@[simp] lemma app_sum {ι : Type*} (s : finset ι) (X : C) (α : ι → (F ⟶ G)) :\n  (∑ i in s, α i).app X = ∑ i in s, ((α i).app X) :=\nby { rw [← app_hom_apply, add_monoid_hom.map_sum], refl }\n\nend nat_trans\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/preadditive/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4871433263966868}}
{"text": "import natural.definition\n\n@[derive decidable_eq]\ninductive Z\n| pos (n : N) : Z\n| neg_succ (n : N) : Z\n\nnamespace Z\n\ninstance : has_zero Z := ⟨ pos N.zero ⟩ \ntheorem zero_eq_zero : pos N.zero = 0 := rfl\n\ndef one : Z := pos (N.succ 0)\n\ninstance : has_one Z := ⟨ Z.one ⟩ \ntheorem one_eq_one : one = 1 := rfl\n\nlemma reduce_one : 1 = pos (N.succ 0) := rfl\n\ntheorem eq_comm (a b : Z) : (a = b) -> (b = a) :=\nbegin\n  intro h,\n  rw h,\nend\n\nlemma eq_pos_eq (a b : N) : (a = b) -> (pos a = pos b) := \nbegin\n  intro h,\n  rw h,\nend\n\nlemma eq_neg_eq (a b : N) : (a = b) -> (neg_succ a = neg_succ b) :=\nbegin\n  intro h,\n  rw h,\nend\n\nlemma pos_neq_neg (a b : N) : pos a ≠ neg_succ b :=\nbegin\n  intro h,\n  cases h,\nend\n\nlemma neg_neq_pos (a b : N) : neg_succ a ≠ pos b :=\nbegin\n  intro h,\n  cases h,\nend\n\ntheorem int1_to_nat (q : Prop) : (∀ (a: Z), q) -> (∀ (b: N), q) :=\nbegin\n  intro h,\n  intro a,\n  have b := pos a,\n  exact h b,\nend\n\ntheorem int2_to_nat (q : Prop) : (∀ (a b: Z), q) -> (∀ (c d: N), q) :=\nbegin\n  intro h,\n  intros a b,\n  have c := pos a,\n  have d := pos b,\n  exact h c d,\nend\n\nend Z", "meta": {"author": "Jijasan", "repo": "UselessArithProofs", "sha": "c2e48e9a83b327246ba86debb1ef2fe87919c00d", "save_path": "github-repos/lean/Jijasan-UselessArithProofs", "path": "github-repos/lean/Jijasan-UselessArithProofs/UselessArithProofs-c2e48e9a83b327246ba86debb1ef2fe87919c00d/src/integer/definition.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.48714331575238573}}
{"text": "theorem foo1 (x : Nat) : 0 + x = x := by\n  first\n   | skip; have : x + x = x + x := rfl; done\n          --^ $/lean/plainGoal\n   | simp\n\ntheorem foo2 (x : Nat) : 0 + x = x := by\n  induction x with\n  | zero => done\n          --^ $/lean/plainGoal\n  | succ => done\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/interactive/goalIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117769928211, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4868415797488322}}
{"text": "variable {α : Type*}\n\ndef is_prefix (l₁ : list α) (l₂ : list α) : Prop :=\n∃ t, l₁ ++ t = l₂\n\ninfix ` <+: `:50 := is_prefix\n\n@[simp, refl]\ntheorem list.is_prefix_refl (l : list α) : l <+: l :=\n⟨[], by simp⟩\n\nexample : [1, 2, 3] <+: [1, 2, 3] := by reflexivity\n", "meta": {"author": "agryman", "repo": "theorem-proving-in-lean", "sha": "cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9", "save_path": "github-repos/lean/agryman-theorem-proving-in-lean", "path": "github-repos/lean/agryman-theorem-proving-in-lean/theorem-proving-in-lean-cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9/src/06-Interacting-with-Lean/example-6.4-5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7431679972357831, "lm_q1q2_score": 0.48669680418250877}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Scott Morrison, Adam Topaz\n-/\nimport algebraic_topology.simplex_category\nimport category_theory.arrow\nimport category_theory.limits.functor_category\nimport category_theory.opposites\n\n/-!\n# Simplicial objects in a category.\n\nA simplicial object in a category `C` is a `C`-valued presheaf on `simplex_category`.\n(Similarly a cosimplicial object is functor `simplex_category ⥤ C`.)\n\nUse the notation `X _[n]` in the `simplicial` locale to obtain the `n`-th term of a\n(co)simplicial object `X`, where `n` is a natural number.\n\n-/\n\nopen opposite\nopen category_theory\nopen category_theory.limits\n\nuniverses v u v' u'\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/-- The category of simplicial objects valued in a category `C`.\nThis is the category of contravariant functors from `simplex_category` to `C`. -/\n@[derive category, nolint has_nonempty_instance]\ndef simplicial_object := simplex_categoryᵒᵖ ⥤ C\n\nnamespace simplicial_object\n\nlocalized \"notation (name := simplicial_object.at) X ` _[`:1000 n `]` :=\n  (X : category_theory.simplicial_object hole!).obj (opposite.op (simplex_category.mk n))\"\n  in simplicial\n\ninstance {J : Type v} [small_category J] [has_limits_of_shape J C] :\n  has_limits_of_shape J (simplicial_object C) := by {dsimp [simplicial_object], apply_instance}\n\ninstance [has_limits C] : has_limits (simplicial_object C) := ⟨infer_instance⟩\n\ninstance {J : Type v} [small_category J] [has_colimits_of_shape J C] :\n  has_colimits_of_shape J (simplicial_object C) := by {dsimp [simplicial_object], apply_instance}\n\ninstance [has_colimits C] : has_colimits (simplicial_object C) := ⟨infer_instance⟩\n\nvariables {C} (X : simplicial_object C)\n\n/-- Face maps for a simplicial object. -/\ndef δ {n} (i : fin (n+2)) : X _[n+1] ⟶ X _[n] :=\nX.map (simplex_category.δ i).op\n\n/-- Degeneracy maps for a simplicial object. -/\ndef σ {n} (i : fin (n+1)) : X _[n] ⟶ X _[n+1] :=\nX.map (simplex_category.σ i).op\n\n\n/-- Isomorphisms from identities in ℕ. -/\ndef eq_to_iso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] :=\nX.map_iso (eq_to_iso (by rw h))\n\n@[simp] lemma eq_to_iso_refl {n : ℕ} (h : n = n) : X.eq_to_iso h = iso.refl _ :=\nby { ext, simp [eq_to_iso], }\n\n\n/-- The generic case of the first simplicial identity -/\n@[reassoc]\nlemma δ_comp_δ {n} {i j : fin (n+2)} (H : i ≤ j) :\n  X.δ j.succ ≫ X.δ i = X.δ i.cast_succ ≫ X.δ j :=\nby { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ H] }\n\n@[reassoc]\nlemma δ_comp_δ' {n} {i : fin (n+2)} {j : fin (n+3)} (H : i.cast_succ < j) :\n  X.δ j ≫ X.δ i = X.δ i.cast_succ ≫\n    X.δ (j.pred (λ hj, by simpa only [hj, fin.not_lt_zero] using H)) :=\nby { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ' H] }\n\n@[reassoc]\n\n\n/-- The special case of the first simplicial identity -/\n@[reassoc]\nlemma δ_comp_δ_self {n} {i : fin (n+2)} : X.δ i.cast_succ ≫ X.δ i = X.δ i.succ ≫ X.δ i :=\nby { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ_self] }\n\n@[reassoc]\nlemma δ_comp_δ_self' {n} {j : fin (n+3)} {i : fin (n+2)} (H : j = i.cast_succ) :\n  X.δ j ≫ X.δ i = X.δ i.succ ≫ X.δ i :=\nby { subst H, rw δ_comp_δ_self, }\n\n/-- The second simplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_of_le {n} {i : fin (n+2)} {j : fin (n+1)} (H : i ≤ j.cast_succ) :\n  X.σ j.succ ≫ X.δ i.cast_succ = X.δ i ≫ X.σ j :=\nby { dsimp [δ, σ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_le H] }\n\n/-- The first part of the third simplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_self {n} {i : fin (n+1)} :\n  X.σ i ≫ X.δ i.cast_succ = 𝟙 _ :=\nbegin\n  dsimp [δ, σ],\n  simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_self, op_id, X.map_id],\nend\n\n@[reassoc]\nlemma δ_comp_σ_self' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.cast_succ):\n  X.σ i ≫ X.δ j = 𝟙 _ := by { subst H, rw δ_comp_σ_self, }\n\n/-- The second part of the third simplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_succ {n} {i : fin (n+1)} :\n  X.σ i ≫ X.δ i.succ = 𝟙 _ :=\nbegin\n  dsimp [δ, σ],\n  simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_succ, op_id, X.map_id],\nend\n\n@[reassoc]\nlemma δ_comp_σ_succ' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.succ) :\n  X.σ i ≫ X.δ j = 𝟙 _ := by { subst H, rw δ_comp_σ_succ, }\n\n/-- The fourth simplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_of_gt {n} {i : fin (n+2)} {j : fin (n+1)} (H : j.cast_succ < i) :\n  X.σ j.cast_succ ≫ X.δ i.succ = X.δ i ≫ X.σ j :=\nby { dsimp [δ, σ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_gt H] }\n\n@[reassoc]\nlemma δ_comp_σ_of_gt' {n} {i : fin (n+3)} {j : fin (n+2)} (H : j.succ < i) :\n  X.σ j ≫ X.δ i = X.δ (i.pred (λ hi, by simpa only [fin.not_lt_zero, hi] using H)) ≫\n    X.σ (j.cast_lt ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le\n      (by simpa only [fin.val_eq_coe, ← fin.coe_succ]\n        using fin.lt_iff_coe_lt_coe.mp H) i.is_le))) :=\nby { dsimp [δ, σ], simpa only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_gt' H], }\n\n/-- The fifth simplicial identity -/\n@[reassoc]\nlemma σ_comp_σ {n} {i j : fin (n+1)} (H : i ≤ j) :\n  X.σ j ≫ X.σ i.cast_succ = X.σ i ≫ X.σ j.succ :=\nby { dsimp [δ, σ], simp only [←X.map_comp, ←op_comp, simplex_category.σ_comp_σ H] }\n\nopen_locale simplicial\n\n@[simp, reassoc]\nlemma δ_naturality {X' X : simplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+2)) :\n  X.δ i ≫ f.app (op [n]) = f.app (op [n+1]) ≫ X'.δ i := f.naturality _\n\n@[simp, reassoc]\nlemma σ_naturality {X' X : simplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+1)) :\n  X.σ i ≫ f.app (op [n+1]) = f.app (op [n]) ≫ X'.σ i := f.naturality _\n\nvariable (C)\n\n/-- Functor composition induces a functor on simplicial objects. -/\n@[simps]\ndef whiskering (D : Type*) [category D] :\n  (C ⥤ D) ⥤ simplicial_object C ⥤ simplicial_object D :=\nwhiskering_right _ _ _\n\n/-- Truncated simplicial objects. -/\n@[derive category, nolint has_nonempty_instance]\ndef truncated (n : ℕ) := (simplex_category.truncated n)ᵒᵖ ⥤ C\n\nvariable {C}\n\nnamespace truncated\n\ninstance {n} {J : Type v} [small_category J] [has_limits_of_shape J C] :\n  has_limits_of_shape J (simplicial_object.truncated C n) := by {dsimp [truncated], apply_instance}\n\ninstance {n} [has_limits C] : has_limits (simplicial_object.truncated C n) := ⟨infer_instance⟩\n\ninstance {n} {J : Type v} [small_category J] [has_colimits_of_shape J C] :\n  has_colimits_of_shape J (simplicial_object.truncated C n) :=\nby {dsimp [truncated], apply_instance}\n\ninstance {n} [has_colimits C] : has_colimits (simplicial_object.truncated C n) := ⟨infer_instance⟩\n\nvariable (C)\n\n/-- Functor composition induces a functor on truncated simplicial objects. -/\n@[simps]\ndef whiskering {n} (D : Type*) [category D] :\n  (C ⥤ D) ⥤ truncated C n ⥤ truncated D n :=\nwhiskering_right _ _ _\n\nvariable {C}\n\nend truncated\n\nsection skeleton\n\n/-- The skeleton functor from simplicial objects to truncated simplicial objects. -/\ndef sk (n : ℕ) : simplicial_object C ⥤ simplicial_object.truncated C n :=\n(whiskering_left _ _ _).obj simplex_category.truncated.inclusion.op\n\nend skeleton\n\nvariable (C)\n\n/-- The constant simplicial object is the constant functor. -/\nabbreviation const : C ⥤ simplicial_object C := category_theory.functor.const _\n\n/-- The category of augmented simplicial objects, defined as a comma category. -/\n@[derive category, nolint has_nonempty_instance]\ndef augmented := comma (𝟭 (simplicial_object C)) (const C)\n\nvariable {C}\n\nnamespace augmented\n\n/-- Drop the augmentation. -/\n@[simps]\ndef drop : augmented C ⥤ simplicial_object C := comma.fst _ _\n\n/-- The point of the augmentation. -/\n@[simps]\ndef point : augmented C ⥤ C := comma.snd _ _\n\n/-- The functor from augmented objects to arrows. -/\n@[simps]\ndef to_arrow : augmented C ⥤ arrow C :=\n{ obj := λ X,\n  { left := (drop.obj X) _[0],\n    right := (point.obj X),\n    hom := X.hom.app _ },\n  map := λ X Y η,\n  { left := (drop.map η).app _,\n    right := (point.map η),\n    w' := begin\n      dsimp,\n      rw ← nat_trans.comp_app,\n      erw η.w,\n      refl,\n    end } }\n\n/-- The compatibility of a morphism with the augmentation, on 0-simplices -/\n@[reassoc]\nlemma w₀ {X Y : augmented C} (f : X ⟶ Y) :\n  (augmented.drop.map f).app (op (simplex_category.mk 0)) ≫\n    Y.hom.app (op (simplex_category.mk 0)) =\n  X.hom.app (op (simplex_category.mk 0)) ≫ augmented.point.map f :=\nby convert congr_app f.w (op (simplex_category.mk 0))\n\nvariable (C)\n\n/-- Functor composition induces a functor on augmented simplicial objects. -/\n@[simp]\ndef whiskering_obj (D : Type*) [category D] (F : C ⥤ D) :\n  augmented C ⥤ augmented D :=\n{ obj := λ X,\n  { left := ((whiskering _ _).obj F).obj (drop.obj X),\n    right := F.obj (point.obj X),\n    hom := whisker_right X.hom F ≫ (functor.const_comp _ _ _).hom },\n  map := λ X Y η,\n  { left := whisker_right η.left _,\n    right := F.map η.right,\n    w' := begin\n      ext,\n      dsimp,\n      rw [category.comp_id, category.comp_id, ← F.map_comp, ← F.map_comp, ← nat_trans.comp_app],\n      erw η.w,\n      refl,\n    end } }\n\n/-- Functor composition induces a functor on augmented simplicial objects. -/\n@[simps]\ndef whiskering (D : Type u') [category.{v'} D] :\n  (C ⥤ D) ⥤ augmented C ⥤ augmented D :=\n{ obj := whiskering_obj _ _,\n  map := λ X Y η,\n  { app := λ A,\n    { left := whisker_left _ η,\n      right := η.app _,\n      w' := begin\n        ext n,\n        dsimp,\n        rw [category.comp_id, category.comp_id, η.naturality],\n      end }, }, }\n\nvariable {C}\n\nend augmented\n\n/-- Augment a simplicial object with an object. -/\n@[simps]\ndef augment (X : simplicial_object C) (X₀ : C) (f : X _[0] ⟶ X₀)\n  (w : ∀ (i : simplex_category) (g₁ g₂ : [0] ⟶ i),\n    X.map g₁.op ≫ f = X.map g₂.op ≫ f) : simplicial_object.augmented C :=\n{ left := X,\n  right := X₀,\n  hom :=\n  { app := λ i, X.map (simplex_category.const i.unop 0).op ≫ f,\n    naturality' := begin\n      intros i j g,\n      dsimp,\n      rw ← g.op_unop,\n      simpa only [← X.map_comp, ← category.assoc, category.comp_id, ← op_comp] using w _ _ _,\n    end } }\n\n@[simp]\nlemma augment_hom_zero (X : simplicial_object C) (X₀ : C) (f : X _[0] ⟶ X₀) (w) :\n  (X.augment X₀ f w).hom.app (op [0]) = f :=\nby { dsimp, rw [simplex_category.hom_zero_zero ([0].const 0), op_id, X.map_id, category.id_comp] }\n\nend simplicial_object\n\n/-- Cosimplicial objects. -/\n@[derive category, nolint has_nonempty_instance]\ndef cosimplicial_object := simplex_category ⥤ C\n\nnamespace cosimplicial_object\n\nlocalized \"notation (name := cosimplicial_object.at) X ` _[`:1000 n `]` :=\n  (X : category_theory.cosimplicial_object hole!).obj (simplex_category.mk n)\" in simplicial\n\ninstance {J : Type v} [small_category J] [has_limits_of_shape J C] :\n  has_limits_of_shape J (cosimplicial_object C) := by {dsimp [cosimplicial_object], apply_instance}\n\ninstance [has_limits C] : has_limits (cosimplicial_object C) := ⟨infer_instance⟩\n\ninstance {J : Type v} [small_category J] [has_colimits_of_shape J C] :\n  has_colimits_of_shape J (cosimplicial_object C) :=\nby {dsimp [cosimplicial_object], apply_instance}\n\ninstance [has_colimits C] : has_colimits (cosimplicial_object C) := ⟨infer_instance⟩\n\nvariables {C} (X : cosimplicial_object C)\n\n/-- Coface maps for a cosimplicial object. -/\ndef δ {n} (i : fin (n+2)) : X _[n] ⟶ X _[n+1] :=\nX.map (simplex_category.δ i)\n\n/-- Codegeneracy maps for a cosimplicial object. -/\ndef σ {n} (i : fin (n+1)) : X _[n+1] ⟶ X _[n] :=\nX.map (simplex_category.σ i)\n\n/-- Isomorphisms from identities in ℕ. -/\ndef eq_to_iso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] :=\nX.map_iso (eq_to_iso (by rw h))\n\n@[simp] lemma eq_to_iso_refl {n : ℕ} (h : n = n) : X.eq_to_iso h = iso.refl _ :=\nby { ext, simp [eq_to_iso], }\n\n/-- The generic case of the first cosimplicial identity -/\n@[reassoc]\nlemma δ_comp_δ {n} {i j : fin (n+2)} (H : i ≤ j) :\n  X.δ i ≫ X.δ j.succ = X.δ j ≫ X.δ i.cast_succ :=\nby { dsimp [δ], simp only [←X.map_comp, simplex_category.δ_comp_δ H], }\n\n@[reassoc]\nlemma δ_comp_δ' {n} {i : fin (n+2)} {j : fin (n+3)} (H : i.cast_succ < j) :\n  X.δ i ≫ X.δ j = X.δ (j.pred (λ hj, by simpa only [hj, fin.not_lt_zero] using H)) ≫\n    X.δ i.cast_succ :=\nby { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ' H] }\n\n@[reassoc]\nlemma δ_comp_δ'' {n} {i : fin (n+3)} {j : fin (n+2)} (H : i ≤ j.cast_succ) :\n  X.δ (i.cast_lt (nat.lt_of_le_of_lt (fin.le_iff_coe_le_coe.mp H) j.is_lt)) ≫ X.δ j.succ =\n    X.δ j ≫ X.δ i :=\nby { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ'' H] }\n\n/-- The special case of the first cosimplicial identity -/\n@[reassoc]\nlemma δ_comp_δ_self {n} {i : fin (n+2)} : X.δ i ≫ X.δ i.cast_succ = X.δ i ≫ X.δ i.succ :=\nby { dsimp [δ], simp only [←X.map_comp, simplex_category.δ_comp_δ_self] }\n\n@[reassoc]\nlemma δ_comp_δ_self' {n} {i : fin (n+2)} {j : fin (n+3)} (H : j = i.cast_succ) :\n  X.δ i ≫ X.δ j = X.δ i ≫ X.δ i.succ :=\nby { subst H, rw δ_comp_δ_self, }\n\n/-- The second cosimplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_of_le {n} {i : fin (n+2)} {j : fin (n+1)} (H : i ≤ j.cast_succ) :\n  X.δ i.cast_succ ≫ X.σ j.succ = X.σ j ≫ X.δ i :=\nby { dsimp [δ, σ], simp only [←X.map_comp, simplex_category.δ_comp_σ_of_le H] }\n\n/-- The first part of the third cosimplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_self {n} {i : fin (n+1)} :\n  X.δ i.cast_succ ≫ X.σ i = 𝟙 _ :=\nbegin\n  dsimp [δ, σ],\n  simp only [←X.map_comp, simplex_category.δ_comp_σ_self, X.map_id],\nend\n\n@[reassoc]\nlemma δ_comp_σ_self' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.cast_succ) :\n  X.δ j ≫ X.σ i = 𝟙 _ :=\nby { subst H, rw δ_comp_σ_self, }\n\n/-- The second part of the third cosimplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_succ {n} {i : fin (n+1)} :\n  X.δ i.succ ≫ X.σ i = 𝟙 _ :=\nbegin\n  dsimp [δ, σ],\n  simp only [←X.map_comp, simplex_category.δ_comp_σ_succ, X.map_id],\nend\n\n@[reassoc]\nlemma δ_comp_σ_succ' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.succ) :\n  X.δ j ≫ X.σ i = 𝟙 _ :=\nby { subst H, rw δ_comp_σ_succ, }\n\n/-- The fourth cosimplicial identity -/\n@[reassoc]\nlemma δ_comp_σ_of_gt {n} {i : fin (n+2)} {j : fin (n+1)} (H : j.cast_succ < i) :\n  X.δ i.succ ≫ X.σ j.cast_succ = X.σ j ≫ X.δ i :=\nby { dsimp [δ, σ], simp only [←X.map_comp, simplex_category.δ_comp_σ_of_gt H] }\n\n@[reassoc]\nlemma δ_comp_σ_of_gt' {n} {i : fin (n+3)} {j : fin (n+2)} (H : j.succ < i) :\n  X.δ i ≫ X.σ j = X.σ (j.cast_lt ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le\n      (by simpa only [fin.val_eq_coe, ← fin.coe_succ]\n        using fin.lt_iff_coe_lt_coe.mp H) i.is_le))) ≫\n    X.δ (i.pred (λ hi, by simpa only [fin.not_lt_zero, hi] using H)) :=\nby { dsimp [δ, σ], simpa only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_gt' H], }\n\n/-- The fifth cosimplicial identity -/\n@[reassoc]\nlemma σ_comp_σ {n} {i j : fin (n+1)} (H : i ≤ j) :\n  X.σ i.cast_succ ≫ X.σ j = X.σ j.succ ≫ X.σ i :=\nby { dsimp [δ, σ], simp only [←X.map_comp, simplex_category.σ_comp_σ H] }\n\n@[simp, reassoc]\nlemma δ_naturality {X' X : cosimplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+2)) :\n  X.δ i ≫ f.app (simplex_category.mk (n+1)) =\n    f.app (simplex_category.mk n) ≫ X'.δ i := f.naturality _\n\n@[simp, reassoc]\nlemma σ_naturality {X' X : cosimplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+1)) :\n  X.σ i ≫ f.app (simplex_category.mk n) =\n    f.app (simplex_category.mk (n+1)) ≫ X'.σ i := f.naturality _\n\nvariable (C)\n\n/-- Functor composition induces a functor on cosimplicial objects. -/\n@[simps]\ndef whiskering (D : Type*) [category D] :\n  (C ⥤ D) ⥤ cosimplicial_object C ⥤ cosimplicial_object D :=\nwhiskering_right _ _ _\n\n/-- Truncated cosimplicial objects. -/\n@[derive category, nolint has_nonempty_instance]\ndef truncated (n : ℕ) := simplex_category.truncated n ⥤ C\n\nvariable {C}\n\nnamespace truncated\n\ninstance {n} {J : Type v} [small_category J] [has_limits_of_shape J C] :\n  has_limits_of_shape J (cosimplicial_object.truncated C n) :=\nby {dsimp [truncated], apply_instance}\n\ninstance {n} [has_limits C] : has_limits (cosimplicial_object.truncated C n) := ⟨infer_instance⟩\n\ninstance {n} {J : Type v} [small_category J] [has_colimits_of_shape J C] :\n  has_colimits_of_shape J (cosimplicial_object.truncated C n) :=\nby {dsimp [truncated], apply_instance}\n\ninstance {n} [has_colimits C] : has_colimits (cosimplicial_object.truncated C n) := ⟨infer_instance⟩\n\nvariable (C)\n\n/-- Functor composition induces a functor on truncated cosimplicial objects. -/\n@[simps]\ndef whiskering {n} (D : Type*) [category D] :\n  (C ⥤ D) ⥤ truncated C n ⥤ truncated D n :=\nwhiskering_right _ _ _\n\nvariable {C}\n\nend truncated\n\nsection skeleton\n\n/-- The skeleton functor from cosimplicial objects to truncated cosimplicial objects. -/\ndef sk (n : ℕ) : cosimplicial_object C ⥤ cosimplicial_object.truncated C n :=\n(whiskering_left _ _ _).obj simplex_category.truncated.inclusion\n\nend skeleton\n\nvariable (C)\n\n/-- The constant cosimplicial object. -/\nabbreviation const : C ⥤ cosimplicial_object C := category_theory.functor.const _\n\n/-- Augmented cosimplicial objects. -/\n@[derive category, nolint has_nonempty_instance]\ndef augmented := comma (const C) (𝟭 (cosimplicial_object C))\n\nvariable {C}\n\nnamespace augmented\n\n/-- Drop the augmentation. -/\n@[simps]\ndef drop : augmented C ⥤ cosimplicial_object C := comma.snd _ _\n\n/-- The point of the augmentation. -/\n@[simps]\ndef point : augmented C ⥤ C := comma.fst _ _\n\n/-- The functor from augmented objects to arrows. -/\n@[simps]\ndef to_arrow : augmented C ⥤ arrow C :=\n{ obj := λ X,\n  { left := (point.obj X),\n    right := (drop.obj X) _[0],\n    hom := X.hom.app _ },\n  map := λ X Y η,\n  { left := (point.map η),\n    right := (drop.map η).app _,\n    w' := begin\n      dsimp,\n      rw ← nat_trans.comp_app,\n      erw ← η.w,\n      refl,\n    end } }\n\nvariable (C)\n\n/-- Functor composition induces a functor on augmented cosimplicial objects. -/\n@[simp]\ndef whiskering_obj (D : Type*) [category D] (F : C ⥤ D) :\n  augmented C ⥤ augmented D :=\n{ obj := λ X,\n  { left := F.obj (point.obj X),\n    right := ((whiskering _ _).obj F).obj (drop.obj X),\n    hom := (functor.const_comp _ _ _).inv ≫ whisker_right X.hom F },\n  map := λ X Y η,\n  { left := F.map η.left,\n    right := whisker_right η.right _,\n    w' := begin\n      ext,\n      dsimp,\n      rw [category.id_comp, category.id_comp, ← F.map_comp, ← F.map_comp, ← nat_trans.comp_app],\n      erw ← η.w,\n      refl,\n    end } }\n\n/-- Functor composition induces a functor on augmented cosimplicial objects. -/\n@[simps]\ndef whiskering (D : Type u') [category.{v'} D] :\n  (C ⥤ D) ⥤ augmented C ⥤ augmented D :=\n{ obj := whiskering_obj _ _,\n  map := λ X Y η,\n  { app := λ A,\n    { left := η.app _,\n      right := whisker_left _ η,\n      w' := begin\n        ext n,\n        dsimp,\n        rw [category.id_comp, category.id_comp, η.naturality],\n      end }, }, }\n\nvariable {C}\n\nend augmented\n\nopen_locale simplicial\n\n/-- Augment a cosimplicial object with an object. -/\n@[simps]\ndef augment (X : cosimplicial_object C) (X₀ : C) (f : X₀ ⟶ X.obj [0])\n  (w : ∀ (i : simplex_category) (g₁ g₂ : [0] ⟶ i),\n    f ≫ X.map g₁ = f ≫ X.map g₂) : cosimplicial_object.augmented C :=\n{ left := X₀,\n  right := X,\n  hom :=\n  { app := λ i, f ≫ X.map (simplex_category.const i 0),\n  naturality' := begin\n    intros i j g,\n    dsimp,\n    simpa [← X.map_comp] using w _ _ _,\n  end } }\n\n@[simp]\nlemma augment_hom_zero (X : cosimplicial_object C) (X₀ : C) (f : X₀ ⟶ X.obj [0]) (w) :\n  (X.augment X₀ f w).hom.app [0] = f :=\nby { dsimp, rw [simplex_category.hom_zero_zero ([0].const 0), X.map_id, category.comp_id] }\n\nend cosimplicial_object\n\n/-- The anti-equivalence between simplicial objects and cosimplicial objects. -/\n@[simps]\ndef simplicial_cosimplicial_equiv : (simplicial_object C)ᵒᵖ ≌ (cosimplicial_object Cᵒᵖ) :=\nfunctor.left_op_right_op_equiv _ _\n\n/-- The anti-equivalence between cosimplicial objects and simplicial objects. -/\n@[simps]\ndef cosimplicial_simplicial_equiv : (cosimplicial_object C)ᵒᵖ ≌ (simplicial_object Cᵒᵖ) :=\nfunctor.op_unop_equiv _ _\n\nvariable {C}\n\n/-- Construct an augmented cosimplicial object in the opposite\ncategory from an augmented simplicial object. -/\n@[simps]\ndef simplicial_object.augmented.right_op (X : simplicial_object.augmented C) :\n  cosimplicial_object.augmented Cᵒᵖ :=\n{ left := opposite.op X.right,\n  right := X.left.right_op,\n  hom := X.hom.right_op }\n\n/-- Construct an augmented simplicial object from an augmented cosimplicial\nobject in the opposite category. -/\n@[simps]\ndef cosimplicial_object.augmented.left_op (X : cosimplicial_object.augmented Cᵒᵖ) :\n  simplicial_object.augmented C :=\n{ left := X.right.left_op,\n  right := X.left.unop,\n  hom := X.hom.left_op }\n\n/-- Converting an augmented simplicial object to an augmented cosimplicial\nobject and back is isomorphic to the given object. -/\n@[simps]\ndef simplicial_object.augmented.right_op_left_op_iso (X : simplicial_object.augmented C) :\n  X.right_op.left_op ≅ X :=\ncomma.iso_mk X.left.right_op_left_op_iso (eq_to_iso $ by simp) (by tidy)\n\n/-- Converting an augmented cosimplicial object to an augmented simplicial\nobject and back is isomorphic to the given object. -/\n@[simps]\ndef cosimplicial_object.augmented.left_op_right_op_iso (X : cosimplicial_object.augmented Cᵒᵖ) :\n  X.left_op.right_op ≅ X :=\ncomma.iso_mk (eq_to_iso $ by simp) X.right.left_op_right_op_iso (by tidy)\n\nvariable (C)\n\n/-- A functorial version of `simplicial_object.augmented.right_op`. -/\n@[simps]\ndef simplicial_to_cosimplicial_augmented :\n  (simplicial_object.augmented C)ᵒᵖ ⥤ cosimplicial_object.augmented Cᵒᵖ :=\n{ obj := λ X, X.unop.right_op,\n  map := λ X Y f,\n  { left := f.unop.right.op,\n    right := f.unop.left.right_op,\n    w' := begin\n      ext x,\n      dsimp,\n      simp_rw ← op_comp,\n      congr' 1,\n      exact (congr_app f.unop.w (op x)).symm,\n    end } }\n\n/-- A functorial version of `cosimplicial_object.augmented.left_op`. -/\n@[simps]\ndef cosimplicial_to_simplicial_augmented :\n  cosimplicial_object.augmented Cᵒᵖ ⥤ (simplicial_object.augmented C)ᵒᵖ :=\n{ obj := λ X, opposite.op X.left_op,\n  map := λ X Y f, quiver.hom.op $\n  { left := f.right.left_op,\n    right := f.left.unop,\n    w' := begin\n      ext x,\n      dsimp,\n      simp_rw ← unop_comp,\n      congr' 1,\n      exact (congr_app f.w x.unop).symm,\n    end} }\n\n/-- The contravariant categorical equivalence between augmented simplicial\nobjects and augmented cosimplicial objects in the opposite category. -/\n@[simps functor inverse]\ndef simplicial_cosimplicial_augmented_equiv :\n  (simplicial_object.augmented C)ᵒᵖ ≌ cosimplicial_object.augmented Cᵒᵖ :=\nequivalence.mk\n  (simplicial_to_cosimplicial_augmented _)\n  (cosimplicial_to_simplicial_augmented _)\n  (nat_iso.of_components (λ X, X.unop.right_op_left_op_iso.op) $ λ X Y f,\n    by { dsimp, rw ←f.op_unop, simp_rw ← op_comp, congr' 1, tidy })\n  (nat_iso.of_components (λ X, X.left_op_right_op_iso) $ by tidy)\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_topology/simplicial_object.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.48669680418250866}}
{"text": "/-\nCopyright (c) 2022 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n\n! This file was ported from Lean 3 source module topology.instances.sign\n! leanprover-community/mathlib commit 50832daea47b195a48b5b33b1c8b2162c48c3afc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Sign\nimport Mathbin.Topology.Order.Basic\n\n/-!\n# Topology on `sign_type`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file gives `sign_type` the discrete topology, and proves continuity results for `sign` in\nan `order_topology`.\n\n-/\n\n\ninstance : TopologicalSpace SignType :=\n  ⊥\n\ninstance : DiscreteTopology SignType :=\n  ⟨rfl⟩\n\nvariable {α : Type _} [Zero α] [TopologicalSpace α]\n\nsection PartialOrder\n\nvariable [PartialOrder α] [DecidableRel ((· < ·) : α → α → Prop)] [OrderTopology α]\n\n/- warning: continuous_at_sign_of_pos -> continuousAt_sign_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : PartialOrder.{u1} α] [_inst_4 : DecidableRel.{succ u1} α (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)))] [_inst_5 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α _inst_3)] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α _inst_1))) a) -> (ContinuousAt.{u1, 0} α SignType _inst_2 SignType.topologicalSpace (coeFn.{succ u1, succ u1} (OrderHom.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) (fun (_x : OrderHom.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) => α -> SignType) (OrderHom.hasCoeToFun.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) (SignType.sign.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α _inst_3) (fun (a : α) (b : α) => _inst_4 a b))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : PartialOrder.{u1} α] [_inst_4 : DecidableRel.{succ u1} α (fun (x._@.Mathlib.Topology.Instances.Sign._hyg.105 : α) (x._@.Mathlib.Topology.Instances.Sign._hyg.107 : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)) x._@.Mathlib.Topology.Instances.Sign._hyg.105 x._@.Mathlib.Topology.Instances.Sign._hyg.107)] [_inst_5 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α _inst_3)] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α _inst_1)) a) -> (ContinuousAt.{u1, 0} α SignType _inst_2 instTopologicalSpaceSignType (OrderHom.toFun.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (DistribLattice.toLattice.{0} SignType (instDistribLattice.{0} SignType SignType.instLinearOrderSignType))))) (SignType.sign.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α _inst_3) (fun (a : α) (b : α) => _inst_4 a b))) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at_sign_of_pos continuousAt_sign_of_posₓ'. -/\ntheorem continuousAt_sign_of_pos {a : α} (h : 0 < a) : ContinuousAt SignType.sign a :=\n  by\n  refine' (continuousAt_const : ContinuousAt (fun x => (1 : SignType)) a).congr _\n  rw [Filter.EventuallyEq, eventually_nhds_iff]\n  exact ⟨{ x | 0 < x }, fun x hx => (sign_pos hx).symm, isOpen_lt' 0, h⟩\n#align continuous_at_sign_of_pos continuousAt_sign_of_pos\n\n/- warning: continuous_at_sign_of_neg -> continuousAt_sign_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : PartialOrder.{u1} α] [_inst_4 : DecidableRel.{succ u1} α (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)))] [_inst_5 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α _inst_3)] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α _inst_1)))) -> (ContinuousAt.{u1, 0} α SignType _inst_2 SignType.topologicalSpace (coeFn.{succ u1, succ u1} (OrderHom.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) (fun (_x : OrderHom.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) => α -> SignType) (OrderHom.hasCoeToFun.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) (SignType.sign.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α _inst_3) (fun (a : α) (b : α) => _inst_4 a b))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : TopologicalSpace.{u1} α] [_inst_3 : PartialOrder.{u1} α] [_inst_4 : DecidableRel.{succ u1} α (fun (x._@.Mathlib.Topology.Instances.Sign._hyg.235 : α) (x._@.Mathlib.Topology.Instances.Sign._hyg.237 : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)) x._@.Mathlib.Topology.Instances.Sign._hyg.235 x._@.Mathlib.Topology.Instances.Sign._hyg.237)] [_inst_5 : OrderTopology.{u1} α _inst_2 (PartialOrder.toPreorder.{u1} α _inst_3)] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α _inst_3)) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α _inst_1))) -> (ContinuousAt.{u1, 0} α SignType _inst_2 instTopologicalSpaceSignType (OrderHom.toFun.{u1, 0} α SignType (PartialOrder.toPreorder.{u1} α _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (DistribLattice.toLattice.{0} SignType (instDistribLattice.{0} SignType SignType.instLinearOrderSignType))))) (SignType.sign.{u1} α _inst_1 (PartialOrder.toPreorder.{u1} α _inst_3) (fun (a : α) (b : α) => _inst_4 a b))) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at_sign_of_neg continuousAt_sign_of_negₓ'. -/\ntheorem continuousAt_sign_of_neg {a : α} (h : a < 0) : ContinuousAt SignType.sign a :=\n  by\n  refine' (continuousAt_const : ContinuousAt (fun x => (-1 : SignType)) a).congr _\n  rw [Filter.EventuallyEq, eventually_nhds_iff]\n  exact ⟨{ x | x < 0 }, fun x hx => (sign_neg hx).symm, isOpen_gt' 0, h⟩\n#align continuous_at_sign_of_neg continuousAt_sign_of_neg\n\nend PartialOrder\n\nsection LinearOrder\n\nvariable [LinearOrder α] [OrderTopology α]\n\n#print continuousAt_sign_of_ne_zero /-\ntheorem continuousAt_sign_of_ne_zero {a : α} (h : a ≠ 0) : ContinuousAt SignType.sign a :=\n  by\n  rcases h.lt_or_lt with (h_neg | h_pos)\n  · exact continuousAt_sign_of_neg h_neg\n  · exact continuousAt_sign_of_pos h_pos\n#align continuous_at_sign_of_ne_zero continuousAt_sign_of_ne_zero\n-/\n\nend LinearOrder\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Instances/Sign.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.4866519488333612}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Markus Himmel, Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.wide_pullbacks\nimport Mathlib.category_theory.limits.shapes.binary_products\nimport Mathlib.PostPort\n\nuniverses v u_1 u u₂ \n\nnamespace Mathlib\n\n/-!\n# Pullbacks\n\nWe define a category `walking_cospan` (resp. `walking_span`), which is the index category\nfor the given data for a pullback (resp. pushout) diagram. Convenience methods `cospan f g`\nand `span f g` construct functors from the walking (co)span, hitting the given morphisms.\n\nWe define `pullback f g` and `pushout f g` as limits and colimits of such functors.\n\n## References\n* [Stacks: Fibre products](https://stacks.math.columbia.edu/tag/001U)\n* [Stacks: Pushouts](https://stacks.math.columbia.edu/tag/0025)\n-/\n\nnamespace category_theory.limits\n\n\n/--\nThe type of objects for the diagram indexing a pullback, defined as a special case of\n`wide_pullback_shape`.\n-/\ndef walking_cospan :=\n  wide_pullback_shape walking_pair\n\n/-- The left point of the walking cospan. -/\n/-- The right point of the walking cospan. -/\ndef walking_cospan.left : walking_cospan :=\n  some walking_pair.left\n\n/-- The central point of the walking cospan. -/\ndef walking_cospan.right : walking_cospan :=\n  some walking_pair.right\n\ndef walking_cospan.one : walking_cospan :=\n  none\n\n/--\nThe type of objects for the diagram indexing a pushout, defined as a special case of\n`wide_pushout_shape`.\n-/\ndef walking_span :=\n  wide_pushout_shape walking_pair\n\n/-- The left point of the walking span. -/\n/-- The right point of the walking span. -/\ndef walking_span.left : walking_span :=\n  some walking_pair.left\n\n/-- The central point of the walking span. -/\ndef walking_span.right : walking_span :=\n  some walking_pair.right\n\ndef walking_span.zero : walking_span :=\n  none\n\nnamespace walking_cospan\n\n\n/-- The type of arrows for the diagram indexing a pullback. -/\ndef hom : walking_cospan → walking_cospan → Type v :=\n  wide_pullback_shape.hom\n\n/-- The left arrow of the walking cospan. -/\n/-- The right arrow of the walking cospan. -/\ndef hom.inl : left ⟶ one :=\n  wide_pullback_shape.hom.term walking_pair.left\n\n/-- The identity arrows of the walking cospan. -/\ndef hom.inr : right ⟶ one :=\n  wide_pullback_shape.hom.term walking_pair.right\n\ndef hom.id (X : walking_cospan) : X ⟶ X :=\n  wide_pullback_shape.hom.id X\n\nprotected instance category_theory.has_hom.hom.subsingleton (X : walking_cospan) (Y : walking_cospan) : subsingleton (X ⟶ Y) :=\n  subsingleton.intro fun (a b : X ⟶ Y) => eq.mpr (id (propext (eq_iff_true_of_subsingleton a b))) trivial\n\nend walking_cospan\n\n\nnamespace walking_span\n\n\n/-- The type of arrows for the diagram indexing a pushout. -/\ndef hom : walking_span → walking_span → Type v :=\n  wide_pushout_shape.hom\n\n/-- The left arrow of the walking span. -/\n/-- The right arrow of the walking span. -/\ndef hom.fst : zero ⟶ left :=\n  wide_pushout_shape.hom.init walking_pair.left\n\n/-- The identity arrows of the walking span. -/\ndef hom.snd : zero ⟶ right :=\n  wide_pushout_shape.hom.init walking_pair.right\n\ndef hom.id (X : walking_span) : X ⟶ X :=\n  wide_pushout_shape.hom.id X\n\nprotected instance category_theory.has_hom.hom.subsingleton (X : walking_span) (Y : walking_span) : subsingleton (X ⟶ Y) :=\n  subsingleton.intro fun (a b : X ⟶ Y) => eq.mpr (id (propext (eq_iff_true_of_subsingleton a b))) trivial\n\nend walking_span\n\n\n/-- `cospan f g` is the functor from the walking cospan hitting `f` and `g`. -/\ndef cospan {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : walking_cospan ⥤ C :=\n  wide_pullback_shape.wide_cospan Z (fun (j : walking_pair) => walking_pair.cases_on j X Y)\n    fun (j : walking_pair) => walking_pair.cases_on j f g\n\n/-- `span f g` is the functor from the walking span hitting `f` and `g`. -/\ndef span {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : walking_span ⥤ C :=\n  wide_pushout_shape.wide_span X (fun (j : walking_pair) => walking_pair.cases_on j Y Z)\n    fun (j : walking_pair) => walking_pair.cases_on j f g\n\n@[simp] theorem cospan_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : functor.obj (cospan f g) walking_cospan.left = X :=\n  rfl\n\n@[simp] theorem span_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : functor.obj (span f g) walking_span.left = Y :=\n  rfl\n\n@[simp] theorem cospan_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : functor.obj (cospan f g) walking_cospan.right = Y :=\n  rfl\n\n@[simp] theorem span_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : functor.obj (span f g) walking_span.right = Z :=\n  rfl\n\n@[simp] theorem cospan_one {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : functor.obj (cospan f g) walking_cospan.one = Z :=\n  rfl\n\n@[simp] theorem span_zero {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : functor.obj (span f g) walking_span.zero = X :=\n  rfl\n\n@[simp] theorem cospan_map_inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : functor.map (cospan f g) walking_cospan.hom.inl = f :=\n  rfl\n\n@[simp] theorem span_map_fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : functor.map (span f g) walking_span.hom.fst = f :=\n  rfl\n\n@[simp] theorem cospan_map_inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : functor.map (cospan f g) walking_cospan.hom.inr = g :=\n  rfl\n\n@[simp] theorem span_map_snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : functor.map (span f g) walking_span.hom.snd = g :=\n  rfl\n\ntheorem cospan_map_id {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (w : walking_cospan) : functor.map (cospan f g) (walking_cospan.hom.id w) = 𝟙 :=\n  rfl\n\ntheorem span_map_id {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) (w : walking_span) : functor.map (span f g) (walking_span.hom.id w) = 𝟙 :=\n  rfl\n\n/-- Every diagram indexing an pullback is naturally isomorphic (actually, equal) to a `cospan` -/\ndef diagram_iso_cospan {C : Type u} [category C] (F : walking_cospan ⥤ C) : F ≅ cospan (functor.map F walking_cospan.hom.inl) (functor.map F walking_cospan.hom.inr) :=\n  nat_iso.of_components (fun (j : walking_cospan) => eq_to_iso sorry) sorry\n\n/-- Every diagram indexing a pushout is naturally isomorphic (actually, equal) to a `span` -/\ndef diagram_iso_span {C : Type u} [category C] (F : walking_span ⥤ C) : F ≅ span (functor.map F walking_span.hom.fst) (functor.map F walking_span.hom.snd) :=\n  nat_iso.of_components (fun (j : walking_span) => eq_to_iso sorry) sorry\n\n/-- A pullback cone is just a cone on the cospan formed by two morphisms `f : X ⟶ Z` and\n    `g : Y ⟶ Z`.-/\ndef pullback_cone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :=\n  cone (cospan f g)\n\nnamespace pullback_cone\n\n\n/-- The first projection of a pullback cone. -/\ndef fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} (t : pullback_cone f g) : cone.X t ⟶ X :=\n  nat_trans.app (cone.π t) walking_cospan.left\n\n/-- The second projection of a pullback cone. -/\ndef snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} (t : pullback_cone f g) : cone.X t ⟶ Y :=\n  nat_trans.app (cone.π t) walking_cospan.right\n\n/-- This is a slightly more convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content -/\ndef is_limit_aux {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} (t : pullback_cone f g) (lift : (s : cone (cospan f g)) → cone.X s ⟶ cone.X t) (fac_left : ∀ (s : pullback_cone f g), lift s ≫ fst t = fst s) (fac_right : ∀ (s : pullback_cone f g), lift s ≫ snd t = snd s) (uniq : ∀ (s : pullback_cone f g) (m : cone.X s ⟶ cone.X t),\n  (∀ (j : walking_cospan), m ≫ nat_trans.app (cone.π t) j = nat_trans.app (cone.π s) j) → m = lift s) : is_limit t :=\n  is_limit.mk lift\n\n/-- This is another convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef is_limit_aux' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} (t : pullback_cone f g) (create : (s : pullback_cone f g) →\n  Subtype\n    fun (l : cone.X s ⟶ cone.X t) =>\n      l ≫ fst t = fst s ∧ l ≫ snd t = snd s ∧ ∀ {m : cone.X s ⟶ cone.X t}, m ≫ fst t = fst s → m ≫ snd t = snd s → m = l) : is_limit t :=\n  is_limit_aux t (fun (s : cone (cospan f g)) => subtype.val (create s)) sorry sorry sorry\n\n/-- A pullback cone on `f` and `g` is determined by morphisms `fst : W ⟶ X` and `snd : W ⟶ Y`\n    such that `fst ≫ f = snd ≫ g`. -/\n@[simp] theorem mk_π_app {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) (j : walking_cospan) : nat_trans.app (cone.π (mk fst snd eq)) j =\n  option.cases_on j (fst ≫ f) fun (j' : walking_pair) => walking_pair.cases_on j' fst snd :=\n  Eq.refl (nat_trans.app (cone.π (mk fst snd eq)) j)\n\n@[simp] theorem mk_π_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : nat_trans.app (cone.π (mk fst snd eq)) walking_cospan.left = fst :=\n  rfl\n\n@[simp] theorem mk_π_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : nat_trans.app (cone.π (mk fst snd eq)) walking_cospan.right = snd :=\n  rfl\n\n@[simp] theorem mk_π_app_one {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : nat_trans.app (cone.π (mk fst snd eq)) walking_cospan.one = fst ≫ f :=\n  rfl\n\n@[simp] theorem mk_fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : fst (mk fst snd eq) = fst :=\n  rfl\n\n@[simp] theorem mk_snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : snd (mk fst snd eq) = snd :=\n  rfl\n\ntheorem condition_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} (t : pullback_cone f g) {X' : C} (f' : Z ⟶ X') : fst t ≫ f ≫ f' = snd t ≫ g ≫ f' := sorry\n\n/-- To check whether a morphism is equalized by the maps of a pullback cone, it suffices to check\n  it for `fst t` and `snd t` -/\ntheorem equalizer_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} (t : pullback_cone f g) {W : C} {k : W ⟶ cone.X t} {l : W ⟶ cone.X t} (h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) (j : walking_cospan) : k ≫ nat_trans.app (cone.π t) j = l ≫ nat_trans.app (cone.π t) j := sorry\n\ntheorem is_limit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {t : pullback_cone f g} (ht : is_limit t) {W : C} {k : W ⟶ cone.X t} {l : W ⟶ cone.X t} (h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) : k = l :=\n  is_limit.hom_ext ht (equalizer_ext t h₀ h₁)\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W ⟶ X` and `k : W ⟶ Y` are such that\n    `h ≫ f = k ≫ g`, then we have `l : W ⟶ t.X` satisfying `l ≫ fst t = h` and `l ≫ snd t = k`.\n    -/\ndef is_limit.lift' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {t : pullback_cone f g} (ht : is_limit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : Subtype fun (l : W ⟶ cone.X t) => l ≫ fst t = h ∧ l ≫ snd t = k :=\n  { val := is_limit.lift ht (mk h k w), property := sorry }\n\n/--\nThis is a more convenient formulation to show that a `pullback_cone` constructed using\n`pullback_cone.mk` is a limit cone.\n-/\ndef is_limit.mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g) (lift : (s : pullback_cone f g) → cone.X s ⟶ W) (fac_left : ∀ (s : pullback_cone f g), lift s ≫ fst = fst s) (fac_right : ∀ (s : pullback_cone f g), lift s ≫ snd = snd s) (uniq : ∀ (s : pullback_cone f g) (m : cone.X s ⟶ W), m ≫ fst = fst s → m ≫ snd = snd s → m = lift s) : is_limit (mk fst snd eq) :=\n  is_limit_aux (mk fst snd eq) lift fac_left fac_right sorry\n\n/-- The flip of a pullback square is a pullback square. -/\ndef flip_is_limit {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C} {h : W ⟶ X} {k : W ⟶ Y} {comm : h ≫ f = k ≫ g} (t : is_limit (mk k h flip_is_limit._proof_1)) : is_limit (mk h k comm) :=\n  is_limit_aux' (mk h k comm)\n    fun (s : pullback_cone f g) => { val := subtype.val (is_limit.lift' t (snd s) (fst s) sorry), property := sorry }\n\n/--\nThe pullback cone `(𝟙 X, 𝟙 X)` for the pair `(f, f)` is a limit if `f` is a mono. The converse is\nshown in `mono_of_pullback_is_id`.\n-/\ndef is_limit_mk_id_id {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [mono f] : is_limit (mk 𝟙 𝟙 (is_limit_mk_id_id._proof_1 f)) :=\n  is_limit.mk sorry (fun (s : pullback_cone f f) => fst s) sorry sorry sorry\n\n/--\n`f` is a mono if the pullback cone `(𝟙 X, 𝟙 X)` is a limit for the pair `(f, f)`. The converse is\ngiven in `pullback_cone.is_id_of_mono`.\n-/\ntheorem mono_of_is_limit_mk_id_id {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) (t : is_limit (mk 𝟙 𝟙 rfl)) : mono f := sorry\n\nend pullback_cone\n\n\n/-- A pushout cocone is just a cocone on the span formed by two morphisms `f : X ⟶ Y` and\n    `g : X ⟶ Z`.-/\ndef pushout_cocone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :=\n  cocone (span f g)\n\nnamespace pushout_cocone\n\n\n/-- The first inclusion of a pushout cocone. -/\ndef inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (t : pushout_cocone f g) : Y ⟶ cocone.X t :=\n  nat_trans.app (cocone.ι t) walking_span.left\n\n/-- The second inclusion of a pushout cocone. -/\ndef inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (t : pushout_cocone f g) : Z ⟶ cocone.X t :=\n  nat_trans.app (cocone.ι t) walking_span.right\n\n/-- This is a slightly more convenient method to verify that a pushout cocone is a colimit cocone.\n    It only asks for a proof of facts that carry any mathematical content -/\ndef is_colimit_aux {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (t : pushout_cocone f g) (desc : (s : pushout_cocone f g) → cocone.X t ⟶ cocone.X s) (fac_left : ∀ (s : pushout_cocone f g), inl t ≫ desc s = inl s) (fac_right : ∀ (s : pushout_cocone f g), inr t ≫ desc s = inr s) (uniq : ∀ (s : pushout_cocone f g) (m : cocone.X t ⟶ cocone.X s),\n  (∀ (j : walking_span), nat_trans.app (cocone.ι t) j ≫ m = nat_trans.app (cocone.ι s) j) → m = desc s) : is_colimit t :=\n  is_colimit.mk desc\n\n/-- This is another convenient method to verify that a pushout cocone is a colimit cocone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef is_colimit_aux' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (t : pushout_cocone f g) (create : (s : pushout_cocone f g) →\n  Subtype\n    fun (l : cocone.X t ⟶ cocone.X s) =>\n      inl t ≫ l = inl s ∧\n        inr t ≫ l = inr s ∧ ∀ {m : cocone.X t ⟶ cocone.X s}, inl t ≫ m = inl s → inr t ≫ m = inr s → m = l) : is_colimit t :=\n  is_colimit_aux t (fun (s : pushout_cocone f g) => subtype.val (create s)) sorry sorry sorry\n\n/-- A pushout cocone on `f` and `g` is determined by morphisms `inl : Y ⟶ W` and `inr : Z ⟶ W` such\n    that `f ≫ inl = g ↠ inr`. -/\ndef mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : pushout_cocone f g :=\n  cocone.mk W\n    (nat_trans.mk\n      fun (j : walking_span) => option.cases_on j (f ≫ inl) fun (j' : walking_pair) => walking_pair.cases_on j' inl inr)\n\n@[simp] theorem mk_ι_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : nat_trans.app (cocone.ι (mk inl inr eq)) walking_span.left = inl :=\n  rfl\n\n@[simp] theorem mk_ι_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : nat_trans.app (cocone.ι (mk inl inr eq)) walking_span.right = inr :=\n  rfl\n\n@[simp] theorem mk_ι_app_zero {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : nat_trans.app (cocone.ι (mk inl inr eq)) walking_span.zero = f ≫ inl :=\n  rfl\n\n@[simp] theorem mk_inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : inl (mk inl inr eq) = inl :=\n  rfl\n\n@[simp] theorem mk_inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : inr (mk inl inr eq) = inr :=\n  rfl\n\ntheorem condition_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (t : pushout_cocone f g) {X' : C} (f' : cocone.X t ⟶ X') : f ≫ inl t ≫ f' = g ≫ inr t ≫ f' := sorry\n\n/-- To check whether a morphism is coequalized by the maps of a pushout cocone, it suffices to check\n  it for `inl t` and `inr t` -/\ntheorem coequalizer_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} (t : pushout_cocone f g) {W : C} {k : cocone.X t ⟶ W} {l : cocone.X t ⟶ W} (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) (j : walking_span) : nat_trans.app (cocone.ι t) j ≫ k = nat_trans.app (cocone.ι t) j ≫ l := sorry\n\ntheorem is_colimit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {t : pushout_cocone f g} (ht : is_colimit t) {W : C} {k : cocone.X t ⟶ W} {l : cocone.X t ⟶ W} (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) : k = l :=\n  is_colimit.hom_ext ht (coequalizer_ext t h₀ h₁)\n\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y ⟶ W` and `k : Z ⟶ W` are\n    morphisms satisfying `f ≫ h = g ≫ k`, then we have a factorization `l : t.X ⟶ W` such that\n    `inl t ≫ l = h` and `inr t ≫ l = k`. -/\ndef is_colimit.desc' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {t : pushout_cocone f g} (ht : is_colimit t) {W : C} (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : Subtype fun (l : cocone.X t ⟶ W) => inl t ≫ l = h ∧ inr t ≫ l = k :=\n  { val := is_colimit.desc ht (mk h k w), property := sorry }\n\n/--\nThis is a more convenient formulation to show that a `pushout_cocone` constructed using\n`pushout_cocone.mk` is a colimit cocone.\n-/\ndef is_colimit.mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} {inl : Y ⟶ W} {inr : Z ⟶ W} (eq : f ≫ inl = g ≫ inr) (desc : (s : pushout_cocone f g) → W ⟶ cocone.X s) (fac_left : ∀ (s : pushout_cocone f g), inl ≫ desc s = inl s) (fac_right : ∀ (s : pushout_cocone f g), inr ≫ desc s = inr s) (uniq : ∀ (s : pushout_cocone f g) (m : W ⟶ cocone.X s), inl ≫ m = inl s → inr ≫ m = inr s → m = desc s) : is_colimit (mk inl inr eq) :=\n  is_colimit_aux (mk inl inr eq) desc fac_left fac_right sorry\n\n/-- The flip of a pushout square is a pushout square. -/\ndef flip_is_colimit {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C} {h : Y ⟶ W} {k : Z ⟶ W} {comm : f ≫ h = g ≫ k} (t : is_colimit (mk k h flip_is_colimit._proof_1)) : is_colimit (mk h k comm) :=\n  is_colimit_aux' (mk h k comm)\n    fun (s : pushout_cocone f g) => { val := subtype.val (is_colimit.desc' t (inr s) (inl s) sorry), property := sorry }\n\nend pushout_cocone\n\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pullbacks. Given `F : walking_cospan ⥤ C`, which is really the same as\n    `cospan (F.map inl) (F.map inr)`, and a pullback cone on `F.map inl` and `F.map inr`, we\n    get a cone on `F`.\n\n    If you're thinking about using this, have a look at `has_pullbacks_of_has_limit_cospan`,\n    which you may find to be an easier way of achieving your goal. -/\n@[simp] theorem cone.of_pullback_cone_π {C : Type u} [category C] {F : walking_cospan ⥤ C} (t : pullback_cone (functor.map F walking_cospan.hom.inl) (functor.map F walking_cospan.hom.inr)) : cone.π (cone.of_pullback_cone t) = cone.π t ≫ iso.inv (diagram_iso_cospan F) :=\n  Eq.refl (cone.π (cone.of_pullback_cone t))\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pushout. Given `F : walking_span ⥤ C`, which is really the same as\n    `span (F.map fst) (F.mal snd)`, and a pushout cocone on `F.map fst` and `F.map snd`,\n    we get a cocone on `F`.\n\n    If you're thinking about using this, have a look at `has_pushouts_of_has_colimit_span`, which\n    you may find to be an easiery way of achieving your goal.  -/\n@[simp] theorem cocone.of_pushout_cocone_X {C : Type u} [category C] {F : walking_span ⥤ C} (t : pushout_cocone (functor.map F walking_span.hom.fst) (functor.map F walking_span.hom.snd)) : cocone.X (cocone.of_pushout_cocone t) = cocone.X t :=\n  Eq.refl (cocone.X (cocone.of_pushout_cocone t))\n\n/-- Given `F : walking_cospan ⥤ C`, which is really the same as `cospan (F.map inl) (F.map inr)`,\n    and a cone on `F`, we get a pullback cone on `F.map inl` and `F.map inr`. -/\n@[simp] theorem pullback_cone.of_cone_X {C : Type u} [category C] {F : walking_cospan ⥤ C} (t : cone F) : cone.X (pullback_cone.of_cone t) = cone.X t :=\n  Eq.refl (cone.X (pullback_cone.of_cone t))\n\n/-- Given `F : walking_span ⥤ C`, which is really the same as `span (F.map fst) (F.map snd)`,\n    and a cocone on `F`, we get a pushout cocone on `F.map fst` and `F.map snd`. -/\ndef pushout_cocone.of_cocone {C : Type u} [category C] {F : walking_span ⥤ C} (t : cocone F) : pushout_cocone (functor.map F walking_span.hom.fst) (functor.map F walking_span.hom.snd) :=\n  cocone.mk (cocone.X t) (iso.inv (diagram_iso_span F) ≫ cocone.ι t)\n\n/--\n`has_pullback f g` represents a particular choice of limiting cone\nfor the pair of morphisms `f : X ⟶ Z` and `g : Y ⟶ Z`.\n-/\n/--\ndef has_pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :=\n  has_limit (cospan f g)\n\n`has_pushout f g` represents a particular choice of colimiting cocone\nfor the pair of morphisms `f : X ⟶ Y` and `g : X ⟶ Z`.\n-/\ndef has_pushout {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :=\n  has_colimit (span f g)\n\n/-- `pullback f g` computes the pullback of a pair of morphisms with the same target. -/\ndef pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] : C :=\n  limit (cospan f g)\n\n/-- `pushout f g` computes the pushout of a pair of morphisms with the same source. -/\ndef pushout {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) [has_pushout f g] : C :=\n  colimit (span f g)\n\n/-- The first projection of the pullback of `f` and `g`. -/\ndef pullback.fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] : pullback f g ⟶ X :=\n  limit.π (cospan f g) walking_cospan.left\n\n/-- The second projection of the pullback of `f` and `g`. -/\ndef pullback.snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] : pullback f g ⟶ Y :=\n  limit.π (cospan f g) walking_cospan.right\n\n/-- The first inclusion into the pushout of `f` and `g`. -/\ndef pushout.inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] : Y ⟶ pushout f g :=\n  colimit.ι (span f g) walking_span.left\n\n/-- The second inclusion into the pushout of `f` and `g`. -/\ndef pushout.inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] : Z ⟶ pushout f g :=\n  colimit.ι (span f g) walking_span.right\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `pullback.lift : W ⟶ pullback f g`. -/\ndef pullback.lift {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : W ⟶ pullback f g :=\n  limit.lift (cospan f g) (pullback_cone.mk h k w)\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `pushout.desc : pushout f g ⟶ W`. -/\ndef pushout.desc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout f g ⟶ W :=\n  colimit.desc (span f g) (pushout_cocone.mk h k w)\n\n@[simp] theorem pullback.lift_fst_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) {X' : C} (f' : X ⟶ X') : pullback.lift h k w ≫ pullback.fst ≫ f' = h ≫ f' := sorry\n\n@[simp] theorem pullback.lift_snd_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) {X' : C} (f' : Y ⟶ X') : pullback.lift h k w ≫ pullback.snd ≫ f' = k ≫ f' := sorry\n\n@[simp] theorem pushout.inl_desc_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) {X' : C} (f' : W ⟶ X') : pushout.inl ≫ pushout.desc h k w ≫ f' = h ≫ f' := sorry\n\n@[simp] theorem pushout.inr_desc_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) {X' : C} (f' : W ⟶ X') : pushout.inr ≫ pushout.desc h k w ≫ f' = k ≫ f' := sorry\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `l : W ⟶ pullback f g` such that `l ≫ pullback.fst = h` and `l ≫ pullback.snd = k`. -/\ndef pullback.lift' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : Subtype fun (l : W ⟶ pullback f g) => l ≫ pullback.fst = h ∧ l ≫ pullback.snd = k :=\n  { val := pullback.lift h k w, property := sorry }\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `l : pushout f g ⟶ W` such that `pushout.inl ≫ l = h` and `pushout.inr ≫ l = k`. -/\ndef pullback.desc' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : Subtype fun (l : pushout f g ⟶ W) => pushout.inl ≫ l = h ∧ pushout.inr ≫ l = k :=\n  { val := pushout.desc h k w, property := sorry }\n\ntheorem pullback.condition {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] : pullback.fst ≫ f = pullback.snd ≫ g :=\n  pullback_cone.condition (limit.cone (cospan f g))\n\ntheorem pushout.condition_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] {X' : C} (f' : pushout f g ⟶ X') : f ≫ pushout.inl ≫ f' = g ≫ pushout.inr ≫ f' := sorry\n\n/-- Two morphisms into a pullback are equal if their compositions with the pullback morphisms are\n    equal -/\ntheorem pullback.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] {W : C} {k : W ⟶ pullback f g} {l : W ⟶ pullback f g} (h₀ : k ≫ pullback.fst = l ≫ pullback.fst) (h₁ : k ≫ pullback.snd = l ≫ pullback.snd) : k = l :=\n  limit.hom_ext (pullback_cone.equalizer_ext (limit.cone (cospan f g)) h₀ h₁)\n\n/-- The pullback cone built from the pullback projections is a pullback. -/\ndef pullback_is_pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] : is_limit (pullback_cone.mk pullback.fst pullback.snd pullback.condition) :=\n  pullback_cone.is_limit.mk pullback.condition\n    (fun (s : pullback_cone f g) => pullback.lift (pullback_cone.fst s) (pullback_cone.snd s) (pullback_cone.condition s))\n    sorry sorry sorry\n\n/-- The pullback of a monomorphism is a monomorphism -/\nprotected instance pullback.fst_of_mono {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] [mono g] : mono pullback.fst := sorry\n\n/-- The pullback of a monomorphism is a monomorphism -/\nprotected instance pullback.snd_of_mono {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] [mono f] : mono pullback.snd := sorry\n\n/-- Two morphisms out of a pushout are equal if their compositions with the pushout morphisms are\n    equal -/\ntheorem pushout.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] {W : C} {k : pushout f g ⟶ W} {l : pushout f g ⟶ W} (h₀ : pushout.inl ≫ k = pushout.inl ≫ l) (h₁ : pushout.inr ≫ k = pushout.inr ≫ l) : k = l :=\n  colimit.hom_ext (pushout_cocone.coequalizer_ext (colimit.cocone (span f g)) h₀ h₁)\n\n/-- The pushout of an epimorphism is an epimorphism -/\nprotected instance pushout.inl_of_epi {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] [epi g] : epi pushout.inl :=\n  epi.mk\n    fun (W : C) (u v : pushout f g ⟶ W) (h : pushout.inl ≫ u = pushout.inl ≫ v) =>\n      pushout.hom_ext h\n        (iff.mp (cancel_epi g)\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : X ⟶ W) (e_1 : a = a_1) (ᾰ ᾰ_1 : X ⟶ W) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n                  (g ≫ pushout.inr ≫ u) (f ≫ pushout.inl ≫ v)\n                  (Eq.trans (Eq.symm (pushout.condition_assoc u))\n                    ((fun (ᾰ ᾰ_1 : X ⟶ Y) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : Y ⟶ W) (e_2 : ᾰ_2 = ᾰ_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      f f (Eq.refl f) (pushout.inl ≫ u) (pushout.inl ≫ v) h))\n                  (g ≫ pushout.inr ≫ v) (f ≫ pushout.inl ≫ v) (Eq.symm (pushout.condition_assoc v)))\n                (propext (eq_self_iff_true (f ≫ pushout.inl ≫ v)))))\n            trivial))\n\n/-- The pushout of an epimorphism is an epimorphism -/\nprotected instance pushout.inr_of_epi {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] [epi f] : epi pushout.inr :=\n  epi.mk\n    fun (W : C) (u v : pushout f g ⟶ W) (h : pushout.inr ≫ u = pushout.inr ≫ v) =>\n      pushout.hom_ext\n        (iff.mp (cancel_epi f)\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : X ⟶ W) (e_1 : a = a_1) (ᾰ ᾰ_1 : X ⟶ W) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n                  (f ≫ pushout.inl ≫ u) (g ≫ pushout.inr ≫ v)\n                  (Eq.trans (pushout.condition_assoc u)\n                    ((fun (ᾰ ᾰ_1 : X ⟶ Z) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : Z ⟶ W) (e_2 : ᾰ_2 = ᾰ_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      g g (Eq.refl g) (pushout.inr ≫ u) (pushout.inr ≫ v) h))\n                  (f ≫ pushout.inl ≫ v) (g ≫ pushout.inr ≫ v) (pushout.condition_assoc v))\n                (propext (eq_self_iff_true (g ≫ pushout.inr ≫ v)))))\n            trivial))\n        h\n\n/--\nThe comparison morphism for the pullback of `f,g`.\nThis is an isomorphism iff `G` preserves the pullback of `f,g`; see\n`category_theory/limits/preserves/shapes/pullbacks.lean`\n-/\ndef pullback_comparison {C : Type u} [category C] {X : C} {Y : C} {Z : C} {D : Type u₂} [category D] (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] : functor.obj G (pullback f g) ⟶ pullback (functor.map G f) (functor.map G g) :=\n  pullback.lift (functor.map G pullback.fst) (functor.map G pullback.snd) sorry\n\n@[simp] theorem pullback_comparison_comp_fst_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {D : Type u₂} [category D] (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G X ⟶ X') : pullback_comparison G f g ≫ pullback.fst ≫ f' = functor.map G pullback.fst ≫ f' := sorry\n\n@[simp] theorem pullback_comparison_comp_snd_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {D : Type u₂} [category D] (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G Y ⟶ X') : pullback_comparison G f g ≫ pullback.snd ≫ f' = functor.map G pullback.snd ≫ f' := sorry\n\n@[simp] theorem map_lift_pullback_comparison_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {D : Type u₂} [category D] (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] {W : C} {h : W ⟶ X} {k : W ⟶ Y} (w : h ≫ f = k ≫ g) {X' : D} (f' : pullback (functor.map G f) (functor.map G g) ⟶ X') : functor.map G (pullback.lift h k w) ≫ pullback_comparison G f g ≫ f' =\n  pullback.lift (functor.map G h) (functor.map G k)\n      (eq.mpr\n        (id\n          ((fun (a a_1 : functor.obj G W ⟶ functor.obj G Z) (e_1 : a = a_1) (ᾰ ᾰ_1 : functor.obj G W ⟶ functor.obj G Z)\n              (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n            (functor.map G h ≫ functor.map G f) (functor.map G (k ≫ g))\n            (Eq.trans (Eq.symm (functor.map_comp G h f))\n              ((fun (c : C ⥤ D) {X Y : C} (ᾰ ᾰ_1 : X ⟶ Y) (e_4 : ᾰ = ᾰ_1) => congr_arg (functor.map c) e_4) G (h ≫ f)\n                (k ≫ g) w))\n            (functor.map G k ≫ functor.map G g) (functor.map G (k ≫ g)) (Eq.symm (functor.map_comp G k g))))\n        (Eq.refl (functor.map G (k ≫ g)))) ≫\n    f' := sorry\n\n/--\n`has_pullbacks` represents a choice of pullback for every pair of morphisms\n\nSee https://stacks.math.columbia.edu/tag/001W.\n-/\ndef has_pullbacks (C : Type u) [category C] :=\n  has_limits_of_shape walking_cospan C\n\n/-- `has_pushouts` represents a choice of pushout for every pair of morphisms -/\ndef has_pushouts (C : Type u) [category C] :=\n  has_colimits_of_shape walking_span C\n\n/-- If `C` has all limits of diagrams `cospan f g`, then it has all pullbacks -/\ntheorem has_pullbacks_of_has_limit_cospan (C : Type u) [category C] [∀ {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}, has_limit (cospan f g)] : has_pullbacks C :=\n  has_limits_of_shape.mk fun (F : walking_cospan ⥤ C) => has_limit_of_iso (iso.symm (diagram_iso_cospan F))\n\n/-- If `C` has all colimits of diagrams `span f g`, then it has all pushouts -/\ntheorem has_pushouts_of_has_colimit_span (C : Type u) [category C] [∀ {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z}, has_colimit (span f g)] : has_pushouts C :=\n  has_colimits_of_shape.mk fun (F : walking_span ⥤ C) => has_colimit_of_iso (diagram_iso_span F)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/shapes/pullbacks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6992544210587586, "lm_q1q2_score": 0.4866519356522902}}
{"text": "/-\nCopyright (c) 2015 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Robert Y. Lewis\nThe real numbers, constructed as equivalence classes of Cauchy sequences of rationals.\nThis construction follows Bishop and Bridges (1985).\n\nAt this point, we no longer proceed constructively: this file makes heavy use of decidability\nand excluded middle.\n-/\nimport data.real.basic data.real.order data.rat data.nat\nopen rat\nopen nat\nopen eq.ops pnat classical\n\nnamespace rat_seq\nlocal postfix ⁻¹ := pnat.inv\n\n-----------------------------\n-- Facts about absolute values of sequences, to define inverse\n\ndefinition s_abs (s : seq) : seq := λ n, abs (s n)\n\ntheorem abs_reg_of_reg {s : seq} (Hs : regular s) : regular (s_abs s) :=\n  begin\n    intros,\n    apply le.trans,\n    apply abs_abs_sub_abs_le_abs_sub,\n    apply Hs\n  end\n\ntheorem abs_pos_of_nonzero {s : seq} (Hs : regular s) (Hnz : sep s zero) :\n        ∃ N : ℕ+, ∀ m : ℕ+, m ≥ N → abs (s m) ≥ N⁻¹ :=\n  begin\n    rewrite [↑sep at Hnz, ↑s_lt at Hnz],\n    apply or.elim Hnz,\n    intro Hnz1,\n    have H' : pos (sneg s), begin\n      apply pos_of_pos_equiv,\n      rotate 2,\n      apply Hnz1,\n      rotate 1,\n      apply s_zero_add,\n      repeat (assumption | apply reg_add_reg | apply reg_neg_reg | apply zero_is_reg)\n    end,\n    cases bdd_away_of_pos (reg_neg_reg Hs) H' with [N, HN],\n    existsi N,\n    intro m Hm,\n    apply le.trans,\n    apply HN m Hm,\n    rewrite ↑sneg,\n    apply neg_le_abs_self,\n    intro Hnz2,\n    let H' := pos_of_pos_equiv (reg_add_reg Hs (reg_neg_reg zero_is_reg)) (s_add_zero s Hs) Hnz2,\n    let H'' := bdd_away_of_pos Hs H',\n    cases H'' with [N, HN],\n    existsi N,\n    intro m Hm,\n    apply le.trans,\n    apply HN m Hm,\n    apply le_abs_self\n  end\n\ntheorem abs_well_defined {s t : seq} (Hs : regular s) (Ht : regular t) (Heq : s ≡ t) :\n        s_abs s ≡ s_abs t :=\n  begin\n    rewrite [↑equiv at *],\n    intro n,\n    rewrite ↑s_abs,\n    apply le.trans,\n    apply abs_abs_sub_abs_le_abs_sub,\n    apply Heq\n  end\n\ntheorem sep_zero_of_pos {s : seq} (Hs : regular s) (Hpos : pos s) : sep s zero :=\n  begin\n    apply or.inr,\n    apply pos_of_pos_equiv,\n    rotate 2,\n    apply Hpos,\n    apply Hs,\n    apply equiv.symm,\n    apply s_sub_zero Hs\n  end\n\n------------------------\n-- This section could be cleaned up.\n\nprivate noncomputable definition pb {s : seq} (Hs : regular s) (Hpos : pos s) :=\n  some (abs_pos_of_nonzero Hs (sep_zero_of_pos Hs Hpos))\nprivate noncomputable definition ps {s : seq} (Hs : regular s) (Hsep : sep s zero) :=\n  some (abs_pos_of_nonzero Hs Hsep)\n\n\nprivate theorem pb_spec {s : seq} (Hs : regular s) (Hpos : pos s) :\n        ∀ m : ℕ+, m ≥ (pb Hs Hpos) → abs (s m) ≥ (pb Hs Hpos)⁻¹ :=\n  some_spec (abs_pos_of_nonzero Hs (sep_zero_of_pos Hs Hpos))\n\nprivate theorem ps_spec {s : seq} (Hs : regular s) (Hsep : sep s zero) :\n        ∀ m : ℕ+, m ≥ (ps Hs Hsep) → abs (s m) ≥ (ps Hs Hsep)⁻¹ :=\n  some_spec (abs_pos_of_nonzero Hs Hsep)\n\nnoncomputable definition s_inv {s : seq} (Hs : regular s) (n : ℕ+) : ℚ :=\n  if H : sep s zero then\n      (if n < (ps Hs H) then 1 / (s ((ps Hs H) * (ps Hs H) * (ps Hs H)))\n        else 1 / (s ((ps Hs H) * (ps Hs H) * n)))\n  else 0\n\nprivate theorem peq {s : seq} (Hsep : sep s zero) (Hpos : pos s)  (Hs : regular s) :\n        pb Hs Hpos = ps Hs Hsep := rfl\n\nprivate theorem s_inv_of_sep_lt_p {s : seq} (Hs : regular s) (Hsep : sep s zero) {n : ℕ+}\n        (Hn : n < (ps Hs Hsep)) : s_inv Hs n = 1 / s ((ps Hs Hsep) * (ps Hs Hsep) * (ps Hs Hsep)) :=\n  begin\n    apply eq.trans,\n    apply dif_pos Hsep,\n    apply dif_pos Hn\n  end\n\nprivate theorem s_inv_of_sep_gt_p {s : seq} (Hs : regular s) (Hsep : sep s zero) {n : ℕ+}\n        (Hn : n ≥ (ps Hs Hsep)) : s_inv Hs n = 1 / s ((ps Hs Hsep) * (ps Hs Hsep) * n) :=\n  begin\n    apply eq.trans,\n    apply dif_pos Hsep,\n    apply dif_neg (not_lt_of_ge Hn)\n  end\n\nprivate theorem s_inv_of_pos_lt_p {s : seq} (Hs : regular s) (Hpos : pos s) {n : ℕ+}\n        (Hn : n < (pb Hs Hpos)) : s_inv Hs n = 1 / s ((pb Hs Hpos) * (pb Hs Hpos) * (pb Hs Hpos)) :=\n  s_inv_of_sep_lt_p Hs (sep_zero_of_pos Hs Hpos) Hn\n\nprivate theorem s_inv_of_pos_gt_p {s : seq} (Hs : regular s) (Hpos : pos s) {n : ℕ+}\n        (Hn : n ≥ (pb Hs Hpos)) : s_inv Hs n = 1 / s ((pb Hs Hpos) * (pb Hs Hpos) * n) :=\n  s_inv_of_sep_gt_p Hs (sep_zero_of_pos Hs Hpos) Hn\n\nprivate theorem le_ps {s : seq} (Hs : regular s) (Hsep : sep s zero) (n : ℕ+) :\n        abs (s_inv Hs n) ≤ (rat_of_pnat (ps Hs Hsep)) :=\n  if Hn : n < ps Hs Hsep then\n    (begin\n      rewrite [(s_inv_of_sep_lt_p Hs Hsep Hn), abs_one_div],\n      apply div_le_pnat,\n      apply ps_spec,\n      apply pnat.mul_le_mul_left\n    end)\n  else\n    (begin\n      rewrite [(s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hn)), abs_one_div],\n      apply div_le_pnat,\n      apply ps_spec,\n      rewrite pnat.mul_assoc,\n      apply pnat.mul_le_mul_right\n    end)\n\ntheorem s_inv_zero : s_inv zero_is_reg = zero :=\n  funext (λ n, dif_neg (!not_sep_self))\n\nprivate theorem s_inv_of_zero' {s : seq} (Hs : regular s) (Hz : ¬ sep s zero) (n : ℕ+) : s_inv Hs n = 0 :=\n  dif_neg Hz\n\ntheorem s_inv_of_zero {s : seq} (Hs : regular s) (Hz : ¬ sep s zero) : s_inv Hs = zero :=\n  begin\n    apply funext,\n    intro n,\n    apply s_inv_of_zero' Hs Hz n\n  end\n\nprivate theorem s_ne_zero_of_ge_p {s : seq} (Hs : regular s) (Hsep : sep s zero) {n : ℕ+}\n        (Hn : n ≥ (ps Hs Hsep)) : s n ≠ 0 :=\n  begin\n    let Hps := ps_spec Hs Hsep,\n    apply ne_zero_of_abs_ne_zero,\n    apply ne_of_gt,\n    apply gt_of_ge_of_gt,\n    apply Hps,\n    apply Hn,\n    apply pnat.inv_pos\n  end\n\ntheorem reg_inv_reg {s : seq} (Hs : regular s) (Hsep : sep s zero) : regular (s_inv Hs) :=\n  begin\n    rewrite ↑regular,\n    intros,\n    have Hsp : s ((ps Hs Hsep) * (ps Hs Hsep) * (ps Hs Hsep)) ≠ 0, from\n      s_ne_zero_of_ge_p Hs Hsep !pnat.mul_le_mul_left,\n    have Hspn : s ((ps Hs Hsep) * (ps Hs Hsep) * n) ≠ 0, from\n      s_ne_zero_of_ge_p Hs Hsep (show (ps Hs Hsep) * (ps Hs Hsep) * n ≥ ps Hs Hsep, by\n        rewrite pnat.mul_assoc; apply pnat.mul_le_mul_right),\n    have Hspm : s ((ps Hs Hsep) * (ps Hs Hsep) * m) ≠ 0, from\n      s_ne_zero_of_ge_p Hs Hsep (show (ps Hs Hsep) * (ps Hs Hsep) * m ≥ ps Hs Hsep, by\n        rewrite pnat.mul_assoc; apply pnat.mul_le_mul_right),\n    cases em (m < ps Hs Hsep) with [Hmlt, Hmlt],\n      cases em (n < ps Hs Hsep) with [Hnlt, Hnlt],\n        rewrite [(s_inv_of_sep_lt_p Hs Hsep Hmlt), (s_inv_of_sep_lt_p Hs Hsep Hnlt)],\n        rewrite [sub_self, abs_zero],\n        apply add_invs_nonneg,\n       rewrite [(s_inv_of_sep_lt_p Hs Hsep Hmlt),\n                (s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hnlt))],\n       rewrite [(!div_sub_div Hsp Hspn), div_eq_mul_one_div, *abs_mul, *mul_one, *one_mul],\n       apply le.trans,\n       apply mul_le_mul,\n       apply Hs,\n       rewrite [-(mul_one 1), -(!field.div_mul_div Hsp Hspn), abs_mul],\n       apply mul_le_mul,\n       rewrite -(s_inv_of_sep_lt_p Hs Hsep Hmlt),\n       apply le_ps Hs Hsep,\n       rewrite  -(s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hnlt)),\n       apply le_ps Hs Hsep,\n       apply abs_nonneg,\n       apply le_of_lt !rat_of_pnat_is_pos,\n       apply abs_nonneg,\n       apply add_invs_nonneg,\n       rewrite [right_distrib, *pnat_cancel', add.comm],\n       apply add_le_add_right,\n       apply inv_ge_of_le,\n       apply le_of_lt,\n       apply Hmlt,\n      cases em (n < ps Hs Hsep) with [Hnlt, Hnlt],\n        rewrite [(s_inv_of_sep_lt_p Hs Hsep Hnlt),\n                 (s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hmlt))],\n        rewrite [(!div_sub_div Hspm Hsp), div_eq_mul_one_div, *abs_mul, *mul_one, *one_mul],\n        apply le.trans,\n        apply mul_le_mul,\n        apply Hs,\n        rewrite [-(mul_one 1), -(!field.div_mul_div Hspm Hsp), abs_mul],\n        apply mul_le_mul,\n        rewrite -(s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hmlt)),\n        apply le_ps Hs Hsep,\n        rewrite -(s_inv_of_sep_lt_p Hs Hsep Hnlt),\n        apply le_ps Hs Hsep,\n        apply abs_nonneg,\n        apply le_of_lt !rat_of_pnat_is_pos,\n        apply abs_nonneg,\n        apply add_invs_nonneg,\n        rewrite [right_distrib, *pnat_cancel', add.comm],\n        apply rat.add_le_add_left,\n        apply inv_ge_of_le,\n        apply le_of_lt,\n        apply Hnlt,\n      rewrite [(s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hnlt)),\n              (s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hmlt))],\n      rewrite [(!div_sub_div Hspm Hspn), div_eq_mul_one_div, abs_mul, *one_mul, *mul_one],\n      apply le.trans,\n      apply mul_le_mul,\n      apply Hs,\n      rewrite [-(mul_one 1), -(!field.div_mul_div Hspm Hspn), abs_mul],\n      apply mul_le_mul,\n      rewrite -(s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hmlt)),\n      apply le_ps Hs Hsep,\n      rewrite -(s_inv_of_sep_gt_p Hs Hsep (le_of_not_gt Hnlt)),\n      apply le_ps Hs Hsep,\n      apply abs_nonneg,\n      apply le_of_lt !rat_of_pnat_is_pos,\n      apply abs_nonneg,\n      apply add_invs_nonneg,\n      rewrite [right_distrib, *pnat_cancel', add.comm],\n      apply le.refl\n  end\n\ntheorem s_inv_ne_zero {s : seq} (Hs : regular s) (Hsep : sep s zero) (n : ℕ+) : s_inv Hs n ≠ 0 :=\n  if H : n ≥ ps Hs Hsep then\n    (begin\n      rewrite (s_inv_of_sep_gt_p Hs Hsep H),\n      apply one_div_ne_zero,\n      apply s_ne_zero_of_ge_p,\n      apply le.trans,\n      apply H,\n      apply pnat.mul_le_mul_left\n    end)\n  else\n    (begin\n      rewrite (s_inv_of_sep_lt_p Hs Hsep (lt_of_not_ge H)),\n      apply one_div_ne_zero,\n      apply s_ne_zero_of_ge_p,\n      apply pnat.mul_le_mul_left\n    end)\n\nprotected theorem mul_inv {s : seq} (Hs : regular s) (Hsep : sep s zero) :\n          smul s (s_inv Hs) ≡ one :=\n  begin\n    let Rsi := reg_inv_reg Hs Hsep,\n    let Rssi := reg_mul_reg Hs Rsi,\n    apply eq_of_bdd Rssi one_is_reg,\n    intros,\n    existsi max (ps Hs Hsep) j,\n    intro n Hn,\n    have Hnz : s_inv Hs ((K₂ s (s_inv Hs)) * 2 * n) ≠ 0, from s_inv_ne_zero Hs Hsep _,\n    rewrite [↑smul, ↑one, mul.comm, -(mul_one_div_cancel Hnz),\n            -mul_sub_left_distrib, abs_mul],\n    apply le.trans,\n    apply mul_le_mul_of_nonneg_right,\n    apply canon_2_bound_right s,\n    apply Rsi,\n    apply abs_nonneg,\n    have Hp : (K₂ s (s_inv Hs)) * 2 * n ≥ ps Hs Hsep, begin\n      apply le.trans,\n      apply le_max_left,\n      rotate 1,\n      apply le.trans,\n      apply Hn,\n      apply pnat.mul_le_mul_left\n    end,\n    have Hnz' : s (((ps Hs Hsep) * (ps Hs Hsep)) * ((K₂ s (s_inv Hs)) * 2 * n)) ≠ 0, from\n      s_ne_zero_of_ge_p Hs Hsep\n        (show ps Hs Hsep ≤ ((ps Hs Hsep) * (ps Hs Hsep)) * ((K₂ s (s_inv Hs)) * 2 * n),\n          by rewrite *pnat.mul_assoc; apply pnat.mul_le_mul_right),\n    rewrite [(s_inv_of_sep_gt_p Hs Hsep Hp), (division_ring.one_div_one_div Hnz')],\n    apply rat.le_trans,\n    apply mul_le_mul_of_nonneg_left,\n    apply Hs,\n    apply le_of_lt,\n    apply rat_of_pnat_is_pos,\n    rewrite [left_distrib, pnat.mul_comm ((ps Hs Hsep) * (ps Hs Hsep)), *pnat.mul_assoc,\n            *(@pnat.inv_mul_eq_mul_inv (K₂ s (s_inv Hs))), -*mul.assoc, *pnat.inv_cancel_left,\n            *one_mul, -(pnat.add_halves j)],\n    apply add_le_add,\n    apply inv_ge_of_le,\n    apply pnat_mul_le_mul_left',\n    apply le.trans,\n    rotate 1,\n    apply Hn,\n    rotate_right 1,\n    apply le_max_right,\n    apply inv_ge_of_le,\n    apply pnat_mul_le_mul_left',\n    apply le.trans,\n    apply le_max_right,\n    rotate 1,\n    apply le.trans,\n    apply Hn,\n    apply pnat.mul_le_mul_right\n   end\n\nprotected theorem inv_mul {s : seq} (Hs : regular s) (Hsep : sep s zero) :\n          smul (s_inv Hs) s ≡ one :=\n  begin\n    apply equiv.trans,\n    rotate 3,\n    apply s_mul_comm,\n    apply rat_seq.mul_inv,\n    repeat (assumption | apply reg_mul_reg | apply reg_inv_reg | apply zero_is_reg)\n  end\n\ntheorem sep_of_equiv_sep {s t : seq} (Hs : regular s) (Ht : regular t) (Heq : s ≡ t)\n        (Hsep : sep s zero) : sep t zero :=\n  begin\n    apply or.elim Hsep,\n    intro Hslt,\n    apply or.inl,\n    rewrite ↑s_lt at *,\n    apply pos_of_pos_equiv,\n    rotate 2,\n    apply Hslt,\n    rotate_right 1,\n    apply add_well_defined,\n    rotate 4,\n    apply equiv.refl,\n    apply neg_well_defined,\n    apply Heq,\n    intro Hslt,\n    apply or.inr,\n    rewrite ↑s_lt at *,\n    apply pos_of_pos_equiv,\n    rotate 2,\n    apply Hslt,\n    rotate_right 1,\n    apply add_well_defined,\n    rotate 5,\n    apply equiv.refl,\n    repeat (assumption | apply reg_neg_reg | apply reg_add_reg | apply zero_is_reg)\n  end\n\ntheorem inv_unique {s t : seq} (Hs : regular s) (Ht : regular t) (Hsep : sep s zero)\n        (Heq : smul s t ≡ one) : s_inv Hs ≡ t :=\n  begin\n    apply equiv.trans,\n    rotate 3,\n    apply equiv.symm,\n    apply s_mul_one,\n    rotate 1,\n    apply equiv.trans,\n    rotate 3,\n    apply mul_well_defined,\n    rotate 4,\n    apply equiv.refl,\n    apply equiv.symm,\n    apply Heq,\n    apply equiv.trans,\n    rotate 3,\n    apply equiv.symm,\n    apply s_mul_assoc,\n    rotate 3,\n    apply equiv.trans,\n    rotate 3,\n    apply mul_well_defined,\n    rotate 4,\n    apply rat_seq.inv_mul,\n    rotate 1,\n    apply equiv.refl,\n    apply s_one_mul,\n    repeat (assumption | apply reg_inv_reg | apply reg_mul_reg | apply one_is_reg)\n  end\n\ntheorem inv_well_defined {s t : seq} (Hs : regular s) (Ht : regular t) (Heq : s ≡ t) :\n        s_inv Hs ≡ s_inv Ht :=\n  if Hsep : sep s zero then\n    (begin\n       note Hsept := sep_of_equiv_sep Hs Ht Heq Hsep,\n       have Hm : smul t (s_inv Hs) ≡ smul s (s_inv Hs), begin\n         apply mul_well_defined,\n         repeat (assumption | apply reg_inv_reg),\n         apply equiv.symm s t Heq,\n         apply equiv.refl\n       end,\n       apply equiv.symm,\n       apply inv_unique,\n       rotate 2,\n       apply equiv.trans,\n       rotate 3,\n       apply Hm,\n       apply rat_seq.mul_inv,\n       repeat (assumption | apply reg_inv_reg | apply reg_mul_reg),\n       apply one_is_reg\n     end)\n  else\n    (have H : s_inv Hs = zero, from funext (λ n, dif_neg Hsep),\n     have Hsept : ¬ sep t zero, from\n       assume H', Hsep (sep_of_equiv_sep Ht Hs (equiv.symm _ _ Heq) H'),\n     have H' : s_inv Ht = zero, from funext (λ n, dif_neg Hsept),\n     by rewrite [H', H]; apply equiv.refl)\n\ntheorem s_neg_neg {s : seq} : sneg (sneg s) ≡ s :=\n  begin\n    rewrite [↑equiv, ↑sneg],\n    intro n,\n    rewrite [neg_neg, sub_self, abs_zero],\n    apply add_invs_nonneg\n  end\n\ntheorem s_neg_sub {s t : seq} (Hs : regular s) (Ht : regular t) :\n        sneg (sadd s (sneg t)) ≡ sadd t (sneg s) :=\n  begin\n    apply equiv.trans,\n    rotate 3,\n    apply s_neg_add_eq_s_add_neg,\n    apply equiv.trans,\n    rotate 3,\n    apply add_well_defined,\n    rotate 4,\n    apply equiv.refl,\n    apply s_neg_neg,\n    apply s_add_comm,\n    repeat (assumption | apply reg_add_reg | apply reg_neg_reg)\n  end\n\ntheorem s_le_total {s t : seq} (Hs : regular s) (Ht : regular t) : s_le s t ∨ s_le t s :=\n  if H : s_le s t then or.inl H else or.inr begin\n      rewrite [↑s_le at *],\n      have H' : ∃ n : ℕ+, -n⁻¹ > sadd t (sneg s) n, begin\n        apply by_contradiction,\n        intro Hex,\n        have Hex' : ∀ n : ℕ+, -n⁻¹ ≤ sadd t (sneg s) n, begin\n          intro m,\n          apply by_contradiction,\n          intro Hm,\n          note Hm' := lt_of_not_ge Hm,\n          note Hex'' := exists.intro m Hm',\n          apply Hex Hex''\n        end,\n        apply H Hex'\n      end,\n      eapply exists.elim H',\n      intro m Hm,\n      note Hm' := neg_lt_neg Hm,\n      rewrite neg_neg at Hm',\n      apply s_nonneg_of_pos,\n      rotate 1,\n      apply pos_of_pos_equiv,\n      rotate 1,\n      apply s_neg_sub,\n      rotate 2,\n      rewrite [↑pos, ↑sneg],\n      existsi m,\n      apply Hm',\n      repeat (assumption | apply reg_add_reg | apply reg_neg_reg)\n    end\n\ntheorem s_le_of_not_lt {s t : seq} (Hle : ¬ s_lt s t) : s_le t s :=\n  begin\n    rewrite [↑s_le, ↑nonneg, ↑s_lt at Hle, ↑pos at Hle],\n    let Hle' := iff.mp forall_iff_not_exists Hle,\n    intro n,\n    let Hn := neg_le_neg (le_of_not_gt (Hle' n)),\n    rewrite [↑sadd, ↑sneg, add_neg_eq_neg_add_rev],\n    apply Hn\n  end\n\ntheorem sep_of_nequiv {s t : seq} (Hs : regular s) (Ht : regular t) (Hneq : ¬ equiv s t) :\n        sep s t :=\n  begin\n    rewrite ↑sep,\n    apply by_contradiction,\n    intro Hnor,\n    let Hand := iff.mp !not_or_iff_not_and_not Hnor,\n    let Hle1 := s_le_of_not_lt (and.left Hand),\n    let Hle2 := s_le_of_not_lt (and.right Hand),\n    apply Hneq (equiv_of_le_of_ge Hs Ht Hle2 Hle1)\n  end\n\ntheorem s_zero_inv_equiv_zero : s_inv zero_is_reg ≡ zero :=\n  by rewrite s_inv_zero; apply equiv.refl\n\ntheorem lt_or_equiv_of_le {s t : seq} (Hs : regular s) (Ht : regular t) (Hle : s_le s t) :\n        s_lt s t ∨ s ≡ t :=\n  if H : s ≡ t then or.inr H else\n    or.inl (lt_of_le_and_sep Hs Ht (and.intro Hle (sep_of_nequiv Hs Ht H)))\n\ntheorem s_le_of_equiv_le_left {s t u : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u)\n        (Heq : s ≡ t) (Hle : s_le s u) : s_le t u :=\n  begin\n    rewrite ↑s_le at *,\n    apply nonneg_of_nonneg_equiv,\n    rotate 2,\n    apply add_well_defined,\n    rotate 4,\n    apply equiv.refl,\n    apply neg_well_defined,\n    apply Heq,\n    repeat (assumption | apply reg_add_reg | apply reg_neg_reg)\n  end\n\ntheorem s_le_of_equiv_le_right {s t u : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u)\n        (Heq : t ≡ u) (Hle : s_le s t) : s_le s u :=\n  begin\n    rewrite ↑s_le at *,\n    apply nonneg_of_nonneg_equiv,\n    rotate 2,\n    apply add_well_defined,\n    rotate 4,\n    apply Heq,\n    apply equiv.refl,\n    repeat (assumption | apply reg_add_reg | apply reg_neg_reg)\n  end\n\n-----------------------------\n\nnoncomputable definition r_inv (s : reg_seq) : reg_seq := reg_seq.mk (s_inv (reg_seq.is_reg s))\n  (if H : sep (reg_seq.sq s) zero then reg_inv_reg (reg_seq.is_reg s) H else\n    have Hz : s_inv (reg_seq.is_reg s) = zero, from funext (λ n, dif_neg H),\n    by rewrite Hz; apply zero_is_reg)\n\ntheorem r_inv_zero : requiv (r_inv r_zero) r_zero :=\n  s_zero_inv_equiv_zero\n\ntheorem r_inv_well_defined {s t : reg_seq} (H : requiv s t) : requiv (r_inv s) (r_inv t) :=\n  inv_well_defined (reg_seq.is_reg s) (reg_seq.is_reg t) H\n\ntheorem r_le_total (s t : reg_seq) : r_le s t ∨ r_le t s :=\n  s_le_total (reg_seq.is_reg s) (reg_seq.is_reg t)\n\ntheorem r_mul_inv (s : reg_seq) (Hsep : r_sep s r_zero) : requiv (s * (r_inv s)) r_one :=\n  rat_seq.mul_inv (reg_seq.is_reg s) Hsep\n\ntheorem r_sep_of_nequiv (s t : reg_seq) (Hneq : ¬ requiv s t) : r_sep s t :=\n  sep_of_nequiv (reg_seq.is_reg s) (reg_seq.is_reg t) Hneq\n\ntheorem r_lt_or_equiv_of_le (s t : reg_seq) (Hle : r_le s t) : r_lt s t ∨ requiv s t :=\n  lt_or_equiv_of_le (reg_seq.is_reg s) (reg_seq.is_reg t) Hle\n\ntheorem r_le_of_equiv_le_left {s t u : reg_seq} (Heq : requiv s t) (Hle : r_le s u) : r_le t u :=\n  s_le_of_equiv_le_left (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u) Heq Hle\n\ntheorem r_le_of_equiv_le_right {s t u : reg_seq} (Heq : requiv t u) (Hle : r_le s t) : r_le s u :=\n  s_le_of_equiv_le_right (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u) Heq Hle\n\ndefinition r_abs (s : reg_seq) : reg_seq :=\n  reg_seq.mk (s_abs (reg_seq.sq s)) (abs_reg_of_reg (reg_seq.is_reg s))\n\ntheorem r_abs_well_defined {s t : reg_seq} (H : requiv s t) : requiv (r_abs s) (r_abs t) :=\n  abs_well_defined (reg_seq.is_reg s) (reg_seq.is_reg t) H\n\nend rat_seq\n\nnamespace real\nopen [class] rat_seq\n\nnoncomputable protected definition inv (x : ℝ) : ℝ :=\n  quot.lift_on x (λ a, quot.mk (rat_seq.r_inv a))\n           (λ a b H, quot.sound (rat_seq.r_inv_well_defined H))\n\nnoncomputable definition real_has_inv [instance] [priority real.prio] : has_inv real :=\n  has_inv.mk real.inv\n\nnoncomputable protected definition div (x y : ℝ) : ℝ :=\n  x * y⁻¹\n\nnoncomputable definition real_has_div : has_div real :=\n  has_div.mk real.div\n\nlocal attribute real_has_div [instance] [priority real.prio]\n\nprotected theorem le_total (x y : ℝ) : x ≤ y ∨ y ≤ x :=\n  quot.induction_on₂ x y (λ s t, rat_seq.r_le_total s t)\n\nprotected theorem mul_inv_cancel' (x : ℝ) : x ≢ 0 → x * x⁻¹ = 1 :=\n  quot.induction_on x (λ s H, quot.sound (rat_seq.r_mul_inv s H))\n\nprotected theorem inv_mul_cancel' (x : ℝ) : x ≢ 0 → x⁻¹ * x = 1 :=\n  by rewrite real.mul_comm; apply real.mul_inv_cancel'\n\ntheorem neq_of_sep {x y : ℝ} (H : x ≢ y) : ¬ x = y :=\n  assume Heq, !not_sep_self (Heq ▸ H)\n\ntheorem sep_of_neq {x y : ℝ} : ¬ x = y → x ≢ y :=\n  quot.induction_on₂ x y (λ s t H, rat_seq.r_sep_of_nequiv s t (assume Heq, H (quot.sound Heq)))\n\ntheorem sep_is_neq (x y : ℝ) : (x ≢ y) = (¬ x = y) :=\n  propext (iff.intro neq_of_sep sep_of_neq)\n\nprotected theorem mul_inv_cancel (x : ℝ) : x ≠ 0 → x * x⁻¹ = 1 :=\n  !sep_is_neq ▸ !real.mul_inv_cancel'\n\nprotected theorem inv_mul_cancel (x : ℝ) : x ≠ 0 → x⁻¹ * x = 1 :=\n  !sep_is_neq ▸ !real.inv_mul_cancel'\n\nprotected theorem inv_zero : (0 : ℝ)⁻¹ = 0 := quot.sound (rat_seq.r_inv_zero)\n\nprotected theorem lt_or_eq_of_le (x y : ℝ) : x ≤ y → x < y ∨ x = y :=\n  quot.induction_on₂ x y (λ s t H, or.elim (rat_seq.r_lt_or_equiv_of_le s t H)\n    (assume H1, or.inl H1)\n    (assume H2, or.inr (quot.sound H2)))\n\nprotected theorem le_iff_lt_or_eq (x y : ℝ) : x ≤ y ↔ x < y ∨ x = y :=\n  iff.intro (real.lt_or_eq_of_le x y) (real.le_of_lt_or_eq x y)\n\nnoncomputable definition dec_lt : decidable_rel real.lt :=\n  begin\n    rewrite ↑decidable_rel,\n    intros,\n    apply prop_decidable\n  end\n\nprotected noncomputable definition discrete_linear_ordered_field [trans_instance]:\n  discrete_linear_ordered_field ℝ :=\n  ⦃ discrete_linear_ordered_field, real.comm_ring, real.ordered_ring,\n    le_total        := real.le_total,\n    mul_inv_cancel  := real.mul_inv_cancel,\n    inv_mul_cancel  := real.inv_mul_cancel,\n    zero_lt_one     := real.zero_lt_one,\n    inv_zero        := real.inv_zero,\n    le_iff_lt_or_eq := real.le_iff_lt_or_eq,\n    decidable_lt    := dec_lt\n   ⦄\n\ntheorem of_rat_divide (x y : ℚ) : of_rat (x / y) = of_rat x / of_rat y :=\nby_cases\n  (assume yz : y = 0, by krewrite [yz, div_zero, +of_rat_zero, div_zero])\n  (assume ynz : y ≠ 0,\n    have ynz' : of_rat y ≠ 0, from assume yz', ynz (of_rat.inj yz'),\n    !eq_div_of_mul_eq ynz' (by krewrite [-of_rat_mul, !div_mul_cancel ynz]))\n\nopen int\n\ntheorem of_int_div (x y : ℤ) (H : y ∣ x) : of_int (x / y) = of_int x / of_int y :=\nby rewrite [of_int_eq, rat.of_int_div H, of_rat_divide]\n\ntheorem of_nat_div (x y : ℕ) (H : y ∣ x) : of_nat (x / y) = of_nat x / of_nat y :=\nby rewrite [of_nat_eq, rat.of_nat_div H, of_rat_divide]\n\n/- useful for proving equalities -/\n\ntheorem eq_zero_of_nonneg_of_forall_lt {x : ℝ} (xnonneg : x ≥ 0) (H : ∀ ε : ℝ, ε > 0 → x < ε) :\n  x = 0 :=\ndecidable.by_contradiction\n  (suppose x ≠ 0,\n   have x > 0, from lt_of_le_of_ne xnonneg (ne.symm this),\n   have x < x, from H x this,\n   show false, from !lt.irrefl this)\n\ntheorem eq_zero_of_nonneg_of_forall_le {x : ℝ} (xnonneg : x ≥ 0) (H : ∀ ε : ℝ, ε > 0 → x ≤ ε) :\n  x = 0 :=\nhave ∀ ε : ℝ, ε > 0 → x < ε, from\n  take ε, suppose ε > 0,\n  have e2pos : ε / 2 > 0, from div_pos_of_pos_of_pos `ε > 0` two_pos,\n  have ε / 2 < ε, from div_two_lt_of_pos `ε > 0`,\n  begin apply lt_of_le_of_lt, apply H _ e2pos, apply this end,\neq_zero_of_nonneg_of_forall_lt xnonneg this\n\ntheorem eq_zero_of_forall_abs_le {x : ℝ} (H : ∀ ε : ℝ, ε > 0 → abs x ≤ ε) :\n  x = 0 :=\nby_contradiction\n  (suppose x ≠ 0,\n   have abs x = 0, from eq_zero_of_nonneg_of_forall_le !abs_nonneg H,\n   show false, from `x ≠ 0` (eq_zero_of_abs_eq_zero this))\n\ntheorem eq_of_forall_abs_sub_le {x y : ℝ} (H : ∀ ε : ℝ, ε > 0 → abs (x - y) ≤ ε) :\n  x = y :=\nhave x - y = 0, from eq_zero_of_forall_abs_le H,\neq_of_sub_eq_zero this\nend real\n", "meta": {"author": "Bolt64", "repo": "lean2-aur", "sha": "1d7148e58a17b2d326b032ed1ebf8c5217320242", "save_path": "github-repos/lean/Bolt64-lean2-aur", "path": "github-repos/lean/Bolt64-lean2-aur/lean2-aur-1d7148e58a17b2d326b032ed1ebf8c5217320242/library/data/real/division.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.4866519312904693}}
{"text": "/-\nCopyright (c) 2023 Yaël Dillies, Sky Wilshaw. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Sky Wilshaw\n-/\nimport group_theory.perm.basic\nimport logic.equiv.local_equiv\n\n/-!\n# Local equivalences\n\nThis files defines permutations on a set.\n\nA local permutation on `α` is a domain `set α` and two functions `α → α` that map `domain` to\n`domain` and are inverse to each other on `domain`.\n\n## Main declarations\n\n* `local_perm α`: The type of local permutations on `α`.\n* `equiv.to_local_perm`: Reinter\n-/\n\n\nopen function set\n\nvariables {α : Type*}\n\n/-- A local permutation of a subset `domain` of `α`. The (global) maps `to_fun : α → α` and\n`inv_fun : α → α` map `domain` to itself, and are inverse to each other there. The values of\n`to_fun` and `inv_fun` outside of `domain` are irrelevant. -/\nstructure local_perm (α : Type*) :=\n(to_fun inv_fun : α → α)\n(domain : set α)\n(to_fun_domain' : ∀ ⦃x⦄, x ∈ domain → to_fun x ∈ domain)\n(inv_fun_domain' : ∀ ⦃x⦄, x ∈ domain → inv_fun x ∈ domain)\n(left_inv' : ∀ ⦃x⦄, x ∈ domain → inv_fun (to_fun x) = x)\n(right_inv' : ∀ ⦃x⦄, x ∈ domain → to_fun (inv_fun x) = x)\n\n/-- A `perm` gives rise to a `local_perm` Associating a local_perm to an equiv -/\ndef equiv.perm.to_local_perm (π : equiv.perm α) : local_perm α :=\n{ to_fun := π,\n  inv_fun := π.symm,\n  domain := univ,\n  to_fun_domain' := λ x hx, mem_univ _,\n  inv_fun_domain' := λ y hy, mem_univ _,\n  left_inv' := λ x hx, π.left_inv x,\n  right_inv' := λ x hx, π.right_inv x }\n\nnamespace local_perm\nvariables (π π' : local_perm α)\n\n/-- The inverse of a local permutation. -/\nprotected def symm : local_perm α :=\n{ to_fun := π.inv_fun,\n  inv_fun := π.to_fun,\n  domain := π.domain,\n  to_fun_domain' := π.inv_fun_domain',\n  inv_fun_domain' := π.to_fun_domain',\n  left_inv' := π.right_inv',\n  right_inv' := π.left_inv' }\n\ninstance : has_coe_to_fun (local_perm α) (λ _, α → α) := ⟨local_perm.to_fun⟩\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (π : local_perm α) : α → α := π.symm\n\ninitialize_simps_projections local_perm (to_fun → apply, inv_fun → symm_apply)\n\n@[simp] theorem coe_mk (f : α → α) (g s ml mr il ir) :\n  (local_perm.mk f g s ml mr il ir : α → α) = f := rfl\n\n@[simp] theorem coe_symm_mk (f : α → α) (g s ml mr il ir) :\n  ((local_perm.mk f g s ml mr il ir).symm : α → α) = g := rfl\n\n@[simp] lemma to_fun_as_coe : π.to_fun = π := rfl\n@[simp] lemma inv_fun_as_coe : π.inv_fun = π.symm := rfl\n\n@[simp] lemma map_domain {x : α} (h : x ∈ π.domain) : π x ∈ π.domain := π.to_fun_domain' h\n@[simp] lemma iterate_domain {x : α} (h : x ∈ π.domain) {n : ℕ} : π^[n] x ∈ π.domain :=\nbegin\n  induction n with n ih,\n  exact h,\n  rw function.iterate_succ',\n  exact π.map_domain ih,\nend\n\n@[simp] lemma left_inv {x : α} (h : x ∈ π.domain) : π.symm (π x) = x := π.left_inv' h\n@[simp] lemma right_inv {x : α} (h : x ∈ π.domain) : π (π.symm x) = x := π.right_inv' h\n\n@[simp] lemma symm_domain : π.symm.domain = π.domain := rfl\n@[simp] lemma symm_symm : π.symm.symm = π := by { cases π, refl }\n\nlemma eq_symm_apply {x : α} {y : α} (hx : x ∈ π.domain) (hy : y ∈ π.domain) :\n  x = π.symm y ↔ π x = y :=\n⟨λ h, by rw [← π.right_inv hy, h], λ h, by rw [← π.left_inv hx, h]⟩\n\nprotected lemma maps_to : maps_to π π.domain π.domain := λ x, π.map_domain\nprotected lemma left_inv_on : left_inv_on π.symm π π.domain := λ x, π.left_inv\nprotected lemma right_inv_on : right_inv_on π.symm π π.domain := λ x, π.right_inv\nprotected lemma inv_on : inv_on π.symm π π.domain π.domain := ⟨π.left_inv_on, π.right_inv_on⟩\nprotected lemma inj_on : inj_on π π.domain := π.left_inv_on.inj_on\nprotected lemma bij_on : bij_on π π.domain π.domain := π.inv_on.bij_on π.maps_to π.symm.maps_to\nprotected lemma surj_on : surj_on π π.domain π.domain := π.bij_on.surj_on\n\n/-- Create a copy of a `local_perm` providing better definitional equalities. -/\n@[simps {fully_applied := ff}]\ndef copy (π : local_perm α) (f : α → α) (hf : ⇑π = f) (g : α → α) (hg : ⇑π.symm = g)\n  (s : set α) (hs : π.domain = s) :\n  local_perm α :=\n{ to_fun := f,\n  inv_fun := g,\n  domain := s,\n  to_fun_domain' := hs ▸ hf ▸ π.to_fun_domain',\n  inv_fun_domain' := hs ▸ hg ▸ π.inv_fun_domain',\n  left_inv' := λ x, hs ▸ hf ▸ hg ▸ π.left_inv,\n  right_inv' := λ x, hs ▸ hf ▸ hg ▸ π.right_inv }\n\nlemma copy_eq (π : local_perm α) (f : α → α) (hf : ⇑π = f) (g : α → α) (hg : ⇑π.symm = g)\n  (s : set α) (hs : π.domain = s) :\n  π.copy f hf g hg s hs = π :=\nby { substs f g s, cases π, refl }\n\n/-- Associating to a local_perm a permutation of the domain. -/\nprotected def to_perm : equiv.perm π.domain :=\n{ to_fun := λ x, ⟨π x, π.map_domain x.mem⟩,\n  inv_fun := λ y, ⟨π.symm y, π.symm.map_domain y.mem⟩,\n  left_inv := λ ⟨x, hx⟩, subtype.eq $ π.left_inv hx,\n  right_inv := λ ⟨y, hy⟩, subtype.eq $ π.right_inv hy }\n\n@[simp] lemma image_domain : π '' π.domain = π.domain := π.bij_on.image_eq\n\nlemma forall_mem_domain {p : α → Prop} : (∀ y ∈ π.domain, p y) ↔ ∀ x ∈ π.domain, p (π x) :=\nby conv_lhs { rw [←image_domain, ball_image_iff] }\n\nlemma exists_mem_domain {p : α → Prop} : (∃ y ∈ π.domain, p y) ↔ ∃ x ∈ π.domain, p (π x) :=\nby conv_lhs { rw [←image_domain, bex_image_iff] }\n\n/-- A set `s` is *stable* under a local equivalence `π` if it preserved by it. -/\ndef is_stable (s : set α) : Prop := ∀ ⦃x⦄, x ∈ π.domain → (π x ∈ s ↔ x ∈ s)\n\nnamespace is_stable\n\nvariables {π π'} {s : set α} {x y : α}\n\nlemma apply_mem_iff (h : π.is_stable s) (hx : x ∈ π.domain) : π x ∈ s ↔ x ∈ s := h hx\n\nlemma symm_apply_mem_iff (h : π.is_stable s) : ∀ ⦃y⦄, y ∈ π.domain → (π.symm y ∈ s ↔ y ∈ s) :=\nπ.forall_mem_domain.mpr $ λ x hx, by rw [π.left_inv hx, h hx]\n\nprotected lemma symm (h : π.is_stable s) : π.symm.is_stable s := h.symm_apply_mem_iff\n\n@[simp] lemma symm_iff : π.symm.is_stable s ↔ π.is_stable s := ⟨λ h, h.symm, λ h, h.symm⟩\n\nprotected lemma maps_to (h : π.is_stable s) : maps_to π (π.domain ∩ s) (π.domain ∩ s) :=\nλ x hx, ⟨π.maps_to hx.1, (h hx.1).2 hx.2⟩\n\nlemma symm_maps_to (h : π.is_stable s) : maps_to π.symm (π.domain ∩ s) (π.domain ∩ s) :=\nh.symm.maps_to\n\n/-- Restrict a `local_perm` to a stable subset. -/\n@[simps {fully_applied := ff}] def restr (h : π.is_stable s) : local_perm α :=\n{ to_fun := π,\n  inv_fun := π.symm,\n  domain := π.domain ∩ s,\n  to_fun_domain' := h.maps_to,\n  inv_fun_domain' := h.symm_maps_to,\n  left_inv' := π.left_inv_on.mono (inter_subset_left _ _),\n  right_inv' := π.right_inv_on.mono (inter_subset_left _ _) }\n\nlemma image_eq (h : π.is_stable s) : π '' (π.domain ∩ s) = π.domain ∩ s :=\nh.restr.image_domain\n\nlemma symm_image_eq (h : π.is_stable s) : π.symm '' (π.domain ∩ s) = π.domain ∩ s :=\nh.symm.image_eq\n\nlemma iff_preimage_eq : π.is_stable s ↔ π.domain ∩ π ⁻¹' s = π.domain ∩ s :=\nby simp only [is_stable, set.ext_iff, mem_inter_iff, and.congr_right_iff, mem_preimage]\n\nalias iff_preimage_eq ↔ preimage_eq of_preimage_eq\n\nlemma iff_symm_preimage_eq : π.is_stable s ↔ π.domain ∩ π.symm ⁻¹' s = π.domain ∩ s :=\nsymm_iff.symm.trans iff_preimage_eq\n\nalias iff_symm_preimage_eq ↔ symm_preimage_eq of_symm_preimage_eq\n\n-- lemma of_image_eq (h : π '' (π.domain ∩ s) = π.domain ∩ s) : π.is_stable s :=\n-- of_symm_preimage_eq $ eq.trans (of_symm_preimage_eq rfl).image_eq.symm h\n\n-- lemma of_symm_image_eq (h : π.symm '' (π.domain ∩ s) = π.domain ∩ s) : π.is_stable s :=\n-- of_preimage_eq $ eq.trans (of_preimage_eq rfl).symm_image_eq.symm h\n\nprotected lemma compl (h : π.is_stable s) : π.is_stable sᶜ := λ x hx, not_congr (h hx)\n\nprotected lemma inter {s'} (h : π.is_stable s) (h' : π.is_stable s') : π.is_stable (s ∩ s') :=\nλ x hx, and_congr (h hx) (h' hx)\n\nprotected lemma union {s'} (h : π.is_stable s) (h' : π.is_stable s') : π.is_stable (s ∪ s') :=\nλ x hx, or_congr (h hx) (h' hx)\n\nprotected lemma diff {s'} (h : π.is_stable s) (h' : π.is_stable s') : π.is_stable (s \\ s') :=\nh.inter h'.compl\n\nlemma left_inv_on_piecewise {π' : local_perm α} [Π i, decidable (i ∈ s)]\n  (h : π.is_stable s) (h' : π'.is_stable s) :\n  left_inv_on (s.piecewise π.symm π'.symm) (s.piecewise π π') (s.ite π.domain π'.domain) :=\nbegin\n  rintro x (⟨he, hs⟩ | ⟨he, hs : x ∉ s⟩),\n  { rw [piecewise_eq_of_mem _ _ _ hs, piecewise_eq_of_mem _ _ _ ((h he).2 hs), π.left_inv he] },\n  { rw [piecewise_eq_of_not_mem _ _ _ hs, piecewise_eq_of_not_mem _ _ _ ((h'.compl he).2 hs),\n      π'.left_inv he] }\nend\n\nlemma inter_eq_of_inter_eq_of_eq_on {π' : local_perm α} (h : π.is_stable s)\n  (h' : π'.is_stable s) (hs : π.domain ∩ s = π'.domain ∩ s) (Heq : eq_on π π' (π.domain ∩ s)) :\n  π.domain ∩ s = π'.domain ∩ s :=\nby rw [← h.image_eq, ← h'.image_eq, ← hs, Heq.image_eq]\n\nlemma symm_eq_on_of_inter_eq_of_eq_on {π' : local_perm α} (h : π.is_stable s)\n  (hs : π.domain ∩ s = π'.domain ∩ s) (Heq : eq_on π π' (π.domain ∩ s)) :\n  eq_on π.symm π'.symm (π.domain ∩ s) :=\nbegin\n  rw ←h.image_eq,\n  rintro y ⟨x, hx, rfl⟩,\n  have hx' := hx, rw hs at hx',\n  rw [π.left_inv hx.1, Heq hx, π'.left_inv hx'.1]\nend\n\nend is_stable\n\nlemma image_domain_inter_eq' (s : set α) :\n  π '' (π.domain ∩ s) = π.domain ∩ π.symm ⁻¹' s :=\nby rw [inter_comm, π.left_inv_on.image_inter', image_domain, inter_comm]\n\nlemma image_domain_inter_eq (s : set α) :\n  π '' (π.domain ∩ s) = π.domain ∩ π.symm ⁻¹' (π.domain ∩ s) :=\nby rw [inter_comm, π.left_inv_on.image_inter, image_domain, inter_comm]\n\nlemma image_eq_domain_inter_inv_preimage {s : set α} (h : s ⊆ π.domain) :\n  π '' s = π.domain ∩ π.symm ⁻¹' s :=\nby rw [← π.image_domain_inter_eq', inter_eq_self_of_subset_right h]\n\nlemma symm_image_eq_domain_inter_preimage {s : set α} (h : s ⊆ π.domain) :\n  π.symm '' s = π.domain ∩ π ⁻¹' s :=\nπ.symm.image_eq_domain_inter_inv_preimage h\n\nlemma symm_image_domain_inter_eq (s : set α) :\n  π.symm '' (π.domain ∩ s) = π.domain ∩ π ⁻¹' (π.domain ∩ s) :=\nπ.symm.image_domain_inter_eq _\n\nlemma symm_image_domain_inter_eq' (s : set α) : π.symm '' (π.domain ∩ s) = π.domain ∩ π ⁻¹' s :=\nπ.symm.image_domain_inter_eq' _\n\nlemma domain_inter_preimage_inv_preimage (s : set α) :\n  π.domain ∩ π ⁻¹' (π.symm ⁻¹' s) = π.domain ∩ s :=\nset.ext $ λ x, and.congr_right_iff.2 $ λ hx, by simp only [mem_preimage, π.left_inv hx]\n\nlemma domain_inter_preimage_domain_inter (s : set α) :\n  π.domain ∩ (π ⁻¹' (π.domain ∩ s)) = π.domain ∩ (π ⁻¹' s) :=\next $ λ x, ⟨λ hx, ⟨hx.1, hx.2.2⟩, λ hx, ⟨hx.1, π.map_domain hx.1, hx.2⟩⟩\n\nlemma domain_inter_inv_preimage_preimage (s : set α) :\n  π.domain ∩ π.symm ⁻¹' (π ⁻¹' s) = π.domain ∩ s :=\nπ.symm.domain_inter_preimage_inv_preimage _\n\nlemma symm_image_image_of_subset_domain {s : set α} (h : s ⊆ π.domain) : π.symm '' (π '' s) = s :=\n(π.left_inv_on.mono h).image_image\n\nlemma image_symm_image_of_subset_domain {s : set α} (h : s ⊆ π.domain) : π '' (π.symm '' s) = s :=\nπ.symm.symm_image_image_of_subset_domain h\n\nvariables {π π'}\n\nlemma domain_subset_preimage_domain : π.domain ⊆ π ⁻¹' π.domain := π.maps_to\nlemma symm_image_domain : π.symm '' π.domain = π.domain := π.symm.image_domain\n\n/-- Two local equivs that have the same `domain`, same `to_fun` and same `inv_fun`, coincide. -/\n@[ext]\nprotected lemma ext (h : ∀ x, π x = π' x)\n  (hsymm : ∀ x, π.symm x = π'.symm x) (hs : π.domain = π'.domain) : π = π' :=\nbegin\n  have A : (π : α → α) = π', by { ext x, exact h x },\n  have B : (π.symm : α → α) = π'.symm, by { ext x, exact hsymm x },\n  have I : π '' π.domain = π.domain := π.image_domain,\n  have I' : π' '' π'.domain = π'.domain := π'.image_domain,\n  rw [A, hs, I'] at I,\n  cases π; cases π',\n  simp only [*, coe_symm_mk, coe_mk, eq_self_iff_true, and_self] at *\nend\n\n/-- The identity local equivalence. -/\nprotected def refl (α : Type*) : local_perm α := equiv.perm.to_local_perm $ equiv.refl _\n\n@[simp] lemma refl_domain : (local_perm.refl α).domain = univ := rfl\n@[simp, norm_cast] lemma coe_refl : ⇑(local_perm.refl α) = id := rfl\n@[simp] lemma symm_refl : (local_perm.refl α).symm = local_perm.refl α := rfl\n\ninstance : inhabited (local_perm α) := ⟨local_perm.refl _⟩\n\nvariables (π π')\n\n-- TODO: Clean up these proofs\n/-- Composing two local equivs if the domain of the first coincides with the domain of the\nsecond. -/\n@[simps]\nprotected def trans (π' : local_perm α) (h : π.domain = π'.domain) : local_perm α :=\n{ to_fun := π' ∘ π,\n  inv_fun := π.symm ∘ π'.symm,\n  domain := π.domain,\n  to_fun_domain' := λ x hx, begin\n    rw h,\n    refine map_domain _ _,\n    have := map_domain π hx,\n    rwa h at this,\n  end,\n  inv_fun_domain' := λ y hy, map_domain _ begin\n    rw h at hy,\n    have := map_domain π'.symm hy,\n    rwa [symm_domain, ← h] at this,\n  end,\n  left_inv' := λ x hx, by simp [hx, h.symm],\n  right_inv' := λ y hy, begin\n    simp,\n    rw h at hy,\n    rw [right_inv π, right_inv π' hy],\n    have := map_domain π'.symm hy,\n    rwa [symm_domain, ← h] at this,\n  end }\n\n/-- The identity local equiv on a set `s` -/\ndef of_set (s : set α) : local_perm α :=\n{ to_fun := id,\n  inv_fun := id,\n  domain := s,\n  to_fun_domain' := λ x hx, hx,\n  inv_fun_domain' := λ x hx, hx,\n  left_inv' := λ x hx, rfl,\n  right_inv' := λ x hx, rfl }\n\n@[simp] lemma of_set_domain (s : set α) : (of_set s).domain = s := rfl\n@[simp, norm_cast] lemma coe_of_set (s : set α) : (of_set s : α → α) = id := rfl\n@[simp] lemma of_set_symm (s : set α) : (of_set s).symm = of_set s := rfl\n@[simp] lemma of_set_trans_of_set (s : set α) : (of_set s).trans (of_set s) rfl = of_set s := rfl\n@[simp] lemma of_set_univ : of_set univ = local_perm.refl α := rfl\n\n/-- Reinterpret a local permutation as a local equivalence. -/\ndef to_local_equiv : local_equiv α α :=\n{ to_fun := π,\n  inv_fun := π.symm,\n  source := π.domain,\n  target := π.domain,\n  map_source' := π.maps_to,\n  map_target' := π.symm.maps_to,\n  left_inv' := π.left_inv_on,\n  right_inv' := π.right_inv_on }\n\n@[simp] lemma coe_to_local_equiv : ⇑π.to_local_equiv = π := rfl\n@[simp] lemma coe_to_local_equiv_symm : ⇑π.to_local_equiv.symm = π.symm := rfl\n@[simp] lemma to_local_equiv_source : π.to_local_equiv.source = π.domain := rfl\n@[simp] lemma to_local_equiv_target : π.to_local_equiv.target = π.domain := rfl\n\n@[simp] lemma to_local_equiv_refl : (local_perm.refl α).to_local_equiv = local_equiv.refl _ := rfl\n@[simp] lemma to_local_equiv_symm : π.symm.to_local_equiv = π.to_local_equiv.symm := rfl\n@[simp] lemma to_local_equiv_trans (h) :\n  (π.trans π' h).to_local_equiv = π.to_local_equiv.trans π'.to_local_equiv :=\nbegin\n  ext,\n  { simp },\n  { simp },\n  { simpa [←h] using λ hx, π.maps_to hx }\nend\n\n/-- `eq_on_domain π π'` means that `π` and `π'` have the same domain, and coincide there. Then `π`\nand `π'` should really be considered the same local permutation. -/\ndef eq_on_domain : Prop := π.domain = π'.domain ∧ π.domain.eq_on π π'\n\n/-- `eq_on_domain` is an equivalence relation -/\ninstance eq_on_domain_setoid : setoid (local_perm α) :=\n{ r := eq_on_domain,\n  iseqv := ⟨\n    λ e, by simp [eq_on_domain],\n    λ e e' h, by { simp [eq_on_domain, h.1.symm], exact λ x hx, (h.2 hx).symm },\n    λ e e' e'' h h', ⟨by rwa [← h'.1, ← h.1], λ x hx, by { rw [← h'.2, h.2 hx], rwa ← h.1 }⟩⟩ }\n\nvariables {π π'}\n\nlemma eq_on_domain_refl : π ≈ π := setoid.refl _\n\n/-- Two equivalent local equivs have the same domain -/\nlemma eq_on_domain.domain_eq (h : π ≈ π') : π.domain = π'.domain := h.1\n\n/-- Two equivalent local equivs coincide on the domain -/\nlemma eq_on_domain.eq_on (h : π ≈ π') : π.domain.eq_on π π' := h.2\n\n/-- If two local equivs are equivalent, so are their inverses. -/\nlemma eq_on_domain.symm' (h : π ≈ π') : π.symm ≈ π'.symm :=\nbegin\n  refine ⟨h.domain_eq, eq_on_of_left_inv_on_of_right_inv_on π.left_inv_on _ _⟩;\n    simp only [symm_domain, h.domain_eq, h.domain_eq, π'.symm.maps_to],\n  exact π'.right_inv_on.congr_right π'.symm.maps_to (h.domain_eq ▸ h.eq_on.symm),\n  exact π'.symm.maps_to,\nend\n\n/-- Two equivalent local equivs have coinciding inverses on the domain -/\nlemma eq_on_domain.symm_eq_on (h : π ≈ π') : eq_on π.symm π'.symm π.domain := h.symm'.eq_on\n\n/-- Preimages are respected by equivalence -/\nlemma eq_on_domain.domain_inter_preimage_eq (hπ : π ≈ π') (s : set α) :\n  π.domain ∩ π ⁻¹' s = π'.domain ∩ π' ⁻¹' s :=\nby rw [hπ.eq_on.inter_preimage_eq, hπ.domain_eq]\n\n/-- Two equivalent local equivs are equal when the domain and domain are univ -/\nprotected lemma eq_on_domain.eq (h : π ≈ π') (hπ : π.domain = univ) : π = π' :=\nby apply local_perm.ext (λ x, h.2 _) (λ x, h.symm'.2 _) h.1; simp [hπ]\n\n/-- We define a preorder on local permutations by saying `π ≤ π'` if the domain of `π` is contained\nin the domain of `π'`, and the permutations agree on the domain of `π`. -/\ninstance : preorder (local_perm α) :=\n{  le := λ π π', π.domain ⊆ π'.domain ∧ π.domain.eq_on π π',\n  le_refl := λ a, ⟨subset_rfl, eq_on_refl _ _⟩,\n  le_trans := λ a b c hab hbc, ⟨hab.1.trans hbc.1, hab.2.trans $ hbc.2.mono hab.1⟩ }\n\nlemma domain_mono (h : π ≤ π') : π.domain ⊆ π'.domain := h.1\nlemma eq_on_domain_of_le (h : π ≤ π') : π.domain.eq_on π π' := h.2\nlemma le_of_eq_on_domain (h : π ≈ π') : π ≤ π' := ⟨subset_of_eq h.1, h.2⟩\nlemma apply_eq_of_le (h : π ≤ π') {x : α} (hx : x ∈ π.domain) : π' x = π x :=\n(eq_on_domain_of_le h hx).symm\n\nsection piecewise\nvariables (π π') [Π (j : α), decidable (j ∈ π.domain)] {h : disjoint π.domain π'.domain}\n\n/-- Construct a local permutation from two local permutations with disjoint domains. -/\ndef piecewise (h : disjoint π.domain π'.domain) : local_perm α :=\n{ to_fun := π.domain.piecewise π π',\n  inv_fun := π.domain.piecewise π.symm π'.symm,\n  domain := π.domain ∪ π'.domain,\n  to_fun_domain' := begin\n    rintro x (hx | hx),\n    { rw piecewise_eq_on π.domain π π' hx,\n      exact or.inl (π.map_domain hx) },\n    { rw piecewise_eq_on_compl π.domain π π' (disjoint_right.mp h hx),\n      exact or.inr (π'.map_domain hx) },\n  end,\n  inv_fun_domain' := begin\n    rintro x (hx | hx),\n    { rw piecewise_eq_on π.domain π.symm π'.symm hx,\n      exact or.inl (π.symm.map_domain hx) },\n    { rw piecewise_eq_on_compl π.domain π.symm π'.symm (disjoint_right.mp h hx),\n      exact or.inr (π'.symm.map_domain hx) },\n  end,\n  left_inv' := begin\n    rintro x (hx | hx),\n    { rw [piecewise_eq_on π.domain π π' hx,\n        piecewise_eq_on π.domain π.symm π'.symm (π.map_domain hx),\n        π.left_inv hx] },\n    { rw [piecewise_eq_on_compl π.domain π π' (disjoint_right.mp h hx),\n        piecewise_eq_on_compl π.domain π.symm π'.symm (disjoint_right.mp h (π'.map_domain hx)),\n        π'.left_inv hx] },\n  end,\n  right_inv' := begin\n    rintro x (hx | hx),\n    { rw [piecewise_eq_on π.domain π.symm π'.symm hx,\n        piecewise_eq_on π.domain π π' (π.symm.map_domain hx),\n        π.right_inv hx] },\n    { rw [piecewise_eq_on_compl π.domain π.symm π'.symm (disjoint_right.mp h hx),\n        piecewise_eq_on_compl π.domain π π' (disjoint_right.mp h (π'.symm.map_domain hx)),\n        π'.right_inv hx] },\n  end }\n\nvariables {π π' h}\n\n@[simp] lemma piecewise_domain : (piecewise π π' h).domain = π.domain ∪ π'.domain := rfl\nlemma mem_piecewise_domain_left {x : α} (hx : x ∈ π.domain) : x ∈ (piecewise π π' h).domain :=\nmem_union_left _ hx\nlemma mem_piecewise_domain_right {x : α} (hx : x ∈ π'.domain) : x ∈ (piecewise π π' h).domain :=\nmem_union_right _ hx\n\nlemma piecewise_apply_eq_left {x : α} (hx : x ∈ π.domain) : piecewise π π' h x = π x :=\npiecewise_eq_on _ _ _ hx\n\nlemma piecewise_apply_eq_right {x : α} (hx : x ∈ π'.domain) : piecewise π π' h x = π' x :=\npiecewise_eq_on_compl _ _ _ (disjoint_right.mp h hx)\n\nlemma le_piecewise_left : π ≤ piecewise π π' h :=\n⟨subset_union_left _ _, λ x hx, (piecewise_apply_eq_left hx).symm⟩\n\nlemma le_piecewise_right : π' ≤ piecewise π π' h :=\n⟨subset_union_right _ _, λ x hx, (piecewise_apply_eq_right hx).symm⟩\n\nend piecewise\n\nend local_perm\n\nnamespace set\n\n-- All arguments are explicit to avoid missing information in the pretty printer output\n/-- A bijection between two sets `s : set α` and `t : set α` provides a local permutation on `α`. -/\n@[simps {fully_applied := ff}]\nnoncomputable def bij_on.to_local_perm [nonempty α] (f : α → α) (s : set α) (hf : bij_on f s s) :\n  local_perm α :=\n{ to_fun := f,\n  inv_fun := inv_fun_on f s,\n  domain := s,\n  to_fun_domain' := hf.maps_to,\n  inv_fun_domain' := hf.surj_on.maps_to_inv_fun_on,\n  left_inv' := hf.inv_on_inv_fun_on.1,\n  right_inv' := hf.inv_on_inv_fun_on.2 }\n\nend set\n\n/-!\n# `equiv.to_local_perm`\n\nAn `equiv` can be be interpreted give rise to local_perm. We set up simp lemmas to reduce most\nproperties of the local equiv to that of the equiv.\n-/\n\nopen equiv\n\nnamespace equiv.perm\nvariables (π π' : perm α)\n\n@[simp] lemma to_local_perm_one : to_local_perm (equiv.refl α) = local_perm.refl α := rfl\n@[simp] lemma to_local_perm_inv : π⁻¹.to_local_perm = π.to_local_perm.symm := rfl\n@[simp] lemma to_local_perm_mul :\n  (π * π').to_local_perm = π'.to_local_perm.trans π.to_local_perm rfl :=\nlocal_perm.ext (λ x, rfl) (λ x, rfl) rfl\n\n@[simp] lemma to_local_equiv_to_local_perm : π.to_local_perm.to_local_equiv = π.to_local_equiv :=\nrfl\n\nend equiv.perm\n", "meta": {"author": "leanprover-community", "repo": "con-nf", "sha": "f0b66bd73ca5d3bd8b744985242c4c0b5464913f", "save_path": "github-repos/lean/leanprover-community-con-nf", "path": "github-repos/lean/leanprover-community-con-nf/con-nf-f0b66bd73ca5d3bd8b744985242c4c0b5464913f/src/mathlib/logic/equiv/local_perm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.486601825394372}}
{"text": "\n--- All equality are heterogeneously equal to `rfl`.\nlemma eq_irrel {α : Sort _} : ∀ {x y : α} (hxy : x = y), hxy == @rfl α x\n| _ _ rfl := heq.rfl\n\n--- Eliminator of `ite` of predicators.\nlemma ite_pred_iff {α : Sort _} {p : Prop} [decidable p] {P : α → Prop} : ∀ {x y}, (p → P x) ∧ (¬p → P y) ↔ P (ite p x y) :=\n  begin\n    intros x y,\n    split,\n    show _ → P (ite p x y), {\n      intros hxy,\n      by_cases p,\n      rw [if_pos h]; exact hxy.left h,\n      rw [if_neg h]; exact hxy.right h\n    },\n    show P (ite p x y) → _, {\n      intros hP,\n      by_cases p,\n      rw [if_pos h] at hP; exact ⟨(λ _,hP),λ hn, false.elim (hn h)⟩,\n      rw [if_neg h] at hP; exact ⟨false.elim ∘ h, (λ_,hP)⟩\n    }\n  end\n\nlemma whether_of_ite {α : Sort _} {p : Prop} [decidable p] {P : α → Prop} : ∀ {x y}, P (ite p x y) → P x ∨ P y :=\n  begin\n    intros x y hP,\n    by_cases p,\n    rw [if_pos h] at hP; exact or.inl hP,\n    rw [if_neg h] at hP; exact or.inr hP\n  end\n\nattribute [simp]\ndefinition ite_eval_true {p : Prop} [pdec : decidable p] {α : Type*} : p → ∀ (a b : α), ite p a b = a :=\n  begin\n    intros hp a b,\n    delta ite,\n    cases hd: pdec with h hn,\n    case is_false { contradiction },\n    case is_true { dsimp [], refl }\n  end\n\nattribute [simp]\ndefinition ite_eval_false {p : Prop} [pdec : decidable p] {α : Type*} : (¬p) → ∀ (a b: α), ite p a b = b :=\n  begin\n    intros hnp a b,\n    delta ite,\n    cases hd: pdec with hp1 hnp1,\n    case is_false { dsimp [], refl },\n    case is_true { contradiction }\n  end\n\ndefinition xor_congr {p q p' q' : Prop} : (p ↔ p') → (q ↔ q') → (xor p q ↔ xor p' q') :=\n  begin\n    intros hp hq,\n    have hnp : ¬p ↔ ¬p', from not_congr hp,\n    have hnq : ¬q ↔ ¬q', from not_congr hq,\n    apply or_congr; apply and_congr; try { assumption },\n  end\n\ndefinition xor_self (p : Prop) : xor p p ↔ false :=\n  begin\n    split; intros h; try { contradiction },\n    apply or.elim h; try { exact (and_not_self p).mp }\n  end\n\ndefinition xor_comm (p q : Prop) : xor p q ↔ xor q p :=\n  begin\n    dunfold xor,\n    exact or.comm,\n  end\n\ndefinition false_xor (p : Prop) : xor false p ↔ p :=\n  begin\n    split,\n    show xor false p → p, {\n      dunfold xor; intro h; apply or.elim h,\n      exact (false.elim ∘ and.left),\n      exact and.left\n    },\n    show p → xor false p, {\n      dunfold xor; intro h,\n      right,\n      exact ⟨h, false.elim⟩\n    }\n  end\n\ndefinition xor_false (p : Prop) : xor p false ↔ p :=\n  by calc\n    xor p false\n        ↔ xor false p : xor_comm p false\n    ... ↔ p : false_xor p\n\nlemma not_or_distrib {p q : Prop} : ¬(p∨q) ↔ (¬p)∧(¬q) :=\n  begin\n    constructor,\n    show ¬(p∨ q) → (¬p)∧(¬q), {\n      intros hpq,\n      split,\n      show ¬p, { intros hp, have : p∨ q, by left; assumption, contradiction },\n      show ¬q, { intros hq, have : p∨ q, by right; assumption, contradiction },\n    },\n    show (¬p)∧(¬q) → ¬(p∨ q), {\n      intros hnpq hpq,\n      exact or.elim hpq hnpq.left hnpq.right\n    },\n  end\n\nlemma and_iff_left_of_imp {p q : Prop} : (p → q) → (p ∧ q ↔ p) :=\n  λ hpq, iff.intro and.left (λ hp, ⟨hp,hpq hp⟩)\n\nlemma and_iff_right_of_imp {p q : Prop} : (q → p) → (p ∧ q ↔ q) :=\n  λ hqp, iff.intro and.right (λ hq, ⟨hqp hq, hq⟩)\n\nlemma or_disproof_left {p q : Prop} (hnp : ¬p) : (p ∨ q) ↔ q :=\n  iff.intro (or.rec (by intro; contradiction) id) or.inr\n\nlemma or_disproof_right {p q : Prop} (hnp : ¬p) : (q∨ p) ↔ q :=\n  iff.intro (or.rec id (by intro; contradiction)) or.inl\n\nlemma or_and_distrib {p q r : Prop} : (p ∨ q) ∧ r ↔ (p ∧ r) ∨ (q ∧ r) :=\n{\n  mp :=\n    λ hpqr,\n      hpqr.left.elim\n        (λ hp, or.inl ⟨hp,hpqr.right⟩)\n        (λ hq, or.inr ⟨hq,hpqr.right⟩),\n  mpr :=\n    λ hprqr,\n      hprqr.elim\n        (λ hpr, ⟨or.inl hpr.left, hpr.right⟩)\n        (λ hqr, ⟨or.inr hqr.left, hqr.right⟩)\n}\n\n--- The equality on Σ-type from equality and heterogeneous equality.\nlemma sigma_eq_heq {α : Sort _} {β : α → Sort _} : ∀ {x y : sigma β}, x.fst = y.fst → x.snd == y.snd → x = y\n| ⟨x,hx⟩ ⟨y,hy⟩ rfl heq.rfl := rfl\n\n--- Variant of `funext` with heterogeneous dependent domain.\nlemma funext_hdom {α : Sort _} {β : α → Sort _} {γ : Sort _} : ∀ {a₁ a₂ : α} {f : β a₁ → γ} {g : β a₂ → γ}, a₁ = a₂ → (∀ (x : β a₁) (y : β a₂), x == y → f x = g y) → f == g\n| _ _ f g rfl hfg := heq_of_eq $ funext (λ x, hfg x x heq.rfl)\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/logic/misc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.4866018252509765}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\n! This file was ported from Lean 3 source module algebra.free\n! leanprover-community/mathlib commit 6d0adfa76594f304b4650d098273d4366edeb61b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Hom.Group\nimport Mathlib.Algebra.Hom.Equiv.Basic\nimport Mathlib.Control.Applicative\nimport Mathlib.Control.Traversable.Basic\nimport Mathlib.Logic.Equiv.Defs\nimport Mathlib.Data.List.Basic\n\n/-!\n# Free constructions\n\n## Main definitions\n\n* `FreeMagma α`: free magma (structure with binary operation without any axioms) over alphabet `α`,\n  defined inductively, with traversable instance and decidable equality.\n* `MagmaAssocQuotient α`: quotient of a magma `α` by the associativity equivalence relation.\n* `FreeSemigroup α`: free semigroup over alphabet `α`, defined as a structure with two fields\n  `head : α` and `tail : list α` (i.e. nonempty lists), with traversable instance and decidable\n  equality.\n* `FreeMagmaAssocQuotientEquiv α`: isomorphism between `MagmaAssocQuotient (FreeMagma α)` and\n  `FreeSemigroup α`.\n* `FreeMagma.lift`: the universal property of the free magma, expressing its adjointness.\n-/\n\nuniverse u v l\n\n/-- Free nonabelian additive magma over a given alphabet. -/\ninductive FreeAddMagma (α : Type u) : Type u\n  | of : α → FreeAddMagma α\n  | add : FreeAddMagma α → FreeAddMagma α → FreeAddMagma α\n  deriving DecidableEq\n#align free_add_magma FreeAddMagma\n\n/-- Free magma over a given alphabet. -/\n@[to_additive]\ninductive FreeMagma (α : Type u) : Type u\n  | of : α → FreeMagma α\n  | mul : FreeMagma α → FreeMagma α → FreeMagma α\n  deriving DecidableEq\n#align free_magma FreeMagma\n\nnamespace FreeMagma\n\nvariable {α : Type u}\n\n@[to_additive]\ninstance [Inhabited α] : Inhabited (FreeMagma α) := ⟨of default⟩\n\n@[to_additive]\ninstance : Mul (FreeMagma α) := ⟨FreeMagma.mul⟩\n\n-- Porting note: invalid attribute 'match_pattern', declaration is in an imported module\n-- attribute [match_pattern] Mul.mul\n\n@[to_additive (attr := simp)]\ntheorem mul_eq (x y : FreeMagma α) : mul x y = x * y := rfl\n#align free_magma.mul_eq FreeMagma.mul_eq\n\n/- Porting note: these lemmas are autogenerated by the inductive definition and due to\nthe existence of mul_eq not in simp normal form -/\nattribute [nolint simpNF] FreeAddMagma.add.sizeOf_spec\nattribute [nolint simpNF] FreeMagma.mul.sizeOf_spec\nattribute [nolint simpNF] FreeAddMagma.add.injEq\nattribute [nolint simpNF] FreeMagma.mul.injEq\n\n/-- Recursor for `FreeMagma` using `x * y` instead of `FreeMagma.mul x y`. -/\n@[to_additive (attr := elab_as_elim) \"Recursor for `FreeAddMagma` using `x + y` instead of\n`FreeAddMagma.add x y`.\"]\n-- Porting note: added noncomputable\nnoncomputable def recOnMul {C : FreeMagma α → Sort l} (x) (ih1 : ∀ x, C (of x))\n    (ih2 : ∀ x y, C x → C y → C (x * y)) : C x :=\n  FreeMagma.recOn x ih1 ih2\n#align free_magma.rec_on_mul FreeMagma.recOnMul\n\n@[to_additive (attr := ext 1100)]\ntheorem hom_ext {β : Type v} [Mul β] {f g : FreeMagma α →ₙ* β} (h : f ∘ of = g ∘ of) : f = g :=\n  (FunLike.ext _ _) fun x ↦ recOnMul x (congr_fun h) <| by intros ; simp only [map_mul, *]\n#align free_magma.hom_ext FreeMagma.hom_ext\n\nend FreeMagma\n\n/-- Lifts a function `α → β` to a magma homomorphism `FreeMagma α → β` given a magma `β`. -/\ndef FreeMagma.liftAux {α : Type u} {β : Type v} [Mul β] (f : α → β) : FreeMagma α → β\n  | FreeMagma.of x => f x\n  | x * y => liftAux f x * liftAux f y\n#align free_magma.lift_aux FreeMagma.liftAux\n\n/-- Lifts a function `α → β` to an additive magma homomorphism `FreeAddMagma α → β` given\nan additive magma `β`. -/\ndef FreeAddMagma.liftAux {α : Type u} {β : Type v} [Add β] (f : α → β) : FreeAddMagma α → β\n  | FreeAddMagma.of x => f x\n  | x + y => liftAux f x + liftAux f y\n#align free_add_magma.lift_aux FreeAddMagma.liftAux\n\nattribute [to_additive existing] FreeMagma.liftAux\n\nnamespace FreeMagma\n\nsection lift\n\nvariable {α : Type u} {β : Type v} [Mul β] (f : α → β)\n\n/-- The universal property of the free magma expressing its adjointness. -/\n@[to_additive (attr := simps symm_apply)\n\"The universal property of the free additive magma expressing its adjointness.\"]\ndef lift : (α → β) ≃ (FreeMagma α →ₙ* β) where\n  toFun f :=\n  { toFun := liftAux f\n    map_mul' := fun x y ↦ rfl }\n  invFun F := F ∘ of\n  left_inv f := by rfl\n-- Porting note: replaced ext by FreeMagma.hom_ext\n  right_inv F := FreeMagma.hom_ext (rfl)\n#align free_magma.lift FreeMagma.lift\n\n@[to_additive (attr := simp)]\ntheorem lift_of (x) : lift f (of x) = f x := rfl\n#align free_magma.lift_of FreeMagma.lift_of\n\n@[to_additive (attr := simp)]\ntheorem lift_comp_of : lift f ∘ of = f := rfl\n#align free_magma.lift_comp_of FreeMagma.lift_comp_of\n\n@[to_additive (attr := simp)]\ntheorem lift_comp_of' (f : FreeMagma α →ₙ* β) : lift (f ∘ of) = f := lift.apply_symm_apply f\n#align free_magma.lift_comp_of' FreeMagma.lift_comp_of'\n\nend lift\n\nsection Map\n\nvariable {α : Type u} {β : Type v} (f : α → β)\n\n/-- The unique magma homomorphism `FreeMagma α →ₙ* FreeMagma β` that sends\neach `of x` to `of (f x)`. -/\n@[to_additive \"The unique additive magma homomorphism `FreeAddMagma α → FreeAddMagma β` that sends\neach `of x` to `of (f x)`.\"]\ndef map (f : α → β) : FreeMagma α →ₙ* FreeMagma β := lift (of ∘ f)\n#align free_magma.map FreeMagma.map\n\n@[to_additive (attr := simp)]\ntheorem map_of (x) : map f (of x) = of (f x) := rfl\n#align free_magma.map_of FreeMagma.map_of\n\nend Map\n\nsection Category\n\nvariable {α β : Type u}\n\n@[to_additive]\ninstance : Monad FreeMagma where\n  pure := of\n  bind x f := lift f x\n\n/-- Recursor on `FreeMagma` using `pure` instead of `of`. -/\n@[to_additive (attr := elab_as_elim) \"Recursor on `FreeAddMagma` using `pure` instead of `of`.\"]\n-- Porting note: added noncomputable\nprotected noncomputable def recOnPure {C : FreeMagma α → Sort l} (x) (ih1 : ∀ x, C (pure x))\n    (ih2 : ∀ x y, C x → C y → C (x * y)) : C x :=\n  FreeMagma.recOnMul x ih1 ih2\n#align free_magma.rec_on_pure FreeMagma.recOnPure\n\n-- Porting note: dsimp can not prove this\n@[to_additive (attr := simp, nolint simpNF)]\ntheorem map_pure (f : α → β) (x) : (f <$> pure x : FreeMagma β) = pure (f x) := rfl\n#align free_magma.map_pure FreeMagma.map_pure\n\n@[to_additive (attr := simp)]\ntheorem map_mul' (f : α → β) (x y : FreeMagma α) : f <$> (x * y) = f <$> x * f <$> y := rfl\n#align free_magma.map_mul' FreeMagma.map_mul'\n\n-- Porting note: dsimp can not prove this\n@[to_additive (attr := simp, nolint simpNF)]\ntheorem pure_bind (f : α → FreeMagma β) (x) : pure x >>= f = f x := rfl\n#align free_magma.pure_bind FreeMagma.pure_bind\n\n@[to_additive (attr := simp)]\ntheorem mul_bind (f : α → FreeMagma β) (x y : FreeMagma α) : x * y >>= f = (x >>= f) * (y >>= f) :=\n  rfl\n#align free_magma.mul_bind FreeMagma.mul_bind\n\n@[to_additive (attr := simp)]\ntheorem pure_seq {α β : Type u} {f : α → β} {x : FreeMagma α} : pure f <*> x = f <$> x := rfl\n#align free_magma.pure_seq FreeMagma.pure_seq\n\n@[to_additive (attr := simp)]\ntheorem mul_seq {α β : Type u} {f g : FreeMagma (α → β)} {x : FreeMagma α} :\n    f * g <*> x = (f <*> x) * (g <*> x) := rfl\n#align free_magma.mul_seq FreeMagma.mul_seq\n\n@[to_additive]\ninstance : LawfulMonad FreeMagma.{u} := LawfulMonad.mk'\n  (pure_bind := fun f x ↦ rfl)\n  (bind_assoc := fun x f g ↦ FreeMagma.recOnPure x (fun x ↦ rfl) fun x y ih1 ih2 ↦ by\n    rw [mul_bind, mul_bind, mul_bind, ih1, ih2])\n  (id_map := fun x ↦ FreeMagma.recOnPure x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by\n    rw [map_mul', ih1, ih2])\n\nend Category\n\nend FreeMagma\n\n/-- `FreeMagma` is traversable. -/\nprotected def FreeMagma.traverse {m : Type u → Type u} [Applicative m] {α β : Type u}\n    (F : α → m β) : FreeMagma α → m (FreeMagma β)\n  | FreeMagma.of x => FreeMagma.of <$> F x\n  | x * y => (· * ·) <$> x.traverse F <*> y.traverse F\n#align free_magma.traverse FreeMagma.traverse\n\n/-- `FreeAddMagma` is traversable. -/\nprotected def FreeAddMagma.traverse {m : Type u → Type u} [Applicative m] {α β : Type u}\n    (F : α → m β) : FreeAddMagma α → m (FreeAddMagma β)\n  | FreeAddMagma.of x => FreeAddMagma.of <$> F x\n  | x + y => (· + ·) <$> x.traverse F <*> y.traverse F\n#align free_add_magma.traverse FreeAddMagma.traverse\n\nattribute [to_additive existing] FreeMagma.traverse\n\nnamespace FreeMagma\n\nvariable {α : Type u}\n\nsection Category\n\nvariable {β : Type u}\n\n@[to_additive]\ninstance : Traversable FreeMagma := ⟨@FreeMagma.traverse⟩\n\nvariable {m : Type u → Type u} [Applicative m] (F : α → m β)\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure (x) : traverse F (pure x : FreeMagma α) = pure <$> F x := rfl\n#align free_magma.traverse_pure FreeMagma.traverse_pure\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure' : traverse F ∘ pure = fun x ↦ (pure <$> F x : m (FreeMagma β)) := rfl\n#align free_magma.traverse_pure' FreeMagma.traverse_pure'\n\n@[to_additive (attr := simp)]\ntheorem traverse_mul (x y : FreeMagma α) :\n    traverse F (x * y) = (· * ·) <$> traverse F x <*> traverse F y := rfl\n#align free_magma.traverse_mul FreeMagma.traverse_mul\n\n@[to_additive (attr := simp)]\ntheorem traverse_mul' :\n    Function.comp (traverse F) ∘ @Mul.mul (FreeMagma α) _ = fun x y ↦\n      (· * ·) <$> traverse F x <*> traverse F y := rfl\n#align free_magma.traverse_mul' FreeMagma.traverse_mul'\n\n@[to_additive (attr := simp)]\ntheorem traverse_eq (x) : FreeMagma.traverse F x = traverse F x := rfl\n#align free_magma.traverse_eq FreeMagma.traverse_eq\n\n-- Porting note: dsimp can not prove this\n@[to_additive (attr := simp, nolint simpNF)]\ntheorem mul_map_seq (x y : FreeMagma α) :\n    ((· * ·) <$> x <*> y : Id (FreeMagma α)) = (x * y : FreeMagma α) := rfl\n#align free_magma.mul_map_seq FreeMagma.mul_map_seq\n\n@[to_additive]\ninstance : IsLawfulTraversable FreeMagma.{u} :=\n  { instLawfulMonadFreeMagmaInstMonadFreeMagma with\n    id_traverse := fun x ↦\n      FreeMagma.recOnPure x (fun x ↦ rfl) fun x y ih1 ih2 ↦ by\n        rw [traverse_mul, ih1, ih2, mul_map_seq]\n    comp_traverse := fun f g x ↦\n      FreeMagma.recOnPure x\n        (fun x ↦ by simp only [(. ∘ .), traverse_pure, traverse_pure', functor_norm])\n        (fun x y ih1 ih2 ↦ by\n          rw [traverse_mul, ih1, ih2, traverse_mul];\n          simp [Functor.Comp.map_mk, Functor.map_map, (. ∘ .), Comp.seq_mk, seq_map_assoc,\n            map_seq, traverse_mul])\n    naturality := fun η α β f x ↦\n      FreeMagma.recOnPure x\n        (fun x ↦ by simp only [traverse_pure, functor_norm, Function.comp_apply])\n        (fun x y ih1 ih2 ↦ by simp only [traverse_mul, functor_norm, ih1, ih2])\n    traverse_eq_map_id := fun f x ↦\n      FreeMagma.recOnPure x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by\n        rw [traverse_mul, ih1, ih2, map_mul', mul_map_seq]; rfl }\n\nend Category\n\nend FreeMagma\n\n-- Porting note: changed String to Lean.Format\n/-- Representation of an element of a free magma. -/\nprotected def FreeMagma.repr {α : Type u} [Repr α] : FreeMagma α → Lean.Format\n  | FreeMagma.of x => repr x\n  | x * y => \"( \" ++ x.repr ++ \" * \" ++ y.repr ++ \" )\"\n#align free_magma.repr FreeMagma.repr\n\n/-- Representation of an element of a free additive magma. -/\nprotected def FreeAddMagma.repr {α : Type u} [Repr α] : FreeAddMagma α → Lean.Format\n  | FreeAddMagma.of x => repr x\n  | x + y => \"( \" ++ x.repr ++ \" + \" ++ y.repr ++ \" )\"\n#align free_add_magma.repr FreeAddMagma.repr\n\nattribute [to_additive existing] FreeMagma.repr\n\n@[to_additive]\ninstance {α : Type u} [Repr α] : Repr (FreeMagma α) := ⟨fun o _ => FreeMagma.repr o⟩\n\n/-- Length of an element of a free magma. -/\ndef FreeMagma.length {α : Type u} : FreeMagma α → ℕ\n  | FreeMagma.of _x => 1\n  | x * y => x.length + y.length\n#align free_magma.length FreeMagma.length\n\n/-- Length of an element of a free additive magma. -/\ndef FreeAddMagma.length {α : Type u} : FreeAddMagma α → ℕ\n  | FreeAddMagma.of _x => 1\n  | x + y => x.length + y.length\n#align free_add_magma.length FreeAddMagma.length\n\nattribute [to_additive existing (attr := simp)] FreeMagma.length\n\n/-- Associativity relations for an additive magma. -/\ninductive AddMagma.AssocRel (α : Type u) [Add α] : α → α → Prop\n  | intro : ∀ x y z, AddMagma.AssocRel α (x + y + z) (x + (y + z))\n  | left : ∀ w x y z, AddMagma.AssocRel α (w + (x + y + z)) (w + (x + (y + z)))\n#align add_magma.assoc_rel AddMagma.AssocRel\n\n/-- Associativity relations for a magma. -/\n@[to_additive AddMagma.AssocRel \"Associativity relations for an additive magma.\"]\ninductive Magma.AssocRel (α : Type u) [Mul α] : α → α → Prop\n  | intro : ∀ x y z, Magma.AssocRel α (x * y * z) (x * (y * z))\n  | left : ∀ w x y z, Magma.AssocRel α (w * (x * y * z)) (w * (x * (y * z)))\n#align magma.assoc_rel Magma.AssocRel\n\nnamespace Magma\n\n/-- Semigroup quotient of a magma. -/\n@[to_additive AddMagma.FreeAddSemigroup \"Additive semigroup quotient of an additive magma.\"]\ndef AssocQuotient (α : Type u) [Mul α] : Type u :=\n  Quot <| AssocRel α\n#align magma.assoc_quotient Magma.AssocQuotient\n\nnamespace AssocQuotient\n\nvariable {α : Type u} [Mul α]\n\n@[to_additive]\ntheorem quot_mk_assoc (x y z : α) : Quot.mk (AssocRel α) (x * y * z) = Quot.mk _ (x * (y * z)) :=\n  Quot.sound (AssocRel.intro _ _ _)\n#align magma.assoc_quotient.quot_mk_assoc Magma.AssocQuotient.quot_mk_assoc\n\n@[to_additive]\ntheorem quot_mk_assoc_left (x y z w : α) :\n    Quot.mk (AssocRel α) (x * (y * z * w)) = Quot.mk _ (x * (y * (z * w))) :=\n  Quot.sound (AssocRel.left _ _ _ _)\n#align magma.assoc_quotient.quot_mk_assoc_left Magma.AssocQuotient.quot_mk_assoc_left\n\n@[to_additive]\ninstance : Semigroup (AssocQuotient α) where\n  mul x y := by\n    refine' Quot.liftOn₂ x y (fun x y ↦ Quot.mk _ (x * y)) _ _\n    · rintro a b₁ b₂ (⟨c, d, e⟩ | ⟨c, d, e, f⟩) <;> simp only\n      · exact quot_mk_assoc_left _ _ _ _\n      · rw [← quot_mk_assoc, quot_mk_assoc_left, quot_mk_assoc]\n    · rintro a₁ a₂ b (⟨c, d, e⟩ | ⟨c, d, e, f⟩) <;> simp only\n      · simp only [quot_mk_assoc, quot_mk_assoc_left]\n      · rw [quot_mk_assoc, quot_mk_assoc, quot_mk_assoc_left, quot_mk_assoc_left,\n          quot_mk_assoc_left, ← quot_mk_assoc c d, ← quot_mk_assoc c d, quot_mk_assoc_left]\n  mul_assoc x y z :=\n    Quot.induction_on₃ x y z fun a b c ↦ quot_mk_assoc a b c\n\n/-- Embedding from magma to its free semigroup. -/\n@[to_additive \"Embedding from additive magma to its free additive semigroup.\"]\ndef of : α →ₙ* AssocQuotient α := ⟨Quot.mk _, fun _x _y ↦ rfl⟩\n#align magma.assoc_quotient.of Magma.AssocQuotient.of\n\n@[to_additive]\ninstance [Inhabited α] : Inhabited (AssocQuotient α) := ⟨of default⟩\n\n@[to_additive (attr := elab_as_elim)]\nprotected theorem induction_on {C : AssocQuotient α → Prop} (x : AssocQuotient α)\n    (ih : ∀ x, C (of x)) : C x := Quot.induction_on x ih\n#align magma.assoc_quotient.induction_on Magma.AssocQuotient.induction_on\n\nsection lift\n\nvariable {β : Type v} [Semigroup β] (f : α →ₙ* β)\n\n@[to_additive (attr := ext 1100)]\ntheorem hom_ext {f g : AssocQuotient α →ₙ* β} (h : f.comp of = g.comp of) : f = g :=\n  (FunLike.ext _ _) fun x => AssocQuotient.induction_on x <| FunLike.congr_fun h\n#align magma.assoc_quotient.hom_ext Magma.AssocQuotient.hom_ext\n\n/-- Lifts a magma homomorphism `α → β` to a semigroup homomorphism `Magma.AssocQuotient α → β`\ngiven a semigroup `β`. -/\n@[to_additive (attr := simps symm_apply) \"Lifts an additive magma homomorphism `α → β` to an\nadditive semigroup homomorphism `AddMagma.AssocQuotient α → β` given an additive semigroup `β`.\"]\ndef lift : (α →ₙ* β) ≃ (AssocQuotient α →ₙ* β) where\n  toFun f :=\n  { toFun := fun x ↦\n      Quot.liftOn x f <| by rintro a b (⟨c, d, e⟩ | ⟨c, d, e, f⟩) <;> simp only [map_mul, mul_assoc]\n    map_mul' := fun x y ↦ Quot.induction_on₂ x y (map_mul f) }\n  invFun f := f.comp of\n  left_inv f := (FunLike.ext _ _) fun x ↦ rfl\n  right_inv f := hom_ext <| (FunLike.ext _ _) fun x ↦ rfl\n#align magma.assoc_quotient.lift Magma.AssocQuotient.lift\n\n@[to_additive (attr := simp)]\ntheorem lift_of (x : α) : lift f (of x) = f x := rfl\n#align magma.assoc_quotient.lift_of Magma.AssocQuotient.lift_of\n\n@[to_additive (attr := simp)]\ntheorem lift_comp_of : (lift f).comp of = f := lift.symm_apply_apply f\n#align magma.assoc_quotient.lift_comp_of Magma.AssocQuotient.lift_comp_of\n\n@[to_additive (attr := simp)]\ntheorem lift_comp_of' (f : AssocQuotient α →ₙ* β) : lift (f.comp of) = f := lift.apply_symm_apply f\n#align magma.assoc_quotient.lift_comp_of' Magma.AssocQuotient.lift_comp_of'\n\nend lift\n\nvariable {β : Type v} [Mul β] (f : α →ₙ* β)\n\n/-- From a magma homomorphism `α →ₙ* β` to a semigroup homomorphism\n`Magma.AssocQuotient α →ₙ* Magma.AssocQuotient β`. -/\n@[to_additive \"From an additive magma homomorphism `α → β` to an additive semigroup homomorphism\n`AddMagma.AssocQuotient α → AddMagma.AssocQuotient β`.\"]\ndef map : AssocQuotient α →ₙ* AssocQuotient β := lift (of.comp f)\n#align magma.assoc_quotient.map Magma.AssocQuotient.map\n\n@[to_additive (attr := simp)]\ntheorem map_of (x) : map f (of x) = of (f x) := rfl\n#align magma.assoc_quotient.map_of Magma.AssocQuotient.map_of\n\nend AssocQuotient\n\nend Magma\n\n/-- Free additive semigroup over a given alphabet. -/\nstructure FreeAddSemigroup (α : Type u) where\n/-- The head of the element -/\n  head : α\n/-- The tail of the element -/\n  tail : List α\n#align free_add_semigroup FreeAddSemigroup\n\n/-- Free semigroup over a given alphabet. -/\n@[to_additive (attr := ext)]\nstructure FreeSemigroup (α : Type u) where\n/-- The head of the element -/\n  head : α\n/-- The tail of the element -/\n  tail : List α\n#align free_semigroup FreeSemigroup\n\nnamespace FreeSemigroup\n\nvariable {α : Type u}\n\n@[to_additive]\ninstance : Semigroup (FreeSemigroup α) where\n  mul L1 L2 := ⟨L1.1, L1.2 ++ L2.1 :: L2.2⟩\n-- Porting note: replaced ext by FreeSemigroup.ext\n  mul_assoc _L1 _L2 _L3 := FreeSemigroup.ext _ _ rfl <| List.append_assoc _ _ _\n\n@[to_additive (attr := simp)]\ntheorem head_mul (x y : FreeSemigroup α) : (x * y).1 = x.1 := rfl\n#align free_semigroup.head_mul FreeSemigroup.head_mul\n\n@[to_additive (attr := simp)]\ntheorem tail_mul (x y : FreeSemigroup α) : (x * y).2 = x.2 ++ y.1 :: y.2 := rfl\n#align free_semigroup.tail_mul FreeSemigroup.tail_mul\n\n@[to_additive (attr := simp)]\ntheorem mk_mul_mk (x y : α) (L1 L2 : List α) : mk x L1 * mk y L2 = mk x (L1 ++ y :: L2) := rfl\n#align free_semigroup.mk_mul_mk FreeSemigroup.mk_mul_mk\n\n/-- The embedding `α → FreeSemigroup α`. -/\n@[to_additive (attr := simps) \"The embedding `α → free_add_semigroup α`.\"]\ndef of (x : α) : FreeSemigroup α := ⟨x, []⟩\n#align free_semigroup.of FreeSemigroup.of\n\n/-- Length of an element of free semigroup. -/\n@[to_additive \"Length of an element of free additive semigroup\"]\ndef length (x : FreeSemigroup α) : ℕ := x.tail.length + 1\n#align free_semigroup.length FreeSemigroup.length\n\n@[to_additive (attr := simp)]\ntheorem length_mul (x y : FreeSemigroup α) : (x * y).length = x.length + y.length := by\n  simp [length, ← add_assoc, add_right_comm, List.length, List.length_append]\n#align free_semigroup.length_mul FreeSemigroup.length_mul\n\n@[to_additive (attr := simp)]\ntheorem length_of (x : α) : (of x).length = 1 := rfl\n#align free_semigroup.length_of FreeSemigroup.length_of\n\n@[to_additive]\ninstance [Inhabited α] : Inhabited (FreeSemigroup α) := ⟨of default⟩\n\n/-- Recursor for free semigroup using `of` and `*`. -/\n@[to_additive (attr := elab_as_elim) \"Recursor for free additive semigroup using `of` and `+`.\"]\n-- Porting note: added noncomputable\nprotected noncomputable def recOnMul {C : FreeSemigroup α → Sort l} (x) (ih1 : ∀ x, C (of x))\n    (ih2 : ∀ x y, C (of x) → C y → C (of x * y)) : C x :=\n      FreeSemigroup.recOn x fun f s ↦\n      List.recOn s ih1 (fun hd tl ih f ↦ ih2 f ⟨hd, tl⟩ (ih1 f) (ih hd)) f\n#align free_semigroup.rec_on_mul FreeSemigroup.recOnMul\n\n@[to_additive (attr := ext 1100)]\ntheorem hom_ext {β : Type v} [Mul β] {f g : FreeSemigroup α →ₙ* β} (h : f ∘ of = g ∘ of) : f = g :=\n  (FunLike.ext _ _) fun x ↦\n    FreeSemigroup.recOnMul x (congr_fun h) fun x y hx hy ↦ by simp only [map_mul, *]\n#align free_semigroup.hom_ext FreeSemigroup.hom_ext\n\nsection lift\n\nvariable {β : Type v} [Semigroup β] (f : α → β)\n\n/-- Lifts a function `α → β` to a semigroup homomorphism `FreeSemigroup α → β` given\na semigroup `β`. -/\n@[to_additive (attr := simps symm_apply) \"Lifts a function `α → β` to an additive semigroup\nhomomorphism `FreeAddSemigroup α → β` given an additive semigroup `β`.\"]\ndef lift : (α → β) ≃ (FreeSemigroup α →ₙ* β) where\n  toFun f :=\n    { toFun := fun x ↦ x.2.foldl (fun a b ↦ a * f b) (f x.1)\n      map_mul' := fun x y ↦ by\n        simp only [head_mul, tail_mul, ← List.foldl_map f, List.foldl_append, List.foldl_cons,\n          List.foldl_assoc] }\n  invFun f := f ∘ of\n  left_inv f := rfl\n  right_inv f := hom_ext rfl\n#align free_semigroup.lift FreeSemigroup.lift\n\n@[to_additive (attr := simp)]\ntheorem lift_of (x : α) : lift f (of x) = f x := rfl\n#align free_semigroup.lift_of FreeSemigroup.lift_of\n\n@[to_additive (attr := simp)]\ntheorem lift_comp_of : lift f ∘ of = f := rfl\n#align free_semigroup.lift_comp_of FreeSemigroup.lift_comp_of\n\n@[to_additive (attr := simp)]\ntheorem lift_comp_of' (f : FreeSemigroup α →ₙ* β) : lift (f ∘ of) = f := hom_ext rfl\n#align free_semigroup.lift_comp_of' FreeSemigroup.lift_comp_of'\n\n@[to_additive]\ntheorem lift_of_mul (x y) : lift f (of x * y) = f x * lift f y := by rw [map_mul, lift_of]\n#align free_semigroup.lift_of_mul FreeSemigroup.lift_of_mul\n\nend lift\n\nsection Map\n\nvariable {β : Type v} (f : α → β)\n\n/-- The unique semigroup homomorphism that sends `of x` to `of (f x)`. -/\n@[to_additive \"The unique additive semigroup homomorphism that sends `of x` to `of (f x)`.\"]\ndef map : FreeSemigroup α →ₙ* FreeSemigroup β :=\n  lift <| of ∘ f\n#align free_semigroup.map FreeSemigroup.map\n\n@[to_additive (attr := simp)]\ntheorem map_of (x) : map f (of x) = of (f x) := rfl\n#align free_semigroup.map_of FreeSemigroup.map_of\n\n@[to_additive (attr := simp)]\ntheorem length_map (x) : (map f x).length = x.length :=\n  FreeSemigroup.recOnMul x (fun x ↦ rfl) (fun x y hx hy ↦ by simp only [map_mul, length_mul, *])\n#align free_semigroup.length_map FreeSemigroup.length_map\n\nend Map\n\nsection Category\n\nvariable {β : Type u}\n\n@[to_additive]\ninstance : Monad FreeSemigroup where\n  pure := of\n  bind x f := lift f x\n\n/-- Recursor that uses `pure` instead of `of`. -/\n@[to_additive (attr := elab_as_elim) \"Recursor that uses `pure` instead of `of`.\"]\n-- Porting note: added noncomputable\nnoncomputable def recOnPure {C : FreeSemigroup α → Sort l} (x) (ih1 : ∀ x, C (pure x))\n    (ih2 : ∀ x y, C (pure x) → C y → C (pure x * y)) : C x :=\n  FreeSemigroup.recOnMul x ih1 ih2\n#align free_semigroup.rec_on_pure FreeSemigroup.recOnPure\n\n-- Porting note: dsimp can not prove this\n@[to_additive (attr := simp, nolint simpNF)]\ntheorem map_pure (f : α → β) (x) : (f <$> pure x : FreeSemigroup β) = pure (f x) := rfl\n#align free_semigroup.map_pure FreeSemigroup.map_pure\n\n@[to_additive (attr := simp)]\ntheorem map_mul' (f : α → β) (x y : FreeSemigroup α) : f <$> (x * y) = f <$> x * f <$> y :=\n  map_mul (map f) _ _\n#align free_semigroup.map_mul' FreeSemigroup.map_mul'\n\n-- Porting note: dsimp can not prove this\n@[to_additive (attr := simp, nolint simpNF)]\ntheorem pure_bind (f : α → FreeSemigroup β) (x) : pure x >>= f = f x := rfl\n#align free_semigroup.pure_bind FreeSemigroup.pure_bind\n\n@[to_additive (attr := simp)]\ntheorem mul_bind (f : α → FreeSemigroup β) (x y : FreeSemigroup α) :\n    x * y >>= f = (x >>= f) * (y >>= f) := map_mul (lift f) _ _\n#align free_semigroup.mul_bind FreeSemigroup.mul_bind\n\n@[to_additive (attr := simp)]\ntheorem pure_seq {f : α → β} {x : FreeSemigroup α} : pure f <*> x = f <$> x := rfl\n#align free_semigroup.pure_seq FreeSemigroup.pure_seq\n\n@[to_additive (attr := simp)]\ntheorem mul_seq {f g : FreeSemigroup (α → β)} {x : FreeSemigroup α} :\n    f * g <*> x = (f <*> x) * (g <*> x) := mul_bind _ _ _\n#align free_semigroup.mul_seq FreeSemigroup.mul_seq\n\n@[to_additive]\ninstance : LawfulMonad FreeSemigroup.{u} := LawfulMonad.mk'\n  (pure_bind := fun _ _ ↦ rfl)\n  (bind_assoc := fun x g f ↦\n    recOnPure x (fun x ↦ rfl) fun x y ih1 ih2 ↦ by rw [mul_bind, mul_bind, mul_bind, ih1, ih2])\n  (id_map := fun x ↦ recOnPure x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by rw [map_mul', ih1, ih2])\n\n/-- `FreeSemigroup` is traversable. -/\n@[to_additive \"`FreeAddSemigroup` is traversable.\"]\n-- Porting note: added noncomputable\nprotected noncomputable def traverse {m : Type u → Type u} [Applicative m] {α β : Type u}\n    (F : α → m β) (x : FreeSemigroup α) : m (FreeSemigroup β) :=\n  recOnPure x (fun x ↦ pure <$> F x) fun _x _y ihx ihy ↦ (· * ·) <$> ihx <*> ihy\n#align free_semigroup.traverse FreeSemigroup.traverse\n\n@[to_additive]\n-- Porting note: added noncomputable\nnoncomputable instance : Traversable FreeSemigroup := ⟨@FreeSemigroup.traverse⟩\n\nvariable {m : Type u → Type u} [Applicative m] (F : α → m β)\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure (x) : traverse F (pure x : FreeSemigroup α) = pure <$> F x := rfl\n#align free_semigroup.traverse_pure FreeSemigroup.traverse_pure\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure' : traverse F ∘ pure = fun x ↦ (pure <$> F x : m (FreeSemigroup β)) := rfl\n#align free_semigroup.traverse_pure' FreeSemigroup.traverse_pure'\n\nsection\n\nvariable [LawfulApplicative m]\n\n@[to_additive (attr := simp)]\ntheorem traverse_mul (x y : FreeSemigroup α) :\n    traverse F (x * y) = (· * ·) <$> traverse F x <*> traverse F y :=\n  let ⟨x, L1⟩ := x\n  let ⟨y, L2⟩ := y\n  List.recOn L1 (fun x ↦ rfl)\n    (fun hd tl ih x ↦ show\n        (· * ·) <$> pure <$> F x <*> traverse F (mk hd tl * mk y L2) =\n          (· * ·) <$> ((· * ·) <$> pure <$> F x <*> traverse F (mk hd tl)) <*> traverse F (mk y L2)\n        by rw [ih] ; simp only [(· ∘ ·), (mul_assoc _ _ _).symm, functor_norm])\n    x\n#align free_semigroup.traverse_mul FreeSemigroup.traverse_mul\n\n@[to_additive (attr := simp)]\ntheorem traverse_mul' :\n    Function.comp (traverse F) ∘ @Mul.mul (FreeSemigroup α) _ = fun x y ↦\n      (· * ·) <$> traverse F x <*> traverse F y := funext fun x ↦ funext fun y ↦ traverse_mul F x y\n#align free_semigroup.traverse_mul' FreeSemigroup.traverse_mul'\n\nend\n\n@[to_additive (attr := simp)]\ntheorem traverse_eq (x) : FreeSemigroup.traverse F x = traverse F x := rfl\n#align free_semigroup.traverse_eq FreeSemigroup.traverse_eq\n\n-- Porting note: dsimp can not prove this\n@[to_additive (attr := simp, nolint simpNF)]\ntheorem mul_map_seq (x y : FreeSemigroup α) :\n    ((· * ·) <$> x <*> y : Id (FreeSemigroup α)) = (x * y : FreeSemigroup α) := rfl\n#align free_semigroup.mul_map_seq FreeSemigroup.mul_map_seq\n\n-- Porting note: Added noncomputable\n@[to_additive]\nnoncomputable instance : IsLawfulTraversable FreeSemigroup.{u} :=\n  { instLawfulMonadFreeSemigroupInstMonadFreeSemigroup with\n    id_traverse := fun x ↦\n      FreeSemigroup.recOnMul x (fun x ↦ rfl) fun x y ih1 ih2 ↦ by\n        rw [traverse_mul, ih1, ih2, mul_map_seq]\n    comp_traverse := fun f g x ↦\n      recOnPure x (fun x ↦ by simp only [traverse_pure, functor_norm, (. ∘ .)])\n        fun x y ih1 ih2 ↦ by (rw [traverse_mul, ih1, ih2,\n          traverse_mul, Functor.Comp.map_mk]; simp only [Function.comp, functor_norm, traverse_mul])\n    naturality := fun η α β f x ↦\n      recOnPure x (fun x ↦ by simp only [traverse_pure, functor_norm, Function.comp])\n          (fun x y ih1 ih2 ↦ by simp only [traverse_mul, functor_norm, ih1, ih2])\n    traverse_eq_map_id := fun f x ↦\n      FreeSemigroup.recOnMul x (fun _ ↦ rfl) fun x y ih1 ih2 ↦ by\n        rw [traverse_mul, ih1, ih2, map_mul', mul_map_seq]; rfl }\n\nend Category\n\n@[to_additive]\ninstance [DecidableEq α] : DecidableEq (FreeSemigroup α) :=\n  fun _ _ ↦ decidable_of_iff' _ (FreeSemigroup.ext_iff _ _)\n\nend FreeSemigroup\n\nnamespace FreeMagma\n\nvariable {α : Type u} {β : Type v}\n\n/-- The canonical multiplicative morphism from `FreeMagma α` to `FreeSemigroup α`. -/\n@[to_additive \"The canonical additive morphism from `FreeAddMagma α` to `FreeAddSemigroup α`.\"]\ndef toFreeSemigroup : FreeMagma α →ₙ* FreeSemigroup α := FreeMagma.lift FreeSemigroup.of\n#align free_magma.to_free_semigroup FreeMagma.toFreeSemigroup\n\n@[to_additive (attr := simp)]\ntheorem toFreeSemigroup_of (x : α) : toFreeSemigroup (of x) = FreeSemigroup.of x := rfl\n#align free_magma.to_free_semigroup_of FreeMagma.toFreeSemigroup_of\n\n@[to_additive (attr := simp)]\ntheorem toFreeSemigroup_comp_of : @toFreeSemigroup α ∘ of = FreeSemigroup.of := rfl\n#align free_magma.to_free_semigroup_comp_of FreeMagma.toFreeSemigroup_comp_of\n\n@[to_additive]\ntheorem toFreeSemigroup_comp_map (f : α → β) :\n    toFreeSemigroup.comp (map f) = (FreeSemigroup.map f).comp toFreeSemigroup :=\n  by ext1; rfl\n#align free_magma.to_free_semigroup_comp_map FreeMagma.toFreeSemigroup_comp_map\n\n@[to_additive]\ntheorem toFreeSemigroup_map (f : α → β) (x : FreeMagma α) :\n    toFreeSemigroup (map f x) = FreeSemigroup.map f (toFreeSemigroup x) :=\n  FunLike.congr_fun (toFreeSemigroup_comp_map f) x\n#align free_magma.to_free_semigroup_map FreeMagma.toFreeSemigroup_map\n\n@[to_additive (attr := simp)]\ntheorem length_toFreeSemigroup (x : FreeMagma α) : (toFreeSemigroup x).length = x.length :=\n  FreeMagma.recOnMul x (fun x ↦ rfl) fun x y hx hy ↦ by\n    rw [map_mul, FreeSemigroup.length_mul, hx, hy]; rfl\n#align free_magma.length_to_free_semigroup FreeMagma.length_toFreeSemigroup\n\nend FreeMagma\n\n/-- Isomorphism between `Magma.AssocQuotient (FreeMagma α)` and `FreeSemigroup α`. -/\n@[to_additive \"Isomorphism between `AddMagma.AssocQuotient (FreeAddMagma α)` and\n`FreeAddSemigroup α`.\"]\ndef FreeMagmaAssocQuotientEquiv (α : Type u) :\n    Magma.AssocQuotient (FreeMagma α) ≃* FreeSemigroup α :=\n      (Magma.AssocQuotient.lift FreeMagma.toFreeSemigroup).toMulEquiv\n      (FreeSemigroup.lift (Magma.AssocQuotient.of ∘ FreeMagma.of))\n      (by ext; rfl)\n      (by ext1; rfl)\n#align free_magma_assoc_quotient_equiv FreeMagmaAssocQuotientEquiv\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/Free.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.4866018164798437}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.limits.preserves.limits\n\n/-!\n# (Co)limits in functor categories.\n\nWe show that if `D` has limits, then the functor category `C ⥤ D` also has limits\n(`category_theory.limits.functor_category_has_limits`),\nand the evaluation functors preserve limits\n(`category_theory.limits.evaluation_preserves_limits`)\n(and similarly for colimits).\n\nWe also show that `F : D ⥤ K ⥤ C` preserves (co)limits if it does so for each `k : K`\n(`category_theory.limits.preserves_limits_of_evaluation` and\n`category_theory.limits.preserves_colimits_of_evaluation`).\n-/\n\nopen category_theory category_theory.category\n\n-- morphism levels before object levels. See note [category_theory universes].\nuniverses v₁ v₂ u₁ u₂ v v' u u'\n\nnamespace category_theory.limits\n\nvariables {C : Type u} [category.{v} C] {D : Type u'} [category.{v'} D]\n\nvariables {J : Type u₁} [category.{v₁} J] {K : Type u₂} [category.{v₂} K]\n\n@[simp, reassoc]\nlemma limit.lift_π_app (H : J ⥤ K ⥤ C) [has_limit H] (c : cone H) (j : J) (k : K) :\n  (limit.lift H c).app k ≫ (limit.π H j).app k = (c.π.app j).app k :=\ncongr_app (limit.lift_π c j) k\n\n@[simp, reassoc]\nlemma colimit.ι_desc_app (H : J ⥤ K ⥤ C) [has_colimit H] (c : cocone H) (j : J) (k : K) :\n  (colimit.ι H j).app k ≫ (colimit.desc H c).app k = (c.ι.app j).app k :=\ncongr_app (colimit.ι_desc c j) k\n\n/--\nThe evaluation functors jointly reflect limits: that is, to show a cone is a limit of `F`\nit suffices to show that each evaluation cone is a limit. In other words, to prove a cone is\nlimiting you can show it's pointwise limiting.\n-/\ndef evaluation_jointly_reflects_limits {F : J ⥤ K ⥤ C} (c : cone F)\n  (t : Π (k : K), is_limit (((evaluation K C).obj k).map_cone c)) : is_limit c :=\n{ lift := λ s,\n  { app := λ k, (t k).lift ⟨s.X.obj k, whisker_right s.π ((evaluation K C).obj k)⟩,\n    naturality' := λ X Y f, (t Y).hom_ext $ λ j,\n    begin\n      rw [assoc, (t Y).fac _ j],\n      simpa using\n        ((t X).fac_assoc ⟨s.X.obj X, whisker_right s.π ((evaluation K C).obj X)⟩ j _).symm,\n    end },\n  fac' := λ s j, nat_trans.ext _ _ $ funext $ λ k, (t k).fac _ j,\n  uniq' := λ s m w, nat_trans.ext _ _ $ funext $ λ x, (t x).hom_ext $ λ j,\n      (congr_app (w j) x).trans\n        ((t x).fac ⟨s.X.obj _, whisker_right s.π ((evaluation K C).obj _)⟩ j).symm }\n\n/--\nGiven a functor `F` and a collection of limit cones for each diagram `X ↦ F X k`, we can stitch\nthem together to give a cone for the diagram `F`.\n`combined_is_limit` shows that the new cone is limiting, and `eval_combined` shows it is\n(essentially) made up of the original cones.\n-/\n@[simps] def combine_cones (F : J ⥤ K ⥤ C) (c : Π (k : K), limit_cone (F.flip.obj k)) :\n  cone F :=\n{ X :=\n  { obj := λ k, (c k).cone.X,\n    map := λ k₁ k₂ f, (c k₂).is_limit.lift ⟨_, (c k₁).cone.π ≫ F.flip.map f⟩,\n    map_id' := λ k, (c k).is_limit.hom_ext (λ j, by { dsimp, simp }),\n    map_comp' := λ k₁ k₂ k₃ f₁ f₂, (c k₃).is_limit.hom_ext (λ j, by simp) },\n  π :=\n  { app := λ j, { app := λ k, (c k).cone.π.app j },\n    naturality' := λ j₁ j₂ g, nat_trans.ext _ _ $ funext $ λ k, (c k).cone.π.naturality g } }\n\n/-- The stitched together cones each project down to the original given cones (up to iso). -/\ndef evaluate_combined_cones (F : J ⥤ K ⥤ C) (c : Π (k : K), limit_cone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cone (combine_cones F c) ≅ (c k).cone :=\ncones.ext (iso.refl _) (by tidy)\n\n/-- Stitching together limiting cones gives a limiting cone. -/\ndef combined_is_limit (F : J ⥤ K ⥤ C) (c : Π (k : K), limit_cone (F.flip.obj k)) :\n  is_limit (combine_cones F c) :=\nevaluation_jointly_reflects_limits _\n  (λ k, (c k).is_limit.of_iso_limit (evaluate_combined_cones F c k).symm)\n\n/--\nThe evaluation functors jointly reflect colimits: that is, to show a cocone is a colimit of `F`\nit suffices to show that each evaluation cocone is a colimit. In other words, to prove a cocone is\ncolimiting you can show it's pointwise colimiting.\n-/\ndef evaluation_jointly_reflects_colimits {F : J ⥤ K ⥤ C} (c : cocone F)\n  (t : Π (k : K), is_colimit (((evaluation K C).obj k).map_cocone c)) : is_colimit c :=\n{ desc := λ s,\n  { app := λ k, (t k).desc ⟨s.X.obj k, whisker_right s.ι ((evaluation K C).obj k)⟩,\n    naturality' := λ X Y f, (t X).hom_ext $ λ j,\n    begin\n      rw [(t X).fac_assoc _ j],\n      erw ← (c.ι.app j).naturality_assoc f,\n      erw (t Y).fac ⟨s.X.obj _, whisker_right s.ι _⟩ j,\n      dsimp,\n      simp,\n    end },\n  fac' := λ s j, nat_trans.ext _ _ $ funext $ λ k, (t k).fac _ j,\n  uniq' := λ s m w, nat_trans.ext _ _ $ funext $ λ x, (t x).hom_ext $ λ j,\n      (congr_app (w j) x).trans\n        ((t x).fac ⟨s.X.obj _, whisker_right s.ι ((evaluation K C).obj _)⟩ j).symm }\n\n/--\nGiven a functor `F` and a collection of colimit cocones for each diagram `X ↦ F X k`, we can stitch\nthem together to give a cocone for the diagram `F`.\n`combined_is_colimit` shows that the new cocone is colimiting, and `eval_combined` shows it is\n(essentially) made up of the original cocones.\n-/\n@[simps] def combine_cocones (F : J ⥤ K ⥤ C) (c : Π (k : K), colimit_cocone (F.flip.obj k)) :\n  cocone F :=\n{ X :=\n  { obj := λ k, (c k).cocone.X,\n    map := λ k₁ k₂ f, (c k₁).is_colimit.desc ⟨_, F.flip.map f ≫ (c k₂).cocone.ι⟩,\n    map_id' := λ k, (c k).is_colimit.hom_ext (λ j, by { dsimp, simp }),\n    map_comp' := λ k₁ k₂ k₃ f₁ f₂, (c k₁).is_colimit.hom_ext (λ j, by simp) },\n  ι :=\n  { app := λ j, { app := λ k, (c k).cocone.ι.app j },\n    naturality' := λ j₁ j₂ g, nat_trans.ext _ _ $ funext $ λ k, (c k).cocone.ι.naturality g } }\n\n/-- The stitched together cocones each project down to the original given cocones (up to iso). -/\ndef evaluate_combined_cocones\n  (F : J ⥤ K ⥤ C) (c : Π (k : K), colimit_cocone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cocone (combine_cocones F c) ≅ (c k).cocone :=\ncocones.ext (iso.refl _) (by tidy)\n\n/-- Stitching together colimiting cocones gives a colimiting cocone. -/\ndef combined_is_colimit (F : J ⥤ K ⥤ C) (c : Π (k : K), colimit_cocone (F.flip.obj k)) :\n  is_colimit (combine_cocones F c) :=\nevaluation_jointly_reflects_colimits _\n  (λ k, (c k).is_colimit.of_iso_colimit (evaluate_combined_cocones F c k).symm)\n\nnoncomputable theory\n\ninstance functor_category_has_limits_of_shape\n  [has_limits_of_shape J C] : has_limits_of_shape J (K ⥤ C) :=\n{ has_limit := λ F, has_limit.mk\n  { cone := combine_cones F (λ k, get_limit_cone _),\n    is_limit := combined_is_limit _ _ } }\n\ninstance functor_category_has_colimits_of_shape\n  [has_colimits_of_shape J C] : has_colimits_of_shape J (K ⥤ C) :=\n{ has_colimit := λ F, has_colimit.mk\n  { cocone := combine_cocones _ (λ k, get_colimit_cocone _),\n    is_colimit := combined_is_colimit _ _ } }\n\ninstance functor_category_has_limits_of_size [has_limits_of_size.{v₁ u₁} C] :\n  has_limits_of_size.{v₁ u₁} (K ⥤ C) := ⟨infer_instance⟩\n\ninstance functor_category_has_colimits_of_size [has_colimits_of_size.{v₁ u₁} C] :\n  has_colimits_of_size.{v₁ u₁} (K ⥤ C) := ⟨infer_instance⟩\n\ninstance evaluation_preserves_limits_of_shape [has_limits_of_shape J C] (k : K) :\n  preserves_limits_of_shape J ((evaluation K C).obj k) :=\n{ preserves_limit :=\n  λ F, preserves_limit_of_preserves_limit_cone (combined_is_limit _ _) $\n    is_limit.of_iso_limit (limit.is_limit _)\n      (evaluate_combined_cones F _ k).symm }\n\n/--\nIf `F : J ⥤ K ⥤ C` is a functor into a functor category which has a limit,\nthen the evaluation of that limit at `k` is the limit of the evaluations of `F.obj j` at `k`.\n-/\ndef limit_obj_iso_limit_comp_evaluation [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :\n  (limit F).obj k ≅ limit (F ⋙ ((evaluation K C).obj k)) :=\npreserves_limit_iso ((evaluation K C).obj k) F\n\n@[simp, reassoc]\nlemma limit_obj_iso_limit_comp_evaluation_hom_π\n  [has_limits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K) :\n  (limit_obj_iso_limit_comp_evaluation F k).hom ≫ limit.π (F ⋙ ((evaluation K C).obj k)) j =\n    (limit.π F j).app k :=\nbegin\n  dsimp [limit_obj_iso_limit_comp_evaluation],\n  simp,\nend\n\n@[simp, reassoc]\nlemma limit_obj_iso_limit_comp_evaluation_inv_π_app\n  [has_limits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K):\n  (limit_obj_iso_limit_comp_evaluation F k).inv ≫ (limit.π F j).app k =\n    limit.π (F ⋙ ((evaluation K C).obj k)) j :=\nbegin\n  dsimp [limit_obj_iso_limit_comp_evaluation],\n  rw iso.inv_comp_eq,\n  simp,\nend\n\n@[simp, reassoc]\nlemma limit_map_limit_obj_iso_limit_comp_evaluation_hom\n  [has_limits_of_shape J C] {i j : K} (F : J ⥤ K ⥤ C) (f : i ⟶ j) :\n  (limit F).map f ≫ (limit_obj_iso_limit_comp_evaluation _ _).hom =\n  (limit_obj_iso_limit_comp_evaluation _ _).hom ≫\n  lim_map (whisker_left _ ((evaluation _ _).map f)) :=\nby { ext, dsimp, simp }\n\n@[simp, reassoc]\nlemma limit_obj_iso_limit_comp_evaluation_inv_limit_map\n  [has_limits_of_shape J C] {i j : K} (F : J ⥤ K ⥤ C) (f : i ⟶ j) :\n  (limit_obj_iso_limit_comp_evaluation _ _).inv ≫ (limit F).map f =\n  lim_map (whisker_left _ ((evaluation _ _).map f)) ≫\n  (limit_obj_iso_limit_comp_evaluation _ _).inv :=\nby rw [iso.inv_comp_eq, ← category.assoc, iso.eq_comp_inv,\n  limit_map_limit_obj_iso_limit_comp_evaluation_hom]\n\n@[ext]\nlemma limit_obj_ext {H : J ⥤ K ⥤ C} [has_limits_of_shape J C]\n  {k : K} {W : C} {f g : W ⟶ (limit H).obj k}\n  (w : ∀ j, f ≫ (limits.limit.π H j).app k = g ≫ (limits.limit.π H j).app k) : f = g :=\nbegin\n  apply (cancel_mono (limit_obj_iso_limit_comp_evaluation H k).hom).1,\n  ext,\n  simpa using w j,\nend\n\ninstance evaluation_preserves_colimits_of_shape [has_colimits_of_shape J C] (k : K) :\n  preserves_colimits_of_shape J ((evaluation K C).obj k) :=\n{ preserves_colimit :=\n  λ F, preserves_colimit_of_preserves_colimit_cocone (combined_is_colimit _ _) $\n    is_colimit.of_iso_colimit (colimit.is_colimit _)\n      (evaluate_combined_cocones F _ k).symm }\n\n/--\nIf `F : J ⥤ K ⥤ C` is a functor into a functor category which has a colimit,\nthen the evaluation of that colimit at `k` is the colimit of the evaluations of `F.obj j` at `k`.\n-/\ndef colimit_obj_iso_colimit_comp_evaluation [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :\n  (colimit F).obj k ≅ colimit (F ⋙ ((evaluation K C).obj k)) :=\npreserves_colimit_iso ((evaluation K C).obj k) F\n\n@[simp, reassoc]\nlemma colimit_obj_iso_colimit_comp_evaluation_ι_inv\n  [has_colimits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K) :\n  colimit.ι (F ⋙ ((evaluation K C).obj k)) j ≫ (colimit_obj_iso_colimit_comp_evaluation F k).inv =\n    (colimit.ι F j).app k :=\nbegin\n  dsimp [colimit_obj_iso_colimit_comp_evaluation],\n  simp,\nend\n\n@[simp, reassoc]\nlemma colimit_obj_iso_colimit_comp_evaluation_ι_app_hom\n  [has_colimits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K) :\n  (colimit.ι F j).app k ≫ (colimit_obj_iso_colimit_comp_evaluation F k).hom =\n     colimit.ι (F ⋙ ((evaluation K C).obj k)) j :=\nbegin\n  dsimp [colimit_obj_iso_colimit_comp_evaluation],\n  rw ←iso.eq_comp_inv,\n  simp,\nend\n\n@[simp, reassoc]\nlemma colimit_obj_iso_colimit_comp_evaluation_inv_colimit_map\n  [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) {i j : K} (f : i ⟶ j) :\n  (colimit_obj_iso_colimit_comp_evaluation _ _).inv ≫ (colimit F).map f =\n  colim_map (whisker_left _ ((evaluation _ _).map f)) ≫\n  (colimit_obj_iso_colimit_comp_evaluation _ _).inv :=\nby { ext, dsimp, simp }\n\n@[simp, reassoc]\nlemma colimit_map_colimit_obj_iso_colimit_comp_evaluation_hom\n  [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) {i j : K} (f : i ⟶ j) :\n  (colimit F).map f ≫ (colimit_obj_iso_colimit_comp_evaluation _ _).hom =\n  (colimit_obj_iso_colimit_comp_evaluation _ _).hom ≫\n  colim_map (whisker_left _ ((evaluation _ _).map f)) :=\nby rw [← iso.inv_comp_eq, ← category.assoc, ← iso.eq_comp_inv,\n  colimit_obj_iso_colimit_comp_evaluation_inv_colimit_map]\n\n@[ext]\nlemma colimit_obj_ext {H : J ⥤ K ⥤ C} [has_colimits_of_shape J C]\n  {k : K} {W : C} {f g : (colimit H).obj k ⟶ W}\n  (w : ∀ j, (colimit.ι H j).app k ≫ f = (colimit.ι H j).app k ≫ g) : f = g :=\nbegin\n  apply (cancel_epi (colimit_obj_iso_colimit_comp_evaluation H k).inv).1,\n  ext,\n  simpa using w j,\nend\n\ninstance evaluation_preserves_limits [has_limits C] (k : K) :\n  preserves_limits ((evaluation K C).obj k) :=\n{ preserves_limits_of_shape := λ J 𝒥, by resetI; apply_instance }\n\n/-- `F : D ⥤ K ⥤ C` preserves the limit of some `G : J ⥤ D` if it does for each `k : K`. -/\ndef preserves_limit_of_evaluation (F : D ⥤ K ⥤ C) (G : J ⥤ D)\n  (H : Π (k : K), preserves_limit G (F ⋙ (evaluation K C).obj k : D ⥤ C)) :\n  preserves_limit G F := ⟨λ c hc,\nbegin\n  apply evaluation_jointly_reflects_limits,\n  intro X,\n  haveI := H X,\n  change is_limit ((F ⋙ (evaluation K C).obj X).map_cone c),\n  exact preserves_limit.preserves hc,\nend⟩\n\n/-- `F : D ⥤ K ⥤ C` preserves limits of shape `J` if it does for each `k : K`. -/\ndef preserves_limits_of_shape_of_evaluation (F : D ⥤ K ⥤ C) (J : Type*) [category J]\n  (H : Π (k : K), preserves_limits_of_shape J (F ⋙ (evaluation K C).obj k)) :\n  preserves_limits_of_shape J F :=\n⟨λ G, preserves_limit_of_evaluation F G (λ k, preserves_limits_of_shape.preserves_limit)⟩\n\n/-- `F : D ⥤ K ⥤ C` preserves all limits if it does for each `k : K`. -/\ndef {w' w} preserves_limits_of_evaluation (F : D ⥤ K ⥤ C)\n  (H : Π (k : K), preserves_limits_of_size.{w' w} (F ⋙ (evaluation K C).obj k)) :\n  preserves_limits_of_size.{w' w} F :=\n⟨λ L hL, by exactI preserves_limits_of_shape_of_evaluation\n    F L (λ k, preserves_limits_of_size.preserves_limits_of_shape)⟩\n\ninstance evaluation_preserves_colimits [has_colimits C] (k : K) :\n  preserves_colimits ((evaluation K C).obj k) :=\n{ preserves_colimits_of_shape := λ J 𝒥, by resetI; apply_instance }\n\n/-- `F : D ⥤ K ⥤ C` preserves the colimit of some `G : J ⥤ D` if it does for each `k : K`. -/\ndef preserves_colimit_of_evaluation (F : D ⥤ K ⥤ C) (G : J ⥤ D)\n  (H : Π (k), preserves_colimit G (F ⋙ (evaluation K C).obj k)) : preserves_colimit G F := ⟨λ c hc,\nbegin\n  apply evaluation_jointly_reflects_colimits,\n  intro X,\n  haveI := H X,\n  change is_colimit ((F ⋙ (evaluation K C).obj X).map_cocone c),\n  exact preserves_colimit.preserves hc,\nend⟩\n\n/-- `F : D ⥤ K ⥤ C` preserves all colimits of shape `J` if it does for each `k : K`. -/\ndef preserves_colimits_of_shape_of_evaluation (F : D ⥤ K ⥤ C) (J : Type*) [category J]\n  (H : Π (k : K), preserves_colimits_of_shape J (F ⋙ (evaluation K C).obj k)) :\n  preserves_colimits_of_shape J F :=\n⟨λ G, preserves_colimit_of_evaluation F G (λ k, preserves_colimits_of_shape.preserves_colimit)⟩\n\n/-- `F : D ⥤ K ⥤ C` preserves all colimits if it does for each `k : K`. -/\ndef {w' w} preserves_colimits_of_evaluation (F : D ⥤ K ⥤ C)\n  (H : Π (k : K), preserves_colimits_of_size.{w' w} (F ⋙ (evaluation K C).obj k)) :\n  preserves_colimits_of_size.{w' w} F :=\n⟨λ L hL, by exactI preserves_colimits_of_shape_of_evaluation\n    F L (λ k, preserves_colimits_of_size.preserves_colimits_of_shape)⟩\nopen category_theory.prod\n\n/-- The limit of a diagram `F : J ⥤ K ⥤ C` is isomorphic to the functor given by\nthe individual limits on objects. -/\n@[simps]\ndef limit_iso_flip_comp_lim [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) :\n  limit F ≅ F.flip ⋙ lim :=\nnat_iso.of_components (limit_obj_iso_limit_comp_evaluation F) $ by tidy\n\n/-- A variant of `limit_iso_flip_comp_lim` where the arguemnts of `F` are flipped. -/\n@[simps]\ndef limit_flip_iso_comp_lim [has_limits_of_shape J C] (F : K ⥤ J ⥤ C) :\n  limit F.flip ≅ F ⋙ lim :=\nnat_iso.of_components (λ k,\n  limit_obj_iso_limit_comp_evaluation F.flip k ≪≫\n  has_limit.iso_of_nat_iso (flip_comp_evaluation _ _)) $ by tidy\n\n/--\nFor a functor `G : J ⥤ K ⥤ C`, its limit `K ⥤ C` is given by `(G' : K ⥤ J ⥤ C) ⋙ lim`.\nNote that this does not require `K` to be small.\n-/\n@[simps] def limit_iso_swap_comp_lim [has_limits_of_shape J C] (G : J ⥤ K ⥤ C) :\n  limit G ≅ curry.obj (swap K J ⋙ uncurry.obj G) ⋙ lim :=\nlimit_iso_flip_comp_lim G ≪≫ iso_whisker_right (flip_iso_curry_swap_uncurry _) _\n\n/-- The colimit of a diagram `F : J ⥤ K ⥤ C` is isomorphic to the functor given by\nthe individual colimits on objects. -/\n@[simps]\ndef colimit_iso_flip_comp_colim [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) :\n  colimit F ≅ F.flip ⋙ colim :=\nnat_iso.of_components (colimit_obj_iso_colimit_comp_evaluation F) $ by tidy\n\n/-- A variant of `colimit_iso_flip_comp_colim` where the arguemnts of `F` are flipped. -/\n@[simps]\ndef colimit_flip_iso_comp_colim [has_colimits_of_shape J C] (F : K ⥤ J ⥤ C) :\n  colimit F.flip ≅ F ⋙ colim :=\nnat_iso.of_components (λ k,\n  colimit_obj_iso_colimit_comp_evaluation _ _ ≪≫\n  has_colimit.iso_of_nat_iso (flip_comp_evaluation _ _)) $ by tidy\n\n/--\nFor a functor `G : J ⥤ K ⥤ C`, its colimit `K ⥤ C` is given by `(G' : K ⥤ J ⥤ C) ⋙ colim`.\nNote that this does not require `K` to be small.\n-/\n@[simps]\ndef colimit_iso_swap_comp_colim [has_colimits_of_shape J C] (G : J ⥤ K ⥤ C) :\n  colimit G ≅ curry.obj (swap K J ⋙ uncurry.obj G) ⋙ colim :=\ncolimit_iso_flip_comp_colim G ≪≫ iso_whisker_right (flip_iso_curry_swap_uncurry _) _\n\nend category_theory.limits\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/category_theory/limits/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.4866018121659751}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl\n\nHausdorff completions of uniform spaces.\n\nThe goal is to construct a left-adjoint to the inclusion of complete Hausdorff uniform spaces\ninto all uniform spaces. Any uniform space `α` gets a completion `completion α` and a morphism\n(ie. uniformly continuous map) `completion : α → completion α` which solves the universal\nmapping problem of factorizing morphisms from `α` to any complete Hausdorff uniform space `β`.\nIt means any uniformly continuous `f : α → β` gives rise to a unique morphism\n`completion.map f : completion α → β` such that `f = completion.extension f ∘ completion α`.\nActually `completion.extension f` is defined for all maps from `α` to `β` but it has the desired\nproperties only if `f` is uniformly continuous.\n\nBeware that `completion α` is not injective if `α` is not Hausdorff. But its image is always\ndense. The adjoint functor acting on morphisms is then constructed by the usual abstract nonsense.\nFor every uniform spaces `α` and `β`, it turns `f : α → β` into a morphism\n  `completion.map f : completion α → completion β`\nsuch that\n  `coe ∘ f = (completion.map f) ∘ coe`\nprovided `f` is uniformly continuous. This construction is compatible with composition.\n\nIn this file we introduce the following concepts:\n\n* `Cauchy α` the uniform completion of the uniform space `α` (using Cauchy filters). These are not\n  minimal filters.\n\n* `completion α := quotient (separation_setoid (Cauchy α))` the Hausdorff completion.\n\nThis formalization is mostly based on\n  N. Bourbaki: General Topology\n  I. M. James: Topologies and Uniformities\nFrom a slightly different perspective in order to reuse material in topology.uniform_space.basic.\n-/\nimport data.set.basic data.set.function\nimport topology.uniform_space.uniform_embedding topology.uniform_space.separation\n\n\nnoncomputable theory\nlocal attribute [instance] classical.prop_decidable\nopen filter set\nuniverses u v w x\n\nlocal notation `𝓤` := uniformity\n\n/-- Space of Cauchy filters\n\nThis is essentially the completion of a uniform space. The embeddings are the neighbourhood filters.\nThis space is not minimal, the separated uniform space (i.e. quotiented on the intersection of all\nentourages) is necessary for this.\n-/\ndef Cauchy (α : Type u) [uniform_space α] : Type u := { f : filter α // cauchy f }\n\nnamespace Cauchy\n\nsection\nparameters {α : Type u} [uniform_space α]\nvariables {β : Type v} {γ : Type w}\nvariables [uniform_space β] [uniform_space γ]\n\ndef gen (s : set (α × α)) : set (Cauchy α × Cauchy α) :=\n{p | s ∈ filter.prod (p.1.val) (p.2.val) }\n\nlemma monotone_gen : monotone gen :=\nmonotone_set_of $ assume p, @monotone_mem_sets (α×α) (filter.prod (p.1.val) (p.2.val))\n\nprivate lemma symm_gen : map prod.swap ((𝓤 α).lift' gen) ≤ (𝓤 α).lift' gen :=\ncalc map prod.swap ((𝓤 α).lift' gen) =\n  (𝓤 α).lift' (λs:set (α×α), {p | s ∈ filter.prod (p.2.val) (p.1.val) }) :\n  begin\n    delta gen,\n    simp [map_lift'_eq, monotone_set_of, monotone_mem_sets,\n          function.comp, image_swap_eq_preimage_swap]\n  end\n  ... ≤ (𝓤 α).lift' gen :\n    uniformity_lift_le_swap\n      (monotone_comp (monotone_set_of $ assume p,\n        @monotone_mem_sets (α×α) ((filter.prod ((p.2).val) ((p.1).val)))) monotone_principal)\n      begin\n        have h := λ(p:Cauchy α×Cauchy α), @filter.prod_comm _ _ (p.2.val) (p.1.val),\n        simp [function.comp, h],\n        exact le_refl _\n      end\n\nprivate lemma comp_rel_gen_gen_subset_gen_comp_rel {s t : set (α×α)} : comp_rel (gen s) (gen t) ⊆\n  (gen (comp_rel s t) : set (Cauchy α × Cauchy α)) :=\nassume ⟨f, g⟩ ⟨h, h₁, h₂⟩,\nlet ⟨t₁, (ht₁ : t₁ ∈ f.val), t₂, (ht₂ : t₂ ∈ h.val), (h₁ : set.prod t₁ t₂ ⊆ s)⟩ :=\n  mem_prod_iff.mp h₁ in\nlet ⟨t₃, (ht₃ : t₃ ∈ h.val), t₄, (ht₄ : t₄ ∈ g.val), (h₂ : set.prod t₃ t₄ ⊆ t)⟩ :=\n  mem_prod_iff.mp h₂ in\nhave t₂ ∩ t₃ ∈ h.val,\n  from inter_mem_sets ht₂ ht₃,\nlet ⟨x, xt₂, xt₃⟩ :=\n  inhabited_of_mem_sets (h.property.left) this in\n(filter.prod f.val g.val).sets_of_superset\n  (prod_mem_prod ht₁ ht₄)\n  (assume ⟨a, b⟩ ⟨(ha : a ∈ t₁), (hb : b ∈ t₄)⟩,\n    ⟨x,\n      h₁ (show (a, x) ∈ set.prod t₁ t₂, from ⟨ha, xt₂⟩),\n      h₂ (show (x, b) ∈ set.prod t₃ t₄, from ⟨xt₃, hb⟩)⟩)\n\nprivate lemma comp_gen :\n  ((𝓤 α).lift' gen).lift' (λs, comp_rel s s) ≤ (𝓤 α).lift' gen :=\ncalc ((𝓤 α).lift' gen).lift' (λs, comp_rel s s) =\n    (𝓤 α).lift' (λs, comp_rel (gen s) (gen s)) :\n  begin\n    rw [lift'_lift'_assoc],\n    exact monotone_gen,\n    exact (monotone_comp_rel monotone_id monotone_id)\n  end\n  ... ≤ (𝓤 α).lift' (λs, gen $ comp_rel s s) :\n    lift'_mono' $ assume s hs, comp_rel_gen_gen_subset_gen_comp_rel\n  ... = ((𝓤 α).lift' $ λs:set(α×α), comp_rel s s).lift' gen :\n  begin\n    rw [lift'_lift'_assoc],\n    exact (monotone_comp_rel monotone_id monotone_id),\n    exact monotone_gen\n  end\n  ... ≤ (𝓤 α).lift' gen : lift'_mono comp_le_uniformity (le_refl _)\n\ninstance : uniform_space (Cauchy α) :=\nuniform_space.of_core\n{ uniformity  := (𝓤 α).lift' gen,\n  refl        := principal_le_lift' $ assume s hs ⟨a, b⟩ (a_eq_b : a = b),\n    a_eq_b ▸ a.property.right hs,\n  symm        := symm_gen,\n  comp        := comp_gen }\n\ntheorem mem_uniformity {s : set (Cauchy α × Cauchy α)} :\n  s ∈ 𝓤 (Cauchy α) ↔ ∃ t ∈ 𝓤 α, gen t ⊆ s :=\nmem_lift'_sets monotone_gen\n\ntheorem mem_uniformity' {s : set (Cauchy α × Cauchy α)} :\n  s ∈ 𝓤 (Cauchy α) ↔ ∃ t ∈ 𝓤 α,\n    ∀ f g : Cauchy α, t ∈ filter.prod f.1 g.1 → (f, g) ∈ s :=\nmem_uniformity.trans $ bex_congr $ λ t h, prod.forall\n\n/-- Embedding of `α` into its completion -/\ndef pure_cauchy (a : α) : Cauchy α :=\n⟨pure a, cauchy_pure⟩\n\nlemma uniform_embedding_pure_cauchy : uniform_embedding (pure_cauchy : α → Cauchy α) :=\n⟨assume a₁ a₂ h,\n  have (pure_cauchy a₁).val = (pure_cauchy a₂).val, from congr_arg _ h,\n  have {a₁} = ({a₂} : set α),\n    from principal_eq_iff_eq.mp this,\n  by simp at this; assumption,\n\n  have (preimage (λ (x : α × α), (pure_cauchy (x.fst), pure_cauchy (x.snd))) ∘ gen) = id,\n    from funext $ assume s, set.ext $ assume ⟨a₁, a₂⟩,\n      by simp [preimage, gen, pure_cauchy, prod_principal_principal],\n  calc comap (λ (x : α × α), (pure_cauchy (x.fst), pure_cauchy (x.snd))) ((𝓤 α).lift' gen)\n        = (𝓤 α).lift' (preimage (λ (x : α × α), (pure_cauchy (x.fst), pure_cauchy (x.snd))) ∘ gen) :\n      comap_lift'_eq monotone_gen\n    ... = 𝓤 α : by simp [this]⟩\n\nlemma pure_cauchy_dense : ∀x, x ∈ closure (range pure_cauchy) :=\nassume f,\nhave h_ex : ∀ s ∈ 𝓤 (Cauchy α), ∃y:α, (f, pure_cauchy y) ∈ s, from\n  assume s hs,\n  let ⟨t'', ht''₁, (ht''₂ : gen t'' ⊆ s)⟩ := (mem_lift'_sets monotone_gen).mp hs in\n  let ⟨t', ht'₁, ht'₂⟩ := comp_mem_uniformity_sets ht''₁ in\n  have t' ∈ filter.prod (f.val) (f.val),\n    from f.property.right ht'₁,\n  let ⟨t, ht, (h : set.prod t t ⊆ t')⟩ := mem_prod_same_iff.mp this in\n  let ⟨x, (hx : x ∈ t)⟩ := inhabited_of_mem_sets f.property.left ht in\n  have t'' ∈ filter.prod f.val (pure x),\n    from mem_prod_iff.mpr ⟨t, ht, {y:α | (x, y) ∈ t'},\n      assume y, begin simp, intro h, simp [h], exact refl_mem_uniformity ht'₁ end,\n      assume ⟨a, b⟩ ⟨(h₁ : a ∈ t), (h₂ : (x, b) ∈ t')⟩,\n        ht'₂ $ prod_mk_mem_comp_rel (@h (a, x) ⟨h₁, hx⟩) h₂⟩,\n  ⟨x, ht''₂ $ by dsimp [gen]; exact this⟩,\nbegin\n  simp [closure_eq_nhds, nhds_eq_uniformity, lift'_inf_principal_eq, set.inter_comm],\n  exact (lift'_neq_bot_iff $ monotone_inter monotone_const monotone_preimage).mpr\n    (assume s hs,\n      let ⟨y, hy⟩ := h_ex s hs in\n      have pure_cauchy y ∈ range pure_cauchy ∩ {y : Cauchy α | (f, y) ∈ s},\n        from ⟨mem_range_self y, hy⟩,\n      ne_empty_of_mem this)\nend\n\nlemma dense_embedding_pure_cauchy : dense_embedding pure_cauchy :=\nuniform_embedding_pure_cauchy.dense_embedding pure_cauchy_dense\n\nlemma nonempty_Cauchy_iff : nonempty (Cauchy α) ↔ nonempty α :=\nbegin\n  split ; rintro ⟨c⟩,\n  { have := eq_univ_iff_forall.1 dense_embedding_pure_cauchy.closure_range c,\n    have := mem_closure_iff.1 this _ is_open_univ trivial,\n    rcases exists_mem_of_ne_empty this with ⟨_, ⟨_, a, _⟩⟩,\n    exact ⟨a⟩ },\n  { exact ⟨pure_cauchy c⟩ }\nend\n\nsection\nset_option eqn_compiler.zeta true\ninstance : complete_space (Cauchy α) :=\ncomplete_space_extension\n  uniform_embedding_pure_cauchy\n  pure_cauchy_dense $\n  assume f hf,\n  let f' : Cauchy α := ⟨f, hf⟩ in\n  have map pure_cauchy f ≤ (𝓤 $ Cauchy α).lift' (preimage (prod.mk f')),\n    from le_lift' $ assume s hs,\n    let ⟨t, ht₁, (ht₂ : gen t ⊆ s)⟩ := (mem_lift'_sets monotone_gen).mp hs in\n    let ⟨t', ht', (h : set.prod t' t' ⊆ t)⟩ := mem_prod_same_iff.mp (hf.right ht₁) in\n    have t' ⊆ { y : α | (f', pure_cauchy y) ∈ gen t },\n      from assume x hx, (filter.prod f (pure x)).sets_of_superset (prod_mem_prod ht' $ mem_pure hx) h,\n    f.sets_of_superset ht' $ subset.trans this (preimage_mono ht₂),\n  ⟨f', by simp [nhds_eq_uniformity]; assumption⟩\nend\n\ninstance [inhabited α] : inhabited (Cauchy α) :=\n⟨pure_cauchy $ default α⟩\n\ninstance [h : nonempty α] : nonempty (Cauchy α) :=\nh.rec_on $ assume a, nonempty.intro $ Cauchy.pure_cauchy a\n\nsection extend\nvariables [_root_.complete_space β] [separated β]\n\ndef extend (f : α → β) : (Cauchy α → β) :=\nif uniform_continuous f then\n  dense_embedding_pure_cauchy.extend f\nelse\n  λ x, f (classical.inhabited_of_nonempty $ nonempty_Cauchy_iff.1 ⟨x⟩).default\n\nlemma extend_pure_cauchy {f : α → β} (hf : uniform_continuous f) (a : α) :\n  extend f (pure_cauchy a) = f a :=\nbegin\n  rw [extend, if_pos hf],\n  exact uniformly_extend_of_emb uniform_embedding_pure_cauchy pure_cauchy_dense _\nend\n\nlemma uniform_continuous_extend {f : α → β} : uniform_continuous (extend f) :=\nbegin\n  by_cases hf : uniform_continuous f,\n  { rw [extend, if_pos hf],\n    exact uniform_continuous_uniformly_extend uniform_embedding_pure_cauchy pure_cauchy_dense hf },\n  { rw [extend, if_neg hf],\n    exact uniform_continuous_of_const (assume a b, by congr) }\nend\n\nend extend\n\nend\n\ntheorem Cauchy_eq\n  {α : Type*} [inhabited α] [uniform_space α] [complete_space α] [separated α] {f g : Cauchy α} :\n  lim f.1 = lim g.1 ↔ (f, g) ∈ separation_rel (Cauchy α) :=\nbegin\n  split,\n  { intros e s hs,\n    rcases Cauchy.mem_uniformity'.1 hs with ⟨t, tu, ts⟩,\n    apply ts,\n    rcases comp_mem_uniformity_sets tu with ⟨d, du, dt⟩,\n    refine mem_prod_iff.2\n      ⟨_, le_nhds_lim_of_cauchy f.2 (mem_nhds_right (lim f.1) du),\n       _, le_nhds_lim_of_cauchy g.2 (mem_nhds_left (lim g.1) du), λ x h, _⟩,\n    cases x with a b, cases h with h₁ h₂,\n    rw ← e at h₂,\n    exact dt ⟨_, h₁, h₂⟩ },\n  { intros H,\n    refine separated_def.1 (by apply_instance) _ _ (λ t tu, _),\n    rcases mem_uniformity_is_closed tu with ⟨d, du, dc, dt⟩,\n    refine H {p | (lim p.1.1, lim p.2.1) ∈ t}\n      (Cauchy.mem_uniformity'.2 ⟨d, du, λ f g h, _⟩),\n    rcases mem_prod_iff.1 h with ⟨x, xf, y, yg, h⟩,\n    have limc : ∀ (f : Cauchy α) (x ∈ f.1), lim f.1 ∈ closure x,\n    { intros f x xf,\n      rw closure_eq_nhds,\n      exact lattice.neq_bot_of_le_neq_bot f.2.1\n        (lattice.le_inf (le_nhds_lim_of_cauchy f.2) (le_principal_iff.2 xf)) },\n    have := (closure_subset_iff_subset_of_is_closed dc).2 h,\n    rw closure_prod_eq at this,\n    refine dt (this ⟨_, _⟩); dsimp; apply limc; assumption }\nend\n\nsection\nlocal attribute [instance] uniform_space.separation_setoid\n\nlemma injective_separated_pure_cauchy {α : Type*} [uniform_space α] [s : separated α] :\n  function.injective (λa:α, ⟦pure_cauchy a⟧) | a b h :=\nseparated_def.1 s _ _ $ assume s hs,\nlet ⟨t, ht, hts⟩ :=\n  by rw [← (@uniform_embedding_pure_cauchy α _).right, filter.mem_comap_sets] at hs; exact hs in\nhave (pure_cauchy a, pure_cauchy b) ∈ t, from quotient.exact h t ht,\n@hts (a, b) this\n\nend\n\nsection prod\nvariables {α : Type*} {β : Type*} [uniform_space α] [uniform_space β]\n\ndef prod : Cauchy α × Cauchy β → Cauchy (α × β) :=\ndense_embedding.extend (dense_embedding_pure_cauchy.prod dense_embedding_pure_cauchy) pure_cauchy\n\nlemma prod_pure_cauchy_pure_cauchy (a : α) (b :β) :\n  prod (pure_cauchy a, pure_cauchy b) = pure_cauchy (a, b) :=\nuniformly_extend_of_emb\n  (uniform_embedding_pure_cauchy.prod uniform_embedding_pure_cauchy)\n  (dense_embedding_pure_cauchy.prod dense_embedding_pure_cauchy).dense\n  (a, b)\n\nlemma uniform_continuous_prod : uniform_continuous (@prod α β _ _) :=\nuniform_continuous_uniformly_extend\n  (uniform_embedding_pure_cauchy.prod uniform_embedding_pure_cauchy)\n  (dense_embedding_pure_cauchy.prod dense_embedding_pure_cauchy).dense\n  uniform_embedding_pure_cauchy.uniform_continuous\n\nend prod\n\nend Cauchy\n\nlocal attribute [instance] uniform_space.separation_setoid\n\nopen Cauchy set\n\nnamespace uniform_space\nvariables (α : Type*) [uniform_space α]\nvariables {β : Type*} [uniform_space β]\nvariables {γ : Type*} [uniform_space γ]\n\ninstance complete_space_separation [h : complete_space α] :\n  complete_space (quotient (separation_setoid α)) :=\n⟨assume f, assume hf : cauchy f,\n  have cauchy (f.comap (λx, ⟦x⟧)), from\n    cauchy_comap comap_quotient_le_uniformity hf $\n      comap_neq_bot_of_surj hf.left $ assume b, quotient.exists_rep _,\n  let ⟨x, (hx : f.comap (λx, ⟦x⟧) ≤ nhds x)⟩ := complete_space.complete this in\n  ⟨⟦x⟧, calc f = map (λx, ⟦x⟧) (f.comap (λx, ⟦x⟧)) :\n      (map_comap $ univ_mem_sets' $ assume b, quotient.exists_rep _).symm\n    ... ≤ map (λx, ⟦x⟧) (nhds x) : map_mono hx\n    ... ≤ _ : continuous_iff_continuous_at.mp uniform_continuous_quotient_mk.continuous _⟩⟩\n\n\n/-- Hausdorff completion of `α` -/\ndef completion := quotient (separation_setoid $ Cauchy α)\n\nnamespace completion\n\n@[priority 50]\ninstance : uniform_space (completion α) := by dunfold completion ; apply_instance\n\ninstance : complete_space (completion α) := by dunfold completion ; apply_instance\n\ninstance : separated (completion α) := by dunfold completion ; apply_instance\n\ninstance : t2_space (completion α) := separated_t2\n\ninstance : regular_space (completion α) := separated_regular\n\n/-- Automatic coercion from `α` to its completion. Not always injective. -/\ninstance : has_coe α (completion α) := ⟨quotient.mk ∘ pure_cauchy⟩\n\nprotected lemma coe_eq : (coe : α → completion α) = quotient.mk ∘ pure_cauchy := rfl\n\nlemma uniform_continuous_coe : uniform_continuous (coe : α → completion α) :=\nuniform_continuous.comp uniform_embedding_pure_cauchy.uniform_continuous\n  uniform_continuous_quotient_mk\n\nlemma continuous_coe : continuous (coe : α → completion α) :=\nuniform_continuous.continuous (uniform_continuous_coe α)\n\nlemma comap_coe_eq_uniformity :\n  (𝓤 _).comap (λ(p:α×α), ((p.1 : completion α), (p.2 : completion α))) = 𝓤 α :=\nbegin\n  have : (λx:α×α, ((x.1 : completion α), (x.2 : completion α))) =\n    (λx:(Cauchy α)×(Cauchy α), (⟦x.1⟧, ⟦x.2⟧)) ∘ (λx:α×α, (pure_cauchy x.1, pure_cauchy x.2)),\n  { ext ⟨a, b⟩; simp; refl },\n  rw [this, ← filter.comap_comap_comp],\n  change filter.comap _ (filter.comap _ (𝓤 $ quotient $ separation_setoid $ Cauchy α)) = 𝓤 α,\n  rw [comap_quotient_eq_uniformity, uniform_embedding_pure_cauchy.2]\nend\n\n\n\nvariable {α}\n\nlemma dense : closure (range (coe : α → completion α)) = univ :=\nby rw [completion.coe_eq, range_comp]; exact quotient_dense_of_dense pure_cauchy_dense\n\nlemma dense_embedding_coe [separated α]: dense_embedding (coe : α → completion α) :=\n(uniform_embedding_coe α).dense_embedding (assume x, by rw [dense]; exact mem_univ _)\n\nlemma dense₂ : closure (range (λx:α × β, ((x.1 : completion α), (x.2 : completion β)))) = univ :=\nby rw [← set.prod_range_range_eq, closure_prod_eq, dense, dense, univ_prod_univ]\n\nlemma dense₃ :\n  closure (range (λx:α × (β × γ), ((x.1 : completion α), ((x.2.1 : completion β), (x.2.2 : completion γ))))) = univ :=\nlet a : α → completion α := coe, bc := λp:β × γ, ((p.1 : completion β), (p.2 : completion γ)) in\nshow closure (range (λx:α × (β × γ), (a x.1, bc x.2))) = univ,\nbegin\n  rw [← set.prod_range_range_eq, @closure_prod_eq _ _ _ _ (range a) (range bc), ← univ_prod_univ],\n  congr,\n  exact dense,\n  exact dense₂\nend\n\n@[elab_as_eliminator]\nlemma induction_on {p : completion α → Prop}\n  (a : completion α) (hp : is_closed {a | p a}) (ih : ∀a:α, p a) : p a :=\nis_closed_property dense hp ih a\n\n@[elab_as_eliminator]\nlemma induction_on₂ {p : completion α → completion β → Prop}\n  (a : completion α) (b : completion β)\n  (hp : is_closed {x : completion α × completion β | p x.1 x.2})\n  (ih : ∀(a:α) (b:β), p a b) : p a b :=\nhave ∀x : completion α × completion β, p x.1 x.2, from\n  is_closed_property dense₂ hp $ assume ⟨a, b⟩, ih a b,\nthis (a, b)\n\n@[elab_as_eliminator]\nlemma induction_on₃ {p : completion α → completion β → completion γ → Prop}\n  (a : completion α) (b : completion β) (c : completion γ)\n  (hp : is_closed {x : completion α × completion β × completion γ | p x.1 x.2.1 x.2.2})\n  (ih : ∀(a:α) (b:β) (c:γ), p a b c) : p a b c :=\nhave ∀x : completion α × completion β × completion γ, p x.1 x.2.1 x.2.2, from\n  is_closed_property dense₃ hp $ assume ⟨a, b, c⟩, ih a b c,\nthis (a, b, c)\n\n@[elab_as_eliminator]\nlemma induction_on₄ {δ : Type*} [uniform_space δ]\n  {p : completion α → completion β → completion γ → completion δ → Prop}\n  (a : completion α) (b : completion β) (c : completion γ) (d : completion δ)\n  (hp : is_closed {x : (completion α × completion β) × (completion γ × completion δ) | p x.1.1 x.1.2 x.2.1 x.2.2})\n  (ih : ∀(a:α) (b:β) (c:γ) (d : δ), p ↑a ↑b ↑c ↑d) : p a b c d :=\nlet\n  ab := λp:α × β, ((p.1 : completion α), (p.2 : completion β)),\n  cd := λp:γ × δ, ((p.1 : completion γ), (p.2 : completion δ))\nin\nhave dense₄ : closure (range (λx:(α × β) × (γ × δ), (ab x.1, cd x.2))) = univ,\nbegin\n  rw [← set.prod_range_range_eq, @closure_prod_eq _ _ _ _ (range ab) (range cd), ← univ_prod_univ],\n  congr,\n  exact dense₂,\n  exact dense₂\nend,\nhave ∀x:(completion α × completion β) × (completion γ × completion δ), p x.1.1 x.1.2 x.2.1 x.2.2, from\n  is_closed_property dense₄ hp (assume p:(α×β)×(γ×δ), ih p.1.1 p.1.2 p.2.1 p.2.2),\nthis ((a, b), (c, d))\n\nlemma ext [t2_space β] {f g : completion α → β} (hf : continuous f) (hg : continuous g)\n  (h : ∀a:α, f a = g a) : f = g :=\nfunext $ assume a, completion.induction_on a (is_closed_eq hf hg) h\n\nsection extension\nvariables {f : α → β}\nvariables [complete_space β] [separated β]\n\n/-- \"Extension\" to the completion. Based on `Cauchy.extend`, which is defined for any map `f` but\nreturns an arbitrary constant value if `f` is not uniformly continuous -/\nprotected def extension (f : α → β) : completion α → β :=\nquotient.lift (extend f) $ assume a b,\n  eq_of_separated_of_uniform_continuous uniform_continuous_extend\n\nlemma uniform_continuous_extension : uniform_continuous (completion.extension f) :=\nuniform_continuous_quotient_lift uniform_continuous_extend\n\nlemma continuous_extension : continuous (completion.extension f) :=\nuniform_continuous_extension.continuous\n\n@[simp] lemma extension_coe (hf : uniform_continuous f) (a : α) : (completion.extension f) a = f a :=\nextend_pure_cauchy hf a\n\nend extension\n\nsection map\nvariables {f : α → β}\n\n/-- Completion functor acting on morphisms -/\nprotected def map (f : α → β) : completion α → completion β :=\ncompletion.extension (coe ∘ f)\n\nlemma uniform_continuous_map : uniform_continuous (completion.map f) :=\nuniform_continuous_quotient_lift uniform_continuous_extend\n\nlemma continuous_map : continuous (completion.map f) :=\nuniform_continuous_extension.continuous\n\n@[simp] lemma map_coe (hf : uniform_continuous f) (a : α) : (completion.map f) a = f a :=\nby rw [completion.map, extension_coe]; from hf.comp (uniform_continuous_coe β)\n\nlemma map_unique {f : α → β} {g : completion α → completion β}\n  (hg : uniform_continuous g) (h : ∀a:α, ↑(f a) = g a) : completion.map f = g :=\ncompletion.ext continuous_map hg.continuous $\nbegin\n  intro a,\n  simp only [completion.map, (∘), h],\n  rw [extension_coe ((uniform_continuous_coe α).comp hg)]\nend\n\nlemma map_id : completion.map (@id α) = id :=\nmap_unique uniform_continuous_id (assume a, rfl)\n\nlemma extension_map [complete_space γ] [separated γ] {f : β → γ} {g : α → β}\n  (hf : uniform_continuous f) (hg : uniform_continuous g) :\n  completion.extension f ∘ completion.map g = completion.extension (f ∘ g) :=\ncompletion.ext (continuous_map.comp continuous_extension) continuous_extension $\n  by intro a; simp only [hg, hf, hg.comp hf, (∘), map_coe, extension_coe]\n\nlemma map_comp {f : α → β} {g : β → γ} (hf : uniform_continuous f) (hg : uniform_continuous g) :\n  completion.map g ∘ completion.map f = completion.map (g ∘ f) :=\nextension_map (hg.comp (uniform_continuous_coe _)) hf\n\nend map\n\n/- In this section we construct isomorphisms between the completion of a uniform space and the\ncompletion of its separation quotient -/\nsection separation_quotient_completion\n\ndef completion_separation_quotient_equiv (α : Type u) [uniform_space α] :\n  completion (separation_quotient α) ≃ completion α :=\nbegin\n  refine ⟨completion.extension (separation_quotient.lift (coe : α → completion α)),\n    completion.map quotient.mk, _, _⟩,\n  { assume a,\n    refine completion.induction_on a (is_closed_eq (continuous_extension.comp continuous_map) continuous_id) _,\n    rintros ⟨a⟩,\n    show completion.map quotient.mk (completion.extension (separation_quotient.lift coe) ↑⟦a⟧) = ↑⟦a⟧,\n    rw [extension_coe (separation_quotient.uniform_continuous_lift _),\n      separation_quotient.lift_mk (uniform_continuous_coe α),\n      completion.map_coe uniform_continuous_quotient_mk] },\n  { assume a,\n    refine completion.induction_on a (is_closed_eq (continuous_map.comp continuous_extension) continuous_id) _,\n    assume a,\n    rw [map_coe uniform_continuous_quotient_mk,\n      extension_coe (separation_quotient.uniform_continuous_lift _),\n      separation_quotient.lift_mk (uniform_continuous_coe α) _] }\nend\n\nlemma uniform_continuous_completion_separation_quotient_equiv :\n  uniform_continuous ⇑(completion_separation_quotient_equiv α) :=\nuniform_continuous_extension\n\nlemma uniform_continuous_completion_separation_quotient_equiv_symm :\n  uniform_continuous ⇑(completion_separation_quotient_equiv α).symm :=\nuniform_continuous_map\n\nend separation_quotient_completion\n\nsection prod\nvariables [uniform_space β]\nprotected def prod {α β} [uniform_space α] [uniform_space β] (p : completion α × completion β) : completion (α × β) :=\nquotient.lift_on₂ p.1 p.2 (λa b, ⟦Cauchy.prod (a, b)⟧) $ assume a b c d hab hcd,\n  quotient.sound $ separated_of_uniform_continuous uniform_continuous_prod $\n  separation_prod.2 ⟨hab, hcd⟩\n\nlemma uniform_continuous_prod : uniform_continuous (@completion.prod α β _ _) :=\nuniform_continuous_quotient_lift₂ $\n  suffices uniform_continuous (quotient.mk ∘ Cauchy.prod),\n  { convert this, ext ⟨a, b⟩, refl },\n  Cauchy.uniform_continuous_prod.comp uniform_continuous_quotient_mk\n\nlemma prod_coe_coe (a : α) (b : β) :\n  completion.prod ((a : completion α), (b : completion β)) = (a, b) :=\ncongr_arg quotient.mk $ Cauchy.prod_pure_cauchy_pure_cauchy a b\n\nend prod\n\nsection map₂\n\nprotected def map₂ (f : α → β → γ) (a : completion α) (b : completion β) : completion γ :=\ncompletion.map (λp:α×β, f p.1 p.2) (completion.prod (a, b))\n\nlemma uniform_continuous_map₂' (f : α → β → γ) :\n  uniform_continuous (λp:completion α×completion β, completion.map₂ f p.1 p.2) :=\nuniform_continuous.comp uniform_continuous_prod completion.uniform_continuous_map\n\nlemma continuous_map₂ {δ} [topological_space δ] {f : α → β → γ}\n  {a : δ → completion α} {b : δ → completion β} (ha : continuous a) (hb : continuous b) :\n  continuous (λd:δ, completion.map₂ f (a d) (b d)) :=\n(continuous.prod_mk ha hb).comp (uniform_continuous_map₂' f).continuous\n\nlemma map₂_coe_coe (a : α) (b : β) (f : α → β → γ) (hf : uniform_continuous (λp:α×β, f p.1 p.2)) :\n  completion.map₂ f (a : completion α) (b : completion β) = f a b :=\nby rw [completion.map₂, completion.prod_coe_coe, completion.map_coe hf]\n\nend map₂\nend completion\nend uniform_space\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/topology/uniform_space/completion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.48660181216597503}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Joseph Myers.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.invertible\nimport Mathlib.data.indicator_function\nimport Mathlib.linear_algebra.affine_space.affine_map\nimport Mathlib.linear_algebra.affine_space.affine_subspace\nimport Mathlib.linear_algebra.finsupp\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 \n\nnamespace Mathlib\n\n/-!\n# Affine combinations of points\n\nThis file defines affine combinations of points.\n\n## Main definitions\n\n* `weighted_vsub_of_point` is a general weighted combination of\n  subtractions with an explicit base point, yielding a vector.\n\n* `weighted_vsub` uses an arbitrary choice of base point and is intended\n  to be used when the sum of weights is 0, in which case the result is\n  independent of the choice of base point.\n\n* `affine_combination` adds the weighted combination to the arbitrary\n  base point, yielding a point rather than a vector, and is intended\n  to be used when the sum of weights is 1, in which case the result is\n  independent of the choice of base point.\n\nThese definitions are for sums over a `finset`; versions for a\n`fintype` may be obtained using `finset.univ`, while versions for a\n`finsupp` may be obtained using `finsupp.support`.\n\n## References\n\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nnamespace finset\n\n\n/-- A weighted sum of the results of subtracting a base point from the\ngiven points, as a linear map on the weights.  The main cases of\ninterest are where the sum of the weights is 0, in which case the sum\nis independent of the choice of base point, and where the sum of the\nweights is 1, in which case the sum added to the base point is\nindependent of the choice of base point. -/\ndef weighted_vsub_of_point {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (p : ι → P) (b : P) : linear_map k (ι → k) V :=\n  finset.sum s fun (i : ι) => linear_map.smul_right (linear_map.proj i) (p i -ᵥ b)\n\n@[simp] theorem weighted_vsub_of_point_apply {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (b : P) : coe_fn (weighted_vsub_of_point s p b) w = finset.sum s fun (i : ι) => w i • (p i -ᵥ b) := sorry\n\n/-- The weighted sum is independent of the base point when the sum of\nthe weights is 0. -/\ntheorem weighted_vsub_of_point_eq_of_sum_eq_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : (finset.sum s fun (i : ι) => w i) = 0) (b₁ : P) (b₂ : P) : coe_fn (weighted_vsub_of_point s p b₁) w = coe_fn (weighted_vsub_of_point s p b₂) w := sorry\n\n/-- The weighted sum, added to the base point, is independent of the\nbase point when the sum of the weights is 1. -/\ntheorem weighted_vsub_of_point_vadd_eq_of_sum_eq_one {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : (finset.sum s fun (i : ι) => w i) = 1) (b₁ : P) (b₂ : P) : coe_fn (weighted_vsub_of_point s p b₁) w +ᵥ b₁ = coe_fn (weighted_vsub_of_point s p b₂) w +ᵥ b₂ := sorry\n\n/-- The weighted sum is unaffected by removing the base point, if\npresent, from the set of points. -/\n@[simp] theorem weighted_vsub_of_point_erase {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (i : ι) : coe_fn (weighted_vsub_of_point (erase s i) p (p i)) w = coe_fn (weighted_vsub_of_point s p (p i)) w := sorry\n\n/-- The weighted sum is unaffected by adding the base point, whether\nor not present, to the set of points. -/\n@[simp] theorem weighted_vsub_of_point_insert {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (i : ι) : coe_fn (weighted_vsub_of_point (insert i s) p (p i)) w = coe_fn (weighted_vsub_of_point s p (p i)) w := sorry\n\n/-- The weighted sum is unaffected by changing the weights to the\ncorresponding indicator function and adding points to the set. -/\ntheorem weighted_vsub_of_point_indicator_subset {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (w : ι → k) (p : ι → P) (b : P) {s₁ : finset ι} {s₂ : finset ι} (h : s₁ ⊆ s₂) : coe_fn (weighted_vsub_of_point s₁ p b) w = coe_fn (weighted_vsub_of_point s₂ p b) (set.indicator (↑s₁) w) := sorry\n\n/-- A weighted sum, over the image of an embedding, equals a weighted\nsum with the same points and weights over the original\n`finset`. -/\ntheorem weighted_vsub_of_point_map {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) (b : P) : coe_fn (weighted_vsub_of_point (map e s₂) p b) w = coe_fn (weighted_vsub_of_point s₂ (p ∘ ⇑e) b) (w ∘ ⇑e) := sorry\n\n/-- A weighted sum of the results of subtracting a default base point\nfrom the given points, as a linear map on the weights.  This is\nintended to be used when the sum of the weights is 0; that condition\nis specified as a hypothesis on those lemmas that require it. -/\ndef weighted_vsub {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (p : ι → P) : linear_map k (ι → k) V :=\n  weighted_vsub_of_point s p (Classical.choice sorry)\n\n/-- Applying `weighted_vsub` with given weights.  This is for the case\nwhere a result involving a default base point is OK (for example, when\nthat base point will cancel out later); a more typical use case for\n`weighted_vsub` would involve selecting a preferred base point with\n`weighted_vsub_eq_weighted_vsub_of_point_of_sum_eq_zero` and then\nusing `weighted_vsub_of_point_apply`. -/\ntheorem weighted_vsub_apply {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) : coe_fn (weighted_vsub s p) w = finset.sum s fun (i : ι) => w i • (p i -ᵥ Classical.choice add_torsor.nonempty) := sorry\n\n/-- `weighted_vsub` gives the sum of the results of subtracting any\nbase point, when the sum of the weights is 0. -/\ntheorem weighted_vsub_eq_weighted_vsub_of_point_of_sum_eq_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : (finset.sum s fun (i : ι) => w i) = 0) (b : P) : coe_fn (weighted_vsub s p) w = coe_fn (weighted_vsub_of_point s p b) w :=\n  weighted_vsub_of_point_eq_of_sum_eq_zero s w p h (Classical.choice weighted_vsub._proof_1) b\n\n/-- The `weighted_vsub` for an empty set is 0. -/\n@[simp] theorem weighted_vsub_empty {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (w : ι → k) (p : ι → P) : coe_fn (weighted_vsub ∅ p) w = 0 := sorry\n\n/-- The weighted sum is unaffected by changing the weights to the\ncorresponding indicator function and adding points to the set. -/\ntheorem weighted_vsub_indicator_subset {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (w : ι → k) (p : ι → P) {s₁ : finset ι} {s₂ : finset ι} (h : s₁ ⊆ s₂) : coe_fn (weighted_vsub s₁ p) w = coe_fn (weighted_vsub s₂ p) (set.indicator (↑s₁) w) :=\n  weighted_vsub_of_point_indicator_subset w p (Classical.choice weighted_vsub._proof_1) h\n\n/-- A weighted subtraction, over the image of an embedding, equals a\nweighted subtraction with the same points and weights over the\noriginal `finset`. -/\ntheorem weighted_vsub_map {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) : coe_fn (weighted_vsub (map e s₂) p) w = coe_fn (weighted_vsub s₂ (p ∘ ⇑e)) (w ∘ ⇑e) :=\n  weighted_vsub_of_point_map s₂ e w p (Classical.choice weighted_vsub._proof_1)\n\n/-- A weighted sum of the results of subtracting a default base point\nfrom the given points, added to that base point, as an affine map on\nthe weights.  This is intended to be used when the sum of the weights\nis 1, in which case it is an affine combination (barycenter) of the\npoints with the given weights; that condition is specified as a\nhypothesis on those lemmas that require it. -/\ndef affine_combination {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (p : ι → P) : affine_map k (ι → k) P :=\n  affine_map.mk\n    (fun (w : ι → k) => coe_fn (weighted_vsub_of_point s p (Classical.choice sorry)) w +ᵥ Classical.choice sorry)\n    (weighted_vsub s p) sorry\n\n/-- The linear map corresponding to `affine_combination` is\n`weighted_vsub`. -/\n@[simp] theorem affine_combination_linear {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (p : ι → P) : affine_map.linear (affine_combination s p) = weighted_vsub s p :=\n  rfl\n\n/-- Applying `affine_combination` with given weights.  This is for the\ncase where a result involving a default base point is OK (for example,\nwhen that base point will cancel out later); a more typical use case\nfor `affine_combination` would involve selecting a preferred base\npoint with\n`affine_combination_eq_weighted_vsub_of_point_vadd_of_sum_eq_one` and\nthen using `weighted_vsub_of_point_apply`. -/\ntheorem affine_combination_apply {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) : coe_fn (affine_combination s p) w =\n  coe_fn (weighted_vsub_of_point s p (Classical.choice add_torsor.nonempty)) w +ᵥ Classical.choice add_torsor.nonempty :=\n  rfl\n\n/-- `affine_combination` gives the sum with any base point, when the\nsum of the weights is 1. -/\ntheorem affine_combination_eq_weighted_vsub_of_point_vadd_of_sum_eq_one {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) (h : (finset.sum s fun (i : ι) => w i) = 1) (b : P) : coe_fn (affine_combination s p) w = coe_fn (weighted_vsub_of_point s p b) w +ᵥ b :=\n  weighted_vsub_of_point_vadd_eq_of_sum_eq_one s w p h (Classical.choice affine_combination._proof_1) b\n\n/-- Adding a `weighted_vsub` to an `affine_combination`. -/\ntheorem weighted_vsub_vadd_affine_combination {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w₁ : ι → k) (w₂ : ι → k) (p : ι → P) : coe_fn (weighted_vsub s p) w₁ +ᵥ coe_fn (affine_combination s p) w₂ = coe_fn (affine_combination s p) (w₁ + w₂) := sorry\n\n/-- Subtracting two `affine_combination`s. -/\ntheorem affine_combination_vsub {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w₁ : ι → k) (w₂ : ι → k) (p : ι → P) : coe_fn (affine_combination s p) w₁ -ᵥ coe_fn (affine_combination s p) w₂ = coe_fn (weighted_vsub s p) (w₁ - w₂) := sorry\n\n/-- An `affine_combination` equals a point if that point is in the set\nand has weight 1 and the other points in the set have weight 0. -/\n@[simp] theorem affine_combination_of_eq_one_of_eq_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) (p : ι → P) {i : ι} (his : i ∈ s) (hwi : w i = 1) (hw0 : ∀ (i2 : ι), i2 ∈ s → i2 ≠ i → w i2 = 0) : coe_fn (affine_combination s p) w = p i := sorry\n\n/-- An affine combination is unaffected by changing the weights to the\ncorresponding indicator function and adding points to the set. -/\ntheorem affine_combination_indicator_subset {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} (w : ι → k) (p : ι → P) {s₁ : finset ι} {s₂ : finset ι} (h : s₁ ⊆ s₂) : coe_fn (affine_combination s₁ p) w = coe_fn (affine_combination s₂ p) (set.indicator (↑s₁) w) := sorry\n\n/-- An affine combination, over the image of an embedding, equals an\naffine combination with the same points and weights over the original\n`finset`. -/\ntheorem affine_combination_map {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) : coe_fn (affine_combination (map e s₂) p) w = coe_fn (affine_combination s₂ (p ∘ ⇑e)) (w ∘ ⇑e) := sorry\n\n/-- Suppose an indexed family of points is given, along with a subset\nof the index type.  A vector can be expressed as\n`weighted_vsub_of_point` using a `finset` lying within that subset and\nwith a given sum of weights if and only if it can be expressed as\n`weighted_vsub_of_point` with that sum of weights for the\ncorresponding indexed family whose index type is the subtype\ncorresponding to that subset. -/\ntheorem eq_weighted_vsub_of_point_subset_iff_eq_weighted_vsub_of_point_subtype {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} {v : V} {x : k} {s : set ι} {p : ι → P} {b : P} : (∃ (fs : finset ι),\n    ∃ (hfs : ↑fs ⊆ s),\n      ∃ (w : ι → k), ∃ (hw : (finset.sum fs fun (i : ι) => w i) = x), v = coe_fn (weighted_vsub_of_point fs p b) w) ↔\n  ∃ (fs : finset ↥s),\n    ∃ (w : ↥s → k),\n      ∃ (hw : (finset.sum fs fun (i : ↥s) => w i) = x),\n        v = coe_fn (weighted_vsub_of_point fs (fun (i : ↥s) => p ↑i) b) w := sorry\n\n/-- Suppose an indexed family of points is given, along with a subset\nof the index type.  A vector can be expressed as `weighted_vsub` using\na `finset` lying within that subset and with sum of weights 0 if and\nonly if it can be expressed as `weighted_vsub` with sum of weights 0\nfor the corresponding indexed family whose index type is the subtype\ncorresponding to that subset. -/\ntheorem eq_weighted_vsub_subset_iff_eq_weighted_vsub_subtype (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} {v : V} {s : set ι} {p : ι → P} : (∃ (fs : finset ι),\n    ∃ (hfs : ↑fs ⊆ s),\n      ∃ (w : ι → k), ∃ (hw : (finset.sum fs fun (i : ι) => w i) = 0), v = coe_fn (weighted_vsub fs p) w) ↔\n  ∃ (fs : finset ↥s),\n    ∃ (w : ↥s → k),\n      ∃ (hw : (finset.sum fs fun (i : ↥s) => w i) = 0), v = coe_fn (weighted_vsub fs fun (i : ↥s) => p ↑i) w :=\n  eq_weighted_vsub_of_point_subset_iff_eq_weighted_vsub_of_point_subtype\n\n/-- Suppose an indexed family of points is given, along with a subset\nof the index type.  A point can be expressed as an\n`affine_combination` using a `finset` lying within that subset and\nwith sum of weights 1 if and only if it can be expressed an\n`affine_combination` with sum of weights 1 for the corresponding\nindexed family whose index type is the subtype corresponding to that\nsubset. -/\ntheorem eq_affine_combination_subset_iff_eq_affine_combination_subtype (k : Type u_1) (V : Type u_2) {P : Type u_3} [ring k] [add_comm_group V] [module k V] [S : add_torsor V P] {ι : Type u_4} {p0 : P} {s : set ι} {p : ι → P} : (∃ (fs : finset ι),\n    ∃ (hfs : ↑fs ⊆ s),\n      ∃ (w : ι → k), ∃ (hw : (finset.sum fs fun (i : ι) => w i) = 1), p0 = coe_fn (affine_combination fs p) w) ↔\n  ∃ (fs : finset ↥s),\n    ∃ (w : ↥s → k),\n      ∃ (hw : (finset.sum fs fun (i : ↥s) => w i) = 1), p0 = coe_fn (affine_combination fs fun (i : ↥s) => p ↑i) w := sorry\n\nend finset\n\n\nnamespace finset\n\n\n/-- The weights for the centroid of some points. -/\ndef centroid_weights (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) : ι → k :=\n  function.const ι (↑(card s)⁻¹)\n\n/-- `centroid_weights` at any point. -/\n@[simp] theorem centroid_weights_apply (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) (i : ι) : centroid_weights k s i = (↑(card s)⁻¹) :=\n  rfl\n\n/-- `centroid_weights` equals a constant function. -/\ntheorem centroid_weights_eq_const (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) : centroid_weights k s = function.const ι (↑(card s)⁻¹) :=\n  rfl\n\n/-- The weights in the centroid sum to 1, if the number of points,\nconverted to `k`, is not zero. -/\ntheorem sum_centroid_weights_eq_one_of_cast_card_ne_zero {k : Type u_1} [division_ring k] {ι : Type u_4} (s : finset ι) (h : ↑(card s) ≠ 0) : (finset.sum s fun (i : ι) => centroid_weights k s i) = 1 := sorry\n\n/-- In the characteristic zero case, the weights in the centroid sum\nto 1 if the number of points is not zero. -/\ntheorem sum_centroid_weights_eq_one_of_card_ne_zero (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) [char_zero k] (h : card s ≠ 0) : (finset.sum s fun (i : ι) => centroid_weights k s i) = 1 := sorry\n\n/-- In the characteristic zero case, the weights in the centroid sum\nto 1 if the set is nonempty. -/\ntheorem sum_centroid_weights_eq_one_of_nonempty (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) [char_zero k] (h : finset.nonempty s) : (finset.sum s fun (i : ι) => centroid_weights k s i) = 1 :=\n  sum_centroid_weights_eq_one_of_card_ne_zero k s (ne_of_gt (iff.mpr card_pos h))\n\n/-- In the characteristic zero case, the weights in the centroid sum\nto 1 if the number of points is `n + 1`. -/\ntheorem sum_centroid_weights_eq_one_of_card_eq_add_one (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) [char_zero k] {n : ℕ} (h : card s = n + 1) : (finset.sum s fun (i : ι) => centroid_weights k s i) = 1 :=\n  sum_centroid_weights_eq_one_of_card_ne_zero k s (Eq.symm h ▸ nat.succ_ne_zero n)\n\n/-- The centroid of some points.  Although defined for any `s`, this\nis intended to be used in the case where the number of points,\nconverted to `k`, is not zero. -/\ndef centroid (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (s : finset ι) (p : ι → P) : P :=\n  coe_fn (affine_combination s p) (centroid_weights k s)\n\n/-- The definition of the centroid. -/\ntheorem centroid_def (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (s : finset ι) (p : ι → P) : centroid k s p = coe_fn (affine_combination s p) (centroid_weights k s) :=\n  rfl\n\n/-- The centroid of a single point. -/\n@[simp] theorem centroid_singleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (p : ι → P) (i : ι) : centroid k (singleton i) p = p i := sorry\n\n/-- The centroid of two points, expressed directly as adding a vector\nto a point. -/\ntheorem centroid_insert_singleton (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [invertible (bit0 1)] (p : ι → P) (i₁ : ι) (i₂ : ι) : centroid k (insert i₁ (singleton i₂)) p = bit0 1⁻¹ • (p i₂ -ᵥ p i₁) +ᵥ p i₁ := sorry\n\n/-- The centroid of two points indexed by `fin 2`, expressed directly\nas adding a vector to the first point. -/\ntheorem centroid_insert_singleton_fin (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] [invertible (bit0 1)] (p : fin (bit0 1) → P) : centroid k univ p = bit0 1⁻¹ • (p 1 -ᵥ p 0) +ᵥ p 0 := sorry\n\n/-- A centroid, over the image of an embedding, equals a centroid with\nthe same points and weights over the original `finset`. -/\ntheorem centroid_map (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {ι₂ : Type u_5} (s₂ : finset ι₂) (e : ι₂ ↪ ι) (p : ι → P) : centroid k (map e s₂) p = centroid k s₂ (p ∘ ⇑e) := sorry\n\n/-- `centroid_weights` gives the weights for the centroid as a\nconstant function, which is suitable when summing over the points\nwhose centroid is being taken.  This function gives the weights in a\nform suitable for summing over a larger set of points, as an indicator\nfunction that is zero outside the set whose centroid is being taken.\nIn the case of a `fintype`, the sum may be over `univ`. -/\ndef centroid_weights_indicator (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) : ι → k :=\n  set.indicator (↑s) (centroid_weights k s)\n\n/-- The definition of `centroid_weights_indicator`. -/\ntheorem centroid_weights_indicator_def (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) : centroid_weights_indicator k s = set.indicator (↑s) (centroid_weights k s) :=\n  rfl\n\n/-- The sum of the weights for the centroid indexed by a `fintype`. -/\ntheorem sum_centroid_weights_indicator (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) [fintype ι] : (finset.sum univ fun (i : ι) => centroid_weights_indicator k s i) = finset.sum s fun (i : ι) => centroid_weights k s i :=\n  Eq.symm (set.sum_indicator_subset (fun (i : ι) => centroid_weights k s i) (subset_univ s))\n\n/-- In the characteristic zero case, the weights in the centroid\nindexed by a `fintype` sum to 1 if the number of points is not\nzero. -/\ntheorem sum_centroid_weights_indicator_eq_one_of_card_ne_zero (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) [char_zero k] [fintype ι] (h : card s ≠ 0) : (finset.sum univ fun (i : ι) => centroid_weights_indicator k s i) = 1 := sorry\n\n/-- In the characteristic zero case, the weights in the centroid\nindexed by a `fintype` sum to 1 if the set is nonempty. -/\ntheorem sum_centroid_weights_indicator_eq_one_of_nonempty (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) [char_zero k] [fintype ι] (h : finset.nonempty s) : (finset.sum univ fun (i : ι) => centroid_weights_indicator k s i) = 1 := sorry\n\n/-- In the characteristic zero case, the weights in the centroid\nindexed by a `fintype` sum to 1 if the number of points is `n + 1`. -/\ntheorem sum_centroid_weights_indicator_eq_one_of_card_eq_add_one (k : Type u_1) [division_ring k] {ι : Type u_4} (s : finset ι) [char_zero k] [fintype ι] {n : ℕ} (h : card s = n + 1) : (finset.sum univ fun (i : ι) => centroid_weights_indicator k s i) = 1 := sorry\n\n/-- The centroid as an affine combination over a `fintype`. -/\ntheorem centroid_eq_affine_combination_fintype (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (s : finset ι) [fintype ι] (p : ι → P) : centroid k s p = coe_fn (affine_combination univ p) (centroid_weights_indicator k s) :=\n  affine_combination_indicator_subset (centroid_weights k s) p (subset_univ s)\n\n/-- An indexed family of points that is injective on the given\n`finset` has the same centroid as the image of that `finset`.  This is\nstated in terms of a set equal to the image to provide control of\ndefinitional equality for the index type used for the centroid of the\nimage. -/\ntheorem centroid_eq_centroid_image_of_inj_on (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (s : finset ι) {p : ι → P} (hi : ∀ (i j : ι), i ∈ s → j ∈ s → p i = p j → i = j) {ps : set P} [fintype ↥ps] (hps : ps = p '' ↑s) : centroid k s p = centroid k univ fun (x : ↥ps) => ↑x := sorry\n\n/-- Two indexed families of points that are injective on the given\n`finset`s and with the same points in the image of those `finset`s\nhave the same centroid. -/\ntheorem centroid_eq_of_inj_on_of_image_eq (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (s : finset ι) {ι₂ : Type u_5} (s₂ : finset ι₂) {p : ι → P} (hi : ∀ (i j : ι), i ∈ s → j ∈ s → p i = p j → i = j) {p₂ : ι₂ → P} (hi₂ : ∀ (i j : ι₂), i ∈ s₂ → j ∈ s₂ → p₂ i = p₂ j → i = j) (he : p '' ↑s = p₂ '' ↑s₂) : centroid k s p = centroid k s₂ p₂ := sorry\n\nend finset\n\n\n/-- A `weighted_vsub` with sum of weights 0 is in the `vector_span` of\nan indexed family. -/\ntheorem weighted_vsub_mem_vector_span {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {s : finset ι} {w : ι → k} (h : (finset.sum s fun (i : ι) => w i) = 0) (p : ι → P) : coe_fn (finset.weighted_vsub s p) w ∈ vector_span k (set.range p) := sorry\n\n/-- An `affine_combination` with sum of weights 1 is in the\n`affine_span` of an indexed family, if the underlying ring is\nnontrivial. -/\ntheorem affine_combination_mem_affine_span {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {s : finset ι} {w : ι → k} (h : (finset.sum s fun (i : ι) => w i) = 1) (p : ι → P) : coe_fn (finset.affine_combination s p) w ∈ affine_span k (set.range p) := sorry\n\n/-- A vector is in the `vector_span` of an indexed family if and only\nif it is a `weighted_vsub` with sum of weights 0. -/\ntheorem mem_vector_span_iff_eq_weighted_vsub (k : Type u_1) {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {v : V} {p : ι → P} : v ∈ vector_span k (set.range p) ↔\n  ∃ (s : finset ι),\n    ∃ (w : ι → k), ∃ (h : (finset.sum s fun (i : ι) => w i) = 0), v = coe_fn (finset.weighted_vsub s p) w := sorry\n\n/-- A point in the `affine_span` of an indexed family is an\n`affine_combination` with sum of weights 1. -/\ntheorem eq_affine_combination_of_mem_affine_span {k : Type u_1} {V : Type u_2} {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {p1 : P} {p : ι → P} (h : p1 ∈ affine_span k (set.range p)) : ∃ (s : finset ι),\n  ∃ (w : ι → k), ∃ (hw : (finset.sum s fun (i : ι) => w i) = 1), p1 = coe_fn (finset.affine_combination s p) w := sorry\n\n/-- A point is in the `affine_span` of an indexed family if and only\nif it is an `affine_combination` with sum of weights 1, provided the\nunderlying ring is nontrivial. -/\ntheorem mem_affine_span_iff_eq_affine_combination (k : Type u_1) (V : Type u_2) {P : Type u_3} [ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [nontrivial k] {p1 : P} {p : ι → P} : p1 ∈ affine_span k (set.range p) ↔\n  ∃ (s : finset ι),\n    ∃ (w : ι → k), ∃ (hw : (finset.sum s fun (i : ι) => w i) = 1), p1 = coe_fn (finset.affine_combination s p) w := sorry\n\n/-- The centroid lies in the affine span if the number of points,\nconverted to `k`, is not zero. -/\ntheorem centroid_mem_affine_span_of_cast_card_ne_zero {k : Type u_1} {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} {s : finset ι} (p : ι → P) (h : ↑(finset.card s) ≠ 0) : finset.centroid k s p ∈ affine_span k (set.range p) :=\n  affine_combination_mem_affine_span (finset.sum_centroid_weights_eq_one_of_cast_card_ne_zero s h) p\n\n/-- In the characteristic zero case, the centroid lies in the affine\nspan if the number of points is not zero. -/\ntheorem centroid_mem_affine_span_of_card_ne_zero (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [char_zero k] {s : finset ι} (p : ι → P) (h : finset.card s ≠ 0) : finset.centroid k s p ∈ affine_span k (set.range p) :=\n  affine_combination_mem_affine_span (finset.sum_centroid_weights_eq_one_of_card_ne_zero k s h) p\n\n/-- In the characteristic zero case, the centroid lies in the affine\nspan if the set is nonempty. -/\ntheorem centroid_mem_affine_span_of_nonempty (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [char_zero k] {s : finset ι} (p : ι → P) (h : finset.nonempty s) : finset.centroid k s p ∈ affine_span k (set.range p) :=\n  affine_combination_mem_affine_span (finset.sum_centroid_weights_eq_one_of_nonempty k s h) p\n\n/-- In the characteristic zero case, the centroid lies in the affine\nspan if the number of points is `n + 1`. -/\ntheorem centroid_mem_affine_span_of_card_eq_add_one (k : Type u_1) {V : Type u_2} {P : Type u_3} [division_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} [char_zero k] {s : finset ι} (p : ι → P) {n : ℕ} (h : finset.card s = n + 1) : finset.centroid k s p ∈ affine_span k (set.range p) :=\n  affine_combination_mem_affine_span (finset.sum_centroid_weights_eq_one_of_card_eq_add_one k s h) p\n\nnamespace affine_map\n\n\n-- TODO: define `affine_map.proj`, `affine_map.fst`, `affine_map.snd`\n\n/-- A weighted sum, as an affine map on the points involved. -/\ndef weighted_vsub_of_point {k : Type u_1} {V : Type u_2} (P : Type u_3) [comm_ring k] [add_comm_group V] [module k V] [add_torsor V P] {ι : Type u_4} (s : finset ι) (w : ι → k) : affine_map k ((ι → P) × P) V :=\n  mk (fun (p : (ι → P) × P) => coe_fn (finset.weighted_vsub_of_point s (prod.fst p) (prod.snd p)) w)\n    (finset.sum s\n      fun (i : ι) =>\n        w i • (linear_map.comp (linear_map.proj i) (linear_map.fst k (ι → V) V) - linear_map.snd k (ι → V) V))\n    sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/affine_space/combination.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4866018077087108}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nCoinductive formalization of unbounded computations.\n\n! This file was ported from Lean 3 source module data.seq.computation\n! leanprover-community/mathlib commit 1f0096e6caa61e9c849ec2adbd227e960e9dff58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Stream.Init\nimport Mathlib.Tactic.Basic\n\n/-!\n# Coinductive formalization of unbounded computations.\n\nThis file provides a `Computation` type where `Computation α` is the type of\nunbounded computations returning `α`.\n-/\n\n\nopen Function\n\nuniverse u v w\n\n/-\ncoinductive Computation (α : Type u) : Type u\n| pure : α → Computation α\n| think : Computation α → Xomputation α\n-/\n/-- `Computation α` is the type of unbounded computations returning `α`.\n  An element of `Computation α` is an infinite sequence of `Option α` such\n  that if `f n = some a` for some `n` then it is constantly `some a` after that. -/\ndef Computation (α : Type u) : Type u :=\n  { f : Stream' (Option α) // ∀ ⦃n a⦄, f n = some a → f (n + 1) = some a }\n#align computation Computation\n\nnamespace Computation\n\nvariable {α : Type u} {β : Type v} {γ : Type w}\n\n-- constructors\n/-- `pure a` is the computation that immediately terminates with result `a`. -/\n-- porting notes: `return` is reserved, so changed to `pure`\ndef pure (a : α) : Computation α :=\n  ⟨Stream'.const (some a), fun _ _ => id⟩\n#align computation.return Computation.pure\n\ninstance : CoeTC α (Computation α) :=\n  ⟨pure⟩\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n-- note [use has_coe_t]\n/-- `think c` is the computation that delays for one \"tick\" and then performs\n  computation `c`. -/\ndef think (c : Computation α) : Computation α :=\n  ⟨Stream'.cons none c.1, fun n a h => by\n    cases' n with n\n    . contradiction\n    . exact c.2 h⟩\n#align computation.think Computation.think\n\n/-- `thinkN c n` is the computation that delays for `n` ticks and then performs\n  computation `c`. -/\ndef thinkN (c : Computation α) : ℕ → Computation α\n  | 0 => c\n  | n + 1 => think (thinkN c n)\nset_option linter.uppercaseLean3 false in\n#align computation.thinkN Computation.thinkN\n\n-- check for immediate result\n/-- `head c` is the first step of computation, either `some a` if `c = pure a`\n  or `none` if `c = think c'`. -/\ndef head (c : Computation α) : Option α :=\n  c.1.head\n#align computation.head Computation.head\n\n-- one step of computation\n/-- `tail c` is the remainder of computation, either `c` if `c = pure a`\n  or `c'` if `c = think c'`. -/\ndef tail (c : Computation α) : Computation α :=\n  ⟨c.1.tail, fun _ _ h => c.2 h⟩\n#align computation.tail Computation.tail\n\n/-- `empty α` is the computation that never returns, an infinite sequence of\n  `think`s. -/\ndef empty (α) : Computation α :=\n  ⟨Stream'.const none, fun _ _ => id⟩\n#align computation.empty Computation.empty\n\ninstance : Inhabited (Computation α) :=\n  ⟨empty _⟩\n\n/-- `run_for c n` evaluates `c` for `n` steps and returns the result, or `none`\n  if it did not terminate after `n` steps. -/\ndef runFor : Computation α → ℕ → Option α :=\n  Subtype.val\n#align computation.run_for Computation.runFor\n\n/-- `destruct c` is the destructor for `Computation α` as a coinductive type.\n  It returns `inl a` if `c = pure a` and `inr c'` if `c = think c'`. -/\ndef destruct (c : Computation α) : Sum α (Computation α) :=\n  match c.1 0 with\n  | none => Sum.inr (tail c)\n  | some a => Sum.inl a\n#align computation.destruct Computation.destruct\n\n/-- `run c` is an unsound meta function that runs `c` to completion, possibly\n  resulting in an infinite loop in the VM. -/\nunsafe def run : Computation α → α\n  | c =>\n    match destruct c with\n    | Sum.inl a => a\n    | Sum.inr ca => run ca\n#align computation.run Computation.run\n\ntheorem destruct_eq_pure {s : Computation α} {a : α} : destruct s = Sum.inl a → s = pure a := by\n  dsimp [destruct]\n  induction' f0 : s.1 0 with _ <;> intro h\n  · contradiction\n  · apply Subtype.eq\n    funext n\n    induction' n with n IH\n    · injection h with h'\n      rwa [h'] at f0\n    · exact s.2 IH\n#align computation.destruct_eq_ret Computation.destruct_eq_pure\n\ntheorem destruct_eq_think {s : Computation α} {s'} : destruct s = Sum.inr s' → s = think s' := by\n  dsimp [destruct]\n  induction' f0 : s.1 0 with a' <;> intro h\n  · injection h with h'\n    rw [← h']\n    cases' s with f al\n    apply Subtype.eq\n    dsimp [think, tail]\n    rw [← f0]\n    exact (Stream'.eta f).symm\n  · contradiction\n#align computation.destruct_eq_think Computation.destruct_eq_think\n\n@[simp]\ntheorem destruct_pure (a : α) : destruct (pure a) = Sum.inl a :=\n  rfl\n#align computation.destruct_ret Computation.destruct_pure\n\n@[simp]\ntheorem destruct_think : ∀ s : Computation α, destruct (think s) = Sum.inr s\n  | ⟨_, _⟩ => rfl\n#align computation.destruct_think Computation.destruct_think\n\n@[simp]\ntheorem destruct_empty : destruct (empty α) = Sum.inr (empty α) :=\n  rfl\n#align computation.destruct_empty Computation.destruct_empty\n\n@[simp]\ntheorem head_pure (a : α) : head (pure a) = some a :=\n  rfl\n#align computation.head_ret Computation.head_pure\n\n@[simp]\ntheorem head_think (s : Computation α) : head (think s) = none :=\n  rfl\n#align computation.head_think Computation.head_think\n\n@[simp]\ntheorem head_empty : head (empty α) = none :=\n  rfl\n#align computation.head_empty Computation.head_empty\n\n@[simp]\ntheorem tail_pure (a : α) : tail (pure a) = pure a :=\n  rfl\n#align computation.tail_ret Computation.tail_pure\n\n@[simp]\ntheorem tail_think (s : Computation α) : tail (think s) = s := by\n  cases' s with f al ; apply Subtype.eq ; dsimp [tail, think] ; rw [Stream'.tail_cons]\n#align computation.tail_think Computation.tail_think\n\n@[simp]\ntheorem tail_empty : tail (empty α) = empty α :=\n  rfl\n#align computation.tail_empty Computation.tail_empty\n\ntheorem think_empty : empty α = think (empty α) :=\n  destruct_eq_think destruct_empty\n#align computation.think_empty Computation.think_empty\n\n/-- Recursion principle for computations, compare with `List.recOn`. -/\ndef recOn {C : Computation α → Sort v} (s : Computation α) (h1 : ∀ a, C (pure a))\n    (h2 : ∀ s, C (think s)) : C s :=\n    match H: (destruct s) with\n    | Sum.inl v => by\n      rw [destruct_eq_pure H]\n      apply h1\n    | Sum.inr v => match v with\n      | ⟨a, s'⟩ => by\n        rw [destruct_eq_think H]\n        apply h2\n#align computation.rec_on Computation.recOn\n\n/-- Corecursor constructor for `corec`-/\ndef Corec.f (f : β → Sum α β) : Sum α β → Option α × Sum α β\n  | Sum.inl a => (some a, Sum.inl a)\n  | Sum.inr b =>\n    (match f b with\n      | Sum.inl a => some a\n      | Sum.inr _ => none,\n      f b)\nset_option linter.uppercaseLean3 false in\n#align computation.corec.F Computation.Corec.f\n\n/-- `corec f b` is the corecursor for `Computation α` as a coinductive type.\n  If `f b = inl a` then `corec f b = pure a`, and if `f b = inl b'` then\n  `corec f b = think (corec f b')`. -/\ndef corec (f : β → Sum α β) (b : β) : Computation α := by\n  refine' ⟨Stream'.corec' (Corec.f f) (Sum.inr b), fun n a' h => _⟩\n  rw [Stream'.corec'_eq]\n  change Stream'.corec' (Corec.f f) (Corec.f f (Sum.inr b)).2 n = some a'\n  revert h; generalize Sum.inr b = o; revert o\n  induction' n with n IH <;> intro o\n  · change (Corec.f f o).1 = some a' → (Corec.f f (Corec.f f o).2).1 = some a'\n    cases' o with _ b <;> intro h\n    · exact h\n    unfold Corec.f at *; split <;> simp_all\n  · rw [Stream'.corec'_eq (Corec.f f) (Corec.f f o).2, Stream'.corec'_eq (Corec.f f) o]\n    exact IH (Corec.f f o).2\n#align computation.corec Computation.corec\n\n/-- left map of `⊕` -/\ndef lmap (f : α → β) : Sum α γ → Sum β γ\n  | Sum.inl a => Sum.inl (f a)\n  | Sum.inr b => Sum.inr b\n#align computation.lmap Computation.lmap\n\n/-- right map of `⊕` -/\ndef rmap (f : β → γ) : Sum α β → Sum α γ\n  | Sum.inl a => Sum.inl a\n  | Sum.inr b => Sum.inr (f b)\n#align computation.rmap Computation.rmap\n\nattribute [simp] lmap rmap\n\n-- porting note: this was far less painful in mathlib3. There seem to be two issues;\n-- firstly, in mathlib3 we have `corec.F._match_1` and it's the obvious map α ⊕ β → option α.\n-- In mathlib4 we have `Corec.f.match_1` and it's something completely different.\n-- Secondly, the proof that `Stream'.corec' (Corec.f f) (Sum.inr b) 0` is this function\n-- evaluated at `f b`, used to be `rfl` and now is `cases, rfl`.\n@[simp]\ntheorem corec_eq (f : β → Sum α β) (b : β) : destruct (corec f b) = rmap (corec f) (f b) := by\n  dsimp [corec, destruct]\n  rw [show Stream'.corec' (Corec.f f) (Sum.inr b) 0 =\n    Sum.rec Option.some (λ _ => none) (f b) by\n    dsimp [Corec.f, Stream'.corec', Stream'.corec, Stream'.map, Stream'.nth, Stream'.iterate]\n    match (f b) with\n    | Sum.inl x => rfl\n    | Sum.inr x => rfl\n    ]\n  induction' h : f b with a b'; · rfl\n  dsimp [Corec.f, destruct]\n  apply congr_arg; apply Subtype.eq\n  dsimp [corec, tail]\n  rw [Stream'.corec'_eq, Stream'.tail_cons]\n  dsimp [Corec.f]; rw [h]\n#align computation.corec_eq Computation.corec_eq\n\nsection Bisim\n\nvariable (R : Computation α → Computation α → Prop)\n\n-- mathport name: «expr ~ »\n/-- bisimilarity relation-/\nlocal infixl:50 \" ~ \" => R\n\n/-- Bisimilarity over a sum of `Computation`s-/\ndef BisimO : Sum α (Computation α) → Sum α (Computation α) → Prop\n  | Sum.inl a, Sum.inl a' => a = a'\n  | Sum.inr s, Sum.inr s' => R s s'\n  | _, _ => False\n#align computation.bisim_o Computation.BisimO\n\nattribute [simp] BisimO\n\n/-- Attribute expressing bisimilarity over two `Computation`s-/\ndef IsBisimulation :=\n  ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂)\n#align computation.is_bisimulation Computation.IsBisimulation\n\n-- If two computations are bisimilar, then they are equal\ntheorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s₁ = s₂ := by\n  apply Subtype.eq\n  apply Stream'.eq_of_bisim fun x y => ∃ s s' : Computation α, s.1 = x ∧ s'.1 = y ∧ R s s'\n  dsimp [Stream'.IsBisimulation]\n  intro t₁ t₂ e\n  exact\n    match t₁, t₂, e with\n    | _, _, ⟨s, s', rfl, rfl, r⟩ => by\n      suffices head s = head s' ∧ R (tail s) (tail s') from\n        And.imp id (fun r => ⟨tail s, tail s', by cases s; rfl, by cases s'; rfl, r⟩) this\n      have h := bisim r; revert r h\n      apply recOn s _ _ <;> intro r' <;> apply recOn s' _ _ <;> intro a' r h\n      · constructor <;> dsimp at h\n        . rw [h]\n        . rw [h] at r\n          rw [tail_pure, tail_pure,h]\n          assumption\n      · rw [destruct_pure, destruct_think] at h\n        exact False.elim h\n      · rw [destruct_pure, destruct_think] at h\n        exact False.elim h\n      · simp at h\n        simp [*]\n  exact ⟨s₁, s₂, rfl, rfl, r⟩\n#align computation.eq_of_bisim Computation.eq_of_bisim\n\nend Bisim\n\n-- It's more of a stretch to use ∈ for this relation, but it\n-- asserts that the computation limits to the given value.\n/-- Assertion that a `Computation` limits to a given value-/\nprotected def Mem (a : α) (s : Computation α) :=\n  some a ∈ s.1\n#align computation.mem Computation.Mem\n\ninstance : Membership α (Computation α) :=\n  ⟨Computation.Mem⟩\n\ntheorem le_stable (s : Computation α) {a m n} (h : m ≤ n) : s.1 m = some a → s.1 n = some a := by\n  cases' s with f al\n  induction' h with n _ IH\n  exacts[id, fun h2 => al (IH h2)]\n#align computation.le_stable Computation.le_stable\n\ntheorem mem_unique {s : Computation α} {a b : α} : a ∈ s → b ∈ s → a = b\n  | ⟨m, ha⟩, ⟨n, hb⟩ => by\n    injection\n      (le_stable s (le_max_left m n) ha.symm).symm.trans (le_stable s (le_max_right m n) hb.symm)\n#align computation.mem_unique Computation.mem_unique\n\ntheorem Mem.left_unique : Relator.LeftUnique ((· ∈ ·) : α → Computation α → Prop) := fun _ _ _ =>\n  mem_unique\n#align computation.mem.left_unique Computation.Mem.left_unique\n\n/-- `Terminates s` asserts that the computation `s` eventually terminates with some value. -/\nclass Terminates (s : Computation α) : Prop where\n  /-- assertion that there is some term `a` such that the `Computation` terminates -/\n  term : ∃ a, a ∈ s\n#align computation.terminates Computation.Terminates\n\ntheorem terminates_iff (s : Computation α) : Terminates s ↔ ∃ a, a ∈ s :=\n  ⟨fun h => h.1, Terminates.mk⟩\n#align computation.terminates_iff Computation.terminates_iff\n\ntheorem terminates_of_mem {s : Computation α} {a : α} (h : a ∈ s) : Terminates s :=\n  ⟨⟨a, h⟩⟩\n#align computation.terminates_of_mem Computation.terminates_of_mem\n\ntheorem terminates_def (s : Computation α) : Terminates s ↔ ∃ n, (s.1 n).isSome :=\n  ⟨fun ⟨⟨a, n, h⟩⟩ =>\n    ⟨n, by\n      dsimp [Stream'.nth] at h\n      rw [← h]\n      exact rfl⟩,\n    fun ⟨n, h⟩ => ⟨⟨Option.get _ h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩\n#align computation.terminates_def Computation.terminates_def\n\ntheorem ret_mem (a : α) : a ∈ pure a :=\n  Exists.intro 0 rfl\n#align computation.ret_mem Computation.ret_mem\n\ntheorem eq_of_pure_mem {a a' : α} (h : a' ∈ pure a) : a' = a :=\n  mem_unique h (ret_mem _)\n#align computation.eq_of_ret_mem Computation.eq_of_pure_mem\n\ninstance ret_terminates (a : α) : Terminates (pure a) :=\n  terminates_of_mem (ret_mem _)\n#align computation.ret_terminates Computation.ret_terminates\n\ntheorem think_mem {s : Computation α} {a} : a ∈ s → a ∈ think s\n  | ⟨n, h⟩ => ⟨n + 1, h⟩\n#align computation.think_mem Computation.think_mem\n\ninstance think_terminates (s : Computation α) : ∀ [Terminates s], Terminates (think s)\n  | ⟨⟨a, n, h⟩⟩ => ⟨⟨a, n + 1, h⟩⟩\n#align computation.think_terminates Computation.think_terminates\n\ntheorem of_think_mem {s : Computation α} {a} : a ∈ think s → a ∈ s\n  | ⟨n, h⟩ => by\n    cases' n with n'\n    contradiction\n    exact ⟨n', h⟩\n#align computation.of_think_mem Computation.of_think_mem\n\ntheorem of_think_terminates {s : Computation α} : Terminates (think s) → Terminates s\n  | ⟨⟨a, h⟩⟩ => ⟨⟨a, of_think_mem h⟩⟩\n#align computation.of_think_terminates Computation.of_think_terminates\n\ntheorem not_mem_empty (a : α) : a ∉ empty α := fun ⟨n, h⟩ => by contradiction\n#align computation.not_mem_empty Computation.not_mem_empty\n\ntheorem not_terminates_empty : ¬Terminates (empty α) := fun ⟨⟨a, h⟩⟩ => not_mem_empty a h\n#align computation.not_terminates_empty Computation.not_terminates_empty\n\ntheorem eq_empty_of_not_terminates {s} (H : ¬Terminates s) : s = empty α := by\n  apply Subtype.eq; funext n\n  induction' h : s.val n with _ ; · rfl\n  refine' absurd _ H; exact ⟨⟨_, _, h.symm⟩⟩\n#align computation.eq_empty_of_not_terminates Computation.eq_empty_of_not_terminates\n\ntheorem thinkN_mem {s : Computation α} {a} : ∀ n, a ∈ thinkN s n ↔ a ∈ s\n  | 0 => Iff.rfl\n  | n + 1 => Iff.trans ⟨of_think_mem, think_mem⟩ (thinkN_mem n)\nset_option linter.uppercaseLean3 false in\n#align computation.thinkN_mem Computation.thinkN_mem\n\ninstance thinkN_terminates (s : Computation α) : ∀ [Terminates s] (n), Terminates (thinkN s n)\n  | ⟨⟨a, h⟩⟩, n => ⟨⟨a, (thinkN_mem n).2 h⟩⟩\nset_option linter.uppercaseLean3 false in\n#align computation.thinkN_terminates Computation.thinkN_terminates\n\ntheorem of_thinkN_terminates (s : Computation α) (n) : Terminates (thinkN s n) → Terminates s\n  | ⟨⟨a, h⟩⟩ => ⟨⟨a, (thinkN_mem _).1 h⟩⟩\nset_option linter.uppercaseLean3 false in\n#align computation.of_thinkN_terminates Computation.of_thinkN_terminates\n\n/-- `Promises s a`, or `s ~> a`, asserts that although the computation `s`\n  may not terminate, if it does, then the result is `a`. -/\ndef Promises (s : Computation α) (a : α) : Prop :=\n  ∀ ⦃a'⦄, a' ∈ s → a = a'\n#align computation.promises Computation.Promises\n\n-- mathport name: «expr ~> »\n/-- `Promises s a`, or `s ~> a`, asserts that although the computation `s`\n  may not terminate, if it does, then the result is `a`. -/\nscoped infixl:50 \" ~> \" => Promises\n\ntheorem mem_promises {s : Computation α} {a : α} : a ∈ s → s ~> a := fun h _ => mem_unique h\n#align computation.mem_promises Computation.mem_promises\n\ntheorem empty_promises (a : α) : empty α ~> a := fun _ h => absurd h (not_mem_empty _)\n#align computation.empty_promises Computation.empty_promises\n\nsection get\n\nvariable (s : Computation α) [h : Terminates s]\n\n-- porting notes: no include?\n--include s h\n\n/-- `length s` gets the number of steps of a terminating computation -/\ndef length : ℕ :=\n  Nat.find ((terminates_def _).1 h)\n#align computation.length Computation.length\n\n/-- `get s` returns the result of a terminating computation -/\ndef get : α :=\n  Option.get _ (Nat.find_spec <| (terminates_def _).1 h)\n#align computation.get Computation.get\n\ntheorem get_mem : get s ∈ s :=\n  Exists.intro (length s) (Option.eq_some_of_isSome _).symm\n#align computation.get_mem Computation.get_mem\n\ntheorem get_eq_of_mem {a} : a ∈ s → get s = a :=\n  mem_unique (get_mem _)\n#align computation.get_eq_of_mem Computation.get_eq_of_mem\n\ntheorem mem_of_get_eq {a} : get s = a → a ∈ s := by intro h ; rw [← h] ; apply get_mem\n#align computation.mem_of_get_eq Computation.mem_of_get_eq\n\n@[simp]\ntheorem get_think : get (think s) = get s :=\n  get_eq_of_mem _ <|\n    let ⟨n, h⟩ := get_mem s\n    ⟨n + 1, h⟩\n#align computation.get_think Computation.get_think\n\n@[simp]\ntheorem get_thinkN (n) : get (thinkN s n) = get s :=\n  get_eq_of_mem _ <| (thinkN_mem _).2 (get_mem _)\nset_option linter.uppercaseLean3 false in\n#align computation.get_thinkN Computation.get_thinkN\n\ntheorem get_promises : s ~> get s := fun _ => get_eq_of_mem _\n#align computation.get_promises Computation.get_promises\n\ntheorem mem_of_promises {a} (p : s ~> a) : a ∈ s := by\n  cases' h with h\n  cases' h with a' h\n  rw [p h]\n  exact h\n#align computation.mem_of_promises Computation.mem_of_promises\n\ntheorem get_eq_of_promises {a} : s ~> a → get s = a :=\n  get_eq_of_mem _ ∘ mem_of_promises _\n#align computation.get_eq_of_promises Computation.get_eq_of_promises\n\nend get\n\n/-- `Results s a n` completely characterizes a terminating computation:\n  it asserts that `s` terminates after exactly `n` steps, with result `a`. -/\ndef Results (s : Computation α) (a : α) (n : ℕ) :=\n  ∃ h : a ∈ s, @length _ s (terminates_of_mem h) = n\n#align computation.results Computation.Results\n\ntheorem results_of_terminates (s : Computation α) [_T : Terminates s] :\n    Results s (get s) (length s) :=\n  ⟨get_mem _, rfl⟩\n#align computation.results_of_terminates Computation.results_of_terminates\n\ntheorem results_of_terminates' (s : Computation α) [T : Terminates s] {a} (h : a ∈ s) :\n    Results s a (length s) := by rw [← get_eq_of_mem _ h] ; apply results_of_terminates\n#align computation.results_of_terminates' Computation.results_of_terminates'\n\ntheorem Results.mem {s : Computation α} {a n} : Results s a n → a ∈ s\n  | ⟨m, _⟩ => m\n#align computation.results.mem Computation.Results.mem\n\ntheorem Results.terminates {s : Computation α} {a n} (h : Results s a n) : Terminates s :=\n  terminates_of_mem h.mem\n#align computation.results.terminates Computation.Results.terminates\n\ntheorem Results.length {s : Computation α} {a n} [_T : Terminates s] : Results s a n → length s = n\n  | ⟨_, h⟩ => h\n#align computation.results.length Computation.Results.length\n\ntheorem Results.val_unique {s : Computation α} {a b m n} (h1 : Results s a m) (h2 : Results s b n) :\n    a = b :=\n  mem_unique h1.mem h2.mem\n#align computation.results.val_unique Computation.Results.val_unique\n\ntheorem Results.len_unique {s : Computation α} {a b m n} (h1 : Results s a m) (h2 : Results s b n) :\n    m = n := by haveI := h1.terminates ; haveI := h2.terminates ; rw [← h1.length, h2.length]\n#align computation.results.len_unique Computation.Results.len_unique\n\ntheorem exists_results_of_mem {s : Computation α} {a} (h : a ∈ s) : ∃ n, Results s a n :=\n  haveI := terminates_of_mem h\n  ⟨_, results_of_terminates' s h⟩\n#align computation.exists_results_of_mem Computation.exists_results_of_mem\n\n@[simp]\ntheorem get_pure (a : α) : get (pure a) = a :=\n  get_eq_of_mem _ ⟨0, rfl⟩\n#align computation.get_ret Computation.get_pure\n\n@[simp]\ntheorem length_pure (a : α) : length (pure a) = 0 :=\n  let h := Computation.ret_terminates a\n  Nat.eq_zero_of_le_zero <| Nat.find_min' ((terminates_def (pure a)).1 h) rfl\n#align computation.length_ret Computation.length_pure\n\ntheorem results_pure (a : α) : Results (pure a) a 0 :=\n  ⟨ret_mem a, length_pure _⟩\n#align computation.results_ret Computation.results_pure\n\n@[simp]\ntheorem length_think (s : Computation α) [h : Terminates s] : length (think s) = length s + 1 := by\n  apply le_antisymm\n  · exact Nat.find_min' _ (Nat.find_spec ((terminates_def _).1 h))\n  · have : (Option.isSome ((think s).val (length (think s))) : Prop) :=\n      Nat.find_spec ((terminates_def _).1 s.think_terminates)\n    revert this ; cases' length (think s) with n <;> intro this\n    · simp [think, Stream'.cons] at this\n    · apply Nat.succ_le_succ\n      apply Nat.find_min'\n      apply this\n#align computation.length_think Computation.length_think\n\ntheorem results_think {s : Computation α} {a n} (h : Results s a n) : Results (think s) a (n + 1) :=\n  haveI := h.terminates\n  ⟨think_mem h.mem, by rw [length_think, h.length]⟩\n#align computation.results_think Computation.results_think\n\ntheorem of_results_think {s : Computation α} {a n} (h : Results (think s) a n) :\n    ∃ m, Results s a m ∧ n = m + 1 := by\n  haveI := of_think_terminates h.terminates\n  have := results_of_terminates' _ (of_think_mem h.mem)\n  exact ⟨_, this, Results.len_unique h (results_think this)⟩\n#align computation.of_results_think Computation.of_results_think\n\n@[simp]\ntheorem results_think_iff {s : Computation α} {a n} : Results (think s) a (n + 1) ↔ Results s a n :=\n  ⟨fun h => by\n    let ⟨n', r, e⟩ := of_results_think h\n    injection e with h' ; rw [Nat.add, Nat.add] at h'; rwa [h'], results_think⟩\n#align computation.results_think_iff Computation.results_think_iff\n\ntheorem results_thinkN {s : Computation α} {a m} :\n    ∀ n, Results s a m → Results (thinkN s n) a (m + n)\n  | 0, h => h\n  | n + 1, h => results_think (results_thinkN n h)\nset_option linter.uppercaseLean3 false in\n#align computation.results_thinkN Computation.results_thinkN\n\ntheorem results_thinkN_pure (a : α) (n) : Results (thinkN (pure a) n) a n := by\n  have := results_thinkN n (results_pure a) ; rwa [Nat.zero_add] at this\nset_option linter.uppercaseLean3 false in\n#align computation.results_thinkN_ret Computation.results_thinkN_pure\n\n@[simp]\ntheorem length_thinkN (s : Computation α) [_h : Terminates s] (n) :\n    length (thinkN s n) = length s + n :=\n  (results_thinkN n (results_of_terminates _)).length\nset_option linter.uppercaseLean3 false in\n#align computation.length_thinkN Computation.length_thinkN\n\ntheorem eq_thinkN {s : Computation α} {a n} (h : Results s a n) : s = thinkN (pure a) n := by\n  revert s\n  induction' n with n IH <;> intro s <;> apply recOn s (fun a' => _) fun s => _ <;> intro a h\n  · rw [← eq_of_pure_mem h.mem]\n    rfl\n  · cases' of_results_think h with n h\n    cases h\n    contradiction\n  · have := h.len_unique (results_pure _)\n    contradiction\n  · rw [IH (results_think_iff.1 h)]\n    rfl\nset_option linter.uppercaseLean3 false in\n#align computation.eq_thinkN Computation.eq_thinkN\n\ntheorem eq_thinkN' (s : Computation α) [_h : Terminates s] :\n    s = thinkN (pure (get s)) (length s) :=\n  eq_thinkN (results_of_terminates _)\nset_option linter.uppercaseLean3 false in\n#align computation.eq_thinkN' Computation.eq_thinkN'\n\n/-- Recursor based on memberhip-/\ndef memRecOn {C : Computation α → Sort v} {a s} (M : a ∈ s) (h1 : C (pure a))\n    (h2 : ∀ s, C s → C (think s)) : C s := by\n  haveI T := terminates_of_mem M\n  rw [eq_thinkN' s, get_eq_of_mem s M]\n  generalize length s = n\n  induction' n with n IH; exacts[h1, h2 _ IH]\n#align computation.mem_rec_on Computation.memRecOn\n\n/-- Recursor based on assertion of `Terminates`-/\ndef terminatesRecOn\n    {C : Computation α → Sort v}\n    (s) [Terminates s]\n    (h1 : ∀ a, C (pure a))\n    (h2 : ∀ s, C s → C (think s)) : C s :=\n  memRecOn (get_mem s) (h1 _) h2\n#align computation.terminates_rec_on Computation.terminatesRecOn\n\n/-- Map a function on the result of a computation. -/\ndef map (f : α → β) : Computation α → Computation β\n  | ⟨s, al⟩ =>\n    ⟨s.map fun o => Option.casesOn o none (some ∘ f), fun n b => by\n      dsimp [Stream'.map, Stream'.nth]\n      induction' e : s n with a <;> intro h\n      . contradiction\n      · rw [al e]; exact h⟩\n#align computation.map Computation.map\n\n/-- bind over a `Sum` of `Computation`-/\ndef Bind.g : Sum β (Computation β) → Sum β (Sum (Computation α) (Computation β))\n  | Sum.inl b => Sum.inl b\n  | Sum.inr cb' => Sum.inr <| Sum.inr cb'\nset_option linter.uppercaseLean3 false in\n#align computation.bind.G Computation.Bind.g\n\n/-- bind over a function mapping `α` to a `Computation`-/\ndef Bind.f (f : α → Computation β) :\n    Sum (Computation α) (Computation β) → Sum β (Sum (Computation α) (Computation β))\n  | Sum.inl ca =>\n    match destruct ca with\n    | Sum.inl a => Bind.g <| destruct (f a)\n    | Sum.inr ca' => Sum.inr <| Sum.inl ca'\n  | Sum.inr cb => Bind.g <| destruct cb\nset_option linter.uppercaseLean3 false in\n#align computation.bind.F Computation.Bind.f\n\n/-- Compose two computations into a monadic `bind` operation. -/\ndef bind (c : Computation α) (f : α → Computation β) : Computation β :=\n  corec (Bind.f f) (Sum.inl c)\n#align computation.bind Computation.bind\n\ninstance : Bind Computation :=\n  ⟨@bind⟩\n\ntheorem has_bind_eq_bind {β} (c : Computation α) (f : α → Computation β) : c >>= f = bind c f :=\n  rfl\n#align computation.has_bind_eq_bind Computation.has_bind_eq_bind\n\n/-- Flatten a computation of computations into a single computation. -/\ndef join (c : Computation (Computation α)) : Computation α :=\n  c >>= id\n#align computation.join Computation.join\n\n@[simp]\ntheorem map_pure (f : α → β) (a) : map f (pure a) = pure (f a) :=\n  rfl\n#align computation.map_ret Computation.map_pure\n\n@[simp]\ntheorem map_think (f : α → β) : ∀ s, map f (think s) = think (map f s)\n  | ⟨s, al⟩ => by apply Subtype.eq ; dsimp [think, map] ; rw [Stream'.map_cons]\n#align computation.map_think Computation.map_think\n\n@[simp]\ntheorem destruct_map (f : α → β) (s) : destruct (map f s) = lmap f (rmap (map f) (destruct s)) := by\n  apply s.recOn <;> intro <;> simp\n#align computation.destruct_map Computation.destruct_map\n\n@[simp]\ntheorem map_id : ∀ s : Computation α, map id s = s\n  | ⟨f, al⟩ => by\n    apply Subtype.eq ; simp [map, Function.comp]\n    have e : @Option.rec α (fun _ => Option α) none some = id := by ext ⟨⟩ <;> rfl\n    have h : ((fun x: Option α => x) = id) := by rfl\n    simp [e, h, Stream'.map_id]\n#align computation.map_id Computation.map_id\n\ntheorem map_comp (f : α → β) (g : β → γ) : ∀ s : Computation α, map (g ∘ f) s = map g (map f s)\n  | ⟨s, al⟩ => by\n    apply Subtype.eq ; dsimp [map]\n    rw [Stream'.map_map]\n    apply congr_arg fun f : _ → Option γ => Stream'.map f s\n    ext ⟨⟩ <;> rfl\n#align computation.map_comp Computation.map_comp\n\n@[simp]\ntheorem ret_bind (a) (f : α → Computation β) : bind (pure a) f = f a := by\n  apply\n    eq_of_bisim fun c₁ c₂ => c₁ = bind (pure a) f ∧ c₂ = f a ∨ c₁ = corec (Bind.f f) (Sum.inr c₂)\n  · intro c₁ c₂ h\n    exact\n      match c₁, c₂, h with\n      | _, _, Or.inl ⟨rfl, rfl⟩ => by\n        simp [bind, Bind.f]\n        cases' destruct (f a) with b cb <;> simp [Bind.g]\n      | _, c, Or.inr rfl => by\n        simp [Bind.f]\n        cases' destruct c with b cb <;> simp [Bind.g]\n  · simp\n#align computation.ret_bind Computation.ret_bind\n\n@[simp]\ntheorem think_bind (c) (f : α → Computation β) : bind (think c) f = think (bind c f) :=\n  destruct_eq_think <| by simp [bind, Bind.f]\n#align computation.think_bind Computation.think_bind\n\n@[simp]\ntheorem bind_pure (f : α → β) (s) : bind s (pure ∘ f) = map f s := by\n  apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s (pure ∘ f) ∧ c₂ = map f s\n  · intro c₁ c₂ h\n    exact\n      match c₁, c₂, h with\n      | _, c₂, Or.inl (Eq.refl _) => by cases' destruct c₂ with b cb <;> simp\n      | _, _, Or.inr ⟨s, rfl, rfl⟩ => by\n        apply recOn s <;> intro s <;> simp\n        exact Or.inr ⟨s, rfl, rfl⟩\n  · exact Or.inr ⟨s, rfl, rfl⟩\n#align computation.bind_ret Computation.bind_pure\n\n-- porting notes: used to use `rw [bind_pure]`\n@[simp]\ntheorem bind_pure' (s : Computation α) : bind s pure = s := by\n  apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s (pure) ∧ c₂ = s\n  . intro c₁ c₂ h\n    exact\n      match c₁, c₂, h with\n      | _, c₂, Or.inl (Eq.refl _) => by cases' destruct c₂ with b cb <;> simp\n      | _, _, Or.inr ⟨s, rfl, rfl⟩ => by\n        apply recOn s <;> intro s <;> simp\n  . exact Or.inr ⟨s, rfl, rfl⟩\n#align computation.bind_ret' Computation.bind_pure'\n\n@[simp]\ntheorem bind_assoc (s : Computation α) (f : α → Computation β) (g : β → Computation γ) :\n    bind (bind s f) g = bind s fun x : α => bind (f x) g := by\n  apply\n    eq_of_bisim fun c₁ c₂ =>\n      c₁ = c₂ ∨ ∃ s, c₁ = bind (bind s f) g ∧ c₂ = bind s fun x : α => bind (f x) g\n  · intro c₁ c₂ h\n    exact\n      match c₁, c₂, h with\n      | _, c₂, Or.inl (Eq.refl _) => by cases' destruct c₂ with b cb <;> simp\n      | _, _, Or.inr ⟨s, rfl, rfl⟩ => by\n        apply recOn s <;> intro s <;> simp\n        · generalize f s = fs\n          apply recOn fs <;> intro t <;> simp\n          · cases' destruct (g t) with b cb <;> simp\n        · exact Or.inr ⟨s, rfl, rfl⟩\n  · exact Or.inr ⟨s, rfl, rfl⟩\n#align computation.bind_assoc Computation.bind_assoc\n\ntheorem results_bind {s : Computation α} {f : α → Computation β} {a b m n} (h1 : Results s a m)\n    (h2 : Results (f a) b n) : Results (bind s f) b (n + m) := by\n  have := h1.mem; revert m\n  apply memRecOn this _ fun s IH => _\n  · intro _ h1\n    rw [ret_bind]\n    rw [h1.len_unique (results_pure _)]\n    exact h2\n  · intro _ h3 _ h1\n    rw [think_bind]\n    cases' of_results_think h1 with m' h\n    cases' h with h1 e\n    rw [e]\n    exact results_think (h3 h1)\n#align computation.results_bind Computation.results_bind\n\ntheorem mem_bind {s : Computation α} {f : α → Computation β} {a b} (h1 : a ∈ s) (h2 : b ∈ f a) :\n    b ∈ bind s f :=\n  let ⟨_, h1⟩ := exists_results_of_mem h1\n  let ⟨_, h2⟩ := exists_results_of_mem h2\n  (results_bind h1 h2).mem\n#align computation.mem_bind Computation.mem_bind\n\ninstance terminates_bind (s : Computation α) (f : α → Computation β) [Terminates s]\n    [Terminates (f (get s))] : Terminates (bind s f) :=\n  terminates_of_mem (mem_bind (get_mem s) (get_mem (f (get s))))\n#align computation.terminates_bind Computation.terminates_bind\n\n@[simp]\ntheorem get_bind (s : Computation α) (f : α → Computation β) [Terminates s]\n    [Terminates (f (get s))] : get (bind s f) = get (f (get s)) :=\n  get_eq_of_mem _ (mem_bind (get_mem s) (get_mem (f (get s))))\n#align computation.get_bind Computation.get_bind\n\n@[simp]\ntheorem length_bind (s : Computation α) (f : α → Computation β) [_T1 : Terminates s]\n    [_T2 : Terminates (f (get s))] : length (bind s f) = length (f (get s)) + length s :=\n  (results_of_terminates _).len_unique <|\n    results_bind (results_of_terminates _) (results_of_terminates _)\n#align computation.length_bind Computation.length_bind\n\ntheorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :\n    Results (bind s f) b k → ∃ a m n, Results s a m ∧ Results (f a) b n ∧ k = n + m := by\n  induction' k with n IH generalizing s <;> apply recOn s (fun a => _) fun s' => _ <;> intro e h\n  · simp [thinkN] at h\n    refine' ⟨e, _, _, results_pure _, h, rfl⟩\n  · have := congr_arg head (eq_thinkN h)\n    contradiction\n  · simp at h\n    refine' ⟨e, _, n + 1, results_pure _, h, rfl⟩\n  · simp at h\n    exact by\n      let ⟨a, m, n', h1, h2, e'⟩ := IH h\n      rw [e'] ; exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩\n#align computation.of_results_bind Computation.of_results_bind\n\ntheorem exists_of_mem_bind {s : Computation α} {f : α → Computation β} {b} (h : b ∈ bind s f) :\n    ∃ a ∈ s, b ∈ f a :=\n  let ⟨_, h⟩ := exists_results_of_mem h\n  let ⟨a, _, _, h1, h2, _⟩ := of_results_bind h\n  ⟨a, h1.mem, h2.mem⟩\n#align computation.exists_of_mem_bind Computation.exists_of_mem_bind\n\ntheorem bind_promises {s : Computation α} {f : α → Computation β} {a b} (h1 : s ~> a)\n    (h2 : f a ~> b) : bind s f ~> b := fun b' bB => by\n  rcases exists_of_mem_bind bB with ⟨a', a's, ba'⟩\n  rw [← h1 a's] at ba'; exact h2 ba'\n#align computation.bind_promises Computation.bind_promises\n\ninstance monad : Monad Computation where\n  map := @map\n  pure := @pure\n  bind := @bind\n\ninstance : LawfulMonad Computation := LawfulMonad.mk'\n  (id_map := @map_id)\n  (bind_pure_comp := @bind_pure)\n  (pure_bind := @ret_bind)\n  (bind_assoc := @bind_assoc)\n\ntheorem has_map_eq_map {β} (f : α → β) (c : Computation α) : f <$> c = map f c :=\n  rfl\n#align computation.has_map_eq_map Computation.has_map_eq_map\n\n@[simp]\ntheorem pure_def (a) : (return a : Computation α) = pure a :=\n  rfl\n#align computation.return_def Computation.pure_def\n\n@[simp]\ntheorem map_pure' {α β} : ∀ (f : α → β) (a), f <$> pure a = pure (f a) :=\n  map_pure\n#align computation.map_ret' Computation.map_pure'\n\n@[simp]\ntheorem map_think' {α β} : ∀ (f : α → β) (s), f <$> think s = think (f <$> s) :=\n  map_think\n#align computation.map_think' Computation.map_think'\n\ntheorem mem_map (f : α → β) {a} {s : Computation α} (m : a ∈ s) : f a ∈ map f s := by\n  rw [← bind_pure] ; apply mem_bind m ; apply ret_mem\n#align computation.mem_map Computation.mem_map\n\ntheorem exists_of_mem_map {f : α → β} {b : β} {s : Computation α} (h : b ∈ map f s) :\n    ∃ a, a ∈ s ∧ f a = b := by\n  rw [← bind_pure] at h ;\n    exact\n      let ⟨a, as, fb⟩ := exists_of_mem_bind h\n      ⟨a, as, mem_unique (ret_mem _) fb⟩\n#align computation.exists_of_mem_map Computation.exists_of_mem_map\n\ninstance terminates_map (f : α → β) (s : Computation α) [Terminates s] : Terminates (map f s) := by\n  rw [← bind_pure] ;  exact terminates_of_mem (mem_bind (get_mem s) (get_mem (f (get s))))\n#align computation.terminates_map Computation.terminates_map\n\ntheorem terminates_map_iff (f : α → β) (s : Computation α) : Terminates (map f s) ↔ Terminates s :=\n  ⟨fun ⟨⟨_, h⟩⟩ =>\n    let ⟨_, h1, _⟩ := exists_of_mem_map h\n    ⟨⟨_, h1⟩⟩,\n    @Computation.terminates_map _ _ _ _⟩\n#align computation.terminates_map_iff Computation.terminates_map_iff\n\n-- Parallel computation\n/-- `c₁ <|> c₂` calculates `c₁` and `c₂` simultaneously, returning\n  the first one that gives a result. -/\ndef orElse (c₁: Computation α) (c₂: Unit → Computation α): Computation α :=\n  @Computation.corec α (Computation α × Computation α)\n    (fun ⟨c₁, c₂⟩ =>\n      match destruct c₁ with\n      | Sum.inl a => Sum.inl a\n      | Sum.inr c₁' =>\n        match destruct c₂ with\n        | Sum.inl a => Sum.inl a\n        | Sum.inr c₂' => Sum.inr (c₁', c₂'))\n    (c₁, c₂ ())\n#align computation.orelse Computation.orElse\n\ninstance : Alternative Computation :=\n  { Computation.monad with\n    orElse := @orElse\n    failure := @empty }\n\n-- Porting note: Added unfolds as the code does not work without it\n@[simp]\ntheorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a :=\n  destruct_eq_pure <| by\n    unfold HOrElse.hOrElse instHOrElse\n    unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation\n    simp [orElse]\n#align computation.ret_orelse Computation.ret_orElse\n\n-- Porting note: Added unfolds as the code does not work without it\n@[simp]\ntheorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=\n  destruct_eq_pure <| by\n    unfold HOrElse.hOrElse instHOrElse\n    unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation\n    simp [orElse]\n#align computation.orelse_ret Computation.orelse_pure\n\n-- Porting note: Added unfolds as the code does not work without it\n@[simp]\ntheorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=\n  destruct_eq_think <| by\n    unfold HOrElse.hOrElse instHOrElse\n    unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation\n    simp [orElse]\n#align computation.orelse_think Computation.orelse_think\n\n@[simp]\ntheorem empty_orelse (c) : (empty α <|> c) = c := by\n  apply eq_of_bisim (fun c₁ c₂ => (empty α <|> c₂) = c₁) _ rfl\n  intro s' s h; rw [← h]\n  apply recOn s <;> intro s <;> rw [think_empty] <;> simp\n  rw [← think_empty]\n#align computation.empty_orelse Computation.empty_orelse\n\n@[simp]\ntheorem orelse_empty (c : Computation α) : (c <|> empty α) = c := by\n  apply eq_of_bisim (fun c₁ c₂ => (c₂ <|> empty α) = c₁) _ rfl\n  intro s' s h; rw [← h]\n  apply recOn s <;> intro s <;> rw [think_empty] <;> simp\n  rw [← think_empty]\n#align computation.orelse_empty Computation.orelse_empty\n\n/-- `c₁ ~ c₂` asserts that `c₁` and `c₂` either both terminate with the same result,\n  or both loop forever. -/\ndef Equiv (c₁ c₂ : Computation α) : Prop :=\n  ∀ a, a ∈ c₁ ↔ a ∈ c₂\n#align computation.equiv Computation.Equiv\n\n-- mathport name: «expr ~ »\n/-- equivalence relation for computations-/\nscoped infixl:50 \" ~ \" => Equiv\n\n@[refl]\ntheorem Equiv.refl (s : Computation α) : s ~ s := fun _ => Iff.rfl\n#align computation.equiv.refl Computation.Equiv.refl\n\n@[symm]\ntheorem Equiv.symm {s t : Computation α} : s ~ t → t ~ s := fun h a => (h a).symm\n#align computation.equiv.symm Computation.Equiv.symm\n\n@[trans]\ntheorem Equiv.trans {s t u : Computation α} : s ~ t → t ~ u → s ~ u := fun h1 h2 a =>\n  (h1 a).trans (h2 a)\n#align computation.equiv.trans Computation.Equiv.trans\n\ntheorem Equiv.equivalence : Equivalence (@Equiv α) :=\n  ⟨@Equiv.refl _, @Equiv.symm _, @Equiv.trans _⟩\n#align computation.equiv.equivalence Computation.Equiv.equivalence\n\ntheorem equiv_of_mem {s t : Computation α} {a} (h1 : a ∈ s) (h2 : a ∈ t) : s ~ t := fun a' =>\n  ⟨fun ma => by rw [mem_unique ma h1] ; exact h2, fun ma => by rw [mem_unique ma h2] ; exact h1⟩\n#align computation.equiv_of_mem Computation.equiv_of_mem\n\ntheorem terminates_congr {c₁ c₂ : Computation α} (h : c₁ ~ c₂) : Terminates c₁ ↔ Terminates c₂ := by\n  simp only [terminates_iff, exists_congr h]\n#align computation.terminates_congr Computation.terminates_congr\n\n\n\ntheorem get_equiv {c₁ c₂ : Computation α} (h : c₁ ~ c₂) [Terminates c₁] [Terminates c₂] :\n    get c₁ = get c₂ :=\n  get_eq_of_mem _ <| (h _).2 <| get_mem _\n#align computation.get_equiv Computation.get_equiv\n\ntheorem think_equiv (s : Computation α) : think s ~ s := fun _ => ⟨of_think_mem, think_mem⟩\n#align computation.think_equiv Computation.think_equiv\n\ntheorem thinkN_equiv (s : Computation α) (n) : thinkN s n ~ s := fun _ => thinkN_mem n\nset_option linter.uppercaseLean3 false in\n#align computation.thinkN_equiv Computation.thinkN_equiv\n\ntheorem bind_congr {s1 s2 : Computation α} {f1 f2 : α → Computation β} (h1 : s1 ~ s2)\n    (h2 : ∀ a, f1 a ~ f2 a) : bind s1 f1 ~ bind s2 f2 := fun b =>\n  ⟨fun h =>\n    let ⟨a, ha, hb⟩ := exists_of_mem_bind h\n    mem_bind ((h1 a).1 ha) ((h2 a b).1 hb),\n    fun h =>\n    let ⟨a, ha, hb⟩ := exists_of_mem_bind h\n    mem_bind ((h1 a).2 ha) ((h2 a b).2 hb)⟩\n#align computation.bind_congr Computation.bind_congr\n\ntheorem equiv_pure_of_mem {s : Computation α} {a} (h : a ∈ s) : s ~ pure a :=\n  equiv_of_mem h (ret_mem _)\n#align computation.equiv_ret_of_mem Computation.equiv_pure_of_mem\n\n/-- `LiftRel R ca cb` is a generalization of `Equiv` to relations other than\n  equality. It asserts that if `ca` terminates with `a`, then `cb` terminates with\n  some `b` such that `R a b`, and if `cb` terminates with `b` then `ca` terminates\n  with some `a` such that `R a b`. -/\ndef LiftRel (R : α → β → Prop) (ca : Computation α) (cb : Computation β) : Prop :=\n  (∀ {a}, a ∈ ca → ∃ b, b ∈ cb ∧ R a b) ∧ ∀ {b}, b ∈ cb → ∃ a, a ∈ ca ∧ R a b\n#align computation.lift_rel Computation.LiftRel\n\ntheorem LiftRel.swap (R : α → β → Prop) (ca : Computation α) (cb : Computation β) :\n    LiftRel (swap R) cb ca ↔ LiftRel R ca cb :=\n  @and_comm _ _\n#align computation.lift_rel.swap Computation.LiftRel.swap\n\ntheorem lift_eq_iff_equiv (c₁ c₂ : Computation α) : LiftRel (· = ·) c₁ c₂ ↔ c₁ ~ c₂ :=\n  ⟨fun ⟨h1, h2⟩ a =>\n    ⟨fun a1 => by\n      let ⟨b, b2, ab⟩ := h1 a1\n      rwa [ab], fun a2 => by\n      let ⟨b, b1, ab⟩ := h2 a2\n      rwa [← ab]⟩,\n    fun e => ⟨fun {a} a1 => ⟨a, (e _).1 a1, rfl⟩, fun {a} a2 => ⟨a, (e _).2 a2, rfl⟩⟩⟩\n#align computation.lift_eq_iff_equiv Computation.lift_eq_iff_equiv\n\ntheorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun _ =>\n  ⟨fun {a} as => ⟨a, as, H a⟩, fun {b} bs => ⟨b, bs, H b⟩⟩\n#align computation.lift_rel.refl Computation.LiftRel.refl\n\ntheorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=\n  fun _ _ ⟨l, r⟩ =>\n  ⟨fun {_} a2 =>\n    let ⟨b, b1, ab⟩ := r a2\n    ⟨b, b1, H ab⟩,\n    fun {_} a1 =>\n    let ⟨b, b2, ab⟩ := l a1\n    ⟨b, b2, H ab⟩⟩\n#align computation.lift_rel.symm Computation.LiftRel.symm\n\ntheorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (LiftRel R) :=\n  fun _ _ _ ⟨l1, r1⟩ ⟨l2, r2⟩ =>\n  ⟨fun {_} a1 =>\n    let ⟨_, b2, ab⟩ := l1 a1\n    let ⟨c, c3, bc⟩ := l2 b2\n    ⟨c, c3, H ab bc⟩,\n    fun {_} c3 =>\n    let ⟨_, b2, bc⟩ := r2 c3\n    let ⟨a, a1, ab⟩ := r1 b2\n    ⟨a, a1, H ab bc⟩⟩\n#align computation.lift_rel.trans Computation.LiftRel.trans\n\ntheorem LiftRel.equiv (R : α → α → Prop) : Equivalence R → Equivalence (LiftRel R)\n  -- Porting note: The code below was:\n  -- | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, LiftRel.symm R symm, LiftRel.trans R trans⟩\n  --\n  -- The code fails to identify `symm` as being symmetric.\n  | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, by apply LiftRel.symm; apply symm,\n    by apply LiftRel.trans; apply trans⟩\n#align computation.lift_rel.equiv Computation.LiftRel.equiv\n\ntheorem LiftRel.imp {R S : α → β → Prop} (H : ∀ {a b}, R a b → S a b) (s t) :\n    LiftRel R s t → LiftRel S s t\n  | ⟨l, r⟩ =>\n    ⟨fun {_} as =>\n      let ⟨b, bt, ab⟩ := l as\n      ⟨b, bt, H ab⟩,\n      fun {_} bt =>\n      let ⟨a, as, ab⟩ := r bt\n      ⟨a, as, H ab⟩⟩\n#align computation.lift_rel.imp Computation.LiftRel.imp\n\ntheorem terminates_of_LiftRel {R : α → β → Prop} {s t} :\n    LiftRel R s t → (Terminates s ↔ Terminates t)\n  | ⟨l, r⟩ =>\n    ⟨fun ⟨⟨_, as⟩⟩ =>\n      let ⟨b, bt, _⟩ := l as\n      ⟨⟨b, bt⟩⟩,\n      fun ⟨⟨_, bt⟩⟩ =>\n      let ⟨a, as, _⟩ := r bt\n      ⟨⟨a, as⟩⟩⟩\n#align computation.terminates_of_lift_rel Computation.terminates_of_LiftRel\n\ntheorem rel_of_LiftRel {R : α → β → Prop} {ca cb} :\n    LiftRel R ca cb → ∀ {a b}, a ∈ ca → b ∈ cb → R a b\n  | ⟨l, _⟩, a, b, ma, mb => by\n    let ⟨b', mb', ab'⟩ := l ma\n    rw [mem_unique mb mb'] ; exact ab'\n#align computation.rel_of_lift_rel Computation.rel_of_LiftRel\n\ntheorem liftRel_of_mem {R : α → β → Prop} {a b ca cb} (ma : a ∈ ca) (mb : b ∈ cb) (ab : R a b) :\n    LiftRel R ca cb :=\n  ⟨fun {a'} ma' => by rw [mem_unique ma' ma] ; exact ⟨b, mb, ab⟩, fun {b'} mb' => by\n    rw [mem_unique mb' mb] ; exact ⟨a, ma, ab⟩⟩\n#align computation.lift_rel_of_mem Computation.liftRel_of_mem\n\ntheorem exists_of_LiftRel_left {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {a} (h : a ∈ ca) :\n    ∃ b, b ∈ cb ∧ R a b :=\n  H.left h\n#align computation.exists_of_lift_rel_left Computation.exists_of_LiftRel_left\n\ntheorem exists_of_LiftRel_right {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {b} (h : b ∈ cb) :\n    ∃ a, a ∈ ca ∧ R a b :=\n  H.right h\n#align computation.exists_of_lift_rel_right Computation.exists_of_LiftRel_right\n\ntheorem liftRel_def {R : α → β → Prop} {ca cb} :\n    LiftRel R ca cb ↔ (Terminates ca ↔ Terminates cb) ∧ ∀ {a b}, a ∈ ca → b ∈ cb → R a b :=\n  ⟨fun h =>\n    ⟨terminates_of_LiftRel h, fun {a b} ma mb => by\n      let ⟨b', mb', ab⟩ := h.left ma\n      rwa [mem_unique mb mb']⟩,\n    fun ⟨l, r⟩ =>\n    ⟨fun {a} ma =>\n      let ⟨⟨b, mb⟩⟩ := l.1 ⟨⟨_, ma⟩⟩\n      ⟨b, mb, r ma mb⟩,\n      fun {b} mb =>\n      let ⟨⟨a, ma⟩⟩ := l.2 ⟨⟨_, mb⟩⟩\n      ⟨a, ma, r ma mb⟩⟩⟩\n#align computation.lift_rel_def Computation.liftRel_def\n\ntheorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}\n    {s2 : Computation β} {f1 : α → Computation γ} {f2 : β → Computation δ} (h1 : LiftRel R s1 s2)\n    (h2 : ∀ {a b}, R a b → LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=\n  let ⟨l1, r1⟩ := h1\n  ⟨fun {_} cB =>\n    let ⟨_, a1, c₁⟩ := exists_of_mem_bind cB\n    let ⟨_, b2, ab⟩ := l1 a1\n    let ⟨l2, _⟩ := h2 ab\n    let ⟨_, d2, cd⟩ := l2 c₁\n    ⟨_, mem_bind b2 d2, cd⟩,\n    fun {_} dB =>\n    let ⟨_, b1, d1⟩ := exists_of_mem_bind dB\n    let ⟨_, a2, ab⟩ := r1 b1\n    let ⟨_, r2⟩ := h2 ab\n    let ⟨_, c₂, cd⟩ := r2 d1\n    ⟨_, mem_bind a2 c₂, cd⟩⟩\n#align computation.lift_rel_bind Computation.liftRel_bind\n\n@[simp]\ntheorem liftRel_pure_left (R : α → β → Prop) (a : α) (cb : Computation β) :\n    LiftRel R (pure a) cb ↔ ∃ b, b ∈ cb ∧ R a b :=\n  ⟨fun ⟨l, _⟩ => l (ret_mem _), fun ⟨b, mb, ab⟩ =>\n    ⟨fun {a'} ma' => by rw [eq_of_pure_mem ma'] ; exact ⟨b, mb, ab⟩, fun {b'} mb' =>\n      ⟨_, ret_mem _, by rw [mem_unique mb' mb] ; exact ab⟩⟩⟩\n#align computation.lift_rel_return_left Computation.liftRel_pure_left\n\n@[simp]\ntheorem liftRel_pure_right (R : α → β → Prop) (ca : Computation α) (b : β) :\n    LiftRel R ca (pure b) ↔ ∃ a, a ∈ ca ∧ R a b := by rw [LiftRel.swap, liftRel_pure_left]\n#align computation.lift_rel_return_right Computation.liftRel_pure_right\n\n-- porting notes: `simpNF` wants to simplify based on `liftRel_pure_right` but point is to prove\n-- a general invariant on `LiftRel`\n@[simp, nolint simpNF]\ntheorem liftRel_pure (R : α → β → Prop) (a : α) (b : β) :\n    LiftRel R (pure a) (pure b) ↔ R a b := by\n  rw [liftRel_pure_left] ;\n    exact ⟨fun ⟨b', mb', ab'⟩ => by rwa [eq_of_pure_mem mb'] at ab', fun ab => ⟨_, ret_mem _, ab⟩⟩\n#align computation.lift_rel_return Computation.liftRel_pure\n\n@[simp]\ntheorem liftRel_think_left (R : α → β → Prop) (ca : Computation α) (cb : Computation β) :\n    LiftRel R (think ca) cb ↔ LiftRel R ca cb :=\n  and_congr (forall_congr' fun _ => imp_congr ⟨of_think_mem, think_mem⟩ Iff.rfl)\n    (forall_congr' fun _ =>\n      imp_congr Iff.rfl <| exists_congr fun _ => and_congr ⟨of_think_mem, think_mem⟩ Iff.rfl)\n#align computation.lift_rel_think_left Computation.liftRel_think_left\n\n@[simp]\ntheorem liftRel_think_right (R : α → β → Prop) (ca : Computation α) (cb : Computation β) :\n    LiftRel R ca (think cb) ↔ LiftRel R ca cb := by\n  rw [← LiftRel.swap R, ← LiftRel.swap R] ; apply liftRel_think_left\n#align computation.lift_rel_think_right Computation.liftRel_think_right\n\ntheorem liftRel_mem_cases {R : α → β → Prop} {ca cb} (Ha : ∀ a ∈ ca, LiftRel R ca cb)\n    (Hb : ∀ b ∈ cb, LiftRel R ca cb) : LiftRel R ca cb :=\n  ⟨fun {_} ma => (Ha _ ma).left ma, fun {_} mb => (Hb _ mb).right mb⟩\n#align computation.lift_rel_mem_cases Computation.liftRel_mem_cases\n\ntheorem liftRel_congr {R : α → β → Prop} {ca ca' : Computation α} {cb cb' : Computation β}\n    (ha : ca ~ ca') (hb : cb ~ cb') : LiftRel R ca cb ↔ LiftRel R ca' cb' :=\n  and_congr\n    (forall_congr' fun _ => imp_congr (ha _) <| exists_congr fun _ => and_congr (hb _) Iff.rfl)\n    (forall_congr' fun _ => imp_congr (hb _) <| exists_congr fun _ => and_congr (ha _) Iff.rfl)\n#align computation.lift_rel_congr Computation.liftRel_congr\n\ntheorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}\n    {s2 : Computation β} {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2)\n    (h2 : ∀ {a b}, R a b → S (f1 a) (f2 b)) : LiftRel S (map f1 s1) (map f2 s2) := by\n  -- Porting note: The line below was:\n  -- rw [← bind_pure, ← bind_pure]; apply lift_rel_bind _ _ h1; simp; exact @h2\n  --\n  -- The code fails to work on the last exact.\n  rw [← bind_pure, ← bind_pure]; apply liftRel_bind _ _ h1; simp\n  intros a b h; exact ⟨f1 a, ⟨ret_mem _, @h2 a b h⟩⟩\n#align computation.lift_rel_map Computation.liftRel_map\n\n-- porting notes: deleted initial arguments `(_R : α → α → Prop) (_S : β → β → Prop)`: unused\ntheorem map_congr {s1 s2 : Computation α} {f : α → β}\n    (h1 : s1 ~ s2) : map f s1 ~ map f s2 := by\n  rw [← lift_eq_iff_equiv] ;\n    exact liftRel_map Eq _ ((lift_eq_iff_equiv _ _).2 h1) fun {a} b => congr_arg _\n#align computation.map_congr Computation.map_congr\n\n/-- Alternate defintion of `LiftRel` over relations between `Computation`s-/\ndef LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β → Prop) :\n    Sum α (Computation α) → Sum β (Computation β) → Prop\n  | Sum.inl a, Sum.inl b => R a b\n  | Sum.inl a, Sum.inr cb => ∃ b, b ∈ cb ∧ R a b\n  | Sum.inr ca, Sum.inl b => ∃ a, a ∈ ca ∧ R a b\n  | Sum.inr ca, Sum.inr cb => C ca cb\n#align computation.lift_rel_aux Computation.LiftRelAux\n\n--porting note: was attribute [simp] LiftRelAux but right now `simp` on defs is a Lean 4 catastrophe\n-- Instead we add the equation lemmas and tag them @[simp]\n@[simp] lemma LiftRelAux_inl_inl : LiftRelAux R C (Sum.inl a) (Sum.inl b) = R a b := rfl\n@[simp] lemma LiftRelAux_inl_inr : LiftRelAux R C (Sum.inl a) (Sum.inr cb) = ∃ b, b ∈ cb ∧ R a b :=\n  rfl\n@[simp] lemma LiftRelAux_inr_inl : LiftRelAux R C (Sum.inr ca) (Sum.inl b) = ∃ a, a ∈ ca ∧ R a b :=\n  rfl\n@[simp] lemma LiftRelAux_inr_inr : LiftRelAux R C (Sum.inr ca) (Sum.inr cb) = C ca cb := rfl\n\n@[simp]\ntheorem LiftRelAux.ret_left (R : α → β → Prop) (C : Computation α → Computation β → Prop) (a cb) :\n    LiftRelAux R C (Sum.inl a) (destruct cb) ↔ ∃ b, b ∈ cb ∧ R a b := by\n  apply cb.recOn (fun b => _) fun cb => _\n  · intro b\n    exact\n      ⟨fun h => ⟨_, ret_mem _, h⟩, fun ⟨b', mb, h⟩ => by rw [mem_unique (ret_mem _) mb] ; exact h⟩\n  · intro\n    rw [destruct_think]\n    exact ⟨fun ⟨b, h, r⟩ => ⟨b, think_mem h, r⟩, fun ⟨b, h, r⟩ => ⟨b, of_think_mem h, r⟩⟩\n#align computation.lift_rel_aux.ret_left Computation.LiftRelAux.ret_left\n\ntheorem LiftRelAux.swap (R : α → β → Prop) (C) (a b) :\n    LiftRelAux (swap R) (swap C) b a = LiftRelAux R C a b := by\n  cases' a with a ca <;> cases' b with b cb <;> simp only [LiftRelAux]\n#align computation.lift_rel_aux.swap Computation.LiftRelAux.swap\n\n@[simp]\ntheorem LiftRelAux.ret_right (R : α → β → Prop) (C : Computation α → Computation β → Prop) (b ca) :\n    LiftRelAux R C (destruct ca) (Sum.inl b) ↔ ∃ a, a ∈ ca ∧ R a b := by\n  rw [← LiftRelAux.swap, LiftRelAux.ret_left]\n#align computation.lift_rel_aux.ret_right Computation.LiftRelAux.ret_right\n\ntheorem LiftRelRec.lem {R : α → β → Prop} (C : Computation α → Computation β → Prop)\n    (H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) (a)\n    (ha : a ∈ ca) : LiftRel R ca cb := by\n  revert cb\n  refine' memRecOn (C := (λ ca => ∀ (cb : Computation β), C ca cb → LiftRel R ca cb))\n    ha _ (fun ca' IH => _) <;> intro cb Hc <;> have h := H Hc\n  · simp at h\n    simp [h]\n  · simp\n    revert h\n    apply cb.recOn (fun b => _) fun cb' => _ <;> intros _ h <;> simp at h <;> simp [h]\n    exact IH _ h\n#align computation.lift_rel_rec.lem Computation.LiftRelRec.lem\n\ntheorem lift_rel_rec {R : α → β → Prop} (C : Computation α → Computation β → Prop)\n    (H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) :\n    LiftRel R ca cb :=\n  liftRel_mem_cases (LiftRelRec.lem C (@H) ca cb Hc) fun b hb =>\n    (LiftRel.swap _ _ _).2 <|\n      LiftRelRec.lem (swap C) (fun {_ _} h => cast (LiftRelAux.swap _ _ _ _).symm <| H h) cb ca Hc b\n        hb\n#align computation.lift_rel_rec Computation.lift_rel_rec\n\nend Computation\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Seq/Computation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.48660180756531507}}
{"text": "/-\nCopyright (c) 2018 Kevin Buzzard, Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Patrick Massot\n\nThis file is to a certain extent based on `quotient_module.lean` by Johannes Hölzl.\n-/\nimport group_theory.congruence\nimport group_theory.coset\nimport group_theory.subgroup.finite\nimport group_theory.subgroup.pointwise\n\n/-!\n# Quotients of groups by normal subgroups\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis files develops the basic theory of quotients of groups by normal subgroups. In particular it\nproves Noether's first and second isomorphism theorems.\n\n## Main definitions\n\n* `mk'`: the canonical group homomorphism `G →* G/N` given a normal subgroup `N` of `G`.\n* `lift φ`: the group homomorphism `G/N →* H` given a group homomorphism `φ : G →* H` such that\n  `N ⊆ ker φ`.\n* `map f`: the group homomorphism `G/N →* H/M` given a group homomorphism `f : G →* H` such that\n  `N ⊆ f⁻¹(M)`.\n\n## Main statements\n\n* `quotient_ker_equiv_range`: Noether's first isomorphism theorem, an explicit isomorphism\n  `G/ker φ → range φ` for every group homomorphism `φ : G →* H`.\n* `quotient_inf_equiv_prod_normal_quotient`: Noether's second isomorphism theorem, an explicit\n  isomorphism between `H/(H ∩ N)` and `(HN)/N` given a subgroup `H` and a normal subgroup `N` of a\n  group `G`.\n* `quotient_group.quotient_quotient_equiv_quotient`: Noether's third isomorphism theorem,\n  the canonical isomorphism between `(G / N) / (M / N)` and `G / M`, where `N ≤ M`.\n\n## Tags\n\nisomorphism theorems, quotient groups\n-/\n\nopen function\nuniverses u v\n\nnamespace quotient_group\n\nvariables {G : Type u} [group G] (N : subgroup G) [nN : N.normal] {H : Type v} [group H]\ninclude nN\n\n/-- The congruence relation generated by a normal subgroup. -/\n@[to_additive \"The additive congruence relation generated by a normal additive subgroup.\"]\nprotected def con : con G :=\n{ to_setoid := left_rel N,\n  mul' := λ a b c d hab hcd, begin\n    rw [left_rel_eq] at hab hcd ⊢,\n    calc (a * c)⁻¹ * (b * d) = c⁻¹ * (a⁻¹ * b) * c⁻¹⁻¹ * (c⁻¹ * d) :\n      by simp only [mul_inv_rev, mul_assoc, inv_mul_cancel_left]\n    ... ∈ N : N.mul_mem (nN.conj_mem _ hab _) hcd\n  end }\n\n@[to_additive] instance quotient.group : group (G ⧸ N) := (quotient_group.con N).group\n\n/-- The group homomorphism from `G` to `G/N`. -/\n@[to_additive \"The additive group homomorphism from `G` to `G/N`.\"]\ndef mk' : G →* G ⧸ N := monoid_hom.mk' (quotient_group.mk) (λ _ _, rfl)\n\n@[simp, to_additive]\nlemma coe_mk' : (mk' N : G → G ⧸ N) = coe := rfl\n\n@[simp, to_additive]\nlemma mk'_apply (x : G) : mk' N x = x := rfl\n\n@[to_additive]\nlemma mk'_surjective : surjective $ mk' N := @mk_surjective _ _ N\n\n@[to_additive]\nlemma mk'_eq_mk' {x y : G} : mk' N x = mk' N y ↔ ∃ z ∈ N, x * z = y :=\nquotient_group.eq'.trans $\n  by simp only [← _root_.eq_inv_mul_iff_mul_eq, exists_prop, exists_eq_right]\n\n/-- Two `monoid_hom`s from a quotient group are equal if their compositions with\n`quotient_group.mk'` are equal.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext, to_additive /-\" Two `add_monoid_hom`s from an additive quotient group are equal if their\ncompositions with `add_quotient_group.mk'` are equal.\n\nSee note [partially-applied ext lemmas]. \"-/]\nlemma monoid_hom_ext ⦃f g : G ⧸ N →* H⦄ (h : f.comp (mk' N) = g.comp (mk' N)) : f = g :=\nmonoid_hom.ext $ λ x, quotient_group.induction_on x $ (monoid_hom.congr_fun h : _)\n\n@[simp, to_additive]\nlemma eq_one_iff {N : subgroup G} [nN : N.normal] (x : G) : (x : G ⧸ N) = 1 ↔ x ∈ N :=\nbegin\n  refine quotient_group.eq.trans _,\n  rw [mul_one, subgroup.inv_mem_iff],\nend\n\n@[simp, to_additive]\nlemma ker_mk : monoid_hom.ker (quotient_group.mk' N : G →* G ⧸ N) = N :=\nsubgroup.ext eq_one_iff\n\n@[to_additive]\n\n\n-- for commutative groups we don't need normality assumption\nomit nN\n\n@[to_additive]\ninstance quotient.comm_group {G : Type*} [comm_group G] (N : subgroup G) : comm_group (G ⧸ N) :=\n{ mul_comm := λ a b, quotient.induction_on₂' a b\n    (λ a b, congr_arg mk (mul_comm a b)),\n  .. @quotient_group.quotient.group _ _ N N.normal_of_comm }\n\ninclude nN\n\nlocal notation ` Q ` := G ⧸ N\n\n@[simp, to_additive] lemma coe_one : ((1 : G) : Q) = 1 := rfl\n@[simp, to_additive] lemma coe_mul (a b : G) : ((a * b : G) : Q) = a * b := rfl\n@[simp, to_additive] lemma coe_inv (a : G) : ((a⁻¹ : G) : Q) = a⁻¹ := rfl\n@[simp, to_additive] lemma coe_div (a b : G) : ((a / b : G) : Q) = a / b := rfl\n@[simp, to_additive] lemma coe_pow (a : G) (n : ℕ) : ((a ^ n : G) : Q) = a ^ n := rfl\n@[simp, to_additive] lemma coe_zpow (a : G) (n : ℤ) : ((a ^ n : G) : Q) = a ^ n := rfl\n\n/-- A group homomorphism `φ : G →* H` with `N ⊆ ker(φ)` descends (i.e. `lift`s) to a\ngroup homomorphism `G/N →* H`. -/\n@[to_additive \"An `add_group` homomorphism `φ : G →+ H` with `N ⊆ ker(φ)` descends (i.e. `lift`s)\nto a group homomorphism `G/N →* H`.\"]\ndef lift (φ : G →* H) (HN : ∀x∈N, φ x = 1) : Q →* H :=\n(quotient_group.con N).lift φ $ λ x y h, begin\n  simp only [quotient_group.con, left_rel_apply, con.rel_mk] at h,\n  calc φ x = φ (y * (x⁻¹ * y)⁻¹) : by rw [mul_inv_rev, inv_inv, mul_inv_cancel_left]\n       ... = φ y                 : by rw [φ.map_mul, HN _ (N.inv_mem h), mul_one]\n  end\n\n@[simp, to_additive]\nlemma lift_mk {φ : G →* H} (HN : ∀x∈N, φ x = 1) (g : G) : lift N φ HN (g : Q) = φ g := rfl\n\n@[simp, to_additive]\nlemma lift_mk' {φ : G →* H} (HN : ∀x∈N, φ x = 1) (g : G) : lift N φ HN (mk g : Q) = φ g := rfl\n\n@[simp, to_additive]\nlemma lift_quot_mk {φ : G →* H} (HN : ∀x∈N, φ x = 1) (g : G) :\n  lift N φ HN (quot.mk _ g : Q) = φ g := rfl\n\n/-- A group homomorphism `f : G →* H` induces a map `G/N →* H/M` if `N ⊆ f⁻¹(M)`. -/\n@[to_additive \"An `add_group` homomorphism `f : G →+ H` induces a map `G/N →+ H/M` if\n`N ⊆ f⁻¹(M)`.\"]\ndef map (M : subgroup H) [M.normal] (f : G →* H) (h : N ≤ M.comap f) :\n  G ⧸ N →* H ⧸ M :=\nbegin\n  refine quotient_group.lift N ((mk' M).comp f) _,\n  assume x hx,\n  refine quotient_group.eq.2 _,\n  rw [mul_one, subgroup.inv_mem_iff],\n  exact h hx,\nend\n\n@[simp, to_additive] lemma map_coe (M : subgroup H) [M.normal] (f : G →* H) (h : N ≤ M.comap f)\n  (x : G) :\n  map N M f h ↑x = ↑(f x) :=\nrfl\n\n@[to_additive] lemma map_mk' (M : subgroup H) [M.normal] (f : G →* H) (h : N ≤ M.comap f) (x : G) :\n  map N M f h (mk' _ x) = ↑(f x) :=\nrfl\n\n@[to_additive]\nlemma map_id_apply (h : N ≤ subgroup.comap (monoid_hom.id _) N := (subgroup.comap_id N).le) (x) :\n  map N N (monoid_hom.id _) h x = x :=\ninduction_on' x $ λ x, rfl\n\n@[simp, to_additive]\nlemma map_id (h : N ≤ subgroup.comap (monoid_hom.id _) N := (subgroup.comap_id N).le) :\n  map N N (monoid_hom.id _) h = monoid_hom.id _ :=\nmonoid_hom.ext (map_id_apply N h)\n\n@[simp, to_additive]\nlemma map_map {I : Type*} [group I] (M : subgroup H) (O : subgroup I)\n  [M.normal] [O.normal]\n  (f : G →* H) (g : H →* I) (hf : N ≤ subgroup.comap f M) (hg : M ≤ subgroup.comap g O)\n  (hgf : N ≤ subgroup.comap (g.comp f) O :=\n    hf.trans ((subgroup.comap_mono hg).trans_eq (subgroup.comap_comap _ _ _))) (x : G ⧸ N) :\n  map M O g hg (map N M f hf x) = map N O (g.comp f) hgf x :=\nbegin\n  refine induction_on' x (λ x, _),\n  simp only [map_coe, monoid_hom.comp_apply]\nend\n\n@[simp, to_additive]\nlemma map_comp_map {I : Type*} [group I] (M : subgroup H) (O : subgroup I)\n  [M.normal] [O.normal]\n  (f : G →* H) (g : H →* I) (hf : N ≤ subgroup.comap f M) (hg : M ≤ subgroup.comap g O)\n  (hgf : N ≤ subgroup.comap (g.comp f) O :=\n    hf.trans ((subgroup.comap_mono hg).trans_eq (subgroup.comap_comap _ _ _))) :\n  (map M O g hg).comp (map N M f hf) = map N O (g.comp f) hgf :=\nmonoid_hom.ext (map_map N M O f g hf hg hgf)\n\nomit nN\n\nsection congr\n\nvariables (G' : subgroup G) (H' : subgroup H) [subgroup.normal G'] [subgroup.normal H']\n\n/-- `quotient_group.congr` lifts the isomorphism `e : G ≃ H` to `G ⧸ G' ≃ H ⧸ H'`,\ngiven that `e` maps `G` to `H`. -/\n@[to_additive \"`quotient_add_group.congr` lifts the isomorphism `e : G ≃ H` to `G ⧸ G' ≃ H ⧸ H'`,\ngiven that `e` maps `G` to `H`.\"]\ndef congr (e : G ≃* H) (he : G'.map ↑e = H') : G ⧸ G' ≃* H ⧸ H' :=\n{ to_fun := map G' H' ↑e (he ▸ G'.le_comap_map e),\n  inv_fun := map H' G' ↑e.symm (he ▸ (G'.map_equiv_eq_comap_symm e).le),\n  left_inv := λ x, by rw map_map; -- `simp` doesn't like this lemma...\n    simp only [map_map, ← mul_equiv.coe_monoid_hom_trans, mul_equiv.self_trans_symm,\n        mul_equiv.coe_monoid_hom_refl, map_id_apply],\n  right_inv := λ x, by rw map_map; -- `simp` doesn't like this lemma...\n    simp only [← mul_equiv.coe_monoid_hom_trans, mul_equiv.symm_trans_self,\n        mul_equiv.coe_monoid_hom_refl, map_id_apply],\n  .. map G' H' ↑e (he ▸ G'.le_comap_map e) }\n\n@[simp] lemma congr_mk (e : G ≃* H) (he : G'.map ↑e = H')\n  (x) : congr G' H' e he (mk x) = e x :=\nrfl\n\nlemma congr_mk' (e : G ≃* H) (he : G'.map ↑e = H')\n  (x) : congr G' H' e he (mk' G' x) = mk' H' (e x) :=\nrfl\n\n@[simp] lemma congr_apply (e : G ≃* H) (he : G'.map ↑e = H')\n  (x : G) : congr G' H' e he x = mk' H' (e x) :=\nrfl\n\n@[simp] lemma congr_refl (he : G'.map (mul_equiv.refl G : G →* G) = G' := subgroup.map_id G') :\n  congr G' G' (mul_equiv.refl G) he = mul_equiv.refl (G ⧸ G') :=\nby { ext ⟨x⟩, refl }\n\n@[simp] lemma congr_symm (e : G ≃* H) (he : G'.map ↑e = H') :\n  (congr G' H' e he).symm = congr H' G' e.symm ((subgroup.map_symm_eq_iff_map_eq _).mpr he) :=\nrfl\n\nend congr\n\nvariables (φ : G →* H)\n\nopen monoid_hom\n\n/-- The induced map from the quotient by the kernel to the codomain. -/\n@[to_additive \"The induced map from the quotient by the kernel to the codomain.\"]\ndef ker_lift : G ⧸ ker φ →* H :=\nlift _ φ $ λ g, φ.mem_ker.mp\n\n@[simp, to_additive]\nlemma ker_lift_mk (g : G) : (ker_lift φ) g = φ g := lift_mk _ _ _\n\n@[simp, to_additive]\nlemma ker_lift_mk' (g : G) : (ker_lift φ) (mk g) = φ g := lift_mk' _ _ _\n\n@[to_additive]\nlemma ker_lift_injective : injective (ker_lift φ) :=\nassume a b, quotient.induction_on₂' a b $\n  assume a b (h : φ a = φ b), quotient.sound' $\n  by rw [left_rel_apply, mem_ker, φ.map_mul, ← h, φ.map_inv, inv_mul_self]\n\n-- Note that `ker φ` isn't definitionally `ker (φ.range_restrict)`\n-- so there is a bit of annoying code duplication here\n\n/-- The induced map from the quotient by the kernel to the range. -/\n@[to_additive \"The induced map from the quotient by the kernel to the range.\"]\ndef range_ker_lift : G ⧸ ker φ →* φ.range :=\nlift _ φ.range_restrict $ λ g hg, (mem_ker _).mp $ by rwa ker_range_restrict\n\n@[to_additive]\nlemma range_ker_lift_injective : injective (range_ker_lift φ) :=\nassume a b, quotient.induction_on₂' a b $\n  assume a b (h : φ.range_restrict a = φ.range_restrict b), quotient.sound' $\n  by rw [left_rel_apply, ←ker_range_restrict, mem_ker,\n  φ.range_restrict.map_mul, ← h, φ.range_restrict.map_inv, inv_mul_self]\n\n@[to_additive]\nlemma range_ker_lift_surjective : surjective (range_ker_lift φ) :=\nbegin\n  rintro ⟨_, g, rfl⟩,\n  use mk g,\n  refl,\nend\n\n/-- **Noether's first isomorphism theorem** (a definition): the canonical isomorphism between\n`G/(ker φ)` to `range φ`. -/\n@[to_additive \"The first isomorphism theorem (a definition): the canonical isomorphism between\n`G/(ker φ)` to `range φ`.\"]\nnoncomputable def quotient_ker_equiv_range : G ⧸ ker φ ≃* range φ :=\nmul_equiv.of_bijective (range_ker_lift φ) ⟨range_ker_lift_injective φ, range_ker_lift_surjective φ⟩\n\n/-- The canonical isomorphism `G/(ker φ) ≃* H` induced by a homomorphism `φ : G →* H`\nwith a right inverse `ψ : H → G`. -/\n@[to_additive \"The canonical isomorphism `G/(ker φ) ≃+ H` induced by a homomorphism `φ : G →+ H`\nwith a right inverse `ψ : H → G`.\", simps]\ndef quotient_ker_equiv_of_right_inverse (ψ : H → G) (hφ : right_inverse ψ φ) :\n  G ⧸ ker φ ≃* H :=\n{ to_fun := ker_lift φ,\n  inv_fun := mk ∘ ψ,\n  left_inv := λ x, ker_lift_injective φ (by rw [comp_app, ker_lift_mk', hφ]),\n  right_inv := hφ,\n  .. ker_lift φ }\n\n/-- The canonical isomorphism `G/⊥ ≃* G`. -/\n@[to_additive \"The canonical isomorphism `G/⊥ ≃+ G`.\", simps]\ndef quotient_bot : G ⧸ (⊥ : subgroup G) ≃* G :=\nquotient_ker_equiv_of_right_inverse (monoid_hom.id G) id (λ x, rfl)\n\n/-- The canonical isomorphism `G/(ker φ) ≃* H` induced by a surjection `φ : G →* H`.\n\nFor a `computable` version, see `quotient_group.quotient_ker_equiv_of_right_inverse`.\n-/\n@[to_additive \"The canonical isomorphism `G/(ker φ) ≃+ H` induced by a surjection `φ : G →+ H`.\n\nFor a `computable` version, see `quotient_add_group.quotient_ker_equiv_of_right_inverse`.\"]\nnoncomputable def quotient_ker_equiv_of_surjective (hφ : surjective φ) :\n  G ⧸ (ker φ) ≃* H :=\nquotient_ker_equiv_of_right_inverse φ _ hφ.has_right_inverse.some_spec\n\n/-- If two normal subgroups `M` and `N` of `G` are the same, their quotient groups are\nisomorphic. -/\n@[to_additive \"If two normal subgroups `M` and `N` of `G` are the same, their quotient groups are\nisomorphic.\"]\ndef quotient_mul_equiv_of_eq {M N : subgroup G} [M.normal] [N.normal] (h : M = N) :\n  G ⧸ M ≃* G ⧸ N :=\n{ map_mul' := λ q r, quotient.induction_on₂' q r (λ g h, rfl),\n  .. subgroup.quotient_equiv_of_eq h }\n\n@[simp, to_additive]\nlemma quotient_mul_equiv_of_eq_mk {M N : subgroup G} [M.normal] [N.normal] (h : M = N) (x : G) :\n  quotient_group.quotient_mul_equiv_of_eq h (quotient_group.mk x) = (quotient_group.mk x) :=\nrfl\n\n/-- Let `A', A, B', B` be subgroups of `G`. If `A' ≤ B'` and `A ≤ B`,\nthen there is a map `A / (A' ⊓ A) →* B / (B' ⊓ B)` induced by the inclusions. -/\n@[to_additive \"Let `A', A, B', B` be subgroups of `G`. If `A' ≤ B'` and `A ≤ B`,\nthen there is a map `A / (A' ⊓ A) →+ B / (B' ⊓ B)` induced by the inclusions.\"]\ndef quotient_map_subgroup_of_of_le {A' A B' B : subgroup G}\n  [hAN : (A'.subgroup_of A).normal] [hBN : (B'.subgroup_of B).normal]\n  (h' : A' ≤ B') (h : A ≤ B) :\n  A ⧸ (A'.subgroup_of A) →* B ⧸ (B'.subgroup_of B) :=\nmap _ _ (subgroup.inclusion h) $ subgroup.comap_mono h'\n\n@[simp, to_additive]\nlemma quotient_map_subgroup_of_of_le_coe {A' A B' B : subgroup G}\n  [hAN : (A'.subgroup_of A).normal] [hBN : (B'.subgroup_of B).normal]\n  (h' : A' ≤ B') (h : A ≤ B) (x : A) :\n  quotient_map_subgroup_of_of_le h' h x = ↑(subgroup.inclusion h x : B) := rfl\n\n/-- Let `A', A, B', B` be subgroups of `G`.\nIf `A' = B'` and `A = B`, then the quotients `A / (A' ⊓ A)` and `B / (B' ⊓ B)` are isomorphic.\n\nApplying this equiv is nicer than rewriting along the equalities, since the type of\n`(A'.subgroup_of A : subgroup A)` depends on on `A`.\n-/\n@[to_additive \"Let `A', A, B', B` be subgroups of `G`.\nIf `A' = B'` and `A = B`, then the quotients `A / (A' ⊓ A)` and `B / (B' ⊓ B)` are isomorphic.\n\nApplying this equiv is nicer than rewriting along the equalities, since the type of\n`(A'.add_subgroup_of A : add_subgroup A)` depends on on `A`.\n\"]\ndef equiv_quotient_subgroup_of_of_eq {A' A B' B : subgroup G}\n  [hAN : (A'.subgroup_of A).normal] [hBN : (B'.subgroup_of B).normal]\n  (h' : A' = B') (h : A = B) :\n  A ⧸ (A'.subgroup_of A) ≃* B ⧸ (B'.subgroup_of B) :=\nmonoid_hom.to_mul_equiv\n  (quotient_map_subgroup_of_of_le h'.le h.le) (quotient_map_subgroup_of_of_le h'.ge h.ge)\n  (by { ext ⟨x, hx⟩, refl })\n  (by { ext ⟨x, hx⟩, refl })\n\nsection zpow\n\nvariables {A B C : Type u} [comm_group A] [comm_group B] [comm_group C]\nvariables (f : A →* B) (g : B →* A) (e : A ≃* B) (d : B ≃* C) (n : ℤ)\n\n/-- The map of quotients by powers of an integer induced by a group homomorphism. -/\n@[to_additive \"The map of quotients by multiples of an integer induced by an additive group\nhomomorphism.\"]\ndef hom_quotient_zpow_of_hom :\n  A ⧸ (zpow_group_hom n : A →* A).range →* B ⧸ (zpow_group_hom n : B →* B).range :=\nlift _ ((mk' _).comp f) $\n  λ g ⟨h, (hg : h ^ n = g)⟩, (eq_one_iff _).mpr ⟨_, by simpa only [← hg, map_zpow]⟩\n\n@[simp, to_additive]\nlemma hom_quotient_zpow_of_hom_id :\n  hom_quotient_zpow_of_hom (monoid_hom.id A) n = monoid_hom.id _ :=\nmonoid_hom_ext _ rfl\n\n@[simp, to_additive]\nlemma hom_quotient_zpow_of_hom_comp :\n  hom_quotient_zpow_of_hom (f.comp g) n\n    = (hom_quotient_zpow_of_hom f n).comp (hom_quotient_zpow_of_hom g n) :=\nmonoid_hom_ext _ rfl\n\n@[simp, to_additive]\nlemma hom_quotient_zpow_of_hom_comp_of_right_inverse (i : function.right_inverse g f) :\n  (hom_quotient_zpow_of_hom f n).comp (hom_quotient_zpow_of_hom g n) = monoid_hom.id _ :=\nmonoid_hom_ext _ $ monoid_hom.ext $ λ x, congr_arg coe $ i x\n\n/-- The equivalence of quotients by powers of an integer induced by a group isomorphism. -/\n@[to_additive \"The equivalence of quotients by multiples of an integer induced by an additive group\nisomorphism.\"]\ndef equiv_quotient_zpow_of_equiv :\n  A ⧸ (zpow_group_hom n : A →* A).range ≃* B ⧸ (zpow_group_hom n : B →* B).range :=\nmonoid_hom.to_mul_equiv _ _ (hom_quotient_zpow_of_hom_comp_of_right_inverse e.symm e n e.left_inv)\n  (hom_quotient_zpow_of_hom_comp_of_right_inverse e e.symm n e.right_inv)\n\n@[simp, to_additive]\nlemma equiv_quotient_zpow_of_equiv_refl :\n  mul_equiv.refl (A ⧸ (zpow_group_hom n : A →* A).range)\n    = equiv_quotient_zpow_of_equiv (mul_equiv.refl A) n :=\nby { ext x, rw [← quotient.out_eq' x], refl }\n\n@[simp, to_additive]\nlemma equiv_quotient_zpow_of_equiv_symm :\n  (equiv_quotient_zpow_of_equiv e n).symm = equiv_quotient_zpow_of_equiv e.symm n :=\nrfl\n\n@[simp, to_additive]\nlemma equiv_quotient_zpow_of_equiv_trans :\n  (equiv_quotient_zpow_of_equiv e n).trans (equiv_quotient_zpow_of_equiv d n)\n    = equiv_quotient_zpow_of_equiv (e.trans d) n :=\nby { ext x, rw [← quotient.out_eq' x], refl }\n\nend zpow\n\nsection snd_isomorphism_thm\n\nopen _root_.subgroup\n\n/-- **Noether's second isomorphism theorem**: given two subgroups `H` and `N` of a group `G`, where\n`N` is normal, defines an isomorphism between `H/(H ∩ N)` and `(HN)/N`. -/\n@[to_additive \"The second isomorphism theorem: given two subgroups `H` and `N` of a group `G`,\nwhere `N` is normal, defines an isomorphism between `H/(H ∩ N)` and `(H + N)/N`\"]\nnoncomputable def quotient_inf_equiv_prod_normal_quotient (H N : subgroup G) [N.normal] :\n  H ⧸ (N.subgroup_of H) ≃* _ ⧸ (N.subgroup_of (H ⊔ N)) :=\n/- φ is the natural homomorphism H →* (HN)/N. -/\nlet φ : H →* _ ⧸ (N.subgroup_of (H ⊔ N)) :=\n  (mk' $ N.subgroup_of (H ⊔ N)).comp (inclusion le_sup_left) in\nhave φ_surjective : surjective φ := λ x, x.induction_on' $\n  begin\n    rintro ⟨y, (hy : y ∈ ↑(H ⊔ N))⟩, rw mul_normal H N at hy,\n    rcases hy with ⟨h, n, hh, hn, rfl⟩,\n    use [h, hh], apply quotient.eq.mpr,\n    change setoid.r _ _,\n    rw left_rel_apply,\n    change h⁻¹ * (h * n) ∈ N,\n    rwa [←mul_assoc, inv_mul_self, one_mul],\n  end,\n(quotient_mul_equiv_of_eq (by simp [← comap_ker])).trans\n  (quotient_ker_equiv_of_surjective φ φ_surjective)\n\nend snd_isomorphism_thm\n\nsection third_iso_thm\n\nvariables (M : subgroup G) [nM : M.normal]\n\ninclude nM nN\n\n@[to_additive] instance map_normal : (M.map (quotient_group.mk' N)).normal :=\nnM.map _ mk_surjective\n\nvariables (h : N ≤ M)\n\n/-- The map from the third isomorphism theorem for groups: `(G / N) / (M / N) → G / M`. -/\n@[to_additive \"The map from the third isomorphism theorem for additive groups:\n`(A / N) / (M / N) → A / M`.\"]\ndef quotient_quotient_equiv_quotient_aux :\n  (G ⧸ N) ⧸ (M.map (mk' N)) →* G ⧸ M :=\nlift (M.map (mk' N))\n  (map N M (monoid_hom.id G) h)\n  (by { rintro _ ⟨x, hx, rfl⟩, rw map_mk' N M _ _ x,\n        exact (quotient_group.eq_one_iff _).mpr hx })\n\n@[simp, to_additive]\nlemma quotient_quotient_equiv_quotient_aux_coe (x : G ⧸ N) :\n  quotient_quotient_equiv_quotient_aux N M h x = quotient_group.map N M (monoid_hom.id G) h x :=\nquotient_group.lift_mk' _ _ x\n\n@[to_additive]\nlemma quotient_quotient_equiv_quotient_aux_coe_coe (x : G) :\n  quotient_quotient_equiv_quotient_aux N M h (x : G ⧸ N) =\n    x :=\nquotient_group.lift_mk' _ _ x\n\n/-- **Noether's third isomorphism theorem** for groups: `(G / N) / (M / N) ≃* G / M`. -/\n@[to_additive \"**Noether's third isomorphism theorem** for additive groups:\n`(A / N) / (M / N) ≃+ A / M`.\"]\ndef quotient_quotient_equiv_quotient :\n  (G ⧸ N) ⧸ (M.map (quotient_group.mk' N)) ≃* G ⧸ M :=\nmonoid_hom.to_mul_equiv\n  (quotient_quotient_equiv_quotient_aux N M h)\n  (quotient_group.map _ _ (quotient_group.mk' N) (subgroup.le_comap_map _ _))\n  (by { ext, simp })\n  (by { ext, simp })\n\nend third_iso_thm\n\nsection trivial\n\n@[to_additive] lemma subsingleton_quotient_top :\n  subsingleton (G ⧸ (⊤ : subgroup G)) :=\nbegin\n  dsimp [has_quotient.quotient, subgroup.has_quotient, quotient],\n  rw left_rel_eq,\n  exact @trunc.subsingleton G,\nend\n\n/-- If the quotient by a subgroup gives a singleton then the subgroup is the whole group. -/\n@[to_additive \"If the quotient by an additive subgroup gives a singleton then the additive subgroup\nis the whole additive group.\"] lemma subgroup_eq_top_of_subsingleton (H : subgroup G)\n  (h : subsingleton (G ⧸ H)) : H = ⊤ :=\ntop_unique $ λ x _,\n  have this : 1⁻¹ * x ∈ H := quotient_group.eq.1 (subsingleton.elim _ _),\n  by rwa [inv_one, one_mul] at this\n\nend trivial\n\n@[to_additive]\nlemma comap_comap_center {H₁ : subgroup G} [H₁.normal] {H₂ : subgroup (G ⧸ H₁)} [H₂.normal] :\n  (((subgroup.center ((G ⧸ H₁) ⧸ H₂))).comap (mk' H₂)).comap (mk' H₁) =\n  (subgroup.center (G ⧸ H₂.comap (mk' H₁))).comap (mk' (H₂.comap (mk' H₁))) :=\nbegin\n  ext x,\n  simp only [mk'_apply, subgroup.mem_comap, subgroup.mem_center_iff, forall_coe,\n    ← coe_mul, eq_iff_div_mem, coe_div]\nend\n\nend quotient_group\n\nnamespace group\n\nopen_locale classical\nopen quotient_group subgroup\n\nvariables {F G H : Type u} [group F] [group G] [group H] [fintype F] [fintype H]\nvariables (f : F →* G) (g : G →* H)\n\n/-- If `F` and `H` are finite such that `ker(G →* H) ≤ im(F →* G)`, then `G` is finite. -/\n@[to_additive \"If `F` and `H` are finite such that `ker(G →+ H) ≤ im(F →+ G)`, then `G` is finite.\"]\nnoncomputable def fintype_of_ker_le_range (h : g.ker ≤ f.range) : fintype G :=\n@fintype.of_equiv _ _ (@prod.fintype _ _ (fintype.of_injective _ $ ker_lift_injective g) $\n                                          fintype.of_injective _ $ inclusion_injective h)\n  group_equiv_quotient_times_subgroup.symm\n\n/-- If `F` and `H` are finite such that `ker(G →* H) = im(F →* G)`, then `G` is finite. -/\n@[to_additive \"If `F` and `H` are finite such that `ker(G →+ H) = im(F →+ G)`, then `G` is finite.\"]\nnoncomputable def fintype_of_ker_eq_range (h : g.ker = f.range) : fintype G :=\nfintype_of_ker_le_range _ _ h.le\n\n/-- If `ker(G →* H)` and `H` are finite, then `G` is finite. -/\n@[to_additive \"If `ker(G →+ H)` and `H` are finite, then `G` is finite.\"]\nnoncomputable def fintype_of_ker_of_codom [fintype g.ker] : fintype G :=\nfintype_of_ker_le_range ((top_equiv : _ ≃* G).to_monoid_hom.comp $ inclusion le_top) g $\n  λ x hx, ⟨⟨x, hx⟩, rfl⟩\n\n/-- If `F` and `coker(F →* G)` are finite, then `G` is finite. -/\n@[to_additive \"If `F` and `coker(F →+ G)` are finite, then `G` is finite.\"]\nnoncomputable def fintype_of_dom_of_coker [normal f.range] [fintype $ G ⧸ f.range] : fintype G :=\nfintype_of_ker_le_range _ (mk' f.range) $ λ x, (eq_one_iff x).mp\n\nend group\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/group_theory/quotient_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.48660180353823757}}
{"text": "/-\nCopyright (c) 2019 Neil Strickland. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Neil Strickland\n\nThis file effectively deals with the cartesian-closed category\nof finite posets and the associated \"strong homotopy category\".\nHowever, we have taken an ad hoc approach rather than using the\ncategory theory library.\n-/\n\nimport order.basic order.sort_rank\nimport logic.equiv.basic\nimport data.fintype.basic data.fin_extra\nimport logic.relation\nimport algebra.punit_instances\n\nuniverses uP uQ uR uS\n\nvariables (P : Type uP) [partial_order P]\nvariables (Q : Type uQ) [partial_order Q]\nvariables (R : Type uR) [partial_order R]\nvariables (S : Type uS) [partial_order S]\n\nnamespace poset \n\nstructure hom := \n(val : P → Q)\n(property : monotone val)\n\ninstance : has_coe_to_fun (hom P Q) (λ _, P → Q) := {\n coe := λ f, f.val\n}\n\n@[ext]\nlemma hom_ext (f g : hom P Q) : \n  (∀ (p : P), f p = g p) → f = g :=\nbegin\n  rcases f with ⟨f,hf⟩,\n  rcases g with ⟨g,hg⟩,\n  intro h,\n  have h' : f = g := funext h,\n  rcases h', refl,\nend\n\ndef id : hom P P := ⟨_root_.id,monotone_id⟩\n\nlemma id_val : (id P).val = _root_.id := rfl\n\nvariables {P Q R}\n\ninstance hom_order : partial_order (hom P Q) := {\n le := λ f g, ∀ p, (f p) ≤ (g p),\n le_refl := λ f p,le_refl (f p),\n le_antisymm := λ f g f_le_g g_le_f,\n  begin ext p, exact le_antisymm (f_le_g p) (g_le_f p), end,\n le_trans := λ f g h f_le_g g_le_h p,\n   le_trans (f_le_g p) (g_le_h p)\n}\n\n@[simp]\nlemma id_eval (p : P) : (id P) p = p := rfl\n\nvariable (P)\ndef const (q : Q) : hom P Q := ⟨λ p,q, λ p₀ p₁ hp, le_refl q⟩\n\ndef terminal : hom P punit.{uP + 1} := const P punit.star\nvariable {P}\n\nlemma eq_terminal (f : hom P punit.{uP + 1}) : f = terminal P := by { ext p }\n\n@[irreducible] \ndef adjoint (f : hom P Q) (g : hom Q P) : Prop :=\n  ∀ {p : P} {q : Q}, f p ≤ q ↔ p ≤ g q\n\ndef adjoint.iff {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  ∀ {p : P} {q : Q}, f p ≤ q ↔ p ≤ g q := \n    by { intros p q, unfold adjoint at h, exact h }\n\ndef comp : (hom Q R) → (hom P Q) → (hom P R) := \n λ g f, ⟨g.val ∘ f.val, monotone.comp g.property f.property⟩\n\nlemma comp_val (g : hom Q R) (f : hom P Q) : \n (comp g f).val = g.val ∘ f.val := rfl\n\nlemma id_comp (f : hom P Q) : comp (id Q) f = f := by {ext, refl}\nlemma comp_id (f : hom P Q) : comp f (id P) = f := by {ext, refl}\nlemma comp_assoc (h : hom R S) (g : hom Q R) (f : hom P Q) : \n comp (comp h g) f = comp h (comp g f) := by {ext, refl}\n\nlemma const_comp (r : R) (f : hom P Q) :\n comp (const Q r) f = const P r := by {ext, refl}\n\nlemma comp_const (g : hom Q R) (q : Q) :\n comp g (const P q) = const P (g q) := by {ext, refl}\n\nlemma comp_mono₂ {g₀ g₁ : hom Q R} {f₀ f₁ : hom P Q} \n (eg : g₀ ≤ g₁) (ef : f₀ ≤ f₁) : comp g₀ f₀ ≤ comp g₁ f₁ := \n λ p, calc \n  g₀.val (f₀.val p) ≤ g₀.val (f₁.val p) : g₀.property (ef p)\n  ... ≤ g₁.val (f₁.val p) : eg (f₁.val p)\n\n@[simp]\nlemma comp_eval (g : hom Q R) (f : hom P Q) (p : P) : \n (comp g f) p = g (f p) := rfl\n\ndef comp' : (hom Q R) × (hom P Q) → (hom P R) := \n λ ⟨g,f⟩, comp g f\n\nlemma comp'_mono : monotone (@comp' P _ Q _ R _) := \n λ ⟨g₀,f₀⟩ ⟨g₁,f₁⟩ ⟨eg,ef⟩, comp_mono₂ eg ef\n\ndef eval : (hom P Q) → P → Q := λ f p, f.val p\n\nlemma eval_mono₂ {f₀ f₁ : hom P Q} {p₀ p₁ : P} \n (ef : f₀ ≤ f₁) (ep : p₀ ≤ p₁) : eval f₀ p₀ ≤ eval f₁ p₁ := \ncalc \n  f₀.val p₀ ≤ f₀.val p₁ : f₀.property ep\n  ... ≤ f₁.val p₁ : ef p₁  \n\ndef eval' : (hom P Q) × P → Q := λ ⟨f,p⟩, eval f p\n\nlemma eval'_mono : monotone (@eval' P _ Q _) := \n λ ⟨f₀,p₀⟩ ⟨f₁,p₁⟩ ⟨ef,ep⟩, eval_mono₂ ef ep\n\ndef ins' : P → (hom Q (P × Q)) := \n λ p, ⟨λ q,⟨p,q⟩, λ q₀ q₁ eq, ⟨le_refl p,eq⟩⟩ \n\nlemma ins_mono : monotone (@ins' P _ Q _) := \n λ p₀ p₁ ep q, ⟨ep,le_refl q⟩\n\nlemma adjoint.unit {f : hom P Q} {g : hom Q P} (h : adjoint f g) :\n  id P ≤ comp g f := λ p, h.iff.mp (le_refl (f p))\n\nlemma adjoint.counit {f : hom P Q} {g : hom Q P} (h : adjoint f g) :\n  comp f g ≤ id Q := λ q, h.iff.mpr (le_refl (g q))\n\nvariable (P)\ndef π₀ : Type* := quot (has_le.le : P → P → Prop)\nvariable {P}\n\ndef component (p : P) : π₀ P := quot.mk _ p\n\ndef connected : P → P → Prop := λ p₀ p₁, component p₀ = component p₁ \n\nlemma π₀.sound {p₀ p₁ : P} (hp : p₀ ≤ p₁) : \n component p₀ = component p₁ := quot.sound hp\n\nlemma π₀.epi {X : Type*} (f₀ f₁ : π₀ P → X) \n (h : ∀ p, f₀ (component p) = f₁ (component p)) : f₀ = f₁ := \n  by {apply funext, rintro ⟨p⟩, exact (h p),}\n\ndef π₀.lift {X : Type*} (f : P → X)\n (h : ∀ p₀ p₁ : P, p₀ ≤ p₁ → f p₀ = f p₁) : \n  (π₀ P) → X := @quot.lift P has_le.le X f h\n\nlemma π₀.lift_beta {X : Type*} (f : P → X)\n (h : ∀ p₀ p₁ : P, p₀ ≤ p₁ → f p₀ = f p₁) (p : P) :\n  π₀.lift f h (component p) = f p := \n   @quot.lift_beta P has_le.le X f h p \n\ndef π₀.lift₂ {X : Type*} (f : P → Q → X)\n (h : ∀ p₀ p₁ q₀ q₁, p₀ ≤ p₁ → q₀ ≤ q₁ → f p₀ q₀ = f p₁ q₁) : \n  (π₀ P) → (π₀ Q) → X := \nbegin\n let h1 := λ p q₀ q₁ hq, h p p q₀ q₁ (le_refl p) hq,\n let f1 : P → (π₀ Q) → X := λ p, π₀.lift (f p) (h1 p),\n let hf1 : ∀ p q, f1 p (component q) = f p q := λ p, π₀.lift_beta (f p) (h1 p),\n let h2 : ∀ p₀ p₁, p₀ ≤ p₁ → f1 p₀ = f1 p₁ := λ p₀ p₁ hp,\n  begin\n   apply π₀.epi,intro q,rw[hf1,hf1],\n   exact h p₀ p₁ q q hp (le_refl q),\n  end,\n exact π₀.lift f1 h2\nend\n\nlemma π₀.lift₂_beta {X : Type*} (f : P → Q → X)\n (h : ∀ p₀ p₁ q₀ q₁, p₀ ≤ p₁ → q₀ ≤ q₁ → f p₀ q₀ = f p₁ q₁)\n  (p : P) (q : Q) : (π₀.lift₂ f h) (component p) (component q) = f p q := \nbegin\n unfold π₀.lift₂,simp only [],rw[π₀.lift_beta,π₀.lift_beta],\nend\n\nlemma parity_induction (u : ℕ → Prop)\n  (h_zero : u 0)\n  (h_even : ∀ i, u (2 * i) → u (2 * i + 1))\n  (h_odd  : ∀ i, u (2 * i + 1) → u (2 * i + 2)) : \n  ∀ i, u i\n| 0 := h_zero \n| (i + 1) := \nbegin\n  have ih := parity_induction i,\n  let k := i.div2, \n  have hi : cond i.bodd 1 0 + 2 * k = i := nat.bodd_add_div2 i,\n  rcases i.bodd ; intro hk; rw[cond] at hk,\n  { rw [zero_add] at hk,\n    rw [← hk] at ih ⊢, \n    exact h_even k ih },\n  { rw [add_comm] at hk,\n    rw [← hk] at ih ⊢, \n    exact h_odd k ih }\nend\n\nlemma zigzag (u : ℕ → P) \n  (h_even : ∀ i, u (2 * i) ≤ u (2 * i + 1))\n  (h_odd : ∀ i, u (2 * i + 2) ≤ u(2 * i + 1)) : \n   ∀ i, component (u i) = component (u 0) := \nparity_induction \n (λ i, component (u i) = component (u 0))\n rfl \n (λ i h, (π₀.sound (h_even i)).symm.trans h)\n (λ i h, (π₀.sound (h_odd i)).trans h)\n\nvariables (P Q)\ndef homₕ := π₀ (hom P Q)\n\ndef idₕ : homₕ P P := component (id P)\n\nvariables {P Q}\n\ndef compₕ : (homₕ Q R) → (homₕ P Q) → (homₕ P R) := \n π₀.lift₂ (λ g f, component (comp g f)) (begin \n  intros g₀ g₁ f₀ f₁ hg hf,\n  let hgf := comp_mono₂ hg hf,\n  let hgf' := π₀.sound hgf,\n  exact (π₀.sound (comp_mono₂ hg hf))\n end)\n\nlemma compₕ_def (g : hom Q R) (f : hom P Q) : \n compₕ (component g) (component f) = component (comp g f) := \n  by {simp[compₕ,π₀.lift₂_beta]}\n\nlemma id_compₕ (f : homₕ P Q) : compₕ (idₕ Q) f = f := \n begin \n  rcases f with ⟨f⟩,\n  change compₕ (component (id Q)) (component f) = component f,\n  rw[compₕ_def,id_comp],\n end \n\nlemma comp_idₕ (f : homₕ P Q) : compₕ f (idₕ P) = f := \n begin \n  rcases f with ⟨f⟩,\n  change compₕ (component f) (component (id P)) = component f,\n  rw[compₕ_def,comp_id],\n end \n\nlemma comp_assocₕ (h : homₕ R S) (g : homₕ Q R) (f : homₕ P Q) : \n compₕ (compₕ h g) f = compₕ h (compₕ g f) := \n begin\n  rcases h with ⟨h⟩, rcases g with ⟨g⟩, rcases f with ⟨f⟩,\n  change compₕ (compₕ (component h) (component g)) (component f) =\n         compₕ (component h) (compₕ (component g) (component f)),\n  repeat {rw[compₕ_def]},rw[comp_assoc],\n end\n\nvariables (P Q)\nstructure equivₕ :=\n(to_fun : homₕ P Q)\n(inv_fun : homₕ Q P)\n(left_inv : compₕ inv_fun to_fun = idₕ P)\n(right_inv : compₕ to_fun inv_fun = idₕ Q)\n\n@[refl] def equivₕ.refl : equivₕ P P := \n{ to_fun := idₕ P, inv_fun := idₕ P,\n  left_inv := comp_idₕ _,\n  right_inv := comp_idₕ _ }\n\nvariables {P Q}\n\n@[symm] def equivₕ.symm (e : equivₕ P Q) : equivₕ Q P := \n{ to_fun := e.inv_fun, inv_fun := e.to_fun, \n  left_inv := e.right_inv, right_inv := e.left_inv }\n\n@[trans] def equivₕ.trans (e : equivₕ P Q) (f : equivₕ Q R) : (equivₕ P R) := \n{ to_fun  := compₕ f.to_fun e.to_fun,\n  inv_fun := compₕ e.inv_fun f.inv_fun,\n  left_inv := by\n    rw [comp_assocₕ, ← comp_assocₕ _ f.inv_fun, f.left_inv,\n        id_compₕ, e.left_inv],\n  right_inv := by\n    rw [comp_assocₕ, ← comp_assocₕ _ e.to_fun, e.right_inv,\n        id_compₕ, f.right_inv] }\n\nlemma adjoint.unitₕ {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  compₕ (component g) (component f) = idₕ P := \nbegin\n  have : id P ≤ comp g f := by { apply adjoint.unit, assumption },\n  exact (π₀.sound this).symm\nend\n\nlemma adjoint.counitₕ {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  compₕ (component f) (component g) = idₕ Q := \nbegin\n  have : comp f g ≤ id Q := by { apply adjoint.counit, assumption },\n  exact (π₀.sound this)\nend\n\n/-- LaTeX: rem-adjoint-strong -/\ndef equivₕ_of_adjoint {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  equivₕ P Q :=\n{ to_fun := component f, \n  inv_fun := component g,\n  left_inv := adjoint.unitₕ h,\n  right_inv := adjoint.counitₕ h }\n\nvariable (P)\n\n/-- defn-strongly-contractible -/\ndef contractibleₕ := nonempty (equivₕ P punit.{uP + 1})\n\nvariable {P}\n\nlemma contractibleₕ_of_smallest {m : P} (h : ∀ p, m ≤ p) : contractibleₕ P := \nbegin\n  have : adjoint (const punit.{uP + 1} m) (terminal P) :=\n  begin\n    unfold adjoint,\n    rintro ⟨⟩ p,\n    change m ≤ p ↔ punit.star ≤ punit.star,\n    simp only [le_refl, h p],\n  end,\n  let hh := equivₕ_of_adjoint this,\n  exact ⟨hh.symm⟩,\nend\n\ndef π₀.map (f : hom P Q) : (π₀ P) → (π₀ Q) := \n π₀.lift (λ p, component (f p)) (λ p₀ p₁ ep, quot.sound (f.property ep))\n\nlemma π₀.map_def (f : hom P Q) (p : P) : π₀.map f (component p) = component (f p) := \n by { simp [π₀.map, π₀.lift_beta] }\n\nlemma π₀.map_congr {f₀ f₁ : hom P Q} (ef : f₀ ≤ f₁) : π₀.map f₀ = π₀.map f₁ := \nbegin \n  apply π₀.epi,\n  intro p,\n  rw [π₀.map_def, π₀.map_def],\n  exact π₀.sound (ef p)\nend\n\nvariable (P)\nlemma π₀.map_id : π₀.map (id P) = _root_.id := \n by { apply π₀.epi, intro p, rw[π₀.map_def], refl }\nvariable {P}\n\nlemma π₀.map_comp (g : hom Q R) (f : hom P Q) :\n π₀.map (comp g f) = (π₀.map g) ∘ (π₀.map f) := \n  by { apply π₀.epi, intro p, rw[π₀.map_def], refl }\n\ndef evalₕ : (homₕ P Q) → (π₀ P) → (π₀ Q) := \n π₀.lift π₀.map (@π₀.map_congr _ _ _ _)\n\nvariables {P Q}\n\ndef comma (f : hom P Q) (q : Q) := { p : P // f p ≤ q }\n\ninstance comma_order (f : hom P Q) (q : Q) :\n  partial_order (comma f q) := by { dsimp[comma], apply_instance }\n\ndef cocomma (f : hom P Q) (q : Q) := { p : P // q ≤ f p }\n\ninstance cocomma_order (f : hom P Q) (q : Q) :\n  partial_order (cocomma f q) := by { dsimp[cocomma], apply_instance }\n\n/-- Here we define predicates finalₕ and cofinalₕ.  \n  If (finalₕ f) holds then f is homotopy cofinal, by \n  prop-cofinal.  The dual is also valid, but the converse \n  is not.  \n-/\n\ndef finalₕ (f : hom P Q) : Prop := \n  ∀ q, contractibleₕ (cocomma f q)\n\ndef cofinalₕ (f : hom P Q) : Prop := \n  ∀ q, contractibleₕ (comma f q)\n\n\nvariable (P)\n\nstructure fin_ranking := \n(card : ℕ)\n(rank : P ≃ fin card)\n(rank_mono : monotone rank.to_fun)\n\nsection sort \n\nvariable {P}\nvariable [decidable_rel (has_le.le : P → P → Prop)]\n\ndef is_semisorted (l : list P) : Prop := \n  l.pairwise (λ a b, ¬ b < a)\n\nlemma mem_ordered_insert (x p : P) (l : list P) : \n  x ∈ (l.ordered_insert has_le.le p) ↔ x = p ∨ x ∈ l := \nbegin\n  rw [list.perm.mem_iff (list.perm_ordered_insert _ _ _)],\n  apply list.mem_cons_iff  \nend\n\nlemma insert_semisorted (p : P) (l : list P) (h : is_semisorted l) : \n  is_semisorted (l.ordered_insert has_le.le p) :=\nbegin\n  induction h with q l hq hl ih,\n  { apply list.pairwise_singleton },\n  { dsimp [list.ordered_insert], \n    split_ifs with hpq, \n    { apply list.pairwise.cons, \n      { intros x x_in_ql,\n        rcases (list.mem_cons_iff _ _ _).mp x_in_ql with ⟨⟨⟩⟩ | x_in_l,\n        { exact not_lt_of_ge hpq },\n        { intro x_lt_p, \n          exact hq x x_in_l (lt_of_lt_of_le x_lt_p hpq) } },\n      { exact list.pairwise.cons hq hl } }, \n    { apply list.pairwise.cons,\n      { intros x x_in_pl x_lt_q, \n        rw [mem_ordered_insert] at x_in_pl,\n        rcases x_in_pl with ⟨⟨⟩⟩ | x_in_l,\n        { exact hpq (le_of_lt x_lt_q) },\n        { exact hq x x_in_l x_lt_q } },\n      { exact ih } } }\nend\n\nlemma insertion_sort_semisorted (l : list P) : \n  is_semisorted (l.insertion_sort (has_le.le : P → P → Prop)) :=\nbegin\n  induction l with p l ih,\n  { apply list.pairwise.nil },\n  { dsimp [list.insertion_sort],\n    apply insert_semisorted,\n    exact ih }\nend\n\nvariable (P) \n\nlemma exists_fin_ranking [fintype P] : nonempty (fin_ranking P) := \nbegin\n  rcases fintype.equiv_fin P with f,\n  let n := fintype.card P,\n  let l := (fin.elems_list n).map f.symm,\n  have l_nodup : l.nodup :=\n    list.nodup.map f.symm.injective (fin.elems_list_nodup _),\n  have l_univ : ∀ p, p ∈ l := λ p,\n  begin \n    apply list.mem_map.mpr,\n    exact ⟨f.to_fun p, ⟨fin.elems_list_complete (f.to_fun p),f.left_inv p⟩⟩\n  end,\n  have l_length : l.length = n := \n    (list.length_map f.symm (fin.elems_list _)).trans (fin.elems_list_length _),\n  let ls := l.insertion_sort has_le.le,\n  let ls_perm := list.perm_insertion_sort has_le.le l,\n  have ls_sorted : is_semisorted ls := \n    insertion_sort_semisorted l,\n  have ls_nodup : ls.nodup := \n    (list.perm.nodup_iff ls_perm).mpr l_nodup,\n  have ls_univ : ∀ p, p ∈ ls := λ p, \n    (list.perm.mem_iff ls_perm).mpr (l_univ p),\n  have ls_length : ls.length = n := \n    (list.perm.length_eq ls_perm).trans l_length,\n  let inv_fun : (fin n) → P := \n    λ i, ls.nth_le i.val (@eq.subst ℕ (nat.lt i.val) _ _ ls_length.symm i.is_lt),\n  let to_fun_aux : ∀ a : P, {i : fin n // inv_fun i = a} := \n  begin\n    intro p,\n    let i_val := ls.index_of p,\n    let i_lt_l := list.index_of_lt_length.mpr (ls_univ p),\n    let i_lt_n : i_val < n := @eq.subst ℕ (nat.lt i_val) _ _ ls_length i_lt_l,\n    let i : fin n := ⟨i_val,i_lt_n⟩,\n    have : inv_fun i = p := list.index_of_nth_le i_lt_l,\n    exact ⟨i,this⟩ \n  end,\n  let to_fun : P → (fin n) := λ p, (to_fun_aux p).val,\n  let left_inv : ∀ p : P, inv_fun (to_fun p) = p := \n    λ p, (to_fun_aux p).property,\n  let right_inv : ∀ i : (fin n), to_fun (inv_fun i) = i := \n  begin\n   intro i,cases i with i_val i_is_lt,\n   apply fin.eq_of_veq,\n   let i_lt_l : i_val < ls.length := \n    @eq.subst ℕ (nat.lt i_val) _ _ ls_length.symm i_is_lt,\n   exact list.nth_le_index_of ls_nodup i_val i_lt_l,\n  end,\n  let g : P ≃ (fin n) := ⟨to_fun,inv_fun,left_inv,right_inv⟩,\n  have g_mono : monotone g.to_fun := λ p q hpq, \n  begin\n    let i := g.to_fun p,\n    let j := g.to_fun q,\n    have hp : g.inv_fun i = p := g.left_inv p,\n    have hq : g.inv_fun j = q := g.left_inv q,\n    have hi : i.val < ls.length := by { rw [ls_length], exact i.is_lt },\n    have hj : j.val < ls.length := by { rw [ls_length], exact j.is_lt },\n    by_cases h : i ≤ j, { exact h },\n    exfalso,\n    replace h := lt_of_not_ge h,\n    have hp' : ls.nth_le i.val hi = g.inv_fun i := rfl,\n    have hq' : ls.nth_le j.val hj = g.inv_fun j := rfl,\n    let h_ne  := list.pairwise_nth_iff.mp ls_nodup h hi,\n    let h_ngt := list.pairwise_nth_iff.mp ls_sorted h hi,\n    rw [hp', hq', hp, hq] at h_ne h_ngt,\n    exact h_ngt (lt_of_le_of_ne hpq h_ne.symm),\n  end,\n  exact ⟨⟨n,g,g_mono⟩⟩\nend\n\nend sort \n\n\nend poset", "meta": {"author": "NeilStrickland", "repo": "lean_lib", "sha": "6a9563de93748ace509d9db4302db6cd77d8f92c", "save_path": "github-repos/lean/NeilStrickland-lean_lib", "path": "github-repos/lean/NeilStrickland-lean_lib/lean_lib-6a9563de93748ace509d9db4302db6cd77d8f92c/src/poset/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6926419704455588, "lm_q1q2_score": 0.4866018032514464}}
{"text": "import tactic \n\nstructure Dict (α : Type*) (β : Type*) :=\n  (data : α -> option β)\n\nnamespace Dict\n  variables {α β : Type*}\n  [decidable_eq α]\n\n  def empty : Dict α β :=\n    ⟨λ k, none⟩\n\n  def add (d : Dict α β) (k : α) (e : β) : Dict α β :=\n    ⟨λ k', if k' = k then e else d.data k'⟩\n  \n  def rem (d : Dict α β) (k : α) : Dict α β :=\n    ⟨λ k', if k' = k then none else d.data k'⟩\n\n  def get (d : Dict α β) (k : α) : option β := d.data k\n  \n  def inDict (d : Dict α β) (x : α) := d.get x ≠ none \n\n  instance : has_mem α (Dict α β) := ⟨λ k d, inDict d k⟩ \n\n  def subDictOf (d1 d2 : Dict α β) := ∀ k ∈ d1, d1.get k = d2.get k\n  \n  theorem emptySubdictAll (d : Dict α β) : subDictOf empty d := \n  begin \n    intros k h,\n    exact congr_fun (false.rec (empty.get = λ (k : α), get d k) (h rfl)) k,\n  end\n\n  theorem subDictSelf (d : Dict α β) : subDictOf d d :=\n  begin \n    intros k h,\n    refl,\n  end\n\n  theorem getSome {d : Dict α β} {x : α} {y : β} : Dict.get d x = (some y) -> x ∈ d :=\n  begin\n    intro h,\n    unfold has_mem.mem,\n    rw inDict,\n    rw h,\n    simp only [ne.def, not_false_iff],\n  end\n\n\n  theorem subDictAdd {d1 d2 : Dict α β} (h : subDictOf d1 d2) : \n  ∀ k e, subDictOf (add d1 k e) (add d2 k e)\n  :=\n  begin\n    intros k e k' h',\n    simp only [add, get],\n    split_ifs with lem,\n    { refl },\n    specialize h k',\n    simp only [has_mem.mem, inDict, get, add, lem, if_false, ne.def] at h',\n    exact h h',\n  end\nend Dict", "meta": {"author": "zaxioms", "repo": "stlc-lean", "sha": "8019f986056c895a0c9a3804fccdba86f57ef7e9", "save_path": "github-repos/lean/zaxioms-stlc-lean", "path": "github-repos/lean/zaxioms-stlc-lean/stlc-lean-8019f986056c895a0c9a3804fccdba86f57ef7e9/src/dict.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.4866017989375779}}
{"text": "import MLIR.Util.FinInt\nimport MLIR.Dialects.ArithSemantics\nopen MLIR.AST\n\nabbrev FinIntPred1 := (sz: Nat) → FinInt sz → Bool\nabbrev FinIntPred2 := (sz: Nat) → FinInt sz → FinInt sz → Bool\nabbrev FinIntPred3 := (sz: Nat) → FinInt sz → FinInt sz → FinInt sz → Bool\n\ndef isTautologyUpTo1 (sz: Nat) (P: FinIntPred1): Bool :=\n  match sz with\n  | 0 => P 0 .nil\n  | sz+1 =>\n      isTautologyUpTo1 sz (fun sz n => P (sz+1) n.O) &&\n      isTautologyUpTo1 sz (fun sz n => P (sz+1) n.I)\n\ndef isTautologyUpTo2 (sz: Nat) (P: FinIntPred2): Bool :=\n  match sz with\n  | 0 => P 0 .nil .nil\n  | sz+1 =>\n      isTautologyUpTo2 sz (fun sz n m => P (sz+1) n.O m.O) &&\n      isTautologyUpTo2 sz (fun sz n m => P (sz+1) n.O m.I) &&\n      isTautologyUpTo2 sz (fun sz n m => P (sz+1) n.I m.O) &&\n      isTautologyUpTo2 sz (fun sz n m => P (sz+1) n.I m.I)\n\ndef P₁: FinIntPred2 := fun _ X Y =>\n  ((X ||| Y) - X) = ((X ^^^ -1) &&& Y)\n\ntheorem P₁_tautology8: isTautologyUpTo2 8 P₁ := by\n  native_decide\n\ndef P₂: FinIntPred2 := fun _ X Y =>\n  (X + Y) - (X &&& Y) = (X ||| Y)\n\ntheorem P₂_tautology8: isTautologyUpTo2 8 P₂ := by\n  native_decide\n\ndef P₃: FinIntPred2 := fun _ X Y =>\n  -(FinInt.select 0 (-X) Y) = FinInt.select 0 X (-Y) &&\n  -(FinInt.select 1 (-X) Y) = FinInt.select 1 X (-Y)\n\ntheorem P₃_tautology8: isTautologyUpTo2 8 P₃ := by\n  native_decide\n\n--\n\naxiom alive1 (P: FinIntPred1):\n  isTautologyUpTo1 8 P → ∀ sz n, P sz n\n\naxiom alive2 (P: FinIntPred2):\n  isTautologyUpTo2 8 P → ∀ sz n m, P sz n m\n\n---\n\nnamespace BruteforceThm1\ndef LHS: Region arith := [mlir_region|{\n    %_1 = \"addi\"(%X, %Y): (i32, i32) -> i32\n    %_2 = \"andi\"(%X, %Y): (i32, i32) -> i32\n    %r = \"subi\"(%_1, %_2): (i32, i32) -> i32\n}]\ndef RHS: Region arith := [mlir_region|{\n  ^bb:\n    %r = \"ori\"(%X, %Y): (i32, i32) -> i32\n}]\ndef INPUT (X Y: FinInt 32): SSAEnv arith := SSAEnv.One [\n  (\"X\", ⟨.i32, X⟩), (\"Y\", ⟨.i32, Y⟩)\n]\n\n-- Too long... times out during type checking\n/-\ntheorem equivalent (X Y: FinInt 32):\n    (run (denoteBB _ LHS) (INPUT X Y) |>.snd.get \"r\" .i32) =\n    (run (denoteBB _ RHS) (INPUT X Y) |>.snd.get \"r\" .i32) := by\n  simp [LHS, RHS, INPUT]\n  simp [run, denoteBB, denoteBBStmt, denoteOp]; simp_itree\n  simp [interpUB']; simp_itree\n  simp [interpSSA', Fitree.interpState, SSAEnvE.handle, SSAEnv.get]; simp_itree\n  repeat (simp [SSAEnv.get]; simp_itree)\n  have h := alive2 _ P₂_tautology8 _ X Y\n  simp [P₂] at h; assumption\n-/\nend BruteforceThm1\n", "meta": {"author": "opencompl", "repo": "lean-mlir", "sha": "85fd61e38dec57e4d67d7af4d49a1ccc67828c1b", "save_path": "github-repos/lean/opencompl-lean-mlir", "path": "github-repos/lean/opencompl-lean-mlir/lean-mlir-85fd61e38dec57e4d67d7af4d49a1ccc67828c1b/MLIR/Examples/FinIntBruteforce.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637505099168, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.48658561682480994}}
{"text": "import Qpf\n\nopen MvQPF\n\n\n\n-- inductive QpfStruct (α : Type) where\n--   mk : α → QpfStruct α\n\nnamespace QpfStruct\n\n  abbrev HeadT  := Unit\n\n  @[simp]\n  abbrev ChildT : HeadT → TypeVec 2\n    := fun _ i => match i with \n        | 0 => Empty \n        | 1 => Unit\n\n  abbrev P := MvPFunctor.mk HeadT ChildT\n\n  abbrev QpfStruct (α : Type)\n    := Fix P.Obj (fun _ => α)\n\n  abbrev mk {α : Type} (a : α) : QpfStruct α\n    := Fix.mk ⟨(), fun i _ => match i with  \n                                | 0 => by contradiction\n                                | 1 => a\n    ⟩\n\n  -- def rec {α} \n  --         {motive : QpfStruct α → Sort _} \n  --         : ((a : α) → motive (mk a))\n  --         → (t : QpfStruct α)\n  --         → motive t := \n  --   fun recurse t =>\n  --     let g := fun ⟨a, f⟩ =>\n  --       by cases a\n  --          let a := f 1(a₁, ..., aₘ).append1, Vec.cons] at a;\n  --          apply recurse a\n  --     Fix.drec (β := motive) g t\n\n  abbrev rec {α motive} := Fix.drec (F:=P.Obj) (α := α) (β := motive)\n\n  -- open MvPFunctor in\n  -- example : QpfStruct α → α :=\n  --   by intro x\n  --      let x := Fix.dest x;\n  --      simp [Obj, TypeVec.append1] at x;\n  --      cases x\n  --     --  have : ∃ a f, x = Fix.mk ⟨a, f⟩\n  --     --   := by unfold QpfStruct\n           \n  --      cases x using QpfStruct.rec\n    \nend QpfStruct\n\nopen QpfStruct (QpfStruct)", "meta": {"author": "alexkeizer", "repo": "qpf4", "sha": "980f97425b9d5a5e3897073df33794192b3b3124", "save_path": "github-repos/lean/alexkeizer-qpf4", "path": "github-repos/lean/alexkeizer-qpf4/qpf4-980f97425b9d5a5e3897073df33794192b3b3124/Qpf/Examples/_00_QpfStruct.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478256, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.48654691956335205}}
{"text": "import Kenny_comm_alg.ideal_lattice\n\nnoncomputable theory\nlocal attribute [instance] classical.prop_decidable\n\nuniverse u\n\nnamespace is_ideal\n\nsection maximal_ideal\n\nparameters {α : Type u} [comm_ring α] (P : set α) [hp : is_proper_ideal P]\ninclude hp\n\ndef find_maximal_ideal.partial_order : partial_order {S : set α // P ⊆ S ∧ is_proper_ideal S} :=\nsubrel.partial_order\n\ndef find_maximal_ideal.inhabited : inhabited {S : set α // P ⊆ S ∧ is_proper_ideal S} :=\n⟨⟨P, set.subset.refl P, hp⟩⟩\n\nlocal attribute [instance] find_maximal_ideal.partial_order find_maximal_ideal.inhabited\n\nprivate theorem find_maximal_ideal.aux :\n  ∃ (M : {S : set α // P ⊆ S ∧ is_proper_ideal S}), ∀ x, M ≤ x → x = M :=\nzorn.zorn' {S : set α // P ⊆ S ∧ is_proper_ideal S} $\nλ c x hx hc, ⟨⟨{y | ∃ S : {S : set α // P ⊆ S ∧ is_proper_ideal S}, S ∈ c ∧ y ∈ S.val},\n  λ z hz, ⟨x, hx, x.2.1 hz⟩,\n  { zero_ := ⟨x, hx, @@is_ideal.zero _ x.1 x.2.2.to_is_ideal⟩,\n    add_  := λ x y ⟨Sx, hxc, hx⟩ ⟨Sy, hyc, hy⟩,\n      or.cases_on (hc Sx Sy hxc hyc)\n        (λ hxy, ⟨Sy, hyc, @@is_ideal.add _ Sy.2.2.to_is_ideal (hxy hx) hy⟩)\n        (λ hyx, ⟨Sx, hxc, @@is_ideal.add _ Sx.2.2.to_is_ideal hx (hyx hy)⟩),\n    smul  := λ x y ⟨Sy, hyc, hy⟩,\n      ⟨Sy, hyc, @@is_ideal.mul_left _ Sy.2.2.to_is_ideal hy⟩,\n    ne_univ := λ h, by rw set.eq_univ_iff_forall at h;\n      rcases h 1 with ⟨S, hsc, hs⟩; apply S.2.2.ne_univ;\n      exact @@is_submodule.univ_of_one_mem _ S.1\n        S.2.2.to_is_ideal.to_is_submodule hs }⟩,\nλ S hsc z hzs, ⟨S, hsc, hzs⟩⟩\n\ndef find_maximal_ideal : set α :=\n(classical.some find_maximal_ideal.aux).1\n\ntheorem find_maximal_ideal.contains : P ⊆ find_maximal_ideal :=\n(classical.some find_maximal_ideal.aux).2.1\n\ndef find_maximal_ideal.is_maximal_ideal :\n  is_maximal_ideal find_maximal_ideal :=\nlet M : {S : set α // P ⊆ S ∧ is_proper_ideal S} :=\nclassical.some find_maximal_ideal.aux in\n{ eq_or_univ_of_subset := λ T ht hmt, or_iff_not_imp_right.2 $\n    λ h, congr_arg subtype.val $\n    classical.some_spec find_maximal_ideal.aux\n    ⟨T, set.subset.trans M.2.1 hmt, { ne_univ := h, .. ht }⟩ hmt,\n  ..M.2.2 }\n\nend maximal_ideal\n\nsection nonunits\n\nparameters {α : Type u} [comm_ring α]\nparameters (x : α) (hx : x ∈ nonunits α)\n\ninclude hx\n\ntheorem ne_univ_of_nonunits : span ({x}:set α) ≠ set.univ :=\nbegin\n  intro h,\n  rw [span_singleton, set.eq_univ_iff_forall] at h,\n  exact hx (h 1)\nend\n\ndef find_maximal_ideal.of_nonunits : set α :=\n@@find_maximal_ideal _ (span ({x}:set α))\n{ ne_univ := ne_univ_of_nonunits }\n\ntheorem find_maximal_ideal.of_nonunits.mem :\n  x ∈ find_maximal_ideal.of_nonunits :=\n@@find_maximal_ideal.contains _ (span ({x}:set α))\n{ ne_univ := ne_univ_of_nonunits } $\nsubset_span $ set.mem_singleton x\n\ndef find_maximal_ideal.of_nonunits.is_maximal_ideal :\n  is_maximal_ideal find_maximal_ideal.of_nonunits :=\n@@find_maximal_ideal.is_maximal_ideal _ (span ({x}:set α))\n{ ne_univ := ne_univ_of_nonunits }\n\nend nonunits\n\nsection zero_ne_one\n\nparameters {α : Type u} [comm_ring α]\nparameters (hzo : (0:α) ≠ 1)\n\ninclude hzo\n\ndef find_maximal_ideal.of_zero_ne_one : set α :=\nfind_maximal_ideal.of_nonunits 0 $\nλ ⟨y, h⟩, hzo $ by simpa using h\n\ndef find_maximal_ideal.of_zero_ne_one.is_maximal_ideal :\n  is_maximal_ideal find_maximal_ideal.of_zero_ne_one :=\nfind_maximal_ideal.of_nonunits.is_maximal_ideal 0 $\nλ ⟨y, h⟩, hzo $ by simpa using h\n\nend zero_ne_one\n\nend is_ideal", "meta": {"author": "kbuzzard", "repo": "lean-stacks-project", "sha": "b57be17aa917f1c3a23c59db5ee37b1aa21112c2", "save_path": "github-repos/lean/kbuzzard-lean-stacks-project", "path": "github-repos/lean/kbuzzard-lean-stacks-project/lean-stacks-project-b57be17aa917f1c3a23c59db5ee37b1aa21112c2/src/Kenny_comm_alg/maximal_ideal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478255, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4865469195633519}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\nThe Schröder-Bernstein theorem, and well ordering of cardinals.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.fixed_points\nimport Mathlib.order.zorn\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\nnamespace function\n\n\nnamespace embedding\n\n\ntheorem schroeder_bernstein {α : Type u} {β : Type v} {f : α → β} {g : β → α} (hf : injective f)\n    (hg : injective g) : ∃ (h : α → β), bijective h :=\n  sorry\n\ntheorem antisymm {α : Type u} {β : Type v} : (α ↪ β) → (β ↪ α) → Nonempty (α ≃ β) := sorry\n\ntheorem min_injective {ι : Type u} {β : ι → Type v} (I : Nonempty ι) :\n    ∃ (i : ι), Nonempty ((j : ι) → β i ↪ β j) :=\n  sorry\n\ntheorem total {α : Type u} {β : Type v} : Nonempty (α ↪ β) ∨ Nonempty (β ↪ α) := sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/set_theory/schroeder_bernstein_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478254, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.48654691956335183}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n\nNonnegative real numbers.\n-/\nimport data.real.nnreal analysis.real analysis.topology.infinite_sum\nnoncomputable theory\nopen set topological_space\n\nnamespace nnreal\nlocal notation ` ℝ≥0 ` := nnreal\n\ninstance : metric_space ℝ≥0 := by unfold nnreal; apply_instance\ninstance : topological_space ℝ≥0 := infer_instance\n\ninstance : topological_semiring ℝ≥0 :=\n{ continuous_mul :=\n   continuous_subtype_mk _\n        (continuous_mul (continuous.comp continuous_fst continuous_subtype_val)\n                        (continuous.comp continuous_snd continuous_subtype_val)),\n  continuous_add :=\n    continuous_subtype_mk _\n          (continuous_add (continuous.comp continuous_fst continuous_subtype_val)\n                          (continuous.comp continuous_snd continuous_subtype_val)) }\n\ninstance : orderable_topology ℝ≥0 :=\n⟨ le_antisymm\n    begin\n      apply induced_le_iff_le_coinduced.2,\n      rw [orderable_topology.topology_eq_generate_intervals ℝ],\n      apply generate_from_le,\n      assume s hs,\n      rcases hs with ⟨a, rfl | rfl⟩,\n      { show topological_space.generate_open _ {b : ℝ≥0 | a < b },\n        by_cases ha : 0 ≤ a,\n        { exact topological_space.generate_open.basic _ ⟨⟨a, ha⟩, or.inl rfl⟩ },\n        { have : a < 0, from lt_of_not_ge ha,\n          have : {b : ℝ≥0 | a < b } = set.univ,\n            from (set.eq_univ_iff_forall.2 $ assume b, lt_of_lt_of_le this b.2),\n          rw [this],\n          exact topological_space.generate_open.univ _ } },\n      { show (topological_space.generate_from _).is_open {b : ℝ≥0 | a > b },\n        by_cases ha : 0 ≤ a,\n        { exact topological_space.generate_open.basic _ ⟨⟨a, ha⟩, or.inr rfl⟩ },\n        { have : {b : ℝ≥0 | a > b } = ∅,\n            from (set.eq_empty_iff_forall_not_mem.2 $ assume b hb, ha $\n              show 0 ≤ a, from le_trans b.2 (le_of_lt hb)),\n          rw [this],\n          apply @is_open_empty } },\n    end\n    (generate_from_le $ assume s hs,\n    match s, hs with\n    | _, ⟨⟨a, ha⟩, or.inl rfl⟩ := ⟨{b : ℝ | a < b}, is_open_lt' a, rfl⟩\n    | _, ⟨⟨a, ha⟩, or.inr rfl⟩ := ⟨{b : ℝ | b < a}, is_open_gt' a, set.ext $ assume b, iff.refl _⟩\n    end) ⟩\n\nsection coe\nvariable {α : Type*}\nopen filter\n\nlemma continuous_of_real : continuous nnreal.of_real :=\ncontinuous_subtype_mk _ $ continuous_max continuous_id continuous_const\n\nlemma continuous_coe : continuous (coe : nnreal → ℝ) :=\ncontinuous_subtype_val\n\nlemma tendsto_coe {f : filter α} {m : α → nnreal} :\n  ∀{x : nnreal}, tendsto (λa, (m a : ℝ)) f (nhds (x : ℝ)) ↔ tendsto m f (nhds x)\n| ⟨r, hr⟩ := by rw [nhds_subtype_eq_comap, tendsto_comap_iff]; refl\n\nlemma tendsto_of_real {f : filter α} {m : α → ℝ} {x : ℝ} (h : tendsto m f (nhds x)):\n  tendsto (λa, nnreal.of_real (m a)) f (nhds (nnreal.of_real x)) :=\nh.comp (continuous_iff_tendsto.1 continuous_of_real _)\n\nlemma tendsto_sub {f : filter α} {m n : α → nnreal} {r p : nnreal}\n  (hm : tendsto m f (nhds r)) (hn : tendsto n f (nhds p)) :\n  tendsto (λa, m a - n a) f (nhds (r - p)) :=\ntendsto_of_real $ tendsto_sub (tendsto_coe.2 hm) (tendsto_coe.2 hn)\n\nlemma is_sum_coe {f : α → nnreal} {r : nnreal} : is_sum (λa, (f a : ℝ)) (r : ℝ) ↔ is_sum f r :=\nby simp [is_sum, sum_coe.symm, tendsto_coe]\n\nlemma has_sum_coe {f : α → nnreal} : has_sum (λa, (f a : ℝ)) ↔ has_sum f :=\nbegin\n  simp [has_sum],\n  split,\n  exact assume ⟨a, ha⟩, ⟨⟨a, is_sum_le (λa, (f a).2) is_sum_zero ha⟩, is_sum_coe.1 ha⟩,\n  exact assume ⟨a, ha⟩, ⟨a.1, is_sum_coe.2 ha⟩\nend\n\nlemma tsum_coe {f : α → nnreal} (hf : has_sum f) : (∑a, (f a : ℝ)) = ↑(∑a, f a) :=\ntsum_eq_is_sum $ is_sum_coe.2 $ is_sum_tsum $ hf\n\nend coe\n\nend nnreal", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/analysis/nnreal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.48650159294056344}}
{"text": "theorem succ_inj' {a b : mynat} (hs : succ(a) = succ(b)) :  a = b := \nbegin\ncases hs,\nrefl,\nend\n\n-- theorem succ_inj' {a b : mynat} (hs : succ(a) = succ(b)) :  a = b := \n-- begin\n-- exact succ_inj hs,\n-- end\n\n-- theorem succ_inj' {a b : mynat} (hs : succ(a) = succ(b)) :  a = b := \n-- begin\n-- apply succ_inj,\n-- rw hs,\n-- refl,\n-- end\n\n-- theorem succ_inj' {a b : mynat} (hs : succ(a) = succ(b)) :  a = b := \n-- begin\n-- have f := succ_inj,\n-- exact f(hs),\n-- end\n", "meta": {"author": "chanha-park", "repo": "naturalNumberGame", "sha": "4e0d7100ce4575e1add92feefa38b1250431b879", "save_path": "github-repos/lean/chanha-park-naturalNumberGame", "path": "github-repos/lean/chanha-park-naturalNumberGame/naturalNumberGame-4e0d7100ce4575e1add92feefa38b1250431b879/Advanced_Addition/1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203135, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.48650157492168483}}
{"text": "import tactic\nimport tactic.induction\nimport logic.function.iterate\nimport data.list.basic\n\nnoncomputable theory\nopen_locale classical\n\ndef get_some {α : Type} [inhabited α] (P : α → Prop) : α :=\nif h : ∃ (x : α), P x then h.some else default\n\ndef fixed {α : Type} [inhabited α] (f : α → α) (z : α) : α :=\nget_some (λ (x : α), ∃ (n : ℕ), (f^[n]) z = x ∧ (f^[n + 1]) z = x)\n\ndef all {α : Type} (P : α → Prop) (l : list α) : Prop := l.all (λ (x : α), P x)\n\ndef is_digit (n : ℕ) : Prop := n ≤ 9\n\ndef is_digit_list (l : list ℕ) : Prop := all is_digit l\n\ndef get_digits (n : ℕ) : list ℕ :=\nget_some (λ (l : list ℕ), is_digit_list l ∧ l.foldl (λ (a b : ℕ), a * 10 + b) 0 = n)\n\ndef sum_digits (n : ℕ) : ℕ := (get_digits n).sum\n\ndef digital_root (n : ℕ) : ℕ := fixed sum_digits n\n\n-----\n\nlemma get_some_pos {α : Type} [inhabited α] {P : α → Prop}\n  (h : ∃ (x : α), P x) : get_some P = h.some :=\ndif_pos h\n\nlemma get_some_eq_get_some_of_exists_iff {α β : Type} [inhabited α]\n  {P₁ P₂ : α → Prop} {f : α → β}\n  (h₁ : (∃ (x : α), P₁ x) ↔ (∃ (x : α), P₂ x))\n  (h₂ : ∀ (h₁ : ∃ (x : α), P₁ x) (h₂ : ∃ (x : α), P₂ x), f h₁.some = f h₂.some) :\n  f (get_some P₁) = f (get_some P₂) :=\nbegin\n  simp_rw [get_some, h₁], split_ifs with h₃,\n  { apply h₂ },\n  { refl },\nend\n\ndef reversed {α : Type} (f : list α → list α) (l : list α) : list α :=\n(f l.reverse).reverse\n\ndef trim_start : list ℕ → list ℕ\n| (0::l) := trim_start l\n| l := l\n\ndef trim_end : list ℕ → list ℕ :=\nreversed trim_start\n\ninstance {n : ℕ} : decidable (is_digit n) :=\nby { rw is_digit, apply_instance }\n\nlemma list_reverse_snoc {α : Type} {l : list α} {x : α} :\n  (l ++ [x]).reverse = x :: l.reverse := list.reverse_append _ _\n\nlemma trim_start_zero_cons {l : list ℕ} : trim_start (0 :: l) = trim_start l := rfl\n\nlemma trim_start_succ_cons {l : list ℕ} {n : ℕ} :\n  trim_start (n.succ :: l) = n.succ :: l := rfl\n\nlemma trim_end_snoc_zero {l : list ℕ} : trim_end (l ++ [0]) = trim_end l :=\nby { rw [trim_end, reversed, list_reverse_snoc, trim_start_zero_cons], refl }\n\nlemma list_length_snoc {α : Type} {l : list α} {x : α} :\n  (l ++ [x]).length = l.length + 1 := list.length_append _ _\n\nlemma trim_end_snoc_succ {l : list ℕ} {n : ℕ} :\n  trim_end (l ++ [n.succ]) = l ++ [n.succ] :=\nby rw [trim_end, reversed, list_reverse_snoc, trim_start_succ_cons,\n  list.reverse_cons, list.reverse_reverse]\n\nlemma length_trim_end_le {l : list ℕ} : (trim_end l).length ≤ l.length :=\nbegin\n  induction l using list.reverse_rec_on with l n ih,\n  { refl },\n  { cases n,\n    { rw [trim_end_snoc_zero, list_length_snoc],\n      exact nat.le_succ_of_le ih },\n    { rw [trim_end_snoc_succ] }},\nend\n\nlemma list_repeat_succ_snoc {α : Type} {x : α} {n : ℕ} :\n  list.repeat x n.succ = list.repeat x n ++ [x] :=\nby { rw list.repeat_add x n 1, refl }\n\nlemma trim_end_append_repeat_zero {l : list ℕ} :\n  trim_end l ++ list.repeat 0 (l.length - (trim_end l).length) = l :=\nbegin\n  induction l using list.reverse_rec_on with l n ih,\n  { refl },\n  { cases n,\n    { rw [trim_end_snoc_zero, list_length_snoc, nat.sub_add_comm length_trim_end_le,\n        list_repeat_succ_snoc, ←list.append_assoc, ih] },\n    { rw [trim_end_snoc_succ, list_length_snoc, nat.sub_self,\n      list.repeat, list.append_nil] }},\nend\n\nlemma all_nil {α : Type} {P : α → Prop} : all P [] := by simp [all]\n\nlemma all_cons {α : Type} {P : α → Prop} {l : list α} {x : α} :\n  all P (x :: l) ↔ P x ∧ all P l := by simp [all]\n\nlemma all_iff {α : Type} {P : α → Prop} {l : list α} : all P l ↔ ∀ (x ∈ l), P x :=\nbegin\n  induction l with x l ih,\n  { simp [all_nil] },\n  { simp [all_cons, ih] },\nend\n\nlemma all_append {α : Type} {P : α → Prop} {l₁ l₂ : list α} :\n  all P (l₁ ++ l₂) ↔ all P l₁ ∧ all P l₂ :=\nbegin\n  simp_rw all_iff, split; intro h,\n  { split; rintro n h₁; apply h n,\n    { exact list.mem_append_left _ h₁ },\n    { exact list.mem_append_right _ h₁ }},\n  { cases h with h₁ h₂, rintro n h₃, rw list.mem_append_eq at h₃, cases h₃,\n    { exact h₁ _ h₃ },\n    { exact h₂ _ h₃ }},\nend\n\nlemma all_singleton {α : Type} {P : α → Prop} {x : α} : all P [x] ↔ P x :=\nbegin\n  simp_rw all_iff, split; intro h,\n  { exact h _ (list.mem_singleton_self _) },\n  { rintro m h₁, rw list.mem_singleton at h₁, subst m, exact h },\nend\n\nlemma all_snoc {α : Type} {P : α → Prop} {l : list α} {x : α} :\n  all P (l ++ [x]) ↔ all P l ∧ P x := by rw [all_append, all_singleton]\n\nlemma all_reverse {α : Type} {P : α → Prop} {l : list α} : all P l.reverse ↔ all P l :=\nbegin\n  induction l with n l ih,\n  { refl },\n  { rw [list.reverse_cons, all_snoc, all_cons], tauto },\nend\n\nlemma is_digit_of_is_digit_add {d₁ d₂ : ℕ} (h : is_digit (d₁ + d₂)) :\n  is_digit d₁ ∧ is_digit d₂ := ⟨le_of_add_le_left h, le_of_add_le_right h⟩\n\nlemma not_is_digit_add_10 {n : ℕ} : ¬is_digit (n + 10) := dec_trivial\n\nlemma is_digit_mul_10 {n : ℕ} : is_digit (n * 10) ↔ n = 0 :=\nbegin\n  split; intro h,\n  { cases n,\n    { refl },\n    { revert h, rw nat.succ_mul, dec_trivial }},\n  { subst n, dec_trivial },\nend\n\nlemma sum_eq_zero_of_foldr_eq_zero {l : list ℕ}\n  (h : l.foldr (λ (a b : ℕ), a + b * 10) 0 = 0) : l.sum = 0 :=\nbegin\n  induction' l with hd l ih,\n  { refl },\n  { rw [list.foldr_cons, add_eq_zero_iff] at h, rcases h with ⟨rfl, h⟩,\n    apply ih, rw mul_eq_zero at h, cases h,\n    { exact h },\n    { cases h }},\nend\n\nlemma sum_eq_of_foldr_eq_digit {l : list ℕ} {d : ℕ}\n  (h₁ : is_digit_list l) (h₂ : is_digit d)\n  (h₃ : l.foldr (λ (a b : ℕ), a + b * 10) 0 = d) : l.sum = d :=\nbegin\n  cases l with d₁ l,\n  { exact h₃ },\n  { rw list.sum_cons, rw list.foldr_cons at h₃, rw [is_digit_list, all_cons] at h₁,\n    cases h₁ with h₁ h₄, subst d, congr, have h₃ := (is_digit_of_is_digit_add h₂).2,\n    rw is_digit_mul_10 at h₃, rw h₃, exact sum_eq_zero_of_foldr_eq_zero h₃ },\nend\n\nlemma is_digit_succ {n : ℕ} : is_digit n.succ ↔ n < 9 :=\nbegin\n  rw [is_digit, le_iff_lt_or_eq], split; intro h,\n  { cases h,\n    { exact nat.lt_of_succ_lt h },\n    { cases h, dec_trivial }},\n  { rwa [←nat.succ_le_iff, le_iff_lt_or_eq] at h },\nend\n\nlemma nat_exi_mul (x y : ℕ) :\n  ∃ (a b : ℕ), a = x / y ∧ b = x % y ∧ x = a * y + b :=\nby { simp_rw mul_comm, exact ⟨_, _, rfl, rfl, (nat.div_add_mod _ _).symm⟩ }\n\nlemma is_digit_mod_10 {n : ℕ} : is_digit (n % 10) :=\nby { rw [is_digit, ←nat.lt_succ_iff], apply nat.mod_lt, dec_trivial }\n\nlemma digit_ind {P : ℕ → Prop} {n : ℕ}\n  (h₁ : P 0) (h₂ : ∀ (d n : ℕ), is_digit d → P n → P (d + n * 10)) : P n :=\nbegin\n  induction n using nat.strong_induction_on with n ih, dsimp at ih,\n  obtain ⟨a, b, ha, hb, h₃⟩ := nat_exi_mul n 10, rw [h₃, add_comm], apply h₂,\n  { rw hb, exact is_digit_mod_10 },\n  { rw ha, cases n,\n    { exact h₁ },\n    { apply ih, apply nat.div_lt_self; dec_trivial }},\nend\n\ndef all_zeros (l : list ℕ) : Prop := all (λ (n : ℕ), n = 0) l\n\nlemma foldr_eq_zero_iff {l : list ℕ} :\n  l.foldr (λ (a b : ℕ), a + b * 10) 0 = 0 ↔ all_zeros l :=\nbegin\n  induction l with x l ih,\n  { simp [all_zeros, all_nil] },\n  { rw [list.foldr_cons, all_zeros, all_cons, ←all_zeros, ←ih,\n    add_eq_zero_iff, mul_eq_zero], tauto },\nend\n\nlemma trim_end_nil : trim_end [] = [] := rfl\n\nlemma trim_end_eq_nil_iff {l : list ℕ} : trim_end l = [] ↔ all_zeros l :=\nbegin\n  induction l using list.reverse_rec_on with l n ih,\n  { simp [trim_end_nil, all_zeros, all_nil] },\n  { cases n,\n    { simp [trim_end_snoc_zero, ih, all_zeros, all_snoc] },\n    { simp [trim_end_snoc_succ, all_zeros, all_snoc] }},\nend\n\nlemma left_lt_of_add_lt {a b c : ℕ} (h : a + b < c) : a < c := buffer.lt_aux_1 h\n\nlemma right_lt_of_add_lt {a b c : ℕ} (h : a + b < c) : b < c :=\nby { rw add_comm at h, exact left_lt_of_add_lt h }\n\nlemma lt_of_add_lt {a b c : ℕ} (h : a + b < c) : a < c ∧ b < c :=\n⟨left_lt_of_add_lt h, right_lt_of_add_lt h⟩\n\nlemma not_add_self_lt_self {a b : ℕ} : ¬a + b < b :=\nby { intro h, cases lt_irrefl _ (right_lt_of_add_lt h) }\n\nlemma eq_zero_of_mul_lt_self {a b : ℕ} (h : a * b < a) : b = 0 :=\nbegin\n  cases b,\n  { refl },\n  { rw nat.mul_succ at h, cases not_add_self_lt_self h },\nend\n\nlemma add_mul_eq_add_mul_iff {k d₁ d₂ a b : ℕ} (h₁ : d₁ < k) (h₂ : d₂ < k) :\n  d₁ + a * k = d₂ + b * k ↔ d₁ = d₂ ∧ a = b :=\nbegin\n  split; intro h,\n  { induction a with a ih generalizing b,\n    { rw [zero_mul, add_zero] at h, subst d₁, have h₃ := right_lt_of_add_lt h₁,\n      rw mul_comm at h₃, replace h₃ := eq_zero_of_mul_lt_self h₃, subst b,\n      rw zero_mul, exact ⟨rfl, rfl⟩ },\n    { rw [nat.succ_mul, ←add_assoc] at h, cases b,\n      { rw [zero_mul, add_zero] at h, subst d₂, cases not_add_self_lt_self h₂ },\n      { rw [nat.succ_mul, ←add_assoc, add_left_inj] at h,\n        rw nat.succ_inj', exact ih h }}},\n  { rw [h.1, h.2] },\nend\n\nlemma digit_lt_10 {d : ℕ} (h : is_digit d) : d < 10 := by rwa nat.lt_succ_iff\n\nlemma digit_add_mul_10_eq_digit_add_mul_10_iff {d₁ d₂ a b : ℕ}\n  (h₁ : is_digit d₁) (h₂ : is_digit d₂) :\n  d₁ + a * 10 = d₂ + b * 10 ↔ d₁ = d₂ ∧ a = b :=\nby { rw add_mul_eq_add_mul_iff; apply digit_lt_10; assumption }\n\nlemma trim_end_cons {l : list ℕ} {n : ℕ} :\n  trim_end (n :: l) = if all_zeros l then trim_end [n] else n :: trim_end l :=\nbegin\n  split_ifs,\n  { induction l using list.reverse_rec_on with l m ih,\n    { refl },\n    { rw [all_zeros, all_snoc, ←all_zeros] at h, rcases h with ⟨h, rfl⟩,\n      specialize ih h, rwa [←list.cons_append, trim_end_snoc_zero] }},\n  { induction l using list.reverse_rec_on with l m ih,\n    { cases h all_nil },\n    { rw ←list.cons_append,\n      rw [all_zeros, all_snoc, ←all_zeros, not_and_distrib] at h, cases m,\n      { simp_rw trim_end_snoc_zero, cases h,\n        { exact ih h },\n        { cases h rfl }},\n      { simp_rw [trim_end_snoc_succ, list.cons_append], use rfl }}},\nend\n\nlemma trim_end_all_zeros {l : list ℕ} (h : all_zeros l) : trim_end l = [] :=\nby rwa trim_end_eq_nil_iff\n\nlemma trim_end_singleton {n : ℕ} : trim_end [n] = if n = 0 then [] else [n] :=\nbegin\n  split_ifs,\n  { subst n, refl },\n  { change [n] with [] ++ [n], cases n,\n    { cases h rfl },\n    { rw trim_end_snoc_succ }},\nend\n\nlemma trim_end_same_cons_eq_iff_aux {l₁ l₂ : list ℕ} {n : ℕ}\n  (h₁ : all_zeros l₁) (h₂ : ¬all_zeros l₂) :\n  trim_end [n] = n :: trim_end l₂ ↔ trim_end l₁ = trim_end l₂ :=\nbegin\n  rw trim_end_all_zeros h₁, split; intro h,\n  { rw trim_end_singleton at h, split_ifs at h with h₃,\n    { cases h },\n    { exact h.2 }},\n  { symmetry' at h, rw trim_end_eq_nil_iff at h, contradiction }\nend\n\nlemma trim_end_same_cons_eq_iff {l₁ l₂ : list ℕ} {n : ℕ} :\n  trim_end (n :: l₁) = trim_end (n :: l₂) ↔ trim_end l₁ = trim_end l₂ :=\nbegin\n  nth_rewrite 0 trim_end_cons, nth_rewrite 1 trim_end_cons, split_ifs with h₁ h₂ h₂,\n  { simp [trim_end_all_zeros h₁, trim_end_all_zeros h₂] },\n  { exact trim_end_same_cons_eq_iff_aux h₁ h₂ },\n  { have := @trim_end_same_cons_eq_iff_aux _ _ n h₂ h₁, tauto },\n  { simp }\nend\n\nlemma trim_end_eq_trim_end_of_foldr_eq_foldr {l₁ l₂ : list ℕ}\n  (h₁ : is_digit_list l₁) (h₂ : is_digit_list l₂)\n  (h₃ : l₁.foldr (λ (a b : ℕ), a + b * 10) 0 = l₂.foldr (λ (a b : ℕ), a + b * 10) 0) :\n  trim_end l₁ = trim_end l₂ :=\nbegin\n  induction l₁ with n l₁ ih generalizing l₂,\n  { rw trim_end_nil, symmetry' at h₃ ⊢, change _ = 0 at h₃,\n    rw foldr_eq_zero_iff at h₃, rwa trim_end_eq_nil_iff },\n  { rw [is_digit_list, all_cons, ←is_digit_list] at h₁,\n    cases h₁ with h₁ h₄, specialize @ih h₄, cases l₂ with m l₂,\n    { change _ = 0 at h₃,\n      rw [list.foldr_cons, add_eq_zero_iff, mul_eq_zero, foldr_eq_zero_iff] at h₃,\n      rcases h₃ with ⟨rfl, h₃⟩, rw [trim_end_nil, trim_end_eq_nil_iff, all_zeros, all_cons],\n      use rfl, cases h₃,\n      { exact h₃ },\n      { cases h₃ }},\n    { rw [is_digit_list, all_cons, ←is_digit_list] at h₂, cases h₂ with h₂ h₅,\n      simp_rw [list.foldr_cons, digit_add_mul_10_eq_digit_add_mul_10_iff h₁ h₂] at h₃,\n      rcases h₃ with ⟨rfl, h₃⟩, rw trim_end_same_cons_eq_iff, exact ih h₅ h₃ }},\nend\n\nlemma exi_eq_append_zeros_of_foldr_eq_foldr {l₁ l₂ : list ℕ}\n  (h₁ : is_digit_list l₁) (h₂ : is_digit_list l₂)\n  (h₃ : l₁.foldr (λ (a b : ℕ), a + b * 10) 0 = l₂.foldr (λ (a b : ℕ), a + b * 10) 0) :\n  ∃ (l : list ℕ) (n₁ n₂ : ℕ), l₁ = l ++ list.repeat 0 n₁ ∧ l₂ = l ++ list.repeat 0 n₂ :=\nbegin\n  use [trim_end l₁, l₁.length - (trim_end l₁).length, l₂.length - (trim_end l₁).length,\n    trim_end_append_repeat_zero.symm], symmetry,\n  rw [(_ : trim_end l₁ = trim_end l₂), trim_end_append_repeat_zero],\n  exact trim_end_eq_trim_end_of_foldr_eq_foldr h₁ h₂ h₃,\nend\n\nlemma sum_append_repeat_zero {l : list ℕ} {n : ℕ} :\n  (l ++ list.repeat 0 n).sum = l.sum :=\nby { rw [list.sum_append, list.sum_repeat], refl }\n\nlemma sum_eq_sum_of_foldr_eq_foldr {l₁ l₂ : list ℕ}\n  (h₁ : is_digit_list l₁) (h₂ : is_digit_list l₂)\n  (h₃ : l₁.foldr (λ (a b : ℕ), a + b * 10) 0 = l₂.foldr (λ (a b : ℕ), a + b * 10) 0) :\n  l₁.sum = l₂.sum :=\nbegin\n  obtain ⟨l, n₁, n₂, rfl, rfl⟩ := exi_eq_append_zeros_of_foldr_eq_foldr h₁ h₂ h₃,\n  simp_rw sum_append_repeat_zero,\nend\n\nlemma sum_eq_sum_of_foldl_eq_foldr {l₁ l₂ : list ℕ}\n  (h₁ : is_digit_list l₁) (h₂ : is_digit_list l₂)\n  (h₃ : l₁.foldl (λ (a b : ℕ), a * 10 + b) 0 = l₂.foldr (λ (a b : ℕ), a + b * 10) 0) :\n  l₁.sum = l₂.sum :=\nbegin\n  rw ←list.sum_reverse l₁,\n  rw ←list.foldr_reverse _ _ l₁ at h₃,\n  rename l₁ l,\n  rw [is_digit_list, ←all_reverse, ←is_digit_list] at h₁,\n  revert h₁ h₃,\n  generalize : l.reverse = l₁,\n  rintro h₁ h₃,\n  clear l,\n  replace h₃ : list.foldr (λ a b, a + b * 10) 0 l₁ = list.foldr (λ a b, a + b * 10) 0 l₂,\n  { convert h₃; ext a b; rw add_comm },\n  exact sum_eq_sum_of_foldr_eq_foldr h₁ h₂ h₃,\nend\n\nlemma exi_foldl_iff_exi_foldr {n : ℕ} :\n  (∃ (l : list ℕ), is_digit_list l ∧ l.foldl (λ (a b : ℕ), a * 10 + b) 0 = n) ↔\n  (∃ (l : list ℕ), is_digit_list l ∧ l.foldr (λ (a b : ℕ), a + b * 10) 0 = n) :=\nbegin\n  split; rintro ⟨l, hl, rfl⟩; use l.reverse;\n  { rw list.foldl_reverse <|> rw list.foldr_reverse,\n    simp_rw add_comm, rw [is_digit_list, all_reverse, ←is_digit_list], use hl },\nend\n\nlemma sum_digits_eq_get_some {n : ℕ} :\n  sum_digits n = (get_some (λ (l : list ℕ), is_digit_list l ∧\n    l.foldr (λ (a b : ℕ), a + b * 10) 0 = n)).sum :=\nbegin\n  apply get_some_eq_get_some_of_exists_iff exi_foldl_iff_exi_foldr,\n  rintro h₁ h₂, have h₃ := h₁.some_spec, have h₄ := h₂.some_spec,\n  have h₅ : list.foldl (λ (a b : ℕ), a * 10 + b) 0 h₁.some =\n    list.foldr (λ (a b : ℕ), a + b * 10) 0 h₂.some := by rw [h₃.2, h₄.2],\n  exact sum_eq_sum_of_foldl_eq_foldr h₃.1 h₄.1 h₅,\nend\n\nlemma sum_digits_zero : sum_digits 0 = 0 :=\nbegin\n  rw [sum_digits_eq_get_some, get_some_pos], swap,\n  { exact ⟨[], all_nil, rfl⟩ },\n  generalize_proofs h, exact sum_eq_zero_of_foldr_eq_zero h.some_spec.2,\nend\n\nlemma iter_sum_digits_zero {n : ℕ} : (sum_digits^[n]) 0 = 0 :=\nbegin\n  induction' n,\n  { refl },\n  { rw [function.iterate_succ_apply', ih, sum_digits_zero] },\nend\n\nlemma digital_root_zero : digital_root 0 = 0 :=\nbegin\n  rw [digital_root, fixed, get_some_pos], swap,\n  { exact ⟨0, 0, rfl, sum_digits_zero⟩ },\n  generalize_proofs h₁, obtain ⟨n, h₂, h₃⟩ := h₁.some_spec,\n  rw iter_sum_digits_zero at h₂, exact h₂.symm,\nend\n\ndef modp (n k : ℕ) : ℕ := if n % k = 0 then k else n % k\n\nlemma modp_digit_of_pos {d : ℕ} (h₁ : is_digit d) (h₂ : 0 < d) : modp d 9 = d :=\nbegin\n  rw modp, split_ifs,\n  { rw [is_digit, le_iff_lt_or_eq] at h₁, cases h₁,\n    { rw nat.mod_eq_of_lt h₁ at h, rw h at h₂, cases h₂ },\n    { exact h₁.symm }},\n  { rw [is_digit, le_iff_lt_or_eq] at h₁, cases h₁,\n    { exact nat.mod_eq_of_lt h₁ },\n    { subst d, contradiction }},\nend\n\nlemma sum_digits_digit {d : ℕ} (h : is_digit d) : sum_digits d = d :=\nbegin\n  rw [sum_digits_eq_get_some, get_some_pos], swap,\n  { exact ⟨[d], all_singleton.mpr h, rfl⟩ },\n  generalize_proofs h₁, obtain ⟨h₂, h₃⟩ := h₁.some_spec,\n  exact sum_eq_of_foldr_eq_digit h₂ h h₃,\nend\n\nlemma iterate_eq_self {α : Type} {f : α → α} {x : α} {n : ℕ}\n  (h : f x = x) : (f^[n] x) = x :=\nbegin\n  induction n with n ih,\n  { refl },\n  { rw [function.iterate_succ_apply', ih, h] },\nend\n\nlemma fixed_eq_self_of {α : Type} [inhabited α] {f : α → α} {x : α}\n  (h : f x = x) : fixed f x = x :=\nbegin\n  rw [fixed, get_some_pos], swap,\n  { exact ⟨x, 0, rfl, h⟩ },\n  generalize_proofs h₁, obtain ⟨n, h₂, h₃⟩ := h₁.some_spec,\n  rw [←h₂, iterate_eq_self h],\nend\n\nlemma digital_root_digit_eq_self {d : ℕ} (h : is_digit d) :\n  digital_root d = d := fixed_eq_self_of (sum_digits_digit h)\n\nlemma is_digit_modp_9 {n : ℕ} : is_digit (modp n 9) :=\nbegin\n  rw [is_digit, modp], split_ifs,\n  { refl },\n  { apply le_of_lt, apply nat.mod_lt, dec_trivial },\nend\n\nlemma is_digit_digit_add_digit_sub {d₁ d₂ n : ℕ} (h₁ : is_digit d₁) (h₂ : is_digit d₂)\n  (h₃ : 9 ≤ n) : is_digit (d₁ + d₂ - n) :=\nbegin\n  rw is_digit at h₁ h₂ ⊢,\n  have h₄ := (add_le_add h₁ h₂).trans (add_le_add (le_refl _) h₃),\n  rwa tsub_le_iff_right,\nend\n\nlemma exi_digit_add_10_of_not_is_digit_add {d₁ d₂ : ℕ}\n  (h₁ : is_digit d₁) (h₂ : is_digit d₂) (h₃ : ¬is_digit (d₁ + d₂)) :\n  ∃ (d : ℕ), is_digit d ∧ d₁ + d₂ = d + 10 :=\nbegin\n  refine ⟨d₁ + d₂ - 10, _, _⟩,\n  { apply is_digit_digit_add_digit_sub h₁ h₂, dec_trivial },\n  { rw [is_digit, not_le] at h₃, obtain ⟨k, h₄⟩ := nat.exists_eq_add_of_lt h₃,\n    rw h₄, refine (nat.sub_eq_iff_eq_add _).mp rfl, rw add_right_comm, exact le_self_add },\nend\n\nlemma exi_digit_add_9_of_not_is_digit_add {d₁ d₂ : ℕ}\n  (h₁ : is_digit d₁) (h₂ : is_digit d₂) (h₃ : ¬is_digit (d₁ + d₂)) :\n  ∃ (d : ℕ), is_digit d ∧ d₁ + d₂ = d + 9 :=\nbegin\n  refine ⟨d₁ + d₂ - 9, _, _⟩,\n  { apply is_digit_digit_add_digit_sub h₁ h₂, dec_trivial },\n  { rw [is_digit, not_le] at h₃, obtain ⟨k, h₄⟩ := nat.exists_eq_add_of_lt h₃,\n    rw h₄, refine (nat.sub_eq_iff_eq_add _).mp rfl, apply nat.le_succ_of_le,\n    exact le_self_add },\nend\n\nlemma is_digit_of_is_digit_succ {d : ℕ} (h : is_digit d.succ) : is_digit d :=\n(@is_digit_of_is_digit_add d 1 h).1\n\nlemma sum_eq_of_foldr_eq_digit_add_10 {l : list ℕ} {d : ℕ}\n  (h₁ : is_digit_list l) (h₂ : is_digit d)\n  (h₃ : l.foldr (λ (a b : ℕ), a + b * 10) 0 = d + 10) : l.sum = d.succ :=\nbegin\n  cases l with d₁ l,\n  { cases h₃ },\n  { rw list.foldr_cons at h₃, rw [is_digit_list, all_cons, ←is_digit_list] at h₁,\n    cases h₁ with h₁ h₄, nth_rewrite 1 ←one_mul 10 at h₃,\n    rw digit_add_mul_10_eq_digit_add_mul_10_iff h₁ h₂ at h₃, rcases h₃ with ⟨rfl, h₃⟩,\n    rw [list.sum_cons, sum_eq_of_foldr_eq_digit h₄ dec_trivial h₃] },\nend\n\nlemma sum_digits_pos_digit_add_9 {d : ℕ} (h₁ : is_digit d) (h₂ : 0 < d) :\n  sum_digits (d + 9) = d :=\nbegin\n  cases d,\n  { cases h₂ },\n  { rw [sum_digits_eq_get_some, get_some_pos], swap,\n    { refine ⟨[d, 1], _, _⟩,\n      { simp_rw [is_digit_list, all_cons, all_nil],\n        exact ⟨is_digit_of_is_digit_succ h₁, dec_trivial, trivial⟩ },\n      { refl }},\n    generalize_proofs h₃, obtain ⟨h₄, h₅⟩ := h₃.some_spec, change _ = d + 10 at h₅,\n    exact sum_eq_of_foldr_eq_digit_add_10 h₄ (is_digit_of_is_digit_succ h₁) h₅ },\nend\n\nlemma pos_left_of_not_is_digit_digit_add_digit {d₁ d₂ : ℕ}\n  (h₁ : is_digit d₁) (h₂ : is_digit d₂) (h₃ : ¬is_digit (d₁ + d₂)) : 0 < d₁ :=\nby { rw is_digit at h₁ h₂ h₃, linarith }\n\nlemma pos_right_of_not_is_digit_digit_add_digit {d₁ d₂ : ℕ}\n  (h₁ : is_digit d₁) (h₂ : is_digit d₂) (h₃ : ¬is_digit (d₁ + d₂)) : 0 < d₂ :=\nby { rw add_comm at h₃, exact pos_left_of_not_is_digit_digit_add_digit h₂ h₁ h₃ }\n\nlemma sum_digits_digit_add_digit {d₁ d₂ : ℕ} (h₁ : is_digit d₁) (h₂ : is_digit d₂) :\n  sum_digits (d₁ + d₂) = if d₁ + d₂ ≤ 9 then d₁ + d₂ else d₁ + d₂ - 9 :=\nbegin\n  split_ifs,\n  { exact sum_digits_digit h },\n  { obtain ⟨d, h₃, h₄⟩ := exi_digit_add_9_of_not_is_digit_add h₁ h₂ h, have h₅ : 0 < d,\n    { rw h₄ at h, push_neg at h, rwa lt_add_iff_pos_left at h },\n    rw [h₄, sum_digits_pos_digit_add_9 h₃ h₅], refl },\nend\n\nlemma modp_of_le_of_pos {k d : ℕ} (h₁ : 0 < d) (h₂ : d ≤ k) : modp d k = d :=\nbegin\n  rw modp, cases k,\n  { rw le_zero_iff at h₂, subst d, refl },\n  { split_ifs with h₃,\n    { rw le_iff_lt_or_eq at h₂, cases h₂,\n      { rw nat.mod_eq_of_lt h₂ at h₃, subst d, cases h₁ },\n      { subst d }},\n    { rw le_iff_lt_or_eq at h₂, cases h₂,\n      { exact nat.mod_eq_of_lt h₂ },\n      { subst d, cases h₃ (nat.mod_self _) }}},\nend\n\nlemma add_self_mod_eq_zero {a : ℕ} : (a + a) % a = 0 := by simp\n\nlemma modp_add {k a b : ℕ} : modp (a + b) k = modp (modp a k + modp b k) k :=\nby { simp_rw modp, split_ifs; simp [*, nat.add_mod] at * }\n\nlemma modp_pos_of_pos {k d : ℕ} (h : 0 < d) : 0 < modp d k :=\nbegin\n  rw modp, split_ifs with h₁,\n  { by_contra' h₂, rw le_zero_iff at h₂, subst k,\n    rw nat.mod_zero at h₁, subst d, cases h },\n  { rwa pos_iff_ne_zero },\nend\n\nlemma digital_root_eq_self_of {n : ℕ} (h : sum_digits n = n) :\n  digital_root n = n := fixed_eq_self_of h\n\nlemma modp_zero {d : ℕ} : modp d 0 = d :=\nbegin\n  rw [modp, nat.mod_zero], split_ifs,\n  { exact h.symm },\n  { refl },\nend\n\nlemma modp_of_lt {k d : ℕ} (h₁ : 0 < d) (h₂ : d < k) : modp d k = d :=\nbegin\n  rw modp, split_ifs,\n  { rw nat.mod_eq_of_lt h₂ at h, subst d, cases h₁ },\n  { rw nat.mod_eq_of_lt h₂ },\nend\n\nlemma modp_self {k : ℕ} : modp k k = k :=\nby { rw [modp, nat.mod_self], refl }\n\nlemma modp_of_le {k d : ℕ} (h₁ : 0 < d) (h₂ : d ≤ k) : modp d k = d :=\nbegin\n  rw le_iff_lt_or_eq at h₂, cases h₂,\n  { exact modp_of_lt h₁ h₂ },\n  { subst d, rw modp_self },\nend\n\nlemma modp_add_self {k d : ℕ} : modp (d + k) k = modp d k :=\nbegin\n  simp_rw modp, split_ifs with h₁ h₂ h₂;\n  try { rw nat.add_mod_right at h₁, contradiction },\n  { refl },\n  { rw nat.add_mod_right },\nend\n\nlemma modp_of_gt_of_lt_mul_2 {k d : ℕ} (h₁ : k < d) (h₂ : d < k * 2) : modp d k = d - k :=\nbegin\n  obtain ⟨n, rfl⟩ := nat.exists_eq_add_of_lt h₁, clear h₁,\n  replace h₂ : n + 1 < k := by linarith,\n  rw [add_rotate k n 1, nat.add_sub_cancel, modp_add_self],\n  exact modp_of_lt (nat.succ_pos _) h₂,\nend\n\nlemma modp_add_lt {k d₁ d₂ : ℕ} (h₁ : 0 < d₁ ∨ 0 < d₂) (h₂ : d₁ < k) (h₃ : d₂ < k) :\n  modp (d₁ + d₂) k = if d₁ + d₂ ≤ k then d₁ + d₂ else d₁ + d₂ - k :=\nbegin\n  split_ifs with h₄,\n  { exact modp_of_le ((nat.add_pos_iff_pos_or_pos d₁ d₂).mpr h₁) h₄ },\n  { push_neg at h₄, apply modp_of_gt_of_lt_mul_2 h₄, rw mul_two, exact add_lt_add h₂ h₃ },\nend\n\nlemma modp_add_le_aux {k d : ℕ} (h : d < k) :\n  modp (d + k) k = if d + k ≤ k then d + k else d + k - k :=\nbegin\n  cases d,\n  { simp_rw [zero_add, modp_self, if_pos (le_refl _)] },\n  { rw [modp_add_self, if_neg, modp_of_lt (nat.succ_pos _) h, nat.add_sub_cancel],\n    push_neg, rw [nat.succ_add, nat.lt_succ_iff], exact le_add_self }\nend\n\nlemma modp_add_le {k d₁ d₂ : ℕ} (h₁ : 0 < d₁ ∨ 0 < d₂) (h₂ : d₁ ≤ k) (h₃ : d₂ ≤ k) :\n  modp (d₁ + d₂) k = if d₁ + d₂ ≤ k then d₁ + d₂ else d₁ + d₂ - k :=\nbegin\n  rw le_iff_lt_or_eq at h₂, cases h₂,\n  { rw le_iff_lt_or_eq at h₃, cases h₃,\n    { exact modp_add_lt h₁ h₂ h₃ },\n    { subst d₂, exact modp_add_le_aux h₂ }},\n  { subst d₁, rw add_comm k d₂, rw le_iff_lt_or_eq at h₃, cases h₃,\n    { exact modp_add_le_aux h₃ },\n    { subst d₂, rw [modp_add_self, modp_self, if_neg, nat.add_sub_cancel],\n      push_neg, rw or_self at h₁, exact lt_add_of_pos_left k h₁ }},\nend\n\nlemma modp_digit_add_digit {d₁ d₂ : ℕ} (h₁ : is_digit d₁) (h₂ : is_digit d₂)\n  (h₃ : 0 < d₁ ∨ 0 < d₂) :\n  modp (d₁ + d₂) 9 = if d₁ + d₂ ≤ 9 then d₁ + d₂ else d₁ + d₂ - 9 :=\nmodp_add_le h₃ h₁ h₂\n\nlemma modp_le {k d : ℕ} (h : 0 < k) : modp d k ≤ k :=\nbegin\n  rw modp, split_ifs with h₁,\n  { refl },\n  { exact le_of_lt (nat.mod_lt _ h) },\nend\n\nlemma modp_self_mul {k n : ℕ} : modp (k * n) k = k :=\nby { rw modp, split_ifs; simp * at * }\n\nlemma zero_modp {k : ℕ} : modp 0 k = k :=\nby { rw modp, split_ifs; simp * at * }\n\nlemma modp_modp {k d : ℕ} : modp (modp d k) k = modp d k :=\nbegin\n  cases k,\n  { simp_rw modp_zero },\n  { cases d,\n    { simp_rw [zero_modp, modp_self] },\n    { exact modp_of_le (modp_pos_of_pos (nat.succ_pos _)) (modp_le (nat.succ_pos _)) }},\nend\n\nlemma modp_add_self_mul {k d n : ℕ} : modp (d + k * n) k = modp d k :=\nby { rw [modp_add, modp_self_mul, modp_add_self, modp_modp] }\n\nlemma modp_digit_add_mul_10 {d n : ℕ} (h : is_digit d) :\n  modp (d + n * 10) 9 = modp (d + n) 9 :=\nbegin\n  change 10 with 9 + 1, rw [mul_add, mul_one], cases d,\n  { simp_rw zero_add, rw [add_comm, mul_comm, modp_add_self_mul] },\n  { rw [modp_add, modp_digit_of_pos h (nat.succ_pos _),\n    add_comm (n * 9), mul_comm, modp_add_self_mul, eq_comm,\n    modp_add, modp_digit_of_pos h (nat.succ_pos _)] },\nend\n\nlemma lt_mul_of_lt {a b c : ℕ} (h₁ : a < b) (h₂ : 0 < c) : a < b * c :=\nbegin\n  cases c,\n  { cases h₂ },\n  { rw nat.mul_succ, apply nat.lt_add_left, assumption },\nend\n\nlemma le_mul_of_le {a b c : ℕ} (h₁ : a ≤ b) (h₂ : 0 < c) : a ≤ b * c :=\nbegin\n  cases c,\n  { cases h₂ },\n  { rw nat.mul_succ, exact le_add_left h₁},\nend\n\nlemma lt_add_left_iff_lt {a b c : ℕ} : c + a < c + b ↔ a < b :=\nby apply rel_iff_cov\n\nlemma le_add_left_iff_le {a b c : ℕ} : c + a ≤ c + b ↔ a ≤ b :=\nby apply rel_iff_cov\n\nlemma sum_le_foldr {l : list ℕ} : l.sum ≤ l.foldr (λ (a b : ℕ), a + b * 10) 0 :=\nbegin\n  induction l with d l ih,\n  { apply zero_le },\n  { rw [list.sum_cons, list.foldr_cons, le_add_left_iff_le],\n    exact le_mul_of_le ih dec_trivial },\nend\n\nlemma add_left_le_self_iff {a b : ℕ} : a + b ≤ b ↔ a = 0 :=\nbegin\n  split; intro h,\n  { cases a,\n    { refl },\n    { rw [nat.succ_add, nat.succ_le_iff] at h,\n      cases lt_irrefl _ (right_lt_of_add_lt h) }},\n  { subst a, rw zero_add },\nend\n\nlemma sum_eq_zero_iff {l : list ℕ} : l.sum = 0 ↔ all_zeros l :=\nby { rw [list.sum_eq_zero_iff, all_zeros, all_iff] }\n\nlemma sum_eq_foldr_mul_iff_of_gt_1 {l : list ℕ} {n : ℕ}\n  (h₁ : is_digit_list l) (h₂ : 1 < n) :\n  l.sum = l.foldr (λ (a b : ℕ), a + b * 10) 0 * n ↔ all_zeros l :=\nbegin\n  split; intro h,\n  { have h₃ := @sum_le_foldr l, rw h at h₃,\n    obtain ⟨n, rfl⟩ := nat.exists_eq_add_of_lt h₂, clear h₂,\n    have h₂ : 1 + n + 1 = n + 2 := by linarith, rw h₂ at *,\n    rw [mul_add, mul_two, ←add_assoc, add_left_le_self_iff, add_eq_zero_iff] at h₃,\n    rwa [h₃.2, zero_mul, sum_eq_zero_iff] at h },\n  { rwa [foldr_eq_zero_iff.mpr h, zero_mul, sum_eq_zero_iff] },\nend\n\nlemma is_digit_sum_of_sum_eq_foldr {l : list ℕ} (h₁ : is_digit_list l)\n  (h₂ : l.sum = l.foldr (λ (a b : ℕ), a + b * 10) 0) : is_digit l.sum :=\nbegin\n  cases l with d l,\n  { dec_trivial },\n  { rw [is_digit_list, all_cons, ←is_digit_list] at h₁, cases h₁ with h₁ h₃,\n    rw [list.sum_cons, list.foldr_cons, add_right_inj,\n    sum_eq_foldr_mul_iff_of_gt_1 h₃ (dec_trivial : 1 < 10)] at h₂,\n    rwa [list.sum_cons, sum_eq_zero_iff.mpr h₂] },\nend\n\nlemma sum_digits_eq_self_iff_is_digit {n : ℕ} : sum_digits n = n ↔ is_digit n :=\nbegin\n  split; intro h,\n  { by_cases h₁ : n = 0,\n    { subst n, dec_trivial },\n    { rw [sum_digits_eq_get_some, get_some] at h, split_ifs at h with h₁,\n      { obtain ⟨h₂, h₃⟩ := h₁.some_spec, revert h h₂ h₃, generalize : h₁.some = l,\n        rintro h₁ h₂ h₃, subst n, exact is_digit_sum_of_sum_eq_foldr h₂ h₃.symm },\n      { subst n, dec_trivial }}},\n  { exact sum_digits_digit h },\nend\n\nlemma is_digit_digital_root {n : ℕ} : is_digit (digital_root n) :=\nbegin\n  rw [is_digit, digital_root, fixed, get_some], split_ifs,\n  { obtain ⟨k, h₁, h₂⟩ := h.some_spec,\n    rwa [function.iterate_succ_apply', h₁, sum_digits_eq_self_iff_is_digit] at h₂ },\n  { dec_trivial },\nend\n\nlemma exi_sum_digits {n : ℕ} : ∃ (l : list ℕ), is_digit_list l ∧\n  l.foldr (λ (a b : ℕ), a + b * 10) 0 = n :=\nbegin\n  induction n using digit_ind with d n h ih,\n  { use ([]), split,\n    { rw is_digit_list, exact all_nil },\n    { refl }},\n  { rcases ih with ⟨l, h₁, h₂⟩, use d :: l, split,\n    { rw [is_digit_list, all_cons, ←is_digit_list], split; assumption },\n    { rw [list.foldr_cons, add_right_inj, h₂] }},\nend\n\nlemma sum_digits_digit_add_mul_10 {d n : ℕ} (h : is_digit d) :\n  sum_digits (d + n * 10) = d + sum_digits n :=\nbegin\n  rw [sum_digits_eq_get_some, get_some_pos exi_sum_digits], generalize_proofs h₁,\n  obtain ⟨h₁, h₂⟩ := h₁.some_spec, revert h₁ h₂, generalize : exi_sum_digits.some = l₂,\n  clear h₁, rintro h₁ h₂, rw [sum_digits_eq_get_some, get_some_pos exi_sum_digits],\n  generalize_proofs h₁, obtain ⟨h₁, h₂⟩ := h₁.some_spec, revert h₁ h₂,\n  generalize : exi_sum_digits.some = l₁, clear h₁, rintro h₃ h₄, cases l₂ with d₂ l₂,\n  { change 0 = _ at h₂, symmetry' at h₂, rw [add_eq_zero_iff, mul_eq_zero] at h₂,\n    rcases h₂ with ⟨rfl, h₂⟩, clear h h₁, cases h₂,\n    { subst n, rw foldr_eq_zero_iff at h₂, rw sum_eq_zero_iff.mpr h₂, refl },\n    { cases h₂ }},\n  { rw list.foldr_cons at h₂, rw [is_digit_list, all_cons, ←is_digit_list] at h₁,\n    cases h₁ with h₁ h₅, rw digit_add_mul_10_eq_digit_add_mul_10_iff h₁ h at h₂,\n    rcases h₂ with ⟨rfl, h₂⟩, rw [list.sum_cons, add_right_inj], rw ←h₄ at h₂,\n    exact sum_eq_sum_of_foldr_eq_foldr h₅ h₃ h₂ },\nend\n\nlemma sum_digits_le {n : ℕ} : sum_digits n ≤ n :=\nbegin\n  induction n using digit_ind with d n h ih,\n  { rw sum_digits_zero },\n  { rw sum_digits_digit_add_mul_10 h, apply add_le_add_left,\n    exact le_trans ih (le_mul_of_le (le_refl _) dec_trivial) },\nend\n\nlemma sum_digits_eq_self_of_sum_digits_sum_digits_eq_self {n : ℕ}\n  (h : sum_digits (sum_digits n) = n) : sum_digits n = n :=\nbegin\n  apply le_antisymm,\n  { exact sum_digits_le },\n  { have h₁ := @sum_digits_le (sum_digits n), rwa h at h₁ },\nend\n\nlemma iter_le_of_le {f : ℕ → ℕ} {z n : ℕ}\n  (h : ∀ (z : ℕ), f z ≤ z) : (f^[n] z) ≤ z :=\nbegin\n  induction n with n ih,\n  { refl },\n  { rw function.iterate_succ_apply', exact le_trans (h _) ih },\nend\n\nlemma iter_le_iter_of_le {f : ℕ → ℕ} {z m n : ℕ}\n  (h₁ : ∀ (z : ℕ), f z ≤ z) (h₂ : m ≤ n) : (f^[n] z) ≤ (f^[m] z) :=\nbegin\n  obtain ⟨n, rfl⟩ := nat.exists_eq_add_of_le h₂,\n  rw [add_comm, function.iterate_add_apply], exact iter_le_of_le h₁,\nend\n\nlemma iter_sum_digits_le_iter_sum_digits_of_le {n k₁ k₂ : ℕ} (h : k₁ ≤ k₂) :\n  (sum_digits^[k₂] n) ≤ (sum_digits^[k₁] n) := iter_le_iter_of_le (λ _, sum_digits_le) h\n\nlemma sum_digits_digital_root {n : ℕ} : sum_digits (digital_root n) = digital_root n :=\nby { rw sum_digits_eq_self_iff_is_digit, exact is_digit_digital_root }\n\nlemma digital_root_digit {d : ℕ} (h : is_digit d) : digital_root d = d :=\ndigital_root_eq_self_of (sum_digits_digit h)\n\nlemma digital_root_one : digital_root 1 = 1 := digital_root_digit dec_trivial\n\nlemma is_digit_sum_digits_digit_add_digit {d₁ d₂ : ℕ}\n  (h₁ : is_digit d₁) (h₂ : is_digit d₂) : is_digit (sum_digits (d₁ + d₂)) :=\nbegin\n  rw sum_digits_digit_add_digit h₁ h₂, split_ifs,\n  { exact h },\n  { rw is_digit at *, exact nat.sub_le_sub_right (add_le_add h₁ h₂) 9 },\nend\n\nlemma iter_sum_digits_digit {d n : ℕ} (h : is_digit d) : (sum_digits^[n]) d = d :=\nfunction.iterate_fixed (sum_digits_digit h) _\n\nlemma digital_root_digit_add_digit {d₁ d₂ : ℕ} (h₁ : is_digit d₁) (h₂ : is_digit d₂) :\n  digital_root (d₁ + d₂) = sum_digits (d₁ + d₂) :=\nbegin\n  rw [digital_root, fixed, get_some_pos], swap,\n  { use [sum_digits (d₁ + d₂), 1], split,\n    { refl },\n    { exact sum_digits_digit (is_digit_sum_digits_digit_add_digit h₁ h₂) }},\n  generalize_proofs h₃, obtain ⟨n, -, h₄⟩ := h₃.some_spec,\n  symmetry, rwa [function.iterate_succ_apply,\n  iter_sum_digits_digit (is_digit_sum_digits_digit_add_digit h₁ h₂)] at h₄,\nend\n\nlemma sum_digits_def {n : ℕ} : sum_digits n = n % 10 + sum_digits (n / 10) :=\nbegin\n  obtain ⟨a, b, ha, hb, h⟩ := nat_exi_mul n 10,\n  rw [←ha, ←hb, h, add_comm, hb],\n  exact sum_digits_digit_add_mul_10 is_digit_mod_10,\nend\n\ndef converges_to {α : Type} (f : α → α) (z x : α) : Prop :=\n∃ (n : ℕ), (f^[n]) z = x ∧ (f^[n + 1]) z = x\n\ndef converges {α : Type} (f : α → α) (z : α) : Prop :=\n∃ (x : α), converges_to f z x\n\nlemma iter_add {α : Type} {f : α → α} {z : α} {m n : ℕ} :\n  (f^[m + n]) z = (f^[n]) ((f^[m]) z) := by rw [add_comm, function.iterate_add_apply]\n\nlemma converges_to_congr_aux {α : Type} {n₂ n₁ : ℕ} {f : α → α} {z x y : α}\n  (h₁ : f^[n₁] z = x) (h₂ : f^[n₁ + 1] z = x) (h₃ : f^[n₂] z = y) (h₄ : f^[n₂ + 1] z = y)\n  (h₅ : n₁ ≤ n₂) : x = y :=\nbegin\n  obtain ⟨n₂, rfl⟩ := nat.exists_eq_add_of_le h₅, clear h₅, rw add_assoc at h₄,\n  simp_rw iter_add at h₂ h₃ h₄, change (f^[1]) with f at h₂ h₄, rw ←h₁ at h₂,\n  have h₅ := function.iterate_fixed h₂ n₂, rw [h₃, h₁] at h₅, exact h₅.symm,\nend\n\nlemma converges_to_congr {α : Type} {f : α → α} {z x y : α}\n  (h₁ : converges_to f z x) (h₂ : converges_to f z y) : x = y :=\nbegin\n  rcases h₂ with ⟨n₂, h₃, h₄⟩, rcases h₁ with ⟨n₁, h₁, h₂⟩, by_cases h₅ : n₁ ≤ n₂,\n  { exact converges_to_congr_aux h₁ h₂ h₃ h₄ h₅ },\n  { push_neg at h₅, exact (converges_to_congr_aux h₃ h₄ h₁ h₂ (le_of_lt h₅)).symm },\nend\n\nlemma fixed_eq_of_converges_to {α : Type} [inhabited α] {f : α → α} {z x : α}\n  (h : converges_to f z x) : fixed f z = x :=\nbegin\n  rw [fixed, get_some_pos], swap, { exact ⟨x, h⟩ },\n  generalize_proofs h₃, exact converges_to_congr h₃.some_spec h,\nend\n\nlemma apply_eq_of_converges_to {α : Type} {f : α → α} {z x : α}\n  (h : converges_to f z x) : f x = x :=\nby { rcases h with ⟨n, h₁, h₂⟩, rwa [function.iterate_succ_apply', h₁] at h₂ }\n\nlemma apply_fixed_of_converges {α : Type} [inhabited α] {f : α → α} {z : α}\n  (h : converges f z) : f (fixed f z) = fixed f z :=\nby { cases h with x h, by rw [fixed_eq_of_converges_to h, apply_eq_of_converges_to h] }\n\nlemma iter_apply_comm {α : Type} {f : α → α} {x : α} {n : ℕ} :\n  (f^[n]) (f x) = f ((f^[n]) x) :=\nby rw [←function.iterate_succ_apply, function.iterate_succ_apply']\n\nlemma converges_of_le {f : ℕ → ℕ} {n : ℕ} (h : ∀ (n : ℕ), f n ≤ n) : converges f n :=\nbegin\n  change ∃ (_ _ : ℕ), _, induction n using nat.strong_induction_on with n ih, dsimp at ih,\n  simp_rw function.iterate_succ_apply', have h₁ := h ((f^[n]) n),\n  rw le_iff_lt_or_eq at h₁, cases h₁,\n  { replace h₁ : _ < n := gt_of_ge_of_gt (iter_le_of_le h) h₁,\n    specialize ih _ h₁, rcases ih with ⟨y, k, h₂, h₃⟩,\n    use [y, n + 1 + k], split; simp_rw iter_add,\n    { exact h₂ },\n    { rwa ←@iter_apply_comm _ f }},\n  { exact ⟨_, _, rfl, h₁⟩ },\nend\n\nlemma converges_sum_digits {n : ℕ} : converges sum_digits n :=\nconverges_of_le (λ _, sum_digits_le)\n\nlemma converges_to_fixed {α : Type} [inhabited α] {f : α → α} {z : α}\n  (h : converges f z) : converges_to f z (fixed f z) :=\nby { cases h with x h, rwa fixed_eq_of_converges_to h }\n\nlemma converges_to_apply {α : Type} {f : α → α} {z x : α}\n  (h : converges_to f z x) : converges_to f z (f x) :=\nbegin\n  rcases h with ⟨n, h₁, h₂⟩, use n + 1, split; rw iter_add,\n  { rw h₁, refl },\n  { rw h₂, refl },\nend\n\nlemma apply_converges_to {α : Type} {f : α → α} {z x : α}\n  (h : converges_to f z x) : converges_to f (f z) x :=\nbegin\n  rcases h with ⟨k, h₁, h₂⟩, cases k,\n  { use 0, split,\n    { exact h₂ },\n    { cases h₁, rwa [iter_apply_comm, h₂] }},\n  { exact ⟨k, h₁, h₂⟩ },\nend\n\nlemma apply_converges {α : Type} {f : α → α} {z : α}\n  (h : converges f z) : converges f (f z) := ⟨_, apply_converges_to h.some_spec⟩\n\nlemma fixed_eq_fixed_of {α : Type} [inhabited α] {f : α → α} {z₁ z₂ x : α}\n  (h₁ : converges_to f z₁ x) (h₂ : converges_to f z₂ x) : fixed f z₁ = fixed f z₂ :=\nby rw [fixed_eq_of_converges_to h₁, fixed_eq_of_converges_to h₂]\n\nlemma fixed_apply_eq_of_converges {α : Type} [inhabited α] {f : α → α} {z : α}\n  (h : converges f z) : fixed f (f z) = fixed f z :=\nby { cases h with x h, exact fixed_eq_fixed_of (apply_converges_to h) h }\n\nlemma digital_root_sum_digits {n : ℕ} : digital_root (sum_digits n) = digital_root n :=\nfixed_apply_eq_of_converges converges_sum_digits\n\nlemma fixed_ind {α : Type} [inhabited α] {P : α → Prop} {f : α → α} {z : α}\n  (h₁ : converges f z) (h₂ : P z) (h₃ : ∀ (x : α), P x → P (f x)) : P (fixed f z) :=\nbegin\n  cases h₁ with x h₁, rw fixed_eq_of_converges_to h₁,\n  rcases h₁ with ⟨n, h₁, -⟩, rw ←h₁, exact function.iterate.rec _ h₃ h₂ _,\nend\n\nlemma sum_digits_mod_9 {n : ℕ} : sum_digits n % 9 = n % 9 :=\nbegin\n  induction n using digit_ind with d n h ih,\n  { rw sum_digits_zero },\n  { rw [sum_digits_digit_add_mul_10 h, nat.add_mod, ih, eq_comm, nat.add_mod,\n    nat.mul_mod], congr' 2, change 10 % 9 with 1, rw [nat.mul_one, nat.mod_mod] },\nend\n\nlemma digital_root_mod_9 {n : ℕ} : digital_root n % 9 = n % 9 :=\nbegin\n  apply @fixed_ind _ _ (λ (k : ℕ), k % 9 = n % 9) _ _ converges_sum_digits rfl,\n  rintro x h, rw [←h, sum_digits_mod_9],\nend\n\nlemma digit_mod_10 {d : ℕ} (h : is_digit d) : d % 10 = d :=\nnat.mod_eq_of_lt (nat.lt_succ_of_le h)\n\nlemma pos_add_iff {a b : ℕ} : 0 < a + b ↔ 0 < a ∨ 0 < b :=\nby { rw ←not_iff_not, push_neg, simp_rw [le_zero_iff, add_eq_zero_iff] }\n\nlemma sum_digits_pos_succ {n : ℕ} : 0 < sum_digits n.succ :=\nbegin\n  induction n using nat.strong_induction_on with n ih, dsimp at ih,\n  rw [sum_digits_def, pos_add_iff], by_cases h : n.succ ≤ 9,\n  { rw digit_mod_10 h, exact or.inl (nat.succ_pos _) },\n  {\n    right, push_neg at h, rw nat.lt_succ_iff at h,\n    obtain ⟨n, rfl⟩ := nat.exists_eq_add_of_le h, clear h,\n    rw [add_comm, ←nat.add_succ, nat.add_div_right _ (nat.succ_pos _)],\n    apply ih, rw add_comm, cases n,\n    { dec_trivial },\n    { apply nat.lt_add_right, apply nat.div_lt_self; dec_trivial }},\nend\n\nlemma sum_digits_eq_zero_iff {n : ℕ} : sum_digits n = 0 ↔ n = 0 :=\nbegin\n  split; intro h,\n  { cases n,\n    { refl },\n    { contrapose h, exact ne_of_gt sum_digits_pos_succ }},\n  { subst h, exact sum_digits_zero },\nend\n\nlemma digital_root_eq_zero_iff {n : ℕ} : digital_root n = 0 ↔ n = 0 :=\nbegin\n  apply @fixed_ind _ _ (λ (k : ℕ), k = 0 ↔ n = 0) _ _ converges_sum_digits (iff.refl _),\n  rintro x h, rw [←h, sum_digits_eq_zero_iff],\nend\n\nlemma digit_mod_9_eq_zero_iff {d : ℕ} (h : is_digit d) : d % 9 = 0 ↔ d = 0 ∨ d = 9 :=\nbegin\n  rw is_digit at h, split; intro h₁,\n  { cases d,\n    { exact or.inl rfl },\n    { rw le_iff_eq_or_lt at h, cases h,\n      { exact or.inr h },\n      { rw nat.mod_eq_of_lt h at h₁, cases h₁ }}},\n  { cases h₁; subst d; refl },\nend\n\nlemma digital_root_eq_of_pos {n : ℕ} (h : 0 < n) : digital_root n = modp n 9 :=\nbegin\n  cases n,\n  { cases h },\n  { rw modp, split_ifs with h₁;\n    rw [←digital_root_mod_9, digit_mod_9_eq_zero_iff is_digit_digital_root] at h₁,\n    { cases h₁,\n      { rw digital_root_eq_zero_iff at h₁, cases h₁ },\n      { exact h₁ }},\n    { rw not_or_distrib at h₁, cases h₁ with h₁ h₂,\n      rw [←digital_root_mod_9, nat.mod_eq_of_lt],\n      exact lt_of_le_of_ne is_digit_digital_root h₂ }},\nend\n\nlemma digital_root_succ {n : ℕ} : digital_root n.succ = modp n.succ 9 :=\ndigital_root_eq_of_pos (nat.succ_pos _)\n\nlemma eq_zero_of_modp_eq_zero {k n : ℕ} (h : modp n k = 0) : n = 0 :=\nbegin\n  rw modp at h, split_ifs at h with h₁,\n  { subst k, rwa nat.mod_zero at h₁ },\n  { contradiction },\nend\n\nlemma succ_mod_eq_zero_iff_aux {k n : ℕ} : n.succ % k.succ = 0 ↔ n % k.succ = k :=\nbegin\n  split; intro h,\n  { contrapose! h,\n    replace h := lt_of_le_of_ne (nat.le_of_lt_succ (nat.mod_lt _ (nat.succ_pos _))) h,\n    cases k,\n    { cases h },\n    { rw [←ne, ←pos_iff_ne_zero, ←nat.add_one, nat.add_mod, nat.one_mod, nat.mod_eq_of_lt],\n      { apply nat.zero_lt_succ }, rwa nat.succ_lt_succ_iff }},\n  { cases k,\n    { rw nat.mod_one },\n    { rw [←nat.add_one, nat.add_mod, h, nat.one_mod, nat.mod_self] }},\nend\n\nlemma succ_mod_eq_zero_iff {k n : ℕ} (h : 0 < k) : n.succ % k = 0 ↔ n % k = k - 1 :=\nbegin\n  cases k,\n  { cases h },\n  { rw [nat.succ_sub_one, succ_mod_eq_zero_iff_aux] },\nend\n\nlemma digital_root_mod_9_eq_of_ne_9 {n : ℕ} (h : digital_root n ≠ 9) :\n  digital_root n % 9 = digital_root n :=\nnat.mod_eq_of_lt (lt_of_le_of_ne is_digit_digital_root h)\n\nlemma digital_root_succ_eq_of_ne_9 {n : ℕ} (h : digital_root n ≠ 9) :\n  digital_root n.succ = (digital_root n).succ :=\nbegin\n  rw [digital_root_eq_of_pos (nat.succ_pos _), modp], split_ifs with h₁,\n  { rw [succ_mod_eq_zero_iff (nat.succ_pos _), ←digital_root_mod_9,\n    digital_root_mod_9_eq_of_ne_9 h] at h₁, rw h₁ },\n  { cases n,\n    { rw digital_root_zero, refl },\n    { rw [digital_root_eq_of_pos (nat.succ_pos _), modp], split_ifs with h₂,\n      { rw [←digital_root_mod_9, digital_root_mod_9_eq_of_ne_9 h,\n        digital_root_eq_zero_iff] at h₂, cases h₂ },\n      { clear h, rw succ_mod_eq_zero_iff (nat.succ_pos _) at h₁ h₂,\n        rw [←nat.add_one, nat.add_mod, nat.one_mod],\n        have h₃ : n.succ % 9 = (n % 9 + 1) % 9,\n        { rw [←nat.add_one, nat.add_mod, nat.one_mod] },\n        rw h₃ at *, clear h₃, have h₃ : n % 9 < 9 := nat.mod_lt _ (nat.succ_pos _),\n        revert h₃ h₁ h₂, generalize : n % 9 = d, rintro h₁ h₂ h₃,\n        clear n, replace h₁ : d ≤ 7,\n        { cases d,\n          { apply zero_le },\n          { rw nat.lt_succ_iff at h₁, rw ←nat.lt_succ_iff, exact lt_of_le_of_ne h₁ h₃ }},\n        rw ←not_lt at h₁, iterate 7 { cases d, refl }, cases d, cases h₂ rfl,\n        contrapose! h₁, change 7 < d + 8, linarith }}},\nend\n\nlemma not_digit_succ_le_9_iff {d : ℕ} (h : is_digit d) : ¬d.succ ≤ 9 ↔ d = 9 :=\nbegin\n  split; intro h₁,\n  { contrapose! h₁, exact nat.succ_le_of_lt (lt_of_le_of_ne h h₁) },\n  { subst d, dec_trivial }\nend\n\nlemma digital_root_succ_eq_sum_digits {n : ℕ} :\n  digital_root n.succ = sum_digits (digital_root n).succ :=\nbegin\n  rw [eq_comm, digital_root_succ, modp,\n  sum_digits_digit_add_digit is_digit_digital_root (dec_trivial : is_digit 1)],\n  simp_rw ←nat.add_one, split_ifs with h₁ h₂ h₂,\n  { rw [←digital_root_mod_9, digit_mod_9_eq_zero_iff is_digit_digital_root] at h₂,\n    cases h₂,\n    { rw digital_root_eq_of_pos (nat.succ_pos _) at h₂, cases eq_zero_of_modp_eq_zero h₂ },\n    { rw nat.succ_le_iff at h₁, rw [nat.succ_inj', ←nat.mod_eq_of_lt h₁, digital_root_mod_9],\n      apply_fun (λ n, n % 9) at h₂, rwa [nat.mod_self, digital_root_mod_9,\n      succ_mod_eq_zero_iff (nat.succ_pos _)] at h₂ }},\n  { rw [←digital_root_mod_9, digit_mod_9_eq_zero_iff is_digit_digital_root,\n    not_or_distrib] at h₂, cases h₂ with h₂ h₃,\n    have h₄ := lt_of_le_of_ne is_digit_digital_root h₃,\n    rw [←digital_root_mod_9, nat.mod_eq_of_lt h₄, digital_root_succ_eq_of_ne_9],\n    exact ne_of_lt (nat.lt_of_succ_le h₁) },\n  { rw not_digit_succ_le_9_iff is_digit_digital_root at h₁,\n    rw [succ_mod_eq_zero_iff (nat.succ_pos _), ←digital_root_mod_9, h₁] at h₂, cases h₂ },\n  { rw not_digit_succ_le_9_iff is_digit_digital_root at h₁,\n    rw [nat.add_mod, ←@digital_root_mod_9 n, h₁], refl },\nend\n\nlemma sum_digits_digit_succ {d : ℕ} (h : is_digit d) : sum_digits d.succ = modp d.succ 9 :=\nbegin\n  rw [←nat.add_one, sum_digits_digit_add_digit h (dec_trivial : is_digit 1), modp],\n  split_ifs with h₁ h₂ h₂; try { rw not_digit_succ_le_9_iff h at h₁ },\n  { rw [succ_mod_eq_zero_iff (nat.succ_pos _),\n    nat.mod_eq_of_lt (nat.lt_of_succ_le h₁)] at h₂, rwa h₂ },\n  { rw nat.mod_eq_of_lt, rw succ_mod_eq_zero_iff (nat.succ_pos _) at h₂,\n    rw le_iff_lt_or_eq at h₁, cases h₁,\n    { exact h₁ },\n    { rw nat.succ_inj' at h₁, subst d, cases h₂ rfl }},\n  { subst h₁, cases h₂ },\n  { subst h₁, refl },\nend\n\nlemma not_pos_iff {n : ℕ} : ¬0 < n ↔ n = 0 := by rw [not_lt, le_zero_iff]\n\nlemma is_digit_zero : is_digit 0 := dec_trivial\n\nlemma is_digit_one : is_digit 1 := dec_trivial\n\nlemma le_sub_add {m n : ℕ} : m ≤ m - n + n :=\nbegin\n  induction n with n ih generalizing m,\n  { refl },\n  { cases m,\n    { apply zero_le },\n    { rw [nat.succ_sub_succ, nat.add_succ, nat.succ_le_succ_iff], exact ih }},\nend\n\nlemma is_digit_digit_add_digit_sub_9 {d₁ d₂ : ℕ} (h₁ : is_digit d₁) (h₂ : is_digit d₂) :\n  is_digit (d₁ + d₂ - 9) := nat.sub_le_sub_right (add_le_add h₁ h₂) _\n\nlemma digital_root_add_aux₁ {d₁ d₂ : ℕ} (h₁ : is_digit d₁) (h₂ : is_digit d₂)\n  (h₃ : 0 < d₁) (h₄ : 0 < d₂) :\n  sum_digits (d₁ + sum_digits d₂.succ) = modp (sum_digits (d₁ + d₂)).succ 9 :=\nbegin\n  simp_rw [sum_digits_digit_succ h₂, sum_digits_digit_add_digit h₁ h₂,\n  sum_digits_digit_add_digit h₁ is_digit_modp_9, ←nat.add_one],\n  split_ifs with h₅ h₆ h₆,\n  { rw [ modp_digit_add_digit h₂ is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit h₆ is_digit_one (or.inr nat.zero_lt_one)] at *,\n    split_ifs at *; linarith },\n  { rw [ modp_digit_add_digit h₂ is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit (is_digit_digit_add_digit_sub_9 h₁ h₂)\n    is_digit_one (or.inr nat.zero_lt_one)] at *, split_ifs at * with h₇ h₈ h₈,\n    { linarith },\n    { linarith },\n    { rw not_digit_succ_le_9_iff h₂ at h₇, subst h₇, refl },\n    { rw not_digit_succ_le_9_iff h₂ at h₇, subst h₇,\n      rw [nat.add_sub_cancel, not_digit_succ_le_9_iff h₁] at h₈, subst h₈,\n      contrapose! h₅, dec_trivial }},\n  { rw [ modp_digit_add_digit h₂ is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit h₆ is_digit_one (or.inr nat.zero_lt_one)] at *,\n    split_ifs at * with h₇ h₈ h₈,\n    { rw [←nat.add_assoc, not_digit_succ_le_9_iff h₆] at h₅, rw [←nat.add_assoc, h₅] },\n    { linarith },\n    { linarith }},\n  { rw [ modp_digit_add_digit h₂ is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit (is_digit_digit_add_digit_sub_9 h₁ h₂)\n    is_digit_one (or.inr nat.zero_lt_one) ] at *, split_ifs at * with h₇ h₈ h₈,\n    { push_neg at h₆, rw ←nat.add_assoc, exact nat.succ_sub (le_of_lt h₆) },\n    { push_neg at h₅ h₆ h₈, rw ←nat.add_assoc at h₅ ⊢, contrapose! h₈,\n      rw nat.succ_le_succ_iff at h₇ ⊢, exact tsub_le_iff_left.mpr (nat.add_le_add h₁ h₇) },\n    { push_neg at h₅ h₆ h₇, contrapose! h₅,\n      rwa [←nat.add_sub_assoc (le_of_lt h₇), ←nat.add_assoc, nat.succ_sub (le_of_lt h₆)] },\n    { push_neg at h₅ h₆ h₇ h₈,\n      rwa [←nat.add_sub_assoc (le_of_lt h₇), ←nat.add_assoc, nat.succ_sub (le_of_lt h₆)] }},\nend\n\nlemma digital_root_add_aux {d₁ d₂ : ℕ} (h₁ : is_digit d₁) (h₂ : is_digit d₂) :\n  sum_digits (d₁ + sum_digits d₂.succ) = modp (sum_digits (d₁ + d₂)).succ 9 :=\nbegin\n  by_cases h₃ : 0 < d₁,\n  { by_cases h₄ : 0 < d₂,\n    { exact digital_root_add_aux₁ h₁ h₂ h₃ h₄ },\n    { rw not_pos_iff at h₄, subst d₂, rw [add_zero, sum_digits_digit is_digit_one,\n      sum_digits_digit h₁, ←nat.add_one, sum_digits_digit_add_digit h₁ is_digit_one,\n      modp_digit_add_digit h₁ is_digit_one], exact or.inl h₃ }},\n  { rw not_pos_iff at h₃, subst d₁, simp_rw [zero_add, ←nat.add_one],\n    rw [sum_digits_digit (is_digit_sum_digits_digit_add_digit h₂ is_digit_one),\n    sum_digits_digit_add_digit h₂ is_digit_one, sum_digits_digit h₂,\n    modp_digit_add_digit h₂ is_digit_one(or.inr one_pos)] },\nend\n\nlemma digital_root_add {m n : ℕ} :\n  digital_root (m + n) = sum_digits (digital_root m + digital_root n) :=\nbegin\n  induction n with n ih,\n  { simp_rw [digital_root_zero, add_zero, sum_digits_digital_root] },\n  { rw [nat.add_succ, digital_root_succ_eq_sum_digits, ih, sum_digits_digit_succ\n    (is_digit_sum_digits_digit_add_digit is_digit_digital_root is_digit_digital_root)],\n    rw digital_root_succ_eq_sum_digits,\n    generalize hm : digital_root m = d₁, generalize hn : digital_root n = d₂,\n    have h₁ : is_digit d₁, { rw ←hm, exact is_digit_digital_root },\n    have h₂ : is_digit d₂, { rw ←hn, exact is_digit_digital_root },\n    exact (digital_root_add_aux h₁ h₂).symm },\nend\n\nlemma sum_digits_mul_10 {n : ℕ} : sum_digits (n * 10) = sum_digits n :=\nby rw [←nat.zero_add (n * 10), sum_digits_digit_add_mul_10 is_digit_zero, nat.zero_add]\n\nlemma digital_root_mul_10 {n : ℕ} : digital_root (n * 10) = digital_root n :=\nby rw [←digital_root_sum_digits, sum_digits_mul_10, digital_root_sum_digits]\n\nlemma digital_root_digit_add_mul_10 {d n : ℕ} (h : is_digit d) :\n  digital_root (d + n * 10) = sum_digits (d + digital_root n) :=\nby rw [digital_root_add, digital_root_mul_10, digital_root_digit h]\n\nlemma digital_root_eq_modp_of_pos {n : ℕ} (h : 0 < n) : digital_root n = modp n 9 :=\nbegin\n  induction n using digit_ind with d n h₁ ih,\n  { cases h },\n  { cases n,\n    { simp_rw [zero_mul, add_zero] at h ⊢,\n      rw [modp_digit_of_pos h₁ h, digital_root_digit_eq_self h₁] },\n    { specialize ih (nat.succ_pos _),\n      rw [digital_root_digit_add_mul_10 h₁, modp_digit_add_mul_10 h₁, ih,\n      sum_digits_digit_add_digit h₁ is_digit_modp_9],\n      split_ifs with h,\n      { cases d,\n        { simp },\n        { rw [modp_add, modp_digit_of_pos h₁ (nat.succ_pos _),\n          modp_digit_add_digit h₁ is_digit_modp_9 (or.inl (nat.succ_pos _)), if_pos h] }},\n      { have h₂ : 0 < d,\n        { contrapose! h, rw le_zero_iff at h, subst d,\n          rw zero_add, apply modp_le, dec_trivial },\n        rw [modp_add, modp_digit_of_pos h₁ h₂], revert h,\n        generalize h₃ : modp n.succ 9 = d₂, intro h, have h₄ : 0 < d₂,\n        { subst d₂, exact modp_pos_of_pos (nat.succ_pos _) },\n        have h₅ : is_digit d₂,\n        { subst d₂, exact is_digit_modp_9 },\n        rw [modp_digit_add_digit h₁ h₅ (or.inl h₂), if_neg h] }}},\nend\n\nlemma digital_root_def {n : ℕ} :\n  digital_root n = if n = 0 then 0 else if n % 9 = 0 then 9 else n % 9 :=\nbegin\n  rw ←modp, split_ifs with h h₁,\n  { cases h, exact digital_root_zero },\n  { exact digital_root_eq_modp_of_pos (pos_iff_ne_zero.mpr h) },\nend", "meta": {"author": "user7230724", "repo": "lean-projects", "sha": "ab9a83874775efd18f8c5b867e480bae4d596b31", "save_path": "github-repos/lean/user7230724-lean-projects", "path": "github-repos/lean/user7230724-lean-projects/lean-projects-ab9a83874775efd18f8c5b867e480bae4d596b31/src/digital_root/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4865015708948311}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Jeremy Avigad, Minchao Wu, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.multiset.finset_ops\nimport Mathlib.tactic.monotonicity.default\nimport Mathlib.tactic.apply\nimport Mathlib.tactic.nth_rewrite.default\nimport Mathlib.PostPort\n\nuniverses u_4 l u_1 u u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Finite sets\n\nmathlib has several different models for finite sets,\nand it can be confusing when you're first getting used to them!\n\nThis file builds the basic theory of `finset α`,\nmodelled as a `multiset α` without duplicates.\n\nIt's \"constructive\" in the since that there is an underlying list of elements,\nalthough this is wrapped in a quotient by permutations,\nso anytime you actually use this list you're obligated to show you didn't depend on the ordering.\n\nThere's also the typeclass `fintype α`\n(which asserts that there is some `finset α` containing every term of type `α`)\nas well as the predicate `finite` on `s : set α` (which asserts `nonempty (fintype s)`).\n-/\n\n/-- `finset α` is the type of finite sets of elements of `α`. It is implemented\n  as a multiset (a list up to permutation) which has no duplicate elements. -/\nstructure finset (α : Type u_4) \nwhere\n  val : multiset α\n  nodup : multiset.nodup val\n\nnamespace finset\n\n\ntheorem eq_of_veq {α : Type u_1} {s : finset α} {t : finset α} : val s = val t → s = t := sorry\n\n@[simp] theorem val_inj {α : Type u_1} {s : finset α} {t : finset α} : val s = val t ↔ s = t :=\n  { mp := eq_of_veq, mpr := congr_arg fun {s : finset α} => val s }\n\n@[simp] theorem erase_dup_eq_self {α : Type u_1} [DecidableEq α] (s : finset α) : multiset.erase_dup (val s) = val s :=\n  iff.mpr multiset.erase_dup_eq_self (nodup s)\n\nprotected instance has_decidable_eq {α : Type u_1} [DecidableEq α] : DecidableEq (finset α) :=\n  sorry\n\n/-! ### membership -/\n\nprotected instance has_mem {α : Type u_1} : has_mem α (finset α) :=\n  has_mem.mk fun (a : α) (s : finset α) => a ∈ val s\n\ntheorem mem_def {α : Type u_1} {a : α} {s : finset α} : a ∈ s ↔ a ∈ val s :=\n  iff.rfl\n\n@[simp] theorem mem_mk {α : Type u_1} {a : α} {s : multiset α} {nd : multiset.nodup s} : a ∈ mk s nd ↔ a ∈ s :=\n  iff.rfl\n\nprotected instance decidable_mem {α : Type u_1} [h : DecidableEq α] (a : α) (s : finset α) : Decidable (a ∈ s) :=\n  multiset.decidable_mem a (val s)\n\n/-! ### set coercion -/\n\n/-- Convert a finset to a set in the natural way. -/\nprotected instance set.has_coe_t {α : Type u_1} : has_coe_t (finset α) (set α) :=\n  has_coe_t.mk fun (s : finset α) => set_of fun (x : α) => x ∈ s\n\n@[simp] theorem mem_coe {α : Type u_1} {a : α} {s : finset α} : a ∈ ↑s ↔ a ∈ s :=\n  iff.rfl\n\n@[simp] theorem set_of_mem {α : Type u_1} {s : finset α} : (set_of fun (a : α) => a ∈ s) = ↑s :=\n  rfl\n\n@[simp] theorem coe_mem {α : Type u_1} {s : finset α} (x : ↥↑s) : ↑x ∈ s :=\n  subtype.property x\n\n@[simp] theorem mk_coe {α : Type u_1} {s : finset α} (x : ↥↑s) {h : ↑x ∈ ↑s} : { val := ↑x, property := h } = x :=\n  subtype.coe_eta x h\n\nprotected instance decidable_mem' {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : Decidable (a ∈ ↑s) :=\n  finset.decidable_mem a s\n\n/-! ### extensionality -/\n\ntheorem ext_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ = s₂ ↔ ∀ (a : α), a ∈ s₁ ↔ a ∈ s₂ :=\n  iff.trans (iff.symm val_inj) (multiset.nodup_ext (nodup s₁) (nodup s₂))\n\ntheorem ext {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : (∀ (a : α), a ∈ s₁ ↔ a ∈ s₂) → s₁ = s₂ :=\n  iff.mpr ext_iff\n\n@[simp] theorem coe_inj {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : ↑s₁ = ↑s₂ ↔ s₁ = s₂ :=\n  iff.trans set.ext_iff (iff.symm ext_iff)\n\ntheorem coe_injective {α : Type u_1} : function.injective coe :=\n  fun (s t : finset α) => iff.mp coe_inj\n\n/-! ### subset -/\n\nprotected instance has_subset {α : Type u_1} : has_subset (finset α) :=\n  has_subset.mk fun (s₁ s₂ : finset α) => ∀ {a : α}, a ∈ s₁ → a ∈ s₂\n\ntheorem subset_def {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ ⊆ s₂ ↔ val s₁ ⊆ val s₂ :=\n  iff.rfl\n\n@[simp] theorem subset.refl {α : Type u_1} (s : finset α) : s ⊆ s :=\n  multiset.subset.refl (val s)\n\ntheorem subset_of_eq {α : Type u_1} {s : finset α} {t : finset α} (h : s = t) : s ⊆ t :=\n  h ▸ subset.refl s\n\ntheorem subset.trans {α : Type u_1} {s₁ : finset α} {s₂ : finset α} {s₃ : finset α} : s₁ ⊆ s₂ → s₂ ⊆ s₃ → s₁ ⊆ s₃ :=\n  multiset.subset.trans\n\ntheorem superset.trans {α : Type u_1} {s₁ : finset α} {s₂ : finset α} {s₃ : finset α} : s₁ ⊇ s₂ → s₂ ⊇ s₃ → s₁ ⊇ s₃ :=\n  fun (h' : s₁ ⊇ s₂) (h : s₂ ⊇ s₃) => subset.trans h h'\n\n-- TODO: these should be global attributes, but this will require fixing other files\n\ntheorem mem_of_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} {a : α} : s₁ ⊆ s₂ → a ∈ s₁ → a ∈ s₂ :=\n  multiset.mem_of_subset\n\ntheorem subset.antisymm {α : Type u_1} {s₁ : finset α} {s₂ : finset α} (H₁ : s₁ ⊆ s₂) (H₂ : s₂ ⊆ s₁) : s₁ = s₂ :=\n  ext fun (a : α) => { mp := H₁, mpr := H₂ }\n\ntheorem subset_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ ⊆ s₂ ↔ ∀ {x : α}, x ∈ s₁ → x ∈ s₂ :=\n  iff.rfl\n\n@[simp] theorem coe_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : ↑s₁ ⊆ ↑s₂ ↔ s₁ ⊆ s₂ :=\n  iff.rfl\n\n@[simp] theorem val_le_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : val s₁ ≤ val s₂ ↔ s₁ ⊆ s₂ :=\n  multiset.le_iff_subset (nodup s₁)\n\nprotected instance has_ssubset {α : Type u_1} : has_ssubset (finset α) :=\n  has_ssubset.mk fun (a b : finset α) => a ⊆ b ∧ ¬b ⊆ a\n\nprotected instance partial_order {α : Type u_1} : partial_order (finset α) :=\n  partial_order.mk has_subset.subset has_ssubset.ssubset subset.refl subset.trans subset.antisymm\n\ntheorem subset.antisymm_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ = s₂ ↔ s₁ ⊆ s₂ ∧ s₂ ⊆ s₁ :=\n  le_antisymm_iff\n\n@[simp] theorem le_iff_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ ≤ s₂ ↔ s₁ ⊆ s₂ :=\n  iff.rfl\n\n@[simp] theorem lt_iff_ssubset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ < s₂ ↔ s₁ ⊂ s₂ :=\n  iff.rfl\n\n@[simp] theorem coe_ssubset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : ↑s₁ ⊂ ↑s₂ ↔ s₁ ⊂ s₂ := sorry\n\n@[simp] theorem val_lt_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : val s₁ < val s₂ ↔ s₁ ⊂ s₂ :=\n  and_congr val_le_iff (not_congr val_le_iff)\n\ntheorem ssubset_iff_of_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} (h : s₁ ⊆ s₂) : s₁ ⊂ s₂ ↔ ∃ (x : α), ∃ (H : x ∈ s₂), ¬x ∈ s₁ :=\n  set.ssubset_iff_of_subset h\n\n/-! ### Nonempty -/\n\n/-- The property `s.nonempty` expresses the fact that the finset `s` is not empty. It should be used\nin theorem assumptions instead of `∃ x, x ∈ s` or `s ≠ ∅` as it gives access to a nice API thanks\nto the dot notation. -/\nprotected def nonempty {α : Type u_1} (s : finset α) :=\n  ∃ (x : α), x ∈ s\n\n@[simp] theorem coe_nonempty {α : Type u_1} {s : finset α} : set.nonempty ↑s ↔ finset.nonempty s :=\n  iff.rfl\n\ntheorem nonempty.bex {α : Type u_1} {s : finset α} (h : finset.nonempty s) : ∃ (x : α), x ∈ s :=\n  h\n\ntheorem nonempty.mono {α : Type u_1} {s : finset α} {t : finset α} (hst : s ⊆ t) (hs : finset.nonempty s) : finset.nonempty t :=\n  set.nonempty.mono hst hs\n\ntheorem nonempty.forall_const {α : Type u_1} {s : finset α} (h : finset.nonempty s) {p : Prop} : (∀ (x : α), x ∈ s → p) ↔ p := sorry\n\n/-! ### empty -/\n\n/-- The empty finset -/\nprotected def empty {α : Type u_1} : finset α :=\n  mk 0 multiset.nodup_zero\n\nprotected instance has_emptyc {α : Type u_1} : has_emptyc (finset α) :=\n  has_emptyc.mk finset.empty\n\nprotected instance inhabited {α : Type u_1} : Inhabited (finset α) :=\n  { default := ∅ }\n\n@[simp] theorem empty_val {α : Type u_1} : val ∅ = 0 :=\n  rfl\n\n@[simp] theorem not_mem_empty {α : Type u_1} (a : α) : ¬a ∈ ∅ :=\n  id\n\n@[simp] theorem not_nonempty_empty {α : Type u_1} : ¬finset.nonempty ∅ :=\n  fun (_x : finset.nonempty ∅) =>\n    (fun (_a : finset.nonempty ∅) => Exists.dcases_on _a fun (w : α) (h : w ∈ ∅) => idRhs False (not_mem_empty w h)) _x\n\n@[simp] theorem mk_zero {α : Type u_1} : mk 0 multiset.nodup_zero = ∅ :=\n  rfl\n\ntheorem ne_empty_of_mem {α : Type u_1} {a : α} {s : finset α} (h : a ∈ s) : s ≠ ∅ :=\n  fun (e : s = ∅) => not_mem_empty a (e ▸ h)\n\ntheorem nonempty.ne_empty {α : Type u_1} {s : finset α} (h : finset.nonempty s) : s ≠ ∅ :=\n  exists.elim h fun (a : α) => ne_empty_of_mem\n\n@[simp] theorem empty_subset {α : Type u_1} (s : finset α) : ∅ ⊆ s :=\n  multiset.zero_subset (val s)\n\ntheorem eq_empty_of_forall_not_mem {α : Type u_1} {s : finset α} (H : ∀ (x : α), ¬x ∈ s) : s = ∅ :=\n  eq_of_veq (multiset.eq_zero_of_forall_not_mem H)\n\ntheorem eq_empty_iff_forall_not_mem {α : Type u_1} {s : finset α} : s = ∅ ↔ ∀ (x : α), ¬x ∈ s :=\n  { mp := fun (ᾰ : s = ∅) (x : α) => Eq._oldrec id (Eq.symm ᾰ),\n    mpr := fun (h : ∀ (x : α), ¬x ∈ s) => eq_empty_of_forall_not_mem h }\n\n@[simp] theorem val_eq_zero {α : Type u_1} {s : finset α} : val s = 0 ↔ s = ∅ :=\n  val_inj\n\ntheorem subset_empty {α : Type u_1} {s : finset α} : s ⊆ ∅ ↔ s = ∅ :=\n  iff.trans multiset.subset_zero val_eq_zero\n\ntheorem nonempty_of_ne_empty {α : Type u_1} {s : finset α} (h : s ≠ ∅) : finset.nonempty s :=\n  multiset.exists_mem_of_ne_zero (mt (iff.mp val_eq_zero) h)\n\ntheorem nonempty_iff_ne_empty {α : Type u_1} {s : finset α} : finset.nonempty s ↔ s ≠ ∅ :=\n  { mp := nonempty.ne_empty, mpr := nonempty_of_ne_empty }\n\n@[simp] theorem not_nonempty_iff_eq_empty {α : Type u_1} {s : finset α} : ¬finset.nonempty s ↔ s = ∅ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (¬finset.nonempty s ↔ s = ∅)) (propext nonempty_iff_ne_empty))) not_not\n\ntheorem eq_empty_or_nonempty {α : Type u_1} (s : finset α) : s = ∅ ∨ finset.nonempty s :=\n  classical.by_cases Or.inl fun (h : ¬s = ∅) => Or.inr (nonempty_of_ne_empty h)\n\n@[simp] theorem coe_empty {α : Type u_1} : ↑∅ = ∅ :=\n  rfl\n\n/-- A `finset` for an empty type is empty. -/\ntheorem eq_empty_of_not_nonempty {α : Type u_1} (h : ¬Nonempty α) (s : finset α) : s = ∅ :=\n  eq_empty_of_forall_not_mem fun (x : α) => false.elim (iff.mp not_nonempty_iff_imp_false h x)\n\n/-! ### singleton -/\n\n/--\n`{a} : finset a` is the set `{a}` containing `a` and nothing else.\n\nThis differs from `insert a ∅` in that it does not require a `decidable_eq` instance for `α`.\n-/\nprotected instance has_singleton {α : Type u_1} : has_singleton α (finset α) :=\n  has_singleton.mk fun (a : α) => mk (singleton a) (multiset.nodup_singleton a)\n\n@[simp] theorem singleton_val {α : Type u_1} (a : α) : val (singleton a) = a ::ₘ 0 :=\n  rfl\n\n@[simp] theorem mem_singleton {α : Type u_1} {a : α} {b : α} : b ∈ singleton a ↔ b = a :=\n  multiset.mem_singleton\n\ntheorem not_mem_singleton {α : Type u_1} {a : α} {b : α} : ¬a ∈ singleton b ↔ a ≠ b :=\n  not_congr mem_singleton\n\ntheorem mem_singleton_self {α : Type u_1} (a : α) : a ∈ singleton a :=\n  Or.inl rfl\n\ntheorem singleton_inj {α : Type u_1} {a : α} {b : α} : singleton a = singleton b ↔ a = b :=\n  { mp := fun (h : singleton a = singleton b) => iff.mp mem_singleton (h ▸ mem_singleton_self a),\n    mpr := congr_arg fun {a : α} => singleton a }\n\n@[simp] theorem singleton_nonempty {α : Type u_1} (a : α) : finset.nonempty (singleton a) :=\n  Exists.intro a (mem_singleton_self a)\n\n@[simp] theorem singleton_ne_empty {α : Type u_1} (a : α) : singleton a ≠ ∅ :=\n  nonempty.ne_empty (singleton_nonempty a)\n\n@[simp] theorem coe_singleton {α : Type u_1} (a : α) : ↑(singleton a) = singleton a := sorry\n\ntheorem eq_singleton_iff_unique_mem {α : Type u_1} {s : finset α} {a : α} : s = singleton a ↔ a ∈ s ∧ ∀ (x : α), x ∈ s → x = a := sorry\n\ntheorem eq_singleton_iff_nonempty_unique_mem {α : Type u_1} {s : finset α} {a : α} : s = singleton a ↔ finset.nonempty s ∧ ∀ (x : α), x ∈ s → x = a := sorry\n\ntheorem singleton_iff_unique_mem {α : Type u_1} (s : finset α) : (∃ (a : α), s = singleton a) ↔ exists_unique fun (a : α) => a ∈ s := sorry\n\ntheorem singleton_subset_set_iff {α : Type u_1} {s : set α} {a : α} : ↑(singleton a) ⊆ s ↔ a ∈ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (↑(singleton a) ⊆ s ↔ a ∈ s)) (coe_singleton a)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a ⊆ s ↔ a ∈ s)) (propext set.singleton_subset_iff))) (iff.refl (a ∈ s)))\n\n@[simp] theorem singleton_subset_iff {α : Type u_1} {s : finset α} {a : α} : singleton a ⊆ s ↔ a ∈ s :=\n  singleton_subset_set_iff\n\n/-! ### cons -/\n\n/-- `cons a s h` is the set `{a} ∪ s` containing `a` and the elements of `s`. It is the same as\n`insert a s` when it is defined, but unlike `insert a s` it does not require `decidable_eq α`,\nand the union is guaranteed to be disjoint.  -/\ndef cons {α : Type u_1} (a : α) (s : finset α) (h : ¬a ∈ s) : finset α :=\n  mk (a ::ₘ val s) sorry\n\n@[simp] theorem mem_cons {α : Type u_1} {a : α} {s : finset α} {h : ¬a ∈ s} {b : α} : b ∈ cons a s h ↔ b = a ∨ b ∈ s := sorry\n\n@[simp] theorem cons_val {α : Type u_1} {a : α} {s : finset α} (h : ¬a ∈ s) : val (cons a s h) = a ::ₘ val s :=\n  rfl\n\n@[simp] theorem mk_cons {α : Type u_1} {a : α} {s : multiset α} (h : multiset.nodup (a ::ₘ s)) : mk (a ::ₘ s) h = cons a (mk s (and.right (iff.mp multiset.nodup_cons h))) (and.left (iff.mp multiset.nodup_cons h)) :=\n  rfl\n\n@[simp] theorem nonempty_cons {α : Type u_1} {a : α} {s : finset α} (h : ¬a ∈ s) : finset.nonempty (cons a s h) :=\n  Exists.intro a (iff.mpr mem_cons (Or.inl rfl))\n\n@[simp] theorem nonempty_mk_coe {α : Type u_1} {l : List α} {hl : multiset.nodup ↑l} : finset.nonempty (mk (↑l) hl) ↔ l ≠ [] := sorry\n\n/-! ### disjoint union -/\n\n/-- `disj_union s t h` is the set such that `a ∈ disj_union s t h` iff `a ∈ s` or `a ∈ t`.\nIt is the same as `s ∪ t`, but it does not require decidable equality on the type. The hypothesis\nensures that the sets are disjoint. -/\ndef disj_union {α : Type u_1} (s : finset α) (t : finset α) (h : ∀ (a : α), a ∈ s → ¬a ∈ t) : finset α :=\n  mk (val s + val t) sorry\n\n@[simp] theorem mem_disj_union {α : Type u_1} {s : finset α} {t : finset α} {h : ∀ (a : α), a ∈ s → ¬a ∈ t} {a : α} : a ∈ disj_union s t h ↔ a ∈ s ∨ a ∈ t := sorry\n\n/-! ### insert -/\n\n/-- `insert a s` is the set `{a} ∪ s` containing `a` and the elements of `s`. -/\nprotected instance has_insert {α : Type u_1} [DecidableEq α] : has_insert α (finset α) :=\n  has_insert.mk fun (a : α) (s : finset α) => mk (multiset.ndinsert a (val s)) sorry\n\ntheorem insert_def {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : insert a s = mk (multiset.ndinsert a (val s)) (multiset.nodup_ndinsert a (nodup s)) :=\n  rfl\n\n@[simp] theorem insert_val {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : val (insert a s) = multiset.ndinsert a (val s) :=\n  rfl\n\ntheorem insert_val' {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : val (insert a s) = multiset.erase_dup (a ::ₘ val s) := sorry\n\ntheorem insert_val_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) : val (insert a s) = a ::ₘ val s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (val (insert a s) = a ::ₘ val s)) (insert_val a s)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (multiset.ndinsert a (val s) = a ::ₘ val s)) (multiset.ndinsert_of_not_mem h)))\n      (Eq.refl (a ::ₘ val s)))\n\n@[simp] theorem mem_insert {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} : a ∈ insert b s ↔ a = b ∨ a ∈ s :=\n  multiset.mem_ndinsert\n\ntheorem mem_insert_self {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : a ∈ insert a s :=\n  multiset.mem_ndinsert_self a (val s)\n\ntheorem mem_insert_of_mem {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} (h : a ∈ s) : a ∈ insert b s :=\n  multiset.mem_ndinsert_of_mem h\n\ntheorem mem_of_mem_insert_of_ne {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} (h : b ∈ insert a s) : b ≠ a → b ∈ s :=\n  or.resolve_left (iff.mp mem_insert h)\n\n@[simp] theorem cons_eq_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (h : ¬a ∈ s) : cons a s h = insert a s := sorry\n\n@[simp] theorem coe_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : ↑(insert a s) = insert a ↑s := sorry\n\ntheorem mem_insert_coe {α : Type u_1} [DecidableEq α] {s : finset α} {x : α} {y : α} : x ∈ insert y s ↔ x ∈ insert y ↑s := sorry\n\nprotected instance is_lawful_singleton {α : Type u_1} [DecidableEq α] : is_lawful_singleton α (finset α) :=\n  is_lawful_singleton.mk\n    fun (a : α) =>\n      ext\n        fun (a_1 : α) =>\n          eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_2 : Prop) (e_1 : a = a_2) (b b_1 : Prop) (e_2 : b = b_1) => congr (congr_arg Iff e_1) e_2)\n                  (a_1 ∈ insert a ∅) (a_1 = a)\n                  (Eq.trans\n                    (Eq.trans (propext mem_insert)\n                      ((fun (a a_2 : Prop) (e_1 : a = a_2) (b b_1 : Prop) (e_2 : b = b_1) => congr (congr_arg Or e_1) e_2)\n                        (a_1 = a) (a_1 = a) (Eq.refl (a_1 = a)) (a_1 ∈ ∅) False\n                        (propext ((fun {α : Type u_1} (a : α) => iff_false_intro (not_mem_empty a)) a_1))))\n                    (propext (or_false (a_1 = a))))\n                  (a_1 ∈ singleton a) (a_1 = a) (propext mem_singleton))\n                (propext (iff_self (a_1 = a)))))\n            trivial\n\n@[simp] theorem insert_eq_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) : insert a s = s :=\n  eq_of_veq (multiset.ndinsert_of_mem h)\n\n@[simp] theorem insert_singleton_self_eq {α : Type u_1} [DecidableEq α] (a : α) : insert a (singleton a) = singleton a :=\n  insert_eq_of_mem (mem_singleton_self a)\n\ntheorem insert.comm {α : Type u_1} [DecidableEq α] (a : α) (b : α) (s : finset α) : insert a (insert b s) = insert b (insert a s) := sorry\n\ntheorem insert_singleton_comm {α : Type u_1} [DecidableEq α] (a : α) (b : α) : insert a (singleton b) = insert b (singleton a) := sorry\n\n@[simp] theorem insert_idem {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : insert a (insert a s) = insert a s := sorry\n\n@[simp] theorem insert_nonempty {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : finset.nonempty (insert a s) :=\n  Exists.intro a (mem_insert_self a s)\n\n@[simp] theorem insert_ne_empty {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : insert a s ≠ ∅ :=\n  nonempty.ne_empty (insert_nonempty a s)\n\n/-!\nThe universe annotation is required for the following instance, possibly this is a bug in Lean. See\nleanprover.zulipchat.com/#narrow/stream/113488-general/topic/strange.20error.20(universe.20issue.3F)\n-/\n\nprotected instance has_insert.insert.nonempty {α : Type u} [DecidableEq α] (i : α) (s : finset α) : Nonempty ↥↑(insert i s) :=\n  set.nonempty.to_subtype (iff.mpr coe_nonempty (insert_nonempty i s))\n\ntheorem ne_insert_of_not_mem {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) {a : α} (h : ¬a ∈ s) : s ≠ insert a t := sorry\n\ntheorem insert_subset {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} {t : finset α} : insert a s ⊆ t ↔ a ∈ t ∧ s ⊆ t := sorry\n\ntheorem subset_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : s ⊆ insert a s :=\n  fun (b : α) => mem_insert_of_mem\n\ntheorem insert_subset_insert {α : Type u_1} [DecidableEq α] (a : α) {s : finset α} {t : finset α} (h : s ⊆ t) : insert a s ⊆ insert a t :=\n  iff.mpr insert_subset { left := mem_insert_self a t, right := subset.trans h (subset_insert a t) }\n\ntheorem ssubset_iff {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s ⊂ t ↔ ∃ (a : α), ∃ (H : ¬a ∈ s), insert a s ⊆ t := sorry\n\ntheorem ssubset_insert {α : Type u_1} [DecidableEq α] {s : finset α} {a : α} (h : ¬a ∈ s) : s ⊂ insert a s :=\n  iff.mpr ssubset_iff (Exists.intro a (Exists.intro h (subset.refl (insert a s))))\n\nprotected theorem induction {α : Type u_1} {p : finset α → Prop} [DecidableEq α] (h₁ : p ∅) (h₂ : ∀ {a : α} {s : finset α}, ¬a ∈ s → p s → p (insert a s)) (s : finset α) : p s := sorry\n\n/--\nTo prove a proposition about an arbitrary `finset α`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset α`,\nthen it holds for the `finset` obtained by inserting a new element.\n-/\nprotected theorem induction_on {α : Type u_1} {p : finset α → Prop} [DecidableEq α] (s : finset α) (h₁ : p ∅) (h₂ : ∀ {a : α} {s : finset α}, ¬a ∈ s → p s → p (insert a s)) : p s :=\n  finset.induction h₁ h₂ s\n\n/--\nTo prove a proposition about `S : finset α`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset α ⊆ S`,\nthen it holds for the `finset` obtained by inserting a new element of `S`.\n-/\ntheorem induction_on' {α : Type u_1} {p : finset α → Prop} [DecidableEq α] (S : finset α) (h₁ : p ∅) (h₂ : ∀ {a : α} {s : finset α}, a ∈ S → s ⊆ S → ¬a ∈ s → p s → p (insert a s)) : p S := sorry\n\n/-- Inserting an element to a finite set is equivalent to the option type. -/\ndef subtype_insert_equiv_option {α : Type u_1} [DecidableEq α] {t : finset α} {x : α} (h : ¬x ∈ t) : (Subtype fun (i : α) => i ∈ insert x t) ≃ Option (Subtype fun (i : α) => i ∈ t) :=\n  equiv.mk\n    (fun (y : Subtype fun (i : α) => i ∈ insert x t) =>\n      dite (↑y = x) (fun (h : ↑y = x) => none) fun (h : ¬↑y = x) => some { val := ↑y, property := sorry })\n    (fun (y : Option (Subtype fun (i : α) => i ∈ t)) =>\n      option.elim y { val := x, property := sorry }\n        fun (z : Subtype fun (i : α) => i ∈ t) => { val := ↑z, property := sorry })\n    sorry sorry\n\n/-! ### union -/\n\n/-- `s ∪ t` is the set such that `a ∈ s ∪ t` iff `a ∈ s` or `a ∈ t`. -/\nprotected instance has_union {α : Type u_1} [DecidableEq α] : has_union (finset α) :=\n  has_union.mk fun (s₁ s₂ : finset α) => mk (multiset.ndunion (val s₁) (val s₂)) sorry\n\ntheorem union_val_nd {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : val (s₁ ∪ s₂) = multiset.ndunion (val s₁) (val s₂) :=\n  rfl\n\n@[simp] theorem union_val {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : val (s₁ ∪ s₂) = val s₁ ∪ val s₂ :=\n  multiset.ndunion_eq_union (nodup s₁)\n\n@[simp] theorem mem_union {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} : a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂ :=\n  multiset.mem_ndunion\n\n@[simp] theorem disj_union_eq_union {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (h : ∀ (a : α), a ∈ s → ¬a ∈ t) : disj_union s t h = s ∪ t := sorry\n\ntheorem mem_union_left {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} (s₂ : finset α) (h : a ∈ s₁) : a ∈ s₁ ∪ s₂ :=\n  iff.mpr mem_union (Or.inl h)\n\ntheorem mem_union_right {α : Type u_1} [DecidableEq α] {a : α} {s₂ : finset α} (s₁ : finset α) (h : a ∈ s₂) : a ∈ s₁ ∪ s₂ :=\n  iff.mpr mem_union (Or.inr h)\n\ntheorem forall_mem_union {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {p : α → Prop} : (∀ (ab : α), ab ∈ s₁ ∪ s₂ → p ab) ↔ (∀ (a : α), a ∈ s₁ → p a) ∧ ∀ (b : α), b ∈ s₂ → p b := sorry\n\ntheorem not_mem_union {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} : ¬a ∈ s₁ ∪ s₂ ↔ ¬a ∈ s₁ ∧ ¬a ∈ s₂ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (¬a ∈ s₁ ∪ s₂ ↔ ¬a ∈ s₁ ∧ ¬a ∈ s₂)) (propext mem_union)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (¬(a ∈ s₁ ∨ a ∈ s₂) ↔ ¬a ∈ s₁ ∧ ¬a ∈ s₂)) (propext not_or_distrib)))\n      (iff.refl (¬a ∈ s₁ ∧ ¬a ∈ s₂)))\n\n@[simp] theorem coe_union {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : ↑(s₁ ∪ s₂) = ↑s₁ ∪ ↑s₂ :=\n  set.ext fun (x : α) => mem_union\n\ntheorem union_subset {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {s₃ : finset α} (h₁ : s₁ ⊆ s₃) (h₂ : s₂ ⊆ s₃) : s₁ ∪ s₂ ⊆ s₃ :=\n  iff.mp val_le_iff (iff.mpr multiset.ndunion_le { left := h₁, right := iff.mpr val_le_iff h₂ })\n\ntheorem subset_union_left {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ ⊆ s₁ ∪ s₂ :=\n  fun (x : α) => mem_union_left s₂\n\ntheorem subset_union_right {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₂ ⊆ s₁ ∪ s₂ :=\n  fun (x : α) => mem_union_right s₁\n\ntheorem union_subset_union {α : Type u_1} [DecidableEq α] {s1 : finset α} {t1 : finset α} {s2 : finset α} {t2 : finset α} (h1 : s1 ⊆ t1) (h2 : s2 ⊆ t2) : s1 ∪ s2 ⊆ t1 ∪ t2 := sorry\n\ntheorem union_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ ∪ s₂ = s₂ ∪ s₁ := sorry\n\nprotected instance has_union.union.is_commutative {α : Type u_1} [DecidableEq α] : is_commutative (finset α) has_union.union :=\n  is_commutative.mk union_comm\n\n@[simp] theorem union_assoc {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (s₃ : finset α) : s₁ ∪ s₂ ∪ s₃ = s₁ ∪ (s₂ ∪ s₃) := sorry\n\nprotected instance has_union.union.is_associative {α : Type u_1} [DecidableEq α] : is_associative (finset α) has_union.union :=\n  is_associative.mk union_assoc\n\n@[simp] theorem union_idempotent {α : Type u_1} [DecidableEq α] (s : finset α) : s ∪ s = s :=\n  ext fun (_x : α) => iff.trans mem_union (or_self (_x ∈ s))\n\nprotected instance has_union.union.is_idempotent {α : Type u_1} [DecidableEq α] : is_idempotent (finset α) has_union.union :=\n  is_idempotent.mk union_idempotent\n\ntheorem union_left_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (s₃ : finset α) : s₁ ∪ (s₂ ∪ s₃) = s₂ ∪ (s₁ ∪ s₃) := sorry\n\ntheorem union_right_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (s₃ : finset α) : s₁ ∪ s₂ ∪ s₃ = s₁ ∪ s₃ ∪ s₂ := sorry\n\ntheorem union_self {α : Type u_1} [DecidableEq α] (s : finset α) : s ∪ s = s :=\n  union_idempotent s\n\n@[simp] theorem union_empty {α : Type u_1} [DecidableEq α] (s : finset α) : s ∪ ∅ = s :=\n  ext fun (x : α) => iff.trans mem_union (or_false (x ∈ s))\n\n@[simp] theorem empty_union {α : Type u_1} [DecidableEq α] (s : finset α) : ∅ ∪ s = s :=\n  ext fun (x : α) => iff.trans mem_union (false_or (x ∈ s))\n\ntheorem insert_eq {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : insert a s = singleton a ∪ s :=\n  rfl\n\n@[simp] theorem insert_union {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (t : finset α) : insert a s ∪ t = insert a (s ∪ t) := sorry\n\n@[simp] theorem union_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (t : finset α) : s ∪ insert a t = insert a (s ∪ t) := sorry\n\ntheorem insert_union_distrib {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (t : finset α) : insert a (s ∪ t) = insert a s ∪ insert a t := sorry\n\n@[simp] theorem union_eq_left_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s ∪ t = s ↔ t ⊆ s :=\n  { mp := fun (h : s ∪ t = s) => eq.mp (Eq._oldrec (Eq.refl (t ⊆ s ∪ t)) h) (subset_union_right s t),\n    mpr := fun (h : t ⊆ s) => subset.antisymm (union_subset (subset.refl s) h) (subset_union_left s t) }\n\n@[simp] theorem left_eq_union_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s = s ∪ t ↔ t ⊆ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s = s ∪ t ↔ t ⊆ s)) (Eq.symm (propext union_eq_left_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = s ∪ t ↔ s ∪ t = s)) (propext eq_comm))) (iff.refl (s ∪ t = s)))\n\n@[simp] theorem union_eq_right_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : t ∪ s = s ↔ t ⊆ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (t ∪ s = s ↔ t ⊆ s)) (union_comm t s)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t = s ↔ t ⊆ s)) (propext union_eq_left_iff_subset))) (iff.refl (t ⊆ s)))\n\n@[simp] theorem right_eq_union_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s = t ∪ s ↔ t ⊆ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s = t ∪ s ↔ t ⊆ s)) (Eq.symm (propext union_eq_right_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = t ∪ s ↔ t ∪ s = s)) (propext eq_comm))) (iff.refl (t ∪ s = s)))\n\n/--\nTo prove a relation on pairs of `finset X`, it suffices to show that it is\n  * symmetric,\n  * it holds when one of the `finset`s is empty,\n  * it holds for pairs of singletons,\n  * if it holds for `[a, c]` and for `[b, c]`, then it holds for `[a ∪ b, c]`.\n-/\ntheorem induction_on_union {α : Type u_1} [DecidableEq α] (P : finset α → finset α → Prop) (symm : ∀ {a b : finset α}, P a b → P b a) (empty_right : ∀ {a : finset α}, P a ∅) (singletons : ∀ {a b : α}, P (singleton a) (singleton b)) (union_of : ∀ {a b c : finset α}, P a c → P b c → P (a ∪ b) c) (a : finset α) (b : finset α) : P a b := sorry\n\n/-! ### inter -/\n\n/-- `s ∩ t` is the set such that `a ∈ s ∩ t` iff `a ∈ s` and `a ∈ t`. -/\nprotected instance has_inter {α : Type u_1} [DecidableEq α] : has_inter (finset α) :=\n  has_inter.mk fun (s₁ s₂ : finset α) => mk (multiset.ndinter (val s₁) (val s₂)) sorry\n\ntheorem inter_val_nd {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : val (s₁ ∩ s₂) = multiset.ndinter (val s₁) (val s₂) :=\n  rfl\n\n@[simp] theorem inter_val {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : val (s₁ ∩ s₂) = val s₁ ∩ val s₂ :=\n  multiset.ndinter_eq_inter (nodup s₁)\n\n@[simp] theorem mem_inter {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} : a ∈ s₁ ∩ s₂ ↔ a ∈ s₁ ∧ a ∈ s₂ :=\n  multiset.mem_ndinter\n\ntheorem mem_of_mem_inter_left {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} (h : a ∈ s₁ ∩ s₂) : a ∈ s₁ :=\n  and.left (iff.mp mem_inter h)\n\ntheorem mem_of_mem_inter_right {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} (h : a ∈ s₁ ∩ s₂) : a ∈ s₂ :=\n  and.right (iff.mp mem_inter h)\n\ntheorem mem_inter_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} : a ∈ s₁ → a ∈ s₂ → a ∈ s₁ ∩ s₂ :=\n  iff.mp and_imp (iff.mpr mem_inter)\n\ntheorem inter_subset_left {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ ∩ s₂ ⊆ s₁ :=\n  fun (a : α) => mem_of_mem_inter_left\n\ntheorem inter_subset_right {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ ∩ s₂ ⊆ s₂ :=\n  fun (a : α) => mem_of_mem_inter_right\n\ntheorem subset_inter {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {s₃ : finset α} : s₁ ⊆ s₂ → s₁ ⊆ s₃ → s₁ ⊆ s₂ ∩ s₃ := sorry\n\n@[simp] theorem coe_inter {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : ↑(s₁ ∩ s₂) = ↑s₁ ∩ ↑s₂ :=\n  set.ext fun (_x : α) => mem_inter\n\n@[simp] theorem union_inter_cancel_left {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : (s ∪ t) ∩ s = s := sorry\n\n@[simp] theorem union_inter_cancel_right {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : (s ∪ t) ∩ t = t := sorry\n\ntheorem inter_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ ∩ s₂ = s₂ ∩ s₁ := sorry\n\n@[simp] theorem inter_assoc {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (s₃ : finset α) : s₁ ∩ s₂ ∩ s₃ = s₁ ∩ (s₂ ∩ s₃) := sorry\n\ntheorem inter_left_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (s₃ : finset α) : s₁ ∩ (s₂ ∩ s₃) = s₂ ∩ (s₁ ∩ s₃) := sorry\n\ntheorem inter_right_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (s₃ : finset α) : s₁ ∩ s₂ ∩ s₃ = s₁ ∩ s₃ ∩ s₂ := sorry\n\n@[simp] theorem inter_self {α : Type u_1} [DecidableEq α] (s : finset α) : s ∩ s = s :=\n  ext fun (_x : α) => iff.trans mem_inter (and_self (_x ∈ s))\n\n@[simp] theorem inter_empty {α : Type u_1} [DecidableEq α] (s : finset α) : s ∩ ∅ = ∅ :=\n  ext fun (_x : α) => iff.trans mem_inter (and_false (_x ∈ s))\n\n@[simp] theorem empty_inter {α : Type u_1} [DecidableEq α] (s : finset α) : ∅ ∩ s = ∅ :=\n  ext fun (_x : α) => iff.trans mem_inter (false_and (_x ∈ s))\n\n@[simp] theorem inter_union_self {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : s ∩ (t ∪ s) = s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∩ (t ∪ s) = s)) (inter_comm s (t ∪ s))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((t ∪ s) ∩ s = s)) union_inter_cancel_right)) (Eq.refl s))\n\n@[simp] theorem insert_inter_of_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {a : α} (h : a ∈ s₂) : insert a s₁ ∩ s₂ = insert a (s₁ ∩ s₂) := sorry\n\n@[simp] theorem inter_insert_of_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {a : α} (h : a ∈ s₁) : s₁ ∩ insert a s₂ = insert a (s₁ ∩ s₂) := sorry\n\n@[simp] theorem insert_inter_of_not_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {a : α} (h : ¬a ∈ s₂) : insert a s₁ ∩ s₂ = s₁ ∩ s₂ := sorry\n\n@[simp] theorem inter_insert_of_not_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {a : α} (h : ¬a ∈ s₁) : s₁ ∩ insert a s₂ = s₁ ∩ s₂ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s₁ ∩ insert a s₂ = s₁ ∩ s₂)) (inter_comm s₁ (insert a s₂))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a s₂ ∩ s₁ = s₁ ∩ s₂)) (insert_inter_of_not_mem h)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s₂ ∩ s₁ = s₁ ∩ s₂)) (inter_comm s₂ s₁))) (Eq.refl (s₁ ∩ s₂))))\n\n@[simp] theorem singleton_inter_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (H : a ∈ s) : singleton a ∩ s = singleton a :=\n  (fun (this : insert a ∅ ∩ s = insert a ∅) => this)\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a ∅ ∩ s = insert a ∅)) (insert_inter_of_mem H)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (insert a (∅ ∩ s) = insert a ∅)) (empty_inter s))) (Eq.refl (insert a ∅))))\n\n@[simp] theorem singleton_inter_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (H : ¬a ∈ s) : singleton a ∩ s = ∅ := sorry\n\n@[simp] theorem inter_singleton_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) : s ∩ singleton a = singleton a :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∩ singleton a = singleton a)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a ∩ s = singleton a)) (singleton_inter_of_mem h)))\n      (Eq.refl (singleton a)))\n\n@[simp] theorem inter_singleton_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) : s ∩ singleton a = ∅ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∩ singleton a = ∅)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a ∩ s = ∅)) (singleton_inter_of_not_mem h))) (Eq.refl ∅))\n\ntheorem inter_subset_inter {α : Type u_1} [DecidableEq α] {x : finset α} {y : finset α} {s : finset α} {t : finset α} (h : x ⊆ y) (h' : s ⊆ t) : x ∩ s ⊆ y ∩ t := sorry\n\ntheorem inter_subset_inter_right {α : Type u_1} [DecidableEq α] {x : finset α} {y : finset α} {s : finset α} (h : x ⊆ y) : x ∩ s ⊆ y ∩ s :=\n  inter_subset_inter h (subset.refl s)\n\ntheorem inter_subset_inter_left {α : Type u_1} [DecidableEq α] {x : finset α} {y : finset α} {s : finset α} (h : x ⊆ y) : s ∩ x ⊆ s ∩ y :=\n  inter_subset_inter (subset.refl s) h\n\n/-! ### lattice laws -/\n\nprotected instance lattice {α : Type u_1} [DecidableEq α] : lattice (finset α) :=\n  lattice.mk has_union.union partial_order.le partial_order.lt sorry sorry sorry sorry sorry sorry has_inter.inter sorry\n    sorry sorry\n\n@[simp] theorem sup_eq_union {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : s ⊔ t = s ∪ t :=\n  rfl\n\n@[simp] theorem inf_eq_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : s ⊓ t = s ∩ t :=\n  rfl\n\nprotected instance semilattice_inf_bot {α : Type u_1} [DecidableEq α] : semilattice_inf_bot (finset α) :=\n  semilattice_inf_bot.mk ∅ lattice.le lattice.lt sorry sorry sorry empty_subset lattice.inf sorry sorry sorry\n\nprotected instance semilattice_sup_bot {α : Type u_1} [DecidableEq α] : semilattice_sup_bot (finset α) :=\n  semilattice_sup_bot.mk semilattice_inf_bot.bot semilattice_inf_bot.le semilattice_inf_bot.lt sorry sorry sorry sorry\n    lattice.sup sorry sorry sorry\n\nprotected instance distrib_lattice {α : Type u_1} [DecidableEq α] : distrib_lattice (finset α) :=\n  distrib_lattice.mk lattice.sup lattice.le lattice.lt sorry sorry sorry sorry sorry sorry lattice.inf sorry sorry sorry\n    sorry\n\ntheorem inter_distrib_left {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (u : finset α) : s ∩ (t ∪ u) = s ∩ t ∪ s ∩ u :=\n  inf_sup_left\n\ntheorem inter_distrib_right {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (u : finset α) : (s ∪ t) ∩ u = s ∩ u ∪ t ∩ u :=\n  inf_sup_right\n\ntheorem union_distrib_left {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (u : finset α) : s ∪ t ∩ u = (s ∪ t) ∩ (s ∪ u) :=\n  sup_inf_left\n\ntheorem union_distrib_right {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (u : finset α) : s ∩ t ∪ u = (s ∪ u) ∩ (t ∪ u) :=\n  sup_inf_right\n\ntheorem union_eq_empty_iff {α : Type u_1} [DecidableEq α] (A : finset α) (B : finset α) : A ∪ B = ∅ ↔ A = ∅ ∧ B = ∅ :=\n  sup_eq_bot_iff\n\n/-! ### erase -/\n\n/-- `erase s a` is the set `s - {a}`, that is, the elements of `s` which are\n  not equal to `a`. -/\ndef erase {α : Type u_1} [DecidableEq α] (s : finset α) (a : α) : finset α :=\n  mk (multiset.erase (val s) a) sorry\n\n@[simp] theorem erase_val {α : Type u_1} [DecidableEq α] (s : finset α) (a : α) : val (erase s a) = multiset.erase (val s) a :=\n  rfl\n\n@[simp] theorem mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} : a ∈ erase s b ↔ a ≠ b ∧ a ∈ s :=\n  multiset.mem_erase_iff_of_nodup (nodup s)\n\ntheorem not_mem_erase {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : ¬a ∈ erase s a :=\n  multiset.mem_erase_of_nodup (nodup s)\n\n@[simp] theorem erase_empty {α : Type u_1} [DecidableEq α] (a : α) : erase ∅ a = ∅ :=\n  rfl\n\ntheorem ne_of_mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} : b ∈ erase s a → b ≠ a :=\n  eq.mpr (id (imp_congr_eq (propext mem_erase) (Eq.refl (b ≠ a)))) and.left\n\ntheorem mem_of_mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} : b ∈ erase s a → b ∈ s :=\n  multiset.mem_of_mem_erase\n\ntheorem mem_erase_of_ne_of_mem {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} : a ≠ b → a ∈ s → a ∈ erase s b :=\n  eq.mpr (id (imp_congr_eq (Eq.refl (a ≠ b)) (imp_congr_eq (Eq.refl (a ∈ s)) (propext mem_erase)))) And.intro\n\n/-- An element of `s` that is not an element of `erase s a` must be\n`a`. -/\ntheorem eq_of_mem_of_not_mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} (hs : b ∈ s) (hsa : ¬b ∈ erase s a) : b = a := sorry\n\ntheorem erase_insert {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) : erase (insert a s) a = s := sorry\n\ntheorem insert_erase {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) : insert a (erase s a) = s := sorry\n\ntheorem erase_subset_erase {α : Type u_1} [DecidableEq α] (a : α) {s : finset α} {t : finset α} (h : s ⊆ t) : erase s a ⊆ erase t a :=\n  iff.mp val_le_iff (multiset.erase_le_erase a (iff.mpr val_le_iff h))\n\ntheorem erase_subset {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : erase s a ⊆ s :=\n  multiset.erase_subset a (val s)\n\n@[simp] theorem coe_erase {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : ↑(erase s a) = ↑s \\ singleton a := sorry\n\ntheorem erase_ssubset {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) : erase s a ⊂ s :=\n  trans_rel_left has_ssubset.ssubset (ssubset_insert (not_mem_erase a s)) (insert_erase h)\n\ntheorem erase_eq_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) : erase s a = s :=\n  eq_of_veq (multiset.erase_of_not_mem h)\n\ntheorem subset_insert_iff {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} {t : finset α} : s ⊆ insert a t ↔ erase s a ⊆ t := sorry\n\ntheorem erase_insert_subset {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : erase (insert a s) a ⊆ s :=\n  iff.mp subset_insert_iff (subset.refl (insert a s))\n\ntheorem insert_erase_subset {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : s ⊆ insert a (erase s a) :=\n  iff.mpr subset_insert_iff (subset.refl (erase s a))\n\n/-! ### sdiff -/\n\n/-- `s \\ t` is the set consisting of the elements of `s` that are not in `t`. -/\nprotected instance has_sdiff {α : Type u_1} [DecidableEq α] : has_sdiff (finset α) :=\n  has_sdiff.mk fun (s₁ s₂ : finset α) => mk (val s₁ - val s₂) sorry\n\n@[simp] theorem mem_sdiff {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} : a ∈ s₁ \\ s₂ ↔ a ∈ s₁ ∧ ¬a ∈ s₂ :=\n  multiset.mem_sub_of_nodup (nodup s₁)\n\ntheorem not_mem_sdiff_of_mem_right {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} {t : finset α} (h : a ∈ t) : ¬a ∈ s \\ t := sorry\n\ntheorem sdiff_union_of_subset {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} (h : s₁ ⊆ s₂) : s₂ \\ s₁ ∪ s₁ = s₂ := sorry\n\ntheorem union_sdiff_of_subset {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} (h : s₁ ⊆ s₂) : s₁ ∪ s₂ \\ s₁ = s₂ :=\n  Eq.trans (union_comm s₁ (s₂ \\ s₁)) (sdiff_union_of_subset h)\n\ntheorem inter_sdiff {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (u : finset α) : s ∩ (t \\ u) = s ∩ t \\ u := sorry\n\n@[simp] theorem inter_sdiff_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ ∩ (s₂ \\ s₁) = ∅ := sorry\n\n@[simp] theorem sdiff_inter_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₂ \\ s₁ ∩ s₁ = ∅ :=\n  Eq.trans (inter_comm (s₂ \\ s₁) s₁) (inter_sdiff_self s₁ s₂)\n\n@[simp] theorem sdiff_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) : s₁ \\ s₁ = ∅ := sorry\n\ntheorem sdiff_inter_distrib_right {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (s₃ : finset α) : s₁ \\ (s₂ ∩ s₃) = s₁ \\ s₂ ∪ s₁ \\ s₃ := sorry\n\n@[simp] theorem sdiff_inter_self_left {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ \\ (s₁ ∩ s₂) = s₁ \\ s₂ := sorry\n\n@[simp] theorem sdiff_inter_self_right {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ \\ (s₂ ∩ s₁) = s₁ \\ s₂ := sorry\n\n@[simp] theorem sdiff_empty {α : Type u_1} [DecidableEq α] {s₁ : finset α} : s₁ \\ ∅ = s₁ := sorry\n\ntheorem sdiff_subset_sdiff {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {t₁ : finset α} {t₂ : finset α} (h₁ : t₁ ⊆ t₂) (h₂ : s₂ ⊆ s₁) : t₁ \\ s₁ ⊆ t₂ \\ s₂ := sorry\n\ntheorem sdiff_subset_self {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} : s₁ \\ s₂ ⊆ s₁ := sorry\n\n@[simp] theorem coe_sdiff {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : ↑(s₁ \\ s₂) = ↑s₁ \\ ↑s₂ :=\n  set.ext fun (_x : α) => mem_sdiff\n\n@[simp] theorem union_sdiff_self_eq_union {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s ∪ t \\ s = s ∪ t := sorry\n\n@[simp] theorem sdiff_union_self_eq_union {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s \\ t ∪ t = s ∪ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t ∪ t = s ∪ t)) (union_comm (s \\ t) t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (t ∪ s \\ t = s ∪ t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (t ∪ s = s ∪ t)) (union_comm t s))) (Eq.refl (s ∪ t))))\n\ntheorem union_sdiff_symm {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s ∪ t \\ s = t ∪ s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t \\ s = t ∪ s \\ t)) union_sdiff_self_eq_union))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t = t ∪ s \\ t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t = t ∪ s)) (union_comm s t))) (Eq.refl (t ∪ s))))\n\ntheorem sdiff_union_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : s \\ t ∪ s ∩ t = s := sorry\n\n@[simp] theorem sdiff_idem {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : s \\ t \\ t = s \\ t := sorry\n\ntheorem sdiff_eq_empty_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s \\ t = ∅ ↔ s ⊆ t := sorry\n\n@[simp] theorem empty_sdiff {α : Type u_1} [DecidableEq α] (s : finset α) : ∅ \\ s = ∅ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (∅ \\ s = ∅)) (propext sdiff_eq_empty_iff_subset))) (empty_subset s)\n\ntheorem insert_sdiff_of_not_mem {α : Type u_1} [DecidableEq α] (s : finset α) {t : finset α} {x : α} (h : ¬x ∈ t) : insert x s \\ t = insert x (s \\ t) := sorry\n\ntheorem insert_sdiff_of_mem {α : Type u_1} [DecidableEq α] (s : finset α) {t : finset α} {x : α} (h : x ∈ t) : insert x s \\ t = s \\ t := sorry\n\n@[simp] theorem insert_sdiff_insert {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (x : α) : insert x s \\ insert x t = s \\ insert x t :=\n  insert_sdiff_of_mem s (mem_insert_self x t)\n\ntheorem sdiff_insert_of_not_mem {α : Type u_1} [DecidableEq α] {s : finset α} {x : α} (h : ¬x ∈ s) (t : finset α) : s \\ insert x t = s \\ t := sorry\n\n@[simp] theorem sdiff_subset {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : s \\ t ⊆ s := sorry\n\ntheorem union_sdiff_distrib {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (t : finset α) : (s₁ ∪ s₂) \\ t = s₁ \\ t ∪ s₂ \\ t := sorry\n\ntheorem sdiff_union_distrib {α : Type u_1} [DecidableEq α] (s : finset α) (t₁ : finset α) (t₂ : finset α) : s \\ (t₁ ∪ t₂) = s \\ t₁ ∩ (s \\ t₂) := sorry\n\ntheorem union_sdiff_self {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : (s ∪ t) \\ t = s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl ((s ∪ t) \\ t = s \\ t)) (union_sdiff_distrib s t t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t ∪ t \\ t = s \\ t)) (sdiff_self t)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t ∪ ∅ = s \\ t)) (union_empty (s \\ t)))) (Eq.refl (s \\ t))))\n\ntheorem sdiff_singleton_eq_erase {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : s \\ singleton a = erase s a := sorry\n\ntheorem sdiff_sdiff_self_left {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : s \\ (s \\ t) = s ∩ t := sorry\n\ntheorem inter_eq_inter_of_sdiff_eq_sdiff {α : Type u_1} [DecidableEq α] {s : finset α} {t₁ : finset α} {t₂ : finset α} : s \\ t₁ = s \\ t₂ → s ∩ t₁ = s ∩ t₂ := sorry\n\n/-! ### attach -/\n\n/-- `attach s` takes the elements of `s` and forms a new set of elements of the\n  subtype `{x // x ∈ s}`. -/\ndef attach {α : Type u_1} (s : finset α) : finset (Subtype fun (x : α) => x ∈ s) :=\n  mk (multiset.attach (val s)) sorry\n\ntheorem sizeof_lt_sizeof_of_mem {α : Type u_1} [SizeOf α] {x : α} {s : finset α} (hx : x ∈ s) : sizeof x < sizeof s := sorry\n\n@[simp] theorem attach_val {α : Type u_1} (s : finset α) : val (attach s) = multiset.attach (val s) :=\n  rfl\n\n@[simp] theorem mem_attach {α : Type u_1} (s : finset α) (x : Subtype fun (x : α) => x ∈ s) : x ∈ attach s :=\n  multiset.mem_attach (val s)\n\n@[simp] theorem attach_empty {α : Type u_1} : attach ∅ = ∅ :=\n  rfl\n\n/-! ### piecewise -/\n\n/-- `s.piecewise f g` is the function equal to `f` on the finset `s`, and to `g` on its\ncomplement. -/\ndef piecewise {α : Type u_1} {δ : α → Sort u_2} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] (i : α) : δ i :=\n  ite (i ∈ s) (f i) (g i)\n\n@[simp] theorem piecewise_insert_self {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [DecidableEq α] {j : α} [(i : α) → Decidable (i ∈ insert j s)] : piecewise (insert j s) f g j = f j := sorry\n\n@[simp] theorem piecewise_empty {α : Type u_1} {δ : α → Sort u_4} (f : (i : α) → δ i) (g : (i : α) → δ i) [(i : α) → Decidable (i ∈ ∅)] : piecewise ∅ f g = g := sorry\n\ntheorem piecewise_coe {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [(j : α) → Decidable (j ∈ ↑s)] : set.piecewise (↑s) f g = piecewise s f g := sorry\n\n@[simp] theorem piecewise_eq_of_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] {i : α} (hi : i ∈ s) : piecewise s f g i = f i := sorry\n\n@[simp] theorem piecewise_eq_of_not_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] {i : α} (hi : ¬i ∈ s) : piecewise s f g i = g i := sorry\n\ntheorem piecewise_congr {α : Type u_1} {δ : α → Sort u_4} (s : finset α) [(j : α) → Decidable (j ∈ s)] {f : (i : α) → δ i} {f' : (i : α) → δ i} {g : (i : α) → δ i} {g' : (i : α) → δ i} (hf : ∀ (i : α), i ∈ s → f i = f' i) (hg : ∀ (i : α), ¬i ∈ s → g i = g' i) : piecewise s f g = piecewise s f' g' :=\n  funext fun (i : α) => if_ctx_congr iff.rfl (hf i) (hg i)\n\n@[simp] theorem piecewise_insert_of_ne {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] {i : α} {j : α} [(i : α) → Decidable (i ∈ insert j s)] (h : i ≠ j) : piecewise (insert j s) f g i = piecewise s f g i := sorry\n\ntheorem piecewise_insert {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] (j : α) [(i : α) → Decidable (i ∈ insert j s)] : piecewise (insert j s) f g = function.update (piecewise s f g) j (f j) := sorry\n\ntheorem piecewise_cases {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] {i : α} (p : δ i → Prop) (hf : p (f i)) (hg : p (g i)) : p (piecewise s f g i) := sorry\n\ntheorem piecewise_mem_set_pi {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} {t : set α} {t' : (i : α) → set (δ i)} {f : (i : α) → δ i} {g : (i : α) → δ i} (hf : f ∈ set.pi t t') (hg : g ∈ set.pi t t') : piecewise s f g ∈ set.pi t t' :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (piecewise s f g ∈ set.pi t t')) (Eq.symm (piecewise_coe s f g))))\n    (set.piecewise_mem_pi (↑s) hf hg)\n\ntheorem piecewise_singleton {α : Type u_1} {δ : α → Sort u_4} (f : (i : α) → δ i) (g : (i : α) → δ i) [DecidableEq α] (i : α) : piecewise (singleton i) f g = function.update g i (f i) := sorry\n\ntheorem piecewise_piecewise_of_subset_left {α : Type u_1} {δ : α → Sort u_4} {s : finset α} {t : finset α} [(i : α) → Decidable (i ∈ s)] [(i : α) → Decidable (i ∈ t)] (h : s ⊆ t) (f₁ : (a : α) → δ a) (f₂ : (a : α) → δ a) (g : (a : α) → δ a) : piecewise s (piecewise t f₁ f₂) g = piecewise s f₁ g :=\n  piecewise_congr s (fun (i : α) (hi : i ∈ s) => piecewise_eq_of_mem t f₁ f₂ (h hi)) fun (_x : α) (_x_1 : ¬_x ∈ s) => rfl\n\n@[simp] theorem piecewise_idem_left {α : Type u_1} {δ : α → Sort u_4} (s : finset α) [(j : α) → Decidable (j ∈ s)] (f₁ : (a : α) → δ a) (f₂ : (a : α) → δ a) (g : (a : α) → δ a) : piecewise s (piecewise s f₁ f₂) g = piecewise s f₁ g :=\n  piecewise_piecewise_of_subset_left (subset.refl s) f₁ f₂ g\n\ntheorem piecewise_piecewise_of_subset_right {α : Type u_1} {δ : α → Sort u_4} {s : finset α} {t : finset α} [(i : α) → Decidable (i ∈ s)] [(i : α) → Decidable (i ∈ t)] (h : t ⊆ s) (f : (a : α) → δ a) (g₁ : (a : α) → δ a) (g₂ : (a : α) → δ a) : piecewise s f (piecewise t g₁ g₂) = piecewise s f g₂ :=\n  piecewise_congr s (fun (_x : α) (_x_1 : _x ∈ s) => rfl)\n    fun (i : α) (hi : ¬i ∈ s) => piecewise_eq_of_not_mem t g₁ g₂ (mt h hi)\n\n@[simp] theorem piecewise_idem_right {α : Type u_1} {δ : α → Sort u_4} (s : finset α) [(j : α) → Decidable (j ∈ s)] (f : (a : α) → δ a) (g₁ : (a : α) → δ a) (g₂ : (a : α) → δ a) : piecewise s f (piecewise s g₁ g₂) = piecewise s f g₂ :=\n  piecewise_piecewise_of_subset_right (subset.refl s) f g₁ g₂\n\ntheorem update_eq_piecewise {α : Type u_1} {β : Type u_2} [DecidableEq α] (f : α → β) (i : α) (v : β) : function.update f i v = piecewise (singleton i) (fun (j : α) => v) f :=\n  Eq.symm (piecewise_singleton (fun (i : α) => v) f i)\n\ntheorem update_piecewise {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] (i : α) (v : δ i) : function.update (piecewise s f g) i v = piecewise s (function.update f i v) (function.update g i v) := sorry\n\ntheorem update_piecewise_of_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] {i : α} (hi : i ∈ s) (v : δ i) : function.update (piecewise s f g) i v = piecewise s (function.update f i v) g := sorry\n\ntheorem update_piecewise_of_not_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] {i : α} (hi : ¬i ∈ s) (v : δ i) : function.update (piecewise s f g) i v = piecewise s f (function.update g i v) := sorry\n\ntheorem piecewise_le_of_le_of_le {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i} {h : (i : α) → δ i} (Hf : f ≤ h) (Hg : g ≤ h) : piecewise s f g ≤ h :=\n  fun (x : α) => piecewise_cases s f g (fun (_x : δ x) => _x ≤ h x) (Hf x) (Hg x)\n\ntheorem le_piecewise_of_le_of_le {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i} {h : (i : α) → δ i} (Hf : h ≤ f) (Hg : h ≤ g) : h ≤ piecewise s f g :=\n  fun (x : α) => piecewise_cases s f g (fun (y : δ x) => h x ≤ y) (Hf x) (Hg x)\n\ntheorem piecewise_le_piecewise' {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i} {f' : (i : α) → δ i} {g' : (i : α) → δ i} (Hf : ∀ (x : α), x ∈ s → f x ≤ f' x) (Hg : ∀ (x : α), ¬x ∈ s → g x ≤ g' x) : piecewise s f g ≤ piecewise s f' g' := sorry\n\ntheorem piecewise_le_piecewise {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i} {f' : (i : α) → δ i} {g' : (i : α) → δ i} (Hf : f ≤ f') (Hg : g ≤ g') : piecewise s f g ≤ piecewise s f' g' :=\n  piecewise_le_piecewise' s (fun (x : α) (_x : x ∈ s) => Hf x) fun (x : α) (_x : ¬x ∈ s) => Hg x\n\ntheorem piecewise_mem_Icc_of_mem_of_mem {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {f₁ : (i : α) → δ i} {g : (i : α) → δ i} {g₁ : (i : α) → δ i} (hf : f ∈ set.Icc f₁ g₁) (hg : g ∈ set.Icc f₁ g₁) : piecewise s f g ∈ set.Icc f₁ g₁ :=\n  { left := le_piecewise_of_le_of_le s (and.left hf) (and.left hg),\n    right := piecewise_le_of_le_of_le s (and.right hf) (and.right hg) }\n\ntheorem piecewise_mem_Icc {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i} (h : f ≤ g) : piecewise s f g ∈ set.Icc f g :=\n  piecewise_mem_Icc_of_mem_of_mem s (iff.mpr set.left_mem_Icc h) (iff.mpr set.right_mem_Icc h)\n\ntheorem piecewise_mem_Icc' {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)] {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i} (h : g ≤ f) : piecewise s f g ∈ set.Icc g f :=\n  piecewise_mem_Icc_of_mem_of_mem s (iff.mpr set.right_mem_Icc h) (iff.mpr set.left_mem_Icc h)\n\nprotected instance decidable_dforall_finset {α : Type u_1} {s : finset α} {p : (a : α) → a ∈ s → Prop} [hp : (a : α) → (h : a ∈ s) → Decidable (p a h)] : Decidable (∀ (a : α) (h : a ∈ s), p a h) :=\n  multiset.decidable_dforall_multiset\n\n/-- decidable equality for functions whose domain is bounded by finsets -/\nprotected instance decidable_eq_pi_finset {α : Type u_1} {s : finset α} {β : α → Type u_2} [h : (a : α) → DecidableEq (β a)] : DecidableEq ((a : α) → a ∈ s → β a) :=\n  multiset.decidable_eq_pi_multiset\n\nprotected instance decidable_dexists_finset {α : Type u_1} {s : finset α} {p : (a : α) → a ∈ s → Prop} [hp : (a : α) → (h : a ∈ s) → Decidable (p a h)] : Decidable (∃ (a : α), ∃ (h : a ∈ s), p a h) :=\n  multiset.decidable_dexists_multiset\n\n/-! ### filter -/\n\n/-- `filter p s` is the set of elements of `s` that satisfy `p`. -/\ndef filter {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) : finset α :=\n  mk (multiset.filter p (val s)) sorry\n\n@[simp] theorem filter_val {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) : val (filter p s) = multiset.filter p (val s) :=\n  rfl\n\n@[simp] theorem filter_subset {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) : filter p s ⊆ s :=\n  multiset.filter_subset p (val s)\n\n@[simp] theorem mem_filter {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} {a : α} : a ∈ filter p s ↔ a ∈ s ∧ p a :=\n  multiset.mem_filter\n\ntheorem filter_ssubset {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} : filter p s ⊂ s ↔ ∃ (x : α), ∃ (H : x ∈ s), ¬p x := sorry\n\ntheorem filter_filter {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p] [decidable_pred q] (s : finset α) : filter q (filter p s) = filter (fun (a : α) => p a ∧ q a) s := sorry\n\ntheorem filter_true {α : Type u_1} {s : finset α} [h : decidable_pred fun (_x : α) => True] : filter (fun (_x : α) => True) s = s := sorry\n\n@[simp] theorem filter_false {α : Type u_1} {h : decidable_pred fun (a : α) => False} (s : finset α) : filter (fun (a : α) => False) s = ∅ := sorry\n\n/-- If all elements of a `finset` satisfy the predicate `p`, `s.filter p` is `s`. -/\n@[simp] theorem filter_true_of_mem {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} (h : ∀ (x : α), x ∈ s → p x) : filter p s = s := sorry\n\n/-- If all elements of a `finset` fail to satisfy the predicate `p`, `s.filter p` is `∅`. -/\ntheorem filter_false_of_mem {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} (h : ∀ (x : α), x ∈ s → ¬p x) : filter p s = ∅ := sorry\n\ntheorem filter_congr {α : Type u_1} {p : α → Prop} {q : α → Prop} [decidable_pred p] [decidable_pred q] {s : finset α} (H : ∀ (x : α), x ∈ s → (p x ↔ q x)) : filter p s = filter q s :=\n  eq_of_veq (multiset.filter_congr H)\n\ntheorem filter_empty {α : Type u_1} (p : α → Prop) [decidable_pred p] : filter p ∅ = ∅ :=\n  iff.mp subset_empty (filter_subset p ∅)\n\ntheorem filter_subset_filter {α : Type u_1} (p : α → Prop) [decidable_pred p] {s : finset α} {t : finset α} (h : s ⊆ t) : filter p s ⊆ filter p t :=\n  fun (a : α) (ha : a ∈ filter p s) =>\n    iff.mpr mem_filter { left := h (and.left (iff.mp mem_filter ha)), right := and.right (iff.mp mem_filter ha) }\n\n@[simp] theorem coe_filter {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) : ↑(filter p s) = has_sep.sep (fun (x : α) => p x) ↑s :=\n  set.ext fun (_x : α) => mem_filter\n\ntheorem filter_singleton {α : Type u_1} (p : α → Prop) [decidable_pred p] (a : α) : filter p (singleton a) = ite (p a) (singleton a) ∅ := sorry\n\ntheorem filter_union {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : filter p (s₁ ∪ s₂) = filter p s₁ ∪ filter p s₂ := sorry\n\ntheorem filter_union_right {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p] [decidable_pred q] [DecidableEq α] (s : finset α) : filter p s ∪ filter q s = filter (fun (x : α) => p x ∨ q x) s := sorry\n\ntheorem filter_mem_eq_inter {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} [(i : α) → Decidable (i ∈ t)] : filter (fun (i : α) => i ∈ t) s = s ∩ t := sorry\n\ntheorem filter_inter {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (s : finset α) (t : finset α) : filter p s ∩ t = filter p (s ∩ t) := sorry\n\ntheorem inter_filter {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (s : finset α) (t : finset α) : s ∩ filter p t = filter p (s ∩ t) := sorry\n\ntheorem filter_insert {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (a : α) (s : finset α) : filter p (insert a s) = ite (p a) (insert a (filter p s)) (filter p s) := sorry\n\ntheorem filter_or {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p] [decidable_pred q] [DecidableEq α] [decidable_pred fun (a : α) => p a ∨ q a] (s : finset α) : filter (fun (a : α) => p a ∨ q a) s = filter p s ∪ filter q s := sorry\n\ntheorem filter_and {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p] [decidable_pred q] [DecidableEq α] [decidable_pred fun (a : α) => p a ∧ q a] (s : finset α) : filter (fun (a : α) => p a ∧ q a) s = filter p s ∩ filter q s := sorry\n\ntheorem filter_not {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] [decidable_pred fun (a : α) => ¬p a] (s : finset α) : filter (fun (a : α) => ¬p a) s = s \\ filter p s := sorry\n\ntheorem sdiff_eq_filter {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ \\ s₂ = filter (fun (_x : α) => ¬_x ∈ s₂) s₁ := sorry\n\ntheorem sdiff_eq_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) : s₁ \\ s₂ = s₁ ↔ s₁ ∩ s₂ ⊆ ∅ := sorry\n\ntheorem filter_union_filter_neg_eq {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] [decidable_pred fun (a : α) => ¬p a] (s : finset α) : filter p s ∪ filter (fun (a : α) => ¬p a) s = s := sorry\n\ntheorem filter_inter_filter_neg_eq {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (s : finset α) : filter p s ∩ filter (fun (a : α) => ¬p a) s = ∅ := sorry\n\ntheorem subset_union_elim {α : Type u_1} [DecidableEq α] {s : finset α} {t₁ : set α} {t₂ : set α} (h : ↑s ⊆ t₁ ∪ t₂) : ∃ (s₁ : finset α), ∃ (s₂ : finset α), s₁ ∪ s₂ = s ∧ ↑s₁ ⊆ t₁ ∧ ↑s₂ ⊆ t₂ \\ t₁ := sorry\n\n/- We can simplify an application of filter where the decidability is inferred in \"the wrong way\" -/\n\n@[simp] theorem filter_congr_decidable {α : Type u_1} (s : finset α) (p : α → Prop) (h : decidable_pred p) [decidable_pred p] : filter p s = filter p s := sorry\n\n/-- The following instance allows us to write `{ x ∈ s | p x }` for `finset.filter s p`.\n  Since the former notation requires us to define this for all propositions `p`, and `finset.filter`\n  only works for decidable propositions, the notation `{ x ∈ s | p x }` is only compatible with\n  classical logic because it uses `classical.prop_decidable`.\n  We don't want to redo all lemmas of `finset.filter` for `has_sep.sep`, so we make sure that `simp`\n  unfolds the notation `{ x ∈ s | p x }` to `finset.filter s p`. If `p` happens to be decidable, the\n  simp-lemma `filter_congr_decidable` will make sure that `finset.filter` uses the right instance\n  for decidability.\n-/\nprotected instance has_sep {α : Type u_1} : has_sep α (finset α) :=\n  has_sep.mk fun (p : α → Prop) (x : finset α) => filter p x\n\n@[simp] theorem sep_def {α : Type u_1} (s : finset α) (p : α → Prop) : has_sep.sep (fun (x : α) => p x) s = filter p s :=\n  rfl\n\n/--\n  After filtering out everything that does not equal a given value, at most that value remains.\n\n  This is equivalent to `filter_eq'` with the equality the other way.\n-/\n-- This is not a good simp lemma, as it would prevent `finset.mem_filter` from firing\n\n-- on, e.g. `x ∈ s.filter(eq b)`.\n\ntheorem filter_eq {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) : filter (Eq b) s = ite (b ∈ s) (singleton b) ∅ := sorry\n\n/--\n  After filtering out everything that does not equal a given value, at most that value remains.\n\n  This is equivalent to `filter_eq` with the equality the other way.\n-/\ntheorem filter_eq' {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) : filter (fun (a : β) => a = b) s = ite (b ∈ s) (singleton b) ∅ :=\n  trans (filter_congr fun (_x : β) (_x_1 : _x ∈ s) => { mp := Eq.symm, mpr := Eq.symm }) (filter_eq s b)\n\ntheorem filter_ne {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) : filter (fun (a : β) => b ≠ a) s = erase s b := sorry\n\ntheorem filter_ne' {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) : filter (fun (a : β) => a ≠ b) s = erase s b :=\n  trans (filter_congr fun (_x : β) (_x_1 : _x ∈ s) => { mp := ne.symm, mpr := ne.symm }) (filter_ne s b)\n\n/-! ### range -/\n\n/-- `range n` is the set of natural numbers less than `n`. -/\ndef range (n : ℕ) : finset ℕ :=\n  mk (multiset.range n) (multiset.nodup_range n)\n\n@[simp] theorem range_coe (n : ℕ) : val (range n) = multiset.range n :=\n  rfl\n\n@[simp] theorem mem_range {n : ℕ} {m : ℕ} : m ∈ range n ↔ m < n :=\n  multiset.mem_range\n\n@[simp] theorem range_zero : range 0 = ∅ :=\n  rfl\n\n@[simp] theorem range_one : range 1 = singleton 0 :=\n  rfl\n\ntheorem range_succ {n : ℕ} : range (Nat.succ n) = insert n (range n) :=\n  eq_of_veq (Eq.trans (multiset.range_succ n) (Eq.symm (multiset.ndinsert_of_not_mem multiset.not_mem_range_self)))\n\ntheorem range_add_one {n : ℕ} : range (n + 1) = insert n (range n) :=\n  range_succ\n\n@[simp] theorem not_mem_range_self {n : ℕ} : ¬n ∈ range n :=\n  multiset.not_mem_range_self\n\n@[simp] theorem self_mem_range_succ (n : ℕ) : n ∈ range (n + 1) :=\n  multiset.self_mem_range_succ n\n\n@[simp] theorem range_subset {n : ℕ} {m : ℕ} : range n ⊆ range m ↔ n ≤ m :=\n  multiset.range_subset\n\ntheorem range_mono : monotone range :=\n  fun (_x _x_1 : ℕ) => iff.mpr range_subset\n\ntheorem mem_range_succ_iff {a : ℕ} {b : ℕ} : a ∈ range (Nat.succ b) ↔ a ≤ b :=\n  iff.trans mem_range nat.lt_succ_iff\n\n/- useful rules for calculations with quantifiers -/\n\ntheorem exists_mem_empty_iff {α : Type u_1} (p : α → Prop) : (∃ (x : α), x ∈ ∅ ∧ p x) ↔ False := sorry\n\ntheorem exists_mem_insert {α : Type u_1} [d : DecidableEq α] (a : α) (s : finset α) (p : α → Prop) : (∃ (x : α), x ∈ insert a s ∧ p x) ↔ p a ∨ ∃ (x : α), x ∈ s ∧ p x := sorry\n\ntheorem forall_mem_empty_iff {α : Type u_1} (p : α → Prop) : (∀ (x : α), x ∈ ∅ → p x) ↔ True :=\n  iff_true_intro fun (_x : α) => false.elim\n\ntheorem forall_mem_insert {α : Type u_1} [d : DecidableEq α] (a : α) (s : finset α) (p : α → Prop) : (∀ (x : α), x ∈ insert a s → p x) ↔ p a ∧ ∀ (x : α), x ∈ s → p x := sorry\n\nend finset\n\n\n/-- Equivalence between the set of natural numbers which are `≥ k` and `ℕ`, given by `n → n - k`. -/\ndef not_mem_range_equiv (k : ℕ) : (Subtype fun (n : ℕ) => ¬n ∈ multiset.range k) ≃ ℕ :=\n  equiv.mk (fun (i : Subtype fun (n : ℕ) => ¬n ∈ multiset.range k) => subtype.val i - k)\n    (fun (j : ℕ) => { val := j + k, property := sorry }) sorry sorry\n\n@[simp] theorem coe_not_mem_range_equiv (k : ℕ) : ⇑(not_mem_range_equiv k) = fun (i : Subtype fun (n : ℕ) => ¬n ∈ multiset.range k) => ↑i - k :=\n  rfl\n\n@[simp] theorem coe_not_mem_range_equiv_symm (k : ℕ) : ⇑(equiv.symm (not_mem_range_equiv k)) =\n  fun (j : ℕ) =>\n    { val := j + k,\n      property :=\n        eq.mpr\n          (id\n            (Eq.trans\n              (Eq.trans\n                ((fun (a a_1 : Prop) (e_1 : a = a_1) => congr_arg Not e_1) (j + k ∈ multiset.range k) (j < 0)\n                  (Eq.trans (propext multiset.mem_range) (propext add_lt_iff_neg_right)))\n                (propext not_lt))\n              (propext ((fun {α : Type} (a : α) => iff_true_intro (zero_le a)) j))))\n          trivial } :=\n  rfl\n\nnamespace option\n\n\n/-- Construct an empty or singleton finset from an `option` -/\ndef to_finset {α : Type u_1} (o : Option α) : finset α :=\n  sorry\n\n@[simp] theorem to_finset_none {α : Type u_1} : to_finset none = ∅ :=\n  rfl\n\n@[simp] theorem to_finset_some {α : Type u_1} {a : α} : to_finset (some a) = singleton a :=\n  rfl\n\n@[simp] theorem mem_to_finset {α : Type u_1} {a : α} {o : Option α} : a ∈ to_finset o ↔ a ∈ o := sorry\n\nend option\n\n\n/-! ### erase_dup on list and multiset -/\n\nnamespace multiset\n\n\n/-- `to_finset s` removes duplicates from the multiset `s` to produce a finset. -/\ndef to_finset {α : Type u_1} [DecidableEq α] (s : multiset α) : finset α :=\n  finset.mk (erase_dup s) sorry\n\n@[simp] theorem to_finset_val {α : Type u_1} [DecidableEq α] (s : multiset α) : finset.val (to_finset s) = erase_dup s :=\n  rfl\n\ntheorem to_finset_eq {α : Type u_1} [DecidableEq α] {s : multiset α} (n : nodup s) : finset.mk s n = to_finset s :=\n  iff.mp finset.val_inj (Eq.symm (iff.mpr erase_dup_eq_self n))\n\n@[simp] theorem mem_to_finset {α : Type u_1} [DecidableEq α] {a : α} {s : multiset α} : a ∈ to_finset s ↔ a ∈ s :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_zero {α : Type u_1} [DecidableEq α] : to_finset 0 = ∅ :=\n  rfl\n\n@[simp] theorem to_finset_cons {α : Type u_1} [DecidableEq α] (a : α) (s : multiset α) : to_finset (a ::ₘ s) = insert a (to_finset s) :=\n  finset.eq_of_veq erase_dup_cons\n\n@[simp] theorem to_finset_add {α : Type u_1} [DecidableEq α] (s : multiset α) (t : multiset α) : to_finset (s + t) = to_finset s ∪ to_finset t := sorry\n\n@[simp] theorem to_finset_nsmul {α : Type u_1} [DecidableEq α] (s : multiset α) (n : ℕ) (hn : n ≠ 0) : to_finset (n •ℕ s) = to_finset s := sorry\n\n@[simp] theorem to_finset_inter {α : Type u_1} [DecidableEq α] (s : multiset α) (t : multiset α) : to_finset (s ∩ t) = to_finset s ∩ to_finset t := sorry\n\n@[simp] theorem to_finset_union {α : Type u_1} [DecidableEq α] (s : multiset α) (t : multiset α) : to_finset (s ∪ t) = to_finset s ∪ to_finset t := sorry\n\ntheorem to_finset_eq_empty {α : Type u_1} [DecidableEq α] {m : multiset α} : to_finset m = ∅ ↔ m = 0 :=\n  iff.trans (iff.symm finset.val_inj) erase_dup_eq_zero\n\n@[simp] theorem to_finset_subset {α : Type u_1} [DecidableEq α] (m1 : multiset α) (m2 : multiset α) : to_finset m1 ⊆ to_finset m2 ↔ m1 ⊆ m2 := sorry\n\nend multiset\n\n\nnamespace finset\n\n\n@[simp] theorem val_to_finset {α : Type u_1} [DecidableEq α] (s : finset α) : multiset.to_finset (val s) = s := sorry\n\nend finset\n\n\nnamespace list\n\n\n/-- `to_finset l` removes duplicates from the list `l` to produce a finset. -/\ndef to_finset {α : Type u_1} [DecidableEq α] (l : List α) : finset α :=\n  multiset.to_finset ↑l\n\n@[simp] theorem to_finset_val {α : Type u_1} [DecidableEq α] (l : List α) : finset.val (to_finset l) = ↑(erase_dup l) :=\n  rfl\n\ntheorem to_finset_eq {α : Type u_1} [DecidableEq α] {l : List α} (n : nodup l) : finset.mk (↑l) n = to_finset l :=\n  multiset.to_finset_eq n\n\n@[simp] theorem mem_to_finset {α : Type u_1} [DecidableEq α] {a : α} {l : List α} : a ∈ to_finset l ↔ a ∈ l :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_nil {α : Type u_1} [DecidableEq α] : to_finset [] = ∅ :=\n  rfl\n\n@[simp] theorem to_finset_cons {α : Type u_1} [DecidableEq α] {a : α} {l : List α} : to_finset (a :: l) = insert a (to_finset l) := sorry\n\ntheorem to_finset_surj_on {α : Type u_1} [DecidableEq α] : set.surj_on to_finset (set_of fun (l : List α) => nodup l) set.univ := sorry\n\ntheorem to_finset_surjective {α : Type u_1} [DecidableEq α] : function.surjective to_finset := sorry\n\nend list\n\n\nnamespace finset\n\n\n/-! ### map -/\n\n/-- When `f` is an embedding of `α` in `β` and `s` is a finset in `α`, then `s.map f` is the image\nfinset in `β`. The embedding condition guarantees that there are no duplicates in the image. -/\ndef map {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) : finset β :=\n  mk (multiset.map (⇑f) (val s)) sorry\n\n@[simp] theorem map_val {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) : val (map f s) = multiset.map (⇑f) (val s) :=\n  rfl\n\n@[simp] theorem map_empty {α : Type u_1} {β : Type u_2} (f : α ↪ β) : map f ∅ = ∅ :=\n  rfl\n\n@[simp] theorem mem_map {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} {b : β} : b ∈ map f s ↔ ∃ (a : α), ∃ (H : a ∈ s), coe_fn f a = b := sorry\n\ntheorem mem_map' {α : Type u_1} {β : Type u_2} (f : α ↪ β) {a : α} {s : finset α} : coe_fn f a ∈ map f s ↔ a ∈ s :=\n  multiset.mem_map_of_injective (function.embedding.inj' f)\n\ntheorem mem_map_of_mem {α : Type u_1} {β : Type u_2} (f : α ↪ β) {a : α} {s : finset α} : a ∈ s → coe_fn f a ∈ map f s :=\n  iff.mpr (mem_map' f)\n\n@[simp] theorem coe_map {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) : ↑(map f s) = ⇑f '' ↑s :=\n  set.ext fun (x : β) => iff.trans mem_map (iff.symm set.mem_image_iff_bex)\n\ntheorem coe_map_subset_range {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) : ↑(map f s) ⊆ set.range ⇑f :=\n  trans_rel_right has_subset.subset (coe_map f s) (set.image_subset_range ⇑f ↑s)\n\ntheorem map_to_finset {α : Type u_1} {β : Type u_2} {f : α ↪ β} [DecidableEq α] [DecidableEq β] {s : multiset α} : map f (multiset.to_finset s) = multiset.to_finset (multiset.map (⇑f) s) := sorry\n\n@[simp] theorem map_refl {α : Type u_1} {s : finset α} : map (function.embedding.refl α) s = s := sorry\n\ntheorem map_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α ↪ β} {s : finset α} {g : β ↪ γ} : map g (map f s) = map (function.embedding.trans f g) s := sorry\n\ntheorem map_subset_map {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s₁ : finset α} {s₂ : finset α} : map f s₁ ⊆ map f s₂ ↔ s₁ ⊆ s₂ := sorry\n\ntheorem map_inj {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s₁ : finset α} {s₂ : finset α} : map f s₁ = map f s₂ ↔ s₁ = s₂ := sorry\n\n/-- Associate to an embedding `f` from `α` to `β` the embedding that maps a finset to its image\nunder `f`. -/\ndef map_embedding {α : Type u_1} {β : Type u_2} (f : α ↪ β) : finset α ↪ finset β :=\n  function.embedding.mk (map f) sorry\n\n@[simp] theorem map_embedding_apply {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} : coe_fn (map_embedding f) s = map f s :=\n  rfl\n\ntheorem map_filter {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} {p : β → Prop} [decidable_pred p] : filter p (map f s) = map f (filter (p ∘ ⇑f) s) := sorry\n\ntheorem map_union {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] {f : α ↪ β} (s₁ : finset α) (s₂ : finset α) : map f (s₁ ∪ s₂) = map f s₁ ∪ map f s₂ := sorry\n\ntheorem map_inter {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] {f : α ↪ β} (s₁ : finset α) (s₂ : finset α) : map f (s₁ ∩ s₂) = map f s₁ ∩ map f s₂ := sorry\n\n@[simp] theorem map_singleton {α : Type u_1} {β : Type u_2} (f : α ↪ β) (a : α) : map f (singleton a) = singleton (coe_fn f a) := sorry\n\n@[simp] theorem map_insert {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] (f : α ↪ β) (a : α) (s : finset α) : map f (insert a s) = insert (coe_fn f a) (map f s) := sorry\n\n@[simp] theorem map_eq_empty {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} : map f s = ∅ ↔ s = ∅ := sorry\n\ntheorem attach_map_val {α : Type u_1} {s : finset α} : map (function.embedding.subtype fun (x : α) => x ∈ s) (attach s) = s := sorry\n\ntheorem nonempty.map {α : Type u_1} {β : Type u_2} {s : finset α} (h : finset.nonempty s) (f : α ↪ β) : finset.nonempty (map f s) := sorry\n\ntheorem range_add_one' (n : ℕ) : range (n + 1) = insert 0 (map (function.embedding.mk (fun (i : ℕ) => i + 1) fun (i j : ℕ) => nat.succ.inj) (range n)) := sorry\n\n/-! ### image -/\n\n/-- `image f s` is the forward image of `s` under `f`. -/\ndef image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (s : finset α) : finset β :=\n  multiset.to_finset (multiset.map f (val s))\n\n@[simp] theorem image_val {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (s : finset α) : val (image f s) = multiset.erase_dup (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem image_empty {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) : image f ∅ = ∅ :=\n  rfl\n\n@[simp] theorem mem_image {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} {b : β} : b ∈ image f s ↔ ∃ (a : α), ∃ (H : a ∈ s), f a = b := sorry\n\ntheorem mem_image_of_mem {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) {a : α} {s : finset α} (h : a ∈ s) : f a ∈ image f s :=\n  iff.mpr mem_image (Exists.intro a (Exists.intro h rfl))\n\ntheorem filter_mem_image_eq_image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (s : finset α) (t : finset β) (h : ∀ (x : α), x ∈ s → f x ∈ t) : filter (fun (y : β) => y ∈ image f s) t = image f s := sorry\n\ntheorem fiber_nonempty_iff_mem_image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (s : finset α) (y : β) : finset.nonempty (filter (fun (x : α) => f x = y) s) ↔ y ∈ image f s := sorry\n\n@[simp] theorem coe_image {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {f : α → β} : ↑(image f s) = f '' ↑s :=\n  set.ext fun (_x : β) => iff.trans mem_image (iff.symm set.mem_image_iff_bex)\n\ntheorem nonempty.image {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} (h : finset.nonempty s) (f : α → β) : finset.nonempty (image f s) := sorry\n\ntheorem image_to_finset {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} [DecidableEq α] {s : multiset α} : image f (multiset.to_finset s) = multiset.to_finset (multiset.map f s) := sorry\n\ntheorem image_val_of_inj_on {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} (H : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y → x = y) : val (image f s) = multiset.map f (val s) :=\n  iff.mpr multiset.erase_dup_eq_self (multiset.nodup_map_on H (nodup s))\n\n@[simp] theorem image_id {α : Type u_1} {s : finset α} [DecidableEq α] : image id s = s := sorry\n\ntheorem image_image {α : Type u_1} {β : Type u_2} {γ : Type u_3} [DecidableEq β] {f : α → β} {s : finset α} [DecidableEq γ] {g : β → γ} : image g (image f s) = image (g ∘ f) s := sorry\n\ntheorem image_subset_image {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s₁ : finset α} {s₂ : finset α} (h : s₁ ⊆ s₂) : image f s₁ ⊆ image f s₂ := sorry\n\ntheorem image_subset_iff {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {t : finset β} {f : α → β} : image f s ⊆ t ↔ ∀ (x : α), x ∈ s → f x ∈ t := sorry\n\ntheorem image_mono {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) : monotone (image f) :=\n  fun (_x _x_1 : finset α) => image_subset_image\n\ntheorem coe_image_subset_range {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} : ↑(image f s) ⊆ set.range f :=\n  trans_rel_right has_subset.subset coe_image (set.image_subset_range f ↑s)\n\ntheorem image_filter {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} {p : β → Prop} [decidable_pred p] : filter p (image f s) = image f (filter (p ∘ f) s) := sorry\n\ntheorem image_union {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α] {f : α → β} (s₁ : finset α) (s₂ : finset α) : image f (s₁ ∪ s₂) = image f s₁ ∪ image f s₂ := sorry\n\ntheorem image_inter {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) (hf : ∀ (x y : α), f x = f y → x = y) : image f (s₁ ∩ s₂) = image f s₁ ∩ image f s₂ := sorry\n\n@[simp] theorem image_singleton {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (a : α) : image f (singleton a) = singleton (f a) := sorry\n\n@[simp] theorem image_insert {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α] (f : α → β) (a : α) (s : finset α) : image f (insert a s) = insert (f a) (image f s) := sorry\n\n@[simp] theorem image_eq_empty {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} : image f s = ∅ ↔ s = ∅ := sorry\n\ntheorem attach_image_val {α : Type u_1} [DecidableEq α] {s : finset α} : image subtype.val (attach s) = s := sorry\n\n@[simp] theorem attach_insert {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} : attach (insert a s) =\n  insert { val := a, property := mem_insert_self a s }\n    (image\n      (fun (x : Subtype fun (x : α) => x ∈ s) =>\n        { val := subtype.val x, property := mem_insert_of_mem (subtype.property x) })\n      (attach s)) := sorry\n\ntheorem map_eq_image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α ↪ β) (s : finset α) : map f s = image (⇑f) s :=\n  eq_of_veq (Eq.symm (iff.mpr multiset.erase_dup_eq_self (nodup (map f s))))\n\ntheorem image_const {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} (h : finset.nonempty s) (b : β) : image (fun (a : α) => b) s = singleton b := sorry\n\n/--\nBecause `finset.image` requires a `decidable_eq` instances for the target type,\nwe can only construct a `functor finset` when working classically.\n-/\nprotected instance functor [(P : Prop) → Decidable P] : Functor finset :=\n  { map := fun (α β : Type u_1) (f : α → β) (s : finset α) => image f s,\n    mapConst := fun (α β : Type u_1) => (fun (f : β → α) (s : finset β) => image f s) ∘ function.const β }\n\nprotected instance is_lawful_functor [(P : Prop) → Decidable P] : is_lawful_functor finset :=\n  is_lawful_functor.mk (fun (α : Type u_1) (x : finset α) => image_id)\n    fun (α β γ : Type u_1) (f : α → β) (g : β → γ) (s : finset α) => Eq.symm image_image\n\n/-- Given a finset `s` and a predicate `p`, `s.subtype p` is the finset of `subtype p` whose\nelements belong to `s`.  -/\nprotected def subtype {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) : finset (Subtype p) :=\n  map\n    (function.embedding.mk\n      (fun (x : Subtype fun (x : α) => x ∈ filter p s) => { val := subtype.val x, property := sorry }) sorry)\n    (attach (filter p s))\n\n@[simp] theorem mem_subtype {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} {a : Subtype p} : a ∈ finset.subtype p s ↔ ↑a ∈ s := sorry\n\ntheorem subtype_eq_empty {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} : finset.subtype p s = ∅ ↔ ∀ (x : α), p x → ¬x ∈ s := sorry\n\n/-- `s.subtype p` converts back to `s.filter p` with\n`embedding.subtype`. -/\n@[simp] theorem subtype_map {α : Type u_1} {s : finset α} (p : α → Prop) [decidable_pred p] : map (function.embedding.subtype p) (finset.subtype p s) = filter p s := sorry\n\n/-- If all elements of a `finset` satisfy the predicate `p`,\n`s.subtype p` converts back to `s` with `embedding.subtype`. -/\ntheorem subtype_map_of_mem {α : Type u_1} {s : finset α} {p : α → Prop} [decidable_pred p] (h : ∀ (x : α), x ∈ s → p x) : map (function.embedding.subtype p) (finset.subtype p s) = s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (map (function.embedding.subtype p) (finset.subtype p s) = s)) (subtype_map p)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (filter p s = s)) (filter_true_of_mem h))) (Eq.refl s))\n\n/-- If a `finset` of a subtype is converted to the main type with\n`embedding.subtype`, all elements of the result have the property of\nthe subtype. -/\ntheorem property_of_mem_map_subtype {α : Type u_1} {p : α → Prop} (s : finset (Subtype fun (x : α) => p x)) {a : α} (h : a ∈ map (function.embedding.subtype fun (x : α) => p x) s) : p a := sorry\n\n/-- If a `finset` of a subtype is converted to the main type with\n`embedding.subtype`, the result does not contain any value that does\nnot satisfy the property of the subtype. -/\ntheorem not_mem_map_subtype_of_not_property {α : Type u_1} {p : α → Prop} (s : finset (Subtype fun (x : α) => p x)) {a : α} (h : ¬p a) : ¬a ∈ map (function.embedding.subtype fun (x : α) => p x) s :=\n  mt (property_of_mem_map_subtype s) h\n\n/-- If a `finset` of a subtype is converted to the main type with\n`embedding.subtype`, the result is a subset of the set giving the\nsubtype. -/\ntheorem map_subtype_subset {α : Type u_1} {t : set α} (s : finset ↥t) : ↑(map (function.embedding.subtype fun (x : α) => x ∈ t) s) ⊆ t := sorry\n\ntheorem subset_image_iff {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset β} {t : set α} : ↑s ⊆ f '' t ↔ ∃ (s' : finset α), ↑s' ⊆ t ∧ image f s' = s := sorry\n\nend finset\n\n\ntheorem multiset.to_finset_map {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] (f : α → β) (m : multiset α) : multiset.to_finset (multiset.map f m) = finset.image f (multiset.to_finset m) :=\n  iff.mp finset.val_inj (Eq.symm (multiset.erase_dup_map_erase_dup_eq f m))\n\nnamespace finset\n\n\n/-! ### card -/\n\n/-- `card s` is the cardinality (number of elements) of `s`. -/\ndef card {α : Type u_1} (s : finset α) : ℕ :=\n  coe_fn multiset.card (val s)\n\ntheorem card_def {α : Type u_1} (s : finset α) : card s = coe_fn multiset.card (val s) :=\n  rfl\n\n@[simp] theorem card_mk {α : Type u_1} {m : multiset α} {nodup : multiset.nodup m} : card (mk m nodup) = coe_fn multiset.card m :=\n  rfl\n\n@[simp] theorem card_empty {α : Type u_1} : card ∅ = 0 :=\n  rfl\n\n@[simp] theorem card_eq_zero {α : Type u_1} {s : finset α} : card s = 0 ↔ s = ∅ :=\n  iff.trans multiset.card_eq_zero val_eq_zero\n\ntheorem card_pos {α : Type u_1} {s : finset α} : 0 < card s ↔ finset.nonempty s :=\n  iff.trans pos_iff_ne_zero (iff.trans (not_congr card_eq_zero) (iff.symm nonempty_iff_ne_empty))\n\ntheorem card_ne_zero_of_mem {α : Type u_1} {s : finset α} {a : α} (h : a ∈ s) : card s ≠ 0 :=\n  iff.mpr (not_congr card_eq_zero) (ne_empty_of_mem h)\n\ntheorem card_eq_one {α : Type u_1} {s : finset α} : card s = 1 ↔ ∃ (a : α), s = singleton a := sorry\n\n@[simp] theorem card_insert_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) : card (insert a s) = card s + 1 := sorry\n\ntheorem card_insert_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) : card (insert a s) = card s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (card (insert a s) = card s)) (insert_eq_of_mem h))) (Eq.refl (card s))\n\ntheorem card_insert_le {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : card (insert a s) ≤ card s + 1 := sorry\n\n@[simp] theorem card_singleton {α : Type u_1} (a : α) : card (singleton a) = 1 :=\n  multiset.card_singleton a\n\ntheorem card_singleton_inter {α : Type u_1} [DecidableEq α] {x : α} {s : finset α} : card (singleton x ∩ s) ≤ 1 := sorry\n\ntheorem card_erase_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} : a ∈ s → card (erase s a) = Nat.pred (card s) :=\n  multiset.card_erase_of_mem\n\ntheorem card_erase_lt_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} : a ∈ s → card (erase s a) < card s :=\n  multiset.card_erase_lt_of_mem\n\ntheorem card_erase_le {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} : card (erase s a) ≤ card s :=\n  multiset.card_erase_le\n\ntheorem pred_card_le_card_erase {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} : card s - 1 ≤ card (erase s a) := sorry\n\n@[simp] theorem card_range (n : ℕ) : card (range n) = n :=\n  multiset.card_range n\n\n@[simp] theorem card_attach {α : Type u_1} {s : finset α} : card (attach s) = card s :=\n  multiset.card_attach\n\nend finset\n\n\ntheorem multiset.to_finset_card_le {α : Type u_1} [DecidableEq α] (m : multiset α) : finset.card (multiset.to_finset m) ≤ coe_fn multiset.card m :=\n  multiset.card_le_of_le (multiset.erase_dup_le m)\n\ntheorem list.to_finset_card_le {α : Type u_1} [DecidableEq α] (l : List α) : finset.card (list.to_finset l) ≤ list.length l :=\n  multiset.to_finset_card_le (quotient.mk l)\n\nnamespace finset\n\n\ntheorem card_image_le {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} : card (image f s) ≤ card s := sorry\n\ntheorem card_image_of_inj_on {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} (H : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y → x = y) : card (image f s) = card s := sorry\n\ntheorem card_image_of_injective {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} (s : finset α) (H : function.injective f) : card (image f s) = card s :=\n  card_image_of_inj_on fun (x : α) (_x : x ∈ s) (y : α) (_x : y ∈ s) (h : f x = f y) => H h\n\ntheorem fiber_card_ne_zero_iff_mem_image {α : Type u_1} {β : Type u_2} (s : finset α) (f : α → β) [DecidableEq β] (y : β) : card (filter (fun (x : α) => f x = y) s) ≠ 0 ↔ y ∈ image f s := sorry\n\n@[simp] theorem card_map {α : Type u_1} {β : Type u_2} (f : α ↪ β) {s : finset α} : card (map f s) = card s :=\n  multiset.card_map (⇑f) (val s)\n\n@[simp] theorem card_subtype {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) : card (finset.subtype p s) = card (filter p s) := sorry\n\ntheorem card_eq_of_bijective {α : Type u_1} {s : finset α} {n : ℕ} (f : (i : ℕ) → i < n → α) (hf : ∀ (a : α), a ∈ s → ∃ (i : ℕ), ∃ (h : i < n), f i h = a) (hf' : ∀ (i : ℕ) (h : i < n), f i h ∈ s) (f_inj : ∀ (i j : ℕ) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : card s = n := sorry\n\ntheorem card_eq_succ {α : Type u_1} [DecidableEq α] {s : finset α} {n : ℕ} : card s = n + 1 ↔ ∃ (a : α), ∃ (t : finset α), ¬a ∈ t ∧ insert a t = s ∧ card t = n := sorry\n\ntheorem card_le_of_subset {α : Type u_1} {s : finset α} {t : finset α} : s ⊆ t → card s ≤ card t :=\n  multiset.card_le_of_le ∘ iff.mpr val_le_iff\n\ntheorem eq_of_subset_of_card_le {α : Type u_1} {s : finset α} {t : finset α} (h : s ⊆ t) (h₂ : card t ≤ card s) : s = t :=\n  eq_of_veq (multiset.eq_of_le_of_card_le (iff.mpr val_le_iff h) h₂)\n\ntheorem card_lt_card {α : Type u_1} {s : finset α} {t : finset α} (h : s ⊂ t) : card s < card t :=\n  multiset.card_lt_of_lt (iff.mpr val_lt_iff h)\n\ntheorem card_le_card_of_inj_on {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} (f : α → β) (hf : ∀ (a : α), a ∈ s → f a ∈ t) (f_inj : ∀ (a₁ : α), a₁ ∈ s → ∀ (a₂ : α), a₂ ∈ s → f a₁ = f a₂ → a₁ = a₂) : card s ≤ card t := sorry\n\n/--\nIf there are more pigeons than pigeonholes, then there are two pigeons\nin the same pigeonhole.\n-/\ntheorem exists_ne_map_eq_of_card_lt_of_maps_to {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} (hc : card t < card s) {f : α → β} (hf : ∀ (a : α), a ∈ s → f a ∈ t) : ∃ (x : α), ∃ (H : x ∈ s), ∃ (y : α), ∃ (H : y ∈ s), x ≠ y ∧ f x = f y := sorry\n\ntheorem card_le_of_inj_on {α : Type u_1} {n : ℕ} {s : finset α} (f : ℕ → α) (hf : ∀ (i : ℕ), i < n → f i ∈ s) (f_inj : ∀ (i j : ℕ), i < n → j < n → f i = f j → i = j) : n ≤ card s := sorry\n\n/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to\ndefine an object on `s`. Then one can inductively define an object on all finsets, starting from\nthe empty set and iterating. This can be used either to define data, or to prove properties. -/\ndef strong_induction_on {α : Type u_1} {p : finset α → Sort u_2} (s : finset α) : ((s : finset α) → ((t : finset α) → t ⊂ s → p t) → p s) → p s :=\n  sorry\n\ntheorem case_strong_induction_on {α : Type u_1} [DecidableEq α] {p : finset α → Prop} (s : finset α) (h₀ : p ∅) (h₁ : ∀ (a : α) (s : finset α), ¬a ∈ s → (∀ (t : finset α), t ⊆ s → p t) → p (insert a s)) : p s := sorry\n\ntheorem card_congr {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} (f : (a : α) → a ∈ s → β) (h₁ : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t) (h₂ : ∀ (a b : α) (ha : a ∈ s) (hb : b ∈ s), f a ha = f b hb → a = b) (h₃ : ∀ (b : β), b ∈ t → ∃ (a : α), ∃ (ha : a ∈ s), f a ha = b) : card s = card t := sorry\n\ntheorem card_union_add_card_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : card (s ∪ t) + card (s ∩ t) = card s + card t := sorry\n\ntheorem card_union_le {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : card (s ∪ t) ≤ card s + card t :=\n  card_union_add_card_inter s t ▸ nat.le_add_right (card (s ∪ t)) (card (s ∩ t))\n\ntheorem card_union_eq {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} (h : disjoint s t) : card (s ∪ t) = card s + card t := sorry\n\ntheorem surj_on_of_inj_on_of_card_le {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} (f : (a : α) → a ∈ s → β) (hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t) (hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : card t ≤ card s) (b : β) (H : b ∈ t) : ∃ (a : α), ∃ (ha : a ∈ s), b = f a ha := sorry\n\ntheorem inj_on_of_surj_on_of_card_le {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} (f : (a : α) → a ∈ s → β) (hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t) (hsurj : ∀ (b : β), b ∈ t → ∃ (a : α), ∃ (ha : a ∈ s), b = f a ha) (hst : card s ≤ card t) {a₁ : α} {a₂ : α} (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s) (ha₁a₂ : f a₁ ha₁ = f a₂ ha₂) : a₁ = a₂ := sorry\n\n/-!\n### bUnion\n\nThis section is about the bounded union of an indexed family `t : α → finset β` of finite sets\nover a finite set `s : finset α`.\n-/\n\n/-- `bUnion s t` is the union of `t x` over `x ∈ s`.\n(This was formerly `bind` due to the monad structure on types with `decidable_eq`.) -/\nprotected def bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] (s : finset α) (t : α → finset β) : finset β :=\n  multiset.to_finset (multiset.bind (val s) fun (a : α) => val (t a))\n\n@[simp] theorem bUnion_val {α : Type u_1} {β : Type u_2} [DecidableEq β] (s : finset α) (t : α → finset β) : val (finset.bUnion s t) = multiset.erase_dup (multiset.bind (val s) fun (a : α) => val (t a)) :=\n  rfl\n\n@[simp] theorem bUnion_empty {α : Type u_1} {β : Type u_2} [DecidableEq β] {t : α → finset β} : finset.bUnion ∅ t = ∅ :=\n  rfl\n\n@[simp] theorem mem_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {t : α → finset β} {b : β} : b ∈ finset.bUnion s t ↔ ∃ (a : α), ∃ (H : a ∈ s), b ∈ t a := sorry\n\n@[simp] theorem bUnion_insert {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {t : α → finset β} [DecidableEq α] {a : α} : finset.bUnion (insert a s) t = t a ∪ finset.bUnion s t := sorry\n\n-- ext $ λ x, by simp [or_and_distrib_right, exists_or_distrib]\n\n@[simp] theorem singleton_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] {t : α → finset β} {a : α} : finset.bUnion (singleton a) t = t a := sorry\n\ntheorem bUnion_inter {α : Type u_1} {β : Type u_2} [DecidableEq β] (s : finset α) (f : α → finset β) (t : finset β) : finset.bUnion s f ∩ t = finset.bUnion s fun (x : α) => f x ∩ t := sorry\n\ntheorem inter_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] (t : finset β) (s : finset α) (f : α → finset β) : t ∩ finset.bUnion s f = finset.bUnion s fun (x : α) => t ∩ f x := sorry\n\ntheorem image_bUnion {α : Type u_1} {β : Type u_2} {γ : Type u_3} [DecidableEq β] [DecidableEq γ] {f : α → β} {s : finset α} {t : β → finset γ} : finset.bUnion (image f s) t = finset.bUnion s fun (a : α) => t (f a) := sorry\n\ntheorem bUnion_image {α : Type u_1} {β : Type u_2} {γ : Type u_3} [DecidableEq β] [DecidableEq γ] {s : finset α} {t : α → finset β} {f : β → γ} : image f (finset.bUnion s t) = finset.bUnion s fun (a : α) => image f (t a) := sorry\n\ntheorem bind_to_finset {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α] (s : multiset α) (t : α → multiset β) : multiset.to_finset (multiset.bind s t) = finset.bUnion (multiset.to_finset s) fun (a : α) => multiset.to_finset (t a) := sorry\n\ntheorem bUnion_mono {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {t₁ : α → finset β} {t₂ : α → finset β} (h : ∀ (a : α), a ∈ s → t₁ a ⊆ t₂ a) : finset.bUnion s t₁ ⊆ finset.bUnion s t₂ := sorry\n\ntheorem bUnion_subset_bUnion_of_subset_left {β : Type u_2} [DecidableEq β] {α : Type u_1} {s₁ : finset α} {s₂ : finset α} (t : α → finset β) (h : s₁ ⊆ s₂) : finset.bUnion s₁ t ⊆ finset.bUnion s₂ t := sorry\n\ntheorem bUnion_singleton {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {f : α → β} : (finset.bUnion s fun (a : α) => singleton (f a)) = image f s := sorry\n\n@[simp] theorem bUnion_singleton_eq_self {α : Type u_1} {s : finset α} [DecidableEq α] : finset.bUnion s singleton = s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (finset.bUnion s singleton = s)) bUnion_singleton)) image_id\n\ntheorem bUnion_filter_eq_of_maps_to {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α] {s : finset α} {t : finset β} {f : α → β} (h : ∀ (x : α), x ∈ s → f x ∈ t) : (finset.bUnion t fun (a : β) => filter (fun (c : α) => f c = a) s) = s := sorry\n\ntheorem image_bUnion_filter_eq {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α] (s : finset β) (g : β → α) : (finset.bUnion (image g s) fun (a : α) => filter (fun (c : β) => g c = a) s) = s :=\n  bUnion_filter_eq_of_maps_to fun (x : β) => mem_image_of_mem g\n\n/-! ### prod -/\n\n/-- `product s t` is the set of pairs `(a, b)` such that `a ∈ s` and `b ∈ t`. -/\nprotected def product {α : Type u_1} {β : Type u_2} (s : finset α) (t : finset β) : finset (α × β) :=\n  mk (multiset.product (val s) (val t)) sorry\n\n@[simp] theorem product_val {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} : val (finset.product s t) = multiset.product (val s) (val t) :=\n  rfl\n\n@[simp] theorem mem_product {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} {p : α × β} : p ∈ finset.product s t ↔ prod.fst p ∈ s ∧ prod.snd p ∈ t :=\n  multiset.mem_product\n\ntheorem subset_product {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] {s : finset (α × β)} : s ⊆ finset.product (image prod.fst s) (image prod.snd s) :=\n  fun (p : α × β) (hp : p ∈ s) =>\n    iff.mpr mem_product { left := mem_image_of_mem prod.fst hp, right := mem_image_of_mem prod.snd hp }\n\ntheorem product_eq_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] (s : finset α) (t : finset β) : finset.product s t = finset.bUnion s fun (a : α) => image (fun (b : β) => (a, b)) t := sorry\n\n@[simp] theorem card_product {α : Type u_1} {β : Type u_2} (s : finset α) (t : finset β) : card (finset.product s t) = card s * card t :=\n  multiset.card_product (val s) (val t)\n\ntheorem filter_product {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} (p : α → Prop) (q : β → Prop) [decidable_pred p] [decidable_pred q] : filter (fun (x : α × β) => p (prod.fst x) ∧ q (prod.snd x)) (finset.product s t) =\n  finset.product (filter p s) (filter q t) := sorry\n\ntheorem filter_product_card {α : Type u_1} {β : Type u_2} (s : finset α) (t : finset β) (p : α → Prop) (q : β → Prop) [decidable_pred p] [decidable_pred q] : card (filter (fun (x : α × β) => p (prod.fst x) ↔ q (prod.snd x)) (finset.product s t)) =\n  card (filter p s) * card (filter q t) + card (filter (Not ∘ p) s) * card (filter (Not ∘ q) t) := sorry\n\n/-! ### sigma -/\n\n/-- `sigma s t` is the set of dependent pairs `⟨a, b⟩` such that `a ∈ s` and `b ∈ t a`. -/\nprotected def sigma {α : Type u_1} {σ : α → Type u_4} (s : finset α) (t : (a : α) → finset (σ a)) : finset (sigma fun (a : α) => σ a) :=\n  mk (multiset.sigma (val s) fun (a : α) => val (t a)) sorry\n\n@[simp] theorem mem_sigma {α : Type u_1} {σ : α → Type u_4} {s : finset α} {t : (a : α) → finset (σ a)} {p : sigma σ} : p ∈ finset.sigma s t ↔ sigma.fst p ∈ s ∧ sigma.snd p ∈ t (sigma.fst p) :=\n  multiset.mem_sigma\n\ntheorem sigma_mono {α : Type u_1} {σ : α → Type u_4} {s₁ : finset α} {s₂ : finset α} {t₁ : (a : α) → finset (σ a)} {t₂ : (a : α) → finset (σ a)} (H1 : s₁ ⊆ s₂) (H2 : ∀ (a : α), t₁ a ⊆ t₂ a) : finset.sigma s₁ t₁ ⊆ finset.sigma s₂ t₂ := sorry\n\ntheorem sigma_eq_bUnion {α : Type u_1} {σ : α → Type u_4} [DecidableEq (sigma fun (a : α) => σ a)] (s : finset α) (t : (a : α) → finset (σ a)) : finset.sigma s t = finset.bUnion s fun (a : α) => map (function.embedding.sigma_mk a) (t a) := sorry\n\n/-! ### disjoint -/\n\ntheorem disjoint_left {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : disjoint s t ↔ ∀ {a : α}, a ∈ s → ¬a ∈ t := sorry\n\ntheorem disjoint_val {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : disjoint s t ↔ multiset.disjoint (val s) (val t) :=\n  disjoint_left\n\ntheorem disjoint_iff_inter_eq_empty {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : disjoint s t ↔ s ∩ t = ∅ :=\n  disjoint_iff\n\nprotected instance decidable_disjoint {α : Type u_1} [DecidableEq α] (U : finset α) (V : finset α) : Decidable (disjoint U V) :=\n  decidable_of_decidable_of_iff (finset.has_decidable_eq (U ⊓ V) ⊥) sorry\n\ntheorem disjoint_right {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : disjoint s t ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint s t ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s)) (propext disjoint.comm)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (disjoint t s ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s)) (propext disjoint_left)))\n      (iff.refl (∀ {a : α}, a ∈ t → ¬a ∈ s)))\n\ntheorem disjoint_iff_ne {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : disjoint s t ↔ ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a ≠ b := sorry\n\ntheorem disjoint_of_subset_left {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} {u : finset α} (h : s ⊆ u) (d : disjoint u t) : disjoint s t :=\n  iff.mpr disjoint_left fun (x : α) (m₁ : x ∈ s) => iff.mp disjoint_left d x (h m₁)\n\ntheorem disjoint_of_subset_right {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} {u : finset α} (h : t ⊆ u) (d : disjoint s u) : disjoint s t :=\n  iff.mpr disjoint_right fun (x : α) (m₁ : x ∈ t) => iff.mp disjoint_right d x (h m₁)\n\n@[simp] theorem disjoint_empty_left {α : Type u_1} [DecidableEq α] (s : finset α) : disjoint ∅ s :=\n  disjoint_bot_left\n\n@[simp] theorem disjoint_empty_right {α : Type u_1} [DecidableEq α] (s : finset α) : disjoint s ∅ :=\n  disjoint_bot_right\n\n@[simp] theorem singleton_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {a : α} : disjoint (singleton a) s ↔ ¬a ∈ s := sorry\n\n@[simp] theorem disjoint_singleton {α : Type u_1} [DecidableEq α] {s : finset α} {a : α} : disjoint s (singleton a) ↔ ¬a ∈ s :=\n  iff.trans disjoint.comm singleton_disjoint\n\n@[simp] theorem disjoint_insert_left {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} {t : finset α} : disjoint (insert a s) t ↔ ¬a ∈ t ∧ disjoint s t := sorry\n\n@[simp] theorem disjoint_insert_right {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} {t : finset α} : disjoint s (insert a t) ↔ ¬a ∈ s ∧ disjoint s t := sorry\n\n@[simp] theorem disjoint_union_left {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} {u : finset α} : disjoint (s ∪ t) u ↔ disjoint s u ∧ disjoint t u := sorry\n\n@[simp] theorem disjoint_union_right {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} {u : finset α} : disjoint s (t ∪ u) ↔ disjoint s t ∧ disjoint s u := sorry\n\ntheorem sdiff_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : disjoint (t \\ s) s :=\n  iff.mpr disjoint_left fun (a : α) (ha : a ∈ t \\ s) => and.right (iff.mp mem_sdiff ha)\n\ntheorem disjoint_sdiff {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : disjoint s (t \\ s) :=\n  disjoint.symm sdiff_disjoint\n\ntheorem disjoint_sdiff_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) : disjoint (s \\ t) (s ∩ t) :=\n  disjoint_of_subset_right (inter_subset_right s t) sdiff_disjoint\n\ntheorem sdiff_eq_self_iff_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} : s \\ t = s ↔ disjoint s t := sorry\n\ntheorem sdiff_eq_self_of_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} (h : disjoint s t) : s \\ t = s :=\n  iff.mpr sdiff_eq_self_iff_disjoint h\n\ntheorem disjoint_self_iff_empty {α : Type u_1} [DecidableEq α] (s : finset α) : disjoint s s ↔ s = ∅ :=\n  disjoint_self\n\ntheorem disjoint_bUnion_left {α : Type u_1} [DecidableEq α] {ι : Type u_2} (s : finset ι) (f : ι → finset α) (t : finset α) : disjoint (finset.bUnion s f) t ↔ ∀ (i : ι), i ∈ s → disjoint (f i) t := sorry\n\ntheorem disjoint_bUnion_right {α : Type u_1} [DecidableEq α] {ι : Type u_2} (s : finset α) (t : finset ι) (f : ι → finset α) : disjoint s (finset.bUnion t f) ↔ ∀ (i : ι), i ∈ t → disjoint s (f i) := sorry\n\n@[simp] theorem card_disjoint_union {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} (h : disjoint s t) : card (s ∪ t) = card s + card t := sorry\n\ntheorem card_sdiff {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} (h : s ⊆ t) : card (t \\ s) = card t - card s := sorry\n\ntheorem disjoint_filter {α : Type u_1} [DecidableEq α] {s : finset α} {p : α → Prop} {q : α → Prop} [decidable_pred p] [decidable_pred q] : disjoint (filter p s) (filter q s) ↔ ∀ (x : α), x ∈ s → p x → ¬q x := sorry\n\ntheorem disjoint_filter_filter {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} {p : α → Prop} {q : α → Prop} [decidable_pred p] [decidable_pred q] : disjoint s t → disjoint (filter p s) (filter q t) :=\n  disjoint.mono (filter_subset p s) (filter_subset q t)\n\ntheorem disjoint_iff_disjoint_coe {α : Type u_1} {a : finset α} {b : finset α} [DecidableEq α] : disjoint a b ↔ disjoint ↑a ↑b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint a b ↔ disjoint ↑a ↑b)) (propext disjoint_left)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((∀ {a_1 : α}, a_1 ∈ a → ¬a_1 ∈ b) ↔ disjoint ↑a ↑b)) (propext set.disjoint_left)))\n      (iff.refl (∀ {a_1 : α}, a_1 ∈ a → ¬a_1 ∈ b)))\n\ntheorem filter_card_add_filter_neg_card_eq_card {α : Type u_1} {s : finset α} (p : α → Prop) [decidable_pred p] : card (filter p s) + card (filter (Not ∘ p) s) = card s := sorry\n\n/-- Given a finite set `s`, the diagonal, `s.diag` is the set of pairs of the form `(a, a)` for\n`a ∈ s`. -/\ndef diag {α : Type u_1} (s : finset α) [DecidableEq α] : finset (α × α) :=\n  filter (fun (a : α × α) => prod.fst a = prod.snd a) (finset.product s s)\n\n/-- Given a finite set `s`, the off-diagonal, `s.off_diag` is the set of pairs `(a, b)` with `a ≠ b`\nfor `a, b ∈ s`. -/\ndef off_diag {α : Type u_1} (s : finset α) [DecidableEq α] : finset (α × α) :=\n  filter (fun (a : α × α) => prod.fst a ≠ prod.snd a) (finset.product s s)\n\n@[simp] theorem mem_diag {α : Type u_1} (s : finset α) [DecidableEq α] (x : α × α) : x ∈ diag s ↔ prod.fst x ∈ s ∧ prod.fst x = prod.snd x := sorry\n\n@[simp] theorem mem_off_diag {α : Type u_1} (s : finset α) [DecidableEq α] (x : α × α) : x ∈ off_diag s ↔ prod.fst x ∈ s ∧ prod.snd x ∈ s ∧ prod.fst x ≠ prod.snd x := sorry\n\n@[simp] theorem diag_card {α : Type u_1} (s : finset α) [DecidableEq α] : card (diag s) = card s := sorry\n\n@[simp] theorem off_diag_card {α : Type u_1} (s : finset α) [DecidableEq α] : card (off_diag s) = card s * card s - card s := sorry\n\n/--\nGiven a set A and a set B inside it, we can shrink A to any appropriate size, and keep B\ninside it.\n-/\ntheorem exists_intermediate_set {α : Type u_1} {A : finset α} {B : finset α} (i : ℕ) (h₁ : i + card B ≤ card A) (h₂ : B ⊆ A) : ∃ (C : finset α), B ⊆ C ∧ C ⊆ A ∧ card C = i + card B := sorry\n\n/-- We can shrink A to any smaller size. -/\ntheorem exists_smaller_set {α : Type u_1} (A : finset α) (i : ℕ) (h₁ : i ≤ card A) : ∃ (B : finset α), B ⊆ A ∧ card B = i := sorry\n\n/-- `finset.fin_range k` is the finset `{0, 1, ..., k-1}`, as a `finset (fin k)`. -/\ndef fin_range (k : ℕ) : finset (fin k) :=\n  mk (↑(list.fin_range k)) (list.nodup_fin_range k)\n\n@[simp] theorem fin_range_card {k : ℕ} : card (fin_range k) = k := sorry\n\n@[simp] theorem mem_fin_range {k : ℕ} (m : fin k) : m ∈ fin_range k :=\n  list.mem_fin_range m\n\n@[simp] theorem coe_fin_range (k : ℕ) : ↑(fin_range k) = set.univ :=\n  set.eq_univ_of_forall mem_fin_range\n\n/-- Given a finset `s` of `ℕ` contained in `{0,..., n-1}`, the corresponding finset in `fin n`\nis `s.attach_fin h` where `h` is a proof that all elements of `s` are less than `n`. -/\ndef attach_fin (s : finset ℕ) {n : ℕ} (h : ∀ (m : ℕ), m ∈ s → m < n) : finset (fin n) :=\n  mk (multiset.pmap (fun (a : ℕ) (ha : a < n) => { val := a, property := ha }) (val s) h) sorry\n\n@[simp] theorem mem_attach_fin {n : ℕ} {s : finset ℕ} (h : ∀ (m : ℕ), m ∈ s → m < n) {a : fin n} : a ∈ attach_fin s h ↔ ↑a ∈ s := sorry\n\n@[simp] theorem card_attach_fin {n : ℕ} (s : finset ℕ) (h : ∀ (m : ℕ), m ∈ s → m < n) : card (attach_fin s h) = card s :=\n  multiset.card_pmap (fun (a : ℕ) (ha : a < n) => { val := a, property := ha }) (val s) h\n\n/-! ### choose -/\n\n/-- Given a finset `l` and a predicate `p`, associate to a proof that there is a unique element of\n`l` satisfying `p` this unique element, as an element of the corresponding subtype. -/\ndef choose_x {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α) (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : Subtype fun (a : α) => a ∈ l ∧ p a :=\n  multiset.choose_x p (val l) hp\n\n/-- Given a finset `l` and a predicate `p`, associate to a proof that there is a unique element of\n`l` satisfying `p` this unique element, as an element of the ambient type. -/\ndef choose {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α) (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : α :=\n  ↑(choose_x p l hp)\n\ntheorem choose_spec {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α) (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : choose p l hp ∈ l ∧ p (choose p l hp) :=\n  subtype.property (choose_x p l hp)\n\ntheorem choose_mem {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α) (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : choose p l hp ∈ l :=\n  and.left (choose_spec p l hp)\n\ntheorem choose_property {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α) (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : p (choose p l hp) :=\n  and.right (choose_spec p l hp)\n\ntheorem lt_wf {α : Type u_1} : well_founded Less :=\n  (fun (H : subrelation Less (inv_image Less card)) => subrelation.wf H (inv_image.wf card nat.lt_wf))\n    fun (x y : finset α) (hxy : x < y) => card_lt_card hxy\n\nend finset\n\n\nnamespace equiv\n\n\n/-- Given an equivalence `α` to `β`, produce an equivalence between `finset α` and `finset β`. -/\nprotected def finset_congr {α : Type u_1} {β : Type u_2} (e : α ≃ β) : finset α ≃ finset β :=\n  mk (fun (s : finset α) => finset.map (equiv.to_embedding e) s)\n    (fun (s : finset β) => finset.map (equiv.to_embedding (equiv.symm e)) s) sorry sorry\n\n@[simp] theorem finset_congr_apply {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : finset α) : coe_fn (equiv.finset_congr e) s = finset.map (equiv.to_embedding e) s :=\n  rfl\n\n@[simp] theorem finset_congr_symm_apply {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : finset β) : coe_fn (equiv.symm (equiv.finset_congr e)) s = finset.map (equiv.to_embedding (equiv.symm e)) s :=\n  rfl\n\nend equiv\n\n\nnamespace list\n\n\ntheorem to_finset_card_of_nodup {α : Type u_1} [DecidableEq α] {l : List α} (h : nodup l) : finset.card (to_finset l) = length l :=\n  congr_arg (⇑multiset.card) (iff.mpr multiset.erase_dup_eq_self h)\n\nend list\n\n\nnamespace multiset\n\n\ntheorem to_finset_card_of_nodup {α : Type u_1} [DecidableEq α] {l : multiset α} (h : nodup l) : finset.card (to_finset l) = coe_fn card l :=\n  congr_arg (⇑card) (iff.mpr erase_dup_eq_self h)\n\ntheorem disjoint_to_finset {α : Type u_1} [DecidableEq α] (m1 : multiset α) (m2 : multiset α) : disjoint (to_finset m1) (to_finset m2) ↔ disjoint m1 m2 := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/finset/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.7310585669110202, "lm_q1q2_score": 0.4864540894849071}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module topology.sheaves.presheaf_of_functions\n! leanprover-community/mathlib commit 6c31dd6563a3745bf8e0b80bdd077167583ebb8f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Yoneda\nimport Mathbin.Topology.Sheaves.Presheaf\nimport Mathbin.Topology.Category.TopCommRing\nimport Mathbin.Topology.ContinuousFunction.Algebra\n\n/-!\n# Presheaves of functions\n\nWe construct some simple examples of presheaves of functions on a topological space.\n* `presheaf_to_Types X T`, where `T : X → Type`,\n  is the presheaf of dependently-typed (not-necessarily continuous) functions\n* `presheaf_to_Type X T`, where `T : Type`,\n  is the presheaf of (not-necessarily-continuous) functions to a fixed target type `T`\n* `presheaf_to_Top X T`, where `T : Top`,\n  is the presheaf of continuous functions into a topological space `T`\n* `presheaf_To_TopCommRing X R`, where `R : TopCommRing`\n  is the presheaf valued in `CommRing` of functions functions into a topological ring `R`\n* as an example of the previous construction,\n  `presheaf_to_TopCommRing X (TopCommRing.of ℂ)`\n  is the presheaf of rings of continuous complex-valued functions on `X`.\n-/\n\n\nuniverse v u\n\nopen CategoryTheory\n\nopen TopologicalSpace\n\nopen Opposite\n\nnamespace TopCat\n\nvariable (X : TopCat.{v})\n\n/-- The presheaf of dependently typed functions on `X`, with fibres given by a type family `T`.\nThere is no requirement that the functions are continuous, here.\n-/\ndef presheafToTypes (T : X → Type v) : X.Presheaf (Type v)\n    where\n  obj U := ∀ x : unop U, T x\n  map U V i g := fun x : unop V => g (i.unop x)\n  map_id' U := by\n    ext (g⟨x, hx⟩)\n    rfl\n  map_comp' U V W i j := rfl\n#align Top.presheaf_to_Types TopCat.presheafToTypes\n\n@[simp]\ntheorem presheafToTypes_obj {T : X → Type v} {U : (Opens X)ᵒᵖ} :\n    (presheafToTypes X T).obj U = ∀ x : unop U, T x :=\n  rfl\n#align Top.presheaf_to_Types_obj TopCat.presheafToTypes_obj\n\n@[simp]\ntheorem presheafToTypes_map {T : X → Type v} {U V : (Opens X)ᵒᵖ} {i : U ⟶ V} {f} :\n    (presheafToTypes X T).map i f = fun x => f (i.unop x) :=\n  rfl\n#align Top.presheaf_to_Types_map TopCat.presheafToTypes_map\n\n-- We don't just define this in terms of `presheaf_to_Types`,\n-- as it's helpful later to see (at a syntactic level) that `(presheaf_to_Type X T).obj U`\n-- is a non-dependent function.\n-- We don't use `@[simps]` to generate the projection lemmas here,\n-- as it turns out to be useful to have `presheaf_to_Type_map`\n-- written as an equality of functions (rather than being applied to some argument).\n/-- The presheaf of functions on `X` with values in a type `T`.\nThere is no requirement that the functions are continuous, here.\n-/\ndef presheafToType (T : Type v) : X.Presheaf (Type v)\n    where\n  obj U := unop U → T\n  map U V i g := g ∘ i.unop\n  map_id' U := by\n    ext (g⟨x, hx⟩)\n    rfl\n  map_comp' U V W i j := rfl\n#align Top.presheaf_to_Type TopCat.presheafToType\n\n@[simp]\ntheorem presheafToType_obj {T : Type v} {U : (Opens X)ᵒᵖ} :\n    (presheafToType X T).obj U = (unop U → T) :=\n  rfl\n#align Top.presheaf_to_Type_obj TopCat.presheafToType_obj\n\n@[simp]\ntheorem presheafToType_map {T : Type v} {U V : (Opens X)ᵒᵖ} {i : U ⟶ V} {f} :\n    (presheafToType X T).map i f = f ∘ i.unop :=\n  rfl\n#align Top.presheaf_to_Type_map TopCat.presheafToType_map\n\n/-- The presheaf of continuous functions on `X` with values in fixed target topological space\n`T`. -/\ndef presheafToTop (T : TopCat.{v}) : X.Presheaf (Type v) :=\n  (Opens.toTop X).op ⋙ yoneda.obj T\n#align Top.presheaf_to_Top TopCat.presheafToTop\n\n@[simp]\ntheorem presheafToTop_obj (T : TopCat.{v}) (U : (Opens X)ᵒᵖ) :\n    (presheafToTop X T).obj U = ((Opens.toTop X).obj (unop U) ⟶ T) :=\n  rfl\n#align Top.presheaf_to_Top_obj TopCat.presheafToTop_obj\n\n-- TODO upgrade the result to TopCommRing?\n/-- The (bundled) commutative ring of continuous functions from a topological space\nto a topological commutative ring, with pointwise multiplication. -/\ndef continuousFunctions (X : TopCat.{v}ᵒᵖ) (R : TopCommRing.{v}) : CommRingCat.{v} :=\n  CommRingCat.of (unop X ⟶ (forget₂ TopCommRing TopCat).obj R)\n#align Top.continuous_functions TopCat.continuousFunctions\n\nnamespace ContinuousFunctions\n\n/-- Pulling back functions into a topological ring along a continuous map is a ring homomorphism. -/\ndef pullback {X Y : TopCatᵒᵖ} (f : X ⟶ Y) (R : TopCommRing) :\n    continuousFunctions X R ⟶ continuousFunctions Y R\n    where\n  toFun g := f.unop ≫ g\n  map_one' := rfl\n  map_zero' := rfl\n  map_add' := by tidy\n  map_mul' := by tidy\n#align Top.continuous_functions.pullback TopCat.continuousFunctions.pullback\n\n/-- A homomorphism of topological rings can be postcomposed with functions from a source space `X`;\nthis is a ring homomorphism (with respect to the pointwise ring operations on functions). -/\ndef map (X : TopCat.{u}ᵒᵖ) {R S : TopCommRing.{u}} (φ : R ⟶ S) :\n    continuousFunctions X R ⟶ continuousFunctions X S\n    where\n  toFun g := g ≫ (forget₂ TopCommRing TopCat).map φ\n  map_one' := by ext <;> exact φ.1.map_one\n  map_zero' := by ext <;> exact φ.1.map_zero\n  map_add' := by intros <;> ext <;> apply φ.1.map_add\n  map_mul' := by intros <;> ext <;> apply φ.1.map_mul\n#align Top.continuous_functions.map TopCat.continuousFunctions.map\n\nend ContinuousFunctions\n\n/-- An upgraded version of the Yoneda embedding, observing that the continuous maps\nfrom `X : Top` to `R : TopCommRing` form a commutative ring, functorial in both `X` and `R`. -/\ndef commRingYoneda : TopCommRing.{u} ⥤ TopCat.{u}ᵒᵖ ⥤ CommRingCat.{u}\n    where\n  obj R :=\n    { obj := fun X => continuousFunctions X R\n      map := fun X Y f => continuousFunctions.pullback f R\n      map_id' := fun X => by\n        ext\n        rfl\n      map_comp' := fun X Y Z f g => rfl }\n  map R S φ :=\n    { app := fun X => continuousFunctions.map X φ\n      naturality' := fun X Y f => rfl }\n  map_id' X := by\n    ext\n    rfl\n  map_comp' X Y Z f g := rfl\n#align Top.CommRing_yoneda TopCat.commRingYoneda\n\n/-- The presheaf (of commutative rings), consisting of functions on an open set `U ⊆ X` with\nvalues in some topological commutative ring `T`.\n\nFor example, we could construct the presheaf of continuous complex valued functions of `X` as\n```\npresheaf_to_TopCommRing X (TopCommRing.of ℂ)\n```\n(this requires `import topology.instances.complex`).\n-/\ndef presheafToTopCommRing (T : TopCommRing.{v}) : X.Presheaf CommRingCat.{v} :=\n  (Opens.toTop X).op ⋙ commRingYoneda.obj T\n#align Top.presheaf_to_TopCommRing TopCat.presheafToTopCommRing\n\nend TopCat\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Sheaves/PresheafOfFunctions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.48645408368247994}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Andrew Yang\n-/\nimport category_theory.limits.shapes.terminal\nimport category_theory.limits.shapes.pullbacks\nimport category_theory.limits.shapes.binary_products\n\n/-!\n# Constructing binary product from pullbacks and terminal object.\n\nThe product is the pullback over the terminal objects. In particular, if a category\nhas pullbacks and a terminal object, then it has binary products.\n\nWe also provide the dual.\n-/\n\nuniverses v u\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u} [category.{v} C]\n\n/-- The pullback over the terminal object is the product -/\ndef is_product_of_is_terminal_is_pullback {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_terminal Z)\n  (H₂ : is_limit (pullback_cone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _))) :\n  is_limit (binary_fan.mk h k) :=\n{ lift := λ c, H₂.lift (pullback_cone.mk\n    (c.π.app walking_pair.left) (c.π.app walking_pair.right) (H₁.hom_ext _ _)),\n  fac' := λ c j,\n  begin\n    convert H₂.fac (pullback_cone.mk\n      (c.π.app walking_pair.left) (c.π.app walking_pair.right) (H₁.hom_ext _ _)) (some j) using 1,\n    cases j; refl\n  end,\n  uniq' := λ c m hm,\n  begin\n    apply pullback_cone.is_limit.hom_ext H₂,\n    { exact (hm walking_pair.left).trans (H₂.fac (pullback_cone.mk (c.π.app walking_pair.left)\n        (c.π.app walking_pair.right) (H₁.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm walking_pair.right).trans (H₂.fac (pullback_cone.mk (c.π.app walking_pair.left)\n        (c.π.app walking_pair.right) (H₁.hom_ext _ _)) walking_cospan.right).symm },\n  end }\n\n/-- The product is the pullback over the terminal object. -/\ndef is_pullback_of_is_terminal_is_product {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_terminal Z)\n  (H₂ : is_limit (binary_fan.mk h k)) :\n  is_limit (pullback_cone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _)) :=\nbegin\n  apply pullback_cone.is_limit_aux',\n  intro s,\n  use H₂.lift (binary_fan.mk s.fst s.snd),\n  use H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.left,\n  use H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.right,\n  intros m h₁ h₂,\n  apply H₂.hom_ext,\n  rintro ⟨⟩,\n  { exact h₁.trans (H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.left).symm },\n  { exact h₂.trans (H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.right).symm }\nend\n\nvariable (C)\n\n/-- Any category with pullbacks and terminal object has binary products. -/\n-- This is not an instance, as it is not always how one wants to construct binary products!\nlemma has_binary_products_of_terminal_and_pullbacks\n  [has_terminal C] [has_pullbacks C] :\n  has_binary_products C :=\n{ has_limit := λ F, has_limit.mk\n  { cone :=\n    { X := pullback (terminal.from (F.obj walking_pair.left))\n                    (terminal.from (F.obj walking_pair.right)),\n      π := discrete.nat_trans (λ x, walking_pair.cases_on x pullback.fst pullback.snd)},\n    is_limit :=\n    { lift := λ c, pullback.lift ((c.π).app walking_pair.left)\n                                  ((c.π).app walking_pair.right)\n                                  (subsingleton.elim _ _),\n      fac' := λ s c, walking_pair.cases_on c (limit.lift_π _ _) (limit.lift_π _ _),\n      uniq' := λ s m J,\n                begin\n                  rw [←J, ←J],\n                  ext;\n                  rw limit.lift_π;\n                  refl\n                end } } }\n\nvariable {C}\n\n/-- The pushout under the initial object is the coproduct -/\ndef is_coproduct_of_is_initial_is_pushout {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_initial W)\n  (H₂ : is_colimit (pushout_cocone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _))) :\n  is_colimit (binary_cofan.mk f g) :=\n{ desc := λ c, H₂.desc (pushout_cocone.mk\n    (c.ι.app walking_pair.left) (c.ι.app walking_pair.right) (H₁.hom_ext _ _)),\n  fac' := λ c j,\n  begin\n    convert H₂.fac (pushout_cocone.mk\n      (c.ι.app walking_pair.left) (c.ι.app walking_pair.right) (H₁.hom_ext _ _)) (some j) using 1,\n    cases j; refl\n  end,\n  uniq' := λ c m hm,\n  begin\n    apply pushout_cocone.is_colimit.hom_ext H₂,\n    { exact (hm walking_pair.left).trans (H₂.fac (pushout_cocone.mk (c.ι.app walking_pair.left)\n        (c.ι.app walking_pair.right) (H₁.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm walking_pair.right).trans (H₂.fac (pushout_cocone.mk (c.ι.app walking_pair.left)\n        (c.ι.app walking_pair.right) (H₁.hom_ext _ _)) walking_cospan.right).symm },\n  end }\n\n/-- The coproduct is the pushout under the initial object. -/\ndef is_pushout_of_is_initial_is_coproduct {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ X)\n  (k : W ⟶ Y) (H₁ : is_terminal Z)\n  (H₂ : is_limit (binary_fan.mk h k)) :\n  is_limit (pullback_cone.mk _ _ (show h ≫ f = k ≫ g, from H₁.hom_ext _ _)) :=\nbegin\n  apply pullback_cone.is_limit_aux',\n  intro s,\n  use H₂.lift (binary_fan.mk s.fst s.snd),\n  use H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.left,\n  use H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.right,\n  intros m h₁ h₂,\n  apply H₂.hom_ext,\n  rintro ⟨⟩,\n  { exact h₁.trans (H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.left).symm },\n  { exact h₂.trans (H₂.fac (binary_fan.mk s.fst s.snd) walking_pair.right).symm }\nend\n\nvariable (C)\n\n/-- Any category with pushouts and initial object has binary coproducts. -/\n-- This is not an instance, as it is not always how one wants to construct binary coproducts!\nlemma has_binary_coproducts_of_initial_and_pushouts\n  [has_initial C] [has_pushouts C] :\n  has_binary_coproducts C :=\n{ has_colimit := λ F, has_colimit.mk\n  { cocone :=\n    { X := pushout (initial.to (F.obj walking_pair.left))\n                    (initial.to (F.obj walking_pair.right)),\n      ι := discrete.nat_trans (λ x, walking_pair.cases_on x pushout.inl pushout.inr)},\n    is_colimit :=\n    { desc := λ c, pushout.desc (c.ι.app walking_pair.left)\n                                (c.ι.app walking_pair.right)\n                                (subsingleton.elim _ _),\n      fac' := λ s c, walking_pair.cases_on c (colimit.ι_desc _ _) (colimit.ι_desc _ _),\n      uniq' := λ s m J,\n                begin\n                  rw [←J, ←J],\n                  ext;\n                  rw colimit.ι_desc;\n                  refl\n                end } } }\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/limits/constructions/binary_products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.4864540797835119}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\nimport algebraic_geometry.properties\n\n/-!\n# Function field of integral schemes\n\nWe define the function field of an irreducible scheme as the stalk of the generic point.\nThis is a field when the scheme is integral.\n\n## Main definition\n* `algebraic_geometry.Scheme.function_field`: The function field of an integral scheme.\n* `algebraic_geometry.germ_to_function_field`: The canonical map from a component into the function\n  field. This map is injective.\n-/\n\nuniverses u v\n\nopen topological_space opposite category_theory category_theory.limits Top\n\nnamespace algebraic_geometry\n\nvariable (X : Scheme)\n\n/-- The function field of an irreducible scheme is the local ring at its generic point.\nDespite the name, this is a field only when the scheme is integral. -/\nnoncomputable\nabbreviation Scheme.function_field [irreducible_space X.carrier] : CommRing :=\nX.presheaf.stalk (generic_point X.carrier)\n\n/-- The restriction map from a component to the function field. -/\nnoncomputable\nabbreviation Scheme.germ_to_function_field [irreducible_space X.carrier] (U : opens X.carrier)\n  [h : nonempty U] : X.presheaf.obj (op U) ⟶ X.function_field :=\nX.presheaf.germ ⟨generic_point X.carrier,\n  ((generic_point_spec X.carrier).mem_open_set_iff U.prop).mpr (by simpa using h)⟩\n\nnoncomputable\ninstance [irreducible_space X.carrier] (U : opens X.carrier) [nonempty U] :\n  algebra (X.presheaf.obj (op U)) X.function_field :=\n(X.germ_to_function_field U).to_algebra\n\nnoncomputable\ninstance [is_integral X] : field X.function_field :=\nbegin\n  apply field_of_is_unit_or_eq_zero,\n  intro a,\n  obtain ⟨U, m, s, rfl⟩ := Top.presheaf.germ_exist _ _ a,\n  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero],\n  intro ha,\n  replace ha := ne_of_apply_ne _ ha,\n  have hs : generic_point X.carrier ∈ RingedSpace.basic_open _ s,\n  { rw [← opens.mem_coe, (generic_point_spec X.carrier).mem_open_set_iff, set.top_eq_univ,\n      set.univ_inter, ← set.ne_empty_iff_nonempty, ne.def, ← opens.coe_bot,\n      subtype.coe_injective.eq_iff, ← opens.empty_eq],\n    erw basic_open_eq_bot_iff,\n    exacts [ha, (RingedSpace.basic_open _ _).prop] },\n  have := (X.presheaf.germ ⟨_, hs⟩).is_unit_map (RingedSpace.is_unit_res_basic_open _ s),\n  rwa Top.presheaf.germ_res_apply at this\nend\n\nlemma germ_injective_of_is_integral [is_integral X] {U : opens X.carrier} (x : U) :\n  function.injective (X.presheaf.germ x) :=\nbegin\n  rw ring_hom.injective_iff,\n  intros y hy,\n  rw ← (X.presheaf.germ x).map_zero at hy,\n  obtain ⟨W, hW, iU, iV, e⟩ := X.presheaf.germ_eq _ x.prop x.prop _ _ hy,\n  cases (show iU = iV, from subsingleton.elim _ _),\n  haveI : nonempty W := ⟨⟨_, hW⟩⟩,\n  exact map_injective_of_is_integral X iU e\nend\n\nlemma Scheme.germ_to_function_field_injective [is_integral X] (U : opens X.carrier)\n  [nonempty U] : function.injective (X.germ_to_function_field U) :=\ngerm_injective_of_is_integral _ _\n\nlemma generic_point_eq_of_is_open_immersion {X Y : Scheme} (f : X ⟶ Y) [H : is_open_immersion f]\n  [hX : irreducible_space X.carrier] [irreducible_space Y.carrier] :\n    f.1.base (generic_point X.carrier : _) = (generic_point Y.carrier : _) :=\nbegin\n  apply ((generic_point_spec _).eq _).symm,\n  show t0_space Y.carrier, by apply_instance,\n  convert (generic_point_spec X.carrier).image (show continuous f.1.base, by continuity),\n  symmetry,\n  rw [eq_top_iff, set.top_eq_univ, set.top_eq_univ],\n  convert subset_closure_inter_of_is_preirreducible_of_is_open _ H.base_open.open_range _,\n  rw [set.univ_inter, set.image_univ],\n  apply_with preirreducible_space.is_preirreducible_univ { instances := ff },\n  show preirreducible_space Y.carrier, by apply_instance,\n  exact ⟨_, trivial, set.mem_range_self hX.2.some⟩,\nend\n\nnoncomputable\ninstance stalk_function_field_algebra [irreducible_space X.carrier] (x : X.carrier) :\n  algebra (X.presheaf.stalk x) X.function_field :=\nbegin\n  apply ring_hom.to_algebra,\n  exact X.presheaf.stalk_specializes ((generic_point_spec X.carrier).specializes trivial)\nend\n\ninstance function_field_is_scalar_tower [irreducible_space X.carrier] (U : opens X.carrier) (x : U)\n  [nonempty U] :\n  is_scalar_tower (X.presheaf.obj $ op U) (X.presheaf.stalk x) X.function_field :=\nbegin\n  apply is_scalar_tower.of_algebra_map_eq',\n  simp_rw [ring_hom.algebra_map_to_algebra],\n  change _ = X.presheaf.germ x ≫ _,\n  rw X.presheaf.germ_stalk_specializes,\n  refl\nend\n\nnoncomputable\ninstance (R : CommRing) [is_domain R] : algebra R (Scheme.Spec.obj $ op R).function_field :=\nbegin\n  apply ring_hom.to_algebra,\n  exact structure_sheaf.to_stalk R _,\nend\n\n@[simp] lemma generic_point_eq_bot_of_affine (R : CommRing) [is_domain R] :\n  generic_point (Scheme.Spec.obj $ op R).carrier = (⟨0, ideal.bot_prime⟩ : prime_spectrum R) :=\nbegin\n  apply (generic_point_spec (Scheme.Spec.obj $ op R).carrier).eq,\n  simp [is_generic_point_def, ← prime_spectrum.zero_locus_vanishing_ideal_eq_closure]\nend\n\ninstance function_field_is_fraction_ring_of_affine (R : CommRing.{u}) [is_domain R] :\n  is_fraction_ring R (Scheme.Spec.obj $ op R).function_field :=\nbegin\n  convert structure_sheaf.is_localization.to_stalk R _,\n  delta is_fraction_ring is_localization.at_prime,\n  congr' 1,\n  rw generic_point_eq_bot_of_affine,\n  ext,\n  exact mem_non_zero_divisors_iff_ne_zero\nend\n\ninstance {X : Scheme} [is_integral X] {U : opens X.carrier} [hU : nonempty U] :\n  is_integral (X.restrict U.open_embedding) :=\nbegin\n  haveI : nonempty (X.restrict U.open_embedding).carrier := hU,\n  exact is_integral_of_open_immersion (X.of_restrict U.open_embedding)\nend\n\nlemma is_affine_open.prime_ideal_of_generic_point {X : Scheme} [is_integral X]\n  {U : opens X.carrier} (hU : is_affine_open U) [h : nonempty U] :\n  hU.prime_ideal_of ⟨generic_point X.carrier,\n    ((generic_point_spec X.carrier).mem_open_set_iff U.prop).mpr (by simpa using h)⟩ =\n  generic_point (Scheme.Spec.obj $ op $ X.presheaf.obj $ op U).carrier :=\nbegin\n  haveI : is_affine _ := hU,\n  have e : U.open_embedding.is_open_map.functor.obj ⊤ = U,\n  { ext1, exact set.image_univ.trans subtype.range_coe },\n  delta is_affine_open.prime_ideal_of,\n  rw ← Scheme.comp_val_base_apply,\n  convert (generic_point_eq_of_is_open_immersion ((X.restrict U.open_embedding).iso_Spec.hom ≫\n    Scheme.Spec.map (X.presheaf.map (eq_to_hom e).op).op)),\n  ext1,\n  exact (generic_point_eq_of_is_open_immersion (X.of_restrict U.open_embedding)).symm\nend\n\nlemma function_field_is_fraction_ring_of_is_affine_open [is_integral X] (U : opens X.carrier)\n  (hU : is_affine_open U) [hU' : nonempty U] :\n  is_fraction_ring (X.presheaf.obj $ op U) X.function_field :=\nbegin\n  haveI : is_affine _ := hU,\n  haveI : nonempty (X.restrict U.open_embedding).carrier := hU',\n  haveI : is_integral (X.restrict U.open_embedding) := @@is_integral_of_is_affine_is_domain _ _ _\n    (by { dsimp, rw opens.open_embedding_obj_top, apply_instance }),\n  have e : U.open_embedding.is_open_map.functor.obj ⊤ = U,\n  { ext1, exact set.image_univ.trans subtype.range_coe },\n  delta is_fraction_ring Scheme.function_field,\n  convert hU.is_localization_stalk ⟨generic_point X.carrier, _⟩ using 1,\n  rw [hU.prime_ideal_of_generic_point, generic_point_eq_bot_of_affine],\n  ext, exact mem_non_zero_divisors_iff_ne_zero\nend\n\ninstance (x : X.carrier) : is_affine (X.affine_cover.obj x) :=\nalgebraic_geometry.Spec_is_affine _\n\ninstance [h : is_integral X] (x : X.carrier) :\n  is_fraction_ring (X.presheaf.stalk x) X.function_field :=\nbegin\n  let U : opens X.carrier := ⟨set.range (X.affine_cover.map x).1.base,\n    PresheafedSpace.is_open_immersion.base_open.open_range⟩,\n  haveI : nonempty U := ⟨⟨_, X.affine_cover.covers x⟩⟩,\n  have hU : is_affine_open U := range_is_affine_open_of_open_immersion (X.affine_cover.map x),\n  exact @@is_fraction_ring.is_fraction_ring_of_is_domain_of_is_localization _ _ _ _ _ _ _ _ _ _ _\n    (hU.is_localization_stalk ⟨x, X.affine_cover.covers x⟩)\n      (function_field_is_fraction_ring_of_is_affine_open X U hU)\nend\n\nend algebraic_geometry\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebraic_geometry/function_field.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581049086031, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4864510222465064}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport combinatorics.simplicial_complex.convex_independence\nimport combinatorics.simplicial_complex.glued\n\nopen set affine\nnamespace poly\nvariables {m n : ℕ} {E : Type*} [normed_group E] [normed_space ℝ E] {S : simplicial_complex E}\n  {x : E} {X Y : finset E} {C : set E} {A : set (finset E)}\n\n/--\nA polytope of dimension `n` in `R^m` is a subset for which there exists a simplicial complex which\nis pure of dimension `n` and has the same underlying space.\n-/\n@[ext] structure polytope (E : Type*) [normed_group E] [normed_space ℝ E] :=\n(space : set E)\n(realisable : ∃ {S : simplicial_complex E}, S.pure ∧ space = S.space)\n\nvariables {p : polytope E}\n\n/--\nA constructor for polytopes from an underlying simplicial complex\n-/\ndef simplicial_complex.to_polytope (hS : S.pure) :\n  polytope E :=\n{ space := S.space,\n  realisable := ⟨S, hS, rfl⟩}\n\nnoncomputable def polytope.to_simplicial_complex (p : polytope E) :\n  simplicial_complex E := classical.some p.realisable\n\nlemma pure_polytope_realisation :\n  p.to_simplicial_complex.pure :=\n(classical.some_spec p.realisable).1\n\nlemma polytope_space_eq_realisation_space :\n  p.space = p.to_simplicial_complex.space :=\n(classical.some_spec p.realisable).2\n\ndef polytope.vertices (p : polytope E) :\n  set E :=\n⋂ (S : simplicial_complex E) (H : p.space = S.space), S.vertices\n\nlemma vertices_subset_space :\n  p.vertices ⊆ p.space :=\nbegin\n  rintro x hx,\n  have hx' : x ∈ p.to_simplicial_complex.vertices,\n  {\n    --apply bInter_subset_of_mem (polytope_space_eq_realisation_space :\n     -- p.to_simplicial_complex ∈ set_of (λ q : simplicial_complex E, p.space = q.space)),\n     sorry\n  },\n  rw polytope_space_eq_realisation_space,\n  exact mem_space_iff.2 ⟨{x}, hx', by simp⟩,\nend\n\ndef polytope.edges (p : polytope E) :\n  set (finset E) :=\n⋂ (S : simplicial_complex E) (H : p.space = S.space), {X | X ∈ S.faces ∧ X.card = 2}\n\n--def polytope.faces {n : ℕ} (P : polytope E) : set (finset E) :=\n--  P.realisation.boundary.faces\n\nnoncomputable def polytope.triangulation (p : polytope E) :\n  simplicial_complex E :=\nbegin\n  classical,\n  exact\n  if p.space.nonempty ∧ convex p.space then begin\n    have hpnonempty : p.space.nonempty := sorry,\n    let x := classical.some hpnonempty,\n    have hx := classical.some_spec hpnonempty,\n    sorry\n  end else p.to_simplicial_complex,\nend\n\n/- Every convex polytope can be realised by a simplicial complex with the same vertices-/\nlemma polytope.triangulable_of_convex (hp : convex p.space) :\n  p.triangulation.vertices = p.vertices :=\nbegin\n  cases p.space.eq_empty_or_nonempty with hpempty hpnonempty,\n  {\n    /-rw empty_space_of_empty_simplicial_complex,\n    use hpempty,\n    rintro X (hX : {X} ∈ {∅}),\n    simp at hX,\n    exfalso,\n    exact hX,-/\n    sorry\n  },\n  obtain ⟨x, hx⟩ := hpnonempty,\n  --consider the boundary of some realisation of P and remove it x,\n  --have := P.realisation.boundary.erasure {x},\n  --then add it back by taking the pyramid of this monster with x\n  sorry\nend\n\n/-lemma convex_polytope_iff_intersection_of_half_spaces {space : set E} {n : ℕ} :\n  ∃ {S : simplicial_complex E}, S.pure ∧ space = S.space ↔ ∃ half spaces and stuff-/\n\n@[ext] structure polytopial_complex (E : Type*) [normed_group E] [normed_space ℝ E] :=\n(faces : set (finset E))\n(indep : ∀ {X}, X ∈ faces → convex_independent (λ p, p : (X : set E) → E))\n(down_closed : ∀ {X Y}, X ∈ faces → Y ⊆ X → (Y : set E) = (X : set E) ∩ affine_span ℝ (Y : set E)\n  → Y ∈ faces)\n(disjoint : ∀ {X Y}, X ∈ faces → Y ∈ faces →\n  convex_hull ↑X ∩ convex_hull ↑Y ⊆ convex_hull (X ∩ Y : set E))\n\nvariables {P : polytopial_complex E}\n\ndef polytopial_complex.polytopes (P : polytopial_complex E) :\n  set (polytope E) :=\n  sorry\n\ndef polytopial_complex.space (P : polytopial_complex E) :\n  set E :=\n⋃ (p ∈ P.polytopes), (p : polytope E).space\n\nlemma mem_space_iff :\n  x ∈ P.space ↔ ∃ (p : polytope E), p ∈ P.polytopes ∧ x ∈ p.space :=\nbegin\n  unfold polytopial_complex.space,\n  simp,\nend\n\ndef simplicial_complex.to_polytopial_complex (S : simplicial_complex E) :\n  polytopial_complex E :=\n{ faces := S.faces,\n  indep := λ X hX, (S.indep hX).convex_independent,\n  down_closed := λ X Y hX hYX hY, S.down_closed hX hYX,\n  disjoint := S.disjoint }\n\nnoncomputable def polytope.to_polytopial_complex (p : polytope E) :\n  polytopial_complex E :=\nsimplicial_complex.to_polytopial_complex p.to_simplicial_complex\n--@Bhavik I can't use dot notation here because of namespace problems. Do you have a fix?\n\ndef polytopial_complex.coplanarless (P : polytopial_complex E) :\n  Prop :=\n∀ X Y ∈ P.faces, adjacent X Y → (X : set E) ⊆ affine_span ℝ (Y : set E) →\n  X.card = finite_dimensional.finrank ℝ E + 1\n\ndef polytopial_complex.to_simplicial_complex (P : polytopial_complex E) :\n  simplicial_complex E :=\n{ faces := ⋃ (p ∈ P.polytopes), (p : polytope E).to_simplicial_complex.faces,\n  indep := begin\n    rintro X hX,\n    rw mem_bUnion_iff at hX,\n    obtain ⟨p, hp, hX⟩ := hX,\n    exact p.to_simplicial_complex.indep hX,\n  end,\n  down_closed := begin\n    rintro X Y hX hYX,\n    rw mem_bUnion_iff at ⊢ hX,\n    obtain ⟨p, hp, hX⟩ := hX,\n    exact ⟨p, hp, p.to_simplicial_complex.down_closed hX hYX⟩,\n  end,\n  disjoint := begin\n    rintro X Y hX hY,\n    rw mem_bUnion_iff at hX hY,\n    obtain ⟨p, hp, hX⟩ := hX,\n    obtain ⟨q, hq, hY⟩ := hY,\n    sorry --this is wrong because faces of adjacent polytopes aren't required to glue nicely\n    -- causes problem as soon as their shared faces aren't simplices\n  end }\n\nlemma polytopial_space_iff_simplicial_space [finite_dimensional ℝ E] :\n  (∃ (S : simplicial_complex E), S.space = C) ↔\n  ∃ (P : polytopial_complex E), P.space = C :=\nbegin\n  split,\n  {\n    rintro ⟨S, hS⟩,\n    sorry\n  },\n  sorry\nend\n\nend poly\n", "meta": {"author": "mmasdeu", "repo": "brouwerfixedpoint", "sha": "548270f79ecf12d7e20a256806ccb9fcf57b87e2", "save_path": "github-repos/lean/mmasdeu-brouwerfixedpoint", "path": "github-repos/lean/mmasdeu-brouwerfixedpoint/brouwerfixedpoint-548270f79ecf12d7e20a256806ccb9fcf57b87e2/src/combinatorics/simplicial_complex/polytope.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.6370308082623216, "lm_q1q2_score": 0.48636268584863146}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Scott Morrison\n-/\nimport algebra.group.ext\nimport category_theory.simple\nimport category_theory.linear\nimport category_theory.endomorphism\nimport algebra.algebra.spectrum\n\n/-!\n# Schur's lemma\nWe first prove the part of Schur's Lemma that holds in any preadditive category with kernels,\nthat any nonzero morphism between simple objects\nis an isomorphism.\n\nSecond, we prove Schur's lemma for `𝕜`-linear categories with finite dimensional hom spaces,\nover an algebraically closed field `𝕜`:\nthe hom space `X ⟶ Y` between simple objects `X` and `Y` is at most one dimensional,\nand is 1-dimensional iff `X` and `Y` are isomorphic.\n\n## Future work\nIt might be nice to provide a `division_ring` instance on `End X` when `X` is simple.\nThis is an easy consequence of the results here,\nbut may take some care setting up usable instances.\n-/\n\nnamespace category_theory\n\nopen category_theory.limits\n\nuniverses v u\nvariables {C : Type u} [category.{v} C]\nvariables [preadditive C]\n\n/--\nThe part of **Schur's lemma** that holds in any preadditive category with kernels:\nthat a nonzero morphism between simple objects is an isomorphism.\n-/\nlemma is_iso_of_hom_simple [has_kernels C] {X Y : C} [simple X] [simple Y] {f : X ⟶ Y} (w : f ≠ 0) :\n  is_iso f :=\nbegin\n  haveI : mono f := preadditive.mono_of_kernel_zero (kernel_zero_of_nonzero_from_simple w),\n  exact is_iso_of_mono_of_nonzero w\nend\n\n/--\nAs a corollary of Schur's lemma for preadditive categories,\nany morphism between simple objects is (exclusively) either an isomorphism or zero.\n-/\nlemma is_iso_iff_nonzero [has_kernels C] {X Y : C} [simple.{v} X] [simple.{v} Y] (f : X ⟶ Y) :\n  is_iso.{v} f ↔ f ≠ 0 :=\n⟨λ I,\n  begin\n    introI h,\n    apply id_nonzero X,\n    simp only [←is_iso.hom_inv_id f, h, zero_comp],\n  end,\n  λ w, is_iso_of_hom_simple w⟩\n\nopen finite_dimensional\n\nvariables (𝕜 : Type*) [field 𝕜]\n\n/--\nPart of **Schur's lemma** for `𝕜`-linear categories:\nthe hom space between two non-isomorphic simple objects is 0-dimensional.\n-/\nlemma finrank_hom_simple_simple_eq_zero_of_not_iso\n  [has_kernels C] [linear 𝕜 C] {X Y : C} [simple.{v} X] [simple.{v} Y]\n  (h : (X ≅ Y) → false):\n  finrank 𝕜 (X ⟶ Y) = 0 :=\nbegin\n  haveI := subsingleton_of_forall_eq (0 : X ⟶ Y) (λ f, begin\n    have p := not_congr (is_iso_iff_nonzero f),\n    simp only [not_not, ne.def] at p,\n    refine p.mp (λ _, by exactI h (as_iso f)),\n  end),\n  exact finrank_zero_of_subsingleton,\nend\n\nvariables [is_alg_closed 𝕜] [linear 𝕜 C]\n\n-- In the proof below we have some difficulty using `I : finite_dimensional 𝕜 (X ⟶ X)`\n-- where we need a `finite_dimensional 𝕜 (End X)`.\n-- These are definitionally equal, but without eta reduction Lean can't see this.\n-- To get around this, we use `convert I`,\n-- then check the various instances agree field-by-field,\n-- using `ext` equipped with the following extra lemmas:\nlocal attribute [ext] module distrib_mul_action mul_action has_scalar\n\n/--\nAn auxiliary lemma for Schur's lemma.\n\nIf `X ⟶ X` is finite dimensional, and every nonzero endomorphism is invertible,\nthen `X ⟶ X` is 1-dimensional.\n-/\n-- We prove this with the explicit `is_iso_iff_nonzero` assumption,\n-- rather than just `[simple X]`, as this form is useful for\n-- Müger's formulation of semisimplicity.\nlemma finrank_endomorphism_eq_one\n  {X : C} (is_iso_iff_nonzero : ∀ f : X ⟶ X, is_iso f ↔ f ≠ 0)\n  [I : finite_dimensional 𝕜 (X ⟶ X)] :\n  finrank 𝕜 (X ⟶ X) = 1 :=\nbegin\n  have id_nonzero := (is_iso_iff_nonzero (𝟙 X)).mp (by apply_instance),\n  apply finrank_eq_one (𝟙 X),\n  { exact id_nonzero, },\n  { intro f,\n    haveI : nontrivial (End X) := nontrivial_of_ne _ _ id_nonzero,\n    obtain ⟨c, nu⟩ := @spectrum.nonempty_of_is_alg_closed_of_finite_dimensional 𝕜 (End X) _ _ _ _ _\n      (by { convert I, ext, refl, ext, refl, }) (End.of f),\n    use c,\n    rw [spectrum.mem_iff, is_unit.sub_iff, is_unit_iff_is_iso, is_iso_iff_nonzero, ne.def,\n      not_not, sub_eq_zero, algebra.algebra_map_eq_smul_one] at nu,\n    exact nu.symm, },\nend\n\nvariables [has_kernels C]\n\n/--\n**Schur's lemma** for endomorphisms in `𝕜`-linear categories.\n-/\nlemma finrank_endomorphism_simple_eq_one\n  (X : C) [simple.{v} X] [I : finite_dimensional 𝕜 (X ⟶ X)] :\n  finrank 𝕜 (X ⟶ X) = 1 :=\nfinrank_endomorphism_eq_one 𝕜 is_iso_iff_nonzero\n\nlemma endomorphism_simple_eq_smul_id\n  {X : C} [simple.{v} X] [I : finite_dimensional 𝕜 (X ⟶ X)] (f : X ⟶ X) :\n  ∃ c : 𝕜, c • 𝟙 X = f :=\n(finrank_eq_one_iff_of_nonzero' (𝟙 X) (id_nonzero X)).mp (finrank_endomorphism_simple_eq_one 𝕜 X) f\n\n/--\n**Schur's lemma** for `𝕜`-linear categories:\nif hom spaces are finite dimensional, then the hom space between simples is at most 1-dimensional.\n\nSee `finrank_hom_simple_simple_eq_one_iff` and `finrank_hom_simple_simple_eq_zero_iff` below\nfor the refinements when we know whether or not the simples are isomorphic.\n-/\n-- We don't really need `[∀ X Y : C, finite_dimensional 𝕜 (X ⟶ Y)]` here,\n-- just at least one of `[finite_dimensional 𝕜 (X ⟶ X)]` or `[finite_dimensional 𝕜 (Y ⟶ Y)]`.\nlemma finrank_hom_simple_simple_le_one\n  (X Y : C) [∀ X Y : C, finite_dimensional 𝕜 (X ⟶ Y)] [simple.{v} X] [simple.{v} Y] :\n  finrank 𝕜 (X ⟶ Y) ≤ 1 :=\nbegin\n  cases subsingleton_or_nontrivial (X ⟶ Y) with h,\n  { resetI,\n    convert zero_le_one,\n    exact finrank_zero_of_subsingleton, },\n  { obtain ⟨f, nz⟩ := (nontrivial_iff_exists_ne 0).mp h,\n    haveI fi := (is_iso_iff_nonzero f).mpr nz,\n    apply finrank_le_one f,\n    intro g,\n    obtain ⟨c, w⟩ := endomorphism_simple_eq_smul_id 𝕜 (g ≫ inv f),\n    exact ⟨c, by simpa using w =≫ f⟩, },\nend\n\nlemma finrank_hom_simple_simple_eq_one_iff\n  (X Y : C) [∀ X Y : C, finite_dimensional 𝕜 (X ⟶ Y)] [simple.{v} X] [simple.{v} Y] :\n  finrank 𝕜 (X ⟶ Y) = 1 ↔ nonempty (X ≅ Y) :=\nbegin\n  fsplit,\n  { intro h,\n    rw finrank_eq_one_iff' at h,\n    obtain ⟨f, nz, -⟩ := h,\n    rw ←is_iso_iff_nonzero at nz,\n    exactI ⟨as_iso f⟩, },\n  { rintro ⟨f⟩,\n    have le_one := finrank_hom_simple_simple_le_one 𝕜 X Y,\n    have zero_lt : 0 < finrank 𝕜 (X ⟶ Y) :=\n      finrank_pos_iff_exists_ne_zero.mpr ⟨f.hom, (is_iso_iff_nonzero f.hom).mp infer_instance⟩,\n    linarith, }\nend\n\nlemma finrank_hom_simple_simple_eq_zero_iff\n  (X Y : C) [∀ X Y : C, finite_dimensional 𝕜 (X ⟶ Y)] [simple.{v} X] [simple.{v} Y] :\n  finrank 𝕜 (X ⟶ Y) = 0 ↔ is_empty (X ≅ Y) :=\nbegin\n  rw [← not_nonempty_iff, ← not_congr (finrank_hom_simple_simple_eq_one_iff 𝕜 X Y)],\n  refine ⟨λ h, by { rw h, simp, }, λ h, _⟩,\n  have := finrank_hom_simple_simple_le_one 𝕜 X Y,\n  interval_cases finrank 𝕜 (X ⟶ Y) with h',\n  { exact h', },\n  { exact false.elim (h h'), },\nend\n\nend category_theory\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/category_theory/preadditive/schur.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.48636267373100706}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.group.inj_surj\nimport data.list.big_operators\nimport data.list.range\nimport group_theory.group_action.defs\nimport group_theory.submonoid.basic\nimport data.set_like.basic\nimport data.sigma.basic\n\n/-!\n# Additively-graded multiplicative structures\n\nThis module provides a set of heterogeneous typeclasses for defining a multiplicative structure\nover the sigma type `graded_monoid A` such that `(*) : A i → A j → A (i + j)`; that is to say, `A`\nforms an additively-graded monoid. The typeclasses are:\n\n* `graded_monoid.ghas_one A`\n* `graded_monoid.ghas_mul A`\n* `graded_monoid.gmonoid A`\n* `graded_monoid.gcomm_monoid A`\n\nWith the `sigma_graded` locale open, these respectively imbue:\n\n* `has_one (graded_monoid A)`\n* `has_mul (graded_monoid A)`\n* `monoid (graded_monoid A)`\n* `comm_monoid (graded_monoid A)`\n\nthe base type `A 0` with:\n\n* `graded_monoid.grade_zero.has_one`\n* `graded_monoid.grade_zero.has_mul`\n* `graded_monoid.grade_zero.monoid`\n* `graded_monoid.grade_zero.comm_monoid`\n\nand the `i`th grade `A i` with `A 0`-actions (`•`) defined as left-multiplication:\n\n* (nothing)\n* `graded_monoid.grade_zero.has_smul (A 0)`\n* `graded_monoid.grade_zero.mul_action (A 0)`\n* (nothing)\n\nFor now, these typeclasses are primarily used in the construction of `direct_sum.ring` and the rest\nof that file.\n\n## Dependent graded products\n\nThis also introduces `list.dprod`, which takes the (possibly non-commutative) product of a list\nof graded elements of type `A i`. This definition primarily exist to allow `graded_monoid.mk`\nand `direct_sum.of` to be pulled outside a product, such as in `graded_monoid.mk_list_dprod` and\n`direct_sum.of_list_dprod`.\n\n## Internally graded monoids\n\nIn addition to the above typeclasses, in the most frequent case when `A` is an indexed collection of\n`set_like` subobjects (such as `add_submonoid`s, `add_subgroup`s, or `submodule`s), this file\nprovides the `Prop` typeclasses:\n\n* `set_like.has_graded_one A` (which provides the obvious `graded_monoid.ghas_one A` instance)\n* `set_like.has_graded_mul A` (which provides the obvious `graded_monoid.ghas_mul A` instance)\n* `set_like.graded_monoid A` (which provides the obvious `graded_monoid.gmonoid A` and\n  `graded_monoid.gcomm_monoid A` instances)\n* `set_like.is_homogeneous A` (which says that `a` is homogeneous iff `a ∈ A i` for some `i : ι`)\n\nStrictly this last class is unecessary as it has no fields not present in its parents, but it is\nincluded for convenience. Note that there is no need for `graded_ring` or similar, as all the\ninformation it would contain is already supplied by `graded_monoid` when `A` is a collection\nof additively-closed set_like objects such as `submodule`s. These constructions are explored in\n`algebra.direct_sum.internal`.\n\nThis file also contains the definition of `set_like.homogeneous_submonoid A`, which is, as the name\nsuggests, the submonoid consisting of all the homogeneous elements.\n\n## tags\n\ngraded monoid\n-/\n\nset_option old_structure_cmd true\n\nvariables {ι : Type*}\n\n/-- A type alias of sigma types for graded monoids. -/\ndef graded_monoid (A : ι → Type*) := sigma A\n\nnamespace graded_monoid\n\ninstance {A : ι → Type*} [inhabited ι] [inhabited (A default)]: inhabited (graded_monoid A) :=\nsigma.inhabited\n\n/-- Construct an element of a graded monoid. -/\ndef mk {A : ι → Type*} : Π i, A i → graded_monoid A := sigma.mk\n\n/-! ### Typeclasses -/\nsection defs\n\nvariables (A : ι → Type*)\n\n/-- A graded version of `has_one`, which must be of grade 0. -/\nclass ghas_one [has_zero ι] :=\n(one : A 0)\n\n/-- `ghas_one` implies `has_one (graded_monoid A)` -/\ninstance ghas_one.to_has_one [has_zero ι] [ghas_one A] : has_one (graded_monoid A) :=\n⟨⟨_, ghas_one.one⟩⟩\n\n/-- A graded version of `has_mul`. Multiplication combines grades additively, like\n`add_monoid_algebra`. -/\nclass ghas_mul [has_add ι] :=\n(mul {i j} : A i → A j → A (i + j))\n\n/-- `ghas_mul` implies `has_mul (graded_monoid A)`. -/\ninstance ghas_mul.to_has_mul [has_add ι] [ghas_mul A] :\n  has_mul (graded_monoid A) :=\n⟨λ (x y : graded_monoid A), ⟨_, ghas_mul.mul x.snd y.snd⟩⟩\n\nlemma mk_mul_mk [has_add ι] [ghas_mul A] {i j} (a : A i) (b : A j) :\n  mk i a * mk j b = mk (i + j) (ghas_mul.mul a b) :=\nrfl\n\nnamespace gmonoid\n\nvariables {A} [add_monoid ι] [ghas_mul A] [ghas_one A]\n\n/-- A default implementation of power on a graded monoid, like `npow_rec`.\n`gmonoid.gnpow` should be used instead. -/\ndef gnpow_rec : Π (n : ℕ) {i}, A i → A (n • i)\n| 0 i a := cast (congr_arg A (zero_nsmul i).symm) ghas_one.one\n| (n + 1) i a := cast (congr_arg A (succ_nsmul i n).symm) (ghas_mul.mul a $ gnpow_rec _ a)\n\n@[simp] lemma gnpow_rec_zero (a : graded_monoid A) : graded_monoid.mk _ (gnpow_rec 0 a.snd) = 1 :=\nsigma.ext (zero_nsmul _) (heq_of_cast_eq _ rfl).symm\n\n/-- Tactic used to autofill `graded_monoid.gmonoid.gnpow_zero'` when the default\n`graded_monoid.gmonoid.gnpow_rec` is used. -/\nmeta def apply_gnpow_rec_zero_tac : tactic unit := `[apply graded_monoid.gmonoid.gnpow_rec_zero]\n\n@[simp] lemma gnpow_rec_succ (n : ℕ) (a : graded_monoid A) :\n  (graded_monoid.mk _ $ gnpow_rec n.succ a.snd) = a * ⟨_, gnpow_rec n a.snd⟩ :=\nsigma.ext (succ_nsmul _ _) (heq_of_cast_eq _ rfl).symm\n\n/-- Tactic used to autofill `graded_monoid.gmonoid.gnpow_succ'` when the default\n`graded_monoid.gmonoid.gnpow_rec` is used. -/\nmeta def apply_gnpow_rec_succ_tac : tactic unit := `[apply graded_monoid.gmonoid.gnpow_rec_succ]\n\nend gmonoid\n\n/-- A graded version of `monoid`.\n\nLike `monoid.npow`, this has an optional `gmonoid.gnpow` field to allow definitional control of\nnatural powers of a graded monoid. -/\nclass gmonoid [add_monoid ι]  extends ghas_mul A, ghas_one A :=\n(one_mul (a : graded_monoid A) : 1 * a = a)\n(mul_one (a : graded_monoid A) : a * 1 = a)\n(mul_assoc (a b c : graded_monoid A) : a * b * c = a * (b * c))\n(gnpow : Π (n : ℕ) {i}, A i → A (n • i) := gmonoid.gnpow_rec)\n(gnpow_zero' : Π (a : graded_monoid A), graded_monoid.mk _ (gnpow 0 a.snd) = 1\n  . gmonoid.apply_gnpow_rec_zero_tac)\n(gnpow_succ' : Π (n : ℕ) (a : graded_monoid A),\n  (graded_monoid.mk _ $ gnpow n.succ a.snd) = a * ⟨_, gnpow n a.snd⟩\n  . gmonoid.apply_gnpow_rec_succ_tac)\n\n/-- `gmonoid` implies a `monoid (graded_monoid A)`. -/\ninstance gmonoid.to_monoid [add_monoid ι] [gmonoid A] :\n  monoid (graded_monoid A) :=\n{ one := (1), mul := (*),\n  npow := λ n a, graded_monoid.mk _ (gmonoid.gnpow n a.snd),\n  npow_zero' := λ a, gmonoid.gnpow_zero' a,\n  npow_succ' := λ n a, gmonoid.gnpow_succ' n a,\n  one_mul := gmonoid.one_mul, mul_one := gmonoid.mul_one, mul_assoc := gmonoid.mul_assoc }\n\nlemma mk_pow [add_monoid ι] [gmonoid A] {i} (a : A i) (n : ℕ) :\n  mk i a ^ n = mk (n • i) (gmonoid.gnpow _ a) :=\nbegin\n  induction n with n,\n  { rw [pow_zero],\n    exact (gmonoid.gnpow_zero' ⟨_, a⟩).symm, },\n  { rw [pow_succ, n_ih, mk_mul_mk],\n    exact (gmonoid.gnpow_succ' n ⟨_, a⟩).symm, },\nend\n\n/-- A graded version of `comm_monoid`. -/\nclass gcomm_monoid [add_comm_monoid ι] extends gmonoid A :=\n(mul_comm (a : graded_monoid A) (b : graded_monoid A) : a * b = b * a)\n\n/-- `gcomm_monoid` implies a `comm_monoid (graded_monoid A)`, although this is only used as an\ninstance locally to define notation in `gmonoid` and similar typeclasses. -/\ninstance gcomm_monoid.to_comm_monoid [add_comm_monoid ι] [gcomm_monoid A] :\n  comm_monoid (graded_monoid A) :=\n{ mul_comm := gcomm_monoid.mul_comm, ..gmonoid.to_monoid A }\n\nend defs\n\n\n/-! ### Instances for `A 0`\n\nThe various `g*` instances are enough to promote the `add_comm_monoid (A 0)` structure to various\ntypes of multiplicative structure.\n-/\n\nsection grade_zero\n\nvariables (A : ι → Type*)\n\nsection one\nvariables [has_zero ι] [ghas_one A]\n\n/-- `1 : A 0` is the value provided in `ghas_one.one`. -/\n@[nolint unused_arguments]\ninstance grade_zero.has_one : has_one (A 0) :=\n⟨ghas_one.one⟩\n\nend one\n\nsection mul\nvariables [add_zero_class ι] [ghas_mul A]\n\n/-- `(•) : A 0 → A i → A i` is the value provided in `graded_monoid.ghas_mul.mul`, composed with\nan `eq.rec` to turn `A (0 + i)` into `A i`.\n-/\ninstance grade_zero.has_smul (i : ι) : has_smul (A 0) (A i) :=\n{ smul := λ x y, (zero_add i).rec (ghas_mul.mul x y) }\n\n/-- `(*) : A 0 → A 0 → A 0` is the value provided in `graded_monoid.ghas_mul.mul`, composed with\nan `eq.rec` to turn `A (0 + 0)` into `A 0`.\n-/\ninstance grade_zero.has_mul : has_mul (A 0) :=\n{ mul := (•) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_smul {i} (a : A 0) (b : A i) : mk _ (a • b) = mk _ a * mk _ b :=\nsigma.ext (zero_add _).symm $ eq_rec_heq _ _\n\n@[simp] lemma grade_zero.smul_eq_mul (a b : A 0) : a • b = a * b := rfl\n\n\nend mul\n\nsection monoid\nvariables [add_monoid ι] [gmonoid A]\n\ninstance : has_pow (A 0) ℕ :=\n{ pow := λ x n, (nsmul_zero n).rec (gmonoid.gnpow n x : A (n • 0)) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_pow (a : A 0) (n : ℕ) : mk _ (a ^ n) = mk _ a ^ n :=\nsigma.ext (nsmul_zero n).symm $ eq_rec_heq _ _\n\nvariables (A)\n\n/-- The `monoid` structure derived from `gmonoid A`. -/\ninstance grade_zero.monoid : monoid (A 0) :=\nfunction.injective.monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow\n\nend monoid\n\nsection monoid\nvariables [add_comm_monoid ι] [gcomm_monoid A]\n\n/-- The `comm_monoid` structure derived from `gcomm_monoid A`. -/\ninstance grade_zero.comm_monoid : comm_monoid (A 0) :=\nfunction.injective.comm_monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow\n\nend monoid\n\nsection mul_action\nvariables [add_monoid ι] [gmonoid A]\n\n/-- `graded_monoid.mk 0` is a `monoid_hom`, using the `graded_monoid.grade_zero.monoid` structure.\n-/\ndef mk_zero_monoid_hom : A 0 →* (graded_monoid A) :=\n{ to_fun := mk 0, map_one' := rfl, map_mul' := mk_zero_smul }\n\n/-- Each grade `A i` derives a `A 0`-action structure from `gmonoid A`. -/\ninstance grade_zero.mul_action {i} : mul_action (A 0) (A i) :=\nbegin\n  letI := mul_action.comp_hom (graded_monoid A) (mk_zero_monoid_hom A),\n  exact function.injective.mul_action (mk i) sigma_mk_injective mk_zero_smul,\nend\n\nend mul_action\n\nend grade_zero\n\nend graded_monoid\n\n/-! ### Dependent products of graded elements -/\n\nsection dprod\n\nvariables {α : Type*} {A : ι → Type*} [add_monoid ι] [graded_monoid.gmonoid A]\n\n/-- The index used by `list.dprod`. Propositionally this is equal to `(l.map fι).sum`, but\ndefinitionally it needs to have a different form to avoid introducing `eq.rec`s in `list.dprod`. -/\ndef list.dprod_index (l : list α) (fι : α → ι) : ι :=\nl.foldr (λ i b, fι i + b) 0\n\n@[simp] lemma list.dprod_index_nil (fι : α → ι) : ([] : list α).dprod_index fι = 0 := rfl\n@[simp] lemma list.dprod_index_cons (a : α) (l : list α) (fι : α → ι) :\n  (a :: l).dprod_index fι = fι a + l.dprod_index fι := rfl\n\nlemma list.dprod_index_eq_map_sum (l : list α) (fι : α → ι) :\n  l.dprod_index fι = (l.map fι).sum :=\nbegin\n  dunfold list.dprod_index,\n  induction l,\n  { simp, },\n  { simp [l_ih], },\nend\n\n/-- A dependent product for graded monoids represented by the indexed family of types `A i`.\nThis is a dependent version of `(l.map fA).prod`.\n\nFor a list `l : list α`, this computes the product of `fA a` over `a`, where each `fA` is of type\n`A (fι a)`. -/\ndef list.dprod (l : list α) (fι : α → ι) (fA : Π a, A (fι a)) :\n  A (l.dprod_index fι) :=\nl.foldr_rec_on _ _ graded_monoid.ghas_one.one (λ i x a ha, graded_monoid.ghas_mul.mul (fA a) x)\n\n@[simp] lemma list.dprod_nil (fι : α → ι) (fA : Π a, A (fι a)) :\n  (list.nil : list α).dprod fι fA = graded_monoid.ghas_one.one := rfl\n\n-- the `( : _)` in this lemma statement results in the type on the RHS not being unfolded, which\n-- is nicer in the goal view.\n@[simp] lemma list.dprod_cons (fι : α → ι) (fA : Π a, A (fι a)) (a : α) (l : list α) :\n  (a :: l).dprod fι fA = (graded_monoid.ghas_mul.mul (fA a) (l.dprod fι fA) : _) := rfl\n\nlemma graded_monoid.mk_list_dprod (l : list α) (fι : α → ι) (fA : Π a, A (fι a)) :\n  graded_monoid.mk _ (l.dprod fι fA) = (l.map (λ a, graded_monoid.mk (fι a) (fA a))).prod :=\nbegin\n  induction l,\n  { simp, refl  },\n  { simp [←l_ih, graded_monoid.mk_mul_mk, list.prod_cons],\n    refl, },\nend\n\n/-- A variant of `graded_monoid.mk_list_dprod` for rewriting in the other direction. -/\nlemma graded_monoid.list_prod_map_eq_dprod (l : list α) (f : α → graded_monoid A) :\n  (l.map f).prod = graded_monoid.mk _ (l.dprod (λ i, (f i).1) (λ i, (f i).2)) :=\nbegin\n  rw [graded_monoid.mk_list_dprod, graded_monoid.mk],\n  simp_rw sigma.eta,\nend\n\nlemma graded_monoid.list_prod_of_fn_eq_dprod {n : ℕ} (f : fin n → graded_monoid A) :\n  (list.of_fn f).prod =\n    graded_monoid.mk _ ((list.fin_range n).dprod (λ i, (f i).1) (λ i, (f i).2)) :=\nby rw [list.of_fn_eq_map, graded_monoid.list_prod_map_eq_dprod]\n\nend dprod\n\n/-! ### Concrete instances -/\nsection\n\nvariables (ι) {R : Type*}\n\n@[simps one]\ninstance has_one.ghas_one [has_zero ι] [has_one R] : graded_monoid.ghas_one (λ i : ι, R) :=\n{ one := 1 }\n\n@[simps mul]\ninstance has_mul.ghas_mul [has_add ι] [has_mul R] : graded_monoid.ghas_mul (λ i : ι, R) :=\n{ mul := λ i j, (*) }\n\n/-- If all grades are the same type and themselves form a monoid, then there is a trivial grading\nstructure. -/\n@[simps gnpow]\ninstance monoid.gmonoid [add_monoid ι] [monoid R] : graded_monoid.gmonoid (λ i : ι, R) :=\n{ one_mul := λ a, sigma.ext (zero_add _) (heq_of_eq (one_mul _)),\n  mul_one := λ a, sigma.ext (add_zero _) (heq_of_eq (mul_one _)),\n  mul_assoc := λ a b c, sigma.ext (add_assoc _ _ _) (heq_of_eq (mul_assoc _ _ _)),\n  gnpow := λ n i a, a ^ n,\n  gnpow_zero' := λ a, sigma.ext (zero_nsmul _) (heq_of_eq (monoid.npow_zero' _)),\n  gnpow_succ' := λ n ⟨i, a⟩, sigma.ext (succ_nsmul _ _) (heq_of_eq (monoid.npow_succ' _ _)),\n  ..has_one.ghas_one ι,\n  ..has_mul.ghas_mul ι }\n\n/-- If all grades are the same type and themselves form a commutative monoid, then there is a\ntrivial grading structure. -/\ninstance comm_monoid.gcomm_monoid [add_comm_monoid ι] [comm_monoid R] :\n  graded_monoid.gcomm_monoid (λ i : ι, R) :=\n{ mul_comm := λ a b, sigma.ext (add_comm _ _) (heq_of_eq (mul_comm _ _)),\n  ..monoid.gmonoid ι }\n\n/-- When all the indexed types are the same, the dependent product is just the regular product. -/\n@[simp] lemma list.dprod_monoid {α} [add_monoid ι] [monoid R] (l : list α) (fι : α → ι)\n  (fA : α → R) :\n  (l.dprod fι fA : (λ i : ι, R) _) = ((l.map fA).prod : _) :=\nbegin\n  induction l,\n  { rw [list.dprod_nil, list.map_nil, list.prod_nil], refl },\n  { rw [list.dprod_cons, list.map_cons, list.prod_cons, l_ih], refl },\nend\n\nend\n\n/-! ### Shorthands for creating instance of the above typeclasses for collections of subobjects -/\n\nsection subobjects\n\nvariables {R : Type*}\n\n/-- A version of `graded_monoid.ghas_one` for internally graded objects. -/\nclass set_like.has_graded_one {S : Type*} [set_like S R] [has_one R] [has_zero ι]\n  (A : ι → S) : Prop :=\n(one_mem : (1 : R) ∈ A 0)\n\ninstance set_like.ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero ι] (A : ι → S)\n  [set_like.has_graded_one A] : graded_monoid.ghas_one (λ i, A i) :=\n{ one := ⟨1, set_like.has_graded_one.one_mem⟩ }\n\n@[simp] lemma set_like.coe_ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero ι] (A : ι → S)\n  [set_like.has_graded_one A] : ↑(@graded_monoid.ghas_one.one _ (λ i, A i) _ _) = (1 : R) := rfl\n\n/-- A version of `graded_monoid.ghas_one` for internally graded objects. -/\nclass set_like.has_graded_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι]\n  (A : ι → S) : Prop :=\n(mul_mem : ∀ ⦃i j⦄ {gi gj}, gi ∈ A i → gj ∈ A j → gi * gj ∈ A (i + j))\n\ninstance set_like.ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι] (A : ι → S)\n  [set_like.has_graded_mul A] :\n  graded_monoid.ghas_mul (λ i, A i) :=\n{ mul := λ i j a b, ⟨(a * b : R), set_like.has_graded_mul.mul_mem a.prop b.prop⟩ }\n\n@[simp] lemma set_like.coe_ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι] (A : ι → S)\n  [set_like.has_graded_mul A] {i j : ι} (x : A i) (y : A j) :\n    ↑(@graded_monoid.ghas_mul.mul _ (λ i, A i) _ _ _ _ x y) = (x * y : R) := rfl\n\n/-- A version of `graded_monoid.gmonoid` for internally graded objects. -/\nclass set_like.graded_monoid {S : Type*} [set_like S R] [monoid R] [add_monoid ι]\n  (A : ι → S) extends set_like.has_graded_one A, set_like.has_graded_mul A : Prop\n\nnamespace set_like.graded_monoid\nvariables {S : Type*} [set_like S R] [monoid R] [add_monoid ι]\nvariables {A : ι → S} [set_like.graded_monoid A]\n\nlemma pow_mem (n : ℕ) {r : R} {i : ι} (h : r ∈ A i) : r ^ n ∈ A (n • i) :=\nbegin\n  induction n,\n  { rw [pow_zero, zero_nsmul], exact one_mem },\n  { rw [pow_succ', succ_nsmul'], exact mul_mem n_ih h },\nend\n\nlemma list_prod_map_mem {ι'} (l : list ι') (i : ι' → ι) (r : ι' → R) (h : ∀ j ∈ l, r j ∈ A (i j)) :\n  (l.map r).prod ∈ A (l.map i).sum :=\nbegin\n  induction l,\n  { rw [list.map_nil, list.map_nil, list.prod_nil, list.sum_nil],\n    exact one_mem },\n  { rw [list.map_cons, list.map_cons, list.prod_cons, list.sum_cons],\n    exact mul_mem (h _ $ list.mem_cons_self _ _) (l_ih $ λ j hj, h _ $ list.mem_cons_of_mem _ hj) },\nend\n\nlemma list_prod_of_fn_mem {n} (i : fin n → ι) (r : fin n → R) (h : ∀ j, r j ∈ A (i j)) :\n  (list.of_fn r).prod ∈ A (list.of_fn i).sum :=\nbegin\n  rw [list.of_fn_eq_map, list.of_fn_eq_map],\n  exact list_prod_map_mem _ _ _ (λ _ _, h _),\nend\n\nend set_like.graded_monoid\n\n/-- Build a `gmonoid` instance for a collection of subobjects. -/\ninstance set_like.gmonoid {S : Type*} [set_like S R] [monoid R] [add_monoid ι] (A : ι → S)\n  [set_like.graded_monoid A] :\n  graded_monoid.gmonoid (λ i, A i) :=\n{ one_mul := λ ⟨i, a, h⟩, sigma.subtype_ext (zero_add _) (one_mul _),\n  mul_one := λ ⟨i, a, h⟩, sigma.subtype_ext (add_zero _) (mul_one _),\n  mul_assoc := λ ⟨i, a, ha⟩ ⟨j, b, hb⟩ ⟨k, c, hc⟩,\n    sigma.subtype_ext (add_assoc _ _ _) (mul_assoc _ _ _),\n  gnpow := λ n i a, ⟨a ^ n, set_like.graded_monoid.pow_mem n a.prop⟩,\n  gnpow_zero' := λ n, sigma.subtype_ext (zero_nsmul _) (pow_zero _),\n  gnpow_succ' := λ n a, sigma.subtype_ext (succ_nsmul _ _) (pow_succ _ _),\n  ..set_like.ghas_one A,\n  ..set_like.ghas_mul A }\n\n@[simp] lemma set_like.coe_gnpow {S : Type*} [set_like S R] [monoid R] [add_monoid ι] (A : ι → S)\n  [set_like.graded_monoid A] {i : ι} (x : A i) (n : ℕ) :\n    ↑(@graded_monoid.gmonoid.gnpow _ (λ i, A i) _ _ n _ x) = (x ^ n : R) := rfl\n\n/-- Build a `gcomm_monoid` instance for a collection of subobjects. -/\ninstance set_like.gcomm_monoid {S : Type*} [set_like S R] [comm_monoid R] [add_comm_monoid ι]\n  (A : ι → S) [set_like.graded_monoid A] :\n  graded_monoid.gcomm_monoid (λ i, A i) :=\n{ mul_comm := λ ⟨i, a, ha⟩ ⟨j, b, hb⟩, sigma.subtype_ext (add_comm _ _) (mul_comm _ _),\n  ..set_like.gmonoid A}\n\nsection dprod\nopen set_like set_like.graded_monoid\nvariables {α S : Type*} [set_like S R] [monoid R] [add_monoid ι]\n\n/-- Coercing a dependent product of subtypes is the same as taking the regular product of the\ncoercions. -/\n@[simp] lemma set_like.coe_list_dprod (A : ι → S) [set_like.graded_monoid A]\n  (fι : α → ι) (fA : Π a, A (fι a)) (l : list α) :\n  ↑(l.dprod fι fA : (λ i, ↥(A i)) _) = (list.prod (l.map (λ a, fA a)) : R) :=\nbegin\n  induction l,\n  { rw [list.dprod_nil, coe_ghas_one, list.map_nil, list.prod_nil] },\n  { rw [list.dprod_cons, coe_ghas_mul, list.map_cons, list.prod_cons, l_ih], },\nend\n\ninclude R\n\n/-- A version of `list.coe_dprod_set_like` with `subtype.mk`. -/\nlemma set_like.list_dprod_eq (A : ι → S) [set_like.graded_monoid A]\n  (fι : α → ι) (fA : Π a, A (fι a)) (l : list α) :\n  (l.dprod fι fA : (λ i, ↥(A i)) _) =\n    ⟨list.prod (l.map (λ a, fA a)), (l.dprod_index_eq_map_sum fι).symm ▸\n      list_prod_map_mem l _ _ (λ i hi, (fA i).prop)⟩ :=\nsubtype.ext $ set_like.coe_list_dprod _ _ _ _\n\nend dprod\n\nend subobjects\n\nsection homogeneous_elements\n\nvariables {R S : Type*} [set_like S R]\n\n/-- An element `a : R` is said to be homogeneous if there is some `i : ι` such that `a ∈ A i`. -/\ndef set_like.is_homogeneous (A : ι → S) (a : R) : Prop := ∃ i, a ∈ A i\n\n@[simp] lemma set_like.is_homogeneous_coe {A : ι → S} {i} (x : A i) :\n  set_like.is_homogeneous A (x : R) :=\n⟨i, x.prop⟩\n\nlemma set_like.is_homogeneous_one [has_zero ι] [has_one R]\n  (A : ι → S) [set_like.has_graded_one A] : set_like.is_homogeneous A (1 : R) :=\n⟨0, set_like.has_graded_one.one_mem⟩\n\nlemma set_like.is_homogeneous.mul [has_add ι] [has_mul R] {A : ι → S}\n  [set_like.has_graded_mul A] {a b : R} :\n  set_like.is_homogeneous A a → set_like.is_homogeneous A b → set_like.is_homogeneous A (a * b)\n| ⟨i, hi⟩ ⟨j, hj⟩ := ⟨i + j, set_like.has_graded_mul.mul_mem hi hj⟩\n\n/-- When `A` is a `set_like.graded_monoid A`, then the homogeneous elements forms a submonoid. -/\ndef set_like.homogeneous_submonoid [add_monoid ι] [monoid R]\n  (A : ι → S) [set_like.graded_monoid A] : submonoid R :=\n{ carrier := { a | set_like.is_homogeneous A a },\n  one_mem' := set_like.is_homogeneous_one A,\n  mul_mem' := λ a b, set_like.is_homogeneous.mul }\n\nend homogeneous_elements\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/algebra/graded_monoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837527911057, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4863626616133825}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport topology.algebra.module\n\ntheorem continuous_linear_map.is_linear {R : Type*} [semiring R] {M : Type*} [topological_space M]\n  [add_comm_monoid M] {M₂ : Type*} [topological_space M₂] [add_comm_monoid M₂] [module R M]\n  [module R M₂] (f : M →L[R] M₂) :\n  is_linear_map R ⇑f :=\nf.to_linear_map.is_linear\n", "meta": {"author": "mmasdeu", "repo": "brouwerfixedpoint", "sha": "548270f79ecf12d7e20a256806ccb9fcf57b87e2", "save_path": "github-repos/lean/mmasdeu-brouwerfixedpoint", "path": "github-repos/lean/mmasdeu-brouwerfixedpoint/brouwerfixedpoint-548270f79ecf12d7e20a256806ccb9fcf57b87e2/src/combinatorics/simplicial_complex/to_move/continuous_linear_map.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837527911057, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4863626510910962}}
{"text": "/-\nCopyright (c) 2015 Haitao Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n\nAuthor : Haitao Zhang\n-/\nimport algebra.group data .hom .perm .finsubg\n\nnamespace group_theory\nopen finset function\n\nlocal attribute perm.f [coercion]\n\nprivate lemma and_left_true {a b : Prop} (Pa : a) : a ∧ b ↔ b :=\nby rewrite [iff_true_intro Pa, true_and]\n\nsection def\nvariables {G S : Type} [group G] [fintype S]\n\ndefinition is_fixed_point (hom : G → perm S) (H : finset G) (a : S) : Prop :=\n∀ h, h ∈ H → hom h a = a\n\nvariables [decidable_eq S]\n\ndefinition orbit (hom : G → perm S) (H : finset G) (a : S) : finset S :=\n           image (move_by a) (image hom H)\n\ndefinition fixed_points [reducible] (hom : G → perm S) (H : finset G) : finset S :=\n{a ∈ univ | orbit hom H a = '{a}}\n\nvariable [decidable_eq G] -- required by {x ∈ H |p x} filtering\n\ndefinition moverset (hom : G → perm S) (H : finset G) (a b : S) : finset G :=\n           {f ∈ H | hom f a = b}\n\ndefinition stab (hom : G → perm S) (H : finset G) (a : S) : finset G :=\n           {f ∈ H | hom f a = a}\n\nend def\n\nsection orbit_stabilizer\n\nvariables {G S : Type} [group G] [decidable_eq G] [fintype S] [decidable_eq S]\n\nsection\n\nvariables {hom : G → perm S} {H : finset G} {a : S} [Hom : is_hom_class hom]\ninclude Hom\n\nlemma exists_of_orbit {b : S} : b ∈ orbit hom H a → ∃ h, h ∈ H ∧ hom h a = b :=\n      assume Pb,\n      obtain p (Pp₁ : p ∈ image hom H) (Pp₂ : move_by a p = b), from exists_of_mem_image Pb,\n      obtain h (Ph₁ : h ∈ H) (Ph₂ : hom h = p), from exists_of_mem_image Pp₁,\n      have Phab : hom h a = b, from calc\n        hom h a = p a : Ph₂\n            ... = b   : Pp₂,\n      exists.intro h (and.intro Ph₁ Phab)\n\nlemma orbit_of_exists {b : S} : (∃ h, h ∈ H ∧ hom h a = b) → b ∈ orbit hom H a :=\nassume Pex, obtain h PinH Phab, from Pex,\nmem_image (mem_image_of_mem hom PinH) Phab\n\nlemma is_fixed_point_of_mem_fixed_points :\n  a ∈ fixed_points hom H → is_fixed_point hom H a :=\nassume Pain, take h, assume Phin,\n  eq_of_mem_singleton\n    (of_mem_sep Pain ▸ orbit_of_exists (exists.intro h (and.intro Phin rfl)))\n\nlemma mem_fixed_points_of_exists_of_is_fixed_point :\n  (∃ h, h ∈ H) → is_fixed_point hom H a → a ∈ fixed_points hom H :=\nassume Pex Pfp, mem_sep_of_mem !mem_univ\n  (ext take x, iff.intro\n    (assume Porb, obtain h Phin Pha, from exists_of_orbit Porb,\n      by rewrite [mem_singleton_iff, -Pha, Pfp h Phin])\n    (obtain h Phin, from Pex,\n      by rewrite mem_singleton_iff;\n         intro Peq; rewrite Peq;\n         apply orbit_of_exists;\n         existsi h; apply and.intro Phin (Pfp h Phin)))\n\nlemma is_fixed_point_iff_mem_fixed_points_of_exists :\n  (∃ h, h ∈ H) → (a ∈ fixed_points hom H ↔ is_fixed_point hom H a) :=\nassume Pex, iff.intro is_fixed_point_of_mem_fixed_points (mem_fixed_points_of_exists_of_is_fixed_point Pex)\n\nlemma is_fixed_point_iff_mem_fixed_points [finsubgH : is_finsubg H] :\n  a ∈ fixed_points hom H ↔ is_fixed_point hom H a :=\nis_fixed_point_iff_mem_fixed_points_of_exists (exists.intro 1 !finsubg_has_one)\n\nlemma is_fixed_point_of_one : is_fixed_point hom ('{1}) a :=\ntake h, assume Ph, by rewrite [eq_of_mem_singleton Ph, hom_map_one]\n\nlemma fixed_points_of_one : fixed_points hom ('{1}) = univ :=\next take s, iff.intro (assume Pl, mem_univ s)\n  (assume Pr, mem_fixed_points_of_exists_of_is_fixed_point\n    (exists.intro 1 !mem_singleton) is_fixed_point_of_one)\n\nopen fintype\nlemma card_fixed_points_of_one : card (fixed_points hom ('{1})) = card S :=\nby rewrite [fixed_points_of_one]\n\nend\n\n-- these are already specified by stab hom H a\nvariables {hom : G → perm S} {H : finset G} {a : S}\n\nvariable [Hom : is_hom_class hom]\ninclude Hom\n\nlemma perm_f_mul (f g : G): perm.f ((hom f) * (hom g)) a = ((hom f) ∘ (hom g)) a :=\nrfl\n\nlemma stab_lmul {f g : G} : g ∈ stab hom H a → hom (f*g) a = hom f a :=\nassume Pgstab,\nhave hom g a = a, from of_mem_sep Pgstab, calc\n  hom (f*g) a = perm.f ((hom f) * (hom g)) a : is_hom hom\n          ... = ((hom f) ∘ (hom g)) a        : by rewrite perm_f_mul\n          ... = (hom f) a                    : by unfold comp; rewrite this\n\nlemma stab_subset : stab hom H a ⊆ H :=\n      begin\n        apply subset_of_forall, intro f Pfstab, apply mem_of_mem_sep Pfstab\n      end\n\nlemma reverse_move {h g : G} : g ∈ moverset hom H a (hom h a) → hom (h⁻¹*g) a = a :=\nassume Pg,\nhave hom g a = hom h a, from of_mem_sep Pg, calc\n  hom (h⁻¹*g) a = perm.f ((hom h⁻¹) * (hom g)) a : by rewrite (is_hom hom)\n  ... = ((hom h⁻¹) ∘ hom g) a                    : by rewrite perm_f_mul\n  ... = perm.f ((hom h)⁻¹ * hom h) a             : by unfold comp; rewrite [this, perm_f_mul, hom_map_inv hom h]\n  ... = perm.f (1 : perm S) a                    : by rewrite (mul.left_inv (hom h))\n  ... = a                                        : by esimp\n\nlemma moverset_inj_on_orbit : set.inj_on (moverset hom H a) (ts (orbit hom H a)) :=\n      take b1 b2,\n      assume Pb1, obtain h1 Ph1₁ Ph1₂, from exists_of_orbit Pb1,\n      have Ph1b1 : h1 ∈ moverset hom H a b1,\n        from mem_sep_of_mem Ph1₁ Ph1₂,\n      assume Psetb2 Pmeq, begin\n        subst b1,\n        rewrite Pmeq at Ph1b1,\n        apply of_mem_sep Ph1b1\n      end\n\nvariable [finsubgH : is_finsubg H]\ninclude finsubgH\n\nlemma subg_stab_of_move {h g : G} :\n      h ∈ H → g ∈ moverset hom H a (hom h a) → h⁻¹*g ∈ stab hom H a :=\n      assume Ph Pg,\n      have Phinvg : h⁻¹*g ∈ H, from begin\n        apply finsubg_mul_closed H,\n          apply finsubg_has_inv H, assumption,\n          apply mem_of_mem_sep Pg\n        end,\n      mem_sep_of_mem Phinvg (reverse_move Pg)\n\nlemma subg_stab_closed : finset_mul_closed_on (stab hom H a) :=\n      take f g, assume Pfstab, have Pf : hom f a = a, from of_mem_sep Pfstab,\n      assume Pgstab,\n      have Pfg : hom (f*g) a = a, from calc\n        hom (f*g) a = (hom f) a : stab_lmul Pgstab\n        ... = a : Pf,\n      have PfginH : (f*g) ∈ H,\n        from finsubg_mul_closed H (mem_of_mem_sep Pfstab) (mem_of_mem_sep Pgstab),\n      mem_sep_of_mem PfginH Pfg\n\nlemma subg_stab_has_one : 1 ∈ stab hom H a :=\n      have P : hom 1 a = a, from calc\n        hom 1 a = perm.f (1 : perm S) a : {hom_map_one hom}\n        ... = a                         : rfl,\n      have PoneinH : 1 ∈ H, from finsubg_has_one H,\n      mem_sep_of_mem PoneinH P\n\nlemma subg_stab_has_inv : finset_has_inv (stab hom H a) :=\n      take f, assume Pfstab, have Pf : hom f a = a, from of_mem_sep Pfstab,\n      have Pfinv : hom f⁻¹ a = a, from calc\n        hom f⁻¹ a = hom f⁻¹ ((hom f) a)      : by rewrite Pf\n        ... = perm.f ((hom f⁻¹) * (hom f)) a : by rewrite perm_f_mul\n        ... = hom (f⁻¹ * f) a                : by rewrite (is_hom hom)\n        ... = hom 1 a                        : by rewrite mul.left_inv\n        ... = perm.f (1 : perm S) a          : by rewrite (hom_map_one hom),\n      have PfinvinH : f⁻¹ ∈ H, from finsubg_has_inv H (mem_of_mem_sep Pfstab),\n      mem_sep_of_mem PfinvinH Pfinv\n\ndefinition subg_stab_is_finsubg [instance] :\n           is_finsubg (stab hom H a) :=\n           is_finsubg.mk subg_stab_has_one subg_stab_closed subg_stab_has_inv\n\nlemma subg_lcoset_eq_moverset {h : G} :\n      h ∈ H → fin_lcoset (stab hom H a) h = moverset hom H a (hom h a) :=\n      assume Ph, ext (take g, iff.intro\n      (assume Pl, obtain f (Pf₁ : f ∈ stab hom H a) (Pf₂ : h*f = g), from exists_of_mem_image Pl,\n       have Pfstab : hom f a = a, from of_mem_sep Pf₁,\n       have PginH : g ∈ H, begin\n        subst Pf₂,\n        apply finsubg_mul_closed H,\n          assumption,\n          apply mem_of_mem_sep Pf₁\n        end,\n      have Pga : hom g a = hom h a, from calc\n        hom g a = hom (h*f) a : by subst g\n        ... = hom h a         : stab_lmul Pf₁,\n      mem_sep_of_mem PginH Pga)\n      (assume Pr, begin\n       rewrite [↑fin_lcoset, mem_image_iff],\n       existsi h⁻¹*g,\n       split,\n         exact subg_stab_of_move Ph Pr,\n         apply mul_inv_cancel_left\n       end))\n\nlemma subg_moverset_of_orbit_is_lcoset_of_stab (b : S) :\n      b ∈ orbit hom H a → ∃ h, h ∈ H ∧ fin_lcoset (stab hom H a) h = moverset hom H a b :=\n      assume Porb,\n      obtain p (Pp₁ : p ∈ image hom H) (Pp₂ : move_by a p = b), from exists_of_mem_image Porb,\n      obtain h (Ph₁ : h ∈ H) (Ph₂ : hom h = p), from exists_of_mem_image Pp₁,\n      have Phab : hom h a = b, from by subst p; assumption,\n      exists.intro h (and.intro Ph₁ (Phab ▸ subg_lcoset_eq_moverset Ph₁))\n\nlemma subg_lcoset_of_stab_is_moverset_of_orbit (h : G) :\n      h ∈ H → ∃ b, b ∈ orbit hom H a ∧ moverset hom H a b = fin_lcoset (stab hom H a) h :=\n      assume Ph,\n      have Pha : (hom h a) ∈ orbit hom H a, by\n        apply mem_image_of_mem; apply mem_image_of_mem; exact Ph,\n      exists.intro (hom h a) (and.intro Pha (eq.symm (subg_lcoset_eq_moverset Ph)))\n\nlemma subg_moversets_of_orbit_eq_stab_lcosets :\n      image (moverset hom H a) (orbit hom H a) = fin_lcosets (stab hom H a) H :=\n      ext (take s, iff.intro\n      (assume Pl, obtain b Pb₁ Pb₂, from exists_of_mem_image Pl,\n      obtain h Ph, from subg_moverset_of_orbit_is_lcoset_of_stab b Pb₁, begin\n      rewrite [↑fin_lcosets, mem_image_eq],\n      existsi h, subst Pb₂, assumption\n      end)\n      (assume Pr, obtain h Ph₁ Ph₂, from exists_of_mem_image Pr,\n      obtain b Pb, from @subg_lcoset_of_stab_is_moverset_of_orbit G S _ _ _ _ hom H a Hom _ h Ph₁, begin\n      rewrite [mem_image_eq],\n      existsi b, subst Ph₂, assumption\n      end))\n\nopen nat\n\ntheorem orbit_stabilizer_theorem : card H = card (orbit hom H a) * card (stab hom H a) :=\n        calc card H = card (fin_lcosets (stab hom H a) H) * card (stab hom H a) : lagrange_theorem stab_subset\n        ... = card (image (moverset hom H a) (orbit hom H a)) * card (stab hom H a) : subg_moversets_of_orbit_eq_stab_lcosets\n        ... = card (orbit hom H a) * card (stab hom H a) : card_image_eq_of_inj_on moverset_inj_on_orbit\n\nend orbit_stabilizer\n\nsection orbit_partition\n\nvariables {G S : Type} [group G] [decidable_eq G] [fintype S] [decidable_eq S]\nvariables {hom : G → perm S} [Hom : is_hom_class hom] {H : finset G} [subgH : is_finsubg H]\ninclude Hom subgH\n\nlemma in_orbit_refl {a : S} : a ∈ orbit hom H a :=\nmem_image (mem_image (finsubg_has_one H) (hom_map_one hom)) rfl\n\nlemma in_orbit_trans {a b c : S} :\n  a ∈ orbit hom H b → b ∈ orbit hom H c → a ∈ orbit hom H c :=\nassume Painb Pbinc,\nobtain h PhinH Phba, from exists_of_orbit Painb,\nobtain g PginH Pgcb, from exists_of_orbit Pbinc,\norbit_of_exists (exists.intro (h*g) (and.intro\n  (finsubg_mul_closed H PhinH PginH)\n  (calc hom (h*g) c = perm.f ((hom h) * (hom g)) c : is_hom hom\n                ... = ((hom h) ∘ (hom g)) c        : by rewrite perm_f_mul\n                ... = (hom h) b                    : Pgcb\n                ... = a                            : Phba)))\n\nlemma in_orbit_symm {a b : S} : a ∈ orbit hom H b → b ∈ orbit hom H a :=\nassume Painb, obtain h PhinH Phba, from exists_of_orbit Painb,\nhave perm.f (hom h)⁻¹ a = b, by rewrite [-Phba, -perm_f_mul, mul.left_inv],\nhave (hom h⁻¹) a = b,        by rewrite [hom_map_inv, this],\norbit_of_exists (exists.intro h⁻¹ (and.intro (finsubg_has_inv H PhinH) this))\n\nlemma orbit_is_partition : is_partition (orbit hom H) :=\ntake a b, propext (iff.intro\n  (assume Painb, obtain h PhinH Phba, from exists_of_orbit Painb,\n  ext take c, iff.intro\n    (assume Pcina, in_orbit_trans Pcina Painb)\n    (assume Pcinb, obtain g PginH Pgbc, from exists_of_orbit Pcinb,\n      in_orbit_trans Pcinb (in_orbit_symm Painb)))\n  (assume Peq, Peq ▸ in_orbit_refl))\n\nvariables (hom) (H)\nopen nat finset.partition fintype\n\ndefinition orbit_partition : @partition S _ :=\nmk univ (orbit hom H) orbit_is_partition\n  (restriction_imp_union (orbit hom H) orbit_is_partition (λ a Pa, !subset_univ))\n\ndefinition orbits : finset (finset S) := equiv_classes (orbit_partition hom H)\n\ndefinition fixed_point_orbits : finset (finset S) :=\n  {cls ∈ orbits hom H | card cls = 1}\n\nvariables {hom} {H}\n\nlemma exists_iff_mem_orbits (orb : finset S) :\n  orb ∈ orbits hom H ↔ ∃ a : S, orbit hom H a = orb :=\nbegin\n  esimp [orbits, equiv_classes, orbit_partition],\n  rewrite [mem_image_iff],\n  apply iff.intro,\n    intro Pl,\n    cases Pl with a Pa,\n    rewrite (and_left_true !mem_univ) at Pa,\n    existsi a, exact Pa,\n    intro Pr,\n    cases Pr with a Pa,\n    rewrite -true_and at Pa, rewrite -(iff_true_intro (mem_univ a)) at Pa,\n    existsi a, exact Pa\nend\n\nlemma exists_of_mem_orbits {orb : finset S} :\n  orb ∈ orbits hom H → ∃ a : S, orbit hom H a = orb :=\niff.elim_left (exists_iff_mem_orbits orb)\n\nlemma fixed_point_orbits_eq : fixed_point_orbits hom H = image (orbit hom H) (fixed_points hom H) :=\next take s, iff.intro\n  (assume Pin,\n   obtain Psin Ps, from iff.elim_left !mem_sep_iff Pin,\n   obtain a Pa, from exists_of_mem_orbits Psin,\n   mem_image\n     (mem_sep_of_mem !mem_univ (eq.symm\n       (eq_of_card_eq_of_subset (by rewrite [Pa, Ps])\n         (subset_of_forall\n           take x, assume Pxin, eq_of_mem_singleton Pxin ▸ in_orbit_refl))))\n     Pa)\n  (assume Pin,\n   obtain a Pain Porba, from exists_of_mem_image Pin,\n   mem_sep_of_mem\n     (begin esimp [orbits, equiv_classes, orbit_partition], rewrite [mem_image_iff],\n       existsi a, exact and.intro !mem_univ Porba end)\n     (begin substvars, rewrite [of_mem_sep Pain] end))\n\nlemma orbit_inj_on_fixed_points : set.inj_on (orbit hom H) (ts (fixed_points hom H)) :=\ntake a₁ a₂, begin\n  rewrite [-*mem_eq_mem_to_set, ↑fixed_points, *mem_sep_iff],\n  intro Pa₁ Pa₂,\n  rewrite [and.right Pa₁, and.right Pa₂],\n  exact eq_of_singleton_eq\nend\n\nlemma card_fixed_point_orbits_eq : card (fixed_point_orbits hom H) = card (fixed_points hom H) :=\nby rewrite fixed_point_orbits_eq; apply card_image_eq_of_inj_on orbit_inj_on_fixed_points\n\nlemma orbit_class_equation : card S = Sum (orbits hom H) card :=\nclass_equation (orbit_partition hom H)\n\nlemma card_fixed_point_orbits : Sum (fixed_point_orbits hom H) card = card (fixed_point_orbits hom H) :=\ncalc Sum _ _ = Sum (fixed_point_orbits hom H) (λ x, 1) : Sum_ext (take c Pin, of_mem_sep Pin)\n         ... = card (fixed_point_orbits hom H) * 1 : Sum_const_eq_card_mul\n         ... = card (fixed_point_orbits hom H) : mul_one (card (fixed_point_orbits hom H))\n\nlocal attribute nat.comm_semiring [instance]\nlemma orbit_class_equation' : card S = card (fixed_points hom H) + Sum {cls ∈ orbits hom H | card cls ≠ 1} card :=\ncalc card S = Sum (orbits hom H) finset.card                                                            : orbit_class_equation\n        ... = Sum (fixed_point_orbits hom H) finset.card + Sum {cls ∈ orbits hom H | card cls ≠ 1} card : Sum_binary_union\n        ... = card (fixed_point_orbits hom H) + Sum {cls ∈ orbits hom H | card cls ≠ 1} card            : by rewrite -card_fixed_point_orbits\n        ... = card (fixed_points hom H) + Sum {cls ∈ orbits hom H | card cls ≠ 1} card                  : by rewrite card_fixed_point_orbits_eq\n\nend orbit_partition\n\nsection cayley\nvariables {G : Type} [group G] [fintype G]\n\ndefinition action_by_lmul : G → perm G :=\ntake g, perm.mk (lmul_by g) (lmul_inj g)\n\nvariable [decidable_eq G]\n\nlemma action_by_lmul_hom : homomorphic (@action_by_lmul G _ _) :=\ntake g₁ (g₂ : G), eq.symm (calc\n      action_by_lmul g₁ * action_by_lmul g₂\n    = perm.mk ((lmul_by g₁)∘(lmul_by g₂)) _ : rfl\n... = perm.mk (lmul_by (g₁*g₂)) _ : by congruence; apply coset.lmul_compose)\n\nlemma action_by_lmul_inj : injective (@action_by_lmul G _ _) :=\ntake g₁ g₂, assume Peq, perm.no_confusion Peq\n  (λ Pfeq Pqeq,\n  have Pappeq : g₁*1 = g₂*1, from congr_fun Pfeq _,\n  calc g₁ = g₁ * 1 : mul_one\n      ... = g₂ * 1 : Pappeq\n      ... = g₂ : mul_one)\n\ndefinition action_by_lmul_is_iso [instance] : is_iso_class (@action_by_lmul G _ _) :=\nis_iso_class.mk action_by_lmul_hom action_by_lmul_inj\n\nend cayley\n\nsection lcosets\nopen fintype subtype\n\nvariables {G : Type} [group G] [fintype G] [decidable_eq G]\n\nvariables H : finset G\n\ndefinition action_on_lcoset : G → perm (lcoset_type univ H) :=\ntake g, perm.mk (lcoset_lmul (mem_univ g)) lcoset_lmul_inj\n\nprivate definition lcoset_of (g : G) : lcoset_type univ H :=\ntag (fin_lcoset H g) (exists.intro g (and.intro !mem_univ rfl))\n\nvariable {H}\n\nlemma action_on_lcoset_eq (g : G) (J : lcoset_type univ H)\n  : elt_of (action_on_lcoset H g J) = fin_lcoset (elt_of J) g := rfl\n\nlemma action_on_lcoset_hom : homomorphic (action_on_lcoset H) :=\ntake g₁ g₂, eq_of_feq (funext take S, subtype.eq\n  (by rewrite [↑action_on_lcoset, ↑lcoset_lmul, -fin_lcoset_compose]))\n\ndefinition action_on_lcoset_is_hom [instance] : is_hom_class (action_on_lcoset H) :=\nis_hom_class.mk action_on_lcoset_hom\n\nvariable [finsubgH : is_finsubg H]\ninclude finsubgH\n\nlemma aol_fixed_point_subset_normalizer (J : lcoset_type univ H) :\n  is_fixed_point (action_on_lcoset H) H J → elt_of J ⊆ normalizer H :=\nobtain j Pjin Pj, from exists_of_lcoset_type J,\nassume Pfp,\nhave PH : ∀ {h}, h ∈ H → fin_lcoset (fin_lcoset H j) h = fin_lcoset H j,\n  from take h, assume Ph, by rewrite [Pj, -action_on_lcoset_eq, Pfp h Ph],\nsubset_of_forall take g, begin\n  rewrite [-Pj, fin_lcoset_same, -inv_inv at {2}],\n  intro Pg,\n  rewrite -Pg at PH,\n  apply finsubg_has_inv,\n  apply mem_sep_of_mem !mem_univ,\n  intro h Ph,\n  have Phg : fin_lcoset (fin_lcoset H g) h = fin_lcoset H g, from PH Ph,\n  revert Phg,\n  rewrite [↑conj_by, inv_inv, mul.assoc, fin_lcoset_compose, -fin_lcoset_same, ↑fin_lcoset, mem_image_iff, ↑lmul_by],\n  intro Pex, cases Pex with k Pand, cases Pand with Pkin Pk,\n  rewrite [-Pk, inv_mul_cancel_left], exact Pkin\nend\n\nlemma aol_fixed_point_of_mem_normalizer {g : G} :\n  g ∈ normalizer H → is_fixed_point (action_on_lcoset H) H (lcoset_of H g) :=\nassume Pgin, take h, assume Phin, subtype.eq\n  (by rewrite [action_on_lcoset_eq, ↑lcoset_of, lrcoset_same_of_mem_normalizer Pgin, fin_lrcoset_comm, finsubg_lcoset_id Phin])\n\nlemma aol_fixed_points_eq_normalizer :\n  Union (fixed_points (action_on_lcoset H) H) elt_of = normalizer H :=\next take g, begin\n  rewrite [mem_Union_iff],\n  apply iff.intro,\n    intro Pl,\n    cases Pl with L PL, revert PL,\n    rewrite [is_fixed_point_iff_mem_fixed_points],\n    intro Pg,\n    apply mem_of_subset_of_mem,\n      apply aol_fixed_point_subset_normalizer L, exact and.left Pg,\n      exact and.right Pg,\n    intro Pr,\n    existsi (lcoset_of H g), apply and.intro,\n      rewrite [is_fixed_point_iff_mem_fixed_points],\n      exact aol_fixed_point_of_mem_normalizer Pr,\n      exact fin_mem_lcoset g\nend\n\nopen nat\n\nlemma card_aol_fixed_points_eq_card_cosets :\n  card (fixed_points (action_on_lcoset H) H) = card (lcoset_type (normalizer H) H) :=\nhave Peq : card (fixed_points (action_on_lcoset H) H) * card H = card (lcoset_type (normalizer H) H) * card H, from calc\n  card _ * card H = card (Union (fixed_points (action_on_lcoset H) H) elt_of) : card_Union_lcosets\n              ... = card (normalizer H) : aol_fixed_points_eq_normalizer\n              ... = card (lcoset_type (normalizer H) H) * card H : lagrange_theorem' subset_normalizer,\neq_of_mul_eq_mul_right (card_pos_of_mem !finsubg_has_one) Peq\n\nend lcosets\n\nsection perm_fin\nopen fin nat eq.ops\n\nvariable {n : nat}\n\ndefinition lift_perm (p : perm (fin n)) : perm (fin (succ n)) :=\nperm.mk (lift_fun p) (lift_fun_of_inj (perm.inj p))\n\ndefinition lower_perm (p : perm (fin (succ n))) (P : p maxi = maxi) : perm (fin n) :=\nperm.mk (lower_inj p (perm.inj p) P)\n  (take i j, begin\n  rewrite [-eq_iff_veq, *lower_inj_apply, eq_iff_veq],\n  apply injective_comp (perm.inj p) lift_succ_inj\n  end)\n\nlemma lift_lower_eq : ∀ {p : perm (fin (succ n))} (P : p maxi = maxi),\n  lift_perm (lower_perm p P) = p\n| (perm.mk pf Pinj) := assume Pmax, begin\n  rewrite [↑lift_perm], congruence,\n  apply funext, intro i,\n  have Pfmax : pf maxi = maxi, by apply Pmax,\n  have Pd : decidable (i = maxi), from _,\n    cases Pd with Pe Pne,\n      rewrite [Pe, Pfmax], apply lift_fun_max,\n      rewrite [lift_fun_of_ne_max Pne, ↑lower_perm, ↑lift_succ],\n      rewrite [-eq_iff_veq, -val_lift, lower_inj_apply, eq_iff_veq],\n      congruence, rewrite [-eq_iff_veq]\n  end\n\nlemma lift_perm_inj : injective (@lift_perm n) :=\ntake p1 p2, assume Peq, eq_of_feq (lift_fun_inj (feq_of_eq Peq))\n\nlemma lift_perm_inj_on_univ : set.inj_on (@lift_perm n) (ts univ) :=\neq.symm to_set_univ ▸ iff.elim_left set.injective_iff_inj_on_univ lift_perm_inj\n\nlemma lift_to_stab : image (@lift_perm n) univ = stab id univ maxi :=\next (take (pp : perm (fin (succ n))), iff.intro\n  (assume Pimg, obtain p P_ Pp, from exists_of_mem_image Pimg,\n  have Ppp : pp maxi = maxi, from calc\n    pp maxi = lift_perm p maxi : {eq.symm Pp}\n        ... = lift_fun p maxi : rfl\n        ... = maxi : lift_fun_max,\n  mem_sep_of_mem !mem_univ Ppp)\n  (assume Pstab,\n  have Ppp : pp maxi = maxi, from of_mem_sep Pstab,\n  mem_image !mem_univ (lift_lower_eq Ppp)))\n\ndefinition move_from_max_to (i : fin (succ n)) : perm (fin (succ n)) :=\nperm.mk (madd (i - maxi)) madd_inj\n\nlemma orbit_max : orbit (@id (perm (fin (succ n)))) univ maxi = univ :=\next (take i, iff.intro\n  (assume P, !mem_univ)\n  (assume P, begin\n    apply mem_image,\n      apply mem_image,\n        apply mem_univ (move_from_max_to i), apply rfl,\n      apply sub_add_cancel\n    end))\n\nlemma card_orbit_max : card (orbit (@id (perm (fin (succ n)))) univ maxi) = succ n :=\ncalc card (orbit (@id (perm (fin (succ n)))) univ maxi) = card univ : by rewrite orbit_max\n                                                    ... = succ n    : card_fin (succ n)\n\nopen fintype\n\nlemma card_lift_to_stab : card (stab (@id (perm (fin (succ n)))) univ maxi) = card (perm (fin n)) :=\n calc finset.card (stab (@id (perm (fin (succ n)))) univ maxi)\n    = finset.card (image (@lift_perm n) univ) : by rewrite lift_to_stab\n... = card univ                               : by rewrite (card_image_eq_of_inj_on lift_perm_inj_on_univ)\n\nlemma card_perm_step : card (perm (fin (succ n))) = (succ n) * card (perm (fin n)) :=\n calc card (perm (fin (succ n)))\n    = card (orbit id univ maxi) * card (stab id univ maxi) : orbit_stabilizer_theorem\n... = (succ n) * card (stab id univ maxi)                  : {card_orbit_max}\n... = (succ n) * card (perm (fin n))                       : by rewrite -card_lift_to_stab\n\nend perm_fin\nend group_theory\n", "meta": {"author": "Bolt64", "repo": "lean2-aur", "sha": "1d7148e58a17b2d326b032ed1ebf8c5217320242", "save_path": "github-repos/lean/Bolt64-lean2-aur", "path": "github-repos/lean/Bolt64-lean2-aur/lean2-aur-1d7148e58a17b2d326b032ed1ebf8c5217320242/library/theories/finite_group_theory/action.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4863512968454503}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\nimport group_theory.group_action.conj_act\nimport group_theory.quotient_group\nimport order.filter.pointwise\nimport topology.algebra.monoid\nimport topology.compact_open\nimport topology.sets.compacts\nimport topology.algebra.constructions\n\n/-!\n# Topological groups\n\nThis file defines the following typeclasses:\n\n* `topological_group`, `topological_add_group`: multiplicative and additive topological groups,\n  i.e., groups with continuous `(*)` and `(⁻¹)` / `(+)` and `(-)`;\n\n* `has_continuous_sub G` means that `G` has a continuous subtraction operation.\n\nThere is an instance deducing `has_continuous_sub` from `topological_group` but we use a separate\ntypeclass because, e.g., `ℕ` and `ℝ≥0` have continuous subtraction but are not additive groups.\n\nWe also define `homeomorph` versions of several `equiv`s: `homeomorph.mul_left`,\n`homeomorph.mul_right`, `homeomorph.inv`, and prove a few facts about neighbourhood filters in\ngroups.\n\n## Tags\n\ntopological space, group, topological group\n-/\n\nopen classical set filter topological_space function\nopen_locale classical topological_space filter pointwise\n\nuniverses u v w x\nvariables {α : Type u} {β : Type v} {G : Type w} {H : Type x}\n\nsection continuous_mul_group\n\n/-!\n### Groups with continuous multiplication\n\nIn this section we prove a few statements about groups with continuous `(*)`.\n-/\n\nvariables [topological_space G] [group G] [has_continuous_mul G]\n\n/-- Multiplication from the left in a topological group as a homeomorphism. -/\n@[to_additive \"Addition from the left in a topological additive group as a homeomorphism.\"]\nprotected def homeomorph.mul_left (a : G) : G ≃ₜ G :=\n{ continuous_to_fun  := continuous_const.mul continuous_id,\n  continuous_inv_fun := continuous_const.mul continuous_id,\n  .. equiv.mul_left a }\n\n@[simp, to_additive]\nlemma homeomorph.coe_mul_left (a : G) : ⇑(homeomorph.mul_left a) = (*) a := rfl\n\n@[to_additive]\nlemma homeomorph.mul_left_symm (a : G) : (homeomorph.mul_left a).symm = homeomorph.mul_left a⁻¹ :=\nby { ext, refl }\n\n@[to_additive]\nlemma is_open_map_mul_left (a : G) : is_open_map (λ x, a * x) :=\n(homeomorph.mul_left a).is_open_map\n\n@[to_additive is_open.left_add_coset]\nlemma is_open.left_coset {U : set G} (h : is_open U) (x : G) : is_open (left_coset x U) :=\nis_open_map_mul_left x _ h\n\n@[to_additive]\nlemma is_closed_map_mul_left (a : G) : is_closed_map (λ x, a * x) :=\n(homeomorph.mul_left a).is_closed_map\n\n@[to_additive is_closed.left_add_coset]\nlemma is_closed.left_coset {U : set G} (h : is_closed U) (x : G) : is_closed (left_coset x U) :=\nis_closed_map_mul_left x _ h\n\n/-- Multiplication from the right in a topological group as a homeomorphism. -/\n@[to_additive \"Addition from the right in a topological additive group as a homeomorphism.\"]\nprotected def homeomorph.mul_right (a : G) :\n  G ≃ₜ G :=\n{ continuous_to_fun  := continuous_id.mul continuous_const,\n  continuous_inv_fun := continuous_id.mul continuous_const,\n  .. equiv.mul_right a }\n\n@[simp, to_additive]\nlemma homeomorph.coe_mul_right (a : G) : ⇑(homeomorph.mul_right a) = λ g, g * a := rfl\n\n@[to_additive]\nlemma homeomorph.mul_right_symm (a : G) :\n  (homeomorph.mul_right a).symm = homeomorph.mul_right a⁻¹ :=\nby { ext, refl }\n\n@[to_additive]\nlemma is_open_map_mul_right (a : G) : is_open_map (λ x, x * a) :=\n(homeomorph.mul_right a).is_open_map\n\n@[to_additive is_open.right_add_coset]\nlemma is_open.right_coset {U : set G} (h : is_open U) (x : G) : is_open (right_coset U x) :=\nis_open_map_mul_right x _ h\n\n@[to_additive]\nlemma is_closed_map_mul_right (a : G) : is_closed_map (λ x, x * a) :=\n(homeomorph.mul_right a).is_closed_map\n\n@[to_additive is_closed.right_add_coset]\nlemma is_closed.right_coset {U : set G} (h : is_closed U) (x : G) : is_closed (right_coset U x) :=\nis_closed_map_mul_right x _ h\n\n@[to_additive]\nlemma discrete_topology_of_open_singleton_one (h : is_open ({1} : set G)) : discrete_topology G :=\nbegin\n  rw ← singletons_open_iff_discrete,\n  intro g,\n  suffices : {g} = (λ (x : G), g⁻¹ * x) ⁻¹' {1},\n  { rw this, exact (continuous_mul_left (g⁻¹)).is_open_preimage _ h, },\n  simp only [mul_one, set.preimage_mul_left_singleton, eq_self_iff_true,\n    inv_inv, set.singleton_eq_singleton_iff],\nend\n\n@[to_additive]\nlemma discrete_topology_iff_open_singleton_one : discrete_topology G ↔ is_open ({1} : set G) :=\n⟨λ h, forall_open_iff_discrete.mpr h {1}, discrete_topology_of_open_singleton_one⟩\n\nend continuous_mul_group\n\n/-!\n### `has_continuous_inv` and `has_continuous_neg`\n-/\n\n/-- Basic hypothesis to talk about a topological additive group. A topological additive group\nover `M`, for example, is obtained by requiring the instances `add_group M` and\n`has_continuous_add M` and `has_continuous_neg M`. -/\nclass has_continuous_neg (G : Type u) [topological_space G] [has_neg G] : Prop :=\n(continuous_neg : continuous (λ a : G, -a))\n\n/-- Basic hypothesis to talk about a topological group. A topological group over `M`, for example,\nis obtained by requiring the instances `group M` and `has_continuous_mul M` and\n`has_continuous_inv M`. -/\n@[to_additive]\nclass has_continuous_inv (G : Type u) [topological_space G] [has_inv G] : Prop :=\n(continuous_inv : continuous (λ a : G, a⁻¹))\n\nexport has_continuous_inv (continuous_inv)\nexport has_continuous_neg (continuous_neg)\n\nsection continuous_inv\n\nvariables [topological_space G] [has_inv G] [has_continuous_inv G]\n\n@[to_additive]\nlemma continuous_on_inv {s : set G} : continuous_on has_inv.inv s :=\ncontinuous_inv.continuous_on\n\n@[to_additive]\nlemma continuous_within_at_inv {s : set G} {x : G} : continuous_within_at has_inv.inv s x :=\ncontinuous_inv.continuous_within_at\n\n@[to_additive]\nlemma continuous_at_inv {x : G} : continuous_at has_inv.inv x :=\ncontinuous_inv.continuous_at\n\n@[to_additive]\nlemma tendsto_inv (a : G) : tendsto has_inv.inv (𝓝 a) (𝓝 (a⁻¹)) :=\ncontinuous_at_inv\n\n/-- If a function converges to a value in a multiplicative topological group, then its inverse\nconverges to the inverse of this value. For the version in normed fields assuming additionally\nthat the limit is nonzero, use `tendsto.inv'`. -/\n@[to_additive]\nlemma filter.tendsto.inv {f : α → G} {l : filter α} {y : G} (h : tendsto f l (𝓝 y)) :\n  tendsto (λ x, (f x)⁻¹) l (𝓝 y⁻¹) :=\n(continuous_inv.tendsto y).comp h\n\nvariables [topological_space α] {f : α → G} {s : set α} {x : α}\n\n@[continuity, to_additive]\nlemma continuous.inv (hf : continuous f) : continuous (λx, (f x)⁻¹) :=\ncontinuous_inv.comp hf\n\n@[to_additive]\nlemma continuous_at.inv (hf : continuous_at f x) : continuous_at (λ x, (f x)⁻¹) x :=\ncontinuous_at_inv.comp hf\n\n@[to_additive]\nlemma continuous_on.inv (hf : continuous_on f s) : continuous_on (λx, (f x)⁻¹) s :=\ncontinuous_inv.comp_continuous_on hf\n\n@[to_additive]\nlemma continuous_within_at.inv (hf : continuous_within_at f s x) :\n  continuous_within_at (λ x, (f x)⁻¹) s x :=\nhf.inv\n\n@[to_additive]\ninstance [topological_space H] [has_inv H] [has_continuous_inv H] : has_continuous_inv (G × H) :=\n⟨(continuous_inv.comp continuous_fst).prod_mk (continuous_inv.comp continuous_snd)⟩\n\nvariable {ι : Type*}\n\n@[to_additive]\ninstance pi.has_continuous_inv {C : ι → Type*} [∀ i, topological_space (C i)]\n  [∀ i, has_inv (C i)] [∀ i, has_continuous_inv (C i)] : has_continuous_inv (Π i, C i) :=\n{ continuous_inv := continuous_pi (λ i, continuous.inv (continuous_apply i)) }\n\n/-- A version of `pi.has_continuous_inv` for non-dependent functions. It is needed because sometimes\nLean fails to use `pi.has_continuous_inv` for non-dependent functions. -/\n@[to_additive \"A version of `pi.has_continuous_neg` for non-dependent functions. It is needed\nbecause sometimes Lean fails to use `pi.has_continuous_neg` for non-dependent functions.\"]\ninstance pi.has_continuous_inv' : has_continuous_inv (ι → G) :=\npi.has_continuous_inv\n\n@[priority 100, to_additive]\ninstance has_continuous_inv_of_discrete_topology [topological_space H]\n  [has_inv H] [discrete_topology H] : has_continuous_inv H :=\n⟨continuous_of_discrete_topology⟩\n\nsection pointwise_limits\n\nvariables (G₁ G₂ : Type*) [topological_space G₂] [t2_space G₂]\n\n@[to_additive] lemma is_closed_set_of_map_inv [has_inv G₁] [has_inv G₂] [has_continuous_inv G₂] :\n  is_closed {f : G₁ → G₂ | ∀ x, f x⁻¹ = (f x)⁻¹ } :=\nbegin\n  simp only [set_of_forall],\n  refine is_closed_Inter (λ i, is_closed_eq (continuous_apply _) (continuous_apply _).inv),\nend\n\nend pointwise_limits\n\ninstance additive.has_continuous_neg [h : topological_space H] [has_inv H]\n  [has_continuous_inv H] : @has_continuous_neg (additive H) h _ :=\n{ continuous_neg := @continuous_inv H _ _ _ }\n\ninstance multiplicative.has_continuous_inv [h : topological_space H] [has_neg H]\n  [has_continuous_neg H] : @has_continuous_inv (multiplicative H) h _ :=\n{ continuous_inv := @continuous_neg H _ _ _ }\n\nend continuous_inv\n\nsection continuous_involutive_inv\nvariables [topological_space G] [has_involutive_inv G] [has_continuous_inv G] {s : set G}\n\n@[to_additive] lemma is_compact.inv (hs : is_compact s) : is_compact s⁻¹ :=\nby { rw [← image_inv], exact hs.image continuous_inv }\n\nvariables (G)\n\n/-- Inversion in a topological group as a homeomorphism. -/\n@[to_additive \"Negation in a topological group as a homeomorphism.\"]\nprotected def homeomorph.inv (G : Type*) [topological_space G] [has_involutive_inv G]\n  [has_continuous_inv G] : G ≃ₜ G :=\n{ continuous_to_fun  := continuous_inv,\n  continuous_inv_fun := continuous_inv,\n  .. equiv.inv G }\n\n@[to_additive] lemma is_open_map_inv : is_open_map (has_inv.inv : G → G) :=\n(homeomorph.inv _).is_open_map\n\n@[to_additive] lemma is_closed_map_inv : is_closed_map (has_inv.inv : G → G) :=\n(homeomorph.inv _).is_closed_map\n\nvariables {G}\n\n@[to_additive] lemma is_open.inv (hs : is_open s) : is_open s⁻¹ := hs.preimage continuous_inv\n@[to_additive] lemma is_closed.inv (hs : is_closed s) : is_closed s⁻¹ := hs.preimage continuous_inv\n@[to_additive] lemma inv_closure : ∀ s : set G, (closure s)⁻¹ = closure s⁻¹ :=\n(homeomorph.inv G).preimage_closure\n\nend continuous_involutive_inv\n\nsection lattice_ops\n\nvariables {ι' : Sort*} [has_inv G] [has_inv H] {ts : set (topological_space G)}\n  (h : Π t ∈ ts, @has_continuous_inv G t _) {ts' : ι' → topological_space G}\n  (h' : Π i, @has_continuous_inv G (ts' i) _) {t₁ t₂ : topological_space G}\n  (h₁ : @has_continuous_inv G t₁ _) (h₂ : @has_continuous_inv G t₂ _)\n  {t : topological_space H} [has_continuous_inv H]\n\n\n@[to_additive] lemma has_continuous_inv_Inf :\n  @has_continuous_inv G (Inf ts) _ :=\n{ continuous_inv := continuous_Inf_rng (λ t ht, continuous_Inf_dom ht\n  (@has_continuous_inv.continuous_inv G t _ (h t ht))) }\n\ninclude h'\n\n@[to_additive] lemma has_continuous_inv_infi :\n  @has_continuous_inv G (⨅ i, ts' i) _ :=\nby {rw ← Inf_range, exact has_continuous_inv_Inf (set.forall_range_iff.mpr h')}\n\nomit h'\n\ninclude h₁ h₂\n\n@[to_additive] lemma has_continuous_inv_inf :\n  @has_continuous_inv G (t₁ ⊓ t₂) _ :=\nby {rw inf_eq_infi, refine has_continuous_inv_infi (λ b, _), cases b; assumption}\n\nend lattice_ops\n\nsection topological_group\n\n/-!\n### Topological groups\n\nA topological group is a group in which the multiplication and inversion operations are\ncontinuous. Topological additive groups are defined in the same way. Equivalently, we can require\nthat the division operation `λ x y, x * y⁻¹` (resp., subtraction) is continuous.\n-/\n\n/-- A topological (additive) group is a group in which the addition and negation operations are\ncontinuous. -/\nclass topological_add_group (G : Type u) [topological_space G] [add_group G]\n  extends has_continuous_add G, has_continuous_neg G : Prop\n\n/-- A topological group is a group in which the multiplication and inversion operations are\ncontinuous.\n\nWhen you declare an instance that does not already have a `uniform_space` instance,\nyou should also provide an instance of `uniform_space` and `uniform_group` using\n`topological_group.to_uniform_space` and `topological_group_is_uniform`. -/\n@[to_additive]\nclass topological_group (G : Type*) [topological_space G] [group G]\n  extends has_continuous_mul G, has_continuous_inv G : Prop\n\nsection conj\n\ninstance conj_act.units_has_continuous_const_smul {M} [monoid M] [topological_space M]\n  [has_continuous_mul M] :\n  has_continuous_const_smul (conj_act Mˣ) M :=\n⟨λ m, (continuous_const.mul continuous_id).mul continuous_const⟩\n\n/-- we slightly weaken the type class assumptions here so that it will also apply to `ennreal`, but\nwe nevertheless leave it in the `topological_group` namespace. -/\n\nvariables [topological_space G] [has_inv G] [has_mul G] [has_continuous_mul G]\n\n/-- Conjugation is jointly continuous on `G × G` when both `mul` and `inv` are continuous. -/\n@[to_additive \"Conjugation is jointly continuous on `G × G` when both `mul` and `inv` are\ncontinuous.\"]\nlemma topological_group.continuous_conj_prod [has_continuous_inv G] :\n  continuous (λ g : G × G, g.fst * g.snd * g.fst⁻¹) :=\ncontinuous_mul.mul (continuous_inv.comp continuous_fst)\n\n/-- Conjugation by a fixed element is continuous when `mul` is continuous. -/\n@[to_additive \"Conjugation by a fixed element is continuous when `add` is continuous.\"]\nlemma topological_group.continuous_conj (g : G) : continuous (λ (h : G), g * h * g⁻¹) :=\n(continuous_mul_right g⁻¹).comp (continuous_mul_left g)\n\n/-- Conjugation acting on fixed element of the group is continuous when both `mul` and\n`inv` are continuous. -/\n@[to_additive \"Conjugation acting on fixed element of the additive group is continuous when both\n  `add` and `neg` are continuous.\"]\nlemma topological_group.continuous_conj' [has_continuous_inv G]\n  (h : G) : continuous (λ (g : G), g * h * g⁻¹) :=\n(continuous_mul_right h).mul continuous_inv\n\nend conj\n\nvariables [topological_space G] [group G] [topological_group G]\n[topological_space α] {f : α → G} {s : set α} {x : α}\n\nsection zpow\n\n@[continuity, to_additive]\nlemma continuous_zpow : ∀ z : ℤ, continuous (λ a : G, a ^ z)\n| (int.of_nat n) := by simpa using continuous_pow n\n| -[1+n] := by simpa using (continuous_pow (n + 1)).inv\n\ninstance add_group.has_continuous_const_smul_int {A} [add_group A] [topological_space A]\n  [topological_add_group A] : has_continuous_const_smul ℤ A := ⟨continuous_zsmul⟩\n\ninstance add_group.has_continuous_smul_int {A} [add_group A] [topological_space A]\n  [topological_add_group A] : has_continuous_smul ℤ A :=\n⟨continuous_uncurry_of_discrete_topology continuous_zsmul⟩\n\n@[continuity, to_additive]\nlemma continuous.zpow {f : α → G} (h : continuous f) (z : ℤ) :\n  continuous (λ b, (f b) ^ z) :=\n(continuous_zpow z).comp h\n\n@[to_additive]\nlemma continuous_on_zpow {s : set G} (z : ℤ) : continuous_on (λ x, x ^ z) s :=\n(continuous_zpow z).continuous_on\n\n@[to_additive]\nlemma continuous_at_zpow (x : G) (z : ℤ) : continuous_at (λ x, x ^ z) x :=\n(continuous_zpow z).continuous_at\n\n@[to_additive]\nlemma filter.tendsto.zpow {α} {l : filter α} {f : α → G} {x : G} (hf : tendsto f l (𝓝 x)) (z : ℤ) :\n  tendsto (λ x, f x ^ z) l (𝓝 (x ^ z)) :=\n(continuous_at_zpow _ _).tendsto.comp hf\n\n@[to_additive]\nlemma continuous_within_at.zpow {f : α → G} {x : α} {s : set α} (hf : continuous_within_at f s x)\n  (z : ℤ) : continuous_within_at (λ x, f x ^ z) s x :=\nhf.zpow z\n\n@[to_additive]\nlemma continuous_at.zpow {f : α → G} {x : α} (hf : continuous_at f x) (z : ℤ) :\n  continuous_at (λ x, f x ^ z) x :=\nhf.zpow z\n\n@[to_additive continuous_on.zsmul]\nlemma continuous_on.zpow {f : α → G} {s : set α} (hf : continuous_on f s) (z : ℤ) :\n  continuous_on (λ x, f x ^ z) s :=\nλ x hx, (hf x hx).zpow z\n\nend zpow\n\nsection ordered_comm_group\n\nvariables [topological_space H] [ordered_comm_group H] [topological_group H]\n\n@[to_additive] lemma tendsto_inv_nhds_within_Ioi {a : H} :\n  tendsto has_inv.inv (𝓝[>] a) (𝓝[<] (a⁻¹)) :=\n(continuous_inv.tendsto a).inf $ by simp [tendsto_principal_principal]\n\n@[to_additive] lemma tendsto_inv_nhds_within_Iio {a : H} :\n  tendsto has_inv.inv (𝓝[<] a) (𝓝[>] (a⁻¹)) :=\n(continuous_inv.tendsto a).inf $ by simp [tendsto_principal_principal]\n\n@[to_additive] lemma tendsto_inv_nhds_within_Ioi_inv {a : H} :\n  tendsto has_inv.inv (𝓝[>] (a⁻¹)) (𝓝[<] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Ioi _ _ _ _ (a⁻¹)\n\n@[to_additive] lemma tendsto_inv_nhds_within_Iio_inv {a : H} :\n  tendsto has_inv.inv (𝓝[<] (a⁻¹)) (𝓝[>] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Iio _ _ _ _ (a⁻¹)\n\n@[to_additive] lemma tendsto_inv_nhds_within_Ici {a : H} :\n  tendsto has_inv.inv (𝓝[≥] a) (𝓝[≤] (a⁻¹)) :=\n(continuous_inv.tendsto a).inf $ by simp [tendsto_principal_principal]\n\n@[to_additive] lemma tendsto_inv_nhds_within_Iic {a : H} :\n  tendsto has_inv.inv (𝓝[≤] a) (𝓝[≥] (a⁻¹)) :=\n(continuous_inv.tendsto a).inf $ by simp [tendsto_principal_principal]\n\n@[to_additive] lemma tendsto_inv_nhds_within_Ici_inv {a : H} :\n  tendsto has_inv.inv (𝓝[≥] (a⁻¹)) (𝓝[≤] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Ici _ _ _ _ (a⁻¹)\n\n@[to_additive] lemma tendsto_inv_nhds_within_Iic_inv {a : H} :\n  tendsto has_inv.inv (𝓝[≤] (a⁻¹)) (𝓝[≥] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Iic _ _ _ _ (a⁻¹)\n\nend ordered_comm_group\n\n@[instance, to_additive]\ninstance [topological_space H] [group H] [topological_group H] :\n  topological_group (G × H) :=\n{ continuous_inv := continuous_inv.prod_map continuous_inv }\n\n@[to_additive]\ninstance pi.topological_group {C : β → Type*} [∀ b, topological_space (C b)]\n  [∀ b, group (C b)] [∀ b, topological_group (C b)] : topological_group (Π b, C b) :=\n{ continuous_inv := continuous_pi (λ i, (continuous_apply i).inv) }\n\nopen mul_opposite\n\n@[to_additive]\ninstance [group α] [has_continuous_inv α] : has_continuous_inv αᵐᵒᵖ :=\n{ continuous_inv := continuous_induced_rng $ (@continuous_inv α _ _ _).comp continuous_unop }\n\n/-- If multiplication is continuous in `α`, then it also is in `αᵐᵒᵖ`. -/\n@[to_additive \"If addition is continuous in `α`, then it also is in `αᵃᵒᵖ`.\"]\ninstance [group α] [topological_group α] :\n  topological_group αᵐᵒᵖ := { }\n\nvariable (G)\n\n@[to_additive]\nlemma nhds_one_symm : comap has_inv.inv (𝓝 (1 : G)) = 𝓝 (1 : G) :=\n((homeomorph.inv G).comap_nhds_eq _).trans (congr_arg nhds inv_one)\n\n/-- The map `(x, y) ↦ (x, xy)` as a homeomorphism. This is a shear mapping. -/\n@[to_additive \"The map `(x, y) ↦ (x, x + y)` as a homeomorphism.\nThis is a shear mapping.\"]\nprotected def homeomorph.shear_mul_right : G × G ≃ₜ G × G :=\n{ continuous_to_fun  := continuous_fst.prod_mk continuous_mul,\n  continuous_inv_fun := continuous_fst.prod_mk $ continuous_fst.inv.mul continuous_snd,\n  .. equiv.prod_shear (equiv.refl _) equiv.mul_left }\n\n@[simp, to_additive]\nlemma homeomorph.shear_mul_right_coe :\n  ⇑(homeomorph.shear_mul_right G) = λ z : G × G, (z.1, z.1 * z.2) :=\nrfl\n\n@[simp, to_additive]\nlemma homeomorph.shear_mul_right_symm_coe :\n  ⇑(homeomorph.shear_mul_right G).symm = λ z : G × G, (z.1, z.1⁻¹ * z.2) :=\nrfl\n\nvariables {G}\n\nnamespace subgroup\n\n@[to_additive] instance (S : subgroup G) :\n  topological_group S :=\n{ continuous_inv :=\n  begin\n    rw embedding_subtype_coe.to_inducing.continuous_iff,\n    exact continuous_subtype_coe.inv\n  end,\n  ..S.to_submonoid.has_continuous_mul }\n\nend subgroup\n\n/-- The (topological-space) closure of a subgroup of a space `M` with `has_continuous_mul` is\nitself a subgroup. -/\n@[to_additive \"The (topological-space) closure of an additive subgroup of a space `M` with\n`has_continuous_add` is itself an additive subgroup.\"]\ndef subgroup.topological_closure (s : subgroup G) : subgroup G :=\n{ carrier := closure (s : set G),\n  inv_mem' := λ g m, by simpa [←set.mem_inv, inv_closure] using m,\n  ..s.to_submonoid.topological_closure }\n\n@[simp, to_additive] lemma subgroup.topological_closure_coe {s : subgroup G} :\n  (s.topological_closure : set G) = closure s :=\nrfl\n\n@[to_additive]\ninstance subgroup.topological_closure_topological_group (s : subgroup G) :\n  topological_group (s.topological_closure) :=\n{ continuous_inv :=\n  begin\n    apply continuous_induced_rng,\n    change continuous (λ p : s.topological_closure, (p : G)⁻¹),\n    continuity,\n  end\n  ..s.to_submonoid.topological_closure_has_continuous_mul}\n\n@[to_additive] lemma subgroup.subgroup_topological_closure (s : subgroup G) :\n  s ≤ s.topological_closure :=\nsubset_closure\n\n@[to_additive] lemma subgroup.is_closed_topological_closure (s : subgroup G) :\n  is_closed (s.topological_closure : set G) :=\nby convert is_closed_closure\n\n@[to_additive] lemma subgroup.topological_closure_minimal\n  (s : subgroup G) {t : subgroup G} (h : s ≤ t) (ht : is_closed (t : set G)) :\n  s.topological_closure ≤ t :=\nclosure_minimal h ht\n\n@[to_additive] lemma dense_range.topological_closure_map_subgroup [group H] [topological_space H]\n  [topological_group H] {f : G →* H} (hf : continuous f) (hf' : dense_range f) {s : subgroup G}\n  (hs : s.topological_closure = ⊤) :\n  (s.map f).topological_closure = ⊤ :=\nbegin\n  rw set_like.ext'_iff at hs ⊢,\n  simp only [subgroup.topological_closure_coe, subgroup.coe_top, ← dense_iff_closure_eq] at hs ⊢,\n  exact hf'.dense_image hf hs\nend\n\n/-- The topological closure of a normal subgroup is normal.-/\n@[to_additive \"The topological closure of a normal additive subgroup is normal.\"]\nlemma subgroup.is_normal_topological_closure {G : Type*} [topological_space G] [group G]\n  [topological_group G] (N : subgroup G) [N.normal] :\n  (subgroup.topological_closure N).normal :=\n{ conj_mem := λ n hn g,\n  begin\n    apply mem_closure_of_continuous (topological_group.continuous_conj g) hn,\n    intros m hm,\n    exact subset_closure (subgroup.normal.conj_mem infer_instance m hm g),\n  end }\n\n@[to_additive] lemma mul_mem_connected_component_one {G : Type*} [topological_space G]\n  [mul_one_class G] [has_continuous_mul G] {g h : G} (hg : g ∈ connected_component (1 : G))\n  (hh : h ∈ connected_component (1 : G)) : g * h ∈ connected_component (1 : G) :=\nbegin\n  rw connected_component_eq hg,\n  have hmul: g ∈ connected_component (g*h),\n  { apply continuous.image_connected_component_subset (continuous_mul_left g),\n    rw ← connected_component_eq hh,\n    exact ⟨(1 : G), mem_connected_component, by simp only [mul_one]⟩ },\n  simpa [← connected_component_eq hmul] using (mem_connected_component)\nend\n\n@[to_additive] lemma inv_mem_connected_component_one {G : Type*} [topological_space G] [group G]\n  [topological_group G] {g : G} (hg : g ∈ connected_component (1 : G)) :\n  g⁻¹ ∈ connected_component (1 : G) :=\nbegin\n  rw ← inv_one,\n  exact continuous.image_connected_component_subset continuous_inv _\n    ((set.mem_image _ _ _).mp ⟨g, hg, rfl⟩)\nend\n\n/-- The connected component of 1 is a subgroup of `G`. -/\n@[to_additive \"The connected component of 0 is a subgroup of `G`.\"]\ndef subgroup.connected_component_of_one (G : Type*) [topological_space G] [group G]\n  [topological_group G] : subgroup G :=\n{ carrier  := connected_component (1 : G),\n  one_mem' := mem_connected_component,\n  mul_mem' := λ g h hg hh, mul_mem_connected_component_one hg hh,\n  inv_mem' := λ g hg, inv_mem_connected_component_one hg }\n\n/-- If a subgroup of a topological group is commutative, then so is its topological closure. -/\n@[to_additive \"If a subgroup of an additive topological group is commutative, then so is its\ntopological closure.\"]\ndef subgroup.comm_group_topological_closure [t2_space G] (s : subgroup G)\n  (hs : ∀ (x y : s), x * y = y * x) : comm_group s.topological_closure :=\n{ ..s.topological_closure.to_group,\n  ..s.to_submonoid.comm_monoid_topological_closure hs }\n\n@[to_additive exists_nhds_half_neg]\nlemma exists_nhds_split_inv {s : set G} (hs : s ∈ 𝓝 (1 : G)) :\n  ∃ V ∈ 𝓝 (1 : G), ∀ (v ∈ V) (w ∈ V), v / w ∈ s :=\nhave ((λp : G × G, p.1 * p.2⁻¹) ⁻¹' s) ∈ 𝓝 ((1, 1) : G × G),\n  from continuous_at_fst.mul continuous_at_snd.inv (by simpa),\nby simpa only [div_eq_mul_inv, nhds_prod_eq, mem_prod_self_iff, prod_subset_iff, mem_preimage]\n  using this\n\n@[to_additive]\nlemma nhds_translation_mul_inv (x : G) : comap (λ y : G, y * x⁻¹) (𝓝 1) = 𝓝 x :=\n((homeomorph.mul_right x⁻¹).comap_nhds_eq 1).trans $ show 𝓝 (1 * x⁻¹⁻¹) = 𝓝 x, by simp\n\n@[simp, to_additive] lemma map_mul_left_nhds (x y : G) : map ((*) x) (𝓝 y) = 𝓝 (x * y) :=\n(homeomorph.mul_left x).map_nhds_eq y\n\n@[to_additive] lemma map_mul_left_nhds_one (x : G) : map ((*) x) (𝓝 1) = 𝓝 x := by simp\n\n/-- A monoid homomorphism (a bundled morphism of a type that implements `monoid_hom_class`) from a\ntopological group to a topological monoid is continuous provided that it is continuous at one. See\nalso `uniform_continuous_of_continuous_at_one`. -/\n@[to_additive \"An additive monoid homomorphism (a bundled morphism of a type that implements\n`add_monoid_hom_class`) from an additive topological group to an additive topological monoid is\ncontinuous provided that it is continuous at zero. See also\n`uniform_continuous_of_continuous_at_zero`.\"]\nlemma continuous_of_continuous_at_one {M hom : Type*} [mul_one_class M] [topological_space M]\n  [has_continuous_mul M] [monoid_hom_class hom G M] (f : hom) (hf : continuous_at f 1) :\n  continuous f :=\ncontinuous_iff_continuous_at.2 $ λ x,\n  by simpa only [continuous_at, ← map_mul_left_nhds_one x, tendsto_map'_iff, (∘),\n    map_mul, map_one, mul_one] using hf.tendsto.const_mul (f x)\n\n@[to_additive]\nlemma topological_group.ext {G : Type*} [group G] {t t' : topological_space G}\n  (tg : @topological_group G t _) (tg' : @topological_group G t' _)\n  (h : @nhds G t 1 = @nhds G t' 1) : t = t' :=\neq_of_nhds_eq_nhds $ λ x, by\n  rw [← @nhds_translation_mul_inv G t _ _ x , ← @nhds_translation_mul_inv G t' _ _ x , ← h]\n\n@[to_additive]\nlemma topological_group.of_nhds_aux {G : Type*} [group G] [topological_space G]\n  (hinv : tendsto (λ (x : G), x⁻¹) (𝓝 1) (𝓝 1))\n  (hleft : ∀ (x₀ : G), 𝓝 x₀ = map (λ (x : G), x₀ * x) (𝓝 1))\n  (hconj : ∀ (x₀ : G), map (λ (x : G), x₀ * x * x₀⁻¹) (𝓝 1) ≤ 𝓝 1) : continuous (λ x : G, x⁻¹) :=\nbegin\n  rw continuous_iff_continuous_at,\n  rintros x₀,\n  have key : (λ x, (x₀*x)⁻¹) = (λ x, x₀⁻¹*x) ∘ (λ x, x₀*x*x₀⁻¹) ∘ (λ x, x⁻¹),\n    by {ext ; simp[mul_assoc] },\n  calc map (λ x, x⁻¹) (𝓝 x₀)\n      = map (λ x, x⁻¹) (map (λ x, x₀*x) $ 𝓝 1) : by rw hleft\n  ... = map (λ x, (x₀*x)⁻¹) (𝓝 1) : by rw filter.map_map\n  ... = map (((λ x, x₀⁻¹*x) ∘ (λ x, x₀*x*x₀⁻¹)) ∘ (λ x, x⁻¹)) (𝓝 1) : by rw key\n  ... = map ((λ x, x₀⁻¹*x) ∘ (λ x, x₀*x*x₀⁻¹)) _ : by rw ← filter.map_map\n  ... ≤ map ((λ x, x₀⁻¹ * x) ∘ λ x, x₀ * x * x₀⁻¹) (𝓝 1) : map_mono hinv\n  ... = map (λ x, x₀⁻¹ * x) (map (λ x, x₀ * x * x₀⁻¹) (𝓝 1)) : filter.map_map\n  ... ≤ map (λ x, x₀⁻¹ * x) (𝓝 1) : map_mono (hconj x₀)\n  ... = 𝓝 x₀⁻¹ : (hleft _).symm\nend\n\n@[to_additive]\nlemma topological_group.of_nhds_one' {G : Type u} [group G] [topological_space G]\n  (hmul : tendsto (uncurry ((*) : G → G → G)) ((𝓝 1) ×ᶠ 𝓝 1) (𝓝 1))\n  (hinv : tendsto (λ x : G, x⁻¹) (𝓝 1) (𝓝 1))\n  (hleft : ∀ x₀ : G, 𝓝 x₀ = map (λ x, x₀*x) (𝓝 1))\n  (hright : ∀ x₀ : G, 𝓝 x₀ = map (λ x, x*x₀) (𝓝 1)) : topological_group G :=\nbegin\n  refine { continuous_mul := (has_continuous_mul.of_nhds_one hmul hleft hright).continuous_mul,\n           continuous_inv := topological_group.of_nhds_aux hinv hleft _ },\n  intros x₀,\n  suffices : map (λ (x : G), x₀ * x * x₀⁻¹) (𝓝 1) = 𝓝 1, by simp [this, le_refl],\n  rw [show (λ x, x₀ * x * x₀⁻¹) = (λ x, x₀ * x) ∘ λ x, x*x₀⁻¹, by {ext, simp [mul_assoc] },\n      ← filter.map_map, ← hright, hleft x₀⁻¹, filter.map_map],\n  convert map_id,\n  ext,\n  simp\nend\n\n@[to_additive]\nlemma topological_group.of_nhds_one {G : Type u} [group G] [topological_space G]\n  (hmul : tendsto (uncurry ((*) : G → G → G)) ((𝓝 1) ×ᶠ 𝓝 1) (𝓝 1))\n  (hinv : tendsto (λ x : G, x⁻¹) (𝓝 1) (𝓝 1))\n  (hleft : ∀ x₀ : G, 𝓝 x₀ = map (λ x, x₀*x) (𝓝 1))\n  (hconj : ∀ x₀ : G, tendsto (λ x, x₀*x*x₀⁻¹) (𝓝 1) (𝓝 1)) : topological_group G :=\n { continuous_mul := begin\n    rw continuous_iff_continuous_at,\n    rintros ⟨x₀, y₀⟩,\n    have key : (λ (p : G × G), x₀ * p.1 * (y₀ * p.2)) =\n      ((λ x, x₀*y₀*x) ∘ (uncurry (*)) ∘ (prod.map (λ x, y₀⁻¹*x*y₀) id)),\n      by { ext, simp [uncurry, prod.map, mul_assoc] },\n    specialize hconj y₀⁻¹, rw inv_inv at hconj,\n    calc map (λ (p : G × G), p.1 * p.2) (𝓝 (x₀, y₀))\n        = map (λ (p : G × G), p.1 * p.2) ((𝓝 x₀) ×ᶠ 𝓝 y₀)\n            : by rw nhds_prod_eq\n    ... = map (λ (p : G × G), x₀ * p.1 * (y₀ * p.2)) ((𝓝 1) ×ᶠ (𝓝 1))\n            : by rw [hleft x₀, hleft y₀, prod_map_map_eq, filter.map_map]\n    ... = map (((λ x, x₀*y₀*x) ∘ (uncurry (*))) ∘ (prod.map (λ x, y₀⁻¹*x*y₀) id))((𝓝 1) ×ᶠ (𝓝 1))\n            : by rw key\n    ... = map ((λ x, x₀*y₀*x) ∘ (uncurry (*))) ((map  (λ x, y₀⁻¹*x*y₀) $ 𝓝 1) ×ᶠ (𝓝 1))\n            : by rw [← filter.map_map, ← prod_map_map_eq', map_id]\n    ... ≤ map ((λ x, x₀*y₀*x) ∘ (uncurry (*))) ((𝓝 1) ×ᶠ (𝓝 1))\n            : map_mono (filter.prod_mono hconj $ le_rfl)\n    ... = map (λ x, x₀*y₀*x) (map (uncurry (*)) ((𝓝 1) ×ᶠ (𝓝 1)))   : by rw filter.map_map\n    ... ≤ map (λ x, x₀*y₀*x) (𝓝 1)   : map_mono hmul\n    ... = 𝓝 (x₀*y₀)   : (hleft _).symm\n  end,\n  continuous_inv := topological_group.of_nhds_aux hinv hleft hconj}\n\n@[to_additive]\nlemma topological_group.of_comm_of_nhds_one {G : Type u} [comm_group G] [topological_space G]\n  (hmul : tendsto (uncurry ((*) : G → G → G)) ((𝓝 1) ×ᶠ 𝓝 1) (𝓝 1))\n  (hinv : tendsto (λ x : G, x⁻¹) (𝓝 1) (𝓝 1))\n  (hleft : ∀ x₀ : G, 𝓝 x₀ = map (λ x, x₀*x) (𝓝 1)) : topological_group G :=\ntopological_group.of_nhds_one hmul hinv hleft (by simpa using tendsto_id)\n\nend topological_group\n\nsection quotient_topological_group\nvariables [topological_space G] [group G] [topological_group G] (N : subgroup G) (n : N.normal)\n\n@[to_additive]\ninstance quotient_group.quotient.topological_space {G : Type*} [group G] [topological_space G]\n  (N : subgroup G) : topological_space (G ⧸ N) :=\nquotient.topological_space\n\nopen quotient_group\n\n@[to_additive]\nlemma quotient_group.is_open_map_coe : is_open_map (coe : G → G ⧸ N) :=\nbegin\n  intros s s_op,\n  change is_open ((coe : G → G ⧸ N) ⁻¹' (coe '' s)),\n  rw quotient_group.preimage_image_coe N s,\n  exact is_open_Union (λ n, (continuous_mul_right _).is_open_preimage s s_op)\nend\n\n@[to_additive]\ninstance topological_group_quotient [N.normal] : topological_group (G ⧸ N) :=\n{ continuous_mul := begin\n    have cont : continuous ((coe : G → G ⧸ N) ∘ (λ (p : G × G), p.fst * p.snd)) :=\n      continuous_quot_mk.comp continuous_mul,\n    have quot : quotient_map (λ p : G × G, ((p.1 : G ⧸ N), (p.2 : G ⧸ N))),\n    { apply is_open_map.to_quotient_map,\n      { exact (quotient_group.is_open_map_coe N).prod (quotient_group.is_open_map_coe N) },\n      { exact continuous_quot_mk.prod_map continuous_quot_mk },\n      { exact (surjective_quot_mk _).prod_map (surjective_quot_mk _) } },\n    exact (quotient_map.continuous_iff quot).2 cont,\n  end,\n  continuous_inv := begin\n    have : continuous ((coe : G → G ⧸ N) ∘ (λ (a : G), a⁻¹)) :=\n      continuous_quot_mk.comp continuous_inv,\n    convert continuous_quotient_lift _ this,\n  end }\n\nend quotient_topological_group\n\n/-- A typeclass saying that `λ p : G × G, p.1 - p.2` is a continuous function. This property\nautomatically holds for topological additive groups but it also holds, e.g., for `ℝ≥0`. -/\nclass has_continuous_sub (G : Type*) [topological_space G] [has_sub G] : Prop :=\n(continuous_sub : continuous (λ p : G × G, p.1 - p.2))\n\n/-- A typeclass saying that `λ p : G × G, p.1 / p.2` is a continuous function. This property\nautomatically holds for topological groups. Lemmas using this class have primes.\nThe unprimed version is for `group_with_zero`. -/\n@[to_additive]\nclass has_continuous_div (G : Type*) [topological_space G] [has_div G] : Prop :=\n(continuous_div' : continuous (λ p : G × G, p.1 / p.2))\n\n@[priority 100, to_additive] -- see Note [lower instance priority]\ninstance topological_group.to_has_continuous_div [topological_space G] [group G]\n  [topological_group G] : has_continuous_div G :=\n⟨by { simp only [div_eq_mul_inv], exact continuous_fst.mul continuous_snd.inv }⟩\n\nexport has_continuous_sub (continuous_sub)\nexport has_continuous_div (continuous_div')\n\nsection has_continuous_div\n\nvariables [topological_space G] [has_div G] [has_continuous_div G]\n\n@[to_additive sub]\nlemma filter.tendsto.div' {f g : α → G} {l : filter α} {a b : G} (hf : tendsto f l (𝓝 a))\n  (hg : tendsto g l (𝓝 b)) : tendsto (λ x, f x / g x) l (𝓝 (a / b)) :=\n(continuous_div'.tendsto (a, b)).comp (hf.prod_mk_nhds hg)\n\n@[to_additive const_sub]\nlemma filter.tendsto.const_div' (b : G) {c : G} {f : α → G} {l : filter α}\n  (h : tendsto f l (𝓝 c)) : tendsto (λ k : α, b / f k) l (𝓝 (b / c)) :=\ntendsto_const_nhds.div' h\n\n@[to_additive sub_const]\nlemma filter.tendsto.div_const' (b : G) {c : G} {f : α → G} {l : filter α}\n  (h : tendsto f l (𝓝 c)) : tendsto (λ k : α, f k / b) l (𝓝 (c / b)) :=\nh.div' tendsto_const_nhds\n\nvariables [topological_space α] {f g : α → G} {s : set α} {x : α}\n\n@[continuity, to_additive sub] lemma continuous.div' (hf : continuous f) (hg : continuous g) :\n  continuous (λ x, f x / g x) :=\ncontinuous_div'.comp (hf.prod_mk hg : _)\n\n@[to_additive continuous_sub_left]\nlemma continuous_div_left' (a : G) : continuous (λ b : G, a / b) :=\ncontinuous_const.div' continuous_id\n\n@[to_additive continuous_sub_right]\nlemma continuous_div_right' (a : G) : continuous (λ b : G, b / a) :=\ncontinuous_id.div' continuous_const\n\n@[to_additive sub]\nlemma continuous_at.div' {f g : α → G} {x : α} (hf : continuous_at f x) (hg : continuous_at g x) :\n  continuous_at (λx, f x / g x) x :=\nhf.div' hg\n\n@[to_additive sub]\nlemma continuous_within_at.div' (hf : continuous_within_at f s x)\n  (hg : continuous_within_at g s x) :\n  continuous_within_at (λ x, f x / g x) s x :=\nhf.div' hg\n\n@[to_additive sub]\nlemma continuous_on.div' (hf : continuous_on f s) (hg : continuous_on g s) :\n  continuous_on (λx, f x / g x) s :=\nλ x hx, (hf x hx).div' (hg x hx)\n\nend has_continuous_div\n\nsection div_in_topological_group\nvariables [group G] [topological_space G] [topological_group G]\n\n/-- A version of `homeomorph.mul_left a b⁻¹` that is defeq to `a / b`. -/\n@[to_additive /-\" A version of `homeomorph.add_left a (-b)` that is defeq to `a - b`. \"-/,\n  simps {simp_rhs := tt}]\ndef homeomorph.div_left (x : G) : G ≃ₜ G :=\n{ continuous_to_fun := continuous_const.div' continuous_id,\n  continuous_inv_fun := continuous_inv.mul continuous_const,\n  .. equiv.div_left x }\n\n@[to_additive] lemma is_open_map_div_left (a : G) : is_open_map ((/) a) :=\n(homeomorph.div_left _).is_open_map\n\n@[to_additive] lemma is_closed_map_div_left (a : G) : is_closed_map ((/) a) :=\n(homeomorph.div_left _).is_closed_map\n\n/-- A version of `homeomorph.mul_right a⁻¹ b` that is defeq to `b / a`. -/\n@[to_additive /-\" A version of `homeomorph.add_right (-a) b` that is defeq to `b - a`. \"-/,\n  simps {simp_rhs := tt}]\ndef homeomorph.div_right (x : G) : G ≃ₜ G :=\n{ continuous_to_fun := continuous_id.div' continuous_const,\n  continuous_inv_fun := continuous_id.mul continuous_const,\n  .. equiv.div_right x }\n\n@[to_additive]\nlemma is_open_map_div_right (a : G) : is_open_map (λ x, x / a) :=\n(homeomorph.div_right a).is_open_map\n\n@[to_additive]\nlemma is_closed_map_div_right (a : G) : is_closed_map (λ x, x / a) :=\n(homeomorph.div_right a).is_closed_map\n\n@[to_additive]\nlemma tendsto_div_nhds_one_iff\n  {α : Type*} {l : filter α} {x : G} {u : α → G} :\n  tendsto (λ n, u n / x) l (𝓝 1) ↔ tendsto u l (𝓝 x) :=\nbegin\n  have A : tendsto (λ (n : α), x) l (𝓝 x) := tendsto_const_nhds,\n  exact ⟨λ h, by simpa using h.mul A, λ h, by simpa using h.div' A⟩\nend\n\n@[to_additive] lemma nhds_translation_div (x : G) : comap (/ x) (𝓝 1) = 𝓝 x :=\nby simpa only [div_eq_mul_inv] using nhds_translation_mul_inv x\n\nend div_in_topological_group\n\n/-!\n### Topological operations on pointwise sums and products\n\nA few results about interior and closure of the pointwise addition/multiplication of sets in groups\nwith continuous addition/multiplication. See also `submonoid.top_closure_mul_self_eq` in\n`topology.algebra.monoid`.\n-/\n\nsection has_continuous_mul\nvariables [topological_space α] [group α] [has_continuous_mul α] {s t : set α}\n\n@[to_additive] lemma is_open.mul_left (ht : is_open t) : is_open (s * t) :=\nby { rw ←Union_mul_left_image, exact is_open_bUnion (λ a ha, is_open_map_mul_left a t ht) }\n\n@[to_additive] lemma is_open.mul_right (hs : is_open s) : is_open (s * t) :=\nby { rw ←Union_mul_right_image, exact is_open_bUnion (λ a ha, is_open_map_mul_right a s hs) }\n\n@[to_additive] lemma subset_interior_mul_left : interior s * t ⊆ interior (s * t) :=\ninterior_maximal (set.mul_subset_mul_right interior_subset) is_open_interior.mul_right\n\n@[to_additive] lemma subset_interior_mul_right : s * interior t ⊆ interior (s * t) :=\ninterior_maximal (set.mul_subset_mul_left interior_subset) is_open_interior.mul_left\n\n@[to_additive] lemma subset_interior_mul : interior s * interior t ⊆ interior (s * t) :=\n(set.mul_subset_mul_left interior_subset).trans subset_interior_mul_left\n\nend has_continuous_mul\n\nsection topological_group\nvariables [topological_space α] [group α] [topological_group α] {s t : set α}\n\n@[to_additive] lemma is_open.div_left (ht : is_open t) : is_open (s / t) :=\nby { rw ←Union_div_left_image, exact is_open_bUnion (λ a ha, is_open_map_div_left a t ht) }\n\n@[to_additive] lemma is_open.div_right (hs : is_open s) : is_open (s / t) :=\nby { rw ←Union_div_right_image, exact is_open_bUnion (λ a ha, is_open_map_div_right a s hs) }\n\n@[to_additive] lemma subset_interior_div_left : interior s / t ⊆ interior (s / t) :=\ninterior_maximal (div_subset_div_right interior_subset) is_open_interior.div_right\n\n@[to_additive] lemma subset_interior_div_right : s / interior t ⊆ interior (s / t) :=\ninterior_maximal (div_subset_div_left interior_subset) is_open_interior.div_left\n\n@[to_additive] lemma subset_interior_div : interior s / interior t ⊆ interior (s / t) :=\n(div_subset_div_left interior_subset).trans subset_interior_div_left\n\n@[to_additive] lemma is_open.mul_closure (hs : is_open s) (t : set α) : s * closure t = s * t :=\nbegin\n  refine (mul_subset_iff.2 $ λ a ha b hb, _).antisymm (mul_subset_mul_left subset_closure),\n  rw mem_closure_iff at hb,\n  have hbU : b ∈ s⁻¹ * {a * b} := ⟨a⁻¹, a * b, set.inv_mem_inv.2 ha, rfl, inv_mul_cancel_left _ _⟩,\n  obtain ⟨_, ⟨c, d, hc, (rfl : d = _), rfl⟩, hcs⟩ := hb _ hs.inv.mul_right hbU,\n  exact ⟨c⁻¹, _, hc, hcs, inv_mul_cancel_left _ _⟩,\nend\n\n@[to_additive] lemma is_open.closure_mul (ht : is_open t) (s : set α) : closure s * t = s * t :=\nby rw [←inv_inv (closure s * t), mul_inv_rev, inv_closure, ht.inv.mul_closure, mul_inv_rev, inv_inv,\n  inv_inv]\n\n@[to_additive] lemma is_open.div_closure (hs : is_open s) (t : set α) : s / closure t = s / t :=\nby simp_rw [div_eq_mul_inv, inv_closure, hs.mul_closure]\n\n@[to_additive] lemma is_open.closure_div (ht : is_open t) (s : set α) : closure s / t = s / t :=\nby simp_rw [div_eq_mul_inv, ht.inv.closure_mul]\n\nend topological_group\n\n/-- additive group with a neighbourhood around 0.\nOnly used to construct a topology and uniform space.\n\nThis is currently only available for commutative groups, but it can be extended to\nnon-commutative groups too.\n-/\nclass add_group_with_zero_nhd (G : Type u) extends add_comm_group G :=\n(Z [] : filter G)\n(zero_Z : pure 0 ≤ Z)\n(sub_Z : tendsto (λp:G×G, p.1 - p.2) (Z ×ᶠ Z) Z)\n\nsection filter_mul\n\nsection\nvariables (G) [topological_space G] [group G] [topological_group G]\n\n@[to_additive]\nlemma topological_group.t1_space (h : @is_closed G _ {1}) : t1_space G :=\n⟨assume x, by { convert is_closed_map_mul_right x _ h, simp }⟩\n\n@[to_additive]\nlemma topological_group.regular_space [t1_space G] : regular_space G :=\n⟨assume s a hs ha,\n let f := λ p : G × G, p.1 * (p.2)⁻¹ in\n have hf : continuous f := continuous_fst.mul continuous_snd.inv,\n -- a ∈ -s implies f (a, 1) ∈ -s, and so (a, 1) ∈ f⁻¹' (-s);\n -- and so can find t₁ t₂ open such that a ∈ t₁ × t₂ ⊆ f⁻¹' (-s)\n let ⟨t₁, t₂, ht₁, ht₂, a_mem_t₁, one_mem_t₂, t_subset⟩ :=\n   is_open_prod_iff.1 ((is_open_compl_iff.2 hs).preimage hf) a (1:G) (by simpa [f]) in\n begin\n   use [s * t₂, ht₂.mul_left, λ x hx, ⟨x, 1, hx, one_mem_t₂, mul_one _⟩],\n   rw [nhds_within, inf_principal_eq_bot, mem_nhds_iff],\n   refine ⟨t₁, _, ht₁, a_mem_t₁⟩,\n   rintros x hx ⟨y, z, hy, hz, yz⟩,\n   have : x * z⁻¹ ∈ sᶜ := (prod_subset_iff.1 t_subset) x hx z hz,\n   have : x * z⁻¹ ∈ s, rw ← yz, simpa,\n   contradiction\n end⟩\n\n@[to_additive]\nlemma topological_group.t2_space [t1_space G] : t2_space G :=\n@regular_space.t2_space G _ (topological_group.regular_space G)\n\nvariables {G} (S : subgroup G) [subgroup.normal S] [is_closed (S : set G)]\n\n@[to_additive]\ninstance subgroup.regular_quotient_of_is_closed\n  (S : subgroup G) [subgroup.normal S] [is_closed (S : set G)] : regular_space (G ⧸ S) :=\nbegin\n  suffices : t1_space (G ⧸ S), { exact @topological_group.regular_space _ _ _ _ this, },\n  have hS : is_closed (S : set G) := infer_instance,\n  rw ← quotient_group.ker_mk S at hS,\n  exact topological_group.t1_space (G ⧸ S) ((quotient_map_quotient_mk.is_closed_preimage).mp hS),\nend\n\nend\n\nsection\n\n/-! Some results about an open set containing the product of two sets in a topological group. -/\n\nvariables [topological_space G] [group G] [topological_group G]\n\n/-- Given a compact set `K` inside an open set `U`, there is a open neighborhood `V` of `1`\n  such that `K * V ⊆ U`. -/\n@[to_additive \"Given a compact set `K` inside an open set `U`, there is a open neighborhood `V` of\n`0` such that `K + V ⊆ U`.\"]\nlemma compact_open_separated_mul_right {K U : set G} (hK : is_compact K) (hU : is_open U)\n  (hKU : K ⊆ U) : ∃ V ∈ 𝓝 (1 : G), K * V ⊆ U :=\nbegin\n  apply hK.induction_on,\n  { exact ⟨univ, by simp⟩ },\n  { rintros s t hst ⟨V, hV, hV'⟩,\n    exact ⟨V, hV, (mul_subset_mul_right hst).trans hV'⟩ },\n  { rintros s t  ⟨V, V_in, hV'⟩ ⟨W, W_in, hW'⟩,\n    use [V ∩ W, inter_mem V_in W_in],\n    rw union_mul,\n    exact union_subset ((mul_subset_mul_left (V.inter_subset_left W)).trans hV')\n                       ((mul_subset_mul_left (V.inter_subset_right W)).trans hW') },\n  { intros x hx,\n    have := tendsto_mul (show U ∈ 𝓝 (x * 1), by simpa using hU.mem_nhds (hKU hx)),\n    rw [nhds_prod_eq, mem_map, mem_prod_iff] at this,\n    rcases this with ⟨t, ht, s, hs, h⟩,\n    rw [← image_subset_iff, image_mul_prod] at h,\n    exact ⟨t, mem_nhds_within_of_mem_nhds ht, s, hs, h⟩ }\nend\n\nopen mul_opposite\n\n/-- Given a compact set `K` inside an open set `U`, there is a open neighborhood `V` of `1`\n  such that `V * K ⊆ U`. -/\n@[to_additive \"Given a compact set `K` inside an open set `U`, there is a open neighborhood `V` of\n`0` such that `V + K ⊆ U`.\"]\nlemma compact_open_separated_mul_left {K U : set G} (hK : is_compact K) (hU : is_open U)\n  (hKU : K ⊆ U) : ∃ V ∈ 𝓝 (1 : G), V * K ⊆ U :=\nbegin\n  rcases compact_open_separated_mul_right (hK.image continuous_op) (op_homeomorph.is_open_map U hU)\n    (image_subset op hKU) with ⟨V, (hV : V ∈ 𝓝 (op (1 : G))), hV' : op '' K * V ⊆ op '' U⟩,\n  refine ⟨op ⁻¹' V, continuous_op.continuous_at hV, _⟩,\n  rwa [← image_preimage_eq V op_surjective, ← image_op_mul, image_subset_iff,\n    preimage_image_eq _ op_injective] at hV'\nend\n\n/-- A compact set is covered by finitely many left multiplicative translates of a set\n  with non-empty interior. -/\n@[to_additive \"A compact set is covered by finitely many left additive translates of a set\n  with non-empty interior.\"]\nlemma compact_covered_by_mul_left_translates {K V : set G} (hK : is_compact K)\n  (hV : (interior V).nonempty) : ∃ t : finset G, K ⊆ ⋃ g ∈ t, (λ h, g * h) ⁻¹' V :=\nbegin\n  obtain ⟨t, ht⟩ : ∃ t : finset G, K ⊆ ⋃ x ∈ t, interior (((*) x) ⁻¹' V),\n  { refine hK.elim_finite_subcover (λ x, interior $ ((*) x) ⁻¹' V) (λ x, is_open_interior) _,\n    cases hV with g₀ hg₀,\n    refine λ g hg, mem_Union.2 ⟨g₀ * g⁻¹, _⟩,\n    refine preimage_interior_subset_interior_preimage (continuous_const.mul continuous_id) _,\n    rwa [mem_preimage, inv_mul_cancel_right] },\n  exact ⟨t, subset.trans ht $ Union₂_mono $ λ g hg, interior_subset⟩\nend\n\n/-- Every locally compact separable topological group is σ-compact.\n  Note: this is not true if we drop the topological group hypothesis. -/\n@[priority 100, to_additive separable_locally_compact_add_group.sigma_compact_space]\ninstance separable_locally_compact_group.sigma_compact_space\n  [separable_space G] [locally_compact_space G] : sigma_compact_space G :=\nbegin\n  obtain ⟨L, hLc, hL1⟩ := exists_compact_mem_nhds (1 : G),\n  refine ⟨⟨λ n, (λ x, x * dense_seq G n) ⁻¹' L, _, _⟩⟩,\n  { intro n, exact (homeomorph.mul_right _).compact_preimage.mpr hLc },\n  { refine Union_eq_univ_iff.2 (λ x, _),\n    obtain ⟨_, ⟨n, rfl⟩, hn⟩ : (range (dense_seq G) ∩ (λ y, x * y) ⁻¹' L).nonempty,\n    { rw [← (homeomorph.mul_left x).apply_symm_apply 1] at hL1,\n      exact (dense_range_dense_seq G).inter_nhds_nonempty\n        ((homeomorph.mul_left x).continuous.continuous_at $ hL1) },\n    exact ⟨n, hn⟩ }\nend\n\n/-- Every separated topological group in which there exists a compact set with nonempty interior\nis locally compact. -/\n@[to_additive] lemma topological_space.positive_compacts.locally_compact_space_of_group\n  [t2_space G] (K : positive_compacts G) :\n  locally_compact_space G :=\nbegin\n  refine locally_compact_of_compact_nhds (λ x, _),\n  obtain ⟨y, hy⟩ := K.interior_nonempty,\n  let F := homeomorph.mul_left (x * y⁻¹),\n  refine ⟨F '' K, _, K.compact.image F.continuous⟩,\n  suffices : F.symm ⁻¹' K ∈ 𝓝 x, by { convert this, apply equiv.image_eq_preimage },\n  apply continuous_at.preimage_mem_nhds F.symm.continuous.continuous_at,\n  have : F.symm x = y, by simp [F, homeomorph.mul_left_symm],\n  rw this,\n  exact mem_interior_iff_mem_nhds.1 hy\nend\n\nend\n\nsection\nvariables [topological_space G] [comm_group G] [topological_group G]\n\n@[to_additive]\nlemma nhds_mul (x y : G) : 𝓝 (x * y) = 𝓝 x * 𝓝 y :=\nfilter_eq $ set.ext $ assume s,\nbegin\n  rw [← nhds_translation_mul_inv x, ← nhds_translation_mul_inv y, ← nhds_translation_mul_inv (x*y)],\n  split,\n  { rintros ⟨t, ht, ts⟩,\n    rcases exists_nhds_one_split ht with ⟨V, V1, h⟩,\n    refine ⟨(λa, a * x⁻¹) ⁻¹' V, (λa, a * y⁻¹) ⁻¹' V,\n            ⟨V, V1, subset.refl _⟩, ⟨V, V1, subset.refl _⟩, _⟩,\n    rintros a ⟨v, w, v_mem, w_mem, rfl⟩,\n    apply ts,\n    simpa [mul_comm, mul_assoc, mul_left_comm] using h (v * x⁻¹) v_mem (w * y⁻¹) w_mem },\n  { rintros ⟨a, c, ⟨b, hb, ba⟩, ⟨d, hd, dc⟩, ac⟩,\n    refine ⟨b ∩ d, inter_mem hb hd, assume v, _⟩,\n    simp only [preimage_subset_iff, mul_inv_rev, mem_preimage] at *,\n    rintros ⟨vb, vd⟩,\n    refine ac ⟨v * y⁻¹, y, _, _, _⟩,\n    { rw ← mul_assoc _ _ _ at vb, exact ba _ vb },\n    { apply dc y, rw mul_right_inv, exact mem_of_mem_nhds hd },\n    { simp only [inv_mul_cancel_right] } }\nend\n\n/-- On a topological group, `𝓝 : G → filter G` can be promoted to a `mul_hom`. -/\n@[to_additive \"On an additive topological group, `𝓝 : G → filter G` can be promoted to an\n`add_hom`.\", simps]\ndef nhds_mul_hom : G →ₙ* (filter G) :=\n{ to_fun := 𝓝,\n  map_mul' := λ_ _, nhds_mul _ _ }\n\nend\n\nend filter_mul\n\ninstance additive.topological_add_group {G} [h : topological_space G]\n  [group G] [topological_group G] : @topological_add_group (additive G) h _ :=\n{ continuous_neg := @continuous_inv G _ _ _ }\n\ninstance multiplicative.topological_group {G} [h : topological_space G]\n  [add_group G] [topological_add_group G] : @topological_group (multiplicative G) h _ :=\n{ continuous_inv := @continuous_neg G _ _ _ }\n\nsection quotient\nvariables [group G] [topological_space G] [topological_group G] {Γ : subgroup G}\n\n@[to_additive]\ninstance quotient_group.has_continuous_const_smul : has_continuous_const_smul G (G ⧸ Γ) :=\n{ continuous_const_smul := λ g₀, begin\n    apply continuous_coinduced_dom,\n    change continuous (λ g : G, quotient_group.mk (g₀ * g)),\n    exact continuous_coinduced_rng.comp (continuous_mul_left g₀),\n  end }\n\n@[to_additive]\nlemma quotient_group.continuous_smul₁ (x : G ⧸ Γ) : continuous (λ g : G, g • x) :=\nbegin\n  obtain ⟨g₀, rfl⟩ : ∃ g₀, quotient_group.mk g₀ = x,\n  { exact @quotient.exists_rep _ (quotient_group.left_rel Γ) x },\n  change continuous (λ g, quotient_group.mk (g * g₀)),\n  exact continuous_coinduced_rng.comp (continuous_mul_right g₀)\nend\n\n@[to_additive]\ninstance quotient_group.has_continuous_smul [locally_compact_space G] :\n  has_continuous_smul G (G ⧸ Γ) :=\n{ continuous_smul := begin\n    let F : G × G ⧸ Γ → G ⧸ Γ := λ p, p.1 • p.2,\n    change continuous F,\n    have H : continuous (F ∘ (λ p : G × G, (p.1, quotient_group.mk p.2))),\n    { change continuous (λ p : G × G, quotient_group.mk (p.1 * p.2)),\n      refine continuous_coinduced_rng.comp continuous_mul },\n    exact quotient_map.continuous_lift_prod_right quotient_map_quotient_mk H,\n  end }\n\nend quotient\n\nnamespace units\n\nopen mul_opposite (continuous_op continuous_unop)\n\nvariables [monoid α] [topological_space α] [has_continuous_mul α] [monoid β] [topological_space β]\n  [has_continuous_mul β]\n\n@[to_additive] instance : topological_group αˣ :=\n{ continuous_inv := continuous_induced_rng ((continuous_unop.comp\n    (@continuous_embed_product α _ _).snd).prod_mk (continuous_op.comp continuous_coe)) }\n\n/-- The topological group isomorphism between the units of a product of two monoids, and the product\n    of the units of each monoid. -/\ndef homeomorph.prod_units : homeomorph (α × β)ˣ (αˣ × βˣ) :=\n{ continuous_to_fun  :=\n  begin\n    show continuous (λ i : (α × β)ˣ, (map (monoid_hom.fst α β) i, map (monoid_hom.snd α β) i)),\n    refine continuous.prod_mk _ _,\n    { refine continuous_induced_rng ((continuous_fst.comp units.continuous_coe).prod_mk _),\n      refine mul_opposite.continuous_op.comp (continuous_fst.comp _),\n      simp_rw units.inv_eq_coe_inv,\n      exact units.continuous_coe.comp continuous_inv, },\n    { refine continuous_induced_rng ((continuous_snd.comp units.continuous_coe).prod_mk _),\n      simp_rw units.coe_map_inv,\n      exact continuous_op.comp (continuous_snd.comp (units.continuous_coe.comp continuous_inv)), }\n  end,\n  continuous_inv_fun :=\n  begin\n    refine continuous_induced_rng (continuous.prod_mk _ _),\n    { exact (units.continuous_coe.comp continuous_fst).prod_mk\n        (units.continuous_coe.comp continuous_snd), },\n    { refine continuous_op.comp\n        (units.continuous_coe.comp $ continuous_induced_rng $ continuous.prod_mk _ _),\n      { exact (units.continuous_coe.comp (continuous_inv.comp continuous_fst)).prod_mk\n          (units.continuous_coe.comp (continuous_inv.comp continuous_snd)) },\n      { exact continuous_op.comp ((units.continuous_coe.comp continuous_fst).prod_mk\n            (units.continuous_coe.comp continuous_snd)) }}\n  end,\n  ..mul_equiv.prod_units }\n\nend units\n\nsection lattice_ops\n\nvariables {ι : Sort*} [group G] [group H] {ts : set (topological_space G)}\n  (h : ∀ t ∈ ts, @topological_group G t _) {ts' : ι → topological_space G}\n  (h' : ∀ i, @topological_group G (ts' i) _) {t₁ t₂ : topological_space G}\n  (h₁ : @topological_group G t₁ _) (h₂ : @topological_group G t₂ _)\n  {t : topological_space H} [topological_group H] {F : Type*}\n  [monoid_hom_class F G H] (f : F)\n\n@[to_additive] lemma topological_group_Inf :\n  @topological_group G (Inf ts) _ :=\n{ continuous_inv := @has_continuous_inv.continuous_inv G (Inf ts) _\n    (@has_continuous_inv_Inf _ _ _\n      (λ t ht, @topological_group.to_has_continuous_inv G t _ (h t ht))),\n  continuous_mul := @has_continuous_mul.continuous_mul G (Inf ts) _\n    (@has_continuous_mul_Inf _ _ _\n      (λ t ht, @topological_group.to_has_continuous_mul G t _ (h t ht))) }\n\ninclude h'\n\n@[to_additive] lemma topological_group_infi :\n  @topological_group G (⨅ i, ts' i) _ :=\nby {rw ← Inf_range, exact topological_group_Inf (set.forall_range_iff.mpr h')}\n\nomit h'\n\ninclude h₁ h₂\n\n@[to_additive] lemma topological_group_inf :\n  @topological_group G (t₁ ⊓ t₂) _ :=\nby {rw inf_eq_infi, refine topological_group_infi (λ b, _), cases b; assumption}\n\nomit h₁ h₂\n\n@[to_additive] lemma topological_group_induced :\n  @topological_group G (t.induced f) _ :=\n{ continuous_inv :=\n    begin\n      letI : topological_space G := t.induced f,\n      refine continuous_induced_rng _,\n      simp_rw [function.comp, map_inv],\n      exact continuous_inv.comp (continuous_induced_dom : continuous f)\n    end,\n  continuous_mul := @has_continuous_mul.continuous_mul G (t.induced f) _\n    (@has_continuous_mul_induced G H _ _ t _ _ _ f) }\n\nend lattice_ops\n\n/-!\n### Lattice of group topologies\nWe define a type class `group_topology α` which endows a group `α` with a topology such that all\ngroup operations are continuous.\n\nGroup topologies on a fixed group `α` are ordered, by reverse inclusion. They form a complete\nlattice, with `⊥` the discrete topology and `⊤` the indiscrete topology.\n\nAny function `f : α → β` induces `coinduced f : topological_space α → group_topology β`.\n\nThe additive version `add_group_topology α` and corresponding results are provided as well.\n-/\n\n/-- A group topology on a group `α` is a topology for which multiplication and inversion\nare continuous. -/\nstructure group_topology (α : Type u) [group α]\n  extends topological_space α, topological_group α : Type u\n\n/-- An additive group topology on an additive group `α` is a topology for which addition and\n  negation are continuous. -/\nstructure add_group_topology (α : Type u) [add_group α]\n  extends topological_space α, topological_add_group α : Type u\n\nattribute [to_additive] group_topology\n\nnamespace group_topology\n\nvariables [group α]\n\n/-- A version of the global `continuous_mul` suitable for dot notation. -/\n@[to_additive]\nlemma continuous_mul' (g : group_topology α) :\n  by haveI := g.to_topological_space; exact continuous (λ p : α × α, p.1 * p.2) :=\nbegin\n  letI := g.to_topological_space,\n  haveI := g.to_topological_group,\n  exact continuous_mul,\nend\n\n/-- A version of the global `continuous_inv` suitable for dot notation. -/\n@[to_additive]\nlemma continuous_inv' (g : group_topology α) :\n  by haveI := g.to_topological_space; exact continuous (has_inv.inv : α → α) :=\nbegin\n  letI := g.to_topological_space,\n  haveI := g.to_topological_group,\n  exact continuous_inv,\nend\n\n@[to_additive]\nlemma to_topological_space_injective :\n  function.injective (to_topological_space : group_topology α → topological_space α):=\nλ f g h, by { cases f, cases g, congr' }\n\n@[ext, to_additive]\nlemma ext' {f g : group_topology α} (h : f.is_open = g.is_open) : f = g :=\nto_topological_space_injective $ topological_space_eq h\n\n/-- The ordering on group topologies on the group `γ`.\n  `t ≤ s` if every set open in `s` is also open in `t` (`t` is finer than `s`). -/\n@[to_additive]\ninstance : partial_order (group_topology α) :=\npartial_order.lift to_topological_space to_topological_space_injective\n\n@[simp, to_additive] lemma to_topological_space_le {x y : group_topology α} :\n  x.to_topological_space ≤ y.to_topological_space ↔ x ≤ y := iff.rfl\n\n@[to_additive]\ninstance : has_top (group_topology α) :=\n⟨{to_topological_space := ⊤,\n  continuous_mul       := continuous_top,\n  continuous_inv       := continuous_top}⟩\n\n@[simp, to_additive] lemma to_topological_space_top :\n  (⊤ : group_topology α).to_topological_space = ⊤ := rfl\n\n@[to_additive]\ninstance : has_bot (group_topology α) :=\n⟨{to_topological_space := ⊥,\n  continuous_mul       := by continuity,\n  continuous_inv       := continuous_bot}⟩\n\n@[simp, to_additive] lemma to_topological_space_bot :\n  (⊥ : group_topology α).to_topological_space = ⊥ := rfl\n\n@[to_additive]\ninstance : bounded_order (group_topology α) :=\n{ top := ⊤,\n  le_top := λ x, show x.to_topological_space ≤ ⊤, from le_top,\n  bot := ⊥,\n  bot_le := λ x, show ⊥ ≤ x.to_topological_space, from bot_le }\n\n@[to_additive]\ninstance : has_inf (group_topology α) :=\n{ inf := λ x y,\n  { to_topological_space := x.to_topological_space ⊓ y.to_topological_space,\n    continuous_mul := continuous_inf_rng\n      (continuous_inf_dom_left₂ x.continuous_mul') (continuous_inf_dom_right₂ y.continuous_mul'),\n    continuous_inv := continuous_inf_rng\n      (continuous_inf_dom_left x.continuous_inv') (continuous_inf_dom_right y.continuous_inv') } }\n\n@[simp, to_additive]\nlemma to_topological_space_inf (x y : group_topology α) :\n  (x ⊓ y).to_topological_space = x.to_topological_space ⊓ y.to_topological_space := rfl\n\n@[to_additive]\ninstance : semilattice_inf (group_topology α) :=\nto_topological_space_injective.semilattice_inf _ to_topological_space_inf\n\n@[to_additive]\ninstance : inhabited (group_topology α) := ⟨⊤⟩\n\nlocal notation `cont` := @continuous _ _\n@[to_additive \"Infimum of a collection of additive group topologies\"]\ninstance : has_Inf (group_topology α) :=\n{ Inf := λ S,\n  { to_topological_space := Inf (to_topological_space '' S),\n    continuous_mul       := continuous_Inf_rng begin\n      rintros _ ⟨⟨t, tr⟩, haS, rfl⟩, resetI,\n      exact continuous_Inf_dom₂\n        (set.mem_image_of_mem to_topological_space haS)\n        (set.mem_image_of_mem to_topological_space haS) continuous_mul,\n    end,\n    continuous_inv       := continuous_Inf_rng begin\n      rintros _ ⟨⟨t, tr⟩, haS, rfl⟩, resetI,\n      exact continuous_Inf_dom (set.mem_image_of_mem to_topological_space haS) continuous_inv,\n    end, } }\n\n@[simp, to_additive]\nlemma to_topological_space_Inf (s : set (group_topology α)) :\n  (Inf s).to_topological_space = Inf (to_topological_space '' s) := rfl\n\n@[simp, to_additive]\nlemma to_topological_space_infi {ι} (s : ι → group_topology α) :\n  (⨅ i, s i).to_topological_space = ⨅ i, (s i).to_topological_space :=\ncongr_arg Inf (range_comp _ _).symm\n\n/-- Group topologies on `γ` form a complete lattice, with `⊥` the discrete topology and `⊤` the\nindiscrete topology.\n\nThe infimum of a collection of group topologies is the topology generated by all their open sets\n(which is a group topology).\n\nThe supremum of two group topologies `s` and `t` is the infimum of the family of all group\ntopologies contained in the intersection of `s` and `t`. -/\n@[to_additive]\ninstance : complete_semilattice_Inf (group_topology α) :=\n{ Inf_le := λ S a haS, to_topological_space_le.1 $ Inf_le ⟨a, haS, rfl⟩,\n  le_Inf :=\n  begin\n    intros S a hab,\n    apply topological_space.complete_lattice.le_Inf,\n    rintros _ ⟨b, hbS, rfl⟩,\n    exact hab b hbS,\n  end,\n  ..group_topology.has_Inf,\n  ..group_topology.partial_order }\n\n@[to_additive]\ninstance : complete_lattice (group_topology α) :=\n{ inf := (⊓),\n  top := ⊤,\n  bot := ⊥,\n  ..group_topology.bounded_order,\n  ..group_topology.semilattice_inf,\n  ..complete_lattice_of_complete_semilattice_Inf _ }\n\n/--  Given `f : α → β` and a topology on `α`, the coinduced group topology on `β` is the finest\ntopology such that `f` is continuous and `β` is a topological group. -/\n@[to_additive \"Given `f : α → β` and a topology on `α`, the coinduced additive group topology on `β`\nis the finest topology such that `f` is continuous and `β` is a topological additive group.\"]\ndef coinduced {α β : Type*} [t : topological_space α] [group β] (f : α → β) :\n  group_topology β :=\nInf {b : group_topology β | (topological_space.coinduced f t) ≤ b.to_topological_space}\n\n@[to_additive]\nlemma coinduced_continuous {α β : Type*} [t : topological_space α] [group β]\n  (f : α → β) : cont t (coinduced f).to_topological_space f :=\nbegin\n  rw continuous_iff_coinduced_le,\n  refine le_Inf _,\n  rintros _ ⟨t', ht', rfl⟩,\n  exact ht',\nend\n\nend group_topology\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/topology/algebra/group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.4863512968454503}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.over\n! leanprover-community/mathlib commit f47581155c818e6361af4e4fda60d27d020c226b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.StructuredArrow\nimport Mathbin.CategoryTheory.Punit\nimport Mathbin.CategoryTheory.Functor.ReflectsIsomorphisms\nimport Mathbin.CategoryTheory.Functor.EpiMono\n\n/-!\n# Over and under categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nOver (and under) categories are special cases of comma categories.\n* If `L` is the identity functor and `R` is a constant functor, then `comma L R` is the \"slice\" or\n  \"over\" category over the object `R` maps to.\n* Conversely, if `L` is a constant functor and `R` is the identity functor, then `comma L R` is the\n  \"coslice\" or \"under\" category under the object `L` maps to.\n\n## Tags\n\ncomma, slice, coslice, over, under\n-/\n\n\nnamespace CategoryTheory\n\nuniverse v₁ v₂ u₁ u₂\n\n-- morphism levels before object levels. See note [category_theory universes].\nvariable {T : Type u₁} [Category.{v₁} T]\n\n#print CategoryTheory.Over /-\n/-- The over category has as objects arrows in `T` with codomain `X` and as morphisms commutative\ntriangles.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\ndef Over (X : T) :=\n  CostructuredArrow (𝟭 T) X deriving Category\n#align category_theory.over CategoryTheory.Over\n-/\n\n#print CategoryTheory.Over.inhabited /-\n-- Satisfying the inhabited linter\ninstance Over.inhabited [Inhabited T] : Inhabited (Over (default : T))\n    where default :=\n    { left := default\n      right := default\n      Hom := 𝟙 _ }\n#align category_theory.over.inhabited CategoryTheory.Over.inhabited\n-/\n\nnamespace Over\n\nvariable {X : T}\n\n#print CategoryTheory.Over.OverMorphism.ext /-\n@[ext]\ntheorem OverMorphism.ext {X : T} {U V : Over X} {f g : U ⟶ V} (h : f.left = g.left) : f = g := by\n  tidy\n#align category_theory.over.over_morphism.ext CategoryTheory.Over.OverMorphism.ext\n-/\n\n#print CategoryTheory.Over.over_right /-\n@[simp]\ntheorem over_right (U : Over X) : U.right = ⟨⟨⟩⟩ := by tidy\n#align category_theory.over.over_right CategoryTheory.Over.over_right\n-/\n\n#print CategoryTheory.Over.id_left /-\n@[simp]\ntheorem id_left (U : Over X) : CommaMorphism.left (𝟙 U) = 𝟙 U.left :=\n  rfl\n#align category_theory.over.id_left CategoryTheory.Over.id_left\n-/\n\n#print CategoryTheory.Over.comp_left /-\n@[simp]\ntheorem comp_left (a b c : Over X) (f : a ⟶ b) (g : b ⟶ c) : (f ≫ g).left = f.left ≫ g.left :=\n  rfl\n#align category_theory.over.comp_left CategoryTheory.Over.comp_left\n-/\n\n/- warning: category_theory.over.w -> CategoryTheory.Over.w is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {A : CategoryTheory.Over.{u1, u2} T _inst_1 X} {B : CategoryTheory.Over.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.category.{u2, u1} T _inst_1 X))) A B), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B))) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B)) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A B f) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B)) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {A : CategoryTheory.Over.{u1, u2} T _inst_1 X} {B : CategoryTheory.Over.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) A B), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B))) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B)) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A B f) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) B)) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) A)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.w CategoryTheory.Over.wₓ'. -/\n@[simp, reassoc.1]\ntheorem w {A B : Over X} (f : A ⟶ B) : f.left ≫ B.Hom = A.Hom := by have := f.w <;> tidy\n#align category_theory.over.w CategoryTheory.Over.w\n\n#print CategoryTheory.Over.mk /-\n/-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/\n@[simps left Hom]\ndef mk {X Y : T} (f : Y ⟶ X) : Over X :=\n  CostructuredArrow.mk f\n#align category_theory.over.mk CategoryTheory.Over.mk\n-/\n\n#print CategoryTheory.Over.coeFromHom /-\n/-- We can set up a coercion from arrows with codomain `X` to `over X`. This most likely should not\n    be a global instance, but it is sometimes useful. -/\ndef coeFromHom {X Y : T} : Coe (Y ⟶ X) (Over X) where coe := mk\n#align category_theory.over.coe_from_hom CategoryTheory.Over.coeFromHom\n-/\n\nsection\n\nattribute [local instance] coe_from_hom\n\n/- warning: category_theory.over.coe_hom -> CategoryTheory.Over.coe_hom is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} (f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) ((fun (a : Type.{u1}) (b : Type.{max u2 u1}) [self : HasLiftT.{succ u1, succ (max u2 u1)} a b] => self.0) (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (HasLiftT.mk.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CoeTCₓ.coe.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (coeBase.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.coeFromHom.{u1, u2} T _inst_1 X Y)))) f))) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) ((fun (a : Type.{u1}) (b : Type.{max u2 u1}) [self : HasLiftT.{succ u1, succ (max u2 u1)} a b] => self.0) (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (HasLiftT.mk.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CoeTCₓ.coe.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (coeBase.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.coeFromHom.{u1, u2} T _inst_1 X Y)))) f)))) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) ((fun (a : Type.{u1}) (b : Type.{max u2 u1}) [self : HasLiftT.{succ u1, succ (max u2 u1)} a b] => self.0) (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (HasLiftT.mk.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CoeTCₓ.coe.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (coeBase.{succ u1, succ (max u2 u1)} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X) (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.coeFromHom.{u1, u2} T _inst_1 X Y)))) f)) f\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} (f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) Y X), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Over.mk.{u1, u2} T _inst_1 X Y f))) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Over.mk.{u1, u2} T _inst_1 X Y f)))) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Over.mk.{u1, u2} T _inst_1 X Y f)) f\nCase conversion may be inaccurate. Consider using '#align category_theory.over.coe_hom CategoryTheory.Over.coe_homₓ'. -/\n@[simp]\ntheorem coe_hom {X Y : T} (f : Y ⟶ X) : (f : Over X).Hom = f :=\n  rfl\n#align category_theory.over.coe_hom CategoryTheory.Over.coe_hom\n\nend\n\n/- warning: category_theory.over.hom_mk -> CategoryTheory.Over.homMk is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X} {V : CategoryTheory.Over.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V)), (autoParamₓ.{0} (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V))) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V)) f (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V)) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)) (Name.mk_string (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str String.empty (Char.ofNat (OfNat.ofNat.{0} Nat 111 (OfNat.mk.{0} Nat 111 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 98 (OfNat.mk.{0} Nat 98 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 118 (OfNat.mk.{0} Nat 118 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 105 (OfNat.mk.{0} Nat 105 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 111 (OfNat.mk.{0} Nat 111 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 117 (OfNat.mk.{0} Nat 117 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 115 (OfNat.mk.{0} Nat 115 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 108 (OfNat.mk.{0} Nat 108 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 121 (OfNat.mk.{0} Nat 121 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) Name.anonymous)) -> (Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.CostructuredArrow.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.CostructuredArrow.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) X) (CategoryTheory.CostructuredArrow.category.{u1, u2, u2, u1} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) X))) U V)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X} {V : CategoryTheory.Over.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V)), (autoParam.{0} (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V))) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V)) f (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) V)) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)) _auto._@.Mathlib.CategoryTheory.Over._hyg.455) -> (Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) U V)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.hom_mk CategoryTheory.Over.homMkₓ'. -/\n/-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative\n    triangle. -/\n@[simps]\ndef homMk {U V : Over X} (f : U.left ⟶ V.left) (w : f ≫ V.Hom = U.Hom := by obviously) : U ⟶ V :=\n  CostructuredArrow.homMk f w\n#align category_theory.over.hom_mk CategoryTheory.Over.homMk\n\n/- warning: category_theory.over.iso_mk -> CategoryTheory.Over.isoMk is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Over.{u1, u2} T _inst_1 X} {g : CategoryTheory.Over.{u1, u2} T _inst_1 X} (hl : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g)), (autoParamₓ.{0} (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g))) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g)) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g) hl) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g)) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f)) (Name.mk_string (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str String.empty (Char.ofNat (OfNat.ofNat.{0} Nat 111 (OfNat.mk.{0} Nat 111 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 98 (OfNat.mk.{0} Nat 98 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 118 (OfNat.mk.{0} Nat 118 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 105 (OfNat.mk.{0} Nat 105 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 111 (OfNat.mk.{0} Nat 111 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 117 (OfNat.mk.{0} Nat 117 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 115 (OfNat.mk.{0} Nat 115 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 108 (OfNat.mk.{0} Nat 108 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 121 (OfNat.mk.{0} Nat 121 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) Name.anonymous)) -> (CategoryTheory.Iso.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) f g)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Over.{u1, u2} T _inst_1 X} {g : CategoryTheory.Over.{u1, u2} T _inst_1 X} (hl : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g)), (autoParam.{0} (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g))) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g)) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g) hl) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) g)) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f)) _auto._@.Mathlib.CategoryTheory.Over._hyg.525) -> (CategoryTheory.Iso.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) f g)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.iso_mk CategoryTheory.Over.isoMkₓ'. -/\n/-- Construct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\n@[simps]\ndef isoMk {f g : Over X} (hl : f.left ≅ g.left) (hw : hl.Hom ≫ g.Hom = f.Hom := by obviously) :\n    f ≅ g :=\n  CostructuredArrow.isoMk hl hw\n#align category_theory.over.iso_mk CategoryTheory.Over.isoMk\n\nsection\n\nvariable (X)\n\n#print CategoryTheory.Over.forget /-\n/-- The forgetful functor mapping an arrow to its domain.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\ndef forget : Over X ⥤ T :=\n  Comma.fst _ _\n#align category_theory.over.forget CategoryTheory.Over.forget\n-/\n\nend\n\n/- warning: category_theory.over.forget_obj -> CategoryTheory.Over.forget_obj is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X}, Eq.{succ u2} T (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X) U) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X}, Eq.{succ u2} T (Prefunctor.obj.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X)) U) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.forget_obj CategoryTheory.Over.forget_objₓ'. -/\n@[simp]\ntheorem forget_obj {U : Over X} : (forget X).obj U = U.left :=\n  rfl\n#align category_theory.over.forget_obj CategoryTheory.Over.forget_obj\n\n/- warning: category_theory.over.forget_map -> CategoryTheory.Over.forget_map is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X} {V : CategoryTheory.Over.{u1, u2} T _inst_1 X} {f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.category.{u2, u1} T _inst_1 X))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X) U) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X) V)) (CategoryTheory.Functor.map.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X) U V f) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U V f)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X} {V : CategoryTheory.Over.{u1, u2} T _inst_1 X} {f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X)) U) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X)) V)) (Prefunctor.map.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Over.forget.{u1, u2} T _inst_1 X)) U V f) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U V f)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.forget_map CategoryTheory.Over.forget_mapₓ'. -/\n@[simp]\ntheorem forget_map {U V : Over X} {f : U ⟶ V} : (forget X).map f = f.left :=\n  rfl\n#align category_theory.over.forget_map CategoryTheory.Over.forget_map\n\n#print CategoryTheory.Over.forgetCocone /-\n/-- The natural cocone over the forgetful functor `over X ⥤ T` with cocone point `X`. -/\n@[simps]\ndef forgetCocone (X : T) : Limits.Cocone (forget X) :=\n  { pt\n    ι := { app := Comma.hom } }\n#align category_theory.over.forget_cocone CategoryTheory.Over.forgetCocone\n-/\n\n#print CategoryTheory.Over.map /-\n/-- A morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\ndef map {Y : T} (f : X ⟶ Y) : Over X ⥤ Over Y :=\n  Comma.mapRight _ <| Discrete.natTrans fun _ => f\n#align category_theory.over.map CategoryTheory.Over.map\n-/\n\nsection\n\nvariable {Y : T} {f : X ⟶ Y} {U V : Over X} {g : U ⟶ V}\n\n/- warning: category_theory.over.map_obj_left -> CategoryTheory.Over.map_obj_left is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X}, Eq.{succ u2} T (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X}, Eq.{succ u2} T (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) U)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.map_obj_left CategoryTheory.Over.map_obj_leftₓ'. -/\n@[simp]\ntheorem map_obj_left : ((map f).obj U).left = U.left :=\n  rfl\n#align category_theory.over.map_obj_left CategoryTheory.Over.map_obj_left\n\n/- warning: category_theory.over.map_obj_hom -> CategoryTheory.Over.map_obj_hom is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U))) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U)))) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U))) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U))) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) f)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) U))) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) U)))) (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) U)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.right.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U)) Y (CategoryTheory.Comma.hom.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U) f)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.map_obj_hom CategoryTheory.Over.map_obj_homₓ'. -/\n@[simp]\ntheorem map_obj_hom : ((map f).obj U).Hom = U.Hom ≫ f :=\n  rfl\n#align category_theory.over.map_obj_hom CategoryTheory.Over.map_obj_hom\n\n/- warning: category_theory.over.map_map_left -> CategoryTheory.Over.map_map_left is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X} {V : CategoryTheory.Over.{u1, u2} T _inst_1 X} {g : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.category.{u2, u1} T _inst_1 X))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) V))) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) V) (CategoryTheory.Functor.map.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y)) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f) U V g)) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U V g)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Over.{u1, u2} T _inst_1 X} {V : CategoryTheory.Over.{u1, u2} T _inst_1 X} {g : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) U)) (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) V))) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) U) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) V) (Prefunctor.map.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X))) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) (CategoryTheory.Over.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 Y) (CategoryTheory.Over.map.{u1, u2} T _inst_1 X Y f)) U V g)) (CategoryTheory.CommaMorphism.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) U V g)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.map_map_left CategoryTheory.Over.map_map_leftₓ'. -/\n@[simp]\ntheorem map_map_left : ((map f).map g).left = g.left :=\n  rfl\n#align category_theory.over.map_map_left CategoryTheory.Over.map_map_left\n\n#print CategoryTheory.Over.mapId /-\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef mapId : map (𝟙 Y) ≅ 𝟭 _ :=\n  NatIso.ofComponents (fun X => isoMk (Iso.refl _) (by tidy)) (by tidy)\n#align category_theory.over.map_id CategoryTheory.Over.mapId\n-/\n\n#print CategoryTheory.Over.mapComp /-\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef mapComp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map f ⋙ map g :=\n  NatIso.ofComponents (fun X => isoMk (Iso.refl _) (by tidy)) (by tidy)\n#align category_theory.over.map_comp CategoryTheory.Over.mapComp\n-/\n\nend\n\n#print CategoryTheory.Over.forget_reflects_iso /-\ninstance forget_reflects_iso : ReflectsIsomorphisms (forget X)\n    where reflects Y Z f t :=\n    ⟨⟨over.hom_mk (inv ((forget X).map f))\n          ((as_iso ((forget X).map f)).inv_comp_eq.2 (over.w f).symm),\n        by tidy⟩⟩\n#align category_theory.over.forget_reflects_iso CategoryTheory.Over.forget_reflects_iso\n-/\n\n#print CategoryTheory.Over.forget_faithful /-\ninstance forget_faithful : Faithful (forget X) where\n#align category_theory.over.forget_faithful CategoryTheory.Over.forget_faithful\n-/\n\n#print CategoryTheory.Over.epi_of_epi_left /-\n-- TODO: Show the converse holds if `T` has binary products.\n/--\nIf `k.left` is an epimorphism, then `k` is an epimorphism. In other words, `over.forget X` reflects\nepimorphisms.\nThe converse does not hold without additional assumptions on the underlying category, see\n`category_theory.over.epi_left_of_epi`.\n-/\ntheorem epi_of_epi_left {f g : Over X} (k : f ⟶ g) [hk : Epi k.left] : Epi k :=\n  (forget X).epi_of_epi_map hk\n#align category_theory.over.epi_of_epi_left CategoryTheory.Over.epi_of_epi_left\n-/\n\n#print CategoryTheory.Over.mono_of_mono_left /-\n/--\nIf `k.left` is a monomorphism, then `k` is a monomorphism. In other words, `over.forget X` reflects\nmonomorphisms.\nThe converse of `category_theory.over.mono_left_of_mono`.\n\nThis lemma is not an instance, to avoid loops in type class inference.\n-/\ntheorem mono_of_mono_left {f g : Over X} (k : f ⟶ g) [hk : Mono k.left] : Mono k :=\n  (forget X).mono_of_mono_map hk\n#align category_theory.over.mono_of_mono_left CategoryTheory.Over.mono_of_mono_left\n-/\n\n#print CategoryTheory.Over.mono_left_of_mono /-\n/--\nIf `k` is a monomorphism, then `k.left` is a monomorphism. In other words, `over.forget X` preserves\nmonomorphisms.\nThe converse of `category_theory.over.mono_of_mono_left`.\n-/\ninstance mono_left_of_mono {f g : Over X} (k : f ⟶ g) [Mono k] : Mono k.left :=\n  by\n  refine' ⟨fun (Y : T) l m a => _⟩\n  let l' : mk (m ≫ f.hom) ⟶ f :=\n    hom_mk l\n      (by\n        dsimp\n        rw [← over.w k, reassoc_of a])\n  suffices l' = hom_mk m by apply congr_arg comma_morphism.left this\n  rw [← cancel_mono k]\n  ext\n  apply a\n#align category_theory.over.mono_left_of_mono CategoryTheory.Over.mono_left_of_mono\n-/\n\nsection IteratedSlice\n\nvariable (f : Over X)\n\n#print CategoryTheory.Over.iteratedSliceForward /-\n/-- Given f : Y ⟶ X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iteratedSliceForward : Over f ⥤ Over f.left\n    where\n  obj α := Over.mk α.Hom.left\n  map α β κ :=\n    Over.homMk κ.left.left\n      (by\n        rw [autoParam_eq]\n        rw [← over.w κ]\n        rfl)\n#align category_theory.over.iterated_slice_forward CategoryTheory.Over.iteratedSliceForward\n-/\n\n#print CategoryTheory.Over.iteratedSliceBackward /-\n/-- Given f : Y ⟶ X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iteratedSliceBackward : Over f.left ⥤ Over f\n    where\n  obj g := mk (homMk g.Hom : mk (g.Hom ≫ f.Hom) ⟶ f)\n  map g h α := homMk (homMk α.left (w_assoc α f.Hom)) (OverMorphism.ext (w α))\n#align category_theory.over.iterated_slice_backward CategoryTheory.Over.iteratedSliceBackward\n-/\n\n/- warning: category_theory.over.iterated_slice_equiv -> CategoryTheory.Over.iteratedSliceEquiv is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} (f : CategoryTheory.Over.{u1, u2} T _inst_1 X), CategoryTheory.Equivalence.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.category.{u2, u1} T _inst_1 X) f) (CategoryTheory.Over.category.{max u2 u1, u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.Over.category.{u2, u1} T _inst_1 X) f) (CategoryTheory.Over.{u1, u2} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f)) (CategoryTheory.Over.category.{u2, u1} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f))\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} (f : CategoryTheory.Over.{u1, u2} T _inst_1 X), CategoryTheory.Equivalence.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Over.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) f) (CategoryTheory.Over.{u1, u2} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f)) (CategoryTheory.instCategoryOver.{u1, max u2 u1} (CategoryTheory.Over.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 X) f) (CategoryTheory.instCategoryOver.{u1, u2} T _inst_1 (CategoryTheory.Comma.left.{u1, u1, u1, u2, u1, u2} T _inst_1 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) f))\nCase conversion may be inaccurate. Consider using '#align category_theory.over.iterated_slice_equiv CategoryTheory.Over.iteratedSliceEquivₓ'. -/\n/-- Given f : Y ⟶ X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iteratedSliceEquiv : Over f ≌ Over f.left\n    where\n  Functor := iteratedSliceForward f\n  inverse := iteratedSliceBackward f\n  unitIso :=\n    NatIso.ofComponents (fun g => Over.isoMk (Over.isoMk (Iso.refl _) (by tidy)) (by tidy))\n      fun X Y g => by\n      ext\n      dsimp\n      simp\n  counitIso :=\n    NatIso.ofComponents (fun g => Over.isoMk (Iso.refl _) (by tidy)) fun X Y g =>\n      by\n      ext\n      dsimp\n      simp\n#align category_theory.over.iterated_slice_equiv CategoryTheory.Over.iteratedSliceEquiv\n\n#print CategoryTheory.Over.iteratedSliceForward_forget /-\ntheorem iteratedSliceForward_forget :\n    iteratedSliceForward f ⋙ forget f.left = forget f ⋙ forget X :=\n  rfl\n#align category_theory.over.iterated_slice_forward_forget CategoryTheory.Over.iteratedSliceForward_forget\n-/\n\n#print CategoryTheory.Over.iteratedSliceBackward_forget_forget /-\ntheorem iteratedSliceBackward_forget_forget :\n    iteratedSliceBackward f ⋙ forget f ⋙ forget X = forget f.left :=\n  rfl\n#align category_theory.over.iterated_slice_backward_forget_forget CategoryTheory.Over.iteratedSliceBackward_forget_forget\n-/\n\nend IteratedSlice\n\nsection\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\n/- warning: category_theory.over.post -> CategoryTheory.Over.post is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} T] {X : T} {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} T _inst_1 D _inst_2), CategoryTheory.Functor.{u1, u2, max u3 u1, max u4 u2} (CategoryTheory.Over.{u1, u3} T _inst_1 X) (CategoryTheory.Over.category.{u3, u1} T _inst_1 X) (CategoryTheory.Over.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} T _inst_1 D _inst_2 F X)) (CategoryTheory.Over.category.{u4, u2} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} T _inst_1 D _inst_2 F X))\nbut is expected to have type\n  forall {T : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} T] {X : T} {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (F : CategoryTheory.Functor.{u1, u2, u3, u4} T _inst_1 D _inst_2), CategoryTheory.Functor.{u1, u2, max u3 u1, max u4 u2} (CategoryTheory.Over.{u1, u3} T _inst_1 X) (CategoryTheory.instCategoryOver.{u1, u3} T _inst_1 X) (CategoryTheory.Over.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} T (CategoryTheory.Category.toCategoryStruct.{u1, u3} T _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} T _inst_1 D _inst_2 F) X)) (CategoryTheory.instCategoryOver.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} T (CategoryTheory.Category.toCategoryStruct.{u1, u3} T _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} T _inst_1 D _inst_2 F) X))\nCase conversion may be inaccurate. Consider using '#align category_theory.over.post CategoryTheory.Over.postₓ'. -/\n/-- A functor `F : T ⥤ D` induces a functor `over X ⥤ over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T ⥤ D) : Over X ⥤ Over (F.obj X)\n    where\n  obj Y := mk <| F.map Y.Hom\n  map Y₁ Y₂ f := Over.homMk (F.map f.left) (by tidy <;> erw [← F.map_comp, w])\n#align category_theory.over.post CategoryTheory.Over.post\n\nend\n\nend Over\n\n#print CategoryTheory.Under /-\n/-- The under category has as objects arrows with domain `X` and as morphisms commutative\n    triangles. -/\ndef Under (X : T) :=\n  StructuredArrow X (𝟭 T)deriving Category\n#align category_theory.under CategoryTheory.Under\n-/\n\n#print CategoryTheory.Under.inhabited /-\n-- Satisfying the inhabited linter\ninstance Under.inhabited [Inhabited T] : Inhabited (Under (default : T))\n    where default :=\n    { left := default\n      right := default\n      Hom := 𝟙 _ }\n#align category_theory.under.inhabited CategoryTheory.Under.inhabited\n-/\n\nnamespace Under\n\nvariable {X : T}\n\n#print CategoryTheory.Under.UnderMorphism.ext /-\n@[ext]\ntheorem UnderMorphism.ext {X : T} {U V : Under X} {f g : U ⟶ V} (h : f.right = g.right) : f = g :=\n  by tidy\n#align category_theory.under.under_morphism.ext CategoryTheory.Under.UnderMorphism.ext\n-/\n\n#print CategoryTheory.Under.under_left /-\n@[simp]\ntheorem under_left (U : Under X) : U.left = ⟨⟨⟩⟩ := by tidy\n#align category_theory.under.under_left CategoryTheory.Under.under_left\n-/\n\n#print CategoryTheory.Under.id_right /-\n@[simp]\ntheorem id_right (U : Under X) : CommaMorphism.right (𝟙 U) = 𝟙 U.right :=\n  rfl\n#align category_theory.under.id_right CategoryTheory.Under.id_right\n-/\n\n#print CategoryTheory.Under.comp_right /-\n@[simp]\ntheorem comp_right (a b c : Under X) (f : a ⟶ b) (g : b ⟶ c) : (f ≫ g).right = f.right ≫ g.right :=\n  rfl\n#align category_theory.under.comp_right CategoryTheory.Under.comp_right\n-/\n\n/- warning: category_theory.under.w -> CategoryTheory.Under.w is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {A : CategoryTheory.Under.{u1, u2} T _inst_1 X} {B : CategoryTheory.Under.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Under.category.{u2, u1} T _inst_1 X))) A B), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) B)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A)) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) B) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A B f)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) B)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {A : CategoryTheory.Under.{u1, u2} T _inst_1 X} {B : CategoryTheory.Under.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) A B), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) B)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A)) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) B) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) A B f)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) B)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.w CategoryTheory.Under.wₓ'. -/\n@[simp, reassoc.1]\ntheorem w {A B : Under X} (f : A ⟶ B) : A.Hom ≫ f.right = B.Hom := by have := f.w <;> tidy\n#align category_theory.under.w CategoryTheory.Under.w\n\n#print CategoryTheory.Under.mk /-\n/-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/\n@[simps right Hom]\ndef mk {X Y : T} (f : X ⟶ Y) : Under X :=\n  StructuredArrow.mk f\n#align category_theory.under.mk CategoryTheory.Under.mk\n-/\n\n/- warning: category_theory.under.hom_mk -> CategoryTheory.Under.homMk is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Under.{u1, u2} T _inst_1 X} {V : CategoryTheory.Under.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V)), (autoParamₓ.{0} (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U) f) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V)) (Name.mk_string (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str String.empty (Char.ofNat (OfNat.ofNat.{0} Nat 111 (OfNat.mk.{0} Nat 111 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 98 (OfNat.mk.{0} Nat 98 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 118 (OfNat.mk.{0} Nat 118 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 105 (OfNat.mk.{0} Nat 105 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 111 (OfNat.mk.{0} Nat 111 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 117 (OfNat.mk.{0} Nat 117 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 115 (OfNat.mk.{0} Nat 115 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 108 (OfNat.mk.{0} Nat 108 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 121 (OfNat.mk.{0} Nat 121 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) Name.anonymous)) -> (Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.StructuredArrow.{u1, u1, u2, u2} T _inst_1 T _inst_1 X (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.StructuredArrow.{u1, u1, u2, u2} T _inst_1 T _inst_1 X (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.StructuredArrow.category.{u1, u2, u2, u1} T _inst_1 T _inst_1 X (CategoryTheory.Functor.id.{u1, u2} T _inst_1)))) U V)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Under.{u1, u2} T _inst_1 X} {V : CategoryTheory.Under.{u1, u2} T _inst_1 X} (f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V)), (autoParam.{0} (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U) f) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) V)) _auto._@.Mathlib.CategoryTheory.Over._hyg.2636) -> (Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) U V)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.hom_mk CategoryTheory.Under.homMkₓ'. -/\n/-- To give a morphism in the under category, it suffices to give a morphism fitting in a\n    commutative triangle. -/\n@[simps]\ndef homMk {U V : Under X} (f : U.right ⟶ V.right) (w : U.Hom ≫ f = V.Hom := by obviously) : U ⟶ V :=\n  StructuredArrow.homMk f w\n#align category_theory.under.hom_mk CategoryTheory.Under.homMk\n\n/- warning: category_theory.under.iso_mk -> CategoryTheory.Under.isoMk is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Under.{u1, u2} T _inst_1 X} {g : CategoryTheory.Under.{u1, u2} T _inst_1 X} (hr : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)), (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) -> (CategoryTheory.Iso.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) f g)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Under.{u1, u2} T _inst_1 X} {g : CategoryTheory.Under.{u1, u2} T _inst_1 X} (hr : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)), (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) -> (CategoryTheory.Iso.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) f g)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.iso_mk CategoryTheory.Under.isoMkₓ'. -/\n/-- Construct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\ndef isoMk {f g : Under X} (hr : f.right ≅ g.right) (hw : f.Hom ≫ hr.Hom = g.Hom) : f ≅ g :=\n  StructuredArrow.isoMk hr hw\n#align category_theory.under.iso_mk CategoryTheory.Under.isoMk\n\n/- warning: category_theory.under.iso_mk_hom_right -> CategoryTheory.Under.isoMk_hom_right is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Under.{u1, u2} T _inst_1 X} {g : CategoryTheory.Under.{u1, u2} T _inst_1 X} (hr : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (hw : Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f g (CategoryTheory.Iso.hom.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) f g (CategoryTheory.Under.isoMk.{u1, u2} T _inst_1 X f g hr hw))) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Under.{u1, u2} T _inst_1 X} {g : CategoryTheory.Under.{u1, u2} T _inst_1 X} (hr : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (hw : Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f g (CategoryTheory.Iso.hom.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) f g (CategoryTheory.Under.isoMk.{u1, u2} T _inst_1 X f g hr hw))) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.iso_mk_hom_right CategoryTheory.Under.isoMk_hom_rightₓ'. -/\n@[simp]\ntheorem isoMk_hom_right {f g : Under X} (hr : f.right ≅ g.right) (hw : f.Hom ≫ hr.Hom = g.Hom) :\n    (isoMk hr hw).Hom.right = hr.Hom :=\n  rfl\n#align category_theory.under.iso_mk_hom_right CategoryTheory.Under.isoMk_hom_right\n\n/- warning: category_theory.under.iso_mk_inv_right -> CategoryTheory.Under.isoMk_inv_right is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Under.{u1, u2} T _inst_1 X} {g : CategoryTheory.Under.{u1, u2} T _inst_1 X} (hr : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (hw : Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g f (CategoryTheory.Iso.inv.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) f g (CategoryTheory.Under.isoMk.{u1, u2} T _inst_1 X f g hr hw))) (CategoryTheory.Iso.inv.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {f : CategoryTheory.Under.{u1, u2} T _inst_1 X} {g : CategoryTheory.Under.{u1, u2} T _inst_1 X} (hr : CategoryTheory.Iso.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (hw : Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Iso.hom.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g)), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f)) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g f (CategoryTheory.Iso.inv.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) f g (CategoryTheory.Under.isoMk.{u1, u2} T _inst_1 X f g hr hw))) (CategoryTheory.Iso.inv.{u1, u2} T _inst_1 (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) f) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) g) hr)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.iso_mk_inv_right CategoryTheory.Under.isoMk_inv_rightₓ'. -/\n@[simp]\ntheorem isoMk_inv_right {f g : Under X} (hr : f.right ≅ g.right) (hw : f.Hom ≫ hr.Hom = g.Hom) :\n    (isoMk hr hw).inv.right = hr.inv :=\n  rfl\n#align category_theory.under.iso_mk_inv_right CategoryTheory.Under.isoMk_inv_right\n\nsection\n\nvariable (X)\n\n#print CategoryTheory.Under.forget /-\n/-- The forgetful functor mapping an arrow to its domain. -/\ndef forget : Under X ⥤ T :=\n  Comma.snd _ _\n#align category_theory.under.forget CategoryTheory.Under.forget\n-/\n\nend\n\n/- warning: category_theory.under.forget_obj -> CategoryTheory.Under.forget_obj is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Under.{u1, u2} T _inst_1 X}, Eq.{succ u2} T (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X) U) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Under.{u1, u2} T _inst_1 X}, Eq.{succ u2} T (Prefunctor.obj.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X)) U) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.forget_obj CategoryTheory.Under.forget_objₓ'. -/\n@[simp]\ntheorem forget_obj {U : Under X} : (forget X).obj U = U.right :=\n  rfl\n#align category_theory.under.forget_obj CategoryTheory.Under.forget_obj\n\n/- warning: category_theory.under.forget_map -> CategoryTheory.Under.forget_map is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Under.{u1, u2} T _inst_1 X} {V : CategoryTheory.Under.{u1, u2} T _inst_1 X} {f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Under.category.{u2, u1} T _inst_1 X))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X) U) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X) V)) (CategoryTheory.Functor.map.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X) U V f) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U V f)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {U : CategoryTheory.Under.{u1, u2} T _inst_1 X} {V : CategoryTheory.Under.{u1, u2} T _inst_1 X} {f : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X)) U) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X)) V)) (Prefunctor.map.{succ u1, succ u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, u2} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) T _inst_1 (CategoryTheory.Under.forget.{u1, u2} T _inst_1 X)) U V f) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U V f)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.forget_map CategoryTheory.Under.forget_mapₓ'. -/\n@[simp]\ntheorem forget_map {U V : Under X} {f : U ⟶ V} : (forget X).map f = f.right :=\n  rfl\n#align category_theory.under.forget_map CategoryTheory.Under.forget_map\n\n#print CategoryTheory.Under.forgetCone /-\n/-- The natural cone over the forgetful functor `under X ⥤ T` with cone point `X`. -/\n@[simps]\ndef forgetCone (X : T) : Limits.Cone (forget X) :=\n  { pt\n    π := { app := Comma.hom } }\n#align category_theory.under.forget_cone CategoryTheory.Under.forgetCone\n-/\n\n#print CategoryTheory.Under.map /-\n/-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/\ndef map {Y : T} (f : X ⟶ Y) : Under Y ⥤ Under X :=\n  Comma.mapLeft _ <| Discrete.natTrans fun _ => f\n#align category_theory.under.map CategoryTheory.Under.map\n-/\n\nsection\n\nvariable {Y : T} {f : X ⟶ Y} {U V : Under Y} {g : U ⟶ V}\n\n/- warning: category_theory.under.map_obj_right -> CategoryTheory.Under.map_obj_right is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Under.{u1, u2} T _inst_1 Y}, Eq.{succ u2} T (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Under.{u1, u2} T _inst_1 Y}, Eq.{succ u2} T (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.map_obj_right CategoryTheory.Under.map_obj_rightₓ'. -/\n@[simp]\ntheorem map_obj_right : ((map f).obj U).right = U.right :=\n  rfl\n#align category_theory.under.map_obj_right CategoryTheory.Under.map_obj_right\n\n/- warning: category_theory.under.map_obj_hom -> CategoryTheory.Under.map_obj_hom is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Under.{u1, u2} T _inst_1 Y}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U))) (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U)))) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U))) Y (CategoryTheory.Functor.obj.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U))) f (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U))\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Under.{u1, u2} T _inst_1 Y}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (Prefunctor.obj.{succ u1, succ u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.CategoryStruct.toQuiver.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.Category.toCategoryStruct.{u1, u1} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}))) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u1, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X)) (CategoryTheory.Comma.left.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) U))) (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) U)))) (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) U)) (CategoryTheory.CategoryStruct.comp.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1) X Y (Prefunctor.obj.{succ u1, succ u1, u2, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u2} T _inst_1 T _inst_1 (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U)) f (CategoryTheory.Comma.hom.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U))\nCase conversion may be inaccurate. Consider using '#align category_theory.under.map_obj_hom CategoryTheory.Under.map_obj_homₓ'. -/\n@[simp]\ntheorem map_obj_hom : ((map f).obj U).Hom = f ≫ U.Hom :=\n  rfl\n#align category_theory.under.map_obj_hom CategoryTheory.Under.map_obj_hom\n\n/- warning: category_theory.under.map_map_right -> CategoryTheory.Under.map_map_right is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Under.{u1, u2} T _inst_1 Y} {V : CategoryTheory.Under.{u1, u2} T _inst_1 Y} {g : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.category.{u2, u1} T _inst_1 Y))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) V))) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U) (CategoryTheory.Functor.obj.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) V) (CategoryTheory.Functor.map.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.commaCategory.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1)) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f) U V g)) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U V g)\nbut is expected to have type\n  forall {T : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} T] {X : T} {Y : T} {f : Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) X Y} {U : CategoryTheory.Under.{u1, u2} T _inst_1 Y} {V : CategoryTheory.Under.{u1, u2} T _inst_1 Y} {g : Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) U V}, Eq.{succ u1} (Quiver.Hom.{succ u1, u2} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} T (CategoryTheory.Category.toCategoryStruct.{u1, u2} T _inst_1)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) U)) (CategoryTheory.Comma.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) V))) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 X) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) U) (Prefunctor.obj.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) V) (Prefunctor.map.{succ u1, succ u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y))) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, max u2 u1, max u2 u1} (CategoryTheory.Under.{u1, u2} T _inst_1 Y) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 Y) (CategoryTheory.Under.{u1, u2} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u2} T _inst_1 X) (CategoryTheory.Under.map.{u1, u2} T _inst_1 X Y f)) U V g)) (CategoryTheory.CommaMorphism.right.{u1, u1, u1, u1, u2, u2} (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) T _inst_1 T _inst_1 (CategoryTheory.Functor.fromPUnit.{u1, u2} T _inst_1 Y) (CategoryTheory.Functor.id.{u1, u2} T _inst_1) U V g)\nCase conversion may be inaccurate. Consider using '#align category_theory.under.map_map_right CategoryTheory.Under.map_map_rightₓ'. -/\n@[simp]\ntheorem map_map_right : ((map f).map g).right = g.right :=\n  rfl\n#align category_theory.under.map_map_right CategoryTheory.Under.map_map_right\n\n#print CategoryTheory.Under.mapId /-\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef mapId : map (𝟙 Y) ≅ 𝟭 _ :=\n  NatIso.ofComponents (fun X => isoMk (Iso.refl _) (by tidy)) (by tidy)\n#align category_theory.under.map_id CategoryTheory.Under.mapId\n-/\n\n#print CategoryTheory.Under.mapComp /-\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef mapComp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=\n  NatIso.ofComponents (fun X => isoMk (Iso.refl _) (by tidy)) (by tidy)\n#align category_theory.under.map_comp CategoryTheory.Under.mapComp\n-/\n\nend\n\n#print CategoryTheory.Under.forget_reflects_iso /-\ninstance forget_reflects_iso : ReflectsIsomorphisms (forget X)\n    where reflects Y Z f t :=\n    ⟨⟨under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm), by\n        tidy⟩⟩\n#align category_theory.under.forget_reflects_iso CategoryTheory.Under.forget_reflects_iso\n-/\n\n#print CategoryTheory.Under.forget_faithful /-\ninstance forget_faithful : Faithful (forget X) where\n#align category_theory.under.forget_faithful CategoryTheory.Under.forget_faithful\n-/\n\n#print CategoryTheory.Under.mono_of_mono_right /-\n-- TODO: Show the converse holds if `T` has binary coproducts.\n/-- If `k.right` is a monomorphism, then `k` is a monomorphism. In other words, `under.forget X`\nreflects epimorphisms.\nThe converse does not hold without additional assumptions on the underlying category, see\n`category_theory.under.mono_right_of_mono`.\n-/\ntheorem mono_of_mono_right {f g : Under X} (k : f ⟶ g) [hk : Mono k.right] : Mono k :=\n  (forget X).mono_of_mono_map hk\n#align category_theory.under.mono_of_mono_right CategoryTheory.Under.mono_of_mono_right\n-/\n\n#print CategoryTheory.Under.epi_of_epi_right /-\n/--\nIf `k.right` is a epimorphism, then `k` is a epimorphism. In other words, `under.forget X` reflects\nepimorphisms.\nThe converse of `category_theory.under.epi_right_of_epi`.\n\nThis lemma is not an instance, to avoid loops in type class inference.\n-/\ntheorem epi_of_epi_right {f g : Under X} (k : f ⟶ g) [hk : Epi k.right] : Epi k :=\n  (forget X).epi_of_epi_map hk\n#align category_theory.under.epi_of_epi_right CategoryTheory.Under.epi_of_epi_right\n-/\n\n#print CategoryTheory.Under.epi_right_of_epi /-\n/--\nIf `k` is a epimorphism, then `k.right` is a epimorphism. In other words, `under.forget X` preserves\nepimorphisms.\nThe converse of `category_theory.under.epi_of_epi_right`.\n-/\ninstance epi_right_of_epi {f g : Under X} (k : f ⟶ g) [Epi k] : Epi k.right :=\n  by\n  refine' ⟨fun (Y : T) l m a => _⟩\n  let l' : g ⟶ mk (g.hom ≫ m) :=\n    hom_mk l\n      (by\n        dsimp\n        rw [← under.w k, category.assoc, a, category.assoc])\n  suffices l' = hom_mk m by apply congr_arg comma_morphism.right this\n  rw [← cancel_epi k]\n  ext\n  apply a\n#align category_theory.under.epi_right_of_epi CategoryTheory.Under.epi_right_of_epi\n-/\n\nsection\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\n/- warning: category_theory.under.post -> CategoryTheory.Under.post is a dubious translation:\nlean 3 declaration is\n  forall {T : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} T] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {X : T} (F : CategoryTheory.Functor.{u1, u2, u3, u4} T _inst_1 D _inst_2), CategoryTheory.Functor.{u1, u2, max u3 u1, max u4 u2} (CategoryTheory.Under.{u1, u3} T _inst_1 X) (CategoryTheory.Under.category.{u3, u1} T _inst_1 X) (CategoryTheory.Under.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} T _inst_1 D _inst_2 F X)) (CategoryTheory.Under.category.{u4, u2} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} T _inst_1 D _inst_2 F X))\nbut is expected to have type\n  forall {T : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} T] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] {X : T} (F : CategoryTheory.Functor.{u1, u2, u3, u4} T _inst_1 D _inst_2), CategoryTheory.Functor.{u1, u2, max u3 u1, max u4 u2} (CategoryTheory.Under.{u1, u3} T _inst_1 X) (CategoryTheory.instCategoryUnder.{u1, u3} T _inst_1 X) (CategoryTheory.Under.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} T (CategoryTheory.Category.toCategoryStruct.{u1, u3} T _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} T _inst_1 D _inst_2 F) X)) (CategoryTheory.instCategoryUnder.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} T (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} T (CategoryTheory.Category.toCategoryStruct.{u1, u3} T _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} T _inst_1 D _inst_2 F) X))\nCase conversion may be inaccurate. Consider using '#align category_theory.under.post CategoryTheory.Under.postₓ'. -/\n/-- A functor `F : T ⥤ D` induces a functor `under X ⥤ under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T ⥤ D) : Under X ⥤ Under (F.obj X)\n    where\n  obj Y := mk <| F.map Y.Hom\n  map Y₁ Y₂ f := Under.homMk (F.map f.right) (by tidy <;> erw [← F.map_comp, w])\n#align category_theory.under.post CategoryTheory.Under.post\n\nend\n\nend Under\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Over.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.48635129329661986}}
{"text": "/-\nCopyright 2021 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\n\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.sum\nimport formal_ml.lattice\nimport formal_ml.measurable_space\nimport formal_ml.classical\nimport data.equiv.list\nimport formal_ml.prod_measure\nimport formal_ml.finite_pi_measure\nimport formal_ml.probability_space\nimport formal_ml.monotone_class\n\n/-!\n  This file focuses on more esoteric proofs that random variables are identical.\n  In particular, given two random variables X Y with a common measurable space as a codomain,\n  where the codomain is generated by some set of measurable sets S.\n  X and Y are identical if they are identical on measurable sets in S, assuming S\n  has some particular properties. The first is that S is an algebra, i.e. S has the \n  universal set and is closed under set difference.\n\n  An alternative is that S is (basically) a semi-algebra, i.e. it has the empty set \n  and is closed under intersection, and semi-closed under complement. Normally, a \n  semi-algebra would require the universal set, but that is not required for this\n  purpose.\n\n  This is most useful for proving independent and identical random variables, when\n  considered as an aggregate random variable, are identical.\n\n  The core is the monotone class theorem, measurable_space.generate_from_monotone_class.\n-/\n\nlemma random_variable_identical_on_algebra''' {Ω₁ Ω₂ α:Type*} (s: set (set α))\n  (A:s.is_algebra)\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ (measurable_space.generate_from s)}\n  {X₂:P₂ →ᵣ (measurable_space.generate_from s)}:\n  (∀ (T:measurable_setB (measurable_space.generate_from s)), \n   T.val ∈ s → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h3 U,\n  cases U,\n  have AM := A.monotone_class,\n  have h7:∀ {T':set α}, s.monotone_class T' →\n          (measurable_space.generate_from s).measurable_set' T',\n  { intros T h7_1,\n    rw measurable_space.generate_from_monotone_class at h7_1,\n    simp [measurable_space.generate_from],\n    apply h7_1, apply A },\n  have h4:measurable_space.generate_measurable s U_val,\n  { simp [measurable_space.generate_from] at U_property,\n    apply U_property },\n  have h5:s.monotone_class U_val,\n  { rw measurable_space.generate_from_monotone_class,\n    apply h4, apply A },\n  induction h5 with U' h_U' f h_rec h_mono h_ind f h_rec h_mono h_ind,\n  { apply h3, apply h_U' },\n  { have h6:(∀ᵣ i, X₁ ∈ᵣ ⟨f i, h7 (h_rec i)⟩) = (X₁ ∈ᵣ ⟨set.Inter f, U_property⟩) ,\n    { apply event.eq, simp, ext ω, split; intros h6_1; simp at h6_1; simp [h6_1], },\n    rw ← h6,\n    have h7:(∀ᵣ i, X₂ ∈ᵣ ⟨f i, h7 (h_rec i)⟩) = (X₂ ∈ᵣ ⟨set.Inter f, U_property⟩) ,\n    { apply event.eq, simp, ext ω, split; intros h7_1; simp at h7_1; simp [h7_1], },\n    rw ← h7,\n    rw Pr_forall_revent_eq_infi,\n    rw Pr_forall_revent_eq_infi,\n    have h8:(λ (i : ℕ), Pr[X₁ ∈ᵣ ⟨f i, _⟩]) = λ (i : ℕ), Pr[X₂ ∈ᵣ ⟨f i, _⟩],\n    { ext1 i, apply h_ind, \n      rw ← measurable_space.generate_from_monotone_class,\n      apply h_rec, apply A },\n    rw h8,\n    simp, apply h_mono,\n    simp, apply h_mono },\n  { have h9:(∃ᵣ i, X₁ ∈ᵣ ⟨f i, h7 (h_rec i)⟩) = (X₁ ∈ᵣ ⟨set.Union f, U_property⟩) ,\n    { apply event.eq, simp, ext ω, split; intros h9_1; simp at h9_1; simp [h9_1], },\n    rw ← h9,\n    have h10:(∃ᵣ i, X₂ ∈ᵣ ⟨f i, h7 (h_rec i)⟩) = (X₂ ∈ᵣ ⟨set.Union f, U_property⟩) ,\n    { apply event.eq, simp, ext ω, split; intros h10_1; simp at h10_1; simp [h10_1] },\n    rw ← h10,\n    rw Pr_exists_revent_eq_supr,\n    rw Pr_exists_revent_eq_supr,\n    have h11:(λ (i : ℕ), Pr[X₁ ∈ᵣ ⟨f i, _⟩]) = λ (i : ℕ), Pr[X₂ ∈ᵣ ⟨f i, _⟩],\n    { ext1 i, apply h_ind, \n      rw ← measurable_space.generate_from_monotone_class,\n      apply h_rec, apply A },\n    rw h11,\n    simp, apply h_mono,\n    simp, apply h_mono },\nend\n\nlemma random_variable_identical_on_algebra {Ω₁ Ω₂ α:Type*} (s: set (set α))\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ (measurable_space.generate_from s)}\n  {X₂:P₂ →ᵣ (measurable_space.generate_from s)}:\n  (set.univ ∈ s) →\n  (∀ a b, a∈ s → b ∈ s → a \\ b ∈ s) →\n  (∀ (T:measurable_setB (measurable_space.generate_from s)), \n   T.val ∈ s → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h1 h2 h3,\n  apply random_variable_identical_on_algebra''',\n  apply set.is_algebra.mk h1 h2,\n  apply h3,\nend\n\n\n\n/- This allows for the measurable space to be generated from a different\n   set. -/\nlemma random_variable_identical_on_algebra' {Ω₁ Ω₂ α:Type*} (s: set (set α))\n  (M:measurable_space α)\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ M}\n  {X₂:P₂ →ᵣ M}:\n  (set.univ ∈ s) →\n  (∀ a b, a∈ s → b ∈ s → a \\ b ∈ s) →\n  (M = measurable_space.generate_from s) →\n  (∀ (T:measurable_setB M), \n   T.val ∈ s → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h1 h2 h3 h4 T',\n  tactic.unfreeze_local_instances,\n  subst M,\n  apply random_variable_identical_on_algebra,\n  apply h1,\n  apply h2,\n  apply h4,\nend\n\n#check measurable_space.generate_from\nlemma random_variable_identical_on_algebra'' {Ω₁ Ω₂ α:Type*} (s t: set (set α))\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ (measurable_space.generate_from t)}\n  {X₂:P₂ →ᵣ (measurable_space.generate_from t)}:\n  (set.univ ∈ s) →\n  (∀ a b, a∈ s → b ∈ s → a \\ b ∈ s) →\n  (t ⊆ s) →\n  (∀ a∈ s, (measurable_space.generate_from t).measurable_set' a) →\n  (∀ (T:measurable_setB (measurable_space.generate_from t)), \n   T.val ∈ s → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h1 h2 h3 h4 h5,\n  have h6:(measurable_space.generate_from t) = (measurable_space.generate_from s),\n  { apply le_antisymm;\n    apply measurable_space.generate_from_le;\n    intros a h_a,\n    { simp [measurable_space.generate_from],\n      apply measurable_space.generate_measurable.basic,\n      apply h3, apply h_a },\n    apply h4, apply h_a },\n  apply random_variable_identical_on_algebra',\n  apply h1,\n  apply h2,\n  apply h6,\n  apply h5,\nend\n\nlemma equality_disjoint_union_closure {Ω₁ Ω₂ α:Type*} (S : set (set α))\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ (measurable_space.generate_from S)}\n  {X₂:P₂ →ᵣ (measurable_space.generate_from S)}:\n  (∀ (T:measurable_setB (measurable_space.generate_from S)), \n   T.val ∈ S → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  (∀ (T:measurable_setB (measurable_space.generate_from S)),\n   T.val ∈ S.disjoint_union_closure → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) :=\nbegin\n  intros h4,\n  intros T h_T, cases T,\n    rw set.mem_disjoint_union_closure_iff at h_T,\n    cases h_T with m h_T,\n    cases h_T with f h_T,\n    cases h_T with h_f h_T,\n    cases h_T with h_f_pairwise h_s_def,\n    simp at h_s_def,\n    subst T_val,\n    have h_X1:X₁ ∈ᵣ ⟨set.Union f, T_property⟩ = (eany (λ (i:fin m), X₁ ∈ᵣ ⟨f i, \n             measurable_space.measurable_set_generate_from (h_f i)⟩)),\n    { apply event.eq, ext ω, split; intros h_X1_1; simp at h_X1_1; cases h_X1_1 with i\n      h_X1_1; simp [h_X1_1]; apply exists.intro i; apply h_X1_1 },\n    have h_X2:X₂ ∈ᵣ ⟨set.Union f, T_property⟩ = (eany (λ (i:fin m), X₂ ∈ᵣ ⟨f i, \n             measurable_space.measurable_set_generate_from (h_f i)⟩)),\n    { apply event.eq, ext ω, split; intros h_X1_1; simp at h_X1_1; cases h_X1_1 with i\n      h_X1_1; simp [h_X1_1]; apply exists.intro i; apply h_X1_1 },\n    rw h_X1, rw h_X2,\n    rw Pr_eany_sum,\n    rw Pr_eany_sum,\n    { congr, ext1 b, apply h4, simp, apply h_f },\n    { intros i j h_ne, simp only [function.on_fun], apply disjoint_preimage, \n      apply h_f_pairwise, apply h_ne },\n    { intros i j h_ne, simp only [function.on_fun], apply disjoint_preimage, \n      apply h_f_pairwise, apply h_ne },\nend\n\n\n#check 3\n#check 3\n\n\nlemma random_variable_identical_on_semialgebra''' {Ω₁ Ω₂ α:Type*} (S : set (set α))\n  (A:S.is_semialgebra)\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ (measurable_space.generate_from S)}\n  {X₂:P₂ →ᵣ (measurable_space.generate_from S)}:\n  (∀ (T:measurable_setB (measurable_space.generate_from S)), \n   T.val ∈ S → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h4,\n  have CA := A.disjoint_union_closure,\n  \n  apply random_variable_identical_on_algebra'' S.disjoint_union_closure,\n  { apply CA.univ },\n  { apply CA.diff },\n  { intros a h_a, apply set.disjoint_union_closure_self, apply h_a  },\n  { intros s h_s,\n    rw set.mem_disjoint_union_closure_iff at h_s,\n    cases h_s with m h_s,\n    cases h_s with f h_s,\n    cases h_s with h_f h_s,\n    cases h_s with h_f_pairwise h_s_def,\n    subst s,\n    haveI:fintype (fin m) := fin.fintype m,\n    haveI:encodable (fin m) := fintype.encodable (fin m),\n    simp, apply measurable_set.Union, \n    intro b, apply measurable_space.measurable_set_generate_from,\n    apply h_f },\n  { apply equality_disjoint_union_closure,\n    apply h4 },\nend\n\n#check 12\n#check 3\n\n\nlemma random_variable_identical_on_semialgebra {Ω₁ Ω₂ α:Type*} (S : set (set α))\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ (measurable_space.generate_from S)}\n  {X₂:P₂ →ᵣ (measurable_space.generate_from S)}:\n  (∀ s t∈ S, s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (@set.univ α ∈ S) →\n  (∀ (T:measurable_setB (measurable_space.generate_from S)), \n   T.val ∈ S → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h1 h2 h3 h_univ h4,\n  have A := set.is_semialgebra.mk h_univ h3 h1 h2,\n  apply random_variable_identical_on_semialgebra''',\n  apply A,\n  apply h4,\nend\n\n\n/- TODO: technically, could remove empty set or the universe, and it would\n   still be true. -/\nlemma random_variable_identical_on_semialgebra' {Ω₁ Ω₂ α:Type*} (S : set (set α))\n  (M:measurable_space α)\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ M}\n  {X₂:P₂ →ᵣ M}:\n  (∀ s t∈ S, s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (set.univ ∈ S) →\n  (M = measurable_space.generate_from S) →\n  (∀ (T:measurable_setB M), \n   T.val ∈ S → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h1 h2 h3 h_univ h4 h5,\n  tactic.unfreeze_local_instances,\n  subst M,\n  apply random_variable_identical_on_semialgebra,\n  apply h1,\n  apply h2,\n  apply h3,\n  apply h_univ,\n  apply h5,\nend\n\nlemma random_variable_identical_on_semialgebra'' {Ω₁ Ω₂ α:Type*} (s t: set (set α))\n  {P₁:probability_space Ω₁} {P₂:probability_space Ω₂} \n  {X₁:P₁ →ᵣ (measurable_space.generate_from t)}\n  {X₂:P₂ →ᵣ (measurable_space.generate_from t)}:\n  (∀ a b∈ s, a ∩ b ∈ s) →\n  (∀ a ∈ s, aᶜ ∈ s.disjoint_union_closure) →  \n  (∅ ∈ s) →\n  (set.univ ∈ s) →\n  (t ⊆ s) →\n  (∀ a∈ s, (measurable_space.generate_from t).measurable_set' a) →\n  (∀ (T:measurable_setB (measurable_space.generate_from t)), \n   T.val ∈ s → Pr[X₁ ∈ᵣ T] = Pr[X₂ ∈ᵣ T]) → \n  random_variable_identical X₁ X₂ :=\nbegin\n  intros h1 h2 h_empty h_univ h3 h4 h5,\n  have h6:(measurable_space.generate_from t) = (measurable_space.generate_from s),\n  { apply le_antisymm;\n    apply measurable_space.generate_from_le;\n    intros a h_a,\n    { simp [measurable_space.generate_from],\n      apply measurable_space.generate_measurable.basic,\n      apply h3, apply h_a },\n    apply h4, apply h_a },\n  apply random_variable_identical_on_semialgebra',\n  apply h1,\n  apply h2,\n  apply h_empty,\n  apply h_univ,\n  apply h6,\n  apply h5,\nend\n\n\n\n\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/random_variable_identical.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.4863512884102655}}
{"text": "/-\nCopyright (c) 2017 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Mario Carneiro\n-/\nimport data.rat.cast\nimport data.rat.meta_defs\n\n/-!\n# `norm_num`\n\nEvaluating arithmetic expressions including `*`, `+`, `-`, `^`, `≤`.\n-/\n\nuniverses u v w\n\nnamespace tactic\n\nnamespace instance_cache\n\n/-- Faster version of `mk_app ``bit0 [e]`. -/\nmeta def mk_bit0 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) :=\ndo (c, ai) ← c.get ``has_add,\n   return (c, (expr.const ``bit0 [c.univ]).mk_app [c.α, ai, e])\n\n/-- Faster version of `mk_app ``bit1 [e]`. -/\nmeta def mk_bit1 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) :=\ndo (c, ai) ← c.get ``has_add,\n   (c, oi) ← c.get ``has_one,\n   return (c, (expr.const ``bit1 [c.univ]).mk_app [c.α, oi, ai, e])\n\nend instance_cache\n\nend tactic\n\nopen tactic\n\n/-!\nEach lemma in this file is written the way it is to exactly match (with no defeq reduction allowed)\nthe conclusion of some lemma generated by the proof procedure that uses it. That proof procedure\nshould describe the shape of the generated lemma in its docstring.\n-/\n\nnamespace norm_num\nvariable {α : Type u}\n\nlemma subst_into_add {α} [has_add α] (l r tl tr t)\n  (prl : (l : α) = tl) (prr : r = tr) (prt : tl + tr = t) : l + r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_mul {α} [has_mul α] (l r tl tr t)\n  (prl : (l : α) = tl) (prr : r = tr) (prt : tl * tr = t) : l * r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_neg {α} [has_neg α] (a ta t : α) (pra : a = ta) (prt : -ta = t) : -a = t :=\nby simp [pra, prt]\n\n/-- The result type of `match_numeral`, either `0`, `1`, or a top level\ndecomposition of `bit0 e` or `bit1 e`. The `other` case means it is not a numeral. -/\nmeta inductive match_numeral_result\n| zero | one | bit0 (e : expr) | bit1 (e : expr) | other\n\n/-- Unfold the top level constructor of the numeral expression. -/\nmeta def match_numeral : expr → match_numeral_result\n| `(bit0 %%e) := match_numeral_result.bit0 e\n| `(bit1 %%e) := match_numeral_result.bit1 e\n| `(@has_zero.zero _ _) := match_numeral_result.zero\n| `(@has_one.one _ _) := match_numeral_result.one\n| _ := match_numeral_result.other\n\ntheorem zero_succ {α} [semiring α] : (0 + 1 : α) = 1 := zero_add _\ntheorem one_succ {α} [semiring α] : (1 + 1 : α) = 2 := rfl\ntheorem bit0_succ {α} [semiring α] (a : α) : bit0 a + 1 = bit1 a := rfl\ntheorem bit1_succ {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 = bit0 b :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\n/-- Given `a`, `b` natural numerals, proves `⊢ a + 1 = b`, assuming that this is provable.\n(It may prove garbage instead of failing if `a + 1 = b` is false.) -/\nmeta def prove_succ : instance_cache → expr → expr → tactic (instance_cache × expr)\n| c e r := match match_numeral e with\n  | zero := c.mk_app ``zero_succ []\n  | one := c.mk_app ``one_succ []\n  | bit0 e := c.mk_app ``bit0_succ [e]\n  | bit1 e := do\n    let r := r.app_arg,\n    (c, p) ← prove_succ c e r,\n    c.mk_app ``bit1_succ [e, r, p]\n  | _ := failed\n  end\nend\n\n/-- Given `a` natural numeral, returns `(b, ⊢ a + 1 = b)`. -/\nmeta def prove_succ' (c : instance_cache) (a : expr) : tactic (instance_cache × expr × expr) :=\ndo na ← a.to_nat,\n  (c, b) ← c.of_nat (na + 1),\n  (c, p) ← prove_succ c a b,\n  return (c, b, p)\n\ntheorem zero_adc {α} [semiring α] (a b : α) (h : a + 1 = b) : 0 + a + 1 = b := by rwa zero_add\ntheorem adc_zero {α} [semiring α] (a b : α) (h : a + 1 = b) : a + 0 + 1 = b := by rwa add_zero\ntheorem one_add {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + a = b := by rwa add_comm\ntheorem add_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b = bit0 c :=\nh ▸ by simp [bit0, add_left_comm, add_assoc]\ntheorem add_bit0_bit1 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit1 b = bit1 c :=\nh ▸ by simp [bit0, bit1, add_left_comm, add_assoc]\ntheorem add_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit1 a + bit0 b = bit1 c :=\nh ▸ by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem add_bit1_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) : bit1 a + bit1 b = bit0 c :=\nh ▸ by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem adc_one_one {α} [semiring α] : (1 + 1 + 1 : α) = 3 := rfl\ntheorem adc_bit0_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit0 a + 1 + 1 = bit0 b :=\nh ▸ by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit0 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit0 a + 1 = bit0 b :=\nh ▸ by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 + 1 = bit1 b :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit1 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit1 a + 1 = bit1 b :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b + 1 = bit1 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) :\n  bit1 a + bit0 b + 1 = bit0 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) :\n  bit0 a + bit1 b + 1 = bit0 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) :\n  bit1 a + bit1 b + 1 = bit1 c :=\nh ▸ by simp [bit1, bit0, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\nmeta mutual def prove_add_nat, prove_adc_nat\nwith prove_add_nat : instance_cache → expr → expr → expr → tactic (instance_cache × expr)\n| c a b r := do\n  match match_numeral a, match_numeral b with\n  | zero, _ := c.mk_app ``zero_add [b]\n  | _, zero := c.mk_app ``add_zero [a]\n  | _, one := prove_succ c a r\n  | one, _ := do (c, p) ← prove_succ c b r, c.mk_app ``one_add [b, r, p]\n  | bit0 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit0_bit0 [a, b, r, p]\n  | bit0 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit0_bit1 [a, b, r, p]\n  | bit1 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit1_bit0 [a, b, r, p]\n  | bit1 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``add_bit1_bit1 [a, b, r, p]\n  | _, _ := failed\n  end\nwith prove_adc_nat : instance_cache → expr → expr → expr → tactic (instance_cache × expr)\n| c a b r := do\n  match match_numeral a, match_numeral b with\n  | zero, _ := do (c, p) ← prove_succ c b r, c.mk_app ``zero_adc [b, r, p]\n  | _, zero := do (c, p) ← prove_succ c b r, c.mk_app ``adc_zero [b, r, p]\n  | one, one := c.mk_app ``adc_one_one []\n  | bit0 a, one :=\n    do let r := r.app_arg, (c, p) ← prove_succ c a r, c.mk_app ``adc_bit0_one [a, r, p]\n  | one, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_succ c b r, c.mk_app ``adc_one_bit0 [b, r, p]\n  | bit1 a, one :=\n    do let r := r.app_arg, (c, p) ← prove_succ c a r, c.mk_app ``adc_bit1_one [a, r, p]\n  | one, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_succ c b r, c.mk_app ``adc_one_bit1 [b, r, p]\n  | bit0 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``adc_bit0_bit0 [a, b, r, p]\n  | bit0 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit0_bit1 [a, b, r, p]\n  | bit1 a, bit0 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit1_bit0 [a, b, r, p]\n  | bit1 a, bit1 b :=\n    do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit1_bit1 [a, b, r, p]\n  | _, _ := failed\n  end\n\n/-- Given `a`,`b`,`r` natural numerals, proves `⊢ a + b = r`. -/\nadd_decl_doc prove_add_nat\n/-- Given `a`,`b`,`r` natural numerals, proves `⊢ a + b + 1 = r`. -/\nadd_decl_doc prove_adc_nat\n\n/-- Given `a`,`b` natural numerals, returns `(r, ⊢ a + b = r)`. -/\nmeta def prove_add_nat' (c : instance_cache) (a b : expr) : tactic (instance_cache × expr × expr) :=\ndo na ← a.to_nat,\n  nb ← b.to_nat,\n  (c, r) ← c.of_nat (na + nb),\n  (c, p) ← prove_add_nat c a b r,\n  return (c, r, p)\n\nend\n\ntheorem bit0_mul {α} [semiring α] (a b c : α) (h : a * b = c) :\n  bit0 a * b = bit0 c := h ▸ by simp [bit0, add_mul]\ntheorem mul_bit0' {α} [semiring α] (a b c : α) (h : a * b = c) :\n  a * bit0 b = bit0 c := h ▸ by simp [bit0, mul_add]\ntheorem mul_bit0_bit0 {α} [semiring α] (a b c : α) (h : a * b = c) :\n  bit0 a * bit0 b = bit0 (bit0 c) := bit0_mul _ _ _ (mul_bit0' _ _ _ h)\ntheorem mul_bit1_bit1 {α} [semiring α] (a b c d e : α)\n  (hc : a * b = c) (hd : a + b = d) (he : bit0 c + d = e) :\n  bit1 a * bit1 b = bit1 e :=\nby rw [← he, ← hd, ← hc]; simp [bit1, bit0, mul_add, add_mul, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\n/-- Given `a`,`b` natural numerals, returns `(r, ⊢ a * b = r)`. -/\nmeta def prove_mul_nat : instance_cache → expr → expr → tactic (instance_cache × expr × expr)\n| ic a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := do\n    (ic, z) ← ic.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``zero_mul [b],\n    return (ic, z, p)\n  | _, zero := do\n    (ic, z) ← ic.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``mul_zero [a],\n    return (ic, z, p)\n  | one, _ := do (ic, p) ← ic.mk_app ``one_mul [b], return (ic, b, p)\n  | _, one := do (ic, p) ← ic.mk_app ``mul_one [a], return (ic, a, p)\n  | bit0 a, bit0 b := do\n    (ic, c, p) ← prove_mul_nat ic a b,\n    (ic, p) ← ic.mk_app ``mul_bit0_bit0 [a, b, c, p],\n    (ic, c') ← ic.mk_bit0 c,\n    (ic, c') ← ic.mk_bit0 c',\n    return (ic, c', p)\n  | bit0 a, _ := do\n    (ic, c, p) ← prove_mul_nat ic a b,\n    (ic, p) ← ic.mk_app ``bit0_mul [a, b, c, p],\n    (ic, c') ← ic.mk_bit0 c,\n    return (ic, c', p)\n  | _, bit0 b := do\n    (ic, c, p) ← prove_mul_nat ic a b,\n    (ic, p) ← ic.mk_app ``mul_bit0' [a, b, c, p],\n    (ic, c') ← ic.mk_bit0 c,\n    return (ic, c', p)\n  | bit1 a, bit1 b := do\n    (ic, c, pc) ← prove_mul_nat ic a b,\n    (ic, d, pd) ← prove_add_nat' ic a b,\n    (ic, c') ← ic.mk_bit0 c,\n    (ic, e, pe) ← prove_add_nat' ic c' d,\n    (ic, p) ← ic.mk_app ``mul_bit1_bit1 [a, b, c, d, e, pc, pd, pe],\n    (ic, e') ← ic.mk_bit1 e,\n    return (ic, e', p)\n  | _, _ := failed\n  end\n\nend\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a positive natural numeral, returns `⊢ 0 < a`. -/\nmeta def prove_pos_nat (c : instance_cache) : expr → tactic (instance_cache × expr)\n| e :=\n  match match_numeral e with\n  | one := c.mk_app ``zero_lt_one' []\n  | bit0 e := do (c, p) ← prove_pos_nat e, c.mk_app ``bit0_pos [e, p]\n  | bit1 e := do (c, p) ← prove_pos_nat e, c.mk_app ``bit1_pos' [e, p]\n  | _ := failed\n  end\n\nend\n\n/-- Given `a` a rational numeral, returns `⊢ 0 < a`. -/\nmeta def prove_pos (c : instance_cache) : expr → tactic (instance_cache × expr)\n| `(%%e₁ / %%e₂) := do\n  (c, p₁) ← prove_pos_nat c e₁, (c, p₂) ← prove_pos_nat c e₂,\n  c.mk_app ``div_pos [e₁, e₂, p₁, p₂]\n| e := prove_pos_nat c e\n\n/-- `match_neg (- e) = some e`, otherwise `none` -/\nmeta def match_neg : expr → option expr\n| `(- %%e) := some e\n| _ := none\n\n/-- `match_sign (- e) = inl e`, `match_sign 0 = inr ff`, otherwise `inr tt` -/\nmeta def match_sign : expr → expr ⊕ bool\n| `(- %%e) := sum.inl e\n| `(has_zero.zero) := sum.inr ff\n| _ := sum.inr tt\n\ntheorem ne_zero_of_pos {α} [ordered_add_comm_group α] (a : α) : 0 < a → a ≠ 0 := ne_of_gt\ntheorem ne_zero_neg {α} [add_group α] (a : α) : a ≠ 0 → -a ≠ 0 := mt neg_eq_zero.1\n\n/-- Given `a` a rational numeral, returns `⊢ a ≠ 0`. -/\nmeta def prove_ne_zero' (c : instance_cache) : expr → tactic (instance_cache × expr)\n| a :=\n  match match_neg a with\n  | some a := do (c, p) ← prove_ne_zero' a, c.mk_app ``ne_zero_neg [a, p]\n  | none := do (c, p) ← prove_pos c a, c.mk_app ``ne_zero_of_pos [a, p]\n  end\n\ntheorem clear_denom_div {α} [division_ring α] (a b b' c d : α)\n  (h₀ : b ≠ 0) (h₁ : b * b' = d) (h₂ : a * b' = c) : (a / b) * d = c :=\nby rwa [← h₁, ← mul_assoc, div_mul_cancel _ h₀]\n\n/-- Given `a` nonnegative rational and `d` a natural number, returns `(b, ⊢ a * d = b)`.\n(`d` should be a multiple of the denominator of `a`, so that `b` is a natural number.) -/\nmeta def prove_clear_denom'\n  (prove_ne_zero : instance_cache → expr → ℚ → tactic (instance_cache × expr))\n  (c : instance_cache) (a d : expr) (na : ℚ) (nd : ℕ) :\n  tactic (instance_cache × expr × expr) :=\nif na.denom = 1 then\n  prove_mul_nat c a d\nelse do\n  [_, _, a, b] ← return a.get_app_args,\n  (c, b') ← c.of_nat (nd / na.denom),\n  (c, p₀) ← prove_ne_zero c b (rat.of_int na.denom),\n  (c, _, p₁) ← prove_mul_nat c b b',\n  (c, r, p₂) ← prove_mul_nat c a b',\n  (c, p) ← c.mk_app ``clear_denom_div [a, b, b', r, d, p₀, p₁, p₂],\n  return (c, r, p)\n\ntheorem nonneg_pos {α} [ordered_cancel_add_comm_monoid α] (a : α) : 0 < a → 0 ≤ a := le_of_lt\n\ntheorem lt_one_bit0 {α} [linear_ordered_semiring α] (a : α) (h : 1 ≤ a) : 1 < bit0 a :=\nlt_of_lt_of_le one_lt_two (bit0_le_bit0.2 h)\ntheorem lt_one_bit1 {α} [linear_ordered_semiring α] (a : α) (h : 0 < a) : 1 < bit1 a :=\none_lt_bit1.2 h\ntheorem lt_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a < b → bit0 a < bit0 b :=\nbit0_lt_bit0.2\ntheorem lt_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a < bit1 b :=\nlt_of_le_of_lt (bit0_le_bit0.2 h) (lt_add_one _)\ntheorem lt_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a < bit0 b :=\nlt_of_lt_of_le (by simp [bit0, bit1, zero_lt_one, add_assoc]) (bit0_le_bit0.2 h)\ntheorem lt_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) : a < b → bit1 a < bit1 b :=\nbit1_lt_bit1.2\n\ntheorem le_one_bit0 {α} [linear_ordered_semiring α] (a : α) (h : 1 ≤ a) : 1 ≤ bit0 a :=\nle_of_lt (lt_one_bit0 _ h)\n-- deliberately strong hypothesis because bit1 0 is not a numeral\ntheorem le_one_bit1 {α} [linear_ordered_semiring α] (a : α) (h : 0 < a) : 1 ≤ bit1 a :=\nle_of_lt (lt_one_bit1 _ h)\ntheorem le_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a ≤ b → bit0 a ≤ bit0 b :=\nbit0_le_bit0.2\ntheorem le_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a ≤ bit1 b :=\nle_of_lt (lt_bit0_bit1 _ _ h)\ntheorem le_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a ≤ bit0 b :=\nle_of_lt (lt_bit1_bit0 _ _ h)\ntheorem le_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) : a ≤ b → bit1 a ≤ bit1 b :=\nbit1_le_bit1.2\n\ntheorem sle_one_bit0 {α} [linear_ordered_semiring α] (a : α) : 1 ≤ a → 1 + 1 ≤ bit0 a :=\nbit0_le_bit0.2\ntheorem sle_one_bit1 {α} [linear_ordered_semiring α] (a : α) : 1 ≤ a → 1 + 1 ≤ bit1 a :=\nle_bit0_bit1 _ _\ntheorem sle_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a + 1 ≤ b → bit0 a + 1 ≤ bit0 b :=\nle_bit1_bit0 _ _\ntheorem sle_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a + 1 ≤ bit1 b :=\nbit1_le_bit1.2 h\ntheorem sle_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) :\n  bit1 a + 1 ≤ bit0 b :=\n(bit1_succ a _ rfl).symm ▸ bit0_le_bit0.2 h\ntheorem sle_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) :\n  bit1 a + 1 ≤ bit1 b :=\n(bit1_succ a _ rfl).symm ▸ le_bit0_bit1 _ _ h\n\n/-- Given `a` a rational numeral, returns `⊢ 0 ≤ a`. -/\nmeta def prove_nonneg (ic : instance_cache) : expr → tactic (instance_cache × expr)\n| e@`(has_zero.zero) := ic.mk_app ``le_refl [e]\n| e :=\n  if ic.α = `(ℕ) then\n    return (ic, `(nat.zero_le).mk_app [e])\n  else do\n    (ic, p) ← prove_pos ic e,\n    ic.mk_app ``nonneg_pos [e, p]\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a rational numeral, returns `⊢ 1 ≤ a`. -/\nmeta def prove_one_le_nat (ic : instance_cache) : expr → tactic (instance_cache × expr)\n| a :=\n  match match_numeral a with\n  | one := ic.mk_app ``le_refl [a]\n  | bit0 a := do (ic, p) ← prove_one_le_nat a, ic.mk_app ``le_one_bit0 [a, p]\n  | bit1 a := do (ic, p) ← prove_pos_nat ic a, ic.mk_app ``le_one_bit1 [a, p]\n  | _ := failed\n  end\n\nmeta mutual def prove_le_nat, prove_sle_nat (ic : instance_cache)\nwith prove_le_nat : expr → expr → tactic (instance_cache × expr)\n| a b :=\n  if a = b then ic.mk_app ``le_refl [a] else\n  match match_numeral a, match_numeral b with\n  | zero, _ := prove_nonneg ic b\n  | one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``le_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) ← prove_pos_nat ic b, ic.mk_app ``le_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``le_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\nwith prove_sle_nat : expr → expr → tactic (instance_cache × expr)\n| a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := prove_nonneg ic b\n  | one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``sle_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``sle_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``sle_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\n\n/-- Given `a`,`b` natural numerals, proves `⊢ a ≤ b`. -/\nadd_decl_doc prove_le_nat\n/-- Given `a`,`b` natural numerals, proves `⊢ a + 1 ≤ b`. -/\nadd_decl_doc prove_sle_nat\n\n/-- Given `a`,`b` natural numerals, proves `⊢ a < b`. -/\nmeta def prove_lt_nat (ic : instance_cache) : expr → expr → tactic (instance_cache × expr)\n| a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := prove_pos ic b\n  | one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``lt_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) ← prove_pos_nat ic b, ic.mk_app ``lt_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) ← prove_lt_nat a b, ic.mk_app ``lt_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) ← prove_le_nat ic a b, ic.mk_app ``lt_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) ← prove_sle_nat ic a b, ic.mk_app ``lt_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) ← prove_lt_nat a b, ic.mk_app ``lt_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\n\nend\n\ntheorem clear_denom_lt {α} [linear_ordered_semiring α] (a a' b b' d : α)\n  (h₀ : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' < b') : a < b :=\nlt_of_mul_lt_mul_right (by rwa [ha, hb]) (le_of_lt h₀)\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `⊢ a < b`. -/\nmeta def prove_lt_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_lt_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) ← ic.of_nat nd,\n  (ic, p₀) ← prove_pos ic d,\n  (ic, a', pa) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) ← prove_lt_nat ic a' b',\n  ic.mk_app ``clear_denom_lt [a, a', b, b', d, p₀, pa, pb, p]\n\nlemma lt_neg_pos {α} [ordered_add_comm_group α] (a b : α) (ha : 0 < a) (hb : 0 < b) : -a < b :=\nlt_trans (neg_neg_of_pos ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a < b`. -/\nmeta def prove_lt_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  -- we have to switch the order of `a` and `b` because `a < b ↔ -b < -a`\n  (ic, p) ← prove_lt_nonneg_rat ic b a (-nb) (-na),\n  ic.mk_app ``neg_lt_neg [b, a, p]\n| sum.inl a, sum.inr ff := do\n  (ic, p) ← prove_pos ic a,\n  ic.mk_app ``neg_neg_of_pos [a, p]\n| sum.inl a, sum.inr tt := do\n  (ic, pa) ← prove_pos ic a,\n  (ic, pb) ← prove_pos ic b,\n  ic.mk_app ``lt_neg_pos [a, b, pa, pb]\n| sum.inr ff, _ := prove_pos ic b\n| sum.inr tt, _ := prove_lt_nonneg_rat ic a b na nb\nend\n\ntheorem clear_denom_le {α} [linear_ordered_semiring α] (a a' b b' d : α)\n  (h₀ : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' ≤ b') : a ≤ b :=\nle_of_mul_le_mul_right (by rwa [ha, hb]) h₀\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `⊢ a ≤ b`. -/\nmeta def prove_le_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_le_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) ← ic.of_nat nd,\n  (ic, p₀) ← prove_pos ic d,\n  (ic, a', pa) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) ← prove_clear_denom' (λ ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) ← prove_le_nat ic a' b',\n  ic.mk_app ``clear_denom_le [a, a', b, b', d, p₀, pa, pb, p]\n\nlemma le_neg_pos {α} [ordered_add_comm_group α] (a b : α) (ha : 0 ≤ a) (hb : 0 ≤ b) : -a ≤ b :=\nle_trans (neg_nonpos_of_nonneg ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a ≤ b`. -/\nmeta def prove_le_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, p) ← prove_le_nonneg_rat ic a b (-na) (-nb),\n  ic.mk_app ``neg_le_neg [a, b, p]\n| sum.inl a, sum.inr ff := do\n  (ic, p) ← prove_nonneg ic a,\n  ic.mk_app ``neg_nonpos_of_nonneg [a, p]\n| sum.inl a, sum.inr tt := do\n  (ic, pa) ← prove_nonneg ic a,\n  (ic, pb) ← prove_nonneg ic b,\n  ic.mk_app ``le_neg_pos [a, b, pa, pb]\n| sum.inr ff, _ := prove_nonneg ic b\n| sum.inr tt, _ := prove_le_nonneg_rat ic a b na nb\nend\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a ≠ b`. This version tries to prove\n`⊢ a < b` or `⊢ b < a`, and so is not appropriate for types without an order relation. -/\nmeta def prove_ne_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr) :=\nif na < nb then do\n  (ic, p) ← prove_lt_rat ic a b na nb,\n  ic.mk_app ``ne_of_lt [a, b, p]\nelse do\n  (ic, p) ← prove_lt_rat ic b a nb na,\n  ic.mk_app ``ne_of_gt [a, b, p]\n\ntheorem nat_cast_zero {α} [semiring α] : ↑(0 : ℕ) = (0 : α) := nat.cast_zero\ntheorem nat_cast_one {α} [semiring α] : ↑(1 : ℕ) = (1 : α) := nat.cast_one\ntheorem nat_cast_bit0 {α} [semiring α] (a : ℕ) (a' : α) (h : ↑a = a') : ↑(bit0 a) = bit0 a' :=\nh ▸ nat.cast_bit0 _\ntheorem nat_cast_bit1 {α} [semiring α] (a : ℕ) (a' : α) (h : ↑a = a') : ↑(bit1 a) = bit1 a' :=\nh ▸ nat.cast_bit1 _\ntheorem int_cast_zero {α} [ring α] : ↑(0 : ℤ) = (0 : α) := int.cast_zero\ntheorem int_cast_one {α} [ring α] : ↑(1 : ℤ) = (1 : α) := int.cast_one\ntheorem int_cast_bit0 {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑(bit0 a) = bit0 a' :=\nh ▸ int.cast_bit0 _\ntheorem int_cast_bit1 {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑(bit1 a) = bit1 a' :=\nh ▸ int.cast_bit1 _\ntheorem rat_cast_bit0 {α} [division_ring α] [char_zero α] (a : ℚ) (a' : α) (h : ↑a = a') :\n  ↑(bit0 a) = bit0 a' :=\nh ▸ rat.cast_bit0 _\ntheorem rat_cast_bit1 {α} [division_ring α] [char_zero α] (a : ℚ) (a' : α) (h : ↑a = a') :\n  ↑(bit1 a) = bit1 a' :=\nh ▸ rat.cast_bit1 _\n\n/-- Given `a' : α` a natural numeral, returns `(a : ℕ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_nat_uncast (ic nc : instance_cache) : ∀ (a' : expr),\n  tactic (instance_cache × instance_cache × expr × expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (nc, e) ← nc.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``nat_cast_zero [],\n    return (ic, nc, e, p)\n  | match_numeral_result.one := do\n    (nc, e) ← nc.mk_app ``has_one.one [],\n    (ic, p) ← ic.mk_app ``nat_cast_one [],\n    return (ic, nc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, nc, a, p) ← prove_nat_uncast a',\n    (nc, a0) ← nc.mk_bit0 a,\n    (ic, p) ← ic.mk_app ``nat_cast_bit0 [a, a', p],\n    return (ic, nc, a0, p)\n  | match_numeral_result.bit1 a' := do\n    (ic, nc, a, p) ← prove_nat_uncast a',\n    (nc, a1) ← nc.mk_bit1 a,\n    (ic, p) ← ic.mk_app ``nat_cast_bit1 [a, a', p],\n    return (ic, nc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : α` a natural numeral, returns `(a : ℤ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_int_uncast_nat (ic zc : instance_cache) : ∀ (a' : expr),\n  tactic (instance_cache × instance_cache × expr × expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (zc, e) ← zc.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``int_cast_zero [],\n    return (ic, zc, e, p)\n  | match_numeral_result.one := do\n    (zc, e) ← zc.mk_app ``has_one.one [],\n    (ic, p) ← ic.mk_app ``int_cast_one [],\n    return (ic, zc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, zc, a, p) ← prove_int_uncast_nat a',\n    (zc, a0) ← zc.mk_bit0 a,\n    (ic, p) ← ic.mk_app ``int_cast_bit0 [a, a', p],\n    return (ic, zc, a0, p)\n  | match_numeral_result.bit1 a' := do\n    (ic, zc, a, p) ← prove_int_uncast_nat a',\n    (zc, a1) ← zc.mk_bit1 a,\n    (ic, p) ← ic.mk_app ``int_cast_bit1 [a, a', p],\n    return (ic, zc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : α` a natural numeral, returns `(a : ℚ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_rat_uncast_nat (ic qc : instance_cache) (cz_inst : expr) : ∀ (a' : expr),\n  tactic (instance_cache × instance_cache × expr × expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (qc, e) ← qc.mk_app ``has_zero.zero [],\n    (ic, p) ← ic.mk_app ``rat.cast_zero [],\n    return (ic, qc, e, p)\n  | match_numeral_result.one := do\n    (qc, e) ← qc.mk_app ``has_one.one [],\n    (ic, p) ← ic.mk_app ``rat.cast_one [],\n    return (ic, qc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, qc, a, p) ← prove_rat_uncast_nat a',\n    (qc, a0) ← qc.mk_bit0 a,\n    (ic, p) ← ic.mk_app ``rat_cast_bit0 [cz_inst, a, a', p],\n    return (ic, qc, a0, p)\n  | match_numeral_result.bit1 a' := do\n    (ic, qc, a, p) ← prove_rat_uncast_nat a',\n    (qc, a1) ← qc.mk_bit1 a,\n    (ic, p) ← ic.mk_app ``rat_cast_bit1 [cz_inst, a, a', p],\n    return (ic, qc, a1, p)\n  | _ := failed\n  end\n\ntheorem rat_cast_div {α} [division_ring α] [char_zero α] (a b : ℚ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') : ↑(a / b) = a' / b' :=\nha ▸ hb ▸ rat.cast_div _ _\n\n/-- Given `a' : α` a nonnegative rational numeral, returns `(a : ℚ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_rat_uncast_nonneg (ic qc : instance_cache) (cz_inst a' : expr) (na' : ℚ) :\n tactic (instance_cache × instance_cache × expr × expr) :=\nif na'.denom = 1 then\n  prove_rat_uncast_nat ic qc cz_inst a'\nelse do\n  [_, _, a', b'] ← return a'.get_app_args,\n  (ic, qc, a, pa) ← prove_rat_uncast_nat ic qc cz_inst a',\n  (ic, qc, b, pb) ← prove_rat_uncast_nat ic qc cz_inst b',\n  (qc, e) ← qc.mk_app ``has_div.div [a, b],\n  (ic, p) ← ic.mk_app ``rat_cast_div [cz_inst, a, b, a', b', pa, pb],\n  return (ic, qc, e, p)\n\ntheorem int_cast_neg {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑-a = -a' :=\nh ▸ int.cast_neg _\ntheorem rat_cast_neg {α} [division_ring α] (a : ℚ) (a' : α) (h : ↑a = a') : ↑-a = -a' :=\nh ▸ rat.cast_neg _\n\n/-- Given `a' : α` an integer numeral, returns `(a : ℤ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_int_uncast (ic zc : instance_cache) (a' : expr) :\n  tactic (instance_cache × instance_cache × expr × expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, zc, a, p) ← prove_int_uncast_nat ic zc a',\n  (zc, e) ← zc.mk_app ``has_neg.neg [a],\n  (ic, p) ← ic.mk_app ``int_cast_neg [a, a', p],\n  return (ic, zc, e, p)\n| none := prove_int_uncast_nat ic zc a'\nend\n\n/-- Given `a' : α` a rational numeral, returns `(a : ℚ, ⊢ ↑a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_rat_uncast (ic qc : instance_cache) (cz_inst a' : expr) (na' : ℚ) :\n  tactic (instance_cache × instance_cache × expr × expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, qc, a, p) ← prove_rat_uncast_nonneg ic qc cz_inst a' (-na'),\n  (qc, e) ← qc.mk_app ``has_neg.neg [a],\n  (ic, p) ← ic.mk_app ``rat_cast_neg [a, a', p],\n  return (ic, qc, e, p)\n| none := prove_rat_uncast_nonneg ic qc cz_inst a' na'\nend\n\ntheorem nat_cast_ne {α} [semiring α] [char_zero α] (a b : ℕ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=\nha ▸ hb ▸ mt nat.cast_inj.1 h\ntheorem int_cast_ne {α} [ring α] [char_zero α] (a b : ℤ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=\nha ▸ hb ▸ mt int.cast_inj.1 h\ntheorem rat_cast_ne {α} [division_ring α] [char_zero α] (a b : ℚ) (a' b' : α)\n  (ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=\nha ▸ hb ▸ mt rat.cast_inj.1 h\n\n/-- Given `a`,`b` rational numerals, proves `⊢ a ≠ b`. Currently it tries two methods:\n\n  * Prove `⊢ a < b` or `⊢ b < a`, if the base type has an order\n  * Embed `↑(a':ℚ) = a` and `↑(b':ℚ) = b`, and then prove `a' ≠ b'`.\n    This requires that the base type be `char_zero`, and also that it be a `division_ring`\n    so that the coercion from `ℚ` is well defined.\n\nWe may also add coercions to `ℤ` and `ℕ` as well in order to support `char_zero`\nrings and semirings. -/\nmeta def prove_ne : instance_cache → expr → expr → ℚ → ℚ → tactic (instance_cache × expr)\n| ic a b na nb := prove_ne_rat ic a b na nb <|> do\n  cz_inst ← mk_mapp ``char_zero [ic.α, none, none] >>= mk_instance,\n  if na.denom = 1 ∧ nb.denom = 1 then\n    if na ≥ 0 ∧ nb ≥ 0 then do\n      guard (ic.α ≠ `(ℕ)),\n      nc ← mk_instance_cache `(ℕ),\n      (ic, nc, a', pa) ← prove_nat_uncast ic nc a,\n      (ic, nc, b', pb) ← prove_nat_uncast ic nc b,\n      (nc, p) ← prove_ne_rat nc a' b' na nb,\n      ic.mk_app ``nat_cast_ne [cz_inst, a', b', a, b, pa, pb, p]\n    else do\n      guard (ic.α ≠ `(ℤ)),\n      zc ← mk_instance_cache `(ℤ),\n      (ic, zc, a', pa) ← prove_int_uncast ic zc a,\n      (ic, zc, b', pb) ← prove_int_uncast ic zc b,\n      (zc, p) ← prove_ne_rat zc a' b' na nb,\n      ic.mk_app ``int_cast_ne [cz_inst, a', b', a, b, pa, pb, p]\n  else do\n    guard (ic.α ≠ `(ℚ)),\n    qc ← mk_instance_cache `(ℚ),\n    (ic, qc, a', pa) ← prove_rat_uncast ic qc cz_inst a na,\n    (ic, qc, b', pb) ← prove_rat_uncast ic qc cz_inst b nb,\n    (qc, p) ← prove_ne_rat qc a' b' na nb,\n    ic.mk_app ``rat_cast_ne [cz_inst, a', b', a, b, pa, pb, p]\n\n/-- Given `a` a rational numeral, returns `⊢ a ≠ 0`. -/\nmeta def prove_ne_zero (ic : instance_cache) : expr → ℚ → tactic (instance_cache × expr)\n| a na := do\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  prove_ne ic a z na 0\n\n/-- Given `a` nonnegative rational and `d` a natural number, returns `(b, ⊢ a * d = b)`.\n(`d` should be a multiple of the denominator of `a`, so that `b` is a natural number.) -/\nmeta def prove_clear_denom : instance_cache → expr → expr → ℚ → ℕ →\n  tactic (instance_cache × expr × expr) := prove_clear_denom' prove_ne_zero\n\ntheorem clear_denom_add {α} [division_ring α] (a a' b b' c c' d : α)\n  (h₀ : d ≠ 0) (ha : a * d = a') (hb : b * d = b') (hc : c * d = c')\n  (h : a' + b' = c') : a + b = c :=\nmul_right_cancel₀ h₀ $ by rwa [add_mul, ha, hb, hc]\n\n/-- Given `a`,`b`,`c` nonnegative rational numerals, returns `⊢ a + b = c`. -/\nmeta def prove_add_nonneg_rat (ic : instance_cache) (a b c : expr) (na nb nc : ℚ) :\n  tactic (instance_cache × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_add_nat ic a b c\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) ← ic.of_nat nd,\n  (ic, p₀) ← prove_ne_zero ic d (rat.of_int nd),\n  (ic, a', pa) ← prove_clear_denom ic a d na nd,\n  (ic, b', pb) ← prove_clear_denom ic b d nb nd,\n  (ic, c', pc) ← prove_clear_denom ic c d nc nd,\n  (ic, p) ← prove_add_nat ic a' b' c',\n  ic.mk_app ``clear_denom_add [a, a', b, b', c, c', d, p₀, pa, pb, pc, p]\n\ntheorem add_pos_neg_pos {α} [add_group α] (a b c : α) (h : c + b = a) : a + -b = c :=\nh ▸ by simp\ntheorem add_pos_neg_neg {α} [add_group α] (a b c : α) (h : c + a = b) : a + -b = -c :=\nh ▸ by simp\ntheorem add_neg_pos_pos {α} [add_group α] (a b c : α) (h : a + c = b) : -a + b = c :=\nh ▸ by simp\ntheorem add_neg_pos_neg {α} [add_group α] (a b c : α) (h : b + c = a) : -a + b = -c :=\nh ▸ by simp\ntheorem add_neg_neg {α} [add_group α] (a b c : α) (h : b + a = c) : -a + -b = -c :=\nh ▸ by simp\n\n/-- Given `a`,`b`,`c` rational numerals, returns `⊢ a + b = c`. -/\nmeta def prove_add_rat (ic : instance_cache) (ea eb ec : expr) (a b c : ℚ) :\n  tactic (instance_cache × expr) :=\nmatch match_neg ea, match_neg eb, match_neg ec with\n| some ea, some eb, some ec := do\n  (ic, p) ← prove_add_nonneg_rat ic eb ea ec (-b) (-a) (-c),\n  ic.mk_app ``add_neg_neg [ea, eb, ec, p]\n| some ea, none, some ec := do\n  (ic, p) ← prove_add_nonneg_rat ic eb ec ea b (-c) (-a),\n  ic.mk_app ``add_neg_pos_neg [ea, eb, ec, p]\n| some ea, none, none := do\n  (ic, p) ← prove_add_nonneg_rat ic ea ec eb (-a) c b,\n  ic.mk_app ``add_neg_pos_pos [ea, eb, ec, p]\n| none, some eb, some ec := do\n  (ic, p) ← prove_add_nonneg_rat ic ec ea eb (-c) a (-b),\n  ic.mk_app ``add_pos_neg_neg [ea, eb, ec, p]\n| none, some eb, none := do\n  (ic, p) ← prove_add_nonneg_rat ic ec eb ea c (-b) a,\n  ic.mk_app ``add_pos_neg_pos [ea, eb, ec, p]\n| _, _, _ := prove_add_nonneg_rat ic ea eb ec a b c\nend\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a + b = c)`. -/\nmeta def prove_add_rat' (ic : instance_cache) (a b : expr) :\n  tactic (instance_cache × expr × expr) :=\ndo na ← a.to_rat,\n  nb ← b.to_rat,\n  let nc := na + nb,\n  (ic, c) ← ic.of_rat nc,\n  (ic, p) ← prove_add_rat ic a b c na nb nc,\n  return (ic, c, p)\n\ntheorem clear_denom_simple_nat {α} [division_ring α] (a : α) :\n  (1:α) ≠ 0 ∧ a * 1 = a := ⟨one_ne_zero, mul_one _⟩\ntheorem clear_denom_simple_div {α} [division_ring α] (a b : α) (h : b ≠ 0) :\n  b ≠ 0 ∧ a / b * b = a := ⟨h, div_mul_cancel _ h⟩\n\n/-- Given `a` a nonnegative rational numeral, returns `(b, c, ⊢ a * b = c)`\nwhere `b` and `c` are natural numerals. (`b` will be the denominator of `a`.) -/\nmeta def prove_clear_denom_simple (c : instance_cache) (a : expr) (na : ℚ) :\n  tactic (instance_cache × expr × expr × expr) :=\nif na.denom = 1 then do\n  (c, d) ← c.mk_app ``has_one.one [],\n  (c, p) ← c.mk_app ``clear_denom_simple_nat [a],\n  return (c, d, a, p)\nelse do\n  [α, _, a, b] ← return a.get_app_args,\n  (c, p₀) ← prove_ne_zero c b (rat.of_int na.denom),\n  (c, p) ← c.mk_app ``clear_denom_simple_div [a, b, p₀],\n  return (c, b, a, p)\n\ntheorem clear_denom_mul {α} [field α] (a a' b b' c c' d₁ d₂ d : α)\n  (ha : d₁ ≠ 0 ∧ a * d₁ = a') (hb : d₂ ≠ 0 ∧ b * d₂ = b')\n  (hc : c * d = c') (hd : d₁ * d₂ = d)\n  (h : a' * b' = c') : a * b = c :=\nmul_right_cancel₀ ha.1 $ mul_right_cancel₀ hb.1 $\nby rw [mul_assoc c, hd, hc, ← h, ← ha.2, ← hb.2, ← mul_assoc, mul_right_comm a]\n\n/-- Given `a`,`b` nonnegative rational numerals, returns `(c, ⊢ a * b = c)`. -/\nmeta def prove_mul_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr × expr) :=\nif na.denom = 1 ∧ nb.denom = 1 then\n  prove_mul_nat ic a b\nelse do\n  let nc := na * nb, (ic, c) ← ic.of_rat nc,\n  (ic, d₁, a', pa) ← prove_clear_denom_simple ic a na,\n  (ic, d₂, b', pb) ← prove_clear_denom_simple ic b nb,\n  (ic, d, pd) ← prove_mul_nat ic d₁ d₂, nd ← d.to_nat,\n  (ic, c', pc) ← prove_clear_denom ic c d nc nd,\n  (ic, _, p) ← prove_mul_nat ic a' b',\n  (ic, p) ← ic.mk_app ``clear_denom_mul [a, a', b, b', c, c', d₁, d₂, d, pa, pb, pc, pd, p],\n  return (ic, c, p)\n\ntheorem mul_neg_pos {α} [ring α] (a b c : α) (h : a * b = c) : -a * b = -c := h ▸ by simp\ntheorem mul_pos_neg {α} [ring α] (a b c : α) (h : a * b = c) : a * -b = -c := h ▸ by simp\ntheorem mul_neg_neg {α} [ring α] (a b c : α) (h : a * b = c) : -a * -b = c := h ▸ by simp\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a * b = c)`. -/\nmeta def prove_mul_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr × expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, c, p) ← prove_mul_nonneg_rat ic a b (-na) (-nb),\n  (ic, p) ← ic.mk_app ``mul_neg_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff, _ := do\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  (ic, p) ← ic.mk_app ``zero_mul [b],\n  return (ic, z, p)\n| _, sum.inr ff := do\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  (ic, p) ← ic.mk_app ``mul_zero [a],\n  return (ic, z, p)\n| sum.inl a, sum.inr tt := do\n  (ic, c, p) ← prove_mul_nonneg_rat ic a b (-na) nb,\n  (ic, p) ← ic.mk_app ``mul_neg_pos [a, b, c, p],\n  (ic, c') ← ic.mk_app ``has_neg.neg [c],\n  return (ic, c', p)\n| sum.inr tt, sum.inl b := do\n  (ic, c, p) ← prove_mul_nonneg_rat ic a b na (-nb),\n  (ic, p) ← ic.mk_app ``mul_pos_neg [a, b, c, p],\n  (ic, c') ← ic.mk_app ``has_neg.neg [c],\n  return (ic, c', p)\n| sum.inr tt, sum.inr tt := prove_mul_nonneg_rat ic a b na nb\nend\n\ntheorem inv_neg {α} [division_ring α] (a b : α) (h : a⁻¹ = b) : (-a)⁻¹ = -b :=\nh ▸ by simp only [inv_eq_one_div, one_div_neg_eq_neg_one_div]\n\n\n\n/-- Given `a` a rational numeral, returns `(b, ⊢ a⁻¹ = b)`. -/\nmeta def prove_inv : instance_cache → expr → ℚ → tactic (instance_cache × expr × expr)\n| ic e n :=\n  match match_sign e with\n  | sum.inl e := do\n    (ic, e', p) ← prove_inv ic e (-n),\n    (ic, r) ← ic.mk_app ``has_neg.neg [e'],\n    (ic, p) ← ic.mk_app ``inv_neg [e, e', p],\n    return (ic, r, p)\n  | sum.inr ff := do\n    (ic, p) ← ic.mk_app ``inv_zero [],\n    return (ic, e, p)\n  | sum.inr tt :=\n    if n.num = 1 then\n      if n.denom = 1 then do\n        (ic, p) ← ic.mk_app ``inv_one [],\n        return (ic, e, p)\n      else do\n        let e := e.app_arg,\n        (ic, p) ← ic.mk_app ``inv_one_div [e],\n        return (ic, e, p)\n    else if n.denom = 1 then do\n      (ic, p) ← ic.mk_app ``inv_div_one [e],\n      e ← infer_type p,\n      return (ic, e.app_arg, p)\n    else do\n      [_, _, a, b] ← return e.get_app_args,\n      (ic, e') ← ic.mk_app ``has_div.div [b, a],\n      (ic, p) ← ic.mk_app ``inv_div [a, b],\n      return (ic, e', p)\n  end\n\ntheorem div_eq {α} [division_ring α] (a b b' c : α)\n  (hb : b⁻¹ = b') (h : a * b' = c) : a / b = c :=\nby rwa [ ← hb, ← div_eq_mul_inv] at h\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a / b = c)`. -/\nmeta def prove_div (ic : instance_cache) (a b : expr) (na nb : ℚ) :\n  tactic (instance_cache × expr × expr) :=\ndo (ic, b', pb) ← prove_inv ic b nb,\n  (ic, c, p) ← prove_mul_rat ic a b' na nb⁻¹,\n  (ic, p) ← ic.mk_app ``div_eq [a, b, b', c, pb, p],\n  return (ic, c, p)\n\n/-- Given `a` a rational numeral, returns `(b, ⊢ -a = b)`. -/\nmeta def prove_neg (ic : instance_cache) (a : expr) : tactic (instance_cache × expr × expr) :=\nmatch match_sign a with\n| sum.inl a := do\n  (ic, p) ← ic.mk_app ``neg_neg [a],\n  return (ic, a, p)\n| sum.inr ff := do\n  (ic, p) ← ic.mk_app ``neg_zero [],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, a') ← ic.mk_app ``has_neg.neg [a],\n  p ← mk_eq_refl a',\n  return (ic, a', p)\nend\n\ntheorem sub_pos {α} [add_group α] (a b b' c : α) (hb : -b = b') (h : a + b' = c) : a - b = c :=\nby rwa [← hb, ← sub_eq_add_neg] at h\n\ntheorem sub_neg {α} [add_group α] (a b c : α) (h : a + b = c) : a - -b = c :=\nby rwa sub_neg_eq_add\n\n/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a - b = c)`. -/\nmeta def prove_sub (ic : instance_cache) (a b : expr) : tactic (instance_cache × expr × expr) :=\nmatch match_sign b with\n| sum.inl b := do\n  (ic, c, p) ← prove_add_rat' ic a b,\n  (ic, p) ← ic.mk_app ``sub_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff := do\n  (ic, p) ← ic.mk_app ``sub_zero [a],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, b', pb) ← prove_neg ic b,\n  (ic, c, p) ← prove_add_rat' ic a b',\n  (ic, p) ← ic.mk_app ``sub_pos [a, b, b', c, pb, p],\n  return (ic, c, p)\nend\n\ntheorem sub_nat_pos (a b c : ℕ) (h : b + c = a) : a - b = c :=\nh ▸ add_tsub_cancel_left _ _\ntheorem sub_nat_neg (a b c : ℕ) (h : a + c = b) : a - b = 0 :=\ntsub_eq_zero_iff_le.mpr $ h ▸ nat.le_add_right _ _\n\n/-- Given `a : nat`,`b : nat` natural numerals, returns `(c, ⊢ a - b = c)`. -/\nmeta def prove_sub_nat (ic : instance_cache) (a b : expr) : tactic (expr × expr) :=\ndo na ← a.to_nat, nb ← b.to_nat,\n  if nb ≤ na then do\n    (ic, c) ← ic.of_nat (na - nb),\n    (ic, p) ← prove_add_nat ic b c a,\n    return (c, `(sub_nat_pos).mk_app [a, b, c, p])\n  else do\n    (ic, c) ← ic.of_nat (nb - na),\n    (ic, p) ← prove_add_nat ic a c b,\n    return (`(0 : ℕ), `(sub_nat_neg).mk_app [a, b, c, p])\n\n/-- Evaluates the basic field operations `+`,`neg`,`-`,`*`,`inv`,`/` on numerals.\nAlso handles nat subtraction. Does not do recursive simplification; that is,\n`1 + 1 + 1` will not simplify but `2 + 1` will. This is handled by the top level\n`simp` call in `norm_num.derive`. -/\nmeta def eval_field : expr → tactic (expr × expr)\n| `(%%e₁ + %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  let n₃ := n₁ + n₂,\n  (c, e₃) ← c.of_rat n₃,\n  (_, p) ← prove_add_rat c e₁ e₂ e₃ n₁ n₂ n₃,\n  return (e₃, p)\n| `(%%e₁ * %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  prod.snd <$> prove_mul_rat c e₁ e₂ n₁ n₂\n| `(- %%e) := do\n  c ← infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_neg c e\n| `(@has_sub.sub %%α %%inst %%a %%b) := do\n  c ← mk_instance_cache α,\n  if α = `(nat) then prove_sub_nat c a b\n  else prod.snd <$> prove_sub c a b\n| `(has_inv.inv %%e) := do\n  n ← e.to_rat,\n  c ← infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_inv c e n\n| `(%%e₁ / %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  prod.snd <$> prove_div c e₁ e₂ n₁ n₂\n| _ := failed\n\nlemma pow_bit0 [monoid α] (a c' c : α) (b : ℕ)\n  (h : a ^ b = c') (h₂ : c' * c' = c) : a ^ bit0 b = c :=\nh₂ ▸ by simp [pow_bit0, h]\n\nlemma pow_bit1 [monoid α] (a c₁ c₂ c : α) (b : ℕ)\n  (h : a ^ b = c₁) (h₂ : c₁ * c₁ = c₂) (h₃ : c₂ * a = c) : a ^ bit1 b = c :=\nby rw [← h₃, ← h₂]; simp [pow_bit1, h]\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a rational numeral and `b : nat`, returns `(c, ⊢ a ^ b = c)`. -/\nmeta def prove_pow (a : expr) (na : ℚ) :\n  instance_cache → expr → tactic (instance_cache × expr × expr)\n| ic b :=\n  match match_numeral b with\n  | zero := do\n    (ic, p) ← ic.mk_app ``pow_zero [a],\n    (ic, o) ← ic.mk_app ``has_one.one [],\n    return (ic, o, p)\n  | one := do\n    (ic, p) ← ic.mk_app ``pow_one [a],\n    return (ic, a, p)\n  | bit0 b := do\n    (ic, c', p) ← prove_pow ic b,\n    nc' ← expr.to_rat c',\n    (ic, c, p₂) ← prove_mul_rat ic c' c' nc' nc',\n    (ic, p) ← ic.mk_app ``pow_bit0 [a, c', c, b, p, p₂],\n    return (ic, c, p)\n  | bit1 b := do\n    (ic, c₁, p) ← prove_pow ic b,\n    nc₁ ← expr.to_rat c₁,\n    (ic, c₂, p₂) ← prove_mul_rat ic c₁ c₁ nc₁ nc₁,\n    (ic, c, p₃) ← prove_mul_rat ic c₂ a (nc₁ * nc₁) na,\n    (ic, p) ← ic.mk_app ``pow_bit1 [a, c₁, c₂, c, b, p, p₂, p₃],\n    return (ic, c, p)\n  | _ := failed\n  end\n\nend\n\n/-- Evaluates expressions of the form `a ^ b`, `monoid.npow a b` or `nat.pow a b`. -/\nmeta def eval_pow : expr → tactic (expr × expr)\n| `(@has_pow.pow %%α _ %%m %%e₁ %%e₂) := do\n  n₁ ← e₁.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  match m with\n  | `(@monoid.has_pow %%_ %%_) := prod.snd <$> prove_pow e₁ n₁ c e₂\n  | _ := failed\n  end\n| `(monoid.npow %%e₁ %%e₂) := do\n  n₁ ← e₁.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  prod.snd <$> prove_pow e₁ n₁ c e₂\n| _ := failed\n\n/-- Given `⊢ p`, returns `(true, ⊢ p = true)`. -/\nmeta def true_intro (p : expr) : tactic (expr × expr) :=\nprod.mk `(true) <$> mk_app ``eq_true_intro [p]\n\n/-- Given `⊢ ¬ p`, returns `(false, ⊢ p = false)`. -/\nmeta def false_intro (p : expr) : tactic (expr × expr) :=\nprod.mk `(false) <$> mk_app ``eq_false_intro [p]\n\ntheorem not_refl_false_intro {α} (a : α) : (a ≠ a) = false :=\neq_false_intro $ not_not_intro rfl\n\n/-- Evaluates the inequality operations `=`,`<`,`>`,`≤`,`≥`,`≠` on numerals. -/\nmeta def eval_ineq : expr → tactic (expr × expr)\n| `(%%e₁ < %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ < n₂ then\n    do (_, p) ← prove_lt_rat c e₁ e₂ n₁ n₂, true_intro p\n  else if n₁ = n₂ then do\n    (_, p) ← c.mk_app ``lt_irrefl [e₁],\n    false_intro p\n  else do\n    (c, p') ← prove_lt_rat c e₂ e₁ n₂ n₁,\n    (_, p) ← c.mk_app ``not_lt_of_gt [e₁, e₂, p'],\n    false_intro p\n| `(%%e₁ ≤ %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ ≤ n₂ then do\n    (_, p) ←\n      if n₁ = n₂ then c.mk_app ``le_refl [e₁]\n      else prove_le_rat c e₁ e₂ n₁ n₂,\n    true_intro p\n  else do\n    (c, p) ← prove_lt_rat c e₂ e₁ n₂ n₁,\n    (_, p) ← c.mk_app ``not_le_of_gt [e₁, e₂, p],\n    false_intro p\n| `(%%e₁ = %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ = n₂ then mk_eq_refl e₁ >>= true_intro\n  else do (_, p) ← prove_ne c e₁ e₂ n₁ n₂, false_intro p\n| `(%%e₁ > %%e₂) := mk_app ``has_lt.lt [e₂, e₁] >>= eval_ineq\n| `(%%e₁ ≥ %%e₂) := mk_app ``has_le.le [e₂, e₁] >>= eval_ineq\n| `(%%e₁ ≠ %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ = n₂ then\n    prod.mk `(false) <$> mk_app ``not_refl_false_intro [e₁]\n  else do (_, p) ← prove_ne c e₁ e₂ n₁ n₂, true_intro p\n| _ := failed\n\ntheorem nat_succ_eq (a b c : ℕ) (h₁ : a = b) (h₂ : b + 1 = c) : nat.succ a = c := by rwa h₁\n\n/-- Evaluates the expression `nat.succ ... (nat.succ n)` where `n` is a natural numeral.\n(We could also just handle `nat.succ n` here and rely on `simp` to work bottom up, but we figure\nthat towers of successors coming from e.g. `induction` are a common case.) -/\nmeta def prove_nat_succ (ic : instance_cache) : expr → tactic (instance_cache × ℕ × expr × expr)\n| `(nat.succ %%a) := do\n  (ic, n, b, p₁) ← prove_nat_succ a,\n  let n' := n + 1,\n  (ic, c) ← ic.of_nat n',\n  (ic, p₂) ← prove_add_nat ic b `(1) c,\n  return (ic, n', c, `(nat_succ_eq).mk_app [a, b, c, p₁, p₂])\n| e := do\n  n ← e.to_nat,\n  p ← mk_eq_refl e,\n  return (ic, n, e, p)\n\nlemma nat_div (a b q r m : ℕ) (hm : q * b = m) (h : r + m = a) (h₂ : r < b) : a / b = q :=\nby rw [← h, ← hm, nat.add_mul_div_right _ _ (lt_of_le_of_lt (nat.zero_le _) h₂),\n       nat.div_eq_of_lt h₂, zero_add]\n\nlemma int_div (a b q r m : ℤ) (hm : q * b = m) (h : r + m = a) (h₁ : 0 ≤ r) (h₂ : r < b) :\n  a / b = q :=\nby rw [← h, ← hm, int.add_mul_div_right _ _ (ne_of_gt (lt_of_le_of_lt h₁ h₂)),\n       int.div_eq_zero_of_lt h₁ h₂, zero_add]\n\nlemma nat_mod (a b q r m : ℕ) (hm : q * b = m) (h : r + m = a) (h₂ : r < b) : a % b = r :=\nby rw [← h, ← hm, nat.add_mul_mod_self_right, nat.mod_eq_of_lt h₂]\n\nlemma int_mod (a b q r m : ℤ) (hm : q * b = m) (h : r + m = a) (h₁ : 0 ≤ r) (h₂ : r < b) :\n  a % b = r :=\nby rw [← h, ← hm, int.add_mul_mod_self, int.mod_eq_of_lt h₁ h₂]\n\nlemma int_div_neg (a b c' c : ℤ) (h : a / b = c') (h₂ : -c' = c) : a / -b = c :=\nh₂ ▸ h ▸ int.div_neg _ _\n\nlemma int_mod_neg (a b c : ℤ) (h : a % b = c) : a % -b = c :=\n(int.mod_neg _ _).trans h\n\n/-- Given `a`,`b` numerals in `nat` or `int`,\n  * `prove_div_mod ic a b ff` returns `(c, ⊢ a / b = c)`\n  * `prove_div_mod ic a b tt` returns `(c, ⊢ a % b = c)`\n-/\nmeta def prove_div_mod (ic : instance_cache) :\n  expr → expr → bool → tactic (instance_cache × expr × expr)\n| a b mod :=\n  match match_neg b with\n  | some b := do\n    (ic, c', p) ← prove_div_mod a b mod,\n    if mod then\n      return (ic, c', `(int_mod_neg).mk_app [a, b, c', p])\n    else do\n      (ic, c, p₂) ← prove_neg ic c',\n      return (ic, c, `(int_div_neg).mk_app [a, b, c', c, p, p₂])\n  | none := do\n    nb ← b.to_nat,\n    na ← a.to_int,\n    let nq := na / nb,\n    let nr := na % nb,\n    let nm := nq * nr,\n    (ic, q) ← ic.of_int nq,\n    (ic, r) ← ic.of_int nr,\n    (ic, m, pm) ← prove_mul_rat ic q b (rat.of_int nq) (rat.of_int nb),\n    (ic, p) ← prove_add_rat ic r m a (rat.of_int nr) (rat.of_int nm) (rat.of_int na),\n    (ic, p') ← prove_lt_nat ic r b,\n    if ic.α = `(nat) then\n      if mod then return (ic, r, `(nat_mod).mk_app [a, b, q, r, m, pm, p, p'])\n      else        return (ic, q, `(nat_div).mk_app [a, b, q, r, m, pm, p, p'])\n    else if ic.α = `(int) then do\n      (ic, p₀) ← prove_nonneg ic r,\n      if mod then return (ic, r, `(int_mod).mk_app [a, b, q, r, m, pm, p, p₀, p'])\n      else        return (ic, q, `(int_div).mk_app [a, b, q, r, m, pm, p, p₀, p'])\n    else failed\n  end\n\ntheorem dvd_eq_nat (a b c : ℕ) (p) (h₁ : b % a = c) (h₂ : (c = 0) = p) : (a ∣ b) = p :=\n(propext $ by rw [← h₁, nat.dvd_iff_mod_eq_zero]).trans h₂\ntheorem dvd_eq_int (a b c : ℤ) (p) (h₁ : b % a = c) (h₂ : (c = 0) = p) : (a ∣ b) = p :=\n(propext $ by rw [← h₁, int.dvd_iff_mod_eq_zero]).trans h₂\n\ntheorem int_to_nat_pos (a : ℤ) (b : ℕ) (h : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = a) :\n  a.to_nat = b := by rw ← h; simp\ntheorem int_to_nat_neg (a : ℤ) (h : 0 < a) : (-a).to_nat = 0 :=\nby simp only [int.to_nat_of_nonpos, h.le, neg_nonpos]\n\ntheorem nat_abs_pos (a : ℤ) (b : ℕ) (h : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = a) :\n  a.nat_abs = b := by rw ← h; simp\ntheorem nat_abs_neg (a : ℤ) (b : ℕ) (h : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = a) :\n  (-a).nat_abs = b := by rw ← h; simp\n\ntheorem neg_succ_of_nat (a b : ℕ) (c : ℤ) (h₁ : a + 1 = b)\n  (h₂ : (by haveI := @nat.cast_coe ℤ; exact b : ℤ) = c) :\n  -[1+ a] = -c := by rw [← h₂, ← h₁, int.nat_cast_eq_coe_nat]; refl\n\n/-- Evaluates some extra numeric operations on `nat` and `int`, specifically\n`nat.succ`, `/` and `%`, and `∣` (divisibility). -/\nmeta def eval_nat_int_ext : expr → tactic (expr × expr)\n| e@`(nat.succ _) := do\n  ic ← mk_instance_cache `(ℕ),\n  (_, _, ep) ← prove_nat_succ ic e,\n  return ep\n| `(%%a / %%b) := do\n  c ← infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b ff\n| `(%%a % %%b) := do\n  c ← infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b tt\n| `(%%a ∣ %%b) := do\n  α ← infer_type a,\n  ic ← mk_instance_cache α,\n  th ← if α = `(nat) then return (`(dvd_eq_nat):expr) else\n       if α = `(int) then return `(dvd_eq_int) else failed,\n  (ic, c, p₁) ← prove_div_mod ic b a tt,\n  (ic, z) ← ic.mk_app ``has_zero.zero [],\n  (e', p₂) ← mk_app ``eq [c, z] >>= eval_ineq,\n  return (e', th.mk_app [a, b, c, e', p₁, p₂])\n| `(int.to_nat %%a) := do\n  n ← a.to_int,\n  ic ← mk_instance_cache `(ℤ),\n  if n ≥ 0 then do\n    nc ← mk_instance_cache `(ℕ),\n    (_, _, b, p) ← prove_nat_uncast ic nc a,\n    pure (b, `(int_to_nat_pos).mk_app [a, b, p])\n  else do\n    a ← match_neg a,\n    (_, p) ← prove_pos ic a,\n    pure (`(0), `(int_to_nat_neg).mk_app [a, p])\n| `(int.nat_abs %%a) := do\n  n ← a.to_int,\n  ic ← mk_instance_cache `(ℤ),\n  nc ← mk_instance_cache `(ℕ),\n  if n ≥ 0 then do\n    (_, _, b, p) ← prove_nat_uncast ic nc a,\n    pure (b, `(nat_abs_pos).mk_app [a, b, p])\n  else do\n    a ← match_neg a,\n    (_, _, b, p) ← prove_nat_uncast ic nc a,\n    pure (b, `(nat_abs_neg).mk_app [a, b, p])\n| `(int.neg_succ_of_nat %%a) := do\n  na ← a.to_nat,\n  ic ← mk_instance_cache `(ℤ),\n  nc ← mk_instance_cache `(ℕ),\n  let nb := na + 1,\n  (nc, b) ← nc.of_nat nb,\n  (nc, p₁) ← prove_add_nat nc a `(1) b,\n  (ic, c) ← ic.of_nat nb,\n  (_, _, _, p₂) ← prove_nat_uncast ic nc c,\n  pure (`(-%%c : ℤ), `(neg_succ_of_nat).mk_app [a, b, c, p₁, p₂])\n| _ := failed\n\ntheorem int_to_nat_cast (a : ℕ) (b : ℤ)\n  (h : (by haveI := @nat.cast_coe ℤ; exact a : ℤ) = b) :\n  ↑a = b := eq.trans (by simp) h\n\n/-- Evaluates the `↑n` cast operation from `ℕ`, `ℤ`, `ℚ` to an arbitrary type `α`. -/\nmeta def eval_cast : expr → tactic (expr × expr)\n| `(@coe ℕ %%α %%inst %%a) := do\n  if inst.is_app_of ``coe_to_lift then\n    if inst.app_arg.is_app_of ``nat.cast_coe then do\n      n ← a.to_nat,\n      ic ← mk_instance_cache α,\n      nc ← mk_instance_cache `(ℕ),\n      (ic, b) ← ic.of_nat n,\n      (_, _, _, p) ← prove_nat_uncast ic nc b,\n      pure (b, p)\n    else if inst.app_arg.is_app_of ``int.cast_coe then do\n      n ← a.to_int,\n      ic ← mk_instance_cache α,\n      zc ← mk_instance_cache `(ℤ),\n      (ic, b) ← ic.of_int n,\n      (_, _, _, p) ← prove_int_uncast ic zc b,\n      pure (b, p)\n    else if inst.app_arg.is_app_of ``int.cast_coe then do\n      n ← a.to_rat,\n      cz_inst ← mk_mapp ``char_zero [α, none, none] >>= mk_instance,\n      ic ← mk_instance_cache α,\n      qc ← mk_instance_cache `(ℚ),\n        (ic, b) ← ic.of_rat n,\n      (_, _, _, p) ← prove_rat_uncast ic qc cz_inst b n,\n      pure (b, p)\n    else failed\n  else if inst = `(@coe_base nat int int.has_coe) then do\n    n ← a.to_nat,\n    ic ← mk_instance_cache `(ℤ),\n    nc ← mk_instance_cache `(ℕ),\n    (ic, b) ← ic.of_nat n,\n    (_, _, _, p) ← prove_nat_uncast ic nc b,\n    pure (b, `(int_to_nat_cast).mk_app [a, b, p])\n  else failed\n| _ := failed\n\n/-- This version of `derive` does not fail when the input is already a numeral -/\nmeta def derive.step (e : expr) : tactic (expr × expr) :=\neval_field e <|> eval_pow e <|> eval_ineq e <|> eval_cast e <|> eval_nat_int_ext e\n\n/-- An attribute for adding additional extensions to `norm_num`. To use this attribute, put\n`@[norm_num]` on a tactic of type `expr → tactic (expr × expr)`; the tactic will be called on\nsubterms by `norm_num`, and it is responsible for identifying that the expression is a numerical\nfunction applied to numerals, for example `nat.fib 17`, and should return the reduced numerical\nexpression (which must be in `norm_num`-normal form: a natural or rational numeral, i.e. `37`,\n`12 / 7` or `-(2 / 3)`, although this can be an expression in any type), and the proof that the\noriginal expression is equal to the rewritten expression.\n\nFailure is used to indicate that this tactic does not apply to the term. For performance reasons,\nit is best to detect non-applicability as soon as possible so that the next tactic can have a go,\nso generally it will start with a pattern match and then checking that the arguments to the term\nare numerals or of the appropriate form, followed by proof construction, which should not fail.\n\nPropositions are treated like any other term. The normal form for propositions is `true` or\n`false`, so it should produce a proof of the form `p = true` or `p = false`. `eq_true_intro` can be\nused to help here.\n-/\n@[user_attribute]\nprotected meta def attr : user_attribute (expr → tactic (expr × expr)) unit :=\n{ name      := `norm_num,\n  descr     := \"Add norm_num derivers\",\n  cache_cfg :=\n  { mk_cache := λ ns, do\n    { t ← ns.mfoldl\n        (λ (t : expr → tactic (expr × expr)) n, do\n          t' ← eval_expr (expr → tactic (expr × expr)) (expr.const n []),\n          pure (λ e, t' e <|> t e))\n        (λ _, failed),\n      pure (λ e, derive.step e <|> t e) },\n    dependencies := [] } }\n\nadd_tactic_doc\n{ name := \"norm_num\",\n  category := doc_category.attr,\n  decl_names := [`norm_num.attr],\n  tags := [\"arithmetic\", \"decision_procedure\"] }\n\n/-- Look up the `norm_num` extensions in the cache and return a tactic extending `derive.step` with\nadditional reduction procedures. -/\nmeta def get_step : tactic (expr → tactic (expr × expr)) := norm_num.attr.get_cache\n\n/-- Simplify an expression bottom-up using `step` to simplify the subexpressions. -/\nmeta def derive' (step : expr → tactic (expr × expr))\n  : expr → tactic (expr × expr) | e :=\ndo e ← instantiate_mvars e,\n   (_, e', pr) ←\n    ext_simplify_core () {} simp_lemmas.mk (λ _, failed) (λ _ _ _ _ _, failed)\n      (λ _ _ _ _ e,\n        do (new_e, pr) ← step e,\n           guard (¬ new_e =ₐ e),\n           return ((), new_e, some pr, tt))\n      `eq e,\n    return (e', pr)\n\n/-- Simplify an expression bottom-up using the default `norm_num` set to simplify the\nsubexpressions. -/\nmeta def derive (e : expr) : tactic (expr × expr) := do f ← get_step, derive' f e\n\nend norm_num\n\n/-- Basic version of `norm_num` that does not call `simp`. It uses the provided `step` tactic\nto simplify the expression; use `get_step` to get the default `norm_num` set and `derive.step` for\nthe basic builtin set of simplifications. -/\nmeta def tactic.norm_num1 (step : expr → tactic (expr × expr))\n  (loc : interactive.loc) : tactic unit :=\ndo ns ← loc.get_locals,\n   success ← tactic.replace_at (norm_num.derive' step) ns loc.include_goal,\n   when loc.include_goal $ try tactic.triv,\n   when (¬ ns.empty) $ try tactic.contradiction,\n   monad.unlessb success $ done <|> fail \"norm_num failed to simplify\"\n\n/-- Normalize numerical expressions. It uses the provided `step` tactic to simplify the expression;\nuse `get_step` to get the default `norm_num` set and `derive.step` for the basic builtin set of\nsimplifications. -/\nmeta def tactic.norm_num (step : expr → tactic (expr × expr))\n  (hs : list simp_arg_type) (l : interactive.loc) : tactic unit :=\nrepeat1 $ orelse' (tactic.norm_num1 step l) $\ninteractive.simp_core {} (tactic.norm_num1 step (interactive.loc.ns [none]))\n  ff (simp_arg_type.except ``one_div :: hs) [] l >> skip\n\nnamespace tactic.interactive\nopen norm_num interactive interactive.types\n\n/-- Basic version of `norm_num` that does not call `simp`. -/\nmeta def norm_num1 (loc : parse location) : tactic unit :=\ndo f ← get_step, tactic.norm_num1 f loc\n\n/-- Normalize numerical expressions. Supports the operations\n`+` `-` `*` `/` `^` and `%` over numerical types such as\n`ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ` and some general algebraic types,\nand can prove goals of the form `A = B`, `A ≠ B`, `A < B` and `A ≤ B`,\nwhere `A` and `B` are numerical expressions.\nIt also has a relatively simple primality prover. -/\nmeta def norm_num (hs : parse simp_arg_list) (l : parse location) : tactic unit :=\ndo f ← get_step, tactic.norm_num f hs l\n\nadd_hint_tactic \"norm_num\"\n\n/-- Normalizes a numerical expression and tries to close the goal with the result. -/\nmeta def apply_normed (x : parse texpr) : tactic unit :=\ndo x₁ ← to_expr x,\n  (x₂,_) ← derive x₁,\n  tactic.exact x₂\n\n/--\nNormalises numerical expressions. It supports the operations `+` `-` `*` `/` `^` and `%` over\nnumerical types such as `ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ`, and can prove goals of the form `A = B`, `A ≠ B`,\n`A < B` and `A ≤ B`, where `A` and `B` are numerical expressions.\n\nAdd-on tactics marked as `@[norm_num]` can extend the behavior of `norm_num` to include other\nfunctions. This is used to support several other functions on `nat` like `prime`, `min_fac` and\n`factors`.\n```lean\nimport data.real.basic\n\nexample : (2 : ℝ) + 2 = 4 := by norm_num\nexample : (12345.2 : ℝ) ≠ 12345.3 := by norm_num\nexample : (73 : ℝ) < 789/2 := by norm_num\nexample : 123456789 + 987654321 = 1111111110 := by norm_num\nexample (R : Type*) [ring R] : (2 : R) + 2 = 4 := by norm_num\nexample (F : Type*) [linear_ordered_field F] : (2 : F) + 2 < 5 := by norm_num\nexample : nat.prime (2^13 - 1) := by norm_num\nexample : ¬ nat.prime (2^11 - 1) := by norm_num\nexample (x : ℝ) (h : x = 123 + 456) : x = 579 := by norm_num at h; assumption\n```\n\nThe variant `norm_num1` does not call `simp`.\n\nBoth `norm_num` and `norm_num1` can be called inside the `conv` tactic.\n\nThe tactic `apply_normed` normalises a numerical expression and tries to close the goal with\nthe result. Compare:\n```lean\ndef a : ℕ := 2^100\n#print a -- 2 ^ 100\n\ndef normed_a : ℕ := by apply_normed 2^100\n#print normed_a -- 1267650600228229401496703205376\n```\n-/\nadd_tactic_doc\n{ name        := \"norm_num\",\n  category    := doc_category.tactic,\n  decl_names  := [`tactic.interactive.norm_num1, `tactic.interactive.norm_num,\n                  `tactic.interactive.apply_normed],\n  tags        := [\"arithmetic\", \"decision procedure\"] }\n\nend tactic.interactive\n\nnamespace conv.interactive\nopen conv interactive tactic.interactive\nopen norm_num (derive)\n\n/-- Basic version of `norm_num` that does not call `simp`. -/\nmeta def norm_num1 : conv unit := replace_lhs derive\n\n/-- Normalize numerical expressions. Supports the operations\n`+` `-` `*` `/` `^` and `%` over numerical types such as\n`ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ` and some general algebraic types,\nand can prove goals of the form `A = B`, `A ≠ B`, `A < B` and `A ≤ B`,\nwhere `A` and `B` are numerical expressions.\nIt also has a relatively simple primality prover. -/\nmeta def norm_num (hs : parse simp_arg_list) : conv unit :=\nrepeat1 $ orelse' norm_num1 $\nconv.interactive.simp ff (simp_arg_type.except ``one_div :: hs) []\n  { discharger := tactic.interactive.norm_num1 (loc.ns [none]) }\n\nend conv.interactive\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/tactic/norm_num.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676284, "lm_q2_score": 0.6442251133170356, "lm_q1q2_score": 0.4863351929595263}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Chris Hughes, Mario Carneiro, Yury Kudryashov\n\n! This file was ported from Lean 3 source module algebra.ring.prod\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Int.Cast.Prod\nimport Mathbin.Algebra.Group.Prod\nimport Mathbin.Algebra.Ring.Equiv\nimport Mathbin.Algebra.Order.Monoid.Prod\n\n/-!\n# Semiring, ring etc structures on `R × S`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we define two-binop (`semiring`, `ring` etc) structures on `R × S`. We also prove\ntrivial `simp` lemmas, and define the following operations on `ring_hom`s and similarly for\n`non_unital_ring_hom`s:\n\n* `fst R S : R × S →+* R`, `snd R S : R × S →+* S`: projections `prod.fst` and `prod.snd`\n  as `ring_hom`s;\n* `f.prod g : `R →+* S × T`: sends `x` to `(f x, g x)`;\n* `f.prod_map g : `R × S → R' × S'`: `prod.map f g` as a `ring_hom`,\n  sends `(x, y)` to `(f x, g y)`.\n-/\n\n\nvariable {α β R R' S S' T T' : Type _}\n\nnamespace Prod\n\n/-- Product of two distributive types is distributive. -/\ninstance [Distrib R] [Distrib S] : Distrib (R × S) :=\n  { Prod.hasAdd,\n    Prod.hasMul with\n    left_distrib := fun a b c => mk.inj_iff.mpr ⟨left_distrib _ _ _, left_distrib _ _ _⟩\n    right_distrib := fun a b c => mk.inj_iff.mpr ⟨right_distrib _ _ _, right_distrib _ _ _⟩ }\n\n/-- Product of two `non_unital_non_assoc_semiring`s is a `non_unital_non_assoc_semiring`. -/\ninstance [NonUnitalNonAssocSemiring R] [NonUnitalNonAssocSemiring S] :\n    NonUnitalNonAssocSemiring (R × S) :=\n  { Prod.addCommMonoid, Prod.mulZeroClass, Prod.distrib with }\n\n/-- Product of two `non_unital_semiring`s is a `non_unital_semiring`. -/\ninstance [NonUnitalSemiring R] [NonUnitalSemiring S] : NonUnitalSemiring (R × S) :=\n  { Prod.nonUnitalNonAssocSemiring, Prod.semigroup with }\n\n/-- Product of two `non_assoc_semiring`s is a `non_assoc_semiring`. -/\ninstance [NonAssocSemiring R] [NonAssocSemiring S] : NonAssocSemiring (R × S) :=\n  { Prod.nonUnitalNonAssocSemiring, Prod.mulOneClass, Prod.addMonoidWithOne with }\n\n/-- Product of two semirings is a semiring. -/\ninstance [Semiring R] [Semiring S] : Semiring (R × S) :=\n  { Prod.addCommMonoid, Prod.monoidWithZero, Prod.distrib, Prod.addMonoidWithOne with }\n\n/-- Product of two `non_unital_comm_semiring`s is a `non_unital_comm_semiring`. -/\ninstance [NonUnitalCommSemiring R] [NonUnitalCommSemiring S] : NonUnitalCommSemiring (R × S) :=\n  { Prod.nonUnitalSemiring, Prod.commSemigroup with }\n\n/-- Product of two commutative semirings is a commutative semiring. -/\ninstance [CommSemiring R] [CommSemiring S] : CommSemiring (R × S) :=\n  { Prod.semiring, Prod.commMonoid with }\n\ninstance [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] : NonUnitalNonAssocRing (R × S) :=\n  { Prod.addCommGroup, Prod.nonUnitalNonAssocSemiring with }\n\ninstance [NonUnitalRing R] [NonUnitalRing S] : NonUnitalRing (R × S) :=\n  { Prod.addCommGroup, Prod.nonUnitalSemiring with }\n\ninstance [NonAssocRing R] [NonAssocRing S] : NonAssocRing (R × S) :=\n  { Prod.addCommGroup, Prod.nonAssocSemiring, Prod.addGroupWithOne with }\n\n/-- Product of two rings is a ring. -/\ninstance [Ring R] [Ring S] : Ring (R × S) :=\n  { Prod.addCommGroup, Prod.addGroupWithOne, Prod.semiring with }\n\n/-- Product of two `non_unital_comm_ring`s is a `non_unital_comm_ring`. -/\ninstance [NonUnitalCommRing R] [NonUnitalCommRing S] : NonUnitalCommRing (R × S) :=\n  { Prod.nonUnitalRing, Prod.commSemigroup with }\n\n/-- Product of two commutative rings is a commutative ring. -/\ninstance [CommRing R] [CommRing S] : CommRing (R × S) :=\n  { Prod.ring, Prod.commMonoid with }\n\nend Prod\n\nnamespace NonUnitalRingHom\n\nvariable (R S) [NonUnitalNonAssocSemiring R] [NonUnitalNonAssocSemiring S]\n\n/- warning: non_unital_ring_hom.fst -> NonUnitalRingHom.fst is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S], NonUnitalRingHom.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S], NonUnitalRingHom.{max u2 u1, u1} (Prod.{u1, u2} R S) R (Prod.instNonUnitalNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_1\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.fst NonUnitalRingHom.fstₓ'. -/\n/-- Given non-unital semirings `R`, `S`, the natural projection homomorphism from `R × S` to `R`.-/\ndef fst : R × S →ₙ+* R :=\n  { MulHom.fst R S, AddMonoidHom.fst R S with toFun := Prod.fst }\n#align non_unital_ring_hom.fst NonUnitalRingHom.fst\n\n/- warning: non_unital_ring_hom.snd -> NonUnitalRingHom.snd is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S], NonUnitalRingHom.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S], NonUnitalRingHom.{max u2 u1, u2} (Prod.{u1, u2} R S) S (Prod.instNonUnitalNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_2\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.snd NonUnitalRingHom.sndₓ'. -/\n/-- Given non-unital semirings `R`, `S`, the natural projection homomorphism from `R × S` to `S`.-/\ndef snd : R × S →ₙ+* S :=\n  { MulHom.snd R S, AddMonoidHom.snd R S with toFun := Prod.snd }\n#align non_unital_ring_hom.snd NonUnitalRingHom.snd\n\nvariable {R S}\n\n/- warning: non_unital_ring_hom.coe_fst -> NonUnitalRingHom.coe_fst is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S], Eq.{max (succ (max u1 u2)) (succ u1)} ((Prod.{u1, u2} R S) -> R) (coeFn.{max (succ (max u1 u2)) (succ u1), max (succ (max u1 u2)) (succ u1)} (NonUnitalRingHom.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1) (fun (_x : NonUnitalRingHom.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1) => (Prod.{u1, u2} R S) -> R) (NonUnitalRingHom.hasCoeToFun.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1) (NonUnitalRingHom.fst.{u1, u2} R S _inst_1 _inst_2)) (Prod.fst.{u1, u2} R S)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u2} R] [_inst_2 : NonUnitalNonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (forall (ᾰ : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => R) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), succ u2} (NonUnitalRingHom.{max u1 u2, u2} (Prod.{u2, u1} R S) R (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (Prod.{u2, u1} R S) (fun (_x : Prod.{u2, u1} R S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => R) _x) (MulHomClass.toFunLike.{max u2 u1, max u2 u1, u2} (NonUnitalRingHom.{max u1 u2, u2} (Prod.{u2, u1} R S) R (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (Prod.{u2, u1} R S) R (NonUnitalNonAssocSemiring.toMul.{max u2 u1} (Prod.{u2, u1} R S) (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R _inst_1) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, max u2 u1, u2} (NonUnitalRingHom.{max u1 u2, u2} (Prod.{u2, u1} R S) R (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (Prod.{u2, u1} R S) R (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{max u2 u1, u2} (Prod.{u2, u1} R S) R (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1))) (NonUnitalRingHom.fst.{u2, u1} R S _inst_1 _inst_2)) (Prod.fst.{u2, u1} R S)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_fst NonUnitalRingHom.coe_fstₓ'. -/\n@[simp]\ntheorem coe_fst : ⇑(fst R S) = Prod.fst :=\n  rfl\n#align non_unital_ring_hom.coe_fst NonUnitalRingHom.coe_fst\n\n/- warning: non_unital_ring_hom.coe_snd -> NonUnitalRingHom.coe_snd is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S], Eq.{max (succ (max u1 u2)) (succ u2)} ((Prod.{u1, u2} R S) -> S) (coeFn.{max (succ (max u1 u2)) (succ u2), max (succ (max u1 u2)) (succ u2)} (NonUnitalRingHom.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2) (fun (_x : NonUnitalRingHom.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2) => (Prod.{u1, u2} R S) -> S) (NonUnitalRingHom.hasCoeToFun.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonUnitalNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2) (NonUnitalRingHom.snd.{u1, u2} R S _inst_1 _inst_2)) (Prod.snd.{u1, u2} R S)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u2} R] [_inst_2 : NonUnitalNonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (forall (ᾰ : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => S) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), succ u1} (NonUnitalRingHom.{max u1 u2, u1} (Prod.{u2, u1} R S) S (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (Prod.{u2, u1} R S) (fun (_x : Prod.{u2, u1} R S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => S) _x) (MulHomClass.toFunLike.{max u2 u1, max u2 u1, u1} (NonUnitalRingHom.{max u1 u2, u1} (Prod.{u2, u1} R S) S (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (Prod.{u2, u1} R S) S (NonUnitalNonAssocSemiring.toMul.{max u2 u1} (Prod.{u2, u1} R S) (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} S _inst_2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, max u2 u1, u1} (NonUnitalRingHom.{max u1 u2, u1} (Prod.{u2, u1} R S) S (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (Prod.{u2, u1} R S) S (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{max u2 u1, u1} (Prod.{u2, u1} R S) S (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2))) (NonUnitalRingHom.snd.{u2, u1} R S _inst_1 _inst_2)) (Prod.snd.{u2, u1} R S)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_snd NonUnitalRingHom.coe_sndₓ'. -/\n@[simp]\ntheorem coe_snd : ⇑(snd R S) = Prod.snd :=\n  rfl\n#align non_unital_ring_hom.coe_snd NonUnitalRingHom.coe_snd\n\nsection Prod\n\nvariable [NonUnitalNonAssocSemiring T] (f : R →ₙ+* S) (g : R →ₙ+* T)\n\n/- warning: non_unital_ring_hom.prod -> NonUnitalRingHom.prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} T], (NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) -> (NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3) -> (NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} T], (NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) -> (NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3) -> (NonUnitalRingHom.{u1, max u3 u2} R (Prod.{u2, u3} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u2, u3} S T _inst_2 _inst_3))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.prod NonUnitalRingHom.prodₓ'. -/\n/-- Combine two non-unital ring homomorphisms `f : R →ₙ+* S`, `g : R →ₙ+* T` into\n`f.prod g : R →ₙ+* S × T` given by `(f.prod g) x = (f x, g x)` -/\nprotected def prod (f : R →ₙ+* S) (g : R →ₙ+* T) : R →ₙ+* S × T :=\n  { MulHom.prod (f : MulHom R S) (g : MulHom R T), AddMonoidHom.prod (f : R →+ S) (g : R →+ T) with\n    toFun := fun x => (f x, g x) }\n#align non_unital_ring_hom.prod NonUnitalRingHom.prod\n\n/- warning: non_unital_ring_hom.prod_apply -> NonUnitalRingHom.prod_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} T] (f : NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) (g : NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3) (x : R), Eq.{max (succ u2) (succ u3)} (Prod.{u2, u3} S T) (coeFn.{max (succ u1) (succ (max u2 u3)), max (succ u1) (succ (max u2 u3))} (NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) (fun (_x : NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) => R -> (Prod.{u2, u3} S T)) (NonUnitalRingHom.hasCoeToFun.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) (NonUnitalRingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 f g) x) (Prod.mk.{u2, u3} S T (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (NonUnitalRingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3) (fun (_x : NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3) => R -> T) (NonUnitalRingHom.hasCoeToFun.{u1, u3} R T _inst_1 _inst_3) g x))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u3}} {T : Type.{u2}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u3} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} T] (f : NonUnitalRingHom.{u1, u3} R S _inst_1 _inst_2) (g : NonUnitalRingHom.{u1, u2} R T _inst_1 _inst_3) (x : R), Eq.{max (succ u3) (succ u2)} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Prod.{u3, u2} S T) x) (FunLike.coe.{max (max (succ u1) (succ u3)) (succ u2), succ u1, max (succ u3) (succ u2)} (NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Prod.{u3, u2} S T) _x) (MulHomClass.toFunLike.{max (max u1 u3) u2, u1, max u3 u2} (NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) R (Prod.{u3, u2} S T) (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{max u3 u2} (Prod.{u3, u2} S T) (Prod.instNonUnitalNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) (NonUnitalRingHomClass.toMulHomClass.{max (max u1 u3) u2, u1, max u3 u2} (NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3) (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, max u3 u2} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)))) (NonUnitalRingHom.prod.{u1, u3, u2} R S T _inst_1 _inst_2 _inst_3 f g) x) (Prod.mk.{u3, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => T) x) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u3} S _inst_2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} R S _inst_1 _inst_2))) f x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} R T _inst_1 _inst_3) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => T) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} R T _inst_1 _inst_3) R T (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u2} T _inst_3) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} R T _inst_1 _inst_3) R T _inst_1 _inst_3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} R T _inst_1 _inst_3))) g x))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.prod_apply NonUnitalRingHom.prod_applyₓ'. -/\n@[simp]\ntheorem prod_apply (x) : f.Prod g x = (f x, g x) :=\n  rfl\n#align non_unital_ring_hom.prod_apply NonUnitalRingHom.prod_apply\n\n/- warning: non_unital_ring_hom.fst_comp_prod -> NonUnitalRingHom.fst_comp_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} T] (f : NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) (g : NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) (NonUnitalRingHom.comp.{u1, max u2 u3, u2} R (Prod.{u2, u3} S T) S _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_2 (NonUnitalRingHom.fst.{u2, u3} S T _inst_2 _inst_3) (NonUnitalRingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 f g)) f\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u2}} {T : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u3} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u1} T] (f : NonUnitalRingHom.{u3, u2} R S _inst_1 _inst_2) (g : NonUnitalRingHom.{u3, u1} R T _inst_1 _inst_3), Eq.{max (succ u3) (succ u2)} (NonUnitalRingHom.{u3, u2} R S _inst_1 _inst_2) (NonUnitalRingHom.comp.{u3, max u2 u1, u2} R (Prod.{u2, u1} S T) S _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} S T _inst_2 _inst_3) _inst_2 (NonUnitalRingHom.fst.{u2, u1} S T _inst_2 _inst_3) (NonUnitalRingHom.prod.{u3, u2, u1} R S T _inst_1 _inst_2 _inst_3 f g)) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.fst_comp_prod NonUnitalRingHom.fst_comp_prodₓ'. -/\n@[simp]\ntheorem fst_comp_prod : (fst S T).comp (f.Prod g) = f :=\n  ext fun x => rfl\n#align non_unital_ring_hom.fst_comp_prod NonUnitalRingHom.fst_comp_prod\n\n/- warning: non_unital_ring_hom.snd_comp_prod -> NonUnitalRingHom.snd_comp_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} T] (f : NonUnitalRingHom.{u1, u2} R S _inst_1 _inst_2) (g : NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3), Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} R T _inst_1 _inst_3) (NonUnitalRingHom.comp.{u1, max u2 u3, u3} R (Prod.{u2, u3} S T) T _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_3 (NonUnitalRingHom.snd.{u2, u3} S T _inst_2 _inst_3) (NonUnitalRingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 f g)) g\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u1}} {T : Type.{u2}} [_inst_1 : NonUnitalNonAssocSemiring.{u3} R] [_inst_2 : NonUnitalNonAssocSemiring.{u1} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} T] (f : NonUnitalRingHom.{u3, u1} R S _inst_1 _inst_2) (g : NonUnitalRingHom.{u3, u2} R T _inst_1 _inst_3), Eq.{max (succ u3) (succ u2)} (NonUnitalRingHom.{u3, u2} R T _inst_1 _inst_3) (NonUnitalRingHom.comp.{u3, max u1 u2, u2} R (Prod.{u1, u2} S T) T _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3) _inst_3 (NonUnitalRingHom.snd.{u1, u2} S T _inst_2 _inst_3) (NonUnitalRingHom.prod.{u3, u1, u2} R S T _inst_1 _inst_2 _inst_3 f g)) g\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.snd_comp_prod NonUnitalRingHom.snd_comp_prodₓ'. -/\n@[simp]\ntheorem snd_comp_prod : (snd S T).comp (f.Prod g) = g :=\n  ext fun x => rfl\n#align non_unital_ring_hom.snd_comp_prod NonUnitalRingHom.snd_comp_prod\n\n/- warning: non_unital_ring_hom.prod_unique -> NonUnitalRingHom.prod_unique is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} T] (f : NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)), Eq.{max (succ u1) (succ (max u2 u3))} (NonUnitalRingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) (NonUnitalRingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 (NonUnitalRingHom.comp.{u1, max u2 u3, u2} R (Prod.{u2, u3} S T) S _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_2 (NonUnitalRingHom.fst.{u2, u3} S T _inst_2 _inst_3) f) (NonUnitalRingHom.comp.{u1, max u2 u3, u3} R (Prod.{u2, u3} S T) T _inst_1 (Prod.nonUnitalNonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_3 (NonUnitalRingHom.snd.{u2, u3} S T _inst_2 _inst_3) f)) f\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u1}} {T : Type.{u2}} [_inst_1 : NonUnitalNonAssocSemiring.{u3} R] [_inst_2 : NonUnitalNonAssocSemiring.{u1} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} T] (f : NonUnitalRingHom.{u3, max u2 u1} R (Prod.{u1, u2} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3)), Eq.{max (max (succ u3) (succ u1)) (succ u2)} (NonUnitalRingHom.{u3, max u2 u1} R (Prod.{u1, u2} S T) _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3)) (NonUnitalRingHom.prod.{u3, u1, u2} R S T _inst_1 _inst_2 _inst_3 (NonUnitalRingHom.comp.{u3, max u1 u2, u1} R (Prod.{u1, u2} S T) S _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3) _inst_2 (NonUnitalRingHom.fst.{u1, u2} S T _inst_2 _inst_3) f) (NonUnitalRingHom.comp.{u3, max u1 u2, u2} R (Prod.{u1, u2} S T) T _inst_1 (Prod.instNonUnitalNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3) _inst_3 (NonUnitalRingHom.snd.{u1, u2} S T _inst_2 _inst_3) f)) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.prod_unique NonUnitalRingHom.prod_uniqueₓ'. -/\ntheorem prod_unique (f : R →ₙ+* S × T) : ((fst S T).comp f).Prod ((snd S T).comp f) = f :=\n  ext fun x => by simp only [prod_apply, coe_fst, coe_snd, comp_apply, Prod.mk.eta]\n#align non_unital_ring_hom.prod_unique NonUnitalRingHom.prod_unique\n\nend Prod\n\nsection Prod_map\n\nvariable [NonUnitalNonAssocSemiring R'] [NonUnitalNonAssocSemiring S'] [NonUnitalNonAssocSemiring T]\n\nvariable (f : R →ₙ+* R') (g : S →ₙ+* S')\n\n/- warning: non_unital_ring_hom.prod_map -> NonUnitalRingHom.prodMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u3} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u4} S'], (NonUnitalRingHom.{u1, u2} R R' _inst_1 _inst_3) -> (NonUnitalRingHom.{u3, u4} S S' _inst_2 _inst_4) -> (NonUnitalRingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonUnitalNonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4))\nbut is expected to have type\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u3} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u4} S'], (NonUnitalRingHom.{u1, u2} R R' _inst_1 _inst_3) -> (NonUnitalRingHom.{u3, u4} S S' _inst_2 _inst_4) -> (NonUnitalRingHom.{max u3 u1, max u4 u2} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u1, u3} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u2, u4} R' S' _inst_3 _inst_4))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.prod_map NonUnitalRingHom.prodMapₓ'. -/\n/-- `prod.map` as a `non_unital_ring_hom`. -/\ndef prodMap : R × S →ₙ+* R' × S' :=\n  (f.comp (fst R S)).Prod (g.comp (snd R S))\n#align non_unital_ring_hom.prod_map NonUnitalRingHom.prodMap\n\n/- warning: non_unital_ring_hom.prod_map_def -> NonUnitalRingHom.prodMap_def is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u3} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u4} S'] (f : NonUnitalRingHom.{u1, u2} R R' _inst_1 _inst_3) (g : NonUnitalRingHom.{u3, u4} S S' _inst_2 _inst_4), Eq.{max (succ (max u1 u3)) (succ (max u2 u4))} (NonUnitalRingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonUnitalNonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (NonUnitalRingHom.prodMap.{u1, u2, u3, u4} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g) (NonUnitalRingHom.prod.{max u1 u3, u2, u4} (Prod.{u1, u3} R S) R' S' (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) _inst_3 _inst_4 (NonUnitalRingHom.comp.{max u1 u3, u1, u2} (Prod.{u1, u3} R S) R R' (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) _inst_1 _inst_3 f (NonUnitalRingHom.fst.{u1, u3} R S _inst_1 _inst_2)) (NonUnitalRingHom.comp.{max u1 u3, u3, u4} (Prod.{u1, u3} R S) S S' (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) _inst_2 _inst_4 g (NonUnitalRingHom.snd.{u1, u3} R S _inst_1 _inst_2)))\nbut is expected to have type\n  forall {R : Type.{u4}} {R' : Type.{u3}} {S : Type.{u2}} {S' : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u4} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u1} S'] (f : NonUnitalRingHom.{u4, u3} R R' _inst_1 _inst_3) (g : NonUnitalRingHom.{u2, u1} S S' _inst_2 _inst_4), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (NonUnitalRingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (NonUnitalRingHom.prodMap.{u4, u3, u2, u1} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g) (NonUnitalRingHom.prod.{max u4 u2, u3, u1} (Prod.{u4, u2} R S) R' S' (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) _inst_3 _inst_4 (NonUnitalRingHom.comp.{max u4 u2, u4, u3} (Prod.{u4, u2} R S) R R' (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) _inst_1 _inst_3 f (NonUnitalRingHom.fst.{u4, u2} R S _inst_1 _inst_2)) (NonUnitalRingHom.comp.{max u4 u2, u2, u1} (Prod.{u4, u2} R S) S S' (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) _inst_2 _inst_4 g (NonUnitalRingHom.snd.{u4, u2} R S _inst_1 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.prod_map_def NonUnitalRingHom.prodMap_defₓ'. -/\ntheorem prodMap_def : prodMap f g = (f.comp (fst R S)).Prod (g.comp (snd R S)) :=\n  rfl\n#align non_unital_ring_hom.prod_map_def NonUnitalRingHom.prodMap_def\n\n/- warning: non_unital_ring_hom.coe_prod_map -> NonUnitalRingHom.coe_prodMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u3} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u4} S'] (f : NonUnitalRingHom.{u1, u2} R R' _inst_1 _inst_3) (g : NonUnitalRingHom.{u3, u4} S S' _inst_2 _inst_4), Eq.{max (succ (max u1 u3)) (succ (max u2 u4))} ((Prod.{u1, u3} R S) -> (Prod.{u2, u4} R' S')) (coeFn.{max (succ (max u1 u3)) (succ (max u2 u4)), max (succ (max u1 u3)) (succ (max u2 u4))} (NonUnitalRingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonUnitalNonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (fun (_x : NonUnitalRingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonUnitalNonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) => (Prod.{u1, u3} R S) -> (Prod.{u2, u4} R' S')) (NonUnitalRingHom.hasCoeToFun.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonUnitalNonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (NonUnitalRingHom.prodMap.{u1, u2, u3, u4} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g)) (Prod.map.{u1, u2, u3, u4} R R' S S' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} R R' _inst_1 _inst_3) (fun (_x : NonUnitalRingHom.{u1, u2} R R' _inst_1 _inst_3) => R -> R') (NonUnitalRingHom.hasCoeToFun.{u1, u2} R R' _inst_1 _inst_3) f) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (NonUnitalRingHom.{u3, u4} S S' _inst_2 _inst_4) (fun (_x : NonUnitalRingHom.{u3, u4} S S' _inst_2 _inst_4) => S -> S') (NonUnitalRingHom.hasCoeToFun.{u3, u4} S S' _inst_2 _inst_4) g))\nbut is expected to have type\n  forall {R : Type.{u4}} {R' : Type.{u3}} {S : Type.{u2}} {S' : Type.{u1}} [_inst_1 : NonUnitalNonAssocSemiring.{u4} R] [_inst_2 : NonUnitalNonAssocSemiring.{u2} S] [_inst_3 : NonUnitalNonAssocSemiring.{u3} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u1} S'] (f : NonUnitalRingHom.{u4, u3} R R' _inst_1 _inst_3) (g : NonUnitalRingHom.{u2, u1} S S' _inst_2 _inst_4), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (forall (ᾰ : Prod.{u4, u2} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u4, u2} R S) => Prod.{u3, u1} R' S') ᾰ) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), max (succ u4) (succ u2), max (succ u3) (succ u1)} (NonUnitalRingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (Prod.{u4, u2} R S) (fun (_x : Prod.{u4, u2} R S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u4, u2} R S) => Prod.{u3, u1} R' S') _x) (MulHomClass.toFunLike.{max (max (max u4 u3) u2) u1, max u4 u2, max u3 u1} (NonUnitalRingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (NonUnitalNonAssocSemiring.toMul.{max u4 u2} (Prod.{u4, u2} R S) (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2)) (NonUnitalNonAssocSemiring.toMul.{max u3 u1} (Prod.{u3, u1} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (NonUnitalRingHomClass.toMulHomClass.{max (max (max u4 u3) u2) u1, max u4 u2, max u3 u1} (NonUnitalRingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4) (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{max u4 u2, max u3 u1} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonUnitalNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)))) (NonUnitalRingHom.prodMap.{u4, u3, u2, u1} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g)) (Prod.map.{u4, u3, u2, u1} R R' S S' (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (NonUnitalRingHom.{u4, u3} R R' _inst_1 _inst_3) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R') _x) (MulHomClass.toFunLike.{max u4 u3, u4, u3} (NonUnitalRingHom.{u4, u3} R R' _inst_1 _inst_3) R R' (NonUnitalNonAssocSemiring.toMul.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u3} R' _inst_3) (NonUnitalRingHomClass.toMulHomClass.{max u4 u3, u4, u3} (NonUnitalRingHom.{u4, u3} R R' _inst_1 _inst_3) R R' _inst_1 _inst_3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u4, u3} R R' _inst_1 _inst_3))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} S S' _inst_2 _inst_4) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S') _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} S S' _inst_2 _inst_4) S S' (NonUnitalNonAssocSemiring.toMul.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} S' _inst_4) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} S S' _inst_2 _inst_4) S S' _inst_2 _inst_4 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} S S' _inst_2 _inst_4))) g))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_prod_map NonUnitalRingHom.coe_prodMapₓ'. -/\n@[simp]\ntheorem coe_prodMap : ⇑(prodMap f g) = Prod.map f g :=\n  rfl\n#align non_unital_ring_hom.coe_prod_map NonUnitalRingHom.coe_prodMap\n\n/- warning: non_unital_ring_hom.prod_comp_prod_map -> NonUnitalRingHom.prod_comp_prodMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} {T : Type.{u5}} [_inst_1 : NonUnitalNonAssocSemiring.{u1} R] [_inst_2 : NonUnitalNonAssocSemiring.{u3} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u4} S'] [_inst_5 : NonUnitalNonAssocSemiring.{u5} T] (f : NonUnitalRingHom.{u5, u1} T R _inst_5 _inst_1) (g : NonUnitalRingHom.{u5, u3} T S _inst_5 _inst_2) (f' : NonUnitalRingHom.{u1, u2} R R' _inst_1 _inst_3) (g' : NonUnitalRingHom.{u3, u4} S S' _inst_2 _inst_4), Eq.{max (succ u5) (succ (max u2 u4))} (NonUnitalRingHom.{u5, max u2 u4} T (Prod.{u2, u4} R' S') _inst_5 (Prod.nonUnitalNonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (NonUnitalRingHom.comp.{u5, max u1 u3, max u2 u4} T (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') _inst_5 (Prod.nonUnitalNonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonUnitalNonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4) (NonUnitalRingHom.prodMap.{u1, u2, u3, u4} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f' g') (NonUnitalRingHom.prod.{u5, u1, u3} T R S _inst_5 _inst_1 _inst_2 f g)) (NonUnitalRingHom.prod.{u5, u2, u4} T R' S' _inst_5 _inst_3 _inst_4 (NonUnitalRingHom.comp.{u5, u1, u2} T R R' _inst_5 _inst_1 _inst_3 f' f) (NonUnitalRingHom.comp.{u5, u3, u4} T S S' _inst_5 _inst_2 _inst_4 g' g))\nbut is expected to have type\n  forall {R : Type.{u4}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u1}} {T : Type.{u5}} [_inst_1 : NonUnitalNonAssocSemiring.{u4} R] [_inst_2 : NonUnitalNonAssocSemiring.{u3} S] [_inst_3 : NonUnitalNonAssocSemiring.{u2} R'] [_inst_4 : NonUnitalNonAssocSemiring.{u1} S'] [_inst_5 : NonUnitalNonAssocSemiring.{u5} T] (f : NonUnitalRingHom.{u5, u4} T R _inst_5 _inst_1) (g : NonUnitalRingHom.{u5, u3} T S _inst_5 _inst_2) (f' : NonUnitalRingHom.{u4, u2} R R' _inst_1 _inst_3) (g' : NonUnitalRingHom.{u3, u1} S S' _inst_2 _inst_4), Eq.{max (max (succ u2) (succ u1)) (succ u5)} (NonUnitalRingHom.{u5, max u2 u1} T (Prod.{u2, u1} R' S') _inst_5 (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R' S' _inst_3 _inst_4)) (NonUnitalRingHom.comp.{u5, max u4 u3, max u2 u1} T (Prod.{u4, u3} R S) (Prod.{u2, u1} R' S') _inst_5 (Prod.instNonUnitalNonAssocSemiringProd.{u4, u3} R S _inst_1 _inst_2) (Prod.instNonUnitalNonAssocSemiringProd.{u2, u1} R' S' _inst_3 _inst_4) (NonUnitalRingHom.prodMap.{u4, u2, u3, u1} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f' g') (NonUnitalRingHom.prod.{u5, u4, u3} T R S _inst_5 _inst_1 _inst_2 f g)) (NonUnitalRingHom.prod.{u5, u2, u1} T R' S' _inst_5 _inst_3 _inst_4 (NonUnitalRingHom.comp.{u5, u4, u2} T R R' _inst_5 _inst_1 _inst_3 f' f) (NonUnitalRingHom.comp.{u5, u3, u1} T S S' _inst_5 _inst_2 _inst_4 g' g))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.prod_comp_prod_map NonUnitalRingHom.prod_comp_prodMapₓ'. -/\ntheorem prod_comp_prodMap (f : T →ₙ+* R) (g : T →ₙ+* S) (f' : R →ₙ+* R') (g' : S →ₙ+* S') :\n    (f'.Prod_map g').comp (f.Prod g) = (f'.comp f).Prod (g'.comp g) :=\n  rfl\n#align non_unital_ring_hom.prod_comp_prod_map NonUnitalRingHom.prod_comp_prodMap\n\nend Prod_map\n\nend NonUnitalRingHom\n\nnamespace RingHom\n\nvariable (R S) [NonAssocSemiring R] [NonAssocSemiring S]\n\n/- warning: ring_hom.fst -> RingHom.fst is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], RingHom.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], RingHom.{max u2 u1, u1} (Prod.{u1, u2} R S) R (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_1\nCase conversion may be inaccurate. Consider using '#align ring_hom.fst RingHom.fstₓ'. -/\n/-- Given semirings `R`, `S`, the natural projection homomorphism from `R × S` to `R`.-/\ndef fst : R × S →+* R :=\n  { MonoidHom.fst R S, AddMonoidHom.fst R S with toFun := Prod.fst }\n#align ring_hom.fst RingHom.fst\n\n/- warning: ring_hom.snd -> RingHom.snd is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], RingHom.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], RingHom.{max u2 u1, u2} (Prod.{u1, u2} R S) S (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_2\nCase conversion may be inaccurate. Consider using '#align ring_hom.snd RingHom.sndₓ'. -/\n/-- Given semirings `R`, `S`, the natural projection homomorphism from `R × S` to `S`.-/\ndef snd : R × S →+* S :=\n  { MonoidHom.snd R S, AddMonoidHom.snd R S with toFun := Prod.snd }\n#align ring_hom.snd RingHom.snd\n\nvariable {R S}\n\n/- warning: ring_hom.coe_fst -> RingHom.coe_fst is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{max (succ (max u1 u2)) (succ u1)} ((Prod.{u1, u2} R S) -> R) (coeFn.{max (succ (max u1 u2)) (succ u1), max (succ (max u1 u2)) (succ u1)} (RingHom.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1) (fun (_x : RingHom.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1) => (Prod.{u1, u2} R S) -> R) (RingHom.hasCoeToFun.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1) (RingHom.fst.{u1, u2} R S _inst_1 _inst_2)) (Prod.fst.{u1, u2} R S)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (forall (ᾰ : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => R) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), succ u2} (RingHom.{max u1 u2, u2} (Prod.{u2, u1} R S) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (Prod.{u2, u1} R S) (fun (_x : Prod.{u2, u1} R S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => R) _x) (MulHomClass.toFunLike.{max u2 u1, max u2 u1, u2} (RingHom.{max u1 u2, u2} (Prod.{u2, u1} R S) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (Prod.{u2, u1} R S) R (NonUnitalNonAssocSemiring.toMul.{max u2 u1} (Prod.{u2, u1} R S) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} R S) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, max u2 u1, u2} (RingHom.{max u1 u2, u2} (Prod.{u2, u1} R S) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (Prod.{u2, u1} R S) R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} R S) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, max u2 u1, u2} (RingHom.{max u1 u2, u2} (Prod.{u2, u1} R S) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (Prod.{u2, u1} R S) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1 (RingHom.instRingHomClassRingHom.{max u2 u1, u2} (Prod.{u2, u1} R S) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1)))) (RingHom.fst.{u2, u1} R S _inst_1 _inst_2)) (Prod.fst.{u2, u1} R S)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_fst RingHom.coe_fstₓ'. -/\n@[simp]\ntheorem coe_fst : ⇑(fst R S) = Prod.fst :=\n  rfl\n#align ring_hom.coe_fst RingHom.coe_fst\n\n/- warning: ring_hom.coe_snd -> RingHom.coe_snd is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{max (succ (max u1 u2)) (succ u2)} ((Prod.{u1, u2} R S) -> S) (coeFn.{max (succ (max u1 u2)) (succ u2), max (succ (max u1 u2)) (succ u2)} (RingHom.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2) (fun (_x : RingHom.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2) => (Prod.{u1, u2} R S) -> S) (RingHom.hasCoeToFun.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2) (RingHom.snd.{u1, u2} R S _inst_1 _inst_2)) (Prod.snd.{u1, u2} R S)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (forall (ᾰ : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => S) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), succ u1} (RingHom.{max u1 u2, u1} (Prod.{u2, u1} R S) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (Prod.{u2, u1} R S) (fun (_x : Prod.{u2, u1} R S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => S) _x) (MulHomClass.toFunLike.{max u2 u1, max u2 u1, u1} (RingHom.{max u1 u2, u1} (Prod.{u2, u1} R S) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (Prod.{u2, u1} R S) S (NonUnitalNonAssocSemiring.toMul.{max u2 u1} (Prod.{u2, u1} R S) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} R S) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, max u2 u1, u1} (RingHom.{max u1 u2, u1} (Prod.{u2, u1} R S) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (Prod.{u2, u1} R S) S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} R S) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, max u2 u1, u1} (RingHom.{max u1 u2, u1} (Prod.{u2, u1} R S) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (Prod.{u2, u1} R S) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2 (RingHom.instRingHomClassRingHom.{max u2 u1, u1} (Prod.{u2, u1} R S) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2)))) (RingHom.snd.{u2, u1} R S _inst_1 _inst_2)) (Prod.snd.{u2, u1} R S)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_snd RingHom.coe_sndₓ'. -/\n@[simp]\ntheorem coe_snd : ⇑(snd R S) = Prod.snd :=\n  rfl\n#align ring_hom.coe_snd RingHom.coe_snd\n\nsection Prod\n\nvariable [NonAssocSemiring T] (f : R →+* S) (g : R →+* T)\n\n/- warning: ring_hom.prod -> RingHom.prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} T], (RingHom.{u1, u2} R S _inst_1 _inst_2) -> (RingHom.{u1, u3} R T _inst_1 _inst_3) -> (RingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} T], (RingHom.{u1, u2} R S _inst_1 _inst_2) -> (RingHom.{u1, u3} R T _inst_1 _inst_3) -> (RingHom.{u1, max u3 u2} R (Prod.{u2, u3} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u2, u3} S T _inst_2 _inst_3))\nCase conversion may be inaccurate. Consider using '#align ring_hom.prod RingHom.prodₓ'. -/\n/-- Combine two ring homomorphisms `f : R →+* S`, `g : R →+* T` into `f.prod g : R →+* S × T`\ngiven by `(f.prod g) x = (f x, g x)` -/\nprotected def prod (f : R →+* S) (g : R →+* T) : R →+* S × T :=\n  { MonoidHom.prod (f : R →* S) (g : R →* T), AddMonoidHom.prod (f : R →+ S) (g : R →+ T) with\n    toFun := fun x => (f x, g x) }\n#align ring_hom.prod RingHom.prod\n\n/- warning: ring_hom.prod_apply -> RingHom.prod_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} T] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (g : RingHom.{u1, u3} R T _inst_1 _inst_3) (x : R), Eq.{max (succ u2) (succ u3)} (Prod.{u2, u3} S T) (coeFn.{max (succ u1) (succ (max u2 u3)), max (succ u1) (succ (max u2 u3))} (RingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) (fun (_x : RingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) => R -> (Prod.{u2, u3} S T)) (RingHom.hasCoeToFun.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) (RingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 f g) x) (Prod.mk.{u2, u3} S T (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R T _inst_1 _inst_3) (fun (_x : RingHom.{u1, u3} R T _inst_1 _inst_3) => R -> T) (RingHom.hasCoeToFun.{u1, u3} R T _inst_1 _inst_3) g x))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u3}} {T : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u3} S] [_inst_3 : NonAssocSemiring.{u2} T] (f : RingHom.{u1, u3} R S _inst_1 _inst_2) (g : RingHom.{u1, u2} R T _inst_1 _inst_3) (x : R), Eq.{max (succ u3) (succ u2)} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Prod.{u3, u2} S T) x) (FunLike.coe.{max (max (succ u1) (succ u3)) (succ u2), succ u1, max (succ u3) (succ u2)} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Prod.{u3, u2} S T) _x) (MulHomClass.toFunLike.{max (max u1 u3) u2, u1, max u3 u2} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) R (Prod.{u3, u2} S T) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{max u3 u2} (Prod.{u3, u2} S T) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u2} (Prod.{u3, u2} S T) (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max (max u1 u3) u2, u1, max u3 u2} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) R (Prod.{u3, u2} S T) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u2} (Prod.{u3, u2} S T) (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max (max u1 u3) u2, u1, max u3 u2} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3)) R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3) (RingHom.instRingHomClassRingHom.{u1, max u3 u2} R (Prod.{u3, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u3, u2} S T _inst_2 _inst_3))))) (RingHom.prod.{u1, u3, u2} R S T _inst_1 _inst_2 _inst_3 f g) x) (Prod.mk.{u3, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => T) x) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u3} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u3} R S _inst_1 _inst_2)))) f x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R T _inst_1 _inst_3) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => T) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R T _inst_1 _inst_3) R T (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} T _inst_3)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R T _inst_1 _inst_3) R T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} T _inst_3) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R T _inst_1 _inst_3) R T _inst_1 _inst_3 (RingHom.instRingHomClassRingHom.{u1, u2} R T _inst_1 _inst_3)))) g x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.prod_apply RingHom.prod_applyₓ'. -/\n@[simp]\ntheorem prod_apply (x) : f.Prod g x = (f x, g x) :=\n  rfl\n#align ring_hom.prod_apply RingHom.prod_apply\n\n/- warning: ring_hom.fst_comp_prod -> RingHom.fst_comp_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} T] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (g : RingHom.{u1, u3} R T _inst_1 _inst_3), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (RingHom.comp.{u1, max u2 u3, u2} R (Prod.{u2, u3} S T) S _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_2 (RingHom.fst.{u2, u3} S T _inst_2 _inst_3) (RingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 f g)) f\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u2}} {T : Type.{u1}} [_inst_1 : NonAssocSemiring.{u3} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u1} T] (f : RingHom.{u3, u2} R S _inst_1 _inst_2) (g : RingHom.{u3, u1} R T _inst_1 _inst_3), Eq.{max (succ u3) (succ u2)} (RingHom.{u3, u2} R S _inst_1 _inst_2) (RingHom.comp.{u3, max u2 u1, u2} R (Prod.{u2, u1} S T) S _inst_1 (Prod.instNonAssocSemiringProd.{u2, u1} S T _inst_2 _inst_3) _inst_2 (RingHom.fst.{u2, u1} S T _inst_2 _inst_3) (RingHom.prod.{u3, u2, u1} R S T _inst_1 _inst_2 _inst_3 f g)) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.fst_comp_prod RingHom.fst_comp_prodₓ'. -/\n@[simp]\ntheorem fst_comp_prod : (fst S T).comp (f.Prod g) = f :=\n  ext fun x => rfl\n#align ring_hom.fst_comp_prod RingHom.fst_comp_prod\n\n/- warning: ring_hom.snd_comp_prod -> RingHom.snd_comp_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} T] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (g : RingHom.{u1, u3} R T _inst_1 _inst_3), Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} R T _inst_1 _inst_3) (RingHom.comp.{u1, max u2 u3, u3} R (Prod.{u2, u3} S T) T _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_3 (RingHom.snd.{u2, u3} S T _inst_2 _inst_3) (RingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 f g)) g\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u1}} {T : Type.{u2}} [_inst_1 : NonAssocSemiring.{u3} R] [_inst_2 : NonAssocSemiring.{u1} S] [_inst_3 : NonAssocSemiring.{u2} T] (f : RingHom.{u3, u1} R S _inst_1 _inst_2) (g : RingHom.{u3, u2} R T _inst_1 _inst_3), Eq.{max (succ u3) (succ u2)} (RingHom.{u3, u2} R T _inst_1 _inst_3) (RingHom.comp.{u3, max u1 u2, u2} R (Prod.{u1, u2} S T) T _inst_1 (Prod.instNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3) _inst_3 (RingHom.snd.{u1, u2} S T _inst_2 _inst_3) (RingHom.prod.{u3, u1, u2} R S T _inst_1 _inst_2 _inst_3 f g)) g\nCase conversion may be inaccurate. Consider using '#align ring_hom.snd_comp_prod RingHom.snd_comp_prodₓ'. -/\n@[simp]\ntheorem snd_comp_prod : (snd S T).comp (f.Prod g) = g :=\n  ext fun x => rfl\n#align ring_hom.snd_comp_prod RingHom.snd_comp_prod\n\n/- warning: ring_hom.prod_unique -> RingHom.prod_unique is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {T : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} T] (f : RingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)), Eq.{max (succ u1) (succ (max u2 u3))} (RingHom.{u1, max u2 u3} R (Prod.{u2, u3} S T) _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3)) (RingHom.prod.{u1, u2, u3} R S T _inst_1 _inst_2 _inst_3 (RingHom.comp.{u1, max u2 u3, u2} R (Prod.{u2, u3} S T) S _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_2 (RingHom.fst.{u2, u3} S T _inst_2 _inst_3) f) (RingHom.comp.{u1, max u2 u3, u3} R (Prod.{u2, u3} S T) T _inst_1 (Prod.nonAssocSemiring.{u2, u3} S T _inst_2 _inst_3) _inst_3 (RingHom.snd.{u2, u3} S T _inst_2 _inst_3) f)) f\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u1}} {T : Type.{u2}} [_inst_1 : NonAssocSemiring.{u3} R] [_inst_2 : NonAssocSemiring.{u1} S] [_inst_3 : NonAssocSemiring.{u2} T] (f : RingHom.{u3, max u2 u1} R (Prod.{u1, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3)), Eq.{max (max (succ u3) (succ u1)) (succ u2)} (RingHom.{u3, max u2 u1} R (Prod.{u1, u2} S T) _inst_1 (Prod.instNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3)) (RingHom.prod.{u3, u1, u2} R S T _inst_1 _inst_2 _inst_3 (RingHom.comp.{u3, max u1 u2, u1} R (Prod.{u1, u2} S T) S _inst_1 (Prod.instNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3) _inst_2 (RingHom.fst.{u1, u2} S T _inst_2 _inst_3) f) (RingHom.comp.{u3, max u1 u2, u2} R (Prod.{u1, u2} S T) T _inst_1 (Prod.instNonAssocSemiringProd.{u1, u2} S T _inst_2 _inst_3) _inst_3 (RingHom.snd.{u1, u2} S T _inst_2 _inst_3) f)) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.prod_unique RingHom.prod_uniqueₓ'. -/\ntheorem prod_unique (f : R →+* S × T) : ((fst S T).comp f).Prod ((snd S T).comp f) = f :=\n  ext fun x => by simp only [prod_apply, coe_fst, coe_snd, comp_apply, Prod.mk.eta]\n#align ring_hom.prod_unique RingHom.prod_unique\n\nend Prod\n\nsection Prod_map\n\nvariable [NonAssocSemiring R'] [NonAssocSemiring S'] [NonAssocSemiring T]\n\nvariable (f : R →+* R') (g : S →+* S')\n\n/- warning: ring_hom.prod_map -> RingHom.prodMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u3} S] [_inst_3 : NonAssocSemiring.{u2} R'] [_inst_4 : NonAssocSemiring.{u4} S'], (RingHom.{u1, u2} R R' _inst_1 _inst_3) -> (RingHom.{u3, u4} S S' _inst_2 _inst_4) -> (RingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4))\nbut is expected to have type\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u3} S] [_inst_3 : NonAssocSemiring.{u2} R'] [_inst_4 : NonAssocSemiring.{u4} S'], (RingHom.{u1, u2} R R' _inst_1 _inst_3) -> (RingHom.{u3, u4} S S' _inst_2 _inst_4) -> (RingHom.{max u3 u1, max u4 u2} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.instNonAssocSemiringProd.{u1, u3} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u2, u4} R' S' _inst_3 _inst_4))\nCase conversion may be inaccurate. Consider using '#align ring_hom.prod_map RingHom.prodMapₓ'. -/\n/-- `prod.map` as a `ring_hom`. -/\ndef prodMap : R × S →+* R' × S' :=\n  (f.comp (fst R S)).Prod (g.comp (snd R S))\n#align ring_hom.prod_map RingHom.prodMap\n\n/- warning: ring_hom.prod_map_def -> RingHom.prodMap_def is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u3} S] [_inst_3 : NonAssocSemiring.{u2} R'] [_inst_4 : NonAssocSemiring.{u4} S'] (f : RingHom.{u1, u2} R R' _inst_1 _inst_3) (g : RingHom.{u3, u4} S S' _inst_2 _inst_4), Eq.{max (succ (max u1 u3)) (succ (max u2 u4))} (RingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (RingHom.prodMap.{u1, u2, u3, u4} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g) (RingHom.prod.{max u1 u3, u2, u4} (Prod.{u1, u3} R S) R' S' (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) _inst_3 _inst_4 (RingHom.comp.{max u1 u3, u1, u2} (Prod.{u1, u3} R S) R R' (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) _inst_1 _inst_3 f (RingHom.fst.{u1, u3} R S _inst_1 _inst_2)) (RingHom.comp.{max u1 u3, u3, u4} (Prod.{u1, u3} R S) S S' (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) _inst_2 _inst_4 g (RingHom.snd.{u1, u3} R S _inst_1 _inst_2)))\nbut is expected to have type\n  forall {R : Type.{u4}} {R' : Type.{u3}} {S : Type.{u2}} {S' : Type.{u1}} [_inst_1 : NonAssocSemiring.{u4} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} R'] [_inst_4 : NonAssocSemiring.{u1} S'] (f : RingHom.{u4, u3} R R' _inst_1 _inst_3) (g : RingHom.{u2, u1} S S' _inst_2 _inst_4), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (RingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (RingHom.prodMap.{u4, u3, u2, u1} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g) (RingHom.prod.{max u4 u2, u3, u1} (Prod.{u4, u2} R S) R' S' (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) _inst_3 _inst_4 (RingHom.comp.{max u4 u2, u4, u3} (Prod.{u4, u2} R S) R R' (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) _inst_1 _inst_3 f (RingHom.fst.{u4, u2} R S _inst_1 _inst_2)) (RingHom.comp.{max u4 u2, u2, u1} (Prod.{u4, u2} R S) S S' (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) _inst_2 _inst_4 g (RingHom.snd.{u4, u2} R S _inst_1 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.prod_map_def RingHom.prodMap_defₓ'. -/\ntheorem prodMap_def : prodMap f g = (f.comp (fst R S)).Prod (g.comp (snd R S)) :=\n  rfl\n#align ring_hom.prod_map_def RingHom.prodMap_def\n\n/- warning: ring_hom.coe_prod_map -> RingHom.coe_prodMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u3} S] [_inst_3 : NonAssocSemiring.{u2} R'] [_inst_4 : NonAssocSemiring.{u4} S'] (f : RingHom.{u1, u2} R R' _inst_1 _inst_3) (g : RingHom.{u3, u4} S S' _inst_2 _inst_4), Eq.{max (succ (max u1 u3)) (succ (max u2 u4))} ((Prod.{u1, u3} R S) -> (Prod.{u2, u4} R' S')) (coeFn.{max (succ (max u1 u3)) (succ (max u2 u4)), max (succ (max u1 u3)) (succ (max u2 u4))} (RingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (fun (_x : RingHom.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) => (Prod.{u1, u3} R S) -> (Prod.{u2, u4} R' S')) (RingHom.hasCoeToFun.{max u1 u3, max u2 u4} (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (RingHom.prodMap.{u1, u2, u3, u4} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g)) (Prod.map.{u1, u2, u3, u4} R R' S S' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R R' _inst_1 _inst_3) (fun (_x : RingHom.{u1, u2} R R' _inst_1 _inst_3) => R -> R') (RingHom.hasCoeToFun.{u1, u2} R R' _inst_1 _inst_3) f) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (RingHom.{u3, u4} S S' _inst_2 _inst_4) (fun (_x : RingHom.{u3, u4} S S' _inst_2 _inst_4) => S -> S') (RingHom.hasCoeToFun.{u3, u4} S S' _inst_2 _inst_4) g))\nbut is expected to have type\n  forall {R : Type.{u4}} {R' : Type.{u3}} {S : Type.{u2}} {S' : Type.{u1}} [_inst_1 : NonAssocSemiring.{u4} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : NonAssocSemiring.{u3} R'] [_inst_4 : NonAssocSemiring.{u1} S'] (f : RingHom.{u4, u3} R R' _inst_1 _inst_3) (g : RingHom.{u2, u1} S S' _inst_2 _inst_4), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (forall (ᾰ : Prod.{u4, u2} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u4, u2} R S) => Prod.{u3, u1} R' S') ᾰ) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), max (succ u4) (succ u2), max (succ u3) (succ u1)} (RingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (Prod.{u4, u2} R S) (fun (_x : Prod.{u4, u2} R S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u4, u2} R S) => Prod.{u3, u1} R' S') _x) (MulHomClass.toFunLike.{max (max (max u4 u3) u2) u1, max u4 u2, max u3 u1} (RingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (NonUnitalNonAssocSemiring.toMul.{max u4 u2} (Prod.{u4, u2} R S) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u2} (Prod.{u4, u2} R S) (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2))) (NonUnitalNonAssocSemiring.toMul.{max u3 u1} (Prod.{u3, u1} R' S') (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u1} (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4))) (NonUnitalRingHomClass.toMulHomClass.{max (max (max u4 u3) u2) u1, max u4 u2, max u3 u1} (RingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u2} (Prod.{u4, u2} R S) (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u1} (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (RingHomClass.toNonUnitalRingHomClass.{max (max (max u4 u3) u2) u1, max u4 u2, max u3 u1} (RingHom.{max u2 u4, max u1 u3} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4)) (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4) (RingHom.instRingHomClassRingHom.{max u4 u2, max u3 u1} (Prod.{u4, u2} R S) (Prod.{u3, u1} R' S') (Prod.instNonAssocSemiringProd.{u4, u2} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u3, u1} R' S' _inst_3 _inst_4))))) (RingHom.prodMap.{u4, u3, u2, u1} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f g)) (Prod.map.{u4, u3, u2, u1} R R' S S' (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (RingHom.{u4, u3} R R' _inst_1 _inst_3) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R') _x) (MulHomClass.toFunLike.{max u4 u3, u4, u3} (RingHom.{u4, u3} R R' _inst_1 _inst_3) R R' (NonUnitalNonAssocSemiring.toMul.{u4} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u3} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R' _inst_3)) (NonUnitalRingHomClass.toMulHomClass.{max u4 u3, u4, u3} (RingHom.{u4, u3} R R' _inst_1 _inst_3) R R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R' _inst_3) (RingHomClass.toNonUnitalRingHomClass.{max u4 u3, u4, u3} (RingHom.{u4, u3} R R' _inst_1 _inst_3) R R' _inst_1 _inst_3 (RingHom.instRingHomClassRingHom.{u4, u3} R R' _inst_1 _inst_3)))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} S S' _inst_2 _inst_4) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S') _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S' _inst_2 _inst_4) S S' (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} S' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S' _inst_4)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S' _inst_2 _inst_4) S S' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S' _inst_4) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S' _inst_2 _inst_4) S S' _inst_2 _inst_4 (RingHom.instRingHomClassRingHom.{u2, u1} S S' _inst_2 _inst_4)))) g))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_prod_map RingHom.coe_prodMapₓ'. -/\n@[simp]\ntheorem coe_prodMap : ⇑(prodMap f g) = Prod.map f g :=\n  rfl\n#align ring_hom.coe_prod_map RingHom.coe_prodMap\n\n/- warning: ring_hom.prod_comp_prod_map -> RingHom.prod_comp_prodMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u4}} {T : Type.{u5}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u3} S] [_inst_3 : NonAssocSemiring.{u2} R'] [_inst_4 : NonAssocSemiring.{u4} S'] [_inst_5 : NonAssocSemiring.{u5} T] (f : RingHom.{u5, u1} T R _inst_5 _inst_1) (g : RingHom.{u5, u3} T S _inst_5 _inst_2) (f' : RingHom.{u1, u2} R R' _inst_1 _inst_3) (g' : RingHom.{u3, u4} S S' _inst_2 _inst_4), Eq.{max (succ u5) (succ (max u2 u4))} (RingHom.{u5, max u2 u4} T (Prod.{u2, u4} R' S') _inst_5 (Prod.nonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4)) (RingHom.comp.{u5, max u1 u3, max u2 u4} T (Prod.{u1, u3} R S) (Prod.{u2, u4} R' S') _inst_5 (Prod.nonAssocSemiring.{u1, u3} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u4} R' S' _inst_3 _inst_4) (RingHom.prodMap.{u1, u2, u3, u4} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f' g') (RingHom.prod.{u5, u1, u3} T R S _inst_5 _inst_1 _inst_2 f g)) (RingHom.prod.{u5, u2, u4} T R' S' _inst_5 _inst_3 _inst_4 (RingHom.comp.{u5, u1, u2} T R R' _inst_5 _inst_1 _inst_3 f' f) (RingHom.comp.{u5, u3, u4} T S S' _inst_5 _inst_2 _inst_4 g' g))\nbut is expected to have type\n  forall {R : Type.{u4}} {R' : Type.{u2}} {S : Type.{u3}} {S' : Type.{u1}} {T : Type.{u5}} [_inst_1 : NonAssocSemiring.{u4} R] [_inst_2 : NonAssocSemiring.{u3} S] [_inst_3 : NonAssocSemiring.{u2} R'] [_inst_4 : NonAssocSemiring.{u1} S'] [_inst_5 : NonAssocSemiring.{u5} T] (f : RingHom.{u5, u4} T R _inst_5 _inst_1) (g : RingHom.{u5, u3} T S _inst_5 _inst_2) (f' : RingHom.{u4, u2} R R' _inst_1 _inst_3) (g' : RingHom.{u3, u1} S S' _inst_2 _inst_4), Eq.{max (max (succ u2) (succ u1)) (succ u5)} (RingHom.{u5, max u2 u1} T (Prod.{u2, u1} R' S') _inst_5 (Prod.instNonAssocSemiringProd.{u2, u1} R' S' _inst_3 _inst_4)) (RingHom.comp.{u5, max u4 u3, max u2 u1} T (Prod.{u4, u3} R S) (Prod.{u2, u1} R' S') _inst_5 (Prod.instNonAssocSemiringProd.{u4, u3} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u2, u1} R' S' _inst_3 _inst_4) (RingHom.prodMap.{u4, u2, u3, u1} R R' S S' _inst_1 _inst_2 _inst_3 _inst_4 f' g') (RingHom.prod.{u5, u4, u3} T R S _inst_5 _inst_1 _inst_2 f g)) (RingHom.prod.{u5, u2, u1} T R' S' _inst_5 _inst_3 _inst_4 (RingHom.comp.{u5, u4, u2} T R R' _inst_5 _inst_1 _inst_3 f' f) (RingHom.comp.{u5, u3, u1} T S S' _inst_5 _inst_2 _inst_4 g' g))\nCase conversion may be inaccurate. Consider using '#align ring_hom.prod_comp_prod_map RingHom.prod_comp_prodMapₓ'. -/\ntheorem prod_comp_prodMap (f : T →+* R) (g : T →+* S) (f' : R →+* R') (g' : S →+* S') :\n    (f'.Prod_map g').comp (f.Prod g) = (f'.comp f).Prod (g'.comp g) :=\n  rfl\n#align ring_hom.prod_comp_prod_map RingHom.prod_comp_prodMap\n\nend Prod_map\n\nend RingHom\n\nnamespace RingEquiv\n\nvariable {R S} [NonAssocSemiring R] [NonAssocSemiring S]\n\n/- warning: ring_equiv.prod_comm -> RingEquiv.prodComm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], RingEquiv.{max u2 u1, max u1 u2} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.instMulProd.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Prod.instMulProd.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Prod.instAddSum.{u1, u2} R S (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.instAddSum.{u2, u1} S R (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.prod_comm RingEquiv.prodCommₓ'. -/\n/-- Swapping components as an equivalence of (semi)rings. -/\ndef prodComm : R × S ≃+* S × R :=\n  { AddEquiv.prodComm, MulEquiv.prodComm with }\n#align ring_equiv.prod_comm RingEquiv.prodComm\n\n/- warning: ring_equiv.coe_prod_comm -> RingEquiv.coe_prod_comm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{max (succ (max u1 u2)) (succ (max u2 u1))} ((Prod.{u1, u2} R S) -> (Prod.{u2, u1} S R)) (coeFn.{max (succ (max u1 u2)) (succ (max u2 u1)), max (succ (max u1 u2)) (succ (max u2 u1))} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (fun (_x : RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) => (Prod.{u1, u2} R S) -> (Prod.{u2, u1} S R)) (RingEquiv.hasCoeToFun.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingEquiv.prodComm.{u1, u2} R S _inst_1 _inst_2)) (Prod.swap.{u1, u2} R S)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (forall (ᾰ : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u2, u1} R S) => Prod.{u1, u2} S R) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (fun (_x : Prod.{u2, u1} R S) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u2, u1} R S) => Prod.{u1, u2} S R) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (MulEquivClass.toEquivLike.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (RingEquivClass.toMulEquivClass.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (RingEquiv.instRingEquivClassRingEquiv.{max u2 u1, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))))))) (RingEquiv.prodComm.{u2, u1} R S _inst_1 _inst_2)) (Prod.swap.{u2, u1} R S)\nCase conversion may be inaccurate. Consider using '#align ring_equiv.coe_prod_comm RingEquiv.coe_prod_commₓ'. -/\n@[simp]\ntheorem coe_prod_comm : ⇑(prodComm : R × S ≃+* S × R) = Prod.swap :=\n  rfl\n#align ring_equiv.coe_prod_comm RingEquiv.coe_prod_comm\n\n/- warning: ring_equiv.coe_prod_comm_symm -> RingEquiv.coe_prod_comm_symm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{max (succ (max u2 u1)) (succ (max u1 u2))} ((Prod.{u2, u1} S R) -> (Prod.{u1, u2} R S)) (coeFn.{max (succ (max u2 u1)) (succ (max u1 u2)), max (succ (max u2 u1)) (succ (max u1 u2))} (RingEquiv.{max u2 u1, max u1 u2} (Prod.{u2, u1} S R) (Prod.{u1, u2} R S) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))) (fun (_x : RingEquiv.{max u2 u1, max u1 u2} (Prod.{u2, u1} S R) (Prod.{u1, u2} R S) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))) => (Prod.{u2, u1} S R) -> (Prod.{u1, u2} R S)) (RingEquiv.hasCoeToFun.{max u2 u1, max u1 u2} (Prod.{u2, u1} S R) (Prod.{u1, u2} R S) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))) (RingEquiv.symm.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingEquiv.prodComm.{u1, u2} R S _inst_1 _inst_2))) (Prod.swap.{u2, u1} S R)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (forall (ᾰ : Prod.{u1, u2} S R), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u1, u2} S R) => Prod.{u2, u1} R S) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{max u2 u1, max u2 u1} (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))))) (Prod.{u1, u2} S R) (fun (_x : Prod.{u1, u2} S R) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u1, u2} S R) => Prod.{u2, u1} R S) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{max u2 u1, max u2 u1} (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))))) (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{max u2 u1, max u2 u1} (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))))) (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (MulEquivClass.toEquivLike.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u2 u1, max u2 u1} (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))))) (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (RingEquivClass.toMulEquivClass.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u2 u1, max u2 u1} (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))))) (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (RingEquiv.instRingEquivClassRingEquiv.{max u2 u1, max u2 u1} (Prod.{u1, u2} S R) (Prod.{u2, u1} R S) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))))))))) (RingEquiv.symm.{max u2 u1, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))) (RingEquiv.prodComm.{u2, u1} R S _inst_1 _inst_2))) (Prod.swap.{u1, u2} S R)\nCase conversion may be inaccurate. Consider using '#align ring_equiv.coe_prod_comm_symm RingEquiv.coe_prod_comm_symmₓ'. -/\n@[simp]\ntheorem coe_prod_comm_symm : ⇑(prodComm : R × S ≃+* S × R).symm = Prod.swap :=\n  rfl\n#align ring_equiv.coe_prod_comm_symm RingEquiv.coe_prod_comm_symm\n\n/- warning: ring_equiv.fst_comp_coe_prod_comm -> RingEquiv.fst_comp_coe_prod_comm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{max (succ (max u1 u2)) (succ u2)} (RingHom.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2) (RingHom.comp.{max u1 u2, max u2 u1, u2} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1) _inst_2 (RingHom.fst.{u2, u1} S R _inst_2 _inst_1) ((fun (a : Sort.{max (succ (max u1 u2)) (succ (max u2 u1))}) (b : Sort.{max (succ (max u1 u2)) (succ (max u2 u1))}) [self : HasLiftT.{max (succ (max u1 u2)) (succ (max u2 u1)), max (succ (max u1 u2)) (succ (max u2 u1))} a b] => self.0) (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingHom.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1)) (HasLiftT.mk.{max (succ (max u1 u2)) (succ (max u2 u1)), max (succ (max u1 u2)) (succ (max u2 u1))} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingHom.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1)) (CoeTCₓ.coe.{max (succ (max u1 u2)) (succ (max u2 u1)), max (succ (max u1 u2)) (succ (max u2 u1))} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingHom.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1)) (RingHom.hasCoeT.{max (max u1 u2) u2 u1, max u1 u2, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1) (RingEquivClass.toRingHomClass.{max (max u1 u2) u2 u1, max u1 u2, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1) (RingEquiv.ringEquivClass.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))))))) (RingEquiv.prodComm.{u1, u2} R S _inst_1 _inst_2))) (RingHom.snd.{u1, u2} R S _inst_1 _inst_2)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (RingHom.{max u2 u1, u1} (Prod.{u2, u1} R S) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_2) (RingHom.comp.{max u2 u1, max u2 u1, u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) S (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u1, u2} S R _inst_2 _inst_1) _inst_2 (RingHom.fst.{u1, u2} S R _inst_2 _inst_1) (RingHomClass.toRingHom.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u1, u2} S R _inst_2 _inst_1) (RingEquivClass.toRingHomClass.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u1, u2} S R _inst_2 _inst_1) (RingEquiv.instRingEquivClassRingEquiv.{max u2 u1, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))))) (RingEquiv.prodComm.{u2, u1} R S _inst_1 _inst_2))) (RingHom.snd.{u2, u1} R S _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align ring_equiv.fst_comp_coe_prod_comm RingEquiv.fst_comp_coe_prod_commₓ'. -/\n@[simp]\ntheorem fst_comp_coe_prod_comm :\n    (RingHom.fst S R).comp ↑(prodComm : R × S ≃+* S × R) = RingHom.snd R S :=\n  RingHom.ext fun _ => rfl\n#align ring_equiv.fst_comp_coe_prod_comm RingEquiv.fst_comp_coe_prod_comm\n\n/- warning: ring_equiv.snd_comp_coe_prod_comm -> RingEquiv.snd_comp_coe_prod_comm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{max (succ (max u1 u2)) (succ u1)} (RingHom.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1) (RingHom.comp.{max u1 u2, max u2 u1, u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1) _inst_1 (RingHom.snd.{u2, u1} S R _inst_2 _inst_1) ((fun (a : Sort.{max (succ (max u1 u2)) (succ (max u2 u1))}) (b : Sort.{max (succ (max u1 u2)) (succ (max u2 u1))}) [self : HasLiftT.{max (succ (max u1 u2)) (succ (max u2 u1)), max (succ (max u1 u2)) (succ (max u2 u1))} a b] => self.0) (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingHom.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1)) (HasLiftT.mk.{max (succ (max u1 u2)) (succ (max u2 u1)), max (succ (max u1 u2)) (succ (max u2 u1))} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingHom.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1)) (CoeTCₓ.coe.{max (succ (max u1 u2)) (succ (max u2 u1)), max (succ (max u1 u2)) (succ (max u2 u1))} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingHom.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1)) (RingHom.hasCoeT.{max (max u1 u2) u2 u1, max u1 u2, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1) (RingEquivClass.toRingHomClass.{max (max u1 u2) u2 u1, max u1 u2, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) (Prod.nonAssocSemiring.{u2, u1} S R _inst_2 _inst_1) (RingEquiv.ringEquivClass.{max u1 u2, max u2 u1} (Prod.{u1, u2} R S) (Prod.{u2, u1} S R) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))))))) (RingEquiv.prodComm.{u1, u2} R S _inst_1 _inst_2))) (RingHom.fst.{u1, u2} R S _inst_1 _inst_2)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u1} S], Eq.{max (succ u2) (succ u1)} (RingHom.{max u2 u1, u2} (Prod.{u2, u1} R S) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) _inst_1) (RingHom.comp.{max u2 u1, max u2 u1, u2} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) R (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u1, u2} S R _inst_2 _inst_1) _inst_1 (RingHom.snd.{u1, u2} S R _inst_2 _inst_1) (RingHomClass.toRingHom.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u1, u2} S R _inst_2 _inst_1) (RingEquivClass.toRingHomClass.{max u2 u1, max u2 u1, max u2 u1} (RingEquiv.{max u1 u2, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))))) (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instNonAssocSemiringProd.{u2, u1} R S _inst_1 _inst_2) (Prod.instNonAssocSemiringProd.{u1, u2} S R _inst_2 _inst_1) (RingEquiv.instRingEquivClassRingEquiv.{max u2 u1, max u2 u1} (Prod.{u2, u1} R S) (Prod.{u1, u2} S R) (Prod.instMulProd.{u2, u1} R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Prod.instMulProd.{u1, u2} S R (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Prod.instAddSum.{u2, u1} R S (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)))) (Prod.instAddSum.{u1, u2} S R (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)))))) (RingEquiv.prodComm.{u2, u1} R S _inst_1 _inst_2))) (RingHom.fst.{u2, u1} R S _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align ring_equiv.snd_comp_coe_prod_comm RingEquiv.snd_comp_coe_prod_commₓ'. -/\n@[simp]\ntheorem snd_comp_coe_prod_comm :\n    (RingHom.snd S R).comp ↑(prodComm : R × S ≃+* S × R) = RingHom.fst R S :=\n  RingHom.ext fun _ => rfl\n#align ring_equiv.snd_comp_coe_prod_comm RingEquiv.snd_comp_coe_prod_comm\n\nvariable (R S) [Subsingleton S]\n\n/- warning: ring_equiv.prod_zero_ring -> RingEquiv.prodZeroRing is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : Subsingleton.{succ u2} S], RingEquiv.{u1, max u1 u2} R (Prod.{u1, u2} R S) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Prod.hasMul.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (Prod.hasAdd.{u1, u2} R S (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : Subsingleton.{succ u2} S], RingEquiv.{u1, max u2 u1} R (Prod.{u1, u2} R S) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Prod.instMulProd.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Prod.instAddSum.{u1, u2} R S (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.prod_zero_ring RingEquiv.prodZeroRingₓ'. -/\n/-- A ring `R` is isomorphic to `R × S` when `S` is the zero ring -/\n@[simps]\ndef prodZeroRing : R ≃+* R × S where\n  toFun x := (x, 0)\n  invFun := Prod.fst\n  map_add' := by simp\n  map_mul' := by simp\n  left_inv x := rfl\n  right_inv x := by cases x <;> simp\n#align ring_equiv.prod_zero_ring RingEquiv.prodZeroRing\n\n/- warning: ring_equiv.zero_ring_prod -> RingEquiv.zeroRingProd is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : Subsingleton.{succ u2} S], RingEquiv.{u1, max u2 u1} R (Prod.{u2, u1} S R) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Prod.hasMul.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Prod.hasAdd.{u2, u1} S R (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : Subsingleton.{succ u2} S], RingEquiv.{u1, max u1 u2} R (Prod.{u2, u1} S R) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Prod.instMulProd.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Prod.instAddSum.{u2, u1} S R (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.zero_ring_prod RingEquiv.zeroRingProdₓ'. -/\n/-- A ring `R` is isomorphic to `S × R` when `S` is the zero ring -/\n@[simps]\ndef zeroRingProd : R ≃+* S × R where\n  toFun x := (0, x)\n  invFun := Prod.snd\n  map_add' := by simp\n  map_mul' := by simp\n  left_inv x := rfl\n  right_inv x := by cases x <;> simp\n#align ring_equiv.zero_ring_prod RingEquiv.zeroRingProd\n\nend RingEquiv\n\n/- warning: false_of_nontrivial_of_product_domain -> false_of_nontrivial_of_product_domain is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) [_inst_1 : Ring.{u1} R] [_inst_2 : Ring.{u2} S] [_inst_3 : IsDomain.{max u1 u2} (Prod.{u1, u2} R S) (Prod.semiring.{u1, u2} R S (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2))] [_inst_4 : Nontrivial.{u1} R] [_inst_5 : Nontrivial.{u2} S], False\nbut is expected to have type\n  forall (R : Type.{u2}) (S : Type.{u1}) [_inst_1 : Ring.{u2} R] [_inst_2 : Ring.{u1} S] [_inst_3 : IsDomain.{max u1 u2} (Prod.{u2, u1} R S) (Prod.instSemiringProd.{u2, u1} R S (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2))] [_inst_4 : Nontrivial.{u2} R] [_inst_5 : Nontrivial.{u1} S], False\nCase conversion may be inaccurate. Consider using '#align false_of_nontrivial_of_product_domain false_of_nontrivial_of_product_domainₓ'. -/\n/-- The product of two nontrivial rings is not a domain -/\ntheorem false_of_nontrivial_of_product_domain (R S : Type _) [Ring R] [Ring S] [IsDomain (R × S)]\n    [Nontrivial R] [Nontrivial S] : False :=\n  by\n  have :=\n    NoZeroDivisors.eq_zero_or_eq_zero_of_mul_eq_zero (show ((0 : R), (1 : S)) * (1, 0) = 0 by simp)\n  rw [Prod.mk_eq_zero, Prod.mk_eq_zero] at this\n  rcases this with (⟨_, h⟩ | ⟨h, _⟩)\n  · exact zero_ne_one h.symm\n  · exact zero_ne_one h.symm\n#align false_of_nontrivial_of_product_domain false_of_nontrivial_of_product_domain\n\n/-! ### Order -/\n\n\ninstance [OrderedSemiring α] [OrderedSemiring β] : OrderedSemiring (α × β) :=\n  { Prod.semiring,\n    Prod.partialOrder _ _ with\n    add_le_add_left := fun _ _ => add_le_add_left\n    zero_le_one := ⟨zero_le_one, zero_le_one⟩\n    mul_le_mul_of_nonneg_left := fun a b c hab hc =>\n      ⟨mul_le_mul_of_nonneg_left hab.1 hc.1, mul_le_mul_of_nonneg_left hab.2 hc.2⟩\n    mul_le_mul_of_nonneg_right := fun a b c hab hc =>\n      ⟨mul_le_mul_of_nonneg_right hab.1 hc.1, mul_le_mul_of_nonneg_right hab.2 hc.2⟩ }\n\ninstance [OrderedCommSemiring α] [OrderedCommSemiring β] : OrderedCommSemiring (α × β) :=\n  { Prod.commSemiring, Prod.orderedSemiring with }\n\ninstance [OrderedRing α] [OrderedRing β] : OrderedRing (α × β) :=\n  { Prod.ring, Prod.orderedSemiring with\n    mul_nonneg := fun a b ha hb => ⟨mul_nonneg ha.1 hb.1, mul_nonneg ha.2 hb.2⟩ }\n\ninstance [OrderedCommRing α] [OrderedCommRing β] : OrderedCommRing (α × β) :=\n  { Prod.commRing, Prod.orderedRing with }\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Ring/Prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.48633518780295415}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yaël Dillies\n\n! This file was ported from Lean 3 source module order.disjointed\n! leanprover-community/mathlib commit f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Order.PartialSups\n\n/-!\n# Consecutive differences of sets\n\nThis file defines the way to make a sequence of elements into a sequence of disjoint elements with\nthe same partial sups.\n\nFor a sequence `f : ℕ → α`, this new sequence will be `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 ⊔ f 1)`.\nIt is actually unique, as `disjointed_unique` shows.\n\n## Main declarations\n\n* `disjointed f`: The sequence `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 ⊔ f 1)`, ....\n* `partialSups_disjointed`: `disjointed f` has the same partial sups as `f`.\n* `disjoint_disjointed`: The elements of `disjointed f` are pairwise disjoint.\n* `disjointed_unique`: `disjointed f` is the only pairwise disjoint sequence having the same partial\n  sups as `f`.\n* `supᵢ_disjointed`: `disjointed f` has the same supremum as `f`. Limiting case of\n  `partialSups_disjointed`.\n\nWe also provide set notation variants of some lemmas.\n\n## TODO\n\nFind a useful statement of `disjointedRec_succ`.\n\nOne could generalize `disjointed` to any locally finite bot preorder domain, in place of `ℕ`.\nRelated to the TODO in the module docstring of `Mathlib.Order.PartialSups`.\n-/\n\n\nvariable {α β : Type _}\n\nsection GeneralizedBooleanAlgebra\n\nvariable [GeneralizedBooleanAlgebra α]\n\n/-- If `f : ℕ → α` is a sequence of elements, then `disjointed f` is the sequence formed by\nsubtracting each element from the nexts. This is the unique disjoint sequence whose partial sups\nare the same as the original sequence. -/\ndef disjointed (f : ℕ → α) : ℕ → α\n  | 0 => f 0\n  | n + 1 => f (n + 1) \\ partialSups f n\n#align disjointed disjointed\n\n@[simp]\ntheorem disjointed_zero (f : ℕ → α) : disjointed f 0 = f 0 :=\n  rfl\n#align disjointed_zero disjointed_zero\n\ntheorem disjointed_succ (f : ℕ → α) (n : ℕ) : disjointed f (n + 1) = f (n + 1) \\ partialSups f n :=\n  rfl\n#align disjointed_succ disjointed_succ\n\ntheorem disjointed_le_id : disjointed ≤ (id : (ℕ → α) → ℕ → α) := by\n  rintro f n\n  cases n\n  · rfl\n  · exact sdiff_le\n#align disjointed_le_id disjointed_le_id\n\ntheorem disjointed_le (f : ℕ → α) : disjointed f ≤ f :=\n  disjointed_le_id f\n#align disjointed_le disjointed_le\n\ntheorem disjoint_disjointed (f : ℕ → α) : Pairwise (Disjoint on disjointed f) := by\n  refine' (Symmetric.pairwise_on Disjoint.symm _).2 fun m n h => _\n  cases n\n  · exact (Nat.not_lt_zero _ h).elim\n  exact\n    disjoint_sdiff_self_right.mono_left\n      ((disjointed_le f m).trans (le_partialSups_of_le f (Nat.lt_add_one_iff.1 h)))\n#align disjoint_disjointed disjoint_disjointed\n\n-- Porting note: `disjointedRec` had a change in universe level.\n/-- An induction principle for `disjointed`. To define/prove something on `disjointed f n`, it's\nenough to define/prove it for `f n` and being able to extend through diffs. -/\ndef disjointedRec {f : ℕ → α} {p : α → Sort _} (hdiff : ∀ ⦃t i⦄, p t → p (t \\ f i)) :\n    ∀ ⦃n⦄, p (f n) → p (disjointed f n)\n  | 0 => id\n  | n + 1 => fun h => by\n    suffices H : ∀ k, p (f (n + 1) \\ partialSups f k)\n    · exact H n\n    rintro k\n    induction' k with k ih\n    · exact hdiff h\n    rw [partialSups_succ, ← sdiff_sdiff_left]\n    exact hdiff ih\n#align disjointed_rec disjointedRec\n\n@[simp]\ntheorem disjointedRec_zero {f : ℕ → α} {p : α → Sort _} (hdiff : ∀ ⦃t i⦄, p t → p (t \\ f i))\n    (h₀ : p (f 0)) : disjointedRec hdiff h₀ = h₀ :=\n  rfl\n#align disjointed_rec_zero disjointedRec_zero\n\n-- TODO: Find a useful statement of `disjointedRec_succ`.\ntheorem Monotone.disjointed_eq {f : ℕ → α} (hf : Monotone f) (n : ℕ) :\n    disjointed f (n + 1) = f (n + 1) \\ f n := by rw [disjointed_succ, hf.partialSups_eq]\n#align monotone.disjointed_eq Monotone.disjointed_eq\n\n@[simp]\ntheorem partialSups_disjointed (f : ℕ → α) : partialSups (disjointed f) = partialSups f := by\n  ext n\n  induction' n with k ih\n  · rw [partialSups_zero, partialSups_zero, disjointed_zero]\n  · rw [partialSups_succ, partialSups_succ, disjointed_succ, ih, sup_sdiff_self_right]\n#align partial_sups_disjointed partialSups_disjointed\n\n/-- `disjointed f` is the unique sequence that is pairwise disjoint and has the same partial sups\nas `f`. -/\ntheorem disjointed_unique {f d : ℕ → α} (hdisj : Pairwise (Disjoint on d))\n    (hsups : partialSups d = partialSups f) : d = disjointed f := by\n  ext n\n  cases' n with n\n  · rw [← partialSups_zero d, hsups, partialSups_zero, disjointed_zero]\n  suffices h : d n.succ = partialSups d n.succ \\ partialSups d n\n  · rw [h, hsups, partialSups_succ, disjointed_succ, sup_sdiff, sdiff_self, bot_sup_eq]\n  rw [partialSups_succ, sup_sdiff, sdiff_self, bot_sup_eq, eq_comm, sdiff_eq_self_iff_disjoint]\n  suffices h : ∀ m ≤ n, Disjoint (partialSups d m) (d n.succ)\n  · exact h n le_rfl\n  rintro m hm\n  induction' m with m ih\n  · exact hdisj (Nat.succ_ne_zero _).symm\n  rw [partialSups_succ, disjoint_iff, inf_sup_right, sup_eq_bot_iff, ← disjoint_iff, ← disjoint_iff]\n  exact ⟨ih (Nat.le_of_succ_le hm), hdisj (Nat.lt_succ_of_le hm).ne⟩\n#align disjointed_unique disjointed_unique\n\nend GeneralizedBooleanAlgebra\n\nsection CompleteBooleanAlgebra\n\nvariable [CompleteBooleanAlgebra α]\n\ntheorem supᵢ_disjointed (f : ℕ → α) : (⨆ n, disjointed f n) = ⨆ n, f n :=\n  supᵢ_eq_supᵢ_of_partialSups_eq_partialSups (partialSups_disjointed f)\n#align supr_disjointed supᵢ_disjointed\n\ntheorem disjointed_eq_inf_compl (f : ℕ → α) (n : ℕ) : disjointed f n = f n ⊓ ⨅ i < n, f iᶜ :=\n  by\n  cases n\n  · rw [disjointed_zero, eq_comm, inf_eq_left]\n    simp_rw [le_infᵢ_iff]\n    exact fun i hi => (i.not_lt_zero hi).elim\n  simp_rw [disjointed_succ, partialSups_eq_bsupᵢ, sdiff_eq, compl_supᵢ]\n  congr\n  ext i\n  rw [Nat.lt_succ_iff]\n#align disjointed_eq_inf_compl disjointed_eq_inf_compl\n\nend CompleteBooleanAlgebra\n\n/-! ### Set notation variants of lemmas -/\n\n\ntheorem disjointed_subset (f : ℕ → Set α) (n : ℕ) : disjointed f n ⊆ f n :=\n  disjointed_le f n\n#align disjointed_subset disjointed_subset\n\ntheorem unionᵢ_disjointed {f : ℕ → Set α} : (⋃ n, disjointed f n) = ⋃ n, f n :=\n  supᵢ_disjointed f\n#align Union_disjointed unionᵢ_disjointed\n\ntheorem disjointed_eq_inter_compl (f : ℕ → Set α) (n : ℕ) : disjointed f n = f n ∩ ⋂ i < n, f iᶜ :=\n  disjointed_eq_inf_compl f n\n#align disjointed_eq_inter_compl disjointed_eq_inter_compl\n\ntheorem preimage_find_eq_disjointed (s : ℕ → Set α) (H : ∀ x, ∃ n, x ∈ s n)\n    [∀ x n, Decidable (x ∈ s n)] (n : ℕ) : (fun x => Nat.find (H x)) ⁻¹' {n} = disjointed s n :=\n  by\n  ext x\n  simp [Nat.find_eq_iff, disjointed_eq_inter_compl]\n#align preimage_find_eq_disjointed preimage_find_eq_disjointed\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Order/Disjointed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250375, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.4863351810420518}}
{"text": "/-\nCopyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Pierre-Alexandre Bazin\n\n! This file was ported from Lean 3 source module ring_theory.coprime.ideal\n! leanprover-community/mathlib commit 932872382355f00112641d305ba0619305dc8642\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.Dfinsupp\nimport Mathbin.RingTheory.Ideal.Operations\n\n/-!\n# An additional lemma about coprime ideals\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis lemma generalises `exists_sum_eq_one_iff_pairwise_coprime` to the case of non-principal ideals.\nIt is on a separate file due to import requirements.\n-/\n\n\nnamespace Ideal\n\nvariable {ι R : Type _} [CommSemiring R]\n\n/- warning: ideal.supr_infi_eq_top_iff_pairwise -> Ideal.supᵢ_infᵢ_eq_top_iff_pairwise is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] {t : Finset.{u1} ι}, (Finset.Nonempty.{u1} ι t) -> (forall (I : ι -> (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))), Iff (Eq.{succ u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (supᵢ.{u2, succ u1} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (ConditionallyCompleteLattice.toHasSup.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.completeLattice.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) ι (fun (i : ι) => supᵢ.{u2, 0} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (ConditionallyCompleteLattice.toHasSup.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.completeLattice.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i t) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i t) => infᵢ.{u2, succ u1} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.hasInf.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) ι (fun (j : ι) => infᵢ.{u2, 0} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.hasInf.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j t) (fun (hj : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j t) => infᵢ.{u2, 0} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.hasInf.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (Ne.{succ u1} ι j i) (fun (ij : Ne.{succ u1} ι j i) => I j)))))) (Top.top.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.hasTop.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Set.Pairwise.{u1} ι ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} ι) (Set.{u1} ι) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (Finset.Set.hasCoeT.{u1} ι))) t) (fun (i : ι) (j : ι) => Eq.{succ u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Sup.sup.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (SemilatticeSup.toHasSup.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (IdemSemiring.toSemilatticeSup.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.idemSemiring.{u2, u2} R _inst_1 R (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)))) (I i) (I j)) (Top.top.{u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Submodule.hasTop.{u2, u2} R R (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {t : Finset.{u2} ι}, (Finset.Nonempty.{u2} ι t) -> (forall (I : ι -> (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))), Iff (Eq.{succ u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (supᵢ.{u1, succ u2} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (ConditionallyCompleteLattice.toSupSet.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.completeLattice.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) ι (fun (i : ι) => supᵢ.{u1, 0} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (ConditionallyCompleteLattice.toSupSet.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.completeLattice.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i t) (fun (H : Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i t) => infᵢ.{u1, succ u2} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.instInfSetSubmodule.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) ι (fun (j : ι) => infᵢ.{u1, 0} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.instInfSetSubmodule.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j t) (fun (hj : Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j t) => infᵢ.{u1, 0} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.instInfSetSubmodule.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (Ne.{succ u2} ι j i) (fun (ij : Ne.{succ u2} ι j i) => I j)))))) (Top.top.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.instTopSubmodule.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Set.Pairwise.{u2} ι (Finset.toSet.{u2} ι t) (fun (i : ι) (j : ι) => Eq.{succ u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Sup.sup.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (SemilatticeSup.toSup.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (IdemCommSemiring.toSemilatticeSup.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Ideal.instIdemCommSemiringIdealToSemiring.{u1} R _inst_1))) (I i) (I j)) (Top.top.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Submodule.instTopSubmodule.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align ideal.supr_infi_eq_top_iff_pairwise Ideal.supᵢ_infᵢ_eq_top_iff_pairwiseₓ'. -/\n/-- A finite family of ideals is pairwise coprime (that is, any two of them generate the whole ring)\niff when taking all the possible intersections of all but one of these ideals, the resulting family\nof ideals still generate the whole ring.\n\nFor example with three ideals : `I ⊔ J = I ⊔ K = J ⊔ K = ⊤ ↔ (I ⊓ J) ⊔ (I ⊓ K) ⊔ (J ⊓ K) = ⊤`.\n\nWhen ideals are all of the form `I i = R ∙ s i`, this is equivalent to the\n`exists_sum_eq_one_iff_pairwise_coprime` lemma.-/\ntheorem supᵢ_infᵢ_eq_top_iff_pairwise {t : Finset ι} (h : t.Nonempty) (I : ι → Ideal R) :\n    (⨆ i ∈ t, ⨅ (j) (hj : j ∈ t) (ij : j ≠ i), I j) = ⊤ ↔\n      (t : Set ι).Pairwise fun i j => I i ⊔ I j = ⊤ :=\n  by\n  haveI : DecidableEq ι := Classical.decEq ι\n  rw [eq_top_iff_one, Submodule.mem_supᵢ_finset_iff_exists_sum]\n  refine' h.cons_induction _ _ <;> clear t h\n  · simp only [Finset.sum_singleton, Finset.coe_singleton, Set.pairwise_singleton, iff_true_iff]\n    refine' fun a => ⟨fun i => if h : i = a then ⟨1, _⟩ else 0, _⟩\n    · rw [h]\n      simp only [Finset.mem_singleton, Ne.def, infᵢ_infᵢ_eq_left, eq_self_iff_true, not_true,\n        infᵢ_false]\n    · simp only [dif_pos, dif_ctx_congr, Submodule.coe_mk, eq_self_iff_true]\n  intro a t hat h ih\n  rw [Finset.coe_cons,\n    Set.pairwise_insert_of_symmetric fun i j (h : I i ⊔ I j = ⊤) => sup_comm.trans h]\n  constructor\n  · rintro ⟨μ, hμ⟩\n    rw [Finset.sum_cons] at hμ\n    refine' ⟨ih.mp ⟨Pi.single h.some ⟨μ a, _⟩ + fun i => ⟨μ i, _⟩, _⟩, fun b hb ab => _⟩\n    · have := Submodule.coe_mem (μ a)\n      rw [mem_infi] at this⊢\n      --for some reason `simp only [mem_infi]` times out\n      intro i\n      specialize this i\n      rw [mem_infi, mem_infi] at this⊢\n      intro hi _\n      apply this (Finset.subset_cons _ hi)\n      rintro rfl\n      exact hat hi\n    · have := Submodule.coe_mem (μ i)\n      simp only [mem_infi] at this⊢\n      intro j hj ij\n      exact this _ (Finset.subset_cons _ hj) ij\n    · rw [← @if_pos _ _ h.some_spec R (μ a) 0, ← Finset.sum_pi_single', ← Finset.sum_add_distrib] at\n        hμ\n      convert hμ\n      ext i\n      rw [Pi.add_apply, Submodule.coe_add, Submodule.coe_mk]\n      by_cases hi : i = h.some\n      · rw [hi, Pi.single_eq_same, Pi.single_eq_same, Submodule.coe_mk]\n      · rw [Pi.single_eq_of_ne hi, Pi.single_eq_of_ne hi, Submodule.coe_zero]\n    · rw [eq_top_iff_one, Submodule.mem_sup]\n      rw [add_comm] at hμ\n      refine' ⟨_, _, _, _, hμ⟩\n      · refine' sum_mem _ fun x hx => _\n        have := Submodule.coe_mem (μ x)\n        simp only [mem_infi] at this\n        apply this _ (Finset.mem_cons_self _ _)\n        rintro rfl\n        exact hat hx\n      · have := Submodule.coe_mem (μ a)\n        simp only [mem_infi] at this\n        exact this _ (Finset.subset_cons _ hb) ab.symm\n  · rintro ⟨hs, Hb⟩\n    obtain ⟨μ, hμ⟩ := ih.mpr hs\n    have := sup_infi_eq_top fun b hb => Hb b hb (ne_of_mem_of_not_mem hb hat).symm\n    rw [eq_top_iff_one, Submodule.mem_sup] at this\n    obtain ⟨u, hu, v, hv, huv⟩ := this\n    refine' ⟨fun i => if hi : i = a then ⟨v, _⟩ else ⟨u * μ i, _⟩, _⟩\n    · simp only [mem_infi] at hv⊢\n      intro j hj ij\n      rw [Finset.mem_cons, ← hi] at hj\n      exact hv _ (hj.resolve_left ij)\n    · have := Submodule.coe_mem (μ i)\n      simp only [mem_infi] at this⊢\n      intro j hj ij\n      rcases finset.mem_cons.mp hj with (rfl | hj)\n      · exact mul_mem_right _ _ hu\n      · exact mul_mem_left _ _ (this _ hj ij)\n    · rw [Finset.sum_cons, dif_pos rfl, add_comm]\n      rw [← mul_one u] at huv\n      rw [← huv, ← hμ, Finset.mul_sum]\n      congr 1\n      apply Finset.sum_congr rfl\n      intro j hj\n      rw [dif_neg]\n      rfl\n      rintro rfl\n      exact hat hj\n#align ideal.supr_infi_eq_top_iff_pairwise Ideal.supᵢ_infᵢ_eq_top_iff_pairwise\n\nend Ideal\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/Coprime/Ideal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583169, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.48630275660989264}}
{"text": "import category_theory.abelian.opposite\n\nnoncomputable theory\n\nopen category_theory category_theory.limits\n\nvariables {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\n\nstructure sum_str (A B X : 𝓐) :=\n(inl : A ⟶ X)\n(inr : B ⟶ X)\n(fst : X ⟶ A)\n(snd : X ⟶ B)\n(inl_fst : inl ≫ fst = 𝟙 _)\n(inr_snd : inr ≫ snd = 𝟙 _)\n(inl_snd : inl ≫ snd = 0)\n(inr_fst : inr ≫ fst = 0)\n(total : fst ≫ inl + snd ≫ inr = 𝟙 _)\n\nnamespace sum_str\n\nvariables {A B X : 𝓐}\n\nattribute [simp, reassoc] sum_str.inl_fst sum_str.inr_snd sum_str.inl_snd sum_str.inr_fst\n\n@[simps]\ndef biprod (A B : 𝓐) : sum_str A B (A ⊞ B) :=\n{ inl := biprod.inl,\n  inr := biprod.inr,\n  fst := biprod.fst,\n  snd := biprod.snd,\n  inl_fst := biprod.inl_fst,\n  inr_snd := biprod.inr_snd,\n  inl_snd := biprod.inl_snd,\n  inr_fst := biprod.inr_fst,\n  total := biprod.total }\n\n@[simps]\ndef symm (sum : sum_str A B X) : sum_str B A X :=\n{ inl := sum.inr,\n  inr := sum.inl,\n  fst := sum.snd,\n  snd := sum.fst,\n  inl_fst := sum.inr_snd,\n  inr_snd := sum.inl_fst,\n  inl_snd := sum.inr_fst,\n  inr_fst := sum.inl_snd,\n  total := by { rw [add_comm, sum.total], } }\n\nopen category_theory.preadditive opposite\n\nsection iso\n\nvariables {X₁ X₂ : 𝓐} (S₁ : sum_str A B X₁) (S₂ : sum_str A B X₂)\n\n@[simps]\ndef iso : X₁ ≅ X₂ :=\n{ hom := S₁.fst ≫ S₂.inl + S₁.snd ≫ S₂.inr,\n  inv := S₂.fst ≫ S₁.inl + S₂.snd ≫ S₁.inr,\n  hom_inv_id' := by simp only [comp_add, add_comp_assoc, category.assoc, add_comp, inl_fst_assoc,\n    inl_snd_assoc, zero_comp, comp_zero, add_zero, inr_fst_assoc, inr_snd_assoc, zero_add, total],\n  inv_hom_id' := by simp only [comp_add, add_comp_assoc, category.assoc, add_comp, inl_fst_assoc,\n    inl_snd_assoc, zero_comp, comp_zero, add_zero, inr_fst_assoc, inr_snd_assoc, zero_add, total], }\n\nend iso\n\n@[simps]\nprotected def op (sum : sum_str A B X) : sum_str (op A) (op B) (op X) :=\n{ inl := sum.fst.op,\n  inr := sum.snd.op,\n  fst := sum.inl.op,\n  snd := sum.inr.op,\n  inl_fst := by { rw [← op_comp, sum.inl_fst, op_id] },\n  inr_snd := by { rw [← op_comp, sum.inr_snd, op_id] },\n  inl_snd := by { rw [← op_comp, sum.inr_fst, op_zero] },\n  inr_fst := by { rw [← op_comp, sum.inl_snd, op_zero] },\n  total := by { rw [← op_comp, ← op_comp, ← op_add, sum.total, op_id] } }\n\n@[simps]\nprotected def unop {A B X : 𝓐ᵒᵖ} (sum : sum_str A B X) : sum_str (unop A) (unop B) (unop X) :=\n{ inl := sum.fst.unop,\n  inr := sum.snd.unop,\n  fst := sum.inl.unop,\n  snd := sum.inr.unop,\n  inl_fst := by { rw [← unop_comp, sum.inl_fst, unop_id] },\n  inr_snd := by { rw [← unop_comp, sum.inr_snd, unop_id] },\n  inl_snd := by { rw [← unop_comp, sum.inr_fst, unop_zero] },\n  inr_fst := by { rw [← unop_comp, sum.inl_snd, unop_zero] },\n  total := by { rw [← unop_comp, ← unop_comp, ← unop_add, sum.total, unop_id] } }\n\nlemma symm_symm (sum : sum_str A B X) : sum.symm.symm = sum :=\nby { cases sum, refl }\n\nlemma op_symm (sum : sum_str A B X) : sum.symm.op = sum.op.symm :=\nby { cases sum, refl }\n\nlemma unop_symm {A B X : 𝓐ᵒᵖ} (sum : sum_str A B X) : sum.symm.unop = sum.unop.symm :=\nby { cases sum, refl }\n\nlemma unop_op (sum : sum_str A B X) : sum.op.unop = sum :=\nby { cases sum, refl }\n\nlemma op_unop {A B X : 𝓐ᵒᵖ} (sum : sum_str A B X) : sum.unop.op = sum :=\nby { cases sum, refl }\n\nend sum_str\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/sum_str.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303285397348, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.48624560450191695}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport tactic.norm_num\nimport data.fin.basic\n\n/-!\n# `ring`\n\nEvaluate expressions in the language of commutative (semi)rings.\nBased on <http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf> .\n-/\n\nnamespace tactic\nnamespace ring\n\n/-- The normal form that `ring` uses is mediated by the function `horner a x n b := a * x ^ n + b`.\nThe reason we use a definition rather than the (more readable) expression on the right is because\nthis expression contains a number of typeclass arguments in different positions, while `horner`\ncontains only one `comm_semiring` instance at the top level. See also `horner_expr` for a\ndescription of normal form. -/\ndef horner {α} [comm_semiring α] (a x : α) (n : ℕ) (b : α) := a * x ^ n + b\n\n/-- This cache contains data required by the `ring` tactic during execution. -/\nmeta structure cache :=\n(α : expr)\n(univ : level)\n(comm_semiring_inst : expr)\n(red : transparency)\n(ic : ref instance_cache)\n(nc : ref instance_cache)\n(atoms : ref (buffer expr))\n\n/-- The monad that `ring` works in. This is a reader monad containing a mutable cache (using `ref`\nfor mutability), as well as the list of atoms-up-to-defeq encountered thus far, used for atom\nsorting. -/\n@[derive [monad, alternative]]\nmeta def ring_m (α : Type) : Type :=\nreader_t cache tactic α\n\n/-- Get the `ring` data from the monad. -/\nmeta def get_cache : ring_m cache := reader_t.read\n\n/-- Get an already encountered atom by its index. -/\nmeta def get_atom (n : ℕ) : ring_m expr :=\n⟨λ c, do es ← read_ref c.atoms, pure (es.read' n)⟩\n\n/-- Get the index corresponding to an atomic expression, if it has already been encountered, or\nput it in the list of atoms and return the new index, otherwise. -/\nmeta def add_atom (e : expr) : ring_m ℕ :=\n⟨λ c, do\n  let red := c.red,\n  es ← read_ref c.atoms,\n  es.iterate failed (λ n e' t, t <|> (is_def_eq e e' red $> n)) <|>\n  (es.size <$ write_ref c.atoms (es.push_back e))⟩\n\n/-- Lift a tactic into the `ring_m` monad. -/\n@[inline] meta def lift {α} (m : tactic α) : ring_m α := reader_t.lift m\n\n/-- Run a `ring_m` tactic in the tactic monad. This version of `ring_m.run` uses an external\natoms ref, so that subexpressions can be named across multiple `ring_m` calls. -/\nmeta def ring_m.run' (red : transparency) (atoms : ref (buffer expr))\n  (e : expr) {α} (m : ring_m α) : tactic α :=\ndo α ← infer_type e,\n   u ← mk_meta_univ,\n   infer_type α >>= unify (expr.sort (level.succ u)),\n   u ← get_univ_assignment u,\n   ic ← mk_instance_cache α,\n   (ic, c) ← ic.get ``comm_semiring,\n   nc ← mk_instance_cache `(ℕ),\n   using_new_ref ic $ λ r,\n   using_new_ref nc $ λ nr,\n   reader_t.run m ⟨α, u, c, red, r, nr, atoms⟩\n\n/-- Run a `ring_m` tactic in the tactic monad. -/\nmeta def ring_m.run (red : transparency) (e : expr) {α} (m : ring_m α) : tactic α :=\nusing_new_ref mk_buffer $ λ atoms, ring_m.run' red atoms e m\n\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This version\nis abstract over the instance cache in question (either the ring `α`, or `ℕ` for exponents). -/\n@[inline] meta def ic_lift' (icf : cache → ref instance_cache) {α}\n  (f : instance_cache → tactic (instance_cache × α)) : ring_m α :=\n⟨λ c, do\n  let r := icf c,\n  ic ← read_ref r,\n  (ic', a) ← f ic,\n  a <$ write_ref r ic'⟩\n\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to the ring `α`. -/\n@[inline] meta def ic_lift {α} : (instance_cache → tactic (instance_cache × α)) → ring_m α :=\nic_lift' cache.ic\n\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to `ℕ`, which is used for computations in the exponent. -/\n@[inline] meta def nc_lift {α} : (instance_cache → tactic (instance_cache × α)) → ring_m α :=\nic_lift' cache.nc\n\n/-- Apply a theorem that expects a `comm_semiring` instance. This is a special case of\n`ic_lift mk_app`, but it comes up often because `horner` and all its theorems have this assumption;\nit also does not require the tactic monad which improves access speed a bit. -/\nmeta def cache.cs_app (c : cache) (n : name) : list expr → expr :=\n(@expr.const tt n [c.univ] c.α c.comm_semiring_inst).mk_app\n\n/-- Every expression in the language of commutative semirings can be viewed as a sum of monomials,\nwhere each monomial is a product of powers of atoms. We fix a global order on atoms (up to\ndefinitional equality), and then separate the terms according to their smallest atom. So the top\nlevel expression is `a * x^n + b` where `x` is the smallest atom and `n > 0` is a numeral, and\n`n` is maximal (so `a` contains at least one monomial not containing an `x`), and `b` contains no\nmonomials with an `x` (hence all atoms in `b` are larger than `x`).\n\nIf there is no `x` satisfying these constraints, then the expression must be a numeral. Even though\nwe are working over rings, we allow rational constants when these can be interpreted in the ring,\nso we can solve problems like `x / 3 = 1 / 3 * x` even though these are not technically in the\nlanguage of rings.\n\nThese constraints ensure that there is a unique normal form for each ring expression, and so the\nalgorithm is simply to calculate the normal form of each side and compare for equality.\n\nTo allow us to efficiently pattern match on normal forms, we maintain this inductive type that\nholds a normalized expression together with its structure. All the `expr`s in this type could be\nremoved without loss of information, and conversely the `horner_expr` structure and the `ℕ` and\n`ℚ` values can be recovered from the top level `expr`, but we keep both in order to keep proof\n producing normalization functions efficient. -/\nmeta inductive horner_expr : Type\n| const (e : expr) (coeff : ℚ) : horner_expr\n| xadd (e : expr) (a : horner_expr) (x : expr × ℕ) (n : expr × ℕ) (b : horner_expr) : horner_expr\n\n/-- Get the expression corresponding to a `horner_expr`. This can be calculated recursively from\nthe structure, but we cache the exprs in all subterms so that this function can be computed in\nconstant time. -/\nmeta def horner_expr.e : horner_expr → expr\n| (horner_expr.const e _) := e\n| (horner_expr.xadd e _ _ _ _) := e\n\n/-- Is this expr the constant `0`? -/\nmeta def horner_expr.is_zero : horner_expr → bool\n| (horner_expr.const _ c) := c = 0\n| _ := ff\n\nmeta instance : has_coe horner_expr expr := ⟨horner_expr.e⟩\nmeta instance : has_coe_to_fun horner_expr (λ _, expr → expr) := ⟨λ e, ⇑(e : expr)⟩\n\n/-- Construct a `xadd` node, generating the cached expr using the input cache. -/\nmeta def horner_expr.xadd' (c : cache) (a : horner_expr)\n  (x : expr × ℕ) (n : expr × ℕ) (b : horner_expr) : horner_expr :=\nhorner_expr.xadd (c.cs_app ``horner [a, x.1, n.1, b]) a x n b\n\nopen horner_expr\n\n/-- Pretty printer for `horner_expr`. -/\nmeta def horner_expr.to_string : horner_expr → string\n| (const e c) := to_string (e, c)\n| (xadd e a x (_, n) b) :=\n    \"(\" ++ a.to_string ++ \") * (\" ++ to_string x.1 ++ \")^\"\n        ++ to_string n ++ \" + \" ++ b.to_string\n\n/-- Pretty printer for `horner_expr`. -/\nmeta def horner_expr.pp : horner_expr → tactic format\n| (const e c) := pp (e, c)\n| (xadd e a x (_, n) b) := do\n  pa ← a.pp, pb ← b.pp, px ← pp x.1,\n  return $ \"(\" ++ pa ++ \") * (\" ++ px ++ \")^\" ++ to_string n ++ \" + \" ++ pb\n\nmeta instance : has_to_tactic_format horner_expr := ⟨horner_expr.pp⟩\n\n/-- Reflexivity conversion for a `horner_expr`. -/\nmeta def horner_expr.refl_conv (e : horner_expr) : ring_m (horner_expr × expr) :=\ndo p ← lift $ mk_eq_refl e, return (e, p)\n\ntheorem zero_horner {α} [comm_semiring α] (x n b) :\n  @horner α _ 0 x n b = b :=\nby simp [horner]\n\ntheorem horner_horner {α} [comm_semiring α] (a₁ x n₁ n₂ b n')\n  (h : n₁ + n₂ = n') :\n  @horner α _ (horner a₁ x n₁ 0) x n₂ b = horner a₁ x n' b :=\nby simp [h.symm, horner, pow_add, mul_assoc]\n\n/-- Evaluate `horner a n x b` where `a` and `b` are already in normal form. -/\nmeta def eval_horner : horner_expr → expr × ℕ → expr × ℕ → horner_expr → ring_m (horner_expr × expr)\n| ha@(const a coeff) x n b := do\n  c ← get_cache,\n  if coeff = 0 then\n    return (b, c.cs_app ``zero_horner [x.1, n.1, b])\n  else (xadd' c ha x n b).refl_conv\n| ha@(xadd a a₁ x₁ n₁ b₁) x n b := do\n  c ← get_cache,\n  if x₁.2 = x.2 ∧ b₁.e.to_nat = some 0 then do\n    (n', h) ← nc_lift $ λ nc, norm_num.prove_add_nat' nc n₁.1 n.1,\n    return (xadd' c a₁ x (n', n₁.2 + n.2) b,\n      c.cs_app ``horner_horner [a₁, x.1, n₁.1, n.1, b, n', h])\n  else (xadd' c ha x n b).refl_conv\n\ntheorem const_add_horner {α} [comm_semiring α] (k a x n b b') (h : k + b = b') :\n  k + @horner α _ a x n b = horner a x n b' :=\nby simp [h.symm, horner]; cc\n\ntheorem horner_add_const {α} [comm_semiring α] (a x n b k b') (h : b + k = b') :\n  @horner α _ a x n b + k = horner a x n b' :=\nby simp [h.symm, horner, add_assoc]\n\ntheorem horner_add_horner_lt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b')\n  (h₁ : n₁ + k = n₂) (h₂ : (a₁ + horner a₂ x k 0 : α) = a') (h₃ : b₁ + b₂ = b') :\n  @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₁ b' :=\nby simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]; cc\n\ntheorem horner_add_horner_gt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b')\n  (h₁ : n₂ + k = n₁) (h₂ : (horner a₁ x k 0 + a₂ : α) = a') (h₃ : b₁ + b₂ = b') :\n  @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₂ b' :=\nby simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]; cc\n\ntheorem horner_add_horner_eq {α} [comm_semiring α] (a₁ x n b₁ a₂ b₂ a' b' t)\n  (h₁ : a₁ + a₂ = a') (h₂ : b₁ + b₂ = b') (h₃ : horner a' x n b' = t) :\n  @horner α _ a₁ x n b₁ + horner a₂ x n b₂ = t :=\nby simp [h₃.symm, h₂.symm, h₁.symm, horner, add_mul, mul_comm (x ^ n)]; cc\n\n/-- Evaluate `a + b` where `a` and `b` are already in normal form. -/\nmeta def eval_add : horner_expr → horner_expr → ring_m (horner_expr × expr)\n| (const e₁ c₁) (const e₂ c₂) := ic_lift $ λ ic, do\n  let n := c₁ + c₂,\n  (ic, e) ← ic.of_rat n,\n  (ic, p) ← norm_num.prove_add_rat ic e₁ e₂ e c₁ c₂ n,\n  return (ic, const e n, p)\n| he₁@(const e₁ c₁) he₂@(xadd e₂ a x n b) := do\n  c ← get_cache,\n  if c₁ = 0 then ic_lift $ λ ic, do\n    (ic, p) ← ic.mk_app ``zero_add [e₂],\n    return (ic, he₂, p)\n  else do\n    (b', h) ← eval_add he₁ b,\n    return (xadd' c a x n b',\n      c.cs_app ``const_add_horner [e₁, a, x.1, n.1, b, b', h])\n| he₁@(xadd e₁ a x n b) he₂@(const e₂ c₂) := do\n  c ← get_cache,\n  if c₂ = 0 then ic_lift $ λ ic, do\n    (ic, p) ← ic.mk_app ``add_zero [e₁],\n    return (ic, he₁, p)\n  else do\n    (b', h) ← eval_add b he₂,\n    return (xadd' c a x n b',\n      c.cs_app ``horner_add_const [a, x.1, n.1, b, e₂, b', h])\n| he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) := do\n  c ← get_cache,\n  if x₁.2 < x₂.2 then do\n    (b', h) ← eval_add b₁ he₂,\n    return (xadd' c a₁ x₁ n₁ b',\n      c.cs_app ``horner_add_const [a₁, x₁.1, n₁.1, b₁, e₂, b', h])\n  else if x₁.2 ≠ x₂.2 then do\n    (b', h) ← eval_add he₁ b₂,\n    return (xadd' c a₂ x₂ n₂ b',\n      c.cs_app ``const_add_horner [e₁, a₂, x₂.1, n₂.1, b₂, b', h])\n  else if n₁.2 < n₂.2 then do\n    let k := n₂.2 - n₁.2,\n    (ek, h₁) ← nc_lift (λ nc, do\n      (nc, ek) ← nc.of_nat k,\n      (nc, h₁) ← norm_num.prove_add_nat nc n₁.1 ek n₂.1,\n      return (nc, ek, h₁)),\n    α0 ← ic_lift $ λ ic, ic.mk_app ``has_zero.zero [],\n    (a', h₂) ← eval_add a₁ (xadd' c a₂ x₁ (ek, k) (const α0 0)),\n    (b', h₃) ← eval_add b₁ b₂,\n    return (xadd' c a' x₁ n₁ b',\n      c.cs_app ``horner_add_horner_lt [a₁, x₁.1, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃])\n  else if n₁.2 ≠ n₂.2 then do\n    let k := n₁.2 - n₂.2,\n    (ek, h₁) ← nc_lift (λ nc, do\n      (nc, ek) ← nc.of_nat k,\n      (nc, h₁) ← norm_num.prove_add_nat nc n₂.1 ek n₁.1,\n      return (nc, ek, h₁)),\n    α0 ← ic_lift $ λ ic, ic.mk_app ``has_zero.zero [],\n    (a', h₂) ← eval_add (xadd' c a₁ x₁ (ek, k) (const α0 0)) a₂,\n    (b', h₃) ← eval_add b₁ b₂,\n    return (xadd' c a' x₁ n₂ b',\n      c.cs_app ``horner_add_horner_gt [a₁, x₁.1, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃])\n  else do\n    (a', h₁) ← eval_add a₁ a₂,\n    (b', h₂) ← eval_add b₁ b₂,\n    (t, h₃) ← eval_horner a' x₁ n₁ b',\n    return (t, c.cs_app ``horner_add_horner_eq\n      [a₁, x₁.1, n₁.1, b₁, a₂, b₂, a', b', t, h₁, h₂, h₃])\n\ntheorem horner_neg {α} [comm_ring α] (a x n b a' b')\n  (h₁ : -a = a') (h₂ : -b = b') :\n  -@horner α _ a x n b = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner]; cc\n\n/-- Evaluate `-a` where `a` is already in normal form. -/\nmeta def eval_neg : horner_expr → ring_m (horner_expr × expr)\n| (const e coeff) := do\n  (e', p) ← ic_lift $ λ ic, norm_num.prove_neg ic e,\n  return (const e' (-coeff), p)\n| (xadd e a x n b) := do\n  c ← get_cache,\n  (a', h₁) ← eval_neg a,\n  (b', h₂) ← eval_neg b,\n  p ← ic_lift $ λ ic, ic.mk_app ``horner_neg [a, x.1, n.1, b, a', b', h₁, h₂],\n  return (xadd' c a' x n b', p)\n\ntheorem horner_const_mul {α} [comm_semiring α] (c a x n b a' b')\n  (h₁ : c * a = a') (h₂ : c * b = b') :\n  c * @horner α _ a x n b = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner, mul_add, mul_assoc]\n\ntheorem horner_mul_const {α} [comm_semiring α] (a x n b c a' b')\n  (h₁ : a * c = a') (h₂ : b * c = b') :\n  @horner α _ a x n b * c = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner, add_mul, mul_right_comm]\n\n/-- Evaluate `k * a` where `k` is a rational numeral and `a` is in normal form. -/\nmeta def eval_const_mul (k : expr × ℚ) :\n  horner_expr → ring_m (horner_expr × expr)\n| (const e coeff) := do\n  (e', p) ← ic_lift $ λ ic, norm_num.prove_mul_rat ic k.1 e k.2 coeff,\n  return (const e' (k.2 * coeff), p)\n| (xadd e a x n b) := do\n  c ← get_cache,\n  (a', h₁) ← eval_const_mul a,\n  (b', h₂) ← eval_const_mul b,\n  return (xadd' c a' x n b',\n    c.cs_app ``horner_const_mul [k.1, a, x.1, n.1, b, a', b', h₁, h₂])\n\ntheorem horner_mul_horner_zero {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ aa t)\n  (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa)\n  (h₂ : horner aa x n₂ 0 = t) :\n  horner a₁ x n₁ b₁ * horner a₂ x n₂ 0 = t :=\nby rw [← h₂, ← h₁];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\ntheorem horner_mul_horner {α} [comm_semiring α]\n  (a₁ x n₁ b₁ a₂ n₂ b₂ aa haa ab bb t)\n  (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa)\n  (h₂ : horner aa x n₂ 0 = haa)\n  (h₃ : a₁ * b₂ = ab) (h₄ : b₁ * b₂ = bb)\n  (H : haa + horner ab x n₁ bb = t) :\n  horner a₁ x n₁ b₁ * horner a₂ x n₂ b₂ = t :=\nby rw [← H, ← h₂, ← h₁, ← h₃, ← h₄];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\n/-- Evaluate `a * b` where `a` and `b` are in normal form. -/\nmeta def eval_mul : horner_expr → horner_expr → ring_m (horner_expr × expr)\n| (const e₁ c₁) (const e₂ c₂) := do\n  (e', p) ← ic_lift $ λ ic, norm_num.prove_mul_rat ic e₁ e₂ c₁ c₂,\n  return (const e' (c₁ * c₂), p)\n| (const e₁ c₁) e₂ :=\n  if c₁ = 0 then do\n    c ← get_cache,\n    α0 ← ic_lift $ λ ic, ic.mk_app ``has_zero.zero [],\n    p ← ic_lift $ λ ic, ic.mk_app ``zero_mul [e₂],\n    return (const α0 0, p)\n  else if c₁ = 1 then do\n    p ← ic_lift $ λ ic, ic.mk_app ``one_mul [e₂],\n    return (e₂, p)\n  else eval_const_mul (e₁, c₁) e₂\n| e₁ he₂@(const e₂ c₂) := do\n  p₁ ← ic_lift $ λ ic, ic.mk_app ``mul_comm [e₁, e₂],\n  (e', p₂) ← eval_mul he₂ e₁,\n  p ← lift $ mk_eq_trans p₁ p₂, return (e', p)\n| he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) := do\n  c ← get_cache,\n  if x₁.2 < x₂.2 then do\n    (a', h₁) ← eval_mul a₁ he₂,\n    (b', h₂) ← eval_mul b₁ he₂,\n    return (xadd' c a' x₁ n₁ b',\n      c.cs_app ``horner_mul_const [a₁, x₁.1, n₁.1, b₁, e₂, a', b', h₁, h₂])\n  else if x₁.2 ≠ x₂.2 then do\n    (a', h₁) ← eval_mul he₁ a₂,\n    (b', h₂) ← eval_mul he₁ b₂,\n    return (xadd' c a' x₂ n₂ b',\n      c.cs_app ``horner_const_mul [e₁, a₂, x₂.1, n₂.1, b₂, a', b', h₁, h₂])\n  else do\n    (aa, h₁) ← eval_mul he₁ a₂,\n    α0 ← ic_lift $ λ ic, ic.mk_app ``has_zero.zero [],\n    (haa, h₂) ← eval_horner aa x₁ n₂ (const α0 0),\n    if b₂.is_zero then\n      return (haa, c.cs_app ``horner_mul_horner_zero\n        [a₁, x₁.1, n₁.1, b₁, a₂, n₂.1, aa, haa, h₁, h₂])\n    else do\n      (ab, h₃) ← eval_mul a₁ b₂,\n      (bb, h₄) ← eval_mul b₁ b₂,\n      (t, H) ← eval_add haa (xadd' c ab x₁ n₁ bb),\n      return (t, c.cs_app ``horner_mul_horner\n        [a₁, x₁.1, n₁.1, b₁, a₂, n₂.1, b₂, aa, haa, ab, bb, t, h₁, h₂, h₃, h₄, H])\n\ntheorem horner_pow {α} [comm_semiring α] (a x n m n' a') (h₁ : n * m = n') (h₂ : a ^ m = a') :\n  @horner α _ a x n 0 ^ m = horner a' x n' 0 :=\nby simp [h₁.symm, h₂.symm, horner, mul_pow, pow_mul]\n\ntheorem pow_succ {α} [comm_semiring α] (a n b c)\n  (h₁ : (a:α) ^ n = b) (h₂ : b * a = c) : a ^ (n + 1) = c :=\nby rw [← h₂, ← h₁, pow_succ']\n\n/-- Evaluate `a ^ n` where `a` is in normal form and `n` is a natural numeral. -/\nmeta def eval_pow : horner_expr → expr × ℕ → ring_m (horner_expr × expr)\n| e (_, 0) := do\n  c ← get_cache,\n  α1 ← ic_lift $ λ ic, ic.mk_app ``has_one.one [],\n  p ← ic_lift $ λ ic, ic.mk_app ``pow_zero [e],\n  return (const α1 1, p)\n| e (_, 1) := do\n  p ← ic_lift $ λ ic, ic.mk_app ``pow_one [e],\n  return (e, p)\n| (const e coeff) (e₂, m) := ic_lift $ λ ic, do\n  (ic, e', p) ← norm_num.prove_pow e coeff ic e₂,\n  return (ic, const e' (coeff ^ m), p)\n| he@(xadd e a x n b) m := do\n  c ← get_cache,\n  match b.e.to_nat with\n  | some 0 := do\n    (n', h₁) ← nc_lift $ λ nc, norm_num.prove_mul_rat nc n.1 m.1 n.2 m.2,\n    (a', h₂) ← eval_pow a m,\n    α0 ← ic_lift $ λ ic, ic.mk_app ``has_zero.zero [],\n    return (xadd' c a' x (n', n.2 * m.2) (const α0 0),\n      c.cs_app ``horner_pow [a, x.1, n.1, m.1, n', a', h₁, h₂])\n  | _ := do\n    e₂ ← nc_lift $ λ nc, nc.of_nat (m.2-1),\n    (tl, hl) ← eval_pow he (e₂, m.2-1),\n    (t, p₂) ← eval_mul tl he,\n    return (t, c.cs_app ``pow_succ [e, e₂, tl, t, hl, p₂])\n  end\n\ntheorem horner_atom {α} [comm_semiring α] (x : α) : x = horner 1 x 1 0 :=\nby simp [horner]\n\n/-- Evaluate `a` where `a` is an atom. -/\nmeta def eval_atom (e : expr) : ring_m (horner_expr × expr) :=\ndo c ← get_cache,\n  i ← add_atom e,\n  α0 ← ic_lift $ λ ic, ic.mk_app ``has_zero.zero [],\n  α1 ← ic_lift $ λ ic, ic.mk_app ``has_one.one [],\n  return (xadd' c (const α1 1) (e, i) (`(1), 1) (const α0 0),\n    c.cs_app ``horner_atom [e])\n\n/-- Evaluate `a` where `a` is an atom. -/\nmeta def eval_norm_atom (norm_atom : expr → tactic (expr × expr))\n  (e : expr) : ring_m (horner_expr × expr) :=\ndo o ← lift $ try_core (guard (e.get_app_args.length > 0) >> norm_atom e),\n  match o with\n  | none := eval_atom e\n  | some (e', p) := do\n    (e₂, p₂) ← eval_atom e',\n    prod.mk e₂ <$> lift (mk_eq_trans p p₂)\n  end\n\nlemma subst_into_pow {α} [monoid α] (l r tl tr t)\n  (prl : (l : α) = tl) (prr : (r : ℕ) = tr) (prt : tl ^ tr = t) : l ^ r = t :=\nby rw [prl, prr, prt]\n\nlemma unfold_sub {α} [add_group α] (a b c : α)\n  (h : a + -b = c) : a - b = c :=\nby rw [sub_eq_add_neg, h]\n\nlemma unfold_div {α} [division_ring α] (a b c : α)\n  (h : a * b⁻¹ = c) : a / b = c :=\nby rw [div_eq_mul_inv, h]\n\n/-- Evaluate a ring expression `e` recursively to normal form, together with a proof of\nequality. -/\nmeta def eval (norm_atom : expr → tactic (expr × expr)) : expr → ring_m (horner_expr × expr)\n| `(%%e₁ + %%e₂) := do\n  (e₁', p₁) ← eval e₁,\n  (e₂', p₂) ← eval e₂,\n  (e', p') ← eval_add e₁' e₂',\n  p ← ic_lift $ λ ic, ic.mk_app ``norm_num.subst_into_add [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n  return (e', p)\n| e@`(@has_sub.sub %%α %%inst %%e₁ %%e₂) :=\n  mcond (succeeds (lift $ mk_app ``comm_ring [α] >>= mk_instance))\n    (do\n      e₂' ← ic_lift $ λ ic, ic.mk_app ``has_neg.neg [e₂],\n      e ← ic_lift $ λ ic, ic.mk_app ``has_add.add [e₁, e₂'],\n      (e', p) ← eval e,\n      p' ← ic_lift $ λ ic, ic.mk_app ``unfold_sub [e₁, e₂, e', p],\n      return (e', p'))\n    (eval_norm_atom norm_atom e)\n| `(- %%e) := do\n  (e₁, p₁) ← eval e,\n  (e₂, p₂) ← eval_neg e₁,\n  p ← ic_lift $ λ ic, ic.mk_app ``norm_num.subst_into_neg [e, e₁, e₂, p₁, p₂],\n  return (e₂, p)\n| `(%%e₁ * %%e₂) := do\n  (e₁', p₁) ← eval e₁,\n  (e₂', p₂) ← eval e₂,\n  (e', p') ← eval_mul e₁' e₂',\n  p ← ic_lift $ λ ic, ic.mk_app ``norm_num.subst_into_mul [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n  return (e', p)\n| e@`(has_inv.inv %%_) := (do\n    (e', p) ← lift $ norm_num.derive e <|> refl_conv e,\n    n ← lift $ e'.to_rat,\n    return (const e' n, p)) <|> eval_norm_atom norm_atom e\n| e@`(@has_div.div _ %%inst %%e₁ %%e₂) := mcond\n  (succeeds (do\n    inst' ← ic_lift $ λ ic, ic.mk_app ``div_inv_monoid.to_has_div [],\n    lift $ is_def_eq inst inst'))\n  (do\n    e₂' ← ic_lift $ λ ic, ic.mk_app ``has_inv.inv [e₂],\n    e ← ic_lift $ λ ic, ic.mk_app ``has_mul.mul [e₁, e₂'],\n    (e', p) ← eval e,\n    p' ← ic_lift $ λ ic, ic.mk_app ``unfold_div [e₁, e₂, e', p],\n    return (e', p'))\n  (eval_norm_atom norm_atom e)\n| e@`(@has_pow.pow _ _ %%inst %%e₁ %%e₂) := mcond\n  (succeeds (do\n    inst' ← ic_lift $ λ ic, ic.mk_app ``monoid.has_pow [],\n    lift $ is_def_eq inst inst'))\n  (do\n    (e₂', p₂) ← lift $ norm_num.derive e₂ <|> refl_conv e₂,\n    match e₂'.to_nat with\n    | some k := do\n      (e₁', p₁) ← eval e₁,\n      (e', p') ← eval_pow e₁' (e₂, k),\n      p ← ic_lift $ λ ic, ic.mk_app ``subst_into_pow [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n      return (e', p)\n    | _ := eval_norm_atom norm_atom e\n    end)\n  (eval_norm_atom norm_atom e)\n| e := match e.to_nat with\n  | some n := (const e n).refl_conv\n  | none := eval_norm_atom norm_atom e\n  end\n\n/-- Evaluate a ring expression `e` recursively to normal form, together with a proof of\nequality. -/\nmeta def eval' (red : transparency) (atoms : ref (buffer expr))\n  (norm_atom : expr → tactic (expr × expr)) (e : expr) : tactic (expr × expr) :=\nring_m.run' red atoms e $ do (e', p) ← eval norm_atom e, return (e', p)\n\ntheorem horner_def' {α} [comm_semiring α] (a x n b) : @horner α _ a x n b = x ^ n * a + b :=\nby simp [horner, mul_comm]\n\ntheorem mul_assoc_rev {α} [semigroup α] (a b c : α) : a * (b * c) = a * b * c :=\nby simp [mul_assoc]\n\ntheorem pow_add_rev {α} [monoid α] (a : α) (m n : ℕ) : a ^ m * a ^ n = a ^ (m + n) :=\nby simp [pow_add]\n\ntheorem pow_add_rev_right {α} [monoid α] (a b : α) (m n : ℕ) :\n  b * a ^ m * a ^ n = b * a ^ (m + n) :=\nby simp [pow_add, mul_assoc]\n\ntheorem add_neg_eq_sub {α} [add_group α] (a b : α) : a + -b = a - b := (sub_eq_add_neg a b).symm\n\n/-- If `ring` fails to close the goal, it falls back on normalizing the expression to a \"pretty\"\nform so that you can see why it failed. This setting adjusts the resulting form:\n\n  * `raw` is the form that `ring` actually uses internally, with iterated applications of `horner`.\n    Not very readable but useful if you don't want any postprocessing.\n    This results in terms like `horner (horner (horner 3 y 1 0) x 2 1) x 1 (horner 1 y 1 0)`.\n  * `horner` maintains the Horner form structure, but it unfolds the `horner` definition itself,\n    and tries to otherwise minimize parentheses.\n    This results in terms like `(3 * x ^ 2 * y + 1) * x + y`.\n  * `SOP` means sum of products form, expanding everything to monomials.\n    This results in terms like `3 * x ^ 3 * y + x + y`. -/\n@[derive [has_reflect, decidable_eq]]\ninductive normalize_mode | raw | SOP | horner\n\ninstance : inhabited normalize_mode := ⟨normalize_mode.horner⟩\n\n/-- A `ring`-based normalization simplifier that rewrites ring expressions into the specified mode.\nSee `normalize`. This version takes a list of atoms to persist across multiple calls.\n\n* `atoms`: a mutable reference containing the atom set from the previous call\n* `red`: the reducibility setting to use when comparing atoms for defeq\n* `mode`: the normalization style (see `normalize_mode`)\n* `recursive`: if true, atoms will be reduced recursively using `normalize'`\n* `e`: the expression to normalize\n* `inner`: This should be set to `ff`. It is used internally to disable normalization\n  at the top level when called from `eval` in order to prevent an infinite loop\n  `eval' -> eval_atom -> normalize' -> eval'` when called on something that can't\n  be simplified like `x`.\n-/\nmeta def normalize' (atoms : ref (buffer expr))\n  (red : transparency) (mode := normalize_mode.horner) (recursive := tt) :\n  expr → opt_param _ ff → tactic (expr × expr)\n| e inner := do\n  pow_lemma ← simp_lemmas.mk.add_simp ``pow_one,\n  let lemmas := match mode with\n  | normalize_mode.SOP :=\n    [``horner_def', ``add_zero, ``mul_one, ``mul_add, ``mul_sub,\n    ``mul_assoc_rev, ``pow_add_rev, ``pow_add_rev_right,\n    ``mul_neg, ``add_neg_eq_sub]\n  | normalize_mode.horner :=\n    [``horner.equations._eqn_1, ``add_zero, ``one_mul, ``pow_one,\n    ``neg_mul, ``add_neg_eq_sub]\n  | _ := []\n  end,\n  lemmas ← lemmas.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n  trans_conv\n    (λ e, do\n      guard (mode ≠ normalize_mode.raw),\n      (e', pr, _) ← simplify simp_lemmas.mk [] e,\n      pure (e', pr))\n    (λ e, do\n      a ← read_ref atoms,\n      let norm_rec := if recursive then λ e, normalize' e tt else λ _, failed,\n      (a, e', pr) ← ext_simplify_core a {}\n        simp_lemmas.mk (λ _, failed) (λ a _ _ p e, do\n          guard (inner → p.is_some),\n          write_ref atoms a,\n          (new_e, pr) ← eval' red atoms norm_rec e,\n          (new_e, pr) ← match mode with\n          | normalize_mode.raw := λ _, pure (new_e, pr)\n          | normalize_mode.horner := trans_conv (λ _, pure (new_e, pr))\n            (λ e, do (e', prf, _) ← simplify lemmas [] e, pure (e', prf))\n          | normalize_mode.SOP :=\n            trans_conv (λ _, pure (new_e, pr)) $\n            trans_conv (λ e, do (e', prf, _) ← simplify lemmas [] e, pure (e', prf)) $\n            simp_bottom_up' (λ e, norm_num.derive e <|> pow_lemma.rewrite e)\n          end e,\n          guard (¬ new_e =ₐ e),\n          a ← read_ref atoms,\n          pure (a, new_e, some pr, ff))\n        (λ _ _ _ _ _, failed) `eq e,\n      write_ref atoms a,\n      pure (e', pr))\n    e\n\n/-- A `ring`-based normalization simplifier that rewrites ring expressions into the specified mode.\n\n  * `raw` is the form that `ring` actually uses internally, with iterated applications of `horner`.\n    Not very readable but useful if you don't want any postprocessing.\n    This results in terms like `horner (horner (horner 3 y 1 0) x 2 1) x 1 (horner 1 y 1 0)`.\n  * `horner` maintains the Horner form structure, but it unfolds the `horner` definition itself,\n    and tries to otherwise minimize parentheses.\n    This results in terms like `(3 * x ^ 2 * y + 1) * x + y`.\n  * `SOP` means sum of products form, expanding everything to monomials.\n    This results in terms like `3 * x ^ 3 * y + x + y`. -/\nmeta def normalize (red : transparency) (mode := normalize_mode.horner)\n  (recursive := tt) (e : expr) : tactic (expr × expr) :=\nusing_new_ref mk_buffer $ λ atoms, normalize' atoms red mode recursive e\n\n/-- Configuration for `ring_nf`.\n\n  * `recursive`: if true, atoms inside ring expressions will be reduced recursively\n-/\n@[derive inhabited] structure ring_nf_cfg := (recursive := tt)\n\nend ring\n\nnamespace interactive\n\nopen tactic.ring\n\nsetup_tactic_parser\n\n/-- Tactic for solving equations in the language of *commutative* (semi)rings.\n  This version of `ring` fails if the target is not an equality\n  that is provable by the axioms of commutative (semi)rings. -/\nmeta def ring1 (red : parse (tk \"!\")?) : tactic unit :=\nlet transp := if red.is_some then semireducible else reducible in\ndo `(%%e₁ = %%e₂) ← target >>= instantiate_mvars,\n  ((e₁', p₁), (e₂', p₂)) ← ring_m.run transp e₁ $\n    prod.mk <$> eval (λ _, failed) e₁ <*> eval (λ _, failed) e₂,\n  is_def_eq e₁' e₂',\n  p ← mk_eq_symm p₂ >>= mk_eq_trans p₁,\n  tactic.exact p\n\n/-- Parser for `ring_nf`'s `mode` argument, which can only be the \"keywords\" `raw`, `horner` or\n`SOP`. (Because these are not actually keywords we use a name parser and postprocess the result.)\n-/\nmeta def ring.mode : lean.parser ring.normalize_mode :=\nwith_desc \"(SOP|raw|horner)?\" $\ndo mode ← ident?, match mode with\n| none         := pure ring.normalize_mode.horner\n| some `horner := pure ring.normalize_mode.horner\n| some `SOP    := pure ring.normalize_mode.SOP\n| some `raw    := pure ring.normalize_mode.raw\n| _            := failed\nend\n\n/-- Simplification tactic for expressions in the language of commutative (semi)rings,\nwhich rewrites all ring expressions into a normal form. When writing a normal form,\n`ring_nf SOP` will use sum-of-products form instead of horner form.\n`ring_nf!` will use a more aggressive reducibility setting to identify atoms.\n-/\nmeta def ring_nf (red : parse (tk \"!\")?) (SOP : parse ring.mode) (loc : parse location)\n  (cfg : ring_nf_cfg := {}) : tactic unit :=\ndo ns ← loc.get_locals,\n   let transp := if red.is_some then semireducible else reducible,\n   tt ← using_new_ref mk_buffer $ λ atoms,\n     tactic.replace_at (normalize' atoms transp SOP cfg.recursive) ns loc.include_goal\n   | fail \"ring_nf failed to simplify\",\n   when loc.include_goal $ try tactic.reflexivity\n\n/-- Tactic for solving equations in the language of *commutative* (semi)rings.\n`ring!` will use a more aggressive reducibility setting to identify atoms.\n\nIf the goal is not solvable, it falls back to rewriting all ring expressions\ninto a normal form, with a suggestion to use `ring_nf` instead, if this is the intent.\nSee also `ring1`, which is the same as `ring` but without the fallback behavior.\n\nBased on [Proving Equalities in a Commutative Ring Done Right\nin Coq](http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf) by Benjamin Grégoire\nand Assia Mahboubi.\n-/\nmeta def ring (red : parse (tk \"!\")?) : tactic unit :=\nring1 red <|>\n(ring_nf red normalize_mode.horner (loc.ns [none]) >> trace \"Try this: ring_nf\")\n\nadd_hint_tactic \"ring\"\n\nadd_tactic_doc\n{ name        := \"ring\",\n  category    := doc_category.tactic,\n  decl_names  := [``ring, ``ring_nf, ``ring1],\n  inherit_description_from := ``ring,\n  tags        := [\"arithmetic\", \"simplification\", \"decision procedure\"] }\n\nend interactive\nend tactic\n\nnamespace conv.interactive\nopen conv interactive\nopen tactic tactic.interactive (ring.mode ring1)\nopen tactic.ring (normalize normalize_mode.horner)\n\nlocal postfix (name := parser.optional) `?`:9001 := optional\n\n/--\nNormalises expressions in commutative (semi-)rings inside of a `conv` block using the tactic `ring`.\n-/\nmeta def ring_nf (red : parse (lean.parser.tk \"!\")?) (SOP : parse ring.mode)\n  (cfg : ring.ring_nf_cfg := {}) : conv unit :=\nlet transp := if red.is_some then semireducible else reducible in\nreplace_lhs (normalize transp SOP cfg.recursive)\n<|> fail \"ring_nf failed to simplify\"\n\n/--\nNormalises expressions in commutative (semi-)rings inside of a `conv` block using the tactic `ring`.\n-/\nmeta def ring (red : parse (lean.parser.tk \"!\")?) : conv unit :=\nlet transp := if red.is_some then semireducible else reducible in\ndischarge_eq_lhs (ring1 red)\n<|> (replace_lhs (normalize transp normalize_mode.horner) >> trace \"Try this: ring_nf\")\n<|> fail \"ring failed to simplify\"\n\nend conv.interactive\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/tactic/ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303137346446, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.48624559539548573}}
{"text": "import category_theory.category\n\ninductive bwd (α : Type) : Type\n| emp {} : bwd\n| snoc : bwd → α → bwd\n\nnotation `ε` := @bwd.emp _\ninfixl `≪`:5 := @bwd.snoc _\nnotation `⟪` l:(foldl `, ` (h t, (t ≪ h)) ε `⟫`) := l\n\n@[simp]\ndef append {α} : bwd α → list α → bwd α\n| xs [] := xs\n| xs (y :: ys) := append (xs ≪ y) ys\n\ninfixl `⋉`:3 := append\n\n\n\ndef fam (α : Type) := α → Type\n\n\n\n/-- Thinnings -/\ninductive thn {α} : bwd α → bwd α → Type\n| emp {} : thn ⟪⟫ ⟪⟫\n| cong {Γ Δ τ} : thn Γ Δ → thn (Γ ≪ τ) (Δ ≪ τ)\n| drop {Γ Δ τ} : thn Γ Δ → thn (Γ ≪ τ) Δ\n\ninfixr `⇾`:30 := @thn _\ninfixl `≤` := @thn _\n\ndef idn {α} : Π (Γ : bwd α), Γ ⇾ Γ\n| bwd.emp := thn.emp\n| (bwd.snoc Γ _) := thn.cong (idn Γ)\n\ndef seq {α} : Π {Γ Δ Ξ : bwd α}, Γ ⇾ Δ → Δ ⇾ Ξ → Γ ⇾ Ξ\n| _ _ _ thn.emp thn.emp := thn.emp\n| _ _ _ (thn.cong δ) (thn.cong ξ) := thn.cong (seq δ ξ)\n| _ _ _ (thn.cong δ) (thn.drop ξ) := thn.drop (seq δ ξ)\n| _ _ _ (thn.drop δ) ξ := thn.drop (seq δ ξ)\n\ntheorem seq_left_idn {α} : Π {Γ Δ : bwd α} (γ : Δ ⇾ Γ), seq (idn _) γ = γ\n| _ _ thn.emp := by refl\n| _ _ (thn.cong ξ) :=\n  begin\n    unfold idn seq,\n    rewrite (seq_left_idn ξ)\n  end\n| _ _ (thn.drop ξ) :=\n  begin\n    unfold idn seq,\n    rewrite (seq_left_idn ξ)\n  end\n\n\n\ninductive arity (α : Type) : Type\n| mk : list arity → α → arity\n\ndef sig (α : Type) := fam (arity α)\ninfixl `▶`:3 := arity.mk\n\n\n\n/-- the clone (type of terms) and type of substitutions -/\nmutual inductive cn, sb {α} (𝔖 : sig α)\nwith cn : bwd (arity α) → α → Type\n| opr {Γ Δ τ} : 𝔖 (Δ ▶ τ) → sb Γ Δ → cn Γ τ\n| var {Γ Δ τ} : Γ ⇾ ⟪ Δ ▶ τ ⟫ → sb Γ Δ → cn Γ τ\nwith sb : bwd (arity α) → list (arity α) → Type\n| nil {Γ} : sb Γ []\n| cons {Γ Ξ Δ τ} : cn (Γ ⋉ Δ) τ → sb Γ Ξ → sb Γ ((Δ ▶ τ) :: Ξ)\n\n\nnamespace lambda_calculus\n  inductive sort : Type\n  | chk\n  | syn\n\n  open sort\n\n  inductive LAM : arity sort → Type\n  | lam : LAM ([[[] ▶ syn] ▶ chk] ▶ chk)\n  | app : LAM ([[] ▶ syn, [] ▶ chk] ▶ syn)\n  | up : LAM ([[] ▶ syn] ▶ chk)\n\n  infix `∙`:5 := cn.opr\n\n  notation `⦃` l:(foldr `, ` (h t, (sb.cons h t)) (sb.nil _) `⦄`) := l\n\n  notation `ƛ` t := LAM.lam ∙ ⦃ t ⦄\n\n  notation ξ `#` γ := cn.var ξ γ\n  notation `⇑` t := LAM.up ∙ ⦃ t ⦄\n  notation `x₀` := thn.cong thn.emp\n\n  def tm (Γ : bwd (arity sort)) := cn LAM Γ chk\n\n\n  -- identity function\n  def foo : _ :=\n    ƛ ⇑ (x₀ # ⦃⦄)\n\nend lambda_calculus\n", "meta": {"author": "jonsterling", "repo": "lean-syntax", "sha": "a8e3483cc88df3e5ed22d59a1d52f14df8a49885", "save_path": "github-repos/lean/jonsterling-lean-syntax", "path": "github-repos/lean/jonsterling-lean-syntax/lean-syntax-a8e3483cc88df3e5ed22d59a1d52f14df8a49885/src/sig.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324848629214, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.48623167588392086}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\nimport measure_theory.function.lp_space\nimport analysis.normed_space.lattice_ordered_group\n\n/-!\n# Order related properties of Lp spaces\n\n### Results\n\n- `Lp E p μ` is an `ordered_add_comm_group` when `E` is a `normed_lattice_add_comm_group`.\n\n### TODO\n\n- move definitions of `Lp.pos_part` and `Lp.neg_part` to this file, and define them as\n  `has_pos_part.pos` and `has_pos_part.neg` given by the lattice structure.\n- show that if `E` is a `normed_lattice_add_comm_group` then so is `Lp E p μ` for `1 ≤ p`. In\n  particular, this shows `order_closed_topology` for `Lp`.\n\n-/\n\nopen topological_space measure_theory lattice_ordered_comm_group\nopen_locale ennreal\n\nvariables {α E : Type*} {m : measurable_space α} {μ : measure α} {p : ℝ≥0∞}\n\nnamespace measure_theory\nnamespace Lp\n\nsection order\nvariables [normed_lattice_add_comm_group E] [measurable_space E] [borel_space E]\n  [second_countable_topology E]\n\nlemma coe_fn_le (f g : Lp E p μ) : f ≤ᵐ[μ] g ↔ f ≤ g :=\nby rw [← subtype.coe_le_coe, ← ae_eq_fun.coe_fn_le, ← coe_fn_coe_base, ← coe_fn_coe_base]\n\nlemma coe_fn_nonneg (f : Lp E p μ) : 0 ≤ᵐ[μ] f ↔ 0 ≤ f :=\nbegin\n  rw ← coe_fn_le,\n  have h0 := Lp.coe_fn_zero E p μ,\n  split; intro h; filter_upwards [h, h0] with _ _ h2,\n  { rwa h2, },\n  { rwa ← h2, },\nend\n\ninstance : covariant_class (Lp E p μ) (Lp E p μ) (+) (≤) :=\nbegin\n  refine ⟨λ f g₁ g₂ hg₁₂, _⟩,\n  rw ← coe_fn_le at hg₁₂ ⊢,\n  filter_upwards [coe_fn_add f g₁, coe_fn_add f g₂, hg₁₂] with _ h1 h2 h3,\n  rw [h1, h2, pi.add_apply, pi.add_apply],\n  exact add_le_add le_rfl h3,\nend\n\ninstance : ordered_add_comm_group (Lp E p μ) :=\n{ add_le_add_left := λ f g hfg f', add_le_add_left hfg f',\n  ..subtype.partial_order _, ..add_subgroup.to_add_comm_group _}\n\nend order\n\nend Lp\nend measure_theory\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/measure_theory/function/lp_order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.48615099513194315}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.module.basic\nimport Mathlib.algebra.ring.pi\nimport Mathlib.PostPort\n\nuniverses u v u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Pi instances for module and multiplicative actions\n\nThis file defines instances for module, mul_action and related structures on Pi Types\n-/\n\nnamespace pi\n\n\nprotected instance has_scalar {I : Type u} {f : I → Type v} {α : Type u_1}\n    [(i : I) → has_scalar α (f i)] : has_scalar α ((i : I) → f i) :=\n  has_scalar.mk fun (s : α) (x : (i : I) → f i) (i : I) => s • x i\n\n@[simp] theorem smul_apply {I : Type u} {f : I → Type v} (x : (i : I) → f i) (i : I) {α : Type u_1}\n    [(i : I) → has_scalar α (f i)] (s : α) : has_scalar.smul s x i = s • x i :=\n  rfl\n\nprotected instance has_scalar' {I : Type u} {f : I → Type v} {g : I → Type u_1}\n    [(i : I) → has_scalar (f i) (g i)] : has_scalar ((i : I) → f i) ((i : I) → g i) :=\n  has_scalar.mk fun (s : (i : I) → f i) (x : (i : I) → g i) (i : I) => s i • x i\n\n@[simp] theorem smul_apply' {I : Type u} {f : I → Type v} (i : I) {g : I → Type u_1}\n    [(i : I) → has_scalar (f i) (g i)] (s : (i : I) → f i) (x : (i : I) → g i) :\n    has_scalar.smul s x i = s i • x i :=\n  rfl\n\nprotected instance is_scalar_tower {I : Type u} {f : I → Type v} {α : Type u_1} {β : Type u_2}\n    [has_scalar α β] [(i : I) → has_scalar β (f i)] [(i : I) → has_scalar α (f i)]\n    [∀ (i : I), is_scalar_tower α β (f i)] : is_scalar_tower α β ((i : I) → f i) :=\n  is_scalar_tower.mk\n    fun (x : α) (y : β) (z : (i : I) → f i) => funext fun (i : I) => smul_assoc x y (z i)\n\nprotected instance is_scalar_tower' {I : Type u} {f : I → Type v} {g : I → Type u_1} {α : Type u_2}\n    [(i : I) → has_scalar α (f i)] [(i : I) → has_scalar (f i) (g i)] [(i : I) → has_scalar α (g i)]\n    [∀ (i : I), is_scalar_tower α (f i) (g i)] :\n    is_scalar_tower α ((i : I) → f i) ((i : I) → g i) :=\n  is_scalar_tower.mk\n    fun (x : α) (y : (i : I) → f i) (z : (i : I) → g i) =>\n      funext fun (i : I) => smul_assoc x (y i) (z i)\n\nprotected instance is_scalar_tower'' {I : Type u} {f : I → Type v} {g : I → Type u_1}\n    {h : I → Type u_2} [(i : I) → has_scalar (f i) (g i)] [(i : I) → has_scalar (g i) (h i)]\n    [(i : I) → has_scalar (f i) (h i)] [∀ (i : I), is_scalar_tower (f i) (g i) (h i)] :\n    is_scalar_tower ((i : I) → f i) ((i : I) → g i) ((i : I) → h i) :=\n  is_scalar_tower.mk\n    fun (x : (i : I) → f i) (y : (i : I) → g i) (z : (i : I) → h i) =>\n      funext fun (i : I) => smul_assoc (x i) (y i) (z i)\n\nprotected instance mul_action {I : Type u} {f : I → Type v} (α : Type u_1) {m : monoid α}\n    [(i : I) → mul_action α (f i)] : mul_action α ((i : I) → f i) :=\n  mul_action.mk sorry sorry\n\nprotected instance mul_action' {I : Type u} {f : I → Type v} {g : I → Type u_1}\n    {m : (i : I) → monoid (f i)} [(i : I) → mul_action (f i) (g i)] :\n    mul_action ((i : I) → f i) ((i : I) → g i) :=\n  mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action {I : Type u} {f : I → Type v} (α : Type u_1) {m : monoid α}\n    {n : (i : I) → add_monoid (f i)} [(i : I) → distrib_mul_action α (f i)] :\n    distrib_mul_action α ((i : I) → f i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action' {I : Type u} {f : I → Type v} {g : I → Type u_1}\n    {m : (i : I) → monoid (f i)} {n : (i : I) → add_monoid (g i)}\n    [(i : I) → distrib_mul_action (f i) (g i)] :\n    distrib_mul_action ((i : I) → f i) ((i : I) → g i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance semimodule (I : Type u) (f : I → Type v) (α : Type u_1) {r : semiring α}\n    {m : (i : I) → add_comm_monoid (f i)} [(i : I) → semimodule α (f i)] :\n    semimodule α ((i : I) → f i) :=\n  semimodule.mk sorry sorry\n\nprotected instance semimodule' {I : Type u} {f : I → Type v} {g : I → Type u_1}\n    {r : (i : I) → semiring (f i)} {m : (i : I) → add_comm_monoid (g i)}\n    [(i : I) → semimodule (f i) (g i)] : semimodule ((i : I) → f i) ((i : I) → g i) :=\n  semimodule.mk sorry sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/module/pi_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6825737214979746, "lm_q1q2_score": 0.4861509809052155}}
{"text": "/- ------------------------------------------------------------------------- -|\n| @project: riemann_hypothesis                                                |\n| @file:    basic.lean                                                        |\n| @authors: Brandon H. Gomes, Alex Kontorovich                                |\n| @affil:   Rutgers University                                                |\n|- ------------------------------------------------------------------------- -/\n\n/-!\n-/\n\nnamespace riemann_hypothesis --——————————————————————————————————————————————————————————--\nvariables {α : Type*} {β : Type*}\n\n/--\n-/\ndef const (b : β)\n    := λ _ : α, b\nnotation `↓`:max b:max := const b\n\nsection pointwise_classes --—————————————————————————————————————————————————————————————--\n\n/--\n-/\ninstance pointwise.has_le [has_le β] : has_le (α → β)\n    := ⟨λ f g, Π x, f x ≤ g x⟩\n\n/--\n-/\ninstance pointwise.has_zero [has_zero β] : has_zero (α → β)\n    := ⟨↓0⟩\n\nend pointwise_classes --—————————————————————————————————————————————————————————————————--\n\nnamespace algebra --—————————————————————————————————————————————————————————————————————--\nvariables (α) (β)\n\n/--\n-/\nclass has_left_add_distributivity [has_add α] [has_mul α]\n    := (eq : Π x y z : α, x * (y + z) = x * y + x * z)\n\n/--\n-/\nclass has_right_add_distributivity [has_add α] [has_mul α]\n    := (eq : Π x y z : α, (y + z) * x = y * x + z * x)\n\n/--\n-/\nclass has_left_sub_distributivity [has_sub α] [has_mul α]\n    := (eq : Π x y z : α, x * (y - z) = x * y - x * z)\n\n/--\n-/\nclass has_right_sub_distributivity [has_sub α] [has_mul α]\n    := (eq : Π x y z : α, (y - z) * x = y * x - z * x)\n\n/--\n-/\nclass has_lift_add_comm [has_lift_t α β] [has_add α] [has_add β]\n    := (eq : Π x y : α, (↑(x + y) : β) = ↑x + ↑y)\n\n/--\n-/\nclass has_lift_sub_comm [has_lift_t α β] [has_sub α] [has_sub β]\n    := (eq : Π x y : α, (↑(x - y) : β) = ↑x - ↑y)\n\n/--\n-/\nclass has_lift_mul_comm [has_lift_t α β] [has_mul α] [has_mul β]\n    := (eq : Π x y : α, (↑(x * y) : β) = ↑x * ↑y)\n\n/--\n-/\nclass has_lift_inv_comm [has_lift_t α β] [has_inv α] [has_inv β]\n    := (eq : Π a : α, (↑(a⁻¹) : β) = (↑a)⁻¹)\n\n/--\n-/\nclass has_right_unit [has_one α] [has_mul α]\n    := (eq : Π a : α, a * 1 = a)\n\n/--\n-/\nclass has_left_unit [has_one α] [has_mul α]\n    := (eq : Π a : α, 1 * a = a)\n\n/--\n-/\nclass has_add_le_add [has_le α] [has_add α]\n    := (le : Π {a b c d : α}, a ≤ b → c ≤ d → a + c ≤ b + d)\n\n/--\n-/\nclass has_add_lt_add [has_lt α] [has_add α]\n    := (lt : Π {a b c d : α}, a < b → c < d → a + c < b + d)\n\n/--\n-/\nclass has_le_add_of_nonneg_of_le [has_le α] [has_zero α] [has_add α]\n    := (le : Π {a b c : α}, 0 ≤ a → b ≤ c → b ≤ a + c)\n\n/--\n-/\nclass has_lt_add_of_le_of_pos [has_le α] [has_lt α] [has_zero α] [has_add α]\n    := (lt : Π {a b c : α}, 0 < a → b ≤ c → b < a + c)\n\n/--\n-/\nclass has_add_nonneg [has_le α] [has_zero α] [has_add α]\n    := (le : Π {a b : α}, 0 ≤ a → 0 ≤ b → 0 ≤ a + b)\n\n/--\n-/\nclass has_zero_mul_is_zero [has_zero α] [has_mul α]\n    := (eq : Π a : α, 0 * a = 0)\n\n/--\n-/\nclass has_mul_zero_is_zero [has_zero α] [has_mul α]\n    := (eq : Π a : α, a * 0 = 0)\n\n/--\n-/\nclass has_lift_zero_same [has_lift_t α β] [has_zero α] [has_zero β]\n    := (eq : ↑(0 : α) = (0 : β))\n\n/--\n-/\nclass has_lift_one_same [has_lift_t α β] [has_one α] [has_one β]\n    := (eq : ↑(1 : α) = (1 : β))\n\n/--\n-/\nclass has_zero_right_add_cancel [has_zero α] [has_add α]\n    := (eq : Π a : α, a + 0 = a)\n\n/--\n-/\nclass has_zero_left_add_cancel [has_zero α] [has_add α]\n    := (eq : Π a : α, 0 + a = a)\n\n/--\n-/\nclass has_sub_self_is_zero [has_zero α] [has_sub α]\n    := (eq : Π a : α, a - a = 0)\n\n/--\n-/\nclass has_mul_assoc [has_mul α]\n    := (eq : Π a b c : α, (a * b) * c = a * (b * c))\n\n/--\n-/\nclass has_add_sub_assoc [has_add α] [has_sub α]\n    := (eq : Π a b c : α, (a + b) - c = a + (b - c))\n\n/--\n-/\nclass has_le_sub_add_le [has_le α] [has_sub α] [has_add α]\n    := (le : Π {a b c : α}, a ≤ c - b → a + b ≤ c)\n\n/--\n-/\nclass has_le_pos_mul_preserves_right [has_lt α] [has_le α] [has_zero α] [has_mul α]\n    := (le : Π {a b c : α}, 0 < c → a ≤ b → a * c ≤ b * c)\n\n/--\n-/\nclass has_le_pos_mul_preserves_left [has_lt α] [has_le α] [has_zero α] [has_mul α]\n    := (le : Π {a b c : α}, 0 < c → a ≤ b → c * a ≤ c * b)\n\n/--\n-/\nclass has_lt_pos_mul_preserves_right [has_lt α] [has_zero α] [has_mul α]\n    := (lt : Π {a b c : α}, 0 < c → a < b → a * c < b * c)\n\n/--\n-/\nclass has_le_nonneg_mul_preserves_left [has_lt α] [has_le α] [has_zero α] [has_mul α]\n    := (le : Π {a b c : α}, 0 ≤ c → a ≤ b → c * a ≤ c * b)\n\n/--\n-/\nclass has_le_nonneg_mul_preserves_right [has_lt α] [has_le α] [has_zero α] [has_mul α]\n    := (le : Π {a b c : α}, 0 ≤ c → a ≤ b → a * c ≤ b * c)\n\n/--\n-/\nclass has_lift_le_comm [has_lift_t α β] [has_le α] [has_le β]\n    := (le : Π {x y : α}, x ≤ y → ↑x ≤ (↑y : β))\n\n/--\n-/\nclass has_lift_lt_comm [has_lift_t α β] [has_lt α] [has_lt β]\n    := (lt : Π {x y : α}, x < y → ↑x < (↑y : β))\n\n/--\n-/\nclass has_lift_ne_comm [has_lift_t α β]\n    := (ne : Π {x y : α}, x ≠ y → ↑x ≠ (↑y : β))\n\n/--\n-/\nclass has_sub_add_sub_cancel [has_sub α] [has_add α]\n    := (eq : Π a b c : α, a - b + (b - c) = a - c)\n\n/--\n-/\nclass has_double_sub_cancel [has_sub α]\n    := (eq : Π a b : α, a - (a - b) = b)\n\n/--\n-/\nclass has_inv_mul_right_cancel_self [has_zero α] [has_one α] [has_inv α] [has_mul α]\n    := (eq : Π a : α, a ≠ 0 → a * a⁻¹ = 1)\n\n/--\n-/\nclass has_inv_mul_left_cancel_self [has_zero α] [has_one α] [has_inv α] [has_mul α]\n    := (eq : Π a : α, a ≠ 0 → a⁻¹ * a = 1)\n\n/--\n-/\nclass has_add_sub_exchange [has_add α] [has_sub α]\n    := (eq : Π a b c d : α, (a - b) + (c - d) = (c - b) + (a - d))\n\n/--\n-/\nclass has_zero_sub_is_neg [has_zero α] [has_neg α] [has_sub α]\n    := (eq : Π a : α, 0 - a = -a)\n\n/--\n-/\nclass has_inv_right_mul_lt_pos [has_lt α] [has_zero α] [has_mul α] [has_inv α]\n    := (lt : Π {a b c : α}, 0 < b → a < c * b → a * b⁻¹ < c)\n\n/--\n-/\nclass has_right_mul_inv_lt_pos [has_lt α] [has_zero α] [has_mul α] [has_inv α]\n    := (lt : Π {a b c : α}, 0 < b → c < b⁻¹ * a → b * c < a)\n\n/--\n-/\nclass has_left_mul_inv_lt_pos [has_lt α] [has_zero α] [has_mul α] [has_inv α]\n    := (lt : Π {a b c : α}, 0 < b → c < a * b⁻¹ → c * b < a)\n\n/--\n-/\nclass has_left_mul_inv_lt_neg [has_lt α] [has_zero α] [has_mul α] [has_inv α]\n    := (lt : Π {a b c : α}, b < 0 → a * b⁻¹ < c → b * c < a)\n\n/--\n-/\nclass has_sub_ne_zero_of_ne [has_zero α] [has_sub α]\n    := (ne : Π {a b : α}, a ≠ b → a - b ≠ 0)\n\n/--\n-/\nclass has_lt_sub_neg [has_lt α] [has_zero α] [has_sub α]\n    := (lt : Π {a b : α}, a < b → a - b < 0)\n\n/--\n-/\nclass has_zero_lt_one [has_lt α] [has_zero α] [has_one α]\n    := (lt : 0 < (1 : α))\n\n/--\n-/\nclass has_pos_mul_neg_is_neg [has_lt α] [has_zero α] [has_mul α]\n    := (lt : Π {a b : α}, 0 < a → b < 0 → a * b < 0)\n\n/--\n-/\nclass has_nonneg_mul_nonneg_is_nonneg [has_le α] [has_zero α] [has_mul α]\n    := (le : Π {a b : α}, 0 ≤ a → 0 ≤ b → 0 ≤ a * b)\n\n/--\n-/\nclass has_squared_le_monotonic [has_le α] [has_zero α] [has_mul α]\n    := (le : Π {a b : α}, 0 ≤ a → a ≤ b → a * a ≤ b * b)\n\n/--\n-/\nclass has_sub_pos [has_lt α] [has_zero α] [has_sub α]\n    := (lt : Π {a b : α}, a < b → 0 < b - a)\n\n/--\n-/\nclass has_sub_sub [has_add α] [has_sub α]\n    := (eq : Π a b c : α, a - (b - c) = (a - b) + c)\n\n/--\n-/\nclass has_add_left_lt [has_lt α] [has_add α]\n    := (lt : Π a b c : α, a < b → c + a < c + b)\n\n/--\n-/\nclass has_left_inv_pos_lt [has_lt α] [has_zero α] [has_mul α] [has_inv α]\n    := (lt : Π {a b c : α}, 0 < c → a < b → c⁻¹ * a < c⁻¹ * b)\n\n/--\n-/\nclass has_right_inv_pos_lt [has_lt α] [has_zero α] [has_mul α] [has_inv α]\n    := (lt : Π {a b c : α}, 0 < c → a < b → a * c⁻¹ < b * c⁻¹)\n\n/--\n-/\nclass has_mul_pos [has_lt α] [has_zero α] [has_mul α]\n    := (lt : Π {a b : α}, 0 < a → 0 < b → 0 < a * b)\n\n/--\n-/\nclass has_inv_pos [has_lt α] [has_zero α] [has_inv α]\n    := (lt : Π {a : α}, 0 < a → 0 < a⁻¹)\n\n/--\n-/\nclass has_inv_reverses_le [has_le α] [has_inv α]\n    := (le : Π {a b : α}, a ≤ b → b⁻¹ ≤ a⁻¹)\n\n/--\n-/\nclass has_inv_reverses_lt [has_lt α] [has_inv α]\n    := (lt : Π {a b : α}, a < b → b⁻¹ < a⁻¹)\n\n/--\n-/\nclass has_inv_mul_reverse [has_inv α] [has_mul α]\n    := (eq : Π a b : α, (a * b)⁻¹ = b⁻¹ * a⁻¹)\n\n/--\n-/\nstructure Half [has_lt α] [has_zero α] [has_add α]\n    := (map          : α → α)\n       (preserve_pos : Π {x}, 0 < x → 0 < map x)\n       (doubled_inv  : Π (x), map x + map x = x)\n\n/--\n-/\nstructure LiftCeil [has_lift_t nat α] [has_lt α]\n    := (map     : α → nat)\n       (lift_lt : Π {a n}, map a < n → a < ↑n)\n\nsection lemmas --————————————————————————————————————————————————————————————————————————--\nvariables {α β}\n\n/--\n-/\ndef inv_sub_inv_lemma\n    [has_zero α]\n    [has_one α]\n    [has_inv α]\n    [has_mul α]\n    [has_sub α]\n    [has_right_unit α]\n    [has_left_unit α]\n    [has_inv_mul_right_cancel_self α]\n    [has_mul_assoc α]\n    [has_right_sub_distributivity α]\n    {a b : α}\n    (a_ne_0 : a ≠ 0)\n    : a⁻¹ - b⁻¹ = (1 - b⁻¹ * a) * a⁻¹ :=\n    begin\n        rw has_right_sub_distributivity.eq,\n        rw has_mul_assoc.eq,\n        rw has_inv_mul_right_cancel_self.eq _ a_ne_0,\n        rw has_left_unit.eq,\n        rw has_right_unit.eq,\n    end\n\n/--\n-/\ndef inv_sub_inv_lemma'\n    [has_zero α]\n    [has_one α]\n    [has_inv α]\n    [has_mul α]\n    [has_sub α]\n    [has_right_unit α]\n    [has_left_unit α]\n    [has_inv_mul_left_cancel_self α]\n    [has_mul_assoc α]\n    [has_left_sub_distributivity α]\n    {a b : α}\n    (a_ne_0 : a ≠ 0)\n    : a⁻¹ - b⁻¹ = a⁻¹ * (1 - a * b⁻¹) :=\n    begin\n        rw has_left_sub_distributivity.eq,\n        rw ← has_mul_assoc.eq,\n        rw has_inv_mul_left_cancel_self.eq _ a_ne_0,\n        rw has_left_unit.eq,\n        rw has_right_unit.eq,\n    end\n\n/--\n-/\ndef mul_inv_add_one_lemma\n    [has_lift_t nat α]\n    [has_zero α]\n    [has_one α]\n    [has_sub α]\n    [has_mul α]\n    [has_inv α]\n    [has_left_unit α]\n    [has_inv_mul_right_cancel_self α]\n    [has_right_sub_distributivity α]\n    [has_lift_zero_same nat α]\n    [has_lift_one_same nat α]\n    [has_lift_sub_comm nat α]\n    [has_lift_ne_comm nat α]\n    (n : nat)\n    : (↑n : α) * (↑n.succ)⁻¹ = 1 - (↑n.succ)⁻¹ :=\n    begin\n        rw ← has_left_unit.eq (↑n.succ : α)⁻¹,\n\n        have succ_non_zero : ↑n.succ ≠ (0 : α),\n            rw (_ : 0 = (↑0 : α)),\n            refine has_lift_ne_comm.ne (nat.succ_ne_zero _),\n            rw has_lift_zero_same.eq,\n\n        rw ← has_inv_mul_right_cancel_self.eq _ succ_non_zero,\n        rw ← has_right_sub_distributivity.eq,\n        rw has_inv_mul_right_cancel_self.eq _ succ_non_zero,\n        rw has_left_unit.eq,\n\n        rw (_ : 1 = (↑1 : α)),\n\n        rw ← has_lift_sub_comm.eq,\n        rw nat.succ_sub_one,\n        rw has_lift_one_same.eq,\n    end\n\n/--\n-/\ndef two_mul_lemma\n    [has_one α]\n    [has_add α]\n    [has_mul α]\n    [has_right_add_distributivity α]\n    [has_left_unit α]\n    (a : α)\n    : 2 * a = a + a :=\n    begin\n        refine (has_right_add_distributivity.eq _ _ _).trans _,\n        rw has_left_unit.eq,\n    end\n\n/--\n-/\ndef two_mul_lemma'\n    [has_one α]\n    [has_add α]\n    [has_mul α]\n    [has_left_add_distributivity α]\n    [has_right_unit α]\n    (a : α)\n    : a * 2 = a + a :=\n    begin\n        refine (has_left_add_distributivity.eq _ _ _).trans _,\n        rw has_right_unit.eq,\n    end\n\n/--\n-/\ndef two_squares_is_four_lemma\n    [has_one α]\n\n    [has_add α] [has_mul α]\n\n    [has_left_unit α]\n\n    [has_left_add_distributivity α] [has_right_add_distributivity α]\n\n    [has_mul_assoc α]\n\n    (a : α)\n\n    : 4 * (a * a) = (a + a) * (a + a) :=\n\n    begin\n        rw has_left_add_distributivity.eq,\n        rw has_right_add_distributivity.eq,\n        rw ← two_mul_lemma,\n        rw ← two_mul_lemma,\n        rw ← has_mul_assoc.eq,\n        rw ← has_mul_assoc.eq,\n        rw two_mul_lemma,\n        rw has_mul_assoc.eq,\n\n        refine rfl,\n    end\n\n/--\n-/\ndef two_squares_is_four_lemma'\n    [has_one α]\n\n    [has_add α] [has_mul α]\n\n    [has_right_unit α]\n\n    [has_left_add_distributivity α] [has_right_add_distributivity α]\n\n    [has_mul_assoc α]\n\n    (a : α)\n\n    : (a * a) * 4 = (a + a) * (a + a) :=\n\n    begin\n        rw has_right_add_distributivity.eq,\n        rw has_left_add_distributivity.eq,\n        rw ← two_mul_lemma',\n        rw ← two_mul_lemma',\n        rw has_mul_assoc.eq,\n        rw has_mul_assoc.eq,\n        rw two_mul_lemma',\n        rw has_mul_assoc.eq,\n\n        refine rfl,\n    end\n\n/--\n-/\ndef nat_mul_commute_lemma\n    [has_zero α]\n    [has_one α]\n    [has_add α]\n    [has_mul α]\n\n    [has_zero_mul_is_zero α]\n    [has_mul_zero_is_zero α]\n\n    [has_right_unit α]\n    [has_left_unit α]\n\n    [has_left_add_distributivity α]\n    [has_right_add_distributivity α]\n\n    [has_lift_t nat α]\n    [has_lift_zero_same nat α]\n    [has_lift_one_same nat α]\n    [has_lift_add_comm nat α]\n\n    (a : α) (n : nat)\n\n    : a * ↑n = ↑n * a :=\n\n    begin\n        induction n with n hn,\n            rw has_lift_zero_same.eq,\n            rw has_zero_mul_is_zero.eq,\n            rw has_mul_zero_is_zero.eq,\n            rw nat.succ_eq_add_one,\n            rw has_lift_add_comm.eq,\n            rw has_left_add_distributivity.eq,\n            rw has_right_add_distributivity.eq,\n            rw hn,\n            rw has_lift_one_same.eq,\n            rw has_left_unit.eq,\n            rw has_right_unit.eq,\n    end\n\nsection lifted_lemmas --—————————————————————————————————————————————————————————————————--\nvariables (α β)\n\n/--\n-/\ndef zero_is_lifted_zero_lemma\n    [has_zero α] [has_zero β] [has_lift_t α β] [has_lift_zero_same α β]\n    : (0 : β) = ↑(0 : α)\n    := by rw has_lift_zero_same.eq\n\n--———————————————————————————————————————————————————————————————————————————————————————--\nvariables [has_one α] [has_one β] [has_lift_t α β] [has_lift_one_same α β]\n\n/--\n-/\ndef one_is_lifted_one_lemma\n    : (1 : β) = ↑(1 : α)\n    := by rw has_lift_one_same.eq\n\n--———————————————————————————————————————————————————————————————————————————————————————--\nvariables [has_add α] [has_add β] [has_lift_add_comm α β]\n\n/--\n-/\ndef two_is_lifted_two_lemma : (2 : β) = ↑(2 : α) :=\n    begin\n        rw (_ : (2 : β) = ↑(1 : α) + ↑(1 : α)),\n        rw ← has_lift_add_comm.eq,\n        refine rfl,\n        rw has_lift_one_same.eq,\n        refine rfl,\n    end\n\n/--\n-/\ndef three_is_lifted_three_lemma : (3 : β) = ↑(3 : α) :=\n    begin\n        rw (_ : (3 : β) = ↑(1 : α) + ↑(1 : α) + ↑(1 : α)),\n        rw [← has_lift_add_comm.eq, ← has_lift_add_comm.eq],\n        refine rfl,\n        rw has_lift_one_same.eq,\n        refine rfl,\n    end\n\n/--\n-/\ndef four_is_lifted_four_lemma : (4 : β) = ↑(4 : α) :=\n    begin\n        rw (_ : (4 : β) = ↑(1 : α) + ↑(1 : α) + (↑(1 : α) + ↑(1 : α))),\n        rw [← has_lift_add_comm.eq, ← has_lift_add_comm.eq],\n        refine rfl,\n        rw has_lift_one_same.eq,\n        refine rfl,\n    end\n\nend lifted_lemmas --—————————————————————————————————————————————————————————————————————--\nend lemmas --————————————————————————————————————————————————————————————————————————————--\nend algebra --———————————————————————————————————————————————————————————————————————————--\n\nopen algebra\n\nnamespace nat --—————————————————————————————————————————————————————————————————————————--\n\n/--\n-/\ndef of_le_succ {n m : nat} (n_le_m_succ : n ≤ m.succ) : n ≤ m ∨ n = m.succ\n    := (lt_or_eq_of_le n_le_m_succ).imp nat.le_of_lt_succ id\n\n/--\n-/\ndef sub_sub_sub_cancel_right {a b c} (c_le_b : c ≤ b) : a - c - (b - c) = a - b\n    := by rw [nat.sub_sub, ← nat.add_sub_assoc c_le_b, nat.add_sub_cancel_left]\n\n/--\n-/\ndef le_sub_right_of_add_le {m n k} : m + k ≤ n → m ≤ n - k :=\n    begin\n        intros h,\n        rw ← nat.add_sub_cancel m k,\n        refine nat.sub_le_sub_right h _,\n    end\n\n/--\n-/\ndef le_sub_left_of_add_le {k m n} (h : k + m ≤ n) : m ≤ n - k\n    := le_sub_right_of_add_le (by { rw ← nat.add_comm, refine h })\n\n/--\n-/\ndef le_add_of_sub_le_right {k m n} : n - k ≤ m → n ≤ m + k :=\n    begin\n        intros h,\n        rw ← nat.add_sub_cancel m k at h,\n        refine (nat.sub_le_sub_right_iff _ _ _ (nat.le_add_left _ _)).mp h,\n    end\n\n/--\n-/\ndef add_lt_add_of_le_of_lt {a b c d} (h₁ : a ≤ b) (h₂ : c < d) : a + c < b + d\n    := lt_of_le_of_lt (nat.add_le_add_right h₁ c) (nat.add_lt_add_left h₂ b)\n\n/--\n-/\ndef lt_add_of_le_of_pos {a b c} (b_le_c : b ≤ c) (zero_lt_a : 0 < a) : b < c + a\n    := nat.add_zero b ▸ nat.add_lt_add_of_le_of_lt b_le_c zero_lt_a\n\n/--\n-/\ndef neg_right_swap {a b c} (c_le_b : c ≤ b) :  a - (b - c) = (a + c) - b :=\n    begin\n        rw ← nat.add_sub_cancel a _,\n        rw nat.sub_sub_sub_cancel_right c_le_b,\n        rw nat.add_sub_assoc (le_refl _),\n        rw nat.sub_self,\n        rw nat.add_zero,\n    end\n\n/--\n-/\ndef sub_mono_left_strict {x y z : nat} (z_le_x : z ≤ x) (x_lt_y : x < y)\n    : x - z < y - z :=\n    begin\n        refine @nat.lt_of_add_lt_add_left z _ _ _,\n        rw nat.add_sub_of_le (le_trans z_le_x (le_of_lt x_lt_y)),\n        rw nat.add_sub_of_le z_le_x,\n        refine x_lt_y,\nend\n\n/--\n-/\ndef mul_two (n) : n * 2 = n + n :=\n    begin\n        refine (nat.left_distrib _ _ _).trans _,\n        rw nat.mul_one,\n    end\n\n/--\n-/\ndef pow_two_ge_one (n : nat) : 1 ≤ 2 ^ n :=\n    begin\n        induction n with n hn,\n            refine le_refl _,\n            refine le_trans hn (nat.le_add_left _ _),\n    end\n\n/--\n-/\ndef pow_two_monotonic (n : nat) : 2 ^ n < 2 ^ n.succ\n    := lt_add_of_le_of_pos (nat.le_add_left _ _) (pow_two_ge_one _)\n\n/--\n-/\ndef smallest_positive_even (n : nat)\n    : 2 ≤ 2 * n.succ :=\n    begin\n        induction n with n hn,\n            rw nat.mul_one,\n            refine le_trans hn (nat.le.intro rfl),\n    end\n\n/--\n-/\ndef successive_difference (u : nat → nat) (n : nat)\n    := u n.succ - u n\n\n/--\n-/\ndef power [has_one α] [has_mul α] (a : α) : nat → α\n| (nat.zero  ) := 1\n| (nat.succ n) := power n * a\n\nnamespace power --———————————————————————————————————————————————————————————————————————--\nvariables [has_one α] [has_mul α]\n\n/--\n-/\ndef mul_commute\n    [has_one β] [has_mul β]\n    (map     : α → β)\n    (map_one : map 1 = 1)\n    (map_mul : Π x y, map (x * y) = map x * map y)\n    (a : α) (n)\n    : map (power a n) = power (map a) n :=\n    begin\n        induction n with n hn,\n            rw [power, power],\n            rw map_one,\n            rw [power, power],\n            rw map_mul,\n            rw hn,\n    end\n\nend power --—————————————————————————————————————————————————————————————————————————————--\n\nnamespace lift --————————————————————————————————————————————————————————————————————————--\nvariables (α)\n\n/--\n-/\ndef succ_pos\n    [has_lt α]\n    [has_zero α]\n    [has_lift_t nat α]\n    [has_lift_zero_same nat α]\n    [has_lift_lt_comm nat α]\n    (n : nat)\n    : 0 < (↑n.succ : α) :=\n    begin\n        rw zero_is_lifted_zero_lemma nat α,\n        refine has_lift_lt_comm.lt (nat.succ_pos _),\n    end\n\n/--\n-/\ndef succ_nonzero\n    [preorder α]\n    [has_zero α]\n    [has_lift_t nat α]\n    [has_lift_zero_same nat α]\n    [has_lift_lt_comm nat α]\n    (n : nat)\n    : (↑n.succ : α) ≠ 0\n    := (ne_of_gt (nat.lift.succ_pos α _))\n\n/--\n-/\ndef zero_lt_one\n    [has_lt α]\n    [has_zero α]\n    [has_one α]\n    [has_lift_t nat α]\n    [has_lift_zero_same nat α]\n    [has_lift_one_same nat α]\n    [has_lift_lt_comm nat α]\n    : (0 : α) < 1 :=\n    begin\n        rw one_is_lifted_one_lemma nat α,\n        refine nat.lift.succ_pos α _,\n    end\n\n/--\n-/\ninstance zero_lt_one_instance\n    [has_lt α]\n    [has_zero α]\n    [has_one α]\n    [has_lift_t nat α]\n    [has_lift_zero_same nat α]\n    [has_lift_one_same nat α]\n    [has_lift_lt_comm nat α]\n    : has_zero_lt_one α\n    := ⟨zero_lt_one α⟩\n\nend lift --——————————————————————————————————————————————————————————————————————————————--\nend nat --———————————————————————————————————————————————————————————————————————————————--\n\nsection sequences --—————————————————————————————————————————————————————————————————————--\n\n/--\n-/\ndef strictly_increasing\n    [has_lt α]\n    (seq : nat → α)\n    := Π n, seq n < seq n.succ\n\n/--\n-/\ndef increasing\n    [has_le α]\n    (seq : nat → α)\n    := Π n, seq n ≤ seq n.succ\n\n/--\n-/\ndef strictly_increasing.as_increasing\n    [preorder α]\n    (seq : nat → α)\n    : strictly_increasing seq → increasing seq :=\n    begin\n        intros sinc _,\n        refine le_of_lt (sinc _),\n    end\n\n/--\n-/\ndef increasing_strong\n    [has_le α]\n    (seq : nat → α)\n    := Π i j, i ≤ j → seq i ≤ seq j\n\n/--\n-/\ndef increasing.as_increasing_strong\n    [preorder α]\n    (seq : nat → α)\n    : increasing seq → increasing_strong seq :=\n    begin\n        intros inc i j i_le_j,\n        induction j with j hj,\n            cases i_le_j,\n                refine le_refl _,\n            cases nat.of_le_succ i_le_j,\n                refine le_trans (hj h) (inc _),\n                rw h,\n    end\n\n/--\n-/\ndef strictly_increasing.as_increasing_strong\n    [preorder α]\n    (seq : nat → α)\n    : strictly_increasing seq → increasing_strong seq\n    := λ s, increasing.as_increasing_strong _ (strictly_increasing.as_increasing _ s)\n\n/--\n-/\ndef non_increasing\n    [has_le α]\n    (seq : nat → α)\n    := Π n, seq (nat.succ n) ≤ seq n\n\n/--\n-/\ndef non_increasing_strong\n    [has_le α]\n    (seq : nat → α) (k)\n    := Π n, seq (n + k) ≤ seq n\n\n/--\n-/\ndef non_increasing.as_non_increasing_strong\n    [preorder α]\n    (seq : nat → α)\n    : non_increasing seq → Π k, non_increasing_strong seq k :=\n    begin\n        intros noninc k _,\n        induction k with k hk,\n            refine le_refl _,\n            refine le_trans (noninc _) hk,\n    end\n\n/--\n-/\ndef strictly_increasing.ge_index\n    (seq) (sinc : strictly_increasing seq)\n    (k)\n    : k ≤ seq k :=\n    begin\n        induction k with _ hk,\n            refine nat.zero_le _,\n            rw nat.succ_eq_add_one,\n            refine le_trans (nat.add_le_add hk (le_refl _)) (sinc _),\n    end\n\n/--\n-/\ndef nonneg_compose_preserve\n    [has_zero α] [has_le α]\n    (seq : nat → α) (φ : nat → nat)\n    : 0 ≤ seq → 0 ≤ seq ∘ φ\n    := λ p _, p (φ _)\n\n/--\n-/\ndef translate\n    (seq : nat → α)\n    (k)\n    (n)\n    := seq (k + n)\n\n/--\n-/\ndef translate.preserve_nonneg\n    [has_zero α] [has_le α]\n    (seq : nat → α)\n    : 0 ≤ seq → 0 ≤ translate seq\n    := λ p _ _, p _\n\n/--\n-/\ndef translate.monotonicity\n    [has_le α]\n    {a b : nat → α}\n    : a ≤ b → translate a ≤ translate b\n    := λ p _ _, p _\n\n/--\n-/\ndef translate.combine\n    (seq : nat → α)\n    (i j)\n    : translate (translate seq i) j = translate seq (i + j)\n    := funext (λ _, by rw [translate, translate, translate, nat.add_assoc])\n\n/--\n-/\ndef translate.compose_commute\n    (seq : nat → α)\n    (f : α → β)\n    (n k)\n    : f (translate seq n k) = translate (f ∘ seq) n k\n    := by rw [translate, translate]\n\n/--\n-/\ndef translate.compose_commute.funext\n    (seq : nat → α)\n    (f : α → β)\n    (n)\n    : f ∘ (translate seq n) = translate (f ∘ seq) n\n    := funext (translate.compose_commute seq f n)\n\nend sequences --—————————————————————————————————————————————————————————————————————————--\n\nsection series --————————————————————————————————————————————————————————————————————————--\nvariables [has_zero α] [has_add α]\n\n/--\n-/\ndef partial_sum (seq : nat → α) : nat → α\n| (nat.zero  ) := 0\n| (nat.succ n) := seq n + partial_sum n\n\n/--\n-/\ndef partial_sum.preserve_nonneg\n    [preorder α] [has_add_nonneg α]\n\n    (seq : nat → α)\n\n    : 0 ≤ seq → 0 ≤ partial_sum seq :=\n\n    begin\n        intros nonneg k,\n        induction k with k hk,\n            refine le_refl _,\n            refine has_add_nonneg.le (nonneg _) hk,\n    end\n\n/--\n-/\ndef partial_sum.left_mul_commute\n    [has_mul α] [has_mul_zero_is_zero α] [has_left_add_distributivity α]\n    (seq : nat → α)\n    (C)\n    : partial_sum (λ k, C * seq k) = λ n, C * partial_sum seq n :=\n    begin\n        refine funext _,\n        intros n,\n        induction n with n hn,\n            rw partial_sum,\n            rw partial_sum,\n            rw has_mul_zero_is_zero.eq,\n            rw partial_sum,\n            rw partial_sum,\n            rw hn,\n            rw has_left_add_distributivity.eq,\n    end\n\n/--\n-/\ndef partial_sum.right_mul_commute\n    [has_mul α] [has_zero_mul_is_zero α] [has_right_add_distributivity α]\n    (seq : nat → α)\n    (C)\n    : partial_sum (λ k, seq k * C) = λ n, partial_sum seq n * C :=\n    begin\n        refine funext _,\n        intros n,\n        induction n with n hn,\n            rw partial_sum,\n            rw partial_sum,\n            rw has_zero_mul_is_zero.eq,\n            rw partial_sum,\n            rw partial_sum,\n            rw hn,\n            rw has_right_add_distributivity.eq,\n    end\n\n/--\n-/\ndef partial_sum.from_mul\n    [has_one α]\n    [has_mul α]\n\n    [has_zero_mul_is_zero α]\n    [has_left_unit α]\n    [has_right_add_distributivity α]\n\n    [has_lift_t nat α]\n    [has_lift_zero_same nat α]\n    [has_lift_one_same nat α]\n    [has_lift_add_comm nat α]\n\n    (a : α)\n    (n : nat)\n\n    : ↑n * a = partial_sum ↓a n :=\n\n    begin\n        induction n with n hn,\n            rw partial_sum,\n            rw has_lift_zero_same.eq,\n            rw has_zero_mul_is_zero.eq,\n            rw partial_sum,\n            rw nat.succ_eq_add_one,\n            rw nat.add_comm,\n            rw has_lift_add_comm.eq,\n            rw has_right_add_distributivity.eq,\n            rw has_lift_one_same.eq,\n            rw has_left_unit.eq,\n            rw hn,\n            rw const,\n    end\n\n/--\n-/\ndef partial_sum.from_mul'\n    [has_one α]\n    [has_mul α]\n\n    [has_mul_zero_is_zero α]\n    [has_right_unit α]\n    [has_left_add_distributivity α]\n\n    [has_lift_t nat α]\n    [has_lift_zero_same nat α]\n    [has_lift_one_same nat α]\n    [has_lift_add_comm nat α]\n\n    (a : α)\n    (n : nat)\n\n    : a * ↑n = partial_sum ↓a n :=\n\n    begin\n        induction n with n hn,\n            rw partial_sum,\n            rw has_lift_zero_same.eq,\n            rw has_mul_zero_is_zero.eq,\n            rw partial_sum,\n            rw nat.succ_eq_add_one,\n            rw nat.add_comm,\n            rw has_lift_add_comm.eq,\n            rw has_left_add_distributivity.eq,\n            rw has_lift_one_same.eq,\n            rw has_right_unit.eq,\n            rw hn,\n            rw const,\n    end\n\n/--\n-/\ndef partial_sum.monotonicity\n    [preorder α] [has_add_le_add α]\n    {a b : nat → α}\n    : a ≤ b → partial_sum a ≤ partial_sum b :=\n    begin\n        intros a_le_b n,\n        induction n with _ hn,\n            refine le_refl _,\n            refine has_add_le_add.le (a_le_b _) hn,\n    end\n\n/--\n-/\ndef partial_sum.index_monotonicity\n    [preorder α] [has_le_add_of_nonneg_of_le α]\n\n    (seq : nat → α) (nonneg : 0 ≤ seq)\n\n    {m n}\n\n    : m ≤ n → partial_sum seq m ≤ partial_sum seq n :=\n\n    begin\n        intros m_le_n,\n        induction n with n hn,\n            cases m_le_n,\n                refine le_refl _,\n            cases nat.of_le_succ m_le_n,\n                refine has_le_add_of_nonneg_of_le.le (nonneg _) (hn h),\n                rw ← h,\n    end\n\n/--\n-/\ndef partial_sum.double_monotonicity\n    [preorder α] [has_le_add_of_nonneg_of_le α] [has_add_le_add α]\n\n    (a : nat → α) (na)\n    (b : nat → α) (nb)\n\n    : 0 ≤ a → a ≤ b → na ≤ nb → partial_sum a na ≤ partial_sum b nb :=\n\n    begin\n        intros zero_le_a a_le_b na_le_nb,\n        induction nb with _ hnb,\n            cases na_le_nb,\n                refine le_refl _,\n            cases nat.of_le_succ na_le_nb,\n                refine has_le_add_of_nonneg_of_le.le\n                    (le_trans (zero_le_a _) (a_le_b _)) (hnb h),\n                rw h,\n                refine has_add_le_add.le\n                    (a_le_b _) (partial_sum.monotonicity a_le_b _),\n    end\n\n/--\n-/\ndef partial_sum.sub_as_translate\n    [has_sub α] [has_sub_self_is_zero α] [has_add_sub_assoc α]\n\n    (seq : nat → α)\n\n    {m n} (m_le_n : m ≤ n)\n\n    : partial_sum seq n - partial_sum seq m = partial_sum (translate seq m) (n - m) :=\n\n    begin\n        induction n with n hn,\n            cases m_le_n,\n                refine has_sub_self_is_zero.eq _,\n            cases m_le_n with _ m_le_n,\n                rw has_sub_self_is_zero.eq,\n                rw nat.sub_self,\n                rw partial_sum,\n                rw partial_sum,\n                rw has_add_sub_assoc.eq,\n                rw hn m_le_n,\n                rw nat.succ_sub m_le_n,\n                rw partial_sum,\n                rw translate,\n                rw nat.add_sub_of_le m_le_n,\n    end\n\n/--\n-/\ndef partial_sum.lower_differences.bottom\n    [has_sub α]\n    [has_add_sub_assoc α]\n    [has_sub_self_is_zero α]\n\n    [preorder α]\n    [has_le_add_of_nonneg_of_le α]\n\n    (seq : nat → α) (nonneg : 0 ≤ seq)\n\n    {m n} (m_le_n : m ≤ n)\n\n    : 0 ≤ partial_sum seq n - partial_sum seq m :=\n\n    begin\n        induction n with n hn,\n            cases m_le_n,\n                rw has_sub_self_is_zero.eq,\n            cases nat.of_le_succ m_le_n,\n                rw partial_sum,\n                rw has_add_sub_assoc.eq,\n                refine has_le_add_of_nonneg_of_le.le (nonneg _) (hn h),\n                rw ← h,\n                rw has_sub_self_is_zero.eq,\n    end\n\n/--\n-/\ndef partial_sum.lower_differences\n    [has_sub α]\n    [has_sub_self_is_zero α]\n    [has_add_sub_assoc α]\n\n    [preorder α]\n    [has_add_le_add α]\n    [has_le_add_of_nonneg_of_le α]\n\n    (seq : nat → α) (nonneg : 0 ≤ seq)\n\n    {k m n} (k_le_m : k ≤ m) (m_le_n : m ≤ n)\n\n    : partial_sum seq n - partial_sum seq m ≤ partial_sum seq n - partial_sum seq k :=\n\n    begin\n        induction n with n hn,\n            cases m_le_n,\n                cases k_le_m,\n                    refine le_refl _,\n            cases nat.of_le_succ m_le_n,\n                rw partial_sum,\n                rw has_add_sub_assoc.eq,\n                rw has_add_sub_assoc.eq,\n                refine has_add_le_add.le (le_refl _) (hn h),\n                rw ← h,\n                rw has_sub_self_is_zero.eq,\n                refine partial_sum.lower_differences.bottom _ nonneg k_le_m,\n    end\n\n--———————————————————————————————————————————————————————————————————————————————————————--\nvariables [has_sub α]\n\n/--\n-/\ndef shape_sum (seq : nat → α) (φ : nat → nat) (n : nat)\n    := partial_sum seq (φ n.succ) - partial_sum seq (φ n)\n\n/--\n-/\ndef shape_sum.unfold\n    [has_sub_self_is_zero α]\n    [has_add_sub_assoc α]\n    [has_sub_add_sub_cancel α]\n\n    (seq : nat → α)\n\n    (φ) (sinc_φ : strictly_increasing φ)\n\n    {m n} (m_le_n : m ≤ n)\n\n    : partial_sum (translate (shape_sum seq φ) m) (n - m)\n    = partial_sum (translate seq (φ m)) (φ n - φ m) :=\n\n    begin\n        let strong_inc := strictly_increasing.as_increasing_strong _ sinc_φ,\n        induction n with n hn,\n            cases m_le_n,\n                rw [nat.sub_self, nat.sub_self, partial_sum, partial_sum],\n            cases nat.of_le_succ m_le_n,\n                rw nat.succ_sub h,\n                rw partial_sum,\n                rw hn h,\n                rw translate,\n                rw nat.add_sub_of_le h,\n                rw shape_sum,\n                rw ← partial_sum.sub_as_translate seq (strong_inc _ _ h),\n                rw ← partial_sum.sub_as_translate seq (strong_inc _ _ m_le_n),\n                rw has_sub_add_sub_cancel.eq,\n                rw h,\n                rw [nat.sub_self, nat.sub_self, partial_sum, partial_sum],\n    end\n\nend series --————————————————————————————————————————————————————————————————————————————--\n\nsection absolute_value --————————————————————————————————————————————————————————————————--\nvariables [has_zero α] [has_add α]\n\n/--\n-/\ndef triangle_inequality\n    [has_zero β] [has_add β] [preorder β] [has_add_le_add β]\n\n    (abs          : α → β)\n    (abs_zero     : abs 0 = 0)\n    (abs_triangle : Π x y, abs (x + y) ≤ abs x + abs y)\n\n    (seq) (n)\n\n    : abs (partial_sum seq n) ≤ partial_sum (abs ∘ seq) n :=\n\n    begin\n        induction n with _ hn,\n            rw [partial_sum, partial_sum],\n            rw abs_zero,\n            refine le_trans (abs_triangle _ _) (has_add_le_add.le (le_refl _) hn),\n    end\n\n/--\n-/\ndef triangle_equality\n    [preorder α] [has_add_nonneg α]\n\n    (abs           : α → α)\n    (nonneg_to_abs : Π z, 0 ≤ z → abs z = z)\n\n    (seq nonneg) (n)\n\n    : abs (partial_sum seq n) = partial_sum seq n\n\n    := nonneg_to_abs _ (partial_sum.preserve_nonneg _ nonneg _)\n\nend absolute_value --————————————————————————————————————————————————————————————————————--\n\nend riemann_hypothesis --————————————————————————————————————————————————————————————————--\n", "meta": {"author": "bhgomes", "repo": "lean-riemann-hypothesis", "sha": "c36b744a2dc4a7a50c7de770096bd9a051f42ab9", "save_path": "github-repos/lean/bhgomes-lean-riemann-hypothesis", "path": "github-repos/lean/bhgomes-lean-riemann-hypothesis/lean-riemann-hypothesis-c36b744a2dc4a7a50c7de770096bd9a051f42ab9/src/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4861509771656168}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.endomorphism\nimport Mathlib.algebra.group_power.default\nimport Mathlib.PostPort\n\nuniverses u v v₁ u₁ \n\nnamespace Mathlib\n\n/-!\n# Conjugate morphisms by isomorphisms\n\nAn isomorphism `α : X ≅ Y` defines\n- a monoid isomorphism `conj : End X ≃* End Y` by `α.conj f = α.inv ≫ f ≫ α.hom`;\n- a group isomorphism `conj_Aut : Aut X ≃* Aut Y` by `α.conj_Aut f = α.symm ≪≫ f ≪≫ α`.\n\nFor completeness, we also define `hom_congr : (X ≅ X₁) → (Y ≅ Y₁) → (X ⟶ Y) ≃ (X₁ ⟶ Y₁)`, cf. `equiv.arrow_congr`.\n-/\n\nnamespace category_theory\n\n\nnamespace iso\n\n\n/-- If `X` is isomorphic to `X₁` and `Y` is isomorphic to `Y₁`, then\nthere is a natural bijection between `X ⟶ Y` and `X₁ ⟶ Y₁`. See also `equiv.arrow_congr`. -/\ndef hom_congr {C : Type u} [category C] {X : C} {Y : C} {X₁ : C} {Y₁ : C} (α : X ≅ X₁)\n    (β : Y ≅ Y₁) : (X ⟶ Y) ≃ (X₁ ⟶ Y₁) :=\n  equiv.mk (fun (f : X ⟶ Y) => inv α ≫ f ≫ hom β) (fun (f : X₁ ⟶ Y₁) => hom α ≫ f ≫ inv β) sorry\n    sorry\n\n@[simp] theorem hom_congr_apply {C : Type u} [category C] {X : C} {Y : C} {X₁ : C} {Y₁ : C}\n    (α : X ≅ X₁) (β : Y ≅ Y₁) (f : X ⟶ Y) : coe_fn (hom_congr α β) f = inv α ≫ f ≫ hom β :=\n  rfl\n\ntheorem hom_congr_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} {X₁ : C} {Y₁ : C} {Z₁ : C}\n    (α : X ≅ X₁) (β : Y ≅ Y₁) (γ : Z ≅ Z₁) (f : X ⟶ Y) (g : Y ⟶ Z) :\n    coe_fn (hom_congr α γ) (f ≫ g) = coe_fn (hom_congr α β) f ≫ coe_fn (hom_congr β γ) g :=\n  sorry\n\n@[simp] theorem hom_congr_refl {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) :\n    coe_fn (hom_congr (refl X) (refl Y)) f = f :=\n  sorry\n\n@[simp] theorem hom_congr_trans {C : Type u} [category C] {X₁ : C} {Y₁ : C} {X₂ : C} {Y₂ : C}\n    {X₃ : C} {Y₃ : C} (α₁ : X₁ ≅ X₂) (β₁ : Y₁ ≅ Y₂) (α₂ : X₂ ≅ X₃) (β₂ : Y₂ ≅ Y₃) (f : X₁ ⟶ Y₁) :\n    coe_fn (hom_congr (α₁ ≪≫ α₂) (β₁ ≪≫ β₂)) f =\n        coe_fn (equiv.trans (hom_congr α₁ β₁) (hom_congr α₂ β₂)) f :=\n  sorry\n\n@[simp] theorem hom_congr_symm {C : Type u} [category C] {X₁ : C} {Y₁ : C} {X₂ : C} {Y₂ : C}\n    (α : X₁ ≅ X₂) (β : Y₁ ≅ Y₂) : equiv.symm (hom_congr α β) = hom_congr (symm α) (symm β) :=\n  rfl\n\n/-- An isomorphism between two objects defines a monoid isomorphism between their\nmonoid of endomorphisms. -/\ndef conj {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) : End X ≃* End Y :=\n  mul_equiv.mk (equiv.to_fun (hom_congr α α)) (equiv.inv_fun (hom_congr α α)) sorry sorry sorry\n\ntheorem conj_apply {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : End X) :\n    coe_fn (conj α) f = inv α ≫ f ≫ hom α :=\n  rfl\n\n@[simp] theorem conj_comp {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : End X)\n    (g : End X) : coe_fn (conj α) (f ≫ g) = coe_fn (conj α) f ≫ coe_fn (conj α) g :=\n  mul_equiv.map_mul (conj α) g f\n\n@[simp] theorem conj_id {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    coe_fn (conj α) 𝟙 = 𝟙 :=\n  mul_equiv.map_one (conj α)\n\n@[simp] theorem refl_conj {C : Type u} [category C] {X : C} (f : End X) :\n    coe_fn (conj (refl X)) f = f :=\n  sorry\n\n@[simp] theorem trans_conj {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) {Z : C} (β : Y ≅ Z)\n    (f : End X) : coe_fn (conj (α ≪≫ β)) f = coe_fn (conj β) (coe_fn (conj α) f) :=\n  hom_congr_trans α α β β f\n\n@[simp] theorem symm_self_conj {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : End X) :\n    coe_fn (conj (symm α)) (coe_fn (conj α) f) = f :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (coe_fn (conj (symm α)) (coe_fn (conj α) f) = f))\n        (Eq.symm (trans_conj α (symm α) f))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (conj (α ≪≫ symm α)) f = f)) (self_symm_id α)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (conj (refl X)) f = f)) (refl_conj f))) (Eq.refl f)))\n\n@[simp] theorem self_symm_conj {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : End Y) :\n    coe_fn (conj α) (coe_fn (conj (symm α)) f) = f :=\n  symm_self_conj (symm α) f\n\n@[simp] theorem conj_pow {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : End X) (n : ℕ) :\n    coe_fn (conj α) (f ^ n) = coe_fn (conj α) f ^ n :=\n  monoid_hom.map_pow (mul_equiv.to_monoid_hom (conj α)) f n\n\n/-- `conj` defines a group isomorphisms between groups of automorphisms -/\ndef conj_Aut {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) : Aut X ≃* Aut Y :=\n  mul_equiv.trans (mul_equiv.symm (Aut.units_End_equiv_Aut X))\n    (mul_equiv.trans (units.map_equiv (conj α)) (Aut.units_End_equiv_Aut Y))\n\ntheorem conj_Aut_apply {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : Aut X) :\n    coe_fn (conj_Aut α) f = symm α ≪≫ f ≪≫ α :=\n  sorry\n\n@[simp] theorem conj_Aut_hom {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : Aut X) :\n    hom (coe_fn (conj_Aut α) f) = coe_fn (conj α) (hom f) :=\n  rfl\n\n@[simp] theorem trans_conj_Aut {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) {Z : C}\n    (β : Y ≅ Z) (f : Aut X) :\n    coe_fn (conj_Aut (α ≪≫ β)) f = coe_fn (conj_Aut β) (coe_fn (conj_Aut α) f) :=\n  sorry\n\n@[simp] theorem conj_Aut_mul {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : Aut X)\n    (g : Aut X) : coe_fn (conj_Aut α) (f * g) = coe_fn (conj_Aut α) f * coe_fn (conj_Aut α) g :=\n  mul_equiv.map_mul (conj_Aut α) f g\n\n@[simp] theorem conj_Aut_trans {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : Aut X)\n    (g : Aut X) : coe_fn (conj_Aut α) (f ≪≫ g) = coe_fn (conj_Aut α) f ≪≫ coe_fn (conj_Aut α) g :=\n  conj_Aut_mul α g f\n\n@[simp] theorem conj_Aut_pow {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : Aut X)\n    (n : ℕ) : coe_fn (conj_Aut α) (f ^ n) = coe_fn (conj_Aut α) f ^ n :=\n  monoid_hom.map_pow (mul_equiv.to_monoid_hom (conj_Aut α)) f n\n\n@[simp] theorem conj_Aut_gpow {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (f : Aut X)\n    (n : ℤ) : coe_fn (conj_Aut α) (f ^ n) = coe_fn (conj_Aut α) f ^ n :=\n  monoid_hom.map_gpow (mul_equiv.to_monoid_hom (conj_Aut α)) f n\n\nend iso\n\n\nnamespace functor\n\n\ntheorem map_hom_congr {C : Type u} [category C] {D : Type u₁} [category D] (F : C ⥤ D) {X : C}\n    {Y : C} {X₁ : C} {Y₁ : C} (α : X ≅ X₁) (β : Y ≅ Y₁) (f : X ⟶ Y) :\n    map F (coe_fn (iso.hom_congr α β) f) =\n        coe_fn (iso.hom_congr (map_iso F α) (map_iso F β)) (map F f) :=\n  sorry\n\ntheorem map_conj {C : Type u} [category C] {D : Type u₁} [category D] (F : C ⥤ D) {X : C} {Y : C}\n    (α : X ≅ Y) (f : End X) :\n    map F (coe_fn (iso.conj α) f) = coe_fn (iso.conj (map_iso F α)) (map F f) :=\n  map_hom_congr F α α f\n\ntheorem map_conj_Aut {C : Type u} [category C] {D : Type u₁} [category D] (F : C ⥤ D) {X : C}\n    {Y : C} (α : X ≅ Y) (f : Aut X) :\n    map_iso F (coe_fn (iso.conj_Aut α) f) = coe_fn (iso.conj_Aut (map_iso F α)) (map_iso F f) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/conj_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4861509771656167}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.products\nimport Mathlib.category_theory.limits.preserves.basic\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v \n\nnamespace Mathlib\n\n/-!\n# Preserving products\n\nConstructions to relate the notions of preserving products and reflecting products\nto concrete fans.\n\nIn particular, we show that `pi_comparison G f` is an isomorphism iff `G` preserves\nthe limit of `f`.\n-/\n\nnamespace category_theory.limits\n\n\n/--\nThe map of a fan is a limit iff the fan consisting of the mapped morphisms is a limit. This\nessentially lets us commute `fan.mk` with `functor.map_cone`.\n-/\ndef is_limit_map_cone_fan_mk_equiv {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) {P : C} (g : (j : J) → P ⟶ f j) : is_limit (functor.map_cone G (fan.mk P g)) ≃ is_limit (fan.mk (functor.obj G P) fun (j : J) => functor.map G (g j)) :=\n  equiv.trans\n    (equiv.symm\n      (is_limit.postcompose_hom_equiv (discrete.nat_iso fun (j : discrete J) => iso.refl (functor.obj G (f j)))\n        (functor.map_cone G (fan.mk P g))))\n    (is_limit.equiv_iso_limit\n      (cones.ext\n        (iso.refl\n          (cone.X\n            (functor.obj\n              (cones.postcompose (iso.hom (discrete.nat_iso fun (j : discrete J) => iso.refl (functor.obj G (f j)))))\n              (functor.map_cone G (fan.mk P g)))))\n        sorry))\n\n/-- The property of preserving products expressed in terms of fans. -/\ndef is_limit_fan_mk_obj_of_is_limit {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) [preserves_limit (discrete.functor f) G] {P : C} (g : (j : J) → P ⟶ f j) (t : is_limit (fan.mk P g)) : is_limit (fan.mk (functor.obj G P) fun (j : J) => functor.map G (g j)) :=\n  coe_fn (is_limit_map_cone_fan_mk_equiv G (fun (j : J) => f j) g) (preserves_limit.preserves t)\n\n/-- The property of reflecting products expressed in terms of fans. -/\ndef is_limit_of_is_limit_fan_mk_obj {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) [reflects_limit (discrete.functor f) G] {P : C} (g : (j : J) → P ⟶ f j) (t : is_limit (fan.mk (functor.obj G P) fun (j : J) => functor.map G (g j))) : is_limit (fan.mk P g) :=\n  reflects_limit.reflects\n    (coe_fn (equiv.symm (is_limit_map_cone_fan_mk_equiv G (fun (j : J) => f j) fun (j : J) => g j)) t)\n\n/--\nIf `G` preserves products and `C` has them, then the fan constructed of the mapped projection of a\nproduct is a limit.\n-/\ndef is_limit_of_has_product_of_preserves_limit {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) [has_product f] [preserves_limit (discrete.functor f) G] : is_limit (fan.mk (functor.obj G (∏ f)) fun (j : J) => functor.map G (pi.π f j)) :=\n  is_limit_fan_mk_obj_of_is_limit G f (fun (j : J) => pi.π f j) (product_is_product fun (j : J) => f j)\n\n/-- If `pi_comparison G f` is an isomorphism, then `G` preserves the limit of `f`. -/\ndef preserves_product.of_iso_comparison {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) [has_product f] [has_product fun (j : J) => functor.obj G (f j)] [i : is_iso (pi_comparison G f)] : preserves_limit (discrete.functor f) G :=\n  preserves_limit_of_preserves_limit_cone (product_is_product f)\n    (coe_fn (equiv.symm (is_limit_map_cone_fan_mk_equiv G (fun (b : J) => f b) (pi.π f)))\n      (is_limit.of_point_iso (limit.is_limit (discrete.functor fun (j : J) => functor.obj G (f j)))))\n\n/--\nIf `G` preserves limits, we have an isomorphism from the image of a product to the product of the\nimages.\n-/\ndef preserves_product.iso {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) [has_product f] [has_product fun (j : J) => functor.obj G (f j)] [preserves_limit (discrete.functor f) G] : functor.obj G (∏ f) ≅ ∏ fun (j : J) => functor.obj G (f j) :=\n  is_limit.cone_point_unique_up_to_iso (is_limit_of_has_product_of_preserves_limit G f)\n    (limit.is_limit (discrete.functor fun (j : J) => functor.obj G (f j)))\n\n@[simp] theorem preserves_product.iso_hom {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) [has_product f] [has_product fun (j : J) => functor.obj G (f j)] [preserves_limit (discrete.functor f) G] : iso.hom (preserves_product.iso G f) = pi_comparison G f :=\n  rfl\n\nprotected instance pi_comparison.category_theory.is_iso {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) {J : Type v} (f : J → C) [has_product f] [has_product fun (j : J) => functor.obj G (f j)] [preserves_limit (discrete.functor f) G] : is_iso (pi_comparison G f) :=\n  eq.mpr sorry (is_iso.of_iso (preserves_product.iso G f))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/preserves/shapes/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.48608744780292934}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.local_equiv\nimport Mathlib.topology.opens\nimport Mathlib.PostPort\n\nuniverses u_5 u_6 l u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Local homeomorphisms\n\nThis file defines homeomorphisms between open subsets of topological spaces. An element `e` of\n`local_homeomorph α β` is an extension of `local_equiv α β`, i.e., it is a pair of functions\n`e.to_fun` and `e.inv_fun`, inverse of each other on the sets `e.source` and `e.target`.\nAdditionally, we require that these sets are open, and that the functions are continuous on them.\nEquivalently, they are homeomorphisms there.\n\nAs in equivs, we register a coercion to functions, and we use `e x` and `e.symm x` throughout\ninstead of `e.to_fun x` and `e.inv_fun x`.\n\n## Main definitions\n\n`homeomorph.to_local_homeomorph`: associating a local homeomorphism to a homeomorphism, with\n                                  source = target = univ\n`local_homeomorph.symm`  : the inverse of a local homeomorphism\n`local_homeomorph.trans` : the composition of two local homeomorphisms\n`local_homeomorph.refl`  : the identity local homeomorphism\n`local_homeomorph.of_set`: the identity on a set `s`\n`eq_on_source`           : equivalence relation describing the \"right\" notion of equality for local\n                           homeomorphisms\n\n## Implementation notes\n\nMost statements are copied from their local_equiv versions, although some care is required\nespecially when restricting to subsets, as these should be open subsets.\n\nFor design notes, see `local_equiv.lean`.\n-/\n\n/-- local homeomorphisms, defined on open subsets of the space -/\nstructure local_homeomorph (α : Type u_5) (β : Type u_6) [topological_space α] [topological_space β] \nextends local_equiv α β\nwhere\n  open_source : is_open (local_equiv.source _to_local_equiv)\n  open_target : is_open (local_equiv.target _to_local_equiv)\n  continuous_to_fun : continuous_on (local_equiv.to_fun _to_local_equiv) (local_equiv.source _to_local_equiv)\n  continuous_inv_fun : continuous_on (local_equiv.inv_fun _to_local_equiv) (local_equiv.target _to_local_equiv)\n\n/-- A homeomorphism induces a local homeomorphism on the whole space -/\ndef homeomorph.to_local_homeomorph {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α ≃ₜ β) : local_homeomorph α β :=\n  local_homeomorph.mk\n    (local_equiv.mk (local_equiv.to_fun (equiv.to_local_equiv (homeomorph.to_equiv e)))\n      (local_equiv.inv_fun (equiv.to_local_equiv (homeomorph.to_equiv e)))\n      (local_equiv.source (equiv.to_local_equiv (homeomorph.to_equiv e)))\n      (local_equiv.target (equiv.to_local_equiv (homeomorph.to_equiv e))) sorry sorry sorry sorry)\n    is_open_univ is_open_univ sorry sorry\n\nnamespace local_homeomorph\n\n\nprotected instance has_coe_to_fun {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] : has_coe_to_fun (local_homeomorph α β) :=\n  has_coe_to_fun.mk (fun (e : local_homeomorph α β) => α → β)\n    fun (e : local_homeomorph α β) => local_equiv.to_fun (to_local_equiv e)\n\n/-- The inverse of a local homeomorphism -/\nprotected def symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_homeomorph β α :=\n  mk\n    (local_equiv.mk (local_equiv.to_fun (local_equiv.symm (to_local_equiv e)))\n      (local_equiv.inv_fun (local_equiv.symm (to_local_equiv e)))\n      (local_equiv.source (local_equiv.symm (to_local_equiv e)))\n      (local_equiv.target (local_equiv.symm (to_local_equiv e))) sorry sorry sorry sorry)\n    (open_target e) (open_source e) (continuous_inv_fun e) (continuous_to_fun e)\n\nprotected theorem continuous_on {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : continuous_on (⇑e) (local_equiv.source (to_local_equiv e)) :=\n  continuous_to_fun e\n\ntheorem continuous_on_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : continuous_on (⇑(local_homeomorph.symm e)) (local_equiv.target (to_local_equiv e)) :=\n  continuous_inv_fun e\n\n@[simp] theorem mk_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_equiv α β) (a : is_open (local_equiv.source e)) (b : is_open (local_equiv.target e)) (c : continuous_on (local_equiv.to_fun e) (local_equiv.source e)) (d : continuous_on (local_equiv.inv_fun e) (local_equiv.target e)) : ⇑(mk e a b c d) = ⇑e :=\n  rfl\n\n@[simp] theorem mk_coe_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_equiv α β) (a : is_open (local_equiv.source e)) (b : is_open (local_equiv.target e)) (c : continuous_on (local_equiv.to_fun e) (local_equiv.source e)) (d : continuous_on (local_equiv.inv_fun e) (local_equiv.target e)) : ⇑(local_homeomorph.symm (mk e a b c d)) = ⇑(local_equiv.symm e) :=\n  rfl\n\n/- Register a few simp lemmas to make sure that `simp` puts the application of a local\nhomeomorphism in its normal form, i.e., in terms of its coercion to a function. -/\n\n@[simp] theorem to_fun_eq_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_equiv.to_fun (to_local_equiv e) = ⇑e :=\n  rfl\n\n@[simp] theorem inv_fun_eq_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_equiv.inv_fun (to_local_equiv e) = ⇑(local_homeomorph.symm e) :=\n  rfl\n\n@[simp] theorem coe_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : ⇑(to_local_equiv e) = ⇑e :=\n  rfl\n\n@[simp] theorem coe_coe_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : ⇑(local_equiv.symm (to_local_equiv e)) = ⇑(local_homeomorph.symm e) :=\n  rfl\n\n@[simp] theorem map_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (h : x ∈ local_equiv.source (to_local_equiv e)) : coe_fn e x ∈ local_equiv.target (to_local_equiv e) :=\n  local_equiv.map_source' (to_local_equiv e) h\n\n@[simp] theorem map_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : β} (h : x ∈ local_equiv.target (to_local_equiv e)) : coe_fn (local_homeomorph.symm e) x ∈ local_equiv.source (to_local_equiv e) :=\n  local_equiv.map_target' (to_local_equiv e) h\n\n@[simp] theorem left_inv {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (h : x ∈ local_equiv.source (to_local_equiv e)) : coe_fn (local_homeomorph.symm e) (coe_fn e x) = x :=\n  local_equiv.left_inv' (to_local_equiv e) h\n\n@[simp] theorem right_inv {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : β} (h : x ∈ local_equiv.target (to_local_equiv e)) : coe_fn e (coe_fn (local_homeomorph.symm e) x) = x :=\n  local_equiv.right_inv' (to_local_equiv e) h\n\ntheorem source_preimage_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_equiv.source (to_local_equiv e) ⊆ ⇑e ⁻¹' local_equiv.target (to_local_equiv e) :=\n  fun (_x : α) (h : _x ∈ local_equiv.source (to_local_equiv e)) => map_source e h\n\ntheorem eq_of_local_equiv_eq {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (h : to_local_equiv e = to_local_equiv e') : e = e' := sorry\n\ntheorem eventually_left_inverse {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (hx : x ∈ local_equiv.source (to_local_equiv e)) : filter.eventually (fun (y : α) => coe_fn (local_homeomorph.symm e) (coe_fn e y) = y) (nhds x) :=\n  filter.eventually.mono (is_open.eventually_mem (open_source e) hx) (local_equiv.left_inv' (to_local_equiv e))\n\ntheorem eventually_left_inverse' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : β} (hx : x ∈ local_equiv.target (to_local_equiv e)) : filter.eventually (fun (y : α) => coe_fn (local_homeomorph.symm e) (coe_fn e y) = y)\n  (nhds (coe_fn (local_homeomorph.symm e) x)) :=\n  eventually_left_inverse e (map_target e hx)\n\ntheorem eventually_right_inverse {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : β} (hx : x ∈ local_equiv.target (to_local_equiv e)) : filter.eventually (fun (y : β) => coe_fn e (coe_fn (local_homeomorph.symm e) y) = y) (nhds x) :=\n  filter.eventually.mono (is_open.eventually_mem (open_target e) hx) (local_equiv.right_inv' (to_local_equiv e))\n\ntheorem eventually_right_inverse' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (hx : x ∈ local_equiv.source (to_local_equiv e)) : filter.eventually (fun (y : β) => coe_fn e (coe_fn (local_homeomorph.symm e) y) = y) (nhds (coe_fn e x)) :=\n  eventually_right_inverse e (map_source e hx)\n\ntheorem eventually_ne_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (hx : x ∈ local_equiv.source (to_local_equiv e)) : filter.eventually (fun (x' : α) => coe_fn e x' ≠ coe_fn e x) (nhds_within x (singleton xᶜ)) := sorry\n\ntheorem image_eq_target_inter_inv_preimage {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set α} (h : s ⊆ local_equiv.source (to_local_equiv e)) : ⇑e '' s = local_equiv.target (to_local_equiv e) ∩ ⇑(local_homeomorph.symm e) ⁻¹' s :=\n  local_equiv.image_eq_target_inter_inv_preimage (to_local_equiv e) h\n\ntheorem image_inter_source_eq {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : ⇑e '' (s ∩ local_equiv.source (to_local_equiv e)) =\n  local_equiv.target (to_local_equiv e) ∩ ⇑(local_homeomorph.symm e) ⁻¹' (s ∩ local_equiv.source (to_local_equiv e)) :=\n  image_eq_target_inter_inv_preimage e (set.inter_subset_right s (local_equiv.source (to_local_equiv e)))\n\ntheorem symm_image_eq_source_inter_preimage {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set β} (h : s ⊆ local_equiv.target (to_local_equiv e)) : ⇑(local_homeomorph.symm e) '' s = local_equiv.source (to_local_equiv e) ∩ ⇑e ⁻¹' s :=\n  image_eq_target_inter_inv_preimage (local_homeomorph.symm e) h\n\ntheorem symm_image_inter_target_eq {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set β) : ⇑(local_homeomorph.symm e) '' (s ∩ local_equiv.target (to_local_equiv e)) =\n  local_equiv.source (to_local_equiv e) ∩ ⇑e ⁻¹' (s ∩ local_equiv.target (to_local_equiv e)) :=\n  image_inter_source_eq (local_homeomorph.symm e) s\n\n/-- Two local homeomorphisms are equal when they have equal `to_fun`, `inv_fun` and `source`.\nIt is not sufficient to have equal `to_fun` and `source`, as this only determines `inv_fun` on\nthe target. This would only be true for a weaker notion of equality, arguably the right one,\ncalled `eq_on_source`. -/\nprotected theorem ext {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (e' : local_homeomorph α β) (h : ∀ (x : α), coe_fn e x = coe_fn e' x) (hinv : ∀ (x : β), coe_fn (local_homeomorph.symm e) x = coe_fn (local_homeomorph.symm e') x) (hs : local_equiv.source (to_local_equiv e) = local_equiv.source (to_local_equiv e')) : e = e' :=\n  eq_of_local_equiv_eq (local_equiv.ext h hinv hs)\n\n-- The following lemmas are already simp via local_equiv\n\n@[simp] theorem symm_to_local_equiv {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : to_local_equiv (local_homeomorph.symm e) = local_equiv.symm (to_local_equiv e) :=\n  rfl\n\ntheorem symm_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_equiv.source (to_local_equiv (local_homeomorph.symm e)) = local_equiv.target (to_local_equiv e) :=\n  rfl\n\ntheorem symm_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_equiv.target (to_local_equiv (local_homeomorph.symm e)) = local_equiv.source (to_local_equiv e) :=\n  rfl\n\n@[simp] theorem symm_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_homeomorph.symm (local_homeomorph.symm e) = e := sorry\n\n/-- A local homeomorphism is continuous at any point of its source -/\nprotected theorem continuous_at {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (h : x ∈ local_equiv.source (to_local_equiv e)) : continuous_at (⇑e) x :=\n  continuous_within_at.continuous_at (local_homeomorph.continuous_on e x h) (mem_nhds_sets (open_source e) h)\n\n/-- A local homeomorphism inverse is continuous at any point of its target -/\ntheorem continuous_at_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : β} (h : x ∈ local_equiv.target (to_local_equiv e)) : continuous_at (⇑(local_homeomorph.symm e)) x :=\n  local_homeomorph.continuous_at (local_homeomorph.symm e) h\n\ntheorem tendsto_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (hx : x ∈ local_equiv.source (to_local_equiv e)) : filter.tendsto (⇑(local_homeomorph.symm e)) (nhds (coe_fn e x)) (nhds x) := sorry\n\ntheorem map_nhds_eq {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {x : α} (hx : x ∈ local_equiv.source (to_local_equiv e)) : filter.map (⇑e) (nhds x) = nhds (coe_fn e x) :=\n  le_antisymm (local_homeomorph.continuous_at e hx)\n    (filter.le_map_of_right_inverse (eventually_right_inverse' e hx) (tendsto_symm e hx))\n\n/-- Preimage of interior or interior of preimage coincide for local homeomorphisms, when restricted\nto the source. -/\ntheorem preimage_interior {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set β) : local_equiv.source (to_local_equiv e) ∩ ⇑e ⁻¹' interior s = local_equiv.source (to_local_equiv e) ∩ interior (⇑e ⁻¹' s) := sorry\n\ntheorem preimage_open_of_open {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set β} (hs : is_open s) : is_open (local_equiv.source (to_local_equiv e) ∩ ⇑e ⁻¹' s) :=\n  continuous_on.preimage_open_of_open (local_homeomorph.continuous_on e) (open_source e) hs\n\ntheorem preimage_open_of_open_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set α} (hs : is_open s) : is_open (local_equiv.target (to_local_equiv e) ∩ ⇑(local_homeomorph.symm e) ⁻¹' s) :=\n  continuous_on.preimage_open_of_open (local_homeomorph.continuous_on (local_homeomorph.symm e)) (open_target e) hs\n\n/-- The image of an open set in the source is open. -/\ntheorem image_open_of_open {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set α} (hs : is_open s) (h : s ⊆ local_equiv.source (to_local_equiv e)) : is_open (⇑e '' s) :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (is_open (⇑e '' s))) (local_equiv.image_eq_target_inter_inv_preimage (to_local_equiv e) h)))\n    (continuous_on.preimage_open_of_open (continuous_on_symm e) (open_target e) hs)\n\n/-- The image of the restriction of an open set to the source is open. -/\ntheorem image_open_of_open' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set α} (hs : is_open s) : is_open (⇑e '' (s ∩ local_equiv.source (to_local_equiv e))) := sorry\n\n/-- Restricting a local homeomorphism `e` to `e.source ∩ s` when `s` is open. This is sometimes hard\nto use because of the openness assumption, but it has the advantage that when it can\nbe used then its local_equiv is defeq to local_equiv.restr -/\nprotected def restr_open {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) (hs : is_open s) : local_homeomorph α β :=\n  mk\n    (local_equiv.mk (local_equiv.to_fun (local_equiv.restr (to_local_equiv e) s))\n      (local_equiv.inv_fun (local_equiv.restr (to_local_equiv e) s))\n      (local_equiv.source (local_equiv.restr (to_local_equiv e) s))\n      (local_equiv.target (local_equiv.restr (to_local_equiv e) s)) sorry sorry sorry sorry)\n    sorry sorry sorry sorry\n\n@[simp] theorem restr_open_to_local_equiv {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) (hs : is_open s) : to_local_equiv (local_homeomorph.restr_open e s hs) = local_equiv.restr (to_local_equiv e) s :=\n  rfl\n\n-- Already simp via local_equiv\n\ntheorem restr_open_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) (hs : is_open s) : local_equiv.source (to_local_equiv (local_homeomorph.restr_open e s hs)) = local_equiv.source (to_local_equiv e) ∩ s :=\n  rfl\n\n/-- Restricting a local homeomorphism `e` to `e.source ∩ interior s`. We use the interior to make\nsure that the restriction is well defined whatever the set s, since local homeomorphisms are by\ndefinition defined on open sets. In applications where `s` is open, this coincides with the\nrestriction of local equivalences -/\nprotected def restr {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : local_homeomorph α β :=\n  local_homeomorph.restr_open e (interior s) is_open_interior\n\n@[simp] theorem restr_to_local_equiv {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : to_local_equiv (local_homeomorph.restr e s) = local_equiv.restr (to_local_equiv e) (interior s) :=\n  rfl\n\n@[simp] theorem restr_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : ⇑(local_homeomorph.restr e s) = ⇑e :=\n  rfl\n\n@[simp] theorem restr_coe_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : ⇑(local_homeomorph.symm (local_homeomorph.restr e s)) = ⇑(local_homeomorph.symm e) :=\n  rfl\n\ntheorem restr_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : local_equiv.source (to_local_equiv (local_homeomorph.restr e s)) = local_equiv.source (to_local_equiv e) ∩ interior s :=\n  rfl\n\ntheorem restr_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : local_equiv.target (to_local_equiv (local_homeomorph.restr e s)) =\n  local_equiv.target (to_local_equiv e) ∩ ⇑(local_homeomorph.symm e) ⁻¹' interior s :=\n  rfl\n\ntheorem restr_source' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) (hs : is_open s) : local_equiv.source (to_local_equiv (local_homeomorph.restr e s)) = local_equiv.source (to_local_equiv e) ∩ s := sorry\n\ntheorem restr_to_local_equiv' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) (hs : is_open s) : to_local_equiv (local_homeomorph.restr e s) = local_equiv.restr (to_local_equiv e) s := sorry\n\ntheorem restr_eq_of_source_subset {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {s : set α} (h : local_equiv.source (to_local_equiv e) ⊆ s) : local_homeomorph.restr e s = e := sorry\n\n@[simp] theorem restr_univ {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} : local_homeomorph.restr e set.univ = e :=\n  restr_eq_of_source_subset (set.subset_univ (local_equiv.source (to_local_equiv e)))\n\ntheorem restr_source_inter {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : set α) : local_homeomorph.restr e (local_equiv.source (to_local_equiv e) ∩ s) = local_homeomorph.restr e s := sorry\n\n/-- The identity on the whole space as a local homeomorphism. -/\nprotected def refl (α : Type u_1) [topological_space α] : local_homeomorph α α :=\n  homeomorph.to_local_homeomorph (homeomorph.refl α)\n\n@[simp] theorem refl_local_equiv {α : Type u_1} [topological_space α] : to_local_equiv (local_homeomorph.refl α) = local_equiv.refl α :=\n  rfl\n\ntheorem refl_source {α : Type u_1} [topological_space α] : local_equiv.source (to_local_equiv (local_homeomorph.refl α)) = set.univ :=\n  rfl\n\ntheorem refl_target {α : Type u_1} [topological_space α] : local_equiv.target (to_local_equiv (local_homeomorph.refl α)) = set.univ :=\n  rfl\n\n@[simp] theorem refl_symm {α : Type u_1} [topological_space α] : local_homeomorph.symm (local_homeomorph.refl α) = local_homeomorph.refl α :=\n  rfl\n\n@[simp] theorem refl_coe {α : Type u_1} [topological_space α] : ⇑(local_homeomorph.refl α) = id :=\n  rfl\n\n/-- The identity local equiv on a set `s` -/\ndef of_set {α : Type u_1} [topological_space α] (s : set α) (hs : is_open s) : local_homeomorph α α :=\n  mk\n    (local_equiv.mk (local_equiv.to_fun (local_equiv.of_set s)) (local_equiv.inv_fun (local_equiv.of_set s))\n      (local_equiv.source (local_equiv.of_set s)) (local_equiv.target (local_equiv.of_set s)) sorry sorry sorry sorry)\n    hs hs sorry sorry\n\n@[simp] theorem of_set_to_local_equiv {α : Type u_1} [topological_space α] {s : set α} (hs : is_open s) : to_local_equiv (of_set s hs) = local_equiv.of_set s :=\n  rfl\n\ntheorem of_set_source {α : Type u_1} [topological_space α] {s : set α} (hs : is_open s) : local_equiv.source (to_local_equiv (of_set s hs)) = s :=\n  rfl\n\ntheorem of_set_target {α : Type u_1} [topological_space α] {s : set α} (hs : is_open s) : local_equiv.target (to_local_equiv (of_set s hs)) = s :=\n  rfl\n\n@[simp] theorem of_set_coe {α : Type u_1} [topological_space α] {s : set α} (hs : is_open s) : ⇑(of_set s hs) = id :=\n  rfl\n\n@[simp] theorem of_set_symm {α : Type u_1} [topological_space α] {s : set α} (hs : is_open s) : local_homeomorph.symm (of_set s hs) = of_set s hs :=\n  rfl\n\n@[simp] theorem of_set_univ_eq_refl {α : Type u_1} [topological_space α] : of_set set.univ is_open_univ = local_homeomorph.refl α := sorry\n\n/-- Composition of two local homeomorphisms when the target of the first and the source of\nthe second coincide. -/\nprotected def trans' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) (h : local_equiv.target (to_local_equiv e) = local_equiv.source (to_local_equiv e')) : local_homeomorph α γ :=\n  mk\n    (local_equiv.mk (local_equiv.to_fun (local_equiv.trans' (to_local_equiv e) (to_local_equiv e') h))\n      (local_equiv.inv_fun (local_equiv.trans' (to_local_equiv e) (to_local_equiv e') h))\n      (local_equiv.source (local_equiv.trans' (to_local_equiv e) (to_local_equiv e') h))\n      (local_equiv.target (local_equiv.trans' (to_local_equiv e) (to_local_equiv e') h)) sorry sorry sorry sorry)\n    (open_source e) (open_target e') sorry sorry\n\n/-- Composing two local homeomorphisms, by restricting to the maximal domain where their\ncomposition is well defined. -/\nprotected def trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_homeomorph α γ :=\n  local_homeomorph.trans'\n    (local_homeomorph.symm\n      (local_homeomorph.restr_open (local_homeomorph.symm e) (local_equiv.source (to_local_equiv e')) (open_source e')))\n    (local_homeomorph.restr_open e' (local_equiv.target (to_local_equiv e)) (open_target e)) sorry\n\n@[simp] theorem trans_to_local_equiv {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : to_local_equiv (local_homeomorph.trans e e') = local_equiv.trans (to_local_equiv e) (to_local_equiv e') :=\n  rfl\n\n@[simp] theorem coe_trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : ⇑(local_homeomorph.trans e e') = ⇑e' ∘ ⇑e :=\n  rfl\n\n@[simp] theorem coe_trans_symm {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : ⇑(local_homeomorph.symm (local_homeomorph.trans e e')) = ⇑(local_homeomorph.symm e) ∘ ⇑(local_homeomorph.symm e') :=\n  rfl\n\ntheorem trans_symm_eq_symm_trans_symm {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_homeomorph.symm (local_homeomorph.trans e e') =\n  local_homeomorph.trans (local_homeomorph.symm e') (local_homeomorph.symm e) := sorry\n\n/- This could be considered as a simp lemma, but there are many situations where it makes something\nsimple into something more complicated. -/\n\ntheorem trans_source {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.source (to_local_equiv e) ∩ ⇑e ⁻¹' local_equiv.source (to_local_equiv e') :=\n  local_equiv.trans_source (to_local_equiv e) (to_local_equiv e')\n\ntheorem trans_source' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.source (to_local_equiv e) ∩\n    ⇑e ⁻¹' (local_equiv.target (to_local_equiv e) ∩ local_equiv.source (to_local_equiv e')) :=\n  local_equiv.trans_source' (to_local_equiv e) (to_local_equiv e')\n\ntheorem trans_source'' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  ⇑(local_homeomorph.symm e) '' (local_equiv.target (to_local_equiv e) ∩ local_equiv.source (to_local_equiv e')) :=\n  local_equiv.trans_source'' (to_local_equiv e) (to_local_equiv e')\n\ntheorem image_trans_source {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : ⇑e '' local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.target (to_local_equiv e) ∩ local_equiv.source (to_local_equiv e') :=\n  local_equiv.image_trans_source (to_local_equiv e) (to_local_equiv e')\n\ntheorem trans_target {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.target (to_local_equiv e') ∩ ⇑(local_homeomorph.symm e') ⁻¹' local_equiv.target (to_local_equiv e) :=\n  rfl\n\ntheorem trans_target' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.target (to_local_equiv e') ∩\n    ⇑(local_homeomorph.symm e') ⁻¹' (local_equiv.source (to_local_equiv e') ∩ local_equiv.target (to_local_equiv e)) :=\n  trans_source' (local_homeomorph.symm e') (local_homeomorph.symm e)\n\ntheorem trans_target'' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  ⇑e' '' (local_equiv.source (to_local_equiv e') ∩ local_equiv.target (to_local_equiv e)) :=\n  trans_source'' (local_homeomorph.symm e') (local_homeomorph.symm e)\n\ntheorem inv_image_trans_target {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) : ⇑(local_homeomorph.symm e') '' local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.source (to_local_equiv e') ∩ local_equiv.target (to_local_equiv e) :=\n  image_trans_source (local_homeomorph.symm e') (local_homeomorph.symm e)\n\ntheorem trans_assoc {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) (e'' : local_homeomorph γ δ) : local_homeomorph.trans (local_homeomorph.trans e e') e'' = local_homeomorph.trans e (local_homeomorph.trans e' e'') :=\n  eq_of_local_equiv_eq (local_equiv.trans_assoc (to_local_equiv e) (to_local_equiv e') (to_local_equiv e''))\n\n@[simp] theorem trans_refl {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_homeomorph.trans e (local_homeomorph.refl β) = e :=\n  eq_of_local_equiv_eq (local_equiv.trans_refl (to_local_equiv e))\n\n@[simp] theorem refl_trans {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_homeomorph.trans (local_homeomorph.refl α) e = e :=\n  eq_of_local_equiv_eq (local_equiv.refl_trans (to_local_equiv e))\n\ntheorem trans_of_set {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set β} (hs : is_open s) : local_homeomorph.trans e (of_set s hs) = local_homeomorph.restr e (⇑e ⁻¹' s) := sorry\n\ntheorem trans_of_set' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set β} (hs : is_open s) : local_homeomorph.trans e (of_set s hs) = local_homeomorph.restr e (local_equiv.source (to_local_equiv e) ∩ ⇑e ⁻¹' s) := sorry\n\ntheorem of_set_trans {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set α} (hs : is_open s) : local_homeomorph.trans (of_set s hs) e = local_homeomorph.restr e s := sorry\n\ntheorem of_set_trans' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) {s : set α} (hs : is_open s) : local_homeomorph.trans (of_set s hs) e = local_homeomorph.restr e (local_equiv.source (to_local_equiv e) ∩ s) := sorry\n\n@[simp] theorem of_set_trans_of_set {α : Type u_1} [topological_space α] {s : set α} (hs : is_open s) {s' : set α} (hs' : is_open s') : local_homeomorph.trans (of_set s hs) (of_set s' hs') = of_set (s ∩ s') (is_open_inter hs hs') := sorry\n\ntheorem restr_trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) (e' : local_homeomorph β γ) (s : set α) : local_homeomorph.trans (local_homeomorph.restr e s) e' = local_homeomorph.restr (local_homeomorph.trans e e') s :=\n  eq_of_local_equiv_eq (local_equiv.restr_trans (to_local_equiv e) (to_local_equiv e') (interior s))\n\n/-- `eq_on_source e e'` means that `e` and `e'` have the same source, and coincide there. They\nshould really be considered the same local equiv. -/\ndef eq_on_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (e' : local_homeomorph α β) :=\n  local_equiv.source (to_local_equiv e) = local_equiv.source (to_local_equiv e') ∧\n    set.eq_on (⇑e) (⇑e') (local_equiv.source (to_local_equiv e))\n\ntheorem eq_on_source_iff {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (e' : local_homeomorph α β) : eq_on_source e e' ↔ local_equiv.eq_on_source (to_local_equiv e) (to_local_equiv e') :=\n  iff.rfl\n\n/-- `eq_on_source` is an equivalence relation -/\nprotected instance setoid {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] : setoid (local_homeomorph α β) :=\n  setoid.mk eq_on_source sorry\n\ntheorem eq_on_source_refl {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : e ≈ e :=\n  setoid.refl e\n\n/-- If two local homeomorphisms are equivalent, so are their inverses -/\ntheorem eq_on_source.symm' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (h : e ≈ e') : local_homeomorph.symm e ≈ local_homeomorph.symm e' :=\n  local_equiv.eq_on_source.symm' h\n\n/-- Two equivalent local homeomorphisms have the same source -/\ntheorem eq_on_source.source_eq {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (h : e ≈ e') : local_equiv.source (to_local_equiv e) = local_equiv.source (to_local_equiv e') :=\n  and.left h\n\n/-- Two equivalent local homeomorphisms have the same target -/\ntheorem eq_on_source.target_eq {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (h : e ≈ e') : local_equiv.target (to_local_equiv e) = local_equiv.target (to_local_equiv e') :=\n  and.left (eq_on_source.symm' h)\n\n/-- Two equivalent local homeomorphisms have coinciding `to_fun` on the source -/\ntheorem eq_on_source.eq_on {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (h : e ≈ e') : set.eq_on (⇑e) (⇑e') (local_equiv.source (to_local_equiv e)) :=\n  and.right h\n\n/-- Two equivalent local homeomorphisms have coinciding `inv_fun` on the target -/\ntheorem eq_on_source.symm_eq_on_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (h : e ≈ e') : set.eq_on (⇑(local_homeomorph.symm e)) (⇑(local_homeomorph.symm e')) (local_equiv.target (to_local_equiv e)) :=\n  and.right (eq_on_source.symm' h)\n\n/-- Composition of local homeomorphisms respects equivalence -/\ntheorem eq_on_source.trans' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {e : local_homeomorph α β} {e' : local_homeomorph α β} {f : local_homeomorph β γ} {f' : local_homeomorph β γ} (he : e ≈ e') (hf : f ≈ f') : local_homeomorph.trans e f ≈ local_homeomorph.trans e' f' :=\n  local_equiv.eq_on_source.trans' he hf\n\n/-- Restriction of local homeomorphisms respects equivalence -/\ntheorem eq_on_source.restr {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (he : e ≈ e') (s : set α) : local_homeomorph.restr e s ≈ local_homeomorph.restr e' s :=\n  local_equiv.eq_on_source.restr he (interior s)\n\n/-- Composition of a local homeomorphism and its inverse is equivalent to the restriction of the\nidentity to the source -/\ntheorem trans_self_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_homeomorph.trans e (local_homeomorph.symm e) ≈ of_set (local_equiv.source (to_local_equiv e)) (open_source e) :=\n  local_equiv.trans_self_symm (to_local_equiv e)\n\ntheorem trans_symm_self {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) : local_homeomorph.trans (local_homeomorph.symm e) e ≈ of_set (local_equiv.target (to_local_equiv e)) (open_target e) :=\n  trans_self_symm (local_homeomorph.symm e)\n\ntheorem eq_of_eq_on_source_univ {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {e : local_homeomorph α β} {e' : local_homeomorph α β} (h : e ≈ e') (s : local_equiv.source (to_local_equiv e) = set.univ) (t : local_equiv.target (to_local_equiv e) = set.univ) : e = e' :=\n  eq_of_local_equiv_eq (local_equiv.eq_of_eq_on_source_univ (to_local_equiv e) (to_local_equiv e') h s t)\n\n/-- The product of two local homeomorphisms, as a local homeomorphism on the product space. -/\ndef prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph γ δ) : local_homeomorph (α × γ) (β × δ) :=\n  mk\n    (local_equiv.mk (local_equiv.to_fun (local_equiv.prod (to_local_equiv e) (to_local_equiv e')))\n      (local_equiv.inv_fun (local_equiv.prod (to_local_equiv e) (to_local_equiv e')))\n      (local_equiv.source (local_equiv.prod (to_local_equiv e) (to_local_equiv e')))\n      (local_equiv.target (local_equiv.prod (to_local_equiv e) (to_local_equiv e'))) sorry sorry sorry sorry)\n    sorry sorry sorry sorry\n\n@[simp] theorem prod_to_local_equiv {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph γ δ) : to_local_equiv (prod e e') = local_equiv.prod (to_local_equiv e) (to_local_equiv e') :=\n  rfl\n\ntheorem prod_source {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph γ δ) : local_equiv.source (to_local_equiv (prod e e')) =\n  set.prod (local_equiv.source (to_local_equiv e)) (local_equiv.source (to_local_equiv e')) :=\n  rfl\n\ntheorem prod_target {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph γ δ) : local_equiv.target (to_local_equiv (prod e e')) =\n  set.prod (local_equiv.target (to_local_equiv e)) (local_equiv.target (to_local_equiv e')) :=\n  rfl\n\n@[simp] theorem prod_coe {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph γ δ) : ⇑(prod e e') = fun (p : α × γ) => (coe_fn e (prod.fst p), coe_fn e' (prod.snd p)) :=\n  rfl\n\ntheorem prod_coe_symm {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph γ δ) : ⇑(local_homeomorph.symm (prod e e')) =\n  fun (p : β × δ) => (coe_fn (local_homeomorph.symm e) (prod.fst p), coe_fn (local_homeomorph.symm e') (prod.snd p)) :=\n  rfl\n\n@[simp] theorem prod_symm {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] (e : local_homeomorph α β) (e' : local_homeomorph γ δ) : local_homeomorph.symm (prod e e') = prod (local_homeomorph.symm e) (local_homeomorph.symm e') :=\n  rfl\n\n@[simp] theorem prod_trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] {η : Type u_5} {ε : Type u_6} [topological_space η] [topological_space ε] (e : local_homeomorph α β) (f : local_homeomorph β γ) (e' : local_homeomorph δ η) (f' : local_homeomorph η ε) : local_homeomorph.trans (prod e e') (prod f f') = prod (local_homeomorph.trans e f) (local_homeomorph.trans e' f') := sorry\n\n/-- Continuity within a set at a point can be read under right composition with a local\nhomeomorphism, if the point is in its target -/\ntheorem continuous_within_at_iff_continuous_within_at_comp_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) {f : β → γ} {s : set β} {x : β} (h : x ∈ local_equiv.target (to_local_equiv e)) : continuous_within_at f s x ↔ continuous_within_at (f ∘ ⇑e) (⇑e ⁻¹' s) (coe_fn (local_homeomorph.symm e) x) := sorry\n\n/-- Continuity at a point can be read under right composition with a local homeomorphism, if the\npoint is in its target -/\ntheorem continuous_at_iff_continuous_at_comp_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) {f : β → γ} {x : β} (h : x ∈ local_equiv.target (to_local_equiv e)) : continuous_at f x ↔ continuous_at (f ∘ ⇑e) (coe_fn (local_homeomorph.symm e) x) := sorry\n\n/-- A function is continuous on a set if and only if its composition with a local homeomorphism\non the right is continuous on the corresponding set. -/\ntheorem continuous_on_iff_continuous_on_comp_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) {f : β → γ} {s : set β} (h : s ⊆ local_equiv.target (to_local_equiv e)) : continuous_on f s ↔ continuous_on (f ∘ ⇑e) (local_equiv.source (to_local_equiv e) ∩ ⇑e ⁻¹' s) := sorry\n\n/-- Continuity within a set at a point can be read under left composition with a local\nhomeomorphism if a neighborhood of the initial point is sent to the source of the local\nhomeomorphism-/\ntheorem continuous_within_at_iff_continuous_within_at_comp_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) {f : γ → α} {s : set γ} {x : γ} (hx : f x ∈ local_equiv.source (to_local_equiv e)) (h : f ⁻¹' local_equiv.source (to_local_equiv e) ∈ nhds_within x s) : continuous_within_at f s x ↔ continuous_within_at (⇑e ∘ f) s x := sorry\n\n/-- Continuity at a point can be read under left composition with a local homeomorphism if a\nneighborhood of the initial point is sent to the source of the local homeomorphism-/\ntheorem continuous_at_iff_continuous_at_comp_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) {f : γ → α} {x : γ} (h : f ⁻¹' local_equiv.source (to_local_equiv e) ∈ nhds x) : continuous_at f x ↔ continuous_at (⇑e ∘ f) x := sorry\n\n/-- A function is continuous on a set if and only if its composition with a local homeomorphism\non the left is continuous on the corresponding set. -/\ntheorem continuous_on_iff_continuous_on_comp_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : local_homeomorph α β) {f : γ → α} {s : set γ} (h : s ⊆ f ⁻¹' local_equiv.source (to_local_equiv e)) : continuous_on f s ↔ continuous_on (⇑e ∘ f) s := sorry\n\n/-- If a local homeomorphism has source and target equal to univ, then it induces a homeomorphism\nbetween the whole spaces, expressed in this definition. -/\ndef to_homeomorph_of_source_eq_univ_target_eq_univ {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (h : local_equiv.source (to_local_equiv e) = set.univ) (h' : local_equiv.target (to_local_equiv e) = set.univ) : α ≃ₜ β :=\n  homeomorph.mk (equiv.mk ⇑e ⇑(local_homeomorph.symm e) sorry sorry)\n\n@[simp] theorem to_homeomorph_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (h : local_equiv.source (to_local_equiv e) = set.univ) (h' : local_equiv.target (to_local_equiv e) = set.univ) : ⇑(to_homeomorph_of_source_eq_univ_target_eq_univ e h h') = ⇑e :=\n  rfl\n\n@[simp] theorem to_homeomorph_symm_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (h : local_equiv.source (to_local_equiv e) = set.univ) (h' : local_equiv.target (to_local_equiv e) = set.univ) : ⇑(homeomorph.symm (to_homeomorph_of_source_eq_univ_target_eq_univ e h h')) = ⇑(local_homeomorph.symm e) :=\n  rfl\n\n/-- A local homeomorphism whose source is all of `α` defines an open embedding of `α` into `β`.  The\nconverse is also true; see `open_embedding.to_local_homeomorph`. -/\ntheorem to_open_embedding {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (h : local_equiv.source (to_local_equiv e) = set.univ) : open_embedding (local_equiv.to_fun (to_local_equiv e)) := sorry\n\nend local_homeomorph\n\n\nnamespace homeomorph\n\n\n/- Register as simp lemmas that the fields of a local homeomorphism built from a homeomorphism\ncorrespond to the fields of the original homeomorphism. -/\n\n@[simp] theorem to_local_homeomorph_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α ≃ₜ β) : local_equiv.source (local_homeomorph.to_local_equiv (to_local_homeomorph e)) = set.univ :=\n  rfl\n\n@[simp] theorem to_local_homeomorph_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α ≃ₜ β) : local_equiv.target (local_homeomorph.to_local_equiv (to_local_homeomorph e)) = set.univ :=\n  rfl\n\n@[simp] theorem to_local_homeomorph_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α ≃ₜ β) : ⇑(to_local_homeomorph e) = ⇑e :=\n  rfl\n\n@[simp] theorem to_local_homeomorph_coe_symm {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α ≃ₜ β) : ⇑(local_homeomorph.symm (to_local_homeomorph e)) = ⇑(homeomorph.symm e) :=\n  rfl\n\n@[simp] theorem refl_to_local_homeomorph {α : Type u_1} [topological_space α] : to_local_homeomorph (homeomorph.refl α) = local_homeomorph.refl α :=\n  rfl\n\n@[simp] theorem symm_to_local_homeomorph {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : α ≃ₜ β) : to_local_homeomorph (homeomorph.symm e) = local_homeomorph.symm (to_local_homeomorph e) :=\n  rfl\n\n@[simp] theorem trans_to_local_homeomorph {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] (e : α ≃ₜ β) (e' : β ≃ₜ γ) : to_local_homeomorph (homeomorph.trans e e') = local_homeomorph.trans (to_local_homeomorph e) (to_local_homeomorph e') :=\n  local_homeomorph.eq_of_local_equiv_eq (equiv.trans_to_local_equiv (to_equiv e) (to_equiv e'))\n\nend homeomorph\n\n\nnamespace open_embedding\n\n\n/-- An open embedding of `α` into `β`, with `α` nonempty, defines a local equivalence whose source\nis all of `α`.  This is mainly an auxiliary lemma for the stronger result `to_local_homeomorph`. -/\ndef to_local_equiv {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : local_equiv α β :=\n  set.inj_on.to_local_equiv f set.univ sorry\n\n@[simp] theorem to_local_equiv_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : ⇑(to_local_equiv h) = f :=\n  rfl\n\n@[simp] theorem to_local_equiv_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : local_equiv.source (to_local_equiv h) = set.univ :=\n  rfl\n\n@[simp] theorem to_local_equiv_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : local_equiv.target (to_local_equiv h) = set.range f := sorry\n\ntheorem open_target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : is_open (local_equiv.target (to_local_equiv h)) := sorry\n\ntheorem continuous_inv_fun {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : continuous_on (local_equiv.inv_fun (to_local_equiv h)) (local_equiv.target (to_local_equiv h)) := sorry\n\n/-- An open embedding of `α` into `β`, with `α` nonempty, defines a local homeomorphism whose source\nis all of `α`.  The converse is also true; see `local_homeomorph.to_open_embedding`. -/\ndef to_local_homeomorph {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : local_homeomorph α β :=\n  local_homeomorph.mk (to_local_equiv h) is_open_univ (open_target h) sorry (continuous_inv_fun h)\n\n@[simp] theorem to_local_homeomorph_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : ⇑(to_local_homeomorph h) = f :=\n  rfl\n\n@[simp] theorem source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : local_equiv.source (local_homeomorph.to_local_equiv (to_local_homeomorph h)) = set.univ :=\n  rfl\n\n@[simp] theorem target {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [Nonempty α] {f : α → β} (h : open_embedding f) : local_equiv.target (local_homeomorph.to_local_equiv (to_local_homeomorph h)) = set.range f :=\n  to_local_equiv_target h\n\nend open_embedding\n\n\n-- We close and reopen the namespace to avoid\n\n-- picking up the unnecessary `[nonempty α]` typeclass argument\n\nnamespace open_embedding\n\n\ntheorem continuous_at_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {f : α → β} {g : β → γ} (hf : open_embedding f) {x : α} : continuous_at (g ∘ f) x ↔ continuous_at g (f x) := sorry\n\nend open_embedding\n\n\nnamespace topological_space.opens\n\n\n/-- The inclusion of an open subset `s` of a space `α` into `α` is a local homeomorphism from the\nsubtype `s` to `α`. -/\ndef local_homeomorph_subtype_coe {α : Type u_1} [topological_space α] (s : opens α) [Nonempty ↥s] : local_homeomorph (↥s) α :=\n  open_embedding.to_local_homeomorph sorry\n\n@[simp] theorem local_homeomorph_subtype_coe_coe {α : Type u_1} [topological_space α] (s : opens α) [Nonempty ↥s] : ⇑(local_homeomorph_subtype_coe s) = coe :=\n  rfl\n\n@[simp] theorem local_homeomorph_subtype_coe_source {α : Type u_1} [topological_space α] (s : opens α) [Nonempty ↥s] : local_equiv.source (local_homeomorph.to_local_equiv (local_homeomorph_subtype_coe s)) = set.univ :=\n  rfl\n\n@[simp] theorem local_homeomorph_subtype_coe_target {α : Type u_1} [topological_space α] (s : opens α) [Nonempty ↥s] : local_equiv.target (local_homeomorph.to_local_equiv (local_homeomorph_subtype_coe s)) = ↑s := sorry\n\nend topological_space.opens\n\n\nnamespace local_homeomorph\n\n\n/-- The restriction of a local homeomorphism `e` to an open subset `s` of the domain type produces a\nlocal homeomorphism whose domain is the subtype `s`.-/\ndef subtype_restr {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : topological_space.opens α) [Nonempty ↥s] : local_homeomorph (↥s) β :=\n  local_homeomorph.trans (topological_space.opens.local_homeomorph_subtype_coe s) e\n\ntheorem subtype_restr_def {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : topological_space.opens α) [Nonempty ↥s] : subtype_restr e s = local_homeomorph.trans (topological_space.opens.local_homeomorph_subtype_coe s) e :=\n  rfl\n\n@[simp] theorem subtype_restr_coe {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : topological_space.opens α) [Nonempty ↥s] : ⇑(subtype_restr e s) = set.restrict ⇑e ↑s :=\n  rfl\n\n@[simp] theorem subtype_restr_source {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (e : local_homeomorph α β) (s : topological_space.opens α) [Nonempty ↥s] : local_equiv.source (to_local_equiv (subtype_restr e s)) = coe ⁻¹' local_equiv.source (to_local_equiv e) := sorry\n\n/- This lemma characterizes the transition functions of an open subset in terms of the transition\nfunctions of the original space. -/\n\ntheorem subtype_restr_symm_trans_subtype_restr {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (s : topological_space.opens α) [Nonempty ↥s] (f : local_homeomorph α β) (f' : local_homeomorph α β) : local_homeomorph.trans (local_homeomorph.symm (subtype_restr f s)) (subtype_restr f' s) ≈\n  local_homeomorph.restr (local_homeomorph.trans (local_homeomorph.symm f) f')\n    (local_equiv.target (to_local_equiv f) ∩ ⇑(local_homeomorph.symm f) ⁻¹' ↑s) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/local_homeomorph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355188, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.48608744243964647}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.data.nat.lemmas\nimport Mathlib.Lean3Lib.init.meta.well_founded_tactics\n \n\nuniverses u \n\nnamespace Mathlib\n\nnamespace nat\n\n\ndef bodd_div2 : ℕ → Bool × ℕ :=\n  sorry\n\ndef div2 (n : ℕ) : ℕ :=\n  prod.snd (bodd_div2 n)\n\ndef bodd (n : ℕ) : Bool :=\n  prod.fst (bodd_div2 n)\n\n@[simp] theorem bodd_zero : bodd 0 = false :=\n  rfl\n\n@[simp] theorem bodd_one : bodd 1 = tt :=\n  rfl\n\n@[simp] theorem bodd_two : bodd (bit0 1) = false :=\n  rfl\n\n@[simp] theorem bodd_succ (n : ℕ) : bodd (Nat.succ n) = bnot (bodd n) := sorry\n\n@[simp] theorem bodd_add (m : ℕ) (n : ℕ) : bodd (m + n) = bxor (bodd m) (bodd n) := sorry\n\n@[simp] theorem bodd_mul (m : ℕ) (n : ℕ) : bodd (m * n) = bodd m && bodd n := sorry\n\ntheorem mod_two_of_bodd (n : ℕ) : n % bit0 1 = cond (bodd n) 1 0 := sorry\n\n@[simp] theorem div2_zero : div2 0 = 0 :=\n  rfl\n\n@[simp] theorem div2_one : div2 1 = 0 :=\n  rfl\n\n@[simp] theorem div2_two : div2 (bit0 1) = 1 :=\n  rfl\n\n@[simp] theorem div2_succ (n : ℕ) : div2 (Nat.succ n) = cond (bodd n) (Nat.succ (div2 n)) (div2 n) := sorry\n\ntheorem bodd_add_div2 (n : ℕ) : cond (bodd n) 1 0 + bit0 1 * div2 n = n := sorry\n\ntheorem div2_val (n : ℕ) : div2 n = n / bit0 1 := sorry\n\ndef bit (b : Bool) : ℕ → ℕ :=\n  cond b bit1 bit0\n\ntheorem bit0_val (n : ℕ) : bit0 n = bit0 1 * n :=\n  Eq.trans (Eq.trans (eq.mpr (id (Eq._oldrec (Eq.refl (n + n = 0 + n + n)) (nat.zero_add n))) (Eq.refl (n + n))) rfl)\n    (nat.mul_comm n (bit0 1))\n\ntheorem bit1_val (n : ℕ) : bit1 n = bit0 1 * n + 1 :=\n  congr_arg Nat.succ (bit0_val n)\n\ntheorem bit_val (b : Bool) (n : ℕ) : bit b n = bit0 1 * n + cond b 1 0 :=\n  bool.cases_on b (bit0_val n) (bit1_val n)\n\ntheorem bit_decomp (n : ℕ) : bit (bodd n) (div2 n) = n :=\n  Eq.trans (bit_val (bodd n) (div2 n)) (Eq.trans (nat.add_comm (bit0 1 * div2 n) (cond (bodd n) 1 0)) (bodd_add_div2 n))\n\ndef bit_cases_on {C : ℕ → Sort u} (n : ℕ) (h : (b : Bool) → (n : ℕ) → C (bit b n)) : C n :=\n  eq.mpr sorry (h (bodd n) (div2 n))\n\n@[simp] theorem bit_zero : bit false 0 = 0 :=\n  rfl\n\ndef shiftl' (b : Bool) (m : ℕ) : ℕ → ℕ :=\n  sorry\n\ndef shiftl : ℕ → ℕ → ℕ :=\n  shiftl' false\n\n@[simp] theorem shiftl_zero (m : ℕ) : shiftl m 0 = m :=\n  rfl\n\n@[simp] theorem shiftl_succ (m : ℕ) (n : ℕ) : shiftl m (n + 1) = bit0 (shiftl m n) :=\n  rfl\n\ndef shiftr : ℕ → ℕ → ℕ :=\n  sorry\n\ndef test_bit (m : ℕ) (n : ℕ) : Bool :=\n  bodd (shiftr m n)\n\ndef binary_rec {C : ℕ → Sort u} (z : C 0) (f : (b : Bool) → (n : ℕ) → C n → C (bit b n)) (n : ℕ) : C n :=\n  sorry\n\ndef size : ℕ → ℕ :=\n  binary_rec 0 fun (_x : Bool) (_x : ℕ) => Nat.succ\n\ndef bits : ℕ → List Bool :=\n  binary_rec [] fun (b : Bool) (_x : ℕ) (IH : List Bool) => b :: IH\n\ndef bitwise (f : Bool → Bool → Bool) : ℕ → ℕ → ℕ :=\n  binary_rec (fun (n : ℕ) => cond (f false tt) n 0)\n    fun (a : Bool) (m : ℕ) (Ia : ℕ → ℕ) =>\n      binary_rec (cond (f tt false) (bit a m) 0) fun (b : Bool) (n _x : ℕ) => bit (f a b) (Ia n)\n\ndef lor : ℕ → ℕ → ℕ :=\n  bitwise bor\n\ndef land : ℕ → ℕ → ℕ :=\n  bitwise band\n\ndef ldiff : ℕ → ℕ → ℕ :=\n  bitwise fun (a b : Bool) => a && bnot b\n\ndef lxor : ℕ → ℕ → ℕ :=\n  bitwise bxor\n\n@[simp] theorem binary_rec_zero {C : ℕ → Sort u} (z : C 0) (f : (b : Bool) → (n : ℕ) → C n → C (bit b n)) : binary_rec z f 0 = z := sorry\n\n/- bitwise ops -/\n\ntheorem bodd_bit (b : Bool) (n : ℕ) : bodd (bit b n) = b := sorry\n\ntheorem div2_bit (b : Bool) (n : ℕ) : div2 (bit b n) = n := sorry\n\ntheorem shiftl'_add (b : Bool) (m : ℕ) (n : ℕ) (k : ℕ) : shiftl' b m (n + k) = shiftl' b (shiftl' b m n) k := sorry\n\ntheorem shiftl_add (m : ℕ) (n : ℕ) (k : ℕ) : shiftl m (n + k) = shiftl (shiftl m n) k :=\n  shiftl'_add false\n\ntheorem shiftr_add (m : ℕ) (n : ℕ) (k : ℕ) : shiftr m (n + k) = shiftr (shiftr m n) k := sorry\n\ntheorem shiftl'_sub (b : Bool) (m : ℕ) {n : ℕ} {k : ℕ} : k ≤ n → shiftl' b m (n - k) = shiftr (shiftl' b m n) k := sorry\n\ntheorem shiftl_sub (m : ℕ) {n : ℕ} {k : ℕ} : k ≤ n → shiftl m (n - k) = shiftr (shiftl m n) k :=\n  shiftl'_sub false\n\n@[simp] theorem test_bit_zero (b : Bool) (n : ℕ) : test_bit (bit b n) 0 = b :=\n  bodd_bit b n\n\ntheorem test_bit_succ (m : ℕ) (b : Bool) (n : ℕ) : test_bit (bit b n) (Nat.succ m) = test_bit n m := sorry\n\ntheorem binary_rec_eq {C : ℕ → Sort u} {z : C 0} {f : (b : Bool) → (n : ℕ) → C n → C (bit b n)} (h : f false 0 z = z) (b : Bool) (n : ℕ) : binary_rec z f (bit b n) = f b n (binary_rec z f n) := sorry\n\ntheorem bitwise_bit_aux {f : Bool → Bool → Bool} (h : f false false = false) : (binary_rec (cond (f tt false) (bit false 0) 0) fun (b : Bool) (n _x : ℕ) => bit (f false b) (cond (f false tt) n 0)) =\n  fun (n : ℕ) => cond (f false tt) n 0 := sorry\n\n@[simp] theorem bitwise_zero_left (f : Bool → Bool → Bool) (n : ℕ) : bitwise f 0 n = cond (f false tt) n 0 := sorry\n\n@[simp] theorem bitwise_zero_right (f : Bool → Bool → Bool) (h : f false false = false) (m : ℕ) : bitwise f m 0 = cond (f tt false) m 0 := sorry\n\n@[simp] theorem bitwise_zero (f : Bool → Bool → Bool) : bitwise f 0 0 = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (bitwise f 0 0 = 0)) (bitwise_zero_left f 0)))\n    (bool.cases_on (f false tt) (Eq.refl (cond false 0 0)) (Eq.refl (cond tt 0 0)))\n\n@[simp] theorem bitwise_bit {f : Bool → Bool → Bool} (h : f false false = false) (a : Bool) (m : ℕ) (b : Bool) (n : ℕ) : bitwise f (bit a m) (bit b n) = bit (f a b) (bitwise f m n) := sorry\n\ntheorem bitwise_swap {f : Bool → Bool → Bool} (h : f false false = false) : bitwise (function.swap f) = function.swap (bitwise f) := sorry\n\n@[simp] theorem lor_bit (a : Bool) (m : ℕ) (b : Bool) (n : ℕ) : lor (bit a m) (bit b n) = bit (a || b) (lor m n) :=\n  bitwise_bit rfl\n\n@[simp] theorem land_bit (a : Bool) (m : ℕ) (b : Bool) (n : ℕ) : land (bit a m) (bit b n) = bit (a && b) (land m n) :=\n  bitwise_bit rfl\n\n@[simp] theorem ldiff_bit (a : Bool) (m : ℕ) (b : Bool) (n : ℕ) : ldiff (bit a m) (bit b n) = bit (a && bnot b) (ldiff m n) :=\n  bitwise_bit rfl\n\n@[simp] theorem lxor_bit (a : Bool) (m : ℕ) (b : Bool) (n : ℕ) : lxor (bit a m) (bit b n) = bit (bxor a b) (lxor m n) :=\n  bitwise_bit rfl\n\n@[simp] theorem test_bit_bitwise {f : Bool → Bool → Bool} (h : f false false = false) (m : ℕ) (n : ℕ) (k : ℕ) : test_bit (bitwise f m n) k = f (test_bit m k) (test_bit n k) := sorry\n\n@[simp] theorem test_bit_lor (m : ℕ) (n : ℕ) (k : ℕ) : test_bit (lor m n) k = test_bit m k || test_bit n k :=\n  test_bit_bitwise rfl\n\n@[simp] theorem test_bit_land (m : ℕ) (n : ℕ) (k : ℕ) : test_bit (land m n) k = test_bit m k && test_bit n k :=\n  test_bit_bitwise rfl\n\n@[simp] theorem test_bit_ldiff (m : ℕ) (n : ℕ) (k : ℕ) : test_bit (ldiff m n) k = test_bit m k && bnot (test_bit n k) :=\n  test_bit_bitwise rfl\n\n@[simp] theorem test_bit_lxor (m : ℕ) (n : ℕ) (k : ℕ) : test_bit (lxor m n) k = bxor (test_bit m k) (test_bit n k) :=\n  test_bit_bitwise rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/data/nat/bitwise.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.48608743582925246}}
{"text": "import algebra.homology.homological_complex\nimport category_theory.abelian.exact\nimport algebra.category.Module.abelian\n\nimport tactic.interval_cases\n\nimport .test\n\nnoncomputable theory\n\nuniverses v u\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {α β : Type*}\nvariables (V : Type u) [category.{v} V] [has_zero_morphisms V]\n\nsection\n\ndef complex_shape.not_rfl (a : complex_shape α) : Prop :=\n∀ (i : α), ¬ a.rel i i\n\ndef complex_shape.not_rfl.ne {a : complex_shape α} (ha : a.not_rfl) {i i' : α} :\n  a.rel i i' → i ≠ i' :=\nbegin \n  contrapose!,\n  rintro rfl,\n  exact ha _,\nend\n\nstructure homological_bicomplex (a : complex_shape α) (b : complex_shape β) :=\n(X : α → β → V)\n(d_h : Π (i : α) (j j' : β), X i j ⟶ X i j')\n(shape_h' : ∀ (i : α) (j j' : β), ¬ b.rel j j' → d_h i j j' = 0)\n(d_v : Π (j : β) (i i' : α), X i j ⟶ X i' j)\n(shape_v' : ∀ (j : β) (i i' : α), ¬ a.rel i i' → d_v j i i' = 0)\n(d_comp_d_v' : ∀ (j : β) (i₁ i₂ i₃ : α), a.rel i₁ i₂ → a.rel i₂ i₃ → \n  d_v j i₁ i₂ ≫ d_v j i₂ i₃ = 0)\n(d_comp_d_h' : ∀ (i : α) (j₁ j₂ j₃ : β), b.rel j₁ j₂ → b.rel j₂ j₃ → \n  d_h i j₁ j₂ ≫ d_h i j₂ j₃ = 0)\n(comm' : ∀ (i₁ i₂ : α) (j₁ j₂ : β), a.rel i₁ i₂ → b.rel j₁ j₂ → \n  d_v j₁ i₁ i₂ ≫ d_h i₂ j₁ j₂ = d_h i₁ j₁ j₂ ≫ d_v j₂ i₁ i₂)\n\nend\n\nnamespace homological_bicomplex\n\nrestate_axiom shape_h'\nrestate_axiom shape_v'\nattribute [simp] shape_h shape_v\n\nvariables {V}  {γ : Type*} (a : complex_shape α) (b : complex_shape β) (c : complex_shape γ)\n\nclass has_sign :=\n(sign : α → zmod 2)\n(rel : ∀ (i i' : α), a.rel i i' → sign i ≠ sign i')\n\ninstance has_sign1 : has_sign (complex_shape.up ℤ) :=\n{ sign := λ i, i,\n  rel := λ i j,\n  begin \n    dsimp,\n    rintro rfl h,\n    norm_num at h,\n  end }\n\ninstance has_sign2 : has_sign (complex_shape.up ℕ) :=\n{ sign := λ i, i,\n  rel := λ i j,\n  begin \n    dsimp,\n    rintro rfl h,\n    norm_num at h,\n  end }\n\nsection\n\ninstance [has_sign a] (T : Type*) [has_neg T] : has_smul α T :=\n{ smul := λ x f, if has_sign.sign a x = 0 then f else - f }\n\nlemma has_sign.smul_zero [has_sign a] (T : Type*) [add_comm_group T]\n  (x : α) : x • (0 : T) = 0 :=\nbegin \n  dunfold has_smul.smul,\n  dsimp,\n  split_ifs;\n  abel,\nend\n\nlemma has_sign.smul_eq_zero [has_sign a] (T : Type*) [add_comm_group T] (x : α) (t : T) : \n  x • t = 0 ↔ t = 0 :=\nbegin\n  split,\n  { intros h,\n    dunfold has_smul.smul at h,\n    dsimp at h,\n    split_ifs at h,\n    { exact h },\n    { rwa neg_eq_zero at h, }, },\n  { rintro rfl, rw has_sign.smul_zero }\nend\n\nlemma has_sign.smul_comp [has_sign a] [preadditive V] (i : α) \n  {v₁ v₂ v₃ : V} (f : v₁ ⟶ v₂) (g : v₂ ⟶ v₃) :\n  (i • f) ≫ g = i • (f ≫ g) :=\nbegin \n  dunfold has_smul.smul,\n  dsimp,\n  split_ifs,\n  { refl },\n  { rw preadditive.neg_comp },\nend\n\n\nlocal attribute [instance] concrete_category.has_coe_to_fun\nlocal attribute [instance] concrete_category.has_coe_to_sort\n\n\nclass has_hadd :=\n(add' {} : α → β → γ)\n(rel_h' {} : ∀ (i₁ i₂ : α) (j : β), a.rel i₁ i₂ ↔ c.rel (add' i₁ j) (add' i₂ j))\n(rel_v' {} : ∀ (i : α) (j₁ j₂ : β), b.rel j₁ j₂ ↔ c.rel (add' i j₁) (add' i j₂))\n(add_cancel_h' : ∀ (i₁ i₂ : α) (j : β), add' i₁ j = add' i₂ j ↔ i₁ = i₂)\n(add_cancel_v' : ∀ (i : α) (j₁ j₂ : β), add' i j₁ = add' i j₂ ↔ j₁ = j₂)\n(balanced' : ∀ (i : α) (j : β) (k' : γ), c.rel (add' i j) k' → \n  ((∃ i', k' = add' i' j) ∧ (∃ j', k' = add' i j')))\n/--\nThis is wrong for example:\nin down ℕ\ni + 0 -> k' = i - 1\nthen k' = (i - 1) + 0 is fine but k' = i + j' is bad\n\nI want i + 0 -> k' = i - 1\n1 + 0 -> 0\n-/\n\ninstance test1 : has_hadd (complex_shape.up ℤ) (complex_shape.up ℤ) (complex_shape.up ℤ) :=\n{ add' := (+),\n  rel_h' := λ _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  rel_v' := λ _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  add_cancel_h' := λ _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  add_cancel_v' := λ _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  balanced' := λ i j k' (h : _ = _), \n  begin \n    refine ⟨⟨i + 1, by linarith⟩, ⟨j + 1, by linarith⟩⟩,\n  end }\n\ninstance test2 : has_hadd (complex_shape.up ℕ) (complex_shape.up ℕ) (complex_shape.up ℕ) :=\n{ add' := (+),\n  rel_h' := λ _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  rel_v' := λ _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  add_cancel_h' := λ _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  add_cancel_v' := λ _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  balanced' := λ i j k' (h : _ = _), \n  begin \n    refine ⟨⟨i + 1, by linarith⟩, ⟨j + 1, by linarith⟩⟩,\n  end }\n\ninstance test3 : has_hadd (complex_shape.up ℕ) (complex_shape.up ℤ) (complex_shape.up ℤ) :=\n{ add' := λ n z, (n : ℤ) + z,\n  rel_h' := λ _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, norm_num, ring, },\n    { intros h, linarith, },\n  end,\n  rel_v' := λ _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  add_cancel_h' := λ _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  add_cancel_v' := λ _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  balanced' := λ i j k' (h : _ = _), \n  begin \n    refine ⟨⟨i + 1, by norm_num; linarith⟩, ⟨j + 1, by linarith⟩⟩,\n  end }\n\nnotation (name := hadd.add) i `+[` a, b, c`]` j := (has_hadd.add' a b c i j)\nvariables [has_hadd a b c]\n\nvariables {a b c} [decidable_eq α] [decidable_eq β] [decidable_eq γ]\n\n@[simp] lemma d_comp_d_v (C : homological_bicomplex V a b) (j : β) (i₁ i₂ i₃ : α) :\n  C.d_v j i₁ i₂ ≫ C.d_v j i₂ i₃ = 0 := \nbegin \n  by_cases h₁₂ : a.rel i₁ i₂,\n  { refine (em (a.rel i₂ i₃)).elim (λ h₂₃, C.d_comp_d_v' j i₁ i₂ i₃ h₁₂ h₂₃) (λ h₂₃, _),\n    rw [C.shape_v j _ _ h₂₃, comp_zero], },\n  rw [C.shape_v _ _ _ h₁₂, zero_comp],\nend\n\n@[simp] lemma comm (C : homological_bicomplex V a b) (j₁ j₂ : β) (i₁ i₂ : α) :\n  C.d_h i₁ j₁ j₂ ≫ C.d_v j₂ i₁ i₂ = \n  C.d_v j₁ i₁ i₂ ≫ C.d_h i₂ j₁ j₂ := \nbegin \n  by_cases ha : a.rel i₁ i₂;\n  by_cases hb : b.rel j₁ j₂,\n  { rw C.comm'; assumption },\n  { rw [C.shape_h, C.shape_h, comp_zero, zero_comp]; assumption },\n  { rw [C.shape_v, C.shape_v, comp_zero, zero_comp]; assumption },\n  { rw [C.shape_v, C.shape_v, comp_zero, zero_comp]; assumption },\nend\n\n@[simp] lemma d_comp_d_h (C : homological_bicomplex V a b) (i : α) (j₁ j₂ j₃ : β) :\n  C.d_h i j₁ j₂ ≫ C.d_h i j₂ j₃ = 0 := \nbegin \n  by_cases h₁₂ : b.rel j₁ j₂,\n  { refine (em (b.rel j₂ j₃)).elim (λ h₂₃, C.d_comp_d_h' i j₁ j₂ j₃ h₁₂ h₂₃) (λ h₂₃, _),\n    rw [C.shape_h i _ _ h₂₃, comp_zero], },\n  rw [C.shape_h _ _ _ h₁₂, zero_comp],\nend\n\n@[simps]\ndef vertical_component (C : homological_bicomplex V a b) (j : β) : homological_complex V a :=\n{ X := λ i, C.X i j,\n  d := C.d_v j,\n  shape' := λ _ _ h, C.shape_v _ _ _ h,\n  d_comp_d' := λ _ _ _ _ _, C.d_comp_d_v _ _ _ _ }\n\n@[simps]\ndef vertical_component_map (C : homological_bicomplex V a b) (j₁ j₂ : β) :\n  C.vertical_component j₁ ⟶ C.vertical_component j₂ :=\n{ f := λ i, C.d_h i j₁ j₂,\n  comm' := \n  begin \n    intros i₁ i₂ h₁₂,\n    dsimp,\n    by_cases H : b.rel j₁ j₂,\n    { rw C.comm, },\n    { rw [C.shape_h _ _ _ H, C.shape_h _ _ _ H, zero_comp, comp_zero], },\n  end }\n\n@[simps]\ndef as_vertical_complex (C : homological_bicomplex V a b) : \n  homological_complex (homological_complex V a) b :=\n{ X := C.vertical_component,\n  d := C.vertical_component_map,\n  shape' := λ j₁ j₂ h₁₂, \n  begin \n    ext i,\n    simpa only [vertical_component_map_f, homological_complex.zero_apply] using C.shape_h _ _ _ h₁₂,\n  end,\n  d_comp_d' := by { intros, ext, simp } }\n\n@[simps]\ndef horizontal_component (C : homological_bicomplex V a b) (i : α) : homological_complex V b :=\n{ X := C.X i,\n  d := C.d_h i,\n  shape' := λ _ _ h, C.shape_h _ _ _ h,\n  d_comp_d' := λ _ _ _ _ _, C.d_comp_d_h _ _ _ _ }\n\n@[simps]\ndef horizontal_component_map (C : homological_bicomplex V a b) (i₁ i₂ : α) :\n  C.horizontal_component i₁ ⟶ C.horizontal_component i₂ :=\n{ f := λ j, C.d_v j i₁ i₂,\n  comm' := \n  begin \n    intros j₁ j₂ h₁₂,\n    dsimp,\n    by_cases H : a.rel i₁ i₂,\n    { rw C.comm, },\n    { rw [C.shape_v _ _ _ H, C.shape_v _ _ _ H, zero_comp, comp_zero], },\n  end }\n\n@[simps]\ndef as_horizontal_complex (C : homological_bicomplex V a b) :\n  homological_complex (homological_complex V b) a :=\n{ X := C.horizontal_component,\n  d := C.horizontal_component_map,\n  shape' := λ i₁ i₂ h₁₂, \n  begin \n    ext j,\n    simpa only [horizontal_component_map_f, homological_complex.zero_apply] using \n      C.shape_v _ _ _ h₁₂,\n  end,\n  d_comp_d' := by { intros, ext, simp } }\n\nsection defs_in_mod\n\nvariables {R : Type*} [comm_ring R] (C : homological_bicomplex (Module R) a b)\nvariables (a b c)\n\n@[ext]\nstructure diagonal (k : γ) :=\n(fst : α) (snd : β) (add_eq : (fst +[a, b, c] snd) = k)\n\n\nopen_locale direct_sum big_operators\n\nvariables {a b} [∀ k, decidable_eq $ diagonal a b c k]\ndef total_at (j : γ) : Module R :=\nModule.of R $ ⨁ (p : diagonal a b c j), C.X p.fst p.snd\n\n@[simps]\ndef diagonal.from_balancing1\n  {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k') :\n  diagonal a b c k' :=\n{ fst := (has_hadd.balanced' p.1 p.2 k' (by rwa p.add_eq : c.rel (p.1+[a,b,c]p.2) k')).1.some,\n  snd := p.2,\n  add_eq := begin \n    generalize_proofs h,\n    exact h.some_spec.symm,\n  end }\n\n@[simps]\ndef diagonal.from_balancing1'\n  {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k') :\n  diagonal a b c k' :=\n{ fst := a.next p.1,\n  snd := p.2,\n  add_eq := begin \n    suffices : \n      (has_hadd.balanced' p.1 p.2 k' (by rwa p.add_eq : c.rel (p.1+[a,b,c]p.2) k')).1.some = \n      a.next p.1,\n    { rw ← this, \n      generalize_proofs h,\n      exact h.some_spec.symm },\n    generalize_proofs h,\n    have : c.rel (p.1 +[a,b,c] p.2) (h.some +[a,b,c] p.snd),\n    { rw p.add_eq,\n      convert hc,\n      exact h.some_spec.symm },\n    rw ← has_hadd.rel_h' at this,\n    rwa a.next_eq',\n  end }\n\nlemma diagonal.from_balancing1'_rel\n  {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k') :\n  a.rel p.1 (a.next p.1) :=\nbegin \n  have EQ1 := (p.from_balancing1' c hc).add_eq,\n  simp_rw [← EQ1, ← p.add_eq] at hc,\n  erw ← has_hadd.rel_h' at hc,\n  exact hc,\nend\n\nlemma diagonal.from_balancing1_uniq\n  {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k')\n  (q' : diagonal a b c k') \n  (hq' : q'.2 = p.2) :\n  p.from_balancing1 c hc = q' :=\nbegin\n  ext,\n  { dsimp,\n    generalize_proofs h,\n    have := h.some_spec,\n    simp_rw ←q'.add_eq at this, \n    simp_rw hq' at this,\n    rw has_hadd.add_cancel_h' at this,\n    convert this.symm,\n    ext,\n    rw [← hq', q'.add_eq], },\n  { dsimp, rw [←hq'], }\nend\n\nlemma diagonal.from_balancing1_fst_eq {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k') :\n  (p.from_balancing1 c hc).fst = a.next p.1 :=\nbegin \n  rw p.from_balancing1_uniq c hc(p.from_balancing1' c hc) rfl,\n  refl,\nend\n\n@[simps]\ndef diagonal.from_balancing2\n  {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k') :\n  diagonal a b c k' :=\n{ fst := p.1,\n  snd := (has_hadd.balanced' p.1 p.2 k' (by rwa p.add_eq : c.rel (p.1+[a,b,c]p.2) k')).2.some,\n  add_eq := begin \n    generalize_proofs h,\n    exact h.some_spec.symm,\n  end }\n\n\nlemma diagonal.from_balancing2_uniq\n  {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k') (q' : diagonal a b c k') \n  (hq' : q'.1 = p.1) :\n  p.from_balancing2 c hc = q' :=\nbegin\n  ext,\n  { dsimp, rw [←hq'], },\n  { dsimp,\n    generalize_proofs h,\n    have := h.some_spec,\n    simp_rw ←q'.add_eq at this, \n    simp_rw hq' at this,\n    rw has_hadd.add_cancel_v' at this,\n    convert this.symm,\n    ext,\n    rw [← hq', q'.add_eq], },\nend\n\n@[simps]\ndef diagonal.from_balancing2'\n  {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k') :\n  diagonal a b c k' :=\n{ fst := p.1,\n  snd := b.next p.2,\n  add_eq := begin \n    suffices : \n      (has_hadd.balanced' p.1 p.2 k' (by rwa p.add_eq : c.rel (p.1+[a,b,c]p.2) k')).2.some = \n      b.next p.2,\n    { rw ← this, \n      generalize_proofs h,\n      exact h.some_spec.symm },\n    generalize_proofs h,\n    have : c.rel (p.1 +[a,b,c] p.2) (p.1 +[a,b,c] h.some),\n    { rw p.add_eq,\n      convert hc,\n      exact h.some_spec.symm },\n    rw ← has_hadd.rel_v' at this,\n    rwa b.next_eq',\n  end }\n\nlemma diagonal.from_balancing2_snd_eq {k k' : γ} (p : diagonal a b c k) (hc : c.rel k k')\n  (q : diagonal a b c k') (hq : q.2 = p.2) :\n  (p.from_balancing2 c hc).snd = b.next p.2 :=\nbegin \n  rw p.from_balancing2_uniq c hc (p.from_balancing2' c hc) rfl,\n  refl,\nend\n\nlemma has_sign.smul_sub [has_sign a] (i : α) \n  {T : Type*} [add_comm_group T] (t t' : T) :\n  i • (t - t') = i • t - i • t' :=\nbegin \n  dunfold has_smul.smul,\n  dsimp,\n  split_ifs,\n  { refl },\n  abel,\nend  \n\nlemma has_sign.next_smul [has_sign a] (i : α) (ha : a.rel i (a.next i))\n  {T : Type*} [add_comm_group T] (t : T) :\n  a.next i • t = - (i • t) :=\nbegin \n  dunfold has_smul.smul,\n  dsimp,\n  have := has_sign.rel _ _ ha,\n  split_ifs with h1 h2,\n  { exfalso,\n    rw [h1, h2] at this,\n    exact this rfl, },\n  { rw neg_neg },\n  { refl, },\n  { have h2' : has_sign.sign a i = 0 ∨ has_sign.sign a i = 1,\n    { obtain hmm1 := (has_sign.sign a i).2,\n      have hmm2 : 0 ≤ (has_sign.sign a i).1 := by linarith,\n      interval_cases using hmm2 hmm1,\n      left, ext, assumption,\n      right, ext, assumption, },\n    have h1' : has_sign.sign a (a.next i) = 0 ∨ has_sign.sign a (a.next i) = 1,\n    { obtain hmm1 := (has_sign.sign a (a.next i)).2,\n      have hmm2 : 0 ≤ (has_sign.sign a (a.next i)).1 := by linarith,\n      interval_cases using hmm2 hmm1,\n      left, ext, assumption,\n      right, ext, assumption, },\n    rw [h2'.resolve_left h, h1'.resolve_left h1] at this,\n    exfalso,\n    exact this rfl, }\nend \n\nsection\nvariables (a) (R)\nlemma has_sign.smul_apply [has_sign a] (i : α) \n  {v₁ v₂ : Type*} [add_comm_group v₁] [add_comm_group v₂] [module R v₁] [module R v₂] \n  (f : v₁ →ₗ[R] v₂) (x)  :\n  (i • f) x = i • (f x) :=\nbegin \n  dunfold has_smul.smul,\n  dsimp,\n  split_ifs,\n  { refl },\n  { rw linear_map.neg_apply, },\nend\nend\n\nlemma has_sign.map_smul [has_sign a] (i : α) \n  {v₁ v₂ : Module R} (f : v₁ ⟶ v₂) (x)  :\n  f (i • x) = i • (f x) :=\nbegin \n  dunfold has_smul.smul,\n  dsimp,\n  split_ifs,\n  { refl },\n  { rw map_neg, },\nend\n\nvariable [∀ (k k' : γ), decidable $ c.rel k k']\n\n@[reducible]\ndef total_d [has_sign a] (k k' : γ) :\n  C.total_at c k ⟶ C.total_at c k' :=\nif hc : c.rel k k' \nthen direct_sum.to_module _ _ _ $ λ p, \n  (direct_sum.lof R _ _ (p.from_balancing1' c hc)).comp\n    (C.d_v p.2 p.1 (a.next p.1)) +\n  p.fst • (direct_sum.lof R _ _ (p.from_balancing2' c hc)).comp\n    (C.d_h p.1 p.2 (b.next p.2))\nelse 0\n\nlemma total_d_of_rel [has_sign a] (k k' : γ) (hc : c.rel k k') :\nC.total_d c k k' = \ndirect_sum.to_module _ _ _ (λ p, \n  (direct_sum.lof R _ _ (p.from_balancing1' c hc)).comp\n    (C.d_v p.2 p.1 (a.next p.1)) +\n  p.fst • (direct_sum.lof R _ _ (p.from_balancing2' c hc)).comp\n    (C.d_h p.1 p.2 (b.next p.2))) :=\nbegin \n  dunfold total_d,\n  apply direct_sum.linear_map_ext,\n  intros p,\n  ext1 x,\n  rw dif_pos hc,\nend\n\nlemma total_d_comp_d_of_rel [has_sign a] (k₁ k₂ k₃ : γ) (hc12 : c.rel k₁ k₂) (hc23 : c.rel k₂ k₃) :\n  C.total_d c k₁ k₂ ≫ C.total_d c k₂ k₃ = 0 :=\nbegin \n  apply direct_sum.linear_map_ext,\n  intros p,\n  ext1 x,\n  simp only [linear_map.comp_apply, comp_apply, linear_map.zero_apply],\n  rw [total_d_of_rel, total_d_of_rel];\n  try { assumption },\n  simp only [direct_sum.to_module_lof, linear_map.add_apply, map_add, linear_map.comp_apply, \n    has_sign.map_smul, has_sign.smul_apply],\n  rw [← comp_apply], erw [d_comp_d_v],\n  erw has_sign.map_smul,\n  simp only [direct_sum.to_module_lof, linear_map.comp_apply, linear_map.add_apply, \n    has_sign.smul_apply],\n  nth_rewrite 2 [← comp_apply], erw [d_comp_d_h],\n  simp only [linear_map.zero_apply, map_zero, has_sign.smul_zero, add_zero, zero_add],\n  simp_rw show (diagonal.from_balancing1' c p hc12).fst = a.next p.fst, from rfl,\n  have EQ : diagonal.from_balancing2' c (diagonal.from_balancing1' c p hc12) hc23 =\n    diagonal.from_balancing1' c (diagonal.from_balancing2' c p hc12) hc23,\n  { ext; dsimp; refl, },\n  rw has_sign.next_smul,\n  work_on_goal 2 { exact p.from_balancing1'_rel c hc12, },\n  rw [neg_add_eq_sub, ← has_sign.smul_sub, has_sign.smul_eq_zero, sub_eq_zero],\n  congr' 1,\n  dsimp,\n  rw [← comp_apply, ← comp_apply],\n  rw C.comm,\nend\n\n@[simps]\ndef total_complex [has_sign a] : homological_complex (Module R) c :=\n{ X := λ k, C.total_at c k,\n  d := λ k k', C.total_d c k k',\n  shape' := \n  begin \n    rintros, rw total_d, rw dif_neg, assumption\n  end,\n  d_comp_d' := \n  begin \n    intros,\n    apply total_d_comp_d_of_rel;\n    assumption\n  end }\n\nend defs_in_mod\n\nend\n\nend homological_bicomplex", "meta": {"author": "jjaassoonn", "repo": "flat", "sha": "bab2f5c18fdee0042680c31b0350c69d241e9a82", "save_path": "github-repos/lean/jjaassoonn-flat", "path": "github-repos/lean/jjaassoonn-flat/flat-bab2f5c18fdee0042680c31b0350c69d241e9a82/src/bak/bicomplex2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426302, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.4860874345821411}}
{"text": "open tactic\nmeta def fsplit : tactic unit :=\ndo [c] ← target >>= get_constructors_for | tactic.fail \"fsplit tactic failed, target is not an inductive datatype with only one constructor\",\n   mk_const c >>= fapply\n   \nstructure Bijection ( U V : Type ) :=\n  ( morphism : U → V )\n  ( inverse  : V → U )\n  ( witness_1 : ∀ u : U, inverse (morphism u) = u )\n  ( witness_2 : ∀ v : V, morphism (inverse v) = v )\n\nclass Finite ( α : Type ) :=\n  ( cardinality : nat )\n  ( bijection : Bijection α (fin cardinality) )\n\nlemma empty_exfalso (x : false) : empty := begin exfalso, trivial end\n\ninstance empty_is_Finite : Finite empty := {\n  cardinality := 0,\n  bijection := begin\n                 fsplit, \n                 intros, \n                 induction a,\n                 intros,\n                 induction a,\n                 apply empty_exfalso,\n                 cases is_lt,\n                 intros, \n                 induction u,\n                 intros,\n                 induction v,\n                 cases is_lt,\n              end\n}", "meta": {"author": "semorrison", "repo": "proof", "sha": "5ee398aa239a379a431190edbb6022b1a0aa2c70", "save_path": "github-repos/lean/semorrison-proof", "path": "github-repos/lean/semorrison-proof/proof-5ee398aa239a379a431190edbb6022b1a0aa2c70/lean/20170705-failed_to_generate_bytecode.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9149009526726545, "lm_q2_score": 0.5312093733737562, "lm_q1q2_score": 0.48600396176829336}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Johan Commelin, Patrick Massot\n\n! This file was ported from Lean 3 source module algebra.order.with_zero\n! leanprover-community/mathlib commit 655994e298904d7e5bbd1e18c95defd7b543eb94\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Hom.Equiv.Units.GroupWithZero\nimport Mathlib.Algebra.GroupWithZero.InjSurj\nimport Mathlib.Algebra.Order.Group.Units\nimport Mathlib.Algebra.Order.Monoid.Basic\nimport Mathlib.Algebra.Order.Monoid.WithZero.Defs\nimport Mathlib.Algebra.Order.Group.Instances\nimport Mathlib.Algebra.Order.Monoid.TypeTags\n\n/-!\n# Linearly ordered commutative groups and monoids with a zero element adjoined\n\nThis file sets up a special class of linearly ordered commutative monoids\nthat show up as the target of so-called “valuations” in algebraic number theory.\n\nUsually, in the informal literature, these objects are constructed\nby taking a linearly ordered commutative group Γ and formally adjoining a zero element: Γ ∪ {0}.\n\nThe disadvantage is that a type such as `nnreal` is not of that form,\nwhereas it is a very common target for valuations.\nThe solutions is to use a typeclass, and that is exactly what we do in this file.\n\nNote that to avoid issues with import cycles, `LinearOrderedCommMonoidWithZero` is defined\nin another file. However, the lemmas about it are stated here.\n-/\n\n\n/-- A linearly ordered commutative group with a zero element. -/\nclass LinearOrderedCommGroupWithZero (α : Type _) extends LinearOrderedCommMonoidWithZero α,\n  CommGroupWithZero α\n#align linear_ordered_comm_group_with_zero LinearOrderedCommGroupWithZero\n\nvariable {α : Type _}\n\nvariable {a b c d x y z : α}\n\ninstance [LinearOrderedAddCommMonoidWithTop α] :\n    LinearOrderedCommMonoidWithZero (Multiplicative αᵒᵈ) :=\n  { Multiplicative.orderedCommMonoid, Multiplicative.linearOrder with\n    zero := Multiplicative.ofAdd (⊤ : α)\n    zero_mul := @top_add _ (_)\n    -- Porting note:  Here and elsewhere in the file, just `zero_mul` worked in Lean 3.  See\n    -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Type.20synonyms\n    mul_zero := @add_top _ (_)\n    zero_le_one := (le_top : (0 : α) ≤ ⊤) }\n#align multiplicative.linear_ordered_comm_monoid_with_zero instLinearOrderedCommMonoidWithZeroMultiplicativeOrderDual\n\ninstance [LinearOrderedAddCommGroupWithTop α] :\n    LinearOrderedCommGroupWithZero (Multiplicative αᵒᵈ) :=\n  { Multiplicative.divInvMonoid, instLinearOrderedCommMonoidWithZeroMultiplicativeOrderDual,\n    instNontrivialMultiplicative with\n    inv_zero := @LinearOrderedAddCommGroupWithTop.neg_top _ (_)\n    mul_inv_cancel := @LinearOrderedAddCommGroupWithTop.add_neg_cancel _ (_) }\n\ninstance [LinearOrderedCommMonoid α] : LinearOrderedCommMonoidWithZero (WithZero α) :=\n  { WithZero.linearOrder, WithZero.commMonoidWithZero with\n    mul_le_mul_left := fun _ _ ↦ mul_le_mul_left', zero_le_one := WithZero.zero_le _ }\n#align with_zero.linear_ordered_comm_monoid_with_zero instLinearOrderedCommMonoidWithZeroWithZero\n\ninstance [LinearOrderedCommGroup α] : LinearOrderedCommGroupWithZero (WithZero α) :=\n  { instLinearOrderedCommMonoidWithZeroWithZero, WithZero.commGroupWithZero with }\n\nsection LinearOrderedCommMonoid\n\nvariable [LinearOrderedCommMonoidWithZero α]\n\n/-\nThe following facts are true more generally in a (linearly) ordered commutative monoid.\n-/\n/-- Pullback a `LinearOrderedCommMonoidWithZero` under an injective map.\nSee note [reducible non-instances]. -/\n@[reducible]\ndef Function.Injective.linearOrderedCommMonoidWithZero {β : Type _} [Zero β] [One β] [Mul β]\n    [Pow β ℕ] [Sup β] [Inf β] (f : β → α) (hf : Function.Injective f) (zero : f 0 = 0)\n    (one : f 1 = 1) (mul : ∀ x y, f (x * y) = f x * f y) (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n)\n    (hsup : ∀ x y, f (x ⊔ y) = max (f x) (f y)) (hinf : ∀ x y, f (x ⊓ y) = min (f x) (f y)) :\n    LinearOrderedCommMonoidWithZero β :=\n  { LinearOrder.lift f hf hsup hinf, hf.orderedCommMonoid f one mul npow,\n    hf.commMonoidWithZero f zero one mul npow with\n    zero_le_one :=\n      show f 0 ≤ f 1 by simp only [zero, one, LinearOrderedCommMonoidWithZero.zero_le_one] }\n#align function.injective.linear_ordered_comm_monoid_with_zero Function.Injective.linearOrderedCommMonoidWithZero\n\n@[simp]\ntheorem zero_le' : 0 ≤ a := by simpa only [mul_zero, mul_one] using mul_le_mul_left' zero_le_one a\n#align zero_le' zero_le'\n\n@[simp]\ntheorem not_lt_zero' : ¬a < 0 :=\n  not_lt_of_le zero_le'\n#align not_lt_zero' not_lt_zero'\n\n@[simp]\ntheorem le_zero_iff : a ≤ 0 ↔ a = 0 :=\n  ⟨fun h ↦ le_antisymm h zero_le', fun h ↦ h ▸ le_rfl⟩\n#align le_zero_iff le_zero_iff\n\ntheorem zero_lt_iff : 0 < a ↔ a ≠ 0 :=\n  ⟨ne_of_gt, fun h ↦ lt_of_le_of_ne zero_le' h.symm⟩\n#align zero_lt_iff zero_lt_iff\n\ntheorem ne_zero_of_lt (h : b < a) : a ≠ 0 := fun h1 ↦ not_lt_zero' <| show b < 0 from h1 ▸ h\n#align ne_zero_of_lt ne_zero_of_lt\n\ninstance : LinearOrderedAddCommMonoidWithTop (Additive αᵒᵈ) :=\n  { Additive.orderedAddCommMonoid, Additive.linearOrder with\n    top := (0 : α)\n    top_add' := fun a ↦ zero_mul (Additive.toMul a)\n    le_top := fun _ ↦ zero_le' }\n#align additive.linear_ordered_add_comm_monoid_with_top instLinearOrderedAddCommMonoidWithTopAdditiveOrderDual\n\nend LinearOrderedCommMonoid\n\nvariable [LinearOrderedCommGroupWithZero α]\n\n-- TODO: Do we really need the following two?\n/-- Alias of `mul_le_one'` for unification. -/\ntheorem mul_le_one₀ (ha : a ≤ 1) (hb : b ≤ 1) : a * b ≤ 1 :=\n  mul_le_one' ha hb\n#align mul_le_one₀ mul_le_one₀\n\n/-- Alias of `one_le_mul'` for unification. -/\ntheorem one_le_mul₀ (ha : 1 ≤ a) (hb : 1 ≤ b) : 1 ≤ a * b :=\n  one_le_mul ha hb\n#align one_le_mul₀ one_le_mul₀\n\ntheorem le_of_le_mul_right (h : c ≠ 0) (hab : a * c ≤ b * c) : a ≤ b := by\n  simpa only [mul_inv_cancel_right₀ h] using mul_le_mul_right' hab c⁻¹\n#align le_of_le_mul_right le_of_le_mul_right\n\ntheorem le_mul_inv_of_mul_le (h : c ≠ 0) (hab : a * c ≤ b) : a ≤ b * c⁻¹ :=\n  le_of_le_mul_right h (by simpa [h] using hab)\n#align le_mul_inv_of_mul_le le_mul_inv_of_mul_le\n\ntheorem mul_inv_le_of_le_mul (hab : a ≤ b * c) : a * c⁻¹ ≤ b := by\n  by_cases h : c = 0\n  · simp [h]\n  · exact le_of_le_mul_right h (by simpa [h] using hab)\n#align mul_inv_le_of_le_mul mul_inv_le_of_le_mul\n\ntheorem inv_le_one₀ (ha : a ≠ 0) : a⁻¹ ≤ 1 ↔ 1 ≤ a :=\n  @inv_le_one' _ _ _ _ <| Units.mk0 a ha\n#align inv_le_one₀ inv_le_one₀\n\ntheorem one_le_inv₀ (ha : a ≠ 0) : 1 ≤ a⁻¹ ↔ a ≤ 1 :=\n  @one_le_inv' _ _ _ _ <| Units.mk0 a ha\n#align one_le_inv₀ one_le_inv₀\n\ntheorem le_mul_inv_iff₀ (hc : c ≠ 0) : a ≤ b * c⁻¹ ↔ a * c ≤ b :=\n  ⟨fun h ↦ inv_inv c ▸ mul_inv_le_of_le_mul h, le_mul_inv_of_mul_le hc⟩\n#align le_mul_inv_iff₀ le_mul_inv_iff₀\n\ntheorem mul_inv_le_iff₀ (hc : c ≠ 0) : a * c⁻¹ ≤ b ↔ a ≤ b * c :=\n  ⟨fun h ↦ inv_inv c ▸ le_mul_inv_of_mul_le (inv_ne_zero hc) h, mul_inv_le_of_le_mul⟩\n#align mul_inv_le_iff₀ mul_inv_le_iff₀\n\ntheorem div_le_div₀ (a b c d : α) (hb : b ≠ 0) (hd : d ≠ 0) : a * b⁻¹ ≤ c * d⁻¹ ↔ a * d ≤ c * b :=\n  by rw [mul_inv_le_iff₀ hb, mul_right_comm, le_mul_inv_iff₀ hd]\n#align div_le_div₀ div_le_div₀\n\n@[simp]\ntheorem Units.zero_lt (u : αˣ) : (0 : α) < u :=\n  zero_lt_iff.2 <| u.ne_zero\n#align units.zero_lt Units.zero_lt\n\ntheorem mul_lt_mul_of_lt_of_le₀ (hab : a ≤ b) (hb : b ≠ 0) (hcd : c < d) : a * c < b * d :=\n  have hd : d ≠ 0 := ne_zero_of_lt hcd\n  if ha : a = 0 then by\n    rw [ha, zero_mul, zero_lt_iff]\n    exact mul_ne_zero hb hd\n  else\n    if hc : c = 0 then by\n      rw [hc, mul_zero, zero_lt_iff]\n      exact mul_ne_zero hb hd\n    else\n      show Units.mk0 a ha * Units.mk0 c hc < Units.mk0 b hb * Units.mk0 d hd from\n        mul_lt_mul_of_le_of_lt hab hcd\n#align mul_lt_mul_of_lt_of_le₀ mul_lt_mul_of_lt_of_le₀\n\ntheorem mul_lt_mul₀ (hab : a < b) (hcd : c < d) : a * c < b * d :=\n  mul_lt_mul_of_lt_of_le₀ hab.le (ne_zero_of_lt hab) hcd\n#align mul_lt_mul₀ mul_lt_mul₀\n\ntheorem mul_inv_lt_of_lt_mul₀ (h : x < y * z) : x * z⁻¹ < y := by\n  contrapose! h\n  simpa only [inv_inv] using mul_inv_le_of_le_mul h\n#align mul_inv_lt_of_lt_mul₀ mul_inv_lt_of_lt_mul₀\n\ntheorem inv_mul_lt_of_lt_mul₀ (h : x < y * z) : y⁻¹ * x < z := by\n  rw [mul_comm] at *\n  exact mul_inv_lt_of_lt_mul₀ h\n#align inv_mul_lt_of_lt_mul₀ inv_mul_lt_of_lt_mul₀\n\ntheorem mul_lt_right₀ (c : α) (h : a < b) (hc : c ≠ 0) : a * c < b * c := by\n  contrapose! h\n  exact le_of_le_mul_right hc h\n#align mul_lt_right₀ mul_lt_right₀\n\ntheorem inv_lt_inv₀ (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ < b⁻¹ ↔ b < a :=\n  show (Units.mk0 a ha)⁻¹ < (Units.mk0 b hb)⁻¹ ↔ Units.mk0 b hb < Units.mk0 a ha from\n    have : CovariantClass αˣ αˣ (· * ·) (· < ·) :=\n      LeftCancelSemigroup.covariant_mul_lt_of_covariant_mul_le αˣ\n    inv_lt_inv_iff\n#align inv_lt_inv₀ inv_lt_inv₀\n\ntheorem inv_le_inv₀ (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a :=\n  show (Units.mk0 a ha)⁻¹ ≤ (Units.mk0 b hb)⁻¹ ↔ Units.mk0 b hb ≤ Units.mk0 a ha from\n    have : CovariantClass αˣ αˣ (Function.swap (· * ·)) (· ≤ ·) :=\n      OrderedCommMonoid.to_covariantClass_right αˣ\n    have : CovariantClass αˣ αˣ (· * ·) (· ≤ ·) :=\n      OrderedCommGroup.to_covariantClass_left_le αˣ\n    inv_le_inv_iff\n#align inv_le_inv₀ inv_le_inv₀\n\ntheorem lt_of_mul_lt_mul_of_le₀ (h : a * b < c * d) (hc : 0 < c) (hh : c ≤ a) : b < d := by\n  have ha : a ≠ 0 := ne_of_gt (lt_of_lt_of_le hc hh)\n  simp_rw [← inv_le_inv₀ ha (ne_of_gt hc)] at hh\n  have := mul_lt_mul_of_lt_of_le₀ hh (inv_ne_zero (ne_of_gt hc)) h\n  simpa [inv_mul_cancel_left₀ ha, inv_mul_cancel_left₀ (ne_of_gt hc)] using this\n#align lt_of_mul_lt_mul_of_le₀ lt_of_mul_lt_mul_of_le₀\n\ntheorem mul_le_mul_right₀ (hc : c ≠ 0) : a * c ≤ b * c ↔ a ≤ b :=\n  ⟨le_of_le_mul_right hc, fun hab ↦ mul_le_mul_right' hab _⟩\n#align mul_le_mul_right₀ mul_le_mul_right₀\n\ntheorem mul_le_mul_left₀ (ha : a ≠ 0) : a * b ≤ a * c ↔ b ≤ c := by\n  simp only [mul_comm a]\n  exact mul_le_mul_right₀ ha\n#align mul_le_mul_left₀ mul_le_mul_left₀\n\ntheorem div_le_div_right₀ (hc : c ≠ 0) : a / c ≤ b / c ↔ a ≤ b := by\n  rw [div_eq_mul_inv, div_eq_mul_inv, mul_le_mul_right₀ (inv_ne_zero hc)]\n#align div_le_div_right₀ div_le_div_right₀\n\ntheorem div_le_div_left₀ (ha : a ≠ 0) (hb : b ≠ 0) (hc : c ≠ 0) : a / b ≤ a / c ↔ c ≤ b := by\n  simp only [div_eq_mul_inv, mul_le_mul_left₀ ha, inv_le_inv₀ hb hc]\n#align div_le_div_left₀ div_le_div_left₀\n\ntheorem le_div_iff₀ (hc : c ≠ 0) : a ≤ b / c ↔ a * c ≤ b := by\n  rw [div_eq_mul_inv, le_mul_inv_iff₀ hc]\n#align le_div_iff₀ le_div_iff₀\n\ntheorem div_le_iff₀ (hc : c ≠ 0) : a / c ≤ b ↔ a ≤ b * c := by\n  rw [div_eq_mul_inv, mul_inv_le_iff₀ hc]\n#align div_le_iff₀ div_le_iff₀\n\n/-- `Equiv.mulLeft₀` as an `OrderIso` on a `LinearOrderedCommGroupWithZero.`.\n\nNote that `OrderIso.mulLeft₀` refers to the `LinearOrderedField` version. -/\n@[simps! (config := { simpRhs := true }) apply toEquiv]\ndef OrderIso.mulLeft₀' {a : α} (ha : a ≠ 0) : α ≃o α :=\n  { Equiv.mulLeft₀ a ha with map_rel_iff' := mul_le_mul_left₀ ha }\n#align order_iso.mul_left₀' OrderIso.mulLeft₀'\n#align order_iso.mul_left₀'_to_equiv OrderIso.mulLeft₀'_toEquiv\n#align order_iso.mul_left₀'_apply OrderIso.mulLeft₀'_apply\n\ntheorem OrderIso.mulLeft₀'_symm {a : α} (ha : a ≠ 0) :\n    (OrderIso.mulLeft₀' ha).symm = OrderIso.mulLeft₀' (inv_ne_zero ha) := by\n  ext\n  rfl\n#align order_iso.mul_left₀'_symm OrderIso.mulLeft₀'_symm\n\n/-- `Equiv.mulRight₀` as an `OrderIso` on a `LinearOrderedCommGroupWithZero.`.\n\nNote that `OrderIso.mulRight₀` refers to the `LinearOrderedField` version. -/\n@[simps! (config := { simpRhs := true }) apply toEquiv]\ndef OrderIso.mulRight₀' {a : α} (ha : a ≠ 0) : α ≃o α :=\n  { Equiv.mulRight₀ a ha with map_rel_iff' := mul_le_mul_right₀ ha }\n#align order_iso.mul_right₀' OrderIso.mulRight₀'\n#align order_iso.mul_right₀'_apply OrderIso.mulRight₀'_apply\n#align order_iso.mul_right₀'_to_equiv OrderIso.mulRight₀'_toEquiv\n\ntheorem OrderIso.mulRight₀'_symm {a : α} (ha : a ≠ 0) :\n    (OrderIso.mulRight₀' ha).symm = OrderIso.mulRight₀' (inv_ne_zero ha) := by\n  ext\n  rfl\n#align order_iso.mul_right₀'_symm OrderIso.mulRight₀'_symm\n\ninstance : LinearOrderedAddCommGroupWithTop (Additive αᵒᵈ) :=\n  { Additive.subNegMonoid, instLinearOrderedAddCommMonoidWithTopAdditiveOrderDual,\n    instNontrivialAdditive with\n    neg_top := @inv_zero _ (_)\n    add_neg_cancel := fun a ha ↦ mul_inv_cancel (id ha : Additive.toMul a ≠ 0) }\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/Order/WithZero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4860012577778465}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ i j : ℤ, i ≠ j → (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from by {\n    assume i j h,\n    assume heq : int.fract (α * ↑i) = int.fract (α * ↑j),\n    have h2 : (α * ↑i) - ↑(int.nat_abs (α * ↑i)) = (α * ↑j) - ↑(int.nat_abs (α * ↑j)), from by {\n      rw heq,\n    },\n    have h3 : (α * ↑i) - ↑(int.nat_abs (α * ↑i)) = ↑i * α - ↑i * α + (↑(int.nat_abs (α * ↑i)) - ↑i * α), from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (α * ↑i),\n    },\n    have h4 : (α * ↑j) - ↑(int.nat_abs (α * ↑j)) = ↑j * α - ↑j * α + (↑(int.nat_abs (α * ↑j)) - ↑j * α), from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (α * ↑j),\n    },\n    have h5 : ↑i * α - ↑i * α + (↑(int.nat_abs (α * ↑i)) - ↑i * α) = ↑j * α - ↑j * α + (↑(int.nat_abs (α * ↑j)) - ↑j * α), from by {\n      rw h2,\n    },\n    have h6 : ↑i * α - ↑i * α = ↑j * α - ↑j * α, from by {\n      rw h5,\n    },\n    have h7 : ↑i * α = ↑j * α, from by {\n      rw h6,\n    },\n    have h8 : i * α = j * α, from by {\n      rw h7,\n    },\n    let h9 : (α = (i/j : ℤ)) ∨ (α = -(i/j : ℤ)), from by {\n      apply exists_rat_btwn, exact hα_irrat,\n    },\n    rw h8 at h9,\n    cases h9,\n    {\n    have h10 : α = i/j, from by {\n      rw h9,\n    },\n    have h11 : α = (j/i : ℤ), from by {\n      rw h10,\n      rw mul_comm,\n      rw int.mul_inv_cancel i,\n    },\n    have h12 : α = -(i/j : ℤ), from by {\n      rw h11,\n      rw int.mul_neg_self_iff,\n    },\n    rw h12 at hα_irrat,\n    exact absurd hα_irrat (irrational_of_int_div_int h),\n    },\n    {\n    have h10 : α = -(i/j : ℤ), from by {\n      rw h9,\n    },\n    have h11 : α = (j/i : ℤ), from by {\n      rw h10,\n      rw mul_comm,\n      rw int.mul_inv_cancel i,\n    },\n    have h12 : α = -(i/j : ℤ), from by {\n      rw h11,\n      rw int.mul_neg_self_iff,\n    },\n    rw h12 at hα_irrat,\n    exact absurd hα_irrat (irrational_of_int_div_int h),\n    },\n  },\n  have h2 : ∀ i j : ℤ, i ≠ j → (int.fract (α * ↑i)) ∉ ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)), from by {\n    assume i j h3,\n    assume h4 : int.fract (α * ↑i) ∈ ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)),\n    cases h4 with j h5,\n    cases h5 with h6 h7,\n    have h8 : int.fract (α * ↑i) = int.fract (α * ↑j), from by {\n      rw h7,\n    },\n    have h9 : i ≠ j, from by {\n      exact h1 i j h3 h8,\n    },\n    exact absurd h3 h9,\n  },\n  have h3 : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1, from by {\n    apply closure_eq_of_is_closed,\n    apply is_closed_Icc,\n  },\n  have h4 : ∀ i j : ℤ, i ≠ j → (int.fract (α * ↑i)) ∈ (set.Icc 0 1), from by {\n    assume i j h,\n    have h5 : 0 ≤ int.fract (α * ↑i), from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (α * ↑i),\n    },\n    have h6 : int.fract (α * ↑i) < 1, from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (α * ↑i),\n    },\n    split,\n    exact h5,\n    exact h6,\n  },\n  have h5 : ∀ i : ℤ, (int.fract (α * ↑i)) ∈ (set.Icc 0 1), from by {\n    assume i,\n    apply h4 i i,\n    exact int.ne_of_nat_ne_nat (nat.succ_ne_zero 0),\n  },\n  have h6 : set.Icc 0 1 = ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)), from by {\n    apply set.ext,\n    split,\n    {\n      assume x h7,\n      use 0,\n      split,\n      exact set.mem_univ 0,\n      have h8 : int.fract (α * ↑0) = int.fract (α * ↑0), from rfl,\n      rw h8,\n    },\n    {\n      assume x h7,\n      cases h7 with i h8,\n      cases h8 with h9 h10,\n      have h11 : int.fract (α * ↑i) = x, from by {\n        rw h10,\n      },\n      rw h11,\n      exact h5 i,\n    },\n  },\n  rw h6,\n  apply set.ext,\n  split,\n  {\n    assume x h7,\n    cases h7 with i h8,\n    cases h8 with h9 h10,\n    have h11 : int.fract (α * ↑i) = x, from by {\n      rw h10,\n    },\n    rw h11,\n    exact h5 i,\n  },\n  {\n    assume x h7,\n    use 0,\n    split,\n    exact set.mem_univ 0,\n    have h8 : int.fract (α * ↑0) = int.fract (α * ↑0), from rfl,\n    rw h8,\n  },\nend\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  --$\\alpha$ is an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * i) ≠ int.fract (α * j),\n  from by {\n    assume (i j : ℤ) (hneq : i ≠ j),\n    have h2 : int.fract (α * i) = α * i - ⌊α * i⌋, from by {rw int.fract},\n    have h3 : int.fract (α * j) = α * j - ⌊α * j⌋, from by {rw int.fract},\n    have h4 : i ≠ j → α ≠ (⌊α * i⌋ - ⌊α * j⌋) / (i-j), from by {\n      assume hneq1 : i ≠ j,\n      assume h5 : α = (⌊α * i⌋ - ⌊α * j⌋) / (i-j),\n      have h6 : (⌊α * i⌋ - ⌊α * j⌋) = (i-j) * α, from by {rw h5, ring},\n      have h7 : ⌊α * i⌋ = ⌊(i-j) * α⌋, from by {rw ← h6, ring},\n      have h8 : ⌊α * j⌋ = ⌊(i-j) * α⌋, from by {rw ← h6, ring},\n      have h9 : ⌊(i-j) * α⌋ ∈ ℤ, from by {rw int.cast_coe_int, apply int.cast_le.mp, apply int.floor_nonneg},\n      have h10 : ⌊α * i⌋ = ⌊α * j⌋, from by {rw h7, rw h8},\n      have h11 : α * i = ⌊α * i⌋, from by {rw int.cast_coe_int, apply int.cast_le.mp, apply int.floor_nonneg},\n      have h12 : α * j = ⌊α * j⌋, from by {rw int.cast_coe_int, apply int.cast_le.mp, apply int.floor_nonneg},\n      have h13 : α * i = α * j, from by {rw h10, rw h11, rw h12},\n      have h14 : i = j, from by {linarith, linarith},\n      exact h14 hneq1,\n    },\n    have h15 : i - j ≠ 0, from by {intro h16, exact hneq (eq_of_sub_eq_zero h16)},\n    have h16 : rational ((⌊α * i⌋ - ⌊α * j⌋) / (i-j)), from by {rw ← h2, rw ← h3, apply rational.add_sub_div, apply rational.mul_self_floor, apply rational.mul_self_floor, apply rational.mul_self_floor, apply rational.mul_self_floor, apply irrational.floor_div_irrational, exact hα_irrat, exact h15, exact h15},\n    exact hα_irrat h4 h16,\n  },\n\n  --If this were not true, then\n  --$$\n  --i \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n  --$$\n  --which yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$.\n  --Hence,\n  --$$\n  --S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n  --$$\n  --is an infinite subset of $\\left[0,1\\right]$.\n  have h2 : ∀ i j : ℤ, i ≠ j → (λ m : ℤ, int.fract (α * m)) i ≠ (λ m : ℤ, int.fract (α * m)) j,\n  from by {\n    assume (i j : ℤ) (hneq : i ≠ j),\n    have h3 : (λ m : ℤ, int.fract (α * m)) i = int.fract (α * i), from by {rw (λ m : ℤ, int.fract (α * m))},\n    have h4 : (λ m : ℤ, int.fract (α * m)) j = int.fract (α * j), from by {rw (λ m : ℤ, int.fract (α * m))},\n    rw h3, rw h4, exact h1 i j hneq,\n  },\n  have h3 : (λ m : ℤ, int.fract (α * m)) '' (@set.univ ℤ) ⊆ set.Icc 0 1,\n  from by {\n    assume x,\n    assume h4 : x ∈ (λ m : ℤ, int.fract (α * m)) '' (@set.univ ℤ),\n    cases h4 with y h5,\n    cases h5 with h6 h7,\n    have h8 : (λ m : ℤ, int.fract (α * m)) y = x, from by {rw h7, apply h6},\n    have h9 : y ∈ @set.univ ℤ, from by {exact h7},\n    rw h8,\n    have h10 : 0 ≤ int.fract (α * y), from by {rw h8, apply int.fract_nonneg},\n    have h11 : int.fract (α * y) < 1, from by {rw h8, apply int.fract_lt_one},\n    split,\n    exact h10,\n    exact h11,\n  },\n  have h4 : set.Icc 0 1 ⊆ (λ m : ℤ, int.fract (α * m)) '' (@set.univ ℤ),\n  from by {\n    assume x,\n    assume h5 : x ∈ set.Icc 0 1,\n    cases h5 with h6 h7,\n    have h8 : ∃ i : ℤ, int.fract (α * i) = x, from by {\n      have h9 : ∃ i : ℤ, int.fract (α * i) ≤ x, from by {\n        have h10 : ∃ i : ℤ, 0 ≤ int.fract (α * i), from by {\n          existsi (0 : ℤ),\n          have h11 : (α * (0 : ℤ)) = 0, from by {rw mul_zero},\n          rw h11,\n          apply int.fract_nonneg,\n        },\n        existsi (⌈x⌉ : ℤ),\n        have h12 : x < int.fract (α * ⌈x⌉), from by {rw int.fract, linarith},\n        have h13 : x < α * ⌈x⌉ - ⌊α * ⌈x⌉⌋, from by {rw int.fract, linarith},\n        have h14 : x < α * ⌈x⌉, from by {exact lt_of_lt_of_le h13 (int.floor_le _)},\n        have h15 : x ≤ ⌈x⌉, from by {apply le_of_lt, exact h14},\n        have h16 : x ≤ α * ⌈x⌉, from by {linarith, linarith},\n        have h17 : x ≤ int.fract (α * ⌈x⌉), from by {rw int.fract, linarith, linarith},\n        exact le_trans h17 (int.fract_le _),\n      },\n      cases\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  -- Let $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n  have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * i) ≠ int.fract (α * j),\n  from by {\n    assume i j,\n    assume h2 : i ≠ j,\n    assume h3 : int.fract (α * i) = int.fract (α * j),\n    have h4 : α * i - (int.fract (α * i)) = int.fract (α * i), from by rw [h3,int.fract_eq_of_lt (by linarith)],\n    have h5 : α * j - (int.fract (α * j)) = int.fract (α * j), from by rw [h3,int.fract_eq_of_lt (by linarith)],\n    have h6 : α = (int.fract (α * i) - int.fract (α * j)) / (i - j), from by rw [←h4,←h5],\n    have h7 : (int.fract (α * i) - int.fract (α * j)) / (i - j) ∈ ℚ, from by apply quotient.exact h6,\n    have h8 : α ∈ ℚ, from by apply rational_iff_exists_rat.mp h7,\n    have h9 : irrational α, from by assumption,\n    contradiction,\n  },\n\n  -- Hence, $S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$ is an infinite subset of $\\left[0,1\\right]$.\n  have h10 : ∀ i : ℤ, int.fract (α * i) ∈ set.Icc 0 1, from by {\n    assume i : ℤ,\n    have h11 : ↑i * α - ↑(int.fract (α * i)) = int.fract (α * i), from by apply int.fract_eq_of_lt (by linarith),\n    have h12 : ↑i * α - int.fract (α * i) < ↑i * α, from by linarith,\n    have h13 : 0 < int.fract (α * i), from by linarith,\n    have h14 : 0 ≤ int.fract (α * i) ∧ int.fract (α * i) < 1, from by rw [←h11,int.fract_lt_one],\n    exact set.mem_Icc.mpr h14,\n  },\n  have h15 : set.finite (∅ : set ℤ), from by apply set.finite_empty,\n  have h16 : set.finite {z : ℤ | z = 0}, from by apply set.finite_singleton,\n  have h17 : set.finite {z : ℤ | z = -1}, from by apply set.finite_singleton,\n  have h18 : set.finite {z : ℤ | z = 1}, from by apply set.finite_singleton,\n  have h19 : set.finite {z : ℤ | (0 < z) ∧ (z < 1)}, from by apply set.finite_Ico,\n  have h20 : set.finite {z : ℤ | (z < 0) ∧ (-1 < z)}, from by apply set.finite_Icc,\n  have h21 : set.finite {z : ℤ | (z < 0) ∧ (z < -1)}, from by apply set.finite_Icc,\n  have h22 : set.finite {z : ℤ | (0 < z) ∧ (1 < z)}, from by apply set.finite_Ico,\n  have h23 : set.finite {z : ℤ | z = -2}, from by apply set.finite_singleton,\n  have h24 : set.finite {z : ℤ | z = 2}, from by apply set.finite_singleton,\n  have h25 : set.finite {z : ℤ | (z < -2) ∧ (-3 < z)}, from by apply set.finite_Icc,\n  have h26 : set.finite {z : ℤ | (z < -3) ∧ (-4 < z)}, from by apply set.finite_Icc,\n  have h27 : set.finite {z : ℤ | (z < -4) ∧ (-5 < z)}, from by apply set.finite_Icc,\n  have h28 : set.finite {z : ℤ | (z < -5) ∧ (-6 < z)}, from by apply set.finite_Icc,\n  have h29 : set.finite {z : ℤ | (z < -6) ∧ (-7 < z)}, from by apply set.finite_Icc,\n  have h30 : set.finite {z : ℤ | (z < -7) ∧ (-8 < z)}, from by apply set.finite_Icc,\n  have h31 : set.finite {z : ℤ | (z < -8) ∧ (-9 < z)}, from by apply set.finite_Icc,\n  have h32 : set.finite {z : ℤ | (z < -9) ∧ (-10 < z)}, from by apply set.finite_Icc,\n  have h33 : set.finite {z : ℤ | (2 < z) ∧ (z < 3)}, from by apply set.finite_Ico,\n  have h34 : set.finite {z : ℤ | (3 < z) ∧ (z < 4)}, from by apply set.finite_Ico,\n  have h35 : set.finite {z : ℤ | (4 < z) ∧ (z < 5)}, from by apply set.finite_Ico,\n  have h36 : set.finite {z : ℤ | (5 < z) ∧ (z < 6)}, from by apply set.finite_Ico,\n  have h37 : set.finite {z : ℤ | (6 < z) ∧ (z < 7)}, from by apply set.finite_Ico,\n  have h38 : set.finite {z : ℤ | (7 < z) ∧ (z < 8)}, from by apply set.finite_Ico,\n  have h39 : set.finite {z : ℤ | (8 < z) ∧ (z < 9)}, from by apply set.finite_Ico,\n  have h40 : set.finite {z : ℤ | (9 < z) ∧ (z < 10)}, from by apply set.finite_Ico,\n  have h41 : set.finite {z : ℤ | (10 < z) ∧ (z < 11)}, from by apply set.finite_Ico,\n  have h42 : set.finite {z : ℤ | (11 < z) ∧ (z < 12)}, from by apply set.finite_Ico,\n  have h43 : set.finite {z : ℤ | (12 < z) ∧ (z < 13)}, from by apply set.finite_Ico,\n  have h44 : set.finite {z : ℤ | (13 < z) ∧ (z < 14)}, from by apply set.finite_Ico,\n  have h45 : set.finite {z : ℤ | (14 < z) ∧ (z < 15)}, from by apply set.finite_Ico,\n  have h46 : set.finite {z : ℤ | (15 < z) ∧ (z < 16)}, from by apply set.finite_Ico,\n  have h47 : set.finite {z : ℤ | (16 < z) ∧ (z < 17)}, from by apply set.finite_Ico,\n  have h48 : set.finite {z : ℤ | (17 < z) ∧ (z < 18\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ m n : ℤ, ↑(m * n) = (↑m : ℝ) * n, from by {\n    assume m n : ℤ,\n    have h1 : (↑m : ℝ) * n = ↑m * n, from by {\n      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                        have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                          have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                            have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                              have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                                have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                                  have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                                    have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                                      have h1 : (↑m : ℝ) * n = ↑m * ↑n, from by {\n                                                                                                                                        have h1 : (↑m : ℝ\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  --By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  let S : set ℝ := {int.fract (α * ↑m) | m : ℤ},\n  have h1 : ∃ x : ℝ, x ∈ closure S, from by {\n    have h2 : ∀ m n : ℤ, m ≠ n → (int.fract (α * ↑m)) ≠ int.fract (α * ↑n), from by {\n      assume m n hmn,\n      have h3 : m ≠ n, from by {\n        cases hmn, exact hmn,\n      },\n      have h4 : α ≠ ↑n / ↑m, from by {\n        rw hmn at hα_irrat, exact hα_irrat,\n      },\n      have h5 : (α * ↑m) ≠ (α * ↑n), from by {\n        rw mul_comm (α * ↑m) (α * ↑n),\n        rw mul_assoc α ↑m ↑n,\n        rw mul_comm ↑m ↑n,\n        rw mul_assoc ↑m α ↑n,\n        rw mul_comm ↑m α,\n        rw mul_assoc ↑m ↑n α,\n        rw mul_comm ↑n α,\n        rw mul_assoc ↑n ↑m α,\n        rw hmn,\n        rw mul_comm ↑m ↑n,\n        rw ← mul_assoc,\n        rw mul_comm α,\n        rw mul_inv_cancel α,\n        rw mul_one,\n        rw mul_comm ↑n ↑m,\n        rw h4,\n        rw mul_comm ↑n ↑m,\n        rw mul_one,\n      },\n      exact int.fract_ne_of_ne h5,\n    },\n    exact exists_mem_of_finite_image_ne_empty h2,\n  },\n\n  --One can thus find pairs of elements of $S$ that are arbitrarily close. \n  have h2 : ∀ ε > 0, ∃ x y ∈ S, ∀ z ∈ S, |z - x| < ε ∧ |z - y| < ε, from by {\n    assume ε hε,\n    cases h1 with x hx,\n    cases (mem_closure_iff.1 hx ε hε) with h3 h4,\n    cases h3 with y hy,\n    use x, use y,\n    intros z hz,\n    rw [mem_image, exists_prop],\n    use z,\n    split,\n    exact hz,\n    have h5 : ∀ z' ∈ S, ∃ m : ℤ, z' = int.fract (α * ↑m), from by {\n      assume z' hz',\n      rw mem_image at hz',\n      rcases hz' with ⟨m, rfl⟩,\n      use m,\n      exact rfl,\n    },\n    cases h4 z with h6 h7,\n    rcases (h5 z h6) with ⟨m, rfl⟩,\n    rcases (h5 y hy) with ⟨n, rfl⟩,\n    have h8 : ∀ m n : ℤ, m ≠ n → (int.fract (α * ↑m)) ≠ int.fract (α * ↑n), from by {\n      assume m n hmn,\n      have h9 : m ≠ n, from by {\n        cases hmn, exact hmn,\n      },\n      have h10 : α ≠ ↑n / ↑m, from by {\n        rw hmn at hα_irrat, exact hα_irrat,\n      },\n      have h11 : (α * ↑m) ≠ (α * ↑n), from by {\n        rw mul_comm (α * ↑m) (α * ↑n),\n        rw mul_assoc α ↑m ↑n,\n        rw mul_comm ↑m ↑n,\n        rw mul_assoc ↑m α ↑n,\n        rw mul_comm ↑m α,\n        rw mul_assoc ↑m ↑n α,\n        rw mul_comm ↑n α,\n        rw mul_assoc ↑n ↑m α,\n        rw hmn,\n        rw mul_comm ↑m ↑n,\n        rw ← mul_assoc,\n        rw mul_comm α,\n        rw mul_inv_cancel α,\n        rw mul_one,\n        rw mul_comm ↑n ↑m,\n        rw h10,\n        rw mul_comm ↑n ↑m,\n        rw mul_one,\n      },\n      exact int.fract_ne_of_ne h11,\n    },\n    have h12 : (int.fract (α * ↑m)) ≠ int.fract (α * ↑n), from by {\n      apply h8, exact h7,\n    },\n    have h13 : (α * ↑m) ≠ (α * ↑n), from by {\n      exact int.fract_ne_of_ne h12,\n    },\n    have h14 : ↑m ≠ ↑n, from by {\n      intro h,\n      rw [← mul_assoc, mul_comm ↑m ↑n, h] at h13,\n      have h15 : (α * ↑n) = (α * ↑m), from h13,\n      have h16 : ↑n = ↑m, from by {\n        rw ← mul_assoc,\n        rw mul_comm ↑n α,\n        rw mul_inv_cancel α,\n        rw mul_one,\n      },\n      contradiction,\n    },\n    have h17 : (int.fract (α * ↑n)) = z, from by {\n      rw int.fract_mul,\n      rw int.fract_mul,\n      rw mul_comm ↑n α,\n      rw mul_assoc ↑n ↑m α,\n      rw ← mul_assoc,\n      rw mul_comm ↑n ↑m,\n      rw h16,\n      rw mul_assoc ↑m α ↑n,\n      rw mul_comm ↑m α,\n      rw ← mul_assoc,\n      rw mul_comm α ↑m,\n      rw mul_inv_cancel α,\n      rw mul_one,\n    },\n    have h18 : (int.fract (α * ↑m)) = y, from by {\n      rw int.fract_mul,\n      rw int.fract_mul,\n      rw mul_comm ↑m α,\n      rw mul_assoc ↑m ↑n α,\n      rw ← mul_assoc,\n      rw mul_comm ↑m ↑n,\n      rw h16,\n      rw mul_assoc ↑n α ↑m,\n      rw mul_comm ↑n α,\n      rw ← mul_assoc,\n      rw mul_comm α ↑n,\n      rw mul_inv_cancel α,\n      rw mul_one,\n    },\n    have h19 : (int.fract (α * ↑m)) - (int.fract (α * ↑n)) = y - z, from by {\n      rw h17,\n      rw h18,\n    },\n    have h20 : ↑m - ↑n = (y - z) / α, from by {\n      rw [← mul_assoc, mul_comm α ↑n, mul_assoc α ↑n ↑m, ← mul_assoc] at h19,\n      rw mul_comm α ↑m at h19,\n      rw ← mul_assoc at h19,\n      rw mul_comm ↑m α at h19,\n      rw mul_inv_cancel α at h19,\n      rw mul_one at h19,\n      rw h19,\n      rw mul_sub,\n      rw mul_comm ↑m ↑n,\n      rw mul_sub,\n      rw mul_comm ↑m ↑n,\n    },\n    have h21 : ↑m - ↑n ≠ 0, from by {\n      linarith,\n    },\n    have h\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin \n  have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),\n  from by {\n    assume i j : ℤ,\n    assume h2 : i ≠ j,\n    assume h3 : int.fract (α * ↑i) = int.fract (α * ↑j),\n    have h4 : α = (int.fract (α * ↑i)) / (i-j), from by {\n      rw h3,\n      have h5 : (int.fract (α * ↑i)) / (i-j) = ((α * ↑i) - int.nat_abs (α * ↑i)) / (i-j), from by {\n        rw int.fract_def, \n        have h6 : int.nat_abs (α * ↑i) = int.nat_abs ((α * ↑i) - ((α * ↑i) - int.nat_abs (α * ↑i))), from by {\n          apply int.nat_abs_of_nonneg,\n          rw int.nat_abs_of_nonneg,\n          linarith,\n        },\n        rw h6, ring,\n      },\n      rw h5, ring,\n    },\n    have h5 : α ∈ ℚ, from by {\n      have h6 := (set.mem_rat.mpr (⟨α, h4⟩ : ℚ × ℚ)),\n      apply set.mem_rat_iff.mp h6,\n      },\n    apply irrational.not_mem_of_mem_rat hα_irrat h5,\n  },\n\n  --$S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$\n  --$S$ is an infinite subset of $\\left[0,1\\right]$.\n  have h2 : infinite ((λ m : ℤ, int.fract (α * ↑m)) '' set.univ), from by {\n    have h3 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h4 : i ≠ j,\n      have h5 : int.fract (α * ↑i) ∉ {int.fract (α * ↑j)}, from by {\n        rw set.not_mem_singleton,\n        apply h1 i j h4,\n      },\n      exact h5,\n    },\n    have h4 : ∀ i j : ℤ, i ≠ j → (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from by {\n      assume i j : ℤ,\n      assume h5 : i ≠ j,\n      apply h3 i j h5,\n    },\n    have h5 : ∀ i j : ℤ, i ≠ j → ↑i ≠ ↑j, from by {\n      assume i j : ℤ,\n      assume h6 : i ≠ j,\n      apply int.cast_ne_int.mpr h6,\n    },\n    have h6 : ∀ i j : ℤ, i ≠ j → ↑i ≠ ↑j, from by {\n      assume i j : ℤ,\n      assume h7 : i ≠ j,\n      apply h5 i j h7,\n    },\n    have h7 : ∀ i j : ℤ, i ≠ j → (α * ↑i) ≠ (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h8 : i ≠ j,\n      apply int.cast_ne_int.mpr h8,\n    },\n    have h8 : ∀ i j : ℤ, i ≠ j → (α * ↑i) ≠ (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h9 : i ≠ j,\n      apply h7 i j h9,\n    },\n    have h9 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h10 : i ≠ j,\n      apply h4 i j h10,\n    },\n    have h10 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h11 : i ≠ j,\n      apply h9 i j h11,\n    },\n    have h11 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h12 : i ≠ j,\n      apply h10 i j h12,\n    },\n    have h12 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h13 : i ≠ j,\n      apply h11 i j h13,\n    },\n    have h13 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h14 : i ≠ j,\n      apply h12 i j h14,\n    },\n    have h14 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h15 : i ≠ j,\n      apply h13 i j h15,\n    },\n    have h15 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h16 : i ≠ j,\n      apply h14 i j h16,\n    },\n    have h16 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h17 : i ≠ j,\n      apply h15 i j h17,\n    },\n    have h17 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h18 : i ≠ j,\n      apply h16 i j h18,\n    },\n    have h18 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h19 : i ≠ j,\n      apply h17 i j h19,\n    },\n    have h19 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h20 : i ≠ j,\n      apply h18 i j h20,\n    },\n    have h20 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h21 : i ≠ j,\n      apply h19 i j h21,\n    },\n    have h21 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume i j : ℤ,\n      assume h22 : i ≠ j,\n     \nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  --Let $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  have h1 : ∀ (i j : ℤ), i ≠ j → int.fract (i * α) ≠ int.fract (j * α), from assume (i j : ℤ) (h2 : i ≠ j), \n  by {\n    rw [int.fract_eq, int.fract_eq] at h2,\n    have h3 : α = (int.nat_abs (i - j))⁻¹ * (i * α - j * α), from by {\n      rw mul_comm,\n      rw sub_mul,\n      rw h2,\n      ring,\n    },\n    rw [int.nat_abs_of_nonneg (le_of_lt (int.coe_nat_pos.2 hα_irrat))] at h3,\n    have h4 : α ∈ ℚ, from by {\n      rw int.coe_nat_dvd,\n      use (i - j),\n      simp [h3],\n    },\n    have h5 : irrational α, from hα_irrat,\n    have h6 : ¬(α ∈ ℚ), from h5,\n    contradiction,\n  },\n  --If this were not true, then\n  --$$\n  --i \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n  --$$\n  --which yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$.\n  --Hence,\n  --$$\n  --S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n  --$$\n  --is an infinite subset of $\\left[0,1\\right]$.\n  have h7 : set.infinite ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)), from by {\n    have h8 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n      assume (i j : ℤ) (h9 : i ≠ j),\n      rw [mul_comm α i, mul_comm α j] at h9,\n      exact h1 i j h9,\n    },\n    have h9 : ∀ (i j : ℤ), i ≠ j → (λ m : ℤ, int.fract (α * ↑m)) i ≠ (λ m : ℤ, int.fract (α * ↑m)) j, from by {\n      assume (i j : ℤ) (h10 : i ≠ j),\n      rw [eq_comm, ← function.funext_iff],\n      exact h8 i j h10,\n    },\n    show set.infinite ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)), from\n    by {\n      apply set.infinite_of_injective_of_univ,\n      exact h9,\n      exact set.univ_mem_univ,\n    },\n  },\n  --By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h10 : set.has_limit_point ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) (Icc 0 1), from by {\n    apply set.has_limit_point_of_infinite_of_compact_of_nonempty,\n    exact h7,\n    exact is_compact_Icc,\n    simp,\n  },\n  --One can thus find pairs of elements of $S$ that are arbitrarily close.\n  have h11 : ∀ (ε : ℝ), ε > 0 → ∃ (x y : ℤ), x ≠ y ∧ (λ m : ℤ, int.fract (α * ↑m)) x ≠ (λ m : ℤ, int.fract (α * ↑m)) y ∧ int.fract (α * ↑y) - int.fract (α * ↑x) < ε, from by {\n    assume (ε : ℝ) (h12 : ε > 0),\n    apply set.has_limit_point.has_limit_point_of_finite_cover,\n    exact h10,\n    exact h12,\n    exact set.univ_mem_univ,\n    use (set.Icc 0 1),\n    use (set.Ioo (ε / 2) (1 - (ε / 2))),\n    split,\n    {\n      rw [← set.image_univ],\n      rw [← set.image_univ],\n      apply set.finite_inter_finite,\n      apply set.finite_Icc,\n      apply set.finite_Ioo,\n    },\n    {\n      rw [← set.image_univ],\n      rw [← set.image_univ],\n      apply set.finite_inter_finite,\n      apply set.finite_Icc,\n      apply set.finite_Ioo,\n    },\n    {\n      rw [← set.image_univ],\n      rw [← set.image_univ],\n      rw [← set.image_univ],\n      rw [← set.image_univ],\n      apply set.finite_inter_finite,\n      apply set.finite_Icc,\n      apply set.finite_Ioo,\n    },\n    {\n      rw [← set.image_inter],\n      rw [← set.image_inter],\n      rw [← set.image_inter],\n      rw [← set.image_inter],\n      intros x h13,\n      cases h13 with x1 h14,\n      cases h14 with x2 h15,\n      cases h15 with h16 h17,\n      cases h17 with h18 h19,\n      cases h19 with h20 h21,\n      cases h21 with h22 h23,\n      cases h23 with h24 h25,\n      cases h25 with h26 h27,\n      cases h27 with h28 h29,\n      cases h29 with h30 h31,\n      cases h31 with h32 h33,\n      cases h33 with h34 h35,\n      cases h35 with h36 h37,\n      cases h37 with h38 h39,\n      cases h39 with h40 h41,\n      cases h41 with h42 h43,\n      cases h43 with h44 h45,\n      cases h45 with h46 h47,\n      cases h47 with h48 h49,\n      cases h49 with h50 h51,\n      cases h51 with h52 h53,\n      cases h53 with h54 h55,\n      cases h55 with h56 h57,\n      cases h57 with h58 h59,\n      cases h59 with h60 h61,\n      cases h61 with h62 h63,\n      cases h63 with h64 h65,\n      cases h65 with h66 h67,\n      cases h67 with h68 h69,\n      cases h69 with h70 h71,\n      cases h71 with h72 h73,\n      cases h73 with h74 h75,\n      cases h75 with h76 h77,\n      cases h77 with h78 h79,\n      cases h79 with h80 h81,\n      cases h81 with h82 h83,\n      cases h83 with h84 h85,\n      cases h85 with h86 h87,\n      cases h87 with h88 h89,\n      cases h89 with h90 h91,\n      cases h91 with h92 h93,\n      cases h93 with h94 h95,\n      cases h95 with h96 h97,\n      cases h97 with h98 h99,\n     \nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  -- let S := $\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$\n  have h1 : ∀ m : ℤ, int.fract (α * ↑m) ∈ set.Icc 0 1, by {\n    assume m,\n    have h1_1 : 0 ≤ int.fract (α * ↑m), by linarith,\n    have h1_2 : int.fract (α * ↑m) ≤ 1, by linarith,\n    show int.fract (α * ↑m) ∈ set.Icc 0 1, from ⟨h1_1,h1_2⟩,\n  },\n  have h2 : ∀ m : ℤ, int.fract (α * ↑m) ∈ (λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ), by {\n    assume m,\n    have h2_1 : (m : ℤ) ∈ set.univ, from set.mem_univ m,\n    show int.fract (α * ↑m) ∈ (λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ), from ⟨m, h2_1⟩,\n  },\n  let S := (λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ),\n\n  -- then S is infinite set\n  have h3 : infinite S, from by {\n    have h3_1 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from \n      begin\n        assume i j,\n        assume h3_1_1,\n        have h3_1_2 : α = (int.fract (α * ↑i) - int.fract (α * ↑j)) * (i - j)⁻¹, from by {\n          rw ← int.fract_add_int,\n          rw ← mul_int_fract,\n          rw ← mul_int_fract,\n          ring,\n        },\n        have h3_1_3 : ((i - j) : ℤ) ≠ 0, from by {\n          assume h3_1_3_1,\n          have h3_1_3_2 := int.eq_iff_exists_int.mpr h3_1_3_1,\n          cases h3_1_3_2,\n          have h3_1_3_3 := int.cast_inj.mp h3_1_3_2_h,\n          rw h3_1_3_3 at h3_1_2,\n          have h3_1_3_4 : α ∈ ℚ, from by {\n            exact h3_1_2.symm,\n          },\n          have h3_1_3_5 : α ∉ ℚ, from by {\n            apply hα_irrat,\n          },\n          exact h3_1_3_5 h3_1_3_4,\n        },\n        have h3_1_4 : (i - j)⁻¹ ∈ ℚ, from by {\n          exact inv_in_rational (int.cast_ne_zero.mp h3_1_3),\n        },\n        have h3_1_5 : (i - j)⁻¹ ∉ ℚ, from by {\n          apply hα_irrat,\n        },\n        exact h3_1_5 h3_1_4,\n      end,\n    have h3_1_1 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from \n      begin\n        assume i j,\n        assume h3_1_1_1,\n        have h3_1_1_2 := h3_1 i j h3_1_1_1,\n        show int.fract (α * ↑i) ≠ int.fract (α * ↑j),\n        from h3_1_1_2,\n      end,\n    have h3_1_2 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ⁻¹ ≠ (int.fract (α * ↑j)) ⁻¹, from \n      begin\n        assume i j,\n        assume h3_1_2_1,\n        have h3_1_2_2 : int.fract (α * ↑i) ≠ int.fract (α * ↑j), from\n          by {exact h3_1_1_1 i j h3_1_2_1},\n        rw int.fract_eq_of_ne at h3_1_2_2,\n        show (int.fract (α * ↑i)) ⁻¹ ≠ (int.fract (α * ↑j)) ⁻¹,\n        from by {\n          exact inv_ne_of_ne_of_ne h3_1_2_2 h3_1_2_2,\n        },\n      end,\n    have h3_1_3 : ∀ (i j : ℤ), (int.fract (α * ↑i)) ⁻¹ ≠ (int.fract (α * ↑j)) ⁻¹ → i ≠ j, from \n      begin\n        assume i j,\n        assume h3_1_3_1,\n        have h3_1_3_2 : int.fract (α * ↑i) ≠ int.fract (α * ↑j), from\n          by {exact inv_ne_of_ne_of_ne h3_1_3_1 h3_1_3_1},\n        rw int.fract_eq_of_ne at h3_1_3_2,\n        show i ≠ j, from h3_1_1_1 i j h3_1_3_2,\n      end,\n    have h3_1_4 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ⁻¹ ≠ (int.fract (α * ↑j)) ⁻¹, from \n      begin\n        assume i j,\n        assume h3_1_4_1,\n        have h3_1_4_2 : int.fract (α * ↑i) ≠ int.fract (α * ↑j), from\n          by {exact h3_1_1_1 i j h3_1_4_1},\n        rw int.fract_eq_of_ne at h3_1_4_2,\n        show (int.fract (α * ↑i)) ⁻¹ ≠ (int.fract (α * ↑j)) ⁻¹, from\n          by {exact inv_ne_of_ne_of_ne h3_1_4_2 h3_1_4_2},\n      end,\n    have h3_1_5 : ∀ (i j : ℤ), (int.fract (α * ↑i)) ⁻¹ = (int.fract (α * ↑j)) ⁻¹ → i = j, from \n      begin\n        assume i j,\n        assume h3_1_5_1,\n        have h3_1_5_2 : int.fract (α * ↑i) = int.fract (α * ↑j), from\n          by {exact inv_inj h3_1_5_1},\n        show i = j, from int.fract_eq_of_eq h3_1_5_2,\n      end,\n    have h3_1_6 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ⁻¹ ≠ (int.fract (α * ↑j)) ⁻¹, from \n      begin\n        assume i j,\n        assume h3_1_6_1,\n        have h3_1_6_2 : int.fract (α * ↑i) ≠ int.fract (α * ↑j\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by rw add_mul\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n    assume a b : G, use a⁻¹ * b, obviously, },\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n    assume a b : G, use b * a⁻¹, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n    exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n    (mul_one a),\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n    exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n        exists_unique.unique (h3 a) (hident a).right\n        (classical.some_spec (exists_unique.exists (h3 a))), \n      have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n        exists_unique.unique (h4 a) (hident a).left\n        (classical.some_spec (exists_unique.exists (h4 a))),\n      show e = (1 : G), from eq.trans (h9 e) (h6 _),     \n    },\n    exact ⟨by obviously, h7⟩,\n  }\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n  from by \n  {\n    intro x0,\n    have h6 : |x0 - l| < ε ↔ ((x0 - l) < ε) ∧ ((l - x0) < ε), \n    from abs_sub_lt_iff, rw h6,\n    split, \n    rintro ⟨ S_1, S_2 ⟩, \n    split; linarith, \n    rintro ⟨ S_3, S_4 ⟩, \n    split; linarith,\n    },\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : ε > 0),\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that $\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n  cases h2 ε h7 with N1 h8,\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that $\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n  cases h3 ε h7 with N2 h9,\n  \n  --Let $N = \\max \\set {N_1, N_2}$.\n  let N := max N1 N2,\n  use N,\n\n  --Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n  have h10 : ∀ n > N, n > N1 ∧ n > N2 := by {\n    assume n h,\n    split,\n    exact lt_of_le_of_lt (le_max_left N1 N2) h, \n    exact lt_of_le_of_lt (le_max_right N1 N2) h,\n  },\n  \n  --$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n  --$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n  --$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n  --So $\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n  from by {\n    intros n h12,\n    split,\n    {\n\n      have h13 := (h8 n (h10 n h12).left), rw h5 (y n) at h13,\n      split,\n      exact h13.left,\n      exact (h4 n).left,\n    },\n    {        \n      have h14 := (h9 n (h10 n h12).right),rw h5 (z n) at h14,\n      split,\n      exact (h4 n).right,\n      exact h14.right,\n    },\n    \n  },\n\n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n  from by {\n    intros n1 h16, cases (h11 n1 h16);\n    split; linarith,\n  },\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  ∀ (n : ℕ), n > N → |x n - l| < ε, \n  from by {\n    intros n h17,\n    cases h5 (x n) with h18 h19,\n    apply h19, exact h15 n h17,\n  },\nend\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n\nTo show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n\nQED\n-/\ntheorem  irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_with_comments-Natural-Language-Proof-Translation/Correct_statement-lean_proof_with_comments-4_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.48600125547378215}}
{"text": "/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux, Jon Bannon\n-/\n\nimport algebra.star.star_alg_hom\nimport analysis.normed_space.star.basic\nimport analysis.normed_space.operator_norm\nimport analysis.special_functions.pow\nimport analysis.normed_space.star.mul\n\n/-!\n# Multiplier Algebra of a C⋆-algebra\n\nDefine the multiplier algebra of a C⋆-algebra as the algebra (over `𝕜`) of double centralizers,\nfor which we provide the localized notation `𝓜(𝕜, A)`.  A double centralizer is a pair of\ncontinuous linear maps `L R : A →L[𝕜] A` satisfying the intertwining condition `R x * y = x * L y`.\n\nThere is a natural embedding `A → 𝓜(𝕜, A)` which sends `a : A` to the continuous linear maps\n`L R : A →L[𝕜] A` given by left and right multiplication by `a`, and we provide this map as a\ncoercion.\n\nThe multiplier algebra corresponds to a non-commutative Stone–Čech compactification in the sense\nthat when the algebra `A` is commutative, it can be identified with `C₀(X, ℂ)` for some locally\ncompact Hausdorff space `X`, and in that case `𝓜(𝕜, A)` can be identified with `C(β X, ℂ)`.\n\n## Implementation notes\n\nWe make the hypotheses on `𝕜` as weak as possible so that, in particular, this construction works\nfor both `𝕜 = ℝ` and `𝕜 = ℂ`.\n\nThe reader familiar with C⋆-algebra theory may recognize that one\nonly needs `L` and `R` to be functions instead of continuous linear maps, at least when `A` is a\nC⋆-algebra. Our intention is simply to eventually provide a constructor for this situation.\n\nWe pull back the `normed_algebra` structure (and everything contained therein) through the\nring (even algebra) homomorphism\n`double_centralizer.to_prod_mul_opposite_hom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ` which\nsends `a : 𝓜(𝕜, A)` to `(a.fst, mul_opposite.op a.snd)`. The star structure is provided\nseparately.\n\n## References\n\n* https://en.wikipedia.org/wiki/Multiplier_algebra\n\n## TODO\n\n+ Define a type synonym for `𝓜(𝕜, A)` which is equipped with the strict uniform space structure\n  and show it is complete\n+ Show that the image of `A` in `𝓜(𝕜, A)` is an essential ideal\n+ Prove the universal property of `𝓜(𝕜, A)`\n+ Construct a double centralizer from a pair of maps (not necessarily linear or continuous)\n  `L : A → A`, `R : A → A` satisfying the centrality condition `∀ x y, R x * y = x * L y`.\n+ Show that if `A` is unital, then `A ≃⋆ₐ[𝕜] 𝓜(𝕜, A)`.\n-/\n\nopen_locale nnreal ennreal\nopen nnreal continuous_linear_map mul_opposite\n\nuniverses u v\n\n/-- The type of *double centralizers*, also known as the *multiplier algebra* and denoted by\n`𝓜(𝕜, A)`, of a non-unital normed algebra.\n\nIf `x : 𝓜(𝕜, A)`, then `x.fst` and `x.snd` are what is usually referred to as $L$ and $R$. -/\n@[ext]\nstructure double_centralizer (𝕜 : Type u) (A : Type v) [nontrivially_normed_field 𝕜]\n  [non_unital_normed_ring A] [normed_space 𝕜 A] [smul_comm_class 𝕜 A A] [is_scalar_tower 𝕜 A A]\n  extends (A →L[𝕜] A) × (A →L[𝕜] A) :=\n(central : ∀ x y : A, snd x * y = x * fst y)\n\nlocalized \"notation `𝓜(` 𝕜 `, ` A `)` := double_centralizer 𝕜 A\" in multiplier_algebra\n\nnamespace double_centralizer\n\nsection nontrivially_normed\n\nvariables (𝕜 A : Type*) [nontrivially_normed_field 𝕜] [non_unital_normed_ring A]\nvariables [normed_space 𝕜 A] [smul_comm_class 𝕜 A A] [is_scalar_tower 𝕜 A A]\n\n/-!\n### Algebraic structure\n\nBecause the multiplier algebra is defined as the algebra of double centralizers, there is a natural\ninjection `double_centralizer.to_prod_mul_opposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ`\ndefined by `λ a, (a.fst, mul_opposite.op a.snd)`. We use this map to pull back the ring, module and\nalgebra structure from `(A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ` to `𝓜(𝕜, A)`. -/\n\nvariables {𝕜 A}\n\n\n\ninstance : has_add 𝓜(𝕜, A) :=\n{ add := λ a b,\n  { to_prod := a.to_prod + b.to_prod,\n    central := λ x y, show (a.snd + b.snd) x * y = x * (a.fst + b.fst) y,\n      by simp only [continuous_linear_map.add_apply, mul_add, add_mul, central] } }\n\ninstance : has_zero 𝓜(𝕜, A) :=\n{ zero :=\n  { to_prod := 0,\n    central := λ x y, (zero_mul y).trans (mul_zero x).symm } }\n\ninstance : has_neg 𝓜(𝕜, A) :=\n{ neg := λ a,\n  { to_prod := -a.to_prod,\n    central := λ x y, show -a.snd x * y = x * -a.fst y,\n      by simp only [continuous_linear_map.neg_apply, neg_mul, mul_neg, central] } }\n\ninstance : has_sub 𝓜(𝕜, A) :=\n{ sub := λ a b,\n  { to_prod := a.to_prod - b.to_prod,\n    central := λ x y, show (a.snd - b.snd) x * y = x * (a.fst - b.fst) y,\n      by simp only [continuous_linear_map.sub_apply, sub_mul, mul_sub, central] } }\n\nsection scalars\n\nvariables {S : Type*} [monoid S] [distrib_mul_action S A] [smul_comm_class 𝕜 S A]\n  [has_continuous_const_smul S A] [is_scalar_tower S A A] [smul_comm_class S A A]\n\ninstance : has_smul S 𝓜(𝕜, A) :=\n{ smul := λ s a,\n  { to_prod := s • a.to_prod,\n    central := λ x y, show (s • a.snd) x * y = x * (s • a.fst) y,\n      by simp only [continuous_linear_map.smul_apply, mul_smul_comm, smul_mul_assoc, central] } }\n\n@[simp] lemma smul_to_prod (s : S) (a : 𝓜(𝕜, A)) : (s • a).to_prod = s • a.to_prod := rfl\nlemma smul_fst (s : S) (a : 𝓜(𝕜, A)) : (s • a).fst = s • a.fst := rfl\nlemma smul_snd (s : S) (a : 𝓜(𝕜, A)) : (s • a).snd = s • a.snd := rfl\n\nvariables {T : Type*} [monoid T] [distrib_mul_action T A] [smul_comm_class 𝕜 T A]\n  [has_continuous_const_smul T A] [is_scalar_tower T A A] [smul_comm_class T A A]\n\ninstance [has_smul S T] [is_scalar_tower S T A] : is_scalar_tower S T 𝓜(𝕜, A) :=\n{ smul_assoc := λ _ _ a, ext _ _ $ smul_assoc _ _ a.to_prod }\n\ninstance [smul_comm_class S T A] : smul_comm_class S T 𝓜(𝕜, A) :=\n{ smul_comm := λ _ _ a, ext _ _ $ smul_comm _ _ a.to_prod }\n\ninstance {R : Type*} [semiring R] [module R A] [smul_comm_class 𝕜 R A]\n  [has_continuous_const_smul R A] [is_scalar_tower R A A] [smul_comm_class R A A]\n  [module Rᵐᵒᵖ A] [is_central_scalar R A] : is_central_scalar R 𝓜(𝕜, A) :=\n{ op_smul_eq_smul := λ _ a, ext _ _ $ op_smul_eq_smul _ a.to_prod }\n\nend scalars\n\ninstance : has_one 𝓜(𝕜, A) := ⟨⟨1, λ x y, rfl⟩⟩\n\ninstance : has_mul 𝓜(𝕜, A) :=\n{ mul := λ a b,\n  { to_prod := (a.fst.comp b.fst, b.snd.comp a.snd),\n    central := λ x y, show b.snd (a.snd x) * y = x * a.fst (b.fst y),\n      by simp only [central] } }\n\ninstance : has_nat_cast 𝓜(𝕜, A) :=\n{ nat_cast := λ n, ⟨n, λ x y,\n  begin\n    rw [prod.snd_nat_cast, prod.fst_nat_cast],\n    simp only [←nat.smul_one_eq_coe, smul_apply, one_apply, mul_smul_comm, smul_mul_assoc],\n  end⟩ }\n\ninstance : has_int_cast 𝓜(𝕜, A) :=\n{ int_cast := λ n, ⟨n, λ x y,\n  begin\n    rw [prod.snd_int_cast, prod.fst_int_cast],\n    simp only [←int.smul_one_eq_coe, smul_apply, one_apply, mul_smul_comm, smul_mul_assoc],\n  end⟩ }\n\ninstance : has_pow 𝓜(𝕜, A) ℕ :=\n{ pow := λ a n, ⟨a.to_prod ^ n, λ x y,\n  begin\n    induction n with k hk generalizing x y,\n    { refl },\n    { rw [prod.pow_snd, prod.pow_fst] at hk ⊢,\n      rw [pow_succ a.snd, mul_apply, a.central, hk, pow_succ' a.fst, mul_apply] },\n  end⟩ }\n\ninstance : inhabited 𝓜(𝕜, A) := ⟨0⟩\n\n@[simp] lemma add_to_prod (a b : 𝓜(𝕜, A)) : (a + b).to_prod = a.to_prod + b.to_prod := rfl\n@[simp] lemma zero_to_prod : (0 : 𝓜(𝕜, A)).to_prod = 0 := rfl\n@[simp] lemma neg_to_prod (a : 𝓜(𝕜, A)) : (-a).to_prod = -a.to_prod := rfl\n@[simp] lemma sub_to_prod (a b : 𝓜(𝕜, A)) : (a - b).to_prod = a.to_prod - b.to_prod := rfl\n@[simp] lemma one_to_prod : (1 : 𝓜(𝕜, A)).to_prod = 1 := rfl\n@[simp] lemma nat_cast_to_prod (n : ℕ) : (n : 𝓜(𝕜 , A)).to_prod = n := rfl\n@[simp] lemma int_cast_to_prod (n : ℤ) : (n : 𝓜(𝕜 , A)).to_prod = n := rfl\n@[simp] lemma pow_to_prod (n : ℕ) (a : 𝓜(𝕜, A)) : (a ^ n).to_prod = a.to_prod ^ n := rfl\n\nlemma add_fst (a b : 𝓜(𝕜, A)) : (a + b).fst = a.fst + b.fst := rfl\nlemma add_snd (a b : 𝓜(𝕜, A)) : (a + b).snd = a.snd + b.snd := rfl\nlemma zero_fst : (0 : 𝓜(𝕜, A)).fst = 0 := rfl\nlemma zero_snd : (0 : 𝓜(𝕜, A)).snd = 0 := rfl\nlemma neg_fst (a : 𝓜(𝕜, A)) : (-a).fst = -a.fst := rfl\nlemma neg_snd (a : 𝓜(𝕜, A)) : (-a).snd = -a.snd := rfl\nlemma sub_fst (a b : 𝓜(𝕜, A)) : (a - b).fst = a.fst - b.fst := rfl\nlemma sub_snd (a b : 𝓜(𝕜, A)) : (a - b).snd = a.snd - b.snd := rfl\nlemma one_fst : (1 : 𝓜(𝕜, A)).fst = 1 := rfl\nlemma one_snd : (1 : 𝓜(𝕜, A)).snd = 1 := rfl\n@[simp] lemma mul_fst (a b : 𝓜(𝕜, A)) : (a * b).fst = a.fst * b.fst := rfl\n@[simp] lemma mul_snd (a b : 𝓜(𝕜, A)) : (a * b).snd = b.snd * a.snd := rfl\nlemma nat_cast_fst (n : ℕ) : (n : 𝓜(𝕜 , A)).fst = n := rfl\nlemma nat_cast_snd (n : ℕ) : (n : 𝓜(𝕜 , A)).snd = n := rfl\nlemma int_cast_fst (n : ℤ) : (n : 𝓜(𝕜 , A)).fst = n := rfl\nlemma int_cast_snd (n : ℤ) : (n : 𝓜(𝕜 , A)).snd = n := rfl\nlemma pow_fst (n : ℕ) (a : 𝓜(𝕜, A)) : (a ^ n).fst = a.fst ^ n := rfl\nlemma pow_snd (n : ℕ) (a : 𝓜(𝕜, A)) : (a ^ n).snd = a.snd ^ n := rfl\n\n/-- The natural injection from `double_centralizer.to_prod` except the second coordinate inherits\n`mul_opposite.op`. The ring structure on `𝓜(𝕜, A)` is the pullback under this map. -/\ndef to_prod_mul_opposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ :=\nλ a, (a.fst, mul_opposite.op a.snd)\n\nlemma to_prod_mul_opposite_injective :\n  function.injective (to_prod_mul_opposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ) :=\nλ a b h, let h' := prod.ext_iff.mp h in ext _ _ $ prod.ext h'.1 $ mul_opposite.op_injective h'.2\n\nlemma range_to_prod_mul_opposite :\n  set.range to_prod_mul_opposite = {lr : (A →L[𝕜] A) × _ | ∀ x y, unop lr.2 x * y = x * lr.1 y} :=\nset.ext $ λ x,\n  ⟨by {rintro ⟨a, rfl⟩, exact a.central}, λ hx, ⟨⟨(x.1, unop x.2), hx⟩, prod.ext rfl rfl⟩⟩\n\n/-- The ring structure is inherited as the pullback under the injective map\n`double_centralizer.to_prod_mul_opposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ` -/\ninstance : ring 𝓜(𝕜, A) :=\nto_prod_mul_opposite_injective.ring _\n  rfl rfl (λ _ _, rfl) (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl)\n  (λ x n, prod.ext rfl $ mul_opposite.op_smul _ _)\n  (λ x n, prod.ext rfl $ mul_opposite.op_smul _ _)\n  (λ x n, prod.ext rfl $ mul_opposite.op_pow _ _)\n  (λ _, rfl) (λ _, rfl)\n\n/-- The canonical map `double_centralizer.to_prod` as an additive group homomorphism. -/\n@[simps]\ndef to_prod_hom : 𝓜(𝕜, A) →+ (A →L[𝕜] A) × (A →L[𝕜] A) :=\n{ to_fun := to_prod,\n  map_zero' := rfl,\n  map_add' := λ x y, rfl }\n\n/-- The canonical map `double_centralizer.to_prod_mul_opposite` as a ring homomorphism. -/\n@[simps]\ndef to_prod_mul_opposite_hom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ :=\n{ to_fun := to_prod_mul_opposite,\n  map_zero' := rfl,\n  map_one' := rfl,\n  map_add' := λ x y, rfl,\n  map_mul' := λ x y, rfl }\n\n/-- The module structure is inherited as the pullback under the additive group monomorphism\n`double_centralizer.to_prod : 𝓜(𝕜, A) →+ (A →L[𝕜] A) × (A →L[𝕜] A)` -/\ninstance {S : Type*} [semiring S] [module S A] [smul_comm_class 𝕜 S A]\n  [has_continuous_const_smul S A] [is_scalar_tower S A A] [smul_comm_class S A A] :\n  module S 𝓜(𝕜, A) :=\nfunction.injective.module S to_prod_hom ext (λ x y, rfl)\n\n-- TODO: generalize to `algebra S 𝓜(𝕜, A)` once `continuous_linear_map.algebra` is generalized.\ninstance : algebra 𝕜 𝓜(𝕜, A) :=\n{ to_fun := λ k,\n  { to_prod := algebra_map 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A)) k,\n    central := λ x y, by simp_rw [prod.algebra_map_apply, algebra.algebra_map_eq_smul_one,\n      smul_apply, one_apply, mul_smul_comm, smul_mul_assoc] },\n  map_one' := ext _ _ $ map_one $ algebra_map 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A)),\n  map_mul' := λ k₁ k₂, ext _ _ $ prod.ext (map_mul (algebra_map 𝕜 (A →L[𝕜] A)) _ _)\n    ((map_mul (algebra_map 𝕜 (A →L[𝕜] A)) _ _).trans (algebra.commutes _ _)),\n  map_zero' := ext _ _ $ map_zero $ algebra_map 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A)),\n  map_add' := λ _ _, ext _ _ $ map_add (algebra_map 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A))) _ _,\n  commutes' := λ _ _, ext _ _ $ prod.ext (algebra.commutes _ _) (algebra.commutes _ _).symm,\n  smul_def' := λ _ _, ext _ _ $ prod.ext (algebra.smul_def _ _)\n    ((algebra.smul_def _ _).trans $ algebra.commutes _ _) }\n\n@[simp] lemma algebra_map_to_prod (k : 𝕜) :\n  (algebra_map 𝕜 𝓜(𝕜, A) k).to_prod = algebra_map 𝕜 _ k := rfl\nlemma algebra_map_fst (k : 𝕜) : (algebra_map 𝕜 𝓜(𝕜, A) k).fst = algebra_map 𝕜 _ k := rfl\nlemma algebra_map_snd (k : 𝕜) : (algebra_map 𝕜 𝓜(𝕜, A) k).snd = algebra_map 𝕜 _ k := rfl\n\n/-!\n### Star structure\n-/\n\nsection star\n\nvariables [star_ring 𝕜] [star_ring A] [star_module 𝕜 A] [normed_star_group A]\n\n/-- The star operation on `a : 𝓜(𝕜, A)` is given by\n`(star a).to_prod = (star ∘ a.snd ∘ star, star ∘ a.fst ∘ star)`. -/\ninstance : has_star 𝓜(𝕜, A) :=\n{ star := λ a,\n  { fst := (((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A).comp a.snd).comp\n      ((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A),\n    snd := (((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A).comp a.fst).comp\n      ((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A),\n    central := λ x y, by simpa only [star_mul, star_star]\n      using (congr_arg star (a.central (star y) (star x))).symm } }\n\n@[simp] lemma star_fst (a : 𝓜(𝕜, A)) (b : A) : (star a).fst b = star (a.snd (star b)) := rfl\n@[simp] lemma star_snd (a : 𝓜(𝕜, A)) (b : A) : (star a).snd b = star (a.fst (star b)) := rfl\n\ninstance : star_add_monoid 𝓜(𝕜, A) :=\n{ star_involutive := λ x, by {ext; simp only [star_fst, star_snd, star_star]},\n  star_add := λ x y, by {ext; simp only [star_fst, star_snd, add_fst, add_snd,\n    continuous_linear_map.add_apply, star_add]},\n  .. double_centralizer.has_star }\n\ninstance : star_ring 𝓜(𝕜, A) :=\n{ star_mul := λ a b, by {ext; simp only [star_fst, star_snd, mul_fst, mul_snd, star_star,\n    continuous_linear_map.coe_mul, function.comp_app]},\n  .. double_centralizer.star_add_monoid }\n\ninstance : star_module 𝕜 𝓜(𝕜, A) :=\n{ star_smul := λ k a, by {ext; exact star_smul _ _},\n  .. double_centralizer.star_add_monoid }\n\nend star\n\n/-!\n### Coercion from an algebra into its multiplier algebra\n-/\n\n/-- The natural coercion of `A` into `𝓜(𝕜, A)` given by sending `a : A` to the pair of linear\nmaps `Lₐ Rₐ : A →L[𝕜] A` given by left- and right-multiplication by `a`, respectively.\n\nWarning: if `A = 𝕜`, then this is a coercion which is not definitionally equal to the\n`algebra_map 𝕜 𝓜(𝕜, 𝕜)` coercion, but these are propositionally equal. See\n`double_centralizer.coe_eq_algebra_map` below. -/\nnoncomputable instance : has_coe_t A 𝓜(𝕜, A) :=\n{ coe := λ a,\n  { fst := continuous_linear_map.mul 𝕜 A a,\n    snd := (continuous_linear_map.mul 𝕜 A).flip a,\n    central := λ x y, mul_assoc _ _ _ } }\n\n@[simp, norm_cast]\nlemma coe_fst (a : A) : (a : 𝓜(𝕜, A)).fst = continuous_linear_map.mul 𝕜 A a := rfl\n@[simp, norm_cast]\nlemma coe_snd (a : A) : (a : 𝓜(𝕜, A)).snd = (continuous_linear_map.mul 𝕜 A).flip a := rfl\n\nlemma coe_eq_algebra_map : (coe : 𝕜 → 𝓜(𝕜, 𝕜)) = algebra_map 𝕜 𝓜(𝕜, 𝕜) :=\nbegin\n  ext;\n  simp only [coe_fst, mul_apply', mul_one, algebra_map_to_prod, prod.algebra_map_apply, coe_snd,\n    flip_apply, one_mul];\n  simp only [algebra.algebra_map_eq_smul_one, smul_apply, one_apply, smul_eq_mul, mul_one],\nend\n\n/-- The coercion of an algebra into its multiplier algebra as a non-unital star algebra\nhomomorphism. -/\n@[simps]\nnoncomputable def coe_hom [star_ring 𝕜] [star_ring A] [star_module 𝕜 A] [normed_star_group A] :\n  A →⋆ₙₐ[𝕜] 𝓜(𝕜, A) :=\n{ to_fun := λ a, a,\n  map_smul' := λ k a, by ext; simp only [coe_fst, coe_snd, continuous_linear_map.map_smul,\n    smul_fst, smul_snd],\n  map_zero' := by ext; simp only [coe_fst, coe_snd, map_zero, zero_fst, zero_snd],\n  map_add' := λ a b, by ext; simp only [coe_fst, coe_snd, map_add, add_fst, add_snd],\n  map_mul' := λ a b, by ext; simp only [coe_fst, coe_snd, mul_apply', flip_apply, mul_fst, mul_snd,\n    continuous_linear_map.coe_mul, function.comp_app, mul_assoc],\n  map_star' := λ a, by ext; simp only [coe_fst, coe_snd, mul_apply', star_fst, star_snd,\n    flip_apply, star_mul, star_star] }\n\n/-!\n### Norm structures\nWe define the norm structure on `𝓜(𝕜, A)` as the pullback under\n`double_centralizer.to_prod_mul_opposite_hom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ`, which\nprovides a definitional isometric embedding. Consequently, completeness of `𝓜(𝕜, A)` is obtained\nby proving that the range of this map is closed.\n\nIn addition, we prove that `𝓜(𝕜, A)` is a normed algebra, and, when `A` is a C⋆-algebra, we show\nthat `𝓜(𝕜, A)` is also a C⋆-algebra. Moreover, in this case, for `a : 𝓜(𝕜, A)`,\n`‖a‖ = ‖a.fst‖ = ‖a.snd‖`. -/\n\n/-- The normed group structure is inherited as the pullback under the ring monomoprhism\n`double_centralizer.to_prod_mul_opposite_hom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ`. -/\nnoncomputable instance : normed_ring 𝓜(𝕜, A) :=\nnormed_ring.induced _ _ (to_prod_mul_opposite_hom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ)\n  to_prod_mul_opposite_injective\n\n-- even though the definition is actually in terms of `double_centralizer.to_prod_mul_opposite`, we\n-- choose to see through that here to avoid `mul_opposite.op` appearing.\nlemma norm_def (a : 𝓜(𝕜, A)) : ‖a‖ = ‖a.to_prod_hom‖ := rfl\nlemma nnnorm_def (a : 𝓜(𝕜, A)) : ‖a‖₊ = ‖a.to_prod_hom‖₊ := rfl\n\nlemma norm_def' (a : 𝓜(𝕜, A)) : ‖a‖ = ‖a.to_prod_mul_opposite_hom‖ := rfl\nlemma nnnorm_def' (a : 𝓜(𝕜, A)) : ‖a‖₊ = ‖a.to_prod_mul_opposite_hom‖₊ := rfl\n\ninstance : normed_space 𝕜 𝓜(𝕜, A) :=\n{ norm_smul_le := λ k a, norm_smul_le k a.to_prod_mul_opposite,\n  .. double_centralizer.module }\n\ninstance : normed_algebra 𝕜 𝓜(𝕜, A) :=\n{ ..double_centralizer.algebra, ..double_centralizer.normed_space }\n\nlemma uniform_embedding_to_prod_mul_opposite :\n  uniform_embedding (@to_prod_mul_opposite 𝕜 A _ _ _ _ _) :=\nuniform_embedding_comap to_prod_mul_opposite_injective\n\ninstance [complete_space A] : complete_space 𝓜(𝕜, A) :=\nbegin\n  rw complete_space_iff_is_complete_range\n    uniform_embedding_to_prod_mul_opposite.to_uniform_inducing,\n  apply is_closed.is_complete,\n  simp only [range_to_prod_mul_opposite, set.set_of_forall],\n  refine is_closed_Inter (λ x, is_closed_Inter $ λ y, is_closed_eq _ _),\n  exact ((continuous_linear_map.apply 𝕜 A _).continuous.comp $\n    continuous_unop.comp continuous_snd).mul continuous_const,\n  exact continuous_const.mul ((continuous_linear_map.apply 𝕜 A _).continuous.comp continuous_fst),\nend\n\nvariables [star_ring A] [cstar_ring A]\n\n/-- For `a : 𝓜(𝕜, A)`, the norms of `a.fst` and `a.snd` coincide, and hence these\nalso coincide with `‖a‖` which is `max (‖a.fst‖) (‖a.snd‖)`. -/\nlemma norm_fst_eq_snd (a : 𝓜(𝕜, A)) : ‖a.fst‖ = ‖a.snd‖ :=\nbegin\n  -- a handy lemma for this proof\n  have h0 : ∀ f : A →L[𝕜] A, ∀ C : ℝ≥0, (∀ b : A, ‖f b‖₊ ^ 2 ≤ C * ‖f b‖₊ * ‖b‖₊) → ‖f‖₊ ≤ C,\n  { intros f C h,\n    have h1 : ∀ b, C * ‖f b‖₊ * ‖b‖₊ ≤ C * ‖f‖₊ * ‖b‖₊ ^ 2,\n    { intros b,\n      convert mul_le_mul_right' (mul_le_mul_left' (f.le_op_nnnorm b) C) (‖b‖₊) using 1,\n      ring, },\n    have := div_le_of_le_mul (f.op_nnnorm_le_bound _ (by simpa only [sqrt_sq, sqrt_mul]\n      using (λ b, sqrt_le_sqrt_iff.mpr ((h b).trans (h1 b))))),\n    convert rpow_le_rpow this two_pos.le,\n    { simp only [rpow_two, div_pow, sq_sqrt], simp only [sq, mul_self_div_self] },\n    { simp only [rpow_two, sq_sqrt] } },\n  have h1 : ∀ b, ‖a.fst b‖₊ ^ 2 ≤ ‖a.snd‖₊ * ‖a.fst b‖₊ * ‖b‖₊,\n  { intros b,\n    calc ‖a.fst b‖₊ ^ 2\n        = ‖star (a.fst b) * (a.fst b)‖₊\n        : by simpa only [←sq] using (cstar_ring.nnnorm_star_mul_self).symm\n    ... ≤ ‖a.snd (star (a.fst b))‖₊ * ‖b‖₊ : a.central (star (a.fst b)) b ▸ nnnorm_mul_le _ _\n    ... ≤ ‖a.snd‖₊ * ‖a.fst b‖₊ * ‖b‖₊\n        : nnnorm_star (a.fst b) ▸ mul_le_mul_right' (a.snd.le_op_nnnorm _) _},\n  have h2 : ∀ b, ‖a.snd b‖₊ ^ 2 ≤ ‖a.fst‖₊ * ‖a.snd b‖₊ * ‖b‖₊,\n  { intros b,\n    calc ‖a.snd b‖₊ ^ 2\n        = ‖a.snd b * star (a.snd b)‖₊\n        : by simpa only [←sq] using (cstar_ring.nnnorm_self_mul_star).symm\n    ... ≤ ‖b‖₊ * ‖a.fst (star (a.snd b))‖₊\n        : (a.central b (star (a.snd b))).symm ▸ nnnorm_mul_le _ _\n    ... = ‖a.fst (star (a.snd b))‖₊ * ‖b‖₊ : mul_comm _ _\n    ... ≤ ‖a.fst‖₊ * ‖a.snd b‖₊ * ‖b‖₊\n        : nnnorm_star (a.snd b) ▸ mul_le_mul_right' (a.fst.le_op_nnnorm _) _  },\n  exact le_antisymm (h0 _ _ h1) (h0 _ _ h2),\nend\n\nlemma nnnorm_fst_eq_snd (a : 𝓜(𝕜, A)) : ‖a.fst‖₊ = ‖a.snd‖₊ := subtype.ext $ norm_fst_eq_snd a\n@[simp] lemma norm_fst (a : 𝓜(𝕜, A)) : ‖a.fst‖ = ‖a‖ :=\n  by simp only [norm_def, to_prod_hom_apply, prod.norm_def, norm_fst_eq_snd, max_eq_right,\n    eq_self_iff_true]\n@[simp] lemma norm_snd (a : 𝓜(𝕜, A)) : ‖a.snd‖ = ‖a‖ := by rw [←norm_fst, norm_fst_eq_snd]\n@[simp] lemma nnnorm_fst (a : 𝓜(𝕜, A)) : ‖a.fst‖₊ = ‖a‖₊ := subtype.ext (norm_fst a)\n@[simp] lemma nnnorm_snd (a : 𝓜(𝕜, A)) : ‖a.snd‖₊ = ‖a‖₊ := subtype.ext (norm_snd a)\n\nend nontrivially_normed\n\nsection densely_normed\n\nvariables {𝕜 A : Type*} [densely_normed_field 𝕜] [star_ring 𝕜]\nvariables [non_unital_normed_ring A] [star_ring A] [cstar_ring A]\nvariables [normed_space 𝕜 A] [smul_comm_class 𝕜 A A] [is_scalar_tower 𝕜 A A] [star_module 𝕜 A]\n\ninstance : cstar_ring 𝓜(𝕜, A) :=\n{ norm_star_mul_self := λ a, congr_arg (coe : ℝ≥0 → ℝ) $ show ‖star a * a‖₊ = ‖a‖₊ * ‖a‖₊, from\n  begin\n    /- The essence of the argument is this: let `a = (L,R)` and recall `‖a‖ = ‖L‖`.\n    `star a = (star ∘ R ∘ star, star ∘ L ∘ star)`. Then for any `x y : A`, we have\n    `‖star a * a‖ = ‖(star a * a).snd‖ = ‖R (star (L (star x))) * y‖ = ‖star (L (star x)) * L y‖`\n    Now, on the one hand,\n    `‖star (L (star x)) * L y‖ ≤ ‖star (L (star x))‖ * ‖L y‖ = ‖L (star x)‖ * ‖L y‖ ≤ ‖L‖ ^ 2`\n    whenever `‖x‖, ‖y‖ ≤ 1`, so the supremum over all such `x, y` is at most `‖L‖ ^ 2`.\n    On the other hand, for any `‖z‖ ≤ 1`, we may choose `x := star z` and `y := z` to get:\n    `‖star (L (star x)) * L y‖ = ‖star (L z) * (L z)‖ = ‖L z‖ ^ 2`, and taking the supremum over\n    all such `z` yields that the supremum is at least `‖L‖ ^ 2`. It is the latter part of the\n    argument where `densely_normed_field 𝕜` is required (for `Sup_closed_unit_ball_eq_nnnorm`). -/\n    have hball : (metric.closed_ball (0 : A) 1).nonempty :=\n      metric.nonempty_closed_ball.2 (zero_le_one),\n    have key : ∀ x y, ‖x‖₊ ≤ 1 → ‖y‖₊ ≤ 1 → ‖a.snd (star (a.fst (star x))) * y‖₊ ≤ ‖a‖₊ * ‖a‖₊,\n    { intros x y hx hy,\n      rw [a.central],\n      calc ‖star (a.fst (star x)) * a.fst y‖₊ ≤ ‖a.fst (star x)‖₊ * ‖a.fst y‖₊\n          : nnnorm_star (a.fst (star x)) ▸ nnnorm_mul_le _ _\n      ... ≤ (‖a.fst‖₊ * 1) * (‖a.fst‖₊ * 1)\n          : mul_le_mul' (a.fst.le_op_norm_of_le ((nnnorm_star x).trans_le hx))\n              (a.fst.le_op_norm_of_le hy)\n      ... ≤ ‖a‖₊ * ‖a‖₊ : by simp only [mul_one, nnnorm_fst] },\n    rw ←nnnorm_snd,\n    simp only [mul_snd, ←Sup_closed_unit_ball_eq_nnnorm, star_snd, mul_apply],\n    simp only [←@op_nnnorm_mul 𝕜 A],\n    simp only [←Sup_closed_unit_ball_eq_nnnorm, mul_apply'],\n    refine cSup_eq_of_forall_le_of_forall_lt_exists_gt (hball.image _) _ (λ r hr, _),\n    { rintro - ⟨x, hx, rfl⟩,\n      refine cSup_le (hball.image _) _,\n      rintro - ⟨y, hy, rfl⟩,\n      exact key x y (mem_closed_ball_zero_iff.1 hx) (mem_closed_ball_zero_iff.1 hy) },\n    { simp only [set.mem_image, set.mem_set_of_eq, exists_prop, exists_exists_and_eq_and],\n      have hr' : r.sqrt < ‖a‖₊ := (‖a‖₊).sqrt_mul_self ▸ nnreal.sqrt_lt_sqrt_iff.2 hr,\n      simp_rw [←nnnorm_fst, ←Sup_closed_unit_ball_eq_nnnorm] at hr',\n      obtain ⟨_, ⟨x, hx, rfl⟩, hxr⟩ := exists_lt_of_lt_cSup (hball.image _) hr',\n      have hx' : ‖x‖₊ ≤ 1 := mem_closed_ball_zero_iff.1 hx,\n      refine ⟨star x, mem_closed_ball_zero_iff.2 ((nnnorm_star x).trans_le hx'), _⟩,\n      refine lt_cSup_of_lt _ ⟨x, hx, rfl⟩ _,\n      { refine ⟨‖a‖₊ * ‖a‖₊, _⟩,\n        rintros - ⟨y, hy, rfl⟩,\n        exact key (star x) y ((nnnorm_star x).trans_le hx') (mem_closed_ball_zero_iff.1 hy) },\n      { simpa only [a.central, star_star, cstar_ring.nnnorm_star_mul_self, nnreal.sq_sqrt, ←sq]\n          using pow_lt_pow_of_lt_left hxr zero_le' two_pos } }\n  end }\n\nend densely_normed\n\nend double_centralizer\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/analysis/normed_space/star/multiplier.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.48593359052279467}}
{"text": "import cautomaton utils data.vector\nopen utils\n\nnamespace ww\n\nsection ww\n\ninductive cellT | empty | ehead | etail | condu\n\nopen cellT\n\ndef cellT_str : cellT → string \n    | empty := \" \"\n    | ehead := \"H\"\n    | etail := \"T\"\n    | condu := \"X\"\n\ninstance cellT_to_str : has_to_string cellT := ⟨cellT_str⟩\n\ninstance cellT_repr : has_repr cellT := ⟨cellT_str⟩\n\ninstance cellT_deceq : decidable_eq cellT :=\n    λl r,\n        begin\n            cases l; cases r; try {exact is_true rfl}; apply is_false; trivial\n        end\n\nattribute [reducible]\ndef ww := cautomaton cellT\n\ndef step : cellT → ℕ → cellT\n  | empty _ := empty\n  | ehead _ := etail\n  | etail _ := condu\n  | condu c := if c = 1 ∨ c = 2 then ehead else condu\n\ndef ww_step (cell : cellT) (neigh : list cellT) :=\n      step cell $ count_at_single neigh ehead\n\ndef mk_ww (g : vec_grid₀ cellT) : ww :=\n    ⟨g, empty, cautomatons.moore,\n     sum.inr $ @bound_const (vec_grid₀ cellT) _, ww_step⟩\n\ndef wire_g :=\n  vec_grid₀.mk ⟨1, 5, dec_trivial,\n               ⟨[etail, ehead, condu, condu, condu], rfl⟩⟩\n               ⟨0, 1⟩ \n\ndef wire : ww := mk_ww wire_g\n\ndef or_g_10 :=\n    vec_grid₀.mk ⟨5, 6, dec_trivial,\n                        ⟨[etail, ehead, empty, empty, empty, empty,\n                          empty, empty, condu, empty, empty, empty,\n                          empty, condu, condu, condu, condu, condu,\n                          empty, empty, condu, empty, empty, empty,\n                          condu, condu, empty, empty, empty, empty], rfl⟩⟩\n                        ⟨0, 1⟩\n\ndef or_10 : ww := mk_ww or_g_10\n\ndef or_g_01 :=\n    vec_grid₀.mk ⟨5, 6, dec_trivial,\n                        ⟨[condu, condu, empty, empty, empty, empty,\n                          empty, empty, condu, empty, empty, empty,\n                          empty, condu, condu, condu, condu, condu,\n                          empty, empty, condu, empty, empty, empty,\n                          etail, ehead, empty, empty, empty, empty], rfl⟩⟩\n                        ⟨0, 1⟩\n\ndef or_01 : ww := mk_ww or_g_01\n\nopen cardinals\n\nsection ww_or\n\ndef or_gate' :=\n    vec_grid₀.mk ⟨5, 6, dec_trivial,\n                        ⟨[condu, condu, empty, empty, empty, empty,\n                          empty, empty, condu, empty, empty, empty,\n                          empty, condu, condu, condu, condu, condu,\n                          empty, empty, condu, empty, empty, empty,\n                          etail, ehead, empty, empty, empty, empty], rfl⟩⟩\n                        ⟨-5, -5⟩\n\ndef or_gate : ww := mk_ww or_gate'\n\ndef write_input (i₁ : bool) (i₂ : bool) :=\n    let (b₁, b₂) := if i₁ then (etail, ehead) else (condu, condu) in\n    let (b₃, b₄) := if i₂ then (etail, ehead) else (condu, condu) in\n    mod_many\n        [(⟨-5, -10⟩, b₁), (⟨-4, -10⟩, b₂), (⟨-5, -6⟩, b₃), (⟨-4, -6⟩, b₄)]\n        or_gate\n\ndef sim_or (i₁ i₂ : bool) : bool :=\n    let sim := step_n (write_input i₁ i₂) 3 in\n        yield_at sim ⟨-8, -2⟩ = etail ∧ yield_at sim ⟨-8, -1⟩ = ehead\n\nend ww_or\n\nsection ww_xor\n\ninductive direction | N | W | E | S\n\nopen direction\n\nstructure inout :=\n    (p₁ : point)\n    (p₂ : point)\n    (dir : direction)\n\nstructure ww₁ :=\n    (aut : ww)\n    (ins : list inout)\n    (ous : list inout)\n\ndef str_of_ww₁ : ww₁ → string\n  | ⟨aut, _, _⟩ := to_string aut\n\ninstance ww₁_to_str : has_to_string ww₁ := ⟨str_of_ww₁⟩\n\ninstance ww₁_repr : has_repr ww₁ := ⟨str_of_ww₁⟩\n\ndef mk_ww₁ (g : vec_grid₀ cellT) (inputs outputs : list inout) : ww₁ :=\n    ⟨mk_ww g, inputs, outputs⟩\n\ndef write (a : ww₁) (n : ℕ) (b : bool) : ww₁ :=\n    let input := list.nth a.ins n in\n    match input with\n        | none := a\n        | some ⟨p₁, p₂, dir⟩ :=\n          if b then\n          match dir with\n            | N :=\n                ww₁.mk (mod_many [(up p₁ p₂, ehead), (down p₁ p₂, etail)] a.aut)\n                        a.ins a.ous\n            | S :=\n                ww₁.mk (mod_many [(down p₁ p₂, ehead), (up p₁ p₂, etail)] a.aut)\n                              a.ins a.ous\n            | W :=\n              ww₁.mk (mod_many [(left p₁ p₂, ehead), (right p₁ p₂, etail)] a.aut)\n                              a.ins a.ous\n            | E :=\n                ww₁.mk (mod_many [(right p₁ p₂, ehead), (left p₁ p₂, etail)] a.aut)\n                              a.ins a.ous\n          end\n          else ww₁.mk (mod_many [(p₁, condu), (p₂, condu)] a.aut) a.ins a.ous\n    end\n\ndef read (a : ww₁) (n : ℕ) : bool :=\n    let output := list.nth a.ous n in\n    match output with\n      | none := ff\n      | some ⟨p₁, p₂, dir⟩ :=\n      match dir with\n        | N := yield_at a.aut (up p₁ p₂) = ehead ∧\n                      yield_at a.aut (down p₁ p₂) = etail\n        | S := yield_at a.aut (up p₁ p₂) = etail ∧\n                      yield_at a.aut (down p₁ p₂) = ehead\n        | W := yield_at a.aut (left p₁ p₂) = ehead ∧\n                      yield_at a.aut (right p₁ p₂) = etail\n        | E := yield_at a.aut (left p₁ p₂) = etail ∧\n                      yield_at a.aut (right p₁ p₂) = ehead\n      end\n    end\n\ndef xor_gate' :=\n    vec_grid₀.mk ⟨7, 7, dec_trivial,\n      ⟨[condu, condu, empty, empty, empty, empty, empty, \n        empty, empty, condu, empty, empty, empty, empty, \n        empty, condu, condu, condu, condu, empty, empty,\n        empty, condu, empty, empty, condu, condu, condu,\n        empty, condu, condu, condu, condu, empty, empty,\n        empty, empty, condu, empty, empty, empty, empty,\n        condu, condu, empty, empty, empty, empty, empty], rfl⟩⟩\n      ⟨0, 0⟩\n\ndef xor_gate_inputs : list inout := [⟨⟨0, 6⟩, ⟨1, 6⟩, E⟩, ⟨⟨0, 0⟩, ⟨1, 0⟩, E⟩]\n\ndef xor_gate_outputs : list inout := [⟨⟨5, 3⟩, ⟨6, 3⟩, E⟩]\n\ndef mk_xor (a : ww) : ww₁ := ⟨a, xor_gate_inputs, xor_gate_outputs⟩\n\ndef xor_gate_w : ww := mk_ww xor_gate'\n\ndef xor_gate : ww₁ := mk_xor xor_gate_w\n\ndef xor' (b₁ b₂ : bool) : bool :=\n    read (mk_xor (step_n (write (write xor_gate 0 b₂) 1 b₁).aut 5)) 0\n\ntheorem xor_iff_xor' {b₁ b₂} : bxor b₁ b₂ ↔ xor' b₁ b₂ :=\nbegin\n  cases b₁; cases b₂; split; intros h,\n  {\n    dsimp at h, contradiction\n  },\n  {\n    have : xor' ff ff = ff, from dec_trivial,\n    rw this at h,\n    contradiction\n  },\n  {\n    exact dec_trivial\n  },\n  {\n    dsimp, unfold_coes\n  },\n  {\n    exact dec_trivial\n  },\n  {\n    dsimp, unfold_coes\n  },\n  {\n    dsimp at h, contradiction\n  },\n  {\n    have : xor' tt tt = ff, from dec_trivial,\n    rw this at h,\n    contradiction\n  }\nend\n\nend ww_xor\n\nend ww\n\nend ww", "meta": {"author": "frankSil", "repo": "CAExtensions", "sha": "f5c74fd9a806696c73497d9abd45b7315f45379f", "save_path": "github-repos/lean/frankSil-CAExtensions", "path": "github-repos/lean/frankSil-CAExtensions/CAExtensions-f5c74fd9a806696c73497d9abd45b7315f45379f/src/wireworld.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4859335780861937}}
{"text": "/-\nCopyright (c) 2018 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Mario Carneiro, Yury Kudryashov, Heather Macbeth\n\n! This file was ported from Lean 3 source module topology.continuous_function.bounded\n! leanprover-community/mathlib commit d3af0609f6db8691dffdc3e1fb7feb7da72698f2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.Normed.Order.Lattice\nimport Mathbin.Analysis.NormedSpace.OperatorNorm\nimport Mathbin.Analysis.NormedSpace.Star.Basic\nimport Mathbin.Data.Real.Sqrt\nimport Mathbin.Topology.ContinuousFunction.Algebra\nimport Mathbin.Topology.MetricSpace.Equicontinuity\n\n/-!\n# Bounded continuous functions\n\nThe type of bounded continuous functions taking values in a metric space, with\nthe uniform distance.\n\n-/\n\n\nnoncomputable section\n\nopen Topology Classical NNReal uniformity UniformConvergence\n\nopen Set Filter Metric Function\n\nuniverse u v w\n\nvariable {F : Type _} {α : Type u} {β : Type v} {γ : Type w}\n\n/-- `α →ᵇ β` is the type of bounded continuous functions `α → β` from a topological space to a\nmetric space.\n\nWhen possible, instead of parametrizing results over `(f : α →ᵇ β)`,\nyou should parametrize over `(F : Type*) [bounded_continuous_map_class F α β] (f : F)`.\n\nWhen you extend this structure, make sure to extend `bounded_continuous_map_class`. -/\nstructure BoundedContinuousFunction (α : Type u) (β : Type v) [TopologicalSpace α]\n  [PseudoMetricSpace β] extends ContinuousMap α β : Type max u v where\n  map_bounded' : ∃ C, ∀ x y, dist (to_fun x) (to_fun y) ≤ C\n#align bounded_continuous_function BoundedContinuousFunction\n\n-- mathport name: bounded_continuous_function\nscoped[BoundedContinuousFunction] infixr:25 \" →ᵇ \" => BoundedContinuousFunction\n\nsection\n\n/-- `bounded_continuous_map_class F α β` states that `F` is a type of bounded continuous maps.\n\nYou should also extend this typeclass when you extend `bounded_continuous_function`. -/\nclass BoundedContinuousMapClass (F α β : Type _) [TopologicalSpace α] [PseudoMetricSpace β] extends\n  ContinuousMapClass F α β where\n  map_bounded (f : F) : ∃ C, ∀ x y, dist (f x) (f y) ≤ C\n#align bounded_continuous_map_class BoundedContinuousMapClass\n\nend\n\nexport BoundedContinuousMapClass (map_bounded)\n\nnamespace BoundedContinuousFunction\n\nsection Basics\n\nvariable [TopologicalSpace α] [PseudoMetricSpace β] [PseudoMetricSpace γ]\n\nvariable {f g : α →ᵇ β} {x : α} {C : ℝ}\n\ninstance : BoundedContinuousMapClass (α →ᵇ β) α β\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by\n    obtain ⟨⟨_, _⟩, _⟩ := f\n    obtain ⟨⟨_, _⟩, _⟩ := g\n    congr\n  map_continuous f := f.continuous_toFun\n  map_bounded f := f.map_bounded'\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : CoeFun (α →ᵇ β) fun _ => α → β :=\n  FunLike.hasCoeToFun\n\ninstance [BoundedContinuousMapClass F α β] : CoeTC F (α →ᵇ β) :=\n  ⟨fun f =>\n    { toFun := f\n      continuous_toFun := map_continuous f\n      map_bounded' := map_bounded f }⟩\n\n@[simp]\ntheorem coe_to_continuous_fun (f : α →ᵇ β) : (f.toContinuousMap : α → β) = f :=\n  rfl\n#align bounded_continuous_function.coe_to_continuous_fun BoundedContinuousFunction.coe_to_continuous_fun\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef Simps.apply (h : α →ᵇ β) : α → β :=\n  h\n#align bounded_continuous_function.simps.apply BoundedContinuousFunction.Simps.apply\n\ninitialize_simps_projections BoundedContinuousFunction (to_continuous_map_to_fun → apply)\n\nprotected theorem bounded (f : α →ᵇ β) : ∃ C, ∀ x y : α, dist (f x) (f y) ≤ C :=\n  f.map_bounded'\n#align bounded_continuous_function.bounded BoundedContinuousFunction.bounded\n\nprotected theorem continuous (f : α →ᵇ β) : Continuous f :=\n  f.toContinuousMap.Continuous\n#align bounded_continuous_function.continuous BoundedContinuousFunction.continuous\n\n@[ext]\ntheorem ext (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext _ _ h\n#align bounded_continuous_function.ext BoundedContinuousFunction.ext\n\ntheorem bounded_range (f : α →ᵇ β) : Bounded (range f) :=\n  bounded_range_iff.2 f.Bounded\n#align bounded_continuous_function.bounded_range BoundedContinuousFunction.bounded_range\n\ntheorem bounded_image (f : α →ᵇ β) (s : Set α) : Bounded (f '' s) :=\n  f.bounded_range.mono <| image_subset_range _ _\n#align bounded_continuous_function.bounded_image BoundedContinuousFunction.bounded_image\n\ntheorem eq_of_empty [IsEmpty α] (f g : α →ᵇ β) : f = g :=\n  ext <| IsEmpty.elim ‹_›\n#align bounded_continuous_function.eq_of_empty BoundedContinuousFunction.eq_of_empty\n\n/-- A continuous function with an explicit bound is a bounded continuous function. -/\ndef mkOfBound (f : C(α, β)) (C : ℝ) (h : ∀ x y : α, dist (f x) (f y) ≤ C) : α →ᵇ β :=\n  ⟨f, ⟨C, h⟩⟩\n#align bounded_continuous_function.mk_of_bound BoundedContinuousFunction.mkOfBound\n\n@[simp]\ntheorem mkOfBound_coe {f} {C} {h} : (mkOfBound f C h : α → β) = (f : α → β) :=\n  rfl\n#align bounded_continuous_function.mk_of_bound_coe BoundedContinuousFunction.mkOfBound_coe\n\n/-- A continuous function on a compact space is automatically a bounded continuous function. -/\ndef mkOfCompact [CompactSpace α] (f : C(α, β)) : α →ᵇ β :=\n  ⟨f, bounded_range_iff.1 (isCompact_range f.Continuous).Bounded⟩\n#align bounded_continuous_function.mk_of_compact BoundedContinuousFunction.mkOfCompact\n\n@[simp]\ntheorem mkOfCompact_apply [CompactSpace α] (f : C(α, β)) (a : α) : mkOfCompact f a = f a :=\n  rfl\n#align bounded_continuous_function.mk_of_compact_apply BoundedContinuousFunction.mkOfCompact_apply\n\n/-- If a function is bounded on a discrete space, it is automatically continuous,\nand therefore gives rise to an element of the type of bounded continuous functions -/\n@[simps]\ndef mkOfDiscrete [DiscreteTopology α] (f : α → β) (C : ℝ) (h : ∀ x y : α, dist (f x) (f y) ≤ C) :\n    α →ᵇ β :=\n  ⟨⟨f, continuous_of_discreteTopology⟩, ⟨C, h⟩⟩\n#align bounded_continuous_function.mk_of_discrete BoundedContinuousFunction.mkOfDiscrete\n\n/-- The uniform distance between two bounded continuous functions -/\ninstance : Dist (α →ᵇ β) :=\n  ⟨fun f g => infₛ { C | 0 ≤ C ∧ ∀ x : α, dist (f x) (g x) ≤ C }⟩\n\ntheorem dist_eq : dist f g = infₛ { C | 0 ≤ C ∧ ∀ x : α, dist (f x) (g x) ≤ C } :=\n  rfl\n#align bounded_continuous_function.dist_eq BoundedContinuousFunction.dist_eq\n\ntheorem dist_set_exists : ∃ C, 0 ≤ C ∧ ∀ x : α, dist (f x) (g x) ≤ C :=\n  by\n  rcases f.bounded_range.union g.bounded_range with ⟨C, hC⟩\n  refine' ⟨max 0 C, le_max_left _ _, fun x => (hC _ _ _ _).trans (le_max_right _ _)⟩ <;> [left,\n      right] <;>\n    apply mem_range_self\n#align bounded_continuous_function.dist_set_exists BoundedContinuousFunction.dist_set_exists\n\n/-- The pointwise distance is controlled by the distance between functions, by definition. -/\ntheorem dist_coe_le_dist (x : α) : dist (f x) (g x) ≤ dist f g :=\n  le_cinfₛ dist_set_exists fun b hb => hb.2 x\n#align bounded_continuous_function.dist_coe_le_dist BoundedContinuousFunction.dist_coe_le_dist\n\n/- This lemma will be needed in the proof of the metric space instance, but it will become\nuseless afterwards as it will be superseded by the general result that the distance is nonnegative\nin metric spaces. -/\nprivate theorem dist_nonneg' : 0 ≤ dist f g :=\n  le_cinfₛ dist_set_exists fun C => And.left\n#align bounded_continuous_function.dist_nonneg' bounded_continuous_function.dist_nonneg'\n\n/-- The distance between two functions is controlled by the supremum of the pointwise distances -/\ntheorem dist_le (C0 : (0 : ℝ) ≤ C) : dist f g ≤ C ↔ ∀ x : α, dist (f x) (g x) ≤ C :=\n  ⟨fun h x => le_trans (dist_coe_le_dist x) h, fun H => cinfₛ_le ⟨0, fun C => And.left⟩ ⟨C0, H⟩⟩\n#align bounded_continuous_function.dist_le BoundedContinuousFunction.dist_le\n\ntheorem dist_le_iff_of_nonempty [Nonempty α] : dist f g ≤ C ↔ ∀ x, dist (f x) (g x) ≤ C :=\n  ⟨fun h x => le_trans (dist_coe_le_dist x) h, fun w =>\n    (dist_le (le_trans dist_nonneg (w (Nonempty.some ‹_›)))).mpr w⟩\n#align bounded_continuous_function.dist_le_iff_of_nonempty BoundedContinuousFunction.dist_le_iff_of_nonempty\n\ntheorem dist_lt_of_nonempty_compact [Nonempty α] [CompactSpace α]\n    (w : ∀ x : α, dist (f x) (g x) < C) : dist f g < C :=\n  by\n  have c : Continuous fun x => dist (f x) (g x) := by continuity\n  obtain ⟨x, -, le⟩ :=\n    IsCompact.exists_forall_ge isCompact_univ Set.univ_nonempty (Continuous.continuousOn c)\n  exact lt_of_le_of_lt (dist_le_iff_of_nonempty.mpr fun y => le y trivial) (w x)\n#align bounded_continuous_function.dist_lt_of_nonempty_compact BoundedContinuousFunction.dist_lt_of_nonempty_compact\n\ntheorem dist_lt_iff_of_compact [CompactSpace α] (C0 : (0 : ℝ) < C) :\n    dist f g < C ↔ ∀ x : α, dist (f x) (g x) < C :=\n  by\n  fconstructor\n  · intro w x\n    exact lt_of_le_of_lt (dist_coe_le_dist x) w\n  · by_cases h : Nonempty α\n    · skip\n      exact dist_lt_of_nonempty_compact\n    · rintro -\n      convert C0\n      apply le_antisymm _ dist_nonneg'\n      rw [dist_eq]\n      exact cinfₛ_le ⟨0, fun C => And.left⟩ ⟨le_rfl, fun x => False.elim (h (Nonempty.intro x))⟩\n#align bounded_continuous_function.dist_lt_iff_of_compact BoundedContinuousFunction.dist_lt_iff_of_compact\n\ntheorem dist_lt_iff_of_nonempty_compact [Nonempty α] [CompactSpace α] :\n    dist f g < C ↔ ∀ x : α, dist (f x) (g x) < C :=\n  ⟨fun w x => lt_of_le_of_lt (dist_coe_le_dist x) w, dist_lt_of_nonempty_compact⟩\n#align bounded_continuous_function.dist_lt_iff_of_nonempty_compact BoundedContinuousFunction.dist_lt_iff_of_nonempty_compact\n\n/-- The type of bounded continuous functions, with the uniform distance, is a pseudometric space. -/\ninstance : PseudoMetricSpace (α →ᵇ β)\n    where\n  dist_self f := le_antisymm ((dist_le le_rfl).2 fun x => by simp) dist_nonneg'\n  dist_comm f g := by simp [dist_eq, dist_comm]\n  dist_triangle f g h :=\n    (dist_le (add_nonneg dist_nonneg' dist_nonneg')).2 fun x =>\n      le_trans (dist_triangle _ _ _) (add_le_add (dist_coe_le_dist _) (dist_coe_le_dist _))\n\n/-- The type of bounded continuous functions, with the uniform distance, is a metric space. -/\ninstance {α β} [TopologicalSpace α] [MetricSpace β] : MetricSpace (α →ᵇ β)\n    where eq_of_dist_eq_zero f g hfg := by\n    ext x <;> exact eq_of_dist_eq_zero (le_antisymm (hfg ▸ dist_coe_le_dist _) dist_nonneg)\n\ntheorem nndist_eq : nndist f g = infₛ { C | ∀ x : α, nndist (f x) (g x) ≤ C } :=\n  Subtype.ext <|\n    dist_eq.trans <| by\n      rw [NNReal.coe_infₛ, NNReal.coe_image]\n      simp_rw [mem_set_of_eq, ← NNReal.coe_le_coe, Subtype.coe_mk, exists_prop, coe_nndist]\n#align bounded_continuous_function.nndist_eq BoundedContinuousFunction.nndist_eq\n\ntheorem nndist_set_exists : ∃ C, ∀ x : α, nndist (f x) (g x) ≤ C :=\n  Subtype.exists.mpr <| dist_set_exists.imp fun a ⟨ha, h⟩ => ⟨ha, h⟩\n#align bounded_continuous_function.nndist_set_exists BoundedContinuousFunction.nndist_set_exists\n\ntheorem nndist_coe_le_nndist (x : α) : nndist (f x) (g x) ≤ nndist f g :=\n  dist_coe_le_dist x\n#align bounded_continuous_function.nndist_coe_le_nndist BoundedContinuousFunction.nndist_coe_le_nndist\n\n/-- On an empty space, bounded continuous functions are at distance 0 -/\ntheorem dist_zero_of_empty [IsEmpty α] : dist f g = 0 := by\n  rw [(ext isEmptyElim : f = g), dist_self]\n#align bounded_continuous_function.dist_zero_of_empty BoundedContinuousFunction.dist_zero_of_empty\n\ntheorem dist_eq_supᵢ : dist f g = ⨆ x : α, dist (f x) (g x) :=\n  by\n  cases isEmpty_or_nonempty α; · rw [supᵢ_of_empty', Real.supₛ_empty, dist_zero_of_empty]\n  refine' (dist_le_iff_of_nonempty.mpr <| le_csupᵢ _).antisymm (csupᵢ_le dist_coe_le_dist)\n  exact dist_set_exists.imp fun C hC => forall_range_iff.2 hC.2\n#align bounded_continuous_function.dist_eq_supr BoundedContinuousFunction.dist_eq_supᵢ\n\ntheorem nndist_eq_supᵢ : nndist f g = ⨆ x : α, nndist (f x) (g x) :=\n  Subtype.ext <| dist_eq_supᵢ.trans <| by simp_rw [NNReal.coe_supᵢ, coe_nndist]\n#align bounded_continuous_function.nndist_eq_supr BoundedContinuousFunction.nndist_eq_supᵢ\n\ntheorem tendsto_iff_tendstoUniformly {ι : Type _} {F : ι → α →ᵇ β} {f : α →ᵇ β} {l : Filter ι} :\n    Tendsto F l (𝓝 f) ↔ TendstoUniformly (fun i => F i) f l :=\n  Iff.intro\n    (fun h =>\n      tendstoUniformly_iff.2 fun ε ε0 =>\n        (Metric.tendsto_nhds.mp h ε ε0).mp\n          (eventually_of_forall fun n hn x =>\n            lt_of_le_of_lt (dist_coe_le_dist x) (dist_comm (F n) f ▸ hn)))\n    fun h =>\n    Metric.tendsto_nhds.mpr fun ε ε_pos =>\n      (h _ (dist_mem_uniformity <| half_pos ε_pos)).mp\n        (eventually_of_forall fun n hn =>\n          lt_of_le_of_lt\n            ((dist_le (half_pos ε_pos).le).mpr fun x => dist_comm (f x) (F n x) ▸ le_of_lt (hn x))\n            (half_lt_self ε_pos))\n#align bounded_continuous_function.tendsto_iff_tendsto_uniformly BoundedContinuousFunction.tendsto_iff_tendstoUniformly\n\n/-- The topology on `α →ᵇ β` is exactly the topology induced by the natural map to `α →ᵤ β`. -/\ntheorem inducing_coeFn : Inducing (UniformFun.ofFun ∘ coeFn : (α →ᵇ β) → α →ᵤ β) :=\n  by\n  rw [inducing_iff_nhds]\n  refine' fun f => eq_of_forall_le_iff fun l => _\n  rw [← tendsto_iff_comap, ← tendsto_id', tendsto_iff_tendsto_uniformly,\n    UniformFun.tendsto_iff_tendstoUniformly]\n  rfl\n#align bounded_continuous_function.inducing_coe_fn BoundedContinuousFunction.inducing_coeFn\n\n-- TODO: upgrade to a `uniform_embedding`\ntheorem embedding_coeFn : Embedding (UniformFun.ofFun ∘ coeFn : (α →ᵇ β) → α →ᵤ β) :=\n  ⟨inducing_coeFn, fun f g h => ext fun x => congr_fun h x⟩\n#align bounded_continuous_function.embedding_coe_fn BoundedContinuousFunction.embedding_coeFn\n\nvariable (α) {β}\n\n/-- Constant as a continuous bounded function. -/\n@[simps (config := { fullyApplied := false })]\ndef const (b : β) : α →ᵇ β :=\n  ⟨ContinuousMap.const α b, 0, by simp [le_rfl]⟩\n#align bounded_continuous_function.const BoundedContinuousFunction.const\n\nvariable {α}\n\ntheorem const_apply' (a : α) (b : β) : (const α b : α → β) a = b :=\n  rfl\n#align bounded_continuous_function.const_apply' BoundedContinuousFunction.const_apply'\n\n/-- If the target space is inhabited, so is the space of bounded continuous functions -/\ninstance [Inhabited β] : Inhabited (α →ᵇ β) :=\n  ⟨const α default⟩\n\ntheorem lipschitz_evalx (x : α) : LipschitzWith 1 fun f : α →ᵇ β => f x :=\n  LipschitzWith.mk_one fun f g => dist_coe_le_dist x\n#align bounded_continuous_function.lipschitz_evalx BoundedContinuousFunction.lipschitz_evalx\n\ntheorem uniformContinuous_coe : @UniformContinuous (α →ᵇ β) (α → β) _ _ coeFn :=\n  uniformContinuous_pi.2 fun x => (lipschitz_evalx x).UniformContinuous\n#align bounded_continuous_function.uniform_continuous_coe BoundedContinuousFunction.uniformContinuous_coe\n\ntheorem continuous_coe : Continuous fun (f : α →ᵇ β) x => f x :=\n  UniformContinuous.continuous uniformContinuous_coe\n#align bounded_continuous_function.continuous_coe BoundedContinuousFunction.continuous_coe\n\n/-- When `x` is fixed, `(f : α →ᵇ β) ↦ f x` is continuous -/\n@[continuity]\ntheorem continuous_eval_const {x : α} : Continuous fun f : α →ᵇ β => f x :=\n  (continuous_apply x).comp continuous_coe\n#align bounded_continuous_function.continuous_eval_const BoundedContinuousFunction.continuous_eval_const\n\n/-- The evaluation map is continuous, as a joint function of `u` and `x` -/\n@[continuity]\ntheorem continuous_eval : Continuous fun p : (α →ᵇ β) × α => p.1 p.2 :=\n  (continuous_prod_of_continuous_lipschitz _ 1 fun f => f.Continuous) <| lipschitz_evalx\n#align bounded_continuous_function.continuous_eval BoundedContinuousFunction.continuous_eval\n\n/-- Bounded continuous functions taking values in a complete space form a complete space. -/\ninstance [CompleteSpace β] : CompleteSpace (α →ᵇ β) :=\n  complete_of_cauchySeq_tendsto fun (f : ℕ → α →ᵇ β) (hf : CauchySeq f) =>\n    by\n    /- We have to show that `f n` converges to a bounded continuous function.\n      For this, we prove pointwise convergence to define the limit, then check\n      it is a continuous bounded function, and then check the norm convergence. -/\n    rcases cauchySeq_iff_le_tendsto_0.1 hf with ⟨b, b0, b_bound, b_lim⟩\n    have f_bdd := fun x n m N hn hm => le_trans (dist_coe_le_dist x) (b_bound n m N hn hm)\n    have fx_cau : ∀ x, CauchySeq fun n => f n x := fun x =>\n      cauchySeq_iff_le_tendsto_0.2 ⟨b, b0, f_bdd x, b_lim⟩\n    choose F hF using fun x => cauchySeq_tendsto_of_complete (fx_cau x)\n    /- F : α → β,  hF : ∀ (x : α), tendsto (λ (n : ℕ), f n x) at_top (𝓝 (F x))\n      `F` is the desired limit function. Check that it is uniformly approximated by `f N` -/\n    have fF_bdd : ∀ x N, dist (f N x) (F x) ≤ b N := fun x N =>\n      le_of_tendsto (tendsto_const_nhds.dist (hF x))\n        (Filter.eventually_atTop.2 ⟨N, fun n hn => f_bdd x N n N (le_refl N) hn⟩)\n    refine' ⟨⟨⟨F, _⟩, _⟩, _⟩\n    · -- Check that `F` is continuous, as a uniform limit of continuous functions\n      have : TendstoUniformly (fun n x => f n x) F at_top :=\n        by\n        refine' Metric.tendstoUniformly_iff.2 fun ε ε0 => _\n        refine' ((tendsto_order.1 b_lim).2 ε ε0).mono fun n hn x => _\n        rw [dist_comm]\n        exact lt_of_le_of_lt (fF_bdd x n) hn\n      exact this.continuous (eventually_of_forall fun N => (f N).Continuous)\n    · -- Check that `F` is bounded\n      rcases(f 0).Bounded with ⟨C, hC⟩\n      refine' ⟨C + (b 0 + b 0), fun x y => _⟩\n      calc\n        dist (F x) (F y) ≤ dist (f 0 x) (f 0 y) + (dist (f 0 x) (F x) + dist (f 0 y) (F y)) :=\n          dist_triangle4_left _ _ _ _\n        _ ≤ C + (b 0 + b 0) := by mono*\n        \n    · -- Check that `F` is close to `f N` in distance terms\n      refine' tendsto_iff_dist_tendsto_zero.2 (squeeze_zero (fun _ => dist_nonneg) _ b_lim)\n      exact fun N => (dist_le (b0 _)).2 fun x => fF_bdd x N\n\n/-- Composition of a bounded continuous function and a continuous function. -/\ndef compContinuous {δ : Type _} [TopologicalSpace δ] (f : α →ᵇ β) (g : C(δ, α)) : δ →ᵇ β\n    where\n  toContinuousMap := f.1.comp g\n  map_bounded' := f.map_bounded'.imp fun C hC x y => hC _ _\n#align bounded_continuous_function.comp_continuous BoundedContinuousFunction.compContinuous\n\n@[simp]\ntheorem coe_compContinuous {δ : Type _} [TopologicalSpace δ] (f : α →ᵇ β) (g : C(δ, α)) :\n    coeFn (f.comp_continuous g) = f ∘ g :=\n  rfl\n#align bounded_continuous_function.coe_comp_continuous BoundedContinuousFunction.coe_compContinuous\n\n@[simp]\ntheorem compContinuous_apply {δ : Type _} [TopologicalSpace δ] (f : α →ᵇ β) (g : C(δ, α)) (x : δ) :\n    f.comp_continuous g x = f (g x) :=\n  rfl\n#align bounded_continuous_function.comp_continuous_apply BoundedContinuousFunction.compContinuous_apply\n\ntheorem lipschitz_compContinuous {δ : Type _} [TopologicalSpace δ] (g : C(δ, α)) :\n    LipschitzWith 1 fun f : α →ᵇ β => f.comp_continuous g :=\n  LipschitzWith.mk_one fun f₁ f₂ => (dist_le dist_nonneg).2 fun x => dist_coe_le_dist (g x)\n#align bounded_continuous_function.lipschitz_comp_continuous BoundedContinuousFunction.lipschitz_compContinuous\n\ntheorem continuous_compContinuous {δ : Type _} [TopologicalSpace δ] (g : C(δ, α)) :\n    Continuous fun f : α →ᵇ β => f.comp_continuous g :=\n  (lipschitz_compContinuous g).Continuous\n#align bounded_continuous_function.continuous_comp_continuous BoundedContinuousFunction.continuous_compContinuous\n\n/-- Restrict a bounded continuous function to a set. -/\ndef restrict (f : α →ᵇ β) (s : Set α) : s →ᵇ β :=\n  f.comp_continuous <| (ContinuousMap.id _).restrict s\n#align bounded_continuous_function.restrict BoundedContinuousFunction.restrict\n\n@[simp]\ntheorem coe_restrict (f : α →ᵇ β) (s : Set α) : coeFn (f.restrict s) = f ∘ coe :=\n  rfl\n#align bounded_continuous_function.coe_restrict BoundedContinuousFunction.coe_restrict\n\n@[simp]\ntheorem restrict_apply (f : α →ᵇ β) (s : Set α) (x : s) : f.restrict s x = f x :=\n  rfl\n#align bounded_continuous_function.restrict_apply BoundedContinuousFunction.restrict_apply\n\n/-- Composition (in the target) of a bounded continuous function with a Lipschitz map again\ngives a bounded continuous function -/\ndef comp (G : β → γ) {C : ℝ≥0} (H : LipschitzWith C G) (f : α →ᵇ β) : α →ᵇ γ :=\n  ⟨⟨fun x => G (f x), H.Continuous.comp f.Continuous⟩,\n    let ⟨D, hD⟩ := f.Bounded\n    ⟨max C 0 * D, fun x y =>\n      calc\n        dist (G (f x)) (G (f y)) ≤ C * dist (f x) (f y) := H.dist_le_mul _ _\n        _ ≤ max C 0 * dist (f x) (f y) := (mul_le_mul_of_nonneg_right (le_max_left C 0) dist_nonneg)\n        _ ≤ max C 0 * D := mul_le_mul_of_nonneg_left (hD _ _) (le_max_right C 0)\n        ⟩⟩\n#align bounded_continuous_function.comp BoundedContinuousFunction.comp\n\n/-- The composition operator (in the target) with a Lipschitz map is Lipschitz -/\ntheorem lipschitz_comp {G : β → γ} {C : ℝ≥0} (H : LipschitzWith C G) :\n    LipschitzWith C (comp G H : (α →ᵇ β) → α →ᵇ γ) :=\n  LipschitzWith.of_dist_le_mul fun f g =>\n    (dist_le (mul_nonneg C.2 dist_nonneg)).2 fun x =>\n      calc\n        dist (G (f x)) (G (g x)) ≤ C * dist (f x) (g x) := H.dist_le_mul _ _\n        _ ≤ C * dist f g := mul_le_mul_of_nonneg_left (dist_coe_le_dist _) C.2\n        \n#align bounded_continuous_function.lipschitz_comp BoundedContinuousFunction.lipschitz_comp\n\n/-- The composition operator (in the target) with a Lipschitz map is uniformly continuous -/\ntheorem uniformContinuous_comp {G : β → γ} {C : ℝ≥0} (H : LipschitzWith C G) :\n    UniformContinuous (comp G H : (α →ᵇ β) → α →ᵇ γ) :=\n  (lipschitz_comp H).UniformContinuous\n#align bounded_continuous_function.uniform_continuous_comp BoundedContinuousFunction.uniformContinuous_comp\n\n/-- The composition operator (in the target) with a Lipschitz map is continuous -/\ntheorem continuous_comp {G : β → γ} {C : ℝ≥0} (H : LipschitzWith C G) :\n    Continuous (comp G H : (α →ᵇ β) → α →ᵇ γ) :=\n  (lipschitz_comp H).Continuous\n#align bounded_continuous_function.continuous_comp BoundedContinuousFunction.continuous_comp\n\n/-- Restriction (in the target) of a bounded continuous function taking values in a subset -/\ndef codRestrict (s : Set β) (f : α →ᵇ β) (H : ∀ x, f x ∈ s) : α →ᵇ s :=\n  ⟨⟨s.codRestrict f H, f.Continuous.subtype_mk _⟩, f.Bounded⟩\n#align bounded_continuous_function.cod_restrict BoundedContinuousFunction.codRestrict\n\nsection Extend\n\nvariable {δ : Type _} [TopologicalSpace δ] [DiscreteTopology δ]\n\n/-- A version of `function.extend` for bounded continuous maps. We assume that the domain has\ndiscrete topology, so we only need to verify boundedness. -/\ndef extend (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) : δ →ᵇ β\n    where\n  toFun := extend f g h\n  continuous_toFun := continuous_of_discreteTopology\n  map_bounded' :=\n    by\n    rw [← bounded_range_iff, range_extend f.injective, Metric.bounded_union]\n    exact ⟨g.bounded_range, h.bounded_image _⟩\n#align bounded_continuous_function.extend BoundedContinuousFunction.extend\n\n@[simp]\ntheorem extend_apply (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) (x : α) : extend f g h (f x) = g x :=\n  f.Injective.extend_apply _ _ _\n#align bounded_continuous_function.extend_apply BoundedContinuousFunction.extend_apply\n\n@[simp]\ntheorem extend_comp (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) : extend f g h ∘ f = g :=\n  extend_comp f.Injective _ _\n#align bounded_continuous_function.extend_comp BoundedContinuousFunction.extend_comp\n\ntheorem extend_apply' {f : α ↪ δ} {x : δ} (hx : x ∉ range f) (g : α →ᵇ β) (h : δ →ᵇ β) :\n    extend f g h x = h x :=\n  extend_apply' _ _ _ hx\n#align bounded_continuous_function.extend_apply' BoundedContinuousFunction.extend_apply'\n\ntheorem extend_of_empty [IsEmpty α] (f : α ↪ δ) (g : α →ᵇ β) (h : δ →ᵇ β) : extend f g h = h :=\n  FunLike.coe_injective <| Function.extend_of_isEmpty f g h\n#align bounded_continuous_function.extend_of_empty BoundedContinuousFunction.extend_of_empty\n\n@[simp]\ntheorem dist_extend_extend (f : α ↪ δ) (g₁ g₂ : α →ᵇ β) (h₁ h₂ : δ →ᵇ β) :\n    dist (g₁.extend f h₁) (g₂.extend f h₂) =\n      max (dist g₁ g₂) (dist (h₁.restrict (range fᶜ)) (h₂.restrict (range fᶜ))) :=\n  by\n  refine' le_antisymm ((dist_le <| le_max_iff.2 <| Or.inl dist_nonneg).2 fun x => _) (max_le _ _)\n  · rcases em (∃ y, f y = x) with (⟨x, rfl⟩ | hx)\n    · simp only [extend_apply]\n      exact (dist_coe_le_dist x).trans (le_max_left _ _)\n    · simp only [extend_apply' hx]\n      lift x to (range fᶜ : Set δ) using hx\n      calc\n        dist (h₁ x) (h₂ x) = dist (h₁.restrict (range fᶜ) x) (h₂.restrict (range fᶜ) x) := rfl\n        _ ≤ dist (h₁.restrict (range fᶜ)) (h₂.restrict (range fᶜ)) := (dist_coe_le_dist x)\n        _ ≤ _ := le_max_right _ _\n        \n  · refine' (dist_le dist_nonneg).2 fun x => _\n    rw [← extend_apply f g₁ h₁, ← extend_apply f g₂ h₂]\n    exact dist_coe_le_dist _\n  · refine' (dist_le dist_nonneg).2 fun x => _\n    calc\n      dist (h₁ x) (h₂ x) = dist (extend f g₁ h₁ x) (extend f g₂ h₂ x) := by\n        rw [extend_apply' x.coe_prop, extend_apply' x.coe_prop]\n      _ ≤ _ := dist_coe_le_dist _\n      \n#align bounded_continuous_function.dist_extend_extend BoundedContinuousFunction.dist_extend_extend\n\ntheorem isometry_extend (f : α ↪ δ) (h : δ →ᵇ β) : Isometry fun g : α →ᵇ β => extend f g h :=\n  Isometry.of_dist_eq fun g₁ g₂ => by simp [dist_nonneg]\n#align bounded_continuous_function.isometry_extend BoundedContinuousFunction.isometry_extend\n\nend Extend\n\nend Basics\n\nsection ArzelaAscoli\n\nvariable [TopologicalSpace α] [CompactSpace α] [PseudoMetricSpace β]\n\nvariable {f g : α →ᵇ β} {x : α} {C : ℝ}\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y z «expr ∈ » U) -/\n/- Arzela-Ascoli theorem asserts that, on a compact space, a set of functions sharing\na common modulus of continuity and taking values in a compact set forms a compact\nsubset for the topology of uniform convergence. In this section, we prove this theorem\nand several useful variations around it. -/\n/-- First version, with pointwise equicontinuity and range in a compact space -/\ntheorem arzela_ascoli₁ [CompactSpace β] (A : Set (α →ᵇ β)) (closed : IsClosed A)\n    (H : Equicontinuous (coeFn : A → α → β)) : IsCompact A :=\n  by\n  simp_rw [Equicontinuous, Metric.equicontinuousAt_iff_pair] at H\n  refine' isCompact_of_totallyBounded_isClosed _ closed\n  refine' totally_bounded_of_finite_discretization fun ε ε0 => _\n  rcases exists_between ε0 with ⟨ε₁, ε₁0, εε₁⟩\n  let ε₂ := ε₁ / 2 / 2\n  /- We have to find a finite discretization of `u`, i.e., finite information\n    that is sufficient to reconstruct `u` up to ε. This information will be\n    provided by the values of `u` on a sufficiently dense set tα,\n    slightly translated to fit in a finite ε₂-dense set tβ in the image. Such\n    sets exist by compactness of the source and range. Then, to check that these\n    data determine the function up to ε, one uses the control on the modulus of\n    continuity to extend the closeness on tα to closeness everywhere. -/\n  have ε₂0 : ε₂ > 0 := half_pos (half_pos ε₁0)\n  have :\n    ∀ x : α,\n      ∃ U,\n        x ∈ U ∧\n          IsOpen U ∧\n            ∀ (y) (_ : y ∈ U) (z) (_ : z ∈ U) {f : α →ᵇ β}, f ∈ A → dist (f y) (f z) < ε₂ :=\n    fun x =>\n    let ⟨U, nhdsU, hU⟩ := H x _ ε₂0\n    let ⟨V, VU, openV, xV⟩ := _root_.mem_nhds_iff.1 nhdsU\n    ⟨V, xV, openV, fun y hy z hz f hf => hU y (VU hy) z (VU hz) ⟨f, hf⟩⟩\n  choose U hU using this\n  /- For all x, the set hU x is an open set containing x on which the elements of A\n    fluctuate by at most ε₂.\n    We extract finitely many of these sets that cover the whole space, by compactness -/\n  rcases is_compact_univ.elim_finite_subcover_image (fun x _ => (hU x).2.1) fun x hx =>\n      mem_bUnion (mem_univ _) (hU x).1 with\n    ⟨tα, _, ⟨_⟩, htα⟩\n  -- tα : set α, htα : univ ⊆ ⋃x ∈ tα, U x\n  rcases@finite_cover_balls_of_compact β _ _ isCompact_univ _ ε₂0 with ⟨tβ, _, ⟨_⟩, htβ⟩\n  skip\n  -- tβ : set β, htβ : univ ⊆ ⋃y ∈ tβ, ball y ε₂ \n  -- Associate to every point `y` in the space a nearby point `F y` in tβ\n  choose F hF using fun y => show ∃ z ∈ tβ, dist y z < ε₂ by simpa using htβ (mem_univ y)\n  -- F : β → β, hF : ∀ (y : β), F y ∈ tβ ∧ dist y (F y) < ε₂ \n  /- Associate to every function a discrete approximation, mapping each point in `tα`\n    to a point in `tβ` close to its true image by the function. -/\n  refine' ⟨tα → tβ, by infer_instance, fun f a => ⟨F (f a), (hF (f a)).1⟩, _⟩\n  rintro ⟨f, hf⟩ ⟨g, hg⟩ f_eq_g\n  -- If two functions have the same approximation, then they are within distance ε\n  refine' lt_of_le_of_lt ((dist_le <| le_of_lt ε₁0).2 fun x => _) εε₁\n  obtain ⟨x', x'tα, hx'⟩ : ∃ x' ∈ tα, x ∈ U x' := mem_Union₂.1 (htα (mem_univ x))\n  calc\n    dist (f x) (g x) ≤ dist (f x) (f x') + dist (g x) (g x') + dist (f x') (g x') :=\n      dist_triangle4_right _ _ _ _\n    _ ≤ ε₂ + ε₂ + ε₁ / 2 := (le_of_lt (add_lt_add (add_lt_add _ _) _))\n    _ = ε₁ := by rw [add_halves, add_halves]\n    \n  · exact (hU x').2.2 _ hx' _ (hU x').1 hf\n  · exact (hU x').2.2 _ hx' _ (hU x').1 hg\n  · have F_f_g : F (f x') = F (g x') :=\n      (congr_arg (fun f : tα → tβ => (f ⟨x', x'tα⟩ : β)) f_eq_g : _)\n    calc\n      dist (f x') (g x') ≤ dist (f x') (F (f x')) + dist (g x') (F (f x')) :=\n        dist_triangle_right _ _ _\n      _ = dist (f x') (F (f x')) + dist (g x') (F (g x')) := by rw [F_f_g]\n      _ < ε₂ + ε₂ := (add_lt_add (hF (f x')).2 (hF (g x')).2)\n      _ = ε₁ / 2 := add_halves _\n      \n#align bounded_continuous_function.arzela_ascoli₁ BoundedContinuousFunction.arzela_ascoli₁\n\n/-- Second version, with pointwise equicontinuity and range in a compact subset -/\ntheorem arzela_ascoli₂ (s : Set β) (hs : IsCompact s) (A : Set (α →ᵇ β)) (closed : IsClosed A)\n    (in_s : ∀ (f : α →ᵇ β) (x : α), f ∈ A → f x ∈ s) (H : Equicontinuous (coeFn : A → α → β)) :\n    IsCompact A :=\n  by\n  /- This version is deduced from the previous one by restricting to the compact type in the target,\n  using compactness there and then lifting everything to the original space. -/\n  have M : LipschitzWith 1 coe := LipschitzWith.subtype_val s\n  let F : (α →ᵇ s) → α →ᵇ β := comp coe M\n  refine'\n    isCompact_of_isClosed_subset ((_ : IsCompact (F ⁻¹' A)).image (continuous_comp M)) closed\n      fun f hf => _\n  · haveI : CompactSpace s := isCompact_iff_compactSpace.1 hs\n    refine' arzela_ascoli₁ _ (continuous_iff_isClosed.1 (continuous_comp M) _ closed) _\n    rw [uniform_embedding_subtype_coe.to_uniform_inducing.equicontinuous_iff]\n    exact H.comp (A.restrict_preimage F)\n  · let g := cod_restrict s f fun x => in_s f x hf\n    rw [show f = F g by ext <;> rfl] at hf⊢\n    exact ⟨g, hf, rfl⟩\n#align bounded_continuous_function.arzela_ascoli₂ BoundedContinuousFunction.arzela_ascoli₂\n\n/-- Third (main) version, with pointwise equicontinuity and range in a compact subset, but\nwithout closedness. The closure is then compact -/\ntheorem arzela_ascoli [T2Space β] (s : Set β) (hs : IsCompact s) (A : Set (α →ᵇ β))\n    (in_s : ∀ (f : α →ᵇ β) (x : α), f ∈ A → f x ∈ s) (H : Equicontinuous (coeFn : A → α → β)) :\n    IsCompact (closure A) :=\n  /- This version is deduced from the previous one by checking that the closure of A, in\n    addition to being closed, still satisfies the properties of compact range and equicontinuity -/\n    arzela_ascoli₂\n    s hs (closure A) isClosed_closure\n    (fun f x hf =>\n      (mem_of_closed' hs.IsClosed).2 fun ε ε0 =>\n        let ⟨g, gA, dist_fg⟩ := Metric.mem_closure_iff.1 hf ε ε0\n        ⟨g x, in_s g x gA, lt_of_le_of_lt (dist_coe_le_dist _) dist_fg⟩)\n    (H.closure' continuous_coe)\n#align bounded_continuous_function.arzela_ascoli BoundedContinuousFunction.arzela_ascoli\n\nend ArzelaAscoli\n\nsection One\n\nvariable [TopologicalSpace α] [PseudoMetricSpace β] [One β]\n\n@[to_additive]\ninstance : One (α →ᵇ β) :=\n  ⟨const α 1⟩\n\n@[simp, to_additive]\ntheorem coe_one : ((1 : α →ᵇ β) : α → β) = 1 :=\n  rfl\n#align bounded_continuous_function.coe_one BoundedContinuousFunction.coe_one\n#align bounded_continuous_function.coe_zero BoundedContinuousFunction.coe_zero\n\n@[simp, to_additive]\ntheorem mkOfCompact_one [CompactSpace α] : mkOfCompact (1 : C(α, β)) = 1 :=\n  rfl\n#align bounded_continuous_function.mk_of_compact_one BoundedContinuousFunction.mkOfCompact_one\n#align bounded_continuous_function.mk_of_compact_zero BoundedContinuousFunction.mkOfCompact_zero\n\n@[to_additive]\ntheorem forall_coe_one_iff_one (f : α →ᵇ β) : (∀ x, f x = 1) ↔ f = 1 :=\n  (@FunLike.ext_iff _ _ _ _ f 1).symm\n#align bounded_continuous_function.forall_coe_one_iff_one BoundedContinuousFunction.forall_coe_one_iff_one\n#align bounded_continuous_function.forall_coe_zero_iff_zero BoundedContinuousFunction.forall_coe_zero_iff_zero\n\n@[simp, to_additive]\ntheorem one_compContinuous [TopologicalSpace γ] (f : C(γ, α)) :\n    (1 : α →ᵇ β).comp_continuous f = 1 :=\n  rfl\n#align bounded_continuous_function.one_comp_continuous BoundedContinuousFunction.one_compContinuous\n#align bounded_continuous_function.zero_comp_continuous BoundedContinuousFunction.zero_compContinuous\n\nend One\n\nsection LipschitzAdd\n\n/- In this section, if `β` is an `add_monoid` whose addition operation is Lipschitz, then we show\nthat the space of bounded continuous functions from `α` to `β` inherits a topological `add_monoid`\nstructure, by using pointwise operations and checking that they are compatible with the uniform\ndistance.\n\nImplementation note: The material in this section could have been written for `has_lipschitz_mul`\nand transported by `@[to_additive]`.  We choose not to do this because this causes a few lemma\nnames (for example, `coe_mul`) to conflict with later lemma names for normed rings; this is only a\ntrivial inconvenience, but in any case there are no obvious applications of the multiplicative\nversion. -/\nvariable [TopologicalSpace α] [PseudoMetricSpace β] [AddMonoid β]\n\nvariable [LipschitzAdd β]\n\nvariable (f g : α →ᵇ β) {x : α} {C : ℝ}\n\n/-- The pointwise sum of two bounded continuous functions is again bounded continuous. -/\ninstance : Add (α →ᵇ β)\n    where add f g :=\n    BoundedContinuousFunction.mkOfBound (f.toContinuousMap + g.toContinuousMap)\n      (↑(LipschitzAdd.C β) * max (Classical.choose f.Bounded) (Classical.choose g.Bounded))\n      (by\n        intro x y\n        refine' le_trans (lipschitz_with_lipschitz_const_add ⟨f x, g x⟩ ⟨f y, g y⟩) _\n        rw [Prod.dist_eq]\n        refine' mul_le_mul_of_nonneg_left _ (LipschitzAdd.C β).coe_nonneg\n        apply max_le_max\n        exact Classical.choose_spec f.bounded x y\n        exact Classical.choose_spec g.bounded x y)\n\n@[simp]\ntheorem coe_add : ⇑(f + g) = f + g :=\n  rfl\n#align bounded_continuous_function.coe_add BoundedContinuousFunction.coe_add\n\ntheorem add_apply : (f + g) x = f x + g x :=\n  rfl\n#align bounded_continuous_function.add_apply BoundedContinuousFunction.add_apply\n\n@[simp]\ntheorem mkOfCompact_add [CompactSpace α] (f g : C(α, β)) :\n    mkOfCompact (f + g) = mkOfCompact f + mkOfCompact g :=\n  rfl\n#align bounded_continuous_function.mk_of_compact_add BoundedContinuousFunction.mkOfCompact_add\n\ntheorem add_compContinuous [TopologicalSpace γ] (h : C(γ, α)) :\n    (g + f).comp_continuous h = g.comp_continuous h + f.comp_continuous h :=\n  rfl\n#align bounded_continuous_function.add_comp_continuous BoundedContinuousFunction.add_compContinuous\n\n@[simp]\ntheorem coe_nsmulRec : ∀ n, ⇑(nsmulRec n f) = n • f\n  | 0 => by rw [nsmulRec, zero_smul, coe_zero]\n  | n + 1 => by rw [nsmulRec, succ_nsmul, coe_add, coe_nsmul_rec]\n#align bounded_continuous_function.coe_nsmul_rec BoundedContinuousFunction.coe_nsmulRec\n\ninstance hasNatScalar : SMul ℕ (α →ᵇ β)\n    where smul n f :=\n    { toContinuousMap := n • f.toContinuousMap\n      map_bounded' := by simpa [coe_nsmul_rec] using (nsmulRec n f).map_bounded' }\n#align bounded_continuous_function.has_nat_scalar BoundedContinuousFunction.hasNatScalar\n\n@[simp]\ntheorem coe_nsmul (r : ℕ) (f : α →ᵇ β) : ⇑(r • f) = r • f :=\n  rfl\n#align bounded_continuous_function.coe_nsmul BoundedContinuousFunction.coe_nsmul\n\n@[simp]\ntheorem nsmul_apply (r : ℕ) (f : α →ᵇ β) (v : α) : (r • f) v = r • f v :=\n  rfl\n#align bounded_continuous_function.nsmul_apply BoundedContinuousFunction.nsmul_apply\n\ninstance : AddMonoid (α →ᵇ β) :=\n  FunLike.coe_injective.AddMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _\n\ninstance : LipschitzAdd (α →ᵇ β)\n    where lipschitz_add :=\n    ⟨LipschitzAdd.C β, by\n      have C_nonneg := (LipschitzAdd.C β).coe_nonneg\n      rw [lipschitzWith_iff_dist_le_mul]\n      rintro ⟨f₁, g₁⟩ ⟨f₂, g₂⟩\n      rw [dist_le (mul_nonneg C_nonneg dist_nonneg)]\n      intro x\n      refine' le_trans (lipschitz_with_lipschitz_const_add ⟨f₁ x, g₁ x⟩ ⟨f₂ x, g₂ x⟩) _\n      refine' mul_le_mul_of_nonneg_left _ C_nonneg\n      apply max_le_max <;> exact dist_coe_le_dist x⟩\n\n/-- Coercion of a `normed_add_group_hom` is an `add_monoid_hom`. Similar to\n`add_monoid_hom.coe_fn`. -/\n@[simps]\ndef coeFnAddHom : (α →ᵇ β) →+ α → β where\n  toFun := coeFn\n  map_zero' := coe_zero\n  map_add' := coe_add\n#align bounded_continuous_function.coe_fn_add_hom BoundedContinuousFunction.coeFnAddHom\n\nvariable (α β)\n\n/-- The additive map forgetting that a bounded continuous function is bounded.\n-/\n@[simps]\ndef toContinuousMapAddHom : (α →ᵇ β) →+ C(α, β)\n    where\n  toFun := toContinuousMap\n  map_zero' := by\n    ext\n    simp\n  map_add' := by\n    intros\n    ext\n    simp\n#align bounded_continuous_function.to_continuous_map_add_hom BoundedContinuousFunction.toContinuousMapAddHom\n\nend LipschitzAdd\n\nsection CommHasLipschitzAdd\n\nvariable [TopologicalSpace α] [PseudoMetricSpace β] [AddCommMonoid β] [LipschitzAdd β]\n\n@[to_additive]\ninstance : AddCommMonoid (α →ᵇ β) :=\n  { BoundedContinuousFunction.addMonoid with add_comm := fun f g => by ext <;> simp [add_comm] }\n\nopen BigOperators\n\n@[simp]\ntheorem coe_sum {ι : Type _} (s : Finset ι) (f : ι → α →ᵇ β) :\n    ⇑(∑ i in s, f i) = ∑ i in s, (f i : α → β) :=\n  (@coeFnAddHom α β _ _ _ _).map_sum f s\n#align bounded_continuous_function.coe_sum BoundedContinuousFunction.coe_sum\n\ntheorem sum_apply {ι : Type _} (s : Finset ι) (f : ι → α →ᵇ β) (a : α) :\n    (∑ i in s, f i) a = ∑ i in s, f i a := by simp\n#align bounded_continuous_function.sum_apply BoundedContinuousFunction.sum_apply\n\nend CommHasLipschitzAdd\n\nsection NormedAddCommGroup\n\n/- In this section, if β is a normed group, then we show that the space of bounded\ncontinuous functions from α to β inherits a normed group structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\nvariable [TopologicalSpace α] [SeminormedAddCommGroup β]\n\nvariable (f g : α →ᵇ β) {x : α} {C : ℝ}\n\ninstance : Norm (α →ᵇ β) :=\n  ⟨fun u => dist u 0⟩\n\ntheorem norm_def : ‖f‖ = dist f 0 :=\n  rfl\n#align bounded_continuous_function.norm_def BoundedContinuousFunction.norm_def\n\n/-- The norm of a bounded continuous function is the supremum of `‖f x‖`.\nWe use `Inf` to ensure that the definition works if `α` has no elements. -/\ntheorem norm_eq (f : α →ᵇ β) : ‖f‖ = infₛ { C : ℝ | 0 ≤ C ∧ ∀ x : α, ‖f x‖ ≤ C } := by\n  simp [norm_def, BoundedContinuousFunction.dist_eq]\n#align bounded_continuous_function.norm_eq BoundedContinuousFunction.norm_eq\n\n/-- When the domain is non-empty, we do not need the `0 ≤ C` condition in the formula for ‖f‖ as an\n`Inf`. -/\ntheorem norm_eq_of_nonempty [h : Nonempty α] : ‖f‖ = infₛ { C : ℝ | ∀ x : α, ‖f x‖ ≤ C } :=\n  by\n  obtain ⟨a⟩ := h\n  rw [norm_eq]\n  congr\n  ext\n  simp only [and_iff_right_iff_imp]\n  exact fun h' => le_trans (norm_nonneg (f a)) (h' a)\n#align bounded_continuous_function.norm_eq_of_nonempty BoundedContinuousFunction.norm_eq_of_nonempty\n\n@[simp]\ntheorem norm_eq_zero_of_empty [h : IsEmpty α] : ‖f‖ = 0 :=\n  dist_zero_of_empty\n#align bounded_continuous_function.norm_eq_zero_of_empty BoundedContinuousFunction.norm_eq_zero_of_empty\n\ntheorem norm_coe_le_norm (x : α) : ‖f x‖ ≤ ‖f‖ :=\n  calc\n    ‖f x‖ = dist (f x) ((0 : α →ᵇ β) x) := by simp [dist_zero_right]\n    _ ≤ ‖f‖ := dist_coe_le_dist _\n    \n#align bounded_continuous_function.norm_coe_le_norm BoundedContinuousFunction.norm_coe_le_norm\n\ntheorem dist_le_two_norm' {f : γ → β} {C : ℝ} (hC : ∀ x, ‖f x‖ ≤ C) (x y : γ) :\n    dist (f x) (f y) ≤ 2 * C :=\n  calc\n    dist (f x) (f y) ≤ ‖f x‖ + ‖f y‖ := dist_le_norm_add_norm _ _\n    _ ≤ C + C := (add_le_add (hC x) (hC y))\n    _ = 2 * C := (two_mul _).symm\n    \n#align bounded_continuous_function.dist_le_two_norm' BoundedContinuousFunction.dist_le_two_norm'\n\n/-- Distance between the images of any two points is at most twice the norm of the function. -/\ntheorem dist_le_two_norm (x y : α) : dist (f x) (f y) ≤ 2 * ‖f‖ :=\n  dist_le_two_norm' f.norm_coe_le_norm x y\n#align bounded_continuous_function.dist_le_two_norm BoundedContinuousFunction.dist_le_two_norm\n\nvariable {f}\n\n/-- The norm of a function is controlled by the supremum of the pointwise norms -/\ntheorem norm_le (C0 : (0 : ℝ) ≤ C) : ‖f‖ ≤ C ↔ ∀ x : α, ‖f x‖ ≤ C := by\n  simpa using @dist_le _ _ _ _ f 0 _ C0\n#align bounded_continuous_function.norm_le BoundedContinuousFunction.norm_le\n\ntheorem norm_le_of_nonempty [Nonempty α] {f : α →ᵇ β} {M : ℝ} : ‖f‖ ≤ M ↔ ∀ x, ‖f x‖ ≤ M :=\n  by\n  simp_rw [norm_def, ← dist_zero_right]\n  exact dist_le_iff_of_nonempty\n#align bounded_continuous_function.norm_le_of_nonempty BoundedContinuousFunction.norm_le_of_nonempty\n\ntheorem norm_lt_iff_of_compact [CompactSpace α] {f : α →ᵇ β} {M : ℝ} (M0 : 0 < M) :\n    ‖f‖ < M ↔ ∀ x, ‖f x‖ < M :=\n  by\n  simp_rw [norm_def, ← dist_zero_right]\n  exact dist_lt_iff_of_compact M0\n#align bounded_continuous_function.norm_lt_iff_of_compact BoundedContinuousFunction.norm_lt_iff_of_compact\n\ntheorem norm_lt_iff_of_nonempty_compact [Nonempty α] [CompactSpace α] {f : α →ᵇ β} {M : ℝ} :\n    ‖f‖ < M ↔ ∀ x, ‖f x‖ < M :=\n  by\n  simp_rw [norm_def, ← dist_zero_right]\n  exact dist_lt_iff_of_nonempty_compact\n#align bounded_continuous_function.norm_lt_iff_of_nonempty_compact BoundedContinuousFunction.norm_lt_iff_of_nonempty_compact\n\nvariable (f)\n\n/-- Norm of `const α b` is less than or equal to `‖b‖`. If `α` is nonempty,\nthen it is equal to `‖b‖`. -/\ntheorem norm_const_le (b : β) : ‖const α b‖ ≤ ‖b‖ :=\n  (norm_le (norm_nonneg b)).2 fun x => le_rfl\n#align bounded_continuous_function.norm_const_le BoundedContinuousFunction.norm_const_le\n\n@[simp]\ntheorem norm_const_eq [h : Nonempty α] (b : β) : ‖const α b‖ = ‖b‖ :=\n  le_antisymm (norm_const_le b) <| h.elim fun x => (const α b).norm_coe_le_norm x\n#align bounded_continuous_function.norm_const_eq BoundedContinuousFunction.norm_const_eq\n\n/-- Constructing a bounded continuous function from a uniformly bounded continuous\nfunction taking values in a normed group. -/\ndef ofNormedAddCommGroup {α : Type u} {β : Type v} [TopologicalSpace α] [SeminormedAddCommGroup β]\n    (f : α → β) (Hf : Continuous f) (C : ℝ) (H : ∀ x, ‖f x‖ ≤ C) : α →ᵇ β :=\n  ⟨⟨fun n => f n, Hf⟩, ⟨_, dist_le_two_norm' H⟩⟩\n#align bounded_continuous_function.of_normed_add_comm_group BoundedContinuousFunction.ofNormedAddCommGroup\n\n@[simp]\ntheorem coe_ofNormedAddCommGroup {α : Type u} {β : Type v} [TopologicalSpace α]\n    [SeminormedAddCommGroup β] (f : α → β) (Hf : Continuous f) (C : ℝ) (H : ∀ x, ‖f x‖ ≤ C) :\n    (ofNormedAddCommGroup f Hf C H : α → β) = f :=\n  rfl\n#align bounded_continuous_function.coe_of_normed_add_comm_group BoundedContinuousFunction.coe_ofNormedAddCommGroup\n\ntheorem norm_ofNormedAddCommGroup_le {f : α → β} (hfc : Continuous f) {C : ℝ} (hC : 0 ≤ C)\n    (hfC : ∀ x, ‖f x‖ ≤ C) : ‖ofNormedAddCommGroup f hfc C hfC‖ ≤ C :=\n  (norm_le hC).2 hfC\n#align bounded_continuous_function.norm_of_normed_add_comm_group_le BoundedContinuousFunction.norm_ofNormedAddCommGroup_le\n\n/-- Constructing a bounded continuous function from a uniformly bounded\nfunction on a discrete space, taking values in a normed group -/\ndef ofNormedAddCommGroupDiscrete {α : Type u} {β : Type v} [TopologicalSpace α] [DiscreteTopology α]\n    [SeminormedAddCommGroup β] (f : α → β) (C : ℝ) (H : ∀ x, norm (f x) ≤ C) : α →ᵇ β :=\n  ofNormedAddCommGroup f continuous_of_discreteTopology C H\n#align bounded_continuous_function.of_normed_add_comm_group_discrete BoundedContinuousFunction.ofNormedAddCommGroupDiscrete\n\n@[simp]\ntheorem coe_ofNormedAddCommGroupDiscrete {α : Type u} {β : Type v} [TopologicalSpace α]\n    [DiscreteTopology α] [SeminormedAddCommGroup β] (f : α → β) (C : ℝ) (H : ∀ x, ‖f x‖ ≤ C) :\n    (ofNormedAddCommGroupDiscrete f C H : α → β) = f :=\n  rfl\n#align bounded_continuous_function.coe_of_normed_add_comm_group_discrete BoundedContinuousFunction.coe_ofNormedAddCommGroupDiscrete\n\n/-- Taking the pointwise norm of a bounded continuous function with values in a\n`seminormed_add_comm_group` yields a bounded continuous function with values in ℝ. -/\ndef normComp : α →ᵇ ℝ :=\n  f.comp norm lipschitzWith_one_norm\n#align bounded_continuous_function.norm_comp BoundedContinuousFunction.normComp\n\n@[simp]\ntheorem coe_normComp : (f.normComp : α → ℝ) = norm ∘ f :=\n  rfl\n#align bounded_continuous_function.coe_norm_comp BoundedContinuousFunction.coe_normComp\n\n@[simp]\ntheorem norm_normComp : ‖f.normComp‖ = ‖f‖ := by simp only [norm_eq, coe_norm_comp, norm_norm]\n#align bounded_continuous_function.norm_norm_comp BoundedContinuousFunction.norm_normComp\n\ntheorem bddAbove_range_norm_comp : BddAbove <| Set.range <| norm ∘ f :=\n  (Real.bounded_iff_bddBelow_bddAbove.mp <| @bounded_range _ _ _ _ f.normComp).2\n#align bounded_continuous_function.bdd_above_range_norm_comp BoundedContinuousFunction.bddAbove_range_norm_comp\n\ntheorem norm_eq_supᵢ_norm : ‖f‖ = ⨆ x : α, ‖f x‖ := by\n  simp_rw [norm_def, dist_eq_supr, coe_zero, Pi.zero_apply, dist_zero_right]\n#align bounded_continuous_function.norm_eq_supr_norm BoundedContinuousFunction.norm_eq_supᵢ_norm\n\n/-- If `‖(1 : β)‖ = 1`, then `‖(1 : α →ᵇ β)‖ = 1` if `α` is nonempty. -/\ninstance [Nonempty α] [One β] [NormOneClass β] : NormOneClass (α →ᵇ β)\n    where norm_one := by simp only [norm_eq_supr_norm, coe_one, Pi.one_apply, norm_one, csupᵢ_const]\n\n/-- The pointwise opposite of a bounded continuous function is again bounded continuous. -/\ninstance : Neg (α →ᵇ β) :=\n  ⟨fun f =>\n    ofNormedAddCommGroup (-f) f.Continuous.neg ‖f‖ fun x =>\n      trans_rel_right _ (norm_neg _) (f.norm_coe_le_norm x)⟩\n\n/-- The pointwise difference of two bounded continuous functions is again bounded continuous. -/\ninstance : Sub (α →ᵇ β) :=\n  ⟨fun f g =>\n    ofNormedAddCommGroup (f - g) (f.Continuous.sub g.Continuous) (‖f‖ + ‖g‖) fun x =>\n      by\n      simp only [sub_eq_add_neg]\n      exact\n        le_trans (norm_add_le _ _)\n          (add_le_add (f.norm_coe_le_norm x) <|\n            trans_rel_right _ (norm_neg _) (g.norm_coe_le_norm x))⟩\n\n@[simp]\ntheorem coe_neg : ⇑(-f) = -f :=\n  rfl\n#align bounded_continuous_function.coe_neg BoundedContinuousFunction.coe_neg\n\ntheorem neg_apply : (-f) x = -f x :=\n  rfl\n#align bounded_continuous_function.neg_apply BoundedContinuousFunction.neg_apply\n\n@[simp]\ntheorem coe_sub : ⇑(f - g) = f - g :=\n  rfl\n#align bounded_continuous_function.coe_sub BoundedContinuousFunction.coe_sub\n\ntheorem sub_apply : (f - g) x = f x - g x :=\n  rfl\n#align bounded_continuous_function.sub_apply BoundedContinuousFunction.sub_apply\n\n@[simp]\ntheorem mkOfCompact_neg [CompactSpace α] (f : C(α, β)) : mkOfCompact (-f) = -mkOfCompact f :=\n  rfl\n#align bounded_continuous_function.mk_of_compact_neg BoundedContinuousFunction.mkOfCompact_neg\n\n@[simp]\ntheorem mkOfCompact_sub [CompactSpace α] (f g : C(α, β)) :\n    mkOfCompact (f - g) = mkOfCompact f - mkOfCompact g :=\n  rfl\n#align bounded_continuous_function.mk_of_compact_sub BoundedContinuousFunction.mkOfCompact_sub\n\n@[simp]\ntheorem coe_zsmulRec : ∀ z, ⇑(zsmulRec z f) = z • f\n  | Int.ofNat n => by rw [zsmulRec, Int.ofNat_eq_coe, coe_nsmul_rec, coe_nat_zsmul]\n  | -[n+1] => by rw [zsmulRec, negSucc_zsmul, coe_neg, coe_nsmul_rec]\n#align bounded_continuous_function.coe_zsmul_rec BoundedContinuousFunction.coe_zsmulRec\n\ninstance hasIntScalar : SMul ℤ (α →ᵇ β)\n    where smul n f :=\n    { toContinuousMap := n • f.toContinuousMap\n      map_bounded' := by simpa using (zsmulRec n f).map_bounded' }\n#align bounded_continuous_function.has_int_scalar BoundedContinuousFunction.hasIntScalar\n\n@[simp]\ntheorem coe_zsmul (r : ℤ) (f : α →ᵇ β) : ⇑(r • f) = r • f :=\n  rfl\n#align bounded_continuous_function.coe_zsmul BoundedContinuousFunction.coe_zsmul\n\n@[simp]\ntheorem zsmul_apply (r : ℤ) (f : α →ᵇ β) (v : α) : (r • f) v = r • f v :=\n  rfl\n#align bounded_continuous_function.zsmul_apply BoundedContinuousFunction.zsmul_apply\n\ninstance : AddCommGroup (α →ᵇ β) :=\n  FunLike.coe_injective.AddCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _)\n    fun _ _ => coe_zsmul _ _\n\ninstance : SeminormedAddCommGroup (α →ᵇ β)\n    where dist_eq f g := by simp only [norm_eq, dist_eq, dist_eq_norm, sub_apply]\n\ninstance {α β} [TopologicalSpace α] [NormedAddCommGroup β] : NormedAddCommGroup (α →ᵇ β) :=\n  { BoundedContinuousFunction.seminormedAddCommGroup with }\n\ntheorem nnnorm_def : ‖f‖₊ = nndist f 0 :=\n  rfl\n#align bounded_continuous_function.nnnorm_def BoundedContinuousFunction.nnnorm_def\n\ntheorem nnnorm_coe_le_nnnorm (x : α) : ‖f x‖₊ ≤ ‖f‖₊ :=\n  norm_coe_le_norm _ _\n#align bounded_continuous_function.nnnorm_coe_le_nnnorm BoundedContinuousFunction.nnnorm_coe_le_nnnorm\n\ntheorem nndist_le_two_nnnorm (x y : α) : nndist (f x) (f y) ≤ 2 * ‖f‖₊ :=\n  dist_le_two_norm _ _ _\n#align bounded_continuous_function.nndist_le_two_nnnorm BoundedContinuousFunction.nndist_le_two_nnnorm\n\n/-- The nnnorm of a function is controlled by the supremum of the pointwise nnnorms -/\ntheorem nnnorm_le (C : ℝ≥0) : ‖f‖₊ ≤ C ↔ ∀ x : α, ‖f x‖₊ ≤ C :=\n  norm_le C.Prop\n#align bounded_continuous_function.nnnorm_le BoundedContinuousFunction.nnnorm_le\n\ntheorem nnnorm_const_le (b : β) : ‖const α b‖₊ ≤ ‖b‖₊ :=\n  norm_const_le _\n#align bounded_continuous_function.nnnorm_const_le BoundedContinuousFunction.nnnorm_const_le\n\n@[simp]\ntheorem nnnorm_const_eq [h : Nonempty α] (b : β) : ‖const α b‖₊ = ‖b‖₊ :=\n  Subtype.ext <| norm_const_eq _\n#align bounded_continuous_function.nnnorm_const_eq BoundedContinuousFunction.nnnorm_const_eq\n\ntheorem nnnorm_eq_supᵢ_nnnorm : ‖f‖₊ = ⨆ x : α, ‖f x‖₊ :=\n  Subtype.ext <| (norm_eq_supᵢ_norm f).trans <| by simp_rw [NNReal.coe_supᵢ, coe_nnnorm]\n#align bounded_continuous_function.nnnorm_eq_supr_nnnorm BoundedContinuousFunction.nnnorm_eq_supᵢ_nnnorm\n\ntheorem abs_diff_coe_le_dist : ‖f x - g x‖ ≤ dist f g :=\n  by\n  rw [dist_eq_norm]\n  exact (f - g).norm_coe_le_norm x\n#align bounded_continuous_function.abs_diff_coe_le_dist BoundedContinuousFunction.abs_diff_coe_le_dist\n\ntheorem coe_le_coe_add_dist {f g : α →ᵇ ℝ} : f x ≤ g x + dist f g :=\n  sub_le_iff_le_add'.1 <| (abs_le.1 <| @dist_coe_le_dist _ _ _ _ f g x).2\n#align bounded_continuous_function.coe_le_coe_add_dist BoundedContinuousFunction.coe_le_coe_add_dist\n\ntheorem norm_compContinuous_le [TopologicalSpace γ] (f : α →ᵇ β) (g : C(γ, α)) :\n    ‖f.comp_continuous g‖ ≤ ‖f‖ :=\n  ((lipschitz_compContinuous g).dist_le_mul f 0).trans <| by\n    rw [NNReal.coe_one, one_mul, dist_zero_right]\n#align bounded_continuous_function.norm_comp_continuous_le BoundedContinuousFunction.norm_compContinuous_le\n\nend NormedAddCommGroup\n\nsection BoundedSMul\n\n/-!\n### `has_bounded_smul` (in particular, topological module) structure\n\nIn this section, if `β` is a metric space and a `𝕜`-module whose addition and scalar multiplication\nare compatible with the metric structure, then we show that the space of bounded continuous\nfunctions from `α` to `β` inherits a so-called `has_bounded_smul` structure (in particular, a\n`has_continuous_mul` structure, which is the mathlib formulation of being a topological module), by\nusing pointwise operations and checking that they are compatible with the uniform distance. -/\n\n\nvariable {𝕜 : Type _} [PseudoMetricSpace 𝕜] [TopologicalSpace α] [PseudoMetricSpace β]\n\nsection SMul\n\nvariable [Zero 𝕜] [Zero β] [SMul 𝕜 β] [BoundedSMul 𝕜 β]\n\ninstance : SMul 𝕜 (α →ᵇ β)\n    where smul c f :=\n    { toContinuousMap := c • f.toContinuousMap\n      map_bounded' :=\n        let ⟨b, hb⟩ := f.Bounded\n        ⟨dist c 0 * b, fun x y =>\n          by\n          refine' (dist_smul_pair c (f x) (f y)).trans _\n          refine' mul_le_mul_of_nonneg_left _ dist_nonneg\n          exact hb x y⟩ }\n\n@[simp]\ntheorem coe_smul (c : 𝕜) (f : α →ᵇ β) : ⇑(c • f) = fun x => c • f x :=\n  rfl\n#align bounded_continuous_function.coe_smul BoundedContinuousFunction.coe_smul\n\ntheorem smul_apply (c : 𝕜) (f : α →ᵇ β) (x : α) : (c • f) x = c • f x :=\n  rfl\n#align bounded_continuous_function.smul_apply BoundedContinuousFunction.smul_apply\n\ninstance [SMul 𝕜ᵐᵒᵖ β] [IsCentralScalar 𝕜 β] : IsCentralScalar 𝕜 (α →ᵇ β)\n    where op_smul_eq_smul _ _ := ext fun _ => op_smul_eq_smul _ _\n\ninstance : BoundedSMul 𝕜 (α →ᵇ β)\n    where\n  dist_smul_pair' c f₁ f₂ :=\n    by\n    rw [dist_le (mul_nonneg dist_nonneg dist_nonneg)]\n    intro x\n    refine' (dist_smul_pair c (f₁ x) (f₂ x)).trans _\n    exact mul_le_mul_of_nonneg_left (dist_coe_le_dist x) dist_nonneg\n  dist_pair_smul' c₁ c₂ f :=\n    by\n    rw [dist_le (mul_nonneg dist_nonneg dist_nonneg)]\n    intro x\n    refine' (dist_pair_smul c₁ c₂ (f x)).trans _\n    convert mul_le_mul_of_nonneg_left (dist_coe_le_dist x) dist_nonneg\n    simp\n\nend SMul\n\nsection MulAction\n\nvariable [MonoidWithZero 𝕜] [Zero β] [MulAction 𝕜 β] [BoundedSMul 𝕜 β]\n\ninstance : MulAction 𝕜 (α →ᵇ β) :=\n  FunLike.coe_injective.MulAction _ coe_smul\n\nend MulAction\n\nsection DistribMulAction\n\nvariable [MonoidWithZero 𝕜] [AddMonoid β] [DistribMulAction 𝕜 β] [BoundedSMul 𝕜 β]\n\nvariable [LipschitzAdd β]\n\ninstance : DistribMulAction 𝕜 (α →ᵇ β) :=\n  Function.Injective.distribMulAction ⟨_, coe_zero, coe_add⟩ FunLike.coe_injective coe_smul\n\nend DistribMulAction\n\nsection Module\n\nvariable [Semiring 𝕜] [AddCommMonoid β] [Module 𝕜 β] [BoundedSMul 𝕜 β]\n\nvariable {f g : α →ᵇ β} {x : α} {C : ℝ}\n\nvariable [LipschitzAdd β]\n\ninstance : Module 𝕜 (α →ᵇ β) :=\n  Function.Injective.module _ ⟨_, coe_zero, coe_add⟩ FunLike.coe_injective coe_smul\n\nvariable (𝕜)\n\n/-- The evaluation at a point, as a continuous linear map from `α →ᵇ β` to `β`. -/\ndef evalClm (x : α) : (α →ᵇ β) →L[𝕜] β where\n  toFun f := f x\n  map_add' f g := add_apply _ _\n  map_smul' c f := smul_apply _ _ _\n#align bounded_continuous_function.eval_clm BoundedContinuousFunction.evalClm\n\n@[simp]\ntheorem evalClm_apply (x : α) (f : α →ᵇ β) : evalClm 𝕜 x f = f x :=\n  rfl\n#align bounded_continuous_function.eval_clm_apply BoundedContinuousFunction.evalClm_apply\n\nvariable (α β)\n\n/-- The linear map forgetting that a bounded continuous function is bounded. -/\n@[simps]\ndef toContinuousMapLinearMap : (α →ᵇ β) →ₗ[𝕜] C(α, β)\n    where\n  toFun := toContinuousMap\n  map_smul' f g := rfl\n  map_add' c f := rfl\n#align bounded_continuous_function.to_continuous_map_linear_map BoundedContinuousFunction.toContinuousMapLinearMap\n\nend Module\n\nend BoundedSMul\n\nsection NormedSpace\n\n/-!\n### Normed space structure\n\nIn this section, if `β` is a normed space, then we show that the space of bounded\ncontinuous functions from `α` to `β` inherits a normed space structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\n\n\nvariable {𝕜 : Type _}\n\nvariable [TopologicalSpace α] [SeminormedAddCommGroup β]\n\nvariable {f g : α →ᵇ β} {x : α} {C : ℝ}\n\ninstance [NormedField 𝕜] [NormedSpace 𝕜 β] : NormedSpace 𝕜 (α →ᵇ β) :=\n  ⟨fun c f =>\n    by\n    refine' norm_of_normed_add_comm_group_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) _\n    exact fun x =>\n      trans_rel_right _ (norm_smul _ _)\n        (mul_le_mul_of_nonneg_left (f.norm_coe_le_norm _) (norm_nonneg _))⟩\n\nvariable [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 β]\n\nvariable [SeminormedAddCommGroup γ] [NormedSpace 𝕜 γ]\n\nvariable (α)\n\n-- TODO does this work in the `has_bounded_smul` setting, too?\n/--\nPostcomposition of bounded continuous functions into a normed module by a continuous linear map is\na continuous linear map.\nUpgraded version of `continuous_linear_map.comp_left_continuous`, similar to\n`linear_map.comp_left`. -/\nprotected def ContinuousLinearMap.compLeftContinuousBounded (g : β →L[𝕜] γ) :\n    (α →ᵇ β) →L[𝕜] α →ᵇ γ :=\n  LinearMap.mkContinuous\n    { toFun := fun f =>\n        ofNormedAddCommGroup (g ∘ f) (g.Continuous.comp f.Continuous) (‖g‖ * ‖f‖) fun x =>\n          g.le_op_norm_of_le (f.norm_coe_le_norm x)\n      map_add' := fun f g => by ext <;> simp\n      map_smul' := fun c f => by ext <;> simp } ‖g‖ fun f =>\n    norm_ofNormedAddCommGroup_le _ (mul_nonneg (norm_nonneg g) (norm_nonneg f)) _\n#align continuous_linear_map.comp_left_continuous_bounded ContinuousLinearMap.compLeftContinuousBounded\n\n@[simp]\ntheorem ContinuousLinearMap.compLeftContinuousBounded_apply (g : β →L[𝕜] γ) (f : α →ᵇ β) (x : α) :\n    (g.compLeftContinuousBounded α f) x = g (f x) :=\n  rfl\n#align continuous_linear_map.comp_left_continuous_bounded_apply ContinuousLinearMap.compLeftContinuousBounded_apply\n\nend NormedSpace\n\nsection NormedRing\n\n/-!\n### Normed ring structure\n\nIn this section, if `R` is a normed ring, then we show that the space of bounded\ncontinuous functions from `α` to `R` inherits a normed ring structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\n\n\nvariable [TopologicalSpace α] {R : Type _}\n\nsection NonUnital\n\nsection SemiNormed\n\nvariable [NonUnitalSeminormedRing R]\n\ninstance : Mul (α →ᵇ R)\n    where mul f g :=\n    ofNormedAddCommGroup (f * g) (f.Continuous.mul g.Continuous) (‖f‖ * ‖g‖) fun x =>\n      le_trans (norm_mul_le (f x) (g x)) <|\n        mul_le_mul (f.norm_coe_le_norm x) (g.norm_coe_le_norm x) (norm_nonneg _) (norm_nonneg _)\n\n@[simp]\ntheorem coe_mul (f g : α →ᵇ R) : ⇑(f * g) = f * g :=\n  rfl\n#align bounded_continuous_function.coe_mul BoundedContinuousFunction.coe_mul\n\ntheorem mul_apply (f g : α →ᵇ R) (x : α) : (f * g) x = f x * g x :=\n  rfl\n#align bounded_continuous_function.mul_apply BoundedContinuousFunction.mul_apply\n\ninstance : NonUnitalRing (α →ᵇ R) :=\n  FunLike.coe_injective.NonUnitalRing _ coe_zero coe_add coe_mul coe_neg coe_sub\n    (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _\n\ninstance : NonUnitalSeminormedRing (α →ᵇ R) :=\n  { BoundedContinuousFunction.seminormedAddCommGroup with\n    norm_mul := fun f g =>\n      norm_ofNormedAddCommGroup_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) _ }\n\nend SemiNormed\n\ninstance [NonUnitalNormedRing R] : NonUnitalNormedRing (α →ᵇ R) :=\n  { BoundedContinuousFunction.nonUnitalSemiNormedRing,\n    BoundedContinuousFunction.normedAddCommGroup with }\n\nend NonUnital\n\nsection SemiNormed\n\nvariable [SeminormedRing R]\n\n@[simp]\ntheorem coe_npowRec (f : α →ᵇ R) : ∀ n, ⇑(npowRec n f) = f ^ n\n  | 0 => by rw [npowRec, pow_zero, coe_one]\n  | n + 1 => by rw [npowRec, pow_succ, coe_mul, coe_npow_rec]\n#align bounded_continuous_function.coe_npow_rec BoundedContinuousFunction.coe_npowRec\n\ninstance hasNatPow : Pow (α →ᵇ R) ℕ\n    where pow f n :=\n    { toContinuousMap := f.toContinuousMap ^ n\n      map_bounded' := by simpa [coe_npow_rec] using (npowRec n f).map_bounded' }\n#align bounded_continuous_function.has_nat_pow BoundedContinuousFunction.hasNatPow\n\n@[simp]\ntheorem coe_pow (n : ℕ) (f : α →ᵇ R) : ⇑(f ^ n) = f ^ n :=\n  rfl\n#align bounded_continuous_function.coe_pow BoundedContinuousFunction.coe_pow\n\n@[simp]\ntheorem pow_apply (n : ℕ) (f : α →ᵇ R) (v : α) : (f ^ n) v = f v ^ n :=\n  rfl\n#align bounded_continuous_function.pow_apply BoundedContinuousFunction.pow_apply\n\ninstance : NatCast (α →ᵇ R) :=\n  ⟨fun n => BoundedContinuousFunction.const _ n⟩\n\n@[simp, norm_cast]\ntheorem coe_nat_cast (n : ℕ) : ((n : α →ᵇ R) : α → R) = n :=\n  rfl\n#align bounded_continuous_function.coe_nat_cast BoundedContinuousFunction.coe_nat_cast\n\ninstance : IntCast (α →ᵇ R) :=\n  ⟨fun n => BoundedContinuousFunction.const _ n⟩\n\n@[simp, norm_cast]\ntheorem coe_int_cast (n : ℤ) : ((n : α →ᵇ R) : α → R) = n :=\n  rfl\n#align bounded_continuous_function.coe_int_cast BoundedContinuousFunction.coe_int_cast\n\ninstance : Ring (α →ᵇ R) :=\n  FunLike.coe_injective.Ring _ coe_zero coe_one coe_add coe_mul coe_neg coe_sub\n    (fun _ _ => coe_nsmul _ _) (fun _ _ => coe_zsmul _ _) (fun _ _ => coe_pow _ _) coe_nat_cast\n    coe_int_cast\n\ninstance : SeminormedRing (α →ᵇ R) :=\n  { BoundedContinuousFunction.nonUnitalSemiNormedRing with }\n\nend SemiNormed\n\ninstance [NormedRing R] : NormedRing (α →ᵇ R) :=\n  { BoundedContinuousFunction.nonUnitalNormedRing with }\n\nend NormedRing\n\nsection NormedCommRing\n\n/-!\n### Normed commutative ring structure\n\nIn this section, if `R` is a normed commutative ring, then we show that the space of bounded\ncontinuous functions from `α` to `R` inherits a normed commutative ring structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\n\n\nvariable [TopologicalSpace α] {R : Type _}\n\ninstance [SeminormedCommRing R] : CommRing (α →ᵇ R) :=\n  { BoundedContinuousFunction.ring with mul_comm := fun f₁ f₂ => ext fun x => mul_comm _ _ }\n\ninstance [SeminormedCommRing R] : SeminormedCommRing (α →ᵇ R) :=\n  { BoundedContinuousFunction.commRing, BoundedContinuousFunction.seminormedAddCommGroup with }\n\ninstance [NormedCommRing R] : NormedCommRing (α →ᵇ R) :=\n  { BoundedContinuousFunction.commRing, BoundedContinuousFunction.normedAddCommGroup with }\n\nend NormedCommRing\n\nsection NormedAlgebra\n\n/-!\n### Normed algebra structure\n\nIn this section, if `γ` is a normed algebra, then we show that the space of bounded\ncontinuous functions from `α` to `γ` inherits a normed algebra structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\n\n\nvariable {𝕜 : Type _} [NormedField 𝕜]\n\nvariable [TopologicalSpace α] [SeminormedAddCommGroup β] [NormedSpace 𝕜 β]\n\nvariable [NormedRing γ] [NormedAlgebra 𝕜 γ]\n\nvariable {f g : α →ᵇ γ} {x : α} {c : 𝕜}\n\n/-- `bounded_continuous_function.const` as a `ring_hom`. -/\ndef c : 𝕜 →+* α →ᵇ γ where\n  toFun := fun c : 𝕜 => const α ((algebraMap 𝕜 γ) c)\n  map_one' := ext fun x => (algebraMap 𝕜 γ).map_one\n  map_mul' c₁ c₂ := ext fun x => (algebraMap 𝕜 γ).map_mul _ _\n  map_zero' := ext fun x => (algebraMap 𝕜 γ).map_zero\n  map_add' c₁ c₂ := ext fun x => (algebraMap 𝕜 γ).map_add _ _\n#align bounded_continuous_function.C BoundedContinuousFunction.c\n\ninstance : Algebra 𝕜 (α →ᵇ γ) :=\n  { BoundedContinuousFunction.module,\n    BoundedContinuousFunction.ring with\n    toRingHom := c\n    commutes' := fun c f => ext fun x => Algebra.commutes' _ _\n    smul_def' := fun c f => ext fun x => Algebra.smul_def' _ _ }\n\n@[simp]\ntheorem algebraMap_apply (k : 𝕜) (a : α) : algebraMap 𝕜 (α →ᵇ γ) k a = k • 1 :=\n  by\n  rw [Algebra.algebraMap_eq_smul_one]\n  rfl\n#align bounded_continuous_function.algebra_map_apply BoundedContinuousFunction.algebraMap_apply\n\ninstance : NormedAlgebra 𝕜 (α →ᵇ γ) :=\n  { BoundedContinuousFunction.normedSpace with }\n\n/-!\n### Structure as normed module over scalar functions\n\nIf `β` is a normed `𝕜`-space, then we show that the space of bounded continuous\nfunctions from `α` to `β` is naturally a module over the algebra of bounded continuous\nfunctions from `α` to `𝕜`. -/\n\n\ninstance hasSmul' : SMul (α →ᵇ 𝕜) (α →ᵇ β) :=\n  ⟨fun (f : α →ᵇ 𝕜) (g : α →ᵇ β) =>\n    ofNormedAddCommGroup (fun x => f x • g x) (f.Continuous.smul g.Continuous) (‖f‖ * ‖g‖) fun x =>\n      calc\n        ‖f x • g x‖ ≤ ‖f x‖ * ‖g x‖ := norm_smul_le _ _\n        _ ≤ ‖f‖ * ‖g‖ :=\n          mul_le_mul (f.norm_coe_le_norm _) (g.norm_coe_le_norm _) (norm_nonneg _) (norm_nonneg _)\n        ⟩\n#align bounded_continuous_function.has_smul' BoundedContinuousFunction.hasSmul'\n\ninstance module' : Module (α →ᵇ 𝕜) (α →ᵇ β) :=\n  Module.ofCore <|\n    { smul := (· • ·)\n      smul_add := fun c f₁ f₂ => ext fun x => smul_add _ _ _\n      add_smul := fun c₁ c₂ f => ext fun x => add_smul _ _ _\n      mul_smul := fun c₁ c₂ f => ext fun x => mul_smul _ _ _\n      one_smul := fun f => ext fun x => one_smul 𝕜 (f x) }\n#align bounded_continuous_function.module' BoundedContinuousFunction.module'\n\ntheorem norm_smul_le (f : α →ᵇ 𝕜) (g : α →ᵇ β) : ‖f • g‖ ≤ ‖f‖ * ‖g‖ :=\n  norm_ofNormedAddCommGroup_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) _\n#align bounded_continuous_function.norm_smul_le BoundedContinuousFunction.norm_smul_le\n\n/- TODO: When `normed_module` has been added to `normed_space.basic`, the above facts\nshow that the space of bounded continuous functions from `α` to `β` is naturally a normed\nmodule over the algebra of bounded continuous functions from `α` to `𝕜`. -/\nend NormedAlgebra\n\ntheorem Nnreal.upper_bound {α : Type _} [TopologicalSpace α] (f : α →ᵇ ℝ≥0) (x : α) :\n    f x ≤ nndist f 0 :=\n  by\n  have key : nndist (f x) ((0 : α →ᵇ ℝ≥0) x) ≤ nndist f 0 := @dist_coe_le_dist α ℝ≥0 _ _ f 0 x\n  simp only [coe_zero, Pi.zero_apply] at key\n  rwa [NNReal.nndist_zero_eq_val' (f x)] at key\n#align bounded_continuous_function.nnreal.upper_bound BoundedContinuousFunction.Nnreal.upper_bound\n\n/-!\n### Star structures\n\nIn this section, if `β` is a normed ⋆-group, then so is the space of bounded\ncontinuous functions from `α` to `β`, by using the star operation pointwise.\n\nIf `𝕜` is normed field and a ⋆-ring over which `β` is a normed algebra and a\nstar module, then the space of bounded continuous functions from `α` to `β`\nis a star module.\n\nIf `β` is a ⋆-ring in addition to being a normed ⋆-group, then `α →ᵇ β`\ninherits a ⋆-ring structure.\n\nIn summary, if `β` is a C⋆-algebra over `𝕜`, then so is  `α →ᵇ β`; note that\ncompleteness is guaranteed when `β` is complete (see\n`bounded_continuous_function.complete`). -/\n\n\nsection NormedAddCommGroup\n\nvariable {𝕜 : Type _} [NormedField 𝕜] [StarRing 𝕜] [TopologicalSpace α] [SeminormedAddCommGroup β]\n  [StarAddMonoid β] [NormedStarGroup β]\n\nvariable [NormedSpace 𝕜 β] [StarModule 𝕜 β]\n\ninstance : StarAddMonoid (α →ᵇ β)\n    where\n  unit f := f.comp star starNormedAddGroupHom.lipschitz\n  star_involutive f := ext fun x => star_star (f x)\n  star_add f g := ext fun x => star_add (f x) (g x)\n\n/-- The right-hand side of this equality can be parsed `star ∘ ⇑f` because of the\ninstance `pi.has_star`. Upon inspecting the goal, one sees `⊢ ⇑(star f) = star ⇑f`.-/\n@[simp]\ntheorem coe_star (f : α →ᵇ β) : ⇑(star f) = star f :=\n  rfl\n#align bounded_continuous_function.coe_star BoundedContinuousFunction.coe_star\n\n@[simp]\ntheorem star_apply (f : α →ᵇ β) (x : α) : star f x = star (f x) :=\n  rfl\n#align bounded_continuous_function.star_apply BoundedContinuousFunction.star_apply\n\ninstance : NormedStarGroup (α →ᵇ β)\n    where norm_star f := by simp only [norm_eq, star_apply, norm_star]\n\ninstance : StarModule 𝕜 (α →ᵇ β) where star_smul k f := ext fun x => star_smul k (f x)\n\nend NormedAddCommGroup\n\nsection CstarRing\n\nvariable [TopologicalSpace α]\n\nvariable [NonUnitalNormedRing β] [StarRing β]\n\ninstance [NormedStarGroup β] : StarRing (α →ᵇ β) :=\n  { BoundedContinuousFunction.starAddMonoid with\n    star_mul := fun f g => ext fun x => star_mul (f x) (g x) }\n\nvariable [CstarRing β]\n\ninstance : CstarRing (α →ᵇ β)\n    where norm_star_mul_self := by\n    intro f\n    refine' le_antisymm _ _\n    · rw [← sq, norm_le (sq_nonneg _)]\n      dsimp [star_apply]\n      intro x\n      rw [CstarRing.norm_star_mul_self, ← sq]\n      refine' sq_le_sq' _ _\n      · linarith [norm_nonneg (f x), norm_nonneg f]\n      · exact norm_coe_le_norm f x\n    · rw [← sq, ← Real.le_sqrt (norm_nonneg _) (norm_nonneg _), norm_le (Real.sqrt_nonneg _)]\n      intro x\n      rw [Real.le_sqrt (norm_nonneg _) (norm_nonneg _), sq, ← CstarRing.norm_star_mul_self]\n      exact norm_coe_le_norm (star f * f) x\n\nend CstarRing\n\nsection NormedLatticeOrderedGroup\n\nvariable [TopologicalSpace α] [NormedLatticeAddCommGroup β]\n\ninstance : PartialOrder (α →ᵇ β) :=\n  PartialOrder.lift (fun f => f.toFun) (by tidy)\n\n/-- Continuous normed lattice group valued functions form a meet-semilattice\n-/\ninstance : SemilatticeInf (α →ᵇ β) :=\n  {\n    BoundedContinuousFunction.partialOrder with\n    inf := fun f g =>\n      { toFun := fun t => f t ⊓ g t\n        continuous_toFun := f.Continuous.inf g.Continuous\n        map_bounded' := by\n          obtain ⟨C₁, hf⟩ := f.bounded\n          obtain ⟨C₂, hg⟩ := g.bounded\n          refine' ⟨C₁ + C₂, fun x y => _⟩\n          simp_rw [NormedAddCommGroup.dist_eq] at hf hg⊢\n          exact (norm_inf_sub_inf_le_add_norm _ _ _ _).trans (add_le_add (hf _ _) (hg _ _)) }\n    inf_le_left := fun f g => ContinuousMap.le_def.mpr fun _ => inf_le_left\n    inf_le_right := fun f g => ContinuousMap.le_def.mpr fun _ => inf_le_right\n    le_inf := fun f g₁ g₂ w₁ w₂ =>\n      ContinuousMap.le_def.mpr fun _ =>\n        le_inf (ContinuousMap.le_def.mp w₁ _) (ContinuousMap.le_def.mp w₂ _) }\n\ninstance : SemilatticeSup (α →ᵇ β) :=\n  {\n    BoundedContinuousFunction.partialOrder with\n    sup := fun f g =>\n      { toFun := fun t => f t ⊔ g t\n        continuous_toFun := f.Continuous.sup g.Continuous\n        map_bounded' := by\n          obtain ⟨C₁, hf⟩ := f.bounded\n          obtain ⟨C₂, hg⟩ := g.bounded\n          refine' ⟨C₁ + C₂, fun x y => _⟩\n          simp_rw [NormedAddCommGroup.dist_eq] at hf hg⊢\n          exact (norm_sup_sub_sup_le_add_norm _ _ _ _).trans (add_le_add (hf _ _) (hg _ _)) }\n    le_sup_left := fun f g => ContinuousMap.le_def.mpr fun _ => le_sup_left\n    le_sup_right := fun f g => ContinuousMap.le_def.mpr fun _ => le_sup_right\n    sup_le := fun f g₁ g₂ w₁ w₂ =>\n      ContinuousMap.le_def.mpr fun _ =>\n        sup_le (ContinuousMap.le_def.mp w₁ _) (ContinuousMap.le_def.mp w₂ _) }\n\ninstance : Lattice (α →ᵇ β) :=\n  { BoundedContinuousFunction.semilatticeSup, BoundedContinuousFunction.semilatticeInf with }\n\n@[simp]\ntheorem coeFn_sup (f g : α →ᵇ β) : ⇑(f ⊔ g) = f ⊔ g :=\n  rfl\n#align bounded_continuous_function.coe_fn_sup BoundedContinuousFunction.coeFn_sup\n\n@[simp]\ntheorem coeFn_abs (f : α →ᵇ β) : ⇑(|f|) = |f| :=\n  rfl\n#align bounded_continuous_function.coe_fn_abs BoundedContinuousFunction.coeFn_abs\n\ninstance : NormedLatticeAddCommGroup (α →ᵇ β) :=\n  { BoundedContinuousFunction.lattice,\n    BoundedContinuousFunction.seminormedAddCommGroup with\n    add_le_add_left := by\n      intro f g h₁ h t\n      simp only [coe_to_continuous_fun, Pi.add_apply, add_le_add_iff_left, coe_add,\n        ContinuousMap.toFun_eq_coe]\n      exact h₁ _\n    solid := by\n      intro f g h\n      have i1 : ∀ t, ‖f t‖ ≤ ‖g t‖ := fun t => solid (h t)\n      rw [norm_le (norm_nonneg _)]\n      exact fun t => (i1 t).trans (norm_coe_le_norm g t) }\n\nend NormedLatticeOrderedGroup\n\nsection NonnegativePart\n\nvariable [TopologicalSpace α]\n\n/-- The nonnegative part of a bounded continuous `ℝ`-valued function as a bounded\ncontinuous `ℝ≥0`-valued function. -/\ndef nnrealPart (f : α →ᵇ ℝ) : α →ᵇ ℝ≥0 :=\n  BoundedContinuousFunction.comp _ (show LipschitzWith 1 Real.toNNReal from lipschitzWith_pos) f\n#align bounded_continuous_function.nnreal_part BoundedContinuousFunction.nnrealPart\n\n@[simp]\ntheorem nnrealPart_coe_fun_eq (f : α →ᵇ ℝ) : ⇑f.nnrealPart = Real.toNNReal ∘ ⇑f :=\n  rfl\n#align bounded_continuous_function.nnreal_part_coe_fun_eq BoundedContinuousFunction.nnrealPart_coe_fun_eq\n\n/-- The absolute value of a bounded continuous `ℝ`-valued function as a bounded\ncontinuous `ℝ≥0`-valued function. -/\ndef nnnorm (f : α →ᵇ ℝ) : α →ᵇ ℝ≥0 :=\n  BoundedContinuousFunction.comp _\n    (show LipschitzWith 1 fun x : ℝ => ‖x‖₊ from lipschitzWith_one_norm) f\n#align bounded_continuous_function.nnnorm BoundedContinuousFunction.nnnorm\n\n@[simp]\ntheorem nnnorm_coe_fun_eq (f : α →ᵇ ℝ) : ⇑f.nnnorm = NNNorm.nnnorm ∘ ⇑f :=\n  rfl\n#align bounded_continuous_function.nnnorm_coe_fun_eq BoundedContinuousFunction.nnnorm_coe_fun_eq\n\n/-- Decompose a bounded continuous function to its positive and negative parts. -/\ntheorem self_eq_nnrealPart_sub_nnrealPart_neg (f : α →ᵇ ℝ) :\n    ⇑f = coe ∘ f.nnrealPart - coe ∘ (-f).nnrealPart :=\n  by\n  funext x\n  dsimp\n  simp only [max_zero_sub_max_neg_zero_eq_self]\n#align bounded_continuous_function.self_eq_nnreal_part_sub_nnreal_part_neg BoundedContinuousFunction.self_eq_nnrealPart_sub_nnrealPart_neg\n\n/-- Express the absolute value of a bounded continuous function in terms of its\npositive and negative parts. -/\ntheorem abs_self_eq_nnrealPart_add_nnrealPart_neg (f : α →ᵇ ℝ) :\n    abs ∘ ⇑f = coe ∘ f.nnrealPart + coe ∘ (-f).nnrealPart :=\n  by\n  funext x\n  dsimp\n  simp only [max_zero_add_max_neg_zero_eq_abs_self]\n#align bounded_continuous_function.abs_self_eq_nnreal_part_add_nnreal_part_neg BoundedContinuousFunction.abs_self_eq_nnrealPart_add_nnrealPart_neg\n\nend NonnegativePart\n\nend BoundedContinuousFunction\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/ContinuousFunction/Bounded.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384735, "lm_q2_score": 0.6187804267137442, "lm_q1q2_score": 0.48593357256539127}}
{"text": "-- Needed for sheaves temporarily\nimport analysis.topology.topological_space\n\n-- Auxiliary lemmas\n\nlemma exists_and_commute {α : Type} {p q r: α → Prop} : \n(∃! a : α, r a ∧ p a ∧ q a) → ∃! a : α, r a ∧ q a ∧ p a :=\n    λ ⟨a, ⟨b, c ⟩⟩, \n    begin \n        existsi a,\n        simp at *,\n        exact ⟨b.symm.2, b.symm.1.1 ,b.symm.1.2 ,λ y g h, c y g h⟩ \n    end\n\n-- Categories and functors\n\nstructure Category (type : Type) :=\n(obj : type → Prop)\n(mor : type  → type → (type → type) → Prop)\n(associativity : ∀ a b c, ∀ f g : type → type, mor a b f → mor b c g → mor a c (g ∘ f))\n(identity: ∀ a, obj a → mor a a id)\n\nstructure Functor {a b : Type} (C1: Category a) (C2: Category b) : Type :=\n(obj_map: a → b)\n(mor_map: (a → a) → (b → b))\n(respect_obj: ∀ x, C1.obj x → C2.obj (obj_map x))\n(respect_id : mor_map id = id)\n(respect_mor: ∀ x y z, C1.mor x y z →  C2.mor (obj_map x) (obj_map y) (mor_map z))\n(respect_composition: ∀ f g: a → a, mor_map (f ∘ g) = mor_map f ∘ mor_map g)\n\nstructure Contravariant_Functor {a b : Type} (C1: Category a) (C2: Category b) : Type :=\n(obj_map: a → b)\n(mor_map: (a → a) → (b → b))\n(respect_obj: ∀ x, C1.obj x → C2.obj (obj_map x))\n(respect_id : mor_map id = id)\n(swap_mor: ∀ x y z, C1.mor x y z →  C2.mor (obj_map y) (obj_map x) (mor_map z))\n(respect_composition: ∀ f g: a → a, mor_map (f ∘ g) = mor_map g ∘ mor_map f)\n\n-- Notions of isomorphims\n\ndefinition isomorphism {a: Type} (x : Category a) (f: a → a) (b c: a)\n    := ∃ g : a → a, f ∘ g = id ∧ g ∘ f = id ∧ x.mor b c f ∧ x.mor c b g\n\ndefinition isomorphic {a: Type} (x : Category a) (b c : a) \n    := ∃ f : a → a, isomorphism x f b c\n\n-- Category description of groups, groupoids and monoids\n\nstructure Groupoid (a: Type) extends x : Category a :=\n(isomorphisms: ∀ f: a → a, ∃ b c: a, x.obj b ∧ x.obj c ∧ isomorphism x f b c)\n\nstructure Monoid (a: Type) extends x : Category a :=\n(singleton : a)\n(monoid : ∀ c : a, obj c ↔ c = singleton)\n\nstructure Group (a: Type) extends Monoid a :=\n(isomorphisms: ∀ f: a → a, ∃ b c: a, x.obj b ∧ x.obj c ∧ isomorphism x f b c)\n\n-- Initial, terminal and zero objects\n\ndefinition initial_object {t: Type} (c : Category t) (a: t) \n    := c.obj a ∧ ∀ b : t, c.obj b → ∃! f : t → t, c.mor a b f\n\ndefinition terminal_object {t: Type} (c : Category t) (a: t) \n    := c.obj a ∧ ∀ b : t, c.obj b → ∃! f : t → t, c.mor b a f\n\ndefinition zero_object {t: Type} (c : Category t) (a: t)\n    := c.obj a ∧ initial_object c a ∧ terminal_object c a\n\n-- Lemmas for uniqueness of zero, terminal and initial objects up to isomorphism\n\nlemma unique_initial {t: Type } : ∀ c : Category t, ∀ a b: t, initial_object c a ∧ initial_object c b → isomorphic c a b :=\nbegin\nintros,\nunfold isomorphic,\nunfold initial_object at a_1,\ncases a_1,\nintros,\n\napply exists.elim ((right.2 a) left.1),\nintros,\n\napply exists.elim ((left.2 b) right.1),\nintros,\n\nexistsi (a_3),\nexistsi (a_1),\n\nhave H: c.mor b b (a_3∘a_1), from c.associativity b a b a_1 a_3 a_2.1 a_4.1,\napply exists.elim ((right.2 b) right.1),\nintros,\nhave H2: a_3∘a_1 = a_5, from a_6.2 (a_3∘a_1) H,\nhave I1: id = a_5, from a_6.2 id ((c.identity b) right.1),\nsubst I1,\n\nhave HH: c.mor a a (a_1∘a_3), from c.associativity a b a a_3 a_1 a_4.1 a_2.1,\napply exists.elim ((left.2 a) left.1),\nintros,\nhave H3: a_1∘a_3 = a_5, from a_7.2 (a_1∘a_3) HH,\nhave I2: id = a_5, from a_7.2 id ((c.identity a) left.1),\nsubst I2,\n\nrw [H2, H3],\nsimp,\n\nexact and.intro a_4.1 a_2.1\nend\n\nlemma unique_terminal {t: Type } : ∀ c : Category t, ∀ a b: t, terminal_object c a ∧ terminal_object c b → isomorphic c a b :=\nbegin\nintros,\nunfold isomorphic,\nunfold terminal_object at a_1,\ncases a_1,\nintros,\n\napply exists.elim ((right.2 a) left.1),\nintros,\n\napply exists.elim ((left.2 b) right.1),\nintros,\n\nexistsi (a_1),\nexistsi (a_3),\n\nhave H: c.mor a a (a_3∘a_1), from c.associativity a b a a_1 a_3 a_2.1 a_4.1,\napply exists.elim ((left.2 a) left.1),\nintros,\nhave H2: a_3∘a_1 = a_5, from a_6.2 (a_3∘a_1) H,\nhave I1: id = a_5, from a_6.2 id ((c.identity a) left.1),\nsubst I1,\n\nhave HH: c.mor b b (a_1∘a_3), from c.associativity b a b a_3 a_1 a_4.1 a_2.1,\napply exists.elim ((right.2 b) right.1),\nintros,\nhave H3: a_1∘a_3 = a_5, from a_7.2 (a_1∘a_3) HH,\nhave I2: id = a_5, from a_7.2 id ((c.identity b) right.1),\nsubst I2,\n\nrw [H2, H3],\nsimp,\n\nexact ⟨a_2.1, a_4.1⟩ \nend\n\nlemma unique_zero {t: Type } : ∀ c : Category t, ∀ a b: t, zero_object c a ∧ zero_object c b → isomorphic c a b :=\nbegin\nintros,\nunfold isomorphic,\nunfold zero_object at a_1,\n\napply unique_initial,\nexact and.intro a_1.1.2.1 a_1.2.2.1\nend\n\n-- Natural transformations\n\nstructure Natural_Transformation {T S : Type} {A : Category T} {B: Category S} (U V: Functor A B) :=\n(obj_assign : T → (S → S))\n(commutes : ∀ a b f, A.mor a b f → (obj_assign a) ∘ (U.mor_map f) = (V.mor_map f) ∘ (obj_assign b) )\n(existence : ∀ a, B.mor (U.obj_map a) (V.obj_map a) (obj_assign a))\n\n-- Monomorphisms and epimorphisms\n\ndefinition monomorphism {t : Type} {A : Category t} (a b : t) (f : t → t)\n    := A.mor a b f ∧ (∀ m g h, A.mor m a g ∧ A.mor m a h ∧ (f ∘ g) = (f ∘ h) → g = h) \n\ndefinition epimorphism {t : Type} {A : Category t} (a b : t) (f : t → t)\n    := A.mor a b f ∧ (∀ m g h, A.mor b m g ∧ A.mor b m h ∧ (g ∘ f) = (h ∘ f) → g = h) \n\n-- Composition lemmas for epimorphisms and monomorphisms\n\n\n\n-- Products and Coproducts\n\ndefinition product {t : Type} {A : Category t} (a b : t) (p : t) (f g: t → t)\n    := A.obj a ∧ A.obj b ∧ A.obj p ∧ A.mor p a f ∧ A.mor p b g ∧ \n    (∀ k m n, A.obj k ∧ A.mor k a m ∧ A.mor k b n → ∃! u, A.mor k p u ∧ g ∘ u = n ∧ f ∘ u = m ) \n\ndefinition coproduct {t : Type} {A : Category t} (a b : t) (p : t) (f g: t → t)\n    := A.obj a ∧ A.obj b ∧ A.obj p ∧ A.mor a p f ∧ A.mor b p g ∧ \n    (∀ k m n, A.obj k ∧ A.mor a k m ∧ A.mor b k n → ∃! u, A.mor p k u ∧ u ∘ g = n ∧ u ∘ f = m) \n\n-- Proof of associativity, commutativity and uniqueness up to isomorphism of product and coproduct\n\nlemma product_commutes {t : Type} {A : Category t} (a b : t) (p : t) (f g: t → t) : @product t A a b p f g → @product t A b a p g f :=\nbegin\nintros,\nunfold product at a_1,\nunfold product,\nhave H: (∀ k m n, A.obj k ∧ A.mor k b m ∧ A.mor k a n → ∃! u, A.mor k p u ∧ f ∘ u = n ∧ g ∘ u = m ),\n    from ( begin\n        intros,\n        let X := a_1.2.2.2.2.2 k n m,\n        let X2 := X (⟨a_2.1, a_2.2.2, a_2.2.1⟩),\n        apply exists_and_commute,\n        exact X2\n    end ),\nexact ⟨a_1.2.1, a_1.1, a_1.2.2.1, a_1.2.2.2.2.1, a_1.2.2.2.1, H⟩ \nend\n\nlemma coproduct_commutes {t : Type} {A : Category t} (a b : t) (p : t) (f g: t → t) : @coproduct t A a b p f g → @coproduct t A b a p g f :=\nbegin\nintros,\nunfold coproduct at a_1,\nunfold coproduct,\nhave H: (∀ k m n, A.obj k ∧ A.mor b k m ∧ A.mor a k n → ∃! u, A.mor p k u ∧ u ∘ f = n ∧ u ∘ g = m ),\n    from ( begin\n        intros,\n        let X := a_1.2.2.2.2.2 k n m,\n        let X2 := X (⟨a_2.1, a_2.2.2, a_2.2.1⟩),\n        apply exists_and_commute,\n        exact X2\n    end ),\nexact ⟨a_1.2.1, a_1.1, a_1.2.2.1, a_1.2.2.2.2.1, a_1.2.2.2.1, H⟩ \nend\n\n-- Equalizers and co-equalizers\n\ndefinition equalizer {t : Type} {A : Category t} (f g h: t → t) (a b c: t)\n    := A.obj a ∧ A.obj b ∧ A.obj c ∧ A.mor b c g  ∧ A.mor b c h  ∧ A.mor a b f \n    ∧ g ∘ f = h ∘ f ∧ (∀ x m, A.mor x b m ∧ g ∘ m = h ∘ m → ∃! u, A.mor x a u \n    ∧ f ∘ u = m) \n\ndefinition coequalizer {t : Type} {A : Category t} (f g h: t → t) (a b c: t)\n    := A.obj a ∧ A.obj b ∧ A.obj c ∧ A.mor a b g  ∧ A.mor a b h  ∧ A.mor b c f \n    ∧ f ∘ g = f ∘ h ∧ (∀ x m, A.mor b x m ∧ m ∘ g = m ∘ h → ∃! u, A.mor c x u \n    ∧ u ∘ f = m) \n\n-- Kernels and cokernels\n\n\n\n-- Experimental sheaf description\n\ndefinition inc {A : Type} (a b: set A) (c: set A → set A) {x : Category (set A)} \n    := x.mor a b c ↔ c = id ∧ a ⊂ b \n\ndefinition open_category {a: Type} (t : topological_space a) : Category (set a) :=\n{\n    obj := t.is_open,\n    mor := λ A B: set a, λ C: set a → set a, C = id ∧ A ⊆ B,\n    associativity := λ a b c, λ f g , begin\n        intros h1 h2,\n        split,\n        rw [h1.1, h2.1], \n        apply id.def,\n        exact λ x hx, (h2.2 (h1.2 hx))\n    end,\n    identity := λ a, begin\n        split,\n        simp,\n        exact λ x hx, hx\n    end\n}\n\ndefinition open_Cover {a : Type} (T: topological_space a) (t: set a) (s : set (set a))\n    := ⋃₀ s = t ∧ ∀ b ∈ s, T.is_open b\n\nstructure Presheaf {a b: Type} (t : topological_space a) (c : Category b) extends Contravariant_Functor (open_category t) c\n\nstructure Sheaf {a b: Type} (t : topological_space a) (c : Category b) extends Presheaf t c :=\n(sheaf_axiom := ∀ g s, open_Cover t g s → ∀ x y, ∀ f h, c.mor (obj_map y) (obj_map (x ∩ y)) f\n → c.mor (obj_map x) (obj_map (x ∩ y)) h → f (obj_map y) = h (obj_map x) → ∃ n:b, n = (obj_map g) →\n   ∀ l ∈ s, ∀ e, c.mor n (obj_map l) e → e n = obj_map l)", "meta": {"author": "TudorTitan", "repo": "Lean_ElementaryNT", "sha": "e9fa9e1db315fa7aca88666aee9910d5d9d34a11", "save_path": "github-repos/lean/TudorTitan-Lean_ElementaryNT", "path": "github-repos/lean/TudorTitan-Lean_ElementaryNT/Lean_ElementaryNT-e9fa9e1db315fa7aca88666aee9910d5d9d34a11/ANT.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.48593052106027745}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\n! This file was ported from Lean 3 source module logic.embedding.basic\n! leanprover-community/mathlib commit 70d50ecfd4900dd6d328da39ab7ebd516abe4025\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Option.Basic\nimport Mathlib.Data.Prod.PProd\nimport Mathlib.Logic.Equiv.Basic\n\n/-!\n# Injective functions\n-/\n\n\nuniverse u v w x\n\nnamespace Function\n\n-- port note: in Lean 3 this was tagged @[nolint has_nonempty_instance]\n/-- `α ↪ β` is a bundled injective function. -/\nstructure Embedding (α : Sort _) (β : Sort _) where\n  /-- An embedding as a function. Use coercion instead. -/\n  toFun : α → β\n  /-- An embedding is an injective function. Use `Function.Embedding.injective` instead. -/\n  inj' : Injective toFun\n#align function.embedding Function.Embedding\n\n/-- An embedding, a.k.a. a bundled injective function. -/\ninfixr:25 \" ↪ \" => Embedding\n\ninstance {α : Sort u} {β : Sort v} : EmbeddingLike (α ↪ β) α β where\n  coe := Embedding.toFun\n  injective' := Embedding.inj'\n  coe_injective' f g h := by { cases f; cases g; congr }\n\ninitialize_simps_projections Embedding (toFun → apply)\n\n-- porting note: this needs `tactic.lift`.\n--instance {α β : Sort _} : CanLift (α → β) (α ↪ β) coeFn Injective where prf f hf := ⟨⟨f, hf⟩, rfl⟩\n\nend Function\n\nsection Equiv\n\nvariable {α : Sort u} {β : Sort v} (f : α ≃ β)\n\n/-- Convert an `α ≃ β` to `α ↪ β`.\n\nThis is also available as a coercion `Equiv.coeEmbedding`.\nThe explicit `Equiv.toEmbedding` version is preferred though, since the coercion can have issues\ninferring the type of the resulting embedding. For example:\n\n```lean\n-- Works:\nexample (s : Finset (Fin 3)) (f : Equiv.Perm (Fin 3)) : s.map f.toEmbedding = s.map f := by simp\n-- Error, `f` has type `Fin 3 ≃ Fin 3` but is expected to have type `Fin 3 ↪ ?m_1 : Type ?`\nexample (s : Finset (Fin 3)) (f : Equiv.Perm (Fin 3)) : s.map f = s.map f.toEmbedding := by simp\n```\n-/\nprotected def Equiv.toEmbedding : α ↪ β :=\n  ⟨f, f.injective⟩\n#align equiv.to_embedding Equiv.toEmbedding\n\n@[simp]\ntheorem Equiv.coe_toEmbedding : (f.toEmbedding : α → β) = f :=\n  rfl\n#align equiv.coe_to_embedding Equiv.coe_toEmbedding\n\ntheorem Equiv.toEmbedding_apply (a : α) : f.toEmbedding a = f a :=\n  rfl\n#align equiv.to_embedding_apply Equiv.toEmbedding_apply\n\ninstance Equiv.coeEmbedding : Coe (α ≃ β) (α ↪ β) :=\n  ⟨Equiv.toEmbedding⟩\n#align equiv.coe_embedding Equiv.coeEmbedding\n\n@[reducible]\ninstance Equiv.Perm.coeEmbedding : Coe (Equiv.Perm α) (α ↪ α) :=\n  Equiv.coeEmbedding\n#align equiv.perm.coe_embedding Equiv.Perm.coeEmbedding\n\n-- port note : `theorem Equiv.coe_eq_to_embedding : ↑f = f.toEmbedding` is a\n-- syntactic tautology in Lean 4\n\nend Equiv\n\nnamespace Function\n\nnamespace Embedding\n\ntheorem coe_injective {α β} : @Injective (α ↪ β) (α → β) (λ f => ↑f) :=\n  FunLike.coe_injective\n#align function.embedding.coe_injective Function.Embedding.coe_injective\n\n@[ext]\ntheorem ext {α β} {f g : Embedding α β} (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext f g h\n#align function.embedding.ext Function.Embedding.ext\n\n-- port note : in Lean 3 `FunLike.ext_iff.symm` works\ntheorem ext_iff {α β} {f g : Embedding α β} : (∀ x, f x = g x) ↔ f = g :=\n  Iff.symm (FunLike.ext_iff)\n#align function.embedding.ext_iff Function.Embedding.ext_iff\n\n@[simp]\ntheorem toFun_eq_coe {α β} (f : α ↪ β) : toFun f = f :=\n  rfl\n#align function.embedding.to_fun_eq_coe Function.Embedding.toFun_eq_coe\n\n@[simp]\ntheorem coeFn_mk {α β} (f : α → β) (i) : (@mk _ _ f i : α → β) = f :=\n  rfl\n#align function.embedding.coe_fn_mk Function.Embedding.coeFn_mk\n\n@[simp]\ntheorem mk_coe {α β : Type _} (f : α ↪ β) (inj) : (⟨f, inj⟩ : α ↪ β) = f :=\n  rfl\n#align function.embedding.mk_coe Function.Embedding.mk_coe\n\nprotected theorem injective {α β} (f : α ↪ β) : Injective f :=\n  EmbeddingLike.injective f\n#align function.embedding.injective Function.Embedding.injective\n\ntheorem apply_eq_iff_eq {α β} (f : α ↪ β) (x y : α) : f x = f y ↔ x = y :=\n  EmbeddingLike.apply_eq_iff_eq f\n#align function.embedding.apply_eq_iff_eq Function.Embedding.apply_eq_iff_eq\n\n/-- The identity map as a `Function.Embedding`. -/\n@[refl, simps (config := { simpRhs := true })]\nprotected def refl (α : Sort _) : α ↪ α :=\n  ⟨id, injective_id⟩\n#align function.embedding.refl Function.Embedding.refl\n#align function.embedding.refl_apply Function.Embedding.refl_apply\n\n/-- Composition of `f : α ↪ β` and `g : β ↪ γ`. -/\n@[trans, simps (config := { simpRhs := true })]\nprotected def trans {α β γ} (f : α ↪ β) (g : β ↪ γ) : α ↪ γ :=\n  ⟨g ∘ f, g.injective.comp f.injective⟩\n#align function.embedding.trans Function.Embedding.trans\n#align function.embedding.trans_apply Function.Embedding.trans_apply\n\ninstance : Trans Embedding Embedding Embedding := ⟨Embedding.trans⟩\n\n@[simp]\ntheorem equiv_toEmbedding_trans_symm_toEmbedding {α β : Sort _} (e : α ≃ β) :\n    e.toEmbedding.trans e.symm.toEmbedding = Embedding.refl _ := by\n  ext\n  simp\n#align function.embedding.equiv_to_embedding_trans_symm_to_embedding Function.Embedding.equiv_toEmbedding_trans_symm_toEmbedding\n\n@[simp]\ntheorem equiv_symm_toEmbedding_trans_toEmbedding {α β : Sort _} (e : α ≃ β) :\n    e.symm.toEmbedding.trans e.toEmbedding = Embedding.refl _ := by\n  ext\n  simp\n#align function.embedding.equiv_symm_to_embedding_trans_to_embedding Function.Embedding.equiv_symm_toEmbedding_trans_toEmbedding\n\n/-- Transfer an embedding along a pair of equivalences. -/\n@[simps! (config := { fullyApplied := false, simpRhs := true })]\nprotected def congr {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort x} (e₁ : α ≃ β) (e₂ : γ ≃ δ)\n    (f : α ↪ γ) : β ↪ δ :=\n  (Equiv.toEmbedding e₁.symm).trans (f.trans e₂.toEmbedding)\n#align function.embedding.congr Function.Embedding.congr\n#align function.embedding.congr_apply Function.Embedding.congr_apply\n\n/-- A right inverse `surjInv` of a surjective function as an `Embedding`. -/\nprotected noncomputable def ofSurjective {α β} (f : β → α) (hf : Surjective f) : α ↪ β :=\n  ⟨surjInv hf, injective_surjInv _⟩\n#align function.embedding.of_surjective Function.Embedding.ofSurjective\n\n/-- Convert a surjective `Embedding` to an `Equiv` -/\nprotected noncomputable def equivOfSurjective {α β} (f : α ↪ β) (hf : Surjective f) : α ≃ β :=\n  Equiv.ofBijective f ⟨f.injective, hf⟩\n#align function.embedding.equiv_of_surjective Function.Embedding.equivOfSurjective\n\n/-- There is always an embedding from an empty type. -/\nprotected def ofIsEmpty {α β} [IsEmpty α] : α ↪ β :=\n  ⟨isEmptyElim, isEmptyElim⟩\n#align function.embedding.of_is_empty Function.Embedding.ofIsEmpty\n\n/-- Change the value of an embedding `f` at one point. If the prescribed image\nis already occupied by some `f a'`, then swap the values at these two points. -/\ndef setValue {α β} (f : α ↪ β) (a : α) (b : β) [∀ a', Decidable (a' = a)]\n    [∀ a', Decidable (f a' = b)] : α ↪ β :=\n  ⟨fun a' => if a' = a then b else if f a' = b then f a else f a', by\n    intro x y (h : ite _ _ _ = ite _ _ _)\n    -- TODO: once we have `cc` we can avoid all the manual cases below by doing\n    -- split_ifs at h <;> (try subst b) <;> (try simp only [f.injective.eq_iff] at *) <;> cc\n    split_ifs at h with h₁ h₂ _ _ h₅ h₆ <;>\n        (try subst b) <;>\n        (try simp only [f.injective.eq_iff] at *)\n    · rw[h₁,h₂]\n    · rw[h₁,h]\n    · rw[h₅,←h]\n    · exact h₆.symm\n    · exfalso; exact h₅ h.symm\n    · exfalso; exact h₁ h\n    · exact h ⟩\n#align function.embedding.set_value Function.Embedding.setValue\n\ntheorem setValue_eq {α β} (f : α ↪ β) (a : α) (b : β) [∀ a', Decidable (a' = a)]\n    [∀ a', Decidable (f a' = b)] : setValue f a b a = b := by\n  simp [setValue]\n#align function.embedding.set_value_eq Function.Embedding.setValue_eq\n\n/-- Embedding into `Option α` using `some`. -/\n@[simps (config := { fullyApplied := false })]\nprotected def some {α} : α ↪ Option α :=\n  ⟨some, Option.some_injective α⟩\n#align function.embedding.some Function.Embedding.some\n#align function.embedding.some_apply Function.Embedding.some_apply\n\n-- porting note: Lean 4 unfolds coercion `α → Option α` to `some`, so there is no separate\n-- `Function.Embedding.coeOption`.\n#align function.embedding.coe_option Function.Embedding.some\n\n/-- A version of `Option.map` for `Function.Embedding`s. -/\n@[simps (config := { fullyApplied := false })]\ndef optionMap {α β} (f : α ↪ β) : Option α ↪ Option β :=\n  ⟨Option.map f, Option.map_injective f.injective⟩\n#align function.embedding.option_map Function.Embedding.optionMap\n#align function.embedding.option_map_apply Function.Embedding.optionMap_apply\n\n/-- Embedding of a `Subtype`. -/\ndef subtype {α} (p : α → Prop) : Subtype p ↪ α :=\n  ⟨Subtype.val, fun _ _ => Subtype.ext⟩\n#align function.embedding.subtype Function.Embedding.subtype\n\n@[simp]\ntheorem coe_subtype {α} (p : α → Prop) : ↑(subtype p) = Subtype.val :=\n  rfl\n#align function.embedding.coe_subtype Function.Embedding.coe_subtype\n\n/-- `Quotient.out` as an embedding. -/\nnoncomputable def quotientOut (α) [s : Setoid α] : Quotient s ↪ α :=\n  ⟨_, Quotient.out_injective⟩\n#align function.embedding.quotient_out Function.Embedding.quotientOut\n\n@[simp]\ntheorem coe_quotientOut (α) [Setoid α] : ↑(quotientOut α) = Quotient.out :=\n  rfl\n#align function.embedding.coe_quotient_out Function.Embedding.coe_quotientOut\n\n/-- Choosing an element `b : β` gives an embedding of `punit` into `β`. -/\ndef punit {β : Sort _} (b : β) : PUnit ↪ β :=\n  ⟨fun _ => b, by\n    rintro ⟨⟩ ⟨⟩ _\n    rfl⟩\n#align function.embedding.punit Function.Embedding.punit\n\n/-- Fixing an element `b : β` gives an embedding `α ↪ α × β`. -/\n@[simps]\ndef sectl (α : Sort _) {β : Sort _} (b : β) : α ↪ α × β :=\n  ⟨fun a => (a, b), fun _ _ h => congr_arg Prod.fst h⟩\n#align function.embedding.sectl Function.Embedding.sectl\n#align function.embedding.sectl_apply Function.Embedding.sectl_apply\n\n/-- Fixing an element `a : α` gives an embedding `β ↪ α × β`. -/\n@[simps]\ndef sectr {α : Sort _} (a : α) (β : Sort _) : β ↪ α × β :=\n  ⟨fun b => (a, b), fun _ _ h => congr_arg Prod.snd h⟩\n#align function.embedding.sectr Function.Embedding.sectr\n#align function.embedding.sectr_apply Function.Embedding.sectr_apply\n\n/-- If `e₁` and `e₂` are embeddings, then so is `prod.map e₁ e₂ : (a, b) ↦ (e₁ a, e₂ b)`. -/\ndef prodMap {α β γ δ : Type _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : α × γ ↪ β × δ :=\n  ⟨Prod.map e₁ e₂, e₁.injective.Prod_map e₂.injective⟩\n#align function.embedding.prod_map Function.Embedding.prodMap\n\n@[simp]\ntheorem coe_prodMap {α β γ δ : Type _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) :\n    e₁.prodMap e₂ = Prod.map e₁ e₂ :=\n  rfl\n#align function.embedding.coe_prod_map Function.Embedding.coe_prodMap\n\n/-- If `e₁` and `e₂` are embeddings, then so is `λ ⟨a, b⟩, ⟨e₁ a, e₂ b⟩ : pprod α γ → pprod β δ`. -/\ndef pprodMap {α β γ δ : Sort _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : PProd α γ ↪ PProd β δ :=\n  ⟨fun x => ⟨e₁ x.1, e₂ x.2⟩, e₁.injective.pprod_map e₂.injective⟩\n#align function.embedding.pprod_map Function.Embedding.pprodMap\n\nsection Sum\n\nopen Sum\n\n/-- If `e₁` and `e₂` are embeddings, then so is `sum.map e₁ e₂`. -/\ndef sumMap {α β γ δ : Type _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : Sum α γ ↪ Sum β δ :=\n  ⟨Sum.map e₁ e₂, e₁.injective.sum_map e₂.injective⟩\n#align function.embedding.sum_map Function.Embedding.sumMap\n\n@[simp]\ntheorem coe_sumMap {α β γ δ} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : sumMap e₁ e₂ = Sum.map e₁ e₂ :=\n  rfl\n#align function.embedding.coe_sum_map Function.Embedding.coe_sumMap\n\n/-- The embedding of `α` into the sum `α ⊕ β`. -/\n@[simps]\ndef inl {α β : Type _} : α ↪ Sum α β :=\n  ⟨Sum.inl, fun _ _ => Sum.inl.inj⟩\n#align function.embedding.inl Function.Embedding.inl\n#align function.embedding.inl_apply Function.Embedding.inl_apply\n\n/-- The embedding of `β` into the sum `α ⊕ β`. -/\n@[simps]\ndef inr {α β : Type _} : β ↪ Sum α β :=\n  ⟨Sum.inr, fun _ _ => Sum.inr.inj⟩\n#align function.embedding.inr Function.Embedding.inr\n#align function.embedding.inr_apply Function.Embedding.inr_apply\n\nend Sum\n\nsection Sigma\n\nvariable {α α' : Type _} {β : α → Type _} {β' : α' → Type _}\n\n/-- `Sigma.mk` as an `Function.Embedding`. -/\n@[simps apply]\ndef sigmaMk (a : α) : β a ↪ Σx, β x :=\n  ⟨Sigma.mk a, sigma_mk_injective⟩\n#align function.embedding.sigma_mk Function.Embedding.sigmaMk\n#align function.embedding.sigma_mk_apply Function.Embedding.sigmaMk_apply\n\n/-- If `f : α ↪ α'` is an embedding and `g : Π a, β α ↪ β' (f α)` is a family\nof embeddings, then `Sigma.map f g` is an embedding. -/\n@[simps apply]\ndef sigmaMap (f : α ↪ α') (g : ∀ a, β a ↪ β' (f a)) : (Σa, β a) ↪ Σa', β' a' :=\n  ⟨Sigma.map f fun a => g a, f.injective.sigma_map fun a => (g a).injective⟩\n#align function.embedding.sigma_map Function.Embedding.sigmaMap\n#align function.embedding.sigma_map_apply Function.Embedding.sigmaMap_apply\n\nend Sigma\n\n/-- Define an embedding `(Π a : α, β a) ↪ (Π a : α, γ a)` from a family of embeddings\n`e : Π a, (β a ↪ γ a)`. This embedding sends `f` to `λ a, e a (f a)`. -/\n@[simps]\ndef piCongrRight {α : Sort _} {β γ : α → Sort _} (e : ∀ a, β a ↪ γ a) : (∀ a, β a) ↪ ∀ a, γ a :=\n  ⟨fun f a => e a (f a), fun _ _ h => funext fun a => (e a).injective (congr_fun h a)⟩\n#align function.embedding.Pi_congr_right Function.Embedding.piCongrRight\n#align function.embedding.Pi_congr_right_apply Function.Embedding.piCongrRight_apply\n\n/-- An embedding `e : α ↪ β` defines an embedding `(γ → α) ↪ (γ → β)` that sends each `f`\nto `e ∘ f`. -/\ndef arrowCongrRight {α : Sort u} {β : Sort v} {γ : Sort w} (e : α ↪ β) : (γ → α) ↪ γ → β :=\n  piCongrRight fun _ => e\n#align function.embedding.arrow_congr_right Function.Embedding.arrowCongrRight\n\n@[simp]\ntheorem arrowCongrRight_apply {α : Sort u} {β : Sort v} {γ : Sort w} (e : α ↪ β) (f : γ ↪ α) :\n    arrowCongrRight e f = e ∘ f :=\n  rfl\n#align function.embedding.arrow_congr_right_apply Function.Embedding.arrowCongrRight_apply\n\n/-- An embedding `e : α ↪ β` defines an embedding `(α → γ) ↪ (β → γ)` for any inhabited type `γ`.\nThis embedding sends each `f : α → γ` to a function `g : β → γ` such that `g ∘ e = f` and\n`g y = default` whenever `y ∉ range e`. -/\nnoncomputable def arrowCongrLeft {α : Sort u} {β : Sort v} {γ : Sort w} [Inhabited γ] (e : α ↪ β) :\n    (α → γ) ↪ β → γ :=\n  ⟨fun f => extend e f default, fun f₁ f₂ h =>\n    funext fun x => by simpa only [e.injective.extend_apply] using congr_fun h (e x)⟩\n#align function.embedding.arrow_congr_left Function.Embedding.arrowCongrLeft\n\n/-- Restrict both domain and codomain of an embedding. -/\nprotected def subtypeMap {α β} {p : α → Prop} {q : β → Prop} (f : α ↪ β)\n    (h : ∀ ⦃x⦄, p x → q (f x)) :\n    { x : α // p x } ↪ { y : β // q y } :=\n  ⟨Subtype.map f h, Subtype.map_injective h f.2⟩\n#align function.embedding.subtype_map Function.Embedding.subtypeMap\n\nopen Set\n\ntheorem swap_apply {α β : Type _} [DecidableEq α] [DecidableEq β] (f : α ↪ β) (x y z : α) :\n    Equiv.swap (f x) (f y) (f z) = f (Equiv.swap x y z) :=\n  f.injective.swap_apply x y z\n#align function.embedding.swap_apply Function.Embedding.swap_apply\n\ntheorem swap_comp {α β : Type _} [DecidableEq α] [DecidableEq β] (f : α ↪ β) (x y : α) :\n    Equiv.swap (f x) (f y) ∘ f = f ∘ Equiv.swap x y :=\n  f.injective.swap_comp x y\n#align function.embedding.swap_comp Function.Embedding.swap_comp\n\nend Embedding\n\nend Function\n\nnamespace Equiv\n\nopen Function Embedding\n\n/-- Given an equivalence to a subtype, produce an embedding to the elements of the corresponding\nset. -/\n@[simps!]\ndef asEmbedding {p : β → Prop} (e : α ≃ Subtype p) : α ↪ β :=\n  e.toEmbedding.trans (subtype p)\n#align equiv.as_embedding Equiv.asEmbedding\n#align equiv.as_embedding_apply Equiv.asEmbedding_apply\n\n/-- The type of embeddings `α ↪ β` is equivalent to\n    the subtype of all injective functions `α → β`. -/\ndef subtypeInjectiveEquivEmbedding (α β : Sort _) :\n    { f : α → β // Injective f } ≃ (α ↪ β) where\n  toFun f := ⟨f.val, f.property⟩\n  invFun f := ⟨f, f.injective⟩\n  left_inv _ := rfl\n  right_inv _ := rfl\n#align equiv.subtype_injective_equiv_embedding Equiv.subtypeInjectiveEquivEmbedding\n\n-- porting note: in Lean 3 this had `@[congr]`\n/-- If `α₁ ≃ α₂` and `β₁ ≃ β₂`, then the type of embeddings `α₁ ↪ β₁`\nis equivalent to the type of embeddings `α₂ ↪ β₂`. -/\n@[simps apply]\ndef embeddingCongr {α β γ δ : Sort _} (h : α ≃ β) (h' : γ ≃ δ) : (α ↪ γ) ≃ (β ↪ δ) where\n  toFun f := f.congr h h'\n  invFun f := f.congr h.symm h'.symm\n  left_inv x := by\n    ext\n    simp\n  right_inv x := by\n    ext\n    simp\n#align equiv.embedding_congr Equiv.embeddingCongr\n#align equiv.embedding_congr_apply Equiv.embeddingCongr_apply\n\n@[simp]\ntheorem embeddingCongr_refl {α β : Sort _} :\n    embeddingCongr (Equiv.refl α) (Equiv.refl β) = Equiv.refl (α ↪ β) :=\n  rfl\n#align equiv.embedding_congr_refl Equiv.embeddingCongr_refl\n\n@[simp]\ntheorem embeddingCongr_trans {α₁ β₁ α₂ β₂ α₃ β₃ : Sort _} (e₁ : α₁ ≃ α₂) (e₁' : β₁ ≃ β₂)\n    (e₂ : α₂ ≃ α₃) (e₂' : β₂ ≃ β₃) :\n    embeddingCongr (e₁.trans e₂) (e₁'.trans e₂') =\n      (embeddingCongr e₁ e₁').trans (embeddingCongr e₂ e₂') :=\n  rfl\n#align equiv.embedding_congr_trans Equiv.embeddingCongr_trans\n\n@[simp]\ntheorem embeddingCongr_symm {α₁ β₁ α₂ β₂ : Sort _} (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) :\n    (embeddingCongr e₁ e₂).symm = embeddingCongr e₁.symm e₂.symm :=\n  rfl\n#align equiv.embedding_congr_symm Equiv.embeddingCongr_symm\n\ntheorem embeddingCongr_apply_trans {α₁ β₁ γ₁ α₂ β₂ γ₂ : Sort _} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂)\n    (ec : γ₁ ≃ γ₂) (f : α₁ ↪ β₁) (g : β₁ ↪ γ₁) :\n    Equiv.embeddingCongr ea ec (f.trans g) =\n      (Equiv.embeddingCongr ea eb f).trans (Equiv.embeddingCongr eb ec g) := by\n  ext\n  simp\n#align equiv.embedding_congr_apply_trans Equiv.embeddingCongr_apply_trans\n\n@[simp]\ntheorem refl_toEmbedding {α : Type _} : (Equiv.refl α).toEmbedding = Embedding.refl α :=\n  rfl\n#align equiv.refl_to_embedding Equiv.refl_toEmbedding\n\n@[simp]\ntheorem trans_toEmbedding {α β γ : Type _} (e : α ≃ β) (f : β ≃ γ) :\n    (e.trans f).toEmbedding = e.toEmbedding.trans f.toEmbedding :=\n  rfl\n#align equiv.trans_to_embedding Equiv.trans_toEmbedding\n\nend Equiv\n\nsection Subtype\n\nvariable {α : Type _}\n\n/-- A subtype `{x // p x ∨ q x}` over a disjunction of `p q : α → Prop` can be injectively split\ninto a sum of subtypes `{x // p x} ⊕ {x // q x}` such that `¬ p x` is sent to the right. -/\ndef subtypeOrLeftEmbedding (p q : α → Prop) [DecidablePred p] :\n    { x // p x ∨ q x } ↪ Sum { x // p x } { x // q x } :=\n  ⟨fun x => if h : p x then Sum.inl ⟨x, h⟩ else Sum.inr ⟨x, x.prop.resolve_left h⟩, by\n    intro x y\n    dsimp only\n    split_ifs <;> simp [Subtype.ext_iff]⟩\n#align subtype_or_left_embedding subtypeOrLeftEmbedding\n\ntheorem subtypeOrLeftEmbedding_apply_left {p q : α → Prop} [DecidablePred p]\n    (x : { x // p x ∨ q x }) (hx : p x) :\n    subtypeOrLeftEmbedding p q x = Sum.inl ⟨x, hx⟩ :=\n  dif_pos hx\n#align subtype_or_left_embedding_apply_left subtypeOrLeftEmbedding_apply_left\n\ntheorem subtypeOrLeftEmbedding_apply_right {p q : α → Prop} [DecidablePred p]\n    (x : { x // p x ∨ q x }) (hx : ¬p x) :\n    subtypeOrLeftEmbedding p q x = Sum.inr ⟨x, x.prop.resolve_left hx⟩ :=\n  dif_neg hx\n#align subtype_or_left_embedding_apply_right subtypeOrLeftEmbedding_apply_right\n\n/-- A subtype `{x // p x}` can be injectively sent to into a subtype `{x // q x}`,\nif `p x → q x` for all `x : α`. -/\n@[simps]\ndef Subtype.impEmbedding (p q : α → Prop) (h : ∀ x, p x → q x) : { x // p x } ↪ { x // q x } :=\n  ⟨fun x => ⟨x, h x x.prop⟩, fun x y => by simp [Subtype.ext_iff]⟩\n#align subtype.imp_embedding Subtype.impEmbedding\n#align subtype.imp_embedding_apply_coe Subtype.impEmbedding_apply_coe\n\nend Subtype\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Logic/Embedding/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.48593051231384954}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.big_operators.intervals\nimport Mathlib.topology.instances.real\nimport Mathlib.topology.algebra.module\nimport Mathlib.data.indicator_function\nimport Mathlib.data.equiv.encodable.lattice\nimport Mathlib.order.filter.at_top_bot\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 u_6 \n\nnamespace Mathlib\n\n/-!\n# Infinite sum over a topological monoid\n\nThis sum is known as unconditionally convergent, as it sums to the same value under all possible\npermutations. For Euclidean spaces (finite dimensional Banach spaces) this is equivalent to absolute\nconvergence.\n\nNote: There are summable sequences which are not unconditionally convergent! The other way holds\ngenerally, see `has_sum.tendsto_sum_nat`.\n\n## References\n\n* Bourbaki: General Topology (1995), Chapter 3 §5 (Infinite sums in commutative groups)\n\n-/\n\n/-- Infinite sum on a topological monoid\n\nThe `at_top` filter on `finset β` is the limit of all finite sets towards the entire type. So we sum\nup bigger and bigger sets. This sum operation is invariant under reordering. In particular,\nthe function `ℕ → ℝ` sending `n` to `(-1)^n / (n+1)` does not have a\nsum for this definition, but a series which is absolutely convergent will have the correct sum.\n\nThis is based on Mario Carneiro's\n[infinite sum `df-tsms` in Metamath](http://us.metamath.org/mpeuni/df-tsms.html).\n\nFor the definition or many statements, `α` does not need to be a topological monoid. We only add\nthis assumption later, for the lemmas where it is relevant.\n-/\ndef has_sum {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] (f : β → α) (a : α) :=\n  filter.tendsto (fun (s : finset β) => finset.sum s fun (b : β) => f b) filter.at_top (nhds a)\n\n/-- `summable f` means that `f` has some (infinite) sum. Use `tsum` to get the value. -/\ndef summable {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] (f : β → α) :=\n  ∃ (a : α), has_sum f a\n\n/-- `∑' i, f i` is the sum of `f` it exists, or 0 otherwise -/\ndef tsum {α : Type u_1} [add_comm_monoid α] [topological_space α] {β : Type u_2} (f : β → α) : α :=\n  dite (summable f) (fun (h : summable f) => classical.some h) fun (h : ¬summable f) => 0\n\n-- see Note [operator precedence of big operators]\n\ntheorem summable.has_sum {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} (ha : summable f) : has_sum f (tsum fun (b : β) => f b) := sorry\n\ntheorem has_sum.summable {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} (h : has_sum f a) : summable f :=\n  Exists.intro a h\n\n/-- Constant zero function has sum `0` -/\ntheorem has_sum_zero {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] : has_sum (fun (b : β) => 0) 0 := sorry\n\ntheorem summable_zero {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] : summable fun (b : β) => 0 :=\n  has_sum.summable has_sum_zero\n\ntheorem tsum_eq_zero_of_not_summable {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} (h : ¬summable f) : (tsum fun (b : β) => f b) = 0 := sorry\n\ntheorem has_sum.has_sum_of_sum_eq {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {g : γ → α} (h_eq : ∀ (u : finset γ),\n  ∃ (v : finset β),\n    ∀ (v' : finset β),\n      v ⊆ v' → ∃ (u' : finset γ), u ⊆ u' ∧ (finset.sum u' fun (x : γ) => g x) = finset.sum v' fun (b : β) => f b) (hf : has_sum g a) : has_sum f a :=\n  le_trans (filter.map_at_top_finset_sum_le_of_sum_eq h_eq) hf\n\ntheorem has_sum_iff_has_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {g : γ → α} (h₁ : ∀ (u : finset γ),\n  ∃ (v : finset β),\n    ∀ (v' : finset β),\n      v ⊆ v' → ∃ (u' : finset γ), u ⊆ u' ∧ (finset.sum u' fun (x : γ) => g x) = finset.sum v' fun (b : β) => f b) (h₂ : ∀ (v : finset β),\n  ∃ (u : finset γ),\n    ∀ (u' : finset γ),\n      u ⊆ u' → ∃ (v' : finset β), v ⊆ v' ∧ (finset.sum v' fun (b : β) => f b) = finset.sum u' fun (x : γ) => g x) : has_sum f a ↔ has_sum g a :=\n  { mp := has_sum.has_sum_of_sum_eq h₂, mpr := has_sum.has_sum_of_sum_eq h₁ }\n\ntheorem function.injective.has_sum_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {g : γ → β} (hg : function.injective g) (hf : ∀ (x : β), ¬x ∈ set.range g → f x = 0) : has_sum (f ∘ g) a ↔ has_sum f a := sorry\n\ntheorem function.injective.summable_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {g : γ → β} (hg : function.injective g) (hf : ∀ (x : β), ¬x ∈ set.range g → f x = 0) : summable (f ∘ g) ↔ summable f :=\n  exists_congr fun (_x : α) => function.injective.has_sum_iff hg hf\n\ntheorem has_sum_subtype_iff_of_support_subset {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {s : set β} (hf : function.support f ⊆ s) : has_sum (f ∘ coe) a ↔ has_sum f a := sorry\n\ntheorem has_sum_subtype_iff_indicator {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {s : set β} : has_sum (f ∘ coe) a ↔ has_sum (set.indicator s f) a := sorry\n\n@[simp] theorem has_sum_subtype_support {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} : has_sum (f ∘ coe) a ↔ has_sum f a :=\n  has_sum_subtype_iff_of_support_subset (set.subset.refl (function.support f))\n\ntheorem has_sum_fintype {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [fintype β] (f : β → α) : has_sum f (finset.sum finset.univ fun (b : β) => f b) :=\n  order_top.tendsto_at_top_nhds fun (s : finset β) => finset.sum s fun (b : β) => f b\n\nprotected theorem finset.has_sum {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] (s : finset β) (f : β → α) : has_sum (f ∘ coe) (finset.sum s fun (b : β) => f b) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (has_sum (f ∘ coe) (finset.sum s fun (b : β) => f b))) (Eq.symm finset.sum_attach)))\n    (has_sum_fintype (f ∘ coe))\n\nprotected theorem finset.summable {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] (s : finset β) (f : β → α) : summable (f ∘ coe) :=\n  has_sum.summable (finset.has_sum s f)\n\nprotected theorem set.finite.summable {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {s : set β} (hs : set.finite s) (f : β → α) : summable (f ∘ coe) := sorry\n\n/-- If a function `f` vanishes outside of a finite set `s`, then it `has_sum` `∑ b in s, f b`. -/\ntheorem has_sum_sum_of_ne_finset_zero {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {s : finset β} (hf : ∀ (b : β), ¬b ∈ s → f b = 0) : has_sum f (finset.sum s fun (b : β) => f b) :=\n  iff.mp (has_sum_subtype_iff_of_support_subset (iff.mpr function.support_subset_iff' hf)) (finset.has_sum s f)\n\ntheorem summable_of_ne_finset_zero {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {s : finset β} (hf : ∀ (b : β), ¬b ∈ s → f b = 0) : summable f :=\n  has_sum.summable (has_sum_sum_of_ne_finset_zero hf)\n\ntheorem has_sum_single {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} (b : β) (hf : ∀ (b' : β), b' ≠ b → f b' = 0) : has_sum f (f b) := sorry\n\ntheorem has_sum_ite_eq {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] (b : β) (a : α) : has_sum (fun (b' : β) => ite (b' = b) a 0) a := sorry\n\ntheorem equiv.has_sum_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} (e : γ ≃ β) : has_sum (f ∘ ⇑e) a ↔ has_sum f a := sorry\n\ntheorem equiv.summable_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} (e : γ ≃ β) : summable (f ∘ ⇑e) ↔ summable f :=\n  exists_congr fun (a : α) => equiv.has_sum_iff e\n\ntheorem summable.prod_symm {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β × γ → α} (hf : summable f) : summable fun (p : γ × β) => f (prod.swap p) :=\n  iff.mpr (equiv.summable_iff (equiv.prod_comm γ β)) hf\n\ntheorem equiv.has_sum_iff_of_support {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {g : γ → α} (e : ↥(function.support f) ≃ ↥(function.support g)) (he : ∀ (x : ↥(function.support f)), g ↑(coe_fn e x) = f ↑x) : has_sum f a ↔ has_sum g a := sorry\n\ntheorem has_sum_iff_has_sum_of_ne_zero_bij {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {g : γ → α} (i : ↥(function.support g) → β) (hi : ∀ {x y : ↥(function.support g)}, i x = i y → ↑x = ↑y) (hf : function.support f ⊆ set.range i) (hfg : ∀ (x : ↥(function.support g)), f (i x) = g ↑x) : has_sum f a ↔ has_sum g a := sorry\n\ntheorem equiv.summable_iff_of_support {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {g : γ → α} (e : ↥(function.support f) ≃ ↥(function.support g)) (he : ∀ (x : ↥(function.support f)), g ↑(coe_fn e x) = f ↑x) : summable f ↔ summable g :=\n  exists_congr fun (_x : α) => equiv.has_sum_iff_of_support e he\n\nprotected theorem has_sum.map {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} [add_comm_monoid γ] [topological_space γ] (hf : has_sum f a) (g : α →+ γ) (hg : continuous ⇑g) : has_sum (⇑g ∘ f) (coe_fn g a) := sorry\n\nprotected theorem summable.map {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {f : β → α} [add_comm_monoid γ] [topological_space γ] (hf : summable f) (g : α →+ γ) (hg : continuous ⇑g) : summable (⇑g ∘ f) :=\n  has_sum.summable (has_sum.map (summable.has_sum hf) g hg)\n\n/-- If `f : ℕ → α` has sum `a`, then the partial sums `∑_{i=0}^{n-1} f i` converge to `a`. -/\ntheorem has_sum.tendsto_sum_nat {α : Type u_1} [add_comm_monoid α] [topological_space α] {a : α} {f : ℕ → α} (h : has_sum f a) : filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i) filter.at_top (nhds a) :=\n  filter.tendsto.comp h filter.tendsto_finset_range\n\ntheorem has_sum.unique {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {a₁ : α} {a₂ : α} [t2_space α] : has_sum f a₁ → has_sum f a₂ → a₁ = a₂ :=\n  tendsto_nhds_unique\n\ntheorem summable.has_sum_iff_tendsto_nat {α : Type u_1} [add_comm_monoid α] [topological_space α] [t2_space α] {f : ℕ → α} {a : α} (hf : summable f) : has_sum f a ↔ filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i) filter.at_top (nhds a) := sorry\n\ntheorem equiv.summable_iff_of_has_sum_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] {α' : Type u_4} [add_comm_monoid α'] [topological_space α'] (e : α' ≃ α) {f : β → α} {g : γ → α'} (he : ∀ {a : α'}, has_sum f (coe_fn e a) ↔ has_sum g a) : summable f ↔ summable g := sorry\n\ntheorem has_sum.add {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {g : β → α} {a : α} {b : α} [has_continuous_add α] (hf : has_sum f a) (hg : has_sum g b) : has_sum (fun (b : β) => f b + g b) (a + b) := sorry\n\ntheorem summable.add {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {g : β → α} [has_continuous_add α] (hf : summable f) (hg : summable g) : summable fun (b : β) => f b + g b :=\n  has_sum.summable (has_sum.add (summable.has_sum hf) (summable.has_sum hg))\n\ntheorem has_sum_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [has_continuous_add α] {f : γ → β → α} {a : γ → α} {s : finset γ} : (∀ (i : γ), i ∈ s → has_sum (f i) (a i)) →\n  has_sum (fun (b : β) => finset.sum s fun (i : γ) => f i b) (finset.sum s fun (i : γ) => a i) := sorry\n\ntheorem summable_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [has_continuous_add α] {f : γ → β → α} {s : finset γ} (hf : ∀ (i : γ), i ∈ s → summable (f i)) : summable fun (b : β) => finset.sum s fun (i : γ) => f i b :=\n  has_sum.summable (has_sum_sum fun (i : γ) (hi : i ∈ s) => summable.has_sum (hf i hi))\n\ntheorem has_sum.add_compl {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {b : α} [has_continuous_add α] {s : set β} (ha : has_sum (f ∘ coe) a) (hb : has_sum (f ∘ coe) b) : has_sum f (a + b) := sorry\n\ntheorem summable.add_compl {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} [has_continuous_add α] {s : set β} (hs : summable (f ∘ coe)) (hsc : summable (f ∘ coe)) : summable f :=\n  has_sum.summable (has_sum.add_compl (summable.has_sum hs) (summable.has_sum hsc))\n\ntheorem has_sum.compl_add {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} {a : α} {b : α} [has_continuous_add α] {s : set β} (ha : has_sum (f ∘ coe) a) (hb : has_sum (f ∘ coe) b) : has_sum f (a + b) := sorry\n\ntheorem summable.compl_add {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] {f : β → α} [has_continuous_add α] {s : set β} (hs : summable (f ∘ coe)) (hsc : summable (f ∘ coe)) : summable f :=\n  has_sum.summable (has_sum.compl_add (summable.has_sum hs) (summable.has_sum hsc))\n\ntheorem has_sum.sigma {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [has_continuous_add α] [regular_space α] {γ : β → Type u_3} {f : (sigma fun (b : β) => γ b) → α} {g : β → α} {a : α} (ha : has_sum f a) (hf : ∀ (b : β), has_sum (fun (c : γ b) => f (sigma.mk b c)) (g b)) : has_sum g a := sorry\n\n/-- If a series `f` on `β × γ` has sum `a` and for each `b` the restriction of `f` to `{b} × γ`\nhas sum `g b`, then the series `g` has sum `a`. -/\ntheorem has_sum.prod_fiberwise {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [has_continuous_add α] [regular_space α] {f : β × γ → α} {g : β → α} {a : α} (ha : has_sum f a) (hf : ∀ (b : β), has_sum (fun (c : γ) => f (b, c)) (g b)) : has_sum g a :=\n  has_sum.sigma (iff.mpr (equiv.has_sum_iff (equiv.sigma_equiv_prod β γ)) ha) hf\n\ntheorem summable.sigma' {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [has_continuous_add α] [regular_space α] {γ : β → Type u_3} {f : (sigma fun (b : β) => γ b) → α} (ha : summable f) (hf : ∀ (b : β), summable fun (c : γ b) => f (sigma.mk b c)) : summable fun (b : β) => tsum fun (c : γ b) => f (sigma.mk b c) :=\n  has_sum.summable (has_sum.sigma (summable.has_sum ha) fun (b : β) => summable.has_sum (hf b))\n\ntheorem has_sum.sigma_of_has_sum {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [has_continuous_add α] [regular_space α] {γ : β → Type u_3} {f : (sigma fun (b : β) => γ b) → α} {g : β → α} {a : α} (ha : has_sum g a) (hf : ∀ (b : β), has_sum (fun (c : γ b) => f (sigma.mk b c)) (g b)) (hf' : summable f) : has_sum f a := sorry\n\ntheorem has_sum.tsum_eq {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} {a : α} (ha : has_sum f a) : (tsum fun (b : β) => f b) = a :=\n  has_sum.unique (summable.has_sum (Exists.intro a ha)) ha\n\ntheorem summable.has_sum_iff {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} {a : α} (h : summable f) : has_sum f a ↔ (tsum fun (b : β) => f b) = a :=\n  { mp := has_sum.tsum_eq, mpr := fun (eq : (tsum fun (b : β) => f b) = a) => eq ▸ summable.has_sum h }\n\n@[simp] theorem tsum_zero {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] : (tsum fun (b : β) => 0) = 0 :=\n  has_sum.tsum_eq has_sum_zero\n\ntheorem tsum_eq_sum {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} {s : finset β} (hf : ∀ (b : β), ¬b ∈ s → f b = 0) : (tsum fun (b : β) => f b) = finset.sum s fun (b : β) => f b :=\n  has_sum.tsum_eq (has_sum_sum_of_ne_finset_zero hf)\n\ntheorem tsum_fintype {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] [fintype β] (f : β → α) : (tsum fun (b : β) => f b) = finset.sum finset.univ fun (b : β) => f b :=\n  has_sum.tsum_eq (has_sum_fintype f)\n\n@[simp] theorem finset.tsum_subtype {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] (s : finset β) (f : β → α) : (tsum fun (x : Subtype fun (x : β) => x ∈ s) => f ↑x) = finset.sum s fun (x : β) => f x :=\n  has_sum.tsum_eq (finset.has_sum s f)\n\n@[simp] theorem finset.tsum_subtype' {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] (s : finset β) (f : β → α) : (tsum fun (x : ↥↑s) => f ↑x) = finset.sum s fun (x : β) => f x :=\n  finset.tsum_subtype s f\n\ntheorem tsum_eq_single {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} (b : β) (hf : ∀ (b' : β), b' ≠ b → f b' = 0) : (tsum fun (b : β) => f b) = f b :=\n  has_sum.tsum_eq (has_sum_single b hf)\n\n@[simp] theorem tsum_ite_eq {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] (b : β) (a : α) : (tsum fun (b' : β) => ite (b' = b) a 0) = a :=\n  has_sum.tsum_eq (has_sum_ite_eq b a)\n\ntheorem equiv.tsum_eq_tsum_of_has_sum_iff_has_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] {α' : Type u_4} [add_comm_monoid α'] [topological_space α'] (e : α' ≃ α) (h0 : coe_fn e 0 = 0) {f : β → α} {g : γ → α'} (h : ∀ {a : α'}, has_sum f (coe_fn e a) ↔ has_sum g a) : (tsum fun (b : β) => f b) = coe_fn e (tsum fun (c : γ) => g c) := sorry\n\ntheorem tsum_eq_tsum_of_has_sum_iff_has_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} {g : γ → α} (h : ∀ {a : α}, has_sum f a ↔ has_sum g a) : (tsum fun (b : β) => f b) = tsum fun (c : γ) => g c :=\n  equiv.tsum_eq_tsum_of_has_sum_iff_has_sum (equiv.refl α) rfl h\n\ntheorem equiv.tsum_eq {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] (j : γ ≃ β) (f : β → α) : (tsum fun (c : γ) => f (coe_fn j c)) = tsum fun (b : β) => f b :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (a : α) => equiv.has_sum_iff j\n\ntheorem equiv.tsum_eq_tsum_of_support {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} {g : γ → α} (e : ↥(function.support f) ≃ ↥(function.support g)) (he : ∀ (x : ↥(function.support f)), g ↑(coe_fn e x) = f ↑x) : (tsum fun (x : β) => f x) = tsum fun (y : γ) => g y :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (_x : α) => equiv.has_sum_iff_of_support e he\n\ntheorem tsum_eq_tsum_of_ne_zero_bij {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} {g : γ → α} (i : ↥(function.support g) → β) (hi : ∀ {x y : ↥(function.support g)}, i x = i y → ↑x = ↑y) (hf : function.support f ⊆ set.range i) (hfg : ∀ (x : ↥(function.support g)), f (i x) = g ↑x) : (tsum fun (x : β) => f x) = tsum fun (y : γ) => g y :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (_x : α) => has_sum_iff_has_sum_of_ne_zero_bij i hi hf hfg\n\ntheorem tsum_subtype {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] (s : set β) (f : β → α) : (tsum fun (x : ↥s) => f ↑x) = tsum fun (x : β) => set.indicator s f x :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (_x : α) => has_sum_subtype_iff_indicator\n\ntheorem tsum_add {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] {f : β → α} {g : β → α} [has_continuous_add α] (hf : summable f) (hg : summable g) : (tsum fun (b : β) => f b + g b) = (tsum fun (b : β) => f b) + tsum fun (b : β) => g b :=\n  has_sum.tsum_eq (has_sum.add (summable.has_sum hf) (summable.has_sum hg))\n\ntheorem tsum_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] [has_continuous_add α] {f : γ → β → α} {s : finset γ} (hf : ∀ (i : γ), i ∈ s → summable (f i)) : (tsum fun (b : β) => finset.sum s fun (i : γ) => f i b) = finset.sum s fun (i : γ) => tsum fun (b : β) => f i b :=\n  has_sum.tsum_eq (has_sum_sum fun (i : γ) (hi : i ∈ s) => summable.has_sum (hf i hi))\n\ntheorem tsum_sigma' {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] [has_continuous_add α] [regular_space α] {γ : β → Type u_3} {f : (sigma fun (b : β) => γ b) → α} (h₁ : ∀ (b : β), summable fun (c : γ b) => f (sigma.mk b c)) (h₂ : summable f) : (tsum fun (p : sigma fun (b : β) => γ b) => f p) = tsum fun (b : β) => tsum fun (c : γ b) => f (sigma.mk b c) :=\n  Eq.symm (has_sum.tsum_eq (has_sum.sigma (summable.has_sum h₂) fun (b : β) => summable.has_sum (h₁ b)))\n\ntheorem tsum_prod' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] [has_continuous_add α] [regular_space α] {f : β × γ → α} (h : summable f) (h₁ : ∀ (b : β), summable fun (c : γ) => f (b, c)) : (tsum fun (p : β × γ) => f p) = tsum fun (b : β) => tsum fun (c : γ) => f (b, c) :=\n  Eq.symm (has_sum.tsum_eq (has_sum.prod_fiberwise (summable.has_sum h) fun (b : β) => summable.has_sum (h₁ b)))\n\ntheorem tsum_comm' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] [has_continuous_add α] [regular_space α] {f : β → γ → α} (h : summable (function.uncurry f)) (h₁ : ∀ (b : β), summable (f b)) (h₂ : ∀ (c : γ), summable fun (b : β) => f b c) : (tsum fun (c : γ) => tsum fun (b : β) => f b c) = tsum fun (b : β) => tsum fun (c : γ) => f b c := sorry\n\n/-- You can compute a sum over an encodably type by summing over the natural numbers and\n  taking a supremum. This is useful for outer measures. -/\ntheorem tsum_supr_decode2 {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] [encodable γ] [complete_lattice β] (m : β → α) (m0 : m ⊥ = 0) (s : γ → β) : (tsum fun (i : ℕ) => m (supr fun (b : γ) => supr fun (H : b ∈ encodable.decode2 γ i) => s b)) =\n  tsum fun (b : γ) => m (s b) := sorry\n\n/-- `tsum_supr_decode2` specialized to the complete lattice of sets. -/\ntheorem tsum_Union_decode2 {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] [encodable γ] (m : set β → α) (m0 : m ∅ = 0) (s : γ → set β) : (tsum fun (i : ℕ) => m (set.Union fun (b : γ) => set.Union fun (H : b ∈ encodable.decode2 γ i) => s b)) =\n  tsum fun (b : γ) => m (s b) :=\n  tsum_supr_decode2 m m0 s\n\n/-! Some properties about measure-like functions.\n  These could also be functions defined on complete sublattices of sets, with the property\n  that they are countably sub-additive.\n  `R` will probably be instantiated with `(≤)` in all applications.\n-/\n\n/-- If a function is countably sub-additive then it is sub-additive on encodable types -/\ntheorem rel_supr_tsum {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_monoid α] [topological_space α] [t2_space α] [encodable γ] [complete_lattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop) (m_supr : ∀ (s : ℕ → β), R (m (supr fun (i : ℕ) => s i)) (tsum fun (i : ℕ) => m (s i))) (s : γ → β) : R (m (supr fun (b : γ) => s b)) (tsum fun (b : γ) => m (s b)) := sorry\n\n/-- If a function is countably sub-additive then it is sub-additive on finite sets -/\ntheorem rel_supr_sum {α : Type u_1} {β : Type u_2} {δ : Type u_4} [add_comm_monoid α] [topological_space α] [t2_space α] [complete_lattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop) (m_supr : ∀ (s : ℕ → β), R (m (supr fun (i : ℕ) => s i)) (tsum fun (i : ℕ) => m (s i))) (s : δ → β) (t : finset δ) : R (m (supr fun (d : δ) => supr fun (H : d ∈ t) => s d)) (finset.sum t fun (d : δ) => m (s d)) := sorry\n\n/-- If a function is countably sub-additive then it is binary sub-additive -/\ntheorem rel_sup_add {α : Type u_1} {β : Type u_2} [add_comm_monoid α] [topological_space α] [t2_space α] [complete_lattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop) (m_supr : ∀ (s : ℕ → β), R (m (supr fun (i : ℕ) => s i)) (tsum fun (i : ℕ) => m (s i))) (s₁ : β) (s₂ : β) : R (m (s₁ ⊔ s₂)) (m s₁ + m s₂) := sorry\n\ntheorem pi.has_sum {α : Type u_1} {ι : Type u_5} {π : α → Type u_6} [(x : α) → add_comm_monoid (π x)] [(x : α) → topological_space (π x)] {f : ι → (x : α) → π x} {g : (x : α) → π x} : has_sum f g ↔ ∀ (x : α), has_sum (fun (i : ι) => f i x) (g x) := sorry\n\ntheorem pi.summable {α : Type u_1} {ι : Type u_5} {π : α → Type u_6} [(x : α) → add_comm_monoid (π x)] [(x : α) → topological_space (π x)] {f : ι → (x : α) → π x} : summable f ↔ ∀ (x : α), summable fun (i : ι) => f i x := sorry\n\ntheorem tsum_apply {α : Type u_1} {ι : Type u_5} {π : α → Type u_6} [(x : α) → add_comm_monoid (π x)] [(x : α) → topological_space (π x)] [∀ (x : α), t2_space (π x)] {f : ι → (x : α) → π x} {x : α} (hf : summable f) : tsum (fun (i : ι) => f i) x = tsum fun (i : ι) => f i x :=\n  Eq.symm (has_sum.tsum_eq (iff.mp pi.has_sum (summable.has_sum hf) x))\n\n-- `by simpa using` speeds up elaboration. Why?\n\ntheorem has_sum.neg {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {a : α} (h : has_sum f a) : has_sum (fun (b : β) => -f b) (-a) :=\n  eq.mpr (id (Eq.refl (has_sum (fun (b : β) => -f b) (-a))))\n    (eq.mp (Eq.refl (has_sum (⇑(-add_monoid_hom.id α) ∘ f) (coe_fn (-add_monoid_hom.id α) a)))\n      (has_sum.map h (-add_monoid_hom.id α) continuous_neg))\n\ntheorem summable.neg {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} (hf : summable f) : summable fun (b : β) => -f b :=\n  has_sum.summable (has_sum.neg (summable.has_sum hf))\n\ntheorem summable.of_neg {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} (hf : summable fun (b : β) => -f b) : summable f := sorry\n\ntheorem summable_neg_iff {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} : (summable fun (b : β) => -f b) ↔ summable f :=\n  { mp := summable.of_neg, mpr := summable.neg }\n\ntheorem has_sum.sub {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {g : β → α} {a₁ : α} {a₂ : α} (hf : has_sum f a₁) (hg : has_sum g a₂) : has_sum (fun (b : β) => f b - g b) (a₁ - a₂) := sorry\n\ntheorem summable.sub {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {g : β → α} (hf : summable f) (hg : summable g) : summable fun (b : β) => f b - g b :=\n  has_sum.summable (has_sum.sub (summable.has_sum hf) (summable.has_sum hg))\n\ntheorem has_sum.has_sum_compl_iff {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {a₁ : α} {a₂ : α} {s : set β} (hf : has_sum (f ∘ coe) a₁) : has_sum (f ∘ coe) a₂ ↔ has_sum f (a₁ + a₂) := sorry\n\ntheorem has_sum.has_sum_iff_compl {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {a₁ : α} {a₂ : α} {s : set β} (hf : has_sum (f ∘ coe) a₁) : has_sum f a₂ ↔ has_sum (f ∘ coe) (a₂ - a₁) := sorry\n\ntheorem summable.summable_compl_iff {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {s : set β} (hf : summable (f ∘ coe)) : summable (f ∘ coe) ↔ summable f := sorry\n\nprotected theorem finset.has_sum_compl_iff {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {a : α} (s : finset β) : has_sum (fun (x : Subtype fun (x : β) => ¬x ∈ s) => f ↑x) a ↔ has_sum f (a + finset.sum s fun (i : β) => f i) := sorry\n\nprotected theorem finset.has_sum_iff_compl {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {a : α} (s : finset β) : has_sum f a ↔ has_sum (fun (x : Subtype fun (x : β) => ¬x ∈ s) => f ↑x) (a - finset.sum s fun (i : β) => f i) :=\n  has_sum.has_sum_iff_compl (finset.has_sum s f)\n\nprotected theorem finset.summable_compl_iff {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} (s : finset β) : (summable fun (x : Subtype fun (x : β) => ¬x ∈ s) => f ↑x) ↔ summable f :=\n  summable.summable_compl_iff (finset.summable s f)\n\ntheorem set.finite.summable_compl_iff {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {s : set β} (hs : set.finite s) : summable (f ∘ coe) ↔ summable f :=\n  summable.summable_compl_iff (set.finite.summable hs f)\n\ntheorem tsum_neg {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} [t2_space α] (hf : summable f) : (tsum fun (b : β) => -f b) = -tsum fun (b : β) => f b :=\n  has_sum.tsum_eq (has_sum.neg (summable.has_sum hf))\n\ntheorem tsum_sub {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} {g : β → α} [t2_space α] (hf : summable f) (hg : summable g) : (tsum fun (b : β) => f b - g b) = (tsum fun (b : β) => f b) - tsum fun (b : β) => g b :=\n  has_sum.tsum_eq (has_sum.sub (summable.has_sum hf) (summable.has_sum hg))\n\ntheorem tsum_add_tsum_compl {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} [t2_space α] {s : set β} (hs : summable (f ∘ coe)) (hsc : summable (f ∘ coe)) : ((tsum fun (x : ↥s) => f ↑x) + tsum fun (x : ↥(sᶜ)) => f ↑x) = tsum fun (x : β) => f x :=\n  Eq.symm (has_sum.tsum_eq (has_sum.add_compl (summable.has_sum hs) (summable.has_sum hsc)))\n\ntheorem sum_add_tsum_compl {α : Type u_1} {β : Type u_2} [add_comm_group α] [topological_space α] [topological_add_group α] {f : β → α} [t2_space α] {s : finset β} (hf : summable f) : ((finset.sum s fun (x : β) => f x) + tsum fun (x : ↥(↑sᶜ)) => f ↑x) = tsum fun (x : β) => f x :=\n  Eq.symm\n    (has_sum.tsum_eq\n      (has_sum.add_compl (finset.has_sum s f) (summable.has_sum (iff.mpr (finset.summable_compl_iff s) hf))))\n\n/-!\n### Sums on subtypes\n\nIf `s` is a finset of `α`, we show that the summability of `f` in the whole space and on the subtype\n`univ - s` are equivalent, and relate their sums. For a function defined on `ℕ`, we deduce the\nformula `(∑ i in range k, f i) + (∑' i, f (i + k)) = (∑' i, f i)`, in `sum_add_tsum_nat_add`.\n-/\n\ntheorem has_sum_nat_add_iff {α : Type u_1} [add_comm_group α] [topological_space α] [topological_add_group α] {f : ℕ → α} (k : ℕ) {a : α} : has_sum (fun (n : ℕ) => f (n + k)) a ↔ has_sum f (a + finset.sum (finset.range k) fun (i : ℕ) => f i) := sorry\n\ntheorem summable_nat_add_iff {α : Type u_1} [add_comm_group α] [topological_space α] [topological_add_group α] {f : ℕ → α} (k : ℕ) : (summable fun (n : ℕ) => f (n + k)) ↔ summable f :=\n  iff.symm\n    (equiv.summable_iff_of_has_sum_iff (equiv.add_right (finset.sum (finset.range k) fun (i : ℕ) => f i))\n      fun (a : α) => iff.symm (has_sum_nat_add_iff k))\n\ntheorem has_sum_nat_add_iff' {α : Type u_1} [add_comm_group α] [topological_space α] [topological_add_group α] {f : ℕ → α} (k : ℕ) {a : α} : has_sum (fun (n : ℕ) => f (n + k)) (a - finset.sum (finset.range k) fun (i : ℕ) => f i) ↔ has_sum f a := sorry\n\ntheorem sum_add_tsum_nat_add {α : Type u_1} [add_comm_group α] [topological_space α] [topological_add_group α] [t2_space α] {f : ℕ → α} (k : ℕ) (h : summable f) : ((finset.sum (finset.range k) fun (i : ℕ) => f i) + tsum fun (i : ℕ) => f (i + k)) = tsum fun (i : ℕ) => f i := sorry\n\ntheorem tsum_eq_zero_add {α : Type u_1} [add_comm_group α] [topological_space α] [topological_add_group α] [t2_space α] {f : ℕ → α} (hf : summable f) : (tsum fun (b : ℕ) => f b) = f 0 + tsum fun (b : ℕ) => f (b + 1) := sorry\n\n/-- For `f : ℕ → α`, then `∑' k, f (k + i)` tends to zero. This does not require a summability\nassumption on `f`, as otherwise all sums are zero. -/\ntheorem tendsto_sum_nat_add {α : Type u_1} [add_comm_group α] [topological_space α] [topological_add_group α] [t2_space α] (f : ℕ → α) : filter.tendsto (fun (i : ℕ) => tsum fun (k : ℕ) => f (k + i)) filter.at_top (nhds 0) := sorry\n\ntheorem has_sum.mul_left {α : Type u_1} {β : Type u_2} [semiring α] [topological_space α] [topological_semiring α] {f : β → α} {a₁ : α} (a₂ : α) (h : has_sum f a₁) : has_sum (fun (b : β) => a₂ * f b) (a₂ * a₁) :=\n  eq.mpr (id (Eq.refl (has_sum (fun (b : β) => a₂ * f b) (a₂ * a₁))))\n    (eq.mp (Eq.refl (has_sum (⇑(add_monoid_hom.mul_left a₂) ∘ f) (coe_fn (add_monoid_hom.mul_left a₂) a₁)))\n      (has_sum.map h (add_monoid_hom.mul_left a₂) (continuous.mul continuous_const continuous_id)))\n\ntheorem has_sum.mul_right {α : Type u_1} {β : Type u_2} [semiring α] [topological_space α] [topological_semiring α] {f : β → α} {a₁ : α} (a₂ : α) (hf : has_sum f a₁) : has_sum (fun (b : β) => f b * a₂) (a₁ * a₂) :=\n  eq.mpr (id (Eq.refl (has_sum (fun (b : β) => f b * a₂) (a₁ * a₂))))\n    (eq.mp (Eq.refl (has_sum (⇑(add_monoid_hom.mul_right a₂) ∘ f) (coe_fn (add_monoid_hom.mul_right a₂) a₁)))\n      (has_sum.map hf (add_monoid_hom.mul_right a₂) (continuous.mul continuous_id continuous_const)))\n\ntheorem summable.mul_left {α : Type u_1} {β : Type u_2} [semiring α] [topological_space α] [topological_semiring α] {f : β → α} (a : α) (hf : summable f) : summable fun (b : β) => a * f b :=\n  has_sum.summable (has_sum.mul_left a (summable.has_sum hf))\n\ntheorem summable.mul_right {α : Type u_1} {β : Type u_2} [semiring α] [topological_space α] [topological_semiring α] {f : β → α} (a : α) (hf : summable f) : summable fun (b : β) => f b * a :=\n  has_sum.summable (has_sum.mul_right a (summable.has_sum hf))\n\ntheorem summable.tsum_mul_left {α : Type u_1} {β : Type u_2} [semiring α] [topological_space α] [topological_semiring α] {f : β → α} [t2_space α] (a : α) (hf : summable f) : (tsum fun (b : β) => a * f b) = a * tsum fun (b : β) => f b :=\n  has_sum.tsum_eq (has_sum.mul_left a (summable.has_sum hf))\n\ntheorem summable.tsum_mul_right {α : Type u_1} {β : Type u_2} [semiring α] [topological_space α] [topological_semiring α] {f : β → α} [t2_space α] (a : α) (hf : summable f) : (tsum fun (b : β) => f b * a) = (tsum fun (b : β) => f b) * a :=\n  has_sum.tsum_eq (has_sum.mul_right a (summable.has_sum hf))\n\ntheorem has_sum.smul {α : Type u_1} {β : Type u_2} {R : Type u_5} [semiring R] [topological_space R] [topological_space α] [add_comm_monoid α] [semimodule R α] [topological_semimodule R α] {f : β → α} {a : α} {r : R} (hf : has_sum f a) : has_sum (fun (z : β) => r • f z) (r • a) :=\n  has_sum.map hf (const_smul_hom α r) (continuous.smul continuous_const continuous_id)\n\ntheorem summable.smul {α : Type u_1} {β : Type u_2} {R : Type u_5} [semiring R] [topological_space R] [topological_space α] [add_comm_monoid α] [semimodule R α] [topological_semimodule R α] {f : β → α} {r : R} (hf : summable f) : summable fun (z : β) => r • f z :=\n  has_sum.summable (has_sum.smul (summable.has_sum hf))\n\ntheorem tsum_smul {α : Type u_1} {β : Type u_2} {R : Type u_5} [semiring R] [topological_space R] [topological_space α] [add_comm_monoid α] [semimodule R α] [topological_semimodule R α] {f : β → α} [t2_space α] {r : R} (hf : summable f) : (tsum fun (z : β) => r • f z) = r • tsum fun (z : β) => f z :=\n  has_sum.tsum_eq (has_sum.smul (summable.has_sum hf))\n\ntheorem has_sum.div_const {α : Type u_1} {β : Type u_2} [division_ring α] [topological_space α] [topological_semiring α] {f : β → α} {a : α} (h : has_sum f a) (b : α) : has_sum (fun (x : β) => f x / b) (a / b) := sorry\n\ntheorem has_sum_mul_left_iff {α : Type u_1} {β : Type u_2} [division_ring α] [topological_space α] [topological_semiring α] {f : β → α} {a₁ : α} {a₂ : α} (h : a₂ ≠ 0) : has_sum f a₁ ↔ has_sum (fun (b : β) => a₂ * f b) (a₂ * a₁) := sorry\n\ntheorem has_sum_mul_right_iff {α : Type u_1} {β : Type u_2} [division_ring α] [topological_space α] [topological_semiring α] {f : β → α} {a₁ : α} {a₂ : α} (h : a₂ ≠ 0) : has_sum f a₁ ↔ has_sum (fun (b : β) => f b * a₂) (a₁ * a₂) := sorry\n\ntheorem summable_mul_left_iff {α : Type u_1} {β : Type u_2} [division_ring α] [topological_space α] [topological_semiring α] {f : β → α} {a : α} (h : a ≠ 0) : summable f ↔ summable fun (b : β) => a * f b := sorry\n\ntheorem summable_mul_right_iff {α : Type u_1} {β : Type u_2} [division_ring α] [topological_space α] [topological_semiring α] {f : β → α} {a : α} (h : a ≠ 0) : summable f ↔ summable fun (b : β) => f b * a := sorry\n\ntheorem tsum_mul_left {α : Type u_1} {β : Type u_2} [division_ring α] [topological_space α] [topological_semiring α] {f : β → α} {a : α} [t2_space α] : (tsum fun (x : β) => a * f x) = a * tsum fun (x : β) => f x := sorry\n\ntheorem tsum_mul_right {α : Type u_1} {β : Type u_2} [division_ring α] [topological_space α] [topological_semiring α] {f : β → α} {a : α} [t2_space α] : (tsum fun (x : β) => f x * a) = (tsum fun (x : β) => f x) * a := sorry\n\ntheorem has_sum_le {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} {g : β → α} {a₁ : α} {a₂ : α} (h : ∀ (b : β), f b ≤ g b) (hf : has_sum f a₁) (hg : has_sum g a₂) : a₁ ≤ a₂ :=\n  le_of_tendsto_of_tendsto' hf hg fun (s : finset β) => finset.sum_le_sum fun (b : β) (_x : b ∈ s) => h b\n\ntheorem has_sum_le_inj {α : Type u_1} {β : Type u_2} {γ : Type u_3} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} {a₁ : α} {a₂ : α} {g : γ → α} (i : β → γ) (hi : function.injective i) (hs : ∀ (c : γ), ¬c ∈ set.range i → 0 ≤ g c) (h : ∀ (b : β), f b ≤ g (i b)) (hf : has_sum f a₁) (hg : has_sum g a₂) : a₁ ≤ a₂ := sorry\n\ntheorem tsum_le_tsum_of_inj {α : Type u_1} {β : Type u_2} {γ : Type u_3} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} {g : γ → α} (i : β → γ) (hi : function.injective i) (hs : ∀ (c : γ), ¬c ∈ set.range i → 0 ≤ g c) (h : ∀ (b : β), f b ≤ g (i b)) (hf : summable f) (hg : summable g) : tsum f ≤ tsum g :=\n  has_sum_le_inj i hi hs h (summable.has_sum hf) (summable.has_sum hg)\n\ntheorem sum_le_has_sum {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {a : α} {f : β → α} (s : finset β) (hs : ∀ (b : β), ¬b ∈ s → 0 ≤ f b) (hf : has_sum f a) : (finset.sum s fun (b : β) => f b) ≤ a := sorry\n\ntheorem le_has_sum {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} {a : α} (hf : has_sum f a) (b : β) (hb : ∀ (b' : β), b' ≠ b → 0 ≤ f b') : f b ≤ a := sorry\n\ntheorem sum_le_tsum {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} (s : finset β) (hs : ∀ (b : β), ¬b ∈ s → 0 ≤ f b) (hf : summable f) : (finset.sum s fun (b : β) => f b) ≤ tsum f :=\n  sum_le_has_sum s hs (summable.has_sum hf)\n\ntheorem le_tsum {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} (hf : summable f) (b : β) (hb : ∀ (b' : β), b' ≠ b → 0 ≤ f b') : f b ≤ tsum fun (b : β) => f b :=\n  le_has_sum (summable.has_sum hf) b hb\n\ntheorem tsum_le_tsum {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} {g : β → α} (h : ∀ (b : β), f b ≤ g b) (hf : summable f) (hg : summable g) : (tsum fun (b : β) => f b) ≤ tsum fun (b : β) => g b :=\n  has_sum_le h (summable.has_sum hf) (summable.has_sum hg)\n\ntheorem has_sum.nonneg {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {g : β → α} {a : α} (h : ∀ (b : β), 0 ≤ g b) (ha : has_sum g a) : 0 ≤ a :=\n  has_sum_le h has_sum_zero ha\n\ntheorem has_sum.nonpos {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {g : β → α} {a : α} (h : ∀ (b : β), g b ≤ 0) (ha : has_sum g a) : a ≤ 0 :=\n  has_sum_le h ha has_sum_zero\n\ntheorem tsum_nonneg {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {g : β → α} (h : ∀ (b : β), 0 ≤ g b) : 0 ≤ tsum fun (b : β) => g b := sorry\n\ntheorem tsum_nonpos {α : Type u_1} {β : Type u_2} [ordered_add_comm_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} (h : ∀ (b : β), f b ≤ 0) : (tsum fun (b : β) => f b) ≤ 0 := sorry\n\ntheorem le_has_sum' {α : Type u_1} {β : Type u_2} [canonically_ordered_add_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} {a : α} (hf : has_sum f a) (b : β) : f b ≤ a :=\n  le_has_sum hf b fun (_x : β) (_x_1 : _x ≠ b) => zero_le (f _x)\n\ntheorem le_tsum' {α : Type u_1} {β : Type u_2} [canonically_ordered_add_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} (hf : summable f) (b : β) : f b ≤ tsum fun (b : β) => f b :=\n  le_tsum hf b fun (_x : β) (_x_1 : _x ≠ b) => zero_le (f _x)\n\ntheorem has_sum_zero_iff {α : Type u_1} {β : Type u_2} [canonically_ordered_add_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} : has_sum f 0 ↔ ∀ (x : β), f x = 0 := sorry\n\ntheorem tsum_eq_zero_iff {α : Type u_1} {β : Type u_2} [canonically_ordered_add_monoid α] [topological_space α] [order_closed_topology α] {f : β → α} (hf : summable f) : (tsum fun (i : β) => f i) = 0 ↔ ∀ (x : β), f x = 0 := sorry\n\ntheorem summable_iff_cauchy_seq_finset {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [complete_space α] {f : β → α} : summable f ↔ cauchy_seq fun (s : finset β) => finset.sum s fun (b : β) => f b :=\n  iff.symm cauchy_map_iff_exists_tendsto\n\ntheorem cauchy_seq_finset_iff_vanishing {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] {f : β → α} : (cauchy_seq fun (s : finset β) => finset.sum s fun (b : β) => f b) ↔\n  ∀ (e : set α), e ∈ nhds 0 → ∃ (s : finset β), ∀ (t : finset β), disjoint t s → (finset.sum t fun (b : β) => f b) ∈ e := sorry\n\ntheorem summable_iff_vanishing {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] {f : β → α} [complete_space α] : summable f ↔\n  ∀ (e : set α), e ∈ nhds 0 → ∃ (s : finset β), ∀ (t : finset β), disjoint t s → (finset.sum t fun (b : β) => f b) ∈ e := sorry\n\n/- TODO: generalize to monoid with a uniform continuous subtraction operator: `(a + b) - b = a` -/\n\ntheorem summable.summable_of_eq_zero_or_self {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] {f : β → α} {g : β → α} [complete_space α] (hf : summable f) (h : ∀ (b : β), g b = 0 ∨ g b = f b) : summable g := sorry\n\nprotected theorem summable.indicator {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] {f : β → α} [complete_space α] (hf : summable f) (s : set β) : summable (set.indicator s f) :=\n  summable.summable_of_eq_zero_or_self hf (set.indicator_eq_zero_or_self s f)\n\ntheorem summable.comp_injective {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [uniform_space α] [uniform_add_group α] {f : β → α} [complete_space α] {i : γ → β} (hf : summable f) (hi : function.injective i) : summable (f ∘ i) := sorry\n\ntheorem summable.subtype {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] {f : β → α} [complete_space α] (hf : summable f) (s : set β) : summable (f ∘ coe) :=\n  summable.comp_injective hf subtype.coe_injective\n\ntheorem summable_subtype_and_compl {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] {f : β → α} [complete_space α] {s : set β} : ((summable fun (x : ↥s) => f ↑x) ∧ summable fun (x : ↥(sᶜ)) => f ↑x) ↔ summable f :=\n  { mp := iff.mpr and_imp summable.add_compl,\n    mpr := fun (h : summable f) => { left := summable.subtype h s, right := summable.subtype h (sᶜ) } }\n\ntheorem summable.sigma_factor {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] [complete_space α] {γ : β → Type u_3} {f : (sigma fun (b : β) => γ b) → α} (ha : summable f) (b : β) : summable fun (c : γ b) => f (sigma.mk b c) :=\n  summable.comp_injective ha sigma_mk_injective\n\ntheorem summable.sigma {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] [complete_space α] [regular_space α] {γ : β → Type u_3} {f : (sigma fun (b : β) => γ b) → α} (ha : summable f) : summable fun (b : β) => tsum fun (c : γ b) => f (sigma.mk b c) :=\n  summable.sigma' ha fun (b : β) => summable.sigma_factor ha b\n\ntheorem summable.prod_factor {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [uniform_space α] [uniform_add_group α] [complete_space α] {f : β × γ → α} (h : summable f) (b : β) : summable fun (c : γ) => f (b, c) :=\n  summable.comp_injective h\n    fun (c₁ c₂ : γ) (h : (fun (c : γ) => (b, c)) c₁ = (fun (c : γ) => (b, c)) c₂) => and.right (iff.mp prod.ext_iff h)\n\ntheorem tsum_sigma {α : Type u_1} {β : Type u_2} [add_comm_group α] [uniform_space α] [uniform_add_group α] [complete_space α] [regular_space α] {γ : β → Type u_3} {f : (sigma fun (b : β) => γ b) → α} (ha : summable f) : (tsum fun (p : sigma fun (b : β) => γ b) => f p) = tsum fun (b : β) => tsum fun (c : γ b) => f (sigma.mk b c) :=\n  tsum_sigma' (fun (b : β) => summable.sigma_factor ha b) ha\n\ntheorem tsum_prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [uniform_space α] [uniform_add_group α] [complete_space α] [regular_space α] {f : β × γ → α} (h : summable f) : (tsum fun (p : β × γ) => f p) = tsum fun (b : β) => tsum fun (c : γ) => f (b, c) :=\n  tsum_prod' h (summable.prod_factor h)\n\ntheorem tsum_comm {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [uniform_space α] [uniform_add_group α] [complete_space α] [regular_space α] {f : β → γ → α} (h : summable (function.uncurry f)) : (tsum fun (c : γ) => tsum fun (b : β) => f b c) = tsum fun (b : β) => tsum fun (c : γ) => f b c :=\n  tsum_comm' h (summable.prod_factor h) (summable.prod_factor (summable.prod_symm h))\n\ntheorem summable.vanishing {α : Type u_1} {G : Type u_5} [topological_space G] [add_comm_group G] [topological_add_group G] {f : α → G} (hf : summable f) {e : set G} (he : e ∈ nhds 0) : ∃ (s : finset α), ∀ (t : finset α), disjoint t s → (finset.sum t fun (k : α) => f k) ∈ e := sorry\n\n/-- Series divergence test: if `f` is a convergent series, then `f x` tends to zero along\n`cofinite`. -/\ntheorem summable.tendsto_cofinite_zero {α : Type u_1} {G : Type u_5} [topological_space G] [add_comm_group G] [topological_add_group G] {f : α → G} (hf : summable f) : filter.tendsto f filter.cofinite (nhds 0) := sorry\n\ntheorem summable_abs_iff {α : Type u_1} {β : Type u_2} [linear_ordered_add_comm_group β] [uniform_space β] [uniform_add_group β] [complete_space β] {f : α → β} : (summable fun (x : α) => abs (f x)) ↔ summable f := sorry\n\ntheorem summable.of_abs {α : Type u_1} {β : Type u_2} [linear_ordered_add_comm_group β] [uniform_space β] [uniform_add_group β] [complete_space β] {f : α → β} : (summable fun (x : α) => abs (f x)) → summable f :=\n  iff.mp summable_abs_iff\n\n/-- If the extended distance between consequent points of a sequence is estimated\nby a summable series of `nnreal`s, then the original sequence is a Cauchy sequence. -/\ntheorem cauchy_seq_of_edist_le_of_summable {α : Type u_1} [emetric_space α] {f : ℕ → α} (d : ℕ → nnreal) (hf : ∀ (n : ℕ), edist (f n) (f (Nat.succ n)) ≤ ↑(d n)) (hd : summable d) : cauchy_seq f := sorry\n\n/-- If the distance between consequent points of a sequence is estimated by a summable series,\nthen the original sequence is a Cauchy sequence. -/\ntheorem cauchy_seq_of_dist_le_of_summable {α : Type u_1} [metric_space α] {f : ℕ → α} (d : ℕ → ℝ) (hf : ∀ (n : ℕ), dist (f n) (f (Nat.succ n)) ≤ d n) (hd : summable d) : cauchy_seq f := sorry\n\ntheorem cauchy_seq_of_summable_dist {α : Type u_1} [metric_space α] {f : ℕ → α} (h : summable fun (n : ℕ) => dist (f n) (f (Nat.succ n))) : cauchy_seq f :=\n  cauchy_seq_of_dist_le_of_summable (fun (n : ℕ) => dist (f n) (f (Nat.succ n)))\n    (fun (_x : ℕ) => le_refl (dist (f _x) (f (Nat.succ _x)))) h\n\ntheorem dist_le_tsum_of_dist_le_of_tendsto {α : Type u_1} [metric_space α] {f : ℕ → α} (d : ℕ → ℝ) (hf : ∀ (n : ℕ), dist (f n) (f (Nat.succ n)) ≤ d n) (hd : summable d) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) (n : ℕ) : dist (f n) a ≤ tsum fun (m : ℕ) => d (n + m) := sorry\n\ntheorem dist_le_tsum_of_dist_le_of_tendsto₀ {α : Type u_1} [metric_space α] {f : ℕ → α} (d : ℕ → ℝ) (hf : ∀ (n : ℕ), dist (f n) (f (Nat.succ n)) ≤ d n) (hd : summable d) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a ≤ tsum d := sorry\n\ntheorem dist_le_tsum_dist_of_tendsto {α : Type u_1} [metric_space α] {f : ℕ → α} (h : summable fun (n : ℕ) => dist (f n) (f (Nat.succ n))) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) (n : ℕ) : dist (f n) a ≤ tsum fun (m : ℕ) => dist (f (n + m)) (f (Nat.succ (n + m))) :=\n  (fun (this : dist (f n) a ≤ tsum fun (m : ℕ) => (fun (n : ℕ) => dist (f n) (f (Nat.succ n))) (n + m)) => this)\n    (dist_le_tsum_of_dist_le_of_tendsto (fun (n : ℕ) => dist (f n) (f (Nat.succ n)))\n      (fun (_x : ℕ) => le_refl (dist (f _x) (f (Nat.succ _x)))) h ha n)\n\ntheorem dist_le_tsum_dist_of_tendsto₀ {α : Type u_1} [metric_space α] {f : ℕ → α} (h : summable fun (n : ℕ) => dist (f n) (f (Nat.succ n))) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a ≤ tsum fun (n : ℕ) => dist (f n) (f (Nat.succ n)) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/infinite_sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4859305084634064}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nComputational realization of filters (experimental).\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.filter.cofinite\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 u_4 u_5 \n\nnamespace Mathlib\n\n/-- A `cfilter α σ` is a realization of a filter (base) on `α`,\n  represented by a type `σ` together with operations for the top element and\n  the binary inf operation. -/\nstructure cfilter (α : Type u_1) (σ : Type u_2) [partial_order α] \nwhere\n  f : σ → α\n  pt : σ\n  inf : σ → σ → σ\n  inf_le_left : ∀ (a b : σ), f (inf a b) ≤ f a\n  inf_le_right : ∀ (a b : σ), f (inf a b) ≤ f b\n\nnamespace cfilter\n\n\nprotected instance has_coe_to_fun {α : Type u_1} {σ : Type u_3} [partial_order α] : has_coe_to_fun (cfilter α σ) :=\n  has_coe_to_fun.mk (fun (x : cfilter α σ) => σ → α) f\n\n@[simp] theorem coe_mk {α : Type u_1} {σ : Type u_3} [partial_order α] (f : σ → α) (pt : σ) (inf : σ → σ → σ) (h₁ : ∀ (a b : σ), f (inf a b) ≤ f a) (h₂ : ∀ (a b : σ), f (inf a b) ≤ f b) (a : σ) : coe_fn (mk f pt inf h₁ h₂) a = f a :=\n  rfl\n\n/-- Map a cfilter to an equivalent representation type. -/\ndef of_equiv {α : Type u_1} {σ : Type u_3} {τ : Type u_4} [partial_order α] (E : σ ≃ τ) : cfilter α σ → cfilter α τ :=\n  sorry\n\n@[simp] theorem of_equiv_val {α : Type u_1} {σ : Type u_3} {τ : Type u_4} [partial_order α] (E : σ ≃ τ) (F : cfilter α σ) (a : τ) : coe_fn (of_equiv E F) a = coe_fn F (coe_fn (equiv.symm E) a) := sorry\n\n/-- The filter represented by a `cfilter` is the collection of supersets of\n  elements of the filter base. -/\ndef to_filter {α : Type u_1} {σ : Type u_3} (F : cfilter (set α) σ) : filter α :=\n  filter.mk (set_of fun (a : set α) => ∃ (b : σ), coe_fn F b ⊆ a) sorry sorry sorry\n\n@[simp] theorem mem_to_filter_sets {α : Type u_1} {σ : Type u_3} (F : cfilter (set α) σ) {a : set α} : a ∈ to_filter F ↔ ∃ (b : σ), coe_fn F b ⊆ a :=\n  iff.rfl\n\nend cfilter\n\n\n/-- A realizer for filter `f` is a cfilter which generates `f`. -/\nstructure filter.realizer {α : Type u_1} (f : filter α) \nwhere\n  σ : Type u_5\n  F : cfilter (set α) σ\n  eq : cfilter.to_filter F = f\n\nprotected def cfilter.to_realizer {α : Type u_1} {σ : Type u_3} (F : cfilter (set α) σ) : filter.realizer (cfilter.to_filter F) :=\n  filter.realizer.mk σ F sorry\n\nnamespace filter.realizer\n\n\ntheorem mem_sets {α : Type u_1} {f : filter α} (F : realizer f) {a : set α} : a ∈ f ↔ ∃ (b : σ F), coe_fn (F F) b ⊆ a := sorry\n\n-- Used because it has better definitional equalities than the eq.rec proof\n\ndef of_eq {α : Type u_1} {f : filter α} {g : filter α} (e : f = g) (F : realizer f) : realizer g :=\n  mk (σ F) (F F) sorry\n\n/-- A filter realizes itself. -/\ndef of_filter {α : Type u_1} (f : filter α) : realizer f :=\n  mk (↥(sets f))\n    (cfilter.mk subtype.val { val := set.univ, property := univ_mem_sets } (fun (_x : ↥(sets f)) => sorry) sorry sorry)\n    sorry\n\n/-- Transfer a filter realizer to another realizer on a different base type. -/\ndef of_equiv {α : Type u_1} {τ : Type u_4} {f : filter α} (F : realizer f) (E : σ F ≃ τ) : realizer f :=\n  mk τ (cfilter.of_equiv E (F F)) sorry\n\n@[simp] theorem of_equiv_σ {α : Type u_1} {τ : Type u_4} {f : filter α} (F : realizer f) (E : σ F ≃ τ) : σ (of_equiv F E) = τ :=\n  rfl\n\n@[simp] theorem of_equiv_F {α : Type u_1} {τ : Type u_4} {f : filter α} (F : realizer f) (E : σ F ≃ τ) (s : τ) : coe_fn (F (of_equiv F E)) s = coe_fn (F F) (coe_fn (equiv.symm E) s) := sorry\n\n/-- `unit` is a realizer for the principal filter -/\nprotected def principal {α : Type u_1} (s : set α) : realizer (principal s) :=\n  mk Unit (cfilter.mk (fun (_x : Unit) => s) Unit.unit (fun (_x _x : Unit) => Unit.unit) sorry sorry) sorry\n\n@[simp] theorem principal_σ {α : Type u_1} (s : set α) : σ (realizer.principal s) = Unit :=\n  rfl\n\n@[simp] theorem principal_F {α : Type u_1} (s : set α) (u : Unit) : coe_fn (F (realizer.principal s)) u = s :=\n  rfl\n\n/-- `unit` is a realizer for the top filter -/\nprotected def top {α : Type u_1} : realizer ⊤ :=\n  of_eq principal_univ (realizer.principal set.univ)\n\n@[simp] theorem top_σ {α : Type u_1} : σ realizer.top = Unit :=\n  rfl\n\n@[simp] theorem top_F {α : Type u_1} (u : Unit) : coe_fn (F realizer.top) u = set.univ :=\n  rfl\n\n/-- `unit` is a realizer for the bottom filter -/\nprotected def bot {α : Type u_1} : realizer ⊥ :=\n  of_eq principal_empty (realizer.principal ∅)\n\n@[simp] theorem bot_σ {α : Type u_1} : σ realizer.bot = Unit :=\n  rfl\n\n@[simp] theorem bot_F {α : Type u_1} (u : Unit) : coe_fn (F realizer.bot) u = ∅ :=\n  rfl\n\n/-- Construct a realizer for `map m f` given a realizer for `f` -/\nprotected def map {α : Type u_1} {β : Type u_2} (m : α → β) {f : filter α} (F : realizer f) : realizer (map m f) :=\n  mk (σ F) (cfilter.mk (fun (s : σ F) => m '' coe_fn (F F) s) (cfilter.pt (F F)) (cfilter.inf (F F)) sorry sorry) sorry\n\n@[simp] theorem map_σ {α : Type u_1} {β : Type u_2} (m : α → β) {f : filter α} (F : realizer f) : σ (realizer.map m F) = σ F :=\n  rfl\n\n@[simp] theorem map_F {α : Type u_1} {β : Type u_2} (m : α → β) {f : filter α} (F : realizer f) (s : σ (realizer.map m F)) : coe_fn (F (realizer.map m F)) s = m '' coe_fn (F F) s :=\n  rfl\n\n/-- Construct a realizer for `comap m f` given a realizer for `f` -/\nprotected def comap {α : Type u_1} {β : Type u_2} (m : α → β) {f : filter β} (F : realizer f) : realizer (comap m f) :=\n  mk (σ F) (cfilter.mk (fun (s : σ F) => m ⁻¹' coe_fn (F F) s) (cfilter.pt (F F)) (cfilter.inf (F F)) sorry sorry) sorry\n\n/-- Construct a realizer for the sup of two filters -/\nprotected def sup {α : Type u_1} {f : filter α} {g : filter α} (F : realizer f) (G : realizer g) : realizer (f ⊔ g) :=\n  mk (σ F × σ G)\n    (cfilter.mk (fun (_x : σ F × σ G) => sorry) (cfilter.pt (F F), cfilter.pt (F G)) (fun (_x : σ F × σ G) => sorry) sorry\n      sorry)\n    sorry\n\n/-- Construct a realizer for the inf of two filters -/\nprotected def inf {α : Type u_1} {f : filter α} {g : filter α} (F : realizer f) (G : realizer g) : realizer (f ⊓ g) :=\n  mk (σ F × σ G)\n    (cfilter.mk (fun (_x : σ F × σ G) => sorry) (cfilter.pt (F F), cfilter.pt (F G)) (fun (_x : σ F × σ G) => sorry) sorry\n      sorry)\n    sorry\n\n/-- Construct a realizer for the cofinite filter -/\nprotected def cofinite {α : Type u_1} [DecidableEq α] : realizer cofinite :=\n  mk (finset α) (cfilter.mk (fun (s : finset α) => set_of fun (a : α) => ¬a ∈ s) ∅ has_union.union sorry sorry) sorry\n\n/-- Construct a realizer for filter bind -/\nprotected def bind {α : Type u_1} {β : Type u_2} {f : filter α} {m : α → filter β} (F : realizer f) (G : (i : α) → realizer (m i)) : realizer (bind f m) :=\n  mk (sigma fun (s : σ F) => (i : α) → i ∈ coe_fn (F F) s → σ (G i))\n    (cfilter.mk (fun (_x : sigma fun (s : σ F) => (i : α) → i ∈ coe_fn (F F) s → σ (G i)) => sorry)\n      (sigma.mk (cfilter.pt (F F)) fun (i : α) (H : i ∈ coe_fn (F F) (cfilter.pt (F F))) => cfilter.pt (F (G i)))\n      (fun (_x : sigma fun (s : σ F) => (i : α) → i ∈ coe_fn (F F) s → σ (G i)) => sorry) sorry sorry)\n    sorry\n\n/-- Construct a realizer for indexed supremum -/\nprotected def Sup {α : Type u_1} {β : Type u_2} {f : α → filter β} (F : (i : α) → realizer (f i)) : realizer (supr fun (i : α) => f i) :=\n  let F' : realizer (supr fun (i : α) => f i) := of_eq sorry (realizer.bind realizer.top F);\n  of_equiv F'\n    ((fun (this : (sigma fun (u : Unit) => (i : α) → True → σ (F i)) ≃ ((i : α) → σ (F i))) => this)\n      (equiv.mk (fun (_x : sigma fun (u : Unit) => (i : α) → True → σ (F i)) => sorry)\n        (fun (f_1 : (i : α) → σ (F i)) => sigma.mk Unit.unit fun (i : α) (_x : True) => f_1 i) sorry sorry))\n\n/-- Construct a realizer for the product of filters -/\nprotected def prod {α : Type u_1} {f : filter α} {g : filter α} (F : realizer f) (G : realizer g) : realizer (filter.prod f g) :=\n  realizer.inf (realizer.comap prod.fst F) (realizer.comap prod.snd G)\n\ntheorem le_iff {α : Type u_1} {f : filter α} {g : filter α} (F : realizer f) (G : realizer g) : f ≤ g ↔ ∀ (b : σ G), ∃ (a : σ F), coe_fn (F F) a ≤ coe_fn (F G) b := sorry\n\ntheorem tendsto_iff {α : Type u_1} {β : Type u_2} (f : α → β) {l₁ : filter α} {l₂ : filter β} (L₁ : realizer l₁) (L₂ : realizer l₂) : tendsto f l₁ l₂ ↔ ∀ (b : σ L₂), ∃ (a : σ L₁), ∀ (x : α), x ∈ coe_fn (F L₁) a → f x ∈ coe_fn (F L₂) b :=\n  iff.trans (le_iff (realizer.map f L₁) L₂)\n    (forall_congr fun (b : σ L₂) => exists_congr fun (a : σ (realizer.map f L₁)) => set.image_subset_iff)\n\ntheorem ne_bot_iff {α : Type u_1} {f : filter α} (F : realizer f) : f ≠ ⊥ ↔ ∀ (a : σ F), set.nonempty (coe_fn (F F) a) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/analysis/filter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.48593050565850454}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.monoidal.natural_transformation\n! leanprover-community/mathlib commit cb3ceec8485239a61ed51d944cb9a95b68c6bafc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Monoidal.Functor\nimport Mathbin.CategoryTheory.FullSubcategory\n\n/-!\n# Monoidal natural transformations\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nNatural transformations between (lax) monoidal functors must satisfy\nan additional compatibility relation with the tensorators:\n`F.μ X Y ≫ app (X ⊗ Y) = (app X ⊗ app Y) ≫ G.μ X Y`.\n\n(Lax) monoidal functors between a fixed pair of monoidal categories\nthemselves form a category.\n-/\n\n\nopen CategoryTheory\n\nuniverse v₁ v₂ v₃ u₁ u₂ u₃\n\nopen CategoryTheory.Category\n\nopen CategoryTheory.Functor\n\nnamespace CategoryTheory\n\nopen MonoidalCategory\n\nvariable {C : Type u₁} [Category.{v₁} C] [MonoidalCategory.{v₁} C] {D : Type u₂} [Category.{v₂} D]\n  [MonoidalCategory.{v₂} D]\n\n#print CategoryTheory.MonoidalNatTrans /-\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- A monoidal natural transformation is a natural transformation between (lax) monoidal functors\nadditionally satisfying:\n`F.μ X Y ≫ app (X ⊗ Y) = (app X ⊗ app Y) ≫ G.μ X Y`\n-/\n@[ext]\nstructure MonoidalNatTrans (F G : LaxMonoidalFunctor C D) extends\n  NatTrans F.toFunctor G.toFunctor where\n  unit' : F.ε ≫ app (𝟙_ C) = G.ε := by obviously\n  tensor' : ∀ X Y, F.μ _ _ ≫ app (X ⊗ Y) = (app X ⊗ app Y) ≫ G.μ _ _ := by obviously\n#align category_theory.monoidal_nat_trans CategoryTheory.MonoidalNatTrans\n-/\n\nrestate_axiom monoidal_nat_trans.tensor'\n\nattribute [simp, reassoc.1] monoidal_nat_trans.tensor\n\nrestate_axiom monoidal_nat_trans.unit'\n\nattribute [simp, reassoc.1] monoidal_nat_trans.unit\n\nnamespace MonoidalNatTrans\n\n#print CategoryTheory.MonoidalNatTrans.id /-\n/-- The identity monoidal natural transformation.\n-/\n@[simps]\ndef id (F : LaxMonoidalFunctor C D) : MonoidalNatTrans F F :=\n  { 𝟙 F.toFunctor with }\n#align category_theory.monoidal_nat_trans.id CategoryTheory.MonoidalNatTrans.id\n-/\n\ninstance (F : LaxMonoidalFunctor C D) : Inhabited (MonoidalNatTrans F F) :=\n  ⟨id F⟩\n\n#print CategoryTheory.MonoidalNatTrans.vcomp /-\n/-- Vertical composition of monoidal natural transformations.\n-/\n@[simps]\ndef vcomp {F G H : LaxMonoidalFunctor C D} (α : MonoidalNatTrans F G) (β : MonoidalNatTrans G H) :\n    MonoidalNatTrans F H :=\n  { NatTrans.vcomp α.toNatTrans β.toNatTrans with }\n#align category_theory.monoidal_nat_trans.vcomp CategoryTheory.MonoidalNatTrans.vcomp\n-/\n\n#print CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor /-\ninstance categoryLaxMonoidalFunctor : Category (LaxMonoidalFunctor C D)\n    where\n  Hom := MonoidalNatTrans\n  id := id\n  comp F G H α β := vcomp α β\n#align category_theory.monoidal_nat_trans.category_lax_monoidal_functor CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor\n-/\n\n#print CategoryTheory.MonoidalNatTrans.comp_toNatTrans_lax /-\n@[simp]\ntheorem comp_toNatTrans_lax {F G H : LaxMonoidalFunctor C D} {α : F ⟶ G} {β : G ⟶ H} :\n    (α ≫ β).toNatTrans = @CategoryStruct.comp (C ⥤ D) _ _ _ _ α.toNatTrans β.toNatTrans :=\n  rfl\n#align category_theory.monoidal_nat_trans.comp_to_nat_trans_lax CategoryTheory.MonoidalNatTrans.comp_toNatTrans_lax\n-/\n\n#print CategoryTheory.MonoidalNatTrans.categoryMonoidalFunctor /-\ninstance categoryMonoidalFunctor : Category (MonoidalFunctor C D) :=\n  InducedCategory.category MonoidalFunctor.toLaxMonoidalFunctor\n#align category_theory.monoidal_nat_trans.category_monoidal_functor CategoryTheory.MonoidalNatTrans.categoryMonoidalFunctor\n-/\n\n#print CategoryTheory.MonoidalNatTrans.comp_toNatTrans /-\n@[simp]\ntheorem comp_toNatTrans {F G H : MonoidalFunctor C D} {α : F ⟶ G} {β : G ⟶ H} :\n    (α ≫ β).toNatTrans = @CategoryStruct.comp (C ⥤ D) _ _ _ _ α.toNatTrans β.toNatTrans :=\n  rfl\n#align category_theory.monoidal_nat_trans.comp_to_nat_trans CategoryTheory.MonoidalNatTrans.comp_toNatTrans\n-/\n\nvariable {E : Type u₃} [Category.{v₃} E] [MonoidalCategory.{v₃} E]\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print CategoryTheory.MonoidalNatTrans.hcomp /-\n/-- Horizontal composition of monoidal natural transformations.\n-/\n@[simps]\ndef hcomp {F G : LaxMonoidalFunctor C D} {H K : LaxMonoidalFunctor D E} (α : MonoidalNatTrans F G)\n    (β : MonoidalNatTrans H K) : MonoidalNatTrans (F ⊗⋙ H) (G ⊗⋙ K) :=\n  {\n    NatTrans.hcomp α.toNatTrans\n      β.toNatTrans with\n    unit' := by\n      dsimp; simp\n      conv_lhs => rw [← K.to_functor.map_comp, α.unit]\n    tensor' := fun X Y => by\n      dsimp; simp\n      conv_lhs => rw [← K.to_functor.map_comp, α.tensor, K.to_functor.map_comp] }\n#align category_theory.monoidal_nat_trans.hcomp CategoryTheory.MonoidalNatTrans.hcomp\n-/\n\nsection\n\nattribute [local simp] nat_trans.naturality monoidal_nat_trans.unit monoidal_nat_trans.tensor\n\n#print CategoryTheory.MonoidalNatTrans.prod /-\n/-- The cartesian product of two monoidal natural transformations is monoidal. -/\n@[simps]\ndef prod {F G : LaxMonoidalFunctor C D} {H K : LaxMonoidalFunctor C E} (α : MonoidalNatTrans F G)\n    (β : MonoidalNatTrans H K) : MonoidalNatTrans (F.prod' H) (G.prod' K)\n    where app X := (α.app X, β.app X)\n#align category_theory.monoidal_nat_trans.prod CategoryTheory.MonoidalNatTrans.prod\n-/\n\nend\n\nend MonoidalNatTrans\n\nnamespace MonoidalNatIso\n\nvariable {F G : LaxMonoidalFunctor C D}\n\n/- warning: category_theory.monoidal_nat_iso.of_components -> CategoryTheory.MonoidalNatIso.ofComponents is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (app : forall (X : C), CategoryTheory.Iso.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X)), (forall {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X Y f) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (app Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X Y f))) -> (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (app (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)))) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) -> (forall (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F X Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (app (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.MonoidalCategory.tensorHom.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (app Y))) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G X Y))) -> (CategoryTheory.Iso.{max u3 u2, max u3 u4 u1 u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (app : forall (X : C), CategoryTheory.Iso.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X)), (forall {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X Y f) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (app Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X Y f))) -> (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (app (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)))) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) -> (forall (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F X Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (app (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.MonoidalCategory.tensorHom.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (app Y))) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G X Y))) -> (CategoryTheory.Iso.{max u3 u2, max (max (max u3 u4) u1) u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G)\nCase conversion may be inaccurate. Consider using '#align category_theory.monoidal_nat_iso.of_components CategoryTheory.MonoidalNatIso.ofComponentsₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Construct a monoidal natural isomorphism from object level isomorphisms,\nand the monoidal naturality in the forward direction.\n-/\ndef ofComponents (app : ∀ X : C, F.obj X ≅ G.obj X)\n    (naturality : ∀ {X Y : C} (f : X ⟶ Y), F.map f ≫ (app Y).Hom = (app X).Hom ≫ G.map f)\n    (unit : F.ε ≫ (app (𝟙_ C)).Hom = G.ε)\n    (tensor : ∀ X Y, F.μ X Y ≫ (app (X ⊗ Y)).Hom = ((app X).Hom ⊗ (app Y).Hom) ≫ G.μ X Y) : F ≅ G\n    where\n  Hom := { app := fun X => (app X).Hom }\n  inv :=\n    {\n      (NatIso.ofComponents app\n          @naturality).inv with\n      app := fun X => (app X).inv\n      unit' := by\n        dsimp\n        rw [← Unit, assoc, iso.hom_inv_id, comp_id]\n      tensor' := fun X Y => by\n        dsimp\n        rw [iso.comp_inv_eq, assoc, tensor, ← tensor_comp_assoc, iso.inv_hom_id, iso.inv_hom_id,\n          tensor_id, id_comp] }\n#align category_theory.monoidal_nat_iso.of_components CategoryTheory.MonoidalNatIso.ofComponents\n\n/- warning: category_theory.monoidal_nat_iso.of_components.hom_app -> CategoryTheory.MonoidalNatIso.ofComponents.hom_app is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (app : forall (X : C), CategoryTheory.Iso.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X)) (naturality : forall {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X Y f) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (app Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X Y f))) (unit : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (app (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)))) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (tensor : forall (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F X Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (app (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.MonoidalCategory.tensorHom.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (app Y))) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G X Y))) (X : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X)) (CategoryTheory.NatTrans.app.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalNatTrans.toNatTrans.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G (CategoryTheory.Iso.hom.{max u3 u2, max u3 u4 u1 u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G (CategoryTheory.MonoidalNatIso.ofComponents.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G app naturality unit tensor))) X) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (app : forall (X : C), CategoryTheory.Iso.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X)) (naturality : forall {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X Y f) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (app Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X Y f))) (unit : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (app (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)))) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (tensor : forall (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F X Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (app (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.MonoidalCategory.tensorHom.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (app Y))) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G X Y))) (X : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X)) (CategoryTheory.NatTrans.app.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalNatTrans.toNatTrans.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G (CategoryTheory.Iso.hom.{max u3 u2, max (max (max u3 u4) u1) u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G (CategoryTheory.MonoidalNatIso.ofComponents.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G app naturality unit tensor))) X) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X))\nCase conversion may be inaccurate. Consider using '#align category_theory.monoidal_nat_iso.of_components.hom_app CategoryTheory.MonoidalNatIso.ofComponents.hom_appₓ'. -/\n@[simp]\ntheorem ofComponents.hom_app (app : ∀ X : C, F.obj X ≅ G.obj X) (naturality) (unit) (tensor) (X) :\n    (ofComponents app naturality Unit tensor).Hom.app X = (app X).Hom :=\n  rfl\n#align category_theory.monoidal_nat_iso.of_components.hom_app CategoryTheory.MonoidalNatIso.ofComponents.hom_app\n\n/- warning: category_theory.monoidal_nat_iso.of_components.inv_app -> CategoryTheory.MonoidalNatIso.ofComponents.inv_app is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (app : forall (X : C), CategoryTheory.Iso.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X)) (naturality : forall {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X Y f) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (app Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X Y f))) (unit : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (app (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)))) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (tensor : forall (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F X Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (app (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.MonoidalCategory.tensorHom.{u2, u4} D _inst_3 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) Y) (app Y))) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G X Y))) (X : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X)) (CategoryTheory.NatTrans.app.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalNatTrans.toNatTrans.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G F (CategoryTheory.Iso.inv.{max u3 u2, max u3 u4 u1 u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G (CategoryTheory.MonoidalNatIso.ofComponents.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G app naturality unit tensor))) X) (CategoryTheory.Iso.inv.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (app X))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (app : forall (X : C), CategoryTheory.Iso.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X)) (naturality : forall {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X Y f) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (app Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X Y f))) (unit : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorUnit.{u2, u4} D _inst_3 _inst_4) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)) (app (CategoryTheory.MonoidalCategory.tensorUnit.{u1, u3} C _inst_1 _inst_2)))) (CategoryTheory.LaxMonoidalFunctor.ε.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (tensor : forall (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F X Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (app (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y)) (CategoryTheory.MonoidalCategory.tensorObj.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) (CategoryTheory.MonoidalCategory.tensorObj.{u1, u3} C _inst_1 _inst_2 X Y)) (CategoryTheory.MonoidalCategory.tensorHom.{u2, u4} D _inst_3 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) Y) (app Y))) (CategoryTheory.LaxMonoidalFunctor.μ.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G X Y))) (X : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X)) (CategoryTheory.NatTrans.app.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.MonoidalNatTrans.toNatTrans.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G F (CategoryTheory.Iso.inv.{max u3 u2, max (max (max u3 u4) u1) u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G (CategoryTheory.MonoidalNatIso.ofComponents.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G app naturality unit tensor))) X) (CategoryTheory.Iso.inv.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (app X))\nCase conversion may be inaccurate. Consider using '#align category_theory.monoidal_nat_iso.of_components.inv_app CategoryTheory.MonoidalNatIso.ofComponents.inv_appₓ'. -/\n@[simp]\ntheorem ofComponents.inv_app (app : ∀ X : C, F.obj X ≅ G.obj X) (naturality) (unit) (tensor) (X) :\n    (ofComponents app naturality Unit tensor).inv.app X = (app X).inv := by simp [of_components]\n#align category_theory.monoidal_nat_iso.of_components.inv_app CategoryTheory.MonoidalNatIso.ofComponents.inv_app\n\n/- warning: category_theory.monoidal_nat_iso.is_iso_of_is_iso_app -> CategoryTheory.MonoidalNatIso.isIso_of_isIso_app is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (α : Quiver.Hom.{succ (max u3 u2), max u3 u4 u1 u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.CategoryStruct.toQuiver.{max u3 u2, max u3 u4 u1 u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.Category.toCategoryStruct.{max u3 u2, max u3 u4 u1 u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4))) F G) [_inst_5 : forall (X : C), CategoryTheory.IsIso.{u2, u4} D _inst_3 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) X) (CategoryTheory.NatTrans.app.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalNatTrans.toNatTrans.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G α) X)], CategoryTheory.IsIso.{max u3 u2, max u3 u4 u1 u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G α\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_3 : CategoryTheory.Category.{u2, u4} D] [_inst_4 : CategoryTheory.MonoidalCategory.{u2, u4} D _inst_3] {F : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} {G : CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4} (α : Quiver.Hom.{max (succ u3) (succ u2), max (max (max u3 u4) u1) u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.CategoryStruct.toQuiver.{max u3 u2, max (max (max u3 u4) u1) u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.Category.toCategoryStruct.{max u3 u2, max (max (max u3 u4) u1) u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4))) F G) [_inst_5 : forall (X : C), CategoryTheory.IsIso.{u2, u4} D _inst_3 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F)) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_3)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G)) X) (CategoryTheory.NatTrans.app.{u1, u2, u3, u4} C _inst_1 D _inst_3 (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F) (CategoryTheory.LaxMonoidalFunctor.toFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 G) (CategoryTheory.MonoidalNatTrans.toNatTrans.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4 F G α) X)], CategoryTheory.IsIso.{max u3 u2, max (max (max u3 u4) u1) u2} (CategoryTheory.LaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) (CategoryTheory.MonoidalNatTrans.categoryLaxMonoidalFunctor.{u1, u2, u3, u4} C _inst_1 _inst_2 D _inst_3 _inst_4) F G α\nCase conversion may be inaccurate. Consider using '#align category_theory.monoidal_nat_iso.is_iso_of_is_iso_app CategoryTheory.MonoidalNatIso.isIso_of_isIso_appₓ'. -/\ninstance isIso_of_isIso_app (α : F ⟶ G) [∀ X : C, IsIso (α.app X)] : IsIso α :=\n  ⟨(IsIso.of_iso\n        (ofComponents (fun X => asIso (α.app X)) (fun X Y f => α.toNatTrans.naturality f) α.Unit\n          α.tensor)).1⟩\n#align category_theory.monoidal_nat_iso.is_iso_of_is_iso_app CategoryTheory.MonoidalNatIso.isIso_of_isIso_app\n\nend MonoidalNatIso\n\nnoncomputable section\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print CategoryTheory.monoidalUnit /-\n/-- The unit of a monoidal equivalence can be upgraded to a monoidal natural transformation. -/\n@[simps]\ndef monoidalUnit (F : MonoidalFunctor C D) [IsEquivalence F.toFunctor] :\n    LaxMonoidalFunctor.id C ⟶ F.toLaxMonoidalFunctor ⊗⋙ (monoidalInverse F).toLaxMonoidalFunctor :=\n  let e := F.toFunctor.asEquivalence\n  { toNatTrans := e.Unit\n    tensor' := fun X Y =>\n      by\n      -- This proof is not pretty; golfing welcome!\n      dsimp\n      simp only [adjunction.hom_equiv_unit, adjunction.hom_equiv_naturality_right, category.id_comp,\n        category.assoc]\n      simp only [← functor.map_comp]\n      erw [e.counit_app_functor, e.counit_app_functor, F.to_lax_monoidal_functor.μ_natural,\n        is_iso.inv_hom_id_assoc]\n      simp only [CategoryTheory.IsEquivalence.inv_fun_map]\n      slice_rhs 2 3 => erw [iso.hom_inv_id_app]\n      dsimp\n      simp only [CategoryTheory.Category.id_comp]\n      slice_rhs 1 2 =>\n        rw [← tensor_comp, iso.hom_inv_id_app, iso.hom_inv_id_app]\n        dsimp\n        rw [tensor_id]\n      simp }\n#align category_theory.monoidal_unit CategoryTheory.monoidalUnit\n-/\n\ninstance (F : MonoidalFunctor C D) [IsEquivalence F.toFunctor] : IsIso (monoidalUnit F) :=\n  haveI : ∀ X : C, is_iso ((monoidal_unit F).toNatTrans.app X) :=\n    by\n    intros\n    dsimp\n    infer_instance\n  monoidal_nat_iso.is_iso_of_is_iso_app _\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print CategoryTheory.monoidalCounit /-\n/-- The counit of a monoidal equivalence can be upgraded to a monoidal natural transformation. -/\n@[simps]\ndef monoidalCounit (F : MonoidalFunctor C D) [IsEquivalence F.toFunctor] :\n    (monoidalInverse F).toLaxMonoidalFunctor ⊗⋙ F.toLaxMonoidalFunctor ⟶ LaxMonoidalFunctor.id D :=\n  let e := F.toFunctor.asEquivalence\n  { toNatTrans := e.counit\n    unit' := by\n      dsimp\n      simp only [category.comp_id, category.assoc, functor.map_inv, functor.map_comp,\n        nat_iso.inv_inv_app, is_iso.inv_comp, is_equivalence.fun_inv_map, adjunction.hom_equiv_unit]\n      erw [e.counit_app_functor, ← e.functor.map_comp_assoc, iso.hom_inv_id_app]\n      dsimp; simp\n    tensor' := fun X Y => by\n      dsimp\n      simp only [adjunction.hom_equiv_unit, adjunction.hom_equiv_naturality_right, category.assoc,\n        category.comp_id, functor.map_comp]\n      simp only [is_equivalence.fun_inv_map]\n      erw [e.counit_app_functor]\n      simp only [category.assoc]\n      erw [← e.functor.map_comp_assoc]\n      simp only [CategoryTheory.Iso.inv_hom_id_app, CategoryTheory.Iso.inv_hom_id_app_assoc]\n      erw [iso.hom_inv_id_app]\n      erw [CategoryTheory.Functor.map_id]\n      simp only [category.id_comp]\n      simp only [CategoryTheory.Iso.inv_hom_id_app, CategoryTheory.IsIso.hom_inv_id_assoc]\n      erw [iso.inv_hom_id_app]\n      dsimp; simp; rfl }\n#align category_theory.monoidal_counit CategoryTheory.monoidalCounit\n-/\n\ninstance (F : MonoidalFunctor C D) [IsEquivalence F.toFunctor] : IsIso (monoidalCounit F) :=\n  haveI : ∀ X : D, is_iso ((monoidal_counit F).toNatTrans.app X) :=\n    by\n    intros\n    dsimp\n    infer_instance\n  monoidal_nat_iso.is_iso_of_is_iso_app _\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Monoidal/NaturalTransformation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4859305007625199}}
{"text": "lemma and_trans (P Q R : Prop) : P ∧ Q → Q ∧ R → P ∧ R :=\nbegin\n    intro f,\n    cases f with p q,\n    intro h,\n    cases h with q r,\n    split,\n    exact p,\n    exact r,\nend", "meta": {"author": "Samyak-Surti", "repo": "LeanCode", "sha": "944eac3e5f43e2614ed246083b97fbdf24181d83", "save_path": "github-repos/lean/Samyak-Surti-LeanCode", "path": "github-repos/lean/Samyak-Surti-LeanCode/LeanCode-944eac3e5f43e2614ed246083b97fbdf24181d83/nat_num_game/src/Advanced_Proposition_World/adv_prop_wrld3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195152660688, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.4859304958665352}}
{"text": "import data.nat.modeq data.set.finite data.real.basic \nopen nat\nlocal attribute [instance, priority 0] classical.prop_decidable\nnamespace set\nopen function\nuniverse u\nvariable α : Type u\n-- Author: Chris Hughes\n\ntheorem Q1 (S : set ℝ) (H1 : ∃ s : ℝ, s ∈ S) (H2 : ∃ b : ℝ, ∀ s : ℝ, s ∈ S → s ≤ b) :\n  ∃ x : ℝ, is_lub S x ∧ \n  ∀ T : set ℝ, (T ⊆ S ∧ ∃ t : ℝ, t ∈ T) → ∃ y : ℝ, is_lub T y ∧ y ≤ x := sorry\n\n", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/M1F/problem_bank/PB0701/Q0701.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887587905460026, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.48591833870320195}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Patrick Massot\n-/\nimport algebra.hom.group_instances\nimport data.pi\nimport data.set.function\nimport data.set.pairwise\nimport tactic.pi_instances\n\n/-!\n# Pi instances for groups and monoids\n\nThis file defines instances for group, monoid, semigroup and related structures on Pi types.\n-/\n\nuniverses u v w\nvariable {I : Type u}     -- The indexing type\nvariable {f : I → Type v} -- The family of types already equipped with instances\nvariables (x y : Π i, f i) (i : I)\n\nnamespace pi\n\n@[to_additive]\ninstance semigroup [∀ i, semigroup $ f i] : semigroup (Π i : I, f i) :=\nby refine_struct { mul := (*), .. }; tactic.pi_instance_derive_field\n\ninstance semigroup_with_zero [∀ i, semigroup_with_zero $ f i] :\n  semigroup_with_zero (Π i : I, f i) :=\nby refine_struct { zero := (0 : Π i, f i), mul := (*), .. }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance comm_semigroup [∀ i, comm_semigroup $ f i] : comm_semigroup (Π i : I, f i) :=\nby refine_struct { mul := (*), .. }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance mul_one_class [∀ i, mul_one_class $ f i] : mul_one_class (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), .. }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance monoid [∀ i, monoid $ f i] : monoid (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), npow := λ n x i, (x i) ^ n };\ntactic.pi_instance_derive_field\n\n-- the attributes are intentionally out of order. `smul_apply` proves `nsmul_apply`.\n@[to_additive, simp]\nlemma pow_apply [∀ i, monoid $ f i] (n : ℕ) : (x^n) i = (x i)^n := rfl\n\n@[to_additive]\ninstance comm_monoid [∀ i, comm_monoid $ f i] : comm_monoid (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\n@[to_additive]\ninstance div_inv_monoid [∀ i, div_inv_monoid $ f i] :\n  div_inv_monoid (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), inv := has_inv.inv, div := has_div.div,\n  npow := monoid.npow, zpow := λ z x i, (x i) ^ z }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance group [∀ i, group $ f i] : group (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), inv := has_inv.inv, div := has_div.div,\n  npow := monoid.npow, zpow := div_inv_monoid.zpow }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance comm_group [∀ i, comm_group $ f i] : comm_group (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), inv := has_inv.inv, div := has_div.div,\n  npow := monoid.npow, zpow := div_inv_monoid.zpow }; tactic.pi_instance_derive_field\n\n@[to_additive add_left_cancel_semigroup]\ninstance left_cancel_semigroup [∀ i, left_cancel_semigroup $ f i] :\n  left_cancel_semigroup (Π i : I, f i) :=\nby refine_struct { mul := (*) }; tactic.pi_instance_derive_field\n\n@[to_additive add_right_cancel_semigroup]\ninstance right_cancel_semigroup [∀ i, right_cancel_semigroup $ f i] :\n  right_cancel_semigroup (Π i : I, f i) :=\nby refine_struct { mul := (*) }; tactic.pi_instance_derive_field\n\n@[to_additive add_left_cancel_monoid]\ninstance left_cancel_monoid [∀ i, left_cancel_monoid $ f i] :\n  left_cancel_monoid (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\n@[to_additive add_right_cancel_monoid]\ninstance right_cancel_monoid [∀ i, right_cancel_monoid $ f i] :\n  right_cancel_monoid (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), npow := monoid.npow, .. };\ntactic.pi_instance_derive_field\n\n@[to_additive add_cancel_monoid]\ninstance cancel_monoid [∀ i, cancel_monoid $ f i] :\n  cancel_monoid (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\n@[to_additive add_cancel_comm_monoid]\ninstance cancel_comm_monoid [∀ i, cancel_comm_monoid $ f i] :\n  cancel_comm_monoid (Π i : I, f i) :=\nby refine_struct { one := (1 : Π i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\ninstance mul_zero_class [∀ i, mul_zero_class $ f i] :\n  mul_zero_class (Π i : I, f i) :=\nby refine_struct { zero := (0 : Π i, f i), mul := (*), .. }; tactic.pi_instance_derive_field\n\ninstance mul_zero_one_class [∀ i, mul_zero_one_class $ f i] :\n  mul_zero_one_class (Π i : I, f i) :=\nby refine_struct { zero := (0 : Π i, f i), one := (1 : Π i, f i), mul := (*), .. };\n  tactic.pi_instance_derive_field\n\ninstance monoid_with_zero [∀ i, monoid_with_zero $ f i] :\n  monoid_with_zero (Π i : I, f i) :=\nby refine_struct { zero := (0 : Π i, f i), one := (1 : Π i, f i), mul := (*),\n  npow := monoid.npow }; tactic.pi_instance_derive_field\n\ninstance comm_monoid_with_zero [∀ i, comm_monoid_with_zero $ f i] :\n  comm_monoid_with_zero (Π i : I, f i) :=\nby refine_struct { zero := (0 : Π i, f i), one := (1 : Π i, f i), mul := (*),\n  npow := monoid.npow }; tactic.pi_instance_derive_field\n\nend pi\n\nnamespace mul_hom\n\n@[to_additive] lemma coe_mul {M N} {mM : has_mul M} {mN : comm_semigroup N}\n  (f g : mul_hom M N) :\n  (f * g : M → N) = λ x, f x * g x := rfl\n\nend mul_hom\n\nsection monoid_hom\n\nvariables (f) [Π i, mul_one_class (f i)]\n\n/-- Evaluation of functions into an indexed collection of monoids at a point is a monoid\nhomomorphism.\nThis is `function.eval i` as a `monoid_hom`. -/\n@[to_additive \"Evaluation of functions into an indexed collection of additive monoids at a\npoint is an additive monoid homomorphism.\nThis is `function.eval i` as an `add_monoid_hom`.\", simps]\ndef pi.eval_monoid_hom (i : I) : (Π i, f i) →* f i :=\n{ to_fun := λ g, g i,\n  map_one' := pi.one_apply i,\n  map_mul' := λ x y, pi.mul_apply _ _ i, }\n\n/-- `function.const` as a `monoid_hom`. -/\n@[to_additive \"`function.const` as an `add_monoid_hom`.\", simps]\ndef pi.const_monoid_hom (α β : Type*) [mul_one_class β] : β →* (α → β) :=\n{ to_fun := function.const α,\n  map_one' := rfl,\n  map_mul' := λ _ _, rfl }\n\n/-- Coercion of a `monoid_hom` into a function is itself a `monoid_hom`.\n\nSee also `monoid_hom.eval`. -/\n@[to_additive \"Coercion of an `add_monoid_hom` into a function is itself a `add_monoid_hom`.\n\nSee also `add_monoid_hom.eval`. \", simps]\ndef monoid_hom.coe_fn (α β : Type*) [mul_one_class α] [comm_monoid β] : (α →* β) →* (α → β) :=\n{ to_fun := λ g, g,\n  map_one' := rfl,\n  map_mul' := λ x y, rfl, }\n\n/-- Monoid homomorphism between the function spaces `I → α` and `I → β`, induced by a monoid\nhomomorphism `f` between `α` and `β`. -/\n@[to_additive \"Additive monoid homomorphism between the function spaces `I → α` and `I → β`,\ninduced by an additive monoid homomorphism `f` between `α` and `β`\", simps]\nprotected def monoid_hom.comp_left {α β : Type*} [mul_one_class α] [mul_one_class β] (f : α →* β)\n  (I : Type*) :\n  (I → α) →* (I → β) :=\n{ to_fun := λ h, f ∘ h,\n  map_one' := by ext; simp,\n  map_mul' := λ _ _, by ext; simp }\n\nend monoid_hom\n\nsection single\nvariables [decidable_eq I]\nopen pi\n\nvariables (f)\n\n/-- The one-preserving homomorphism including a single value\ninto a dependent family of values, as functions supported at a point.\n\nThis is the `one_hom` version of `pi.mul_single`. -/\n@[to_additive zero_hom.single \"The zero-preserving homomorphism including a single value\ninto a dependent family of values, as functions supported at a point.\n\nThis is the `zero_hom` version of `pi.single`.\"]\ndef one_hom.single [Π i, has_one $ f i] (i : I) : one_hom (f i) (Π i, f i) :=\n{ to_fun := mul_single i,\n  map_one' := mul_single_one i }\n\n@[simp, to_additive]\nlemma one_hom.single_apply [Π i, has_one $ f i] (i : I) (x : f i) :\n  one_hom.single f i x = mul_single i x := rfl\n\n/-- The monoid homomorphism including a single monoid into a dependent family of additive monoids,\nas functions supported at a point.\n\nThis is the `monoid_hom` version of `pi.mul_single`. -/\n@[to_additive \"The additive monoid homomorphism including a single additive\nmonoid into a dependent family of additive monoids, as functions supported at a point.\n\nThis is the `add_monoid_hom` version of `pi.single`.\"]\ndef monoid_hom.single [Π i, mul_one_class $ f i] (i : I) : f i →* Π i, f i :=\n{ map_mul' := mul_single_op₂ (λ _, (*)) (λ _, one_mul _) _,\n  .. (one_hom.single f i) }\n\n@[simp, to_additive]\nlemma monoid_hom.single_apply [Π i, mul_one_class $ f i] (i : I) (x : f i) :\n  monoid_hom.single f i x = mul_single i x := rfl\n\n/-- The multiplicative homomorphism including a single `mul_zero_class`\ninto a dependent family of `mul_zero_class`es, as functions supported at a point.\n\nThis is the `mul_hom` version of `pi.single`. -/\n@[simps] def mul_hom.single [Π i, mul_zero_class $ f i] (i : I) : mul_hom (f i) (Π i, f i) :=\n{ to_fun := single i,\n  map_mul' := pi.single_op₂ (λ _, (*)) (λ _, zero_mul _) _, }\n\nvariables {f}\n\n@[to_additive]\nlemma pi.mul_single_mul [Π i, mul_one_class $ f i] (i : I) (x y : f i) :\n  mul_single i (x * y) = mul_single i x * mul_single i y :=\n(monoid_hom.single f i).map_mul x y\n\n@[to_additive]\nlemma pi.mul_single_inv [Π i, group $ f i] (i : I) (x : f i) :\n  mul_single i (x⁻¹) = (mul_single i x)⁻¹ :=\n(monoid_hom.single f i).map_inv x\n\n@[to_additive]\nlemma pi.single_div [Π i, group $ f i] (i : I) (x y : f i) :\n  mul_single i (x / y) = mul_single i x / mul_single i y :=\n(monoid_hom.single f i).map_div x y\n\nlemma pi.single_mul [Π i, mul_zero_class $ f i] (i : I) (x y : f i) :\n  single i (x * y) = single i x * single i y :=\n(mul_hom.single f i).map_mul x y\n\n/-- The injection into a pi group at different indices commutes.\n\nFor injections of commuting elements at the same index, see `commute.map` -/\n@[to_additive \"The injection into an additive pi group at different indices commutes.\n\nFor injections of commuting elements at the same index, see `add_commute.map`\"]\nlemma pi.mul_single_commute [Π i, mul_one_class $ f i] :\n  pairwise (λ i j, ∀ (x : f i) (y : f j), commute (mul_single i x) (mul_single j y)) :=\nbegin\n  intros i j hij x y, ext k,\n  by_cases h1 : i = k, { subst h1, simp [hij], },\n  by_cases h2 : j = k, { subst h2, simp [hij], },\n  simp [h1,  h2],\nend\n\n/-- The injection into a pi group with the same values commutes. -/\n@[to_additive \"The injection into an additive pi group with the same values commutes.\"]\nlemma pi.mul_single_apply_commute [Π i, mul_one_class $ f i] (x : Π i, f i) (i j : I) :\n  commute (mul_single i (x i)) (mul_single j (x j)) :=\nbegin\n  obtain rfl | hij := decidable.eq_or_ne i j,\n  { refl },\n  { exact pi.mul_single_commute _ _ hij _ _, },\nend\n\n@[to_additive update_eq_sub_add_single]\nlemma pi.update_eq_div_mul_single [Π i, group $ f i] (g : Π (i : I), f i) (x : f i) :\n  function.update g i x = g / mul_single i (g i) * mul_single i x :=\nbegin\n  ext j,\n  rcases eq_or_ne i j with rfl|h,\n  { simp },\n  { simp [function.update_noteq h.symm, h] }\nend\n\nend single\n\nnamespace function\n\n@[simp, to_additive]\nlemma update_one [Π i, has_one (f i)] [decidable_eq I] (i : I) :\n  update (1 : Π i, f i) i 1 = 1 :=\nupdate_eq_self i 1\n\n@[to_additive]\nlemma update_mul [Π i, has_mul (f i)] [decidable_eq I]\n  (f₁ f₂ : Π i, f i) (i : I) (x₁ : f i) (x₂ : f i) :\n  update (f₁ * f₂) i (x₁ * x₂) = update f₁ i x₁ * update f₂ i x₂ :=\nfunext $ λ j, (apply_update₂ (λ i, (*)) f₁ f₂ i x₁ x₂ j).symm\n\n@[to_additive]\nlemma update_inv [Π i, has_inv (f i)] [decidable_eq I]\n  (f₁ : Π i, f i) (i : I) (x₁ : f i) :\n  update (f₁⁻¹) i (x₁⁻¹) = (update f₁ i x₁)⁻¹ :=\nfunext $ λ j, (apply_update (λ i, has_inv.inv) f₁ i x₁ j).symm\n\n@[to_additive]\nlemma update_div [Π i, has_div (f i)] [decidable_eq I]\n  (f₁ f₂ : Π i, f i) (i : I) (x₁ : f i) (x₂ : f i) :\n  update (f₁ / f₂) i (x₁ / x₂) = update f₁ i x₁ / update f₂ i x₂ :=\nfunext $ λ j, (apply_update₂ (λ i, (/)) f₁ f₂ i x₁ x₂ j).symm\n\nend function\n\nsection piecewise\n\n@[to_additive]\nlemma set.piecewise_mul [Π i, has_mul (f i)] (s : set I) [Π i, decidable (i ∈ s)]\n  (f₁ f₂ g₁ g₂ : Π i, f i) :\n  s.piecewise (f₁ * f₂) (g₁ * g₂) = s.piecewise f₁ g₁ * s.piecewise f₂ g₂ :=\ns.piecewise_op₂ _ _ _ _ (λ _, (*))\n\n@[to_additive]\nlemma set.piecewise_inv [Π i, has_inv (f i)] (s : set I) [Π i, decidable (i ∈ s)]\n  (f₁ g₁ : Π i, f i) :\n  s.piecewise (f₁⁻¹) (g₁⁻¹) = (s.piecewise f₁ g₁)⁻¹ :=\ns.piecewise_op f₁ g₁ (λ _ x, x⁻¹)\n\n@[to_additive]\nlemma set.piecewise_div [Π i, has_div (f i)] (s : set I) [Π i, decidable (i ∈ s)]\n  (f₁ f₂ g₁ g₂ : Π i, f i) :\n  s.piecewise (f₁ / f₂) (g₁ / g₂) = s.piecewise f₁ g₁ / s.piecewise f₂ g₂ :=\ns.piecewise_op₂ _ _ _ _ (λ _, (/))\n\nend piecewise\n\nsection extend\n\nvariables {ι : Type u} {η : Type v} (R : Type w) (s : ι → η)\n\n/-- `function.extend s f 1` as a bundled hom. -/\n@[to_additive function.extend_by_zero.hom \"`function.extend s f 0` as a bundled hom.\", simps]\nnoncomputable def function.extend_by_one.hom [mul_one_class R] : (ι → R) →* (η → R) :=\n{ to_fun := λ f, function.extend s f 1,\n  map_one' := function.extend_one s,\n  map_mul' := λ f g, by { simpa using function.extend_mul s f g 1 1 } }\n\nend extend\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/group/pi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834734, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4859007388150813}}
{"text": "/-\nCopyright (c) 2022 Jireh Loreaux. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jireh Loreaux\n\n! This file was ported from Lean 3 source module topology.bornology.basic\n! leanprover-community/mathlib commit 8631e2d5ea77f6c13054d9151d82b83069680cb1\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Order.Filter.Cofinite\n\n/-!\n# Basic theory of bornology\n\nWe develop the basic theory of bornologies. Instead of axiomatizing bounded sets and defining\nbornologies in terms of those, we recognize that the cobounded sets form a filter and define a\nbornology as a filter of cobounded sets which contains the cofinite filter.  This allows us to make\nuse of the extensive library for filters, but we also provide the relevant connecting results for\nbounded sets.\n\nThe specification of a bornology in terms of the cobounded filter is equivalent to the standard\none (e.g., see [Bourbaki, *Topological Vector Spaces*][bourbaki1987], **covering bornology**, now\noften called simply **bornology**) in terms of bounded sets (see `Bornology.ofBounded`,\n`IsBounded.union`, `IsBounded.subset`), except that we do not allow the empty bornology (that is,\nwe require that *some* set must be bounded; equivalently, `∅` is bounded). In the literature the\ncobounded filter is generally referred to as the *filter at infinity*.\n\n## Main definitions\n\n- `Bornology α`: a class consisting of `cobounded : Filter α` and a proof that this filter\n  contains the `cofinite` filter.\n- `Bornology.IsCobounded`: the predicate that a set is a member of the `cobounded α` filter. For\n  `s : set α`, one should prefer `Bornology.IsCobounded s` over `s ∈ cobounded α`.\n- `bornology.IsBounded`: the predicate that states a set is bounded (i.e., the complement of a\n  cobounded set). One should prefer `Bornology.IsBounded s` over `sᶜ ∈ cobounded α`.\n- `BoundedSpace α`: a class extending `Bornology α` with the condition\n  `Bornology.IsBounded (Set.univ : Set α)`\n\nAlthough use of `cobounded α` is discouraged for indicating the (co)boundedness of individual sets,\nit is intended for regular use as a filter on `α`.\n-/\n\n\nopen Set Filter\n\nvariable {ι α β : Type _}\n\n/-- A **bornology** on a type `α` is a filter of cobounded sets which contains the cofinite filter.\nSuch spaces are equivalently specified by their bounded sets, see `Bornology.ofBounded`\nand `Bornology.ext_iff_isBounded`-/\nclass Bornology (α : Type _) where\n  /-- The filter of cobounded sets in a bornology. This is a field of the structure, but one\n  should always prefer `Bornology.cobounded` because it makes the `α` argument explciit. -/\n  cobounded' : Filter α\n  /-- The cobounded filter in a bornology is smaller than the cofinite filter. This is a field of\n  the structure, but one should always prefer `Bornology.le_cofinite` because it makes the `α`\n  argument explciit. -/\n  le_cofinite' : cobounded' ≤ cofinite\n#align bornology Bornology\n\n/- porting note: Because Lean 4 doesn't accept the `[]` syntax to make arguments of structure\nfields explicit, we have to define these separately, prove the `ext` lemmas manually, and\ninitialize new `simps` projections. -/\n\n/-- The filter of cobounded sets in a bornology. -/\ndef Bornology.cobounded (α : Type _) [Bornology α] : Filter α := Bornology.cobounded'\n#align bornology.cobounded Bornology.cobounded\n\nalias Bornology.cobounded ← Bornology.Simps.cobounded\n\nlemma Bornology.le_cofinite (α : Type _) [Bornology α] : cobounded α ≤ cofinite :=\nBornology.le_cofinite'\n#align bornology.le_cofinite Bornology.le_cofinite\n\ninitialize_simps_projections Bornology (cobounded' → cobounded)\n\n@[ext]\nlemma Bornology.ext (t t' : Bornology α)\n    (h_cobounded : @Bornology.cobounded α t = @Bornology.cobounded α t') :\n    t = t' := by\n  cases t\n  cases t'\n  congr\n#align bornology.ext Bornology.ext\n\nlemma Bornology.ext_iff (t t' : Bornology α) :\n    t = t' ↔ @Bornology.cobounded α t = @Bornology.cobounded α t' :=\n⟨congrArg _, Bornology.ext _ _⟩\n#align bornology.ext_iff Bornology.ext_iff\n\n/-- A constructor for bornologies by specifying the bounded sets,\nand showing that they satisfy the appropriate conditions. -/\n@[simps]\ndef Bornology.ofBounded {α : Type _} (B : Set (Set α))\n    (empty_mem : ∅ ∈ B)\n    (subset_mem : ∀ s₁ (_ : s₁ ∈ B) s₂, s₂ ⊆ s₁ → s₂ ∈ B)\n    (union_mem : ∀ s₁ (_ : s₁ ∈ B) s₂ (_ : s₂ ∈ B), s₁ ∪ s₂ ∈ B)\n    (singleton_mem : ∀ x, {x} ∈ B) : Bornology α\n    where\n  cobounded' :=\n    { sets := { s : Set α | sᶜ ∈ B }\n      univ_sets := by rwa [← compl_univ] at empty_mem\n      sets_of_superset := fun hx hy => subset_mem _ hx _ (compl_subset_compl.mpr hy)\n      inter_sets := fun hx hy => by simpa [compl_inter] using union_mem _ hx _ hy }\n  le_cofinite' := by\n    rw [le_cofinite_iff_compl_singleton_mem]\n    intro x\n    change {x}ᶜᶜ ∈ B\n    rw [compl_compl]\n    exact singleton_mem x\n#align bornology.of_bounded Bornology.ofBounded\n#align bornology.of_bounded_cobounded_sets Bornology.ofBounded_cobounded_sets\n\n/-- A constructor for bornologies by specifying the bounded sets,\nand showing that they satisfy the appropriate conditions. -/\n@[simps!]\ndef Bornology.ofBounded' {α : Type _} (B : Set (Set α))\n    (empty_mem : ∅ ∈ B)\n    (subset_mem : ∀ s₁ (_ : s₁ ∈ B) s₂, s₂ ⊆ s₁ → s₂ ∈ B)\n    (union_mem : ∀ s₁ (_ : s₁ ∈ B) s₂ (_ : s₂ ∈ B), s₁ ∪ s₂ ∈ B)\n    (unionₛ_univ : ⋃₀ B = univ) :\n    Bornology α :=\n  Bornology.ofBounded B empty_mem subset_mem union_mem fun x =>\n    by\n    rw [unionₛ_eq_univ_iff] at unionₛ_univ\n    rcases unionₛ_univ x with ⟨s, hs, hxs⟩\n    exact subset_mem s hs {x} (singleton_subset_iff.mpr hxs)\n#align bornology.of_bounded' Bornology.ofBounded'\n#align bornology.of_bounded'_cobounded_sets Bornology.ofBounded'_cobounded_sets\nnamespace Bornology\n\nsection\n\nvariable [Bornology α] {s t : Set α} {x : α}\n\n/-- `IsCobounded` is the predicate that `s` is in the filter of cobounded sets in the ambient\nbornology on `α` -/\ndef IsCobounded (s : Set α) : Prop :=\n  s ∈ cobounded α\n#align bornology.is_cobounded Bornology.IsCobounded\n\n/-- `IsBounded` is the predicate that `s` is bounded relative to the ambient bornology on `α`. -/\ndef IsBounded (s : Set α) : Prop :=\n  IsCobounded (sᶜ)\n#align bornology.is_bounded Bornology.IsBounded\n\ntheorem isCobounded_def {s : Set α} : IsCobounded s ↔ s ∈ cobounded α :=\n  Iff.rfl\n#align bornology.is_cobounded_def Bornology.isCobounded_def\n\ntheorem isBounded_def {s : Set α} : IsBounded s ↔ sᶜ ∈ cobounded α :=\n  Iff.rfl\n#align bornology.is_bounded_def Bornology.isBounded_def\n\n@[simp]\ntheorem isBounded_compl_iff : IsBounded (sᶜ) ↔ IsCobounded s := by\n  rw [isBounded_def, isCobounded_def, compl_compl]\n#align bornology.is_bounded_compl_iff Bornology.isBounded_compl_iff\n\n@[simp]\ntheorem isCobounded_compl_iff : IsCobounded (sᶜ) ↔ IsBounded s :=\n  Iff.rfl\n#align bornology.is_cobounded_compl_iff Bornology.isCobounded_compl_iff\n\nalias isBounded_compl_iff ↔ IsBounded.of_compl IsCobounded.compl\n#align bornology.is_bounded.of_compl Bornology.IsBounded.of_compl\n#align bornology.is_cobounded.compl Bornology.IsCobounded.compl\n\nalias isCobounded_compl_iff ↔ IsCobounded.of_compl IsBounded.compl\n#align bornology.is_cobounded.of_compl Bornology.IsCobounded.of_compl\n#align bornology.is_bounded.compl Bornology.IsBounded.compl\n\n@[simp]\ntheorem isBounded_empty : IsBounded (∅ : Set α) := by\n  rw [isBounded_def, compl_empty]\n  exact univ_mem\n#align bornology.is_bounded_empty Bornology.isBounded_empty\n\n@[simp]\ntheorem isBounded_singleton : IsBounded ({x} : Set α) := by\n  rw [isBounded_def]\n  exact le_cofinite _ (finite_singleton x).compl_mem_cofinite\n#align bornology.is_bounded_singleton Bornology.isBounded_singleton\n\n@[simp]\ntheorem isCobounded_univ : IsCobounded (univ : Set α) :=\n  univ_mem\n#align bornology.is_cobounded_univ Bornology.isCobounded_univ\n\n@[simp]\ntheorem isCobounded_inter : IsCobounded (s ∩ t) ↔ IsCobounded s ∧ IsCobounded t :=\n  inter_mem_iff\n#align bornology.is_cobounded_inter Bornology.isCobounded_inter\n\ntheorem IsCobounded.inter (hs : IsCobounded s) (ht : IsCobounded t) : IsCobounded (s ∩ t) :=\n  isCobounded_inter.2 ⟨hs, ht⟩\n#align bornology.is_cobounded.inter Bornology.IsCobounded.inter\n\n@[simp]\ntheorem isBounded_union : IsBounded (s ∪ t) ↔ IsBounded s ∧ IsBounded t := by\n  simp only [← isCobounded_compl_iff, compl_union, isCobounded_inter]\n#align bornology.is_bounded_union Bornology.isBounded_union\n\ntheorem IsBounded.union (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s ∪ t) :=\n  isBounded_union.2 ⟨hs, ht⟩\n#align bornology.is_bounded.union Bornology.IsBounded.union\n\ntheorem IsCobounded.superset (hs : IsCobounded s) (ht : s ⊆ t) : IsCobounded t :=\n  mem_of_superset hs ht\n#align bornology.is_cobounded.superset Bornology.IsCobounded.superset\n\ntheorem IsBounded.subset (ht : IsBounded t) (hs : s ⊆ t) : IsBounded s :=\n  ht.superset (compl_subset_compl.mpr hs)\n#align bornology.is_bounded.subset Bornology.IsBounded.subset\n\n@[simp]\ntheorem unionₛ_bounded_univ : ⋃₀ { s : Set α | IsBounded s } = univ :=\n  unionₛ_eq_univ_iff.2 fun a => ⟨{a}, isBounded_singleton, mem_singleton a⟩\n#align bornology.sUnion_bounded_univ Bornology.unionₛ_bounded_univ\n\ntheorem comap_cobounded_le_iff [Bornology β] {f : α → β} :\n    (cobounded β).comap f ≤ cobounded α ↔ ∀ ⦃s⦄, IsBounded s → IsBounded (f '' s) := by\n  refine'\n    ⟨fun h s hs => _, fun h t ht =>\n      ⟨(f '' tᶜ)ᶜ, h <| IsCobounded.compl ht, compl_subset_comm.1 <| subset_preimage_image _ _⟩⟩\n  obtain ⟨t, ht, hts⟩ := h hs.compl\n  rw [subset_compl_comm, ← preimage_compl] at hts\n  exact (IsCobounded.compl ht).subset ((image_subset f hts).trans <| image_preimage_subset _ _)\n#align bornology.comap_cobounded_le_iff Bornology.comap_cobounded_le_iff\n\nend\n\ntheorem ext_iff' {t t' : Bornology α} :\n    t = t' ↔ ∀ s, (@cobounded α t).sets s ↔ (@cobounded α t').sets s :=\n  (Bornology.ext_iff _ _).trans Filter.ext_iff\n#align bornology.ext_iff' Bornology.ext_iff'\n\ntheorem ext_iff_isBounded {t t' : Bornology α} :\n    t = t' ↔ ∀ s, @IsBounded α t s ↔ @IsBounded α t' s :=\n  ⟨fun h s => h ▸ Iff.rfl, fun h => by\n    ext s\n    simpa [@isBounded_def _ t, isBounded_def, compl_compl] using h (sᶜ)⟩\n-- porting note: Lean 3 could do this without `@isBounded_def _ t`\n#align bornology.ext_iff_is_bounded Bornology.ext_iff_isBounded\n\nvariable {s : Set α}\n\ntheorem isCobounded_ofBounded_iff (B : Set (Set α)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsCobounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s ↔ sᶜ ∈ B :=\n  Iff.rfl\n#align bornology.is_cobounded_of_bounded_iff Bornology.isCobounded_ofBounded_iff\n\ntheorem isBounded_ofBounded_iff (B : Set (Set α)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsBounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s ↔ s ∈ B := by\n  rw [@isBounded_def _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ), ← Filter.mem_sets,\n   ofBounded_cobounded_sets, Set.mem_setOf_eq, compl_compl]\n-- porting note: again had to use `@isBounded_def _` and feed Lean the instance\n#align bornology.is_bounded_of_bounded_iff Bornology.isBounded_ofBounded_iff\n\nvariable [Bornology α]\n\ntheorem isCobounded_binterᵢ {s : Set ι} {f : ι → Set α} (hs : s.Finite) :\n    IsCobounded (⋂ i ∈ s, f i) ↔ ∀ i ∈ s, IsCobounded (f i) :=\n  binterᵢ_mem hs\n#align bornology.is_cobounded_bInter Bornology.isCobounded_binterᵢ\n\n@[simp]\ntheorem isCobounded_binterᵢ_finset (s : Finset ι) {f : ι → Set α} :\n    IsCobounded (⋂ i ∈ s, f i) ↔ ∀ i ∈ s, IsCobounded (f i) :=\n  binterᵢ_finset_mem s\n#align bornology.is_cobounded_bInter_finset Bornology.isCobounded_binterᵢ_finset\n\n@[simp]\ntheorem isCobounded_interᵢ [Finite ι] {f : ι → Set α} :\n    IsCobounded (⋂ i, f i) ↔ ∀ i, IsCobounded (f i) :=\n  interᵢ_mem\n#align bornology.is_cobounded_Inter Bornology.isCobounded_interᵢ\n\ntheorem isCobounded_interₛ {S : Set (Set α)} (hs : S.Finite) :\n    IsCobounded (⋂₀ S) ↔ ∀ s ∈ S, IsCobounded s :=\n  interₛ_mem hs\n#align bornology.is_cobounded_sInter Bornology.isCobounded_interₛ\n\ntheorem isBounded_bunionᵢ {s : Set ι} {f : ι → Set α} (hs : s.Finite) :\n    IsBounded (⋃ i ∈ s, f i) ↔ ∀ i ∈ s, IsBounded (f i) := by\n  simp only [← isCobounded_compl_iff, compl_unionᵢ, isCobounded_binterᵢ hs]\n#align bornology.is_bounded_bUnion Bornology.isBounded_bunionᵢ\n\ntheorem isBounded_bunionᵢ_finset (s : Finset ι) {f : ι → Set α} :\n    IsBounded (⋃ i ∈ s, f i) ↔ ∀ i ∈ s, IsBounded (f i) :=\n  isBounded_bunionᵢ s.finite_toSet\n#align bornology.is_bounded_bUnion_finset Bornology.isBounded_bunionᵢ_finset\n\ntheorem isBounded_unionₛ {S : Set (Set α)} (hs : S.Finite) :\n    IsBounded (⋃₀ S) ↔ ∀ s ∈ S, IsBounded s := by rw [unionₛ_eq_bunionᵢ, isBounded_bunionᵢ hs]\n#align bornology.is_bounded_sUnion Bornology.isBounded_unionₛ\n\n@[simp]\ntheorem isBounded_unionᵢ [Finite ι] {s : ι → Set α} : IsBounded (⋃ i, s i) ↔ ∀ i, IsBounded (s i) :=\n  by rw [← unionₛ_range, isBounded_unionₛ (finite_range s), forall_range_iff]\n#align bornology.is_bounded_Union Bornology.isBounded_unionᵢ\n\nend Bornology\n\nopen Bornology\n\ntheorem Set.Finite.isBounded [Bornology α] {s : Set α} (hs : s.Finite) : IsBounded s :=\n  Bornology.le_cofinite α hs.compl_mem_cofinite\n#align set.finite.is_bounded Set.Finite.isBounded\n\ninstance : Bornology PUnit :=\n  ⟨⊥, bot_le⟩\n\n/-- The cofinite filter as a bornology -/\n@[reducible]\ndef Bornology.cofinite : Bornology α\n    where\n  cobounded' := Filter.cofinite\n  le_cofinite' := le_rfl\n#align bornology.cofinite Bornology.cofinite\n\n/-- A space with a `Bornology` is a **bounded space** if `Set.univ : Set α` is bounded. -/\nclass BoundedSpace (α : Type _) [Bornology α] : Prop where\n  /-- The `Set.univ` is bounded. -/\n  bounded_univ : Bornology.IsBounded (univ : Set α)\n#align bounded_space BoundedSpace\n\nnamespace Bornology\n\nvariable [Bornology α]\n\ntheorem isBounded_univ : IsBounded (univ : Set α) ↔ BoundedSpace α :=\n  ⟨fun h => ⟨h⟩, fun h => h.1⟩\n#align bornology.is_bounded_univ Bornology.isBounded_univ\n\ntheorem cobounded_eq_bot_iff : cobounded α = ⊥ ↔ BoundedSpace α := by\n  rw [← isBounded_univ, isBounded_def, compl_univ, empty_mem_iff_bot]\n#align bornology.cobounded_eq_bot_iff Bornology.cobounded_eq_bot_iff\n\nvariable [BoundedSpace α]\n\ntheorem IsBounded.all (s : Set α) : IsBounded s :=\n  BoundedSpace.bounded_univ.subset s.subset_univ\n#align bornology.is_bounded.all Bornology.IsBounded.all\n\ntheorem IsCobounded.all (s : Set α) : IsCobounded s :=\n  compl_compl s ▸ IsBounded.all (sᶜ)\n#align bornology.is_cobounded.all Bornology.IsCobounded.all\n\nvariable (α)\n\n@[simp]\n\n\nend Bornology\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Topology/Bornology/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4859007388150812}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module data.multiset.locally_finite\n! leanprover-community/mathlib commit f16e7a22e11fc09c71f25446ac1db23a24e8a0bd\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.LocallyFinite\n\n/-!\n# Intervals as multisets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides basic results about all the `multiset.Ixx`, which are defined in\n`order.locally_finite`.\n\nNote that intervals of multisets themselves (`multiset.locally_finite_order`) are defined elsewhere.\n-/\n\n\nvariable {α : Type _}\n\nnamespace Multiset\n\nsection Preorder\n\nvariable [Preorder α] [LocallyFiniteOrder α] {a b c : α}\n\n#print Multiset.nodup_Icc /-\ntheorem nodup_Icc : (Icc a b).Nodup :=\n  Finset.nodup _\n#align multiset.nodup_Icc Multiset.nodup_Icc\n-/\n\n#print Multiset.nodup_Ico /-\ntheorem nodup_Ico : (Ico a b).Nodup :=\n  Finset.nodup _\n#align multiset.nodup_Ico Multiset.nodup_Ico\n-/\n\n#print Multiset.nodup_Ioc /-\ntheorem nodup_Ioc : (Ioc a b).Nodup :=\n  Finset.nodup _\n#align multiset.nodup_Ioc Multiset.nodup_Ioc\n-/\n\n#print Multiset.nodup_Ioo /-\ntheorem nodup_Ioo : (Ioo a b).Nodup :=\n  Finset.nodup _\n#align multiset.nodup_Ioo Multiset.nodup_Ioo\n-/\n\n#print Multiset.Icc_eq_zero_iff /-\n@[simp]\ntheorem Icc_eq_zero_iff : Icc a b = 0 ↔ ¬a ≤ b := by\n  rw [Icc, Finset.val_eq_zero, Finset.Icc_eq_empty_iff]\n#align multiset.Icc_eq_zero_iff Multiset.Icc_eq_zero_iff\n-/\n\n#print Multiset.Ico_eq_zero_iff /-\n@[simp]\ntheorem Ico_eq_zero_iff : Ico a b = 0 ↔ ¬a < b := by\n  rw [Ico, Finset.val_eq_zero, Finset.Ico_eq_empty_iff]\n#align multiset.Ico_eq_zero_iff Multiset.Ico_eq_zero_iff\n-/\n\n#print Multiset.Ioc_eq_zero_iff /-\n@[simp]\ntheorem Ioc_eq_zero_iff : Ioc a b = 0 ↔ ¬a < b := by\n  rw [Ioc, Finset.val_eq_zero, Finset.Ioc_eq_empty_iff]\n#align multiset.Ioc_eq_zero_iff Multiset.Ioc_eq_zero_iff\n-/\n\n#print Multiset.Ioo_eq_zero_iff /-\n@[simp]\ntheorem Ioo_eq_zero_iff [DenselyOrdered α] : Ioo a b = 0 ↔ ¬a < b := by\n  rw [Ioo, Finset.val_eq_zero, Finset.Ioo_eq_empty_iff]\n#align multiset.Ioo_eq_zero_iff Multiset.Ioo_eq_zero_iff\n-/\n\nalias Icc_eq_zero_iff ↔ _ Icc_eq_zero\n#align multiset.Icc_eq_zero Multiset.Icc_eq_zero\n\nalias Ico_eq_zero_iff ↔ _ Ico_eq_zero\n#align multiset.Ico_eq_zero Multiset.Ico_eq_zero\n\nalias Ioc_eq_zero_iff ↔ _ Ioc_eq_zero\n#align multiset.Ioc_eq_zero Multiset.Ioc_eq_zero\n\n#print Multiset.Ioo_eq_zero /-\n@[simp]\ntheorem Ioo_eq_zero (h : ¬a < b) : Ioo a b = 0 :=\n  eq_zero_iff_forall_not_mem.2 fun x hx => h ((mem_Ioo.1 hx).1.trans (mem_Ioo.1 hx).2)\n#align multiset.Ioo_eq_zero Multiset.Ioo_eq_zero\n-/\n\n#print Multiset.Icc_eq_zero_of_lt /-\n@[simp]\ntheorem Icc_eq_zero_of_lt (h : b < a) : Icc a b = 0 :=\n  Icc_eq_zero h.not_le\n#align multiset.Icc_eq_zero_of_lt Multiset.Icc_eq_zero_of_lt\n-/\n\n#print Multiset.Ico_eq_zero_of_le /-\n@[simp]\ntheorem Ico_eq_zero_of_le (h : b ≤ a) : Ico a b = 0 :=\n  Ico_eq_zero h.not_lt\n#align multiset.Ico_eq_zero_of_le Multiset.Ico_eq_zero_of_le\n-/\n\n#print Multiset.Ioc_eq_zero_of_le /-\n@[simp]\ntheorem Ioc_eq_zero_of_le (h : b ≤ a) : Ioc a b = 0 :=\n  Ioc_eq_zero h.not_lt\n#align multiset.Ioc_eq_zero_of_le Multiset.Ioc_eq_zero_of_le\n-/\n\n#print Multiset.Ioo_eq_zero_of_le /-\n@[simp]\ntheorem Ioo_eq_zero_of_le (h : b ≤ a) : Ioo a b = 0 :=\n  Ioo_eq_zero h.not_lt\n#align multiset.Ioo_eq_zero_of_le Multiset.Ioo_eq_zero_of_le\n-/\n\nvariable (a)\n\n#print Multiset.Ico_self /-\n@[simp]\ntheorem Ico_self : Ico a a = 0 := by rw [Ico, Finset.Ico_self, Finset.empty_val]\n#align multiset.Ico_self Multiset.Ico_self\n-/\n\n#print Multiset.Ioc_self /-\n@[simp]\ntheorem Ioc_self : Ioc a a = 0 := by rw [Ioc, Finset.Ioc_self, Finset.empty_val]\n#align multiset.Ioc_self Multiset.Ioc_self\n-/\n\n#print Multiset.Ioo_self /-\n@[simp]\ntheorem Ioo_self : Ioo a a = 0 := by rw [Ioo, Finset.Ioo_self, Finset.empty_val]\n#align multiset.Ioo_self Multiset.Ioo_self\n-/\n\nvariable {a b c}\n\n#print Multiset.left_mem_Icc /-\ntheorem left_mem_Icc : a ∈ Icc a b ↔ a ≤ b :=\n  Finset.left_mem_Icc\n#align multiset.left_mem_Icc Multiset.left_mem_Icc\n-/\n\n#print Multiset.left_mem_Ico /-\ntheorem left_mem_Ico : a ∈ Ico a b ↔ a < b :=\n  Finset.left_mem_Ico\n#align multiset.left_mem_Ico Multiset.left_mem_Ico\n-/\n\n#print Multiset.right_mem_Icc /-\ntheorem right_mem_Icc : b ∈ Icc a b ↔ a ≤ b :=\n  Finset.right_mem_Icc\n#align multiset.right_mem_Icc Multiset.right_mem_Icc\n-/\n\n#print Multiset.right_mem_Ioc /-\ntheorem right_mem_Ioc : b ∈ Ioc a b ↔ a < b :=\n  Finset.right_mem_Ioc\n#align multiset.right_mem_Ioc Multiset.right_mem_Ioc\n-/\n\n#print Multiset.left_not_mem_Ioc /-\n@[simp]\ntheorem left_not_mem_Ioc : a ∉ Ioc a b :=\n  Finset.left_not_mem_Ioc\n#align multiset.left_not_mem_Ioc Multiset.left_not_mem_Ioc\n-/\n\n#print Multiset.left_not_mem_Ioo /-\n@[simp]\ntheorem left_not_mem_Ioo : a ∉ Ioo a b :=\n  Finset.left_not_mem_Ioo\n#align multiset.left_not_mem_Ioo Multiset.left_not_mem_Ioo\n-/\n\n#print Multiset.right_not_mem_Ico /-\n@[simp]\ntheorem right_not_mem_Ico : b ∉ Ico a b :=\n  Finset.right_not_mem_Ico\n#align multiset.right_not_mem_Ico Multiset.right_not_mem_Ico\n-/\n\n#print Multiset.right_not_mem_Ioo /-\n@[simp]\ntheorem right_not_mem_Ioo : b ∉ Ioo a b :=\n  Finset.right_not_mem_Ioo\n#align multiset.right_not_mem_Ioo Multiset.right_not_mem_Ioo\n-/\n\n#print Multiset.Ico_filter_lt_of_le_left /-\ntheorem Ico_filter_lt_of_le_left [DecidablePred (· < c)] (hca : c ≤ a) :\n    ((Ico a b).filterₓ fun x => x < c) = ∅ :=\n  by\n  rw [Ico, ← Finset.filter_val, Finset.Ico_filter_lt_of_le_left hca]\n  rfl\n#align multiset.Ico_filter_lt_of_le_left Multiset.Ico_filter_lt_of_le_left\n-/\n\n#print Multiset.Ico_filter_lt_of_right_le /-\ntheorem Ico_filter_lt_of_right_le [DecidablePred (· < c)] (hbc : b ≤ c) :\n    ((Ico a b).filterₓ fun x => x < c) = Ico a b := by\n  rw [Ico, ← Finset.filter_val, Finset.Ico_filter_lt_of_right_le hbc]\n#align multiset.Ico_filter_lt_of_right_le Multiset.Ico_filter_lt_of_right_le\n-/\n\n#print Multiset.Ico_filter_lt_of_le_right /-\ntheorem Ico_filter_lt_of_le_right [DecidablePred (· < c)] (hcb : c ≤ b) :\n    ((Ico a b).filterₓ fun x => x < c) = Ico a c :=\n  by\n  rw [Ico, ← Finset.filter_val, Finset.Ico_filter_lt_of_le_right hcb]\n  rfl\n#align multiset.Ico_filter_lt_of_le_right Multiset.Ico_filter_lt_of_le_right\n-/\n\n#print Multiset.Ico_filter_le_of_le_left /-\ntheorem Ico_filter_le_of_le_left [DecidablePred ((· ≤ ·) c)] (hca : c ≤ a) :\n    ((Ico a b).filterₓ fun x => c ≤ x) = Ico a b := by\n  rw [Ico, ← Finset.filter_val, Finset.Ico_filter_le_of_le_left hca]\n#align multiset.Ico_filter_le_of_le_left Multiset.Ico_filter_le_of_le_left\n-/\n\n#print Multiset.Ico_filter_le_of_right_le /-\ntheorem Ico_filter_le_of_right_le [DecidablePred ((· ≤ ·) b)] :\n    ((Ico a b).filterₓ fun x => b ≤ x) = ∅ :=\n  by\n  rw [Ico, ← Finset.filter_val, Finset.Ico_filter_le_of_right_le]\n  rfl\n#align multiset.Ico_filter_le_of_right_le Multiset.Ico_filter_le_of_right_le\n-/\n\n#print Multiset.Ico_filter_le_of_left_le /-\ntheorem Ico_filter_le_of_left_le [DecidablePred ((· ≤ ·) c)] (hac : a ≤ c) :\n    ((Ico a b).filterₓ fun x => c ≤ x) = Ico c b :=\n  by\n  rw [Ico, ← Finset.filter_val, Finset.Ico_filter_le_of_left_le hac]\n  rfl\n#align multiset.Ico_filter_le_of_left_le Multiset.Ico_filter_le_of_left_le\n-/\n\nend Preorder\n\nsection PartialOrder\n\nvariable [PartialOrder α] [LocallyFiniteOrder α] {a b : α}\n\n#print Multiset.Icc_self /-\n@[simp]\ntheorem Icc_self (a : α) : Icc a a = {a} := by rw [Icc, Finset.Icc_self, Finset.singleton_val]\n#align multiset.Icc_self Multiset.Icc_self\n-/\n\n#print Multiset.Ico_cons_right /-\ntheorem Ico_cons_right (h : a ≤ b) : b ::ₘ Ico a b = Icc a b := by\n  classical\n    rw [Ico, ← Finset.insert_val_of_not_mem right_not_mem_Ico, Finset.Ico_insert_right h]\n    rfl\n#align multiset.Ico_cons_right Multiset.Ico_cons_right\n-/\n\n#print Multiset.Ioo_cons_left /-\ntheorem Ioo_cons_left (h : a < b) : a ::ₘ Ioo a b = Ico a b := by\n  classical\n    rw [Ioo, ← Finset.insert_val_of_not_mem left_not_mem_Ioo, Finset.Ioo_insert_left h]\n    rfl\n#align multiset.Ioo_cons_left Multiset.Ioo_cons_left\n-/\n\n#print Multiset.Ico_disjoint_Ico /-\ntheorem Ico_disjoint_Ico {a b c d : α} (h : b ≤ c) : (Ico a b).Disjoint (Ico c d) :=\n  fun x hab hbc => by\n  rw [mem_Ico] at hab hbc\n  exact hab.2.not_le (h.trans hbc.1)\n#align multiset.Ico_disjoint_Ico Multiset.Ico_disjoint_Ico\n-/\n\n#print Multiset.Ico_inter_Ico_of_le /-\n@[simp]\ntheorem Ico_inter_Ico_of_le [DecidableEq α] {a b c d : α} (h : b ≤ c) : Ico a b ∩ Ico c d = 0 :=\n  Multiset.inter_eq_zero_iff_disjoint.2 <| Ico_disjoint_Ico h\n#align multiset.Ico_inter_Ico_of_le Multiset.Ico_inter_Ico_of_le\n-/\n\n#print Multiset.Ico_filter_le_left /-\ntheorem Ico_filter_le_left {a b : α} [DecidablePred (· ≤ a)] (hab : a < b) :\n    ((Ico a b).filterₓ fun x => x ≤ a) = {a} :=\n  by\n  rw [Ico, ← Finset.filter_val, Finset.Ico_filter_le_left hab]\n  rfl\n#align multiset.Ico_filter_le_left Multiset.Ico_filter_le_left\n-/\n\n/- warning: multiset.card_Ico_eq_card_Icc_sub_one -> Multiset.card_Ico_eq_card_Icc_sub_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Ico_eq_card_Icc_sub_one Multiset.card_Ico_eq_card_Icc_sub_oneₓ'. -/\ntheorem card_Ico_eq_card_Icc_sub_one (a b : α) : (Ico a b).card = (Icc a b).card - 1 :=\n  Finset.card_Ico_eq_card_Icc_sub_one _ _\n#align multiset.card_Ico_eq_card_Icc_sub_one Multiset.card_Ico_eq_card_Icc_sub_one\n\n/- warning: multiset.card_Ioc_eq_card_Icc_sub_one -> Multiset.card_Ioc_eq_card_Icc_sub_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Ioc_eq_card_Icc_sub_one Multiset.card_Ioc_eq_card_Icc_sub_oneₓ'. -/\ntheorem card_Ioc_eq_card_Icc_sub_one (a b : α) : (Ioc a b).card = (Icc a b).card - 1 :=\n  Finset.card_Ioc_eq_card_Icc_sub_one _ _\n#align multiset.card_Ioc_eq_card_Icc_sub_one Multiset.card_Ioc_eq_card_Icc_sub_one\n\n/- warning: multiset.card_Ioo_eq_card_Ico_sub_one -> Multiset.card_Ioo_eq_card_Ico_sub_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Ioo_eq_card_Ico_sub_one Multiset.card_Ioo_eq_card_Ico_sub_oneₓ'. -/\ntheorem card_Ioo_eq_card_Ico_sub_one (a b : α) : (Ioo a b).card = (Ico a b).card - 1 :=\n  Finset.card_Ioo_eq_card_Ico_sub_one _ _\n#align multiset.card_Ioo_eq_card_Ico_sub_one Multiset.card_Ioo_eq_card_Ico_sub_one\n\n/- warning: multiset.card_Ioo_eq_card_Icc_sub_two -> Multiset.card_Ioo_eq_card_Icc_sub_two is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1)] (a : α) (b : α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2 a b)) 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Ioo_eq_card_Icc_sub_two Multiset.card_Ioo_eq_card_Icc_sub_twoₓ'. -/\ntheorem card_Ioo_eq_card_Icc_sub_two (a b : α) : (Ioo a b).card = (Icc a b).card - 2 :=\n  Finset.card_Ioo_eq_card_Icc_sub_two _ _\n#align multiset.card_Ioo_eq_card_Icc_sub_two Multiset.card_Ioo_eq_card_Icc_sub_two\n\nend PartialOrder\n\nsection LinearOrder\n\nvariable [LinearOrder α] [LocallyFiniteOrder α] {a b c d : α}\n\n#print Multiset.Ico_subset_Ico_iff /-\ntheorem Ico_subset_Ico_iff {a₁ b₁ a₂ b₂ : α} (h : a₁ < b₁) :\n    Ico a₁ b₁ ⊆ Ico a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ ≤ b₂ :=\n  Finset.Ico_subset_Ico_iff h\n#align multiset.Ico_subset_Ico_iff Multiset.Ico_subset_Ico_iff\n-/\n\n#print Multiset.Ico_add_Ico_eq_Ico /-\ntheorem Ico_add_Ico_eq_Ico {a b c : α} (hab : a ≤ b) (hbc : b ≤ c) : Ico a b + Ico b c = Ico a c :=\n  by\n  rw [add_eq_union_iff_disjoint.2 (Ico_disjoint_Ico le_rfl), Ico, Ico, Ico, ← Finset.union_val,\n    Finset.Ico_union_Ico_eq_Ico hab hbc]\n#align multiset.Ico_add_Ico_eq_Ico Multiset.Ico_add_Ico_eq_Ico\n-/\n\n/- warning: multiset.Ico_inter_Ico -> Multiset.Ico_inter_Ico is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] {a : α} {b : α} {c : α} {d : α}, Eq.{succ u1} (Multiset.{u1} α) (Inter.inter.{u1} (Multiset.{u1} α) (Multiset.hasInter.{u1} α (fun (a : α) (b : α) => Eq.decidable.{u1} α _inst_1 a b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 a b) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 c d)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 (LinearOrder.max.{u1} α _inst_1 a c) (LinearOrder.min.{u1} α _inst_1 b d))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1)))))] {a : α} {b : α} {c : α} {d : α}, Eq.{succ u1} (Multiset.{u1} α) (Inter.inter.{u1} (Multiset.{u1} α) (Multiset.instInterMultiset.{u1} α (fun (a : α) (b : α) => instDecidableEq.{u1} α _inst_1 a b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 a b) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 c d)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 (Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_1) a c) (Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_1) b d))\nCase conversion may be inaccurate. Consider using '#align multiset.Ico_inter_Ico Multiset.Ico_inter_Icoₓ'. -/\ntheorem Ico_inter_Ico : Ico a b ∩ Ico c d = Ico (max a c) (min b d) := by\n  rw [Ico, Ico, Ico, ← Finset.inter_val, Finset.Ico_inter_Ico]\n#align multiset.Ico_inter_Ico Multiset.Ico_inter_Ico\n\n#print Multiset.Ico_filter_lt /-\n@[simp]\ntheorem Ico_filter_lt (a b c : α) : ((Ico a b).filterₓ fun x => x < c) = Ico a (min b c) := by\n  rw [Ico, Ico, ← Finset.filter_val, Finset.Ico_filter_lt]\n#align multiset.Ico_filter_lt Multiset.Ico_filter_lt\n-/\n\n#print Multiset.Ico_filter_le /-\n@[simp]\ntheorem Ico_filter_le (a b c : α) : ((Ico a b).filterₓ fun x => c ≤ x) = Ico (max a c) b := by\n  rw [Ico, Ico, ← Finset.filter_val, Finset.Ico_filter_le]\n#align multiset.Ico_filter_le Multiset.Ico_filter_le\n-/\n\n/- warning: multiset.Ico_sub_Ico_left -> Multiset.Ico_sub_Ico_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) (Multiset.{u1} α) (instHSub.{u1} (Multiset.{u1} α) (Multiset.hasSub.{u1} α (fun (a : α) (b : α) => Eq.decidable.{u1} α _inst_1 a b))) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 a b) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 a c)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 (LinearOrder.max.{u1} α _inst_1 a c) b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1)))))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) (Multiset.{u1} α) (instHSub.{u1} (Multiset.{u1} α) (Multiset.instSubMultiset.{u1} α (fun (a : α) (b : α) => instDecidableEq.{u1} α _inst_1 a b))) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 a b) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 a c)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 (Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_1) a c) b)\nCase conversion may be inaccurate. Consider using '#align multiset.Ico_sub_Ico_left Multiset.Ico_sub_Ico_leftₓ'. -/\n@[simp]\ntheorem Ico_sub_Ico_left (a b c : α) : Ico a b - Ico a c = Ico (max a c) b := by\n  rw [Ico, Ico, Ico, ← Finset.sdiff_val, Finset.Ico_diff_Ico_left]\n#align multiset.Ico_sub_Ico_left Multiset.Ico_sub_Ico_left\n\n/- warning: multiset.Ico_sub_Ico_right -> Multiset.Ico_sub_Ico_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) (Multiset.{u1} α) (instHSub.{u1} (Multiset.{u1} α) (Multiset.hasSub.{u1} α (fun (a : α) (b : α) => Eq.decidable.{u1} α _inst_1 a b))) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 a b) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 c b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 a (LinearOrder.min.{u1} α _inst_1 b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1)))))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) (Multiset.{u1} α) (instHSub.{u1} (Multiset.{u1} α) (Multiset.instSubMultiset.{u1} α (fun (a : α) (b : α) => instDecidableEq.{u1} α _inst_1 a b))) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 a b) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 c b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 a (Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_1) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.Ico_sub_Ico_right Multiset.Ico_sub_Ico_rightₓ'. -/\n@[simp]\ntheorem Ico_sub_Ico_right (a b c : α) : Ico a b - Ico c b = Ico a (min b c) := by\n  rw [Ico, Ico, Ico, ← Finset.sdiff_val, Finset.Ico_diff_Ico_right]\n#align multiset.Ico_sub_Ico_right Multiset.Ico_sub_Ico_right\n\nend LinearOrder\n\nsection OrderedCancelAddCommMonoid\n\nvariable [OrderedCancelAddCommMonoid α] [ExistsAddOfLE α] [LocallyFiniteOrder α]\n\n/- warning: multiset.map_add_left_Icc -> Multiset.map_add_left_Icc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2608 : α) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2610 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2608 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2610) c) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Icc Multiset.map_add_left_Iccₓ'. -/\ntheorem map_add_left_Icc (a b c : α) : (Icc a b).map ((· + ·) c) = Icc (c + a) (c + b) := by\n  classical rw [Icc, Icc, ← Finset.image_add_left_Icc, Finset.image_val,\n      ((Finset.nodup _).map <| add_right_injective c).dedup]\n#align multiset.map_add_left_Icc Multiset.map_add_left_Icc\n\n/- warning: multiset.map_add_left_Ico -> Multiset.map_add_left_Ico is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2713 : α) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2715 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2713 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2715) c) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Ico Multiset.map_add_left_Icoₓ'. -/\ntheorem map_add_left_Ico (a b c : α) : (Ico a b).map ((· + ·) c) = Ico (c + a) (c + b) := by\n  classical rw [Ico, Ico, ← Finset.image_add_left_Ico, Finset.image_val,\n      ((Finset.nodup _).map <| add_right_injective c).dedup]\n#align multiset.map_add_left_Ico Multiset.map_add_left_Ico\n\n/- warning: multiset.map_add_left_Ioc -> Multiset.map_add_left_Ioc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2818 : α) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2820 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2818 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2820) c) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Ioc Multiset.map_add_left_Iocₓ'. -/\ntheorem map_add_left_Ioc (a b c : α) : (Ioc a b).map ((· + ·) c) = Ioc (c + a) (c + b) := by\n  classical rw [Ioc, Ioc, ← Finset.image_add_left_Ioc, Finset.image_val,\n      ((Finset.nodup _).map <| add_right_injective c).dedup]\n#align multiset.map_add_left_Ioc Multiset.map_add_left_Ioc\n\n/- warning: multiset.map_add_left_Ioo -> Multiset.map_add_left_Ioo is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2923 : α) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2925 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2923 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2925) c) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Ioo Multiset.map_add_left_Iooₓ'. -/\ntheorem map_add_left_Ioo (a b c : α) : (Ioo a b).map ((· + ·) c) = Ioo (c + a) (c + b) := by\n  classical rw [Ioo, Ioo, ← Finset.image_add_left_Ioo, Finset.image_val,\n      ((Finset.nodup _).map <| add_right_injective c).dedup]\n#align multiset.map_add_left_Ioo Multiset.map_add_left_Ioo\n\n/- warning: multiset.map_add_right_Icc -> Multiset.map_add_right_Icc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Icc Multiset.map_add_right_Iccₓ'. -/\ntheorem map_add_right_Icc (a b c : α) : ((Icc a b).map fun x => x + c) = Icc (a + c) (b + c) :=\n  by\n  simp_rw [add_comm _ c]\n  exact map_add_left_Icc _ _ _\n#align multiset.map_add_right_Icc Multiset.map_add_right_Icc\n\n/- warning: multiset.map_add_right_Ico -> Multiset.map_add_right_Ico is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Ico Multiset.map_add_right_Icoₓ'. -/\ntheorem map_add_right_Ico (a b c : α) : ((Ico a b).map fun x => x + c) = Ico (a + c) (b + c) :=\n  by\n  simp_rw [add_comm _ c]\n  exact map_add_left_Ico _ _ _\n#align multiset.map_add_right_Ico Multiset.map_add_right_Ico\n\n/- warning: multiset.map_add_right_Ioc -> Multiset.map_add_right_Ioc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Ioc Multiset.map_add_right_Iocₓ'. -/\ntheorem map_add_right_Ioc (a b c : α) : ((Ioc a b).map fun x => x + c) = Ioc (a + c) (b + c) :=\n  by\n  simp_rw [add_comm _ c]\n  exact map_add_left_Ioc _ _ _\n#align multiset.map_add_right_Ioc Multiset.map_add_right_Ioc\n\n/- warning: multiset.map_add_right_Ioo -> Multiset.map_add_right_Ioo is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} α] [_inst_2 : ExistsAddOfLE.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1))] (a : α) (b : α) (c : α), Eq.{succ u1} (Multiset.{u1} α) (Multiset.map.{u1, u1} α α (fun (x : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) x c) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddRightCancelMonoid.toAddMonoid.{u1} α (AddCancelMonoid.toAddRightCancelMonoid.{u1} α (AddCancelCommMonoid.toAddCancelMonoid.{u1} α (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} α _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Ioo Multiset.map_add_right_Iooₓ'. -/\ntheorem map_add_right_Ioo (a b c : α) : ((Ioo a b).map fun x => x + c) = Ioo (a + c) (b + c) :=\n  by\n  simp_rw [add_comm _ c]\n  exact map_add_left_Ioo _ _ _\n#align multiset.map_add_right_Ioo Multiset.map_add_right_Ioo\n\nend OrderedCancelAddCommMonoid\n\nend Multiset\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Multiset/LocallyFinite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484144, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4859007305732077}}
{"text": "import category_theory.action\n       result\n\nopen_locale classical\nnoncomputable theory\nopen quotient_group is_free_group is_free_groupoid category_theory\n\nuniverse u\n\ndef tree_equiv {G} [inhabited G] (T : quiver G) [is_arbor T] :\n  T.total ⊕ unit ≃ G :=\n{ to_fun := λ x, sum.rec_on x (λ tp, tp.target) (λ _, default G),\n  inv_fun := λ g, match g, (default $ T.path (default G) g) with \n                      | _, quiver.path.nil      := sum.inr ()\n                      | _, quiver.path.cons p e := sum.inl ⟨_, _, e⟩\n                      end,\n  left_inv := begin\n    intro x,\n    rcases x with ⟨a, b, e⟩ | ⟨⟨⟩⟩,\n    { dsimp, rw unique.default_eq ((default $ T.path (default G) a).cons e), refl },\n    { dsimp, rw unique.default_eq quiver.path.nil, refl }\n  end,\n  right_inv := begin\n    intro g,\n    have : ∃ p, default (T.path (default G) g) = p := ⟨_, rfl⟩,\n    rcases this with ⟨p, hp⟩,\n    dsimp, rw hp,\n    cases p; refl\n  end }\n\nlemma tree_not_both {G} [inhabited G] (T : quiver G) [is_arbor T] {a b : G} (e : T a b) (f : T b a) :\n  false :=\nbegin\n  set q : T.path (default G) a := default _,\n  have : q = (q.cons e).cons f,\n  { apply unique.default_eq },\n  apply_fun quiver.path.length at this,\n  change q.length = q.length + 2 at this,\n  suffices : 2 = 0,\n  { tauto },\n  simpa only [self_eq_add_right] using this,\nend\n\ndef tree_symmy_equiv {G} [inhabited G] {A : quiver G} (T : subquiver (symmy A)) [is_arbor ¡T] :\n  tree_symmy T ≃ (¡T).total :=\n{ to_fun := λ ht, if h : (sum.inl ht.val.edge) ∈ T ht.val.source ht.val.target\n                  then ⟨_, _, sum.inl ht.val.edge, h⟩\n                  else ⟨_, _, sum.inr ht.val.edge, or.resolve_left ht.property h⟩,\n  inv_fun := λ t, match t with\n          | ⟨a, b, sum.inl e, h⟩ := ⟨⟨_, _, e⟩, or.inl h⟩\n          | ⟨b, a, sum.inr e, h⟩ := ⟨⟨_, _, e⟩, or.inr h⟩\n          end,\n  left_inv := begin\n    rintro ⟨⟨a, b, e⟩, h⟩,\n    cases h,\n    { dsimp, rw dif_pos h, refl },\n    { dsimp, rw dif_neg, { refl },\n      intro h2, exact tree_not_both (¡T) ⟨sum.inl e, h2⟩ ⟨sum.inr e, h⟩ }\n  end,\n  right_inv := begin\n    rintro ⟨a, b, e, h⟩,\n    cases e,\n    { dsimp, rw dif_pos, refl },\n    { dsimp, rw dif_neg, { refl }, \n      intro hn, exact tree_not_both (¡T) ⟨sum.inl e, hn⟩ ⟨sum.inr e, h⟩ }\n  end }\n\ndef action_gens_equiv {G X : Type u} [group G] [is_free_group G] [mul_action G X] :\n  (gp_gens G) × X ≃ (gpd_gens : quiver (action_category G X)).total :=\n{ to_fun := λ p, ⟨⟨(), p.snd⟩, ⟨(), ((gp_emb p.fst) • p.snd : X)⟩, p.fst, rfl⟩,\n  inv_fun := λ t, (t.edge, t.source.snd),\n  left_inv := by tidy,\n  right_inv := begin -- ugh\n    intro x, rcases x with ⟨⟨⟨⟩, x⟩, ⟨⟨⟩, y⟩, e, h⟩,\n    dsimp, congr, { exact h }, { funext, congr, exact h },\n    { exact proof_irrel_heq rfl h }\n  end }\n\ndef index_formula {G} [group G] [is_free_group G] (H : subgroup G) :\n  (gp_gens G) × (quotient H) ⊕ unit ≃ (gp_gens H) ⊕ (quotient H) :=\ncalc      (gp_gens G) × (quotient H) ⊕ unit \n        ≃ (gpd_gens : quiver $ action_category G (quotient H)).total ⊕ unit \n                : equiv.sum_congr action_gens_equiv (equiv.refl unit)\n    ... ≃ ((gp_gens H) ⊕ tree_symmy _) ⊕ unit\n                : equiv.sum_congr (compl_sum_set_equiv _).symm (equiv.refl unit)\n    ... ≃ (gp_gens H) ⊕ (tree_symmy (geodesic_subgraph (symmy gpd_gens)) ⊕ unit)\n                : equiv.sum_assoc _ _ _\n    ... ≃ (gp_gens H) ⊕ ((quiver.total _) ⊕ unit)\n                : equiv.sum_congr (equiv.refl _) (equiv.sum_congr (tree_symmy_equiv _) (equiv.refl unit))\n    ... ≃ (gp_gens H) ⊕ action_category G (quotient H)\n                : equiv.sum_congr (equiv.refl _) (tree_equiv _) \n    ... ≃ (gp_gens H) ⊕ quotient H\n                : equiv.sum_congr (equiv.refl _) (action_category.obj_equiv G (quotient H)).symm", "meta": {"author": "dwarn", "repo": "nielsen-schreier-2", "sha": "e51a8c6511d374dc584698c7fa236a5be47e7dbe", "save_path": "github-repos/lean/dwarn-nielsen-schreier-2", "path": "github-repos/lean/dwarn-nielsen-schreier-2/nielsen-schreier-2-e51a8c6511d374dc584698c7fa236a5be47e7dbe/src/index_formula.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835371034368, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.48566916230067064}}
{"text": "/-\nCopyright (c) 2020 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n\n! This file was ported from Lean 3 source module tactic.zify\n! leanprover-community/mathlib commit ad7038e538b2112a0c88b985b925e64b3b022947\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Int.Cast.Lemmas\nimport Mathbin.Data.Int.CharZero\nimport Mathbin.Tactic.NormCast\n\n/-!\n# A tactic to shift `ℕ` goals to `ℤ`\n\nIt is often easier to work in `ℤ`, where subtraction is well behaved, than in `ℕ` where it isn't.\n`zify` is a tactic that casts goals and hypotheses about natural numbers to ones about integers.\nIt makes use of `push_cast`, part of the `norm_cast` family, to simplify these goals.\n\n## Implementation notes\n\n`zify` is extensible, using the attribute `@[zify]` to label lemmas used for moving propositions\nfrom `ℕ` to `ℤ`.\n`zify` lemmas should have the form `∀ a₁ ... aₙ : ℕ, Pz (a₁ : ℤ) ... (aₙ : ℤ) ↔ Pn a₁ ... aₙ`.\nFor example, `int.coe_nat_le_coe_nat_iff : ∀ (m n : ℕ), ↑m ≤ ↑n ↔ m ≤ n` is a `zify` lemma.\n\n`zify` is very nearly just `simp only with zify push_cast`. There are a few minor differences:\n* `zify` lemmas are used in the opposite order of the standard simp form.\n  E.g. we will rewrite with `int.coe_nat_le_coe_nat_iff` from right to left.\n* `zify` should fail if no `zify` lemma applies (i.e. it was unable to shift any proposition to ℤ).\n  However, once this succeeds, it does not necessarily need to rewrite with any `push_cast` rules.\n-/\n\n\n-- used by clients\n-- used by clients\nopen Tactic\n\nnamespace Zify\n\n/-- The `zify` attribute is used by the `zify` tactic. It applies to lemmas that shift propositions\nbetween `nat` and `int`.\n\n`zify` lemmas should have the form `∀ a₁ ... aₙ : ℕ, Pz (a₁ : ℤ) ... (aₙ : ℤ) ↔ Pn a₁ ... aₙ`.\nFor example, `int.coe_nat_le_coe_nat_iff : ∀ (m n : ℕ), ↑m ≤ ↑n ↔ m ≤ n` is a `zify` lemma.\n-/\n@[user_attribute]\nunsafe def zify_attr : user_attribute simp_lemmas Unit\n    where\n  Name := `zify\n  descr := \"Used to tag lemmas for use in the `zify` tactic\"\n  cache_cfg :=\n    { mk_cache := fun ns =>\n        mapM\n            (fun n => do\n              let c ← mk_const n\n              return (c, tt))\n            ns >>=\n          simp_lemmas.mk.append_with_symm\n      dependencies := [] }\n#align zify.zify_attr zify.zify_attr\n\n/-- Given an expression `e`, `lift_to_z e` looks for subterms of `e` that are propositions \"about\"\nnatural numbers and change them to propositions about integers.\n\nReturns an expression `e'` and a proof that `e = e'`.\n\nIncludes `ge_iff_le` and `gt_iff_lt` in the simp set. These can't be tagged with `zify` as we\nwant to use them in the \"forward\", not \"backward\", direction.\n-/\nunsafe def lift_to_z (e : expr) : tactic (expr × expr) := do\n  let sl ← zify_attr.get_cache\n  let sl ← sl.add_simp `ge_iff_le\n  let sl ← sl.add_simp `gt_iff_lt\n  let (e', prf, _) ← simplify sl [] e\n  return (e', prf)\n#align zify.lift_to_z zify.lift_to_z\n\nattribute [zify] Int.ofNat_le Int.ofNat_lt Int.ofNat_inj\n\nend Zify\n\n@[zify]\ntheorem Int.coe_nat_ne_coe_nat_iff (a b : ℕ) : (a : ℤ) ≠ b ↔ a ≠ b := by simp\n#align int.coe_nat_ne_coe_nat_iff Int.coe_nat_ne_coe_nat_iff\n\n/-- `zify extra_lems e` is used to shift propositions in `e` from `ℕ` to `ℤ`.\nThis is often useful since `ℤ` has well-behaved subtraction.\n\nThe list of extra lemmas is used in the `push_cast` step.\n\nReturns an expression `e'` and a proof that `e = e'`.-/\nunsafe def tactic.zify (extra_lems : List simp_arg_type) : expr → tactic (expr × expr) := fun z =>\n  do\n  let (z1, p1) ← zify.lift_to_z z <|> fail \"failed to find an applicable zify lemma\"\n  let (z2, p2) ← norm_cast.derive_push_cast extra_lems z1\n  Prod.mk z2 <$> mk_eq_trans p1 p2\n#align tactic.zify tactic.zify\n\n/-- A variant of `tactic.zify` that takes `h`, a proof of a proposition about natural numbers,\nand returns a proof of the zified version of that propositon.\n-/\nunsafe def tactic.zify_proof (extra_lems : List simp_arg_type) (h : expr) : tactic expr := do\n  let (_, pf) ← infer_type h >>= tactic.zify extra_lems\n  mk_eq_mp pf h\n#align tactic.zify_proof tactic.zify_proof\n\nsection\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\n/-- The `zify` tactic is used to shift propositions from `ℕ` to `ℤ`.\nThis is often useful since `ℤ` has well-behaved subtraction.\n\n```lean\nexample (a b c x y z : ℕ) (h : ¬ x*y*z < 0) : c < a + 3*b :=\nbegin\n  zify,\n  zify at h,\n  /-\n  h : ¬↑x * ↑y * ↑z < 0\n  ⊢ ↑c < ↑a + 3 * ↑b\n  -/\nend\n```\n\n`zify` can be given extra lemmas to use in simplification. This is especially useful in the\npresence of nat subtraction: passing `≤` arguments will allow `push_cast` to do more work.\n```\nexample (a b c : ℕ) (h : a - b < c) (hab : b ≤ a) : false :=\nbegin\n  zify [hab] at h,\n  /- h : ↑a - ↑b < ↑c -/\nend\n```\n\n`zify` makes use of the `@[zify]` attribute to move propositions,\nand the `push_cast` tactic to simplify the `ℤ`-valued expressions.\n\n`zify` is in some sense dual to the `lift` tactic. `lift (z : ℤ) to ℕ` will change the type of an\ninteger `z` (in the supertype) to `ℕ` (the subtype), given a proof that `z ≥ 0`;\npropositions concerning `z` will still be over `ℤ`. `zify` changes propositions about `ℕ` (the\nsubtype) to propositions about `ℤ` (the supertype), without changing the type of any variable.\n-/\nunsafe def tactic.interactive.zify (sl : parse simp_arg_list) (l : parse location) : tactic Unit :=\n  do\n  let locs ← l.get_locals\n  replace_at (tactic.zify sl) locs l >>= guardb\n#align tactic.interactive.zify tactic.interactive.zify\n\nend\n\nadd_tactic_doc\n  { Name := \"zify\"\n    category := DocCategory.attr\n    declNames := [`zify.zify_attr]\n    tags := [\"coercions\", \"transport\"] }\n\nadd_tactic_doc\n  { Name := \"zify\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.zify]\n    tags := [\"coercions\", \"transport\"] }\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/Zify.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.48560065830234667}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau\n\nType of linear functions\n-/\nimport linear_algebra.basic\n  linear_algebra.prod_module\n  linear_algebra.quotient_module\n  linear_algebra.subtype_module\nnoncomputable theory\nlocal attribute [instance] classical.prop_decidable\n\nuniverses u v w\nvariables {α : Type u} {β : Type v} {γ : Type w}\n\n/-- The type of linear maps `β → γ` between α-modules β and γ -/\ndef linear_map {α : Type u} (β : Type v) (γ : Type w) [ring α] [module α β] [module α γ] :=\nsubtype (@is_linear_map α β γ _ _ _)\n\nnamespace linear_map\nvariables [ring α] [module α β] [module α γ]\nvariables {r : α} {A B C : linear_map β γ} {x y : β}\ninclude α\n\ninstance : has_coe_to_fun (linear_map β γ) := ⟨_, subtype.val⟩\n\ntheorem ext (h : ∀ x, A x = B x) : A = B := subtype.eq $ funext h\n\nlemma is_linear_map_coe : is_linear_map A := A.property\n\n@[simp] lemma map_add  : A (x + y) = A x + A y := is_linear_map_coe.add x y\n@[simp] lemma map_smul : A (r • x) = r • A x := is_linear_map_coe.smul r x\n@[simp] lemma map_zero : A 0 = 0 := is_linear_map_coe.zero\n@[simp] lemma map_neg  : A (-x) = -A x := is_linear_map_coe.neg _\n@[simp] lemma map_sub  : A (x - y) = A x - A y := is_linear_map_coe.sub _ _\n\n/- kernel -/\n\n/-- Kernel of a linear map, i.e. the set of vectors mapped to zero by the map -/\ndef ker (A : linear_map β γ) : set β := {y | A y = 0}\n\nsection ker\n\n@[simp] lemma mem_ker : x ∈ A.ker ↔ A x = 0 := iff.rfl\n\ntheorem ker_of_map_eq_map (h : A x = A y) : x - y ∈ A.ker :=\nby rw [mem_ker, map_sub]; exact sub_eq_zero_of_eq h\n\ntheorem inj_of_trivial_ker (H : A.ker ⊆ {0}) (h : A x = A y) : x = y :=\neq_of_sub_eq_zero $ set.eq_of_mem_singleton $ H $ ker_of_map_eq_map h\n\nvariables (α A)\n\ninstance ker.is_submodule : is_submodule A.ker :=\n{ zero_ := map_zero,\n  add_ := λ x y HU HV, by rw mem_ker at *; simp [HU, HV, mem_ker],\n  smul := λ r x HV, by rw mem_ker at *; simp [HV] }\n\ntheorem sub_ker (HU : x ∈ A.ker) (HV : y ∈ A.ker) : x - y ∈ A.ker :=\nis_submodule.sub HU HV\n\nend ker\n\n/- image -/\n\n/-- Image of a linear map, the set of vectors of the form `A x` for some β -/\ndef im (A : linear_map β γ) : set γ := {x | ∃ y, A y = x}\n\n@[simp] lemma mem_im {A : linear_map β γ} {z : γ} :\n  z ∈ A.im ↔ ∃ y, A y = z := iff.rfl\n\ninstance im.is_submodule : is_submodule A.im :=\n{ zero_ := ⟨0, map_zero⟩,\n  add_ := λ a b ⟨x, hx⟩ ⟨y, hy⟩, ⟨x + y, by simp [hx, hy]⟩,\n  smul := λ r a ⟨x, hx⟩, ⟨r • x, by simp [hx]⟩ }\n\n/- equivalences -/\nsection\nopen is_submodule quotient_module\n\n/-- first isomorphism law -/\ndef quot_ker_equiv_im (f : linear_map β γ) : (quotient β f.ker) ≃ₗ f.im :=\n{ to_fun     := quotient_module.quotient.lift _\n    (is_linear_map_subtype_mk f.1 f.2 $ assume b, ⟨b, rfl⟩) (assume b eq, subtype.eq eq),\n  inv_fun    := λb, @quotient.mk _ (quotient_rel _) (classical.some b.2),\n  left_inv   := assume b', @quotient.induction_on _ (quotient_rel _) _ b' $\n    begin\n      assume b,\n      apply quotient.sound,\n      apply classical.some_spec2 (λa, f (a - b) = 0),\n      show (∀a, f a = f b → f (a - b) = 0), simp {contextual := tt}\n    end,\n  right_inv  := assume c, subtype.eq $ classical.some_spec2 (λa, f a = c) $ assume b, id,\n  linear_fun :=\n    is_linear_map_quotient_lift _ $ @is_linear_map_subtype_mk _ _ _ _ _ _ f.im _ f f.2 _ }\n\nlemma is_submodule.add_left_iff {s : set β} [is_submodule s] {b₁ b₂ : β} (h₂ : b₂ ∈ s) :\n  b₁ + b₂ ∈ s ↔ b₁ ∈ s :=\niff.intro\n  (assume h,\n    have b₁ + b₂ - b₂ ∈ s, from is_submodule.sub h h₂,\n    by rwa [add_sub_cancel] at this)\n  (assume h₁, is_submodule.add h₁ h₂)\n\nlemma is_submodule.neg_iff {s : set β} [is_submodule s] {b : β} :\n  - b ∈ s ↔ b ∈ s :=\niff.intro\n  (assume h,\n    have - - b ∈ s, from is_submodule.neg h,\n    by rwa [neg_neg] at this)\n  is_submodule.neg\n\n/-- second isomorphism law -/\ndef union_quotient_equiv_quotient_inter {s t : set β} [is_submodule s] [is_submodule t] :\n  quotient s ((coe : s → β) ⁻¹' (s ∩ t)) ≃ₗ quotient (span (s ∪ t)) ((coe : span (s ∪ t) → β) ⁻¹' t) :=\nlet sel₁ : s → span (s ∪ t) := λb, ⟨(b : β), subset_span $ or.inl b.2⟩ in\nhave sel₁_val : ∀b:s, (sel₁ b : β) = b, from assume b, rfl,\nhave ∀b'∈span (s ∪ t), ∃x:s, ∃y∈t, b' = x.1 + y,\n  by simp [span_union, span_eq_of_is_submodule, _inst_4, _inst_5] {contextual := tt},\nlet sel₂ : span (s ∪ t) → s := λb', classical.some (this b'.1 b'.2) in\nhave sel₂_spec : ∀b':span (s ∪ t), ∃y∈t, (b' : β) = (sel₂ b' : β) + y,\n  from assume b', classical.some_spec (this b'.1 b'.2),\n{ to_fun :=\n  begin\n    intro b,\n    fapply quotient.lift_on' b,\n    { intro b', exact sel₁ b' },\n    { assume b₁ b₂ h,\n      change b₁ - b₂ ∈ coe ⁻¹' (s ∩ t) at h,\n      apply quotient_module.eq.2, simp * at * }\n  end,\n  inv_fun :=\n  begin\n    intro b,\n    fapply quotient.lift_on' b,\n    { intro b', exact sel₂ b' },\n    { intros b₁ b₂ h,\n      change b₁ - b₂ ∈ _ at h,\n      rcases (sel₂_spec b₁) with ⟨c₁, hc₁, eq_c₁⟩,\n      rcases (sel₂_spec b₂) with ⟨c₂, hc₂, eq_c₂⟩,\n      have : ((sel₂ b₁ : β) - (sel₂ b₂ : β)) + (c₁ - c₂) ∈ t,\n      { simpa [eq_c₁, eq_c₂, add_comm, add_left_comm, add_assoc] using h, },\n      have ht : (sel₂ b₁ : β) - (sel₂ b₂ : β) ∈ t,\n      { rwa [is_submodule.add_left_iff (is_submodule.sub hc₁ hc₂)] at this },\n      have hs : (sel₂ b₁ : β) - (sel₂ b₂ : β) ∈ s,\n      { from is_submodule.sub (sel₂ b₁).2 (sel₂ b₂).2 },\n      apply quotient_module.eq.2,\n      simp * at * }\n  end,\n  right_inv := assume b', quotient.induction_on' b'\n  begin\n    intro b, apply quotient_module.eq.2,\n    rcases (sel₂_spec b) with ⟨c, hc, eq_c⟩,\n    simp [eq_c, hc, is_submodule.neg_iff]\n  end,\n  left_inv := assume b', @quotient.induction_on _ (quotient_rel _) _ b'\n  begin\n    intro b, apply quotient_module.eq.2,\n    rcases (sel₂_spec (sel₁ b)) with ⟨c, hct, eq⟩,\n    have b_eq : (b : β) = c + (sel₂ (sel₁ b)),\n    { simpa [sel₁_val] using eq },\n    have : (b : β) ∈ s, from b.2,\n    have hcs : c ∈ s,\n    { rwa [b_eq, is_submodule.add_left_iff (sel₂ (sel₁ b)).mem] at this },\n    show (sel₂ (sel₁ b) - b : β) ∈ s ∩ t, { simp [b_eq, hct, hcs, is_submodule.neg_iff] }\n  end,\n  linear_fun :=  is_linear_map_quotient_lift _ $ (is_linear_map_quotient_mk _).comp $\n    is_linear_map_subtype_mk _ (is_submodule.is_linear_map_coe s) _ }\n\nend\n\nsection add_comm_group\n\ninstance : has_add (linear_map β γ) := ⟨λhf hg, ⟨_, hf.2.map_add hg.2⟩⟩\ninstance : has_zero (linear_map β γ) := ⟨⟨_, is_linear_map.map_zero⟩⟩\ninstance : has_neg (linear_map β γ) := ⟨λhf, ⟨_, hf.2.map_neg⟩⟩\n\n@[simp] lemma add_app : (A + B) x = A x + B x := rfl\n@[simp] lemma zero_app : (0 : linear_map β γ) x = 0 := rfl\n@[simp] lemma neg_app : (-A) x = -A x := rfl\n\ninstance : add_comm_group (linear_map β γ) :=\nby refine {add := (+), zero := 0, neg := has_neg.neg, ..}; { intros, apply ext, simp }\n\nend add_comm_group\n\nend linear_map\n\nnamespace linear_map\nvariables [comm_ring α] [module α β] [module α γ]\n\ninstance : has_scalar α (linear_map β γ) := ⟨λr f, ⟨λb, r • f b, f.2.map_smul_right⟩⟩\n\n@[simp] lemma smul_app {r : α} {x : β} {A : linear_map β γ} : (r • A) x = r • (A x) := rfl\n\nvariables (α β γ)\n\ninstance : module α (linear_map β γ) :=\nby refine {smul := (•), ..linear_map.add_comm_group, ..};\n  { intros, apply ext, simp [smul_add, add_smul, mul_smul] }\n\nend linear_map\n\nnamespace module\nvariables [ring α] [module α β]\ninclude α β\n\ninstance : has_one (linear_map β β) := ⟨⟨id, is_linear_map.id⟩⟩\ninstance : has_mul (linear_map β β) := ⟨λf g, ⟨_, is_linear_map.comp f.2 g.2⟩⟩\n\n@[simp] lemma one_app (x : β) : (1 : linear_map β β) x = x := rfl\n@[simp] lemma mul_app (A B : linear_map β β) (x : β) : (A * B) x = A (B x) := rfl\n\nvariables (α β)\n\n-- declaring this an instance breaks `real.lean` with reaching max. instance resolution depth\ndef endomorphism_ring : ring (linear_map β β) :=\nby refine {mul := (*), one := 1, ..linear_map.add_comm_group, ..};\n  { intros, apply linear_map.ext, simp }\n\n/-- The group of invertible linear maps from `β` to itself -/\ndef general_linear_group :=\nby haveI := endomorphism_ring α β; exact units (linear_map β β)\n\nend module\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/linear_algebra/linear_map_module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4856006576825129}}
{"text": "/-\nCopyright (c) 2014 Robert Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Lewis, Leonardo de Moura, Johannes Hölzl, Mario Carneiro\n\n! This file was ported from Lean 3 source module algebra.field.basic\n! leanprover-community/mathlib commit 05101c3df9d9cfe9430edc205860c79b6d660102\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Field.Defs\nimport Mathlib.Algebra.GroupWithZero.Units.Lemmas\nimport Mathlib.Algebra.Hom.Ring\nimport Mathlib.Algebra.Ring.Commute\n\n/-!\n# Lemmas about division (semi)rings and (semi)fields\n\n-/\n\n\nopen Function OrderDual Set\n\nuniverse u\n\nvariable {α β K : Type _}\n\nsection DivisionSemiring\n\nvariable [DivisionSemiring α] {a b c d : α}\n\ntheorem add_div (a b c : α) : (a + b) / c = a / c + b / c := by simp_rw [div_eq_mul_inv, add_mul]\n#align add_div add_div\n\n@[field_simps]\ntheorem div_add_div_same (a b c : α) : a / c + b / c = (a + b) / c :=\n  (add_div _ _ _).symm\n#align div_add_div_same div_add_div_same\n\ntheorem same_add_div (h : b ≠ 0) : (b + a) / b = 1 + a / b := by rw [← div_self h, add_div]\n#align same_add_div same_add_div\n\ntheorem div_add_same (h : b ≠ 0) : (a + b) / b = a / b + 1 := by rw [← div_self h, add_div]\n#align div_add_same div_add_same\n\ntheorem one_add_div (h : b ≠ 0) : 1 + a / b = (b + a) / b :=\n  (same_add_div h).symm\n#align one_add_div one_add_div\n\ntheorem div_add_one (h : b ≠ 0) : a / b + 1 = (a + b) / b :=\n  (div_add_same h).symm\n#align div_add_one div_add_one\n\ntheorem one_div_mul_add_mul_one_div_eq_one_div_add_one_div (ha : a ≠ 0) (hb : b ≠ 0) :\n    1 / a * (a + b) * (1 / b) = 1 / a + 1 / b := by\n  rw [mul_add, one_div_mul_cancel ha, add_mul, one_mul, mul_assoc, mul_one_div_cancel hb, mul_one,\n    add_comm]\n#align one_div_mul_add_mul_one_div_eq_one_div_add_one_div one_div_mul_add_mul_one_div_eq_one_div_add_one_div\n\ntheorem add_div_eq_mul_add_div (a b : α) (hc : c ≠ 0) : a + b / c = (a * c + b) / c :=\n  (eq_div_iff_mul_eq hc).2 <| by rw [right_distrib, div_mul_cancel _ hc]\n#align add_div_eq_mul_add_div add_div_eq_mul_add_div\n\n@[field_simps]\ntheorem add_div' (a b c : α) (hc : c ≠ 0) : b + a / c = (b * c + a) / c := by\n  rw [add_div, mul_div_cancel _ hc]\n#align add_div' add_div'\n\n@[field_simps]\ntheorem div_add' (a b c : α) (hc : c ≠ 0) : a / c + b = (a + b * c) / c := by\n  rwa [add_comm, add_div', add_comm]\n#align div_add' div_add'\n\nprotected theorem Commute.div_add_div (hbc : Commute b c) (hbd : Commute b d) (hb : b ≠ 0)\n    (hd : d ≠ 0) : a / b + c / d = (a * d + b * c) / (b * d) := by\n  rw [add_div, mul_div_mul_right _ b hd, hbc.eq, hbd.eq, mul_div_mul_right c d hb]\n#align commute.div_add_div Commute.div_add_div\n\nprotected theorem Commute.one_div_add_one_div (hab : Commute a b) (ha : a ≠ 0) (hb : b ≠ 0) :\n    1 / a + 1 / b = (a + b) / (a * b) := by\n  rw [(Commute.one_right a).div_add_div hab ha hb, one_mul, mul_one, add_comm]\n#align commute.one_div_add_one_div Commute.one_div_add_one_div\n\nprotected theorem Commute.inv_add_inv (hab : Commute a b) (ha : a ≠ 0) (hb : b ≠ 0) :\n    a⁻¹ + b⁻¹ = (a + b) / (a * b) := by\n  rw [inv_eq_one_div, inv_eq_one_div, hab.one_div_add_one_div ha hb]\n#align commute.inv_add_inv Commute.inv_add_inv\n\nend DivisionSemiring\n\nsection DivisionMonoid\n\nvariable [DivisionMonoid K] [HasDistribNeg K] {a b : K}\n\ntheorem one_div_neg_one_eq_neg_one : (1 : K) / -1 = -1 :=\n  have : -1 * -1 = (1 : K) := by rw [neg_mul_neg, one_mul]\n  Eq.symm (eq_one_div_of_mul_eq_one_right this)\n#align one_div_neg_one_eq_neg_one one_div_neg_one_eq_neg_one\n\ntheorem one_div_neg_eq_neg_one_div (a : K) : 1 / -a = -(1 / a) :=\n  calc\n    1 / -a = 1 / (-1 * a) := by rw [neg_eq_neg_one_mul]\n    _ = 1 / a * (1 / -1) := by rw [one_div_mul_one_div_rev]\n    _ = 1 / a * -1 := by rw [one_div_neg_one_eq_neg_one]\n    _ = -(1 / a) := by rw [mul_neg, mul_one]\n#align one_div_neg_eq_neg_one_div one_div_neg_eq_neg_one_div\n\ntheorem div_neg_eq_neg_div (a b : K) : b / -a = -(b / a) :=\n  calc\n    b / -a = b * (1 / -a) := by rw [← inv_eq_one_div, division_def]\n    _ = b * -(1 / a) := by rw [one_div_neg_eq_neg_one_div]\n    _ = -(b * (1 / a)) := by rw [neg_mul_eq_mul_neg]\n    _ = -(b / a) := by rw [mul_one_div]\n#align div_neg_eq_neg_div div_neg_eq_neg_div\n\ntheorem neg_div (a b : K) : -b / a = -(b / a) := by\n  rw [neg_eq_neg_one_mul, mul_div_assoc, ← neg_eq_neg_one_mul]\n#align neg_div neg_div\n\n@[field_simps]\ntheorem neg_div' (a b : K) : -(b / a) = -b / a := by simp [neg_div]\n#align neg_div' neg_div'\n\ntheorem neg_div_neg_eq (a b : K) : -a / -b = a / b := by rw [div_neg_eq_neg_div, neg_div, neg_neg]\n#align neg_div_neg_eq neg_div_neg_eq\n\ntheorem neg_inv : -a⁻¹ = (-a)⁻¹ := by rw [inv_eq_one_div, inv_eq_one_div, div_neg_eq_neg_div]\n#align neg_inv neg_inv\n\ntheorem div_neg (a : K) : a / -b = -(a / b) := by rw [← div_neg_eq_neg_div]\n#align div_neg div_neg\n\ntheorem inv_neg : (-a)⁻¹ = -a⁻¹ := by rw [neg_inv]\n#align inv_neg inv_neg\n\ntheorem inv_neg_one : (-1 : K)⁻¹ = -1 := by rw [← neg_inv, inv_one]\n\nend DivisionMonoid\n\nsection DivisionRing\n\nvariable [DivisionRing K] {a b c d : K}\n\n@[simp]\ntheorem div_neg_self {a : K} (h : a ≠ 0) : a / -a = -1 := by rw [div_neg_eq_neg_div, div_self h]\n#align div_neg_self div_neg_self\n\n@[simp]\ntheorem neg_div_self {a : K} (h : a ≠ 0) : -a / a = -1 := by rw [neg_div, div_self h]\n#align neg_div_self neg_div_self\n\ntheorem div_sub_div_same (a b c : K) : a / c - b / c = (a - b) / c := by\n  rw [sub_eq_add_neg, ← neg_div, div_add_div_same, sub_eq_add_neg]\n#align div_sub_div_same div_sub_div_same\n\ntheorem same_sub_div {a b : K} (h : b ≠ 0) : (b - a) / b = 1 - a / b := by\n  simpa only [← @div_self _ _ b h] using (div_sub_div_same b a b).symm\n#align same_sub_div same_sub_div\n\ntheorem one_sub_div {a b : K} (h : b ≠ 0) : 1 - a / b = (b - a) / b :=\n  (same_sub_div h).symm\n#align one_sub_div one_sub_div\n\ntheorem div_sub_same {a b : K} (h : b ≠ 0) : (a - b) / b = a / b - 1 := by\n  simpa only [← @div_self _ _ b h] using (div_sub_div_same a b b).symm\n#align div_sub_same div_sub_same\n\ntheorem div_sub_one {a b : K} (h : b ≠ 0) : a / b - 1 = (a - b) / b :=\n  (div_sub_same h).symm\n#align div_sub_one div_sub_one\n\ntheorem sub_div (a b c : K) : (a - b) / c = a / c - b / c :=\n  (div_sub_div_same _ _ _).symm\n#align sub_div sub_div\n\n/-- See `inv_sub_inv` for the more convenient version when `K` is commutative. -/\ntheorem inv_sub_inv' {a b : K} (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ - b⁻¹ = a⁻¹ * (b - a) * b⁻¹ := by\n  rw [mul_sub, sub_mul, mul_inv_cancel_right₀ hb, inv_mul_cancel ha, one_mul]\n#align inv_sub_inv' inv_sub_inv'\n\ntheorem one_div_mul_sub_mul_one_div_eq_one_div_add_one_div (ha : a ≠ 0) (hb : b ≠ 0) :\n    1 / a * (b - a) * (1 / b) = 1 / a - 1 / b := by\n  rw [mul_sub_left_distrib (1 / a), one_div_mul_cancel ha, mul_sub_right_distrib, one_mul,\n    mul_assoc, mul_one_div_cancel hb, mul_one]\n#align one_div_mul_sub_mul_one_div_eq_one_div_add_one_div one_div_mul_sub_mul_one_div_eq_one_div_add_one_div\n\n-- see Note [lower instance priority]\ninstance (priority := 100) DivisionRing.isDomain : IsDomain K :=\n  NoZeroDivisors.to_isDomain _\n#align division_ring.is_domain DivisionRing.isDomain\n\nprotected theorem Commute.div_sub_div (hbc : Commute b c) (hbd : Commute b d) (hb : b ≠ 0)\n    (hd : d ≠ 0) : a / b - c / d = (a * d - b * c) / (b * d) := by\n  simpa only [mul_neg, neg_div, ← sub_eq_add_neg] using hbc.neg_right.div_add_div hbd hb hd\n#align commute.div_sub_div Commute.div_sub_div\n\nprotected theorem Commute.inv_sub_inv (hab : Commute a b) (ha : a ≠ 0) (hb : b ≠ 0) :\n    a⁻¹ - b⁻¹ = (b - a) / (a * b) := by\n  simp only [inv_eq_one_div, (Commute.one_right a).div_sub_div hab ha hb, one_mul, mul_one]\n#align commute.inv_sub_inv Commute.inv_sub_inv\n\nend DivisionRing\n\nsection Semifield\n\nvariable [Semifield α] {a b c d : α}\n\ntheorem div_add_div (a : α) (c : α) (hb : b ≠ 0) (hd : d ≠ 0) :\n    a / b + c / d = (a * d + b * c) / (b * d) :=\n  (Commute.all b _).div_add_div (Commute.all _ _) hb hd\n#align div_add_div div_add_div\n\ntheorem one_div_add_one_div (ha : a ≠ 0) (hb : b ≠ 0) : 1 / a + 1 / b = (a + b) / (a * b) :=\n  (Commute.all a _).one_div_add_one_div ha hb\n#align one_div_add_one_div one_div_add_one_div\n\ntheorem inv_add_inv (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ + b⁻¹ = (a + b) / (a * b) :=\n  (Commute.all a _).inv_add_inv ha hb\n#align inv_add_inv inv_add_inv\n\nend Semifield\n\nsection Field\n\nvariable [Field K]\n\nattribute [local simp] mul_assoc mul_comm mul_left_comm\n\n@[field_simps]\ntheorem div_sub_div (a : K) {b : K} (c : K) {d : K} (hb : b ≠ 0) (hd : d ≠ 0) :\n    a / b - c / d = (a * d - b * c) / (b * d) :=\n  (Commute.all b _).div_sub_div (Commute.all _ _) hb hd\n#align div_sub_div div_sub_div\n\ntheorem inv_sub_inv {a b : K} (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ - b⁻¹ = (b - a) / (a * b) := by\n  rw [inv_eq_one_div, inv_eq_one_div, div_sub_div _ _ ha hb, one_mul, mul_one]\n#align inv_sub_inv inv_sub_inv\n\n@[field_simps]\ntheorem sub_div' (a b c : K) (hc : c ≠ 0) : b - a / c = (b * c - a) / c := by\n  simpa using div_sub_div b a one_ne_zero hc\n#align sub_div' sub_div'\n\n@[field_simps]\ntheorem div_sub' (a b c : K) (hc : c ≠ 0) : a / c - b = (a - c * b) / c := by\n  simpa using div_sub_div a b hc one_ne_zero\n#align div_sub' div_sub'\n\n-- see Note [lower instance priority]\ninstance (priority := 100) Field.isDomain : IsDomain K :=\n  { DivisionRing.isDomain with }\n#align field.is_domain Field.isDomain\n\nend Field\n\nnamespace RingHom\n\nprotected theorem injective [DivisionRing α] [Semiring β] [Nontrivial β] (f : α →+* β) :\n    Injective f :=\n  (injective_iff_map_eq_zero f).2 fun _ ↦ (map_eq_zero f).1\n#align ring_hom.injective RingHom.injective\n\nend RingHom\n\nsection NoncomputableDefs\n\nvariable {R : Type _} [Nontrivial R]\n\n/-- Constructs a `DivisionRing` structure on a `Ring` consisting only of units and 0. -/\nnoncomputable def divisionRingOfIsUnitOrEqZero [hR : Ring R] (h : ∀ a : R, IsUnit a ∨ a = 0) :\n    DivisionRing R :=\n  { groupWithZeroOfIsUnitOrEqZero h, hR with }\n#align division_ring_of_is_unit_or_eq_zero divisionRingOfIsUnitOrEqZero\n\n/-- Constructs a `Field` structure on a `CommRing` consisting only of units and 0.\nSee note [reducible non-instances]. -/\n@[reducible]\nnoncomputable def fieldOfIsUnitOrEqZero [hR : CommRing R] (h : ∀ a : R, IsUnit a ∨ a = 0) :\n    Field R :=\n  { groupWithZeroOfIsUnitOrEqZero h, hR with }\n#align field_of_is_unit_or_eq_zero fieldOfIsUnitOrEqZero\n\nend NoncomputableDefs\n\n-- See note [reducible non-instances]\n/-- Pullback a `DivisionSemiring` along an injective function. -/\n@[reducible]\nprotected def Function.Injective.divisionSemiring [DivisionSemiring β] [Zero α] [Mul α] [Add α]\n    [One α] [Inv α] [Div α] [SMul ℕ α] [Pow α ℕ] [Pow α ℤ] [NatCast α] (f : α → β)\n    (hf : Injective f) (zero : f 0 = 0) (one : f 1 = 1) (add : ∀ x y, f (x + y) = f x + f y)\n    (mul : ∀ x y, f (x * y) = f x * f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)\n    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)\n    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)\n    (nat_cast : ∀ n : ℕ, f n = n) : DivisionSemiring α :=\n  { hf.groupWithZero f zero one mul inv div npow zpow,\n    hf.semiring f zero one add mul nsmul npow nat_cast with }\n#align function.injective.division_semiring Function.Injective.divisionSemiring\n\n/-- Pullback a `DivisionSemiring` along an injective function.\nSee note [reducible non-instances]. -/\n@[reducible]\nprotected def Function.Injective.divisionRing [DivisionRing K] {K'} [Zero K'] [One K'] [Add K']\n    [Mul K'] [Neg K'] [Sub K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K']\n    [Pow K' ℕ] [Pow K' ℤ] [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (hf : Injective f)\n    (zero : f 0 = 0) (one : f 1 = 1) (add : ∀ x y, f (x + y) = f x + f y)\n    (mul : ∀ x y, f (x * y) = f x * f y) (neg : ∀ x, f (-x) = -f x)\n    (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)\n    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)\n    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)\n    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)\n    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :\n    DivisionRing K' :=\n  { hf.groupWithZero f zero one mul inv div npow zpow,\n    hf.ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with\n    ratCast := Rat.cast,\n    ratCast_mk := fun a b h1 h2 ↦\n      hf\n        (by\n          erw [rat_cast, mul, inv, int_cast, nat_cast]\n          exact DivisionRing.ratCast_mk a b h1 h2),\n    qsmul := (· • ·), qsmul_eq_mul' := fun a x ↦ hf (by erw [qsmul, mul, Rat.smul_def, rat_cast]) }\n#align function.injective.division_ring Function.Injective.divisionRing\n\n-- See note [reducible non-instances]\n/-- Pullback a `Field` along an injective function. -/\n@[reducible]\nprotected def Function.Injective.semifield [Semifield β] [Zero α] [Mul α] [Add α] [One α] [Inv α]\n    [Div α] [SMul ℕ α] [Pow α ℕ] [Pow α ℤ] [NatCast α] (f : α → β) (hf : Injective f)\n    (zero : f 0 = 0) (one : f 1 = 1) (add : ∀ x y, f (x + y) = f x + f y)\n    (mul : ∀ x y, f (x * y) = f x * f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)\n    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)\n    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)\n    (nat_cast : ∀ n : ℕ, f n = n) : Semifield α :=\n  { hf.commGroupWithZero f zero one mul inv div npow zpow,\n    hf.commSemiring f zero one add mul nsmul npow nat_cast with }\n#align function.injective.semifield Function.Injective.semifield\n\n/-- Pullback a `Field` along an injective function.\nSee note [reducible non-instances]. -/\n@[reducible]\nprotected def Function.Injective.field [Field K] {K'} [Zero K'] [Mul K'] [Add K'] [Neg K'] [Sub K']\n    [One K'] [Inv K'] [Div K'] [SMul ℕ K'] [SMul ℤ K'] [SMul ℚ K'] [Pow K' ℕ] [Pow K' ℤ]\n    [NatCast K'] [IntCast K'] [RatCast K'] (f : K' → K) (hf : Injective f) (zero : f 0 = 0)\n    (one : f 1 = 1) (add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)\n    (neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y) (inv : ∀ x, f x⁻¹ = (f x)⁻¹)\n    (div : ∀ x y, f (x / y) = f x / f y) (nsmul : ∀ (x) (n : ℕ), f (n • x) = n • f x)\n    (zsmul : ∀ (x) (n : ℤ), f (n • x) = n • f x) (qsmul : ∀ (x) (n : ℚ), f (n • x) = n • f x)\n    (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) (zpow : ∀ (x) (n : ℤ), f (x ^ n) = f x ^ n)\n    (nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) (rat_cast : ∀ n : ℚ, f n = n) :\n    Field K' :=\n  { hf.commGroupWithZero f zero one mul inv div npow zpow,\n    hf.commRing f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast with\n    ratCast := Rat.cast,\n    ratCast_mk := fun a b h1 h2 ↦\n      hf\n        (by\n          erw [rat_cast, mul, inv, int_cast, nat_cast]\n          exact DivisionRing.ratCast_mk a b h1 h2),\n    qsmul := (· • ·), qsmul_eq_mul' := fun a x ↦ hf (by erw [qsmul, mul, Rat.smul_def, rat_cast]) }\n#align function.injective.field Function.Injective.field\n\n/-! ### Order dual -/\n\n\ninstance [h : RatCast α] : RatCast αᵒᵈ :=\n  h\n\ninstance [h : DivisionSemiring α] : DivisionSemiring αᵒᵈ :=\n  h\n\ninstance [h : DivisionRing α] : DivisionRing αᵒᵈ :=\n  h\n\ninstance [h : Semifield α] : Semifield αᵒᵈ :=\n  h\n\ninstance [h : Field α] : Field αᵒᵈ :=\n  h\n\n@[simp]\ntheorem toDual_rat_cast [RatCast α] (n : ℚ) : toDual (n : α) = n :=\n  rfl\n#align to_dual_rat_cast toDual_rat_cast\n\n@[simp]\ntheorem ofDual_rat_cast [RatCast α] (n : ℚ) : (ofDual n : α) = n :=\n  rfl\n#align of_dual_rat_cast ofDual_rat_cast\n\n/-! ### Lexicographic order -/\n\ninstance [h : RatCast α] : RatCast (Lex α) :=\n  h\n\ninstance [h : DivisionSemiring α] : DivisionSemiring (Lex α) :=\n  h\n\ninstance [h : DivisionRing α] : DivisionRing (Lex α) :=\n  h\n\ninstance [h : Semifield α] : Semifield (Lex α) :=\n  h\n\ninstance [h : Field α] : Field (Lex α) :=\n  h\n\n@[simp]\ntheorem toLex_rat_cast [RatCast α] (n : ℚ) : toLex (n : α) = n :=\n  rfl\n#align to_lex_rat_cast toLex_rat_cast\n\n@[simp]\ntheorem ofLex_rat_cast [RatCast α] (n : ℚ) : (ofLex n : α) = n :=\n  rfl\n#align of_lex_rat_cast ofLex_rat_cast\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/Field/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.4856006482978259}}
{"text": "/-\nCopyright (c) 2021 Ashvni Narayanan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ashvni Narayanan\n-/\nimport data.zmod.quotient\nimport ring_theory.roots_of_unity\nimport zmod.properties\n/-!\n# Dirichlet characters\nThis file defines Dirichlet characters over (ℤ/nℤ)* and then relates them\nto multiplicative homomorphisms over ℤ/nℤ for any n divisible by the conductor.\n\n## Main definitions\n * `dirichlet_character`\n * `asso_dirichlet_character`\n * `change_level`\n * `conductor`\n\n## Tags\np-adic, L-function, Bernoulli measure, Dirichlet character\n-/\n\nlemma is_unit.unit_mul {α : Type*} [monoid α] {x y : α} (hx : is_unit x) (hy : is_unit y) :\n  hx.unit * hy.unit = (hx.mul hy).unit :=\n  by { rw ←units.eq_iff, simp [is_unit.unit_spec] }\n\n/-- A Dirichlet character is defined as a monoid homomorphism which is periodic. -/\nabbreviation dirichlet_character (R : Type*) [monoid R] (n : ℕ) := units (zmod n) →* units R\n\nopen_locale classical\n\nlemma extend_eq_char {R : Type*} [monoid_with_zero R] {n : ℕ}\n  (χ : dirichlet_character R n) {x : zmod n} (hx : is_unit x) :\n  function.extend (units.coe_hom (zmod n)) ((units.coe_hom R) ∘ χ) 0 x = χ hx.unit :=\nbegin\n  conv_lhs { congr, skip, skip, skip, rw ←is_unit.unit_spec hx, },\n  rw ←units.coe_hom_apply, rw function.extend_apply _,\n  { simp only [units.coe_hom_apply, function.comp_app], },\n  { exact units.ext, },\nend\n\nlemma extend_eq_zero {R : Type*} [monoid_with_zero R] {n : ℕ}\n  (χ : dirichlet_character R n) {x : zmod n} (hx : ¬ is_unit x) :\n  function.extend (units.coe_hom (zmod n)) ((units.coe_hom R) ∘ χ) 0 x = 0 :=\nbegin\n  rw [function.extend_def, dif_neg],\n  { simp only [pi.zero_apply], },\n  { contrapose hx, rw not_not at *, cases hx with a ha, rw ←ha, apply units.is_unit, },\nend\n\n/-- The Dirichlet character on ℤ/nℤ →* R determined by χ, 0 on non-units. -/\nnoncomputable abbreviation asso_dirichlet_character {R : Type*} [monoid_with_zero R] {n : ℕ}\n  (χ : dirichlet_character R n) : zmod n →* R :=\n{ to_fun := function.extend (units.coe_hom (zmod n)) ((units.coe_hom R) ∘ χ) 0,\n  map_one' := begin\n    rw [extend_eq_char _ is_unit_one, units.coe_eq_one],\n    convert χ.map_one',\n    rw [←units.eq_iff, is_unit.unit_spec, units.coe_one],\n  end,\n  map_mul' := λ x y, begin\n    by_cases is_unit x ∧ is_unit y,\n    { rw [extend_eq_char _ (is_unit.mul h.1 h.2), extend_eq_char _ h.1, extend_eq_char _ h.2],\n      change (units.coe_hom R) (χ _) = (units.coe_hom R) (χ _) * (units.coe_hom R) (χ _),\n      repeat { rw ←monoid_hom.comp_apply _ χ, },\n      convert ←monoid_hom.map_mul' (monoid_hom.comp (units.coe_hom R) χ) _ _,\n      rw is_unit.unit_mul, },\n    { have : ¬ (is_unit (x * y)),\n      { contrapose h, rw not_not at *, rw ←is_unit.mul_iff, assumption, },\n      rw extend_eq_zero _ this,\n      push_neg at h,\n      by_cases h' : is_unit x,\n      { rw [extend_eq_zero _ (h h'), mul_zero], },\n      { rw [extend_eq_zero _ h', zero_mul], }, },\n  end, }\n-- is it possible to construct monoid_hom.extend?\n\nlemma asso_dirichlet_character_eq_char {R : Type*} [monoid_with_zero R] {n : ℕ}\n  (χ : dirichlet_character R n) (a : units (zmod n)) : asso_dirichlet_character χ a = χ a :=\nby { convert extend_eq_char χ a.is_unit, rw [←units.eq_iff, (a.is_unit).unit_spec], }\n\nlemma asso_dirichlet_character_eq_char' {R : Type*} [monoid_with_zero R] {n : ℕ}\n  (χ : dirichlet_character R n) {a : zmod n} (ha : is_unit a) :\n  asso_dirichlet_character χ a = χ ha.unit :=\nby { convert extend_eq_char χ ha, }\n\nlemma asso_dirichlet_character_eq_zero {R : Type*} [monoid_with_zero R] {n : ℕ}\n  (χ : dirichlet_character R n) {a : zmod n} (ha : ¬ is_unit a) :\n  asso_dirichlet_character χ a = 0 :=\nby { convert extend_eq_zero χ ha, }\n\nlemma asso_dirichlet_character_eq_iff {R : Type*} [monoid_with_zero R] {n : ℕ}\n  (χ : dirichlet_character R n) (ψ : dirichlet_character R n) :\n  χ = ψ ↔ asso_dirichlet_character χ = asso_dirichlet_character ψ :=\n⟨λ h, begin\n  ext, by_cases hx : is_unit x,\n  { simp_rw asso_dirichlet_character_eq_char' _ hx, rw h, },\n  { rw asso_dirichlet_character_eq_zero _ hx, rw asso_dirichlet_character_eq_zero _ hx, },\n  end,\nλ h, begin\n  ext,\n  repeat { rw ←asso_dirichlet_character_eq_char _ x, }, rw h,\n  end⟩\n\nnamespace dirichlet_character\n\nvariables {R : Type*} [comm_monoid_with_zero R] {n : ℕ} (χ : dirichlet_character R n)\n--commutativity is needed to define mul, not before that\n\nlemma asso_dirichlet_character_eval_sub (x : zmod n) :\n  asso_dirichlet_character χ (n - x) = asso_dirichlet_character χ (-x) :=\nby { congr, simp, }\n\nlemma is_periodic (m : ℕ) (hm : n ∣ m) (a : ℤ) :\n  asso_dirichlet_character χ (a + m) = asso_dirichlet_character χ a :=\nbegin\n  rw ← zmod.nat_coe_zmod_eq_zero_iff_dvd at hm,\n  simp only [hm, add_zero],\nend\n\n/-- Extends the Dirichlet character χ of level n to level m, where n ∣ m. -/\ndef change_level {m : ℕ} (hm : n ∣ m) : dirichlet_character R n →* dirichlet_character R m :=\n{ to_fun := λ ψ, ψ.comp (units.map (zmod.cast_hom hm (zmod n))),\n  map_one' := by simp,\n  map_mul' := λ ψ₁ ψ₂, monoid_hom.mul_comp _ _ _, }\n\nlemma change_level_def {m : ℕ} (hm : n ∣ m) : change_level hm χ = χ.comp (units.map (zmod.cast_hom hm (zmod n))) := rfl\n\nnamespace change_level\nlemma self : change_level (dvd_refl n) χ = χ := by { rw change_level_def, simp, }\n\nlemma dvd {m d : ℕ} (hm : n ∣ m) (hd : m ∣ d) :\n  change_level (dvd_trans hm hd) χ = change_level hd (change_level hm χ) :=\nbegin\n  repeat { rw change_level_def, }, \n  rw [monoid_hom.comp_assoc, ←units.map_comp], \n  change _ = χ.comp (units.map ↑((zmod.cast_hom hm (zmod n)).comp (zmod.cast_hom hd (zmod m)))),\n  congr,\nend\n\nlemma asso_dirichlet_character_eq {m : ℕ} (hm : n ∣ m) (a : units (zmod m)) :\n  asso_dirichlet_character (change_level hm χ) a = asso_dirichlet_character χ a :=\nbegin\n  rw asso_dirichlet_character_eq_char' _,\n  swap, { apply (units.is_unit a), },\n  { rw asso_dirichlet_character_eq_char' _,\n    swap, { change is_unit ((a : zmod m) : zmod n),\n      rw ←zmod.cast_hom_apply (a : zmod m),\n      swap 3, { apply zmod.char_p _, },\n      swap, { assumption, },\n      rw [←ring_hom.coe_monoid_hom, ←units.coe_map _ _],\n      apply units.is_unit, },\n    { rw [units.eq_iff, change_level_def],\n      simp only [function.comp_app, monoid_hom.coe_comp, coe_coe], congr,\n      rw [←units.eq_iff, units.coe_map, is_unit.unit_spec _, is_unit.unit_spec _], refl, }, },\nend\n\nlemma asso_dirichlet_character_eq' {m : ℕ} (hm : n ∣ m) {a : zmod m}\n  (ha : is_unit a) : asso_dirichlet_character (change_level hm χ) a =\n  asso_dirichlet_character χ a :=\nbegin\n  rw [←is_unit.unit_spec ha, asso_dirichlet_character_eq], congr,\nend\nend change_level\n\n/-- χ₀ of level d factors through χ of level n if d ∣ n and χ₀ = χ ∘ (zmod n → zmod d). -/\nstructure factors_through (d : ℕ) : Prop :=\n(dvd : d ∣ n)\n(ind_char : ∃ χ₀ : dirichlet_character R d, χ = change_level dvd χ₀)\n\nnamespace factors_through\nlemma spec {d : ℕ} (h : factors_through χ d) :\n  χ = change_level h.1 (classical.some (h.ind_char)) := classical.some_spec (h.ind_char)\nend factors_through\n\n/-- The set of natural numbers for which a Dirichlet character is periodic. -/\ndef conductor_set : set ℕ := {x : ℕ | χ.factors_through x}\n\nlemma mem_conductor_set_iff {x : ℕ} : x ∈ χ.conductor_set ↔ χ.factors_through x := iff.refl _\n\nlemma level_mem_conductor_set : n ∈ conductor_set χ := (mem_conductor_set_iff _).2\n{ dvd := dvd_rfl,\n  ind_char := ⟨χ, (change_level.self χ).symm⟩, }\n\nlemma mem_conductor_set_dvd {x : ℕ} (hx : x ∈ χ.conductor_set) : x ∣ n := hx.1\n\nlemma mem_conductor_set_factors_through {x : ℕ} (hx : x ∈ χ.conductor_set) : χ.factors_through x := hx\n\n/-- The minimum natural number n for which a Dirichlet character is periodic.\n  The Dirichlet character χ can then alternatively be reformulated on ℤ/nℤ. -/\nnoncomputable def conductor : ℕ := Inf (conductor_set χ)\n\nlemma nat.le_one {n : ℕ} (h : n ≤ 1) : n = 0 ∨ n = 1 :=\nby { cases n, { left, refl, },\n  { right, rw nat.succ_le_succ_iff at h, rw nat.le_zero_iff at h, rw h, }, }\n\nnamespace conductor\nlemma mem_conductor_set : conductor χ ∈ conductor_set χ := Inf_mem (set.nonempty_of_mem χ.level_mem_conductor_set)\n\nlemma dvd_lev : χ.conductor ∣ n := (mem_conductor_set χ).1\n\nlemma factors_through : χ.factors_through χ.conductor := mem_conductor_set χ\n\nlemma eq_one (hχ : χ.conductor = 1) : χ = 1 :=\nbegin\n  obtain ⟨h', χ₀, h⟩ := factors_through χ,\n  rw h, ext, rw units.eq_iff, rw change_level_def,\n  simp only [function.comp_app, monoid_hom.one_apply, monoid_hom.coe_comp],\n  convert χ₀.map_one',\n  apply subsingleton.elim _ _,\n  rw hχ,\n  refine fintype.card_le_one_iff_subsingleton.mp _,\n  rw [zmod.card_units_eq_totient _, nat.totient_one], exact succ_pos'' 0,\nend\n\nlemma one (hn : 0 < n) : (1 : dirichlet_character R n).conductor = 1 :=\nbegin\n  suffices : (1 : dirichlet_character R n).conductor ≤ 1,\n  { cases nat.le_one this,\n    { rw h, exfalso,\n      have := factors_through.dvd (factors_through (1 : dirichlet_character R n)),\n      rw [h, zero_dvd_iff] at this, \n      rw this at hn, \n      apply lt_irrefl _ hn, },\n    { exact h, }, },\n  { refine nat.Inf_le ⟨one_dvd _, 1, _⟩,\n    ext, \n    rw [units.eq_iff, change_level_def], \n    simp only [monoid_hom.one_comp], },\nend\n\nvariable {χ}\nlemma eq_one_iff (hn : 0 < n) : χ = 1 ↔ χ.conductor = 1 :=\n⟨λ h, by { rw [h, one hn], }, λ h, by {rw eq_one χ h}⟩\n\nlemma eq_zero_iff_level_eq_zero : χ.conductor = 0 ↔ n = 0 :=\n⟨λ h, by {rw ←zero_dvd_iff, convert dvd_lev χ, rw h, },\n  λ h, by {rw [conductor, nat.Inf_eq_zero], left, refine ⟨zero_dvd_iff.2 h,\n  ⟨change_level (by {rw h}) χ, by { rw [←change_level.dvd _ _ _, change_level.self _], }⟩, ⟩, }⟩\nend conductor\n\n/-- A character is primitive if its level is equal to its conductor. -/\ndef is_primitive : Prop := χ.conductor = n\n\nlemma is_primitive_def : χ.is_primitive ↔ χ.conductor = n := ⟨λ h, h, λ h, h⟩\n\nnamespace is_primitive\nlemma one : is_primitive (1 : dirichlet_character R 1) := nat.dvd_one.1 (conductor.dvd_lev _)\n\nlemma one_lev_zero : (1 : dirichlet_character R 0).is_primitive :=\nbegin\n  rw [is_primitive_def, conductor, nat.Inf_eq_zero],\n  left, rw conductor_set,\n  simp only [set.mem_set_of_eq], fconstructor,\n  simp only [true_and, zmod.cast_id', id.def, monoid_hom.coe_mk, dvd_zero, coe_coe],\n  refine ⟨1, rfl⟩,\nend\nend is_primitive\n\nlemma conductor_one_dvd (n : ℕ) : conductor (1 : dirichlet_character R 1) ∣ n :=\nby { rw (is_primitive_def _).1 is_primitive.one, apply one_dvd _, }\n\n/-- If m = n are positive natural numbers, then zmod m ≃ zmod n. -/\ndef zmod.mul_equiv {a b : ℕ} (h : a = b) : zmod a ≃* zmod b :=\nby { rw h }\n\n/-- If m = n are positive natural numbers, then their Dirichlet character spaces are the same. -/\ndef equiv {a b : ℕ} (h : a = b) : dirichlet_character R a ≃* dirichlet_character R b := by { rw h, }\n\n/-- The primitive character associated to a Dirichlet character. -/\nnoncomputable def asso_primitive_character : dirichlet_character R χ.conductor :=\n  classical.some (conductor.factors_through χ).ind_char\n\nlemma mem_conductor_set_eq_conductor {d : ℕ} (hd : d ∈ χ.conductor_set) :\n  χ.conductor ≤ (classical.some hd.2).conductor :=\nbegin\n  apply nat.Inf_le,\n  rw conductor_set, simp only [set.mem_set_of_eq, monoid_hom.coe_mk],\n  refine ⟨dvd_trans (conductor.dvd_lev _) hd.1, (conductor.factors_through (classical.some hd.2)).2.some, _⟩,\n  convert factors_through.spec χ hd using 1,\n  have : (zmod.cast_hom (dvd_trans (conductor.dvd_lev hd.2.some) hd.1)\n    (zmod (classical.some hd.2).conductor) : monoid_hom (zmod n)\n    (zmod (classical.some hd.2).conductor)) = ((zmod.cast_hom (conductor.dvd_lev hd.2.some)\n    (zmod (classical.some hd.2).conductor)) : monoid_hom (zmod d)\n    (zmod (classical.some hd.2).conductor)).comp (zmod.cast_hom hd.1\n    (zmod d) : monoid_hom (zmod n) (zmod d)),\n  { suffices : (zmod.cast_hom (dvd_trans (conductor.dvd_lev hd.2.some) hd.1)\n    (zmod (classical.some hd.2).conductor)) = ((zmod.cast_hom (conductor.dvd_lev hd.2.some)\n    (zmod (classical.some hd.2).conductor))).comp (zmod.cast_hom hd.1\n    (zmod d)),\n    { rw this, refl, },\n    { convert ring_hom.ext_zmod _ _, }, },\n  rw [change_level_def, this, units.map_comp, ←monoid_hom.comp_assoc],\n  congr,\n  change change_level _ _ = _,\n  convert (factors_through.spec _ _).symm,\nend\n\nlemma asso_primitive_character_is_primitive : (χ.asso_primitive_character).is_primitive :=\nbegin\n  by_cases χ.conductor = 0,\n  { rw is_primitive_def, conv_rhs { rw h, },\n    rw conductor.eq_zero_iff_level_eq_zero, rw h, },\n  refine le_antisymm (nat.le_of_dvd (nat.pos_of_ne_zero h) (conductor.dvd_lev _))\n  (mem_conductor_set_eq_conductor _ (conductor.mem_conductor_set _)),\nend\n\nlemma asso_primitive_character_one (hn : 0 < n) :\n  (1 : dirichlet_character R n).asso_primitive_character = 1 :=\nbegin\n  rw conductor.eq_one_iff _,\n  { convert (1 : dirichlet_character R n).asso_primitive_character_is_primitive,\n    rw conductor.one hn, },\n  { rw conductor.one hn, apply nat.one_pos, },\nend\n\nlemma asso_dirichlet_character_mul (ψ : dirichlet_character R n) :\n  asso_dirichlet_character (χ * ψ) = (asso_dirichlet_character χ) * (asso_dirichlet_character ψ) :=\nbegin\n  ext,\n  simp only [monoid_hom.mul_apply],\n  by_cases is_unit x,\n  { repeat { rw asso_dirichlet_character_eq_char' _ h, },\n    simp only [monoid_hom.mul_apply, units.coe_mul], },\n  { repeat { rw asso_dirichlet_character_eq_zero _ h, }, rw zero_mul, },\nend\n\n-- `mul_eq_asso_pri_char` changed to `asso_primitive_conductor_eq`\nlemma asso_primitive_conductor_eq {n : ℕ} (χ : dirichlet_character R n) :\n  χ.asso_primitive_character.conductor = χ.conductor :=\n(is_primitive_def χ.asso_primitive_character).1 (asso_primitive_character_is_primitive χ)\n\n/-- Similar to multiplication of Dirichlet characters, without needing the characters to be\n  primitive. -/\nnoncomputable def mul {m : ℕ} (χ₁ : dirichlet_character R n) (χ₂ : dirichlet_character R m) :=\nasso_primitive_character (change_level (dvd_lcm_left n m) χ₁ * change_level (dvd_lcm_right n m) χ₂)\n\nlemma mul_def {n m : ℕ} {χ : dirichlet_character R n} {ψ : dirichlet_character R m} :\n  χ.mul ψ = (change_level _ χ * change_level _ ψ).asso_primitive_character := rfl\n\nnamespace is_primitive\nlemma mul {m : ℕ} (ψ : dirichlet_character R m) : (mul χ ψ).is_primitive :=\nasso_primitive_character_is_primitive _\nend is_primitive\n\n/-- Composition of a Dirichlet character with a multiplicative homomorphism of units. -/\n--abbreviation comp {S : Type*} [comm_monoid_with_zero S] (f : units R →* units S) : dirichlet_character S n := f.comp χ\n\nvariables {S : Type*} [comm_ring S] {m : ℕ} (ψ : dirichlet_character S m)\n\n/-- A Dirichlet character is odd if its value at -1 is -1. -/\ndef is_odd : Prop := ψ (-1) = -1\n\n/-- A Dirichlet character is even if its value at -1 is 1. -/\ndef is_even : Prop := ψ (-1) = 1\n\nlemma is_odd_or_is_even [no_zero_divisors S] : ψ.is_odd ∨ ψ.is_even :=\nbegin\n  suffices : (ψ (-1))^2 = 1,\n  { rw ←units.eq_iff at this,\n    conv_rhs at this { rw ←one_pow 2 },\n    rw ←sub_eq_zero at this,\n    simp only [units.coe_one, units.coe_pow] at this,\n    rw [sq_sub_sq, mul_eq_zero, sub_eq_zero, add_eq_zero_iff_eq_neg] at this,\n    cases this,\n    { left, rw [is_odd, ←units.eq_iff], simp only [this, units.coe_neg_one], },\n    { right, rw [is_even, ←units.eq_iff], simp only [this, units.coe_one], }, },\n  { rw [←monoid_hom.map_pow, ←monoid_hom.map_one ψ],\n    congr, rw units.ext_iff,\n    simp only [units.coe_one, units.coe_neg_one, units.coe_pow], rw neg_one_sq, },\nend\n-- can conditions on S be relaxed? comm needed for sq_sub_sq, and no_divisors needed for mul_eq_zero\n\nlemma asso_odd_dirichlet_character_eval_neg_one (hψ : ψ.is_odd) :\n  asso_dirichlet_character ψ (-1) = -1 :=\nbegin\n  rw is_odd at hψ,\n  convert asso_dirichlet_character_eq_char _ (-1),\n  rw hψ, simp,\nend\n\nlemma asso_even_dirichlet_character_eval_neg_one (hψ : ψ.is_even) :\n  asso_dirichlet_character ψ (-1) = 1 :=\nbegin\n  rw is_even at hψ,\n  convert asso_dirichlet_character_eq_char _ (-1),\n  rw hψ, simp,\nend\n\nlemma asso_odd_dirichlet_character_eval_sub (x : zmod m) (hψ : ψ.is_odd) :\n  asso_dirichlet_character ψ (m - x) = -(asso_dirichlet_character ψ x) :=\nbegin\n  rw [asso_dirichlet_character_eval_sub, ←neg_one_mul, monoid_hom.map_mul,\n    asso_odd_dirichlet_character_eval_neg_one _ hψ],\n  simp,\nend\n\nlemma asso_even_dirichlet_character_eval_sub (x : zmod m) (hψ : ψ.is_even) :\n  asso_dirichlet_character ψ (m - x) = asso_dirichlet_character ψ x :=\nbegin\n  rw [asso_dirichlet_character_eval_sub, ←neg_one_mul, monoid_hom.map_mul,\n    asso_even_dirichlet_character_eval_neg_one _ hψ],\n  simp,\nend\n\nend dirichlet_character", "meta": {"author": "laughinggas", "repo": "p-adic-L-functions", "sha": "bfc0c84fabe9b89e3da79f95d7a8eacabe8a5bb7", "save_path": "github-repos/lean/laughinggas-p-adic-L-functions", "path": "github-repos/lean/laughinggas-p-adic-L-functions/p-adic-L-functions-bfc0c84fabe9b89e3da79f95d7a8eacabe8a5bb7/src/dirichlet_character/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6757645879592641, "lm_q1q2_score": 0.4856006436054822}}
{"text": "/-\nThis example demonstrates why allowing types such as\n\ninductive D : Type :=\n| intro : (D → D) → D\n\nwould make the system inconsistent\n-/\n\n/- If we were allowed to form the inductive type\n\n     inductive D : Type :=\n     | intro : (D → D) → D\n\n   we would get the following\n-/\nuniverse l\n-- The new type A\naxiom D : Type.{l}\n-- The constructor\naxiom introD : (D → D) → D\n-- The eliminator\naxiom recD   : Π {C : D → Type}, (Π (f : D → D) (r : Π d, C (f d)), C (introD f)) → (Π (d : D), C d)\n-- We would also get a computational rule for the eliminator, but we don't need it for deriving the inconsistency.\n\nnoncomputable definition id' : D → D := λd, d\nnoncomputable definition v  : D     := introD id'\n\ntheorem inconsistent : false :=\nrecD (λ f ih, ih v) v\n", "meta": {"author": "Bolt64", "repo": "lean2-aur", "sha": "1d7148e58a17b2d326b032ed1ebf8c5217320242", "save_path": "github-repos/lean/Bolt64-lean2-aur", "path": "github-repos/lean/Bolt64-lean2-aur/lean2-aur-1d7148e58a17b2d326b032ed1ebf8c5217320242/library/logic/examples/negative.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8244619436290698, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4855166773348802}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.witt_vector.is_poly\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n## Multiplication by `n` in the ring of Witt vectors\n\nIn this file we show that multiplication by `n` in the ring of Witt vectors\nis a polynomial function. We then use this fact to show that the composition of Frobenius\nand Verschiebung is equal to multiplication by `p`.\n\n### Main declarations\n\n* `mul_n_is_poly`: multiplication by `n` is a polynomial function\n\n-/\n\nnamespace witt_vector\n\n\n/-- `witt_mul_n p n` is the family of polynomials that computes\nthe coefficients of `x * n` in terms of the coefficients of the Witt vector `x`. -/\ndef witt_mul_n (p : ℕ) [hp : fact (nat.prime p)] : ℕ → ℕ → mv_polynomial ℕ ℤ :=\n  sorry\n\ntheorem mul_n_coeff {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (n : ℕ) (x : witt_vector p R) (k : ℕ) : coeff (x * ↑n) k = coe_fn (mv_polynomial.aeval (coeff x)) (witt_mul_n p n k) := sorry\n\n/-- Multiplication by `n` is a polynomial function. -/\ntheorem mul_n_is_poly (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) (x : witt_vector p R) => x * ↑n :=\n  Exists.intro (witt_mul_n p n)\n    fun (R : Type u_1) (_Rcr : comm_ring R) (x : witt_vector p R) => funext fun (k : ℕ) => mul_n_coeff n x k\n\n@[simp] theorem bind₁_witt_mul_n_witt_polynomial (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (k : ℕ) : coe_fn (mv_polynomial.bind₁ (witt_mul_n p n)) (witt_polynomial p ℤ k) = ↑n * witt_polynomial p ℤ k := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/mul_p.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799928951399098, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.48551385585098655}}
{"text": "/-\nCopyright (c) 2015 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Robert Y. Lewis\n\n! This file was ported from Lean 3 source module algebra.group_power.order\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.Ring.Abs\nimport Mathbin.Algebra.Order.WithZero\nimport Mathbin.Algebra.GroupPower.Ring\nimport Mathbin.Data.Set.Intervals.Basic\n\n/-!\n# Lemmas about the interaction of power operations with order\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nNote that some lemmas are in `algebra/group_power/lemmas.lean` as they import files which\ndepend on this file.\n-/\n\n\nopen Function\n\nvariable {β A G M R : Type _}\n\nsection Monoid\n\nvariable [Monoid M]\n\nsection Preorder\n\nvariable [Preorder M]\n\nsection Left\n\nvariable [CovariantClass M M (· * ·) (· ≤ ·)] {x : M}\n\n/- warning: pow_le_pow_of_le_left' -> pow_le_pow_of_le_left' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {a : M} {b : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) a b) -> (forall (i : Nat), LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a i) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) b i))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.109 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.111 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.109 x._@.Mathlib.Algebra.GroupPower.Order._hyg.111) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.124 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.126 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.124 x._@.Mathlib.Algebra.GroupPower.Order._hyg.126)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.147 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.149 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.147 x._@.Mathlib.Algebra.GroupPower.Order._hyg.149)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.162 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.164 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.162 x._@.Mathlib.Algebra.GroupPower.Order._hyg.164)] {a : M} {b : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) a b) -> (forall (i : Nat), LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a i) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) b i))\nCase conversion may be inaccurate. Consider using '#align pow_le_pow_of_le_left' pow_le_pow_of_le_left'ₓ'. -/\n@[to_additive nsmul_le_nsmul_of_le_right, mono]\ntheorem pow_le_pow_of_le_left' [CovariantClass M M (swap (· * ·)) (· ≤ ·)] {a b : M} (hab : a ≤ b) :\n    ∀ i : ℕ, a ^ i ≤ b ^ i\n  | 0 => by simp\n  | k + 1 => by\n    rw [pow_succ, pow_succ]\n    exact mul_le_mul' hab (pow_le_pow_of_le_left' k)\n#align pow_le_pow_of_le_left' pow_le_pow_of_le_left'\n#align nsmul_le_nsmul_of_le_right nsmul_le_nsmul_of_le_right\n\nattribute [mono] nsmul_le_nsmul_of_le_right\n\n/- warning: one_le_pow_of_one_le' -> one_le_pow_of_one_le' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {a : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) a) -> (forall (n : Nat), LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.290 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.292 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.290 x._@.Mathlib.Algebra.GroupPower.Order._hyg.292) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.305 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.307 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.305 x._@.Mathlib.Algebra.GroupPower.Order._hyg.307)] {a : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) a) -> (forall (n : Nat), LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n))\nCase conversion may be inaccurate. Consider using '#align one_le_pow_of_one_le' one_le_pow_of_one_le'ₓ'. -/\n@[to_additive nsmul_nonneg]\ntheorem one_le_pow_of_one_le' {a : M} (H : 1 ≤ a) : ∀ n : ℕ, 1 ≤ a ^ n\n  | 0 => by simp\n  | k + 1 => by\n    rw [pow_succ]\n    exact one_le_mul H (one_le_pow_of_one_le' k)\n#align one_le_pow_of_one_le' one_le_pow_of_one_le'\n#align nsmul_nonneg nsmul_nonneg\n\n/- warning: pow_le_one' -> pow_le_one' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {a : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) a (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) -> (forall (n : Nat), LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.430 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.432 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.430 x._@.Mathlib.Algebra.GroupPower.Order._hyg.432) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.445 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.447 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.445 x._@.Mathlib.Algebra.GroupPower.Order._hyg.447)] {a : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) a (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) -> (forall (n : Nat), LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align pow_le_one' pow_le_one'ₓ'. -/\n@[to_additive nsmul_nonpos]\ntheorem pow_le_one' {a : M} (H : a ≤ 1) (n : ℕ) : a ^ n ≤ 1 :=\n  @one_le_pow_of_one_le' Mᵒᵈ _ _ _ _ H n\n#align pow_le_one' pow_le_one'\n#align nsmul_nonpos nsmul_nonpos\n\n/- warning: pow_le_pow' -> pow_le_pow' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {a : M} {n : Nat} {m : Nat}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) a) -> (LE.le.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.503 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.505 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.503 x._@.Mathlib.Algebra.GroupPower.Order._hyg.505) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.518 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.520 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.518 x._@.Mathlib.Algebra.GroupPower.Order._hyg.520)] {a : M} {n : Nat} {m : Nat}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) a) -> (LE.le.{0} Nat instLENat n m) -> (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m))\nCase conversion may be inaccurate. Consider using '#align pow_le_pow' pow_le_pow'ₓ'. -/\n@[to_additive nsmul_le_nsmul]\ntheorem pow_le_pow' {a : M} {n m : ℕ} (ha : 1 ≤ a) (h : n ≤ m) : a ^ n ≤ a ^ m :=\n  let ⟨k, hk⟩ := Nat.le.dest h\n  calc\n    a ^ n ≤ a ^ n * a ^ k := le_mul_of_one_le_right' (one_le_pow_of_one_le' ha _)\n    _ = a ^ m := by rw [← hk, pow_add]\n    \n#align pow_le_pow' pow_le_pow'\n#align nsmul_le_nsmul nsmul_le_nsmul\n\n/- warning: pow_le_pow_of_le_one' -> pow_le_pow_of_le_one' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {a : M} {n : Nat} {m : Nat}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) a (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) -> (LE.le.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.666 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.668 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.666 x._@.Mathlib.Algebra.GroupPower.Order._hyg.668) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.681 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.683 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.681 x._@.Mathlib.Algebra.GroupPower.Order._hyg.683)] {a : M} {n : Nat} {m : Nat}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) a (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) -> (LE.le.{0} Nat instLENat n m) -> (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n))\nCase conversion may be inaccurate. Consider using '#align pow_le_pow_of_le_one' pow_le_pow_of_le_one'ₓ'. -/\n@[to_additive nsmul_le_nsmul_of_nonpos]\ntheorem pow_le_pow_of_le_one' {a : M} {n m : ℕ} (ha : a ≤ 1) (h : n ≤ m) : a ^ m ≤ a ^ n :=\n  @pow_le_pow' Mᵒᵈ _ _ _ _ _ _ ha h\n#align pow_le_pow_of_le_one' pow_le_pow_of_le_one'\n#align nsmul_le_nsmul_of_nonpos nsmul_le_nsmul_of_nonpos\n\n/- warning: one_lt_pow' -> one_lt_pow' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {a : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) a) -> (forall {k : Nat}, (Ne.{1} Nat k (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a k)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.751 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.753 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.751 x._@.Mathlib.Algebra.GroupPower.Order._hyg.753) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.766 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.768 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.766 x._@.Mathlib.Algebra.GroupPower.Order._hyg.768)] {a : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) a) -> (forall {k : Nat}, (Ne.{1} Nat k (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a k)))\nCase conversion may be inaccurate. Consider using '#align one_lt_pow' one_lt_pow'ₓ'. -/\n@[to_additive nsmul_pos]\ntheorem one_lt_pow' {a : M} (ha : 1 < a) {k : ℕ} (hk : k ≠ 0) : 1 < a ^ k :=\n  by\n  rcases Nat.exists_eq_succ_of_ne_zero hk with ⟨l, rfl⟩\n  clear hk\n  induction' l with l IH\n  · simpa using ha\n  · rw [pow_succ]\n    exact one_lt_mul'' ha IH\n#align one_lt_pow' one_lt_pow'\n#align nsmul_pos nsmul_pos\n\n/- warning: pow_lt_one' -> pow_lt_one' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {a : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) a (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) -> (forall {k : Nat}, (Ne.{1} Nat k (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a k) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.902 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.904 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.902 x._@.Mathlib.Algebra.GroupPower.Order._hyg.904) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.917 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.919 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.917 x._@.Mathlib.Algebra.GroupPower.Order._hyg.919)] {a : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) a (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) -> (forall {k : Nat}, (Ne.{1} Nat k (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a k) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align pow_lt_one' pow_lt_one'ₓ'. -/\n@[to_additive nsmul_neg]\ntheorem pow_lt_one' {a : M} (ha : a < 1) {k : ℕ} (hk : k ≠ 0) : a ^ k < 1 :=\n  @one_lt_pow' Mᵒᵈ _ _ _ _ ha k hk\n#align pow_lt_one' pow_lt_one'\n#align nsmul_neg nsmul_neg\n\n/- warning: pow_lt_pow' -> pow_lt_pow' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2))] {a : M} {n : Nat} {m : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) a) -> (LT.lt.{0} Nat Nat.hasLt n m) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.981 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.983 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.981 x._@.Mathlib.Algebra.GroupPower.Order._hyg.983) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.996 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.998 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.996 x._@.Mathlib.Algebra.GroupPower.Order._hyg.998)] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1016 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1018 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1016 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1018) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1031 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1033 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1031 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1033)] {a : M} {n : Nat} {m : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) a) -> (LT.lt.{0} Nat instLTNat n m) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m))\nCase conversion may be inaccurate. Consider using '#align pow_lt_pow' pow_lt_pow'ₓ'. -/\n@[to_additive nsmul_lt_nsmul]\ntheorem pow_lt_pow' [CovariantClass M M (· * ·) (· < ·)] {a : M} {n m : ℕ} (ha : 1 < a)\n    (h : n < m) : a ^ n < a ^ m :=\n  by\n  rcases Nat.le.dest h with ⟨k, rfl⟩; clear h\n  rw [pow_add, pow_succ', mul_assoc, ← pow_succ]\n  exact lt_mul_of_one_lt_right' _ (one_lt_pow' ha k.succ_ne_zero)\n#align pow_lt_pow' pow_lt_pow'\n#align nsmul_lt_nsmul nsmul_lt_nsmul\n\n/- warning: pow_strict_mono_left -> pow_strictMono_left is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2))] {a : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) a) -> (StrictMono.{0, u1} Nat M (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) _inst_2 (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1139 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1141 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1139 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1141) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1154 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1156 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1154 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1156)] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1174 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1176 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1174 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1176) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1189 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1191 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1189 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1191)] {a : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) a) -> (StrictMono.{0, u1} Nat M (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) _inst_2 ((fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1219 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1221 : Nat) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1219 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1221) a))\nCase conversion may be inaccurate. Consider using '#align pow_strict_mono_left pow_strictMono_leftₓ'. -/\n@[to_additive nsmul_strictMono_right]\ntheorem pow_strictMono_left [CovariantClass M M (· * ·) (· < ·)] {a : M} (ha : 1 < a) :\n    StrictMono ((· ^ ·) a : ℕ → M) := fun m n => pow_lt_pow' ha\n#align pow_strict_mono_left pow_strictMono_left\n#align nsmul_strict_mono_right nsmul_strictMono_right\n\n/- warning: left.one_le_pow_of_le -> Left.one_le_pow_of_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) x) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1264 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1266 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1264 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1266) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1279 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1281 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1279 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1281)] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) x) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n))\nCase conversion may be inaccurate. Consider using '#align left.one_le_pow_of_le Left.one_le_pow_of_leₓ'. -/\n@[to_additive Left.pow_nonneg]\ntheorem Left.one_le_pow_of_le (hx : 1 ≤ x) : ∀ {n : ℕ}, 1 ≤ x ^ n\n  | 0 => (pow_zero x).ge\n  | n + 1 => by\n    rw [pow_succ]\n    exact Left.one_le_mul hx Left.one_le_pow_of_le\n#align left.one_le_pow_of_le Left.one_le_pow_of_le\n#align left.pow_nonneg Left.pow_nonneg\n\n/- warning: left.pow_le_one_of_le -> Left.pow_le_one_of_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1405 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1407 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1405 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1407) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1420 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1422 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1420 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1422)] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align left.pow_le_one_of_le Left.pow_le_one_of_leₓ'. -/\n@[to_additive Left.pow_nonpos]\ntheorem Left.pow_le_one_of_le (hx : x ≤ 1) : ∀ {n : ℕ}, x ^ n ≤ 1\n  | 0 => (pow_zero _).le\n  | n + 1 => by\n    rw [pow_succ]\n    exact Left.mul_le_one hx Left.pow_le_one_of_le\n#align left.pow_le_one_of_le Left.pow_le_one_of_le\n#align left.pow_nonpos Left.pow_nonpos\n\nend Left\n\nsection Right\n\nvariable [CovariantClass M M (swap (· * ·)) (· ≤ ·)] {x : M}\n\n/- warning: right.one_le_pow_of_le -> Right.one_le_pow_of_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) x) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1603 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1605 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1603 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1605)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1618 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1620 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1618 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1620)] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) x) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n))\nCase conversion may be inaccurate. Consider using '#align right.one_le_pow_of_le Right.one_le_pow_of_leₓ'. -/\n@[to_additive Right.pow_nonneg]\ntheorem Right.one_le_pow_of_le (hx : 1 ≤ x) : ∀ {n : ℕ}, 1 ≤ x ^ n\n  | 0 => (pow_zero _).ge\n  | n + 1 => by\n    rw [pow_succ]\n    exact Right.one_le_mul hx Right.one_le_pow_of_le\n#align right.one_le_pow_of_le Right.one_le_pow_of_le\n#align right.pow_nonneg Right.pow_nonneg\n\n/- warning: right.pow_le_one_of_le -> Right.pow_le_one_of_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1747 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1749 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1747 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1749)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1762 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1764 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1762 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1764)] {x : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) -> (forall {n : Nat}, LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align right.pow_le_one_of_le Right.pow_le_one_of_leₓ'. -/\n@[to_additive Right.pow_nonpos]\ntheorem Right.pow_le_one_of_le (hx : x ≤ 1) : ∀ {n : ℕ}, x ^ n ≤ 1\n  | 0 => (pow_zero _).le\n  | n + 1 => by\n    rw [pow_succ]\n    exact Right.mul_le_one hx Right.pow_le_one_of_le\n#align right.pow_le_one_of_le Right.pow_le_one_of_le\n#align right.pow_nonpos Right.pow_nonpos\n\nend Right\n\nsection CovariantLtSwap\n\nvariable [Preorder β] [CovariantClass M M (· * ·) (· < ·)]\n  [CovariantClass M M (swap (· * ·)) (· < ·)] {f : β → M}\n\n/- warning: strict_mono.pow_right' -> StrictMono.pow_right' is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_2 : Preorder.{u2} M] [_inst_3 : Preorder.{u1} β] [_inst_4 : CovariantClass.{u2, u2} M M (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))) (LT.lt.{u2} M (Preorder.toLT.{u2} M _inst_2))] [_inst_5 : CovariantClass.{u2, u2} M M (Function.swap.{succ u2, succ u2, succ u2} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (LT.lt.{u2} M (Preorder.toLT.{u2} M _inst_2))] {f : β -> M}, (StrictMono.{u1, u2} β M _inst_3 _inst_2 f) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (StrictMono.{u1, u2} β M _inst_3 _inst_2 (fun (a : β) => HPow.hPow.{u2, 0, u2} M Nat M (instHPow.{u2, 0} M Nat (Monoid.Pow.{u2} M _inst_1)) (f a) n)))\nbut is expected to have type\n  forall {β : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : Preorder.{u2} β] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1986 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.1988 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.1986 x._@.Mathlib.Algebra.GroupPower.Order._hyg.1988) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2001 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2003 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2001 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2003)] [_inst_5 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2023 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2025 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2023 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2025)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2038 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2040 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2038 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2040)] {f : β -> M}, (StrictMono.{u2, u1} β M _inst_3 _inst_2 f) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (StrictMono.{u2, u1} β M _inst_3 _inst_2 (fun (a : β) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) (f a) n)))\nCase conversion may be inaccurate. Consider using '#align strict_mono.pow_right' StrictMono.pow_right'ₓ'. -/\n@[to_additive StrictMono.nsmul_left]\ntheorem StrictMono.pow_right' (hf : StrictMono f) : ∀ {n : ℕ}, n ≠ 0 → StrictMono fun a => f a ^ n\n  | 0, hn => (hn rfl).elim\n  | 1, hn => by simpa\n  | Nat.succ <| Nat.succ n, hn => by\n    simp_rw [pow_succ _ (n + 1)]\n    exact hf.mul' (StrictMono.pow_right' n.succ_ne_zero)\n#align strict_mono.pow_right' StrictMono.pow_right'\n#align strict_mono.nsmul_left StrictMono.nsmul_left\n\n/- warning: pow_strict_mono_right' -> pow_strictMono_right' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2))] [_inst_5 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2))] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (StrictMono.{u1, u1} M M _inst_2 _inst_2 (fun (a : M) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2189 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2191 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2189 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2191) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2204 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2206 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2204 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2206)] [_inst_5 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2226 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2228 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2226 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2228)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2241 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2243 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2241 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2243)] {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (StrictMono.{u1, u1} M M _inst_2 _inst_2 (fun (a : M) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n))\nCase conversion may be inaccurate. Consider using '#align pow_strict_mono_right' pow_strictMono_right'ₓ'. -/\n/-- See also `pow_strict_mono_right` -/\n@[nolint to_additive_doc, to_additive nsmul_strictMono_left]\ntheorem pow_strictMono_right' {n : ℕ} (hn : n ≠ 0) : StrictMono fun a : M => a ^ n :=\n  strictMono_id.pow_right' hn\n#align pow_strict_mono_right' pow_strictMono_right'\n#align nsmul_strict_mono_left nsmul_strictMono_left\n\nend CovariantLtSwap\n\nsection CovariantLeSwap\n\nvariable [Preorder β] [CovariantClass M M (· * ·) (· ≤ ·)]\n  [CovariantClass M M (swap (· * ·)) (· ≤ ·)]\n\n/- warning: monotone.pow_right -> Monotone.pow_right is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_2 : Preorder.{u2} M] [_inst_3 : Preorder.{u1} β] [_inst_4 : CovariantClass.{u2, u2} M M (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))) (LE.le.{u2} M (Preorder.toLE.{u2} M _inst_2))] [_inst_5 : CovariantClass.{u2, u2} M M (Function.swap.{succ u2, succ u2, succ u2} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (LE.le.{u2} M (Preorder.toLE.{u2} M _inst_2))] {f : β -> M}, (Monotone.{u1, u2} β M _inst_3 _inst_2 f) -> (forall (n : Nat), Monotone.{u1, u2} β M _inst_3 _inst_2 (fun (a : β) => HPow.hPow.{u2, 0, u2} M Nat M (instHPow.{u2, 0} M Nat (Monoid.Pow.{u2} M _inst_1)) (f a) n))\nbut is expected to have type\n  forall {β : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : Preorder.{u2} β] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2395 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2397 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2395 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2397) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2410 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2412 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2410 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2412)] [_inst_5 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2432 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2434 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2432 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2434)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2447 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2449 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2447 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2449)] {f : β -> M}, (Monotone.{u2, u1} β M _inst_3 _inst_2 f) -> (forall (n : Nat), Monotone.{u2, u1} β M _inst_3 _inst_2 (fun (a : β) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) (f a) n))\nCase conversion may be inaccurate. Consider using '#align monotone.pow_right Monotone.pow_rightₓ'. -/\n@[to_additive Monotone.nsmul_left]\ntheorem Monotone.pow_right {f : β → M} (hf : Monotone f) : ∀ n : ℕ, Monotone fun a => f a ^ n\n  | 0 => by simpa using monotone_const\n  | n + 1 => by\n    simp_rw [pow_succ]\n    exact hf.mul' (Monotone.pow_right _)\n#align monotone.pow_right Monotone.pow_right\n#align monotone.nsmul_left Monotone.nsmul_left\n\n/- warning: pow_mono_right -> pow_mono_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] [_inst_5 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2))] (n : Nat), Monotone.{u1, u1} M M _inst_2 _inst_2 (fun (a : M) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2556 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2558 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2556 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2558) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2571 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2573 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2571 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2573)] [_inst_5 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2593 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2595 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2593 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2595)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2608 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2610 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2608 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2610)] (n : Nat), Monotone.{u1, u1} M M _inst_2 _inst_2 (fun (a : M) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n)\nCase conversion may be inaccurate. Consider using '#align pow_mono_right pow_mono_rightₓ'. -/\n@[to_additive nsmul_mono_left]\ntheorem pow_mono_right (n : ℕ) : Monotone fun a : M => a ^ n :=\n  monotone_id.pow_right _\n#align pow_mono_right pow_mono_right\n#align nsmul_mono_left nsmul_mono_left\n\nend CovariantLeSwap\n\n/- warning: left.pow_lt_one_of_lt -> Left.pow_lt_one_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2))] {n : Nat} {x : M}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2661 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2663 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2661 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2663) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2676 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2678 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2676 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2678)] {n : Nat} {x : M}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align left.pow_lt_one_of_lt Left.pow_lt_one_of_ltₓ'. -/\n@[to_additive Left.pow_neg]\ntheorem Left.pow_lt_one_of_lt [CovariantClass M M (· * ·) (· < ·)] {n : ℕ} {x : M} (hn : 0 < n)\n    (h : x < 1) : x ^ n < 1 :=\n  Nat.le_induction ((pow_one _).trans_lt h)\n    (fun n _ ih => by\n      rw [pow_succ]\n      exact mul_lt_one h ih)\n    _ (Nat.succ_le_iff.2 hn)\n#align left.pow_lt_one_of_lt Left.pow_lt_one_of_lt\n#align left.pow_neg Left.pow_neg\n\n/- warning: right.pow_lt_one_of_lt -> Right.pow_lt_one_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2))] {n : Nat} {x : M}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2797 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2799 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2797 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2799)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2812 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2814 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2812 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2814)] {n : Nat} {x : M}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M _inst_2) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align right.pow_lt_one_of_lt Right.pow_lt_one_of_ltₓ'. -/\n@[to_additive Right.pow_neg]\ntheorem Right.pow_lt_one_of_lt [CovariantClass M M (swap (· * ·)) (· < ·)] {n : ℕ} {x : M}\n    (hn : 0 < n) (h : x < 1) : x ^ n < 1 :=\n  Nat.le_induction ((pow_one _).trans_lt h)\n    (fun n _ ih => by\n      rw [pow_succ]\n      exact Right.mul_lt_one h ih)\n    _ (Nat.succ_le_iff.2 hn)\n#align right.pow_lt_one_of_lt Right.pow_lt_one_of_lt\n#align right.pow_neg Right.pow_neg\n\nend Preorder\n\nsection LinearOrder\n\nvariable [LinearOrder M]\n\nsection CovariantLe\n\nvariable [CovariantClass M M (· * ·) (· ≤ ·)]\n\n/- warning: one_le_pow_iff -> one_le_pow_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n)) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) x))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2990 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.2992 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.2990 x._@.Mathlib.Algebra.GroupPower.Order._hyg.2992) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3005 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3007 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3005 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3007)] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n)) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) x))\nCase conversion may be inaccurate. Consider using '#align one_le_pow_iff one_le_pow_iffₓ'. -/\n@[to_additive nsmul_nonneg_iff]\ntheorem one_le_pow_iff {x : M} {n : ℕ} (hn : n ≠ 0) : 1 ≤ x ^ n ↔ 1 ≤ x :=\n  ⟨le_imp_le_of_lt_imp_lt fun h => pow_lt_one' h hn, fun h => one_le_pow_of_one_le' h n⟩\n#align one_le_pow_iff one_le_pow_iff\n#align nsmul_nonneg_iff nsmul_nonneg_iff\n\n/- warning: pow_le_one_iff -> pow_le_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3077 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3079 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3077 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3079) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3092 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3094 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3092 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3094)] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align pow_le_one_iff pow_le_one_iffₓ'. -/\n@[to_additive]\ntheorem pow_le_one_iff {x : M} {n : ℕ} (hn : n ≠ 0) : x ^ n ≤ 1 ↔ x ≤ 1 :=\n  @one_le_pow_iff Mᵒᵈ _ _ _ _ _ hn\n#align pow_le_one_iff pow_le_one_iff\n#align nsmul_nonpos_iff nsmul_nonpos_iff\n\n/- warning: one_lt_pow_iff -> one_lt_pow_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n)) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) x))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3157 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3159 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3157 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3159) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3172 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3174 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3172 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3174)] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n)) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) x))\nCase conversion may be inaccurate. Consider using '#align one_lt_pow_iff one_lt_pow_iffₓ'. -/\n@[to_additive nsmul_pos_iff]\ntheorem one_lt_pow_iff {x : M} {n : ℕ} (hn : n ≠ 0) : 1 < x ^ n ↔ 1 < x :=\n  lt_iff_lt_of_le_iff_le (pow_le_one_iff hn)\n#align one_lt_pow_iff one_lt_pow_iff\n#align nsmul_pos_iff nsmul_pos_iff\n\n/- warning: pow_lt_one_iff -> pow_lt_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3234 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3236 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3234 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3236) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3249 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3251 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3249 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3251)] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align pow_lt_one_iff pow_lt_one_iffₓ'. -/\n@[to_additive]\ntheorem pow_lt_one_iff {x : M} {n : ℕ} (hn : n ≠ 0) : x ^ n < 1 ↔ x < 1 :=\n  lt_iff_lt_of_le_iff_le (one_le_pow_iff hn)\n#align pow_lt_one_iff pow_lt_one_iff\n#align nsmul_neg_iff nsmul_neg_iff\n\n/- warning: pow_eq_one_iff -> pow_eq_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3311 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3313 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3311 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3313) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3326 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3328 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3326 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3328)] {x : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align pow_eq_one_iff pow_eq_one_iffₓ'. -/\n@[to_additive]\ntheorem pow_eq_one_iff {x : M} {n : ℕ} (hn : n ≠ 0) : x ^ n = 1 ↔ x = 1 := by\n  simp only [le_antisymm_iff, pow_le_one_iff hn, one_le_pow_iff hn]\n#align pow_eq_one_iff pow_eq_one_iff\n#align nsmul_eq_zero_iff nsmul_eq_zero_iff\n\nvariable [CovariantClass M M (· * ·) (· < ·)] {a : M} {m n : ℕ}\n\n/- warning: pow_le_pow_iff' -> pow_le_pow_iff' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {m : Nat} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) a) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n)) (LE.le.{0} Nat Nat.hasLe m n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3506 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3508 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3506 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3508) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3521 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3523 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3521 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3523)] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3540 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3542 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3540 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3542) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3555 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3557 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3555 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3557)] {a : M} {m : Nat} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) a) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n)) (LE.le.{0} Nat instLENat m n))\nCase conversion may be inaccurate. Consider using '#align pow_le_pow_iff' pow_le_pow_iff'ₓ'. -/\n@[to_additive nsmul_le_nsmul_iff]\ntheorem pow_le_pow_iff' (ha : 1 < a) : a ^ m ≤ a ^ n ↔ m ≤ n :=\n  (pow_strictMono_left ha).le_iff_le\n#align pow_le_pow_iff' pow_le_pow_iff'\n#align nsmul_le_nsmul_iff nsmul_le_nsmul_iff\n\n/- warning: pow_lt_pow_iff' -> pow_lt_pow_iff' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {m : Nat} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) a) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n)) (LT.lt.{0} Nat Nat.hasLt m n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3622 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3624 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3622 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3624) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3637 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3639 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3637 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3639)] [_inst_4 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3656 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3658 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3656 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3658) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3671 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3673 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3671 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3673)] {a : M} {m : Nat} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1))) a) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n)) (LT.lt.{0} Nat instLTNat m n))\nCase conversion may be inaccurate. Consider using '#align pow_lt_pow_iff' pow_lt_pow_iff'ₓ'. -/\n@[to_additive nsmul_lt_nsmul_iff]\ntheorem pow_lt_pow_iff' (ha : 1 < a) : a ^ m < a ^ n ↔ m < n :=\n  (pow_strictMono_left ha).lt_iff_lt\n#align pow_lt_pow_iff' pow_lt_pow_iff'\n#align nsmul_lt_nsmul_iff nsmul_lt_nsmul_iff\n\nend CovariantLe\n\nsection CovariantLeSwap\n\nvariable [CovariantClass M M (· * ·) (· ≤ ·)] [CovariantClass M M (swap (· * ·)) (· ≤ ·)]\n\n/- warning: lt_of_pow_lt_pow' -> lt_of_pow_lt_pow' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {b : M} (n : Nat), (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) b n)) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) a b)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3825 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3827 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3825 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3827) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3840 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3842 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3840 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3842)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3862 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3864 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3862 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3864)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3877 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3879 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3877 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3879)] {a : M} {b : M} (n : Nat), (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) b n)) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) a b)\nCase conversion may be inaccurate. Consider using '#align lt_of_pow_lt_pow' lt_of_pow_lt_pow'ₓ'. -/\n@[to_additive lt_of_nsmul_lt_nsmul]\ntheorem lt_of_pow_lt_pow' {a b : M} (n : ℕ) : a ^ n < b ^ n → a < b :=\n  (pow_mono_right _).reflect_lt\n#align lt_of_pow_lt_pow' lt_of_pow_lt_pow'\n#align lt_of_nsmul_lt_nsmul lt_of_nsmul_lt_nsmul\n\n/- warning: min_lt_max_of_mul_lt_mul -> min_lt_max_of_mul_lt_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {b : M} {c : M} {d : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) a b) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) c d)) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (LinearOrder.min.{u1} M _inst_2 a b) (LinearOrder.max.{u1} M _inst_2 c d))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3935 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3937 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3935 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3937) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3950 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3952 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3950 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3952)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3972 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3974 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3972 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3974)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3987 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.3989 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.3987 x._@.Mathlib.Algebra.GroupPower.Order._hyg.3989)] {a : M} {b : M} {c : M} {d : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) a b) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) c d)) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (Min.min.{u1} M (LinearOrder.toMin.{u1} M _inst_2) a b) (Max.max.{u1} M (LinearOrder.toMax.{u1} M _inst_2) c d))\nCase conversion may be inaccurate. Consider using '#align min_lt_max_of_mul_lt_mul min_lt_max_of_mul_lt_mulₓ'. -/\n@[to_additive]\ntheorem min_lt_max_of_mul_lt_mul {a b c d : M} (h : a * b < c * d) : min a b < max c d :=\n  lt_of_pow_lt_pow' 2 <| by\n    simp_rw [pow_two]\n    exact\n      (mul_le_mul' inf_le_left inf_le_right).trans_lt\n        (h.trans_le <| mul_le_mul' le_sup_left le_sup_right)\n#align min_lt_max_of_mul_lt_mul min_lt_max_of_mul_lt_mul\n#align min_lt_max_of_add_lt_add min_lt_max_of_add_lt_add\n\n/- warning: min_lt_of_mul_lt_sq -> min_lt_of_mul_lt_sq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {b : M} {c : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) a b) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) c (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (LinearOrder.min.{u1} M _inst_2 a b) c)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4069 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4071 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4069 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4071) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4084 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4086 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4084 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4086)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4106 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4108 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4106 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4108)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4121 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4123 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4121 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4123)] {a : M} {b : M} {c : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) a b) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) c (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (Min.min.{u1} M (LinearOrder.toMin.{u1} M _inst_2) a b) c)\nCase conversion may be inaccurate. Consider using '#align min_lt_of_mul_lt_sq min_lt_of_mul_lt_sqₓ'. -/\n@[to_additive min_lt_of_add_lt_two_nsmul]\ntheorem min_lt_of_mul_lt_sq {a b c : M} (h : a * b < c ^ 2) : min a b < c := by\n  simpa using min_lt_max_of_mul_lt_mul (h.trans_eq <| pow_two _)\n#align min_lt_of_mul_lt_sq min_lt_of_mul_lt_sq\n#align min_lt_of_add_lt_two_nsmul min_lt_of_add_lt_two_nsmul\n\n/- warning: lt_max_of_sq_lt_mul -> lt_max_of_sq_lt_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {b : M} {c : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) b c)) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) a (LinearOrder.max.{u1} M _inst_2 b c))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4188 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4190 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4188 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4190) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4203 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4205 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4203 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4205)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4225 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4227 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4225 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4227)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4240 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4242 : M) => LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4240 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4242)] {a : M} {b : M} {c : M}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) b c)) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) a (Max.max.{u1} M (LinearOrder.toMax.{u1} M _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align lt_max_of_sq_lt_mul lt_max_of_sq_lt_mulₓ'. -/\n@[to_additive lt_max_of_two_nsmul_lt_add]\ntheorem lt_max_of_sq_lt_mul {a b c : M} (h : a ^ 2 < b * c) : a < max b c := by\n  simpa using min_lt_max_of_mul_lt_mul ((pow_two _).symm.trans_lt h)\n#align lt_max_of_sq_lt_mul lt_max_of_sq_lt_mul\n#align lt_max_of_two_nsmul_lt_add lt_max_of_two_nsmul_lt_add\n\nend CovariantLeSwap\n\nsection CovariantLtSwap\n\nvariable [CovariantClass M M (· * ·) (· < ·)] [CovariantClass M M (swap (· * ·)) (· < ·)]\n\n/- warning: le_of_pow_le_pow' -> le_of_pow_le_pow' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {b : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) b n)) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) a b)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4395 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4397 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4395 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4397) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4410 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4412 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4410 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4412)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4432 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4434 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4432 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4434)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4447 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4449 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4447 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4449)] {a : M} {b : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) b n)) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) a b)\nCase conversion may be inaccurate. Consider using '#align le_of_pow_le_pow' le_of_pow_le_pow'ₓ'. -/\n@[to_additive le_of_nsmul_le_nsmul]\ntheorem le_of_pow_le_pow' {a b : M} {n : ℕ} (hn : n ≠ 0) : a ^ n ≤ b ^ n → a ≤ b :=\n  (pow_strictMono_right' hn).le_iff_le.1\n#align le_of_pow_le_pow' le_of_pow_le_pow'\n#align le_of_nsmul_le_nsmul le_of_nsmul_le_nsmul\n\n/- warning: min_le_of_mul_le_sq -> min_le_of_mul_le_sq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {b : M} {c : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) a b) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) c (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (LinearOrder.min.{u1} M _inst_2 a b) c)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4510 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4512 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4510 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4512) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4525 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4527 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4525 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4527)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4547 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4549 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4547 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4549)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4562 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4564 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4562 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4564)] {a : M} {b : M} {c : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) a b) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) c (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (Min.min.{u1} M (LinearOrder.toMin.{u1} M _inst_2) a b) c)\nCase conversion may be inaccurate. Consider using '#align min_le_of_mul_le_sq min_le_of_mul_le_sqₓ'. -/\n@[to_additive min_le_of_add_le_two_nsmul]\ntheorem min_le_of_mul_le_sq {a b c : M} (h : a * b ≤ c ^ 2) : min a b ≤ c := by\n  simpa using min_le_max_of_mul_le_mul (h.trans_eq <| pow_two _)\n#align min_le_of_mul_le_sq min_le_of_mul_le_sq\n#align min_le_of_add_le_two_nsmul min_le_of_add_le_two_nsmul\n\n/- warning: le_max_of_sq_le_mul -> le_max_of_sq_le_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {a : M} {b : M} {c : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) b c)) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) a (LinearOrder.max.{u1} M _inst_2 b c))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4629 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4631 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4629 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4631) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4644 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4646 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4644 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4646)] [_inst_4 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4666 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4668 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4666 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4668)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4681 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4683 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4681 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4683)] {a : M} {b : M} {c : M}, (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) b c)) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) a (Max.max.{u1} M (LinearOrder.toMax.{u1} M _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align le_max_of_sq_le_mul le_max_of_sq_le_mulₓ'. -/\n@[to_additive le_max_of_two_nsmul_le_add]\ntheorem le_max_of_sq_le_mul {a b c : M} (h : a ^ 2 ≤ b * c) : a ≤ max b c := by\n  simpa using min_le_max_of_mul_le_mul ((pow_two _).symm.trans_le h)\n#align le_max_of_sq_le_mul le_max_of_sq_le_mul\n#align le_max_of_two_nsmul_le_add le_max_of_two_nsmul_le_add\n\nend CovariantLtSwap\n\n/- warning: left.pow_lt_one_iff -> Left.pow_lt_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {n : Nat} {x : M}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4839 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4841 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4839 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4841) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4854 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4856 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4854 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4856)] {n : Nat} {x : M}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align left.pow_lt_one_iff Left.pow_lt_one_iffₓ'. -/\n@[to_additive Left.nsmul_neg_iff]\ntheorem Left.pow_lt_one_iff [CovariantClass M M (· * ·) (· < ·)] {n : ℕ} {x : M} (hn : 0 < n) :\n    x ^ n < 1 ↔ x < 1 :=\n  haveI := Mul.to_covariantClass_left M\n  pow_lt_one_iff hn.ne'\n#align left.pow_lt_one_iff Left.pow_lt_one_iff\n#align left.nsmul_neg_iff Left.nsmul_neg_iff\n\n/- warning: right.pow_lt_one_iff -> Right.pow_lt_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))))] {n : Nat} {x : M}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_2))))) x (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : LinearOrder.{u1} M] [_inst_3 : CovariantClass.{u1, u1} M M (Function.swap.{succ u1, succ u1, succ u1} M M (fun (ᾰ : M) (ᾰ : M) => M) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4919 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4921 : M) => HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4919 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4921)) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4934 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.4936 : M) => LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.4934 x._@.Mathlib.Algebra.GroupPower.Order._hyg.4936)] {n : Nat} {x : M}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) x n) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (DistribLattice.toLattice.{u1} M (instDistribLattice.{u1} M _inst_2)))))) x (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align right.pow_lt_one_iff Right.pow_lt_one_iffₓ'. -/\n@[to_additive Right.nsmul_neg_iff]\ntheorem Right.pow_lt_one_iff [CovariantClass M M (swap (· * ·)) (· < ·)] {n : ℕ} {x : M}\n    (hn : 0 < n) : x ^ n < 1 ↔ x < 1 :=\n  ⟨fun H =>\n    not_le.mp fun k =>\n      H.not_le <|\n        haveI := Mul.to_covariantClass_right M\n        Right.one_le_pow_of_le k,\n    Right.pow_lt_one_of_lt hn⟩\n#align right.pow_lt_one_iff Right.pow_lt_one_iff\n#align right.nsmul_neg_iff Right.nsmul_neg_iff\n\nend LinearOrder\n\nend Monoid\n\nsection DivInvMonoid\n\nvariable [DivInvMonoid G] [Preorder G] [CovariantClass G G (· * ·) (· ≤ ·)]\n\n/- warning: one_le_zpow -> one_le_zpow is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G] [_inst_2 : Preorder.{u1} G] [_inst_3 : CovariantClass.{u1, u1} G G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_1))))) (LE.le.{u1} G (Preorder.toLE.{u1} G _inst_2))] {x : G}, (LE.le.{u1} G (Preorder.toLE.{u1} G _inst_2) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_1)))))) x) -> (forall {n : Int}, (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) n) -> (LE.le.{u1} G (Preorder.toLE.{u1} G _inst_2) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_1)))))) (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G _inst_1)) x n)))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G] [_inst_2 : Preorder.{u1} G] [_inst_3 : CovariantClass.{u1, u1} G G (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.5069 : G) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.5071 : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_1)))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.5069 x._@.Mathlib.Algebra.GroupPower.Order._hyg.5071) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.5084 : G) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.5086 : G) => LE.le.{u1} G (Preorder.toLE.{u1} G _inst_2) x._@.Mathlib.Algebra.GroupPower.Order._hyg.5084 x._@.Mathlib.Algebra.GroupPower.Order._hyg.5086)] {x : G}, (LE.le.{u1} G (Preorder.toLE.{u1} G _inst_2) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (Monoid.toOne.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_1)))) x) -> (forall {n : Int}, (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) n) -> (LE.le.{u1} G (Preorder.toLE.{u1} G _inst_2) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (Monoid.toOne.{u1} G (DivInvMonoid.toMonoid.{u1} G _inst_1)))) (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G _inst_1)) x n)))\nCase conversion may be inaccurate. Consider using '#align one_le_zpow one_le_zpowₓ'. -/\n@[to_additive zsmul_nonneg]\ntheorem one_le_zpow {x : G} (H : 1 ≤ x) {n : ℤ} (hn : 0 ≤ n) : 1 ≤ x ^ n :=\n  by\n  lift n to ℕ using hn\n  rw [zpow_ofNat]\n  apply one_le_pow_of_one_le' H\n#align one_le_zpow one_le_zpow\n#align zsmul_nonneg zsmul_nonneg\n\nend DivInvMonoid\n\nnamespace CanonicallyOrderedCommSemiring\n\nvariable [CanonicallyOrderedCommSemiring R]\n\n/- warning: canonically_ordered_comm_semiring.pow_pos -> CanonicallyOrderedCommSemiring.pow_pos is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))))))) a) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))))) a n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CanonicallyOrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) a) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CanonicallyOrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))))) a n))\nCase conversion may be inaccurate. Consider using '#align canonically_ordered_comm_semiring.pow_pos CanonicallyOrderedCommSemiring.pow_posₓ'. -/\ntheorem pow_pos {a : R} (H : 0 < a) (n : ℕ) : 0 < a ^ n :=\n  pos_iff_ne_zero.2 <| pow_ne_zero _ H.ne'\n#align canonically_ordered_comm_semiring.pow_pos CanonicallyOrderedCommSemiring.pow_pos\n\nend CanonicallyOrderedCommSemiring\n\nsection OrderedSemiring\n\nvariable [OrderedSemiring R] {a x y : R} {n m : ℕ}\n\n/- warning: zero_pow_le_one -> zero_pow_le_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] (n : Nat), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))))) n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] (n : Nat), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))\nCase conversion may be inaccurate. Consider using '#align zero_pow_le_one zero_pow_le_oneₓ'. -/\ntheorem zero_pow_le_one : ∀ n : ℕ, (0 : R) ^ n ≤ 1\n  | 0 => (pow_zero _).le\n  | n + 1 => by\n    rw [zero_pow n.succ_pos]\n    exact zero_le_one\n#align zero_pow_le_one zero_pow_le_one\n\n/- warning: pow_add_pow_le -> pow_add_pow_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {x : R} {y : R} {n : Nat}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))))) x) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))))) y) -> (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) y n)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))) x y) n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {x : R} {y : R} {n : Nat}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) x) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) y) -> (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) y n)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))) x y) n))\nCase conversion may be inaccurate. Consider using '#align pow_add_pow_le pow_add_pow_leₓ'. -/\ntheorem pow_add_pow_le (hx : 0 ≤ x) (hy : 0 ≤ y) (hn : n ≠ 0) : x ^ n + y ^ n ≤ (x + y) ^ n :=\n  by\n  rcases Nat.exists_eq_succ_of_ne_zero hn with ⟨k, rfl⟩\n  induction' k with k ih; · simp only [pow_one]\n  let n := k.succ\n  have h1 := add_nonneg (mul_nonneg hx (pow_nonneg hy n)) (mul_nonneg hy (pow_nonneg hx n))\n  have h2 := add_nonneg hx hy\n  calc\n    x ^ n.succ + y ^ n.succ ≤ x * x ^ n + y * y ^ n + (x * y ^ n + y * x ^ n) :=\n      by\n      rw [pow_succ _ n, pow_succ _ n]\n      exact le_add_of_nonneg_right h1\n    _ = (x + y) * (x ^ n + y ^ n) := by\n      rw [add_mul, mul_add, mul_add, add_comm (y * x ^ n), ← add_assoc, ← add_assoc,\n        add_assoc (x * x ^ n) (x * y ^ n), add_comm (x * y ^ n) (y * y ^ n), ← add_assoc]\n    _ ≤ (x + y) ^ n.succ := by\n      rw [pow_succ _ n]\n      exact mul_le_mul_of_nonneg_left (ih (Nat.succ_ne_zero k)) h2\n    \n#align pow_add_pow_le pow_add_pow_le\n\n/- warning: pow_le_one -> pow_le_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {a : R} (n : Nat), (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))))))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {a : R} (n : Nat), (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align pow_le_one pow_le_oneₓ'. -/\ntheorem pow_le_one : ∀ (n : ℕ) (h₀ : 0 ≤ a) (h₁ : a ≤ 1), a ^ n ≤ 1\n  | 0, h₀, h₁ => (pow_zero a).le\n  | n + 1, h₀, h₁ => (pow_succ' a n).le.trans (mul_le_one (pow_le_one n h₀ h₁) h₀ h₁)\n#align pow_le_one pow_le_one\n\n/- warning: pow_lt_one -> pow_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))))))) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align pow_lt_one pow_lt_oneₓ'. -/\ntheorem pow_lt_one (h₀ : 0 ≤ a) (h₁ : a < 1) : ∀ {n : ℕ} (hn : n ≠ 0), a ^ n < 1\n  | 0, h => (h rfl).elim\n  | n + 1, h => by\n    rw [pow_succ]\n    exact mul_lt_one_of_nonneg_of_lt_one_left h₀ h₁ (pow_le_one _ h₀ h₁.le)\n#align pow_lt_one pow_lt_one\n\n#print one_le_pow_of_one_le /-\ntheorem one_le_pow_of_one_le (H : 1 ≤ a) : ∀ n : ℕ, 1 ≤ a ^ n\n  | 0 => by rw [pow_zero]\n  | n + 1 => by\n    rw [pow_succ]\n    simpa only [mul_one] using\n      mul_le_mul H (one_le_pow_of_one_le n) zero_le_one (le_trans zero_le_one H)\n#align one_le_pow_of_one_le one_le_pow_of_one_le\n-/\n\n#print pow_mono /-\ntheorem pow_mono (h : 1 ≤ a) : Monotone fun n : ℕ => a ^ n :=\n  monotone_nat_of_le_succ fun n => by\n    rw [pow_succ]\n    exact le_mul_of_one_le_left (pow_nonneg (zero_le_one.trans h) _) h\n#align pow_mono pow_mono\n-/\n\n#print pow_le_pow /-\ntheorem pow_le_pow (ha : 1 ≤ a) (h : n ≤ m) : a ^ n ≤ a ^ m :=\n  pow_mono ha h\n#align pow_le_pow pow_le_pow\n-/\n\n#print le_self_pow /-\ntheorem le_self_pow (ha : 1 ≤ a) (h : m ≠ 0) : a ≤ a ^ m :=\n  (pow_one a).symm.trans_le (pow_le_pow ha <| pos_iff_ne_zero.mpr h)\n#align le_self_pow le_self_pow\n-/\n\n/- warning: pow_le_pow_of_le_left -> pow_le_pow_of_le_left is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {a : R} {b : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) a b) -> (forall (i : Nat), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a i) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) b i))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} R] {a : R} {b : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) a b) -> (forall (i : Nat), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) a i) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_1))))) b i))\nCase conversion may be inaccurate. Consider using '#align pow_le_pow_of_le_left pow_le_pow_of_le_leftₓ'. -/\n@[mono]\ntheorem pow_le_pow_of_le_left {a b : R} (ha : 0 ≤ a) (hab : a ≤ b) : ∀ i : ℕ, a ^ i ≤ b ^ i\n  | 0 => by simp\n  | k + 1 => by\n    rw [pow_succ, pow_succ]\n    exact mul_le_mul hab (pow_le_pow_of_le_left _) (pow_nonneg ha _) (le_trans ha hab)\n#align pow_le_pow_of_le_left pow_le_pow_of_le_left\n\n#print one_lt_pow /-\ntheorem one_lt_pow (ha : 1 < a) : ∀ {n : ℕ} (hn : n ≠ 0), 1 < a ^ n\n  | 0, h => (h rfl).elim\n  | n + 1, h => by\n    rw [pow_succ]\n    exact one_lt_mul_of_lt_of_le ha (one_le_pow_of_one_le ha.le _)\n#align one_lt_pow one_lt_pow\n-/\n\nend OrderedSemiring\n\nsection StrictOrderedSemiring\n\nvariable [StrictOrderedSemiring R] {a x y : R} {n m : ℕ}\n\n/- warning: pow_lt_pow_of_lt_left -> pow_lt_pow_of_lt_left is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) x y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))) x) -> (forall {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) y n)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) x y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) x) -> (forall {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) y n)))\nCase conversion may be inaccurate. Consider using '#align pow_lt_pow_of_lt_left pow_lt_pow_of_lt_leftₓ'. -/\ntheorem pow_lt_pow_of_lt_left (h : x < y) (hx : 0 ≤ x) : ∀ {n : ℕ}, 0 < n → x ^ n < y ^ n\n  | 0, hn => hn.False.elim\n  | n + 1, _ => by\n    simpa only [pow_succ'] using\n      mul_lt_mul_of_le_of_le' (pow_le_pow_of_le_left hx h.le _) h (pow_pos (hx.trans_lt h) _) hx\n#align pow_lt_pow_of_lt_left pow_lt_pow_of_lt_left\n\n/- warning: strict_mono_on_pow -> strictMonoOn_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (StrictMonoOn.{u1, u1} R R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1))) (fun (x : R) => HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) x n) (Set.Ici.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (StrictMonoOn.{u1, u1} R R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1)) (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1)) (fun (x : R) => HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) x n) (Set.Ici.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1)) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align strict_mono_on_pow strictMonoOn_powₓ'. -/\ntheorem strictMonoOn_pow (hn : 0 < n) : StrictMonoOn (fun x : R => x ^ n) (Set.Ici 0) :=\n  fun x hx y hy h => pow_lt_pow_of_lt_left h hx hn\n#align strict_mono_on_pow strictMonoOn_pow\n\n#print pow_strictMono_right /-\ntheorem pow_strictMono_right (h : 1 < a) : StrictMono fun n : ℕ => a ^ n :=\n  have : 0 < a := zero_le_one.trans_lt h\n  strictMono_nat_of_lt_succ fun n => by\n    simpa only [one_mul, pow_succ] using mul_lt_mul h (le_refl (a ^ n)) (pow_pos this _) this.le\n#align pow_strict_mono_right pow_strictMono_right\n-/\n\n#print pow_lt_pow /-\ntheorem pow_lt_pow (h : 1 < a) (h2 : n < m) : a ^ n < a ^ m :=\n  pow_strictMono_right h h2\n#align pow_lt_pow pow_lt_pow\n-/\n\n#print pow_lt_pow_iff /-\ntheorem pow_lt_pow_iff (h : 1 < a) : a ^ n < a ^ m ↔ n < m :=\n  (pow_strictMono_right h).lt_iff_lt\n#align pow_lt_pow_iff pow_lt_pow_iff\n-/\n\n#print pow_le_pow_iff /-\ntheorem pow_le_pow_iff (h : 1 < a) : a ^ n ≤ a ^ m ↔ n ≤ m :=\n  (pow_strictMono_right h).le_iff_le\n#align pow_le_pow_iff pow_le_pow_iff\n-/\n\n/- warning: strict_anti_pow -> strictAnti_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))))))) -> (StrictAnti.{0, u1} Nat R (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1))) (fun (n : Nat) => HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) -> (StrictAnti.{0, u1} Nat R (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1)) (fun (n : Nat) => HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a n))\nCase conversion may be inaccurate. Consider using '#align strict_anti_pow strictAnti_powₓ'. -/\ntheorem strictAnti_pow (h₀ : 0 < a) (h₁ : a < 1) : StrictAnti fun n : ℕ => a ^ n :=\n  strictAnti_nat_of_succ_lt fun n => by\n    simpa only [pow_succ, one_mul] using mul_lt_mul h₁ le_rfl (pow_pos h₀ n) zero_le_one\n#align strict_anti_pow strictAnti_pow\n\n/- warning: pow_lt_pow_iff_of_lt_one -> pow_lt_pow_iff_of_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R} {n : Nat} {m : Nat}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))))))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a m) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a n)) (LT.lt.{0} Nat Nat.hasLt n m))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R} {n : Nat} {m : Nat}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a m) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a n)) (LT.lt.{0} Nat instLTNat n m))\nCase conversion may be inaccurate. Consider using '#align pow_lt_pow_iff_of_lt_one pow_lt_pow_iff_of_lt_oneₓ'. -/\ntheorem pow_lt_pow_iff_of_lt_one (h₀ : 0 < a) (h₁ : a < 1) : a ^ m < a ^ n ↔ n < m :=\n  (strictAnti_pow h₀ h₁).lt_iff_lt\n#align pow_lt_pow_iff_of_lt_one pow_lt_pow_iff_of_lt_one\n\n/- warning: pow_lt_pow_of_lt_one -> pow_lt_pow_of_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))))))) -> (forall {i : Nat} {j : Nat}, (LT.lt.{0} Nat Nat.hasLt i j) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a j) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a i)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) -> (forall {i : Nat} {j : Nat}, (LT.lt.{0} Nat instLTNat i j) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a j) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a i)))\nCase conversion may be inaccurate. Consider using '#align pow_lt_pow_of_lt_one pow_lt_pow_of_lt_oneₓ'. -/\ntheorem pow_lt_pow_of_lt_one (h : 0 < a) (ha : a < 1) {i j : ℕ} (hij : i < j) : a ^ j < a ^ i :=\n  (pow_lt_pow_iff_of_lt_one h ha).2 hij\n#align pow_lt_pow_of_lt_one pow_lt_pow_of_lt_one\n\n/- warning: pow_lt_self_of_lt_one -> pow_lt_self_of_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R} {n : Nat}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))))))) -> (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) n) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a n) a)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R} {n : Nat}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) -> (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) n) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a n) a)\nCase conversion may be inaccurate. Consider using '#align pow_lt_self_of_lt_one pow_lt_self_of_lt_oneₓ'. -/\ntheorem pow_lt_self_of_lt_one (h₀ : 0 < a) (h₁ : a < 1) (hn : 1 < n) : a ^ n < a :=\n  calc\n    a ^ n < a ^ 1 := pow_lt_pow_of_lt_one h₀ h₁ hn\n    _ = a := pow_one _\n    \n#align pow_lt_self_of_lt_one pow_lt_self_of_lt_one\n\n/- warning: sq_pos_of_pos -> sq_pos_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1)))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedSemiring.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align sq_pos_of_pos sq_pos_of_posₓ'. -/\ntheorem sq_pos_of_pos (ha : 0 < a) : 0 < a ^ 2 :=\n  by\n  rw [sq]\n  exact mul_pos ha ha\n#align sq_pos_of_pos sq_pos_of_pos\n\nend StrictOrderedSemiring\n\nsection StrictOrderedRing\n\nvariable [StrictOrderedRing R] {a : R}\n\n/- warning: pow_bit0_pos_of_neg -> pow_bit0_pos_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedRing.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1)))))))))) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1)))) a (bit0.{0} Nat Nat.hasAdd n)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedRing.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1))))))) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (bit0.{0} Nat instAddNat n)))\nCase conversion may be inaccurate. Consider using '#align pow_bit0_pos_of_neg pow_bit0_pos_of_negₓ'. -/\ntheorem pow_bit0_pos_of_neg (ha : a < 0) (n : ℕ) : 0 < a ^ bit0 n :=\n  by\n  rw [pow_bit0']\n  exact pow_pos (mul_pos_of_neg_of_neg ha ha) _\n#align pow_bit0_pos_of_neg pow_bit0_pos_of_neg\n\n/- warning: pow_bit1_neg -> pow_bit1_neg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedRing.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1)))))))))) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1)))) a (bit1.{0} Nat Nat.hasOne Nat.hasAdd n)) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedRing.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1))))))) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (bit1.{0} Nat (CanonicallyOrderedCommSemiring.toOne.{0} Nat Nat.canonicallyOrderedCommSemiring) instAddNat n)) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align pow_bit1_neg pow_bit1_negₓ'. -/\ntheorem pow_bit1_neg (ha : a < 0) (n : ℕ) : a ^ bit1 n < 0 :=\n  by\n  rw [bit1, pow_succ]\n  exact mul_neg_of_neg_of_pos ha (pow_bit0_pos_of_neg ha n)\n#align pow_bit1_neg pow_bit1_neg\n\n/- warning: sq_pos_of_neg -> sq_pos_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedRing.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1)))))))))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : StrictOrderedRing.{u1} R] {a : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R _inst_1))) a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1))))))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedRing.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align sq_pos_of_neg sq_pos_of_negₓ'. -/\ntheorem sq_pos_of_neg (ha : a < 0) : 0 < a ^ 2 :=\n  pow_bit0_pos_of_neg ha _\n#align sq_pos_of_neg sq_pos_of_neg\n\nend StrictOrderedRing\n\nsection LinearOrderedSemiring\n\nvariable [LinearOrderedSemiring R] {a b : R}\n\n/- warning: pow_le_one_iff_of_nonneg -> pow_le_one_iff_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align pow_le_one_iff_of_nonneg pow_le_one_iff_of_nonnegₓ'. -/\ntheorem pow_le_one_iff_of_nonneg {a : R} (ha : 0 ≤ a) {n : ℕ} (hn : n ≠ 0) : a ^ n ≤ 1 ↔ a ≤ 1 :=\n  by\n  refine' ⟨_, pow_le_one n ha⟩\n  rw [← not_lt, ← not_lt]\n  exact mt fun h => one_lt_pow h hn\n#align pow_le_one_iff_of_nonneg pow_le_one_iff_of_nonneg\n\n/- warning: one_le_pow_iff_of_nonneg -> one_le_pow_iff_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n)) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n)) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a)))\nCase conversion may be inaccurate. Consider using '#align one_le_pow_iff_of_nonneg one_le_pow_iff_of_nonnegₓ'. -/\ntheorem one_le_pow_iff_of_nonneg {a : R} (ha : 0 ≤ a) {n : ℕ} (hn : n ≠ 0) : 1 ≤ a ^ n ↔ 1 ≤ a :=\n  by\n  refine' ⟨_, fun h => one_le_pow_of_one_le h n⟩\n  rw [← not_lt, ← not_lt]\n  exact mt fun h => pow_lt_one ha h hn\n#align one_le_pow_iff_of_nonneg one_le_pow_iff_of_nonneg\n\n/- warning: one_lt_pow_iff_of_nonneg -> one_lt_pow_iff_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n)) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n)) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a)))\nCase conversion may be inaccurate. Consider using '#align one_lt_pow_iff_of_nonneg one_lt_pow_iff_of_nonnegₓ'. -/\ntheorem one_lt_pow_iff_of_nonneg {a : R} (ha : 0 ≤ a) {n : ℕ} (hn : n ≠ 0) : 1 < a ^ n ↔ 1 < a :=\n  lt_iff_lt_of_le_iff_le (pow_le_one_iff_of_nonneg ha hn)\n#align one_lt_pow_iff_of_nonneg one_lt_pow_iff_of_nonneg\n\n/- warning: pow_lt_one_iff_of_nonneg -> pow_lt_one_iff_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align pow_lt_one_iff_of_nonneg pow_lt_one_iff_of_nonnegₓ'. -/\ntheorem pow_lt_one_iff_of_nonneg {a : R} (ha : 0 ≤ a) {n : ℕ} (hn : n ≠ 0) : a ^ n < 1 ↔ a < 1 :=\n  lt_iff_lt_of_le_iff_le (one_le_pow_iff_of_nonneg ha hn)\n#align pow_lt_one_iff_of_nonneg pow_lt_one_iff_of_nonneg\n\n/- warning: sq_le_one_iff -> sq_le_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align sq_le_one_iff sq_le_one_iffₓ'. -/\ntheorem sq_le_one_iff {a : R} (ha : 0 ≤ a) : a ^ 2 ≤ 1 ↔ a ≤ 1 :=\n  pow_le_one_iff_of_nonneg ha (Nat.succ_ne_zero _)\n#align sq_le_one_iff sq_le_one_iff\n\n/- warning: sq_lt_one_iff -> sq_lt_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align sq_lt_one_iff sq_lt_one_iffₓ'. -/\ntheorem sq_lt_one_iff {a : R} (ha : 0 ≤ a) : a ^ 2 < 1 ↔ a < 1 :=\n  pow_lt_one_iff_of_nonneg ha (Nat.succ_ne_zero _)\n#align sq_lt_one_iff sq_lt_one_iff\n\n/- warning: one_le_sq_iff -> one_le_sq_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a))\nCase conversion may be inaccurate. Consider using '#align one_le_sq_iff one_le_sq_iffₓ'. -/\ntheorem one_le_sq_iff {a : R} (ha : 0 ≤ a) : 1 ≤ a ^ 2 ↔ 1 ≤ a :=\n  one_le_pow_iff_of_nonneg ha (Nat.succ_ne_zero _)\n#align one_le_sq_iff one_le_sq_iff\n\n/- warning: one_lt_sq_iff -> one_lt_sq_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a))\nCase conversion may be inaccurate. Consider using '#align one_lt_sq_iff one_lt_sq_iffₓ'. -/\ntheorem one_lt_sq_iff {a : R} (ha : 0 ≤ a) : 1 < a ^ 2 ↔ 1 < a :=\n  one_lt_pow_iff_of_nonneg ha (Nat.succ_ne_zero _)\n#align one_lt_sq_iff one_lt_sq_iff\n\n/- warning: pow_left_inj -> pow_left_inj is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {x : R} {y : R} {n : Nat}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) x) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) y) -> (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) y n)) (Eq.{succ u1} R x y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {x : R} {y : R} {n : Nat}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) x) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) y) -> (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) y n)) (Eq.{succ u1} R x y))\nCase conversion may be inaccurate. Consider using '#align pow_left_inj pow_left_injₓ'. -/\n@[simp]\ntheorem pow_left_inj {x y : R} {n : ℕ} (Hxpos : 0 ≤ x) (Hypos : 0 ≤ y) (Hnpos : 0 < n) :\n    x ^ n = y ^ n ↔ x = y :=\n  (@strictMonoOn_pow R _ _ Hnpos).eq_iff_eq Hxpos Hypos\n#align pow_left_inj pow_left_inj\n\n/- warning: lt_of_pow_lt_pow -> lt_of_pow_lt_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R} (n : Nat), (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) b) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b n)) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a b)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R} (n : Nat), (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b n)) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) a b)\nCase conversion may be inaccurate. Consider using '#align lt_of_pow_lt_pow lt_of_pow_lt_powₓ'. -/\ntheorem lt_of_pow_lt_pow {a b : R} (n : ℕ) (hb : 0 ≤ b) (h : a ^ n < b ^ n) : a < b :=\n  lt_of_not_ge fun hn => not_lt_of_ge (pow_le_pow_of_le_left hb hn _) h\n#align lt_of_pow_lt_pow lt_of_pow_lt_pow\n\n/- warning: le_of_pow_le_pow -> le_of_pow_le_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R} (n : Nat), (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) b) -> (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b n)) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a b)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R} (n : Nat), (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b) -> (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b n)) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) a b)\nCase conversion may be inaccurate. Consider using '#align le_of_pow_le_pow le_of_pow_le_powₓ'. -/\ntheorem le_of_pow_le_pow {a b : R} (n : ℕ) (hb : 0 ≤ b) (hn : 0 < n) (h : a ^ n ≤ b ^ n) : a ≤ b :=\n  le_of_not_lt fun h1 => not_le_of_lt (pow_lt_pow_of_lt_left h1 hb hn) h\n#align le_of_pow_le_pow le_of_pow_le_pow\n\n/- warning: sq_eq_sq -> sq_eq_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) a) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) b) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (Eq.{succ u1} R a b))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (Eq.{succ u1} R a b))\nCase conversion may be inaccurate. Consider using '#align sq_eq_sq sq_eq_sqₓ'. -/\n@[simp]\ntheorem sq_eq_sq {a b : R} (ha : 0 ≤ a) (hb : 0 ≤ b) : a ^ 2 = b ^ 2 ↔ a = b :=\n  pow_left_inj ha hb (by decide)\n#align sq_eq_sq sq_eq_sq\n\n/- warning: lt_of_mul_self_lt_mul_self -> lt_of_mul_self_lt_mul_self is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))))) b) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))) a a) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))))) b b)) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1))))) a b)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} R] {a : R} {b : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) a a) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))))) b b)) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) a b)\nCase conversion may be inaccurate. Consider using '#align lt_of_mul_self_lt_mul_self lt_of_mul_self_lt_mul_selfₓ'. -/\ntheorem lt_of_mul_self_lt_mul_self (hb : 0 ≤ b) : a * a < b * b → a < b :=\n  by\n  simp_rw [← sq]\n  exact lt_of_pow_lt_pow _ hb\n#align lt_of_mul_self_lt_mul_self lt_of_mul_self_lt_mul_self\n\nend LinearOrderedSemiring\n\nsection LinearOrderedRing\n\nvariable [LinearOrderedRing R]\n\n/- warning: pow_abs -> pow_abs is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) a) n) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) a) n) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a n))\nCase conversion may be inaccurate. Consider using '#align pow_abs pow_absₓ'. -/\ntheorem pow_abs (a : R) (n : ℕ) : |a| ^ n = |a ^ n| :=\n  ((absHom.toMonoidHom : R →* R).map_pow a n).symm\n#align pow_abs pow_abs\n\n/- warning: abs_neg_one_pow -> abs_neg_one_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (n : Nat), Eq.{succ u1} R (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) n)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (n : Nat), Eq.{succ u1} R (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (Neg.neg.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) n)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align abs_neg_one_pow abs_neg_one_powₓ'. -/\ntheorem abs_neg_one_pow (n : ℕ) : |(-1 : R) ^ n| = 1 := by rw [← pow_abs, abs_neg, abs_one, one_pow]\n#align abs_neg_one_pow abs_neg_one_pow\n\n/- warning: pow_bit0_nonneg -> pow_bit0_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R) (n : Nat), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (bit0.{0} Nat Nat.hasAdd n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R) (n : Nat), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (bit0.{0} Nat instAddNat n))\nCase conversion may be inaccurate. Consider using '#align pow_bit0_nonneg pow_bit0_nonnegₓ'. -/\ntheorem pow_bit0_nonneg (a : R) (n : ℕ) : 0 ≤ a ^ bit0 n :=\n  by\n  rw [pow_bit0]\n  exact mul_self_nonneg _\n#align pow_bit0_nonneg pow_bit0_nonneg\n\n/- warning: sq_nonneg -> sq_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align sq_nonneg sq_nonnegₓ'. -/\ntheorem sq_nonneg (a : R) : 0 ≤ a ^ 2 :=\n  pow_bit0_nonneg a 1\n#align sq_nonneg sq_nonneg\n\n/- warning: pow_two_nonneg -> pow_two_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align pow_two_nonneg pow_two_nonnegₓ'. -/\nalias sq_nonneg ← pow_two_nonneg\n#align pow_two_nonneg pow_two_nonneg\n\n/- warning: pow_bit0_pos -> pow_bit0_pos is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {a : R}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))))) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (bit0.{0} Nat Nat.hasAdd n)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {a : R}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1)))))))) -> (forall (n : Nat), LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (bit0.{0} Nat instAddNat n)))\nCase conversion may be inaccurate. Consider using '#align pow_bit0_pos pow_bit0_posₓ'. -/\ntheorem pow_bit0_pos {a : R} (h : a ≠ 0) (n : ℕ) : 0 < a ^ bit0 n :=\n  (pow_bit0_nonneg a n).lt_of_ne (pow_ne_zero _ h).symm\n#align pow_bit0_pos pow_bit0_pos\n\n/- warning: sq_pos_of_ne_zero -> sq_pos_of_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1)))))))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align sq_pos_of_ne_zero sq_pos_of_ne_zeroₓ'. -/\ntheorem sq_pos_of_ne_zero (a : R) (h : a ≠ 0) : 0 < a ^ 2 :=\n  pow_bit0_pos h 1\n#align sq_pos_of_ne_zero sq_pos_of_ne_zero\n\n/- warning: pow_two_pos_of_ne_zero -> pow_two_pos_of_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1)))))))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align pow_two_pos_of_ne_zero pow_two_pos_of_ne_zeroₓ'. -/\nalias sq_pos_of_ne_zero ← pow_two_pos_of_ne_zero\n#align pow_two_pos_of_ne_zero pow_two_pos_of_ne_zero\n\n/- warning: pow_bit0_pos_iff -> pow_bit0_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R) {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (bit0.{0} Nat Nat.hasAdd n))) (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R) {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (bit0.{0} Nat instAddNat n))) (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align pow_bit0_pos_iff pow_bit0_pos_iffₓ'. -/\ntheorem pow_bit0_pos_iff (a : R) {n : ℕ} (hn : n ≠ 0) : 0 < a ^ bit0 n ↔ a ≠ 0 :=\n  by\n  refine' ⟨fun h => _, fun h => pow_bit0_pos h n⟩\n  rintro rfl\n  rw [zero_pow (Nat.zero_lt_bit0 hn)] at h\n  exact lt_irrefl _ h\n#align pow_bit0_pos_iff pow_bit0_pos_iff\n\n/- warning: sq_pos_iff -> sq_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (a : R), Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align sq_pos_iff sq_pos_iffₓ'. -/\ntheorem sq_pos_iff (a : R) : 0 < a ^ 2 ↔ a ≠ 0 :=\n  pow_bit0_pos_iff a one_ne_zero\n#align sq_pos_iff sq_pos_iff\n\nvariable {x y : R}\n\n/- warning: sq_abs -> sq_abs is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align sq_abs sq_absₓ'. -/\ntheorem sq_abs (x : R) : |x| ^ 2 = x ^ 2 := by simpa only [sq] using abs_mul_abs_self x\n#align sq_abs sq_abs\n\n/- warning: abs_sq -> abs_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Eq.{succ u1} R (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Eq.{succ u1} R (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align abs_sq abs_sqₓ'. -/\ntheorem abs_sq (x : R) : |x ^ 2| = x ^ 2 := by simpa only [sq] using abs_mul_self x\n#align abs_sq abs_sq\n\n/- warning: sq_lt_sq -> sq_lt_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) y))\nCase conversion may be inaccurate. Consider using '#align sq_lt_sq sq_lt_sqₓ'. -/\ntheorem sq_lt_sq : x ^ 2 < y ^ 2 ↔ |x| < |y| := by\n  simpa only [sq_abs] using\n    (@strictMonoOn_pow R _ _ two_pos).lt_iff_lt (abs_nonneg x) (abs_nonneg y)\n#align sq_lt_sq sq_lt_sq\n\n/- warning: sq_lt_sq' -> sq_lt_sq' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) y) x) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x y) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Neg.neg.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) y) x) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) x y) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align sq_lt_sq' sq_lt_sq'ₓ'. -/\ntheorem sq_lt_sq' (h1 : -y < x) (h2 : x < y) : x ^ 2 < y ^ 2 :=\n  sq_lt_sq.2 (lt_of_lt_of_le (abs_lt.2 ⟨h1, h2⟩) (le_abs_self _))\n#align sq_lt_sq' sq_lt_sq'\n\n/- warning: sq_le_sq -> sq_le_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) y))\nCase conversion may be inaccurate. Consider using '#align sq_le_sq sq_le_sqₓ'. -/\ntheorem sq_le_sq : x ^ 2 ≤ y ^ 2 ↔ |x| ≤ |y| := by\n  simpa only [sq_abs] using\n    (@strictMonoOn_pow R _ _ two_pos).le_iff_le (abs_nonneg x) (abs_nonneg y)\n#align sq_le_sq sq_le_sq\n\n/- warning: sq_le_sq' -> sq_le_sq' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) y) x) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Neg.neg.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) y) x) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) x y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align sq_le_sq' sq_le_sq'ₓ'. -/\ntheorem sq_le_sq' (h1 : -y ≤ x) (h2 : x ≤ y) : x ^ 2 ≤ y ^ 2 :=\n  sq_le_sq.2 (le_trans (abs_le.mpr ⟨h1, h2⟩) (le_abs_self _))\n#align sq_le_sq' sq_le_sq'\n\n/- warning: abs_lt_of_sq_lt_sq -> abs_lt_of_sq_lt_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) y) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) y)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) y)\nCase conversion may be inaccurate. Consider using '#align abs_lt_of_sq_lt_sq abs_lt_of_sq_lt_sqₓ'. -/\ntheorem abs_lt_of_sq_lt_sq (h : x ^ 2 < y ^ 2) (hy : 0 ≤ y) : |x| < y := by\n  rwa [← abs_of_nonneg hy, ← sq_lt_sq]\n#align abs_lt_of_sq_lt_sq abs_lt_of_sq_lt_sq\n\n/- warning: abs_lt_of_sq_lt_sq' -> abs_lt_of_sq_lt_sq' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) y) -> (And (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) y) x) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y) -> (And (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Neg.neg.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) y) x) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) x y))\nCase conversion may be inaccurate. Consider using '#align abs_lt_of_sq_lt_sq' abs_lt_of_sq_lt_sq'ₓ'. -/\ntheorem abs_lt_of_sq_lt_sq' (h : x ^ 2 < y ^ 2) (hy : 0 ≤ y) : -y < x ∧ x < y :=\n  abs_lt.mp <| abs_lt_of_sq_lt_sq h hy\n#align abs_lt_of_sq_lt_sq' abs_lt_of_sq_lt_sq'\n\n/- warning: abs_le_of_sq_le_sq -> abs_le_of_sq_le_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) y)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) y)\nCase conversion may be inaccurate. Consider using '#align abs_le_of_sq_le_sq abs_le_of_sq_le_sqₓ'. -/\ntheorem abs_le_of_sq_le_sq (h : x ^ 2 ≤ y ^ 2) (hy : 0 ≤ y) : |x| ≤ y := by\n  rwa [← abs_of_nonneg hy, ← sq_le_sq]\n#align abs_le_of_sq_le_sq abs_le_of_sq_le_sq\n\n/- warning: abs_le_of_sq_le_sq' -> abs_le_of_sq_le_sq' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) y) -> (And (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) y) x) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y) -> (And (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Neg.neg.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) y) x) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) x y))\nCase conversion may be inaccurate. Consider using '#align abs_le_of_sq_le_sq' abs_le_of_sq_le_sq'ₓ'. -/\ntheorem abs_le_of_sq_le_sq' (h : x ^ 2 ≤ y ^ 2) (hy : 0 ≤ y) : -y ≤ x ∧ x ≤ y :=\n  abs_le.mp <| abs_le_of_sq_le_sq h hy\n#align abs_le_of_sq_le_sq' abs_le_of_sq_le_sq'\n\n/- warning: sq_eq_sq_iff_abs_eq_abs -> sq_eq_sq_iff_abs_eq_abs is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R) (y : R), Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (Eq.{succ u1} R (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R) (y : R), Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (Eq.{succ u1} R (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) y))\nCase conversion may be inaccurate. Consider using '#align sq_eq_sq_iff_abs_eq_abs sq_eq_sq_iff_abs_eq_absₓ'. -/\ntheorem sq_eq_sq_iff_abs_eq_abs (x y : R) : x ^ 2 = y ^ 2 ↔ |x| = |y| := by\n  simp only [le_antisymm_iff, sq_le_sq]\n#align sq_eq_sq_iff_abs_eq_abs sq_eq_sq_iff_abs_eq_abs\n\n/- warning: sq_le_one_iff_abs_le_one -> sq_le_one_iff_abs_le_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align sq_le_one_iff_abs_le_one sq_le_one_iff_abs_le_oneₓ'. -/\n@[simp]\ntheorem sq_le_one_iff_abs_le_one (x : R) : x ^ 2 ≤ 1 ↔ |x| ≤ 1 := by\n  simpa only [one_pow, abs_one] using @sq_le_sq _ _ x 1\n#align sq_le_one_iff_abs_le_one sq_le_one_iff_abs_le_one\n\n/- warning: sq_lt_one_iff_abs_lt_one -> sq_lt_one_iff_abs_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align sq_lt_one_iff_abs_lt_one sq_lt_one_iff_abs_lt_oneₓ'. -/\n@[simp]\ntheorem sq_lt_one_iff_abs_lt_one (x : R) : x ^ 2 < 1 ↔ |x| < 1 := by\n  simpa only [one_pow, abs_one] using @sq_lt_sq _ _ x 1\n#align sq_lt_one_iff_abs_lt_one sq_lt_one_iff_abs_lt_one\n\n/- warning: one_le_sq_iff_one_le_abs -> one_le_sq_iff_one_le_abs is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x))\nCase conversion may be inaccurate. Consider using '#align one_le_sq_iff_one_le_abs one_le_sq_iff_one_le_absₓ'. -/\n@[simp]\ntheorem one_le_sq_iff_one_le_abs (x : R) : 1 ≤ x ^ 2 ↔ 1 ≤ |x| := by\n  simpa only [one_pow, abs_one] using @sq_le_sq _ _ 1 x\n#align one_le_sq_iff_one_le_abs one_le_sq_iff_one_le_abs\n\n/- warning: one_lt_sq_iff_one_lt_abs -> one_lt_sq_iff_one_lt_abs is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))))) (SemilatticeSup.toHasSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (LinearOrder.toLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1))))) x))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] (x : R), Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))))) (Abs.abs.{u1} R (Neg.toHasAbs.{u1} R (Ring.toNeg.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))) (SemilatticeSup.toSup.{u1} R (Lattice.toSemilatticeSup.{u1} R (DistribLattice.toLattice.{u1} R (instDistribLattice.{u1} R (LinearOrderedRing.toLinearOrder.{u1} R _inst_1)))))) x))\nCase conversion may be inaccurate. Consider using '#align one_lt_sq_iff_one_lt_abs one_lt_sq_iff_one_lt_absₓ'. -/\n@[simp]\ntheorem one_lt_sq_iff_one_lt_abs (x : R) : 1 < x ^ 2 ↔ 1 < |x| := by\n  simpa only [one_pow, abs_one] using @sq_lt_sq _ _ 1 x\n#align one_lt_sq_iff_one_lt_abs one_lt_sq_iff_one_lt_abs\n\n/- warning: pow_four_le_pow_two_of_pow_two_le -> pow_four_le_pow_two_of_pow_two_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) x (OfNat.ofNat.{0} Nat 4 (OfNat.mk.{0} Nat 4 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1))))) y (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} R] {x : R} {y : R}, (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) y) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) x (OfNat.ofNat.{0} Nat 4 (instOfNatNat 4))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedRing.toLinearOrderedSemiring.{u1} R _inst_1))))))) y (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align pow_four_le_pow_two_of_pow_two_le pow_four_le_pow_two_of_pow_two_leₓ'. -/\ntheorem pow_four_le_pow_two_of_pow_two_le {x y : R} (h : x ^ 2 ≤ y) : x ^ 4 ≤ y ^ 2 :=\n  (pow_mul x 2 2).symm ▸ pow_le_pow_of_le_left (sq_nonneg x) h 2\n#align pow_four_le_pow_two_of_pow_two_le pow_four_le_pow_two_of_pow_two_le\n\nend LinearOrderedRing\n\nsection LinearOrderedCommRing\n\nvariable [LinearOrderedCommRing R]\n\n/- warning: two_mul_le_add_sq -> two_mul_le_add_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedCommRing.{u1} R] (a : R) (b : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))))))) a) b) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedCommRing.{u1} R] (a : R) (b : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (NonAssocRing.toNatCast.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u1} R _inst_1)))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u1} R _inst_1)))))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align two_mul_le_add_sq two_mul_le_add_sqₓ'. -/\n/-- Arithmetic mean-geometric mean (AM-GM) inequality for linearly ordered commutative rings. -/\ntheorem two_mul_le_add_sq (a b : R) : 2 * a * b ≤ a ^ 2 + b ^ 2 :=\n  sub_nonneg.mp ((sub_add_eq_add_sub _ _ _).subst ((sub_sq a b).subst (sq_nonneg _)))\n#align two_mul_le_add_sq two_mul_le_add_sq\n\n/- warning: two_mul_le_add_pow_two -> two_mul_le_add_pow_two is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedCommRing.{u1} R] (a : R) (b : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommGroup.toPartialOrder.{u1} R (StrictOrderedRing.toOrderedAddCommGroup.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))))))) a) b) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : LinearOrderedCommRing.{u1} R] (a : R) (b : R), LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedRing.toPartialOrder.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (NonAssocRing.toNatCast.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (StrictOrderedRing.toRing.{u1} R (LinearOrderedRing.toStrictOrderedRing.{u1} R (LinearOrderedCommRing.toLinearOrderedRing.{u1} R _inst_1))))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u1} R _inst_1)))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u1} R _inst_1)))))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align two_mul_le_add_pow_two two_mul_le_add_pow_twoₓ'. -/\nalias two_mul_le_add_sq ← two_mul_le_add_pow_two\n#align two_mul_le_add_pow_two two_mul_le_add_pow_two\n\nend LinearOrderedCommRing\n\nsection LinearOrderedCommMonoidWithZero\n\nvariable [LinearOrderedCommMonoidWithZero M] [NoZeroDivisors M] {a : M} {n : ℕ}\n\n/- warning: pow_pos_iff -> pow_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : LinearOrderedCommMonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M (LinearOrderedCommMonoidWithZero.toCommMonoidWithZero.{u1} M _inst_1))))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M (LinearOrderedCommMonoidWithZero.toCommMonoidWithZero.{u1} M _inst_1)))))] {a : M} {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M _inst_1))))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M (LinearOrderedCommMonoidWithZero.toCommMonoidWithZero.{u1} M _inst_1)))))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M (LinearOrderedCommMonoidWithZero.toCommMonoidWithZero.{u1} M _inst_1))))) a n)) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M _inst_1))))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M (LinearOrderedCommMonoidWithZero.toCommMonoidWithZero.{u1} M _inst_1)))))))) a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : LinearOrderedCommMonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M (LinearOrderedCommMonoidWithZero.toCommMonoidWithZero.{u1} M _inst_1))))) (LinearOrderedCommMonoidWithZero.toZero.{u1} M _inst_1)] {a : M} {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M _inst_1))))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (LinearOrderedCommMonoidWithZero.toZero.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M (LinearOrderedCommMonoidWithZero.toCommMonoidWithZero.{u1} M _inst_1))))) a n)) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M _inst_1))))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (LinearOrderedCommMonoidWithZero.toZero.{u1} M _inst_1))) a))\nCase conversion may be inaccurate. Consider using '#align pow_pos_iff pow_pos_iffₓ'. -/\ntheorem pow_pos_iff (hn : 0 < n) : 0 < a ^ n ↔ 0 < a := by simp_rw [zero_lt_iff, pow_ne_zero_iff hn]\n#align pow_pos_iff pow_pos_iff\n\nend LinearOrderedCommMonoidWithZero\n\nsection LinearOrderedCommGroupWithZero\n\nvariable [LinearOrderedCommGroupWithZero M] {a : M} {m n : ℕ}\n\n/- warning: pow_lt_pow_succ -> pow_lt_pow_succ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : LinearOrderedCommGroupWithZero.{u1} M] {a : M} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1))))))))) a) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a (Nat.succ n)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : LinearOrderedCommGroupWithZero.{u1} M] {a : M} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (InvOneClass.toOne.{u1} M (DivInvOneMonoid.toInvOneClass.{u1} M (DivisionMonoid.toDivInvOneMonoid.{u1} M (DivisionCommMonoid.toDivisionMonoid.{u1} M (CommGroupWithZero.toDivisionCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))))) a) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a n) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a (Nat.succ n)))\nCase conversion may be inaccurate. Consider using '#align pow_lt_pow_succ pow_lt_pow_succₓ'. -/\ntheorem pow_lt_pow_succ (ha : 1 < a) : a ^ n < a ^ n.succ :=\n  by\n  rw [← one_mul (a ^ n), pow_succ]\n  exact mul_lt_right₀ _ ha (pow_ne_zero _ (zero_lt_one.trans ha).ne')\n#align pow_lt_pow_succ pow_lt_pow_succ\n\n/- warning: pow_lt_pow₀ -> pow_lt_pow₀ is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : LinearOrderedCommGroupWithZero.{u1} M] {a : M} {m : Nat} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1))))))))) a) -> (LT.lt.{0} Nat Nat.hasLt m n) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a n))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : LinearOrderedCommGroupWithZero.{u1} M] {a : M} {m : Nat} {n : Nat}, (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (InvOneClass.toOne.{u1} M (DivInvOneMonoid.toInvOneClass.{u1} M (DivisionMonoid.toDivInvOneMonoid.{u1} M (DivisionCommMonoid.toDivisionMonoid.{u1} M (CommGroupWithZero.toDivisionCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))))) a) -> (LT.lt.{0} Nat instLTNat m n) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (LinearOrderedCommMonoid.toOrderedCommMonoid.{u1} M (LinearOrderedCommMonoidWithZero.toLinearOrderedCommMonoid.{u1} M (LinearOrderedCommGroupWithZero.toLinearOrderedCommMonoidWithZero.{u1} M _inst_1)))))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a m) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (GroupWithZero.toMonoidWithZero.{u1} M (CommGroupWithZero.toGroupWithZero.{u1} M (LinearOrderedCommGroupWithZero.toCommGroupWithZero.{u1} M _inst_1)))))) a n))\nCase conversion may be inaccurate. Consider using '#align pow_lt_pow₀ pow_lt_pow₀ₓ'. -/\ntheorem pow_lt_pow₀ (ha : 1 < a) (hmn : m < n) : a ^ m < a ^ n :=\n  by\n  induction' hmn with n hmn ih\n  exacts[pow_lt_pow_succ ha, lt_trans ih (pow_lt_pow_succ ha)]\n#align pow_lt_pow₀ pow_lt_pow₀\n\nend LinearOrderedCommGroupWithZero\n\nnamespace MonoidHom\n\nvariable [Ring R] [Monoid M] [LinearOrder M] [CovariantClass M M (· * ·) (· ≤ ·)] (f : R →* M)\n\n/- warning: monoid_hom.map_neg_one -> MonoidHom.map_neg_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {R : Type.{u2}} [_inst_1 : Ring.{u2} R] [_inst_2 : Monoid.{u1} M] [_inst_3 : LinearOrder.{u1} M] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_2)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_3))))))] (f : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)), Eq.{succ u1} M (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) (fun (_x : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) => R -> M) (MonoidHom.hasCoeToFun.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) f (Neg.neg.{u2} R (SubNegMonoid.toHasNeg.{u2} R (AddGroup.toSubNegMonoid.{u2} R (AddGroupWithOne.toAddGroup.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 1 (OfNat.mk.{u2} R 1 (One.one.{u2} R (AddMonoidWithOne.toOne.{u2} R (AddGroupWithOne.toAddMonoidWithOne.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R _inst_1))))))))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_2)))))\nbut is expected to have type\n  forall {M : Type.{u2}} {R : Type.{u1}} [_inst_1 : Ring.{u1} R] [_inst_2 : Monoid.{u2} M] [_inst_3 : LinearOrder.{u2} M] [_inst_4 : CovariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9750 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9752 : M) => HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.9750 x._@.Mathlib.Algebra.GroupPower.Order._hyg.9752) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9765 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9767 : M) => LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (SemilatticeInf.toPartialOrder.{u2} M (Lattice.toSemilatticeInf.{u2} M (DistribLattice.toLattice.{u2} M (instDistribLattice.{u2} M _inst_3)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.9765 x._@.Mathlib.Algebra.GroupPower.Order._hyg.9767)] (f : MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2) (MonoidHom.monoidHomClass.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)))) f (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))) (Monoid.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))) _inst_2)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_neg_one MonoidHom.map_neg_oneₓ'. -/\ntheorem map_neg_one : f (-1) = 1 :=\n  (pow_eq_one_iff (Nat.succ_ne_zero 1)).1 <| by rw [← map_pow, neg_one_sq, map_one]\n#align monoid_hom.map_neg_one MonoidHom.map_neg_one\n\n/- warning: monoid_hom.map_neg -> MonoidHom.map_neg is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {R : Type.{u2}} [_inst_1 : Ring.{u2} R] [_inst_2 : Monoid.{u1} M] [_inst_3 : LinearOrder.{u1} M] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_2)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_3))))))] (f : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) (x : R), Eq.{succ u1} M (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) (fun (_x : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) => R -> M) (MonoidHom.hasCoeToFun.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) f (Neg.neg.{u2} R (SubNegMonoid.toHasNeg.{u2} R (AddGroup.toSubNegMonoid.{u2} R (AddGroupWithOne.toAddGroup.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R _inst_1))))) x)) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) (fun (_x : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) => R -> M) (MonoidHom.hasCoeToFun.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) f x)\nbut is expected to have type\n  forall {M : Type.{u2}} {R : Type.{u1}} [_inst_1 : Ring.{u1} R] [_inst_2 : Monoid.{u2} M] [_inst_3 : LinearOrder.{u2} M] [_inst_4 : CovariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9858 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9860 : M) => HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.9858 x._@.Mathlib.Algebra.GroupPower.Order._hyg.9860) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9873 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9875 : M) => LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (SemilatticeInf.toPartialOrder.{u2} M (Lattice.toSemilatticeInf.{u2} M (DistribLattice.toLattice.{u2} M (instDistribLattice.{u2} M _inst_3)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.9873 x._@.Mathlib.Algebra.GroupPower.Order._hyg.9875)] (f : MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) (x : R), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) x)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2) (MonoidHom.monoidHomClass.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)))) f (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) x)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2) (MonoidHom.monoidHomClass.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)))) f x)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_neg MonoidHom.map_negₓ'. -/\n@[simp]\ntheorem map_neg (x : R) : f (-x) = f x := by rw [← neg_one_mul, map_mul, map_neg_one, one_mul]\n#align monoid_hom.map_neg MonoidHom.map_neg\n\n/- warning: monoid_hom.map_sub_swap -> MonoidHom.map_sub_swap is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {R : Type.{u2}} [_inst_1 : Ring.{u2} R] [_inst_2 : Monoid.{u1} M] [_inst_3 : LinearOrder.{u1} M] [_inst_4 : CovariantClass.{u1, u1} M M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_2)))) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (SemilatticeInf.toPartialOrder.{u1} M (Lattice.toSemilatticeInf.{u1} M (LinearOrder.toLattice.{u1} M _inst_3))))))] (f : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) (x : R) (y : R), Eq.{succ u1} M (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) (fun (_x : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) => R -> M) (MonoidHom.hasCoeToFun.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) f (HSub.hSub.{u2, u2, u2} R R R (instHSub.{u2} R (SubNegMonoid.toHasSub.{u2} R (AddGroup.toSubNegMonoid.{u2} R (AddGroupWithOne.toAddGroup.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R _inst_1)))))) x y)) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) (fun (_x : MonoidHom.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) => R -> M) (MonoidHom.hasCoeToFun.{u2, u1} R M (MulZeroOneClass.toMulOneClass.{u2} R (NonAssocSemiring.toMulZeroOneClass.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (Monoid.toMulOneClass.{u1} M _inst_2)) f (HSub.hSub.{u2, u2, u2} R R R (instHSub.{u2} R (SubNegMonoid.toHasSub.{u2} R (AddGroup.toSubNegMonoid.{u2} R (AddGroupWithOne.toAddGroup.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R _inst_1)))))) y x))\nbut is expected to have type\n  forall {M : Type.{u2}} {R : Type.{u1}} [_inst_1 : Ring.{u1} R] [_inst_2 : Monoid.{u2} M] [_inst_3 : LinearOrder.{u2} M] [_inst_4 : CovariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9960 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9962 : M) => HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.9960 x._@.Mathlib.Algebra.GroupPower.Order._hyg.9962) (fun (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9975 : M) (x._@.Mathlib.Algebra.GroupPower.Order._hyg.9977 : M) => LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (SemilatticeInf.toPartialOrder.{u2} M (Lattice.toSemilatticeInf.{u2} M (DistribLattice.toLattice.{u2} M (instDistribLattice.{u2} M _inst_3)))))) x._@.Mathlib.Algebra.GroupPower.Order._hyg.9975 x._@.Mathlib.Algebra.GroupPower.Order._hyg.9977)] (f : MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) (x : R) (y : R), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R _inst_1)) x y)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2) (MonoidHom.monoidHomClass.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)))) f (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R _inst_1)) x y)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => M) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M _inst_2)) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)) R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2) (MonoidHom.monoidHomClass.{u1, u2} R M (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (Monoid.toMulOneClass.{u2} M _inst_2)))) f (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R _inst_1)) y x))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_sub_swap MonoidHom.map_sub_swapₓ'. -/\ntheorem map_sub_swap (x y : R) : f (x - y) = f (y - x) := by rw [← map_neg, neg_sub]\n#align monoid_hom.map_sub_swap MonoidHom.map_sub_swap\n\nend MonoidHom\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/GroupPower/Order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.48551385266760677}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.integral_closure\nimport Mathlib.ring_theory.valuation.integers\nimport Mathlib.PostPort\n\nuniverses u v w \n\nnamespace Mathlib\n\n/-!\n# Integral elements over the ring of integers of a valution\n\nThe ring of integers is integrally closed inside the original ring.\n-/\n\nnamespace valuation\n\n\nnamespace integers\n\n\ntheorem mem_of_integral {R : Type u} {Γ₀ : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero Γ₀] {v : valuation R Γ₀} {O : Type w} [comm_ring O] [algebra O R] (hv : integers v O) {x : R} (hx : is_integral O x) : x ∈ integer v := sorry\n\nprotected theorem integral_closure {R : Type u} {Γ₀ : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero Γ₀] {v : valuation R Γ₀} {O : Type w} [comm_ring O] [algebra O R] (hv : integers v O) : integral_closure O R = ⊥ := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/valuation/integral.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519527944504227, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.48548755879727373}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module algebraic_geometry.gluing\n! leanprover-community/mathlib commit a9402e0a11843994283cd0a918e61fa51360e26a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.AlgebraicGeometry.PresheafedSpace.Gluing\n\n/-!\n# Gluing Schemes\n\nGiven a family of gluing data of schemes, we may glue them together.\n\n## Main definitions\n\n* `algebraic_geometry.Scheme.glue_data`: A structure containing the family of gluing data.\n* `algebraic_geometry.Scheme.glue_data.glued`: The glued scheme.\n    This is defined as the multicoequalizer of `∐ V i j ⇉ ∐ U i`, so that the general colimit API\n    can be used.\n* `algebraic_geometry.Scheme.glue_data.ι`: The immersion `ι i : U i ⟶ glued` for each `i : J`.\n* `algebraic_geometry.Scheme.glue_data.iso_carrier`: The isomorphism between the underlying space\n  of the glued scheme and the gluing of the underlying topological spaces.\n* `algebraic_geometry.Scheme.open_cover.glue_data`: The glue data associated with an open cover.\n* `algebraic_geometry.Scheme.open_cover.from_glue_data`: The canonical morphism\n  `𝒰.glue_data.glued ⟶ X`. This has an `is_iso` instance.\n* `algebraic_geometry.Scheme.open_cover.glue_morphisms`: We may glue a family of compatible\n  morphisms defined on an open cover of a scheme.\n\n## Main results\n\n* `algebraic_geometry.Scheme.glue_data.ι_is_open_immersion`: The map `ι i : U i ⟶ glued`\n  is an open immersion for each `i : J`.\n* `algebraic_geometry.Scheme.glue_data.ι_jointly_surjective` : The underlying maps of\n  `ι i : U i ⟶ glued` are jointly surjective.\n* `algebraic_geometry.Scheme.glue_data.V_pullback_cone_is_limit` : `V i j` is the pullback\n  (intersection) of `U i` and `U j` over the glued space.\n* `algebraic_geometry.Scheme.glue_data.ι_eq_iff_rel` : `ι i x = ι j y` if and only if they coincide\n  when restricted to `V i i`.\n* `algebraic_geometry.Scheme.glue_data.is_open_iff` : An subset of the glued scheme is open iff\n  all its preimages in `U i` are open.\n\n## Implementation details\n\nAll the hard work is done in `algebraic_geometry/presheafed_space/gluing.lean` where we glue\npresheafed spaces, sheafed spaces, and locally ringed spaces.\n\n-/\n\n\nnoncomputable section\n\nuniverse u\n\nopen TopologicalSpace CategoryTheory Opposite\n\nopen CategoryTheory.Limits AlgebraicGeometry.PresheafedSpace\n\nopen CategoryTheory.GlueData\n\nnamespace AlgebraicGeometry\n\nnamespace Scheme\n\n/-- A family of gluing data consists of\n1. An index type `J`\n2. An scheme `U i` for each `i : J`.\n3. An scheme `V i j` for each `i j : J`.\n  (Note that this is `J × J → Scheme` rather than `J → J → Scheme` to connect to the\n  limits library easier.)\n4. An open immersion `f i j : V i j ⟶ U i` for each `i j : ι`.\n5. A transition map `t i j : V i j ⟶ V j i` for each `i j : ι`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some\n    `t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`.\n9. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`.\n\nWe can then glue the schemes `U i` together by identifying `V i j` with `V j i`, such\nthat the `U i`'s are open subschemes of the glued space.\n-/\n@[nolint has_nonempty_instance]\nstructure GlueData extends CategoryTheory.GlueData Scheme where\n  f_open : ∀ i j, IsOpenImmersion (f i j)\n#align algebraic_geometry.Scheme.glue_data AlgebraicGeometry.Scheme.GlueData\n\nattribute [instance] glue_data.f_open\n\nnamespace GlueData\n\nvariable (D : GlueData)\n\ninclude D\n\n-- mathport name: «expr𝖣»\nlocal notation \"𝖣\" => D.toGlueData\n\n/-- The glue data of locally ringed spaces spaces associated to a family of glue data of schemes. -/\nabbrev toLocallyRingedSpaceGlueData : LocallyRingedSpace.GlueData :=\n  { f_open := D.f_open\n    toGlueData := 𝖣.mapGlueData forgetToLocallyRingedSpace }\n#align algebraic_geometry.Scheme.glue_data.to_LocallyRingedSpace_glue_data AlgebraicGeometry.Scheme.GlueData.toLocallyRingedSpaceGlueData\n\n/-- (Implementation). The glued scheme of a glue data.\nThis should not be used outside this file. Use `Scheme.glue_data.glued` instead. -/\ndef gluedScheme : Scheme :=\n  by\n  apply\n    LocallyRingedSpace.is_open_immersion.Scheme D.to_LocallyRingedSpace_glue_data.to_glue_data.glued\n  intro x\n  obtain ⟨i, y, rfl⟩ := D.to_LocallyRingedSpace_glue_data.ι_jointly_surjective x\n  refine' ⟨_, _ ≫ D.to_LocallyRingedSpace_glue_data.to_glue_data.ι i, _⟩\n  swap; exact (D.U i).affineCover.map y\n  constructor\n  · dsimp [-Set.mem_range]\n    rw [coe_comp, Set.range_comp]\n    refine' Set.mem_image_of_mem _ _\n    exact (D.U i).affineCover.Covers y\n  · infer_instance\n#align algebraic_geometry.Scheme.glue_data.glued_Scheme AlgebraicGeometry.Scheme.GlueData.gluedScheme\n\ninstance : CreatesColimit 𝖣.diagram.multispan forgetToLocallyRingedSpace :=\n  createsColimitOfFullyFaithfulOfIso D.gluedScheme\n    (HasColimit.isoOfNatIso (𝖣.diagramIso forgetToLocallyRingedSpace).symm)\n\ninstance : PreservesColimit 𝖣.diagram.multispan forgetToTop :=\n  by\n  delta forget_to_Top LocallyRingedSpace.forget_to_Top\n  infer_instance\n\ninstance : HasMulticoequalizer 𝖣.diagram :=\n  hasColimit_of_created _ forgetToLocallyRingedSpace\n\n/-- The glued scheme of a glued space. -/\nabbrev glued : Scheme :=\n  𝖣.glued\n#align algebraic_geometry.Scheme.glue_data.glued AlgebraicGeometry.Scheme.GlueData.glued\n\n/-- The immersion from `D.U i` into the glued space. -/\nabbrev ι (i : D.J) : D.U i ⟶ D.glued :=\n  𝖣.ι i\n#align algebraic_geometry.Scheme.glue_data.ι AlgebraicGeometry.Scheme.GlueData.ι\n\n/-- The gluing as sheafed spaces is isomorphic to the gluing as presheafed spaces. -/\nabbrev isoLocallyRingedSpace :\n    D.glued.toLocallyRingedSpace ≅ D.toLocallyRingedSpaceGlueData.toGlueData.glued :=\n  𝖣.gluedIso forgetToLocallyRingedSpace\n#align algebraic_geometry.Scheme.glue_data.iso_LocallyRingedSpace AlgebraicGeometry.Scheme.GlueData.isoLocallyRingedSpace\n\ntheorem ι_isoLocallyRingedSpace_inv (i : D.J) :\n    D.toLocallyRingedSpaceGlueData.toGlueData.ι i ≫ D.isoLocallyRingedSpace.inv = 𝖣.ι i :=\n  𝖣.ι_gluedIso_inv forgetToLocallyRingedSpace i\n#align algebraic_geometry.Scheme.glue_data.ι_iso_LocallyRingedSpace_inv AlgebraicGeometry.Scheme.GlueData.ι_isoLocallyRingedSpace_inv\n\ninstance ι_isOpenImmersion (i : D.J) : IsOpenImmersion (𝖣.ι i) :=\n  by\n  rw [← D.ι_iso_LocallyRingedSpace_inv]\n  infer_instance\n#align algebraic_geometry.Scheme.glue_data.ι_is_open_immersion AlgebraicGeometry.Scheme.GlueData.ι_isOpenImmersion\n\ntheorem ι_jointly_surjective (x : 𝖣.glued.carrier) :\n    ∃ (i : D.J)(y : (D.U i).carrier), (D.ι i).1.base y = x :=\n  𝖣.ι_jointly_surjective (forgetToTop ⋙ forget TopCat) x\n#align algebraic_geometry.Scheme.glue_data.ι_jointly_surjective AlgebraicGeometry.Scheme.GlueData.ι_jointly_surjective\n\n@[simp, reassoc.1]\ntheorem glue_condition (i j : D.J) : D.t i j ≫ D.f j i ≫ D.ι j = D.f i j ≫ D.ι i :=\n  𝖣.glue_condition i j\n#align algebraic_geometry.Scheme.glue_data.glue_condition AlgebraicGeometry.Scheme.GlueData.glue_condition\n\n/-- The pullback cone spanned by `V i j ⟶ U i` and `V i j ⟶ U j`.\nThis is a pullback diagram (`V_pullback_cone_is_limit`). -/\ndef vPullbackCone (i j : D.J) : PullbackCone (D.ι i) (D.ι j) :=\n  PullbackCone.mk (D.f i j) (D.t i j ≫ D.f j i) (by simp)\n#align algebraic_geometry.Scheme.glue_data.V_pullback_cone AlgebraicGeometry.Scheme.GlueData.vPullbackCone\n\n/-- The following diagram is a pullback, i.e. `Vᵢⱼ` is the intersection of `Uᵢ` and `Uⱼ` in `X`.\n\nVᵢⱼ ⟶ Uᵢ\n |      |\n ↓      ↓\n Uⱼ ⟶ X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (D.vPullbackCone i j) :=\n  𝖣.vPullbackConeIsLimitOfMap forgetToLocallyRingedSpace i j\n    (D.toLocallyRingedSpaceGlueData.vPullbackConeIsLimit _ _)\n#align algebraic_geometry.Scheme.glue_data.V_pullback_cone_is_limit AlgebraicGeometry.Scheme.GlueData.vPullbackConeIsLimit\n\n/-- The underlying topological space of the glued scheme is isomorphic to the gluing of the\nunderlying spacess -/\ndef isoCarrier :\n    D.glued.carrier ≅\n      D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toPresheafedSpaceGlueData.toTopGlueData.toGlueData.glued :=\n  by\n  refine' (PresheafedSpace.forget _).mapIso _ ≪≫ glue_data.glued_iso _ (PresheafedSpace.forget _)\n  refine'\n    SheafedSpace.forget_to_PresheafedSpace.map_iso _ ≪≫ SheafedSpace.glue_data.iso_PresheafedSpace _\n  refine'\n    LocallyRingedSpace.forget_to_SheafedSpace.map_iso _ ≪≫\n      LocallyRingedSpace.glue_data.iso_SheafedSpace _\n  exact Scheme.glue_data.iso_LocallyRingedSpace _\n#align algebraic_geometry.Scheme.glue_data.iso_carrier AlgebraicGeometry.Scheme.GlueData.isoCarrier\n\n@[simp]\ntheorem ι_isoCarrier_inv (i : D.J) :\n    D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toPresheafedSpaceGlueData.toTopGlueData.toGlueData.ι\n          i ≫\n        D.isoCarrier.inv =\n      (D.ι i).1.base :=\n  by\n  delta iso_carrier\n  simp only [functor.map_iso_inv, iso.trans_inv, iso.trans_assoc, glue_data.ι_glued_iso_inv_assoc,\n    functor.map_iso_trans, category.assoc]\n  iterate 3 erw [← comp_base]\n  simp_rw [← category.assoc]\n  rw [D.to_LocallyRingedSpace_glue_data.to_SheafedSpace_glue_data.ι_iso_PresheafedSpace_inv i]\n  erw [D.to_LocallyRingedSpace_glue_data.ι_iso_SheafedSpace_inv i]\n  change (_ ≫ D.iso_LocallyRingedSpace.inv).1.base = _\n  rw [D.ι_iso_LocallyRingedSpace_inv i]\n#align algebraic_geometry.Scheme.glue_data.ι_iso_carrier_inv AlgebraicGeometry.Scheme.GlueData.ι_isoCarrier_inv\n\n/-- An equivalence relation on `Σ i, D.U i` that holds iff `𝖣 .ι i x = 𝖣 .ι j y`.\nSee `Scheme.gluing_data.ι_eq_iff`. -/\ndef Rel (a b : Σi, ((D.U i).carrier : Type _)) : Prop :=\n  a = b ∨\n    ∃ x : (D.V (a.1, b.1)).carrier, (D.f _ _).1.base x = a.2 ∧ (D.t _ _ ≫ D.f _ _).1.base x = b.2\n#align algebraic_geometry.Scheme.glue_data.rel AlgebraicGeometry.Scheme.GlueData.Rel\n\ntheorem ι_eq_iff (i j : D.J) (x : (D.U i).carrier) (y : (D.U j).carrier) :\n    (𝖣.ι i).1.base x = (𝖣.ι j).1.base y ↔ D.Rel ⟨i, x⟩ ⟨j, y⟩ :=\n  by\n  refine'\n    Iff.trans _\n      (D.to_LocallyRingedSpace_glue_data.to_SheafedSpace_glue_data.toPresheafedSpaceGlueData.toTopGlueData.ι_eq_iff_rel\n        i j x y)\n  rw [← ((TopCat.mono_iff_injective D.iso_carrier.inv).mp inferInstance).eq_iff]\n  simp_rw [← comp_apply, D.ι_iso_carrier_inv]\n#align algebraic_geometry.Scheme.glue_data.ι_eq_iff AlgebraicGeometry.Scheme.GlueData.ι_eq_iff\n\ntheorem isOpen_iff (U : Set D.glued.carrier) : IsOpen U ↔ ∀ i, IsOpen ((D.ι i).1.base ⁻¹' U) :=\n  by\n  rw [← (TopCat.homeoOfIso D.iso_carrier.symm).isOpen_preimage]\n  rw [TopCat.GlueData.isOpen_iff]\n  apply forall_congr'\n  intro i\n  erw [← Set.preimage_comp, ← coe_comp, ι_iso_carrier_inv]\n#align algebraic_geometry.Scheme.glue_data.is_open_iff AlgebraicGeometry.Scheme.GlueData.isOpen_iff\n\n/-- The open cover of the glued space given by the glue data. -/\ndef openCover (D : Scheme.GlueData) : OpenCover D.glued\n    where\n  J := D.J\n  obj := D.U\n  map := D.ι\n  f x := (D.ι_jointly_surjective x).some\n  Covers x := ⟨_, (D.ι_jointly_surjective x).choose_spec.choose_spec⟩\n#align algebraic_geometry.Scheme.glue_data.open_cover AlgebraicGeometry.Scheme.GlueData.openCover\n\nend GlueData\n\nnamespace OpenCover\n\nvariable {X : Scheme.{u}} (𝒰 : OpenCover.{u} X)\n\n/-- (Implementation) the transition maps in the glue data associated with an open cover. -/\ndef gluedCoverT' (x y z : 𝒰.J) :\n    pullback (pullback.fst : pullback (𝒰.map x) (𝒰.map y) ⟶ _)\n        (pullback.fst : pullback (𝒰.map x) (𝒰.map z) ⟶ _) ⟶\n      pullback (pullback.fst : pullback (𝒰.map y) (𝒰.map z) ⟶ _)\n        (pullback.fst : pullback (𝒰.map y) (𝒰.map x) ⟶ _) :=\n  by\n  refine' (pullback_right_pullback_fst_iso _ _ _).Hom ≫ _\n  refine' _ ≫ (pullback_symmetry _ _).Hom\n  refine' _ ≫ (pullback_right_pullback_fst_iso _ _ _).inv\n  refine' pullback.map _ _ _ _ (pullback_symmetry _ _).Hom (𝟙 _) (𝟙 _) _ _\n  · simp [pullback.condition]\n  · simp\n#align algebraic_geometry.Scheme.open_cover.glued_cover_t' AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'\n\n@[simp, reassoc.1]\ntheorem gluedCoverT'_fst_fst (x y z : 𝒰.J) :\n    𝒰.gluedCoverT' x y z ≫ pullback.fst ≫ pullback.fst = pullback.fst ≫ pullback.snd :=\n  by\n  delta glued_cover_t'\n  simp\n#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_fst_fst AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_fst_fst\n\n@[simp, reassoc.1]\ntheorem gluedCoverT'_fst_snd (x y z : 𝒰.J) :\n    gluedCoverT' 𝒰 x y z ≫ pullback.fst ≫ pullback.snd = pullback.snd ≫ pullback.snd :=\n  by\n  delta glued_cover_t'\n  simp\n#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_fst_snd AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_fst_snd\n\n@[simp, reassoc.1]\ntheorem gluedCoverT'_snd_fst (x y z : 𝒰.J) :\n    gluedCoverT' 𝒰 x y z ≫ pullback.snd ≫ pullback.fst = pullback.fst ≫ pullback.snd :=\n  by\n  delta glued_cover_t'\n  simp\n#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_snd_fst AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_snd_fst\n\n@[simp, reassoc.1]\ntheorem gluedCoverT'_snd_snd (x y z : 𝒰.J) :\n    gluedCoverT' 𝒰 x y z ≫ pullback.snd ≫ pullback.snd = pullback.fst ≫ pullback.fst :=\n  by\n  delta glued_cover_t'\n  simp\n#align algebraic_geometry.Scheme.open_cover.glued_cover_t'_snd_snd AlgebraicGeometry.Scheme.OpenCover.gluedCoverT'_snd_snd\n\ntheorem glued_cover_cocycle_fst (x y z : 𝒰.J) :\n    gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y ≫ pullback.fst =\n      pullback.fst :=\n  by apply pullback.hom_ext <;> simp\n#align algebraic_geometry.Scheme.open_cover.glued_cover_cocycle_fst AlgebraicGeometry.Scheme.OpenCover.glued_cover_cocycle_fst\n\ntheorem glued_cover_cocycle_snd (x y z : 𝒰.J) :\n    gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y ≫ pullback.snd =\n      pullback.snd :=\n  by apply pullback.hom_ext <;> simp [pullback.condition]\n#align algebraic_geometry.Scheme.open_cover.glued_cover_cocycle_snd AlgebraicGeometry.Scheme.OpenCover.glued_cover_cocycle_snd\n\ntheorem glued_cover_cocycle (x y z : 𝒰.J) :\n    gluedCoverT' 𝒰 x y z ≫ gluedCoverT' 𝒰 y z x ≫ gluedCoverT' 𝒰 z x y = 𝟙 _ :=\n  by\n  apply pullback.hom_ext <;> simp_rw [category.id_comp, category.assoc]\n  apply glued_cover_cocycle_fst\n  apply glued_cover_cocycle_snd\n#align algebraic_geometry.Scheme.open_cover.glued_cover_cocycle AlgebraicGeometry.Scheme.OpenCover.glued_cover_cocycle\n\n/-- The glue data associated with an open cover.\nThe canonical isomorphism `𝒰.glued_cover.glued ⟶ X` is provided by `𝒰.from_glued`. -/\n@[simps]\ndef gluedCover : Scheme.GlueData.{u} where\n  J := 𝒰.J\n  U := 𝒰.obj\n  V := fun ⟨x, y⟩ => pullback (𝒰.map x) (𝒰.map y)\n  f x y := pullback.fst\n  f_id x := inferInstance\n  t x y := (pullbackSymmetry _ _).Hom\n  t_id x := by simpa\n  t' x y z := gluedCoverT' 𝒰 x y z\n  t_fac x y z := by apply pullback.hom_ext <;> simp\n  -- The `cocycle` field could have been `by tidy` but lean timeouts.\n  cocycle x y z := glued_cover_cocycle 𝒰 x y z\n  f_open x := inferInstance\n#align algebraic_geometry.Scheme.open_cover.glued_cover AlgebraicGeometry.Scheme.OpenCover.gluedCover\n\n/-- The canonical morphism from the gluing of an open cover of `X` into `X`.\nThis is an isomorphism, as witnessed by an `is_iso` instance. -/\ndef fromGlued : 𝒰.gluedCover.glued ⟶ X :=\n  by\n  fapply multicoequalizer.desc\n  exact fun x => 𝒰.map x\n  rintro ⟨x, y⟩\n  change pullback.fst ≫ _ = ((pullback_symmetry _ _).Hom ≫ pullback.fst) ≫ _\n  simpa using pullback.condition\n#align algebraic_geometry.Scheme.open_cover.from_glued AlgebraicGeometry.Scheme.OpenCover.fromGlued\n\n@[simp, reassoc.1]\ntheorem ι_fromGlued (x : 𝒰.J) : 𝒰.gluedCover.ι x ≫ 𝒰.fromGlued = 𝒰.map x :=\n  Multicoequalizer.π_desc _ _ _ _ _\n#align algebraic_geometry.Scheme.open_cover.ι_from_glued AlgebraicGeometry.Scheme.OpenCover.ι_fromGlued\n\ntheorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base :=\n  by\n  intro x y h\n  obtain ⟨i, x, rfl⟩ := 𝒰.glued_cover.ι_jointly_surjective x\n  obtain ⟨j, y, rfl⟩ := 𝒰.glued_cover.ι_jointly_surjective y\n  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h\n  erw [ι_from_glued, ι_from_glued] at h\n  let e :=\n    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso\n      (is_limit_of_has_pullback_of_preserves_limit Scheme.forget_to_Top (𝒰.map i) (𝒰.map j))\n  rw [𝒰.glued_cover.ι_eq_iff]\n  right\n  use e.hom ⟨⟨x, y⟩, h⟩\n  simp_rw [← comp_apply]\n  constructor\n  · erw [is_limit.cone_point_unique_up_to_iso_hom_comp _ _ walking_cospan.left]\n    rfl\n  · erw [pullback_symmetry_hom_comp_fst,\n      is_limit.cone_point_unique_up_to_iso_hom_comp _ _ walking_cospan.right]\n    rfl\n#align algebraic_geometry.Scheme.open_cover.from_glued_injective AlgebraicGeometry.Scheme.OpenCover.fromGlued_injective\n\ninstance fromGlued_stalk_iso (x : 𝒰.gluedCover.glued.carrier) :\n    IsIso (PresheafedSpace.stalkMap 𝒰.fromGlued.val x) :=\n  by\n  obtain ⟨i, x, rfl⟩ := 𝒰.glued_cover.ι_jointly_surjective x\n  have :=\n    PresheafedSpace.stalk_map.congr_hom _ _\n      (congr_arg LocallyRingedSpace.hom.val <| 𝒰.ι_from_glued i) x\n  erw [PresheafedSpace.stalk_map.comp] at this\n  rw [← is_iso.eq_comp_inv] at this\n  rw [this]\n  infer_instance\n#align algebraic_geometry.Scheme.open_cover.from_glued_stalk_iso AlgebraicGeometry.Scheme.OpenCover.fromGlued_stalk_iso\n\ntheorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base :=\n  by\n  intro U hU\n  rw [isOpen_iff_forall_mem_open]\n  intro x hx\n  rw [𝒰.glued_cover.is_open_iff] at hU\n  use 𝒰.from_glued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base\n  use Set.inter_subset_left _ _\n  constructor\n  · rw [← Set.image_preimage_eq_inter_range]\n    apply show is_open_immersion (𝒰.map (𝒰.f x)) by infer_instance.base_open.IsOpenMap\n    convert hU (𝒰.f x) using 1\n    rw [← ι_from_glued]\n    erw [coe_comp]\n    rw [Set.preimage_comp]\n    congr 1\n    refine' Set.preimage_image_eq _ 𝒰.from_glued_injective\n  · exact ⟨hx, 𝒰.covers x⟩\n#align algebraic_geometry.Scheme.open_cover.from_glued_open_map AlgebraicGeometry.Scheme.OpenCover.fromGlued_open_map\n\ntheorem fromGlued_openEmbedding : OpenEmbedding 𝒰.fromGlued.1.base :=\n  openEmbedding_of_continuous_injective_open (by continuity) 𝒰.fromGlued_injective\n    𝒰.fromGlued_open_map\n#align algebraic_geometry.Scheme.open_cover.from_glued_open_embedding AlgebraicGeometry.Scheme.OpenCover.fromGlued_openEmbedding\n\ninstance : Epi 𝒰.fromGlued.val.base :=\n  by\n  rw [TopCat.epi_iff_surjective]\n  intro x\n  obtain ⟨y, h⟩ := 𝒰.covers x\n  use (𝒰.glued_cover.ι (𝒰.f x)).1.base y\n  rw [← comp_apply]\n  rw [← 𝒰.ι_from_glued (𝒰.f x)] at h\n  exact h\n\ninstance fromGlued_open_immersion : IsOpenImmersion 𝒰.fromGlued :=\n  SheafedSpace.IsOpenImmersion.of_stalk_iso _ 𝒰.fromGlued_openEmbedding\n#align algebraic_geometry.Scheme.open_cover.from_glued_open_immersion AlgebraicGeometry.Scheme.OpenCover.fromGlued_open_immersion\n\ninstance : IsIso 𝒰.fromGlued :=\n  by\n  apply\n    is_iso_of_reflects_iso _\n      (Scheme.forget_to_LocallyRingedSpace ⋙\n        LocallyRingedSpace.forget_to_SheafedSpace ⋙ SheafedSpace.forget_to_PresheafedSpace)\n  change @is_iso (PresheafedSpace _) _ _ _ 𝒰.from_glued.val\n  apply PresheafedSpace.is_open_immersion.to_iso\n\n/-- Given an open cover of `X`, and a morphism `𝒰.obj x ⟶ Y` for each open subscheme in the cover,\nsuch that these morphisms are compatible in the intersection (pullback), we may glue the morphisms\ntogether into a morphism `X ⟶ Y`.\n\nNote:\nIf `X` is exactly (defeq to) the gluing of `U i`, then using `multicoequalizer.desc` suffices.\n-/\ndef glueMorphisms {Y : Scheme} (f : ∀ x, 𝒰.obj x ⟶ Y)\n    (hf : ∀ x y, (pullback.fst : pullback (𝒰.map x) (𝒰.map y) ⟶ _) ≫ f x = pullback.snd ≫ f y) :\n    X ⟶ Y := by\n  refine' inv 𝒰.from_glued ≫ _\n  fapply multicoequalizer.desc\n  exact f\n  rintro ⟨i, j⟩\n  change pullback.fst ≫ f i = (_ ≫ _) ≫ f j\n  erw [pullback_symmetry_hom_comp_fst]\n  exact hf i j\n#align algebraic_geometry.Scheme.open_cover.glue_morphisms AlgebraicGeometry.Scheme.OpenCover.glueMorphisms\n\n@[simp, reassoc.1]\ntheorem ι_glueMorphisms {Y : Scheme} (f : ∀ x, 𝒰.obj x ⟶ Y)\n    (hf : ∀ x y, (pullback.fst : pullback (𝒰.map x) (𝒰.map y) ⟶ _) ≫ f x = pullback.snd ≫ f y)\n    (x : 𝒰.J) : 𝒰.map x ≫ 𝒰.glueMorphisms f hf = f x :=\n  by\n  rw [← ι_from_glued, category.assoc]\n  erw [is_iso.hom_inv_id_assoc, multicoequalizer.π_desc]\n#align algebraic_geometry.Scheme.open_cover.ι_glue_morphisms AlgebraicGeometry.Scheme.OpenCover.ι_glueMorphisms\n\ntheorem hom_ext {Y : Scheme} (f₁ f₂ : X ⟶ Y) (h : ∀ x, 𝒰.map x ≫ f₁ = 𝒰.map x ≫ f₂) : f₁ = f₂ :=\n  by\n  rw [← cancel_epi 𝒰.from_glued]\n  apply multicoequalizer.hom_ext\n  intro x\n  erw [multicoequalizer.π_desc_assoc]\n  erw [multicoequalizer.π_desc_assoc]\n  exact h x\n#align algebraic_geometry.Scheme.open_cover.hom_ext AlgebraicGeometry.Scheme.OpenCover.hom_ext\n\nend OpenCover\n\nend Scheme\n\nend AlgebraicGeometry\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/AlgebraicGeometry/Gluing.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4854702552330544}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\n! This file was ported from Lean 3 source module algebra.polynomial.group_ring_action\n! leanprover-community/mathlib commit 10bf4f825ad729c5653adc039dafa3622e7f93c9\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GroupRingAction.Basic\nimport Mathbin.Algebra.Hom.GroupAction\nimport Mathbin.Data.Polynomial.AlgebraMap\nimport Mathbin.Data.Polynomial.Monic\nimport Mathbin.GroupTheory.GroupAction.Quotient\n\n/-!\n# Group action on rings applied to polynomials\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains instances and definitions relating `mul_semiring_action` to `polynomial`.\n-/\n\n\nvariable (M : Type _) [Monoid M]\n\nopen Polynomial\n\nnamespace Polynomial\n\nvariable (R : Type _) [Semiring R]\n\nvariable {M}\n\n/- warning: polynomial.smul_eq_map -> Polynomial.smul_eq_map is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (R : Type.{u2}) [_inst_2 : Semiring.{u2} R] [_inst_3 : MulSemiringAction.{u1, u2} M R _inst_1 _inst_2] (m : M), Eq.{succ u2} ((Polynomial.{u2} R _inst_2) -> (Polynomial.{u2} R _inst_2)) (SMul.smul.{u1, u2} M (Polynomial.{u2} R _inst_2) (SMulZeroClass.toHasSmul.{u1, u2} M (Polynomial.{u2} R _inst_2) (Polynomial.zero.{u2} R _inst_2) (Polynomial.smulZeroClass.{u2, u1} R _inst_2 M (DistribSMul.toSmulZeroClass.{u1, u2} M R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} M R _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_2)))) (MulSemiringAction.toDistribMulAction.{u1, u2} M R _inst_1 _inst_2 _inst_3))))) m) (Polynomial.map.{u2, u2} R R _inst_2 _inst_2 (MulSemiringAction.toRingHom.{u2, u1} M _inst_1 R _inst_2 _inst_3 m))\nbut is expected to have type\n  forall {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] (R : Type.{u1}) [_inst_2 : Semiring.{u1} R] [_inst_3 : MulSemiringAction.{u2, u1} M R _inst_1 _inst_2] (m : M), Eq.{succ u1} ((Polynomial.{u1} R _inst_2) -> (Polynomial.{u1} R _inst_2)) (HSMul.hSMul.{u2, u1, u1} M (Polynomial.{u1} R _inst_2) (Polynomial.{u1} R _inst_2) (instHSMul.{u2, u1} M (Polynomial.{u1} R _inst_2) (SMulZeroClass.toSMul.{u2, u1} M (Polynomial.{u1} R _inst_2) (Polynomial.zero.{u1} R _inst_2) (Polynomial.smulZeroClass.{u1, u2} R _inst_2 M (DistribSMul.toSMulZeroClass.{u2, u1} M R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_2))))) (DistribMulAction.toDistribSMul.{u2, u1} M R _inst_1 (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_2)))) (MulSemiringAction.toDistribMulAction.{u2, u1} M R _inst_1 _inst_2 _inst_3)))))) m) (Polynomial.map.{u1, u1} R R _inst_2 _inst_2 (MulSemiringAction.toRingHom.{u1, u2} M _inst_1 R _inst_2 _inst_3 m))\nCase conversion may be inaccurate. Consider using '#align polynomial.smul_eq_map Polynomial.smul_eq_mapₓ'. -/\ntheorem smul_eq_map [MulSemiringAction M R] (m : M) :\n    (· • ·) m = map (MulSemiringAction.toRingHom M R m) :=\n  by\n  suffices\n    DistribMulAction.toAddMonoidHom R[X] m =\n      (map_ring_hom (MulSemiringAction.toRingHom M R m)).toAddMonoidHom\n    by\n    ext1 r\n    exact AddMonoidHom.congr_fun this r\n  ext (n r) : 2\n  change m • monomial n r = map (MulSemiringAction.toRingHom M R m) (monomial n r)\n  simpa only [Polynomial.map_monomial, Polynomial.smul_monomial]\n#align polynomial.smul_eq_map Polynomial.smul_eq_map\n\nvariable (M)\n\nnoncomputable instance [MulSemiringAction M R] : MulSemiringAction M R[X] :=\n  { Polynomial.distribMulAction with\n    smul := (· • ·)\n    smul_one := fun m =>\n      (smul_eq_map R m).symm ▸ Polynomial.map_one (MulSemiringAction.toRingHom M R m)\n    smul_mul := fun m p q =>\n      (smul_eq_map R m).symm ▸ Polynomial.map_mul (MulSemiringAction.toRingHom M R m) }\n\nvariable {M R}\n\nvariable [MulSemiringAction M R]\n\n/- warning: polynomial.smul_X -> Polynomial.smul_X is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {R : Type.{u2}} [_inst_2 : Semiring.{u2} R] [_inst_3 : MulSemiringAction.{u1, u2} M R _inst_1 _inst_2] (m : M), Eq.{succ u2} (Polynomial.{u2} R _inst_2) (SMul.smul.{u1, u2} M (Polynomial.{u2} R _inst_2) (SMulZeroClass.toHasSmul.{u1, u2} M (Polynomial.{u2} R _inst_2) (Polynomial.zero.{u2} R _inst_2) (Polynomial.smulZeroClass.{u2, u1} R _inst_2 M (DistribSMul.toSmulZeroClass.{u1, u2} M R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} M R _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_2)))) (MulSemiringAction.toDistribMulAction.{u1, u2} M R _inst_1 _inst_2 _inst_3))))) m (Polynomial.X.{u2} R _inst_2)) (Polynomial.X.{u2} R _inst_2)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {R : Type.{u2}} [_inst_2 : Semiring.{u2} R] [_inst_3 : MulSemiringAction.{u1, u2} M R _inst_1 _inst_2] (m : M), Eq.{succ u2} (Polynomial.{u2} R _inst_2) (HSMul.hSMul.{u1, u2, u2} M (Polynomial.{u2} R _inst_2) (Polynomial.{u2} R _inst_2) (instHSMul.{u1, u2} M (Polynomial.{u2} R _inst_2) (SMulZeroClass.toSMul.{u1, u2} M (Polynomial.{u2} R _inst_2) (Polynomial.zero.{u2} R _inst_2) (Polynomial.smulZeroClass.{u2, u1} R _inst_2 M (DistribSMul.toSMulZeroClass.{u1, u2} M R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} M R _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_2)))) (MulSemiringAction.toDistribMulAction.{u1, u2} M R _inst_1 _inst_2 _inst_3)))))) m (Polynomial.X.{u2} R _inst_2)) (Polynomial.X.{u2} R _inst_2)\nCase conversion may be inaccurate. Consider using '#align polynomial.smul_X Polynomial.smul_Xₓ'. -/\n@[simp]\ntheorem smul_X (m : M) : (m • X : R[X]) = X :=\n  (smul_eq_map R m).symm ▸ map_X _\n#align polynomial.smul_X Polynomial.smul_X\n\nvariable (S : Type _) [CommSemiring S] [MulSemiringAction M S]\n\n/- warning: polynomial.smul_eval_smul -> Polynomial.smul_eval_smul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Type.{u2}) [_inst_4 : CommSemiring.{u2} S] [_inst_5 : MulSemiringAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4)] (m : M) (f : Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (x : S), Eq.{succ u2} S (Polynomial.eval.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4) (SMul.smul.{u1, u2} M S (SMulZeroClass.toHasSmul.{u1, u2} M S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))))) (DistribSMul.toSmulZeroClass.{u1, u2} M S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} M S _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4) _inst_5)))) m x) (SMul.smul.{u1, u2} M (Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (SMulZeroClass.toHasSmul.{u1, u2} M (Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (Polynomial.zero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (Polynomial.smulZeroClass.{u2, u1} S (CommSemiring.toSemiring.{u2} S _inst_4) M (DistribSMul.toSmulZeroClass.{u1, u2} M S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} M S _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4) _inst_5))))) m f)) (SMul.smul.{u1, u2} M S (SMulZeroClass.toHasSmul.{u1, u2} M S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))))) (DistribSMul.toSmulZeroClass.{u1, u2} M S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} M S _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4) _inst_5)))) m (Polynomial.eval.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4) x f))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Type.{u2}) [_inst_4 : CommSemiring.{u2} S] [_inst_5 : MulSemiringAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4)] (m : M) (f : Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (x : S), Eq.{succ u2} S (Polynomial.eval.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4) (HSMul.hSMul.{u1, u2, u2} M S S (instHSMul.{u1, u2} M S (SMulZeroClass.toSMul.{u1, u2} M S (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_4)) (DistribSMul.toSMulZeroClass.{u1, u2} M S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} M S _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4) _inst_5))))) m x) (HSMul.hSMul.{u1, u2, u2} M (Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (instHSMul.{u1, u2} M (Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (SMulZeroClass.toSMul.{u1, u2} M (Polynomial.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (Polynomial.zero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)) (Polynomial.smulZeroClass.{u2, u1} S (CommSemiring.toSemiring.{u2} S _inst_4) M (DistribSMul.toSMulZeroClass.{u1, u2} M S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} M S _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4) _inst_5)))))) m f)) (HSMul.hSMul.{u1, u2, u2} M S S (instHSMul.{u1, u2} M S (SMulZeroClass.toSMul.{u1, u2} M S (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_4)) (DistribSMul.toSMulZeroClass.{u1, u2} M S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} M S _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u1, u2} M S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_4) _inst_5))))) m (Polynomial.eval.{u2} S (CommSemiring.toSemiring.{u2} S _inst_4) x f))\nCase conversion may be inaccurate. Consider using '#align polynomial.smul_eval_smul Polynomial.smul_eval_smulₓ'. -/\ntheorem smul_eval_smul (m : M) (f : S[X]) (x : S) : (m • f).eval (m • x) = m • f.eval x :=\n  Polynomial.induction_on f (fun r => by rw [smul_C, eval_C, eval_C])\n    (fun f g ihf ihg => by rw [smul_add, eval_add, ihf, ihg, eval_add, smul_add]) fun n r ih => by\n    rw [smul_mul', smul_pow', smul_C, smul_X, eval_mul, eval_C, eval_pow, eval_X, eval_mul, eval_C,\n      eval_pow, eval_X, smul_mul', smul_pow']\n#align polynomial.smul_eval_smul Polynomial.smul_eval_smul\n\nvariable (G : Type _) [Group G]\n\n/- warning: polynomial.eval_smul' -> Polynomial.eval_smul' is a dubious translation:\nlean 3 declaration is\n  forall (S : Type.{u1}) [_inst_4 : CommSemiring.{u1} S] (G : Type.{u2}) [_inst_6 : Group.{u2} G] [_inst_7 : MulSemiringAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4)] (g : G) (f : Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (x : S), Eq.{succ u1} S (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) (SMul.smul.{u2, u1} G S (SMulZeroClass.toHasSmul.{u2, u1} G S (AddZeroClass.toHasZero.{u1} S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))))) (DistribSMul.toSmulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7)))) g x) f) (SMul.smul.{u2, u1} G S (SMulZeroClass.toHasSmul.{u2, u1} G S (AddZeroClass.toHasZero.{u1} S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))))) (DistribSMul.toSmulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7)))) g (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) x (SMul.smul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (SMulZeroClass.toHasSmul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.zero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.smulZeroClass.{u1, u2} S (CommSemiring.toSemiring.{u1} S _inst_4) G (DistribSMul.toSmulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7))))) (Inv.inv.{u2} G (DivInvMonoid.toHasInv.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) g) f)))\nbut is expected to have type\n  forall (S : Type.{u1}) [_inst_4 : CommSemiring.{u1} S] (G : Type.{u2}) [_inst_6 : Group.{u2} G] [_inst_7 : MulSemiringAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4)] (g : G) (f : Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (x : S), Eq.{succ u1} S (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) (HSMul.hSMul.{u2, u1, u1} G S S (instHSMul.{u2, u1} G S (SMulZeroClass.toSMul.{u2, u1} G S (CommMonoidWithZero.toZero.{u1} S (CommSemiring.toCommMonoidWithZero.{u1} S _inst_4)) (DistribSMul.toSMulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7))))) g x) f) (HSMul.hSMul.{u2, u1, u1} G S S (instHSMul.{u2, u1} G S (SMulZeroClass.toSMul.{u2, u1} G S (CommMonoidWithZero.toZero.{u1} S (CommSemiring.toCommMonoidWithZero.{u1} S _inst_4)) (DistribSMul.toSMulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7))))) g (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) x (HSMul.hSMul.{u2, u1, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (instHSMul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (SMulZeroClass.toSMul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.zero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.smulZeroClass.{u1, u2} S (CommSemiring.toSemiring.{u1} S _inst_4) G (DistribSMul.toSMulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7)))))) (Inv.inv.{u2} G (InvOneClass.toInv.{u2} G (DivInvOneMonoid.toInvOneClass.{u2} G (DivisionMonoid.toDivInvOneMonoid.{u2} G (Group.toDivisionMonoid.{u2} G _inst_6)))) g) f)))\nCase conversion may be inaccurate. Consider using '#align polynomial.eval_smul' Polynomial.eval_smul'ₓ'. -/\ntheorem eval_smul' [MulSemiringAction G S] (g : G) (f : S[X]) (x : S) :\n    f.eval (g • x) = g • (g⁻¹ • f).eval x := by rw [← smul_eval_smul, smul_inv_smul]\n#align polynomial.eval_smul' Polynomial.eval_smul'\n\n/- warning: polynomial.smul_eval -> Polynomial.smul_eval is a dubious translation:\nlean 3 declaration is\n  forall (S : Type.{u1}) [_inst_4 : CommSemiring.{u1} S] (G : Type.{u2}) [_inst_6 : Group.{u2} G] [_inst_7 : MulSemiringAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4)] (g : G) (f : Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (x : S), Eq.{succ u1} S (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) x (SMul.smul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (SMulZeroClass.toHasSmul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.zero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.smulZeroClass.{u1, u2} S (CommSemiring.toSemiring.{u1} S _inst_4) G (DistribSMul.toSmulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7))))) g f)) (SMul.smul.{u2, u1} G S (SMulZeroClass.toHasSmul.{u2, u1} G S (AddZeroClass.toHasZero.{u1} S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))))) (DistribSMul.toSmulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7)))) g (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) (SMul.smul.{u2, u1} G S (SMulZeroClass.toHasSmul.{u2, u1} G S (AddZeroClass.toHasZero.{u1} S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))))) (DistribSMul.toSmulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7)))) (Inv.inv.{u2} G (DivInvMonoid.toHasInv.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) g) x) f))\nbut is expected to have type\n  forall (S : Type.{u1}) [_inst_4 : CommSemiring.{u1} S] (G : Type.{u2}) [_inst_6 : Group.{u2} G] [_inst_7 : MulSemiringAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4)] (g : G) (f : Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (x : S), Eq.{succ u1} S (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) x (HSMul.hSMul.{u2, u1, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (instHSMul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (SMulZeroClass.toSMul.{u2, u1} G (Polynomial.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.zero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)) (Polynomial.smulZeroClass.{u1, u2} S (CommSemiring.toSemiring.{u1} S _inst_4) G (DistribSMul.toSMulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7)))))) g f)) (HSMul.hSMul.{u2, u1, u1} G S S (instHSMul.{u2, u1} G S (SMulZeroClass.toSMul.{u2, u1} G S (CommMonoidWithZero.toZero.{u1} S (CommSemiring.toCommMonoidWithZero.{u1} S _inst_4)) (DistribSMul.toSMulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7))))) g (Polynomial.eval.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4) (HSMul.hSMul.{u2, u1, u1} G S S (instHSMul.{u2, u1} G S (SMulZeroClass.toSMul.{u2, u1} G S (CommMonoidWithZero.toZero.{u1} S (CommSemiring.toCommMonoidWithZero.{u1} S _inst_4)) (DistribSMul.toSMulZeroClass.{u2, u1} G S (AddMonoid.toAddZeroClass.{u1} S (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4)))))) (DistribMulAction.toDistribSMul.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (AddMonoidWithOne.toAddMonoid.{u1} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} S (NonAssocSemiring.toAddCommMonoidWithOne.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_4))))) (MulSemiringAction.toDistribMulAction.{u2, u1} G S (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_6)) (CommSemiring.toSemiring.{u1} S _inst_4) _inst_7))))) (Inv.inv.{u2} G (InvOneClass.toInv.{u2} G (DivInvOneMonoid.toInvOneClass.{u2} G (DivisionMonoid.toDivInvOneMonoid.{u2} G (Group.toDivisionMonoid.{u2} G _inst_6)))) g) x) f))\nCase conversion may be inaccurate. Consider using '#align polynomial.smul_eval Polynomial.smul_evalₓ'. -/\ntheorem smul_eval [MulSemiringAction G S] (g : G) (f : S[X]) (x : S) :\n    (g • f).eval x = g • f.eval (g⁻¹ • x) := by rw [← smul_eval_smul, smul_inv_smul]\n#align polynomial.smul_eval Polynomial.smul_eval\n\nend Polynomial\n\nsection CommRing\n\nvariable (G : Type _) [Group G] [Fintype G]\n\nvariable (R : Type _) [CommRing R] [MulSemiringAction G R]\n\nopen MulAction\n\nopen Classical\n\n#print prodXSubSmul /-\n/-- the product of `(X - g • x)` over distinct `g • x`. -/\nnoncomputable def prodXSubSmul (x : R) : R[X] :=\n  (Finset.univ : Finset (G ⧸ MulAction.stabilizer G x)).Prod fun g =>\n    Polynomial.X - Polynomial.C (ofQuotientStabilizer G x g)\n#align prod_X_sub_smul prodXSubSmul\n-/\n\n#print prodXSubSmul.monic /-\ntheorem prodXSubSmul.monic (x : R) : (prodXSubSmul G R x).Monic :=\n  Polynomial.monic_prod_of_monic _ _ fun g _ => Polynomial.monic_X_sub_C _\n#align prod_X_sub_smul.monic prodXSubSmul.monic\n-/\n\n/- warning: prod_X_sub_smul.eval -> prodXSubSmul.eval is a dubious translation:\nlean 3 declaration is\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_3 : Fintype.{u1} G] (R : Type.{u2}) [_inst_4 : CommRing.{u2} R] [_inst_5 : MulSemiringAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))] (x : R), Eq.{succ u2} R (Polynomial.eval.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) x (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x)) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} R (NonAssocRing.toNonUnitalNonAssocRing.{u2} R (Ring.toNonAssocRing.{u2} R (CommRing.toRing.{u2} R _inst_4)))))))))\nbut is expected to have type\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_3 : Fintype.{u1} G] (R : Type.{u2}) [_inst_4 : CommRing.{u2} R] [_inst_5 : MulSemiringAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))] (x : R), Eq.{succ u2} R (Polynomial.eval.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) x (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x)) (OfNat.ofNat.{u2} R 0 (Zero.toOfNat0.{u2} R (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_4)))))\nCase conversion may be inaccurate. Consider using '#align prod_X_sub_smul.eval prodXSubSmul.evalₓ'. -/\ntheorem prodXSubSmul.eval (x : R) : (prodXSubSmul G R x).eval x = 0 :=\n  (MonoidHom.map_prod ((Polynomial.aeval x).toRingHom.toMonoidHom : R[X] →* R) _ _).trans <|\n    Finset.prod_eq_zero (Finset.mem_univ <| QuotientGroup.mk 1) <| by simp\n#align prod_X_sub_smul.eval prodXSubSmul.eval\n\n/- warning: prod_X_sub_smul.smul -> prodXSubSmul.smul is a dubious translation:\nlean 3 declaration is\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_3 : Fintype.{u1} G] (R : Type.{u2}) [_inst_4 : CommRing.{u2} R] [_inst_5 : MulSemiringAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))] (x : R) (g : G), Eq.{succ u2} (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (SMul.smul.{u1, u2} G (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (SMulZeroClass.toHasSmul.{u1, u2} G (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (Polynomial.zero.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (Polynomial.smulZeroClass.{u2, u1} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) G (DistribSMul.toSmulZeroClass.{u1, u2} G R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddGroupWithOne.toAddMonoidWithOne.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R (CommRing.toRing.{u2} R _inst_4)))))) (DistribMulAction.toDistribSMul.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (AddMonoidWithOne.toAddMonoid.{u2} R (AddGroupWithOne.toAddMonoidWithOne.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R (CommRing.toRing.{u2} R _inst_4))))) (MulSemiringAction.toDistribMulAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) _inst_5))))) g (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x)) (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x)\nbut is expected to have type\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_3 : Fintype.{u1} G] (R : Type.{u2}) [_inst_4 : CommRing.{u2} R] [_inst_5 : MulSemiringAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))] (x : R) (g : G), Eq.{succ u2} (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (HSMul.hSMul.{u1, u2, u2} G (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (instHSMul.{u1, u2} G (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (SMulZeroClass.toSMul.{u1, u2} G (Polynomial.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (Polynomial.zero.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))) (Polynomial.smulZeroClass.{u2, u1} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) G (DistribSMul.toSMulZeroClass.{u1, u2} G R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddGroupWithOne.toAddMonoidWithOne.{u2} R (Ring.toAddGroupWithOne.{u2} R (CommRing.toRing.{u2} R _inst_4))))) (DistribMulAction.toDistribSMul.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (AddMonoidWithOne.toAddMonoid.{u2} R (AddGroupWithOne.toAddMonoidWithOne.{u2} R (Ring.toAddGroupWithOne.{u2} R (CommRing.toRing.{u2} R _inst_4)))) (MulSemiringAction.toDistribMulAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) _inst_5)))))) g (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x)) (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x)\nCase conversion may be inaccurate. Consider using '#align prod_X_sub_smul.smul prodXSubSmul.smulₓ'. -/\ntheorem prodXSubSmul.smul (x : R) (g : G) : g • prodXSubSmul G R x = prodXSubSmul G R x :=\n  Finset.smul_prod.trans <|\n    Fintype.prod_bijective _ (MulAction.bijective g) _ _ fun g' => by\n      rw [of_quotient_stabilizer_smul, smul_sub, Polynomial.smul_X, Polynomial.smul_C]\n#align prod_X_sub_smul.smul prodXSubSmul.smul\n\n/- warning: prod_X_sub_smul.coeff -> prodXSubSmul.coeff is a dubious translation:\nlean 3 declaration is\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_3 : Fintype.{u1} G] (R : Type.{u2}) [_inst_4 : CommRing.{u2} R] [_inst_5 : MulSemiringAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))] (x : R) (g : G) (n : Nat), Eq.{succ u2} R (SMul.smul.{u1, u2} G R (SMulZeroClass.toHasSmul.{u1, u2} G R (AddZeroClass.toHasZero.{u2} R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)))))))) (DistribSMul.toSmulZeroClass.{u1, u2} G R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))))))) (DistribMulAction.toDistribSMul.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)))))) (MulSemiringAction.toDistribMulAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) _inst_5)))) g (Polynomial.coeff.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x) n)) (Polynomial.coeff.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x) n)\nbut is expected to have type\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_3 : Fintype.{u1} G] (R : Type.{u2}) [_inst_4 : CommRing.{u2} R] [_inst_5 : MulSemiringAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4))] (x : R) (g : G) (n : Nat), Eq.{succ u2} R (HSMul.hSMul.{u1, u2, u2} G R R (instHSMul.{u1, u2} G R (SMulZeroClass.toSMul.{u1, u2} G R (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_4))) (DistribSMul.toSMulZeroClass.{u1, u2} G R (AddMonoid.toAddZeroClass.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddGroupWithOne.toAddMonoidWithOne.{u2} R (Ring.toAddGroupWithOne.{u2} R (CommRing.toRing.{u2} R _inst_4))))) (DistribMulAction.toDistribSMul.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (AddMonoidWithOne.toAddMonoid.{u2} R (AddGroupWithOne.toAddMonoidWithOne.{u2} R (Ring.toAddGroupWithOne.{u2} R (CommRing.toRing.{u2} R _inst_4)))) (MulSemiringAction.toDistribMulAction.{u1, u2} G R (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) _inst_5))))) g (Polynomial.coeff.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x) n)) (Polynomial.coeff.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_4)) (prodXSubSmul.{u1, u2} G _inst_2 _inst_3 R _inst_4 _inst_5 x) n)\nCase conversion may be inaccurate. Consider using '#align prod_X_sub_smul.coeff prodXSubSmul.coeffₓ'. -/\ntheorem prodXSubSmul.coeff (x : R) (g : G) (n : ℕ) :\n    g • (prodXSubSmul G R x).coeff n = (prodXSubSmul G R x).coeff n := by\n  rw [← Polynomial.coeff_smul, prodXSubSmul.smul]\n#align prod_X_sub_smul.coeff prodXSubSmul.coeff\n\nend CommRing\n\nnamespace MulSemiringActionHom\n\nvariable {M}\n\nvariable {P : Type _} [CommSemiring P] [MulSemiringAction M P]\n\nvariable {Q : Type _} [CommSemiring Q] [MulSemiringAction M Q]\n\nopen Polynomial\n\n/- warning: mul_semiring_action_hom.polynomial -> MulSemiringActionHom.polynomial is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {P : Type.{u2}} [_inst_2 : CommSemiring.{u2} P] [_inst_3 : MulSemiringAction.{u1, u2} M P _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2)] {Q : Type.{u3}} [_inst_4 : CommSemiring.{u3} Q] [_inst_5 : MulSemiringAction.{u1, u3} M Q _inst_1 (CommSemiring.toSemiring.{u3} Q _inst_4)], (MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) -> (MulSemiringActionHom.{u1, u2, u3} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.mulSemiringAction.{u1, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.semiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.mulSemiringAction.{u1, u3} M _inst_1 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {P : Type.{u2}} [_inst_2 : CommSemiring.{u2} P] [_inst_3 : MulSemiringAction.{u1, u2} M P _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2)] {Q : Type.{u3}} [_inst_4 : CommSemiring.{u3} Q] [_inst_5 : MulSemiringAction.{u1, u3} M Q _inst_1 (CommSemiring.toSemiring.{u3} Q _inst_4)], (MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) -> (MulSemiringActionHom.{u1, u2, u3} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u1, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.semiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u1, u3} M _inst_1 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5))\nCase conversion may be inaccurate. Consider using '#align mul_semiring_action_hom.polynomial MulSemiringActionHom.polynomialₓ'. -/\n/-- An equivariant map induces an equivariant map on polynomials. -/\nprotected noncomputable def polynomial (g : P →+*[M] Q) : P[X] →+*[M] Q[X]\n    where\n  toFun := map g\n  map_smul' m p :=\n    Polynomial.induction_on p\n      (fun b => by rw [smul_C, map_C, coe_fn_coe, g.map_smul, map_C, coe_fn_coe, smul_C])\n      (fun p q ihp ihq => by\n        rw [smul_add, Polynomial.map_add, ihp, ihq, Polynomial.map_add, smul_add])\n      fun n b ih => by\n      rw [smul_mul', smul_C, smul_pow', smul_X, Polynomial.map_mul, map_C, Polynomial.map_pow,\n        map_X, coe_fn_coe, g.map_smul, Polynomial.map_mul, map_C, Polynomial.map_pow, map_X,\n        smul_mul', smul_C, smul_pow', smul_X, coe_fn_coe]\n  map_zero' := Polynomial.map_zero g\n  map_add' p q := Polynomial.map_add g\n  map_one' := Polynomial.map_one g\n  map_mul' p q := Polynomial.map_mul g\n#align mul_semiring_action_hom.polynomial MulSemiringActionHom.polynomial\n\n/- warning: mul_semiring_action_hom.coe_polynomial -> MulSemiringActionHom.coe_polynomial is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {P : Type.{u2}} [_inst_2 : CommSemiring.{u2} P] [_inst_3 : MulSemiringAction.{u1, u2} M P _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2)] {Q : Type.{u3}} [_inst_4 : CommSemiring.{u3} Q] [_inst_5 : MulSemiringAction.{u1, u3} M Q _inst_1 (CommSemiring.toSemiring.{u3} Q _inst_4)] (g : MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5), Eq.{max (succ u2) (succ u3)} ((fun (_x : MulSemiringActionHom.{u1, u2, u3} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.mulSemiringAction.{u1, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.semiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.mulSemiringAction.{u1, u3} M _inst_1 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5)) => (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) -> (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4))) (MulSemiringActionHom.polynomial.{u1, u2, u3} M _inst_1 P _inst_2 _inst_3 Q _inst_4 _inst_5 g)) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (MulSemiringActionHom.{u1, u2, u3} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.mulSemiringAction.{u1, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.semiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.mulSemiringAction.{u1, u3} M _inst_1 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5)) (fun (_x : MulSemiringActionHom.{u1, u2, u3} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.mulSemiringAction.{u1, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.semiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.mulSemiringAction.{u1, u3} M _inst_1 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5)) => (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) -> (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4))) ([anonymous].{u1, u2, u3} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.mulSemiringAction.{u1, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.semiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (Polynomial.mulSemiringAction.{u1, u3} M _inst_1 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5)) (MulSemiringActionHom.polynomial.{u1, u2, u3} M _inst_1 P _inst_2 _inst_3 Q _inst_4 _inst_5 g)) (Polynomial.map.{u2, u3} P Q (CommSemiring.toSemiring.{u2} P _inst_2) (CommSemiring.toSemiring.{u3} Q _inst_4) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u2) (succ u3)} a b] => self.0) (MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) (RingHom.{u2, u3} P Q (Semiring.toNonAssocSemiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) (RingHom.{u2, u3} P Q (Semiring.toNonAssocSemiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4))) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) (RingHom.{u2, u3} P Q (Semiring.toNonAssocSemiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4))) (RingHom.hasCoeT.{max u2 u3, u2, u3} (MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) P Q (Semiring.toNonAssocSemiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u3} Q (CommSemiring.toSemiring.{u3} Q _inst_4)) (MulSemiringActionHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (MulSemiringActionHom.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) M P Q _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2) (CommSemiring.toSemiring.{u3} Q _inst_4) (MulSemiringAction.toDistribMulAction.{u1, u2} M P _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (MulSemiringAction.toDistribMulAction.{u1, u3} M Q _inst_1 (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5) (MulSemiringActionHom.mulSemiringActionHomClass.{u1, u2, u3} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u3} Q _inst_4) _inst_5))))) g))\nbut is expected to have type\n  forall {M : Type.{u3}} [_inst_1 : Monoid.{u3} M] {P : Type.{u2}} [_inst_2 : CommSemiring.{u2} P] [_inst_3 : MulSemiringAction.{u3, u2} M P _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2)] {Q : Type.{u1}} [_inst_4 : CommSemiring.{u1} Q] [_inst_5 : MulSemiringAction.{u3, u1} M Q _inst_1 (CommSemiring.toSemiring.{u1} Q _inst_4)] (g : MulSemiringActionHom.{u3, u2, u1} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5), Eq.{max (succ u2) (succ u1)} (forall (a : Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) => Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulSemiringActionHom.{u3, u2, u1} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5)) (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (fun (_x : Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) => Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) _x) (SMulHomClass.toFunLike.{max u2 u1, u3, u2, u1} (MulSemiringActionHom.{u3, u2, u1} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5)) M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (SMulZeroClass.toSMul.{u3, u2} M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddMonoid.toZero.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddMonoidWithOne.toAddMonoid.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (NonAssocSemiring.toAddCommMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2))))))) (DistribSMul.toSMulZeroClass.{u3, u2} M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddMonoid.toAddZeroClass.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddMonoidWithOne.toAddMonoid.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (NonAssocSemiring.toAddCommMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2))))))) (DistribMulAction.toDistribSMul.{u3, u2} M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (NonAssocSemiring.toAddCommMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)))))) (MulSemiringAction.toDistribMulAction.{u3, u2} M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) _inst_1 (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3))))) (SMulZeroClass.toSMul.{u3, u1} M (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddMonoid.toZero.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddMonoidWithOne.toAddMonoid.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (NonAssocSemiring.toAddCommMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4))))))) (DistribSMul.toSMulZeroClass.{u3, u1} M (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddMonoidWithOne.toAddMonoid.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (NonAssocSemiring.toAddCommMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4))))))) (DistribMulAction.toDistribSMul.{u3, u1} M (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) _inst_1 (AddMonoidWithOne.toAddMonoid.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (NonAssocSemiring.toAddCommMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)))))) (MulSemiringAction.toDistribMulAction.{u3, u1} M (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) _inst_1 (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u3, u2, u1} (MulSemiringActionHom.{u3, u2, u1} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5)) M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) _inst_1 (AddMonoidWithOne.toAddMonoid.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (NonAssocSemiring.toAddCommMonoidWithOne.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)))))) (AddMonoidWithOne.toAddMonoid.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (NonAssocSemiring.toAddCommMonoidWithOne.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)))))) (MulSemiringAction.toDistribMulAction.{u3, u2} M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) _inst_1 (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3)) (MulSemiringAction.toDistribMulAction.{u3, u1} M (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) _inst_1 (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5)) (MulSemiringActionHomClass.toDistribMulActionHomClass.{max u2 u1, u3, u2, u1} (MulSemiringActionHom.{u3, u2, u1} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5)) M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) _inst_1 (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (MulSemiringAction.toDistribMulAction.{u3, u2} M (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) _inst_1 (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3)) (MulSemiringAction.toDistribMulAction.{u3, u1} M (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) _inst_1 (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5)) (MulSemiringActionHom.instMulSemiringActionHomClassMulSemiringActionHomToDistribMulActionToDistribMulAction.{u3, u2, u1} M _inst_1 (Polynomial.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.semiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u2} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (Polynomial.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.semiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (Polynomial.instMulSemiringActionPolynomialSemiring.{u3, u1} M _inst_1 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5))))) (MulSemiringActionHom.polynomial.{u3, u2, u1} M _inst_1 P _inst_2 _inst_3 Q _inst_4 _inst_5 g)) (Polynomial.map.{u2, u1} P Q (CommSemiring.toSemiring.{u2} P _inst_2) (CommSemiring.toSemiring.{u1} Q _inst_4) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (MulSemiringActionHom.{u3, u2, u1} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5) P Q (Semiring.toNonAssocSemiring.{u2} P (CommSemiring.toSemiring.{u2} P _inst_2)) (Semiring.toNonAssocSemiring.{u1} Q (CommSemiring.toSemiring.{u1} Q _inst_4)) (MulSemiringActionHomClass.toRingHomClass.{max u2 u1, u3, u2, u1} (MulSemiringActionHom.{u3, u2, u1} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5) M P Q _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2) (CommSemiring.toSemiring.{u1} Q _inst_4) (MulSemiringAction.toDistribMulAction.{u3, u2} M P _inst_1 (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3) (MulSemiringAction.toDistribMulAction.{u3, u1} M Q _inst_1 (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5) (MulSemiringActionHom.instMulSemiringActionHomClassMulSemiringActionHomToDistribMulActionToDistribMulAction.{u3, u2, u1} M _inst_1 P (CommSemiring.toSemiring.{u2} P _inst_2) _inst_3 Q (CommSemiring.toSemiring.{u1} Q _inst_4) _inst_5)) g))\nCase conversion may be inaccurate. Consider using '#align mul_semiring_action_hom.coe_polynomial MulSemiringActionHom.coe_polynomialₓ'. -/\n@[simp]\ntheorem coe_polynomial (g : P →+*[M] Q) : (g.Polynomial : P[X] → Q[X]) = map g :=\n  rfl\n#align mul_semiring_action_hom.coe_polynomial MulSemiringActionHom.coe_polynomial\n\nend MulSemiringActionHom\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Polynomial/GroupRingAction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4854702552330544}}
{"text": "/-\nCopyright (c) 2018 Ellen Arlt. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.big_operators.pi\nimport Mathlib.algebra.module.pi\nimport Mathlib.algebra.module.linear_map\nimport Mathlib.algebra.big_operators.ring\nimport Mathlib.algebra.star.basic\nimport Mathlib.data.equiv.ring\nimport Mathlib.data.fintype.card\nimport Mathlib.PostPort\n\nuniverses u u' v u_2 u_3 w u_1 u_4 u_5 u_6 \n\nnamespace Mathlib\n\n/-!\n# Matrices\n-/\n\n/-- `matrix m n` is the type of matrices whose rows are indexed by the fintype `m`\n    and whose columns are indexed by the fintype `n`. -/\ndef matrix (m : Type u) (n : Type u') [fintype m] [fintype n] (α : Type v) := m → n → α\n\nnamespace matrix\n\n\ntheorem ext_iff {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix m n α} {N : matrix m n α} : (∀ (i : m) (j : n), M i j = N i j) ↔ M = N :=\n  sorry\n\ntheorem ext {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} {M : matrix m n α}\n    {N : matrix m n α} : (∀ (i : m) (j : n), M i j = N i j) → M = N :=\n  iff.mp ext_iff\n\n/-- `M.map f` is the matrix obtained by applying `f` to each entry of the matrix `M`. -/\ndef map {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} (M : matrix m n α)\n    {β : Type w} (f : α → β) : matrix m n β :=\n  fun (i : m) (j : n) => f (M i j)\n\n@[simp] theorem map_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix m n α} {β : Type w} {f : α → β} {i : m} {j : n} : map M f i j = f (M i j) :=\n  rfl\n\n@[simp] theorem map_map {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix m n α} {β : Type u_1} {γ : Type u_4} {f : α → β} {g : β → γ} :\n    map (map M f) g = map M (g ∘ f) :=\n  sorry\n\n/-- The transpose of a matrix. -/\ndef transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    (M : matrix m n α) : matrix n m α :=\n  sorry\n\n/-- `matrix.col u` is the column matrix whose entries are given by `u`. -/\ndef col {m : Type u_2} [fintype m] {α : Type v} (w : m → α) : matrix m Unit α := sorry\n\n/-- `matrix.row u` is the row matrix whose entries are given by `u`. -/\ndef row {n : Type u_3} [fintype n] {α : Type v} (v : n → α) : matrix Unit n α := sorry\n\nprotected instance inhabited {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [Inhabited α] : Inhabited (matrix m n α) :=\n  pi.inhabited m\n\nprotected instance has_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [Add α] : Add (matrix m n α) :=\n  pi.has_add\n\nprotected instance add_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [add_semigroup α] : add_semigroup (matrix m n α) :=\n  pi.add_semigroup\n\nprotected instance add_comm_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} [add_comm_semigroup α] : add_comm_semigroup (matrix m n α) :=\n  pi.add_comm_semigroup\n\nprotected instance has_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [HasZero α] : HasZero (matrix m n α) :=\n  pi.has_zero\n\nprotected instance add_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [add_monoid α] : add_monoid (matrix m n α) :=\n  pi.add_monoid\n\nprotected instance add_comm_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} [add_comm_monoid α] : add_comm_monoid (matrix m n α) :=\n  pi.add_comm_monoid\n\nprotected instance has_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [Neg α] : Neg (matrix m n α) :=\n  pi.has_neg\n\nprotected instance has_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [Sub α] : Sub (matrix m n α) :=\n  pi.has_sub\n\nprotected instance add_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [add_group α] : add_group (matrix m n α) :=\n  pi.add_group\n\nprotected instance add_comm_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [add_comm_group α] : add_comm_group (matrix m n α) :=\n  pi.add_comm_group\n\n@[simp] theorem zero_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [HasZero α] (i : m) (j : n) : HasZero.zero i j = 0 :=\n  rfl\n\n@[simp] theorem neg_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Neg α]\n    (M : matrix m n α) (i : m) (j : n) : Neg.neg M i j = -M i j :=\n  rfl\n\n@[simp] theorem add_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Add α]\n    (M : matrix m n α) (N : matrix m n α) (i : m) (j : n) : Add.add M N i j = M i j + N i j :=\n  rfl\n\n@[simp] theorem sub_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [Sub α]\n    (M : matrix m n α) (N : matrix m n α) (i : m) (j : n) : Sub.sub M N i j = M i j - N i j :=\n  rfl\n\n@[simp] theorem map_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [HasZero α] {β : Type w} [HasZero β] {f : α → β} (h : f 0 = 0) : map 0 f = 0 :=\n  sorry\n\ntheorem map_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_monoid α]\n    {β : Type w} [add_monoid β] (f : α →+ β) (M : matrix m n α) (N : matrix m n α) :\n    map (M + N) ⇑f = map M ⇑f + map N ⇑f :=\n  sorry\n\ntheorem map_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [add_group α]\n    {β : Type w} [add_group β] (f : α →+ β) (M : matrix m n α) (N : matrix m n α) :\n    map (M - N) ⇑f = map M ⇑f - map N ⇑f :=\n  sorry\n\ntheorem subsingleton_of_empty_left {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} (hm : ¬Nonempty m) : subsingleton (matrix m n α) :=\n  sorry\n\ntheorem subsingleton_of_empty_right {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} (hn : ¬Nonempty n) : subsingleton (matrix m n α) :=\n  sorry\n\nend matrix\n\n\n/-- The `add_monoid_hom` between spaces of matrices induced by an `add_monoid_hom` between their\ncoefficients. -/\ndef add_monoid_hom.map_matrix {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [add_monoid α] {β : Type w} [add_monoid β] (f : α →+ β) : matrix m n α →+ matrix m n β :=\n  add_monoid_hom.mk (fun (M : matrix m n α) => matrix.map M ⇑f) sorry (matrix.map_add f)\n\n@[simp] theorem add_monoid_hom.map_matrix_apply {m : Type u_2} {n : Type u_3} [fintype m]\n    [fintype n] {α : Type v} [add_monoid α] {β : Type w} [add_monoid β] (f : α →+ β)\n    (M : matrix m n α) : coe_fn (add_monoid_hom.map_matrix f) M = matrix.map M ⇑f :=\n  rfl\n\nnamespace matrix\n\n\n/-- `diagonal d` is the square matrix such that `(diagonal d) i i = d i` and `(diagonal d) i j = 0`\nif `i ≠ j`. -/\ndef diagonal {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] (d : n → α) :\n    matrix n n α :=\n  fun (i j : n) => ite (i = j) (d i) 0\n\n@[simp] theorem diagonal_apply_eq {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n]\n    [HasZero α] {d : n → α} (i : n) : diagonal d i i = d i :=\n  sorry\n\n@[simp] theorem diagonal_apply_ne {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n]\n    [HasZero α] {d : n → α} {i : n} {j : n} (h : i ≠ j) : diagonal d i j = 0 :=\n  sorry\n\ntheorem diagonal_apply_ne' {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α]\n    {d : n → α} {i : n} {j : n} (h : j ≠ i) : diagonal d i j = 0 :=\n  diagonal_apply_ne (ne.symm h)\n\n@[simp] theorem diagonal_zero {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] :\n    (diagonal fun (_x : n) => 0) = 0 :=\n  sorry\n\n@[simp] theorem diagonal_transpose {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n]\n    [HasZero α] (v : n → α) : transpose (diagonal v) = diagonal v :=\n  sorry\n\n@[simp] theorem diagonal_add {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α]\n    (d₁ : n → α) (d₂ : n → α) : diagonal d₁ + diagonal d₂ = diagonal fun (i : n) => d₁ i + d₂ i :=\n  sorry\n\n@[simp] theorem diagonal_map {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] {β : Type w}\n    [HasZero α] [HasZero β] {f : α → β} (h : f 0 = 0) {d : n → α} :\n    map (diagonal d) f = diagonal fun (m : n) => f (d m) :=\n  sorry\n\nprotected instance has_one {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α]\n    [HasOne α] : HasOne (matrix n n α) :=\n  { one := diagonal fun (_x : n) => 1 }\n\n@[simp] theorem diagonal_one {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α]\n    [HasOne α] : (diagonal fun (_x : n) => 1) = 1 :=\n  rfl\n\ntheorem one_apply {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α]\n    {i : n} {j : n} : HasOne.one i j = ite (i = j) 1 0 :=\n  rfl\n\n@[simp] theorem one_apply_eq {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α]\n    [HasOne α] (i : n) : HasOne.one i i = 1 :=\n  diagonal_apply_eq i\n\n@[simp] theorem one_apply_ne {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α]\n    [HasOne α] {i : n} {j : n} : i ≠ j → HasOne.one i j = 0 :=\n  diagonal_apply_ne\n\ntheorem one_apply_ne' {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α] [HasOne α]\n    {i : n} {j : n} : j ≠ i → HasOne.one i j = 0 :=\n  diagonal_apply_ne'\n\n@[simp] theorem one_map {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α]\n    [HasOne α] {β : Type w} [HasZero β] [HasOne β] {f : α → β} (h₀ : f 0 = 0) (h₁ : f 1 = 1) :\n    map 1 f = 1 :=\n  sorry\n\n@[simp] theorem bit0_apply {m : Type u_2} [fintype m] {α : Type v} [Add α] (M : matrix m m α)\n    (i : m) (j : m) : bit0 M i j = bit0 (M i j) :=\n  rfl\n\ntheorem bit1_apply {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α] [HasOne α]\n    (M : matrix n n α) (i : n) (j : n) : bit1 M i j = ite (i = j) (bit1 (M i j)) (bit0 (M i j)) :=\n  sorry\n\n@[simp] theorem bit1_apply_eq {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α]\n    [HasOne α] (M : matrix n n α) (i : n) : bit1 M i i = bit1 (M i i) :=\n  sorry\n\n@[simp] theorem bit1_apply_ne {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_monoid α]\n    [HasOne α] (M : matrix n n α) {i : n} {j : n} (h : i ≠ j) : bit1 M i j = bit0 (M i j) :=\n  sorry\n\n/-- `dot_product v w` is the sum of the entrywise products `v i * w i` -/\ndef dot_product {m : Type u_2} [fintype m] {α : Type v} [Mul α] [add_comm_monoid α] (v : m → α)\n    (w : m → α) : α :=\n  finset.sum finset.univ fun (i : m) => v i * w i\n\ntheorem dot_product_assoc {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] (u : m → α) (v : m → n → α) (w : n → α) :\n    dot_product (fun (j : n) => dot_product u fun (i : m) => v i j) w =\n        dot_product u fun (i : m) => dot_product (v i) w :=\n  sorry\n\ntheorem dot_product_comm {m : Type u_2} [fintype m] {α : Type v} [comm_semiring α] (v : m → α)\n    (w : m → α) : dot_product v w = dot_product w v :=\n  sorry\n\n@[simp] theorem dot_product_punit {α : Type v} [add_comm_monoid α] [Mul α] (v : PUnit → α)\n    (w : PUnit → α) : dot_product v w = v PUnit.unit * w PUnit.unit :=\n  sorry\n\n@[simp] theorem dot_product_zero {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) :\n    dot_product v 0 = 0 :=\n  sorry\n\n@[simp] theorem dot_product_zero' {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) :\n    (dot_product v fun (_x : m) => 0) = 0 :=\n  dot_product_zero v\n\n@[simp] theorem zero_dot_product {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) :\n    dot_product 0 v = 0 :=\n  sorry\n\n@[simp] theorem zero_dot_product' {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α) :\n    dot_product (fun (_x : m) => 0) v = 0 :=\n  zero_dot_product v\n\n@[simp] theorem add_dot_product {m : Type u_2} [fintype m] {α : Type v} [semiring α] (u : m → α)\n    (v : m → α) (w : m → α) : dot_product (u + v) w = dot_product u w + dot_product v w :=\n  sorry\n\n@[simp] theorem dot_product_add {m : Type u_2} [fintype m] {α : Type v} [semiring α] (u : m → α)\n    (v : m → α) (w : m → α) : dot_product u (v + w) = dot_product u v + dot_product u w :=\n  sorry\n\n@[simp] theorem diagonal_dot_product {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m]\n    [semiring α] (v : m → α) (w : m → α) (i : m) : dot_product (diagonal v i) w = v i * w i :=\n  sorry\n\n@[simp] theorem dot_product_diagonal {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m]\n    [semiring α] (v : m → α) (w : m → α) (i : m) : dot_product v (diagonal w i) = v i * w i :=\n  sorry\n\n@[simp] theorem dot_product_diagonal' {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m]\n    [semiring α] (v : m → α) (w : m → α) (i : m) :\n    (dot_product v fun (j : m) => diagonal w j i) = v i * w i :=\n  sorry\n\n@[simp] theorem neg_dot_product {m : Type u_2} [fintype m] {α : Type v} [ring α] (v : m → α)\n    (w : m → α) : dot_product (-v) w = -dot_product v w :=\n  sorry\n\n@[simp] theorem dot_product_neg {m : Type u_2} [fintype m] {α : Type v} [ring α] (v : m → α)\n    (w : m → α) : dot_product v (-w) = -dot_product v w :=\n  sorry\n\n@[simp] theorem smul_dot_product {m : Type u_2} [fintype m] {α : Type v} [semiring α] (x : α)\n    (v : m → α) (w : m → α) : dot_product (x • v) w = x * dot_product v w :=\n  sorry\n\n@[simp] theorem dot_product_smul {m : Type u_2} [fintype m] {α : Type v} [comm_semiring α] (x : α)\n    (v : m → α) (w : m → α) : dot_product v (x • w) = x * dot_product v w :=\n  sorry\n\n/-- `M ⬝ N` is the usual product of matrices `M` and `N`, i.e. we have that\n    `(M ⬝ N) i k` is the dot product of the `i`-th row of `M` by the `k`-th column of `Ǹ`. -/\nprotected def mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n]\n    {α : Type v} [Mul α] [add_comm_monoid α] (M : matrix l m α) (N : matrix m n α) : matrix l n α :=\n  fun (i : l) (k : n) => dot_product (fun (j : m) => M i j) fun (j : m) => N j k\n\ntheorem mul_apply {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n]\n    {α : Type v} [Mul α] [add_comm_monoid α] {M : matrix l m α} {N : matrix m n α} {i : l} {k : n} :\n    matrix.mul M N i k = finset.sum finset.univ fun (j : m) => M i j * N j k :=\n  rfl\n\nprotected instance has_mul {n : Type u_3} [fintype n] {α : Type v} [Mul α] [add_comm_monoid α] :\n    Mul (matrix n n α) :=\n  { mul := matrix.mul }\n\n@[simp] theorem mul_eq_mul {n : Type u_3} [fintype n] {α : Type v} [Mul α] [add_comm_monoid α]\n    (M : matrix n n α) (N : matrix n n α) : M * N = matrix.mul M N :=\n  rfl\n\ntheorem mul_apply' {n : Type u_3} [fintype n] {α : Type v} [Mul α] [add_comm_monoid α]\n    {M : matrix n n α} {N : matrix n n α} {i : n} {k : n} :\n    matrix.mul M N i k = dot_product (fun (j : n) => M i j) fun (j : n) => N j k :=\n  rfl\n\nprotected theorem mul_assoc {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l]\n    [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (L : matrix l m α)\n    (M : matrix m n α) (N : matrix n o α) :\n    matrix.mul (matrix.mul L M) N = matrix.mul L (matrix.mul M N) :=\n  ext\n    fun (i : l) (j : o) =>\n      dot_product_assoc (fun (j : m) => L i j) (fun (i : m) (j : n) => M i j)\n        fun (j_1 : n) => N j_1 j\n\nprotected instance semigroup {n : Type u_3} [fintype n] {α : Type v} [semiring α] :\n    semigroup (matrix n n α) :=\n  semigroup.mk Mul.mul matrix.mul_assoc\n\n@[simp] theorem diagonal_neg {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [add_group α]\n    (d : n → α) : -diagonal d = diagonal fun (i : n) => -d i :=\n  sorry\n\n@[simp] protected theorem mul_zero {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} [semiring α] (M : matrix m n α) : matrix.mul M 0 = 0 :=\n  ext fun (i : m) (j : o) => dot_product_zero fun (j : n) => M i j\n\n@[simp] protected theorem zero_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l]\n    [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) : matrix.mul 0 M = 0 :=\n  ext fun (i : l) (j : n) => zero_dot_product fun (j_1 : m) => M j_1 j\n\nprotected theorem mul_add {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [semiring α] (L : matrix m n α) (M : matrix n o α) (N : matrix n o α) :\n    matrix.mul L (M + N) = matrix.mul L M + matrix.mul L N :=\n  ext\n    fun (i : m) (j : o) =>\n      dot_product_add (fun (j : n) => L i j) (fun (i : n) => M i j) fun (i : n) => N i j\n\nprotected theorem add_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m]\n    [fintype n] {α : Type v} [semiring α] (L : matrix l m α) (M : matrix l m α) (N : matrix m n α) :\n    matrix.mul (L + M) N = matrix.mul L N + matrix.mul M N :=\n  ext\n    fun (i : l) (j : n) =>\n      add_dot_product (fun (i_1 : m) => L i i_1) (fun (i_1 : m) => M i i_1) fun (j_1 : m) => N j_1 j\n\n@[simp] theorem diagonal_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] [DecidableEq m] (d : m → α) (M : matrix m n α) (i : m) (j : n) :\n    matrix.mul (diagonal d) M i j = d i * M i j :=\n  diagonal_dot_product (fun (i : m) => d i) (fun (j_1 : m) => M j_1 j) i\n\n@[simp] theorem mul_diagonal {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] [DecidableEq n] (d : n → α) (M : matrix m n α) (i : m) (j : n) :\n    matrix.mul M (diagonal d) i j = M i j * d j :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (matrix.mul M (diagonal d) i j = M i j * d j))\n        (Eq.symm (diagonal_transpose d))))\n    (dot_product_diagonal (fun (j : n) => M i j) (fun (j : n) => d j) j)\n\n@[simp] protected theorem one_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] [DecidableEq m] (M : matrix m n α) : matrix.mul 1 M = M :=\n  sorry\n\n@[simp] protected theorem mul_one {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] [DecidableEq n] (M : matrix m n α) : matrix.mul M 1 = M :=\n  sorry\n\nprotected instance monoid {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] :\n    monoid (matrix n n α) :=\n  monoid.mk semigroup.mul sorry 1 sorry sorry\n\nprotected instance semiring {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] :\n    semiring (matrix n n α) :=\n  semiring.mk add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry sorry monoid.mul sorry\n    monoid.one sorry sorry matrix.zero_mul matrix.mul_zero matrix.mul_add matrix.add_mul\n\n@[simp] theorem diagonal_mul_diagonal {n : Type u_3} [fintype n] {α : Type v} [semiring α]\n    [DecidableEq n] (d₁ : n → α) (d₂ : n → α) :\n    matrix.mul (diagonal d₁) (diagonal d₂) = diagonal fun (i : n) => d₁ i * d₂ i :=\n  sorry\n\ntheorem diagonal_mul_diagonal' {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n]\n    (d₁ : n → α) (d₂ : n → α) : diagonal d₁ * diagonal d₂ = diagonal fun (i : n) => d₁ i * d₂ i :=\n  diagonal_mul_diagonal d₁ d₂\n\n@[simp] theorem map_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [semiring α] {L : matrix m n α} {M : matrix n o α} {β : Type w}\n    [semiring β] {f : α →+* β} : map (matrix.mul L M) ⇑f = matrix.mul (map L ⇑f) (map M ⇑f) :=\n  sorry\n\n-- TODO: there should be a way to avoid restating these for each `foo_hom`. \n\n/-- A version of `one_map` where `f` is a ring hom. -/\n@[simp] theorem ring_hom_map_one {n : Type u_3} [fintype n] {α : Type v} [semiring α]\n    [DecidableEq n] {β : Type w} [semiring β] (f : α →+* β) : map 1 ⇑f = 1 :=\n  one_map (ring_hom.map_zero f) (ring_hom.map_one f)\n\n/-- A version of `one_map` where `f` is a `ring_equiv`. -/\n@[simp] theorem ring_equiv_map_one {n : Type u_3} [fintype n] {α : Type v} [semiring α]\n    [DecidableEq n] {β : Type w} [semiring β] (f : α ≃+* β) : map 1 ⇑f = 1 :=\n  one_map (ring_equiv.map_zero f) (ring_equiv.map_one f)\n\n/-- A version of `map_zero` where `f` is a `zero_hom`. -/\n@[simp] theorem zero_hom_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w}\n    [HasZero β] (f : zero_hom α β) : map 0 ⇑f = 0 :=\n  map_zero (zero_hom.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `add_monoid_hom`. -/\n@[simp] theorem add_monoid_hom_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α]\n    {β : Type w} [add_monoid β] (f : α →+ β) : map 0 ⇑f = 0 :=\n  map_zero (add_monoid_hom.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `add_equiv`. -/\n@[simp] theorem add_equiv_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w}\n    [add_monoid β] (f : α ≃+ β) : map 0 ⇑f = 0 :=\n  map_zero (add_equiv.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `linear_map`. -/\n@[simp] theorem linear_map_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α]\n    {R : Type u_1} [semiring R] {β : Type w} [add_comm_monoid β] [semimodule R α] [semimodule R β]\n    (f : linear_map R α β) : map 0 ⇑f = 0 :=\n  map_zero (linear_map.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `linear_equiv`. -/\n@[simp] theorem linear_equiv_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α]\n    {R : Type u_1} [semiring R] {β : Type w} [add_comm_monoid β] [semimodule R α] [semimodule R β]\n    (f : linear_equiv R α β) : map 0 ⇑f = 0 :=\n  map_zero (linear_equiv.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `ring_hom`. -/\n@[simp] theorem ring_hom_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α] {β : Type w}\n    [semiring β] (f : α →+* β) : map 0 ⇑f = 0 :=\n  map_zero (ring_hom.map_zero f)\n\n/-- A version of `map_zero` where `f` is a `ring_equiv`. -/\n@[simp] theorem ring_equiv_map_zero {n : Type u_3} [fintype n] {α : Type v} [semiring α]\n    {β : Type w} [semiring β] (f : α ≃+* β) : map 0 ⇑f = 0 :=\n  map_zero (ring_equiv.map_zero f)\n\ntheorem is_add_monoid_hom_mul_left {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l]\n    [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix l m α) :\n    is_add_monoid_hom fun (x : matrix m n α) => matrix.mul M x :=\n  is_add_monoid_hom.mk (matrix.mul_zero M)\n\ntheorem is_add_monoid_hom_mul_right {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l]\n    [fintype m] [fintype n] {α : Type v} [semiring α] (M : matrix m n α) :\n    is_add_monoid_hom fun (x : matrix l m α) => matrix.mul x M :=\n  is_add_monoid_hom.mk (matrix.zero_mul M)\n\nprotected theorem sum_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m]\n    [fintype n] {α : Type v} [semiring α] {β : Type u_4} (s : finset β) (f : β → matrix l m α)\n    (M : matrix m n α) :\n    matrix.mul (finset.sum s fun (a : β) => f a) M =\n        finset.sum s fun (a : β) => matrix.mul (f a) M :=\n  Eq.symm (finset.sum_hom s fun (x : matrix l m α) => matrix.mul x M)\n\n/- This line does not type-check without `id` and `: _`. Lean did not recognize that two different\n  `add_monoid` instances were def-eq -/\n\nprotected theorem mul_sum {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m]\n    [fintype n] {α : Type v} [semiring α] {β : Type u_4} (s : finset β) (f : β → matrix m n α)\n    (M : matrix l m α) :\n    matrix.mul M (finset.sum s fun (a : β) => f a) =\n        finset.sum s fun (a : β) => matrix.mul M (f a) :=\n  Eq.symm (finset.sum_hom s fun (x : matrix m n α) => matrix.mul M x)\n\n/- This line does not type-check without `id` and `: _`. Lean did not recognize that two different\n  `add_monoid` instances were def-eq -/\n\n@[simp] theorem row_mul_col_apply {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α)\n    (w : m → α) (i : Unit) (j : Unit) : matrix.mul (row v) (col w) i j = dot_product v w :=\n  rfl\n\nend matrix\n\n\n/-- The `ring_hom` between spaces of square matrices induced by a `ring_hom` between their\ncoefficients. -/\ndef ring_hom.map_matrix {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m] [semiring α]\n    {β : Type w} [semiring β] (f : α →+* β) : matrix m m α →+* matrix m m β :=\n  ring_hom.mk (fun (M : matrix m m α) => matrix.map M ⇑f) sorry sorry sorry sorry\n\n@[simp] theorem ring_hom.map_matrix_apply {m : Type u_2} [fintype m] {α : Type v} [DecidableEq m]\n    [semiring α] {β : Type w} [semiring β] (f : α →+* β) (M : matrix m m α) :\n    coe_fn (ring_hom.map_matrix f) M = matrix.map M ⇑f :=\n  rfl\n\nnamespace matrix\n\n\n@[simp] theorem neg_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [ring α] (M : matrix m n α) (N : matrix n o α) :\n    matrix.mul (-M) N = -matrix.mul M N :=\n  ext fun (i : m) (j : o) => neg_dot_product (fun (i_1 : n) => M i i_1) fun (j_1 : n) => N j_1 j\n\n@[simp] theorem mul_neg {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [ring α] (M : matrix m n α) (N : matrix n o α) :\n    matrix.mul M (-N) = -matrix.mul M N :=\n  ext fun (i : m) (j : o) => dot_product_neg (fun (j : n) => M i j) fun (i : n) => N i j\n\nprotected theorem sub_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [ring α] (M : matrix m n α) (M' : matrix m n α) (N : matrix n o α) :\n    matrix.mul (M - M') N = matrix.mul M N - matrix.mul M' N :=\n  sorry\n\nprotected theorem mul_sub {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [ring α] (M : matrix m n α) (N : matrix n o α) (N' : matrix n o α) :\n    matrix.mul M (N - N') = matrix.mul M N - matrix.mul M N' :=\n  sorry\n\nprotected instance ring {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [ring α] :\n    ring (matrix n n α) :=\n  ring.mk semiring.add sorry semiring.zero sorry sorry add_comm_group.neg add_comm_group.sub sorry\n    sorry semiring.mul sorry semiring.one sorry sorry sorry sorry\n\nprotected instance has_scalar {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] : has_scalar α (matrix m n α) :=\n  pi.has_scalar\n\nprotected instance semimodule {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {β : Type w} [semiring α] [add_comm_monoid β] [semimodule α β] : semimodule α (matrix m n β) :=\n  pi.semimodule m (fun (ᾰ : m) => n → β) α\n\n@[simp] theorem smul_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] (a : α) (A : matrix m n α) (i : m) (j : n) : has_scalar.smul a A i j = a * A i j :=\n  rfl\n\ntheorem smul_eq_diagonal_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] [DecidableEq m] (M : matrix m n α) (a : α) :\n    a • M = matrix.mul (diagonal fun (_x : m) => a) M :=\n  sorry\n\n@[simp] theorem smul_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m]\n    [fintype n] {α : Type v} [semiring α] (M : matrix m n α) (a : α) (N : matrix n l α) :\n    matrix.mul (a • M) N = a • matrix.mul M N :=\n  ext fun (i : m) (j : l) => smul_dot_product a (fun (i_1 : n) => M i i_1) fun (j_1 : n) => N j_1 j\n\n@[simp] theorem mul_mul_left {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [semiring α] (M : matrix m n α) (N : matrix n o α) (a : α) :\n    matrix.mul (fun (i : m) (j : n) => a * M i j) N = a • matrix.mul M N :=\n  sorry\n\n/--\nThe ring homomorphism `α →+* matrix n n α`\nsending `a` to the diagonal matrix with `a` on the diagonal.\n-/\ndef scalar {α : Type v} [semiring α] (n : Type u) [DecidableEq n] [fintype n] :\n    α →+* matrix n n α :=\n  ring_hom.mk (fun (a : α) => a • 1) sorry sorry sorry sorry\n\n@[simp] theorem coe_scalar {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] :\n    ⇑(scalar n) = fun (a : α) => a • 1 :=\n  rfl\n\ntheorem scalar_apply_eq {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] (a : α)\n    (i : n) : coe_fn (scalar n) a i i = a :=\n  sorry\n\ntheorem scalar_apply_ne {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] (a : α)\n    (i : n) (j : n) (h : i ≠ j) : coe_fn (scalar n) a i j = 0 :=\n  sorry\n\ntheorem scalar_inj {n : Type u_3} [fintype n] {α : Type v} [semiring α] [DecidableEq n] [Nonempty n]\n    {r : α} {s : α} : coe_fn (scalar n) r = coe_fn (scalar n) s ↔ r = s :=\n  sorry\n\ntheorem smul_eq_mul_diagonal {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [comm_semiring α] [DecidableEq n] (M : matrix m n α) (a : α) :\n    a • M = matrix.mul M (diagonal fun (_x : n) => a) :=\n  sorry\n\n@[simp] theorem mul_smul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m]\n    [fintype n] {α : Type v} [comm_semiring α] (M : matrix m n α) (a : α) (N : matrix n l α) :\n    matrix.mul M (a • N) = a • matrix.mul M N :=\n  ext fun (i : m) (j : l) => dot_product_smul a (fun (j : n) => M i j) fun (i : n) => N i j\n\n@[simp] theorem mul_mul_right {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [comm_semiring α] (M : matrix m n α) (N : matrix n o α) (a : α) :\n    (matrix.mul M fun (i : n) (j : o) => a * N i j) = a • matrix.mul M N :=\n  sorry\n\ntheorem scalar.commute {n : Type u_3} [fintype n] {α : Type v} [comm_semiring α] [DecidableEq n]\n    (r : α) (M : matrix n n α) : commute (coe_fn (scalar n) r) M :=\n  sorry\n\n/-- For two vectors `w` and `v`, `vec_mul_vec w v i j` is defined to be `w i * v j`.\n    Put another way, `vec_mul_vec w v` is exactly `col w ⬝ row v`. -/\ndef vec_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    (w : m → α) (v : n → α) : matrix m n α :=\n  sorry\n\n/-- `mul_vec M v` is the matrix-vector product of `M` and `v`, where `v` is seen as a column matrix.\n    Put another way, `mul_vec M v` is the vector whose entries\n    are those of `M ⬝ col v` (see `col_mul_vec`). -/\ndef mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    (M : matrix m n α) (v : n → α) : m → α :=\n  sorry\n\n/-- `vec_mul v M` is the vector-matrix product of `v` and `M`, where `v` is seen as a row matrix.\n    Put another way, `vec_mul v M` is the vector whose entries\n    are those of `row v ⬝ M` (see `row_vec_mul`). -/\ndef vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    (v : m → α) (M : matrix m n α) : n → α :=\n  sorry\n\nprotected instance mul_vec.is_add_monoid_hom_left {m : Type u_2} {n : Type u_3} [fintype m]\n    [fintype n] {α : Type v} [semiring α] (v : n → α) :\n    is_add_monoid_hom fun (M : matrix m n α) => mul_vec M v :=\n  is_add_monoid_hom.mk\n    (funext\n      fun (x : m) =>\n        eq.mpr\n          (id\n            (Eq.trans\n              ((fun (a a_1 : α) (e_1 : a = a_1) (ᾰ ᾰ_1 : α) (e_2 : ᾰ = ᾰ_1) =>\n                  congr (congr_arg Eq e_1) e_2)\n                (mul_vec 0 v x) 0\n                (Eq.trans\n                  (Eq.trans (mul_vec.equations._eqn_1 0 v x)\n                    ((fun [_inst_2 : fintype n] {α : Type v} (v v_1 : n → α) (e_5 : v = v_1)\n                        (w w_1 : n → α) (e_6 : w = w_1) =>\n                        eq.drec (eq.drec (Eq.refl (dot_product v w)) e_6) e_5)\n                      (fun (j : n) => HasZero.zero x j) (fun (j : n) => 0)\n                      (funext fun (j : n) => zero_apply x j) v v (Eq.refl v)))\n                  (zero_dot_product' v))\n                (HasZero.zero x) 0 (pi.zero_apply x))\n              (propext (eq_self_iff_true 0))))\n          trivial)\n\ntheorem mul_vec_diagonal {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m]\n    (v : m → α) (w : m → α) (x : m) : mul_vec (diagonal v) w x = v x * w x :=\n  diagonal_dot_product v w x\n\ntheorem vec_mul_diagonal {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m]\n    (v : m → α) (w : m → α) (x : m) : vec_mul v (diagonal w) x = v x * w x :=\n  dot_product_diagonal' v w x\n\n@[simp] theorem mul_vec_one {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m]\n    (v : m → α) : mul_vec 1 v = v :=\n  sorry\n\n@[simp] theorem vec_mul_one {m : Type u_2} [fintype m] {α : Type v} [semiring α] [DecidableEq m]\n    (v : m → α) : vec_mul v 1 = v :=\n  sorry\n\n@[simp] theorem mul_vec_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] (A : matrix m n α) : mul_vec A 0 = 0 :=\n  sorry\n\n@[simp] theorem vec_mul_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] (A : matrix m n α) : vec_mul 0 A = 0 :=\n  sorry\n\n@[simp] theorem vec_mul_vec_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [semiring α] (v : m → α) (M : matrix m n α) (N : matrix n o α) :\n    vec_mul (vec_mul v M) N = vec_mul v (matrix.mul M N) :=\n  funext fun (x : o) => dot_product_assoc v (fun (i : m) (j : n) => M i j) fun (i : n) => N i x\n\n@[simp] theorem mul_vec_mul_vec {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} [semiring α] (v : o → α) (M : matrix m n α) (N : matrix n o α) :\n    mul_vec M (mul_vec N v) = mul_vec (matrix.mul M N) v :=\n  funext\n    fun (x : m) =>\n      Eq.symm (dot_product_assoc (fun (j : n) => M x j) (fun (i : n) (j : o) => N i j) v)\n\ntheorem vec_mul_vec_eq {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] (w : m → α) (v : n → α) : vec_mul_vec w v = matrix.mul (col w) (row v) :=\n  sorry\n\n/--\n`std_basis_matrix i j a` is the matrix with `a` in the `i`-th row, `j`-th column,\nand zeroes elsewhere.\n-/\ndef std_basis_matrix {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : α) : matrix m n α :=\n  fun (i' : m) (j' : n) => ite (i' = i ∧ j' = j) a 0\n\n@[simp] theorem smul_std_basis_matrix {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} [semiring α] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : α) (b : α) :\n    b • std_basis_matrix i j a = std_basis_matrix i j (b • a) :=\n  sorry\n\n@[simp] theorem std_basis_matrix_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} [semiring α] [DecidableEq m] [DecidableEq n] (i : m) (j : n) :\n    std_basis_matrix i j 0 = 0 :=\n  sorry\n\ntheorem std_basis_matrix_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : α) (b : α) :\n    std_basis_matrix i j (a + b) = std_basis_matrix i j a + std_basis_matrix i j b :=\n  sorry\n\ntheorem matrix_eq_sum_std_basis {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] [DecidableEq m] [DecidableEq n] (x : matrix n m α) :\n    x =\n        finset.sum finset.univ\n          fun (i : n) => finset.sum finset.univ fun (j : m) => std_basis_matrix i j (x i j) :=\n  sorry\n\n-- TODO: tie this up with the `basis` machinery of linear algebra\n\n-- this is not completely trivial because we are indexing by two types, instead of one\n\n-- TODO: add `std_basis_vec`\n\ntheorem std_basis_eq_basis_mul_basis {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    [DecidableEq m] [DecidableEq n] (i : m) (j : n) :\n    std_basis_matrix i j 1 =\n        vec_mul_vec (fun (i' : m) => ite (i = i') 1 0) fun (j' : n) => ite (j = j') 1 0 :=\n  sorry\n\nprotected theorem induction_on' {n : Type u_3} [fintype n] [DecidableEq n] {X : Type u_1}\n    [semiring X] {M : matrix n n X → Prop} (m : matrix n n X) (h_zero : M 0)\n    (h_add : ∀ (p q : matrix n n X), M p → M q → M (p + q))\n    (h_std_basis : ∀ (i j : n) (x : X), M (std_basis_matrix i j x)) : M m :=\n  sorry\n\nprotected theorem induction_on {n : Type u_3} [fintype n] [DecidableEq n] [Nonempty n]\n    {X : Type u_1} [semiring X] {M : matrix n n X → Prop} (m : matrix n n X)\n    (h_add : ∀ (p q : matrix n n X), M p → M q → M (p + q))\n    (h_std_basis : ∀ (i j : n) (x : X), M (std_basis_matrix i j x)) : M m :=\n  sorry\n\ntheorem neg_vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α]\n    (v : m → α) (A : matrix m n α) : vec_mul (-v) A = -vec_mul v A :=\n  funext fun (x : n) => neg_dot_product v fun (i : m) => A i x\n\ntheorem vec_mul_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α]\n    (v : m → α) (A : matrix m n α) : vec_mul v (-A) = -vec_mul v A :=\n  funext fun (x : n) => dot_product_neg v fun (i : m) => A i x\n\ntheorem neg_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α]\n    (v : n → α) (A : matrix m n α) : mul_vec (-A) v = -mul_vec A v :=\n  funext fun (x : m) => neg_dot_product (fun (i : n) => A x i) v\n\ntheorem mul_vec_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [ring α]\n    (v : n → α) (A : matrix m n α) : mul_vec A (-v) = -mul_vec A v :=\n  funext fun (x : m) => dot_product_neg (fun (j : n) => A x j) v\n\ntheorem smul_mul_vec_assoc {n : Type u_3} [fintype n] {α : Type v} [ring α] (A : matrix n n α)\n    (b : n → α) (a : α) : mul_vec (a • A) b = a • mul_vec A b :=\n  sorry\n\n/--\n  Tell `simp` what the entries are in a transposed matrix.\n\n  Compare with `mul_apply`, `diagonal_apply_eq`, etc.\n-/\n@[simp] theorem transpose_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    (M : matrix m n α) (i : m) (j : n) : transpose M j i = M i j :=\n  rfl\n\n@[simp] theorem transpose_transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} (M : matrix m n α) : transpose (transpose M) = M :=\n  ext fun (i : m) (j : n) => Eq.refl (transpose (transpose M) i j)\n\n@[simp] theorem transpose_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [HasZero α] : transpose 0 = 0 :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose 0 i j)\n\n@[simp] theorem transpose_one {n : Type u_3} [fintype n] {α : Type v} [DecidableEq n] [HasZero α]\n    [HasOne α] : transpose 1 = 1 :=\n  sorry\n\n@[simp] theorem transpose_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [Add α] (M : matrix m n α) (N : matrix m n α) : transpose (M + N) = transpose M + transpose N :=\n  sorry\n\n@[simp] theorem transpose_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [add_group α] (M : matrix m n α) (N : matrix m n α) :\n    transpose (M - N) = transpose M - transpose N :=\n  sorry\n\n@[simp] theorem transpose_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m]\n    [fintype n] {α : Type v} [comm_semiring α] (M : matrix m n α) (N : matrix n l α) :\n    transpose (matrix.mul M N) = matrix.mul (transpose N) (transpose M) :=\n  ext\n    fun (i : l) (j : m) =>\n      dot_product_comm (fun (i : n) => (fun (j_1 : n) => M j j_1) i)\n        fun (i_1 : n) => (fun (j : n) => N j i) i_1\n\n@[simp] theorem transpose_smul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [semiring α] (c : α) (M : matrix m n α) : transpose (c • M) = c • transpose M :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose (c • M) i j)\n\n@[simp] theorem transpose_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    [Neg α] (M : matrix m n α) : transpose (-M) = -transpose M :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose (-M) i j)\n\ntheorem transpose_map {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {β : Type w} {f : α → β} {M : matrix m n α} : map (transpose M) f = transpose (map M f) :=\n  ext fun (i : n) (j : m) => Eq.refl (map (transpose M) f i j)\n\n/--\nWhen `R` is a *-(semi)ring, `matrix n n R` becomes a *-(semi)ring with\nthe star operation given by taking the conjugate, and the star of each entry.\n-/\nprotected instance star_ring {n : Type u_3} [fintype n] [DecidableEq n] {R : Type u_5} [semiring R]\n    [star_ring R] : star_ring (matrix n n R) :=\n  star_ring.mk sorry\n\n@[simp] theorem star_apply {n : Type u_3} [fintype n] [DecidableEq n] {R : Type u_5} [semiring R]\n    [star_ring R] (M : matrix n n R) (i : n) (j : n) : star M i j = star (M j i) :=\n  rfl\n\n/-- `M.minor row col` is the matrix obtained by reindexing the rows and the lines of\n    `M`, such that `M.minor row col i j = M (row i) (col j)`. Note that the total number\n    of row/colums doesn't have to be preserved. -/\ndef minor {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m]\n    [fintype n] [fintype o] {α : Type v} (A : matrix m n α) (row : l → m) (col : o → n) :\n    matrix l o α :=\n  fun (i : l) (j : o) => A (row i) (col j)\n\n/-- The left `n × l` part of a `n × (l+r)` matrix. -/\ndef sub_left {α : Type v} {m : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin m) (fin (l + r)) α) :\n    matrix (fin m) (fin l) α :=\n  minor A id ⇑(fin.cast_add r)\n\n/-- The right `n × r` part of a `n × (l+r)` matrix. -/\ndef sub_right {α : Type v} {m : ℕ} {l : ℕ} {r : ℕ} (A : matrix (fin m) (fin (l + r)) α) :\n    matrix (fin m) (fin r) α :=\n  minor A id ⇑(fin.nat_add l)\n\n/-- The top `u × n` part of a `(u+d) × n` matrix. -/\ndef sub_up {α : Type v} {d : ℕ} {u : ℕ} {n : ℕ} (A : matrix (fin (u + d)) (fin n) α) :\n    matrix (fin u) (fin n) α :=\n  minor A (⇑(fin.cast_add d)) id\n\n/-- The bottom `d × n` part of a `(u+d) × n` matrix. -/\ndef sub_down {α : Type v} {d : ℕ} {u : ℕ} {n : ℕ} (A : matrix (fin (u + d)) (fin n) α) :\n    matrix (fin d) (fin n) α :=\n  minor A (⇑(fin.nat_add u)) id\n\n/-- The top-right `u × r` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_up_right {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ}\n    (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin u) (fin r) α :=\n  sub_up (sub_right A)\n\n/-- The bottom-right `d × r` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_down_right {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ}\n    (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin d) (fin r) α :=\n  sub_down (sub_right A)\n\n/-- The top-left `u × l` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_up_left {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ}\n    (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin u) (fin l) α :=\n  sub_up (sub_left A)\n\n/-- The bottom-left `d × l` part of a `(u+d) × (l+r)` matrix. -/\ndef sub_down_left {α : Type v} {d : ℕ} {u : ℕ} {l : ℕ} {r : ℕ}\n    (A : matrix (fin (u + d)) (fin (l + r)) α) : matrix (fin d) (fin l) α :=\n  sub_down (sub_left A)\n\n/-!\n### `row_col` section\n\nSimplification lemmas for `matrix.row` and `matrix.col`.\n-/\n\n@[simp] theorem col_add {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α)\n    (w : m → α) : col (v + w) = col v + col w :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (v + w) i j)\n\n@[simp] theorem col_smul {m : Type u_2} [fintype m] {α : Type v} [semiring α] (x : α) (v : m → α) :\n    col (x • v) = x • col v :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (x • v) i j)\n\n@[simp] theorem row_add {m : Type u_2} [fintype m] {α : Type v} [semiring α] (v : m → α)\n    (w : m → α) : row (v + w) = row v + row w :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (v + w) i j)\n\n@[simp] theorem row_smul {m : Type u_2} [fintype m] {α : Type v} [semiring α] (x : α) (v : m → α) :\n    row (x • v) = x • row v :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (x • v) i j)\n\n@[simp] theorem col_apply {m : Type u_2} [fintype m] {α : Type v} (v : m → α) (i : m) (j : Unit) :\n    col v i j = v i :=\n  rfl\n\n@[simp] theorem row_apply {m : Type u_2} [fintype m] {α : Type v} (v : m → α) (i : Unit) (j : m) :\n    row v i j = v j :=\n  rfl\n\n@[simp] theorem transpose_col {m : Type u_2} [fintype m] {α : Type v} (v : m → α) :\n    transpose (col v) = row v :=\n  ext fun (i : Unit) (j : m) => Eq.refl (transpose (col v) i j)\n\n@[simp] theorem transpose_row {m : Type u_2} [fintype m] {α : Type v} (v : m → α) :\n    transpose (row v) = col v :=\n  ext fun (i : m) (j : Unit) => Eq.refl (transpose (row v) i j)\n\ntheorem row_vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    (M : matrix m n α) (v : m → α) : row (vec_mul v M) = matrix.mul (row v) M :=\n  ext fun (i : Unit) (j : n) => Eq.refl (row (vec_mul v M) i j)\n\ntheorem col_vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    (M : matrix m n α) (v : m → α) : col (vec_mul v M) = transpose (matrix.mul (row v) M) :=\n  ext fun (i : n) (j : Unit) => Eq.refl (col (vec_mul v M) i j)\n\ntheorem col_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    (M : matrix m n α) (v : n → α) : col (mul_vec M v) = matrix.mul M (col v) :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (mul_vec M v) i j)\n\ntheorem row_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [semiring α]\n    (M : matrix m n α) (v : n → α) : row (mul_vec M v) = transpose (matrix.mul M (col v)) :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (mul_vec M v) i j)\n\n/-- Update, i.e. replace the `i`th row of matrix `A` with the values in `b`. -/\ndef update_row {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [DecidableEq n]\n    (M : matrix n m α) (i : n) (b : m → α) : matrix n m α :=\n  function.update M i b\n\n/-- Update, i.e. replace the `j`th column of matrix `A` with the values in `b`. -/\ndef update_column {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v} [DecidableEq m]\n    (M : matrix n m α) (j : m) (b : n → α) : matrix n m α :=\n  fun (i : n) => function.update (M i) j (b i)\n\n@[simp] theorem update_row_self {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix n m α} {i : n} {b : m → α} [DecidableEq n] : update_row M i b i = b :=\n  function.update_same i b M\n\n@[simp] theorem update_column_self {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {α : Type v} {M : matrix n m α} {i : n} {j : m} {c : n → α} [DecidableEq m] :\n    update_column M j c i j = c i :=\n  function.update_same j (c i) (M i)\n\n@[simp] theorem update_row_ne {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix n m α} {i : n} {b : m → α} [DecidableEq n] {i' : n} (i_ne : i' ≠ i) :\n    update_row M i b i' = M i' :=\n  function.update_noteq i_ne b M\n\n@[simp] theorem update_column_ne {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix n m α} {i : n} {j : m} {c : n → α} [DecidableEq m] {j' : m} (j_ne : j' ≠ j) :\n    update_column M j c i j' = M i j' :=\n  function.update_noteq j_ne (c i) (M i)\n\ntheorem update_row_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix n m α} {i : n} {j : m} {b : m → α} [DecidableEq n] {i' : n} :\n    update_row M i b i' j = ite (i' = i) (b j) (M i' j) :=\n  sorry\n\ntheorem update_column_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix n m α} {i : n} {j : m} {c : n → α} [DecidableEq m] {j' : m} :\n    update_column M j c i j' = ite (j' = j) (c i) (M i j') :=\n  sorry\n\ntheorem update_row_transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix n m α} {j : m} {c : n → α} [DecidableEq m] :\n    update_row (transpose M) j c = transpose (update_column M j c) :=\n  sorry\n\ntheorem update_column_transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {α : Type v}\n    {M : matrix n m α} {i : n} {b : m → α} [DecidableEq n] :\n    update_column (transpose M) i b = transpose (update_row M i b) :=\n  sorry\n\n/-- We can form a single large matrix by flattening smaller 'block' matrices of compatible\ndimensions. -/\ndef from_blocks {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m]\n    [fintype n] [fintype o] {α : Type v} (A : matrix n l α) (B : matrix n m α) (C : matrix o l α)\n    (D : matrix o m α) : matrix (n ⊕ o) (l ⊕ m) α :=\n  sum.elim (fun (i : n) => sum.elim (A i) (B i)) fun (i : o) => sum.elim (C i) (D i)\n\n@[simp] theorem from_blocks_apply₁₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : n) (j : l) :\n    from_blocks A B C D (sum.inl i) (sum.inl j) = A i j :=\n  rfl\n\n@[simp] theorem from_blocks_apply₁₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : n) (j : m) :\n    from_blocks A B C D (sum.inl i) (sum.inr j) = B i j :=\n  rfl\n\n@[simp] theorem from_blocks_apply₂₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : o) (j : l) :\n    from_blocks A B C D (sum.inr i) (sum.inl j) = C i j :=\n  rfl\n\n@[simp] theorem from_blocks_apply₂₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : o) (j : m) :\n    from_blocks A B C D (sum.inr i) (sum.inr j) = D i j :=\n  rfl\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"top left\" submatrix. -/\ndef to_blocks₁₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix n l α :=\n  fun (i : n) (j : l) => M (sum.inl i) (sum.inl j)\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"top right\" submatrix. -/\ndef to_blocks₁₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix n m α :=\n  fun (i : n) (j : m) => M (sum.inl i) (sum.inr j)\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"bottom left\" submatrix. -/\ndef to_blocks₂₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix o l α :=\n  fun (i : o) (j : l) => M (sum.inr i) (sum.inl j)\n\n/-- Given a matrix whose row and column indexes are sum types, we can extract the correspnding\n\"bottom right\" submatrix. -/\ndef to_blocks₂₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix o m α :=\n  fun (i : o) (j : m) => M (sum.inr i) (sum.inr j)\n\ntheorem from_blocks_to_blocks {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (M : matrix (n ⊕ o) (l ⊕ m) α) :\n    from_blocks (to_blocks₁₁ M) (to_blocks₁₂ M) (to_blocks₂₁ M) (to_blocks₂₂ M) = M :=\n  sorry\n\n@[simp] theorem to_blocks_from_blocks₁₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :\n    to_blocks₁₁ (from_blocks A B C D) = A :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks₁₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :\n    to_blocks₁₂ (from_blocks A B C D) = B :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks₂₁ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :\n    to_blocks₂₁ (from_blocks A B C D) = C :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks₂₂ {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :\n    to_blocks₂₂ (from_blocks A B C D) = D :=\n  rfl\n\ntheorem from_blocks_transpose {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4}\n    [fintype l] [fintype m] [fintype n] [fintype o] {α : Type v} (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :\n    transpose (from_blocks A B C D) =\n        from_blocks (transpose A) (transpose C) (transpose B) (transpose D) :=\n  sorry\n\ntheorem from_blocks_smul {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l]\n    [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (x : α) (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :\n    x • from_blocks A B C D = from_blocks (x • A) (x • B) (x • C) (x • D) :=\n  sorry\n\ntheorem from_blocks_add {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l]\n    [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] (A : matrix n l α)\n    (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (A' : matrix n l α) (B' : matrix n m α)\n    (C' : matrix o l α) (D' : matrix o m α) :\n    from_blocks A B C D + from_blocks A' B' C' D' =\n        from_blocks (A + A') (B + B') (C + C') (D + D') :=\n  sorry\n\ntheorem from_blocks_multiply {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l]\n    [fintype m] [fintype n] [fintype o] {α : Type v} [semiring α] {p : Type u_5} {q : Type u_6}\n    [fintype p] [fintype q] (A : matrix n l α) (B : matrix n m α) (C : matrix o l α)\n    (D : matrix o m α) (A' : matrix l p α) (B' : matrix l q α) (C' : matrix m p α)\n    (D' : matrix m q α) :\n    matrix.mul (from_blocks A B C D) (from_blocks A' B' C' D') =\n        from_blocks (matrix.mul A A' + matrix.mul B C') (matrix.mul A B' + matrix.mul B D')\n          (matrix.mul C A' + matrix.mul D C') (matrix.mul C B' + matrix.mul D D') :=\n  sorry\n\n@[simp] theorem from_blocks_diagonal {l : Type u_1} {m : Type u_2} [fintype l] [fintype m]\n    {α : Type v} [semiring α] [DecidableEq l] [DecidableEq m] (d₁ : l → α) (d₂ : m → α) :\n    from_blocks (diagonal d₁) 0 0 (diagonal d₂) = diagonal (sum.elim d₁ d₂) :=\n  sorry\n\n@[simp] theorem from_blocks_one {l : Type u_1} {m : Type u_2} [fintype l] [fintype m] {α : Type v}\n    [semiring α] [DecidableEq l] [DecidableEq m] : from_blocks 1 0 0 1 = 1 :=\n  sorry\n\n/-- `matrix.block_diagonal M` turns `M : o → matrix m n α'` into a\n`m × o`-by`n × o` block matrix which has the entries of `M` along the diagonal\nand zero elsewhere. -/\ndef block_diagonal {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o]\n    {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] : matrix (m × o) (n × o) α :=\n  sorry\n\ntheorem block_diagonal_apply {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] (ik : m × o)\n    (jk : n × o) :\n    block_diagonal M ik jk =\n        ite (prod.snd ik = prod.snd jk) (M (prod.snd ik) (prod.fst ik) (prod.fst jk)) 0 :=\n  prod.cases_on ik\n    fun (ik_fst : m) (ik_snd : o) =>\n      prod.cases_on jk\n        fun (jk_fst : n) (jk_snd : o) =>\n          Eq.refl (block_diagonal M (ik_fst, ik_snd) (jk_fst, jk_snd))\n\n@[simp] theorem block_diagonal_apply_eq {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] (i : m)\n    (j : n) (k : o) : block_diagonal M (i, k) (j, k) = M k i j :=\n  if_pos rfl\n\ntheorem block_diagonal_apply_ne {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] (i : m) (j : n)\n    {k : o} {k' : o} (h : k ≠ k') : block_diagonal M (i, k) (j, k') = 0 :=\n  if_neg h\n\n@[simp] theorem block_diagonal_transpose {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [HasZero α] :\n    transpose (block_diagonal M) = block_diagonal fun (k : o) => transpose (M k) :=\n  sorry\n\n@[simp] theorem block_diagonal_zero {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} [DecidableEq o] [HasZero α] : block_diagonal 0 = 0 :=\n  sorry\n\n@[simp] theorem block_diagonal_diagonal {m : Type u_2} {o : Type u_4} [fintype m] [fintype o]\n    {α : Type v} [DecidableEq o] [HasZero α] [DecidableEq m] (d : o → m → α) :\n    (block_diagonal fun (k : o) => diagonal (d k)) =\n        diagonal fun (ik : m × o) => d (prod.snd ik) (prod.fst ik) :=\n  sorry\n\n@[simp] theorem block_diagonal_one {m : Type u_2} {o : Type u_4} [fintype m] [fintype o]\n    {α : Type v} [DecidableEq o] [HasZero α] [DecidableEq m] [HasOne α] : block_diagonal 1 = 1 :=\n  sorry\n\n@[simp] theorem block_diagonal_add {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) (N : o → matrix m n α)\n    [DecidableEq o] [add_monoid α] : block_diagonal (M + N) = block_diagonal M + block_diagonal N :=\n  sorry\n\n@[simp] theorem block_diagonal_neg {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] [add_group α] :\n    block_diagonal (-M) = -block_diagonal M :=\n  sorry\n\n@[simp] theorem block_diagonal_sub {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) (N : o → matrix m n α)\n    [DecidableEq o] [add_group α] : block_diagonal (M - N) = block_diagonal M - block_diagonal N :=\n  sorry\n\n@[simp] theorem block_diagonal_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] {p : Type u_1}\n    [fintype p] [semiring α] (N : o → matrix n p α) :\n    (block_diagonal fun (k : o) => matrix.mul (M k) (N k)) =\n        matrix.mul (block_diagonal M) (block_diagonal N) :=\n  sorry\n\n@[simp] theorem block_diagonal_smul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m]\n    [fintype n] [fintype o] {α : Type v} (M : o → matrix m n α) [DecidableEq o] {R : Type u_1}\n    [semiring R] [add_comm_monoid α] [semimodule R α] (x : R) :\n    block_diagonal (x • M) = x • block_diagonal M :=\n  sorry\n\nend matrix\n\n\nnamespace ring_hom\n\n\ntheorem map_matrix_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n]\n    [fintype o] {α : Type v} {β : Type u_5} [semiring α] [semiring β] (M : matrix m n α)\n    (N : matrix n o α) (i : m) (j : o) (f : α →+* β) :\n    coe_fn f (matrix.mul M N i j) =\n        matrix.mul (fun (i : m) (j : n) => coe_fn f (M i j))\n          (fun (i : n) (j : o) => coe_fn f (N i j)) i j :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/matrix/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.48547024144426026}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.norm_num\nimport Mathlib.PostPort\n\nuniverses u_1 l \n\nnamespace Mathlib\n\n/-!\n# The `abel` tactic\n\nEvaluate expressions in the language of additive, commutative monoids and groups.\n\n\n-/\n\nnamespace tactic\n\n\nnamespace abel\n\n\ndef term {α : Type u_1} [add_comm_monoid α] (n : ℕ) (x : α) (a : α) : α :=\n  n •ℕ x + a\n\ndef termg {α : Type u_1} [add_comm_group α] (n : ℤ) (x : α) (a : α) : α :=\n  n •ℤ x + a\n\ntheorem const_add_term {α : Type u_1} [add_comm_monoid α] (k : α) (n : ℕ) (x : α) (a : α) (a' : α) (h : k + a = a') : k + term n x a = term n x a' := sorry\n\ntheorem const_add_termg {α : Type u_1} [add_comm_group α] (k : α) (n : ℤ) (x : α) (a : α) (a' : α) (h : k + a = a') : k + termg n x a = termg n x a' := sorry\n\ntheorem term_add_const {α : Type u_1} [add_comm_monoid α] (n : ℕ) (x : α) (a : α) (k : α) (a' : α) (h : a + k = a') : term n x a + k = term n x a' := sorry\n\ntheorem term_add_constg {α : Type u_1} [add_comm_group α] (n : ℤ) (x : α) (a : α) (k : α) (a' : α) (h : a + k = a') : termg n x a + k = termg n x a' := sorry\n\ntheorem term_add_term {α : Type u_1} [add_comm_monoid α] (n₁ : ℕ) (x : α) (a₁ : α) (n₂ : ℕ) (a₂ : α) (n' : ℕ) (a' : α) (h₁ : n₁ + n₂ = n') (h₂ : a₁ + a₂ = a') : term n₁ x a₁ + term n₂ x a₂ = term n' x a' := sorry\n\ntheorem term_add_termg {α : Type u_1} [add_comm_group α] (n₁ : ℤ) (x : α) (a₁ : α) (n₂ : ℤ) (a₂ : α) (n' : ℤ) (a' : α) (h₁ : n₁ + n₂ = n') (h₂ : a₁ + a₂ = a') : termg n₁ x a₁ + termg n₂ x a₂ = termg n' x a' := sorry\n\ntheorem zero_term {α : Type u_1} [add_comm_monoid α] (x : α) (a : α) : term 0 x a = a := sorry\n\ntheorem zero_termg {α : Type u_1} [add_comm_group α] (x : α) (a : α) : termg 0 x a = a := sorry\n\ntheorem term_neg {α : Type u_1} [add_comm_group α] (n : ℤ) (x : α) (a : α) (n' : ℤ) (a' : α) (h₁ : -n = n') (h₂ : -a = a') : -termg n x a = termg n' x a' := sorry\n\ndef smul {α : Type u_1} [add_comm_monoid α] (n : ℕ) (x : α) : α :=\n  n •ℕ x\n\ndef smulg {α : Type u_1} [add_comm_group α] (n : ℤ) (x : α) : α :=\n  n •ℤ x\n\ntheorem zero_smul {α : Type u_1} [add_comm_monoid α] (c : ℕ) : smul c 0 = 0 := sorry\n\ntheorem zero_smulg {α : Type u_1} [add_comm_group α] (c : ℤ) : smulg c 0 = 0 := sorry\n\ntheorem term_smul {α : Type u_1} [add_comm_monoid α] (c : ℕ) (n : ℕ) (x : α) (a : α) (n' : ℕ) (a' : α) (h₁ : c * n = n') (h₂ : smul c a = a') : smul c (term n x a) = term n' x a' := sorry\n\ntheorem term_smulg {α : Type u_1} [add_comm_group α] (c : ℤ) (n : ℤ) (x : α) (a : α) (n' : ℤ) (a' : α) (h₁ : c * n = n') (h₂ : smulg c a = a') : smulg c (termg n x a) = termg n' x a' := sorry\n\ntheorem term_atom {α : Type u_1} [add_comm_monoid α] (x : α) : x = term 1 x 0 := sorry\n\ntheorem term_atomg {α : Type u_1} [add_comm_group α] (x : α) : x = termg 1 x 0 := sorry\n\ntheorem unfold_sub {α : Type u_1} [add_group α] (a : α) (b : α) (c : α) (h : a + -b = c) : a - b = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a - b = c)) (sub_eq_add_neg a b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a + -b = c)) h)) (Eq.refl c))\n\ntheorem unfold_smul {α : Type u_1} [add_comm_monoid α] (n : ℕ) (x : α) (y : α) (h : smul n x = y) : n •ℕ x = y :=\n  h\n\ntheorem unfold_smulg {α : Type u_1} [add_comm_group α] (n : ℕ) (x : α) (y : α) (h : smulg (Int.ofNat n) x = y) : n •ℕ x = y :=\n  h\n\ntheorem unfold_gsmul {α : Type u_1} [add_comm_group α] (n : ℤ) (x : α) (y : α) (h : smulg n x = y) : n •ℤ x = y :=\n  h\n\ntheorem subst_into_smul {α : Type u_1} [add_comm_monoid α] (l : ℕ) (r : α) (tl : ℕ) (tr : α) (t : α) (prl : l = tl) (prr : r = tr) (prt : smul tl tr = t) : smul l r = t := sorry\n\ntheorem subst_into_smulg {α : Type u_1} [add_comm_group α] (l : ℤ) (r : α) (tl : ℤ) (tr : α) (t : α) (prl : l = tl) (prr : r = tr) (prt : smulg tl tr = t) : smulg l r = t := sorry\n\ninductive normalize_mode \nwhere\n| raw : normalize_mode\n| term : normalize_mode\n\nprotected instance normalize_mode.inhabited : Inhabited normalize_mode :=\n  { default := normalize_mode.term }\n\nend abel\n\n\nnamespace interactive\n\n\n/-- Tactic for solving equations in the language of\n*additive*, commutative monoids and groups.\nThis version of `abel` fails if the target is not an equality\nthat is provable by the axioms of commutative monoids/groups. -/\n/--\nEvaluate expressions in the language of *additive*, commutative monoids and groups.\nIt attempts to prove the goal outright if there is no `at`\nspecifier and the target is an equality, but if this\nfails, it falls back to rewriting all monoid expressions into a normal form.\nIf there is an `at` specifier, it rewrites the given target into a normal form.\n```lean\nexample {α : Type*} {a b : α} [add_comm_monoid α] : a + (b + a) = a + a + b := by abel\nexample {α : Type*} {a b : α} [add_comm_group α] : (a + b) - ((b + a) + a) = -a := by abel\nexample {α : Type*} {a b : α} [add_comm_group α] (hyp : a + a - a = b - b) : a = 0 :=\nby { abel at hyp, exact hyp }\n```\n-/\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/abel.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.48547022742720003}}
{"text": "/- -----------------------------------------------------------------------\nPolynomial functors.\n----------------------------------------------------------------------- -/\n\n\n\nimport ..c2_limits\nimport .s1_base_change\nimport .s2_exp\nimport .s3_algebras\n\nnamespace qp\n\nopen stdaux\n\nuniverse variables ℓobjx ℓhomx ℓobj ℓhom\n\n\n\n/- -----------------------------------------------------------------------\nDependent polynomial functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief An induced dependent polynomial functor.\n-/\ndefinition DepPolyFun {C : Cat.{ℓobj ℓhom}}\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {a b c₁ c₂ : C^.obj}\n    (f : C^.hom a b)\n    (h : C^.hom a c₁)\n    (g : C^.hom b c₂)\n    [C_HasDepProd : HasDepProd C f]\n    : Fun (OverCat C c₁) (OverCat C c₂)\n:= DepSumFun g □□ DepProdFun f □□ BaseChangeFun h\n\n/-! #brief A dependent polynomial functor.\n-/\nstructure IsDepPolyFun {C : Cat.{ℓobj ℓhom}}\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {c₁ c₂ : C^.obj}\n    (P : Fun (OverCat C c₁) (OverCat C c₂))\n:= (dom : C^.obj)\n   (codom : C^.obj)\n   (hom : C^.hom dom codom)\n   (dom_out : C^.hom dom c₁)\n   (codom_out : C^.hom codom c₂)\n   (to_poly : NatTrans P (DepPolyFun hom dom_out codom_out))\n   (of_poly : NatTrans (DepPolyFun hom dom_out codom_out) P)\n   (equiv : NatIso to_poly of_poly)\n\n/-! #brief Preservation of co-limits by DepPolyFun.\n-/\ndefinition DepPolyFun.PresCoLimit {C : Cat.{ℓobj ℓhom}}\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {a b c₁ c₂ : C^.obj}\n    {f : C^.hom a b}\n    {h : C^.hom a c₁}\n    {g : C^.hom b c₂}\n    {X : Cat.{ℓobjx ℓhomx}}\n    (L : Fun X (OverCat C c₁))\n    [f_PresCoLimitsFrom : PresCoLimitsFrom (DepProdFun f) X]\n    : PresCoLimit L (DepPolyFun f h g)\n:= @PresCoLimit.comp _ _ _ _\n     L\n     (BaseChangeFun h)\n     (Adj.left.PresCoLimit (BaseChange_DepProd.Adj h) L)\n     (DepSumFun g □□ DepProdFun f)\n     (@PresCoLimit.comp _ _ _ _\n       (Fun.comp (BaseChangeFun h) L)\n       (DepProdFun f) (PresCoLimitsFrom.PresCoLimit (DepProdFun f) _)\n       (DepSumFun g) (Adj.left.PresCoLimit (DepSum_BaseChange.Adj g) _))\n\n/-! #brief Adámek's construction for dependent W-types.\n-/\ndefinition DepPolyFun.Adamek {C : Cat.{ℓobj ℓhom}}\n    [C_HasInit : HasInit C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {a b c : C^.obj} (f : C^.hom a b)\n    [Cc_HasAllCoLimitsFrom : HasAllCoLimitsFrom (OverCat C c) NatCat]\n    [f_PresCoLimitsFrom : PresCoLimitsFrom (DepProdFun f) NatCat]\n    (h : C^.hom a c)\n    (g : C^.hom b c)\n    : HasInitAlg (DepPolyFun f h g)\n:= @Adamek (OverCat C c)\n    (OverCat.HasInit C c)\n    (DepPolyFun f h g)\n    (@HasAllCoLimitsFrom.has_colimit (OverCat C c) NatCat Cc_HasAllCoLimitsFrom\n       (@AdamekFun (OverCat C c) (OverCat.HasInit C c) (DepPolyFun f h g)))\n    (@PresCoLimitsFrom.pres_colimit (OverCat C c) (OverCat C c)\n       (DepPolyFun f h g)\n       NatCat\n       { pres_colimit := λ L, DepPolyFun.PresCoLimit L }\n       (@AdamekFun (OverCat C c) (OverCat.HasInit C c) (DepPolyFun f h g)))\n\n\n\n/- -----------------------------------------------------------------------\nPolynomial endo-functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief An induced polynomial endo-functor.\n-/\ndefinition PolyEndoFun.induce {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {x y : C^.obj}\n    (f : C^.hom x y)\n    : Fun C C\n:= OverFinal.from C\n    □□ DepPolyFun f (final_hom x) (final_hom y)\n    □□ OverFinal.to C\n\n/-! #brief PolyEndoFun is conjugate to DepPolyFun.\n-/\ntheorem PolyEndoFun_conj_DepPolyFun {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {x y : C^.obj}\n    (f : C^.hom x y)\n    : OverFinal.to C □□ PolyEndoFun.induce f □□ OverFinal.from C\n        = DepPolyFun f (final_hom x) (final_hom y)\n:= let bij₂ := (OverFinal.Bij C)^.id₂\nin begin\n     dsimp [PolyEndoFun.induce],\n     repeat { rw Fun.comp_assoc },\n     rw bij₂,\n     repeat { rw -Fun.comp_assoc },\n     rw bij₂,\n     rw [Fun.comp_id_left, Fun.comp_id_right]\n   end\n\n/-! #brief A polynomial endo-functor.\n-/\nstructure PolyEndoFun (C : Cat.{ℓobj ℓhom})\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n:= (endo : Fun C C)\n   (dom : C^.obj)\n   (codom : C^.obj)\n   (hom : C^.hom dom codom)\n   (to_poly : NatTrans endo (PolyEndoFun.induce hom))\n   (of_poly : NatTrans (PolyEndoFun.induce hom) endo)\n   (iso : NatIso to_poly of_poly)\n\n/-! #brief PolyEndoFun.induce is a polynomial endo-functor.\n-/\ndefinition PolyEndoFun.of_hom {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {x y : C^.obj}\n    (f : C^.hom x y)\n    : PolyEndoFun C\n:= { endo := PolyEndoFun.induce f\n   , dom := x\n   , codom := y\n   , hom := f\n   , to_poly := NatTrans.id _\n   , of_poly := NatTrans.id _\n   , iso := NatIso.id\n   }\n\n/-! #brief IsPolyEndoFun casts along natural isomorphisms.\n-/\ndefinition NatIso.IsPolyEndoFun₁ {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    (P₂ : PolyEndoFun C)\n    {P₁ : Fun C C}\n    {η₁₂ : NatTrans P₁ P₂^.endo} {η₂₁ : NatTrans P₂^.endo P₁}\n    (η_iso : NatIso η₁₂ η₂₁)\n    : PolyEndoFun C\n:= { endo := P₁\n   , dom := P₂^.dom\n   , codom := P₂^.codom\n   , hom := P₂^.hom\n   , to_poly := NatTrans.comp P₂^.to_poly η₁₂\n   , of_poly := NatTrans.comp η₂₁ P₂^.of_poly\n   , iso := NatIso.comp P₂^.iso η_iso\n   }\n\ntheorem NatIso.IsPolyEndoFun₁.endo {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {P₂ : PolyEndoFun C}\n    {P₁ : Fun C C}\n    {η₁₂ : NatTrans P₁ P₂^.endo} {η₂₁ : NatTrans P₂^.endo P₁}\n    (η_iso : NatIso η₁₂ η₂₁)\n    : (NatIso.IsPolyEndoFun₁ P₂ η_iso)^.endo = P₁\n:= rfl\n\n/-! #brief IsPolyEndoFun casts along natural isomorphisms.\n-/\ndefinition NatIso.IsPolyEndoFun₂ {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    (P₁ : PolyEndoFun C)\n    {P₂ : Fun C C}\n    {η₁₂ : NatTrans P₁^.endo P₂} {η₂₁ : NatTrans P₂ P₁^.endo}\n    (η_iso : NatIso η₁₂ η₂₁)\n    : PolyEndoFun C\n:= NatIso.IsPolyEndoFun₁ P₁ η_iso^.flip\n\ntheorem NatIso.IsPolyEndoFun₂.endo {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {P₁ : PolyEndoFun C}\n    {P₂ : Fun C C}\n    {η₁₂ : NatTrans P₁^.endo P₂} {η₂₁ : NatTrans P₂ P₁^.endo}\n    (η_iso : NatIso η₁₂ η₂₁)\n    : (NatIso.IsPolyEndoFun₂ P₁ η_iso)^.endo = P₂\n:= rfl\n\n-- /-! #brief Every polynomial endo-functor is a dependent polynomial functor.\n-- -/\n-- definition IsPolyEndoFun.IsDepPolyFun {C : Cat.{ℓobj ℓhom}}\n--     [C_HasFinal : HasFinal C]\n--     [C_HasDepProd : HasDepProd C]\n--     [C_HasAllPullbacks : HasAllPullbacks C]\n--     (P : Fun C C)\n--     (P_IsPolyEndoFun : IsPolyEndoFun P)\n--     : IsDepPolyFun (OverFinal.to C □□ P □□ OverFinal.from C)\n-- := { dom := P_IsPolyEndoFun^.dom\n--    , codom := P_IsPolyEndoFun^.codom\n--    , hom := P_IsPolyEndoFun^.hom\n--    , dom_out := final_hom P_IsPolyEndoFun^.dom\n--    , codom_out := final_hom P_IsPolyEndoFun^.codom\n--    , to_poly\n--       := let trans := NatTrans.whisk_right\n--                        (NatTrans.whisk_left (OverFinal.to C) P_IsPolyEndoFun^.to_poly)\n--                        (OverFinal.from C)\n--          in NatTrans.comp (NatTrans.cast (PolyEndoFun_conj_DepPolyFun _)) trans\n--    , of_poly\n--        := let trans := NatTrans.whisk_right\n--                         (NatTrans.whisk_left (OverFinal.to C) P_IsPolyEndoFun^.of_poly)\n--                         (OverFinal.from C)\n--           in NatTrans.comp trans (NatTrans.cast (eq.symm (PolyEndoFun_conj_DepPolyFun _)))\n--    , equiv\n--       := { id₁ := let foo := P_IsPolyEndoFun^.equiv^.id₁\n--                   in sorry\n--          , id₂ := let foo := P_IsPolyEndoFun^.equiv^.id₂\n--                   in sorry\n--          }\n--    }\n\n\n\n/- -----------------------------------------------------------------------\nSums of polynomial endo-functors.\n----------------------------------------------------------------------- -/\n\ndefinition PolyEndoFun.fincoproduct.IsPolyEndoFun.to_poly {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    [C_HasAllFinCoProducts : HasAllFinCoProducts C]\n    (Ps : list (PolyEndoFun C))\n    : NatTrans (fincoproduct (FunCat C C) (list.map PolyEndoFun.endo Ps))\n               (PolyEndoFun.induce (fincoproduct.hom (HomsList.from_list PolyEndoFun.hom Ps)))\n:= fincoproduct.univ\n     (FunCat C C)\n     (list.map PolyEndoFun.endo Ps)\n     sorry\n\ndefinition PolyEndoFun.fincoproduct.IsPolyEndoFun.of_poly {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    [C_HasAllFinCoProducts : HasAllFinCoProducts C]\n    (Ps : list (PolyEndoFun C))\n    : NatTrans (PolyEndoFun.induce (fincoproduct.hom (HomsList.from_list PolyEndoFun.hom Ps)))\n               (fincoproduct (FunCat C C) (list.map PolyEndoFun.endo Ps))\n:= sorry\n\ndefinition PolyEndoFun.fincoproduct.IsPolyEndoFun.iso {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    [C_HasAllFinCoProducts : HasAllFinCoProducts C]\n    (Ps : list (PolyEndoFun C))\n    : NatIso (PolyEndoFun.fincoproduct.IsPolyEndoFun.to_poly Ps) \n             (PolyEndoFun.fincoproduct.IsPolyEndoFun.of_poly Ps)\n:= sorry\n\n/-! #brief Sum operation on polynomial endo-functors.\n-/\ndefinition PolyEndoFun.sum {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    [C_HasAllFinCoProducts : HasAllFinCoProducts C]\n    (Ps : list (PolyEndoFun C))\n    : PolyEndoFun C\n:= { endo := fincoproduct (FunCat C C) (list.map PolyEndoFun.endo Ps)\n   , dom := _ -- fincoproduct C (list.map PolyEndoFun.dom Ps)\n   , codom := _ -- fincoproduct C (list.map PolyEndoFun.codom Ps)\n   , hom := fincoproduct.hom (HomsList.from_list PolyEndoFun.hom Ps)\n   , to_poly := PolyEndoFun.fincoproduct.IsPolyEndoFun.to_poly Ps\n   , of_poly := PolyEndoFun.fincoproduct.IsPolyEndoFun.of_poly Ps\n   , iso := PolyEndoFun.fincoproduct.IsPolyEndoFun.iso Ps\n   }\n\n/-! #brief Iso for the domain of the sum.\n-/\ndefinition PolyEndoFun.sum.dom_iso {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    [C_HasAllFinCoProducts : HasAllFinCoProducts C]\n    (Ps : list (PolyEndoFun C))\n    : C^.hom (fincoproduct C (list.map PolyEndoFun.dom Ps))\n             (PolyEndoFun.sum Ps)^.dom\n:= cast_hom begin dsimp [PolyEndoFun.sum], rw list.map_map end\n\n/-! #brief Iso for the codomain of the sum.\n-/\ndefinition PolyEndoFun.sum.codom_iso {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    [C_HasAllFinCoProducts : HasAllFinCoProducts C]\n    (Ps : list (PolyEndoFun C))\n    : C^.hom (PolyEndoFun.sum Ps)^.codom\n             (fincoproduct C (list.map PolyEndoFun.codom Ps))\n:= cast_hom begin dsimp [PolyEndoFun.sum], rw list.map_map end\n\n\n\n/- -----------------------------------------------------------------------\nAdámek's construction for polynomial endo-functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief Preservation of co-limits by PolyEndoFun.\n-/\ndefinition PolyEndoFun.PresCoLimit {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {x y : C^.obj}\n    {f : C^.hom x y}\n    {X : Cat.{ℓobjx ℓhomx}}\n    (L : Fun X C)\n    [f_PresCoLimitsFrom : PresCoLimitsFrom (DepProdFun f) X]\n    : PresCoLimit L (PolyEndoFun.induce f)\n:= @PresCoLimit.comp _ _ _ _\n     L\n     (OverFinal.to C)\n     (Adj.left.PresCoLimit (OverFinal.Bij C)^.Adj L)\n     (OverFinal.from C □□ DepPolyFun f (final_hom x) (final_hom y))\n     (@PresCoLimit.comp _ _ _ _\n       (OverFinal.to C □□ L)\n       (DepPolyFun f (final_hom x) (final_hom y)) (DepPolyFun.PresCoLimit _)\n       (OverFinal.from C)\n       (Adj.left.PresCoLimit (OverFinal.Bij C)^.flip^.Adj _))\n\n/-! #brief Adámek's construction for W-types.\n-/\ndefinition PolyEndoFun.Adamek {C : Cat.{ℓobj ℓhom}}\n    [C_HasInit : HasInit C]\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    [C_HasAllCoLimitsFrom : HasAllCoLimitsFrom C NatCat]\n    {x y : C^.obj} (f : C^.hom x y)\n    [f_PresCoLimitsFrom : PresCoLimitsFrom (DepProdFun f) NatCat]\n    : HasInitAlg (PolyEndoFun.induce f)\n:= @Adamek C\n    C_HasInit\n    (PolyEndoFun.induce f)\n    (@HasAllCoLimitsFrom.has_colimit C NatCat C_HasAllCoLimitsFrom\n       (@AdamekFun C C_HasInit (PolyEndoFun.induce f)))\n    (@PresCoLimitsFrom.pres_colimit C C\n       (PolyEndoFun.induce f)\n       NatCat\n       { pres_colimit := λ L, PolyEndoFun.PresCoLimit L }\n       (@AdamekFun C C_HasInit (PolyEndoFun.induce f)))\n\nend qp\n", "meta": {"author": "intoverflow", "repo": "qvr", "sha": "0cfcd33fe4bf8d93851a00cec5bfd21e77105d74", "save_path": "github-repos/lean/intoverflow-qvr", "path": "github-repos/lean/intoverflow-qvr/qvr-0cfcd33fe4bf8d93851a00cec5bfd21e77105d74/qp/p1_categories/c3_wtypes/s4_poly_endofuns.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4853782691274643}}
{"text": "import algebra.field\nimport gtm106.weierstrass_equation.basic\nimport gtm106.weierstrass_equation.point\nimport gtm106.weierstrass_equation.non_singular_criterion\nimport gtm106.weierstrass_equation.linear_change_of_variable\nimport gtm106.weierstrass_equation.intersection_with_line.basic\nimport gtm106.weierstrass_equation.intersection_with_line.linear_change_of_variable\nimport tactic\n\nnamespace weierstrass_equation\n\nnamespace intersection_with_line\n\nlemma disc_zero_implies_tangent.p00\n{K : Type*} [field K] (E : weierstrass_equation K)\n(P : affine_plane_point K)\n(hP' : P = ⟨ 0, 0 ⟩)\n(A : K)\n(hP : E.affine_point_on_curve P)\n(h : (from_point E P A).poly.disc = 0)\n: - E.eval_dx_at_affine_point P = A * E.eval_dy_at_affine_point P\n∨ ((ring_char K = 2 → my_perfect_field K) → ∃ (Q : affine_plane_point K), E.affine_point_on_curve Q ∧ Q.x ≠ 0 ∧ Q.y = A * Q.x ∧ - E.eval_dx_at_affine_point Q = A * E.eval_dy_at_affine_point Q) :=\nbegin\n  simp [affine_point_on_curve, eval_at_affine_point, hP', zero_pow] at hP,\n  simp only [eval_dx_at_affine_point,\n    eval_dy_at_affine_point],\n  simp only [from_point, poly, monic_cubic_poly.disc, a, b, c, hP] at h,\n  simp [hP', zero_pow] at h ⊢,\n  let f : monic_quad_poly K := ⟨ E.a2 - (A + E.a1) * A, E.a4 - A * E.a3 ⟩,\n  have : (E.a2 - (A + E.a1) * A) ^ 2 * (E.a4 - A * E.a3) ^ 2 - 4 * (E.a4 - A * E.a3) ^ 3\n  = f.disc * (E.a4 - A * E.a3) ^ 2 := by {\n    simp only [monic_quad_poly.disc], ring,\n  },\n  rw this at h, clear this,\n  simp at h,\n  by_cases h1 : E.a4 - A * E.a3 = 0, {\n    left,\n    exact sub_eq_zero.1 h1,\n  },\n  right,\n  simp [h1] at h,\n  intro hperfect,\n  rcases f.disc_zero_implies_has_multiple_root hperfect h with ⟨ x, hx1, hx2 ⟩,\n  have hx0 : x ≠ 0 := by {\n    intro hx,\n    simp [hx, monic_quad_poly.eval_at] at hx1,\n    exact h1 hx1,\n  },\n  let Q : affine_plane_point K := ⟨ x, A * x ⟩,\n  use Q,\n  simp [hx0, affine_point_on_curve, eval_at_affine_point,\n    eval_dx_at_affine_point, eval_dy_at_affine_point, hP],\n  split, {\n    transitivity - x * f.eval_at x, {\n      simp only [monic_quad_poly.eval_at], ring,\n    },\n    simp [hx1],\n  },\n  rw ← sub_eq_zero,\n  transitivity f.eval_at x + x * f.eval_dx_at x, {\n    rw ← sub_eq_zero,\n    simp only [monic_quad_poly.eval_at, monic_quad_poly.eval_dx_at],\n    ring,\n  },\n  simp [hx1, hx2],\nend\n\nlemma disc_zero_implies_tangent\n{K : Type*} [field K] (E : weierstrass_equation K)\n(P : affine_plane_point K)\n(A : K)\n(hP : E.affine_point_on_curve P)\n(h : (from_point E P A).poly.disc = 0)\n: - E.eval_dx_at_affine_point P = A * E.eval_dy_at_affine_point P\n∨ ((ring_char K = 2 → my_perfect_field K) → ∃ (Q : affine_plane_point K), E.affine_point_on_curve Q ∧ Q.x ≠ P.x ∧ Q.y - P.y = A * (Q.x - P.x) ∧ - E.eval_dx_at_affine_point Q = A * E.eval_dy_at_affine_point Q) :=\nbegin\n  set! C : linear_change_of_variable K := ⟨ 1, P.x, 0, P.y, by simp ⟩ with hC, clear_value C,\n  set! E' := C.change_curve E with hE', clear_value E',\n  set! P' := C.change_affine_point P with hP', clear_value P',\n  replace h : (from_point E P A).poly.disc / C.u ^ 12 = 0 := by {\n    simp [h],\n  },\n  rw [← disc_lcov _ C, ← from_point_lcov, ← hE', ← hP'] at h,\n  simp [hC] at h,\n  rw [C.preserve_affine_point E P, ← hE', ← hP'] at hP,\n  cases disc_zero_implies_tangent.p00 E' P' (by {\n    simp [hP', hC, linear_change_of_variable.change_affine_point],\n  }) A hP h with h h, {\n    left,\n    simp [hE', hP', hC] at h,\n    exact h,\n  },\n  right,\n  intro hperfect,\n  rcases h hperfect with ⟨ Q', ⟨ h1, h2, h3, h4 ⟩ ⟩,\n  set! Q := C.inverse.change_affine_point Q' with hQ, clear_value Q,\n  apply_fun C.change_affine_point at hQ,\n  simp [linear_change_of_variable.change_affine_point.comp] at hQ,\n  rw [← hQ, hE', ← linear_change_of_variable.preserve_affine_point] at h1,\n  use [Q, h1],\n  simp [← hQ, linear_change_of_variable.change_affine_point, hC] at h2 h3,\n  use [sub_ne_zero.1 h2],\n  split, { rw ← h3, ring, },\n  simp [← hQ, hE', hC] at h4,\n  exact h4,\nend\n\nlemma tangent_implies_disc_zero.p00\n{K : Type*} [field K] (E : weierstrass_equation K)\n(P : affine_plane_point K)\n(hP' : P = ⟨ 0, 0 ⟩)\n(A : K)\n(hP : E.affine_point_on_curve P)\n(h : - E.eval_dx_at_affine_point P = A * E.eval_dy_at_affine_point P)\n: (from_point E P A).poly.disc = 0 :=\nbegin\n  simp [affine_point_on_curve, eval_at_affine_point, hP', zero_pow] at hP,\n  simp only [eval_dx_at_affine_point,\n    eval_dy_at_affine_point] at h,\n  simp only [from_point, poly, monic_cubic_poly.disc, a, b, c, hP],\n  simp [hP', zero_pow] at h ⊢,\n  rw h,\n  ring,\nend\n\nlemma tangent_implies_disc_zero\n{K : Type*} [field K] (E : weierstrass_equation K)\n(P : affine_plane_point K)\n(A : K)\n(hP : E.affine_point_on_curve P)\n(h : - E.eval_dx_at_affine_point P = A * E.eval_dy_at_affine_point P)\n: (from_point E P A).poly.disc = 0 :=\nbegin\n  set! C : linear_change_of_variable K := ⟨ 1, P.x, 0, P.y, by simp ⟩ with hC, clear_value C,\n  set! E' := C.change_curve E with hE', clear_value E',\n  set! P' := C.change_affine_point P with hP', clear_value P',\n  suffices : (from_point E P A).poly.disc / C.u ^ 12 = 0, {\n    simp only [hC, one_pow, div_one] at this,\n    exact this,\n  },\n  rw [← disc_lcov _ C, ← from_point_lcov, ← hE', ← hP'],\n  rw [C.preserve_affine_point E P, ← hE', ← hP'] at hP,\n  simp [hC],\n  apply tangent_implies_disc_zero.p00 E' P' (by {\n    simp [hP', hC, linear_change_of_variable.change_affine_point],\n  }) A hP,\n  simp [hE', hP'],\n  simp [h, hC],\nend\n\nlemma disc_zero_iff_tangent {K : Type*} [field K] (E : weierstrass_equation K)\n(P : affine_plane_point K)\n(A : K)\n(hP : E.affine_point_on_curve P)\n(hperfect : ring_char K = 2 → my_perfect_field K)\n: (from_point E P A).poly.disc = 0\n↔ - E.eval_dx_at_affine_point P = A * E.eval_dy_at_affine_point P\n∨ ∃ (Q : affine_plane_point K), E.affine_point_on_curve Q ∧ Q.x ≠ P.x ∧ Q.y - P.y = A * (Q.x - P.x) ∧ - E.eval_dx_at_affine_point Q = A * E.eval_dy_at_affine_point Q :=\nbegin\n  split, {\n    intro h,\n    cases disc_zero_implies_tangent E P A hP h with h h, {\n      left, exact h,\n    },\n    right, exact h hperfect,\n  },\n  intro h,\n  rcases h with h | ⟨ Q, h1, h2, h3, h4 ⟩, {\n    exact tangent_implies_disc_zero E P A hP h,\n  },\n  replace h3 : Q = (from_point E P A).point Q.x := by {\n    simp [from_point, point, affine_plane_point.ext_iff],\n    rw [← sub_eq_zero, sub_sub, sub_eq_zero] at h3,\n    rw h3, ring,\n  },\n  replace h3 : from_point E P A = from_point E Q A := by {\n    rw [h3, from_point'' E P A Q.x],\n  },\n  rw h3,\n  exact tangent_implies_disc_zero E Q A h1 h4,\nend\n\nend intersection_with_line\n\nend weierstrass_equation\n", "meta": {"author": "acmepjz", "repo": "my-lean-test", "sha": "fd1bb144adc9ccd23794a867a2dd2cf57648b089", "save_path": "github-repos/lean/acmepjz-my-lean-test", "path": "github-repos/lean/acmepjz-my-lean-test/my-lean-test-fd1bb144adc9ccd23794a867a2dd2cf57648b089/gtm106/weierstrass_equation/intersection_with_line/disc_zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.48537824791599654}}
{"text": "/-\nCopyright (c) 2022 Yuma Mizuno. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuma Mizuno\n-/\nimport category_theory.eq_to_hom\nimport category_theory.bicategory.basic\n\n/-!\n# Strict bicategories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA bicategory is called `strict` if the left unitors, the right unitors, and the associators are\nisomorphisms given by equalities.\n\n## Implementation notes\n\nIn the literature of category theory, a strict bicategory (usually called a strict 2-category) is\noften defined as a bicategory whose left unitors, right unitors, and associators are identities.\nWe cannot use this definition directly here since the types of 2-morphisms depend on 1-morphisms.\nFor this reason, we use `eq_to_iso`, which gives isomorphisms from equalities, instead of\nidentities.\n-/\n\nnamespace category_theory\n\nopen_locale bicategory\n\nuniverses w v u\n\nvariables (B : Type u) [bicategory.{w v} B]\n\n/--\nA bicategory is called `strict` if the left unitors, the right unitors, and the associators are\nisomorphisms given by equalities.\n-/\nclass bicategory.strict : Prop :=\n(id_comp' : ∀ {a b : B} (f : a ⟶ b), 𝟙 a ≫ f = f . obviously)\n(comp_id' : ∀ {a b : B} (f : a ⟶ b), f ≫ 𝟙 b = f . obviously)\n(assoc' : ∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d),\n  (f ≫ g) ≫ h = f ≫ (g ≫ h) . obviously)\n(left_unitor_eq_to_iso' : ∀ {a b : B} (f : a ⟶ b),\n  λ_ f = eq_to_iso (id_comp' f) . obviously)\n(right_unitor_eq_to_iso' : ∀ {a b : B} (f : a ⟶ b),\n  ρ_ f = eq_to_iso (comp_id' f) . obviously)\n(associator_eq_to_iso' : ∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d),\n  α_ f g h = eq_to_iso (assoc' f g h) . obviously)\n\nrestate_axiom bicategory.strict.id_comp'\nrestate_axiom bicategory.strict.comp_id'\nrestate_axiom bicategory.strict.assoc'\nrestate_axiom bicategory.strict.left_unitor_eq_to_iso'\nrestate_axiom bicategory.strict.right_unitor_eq_to_iso'\nrestate_axiom bicategory.strict.associator_eq_to_iso'\nattribute [simp]\n  bicategory.strict.id_comp bicategory.strict.left_unitor_eq_to_iso\n  bicategory.strict.comp_id bicategory.strict.right_unitor_eq_to_iso\n  bicategory.strict.assoc bicategory.strict.associator_eq_to_iso\n\n/-- Category structure on a strict bicategory -/\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_bicategory.category [bicategory.strict B] : category B :=\n{ id_comp' := λ a b, bicategory.strict.id_comp,\n  comp_id' := λ a b, bicategory.strict.comp_id,\n  assoc' := λ a b c d, bicategory.strict.assoc }\n\nnamespace bicategory\n\nvariables {B}\n\n@[simp]\nlemma whisker_left_eq_to_hom {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g = h) :\n  f ◁ eq_to_hom η = eq_to_hom (congr_arg2 (≫) rfl η) :=\nby { cases η, simp only [whisker_left_id, eq_to_hom_refl] }\n\n@[simp]\nlemma eq_to_hom_whisker_right {a b c : B} {f g : a ⟶ b} (η : f = g) (h : b ⟶ c) :\n  eq_to_hom η ▷ h = eq_to_hom (congr_arg2 (≫) η rfl) :=\nby { cases η, simp only [id_whisker_right, eq_to_hom_refl] }\n\nend bicategory\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/bicategory/strict.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.48535784750144395}}
{"text": "lemma example2 (x y : mynat) (h : y = x + 7) : 2 * y = 2 * (x + 7) :=\nbegin\nrw h,\nrefl,\nend\n", "meta": {"author": "chanha-park", "repo": "naturalNumberGame", "sha": "4e0d7100ce4575e1add92feefa38b1250431b879", "save_path": "github-repos/lean/chanha-park-naturalNumberGame", "path": "github-repos/lean/chanha-park-naturalNumberGame/naturalNumberGame-4e0d7100ce4575e1add92feefa38b1250431b879/Tutorial/2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.4853578372345544}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.num.bitwise\nimport data.int.char_zero\nimport data.nat.gcd.basic\nimport data.nat.psub\nimport data.nat.size\n\n/-!\n# Properties of the binary representation of integers\n-/\n\nlocal attribute [simp] add_assoc\n\nnamespace pos_num\nvariables {α : Type*}\n\n@[simp, norm_cast] theorem cast_one [has_one α] [has_add α] :\n  ((1 : pos_num) : α) = 1 := rfl\n@[simp] theorem cast_one' [has_one α] [has_add α] : (pos_num.one : α) = 1 := rfl\n@[simp, norm_cast] theorem cast_bit0 [has_one α] [has_add α] (n : pos_num) :\n  (n.bit0 : α) = _root_.bit0 n := rfl\n@[simp, norm_cast] theorem cast_bit1 [has_one α] [has_add α] (n : pos_num) :\n  (n.bit1 : α) = _root_.bit1 n := rfl\n\n@[simp, norm_cast] theorem cast_to_nat [add_monoid_with_one α] :\n  ∀ n : pos_num, ((n : ℕ) : α) = n\n| 1        := nat.cast_one\n| (bit0 p) := (nat.cast_bit0 _).trans $ congr_arg _root_.bit0 p.cast_to_nat\n| (bit1 p) := (nat.cast_bit1 _).trans $ congr_arg _root_.bit1 p.cast_to_nat\n\n@[simp, norm_cast] theorem to_nat_to_int (n : pos_num) : ((n : ℕ) : ℤ) = n :=\ncast_to_nat _\n\n@[simp, norm_cast] theorem cast_to_int [add_group_with_one α] (n : pos_num) :\n  ((n : ℤ) : α) = n :=\nby rw [← to_nat_to_int, int.cast_coe_nat, cast_to_nat]\n\ntheorem succ_to_nat : ∀ n, (succ n : ℕ) = n + 1\n| 1        := rfl\n| (bit0 p) := rfl\n| (bit1 p) := (congr_arg _root_.bit0 (succ_to_nat p)).trans $\n  show ↑p + 1 + ↑p + 1 = ↑p + ↑p + 1 + 1, by simp [add_left_comm]\n\ntheorem one_add (n : pos_num) : 1 + n = succ n := by cases n; refl\ntheorem add_one (n : pos_num) : n + 1 = succ n := by cases n; refl\n\n@[norm_cast]\ntheorem add_to_nat : ∀ m n, ((m + n : pos_num) : ℕ) = m + n\n| 1        b        := by rw [one_add b, succ_to_nat, add_comm]; refl\n| a        1        := by rw [add_one a, succ_to_nat]; refl\n| (bit0 a) (bit0 b) := (congr_arg _root_.bit0 (add_to_nat a b)).trans $ add_add_add_comm _ _ _ _\n| (bit0 a) (bit1 b) := (congr_arg _root_.bit1 (add_to_nat a b)).trans $\n  show ((a + b) + (a + b) + 1 : ℕ) = (a + a) + (b + b + 1), by simp [add_left_comm]\n| (bit1 a) (bit0 b) := (congr_arg _root_.bit1 (add_to_nat a b)).trans $\n  show ((a + b) + (a + b) + 1 : ℕ) = (a + a + 1) + (b + b), by simp [add_comm, add_left_comm]\n| (bit1 a) (bit1 b) :=\n  show (succ (a + b) + succ (a + b) : ℕ) = (a + a + 1) + (b + b + 1),\n  by rw [succ_to_nat, add_to_nat]; simp [add_left_comm]\n\ntheorem add_succ : ∀ (m n : pos_num), m + succ n = succ (m + n)\n| 1        b        := by simp [one_add]\n| (bit0 a) 1        := congr_arg bit0 (add_one a)\n| (bit1 a) 1        := congr_arg bit1 (add_one a)\n| (bit0 a) (bit0 b) := rfl\n| (bit0 a) (bit1 b) := congr_arg bit0 (add_succ a b)\n| (bit1 a) (bit0 b) := rfl\n| (bit1 a) (bit1 b) := congr_arg bit1 (add_succ a b)\n\ntheorem bit0_of_bit0 : Π n, _root_.bit0 n = bit0 n\n| 1        := rfl\n| (bit0 p) := congr_arg bit0 (bit0_of_bit0 p)\n| (bit1 p) := show bit0 (succ (_root_.bit0 p)) = _, by rw bit0_of_bit0; refl\n\ntheorem bit1_of_bit1 (n : pos_num) : _root_.bit1 n = bit1 n :=\nshow _root_.bit0 n + 1 = bit1 n, by rw [add_one, bit0_of_bit0]; refl\n\n@[norm_cast]\ntheorem mul_to_nat (m) : ∀ n, ((m * n : pos_num) : ℕ) = m * n\n| 1        := (mul_one _).symm\n| (bit0 p) := show (↑(m * p) + ↑(m * p) : ℕ) = ↑m * (p + p), by rw [mul_to_nat, left_distrib]\n| (bit1 p) := (add_to_nat (bit0 (m * p)) m).trans $\n  show (↑(m * p) + ↑(m * p) + ↑m : ℕ) = ↑m * (p + p) + m, by rw [mul_to_nat, left_distrib]\n\ntheorem to_nat_pos : ∀ n : pos_num, 0 < (n : ℕ)\n| 1        := zero_lt_one\n| (bit0 p) := let h := to_nat_pos p in add_pos h h\n| (bit1 p) := nat.succ_pos _\n\ntheorem cmp_to_nat_lemma {m n : pos_num} : (m:ℕ) < n → (bit1 m : ℕ) < bit0 n :=\nshow (m:ℕ) < n → (m + m + 1 + 1 : ℕ) ≤ n + n,\nby intro h; rw [nat.add_right_comm m m 1, add_assoc]; exact add_le_add h h\n\ntheorem cmp_swap (m) : ∀n, (cmp m n).swap = cmp n m :=\nby induction m with m IH m IH; intro n;\n   cases n with n n; try {unfold cmp}; try {refl}; rw ←IH; cases cmp m n; refl\n\ntheorem cmp_to_nat : ∀ (m n), (ordering.cases_on (cmp m n) ((m:ℕ) < n) (m = n) ((n:ℕ) < m) : Prop)\n| 1        1        := rfl\n| (bit0 a) 1        := let h : (1:ℕ) ≤ a := to_nat_pos a in add_le_add h h\n| (bit1 a) 1        := nat.succ_lt_succ $ to_nat_pos $ bit0 a\n| 1        (bit0 b) := let h : (1:ℕ) ≤ b := to_nat_pos b in add_le_add h h\n| 1        (bit1 b) := nat.succ_lt_succ $ to_nat_pos $ bit0 b\n| (bit0 a) (bit0 b) := begin\n    have := cmp_to_nat a b, revert this, cases cmp a b; dsimp; intro,\n    { exact add_lt_add this this },\n    { rw this },\n    { exact add_lt_add this this }\n  end\n| (bit0 a) (bit1 b) := begin dsimp [cmp],\n    have := cmp_to_nat a b, revert this, cases cmp a b; dsimp; intro,\n    { exact nat.le_succ_of_le (add_lt_add this this) },\n    { rw this, apply nat.lt_succ_self },\n    { exact cmp_to_nat_lemma this }\n  end\n| (bit1 a) (bit0 b) := begin dsimp [cmp],\n    have := cmp_to_nat a b, revert this, cases cmp a b; dsimp; intro,\n    { exact cmp_to_nat_lemma this },\n    { rw this, apply nat.lt_succ_self },\n    { exact nat.le_succ_of_le (add_lt_add this this) },\n  end\n| (bit1 a) (bit1 b) := begin\n    have := cmp_to_nat a b, revert this, cases cmp a b; dsimp; intro,\n    { exact nat.succ_lt_succ (add_lt_add this this) },\n    { rw this },\n    { exact nat.succ_lt_succ (add_lt_add this this) }\n  end\n\n@[norm_cast]\ntheorem lt_to_nat {m n : pos_num} : (m:ℕ) < n ↔ m < n :=\nshow (m:ℕ) < n ↔ cmp m n = ordering.lt, from\nmatch cmp m n, cmp_to_nat m n with\n| ordering.lt, h := by simp at h; simp [h]\n| ordering.eq, h := by simp at h; simp [h, lt_irrefl]; exact dec_trivial\n| ordering.gt, h := by simp [not_lt_of_gt h]; exact dec_trivial\nend\n\n@[norm_cast]\ntheorem le_to_nat {m n : pos_num} : (m:ℕ) ≤ n ↔ m ≤ n :=\nby rw ← not_lt; exact not_congr lt_to_nat\n\nend pos_num\n\nnamespace num\nvariables {α : Type*}\nopen pos_num\n\ntheorem add_zero (n : num) : n + 0 = n := by cases n; refl\ntheorem zero_add (n : num) : 0 + n = n := by cases n; refl\n\ntheorem add_one : ∀ n : num, n + 1 = succ n\n| 0       := rfl\n| (pos p) := by cases p; refl\n\ntheorem add_succ : ∀ (m n : num), m + succ n = succ (m + n)\n| 0       n       := by simp [zero_add]\n| (pos p) 0       := show pos (p + 1) = succ (pos p + 0),\n                     by rw [pos_num.add_one, add_zero]; refl\n| (pos p) (pos q) := congr_arg pos (pos_num.add_succ _ _)\n\ntheorem bit0_of_bit0 : ∀ n : num, bit0 n = n.bit0\n| 0       := rfl\n| (pos p) := congr_arg pos p.bit0_of_bit0\n\ntheorem bit1_of_bit1 : ∀ n : num, bit1 n = n.bit1\n| 0       := rfl\n| (pos p) := congr_arg pos p.bit1_of_bit1\n\n@[simp] lemma of_nat'_zero : num.of_nat' 0 = 0 :=\nby simp [num.of_nat']\n\nlemma of_nat'_bit (b n) : of_nat' (nat.bit b n) = cond b num.bit1 num.bit0 (of_nat' n) :=\nnat.binary_rec_eq rfl _ _\n\n@[simp] lemma of_nat'_one : num.of_nat' 1 = 1 :=\nby erw [of_nat'_bit tt 0, cond, of_nat'_zero]; refl\n\nlemma bit1_succ : ∀ n : num, n.bit1.succ = n.succ.bit0\n| 0 := rfl\n| (pos n) := rfl\n\nlemma of_nat'_succ : ∀ {n}, of_nat' (n + 1) = of_nat' n + 1 :=\nnat.binary_rec (by simp; refl) $ λ b n ih,\nbegin\n  cases b,\n  { erw [of_nat'_bit tt n, of_nat'_bit],\n    simp only [← bit1_of_bit1, ← bit0_of_bit0, cond, _root_.bit1] },\n  { erw [show n.bit tt + 1 = (n + 1).bit ff, by simp [nat.bit, _root_.bit1, _root_.bit0]; cc,\n      of_nat'_bit, of_nat'_bit, ih],\n    simp only [cond, add_one, bit1_succ], },\nend\n\n@[simp] theorem add_of_nat' (m n) : num.of_nat' (m + n) = num.of_nat' m + num.of_nat' n :=\nby induction n; simp [nat.add_zero, of_nat'_succ, add_zero, nat.add_succ, add_one, add_succ, *]\n\n@[simp, norm_cast] theorem cast_zero [has_zero α] [has_one α] [has_add α] :\n  ((0 : num) : α) = 0 := rfl\n\n@[simp] theorem cast_zero' [has_zero α] [has_one α] [has_add α] :\n  (num.zero : α) = 0 := rfl\n\n@[simp, norm_cast] theorem cast_one [has_zero α] [has_one α] [has_add α] :\n  ((1 : num) : α) = 1 := rfl\n\n@[simp] theorem cast_pos [has_zero α] [has_one α] [has_add α]\n  (n : pos_num) : (num.pos n : α) = n := rfl\n\ntheorem succ'_to_nat : ∀ n, (succ' n : ℕ) = n + 1\n| 0       := (_root_.zero_add _).symm\n| (pos p) := pos_num.succ_to_nat _\n\ntheorem succ_to_nat (n) : (succ n : ℕ) = n + 1 := succ'_to_nat n\n\n@[simp, norm_cast] theorem cast_to_nat [add_monoid_with_one α] : ∀ n : num, ((n : ℕ) : α) = n\n| 0       := nat.cast_zero\n| (pos p) := p.cast_to_nat\n\n@[norm_cast]\ntheorem add_to_nat : ∀ m n, ((m + n : num) : ℕ) = m + n\n| 0       0       := rfl\n| 0       (pos q) := (_root_.zero_add _).symm\n| (pos p) 0       := rfl\n| (pos p) (pos q) := pos_num.add_to_nat _ _\n\n@[norm_cast]\ntheorem mul_to_nat : ∀ m n, ((m * n : num) : ℕ) = m * n\n| 0       0       := rfl\n| 0       (pos q) := (zero_mul _).symm\n| (pos p) 0       := rfl\n| (pos p) (pos q) := pos_num.mul_to_nat _ _\n\ntheorem cmp_to_nat : ∀ (m n), (ordering.cases_on (cmp m n) ((m:ℕ) < n) (m = n) ((n:ℕ) < m) : Prop)\n| 0       0       := rfl\n| 0       (pos b) := to_nat_pos _\n| (pos a) 0       := to_nat_pos _\n| (pos a) (pos b) :=\n  by { have := pos_num.cmp_to_nat a b; revert this; dsimp [cmp];\n       cases pos_num.cmp a b, exacts [id, congr_arg pos, id] }\n\n@[norm_cast]\ntheorem lt_to_nat {m n : num} : (m:ℕ) < n ↔ m < n :=\nshow (m:ℕ) < n ↔ cmp m n = ordering.lt, from\nmatch cmp m n, cmp_to_nat m n with\n| ordering.lt, h := by simp at h; simp [h]\n| ordering.eq, h := by simp at h; simp [h, lt_irrefl]; exact dec_trivial\n| ordering.gt, h := by simp [not_lt_of_gt h]; exact dec_trivial\nend\n\n@[norm_cast]\ntheorem le_to_nat {m n : num} : (m:ℕ) ≤ n ↔ m ≤ n :=\nby rw ← not_lt; exact not_congr lt_to_nat\n\nend num\n\nnamespace pos_num\n\n@[simp] theorem of_to_nat' : Π (n : pos_num), num.of_nat' (n : ℕ) = num.pos n\n| 1        := by erw [@num.of_nat'_bit tt 0, num.of_nat'_zero]; refl\n| (bit0 p) := by erw [@num.of_nat'_bit ff, of_to_nat']; refl\n| (bit1 p) := by erw [@num.of_nat'_bit tt, of_to_nat']; refl\nend pos_num\n\nnamespace num\n\n@[simp, norm_cast] theorem of_to_nat' : Π (n : num), num.of_nat' (n : ℕ) = n\n| 0       := of_nat'_zero\n| (pos p) := p.of_to_nat'\n\n@[norm_cast] theorem to_nat_inj {m n : num} : (m : ℕ) = n ↔ m = n :=\n⟨λ h, function.left_inverse.injective of_to_nat' h, congr_arg _⟩\n\n/--\nThis tactic tries to turn an (in)equality about `num`s to one about `nat`s by rewriting.\n```lean\nexample (n : num) (m : num) : n ≤ n + m :=\nbegin\n  num.transfer_rw,\n  exact nat.le_add_right _ _\nend\n```\n-/\nmeta def transfer_rw : tactic unit :=\n`[repeat {rw ← to_nat_inj <|> rw ← lt_to_nat <|> rw ← le_to_nat},\n  repeat {rw add_to_nat <|> rw mul_to_nat <|> rw cast_one <|> rw cast_zero}]\n\n/--\nThis tactic tries to prove (in)equalities about `num`s by transfering them to the `nat` world and\nthen trying to call `simp`.\n```lean\nexample (n : num) (m : num) : n ≤ n + m := by num.transfer\n```\n-/\nmeta def transfer : tactic unit := `[intros, transfer_rw, try {simp}]\n\ninstance : add_monoid num :=\n{ add := (+),\n  zero := 0,\n  zero_add := zero_add,\n  add_zero := add_zero,\n  add_assoc := by transfer }\n\ninstance : add_monoid_with_one num :=\n{ nat_cast := num.of_nat',\n  one := 1,\n  nat_cast_zero := of_nat'_zero,\n  nat_cast_succ := λ _, of_nat'_succ,\n  .. num.add_monoid }\n\ninstance : comm_semiring num :=\nby refine_struct\n{ mul := (*),\n  one := 1,\n  add := (+),\n  zero := 0,\n  npow := @npow_rec num ⟨1⟩ ⟨(*)⟩,\n  .. num.add_monoid, .. num.add_monoid_with_one };\ntry { intros, refl }; try { transfer };\nsimp [add_comm, mul_add, add_mul, mul_assoc, mul_comm, mul_left_comm]\n\ninstance : ordered_cancel_add_comm_monoid num :=\n{ lt                         := (<),\n  lt_iff_le_not_le           := by {intros a b, transfer_rw, apply lt_iff_le_not_le},\n  le                         := (≤),\n  le_refl                    := by transfer,\n  le_trans                   := by {intros a b c, transfer_rw, apply le_trans},\n  le_antisymm                := by {intros a b, transfer_rw, apply le_antisymm},\n  add_le_add_left            := by {intros a b h c, revert h, transfer_rw,\n    exact λ h, add_le_add_left h c},\n  le_of_add_le_add_left      := by {intros a b c, transfer_rw, apply le_of_add_le_add_left},\n  ..num.comm_semiring }\n\ninstance : linear_ordered_semiring num :=\n{ le_total                   := by {intros a b, transfer_rw, apply le_total},\n  zero_le_one                := dec_trivial,\n  mul_lt_mul_of_pos_left     := by {intros a b c, transfer_rw, apply mul_lt_mul_of_pos_left},\n  mul_lt_mul_of_pos_right    := by {intros a b c, transfer_rw, apply mul_lt_mul_of_pos_right},\n  decidable_lt               := num.decidable_lt,\n  decidable_le               := num.decidable_le,\n  decidable_eq               := num.decidable_eq,\n  exists_pair_ne             := ⟨0, 1, dec_trivial⟩,\n  ..num.comm_semiring, ..num.ordered_cancel_add_comm_monoid }\n\n@[simp, norm_cast] theorem add_of_nat (m n) : ((m + n : ℕ) : num) = m + n :=\nadd_of_nat' _ _\n\n@[simp, norm_cast] theorem to_nat_to_int (n : num) : ((n : ℕ) : ℤ) = n :=\ncast_to_nat _\n\n@[simp, norm_cast] theorem cast_to_int {α} [add_group_with_one α] (n : num) : ((n : ℤ) : α) = n :=\nby rw [← to_nat_to_int, int.cast_coe_nat, cast_to_nat]\n\ntheorem to_of_nat : Π (n : ℕ), ((n : num) : ℕ) = n\n| 0     := by rw [nat.cast_zero, cast_zero]\n| (n+1) := by rw [nat.cast_succ, add_one, succ_to_nat, to_of_nat]\n\n@[simp, norm_cast]\ntheorem of_nat_cast {α} [add_monoid_with_one α] (n : ℕ) : ((n : num) : α) = n :=\nby rw [← cast_to_nat, to_of_nat]\n\n@[simp, norm_cast] theorem of_nat_inj {m n : ℕ} : (m : num) = n ↔ m = n :=\n⟨λ h, function.left_inverse.injective to_of_nat h, congr_arg _⟩\n\n@[simp, norm_cast] theorem of_to_nat : Π (n : num), ((n : ℕ) : num) = n := of_to_nat'\n\n@[norm_cast]\ntheorem dvd_to_nat (m n : num) : (m : ℕ) ∣ n ↔ m ∣ n :=\n⟨λ ⟨k, e⟩, ⟨k, by rw [← of_to_nat n, e]; simp⟩,\n λ ⟨k, e⟩, ⟨k, by simp [e, mul_to_nat]⟩⟩\n\nend num\n\nnamespace pos_num\nvariables {α : Type*}\nopen num\n\n@[simp, norm_cast] theorem of_to_nat : Π (n : pos_num), ((n : ℕ) : num) = num.pos n := of_to_nat'\n\n@[norm_cast] theorem to_nat_inj {m n : pos_num} : (m : ℕ) = n ↔ m = n :=\n⟨λ h, num.pos.inj $ by rw [← pos_num.of_to_nat, ← pos_num.of_to_nat, h],\n congr_arg _⟩\n\ntheorem pred'_to_nat : ∀ n, (pred' n : ℕ) = nat.pred n\n| 1        := rfl\n| (bit0 n) :=\n  have nat.succ ↑(pred' n) = ↑n,\n  by rw [pred'_to_nat n, nat.succ_pred_eq_of_pos (to_nat_pos n)],\n  match pred' n, this : ∀ k : num, nat.succ ↑k = ↑n →\n    ↑(num.cases_on k 1 bit1 : pos_num) = nat.pred (_root_.bit0 n) with\n  | 0, (h : ((1:num):ℕ) = n) := by rw ← to_nat_inj.1 h; refl\n  | num.pos p, (h : nat.succ ↑p = n) :=\n    by rw ← h; exact (nat.succ_add p p).symm\n  end\n| (bit1 n) := rfl\n\n@[simp] theorem pred'_succ' (n) : pred' (succ' n) = n :=\nnum.to_nat_inj.1 $ by rw [pred'_to_nat, succ'_to_nat,\n  nat.add_one, nat.pred_succ]\n\n@[simp] theorem succ'_pred' (n) : succ' (pred' n) = n :=\nto_nat_inj.1 $ by rw [succ'_to_nat, pred'_to_nat,\n  nat.add_one, nat.succ_pred_eq_of_pos (to_nat_pos _)]\n\ninstance : has_dvd pos_num := ⟨λ m n, pos m ∣ pos n⟩\n\n@[norm_cast] theorem dvd_to_nat {m n : pos_num} : (m:ℕ) ∣ n ↔ m ∣ n :=\nnum.dvd_to_nat (pos m) (pos n)\n\ntheorem size_to_nat : ∀ n, (size n : ℕ) = nat.size n\n| 1        := nat.size_one.symm\n| (bit0 n) := by rw [size, succ_to_nat, size_to_nat, cast_bit0,\n                     nat.size_bit0 $ ne_of_gt $ to_nat_pos n]\n| (bit1 n) := by rw [size, succ_to_nat, size_to_nat, cast_bit1,\n                     nat.size_bit1]\n\ntheorem size_eq_nat_size : ∀ n, (size n : ℕ) = nat_size n\n| 1        := rfl\n| (bit0 n) := by rw [size, succ_to_nat, nat_size, size_eq_nat_size]\n| (bit1 n) := by rw [size, succ_to_nat, nat_size, size_eq_nat_size]\n\ntheorem nat_size_to_nat (n) : nat_size n = nat.size n :=\nby rw [← size_eq_nat_size, size_to_nat]\n\ntheorem nat_size_pos (n) : 0 < nat_size n :=\nby cases n; apply nat.succ_pos\n\n/--\nThis tactic tries to turn an (in)equality about `pos_num`s to one about `nat`s by rewriting.\n```lean\nexample (n : pos_num) (m : pos_num) : n ≤ n + m :=\nbegin\n  pos_num.transfer_rw,\n  exact nat.le_add_right _ _\nend\n```\n-/\nmeta def transfer_rw : tactic unit :=\n`[repeat {rw ← to_nat_inj <|> rw ← lt_to_nat <|> rw ← le_to_nat},\n  repeat {rw add_to_nat <|> rw mul_to_nat <|> rw cast_one <|> rw cast_zero}]\n\n/--\nThis tactic tries to prove (in)equalities about `pos_num`s by transferring them to the `nat` world\nand then trying to call `simp`.\n```lean\nexample (n : pos_num) (m : pos_num) : n ≤ n + m := by pos_num.transfer\n```\n-/\nmeta def transfer : tactic unit :=\n`[intros, transfer_rw, try {simp [add_comm, add_left_comm, mul_comm, mul_left_comm]}]\n\ninstance : add_comm_semigroup pos_num :=\nby refine {add := (+), ..}; transfer\n\ninstance : comm_monoid pos_num :=\nby refine_struct {mul := (*), one := (1 : pos_num), npow := @npow_rec pos_num ⟨1⟩ ⟨(*)⟩};\ntry { intros, refl }; transfer\n\ninstance : distrib pos_num :=\nby refine {add := (+), mul := (*), ..}; {transfer, simp [mul_add, mul_comm]}\n\ninstance : linear_order pos_num :=\n{ lt              := (<),\n  lt_iff_le_not_le := by {intros a b, transfer_rw, apply lt_iff_le_not_le},\n  le              := (≤),\n  le_refl         := by transfer,\n  le_trans        := by {intros a b c, transfer_rw, apply le_trans},\n  le_antisymm     := by {intros a b, transfer_rw, apply le_antisymm},\n  le_total        := by {intros a b, transfer_rw, apply le_total},\n  decidable_lt    := by apply_instance,\n  decidable_le    := by apply_instance,\n  decidable_eq    := by apply_instance }\n\n@[simp] theorem cast_to_num (n : pos_num) : ↑n = num.pos n :=\nby rw [← cast_to_nat, ← of_to_nat n]\n\n@[simp, norm_cast]\ntheorem bit_to_nat (b n) : (bit b n : ℕ) = nat.bit b n :=\nby cases b; refl\n\n@[simp, norm_cast]\ntheorem cast_add [add_monoid_with_one α] (m n) : ((m + n : pos_num) : α) = m + n :=\nby rw [← cast_to_nat, add_to_nat, nat.cast_add, cast_to_nat, cast_to_nat]\n\n@[simp, norm_cast, priority 500]\ntheorem cast_succ [add_monoid_with_one α] (n : pos_num) : (succ n : α) = n + 1 :=\nby rw [← add_one, cast_add, cast_one]\n\n@[simp, norm_cast]\ntheorem cast_inj [add_monoid_with_one α] [char_zero α] {m n : pos_num} : (m:α) = n ↔ m = n :=\nby rw [← cast_to_nat m, ← cast_to_nat n, nat.cast_inj, to_nat_inj]\n\n@[simp]\ntheorem one_le_cast [linear_ordered_semiring α] (n : pos_num) : (1 : α) ≤ n :=\nby rw [← cast_to_nat, ← nat.cast_one, nat.cast_le]; apply to_nat_pos\n\n@[simp]\ntheorem cast_pos [linear_ordered_semiring α] (n : pos_num) : 0 < (n : α) :=\nlt_of_lt_of_le zero_lt_one (one_le_cast n)\n\n@[simp, norm_cast]\ntheorem cast_mul [semiring α] (m n) : ((m * n : pos_num) : α) = m * n :=\nby rw [← cast_to_nat, mul_to_nat, nat.cast_mul, cast_to_nat, cast_to_nat]\n\n@[simp]\ntheorem cmp_eq (m n) : cmp m n = ordering.eq ↔ m = n :=\nbegin\n  have := cmp_to_nat m n,\n  cases cmp m n; simp at this ⊢; try {exact this};\n  { simp [show m ≠ n, from λ e, by rw e at this; exact lt_irrefl _ this] }\nend\n\n@[simp, norm_cast]\ntheorem cast_lt [linear_ordered_semiring α] {m n : pos_num} : (m:α) < n ↔ m < n :=\nby rw [← cast_to_nat m, ← cast_to_nat n, nat.cast_lt, lt_to_nat]\n\n@[simp, norm_cast]\ntheorem cast_le [linear_ordered_semiring α] {m n : pos_num} : (m:α) ≤ n ↔ m ≤ n :=\nby rw ← not_lt; exact not_congr cast_lt\n\nend pos_num\n\nnamespace num\nvariables {α : Type*}\nopen pos_num\n\ntheorem bit_to_nat (b n) : (bit b n : ℕ) = nat.bit b n :=\nby cases b; cases n; refl\n\ntheorem cast_succ' [add_monoid_with_one α] (n) : (succ' n : α) = n + 1 :=\nby rw [← pos_num.cast_to_nat, succ'_to_nat, nat.cast_add_one, cast_to_nat]\n\ntheorem cast_succ [add_monoid_with_one α] (n) : (succ n : α) = n + 1 := cast_succ' n\n\n@[simp, norm_cast] theorem cast_add [semiring α] (m n) : ((m + n : num) : α) = m + n :=\nby rw [← cast_to_nat, add_to_nat, nat.cast_add, cast_to_nat, cast_to_nat]\n\n@[simp, norm_cast] theorem cast_bit0 [semiring α] (n : num) : (n.bit0 : α) = _root_.bit0 n :=\nby rw [← bit0_of_bit0, _root_.bit0, cast_add]; refl\n\n@[simp, norm_cast] theorem cast_bit1 [semiring α] (n : num) : (n.bit1 : α) = _root_.bit1 n :=\nby rw [← bit1_of_bit1, _root_.bit1, bit0_of_bit0, cast_add, cast_bit0]; refl\n\n@[simp, norm_cast] theorem cast_mul [semiring α] : ∀ m n, ((m * n : num) : α) = m * n\n| 0       0       := (zero_mul _).symm\n| 0       (pos q) := (zero_mul _).symm\n| (pos p) 0       := (mul_zero _).symm\n| (pos p) (pos q) := pos_num.cast_mul _ _\n\ntheorem size_to_nat : ∀ n, (size n : ℕ) = nat.size n\n| 0       := nat.size_zero.symm\n| (pos p) := p.size_to_nat\n\ntheorem size_eq_nat_size : ∀ n, (size n : ℕ) = nat_size n\n| 0       := rfl\n| (pos p) := p.size_eq_nat_size\n\ntheorem nat_size_to_nat (n) : nat_size n = nat.size n :=\nby rw [← size_eq_nat_size, size_to_nat]\n\n@[simp, priority 999] theorem of_nat'_eq : ∀ n, num.of_nat' n = n :=\nnat.binary_rec (by simp) $ λ b n IH, begin\n  rw of_nat' at IH ⊢,\n  rw [nat.binary_rec_eq, IH],\n  { cases b; simp [nat.bit, bit0_of_bit0, bit1_of_bit1] },\n  { refl }\nend\n\ntheorem zneg_to_znum (n : num) : -n.to_znum = n.to_znum_neg := by cases n; refl\ntheorem zneg_to_znum_neg (n : num) : -n.to_znum_neg = n.to_znum := by cases n; refl\n\ntheorem to_znum_inj {m n : num} : m.to_znum = n.to_znum ↔ m = n :=\n⟨λ h, by cases m; cases n; cases h; refl, congr_arg _⟩\n\n@[simp, norm_cast squash] theorem cast_to_znum [has_zero α] [has_one α] [has_add α] [has_neg α] :\n  ∀ n : num, (n.to_znum : α) = n\n| 0           := rfl\n| (num.pos p) := rfl\n\n@[simp] theorem cast_to_znum_neg [add_group α] [has_one α] :\n  ∀ n : num, (n.to_znum_neg : α) = -n\n| 0           := neg_zero.symm\n| (num.pos p) := rfl\n\n@[simp] theorem add_to_znum (m n : num) : num.to_znum (m + n) = m.to_znum + n.to_znum :=\nby cases m; cases n; refl\n\nend num\n\nnamespace pos_num\nopen num\n\ntheorem pred_to_nat {n : pos_num} (h : 1 < n) : (pred n : ℕ) = nat.pred n :=\nbegin\n  unfold pred,\n  have := pred'_to_nat n,\n  cases e : pred' n,\n  { have : (1:ℕ) ≤ nat.pred n :=\n      nat.pred_le_pred ((@cast_lt ℕ _ _ _).2 h),\n    rw [← pred'_to_nat, e] at this,\n    exact absurd this dec_trivial },\n  { rw [← pred'_to_nat, e], refl }\nend\n\ntheorem sub'_one (a : pos_num) : sub' a 1 = (pred' a).to_znum :=\nby cases a; refl\n\ntheorem one_sub' (a : pos_num) : sub' 1 a = (pred' a).to_znum_neg :=\nby cases a; refl\n\ntheorem lt_iff_cmp {m n} : m < n ↔ cmp m n = ordering.lt := iff.rfl\n\ntheorem le_iff_cmp {m n} : m ≤ n ↔ cmp m n ≠ ordering.gt :=\nnot_congr $ lt_iff_cmp.trans $\nby rw ← cmp_swap; cases cmp m n; exact dec_trivial\n\nend pos_num\n\nnamespace num\nvariables {α : Type*}\nopen pos_num\n\ntheorem pred_to_nat : ∀ (n : num), (pred n : ℕ) = nat.pred n\n| 0       := rfl\n| (pos p) := by rw [pred, pos_num.pred'_to_nat]; refl\n\ntheorem ppred_to_nat : ∀ (n : num), coe <$> ppred n = nat.ppred n\n| 0       := rfl\n| (pos p) := by rw [ppred, option.map_some, nat.ppred_eq_some.2];\n  rw [pos_num.pred'_to_nat, nat.succ_pred_eq_of_pos (pos_num.to_nat_pos _)]; refl\n\ntheorem cmp_swap (m n) : (cmp m n).swap = cmp n m :=\nby cases m; cases n; try {unfold cmp}; try {refl}; apply pos_num.cmp_swap\n\ntheorem cmp_eq (m n) : cmp m n = ordering.eq ↔ m = n :=\nbegin\n  have := cmp_to_nat m n,\n  cases cmp m n; simp at this ⊢; try {exact this};\n  { simp [show m ≠ n, from λ e, by rw e at this; exact lt_irrefl _ this] }\nend\n\n@[simp, norm_cast]\ntheorem cast_lt [linear_ordered_semiring α] {m n : num} : (m:α) < n ↔ m < n :=\nby rw [← cast_to_nat m, ← cast_to_nat n, nat.cast_lt, lt_to_nat]\n\n@[simp, norm_cast]\ntheorem cast_le [linear_ordered_semiring α] {m n : num} : (m:α) ≤ n ↔ m ≤ n :=\nby rw ← not_lt; exact not_congr cast_lt\n\n@[simp, norm_cast]\ntheorem cast_inj [linear_ordered_semiring α] {m n : num} : (m:α) = n ↔ m = n :=\nby rw [← cast_to_nat m, ← cast_to_nat n, nat.cast_inj, to_nat_inj]\n\ntheorem lt_iff_cmp {m n} : m < n ↔ cmp m n = ordering.lt := iff.rfl\n\ntheorem le_iff_cmp {m n} : m ≤ n ↔ cmp m n ≠ ordering.gt :=\nnot_congr $ lt_iff_cmp.trans $\nby rw ← cmp_swap; cases cmp m n; exact dec_trivial\n\ntheorem bitwise_to_nat {f : num → num → num} {g : bool → bool → bool}\n  (p : pos_num → pos_num → num)\n  (gff : g ff ff = ff)\n  (f00 : f 0 0 = 0)\n  (f0n : ∀ n, f 0 (pos n) = cond (g ff tt) (pos n) 0)\n  (fn0 : ∀ n, f (pos n) 0 = cond (g tt ff) (pos n) 0)\n  (fnn : ∀ m n, f (pos m) (pos n) = p m n)\n  (p11 : p 1 1 = cond (g tt tt) 1 0)\n  (p1b : ∀ b n, p 1 (pos_num.bit b n) = bit (g tt b) (cond (g ff tt) (pos n) 0))\n  (pb1 : ∀ a m, p (pos_num.bit a m) 1 = bit (g a tt) (cond (g tt ff) (pos m) 0))\n  (pbb : ∀ a b m n, p (pos_num.bit a m) (pos_num.bit b n) = bit (g a b) (p m n))\n  : ∀ m n : num, (f m n : ℕ) = nat.bitwise g m n :=\nbegin\n  intros, cases m with m; cases n with n;\n  try { change zero with 0 };\n  try { change ((0:num):ℕ) with 0 },\n  { rw [f00, nat.bitwise_zero]; refl },\n  { unfold nat.bitwise, rw [f0n, nat.binary_rec_zero],\n    cases g ff tt; refl },\n  { unfold nat.bitwise,\n    generalize h : (pos m : ℕ) = m', revert h,\n    apply nat.bit_cases_on m' _, intros b m' h,\n    rw [fn0, nat.binary_rec_eq, nat.binary_rec_zero, ←h],\n    cases g tt ff; refl,\n    apply nat.bitwise_bit_aux gff },\n  { rw fnn,\n    have : ∀b (n : pos_num), (cond b ↑n 0 : ℕ) = ↑(cond b (pos n) 0 : num) :=\n      by intros; cases b; refl,\n    induction m with m IH m IH generalizing n; cases n with n n,\n    any_goals { change one with 1 },\n    any_goals { change pos 1 with 1 },\n    any_goals { change pos_num.bit0 with pos_num.bit ff },\n    any_goals { change pos_num.bit1 with pos_num.bit tt },\n    any_goals { change ((1:num):ℕ) with nat.bit tt 0 },\n    all_goals\n    { repeat\n      { rw show ∀ b n, (pos (pos_num.bit b n) : ℕ) = nat.bit b ↑n,\n           by intros; cases b; refl },\n      rw nat.bitwise_bit },\n    any_goals { assumption },\n    any_goals { rw [nat.bitwise_zero, p11], cases g tt tt; refl },\n    any_goals { rw [nat.bitwise_zero_left, this, ← bit_to_nat, p1b] },\n    any_goals { rw [nat.bitwise_zero_right _ gff, this, ← bit_to_nat, pb1] },\n    all_goals { rw [← show ∀ n, ↑(p m n) = nat.bitwise g ↑m ↑n, from IH],\n      rw [← bit_to_nat, pbb] } }\nend\n\n@[simp, norm_cast] theorem lor_to_nat   : ∀ m n, (lor    m n : ℕ) = nat.lor    m n :=\nby apply bitwise_to_nat (λx y, pos (pos_num.lor x y)); intros; try {cases a}; try {cases b}; refl\n@[simp, norm_cast] theorem land_to_nat  : ∀ m n, (land   m n : ℕ) = nat.land   m n :=\nby apply bitwise_to_nat pos_num.land; intros; try {cases a}; try {cases b}; refl\n@[simp, norm_cast] theorem ldiff_to_nat : ∀ m n, (ldiff  m n : ℕ) = nat.ldiff  m n :=\nby apply bitwise_to_nat pos_num.ldiff; intros; try {cases a}; try {cases b}; refl\n@[simp, norm_cast] theorem lxor_to_nat  : ∀ m n, (lxor   m n : ℕ) = nat.lxor   m n :=\nby apply bitwise_to_nat pos_num.lxor; intros; try {cases a}; try {cases b}; refl\n\n@[simp, norm_cast] theorem shiftl_to_nat (m n) : (shiftl m n : ℕ) = nat.shiftl m n :=\nbegin\n  cases m; dunfold shiftl, {symmetry, apply nat.zero_shiftl},\n  simp, induction n with n IH, {refl},\n  simp [pos_num.shiftl, nat.shiftl_succ], rw ←IH\nend\n\n@[simp, norm_cast] theorem shiftr_to_nat (m n) : (shiftr m n : ℕ) = nat.shiftr m n :=\nbegin\n  cases m with m; dunfold shiftr, {symmetry, apply nat.zero_shiftr},\n  induction n with n IH generalizing m, {cases m; refl},\n  cases m with m m; dunfold pos_num.shiftr,\n  { rw [nat.shiftr_eq_div_pow], symmetry, apply nat.div_eq_of_lt,\n    exact @nat.pow_lt_pow_of_lt_right 2 dec_trivial 0 (n+1) (nat.succ_pos _) },\n  { transitivity, apply IH,\n    change nat.shiftr m n = nat.shiftr (bit1 m) (n+1),\n    rw [add_comm n 1, nat.shiftr_add],\n    apply congr_arg (λx, nat.shiftr x n), unfold nat.shiftr,\n    change (bit1 ↑m : ℕ) with nat.bit tt m,\n    rw nat.div2_bit },\n  { transitivity, apply IH,\n    change nat.shiftr m n = nat.shiftr (bit0 m) (n + 1),\n    rw [add_comm n 1, nat.shiftr_add],\n    apply congr_arg (λx, nat.shiftr x n), unfold nat.shiftr,\n    change (bit0 ↑m : ℕ) with nat.bit ff m,\n    rw nat.div2_bit }\nend\n\n@[simp] theorem test_bit_to_nat (m n) : test_bit m n = nat.test_bit m n :=\nbegin\n  cases m with m; unfold test_bit nat.test_bit,\n  { change (zero : nat) with 0, rw nat.zero_shiftr, refl },\n  induction n with n IH generalizing m;\n  cases m; dunfold pos_num.test_bit, {refl},\n  { exact (nat.bodd_bit _ _).symm },\n  { exact (nat.bodd_bit _ _).symm },\n  { change ff = nat.bodd (nat.shiftr 1 (n + 1)),\n    rw [add_comm, nat.shiftr_add], change nat.shiftr 1 1 with 0,\n    rw nat.zero_shiftr; refl },\n  { change pos_num.test_bit m n = nat.bodd (nat.shiftr (nat.bit tt m) (n + 1)),\n    rw [add_comm, nat.shiftr_add], unfold nat.shiftr,\n    rw nat.div2_bit, apply IH },\n  { change pos_num.test_bit m n = nat.bodd (nat.shiftr (nat.bit ff m) (n + 1)),\n    rw [add_comm, nat.shiftr_add], unfold nat.shiftr,\n    rw nat.div2_bit, apply IH },\nend\n\nend num\n\nnamespace znum\nvariables {α : Type*}\nopen pos_num\n\n@[simp, norm_cast] theorem cast_zero [has_zero α] [has_one α] [has_add α] [has_neg α] :\n  ((0 : znum) : α) = 0 := rfl\n\n@[simp] theorem cast_zero' [has_zero α] [has_one α] [has_add α] [has_neg α] :\n  (znum.zero : α) = 0 := rfl\n\n@[simp, norm_cast] theorem cast_one [has_zero α] [has_one α] [has_add α] [has_neg α] :\n  ((1 : znum) : α) = 1 := rfl\n\n@[simp] theorem cast_pos [has_zero α] [has_one α] [has_add α] [has_neg α]\n  (n : pos_num) : (pos n : α) = n := rfl\n\n@[simp] theorem cast_neg [has_zero α] [has_one α] [has_add α] [has_neg α]\n  (n : pos_num) : (neg n : α) = -n := rfl\n\n@[simp, norm_cast] theorem cast_zneg [add_group α] [has_one α] : ∀ n, ((-n : znum) : α) = -n\n| 0       := neg_zero.symm\n| (pos p) := rfl\n| (neg p) := (neg_neg _).symm\n\ntheorem neg_zero : (-0 : znum) = 0 := rfl\ntheorem zneg_pos (n : pos_num) : -pos n = neg n := rfl\ntheorem zneg_neg (n : pos_num) : -neg n = pos n := rfl\ntheorem zneg_zneg (n : znum) : - -n = n := by cases n; refl\ntheorem zneg_bit1 (n : znum) : -n.bit1 = (-n).bitm1 := by cases n; refl\ntheorem zneg_bitm1 (n : znum) : -n.bitm1 = (-n).bit1 := by cases n; refl\n\ntheorem zneg_succ (n : znum) : -n.succ = (-n).pred :=\nby cases n; try {refl}; rw [succ, num.zneg_to_znum_neg]; refl\n\ntheorem zneg_pred (n : znum) : -n.pred = (-n).succ :=\nby rw [← zneg_zneg (succ (-n)), zneg_succ, zneg_zneg]\n\n@[simp] theorem abs_to_nat : ∀ n, (abs n : ℕ) = int.nat_abs n\n| 0       := rfl\n| (pos p) := congr_arg int.nat_abs p.to_nat_to_int\n| (neg p) := show int.nat_abs ((p:ℕ):ℤ) = int.nat_abs (- p),\n  by rw [p.to_nat_to_int, int.nat_abs_neg]\n\n@[simp] theorem abs_to_znum : ∀ n : num, abs n.to_znum = n\n| 0           := rfl\n| (num.pos p) := rfl\n\n@[simp, norm_cast] theorem cast_to_int [add_group_with_one α] : ∀ n : znum, ((n : ℤ) : α) = n\n| 0       := by rw [cast_zero, cast_zero, int.cast_zero]\n| (pos p) := by rw [cast_pos, cast_pos, pos_num.cast_to_int]\n| (neg p) := by rw [cast_neg, cast_neg, int.cast_neg, pos_num.cast_to_int]\n\ntheorem bit0_of_bit0 : ∀ n : znum, _root_.bit0 n = n.bit0\n| 0       := rfl\n| (pos a) := congr_arg pos a.bit0_of_bit0\n| (neg a) := congr_arg neg a.bit0_of_bit0\n\ntheorem bit1_of_bit1 : ∀ n : znum, _root_.bit1 n = n.bit1\n| 0       := rfl\n| (pos a) := congr_arg pos a.bit1_of_bit1\n| (neg a) := show pos_num.sub' 1 (_root_.bit0 a) = _,\n  by rw [pos_num.one_sub', a.bit0_of_bit0]; refl\n\n@[simp, norm_cast] theorem cast_bit0 [add_group_with_one α] :\n  ∀ n : znum, (n.bit0 : α) = bit0 n\n| 0       := (add_zero _).symm\n| (pos p) := by rw [znum.bit0, cast_pos, cast_pos]; refl\n| (neg p) := by rw [znum.bit0, cast_neg, cast_neg, pos_num.cast_bit0,\n                    _root_.bit0, _root_.bit0, neg_add_rev]\n\n@[simp, norm_cast] theorem cast_bit1 [add_group_with_one α] :\n  ∀ n : znum, (n.bit1 : α) = bit1 n\n| 0       := by simp [znum.bit1, _root_.bit1, _root_.bit0]\n| (pos p) := by rw [znum.bit1, cast_pos, cast_pos]; refl\n| (neg p) := begin\n    rw [znum.bit1, cast_neg, cast_neg],\n    cases e : pred' p with a;\n    have : p = _ := (succ'_pred' p).symm.trans\n      (congr_arg num.succ' e),\n    { change p=1 at this, subst p,\n      simp [_root_.bit1, _root_.bit0] },\n    { rw [num.succ'] at this, subst p,\n      have : (↑(-↑a:ℤ) : α) = -1 + ↑(-↑a + 1 : ℤ), {simp [add_comm]},\n      simpa [_root_.bit1, _root_.bit0, -add_comm] },\n  end\n\n@[simp] theorem cast_bitm1 [add_group_with_one α]\n  (n : znum) : (n.bitm1 : α) = bit0 n - 1 :=\nbegin\n  conv { to_lhs, rw ← zneg_zneg n },\n  rw [← zneg_bit1, cast_zneg, cast_bit1],\n  have : ((-1 + n + n : ℤ) : α) = (n + n + -1 : ℤ), {simp [add_comm, add_left_comm]},\n  simpa [_root_.bit1, _root_.bit0, sub_eq_add_neg, -int.add_neg_one]\nend\n\ntheorem add_zero (n : znum) : n + 0 = n := by cases n; refl\ntheorem zero_add (n : znum) : 0 + n = n := by cases n; refl\n\ntheorem add_one : ∀ n : znum, n + 1 = succ n\n| 0       := rfl\n| (pos p) := congr_arg pos p.add_one\n| (neg p) := by cases p; refl\n\nend znum\n\nnamespace pos_num\nvariables {α : Type*}\n\ntheorem cast_to_znum : ∀ n : pos_num, (n : znum) = znum.pos n\n| 1        := rfl\n| (bit0 p) := (znum.bit0_of_bit0 p).trans $ congr_arg _ (cast_to_znum p)\n| (bit1 p) := (znum.bit1_of_bit1 p).trans $ congr_arg _ (cast_to_znum p)\n\nlocal attribute [-simp] int.add_neg_one\n\ntheorem cast_sub' [add_group_with_one α] : ∀ m n : pos_num, (sub' m n : α) = m - n\n| a        1        := by rw [sub'_one, num.cast_to_znum,\n                              ← num.cast_to_nat, pred'_to_nat, ← nat.sub_one];\n                          simp [pos_num.cast_pos]\n| 1        b        := by rw [one_sub', num.cast_to_znum_neg, ← neg_sub, neg_inj,\n                              ← num.cast_to_nat, pred'_to_nat, ← nat.sub_one];\n                          simp [pos_num.cast_pos]\n| (bit0 a) (bit0 b) := begin\n    rw [sub', znum.cast_bit0, cast_sub'],\n    have : ((a + -b + (a + -b) : ℤ) : α) = a + a + (-b + -b), {simp [add_left_comm]},\n    simpa [_root_.bit0, sub_eq_add_neg]\n  end\n| (bit0 a) (bit1 b) := begin\n    rw [sub', znum.cast_bitm1, cast_sub'],\n    have : ((-b + (a + (-b + -1)) : ℤ) : α) = (a + -1 + (-b + -b):ℤ),\n    { simp [add_comm, add_left_comm] },\n    simpa [_root_.bit1, _root_.bit0, sub_eq_add_neg]\n  end\n| (bit1 a) (bit0 b) := begin\n    rw [sub', znum.cast_bit1, cast_sub'],\n    have : ((-b + (a + (-b + 1)) : ℤ) : α) = (a + 1 + (-b + -b):ℤ),\n    { simp [add_comm, add_left_comm] },\n    simpa [_root_.bit1, _root_.bit0, sub_eq_add_neg]\n  end\n| (bit1 a) (bit1 b) := begin\n    rw [sub', znum.cast_bit0, cast_sub'],\n    have : ((-b + (a + -b) : ℤ) : α) = a + (-b + -b), {simp [add_left_comm]},\n    simpa [_root_.bit1, _root_.bit0, sub_eq_add_neg]\n  end\n\ntheorem to_nat_eq_succ_pred (n : pos_num) : (n:ℕ) = n.pred' + 1 :=\nby rw [← num.succ'_to_nat, n.succ'_pred']\n\ntheorem to_int_eq_succ_pred (n : pos_num) : (n:ℤ) = (n.pred' : ℕ) + 1 :=\nby rw [← n.to_nat_to_int, to_nat_eq_succ_pred]; refl\n\nend pos_num\n\nnamespace num\nvariables {α : Type*}\n\n@[simp] theorem cast_sub' [add_group_with_one α] : ∀ m n : num, (sub' m n : α) = m - n\n| 0       0       := (sub_zero _).symm\n| (pos a) 0       := (sub_zero _).symm\n| 0       (pos b) := (zero_sub _).symm\n| (pos a) (pos b) := pos_num.cast_sub' _ _\n\ntheorem to_znum_succ : ∀ n : num, n.succ.to_znum = n.to_znum.succ\n| 0 := rfl\n| (pos n) := rfl\n\ntheorem to_znum_neg_succ : ∀ n : num, n.succ.to_znum_neg = n.to_znum_neg.pred\n| 0 := rfl\n| (pos n) := rfl\n\n@[simp] theorem pred_succ : ∀ n : znum, n.pred.succ = n\n| 0 := rfl\n| (znum.neg p) := show to_znum_neg (pos p).succ'.pred' = _, by rw [pos_num.pred'_succ']; refl\n| (znum.pos p) := by rw [znum.pred, ← to_znum_succ, num.succ, pos_num.succ'_pred', to_znum]\n\ntheorem succ_of_int' : ∀ n, znum.of_int' (n + 1) = znum.of_int' n + 1\n| (n : ℕ) := by erw [znum.of_int', znum.of_int', num.of_nat'_succ,\n  num.add_one, to_znum_succ, znum.add_one]\n| -[1+ 0] := by erw [znum.of_int', znum.of_int', of_nat'_succ, of_nat'_zero]; refl\n| -[1+ n+1] := by erw [znum.of_int', znum.of_int', @num.of_nat'_succ (n+1), num.add_one,\n  to_znum_neg_succ, @of_nat'_succ n, num.add_one, znum.add_one, pred_succ]\n\ntheorem of_int'_to_znum : ∀ n : ℕ, to_znum n = znum.of_int' n\n| 0 := rfl\n| (n+1) := by rw [nat.cast_succ, num.add_one, to_znum_succ, of_int'_to_znum, nat.cast_succ,\n  succ_of_int', znum.add_one]\n\ntheorem mem_of_znum' : ∀ {m : num} {n : znum}, m ∈ of_znum' n ↔ n = to_znum m\n| 0       0      := ⟨λ _, rfl, λ _, rfl⟩\n| (pos m) 0      := ⟨λ h, by cases h, λ h, by cases h⟩\n| m (znum.pos p) := option.some_inj.trans $\n  by cases m; split; intro h; try {cases h}; refl\n| m (znum.neg p) := ⟨λ h, by cases h, λ h, by cases m; cases h⟩\n\ntheorem of_znum'_to_nat : ∀ (n : znum), coe <$> of_znum' n = int.to_nat' n\n| 0            := rfl\n| (znum.pos p) := show _ = int.to_nat' p, by rw [← pos_num.to_nat_to_int p]; refl\n| (znum.neg p) := congr_arg (λ x, int.to_nat' (-x)) $\n  show ((p.pred' + 1 : ℕ) : ℤ) = p, by rw ← succ'_to_nat; simp\n\n@[simp] theorem of_znum_to_nat : ∀ (n : znum), (of_znum n : ℕ) = int.to_nat n\n| 0            := rfl\n| (znum.pos p) := show _ = int.to_nat p, by rw [← pos_num.to_nat_to_int p]; refl\n| (znum.neg p) := congr_arg (λ x, int.to_nat (-x)) $\n  show ((p.pred' + 1 : ℕ) : ℤ) = p, by rw ← succ'_to_nat; simp\n\n@[simp] theorem cast_of_znum [add_group_with_one α] (n : znum) :\n  (of_znum n : α) = int.to_nat n :=\nby rw [← cast_to_nat, of_znum_to_nat]\n\n@[simp, norm_cast] theorem sub_to_nat (m n) : ((m - n : num) : ℕ) = m - n :=\nshow (of_znum _ : ℕ) = _, by rw [of_znum_to_nat, cast_sub',\n  ← to_nat_to_int, ← to_nat_to_int, int.to_nat_sub]\n\nend num\n\nnamespace znum\nvariables {α : Type*}\n\n@[simp, norm_cast] theorem cast_add [add_group_with_one α] : ∀ m n, ((m + n : znum) : α) = m + n\n| 0       a       := by cases a; exact (_root_.zero_add _).symm\n| b       0       := by cases b; exact (_root_.add_zero _).symm\n| (pos a) (pos b) := pos_num.cast_add _ _\n| (pos a) (neg b) := by simpa only [sub_eq_add_neg] using pos_num.cast_sub' _ _\n| (neg a) (pos b) :=\nhave (↑b + -↑a : α) = -↑a + ↑b, by rw [← pos_num.cast_to_int a, ← pos_num.cast_to_int b,\n  ← int.cast_neg, ← int.cast_add (-a)]; simp [add_comm],\n(pos_num.cast_sub' _ _).trans $ (sub_eq_add_neg _ _).trans this\n| (neg a) (neg b) := show -(↑(a + b) : α) = -a + -b, by  rw [\n  pos_num.cast_add, neg_eq_iff_eq_neg, neg_add_rev, neg_neg, neg_neg,\n  ← pos_num.cast_to_int a, ← pos_num.cast_to_int b, ← int.cast_add, ← int.cast_add, add_comm]\n\n@[simp] theorem cast_succ [add_group_with_one α] (n) : ((succ n : znum) : α) = n + 1 :=\nby rw [← add_one, cast_add, cast_one]\n\n@[simp, norm_cast] theorem mul_to_int : ∀ m n, ((m * n : znum) : ℤ) = m * n\n| 0       a       := by cases a; exact (_root_.zero_mul _).symm\n| b       0       := by cases b; exact (_root_.mul_zero _).symm\n| (pos a) (pos b) := pos_num.cast_mul a b\n| (pos a) (neg b) := show -↑(a * b) = ↑a * -↑b, by rw [pos_num.cast_mul, neg_mul_eq_mul_neg]\n| (neg a) (pos b) := show -↑(a * b) = -↑a * ↑b, by rw [pos_num.cast_mul, neg_mul_eq_neg_mul]\n| (neg a) (neg b) := show ↑(a * b) = -↑a * -↑b, by rw [pos_num.cast_mul, neg_mul_neg]\n\ntheorem cast_mul [ring α] (m n) : ((m * n : znum) : α) = m * n :=\nby rw [← cast_to_int, mul_to_int, int.cast_mul, cast_to_int, cast_to_int]\n\ntheorem of_int'_neg : ∀ n : ℤ, of_int' (-n) = -of_int' n\n| -[1+ n] := show of_int' (n + 1 : ℕ) = _, by simp only [of_int', num.zneg_to_znum_neg]\n| 0 := show num.to_znum _ = -num.to_znum _, by rw [num.of_nat'_zero]; refl\n| (n+1 : ℕ) := show num.to_znum_neg _ = -num.to_znum _, by rw [num.zneg_to_znum]; refl\n\ntheorem of_to_int' : ∀ (n : znum), znum.of_int' n = n\n| 0       := by erw [of_int', num.of_nat'_zero, num.to_znum]\n| (pos a) := by rw [cast_pos, ← pos_num.cast_to_nat, ← num.of_int'_to_znum, pos_num.of_to_nat]; refl\n| (neg a) := by rw [cast_neg, of_int'_neg, ← pos_num.cast_to_nat, ← num.of_int'_to_znum,\n  pos_num.of_to_nat]; refl\n\ntheorem to_int_inj {m n : znum} : (m : ℤ) = n ↔ m = n :=\n⟨λ h, function.left_inverse.injective of_to_int' h, congr_arg _⟩\n\ntheorem cmp_to_int : ∀ (m n), (ordering.cases_on (cmp m n) ((m:ℤ) < n) (m = n) ((n:ℤ) < m) : Prop)\n| 0       0       := rfl\n| (pos a) (pos b) := begin\n    have := pos_num.cmp_to_nat a b; revert this; dsimp [cmp];\n    cases pos_num.cmp a b; dsimp;\n    [simp, exact congr_arg pos, simp [gt]]\n  end\n| (neg a) (neg b) := begin\n    have := pos_num.cmp_to_nat b a; revert this; dsimp [cmp];\n    cases pos_num.cmp b a; dsimp;\n    [simp, simp {contextual := tt}, simp [gt]]\n  end\n| (pos a) 0       := pos_num.cast_pos _\n| (pos a) (neg b) := lt_trans (neg_lt_zero.2 $ pos_num.cast_pos _) (pos_num.cast_pos _)\n| 0       (neg b) := neg_lt_zero.2 $ pos_num.cast_pos _\n| (neg a) 0       := neg_lt_zero.2 $ pos_num.cast_pos _\n| (neg a) (pos b) := lt_trans (neg_lt_zero.2 $ pos_num.cast_pos _) (pos_num.cast_pos _)\n| 0       (pos b) := pos_num.cast_pos _\n\n@[norm_cast]\ntheorem lt_to_int {m n : znum} : (m:ℤ) < n ↔ m < n :=\nshow (m:ℤ) < n ↔ cmp m n = ordering.lt, from\nmatch cmp m n, cmp_to_int m n with\n| ordering.lt, h := by simp at h; simp [h]\n| ordering.eq, h := by simp at h; simp [h, lt_irrefl]; exact dec_trivial\n| ordering.gt, h := by simp [not_lt_of_gt h]; exact dec_trivial\nend\n\ntheorem le_to_int {m n : znum} : (m:ℤ) ≤ n ↔ m ≤ n :=\nby rw ← not_lt; exact not_congr lt_to_int\n\n@[simp, norm_cast]\ntheorem cast_lt [linear_ordered_ring α] {m n : znum} : (m:α) < n ↔ m < n :=\nby rw [← cast_to_int m, ← cast_to_int n, int.cast_lt, lt_to_int]\n\n@[simp, norm_cast]\ntheorem cast_le [linear_ordered_ring α] {m n : znum} : (m:α) ≤ n ↔ m ≤ n :=\nby rw ← not_lt; exact not_congr cast_lt\n\n@[simp, norm_cast]\ntheorem cast_inj [linear_ordered_ring α] {m n : znum} : (m:α) = n ↔ m = n :=\nby rw [← cast_to_int m, ← cast_to_int n, int.cast_inj, to_int_inj]\n\n/--\nThis tactic tries to turn an (in)equality about `znum`s to one about `int`s by rewriting.\n```lean\nexample (n : znum) (m : znum) : n ≤ n + m * m :=\nbegin\n  znum.transfer_rw,\n  exact le_add_of_nonneg_right (mul_self_nonneg _)\nend\n```\n-/\nmeta def transfer_rw : tactic unit :=\n`[repeat {rw ← to_int_inj <|> rw ← lt_to_int <|> rw ← le_to_int},\n  repeat {rw cast_add <|> rw mul_to_int <|> rw cast_one <|> rw cast_zero}]\n\n/--\nThis tactic tries to prove (in)equalities about `znum`s by transfering them to the `int` world and\nthen trying to call `simp`.\n```lean\nexample (n : znum) (m : znum) : n ≤ n + m * m :=\nbegin\n  znum.transfer,\n  exact mul_self_nonneg _\nend\n```\n-/\nmeta def transfer : tactic unit :=\n`[intros, transfer_rw, try {simp [add_comm, add_left_comm, mul_comm, mul_left_comm]}]\n\ninstance : linear_order znum :=\n{ lt               := (<),\n  lt_iff_le_not_le := by {intros a b, transfer_rw, apply lt_iff_le_not_le},\n  le               := (≤),\n  le_refl          := by transfer,\n  le_trans         := by {intros a b c, transfer_rw, apply le_trans},\n  le_antisymm      := by {intros a b, transfer_rw, apply le_antisymm},\n  le_total         := by {intros a b, transfer_rw, apply le_total},\n  decidable_eq     := znum.decidable_eq,\n  decidable_le     := znum.decidable_le,\n  decidable_lt     := znum.decidable_lt }\n\ninstance : add_comm_group znum :=\n{ add              := (+),\n  add_assoc        := by transfer,\n  zero             := 0,\n  zero_add         := zero_add,\n  add_zero         := add_zero,\n  add_comm         := by transfer,\n  neg              := has_neg.neg,\n  add_left_neg     := by transfer }\n\ninstance : add_monoid_with_one znum :=\n{ one := 1,\n  nat_cast := λ n, znum.of_int' n,\n  nat_cast_zero := show (num.of_nat' 0).to_znum = 0, by rw num.of_nat'_zero; refl,\n  nat_cast_succ := λ n, show (num.of_nat' (n+1)).to_znum = (num.of_nat' n).to_znum + 1,\n    by rw [num.of_nat'_succ, num.add_one, num.to_znum_succ, znum.add_one],\n  .. znum.add_comm_group }\n\ninstance : linear_ordered_comm_ring znum :=\n{ mul              := (*),\n  mul_assoc        := by transfer,\n  one              := 1,\n  one_mul          := by transfer,\n  mul_one          := by transfer,\n  left_distrib     := by {transfer, simp [mul_add]},\n  right_distrib    := by {transfer, simp [mul_add, mul_comm]},\n  mul_comm         := by transfer,\n  exists_pair_ne   := ⟨0, 1, dec_trivial⟩,\n  add_le_add_left  := by {intros a b h c, revert h, transfer_rw, exact λ h, add_le_add_left h c},\n  mul_pos          := λ a b, show 0 < a → 0 < b → 0 < a * b, by {transfer_rw, apply mul_pos},\n  zero_le_one      := dec_trivial,\n  ..znum.linear_order, ..znum.add_comm_group, ..znum.add_monoid_with_one }\n\n@[simp, norm_cast] theorem cast_sub [ring α] (m n) : ((m - n : znum) : α) = m - n :=\nby simp [sub_eq_neg_add]\n\n@[simp, norm_cast] \n\n@[simp] theorem of_int'_eq : ∀ n : ℤ, znum.of_int' n = n\n| (n : ℕ) := rfl\n| -[1+ n] := begin\n  show num.to_znum_neg (n+1 : ℕ) = -(n+1 : ℕ),\n  rw [← neg_inj, neg_neg, nat.cast_succ, num.add_one, num.zneg_to_znum_neg, num.to_znum_succ,\n    nat.cast_succ, znum.add_one],\n  refl\nend\n\n@[simp] theorem of_nat_to_znum (n : ℕ) : num.to_znum n = n := rfl\n\n@[simp, norm_cast] theorem of_to_int (n : znum) : ((n : ℤ) : znum) = n :=\nby rw [← of_int'_eq, of_to_int']\n\ntheorem to_of_int (n : ℤ) : ((n : znum) : ℤ) = n :=\nint.induction_on' n 0 (by simp) (by simp) (by simp)\n\n@[simp] theorem of_nat_to_znum_neg (n : ℕ) : num.to_znum_neg n = -n :=\nby rw [← of_nat_to_znum, num.zneg_to_znum]\n\n@[simp, norm_cast] theorem of_int_cast [add_group_with_one α] (n : ℤ) : ((n : znum) : α) = n :=\nby rw [← cast_to_int, to_of_int]\n\n@[simp, norm_cast] theorem of_nat_cast [add_group_with_one α] (n : ℕ) : ((n : znum) : α) = n :=\nby rw [← int.cast_coe_nat, of_int_cast, int.cast_coe_nat]\n\n@[simp, norm_cast] theorem dvd_to_int (m n : znum) : (m : ℤ) ∣ n ↔ m ∣ n :=\n⟨λ ⟨k, e⟩, ⟨k, by rw [← of_to_int n, e]; simp⟩,\n λ ⟨k, e⟩, ⟨k, by simp [e]⟩⟩\n\nend znum\n\nnamespace pos_num\n\ntheorem divmod_to_nat_aux {n d : pos_num} {q r : num}\n  (h₁ : (r:ℕ) + d * _root_.bit0 q = n)\n  (h₂ : (r:ℕ) < 2 * d) :\n  ((divmod_aux d q r).2 + d * (divmod_aux d q r).1 : ℕ) = ↑n ∧\n  ((divmod_aux d q r).2 : ℕ) < d :=\nbegin\n  unfold divmod_aux,\n  have : ∀ {r₂}, num.of_znum' (num.sub' r (num.pos d)) = some r₂ ↔ (r : ℕ) = r₂ + d,\n  { intro r₂,\n    apply num.mem_of_znum'.trans,\n    rw [← znum.to_int_inj, num.cast_to_znum,\n      num.cast_sub', sub_eq_iff_eq_add, ← int.coe_nat_inj'],\n    simp },\n  cases e : num.of_znum' (num.sub' r (num.pos d)) with r₂;\n    simp [divmod_aux],\n  { refine ⟨h₁, lt_of_not_ge (λ h, _)⟩,\n    cases nat.le.dest h with r₂ e',\n    rw [← num.to_of_nat r₂, add_comm] at e',\n    cases e.symm.trans (this.2 e'.symm) },\n  { have := this.1 e,\n    split,\n    { rwa [_root_.bit1, add_comm _ 1, mul_add, mul_one,\n        ← add_assoc, ← this] },\n    { rwa [this, two_mul, add_lt_add_iff_right] at h₂ } }\nend\n\ntheorem divmod_to_nat (d n : pos_num) :\n  (n / d : ℕ) = (divmod d n).1 ∧\n  (n % d : ℕ) = (divmod d n).2 :=\nbegin\n  rw nat.div_mod_unique (pos_num.cast_pos _),\n  induction n with n IH n IH,\n  { exact divmod_to_nat_aux (by simp; refl)\n      (nat.mul_le_mul_left 2\n        (pos_num.cast_pos d : (0 : ℕ) < d)) },\n  { unfold divmod,\n    cases divmod d n with q r, simp only [divmod] at IH ⊢,\n    apply divmod_to_nat_aux; simp,\n    { rw [_root_.bit1, _root_.bit1, add_right_comm,\n        bit0_eq_two_mul (n : ℕ), ← IH.1,\n        mul_add, ← bit0_eq_two_mul,\n        mul_left_comm, ← bit0_eq_two_mul] },\n    { rw ← bit0_eq_two_mul,\n      exact nat.bit1_lt_bit0 IH.2 } },\n  { unfold divmod,\n    cases divmod d n with q r, simp only [divmod] at IH ⊢,\n    apply divmod_to_nat_aux; simp,\n    { rw [bit0_eq_two_mul (n : ℕ), ← IH.1,\n        mul_add, ← bit0_eq_two_mul,\n        mul_left_comm, ← bit0_eq_two_mul] },\n    { rw ← bit0_eq_two_mul,\n      exact nat.bit0_lt IH.2 } }\nend\n\n@[simp] theorem div'_to_nat (n d) : (div' n d : ℕ) = n / d :=\n(divmod_to_nat _ _).1.symm\n\n@[simp] theorem mod'_to_nat (n d) : (mod' n d : ℕ) = n % d :=\n(divmod_to_nat _ _).2.symm\n\nend pos_num\n\nnamespace num\n\n@[simp] protected lemma div_zero (n : num) : n / 0 = 0 :=\nshow n.div 0 = 0, by { cases n, refl, simp [num.div] }\n\n@[simp, norm_cast] theorem div_to_nat : ∀ n d, ((n / d : num) : ℕ) = n / d\n| 0       0       := by simp\n| 0       (pos d) := (nat.zero_div _).symm\n| (pos n) 0       := (nat.div_zero _).symm\n| (pos n) (pos d) := pos_num.div'_to_nat _ _\n\n@[simp] protected lemma mod_zero (n : num) : n % 0 = n :=\nshow n.mod 0 = n, by { cases n, refl, simp [num.mod] }\n\n@[simp, norm_cast] theorem mod_to_nat : ∀ n d, ((n % d : num) : ℕ) = n % d\n| 0       0       := by simp\n| 0       (pos d) := (nat.zero_mod _).symm\n| (pos n) 0       := (nat.mod_zero _).symm\n| (pos n) (pos d) := pos_num.mod'_to_nat _ _\n\ntheorem gcd_to_nat_aux : ∀ {n} {a b : num},\n  a ≤ b → (a * b).nat_size ≤ n → (gcd_aux n a b : ℕ) = nat.gcd a b\n| 0            0       b       ab h := (nat.gcd_zero_left _).symm\n| 0            (pos a) 0       ab h := (not_lt_of_ge ab).elim rfl\n| 0            (pos a) (pos b) ab h :=\n  (not_lt_of_le h).elim $ pos_num.nat_size_pos _\n| (nat.succ n) 0       b       ab h := (nat.gcd_zero_left _).symm\n| (nat.succ n) (pos a) b       ab h := begin\n  simp [gcd_aux],\n  rw [nat.gcd_rec, gcd_to_nat_aux, mod_to_nat], {refl},\n  { rw [← le_to_nat, mod_to_nat],\n    exact le_of_lt (nat.mod_lt _ (pos_num.cast_pos _)) },\n  rw [nat_size_to_nat, mul_to_nat, nat.size_le] at h ⊢,\n  rw [mod_to_nat, mul_comm],\n  rw [pow_succ', ← nat.mod_add_div b (pos a)] at h,\n  refine lt_of_mul_lt_mul_right (lt_of_le_of_lt _ h) (nat.zero_le 2),\n  rw [mul_two, mul_add],\n  refine add_le_add_left (nat.mul_le_mul_left _\n    (le_trans (le_of_lt (nat.mod_lt _ (pos_num.cast_pos _))) _)) _,\n  suffices : 1 ≤ _, simpa using nat.mul_le_mul_left (pos a) this,\n  rw [nat.le_div_iff_mul_le a.cast_pos, one_mul],\n  exact le_to_nat.2 ab\nend\n\n@[simp] theorem gcd_to_nat : ∀ a b, (gcd a b : ℕ) = nat.gcd a b :=\nhave ∀ a b : num, (a * b).nat_size ≤ a.nat_size + b.nat_size,\nbegin\n  intros,\n  simp [nat_size_to_nat],\n  rw [nat.size_le, pow_add],\n  exact mul_lt_mul'' (nat.lt_size_self _)\n    (nat.lt_size_self _) (nat.zero_le _) (nat.zero_le _)\nend,\nbegin\n  intros, unfold gcd, split_ifs,\n  { exact gcd_to_nat_aux h (this _ _) },\n  { rw nat.gcd_comm,\n    exact gcd_to_nat_aux (le_of_not_le h) (this _ _) }\nend\n\ntheorem dvd_iff_mod_eq_zero {m n : num} : m ∣ n ↔ n % m = 0 :=\nby rw [← dvd_to_nat, nat.dvd_iff_mod_eq_zero,\n  ← to_nat_inj, mod_to_nat]; refl\n\ninstance decidable_dvd : decidable_rel ((∣) : num → num → Prop)\n| a b := decidable_of_iff' _ dvd_iff_mod_eq_zero\n\nend num\n\ninstance pos_num.decidable_dvd : decidable_rel ((∣) : pos_num → pos_num → Prop)\n| a b := num.decidable_dvd _ _\n\nnamespace znum\n\n@[simp] protected lemma div_zero (n : znum) : n / 0 = 0 :=\nshow n.div 0 = 0, by cases n; refl <|> simp [znum.div]\n\n@[simp, norm_cast] theorem div_to_int : ∀ n d, ((n / d : znum) : ℤ) = n / d\n| 0       0       := by simp [int.div_zero]\n| 0       (pos d) := (int.zero_div _).symm\n| 0       (neg d) := (int.zero_div _).symm\n| (pos n) 0       := (int.div_zero _).symm\n| (neg n) 0       := (int.div_zero _).symm\n| (pos n) (pos d) := (num.cast_to_znum _).trans $\n  by rw ← num.to_nat_to_int; simp\n| (pos n) (neg d) := (num.cast_to_znum_neg _).trans $\n  by rw ← num.to_nat_to_int; simp\n| (neg n) (pos d) := show - _ = (-_/↑d), begin\n    rw [n.to_int_eq_succ_pred, d.to_int_eq_succ_pred,\n      ← pos_num.to_nat_to_int, num.succ'_to_nat,\n      num.div_to_nat],\n    change -[1+ n.pred' / ↑d] = -[1+ n.pred' / (d.pred' + 1)],\n    rw d.to_nat_eq_succ_pred\n  end\n| (neg n) (neg d) := show ↑(pos_num.pred' n / num.pos d).succ' = (-_ / -↑d), begin\n    rw [n.to_int_eq_succ_pred, d.to_int_eq_succ_pred,\n      ← pos_num.to_nat_to_int, num.succ'_to_nat,\n      num.div_to_nat],\n    change (nat.succ (_/d) : ℤ) = nat.succ (n.pred'/(d.pred' + 1)),\n    rw d.to_nat_eq_succ_pred\n  end\n\n@[simp, norm_cast] theorem mod_to_int : ∀ n d, ((n % d : znum) : ℤ) = n % d\n| 0       d := (int.zero_mod _).symm\n| (pos n) d := (num.cast_to_znum _).trans $\n  by rw [← num.to_nat_to_int, cast_pos, num.mod_to_nat,\n    ← pos_num.to_nat_to_int, abs_to_nat]; refl\n| (neg n) d := (num.cast_sub' _ _).trans $\n  by rw [← num.to_nat_to_int, cast_neg, ← num.to_nat_to_int,\n    num.succ_to_nat, num.mod_to_nat, abs_to_nat,\n    ← int.sub_nat_nat_eq_coe, n.to_int_eq_succ_pred]; refl\n\n@[simp] theorem gcd_to_nat (a b) : (gcd a b : ℕ) = int.gcd a b :=\n(num.gcd_to_nat _ _).trans $ by simpa\n\ntheorem dvd_iff_mod_eq_zero {m n : znum} : m ∣ n ↔ n % m = 0 :=\nby rw [← dvd_to_int, int.dvd_iff_mod_eq_zero,\n  ← to_int_inj, mod_to_int]; refl\n\ninstance : decidable_rel ((∣) : znum → znum → Prop)\n| a b := decidable_of_iff' _ dvd_iff_mod_eq_zero\n\nend znum\n\nnamespace int\n\n/-- Cast a `snum` to the corresponding integer. -/\ndef of_snum : snum → ℤ :=\nsnum.rec' (λ a, cond a (-1) 0) (λa p IH, cond a (bit1 IH) (bit0 IH))\n\ninstance snum_coe : has_coe snum ℤ := ⟨of_snum⟩\nend int\n\ninstance : has_lt snum := ⟨λa b, (a : ℤ) < b⟩\ninstance : has_le snum := ⟨λa b, (a : ℤ) ≤ b⟩\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/num/lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584174871563662, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.48535782127282945}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n\nAuthor: Leonardo de Moura\n\nPropF has decidable equality\n-/\nimport .soundness\nopen bool decidable nat\n\nnamespace PropF\n  -- Show that PropF has decidable equality\n\n  definition equal : PropF → PropF → bool\n  | (Var x) (Var y)           := if x = y then tt else ff\n  | Bot Bot                   := tt\n  | (Conj p₁ p₂) (Conj q₁ q₂) := equal p₁ q₁ && equal p₂ q₂\n  | (Disj p₁ p₂) (Disj q₁ q₂) := equal p₁ q₁ && equal p₂ q₂\n  | (Impl p₁ p₂) (Impl q₁ q₂) := equal p₁ q₁ && equal p₂ q₂\n  | _            _            := ff\n\n  lemma equal_refl : ∀ p, equal p p = tt\n  | (Var x)      := if_pos rfl\n  | Bot          := rfl\n  | (Conj p₁ p₂) := begin change (equal p₁ p₁ && equal p₂ p₂ = tt), rewrite *equal_refl end\n  | (Disj p₁ p₂) := begin change (equal p₁ p₁ && equal p₂ p₂ = tt), rewrite *equal_refl end\n  | (Impl p₁ p₂) := begin change (equal p₁ p₁ && equal p₂ p₂ = tt), rewrite *equal_refl end\n\n  lemma equal_to_eq : ∀ ⦃p q⦄, equal p q = tt → p = q\n  | (Var x) (Var y) H :=\n    if H₁ : x = y then congr_arg Var H₁\n    else by rewrite [▸ (if x = y then tt else ff) = tt at H, if_neg H₁ at H]; exact (absurd H ff_ne_tt)\n  | Bot Bot H  := rfl\n  | (Conj p₁ p₂) (Conj q₁ q₂) H :=\n    by rewrite [equal_to_eq (band_elim_left H), equal_to_eq (band_elim_right H)]\n  | (Disj p₁ p₂) (Disj q₁ q₂) H :=\n    by rewrite [equal_to_eq (band_elim_left H), equal_to_eq (band_elim_right H)]\n  | (Impl p₁ p₂) (Impl q₁ q₂) H :=\n    by rewrite [equal_to_eq (band_elim_left H), equal_to_eq (band_elim_right H)]\n\n  lemma has_decidable_eq [instance] : decidable_eq PropF :=\n  decidable_eq_of_bool_pred equal_to_eq equal_refl\nend PropF\n", "meta": {"author": "Bolt64", "repo": "lean2-aur", "sha": "1d7148e58a17b2d326b032ed1ebf8c5217320242", "save_path": "github-repos/lean/Bolt64-lean2-aur", "path": "github-repos/lean/Bolt64-lean2-aur/lean2-aur-1d7148e58a17b2d326b032ed1ebf8c5217320242/library/logic/examples/propositional/deceq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.485257371933374}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov, Patrick Massot\n\n! This file was ported from Lean 3 source module data.set.intervals.monoid\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Intervals.Basic\nimport Mathbin.Data.Set.Function\nimport Mathbin.Algebra.Order.Monoid.Cancel.Defs\nimport Mathbin.Algebra.Order.Monoid.Canonical.Defs\nimport Mathbin.Algebra.Group.Basic\n\n/-!\n# Images of intervals under `(+ d)`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe lemmas in this file state that addition maps intervals bijectively. The typeclass\n`has_exists_add_of_le` is defined specifically to make them work when combined with\n`ordered_cancel_add_comm_monoid`; the lemmas below therefore apply to all\n`ordered_add_comm_group`, but also to `ℕ` and `ℝ≥0`, which are not groups.\n-/\n\n\nnamespace Set\n\nvariable {M : Type _} [OrderedCancelAddCommMonoid M] [ExistsAddOfLE M] (a b c d : M)\n\n/- warning: set.Ici_add_bij -> Set.Ici_add_bij is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d))\nCase conversion may be inaccurate. Consider using '#align set.Ici_add_bij Set.Ici_add_bijₓ'. -/\ntheorem Ici_add_bij : BijOn (· + d) (Ici a) (Ici (a + d)) :=\n  by\n  refine'\n    ⟨fun x h => add_le_add_right (mem_Ici.mp h) _, (add_left_injective d).InjOn _, fun _ h => _⟩\n  obtain ⟨c, rfl⟩ := exists_add_of_le (mem_Ici.mp h)\n  rw [mem_Ici, add_right_comm, add_le_add_iff_right] at h\n  exact ⟨a + c, h, by rw [add_right_comm]⟩\n#align set.Ici_add_bij Set.Ici_add_bij\n\n/- warning: set.Ioi_add_bij -> Set.Ioi_add_bij is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d))\nCase conversion may be inaccurate. Consider using '#align set.Ioi_add_bij Set.Ioi_add_bijₓ'. -/\ntheorem Ioi_add_bij : BijOn (· + d) (Ioi a) (Ioi (a + d)) :=\n  by\n  refine'\n    ⟨fun x h => add_lt_add_right (mem_Ioi.mp h) _, fun _ _ _ _ h => add_right_cancel h, fun _ h =>\n      _⟩\n  obtain ⟨c, rfl⟩ := exists_add_of_le (mem_Ioi.mp h).le\n  rw [mem_Ioi, add_right_comm, add_lt_add_iff_right] at h\n  exact ⟨a + c, h, by rw [add_right_comm]⟩\n#align set.Ioi_add_bij Set.Ioi_add_bij\n\n/- warning: set.Icc_add_bij -> Set.Icc_add_bij is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nCase conversion may be inaccurate. Consider using '#align set.Icc_add_bij Set.Icc_add_bijₓ'. -/\ntheorem Icc_add_bij : BijOn (· + d) (Icc a b) (Icc (a + d) (b + d)) :=\n  by\n  rw [← Ici_inter_Iic, ← Ici_inter_Iic]\n  exact\n    (Ici_add_bij a d).inter_mapsTo (fun x hx => add_le_add_right hx _) fun x hx =>\n      le_of_add_le_add_right hx.2\n#align set.Icc_add_bij Set.Icc_add_bij\n\n/- warning: set.Ioo_add_bij -> Set.Ioo_add_bij is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nCase conversion may be inaccurate. Consider using '#align set.Ioo_add_bij Set.Ioo_add_bijₓ'. -/\ntheorem Ioo_add_bij : BijOn (· + d) (Ioo a b) (Ioo (a + d) (b + d)) :=\n  by\n  rw [← Ioi_inter_Iio, ← Ioi_inter_Iio]\n  exact\n    (Ioi_add_bij a d).inter_mapsTo (fun x hx => add_lt_add_right hx _) fun x hx =>\n      lt_of_add_lt_add_right hx.2\n#align set.Ioo_add_bij Set.Ioo_add_bij\n\n/- warning: set.Ioc_add_bij -> Set.Ioc_add_bij is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nCase conversion may be inaccurate. Consider using '#align set.Ioc_add_bij Set.Ioc_add_bijₓ'. -/\ntheorem Ioc_add_bij : BijOn (· + d) (Ioc a b) (Ioc (a + d) (b + d)) :=\n  by\n  rw [← Ioi_inter_Iic, ← Ioi_inter_Iic]\n  exact\n    (Ioi_add_bij a d).inter_mapsTo (fun x hx => add_le_add_right hx _) fun x hx =>\n      le_of_add_le_add_right hx.2\n#align set.Ioc_add_bij Set.Ioc_add_bij\n\n/- warning: set.Ico_add_bij -> Set.Ico_add_bij is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (d : M), Set.BijOn.{u1, u1} M M (fun (_x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) _x d) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) a b) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a d) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b d))\nCase conversion may be inaccurate. Consider using '#align set.Ico_add_bij Set.Ico_add_bijₓ'. -/\ntheorem Ico_add_bij : BijOn (· + d) (Ico a b) (Ico (a + d) (b + d)) :=\n  by\n  rw [← Ici_inter_Iio, ← Ici_inter_Iio]\n  exact\n    (Ici_add_bij a d).inter_mapsTo (fun x hx => add_lt_add_right hx _) fun x hx =>\n      lt_of_add_lt_add_right hx.2\n#align set.Ico_add_bij Set.Ico_add_bij\n\n/-!\n### Images under `x ↦ x + a`\n-/\n\n\n/- warning: set.image_add_const_Ici -> Set.image_add_const_Ici is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a))\nCase conversion may be inaccurate. Consider using '#align set.image_add_const_Ici Set.image_add_const_Iciₓ'. -/\n@[simp]\ntheorem image_add_const_Ici : (fun x => x + a) '' Ici b = Ici (b + a) :=\n  (Ici_add_bij _ _).image_eq\n#align set.image_add_const_Ici Set.image_add_const_Ici\n\n/- warning: set.image_add_const_Ioi -> Set.image_add_const_Ioi is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a))\nCase conversion may be inaccurate. Consider using '#align set.image_add_const_Ioi Set.image_add_const_Ioiₓ'. -/\n@[simp]\ntheorem image_add_const_Ioi : (fun x => x + a) '' Ioi b = Ioi (b + a) :=\n  (Ioi_add_bij _ _).image_eq\n#align set.image_add_const_Ioi Set.image_add_const_Ioi\n\n/- warning: set.image_add_const_Icc -> Set.image_add_const_Icc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nCase conversion may be inaccurate. Consider using '#align set.image_add_const_Icc Set.image_add_const_Iccₓ'. -/\n@[simp]\ntheorem image_add_const_Icc : (fun x => x + a) '' Icc b c = Icc (b + a) (c + a) :=\n  (Icc_add_bij _ _ _).image_eq\n#align set.image_add_const_Icc Set.image_add_const_Icc\n\n/- warning: set.image_add_const_Ico -> Set.image_add_const_Ico is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nCase conversion may be inaccurate. Consider using '#align set.image_add_const_Ico Set.image_add_const_Icoₓ'. -/\n@[simp]\ntheorem image_add_const_Ico : (fun x => x + a) '' Ico b c = Ico (b + a) (c + a) :=\n  (Ico_add_bij _ _ _).image_eq\n#align set.image_add_const_Ico Set.image_add_const_Ico\n\n/- warning: set.image_add_const_Ioc -> Set.image_add_const_Ioc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nCase conversion may be inaccurate. Consider using '#align set.image_add_const_Ioc Set.image_add_const_Iocₓ'. -/\n@[simp]\ntheorem image_add_const_Ioc : (fun x => x + a) '' Ioc b c = Ioc (b + a) (c + a) :=\n  (Ioc_add_bij _ _ _).image_eq\n#align set.image_add_const_Ioc Set.image_add_const_Ioc\n\n/- warning: set.image_add_const_Ioo -> Set.image_add_const_Ioo is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) x a) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) b a) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) c a))\nCase conversion may be inaccurate. Consider using '#align set.image_add_const_Ioo Set.image_add_const_Iooₓ'. -/\n@[simp]\ntheorem image_add_const_Ioo : (fun x => x + a) '' Ioo b c = Ioo (b + a) (c + a) :=\n  (Ioo_add_bij _ _ _).image_eq\n#align set.image_add_const_Ioo Set.image_add_const_Ioo\n\n/-!\n### Images under `x ↦ a + x`\n-/\n\n\n/- warning: set.image_const_add_Ici -> Set.image_const_add_Ici is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ici.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b))\nCase conversion may be inaccurate. Consider using '#align set.image_const_add_Ici Set.image_const_add_Iciₓ'. -/\n@[simp]\ntheorem image_const_add_Ici : (fun x => a + x) '' Ici b = Ici (a + b) := by\n  simp only [add_comm a, image_add_const_Ici]\n#align set.image_const_add_Ici Set.image_const_add_Ici\n\n/- warning: set.image_const_add_Ioi -> Set.image_const_add_Ioi is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b)) (Set.Ioi.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b))\nCase conversion may be inaccurate. Consider using '#align set.image_const_add_Ioi Set.image_const_add_Ioiₓ'. -/\n@[simp]\ntheorem image_const_add_Ioi : (fun x => a + x) '' Ioi b = Ioi (a + b) := by\n  simp only [add_comm a, image_add_const_Ioi]\n#align set.image_const_add_Ioi Set.image_const_add_Ioi\n\n/- warning: set.image_const_add_Icc -> Set.image_const_add_Icc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Icc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nCase conversion may be inaccurate. Consider using '#align set.image_const_add_Icc Set.image_const_add_Iccₓ'. -/\n@[simp]\ntheorem image_const_add_Icc : (fun x => a + x) '' Icc b c = Icc (a + b) (a + c) := by\n  simp only [add_comm a, image_add_const_Icc]\n#align set.image_const_add_Icc Set.image_const_add_Icc\n\n/- warning: set.image_const_add_Ico -> Set.image_const_add_Ico is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ico.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nCase conversion may be inaccurate. Consider using '#align set.image_const_add_Ico Set.image_const_add_Icoₓ'. -/\n@[simp]\ntheorem image_const_add_Ico : (fun x => a + x) '' Ico b c = Ico (a + b) (a + c) := by\n  simp only [add_comm a, image_add_const_Ico]\n#align set.image_const_add_Ico Set.image_const_add_Ico\n\n/- warning: set.image_const_add_Ioc -> Set.image_const_add_Ioc is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioc.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nCase conversion may be inaccurate. Consider using '#align set.image_const_add_Ioc Set.image_const_add_Iocₓ'. -/\n@[simp]\ntheorem image_const_add_Ioc : (fun x => a + x) '' Ioc b c = Ioc (a + b) (a + c) := by\n  simp only [add_comm a, image_add_const_Ioc]\n#align set.image_const_add_Ioc Set.image_const_add_Ioc\n\n/- warning: set.image_const_add_Ioo -> Set.image_const_add_Ioo is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toHasAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} M] [_inst_2 : ExistsAddOfLE.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1)))))) (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)))] (a : M) (b : M) (c : M), Eq.{succ u1} (Set.{u1} M) (Set.image.{u1, u1} M M (fun (x : M) => HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a x) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) b c)) (Set.Ioo.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelAddCommMonoid.toPartialOrder.{u1} M _inst_1)) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a b) (HAdd.hAdd.{u1, u1, u1} M M M (instHAdd.{u1} M (AddZeroClass.toAdd.{u1} M (AddMonoid.toAddZeroClass.{u1} M (AddRightCancelMonoid.toAddMonoid.{u1} M (AddCancelMonoid.toAddRightCancelMonoid.{u1} M (AddCancelCommMonoid.toAddCancelMonoid.{u1} M (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} M _inst_1))))))) a c))\nCase conversion may be inaccurate. Consider using '#align set.image_const_add_Ioo Set.image_const_add_Iooₓ'. -/\n@[simp]\ntheorem image_const_add_Ioo : (fun x => a + x) '' Ioo b c = Ioo (a + b) (a + c) := by\n  simp only [add_comm a, image_add_const_Ioo]\n#align set.image_const_add_Ioo Set.image_const_add_Ioo\n\nend Set\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Set/Intervals/Monoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.48525735958260424}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport algebra.hom.group\nimport logic.equiv.basic\n/-!\n# Type tags that turn additive structures into multiplicative, and vice versa\n\nWe define two type tags:\n\n* `additive α`: turns any multiplicative structure on `α` into the corresponding\n  additive structure on `additive α`;\n* `multiplicative α`: turns any additive structure on `α` into the corresponding\n  multiplicative structure on `multiplicative α`.\n\nWe also define instances `additive.*` and `multiplicative.*` that actually transfer the structures.\n-/\n\nuniverses u v\nvariables {α : Type u} {β : Type v}\n\n/-- If `α` carries some multiplicative structure, then `additive α` carries the corresponding\nadditive structure. -/\ndef additive (α : Type*) := α\n/-- If `α` carries some additive structure, then `multiplicative α` carries the corresponding\nmultiplicative structure. -/\ndef multiplicative (α : Type*) := α\n\nnamespace additive\n\n/-- Reinterpret `x : α` as an element of `additive α`. -/\ndef of_mul : α ≃ additive α := ⟨λ x, x, λ x, x, λ x, rfl, λ x, rfl⟩\n\n/-- Reinterpret `x : additive α` as an element of `α`. -/\ndef to_mul : additive α ≃ α := of_mul.symm\n\n@[simp] lemma of_mul_symm_eq : (@of_mul α).symm = to_mul := rfl\n\n@[simp] lemma to_mul_symm_eq : (@to_mul α).symm = of_mul := rfl\n\nend additive\n\nnamespace multiplicative\n\n/-- Reinterpret `x : α` as an element of `multiplicative α`. -/\ndef of_add : α ≃ multiplicative α := ⟨λ x, x, λ x, x, λ x, rfl, λ x, rfl⟩\n\n/-- Reinterpret `x : multiplicative α` as an element of `α`. -/\ndef to_add : multiplicative α ≃ α := of_add.symm\n\n@[simp] lemma of_add_symm_eq : (@of_add α).symm = to_add := rfl\n\n@[simp] \n\nend multiplicative\n\n@[simp] lemma to_add_of_add (x : α) : (multiplicative.of_add x).to_add = x := rfl\n@[simp] lemma of_add_to_add (x : multiplicative α) : multiplicative.of_add x.to_add = x := rfl\n\n@[simp] lemma to_mul_of_mul (x : α) : (additive.of_mul x).to_mul = x := rfl\n@[simp] lemma of_mul_to_mul (x : additive α) : additive.of_mul x.to_mul = x := rfl\n\ninstance [inhabited α] : inhabited (additive α) := ⟨additive.of_mul default⟩\ninstance [inhabited α] : inhabited (multiplicative α) := ⟨multiplicative.of_add default⟩\n\ninstance [nontrivial α] : nontrivial (additive α) :=\nadditive.of_mul.injective.nontrivial\n\ninstance [nontrivial α] : nontrivial (multiplicative α) :=\nmultiplicative.of_add.injective.nontrivial\n\ninstance additive.has_add [has_mul α] : has_add (additive α) :=\n{ add := λ x y, additive.of_mul (x.to_mul * y.to_mul) }\n\ninstance [has_add α] : has_mul (multiplicative α) :=\n{ mul := λ x y, multiplicative.of_add (x.to_add + y.to_add) }\n\n@[simp] lemma of_add_add [has_add α] (x y : α) :\n  multiplicative.of_add (x + y) = multiplicative.of_add x * multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_mul [has_add α] (x y : multiplicative α) :\n  (x * y).to_add = x.to_add + y.to_add :=\nrfl\n\n@[simp] lemma of_mul_mul [has_mul α] (x y : α) :\n  additive.of_mul (x * y) = additive.of_mul x + additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_add [has_mul α] (x y : additive α) :\n  (x + y).to_mul = x.to_mul * y.to_mul :=\nrfl\n\ninstance [semigroup α] : add_semigroup (additive α) :=\n{ add_assoc := @mul_assoc α _,\n  ..additive.has_add }\n\ninstance [add_semigroup α] : semigroup (multiplicative α) :=\n{ mul_assoc := @add_assoc α _,\n  ..multiplicative.has_mul }\n\ninstance [comm_semigroup α] : add_comm_semigroup (additive α) :=\n{ add_comm := @mul_comm _ _,\n  ..additive.add_semigroup }\n\ninstance [add_comm_semigroup α] : comm_semigroup (multiplicative α) :=\n{ mul_comm := @add_comm _ _,\n  ..multiplicative.semigroup }\n\ninstance [left_cancel_semigroup α] : add_left_cancel_semigroup (additive α) :=\n{ add_left_cancel := @mul_left_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_left_cancel_semigroup α] : left_cancel_semigroup (multiplicative α) :=\n{ mul_left_cancel := @add_left_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [right_cancel_semigroup α] : add_right_cancel_semigroup (additive α) :=\n{ add_right_cancel := @mul_right_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_right_cancel_semigroup α] : right_cancel_semigroup (multiplicative α) :=\n{ mul_right_cancel := @add_right_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [has_one α] : has_zero (additive α) := ⟨additive.of_mul 1⟩\n\n@[simp] lemma of_mul_one [has_one α] : @additive.of_mul α 1 = 0 := rfl\n\n@[simp] lemma of_mul_eq_zero {A : Type*} [has_one A] {x : A} :\n  additive.of_mul x = 0 ↔ x = 1 := iff.rfl\n\n@[simp] lemma to_mul_zero [has_one α] : (0 : additive α).to_mul = 1 := rfl\n\ninstance [has_zero α] : has_one (multiplicative α) := ⟨multiplicative.of_add 0⟩\n\n@[simp] lemma of_add_zero [has_zero α] : @multiplicative.of_add α 0 = 1 := rfl\n\n@[simp] lemma of_add_eq_one {A : Type*} [has_zero A] {x : A} :\n  multiplicative.of_add x = 1 ↔ x = 0 := iff.rfl\n\n@[simp] lemma to_add_one [has_zero α] : (1 : multiplicative α).to_add = 0 := rfl\n\ninstance [mul_one_class α] : add_zero_class (additive α) :=\n{ zero     := 0,\n  add      := (+),\n  zero_add := one_mul,\n  add_zero := mul_one }\n\ninstance [add_zero_class α] : mul_one_class (multiplicative α) :=\n{ one     := 1,\n  mul     := (*),\n  one_mul := zero_add,\n  mul_one := add_zero }\n\ninstance [h : monoid α] : add_monoid (additive α) :=\n{ zero     := 0,\n  add      := (+),\n  nsmul    := @monoid.npow α h,\n  nsmul_zero' := monoid.npow_zero',\n  nsmul_succ' := monoid.npow_succ',\n  ..additive.add_zero_class,\n  ..additive.add_semigroup }\n\ninstance [h : add_monoid α] : monoid (multiplicative α) :=\n{ one     := 1,\n  mul     := (*),\n  npow   := @add_monoid.nsmul α h,\n  npow_zero' := add_monoid.nsmul_zero',\n  npow_succ' := add_monoid.nsmul_succ',\n  ..multiplicative.mul_one_class,\n  ..multiplicative.semigroup }\n\ninstance [left_cancel_monoid α] : add_left_cancel_monoid (additive α) :=\n{ zero := 0, add := (+), .. additive.add_monoid, .. additive.add_left_cancel_semigroup }\n\ninstance [add_left_cancel_monoid α] : left_cancel_monoid (multiplicative α) :=\n{ one := 1, mul := (*), .. multiplicative.monoid, .. multiplicative.left_cancel_semigroup }\n\ninstance [right_cancel_monoid α] : add_right_cancel_monoid (additive α) :=\n{ zero := 0, add := (+), .. additive.add_monoid, .. additive.add_right_cancel_semigroup }\n\ninstance [add_right_cancel_monoid α] : right_cancel_monoid (multiplicative α) :=\n{ one := 1, mul := (*), .. multiplicative.monoid, .. multiplicative.right_cancel_semigroup }\n\ninstance [comm_monoid α] : add_comm_monoid (additive α) :=\n{ zero := 0, add := (+), .. additive.add_monoid, .. additive.add_comm_semigroup }\n\ninstance [add_comm_monoid α] : comm_monoid (multiplicative α) :=\n{ one := 1, mul := (*), ..multiplicative.monoid, .. multiplicative.comm_semigroup }\n\ninstance [has_inv α] : has_neg (additive α) := ⟨λ x, multiplicative.of_add x.to_mul⁻¹⟩\n\n@[simp] lemma of_mul_inv [has_inv α] (x : α) : additive.of_mul x⁻¹ = -(additive.of_mul x) := rfl\n\n@[simp] lemma to_mul_neg [has_inv α] (x : additive α) : (-x).to_mul = x.to_mul⁻¹ := rfl\n\ninstance [has_neg α] : has_inv (multiplicative α) := ⟨λ x, additive.of_mul (-x.to_add)⟩\n\n@[simp] lemma of_add_neg [has_neg α] (x : α) :\n  multiplicative.of_add (-x) = (multiplicative.of_add x)⁻¹ := rfl\n\n@[simp] lemma to_add_inv [has_neg α] (x : multiplicative α) :\n  (x⁻¹).to_add = -x.to_add := rfl\n\ninstance additive.has_sub [has_div α] : has_sub (additive α) :=\n{ sub := λ x y, additive.of_mul (x.to_mul / y.to_mul) }\n\ninstance multiplicative.has_div [has_sub α] : has_div (multiplicative α) :=\n{ div := λ x y, multiplicative.of_add (x.to_add - y.to_add) }\n\n@[simp] lemma of_add_sub [has_sub α] (x y : α) :\n  multiplicative.of_add (x - y) = multiplicative.of_add x / multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_div [has_sub α] (x y : multiplicative α) :\n  (x / y).to_add = x.to_add - y.to_add :=\nrfl\n\n@[simp] lemma of_mul_div [has_div α] (x y : α) :\n  additive.of_mul (x / y) = additive.of_mul x - additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_sub [has_div α] (x y : additive α) :\n  (x - y).to_mul = x.to_mul / y.to_mul :=\nrfl\n\ninstance [div_inv_monoid α] : sub_neg_monoid (additive α) :=\n{ sub_eq_add_neg := @div_eq_mul_inv α _,\n  zsmul := @div_inv_monoid.zpow α _,\n  zsmul_zero' := div_inv_monoid.zpow_zero',\n  zsmul_succ' := div_inv_monoid.zpow_succ',\n  zsmul_neg' := div_inv_monoid.zpow_neg',\n  .. additive.has_neg, .. additive.has_sub, .. additive.add_monoid }\n\ninstance [sub_neg_monoid α] : div_inv_monoid (multiplicative α) :=\n{ div_eq_mul_inv := @sub_eq_add_neg α _,\n  zpow := @sub_neg_monoid.zsmul α _,\n  zpow_zero' := sub_neg_monoid.zsmul_zero',\n  zpow_succ' := sub_neg_monoid.zsmul_succ',\n  zpow_neg' := sub_neg_monoid.zsmul_neg',\n  .. multiplicative.has_inv, .. multiplicative.has_div, .. multiplicative.monoid }\n\ninstance [group α] : add_group (additive α) :=\n{ add_left_neg := @mul_left_inv α _,\n  .. additive.sub_neg_monoid }\n\ninstance [add_group α] : group (multiplicative α) :=\n{ mul_left_inv := @add_left_neg α _,\n  .. multiplicative.div_inv_monoid }\n\ninstance [comm_group α] : add_comm_group (additive α) :=\n{ .. additive.add_group, .. additive.add_comm_monoid }\n\ninstance [add_comm_group α] : comm_group (multiplicative α) :=\n{ .. multiplicative.group, .. multiplicative.comm_monoid }\n\n/-- Reinterpret `α →+ β` as `multiplicative α →* multiplicative β`. -/\ndef add_monoid_hom.to_multiplicative [add_zero_class α] [add_zero_class β] :\n  (α →+ β) ≃ (multiplicative α →* multiplicative β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `α →* β` as `additive α →+ additive β`. -/\ndef monoid_hom.to_additive [mul_one_class α] [mul_one_class β] :\n  (α →* β) ≃ (additive α →+ additive β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `additive α →+ β` as `α →* multiplicative β`. -/\ndef add_monoid_hom.to_multiplicative' [mul_one_class α] [add_zero_class β] :\n  (additive α →+ β) ≃ (α →* multiplicative β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `α →* multiplicative β` as `additive α →+ β`. -/\ndef monoid_hom.to_additive' [mul_one_class α] [add_zero_class β] :\n  (α →* multiplicative β) ≃ (additive α →+ β) :=\nadd_monoid_hom.to_multiplicative'.symm\n\n/-- Reinterpret `α →+ additive β` as `multiplicative α →* β`. -/\ndef add_monoid_hom.to_multiplicative'' [add_zero_class α] [mul_one_class β] :\n  (α →+ additive β) ≃ (multiplicative α →* β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `multiplicative α →* β` as `α →+ additive β`. -/\ndef monoid_hom.to_additive'' [add_zero_class α] [mul_one_class β] :\n  (multiplicative α →* β) ≃ (α →+ additive β) :=\nadd_monoid_hom.to_multiplicative''.symm\n\n/-- If `α` has some multiplicative structure and coerces to a function,\nthen `additive α` should also coerce to the same function.\n\nThis allows `additive` to be used on bundled function types with a multiplicative structure, which\nis often used for composition, without affecting the behavior of the function itself.\n-/\ninstance additive.has_coe_to_fun {α : Type*} {β : α → Sort*} [has_coe_to_fun α β] :\n  has_coe_to_fun (additive α) (λ a, β a.to_mul) :=\n⟨λ a, coe_fn a.to_mul⟩\n\n/-- If `α` has some additive structure and coerces to a function,\nthen `multiplicative α` should also coerce to the same function.\n\nThis allows `multiplicative` to be used on bundled function types with an additive structure, which\nis often used for composition, without affecting the behavior of the function itself.\n-/\ninstance multiplicative.has_coe_to_fun {α : Type*} {β : α → Sort*} [has_coe_to_fun α β] :\n  has_coe_to_fun (multiplicative α) (λ a, β a.to_add) :=\n⟨λ a, coe_fn a.to_add⟩\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/group/type_tags.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.7217432062975978, "lm_q1q2_score": 0.4852508457383869}}
{"text": "import topology.continuous_function.basic\nimport topology.instances.real\nimport topology.path_connected\nimport intervals\n\n/-!\n# Homotopy\n\nIn this file, we define homotopies between continuous functions. Note in particular that we are\ndefining homotopies to be `to_fun : C(X × ℝ, Y)` instead of `to_fun : C(X × I, Y)`. This is because\nof the subtypes can be annoying to work with, and we don't actually care about the value that the\nhomotopy takes outside of `X × [0, 1]`.\n\n## Implementation Notes\n\nThe definition of homotopies is inspired by the file HOL-Library/Homotopy, by Lawrence Paulson. In\nparticular, we define a general `homotopy_with f₀ f₁ P`, which is a homotopy between `f₀` and `f₁`,\nwhere all of the intermediate maps satisfy the property `P`. In particular, this general definition\nallows us to define homotopy, homotopy between paths, homotopy between loops and homotopy relative\nto a subset all using the same definition. \n\n## Key Declarations\n\n- `homotopy_with f₀ f₁ P` - A homotopy between `f₀` and `f₁`, where all of the intermediate maps\n  satisfy the property `P`.\n- `homotopy f₀ f₁` - A homotopy between `f₀` and `f₁`.\n-/\n\nnoncomputable theory\n\nvariables {X Y : Type _} [topological_space X] [topological_space Y]\n\n/--\nA homotopy between `f₀` and `f₁`, with a proposition `P` restricting the intermediate maps.\n-/\n@[nolint has_inhabited_instance] -- if `P` is always `false`, then there are no homotopies.\nstructure homotopy_with (f₀ f₁ : C(X, Y)) (P : (X → Y) → Prop) :=\n(to_fun : C(X × ℝ, Y))\n(to_fun_zero' : ∀ x, to_fun (x, 0) = f₀ x)\n(to_fun_one' : ∀ x, to_fun (x, 1) = f₁ x)\n(prop : ∀ t, P(λ x, to_fun (x, t)))\n\nnamespace homotopy_with\n\nvariables {f₀ f₁ f₂ : C(X, Y)} {P : (X → Y) → Prop}\n\ninstance : has_coe_t (homotopy_with f₀ f₁ P) (C(X × ℝ, Y)) := ⟨homotopy_with.to_fun⟩\ninstance : has_coe_to_fun (homotopy_with f₀ f₁ P) := ⟨_, λ h, h.to_fun.to_fun⟩\n\n@[continuity]\nlemma continuous (h : homotopy_with f₀ f₁ P) : continuous h := h.to_fun.continuous\n\n@[simp] lemma to_fun_zero (h : homotopy_with f₀ f₁ P) (x : X) : h (x, 0) = f₀ x := \n  h.to_fun_zero' x \n\n@[simp] lemma to_fun_one (h : homotopy_with f₀ f₁ P) (x : X) : h (x, 1) = f₁ x := \n  h.to_fun_one' x \n\n@[simp] lemma coe_coe_apply_eq_coe (h : homotopy_with f₀ f₁ P) (x : X × ℝ) :\n  (h : C(X × ℝ, Y)) x = h x := rfl\n\n/--\nIf `f₀` satisfies the property `P`, then we have a `homotopy_with f₀ f₀ P`.\n-/\ndef refl (hP : P f₀) : homotopy_with f₀ f₀ P :=\n{ to_fun := \n  { to_fun := λ p, f₀ p.1 },\n  to_fun_zero' := by simp only [continuous_map.coe_mk, implies_true_iff, eq_self_iff_true],\n  to_fun_one' := by simp only [continuous_map.coe_mk, implies_true_iff, eq_self_iff_true],\n  prop := λ t, hP }\n\n/--\nIf `f₀` and `f₁` agree on every input, and that `f₀` satisfies the property `P`, then we have a ` homotmotopy_with f₀ f₁ P`.\n-/\ndef of_refl (hP : P f₀) (h : f₀ = f₁) : homotopy_with f₀ f₁ P :=\n{ to_fun := { to_fun := λ p, f₀ p.1 },\n  to_fun_zero' := by simp only [continuous_map.coe_mk, implies_true_iff, eq_self_iff_true],\n  to_fun_one' := by simp only [continuous_map.coe_mk, implies_true_iff, eq_self_iff_true, h],\n  prop := λ t, hP }\n\n/--\nIf we have `h : homotopy_with f₀ f₁ P`, we can define a `homotopy_with f₁ f₀ P` by reversing the \ndirection of the homotopy.\n-/\ndef symm (h : homotopy_with f₀ f₁ P) : homotopy_with f₁ f₀ P :=\n{ to_fun := \n  { to_fun := λ p, h (p.1, 1 - p.2) },\n  to_fun_zero' := by simp,\n  to_fun_one' := by simp,\n  prop := λ t, \n  begin\n    simp only [continuous_map.coe_mk],\n    apply h.prop,\n  end }\n\n/--\nIf we have `h₀ : homotopy_with f₀ f₁ P` and `h₁ : homotopy_with f₁ f₂ P`, we can define a\n`homotopy_with f₀ f₂ P` by 'gluing' the homotopies together.\n-/\ndef trans (h₀ : homotopy_with f₀ f₁ P) (h₁ : homotopy_with f₁ f₂ P) : homotopy_with f₀ f₂ P :=\n{ to_fun := \n  { to_fun := λ p, if p.2 ≤ 1/2 then h₀ (p.1, 2 * p.2) else h₁ (p.1, 2 * p.2 - 1),\n    continuous_to_fun := begin\n      apply continuous.if; [skip, continuity, continuity],\n      intros a ha,\n      rw frontier_snd_le at ha,\n      obtain ⟨ha₁, ha₂⟩ := ha,\n      simp only [*, one_div, set.mem_singleton_iff, to_fun_one, mul_inv_cancel, ne.def, \n                 not_false_iff, bit0_eq_zero, one_ne_zero, to_fun_zero, sub_self] at *,\n    end },\n  to_fun_zero' := λ x, by simp only [one_div, zero_le_one, inv_nonneg, if_true, \n                                     continuous_map.coe_mk, zero_le_bit0, to_fun_zero, mul_zero],\n  to_fun_one' := λ x, by norm_num,\n  prop := λ t, begin\n    simp only [continuous_map.coe_mk, set.mem_singleton_iff, to_fun_one, mul_inv_cancel, \n               ne.def, not_false_iff, bit0_eq_zero, one_ne_zero, to_fun_zero, sub_self],\n    split_ifs,\n    { apply h₀.prop },\n    { apply h₁.prop }\n  end }\n\nend homotopy_with\n\n/--\nA `homotopy f₀ f₁` is defined to be a `homotopy_with f₀ f₁ P`, where `P` is always `true`.\n-/\nabbreviation homotopy (f₀ f₁ : C(X, Y)) := homotopy_with f₀ f₁ (λ f, true)\n\nnamespace homotopy\n\nvariables {f₀ f₁ f₂ : C(X, Y)}\n\n/--\nFor `homotopy f₀ f₀`, the property `P` in `homotopy_with.refl` is always satisfied, so we add in\nthis definition so we don't need to prove `true` every time. \n-/\ndef refl (f₀ : C(X, Y)) : homotopy f₀ f₀ := homotopy_with.refl trivial\n\n/--\nThe property `P` in `homotopy_with.refl` is always satisfied for `homotopy`, so we add in this\ndefinition so we don't need to prove `true` every time.\n-/\ndef of_refl (h : f₀ = f₁) : homotopy f₀ f₁ := homotopy_with.of_refl trivial h\n\nend homotopy\n\n/--\nTwo continuous functions `f₀` and `f₁` are homotopic if there exists a `homotopy f₀ f₁`.\n-/\ndef homotopic (f₀ f₁ : C(X, Y)) := nonempty (homotopy f₀ f₁)\n\nlemma homotopic.equiv : equivalence (@homotopic X Y _ _) :=\n⟨λ f, ⟨homotopy.refl f⟩, λ f g ⟨h⟩, ⟨h.symm⟩, λ f₀ f₁ f₂ ⟨h₀⟩ ⟨h₁⟩, ⟨h₀.trans h₁⟩⟩\n", "meta": {"author": "shingtaklam1324", "repo": "alg-top", "sha": "4c88e28df6f0a329f26eab32bae023789193990e", "save_path": "github-repos/lean/shingtaklam1324-alg-top", "path": "github-repos/lean/shingtaklam1324-alg-top/alg-top-4c88e28df6f0a329f26eab32bae023789193990e/src/homotopy/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.48525083626117}}
{"text": "/-\nCopyright (c) 2019 Abhimanyu Pallavi Sudhir. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Abhimanyu Pallavi Sudhir\n-/\nimport order.filter.filter_product\nimport analysis.specific_limits\n\n/-!\n# Construction of the hyperreal numbers as an ultraproduct of real sequences.\n-/\n\nopen filter filter.germ\nopen_locale topological_space classical\n\n/-- Hyperreal numbers on the ultrafilter extending the cofinite filter -/\n@[derive [linear_ordered_field, inhabited]]\ndef hyperreal : Type := germ (hyperfilter ℕ : filter ℕ) ℝ\n\nnamespace hyperreal\n\nnotation `ℝ*` := hyperreal\n\nnoncomputable instance : has_coe_t ℝ ℝ* := ⟨λ x, (↑x : germ _ _)⟩\n\n@[simp, norm_cast]\nlemma coe_eq_coe {x y : ℝ} : (x : ℝ*) = y ↔ x = y :=\ngerm.const_inj\n\n@[simp, norm_cast] lemma coe_eq_zero {x : ℝ} : (x : ℝ*) = 0 ↔ x = 0 := coe_eq_coe\n@[simp, norm_cast] lemma coe_eq_one {x : ℝ} : (x : ℝ*) = 1 ↔ x = 1 := coe_eq_coe\n\n@[simp, norm_cast] lemma coe_one : ↑(1 : ℝ) = (1 : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_zero : ↑(0 : ℝ) = (0 : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_inv (x : ℝ) : ↑(x⁻¹) = (x⁻¹ : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_neg (x : ℝ) : ↑(-x) = (-x : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_add (x y : ℝ) : ↑(x + y) = (x + y : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_bit0 (x : ℝ) : ↑(bit0 x) = (bit0 x : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_bit1 (x : ℝ) : ↑(bit1 x) = (bit1 x : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_mul (x y : ℝ) : ↑(x * y) = (x * y : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_div (x y : ℝ) : ↑(x / y) = (x / y : ℝ*) := rfl\n@[simp, norm_cast] lemma coe_sub (x y : ℝ) : ↑(x - y) = (x - y : ℝ*) := rfl\n\n@[simp, norm_cast] lemma coe_lt_coe {x y : ℝ} : (x : ℝ*) < y ↔ x < y := germ.const_lt\n@[simp, norm_cast] lemma coe_pos {x : ℝ} : 0 < (x : ℝ*) ↔ 0 < x :=\ncoe_lt_coe\n@[simp, norm_cast] lemma coe_le_coe {x y : ℝ} : (x : ℝ*) ≤ y ↔ x ≤ y := germ.const_le_iff\n@[simp, norm_cast] lemma coe_abs (x : ℝ) : ((abs x : ℝ) : ℝ*) = abs x := germ.const_abs _\n@[simp, norm_cast] lemma coe_max (x y : ℝ) : ((max x y : ℝ) : ℝ*) = max x y := germ.const_max _ _\n@[simp, norm_cast] lemma coe_min (x y : ℝ) : ((min x y : ℝ) : ℝ*) = min x y := germ.const_min _ _\n\n/-- Construct a hyperreal number from a sequence of real numbers. -/\nnoncomputable def of_seq (f : ℕ → ℝ) : ℝ* := (↑f : germ (hyperfilter ℕ : filter ℕ) ℝ)\n\n/-- A sample infinitesimal hyperreal-/\nnoncomputable def epsilon : ℝ* := of_seq $ λ n, n⁻¹\n\n/-- A sample infinite hyperreal-/\nnoncomputable def omega : ℝ* := of_seq coe\n\nlocalized \"notation `ε` := hyperreal.epsilon\" in hyperreal\nlocalized \"notation `ω` := hyperreal.omega\" in hyperreal\n\nlemma epsilon_eq_inv_omega : ε = ω⁻¹ := rfl\n\nlemma inv_epsilon_eq_omega : ε⁻¹ = ω := @inv_inv' _ _ ω\n\nlemma epsilon_pos : 0 < ε :=\nsuffices ∀ᶠ i in hyperfilter ℕ, (0 : ℝ) < (i : ℕ)⁻¹, by rwa lt_def,\nhave h0' : {n : ℕ | ¬ 0 < n} = {0} :=\nby simp only [not_lt, (set.set_of_eq_eq_singleton).symm]; ext; exact nat.le_zero_iff,\nbegin\n  simp only [inv_pos, nat.cast_pos],\n  exact mem_hyperfilter_of_finite_compl (by convert set.finite_singleton _),\nend\n\nlemma epsilon_ne_zero : ε ≠ 0 := ne_of_gt epsilon_pos\n\nlemma omega_pos : 0 < ω := by rw ←inv_epsilon_eq_omega; exact inv_pos.2 epsilon_pos\n\nlemma omega_ne_zero : ω ≠ 0 := ne_of_gt omega_pos\n\ntheorem epsilon_mul_omega : ε * ω = 1 := @inv_mul_cancel _ _ ω omega_ne_zero\n\nlemma lt_of_tendsto_zero_of_pos {f : ℕ → ℝ} (hf : tendsto f at_top (𝓝 0)) :\n  ∀ {r : ℝ}, 0 < r → of_seq f < (r : ℝ*) :=\nbegin\n  simp only [metric.tendsto_at_top, dist_zero_right, norm, lt_def] at hf ⊢,\n  intros r hr, cases hf r hr with N hf',\n  have hs : {i : ℕ | f i < r}ᶜ ⊆ {i : ℕ | i ≤ N} :=\n    λ i hi1, le_of_lt (by simp only [lt_iff_not_ge];\n    exact λ hi2, hi1 (lt_of_le_of_lt (le_abs_self _) (hf' i hi2)) : i < N),\n  exact mem_hyperfilter_of_finite_compl\n    ((set.finite_le_nat N).subset hs)\nend\n\nlemma neg_lt_of_tendsto_zero_of_pos {f : ℕ → ℝ} (hf : tendsto f at_top (𝓝 0)) :\n  ∀ {r : ℝ}, 0 < r → (-r : ℝ*) < of_seq f :=\nλ r hr, have hg : _ := hf.neg,\nneg_lt_of_neg_lt (by rw [neg_zero] at hg; exact lt_of_tendsto_zero_of_pos hg hr)\n\nlemma gt_of_tendsto_zero_of_neg {f : ℕ → ℝ} (hf : tendsto f at_top (𝓝 0)) :\n  ∀ {r : ℝ}, r < 0 → (r : ℝ*) < of_seq f :=\nλ r hr, by rw [←neg_neg r, coe_neg];\nexact neg_lt_of_tendsto_zero_of_pos hf (neg_pos.mpr hr)\n\nlemma epsilon_lt_pos (x : ℝ) : 0 < x → ε < x :=\nlt_of_tendsto_zero_of_pos tendsto_inverse_at_top_nhds_0_nat\n\n/-- Standard part predicate -/\ndef is_st (x : ℝ*) (r : ℝ) := ∀ δ : ℝ, 0 < δ → (r - δ : ℝ*) < x ∧ x < r + δ\n\n/-- Standard part function: like a \"round\" to ℝ instead of ℤ -/\nnoncomputable def st : ℝ* → ℝ :=\nλ x, if h : ∃ r, is_st x r then classical.some h else 0\n\n/-- A hyperreal number is infinitesimal if its standard part is 0 -/\ndef infinitesimal (x : ℝ*) := is_st x 0\n\n/-- A hyperreal number is positive infinite if it is larger than all real numbers -/\ndef infinite_pos (x : ℝ*) := ∀ r : ℝ, ↑r < x\n\n/-- A hyperreal number is negative infinite if it is smaller than all real numbers -/\ndef infinite_neg (x : ℝ*) := ∀ r : ℝ, x < r\n\n/-- A hyperreal number is infinite if it is infinite positive or infinite negative -/\ndef infinite (x : ℝ*) := infinite_pos x ∨ infinite_neg x\n\n/-!\n### Some facts about `st`\n-/\n\nprivate lemma is_st_unique' (x : ℝ*) (r s : ℝ) (hr : is_st x r) (hs : is_st x s) (hrs : r < s) :\n  false :=\nhave hrs' : _ := half_pos $ sub_pos_of_lt hrs,\nhave hr' : _ := (hr _ hrs').2,\nhave hs' : _ := (hs _ hrs').1,\nhave h : s - ((s - r) / 2) = r + (s - r) / 2 := by linarith,\nbegin\n  norm_cast at *,\n  rw h at hs',\n  exact not_lt_of_lt hs' hr'\nend\n\ntheorem is_st_unique {x : ℝ*} {r s : ℝ} (hr : is_st x r) (hs : is_st x s) : r = s :=\nbegin\n  rcases lt_trichotomy r s with h | h | h,\n  { exact false.elim (is_st_unique' x r s hr hs h) },\n  { exact h },\n  { exact false.elim (is_st_unique' x s r hs hr h) }\nend\n\ntheorem not_infinite_of_exists_st {x : ℝ*} : (∃ r : ℝ, is_st x r) → ¬ infinite x :=\nλ he hi, Exists.dcases_on he $ λ r hr, hi.elim\n   (λ hip, not_lt_of_lt (hr 2 zero_lt_two).2 (hip $ r + 2))\n   (λ hin, not_lt_of_lt (hr 2 zero_lt_two).1 (hin $ r - 2))\n\ntheorem is_st_Sup {x : ℝ*} (hni : ¬ infinite x) : is_st x (Sup {y : ℝ | (y : ℝ*) < x}) :=\nlet S : set ℝ := {y : ℝ | (y : ℝ*) < x} in\nlet R : _ := Sup S in\nhave hnile : _ := not_forall.mp (not_or_distrib.mp hni).1,\nhave hnige : _ := not_forall.mp (not_or_distrib.mp hni).2,\nExists.dcases_on hnile $ Exists.dcases_on hnige $ λ r₁ hr₁ r₂ hr₂,\nhave HR₁ : ∃ y : ℝ, y ∈ S :=\n  ⟨r₁ - 1, lt_of_lt_of_le (coe_lt_coe.2 $ sub_one_lt _) (not_lt.mp hr₁) ⟩,\nhave HR₂ : ∃ z : ℝ, ∀ y ∈ S, y ≤ z :=\n  ⟨ r₂, λ y hy, le_of_lt (coe_lt_coe.1 (lt_of_lt_of_le hy (not_lt.mp hr₂))) ⟩,\nλ δ hδ,\n  ⟨ lt_of_not_ge' $ λ c,\n      have hc : ∀ y ∈ S, y ≤ R - δ := λ y hy, coe_le_coe.1 $ le_of_lt $ lt_of_lt_of_le hy c,\n      not_lt_of_le ((real.Sup_le _ HR₁ HR₂).mpr hc) $ sub_lt_self R hδ,\n    lt_of_not_ge' $ λ c,\n      have hc : ↑(R + δ / 2) < x :=\n        lt_of_lt_of_le (add_lt_add_left (coe_lt_coe.2 (half_lt_self hδ)) R) c,\n      not_lt_of_le (real.le_Sup _ HR₂ hc) $ (lt_add_iff_pos_right _).mpr $ half_pos hδ⟩\n\ntheorem exists_st_of_not_infinite {x : ℝ*} (hni : ¬ infinite x) : ∃ r : ℝ, is_st x r :=\n⟨Sup {y : ℝ | (y : ℝ*) < x}, is_st_Sup hni⟩\n\ntheorem st_eq_Sup {x : ℝ*} : st x = Sup {y : ℝ | (y : ℝ*) < x} :=\nbegin\nunfold st, split_ifs,\n{ exact is_st_unique (classical.some_spec h) (is_st_Sup (not_infinite_of_exists_st h)) },\n{ cases not_imp_comm.mp exists_st_of_not_infinite h with H H,\n  { rw (set.ext (λ i, ⟨λ hi, set.mem_univ i, λ hi, H i⟩) : {y : ℝ | (y : ℝ*) < x} = set.univ),\n    exact (real.Sup_univ).symm },\n  { rw (set.ext (λ i, ⟨λ hi, false.elim (not_lt_of_lt (H i) hi),\n    λ hi, false.elim (set.not_mem_empty i hi)⟩) : {y : ℝ | (y : ℝ*) < x} = ∅),\n    exact (real.Sup_empty).symm } }\nend\n\ntheorem exists_st_iff_not_infinite {x : ℝ*} : (∃ r : ℝ, is_st x r) ↔ ¬ infinite x :=\n⟨ not_infinite_of_exists_st, exists_st_of_not_infinite ⟩\n\ntheorem infinite_iff_not_exists_st {x : ℝ*} : infinite x ↔ ¬ ∃ r : ℝ, is_st x r :=\niff_not_comm.mp exists_st_iff_not_infinite\n\ntheorem st_infinite {x : ℝ*} (hi : infinite x) : st x = 0 :=\nbegin\n  unfold st, split_ifs,\n  { exact false.elim ((infinite_iff_not_exists_st.mp hi) h) },\n  { refl }\nend\n\nlemma st_of_is_st {x : ℝ*} {r : ℝ} (hxr : is_st x r) : st x = r :=\nbegin\n  unfold st, split_ifs,\n  { exact is_st_unique (classical.some_spec h) hxr },\n  { exact false.elim (h ⟨r, hxr⟩) }\nend\n\nlemma is_st_st_of_is_st {x : ℝ*} {r : ℝ} (hxr : is_st x r) : is_st x (st x) :=\nby rwa [st_of_is_st hxr]\n\nlemma is_st_st_of_exists_st {x : ℝ*} (hx : ∃ r : ℝ, is_st x r) : is_st x (st x) :=\nExists.dcases_on hx (λ r, is_st_st_of_is_st)\n\nlemma is_st_st {x : ℝ*} (hx : st x ≠ 0) : is_st x (st x) :=\nbegin\n  unfold st, split_ifs,\n  { exact classical.some_spec h },\n  { exact false.elim (hx (by unfold st; split_ifs; refl)) }\nend\n\nlemma is_st_st' {x : ℝ*} (hx : ¬ infinite x) : is_st x (st x) :=\nis_st_st_of_exists_st $ exists_st_of_not_infinite hx\n\nlemma is_st_refl_real (r : ℝ) : is_st r r :=\nλ δ hδ, ⟨ sub_lt_self _ (coe_lt_coe.2 hδ), (lt_add_of_pos_right _ (coe_lt_coe.2 hδ)) ⟩\n\nlemma st_id_real (r : ℝ) : st r = r := st_of_is_st (is_st_refl_real r)\n\nlemma eq_of_is_st_real {r s : ℝ} : is_st r s → r = s := is_st_unique (is_st_refl_real r)\n\nlemma is_st_real_iff_eq {r s : ℝ} : is_st r s ↔ r = s :=\n⟨eq_of_is_st_real, λ hrs, by rw [hrs]; exact is_st_refl_real s⟩\n\nlemma is_st_symm_real {r s : ℝ} : is_st r s ↔ is_st s r :=\nby rw [is_st_real_iff_eq, is_st_real_iff_eq, eq_comm]\n\nlemma is_st_trans_real {r s t : ℝ} : is_st r s → is_st s t → is_st r t :=\nby rw [is_st_real_iff_eq, is_st_real_iff_eq, is_st_real_iff_eq]; exact eq.trans\n\nlemma is_st_inj_real {r₁ r₂ s : ℝ} (h1 : is_st r₁ s) (h2 : is_st r₂ s) : r₁ = r₂ :=\neq.trans (eq_of_is_st_real h1) (eq_of_is_st_real h2).symm\n\nlemma is_st_iff_abs_sub_lt_delta {x : ℝ*} {r : ℝ} :\n  is_st x r ↔ ∀ (δ : ℝ), 0 < δ → abs (x - r) < δ :=\nby simp only [abs_sub_lt_iff, @sub_lt _ _ (r : ℝ*) x _,\n    @sub_lt_iff_lt_add' _ _ x (r : ℝ*) _, and_comm]; refl\n\nlemma is_st_add {x y : ℝ*} {r s : ℝ} : is_st x r → is_st y s → is_st (x + y) (r + s) :=\nλ hxr hys d hd,\nhave hxr' : _ := hxr (d / 2) (half_pos hd),\nhave hys' : _ := hys (d / 2) (half_pos hd),\n⟨by convert add_lt_add hxr'.1 hys'.1 using 1; norm_cast; linarith,\n by convert add_lt_add hxr'.2 hys'.2 using 1; norm_cast; linarith⟩\n\nlemma is_st_neg {x : ℝ*} {r : ℝ} (hxr : is_st x r) : is_st (-x) (-r) :=\nλ d hd, by show -(r : ℝ*) - d < -x ∧ -x < -r + d; cases (hxr d hd); split; linarith\n\nlemma is_st_sub {x y : ℝ*} {r s : ℝ} : is_st x r → is_st y s → is_st (x - y) (r - s) :=\nλ hxr hys, by rw [sub_eq_add_neg, sub_eq_add_neg]; exact is_st_add hxr (is_st_neg hys)\n\n/- (st x < st y) → (x < y) → (x ≤ y) → (st x ≤ st y) -/\n\nlemma lt_of_is_st_lt {x y : ℝ*} {r s : ℝ} (hxr : is_st x r) (hys : is_st y s) :\n  r < s → x < y :=\nλ hrs, have hrs' : 0 < (s - r) / 2 := half_pos (sub_pos.mpr hrs),\nhave hxr' : _ := (hxr _ hrs').2, have hys' : _ := (hys _ hrs').1,\nhave H1 : r + ((s - r) / 2) = (r + s) / 2 := by linarith,\nhave H2 : s - ((s - r) / 2) = (r + s) / 2 := by linarith,\nbegin\n  norm_cast at *,\n  rw H1 at hxr',\n  rw H2 at hys',\n  exact lt_trans hxr' hys'\nend\n\nlemma is_st_le_of_le {x y : ℝ*} {r s : ℝ} (hrx : is_st x r) (hsy : is_st y s) :\n  x ≤ y → r ≤ s := by rw [←not_lt, ←not_lt, not_imp_not]; exact lt_of_is_st_lt hsy hrx\n\nlemma st_le_of_le {x y : ℝ*} (hix : ¬ infinite x) (hiy : ¬ infinite y) :\n  x ≤ y → st x ≤ st y :=\nhave hx' : _ := is_st_st' hix, have hy' : _ := is_st_st' hiy,\nis_st_le_of_le hx' hy'\n\nlemma lt_of_st_lt {x y : ℝ*} (hix : ¬ infinite x) (hiy : ¬ infinite y) :\n  st x < st y → x < y :=\nhave hx' : _ := is_st_st' hix, have hy' : _ := is_st_st' hiy,\nlt_of_is_st_lt hx' hy'\n\n/-!\n### Basic lemmas about infinite\n-/\n\nlemma infinite_pos_def {x : ℝ*} : infinite_pos x ↔ ∀ r : ℝ, ↑r < x := by rw iff_eq_eq; refl\n\nlemma infinite_neg_def {x : ℝ*} : infinite_neg x ↔ ∀ r : ℝ, x < r := by rw iff_eq_eq; refl\n\nlemma ne_zero_of_infinite {x : ℝ*} : infinite x → x ≠ 0 :=\nλ hI h0, or.cases_on hI\n  (λ hip, lt_irrefl (0 : ℝ*) ((by rwa ←h0 : infinite_pos 0) 0))\n  (λ hin, lt_irrefl (0 : ℝ*) ((by rwa ←h0 : infinite_neg 0) 0))\n\nlemma not_infinite_zero : ¬ infinite 0 := λ hI, ne_zero_of_infinite hI rfl\n\nlemma pos_of_infinite_pos {x : ℝ*} : infinite_pos x → 0 < x := λ hip, hip 0\n\nlemma neg_of_infinite_neg {x : ℝ*} : infinite_neg x → x < 0 := λ hin, hin 0\n\nlemma not_infinite_pos_of_infinite_neg {x : ℝ*} : infinite_neg x → ¬ infinite_pos x :=\nλ hn hp, not_lt_of_lt (hn 1) (hp 1)\n\nlemma not_infinite_neg_of_infinite_pos {x : ℝ*} : infinite_pos x → ¬ infinite_neg x :=\nimp_not_comm.mp not_infinite_pos_of_infinite_neg\n\nlemma infinite_neg_neg_of_infinite_pos {x : ℝ*} : infinite_pos x → infinite_neg (-x) :=\nλ hp r, neg_lt.mp (hp (-r))\n\nlemma infinite_pos_neg_of_infinite_neg {x : ℝ*} : infinite_neg x → infinite_pos (-x) :=\nλ hp r, lt_neg.mp (hp (-r))\n\nlemma infinite_pos_iff_infinite_neg_neg {x : ℝ*} : infinite_pos x ↔ infinite_neg (-x) :=\n⟨ infinite_neg_neg_of_infinite_pos, λ hin, neg_neg x ▸ infinite_pos_neg_of_infinite_neg hin ⟩\n\nlemma infinite_neg_iff_infinite_pos_neg {x : ℝ*} : infinite_neg x ↔ infinite_pos (-x) :=\n⟨ infinite_pos_neg_of_infinite_neg, λ hin, neg_neg x ▸ infinite_neg_neg_of_infinite_pos hin ⟩\n\nlemma infinite_iff_infinite_neg {x : ℝ*} : infinite x ↔ infinite (-x) :=\n⟨ λ hi, or.cases_on hi\n  (λ hip, or.inr (infinite_neg_neg_of_infinite_pos hip))\n  (λ hin, or.inl (infinite_pos_neg_of_infinite_neg hin)),\n λ hi, or.cases_on hi\n  (λ hipn, or.inr (infinite_neg_iff_infinite_pos_neg.mpr hipn))\n  (λ hinp, or.inl (infinite_pos_iff_infinite_neg_neg.mpr hinp))⟩\n\nlemma not_infinite_of_infinitesimal {x : ℝ*} : infinitesimal x → ¬ infinite x :=\nλ hi hI, have hi' : _ := (hi 2 zero_lt_two), or.dcases_on hI\n  (λ hip, have hip' : _ := hip 2, not_lt_of_lt hip' (by convert hi'.2; exact (zero_add 2).symm))\n  (λ hin, have hin' : _ := hin (-2), not_lt_of_lt hin' (by convert hi'.1; exact (zero_sub 2).symm))\n\n\n\nlemma not_infinitesimal_of_infinite_pos {x : ℝ*} : infinite_pos x → ¬ infinitesimal x :=\nλ hp, not_infinitesimal_of_infinite (or.inl hp)\n\nlemma not_infinitesimal_of_infinite_neg {x : ℝ*} : infinite_neg x → ¬ infinitesimal x :=\nλ hn, not_infinitesimal_of_infinite (or.inr hn)\n\nlemma infinite_pos_iff_infinite_and_pos {x : ℝ*} : infinite_pos x ↔ (infinite x ∧ 0 < x) :=\n⟨ λ hip, ⟨or.inl hip, hip 0⟩,\n  λ ⟨hi, hp⟩, hi.cases_on (λ hip, hip) (λ hin, false.elim (not_lt_of_lt hp (hin 0))) ⟩\n\nlemma infinite_neg_iff_infinite_and_neg {x : ℝ*} : infinite_neg x ↔ (infinite x ∧ x < 0) :=\n⟨ λ hip, ⟨or.inr hip, hip 0⟩,\n  λ ⟨hi, hp⟩, hi.cases_on (λ hin, false.elim (not_lt_of_lt hp (hin 0))) (λ hip, hip) ⟩\n\nlemma infinite_pos_iff_infinite_of_pos {x : ℝ*} (hp : 0 < x) : infinite_pos x ↔ infinite x :=\nby rw [infinite_pos_iff_infinite_and_pos]; exact ⟨λ hI, hI.1, λ hI, ⟨hI, hp⟩⟩\n\nlemma infinite_pos_iff_infinite_of_nonneg {x : ℝ*} (hp : 0 ≤ x) : infinite_pos x ↔ infinite x :=\nor.cases_on (lt_or_eq_of_le hp) (infinite_pos_iff_infinite_of_pos)\n  (λ h, by rw h.symm; exact\n  ⟨λ hIP, false.elim (not_infinite_zero (or.inl hIP)), λ hI, false.elim (not_infinite_zero hI)⟩)\n\nlemma infinite_neg_iff_infinite_of_neg {x : ℝ*} (hn : x < 0) : infinite_neg x ↔ infinite x :=\nby rw [infinite_neg_iff_infinite_and_neg]; exact ⟨λ hI, hI.1, λ hI, ⟨hI, hn⟩⟩\n\nlemma infinite_pos_abs_iff_infinite_abs {x : ℝ*} : infinite_pos (abs x) ↔ infinite (abs x) :=\ninfinite_pos_iff_infinite_of_nonneg (abs_nonneg _)\n\nlemma infinite_iff_infinite_pos_abs {x : ℝ*} : infinite x ↔ infinite_pos (abs x) :=\n⟨ λ hi d, or.cases_on hi\n   (λ hip, by rw [abs_of_pos (hip 0)]; exact hip d)\n   (λ hin, by rw [abs_of_neg (hin 0)]; exact lt_neg.mp (hin (-d))),\n  λ hipa, by { rcases (lt_trichotomy x 0) with h | h | h,\n    { exact or.inr (infinite_neg_iff_infinite_pos_neg.mpr (by rwa abs_of_neg h at hipa)) },\n    { exact false.elim (ne_zero_of_infinite (or.inl (by rw [h]; rwa [h, abs_zero] at hipa)) h) },\n    { exact or.inl (by rwa abs_of_pos h at hipa) } } ⟩\n\nlemma infinite_iff_infinite_abs {x : ℝ*} : infinite x ↔ infinite (abs x) :=\nby rw [←infinite_pos_iff_infinite_of_nonneg (abs_nonneg _), infinite_iff_infinite_pos_abs]\n\nlemma infinite_iff_abs_lt_abs {x : ℝ*} : infinite x ↔ ∀ r : ℝ, (abs r : ℝ*) < abs x :=\n⟨ λ hI r, (coe_abs r) ▸ infinite_iff_infinite_pos_abs.mp hI (abs r),\n  λ hR, or.cases_on (max_choice x (-x))\n  (λ h, or.inl $ λ r, lt_of_le_of_lt (le_abs_self _) (h ▸ (hR r)))\n  (λ h, or.inr $ λ r, neg_lt_neg_iff.mp $ lt_of_le_of_lt (neg_le_abs_self _) (h ▸ (hR r)))⟩\n\nlemma infinite_pos_add_not_infinite_neg {x y : ℝ*} :\n  infinite_pos x → ¬ infinite_neg y → infinite_pos (x + y) :=\nbegin\n  intros hip hnin r,\n  cases not_forall.mp hnin with r₂ hr₂,\n  convert add_lt_add_of_lt_of_le (hip (r + -r₂)) (not_lt.mp hr₂) using 1,\n  simp\nend\n\nlemma not_infinite_neg_add_infinite_pos {x y : ℝ*} :\n  ¬ infinite_neg x → infinite_pos y → infinite_pos (x + y) :=\nλ hx hy, by rw [add_comm]; exact infinite_pos_add_not_infinite_neg hy hx\n\nlemma infinite_neg_add_not_infinite_pos {x y : ℝ*} :\n  infinite_neg x → ¬ infinite_pos y → infinite_neg (x + y) :=\nby rw [@infinite_neg_iff_infinite_pos_neg x, @infinite_pos_iff_infinite_neg_neg y,\n       @infinite_neg_iff_infinite_pos_neg (x + y), neg_add];\nexact infinite_pos_add_not_infinite_neg\n\nlemma not_infinite_pos_add_infinite_neg {x y : ℝ*} :\n  ¬ infinite_pos x → infinite_neg y → infinite_neg (x + y) :=\nλ hx hy, by rw [add_comm]; exact infinite_neg_add_not_infinite_pos hy hx\n\nlemma infinite_pos_add_infinite_pos {x y : ℝ*} :\n  infinite_pos x → infinite_pos y → infinite_pos (x + y) :=\nλ hx hy, infinite_pos_add_not_infinite_neg hx (not_infinite_neg_of_infinite_pos hy)\n\nlemma infinite_neg_add_infinite_neg {x y : ℝ*} :\n  infinite_neg x → infinite_neg y → infinite_neg (x + y) :=\nλ hx hy, infinite_neg_add_not_infinite_pos hx (not_infinite_pos_of_infinite_neg hy)\n\nlemma infinite_pos_add_not_infinite {x y : ℝ*} :\n  infinite_pos x → ¬ infinite y → infinite_pos (x + y) :=\nλ hx hy, infinite_pos_add_not_infinite_neg hx (not_or_distrib.mp hy).2\n\nlemma infinite_neg_add_not_infinite {x y : ℝ*} :\n  infinite_neg x → ¬ infinite y → infinite_neg (x + y) :=\nλ hx hy, infinite_neg_add_not_infinite_pos hx (not_or_distrib.mp hy).1\n\ntheorem infinite_pos_of_tendsto_top {f : ℕ → ℝ} (hf : tendsto f at_top at_top) :\n  infinite_pos (of_seq f) :=\nλ r, have hf' : _ := tendsto_at_top_at_top.mp hf,\nExists.cases_on (hf' (r + 1)) $ λ i hi,\n  have hi' : ∀ (a : ℕ), f a < (r + 1) → a < i :=\n    λ a, by rw [←not_le, ←not_le]; exact not_imp_not.mpr (hi a),\n  have hS : {a : ℕ | r < f a}ᶜ ⊆ {a : ℕ | a ≤ i} :=\n    by simp only [set.compl_set_of, not_lt];\n    exact λ a har, le_of_lt (hi' a (lt_of_le_of_lt har (lt_add_one _))),\n  germ.coe_lt.2 $ mem_hyperfilter_of_finite_compl $\n  (set.finite_le_nat _).subset hS\n\ntheorem infinite_neg_of_tendsto_bot {f : ℕ → ℝ} (hf : tendsto f at_top at_bot) :\n  infinite_neg (of_seq f) :=\nλ r, have hf' : _ := tendsto_at_top_at_bot.mp hf,\nExists.cases_on (hf' (r - 1)) $ λ i hi,\n  have hi' : ∀ (a : ℕ), r - 1 < f a → a < i :=\n    λ a, by rw [←not_le, ←not_le]; exact not_imp_not.mpr (hi a),\n  have hS : {a : ℕ | f a < r}ᶜ ⊆ {a : ℕ | a ≤ i} :=\n    by simp only [set.compl_set_of, not_lt];\n    exact λ a har, le_of_lt (hi' a (lt_of_lt_of_le (sub_one_lt _) har)),\n  germ.coe_lt.2 $ mem_hyperfilter_of_finite_compl $\n  (set.finite_le_nat _).subset hS\n\nlemma not_infinite_neg {x : ℝ*} : ¬ infinite x → ¬ infinite (-x) :=\nnot_imp_not.mpr infinite_iff_infinite_neg.mpr\n\nlemma not_infinite_add {x y : ℝ*} (hx : ¬ infinite x) (hy : ¬ infinite y) :\n  ¬ infinite (x + y) :=\nhave hx' : _ := exists_st_of_not_infinite hx, have hy' : _ := exists_st_of_not_infinite hy,\nExists.cases_on hx' $ Exists.cases_on hy' $\nλ r hr s hs, not_infinite_of_exists_st $ ⟨s + r, is_st_add hs hr⟩\n\ntheorem not_infinite_iff_exist_lt_gt {x : ℝ*} : ¬ infinite x ↔ ∃ r s : ℝ, (r : ℝ*) < x ∧ x < s :=\n⟨ λ hni,\nExists.dcases_on (not_forall.mp (not_or_distrib.mp hni).1) $\nExists.dcases_on (not_forall.mp (not_or_distrib.mp hni).2) $ λ r hr s hs,\nby rw [not_lt] at hr hs; exact ⟨r - 1, s + 1,\n  ⟨ lt_of_lt_of_le (by rw sub_eq_add_neg; norm_num) hr,\n    lt_of_le_of_lt hs (by norm_num)⟩ ⟩,\nλ hrs, Exists.dcases_on hrs $ λ r hr, Exists.dcases_on hr $ λ s hs,\n  not_or_distrib.mpr ⟨not_forall.mpr ⟨s, lt_asymm (hs.2)⟩, not_forall.mpr ⟨r, lt_asymm (hs.1) ⟩⟩⟩\n\ntheorem not_infinite_real (r : ℝ) : ¬ infinite r := by rw not_infinite_iff_exist_lt_gt; exact\n⟨ r - 1, r + 1, coe_lt_coe.2 $ sub_one_lt r, coe_lt_coe.2 $ lt_add_one r⟩\n\ntheorem not_real_of_infinite {x : ℝ*} : infinite x → ∀ r : ℝ, x ≠ r :=\nλ hi r hr,  not_infinite_real r $ @eq.subst _ infinite _ _ hr hi\n\n/-!\n### Facts about `st` that require some infinite machinery\n-/\n\nprivate lemma is_st_mul' {x y : ℝ*} {r s : ℝ} (hxr : is_st x r) (hys : is_st y s) (hs : s ≠ 0) :\n  is_st (x * y) (r * s) :=\nhave hxr' : _ := is_st_iff_abs_sub_lt_delta.mp hxr,\nhave hys' : _ := is_st_iff_abs_sub_lt_delta.mp hys,\nhave h : _ := not_infinite_iff_exist_lt_gt.mp $ not_imp_not.mpr infinite_iff_infinite_abs.mpr $\nnot_infinite_of_exists_st ⟨r, hxr⟩,\nExists.cases_on h $ λ u h', Exists.cases_on h' $ λ t ⟨hu, ht⟩,\nis_st_iff_abs_sub_lt_delta.mpr $ λ d hd,\n   calc abs (x * y - r * s)\n      = abs (x * (y - s) + (x - r) * s) :\n        by rw [mul_sub, sub_mul, add_sub, sub_add_cancel]\n  ... ≤ abs (x * (y - s)) + abs ((x - r) * s) : abs_add _ _\n  ... ≤ abs x * abs (y - s) + abs (x - r) * abs s : by simp only [abs_mul]\n  ... ≤ abs x * ((d / t) / 2 : ℝ) + ((d / abs s) / 2 : ℝ) * abs s : add_le_add\n        (mul_le_mul_of_nonneg_left (le_of_lt $ hys' _ $ half_pos $ div_pos hd $\n          coe_pos.1 $ lt_of_le_of_lt (abs_nonneg x) ht) $ abs_nonneg _)\n        (mul_le_mul_of_nonneg_right (le_of_lt $ hxr' _ $ half_pos $ div_pos hd $\n          abs_pos.2 hs) $ abs_nonneg _)\n  ... = (d / 2 * (abs x / t) + d / 2 : ℝ*) : by\n      { push_cast [-filter.germ.const_div], -- TODO: Why wasn't `hyperreal.coe_div` used?\n        have : (abs s : ℝ*) ≠ 0, by simpa,\n        have : (2 : ℝ*) ≠ 0 := two_ne_zero,\n        field_simp [*, add_mul, mul_add, mul_assoc, mul_comm, mul_left_comm] }\n  ... < (d / 2 * 1 + d / 2 : ℝ*) :\n        add_lt_add_right (mul_lt_mul_of_pos_left\n        ((div_lt_one $ lt_of_le_of_lt (abs_nonneg x) ht).mpr ht) $\n        half_pos $ coe_pos.2 hd) _\n  ... = (d : ℝ*) : by rw [mul_one, add_halves]\n\nlemma is_st_mul {x y : ℝ*} {r s : ℝ} (hxr : is_st x r) (hys : is_st y s) :\n  is_st (x * y) (r * s) :=\nhave h : _ := not_infinite_iff_exist_lt_gt.mp $\n  not_imp_not.mpr infinite_iff_infinite_abs.mpr $ not_infinite_of_exists_st ⟨r, hxr⟩,\nExists.cases_on h $ λ u h', Exists.cases_on h' $ λ t ⟨hu, ht⟩,\nbegin\n  by_cases hs : s = 0,\n  { apply is_st_iff_abs_sub_lt_delta.mpr, intros d hd,\n    have hys' : _ := is_st_iff_abs_sub_lt_delta.mp hys (d / t)\n      (div_pos hd (coe_pos.1 (lt_of_le_of_lt (abs_nonneg x) ht))),\n    rw [hs, coe_zero, sub_zero] at hys',\n    rw [hs, mul_zero, coe_zero, sub_zero, abs_mul, mul_comm,\n        ←div_mul_cancel (d : ℝ*) (ne_of_gt (lt_of_le_of_lt (abs_nonneg x) ht)),\n        ←coe_div],\n    exact mul_lt_mul'' hys' ht (abs_nonneg _) (abs_nonneg _) },\n  exact is_st_mul' hxr hys hs,\nend\n\n--AN INFINITE LEMMA THAT REQUIRES SOME MORE ST MACHINERY\nlemma not_infinite_mul {x y : ℝ*} (hx : ¬ infinite x) (hy : ¬ infinite y) :\n  ¬ infinite (x * y) :=\nhave hx' : _ := exists_st_of_not_infinite hx, have hy' : _ := exists_st_of_not_infinite hy,\nExists.cases_on hx' $ Exists.cases_on hy' $ λ r hr s hs, not_infinite_of_exists_st $\n⟨s * r, is_st_mul hs hr⟩\n---\n\nlemma st_add {x y : ℝ*} (hx : ¬infinite x) (hy : ¬infinite y) : st (x + y) = st x + st y :=\nhave hx' : _ := is_st_st' hx,\nhave hy' : _ := is_st_st' hy,\nhave hxy : _ := is_st_st' (not_infinite_add hx hy),\nhave hxy' : _ := is_st_add hx' hy',\nis_st_unique hxy hxy'\n\nlemma st_neg (x : ℝ*) : st (-x) = - st x :=\nif h : infinite x\nthen by rw [st_infinite h, st_infinite (infinite_iff_infinite_neg.mp h), neg_zero]\nelse is_st_unique (is_st_st' (not_infinite_neg h)) (is_st_neg (is_st_st' h))\n\nlemma st_mul {x y : ℝ*} (hx : ¬infinite x) (hy : ¬infinite y) : st (x * y) = (st x) * (st y) :=\nhave hx' : _ := is_st_st' hx,\nhave hy' : _ := is_st_st' hy,\nhave hxy : _ := is_st_st' (not_infinite_mul hx hy),\nhave hxy' : _ := is_st_mul hx' hy',\nis_st_unique hxy hxy'\n\n/-!\n### Basic lemmas about infinitesimal\n-/\n\ntheorem infinitesimal_def {x : ℝ*} :\n  infinitesimal x ↔ (∀ r : ℝ, 0 < r → -(r : ℝ*) < x ∧ x < r) :=\n⟨ λ hi r hr, by { convert (hi r hr); simp },\n  λ hi d hd, by { convert (hi d hd); simp } ⟩\n\ntheorem lt_of_pos_of_infinitesimal {x : ℝ*} : infinitesimal x → ∀ r : ℝ, 0 < r → x < r :=\nλ hi r hr, ((infinitesimal_def.mp hi) r hr).2\n\ntheorem lt_neg_of_pos_of_infinitesimal {x : ℝ*} : infinitesimal x → ∀ r : ℝ, 0 < r → -↑r < x :=\nλ hi r hr, ((infinitesimal_def.mp hi) r hr).1\n\ntheorem gt_of_neg_of_infinitesimal {x : ℝ*} : infinitesimal x → ∀ r : ℝ, r < 0 → ↑r < x :=\nλ hi r hr, by convert ((infinitesimal_def.mp hi) (-r) (neg_pos.mpr hr)).1;\nexact (neg_neg ↑r).symm\n\ntheorem abs_lt_real_iff_infinitesimal {x : ℝ*} :\n  infinitesimal x ↔ ∀ r : ℝ, r ≠ 0 → abs x < abs r :=\n⟨ λ hi r hr, abs_lt.mpr (by rw ←coe_abs;\n  exact infinitesimal_def.mp hi (abs r) (abs_pos.2 hr)),\n  λ hR, infinitesimal_def.mpr $ λ r hr, abs_lt.mp $\n  (abs_of_pos $ coe_pos.2 hr) ▸ hR r $ ne_of_gt hr ⟩\n\nlemma infinitesimal_zero : infinitesimal 0 := is_st_refl_real 0\n\nlemma zero_of_infinitesimal_real {r : ℝ} : infinitesimal r → r = 0 := eq_of_is_st_real\n\nlemma zero_iff_infinitesimal_real {r : ℝ} : infinitesimal r ↔ r = 0 :=\n⟨zero_of_infinitesimal_real, λ hr, by rw hr; exact infinitesimal_zero⟩\n\nlemma infinitesimal_add {x y : ℝ*} (hx : infinitesimal x) (hy : infinitesimal y) :\n  infinitesimal (x + y) :=\nby simpa only [add_zero] using is_st_add hx hy\n\nlemma infinitesimal_neg {x : ℝ*} (hx : infinitesimal x) : infinitesimal (-x) :=\nby simpa only [neg_zero] using is_st_neg hx\n\nlemma infinitesimal_neg_iff {x : ℝ*} : infinitesimal x ↔ infinitesimal (-x) :=\n⟨infinitesimal_neg, λ h, (neg_neg x) ▸ @infinitesimal_neg (-x) h⟩\n\nlemma infinitesimal_mul {x y : ℝ*} (hx : infinitesimal x) (hy : infinitesimal y) :\n  infinitesimal (x * y) :=\nby simpa only [mul_zero] using is_st_mul hx hy\n\ntheorem infinitesimal_of_tendsto_zero {f : ℕ → ℝ} :\n  tendsto f at_top (𝓝 0) → infinitesimal (of_seq f) :=\nλ hf d hd, by rw [sub_eq_add_neg, ←coe_neg, ←coe_add, ←coe_add, zero_add, zero_add];\nexact ⟨neg_lt_of_tendsto_zero_of_pos hf hd, lt_of_tendsto_zero_of_pos hf hd⟩\n\ntheorem infinitesimal_epsilon : infinitesimal ε :=\ninfinitesimal_of_tendsto_zero tendsto_inverse_at_top_nhds_0_nat\n\nlemma not_real_of_infinitesimal_ne_zero (x : ℝ*) :\n  infinitesimal x → x ≠ 0 → ∀ r : ℝ, x ≠ r :=\nλ hi hx r hr, hx $ hr.trans $ coe_eq_zero.2 $\nis_st_unique (hr.symm ▸ is_st_refl_real r : is_st x r) hi\n\ntheorem infinitesimal_sub_is_st {x : ℝ*} {r : ℝ} (hxr : is_st x r) : infinitesimal (x - r) :=\nshow is_st (x - r) 0,\nby { rw [sub_eq_add_neg, ← add_neg_self r], exact is_st_add hxr (is_st_refl_real (-r)) }\n\ntheorem infinitesimal_sub_st {x : ℝ*} (hx : ¬infinite x) : infinitesimal (x - st x) :=\ninfinitesimal_sub_is_st $ is_st_st' hx\n\nlemma infinite_pos_iff_infinitesimal_inv_pos {x : ℝ*} :\n  infinite_pos x ↔ (infinitesimal x⁻¹ ∧ 0 < x⁻¹) :=\n⟨ λ hip, ⟨ infinitesimal_def.mpr $ λ r hr,\n  ⟨ lt_trans (coe_lt_coe.2 (neg_neg_of_pos hr)) (inv_pos.2 (hip 0)),\n    (inv_lt (coe_lt_coe.2 hr) (hip 0)).mp (by convert hip r⁻¹) ⟩,\n  inv_pos.2 $ hip 0 ⟩,\n  λ ⟨hi, hp⟩ r, @classical.by_cases (r = 0) (↑r < x) (λ h, eq.substr h (inv_pos.mp hp)) $\n  λ h, lt_of_le_of_lt (coe_le_coe.2 (le_abs_self r))\n  ((inv_lt_inv (inv_pos.mp hp) (coe_lt_coe.2 (abs_pos.2 h))).mp\n  ((infinitesimal_def.mp hi) ((abs r)⁻¹) (inv_pos.2 (abs_pos.2 h))).2) ⟩\n\nlemma infinite_neg_iff_infinitesimal_inv_neg {x : ℝ*} :\n  infinite_neg x ↔ (infinitesimal x⁻¹ ∧ x⁻¹ < 0) :=\n⟨ λ hin, have hin' : _ := infinite_pos_iff_infinitesimal_inv_pos.mp\n  (infinite_pos_neg_of_infinite_neg hin),\n  by rwa [infinitesimal_neg_iff, ←neg_pos, neg_inv],\n  λ hin, by rwa [←neg_pos, infinitesimal_neg_iff, neg_inv,\n    ←infinite_pos_iff_infinitesimal_inv_pos, ←infinite_neg_iff_infinite_pos_neg] at hin ⟩\n\ntheorem infinitesimal_inv_of_infinite {x : ℝ*} : infinite x → infinitesimal x⁻¹ :=\nλ hi, or.cases_on hi\n (λ hip, (infinite_pos_iff_infinitesimal_inv_pos.mp hip).1)\n (λ hin, (infinite_neg_iff_infinitesimal_inv_neg.mp hin).1)\n\ntheorem infinite_of_infinitesimal_inv {x : ℝ*} (h0 : x ≠ 0) (hi : infinitesimal x⁻¹ ) :\n  infinite x :=\nbegin\n  cases (lt_or_gt_of_ne h0) with hn hp,\n  { exact or.inr (infinite_neg_iff_infinitesimal_inv_neg.mpr ⟨hi, inv_lt_zero.mpr hn⟩) },\n  { exact or.inl (infinite_pos_iff_infinitesimal_inv_pos.mpr ⟨hi, inv_pos.mpr hp⟩) }\nend\n\ntheorem infinite_iff_infinitesimal_inv {x : ℝ*} (h0 : x ≠ 0) : infinite x ↔ infinitesimal x⁻¹ :=\n⟨ infinitesimal_inv_of_infinite, infinite_of_infinitesimal_inv h0 ⟩\n\nlemma infinitesimal_pos_iff_infinite_pos_inv {x : ℝ*} :\n  infinite_pos x⁻¹ ↔ (infinitesimal x ∧ 0 < x) :=\nby convert infinite_pos_iff_infinitesimal_inv_pos; simp only [inv_inv']\n\nlemma infinitesimal_neg_iff_infinite_neg_inv {x : ℝ*} :\n  infinite_neg x⁻¹ ↔ (infinitesimal x ∧ x < 0) :=\nby convert infinite_neg_iff_infinitesimal_inv_neg; simp only [inv_inv']\n\ntheorem infinitesimal_iff_infinite_inv {x : ℝ*} (h : x ≠ 0) : infinitesimal x ↔ infinite x⁻¹ :=\nby convert (infinite_iff_infinitesimal_inv (inv_ne_zero h)).symm; simp only [inv_inv']\n\n/-!\n### `st` stuff that requires infinitesimal machinery\n-/\n\ntheorem is_st_of_tendsto {f : ℕ → ℝ} {r : ℝ} (hf : tendsto f at_top (𝓝 r)) :\n  is_st (of_seq f) r :=\nhave hg : tendsto (λ n, f n - r) at_top (𝓝 0) :=\n  (sub_self r) ▸ (hf.sub tendsto_const_nhds),\nby rw [←(zero_add r), ←(sub_add_cancel f (λ n, r))];\nexact is_st_add (infinitesimal_of_tendsto_zero hg) (is_st_refl_real r)\n\nlemma is_st_inv {x : ℝ*} {r : ℝ} (hi : ¬ infinitesimal x) : is_st x r → is_st x⁻¹ r⁻¹ :=\nλ hxr, have h : x ≠ 0 := (λ h, hi (h.symm ▸ infinitesimal_zero)),\nhave H : _ := exists_st_of_not_infinite $ not_imp_not.mpr (infinitesimal_iff_infinite_inv h).mpr hi,\nExists.cases_on H $ λ s hs,\nhave H' : is_st 1 (r * s) := mul_inv_cancel h ▸ is_st_mul hxr hs,\nhave H'' : s = r⁻¹ := one_div r ▸ eq_one_div_of_mul_eq_one (eq_of_is_st_real H').symm,\nH'' ▸ hs\n\nlemma st_inv (x : ℝ*) : st x⁻¹ = (st x)⁻¹ :=\nbegin\n  by_cases h0 : x = 0,\n  rw [h0, inv_zero, ←coe_zero, st_id_real, inv_zero],\n  by_cases h1 : infinitesimal x,\n  rw [st_infinite ((infinitesimal_iff_infinite_inv h0).mp h1), st_of_is_st h1, inv_zero],\n  by_cases h2 : infinite x,\n  rw [st_of_is_st (infinitesimal_inv_of_infinite h2), st_infinite h2, inv_zero],\n  exact st_of_is_st (is_st_inv h1 (is_st_st' h2)),\nend\n\n/-!\n### Infinite stuff that requires infinitesimal machinery\n-/\n\nlemma infinite_pos_omega : infinite_pos ω :=\ninfinite_pos_iff_infinitesimal_inv_pos.mpr ⟨infinitesimal_epsilon, epsilon_pos⟩\n\nlemma infinite_omega : infinite ω :=\n(infinite_iff_infinitesimal_inv omega_ne_zero).mpr infinitesimal_epsilon\n\nlemma infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos {x y : ℝ*} :\n  infinite_pos x → ¬ infinitesimal y → 0 < y → infinite_pos (x * y) :=\nλ hx hy₁ hy₂ r, have hy₁' : _ := not_forall.mp (by rw infinitesimal_def at hy₁; exact hy₁),\nExists.dcases_on hy₁' $ λ r₁ hy₁'',\nhave hyr : _ := by rw [not_imp, ←abs_lt, not_lt, abs_of_pos hy₂] at hy₁''; exact hy₁'',\nby rw [←div_mul_cancel r (ne_of_gt hyr.1), coe_mul];\nexact mul_lt_mul (hx (r / r₁)) hyr.2 (coe_lt_coe.2 hyr.1) (le_of_lt (hx 0))\n\nlemma infinite_pos_mul_of_not_infinitesimal_pos_infinite_pos {x y : ℝ*} :\n  ¬ infinitesimal x → 0 < x → infinite_pos y → infinite_pos (x * y) :=\nλ hx hp hy, by rw mul_comm; exact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos hy hx hp\n\nlemma infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg {x y : ℝ*} :\n  infinite_neg x → ¬ infinitesimal y → y < 0 → infinite_pos (x * y) :=\nby rw [infinite_neg_iff_infinite_pos_neg, ←neg_pos, ←neg_mul_neg, infinitesimal_neg_iff];\nexact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos\n\nlemma infinite_pos_mul_of_not_infinitesimal_neg_infinite_neg {x y : ℝ*} :\n  ¬ infinitesimal x → x < 0 → infinite_neg y → infinite_pos (x * y) :=\nλ hx hp hy, by rw mul_comm; exact infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg hy hx hp\n\nlemma infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg {x y : ℝ*} :\n  infinite_pos x → ¬ infinitesimal y → y < 0 → infinite_neg (x * y) :=\nby rw [infinite_neg_iff_infinite_pos_neg, ←neg_pos, neg_mul_eq_mul_neg, infinitesimal_neg_iff];\nexact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos\n\nlemma infinite_neg_mul_of_not_infinitesimal_neg_infinite_pos {x y : ℝ*} :\n  ¬ infinitesimal x → x < 0 → infinite_pos y → infinite_neg (x * y) :=\nλ hx hp hy, by rw mul_comm; exact infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg hy hx hp\n\nlemma infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos {x y : ℝ*} :\n  infinite_neg x → ¬ infinitesimal y → 0 < y → infinite_neg (x * y) :=\nby rw [infinite_neg_iff_infinite_pos_neg, infinite_neg_iff_infinite_pos_neg, neg_mul_eq_neg_mul];\nexact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos\n\nlemma infinite_neg_mul_of_not_infinitesimal_pos_infinite_neg {x y : ℝ*} :\n  ¬ infinitesimal x → 0 < x → infinite_neg y → infinite_neg (x * y) :=\nλ hx hp hy, by rw mul_comm; exact infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos hy hx hp\n\nlemma infinite_pos_mul_infinite_pos {x y : ℝ*} :\n  infinite_pos x → infinite_pos y → infinite_pos (x * y) :=\nλ hx hy, infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos\nhx (not_infinitesimal_of_infinite_pos hy) (hy 0)\n\nlemma infinite_neg_mul_infinite_neg {x y : ℝ*} :\n  infinite_neg x → infinite_neg y → infinite_pos (x * y) :=\nλ hx hy, infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg\nhx (not_infinitesimal_of_infinite_neg hy) (hy 0)\n\nlemma infinite_pos_mul_infinite_neg {x y : ℝ*} :\n  infinite_pos x → infinite_neg y → infinite_neg (x * y) :=\nλ hx hy, infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg\nhx (not_infinitesimal_of_infinite_neg hy) (hy 0)\n\nlemma infinite_neg_mul_infinite_pos {x y : ℝ*} :\n  infinite_neg x → infinite_pos y → infinite_neg (x * y) :=\nλ hx hy, infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos\nhx (not_infinitesimal_of_infinite_pos hy) (hy 0)\n\nlemma infinite_mul_of_infinite_not_infinitesimal {x y : ℝ*} :\n  infinite x → ¬ infinitesimal y → infinite (x * y) :=\nλ hx hy, have h0 : y < 0 ∨ 0 < y := lt_or_gt_of_ne (λ H0, hy (eq.substr H0 (is_st_refl_real 0))),\nor.dcases_on hx\n  (or.dcases_on h0\n    (λ H0 Hx, or.inr (infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg Hx hy H0))\n    (λ H0 Hx, or.inl (infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos Hx hy H0)))\n  (or.dcases_on h0\n    (λ H0 Hx, or.inl (infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg Hx hy H0))\n    (λ H0 Hx, or.inr (infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos Hx hy H0)))\n\nlemma infinite_mul_of_not_infinitesimal_infinite {x y : ℝ*} :\n  ¬ infinitesimal x → infinite y → infinite (x * y) :=\nλ hx hy, by rw [mul_comm]; exact infinite_mul_of_infinite_not_infinitesimal hy hx\n\nlemma infinite_mul_infinite {x y : ℝ*} : infinite x → infinite y → infinite (x * y) :=\nλ hx hy, infinite_mul_of_infinite_not_infinitesimal hx (not_infinitesimal_of_infinite hy)\n\nend hyperreal\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/real/hyperreal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.4852508308079917}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Johan Commelin, Mario Carneiro\n\nMultivariate Polynomial\n-/\nimport algebra.ring\nimport data.finsupp data.polynomial data.equiv.algebra\n\nopen set function finsupp lattice\n\nuniverses u v w x\nvariables {α : Type u} {β : Type v} {γ : Type w} {δ : Type x}\n\n/-- Multivariate polynomial, where `σ` is the index set of the variables and\n  `α` is the coefficient ring -/\ndef mv_polynomial (σ : Type*) (α : Type*) [comm_semiring α] := (σ →₀ ℕ) →₀ α\n\nnamespace mv_polynomial\nvariables {σ : Type*} {a a' a₁ a₂ : α} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}\nvariables [decidable_eq σ] [decidable_eq α]\n\nsection comm_semiring\nvariables [comm_semiring α] {p q : mv_polynomial σ α}\n\ninstance : decidable_eq (mv_polynomial σ α) := finsupp.decidable_eq\ninstance : has_zero (mv_polynomial σ α) := finsupp.has_zero\ninstance : has_one (mv_polynomial σ α) := finsupp.has_one\ninstance : has_add (mv_polynomial σ α) := finsupp.has_add\ninstance : has_mul (mv_polynomial σ α) := finsupp.has_mul\ninstance : comm_semiring (mv_polynomial σ α) := finsupp.to_comm_semiring\n\n/-- `monomial s a` is the monomial `a * X^s` -/\ndef monomial (s : σ →₀ ℕ) (a : α) : mv_polynomial σ α := single s a\n\n/-- `C a` is the constant polynomial with value `a` -/\ndef C (a : α) : mv_polynomial σ α := monomial 0 a\n\n/-- `X n` is the polynomial with value X_n -/\ndef X (n : σ) : mv_polynomial σ α := monomial (single n 1) 1\n\n@[simp] lemma C_0 : C 0 = (0 : mv_polynomial σ α) := by simp [C, monomial]; refl\n\n@[simp] lemma C_1 : C 1 = (1 : mv_polynomial σ α) := rfl\n\nlemma C_mul_monomial : C a * monomial s a' = monomial s (a * a') :=\nby simp [C, monomial, single_mul_single]\n\n@[simp] lemma C_add : (C (a + a') : mv_polynomial σ α) = C a + C a' := single_add\n\n@[simp] lemma C_mul : (C (a * a') : mv_polynomial σ α) = C a * C a' := C_mul_monomial.symm\n\ninstance : is_semiring_hom (C : α → mv_polynomial σ α) :=\n{ map_zero := C_0,\n  map_one := C_1,\n  map_add := λ a a', C_add,\n  map_mul := λ a a', C_mul }\n\nlemma X_pow_eq_single : X n ^ e = monomial (single n e) (1 : α) :=\nbegin\n  induction e,\n  { simp [X], refl },\n  { simp [pow_succ, e_ih],\n    simp [X, monomial, single_mul_single, nat.succ_eq_add_one] }\nend\n\nlemma monomial_add_single : monomial (s + single n e) a = (monomial s a * X n ^ e):=\nby rw [X_pow_eq_single, monomial, monomial, monomial, single_mul_single]; simp\n\nlemma monomial_single_add : monomial (single n e + s) a = (X n ^ e * monomial s a):=\nby rw [X_pow_eq_single, monomial, monomial, monomial, single_mul_single]; simp\n\nlemma monomial_eq : monomial s a = C a * (s.prod $ λn e, X n ^ e : mv_polynomial σ α) :=\nbegin\n  apply @finsupp.induction σ ℕ _ _ _ _ s,\n  { simp [C, prod_zero_index]; exact (mul_one _).symm },\n  { assume n e s hns he ih,\n    simp [prod_add_index, prod_single_index, pow_zero, pow_add, (mul_assoc _ _ _).symm, ih.symm,\n      monomial_add_single] }\nend\n\n@[recursor 7]\nlemma induction_on {M : mv_polynomial σ α → Prop} (p : mv_polynomial σ α)\n  (h_C : ∀a, M (C a)) (h_add : ∀p q, M p → M q → M (p + q)) (h_X : ∀p n, M p → M (p * X n)) :\n  M p :=\nhave ∀s a, M (monomial s a),\nbegin\n  assume s a,\n  apply @finsupp.induction σ ℕ _ _ _ _ s,\n  { show M (monomial 0 a), from h_C a, },\n  { assume n e p hpn he ih,\n    have : ∀e:ℕ, M (monomial p a * X n ^ e),\n    { intro e,\n      induction e,\n      { simp [ih] },\n      { simp [ih, pow_succ', (mul_assoc _ _ _).symm, h_X, e_ih] } },\n    simp [monomial_add_single, this] }\nend,\nfinsupp.induction p\n  (by have : M (C 0) := h_C 0; rwa [C_0] at this)\n  (assume s a p hsp ha hp, h_add _ _ (this s a) hp)\n\nlemma hom_eq_hom [semiring γ]\n  (f g : mv_polynomial σ α → γ) (hf : is_semiring_hom f) (hg : is_semiring_hom g)\n  (hC : ∀a:α, f (C a) = g (C a)) (hX : ∀n:σ, f (X n) = g (X n)) (p : mv_polynomial σ α) :\n  f p = g p :=\nmv_polynomial.induction_on p hC\n  begin assume p q hp hq, rw [is_semiring_hom.map_add f, is_semiring_hom.map_add g, hp, hq] end\n  begin assume p n hp, rw [is_semiring_hom.map_mul f, is_semiring_hom.map_mul g, hp, hX] end\n\nlemma is_id (f : mv_polynomial σ α → mv_polynomial σ α) (hf : is_semiring_hom f)\n  (hC : ∀a:α, f (C a) = (C a)) (hX : ∀n:σ, f (X n) = (X n)) (p : mv_polynomial σ α) :\n  f p = p :=\nhom_eq_hom f id hf is_semiring_hom.id hC hX p\n\nsection eval₂\nvariables [comm_semiring β]\nvariables (f : α → β) (g : σ → β)\n\n/-- Evaluate a polynomial `p` given a valuation `g` of all the variables\n  and a ring hom `f` from the scalar ring to the target -/\ndef eval₂ (p : mv_polynomial σ α) : β :=\np.sum (λs a, f a * s.prod (λn e, g n ^ e))\n\n@[simp] lemma eval₂_zero : (0 : mv_polynomial σ α).eval₂ f g = 0 :=\nfinsupp.sum_zero_index\n\nvariables [is_semiring_hom f]\n\n@[simp] lemma eval₂_add : (p + q).eval₂ f g = p.eval₂ f g + q.eval₂ f g :=\nfinsupp.sum_add_index\n  (by simp [is_semiring_hom.map_zero f])\n  (by simp [add_mul, is_semiring_hom.map_add f])\n\n@[simp] lemma eval₂_monomial : (monomial s a).eval₂ f g = f a * s.prod (λn e, g n ^ e) :=\nfinsupp.sum_single_index (by simp [is_semiring_hom.map_zero f])\n\n@[simp] lemma eval₂_C (a) : (C a).eval₂ f g = f a :=\nby simp [eval₂_monomial, C, prod_zero_index]\n\n@[simp] lemma eval₂_one : (1 : mv_polynomial σ α).eval₂ f g = 1 :=\n(eval₂_C _ _ _).trans (is_semiring_hom.map_one f)\n\n@[simp] lemma eval₂_X (n) : (X n).eval₂ f g = g n :=\nby simp [eval₂_monomial,\n  is_semiring_hom.map_one f, X, prod_single_index, pow_one]\n\nlemma eval₂_mul_monomial :\n  ∀{s a}, (p * monomial s a).eval₂ f g = p.eval₂ f g * f a * s.prod (λn e, g n ^ e) :=\nbegin\n  apply mv_polynomial.induction_on p,\n  { assume a' s a,\n    simp [C_mul_monomial, eval₂_monomial, is_semiring_hom.map_mul f] },\n  { assume p q ih_p ih_q, simp [add_mul, eval₂_add, ih_p, ih_q] },\n  { assume p n ih s a,\n    from calc (p * X n * monomial s a).eval₂ f g = (p * monomial (single n 1 + s) a).eval₂ f g :\n        by simp [monomial_single_add, -add_comm, pow_one, mul_assoc]\n      ... = (p * monomial (single n 1) 1).eval₂ f g * f a * s.prod (λn e, g n ^ e) :\n        by simp [ih, prod_single_index, prod_add_index, pow_one, pow_add, mul_assoc, mul_left_comm,\n          is_semiring_hom.map_one f, -add_comm] }\nend\n\nlemma eval₂_mul : ∀{p}, (p * q).eval₂ f g = p.eval₂ f g * q.eval₂ f g :=\nbegin\n  apply mv_polynomial.induction_on q,\n  { simp [C, eval₂_monomial, eval₂_mul_monomial, prod_zero_index] },\n  { simp [mul_add, eval₂_add] {contextual := tt} },\n  { simp [X, eval₂_monomial, eval₂_mul_monomial, (mul_assoc _ _ _).symm] { contextual := tt} }\nend\n\nlemma eval₂_pow {p:mv_polynomial σ α} : ∀{n:ℕ}, (p ^ n).eval₂ f g = (p.eval₂ f g)^n\n| 0       := eval₂_one _ _\n| (n + 1) := by rw [pow_add, pow_one, pow_add, pow_one, eval₂_mul, eval₂_pow]\n\ninstance eval₂.is_semiring_hom : is_semiring_hom (eval₂ f g) :=\n{ map_zero := eval₂_zero _ _,\n  map_one := eval₂_one _ _,\n  map_add := λ p q, eval₂_add _ _,\n  map_mul := λ p q, eval₂_mul _ _ }\n\nlemma eval₂_comp_left {γ} [comm_semiring γ]\n  (k : β → γ) [is_semiring_hom k]\n  (f : α → β) [is_semiring_hom f] (g : σ → β)\n  (p) : k (eval₂ f g p) = eval₂ (k ∘ f) (k ∘ g) p :=\nby apply mv_polynomial.induction_on p; simp [\n  eval₂_add, is_semiring_hom.map_add k,\n  eval₂_mul, is_semiring_hom.map_mul k] {contextual := tt}\n\nlemma eval₂_eta (p : mv_polynomial σ α) : eval₂ C X p = p :=\nby apply mv_polynomial.induction_on p;\n   simp [eval₂_add, eval₂_mul] {contextual := tt}\n\nend eval₂\n\nsection eval\nvariables {f : σ → α}\n\n/-- Evaluate a polynomial `p` given a valuation `f` of all the variables -/\ndef eval (f : σ → α) : mv_polynomial σ α → α := eval₂ id f\n\n@[simp] lemma eval_zero : (0 : mv_polynomial σ α).eval f = 0 := eval₂_zero _ _\n\n@[simp] lemma eval_add : (p + q).eval f = p.eval f + q.eval f := eval₂_add _ _\n\nlemma eval_monomial : (monomial s a).eval f = a * s.prod (λn e, f n ^ e) :=\neval₂_monomial _ _\n\n@[simp] lemma eval_C : ∀ a, (C a).eval f = a := eval₂_C _ _\n\n@[simp] lemma eval_X : ∀ n, (X n).eval f = f n := eval₂_X _ _\n\n@[simp] lemma eval_mul : (p * q).eval f = p.eval f * q.eval f := eval₂_mul _ _\n\ninstance eval.is_semiring_hom : is_semiring_hom (eval f) :=\neval₂.is_semiring_hom _ _\n\ntheorem eval_assoc {τ} [decidable_eq τ]\n  (f : σ → mv_polynomial τ α) (g : τ → α)\n  (p : mv_polynomial σ α) :\n  p.eval (eval g ∘ f) = (eval₂ C f p).eval g :=\nbegin\n  rw eval₂_comp_left (eval g),\n  unfold eval, congr; funext a; simp\nend\n\nend eval\n\nsection map\nvariables [comm_semiring β] [decidable_eq β]\nvariables (f : α → β) [is_semiring_hom f]\n\n/-- `map f p` maps a polynomial `p` across a ring hom `f` -/\ndef map : mv_polynomial σ α → mv_polynomial σ β := eval₂ (C ∘ f) X\n\n@[simp] theorem map_monomial (s : σ →₀ ℕ) (a : α) : map f (monomial s a) = monomial s (f a) :=\n(eval₂_monomial _ _).trans monomial_eq.symm\n\n@[simp] theorem map_C : ∀ (a : α), map f (C a : mv_polynomial σ α) = C (f a) := map_monomial _ _\n\n@[simp] theorem map_X : ∀ (n : σ), map f (X n : mv_polynomial σ α) = X n := eval₂_X _ _\n\n@[simp] theorem map_one : map f (1 : mv_polynomial σ α) = 1 := eval₂_one _ _\n\n@[simp] theorem map_add (p q : mv_polynomial σ α) :\n  map f (p + q) = map f p + map f q := eval₂_add _ _\n\n@[simp] theorem map_mul (p q : mv_polynomial σ α) :\n  map f (p * q) = map f p * map f q := eval₂_mul _ _\n\ninstance map.is_semiring_hom :\n  is_semiring_hom (map f : mv_polynomial σ α → mv_polynomial σ β) :=\neval₂.is_semiring_hom _ _\n\ntheorem map_id : ∀ (p : mv_polynomial σ α), map id p = p := eval₂_eta\n\ntheorem map_map [comm_semiring γ] [decidable_eq γ]\n  (g : β → γ) [is_semiring_hom g]\n  (p : mv_polynomial σ α) :\n  map g (map f p) = map (g ∘ f) p :=\n(eval₂_comp_left (map g) (C ∘ f) X p).trans $\nby congr; funext a; simp\n\ntheorem eval₂_eq_eval_map (g : σ → β) (p : mv_polynomial σ α) :\n  p.eval₂ f g = (map f p).eval g :=\nbegin\n  unfold map eval,\n  rw eval₂_comp_left (eval₂ id g),\n  congr; funext a; simp\nend\n\nend map\n\nsection degrees\n\nsection comm_semiring\n\ndef degrees (p : mv_polynomial σ α) : multiset σ :=\np.support.sup (λs:σ →₀ ℕ, s.to_multiset)\n\nlemma degrees_monomial (s : σ →₀ ℕ) (a : α) : degrees (monomial s a) ≤ s.to_multiset :=\nfinset.sup_le $ assume t h,\nbegin\n  have := finsupp.support_single_subset h,\n  rw [finset.singleton_eq_singleton, finset.mem_singleton] at this,\n  rw this\nend\n\nlemma degrees_monomial_eq (s : σ →₀ ℕ) (a : α) (ha : a ≠ 0) :\n  degrees (monomial s a) = s.to_multiset :=\nle_antisymm (degrees_monomial s a) $ finset.le_sup $\n  by rw [monomial, finsupp.support_single_ne_zero ha,\n    finset.singleton_eq_singleton, finset.mem_singleton]\n\nlemma degrees_C (a : α) : degrees (C a : mv_polynomial σ α) = 0 :=\nmultiset.le_zero.1 $ degrees_monomial _ _\n\nlemma degrees_X (n : σ) : degrees (X n : mv_polynomial σ α) ≤ {n} :=\nle_trans (degrees_monomial _ _) $ le_of_eq $ to_multiset_single _ _\n\nlemma degrees_zero : degrees (0 : mv_polynomial σ α) = 0 := degrees_C 0\n\nlemma degrees_one : degrees (1 : mv_polynomial σ α) = 0 := degrees_C 1\n\nlemma degrees_add (p q : mv_polynomial σ α) : (p + q).degrees ≤ p.degrees ⊔ q.degrees :=\nbegin\n  refine finset.sup_le (assume b hb, _),\n  cases finset.mem_union.1 (finsupp.support_add hb),\n  { exact le_sup_left_of_le (finset.le_sup h) },\n  { exact le_sup_right_of_le (finset.le_sup h) },\nend\n\nlemma degrees_sum {ι : Type*} [decidable_eq ι] (s : finset ι) (f : ι → mv_polynomial σ α) :\n  (s.sum f).degrees ≤ s.sup (λi, (f i).degrees) :=\nbegin\n  refine s.induction _ _,\n  { simp only [finset.sum_empty, finset.sup_empty, degrees_zero], exact le_refl _ },\n  { assume i s his ih,\n    rw [finset.sup_insert, finset.sum_insert his],\n    exact le_trans (degrees_add _ _) (sup_le_sup_left ih _) }\nend\n\nlemma degrees_mul (p q : mv_polynomial σ α) : (p * q).degrees ≤ p.degrees + q.degrees :=\nbegin\n  refine finset.sup_le (assume b hb, _),\n  have := support_mul p q hb,\n  simp only [finset.mem_bind, finset.singleton_eq_singleton, finset.mem_singleton] at this,\n  rcases this with ⟨a₁, h₁, a₂, h₂, rfl⟩,\n  rw [finsupp.to_multiset_add],\n  exact add_le_add (finset.le_sup h₁) (finset.le_sup h₂)\nend\n\nlemma degrees_prod {ι : Type*} [decidable_eq ι] (s : finset ι) (f : ι → mv_polynomial σ α) :\n  (s.prod f).degrees ≤ s.sum (λi, (f i).degrees) :=\nbegin\n  refine s.induction _ _,\n  { simp only [finset.prod_empty, finset.sum_empty, degrees_one] },\n  { assume i s his ih,\n    rw [finset.prod_insert his, finset.sum_insert his],\n    exact le_trans (degrees_mul _ _) (add_le_add_left ih _) }\nend\n\nlemma degrees_pow (p : mv_polynomial σ α) :\n  ∀(n : ℕ), (p^n).degrees ≤ add_monoid.smul n p.degrees\n| 0       := begin rw [pow_zero, degrees_one], exact multiset.zero_le _ end\n| (n + 1) := le_trans (degrees_mul _ _) (add_le_add_left (degrees_pow n) _)\n\nend comm_semiring\n\nend degrees\n\nsection vars\n\n/-- `vars p` is the set of variables appearing in the polynomial `p` -/\ndef vars (p : mv_polynomial σ α) : finset σ := p.degrees.to_finset\n\n@[simp] lemma vars_0 : (0 : mv_polynomial σ α).vars = ∅ :=\nby rw [vars, degrees_zero, multiset.to_finset_zero]\n\n@[simp] lemma vars_monomial (h : a ≠ 0) : (monomial s a).vars = s.support :=\nby rw [vars, degrees_monomial_eq _ _ h, finsupp.to_finset_to_multiset]\n\n@[simp] lemma vars_C : (C a : mv_polynomial σ α).vars = ∅ :=\nby rw [vars, degrees_C, multiset.to_finset_zero]\n\n@[simp] lemma vars_X (h : 0 ≠ (1 : α)) : (X n : mv_polynomial σ α).vars = {n} :=\nby rw [X, vars_monomial h.symm, finsupp.support_single_ne_zero zero_ne_one.symm]\n\nend vars\n\nsection degree_of\n\n/-- `degree_of n p` gives the highest power of X_n that appears in `p` -/\ndef degree_of (n : σ) (p : mv_polynomial σ α) : ℕ := p.degrees.count n\n\nend degree_of\n\nsection total_degree\n/-- `total_degree p` gives the maximum |s| over the monomials X^s in `p` -/\ndef total_degree (p : mv_polynomial σ α) : ℕ := p.support.sup (λs, s.sum $ λn e, e)\n\nlemma total_degree_eq (p : mv_polynomial σ α) :\n  p.total_degree = p.support.sup (λm, m.to_multiset.card) :=\nbegin\n  rw [total_degree],\n  congr, funext m,\n  exact (finsupp.card_to_multiset _).symm\nend\n\nlemma total_degree_le_degrees_card (p : mv_polynomial σ α) :\n  p.total_degree ≤ p.degrees.card :=\nbegin\n  rw [total_degree_eq],\n  exact finset.sup_le (assume s hs, multiset.card_le_of_le $ finset.le_sup hs)\nend\n\nlemma total_degree_C (a : α) : (C a : mv_polynomial σ α).total_degree = 0 :=\nnat.eq_zero_of_le_zero $ finset.sup_le $ assume n hn,\n  have _ := finsupp.support_single_subset hn,\n  begin\n    rw [finset.singleton_eq_singleton, finset.mem_singleton] at this,\n    subst this,\n    exact le_refl _\n  end\n\nlemma total_degree_zero : (0 : mv_polynomial σ α).total_degree = 0 :=\nby rw [← C_0]; exact total_degree_C (0 : α)\n\nlemma total_degree_one : (1 : mv_polynomial σ α).total_degree = 0 :=\ntotal_degree_C (1 : α)\n\nlemma total_degree_add (a b : mv_polynomial σ α) :\n  (a + b).total_degree ≤ max a.total_degree b.total_degree :=\nfinset.sup_le $ assume n hn,\n  have _ := finsupp.support_add hn,\n  begin\n    rcases finset.mem_union.1 this,\n    { exact le_max_left_of_le (finset.le_sup h) },\n    { exact le_max_right_of_le (finset.le_sup h) }\n  end\n\nlemma total_degree_mul (a b : mv_polynomial σ α) :\n  (a * b).total_degree ≤ a.total_degree + b.total_degree :=\nfinset.sup_le $ assume n hn,\n  have _ := finsupp.support_mul a b hn,\n  begin\n    simp only [finset.mem_bind, finset.mem_singleton, finset.singleton_eq_singleton] at this,\n    rcases this with ⟨a₁, h₁, a₂, h₂, rfl⟩,\n    rw [finsupp.sum_add_index],\n    { exact add_le_add (finset.le_sup h₁) (finset.le_sup h₂) },\n    { assume a, refl },\n    { assume a b₁ b₂, refl }\n  end\n\nlemma total_degree_list_prod :\n  ∀(s : list (mv_polynomial σ α)), s.prod.total_degree ≤ (s.map mv_polynomial.total_degree).sum\n| []        := by rw [@list.prod_nil (mv_polynomial σ α) _, total_degree_one]; refl\n| (p :: ps) :=\n  begin\n    rw [@list.prod_cons (mv_polynomial σ α) _, list.map, list.sum_cons],\n    exact le_trans (total_degree_mul _ _) (add_le_add_left (total_degree_list_prod ps) _)\n  end\n\nlemma total_degree_multiset_prod (s : multiset (mv_polynomial σ α)) :\n  s.prod.total_degree ≤ (s.map mv_polynomial.total_degree).sum :=\nbegin\n  refine quotient.induction_on s (assume l, _),\n  rw [multiset.quot_mk_to_coe, multiset.coe_prod, multiset.coe_map, multiset.coe_sum],\n  exact total_degree_list_prod l\nend\n\nlemma total_degree_finset_prod {ι : Type*}\n  (s : finset ι) (f : ι → mv_polynomial σ α) :\n  (s.prod f).total_degree ≤ s.sum (λi, (f i).total_degree) :=\nbegin\n  refine le_trans (total_degree_multiset_prod _) _,\n  rw [multiset.map_map],\n  refl\nend\n\nend total_degree\n\nend comm_semiring\n\nsection comm_ring\nvariable [comm_ring α]\nvariables {p q : mv_polynomial σ α}\n\ninstance : ring (mv_polynomial σ α) := finsupp.to_ring\ninstance : comm_ring (mv_polynomial σ α) := finsupp.to_comm_ring\ninstance : has_scalar α (mv_polynomial σ α) := finsupp.to_has_scalar\ninstance : module α (mv_polynomial σ α) := finsupp.to_module _ α\n\ninstance C.is_ring_hom : is_ring_hom (C : α → mv_polynomial σ α) :=\nby apply is_ring_hom.of_semiring\n\nvariables (σ a a')\nlemma C_sub : (C (a - a') : mv_polynomial σ α) = C a - C a' := is_ring_hom.map_sub _\n\n@[simp] lemma C_neg : (C (-a) : mv_polynomial σ α) = -C a := is_ring_hom.map_neg _\n\nvariables {σ} (p)\ntheorem C_mul' : mv_polynomial.C a * p = a • p :=\nbegin\n  apply finsupp.induction p,\n  { exact (mul_zero $ mv_polynomial.C a).trans (@smul_zero α (mv_polynomial σ α) _ _ _ a).symm },\n  intros p b f haf hb0 ih,\n  rw [mul_add, ih, @smul_add α (mv_polynomial σ α) _ _ _ a], congr' 1,\n  rw [finsupp.mul_def, finsupp.smul_single, mv_polynomial.C, mv_polynomial.monomial],\n  rw [finsupp.sum_single_index, finsupp.sum_single_index, zero_add, smul_eq_mul],\n  { rw [mul_zero, finsupp.single_zero] },\n  { rw finsupp.sum_single_index,\n    all_goals { rw [zero_mul, finsupp.single_zero] } }\nend\n\nlemma smul_eq_C_mul (p : mv_polynomial σ α) (a : α) : a • p = C a * p :=\nbegin\n  rw [← finsupp.sum_single p, @finsupp.smul_sum (σ →₀ ℕ) α α, finsupp.mul_sum],\n  refine finset.sum_congr rfl (assume n _, _),\n  simp only [finsupp.smul_single],\n  exact C_mul_monomial.symm\nend\n\n@[simp] lemma smul_eval (x) (p : mv_polynomial σ α) (s) : (s • p).eval x = s * p.eval x :=\nby rw [smul_eq_C_mul, eval_mul, eval_C]\n\nsection degrees\n\nlemma degrees_neg [comm_ring α] (p : mv_polynomial σ α) : (- p).degrees = p.degrees :=\nby rw [degrees, finsupp.support_neg]; refl\n\nlemma degrees_sub [comm_ring α] (p q : mv_polynomial σ α) :\n  (p - q).degrees ≤ p.degrees ⊔ q.degrees :=\nle_trans (degrees_add p (-q)) $ by rw [degrees_neg]\n\nend degrees\n\nsection eval₂\n\nvariables [comm_ring β]\nvariables (f : α → β) [is_ring_hom f] (g : σ → β)\n\ninstance eval₂.is_ring_hom : is_ring_hom (eval₂ f g) :=\nby apply is_ring_hom.of_semiring\n\nlemma eval₂_sub : (p - q).eval₂ f g = p.eval₂ f g - q.eval₂ f g := is_ring_hom.map_sub _\n\n@[simp] lemma eval₂_neg : (-p).eval₂ f g = -(p.eval₂ f g) := is_ring_hom.map_neg _\n\nend eval₂\n\nsection eval\n\nvariables (f : σ → α)\n\ninstance eval.is_ring_hom : is_ring_hom (eval f) := eval₂.is_ring_hom _ _\n\nlemma eval_sub : (p - q).eval f = p.eval f - q.eval f := is_ring_hom.map_sub _\n\n@[simp] lemma eval_neg : (-p).eval f = -(p.eval f) := is_ring_hom.map_neg _\n\nend eval\n\nsection map\n\nvariables [decidable_eq β] [comm_ring β]\nvariables (f : α → β) [is_ring_hom f]\n\ninstance map.is_ring_hom : is_ring_hom (map f : mv_polynomial σ α → mv_polynomial σ β) :=\neval₂.is_ring_hom _ _\n\nlemma map_sub : (p - q).map f = p.map f - q.map f := is_ring_hom.map_sub _\n\n@[simp] lemma map_neg : (-p).map f = -(p.map f) := is_ring_hom.map_neg _\n\nend map\n\nend comm_ring\n\nsection rename\nvariables {α} [comm_semiring α] [decidable_eq α] [decidable_eq β] [decidable_eq γ] [decidable_eq δ]\n\ndef rename (f : β → γ) : mv_polynomial β α → mv_polynomial γ α :=\neval₂ C (X ∘ f)\n\ninstance rename.is_semiring_hom (f : β → γ) :\n  is_semiring_hom (rename f : mv_polynomial β α → mv_polynomial γ α) :=\nby unfold rename; apply_instance\n\n@[simp] lemma rename_C (f : β → γ) (a : α) : rename f (C a) = C a :=\neval₂_C _ _ _\n\n@[simp] lemma rename_X (f : β → γ) (b : β) : rename f (X b : mv_polynomial β α) = X (f b) :=\neval₂_X _ _ _\n\nlemma rename_rename (f : β → γ) (g : γ → δ) (p : mv_polynomial β α) :\n  rename g (rename f p) = rename (g ∘ f) p :=\nshow rename g (eval₂ C (X ∘ f) p) = _,\n  by simp only [eval₂_comp_left (rename g) C (X ∘ f) p, (∘), rename_C, rename_X]; refl\n\nlemma rename_id (p : mv_polynomial β α) : rename id p = p :=\neval₂_eta p\n\nlemma rename_monomial (f : β → γ) (p : β →₀ ℕ) (a : α) :\n  rename f (monomial p a) = monomial (p.map_domain f) a :=\nbegin\n  rw [rename, eval₂_monomial, monomial_eq, finsupp.prod_map_domain_index],\n  { exact assume n, pow_zero _ },\n  { exact assume n i₁ i₂, pow_add _ _ _ }\nend\n\nlemma rename_eq (f : β → γ) (p : mv_polynomial β α) :\n  rename f p = finsupp.map_domain (finsupp.map_domain f) p :=\nbegin\n  simp only [rename, eval₂, finsupp.map_domain],\n  congr, ext s a : 2,\n  rw [← monomial, monomial_eq, finsupp.prod_sum_index],\n  congr, ext n i : 2,\n  rw [finsupp.prod_single_index],\n  exact pow_zero _,\n  exact assume a, pow_zero _,\n  exact assume a b c, pow_add _ _ _\nend\n\nlemma injective_rename (f : β → γ) (hf : function.injective f) :\n  function.injective (rename f : mv_polynomial β α → mv_polynomial γ α) :=\nhave (rename f : mv_polynomial β α → mv_polynomial γ α) =\n  finsupp.map_domain (finsupp.map_domain f) := funext (rename_eq f),\nbegin\n  rw this,\n  exact finsupp.injective_map_domain (finsupp.injective_map_domain hf)\nend\n\nlemma total_degree_rename_le (f : β → γ) (p : mv_polynomial β α) :\n  (p.rename f).total_degree ≤ p.total_degree :=\nfinset.sup_le $ assume b,\n  begin\n    assume h,\n    rw rename_eq at h,\n    have h' := finsupp.map_domain_support h,\n    rcases finset.mem_image.1 h' with ⟨s, hs, rfl⟩,\n    rw finsupp.sum_map_domain_index,\n    exact le_trans (le_refl _) (finset.le_sup hs),\n    exact assume _, rfl,\n    exact assume _ _ _, rfl\n  end\n\nend rename\n\ninstance rename.is_ring_hom\n  {α} [comm_ring α] [decidable_eq α] [decidable_eq β] [decidable_eq γ] (f : β → γ) :\n  is_ring_hom (rename f : mv_polynomial β α → mv_polynomial γ α) :=\n@is_ring_hom.of_semiring (mv_polynomial β α) (mv_polynomial γ α) _ _ (rename f)\n  (rename.is_semiring_hom f)\n\nsection equiv\n\nvariables (α) [comm_ring α]\nvariables [decidable_eq β] [decidable_eq γ] [decidable_eq δ]\n\ndef pempty_ring_equiv : mv_polynomial pempty α ≃r α :=\n{ to_fun    := mv_polynomial.eval₂ id $ pempty.elim,\n  inv_fun   := C,\n  left_inv  := is_id _ (by apply_instance) (assume a, by rw [eval₂_C]; refl) (assume a, a.elim),\n  right_inv := λ r, eval₂_C _ _ _,\n  hom       := eval₂.is_ring_hom _ _ }\n\ndef punit_ring_equiv : mv_polynomial punit α ≃r polynomial α :=\n{ to_fun    := eval₂ polynomial.C (λu:punit, polynomial.X),\n  inv_fun   := polynomial.eval₂ mv_polynomial.C (X punit.star),\n  left_inv  :=\n    begin\n      refine is_id _ _ _ _,\n      apply is_semiring_hom.comp (eval₂ polynomial.C (λu:punit, polynomial.X)) _; apply_instance,\n      { assume a, rw [eval₂_C, polynomial.eval₂_C] },\n      { rintros ⟨⟩, rw [eval₂_X, polynomial.eval₂_X] }\n    end,\n  right_inv := assume p, polynomial.induction_on p\n    (assume a, by rw [polynomial.eval₂_C, mv_polynomial.eval₂_C])\n    (assume p q hp hq, by rw [polynomial.eval₂_add, mv_polynomial.eval₂_add, hp, hq])\n    (assume p n hp,\n      by rw [polynomial.eval₂_mul, polynomial.eval₂_pow, polynomial.eval₂_X, polynomial.eval₂_C,\n        eval₂_mul, eval₂_C, eval₂_pow, eval₂_X]),\n  hom       := eval₂.is_ring_hom _ _ }\n\ndef ring_equiv_of_equiv (e : β ≃ γ) : mv_polynomial β α ≃r mv_polynomial γ α :=\n{ to_fun    := rename e,\n  inv_fun   := rename e.symm,\n  left_inv  := λ p, by simp only [rename_rename, (∘), e.symm_apply_apply]; exact rename_id p,\n  right_inv := λ p, by simp only [rename_rename, (∘), e.apply_symm_apply]; exact rename_id p,\n  hom       := rename.is_ring_hom e }\n\ndef ring_equiv_congr [comm_ring γ] (e : α ≃r γ) : mv_polynomial β α ≃r mv_polynomial β γ :=\n{ to_fun    := map e.to_fun,\n  inv_fun   := map e.symm.to_fun,\n  left_inv  := assume p,\n    have (e.symm.to_equiv.to_fun ∘ e.to_equiv.to_fun) = id,\n    { ext a, exact e.to_equiv.symm_apply_apply a },\n    by simp only [map_map, this, map_id],\n  right_inv := assume p,\n    have (e.to_equiv.to_fun ∘ e.symm.to_equiv.to_fun) = id,\n    { ext a, exact e.to_equiv.apply_symm_apply a },\n    by simp only [map_map, this, map_id],\n  hom       := map.is_ring_hom e.to_fun }\n\nsection\nvariables (β γ δ)\n\ninstance ring_on_sum : ring (mv_polynomial (β ⊕ γ) α) := by apply_instance\ninstance ring_on_iter : ring (mv_polynomial β (mv_polynomial γ α)) := by apply_instance\n\ndef sum_to_iter : mv_polynomial (β ⊕ γ) α → mv_polynomial β (mv_polynomial γ α) :=\neval₂ (C ∘ C) (λbc, sum.rec_on bc X (C ∘ X))\n\ninstance is_semiring_hom_C_C :\n  is_semiring_hom (C ∘ C : α → mv_polynomial β (mv_polynomial γ α)) :=\n@is_semiring_hom.comp _ _ _ _ C mv_polynomial.is_semiring_hom _ _ C mv_polynomial.is_semiring_hom\n\ninstance is_semiring_hom_sum_to_iter : is_semiring_hom (sum_to_iter α β γ) :=\neval₂.is_semiring_hom _ _\n\nlemma sum_to_iter_C (a : α) : sum_to_iter α β γ (C a) = C (C a) :=\neval₂_C _ _ a\n\nlemma sum_to_iter_Xl (b : β) : sum_to_iter α β γ (X (sum.inl b)) = X b :=\neval₂_X _ _ (sum.inl b)\n\nlemma sum_to_iter_Xr (c : γ) : sum_to_iter α β γ (X (sum.inr c)) = C (X c) :=\neval₂_X _ _ (sum.inr c)\n\ndef iter_to_sum : mv_polynomial β (mv_polynomial γ α) → mv_polynomial (β ⊕ γ) α :=\neval₂ (eval₂ C (X ∘ sum.inr)) (X ∘ sum.inl)\n\nsection\n\ninstance is_semiring_hom_iter_to_sum : is_semiring_hom (iter_to_sum α β γ) :=\neval₂.is_semiring_hom _ _\n\nend\n\nlemma iter_to_sum_C_C (a : α) : iter_to_sum α β γ (C (C a)) = C a :=\neq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _)\n\nlemma iter_to_sum_X (b : β) : iter_to_sum α β γ (X b) = X (sum.inl b) :=\neval₂_X _ _ _\n\nlemma iter_to_sum_C_X (c : γ) : iter_to_sum α β γ (C (X c)) = X (sum.inr c) :=\neq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _)\n\ndef mv_polynomial_equiv_mv_polynomial [comm_ring δ]\n  (f : mv_polynomial β α → mv_polynomial γ δ) (hf : is_semiring_hom f)\n  (g : mv_polynomial γ δ → mv_polynomial β α) (hg : is_semiring_hom g)\n  (hfgC : ∀a, f (g (C a)) = C a)\n  (hfgX : ∀n, f (g (X n)) = X n)\n  (hgfC : ∀a, g (f (C a)) = C a)\n  (hgfX : ∀n, g (f (X n)) = X n) :\n  mv_polynomial β α ≃r mv_polynomial γ δ :=\n{ to_fun    := f, inv_fun := g,\n  left_inv  := is_id _ (is_semiring_hom.comp _ _) hgfC hgfX,\n  right_inv := is_id _ (is_semiring_hom.comp _ _) hfgC hfgX,\n  hom       := is_ring_hom.of_semiring f }\n\ndef sum_ring_equiv : mv_polynomial (β ⊕ γ) α ≃r mv_polynomial β (mv_polynomial γ α) :=\nbegin\n  apply @mv_polynomial_equiv_mv_polynomial α (β ⊕ γ) _ _ _ _ _ _ _ _\n    (sum_to_iter α β γ) _ (iter_to_sum α β γ) _,\n  { assume p,\n    apply @hom_eq_hom _ _ _ _ _ _ _ _ _ _ _ _ _ p,\n    apply_instance,\n    { apply @is_semiring_hom.comp _ _ _ _ _ _ _ _ _ _,\n      apply_instance,\n      apply @is_semiring_hom.comp _ _ _ _ _ _ _ _ _ _,\n      apply_instance,\n      { apply @mv_polynomial.is_semiring_hom },\n      { apply mv_polynomial.is_semiring_hom_iter_to_sum α β γ },\n      { apply mv_polynomial.is_semiring_hom_sum_to_iter α β γ } },\n    { apply mv_polynomial.is_semiring_hom },\n    { assume a, rw [iter_to_sum_C_C α β γ, sum_to_iter_C α β γ] },\n    { assume c, rw [iter_to_sum_C_X α β γ, sum_to_iter_Xr α β γ] } },\n  { assume b, rw [iter_to_sum_X α β γ, sum_to_iter_Xl α β γ] },\n  { assume a, rw [sum_to_iter_C α β γ, iter_to_sum_C_C α β γ] },\n  { assume n, cases n with b c,\n    { rw [sum_to_iter_Xl, iter_to_sum_X] },\n    { rw [sum_to_iter_Xr, iter_to_sum_C_X] } },\n  { apply mv_polynomial.is_semiring_hom_sum_to_iter α β γ },\n  { apply mv_polynomial.is_semiring_hom_iter_to_sum α β γ }\nend\n\ninstance option_ring : ring (mv_polynomial (option β) α) :=\nmv_polynomial.ring\n\ninstance polynomial_ring : ring (polynomial (mv_polynomial β α)) :=\n@comm_ring.to_ring _ polynomial.comm_ring\n\ninstance polynomial_ring2 : ring (mv_polynomial β (polynomial α)) :=\nby apply_instance\n\ndef option_equiv_left : mv_polynomial (option β) α ≃r polynomial (mv_polynomial β α) :=\n(ring_equiv_of_equiv α $ (equiv.option_equiv_sum_punit β).trans (equiv.sum_comm _ _)).trans $\n(sum_ring_equiv α _ _).trans $\npunit_ring_equiv _\n\ndef option_equiv_right : mv_polynomial (option β) α ≃r mv_polynomial β (polynomial α) :=\n(ring_equiv_of_equiv α $ equiv.option_equiv_sum_punit.{0} β).trans $\n(sum_ring_equiv α β unit).trans $\nring_equiv_congr (mv_polynomial unit α) (punit_ring_equiv α)\n\nend\n\nend equiv\n\nend mv_polynomial\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/data/mv_polynomial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4852508267839529}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.terminal\nimport Mathlib.category_theory.limits.shapes.pullbacks\nimport Mathlib.category_theory.limits.shapes.binary_products\nimport Mathlib.PostPort\n\nuniverses v u \n\nnamespace Mathlib\n\n/-!\n# Constructing binary product from pullbacks and terminal object.\n\nIf a category has pullbacks and a terminal object, then it has binary products.\n\nTODO: provide the dual result.\n-/\n\n/-- Any category with pullbacks and terminal object has binary products. -/\n-- This is not an instance, as it is not always how one wants to construct binary products!\n\ntheorem has_binary_products_of_terminal_and_pullbacks (C : Type u) [𝒞 : category_theory.category C]\n    [category_theory.limits.has_terminal C] [category_theory.limits.has_pullbacks C] :\n    category_theory.limits.has_binary_products C :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/constructions/binary_products_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867873410141, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4850287133143728}}
{"text": "/-\nThe organization of information in the memory.\n-/\nimport starkware.cairo.lean.semantics.air_encoding.memory_aux\nimport starkware.cairo.lean.semantics.air_encoding.constraints\n\nnoncomputable theory\nopen_locale classical\nopen_locale big_operators\n\n/- the data -/\n\nvariables {F : Type*}\n\nvariable  {T : ℕ}    -- the number of steps in the execution\n\nvariable  {rc_len : ℕ}  -- the number of range-checked elements for the range-check builtin\n\nvariables {pc       inst\n           dst_addr dst\n           op0_addr op0\n           op1_addr op1  : fin T → F}\n\nvariables {rc_addr rc_val : fin rc_len → F}\n\nvariables {mem_star : F → option F}\n\nvariables {n : ℕ}\n\nvariables {a v a' v' p   : fin (n + 1) → F}\n\nvariables {embed_inst\n           embed_dst\n           embed_op0\n           embed_op1     : fin T → fin (n + 1)}\n\nvariables {embed_rc      : fin rc_len → fin (n + 1)}\n\nvariables {embed_mem     : mem_dom mem_star → fin (n + 1)}\n\nvariables {alpha z : F}\n\n/- the assumptions and constraints -/\n\nvariables [field F] [fintype F]\n\nvariable h_continuity :\n  ∀ i : fin n, (a' i.succ - a' i.cast_succ) * (a' i.succ - a' i.cast_succ - 1) = 0\n\nvariable h_single_valued :\n  ∀ i : fin n, (v' i.succ - v' i.cast_succ) * (a' i.succ - a' i.cast_succ - 1) = 0\n\nvariable h_initial : (z - (a' 0 + alpha * v' 0)) * p 0 = z - (a 0 + alpha * v 0)\n\nvariable h_cumulative : ∀ i : fin n, (z - (a' i.succ + alpha * v' i.succ)) * p i.succ =\n                                       (z - (a i.succ + alpha * v i.succ)) * p i.cast_succ\n\nvariable h_final : p (fin.last n) * ∏ a : mem_dom mem_star, (z - (a.val + alpha * mem_val a)) =\n    z^(fintype.card (mem_dom mem_star))\n\nvariable h_embed_pc       : ∀ i, a (embed_inst i) = pc i\nvariable h_embed_inst     : ∀ i, v (embed_inst i) = inst i\nvariable h_embed_dst_addr : ∀ i, a (embed_dst i)  = dst_addr i\nvariable h_embed_dst      : ∀ i, v (embed_dst i)  = dst i\nvariable h_embed_op0_addr : ∀ i, a (embed_op0 i)  = op0_addr i\nvariable h_embed_op0      : ∀ i, v (embed_op0 i)  = op0 i\nvariable h_embed_op1_addr : ∀ i, a (embed_op1 i)  = op1_addr i\nvariable h_embed_op1      : ∀ i, v (embed_op1 i)  = op1 i\n\nvariable h_embed_rc_addr  : ∀ i, a (embed_rc i)   = rc_addr i\nvariable h_embed_rc_val   : ∀ i, v (embed_rc i)   = rc_val i\n\nvariable h_embed_dom      : ∀ i, a (embed_mem i) = 0\nvariable h_embed_val      : ∀ i, v (embed_mem i) = 0\n\nvariable h_embed_mem_inj       : function.injective embed_mem\nvariable h_embed_mem_disj_inst : ∀ i j, embed_mem i ≠ embed_inst j\nvariable h_embed_mem_disj_dst  : ∀ i j, embed_mem i ≠ embed_dst j\nvariable h_embed_mem_disj_op0  : ∀ i j, embed_mem i ≠ embed_op0 j\nvariable h_embed_mem_disj_op1  : ∀ i j, embed_mem i ≠ embed_op1 j\nvariable h_embed_mem_disj_rc   : ∀ i j, embed_mem i ≠ embed_rc j\n\n/-\nThe memory.\n-/\n\ndef mem (a' v' : fin (n + 1) → F) : F → F :=\nλ addr, if h : ∃ i, a' i = addr then v' (classical.some h) else 0\n\n/-\nRecovering the real a and v arrays from mem_star and the trace version in which\nthose values have been replaced by (0, 0) pairs.\n-/\n\ndef real_a (mem_star : F → option F) (a : fin (n + 1) → F)\n    (embed_mem : mem_dom mem_star → fin (n + 1)) :\n  fin (n + 1) → F :=\nλ i, if h : ∃ addr, embed_mem addr = i then (classical.some h).val else a i\n\ndef real_v (mem_star : F → option F) (v : fin (n + 1) → F)\n    (embed_mem : mem_dom mem_star → fin (n + 1)) :\n  fin (n + 1) → F :=\nλ i, if h : ∃ addr, embed_mem addr = i then mem_val (classical.some h) else v i\n\n/-\nRequires messing around with finite products. Needs the fact that `embed_mem` is injective.\n-/\n\nsection\ninclude h_embed_mem_inj h_embed_dom h_embed_val\n\nlemma real_prod_eq :\n  let ra := real_a mem_star a embed_mem,\n      rv := real_v mem_star v embed_mem in\n  (∏ i, (z - (ra i + alpha * rv i))) * z^(fintype.card (mem_dom mem_star)) =\n    (∏ i, (z - (a i + alpha * v i))) *\n      ∏ a : mem_dom mem_star, (z - (a.val + alpha * mem_val a)) :=\nbegin\n  dsimp,\n  let s := finset.image embed_mem finset.univ,\n  rw [←finset.prod_sdiff (finset.subset_univ s), ←finset.prod_sdiff (finset.subset_univ s),\n        mul_right_comm _ _ (z ^ _)],\n  congr' 2,\n  { apply finset.prod_congr rfl,\n    intro i, rw finset.mem_sdiff, rintros ⟨_, nsi⟩,\n    simp [-not_exists, finset.mem_image] at nsi,\n    rw [real_a, real_v], dsimp, rw [dif_neg nsi, dif_neg nsi] },\n  { rw [finset.prod_image (λ x _ y _ h, @h_embed_mem_inj x y h), fintype.card, ←finset.prod_const],\n    apply finset.prod_congr rfl,\n    intros i _, dsimp,\n    rw [h_embed_dom, h_embed_val, zero_add, mul_zero, sub_zero] },\n  rw [finset.prod_image (λ x _ y _ h, @h_embed_mem_inj x y h)],\n  apply finset.prod_congr rfl,\n  intros i _, dsimp,\n  have h : ∃ addr, embed_mem addr = embed_mem i := ⟨i, rfl⟩,\n  have h' : classical.some h = i := h_embed_mem_inj (classical.some_spec h),\n  rw [real_a, real_v], dsimp, rw [dif_pos h, dif_pos h, mem_val],\n  congr; exact h'\nend\nend\n\n/-\nMoving from `a`, `v` to `real_a`, `real_v` preserves the pairs we care about.\n-/\n\nsection\ninclude h_embed_pc h_embed_mem_disj_inst\n\nlemma real_a_embed_inst (i : fin T) : real_a mem_star a embed_mem (embed_inst i) = pc i :=\nbegin\n  rw [real_a], dsimp, rw [dif_neg, h_embed_pc],\n  apply not_exists_of_forall_not, intro j,\n  apply h_embed_mem_disj_inst\nend\n\nend\n\nsection\ninclude h_embed_inst h_embed_mem_disj_inst\n\nlemma real_v_embed_inst (i : fin T) : real_v mem_star v embed_mem (embed_inst i) = inst i :=\nbegin\n  rw [real_v], dsimp, rw [dif_neg, h_embed_inst],\n  apply not_exists_of_forall_not, intro j,\n  apply h_embed_mem_disj_inst\nend\n\nend\n\n-- because these are so uniform, we can use the same proofs\n\nlemma real_a_embed_dst (i : fin T) : real_a mem_star a embed_mem (embed_dst i) = dst_addr i :=\nreal_a_embed_inst h_embed_dst_addr h_embed_mem_disj_dst i\n\nlemma real_v_embed_dst (i : fin T) : real_v mem_star v embed_mem (embed_dst i) = dst i :=\nreal_v_embed_inst h_embed_dst h_embed_mem_disj_dst i\n\nlemma real_a_embed_op0 (i : fin T) : real_a mem_star a embed_mem (embed_op0 i) = op0_addr i :=\nreal_a_embed_inst h_embed_op0_addr h_embed_mem_disj_op0 i\n\nlemma real_v_embed_op0 (i : fin T) : real_v mem_star v embed_mem (embed_op0 i) = op0 i :=\nreal_v_embed_inst h_embed_op0 h_embed_mem_disj_op0 i\n\nlemma real_a_embed_op1 (i : fin T) : real_a mem_star a embed_mem (embed_op1 i) = op1_addr i :=\nreal_a_embed_inst h_embed_op1_addr h_embed_mem_disj_op1 i\n\nlemma real_v_embed_op1 (i : fin T) : real_v mem_star v embed_mem (embed_op1 i) = op1 i :=\nreal_v_embed_inst h_embed_op1 h_embed_mem_disj_op1 i\n\nsection\ninclude h_embed_rc_addr h_embed_mem_disj_rc\n\nlemma real_a_embed_rc (i : fin rc_len) :\n  real_a mem_star a embed_mem (embed_rc i) = rc_addr i :=\nbegin\n  rw [real_a], dsimp, rw [dif_neg, h_embed_rc_addr],\n  apply not_exists_of_forall_not, intro j,\n  apply h_embed_mem_disj_rc\nend\n\nend\n\nsection\ninclude h_embed_rc_val h_embed_mem_disj_rc\n\nlemma real_v_embed_rc (i : fin rc_len) : real_v mem_star v embed_mem (embed_rc i) = rc_val i :=\nbegin\n  rw [real_v], dsimp, rw [dif_neg, h_embed_rc_val],\n  apply not_exists_of_forall_not, intro j,\n  apply h_embed_mem_disj_rc\nend\n\nend\n\nsection\n\nvariable h_z_ne_zero : z ≠ 0\n\ninclude h_initial h_cumulative h_final h_embed_mem_inj h_embed_dom h_embed_val h_z_ne_zero\n\nlemma real_permutation_prod_eq :\n  let ra := real_a mem_star a embed_mem,\n      rv := real_v mem_star v embed_mem in\n  (∏ i, (z - (ra i + alpha * rv i))) = (∏ i, (z - (a' i + alpha * v' i))) :=\nbegin\n  let ra := real_a mem_star a embed_mem,\n  let rv := real_v mem_star v embed_mem,\n  suffices : (∏ i, (z - (ra i + alpha * rv i))) * z^(fintype.card (mem_dom mem_star)) =\n               (∏ i, (z - (a' i + alpha * v' i))) * z^(fintype.card (mem_dom mem_star)),\n    from mul_right_cancel₀ (pow_ne_zero _ h_z_ne_zero) this,\n  have := real_prod_eq h_embed_dom h_embed_val h_embed_mem_inj ,\n  dsimp [-subtype.val_eq_coe] at this, rw this,\n  rw [←fin.range_last, ←fin.succ_last, permutation_aux h_initial h_cumulative,\n    mul_assoc, h_final]\nend\n\nvariable hprob₁ : alpha ∉\n  bad_set_1 (real_a mem_star a embed_mem) (real_v mem_star v embed_mem) a' v'\n\nvariable hprob₂ : z ∉\n  bad_set_2 (real_a mem_star a embed_mem) (real_v mem_star v embed_mem) a' v' alpha\n\nlemma real_perm :\n  ∀ i, ∃ j, real_v mem_star v embed_mem i = v' j ∧\n            real_a mem_star a embed_mem i = a' j :=\nlet ra := real_a mem_star a embed_mem,\n    rv := real_v mem_star v embed_mem in\nhave h : ∏ (i : fin (n + 1)), (z - (ra i + alpha * rv i)) =\n          ∏ (i : fin (n + 1)), (z - (a' i + alpha * v' i)) :=\n    real_permutation_prod_eq h_initial h_cumulative h_final h_embed_dom h_embed_val h_embed_mem_inj\n      h_z_ne_zero,\npermutation hprob₁ hprob₂ h\n\nlemma real_perm' :\n  ∀ i, ∃ j, v' i = real_v mem_star v embed_mem j ∧\n            a' i = real_a mem_star a embed_mem j :=\nlet ra := real_a mem_star a embed_mem,\n    rv := real_v mem_star v embed_mem in\nhave h : ∏ (i : fin (n + 1)), (z - (ra i + alpha * rv i)) =\n          ∏ (i : fin (n + 1)), (z - (a' i + alpha * v' i)) :=\n    real_permutation_prod_eq h_initial h_cumulative h_final h_embed_dom h_embed_val h_embed_mem_inj\n      h_z_ne_zero,\npermutation' hprob₁ hprob₂ h\n\nvariable h_char_lt : n < ring_char F\n\ninclude h_continuity h_single_valued hprob₁ hprob₂ h_char_lt\n\nlemma real_a_single_valued :\n  let ra := real_a mem_star a embed_mem,\n      rv := real_v mem_star v embed_mem in\n  ∀ i i', ra i = ra i' → rv i = rv i' :=\nbegin\n  dsimp,\n  intros i i' aieq,\n  let ra := real_a mem_star a embed_mem,\n  let rv := real_v mem_star v embed_mem,\n  have h : ∏ (i : fin (n + 1)), (z - (ra i + alpha * rv i)) =\n             ∏ (i : fin (n + 1)), (z - (a' i + alpha * v' i)) :=\n    real_permutation_prod_eq h_initial h_cumulative h_final h_embed_dom h_embed_val h_embed_mem_inj\n      h_z_ne_zero,\n  have perm := permutation hprob₁ hprob₂ h,\n  rcases perm i with ⟨j, veq, aeq⟩,\n  rcases perm i' with ⟨j', veq', aeq'⟩,\n  rw [veq, veq'],\n  apply a'_single_valued h_continuity h_single_valued h_char_lt,\n  rw [←aeq, ←aeq', aieq]\nend\n\nlemma mem_unique (i : fin (n + 1)) :\n  mem a' v' (real_a mem_star a embed_mem i) = real_v mem_star v embed_mem i :=\nbegin\n  have perm := real_perm h_initial h_cumulative h_final h_embed_dom h_embed_val h_embed_mem_inj\n    h_z_ne_zero hprob₁ hprob₂,\n  rcases perm i with ⟨i', v'eq, a'eq⟩,\n  have h : ∃ i', a' i' = real_a mem_star a embed_mem i := ⟨i', a'eq.symm⟩,\n  rw [mem], dsimp, rw [dif_pos h],\n  rw v'eq,\n  apply a'_single_valued h_continuity h_single_valued h_char_lt,\n  exact (classical.some_spec h).trans a'eq\nend\n\nsection\ninclude h_embed_pc h_embed_inst h_embed_mem_disj_inst\n\ntheorem mem_pc (i : fin T) : mem a' v' (pc i) = inst i :=\nbegin\n  rw [←@real_a_embed_inst _ T pc mem_star _ a embed_inst embed_mem _ _ h_embed_pc\n          h_embed_mem_disj_inst],\n  rw [←@real_v_embed_inst _ T inst mem_star _ v embed_inst embed_mem _ _\n          h_embed_inst h_embed_mem_disj_inst],\n  apply mem_unique h_continuity h_single_valued h_initial h_cumulative h_final h_embed_dom\n    h_embed_val h_embed_mem_inj h_z_ne_zero hprob₁ hprob₂ h_char_lt\nend\nend\n\ntheorem mem_dst_addr (i : fin T) : mem a' v' (dst_addr i) = dst i :=\nmem_pc h_continuity h_single_valued h_initial h_cumulative h_final h_embed_dst_addr h_embed_dst\n  h_embed_dom h_embed_val h_embed_mem_inj h_embed_mem_disj_dst h_z_ne_zero hprob₁ hprob₂ h_char_lt i\n\ntheorem mem_op0_addr (i : fin T) : mem a' v' (op0_addr i) = op0 i :=\nmem_pc h_continuity h_single_valued h_initial h_cumulative h_final h_embed_op0_addr h_embed_op0\n  h_embed_dom h_embed_val h_embed_mem_inj h_embed_mem_disj_op0 h_z_ne_zero hprob₁ hprob₂ h_char_lt i\n\ntheorem mem_op1_addr (i : fin T) : mem a' v' (op1_addr i) = op1 i :=\nmem_pc h_continuity h_single_valued h_initial h_cumulative h_final h_embed_op1_addr h_embed_op1\n  h_embed_dom h_embed_val h_embed_mem_inj h_embed_mem_disj_op1 h_z_ne_zero hprob₁ hprob₂ h_char_lt i\n\nsection\ninclude h_embed_rc_addr h_embed_rc_val h_embed_mem_disj_rc\n\ntheorem mem_rc_addr (i : fin rc_len) : mem a' v' (rc_addr i) = rc_val i :=\nbegin\n  rw [←@real_a_embed_rc _ _ rc_addr mem_star _ a embed_rc embed_mem _ _ h_embed_rc_addr\n          h_embed_mem_disj_rc],\n  rw [←@real_v_embed_inst _ _ rc_val mem_star _ v embed_rc embed_mem _ _\n          h_embed_rc_val h_embed_mem_disj_rc],\n  apply mem_unique h_continuity h_single_valued h_initial h_cumulative h_final h_embed_dom\n    h_embed_val h_embed_mem_inj h_z_ne_zero hprob₁ hprob₂ h_char_lt\nend\nend\n\ntheorem mem_extends : option.fn_extends (mem a' v') mem_star :=\nbegin\n  intro addr,\n  cases h : (mem_star addr) with val; simp only [option.agrees],\n  have h' : (option.is_some (mem_star addr) : Prop), by { rw h, simp },\n  let aelt : mem_dom mem_star := ⟨addr, h'⟩,\n  have h₀ : ∃ i, embed_mem i = embed_mem aelt := ⟨aelt, rfl⟩,\n  have h₁ : classical.some h₀ = aelt,\n  { apply h_embed_mem_inj, apply classical.some_spec h₀ },\n  have h₂ : real_a mem_star a embed_mem (embed_mem aelt) = addr,\n  { rw real_a, dsimp, rw [dif_pos h₀, h₁], refl },\n  have h₃ : real_v mem_star v embed_mem (embed_mem aelt) = val,\n  { rw real_v, dsimp, rw [dif_pos h₀, h₁],\n    apply option.some_inj.mp,\n    rw [←h, mem_val, option.some_get] },\n  rw [←h₂, ←h₃], symmetry,\n  dsimp [aelt],\n  exact mem_unique h_continuity h_single_valued h_initial h_cumulative h_final h_embed_dom\n    h_embed_val h_embed_mem_inj h_z_ne_zero hprob₁ hprob₂ h_char_lt (embed_mem ⟨addr, h'⟩)\nend\n\nend\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/lean/semantics/air_encoding/memory.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867825403177, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4850287103971664}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.category.Module.monoidal\nimport Mathlib.algebra.category.Algebra.basic\nimport Mathlib.category_theory.monoidal.Mon_\nimport Mathlib.PostPort\n\nuniverses u \n\nnamespace Mathlib\n\n/-!\n# `Mon_ (Module R) ≌ Algebra R`\n\nThe category of internal monoid objects in `Module R`\nis equivalent to the category of \"native\" bundled `R`-algebras.\n\nMoreover, this equivalence is compatible with the forgetful functors to `Module R`.\n-/\n\nnamespace Module\n\n\nnamespace Mon_Module_equivalence_Algebra\n\n\n@[simp] theorem Mon_.X.ring_zero {R : Type u} [comm_ring R] (A : Mon_ (Module R)) :\n    0 = add_comm_group.zero :=\n  Eq.refl 0\n\nprotected instance Mon_.X.algebra {R : Type u} [comm_ring R] (A : Mon_ (Module R)) :\n    algebra R ↥(Mon_.X A) :=\n  algebra.mk (ring_hom.mk (linear_map.to_fun (Mon_.one A)) sorry sorry sorry sorry) sorry sorry\n\n@[simp] theorem algebra_map {R : Type u} [comm_ring R] (A : Mon_ (Module R)) (r : R) :\n    coe_fn (algebra_map R ↥(Mon_.X A)) r = coe_fn (Mon_.one A) r :=\n  rfl\n\n/--\nConverting a monoid object in `Module R` to a bundled algebra.\n-/\n@[simp] theorem functor_obj {R : Type u} [comm_ring R] (A : Mon_ (Module R)) :\n    category_theory.functor.obj functor A = Algebra.of R ↥(Mon_.X A) :=\n  Eq.refl (category_theory.functor.obj functor A)\n\n/--\nConverting a bundled algebra to a monoid object in `Module R`.\n-/\ndef inverse_obj {R : Type u} [comm_ring R] (A : Algebra R) : Mon_ (Module R) :=\n  Mon_.mk (of R ↥A) (algebra.linear_map R ↥A) (algebra.lmul' R)\n\n/--\nConverting a bundled algebra to a monoid object in `Module R`.\n-/\n@[simp] theorem inverse_map_hom {R : Type u} [comm_ring R] (A : Algebra R) (B : Algebra R)\n    (f : A ⟶ B) : Mon_.hom.hom (category_theory.functor.map inverse f) = alg_hom.to_linear_map f :=\n  Eq.refl (Mon_.hom.hom (category_theory.functor.map inverse f))\n\nend Mon_Module_equivalence_Algebra\n\n\n/--\nThe category of internal monoid objects in `Module R`\nis equivalent to the category of \"native\" bundled `R`-algebras.\n-/\ndef Mon_Module_equivalence_Algebra {R : Type u} [comm_ring R] : Mon_ (Module R) ≌ Algebra R :=\n  category_theory.equivalence.mk' sorry sorry\n    (category_theory.nat_iso.of_components\n      (fun (A : Mon_ (Module R)) =>\n        category_theory.iso.mk (Mon_.hom.mk (linear_map.mk id sorry sorry))\n          (Mon_.hom.mk (linear_map.mk id sorry sorry)))\n      sorry)\n    (category_theory.nat_iso.of_components\n      (fun (A : Algebra R) =>\n        category_theory.iso.mk (alg_hom.mk id sorry sorry sorry sorry sorry)\n          (alg_hom.mk id sorry sorry sorry sorry sorry))\n      sorry)\n\n/--\nThe equivalence `Mon_ (Module R) ≌ Algebra R`\nis naturally compatible with the forgetful functors to `Module R`.\n-/\ndef Mon_Module_equivalence_Algebra_forget {R : Type u} [comm_ring R] :\n    Mon_Module_equivalence_Algebra.functor ⋙ category_theory.forget₂ (Algebra R) (Module R) ≅\n        Mon_.forget (Module R) :=\n  category_theory.nat_iso.of_components\n    (fun (A : Mon_ (Module R)) =>\n      category_theory.iso.mk (linear_map.mk id sorry sorry) (linear_map.mk id sorry sorry))\n    sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/internal/Module_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186768138228, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4850287016455469}}
{"text": "import .WhileSyntax\nopen whileSyntax\nopen whileSyntax.configExpr\nopen whileSyntax.wExpr\nopen whileSyntax.wComm\nopen whileSyntax.wBool\n\nnamespace semantics\n\ndef a := num 1\ndef b := num 2\ndef c := num 3\ndef d := ident(\"x\")\ndef f : string → ℕ\n| \"x\" := 4\n| _   := 0\ndef exampleConfig := (configE(a + b + (c * d), f))\n\n\ndef oneSmallStepExpr : configExpr → configExpr\n| (configE (num a, state)) := configE (num a, state)\n| (configE (ident x, state)) := configE (num (state x), state)\n| (configE (num a + num b, state)) := configE (num (a + b), state)\n| (configE (num a * num b, state)) := configE (num (a * b), state)\n| (configE (num a + exp2, state)) := let (configE (exp2', state')) := oneSmallStepExpr (configE (exp2, state)) in\n                                       configE (num a + exp2', state')\n| (configE (num a * exp2, state)) := let (configE (exp2', state')) := oneSmallStepExpr (configE (exp2, state)) in\n                                       configE (num a * exp2', state')\n| (configE (exp1 + exp2, state)) := let (configE (exp1', state')) := oneSmallStepExpr (configE (exp1, state)) in \n                                      configE (exp1' + exp2, state')\n| (configE (exp1 * exp2, state)) := let (configE (exp1', state')) := oneSmallStepExpr (configE (exp1, state)) in \n                                      configE (exp1' * exp2, state')\n\ndef smallStepExpr : configExpr → configExpr\n| (configE (num a, state)) := configE (num a, state)\n| a := have sizeof (oneSmallStepExpr a) < sizeof a, from sorry,\n       smallStepExpr $ oneSmallStepExpr a\n\ndef bigStepExpr : configExpr → configExpr\n| (configE (num a, state)) := configE (num a, state)\n| (configE (ident x, state)) := configE (num (state x), state)\n| (configE (num a + num b, state)) := configE (num (a + b), state)\n| (configE (num a * num b, state)) := configE (num (a * b), state)\n| (configE (exp1 + exp2, state)) := let (configE (exp1', state')) := bigStepExpr (configE (exp1, state)),\n                                        (configE (exp2', state'')) := bigStepExpr (configE (exp2, state')) in\n                                      have sizeof exp2' + sizeof exp1' < sizeof exp2 + sizeof exp1, from sorry,\n                                      bigStepExpr $ configE (exp1' + exp2', state'')\n| (configE (exp1 * exp2, state)) := let (configE (exp1', state')) := bigStepExpr (configE (exp1, state)),\n                                        (configE (exp2', state'')) := bigStepExpr (configE (exp2, state')) in\n                                      have sizeof exp2' * sizeof exp1' < sizeof exp2 * sizeof exp1, from sorry,\n                                      bigStepExpr $ configE (exp1' * exp2', state'')\n\ntheorem normal_forms (e : configExpr) : (∃ n : ℕ, ∃ f : string → ℕ, smallStepExpr e = configE (num n, f) ) :=\nbegin\nadmit\nend\n\ndef g := let (configE (a, _)) := smallStepExpr (configE (num 7 + num 6, f)) in a\ndef h := let (configE (a, _)) := bigStepExpr (configE (num 7 + ident \"x\", f)) in a\ndef i := let (configE (a, _)) := bigStepExpr exampleConfig in a\ndef j := let (configE (a, _)) := smallStepExpr exampleConfig in a\n\n#eval i\n#eval j\n\n\nend semantics", "meta": {"author": "benating", "repo": "Lean_Test", "sha": "c07099804a86347b4ec836f54530f62e22534bdb", "save_path": "github-repos/lean/benating-Lean_Test", "path": "github-repos/lean/benating-Lean_Test/Lean_Test-c07099804a86347b4ec836f54530f62e22534bdb/While.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.82893881677331, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4850130584579245}}
{"text": "\nimport temporal_logic\n\nopen temporal predicate\n\nlocal infix ` ≃ ` := v_eq\n\nsection\nvariable α : Type\n\nvariables Γ p q r : cpred\nvariables v₀ v₁ : tvar α\nvariables f : pred' α\nvariables h₀ : Γ ⊢ p ≡ q\ninclude h₀\nexample : Γ ⊢ p ⋀ r ≡ q ⋀ r :=\nbegin [temporal]\n  rw h₀,\nend\n\nexample : Γ ⊢ p ⋀ r →  Γ ⊢ q ⋀ r :=\nassume _,\nbegin [temporal]\n  rw ← h₀,\nend\n\nvariables h₁ : Γ ⊢ ◻(p ≡ q)\nomit h₀\ninclude h₁\nexample : Γ ⊢ ◻◇p ≡ ◻◇q :=\nbegin [temporal]\n  rw h₁,\nend\n\nvariables h₂ : Γ ⊢ ◻(v₀ ≃ v₁)\ninclude h₂\nexample (h : Γ ⊢ ◇(◻(f ! v₀ ≡ q) ⋀ p))\n: Γ ⊢ ◇(◻(f ! v₁ ≡ q) ⋀ p) :=\nbegin [temporal]\n  rw ← h₂,\nend\n\nexample (h : Γ ⊢ ◇(◻(f ! v₀ ≡ q) ⋀ p))\n: Γ ⊢ ◇(◻(f ! v₁ ≡ q) ⋀ p) :=\nbegin [temporal]\n  rw h₂ at h,\nend\nend\n\ninductive nat.even : ℕ → Prop\n | zero : nat.even 0\n | succ_succ (n) : nat.even n → nat.even (nat.succ (nat.succ n))\n\nsection\nopen nat\nlemma even_succ_succ (n : ℕ)\n: nat.even (nat.succ $ nat.succ n) ↔ nat.even n :=\nsorry\nend\nabbreviation succ : var ℕ ℕ := ⟨ nat.succ ⟩\nabbreviation even : var ℕ Prop := ⟨ nat.even ⟩\n\nvariables Γ : cpred\n\nexample (x y : tvar ℕ)\n(h₀ : Γ ⊢ ◻(⊙x ≃ succ!succ!x))\n(h₁ : Γ ⊢ ◻(⊙y ≃ y))\n(h₂ : Γ ⊢ even!x ≡ even!y)\n: Γ ⊢ ◻(even!x ≡ even!y) :=\nbegin [temporal]\n  apply induct _ _ _ _,\n-- h₀ : ◻(⊙x ≃ succ ! succ ! x),\n-- h₁ : ◻(⊙y ≃ y),\n-- h₂ : even ! x ≡ even ! y\n-- ⊢ ◻((even ! x ≡ even ! y) ⟶ ⊙(even ! x ≡ even ! y))\n  { clear h₂,\n    henceforth at ⊢ h₀ h₁,\n-- _inst_1 : persistent Γ,\n-- h₁ : ⊙y ≃ y,\n-- h₀ : ⊙x ≃ succ ! succ ! x\n-- ⊢ (even ! x ≡ even ! y) ⟶ ⊙(even ! x ≡ even ! y)\n    intros h₃,\n-- h₁ : ⊙y ≃ y,\n-- h₀ : ⊙x ≃ succ ! succ ! x,\n-- h₃ : even ! x ≡ even ! y\n-- ⊢ ⊙(even ! x ≡ even ! y)\n    explicit' with h₀ h₁ h₃\n-- x x' y y' : ℕ,\n-- h₃ : nat.even x ↔ nat.even y,\n-- h₀ : x' = nat.succ (nat.succ x),\n-- h₁ : y' = y\n-- ⊢ nat.even x' ↔ nat.even y'\n    { have := even_succ_succ x,\n-- x x' y y' : ℕ,\n-- h₃ : nat.even x ↔ nat.even y,\n-- h₀ : x' = nat.succ (nat.succ x),\n-- h₁ : y' = y,\n-- this : nat.even (nat.succ (nat.succ x)) ↔ nat.even x\n-- ⊢ nat.even x' ↔ nat.even y'\n      guard_hyp h₀ := x' = nat.succ (nat.succ x),\n      guard_target (nat.even x' ↔ nat.even y'),\n      cc, } },\n-- h₀ : ◻(⊙x ≃ succ ! succ ! x),\n-- h₁ : ◻(⊙y ≃ y),\n-- h₂ : even ! x ≡ even ! y\n-- ⊢ even ! x ≡ even ! y\n  { assumption },\nend\n", "meta": {"author": "unitb", "repo": "temporal-logic", "sha": "accec04d1b09ca841be065511c9e206b725b16e9", "save_path": "github-repos/lean/unitb-temporal-logic", "path": "github-repos/lean/unitb-temporal-logic/temporal-logic-accec04d1b09ca841be065511c9e206b725b16e9/test/tactic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672227971212, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.48499254062255465}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.pi_instances\nimport Mathlib.algebra.group.pi\nimport Mathlib.algebra.ring.basic\nimport Mathlib.PostPort\n\nuniverses u v w u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Pi instances for ring\n\nThis file defines instances for ring, semiring and related structures on Pi Types\n-/\n\nnamespace pi\n\n\nprotected instance distrib {I : Type u} {f : I → Type v} [(i : I) → distrib (f i)] :\n    distrib ((i : I) → f i) :=\n  distrib.mk Mul.mul Add.add sorry sorry\n\nprotected instance semiring {I : Type u} {f : I → Type v} [(i : I) → semiring (f i)] :\n    semiring ((i : I) → f i) :=\n  semiring.mk Add.add sorry 0 sorry sorry sorry Mul.mul sorry 1 sorry sorry sorry sorry sorry sorry\n\nprotected instance comm_semiring {I : Type u} {f : I → Type v} [(i : I) → comm_semiring (f i)] :\n    comm_semiring ((i : I) → f i) :=\n  comm_semiring.mk Add.add sorry 0 sorry sorry sorry Mul.mul sorry 1 sorry sorry sorry sorry sorry\n    sorry sorry\n\nprotected instance ring {I : Type u} {f : I → Type v} [(i : I) → ring (f i)] :\n    ring ((i : I) → f i) :=\n  ring.mk Add.add sorry 0 sorry sorry Neg.neg\n    (fun (ᾰ ᾰ_1 : (i : I) → f i) (i : I) => ring.sub (ᾰ i) (ᾰ_1 i)) sorry sorry Mul.mul sorry 1\n    sorry sorry sorry sorry\n\nprotected instance comm_ring {I : Type u} {f : I → Type v} [(i : I) → comm_ring (f i)] :\n    comm_ring ((i : I) → f i) :=\n  comm_ring.mk Add.add sorry 0 sorry sorry Neg.neg\n    (fun (ᾰ ᾰ_1 : (i : I) → f i) (i : I) => comm_ring.sub (ᾰ i) (ᾰ_1 i)) sorry sorry Mul.mul sorry 1\n    sorry sorry sorry sorry sorry\n\n/-- A family of ring homomorphisms `f a : γ →+* β a` defines a ring homomorphism\n`pi.ring_hom f : γ →+* Π a, β a` given by `pi.ring_hom f x b = f b x`. -/\nprotected def ring_hom {α : Type u} {β : α → Type v} [R : (a : α) → semiring (β a)] {γ : Type w}\n    [semiring γ] (f : (a : α) → γ →+* β a) : γ →+* (a : α) → β a :=\n  ring_hom.mk (fun (x : γ) (b : α) => coe_fn (f b) x) sorry sorry sorry sorry\n\n@[simp] theorem ring_hom_apply {α : Type u} {β : α → Type v} [R : (a : α) → semiring (β a)]\n    {γ : Type w} [semiring γ] (f : (a : α) → γ →+* β a) (g : γ) (a : α) :\n    coe_fn (pi.ring_hom f) g a = coe_fn (f a) g :=\n  rfl\n\nend pi\n\n\n/-- Evaluation of functions into an indexed collection of monoids at a point is a monoid\nhomomorphism. -/\ndef ring_hom.apply {I : Type u_1} (f : I → Type u_2) [(i : I) → semiring (f i)] (i : I) :\n    ((i : I) → f i) →+* f i :=\n  ring_hom.mk (monoid_hom.to_fun (monoid_hom.apply f i)) sorry sorry sorry sorry\n\n@[simp] theorem ring_hom.apply_apply {I : Type u_1} (f : I → Type u_2) [(i : I) → semiring (f i)]\n    (i : I) (g : (i : I) → f i) : coe_fn (ring_hom.apply f i) g = g i :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/ring/pi_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672227971211, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4849925406225546}}
{"text": "inductive MyBool :=\n  | MyTrue\n  | MyFalse\n\ninductive T :=\n  | mk (b: MyBool) (u: Unit)\n\ninductive isTrue: T → Type :=\n  | intro: isTrue (.mk .MyTrue ())\n\nexample {τ: T} (h: isTrue τ): Unit :=\n  match τ, h with\n  | .mk .MyTrue (), .intro => ()\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/enumNoConfusionIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8080672135527631, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.48499253507419854}}
{"text": "import Mathlib.Algebra.Field.Basic\nimport Mathlib.Algebra.Hom.Group\nimport Aesop\n\nimport Util.Arithmetic\nimport RealsQuasiMorphisms.Basic\n\nopen scoped Int.natAbs\n\nvariable {G : Type _} [AddCommGroup G]\n\nsection Comp\nnamespace AlmostAdditive\n\n/-- The composition of almost additive functions (on appropriate domains) is\nalmost additive. -/\nprotected theorem comp\n        ⦃f₁ : ℤ → ℤ⦄ ⦃bound₁ : ℕ⦄ (h₁ : AlmostAdditive f₁ bound₁)\n        ⦃f₂ : G → ℤ⦄ ⦃bound₂ : ℕ⦄ (h₂ : AlmostAdditive f₂ bound₂)\n    : AlmostAdditive (f₁ ∘ f₂) <|\n        (bound₁ + |f₁ 1|) * bound₂ + bound₁ * 3 := fun x y =>\n  calc |f₁ (f₂ (x + y)) - f₁ (f₂ x) - f₁ (f₂ y)|\n    ≤ |f₁ (f₂ (x + y)) - f₁ (f₂ (x + y) - f₂ x - f₂ y) - f₁ (f₂ x + f₂ y)|\n      + |f₁ (f₂ (x + y) - f₂ x - f₂ y)|\n      + |f₁ (f₂ x + f₂ y) - f₁ (f₂ x) - f₁ (f₂ y)|\n        := by lax_exact Int.natAbs_add_le₃ (f₁ (f₂ (x + y)) - f₁ (f₂ (x + y) - f₂ x - f₂ y) - f₁ (f₂ x + f₂ y))\n                                           (f₁ (f₂ (x + y) - f₂ x - f₂ y))\n                                           (f₁ (f₂ x + f₂ y) - f₁ (f₂ x) - f₁ (f₂ y))\n              linarith\n  _ ≤ bound₁\n      + ((bound₁ + |f₁ 1|) * |f₂ (x + y) - f₂ x - f₂ y| + bound₁)\n      + bound₁\n        := by conv in f₁ (f₂ (x + y)) =>\n                /- Need `f₂ (x + y)` like this to use `h₁.almost_additive`. -/\n                rw [show f₂ (x + y) = (f₂ (x + y) - f₂ x - f₂ y) + (f₂ x + f₂ y)\n                    by linarith]\n              refine Nat.add_le_add₃ ?_ ?using_lemma ?_;\n              case using_lemma => apply h₁.linear_growth_upper_bound_int\n              all_goals apply h₁.almost_additive\n  _ = (bound₁ + |f₁ 1|) * |f₂ (x + y) - f₂ x - f₂ y| + bound₁ * 3 := by linarith\n  _ ≤ (bound₁ + |f₁ 1|) * bound₂ + bound₁ * 3\n        := h₂.almost_additive .. |> Nat.mul_le_mul_left (k := _)\n                                 |> Nat.add_le_add_right (k := _)\n\n/-- If f₂ - f₁ is bounded then f ∘ (f₂ - f₁) is bounded. -/\nlemma comp_congr_right\n        ⦃f  : ℤ → ℤ⦄ ⦃bound : ℕ⦄ (h : AlmostAdditive f  bound)\n        ⦃f₁ f₂ : G → ℤ⦄ ⦃bound' : ℕ⦄ (h' : Bounded (-f₁ + f₂) bound')\n    : Bounded (-f.comp f₁ + f.comp f₂) <|\n        (bound + |f 1|) * bound' + bound * 2 := fun g =>\n  calc |(-f (f₁ g)) + f (f₂ g)|\n      = |f (f₁ g + (f₂ g - f₁ g)) - f (f₁ g) - f (f₂ g - f₁ g)\n         + f (f₂ g - f₁ g)|\n          := congrArg Int.natAbs <| by\n               rw [Int.add_sub_cancel_right (f₁ g) (f₂ g),\n                   ←Int.sub_eq_neg_add, Int.sub_add_cancel]\n    _ ≤ bound + ((bound + |f 1|) * |f₂ g - f₁ g| + bound)\n          := Trans.trans (Int.natAbs_add_le ..) <| Nat.add_le_add\n               (h.almost_additive ..)\n               (h.linear_growth_upper_bound_int ..)\n    _ ≤ (bound + |f 1|) * bound' + bound * 2\n          := by have : |f₂ g - f₁ g| ≤ bound' := Int.sub_eq_neg_add .. ▸ h' g\n                have := Nat.mul_le_mul_left (bound + (f 1).natAbs) this\n                linarith [this]\n\n/-- Composition of almost additive functions is distributive over addition on\nthe right, up to a bounded function. -/\nlemma almost_comp_add\n        ⦃f  : ℤ → ℤ⦄ ⦃bound : ℕ⦄ (h : AlmostAdditive f  bound)\n        (f₁ f₂ : G → ℤ)\n    : Bounded (-f ∘ (f₁ + f₂) + (f ∘ f₁ + f ∘ f₂)) bound := fun g => by\n  show |(-f (f₁ g + f₂ g)) + (f (f₁ g) + f (f₂ g))| ≤ bound\n  rewrite [←Int.natAbs_neg]\n  lax_exact h.almost_additive (f₁ g) (f₂ g); linarith\n\nend AlmostAdditive\n\nnamespace AlmostHom\n\n/-- Composition of almost-homomorphisms (with appropriate domains), returning\nanother almost-homomorphism. -/\nprotected def comp  (f₁ : AlmostHom ℤ) (f₂ : AlmostHom G) : AlmostHom G where\n  toFun := f₁ ∘ f₂\n  almostAdditive :=\n    let ⟨_, h₁⟩ := f₁.almostAdditive\n    let ⟨_, h₂⟩ := f₂.almostAdditive\n    -- bound is filled in based on the proof :)\n    ⟨_, AlmostAdditive.comp h₁ h₂⟩\n\n/-- Concrete statement of well-defined-ness of `QuasiHom.comp` wrt second argument. -/\nlemma comp_congr_right (f : AlmostHom ℤ)\n        ⦃f₁ f₂ : AlmostHom G⦄ (h : ∃ bound : ℕ, Bounded (-f₁ + f₂) bound)\n    : ∃ bound : ℕ, Bounded (-f.comp f₁ + f.comp f₂) bound :=\n  let ⟨_, h'⟩ := h; let ⟨_, h⟩ := f.almostAdditive\n  ⟨_, h.comp_congr_right h'⟩\n\n/-- Concrete statement of additivity of `QuasiHom.comp` wrt second argument. -/\nlemma almost_comp_add (f : AlmostHom ℤ) (f₁ f₂ : AlmostHom G)\n    : ∃ bound : ℕ, Bounded (-f.comp (f₁ + f₂) + (f.comp f₁ + f.comp f₂)) bound :=\n  let ⟨_, h⟩ := f.almostAdditive\n  ⟨_, h.almost_comp_add f₁ f₂⟩\n\n/-- Left distributivity of composition over addition. -/\nlemma add_comp (f : AlmostHom G) (f₁ f₂ : AlmostHom ℤ)\n    : (f₁ + f₂).comp f = f₁.comp f + f₂.comp f := by ext; rfl\n/-- If f₁ is bounded then f₁.comp f₂ is bounded. -/\nlemma bounded_comp (f₂ : AlmostHom G)\n                   ⦃f₁ : AlmostHom ℤ⦄ (h : ∃ bound : ℕ, Bounded f₁ bound)\n    : ∃ bound : ℕ, Bounded (f₁.comp f₂) bound :=\n  let ⟨bound, h⟩ := h; ⟨bound, fun g => h (f₂ g)⟩\n\n/-- Composition of AlmostHoms f g is almost equal to (f n * g n)/n -/\nprivate lemma comp_almost_mul (f₁ f₂ : AlmostHom ℤ) \n    : ∃ k, ∀ n, |n * (f₁.comp f₂ n) - f₂ n * f₁ n| ≤ (|n| + 1) * k := by\n  let ⟨a', b', hlin⟩ := linear_growth_upper_bound_int f₂\n  let ⟨b₁, hf₁⟩ := f₁.almostAdditive \n  exact ⟨_, by\n    intro n\n    have hypcomm := AlmostAdditive.almost_smul_comm (hf₁) (f₂ n) n 1\n    specialize hlin n\n    simp only [smul_eq_mul, mul_one] at hypcomm\n    calc |n * (f₁.comp f₂ n) - f₂ n * f₁ n| \n        ≤ b₁*(|f₂ n| + |n| + 2) := hypcomm\n      _ ≤ b₁*(a'*|n| + b' + |n| + 2) := \n          by apply mul_le_mul_of_nonneg_left \n              (by simp only [add_le_add_iff_right, hlin]) (zero_le _)\n      _ = b₁*(|n| * (a' + 1) + (b'+ 2)) := by ring\n      _ ≤ b₁*(|n| * (a' + 1) + (b'+ 2)) + b₁*(a'+1) := \n          by simp only [le_add_iff_nonneg_right, zero_le]\n      _ ≤ b₁*(|n| * (a' + 1) + (b'+ 2)) + b₁*(a'+1) + b₁*(|n|)*(b'+2) := \n          by simp only [le_add_iff_nonneg_right, zero_le]\n      _ = (|n|+1)*(b₁*(a'+1 + b'+2)) := by ring\n  ⟩\n\nlemma succ_le_two_mul (a : ℕ) (ha : a ≠ 0) : a+1 ≤ 2*a := by cases a; contradiction; apply Nat.succ_le.2; linarith [NeZero.pos]\n\n/-- Composition of AlmostHoms is commutative. -/\nlemma comp_almost_comm (f₁ f₂ : AlmostHom ℤ) \n    : (f₁.comp f₂) - (f₂.comp f₁) ∈ boundedAlmostHoms ℤ := by\n  simp only [boundedAlmostHoms, Bounded, AddSubgroup.mem_mk, Set.mem_setOf_eq]\n  let ⟨k₁, hf₁⟩ := comp_almost_mul f₁ f₂\n  let ⟨k₂, hf₂⟩ := comp_almost_mul f₂ f₁\n  exact ⟨_, by \n    intro n\n    have triag := Int.natAbs_add_le (n * (f₁.comp f₂ n) - f₂ n * f₁ n) (f₂ n * f₁ n - n * (f₂.comp f₁ n))\n    simp only [sub_add_sub_cancel, Int.diff_eq] at triag\n    if c: n = 0 \n    then \n      simp only [c, zero_mul, zero_sub, Int.natAbs_neg, ge_iff_le] at hf₁ hf₂ |-\n      exact self_le_add_right |(f₁.comp f₂ - f₂.comp f₁) 0| (2*(k₁ + k₂))\n    else \n    have goal_mul_n := \n      calc \n        |n| * |f₁.comp f₂ n - f₂.comp f₁ n|\n          = |n*f₁.comp f₂ n - n*f₂.comp f₁ n| := by rw [←Int.natAbs_mul, mul_sub_left_distrib]\n        _ ≤ |n*f₁.comp f₂ n - f₂ n * f₁ n| + |f₂ n * f₁ n - n*f₂.comp f₁ n| := triag\n        _ ≤ |n*f₁.comp f₂ n - f₂ n * f₁ n| + (|n|+1)*k₂  := \n            by \n              rw [mul_comm $ f₂ n, ←Int.natAbs_neg (f₁ n * f₂ n - n*f₂.comp f₁ n)]\n              apply Nat.add_le_add_left; \n              simp only [neg_sub, Int.diff_eq]; exact hf₂ ..\n        _ ≤ (|n|+1)*k₁ + (|n|+1)*k₂ := Nat.add_le_add_right (hf₁ ..) ..\n        _ = (|n|+1)*(k₁ + k₂) := by ring\n        _ ≤ |n| * (2*(k₁ + k₂)) := \n            by \n              rw [←mul_assoc, mul_comm |n|]\n              exact Nat.mul_le_mul_of_nonneg_right \n                <| succ_le_two_mul |n| \n                <| Int.natAbs_ne_zero.2 c\n    calc |f₁.comp f₂ n - f₂.comp f₁ n| \n      ≤ 2*(k₁ + k₂) := le_of_mul_le_mul_left goal_mul_n \n        <| Or.resolve_left (Nat.eq_zero_or_pos ..) (Int.natAbs_ne_zero.2 c)\n    _ ≤ _ := self_le_add_left  (2*(k₁ + k₂)) |(f₁.comp f₂ - f₂.comp f₁) 0| ⟩\n\ndef non_zero (f : AlmostHom ℤ) : AlmostHom ℤ := \n  ⟨fun n => if f n = 0 then 1 else f n, \n    by \n      let ⟨f,b,hf⟩ := f \n      unfold AlmostAdditive at hf\n      exact ⟨2+b, \n      by \n        rw [AlmostAdditive]\n        intro g₁ g₂\n        split\n        case inl hg => \n          by_cases c:f g₁ = 0 \n          <;> by_cases d:f g₂ = 0\n          <;> specialize hf g₁ g₂\n          <;> simp_all only [c, d, not_false_iff, sub_self, Int.natAbs_zero, zero_le, ite_true, ite_false, zero_sub, Int.natAbs_neg, Int.natAbs_one, le_add_iff_nonneg_right] \n          · linarith -- TODO remove linarith\n          · exact le_add_left hf\n          · simp only [sub_sub_cancel_left, sub_zero] at hf |-; exact le_add_left hf\n          · rw [Int.sub_eq_add_neg, \n                Int.sub_eq_add_neg, \n                add_assoc,\n                ←Int.sub_eq_add_neg]\n            have := Int.natAbs_add_le 1 (-f g₁ - f g₂)\n            rw [Int.natAbs_one] at this\n            linarith\n        case inr hg => \n          by_cases c:f g₁ = 0 \n          <;> by_cases d:f g₂ = 0\n          <;> specialize hf g₁ g₂\n          <;> simp_all only [sub_zero, ite_true, ite_false]\n          · have := Int.natAbs_add_le₃ (f (g₁ + g₂)) (-1) (-1)\n            rw [Int.sub_eq_add_neg, Int.sub_eq_add_neg]\n            simp_all only [Int.natAbs_neg, Int.natAbs_one, ge_iff_le]; linarith\n          · rw [Int.sub_eq_add_neg, \n                Int.sub_eq_add_neg, \n                add_assoc, add_comm (-1), \n                ←add_assoc, \n                ←@Int.sub_eq_add_neg _ (f g₂)]\n            have := Int.natAbs_add_le (f (g₁ + g₂) - f g₂) (-1)\n            rw [Int.natAbs_neg, Int.natAbs_one] at this\n            linarith\n          · rw [Int.sub_eq_add_neg]\n            have := Int.natAbs_add_le (f (g₁ + g₂) - f g₁) (-1)\n            rw [Int.natAbs_neg, Int.natAbs_one] at this\n            linarith\n          · linarith [hf ..]⟩⟩\n\nend AlmostHom\n\n\n-- Tidy up the proof and add it to suitable namespace\n@[aesop norm unfold] def smulHom : QuasiHom ℤ →+ QuasiHom G →+ QuasiHom G := by\n  /- Skeleton. This is glue code tying `Quotient`s and\n  `QuotientAddGroup`s and `MonoidHom`-related functions to define the\n  homomorphism in terms of the actual concrete proofs needed, which\n  are given as holes (except for the function, which is filled in). -/\n  open QuotientAddGroup in\n  refine\n    lift (boundedAlmostHoms ℤ)\n      (AddMonoidHom.mk' (fun f => AddMonoidHom.mk'\n          (Quotient.map (sa := leftRel _) (sb := leftRel _)\n            /- Function definition -/\n            f.comp\n            /- Well-defined wrt second arg -/\n            (fun f₁ f₂ =>\n              show (leftRel _).r .. → (leftRel _).r ..\n                by (repeat rewrite [leftRel_apply]); exact\n              f.comp_congr_right (f₁ := f₁) (f₂ := f₂)))\n          /- Hom wrt second arg as `QuasiHom G` -/\n          (Quotient.ind₂ <| fun g₁ g₂ => Quotient.sound <|\n           show (leftRel _).r (f.comp (g₁ + g₂)) (f.comp g₁ + f.comp g₂)\n             by rewrite [leftRel_apply]; exact\n           f.almost_comp_add g₁ g₂))\n        /- Hom wrt first arg as `AlmostHom ℤ` -/\n        fun f₁ f₂ =>\n          AddMonoidHom.ext <|\n          Quotient.ind <| fun g => congrArg mk <|\n          g.add_comp f₁ f₂)\n      /- Show output is 0 if first arg is in `boundedAlmostHoms ℤ`\n      (i.e, well-defined wrt first arg as `QuasiHom ℤ`) -/\n      fun f h =>\n        AddMonoidHom.ext <|\n        Quotient.ind <| fun g => Quotient.sound <| by\n          simp only [HasEquiv.Equiv, leftRel_apply];\n          show -f.comp g + 0 ∈ boundedAlmostHoms G\n          rewrite [add_zero, neg_mem_iff]; exact g.bounded_comp h\n\nnamespace QuasiHom\n\n/- The following 'helper lemmas' are for showing field structure. -/\n\nprivate lemma right_distrib (a b c : QuasiHom ℤ) :\n    smulHom (a + b) c = smulHom a c + smulHom b c := by\n  rw [AddMonoidHom.map_add]; apply AddMonoidHom.add_apply\n\nprivate lemma zero_mul (a : QuasiHom ℤ) : smulHom 0 a = 0 := by\n  simp only [map_zero, AddMonoidHom.zero_apply]\n\nprivate lemma mul_zero (a : QuasiHom ℤ) : @smulHom ℤ _ a 0 = 0 := by\n  simp only [map_zero]\n\nprivate lemma mul_assoc (a b c : QuasiHom ℤ) :\n    smulHom (smulHom a b) c = smulHom a (smulHom b c) := by\n  apply QuotientAddGroup.induction_on a\n  apply QuotientAddGroup.induction_on b\n  apply QuotientAddGroup.induction_on c\n  intro _ _ _; rfl\n\nprivate def one : QuasiHom ℤ := ⟦ ⟨ fun n => n, ⟨0, by intros _ _ ; simp only\n                      [add_sub_cancel', sub_self,\n                      Int.natAbs_zero, le_refl]⟩⟩  ⟧\n\nprivate def one_mul  (a : QuasiHom ℤ) : smulHom one a = a := by\n  apply QuotientAddGroup.induction_on a; intro _; rfl\n\nprivate def mul_one (a : QuasiHom ℤ) : smulHom a one = a := by\n  apply QuotientAddGroup.induction_on a; intro _; rfl\n\nprivate def inv (a : QuasiHom ℤ) : QuasiHom ℤ := by\n  sorry\n\nprivate def exists_pair_ne : one ≠ ⟦⟨0, 0, fun _ _ => Nat.le_refl ..⟩⟧ := by\n  /- rewrite [show ∀ a : QuasiHom ℤ, a ≠ 0 ↔ ¬a = 0 by intro; rfl] -/\n  /- by_contra h -/\n  /- apply QuotientAddGroup.eq -/\n  \n  /- apply Quotient.exact  (⟨ fun n => n, ⟨0, by intros _ _ ; simp only -/\n  /-                         [add_sub_cancel', sub_self, -/\n  /-                         Int.natAbs_zero, le_refl]⟩⟩) -/\n  /- have := Quotient.exact h; -/\n  /- simp [funext] at this; -/ \n  sorry\n\nprivate def mul_comm (a b : QuasiHom ℤ) : smulHom a b = smulHom b a := by\n  apply QuotientAddGroup.induction_on a\n  apply QuotientAddGroup.induction_on b\n  intro a b\n  rw [smulHom]\n  apply (QuotientAddGroup.eq ..).2\n  rw [add_comm]\n  show a.comp b - b.comp a ∈ boundedAlmostHoms ℤ\n  exact AlmostHom.comp_almost_comm a b\n\n/- For some reason LSP is quite slow if it is allowed to work on this instance declaration. -/\n#exit\ninstance : Field (QuasiHom ℤ) :=\n  let mul : Mul (QuasiHom ℤ) := ⟨ fun f g => smulHom f g ⟩\n  {\n    sub_eq_add_neg := SubNegMonoid.sub_eq_add_neg\n    left_distrib := by intros _ _ _;  apply AddMonoidHom.map_add\n    right_distrib := right_distrib\n      -- aesop? (add norm unfold [HMul.hMul, Mul.mul], norm simp AddMonoidHom.map_add, safe apply AddMonoidHom.add_apply)\n    mul_comm := mul_comm\n    zero_mul  := zero_mul\n    mul_zero  := mul_zero\n    mul_assoc := mul_assoc\n    one :=  one\n    one_mul := one_mul\n    mul_one := mul_one\n    add_left_neg := add_left_neg\n    inv := sorry\n    exists_pair_ne := sorry\n    mul_inv_cancel := sorry\n    inv_zero := sorry\n  }\n\n\n\nend QuasiHom\n\nend Comp\n", "meta": {"author": "Karthik-Dulam", "repo": "reals-quasi-morphisms", "sha": "0604e81bbae64fed54dbccf7bd39b17b8779050d", "save_path": "github-repos/lean/Karthik-Dulam-reals-quasi-morphisms", "path": "github-repos/lean/Karthik-Dulam-reals-quasi-morphisms/reals-quasi-morphisms-0604e81bbae64fed54dbccf7bd39b17b8779050d/RealsQuasiMorphisms/Algebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.774583389368527, "lm_q2_score": 0.6261241702517976, "lm_q1q2_score": 0.484985381959194}}
{"text": "import Project.Main\nimport Project.Merge\nimport Project.findMin\n\nuniverse u\n\nnamespace project\n\nvariable {le : α → α → Bool} \n(not_le_le : ∀ x y, ¬ le x y → le y x) \n(le_trans : ∀ x y z, le x y → le y z → le x z)\n(le_rfl : ∀ z, le z z)\n\n\ntheorem deleteMin_empty_IsHeap :  deleteMin le xs = none → isEmpty xs := by\nintro heq\nunfold deleteMin at heq\ncases xs with | heap ts =>\ncases ts with \n| nil =>\n  rfl\n| cons _ ts =>\n  dsimp at heq\n  cases ts <;> contradiction\n\n\ntheorem IsHeapForest'_of_IsRankedTree (h₁ : r ≠ 0) : \n    IsRankedTree r s nodes → IsHeapForest' (r - 1) nodes \n  | .nil => by \n    constructor\n  | .cons (t := t) (ts := ts) eq rt _ => by\n    constructor\n    . rw[←eq]\n      apply Nat.pred_lt\n      simp\n      rw[eq]\n      assumption\n    . assumption\n    . have : t.rank = (r + 1) - 1 := by\n        simp_all\n      rw[this]\n      apply IsHeapForest'_of_IsRankedTree\n      . simp\n      . assumption\n\ntheorem children_IsHeap : IsHeap (.heap [h]) → IsHeap h.children := by\n  intro h₁\n  cases h with | mk val rank children =>\n  dsimp at *\n  cases h₁ with | cons lt bt h₁ =>\n  dsimp at *\n  cases children with | heap nodes =>\n  dsimp at *\n  cases bt with | mk rt =>\n  dsimp at rt\n  apply IsHeapForest'_of_IsRankedTree (r := 1)\n  . simp\n  . assumption\n\ntheorem IsMinHeap_of_IsMinTree : IsMinTree le val nodes → IsMinHeap le (.heap nodes)\n  | .nil => by\n    constructor\n  | .cons _ _ _=> by\n    constructor\n    . assumption\n    . apply IsMinHeap_of_IsMinTree\n      . assumption\n\ntheorem children_IsMinHeap : IsMinHeap le (.heap [h]) → IsMinHeap le h.children := by\n  intro imh\n  cases h with | mk val rank children =>\n  dsimp at *\n  cases imh with | cons st imh =>\n  cases children with | heap nodes =>\n  cases imh with | nil =>\n  cases st with | mk mt =>\n  dsimp at mt\n  apply IsMinHeap_of_IsMinTree\n  repeat assumption\n\n\ntheorem IsHeapForest'_eraseIdx {id : ℕ} : IsHeapForest' r a → IsHeapForest' r (List.eraseIdx a id)\n  | .nil => by\n    simp \n    constructor\n  | .cons (t := t) (ts := ts) lt bt h₁ => by\n    unfold List.eraseIdx\n    split\n    . constructor\n    . simp_all\n      apply IsHeapForest'_weaken\n      . assumption\n      . apply le_of_lt \n        assumption\n    . rename_i eq\n      have hf : IsHeapForest' r (t ::ts) := by\n        apply IsHeapForest'_of_IsHeapForest' <;> assumption\n      constructor\n      . simp_all\n      . simp_all\n      . rw[eq] at hf\n        cases hf\n        apply IsHeapForest'_eraseIdx\n        assumption \n    \n\ntheorem IsHeap_delete_BinTree {id : Nat} : IsHeap (.heap (a :: b)) → IsHeap (.heap (a :: List.eraseIdx b id)) := by\n  intros h₁\n  cases h₁\n  constructor\n  . assumption\n  . assumption\n  . apply IsHeapForest'_eraseIdx\n    assumption\n\n\ntheorem IsMinHeap_eraseIdx {id : Nat} : IsMinHeap le (.heap b) → IsMinHeap le (.heap (List.eraseIdx b id))\n  | .nil => by\n    simp\n    constructor\n  | .cons (n := n) (ns := ns) st mh => by\n    unfold List.eraseIdx\n    split\n    . constructor\n    . rename_i heq\n      rw[← List.tail_eq_of_cons_eq heq]\n      assumption\n    . rename_i heq\n      constructor\n      . rw[← List.head_eq_of_cons_eq heq]\n        assumption\n      . apply IsMinHeap_eraseIdx\n        rw[← List.tail_eq_of_cons_eq heq]\n        assumption\n\ntheorem IsMinHeap_delete_BinTree {id : Nat} : IsMinHeap le (.heap (a :: b)) → IsMinHeap le (.heap (a :: List.eraseIdx b id)) := by\n  intros imh\n  cases imh\n  constructor\n  . assumption\n  . apply IsMinHeap_eraseIdx\n    assumption\n\n\ntheorem rank_zero_IsRankedTree : IsRankedTree (n + 1) 0 ts → False\n  | .cons (ts := ts) _ rt _ => by\n    cases rt with\n    | cons => \n      apply rank_zero_IsRankedTree\n      assumption\n  \n\ntheorem min_rank_IsBinTree : IsBinTree t → 0 < t.rank := by\n  intro bt\n  cases t with | mk val r children =>\n  cases r\n  . cases bt with | mk rt =>\n    simp at rt\n    generalize eq : (children.nodes) = ts\n    rw[eq] at rt\n    cases rt\n    . simp\n      apply rank_zero_IsRankedTree\n      assumption\n  . simp_arith\n\ntheorem deleteMin_non_empty_minimum : deleteMin le (.heap xs) = some (y, ys) → ∀ x ∈ xs, le y x.val := by\n  intros heq t hel\n  unfold deleteMin at heq\n  split at heq\n  . contradiction\n  . simp_all\n  . simp_all\n    dsimp at heq\n    rw[← heq.left]\n    cases hel\n    . rename_i heq₂\n      rw[← heq₂]\n      apply findMin_is_minimum_head <;> simp_all; assumption\n    . apply findMin_is_minimum_tail\n      . simp_all\n      repeat assumption\n      . apply findMin_is_minimum_head\n        . simp_all\n        repeat assumption\n      . assumption\n\n\ntheorem deleteMin_non_empty (h₁ : IsHeap xs) (h₂ : IsMinHeap le xs) : deleteMin le xs = some (y, ys) → IsHeap ys ∧ IsMinHeap le ys :=\nmatch xs with\n| .heap [] => by\n  intro eq\n  unfold deleteMin at eq\n  dsimp at eq\n  contradiction\n| .heap [h] => by\n  intro eq\n  unfold deleteMin at eq\n  dsimp at eq\n  rw[Option.some_inj, Prod.eq_iff_fst_eq_snd_eq] at eq\n  simp at eq\n  apply And.intro\n  . rw[← eq.right]\n    apply children_IsHeap\n    assumption \n  . rw[← eq.right]\n    apply children_IsMinHeap\n    assumption\n| .heap (h::hs) => by\n  intro dmeq\n  unfold deleteMin at dmeq\n  dsimp at dmeq\n  split at dmeq\n  . contradiction\n  . rename_i heq\n    rw[Option.some_inj] at dmeq\n    rw[Prod.eq_iff_fst_eq_snd_eq] at dmeq\n    simp at *\n    rw[←dmeq.right]\n    rw[←heq.left]\n    apply And.intro\n    . apply children_IsHeap\n      rw[heq.right] at h₁\n      assumption\n    . apply children_IsMinHeap\n      rw[heq.right] at h₂\n      assumption\n  . rename_i xs₂ t₁ ts hne₂ heqh\n    rw[Option.some_inj] at dmeq\n    unfold findMin at dmeq\n    split at dmeq\n    . contradiction\n    . split at dmeq\n      . simp at *\n        rename_i ts n btxn bt ts₂ bt₂ n₂ lebt eqeq\n        rw[←dmeq.right]\n        apply And.intro\n        . unfold merge\n          split\n          rename_i ys₂ xs₃ ts₃ ts₄ heq heq₂\n          simp at heq\n          unfold List.eraseIdx at heq\n          have ihts₃ : IsHeap (.heap ts₃) := by\n            split at heq\n            . simp_all\n            . simp_all\n              unfold IsHeap\n              simp\n              unfold IsHeapForest\n              cases h₁\n              apply IsHeapForest'_weaken\n              . assumption\n              . simp_arith\n            . rename_i heq₃ _\n              rw[← heq]\n              apply IsHeap_delete_BinTree\n              rw[← heq₃, ← heqh.left, ← heqh.right] \n              assumption\n          have ihts₄ : IsHeap (.heap ts₄) := by\n            clear heq \n            rw [← heq₂]\n            have (And.intro ml mr) := eqeq\n            rw [← ml, ← mr] at *; clear eqeq ml mr\n            apply children_IsHeap\n            constructor\n            . have fm : IsBinTree (findMin le ts₂ (1 + 1) (t₁, 0)).fst := by\n                apply IsBinTree_findMin\n                . cases h₁ with | cons _ _ hf =>\n                  rw[heqh.right] at hf \n                  cases hf\n                  assumption\n                . cases h₁\n                  simp_all\n              apply min_rank_IsBinTree \n              assumption\n            . apply IsBinTree_findMin\n              . rw[heqh.right] at h₁\n                cases h₁ with | cons _ _ hf =>\n                  cases hf\n                  assumption\n              . unfold IsHeap at h₁\n                unfold IsHeapForest at h₁\n                cases h₁ with | cons _ ht _ =>\n                rw[heqh.left] at ht\n                assumption\n            . constructor\n          unfold IsHeap at *\n          unfold IsHeapForest at *\n          simp at *\n          have min_zero : 0 = min 0 0 := by\n            simp\n          rw[min_zero]\n          apply IsHeap_merge <;> assumption\n        . unfold merge\n          split\n          rename_i ys₂ xs₃ ts₃ ts₄ heq heq₂\n          simp at heq\n          unfold List.eraseIdx at heq\n          have h₁₂ : IsMinHeap le (.heap ts₃) := by\n            split at heq\n            . rw[← heq]\n              constructor\n            . rename_i ts₅ heq₃ _\n              rw[← heqh.right] at heq₃\n              have eq : hs = ts₅ := by\n                apply List.tail_eq_of_cons_eq\n                assumption\n              rw[← heq, ← eq]\n              cases h₂\n              assumption\n            . rename_i heq₃ _\n              rw[← heq]\n              apply IsMinHeap_delete_BinTree\n              rw[← heq₃, ← heqh.left, ← heqh.right]\n              assumption                                                           \n          have h₁₃ : IsMinHeap le (.heap ts₄) := by\n            rw[← heq₂]\n            apply children_IsMinHeap\n            constructor\n            . apply IsSearchTree_findMin\n              . rw[heqh.right] at h₂\n                cases h₂ with | cons _ mh => \n                cases mh\n                assumption\n              . rw[← eqeq.left, ← heqh.left]\n                cases h₂\n                assumption\n            . constructor\n          apply IsMinHeap_merge\n          simp\n          repeat assumption\n      . simp at dmeq\n        have (And.intro _ heq) := dmeq\n        clear dmeq\n        unfold merge at heq\n        split at heq\n        rename_i bt ts _ _ _ _ _ _ _ ts₂ ts₃ heq₃ heq₄\n        rw[← heq]\n        apply And.intro\n        . have ihts₂ : IsHeap (.heap ts₂) := by\n            rw[← heq₃]\n            unfold IsHeap\n            unfold IsHeapForest\n            apply IsHeapForest'_eraseIdx\n            simp at heqh\n            constructor\n            . apply min_rank_IsBinTree\n              rw[← heqh.left]\n              cases h₁\n              assumption\n            . rw[← heqh.left]\n              cases h₁\n              assumption\n            . cases h₁\n              rw[← heqh.left, ← heqh.right]\n              assumption\n          have h₂₄ : IsHeap (.heap ts₃) := by\n            rw[← heq₄]\n            apply children_IsHeap\n            constructor\n            . have ibt : IsBinTree (findMin le ts (1 + 1) (bt, 1)).fst := by\n                simp at heqh\n                rw[heqh.right] at h₁\n                apply IsBinTree_findMin <;>\n                  cases h₁ with | cons _ _ hf =>\n                  cases hf\n                  assumption\n              apply min_rank_IsBinTree ibt\n            . simp at heqh\n              rw[heqh.right] at h₁\n              apply IsBinTree_findMin <;>\n                cases h₁ with | cons _ _ hf =>\n                cases hf\n                assumption\n            . constructor\n          unfold IsHeap at *\n          unfold IsHeapForest at *\n          simp at *\n          have min_zero : 0 = min 0 0 := by\n            simp\n          rw[min_zero]\n          apply IsHeap_merge <;> assumption\n        . simp at heqh\n          have imhts₂ : IsMinHeap le (.heap ts₂) := by\n            rw[← heq₃]\n            apply IsMinHeap_eraseIdx\n            rw[← heqh.left, ← heqh.right]\n            assumption\n          have imhts₃ : IsMinHeap le (.heap ts₃) := by\n            rw[← heq₄]\n            apply children_IsMinHeap\n            constructor\n            . apply IsSearchTree_findMin <;>\n              . rw[heqh.right] at h₂\n                cases h₂ with | cons _ mh =>\n                cases mh\n                assumption\n            . constructor\n          apply IsMinHeap_merge <;> assumption\n\n", "meta": {"author": "jappaaa", "repo": "Bachelor-project", "sha": "56d13d7ad5136ac2142d0d7cccb859c1a96a81e5", "save_path": "github-repos/lean/jappaaa-Bachelor-project", "path": "github-repos/lean/jappaaa-Bachelor-project/Bachelor-project-56d13d7ad5136ac2142d0d7cccb859c1a96a81e5/Project/DeleteMin.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.48489068146627706}}
{"text": "import category_theory.limits.shapes.biproducts\nimport category_theory.preadditive.basic\nimport category_theory.preadditive.biproducts\nimport data.fintype.sigma\n\n/-!\nLet's show that every preadditive category embeds into a preadditive category with biproducts,\nand identify a good universal property.\n\nThis is a more advanced exercise, for which I've indicated a suggested structure,\nbut not written a full solution. I hope this structure will work out!\n-/\n\nnoncomputable theory\n\nuniverses v u\n\nvariables (C : Type u)\n\nstructure additive_envelope :=\n(ι : Type)\n[fintype : fintype ι]\n[decidable_eq : decidable_eq ι]\n(val : ι → C)\n\nattribute [instance] additive_envelope.fintype additive_envelope.decidable_eq\n\nvariables {C}\n\ndef dmatrix {X Y : additive_envelope C} (Z : X.ι → Y.ι → Type*) := Π (i : X.ι) (j : Y.ι), Z i j\n-- You may need to develop some API for `dmatrix`, parallel to that in `data.matrix.basic`.\n-- One thing you'll certainly need is an \"extensionality\" lemma,\n-- showing that you can prove two `dmatrix`s are equal by checking componentwise.\n\nopen category_theory\n\nvariables [category C] [preadditive C]\n\nnamespace family\n\ndef hom (X Y : additive_envelope C) := dmatrix (λ i j, X.val i ⟶ Y.val j)\n\nopen_locale big_operators\n\ninstance : category (additive_envelope C) :=\n{ hom := hom,\n  id := λ X i j, if h : i = j then eq_to_hom (by subst h) else 0,\n  comp := λ X Y Z f g i k, ∑ (j : Y.ι), f i j ≫ g j k,\n  id_comp' := sorry,\n  comp_id' := sorry,\n  assoc' := sorry, }\n\nvariables (C)\n\n@[simps]\ndef embedding : C ⥤ additive_envelope C :=\n{ obj := λ X, ⟨unit, λ _, X⟩,\n  map := λ X Y f _ _, f,\n  map_id' := sorry,\n  map_comp' := sorry, }\n\nlemma embedding.faithful : faithful (embedding C) :=\nsorry\n\ninstance : preadditive (additive_envelope C) :=\nsorry -- probably best to go back and make `dmatrix` an `add_comm_group` first.\n\nopen category_theory.limits\n\ninstance : has_finite_biproducts (additive_envelope C) :=\n{ out := λ n,\n  { has_biproduct := λ F, has_biproduct.mk\n    { bicone :=\n      { X :=\n        { ι := Σ (j : fin n), (F j).ι,\n          val := λ p, (F p.1).val p.2 },\n        ι := sorry,\n        π := sorry,\n        ι_π := sorry, },\n      is_bilimit := sorry }}}\n\nvariables {C}\n\ndef factor {D : Type u} [category.{v} D] [preadditive D] [has_finite_biproducts D]\n  (F : C ⥤ D) : additive_envelope C ⥤ D :=\n{ obj := λ X, ⨁ (λ i, F.obj (X.val i)),\n  map := sorry,\n  map_id' := sorry,\n  map_comp' := sorry, }\n\ndef factor_factorisation {D : Type u} [category D] [preadditive D] [has_finite_biproducts D]\n  (F : C ⥤ D) : F ≅ embedding C ⋙ factor F :=\nsorry\n\nend family\n\n", "meta": {"author": "leanprover-community", "repo": "lftcm2020", "sha": "cc683e2b074b61909310746d6acc1fb3d42d6ee2", "save_path": "github-repos/lean/leanprover-community-lftcm2020", "path": "github-repos/lean/leanprover-community-lftcm2020/lftcm2020-cc683e2b074b61909310746d6acc1fb3d42d6ee2/src/exercises_sources/thursday/category_theory/exercise9.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.484890681466277}}
{"text": "import contourintegral\nimport analysis.calculus.dslope\nimport analysis.complex.cauchy_integral\nnoncomputable theory\n\nsection tactic \n\nvariables {E : Type} {𝕜: Type} [nontrivially_normed_field 𝕜]\n[normed_add_comm_group E] [normed_space 𝕜 E] [complete_space E] \n\n/-! Part O. tactic\n\n- # Tactic\n-/\n\n@[simp] lemma addminus{a:E}{b:E}: a+(-b)=a - b:= \nby {have t: -b=0-b:= by simp, rw t,\n    rw ← add_sub_assoc, simp,}\n\nlemma zero_exact{a b:E}(h:0=a-b):a=b:=\nbegin\n  have b_z: b=b+0:= by simp,\n  rw h at b_z,\n  rw b_z, simp,\nend\n\nlemma zero_symm_exact{a b:E}(h:a-b=0):a=b:=\nbegin\n  have h':0=a-b:=by rw h,\n  exact zero_exact h',\nend\n\nlemma neg_rewrite {a b:E}: -a=b ↔ a=-b := \nby {split, intro f, rw← f,simp,\n    intro f, rw f,simp,}\n\nend tactic \n\nvariables {E : Type} \n[normed_add_comm_group E] [normed_space ℂ E] [complete_space E] \n\n/-! Part O'. basic function \n\n- # Basic Function\n-/\n/-- The derivative of the inclusion ℝ → ℂ is 1. --/\nlemma coe_has_deriv (x:ℝ ):\nhas_deriv_at (λ (t : ℝ), (t : ℂ)) 1 x :=\nbegin\n  rw has_deriv_at,\n  rw has_deriv_at_filter_iff_is_o,\n  simp,\nend\n\nlemma coe_differentiable: \ndifferentiable ℝ (λ (t : ℝ), (t : ℂ)):=\nbegin\n  intro x,\n  exact has_deriv_at.differentiable_at \n    (coe_has_deriv x),\nend\n\nlemma deriv_of_coe: deriv (λ (x : ℝ), (x : ℂ)) = 1 :=\n deriv_eq coe_has_deriv\n\nlemma complex_affine_has_deriv (a b x:ℂ):\nhas_deriv_at (λ (z : ℂ), a * z + b) a x :=\nbegin\n  apply has_deriv_at.add_const _ b,\n  have frw:(λ (x : ℂ), a * x)=(λ (x : ℂ), x * a):=\n    by {ext1,rw mul_comm,}, rw frw,\n  exact has_deriv_at_mul_const a,\nend\n\nlemma complex_affine_differentiable(a b:ℂ):\ndifferentiable ℂ (λ (z : ℂ), a * z + b):=\nbegin\n  intro x,\n  exact has_deriv_at.differentiable_at \n    (complex_affine_has_deriv a b x),\nend\n\nlemma affine_rtc_has_deriv(a b :ℂ)(x:ℝ):\nhas_deriv_at ((λ x:ℝ, a*x+b):ℝ→ ℂ) a x:=\nbegin\n  have func_eq:((λ x:ℝ, a*x+b):ℝ→ ℂ)= \n    ((λ z:ℂ, a*z+b):ℂ→ ℂ) ∘ (λ (t : ℝ), (t : ℂ)) :=\n    by {ext1, simp,},\n  have conc: has_deriv_at ((λ (z : ℂ), a * z + b) \n    ∘ λ (t : ℝ), ↑t) a x ↔ has_deriv_at ((λ (z : ℂ), \n    a * z + b) ∘ λ (t : ℝ), ↑t) (a*1) x:= by simp,\n  rw [func_eq, conc],\n  apply has_deriv_at.comp,\n  exact complex_affine_has_deriv a b _,\n  exact coe_has_deriv _,\nend\n\nlemma affine_rtc_differentiable(a b:ℂ):\ndifferentiable ℝ ((λ x:ℝ, a*x+b):ℝ→ ℂ):=\nbegin\n  intro x,\n  exact has_deriv_at.differentiable_at \n    (affine_rtc_has_deriv a b x),\nend\n\nlemma affine_rtc_continuous (a b:ℂ):\ncontinuous ((λ x:ℝ, a*x+b):ℝ→ ℂ):=\ndifferentiable.continuous (affine_rtc_differentiable a b)\n\nlemma complex_affine_inverse_has_deriv{a b x:ℂ}\n(h: a*x+b≠ 0):\nhas_deriv_at ((λ(t:ℂ), (a*t + b)⁻¹):ℂ→ ℂ) \n(-a/(a*x+b)^2) x :=\nhas_deriv_at.inv (complex_affine_has_deriv a b x) h\n\nlemma affine_rtc_inverse_has_deriv{a b :ℂ}{x:ℝ}\n(h: a*x+b≠ 0):\nhas_deriv_at ((λ(t:ℝ), (a*t + b)⁻¹):ℝ→ ℂ) \n(-a/(a*x+b)^2) x :=\nbegin\n  have func_rw:((λ(t:ℝ), (a*t + b)⁻¹):ℝ→ ℂ)=\n    ((λ(t:ℂ), (a*t + b)⁻¹):ℂ→ ℂ) ∘ (λ (t : ℝ), (t : ℂ)):=\n    by {ext1, simp,},\n  have q:(-a/(a*x+b)^2) =(-a/(a*x+b)^2)*1:= by ring_nf,\n  rw [func_rw,q],\n  apply has_deriv_at.comp,\n  exact complex_affine_inverse_has_deriv h,\n  exact coe_has_deriv _,\nend\n\nlemma affine_rtc_differentiable_on{a b :ℂ}{s: set ℝ}\n(h: ∀(x:ℝ), x∈ s → a*x+b≠ 0):\ndifferentiable_on ℝ ((λ(t:ℝ), (a*t + b)⁻¹):ℝ→ ℂ) s :=\nbegin\n  intros x x_in,\n  apply differentiable_at.differentiable_within_at,\n  have x_in':= h x x_in,\n  exact has_deriv_at.differentiable_at \n    (affine_rtc_inverse_has_deriv x_in'),\nend\n\nlemma affine_rtc_continuous_on{a b :ℂ}{s: set ℝ}\n(h: ∀(x:ℝ), x∈ s → a*x+b≠ 0):\ncontinuous_on ((λ(t:ℝ), (a*t + b)⁻¹):ℝ→ ℂ) s :=\ndifferentiable_on.continuous_on \n  (affine_rtc_differentiable_on h)\n\nlemma reciprocal_differentiable_on (c:ℂ):\ndifferentiable_on ℂ (λ (z : ℂ), (z - c)⁻¹) {c}ᶜ :=\nbegin\n  apply differentiable_on.inv,\n  apply differentiable.differentiable_on,\n  simp,\n  intros x x_in, simp at x_in, symmetry,\n  intro f, have h:=zero_exact f,\n  exact x_in h,\nend\n\nlemma reciprocal_continuous_on (c:ℂ) :\ncontinuous_on (λ (z : ℂ), (z - c)⁻¹) {c}ᶜ :=\ndifferentiable_on.continuous_on \n  (reciprocal_differentiable_on c)\n\n/-! Part I. Define line segments \n\n- # Line Segments\n-/\n\ndef line_segment (a:ℂ) (b:ℂ) : ℝ → ℂ :=\n  λ (θ : ℝ) , (b-a) * θ + a\n\n/-- The line sgement and circle are both continuously differentiable. --/\nlemma deriv_of_line (a:ℂ)(b:ℂ): \n  deriv (line_segment a b)  = constant_path (b-a):=\nbegin\n  unfold line_segment constant_path,\n  ext1,\n  simp,\n  rw deriv_of_coe,\n  simp,\nend\n\nlemma deriv_of_line' (a:ℂ)(b:ℂ)(x : ℝ): \n  has_deriv_at (line_segment a b) (constant_path (b-a) x) x:=\nbegin\n  unfold line_segment,\n  have h0 : b - a = (b - a) + 0 := by simp,\n  rw h0,\n  apply has_deriv_at.add,\n  have h2 : b - a = (1 : ℂ) • (b - a : ℂ) := by simp,\n  rw h2,\n  have h1 : (λ (x : ℝ), ((1 : ℂ) • (b - a) + 0) * ↑x) = (λ (x : ℂ), (b - a + 0) * x) ∘ (λ (x : ℝ), (x : ℂ)) := by simp,\n  rw h1,\n  apply has_deriv_at.scomp,\n  {\n    rw has_deriv_at,\n    rw has_deriv_at_filter_iff_is_o,\n    simp,\n    have mid: (λ (x' : ℂ), (b - a) * x' - \n      (b - a) * ↑x - (x' - ↑x) * (b - a)) = \n      (λ(x:ℂ), (0:ℂ)) := by ring_nf,\n    rw mid,\n    rw asymptotics.is_o_const_left,\n    left,\n    exact rfl,\n  },\n  {\n    simp,\n    exact coe_has_deriv x,\n  },\n  {\n    exact has_deriv_at_const x a,\n  }\nend\n\nlemma line_is_differentiable (a:ℂ)(b:ℂ): \n  differentiable ℝ (line_segment a b):= \nbegin\n  unfold differentiable,\n  intro x,\n  apply has_deriv_at.differentiable_at (deriv_of_line' a b x),\nend\n\nlemma line_is_continuous (a:ℂ )(b:ℂ ):\n  continuous (line_segment a b):=\n  by {exact differentiable.continuous (line_is_differentiable a b),}\n\nlemma line_is_continuous_on (a:ℂ )(b:ℂ ):\n  continuous_on (line_segment a b) (set.interval 0 1):=\n  (line_is_continuous a b).continuous_on\n\nlemma line_is_in_C1 (a:ℂ )(b:ℂ):\n  continuous (deriv (line_segment a b)):=\nbegin\n  rw deriv_of_line a b,\n  exact continuity_of_constant_path (b-a),\nend\n\nlemma deriv_line_integrable (a:ℂ)(b:ℂ):\n  interval_integrable (deriv (line_segment a b)) \n  measure_theory.measure_space.volume 0 1:=\ncontinuous.interval_integrable (line_is_in_C1 a b) 0 1\n\nlemma line_integral_ML_inequality{f:ℂ → E}{a b:ℂ}{M:ℝ}\n(hf: ∀ z:ℂ, z ∈ set.image (line_segment a b) \n(set.interval 0 1) → ∥f z∥ ≤ M):\n∥contour_integral f (line_segment a b)∥ ≤ \nM * complex.abs(b-a) :=\nbegin\n  apply contour_integral_ML_inequality,\n  {\n    intros z z_in,\n    exact hf z ((set.image_subset (line_segment a b) \n      set.Ioc_subset_Icc_self) z_in),\n  },\n  {\n    intros x _,\n    rw deriv_of_line,\n    unfold constant_path,\n  },\nend \n\n/-! Part II. Define rectangles \n\n- # Rectangles\n-/\n\ndef rec_bottom (l:ℝ)(b:ℝ)(r:ℝ):=\n  line_segment (l+b*complex.I) (r+b*complex.I)\ndef rec_right (b:ℝ)(r:ℝ)(t:ℝ):=\n  line_segment (r+b*complex.I) (r+t*complex.I)\ndef rec_top (r:ℝ)(t:ℝ)(l:ℝ):=\n  line_segment (r+t*complex.I) (l+t*complex.I)\ndef rec_left (t:ℝ)(l:ℝ)(b:ℝ):=\n  line_segment (l+t*complex.I) (l+b*complex.I)\n\n@[protected] lemma bottom_join_right (b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ) : \n  rec_bottom l b r 1 = rec_right b r t 0:=\nbegin\n  rw rec_bottom, rw rec_right, repeat {rw line_segment,}, \n  simp, ring_nf,\nend \n\ndef rec_bottomright (b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ) :=\n  path_concatenation (bottom_join_right b r t l) \n\n@[protected] lemma top_join_left (b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ) : \n  rec_top r t l 1 = rec_left t l b 0:=\nbegin\n  rw rec_top, rw rec_left, repeat {rw line_segment,}, \n  simp, ring_nf,\nend \n\ndef rec_topleft (b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ) :=\n  path_concatenation (top_join_left b r t l) \n\n@[protected] lemma br_join_tl (b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ) :\n  rec_bottomright b r t l 1 = rec_topleft b r t l 0 :=\nbegin\n  rw [rec_bottomright, rec_topleft],\n  rw path_concatenation_endpoint _,\n  rw rec_right, rw path_concatenation, simp,\n  rw rec_top, repeat {rw line_segment,}, simp, ring_nf,\nend\n\ndef rectangle (b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ) := \n  path_concatenation (br_join_tl b r t l) \n\nlemma center_in_interior_rectangle{c:ℂ}\n{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\nc ∈ (set.Ioo l r ×ℂ set.Ioo b t) :=\nbegin\n  unfold set.re_prod_im,\n  simp, split, split,\n  exact lc, exact cr, split,\n  exact bc, exact ct,\nend\n\nlemma center_in_interior_rectangle_iff {c:ℂ}\n{b r t l:ℝ}: c ∈ (set.Ioo l r ×ℂ set.Ioo b t) ↔\n((l < c.re ∧ c.re < r)∧ b < c.im ∧ c.im < t ) :=\nbegin\n  split,\n  intros c_in,\n  unfold set.re_prod_im at c_in,\n  simp at c_in, exact c_in,\n  intros in_cond,\n  exact center_in_interior_rectangle (in_cond.2.1) \n    (in_cond.2.2) (in_cond.1.1) (in_cond.1.2),\nend\n\nlemma point_in_closure_rectangle{c:ℂ}\n{b r t l:ℝ}(bc: b ≤ c.im) (ct: c.im ≤ t)\n(lc: l ≤ c.re) (cr: c.re ≤ r):\nc ∈ (set.interval l r ×ℂ set.interval b t) :=\nbegin \n  have bt:b≤ t:= le_trans bc ct,\n  have lr:l≤ r:= le_trans lc cr,\n  unfold set.re_prod_im,\n  simp, split, split,\n  rw min_eq_left lr, exact lc,\n  rw max_eq_right lr, exact cr,\n  split, rw min_eq_left bt, exact bc,\n  rw max_eq_right bt, exact ct, \nend\n\nlemma interior_rectangle_open(b r t l:ℝ): \nis_open (set.Ioo l r ×ℂ set.Ioo b t) :=\nis_open.re_prod_im is_open_Ioo is_open_Ioo\n\nlemma interior_rectangle_sub_closure(b r t l:ℝ):\n(set.Ioo l r ×ℂ set.Ioo b t)⊆ \n(set.interval l r ×ℂ set.interval b t) :=\nbegin\n  unfold set.re_prod_im,\n  have lr : set.Ioo l r ⊆ set.interval l r := \n    Ioo_subset_interval,\n  have bt : set.Ioo b t ⊆ set.interval b t := \n    Ioo_subset_interval, \n  intro, simp,\n  intros ll rr bb tt, split,\n  have x_re_in:x.re∈ set.Ioo l r := \n    by {unfold set.Ioo, simp, split, exact ll, exact rr,},\n  exact lr x_re_in,\n  have x_im_in:x.im∈ set.Ioo b t:=\n    by {unfold set.Ioo, simp, split, exact bb, exact tt,},\n  exact bt x_im_in,\nend\n\nlemma interior_rectangle_neighborhood {c: ℂ}\n{b r t l:ℝ} (hin: c ∈ (set.Ioo l r ×ℂ set.Ioo b t)):\n(set.Ioo l r ×ℂ set.Ioo b t) ∈ (nhds c) :=\nbegin\n  rw mem_nhds_iff,\n  use (set.Ioo l r ×ℂ set.Ioo b t),\n  split, exact rfl.subset,\n  split, exact interior_rectangle_open b r t l,\n  exact hin,\nend\n\nlemma interior_rectangle_neighborhood' {c: ℂ}\n{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\n(set.Ioo l r ×ℂ set.Ioo b t) ∈ (nhds c) :=\n  interior_rectangle_neighborhood \n  (center_in_interior_rectangle bc ct lc cr)\n\nlemma closure_rectangle_neighborhood {c: ℂ}\n{b r t l:ℝ} (hin: c ∈ (set.Ioo l r ×ℂ set.Ioo b t) ):\n(set.interval l r ×ℂ set.interval b t) ∈ (nhds c) :=\nbegin\n  rw mem_nhds_iff,\n  use (set.Ioo l r ×ℂ set.Ioo b t),\n  split, exact interior_rectangle_sub_closure b r t l,\n  split, exact interior_rectangle_open b r t l,\n  exact hin,\nend\n\nlemma closure_rectangle_neighborhood' {c: ℂ}\n{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\n(set.interval l r ×ℂ set.interval b t) ∈ (nhds c) :=\n  closure_rectangle_neighborhood \n  (center_in_interior_rectangle bc ct lc cr)\n\nlemma image_rec_bottom {l:ℝ}(b:ℝ){r:ℝ}(lr:l≤ r):\nset.image (rec_bottom l b r) (set.interval 0 1)\n⊆  {z:ℂ | l≤ z.re ∧ z.re≤ r ∧ z.im = b} :=\nbegin\n  unfold rec_bottom, unfold line_segment, \n  simp, unfold set.Icc, simp,\n  intros a a_ge a_le, split, \n  {\n    apply mul_nonneg,\n    simp, exact lr, exact a_ge,\n  },\n  {\n    have temp: (r-l)*a≤ r-l :=\n      by {apply mul_nonneg_le_one_le, \n      simp, exact lr, exact rfl.ge, \n      exact a_ge, exact a_le,},\n    have temp':=add_le_add_right temp l,\n    simp at temp', exact temp',\n  },\nend\n\nlemma image_rec_right {b:ℝ}(r:ℝ){t:ℝ}(bt:b≤ t):\nset.image (rec_right b r t) (set.interval 0 1)\n⊆  {z:ℂ | b≤ z.im ∧ z.im≤ t ∧ z.re = r} :=\nbegin\n  unfold rec_right, unfold line_segment, \n  simp, unfold set.Icc, simp,\n  intros a a_ge a_le, split, \n  {\n    apply mul_nonneg,\n    simp, exact bt, exact a_ge,\n  },\n  {\n    have temp: (t-b)*a≤ t-b :=\n      by {apply mul_nonneg_le_one_le, \n      simp, exact bt, exact rfl.ge, \n      exact a_ge, exact a_le,},\n    have temp':=add_le_add_right temp b,\n    simp at temp', exact temp',\n  },\nend\n\nlemma image_rec_top {r:ℝ}(t:ℝ){l:ℝ}(lr:l≤ r):\nset.image (rec_top r t l) (set.interval 0 1)\n⊆  {z:ℂ | l≤ z.re ∧ z.re≤ r ∧ z.im = t} :=\nbegin\n  unfold rec_top, unfold line_segment, \n  simp, unfold set.Icc, simp,\n  intros a a_ge a_le, split, \n  {\n    have temp: (r-l)*a≤ r-l :=\n      by {apply mul_nonneg_le_one_le, \n      simp, exact lr, exact rfl.ge, \n      exact a_ge, exact a_le,},\n    have temp_m: -(r-l)≤ -((r-l)*a):=neg_le_neg temp,\n    have temp':=add_le_add_right temp_m r,\n    have rwl : -(r - l) + r = l:= by ring_nf,\n    have rwr : -((r - l) * a) + r = (l - r) * a + r :=by ring_nf,\n    rw [rwl, rwr] at temp', exact temp',\n  },\n  {\n    apply mul_nonpos_of_nonpos_of_nonneg,\n    simp, exact lr, exact a_ge,\n  },\nend\n\nlemma image_rec_left {t:ℝ}(l:ℝ){b:ℝ}(bt:b≤ t):\nset.image (rec_left t l b) (set.interval 0 1)\n⊆  {z:ℂ | b≤ z.im ∧ z.im≤ t ∧ z.re = l} :=\nbegin\n  unfold rec_left, unfold line_segment, \n  simp, unfold set.Icc, simp,\n  intros a a_ge a_le, split, \n  {\n    have temp: (t-b)*a≤ t-b :=\n      by {apply mul_nonneg_le_one_le, \n      simp, exact bt, exact rfl.ge, \n      exact a_ge, exact a_le,},\n    have temp_m: -(t-b)≤ -((t-b)*a):=neg_le_neg temp,\n    have temp':=add_le_add_right temp_m t,\n    have rwl : -(t - b) + t = b:= by ring_nf,\n    have rwr : -((t - b) * a) + t = (b - t) * a + t :=by ring_nf,\n    rw [rwl, rwr] at temp', exact temp',\n  },\n  {\n    apply mul_nonpos_of_nonpos_of_nonneg,\n    simp, exact bt, exact a_ge,\n  },\nend\n\nlemma image_rectangle'{b r t l:ℝ}(bt: b≤ t)(lr: l≤ r):\nset.image (rectangle b r t l) (set.interval 0 1)=\n((set.image (rec_bottom l b r) (set.interval 0 1))∪ \n(set.image (rec_right b r t) (set.interval 0 1))) ∪ \n((set.image (rec_top r t l) (set.interval 0 1))∪\n(set.image (rec_left t l b) (set.interval 0 1))):=\nbegin\n  unfold rectangle,\n  rw path_concatenation_image (br_join_tl b r t l),\n  rw [rec_bottomright, rec_topleft],\n  rw path_concatenation_image (bottom_join_right b r t l),\n  rw path_concatenation_image (top_join_left b r t l),\nend\n\nlemma image_rectangle_sub_closure{b r t l:ℝ}\n(bt: b≤ t)(lr: l≤ r):\nset.image (rectangle b r t l) (set.interval 0 1)\n⊆ (set.interval l r ×ℂ set.interval b t) :=\nbegin\n  rw image_rectangle' bt lr,\n  apply set.union_subset,\n  apply set.union_subset,\n  {\n    intros x x_in,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_bottom b lr) x_in, \n    simp at x_in', \n    apply point_in_closure_rectangle,\n    exact eq.ge x_in'.2.2,\n    rw x_in'.2.2, exact bt,\n    exact x_in'.1, exact x_in'.2.1,\n  },\n  {\n    intros x x_in,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_right r bt) x_in, \n    simp at x_in', \n    apply point_in_closure_rectangle,\n    exact x_in'.1, exact x_in'.2.1,\n    rw x_in'.2.2, exact lr,\n    exact (eq.symm x_in'.2.2).ge,\n  },\n  apply set.union_subset,\n  {\n    intros x x_in,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_top t lr) x_in, \n    simp at x_in', \n    apply point_in_closure_rectangle,\n    rw x_in'.2.2, exact bt,\n    exact (eq.symm x_in'.2.2).ge,\n    exact x_in'.1, exact x_in'.2.1,\n  },\n  {\n    intros x x_in,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_left l bt) x_in, \n    simp at x_in', \n    apply point_in_closure_rectangle,\n    exact x_in'.1, exact x_in'.2.1,\n    exact eq.ge x_in'.2.2,\n    rw x_in'.2.2, exact lr,\n  },\nend\n\nlemma image_rectangle_sub_compl_center{c: ℂ}\n{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\nset.image (rectangle b r t l) (set.interval 0 1) ⊆ {c}ᶜ :=\nbegin\n  have bt: b≤ t:= le_of_lt (lt_trans bc ct),\n  have lr: l≤ r:= le_of_lt (lt_trans lc cr),\n  rw image_rectangle' bt lr,\n  rw set.union_subset_iff, split,\n  rw set.union_subset_iff, split,\n  {\n    intros x x_in, simp, intro x_c,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_bottom b lr) x_in, \n    simp at x_in', rw x_c at x_in',\n    rw x_in'.2.2 at bc, simp at bc, exact bc,\n  },\n  {\n    intros x x_in, simp, intro x_c,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_right r bt) x_in, \n    simp at x_in', rw x_c at x_in',\n    rw x_in'.2.2 at cr, simp at cr, exact cr,\n  },\n  rw set.union_subset_iff, split,\n  {\n    intros x x_in, simp, intro x_c,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_top t lr) x_in, \n    simp at x_in', rw x_c at x_in',\n    rw x_in'.2.2 at ct, simp at ct, exact ct,\n  },\n  {\n    intros x x_in, simp, intro x_c,\n    have x_in':=set.mem_of_subset_of_mem \n      (image_rec_left l bt) x_in, \n    simp at x_in', rw x_c at x_in',\n    rw x_in'.2.2 at lc, simp at lc, exact lc,\n  },\nend\n\nlemma image_rectangle_sub_closure_inter_compl_center\n{c: ℂ}{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\nset.image (rectangle b r t l) (set.interval 0 1) ⊆ \n(set.interval l r ×ℂ set.interval b t) ∩ {c}ᶜ :=\nbegin\n  rw set.subset_inter_iff, split,\n  exact image_rectangle_sub_closure \n    (le_of_lt (lt_trans bc ct)) (le_of_lt (lt_trans lc cr)),\n  exact image_rectangle_sub_compl_center bc ct lc cr,\nend\n\n@[protected] lemma rec_bottomright_continuous_on(b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ):\ncontinuous_on (rec_bottomright b r t l) (set.interval 0 1):=\npath_concatenation_continuous_on \n(bottom_join_right b r t l)\n(line_is_continuous_on (l+b*complex.I) (r+b*complex.I))\n(line_is_continuous_on (r+b*complex.I) (r+t*complex.I))\n\n@[protected] lemma rec_topleft_continuous_on(b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ):\ncontinuous_on (rec_topleft b r t l) (set.interval 0 1):=\npath_concatenation_continuous_on \n(top_join_left b r t l)\n(line_is_continuous_on (r+t*complex.I) (l+t*complex.I))\n(line_is_continuous_on (l+t*complex.I) (l+b*complex.I))\n\nlemma rectangle_continuous_on(b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ):\ncontinuous_on (rectangle b r t l) (set.interval 0 1):=\npath_concatenation_continuous_on \n(br_join_tl b r t l)\n(rec_bottomright_continuous_on b r t l)\n(rec_topleft_continuous_on b r t l)\n\n@[protected] lemma deriv_rec_bottomright_integrable(b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ):\ninterval_integrable (deriv (rec_bottomright b r t l))\nmeasure_theory.measure_space.volume 0 1 :=\npath_concatenation_deriv_integrable\n(bottom_join_right b r t l)\n(deriv_line_integrable (l+b*complex.I) (r+b*complex.I))\n(deriv_line_integrable (r+b*complex.I) (r+t*complex.I))\n\n@[protected] lemma deriv_rec_topleft_integrable(b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ):\ninterval_integrable (deriv (rec_topleft b r t l))\nmeasure_theory.measure_space.volume 0 1 :=\npath_concatenation_deriv_integrable\n(top_join_left b r t l)\n(deriv_line_integrable (r+t*complex.I) (l+t*complex.I))\n(deriv_line_integrable (l+t*complex.I) (l+b*complex.I))\n\nlemma deriv_rectangle_integrable(b:ℝ)(r:ℝ)(t:ℝ)(l:ℝ):\ninterval_integrable (deriv (rectangle b r t l))\nmeasure_theory.measure_space.volume 0 1 :=\npath_concatenation_deriv_integrable\n(br_join_tl b r t l)\n(deriv_rec_bottomright_integrable b r t l)\n(deriv_rec_topleft_integrable b r t l)\n\n/-! Part III. Define integrals along rectangles\n\n- # Integral along Rectangles\n-/\n\ndef complex_affine (α:ℂ)(c:ℂ):ℂ→ ℂ:=λz, α*z+c\n\nlemma contour_integral_under_affine (f:ℂ → E)\n(L:ℝ → ℂ)(α:ℂ)(c:ℂ):\n  contour_integral f ((complex_affine α c)∘ L) = \n  α • contour_integral (f ∘ (complex_affine α c)) L :=\nbegin\n  repeat {rw contour_integral},\n  rw complex_affine,\n  simp,\n  rw smul_integral_convert,\n  have l1: (λ t:ℝ, (α * deriv L t) • f (α * L t + c))\n    = (λ t:ℝ, α •  deriv L t • f (α * L t + c)) :=\n    by {ext1, rw smul_assoc_convert,},\n  rw l1,\nend\n\n/- The contour integral along the sgements with both endpoints being real numbers is equal to the corresponding real integral. -/\nlemma integral_along_reals (f:ℂ → E)(a:ℝ)(b:ℝ):\n  contour_integral f (line_segment a b) = \n  ∫ (t: ℝ ) in a..b, f(t):=\nbegin\n  unfold contour_integral,\n  rw [deriv_of_line, constant_path, line_segment],\n  simp,\n  have h0 : ↑(b - a) = (b : ℂ) - (a : ℂ) := by simp,\n  rw ←h0,\n  cases decidable.em (b ≠ a) with heq hneq,\n  {\n    have h1 : (λ (x : ℝ), f (↑(b - a) * (x : ℂ) + (a : ℂ))) = (λ (x : ℝ), ((f ∘ λ (y : ℝ), (y : ℂ)) ((b - a) * x + a))) := by simp,\n    have h2 : (λ (t : ℝ), f (t : ℂ)) = (λ (x : ℝ), ((f ∘ λ (y : ℝ), (y : ℂ)) x)) := by simp,\n    rw [h1, h2],\n    let g := (f ∘ λ (y : ℝ), (y : ℂ)),\n    have h3 : g = (f ∘ λ (y : ℝ), (y : ℂ)) := rfl,\n    rw [←h3],\n    have h4 : ∫ (x : ℝ) in a..b, g x = ∫ (x : ℝ) in (b - a) * 0 + a..(b - a) * 1 + a, g x := by simp,\n    rw h4,\n    rw ←interval_integral.smul_integral_comp_mul_add g (b - a) a,\n    have h5 : ∫ (x : ℝ) in 0..1, g ((b - a) * x + a) = ∫ (x : ℝ) in 0..1, g ((b - a) * x + a) := rfl,\n    rw smul_type_convert (b-a) ∫ (x : ℝ) in 0..1, g ((b - a) * x + a),\n  },\n  {\n    simp at hneq,\n    rw hneq,\n    simp,\n  }\nend \n\nlemma integral_along_horizontal_line (f:ℂ → E)(a:ℝ)(b:ℝ)(c:ℝ):\n  contour_integral f (line_segment (a+c*complex.I) (b+c*complex.I)) = \n  ∫ (t: ℝ) in a..b, f(t+c*complex.I) :=\nbegin\n  have hr: ∫ (t: ℝ) in a..b, f(t+c*complex.I) =\n    ∫ (t: ℝ) in a..b, (f∘ (complex_affine 1 (c*complex.I))) t:=\n    by {rw complex_affine,simp,},\n  have hl: (line_segment (↑a + ↑c * complex.I) (↑b + ↑c * complex.I))\n    = (complex_affine 1 (c*complex.I)) ∘ (line_segment a b) :=\n    by {rw complex_affine, repeat {rw line_segment,}, \n        simp, ext1, simp, ring_nf,},\n  rw hr, rw hl,\n  rw contour_integral_under_affine _ _ _,\n  rw integral_along_reals _ a b,\n  simp,\nend\n\nlemma integral_along_vertical_line (f:ℂ → E)(a:ℝ)(b:ℝ)(c:ℝ):\n  contour_integral f (line_segment (c+a*complex.I) (c+b*complex.I)) = \n  complex.I • ∫ (t: ℝ) in a..b, f(c+t*complex.I) :=\nbegin\n  have hr: ((λ t:ℝ, f (↑c + ↑t * complex.I)):ℝ → E)\n  = ((λt:ℝ, (f ∘ (complex_affine complex.I c)) t):ℝ→ E) := \n    by {rw complex_affine, simp, ext1, ring_nf,},\n  have hl:(line_segment (↑c + ↑a * complex.I) (↑c + ↑b * complex.I))\n    = (complex_affine complex.I c) ∘ (line_segment a b) :=\n    by {repeat {rw complex_affine,}, repeat {rw line_segment,}, \n    simp, ext1, simp, ring_nf,},\n  rw hr, rw hl,\n  rw contour_integral_under_affine _ _ _,\n  rw integral_along_reals _ a b,\nend\n\nlemma integral_along_rectangle_bottom(f:ℂ → E)\n(l:ℝ)(b:ℝ)(r:ℝ):\n  contour_integral f (rec_bottom l b r) \n  = ∫ (x: ℝ) in l..r, f(x+b*complex.I) :=\n  integral_along_horizontal_line f l r b\n\nlemma integral_along_rectangle_right(f:ℂ → E)\n(b:ℝ)(r:ℝ)(t:ℝ):\n  contour_integral f (rec_right b r t) \n  = complex.I • ∫ (x: ℝ) in b..t, f(r+x*complex.I) :=\n  integral_along_vertical_line f b t r\n\nlemma integral_along_rectangle_top(f:ℂ → E)\n(r:ℝ)(t:ℝ)(l:ℝ):\n  contour_integral f (rec_top r t l) \n  = - ∫ (x: ℝ) in l..r, f(x+t*complex.I) :=\n  by { unfold rec_top,\n       rw integral_along_horizontal_line f r l t,\n       rw interval_integral.integral_symm, }\n\nlemma integral_along_rectangle_left(f:ℂ → E)\n(t:ℝ)(l:ℝ)(b:ℝ):\n  contour_integral f (rec_left t l b) \n  = - complex.I • ∫ (x: ℝ) in b..t, f(l+x*complex.I) :=\n  by { unfold rec_left,\n       rw integral_along_vertical_line f t b l,\n       rw interval_integral.integral_symm, simp, }\n\n@[protected] lemma integral_along_rectangle_bottomright' \n{f:ℂ → E}{b r t l: ℝ}\n(hf: continuous_on f \n  (set.image (rec_bottomright b r t l) (set.interval 0 1))):\n  contour_integral f (rec_bottomright b r t l)\n  = (contour_integral f (rec_bottom l b r))\n  + (contour_integral f (rec_right b r t)):=\ncontour_integral_along_piecewise_path' hf \n(rec_bottomright_continuous_on b r t l)\n(deriv_rec_bottomright_integrable b r t l)\n\n@[protected] lemma integral_along_rectangle_topleft' \n{f:ℂ → E}{b r t l: ℝ}\n(hf: continuous_on f \n  (set.image (rec_topleft b r t l) (set.interval 0 1))):\n  contour_integral f (rec_topleft b r t l)\n  = (contour_integral f (rec_top r t l))\n  + (contour_integral f (rec_left t l b)):=\ncontour_integral_along_piecewise_path' hf \n(rec_topleft_continuous_on b r t l)\n(deriv_rec_topleft_integrable b r t l)\n\ntheorem integral_along_rectangle'\n{f:ℂ → E}{b r t l: ℝ}\n(hf: continuous_on f \n  (set.image (rectangle b r t l) (set.interval 0 1))):\n  contour_integral f (rectangle b r t l)\n  = (((contour_integral f (rec_bottom l b r))\n  + (contour_integral f (rec_top r t l)))\n  + (contour_integral f (rec_right b r t)))\n  + (contour_integral f (rec_left t l b)) :=\nbegin\n  unfold rectangle,\n  rw contour_integral_along_piecewise_path' hf \n     (rectangle_continuous_on b r t l)\n     (deriv_rectangle_integrable b r t l),\n  have hfbr:=continuous_on.mono hf \n       (path_concatenation_image_left_subset (br_join_tl b r t l)),\n  have hftl:=continuous_on.mono hf \n       (path_concatenation_image_right_subset (br_join_tl b r t l)),\n  rw integral_along_rectangle_bottomright' hfbr,\n  rw integral_along_rectangle_topleft' hftl,\n  rw ← add_assoc (contour_integral f (rec_bottom l b r) + \n  contour_integral f (rec_right b r t)) _ _,\n  rw add_assoc _ (contour_integral f (rec_right b r t)) \n  (contour_integral f (rec_top r t l) ),\n  rw add_comm (contour_integral f (rec_right b r t)) \n  (contour_integral f (rec_top r t l) ),\n  rw ← add_assoc (contour_integral f (rec_bottom l b r)) _ _,\nend\n\ntheorem integral_along_rectangle\n{f:ℂ → E}{b r t l: ℝ}\n(hf: continuous_on f \n  (set.image (rectangle b r t l) (set.interval 0 1))):\n  contour_integral f (rectangle b r t l)\n  = (((∫ (x: ℝ) in l..r, f(x+b*complex.I))\n  - (∫ (x: ℝ) in l..r, f(x+t*complex.I)))\n  + (complex.I • ∫ (x: ℝ) in b..t, f(r+x*complex.I)))\n  - (complex.I • ∫ (x: ℝ) in b..t, f(l+x*complex.I)) :=\nbegin\n  rw integral_along_rectangle' hf,\n  rw integral_along_rectangle_bottom,\n  rw integral_along_rectangle_top,\n  rw integral_along_rectangle_right,\n  rw integral_along_rectangle_left,\n  simp,\nend\n\n/-! Part IV. Formalize the Cauchy theorem on rectangles. \n\n- # Cauchy Theorem on Rectangles\n-/\n\ntheorem Cauchy_Goursat_rectangle_countable {f : ℂ → E} \n{b r t l:ℝ}(bt: b≤ t)(lr: l≤ r) \n{s: set ℂ}(hs: s.countable)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t)) \n(Hd : ∀ (x : ℂ), x ∈ (set.Ioo l r ×ℂ set.Ioo b t) \\ s \n→ differentiable_at ℂ f x) :\ncontour_integral f (rectangle b r t l) = 0 :=\nbegin\n  have hf: continuous_on f \n       (set.image (rectangle b r t l) (set.interval 0 1)):=\n       continuous_on.mono Hc (image_rectangle_sub_closure bt lr),\n  rw integral_along_rectangle hf,\n  let z:ℂ:={re:=l,im:=b},\n  let w:ℂ:={re:=r,im:=t},\n  have z_re : l = z.re := rfl,\n  have w_re : r = w.re := rfl,\n  have z_im : b = z.im := rfl,\n  have w_im : t = w.im := rfl,\n  have hl : l = linear_order.min z.re w.re := \n    by {rw [←z_re, ←w_re], symmetry, exact min_eq_left lr,},\n  have hr : r = linear_order.max z.re w.re := \n    by {rw [←z_re, ←w_re], symmetry, exact max_eq_right lr,},\n  have hb : b = linear_order.min z.im w.im := \n    by {rw [←z_im, ←w_im], symmetry, exact min_eq_left bt,},\n  have ht : t = linear_order.max z.im w.im := \n    by {rw [←z_im, ←w_im], symmetry, exact max_eq_right bt,},\n  rw [z_re, w_re, z_im, w_im] at Hc,\n  rw [hl, hr, hb, ht] at Hd,\n  have t:=complex.integral_boundary_rect_eq_zero_of_differentiable_on_off_countable \n           f z w s hs Hc Hd,\n  exact t,\nend\n\ntheorem Cauchy_Goursat_rectangle_singleton {f : ℂ → E} \n(c: ℂ) {b r t l:ℝ}(bt: b≤ t)(lr: l≤ r)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t)) \n(Hd : ∀ (x : ℂ), x ∈ (set.Ioo l r ×ℂ set.Ioo b t) \\ {c} \n→ differentiable_at ℂ f x) :\ncontour_integral f (rectangle b r t l) = 0 :=\n  Cauchy_Goursat_rectangle_countable \n    bt lr (set.to_countable {c}) Hc Hd\n\ntheorem Cauchy_Goursat_rectangle{f : ℂ → E} \n{b r t l:ℝ}(bt: b≤ t)(lr: l≤ r)\n(Hc : continuous_on f (set.interval l r ×ℂ \n  set.interval b t)) \n(Hd : ∀ (x : ℂ), x ∈ (set.Ioo l r ×ℂ set.Ioo b t) \n→ differentiable_at ℂ f x) :\ncontour_integral f (rectangle b r t l) = 0 :=\nbegin\n  apply Cauchy_Goursat_rectangle_singleton 0 bt lr Hc,\n  intros x x_in, simp at x_in,\n  exact Hd x x_in.1,\nend\n\n/-! Part V. Formalize the Cauchy integral formula on rectangles. \n\n- # Cauchy Integral Formula on Rectangles\n-/\n\nlemma dslope_eq_on{f : ℂ → E}{c: ℂ}\n{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\nset.eq_on (dslope f c) (λz:ℂ, (z-c)⁻¹•f(z) - (z-c)⁻¹•f(c)) \n(set.image (rectangle b r t l) (set.interval 0 1)):=\nbegin\n  apply set.eq_on.mono \n    (image_rectangle_sub_compl_center bc ct lc cr),\n  have func_eq:(λz:ℂ, (z-c)⁻¹•f(z) - (z-c)⁻¹•f(c))=\n    slope f c := \n    by {ext1, rw slope_def_module f c x, rw smul_sub,},\n  rw func_eq,\n  exact eq_on_dslope_slope f c,\nend\n\nlemma dslope_continuous_on {f : ℂ → E}{c: ℂ}\n{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t))\n(Hd : differentiable_on ℂ f (set.Ioo l r ×ℂ set.Ioo b t)):\ncontinuous_on (dslope f c) (set.interval l r ×ℂ set.interval b t):=\nbegin\n  rw continuous_on_dslope \n    (closure_rectangle_neighborhood' bc ct lc cr),\n  split,\n  exact Hc,\n  exact differentiable_on.differentiable_at Hd \n    (interior_rectangle_neighborhood' bc ct lc cr),\nend\n\nlemma dslope_differentiable_at {f : ℂ → E}{c: ℂ}\n{b r t l:ℝ}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t))\n(Hd : differentiable_on ℂ f (set.Ioo l r ×ℂ set.Ioo b t)):\n∀ (x : ℂ), x ∈ set.Ioo l r ×ℂ set.Ioo b t \\ {c} → \ndifferentiable_at ℂ (dslope f c) x :=\nbegin\n  intros x x_in,\n  simp at x_in,\n  rw differentiable_at_dslope_of_ne x_in.2,\n  have hd:=Hd x x_in.1,\n  exact differentiable_within_at.differentiable_at hd\n    (interior_rectangle_neighborhood x_in.1),\nend\n\nlemma dslope_zero_integral {f : ℂ → E} {c: ℂ}\n{b r t l:ℝ} (bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t))\n(Hd : differentiable_on ℂ f (set.Ioo l r ×ℂ set.Ioo b t)):\ncontour_integral (dslope f c) (rectangle b r t l) = 0 :=\nbegin\n  have b_lt_t : b<t := lt_trans bc ct,\n  have l_lt_r : l<r := lt_trans lc cr,\n  have bt: b≤ t:= le_of_lt b_lt_t,\n  have lr: l≤ r:= le_of_lt l_lt_r,\n  apply Cauchy_Goursat_rectangle_singleton c bt lr,\n  exact dslope_continuous_on bc ct lc cr Hc Hd,\n  exact dslope_differentiable_at bc ct lc cr Hc Hd,\nend\n\nlemma part_of_dslope_continuous_on{f : ℂ → E} {c: ℂ}\n{b r t l:ℝ} (bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t)):\ncontinuous_on ((λ (z : ℂ), (z - c)⁻¹) • f) \n(rectangle b r t l '' set.interval 0 1) :=\nbegin \n  have hr: continuous_on (λ (z : ℂ), (z - c)⁻¹) \n    (rectangle b r t l '' set.interval 0 1) := \n    continuous_on.mono (reciprocal_continuous_on c)\n      (image_rectangle_sub_compl_center bc ct lc cr),\n  have ss :(set.interval l r ×ℂ set.interval b t) ∩ {c}ᶜ\n  ⊆ (set.interval l r ×ℂ set.interval b t) := \n  (set.interval l r ×ℂ set.interval b t).inter_subset_left {c}ᶜ,\n  have hf': continuous_on f \n    ((set.interval l r ×ℂ set.interval b t) ∩ {c}ᶜ) :=\n    continuous_on.mono Hc ss,\n  have hf: continuous_on f \n    (rectangle b r t l '' set.interval 0 1) :=\n    continuous_on.mono hf'\n    (image_rectangle_sub_closure_inter_compl_center bc ct lc cr),\n  have rf:= continuous_on.prod_map hr hf,\n  exact continuous_on.smul hr hf,\nend\n\nlemma Cauchy_integral_formula_rectangle_pre{f : ℂ → E} {c: ℂ}\n{b r t l:ℝ} (bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t))\n(Hd : differentiable_on ℂ f (set.Ioo l r ×ℂ set.Ioo b t)):\ncontour_integral (λz:ℂ, (z-c)⁻¹•f(z)) (rectangle b r t l)=\ncontour_integral (λz:ℂ, (z-c)⁻¹) (rectangle b r t l) • f(c):=\nbegin\n  rw ← contour_integral_smul_right _ _ (f(c)),\n  have func_eq:(λz:ℂ, (z-c)⁻¹•f(z) - (z-c)⁻¹•f(c))=\n  (λz:ℂ, (z-c)⁻¹•f(z))-(λz:ℂ, (z-c)⁻¹•f(c)):=\n    by {ext1, simp,},\n  have left_func:(λ (z : ℂ), (z - c)⁻¹ • f z) =\n  (λ (z : ℂ), (z - c)⁻¹) • f:=\n    by {ext1, simp,},\n  have right_func:(λ (z : ℂ), (z - c)⁻¹ • f c) =\n  (λ (z : ℂ), (z - c)⁻¹) • (λ (z:ℂ), f c) :=\n    by {ext1, simp,},\n  have int_z:=dslope_zero_integral bc ct lc cr Hc Hd,\n  rw contour_integral_congr (dslope_eq_on bc ct lc cr) at int_z,\n  rw func_eq at int_z,\n  have int_sub:contour_integral ((λ (z : ℂ), (z - c)⁻¹ • f z) - \n  λ (z : ℂ), (z - c)⁻¹ • f c) (rectangle b r t l) = \n  contour_integral (λ (z : ℂ), (z - c)⁻¹ • f z) (rectangle b r t l) - \n  contour_integral (λ (z : ℂ), (z - c)⁻¹ • f c) (rectangle b r t l):=\n    begin\n      apply contour_integral_sub',\n      {\n        rw left_func,\n        exact part_of_dslope_continuous_on bc ct lc cr Hc,\n      },\n      {\n        rw right_func,\n        apply part_of_dslope_continuous_on bc ct lc cr,\n        apply continuous.continuous_on,\n        exact continuous_const,\n        exact _inst_3,\n      },\n      {\n        exact rectangle_continuous_on b r t l,\n      },\n      {\n        exact deriv_rectangle_integrable b r t l,\n      },\n    end,\n  rw int_z at int_sub, \n  exact zero_exact int_sub,\n  exact _inst_3,\nend\n\nlemma log_comp_affine_continuous_on{a b:ℂ}{s:set ℝ}\n(ha: a ≠ 0)\n(h: ∀ (x:ℝ), x∈ s→ 0 < (a*x+b).re ∨ (a*x+b).im ≠ 0):\ncontinuous_on (λ (t : ℝ), (a⁻¹*complex.log (a*t + b))) s:=\nbegin\n  apply continuous_on.const_smul _ a⁻¹,\n  exact is_scalar_tower.has_continuous_const_smul,\n  apply continuous_on.clog,\n  exact continuous.continuous_on (affine_rtc_continuous a b), \n  exact h,\nend\n\nlemma log_comp_affine_has_deriv {a b:ℂ}{x:ℝ}\n(ha: a ≠ 0)(h: 0 < (a*x+b).re ∨ (a*x+b).im ≠ 0):\nhas_deriv_at (λ (t : ℝ), (a⁻¹*complex.log (a*t + b)))\n((a*x+b)⁻¹) x :=\nbegin \n  have funrw: (λ (t : ℝ), (a⁻¹*complex.log (a*t + b)))\n  =(λ (t : ℝ), (complex.log (a*t + b))*a⁻¹):= \n    by {ext1, rw mul_comm,},\n  rw funrw,\n  have axbrw: (a*x+b)⁻¹ = (a*(a*x+b)⁻¹)*a⁻¹:=\n    by {rw mul_comm _ (a*x+b)⁻¹, rw mul_assoc,\n        have a':a * a⁻¹=1:= div_self ha,\n        rw a', ring_nf,},\n  rw axbrw,\n  apply has_deriv_at.mul_const _ a⁻¹,\n  let f:ℝ→ ℂ:=λt:ℝ, (a*t+b),\n  have f_rw: (λ (y : ℝ), complex.log (a * y + b))\n  =(λ (t:ℝ), complex.log (f t)) :=\n    by {ext1, simp,},\n  have f'f_rw: (a * (a * ↑x + b)⁻¹) = a/f x:=\n    by {ring_nf,simp,left,rw mul_comm,},\n  rw [f_rw, f'f_rw],\n  apply has_deriv_at.clog_real,\n  simp,\n  have coe_comp: f=(λt:ℂ, a*t+b) ∘ (λ (t : ℝ), (t : ℂ)):=\n    by {ext1, simp,},\n  rw coe_comp,\n  have conc:has_deriv_at ((λ (t : ℂ), a * t + b) ∘ \n    λ (t : ℝ), ↑t) a x ↔ \n    has_deriv_at ((λ (t : ℂ), a * t + b) ∘ \n    λ (t : ℝ), ↑t) (a*1) x := by simp,\n  rw conc,\n  apply has_deriv_at.comp,\n  exact complex_affine_has_deriv a b _,\n  exact coe_has_deriv _,\n  exact h,\nend\n\nlemma integral_of_fraction'{a b:ℂ}{lef ref:ℝ}\n(ha: a ≠ 0)(hlr: lef ≤ ref)\n(h: ∀ (x:ℝ), (x∈ (set.Ioo lef ref)) → \n0 < (a*x+b).re ∨ (a*x+b).im ≠ 0)\n(hc:continuous_on  (λ x : ℝ, a⁻¹ * complex.log (a * x + b)) \n(set.Icc lef ref))\n(hii: interval_integrable (λ (y : ℝ), (a * ↑y + b)⁻¹) \nmeasure_theory.measure_space.volume lef ref):\n∫ (t: ℝ) in lef..ref, ((a*t+b)⁻¹) =\na⁻¹*(complex.log (a*ref + b)-complex.log(a*lef+b)):=\nbegin\n  rw mul_sub,\n  apply interval_integral.integral_eq_sub_of_has_deriv_at_of_le hlr,\n  exact hc,\n  intros x x_in,\n  have h':= h x x_in,\n  exact log_comp_affine_has_deriv ha h',\n  exact hii,\nend\n\nlemma integral_of_fraction{a b:ℂ}{lef ref:ℝ}\n(ha: a ≠ 0)(hlr: lef ≤ ref)\n(h: ∀ (x:ℝ), (x∈ (set.Icc lef ref)) → \n0 < (a*x+b).re ∨ (a*x+b).im ≠ 0):\n∫ (t: ℝ) in lef..ref, ((a*t+b)⁻¹) =\na⁻¹*(complex.log (a*ref + b)-complex.log(a*lef+b)):=\nbegin\n  apply integral_of_fraction' ha hlr,\n  intros x x_in,\n  exact h x (set.Ioo_subset_Icc_self x_in),\n  exact log_comp_affine_continuous_on ha h,\n  apply continuous_on.interval_integrable,\n  apply affine_rtc_continuous_on,\n  intros x x_in,\n  unfold set.interval at x_in,\n  have lef_rw:(min lef ref)=lef:= min_eq_left hlr,\n  have ref_rw:(max lef ref)=ref:= max_eq_right hlr,\n  rw [lef_rw, ref_rw] at x_in,\n  have h'':=h x x_in, intro f,\n  rw f at h'', \n  simp at h'', exact h'',\nend\n\nlemma integral_of_fraction_one{b:ℂ}{lef ref:ℝ}\n(hlr: lef < ref)\n(h: ∀ (x:ℝ), (x∈ (set.Icc lef ref)) → \n0 < ((x:ℂ)+b).re ∨ ((x:ℂ)+b).im ≠ 0):\n∫ (t: ℝ) in lef..ref, (((t:ℂ)+b)⁻¹) =\n(complex.log (ref + b)-complex.log(lef+b)) :=\nbegin\n  have one_ne_zero:(1:ℂ)≠ 0:=by simp,\n  have hlr':lef≤ ref:= le_of_lt hlr,\n  have h':∀ (x:ℝ), (x∈ (set.Icc lef ref)) → \n    0 < ((1:ℂ)*x+b).re ∨ ((1:ℂ)*x+b).im ≠ 0 :=\n    by {ring_nf,exact h,},\n  have lhs:∫ (t: ℝ) in lef..ref, (((t:ℂ)+b)⁻¹) =\n  ∫ (t: ℝ) in lef..ref, (((1:ℂ)*t+b)⁻¹):= by simp,\n  rw lhs, \n  rw integral_of_fraction one_ne_zero hlr' h',\n  simp,\nend\n\nlemma integral_of_fraction_I'{b:ℂ}{lef ref:ℝ}\n(hlr: lef < ref)\n(h: ∀ (x:ℝ), (x∈ (set.Ioo lef ref)) → \n0 < (complex.I*x+b:ℂ).re ∨ (complex.I*x+b:ℂ).im ≠ 0)\n(hc:continuous_on  (λ x : ℝ, complex.log (complex.I * x + b)) \n(set.Icc lef ref))\n(hii: interval_integrable (λ (y : ℝ), (complex.I * y + b)⁻¹) \nmeasure_theory.measure_space.volume lef ref):\ncomplex.I • ∫ (t: ℝ) in lef..ref, ((complex.I*t+b:ℂ)⁻¹) =\n(complex.log (complex.I * ref + b)) -\n(complex.log (complex.I * lef + b)) :=\nbegin\n  have i_ne_zero:complex.I≠ 0:=complex.I_ne_zero,\n  have hlr':lef≤ ref:= le_of_lt hlr,\n  have hc':continuous_on  (λ x : ℝ, \n    (complex.I)⁻¹*complex.log (complex.I * x + b)) \n    (set.Icc lef ref):=\n      by { have hcm:=\n      continuous_on.const_smul hc (complex.I)⁻¹,\n      simp, simp at hcm, exact hcm,}, \n  rw integral_of_fraction' i_ne_zero hlr' h hc' hii,\n  simp, rw ← mul_assoc, simp,\nend\n\nlemma integral_of_fraction_I{b:ℂ}{lef ref:ℝ}\n(hlr: lef < ref)\n(h: ∀ (x:ℝ), (x∈ (set.Icc lef ref)) → \n0 < (x*complex.I+b:ℂ).re ∨ (x*complex.I+b:ℂ).im ≠ 0):\ncomplex.I • ∫ (t: ℝ) in lef..ref, ((t*complex.I+b:ℂ)⁻¹) =\n(complex.log (ref*complex.I + b)) -\n(complex.log (lef*complex.I + b)) :=\nbegin\n  have i_ne_zero:complex.I≠ 0:=complex.I_ne_zero,\n  have hlr':lef≤ ref:= le_of_lt hlr,\n  have h':∀ (x:ℝ), (x∈ (set.Icc lef ref)) → \n    0 < (complex.I*x+b).re ∨ (complex.I*x+b).im ≠ 0 :=\n    by {ring_nf,exact h,},\n  have lhs:(λt:ℝ,(t*complex.I+b:ℂ)⁻¹) =\n    (λt:ℝ ,(complex.I*t+b)⁻¹):= \n    by {ext1,simp,rw mul_comm},\n  rw lhs, \n  rw integral_of_fraction i_ne_zero hlr' h',\n  simp, rw ← mul_assoc, simp,\n  rw mul_comm, rw mul_comm ↑lef complex.I,\nend\n\nlemma integral_of_reciprocal_on_bottom {c: ℂ}\n{l b r:ℝ} (bc: b < c.im) (lc: l < c.re) (cr: c.re < r):\ncontour_integral (λz:ℂ, (z-c)⁻¹) (rec_bottom l b r) = \ncomplex.log (r+b*complex.I-c) -\ncomplex.log (l+b*complex.I-c) :=\nbegin\n  have lr:l< r:= lt_trans lc cr,\n  rw integral_along_rectangle_bottom,\n  have lhs: (λx:ℝ,(↑x + ↑b * complex.I - c)⁻¹)=\n  (λx:ℝ,(↑x + (↑b * complex.I - c))⁻¹) := \n    by {ext1, rw← add_sub,}, rw lhs,\n  repeat {rw ← add_sub},\n  apply integral_of_fraction_one lr, \n  intros x x_in, rw add_sub,\n  simp, right, intro f,\n  exact (ne_of_lt bc) (zero_symm_exact f),\nend\n\nlemma integral_of_reciprocal_on_top {c: ℂ}\n{r t l:ℝ} (ct: c.im < t) (lc: l < c.re) (cr: c.re < r):\ncontour_integral (λz:ℂ, (z-c)⁻¹) (rec_top r t l) = \ncomplex.log (l+t*complex.I-c) -\ncomplex.log (r+t*complex.I-c) :=\nbegin\n  have lr:l< r:= lt_trans lc cr,\n  rw integral_along_rectangle_top,\n  rw neg_rewrite, simp,\n  have lhs: (λx:ℝ,(↑x + ↑t * complex.I - c)⁻¹)=\n  (λx:ℝ,(↑x + (↑t * complex.I - c))⁻¹) := \n    by {ext1, rw← add_sub,}, rw lhs,\n  repeat {rw ← add_sub},\n  apply integral_of_fraction_one lr, \n  intros x x_in, rw add_sub,\n  simp, right, intro f,\n  have f':= zero_symm_exact f,\n  rw f' at ct, simp at ct, exact ct,\nend\n\nlemma integral_of_reciprocal_on_right {c: ℂ}\n{b r t:ℝ} (bc: b < c.im) (ct: c.im < t) (cr: c.re < r) :\ncontour_integral (λz:ℂ, (z-c)⁻¹) (rec_right b r t) = \ncomplex.log (r+t*complex.I-c) -\ncomplex.log (r+b*complex.I-c) :=\nbegin\n  have bt : b< t:= lt_trans bc ct,\n  rw integral_along_rectangle_right,\n  have lhs: (λx:ℝ,(↑r + ↑x * complex.I - c)⁻¹)=\n  (λx:ℝ,( ↑x * complex.I +(↑r- c))⁻¹) := \n    by {ext1, ring_nf,}, rw lhs,\n  have rtc: ↑r + ↑t * complex.I - c =\n    ↑t * complex.I+ (↑r-c):= by ring_nf,\n  have rbc: ↑r + ↑b * complex.I - c =\n    ↑b * complex.I + (↑r - c) := by ring_nf,\n  rw [rtc, rbc],\n  apply integral_of_fraction_I bt,\n  intros x x_in, simp,\n  left, exact cr,\nend\n\n@[protected] lemma integrable_lxc_inv_bt{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ninterval_integrable (λ (x : ℝ), \n(complex.I * ↑x  + (↑l - c))⁻¹)\nmeasure_theory.measure_space.volume b t :=\nbegin\n  apply continuous_on.interval_integrable,\n  apply affine_rtc_continuous_on,\n  intros x x_in, intro fp, \n  have rp:(complex.I * ↑x + (↑l - c)).re=l-c.re:=\n    by simp,\n  rw fp at rp, simp at rp,\n  exact (ne_of_lt lc) (zero_exact rp),\nend\n\n@[protected] lemma integrable_lxc_inv_bcim{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ninterval_integrable (λ (x : ℝ), \n(complex.I * ↑x  + (↑l - c))⁻¹) \nmeasure_theory.measure_space.volume b c.im :=\nbegin\n  have bt: b< t:= (lt_trans bc ct),\n  apply interval_integrable.mono_set \n    (integrable_lxc_inv_bt bc ct lc),\n  unfold set.interval, \n  rw [min_eq_left_of_lt bc, min_eq_left_of_lt bt,\n    max_eq_right_of_lt bc, max_eq_right_of_lt bt],\n  exact set.Icc_subset_Icc_right (le_of_lt ct),\nend\n\n@[protected] lemma integrable_lxc_inv_cimt{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ninterval_integrable (λ (x : ℝ), \n(complex.I * ↑x  + (↑l - c))⁻¹) \nmeasure_theory.measure_space.volume c.im t :=\nbegin\n  have bt: b< t:= (lt_trans bc ct),\n  apply interval_integrable.mono_set \n    (integrable_lxc_inv_bt bc ct lc),\n  unfold set.interval, \n  rw [min_eq_left_of_lt ct, min_eq_left_of_lt bt,\n    max_eq_right_of_lt ct, max_eq_right_of_lt bt],\n  exact set.Icc_subset_Icc_left (le_of_lt bc),\nend\n\n@[protected] lemma integral_left_two_pieces{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ncontour_integral (λz:ℂ, (z-c)⁻¹) (rec_left t l b) \n= -(complex.I • ∫ (x: ℝ) in (c.im)..t, (l+x*complex.I-c)⁻¹)\n- (complex.I • ∫ (x: ℝ) in b..(c.im), (l+x*complex.I-c)⁻¹):=\nbegin\n  rw integral_along_rectangle_left,\n  have lhs:-complex.I • ∫ (x : ℝ) in b..t, \n  (↑l + ↑x * complex.I - c)⁻¹=-(complex.I • \n  ∫ (x : ℝ) in b..t, (↑l + ↑x * complex.I - c)⁻¹):=\n    by {simp,}, rw lhs,\n  have fr: (λ (x : ℝ), (↑l + ↑x * complex.I - c)⁻¹)\n  =(λ (x : ℝ), (complex.I * ↑x  + (↑l - c))⁻¹) :=\n    by {ext1,simp,ring_nf,}, rw fr,\n  rw neg_rewrite, simp, symmetry,\n  rw ← mul_add, simp, left,\n  exact interval_integral.integral_add_adjacent_intervals \n    (integrable_lxc_inv_bcim bc ct lc)\n    (integrable_lxc_inv_cimt bc ct lc),\nend\n\n@[protected] lemma crel{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\nc.re - l = complex.abs(l-c.re):=\nbegin\n  have cplx:complex.abs(l-c.re)= \n    complex.abs((l-c.re):ℝ):= by simp,\n  rw cplx, \n  have l_sub:(((l-c.re):ℝ):ℂ)=-(((c.re-l):ℝ):ℂ):= by simp,\n  rw l_sub, rw complex.abs_neg,\n  have c_sub:c.re-l≥ 0:=\n    by {simp,exact le_of_lt lc,},\n  exact (complex.abs_of_nonneg c_sub).symm,\nend\n\n@[protected] lemma lcre{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\n↑l - ↑(c.re)=complex.I*c.im+(l-c:ℂ) :=\nbegin\n  apply complex.ext,\n  simp, simp,\nend\n\n@[protected] lemma lcrearg{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\n(l - (c.re):ℂ).arg=real.pi :=\nbegin\n  rw complex.arg_eq_pi_iff, split,\n  simp, exact lc, simp,\nend\n\nlemma integral_on_lower_left{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\n∫ (x: ℝ) in b..(c.im), (l+x*complex.I-c:ℂ)⁻¹=\n(complex.I)⁻¹ *(real.log(c.re-l)-real.pi*complex.I-\ncomplex.log (l+b*complex.I-c)) :=\nbegin\n  rw mul_sub,\n  have lhs:(λx:ℝ,(↑l + ↑x * complex.I - c)⁻¹)=\n  (λx:ℝ,( complex.I * ↑x + (l - c))⁻¹) := \n    by {ext1, simp, ring_nf,}, rw lhs,\n  have rhs: ↑l + ↑b * complex.I - c = \n    complex.I * ↑b + (↑l - c) := by ring_nf, rw rhs,\n  let F:ℝ → ℂ:=λ (x : ℝ), \n    ite (x=c.im) (complex.I⁻¹ * \n    (↑(real.log (c.re - l)) - ↑real.pi * complex.I))\n    (complex.I⁻¹*complex.log (complex.I*x + (l-c))),\n  have Fx:∀x:ℝ, F x=ite (x=c.im) (complex.I⁻¹ * \n    (↑(real.log (c.re - l)) - ↑real.pi * complex.I))\n    (complex.I⁻¹*complex.log (complex.I*x + (l-c))):=\n    by {intro x,exact rfl,},\n  have Fcim: F c.im = (complex.I⁻¹ * \n    (↑(real.log (c.re - l)) - ↑real.pi * complex.I)):=\n    by {rw Fx c.im, simp,}, rw ← Fcim,\n  have Fb: F b = complex.I⁻¹ * \n    complex.log (complex.I * ↑b + (↑l - c)) :=\n    by {rw Fx b, rw if_neg (ne_of_lt bc),}, rw ← Fb,\n  have F_eq_on_Ico: set.eq_on \n    (λx:ℝ, complex.I⁻¹*complex.log (complex.I*x + (l-c))) \n    F (set.Ico b c.im):=\n    by {intros x x_in, simp at x_in,\n      have mh:=ne_of_lt x_in.2, rw Fx x,\n      rw if_neg mh,},\n  have F_eq_on_Ioo:=set.eq_on.mono \n    set.Ioo_subset_Ico_self F_eq_on_Ico,\n  apply interval_integral.integral_eq_sub_of_has_deriv_at_of_le \n    (le_of_lt bc),\n  {\n    intros x x_in,\n    by_cases x=c.im,\n    {\n      rw← continuous_within_at_diff_self ,\n      have iccico:(set.Icc b c.im \\ {x})=set.Ico b c.im:=\n        by { rw h, exact set.Icc_diff_right,},\n      rw iccico,\n      unfold continuous_within_at,\n      apply tendsto_nhds_within_congr F_eq_on_Ico,\n      rw h, rw Fcim, \n      have indu: (λ (x : ℝ), (λ (x : ℝ), complex.I⁻¹ * \n      complex.log (complex.I * ↑x + (↑l - c))) x) =\n      (λ (x : ℝ), complex.I⁻¹ * \n      complex.log (complex.I * ↑x + (↑l - c))):= by simp,\n      rw indu,\n      apply filter.tendsto.const_mul complex.I⁻¹,\n      have ftr:(λ (k : ℝ), complex.log (complex.I * ↑k + \n      (↑l - c)))= complex.log ∘ (λk:ℝ, (complex.I * ↑k + \n      (↑l - c))):= by simp, rw ftr,\n      apply filter.tendsto.comp,\n      rw crel bc ct lc,\n      apply complex.tendsto_log_nhds_within_im_neg_of_re_neg_of_im_zero,\n      simp, exact lc, \n      simp,\n      apply tendsto_nhds_within_of_tendsto_nhds_of_eventually_within\n        (λ (k : ℝ), complex.I * ↑k + (↑l - c)),\n      rw lcre bc ct lc,\n      apply filter.tendsto.add_const (l-c:ℂ),\n      apply filter.tendsto.const_mul complex.I,\n      have hs:=coe_differentiable.continuous.continuous_within_at.tendsto,\n      simp at hs, simp, exact hs,\n      simp, rw eventually_nhds_within_iff,\n      rw eventually_nhds_iff,\n      use set.univ, split,\n      intros new_x x_in_1 x_in_2, \n      simp at x_in_2, exact x_in_2.2,\n      split, exact is_open_univ,\n      exact set.mem_univ c.im,\n    },\n    {\n      have x_now_in:x∈ set.Ico b c.im := \n        by {unfold set.Ico, simp,\n          unfold set.Icc at x_in, simp at x_in,\n          split, exact x_in.1,\n          exact ne.lt_of_le h x_in.2,},\n      have Iconhd:set.Ico b c.im∈ nhds_within x \n        (set.Icc b c.im):= \n        by {rw mem_nhds_within, use (set.Iio c.im), split,\n        exact is_open_Iio, split,\n        exact set.Ico_subset_Iio_self x_now_in,\n        exact eq.subset Iio_inter_Icc,} ,\n      rw ← continuous_within_at_inter' Iconhd,\n      rw set.inter_comm,\n      rw set.inter_eq_left_iff_subset.2 \n        set.Ico_subset_Icc_self,\n      apply continuous_on.continuous_within_at _ x_now_in,\n      apply continuous_on.congr _ \n        (set.eq_on.symm F_eq_on_Ico),\n      apply log_comp_affine_continuous_on complex.I_ne_zero,\n      intros xx xx_in, simp, right, intro xf,\n      simp at xx_in,\n      exact (ne_of_lt xx_in.2) (zero_symm_exact xf),\n    },\n  },\n  {\n    intros x x_in,\n    apply has_eq_deriv_on_Ioo (le_of_lt bc) F_eq_on_Ioo x_in,\n    apply log_comp_affine_has_deriv complex.I_ne_zero,\n    simp, right, intro ff, simp at x_in,\n    exact (ne_of_lt x_in.2) (zero_symm_exact ff),\n  },\n  {\n    exact (integrable_lxc_inv_bcim bc ct lc),\n  },\nend\n\nlemma integral_on_upper_left{c:ℂ}{t l b:ℝ}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ncomplex.I • ∫ (x: ℝ) in (c.im)..t, (l+x*complex.I-c:ℂ)⁻¹=\n(complex.log (l+t*complex.I-c)-\nreal.log(c.re-l)-real.pi*complex.I) :=\nbegin\n  rw sub_sub,\n  have cc: (↑(real.log (c.re - l)) \n    + ↑real.pi * complex.I) = \n    complex.log ( complex.I * (c.im)+(l - c)) :=\n    by {rw ← lcre bc ct lc,\n        unfold complex.log, rw← crel bc ct lc,\n        simp, left, rw← lcrearg bc ct lc,},\n  rw cc,\n  have lhs:(λx:ℝ,(↑l + ↑x * complex.I - c)⁻¹)=\n  (λx:ℝ,( complex.I * ↑x + (l - c))⁻¹) := \n    by {ext1, simp, ring_nf,}, rw lhs,\n  have rhs: ↑l + ↑t * complex.I - c = \n    complex.I * ↑t + (↑l - c) := by ring_nf, rw rhs,\n  apply integral_of_fraction_I' ct,\n  {\n    intros x x_in,\n    simp, simp at x_in,\n    right, intro xcim,\n    exact (ne_of_lt x_in.1) (zero_symm_exact xcim).symm,\n  },\n  {\n    have func_rw: (λ (x : ℝ), \n      complex.log (complex.I * ↑x + (↑l - c))) = \n      (λ(z:ℂ), complex.log z)∘ \n      (λ(x:ℝ), (complex.I * ↑x + (↑l - c))) :=\n      by {ext1,simp,}, rw func_rw,\n    apply continuous_on.comp,\n    {\n      exact continuous_on_log_of_upper_plane,\n    },\n    {\n      exact (affine_rtc_continuous complex.I (l-c:ℂ)).continuous_on,\n    },\n    {\n      unfold set.maps_to, intros x x_in, \n      simp, simp at x_in, split,\n      exact x_in.1,\n      intro idd,\n      have iddre:(complex.I * ↑x + (↑l - c)).re=0:=\n        (congr_arg complex.re idd).trans rfl,\n      simp at iddre,\n      exact (ne_of_lt lc) (zero_symm_exact iddre),\n    },\n  },\n  {\n    exact integrable_lxc_inv_cimt bc ct lc,\n  },\nend\n\nlemma integral_of_reciprocal_on_left {c: ℂ}\n{t l b:ℝ}(bc: b < c.im) (ct: c.im < t) (lc: l < c.re) :\ncontour_integral (λz:ℂ, (z-c)⁻¹) (rec_left t l b) = \ncomplex.log (l+b*complex.I-c) -\ncomplex.log (l+t*complex.I-c) + 2*real.pi*complex.I :=\nbegin\n  rw [integral_left_two_pieces bc ct lc,\n    integral_on_lower_left bc ct lc,\n    integral_on_upper_left bc ct lc],\n  simp, rw ← mul_assoc, simp, ring_nf,\nend\n\nlemma winding_number_of_rectangle {c: ℂ}\n{b r t l:ℝ} (bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\ncontour_integral (λz:ℂ, (z-c)⁻¹) (rectangle b r t l)\n= 2 * real.pi *complex.I :=\nbegin\n  rw integral_along_rectangle' \n    (continuous_on.mono\n      (reciprocal_continuous_on c)\n      (image_rectangle_sub_compl_center bc ct lc cr)),\n  rw [integral_of_reciprocal_on_bottom bc lc cr,\n    integral_of_reciprocal_on_top ct lc cr,\n    integral_of_reciprocal_on_right bc ct cr,\n    integral_of_reciprocal_on_left bc ct lc],\n  ring_nf,\nend\n\ntheorem Cauchy_integral_formula_rectangle{f : ℂ → E} {c: ℂ}\n{b r t l:ℝ} (bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r)\n(Hc : continuous_on f (set.interval l r ×ℂ set.interval b t))\n(Hd : differentiable_on ℂ f (set.Ioo l r ×ℂ set.Ioo b t)):\ncontour_integral (λz:ℂ, (z-c)⁻¹•f(z)) (rectangle b r t l)=\n(2 * real.pi *complex.I :ℂ) • f(c) :=\nbegin\n  rw Cauchy_integral_formula_rectangle_pre bc ct lc cr Hc Hd,\n  rw winding_number_of_rectangle bc ct lc cr,\nend\n", "meta": {"author": "xinhjBrant", "repo": "prime-number-theorem", "sha": "e23408949a2d158070a2dc1dcf69da1f4a5c50be", "save_path": "github-repos/lean/xinhjBrant-prime-number-theorem", "path": "github-repos/lean/xinhjBrant-prime-number-theorem/prime-number-theorem-e23408949a2d158070a2dc1dcf69da1f4a5c50be/src/rectangle_and_cauchytheorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4848906754866796}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.eq_to_hom\nimport category_theory.quotient\nimport combinatorics.quiver.path\n\n/-!\n# The category paths on a quiver.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\nWhen `C` is a quiver, `paths C` is the category of paths.\n\n## When the quiver is itself a category\nWe provide `path_composition : paths C ⥤ C`.\n\nWe check that the quotient of the path category of a category by the canonical relation\n(paths are related if they compose to the same path) is equivalent to the original category.\n-/\n\nuniverses v₁ v₂ u₁ u₂\n\nnamespace category_theory\n\nsection\n\n/--\nA type synonym for the category of paths in a quiver.\n-/\ndef paths (V : Type u₁) : Type u₁ := V\n\ninstance (V : Type u₁) [inhabited V] : inhabited (paths V) := ⟨(default : V)⟩\n\nvariables (V : Type u₁) [quiver.{v₁+1} V]\n\nnamespace paths\n\ninstance category_paths : category.{max u₁ v₁} (paths V) :=\n{ hom := λ (X Y : V), quiver.path X Y,\n  id := λ X, quiver.path.nil,\n  comp := λ X Y Z f g, quiver.path.comp f g, }\n\nvariables {V}\n\n/--\nThe inclusion of a quiver `V` into its path category, as a prefunctor.\n-/\n@[simps]\ndef of : V ⥤q (paths V) :=\n{ obj := λ X, X,\n  map := λ X Y f, f.to_path, }\n\nlocal attribute [ext] functor.ext\n\n/-- Any prefunctor from `V` lifts to a functor from `paths V` -/\ndef lift {C} [category C] (φ : V ⥤q C) : paths V ⥤ C :=\n{ obj := φ.obj,\n  map := λ X Y f, @quiver.path.rec V _ X (λ Y f, φ.obj X ⟶ φ.obj Y) (𝟙 $ φ.obj X)\n                  (λ Y Z p f ihp, ihp ≫ (φ.map f)) Y f,\n  map_id' := λ X, by { refl, },\n  map_comp' := λ X Y Z f g, by\n  { induction g with _ _ g' p ih _ _ _,\n    { rw category.comp_id, refl, },\n    { have : f ≫ g'.cons p = (f ≫ g').cons p, by apply quiver.path.comp_cons,\n      rw this, simp only, rw [ih, category.assoc], } } }\n\n@[simp] lemma lift_nil {C} [category C] (φ : V ⥤q C) (X : V) :\n  (lift φ).map (quiver.path.nil) = 𝟙 (φ.obj X) := rfl\n\n@[simp] lemma lift_cons {C} [category C] (φ : V ⥤q C) {X Y Z : V}\n  (p : quiver.path X Y) (f : Y ⟶ Z) :\n  (lift φ).map (p.cons f) = (lift φ).map p ≫ (φ.map f) := rfl\n\n@[simp] lemma lift_to_path {C} [category C] (φ : V ⥤q C) {X Y : V} (f : X ⟶ Y) :\n  (lift φ).map f.to_path = φ.map f := by {dsimp [quiver.hom.to_path,lift], simp, }\n\nlemma lift_spec {C} [category C] (φ : V ⥤q C) :\n  of ⋙q (lift φ).to_prefunctor = φ :=\nbegin\n  apply prefunctor.ext, rotate,\n  { rintro X, refl, },\n  { rintro X Y f, rcases φ with ⟨φo,φm⟩,\n    dsimp [lift, quiver.hom.to_path],\n    simp only [category.id_comp], },\nend\n\nlemma lift_unique {C} [category C] (φ : V ⥤q C) (Φ : paths V ⥤ C)\n  (hΦ : of ⋙q Φ.to_prefunctor = φ) : Φ = lift φ :=\nbegin\n  subst_vars,\n  apply functor.ext, rotate,\n  { rintro X, refl, },\n  { rintro X Y f,\n    dsimp [lift],\n    induction f with _ _ p f' ih,\n    { simp only [category.comp_id], apply functor.map_id, },\n    { simp only [category.comp_id, category.id_comp] at ih ⊢,\n      have : Φ.map (p.cons f') = Φ.map p ≫ (Φ.map (f'.to_path)), by\n      { convert functor.map_comp Φ p (f'.to_path), },\n      rw [this, ih], }, },\nend\n\n/-- Two functors out of a path category are equal when they agree on singleton paths. -/\n@[ext]\nlemma ext_functor {C} [category C]\n  {F G : paths V ⥤ C}\n  (h_obj : F.obj = G.obj)\n  (h : ∀ (a b : V) (e : a ⟶ b), F.map e.to_path =\n  eq_to_hom (congr_fun h_obj a) ≫ G.map e.to_path ≫ eq_to_hom (congr_fun h_obj.symm b)) :\n  F = G :=\nbegin\n  ext X Y f,\n  { induction f with Y' Z' g e ih,\n    { erw [F.map_id, G.map_id, category.id_comp, eq_to_hom_trans, eq_to_hom_refl], },\n    { erw [F.map_comp g e.to_path, G.map_comp g e.to_path, ih, h],\n      simp only [category.id_comp, eq_to_hom_refl, eq_to_hom_trans_assoc, category.assoc], }, },\n  { intro X, rw h_obj, }\nend\n\nend paths\n\nvariables (W : Type u₂) [quiver.{v₂+1} W]\n\n-- A restatement of `prefunctor.map_path_comp` using `f ≫ g` instead of `f.comp g`.\n@[simp] lemma prefunctor.map_path_comp' (F : V ⥤q W) {X Y Z : paths V} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  F.map_path (f ≫ g) = (F.map_path f).comp (F.map_path g) :=\nprefunctor.map_path_comp _ _ _\n\nend\n\nsection\n\nvariables {C : Type u₁} [category.{v₁} C]\n\nopen quiver\n\n/-- A path in a category can be composed to a single morphism. -/\n@[simp]\ndef compose_path {X : C} : Π {Y : C} (p : path X Y), X ⟶ Y\n| _ path.nil := 𝟙 X\n| _ (path.cons p e) := compose_path p ≫ e\n\n@[simp]\nlemma compose_path_to_path {X Y : C} (f : X ⟶ Y) : compose_path (f.to_path) = f :=\ncategory.id_comp _\n\n@[simp]\nlemma compose_path_comp {X Y Z : C} (f : path X Y) (g : path Y Z) :\n  compose_path (f.comp g) = compose_path f ≫ compose_path g :=\nbegin\n  induction g with Y' Z' g e ih,\n  { simp, },\n  { simp [ih], },\nend\n\n@[simp]\n\n\n@[simp]\nlemma compose_path_comp' {X Y Z : paths C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  compose_path (f ≫ g) = compose_path f ≫ compose_path g :=\ncompose_path_comp f g\n\nvariables (C)\n\n/-- Composition of paths as functor from the path category of a category to the category. -/\n@[simps]\ndef path_composition : paths C ⥤ C :=\n{ obj := λ X, X,\n  map := λ X Y f, compose_path f, }\n\n/-- The canonical relation on the path category of a category:\ntwo paths are related if they compose to the same morphism. -/\n-- TODO: This, and what follows, should be generalized to\n-- the `hom_rel` for the kernel of any functor.\n-- Indeed, this should be part of an equivalence between congruence relations on a category `C`\n-- and full, essentially surjective functors out of `C`.\n@[simp]\ndef paths_hom_rel : hom_rel (paths C) :=\nλ X Y p q, (path_composition C).map p = (path_composition C).map q\n\n/-- The functor from a category to the canonical quotient of its path category. -/\n@[simps]\ndef to_quotient_paths : C ⥤ quotient (paths_hom_rel C) :=\n{ obj := λ X, quotient.mk X,\n  map := λ X Y f, quot.mk _ f.to_path,\n  map_id' := λ X, quot.sound (quotient.comp_closure.of _ _ _ (by simp)),\n  map_comp' := λ X Y Z f g, quot.sound (quotient.comp_closure.of _ _ _ (by simp)), }\n\n/-- The functor from the canonical quotient of a path category of a category\nto the original category. -/\n@[simps]\ndef quotient_paths_to : quotient (paths_hom_rel C) ⥤ C :=\nquotient.lift _ (path_composition C) (λ X Y p q w, w)\n\n/-- The canonical quotient of the path category of a category\nis equivalent to the original category. -/\ndef quotient_paths_equiv : quotient (paths_hom_rel C) ≌ C :=\n{ functor := quotient_paths_to C,\n  inverse := to_quotient_paths C,\n  unit_iso := nat_iso.of_components (λ X, by { cases X, refl, }) begin\n    intros,\n    cases X, cases Y,\n    induction f,\n    dsimp,\n    simp only [category.comp_id, category.id_comp],\n    apply quot.sound,\n    apply quotient.comp_closure.of,\n    simp [paths_hom_rel],\n  end,\n  counit_iso := nat_iso.of_components (λ X, iso.refl _) (by tidy),\n  functor_unit_iso_comp' := by { intros, cases X, dsimp, simp, refl, }, }\n\nend\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/path_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.48485143260906155}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison\n-/\nimport tactic.reassoc_axiom\nimport category_theory.category.basic\n\n/-!\n# Functors\n\nDefines a functor between categories, extending a `prefunctor` between quivers.\n\nIntroduces notation `C ⥤ D` for the type of all functors from `C` to `D`.\n(Unfortunately the `⇒` arrow (`\\functor`) is taken by core,\nbut in mathlib4 we should switch to this.)\n-/\n\nnamespace category_theory\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\n\nsection\n\nset_option old_structure_cmd true\n\n/--\n`functor C D` represents a functor between categories `C` and `D`.\n\nTo apply a functor `F` to an object use `F.obj X`, and to a morphism use `F.map f`.\n\nThe axiom `map_id` expresses preservation of identities, and\n`map_comp` expresses functoriality.\n\nSee <https://stacks.math.columbia.edu/tag/001B>.\n-/\nstructure functor (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D]\n  extends prefunctor C D : Type (max v₁ v₂ u₁ u₂) :=\n(map_id'   : ∀ (X : C), map (𝟙 X) = 𝟙 (obj X) . obviously)\n(map_comp' : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = (map f) ≫ (map g) . obviously)\n\n/-- The prefunctor between the underlying quivers. -/\nadd_decl_doc functor.to_prefunctor\n\nend\n\n-- A functor is basically a function, so give ⥤ a similar precedence to → (25).\n-- For example, `C × D ⥤ E` should parse as `(C × D) ⥤ E` not `C × (D ⥤ E)`.\ninfixr ` ⥤ `:26 := functor       -- type as \\func --\n\nrestate_axiom functor.map_id'\nattribute [simp] functor.map_id\nrestate_axiom functor.map_comp'\nattribute [reassoc, simp] functor.map_comp\n\nnamespace functor\n\nsection\nvariables (C : Type u₁) [category.{v₁} C]\n\n/-- `𝟭 C` is the identity functor on a category `C`. -/\nprotected def id : C ⥤ C :=\n{ obj := λ X, X,\n  map := λ _ _ f, f }\n\nnotation `𝟭` := functor.id -- Type this as `\\sb1`\n\ninstance : inhabited (C ⥤ C) := ⟨functor.id C⟩\n\nvariable {C}\n\n@[simp] lemma id_obj (X : C) : (𝟭 C).obj X = X := rfl\n@[simp] lemma id_map {X Y : C} (f : X ⟶ Y) : (𝟭 C).map f = f := rfl\nend\n\nsection\nvariables {C : Type u₁} [category.{v₁} C]\n          {D : Type u₂} [category.{v₂} D]\n          {E : Type u₃} [category.{v₃} E]\n\n/--\n`F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp (F : C ⥤ D) (G : D ⥤ E) : C ⥤ E :=\n{ obj := λ X, G.obj (F.obj X),\n  map := λ _ _ f, G.map (F.map f) }\n\ninfixr ` ⋙ `:80 := comp\n\n@[simp] lemma comp_obj (F : C ⥤ D) (G : D ⥤ E) (X : C) : (F ⋙ G).obj X = G.obj (F.obj X) := rfl\n@[simp] lemma comp_map (F : C ⥤ D) (G : D ⥤ E) {X Y : C} (f : X ⟶ Y) :\n  (F ⋙ G).map f = G.map (F.map f) := rfl\n\n-- These are not simp lemmas because rewriting along equalities between functors\n-- is not necessarily a good idea.\n-- Natural isomorphisms are also provided in `whiskering.lean`.\nprotected lemma comp_id (F : C ⥤ D) : F ⋙ (𝟭 D) = F := by cases F; refl\nprotected lemma id_comp (F : C ⥤ D) : (𝟭 C) ⋙ F = F := by cases F; refl\n\n@[simp] lemma map_dite (F : C ⥤ D) {X Y : C} {P : Prop} [decidable P]\n  (f : P → (X ⟶ Y)) (g : ¬P → (X ⟶ Y)) :\n  F.map (if h : P then f h else g h) = if h : P then F.map (f h) else F.map (g h) :=\nby { split_ifs; refl, }\n\nend\n\nend functor\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/functor/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.48485142384893976}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.preadditive.yoneda.basic\n! leanprover-community/mathlib commit 09f981f72d43749f1fa072deade828d9c1e185bb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Yoneda\nimport Mathbin.CategoryTheory.Preadditive.Opposite\nimport Mathbin.Algebra.Category.Module.Basic\nimport Mathbin.Algebra.Category.Group.Preadditive\n\n/-!\n# The Yoneda embedding for preadditive categories\n\nThe Yoneda embedding for preadditive categories sends an object `Y` to the presheaf sending an\nobject `X` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End Y`-module\nstructure.\n\nWe also show that this presheaf is additive and that it is compatible with the normal Yoneda\nembedding in the expected way and deduce that the preadditive Yoneda embedding is fully faithful.\n\n## TODO\n* The Yoneda embedding is additive itself\n\n-/\n\n\nuniverse v u\n\nopen CategoryTheory.Preadditive Opposite CategoryTheory.Limits\n\nnoncomputable section\n\nnamespace CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] [Preadditive C]\n\n/-- The Yoneda embedding for preadditive categories sends an object `Y` to the presheaf sending an\nobject `X` to the `End Y`-module of morphisms `X ⟶ Y`.\n-/\n@[simps]\ndef preadditiveYonedaObj (Y : C) : Cᵒᵖ ⥤ ModuleCat.{v} (End Y)\n    where\n  obj X := ModuleCat.of _ (X.unop ⟶ Y)\n  map X X' f :=\n    { toFun := fun g => f.unop ≫ g\n      map_add' := fun g g' => comp_add _ _ _ _ _ _\n      map_smul' := fun r g => Eq.symm <| Category.assoc _ _ _ }\n#align category_theory.preadditive_yoneda_obj CategoryTheory.preadditiveYonedaObj\n\n/-- The Yoneda embedding for preadditive categories sends an object `Y` to the presheaf sending an\nobject `X` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End Y`-module\nstructure, see `preadditive_yoneda_obj`.\n-/\n@[simps]\ndef preadditiveYoneda : C ⥤ Cᵒᵖ ⥤ AddCommGroupCat.{v}\n    where\n  obj Y := preadditiveYonedaObj Y ⋙ forget₂ _ _\n  map Y Y' f :=\n    { app := fun X =>\n        { toFun := fun g => g ≫ f\n          map_zero' := Limits.zero_comp\n          map_add' := fun g g' => add_comp _ _ _ _ _ _ }\n      naturality' := fun X X' g => AddCommGroupCat.ext _ _ _ _ fun x => Category.assoc _ _ _ }\n  map_id' X := by\n    ext\n    simp\n  map_comp' X Y Z f g := by\n    ext\n    simp\n#align category_theory.preadditive_yoneda CategoryTheory.preadditiveYoneda\n\n/-- The Yoneda embedding for preadditive categories sends an object `X` to the copresheaf sending an\nobject `Y` to the `End X`-module of morphisms `X ⟶ Y`.\n-/\n@[simps]\ndef preadditiveCoyonedaObj (X : Cᵒᵖ) : C ⥤ ModuleCat.{v} (End X)\n    where\n  obj Y := ModuleCat.of _ (unop X ⟶ Y)\n  map Y Y' f :=\n    { toFun := fun g => g ≫ f\n      map_add' := fun g g' => add_comp _ _ _ _ _ _\n      map_smul' := fun r g => Category.assoc _ _ _ }\n#align category_theory.preadditive_coyoneda_obj CategoryTheory.preadditiveCoyonedaObj\n\n/-- The Yoneda embedding for preadditive categories sends an object `X` to the copresheaf sending an\nobject `Y` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End X`-module\nstructure, see `preadditive_coyoneda_obj`.\n-/\n@[simps]\ndef preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGroupCat.{v}\n    where\n  obj X := preadditiveCoyonedaObj X ⋙ forget₂ _ _\n  map X X' f :=\n    { app := fun Y =>\n        { toFun := fun g => f.unop ≫ g\n          map_zero' := Limits.comp_zero\n          map_add' := fun g g' => comp_add _ _ _ _ _ _ }\n      naturality' := fun Y Y' g =>\n        AddCommGroupCat.ext _ _ _ _ fun x => Eq.symm <| Category.assoc _ _ _ }\n  map_id' X := by\n    ext\n    simp\n  map_comp' X Y Z f g := by\n    ext\n    simp\n#align category_theory.preadditive_coyoneda CategoryTheory.preadditiveCoyoneda\n\ninstance additive_yoneda_obj (X : C) : Functor.Additive (preadditiveYonedaObj X) where\n#align category_theory.additive_yoneda_obj CategoryTheory.additive_yoneda_obj\n\ninstance additive_yoneda_obj' (X : C) : Functor.Additive (preadditiveYoneda.obj X) where\n#align category_theory.additive_yoneda_obj' CategoryTheory.additive_yoneda_obj'\n\ninstance additive_coyoneda_obj (X : Cᵒᵖ) : Functor.Additive (preadditiveCoyonedaObj X) where\n#align category_theory.additive_coyoneda_obj CategoryTheory.additive_coyoneda_obj\n\ninstance additive_coyoneda_obj' (X : Cᵒᵖ) : Functor.Additive (preadditiveCoyoneda.obj X) where\n#align category_theory.additive_coyoneda_obj' CategoryTheory.additive_coyoneda_obj'\n\n/-- Composing the preadditive yoneda embedding with the forgetful functor yields the regular\nYoneda embedding.\n-/\n@[simp]\ntheorem whiskering_preadditiveYoneda :\n    preadditiveYoneda ⋙\n        (whiskeringRight Cᵒᵖ AddCommGroupCat (Type v)).obj (forget AddCommGroupCat) =\n      yoneda :=\n  rfl\n#align category_theory.whiskering_preadditive_yoneda CategoryTheory.whiskering_preadditiveYoneda\n\n/-- Composing the preadditive yoneda embedding with the forgetful functor yields the regular\nYoneda embedding.\n-/\n@[simp]\ntheorem whiskering_preadditiveCoyoneda :\n    preadditiveCoyoneda ⋙\n        (whiskeringRight C AddCommGroupCat (Type v)).obj (forget AddCommGroupCat) =\n      coyoneda :=\n  rfl\n#align category_theory.whiskering_preadditive_coyoneda CategoryTheory.whiskering_preadditiveCoyoneda\n\ninstance preadditiveYonedaFull : Full (preadditiveYoneda : C ⥤ Cᵒᵖ ⥤ AddCommGroupCat) :=\n  let yoneda_full :\n    Full\n      (preadditiveYoneda ⋙\n        (whiskeringRight Cᵒᵖ AddCommGroupCat (Type v)).obj (forget AddCommGroupCat)) :=\n    Yoneda.yonedaFull\n  full.of_comp_faithful preadditive_yoneda\n    ((whiskering_right Cᵒᵖ AddCommGroupCat (Type v)).obj (forget AddCommGroupCat))\n#align category_theory.preadditive_yoneda_full CategoryTheory.preadditiveYonedaFull\n\ninstance preadditiveCoyonedaFull : Full (preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGroupCat) :=\n  let coyoneda_full :\n    Full\n      (preadditiveCoyoneda ⋙\n        (whiskeringRight C AddCommGroupCat (Type v)).obj (forget AddCommGroupCat)) :=\n    Coyoneda.coyonedaFull\n  full.of_comp_faithful preadditive_coyoneda\n    ((whiskering_right C AddCommGroupCat (Type v)).obj (forget AddCommGroupCat))\n#align category_theory.preadditive_coyoneda_full CategoryTheory.preadditiveCoyonedaFull\n\ninstance preadditiveYoneda_faithful : Faithful (preadditiveYoneda : C ⥤ Cᵒᵖ ⥤ AddCommGroupCat) :=\n  Faithful.of_comp_eq whiskering_preadditiveYoneda\n#align category_theory.preadditive_yoneda_faithful CategoryTheory.preadditiveYoneda_faithful\n\ninstance preadditiveCoyoneda_faithful :\n    Faithful (preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGroupCat) :=\n  Faithful.of_comp_eq whiskering_preadditiveCoyoneda\n#align category_theory.preadditive_coyoneda_faithful CategoryTheory.preadditiveCoyoneda_faithful\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Preadditive/Yoneda/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.48485142068243675}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n\n! This file was ported from Lean 3 source module category_theory.idempotents.homological_complex\n! leanprover-community/mathlib commit 200eda15d8ff5669854ff6bcc10aaf37cb70498f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Homology.Additive\nimport Mathbin.CategoryTheory.Idempotents.Karoubi\n\n/-!\n# Idempotent completeness and homological complexes\n\nThis file contains simplifications lemmas for categories\n`karoubi (homological_complex C c)` and the construction of an equivalence\nof categories `karoubi (homological_complex C c) ≌ homological_complex (karoubi C) c`.\n\nWhen the category `C` is idempotent complete, it is shown that\n`homological_complex (karoubi C) c` is also idempotent complete.\n\n-/\n\n\nnamespace CategoryTheory\n\nopen Category\n\nvariable {C : Type _} [Category C] [Preadditive C] {ι : Type _} {c : ComplexShape ι}\n\nnamespace Idempotents\n\nnamespace Karoubi\n\nnamespace HomologicalComplex\n\nvariable {P Q : Karoubi (HomologicalComplex C c)} (f : P ⟶ Q) (n : ι)\n\n@[simp, reassoc.1]\ntheorem p_comp_d : P.p.f n ≫ f.f.f n = f.f.f n :=\n  HomologicalComplex.congr_hom (p_comp f) n\n#align category_theory.idempotents.karoubi.homological_complex.p_comp_d CategoryTheory.Idempotents.Karoubi.HomologicalComplex.p_comp_d\n\n@[simp, reassoc.1]\ntheorem comp_p_d : f.f.f n ≫ Q.p.f n = f.f.f n :=\n  HomologicalComplex.congr_hom (comp_p f) n\n#align category_theory.idempotents.karoubi.homological_complex.comp_p_d CategoryTheory.Idempotents.Karoubi.HomologicalComplex.comp_p_d\n\n@[reassoc.1]\ntheorem p_comm_f : P.p.f n ≫ f.f.f n = f.f.f n ≫ Q.p.f n :=\n  HomologicalComplex.congr_hom (p_comm f) n\n#align category_theory.idempotents.karoubi.homological_complex.p_comm_f CategoryTheory.Idempotents.Karoubi.HomologicalComplex.p_comm_f\n\nvariable (P)\n\n@[simp, reassoc.1]\ntheorem p_idem : P.p.f n ≫ P.p.f n = P.p.f n :=\n  HomologicalComplex.congr_hom P.idem n\n#align category_theory.idempotents.karoubi.homological_complex.p_idem CategoryTheory.Idempotents.Karoubi.HomologicalComplex.p_idem\n\nend HomologicalComplex\n\nend Karoubi\n\nopen Karoubi\n\nnamespace KaroubiHomologicalComplexEquivalence\n\nnamespace Functor\n\n/-- The functor `karoubi (homological_complex C c) ⥤ homological_complex (karoubi C) c`,\non objects. -/\n@[simps]\ndef obj (P : Karoubi (HomologicalComplex C c)) : HomologicalComplex (Karoubi C) c\n    where\n  pt n :=\n    ⟨P.pt.pt n, P.p.f n, by\n      simpa only [HomologicalComplex.comp_f] using HomologicalComplex.congr_hom P.idem n⟩\n  d i j :=\n    { f := P.p.f i ≫ P.pt.d i j\n      comm := by tidy }\n  shape' i j hij := by simp only [hom_eq_zero_iff, P.X.shape i j hij, limits.comp_zero]\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.functor.obj CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.Functor.obj\n\n/-- The functor `karoubi (homological_complex C c) ⥤ homological_complex (karoubi C) c`,\non morphisms. -/\n@[simps]\ndef map {P Q : Karoubi (HomologicalComplex C c)} (f : P ⟶ Q) : obj P ⟶ obj Q\n    where f n :=\n    { f := f.f.f n\n      comm := by simp }\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.functor.map CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.Functor.map\n\nend Functor\n\n/-- The functor `karoubi (homological_complex C c) ⥤ homological_complex (karoubi C) c`. -/\n@[simps]\ndef functor : Karoubi (HomologicalComplex C c) ⥤ HomologicalComplex (Karoubi C) c\n    where\n  obj := Functor.obj\n  map P Q f := Functor.map f\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.functor CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.functor\n\nnamespace Inverse\n\n/-- The functor `homological_complex (karoubi C) c ⥤ karoubi (homological_complex C c)`,\non objects -/\n@[simps]\ndef obj (K : HomologicalComplex (Karoubi C) c) : Karoubi (HomologicalComplex C c)\n    where\n  pt :=\n    { pt := fun n => (K.pt n).pt\n      d := fun i j => (K.d i j).f\n      shape' := fun i j hij => hom_eq_zero_iff.mp (K.shape i j hij)\n      d_comp_d' := fun i j k hij hjk => by\n        simpa only [comp_f] using hom_eq_zero_iff.mp (K.d_comp_d i j k) }\n  p :=\n    { f := fun n => (K.pt n).p\n      comm' := by simp }\n  idem := by tidy\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.inverse.obj CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.Inverse.obj\n\n/-- The functor `homological_complex (karoubi C) c ⥤ karoubi (homological_complex C c)`,\non morphisms -/\n@[simps]\ndef map {K L : HomologicalComplex (Karoubi C) c} (f : K ⟶ L) : obj K ⟶ obj L\n    where\n  f :=\n    { f := fun n => (f.f n).f\n      comm' := fun i j hij => by simpa only [comp_f] using hom_ext.mp (f.comm' i j hij) }\n  comm := by tidy\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.inverse.map CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.Inverse.map\n\nend Inverse\n\n/-- The functor `homological_complex (karoubi C) c ⥤ karoubi (homological_complex C c)`. -/\n@[simps]\ndef inverse : HomologicalComplex (Karoubi C) c ⥤ Karoubi (HomologicalComplex C c)\n    where\n  obj := Inverse.obj\n  map K L f := Inverse.map f\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.inverse CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.inverse\n\n/-- The counit isomorphism of the equivalence\n`karoubi (homological_complex C c) ≌ homological_complex (karoubi C) c`. -/\n@[simps]\ndef counitIso : inverse ⋙ functor ≅ 𝟭 (HomologicalComplex (Karoubi C) c) :=\n  eqToIso (Functor.ext (fun P => HomologicalComplex.ext (by tidy) (by tidy)) (by tidy))\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.counit_iso CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.counitIso\n\n/-- The unit isomorphism of the equivalence\n`karoubi (homological_complex C c) ≌ homological_complex (karoubi C) c`. -/\n@[simps]\ndef unitIso : 𝟭 (Karoubi (HomologicalComplex C c)) ≅ functor ⋙ inverse\n    where\n  Hom :=\n    { app := fun P =>\n        { f :=\n            { f := fun n => P.p.f n\n              comm' := fun i j hij => by\n                dsimp\n                simp only [HomologicalComplex.Hom.comm, HomologicalComplex.Hom.comm_assoc,\n                  homological_complex.p_idem] }\n          comm := by\n            ext n\n            dsimp\n            simp only [homological_complex.p_idem] }\n      naturality' := fun P Q φ => by\n        ext\n        dsimp\n        simp only [comp_f, HomologicalComplex.comp_f, homological_complex.comp_p_d, inverse.map_f_f,\n          functor.map_f_f, homological_complex.p_comp_d] }\n  inv :=\n    { app := fun P =>\n        { f :=\n            { f := fun n => P.p.f n\n              comm' := fun i j hij => by\n                dsimp\n                simp only [HomologicalComplex.Hom.comm, assoc, homological_complex.p_idem] }\n          comm := by\n            ext n\n            dsimp\n            simp only [homological_complex.p_idem] }\n      naturality' := fun P Q φ => by\n        ext\n        dsimp\n        simp only [comp_f, HomologicalComplex.comp_f, inverse.map_f_f, functor.map_f_f,\n          homological_complex.comp_p_d, homological_complex.p_comp_d] }\n  hom_inv_id' := by\n    ext\n    dsimp\n    simp only [homological_complex.p_idem, comp_f, HomologicalComplex.comp_f, id_eq]\n  inv_hom_id' := by\n    ext\n    dsimp\n    simp only [homological_complex.p_idem, comp_f, HomologicalComplex.comp_f, id_eq,\n      inverse.obj_p_f, functor.obj_X_p]\n#align category_theory.idempotents.karoubi_homological_complex_equivalence.unit_iso CategoryTheory.Idempotents.KaroubiHomologicalComplexEquivalence.unitIso\n\nend KaroubiHomologicalComplexEquivalence\n\nvariable (C) (c)\n\n/-- The equivalence `karoubi (homological_complex C c) ≌ homological_complex (karoubi C) c`. -/\n@[simps]\ndef karoubiHomologicalComplexEquivalence :\n    Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c\n    where\n  Functor := KaroubiHomologicalComplexEquivalence.functor\n  inverse := KaroubiHomologicalComplexEquivalence.inverse\n  unitIso := KaroubiHomologicalComplexEquivalence.unitIso\n  counitIso := KaroubiHomologicalComplexEquivalence.counitIso\n#align category_theory.idempotents.karoubi_homological_complex_equivalence CategoryTheory.Idempotents.karoubiHomologicalComplexEquivalence\n\nvariable (α : Type _) [AddRightCancelSemigroup α] [One α]\n\n/-- The equivalence `karoubi (chain_complex C α) ≌ chain_complex (karoubi C) α`. -/\n@[simps]\ndef karoubiChainComplexEquivalence : Karoubi (ChainComplex C α) ≌ ChainComplex (Karoubi C) α :=\n  karoubiHomologicalComplexEquivalence C (ComplexShape.down α)\n#align category_theory.idempotents.karoubi_chain_complex_equivalence CategoryTheory.Idempotents.karoubiChainComplexEquivalence\n\n/-- The equivalence `karoubi (cochain_complex C α) ≌ cochain_complex (karoubi C) α`. -/\n@[simps]\ndef karoubiCochainComplexEquivalence :\n    Karoubi (CochainComplex C α) ≌ CochainComplex (Karoubi C) α :=\n  karoubiHomologicalComplexEquivalence C (ComplexShape.up α)\n#align category_theory.idempotents.karoubi_cochain_complex_equivalence CategoryTheory.Idempotents.karoubiCochainComplexEquivalence\n\ninstance [IsIdempotentComplete C] : IsIdempotentComplete (HomologicalComplex C c) :=\n  by\n  rw [is_idempotent_complete_iff_of_equivalence\n      ((to_karoubi_equivalence C).mapHomologicalComplex c),\n    ← is_idempotent_complete_iff_of_equivalence (karoubi_homological_complex_equivalence C c)]\n  infer_instance\n\nend Idempotents\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Idempotents/HomologicalComplex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.48485141744628135}}
{"text": "import combinatorics.simple_graph.basic\nimport combinatorics.simple_graph.subgraph\n\nnamespace simple_graph\n\nuniverse u\n\nvariables {V : Type u} [fintype V] [decidable_eq V]\nvariable (G : simple_graph V)\n\ndef edge_to_finset_powerset_len_two : Π (e : sym2 V), \n  e ∈ G.edge_set → ↥(finset.powerset_len 2 (finset.univ : finset V)) :=\nλ e, λ e_in, \n⟨ sym2.lift ⟨λ v₁ v₂ : V, ({v₁, v₂} : finset V), \n    λ v₁ v₂ : V, finset.insert.comm v₁ v₂ ∅⟩ e,\n  begin\n    revert e,\n    rw sym2.forall,\n    unfold simple_graph.edge_set,\n    intros v₁ v₂,\n    rw sym2.from_rel_prop,\n    intro h_adj,\n    simp only [sym2.lift_mk, subtype.coe_mk],\n    rw finset.mem_powerset_len,\n    rw finset.card_eq_two,\n    have v₁_ne_v₂ : v₁ ≠ v₂,\n    { intro x_eq_y,\n      rw x_eq_y at h_adj,\n      exact G.loopless v₂ h_adj, },\n    exact ⟨finset.subset_univ {v₁, v₂}, ⟨v₁, v₂, v₁_ne_v₂, rfl⟩⟩,\n  end ⟩\n\nlemma edge_to_finset_powerset_len_two_inj : ∀ e₁ e₂ e₁_in e₂_in,\n  G.edge_to_finset_powerset_len_two e₁ e₁_in = \n    G.edge_to_finset_powerset_len_two e₂ e₂_in → \n  e₁ = e₂ :=\nbegin\n  rw sym2.forall,\n  intros v₁ v₂,\n  rw sym2.forall,\n  intros v₁' v₂',\n  intros e₁_in e₂_in h_eq,\n  apply sym2.ext,\n  rw ← subtype.val_inj at h_eq,\n  unfold edge_to_finset_powerset_len_two at h_eq,\n  simp only [sym2.lift_mk, subtype.coe_mk] at h_eq,\n  rw finset.ext_iff at h_eq,\n  simp only [finset.mem_insert, finset.mem_singleton] at h_eq,\n  simp_rw sym2.mem_iff,\n  exact h_eq,\nend\n\nnamespace subgraph\n\nvariables {G} [decidable_rel G.adj]\nvariables (G' : G.subgraph) [decidable_rel G'.adj]\n\nnamespace decidable\n\ninstance edge_set_mem :\ndecidable_pred (∈ G'.edge_set) := sym2.from_rel.decidable_pred G'.symm\n\ninstance coe_adj : decidable_rel G'.coe.adj := \nbegin\n  unfold decidable_rel,\n  intros v w,\n  rw simple_graph.subgraph.coe_adj,\n  apply_instance,\nend\n\ninstance coe_edge_set_mem [decidable_pred (∈ G'.verts)] :\ndecidable_pred (∈ G'.coe.edge_set) :=\nsym2.from_rel.decidable_pred G'.coe.symm\n\nend decidable\n\ndef edge_finset : finset (sym2 V) := G'.edge_set.to_finset\n\nlemma edge_finset_subset : G'.edge_finset ⊆ G.edge_finset := \nbegin\n  unfold edge_finset,\n  unfold simple_graph.edge_finset,\n  rw ← set.subset_iff_to_finset_subset,\n  exact G'.edge_set_subset,\nend\n\ndef edge_to_finset_powerset_len_two [decidable_pred (∈ G'.verts)] : Π (e : sym2 V), \n  e ∈ G'.edge_set → ↥(finset.powerset_len 2 G'.verts.to_finset) :=\nλ e, λ e_in,\n⟨ sym2.lift ⟨λ v₁ v₂ : V, ({v₁, v₂} : finset V), \n    λ v₁ v₂ : V, finset.insert.comm v₁ v₂ ∅⟩ e,\n  begin\n    revert e,\n    rw sym2.forall,\n    unfold simple_graph.subgraph.edge_set,\n    intros v₁ v₂,\n    rw sym2.from_rel_prop,\n    intro h_adj,\n    simp only [sym2.lift_mk, subtype.coe_mk],\n    rw finset.mem_powerset_len,\n    rw finset.card_eq_two,\n    have v₁_ne_v₂ : v₁ ≠ v₂,\n    { intro v₁_eq_v₂,\n      rw v₁_eq_v₂ at h_adj,\n      exact G'.loopless v₂ h_adj, },\n    have h_subset : {v₁, v₂} ⊆ G'.verts.to_finset,\n    { rw finset.subset_iff,\n      simp only [finset.mem_insert, finset.mem_singleton, set.mem_to_finset, forall_eq_or_imp, forall_eq],\n      exact ⟨G'.edge_vert h_adj, G'.edge_vert (G'.symm h_adj)⟩, },\n    exact ⟨h_subset, ⟨v₁, v₂, v₁_ne_v₂, rfl⟩⟩,\n  end ⟩\n\ndef edge_to_finset_powerset_len_two_inj [decidable_pred (∈ G'.verts)] : ∀ e₁ e₂ e₁_in e₂_in,\n  G'.edge_to_finset_powerset_len_two e₁ e₁_in = \n    G'.edge_to_finset_powerset_len_two e₂ e₂_in → \n  e₁ = e₂ :=\nbegin\n  rw sym2.forall,\n  intros v₁ v₂,\n  rw sym2.forall,\n  intros v₁' v₂',\n  intros e₁_in e₂_in h_eq,\n  apply sym2.ext,\n  rw ← subtype.val_inj at h_eq,\n  unfold edge_to_finset_powerset_len_two at h_eq,\n  simp only [sym2.lift_mk, subtype.coe_mk] at h_eq,\n  rw finset.ext_iff at h_eq,\n  simp only [finset.mem_insert, finset.mem_singleton] at h_eq,\n  simp_rw sym2.mem_iff,\n  exact h_eq,\nend\n\nend subgraph\n\nend simple_graph", "meta": {"author": "andrei232000", "repo": "4th_year_project", "sha": "8836b40a6470960c96de3deaa18754be4792ed0c", "save_path": "github-repos/lean/andrei232000-4th_year_project", "path": "github-repos/lean/andrei232000-4th_year_project/4th_year_project-8836b40a6470960c96de3deaa18754be4792ed0c/src/simple_graph_aux.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4848210118735512}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Bhavik Mehta\n-/\nimport category_theory.structured_arrow\nimport category_theory.punit\nimport category_theory.functor.reflects_isomorphisms\nimport category_theory.epi_mono\n\n/-!\n# Over and under categories\n\nOver (and under) categories are special cases of comma categories.\n* If `L` is the identity functor and `R` is a constant functor, then `comma L R` is the \"slice\" or\n  \"over\" category over the object `R` maps to.\n* Conversely, if `L` is a constant functor and `R` is the identity functor, then `comma L R` is the\n  \"coslice\" or \"under\" category under the object `L` maps to.\n\n## Tags\n\ncomma, slice, coslice, over, under\n-/\n\nnamespace category_theory\n\nuniverses v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u₁} [category.{v₁} T]\n\n/--\nThe over category has as objects arrows in `T` with codomain `X` and as morphisms commutative\ntriangles.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\n@[derive category]\ndef over (X : T) := costructured_arrow (𝟭 T) X\n\n-- Satisfying the inhabited linter\ninstance over.inhabited [inhabited T] : inhabited (over (default : T)) :=\n{ default :=\n  { left := default,\n    hom := 𝟙 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U ⟶ V}\n  (h : f.left = g.left) : f = g :=\nby tidy\n\n@[simp] lemma over_right (U : over X) : U.right = ⟨⟨⟩⟩ := by tidy\n\n@[simp] lemma id_left (U : over X) : comma_morphism.left (𝟙 U) = 𝟙 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).left = f.left ≫ g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A ⟶ B) : f.left ≫ B.hom = A.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/\n@[simps left hom]\ndef mk {X Y : T} (f : Y ⟶ X) : over X :=\ncostructured_arrow.mk f\n\n/-- We can set up a coercion from arrows with codomain `X` to `over X`. This most likely should not\n    be a global instance, but it is sometimes useful. -/\ndef coe_from_hom {X Y : T} : has_coe (Y ⟶ X) (over X) :=\n{ coe := mk }\n\nsection\nlocal attribute [instance] coe_from_hom\n\n@[simp] lemma coe_hom {X Y : T} (f : Y ⟶ X) : (f : over X).hom = f := rfl\nend\n\n/-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative\n    triangle. -/\n@[simps]\ndef hom_mk {U V : over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom . obviously) :\n  U ⟶ V :=\ncostructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\n@[simps]\ndef iso_mk {f g : over X} (hl : f.left ≅ g.left) (hw : hl.hom ≫ g.hom = f.hom . obviously) :\n  f ≅ g :=\ncostructured_arrow.iso_mk hl hw\n\nsection\nvariable (X)\n/--\nThe forgetful functor mapping an arrow to its domain.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\ndef forget : over X ⥤ T := comma.fst _ _\n\nend\n\n@[simp] lemma forget_obj {U : over X} : (forget X).obj U = U.left := rfl\n@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : (forget X).map f = f.left := rfl\n\n/-- The natural cocone over the forgetful functor `over X ⥤ T` with cocone point `X`. -/\n@[simps] def forget_cocone (X : T) : limits.cocone (forget X) :=\n{ X := X, ι := { app := comma.hom } }\n\n/--\nA morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\ndef map {Y : T} (f : X ⟶ Y) : over X ⥤ over Y := comma.map_right _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : over X} {g : U ⟶ V}\n@[simp] lemma map_obj_left : ((map f).obj U).left = U.left := rfl\n@[simp] lemma map_obj_hom  : ((map f).obj U).hom  = U.hom ≫ f := rfl\n@[simp] lemma map_map_left : ((map f).map g).left = g.left := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map f ⋙ map g :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := λ Y Z f t, by exactI\n  ⟨⟨over.hom_mk (inv ((forget X).map f))\n      ((as_iso ((forget X).map f)).inv_comp_eq.2 (over.w f).symm),\n    by tidy⟩⟩ }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\n/--\nIf `k.left` is an epimorphism, then `k` is an epimorphism. In other words, `over.forget X` reflects\nepimorphisms.\nThe converse does not hold without additional assumptions on the underlying category.\n-/\n-- TODO: Show the converse holds if `T` has binary products or pushouts.\nlemma epi_of_epi_left {f g : over X} (k : f ⟶ g) [hk : epi k.left] : epi k :=\nfaithful_reflects_epi (forget X) hk\n\n/--\nIf `k.left` is a monomorphism, then `k` is a monomorphism. In other words, `over.forget X` reflects\nmonomorphisms.\nThe converse of `category_theory.over.mono_left_of_mono`.\n\nThis lemma is not an instance, to avoid loops in type class inference.\n-/\nlemma mono_of_mono_left {f g : over X} (k : f ⟶ g) [hk : mono k.left] : mono k :=\nfaithful_reflects_mono (forget X) hk\n\n/--\nIf `k` is a monomorphism, then `k.left` is a monomorphism. In other words, `over.forget X` preserves\nmonomorphisms.\nThe converse of `category_theory.over.mono_of_mono_left`.\n-/\ninstance mono_left_of_mono {f g : over X} (k : f ⟶ g) [mono k] : mono k.left :=\nbegin\n  refine ⟨λ (Y : T) l m a, _⟩,\n  let l' : mk (m ≫ f.hom) ⟶ f := hom_mk l (by { dsimp, rw [←over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw ← cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y ⟶ X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f ⥤ over f.left :=\n{ obj := λ α, over.mk α.hom.left,\n  map := λ α β κ, over.hom_mk κ.left.left (by { rw auto_param_eq, rw ← over.w κ, refl }) }\n\n/-- Given f : Y ⟶ X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left ⥤ over f :=\n{ obj := λ g, mk (hom_mk g.hom : mk (g.hom ≫ f.hom) ⟶ f),\n  map := λ g h α, hom_mk (hom_mk α.left (w_assoc α f.hom)) (over_morphism.ext (w α)) }\n\n/-- Given f : Y ⟶ X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f ≌ over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (iso.refl _) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f ⋙ forget f.left = forget f ⋙ forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f ⋙ forget f ⋙ forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `over X ⥤ over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T ⥤ D) : over X ⥤ over (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { left := F.map f.left,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend over\n\n/-- The under category has as objects arrows with domain `X` and as morphisms commutative\n    triangles. -/\n@[derive category]\ndef under (X : T) := structured_arrow X (𝟭 T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default : T)) :=\n{ default :=\n  { right := default,\n    hom := 𝟙 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U ⟶ V}\n  (h : f.right = g.right) : f = g :=\nby tidy\n\n@[simp] lemma under_left (U : under X) : U.left = ⟨⟨⟩⟩ := by tidy\n\n@[simp] lemma id_right (U : under X) : comma_morphism.right (𝟙 U) = 𝟙 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).right = f.right ≫ g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A ⟶ B) : A.hom ≫ f.right = B.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/\n@[simps right hom]\ndef mk {X Y : T} (f : X ⟶ Y) : under X :=\nstructured_arrow.mk f\n\n/-- To give a morphism in the under category, it suffices to give a morphism fitting in a\n    commutative triangle. -/\n@[simps]\ndef hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom . obviously) :\n  U ⟶ V :=\nstructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\ndef iso_mk {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) : f ≅ g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).hom.right = hr.hom := rfl\n\n@[simp]\nlemma iso_mk_inv_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).inv.right = hr.inv := rfl\n\nsection\nvariables (X)\n/-- The forgetful functor mapping an arrow to its domain. -/\ndef forget : under X ⥤ T := comma.snd _ _\n\nend\n\n@[simp] lemma forget_obj {U : under X} : (forget X).obj U = U.right := rfl\n@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : (forget X).map f = f.right := rfl\n\n/-- The natural cone over the forgetful functor `under X ⥤ T` with cone point `X`. -/\n@[simps] def forget_cone (X : T) : limits.cone (forget X) :=\n{ X := X, π := { app := comma.hom } }\n\n/-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/\ndef map {Y : T} (f : X ⟶ Y) : under Y ⥤ under X := comma.map_left _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : under Y} {g : U ⟶ V}\n@[simp] lemma map_obj_right : ((map f).obj U).right = U.right := rfl\n@[simp] lemma map_obj_hom   : ((map f).obj U).hom   = f ≫ U.hom := rfl\n@[simp] lemma map_map_right : ((map f).map g).right = g.right := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := λ Y Z f t, by exactI\n  ⟨⟨under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm),\n    by tidy⟩⟩ }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `under X ⥤ under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T ⥤ D) : under X ⥤ under (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { right := F.map f.right,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend under\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/over.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4847362932569541}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.group.inj_surj\nimport data.list.big_operators\nimport data.list.range\nimport group_theory.group_action.defs\nimport group_theory.submonoid.basic\nimport data.set_like.basic\nimport data.sigma.basic\n\n/-!\n# Additively-graded multiplicative structures\n\nThis module provides a set of heterogeneous typeclasses for defining a multiplicative structure\nover the sigma type `graded_monoid A` such that `(*) : A i → A j → A (i + j)`; that is to say, `A`\nforms an additively-graded monoid. The typeclasses are:\n\n* `graded_monoid.ghas_one A`\n* `graded_monoid.ghas_mul A`\n* `graded_monoid.gmonoid A`\n* `graded_monoid.gcomm_monoid A`\n\nWith the `sigma_graded` locale open, these respectively imbue:\n\n* `has_one (graded_monoid A)`\n* `has_mul (graded_monoid A)`\n* `monoid (graded_monoid A)`\n* `comm_monoid (graded_monoid A)`\n\nthe base type `A 0` with:\n\n* `graded_monoid.grade_zero.has_one`\n* `graded_monoid.grade_zero.has_mul`\n* `graded_monoid.grade_zero.monoid`\n* `graded_monoid.grade_zero.comm_monoid`\n\nand the `i`th grade `A i` with `A 0`-actions (`•`) defined as left-multiplication:\n\n* (nothing)\n* `graded_monoid.grade_zero.has_scalar (A 0)`\n* `graded_monoid.grade_zero.mul_action (A 0)`\n* (nothing)\n\nFor now, these typeclasses are primarily used in the construction of `direct_sum.ring` and the rest\nof that file.\n\n## Dependent graded products\n\nThis also introduces `list.dprod`, which takes the (possibly non-commutative) product of a list\nof graded elements of type `A i`. This definition primarily exist to allow `graded_monoid.mk`\nand `direct_sum.of` to be pulled outside a product, such as in `graded_monoid.mk_list_dprod` and\n`direct_sum.of_list_dprod`.\n\n## Internally graded monoids\n\nIn addition to the above typeclasses, in the most frequent case when `A` is an indexed collection of\n`set_like` subobjects (such as `add_submonoid`s, `add_subgroup`s, or `submodule`s), this file\nprovides the `Prop` typeclasses:\n\n* `set_like.has_graded_one A` (which provides the obvious `graded_monoid.ghas_one A` instance)\n* `set_like.has_graded_mul A` (which provides the obvious `graded_monoid.ghas_mul A` instance)\n* `set_like.graded_monoid A` (which provides the obvious `graded_monoid.gmonoid A` and\n  `graded_monoid.gcomm_monoid A` instances)\n* `set_like.is_homogeneous A` (which says that `a` is homogeneous iff `a ∈ A i` for some `i : ι`)\n\nStrictly this last class is unecessary as it has no fields not present in its parents, but it is\nincluded for convenience. Note that there is no need for `graded_ring` or similar, as all the\ninformation it would contain is already supplied by `graded_monoid` when `A` is a collection\nof additively-closed set_like objects such as `submodules`. These constructions are explored in\n`algebra.direct_sum.internal`.\n\nThis file also contains the definition of `set_like.homogeneous_submonoid A`, which is, as the name\nsuggests, the submonoid consisting of all the homogeneous elements.\n\n## tags\n\ngraded monoid\n-/\n\nset_option old_structure_cmd true\n\nvariables {ι : Type*}\n\n/-- A type alias of sigma types for graded monoids. -/\ndef graded_monoid (A : ι → Type*) := sigma A\n\nnamespace graded_monoid\n\ninstance {A : ι → Type*} [inhabited ι] [inhabited (A default)]: inhabited (graded_monoid A) :=\nsigma.inhabited\n\n/-- Construct an element of a graded monoid. -/\ndef mk {A : ι → Type*} : Π i, A i → graded_monoid A := sigma.mk\n\n/-! ### Typeclasses -/\nsection defs\n\nvariables (A : ι → Type*)\n\n/-- A graded version of `has_one`, which must be of grade 0. -/\nclass ghas_one [has_zero ι] :=\n(one : A 0)\n\n/-- `ghas_one` implies `has_one (graded_monoid A)` -/\ninstance ghas_one.to_has_one [has_zero ι] [ghas_one A] : has_one (graded_monoid A) :=\n⟨⟨_, ghas_one.one⟩⟩\n\n/-- A graded version of `has_mul`. Multiplication combines grades additively, like\n`add_monoid_algebra`. -/\nclass ghas_mul [has_add ι] :=\n(mul {i j} : A i → A j → A (i + j))\n\n/-- `ghas_mul` implies `has_mul (graded_monoid A)`. -/\ninstance ghas_mul.to_has_mul [has_add ι] [ghas_mul A] :\n  has_mul (graded_monoid A) :=\n⟨λ (x y : graded_monoid A), ⟨_, ghas_mul.mul x.snd y.snd⟩⟩\n\nlemma mk_mul_mk [has_add ι] [ghas_mul A] {i j} (a : A i) (b : A j) :\n  mk i a * mk j b = mk (i + j) (ghas_mul.mul a b) :=\nrfl\n\nnamespace gmonoid\n\nvariables {A} [add_monoid ι] [ghas_mul A] [ghas_one A]\n\n/-- A default implementation of power on a graded monoid, like `npow_rec`.\n`gmonoid.gnpow` should be used instead. -/\ndef gnpow_rec : Π (n : ℕ) {i}, A i → A (n • i)\n| 0 i a := cast (congr_arg A (zero_nsmul i).symm) ghas_one.one\n| (n + 1) i a := cast (congr_arg A (succ_nsmul i n).symm) (ghas_mul.mul a $ gnpow_rec _ a)\n\n@[simp] lemma gnpow_rec_zero (a : graded_monoid A) : graded_monoid.mk _ (gnpow_rec 0 a.snd) = 1 :=\nsigma.ext (zero_nsmul _) (heq_of_cast_eq _ rfl).symm\n\n/-- Tactic used to autofill `graded_monoid.gmonoid.gnpow_zero'` when the default\n`graded_monoid.gmonoid.gnpow_rec` is used. -/\nmeta def apply_gnpow_rec_zero_tac : tactic unit := `[apply graded_monoid.gmonoid.gnpow_rec_zero]\n\n@[simp] lemma gnpow_rec_succ (n : ℕ) (a : graded_monoid A) :\n  (graded_monoid.mk _ $ gnpow_rec n.succ a.snd) = a * ⟨_, gnpow_rec n a.snd⟩ :=\nsigma.ext (succ_nsmul _ _) (heq_of_cast_eq _ rfl).symm\n\n/-- Tactic used to autofill `graded_monoid.gmonoid.gnpow_succ'` when the default\n`graded_monoid.gmonoid.gnpow_rec` is used. -/\nmeta def apply_gnpow_rec_succ_tac : tactic unit := `[apply graded_monoid.gmonoid.gnpow_rec_succ]\n\nend gmonoid\n\n/-- A graded version of `monoid`.\n\nLike `monoid.npow`, this has an optional `gmonoid.gnpow` field to allow definitional control of\nnatural powers of a graded monoid. -/\nclass gmonoid [add_monoid ι]  extends ghas_mul A, ghas_one A :=\n(one_mul (a : graded_monoid A) : 1 * a = a)\n(mul_one (a : graded_monoid A) : a * 1 = a)\n(mul_assoc (a b c : graded_monoid A) : a * b * c = a * (b * c))\n(gnpow : Π (n : ℕ) {i}, A i → A (n • i) := gmonoid.gnpow_rec)\n(gnpow_zero' : Π (a : graded_monoid A), graded_monoid.mk _ (gnpow 0 a.snd) = 1\n  . gmonoid.apply_gnpow_rec_zero_tac)\n(gnpow_succ' : Π (n : ℕ) (a : graded_monoid A),\n  (graded_monoid.mk _ $ gnpow n.succ a.snd) = a * ⟨_, gnpow n a.snd⟩\n  . gmonoid.apply_gnpow_rec_succ_tac)\n\n/-- `gmonoid` implies a `monoid (graded_monoid A)`. -/\ninstance gmonoid.to_monoid [add_monoid ι] [gmonoid A] :\n  monoid (graded_monoid A) :=\n{ one := (1), mul := (*),\n  npow := λ n a, graded_monoid.mk _ (gmonoid.gnpow n a.snd),\n  npow_zero' := λ a, gmonoid.gnpow_zero' a,\n  npow_succ' := λ n a, gmonoid.gnpow_succ' n a,\n  one_mul := gmonoid.one_mul, mul_one := gmonoid.mul_one, mul_assoc := gmonoid.mul_assoc }\n\nlemma mk_pow [add_monoid ι] [gmonoid A] {i} (a : A i) (n : ℕ) :\n  mk i a ^ n = mk (n • i) (gmonoid.gnpow _ a) :=\nbegin\n  induction n with n,\n  { rw [pow_zero],\n    exact (gmonoid.gnpow_zero' ⟨_, a⟩).symm, },\n  { rw [pow_succ, n_ih, mk_mul_mk],\n    exact (gmonoid.gnpow_succ' n ⟨_, a⟩).symm, },\nend\n\n/-- A graded version of `comm_monoid`. -/\nclass gcomm_monoid [add_comm_monoid ι] extends gmonoid A :=\n(mul_comm (a : graded_monoid A) (b : graded_monoid A) : a * b = b * a)\n\n/-- `gcomm_monoid` implies a `comm_monoid (graded_monoid A)`, although this is only used as an\ninstance locally to define notation in `gmonoid` and similar typeclasses. -/\ninstance gcomm_monoid.to_comm_monoid [add_comm_monoid ι] [gcomm_monoid A] :\n  comm_monoid (graded_monoid A) :=\n{ mul_comm := gcomm_monoid.mul_comm, ..gmonoid.to_monoid A }\n\nend defs\n\n\n/-! ### Instances for `A 0`\n\nThe various `g*` instances are enough to promote the `add_comm_monoid (A 0)` structure to various\ntypes of multiplicative structure.\n-/\n\nsection grade_zero\n\nvariables (A : ι → Type*)\n\nsection one\nvariables [has_zero ι] [ghas_one A]\n\n/-- `1 : A 0` is the value provided in `ghas_one.one`. -/\n@[nolint unused_arguments]\ninstance grade_zero.has_one : has_one (A 0) :=\n⟨ghas_one.one⟩\n\nend one\n\nsection mul\nvariables [add_zero_class ι] [ghas_mul A]\n\n/-- `(•) : A 0 → A i → A i` is the value provided in `graded_monoid.ghas_mul.mul`, composed with\nan `eq.rec` to turn `A (0 + i)` into `A i`.\n-/\ninstance grade_zero.has_scalar (i : ι) : has_scalar (A 0) (A i) :=\n{ smul := λ x y, (zero_add i).rec (ghas_mul.mul x y) }\n\n/-- `(*) : A 0 → A 0 → A 0` is the value provided in `graded_monoid.ghas_mul.mul`, composed with\nan `eq.rec` to turn `A (0 + 0)` into `A 0`.\n-/\ninstance grade_zero.has_mul : has_mul (A 0) :=\n{ mul := (•) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_smul {i} (a : A 0) (b : A i) : mk _ (a • b) = mk _ a * mk _ b :=\nsigma.ext (zero_add _).symm $ eq_rec_heq _ _\n\n@[simp] lemma grade_zero.smul_eq_mul (a b : A 0) : a • b = a * b := rfl\n\n\nend mul\n\nsection monoid\nvariables [add_monoid ι] [gmonoid A]\n\ninstance : has_pow (A 0) ℕ :=\n{ pow := λ x n, (nsmul_zero n).rec (gmonoid.gnpow n x : A (n • 0)) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_pow (a : A 0) (n : ℕ) : mk _ (a ^ n) = mk _ a ^ n :=\nsigma.ext (nsmul_zero n).symm $ eq_rec_heq _ _\n\nvariables (A)\n\n/-- The `monoid` structure derived from `gmonoid A`. -/\ninstance grade_zero.monoid : monoid (A 0) :=\nfunction.injective.monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow\n\nend monoid\n\nsection monoid\nvariables [add_comm_monoid ι] [gcomm_monoid A]\n\n/-- The `comm_monoid` structure derived from `gcomm_monoid A`. -/\ninstance grade_zero.comm_monoid : comm_monoid (A 0) :=\nfunction.injective.comm_monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow\n\nend monoid\n\nsection mul_action\nvariables [add_monoid ι] [gmonoid A]\n\n/-- `graded_monoid.mk 0` is a `monoid_hom`, using the `graded_monoid.grade_zero.monoid` structure.\n-/\ndef mk_zero_monoid_hom : A 0 →* (graded_monoid A) :=\n{ to_fun := mk 0, map_one' := rfl, map_mul' := mk_zero_smul }\n\n/-- Each grade `A i` derives a `A 0`-action structure from `gmonoid A`. -/\ninstance grade_zero.mul_action {i} : mul_action (A 0) (A i) :=\nbegin\n  letI := mul_action.comp_hom (graded_monoid A) (mk_zero_monoid_hom A),\n  exact function.injective.mul_action (mk i) sigma_mk_injective mk_zero_smul,\nend\n\nend mul_action\n\nend grade_zero\n\nend graded_monoid\n\n/-! ### Dependent products of graded elements -/\n\nsection dprod\n\nvariables {α : Type*} {A : ι → Type*} [add_monoid ι] [graded_monoid.gmonoid A]\n\n/-- The index used by `list.dprod`. Propositionally this is equal to `(l.map fι).sum`, but\ndefinitionally it needs to have a different form to avoid introducing `eq.rec`s in `list.dprod`. -/\ndef list.dprod_index (l : list α) (fι : α → ι) : ι :=\nl.foldr (λ i b, fι i + b) 0\n\n@[simp] lemma list.dprod_index_nil (fι : α → ι) : ([] : list α).dprod_index fι = 0 := rfl\n@[simp] lemma list.dprod_index_cons (a : α) (l : list α) (fι : α → ι) :\n  (a :: l).dprod_index fι = fι a + l.dprod_index fι := rfl\n\nlemma list.dprod_index_eq_map_sum (l : list α) (fι : α → ι) :\n  l.dprod_index fι = (l.map fι).sum :=\nbegin\n  dunfold list.dprod_index,\n  induction l,\n  { simp, },\n  { simp [l_ih], },\nend\n\n/-- A dependent product for graded monoids represented by the indexed family of types `A i`.\nThis is a dependent version of `(l.map fA).prod`.\n\nFor a list `l : list α`, this computes the product of `fA a` over `a`, where each `fA` is of type\n`A (fι a)`. -/\ndef list.dprod (l : list α) (fι : α → ι) (fA : Π a, A (fι a)) :\n  A (l.dprod_index fι) :=\nl.foldr_rec_on _ _ graded_monoid.ghas_one.one (λ i x a ha, graded_monoid.ghas_mul.mul (fA a) x)\n\n@[simp] lemma list.dprod_nil (fι : α → ι) (fA : Π a, A (fι a)) :\n  (list.nil : list α).dprod fι fA = graded_monoid.ghas_one.one := rfl\n\n-- the `( : _)` in this lemma statement results in the type on the RHS not being unfolded, which\n-- is nicer in the goal view.\n@[simp] lemma list.dprod_cons (fι : α → ι) (fA : Π a, A (fι a)) (a : α) (l : list α) :\n  (a :: l).dprod fι fA = (graded_monoid.ghas_mul.mul (fA a) (l.dprod fι fA) : _) := rfl\n\nlemma graded_monoid.mk_list_dprod (l : list α) (fι : α → ι) (fA : Π a, A (fι a)) :\n  graded_monoid.mk _ (l.dprod fι fA) = (l.map (λ a, graded_monoid.mk (fι a) (fA a))).prod :=\nbegin\n  induction l,\n  { simp, refl  },\n  { simp [←l_ih, graded_monoid.mk_mul_mk, list.prod_cons],\n    refl, },\nend\n\n/-- A variant of `graded_monoid.mk_list_dprod` for rewriting in the other direction. -/\nlemma graded_monoid.list_prod_map_eq_dprod (l : list α) (f : α → graded_monoid A) :\n  (l.map f).prod = graded_monoid.mk _ (l.dprod (λ i, (f i).1) (λ i, (f i).2)) :=\nbegin\n  rw [graded_monoid.mk_list_dprod, graded_monoid.mk],\n  simp_rw sigma.eta,\nend\n\nlemma graded_monoid.list_prod_of_fn_eq_dprod {n : ℕ} (f : fin n → graded_monoid A) :\n  (list.of_fn f).prod =\n    graded_monoid.mk _ ((list.fin_range n).dprod (λ i, (f i).1) (λ i, (f i).2)) :=\nby rw [list.of_fn_eq_map, graded_monoid.list_prod_map_eq_dprod]\n\nend dprod\n\n/-! ### Concrete instances -/\nsection\n\nvariables (ι) {R : Type*}\n\n@[simps one]\ninstance has_one.ghas_one [has_zero ι] [has_one R] : graded_monoid.ghas_one (λ i : ι, R) :=\n{ one := 1 }\n\n@[simps mul]\ninstance has_mul.ghas_mul [has_add ι] [has_mul R] : graded_monoid.ghas_mul (λ i : ι, R) :=\n{ mul := λ i j, (*) }\n\n/-- If all grades are the same type and themselves form a monoid, then there is a trivial grading\nstructure. -/\n@[simps gnpow]\ninstance monoid.gmonoid [add_monoid ι] [monoid R] : graded_monoid.gmonoid (λ i : ι, R) :=\n{ one_mul := λ a, sigma.ext (zero_add _) (heq_of_eq (one_mul _)),\n  mul_one := λ a, sigma.ext (add_zero _) (heq_of_eq (mul_one _)),\n  mul_assoc := λ a b c, sigma.ext (add_assoc _ _ _) (heq_of_eq (mul_assoc _ _ _)),\n  gnpow := λ n i a, a ^ n,\n  gnpow_zero' := λ a, sigma.ext (zero_nsmul _) (heq_of_eq (monoid.npow_zero' _)),\n  gnpow_succ' := λ n ⟨i, a⟩, sigma.ext (succ_nsmul _ _) (heq_of_eq (monoid.npow_succ' _ _)),\n  ..has_one.ghas_one ι,\n  ..has_mul.ghas_mul ι }\n\n/-- If all grades are the same type and themselves form a commutative monoid, then there is a\ntrivial grading structure. -/\ninstance comm_monoid.gcomm_monoid [add_comm_monoid ι] [comm_monoid R] :\n  graded_monoid.gcomm_monoid (λ i : ι, R) :=\n{ mul_comm := λ a b, sigma.ext (add_comm _ _) (heq_of_eq (mul_comm _ _)),\n  ..monoid.gmonoid ι }\n\n/-- When all the indexed types are the same, the dependent product is just the regular product. -/\n@[simp] lemma list.dprod_monoid {α} [add_monoid ι] [monoid R] (l : list α) (fι : α → ι)\n  (fA : α → R) :\n  (l.dprod fι fA : (λ i : ι, R) _) = ((l.map fA).prod : _) :=\nbegin\n  induction l,\n  { rw [list.dprod_nil, list.map_nil, list.prod_nil], refl },\n  { rw [list.dprod_cons, list.map_cons, list.prod_cons, l_ih], refl },\nend\n\nend\n\n/-! ### Shorthands for creating instance of the above typeclasses for collections of subobjects -/\n\nsection subobjects\n\nvariables {R : Type*}\n\n/-- A version of `graded_monoid.ghas_one` for internally graded objects. -/\nclass set_like.has_graded_one {S : Type*} [set_like S R] [has_one R] [has_zero ι]\n  (A : ι → S) : Prop :=\n(one_mem : (1 : R) ∈ A 0)\n\ninstance set_like.ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero ι] (A : ι → S)\n  [set_like.has_graded_one A] : graded_monoid.ghas_one (λ i, A i) :=\n{ one := ⟨1, set_like.has_graded_one.one_mem⟩ }\n\n@[simp] lemma set_like.coe_ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero ι] (A : ι → S)\n  [set_like.has_graded_one A] : ↑(@graded_monoid.ghas_one.one _ (λ i, A i) _ _) = (1 : R) := rfl\n\n/-- A version of `graded_monoid.ghas_one` for internally graded objects. -/\nclass set_like.has_graded_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι]\n  (A : ι → S) : Prop :=\n(mul_mem : ∀ ⦃i j⦄ {gi gj}, gi ∈ A i → gj ∈ A j → gi * gj ∈ A (i + j))\n\ninstance set_like.ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι] (A : ι → S)\n  [set_like.has_graded_mul A] :\n  graded_monoid.ghas_mul (λ i, A i) :=\n{ mul := λ i j a b, ⟨(a * b : R), set_like.has_graded_mul.mul_mem a.prop b.prop⟩ }\n\n@[simp] lemma set_like.coe_ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι] (A : ι → S)\n  [set_like.has_graded_mul A] {i j : ι} (x : A i) (y : A j) :\n    ↑(@graded_monoid.ghas_mul.mul _ (λ i, A i) _ _ _ _ x y) = (x * y : R) := rfl\n\n/-- A version of `graded_monoid.gmonoid` for internally graded objects. -/\nclass set_like.graded_monoid {S : Type*} [set_like S R] [monoid R] [add_monoid ι]\n  (A : ι → S) extends set_like.has_graded_one A, set_like.has_graded_mul A : Prop\n\nnamespace set_like.graded_monoid\nvariables {S : Type*} [set_like S R] [monoid R] [add_monoid ι]\nvariables {A : ι → S} [set_like.graded_monoid A]\n\nlemma pow_mem (n : ℕ) {r : R} {i : ι} (h : r ∈ A i) : r ^ n ∈ A (n • i) :=\nbegin\n  induction n,\n  { rw [pow_zero, zero_nsmul], exact one_mem },\n  { rw [pow_succ', succ_nsmul'], exact mul_mem n_ih h },\nend\n\nlemma list_prod_map_mem {ι'} (l : list ι') (i : ι' → ι) (r : ι' → R) (h : ∀ j ∈ l, r j ∈ A (i j)) :\n  (l.map r).prod ∈ A (l.map i).sum :=\nbegin\n  induction l,\n  { rw [list.map_nil, list.map_nil, list.prod_nil, list.sum_nil],\n    exact one_mem },\n  { rw [list.map_cons, list.map_cons, list.prod_cons, list.sum_cons],\n    exact mul_mem (h _ $ list.mem_cons_self _ _) (l_ih $ λ j hj, h _ $ list.mem_cons_of_mem _ hj) },\nend\n\nlemma list_prod_of_fn_mem {n} (i : fin n → ι) (r : fin n → R) (h : ∀ j, r j ∈ A (i j)) :\n  (list.of_fn r).prod ∈ A (list.of_fn i).sum :=\nbegin\n  rw [list.of_fn_eq_map, list.of_fn_eq_map],\n  exact list_prod_map_mem _ _ _ (λ _ _, h _),\nend\n\nend set_like.graded_monoid\n\n/-- Build a `gmonoid` instance for a collection of subobjects. -/\ninstance set_like.gmonoid {S : Type*} [set_like S R] [monoid R] [add_monoid ι] (A : ι → S)\n  [set_like.graded_monoid A] :\n  graded_monoid.gmonoid (λ i, A i) :=\n{ one_mul := λ ⟨i, a, h⟩, sigma.subtype_ext (zero_add _) (one_mul _),\n  mul_one := λ ⟨i, a, h⟩, sigma.subtype_ext (add_zero _) (mul_one _),\n  mul_assoc := λ ⟨i, a, ha⟩ ⟨j, b, hb⟩ ⟨k, c, hc⟩,\n    sigma.subtype_ext (add_assoc _ _ _) (mul_assoc _ _ _),\n  gnpow := λ n i a, ⟨a ^ n, set_like.graded_monoid.pow_mem n a.prop⟩,\n  gnpow_zero' := λ n, sigma.subtype_ext (zero_nsmul _) (pow_zero _),\n  gnpow_succ' := λ n a, sigma.subtype_ext (succ_nsmul _ _) (pow_succ _ _),\n  ..set_like.ghas_one A,\n  ..set_like.ghas_mul A }\n\n@[simp] lemma set_like.coe_gnpow {S : Type*} [set_like S R] [monoid R] [add_monoid ι] (A : ι → S)\n  [set_like.graded_monoid A] {i : ι} (x : A i) (n : ℕ) :\n    ↑(@graded_monoid.gmonoid.gnpow _ (λ i, A i) _ _ n _ x) = (x ^ n : R) := rfl\n\n/-- Build a `gcomm_monoid` instance for a collection of subobjects. -/\ninstance set_like.gcomm_monoid {S : Type*} [set_like S R] [comm_monoid R] [add_comm_monoid ι]\n  (A : ι → S) [set_like.graded_monoid A] :\n  graded_monoid.gcomm_monoid (λ i, A i) :=\n{ mul_comm := λ ⟨i, a, ha⟩ ⟨j, b, hb⟩, sigma.subtype_ext (add_comm _ _) (mul_comm _ _),\n  ..set_like.gmonoid A}\n\nsection dprod\nopen set_like set_like.graded_monoid\nvariables {α S : Type*} [set_like S R] [monoid R] [add_monoid ι]\n\n/-- Coercing a dependent product of subtypes is the same as taking the regular product of the\ncoercions. -/\n@[simp] lemma set_like.coe_list_dprod (A : ι → S) [set_like.graded_monoid A]\n  (fι : α → ι) (fA : Π a, A (fι a)) (l : list α) :\n  ↑(l.dprod fι fA : (λ i, ↥(A i)) _) = (list.prod (l.map (λ a, fA a)) : R) :=\nbegin\n  induction l,\n  { rw [list.dprod_nil, coe_ghas_one, list.map_nil, list.prod_nil] },\n  { rw [list.dprod_cons, coe_ghas_mul, list.map_cons, list.prod_cons, l_ih], },\nend\n\ninclude R\n\n/-- A version of `list.coe_dprod_set_like` with `subtype.mk`. -/\nlemma set_like.list_dprod_eq (A : ι → S) [set_like.graded_monoid A]\n  (fι : α → ι) (fA : Π a, A (fι a)) (l : list α) :\n  (l.dprod fι fA : (λ i, ↥(A i)) _) =\n    ⟨list.prod (l.map (λ a, fA a)), (l.dprod_index_eq_map_sum fι).symm ▸\n      list_prod_map_mem l _ _ (λ i hi, (fA i).prop)⟩ :=\nsubtype.ext $ set_like.coe_list_dprod _ _ _ _\n\nend dprod\n\nend subobjects\n\nsection homogeneous_elements\n\nvariables {R S : Type*} [set_like S R]\n\n/-- An element `a : R` is said to be homogeneous if there is some `i : ι` such that `a ∈ A i`. -/\ndef set_like.is_homogeneous (A : ι → S) (a : R) : Prop := ∃ i, a ∈ A i\n\n@[simp] lemma set_like.is_homogeneous_coe {A : ι → S} {i} (x : A i) :\n  set_like.is_homogeneous A (x : R) :=\n⟨i, x.prop⟩\n\nlemma set_like.is_homogeneous_one [has_zero ι] [has_one R]\n  (A : ι → S) [set_like.has_graded_one A] : set_like.is_homogeneous A (1 : R) :=\n⟨0, set_like.has_graded_one.one_mem⟩\n\nlemma set_like.is_homogeneous.mul [has_add ι] [has_mul R] {A : ι → S}\n  [set_like.has_graded_mul A] {a b : R} :\n  set_like.is_homogeneous A a → set_like.is_homogeneous A b → set_like.is_homogeneous A (a * b)\n| ⟨i, hi⟩ ⟨j, hj⟩ := ⟨i + j, set_like.has_graded_mul.mul_mem hi hj⟩\n\n/-- When `A` is a `set_like.graded_monoid A`, then the homogeneous elements forms a submonoid. -/\ndef set_like.homogeneous_submonoid [add_monoid ι] [monoid R]\n  (A : ι → S) [set_like.graded_monoid A] : submonoid R :=\n{ carrier := { a | set_like.is_homogeneous A a },\n  one_mem' := set_like.is_homogeneous_one A,\n  mul_mem' := λ a b, set_like.is_homogeneous.mul }\n\nend homogeneous_elements\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/graded_monoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.4847362783005052}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monoidal.braided\nimport Mathlib.algebra.category.Module.basic\nimport Mathlib.linear_algebra.tensor_product\nimport Mathlib.PostPort\n\nuniverses u u_1 u_2 u_3 u_4 u_5 u_6 \n\nnamespace Mathlib\n\n/-!\n# The symmetric monoidal category structure on R-modules\n\nMostly this uses existing machinery in `linear_algebra.tensor_product`.\nWe just need to provide a few small missing pieces to build the\n`monoidal_category` instance and then the `symmetric_category` instance.\n\nIf you're happy using the bundled `Module R`, it may be possible to mostly\nuse this as an interface and not need to interact much with the implementation details.\n-/\n\nnamespace Module\n\n\nnamespace monoidal_category\n\n\n-- The definitions inside this namespace are essentially private.\n\n-- After we build the `monoidal_category (Module R)` instance,\n\n-- you should use that API.\n\n/-- (implementation) tensor product of R-modules -/\n/-- (implementation) tensor product of morphisms R-modules -/\ndef tensor_obj {R : Type u} [comm_ring R] (M : Module R) (N : Module R) : Module R :=\n  of R (tensor_product R ↥M ↥N)\n\ndef tensor_hom {R : Type u} [comm_ring R] {M : Module R} {N : Module R} {M' : Module R} {N' : Module R} (f : M ⟶ N) (g : M' ⟶ N') : tensor_obj M M' ⟶ tensor_obj N N' :=\n  tensor_product.map f g\n\ntheorem tensor_id {R : Type u} [comm_ring R] (M : Module R) (N : Module R) : tensor_hom 𝟙 𝟙 = 𝟙 :=\n  tensor_product.ext fun (x : ↥M) (y : ↥N) => Eq.refl (coe_fn (tensor_hom 𝟙 𝟙) (tensor_product.tmul R x y))\n\ntheorem tensor_comp {R : Type u} [comm_ring R] {X₁ : Module R} {Y₁ : Module R} {Z₁ : Module R} {X₂ : Module R} {Y₂ : Module R} {Z₂ : Module R} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) : tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) = tensor_hom f₁ f₂ ≫ tensor_hom g₁ g₂ :=\n  tensor_product.ext\n    fun (x : ↥X₁) (y : ↥X₂) => Eq.refl (coe_fn (tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂)) (tensor_product.tmul R x y))\n\n/-- (implementation) the associator for R-modules -/\ndef associator {R : Type u} [comm_ring R] (M : Module R) (N : Module R) (K : Module R) : tensor_obj (tensor_obj M N) K ≅ tensor_obj M (tensor_obj N K) :=\n  linear_equiv.to_Module_iso (tensor_product.assoc R ↥M ↥N ↥K)\n\n/-! The `associator_naturality` and `pentagon` lemmas below are very slow to elaborate.\n\nWe give them some help by expressing the lemmas first non-categorically, then using\n`convert _aux using 1` to have the elaborator work as little as possible. -/\n\ntheorem associator_naturality {R : Type u} [comm_ring R] {X₁ : Module R} {X₂ : Module R} {X₃ : Module R} {Y₁ : Module R} {Y₂ : Module R} {Y₃ : Module R} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) : tensor_hom (tensor_hom f₁ f₂) f₃ ≫ category_theory.iso.hom (associator Y₁ Y₂ Y₃) =\n  category_theory.iso.hom (associator X₁ X₂ X₃) ≫ tensor_hom f₁ (tensor_hom f₂ f₃) := sorry\n\ntheorem pentagon {R : Type u} [comm_ring R] (W : Module R) (X : Module R) (Y : Module R) (Z : Module R) : tensor_hom (category_theory.iso.hom (associator W X Y)) 𝟙 ≫\n    category_theory.iso.hom (associator W (tensor_obj X Y) Z) ≫\n      tensor_hom 𝟙 (category_theory.iso.hom (associator X Y Z)) =\n  category_theory.iso.hom (associator (tensor_obj W X) Y Z) ≫ category_theory.iso.hom (associator W X (tensor_obj Y Z)) := sorry\n\n/-- (implementation) the left unitor for R-modules -/\ndef left_unitor {R : Type u} [comm_ring R] (M : Module R) : of R (tensor_product R R ↥M) ≅ M :=\n  linear_equiv.to_Module_iso (tensor_product.lid R ↥M) ≪≫ of_self_iso M\n\ntheorem left_unitor_naturality {R : Type u} [comm_ring R] {M : Module R} {N : Module R} (f : M ⟶ N) : tensor_hom 𝟙 f ≫ category_theory.iso.hom (left_unitor N) = category_theory.iso.hom (left_unitor M) ≫ f := sorry\n\n/-- (implementation) the right unitor for R-modules -/\ndef right_unitor {R : Type u} [comm_ring R] (M : Module R) : of R (tensor_product R (↥M) R) ≅ M :=\n  linear_equiv.to_Module_iso (tensor_product.rid R ↥M) ≪≫ of_self_iso M\n\ntheorem right_unitor_naturality {R : Type u} [comm_ring R] {M : Module R} {N : Module R} (f : M ⟶ N) : tensor_hom f 𝟙 ≫ category_theory.iso.hom (right_unitor N) = category_theory.iso.hom (right_unitor M) ≫ f := sorry\n\ntheorem triangle {R : Type u} [comm_ring R] (M : Module R) (N : Module R) : category_theory.iso.hom (associator M (of R R) N) ≫ tensor_hom 𝟙 (category_theory.iso.hom (left_unitor N)) =\n  tensor_hom (category_theory.iso.hom (right_unitor M)) 𝟙 := sorry\n\nend monoidal_category\n\n\nprotected instance Module.monoidal_category {R : Type u} [comm_ring R] : category_theory.monoidal_category (Module R) :=\n  category_theory.monoidal_category.mk monoidal_category.tensor_obj monoidal_category.tensor_hom (of R R)\n    monoidal_category.associator monoidal_category.left_unitor monoidal_category.right_unitor\n\n/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/\nprotected instance category_theory.monoidal_category.tensor_unit.comm_ring {R : Type u} [comm_ring R] : comm_ring ↥𝟙_ :=\n  _inst_1\n\nnamespace monoidal_category\n\n\n@[simp] theorem hom_apply {R : Type u} [comm_ring R] {K : Module R} {L : Module R} {M : Module R} {N : Module R} (f : K ⟶ L) (g : M ⟶ N) (k : ↥K) (m : ↥M) : coe_fn (f ⊗ g) (tensor_product.tmul R k m) = tensor_product.tmul R (coe_fn f k) (coe_fn g m) :=\n  rfl\n\n@[simp] theorem left_unitor_hom_apply {R : Type u} [comm_ring R] {M : Module R} (r : R) (m : ↥M) : coe_fn (category_theory.iso.hom λ_) (tensor_product.tmul R r m) = r • m :=\n  tensor_product.lid_tmul m r\n\n@[simp] theorem right_unitor_hom_apply {R : Type u} [comm_ring R] {M : Module R} (m : ↥M) (r : R) : coe_fn (category_theory.iso.hom ρ_) (tensor_product.tmul R m r) = r • m :=\n  tensor_product.rid_tmul m r\n\n@[simp] theorem associator_hom_apply {R : Type u} [comm_ring R] {M : Module R} {N : Module R} {K : Module R} (m : ↥M) (n : ↥N) (k : ↥K) : coe_fn (category_theory.iso.hom α_) (tensor_product.tmul R (tensor_product.tmul R m n) k) =\n  tensor_product.tmul R m (tensor_product.tmul R n k) :=\n  rfl\n\nend monoidal_category\n\n\n/-- (implementation) the braiding for R-modules -/\ndef braiding {R : Type u} [comm_ring R] (M : Module R) (N : Module R) : monoidal_category.tensor_obj M N ≅ monoidal_category.tensor_obj N M :=\n  linear_equiv.to_Module_iso (tensor_product.comm R ↥M ↥N)\n\n@[simp] theorem braiding_naturality {R : Type u} [comm_ring R] {X₁ : Module R} {X₂ : Module R} {Y₁ : Module R} {Y₂ : Module R} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) : (f ⊗ g) ≫ category_theory.iso.hom (braiding Y₁ Y₂) = category_theory.iso.hom (braiding X₁ X₂) ≫ (g ⊗ f) :=\n  tensor_product.ext\n    fun (x : ↥X₁) (y : ↥X₂) =>\n      Eq.refl (coe_fn ((f ⊗ g) ≫ category_theory.iso.hom (braiding Y₁ Y₂)) (tensor_product.tmul R x y))\n\n@[simp] theorem hexagon_forward {R : Type u} [comm_ring R] (X : Module R) (Y : Module R) (Z : Module R) : category_theory.iso.hom α_ ≫ category_theory.iso.hom (braiding X (Y ⊗ Z)) ≫ category_theory.iso.hom α_ =\n  (category_theory.iso.hom (braiding X Y) ⊗ 𝟙) ≫\n    category_theory.iso.hom α_ ≫ (𝟙 ⊗ category_theory.iso.hom (braiding X Z)) := sorry\n\n@[simp] theorem hexagon_reverse {R : Type u} [comm_ring R] (X : Module R) (Y : Module R) (Z : Module R) : category_theory.iso.inv α_ ≫ category_theory.iso.hom (braiding (X ⊗ Y) Z) ≫ category_theory.iso.inv α_ =\n  (𝟙 ⊗ category_theory.iso.hom (braiding Y Z)) ≫\n    category_theory.iso.inv α_ ≫ (category_theory.iso.hom (braiding X Z) ⊗ 𝟙) := sorry\n\n/-- The symmetric monoidal structure on `Module R`. -/\nprotected instance Module.symmetric_category {R : Type u} [comm_ring R] : category_theory.symmetric_category (Module R) :=\n  category_theory.symmetric_category.mk\n\nnamespace monoidal_category\n\n\n@[simp] theorem braiding_hom_apply {R : Type u} [comm_ring R] {M : Module R} {N : Module R} (m : ↥M) (n : ↥N) : coe_fn (category_theory.iso.hom β_) (tensor_product.tmul R m n) = tensor_product.tmul R n m :=\n  rfl\n\n@[simp] theorem braiding_inv_apply {R : Type u} [comm_ring R] {M : Module R} {N : Module R} (m : ↥M) (n : ↥N) : coe_fn (category_theory.iso.inv β_) (tensor_product.tmul R n m) = tensor_product.tmul R m n :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/category/Module/monoidal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.48455790008027555}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.valuation.basic\nimport Mathlib.PostPort\n\nuniverses u v w l \n\nnamespace Mathlib\n\n/-!\n# Ring of integers under a given valuation\n\nThe elements with valuation less than or equal to 1.\n\nTODO: Define characteristic predicate.\n-/\n\nnamespace valuation\n\n\n/-- The ring of integers under a given valuation is the subring of elements with valuation ≤ 1. -/\ndef integer {R : Type u} {Γ₀ : Type v} [ring R] [linear_ordered_comm_group_with_zero Γ₀]\n    (v : valuation R Γ₀) : subring R :=\n  subring.mk (set_of fun (x : R) => coe_fn v x ≤ 1) sorry sorry sorry sorry sorry\n\n/-- Given a valuation v : R → Γ₀ and a ring homomorphism O →+* R, we say that O is the integers of v\nif f is injective, and its range is exactly `v.integer`. -/\nstructure integers {R : Type u} {Γ₀ : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero Γ₀]\n    (v : valuation R Γ₀) (O : Type w) [comm_ring O] [algebra O R]\n    where\n  hom_inj : function.injective ⇑(algebra_map O R)\n  map_le_one : ∀ (x : O), coe_fn v (coe_fn (algebra_map O R) x) ≤ 1\n  exists_of_le_one : ∀ {r : R}, coe_fn v r ≤ 1 → ∃ (x : O), coe_fn (algebra_map O R) x = r\n\n-- typeclass shortcut\n\nprotected instance algebra {R : Type u} {Γ₀ : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero Γ₀] (v : valuation R Γ₀) : algebra (↥(integer v)) R :=\n  algebra.of_subring (integer v)\n\ntheorem integer.integers {R : Type u} {Γ₀ : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero Γ₀] (v : valuation R Γ₀) : integers v ↥(integer v) :=\n  integers.mk subtype.coe_injective (fun (r : ↥(integer v)) => subtype.property r)\n    fun (r : R) (hr : coe_fn v r ≤ 1) => Exists.intro { val := r, property := hr } rfl\n\nnamespace integers\n\n\ntheorem one_of_is_unit {R : Type u} {Γ₀ : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero Γ₀] {v : valuation R Γ₀} {O : Type w} [comm_ring O]\n    [algebra O R] (hv : integers v O) {x : O} (hx : is_unit x) :\n    coe_fn v (coe_fn (algebra_map O R) x) = 1 :=\n  sorry\n\ntheorem is_unit_of_one {R : Type u} {Γ₀ : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero Γ₀] {v : valuation R Γ₀} {O : Type w} [comm_ring O]\n    [algebra O R] (hv : integers v O) {x : O} (hx : is_unit (coe_fn (algebra_map O R) x))\n    (hvx : coe_fn v (coe_fn (algebra_map O R) x) = 1) : is_unit x :=\n  sorry\n\ntheorem le_of_dvd {R : Type u} {Γ₀ : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero Γ₀]\n    {v : valuation R Γ₀} {O : Type w} [comm_ring O] [algebra O R] (hv : integers v O) {x : O}\n    {y : O} (h : x ∣ y) :\n    coe_fn v (coe_fn (algebra_map O R) y) ≤ coe_fn v (coe_fn (algebra_map O R) x) :=\n  sorry\n\nend integers\n\n\nnamespace integers\n\n\ntheorem dvd_of_le {F : Type u} {Γ₀ : Type v} [field F] [linear_ordered_comm_group_with_zero Γ₀]\n    {v : valuation F Γ₀} {O : Type w} [comm_ring O] [algebra O F] (hv : integers v O) {x : O}\n    {y : O} (h : coe_fn v (coe_fn (algebra_map O F) x) ≤ coe_fn v (coe_fn (algebra_map O F) y)) :\n    y ∣ x :=\n  sorry\n\ntheorem dvd_iff_le {F : Type u} {Γ₀ : Type v} [field F] [linear_ordered_comm_group_with_zero Γ₀]\n    {v : valuation F Γ₀} {O : Type w} [comm_ring O] [algebra O F] (hv : integers v O) {x : O}\n    {y : O} :\n    x ∣ y ↔ coe_fn v (coe_fn (algebra_map O F) y) ≤ coe_fn v (coe_fn (algebra_map O F) x) :=\n  { mp := le_of_dvd hv, mpr := dvd_of_le hv }\n\ntheorem le_iff_dvd {F : Type u} {Γ₀ : Type v} [field F] [linear_ordered_comm_group_with_zero Γ₀]\n    {v : valuation F Γ₀} {O : Type w} [comm_ring O] [algebra O F] (hv : integers v O) {x : O}\n    {y : O} :\n    coe_fn v (coe_fn (algebra_map O F) x) ≤ coe_fn v (coe_fn (algebra_map O F) y) ↔ y ∣ x :=\n  { mp := dvd_of_le hv, mpr := le_of_dvd hv }\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/valuation/integers_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4845579000802755}}
{"text": "import EggTactic\n-- Rewrites that force a counter to count upward.\n\ninductive B where -- bit\n| O : B\n| I : B\nopen B\n\ndef count_upward_v3\n    (count: B -> B -> B -> B)\n    (count_0: ∀ (b2 b1: B), count b2 b1 O = count b2 b1 I)\n    (count_1: ∀ (b2: B), count b2 O I = count b2 I O)\n    (count_2: count O I I = count I O O): count I I I = count O O O := by {\n      simp[count_0, count_1, count_2];\n      -- rawEgg[count_0, count_1, count_2];\n    }\n\n/-\ninductive N where  -- unary encoding of natural numbers\n| Z : N\n| S : N -> N\n\n\nopen N\nopen B\n\naxiom BinNum : Type\naxiom BinNum.get: BinNum -> N -> B -- get Nth bit\naxiom counter: N -> BinNum  -- counter value at nth step\n\naxiom counter_begin (ix: N): (counter Z).get ix = O\n\n-- 0 0 0 -> 0 0 1\naxiom axiom_000_SSn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = O):\n    (counter (S n)).get (S (S i)) = O\naxiom axiom_000_Sn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = O):\n    (counter (S n)).get (S i) = O\naxiom axiom_000_n (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = O):\n    (counter (S n)).get i = I\n\n-- 0 0 1 -> 0  1  0\n--         Ssn Sn n\naxiom axiom_001_SSn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = I):\n    (counter (S n)).get (S (S i)) = O\naxiom axiom_001_Sn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = I):\n    (counter (S n)).get (S i) = I\naxiom axiom_001_n (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = I):\n    (counter (S n)).get i = O\n\n-- 0 1 0 ->0   1  1\n--         Ssn Sn n\naxiom axiom_010_SSn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O):\n    (counter (S n)).get (S (S i)) = O\naxiom axiom_010_Sn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O):\n    (counter (S n)).get (S i) = I\naxiom axiom_010_n (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O):\n\n-- 0 1 1 -> 1 0 0\naxiom axiom_011_SSn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O):\n    (counter (S n)).get (S (S i)) = I\naxiom axiom_011_Sn (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O):\n    (counter (S n)).get (S i) = O\naxiom axiom_011_n (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O):\n    (counter (S n)).get i = O\n  \nabbrev one : N := S Z\nabbrev two : N := S one\nabbrev three : N := S two\nabbrev four : N := S three\nabbrev five : N := S four                                                                                                    \nabbrev six: N := S five\nabbrev seven : N := S six\n\n/-\n#print seven\ntheorem count_upward_7_at_0: (counter seven).get Z = I := by {\n  rawEgg [axiom_000_SSn, axiom_000_Sn, axiom_000_n\n  , axiom_001_SSn, axiom_001_Sn, axiom_001_n\n  , axiom_010_SSn, axiom_010_Sn, axiom_010_n\n  , axiom_011_SSn, axiom_011_Sn, axiom_011_n]\n  sorry\n-/\n\ndef foo\n  (x: Int)\n  (y: Nat): True := sorry\n\ndef count_upward_7_at_0'\n  -- 0 0 0 -> 0 0 1\n  (axiom_000_SSn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = O), (counter (S n)).get (S (S i)) = O)\n  (axiom_000_Sn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = O), (counter (S n)).get (S i) = O)\n  (axiom_000_n: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = O), (counter (S n)).get i = I)\n  -- 0 0 1 -> 0  1  0\n  --         Ssn Sn n\n  (axiom_001_SSn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = I), (counter (S n)).get (S (S i)) = O)\n  (axiom_001_Sn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = I), (counter (S n)).get (S i) = I)\n  (axiom_001_n: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = O) (Xn: (counter n).get i = I), (counter (S n)).get i = O)\n  -- 0 1 0 ->0   1  1\n  --         Ssn Sn n\n  (axiom_010_SSn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O), (counter (S n)).get (S (S i)) = O)\n  (axiom_010_Sn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O), (counter (S n)).get (S i) = I)\n  (axiom_010_n: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O), (counter (S n)).get i = I)\n  -- 0 1 1 -> 1 0 0\n  (axiom_011_SSn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O), (counter (S n)).get (S (S i)) = I)\n  (axiom_011_Sn: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O), (counter (S n)).get (S i) = O)\n  (axiom_011_n: forall (n: N) (i: N) (Xssn: (counter n).get (S (S i)) = O)  (Xsn: (counter n).get (S i) = I) (Xn: (counter n).get i = O), (counter (S n)).get i = O): \n   (counter seven).get Z = I := by {\n    rawEgg [axiom_000_SSn, axiom_000_Sn, axiom_000_n\n      , axiom_001_SSn, axiom_001_Sn, axiom_001_n\n      , axiom_010_SSn, axiom_010_Sn, axiom_010_n\n    , axiom_011_SSn, axiom_011_Sn, axiom_011_n];\n    sorry\n    \n  }\n-/\n\n", "meta": {"author": "opencompl", "repo": "egg-tactic-code", "sha": "4c37f57478f88d5e11120051012e3d97264c338c", "save_path": "github-repos/lean/opencompl-egg-tactic-code", "path": "github-repos/lean/opencompl-egg-tactic-code/egg-tactic-code-4c37f57478f88d5e11120051012e3d97264c338c/Evaluation/scaling-space-and-proof/Scaling.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506635289835, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.484557896509899}}
{"text": "import for_mathlib.valuation_subring.basic\nimport rigid_elements.rigid_pair\n\nvariables {K : Type*} [field K] {T H : mul_subgroup K} {rp : rigid_pair T H}\n\nopen rigid_pair\n\nlemma rigid_pair.preadditive.mul_mem (h : rp.preadditive) :\n  ∀ (x y : K), x ∈ rp.OO → y ∈ rp.OO → x * y ∈ rp.OO :=\nbegin\n  suffices : ∀ a b : K, a ∈ rp.OO_m → b ∈ rp.OO_m → a * b ∈ rp.OO,\n  { rintros a b (ha|ha) (hb|hb), \n    { apply this, assumption' },\n    { left, rw mul_comm, apply hb.2, assumption },\n    { left, apply ha.2, assumption },\n    { right, apply rp.OO_p_mul_mem, assumption' } },\n  intros x y hx hy,\n  by_cases hxy : x * y ∈ H, \n  { right, apply h.mul_mem_of_mem, assumption' },\n  left, refine ⟨hxy,_⟩,\n  rw (show (1 + x * y = 1 - ((-1) * x) * y), by ring),\n  apply (rp.preadditive_iff.mp h) _ _ _ hy,\n  apply h.neg_one_mem.2 _ hx,\nend\n\nlemma rigid_pair.preadditive.one_mem (h : rp.preadditive) :\n  (1 : K) ∈ rp.OO := or.inr $ rp.OO_p_one_mem \n\nlemma rigid_pair.preadditive.zero_mem (h : rp.preadditive) :\n  (0 : K) ∈ rp.OO := or.inl $ rp.OO_m_zero_mem\n\nlemma rigid_pair.preadditive.neg_mem (h : rp.preadditive) :\n  ∀ (x : K), x ∈ rp.OO → -x ∈ rp.OO :=\nbegin\n  intros x hx,\n  rw (show -x = (-1) * x, by ring),\n  apply h.mul_mem _ _ _ hx,\n  exact or.inr h.neg_one_mem,\nend\n\nlemma rigid_pair.preadditive.one_plus_mem (h : rp.preadditive) :\n  ∀ (x : K), x ∈ rp.OO → 1 + x ∈ rp.OO :=\nbegin\n  intros z hz,\n  by_cases hzz : z = -1, { rw hzz, simp [h.zero_mem] },\n  have hzz' : 1 + z ≠ 0, \n  { intro c, apply hzz,  \n    rwa [← add_eq_zero_iff_eq_neg, add_comm] },\n  by_cases hz1 : z ∈ rp.OO_p,\n  swap, \n  { right, apply h, cases hz, assumption, contradiction },\n  have hh : 1 - (1 + z) ∈ rp.OO_p, \n  { rw (show 1 - (1 + z) = (-1) * z, by ring),\n    apply rp.OO_p_mul_mem h.neg_one_mem hz1 },\n  have aux : ∀ y : K, y ∈ rp.OO_m → 1 + (1 + z) * y ∈ T ∧ 1 + (1 + z) * y ∈ rp.OO_p,\n  { intros y hy,\n    have := h.one_sub_mul_mem (-(1+z)) y _ _ hy, \n    { convert this, ring, ring },\n    { contrapose! hzz, simp at hzz, rwa neg_add_eq_zero at hzz },\n    { simpa using hh } },\n  by_cases hz2 : (1 + z) ∈ H, \n  { right, refine ⟨hz2, _⟩,  \n    intros y hy, refine ⟨_, (aux y hy).1⟩,\n    intros c, apply hy.1, \n    convert H.mul_mem (H.inv_mem hz2) c,\n    field_simp, ring },\n  have : 1 + (1 + z) * (-1 * (1 + z)⁻¹) ∉ T,\n  { convert T.zero_nmem, field_simp, ring },\n  have : (-1) * (1 + z)⁻¹ ∉ rp.OO_m,\n  { intro c, apply this, exact (aux _ c).1 },\n  rw (show (-1) * (1 + z)⁻¹ = (- (1 + z))⁻¹, by rw [inv_neg, ← neg_eq_neg_one_mul]) at this,\n  rw ← rp.OO_m_mem_iff_inv_nmem at this,\n  rw (show 1 + z = (-1) * (-(1+z)), by ring), \n  apply h.mul_mem, apply h.neg_mem, apply h.one_mem, left, assumption, rwa neg_ne_zero,\n  intro c, apply hz2,\n  rw (show 1 + z = (-1) * (-(1 + z)), by ring), \n  apply H.mul_mem _ c, apply rp.neg_one_mem,\nend\n\nlemma rigid_pair.preadditive.mem_or_inv_mem (h : rp.preadditive) :\n  ∀ x : K, x ∈ rp.OO ∨ x⁻¹ ∈ rp.OO :=\nbegin\n  intros x, \n  by_cases hx : x ∈ rp.OO, { left, assumption },\n  right, apply h.inv_mem_of_nmem, assumption,\nend\n\nlemma rigid_pair.preadditive.add_mem (h : rp.preadditive) :\n  ∀ (x y : K), x ∈ rp.OO → y ∈ rp.OO → x + y ∈ rp.OO := \nbegin\n  intros x y hx hy,\n  by_cases hxz : x = 0, { simpa [hxz] },\n  by_cases hyz : y = 0, { simpa [hyz] },\n  cases h.mem_or_inv_mem (x * y⁻¹) with hh hh,\n  { replace hh := h.one_plus_mem _ hh, \n    convert h.mul_mem _ _ hy hh, field_simp, ring },\n  { replace hh := h.one_plus_mem _ hh, \n    convert h.mul_mem _ _ hx hh, field_simp, ring }\nend\n\ndef rigid_pair.preadditive.valuation_subring \n  (h : rp.preadditive) : valuation_subring K :=\n{ carrier := rp.OO,\n  mul_mem' := h.mul_mem,\n  one_mem' := h.one_mem,\n  add_mem' := h.add_mem,\n  zero_mem' := h.zero_mem,\n  neg_mem' := h.neg_mem,\n  mem_or_inv_mem' := h.mem_or_inv_mem }\n\nlemma rigid_pair.preadditive.units_eq \n  (h : rp.preadditive) (u : Kˣ) : \n  u ∈ h.valuation_subring.unit_group ↔ \n  (u : K) ∈ rp.UU :=\nbegin\n  split,\n  { intros h, \n    rw valuation_subring.mem_unit_group_iff_mem_and_inv_mem at h, \n    rcases h with ⟨(h1|h1),(h2|h2)⟩,\n    { rw OO_m_mem_iff_inv_nmem at h1, contradiction, exact u.ne_zero, exact h1.1 },\n    { exfalso, apply h1.1, convert H.inv_mem h2.1, simp },\n    { exfalso, apply h2.1, convert H.inv_mem h1.1 },\n    { refine ⟨h1,h2⟩ } },\n  { intros h, \n    rw valuation_subring.mem_unit_group_iff_mem_and_inv_mem, \n    split,\n    exact or.inr h.1,\n    exact or.inr h.2 }\nend\n\nlemma rigid_pair.preadditive.mem_of_mem_units\n  (h : rp.preadditive) (u : Kˣ) (hu : u ∈ h.valuation_subring.unit_group) : (u : K) ∈ H :=\nbegin\n  rw h.units_eq at hu,\n  cases hu with hu _,\n  exact hu.1,\nend\n\nlemma rigid_pair.preadditive.mem_of_mem_principal_units\n  (h : rp.preadditive) (u : Kˣ) \n  (hu : u ∈ h.valuation_subring.principal_unit_group) : \n  (u : K) ∈ T := \nbegin\n  rw valuation_subring.mem_principal_unit_group_iff_mem at hu,\n  rw valuation_subring.mem_nonunits_iff_mem_and_nmem at hu,\n  change _ ∈ rp.OO ∧ _ ∉ _ at hu,\n  cases hu with hu1 hu2,\n  by_cases hune1 : u = 1,\n  { rw hune1, simp [T.one_mem] },\n  change ¬ ∃ v, _ at hu2, push_neg at hu2, \n  have husub1 : (u : K) - 1 ≠ 0, { contrapose! hune1, rw sub_eq_zero at hune1, ext, exact hune1 },\n  specialize hu2 (units.mk0 _ husub1),\n  have : units.mk0 _ husub1 ∉ h.valuation_subring.unit_group,\n  { intro c, exact hu2 c rfl },\n  rw h.units_eq at this,\n  cases hu1, convert hu1.2, ring,\n  have : ((u : K) - 1)⁻¹ ∉ rp.OO_p, \n  { intro c, apply this, split, \n    exact hu1, exact c },\n  obtain ⟨y,z,hy,hz,hh⟩ := rp.exists_inv_eq_mul _ (H.inv_mem hu1.1) this, rw inv_inv at hh,\n  have hhneg1 : (-1 : K) ∈ rp.OO_p := h.neg_one_mem,\n  replace hhneg1 := hhneg1.2 _ hy,\n  convert (preadditive_iff _).mp h _ _ hhneg1 hz,\n  rw [mul_assoc, ← hh], ring,\nend", "meta": {"author": "adamtopaz", "repo": "lean-acl-pairs", "sha": "6ac31d86ca2739b6c18d3f05b7007e720f66299f", "save_path": "github-repos/lean/adamtopaz-lean-acl-pairs", "path": "github-repos/lean/adamtopaz-lean-acl-pairs/lean-acl-pairs-6ac31d86ca2739b6c18d3f05b7007e720f66299f/src/rigid_elements/valuation_subring_of_preadditive.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.48455788435541464}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.semiquot\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Lattice\n\n/-! # Semiquotients\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA data type for semiquotients, which are classically equivalent to\nnonempty sets, but are useful for programming; the idea is that\na semiquotient set `S` represents some (particular but unknown)\nelement of `S`. This can be used to model nondeterministic functions,\nwhich return something in a range of values (represented by the\npredicate `S`) but are not completely determined.\n-/\n\n\n/-- A member of `semiquot α` is classically a nonempty `set α`,\n  and in the VM is represented by an element of `α`; the relation\n  between these is that the VM element is required to be a member\n  of the set `s`. The specific element of `s` that the VM computes\n  is hidden by a quotient construction, allowing for the representation\n  of nondeterministic functions. -/\nstructure Semiquot.{u} (α : Type _) where mk' ::\n  s : Set α\n  val : Trunc ↥s\n#align semiquot Semiquotₓ\n\nnamespace Semiquot\n\nvariable {α : Type _} {β : Type _}\n\ninstance : Membership α (Semiquot α) :=\n  ⟨fun a q => a ∈ q.s⟩\n\n/- warning: semiquot.mk -> Semiquot.mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {a : α} {s : Set.{u_1} α}, (Membership.Mem.{u_1, u_1} α (Set.{u_1} α) (Set.hasMem.{u_1} α) a s) -> (Semiquotₓ.{u_2, u_1} α)\nbut is expected to have type\n  forall {α : Type.{u_1}} {a : α} {s : Set.{u_1} α}, (Membership.mem.{u_1, u_1} α (Set.{u_1} α) (Set.instMembershipSet.{u_1} α) a s) -> (Semiquot.{u_1} α)\nCase conversion may be inaccurate. Consider using '#align semiquot.mk Semiquot.mkₓ'. -/\n/-- Construct a `semiquot α` from `h : a ∈ s` where `s : set α`. -/\ndef mk {a : α} {s : Set α} (h : a ∈ s) : Semiquot α :=\n  ⟨s, Trunc.mk ⟨a, h⟩⟩\n#align semiquot.mk Semiquot.mk\n\n/- warning: semiquot.ext_s -> Semiquot.ext_s is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {q₁ : Semiquotₓ.{u_2, u_1} α} {q₂ : Semiquotₓ.{u_2, u_1} α}, Iff (Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) q₁ q₂) (Eq.{max (succ u_1) 1} (Set.{u_1} α) (Semiquotₓ.s.{u_2, u_1} α q₁) (Semiquotₓ.s.{u_2, u_1} α q₂))\nbut is expected to have type\n  forall {α : Type.{u_1}} {q₁ : Semiquot.{u_1} α} {q₂ : Semiquot.{u_1} α}, Iff (Eq.{succ u_1} (Semiquot.{u_1} α) q₁ q₂) (Eq.{succ u_1} (Set.{u_1} α) (Semiquot.s.{u_1} α q₁) (Semiquot.s.{u_1} α q₂))\nCase conversion may be inaccurate. Consider using '#align semiquot.ext_s Semiquot.ext_sₓ'. -/\ntheorem ext_s {q₁ q₂ : Semiquot α} : q₁ = q₂ ↔ q₁.s = q₂.s :=\n  by\n  refine' ⟨congr_arg _, fun h => _⟩\n  cases q₁\n  cases q₂\n  cc\n#align semiquot.ext_s Semiquot.ext_s\n\n/- warning: semiquot.ext -> Semiquot.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {q₁ : Semiquotₓ.{u_2, u_1} α} {q₂ : Semiquotₓ.{u_2, u_1} α}, Iff (Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) q₁ q₂) (forall (a : α), Iff (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a q₁) (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a q₂))\nbut is expected to have type\n  forall {α : Type.{u_1}} {q₁ : Semiquot.{u_1} α} {q₂ : Semiquot.{u_1} α}, Iff (Eq.{succ u_1} (Semiquot.{u_1} α) q₁ q₂) (forall (a : α), Iff (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q₁) (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q₂))\nCase conversion may be inaccurate. Consider using '#align semiquot.ext Semiquot.extₓ'. -/\ntheorem ext {q₁ q₂ : Semiquot α} : q₁ = q₂ ↔ ∀ a, a ∈ q₁ ↔ a ∈ q₂ :=\n  ext_s.trans Set.ext_iff\n#align semiquot.ext Semiquot.ext\n\n/- warning: semiquot.exists_mem -> Semiquot.exists_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (q : Semiquotₓ.{u_2, u_1} α), Exists.{succ u_1} α (fun (a : α) => Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a q)\nbut is expected to have type\n  forall {α : Type.{u_1}} (q : Semiquot.{u_1} α), Exists.{succ u_1} α (fun (a : α) => Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q)\nCase conversion may be inaccurate. Consider using '#align semiquot.exists_mem Semiquot.exists_memₓ'. -/\ntheorem exists_mem (q : Semiquot α) : ∃ a, a ∈ q :=\n  let ⟨⟨a, h⟩, h₂⟩ := q.2.exists_rep\n  ⟨a, h⟩\n#align semiquot.exists_mem Semiquot.exists_mem\n\n/- warning: semiquot.eq_mk_of_mem -> Semiquot.eq_mk_of_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {q : Semiquotₓ.{u_2, u_1} α} {a : α} (h : Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a q), Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) q (Semiquot.mk.{u_1, u_2} α a (Semiquotₓ.s.{u_2, u_1} α q) h)\nbut is expected to have type\n  forall {α : Type.{u_1}} {q : Semiquot.{u_1} α} {a : α} (h : Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q), Eq.{succ u_1} (Semiquot.{u_1} α) q (Semiquot.mk.{u_1} α a (Semiquot.s.{u_1} α q) h)\nCase conversion may be inaccurate. Consider using '#align semiquot.eq_mk_of_mem Semiquot.eq_mk_of_memₓ'. -/\ntheorem eq_mk_of_mem {q : Semiquot α} {a : α} (h : a ∈ q) : q = @mk _ a q.1 h :=\n  ext_s.2 rfl\n#align semiquot.eq_mk_of_mem Semiquot.eq_mk_of_mem\n\n/- warning: semiquot.nonempty -> Semiquot.nonempty is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (q : Semiquotₓ.{u_2, u_1} α), Set.Nonempty.{u_1} α (Semiquotₓ.s.{u_2, u_1} α q)\nbut is expected to have type\n  forall {α : Type.{u_1}} (q : Semiquot.{u_1} α), Set.Nonempty.{u_1} α (Semiquot.s.{u_1} α q)\nCase conversion may be inaccurate. Consider using '#align semiquot.nonempty Semiquot.nonemptyₓ'. -/\ntheorem nonempty (q : Semiquot α) : q.s.Nonempty :=\n  q.exists_mem\n#align semiquot.nonempty Semiquot.nonempty\n\n/- warning: semiquot.pure -> Semiquot.pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}}, α -> (Semiquotₓ.{u_2, u_1} α)\nbut is expected to have type\n  forall {α : Type.{u_1}}, α -> (Semiquot.{u_1} α)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure Semiquot.pureₓ'. -/\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure (a : α) : Semiquot α :=\n  mk (Set.mem_singleton a)\n#align semiquot.pure Semiquot.pure\n\n/- warning: semiquot.mem_pure' -> Semiquot.mem_pure' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {a : α} {b : α}, Iff (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a (Semiquot.pure.{u_1, u_2} α b)) (Eq.{succ u_1} α a b)\nbut is expected to have type\n  forall {α : Type.{u_1}} {a : α} {b : α}, Iff (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a (Semiquot.pure.{u_1} α b)) (Eq.{succ u_1} α a b)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_pure' Semiquot.mem_pure'ₓ'. -/\n@[simp]\ntheorem mem_pure' {a b : α} : a ∈ Semiquot.pure b ↔ a = b :=\n  Set.mem_singleton_iff\n#align semiquot.mem_pure' Semiquot.mem_pure'\n\n/- warning: semiquot.blur' -> Semiquot.blur' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (q : Semiquotₓ.{u_2, u_1} α) {s : Set.{u_1} α}, (HasSubset.Subset.{u_1} (Set.{u_1} α) (Set.hasSubset.{u_1} α) (Semiquotₓ.s.{u_2, u_1} α q) s) -> (Semiquotₓ.{u_3, u_1} α)\nbut is expected to have type\n  forall {α : Type.{u_1}} (q : Semiquot.{u_1} α) {s : Set.{u_1} α}, (HasSubset.Subset.{u_1} (Set.{u_1} α) (Set.instHasSubsetSet.{u_1} α) (Semiquot.s.{u_1} α q) s) -> (Semiquot.{u_1} α)\nCase conversion may be inaccurate. Consider using '#align semiquot.blur' Semiquot.blur'ₓ'. -/\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' (q : Semiquot α) {s : Set α} (h : q.s ⊆ s) : Semiquot α :=\n  ⟨s, Trunc.lift (fun a : q.s => Trunc.mk ⟨a.1, h a.2⟩) (fun _ _ => Trunc.eq _ _) q.2⟩\n#align semiquot.blur' Semiquot.blur'\n\n/- warning: semiquot.blur -> Semiquot.blur is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}}, (Set.{u_1} α) -> (Semiquotₓ.{u_2, u_1} α) -> (Semiquotₓ.{u_3, u_1} α)\nbut is expected to have type\n  forall {α : Type.{u_1}}, (Set.{u_1} α) -> (Semiquot.{u_1} α) -> (Semiquot.{u_1} α)\nCase conversion may be inaccurate. Consider using '#align semiquot.blur Semiquot.blurₓ'. -/\n/-- Replace `s` in a `q : semiquot α` with a union `s ∪ q.s` -/\ndef blur (s : Set α) (q : Semiquot α) : Semiquot α :=\n  blur' q (Set.subset_union_right s q.s)\n#align semiquot.blur Semiquot.blur\n\n/- warning: semiquot.blur_eq_blur' -> Semiquot.blur_eq_blur' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (q : Semiquotₓ.{u_2, u_1} α) (s : Set.{u_1} α) (h : HasSubset.Subset.{u_1} (Set.{u_1} α) (Set.hasSubset.{u_1} α) (Semiquotₓ.s.{u_2, u_1} α q) s), Eq.{succ u_1} (Semiquotₓ.{u_3, u_1} α) (Semiquot.blur.{u_1, u_2, u_3} α s q) (Semiquot.blur'.{u_1, u_2, u_3} α q s h)\nbut is expected to have type\n  forall {α : Type.{u_1}} (q : Semiquot.{u_1} α) (s : Set.{u_1} α) (h : HasSubset.Subset.{u_1} (Set.{u_1} α) (Set.instHasSubsetSet.{u_1} α) (Semiquot.s.{u_1} α q) s), Eq.{succ u_1} (Semiquot.{u_1} α) (Semiquot.blur.{u_1} α s q) (Semiquot.blur'.{u_1} α q s h)\nCase conversion may be inaccurate. Consider using '#align semiquot.blur_eq_blur' Semiquot.blur_eq_blur'ₓ'. -/\ntheorem blur_eq_blur' (q : Semiquot α) (s : Set α) (h : q.s ⊆ s) : blur s q = blur' q h := by\n  unfold blur <;> congr <;> exact Set.union_eq_self_of_subset_right h\n#align semiquot.blur_eq_blur' Semiquot.blur_eq_blur'\n\n/- warning: semiquot.mem_blur' -> Semiquot.mem_blur' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (q : Semiquotₓ.{u_2, u_1} α) {s : Set.{u_1} α} (h : HasSubset.Subset.{u_1} (Set.{u_1} α) (Set.hasSubset.{u_1} α) (Semiquotₓ.s.{u_2, u_1} α q) s) {a : α}, Iff (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) a (Semiquot.blur'.{u_1, u_2, u_3} α q s h)) (Membership.Mem.{u_1, u_1} α (Set.{u_1} α) (Set.hasMem.{u_1} α) a s)\nbut is expected to have type\n  forall {α : Type.{u_1}} (q : Semiquot.{u_1} α) {s : Set.{u_1} α} (h : HasSubset.Subset.{u_1} (Set.{u_1} α) (Set.instHasSubsetSet.{u_1} α) (Semiquot.s.{u_1} α q) s) {a : α}, Iff (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a (Semiquot.blur'.{u_1} α q s h)) (Membership.mem.{u_1, u_1} α (Set.{u_1} α) (Set.instMembershipSet.{u_1} α) a s)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_blur' Semiquot.mem_blur'ₓ'. -/\n@[simp]\ntheorem mem_blur' (q : Semiquot α) {s : Set α} (h : q.s ⊆ s) {a : α} : a ∈ blur' q h ↔ a ∈ s :=\n  Iff.rfl\n#align semiquot.mem_blur' Semiquot.mem_blur'\n\n/- warning: semiquot.of_trunc -> Semiquot.ofTrunc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}}, (Trunc.{succ u_1} α) -> (Semiquotₓ.{u_2, u_1} α)\nbut is expected to have type\n  forall {α : Type.{u_1}}, (Trunc.{succ u_1} α) -> (Semiquot.{u_1} α)\nCase conversion may be inaccurate. Consider using '#align semiquot.of_trunc Semiquot.ofTruncₓ'. -/\n/-- Convert a `trunc α` to a `semiquot α`. -/\ndef ofTrunc (q : Trunc α) : Semiquot α :=\n  ⟨Set.univ, q.map fun a => ⟨a, trivial⟩⟩\n#align semiquot.of_trunc Semiquot.ofTrunc\n\n/- warning: semiquot.to_trunc -> Semiquot.toTrunc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}}, (Semiquotₓ.{u_2, u_1} α) -> (Trunc.{succ u_1} α)\nbut is expected to have type\n  forall {α : Type.{u_1}}, (Semiquot.{u_1} α) -> (Trunc.{succ u_1} α)\nCase conversion may be inaccurate. Consider using '#align semiquot.to_trunc Semiquot.toTruncₓ'. -/\n/-- Convert a `semiquot α` to a `trunc α`. -/\ndef toTrunc (q : Semiquot α) : Trunc α :=\n  q.2.map Subtype.val\n#align semiquot.to_trunc Semiquot.toTrunc\n\n/- warning: semiquot.lift_on -> Semiquot.liftOn is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (q : Semiquotₓ.{u_3, u_1} α) (f : α -> β), (forall (a : α), (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) a q) -> (forall (b : α), (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) b q) -> (Eq.{succ u_2} β (f a) (f b)))) -> β\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (q : Semiquot.{u_1} α) (f : α -> β), (forall (a : α), (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q) -> (forall (b : α), (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) b q) -> (Eq.{succ u_2} β (f a) (f b)))) -> β\nCase conversion may be inaccurate. Consider using '#align semiquot.lift_on Semiquot.liftOnₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » q) -/\n/-- If `f` is a constant on `q.s`, then `q.lift_on f` is the value of `f`\nat any point of `q`. -/\ndef liftOn (q : Semiquot α) (f : α → β) (h : ∀ (a) (_ : a ∈ q) (b) (_ : b ∈ q), f a = f b) : β :=\n  Trunc.liftOn q.2 (fun x => f x.1) fun x y => h _ x.2 _ y.2\n#align semiquot.lift_on Semiquot.liftOn\n\n/- warning: semiquot.lift_on_of_mem -> Semiquot.liftOn_ofMem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (q : Semiquotₓ.{u_3, u_1} α) (f : α -> β) (h : forall (a : α), (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) a q) -> (forall (b : α), (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) b q) -> (Eq.{succ u_2} β (f a) (f b)))) (a : α), (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) a q) -> (Eq.{succ u_2} β (Semiquot.liftOn.{u_1, u_2, u_3} α β q f h) (f a))\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (q : Semiquot.{u_1} α) (f : α -> β) (h : forall (a : α), (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q) -> (forall (b : α), (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) b q) -> (Eq.{succ u_2} β (f a) (f b)))) (a : α), (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q) -> (Eq.{succ u_2} β (Semiquot.liftOn.{u_1, u_2} α β q f h) (f a))\nCase conversion may be inaccurate. Consider using '#align semiquot.lift_on_of_mem Semiquot.liftOn_ofMemₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » q) -/\ntheorem liftOn_ofMem (q : Semiquot α) (f : α → β) (h : ∀ (a) (_ : a ∈ q) (b) (_ : b ∈ q), f a = f b)\n    (a : α) (aq : a ∈ q) : liftOn q f h = f a := by\n  revert h <;> rw [eq_mk_of_mem aq] <;> intro <;> rfl\n#align semiquot.lift_on_of_mem Semiquot.liftOn_ofMem\n\n/- warning: semiquot.map -> Semiquot.map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}}, (α -> β) -> (Semiquotₓ.{u_3, u_1} α) -> (Semiquotₓ.{u_4, u_2} β)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}}, (α -> β) -> (Semiquot.{u_1} α) -> (Semiquot.{u_2} β)\nCase conversion may be inaccurate. Consider using '#align semiquot.map Semiquot.mapₓ'. -/\n/-- Apply a function to the unknown value stored in a `semiquot α`. -/\ndef map (f : α → β) (q : Semiquot α) : Semiquot β :=\n  ⟨f '' q.1, q.2.map fun x => ⟨f x.1, Set.mem_image_of_mem _ x.2⟩⟩\n#align semiquot.map Semiquot.map\n\n/- warning: semiquot.mem_map -> Semiquot.mem_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (f : α -> β) (q : Semiquotₓ.{u_3, u_1} α) (b : β), Iff (Membership.Mem.{u_2, u_2} β (Semiquotₓ.{u_4, u_2} β) (Semiquotₓ.hasMem.{u_2, u_4} β) b (Semiquot.map.{u_1, u_2, u_3, u_4} α β f q)) (Exists.{succ u_1} α (fun (a : α) => And (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) a q) (Eq.{succ u_2} β (f a) b)))\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (f : α -> β) (q : Semiquot.{u_1} α) (b : β), Iff (Membership.mem.{u_2, u_2} β (Semiquot.{u_2} β) (Semiquot.instMembershipSemiquot.{u_2} β) b (Semiquot.map.{u_1, u_2} α β f q)) (Exists.{succ u_1} α (fun (a : α) => And (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q) (Eq.{succ u_2} β (f a) b)))\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_map Semiquot.mem_mapₓ'. -/\n@[simp]\ntheorem mem_map (f : α → β) (q : Semiquot α) (b : β) : b ∈ map f q ↔ ∃ a, a ∈ q ∧ f a = b :=\n  Set.mem_image _ _ _\n#align semiquot.mem_map Semiquot.mem_map\n\n/- warning: semiquot.bind -> Semiquot.bind is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}}, (Semiquotₓ.{u_3, u_1} α) -> (α -> (Semiquotₓ.{u_4, u_2} β)) -> (Semiquotₓ.{u_5, u_2} β)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}}, (Semiquot.{u_1} α) -> (α -> (Semiquot.{u_2} β)) -> (Semiquot.{u_2} β)\nCase conversion may be inaccurate. Consider using '#align semiquot.bind Semiquot.bindₓ'. -/\n/-- Apply a function returning a `semiquot` to a `semiquot`. -/\ndef bind (q : Semiquot α) (f : α → Semiquot β) : Semiquot β :=\n  ⟨⋃ a ∈ q.1, (f a).1, q.2.bind fun a => (f a.1).2.map fun b => ⟨b.1, Set.mem_bunionᵢ a.2 b.2⟩⟩\n#align semiquot.bind Semiquot.bind\n\n/- warning: semiquot.mem_bind -> Semiquot.mem_bind is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (q : Semiquotₓ.{u_3, u_1} α) (f : α -> (Semiquotₓ.{u_4, u_2} β)) (b : β), Iff (Membership.Mem.{u_2, u_2} β (Semiquotₓ.{u_5, u_2} β) (Semiquotₓ.hasMem.{u_2, u_5} β) b (Semiquot.bind.{u_1, u_2, u_3, u_4, u_5} α β q f)) (Exists.{succ u_1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) a q) (fun (H : Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_3, u_1} α) (Semiquotₓ.hasMem.{u_1, u_3} α) a q) => Membership.Mem.{u_2, u_2} β (Semiquotₓ.{u_4, u_2} β) (Semiquotₓ.hasMem.{u_2, u_4} β) b (f a))))\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_2}} (q : Semiquot.{u_1} α) (f : α -> (Semiquot.{u_2} β)) (b : β), Iff (Membership.mem.{u_2, u_2} β (Semiquot.{u_2} β) (Semiquot.instMembershipSemiquot.{u_2} β) b (Semiquot.bind.{u_1, u_2} α β q f)) (Exists.{succ u_1} α (fun (a : α) => And (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a q) (Membership.mem.{u_2, u_2} β (Semiquot.{u_2} β) (Semiquot.instMembershipSemiquot.{u_2} β) b (f a))))\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_bind Semiquot.mem_bindₓ'. -/\n@[simp]\ntheorem mem_bind (q : Semiquot α) (f : α → Semiquot β) (b : β) : b ∈ bind q f ↔ ∃ a ∈ q, b ∈ f a :=\n  Set.mem_unionᵢ₂\n#align semiquot.mem_bind Semiquot.mem_bind\n\ninstance : Monad Semiquot where\n  pure := @Semiquot.pure\n  map := @Semiquot.map\n  bind := @Semiquot.bind\n\n/- warning: semiquot.map_def -> Semiquot.map_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_1}}, Eq.{succ u_1} ((α -> β) -> (Semiquotₓ.{u_2, u_1} α) -> (Semiquotₓ.{u_2, u_1} β)) (Functor.map.{u_1, u_1} (fun {α : Type.{u_1}} => Semiquotₓ.{u_2, u_1} α) (Applicative.toFunctor.{u_1, u_1} (fun {α : Type.{u_1}} => Semiquotₓ.{u_2, u_1} α) (Monad.toApplicative.{u_1, u_1} (fun {α : Type.{u_1}} => Semiquotₓ.{u_2, u_1} α) Semiquotₓ.monad.{u_1, u_2})) α β) (Semiquot.map.{u_1, u_1, u_2, u_2} α β)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_1}}, Eq.{succ u_1} ((α -> β) -> (Semiquot.{u_1} α) -> (Semiquot.{u_1} β)) (fun (x._@.Mathlib.Data.Semiquot._hyg.993 : α -> β) (x._@.Mathlib.Data.Semiquot._hyg.995 : Semiquot.{u_1} α) => Functor.map.{u_1, u_1} Semiquot.{u_1} (Applicative.toFunctor.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α β x._@.Mathlib.Data.Semiquot._hyg.993 x._@.Mathlib.Data.Semiquot._hyg.995) (Semiquot.map.{u_1, u_1} α β)\nCase conversion may be inaccurate. Consider using '#align semiquot.map_def Semiquot.map_defₓ'. -/\n@[simp]\ntheorem map_def {β} : ((· <$> ·) : (α → β) → Semiquot α → Semiquot β) = map :=\n  rfl\n#align semiquot.map_def Semiquot.map_def\n\n/- warning: semiquot.bind_def -> Semiquot.bind_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {β : Type.{u_1}}, Eq.{succ u_1} ((Semiquotₓ.{u_2, u_1} α) -> (α -> (Semiquotₓ.{u_2, u_1} β)) -> (Semiquotₓ.{u_2, u_1} β)) (Bind.bind.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toHasBind.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2}) α β) (Semiquot.bind.{u_1, u_1, u_2, u_2, u_2} α β)\nbut is expected to have type\n  forall {α : Type.{u_1}} {β : Type.{u_1}}, Eq.{succ u_1} ((Semiquot.{u_1} α) -> (α -> (Semiquot.{u_1} β)) -> (Semiquot.{u_1} β)) (fun (x._@.Mathlib.Data.Semiquot._hyg.1033 : Semiquot.{u_1} α) (x._@.Mathlib.Data.Semiquot._hyg.1035 : α -> (Semiquot.{u_1} β)) => Bind.bind.{u_1, u_1} Semiquot.{u_1} (Monad.toBind.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1}) α β x._@.Mathlib.Data.Semiquot._hyg.1033 x._@.Mathlib.Data.Semiquot._hyg.1035) (Semiquot.bind.{u_1, u_1} α β)\nCase conversion may be inaccurate. Consider using '#align semiquot.bind_def Semiquot.bind_defₓ'. -/\n@[simp]\ntheorem bind_def {β} : ((· >>= ·) : Semiquot α → (α → Semiquot β) → Semiquot β) = bind :=\n  rfl\n#align semiquot.bind_def Semiquot.bind_def\n\n/- warning: semiquot.mem_pure -> Semiquot.mem_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {a : α} {b : α}, Iff (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a (Pure.pure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2})) α b)) (Eq.{succ u_1} α a b)\nbut is expected to have type\n  forall {α : Type.{u_1}} {a : α} {b : α}, Iff (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α b)) (Eq.{succ u_1} α a b)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_pure Semiquot.mem_pureₓ'. -/\n@[simp]\ntheorem mem_pure {a b : α} : a ∈ (pure b : Semiquot α) ↔ a = b :=\n  Set.mem_singleton_iff\n#align semiquot.mem_pure Semiquot.mem_pure\n\n/- warning: semiquot.mem_pure_self -> Semiquot.mem_pure_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (a : α), Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a (Pure.pure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2})) α a)\nbut is expected to have type\n  forall {α : Type.{u_1}} (a : α), Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α a)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_pure_self Semiquot.mem_pure_selfₓ'. -/\ntheorem mem_pure_self (a : α) : a ∈ (pure a : Semiquot α) :=\n  Set.mem_singleton a\n#align semiquot.mem_pure_self Semiquot.mem_pure_self\n\n/- warning: semiquot.pure_inj -> Semiquot.pure_inj is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {a : α} {b : α}, Iff (Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) (Pure.pure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2})) α a) (Pure.pure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2})) α b)) (Eq.{succ u_1} α a b)\nbut is expected to have type\n  forall {α : Type.{u_1}} {a : α} {b : α}, Iff (Eq.{succ u_1} (Semiquot.{u_1} α) (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α a) (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α b)) (Eq.{succ u_1} α a b)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure_inj Semiquot.pure_injₓ'. -/\n@[simp]\ntheorem pure_inj {a b : α} : (pure a : Semiquot α) = pure b ↔ a = b :=\n  ext_s.trans Set.singleton_eq_singleton_iff\n#align semiquot.pure_inj Semiquot.pure_inj\n\ninstance : LawfulMonad Semiquot\n    where\n  pure_bind α β x f := ext.2 <| by simp\n  bind_assoc α β γ s f g :=\n    ext.2 <| by\n      simp <;>\n        exact fun c =>\n          ⟨fun ⟨b, ⟨a, as, bf⟩, cg⟩ => ⟨a, as, b, bf, cg⟩, fun ⟨a, as, b, bf, cg⟩ =>\n            ⟨b, ⟨a, as, bf⟩, cg⟩⟩\n  id_map α q := ext.2 <| by simp\n  bind_pure_comp_eq_map α β f s := ext.2 <| by simp [eq_comm]\n\ninstance : LE (Semiquot α) :=\n  ⟨fun s t => s.s ⊆ t.s⟩\n\ninstance : PartialOrder (Semiquot α)\n    where\n  le s t := ∀ ⦃x⦄, x ∈ s → x ∈ t\n  le_refl s := Set.Subset.refl _\n  le_trans s t u := Set.Subset.trans\n  le_antisymm s t h₁ h₂ := ext_s.2 (Set.Subset.antisymm h₁ h₂)\n\ninstance : SemilatticeSup (Semiquot α) :=\n  { Semiquot.partialOrder with\n    sup := fun s => blur s.s\n    le_sup_left := fun s t => Set.subset_union_left _ _\n    le_sup_right := fun s t => Set.subset_union_right _ _\n    sup_le := fun s t u => Set.union_subset }\n\n/- warning: semiquot.pure_le -> Semiquot.pure_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {a : α} {s : Semiquotₓ.{u_2, u_1} α}, Iff (LE.le.{u_1} (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasLe.{u_1, u_2} α) (Pure.pure.{u_1, u_1} (fun {α : Type.{u_1}} => Semiquotₓ.{u_2, u_1} α) (Applicative.toHasPure.{u_1, u_1} (fun {α : Type.{u_1}} => Semiquotₓ.{u_2, u_1} α) (Monad.toApplicative.{u_1, u_1} (fun {α : Type.{u_1}} => Semiquotₓ.{u_2, u_1} α) Semiquotₓ.monad.{u_1, u_2})) α a) s) (Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a s)\nbut is expected to have type\n  forall {α : Type.{u_1}} {a : α} {s : Semiquot.{u_1} α}, Iff (LE.le.{u_1} (Semiquot.{u_1} α) (Semiquot.instLESemiquot.{u_1} α) (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α a) s) (Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a s)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure_le Semiquot.pure_leₓ'. -/\n@[simp]\ntheorem pure_le {a : α} {s : Semiquot α} : pure a ≤ s ↔ a ∈ s :=\n  Set.singleton_subset_iff\n#align semiquot.pure_le Semiquot.pure_le\n\n/- warning: semiquot.is_pure -> Semiquot.IsPure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}}, (Semiquotₓ.{u_2, u_1} α) -> Prop\nbut is expected to have type\n  forall {α : Type.{u_1}}, (Semiquot.{u_1} α) -> Prop\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure Semiquot.IsPureₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b «expr ∈ » q) -/\n/-- Assert that a `semiquot` contains only one possible value. -/\ndef IsPure (q : Semiquot α) : Prop :=\n  ∀ (a) (_ : a ∈ q) (b) (_ : b ∈ q), a = b\n#align semiquot.is_pure Semiquot.IsPure\n\n/- warning: semiquot.get -> Semiquot.get is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (q : Semiquotₓ.{u_2, u_1} α), (Semiquot.IsPure.{u_1, u_2} α q) -> α\nbut is expected to have type\n  forall {α : Type.{u_1}} (q : Semiquot.{u_1} α), (Semiquot.IsPure.{u_1} α q) -> α\nCase conversion may be inaccurate. Consider using '#align semiquot.get Semiquot.getₓ'. -/\n/-- Extract the value from a `is_pure` semiquotient. -/\ndef get (q : Semiquot α) (h : q.IsPure) : α :=\n  liftOn q id h\n#align semiquot.get Semiquot.get\n\n/- warning: semiquot.get_mem -> Semiquot.get_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {q : Semiquotₓ.{u_2, u_1} α} (p : Semiquot.IsPure.{u_1, u_2} α q), Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) (Semiquot.get.{u_1, u_2} α q p) q\nbut is expected to have type\n  forall {α : Type.{u_1}} {q : Semiquot.{u_1} α} (p : Semiquot.IsPure.{u_1} α q), Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) (Semiquot.get.{u_1} α q p) q\nCase conversion may be inaccurate. Consider using '#align semiquot.get_mem Semiquot.get_memₓ'. -/\ntheorem get_mem {q : Semiquot α} (p) : get q p ∈ q :=\n  by\n  let ⟨a, h⟩ := exists_mem q\n  unfold get <;> rw [lift_on_of_mem q _ _ a h] <;> exact h\n#align semiquot.get_mem Semiquot.get_mem\n\n/- warning: semiquot.eq_pure -> Semiquot.eq_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {q : Semiquotₓ.{u_2, u_1} α} (p : Semiquot.IsPure.{u_1, u_2} α q), Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) q (Pure.pure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2})) α (Semiquot.get.{u_1, u_2} α q p))\nbut is expected to have type\n  forall {α : Type.{u_1}} {q : Semiquot.{u_1} α} (p : Semiquot.IsPure.{u_1} α q), Eq.{succ u_1} (Semiquot.{u_1} α) q (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α (Semiquot.get.{u_1} α q p))\nCase conversion may be inaccurate. Consider using '#align semiquot.eq_pure Semiquot.eq_pureₓ'. -/\ntheorem eq_pure {q : Semiquot α} (p) : q = pure (get q p) :=\n  ext.2 fun a => by simp <;> exact ⟨fun h => p _ h _ (get_mem _), fun e => e.symm ▸ get_mem _⟩\n#align semiquot.eq_pure Semiquot.eq_pure\n\n/- warning: semiquot.pure_is_pure -> Semiquot.pure_isPure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (a : α), Semiquot.IsPure.{u_1, u_2} α (Pure.pure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2})) α a)\nbut is expected to have type\n  forall {α : Type.{u_1}} (a : α), Semiquot.IsPure.{u_1} α (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α a)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure_is_pure Semiquot.pure_isPureₓ'. -/\n@[simp]\ntheorem pure_isPure (a : α) : IsPure (pure a)\n  | b, ab, c, ac => by\n    rw [mem_pure] at ab ac\n    cc\n#align semiquot.pure_is_pure Semiquot.pure_isPure\n\n/- warning: semiquot.is_pure_iff -> Semiquot.isPure_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {s : Semiquotₓ.{u_2, u_1} α}, Iff (Semiquot.IsPure.{u_1, u_2} α s) (Exists.{succ u_1} α (fun (a : α) => Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) s (Pure.pure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquotₓ.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquotₓ.{u_2, u_1} Semiquotₓ.monad.{u_1, u_2})) α a)))\nbut is expected to have type\n  forall {α : Type.{u_1}} {s : Semiquot.{u_1} α}, Iff (Semiquot.IsPure.{u_1} α s) (Exists.{succ u_1} α (fun (a : α) => Eq.{succ u_1} (Semiquot.{u_1} α) s (Pure.pure.{u_1, u_1} Semiquot.{u_1} (Applicative.toPure.{u_1, u_1} Semiquot.{u_1} (Monad.toApplicative.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1})) α a)))\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure_iff Semiquot.isPure_iffₓ'. -/\ntheorem isPure_iff {s : Semiquot α} : IsPure s ↔ ∃ a, s = pure a :=\n  ⟨fun h => ⟨_, eq_pure h⟩, fun ⟨a, e⟩ => e.symm ▸ pure_isPure _⟩\n#align semiquot.is_pure_iff Semiquot.isPure_iff\n\n/- warning: semiquot.is_pure.mono -> Semiquot.IsPure.mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {s : Semiquotₓ.{u_2, u_1} α} {t : Semiquotₓ.{u_2, u_1} α}, (LE.le.{u_1} (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasLe.{u_1, u_2} α) s t) -> (Semiquot.IsPure.{u_1, u_2} α t) -> (Semiquot.IsPure.{u_1, u_2} α s)\nbut is expected to have type\n  forall {α : Type.{u_1}} {s : Semiquot.{u_1} α} {t : Semiquot.{u_1} α}, (LE.le.{u_1} (Semiquot.{u_1} α) (Semiquot.instLESemiquot.{u_1} α) s t) -> (Semiquot.IsPure.{u_1} α t) -> (Semiquot.IsPure.{u_1} α s)\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure.mono Semiquot.IsPure.monoₓ'. -/\ntheorem IsPure.mono {s t : Semiquot α} (st : s ≤ t) (h : IsPure t) : IsPure s\n  | a, as, b, bs => h _ (st as) _ (st bs)\n#align semiquot.is_pure.mono Semiquot.IsPure.mono\n\n/- warning: semiquot.is_pure.min -> Semiquot.IsPure.min is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} {s : Semiquotₓ.{u_2, u_1} α} {t : Semiquotₓ.{u_2, u_1} α}, (Semiquot.IsPure.{u_1, u_2} α t) -> (Iff (LE.le.{u_1} (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasLe.{u_1, u_2} α) s t) (Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) s t))\nbut is expected to have type\n  forall {α : Type.{u_1}} {s : Semiquot.{u_1} α} {t : Semiquot.{u_1} α}, (Semiquot.IsPure.{u_1} α t) -> (Iff (LE.le.{u_1} (Semiquot.{u_1} α) (Semiquot.instLESemiquot.{u_1} α) s t) (Eq.{succ u_1} (Semiquot.{u_1} α) s t))\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure.min Semiquot.IsPure.minₓ'. -/\ntheorem IsPure.min {s t : Semiquot α} (h : IsPure t) : s ≤ t ↔ s = t :=\n  ⟨fun st =>\n    le_antisymm st <| by\n      rw [eq_pure h, eq_pure (h.mono st)] <;> simp <;> exact h _ (get_mem _) _ (st <| get_mem _),\n    le_of_eq⟩\n#align semiquot.is_pure.min Semiquot.IsPure.min\n\n/- warning: semiquot.is_pure_of_subsingleton -> Semiquot.isPure_of_subsingleton is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} [_inst_1 : Subsingleton.{succ u_1} α] (q : Semiquotₓ.{u_2, u_1} α), Semiquot.IsPure.{u_1, u_2} α q\nbut is expected to have type\n  forall {α : Type.{u_1}} [_inst_1 : Subsingleton.{succ u_1} α] (q : Semiquot.{u_1} α), Semiquot.IsPure.{u_1} α q\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure_of_subsingleton Semiquot.isPure_of_subsingletonₓ'. -/\ntheorem isPure_of_subsingleton [Subsingleton α] (q : Semiquot α) : IsPure q\n  | a, b, aq, bq => Subsingleton.elim _ _\n#align semiquot.is_pure_of_subsingleton Semiquot.isPure_of_subsingleton\n\n/- warning: semiquot.univ -> Semiquot.univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} α], Semiquotₓ.{u_2, u_1} α\nbut is expected to have type\n  forall {α : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} α], Semiquot.{u_1} α\nCase conversion may be inaccurate. Consider using '#align semiquot.univ Semiquot.univₓ'. -/\n/-- `univ : semiquot α` represents an unspecified element of `univ : set α`. -/\ndef univ [Inhabited α] : Semiquot α :=\n  mk <| Set.mem_univ default\n#align semiquot.univ Semiquot.univ\n\ninstance [Inhabited α] : Inhabited (Semiquot α) :=\n  ⟨univ⟩\n\n/- warning: semiquot.mem_univ -> Semiquot.mem_univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} α] (a : α), Membership.Mem.{u_1, u_1} α (Semiquotₓ.{u_2, u_1} α) (Semiquotₓ.hasMem.{u_1, u_2} α) a (Semiquot.univ.{u_1, u_2} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} α] (a : α), Membership.mem.{u_1, u_1} α (Semiquot.{u_1} α) (Semiquot.instMembershipSemiquot.{u_1} α) a (Semiquot.univ.{u_1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_univ Semiquot.mem_univₓ'. -/\n@[simp]\ntheorem mem_univ [Inhabited α] : ∀ a, a ∈ @univ α _ :=\n  @Set.mem_univ α\n#align semiquot.mem_univ Semiquot.mem_univ\n\n/- warning: semiquot.univ_unique -> Semiquot.univ_unique is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} (I : Inhabited.{succ u_1} α) (J : Inhabited.{succ u_1} α), Eq.{succ u_1} (Semiquotₓ.{u_2, u_1} α) (Semiquot.univ.{u_1, u_2} α I) (Semiquot.univ.{u_1, u_2} α J)\nbut is expected to have type\n  forall {α : Type.{u_1}} (I : Inhabited.{succ u_1} α) (J : Inhabited.{succ u_1} α), Eq.{succ u_1} (Semiquot.{u_1} α) (Semiquot.univ.{u_1} α I) (Semiquot.univ.{u_1} α J)\nCase conversion may be inaccurate. Consider using '#align semiquot.univ_unique Semiquot.univ_uniqueₓ'. -/\n@[congr]\ntheorem univ_unique (I J : Inhabited α) : @univ _ I = @univ _ J :=\n  ext.2 <| by simp\n#align semiquot.univ_unique Semiquot.univ_unique\n\n/- warning: semiquot.is_pure_univ -> Semiquot.isPure_univ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} α], Iff (Semiquot.IsPure.{u_1, u_2} α (Semiquot.univ.{u_1, u_2} α _inst_1)) (Subsingleton.{succ u_1} α)\nbut is expected to have type\n  forall {α : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} α], Iff (Semiquot.IsPure.{u_1} α (Semiquot.univ.{u_1} α _inst_1)) (Subsingleton.{succ u_1} α)\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure_univ Semiquot.isPure_univₓ'. -/\n@[simp]\ntheorem isPure_univ [Inhabited α] : @IsPure α univ ↔ Subsingleton α :=\n  ⟨fun h => ⟨fun a b => h a trivial b trivial⟩, fun ⟨h⟩ a _ b _ => h a b⟩\n#align semiquot.is_pure_univ Semiquot.isPure_univ\n\ninstance [Inhabited α] : OrderTop (Semiquot α)\n    where\n  top := univ\n  le_top s := Set.subset_univ _\n\nend Semiquot\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Semiquot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.48455787220093016}}
{"text": "import list.simple_value \n       list.modify.basic\n\n\n\nopen list\n\n/-- Man in the middle for all-chain or all-loop situations -/\ntheorem MITM_baby (tf : ℤ) (L1 L2 : list ℤ) (d : ℤ) (h : list.modify L1 L2 d)\n  (n : ℕ) (hL1 : L1.length = n) (hL2 : L2.length = n) (i : fin n) :\n  abs (list.value_i tf n L1 i hL1 - list.value_i tf n L2 i hL2) ≤ d :=\nbegin\n  revert L1 L2, -- so the inductive hypothesis does not depend on the exact choice of L1 and L2\n  induction n with e he, -- by induction on the number of components\n\n    -- base case : n = 0\n    {cases i.is_lt},\n\n    -- inductive step : n = nat.succ e\n    {intros L1 L2 h hL1 hL2,\n    unfold list.value_i,\n\n    /- after unfolding, the goal is :\n       abs\n       (aux_fun (nth_le L1 (i.val) _) tf (min' (of_fn (λ (j : fin e), value_i tf e (remove_nth L1 (i.val)) j _))) -\n        aux_fun (nth_le L2 (i.val) _) tf (min' (of_fn (λ (j : fin e), value_i tf e (remove_nth L2 (i.val)) j _)))) \n        ≤ d\n    -/\n\n    /- now either we opened the component in which the games differ or not-/\n    by_cases hin : h.n = i.val,\n    \n      { -- i = place where lists differ\n        have heq := h.heq,\n        rw hin at heq, -- after substitution, heq is remove_nth L1 (i.val) = remove_nth L2 (i.val)\n        simp only [heq], -- simp only rewrites in the arguments of nth_le as well \n        apply list.aux_fun_L1, -- see list.simple_value\n        convert h.bound, -- goal is basically just h.bound\n          exact hin.symm, /- need to prove i.val = h.n, as the goal described the indices\n                             using i.val, and h.bound used h.n-/\n          exact hin.symm, -- because i.val/h.n comes up twice\n      },\n\n      { -- i ≠ place where lists differ\n           /- so this time by another lemma nth_le L1 (i.val) _ = nth_le L2 (i.val) _ -/\n        rw list.modify_same h i.val _ (begin rw hL2, exact i.is_lt end) hin, -- see list.modify.basic\n        apply list.aux_fun_L2, -- see list.simple_value\n        -- apply \"lists differ by at most d -> min differs by at most d\"\n        apply list.min'_change, -- see list.min.basic\n\n          {simp only [list.length_of_fn]}, -- use that length (of_fn (λ (j : fin e), ...))) = e\n          \n          --prove 0 <= d from h using that the absolute value is non-negative \n          {apply le_trans _ h.bound, -- transitivity of ≤ \n          show abs (nth_le L1 h.n h.ha - nth_le L2 h.n h.hb) ≥ 0, \n          exact abs_nonneg _,}, -- absolute values are non-negative\n\n          {intros n HnL HnM,        \n          rw eq_comm at hin, -- commutativity of =\n\n          --need the following as argument for he (in he L1 = (remove_nth L1 (i.val))\n          --and L2 = (remove_nth L2 (i.val)))\n          have P : list.modify (remove_nth L1 (i.val)) (remove_nth L2 (i.val)) d, \n            {exact list.modify_remove_nth h i.val hin}, -- see list.modify.basic\n \n          -- put the goal into the correct form for the inductive hypothis he\n          rw length_of_fn at HnL,\n          rw nth_le_of_fn _ ⟨n, HnL⟩, /- nth_le (of_fn f) ⟨n, HnL⟩ = f (⟨n, HnL⟩)\n                                        (where f is : λ (j : fin e), value_i tf e (remove_nth L1 (i.val)) j _)) -/\n          rw nth_le_of_fn _ ⟨n, HnL⟩,\n\n          exact he _ _ _ P _ _, /- use inductive hypothesis \n                                   (every argument other than P can be inferred)-/\n          },\n      },\n   }\nend\n", "meta": {"author": "ImperialCollegeLondon", "repo": "dots_and_boxes", "sha": "f7bd0b1603674a657170c5395adb717c4f670220", "save_path": "github-repos/lean/ImperialCollegeLondon-dots_and_boxes", "path": "github-repos/lean/ImperialCollegeLondon-dots_and_boxes/dots_and_boxes-f7bd0b1603674a657170c5395adb717c4f670220/src/MITM_baby.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.4845490850149163}}
{"text": "/-\nCopyright (c) 2022 Alexander Bentkamp. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alexander Bentkamp, Jeremy Avigad, Johan Commelin\n\n! This file was ported from Lean 3 source module linear_algebra.matrix.schur_complement\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.Matrix.NonsingularInverse\nimport Mathbin.LinearAlgebra.Matrix.PosDef\n\n/-! # Schur complement\n\nThis file proves properties of the Schur complement `D - C A⁻¹ B` of a block matrix `[A B; C D]`.\n\nThe determinant of a block matrix in terms of the Schur complement is expressed in the lemmas\n`matrix.det_from_blocks₁₁` and `matrix.det_from_blocks₂₂` in the file\n`linear_algebra.matrix.nonsingular_inverse`.\n\n## Main result\n\n * `matrix.schur_complement_pos_semidef_iff` : If a matrix `A` is positive definite, then `[A B; Bᴴ\n  D]` is postive semidefinite if and only if `D - Bᴴ A⁻¹ B` is postive semidefinite.\n\n-/\n\n\nnamespace Matrix\n\nopen Matrix\n\nvariable {n : Type _} {m : Type _} {𝕜 : Type _} [IsROrC 𝕜]\n\n-- mathport name: «expr ⊕ᵥ »\nscoped infixl:65 \" ⊕ᵥ \" => Sum.elim\n\ntheorem schur_complement_eq₁₁ [Fintype m] [DecidableEq m] [Fintype n] {A : Matrix m m 𝕜}\n    (B : Matrix m n 𝕜) (D : Matrix n n 𝕜) (x : m → 𝕜) (y : n → 𝕜) [Invertible A]\n    (hA : A.IsHermitian) :\n    vecMul (star (x ⊕ᵥ y)) (fromBlocks A B Bᴴ D) ⬝ᵥ (x ⊕ᵥ y) =\n      vecMul (star (x + (A⁻¹ ⬝ B).mulVec y)) A ⬝ᵥ (x + (A⁻¹ ⬝ B).mulVec y) +\n        vecMul (star y) (D - Bᴴ ⬝ A⁻¹ ⬝ B) ⬝ᵥ y :=\n  by\n  simp [Function.star_sum_elim, from_blocks_mul_vec, vec_mul_from_blocks, add_vec_mul,\n    dot_product_mul_vec, vec_mul_sub, Matrix.mul_assoc, vec_mul_mul_vec, hA.eq,\n    conj_transpose_nonsing_inv, star_mul_vec]\n  abel\n#align matrix.schur_complement_eq₁₁ Matrix.schur_complement_eq₁₁\n\ntheorem schur_complement_eq₂₂ [Fintype m] [Fintype n] [DecidableEq n] (A : Matrix m m 𝕜)\n    (B : Matrix m n 𝕜) {D : Matrix n n 𝕜} (x : m → 𝕜) (y : n → 𝕜) [Invertible D]\n    (hD : D.IsHermitian) :\n    vecMul (star (x ⊕ᵥ y)) (fromBlocks A B Bᴴ D) ⬝ᵥ (x ⊕ᵥ y) =\n      vecMul (star ((D⁻¹ ⬝ Bᴴ).mulVec x + y)) D ⬝ᵥ ((D⁻¹ ⬝ Bᴴ).mulVec x + y) +\n        vecMul (star x) (A - B ⬝ D⁻¹ ⬝ Bᴴ) ⬝ᵥ x :=\n  by\n  simp [Function.star_sum_elim, from_blocks_mul_vec, vec_mul_from_blocks, add_vec_mul,\n    dot_product_mul_vec, vec_mul_sub, Matrix.mul_assoc, vec_mul_mul_vec, hD.eq,\n    conj_transpose_nonsing_inv, star_mul_vec]\n  abel\n#align matrix.schur_complement_eq₂₂ Matrix.schur_complement_eq₂₂\n\nend Matrix\n\nnamespace Matrix\n\nopen Matrix\n\nvariable {n : Type _} {m : Type _} {𝕜 : Type _} [IsROrC 𝕜]\n\ntheorem IsHermitian.from_blocks₁₁ [Fintype m] [DecidableEq m] {A : Matrix m m 𝕜} (B : Matrix m n 𝕜)\n    (D : Matrix n n 𝕜) (hA : A.IsHermitian) :\n    (fromBlocks A B Bᴴ D).IsHermitian ↔ (D - Bᴴ ⬝ A⁻¹ ⬝ B).IsHermitian :=\n  by\n  have hBAB : (Bᴴ ⬝ A⁻¹ ⬝ B).IsHermitian :=\n    by\n    apply is_hermitian_conj_transpose_mul_mul\n    apply hA.inv\n  rw [is_hermitian_from_blocks_iff]\n  constructor\n  · intro h\n    apply is_hermitian.sub h.2.2.2 hBAB\n  · intro h\n    refine' ⟨hA, rfl, conj_transpose_conj_transpose B, _⟩\n    rw [← sub_add_cancel D]\n    apply is_hermitian.add h hBAB\n#align matrix.is_hermitian.from_blocks₁₁ Matrix.IsHermitian.from_blocks₁₁\n\ntheorem IsHermitian.from_blocks₂₂ [Fintype n] [DecidableEq n] (A : Matrix m m 𝕜) (B : Matrix m n 𝕜)\n    {D : Matrix n n 𝕜} (hD : D.IsHermitian) :\n    (fromBlocks A B Bᴴ D).IsHermitian ↔ (A - B ⬝ D⁻¹ ⬝ Bᴴ).IsHermitian :=\n  by\n  rw [← is_hermitian_submatrix_equiv (Equiv.sumComm n m), Equiv.sumComm_apply,\n    from_blocks_submatrix_sum_swap_sum_swap]\n  convert is_hermitian.from_blocks₁₁ _ _ hD <;> simp\n#align matrix.is_hermitian.from_blocks₂₂ Matrix.IsHermitian.from_blocks₂₂\n\ntheorem PosSemidef.from_blocks₁₁ [Fintype m] [DecidableEq m] [Fintype n] {A : Matrix m m 𝕜}\n    (B : Matrix m n 𝕜) (D : Matrix n n 𝕜) (hA : A.PosDef) [Invertible A] :\n    (fromBlocks A B Bᴴ D).PosSemidef ↔ (D - Bᴴ ⬝ A⁻¹ ⬝ B).PosSemidef :=\n  by\n  rw [pos_semidef, is_hermitian.from_blocks₁₁ _ _ hA.1]\n  constructor\n  · refine' fun h => ⟨h.1, fun x => _⟩\n    have := h.2 (-(A⁻¹ ⬝ B).mulVec x ⊕ᵥ x)\n    rw [dot_product_mul_vec, schur_complement_eq₁₁ B D _ _ hA.1, neg_add_self, dot_product_zero,\n      zero_add] at this\n    rw [dot_product_mul_vec]\n    exact this\n  · refine' fun h => ⟨h.1, fun x => _⟩\n    rw [dot_product_mul_vec, ← Sum.elim_comp_inl_inr x, schur_complement_eq₁₁ B D _ _ hA.1, map_add]\n    apply le_add_of_nonneg_of_le\n    · rw [← dot_product_mul_vec]\n      apply hA.pos_semidef.2\n    · rw [← dot_product_mul_vec]\n      apply h.2\n#align matrix.pos_semidef.from_blocks₁₁ Matrix.PosSemidef.from_blocks₁₁\n\ntheorem PosSemidef.from_blocks₂₂ [Fintype m] [Fintype n] [DecidableEq n] (A : Matrix m m 𝕜)\n    (B : Matrix m n 𝕜) {D : Matrix n n 𝕜} (hD : D.PosDef) [Invertible D] :\n    (fromBlocks A B Bᴴ D).PosSemidef ↔ (A - B ⬝ D⁻¹ ⬝ Bᴴ).PosSemidef :=\n  by\n  rw [← pos_semidef_submatrix_equiv (Equiv.sumComm n m), Equiv.sumComm_apply,\n    from_blocks_submatrix_sum_swap_sum_swap]\n  convert pos_semidef.from_blocks₁₁ _ _ hD <;> first |infer_instance|simp\n#align matrix.pos_semidef.from_blocks₂₂ Matrix.PosSemidef.from_blocks₂₂\n\nend Matrix\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/Matrix/SchurComplement.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4844653804094943}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module data.set.pairwise.basic\n! leanprover-community/mathlib commit c227d107bbada5d0d9d20287e3282c0a7f1651a0\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Set.Function\nimport Mathlib.Logic.Relation\nimport Mathlib.Logic.Pairwise\n\n/-!\n# Relations holding pairwise\n\nThis file develops pairwise relations and defines pairwise disjoint indexed sets.\n\nWe also prove many basic facts about `Pairwise`. It is possible that an intermediate file,\nwith more imports than `Logic.Pairwise` but not importing `Data.Set.Function` would be appropriate\nto hold many of these basic facts.\n\n## Main declarations\n\n* `Set.PairwiseDisjoint`: `s.PairwiseDisjoint f` states that images under `f` of distinct elements\n  of `s` are either equal or `Disjoint`.\n\n## Notes\n\nThe spelling `s.PairwiseDisjoint id` is preferred over `s.Pairwise Disjoint` to permit dot notation\non `Set.PairwiseDisjoint`, even though the latter unfolds to something nicer.\n-/\n\n\nopen Set Function\n\nvariable {α β γ ι ι' : Type _} {r p q : α → α → Prop}\n\nsection Pairwise\n\nvariable {f g : ι → α} {s t u : Set α} {a b : α}\n\ntheorem pairwise_on_bool (hr : Symmetric r) {a b : α} :\n    Pairwise (r on fun c => cond c a b) ↔ r a b := by simpa [Pairwise, Function.onFun] using @hr a b\n#align pairwise_on_bool pairwise_on_bool\n\ntheorem pairwise_disjoint_on_bool [SemilatticeInf α] [OrderBot α] {a b : α} :\n    Pairwise (Disjoint on fun c => cond c a b) ↔ Disjoint a b :=\n  pairwise_on_bool Disjoint.symm\n#align pairwise_disjoint_on_bool pairwise_disjoint_on_bool\n\ntheorem Symmetric.pairwise_on [LinearOrder ι] (hr : Symmetric r) (f : ι → α) :\n    Pairwise (r on f) ↔ ∀ ⦃m n⦄, m < n → r (f m) (f n) :=\n  ⟨fun h _m _n hmn => h hmn.ne, fun h _m _n hmn => hmn.lt_or_lt.elim (@h _ _) fun h' => hr (h h')⟩\n#align symmetric.pairwise_on Symmetric.pairwise_on\n\ntheorem pairwise_disjoint_on [SemilatticeInf α] [OrderBot α] [LinearOrder ι] (f : ι → α) :\n    Pairwise (Disjoint on f) ↔ ∀ ⦃m n⦄, m < n → Disjoint (f m) (f n) :=\n  Symmetric.pairwise_on Disjoint.symm f\n#align pairwise_disjoint_on pairwise_disjoint_on\n\ntheorem pairwise_disjoint_mono [SemilatticeInf α] [OrderBot α] (hs : Pairwise (Disjoint on f))\n    (h : g ≤ f) : Pairwise (Disjoint on g) :=\n  hs.mono fun i j hij => Disjoint.mono (h i) (h j) hij\n#align pairwise_disjoint.mono pairwise_disjoint_mono\n\nnamespace Set\n\ntheorem Pairwise.mono (h : t ⊆ s) (hs : s.Pairwise r) : t.Pairwise r :=\n  fun _x xt _y yt => hs (h xt) (h yt)\n#align set.pairwise.mono Set.Pairwise.mono\n\ntheorem Pairwise.mono' (H : r ≤ p) (hr : s.Pairwise r) : s.Pairwise p :=\n  hr.imp H\n#align set.pairwise.mono' Set.Pairwise.mono'\n\ntheorem pairwise_top (s : Set α) : s.Pairwise ⊤ :=\n  pairwise_of_forall s _ fun _ _ => trivial\n#align set.pairwise_top Set.pairwise_top\n\nprotected theorem Subsingleton.pairwise (h : s.Subsingleton) (r : α → α → Prop) : s.Pairwise r :=\n  fun _x hx _y hy hne => (hne (h hx hy)).elim\n#align set.subsingleton.pairwise Set.Subsingleton.pairwise\n\n@[simp]\ntheorem pairwise_empty (r : α → α → Prop) : (∅ : Set α).Pairwise r :=\n  subsingleton_empty.pairwise r\n#align set.pairwise_empty Set.pairwise_empty\n\n@[simp]\ntheorem pairwise_singleton (a : α) (r : α → α → Prop) : Set.Pairwise {a} r :=\n  subsingleton_singleton.pairwise r\n#align set.pairwise_singleton Set.pairwise_singleton\n\ntheorem pairwise_iff_of_refl [IsRefl α r] : s.Pairwise r ↔ ∀ ⦃a⦄, a ∈ s → ∀ ⦃b⦄, b ∈ s → r a b :=\n  forall₄_congr fun _ _ _ _ => or_iff_not_imp_left.symm.trans <| or_iff_right_of_imp of_eq\n#align set.pairwise_iff_of_refl Set.pairwise_iff_of_refl\n\nalias pairwise_iff_of_refl ↔ Pairwise.of_refl _\n#align set.pairwise.of_refl Set.Pairwise.of_refl\n\ntheorem Nonempty.pairwise_iff_exists_forall [IsEquiv α r] {s : Set ι} (hs : s.Nonempty) :\n    s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by\n  constructor\n  · rcases hs with ⟨y, hy⟩\n    refine' fun H => ⟨f y, fun x hx => _⟩\n    rcases eq_or_ne x y with (rfl | hne)\n    · apply IsRefl.refl\n    · exact H hx hy hne\n  · rintro ⟨z, hz⟩ x hx y hy _\n    exact @IsTrans.trans α r _ (f x) z (f y) (hz _ hx) (IsSymm.symm _ _ <| hz _ hy)\n#align set.nonempty.pairwise_iff_exists_forall Set.Nonempty.pairwise_iff_exists_forall\n\n/-- For a nonempty set `s`, a function `f` takes pairwise equal values on `s` if and only if\nfor some `z` in the codomain, `f` takes value `z` on all `x ∈ s`. See also\n`Set.pairwise_eq_iff_exists_eq` for a version that assumes `[Nonempty ι]` instead of\n`Set.Nonempty s`. -/\ntheorem Nonempty.pairwise_eq_iff_exists_eq {s : Set α} (hs : s.Nonempty) {f : α → ι} :\n    (s.Pairwise fun x y => f x = f y) ↔ ∃ z, ∀ x ∈ s, f x = z :=\n  hs.pairwise_iff_exists_forall\n#align set.nonempty.pairwise_eq_iff_exists_eq Set.Nonempty.pairwise_eq_iff_exists_eq\n\ntheorem pairwise_iff_exists_forall [Nonempty ι] (s : Set α) (f : α → ι) {r : ι → ι → Prop}\n    [IsEquiv ι r] : s.Pairwise (r on f) ↔ ∃ z, ∀ x ∈ s, r (f x) z := by\n  rcases s.eq_empty_or_nonempty with (rfl | hne)\n  · simp\n  · exact hne.pairwise_iff_exists_forall\n#align set.pairwise_iff_exists_forall Set.pairwise_iff_exists_forall\n\n/-- A function `f : α → ι` with nonempty codomain takes pairwise equal values on a set `s` if and\nonly if for some `z` in the codomain, `f` takes value `z` on all `x ∈ s`. See also\n`Set.Nonempty.pairwise_eq_iff_exists_eq` for a version that assumes `Set.Nonempty s` instead of\n`[Nonempty ι]`. -/\ntheorem pairwise_eq_iff_exists_eq [Nonempty ι] (s : Set α) (f : α → ι) :\n    (s.Pairwise fun x y => f x = f y) ↔ ∃ z, ∀ x ∈ s, f x = z :=\n  pairwise_iff_exists_forall s f\n#align set.pairwise_eq_iff_exists_eq Set.pairwise_eq_iff_exists_eq\n\ntheorem pairwise_union :\n  (s ∪ t).Pairwise r ↔\n    s.Pairwise r ∧ t.Pairwise r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b ∧ r b a := by\n  simp only [Set.Pairwise, mem_union, or_imp, forall_and]\n  exact\n    ⟨fun H => ⟨H.1.1, H.2.2, H.2.1, fun x hx y hy hne => H.1.2 y hy x hx hne.symm⟩, fun H =>\n      ⟨⟨H.1, fun x hx y hy hne => H.2.2.2 y hy x hx hne.symm⟩, H.2.2.1, H.2.1⟩⟩\n#align set.pairwise_union Set.pairwise_union\n\ntheorem pairwise_union_of_symmetric (hr : Symmetric r) :\n    (s ∪ t).Pairwise r ↔ s.Pairwise r ∧ t.Pairwise r ∧ ∀ a ∈ s, ∀ b ∈ t, a ≠ b → r a b :=\n  pairwise_union.trans <| by simp only [hr.iff, and_self_iff]\n#align set.pairwise_union_of_symmetric Set.pairwise_union_of_symmetric\n\ntheorem pairwise_insert :\n    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, a ≠ b → r a b ∧ r b a := by\n  simp only [insert_eq, pairwise_union, pairwise_singleton, true_and_iff, mem_singleton_iff,\n    forall_eq]\n#align set.pairwise_insert Set.pairwise_insert\n\ntheorem pairwise_insert_of_not_mem (ha : a ∉ s) :\n    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, r a b ∧ r b a :=\n  pairwise_insert.trans <|\n    and_congr_right' <| forall₂_congr fun b hb => by simp [(ne_of_mem_of_not_mem hb ha).symm]\n#align set.pairwise_insert_of_not_mem Set.pairwise_insert_of_not_mem\n\nprotected theorem Pairwise.insert (hs : s.Pairwise r) (h : ∀ b ∈ s, a ≠ b → r a b ∧ r b a) :\n    (insert a s).Pairwise r :=\n  pairwise_insert.2 ⟨hs, h⟩\n#align set.pairwise.insert Set.Pairwise.insert\n\ntheorem Pairwise.insert_of_not_mem (ha : a ∉ s) (hs : s.Pairwise r) (h : ∀ b ∈ s, r a b ∧ r b a) :\n    (insert a s).Pairwise r :=\n  (pairwise_insert_of_not_mem ha).2 ⟨hs, h⟩\n#align set.pairwise.insert_of_not_mem Set.Pairwise.insert_of_not_mem\n\ntheorem pairwise_insert_of_symmetric (hr : Symmetric r) :\n    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, a ≠ b → r a b := by\n  simp only [pairwise_insert, hr.iff a, and_self_iff]\n#align set.pairwise_insert_of_symmetric Set.pairwise_insert_of_symmetric\n\ntheorem pairwise_insert_of_symmetric_of_not_mem (hr : Symmetric r) (ha : a ∉ s) :\n    (insert a s).Pairwise r ↔ s.Pairwise r ∧ ∀ b ∈ s, r a b := by\n  simp only [pairwise_insert_of_not_mem ha, hr.iff a, and_self_iff]\n#align set.pairwise_insert_of_symmetric_of_not_mem Set.pairwise_insert_of_symmetric_of_not_mem\n\ntheorem Pairwise.insert_of_symmetric (hs : s.Pairwise r) (hr : Symmetric r)\n    (h : ∀ b ∈ s, a ≠ b → r a b) : (insert a s).Pairwise r :=\n  (pairwise_insert_of_symmetric hr).2 ⟨hs, h⟩\n#align set.pairwise.insert_of_symmetric Set.Pairwise.insert_of_symmetric\n\ntheorem Pairwise.insert_of_symmetric_of_not_mem (hs : s.Pairwise r) (hr : Symmetric r) (ha : a ∉ s)\n    (h : ∀ b ∈ s, r a b) : (insert a s).Pairwise r :=\n  (pairwise_insert_of_symmetric_of_not_mem hr ha).2 ⟨hs, h⟩\n#align set.pairwise.insert_of_symmetric_of_not_mem Set.Pairwise.insert_of_symmetric_of_not_mem\n\ntheorem pairwise_pair : Set.Pairwise {a, b} r ↔ a ≠ b → r a b ∧ r b a := by simp [pairwise_insert]\n#align set.pairwise_pair Set.pairwise_pair\n\ntheorem pairwise_pair_of_symmetric (hr : Symmetric r) : Set.Pairwise {a, b} r ↔ a ≠ b → r a b := by\n  simp [pairwise_insert_of_symmetric hr]\n#align set.pairwise_pair_of_symmetric Set.pairwise_pair_of_symmetric\n\ntheorem pairwise_univ : (univ : Set α).Pairwise r ↔ Pairwise r := by\n  simp only [Set.Pairwise, Pairwise, mem_univ, forall_const]\n#align set.pairwise_univ Set.pairwise_univ\n\n@[simp]\ntheorem pairwise_bot_iff : s.Pairwise (⊥ : α → α → Prop) ↔ (s : Set α).Subsingleton :=\n  ⟨fun h _a ha _b hb => h.eq ha hb id, fun h => h.pairwise _⟩\n#align set.pairwise_bot_iff Set.pairwise_bot_iff\n\nalias pairwise_bot_iff ↔ Pairwise.subsingleton _\n#align set.pairwise.subsingleton Set.Pairwise.subsingleton\n\ntheorem InjOn.pairwise_image {s : Set ι} (h : s.InjOn f) :\n    (f '' s).Pairwise r ↔ s.Pairwise (r on f) := by\n  simp (config := { contextual := true }) [h.eq_iff, Set.Pairwise]\n#align set.inj_on.pairwise_image Set.InjOn.pairwise_image\n\nend Set\n\nend Pairwise\n\ntheorem pairwise_subtype_iff_pairwise_set (s : Set α) (r : α → α → Prop) :\n    (Pairwise fun (x : s) (y : s) => r x y) ↔ s.Pairwise r := by\n  simp only [Pairwise, Set.Pairwise, SetCoe.forall, Ne.def, Subtype.ext_iff, Subtype.coe_mk]\n#align pairwise_subtype_iff_pairwise_set pairwise_subtype_iff_pairwise_set\n\nalias pairwise_subtype_iff_pairwise_set ↔ Pairwise.set_of_subtype Set.Pairwise.subtype\n#align pairwise.set_of_subtype Pairwise.set_of_subtype\n#align set.pairwise.subtype Set.Pairwise.subtype\n\nnamespace Set\n\nsection PartialOrderBot\n\nvariable [PartialOrder α] [OrderBot α] {s t : Set ι} {f g : ι → α}\n\n/-- A set is `PairwiseDisjoint` under `f`, if the images of any distinct two elements under `f`\nare disjoint.\n\n`s.Pairwise Disjoint` is (definitionally) the same as `s.PairwiseDisjoint id`. We prefer the latter\nin order to allow dot notation on `Set.PairwiseDisjoint`, even though the former unfolds more\nnicely. -/\ndef PairwiseDisjoint (s : Set ι) (f : ι → α) : Prop :=\n  s.Pairwise (Disjoint on f)\n#align set.pairwise_disjoint Set.PairwiseDisjoint\n\ntheorem PairwiseDisjoint.subset (ht : t.PairwiseDisjoint f) (h : s ⊆ t) : s.PairwiseDisjoint f :=\n  Pairwise.mono h ht\n#align set.pairwise_disjoint.subset Set.PairwiseDisjoint.subset\n\ntheorem PairwiseDisjoint.mono_on (hs : s.PairwiseDisjoint f) (h : ∀ ⦃i⦄, i ∈ s → g i ≤ f i) :\n    s.PairwiseDisjoint g := fun _a ha _b hb hab => (hs ha hb hab).mono (h ha) (h hb)\n#align set.pairwise_disjoint.mono_on Set.PairwiseDisjoint.mono_on\n\ntheorem PairwiseDisjoint.mono (hs : s.PairwiseDisjoint f) (h : g ≤ f) : s.PairwiseDisjoint g :=\n  hs.mono_on fun i _ => h i\n#align set.pairwise_disjoint.mono Set.PairwiseDisjoint.mono\n\n@[simp]\ntheorem pairwiseDisjoint_empty : (∅ : Set ι).PairwiseDisjoint f :=\n  pairwise_empty _\n#align set.pairwise_disjoint_empty Set.pairwiseDisjoint_empty\n\n@[simp]\ntheorem pairwiseDisjoint_singleton (i : ι) (f : ι → α) : PairwiseDisjoint {i} f :=\n  pairwise_singleton i _\n#align set.pairwise_disjoint_singleton Set.pairwiseDisjoint_singleton\n\ntheorem pairwiseDisjoint_insert {i : ι} :\n    (insert i s).PairwiseDisjoint f ↔\n      s.PairwiseDisjoint f ∧ ∀ j ∈ s, i ≠ j → Disjoint (f i) (f j) :=\n  pairwise_insert_of_symmetric <| symmetric_disjoint.comap f\n#align set.pairwise_disjoint_insert Set.pairwiseDisjoint_insert\n\ntheorem pairwiseDisjoint_insert_of_not_mem {i : ι} (hi : i ∉ s) :\n    (insert i s).PairwiseDisjoint f ↔ s.PairwiseDisjoint f ∧ ∀ j ∈ s, Disjoint (f i) (f j) :=\n  pairwise_insert_of_symmetric_of_not_mem (symmetric_disjoint.comap f) hi\n#align set.pairwise_disjoint_insert_of_not_mem Set.pairwiseDisjoint_insert_of_not_mem\n\nprotected theorem PairwiseDisjoint.insert (hs : s.PairwiseDisjoint f) {i : ι}\n    (h : ∀ j ∈ s, i ≠ j → Disjoint (f i) (f j)) : (insert i s).PairwiseDisjoint f :=\n  pairwiseDisjoint_insert.2 ⟨hs, h⟩\n#align set.pairwise_disjoint.insert Set.PairwiseDisjoint.insert\n\ntheorem PairwiseDisjoint.insert_of_not_mem (hs : s.PairwiseDisjoint f) {i : ι} (hi : i ∉ s)\n    (h : ∀ j ∈ s, Disjoint (f i) (f j)) : (insert i s).PairwiseDisjoint f :=\n  (pairwiseDisjoint_insert_of_not_mem hi).2 ⟨hs, h⟩\n#align set.pairwise_disjoint.insert_of_not_mem Set.PairwiseDisjoint.insert_of_not_mem\n\ntheorem PairwiseDisjoint.image_of_le (hs : s.PairwiseDisjoint f) {g : ι → ι} (hg : f ∘ g ≤ f) :\n    (g '' s).PairwiseDisjoint f := by\n  rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ h\n  exact (hs ha hb <| ne_of_apply_ne _ h).mono (hg a) (hg b)\n#align set.pairwise_disjoint.image_of_le Set.PairwiseDisjoint.image_of_le\n\ntheorem InjOn.pairwiseDisjoint_image {g : ι' → ι} {s : Set ι'} (h : s.InjOn g) :\n    (g '' s).PairwiseDisjoint f ↔ s.PairwiseDisjoint (f ∘ g) :=\n  h.pairwise_image\n#align set.inj_on.pairwise_disjoint_image Set.InjOn.pairwiseDisjoint_image\n\ntheorem PairwiseDisjoint.range (g : s → ι) (hg : ∀ i : s, f (g i) ≤ f i)\n    (ht : s.PairwiseDisjoint f) : (range g).PairwiseDisjoint f := by\n  rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ hxy\n  exact ((ht x.2 y.2) fun h => hxy <| congr_arg g <| Subtype.ext h).mono (hg x) (hg y)\n#align set.pairwise_disjoint.range Set.PairwiseDisjoint.range\n\ntheorem pairwiseDisjoint_union :\n    (s ∪ t).PairwiseDisjoint f ↔\n      s.PairwiseDisjoint f ∧\n        t.PairwiseDisjoint f ∧ ∀ ⦃i⦄, i ∈ s → ∀ ⦃j⦄, j ∈ t → i ≠ j → Disjoint (f i) (f j) :=\n  pairwise_union_of_symmetric <| symmetric_disjoint.comap f\n#align set.pairwise_disjoint_union Set.pairwiseDisjoint_union\n\ntheorem PairwiseDisjoint.union (hs : s.PairwiseDisjoint f) (ht : t.PairwiseDisjoint f)\n    (h : ∀ ⦃i⦄, i ∈ s → ∀ ⦃j⦄, j ∈ t → i ≠ j → Disjoint (f i) (f j)) : (s ∪ t).PairwiseDisjoint f :=\n  pairwiseDisjoint_union.2 ⟨hs, ht, h⟩\n#align set.pairwise_disjoint.union Set.PairwiseDisjoint.union\n\n-- classical\ntheorem PairwiseDisjoint.elim (hs : s.PairwiseDisjoint f) {i j : ι} (hi : i ∈ s) (hj : j ∈ s)\n    (h : ¬Disjoint (f i) (f j)) : i = j :=\n  hs.eq hi hj h\n#align set.pairwise_disjoint.elim Set.PairwiseDisjoint.elim\n\nend PartialOrderBot\n\nsection SemilatticeInfBot\n\nvariable [SemilatticeInf α] [OrderBot α] {s t : Set ι} {f g : ι → α}\n\n-- classical\ntheorem PairwiseDisjoint.elim' (hs : s.PairwiseDisjoint f) {i j : ι} (hi : i ∈ s) (hj : j ∈ s)\n    (h : f i ⊓ f j ≠ ⊥) : i = j :=\n  (hs.elim hi hj) fun hij => h hij.eq_bot\n#align set.pairwise_disjoint.elim' Set.PairwiseDisjoint.elim'\n\ntheorem PairwiseDisjoint.eq_of_le (hs : s.PairwiseDisjoint f) {i j : ι} (hi : i ∈ s) (hj : j ∈ s)\n    (hf : f i ≠ ⊥) (hij : f i ≤ f j) : i = j :=\n  (hs.elim' hi hj) fun h => hf <| (inf_of_le_left hij).symm.trans h\n#align set.pairwise_disjoint.eq_of_le Set.PairwiseDisjoint.eq_of_le\n\nend SemilatticeInfBot\n\n/-! ### Pairwise disjoint set of sets -/\n\ntheorem pairwiseDisjoint_range_singleton :\n    (range (singleton : ι → Set ι)).PairwiseDisjoint id := by\n  rintro _ ⟨a, rfl⟩ _ ⟨b, rfl⟩ h\n  exact disjoint_singleton.2 (ne_of_apply_ne _ h)\n#align set.pairwise_disjoint_range_singleton Set.pairwiseDisjoint_range_singleton\n\ntheorem pairwiseDisjoint_fiber (f : ι → α) (s : Set α) : s.PairwiseDisjoint fun a => f ⁻¹' {a} :=\n  fun _a _ _b _ h => disjoint_iff_inf_le.mpr fun _i ⟨hia, hib⟩ => h <| (Eq.symm hia).trans hib\n#align set.pairwise_disjoint_fiber Set.pairwiseDisjoint_fiber\n\n-- classical\ntheorem PairwiseDisjoint.elim_set {s : Set ι} {f : ι → Set α} (hs : s.PairwiseDisjoint f) {i j : ι}\n    (hi : i ∈ s) (hj : j ∈ s) (a : α) (hai : a ∈ f i) (haj : a ∈ f j) : i = j :=\n  hs.elim hi hj <| not_disjoint_iff.2 ⟨a, hai, haj⟩\n#align set.pairwise_disjoint.elim_set Set.PairwiseDisjoint.elim_set\n\n/-- The partial images of a binary function `f` whose partial evaluations are injective are pairwise\ndisjoint iff `f` is injective . -/\ntheorem pairwiseDisjoint_image_right_iff {f : α → β → γ} {s : Set α} {t : Set β}\n    (hf : ∀ a ∈ s, Injective (f a)) :\n    (s.PairwiseDisjoint fun a => f a '' t) ↔ (s ×ˢ t).InjOn fun p => f p.1 p.2 := by\n  refine' ⟨fun hs x hx y hy (h : f _ _ = _) => _, fun hs x hx y hy h => _⟩\n  · suffices x.1 = y.1 by exact Prod.ext this (hf _ hx.1 <| h.trans <| by rw [this])\n    refine' hs.elim hx.1 hy.1 (not_disjoint_iff.2 ⟨_, mem_image_of_mem _ hx.2, _⟩)\n    rw [h]\n    exact mem_image_of_mem _ hy.2\n  · refine' disjoint_iff_inf_le.mpr _\n    rintro _ ⟨⟨a, ha, hab⟩, b, hb, rfl⟩\n    exact h (congr_arg Prod.fst <| hs (mk_mem_prod hx ha) (mk_mem_prod hy hb) hab)\n#align set.pairwise_disjoint_image_right_iff Set.pairwiseDisjoint_image_right_iff\n\n/-- The partial images of a binary function `f` whose partial evaluations are injective are pairwise\ndisjoint iff `f` is injective . -/\ntheorem pairwiseDisjoint_image_left_iff {f : α → β → γ} {s : Set α} {t : Set β}\n    (hf : ∀ b ∈ t, Injective fun a => f a b) :\n    (t.PairwiseDisjoint fun b => (fun a => f a b) '' s) ↔ (s ×ˢ t).InjOn fun p => f p.1 p.2 := by\n  refine' ⟨fun ht x hx y hy (h : f _ _ = _) => _, fun ht x hx y hy h => _⟩\n  · suffices x.2 = y.2 by exact Prod.ext (hf _ hx.2 <| h.trans <| by rw [this]) this\n    refine' ht.elim hx.2 hy.2 (not_disjoint_iff.2 ⟨_, mem_image_of_mem _ hx.1, _⟩)\n    rw [h]\n    exact mem_image_of_mem _ hy.1\n  · refine' disjoint_iff_inf_le.mpr _\n    rintro _ ⟨⟨a, ha, hab⟩, b, hb, rfl⟩\n    exact h (congr_arg Prod.snd <| ht (mk_mem_prod ha hx) (mk_mem_prod hb hy) hab)\n#align set.pairwise_disjoint_image_left_iff Set.pairwiseDisjoint_image_left_iff\n\nend Set\n\ntheorem pairwise_disjoint_fiber (f : ι → α) : Pairwise (Disjoint on fun a : α => f ⁻¹' {a}) :=\n  pairwise_univ.1 <| Set.pairwiseDisjoint_fiber f univ\n#align pairwise_disjoint_fiber pairwise_disjoint_fiber\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Set/Pairwise/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.4844653804094943}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.monoidal.preadditive\n! leanprover-community/mathlib commit 986c4d5761f938b2e1c43c01f001b6d9d88c2055\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Preadditive.AdditiveFunctor\nimport Mathlib.CategoryTheory.Monoidal.Functor\n\n/-!\n# Preadditive monoidal categories\n\nA monoidal category is `MonoidalPreadditive` if it is preadditive and tensor product of morphisms\nis linear in both factors.\n-/\n\n\nnoncomputable section\n\nopen Classical\n\nnamespace CategoryTheory\n\nopen CategoryTheory.Limits\n\nopen CategoryTheory.MonoidalCategory\n\nvariable (C : Type _) [Category C] [Preadditive C] [MonoidalCategory C]\n\n/-- A category is `MonoidalPreadditive` if tensoring is additive in both factors.\n\nNote we don't `extend Preadditive C` here, as `Abelian C` already extends it,\nand we'll need to have both typeclasses sometimes.\n-/\nclass MonoidalPreadditive : Prop where\n  /-- tensoring on the right with a zero morphism gives zero -/\n  tensor_zero : ∀ {W X Y Z : C} (f : W ⟶ X), f ⊗ (0 : Y ⟶ Z) = 0 := by aesop_cat\n  /-- tensoring on the left with a zero morphism gives zero -/\n  zero_tensor : ∀ {W X Y Z : C} (f : Y ⟶ Z), (0 : W ⟶ X) ⊗ f = 0 := by aesop_cat\n  /-- left tensoring with a morphism is compatible with addition -/\n  tensor_add : ∀ {W X Y Z : C} (f : W ⟶ X) (g h : Y ⟶ Z), f ⊗ (g + h) = f ⊗ g + f ⊗ h := by\n    aesop_cat\n  /-- right tensoring with a morphism is compatible with addition -/\n  add_tensor : ∀ {W X Y Z : C} (f g : W ⟶ X) (h : Y ⟶ Z), (f + g) ⊗ h = f ⊗ h + g ⊗ h := by\n    aesop_cat\n#align category_theory.monoidal_preadditive CategoryTheory.MonoidalPreadditive\n\n--restate_axiom monoidal_preadditive.tensor_zero'\n--\n--restate_axiom monoidal_preadditive.zero_tensor'\n--\n--restate_axiom monoidal_preadditive.tensor_add'\n--\n--restate_axiom monoidal_preadditive.add_tensor'\n\nattribute [simp] MonoidalPreadditive.tensor_zero MonoidalPreadditive.zero_tensor\n\nvariable {C}\nvariable [MonoidalPreadditive C]\n\nattribute [local simp] MonoidalPreadditive.tensor_add MonoidalPreadditive.add_tensor\n\ninstance tensorLeft_additive (X : C) : (tensorLeft X).Additive where\n#align category_theory.tensor_left_additive CategoryTheory.tensorLeft_additive\n\ninstance tensorRight_additive (X : C) : (tensorRight X).Additive where\n#align category_theory.tensor_right_additive CategoryTheory.tensorRight_additive\n\ninstance tensoringLeft_additive (X : C) : ((tensoringLeft C).obj X).Additive where\n#align category_theory.tensoring_left_additive CategoryTheory.tensoringLeft_additive\n\ninstance tensoringRight_additive (X : C) : ((tensoringRight C).obj X).Additive where\n#align category_theory.tensoring_right_additive CategoryTheory.tensoringRight_additive\n\n/-- A faithful additive monoidal functor to a monoidal preadditive category\nensures that the domain is monoidal preadditive. -/\ntheorem monoidalPreadditive_of_faithful {D} [Category D] [Preadditive D] [MonoidalCategory D]\n    (F : MonoidalFunctor D C) [Faithful F.toFunctor] [F.toFunctor.Additive] :\n    MonoidalPreadditive D :=\n  { tensor_zero := by\n      intros\n      apply F.toFunctor.map_injective\n      simp [F.map_tensor]\n    zero_tensor := by\n      intros\n      apply F.toFunctor.map_injective\n      simp [F.map_tensor]\n    tensor_add := by\n      intros\n      apply F.toFunctor.map_injective\n      simp only [F.map_tensor, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,\n        MonoidalPreadditive.tensor_add]\n    add_tensor := by\n      intros\n      apply F.toFunctor.map_injective\n      simp only [F.map_tensor, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,\n        MonoidalPreadditive.add_tensor] }\n#align category_theory.monoidal_preadditive_of_faithful CategoryTheory.monoidalPreadditive_of_faithful\n\nopen BigOperators\n\ntheorem tensor_sum {P Q R S : C} {J : Type _} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :\n    (f ⊗ ∑ j in s, g j) = ∑ j in s, f ⊗ g j := by\n  rw [← tensor_id_comp_id_tensor]\n  let tQ := (((tensoringLeft C).obj Q).mapAddHom : (R ⟶ S) →+ _)\n  change _ ≫ tQ _ = _\n  rw [tQ.map_sum, Preadditive.comp_sum]\n  dsimp [Functor.mapAddHom]\n  simp only [tensor_id_comp_id_tensor]\n#align category_theory.tensor_sum CategoryTheory.tensor_sum\n\ntheorem sum_tensor {P Q R S : C} {J : Type _} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :\n    (∑ j in s, g j) ⊗ f = ∑ j in s, g j ⊗ f := by\n  rw [← tensor_id_comp_id_tensor]\n  let tQ := (((tensoringRight C).obj P).mapAddHom : (R ⟶ S) →+ _)\n  change tQ _ ≫ _ = _\n  rw [tQ.map_sum, Preadditive.sum_comp]\n  dsimp [Functor.mapAddHom]\n  simp only [tensor_id_comp_id_tensor]\n#align category_theory.sum_tensor CategoryTheory.sum_tensor\n\n-- In a closed monoidal category, this would hold because\n-- `tensorLeft X` is a left adjoint and hence preserves all colimits.\n-- In any case it is true in any preadditive category.\ninstance (X : C) : PreservesFiniteBiproducts (tensorLeft X) where\n  preserves {J} :=\n    { preserves := fun {f} =>\n        { preserves := fun {b} i => isBilimitOfTotal _ (by\n            dsimp\n            simp only [← tensor_comp, Category.comp_id, ← tensor_sum, ← tensor_id,\n              IsBilimit.total i]) } }\n\ninstance (X : C) : PreservesFiniteBiproducts (tensorRight X) where\n  preserves {J} :=\n    { preserves := fun {f} =>\n        { preserves := fun {b} i => isBilimitOfTotal _ (by\n            dsimp\n            simp only [← tensor_comp, Category.comp_id, ← sum_tensor, ← tensor_id,\n               IsBilimit.total i]) } }\n\nvariable [HasFiniteBiproducts C]\n\n/-- The isomorphism showing how tensor product on the left distributes over direct sums. -/\ndef leftDistributor {J : Type} [Fintype J] (X : C) (f : J → C) : X ⊗ ⨁ f ≅ ⨁ fun j => X ⊗ f j :=\n  (tensorLeft X).mapBiproduct f\n#align category_theory.left_distributor CategoryTheory.leftDistributor\n\n@[simp]\ntheorem leftDistributor_hom {J : Type} [Fintype J] (X : C) (f : J → C) :\n    (leftDistributor X f).hom =\n      ∑ j : J, (𝟙 X ⊗ biproduct.π f j) ≫ biproduct.ι (fun j => X ⊗ f j) j := by\n  ext\n  dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  erw [biproduct.lift_π]\n  simp only [Preadditive.sum_comp, Category.assoc, biproduct.ι_π, comp_dite, comp_zero,\n    Finset.sum_dite_eq', Finset.mem_univ, ite_true, eqToHom_refl, Category.comp_id]\n#align category_theory.left_distributor_hom CategoryTheory.leftDistributor_hom\n\n@[simp]\ntheorem leftDistributor_inv {J : Type} [Fintype J] (X : C) (f : J → C) :\n    (leftDistributor X f).inv = ∑ j : J, biproduct.π _ j ≫ (𝟙 X ⊗ biproduct.ι f j) := by\n  ext\n  dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  simp only [Preadditive.comp_sum, biproduct.ι_π_assoc, dite_comp, zero_comp,\n    Finset.sum_dite_eq, Finset.mem_univ, ite_true, eqToHom_refl, Category.id_comp,\n    biproduct.ι_desc]\n#align category_theory.left_distributor_inv CategoryTheory.leftDistributor_inv\n\ntheorem leftDistributor_assoc {J : Type} [Fintype J] (X Y : C) (f : J → C) :\n    (asIso (𝟙 X) ⊗ leftDistributor Y f) ≪≫ leftDistributor X _ =\n      (α_ X Y (⨁ f)).symm ≪≫ leftDistributor (X ⊗ Y) f ≪≫ biproduct.mapIso fun j => α_ X Y _ := by\n  ext\n  simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.trans_hom, Iso.symm_hom,\n    asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, tensor_sum,\n    id_tensor_comp, tensorIso_hom, leftDistributor_hom, biproduct.mapIso_hom, biproduct.ι_map,\n    biproduct.ι_π, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero]\n  simp only [← id_tensor_comp, biproduct.ι_π]\n  simp only [id_tensor_comp, tensor_dite, comp_dite]\n  simp only [Category.comp_id, comp_zero, MonoidalPreadditive.tensor_zero, eqToHom_refl,\n    tensor_id, if_true, dif_ctx_congr, Finset.sum_congr, Finset.mem_univ, Finset.sum_dite_eq']\n  simp only [← tensor_id, associator_naturality, Iso.inv_hom_id_assoc]\n#align category_theory.left_distributor_assoc CategoryTheory.leftDistributor_assoc\n\n/-- The isomorphism showing how tensor product on the right distributes over direct sums. -/\ndef rightDistributor {J : Type} [Fintype J] (X : C) (f : J → C) : (⨁ f) ⊗ X ≅ ⨁ fun j => f j ⊗ X :=\n  (tensorRight X).mapBiproduct f\n#align category_theory.right_distributor CategoryTheory.rightDistributor\n\n@[simp]\ntheorem rightDistributor_hom {J : Type} [Fintype J] (X : C) (f : J → C) :\n    (rightDistributor X f).hom =\n      ∑ j : J, (biproduct.π f j ⊗ 𝟙 X) ≫ biproduct.ι (fun j => f j ⊗ X) j := by\n  ext\n  dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  erw [biproduct.lift_π]\n  simp only [Preadditive.sum_comp, Category.assoc, biproduct.ι_π, comp_dite, comp_zero,\n    Finset.sum_dite_eq', Finset.mem_univ, eqToHom_refl, Category.comp_id, ite_true]\n#align category_theory.right_distributor_hom CategoryTheory.rightDistributor_hom\n\n@[simp]\ntheorem rightDistributor_inv {J : Type} [Fintype J] (X : C) (f : J → C) :\n    (rightDistributor X f).inv = ∑ j : J, biproduct.π _ j ≫ (biproduct.ι f j ⊗ 𝟙 X) := by\n  ext\n  dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  simp only [biproduct.ι_desc, Preadditive.comp_sum, ne_eq, biproduct.ι_π_assoc, dite_comp,\n    zero_comp, Finset.sum_dite_eq, Finset.mem_univ, eqToHom_refl, Category.id_comp, ite_true]\n#align category_theory.right_distributor_inv CategoryTheory.rightDistributor_inv\n\ntheorem rightDistributor_assoc {J : Type} [Fintype J] (X Y : C) (f : J → C) :\n    (rightDistributor X f ⊗ asIso (𝟙 Y)) ≪≫ rightDistributor Y _ =\n      α_ (⨁ f) X Y ≪≫ rightDistributor (X ⊗ Y) f ≪≫ biproduct.mapIso fun j => (α_ _ X Y).symm := by\n  ext\n  simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.symm_hom, Iso.trans_hom,\n    asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, sum_tensor,\n    comp_tensor_id, tensorIso_hom, rightDistributor_hom, biproduct.mapIso_hom, biproduct.ι_map,\n    biproduct.ι_π, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero,\n    Finset.mem_univ, if_true]\n  simp only [← comp_tensor_id, biproduct.ι_π, dite_tensor, comp_dite]\n  simp only [Category.comp_id, comp_tensor_id, eqToHom_refl, tensor_id, comp_zero,\n    MonoidalPreadditive.zero_tensor, if_true, dif_ctx_congr, Finset.mem_univ, Finset.sum_congr,\n    Finset.sum_dite_eq']\n  simp only [← tensor_id, associator_inv_naturality, Iso.hom_inv_id_assoc]\n#align category_theory.right_distributor_assoc CategoryTheory.rightDistributor_assoc\n\ntheorem leftDistributor_rightDistributor_assoc {J : Type _} [Fintype J] (X Y : C) (f : J → C) :\n    (leftDistributor X f ⊗ asIso (𝟙 Y)) ≪≫ rightDistributor Y _ =\n      α_ X (⨁ f) Y ≪≫\n        (asIso (𝟙 X) ⊗ rightDistributor Y _) ≪≫\n          leftDistributor X _ ≪≫ biproduct.mapIso fun j => (α_ _ _ _).symm := by\n  ext\n  simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.symm_hom, Iso.trans_hom,\n    asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, sum_tensor,\n    tensor_sum, comp_tensor_id, tensorIso_hom, leftDistributor_hom, rightDistributor_hom,\n    biproduct.mapIso_hom, biproduct.ι_map, biproduct.ι_π, Finset.sum_dite_irrel,\n    Finset.sum_dite_eq', Finset.sum_const_zero, Finset.mem_univ, if_true]\n  simp only [← comp_tensor_id, ← id_tensor_comp_assoc, Category.assoc, biproduct.ι_π, comp_dite,\n    dite_comp, tensor_dite, dite_tensor]\n  simp only [Category.comp_id, Category.id_comp, Category.assoc, id_tensor_comp, comp_zero,\n    zero_comp, MonoidalPreadditive.tensor_zero, MonoidalPreadditive.zero_tensor, comp_tensor_id,\n    eqToHom_refl, tensor_id, if_true, dif_ctx_congr, Finset.sum_congr, Finset.mem_univ,\n    Finset.sum_dite_eq']\n  simp only [associator_inv_naturality, Iso.hom_inv_id_assoc]\n#align category_theory.left_distributor_right_distributor_assoc CategoryTheory.leftDistributor_rightDistributor_assoc\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Monoidal/Preadditive.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4844653732485133}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.analysis.topology\n! leanprover-community/mathlib commit 55d771df074d0dd020139ee1cd4b95521422df9f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Analysis.Filter\nimport Mathbin.Topology.Bases\nimport Mathbin.Topology.LocallyFinite\n\n/-!\n# Computational realization of topological spaces (experimental)\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides infrastructure to compute with topological spaces.\n\n## Main declarations\n\n* `ctop`: Realization of a topology basis.\n* `ctop.realizer`: Realization of a topological space. `ctop` that generates the given topology.\n* `locally_finite.realizer`: Realization of the local finiteness of an indexed family of sets.\n* `compact.realizer`: Realization of the compactness of a set.\n-/\n\n\nopen Set\n\nopen Filter hiding Realizer\n\nopen Topology\n\n#print Ctop /-\n/-- A `ctop α σ` is a realization of a topology (basis) on `α`,\n  represented by a type `σ` together with operations for the top element and\n  the intersection operation. -/\nstructure Ctop (α σ : Type _) where\n  f : σ → Set α\n  top : α → σ\n  top_mem : ∀ x : α, x ∈ f (top x)\n  inter : ∀ (a b) (x : α), x ∈ f a ∩ f b → σ\n  inter_mem : ∀ a b x h, x ∈ f (inter a b x h)\n  inter_sub : ∀ a b x h, f (inter a b x h) ⊆ f a ∩ f b\n#align ctop Ctop\n-/\n\nvariable {α : Type _} {β : Type _} {σ : Type _} {τ : Type _}\n\ninstance : Inhabited (Ctop α (Set α)) :=\n  ⟨{  f := id\n      top := singleton\n      top_mem := mem_singleton\n      inter := fun s t _ _ => s ∩ t\n      inter_mem := fun s t a => id\n      inter_sub := fun s t a ha => Subset.rfl }⟩\n\nnamespace Ctop\n\nsection\n\nvariable (F : Ctop α σ)\n\ninstance : CoeFun (Ctop α σ) fun _ => σ → Set α :=\n  ⟨Ctop.f⟩\n\n/- warning: ctop.coe_mk -> Ctop.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} (f : σ -> (Set.{u1} α)) (T : α -> σ) (h₁ : forall (x : α), Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (f (T x))) (I : forall (a : σ) (b : σ) (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (f a) (f b))) -> σ) (h₂ : forall (a : σ) (b : σ) (x : α) (h : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (f a) (f b))), Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (f (I a b x h))) (h₃ : forall (a : σ) (b : σ) (x : α) (h : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (f a) (f b))), HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (f (I a b x h)) (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (f a) (f b))) (a : σ), Eq.{succ u1} (Set.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) (Ctop.mk.{u1, u2} α σ f T h₁ I h₂ h₃) a) (f a)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} (f : σ -> (Set.{u2} α)) (T : α -> σ) (h₁ : forall (x : α), Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (f (T x))) (I : forall (a : σ) (b : σ) (x : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Inter.inter.{u2} (Set.{u2} α) (Set.instInterSet.{u2} α) (f a) (f b))) -> σ) (h₂ : forall (a : σ) (b : σ) (x : α) (h : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Inter.inter.{u2} (Set.{u2} α) (Set.instInterSet.{u2} α) (f a) (f b))), Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (f (I a b x h))) (h₃ : forall (a : σ) (b : σ) (x : α) (h : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Inter.inter.{u2} (Set.{u2} α) (Set.instInterSet.{u2} α) (f a) (f b))), HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (f (I a b x h)) (Inter.inter.{u2} (Set.{u2} α) (Set.instInterSet.{u2} α) (f a) (f b))) (a : σ), Eq.{succ u2} (Set.{u2} α) (Ctop.f.{u2, u1} α σ (Ctop.mk.{u2, u1} α σ f T h₁ I h₂ h₃) a) (f a)\nCase conversion may be inaccurate. Consider using '#align ctop.coe_mk Ctop.coe_mkₓ'. -/\n@[simp]\ntheorem coe_mk (f T h₁ I h₂ h₃ a) : (@Ctop.mk α σ f T h₁ I h₂ h₃) a = f a :=\n  rfl\n#align ctop.coe_mk Ctop.coe_mk\n\n#print Ctop.ofEquiv /-\n/-- Map a ctop to an equivalent representation type. -/\ndef ofEquiv (E : σ ≃ τ) : Ctop α σ → Ctop α τ\n  | ⟨f, T, h₁, I, h₂, h₃⟩ =>\n    { f := fun a => f (E.symm a)\n      top := fun x => E (T x)\n      top_mem := fun x => by simpa using h₁ x\n      inter := fun a b x h => E (I (E.symm a) (E.symm b) x h)\n      inter_mem := fun a b x h => by simpa using h₂ (E.symm a) (E.symm b) x h\n      inter_sub := fun a b x h => by simpa using h₃ (E.symm a) (E.symm b) x h }\n#align ctop.of_equiv Ctop.ofEquiv\n-/\n\n/- warning: ctop.of_equiv_val -> Ctop.ofEquiv_val is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} {τ : Type.{u3}} (E : Equiv.{succ u2, succ u3} σ τ) (F : Ctop.{u1, u2} α σ) (a : τ), Eq.{succ u1} (Set.{u1} α) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (Ctop.{u1, u3} α τ) (fun (_x : Ctop.{u1, u3} α τ) => τ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u3} α τ) (Ctop.ofEquiv.{u1, u2, u3} α σ τ E F) a) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F (coeFn.{max 1 (max (succ u3) (succ u2)) (succ u2) (succ u3), max (succ u3) (succ u2)} (Equiv.{succ u3, succ u2} τ σ) (fun (_x : Equiv.{succ u3, succ u2} τ σ) => τ -> σ) (Equiv.hasCoeToFun.{succ u3, succ u2} τ σ) (Equiv.symm.{succ u2, succ u3} σ τ E) a))\nbut is expected to have type\n  forall {α : Type.{u1}} {σ : Type.{u3}} {τ : Type.{u2}} (E : Equiv.{succ u3, succ u2} σ τ) (F : Ctop.{u1, u3} α σ) (a : τ), Eq.{succ u1} (Set.{u1} α) (Ctop.f.{u1, u2} α τ (Ctop.ofEquiv.{u1, u3, u2} α σ τ E F) a) (Ctop.f.{u1, u3} α σ F (FunLike.coe.{max (succ u3) (succ u2), succ u2, succ u3} (Equiv.{succ u2, succ u3} τ σ) τ (fun (_x : τ) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : τ) => σ) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u3} τ σ) (Equiv.symm.{succ u3, succ u2} σ τ E) a))\nCase conversion may be inaccurate. Consider using '#align ctop.of_equiv_val Ctop.ofEquiv_valₓ'. -/\n@[simp]\ntheorem ofEquiv_val (E : σ ≃ τ) (F : Ctop α σ) (a : τ) : F.of_equiv E a = F (E.symm a) := by\n  cases F <;> rfl\n#align ctop.of_equiv_val Ctop.ofEquiv_val\n\nend\n\n#print Ctop.toTopsp /-\n/-- Every `ctop` is a topological space. -/\ndef toTopsp (F : Ctop α σ) : TopologicalSpace α :=\n  TopologicalSpace.generateFrom (Set.range F.f)\n#align ctop.to_topsp Ctop.toTopsp\n-/\n\n/- warning: ctop.to_topsp_is_topological_basis -> Ctop.toTopsp_isTopologicalBasis is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} (F : Ctop.{u1, u2} α σ), TopologicalSpace.IsTopologicalBasis.{u1} α (Ctop.toTopsp.{u1, u2} α σ F) (Set.range.{u1, succ u2} (Set.{u1} α) σ (Ctop.f.{u1, u2} α σ F))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} (F : Ctop.{u2, u1} α σ), TopologicalSpace.IsTopologicalBasis.{u2} α (Ctop.toTopsp.{u2, u1} α σ F) (Set.range.{u2, succ u1} (Set.{u2} α) σ (Ctop.f.{u2, u1} α σ F))\nCase conversion may be inaccurate. Consider using '#align ctop.to_topsp_is_topological_basis Ctop.toTopsp_isTopologicalBasisₓ'. -/\ntheorem toTopsp_isTopologicalBasis (F : Ctop α σ) :\n    @TopologicalSpace.IsTopologicalBasis _ F.toTopsp (Set.range F.f) :=\n  letI := F.to_topsp\n  ⟨fun u ⟨a, e₁⟩ v ⟨b, e₂⟩ =>\n    e₁ ▸ e₂ ▸ fun x h => ⟨_, ⟨_, rfl⟩, F.inter_mem a b x h, F.inter_sub a b x h⟩,\n    eq_univ_iff_forall.2 fun x => ⟨_, ⟨_, rfl⟩, F.top_mem x⟩, rfl⟩\n#align ctop.to_topsp_is_topological_basis Ctop.toTopsp_isTopologicalBasis\n\n/- warning: ctop.mem_nhds_to_topsp -> Ctop.mem_nhds_toTopsp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} (F : Ctop.{u1, u2} α σ) {s : Set.{u1} α} {a : α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α (Ctop.toTopsp.{u1, u2} α σ F) a)) (Exists.{succ u2} σ (fun (b : σ) => And (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F b) s)))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} (F : Ctop.{u2, u1} α σ) {s : Set.{u2} α} {a : α}, Iff (Membership.mem.{u2, u2} (Set.{u2} α) (Filter.{u2} α) (instMembershipSetFilter.{u2} α) s (nhds.{u2} α (Ctop.toTopsp.{u2, u1} α σ F) a)) (Exists.{succ u1} σ (fun (b : σ) => And (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α σ F b)) (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Ctop.f.{u2, u1} α σ F b) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.mem_nhds_to_topsp Ctop.mem_nhds_toTopspₓ'. -/\n@[simp]\ntheorem mem_nhds_toTopsp (F : Ctop α σ) {s : Set α} {a : α} :\n    s ∈ @nhds _ F.toTopsp a ↔ ∃ b, a ∈ F b ∧ F b ⊆ s :=\n  (@TopologicalSpace.IsTopologicalBasis.mem_nhds_iff _ F.toTopsp _ _ _\n        F.toTopsp_isTopologicalBasis).trans <|\n    ⟨fun ⟨_, ⟨x, rfl⟩, h⟩ => ⟨x, h⟩, fun ⟨x, h⟩ => ⟨_, ⟨x, rfl⟩, h⟩⟩\n#align ctop.mem_nhds_to_topsp Ctop.mem_nhds_toTopsp\n\nend Ctop\n\n#print Ctop.Realizer /-\n/-- A `ctop` realizer for the topological space `T` is a `ctop`\n  which generates `T`. -/\nstructure Ctop.Realizer (α) [T : TopologicalSpace α] where\n  σ : Type _\n  f : Ctop α σ\n  Eq : F.toTopsp = T\n#align ctop.realizer Ctop.Realizer\n-/\n\nopen Ctop\n\n#print Ctop.toRealizer /-\n/-- A `ctop` realizes the topological space it generates. -/\nprotected def Ctop.toRealizer (F : Ctop α σ) : @Ctop.Realizer _ F.toTopsp :=\n  @Ctop.Realizer.mk _ F.toTopsp σ F rfl\n#align ctop.to_realizer Ctop.toRealizer\n-/\n\ninstance (F : Ctop α σ) : Inhabited (@Ctop.Realizer _ F.toTopsp) :=\n  ⟨F.toRealizer⟩\n\nnamespace Ctop.Realizer\n\n/- warning: ctop.realizer.is_basis -> Ctop.Realizer.is_basis is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [T : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α T), TopologicalSpace.IsTopologicalBasis.{u1} α T (Set.range.{u1, succ u2} (Set.{u1} α) (Ctop.Realizer.σ.{u1, u2} α T F) (Ctop.f.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α T F) (Ctop.Realizer.f.{u1, u2} α T F)))\nbut is expected to have type\n  forall {α : Type.{u2}} [T : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α T), TopologicalSpace.IsTopologicalBasis.{u2} α T (Set.range.{u2, succ u1} (Set.{u2} α) (Ctop.Realizer.σ.{u2, u1} α T F) (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α T F) (Ctop.Realizer.F.{u2, u1} α T F)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_basis Ctop.Realizer.is_basisₓ'. -/\nprotected theorem is_basis [T : TopologicalSpace α] (F : Realizer α) :\n    TopologicalSpace.IsTopologicalBasis (Set.range F.f.f) := by\n  have := to_topsp_is_topological_basis F.F <;> rwa [F.eq] at this\n#align ctop.realizer.is_basis Ctop.Realizer.is_basis\n\n/- warning: ctop.realizer.mem_nhds -> Ctop.Realizer.mem_nhds is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [T : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α T) {s : Set.{u1} α} {a : α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α T a)) (Exists.{succ u2} (Ctop.Realizer.σ.{u1, u2} α T F) (fun (b : Ctop.Realizer.σ.{u1, u2} α T F) => And (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α T F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α T F)) => (Ctop.Realizer.σ.{u1, u2} α T F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α T F)) (Ctop.Realizer.f.{u1, u2} α T F) b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α T F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α T F)) => (Ctop.Realizer.σ.{u1, u2} α T F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α T F)) (Ctop.Realizer.f.{u1, u2} α T F) b) s)))\nbut is expected to have type\n  forall {α : Type.{u2}} [T : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α T) {s : Set.{u2} α} {a : α}, Iff (Membership.mem.{u2, u2} (Set.{u2} α) (Filter.{u2} α) (instMembershipSetFilter.{u2} α) s (nhds.{u2} α T a)) (Exists.{succ u1} (Ctop.Realizer.σ.{u2, u1} α T F) (fun (b : Ctop.Realizer.σ.{u2, u1} α T F) => And (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α T F) (Ctop.Realizer.F.{u2, u1} α T F) b)) (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α T F) (Ctop.Realizer.F.{u2, u1} α T F) b) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.mem_nhds Ctop.Realizer.mem_nhdsₓ'. -/\nprotected theorem mem_nhds [T : TopologicalSpace α] (F : Realizer α) {s : Set α} {a : α} :\n    s ∈ 𝓝 a ↔ ∃ b, a ∈ F.f b ∧ F.f b ⊆ s := by have := mem_nhds_to_topsp F.F <;> rwa [F.eq] at this\n#align ctop.realizer.mem_nhds Ctop.Realizer.mem_nhds\n\n/- warning: ctop.realizer.is_open_iff -> Ctop.Realizer.isOpen_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α _inst_1) {s : Set.{u1} α}, Iff (IsOpen.{u1} α _inst_1 s) (forall (a : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a s) -> (Exists.{succ u2} (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) (fun (b : Ctop.Realizer.σ.{u1, u2} α _inst_1 F) => And (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) b) s))))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α _inst_1) {s : Set.{u2} α}, Iff (IsOpen.{u2} α _inst_1 s) (forall (a : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a s) -> (Exists.{succ u1} (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (fun (b : Ctop.Realizer.σ.{u2, u1} α _inst_1 F) => And (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) b)) (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) b) s))))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_open_iff Ctop.Realizer.isOpen_iffₓ'. -/\ntheorem isOpen_iff [TopologicalSpace α] (F : Realizer α) {s : Set α} :\n    IsOpen s ↔ ∀ a ∈ s, ∃ b, a ∈ F.f b ∧ F.f b ⊆ s :=\n  isOpen_iff_mem_nhds.trans <| ball_congr fun a h => F.mem_nhds\n#align ctop.realizer.is_open_iff Ctop.Realizer.isOpen_iff\n\n/- warning: ctop.realizer.is_closed_iff -> Ctop.Realizer.isClosed_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α _inst_1) {s : Set.{u1} α}, Iff (IsClosed.{u1} α _inst_1 s) (forall (a : α), (forall (b : Ctop.Realizer.σ.{u1, u2} α _inst_1 F), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) b)) -> (Exists.{succ u1} α (fun (z : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) z (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) b) s)))) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a s))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α _inst_1) {s : Set.{u2} α}, Iff (IsClosed.{u2} α _inst_1 s) (forall (a : α), (forall (b : Ctop.Realizer.σ.{u2, u1} α _inst_1 F), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) b)) -> (Exists.{succ u2} α (fun (z : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) z (Inter.inter.{u2} (Set.{u2} α) (Set.instInterSet.{u2} α) (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) b) s)))) -> (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a s))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_closed_iff Ctop.Realizer.isClosed_iffₓ'. -/\ntheorem isClosed_iff [TopologicalSpace α] (F : Realizer α) {s : Set α} :\n    IsClosed s ↔ ∀ a, (∀ b, a ∈ F.f b → ∃ z, z ∈ F.f b ∩ s) → a ∈ s :=\n  isOpen_compl_iff.symm.trans <|\n    F.isOpen_iff.trans <|\n      forall_congr' fun a =>\n        show (a ∉ s → ∃ b : F.σ, a ∈ F.f b ∧ ∀ z ∈ F.f b, z ∉ s) ↔ _ by\n          haveI := Classical.propDecidable <;> rw [not_imp_comm] <;>\n            simp [not_exists, not_and, not_forall, and_comm']\n#align ctop.realizer.is_closed_iff Ctop.Realizer.isClosed_iff\n\n/- warning: ctop.realizer.mem_interior_iff -> Ctop.Realizer.mem_interior_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α _inst_1) {s : Set.{u1} α} {a : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (interior.{u1} α _inst_1 s)) (Exists.{succ u2} (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) (fun (b : Ctop.Realizer.σ.{u1, u2} α _inst_1 F) => And (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) b) s)))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α _inst_1) {s : Set.{u2} α} {a : α}, Iff (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (interior.{u2} α _inst_1 s)) (Exists.{succ u1} (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (fun (b : Ctop.Realizer.σ.{u2, u1} α _inst_1 F) => And (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) b)) (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) b) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.mem_interior_iff Ctop.Realizer.mem_interior_iffₓ'. -/\ntheorem mem_interior_iff [TopologicalSpace α] (F : Realizer α) {s : Set α} {a : α} :\n    a ∈ interior s ↔ ∃ b, a ∈ F.f b ∧ F.f b ⊆ s :=\n  mem_interior_iff_mem_nhds.trans F.mem_nhds\n#align ctop.realizer.mem_interior_iff Ctop.Realizer.mem_interior_iff\n\n/- warning: ctop.realizer.is_open -> Ctop.Realizer.isOpen is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α _inst_1) (s : Ctop.Realizer.σ.{u1, u2} α _inst_1 F), IsOpen.{u1} α _inst_1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) s)\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α _inst_1) (s : Ctop.Realizer.σ.{u2, u1} α _inst_1 F), IsOpen.{u2} α _inst_1 (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) s)\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_open Ctop.Realizer.isOpenₓ'. -/\nprotected theorem isOpen [TopologicalSpace α] (F : Realizer α) (s : F.σ) : IsOpen (F.f s) :=\n  isOpen_iff_nhds.2 fun a m => by simpa using F.mem_nhds.2 ⟨s, m, subset.refl _⟩\n#align ctop.realizer.is_open Ctop.Realizer.isOpen\n\n/- warning: ctop.realizer.ext' -> Ctop.Realizer.ext' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [T : TopologicalSpace.{u1} α] {σ : Type.{u2}} {F : Ctop.{u1, u2} α σ}, (forall (a : α) (s : Set.{u1} α), Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α T a)) (Exists.{succ u2} σ (fun (b : σ) => And (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F b) s)))) -> (Eq.{succ u1} (TopologicalSpace.{u1} α) (Ctop.toTopsp.{u1, u2} α σ F) T)\nbut is expected to have type\n  forall {α : Type.{u2}} [T : TopologicalSpace.{u2} α] {σ : Type.{u1}} {F : Ctop.{u2, u1} α σ}, (forall (a : α) (s : Set.{u2} α), Iff (Membership.mem.{u2, u2} (Set.{u2} α) (Filter.{u2} α) (instMembershipSetFilter.{u2} α) s (nhds.{u2} α T a)) (Exists.{succ u1} σ (fun (b : σ) => And (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α σ F b)) (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Ctop.f.{u2, u1} α σ F b) s)))) -> (Eq.{succ u2} (TopologicalSpace.{u2} α) (Ctop.toTopsp.{u2, u1} α σ F) T)\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.ext' Ctop.Realizer.ext'ₓ'. -/\ntheorem ext' [T : TopologicalSpace α] {σ : Type _} {F : Ctop α σ}\n    (H : ∀ a s, s ∈ 𝓝 a ↔ ∃ b, a ∈ F b ∧ F b ⊆ s) : F.toTopsp = T :=\n  by\n  refine' eq_of_nhds_eq_nhds fun x => _\n  ext s\n  rw [mem_nhds_to_topsp, H]\n#align ctop.realizer.ext' Ctop.Realizer.ext'\n\n/- warning: ctop.realizer.ext -> Ctop.Realizer.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [T : TopologicalSpace.{u1} α] {σ : Type.{u2}} {F : Ctop.{u1, u2} α σ}, (forall (a : σ), IsOpen.{u1} α T (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F a)) -> (forall (a : α) (s : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α T a)) -> (Exists.{succ u2} σ (fun (b : σ) => And (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F b)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α σ) (fun (_x : Ctop.{u1, u2} α σ) => σ -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α σ) F b) s)))) -> (Eq.{succ u1} (TopologicalSpace.{u1} α) (Ctop.toTopsp.{u1, u2} α σ F) T)\nbut is expected to have type\n  forall {α : Type.{u2}} [T : TopologicalSpace.{u2} α] {σ : Type.{u1}} {F : Ctop.{u2, u1} α σ}, (forall (a : σ), IsOpen.{u2} α T (Ctop.f.{u2, u1} α σ F a)) -> (forall (a : α) (s : Set.{u2} α), (Membership.mem.{u2, u2} (Set.{u2} α) (Filter.{u2} α) (instMembershipSetFilter.{u2} α) s (nhds.{u2} α T a)) -> (Exists.{succ u1} σ (fun (b : σ) => And (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α σ F b)) (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Ctop.f.{u2, u1} α σ F b) s)))) -> (Eq.{succ u2} (TopologicalSpace.{u2} α) (Ctop.toTopsp.{u2, u1} α σ F) T)\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.ext Ctop.Realizer.extₓ'. -/\ntheorem ext [T : TopologicalSpace α] {σ : Type _} {F : Ctop α σ} (H₁ : ∀ a, IsOpen (F a))\n    (H₂ : ∀ a s, s ∈ 𝓝 a → ∃ b, a ∈ F b ∧ F b ⊆ s) : F.toTopsp = T :=\n  ext' fun a s => ⟨H₂ a s, fun ⟨b, h₁, h₂⟩ => mem_nhds_iff.2 ⟨_, h₂, H₁ _, h₁⟩⟩\n#align ctop.realizer.ext Ctop.Realizer.ext\n\nvariable [TopologicalSpace α]\n\n#print Ctop.Realizer.id /-\n/-- The topological space realizer made of the open sets. -/\nprotected def id : Realizer α :=\n  ⟨{ x : Set α // IsOpen x },\n    { f := Subtype.val\n      top := fun _ => ⟨univ, isOpen_univ⟩\n      top_mem := mem_univ\n      inter := fun ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃ => ⟨_, h₁.inter h₂⟩\n      inter_mem := fun ⟨x, h₁⟩ ⟨y, h₂⟩ a => id\n      inter_sub := fun ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃ => Subset.refl _ },\n    ext Subtype.property fun x s h =>\n      let ⟨t, h, o, m⟩ := mem_nhds_iff.1 h\n      ⟨⟨t, o⟩, m, h⟩⟩\n#align ctop.realizer.id Ctop.Realizer.id\n-/\n\n#print Ctop.Realizer.ofEquiv /-\n/-- Replace the representation type of a `ctop` realizer. -/\ndef ofEquiv (F : Realizer α) (E : F.σ ≃ τ) : Realizer α :=\n  ⟨τ, F.f.of_equiv E,\n    ext' fun a s =>\n      F.mem_nhds.trans <|\n        ⟨fun ⟨s, h⟩ => ⟨E s, by simpa using h⟩, fun ⟨t, h⟩ => ⟨E.symm t, by simpa using h⟩⟩⟩\n#align ctop.realizer.of_equiv Ctop.Realizer.ofEquiv\n-/\n\n/- warning: ctop.realizer.of_equiv_σ -> Ctop.Realizer.ofEquiv_σ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {τ : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u3} α _inst_1) (E : Equiv.{succ u3, succ u2} (Ctop.Realizer.σ.{u1, u3} α _inst_1 F) τ), Eq.{succ (succ u2)} Type.{u2} (Ctop.Realizer.σ.{u1, u2} α _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} α τ _inst_1 F E)) τ\nbut is expected to have type\n  forall {α : Type.{u3}} {τ : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} α] (F : Ctop.Realizer.{u3, u2} α _inst_1) (E : Equiv.{succ u2, succ u1} (Ctop.Realizer.σ.{u3, u2} α _inst_1 F) τ), Eq.{succ (succ u1)} Type.{u1} (Ctop.Realizer.σ.{u3, u1} α _inst_1 (Ctop.Realizer.ofEquiv.{u3, u1, u2} α τ _inst_1 F E)) τ\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.of_equiv_σ Ctop.Realizer.ofEquiv_σₓ'. -/\n@[simp]\ntheorem ofEquiv_σ (F : Realizer α) (E : F.σ ≃ τ) : (F.of_equiv E).σ = τ :=\n  rfl\n#align ctop.realizer.of_equiv_σ Ctop.Realizer.ofEquiv_σ\n\n/- warning: ctop.realizer.of_equiv_F -> Ctop.Realizer.ofEquiv_F is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {τ : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u3} α _inst_1) (E : Equiv.{succ u3, succ u2} (Ctop.Realizer.σ.{u1, u3} α _inst_1 F) τ) (s : τ), Eq.{succ u1} (Set.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} α τ _inst_1 F E))) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} α τ _inst_1 F E))) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} α τ _inst_1 F E)) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} α τ _inst_1 F E))) (Ctop.Realizer.f.{u1, u2} α _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} α τ _inst_1 F E)) s) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (Ctop.{u1, u3} α (Ctop.Realizer.σ.{u1, u3} α _inst_1 F)) (fun (_x : Ctop.{u1, u3} α (Ctop.Realizer.σ.{u1, u3} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u3} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u3} α (Ctop.Realizer.σ.{u1, u3} α _inst_1 F)) (Ctop.Realizer.f.{u1, u3} α _inst_1 F) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} τ (Ctop.Realizer.σ.{u1, u3} α _inst_1 F)) (fun (_x : Equiv.{succ u2, succ u3} τ (Ctop.Realizer.σ.{u1, u3} α _inst_1 F)) => τ -> (Ctop.Realizer.σ.{u1, u3} α _inst_1 F)) (Equiv.hasCoeToFun.{succ u2, succ u3} τ (Ctop.Realizer.σ.{u1, u3} α _inst_1 F)) (Equiv.symm.{succ u3, succ u2} (Ctop.Realizer.σ.{u1, u3} α _inst_1 F) τ E) s))\nbut is expected to have type\n  forall {α : Type.{u3}} {τ : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} α] (F : Ctop.Realizer.{u3, u2} α _inst_1) (E : Equiv.{succ u2, succ u1} (Ctop.Realizer.σ.{u3, u2} α _inst_1 F) τ) (s : τ), Eq.{succ u3} (Set.{u3} α) (Ctop.f.{u3, u1} α (Ctop.Realizer.σ.{u3, u1} α _inst_1 (Ctop.Realizer.ofEquiv.{u3, u1, u2} α τ _inst_1 F E)) (Ctop.Realizer.F.{u3, u1} α _inst_1 (Ctop.Realizer.ofEquiv.{u3, u1, u2} α τ _inst_1 F E)) s) (Ctop.f.{u3, u2} α (Ctop.Realizer.σ.{u3, u2} α _inst_1 F) (Ctop.Realizer.F.{u3, u2} α _inst_1 F) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Equiv.{succ u1, succ u2} τ (Ctop.Realizer.σ.{u3, u2} α _inst_1 F)) τ (fun (_x : τ) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : τ) => Ctop.Realizer.σ.{u3, u2} α _inst_1 F) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u2} τ (Ctop.Realizer.σ.{u3, u2} α _inst_1 F)) (Equiv.symm.{succ u2, succ u1} (Ctop.Realizer.σ.{u3, u2} α _inst_1 F) τ E) s))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.of_equiv_F Ctop.Realizer.ofEquiv_Fₓ'. -/\n@[simp]\ntheorem ofEquiv_F (F : Realizer α) (E : F.σ ≃ τ) (s : τ) : (F.of_equiv E).f s = F.f (E.symm s) := by\n  delta of_equiv <;> simp\n#align ctop.realizer.of_equiv_F Ctop.Realizer.ofEquiv_F\n\n#print Ctop.Realizer.nhds /-\n/-- A realizer of the neighborhood of a point. -/\nprotected def nhds (F : Realizer α) (a : α) : (𝓝 a).Realizer :=\n  ⟨{ s : F.σ // a ∈ F.f s },\n    { f := fun s => F.f s.1\n      pt := ⟨_, F.f.top_mem a⟩\n      inf := fun ⟨x, h₁⟩ ⟨y, h₂⟩ => ⟨_, F.f.inter_mem x y a ⟨h₁, h₂⟩⟩\n      inf_le_left := fun ⟨x, h₁⟩ ⟨y, h₂⟩ z h => (F.f.inter_sub x y a ⟨h₁, h₂⟩ h).1\n      inf_le_right := fun ⟨x, h₁⟩ ⟨y, h₂⟩ z h => (F.f.inter_sub x y a ⟨h₁, h₂⟩ h).2 },\n    filter_eq <|\n      Set.ext fun x =>\n        ⟨fun ⟨⟨s, as⟩, h⟩ => mem_nhds_iff.2 ⟨_, h, F.IsOpen _, as⟩, fun h =>\n          let ⟨s, h, as⟩ := F.mem_nhds.1 h\n          ⟨⟨s, h⟩, as⟩⟩⟩\n#align ctop.realizer.nhds Ctop.Realizer.nhds\n-/\n\n/- warning: ctop.realizer.nhds_σ -> Ctop.Realizer.nhds_σ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α _inst_1) (a : α), Eq.{succ (succ u2)} Type.{u2} (Filter.Realizer.σ.{u1, u2} α (nhds.{u1} α _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} α _inst_1 F a)) (Subtype.{succ u2} (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) (fun (s : Ctop.Realizer.σ.{u1, u2} α _inst_1 F) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) s)))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α _inst_1) (a : α), Eq.{succ (succ u1)} Type.{u1} (Filter.Realizer.σ.{u2, u1} α (nhds.{u2} α _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} α _inst_1 F a)) (Subtype.{succ u1} (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (fun (s : Ctop.Realizer.σ.{u2, u1} α _inst_1 F) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.nhds_σ Ctop.Realizer.nhds_σₓ'. -/\n@[simp]\ntheorem nhds_σ (F : Realizer α) (a : α) : (F.nhds a).σ = { s : F.σ // a ∈ F.f s } :=\n  rfl\n#align ctop.realizer.nhds_σ Ctop.Realizer.nhds_σ\n\n/- warning: ctop.realizer.nhds_F -> Ctop.Realizer.nhds_F is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u2} α _inst_1) (a : α) (s : Filter.Realizer.σ.{u1, u2} α (nhds.{u1} α _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} α _inst_1 F a)), Eq.{succ u1} (Set.{u1} α) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (CFilter.{u1, u2} (Set.{u1} α) (Filter.Realizer.σ.{u1, u2} α (nhds.{u1} α _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} α _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α))))))) (fun (_x : CFilter.{u1, u2} (Set.{u1} α) (Filter.Realizer.σ.{u1, u2} α (nhds.{u1} α _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} α _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α))))))) => (Filter.Realizer.σ.{u1, u2} α (nhds.{u1} α _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} α _inst_1 F a)) -> (Set.{u1} α)) (CFilter.hasCoeToFun.{u1, u2} (Set.{u1} α) (Filter.Realizer.σ.{u1, u2} α (nhds.{u1} α _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} α _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α))))))) (Filter.Realizer.f.{u1, u2} α (nhds.{u1} α _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} α _inst_1 F a)) s) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) (Subtype.val.{succ u2} (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) (fun (s : Ctop.Realizer.σ.{u1, u2} α _inst_1 F) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (fun (_x : Ctop.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) => (Ctop.Realizer.σ.{u1, u2} α _inst_1 F) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u2} α (Ctop.Realizer.σ.{u1, u2} α _inst_1 F)) (Ctop.Realizer.f.{u1, u2} α _inst_1 F) s)) s))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} α] (F : Ctop.Realizer.{u2, u1} α _inst_1) (a : α) (s : Filter.Realizer.σ.{u2, u1} α (nhds.{u2} α _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} α _inst_1 F a)), Eq.{succ u2} (Set.{u2} α) (CFilter.f.{u2, u1} (Set.{u2} α) (Filter.Realizer.σ.{u2, u1} α (nhds.{u2} α _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} α _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (Filter.Realizer.F.{u2, u1} α (nhds.{u2} α _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} α _inst_1 F a)) s) (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) (Subtype.val.{succ u1} (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (fun (s : Ctop.Realizer.σ.{u2, u1} α _inst_1 F) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 F) (Ctop.Realizer.F.{u2, u1} α _inst_1 F) s)) s))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.nhds_F Ctop.Realizer.nhds_Fₓ'. -/\n@[simp]\ntheorem nhds_F (F : Realizer α) (a : α) (s) : (F.nhds a).f s = F.f s.1 :=\n  rfl\n#align ctop.realizer.nhds_F Ctop.Realizer.nhds_F\n\n/- warning: ctop.realizer.tendsto_nhds_iff -> Ctop.Realizer.tendsto_nhds_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] {m : β -> α} {f : Filter.{u2} β} (F : Filter.Realizer.{u2, u3} β f) (R : Ctop.Realizer.{u1, u4} α _inst_1) {a : α}, Iff (Filter.Tendsto.{u2, u1} β α m f (nhds.{u1} α _inst_1 a)) (forall (t : Ctop.Realizer.σ.{u1, u4} α _inst_1 R), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (coeFn.{max (succ u1) (succ u4), max (succ u4) (succ u1)} (Ctop.{u1, u4} α (Ctop.Realizer.σ.{u1, u4} α _inst_1 R)) (fun (_x : Ctop.{u1, u4} α (Ctop.Realizer.σ.{u1, u4} α _inst_1 R)) => (Ctop.Realizer.σ.{u1, u4} α _inst_1 R) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u4} α (Ctop.Realizer.σ.{u1, u4} α _inst_1 R)) (Ctop.Realizer.f.{u1, u4} α _inst_1 R) t)) -> (Exists.{succ u3} (Filter.Realizer.σ.{u2, u3} β f F) (fun (s : Filter.Realizer.σ.{u2, u3} β f F) => forall (x : β), (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) x (coeFn.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (CFilter.{u2, u3} (Set.{u2} β) (Filter.Realizer.σ.{u2, u3} β f F) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β))))))) (fun (_x : CFilter.{u2, u3} (Set.{u2} β) (Filter.Realizer.σ.{u2, u3} β f F) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β))))))) => (Filter.Realizer.σ.{u2, u3} β f F) -> (Set.{u2} β)) (CFilter.hasCoeToFun.{u2, u3} (Set.{u2} β) (Filter.Realizer.σ.{u2, u3} β f F) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β))))))) (Filter.Realizer.f.{u2, u3} β f F) s)) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (m x) (coeFn.{max (succ u1) (succ u4), max (succ u4) (succ u1)} (Ctop.{u1, u4} α (Ctop.Realizer.σ.{u1, u4} α _inst_1 R)) (fun (_x : Ctop.{u1, u4} α (Ctop.Realizer.σ.{u1, u4} α _inst_1 R)) => (Ctop.Realizer.σ.{u1, u4} α _inst_1 R) -> (Set.{u1} α)) (Ctop.hasCoeToFun.{u1, u4} α (Ctop.Realizer.σ.{u1, u4} α _inst_1 R)) (Ctop.Realizer.f.{u1, u4} α _inst_1 R) t)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u4}} [_inst_1 : TopologicalSpace.{u2} α] {m : β -> α} {f : Filter.{u4} β} (F : Filter.Realizer.{u4, u3} β f) (R : Ctop.Realizer.{u2, u1} α _inst_1) {a : α}, Iff (Filter.Tendsto.{u4, u2} β α m f (nhds.{u2} α _inst_1 a)) (forall (t : Ctop.Realizer.σ.{u2, u1} α _inst_1 R), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 R) (Ctop.Realizer.F.{u2, u1} α _inst_1 R) t)) -> (Exists.{succ u3} (Filter.Realizer.σ.{u4, u3} β f F) (fun (s : Filter.Realizer.σ.{u4, u3} β f F) => forall (x : β), (Membership.mem.{u4, u4} β (Set.{u4} β) (Set.instMembershipSet.{u4} β) x (CFilter.f.{u4, u3} (Set.{u4} β) (Filter.Realizer.σ.{u4, u3} β f F) (CompleteSemilatticeInf.toPartialOrder.{u4} (Set.{u4} β) (CompleteLattice.toCompleteSemilatticeInf.{u4} (Set.{u4} β) (Order.Coframe.toCompleteLattice.{u4} (Set.{u4} β) (CompleteDistribLattice.toCoframe.{u4} (Set.{u4} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u4} (Set.{u4} β) (Set.instCompleteBooleanAlgebraSet.{u4} β)))))) (Filter.Realizer.F.{u4, u3} β f F) s)) -> (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) (m x) (Ctop.f.{u2, u1} α (Ctop.Realizer.σ.{u2, u1} α _inst_1 R) (Ctop.Realizer.F.{u2, u1} α _inst_1 R) t)))))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.tendsto_nhds_iff Ctop.Realizer.tendsto_nhds_iffₓ'. -/\ntheorem tendsto_nhds_iff {m : β → α} {f : Filter β} (F : f.Realizer) (R : Realizer α) {a : α} :\n    Tendsto m f (𝓝 a) ↔ ∀ t, a ∈ R.f t → ∃ s, ∀ x ∈ F.f s, m x ∈ R.f t :=\n  (F.tendsto_iffₓ _ (R.nhds a)).trans Subtype.forall\n#align ctop.realizer.tendsto_nhds_iff Ctop.Realizer.tendsto_nhds_iff\n\nend Ctop.Realizer\n\n#print LocallyFinite.Realizer /-\n/-- A `locally_finite.realizer F f` is a realization that `f` is locally finite, namely it is a\nchoice of open sets from the basis of `F` such that they intersect only finitely many of the values\nof `f`.  -/\nstructure LocallyFinite.Realizer [TopologicalSpace α] (F : Realizer α) (f : β → Set α) where\n  bas : ∀ a, { s // a ∈ F.f s }\n  sets : ∀ x : α, Fintype { i | (f i ∩ F.f (bas x)).Nonempty }\n#align locally_finite.realizer LocallyFinite.Realizer\n-/\n\n/- warning: locally_finite.realizer.to_locally_finite -> LocallyFinite.Realizer.to_locallyFinite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] {F : Ctop.Realizer.{u1, u3} α _inst_1} {f : β -> (Set.{u1} α)}, (LocallyFinite.Realizer.{u1, u2, u3} α β _inst_1 F f) -> (LocallyFinite.{u2, u1} β α _inst_1 f)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} α] {F : Ctop.Realizer.{u3, u2} α _inst_1} {f : β -> (Set.{u3} α)}, (LocallyFinite.Realizer.{u3, u1, u2} α β _inst_1 F f) -> (LocallyFinite.{u1, u3} β α _inst_1 f)\nCase conversion may be inaccurate. Consider using '#align locally_finite.realizer.to_locally_finite LocallyFinite.Realizer.to_locallyFiniteₓ'. -/\ntheorem LocallyFinite.Realizer.to_locallyFinite [TopologicalSpace α] {F : Realizer α}\n    {f : β → Set α} (R : LocallyFinite.Realizer F f) : LocallyFinite f := fun a =>\n  ⟨_, F.mem_nhds.2 ⟨(R.bas a).1, (R.bas a).2, Subset.refl _⟩, ⟨R.sets a⟩⟩\n#align locally_finite.realizer.to_locally_finite LocallyFinite.Realizer.to_locallyFinite\n\n/- warning: locally_finite_iff_exists_realizer -> locallyFinite_iff_exists_realizer is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} α] (F : Ctop.Realizer.{u1, u3} α _inst_1) {f : β -> (Set.{u1} α)}, Iff (LocallyFinite.{u2, u1} β α _inst_1 f) (Nonempty.{max (succ u1) (succ u2) (succ u3)} (LocallyFinite.Realizer.{u1, u2, u3} α β _inst_1 F f))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} α] (F : Ctop.Realizer.{u3, u2} α _inst_1) {f : β -> (Set.{u3} α)}, Iff (LocallyFinite.{u1, u3} β α _inst_1 f) (Nonempty.{max (max (succ u2) (succ u1)) (succ u3)} (LocallyFinite.Realizer.{u3, u1, u2} α β _inst_1 F f))\nCase conversion may be inaccurate. Consider using '#align locally_finite_iff_exists_realizer locallyFinite_iff_exists_realizerₓ'. -/\ntheorem locallyFinite_iff_exists_realizer [TopologicalSpace α] (F : Realizer α) {f : β → Set α} :\n    LocallyFinite f ↔ Nonempty (LocallyFinite.Realizer F f) :=\n  ⟨fun h =>\n    let ⟨g, h₁⟩ := Classical.axiom_of_choice h\n    let ⟨g₂, h₂⟩ :=\n      Classical.axiom_of_choice fun x =>\n        show ∃ b : F.σ, x ∈ F.f b ∧ F.f b ⊆ g x from\n          let ⟨h, h'⟩ := h₁ x\n          F.mem_nhds.1 h\n    ⟨⟨fun x => ⟨g₂ x, (h₂ x).1⟩, fun x =>\n        Finite.fintype <|\n          let ⟨h, h'⟩ := h₁ x\n          h'.Subset fun i hi => hi.mono (inter_subset_inter_right _ (h₂ x).2)⟩⟩,\n    fun ⟨R⟩ => R.to_locallyFinite⟩\n#align locally_finite_iff_exists_realizer locallyFinite_iff_exists_realizer\n\ninstance [TopologicalSpace α] [Finite β] (F : Realizer α) (f : β → Set α) :\n    Nonempty (LocallyFinite.Realizer F f) :=\n  (locallyFinite_iff_exists_realizer _).1 <| locallyFinite_of_finite _\n\n#print Compact.Realizer /-\n/-- A `compact.realizer s` is a realization that `s` is compact, namely it is a\nchoice of finite open covers for each set family covering `s`.  -/\ndef Compact.Realizer [TopologicalSpace α] (s : Set α) :=\n  ∀ {f : Filter α} (F : f.Realizer) (x : F.σ), f ≠ ⊥ → F.f x ⊆ s → { a // a ∈ s ∧ 𝓝 a ⊓ f ≠ ⊥ }\n#align compact.realizer Compact.Realizer\n-/\n\ninstance [TopologicalSpace α] : Inhabited (Compact.Realizer (∅ : Set α)) :=\n  ⟨fun f F x h hF => by\n    cases h _\n    rw [← F.eq, eq_bot_iff]\n    exact fun s _ => ⟨x, hF.trans s.empty_subset⟩⟩\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Analysis/Topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4844653732485133}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.metric_space.closeds\nimport Mathlib.set_theory.cardinal\nimport Mathlib.topology.metric_space.gromov_hausdorff_realized\nimport Mathlib.topology.metric_space.completion\nimport Mathlib.PostPort\n\nuniverses u v w l \n\nnamespace Mathlib\n\n/-!\n# Gromov-Hausdorff distance\n\nThis file defines the Gromov-Hausdorff distance on the space of nonempty compact metric spaces\nup to isometry.\n\nWe introduce the space of all nonempty compact metric spaces, up to isometry,\ncalled `GH_space`, and endow it with a metric space structure. The distance,\nknown as the Gromov-Hausdorff distance, is defined as follows: given two\nnonempty compact spaces `X` and `Y`, their distance is the minimum Hausdorff distance\nbetween all possible isometric embeddings of `X` and `Y` in all metric spaces.\nTo define properly the Gromov-Hausdorff space, we consider the non-empty\ncompact subsets of `ℓ^∞(ℝ)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `ℓ^∞(ℝ)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `ℓ^∞(ℝ)`, through an\nembedding called the Kuratowski embedding.\nTo prove that we have a distance, we should show that if spaces can be coupled\nto be arbitrarily close, then they are isometric. More generally, the Gromov-Hausdorff\ndistance is realized, i.e., there is a coupling for which the Hausdorff distance\nis exactly the Gromov-Hausdorff distance. This follows from a compactness\nargument, essentially following from Arzela-Ascoli.\n\n## Main results\n\nWe prove the most important properties of the Gromov-Hausdorff space: it is a polish space,\ni.e., it is complete and second countable. We also prove the Gromov compactness criterion.\n\n-/\n\nnamespace Gromov_Hausdorff\n\n\n/- In this section, we define the Gromov-Hausdorff space, denoted `GH_space` as the quotient\nof nonempty compact subsets of `ℓ^∞(ℝ)` by identifying isometric sets.\nUsing the Kuratwoski embedding, we get a canonical map `to_GH_space` mapping any nonempty\ncompact type to `GH_space`. -/\n\n/-- Equivalence relation identifying two nonempty compact sets which are isometric -/\n/-- This is indeed an equivalence relation -/\n/-- setoid instance identifying two isometric nonempty compact subspaces of ℓ^∞(ℝ) -/\nprotected instance isometry_rel.setoid : setoid (topological_space.nonempty_compacts ℓ_infty_ℝ) :=\n  setoid.mk isometry_rel is_equivalence_isometry_rel\n\n/-- The Gromov-Hausdorff space -/\ndef GH_space :=\n  quotient isometry_rel.setoid\n\n/-- Map any nonempty compact type to `GH_space` -/\ndef to_GH_space (α : Type u) [metric_space α] [compact_space α] [Nonempty α] : GH_space :=\n  quotient.mk (nonempty_compacts.Kuratowski_embedding α)\n\nprotected instance GH_space.inhabited : Inhabited GH_space :=\n  { default := Quot.mk setoid.r { val := singleton 0, property := sorry } }\n\n/-- A metric space representative of any abstract point in `GH_space` -/\ndef GH_space.rep (p : GH_space) :=\n  ↥(subtype.val (quot.out p))\n\ntheorem eq_to_GH_space_iff {α : Type u} [metric_space α] [compact_space α] [Nonempty α] {p : topological_space.nonempty_compacts ℓ_infty_ℝ} : quotient.mk p = to_GH_space α ↔ ∃ (Ψ : α → ℓ_infty_ℝ), isometry Ψ ∧ set.range Ψ = subtype.val p := sorry\n\ntheorem eq_to_GH_space {p : topological_space.nonempty_compacts ℓ_infty_ℝ} : quotient.mk p = to_GH_space ↥(subtype.val p) :=\n  iff.mpr eq_to_GH_space_iff\n    (Exists.intro (fun (x : ↥(subtype.val p)) => ↑x) { left := isometry_subtype_coe, right := subtype.range_coe })\n\nprotected instance rep_GH_space_metric_space {p : GH_space} : metric_space (GH_space.rep p) :=\n  subtype.metric_space\n\nprotected instance rep_GH_space_compact_space {p : GH_space} : compact_space (GH_space.rep p) :=\n  topological_space.nonempty_compacts.to_compact_space\n\nprotected instance rep_GH_space_nonempty {p : GH_space} : Nonempty (GH_space.rep p) :=\n  topological_space.nonempty_compacts.to_nonempty\n\ntheorem GH_space.to_GH_space_rep (p : GH_space) : to_GH_space (GH_space.rep p) = p :=\n  id\n    (eq.mpr (id (Eq._oldrec (Eq.refl (to_GH_space ↥(subtype.val (quot.out p)) = p)) (Eq.symm eq_to_GH_space)))\n      (quot.out_eq p))\n\n/-- Two nonempty compact spaces have the same image in `GH_space` if and only if they are\nisometric. -/\ntheorem to_GH_space_eq_to_GH_space_iff_isometric {α : Type u} [metric_space α] [compact_space α] [Nonempty α] {β : Type u} [metric_space β] [compact_space β] [Nonempty β] : to_GH_space α = to_GH_space β ↔ Nonempty (α ≃ᵢ β) := sorry\n\n/-- Distance on `GH_space`: the distance between two nonempty compact spaces is the infimum\nHausdorff distance between isometric copies of the two spaces in a metric space. For the definition,\nwe only consider embeddings in `ℓ^∞(ℝ)`, but we will prove below that it works for all spaces. -/\nprotected instance GH_space.has_dist : has_dist GH_space :=\n  has_dist.mk\n    fun (x y : GH_space) =>\n      Inf\n        ((fun (p : topological_space.nonempty_compacts ℓ_infty_ℝ × topological_space.nonempty_compacts ℓ_infty_ℝ) =>\n            metric.Hausdorff_dist (subtype.val (prod.fst p)) (subtype.val (prod.snd p))) ''\n          set.prod (set_of fun (a : topological_space.nonempty_compacts ℓ_infty_ℝ) => quotient.mk a = x)\n            (set_of fun (b : topological_space.nonempty_compacts ℓ_infty_ℝ) => quotient.mk b = y))\n\n/-- The Gromov-Hausdorff distance between two nonempty compact metric spaces, equal by definition to\nthe distance of the equivalence classes of these spaces in the Gromov-Hausdorff space. -/\ndef GH_dist (α : Type u) (β : Type v) [metric_space α] [Nonempty α] [compact_space α] [metric_space β] [Nonempty β] [compact_space β] : ℝ :=\n  dist (to_GH_space α) (to_GH_space β)\n\ntheorem dist_GH_dist (p : GH_space) (q : GH_space) : dist p q = GH_dist (GH_space.rep p) (GH_space.rep q) := sorry\n\n/-- The Gromov-Hausdorff distance between two spaces is bounded by the Hausdorff distance\nof isometric copies of the spaces, in any metric space. -/\ntheorem GH_dist_le_Hausdorff_dist {α : Type u} [metric_space α] [compact_space α] [Nonempty α] {β : Type v} [metric_space β] [compact_space β] [Nonempty β] {γ : Type w} [metric_space γ] {Φ : α → γ} {Ψ : β → γ} (ha : isometry Φ) (hb : isometry Ψ) : GH_dist α β ≤ metric.Hausdorff_dist (set.range Φ) (set.range Ψ) := sorry\n\n/-- The optimal coupling constructed above realizes exactly the Gromov-Hausdorff distance,\nessentially by design. -/\ntheorem Hausdorff_dist_optimal {α : Type u} [metric_space α] [compact_space α] [Nonempty α] {β : Type v} [metric_space β] [compact_space β] [Nonempty β] : metric.Hausdorff_dist (set.range (optimal_GH_injl α β)) (set.range (optimal_GH_injr α β)) = GH_dist α β := sorry\n\n/-- The Gromov-Hausdorff distance can also be realized by a coupling in `ℓ^∞(ℝ)`, by embedding\nthe optimal coupling through its Kuratowski embedding. -/\ntheorem GH_dist_eq_Hausdorff_dist (α : Type u) [metric_space α] [compact_space α] [Nonempty α] (β : Type v) [metric_space β] [compact_space β] [Nonempty β] : ∃ (Φ : α → ℓ_infty_ℝ),\n  ∃ (Ψ : β → ℓ_infty_ℝ), isometry Φ ∧ isometry Ψ ∧ GH_dist α β = metric.Hausdorff_dist (set.range Φ) (set.range Ψ) := sorry\n\n-- without the next two lines, `{ exact hΦ.is_closed }` in the next\n\n-- proof is very slow, as the `t2_space` instance is very hard to find\n\n/-- The Gromov-Hausdorff distance defines a genuine distance on the Gromov-Hausdorff space. -/\nprotected instance GH_space_metric_space : metric_space GH_space := sorry\n\nend Gromov_Hausdorff\n\n\n/-- In particular, nonempty compacts of a metric space map to `GH_space`. We register this\nin the topological_space namespace to take advantage of the notation `p.to_GH_space`. -/\ndef topological_space.nonempty_compacts.to_GH_space {α : Type u} [metric_space α] (p : topological_spa", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/metric_space/gromov_hausdorff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.4844653629750199}}
{"text": "constant f : Nat → Nat\nconstant g : Nat → Nat\n\nnamespace Foo\n\n@[scoped simp] axiom ax1 (x : Nat) : f (g x) = x\n@[scoped simp] axiom ax2 (x : Nat) : g (g x) = g x\n\nend Foo\n\ntheorem ex1 : f (g (g (g x))) = x := by\n  simp -- does not use ax1 and ax2\n  simp [Foo.ax1, Foo.ax2]\n\ntheorem ex2 : f (g (g (g x))) = x :=\n  have h₁ : f (g (g (g x))) = f (g x) := by simp; /- try again with `Foo` scoped lemmas -/ open Foo in simp\n  have h₂ : f (g x) = x               := by simp; open Foo in simp\n  Eq.trans h₁ h₂\n  -- open Foo in simp -- works\n\ntheorem ex3 : f (g (g (g x))) = x := by\n  simp\n  simp [Foo.ax1, Foo.ax2]\n\nopen Foo in\ntheorem ex4 : f (g (g (g x))) = x := by\n  simp\n\ntheorem ex5 : f (g (g (g x))) = x ∧ f (g x) = x := by\n  apply And.intro\n  { simp; open Foo in simp }\n  { simp; open Foo in simp }\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/run/openInScopeBug.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4844025502104892}}
{"text": "/-\nCopyright (c) 2020 Kevin Kappelmann. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Kappelmann\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.continued_fractions.computation.translations\nimport Mathlib.algebra.continued_fractions.terminated_stable\nimport Mathlib.algebra.continued_fractions.continuants_recurrence\nimport Mathlib.order.filter.at_top_bot\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n# Correctness of Terminating Continued Fraction Computations (`gcf.of`)\n\n## Summary\n\nLet us write `gcf` for `generalized_continued_fraction`. We show the correctness of the\nalgorithm computing continued fractions (`gcf.of`) in case of termination in the following sense:\n\nAt every step `n : ℕ`, we can obtain the value `v` by adding a specific residual term to the last\ndenominator of the fraction described by `(gcf.of v).convergents' n`. The residual term will be zero\nexactly when the continued fraction terminated; otherwise, the residual term will be given by the\nfractional part stored in `gcf.int_fract_pair.stream v n`.\n\nFor an example, refer to `gcf.comp_exact_value_correctness_of_stream_eq_some` and for more\ninformation about the computation process, refer to `algebra.continued_fraction.computation.basic`.\n\n## Main definitions\n\n- `gcf.comp_exact_value` can be used to compute the exact value approximated by the continued\n  fraction `gcf.of v` by adding a residual term as described in the summary.\n\n## Main Theorems\n\n- `gcf.comp_exact_value_correctness_of_stream_eq_some` shows that `gcf.comp_exact_value` indeed\n  returns the value `v` when given the convergent and fractional part as described in the summary.\n- `gcf.of_correctness_of_terminated_at` shows the equality `v = (gcf.of v).convergents n`\n  if `gcf.of v` terminated at position `n`.\n-/\n\nnamespace generalized_continued_fraction\n\n\n/--\nGiven two continuants `pconts` and `conts` and a value `fr`, this function returns\n- `conts.a / conts.b` if `fr = 0`\n- `exact_conts.a / exact_conts.b` where `exact_conts = next_continuants 1 fr⁻¹ pconts conts` otherwise.\n\nThis function can be used to compute the exact value approxmated by a continued fraction `gcf.of v`\nas described in lemma `comp_exact_value_correctness_of_stream_eq_some`.\n-/\n-- if the fractional part is zero, we exactly approximated the value by the last continuants\n\nprotected def comp_exact_value {K : Type u_1} [linear_ordered_field K] (pconts : pair K)\n    (conts : pair K) (fr : K) : K :=\n  ite (fr = 0) (pair.a conts / pair.b conts)\n    (let exact_conts : pair K := next_continuants 1 (fr⁻¹) pconts conts;\n    pair.a exact_conts / pair.b exact_conts)\n\n-- otherwise, we have to include the fractional part in a final continuants step.\n\n/-- Just a computational lemma we need for the next main proof. -/\nprotected theorem comp_exact_value_correctness_of_stream_eq_some_aux_comp {K : Type u_1}\n    [linear_ordered_field K] [floor_ring K] {a : K} (b : K) (c : K)\n    (fract_a_ne_zero : fract a ≠ 0) : (↑(floor a) * b + c) / fract a + b = (b * a + c) / fract a :=\n  sorry\n\n/--\nShows the correctness of `comp_exact_value` in case the continued fraction `gcf.of v` did not\nterminate at position `n`. That is, we obtain the value `v` if we pass the two successive\n(auxiliary) continuants at positions `n` and `n + 1` as well as the fractional part at\n`int_fract_pair.stream n` to `comp_exact_value`.\n\nThe correctness might be seen more readily if one uses `convergents'` to evaluate the continued\nfraction. Here is an example to illustrate the idea:\n\nLet `(v : ℚ) := 3.4`. We have\n- `gcf.int_fract_pair.stream v 0 = some ⟨3, 0.4⟩`, and\n- `gcf.int_fract_pair.stream v 1 = some ⟨2, 0.5⟩`.\nNow `(gcf.of v).convergents' 1 = 3 + 1/2`, and our fractional term at position `2` is `0.5`. We hence\nhave `v = 3 + 1/(2 + 0.5) = 3 + 1/2.5 = 3.4`. This computation corresponds exactly to the one using\nthe recurrence equation in `comp_exact_value`.\n-/\ntheorem comp_exact_value_correctness_of_stream_eq_some {K : Type u_1} [linear_ordered_field K]\n    {v : K} {n : ℕ} [floor_ring K] {ifp_n : int_fract_pair K} :\n    int_fract_pair.stream v n = some ifp_n →\n        v =\n          generalized_continued_fraction.comp_exact_value\n            (continuants_aux (generalized_continued_fraction.of v) n)\n            (continuants_aux (generalized_continued_fraction.of v) (n + 1))\n            (int_fract_pair.fr ifp_n) :=\n  sorry\n\n/-- The convergent of `gcf.of v` at step `n - 1` is exactly `v` if the `int_fract_pair.stream` of\nthe corresponding continued fraction terminated at step `n`. -/\ntheorem of_correctness_of_nth_stream_eq_none {K : Type u_1} [linear_ordered_field K] {v : K} {n : ℕ}\n    [floor_ring K] (nth_stream_eq_none : int_fract_pair.stream v n = none) :\n    v = convergents (generalized_continued_fraction.of v) (n - 1) :=\n  sorry\n\n/-- If `gcf.of v` terminated at step `n`, then the `n`th convergent is exactly `v`. -/\ntheorem of_correctness_of_terminated_at {K : Type u_1} [linear_ordered_field K] {v : K} {n : ℕ}\n    [floor_ring K] (terminated_at_n : terminated_at (generalized_continued_fraction.of v) n) :\n    v = convergents (generalized_continued_fraction.of v) n :=\n  (fun (this : int_fract_pair.stream v (n + 1) = none) => of_correctness_of_nth_stream_eq_none this)\n    (iff.elim_left of_terminated_at_n_iff_succ_nth_int_fract_pair_stream_eq_none terminated_at_n)\n\n/-- If `gcf.of v` terminates, then there is `n : ℕ` such that the `n`th convergent is exactly `v`. -/\ntheorem of_correctness_of_terminates {K : Type u_1} [linear_ordered_field K] {v : K} [floor_ring K]\n    (terminates : terminates (generalized_continued_fraction.of v)) :\n    ∃ (n : ℕ), v = convergents (generalized_continued_fraction.of v) n :=\n  exists.elim terminates\n    fun (n : ℕ) (terminated_at_n : seq.terminated_at (s (generalized_continued_fraction.of v)) n) =>\n      exists.intro n (of_correctness_of_terminated_at terminated_at_n)\n\n/-- If `gcf.of v` terminates, then its convergents will eventually always be `v`. -/\ntheorem of_correctness_at_top_of_terminates {K : Type u_1} [linear_ordered_field K] {v : K}\n    [floor_ring K] (terminates : terminates (generalized_continued_fraction.of v)) :\n    filter.eventually (fun (n : ℕ) => v = convergents (generalized_continued_fraction.of v) n)\n        filter.at_top :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/continued_fractions/computation/correctness_terminating_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.48440255021048917}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Heather Macbeth, Sébastien Gouëzel\n-/\nimport analysis.calculus.times_cont_diff\nimport analysis.normed_space.banach\nimport topology.local_homeomorph\nimport topology.metric_space.contracting\n\n/-!\n# Inverse function theorem\n\nIn this file we prove the inverse function theorem. It says that if a map `f : E → F`\nhas an invertible strict derivative `f'` at `a`, then it is locally invertible,\nand the inverse function has derivative `f' ⁻¹`.\n\nWe define `has_strict_deriv_at.to_local_homeomorph` that repacks a function `f`\nwith a `hf : has_strict_fderiv_at f f' a`, `f' : E ≃L[𝕜] F`, into a `local_homeomorph`.\nThe `to_fun` of this `local_homeomorph` is `defeq` to `f`, so one can apply theorems\nabout `local_homeomorph` to `hf.to_local_homeomorph f`, and get statements about `f`.\n\nThen we define `has_strict_fderiv_at.local_inverse` to be the `inv_fun` of this `local_homeomorph`,\nand prove two versions of the inverse function theorem:\n\n* `has_strict_fderiv_at.to_local_inverse`: if `f` has an invertible derivative `f'` at `a` in the\n  strict sense (`hf`), then `hf.local_inverse f f' a` has derivative `f'.symm` at `f a` in the\n  strict sense;\n\n* `has_strict_fderiv_at.to_local_left_inverse`: if `f` has an invertible derivative `f'` at `a` in\n  the strict sense and `g` is locally left inverse to `f` near `a`, then `g` has derivative\n  `f'.symm` at `f a` in the strict sense.\n\nIn the one-dimensional case we reformulate these theorems in terms of `has_strict_deriv_at` and\n`f'⁻¹`.\n\nWe also reformulate the theorems in terms of `times_cont_diff`, to give that `C^k` (respectively,\nsmooth) inputs give `C^k` (smooth) inverses.  These versions require that continuous\ndifferentiability implies strict differentiability; this is false over a general field, true over\n`ℝ` or `ℂ` and implemented here assuming `is_R_or_C 𝕂`.\n\nSome related theorems, providing the derivative and higher regularity assuming that we already know\nthe inverse function, are formulated in `fderiv.lean`, `deriv.lean`, and `times_cont_diff.lean`.\n\n## Notations\n\nIn the section about `approximates_linear_on` we introduce some `local notation` to make formulas\nshorter:\n\n* by `N` we denote `∥f'⁻¹∥`;\n* by `g` we denote the auxiliary contracting map `x ↦ x + f'.symm (y - f x)` used to prove that\n  `{x | f x = y}` is nonempty.\n\n## Tags\n\nderivative, strictly differentiable, continuously differentiable, smooth, inverse function\n-/\n\nopen function set filter metric\nopen_locale topological_space classical nnreal\n\nnoncomputable theory\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\nvariables {E : Type*} [normed_group E] [normed_space 𝕜 E]\nvariables {F : Type*} [normed_group F] [normed_space 𝕜 F]\nvariables {G : Type*} [normed_group G] [normed_space 𝕜 G]\nvariables {G' : Type*} [normed_group G'] [normed_space 𝕜 G']\nvariables {ε : ℝ}\n\n\nopen asymptotics filter metric set\nopen continuous_linear_map (id)\n\n\n/-!\n### Non-linear maps close to affine maps\n\nIn this section we study a map `f` such that `∥f x - f y - f' (x - y)∥ ≤ c * ∥x - y∥` on an open set\n`s`, where `f' : E →L[𝕜] F` is a continuous linear map and `c` is suitably small. Maps of this type\nbehave like `f a + f' (x - a)` near each `a ∈ s`.\n\nWhen `f'` is onto, we show that `f` is locally onto.\n\nWhen `f'` is a continuous linear equiv, we show that `f` is a homeomorphism\nbetween `s` and `f '' s`. More precisely, we define `approximates_linear_on.to_local_homeomorph` to\nbe a `local_homeomorph` with `to_fun = f`, `source = s`, and `target = f '' s`.\n\nMaps of this type naturally appear in the proof of the inverse function theorem (see next section),\nand `approximates_linear_on.to_local_homeomorph` will imply that the locally inverse function\nexists.\n\nWe define this auxiliary notion to split the proof of the inverse function theorem into small\nlemmas. This approach makes it possible\n\n- to prove a lower estimate on the size of the domain of the inverse function;\n\n- to reuse parts of the proofs in the case if a function is not strictly differentiable. E.g., for a\n  function `f : E × F → G` with estimates on `f x y₁ - f x y₂` but not on `f x₁ y - f x₂ y`.\n-/\n\n/-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`,\nif `∥f x - f y - f' (x - y)∥ ≤ c * ∥x - y∥` whenever `x, y ∈ s`.\n\nThis predicate is defined to facilitate the splitting of the inverse function theorem into small\nlemmas. Some of these lemmas can be useful, e.g., to prove that the inverse function is defined\non a specific set. -/\ndef approximates_linear_on (f : E → F) (f' : E →L[𝕜] F) (s : set E) (c : ℝ≥0) : Prop :=\n∀ (x ∈ s) (y ∈ s), ∥f x - f y - f' (x - y)∥ ≤ c * ∥x - y∥\n\nnamespace approximates_linear_on\n\nvariables [cs : complete_space E] {f : E → F}\n\n/-! First we prove some properties of a function that `approximates_linear_on` a (not necessarily\ninvertible) continuous linear map. -/\n\nsection\n\nvariables {f' : E →L[𝕜] F} {s t : set E} {c c' : ℝ≥0}\n\ntheorem mono_num (hc : c ≤ c') (hf : approximates_linear_on f f' s c) :\n  approximates_linear_on f f' s c' :=\nλ x hx y hy, le_trans (hf x hx y hy) (mul_le_mul_of_nonneg_right hc $ norm_nonneg _)\n\ntheorem mono_set (hst : s ⊆ t) (hf : approximates_linear_on f f' t c) :\n  approximates_linear_on f f' s c :=\nλ x hx y hy, hf x (hst hx) y (hst hy)\n\nlemma lipschitz_sub (hf : approximates_linear_on f f' s c) :\n  lipschitz_with c (λ x : s, f x - f' x) :=\nbegin\n  refine lipschitz_with.of_dist_le_mul (λ x y, _),\n  rw [dist_eq_norm, subtype.dist_eq, dist_eq_norm],\n  convert hf x x.2 y y.2 using 2,\n  rw [f'.map_sub], abel\nend\n\nprotected lemma lipschitz (hf : approximates_linear_on f f' s c) :\n  lipschitz_with (nnnorm f' + c) (s.restrict f) :=\nby simpa only [restrict_apply, add_sub_cancel'_right]\n  using (f'.lipschitz.restrict s).add hf.lipschitz_sub\n\nprotected lemma continuous (hf : approximates_linear_on f f' s c) :\n  continuous (s.restrict f) :=\nhf.lipschitz.continuous\n\nprotected lemma continuous_on (hf : approximates_linear_on f f' s c) :\n  continuous_on f s :=\ncontinuous_on_iff_continuous_restrict.2 hf.continuous\n\nend\n\nsection locally_onto\n/-!\nWe prove that a function which is linearly approximated by a continuous linear map with a nonlinear\nright inverse is locally onto. This will apply to the case where the approximating map is a linear\nequivalence, for the local inverse theorem, but also whenever the approximating map is onto,\nby Banach's open mapping theorem. -/\n\ninclude cs\n\nvariables {s : set E} {c : ℝ≥0} {f' : E →L[𝕜] F}\n\n/-- If a function is linearly approximated by a continuous linear map with a (possibly nonlinear)\nright inverse, then it is locally onto: a ball of an explicit radius is included in the image\nof the map. -/\ntheorem surj_on_closed_ball_of_nonlinear_right_inverse\n  (hf : approximates_linear_on f f' s c)  (f'symm : f'.nonlinear_right_inverse)\n  {ε : ℝ} {b : E} (ε0 : 0 ≤ ε) (hε : closed_ball b ε ⊆ s) :\n  surj_on f (closed_ball b ε) (closed_ball (f b) (((f'symm.nnnorm : ℝ)⁻¹ - c) * ε)) :=\nbegin\n  assume y hy,\n  cases le_or_lt (f'symm.nnnorm : ℝ) ⁻¹ c with hc hc,\n  { refine ⟨b, by simp [ε0], _⟩,\n    have : dist y (f b) ≤ 0 :=\n      (mem_closed_ball.1 hy).trans (mul_nonpos_of_nonpos_of_nonneg (by linarith) ε0),\n    simp only [dist_le_zero] at this,\n    rw this },\n  have If' : (0 : ℝ) < f'symm.nnnorm,\n    by { rw [← inv_pos], exact (nnreal.coe_nonneg _).trans_lt hc },\n  have Icf' : (c : ℝ) * f'symm.nnnorm < 1, by rwa [inv_eq_one_div, lt_div_iff If'] at hc,\n  have Jf' : (f'symm.nnnorm : ℝ) ≠ 0 := ne_of_gt If',\n  have Jcf' : (1 : ℝ) - c * f'symm.nnnorm ≠ 0, by { apply ne_of_gt, linarith },\n  /- We have to show that `y` can be written as `f x` for some `x ∈ closed_ball b ε`.\n  The idea of the proof is to apply the Banach contraction principle to the map\n  `g : x ↦ x + f'symm (y - f x)`, as a fixed point of this map satisfies `f x = y`.\n  When `f'symm` is a genuine linear inverse, `g` is a contracting map. In our case, since `f'symm`\n  is nonlinear, this map is not contracting (it is not even continuous), but still the proof of\n  the contraction theorem holds: `uₙ = gⁿ b` is a Cauchy sequence, converging exponentially fast\n  to the desired point `x`. Instead of appealing to general results, we check this by hand.\n\n  The main point is that `f (u n)` becomes exponentially close to `y`, and therefore\n  `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive\n  bound on `dist (u n) b`, from which one checks that `u n` stays in the ball on which one has a\n  control. Therefore, the bound can be checked at the next step, and so on inductively.\n  -/\n  set g := λ x, x + f'symm (y - f x) with hg,\n  set u := λ (n : ℕ), g ^[n] b with hu,\n  have usucc : ∀ n, u (n + 1) = g (u n), by simp [hu, ← iterate_succ_apply' g _ b],\n  -- First bound: if `f z` is close to `y`, then `g z` is close to `z` (i.e., almost a fixed point).\n  have A : ∀ z, dist (g z) z ≤ f'symm.nnnorm * dist (f z) y,\n  { assume z,\n    rw [dist_eq_norm, hg, add_sub_cancel', dist_eq_norm'],\n    exact f'symm.bound _ },\n  -- Second bound: if `z` and `g z` are in the set with good control, then `f (g z)` becomes closer\n  -- to `y` than `f z` was (this uses the linear approximation property, and is the reason for the\n  -- choice of the formula for `g`).\n  have B : ∀ z ∈ closed_ball b ε, g z ∈ closed_ball b ε →\n    dist (f (g z)) y ≤ c * f'symm.nnnorm * dist (f z) y,\n  { assume z hz hgz,\n    set v := f'symm (y - f z) with hv,\n    calc dist (f (g z)) y = ∥f (z + v) - y∥ : by rw [dist_eq_norm]\n    ... = ∥f (z + v) - f  z - f' v + f' v - (y - f z)∥ : by { congr' 1, abel }\n    ... = ∥f (z + v) - f z - f' ((z + v) - z)∥ :\n      by simp only [continuous_linear_map.nonlinear_right_inverse.right_inv,\n                    add_sub_cancel', sub_add_cancel]\n    ... ≤ c * ∥(z + v) - z∥ : hf _ (hε hgz) _ (hε hz)\n    ... ≤ c * (f'symm.nnnorm * dist (f z) y) : begin\n      apply mul_le_mul_of_nonneg_left _ (nnreal.coe_nonneg c),\n      simpa [hv, dist_eq_norm'] using f'symm.bound (y - f z),\n    end\n    ... = c * f'symm.nnnorm * dist (f z) y : by ring },\n  -- Third bound: a complicated bound on `dist w b` (that will show up in the induction) is enough\n  -- to check that `w` is in the ball on which one has controls. Will be used to check that `u n`\n  -- belongs to this ball for all `n`.\n  have C : ∀ (n : ℕ) (w : E),\n    dist w b ≤ f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y\n    → w ∈ closed_ball b ε,\n  { assume n w hw,\n    apply hw.trans,\n    rw [div_mul_eq_mul_div, div_le_iff], swap, { linarith },\n    calc (f'symm.nnnorm : ℝ) * (1 - (c * f'symm.nnnorm) ^ n) * dist (f b) y\n      = f'symm.nnnorm * dist (f b) y * (1 - (c * f'symm.nnnorm) ^ n) : by ring\n      ... ≤ f'symm.nnnorm * dist (f b) y * 1 :\n      begin\n        apply mul_le_mul_of_nonneg_left _ (mul_nonneg (nnreal.coe_nonneg _) dist_nonneg),\n        rw [sub_le_self_iff],\n        exact pow_nonneg (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _)) _,\n      end\n    ... ≤ f'symm.nnnorm * (((f'symm.nnnorm : ℝ)⁻¹ - c) * ε) :\n      by { rw [mul_one],\n           exact mul_le_mul_of_nonneg_left (mem_closed_ball'.1 hy) (nnreal.coe_nonneg _) }\n    ... = ε * (1 - c * f'symm.nnnorm) : by { field_simp, ring } },\n  /- Main inductive control: `f (u n)` becomes exponentially close to `y`, and therefore\n  `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive\n  bound on `dist (u n) b`, from which one checks that `u n` remains in the ball on which we\n  have estimates. -/\n  have D : ∀ (n : ℕ), dist (f (u n)) y ≤ (c * f'symm.nnnorm)^n * dist (f b) y\n    ∧ dist (u n) b ≤ f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm)\n      * dist (f b) y,\n  { assume n,\n    induction n with n IH, { simp [hu, le_refl] },\n    rw usucc,\n    have Ign : dist (g (u n)) b ≤\n      f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n.succ) / (1 - c * f'symm.nnnorm) * dist (f b) y :=\n    calc\n      dist (g (u n)) b ≤ dist (g (u n)) (u n) + dist (u n) b : dist_triangle _ _ _\n      ... ≤ f'symm.nnnorm * dist (f (u n)) y + dist (u n) b : add_le_add (A _) (le_refl _)\n      ... ≤ f'symm.nnnorm * ((c * f'symm.nnnorm)^n * dist (f b) y) +\n        f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y :\n          add_le_add (mul_le_mul_of_nonneg_left IH.1 (nnreal.coe_nonneg _)) IH.2\n      ... = f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n.succ) / (1 - c * f'symm.nnnorm)\n        * dist (f b) y : by { field_simp [Jcf'], ring_exp },\n    refine ⟨_, Ign⟩,\n    calc dist (f (g (u n))) y ≤ c * f'symm.nnnorm * dist (f (u n)) y :\n      B _ (C n _ IH.2) (C n.succ _ Ign)\n    ... ≤ (c * f'symm.nnnorm) * ((c * f'symm.nnnorm)^n * dist (f b) y) :\n      mul_le_mul_of_nonneg_left IH.1 (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _))\n    ... = (c * f'symm.nnnorm) ^ n.succ * dist (f b) y : by ring_exp },\n  -- Deduce from the inductive bound that `uₙ` is a Cauchy sequence, therefore converging.\n  have : cauchy_seq u,\n  { have : ∀ (n : ℕ), dist (u n) (u (n+1)) ≤ f'symm.nnnorm * dist (f b) y * (c * f'symm.nnnorm)^n,\n    { assume n,\n      calc dist (u n) (u (n+1)) = dist (g (u n)) (u n) :  by rw [usucc, dist_comm]\n      ... ≤ f'symm.nnnorm * dist (f (u n)) y : A _\n      ... ≤ f'symm.nnnorm * ((c * f'symm.nnnorm)^n * dist (f b) y) :\n        mul_le_mul_of_nonneg_left (D n).1 (nnreal.coe_nonneg _)\n      ... = f'symm.nnnorm * dist (f b) y * (c * f'symm.nnnorm)^n : by ring },\n    exact cauchy_seq_of_le_geometric _ _ Icf' this },\n  obtain ⟨x, hx⟩ : ∃ x, tendsto u at_top (𝓝 x) := cauchy_seq_tendsto_of_complete this,\n  -- As all the `uₙ` belong to the ball `closed_ball b ε`, so does their limit `x`.\n  have xmem : x ∈ closed_ball b ε :=\n    is_closed_ball.mem_of_tendsto hx (eventually_of_forall (λ n, C n _ (D n).2)),\n  refine ⟨x, xmem, _⟩,\n  -- It remains to check that `f x = y`. This follows from continuity of `f` on `closed_ball b ε`\n  -- and from the fact that `f uₙ` is converging to `y` by construction.\n  have hx' : tendsto u at_top (𝓝[closed_ball b ε] x),\n  { simp only [nhds_within, tendsto_inf, hx, true_and, ge_iff_le, tendsto_principal],\n    exact eventually_of_forall (λ n, C n _ (D n).2) },\n  have T1 : tendsto (λ n, f (u n)) at_top (𝓝 (f x)) :=\n    (hf.continuous_on.mono hε x xmem).tendsto.comp hx',\n  have T2 : tendsto (λ n, f (u n)) at_top (𝓝 y),\n  { rw tendsto_iff_dist_tendsto_zero,\n    refine squeeze_zero (λ n, dist_nonneg) (λ n, (D n).1) _,\n    simpa using (tendsto_pow_at_top_nhds_0_of_lt_1\n      (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _)) Icf').mul tendsto_const_nhds },\n  exact tendsto_nhds_unique T1 T2,\nend\n\nlemma open_image (hf : approximates_linear_on f f' s c)  (f'symm : f'.nonlinear_right_inverse)\n  (hs : is_open s) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) : is_open (f '' s) :=\nbegin\n  cases hc with hE hc, { resetI, apply is_open_discrete },\n  simp only [is_open_iff_mem_nhds, nhds_basis_closed_ball.mem_iff, ball_image_iff] at hs ⊢,\n  intros x hx,\n  rcases hs x hx with ⟨ε, ε0, hε⟩,\n  refine ⟨(f'symm.nnnorm⁻¹ - c) * ε, mul_pos (sub_pos.2 hc) ε0, _⟩,\n  exact (hf.surj_on_closed_ball_of_nonlinear_right_inverse f'symm (le_of_lt ε0) hε).mono\n    hε (subset.refl _)\nend\n\nlemma image_mem_nhds (hf : approximates_linear_on f f' s c) (f'symm : f'.nonlinear_right_inverse)\n  {x : E} (hs : s ∈ 𝓝 x) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) :\n  f '' s ∈ 𝓝 (f x) :=\nbegin\n  obtain ⟨t, hts, ht, xt⟩ : ∃ t ⊆ s, is_open t ∧ x ∈ t := mem_nhds_sets_iff.1 hs,\n  have := mem_nhds_sets ((hf.mono_set hts).open_image f'symm ht hc) (mem_image_of_mem _ xt),\n  exact mem_sets_of_superset this (image_subset _ hts),\nend\n\nlemma map_nhds_eq (hf : approximates_linear_on f f' s c) (f'symm : f'.nonlinear_right_inverse)\n  {x : E} (hs : s ∈ 𝓝 x) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) :\n  map f (𝓝 x) = 𝓝 (f x) :=\nbegin\n  refine le_antisymm ((hf.continuous_on x (mem_of_nhds hs)).continuous_at hs) (le_map (λ t ht, _)),\n  have : f '' (s ∩ t) ∈ 𝓝 (f x) := (hf.mono_set (inter_subset_left s t)).image_mem_nhds\n    f'symm (inter_mem_sets hs ht) hc,\n  exact mem_sets_of_superset this (image_subset _ (inter_subset_right _ _)),\nend\n\nend locally_onto\n\n/-!\nFrom now on we assume that `f` approximates an invertible continuous linear map `f : E ≃L[𝕜] F`.\n\nWe also assume that either `E = {0}`, or `c < ∥f'⁻¹∥⁻¹`. We use `N` as an abbreviation for `∥f'⁻¹∥`.\n-/\n\nvariables {f' : E ≃L[𝕜] F} {s : set E} {c : ℝ≥0}\n\nlocal notation `N` := nnnorm (f'.symm : F →L[𝕜] E)\n\nprotected lemma antilipschitz (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  antilipschitz_with (N⁻¹ - c)⁻¹ (s.restrict f) :=\nbegin\n  cases hc with hE hc,\n  { haveI : subsingleton s := ⟨λ x y, subtype.eq $ @subsingleton.elim _ hE _ _⟩,\n    exact antilipschitz_with.of_subsingleton },\n  convert (f'.antilipschitz.restrict s).add_lipschitz_with hf.lipschitz_sub hc,\n  simp [restrict]\nend\n\nprotected lemma injective (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  injective (s.restrict f) :=\n(hf.antilipschitz hc).injective\n\nprotected lemma inj_on (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  inj_on f s :=\ninj_on_iff_injective.2 $ hf.injective hc\n\n/-- A map approximating a linear equivalence on a set defines a local equivalence on this set.\nShould not be used outside of this file, because it is superseded by `to_local_homeomorph` below.\n\nThis is a first step towards the inverse function. -/\ndef to_local_equiv (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) : local_equiv E F :=\n(hf.inj_on hc).to_local_equiv _ _\n\n/-- The inverse function is continuous on `f '' s`. Use properties of `local_homeomorph` instead. -/\nlemma inverse_continuous_on (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  continuous_on (hf.to_local_equiv hc).symm (f '' s) :=\nbegin\n  apply continuous_on_iff_continuous_restrict.2,\n  refine ((hf.antilipschitz hc).to_right_inv_on' _ (hf.to_local_equiv hc).right_inv').continuous,\n  exact (λ x hx, (hf.to_local_equiv hc).map_target hx)\nend\n\ninclude cs\n\nsection\nvariables (f s)\n\n/-- Given a function `f` that approximates a linear equivalence on an open set `s`,\nreturns a local homeomorph with `to_fun = f` and `source = s`. -/\ndef to_local_homeomorph (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) : local_homeomorph E F :=\n{ to_local_equiv := hf.to_local_equiv hc,\n  open_source := hs,\n  open_target := hf.open_image f'.to_nonlinear_right_inverse hs\n    (by rwa f'.to_linear_equiv.to_equiv.subsingleton_iff at hc),\n  continuous_to_fun := hf.continuous_on,\n  continuous_inv_fun := hf.inverse_continuous_on hc }\n\nend\n\n@[simp] lemma to_local_homeomorph_coe (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs : E → F) = f := rfl\n\n@[simp] lemma to_local_homeomorph_source (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs).source = s := rfl\n\n@[simp] lemma to_local_homeomorph_target (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs).target = f '' s := rfl\n\nlemma closed_ball_subset_target (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) {b : E} (ε0 : 0 ≤ ε) (hε : closed_ball b ε ⊆ s) :\n  closed_ball (f b) ((N⁻¹ - c) * ε) ⊆ (hf.to_local_homeomorph f s hc hs).target :=\n(hf.surj_on_closed_ball_of_nonlinear_right_inverse f'.to_nonlinear_right_inverse\n  ε0 hε).mono hε (subset.refl _)\n\nend approximates_linear_on\n\n/-!\n### Inverse function theorem\n\nNow we prove the inverse function theorem. Let `f : E → F` be a map defined on a complete vector\nspace `E`. Assume that `f` has an invertible derivative `f' : E ≃L[𝕜] F` at `a : E` in the strict\nsense. Then `f` approximates `f'` in the sense of `approximates_linear_on` on an open neighborhood\nof `a`, and we can apply `approximates_linear_on.to_local_homeomorph` to construct the inverse\nfunction. -/\n\nnamespace has_strict_fderiv_at\n\n/-- If `f` has derivative `f'` at `a` in the strict sense and `c > 0`, then `f` approximates `f'`\nwith constant `c` on some neighborhood of `a`. -/\nlemma approximates_deriv_on_nhds {f : E → F} {f' : E →L[𝕜] F} {a : E}\n  (hf : has_strict_fderiv_at f f' a) {c : ℝ≥0} (hc : subsingleton E ∨ 0 < c) :\n  ∃ s ∈ 𝓝 a, approximates_linear_on f f' s c :=\nbegin\n  cases hc with hE hc,\n  { refine ⟨univ, mem_nhds_sets is_open_univ trivial, λ x hx y hy, _⟩,\n    simp [@subsingleton.elim E hE x y] },\n  have := hf.def hc,\n  rw [nhds_prod_eq, filter.eventually, mem_prod_same_iff] at this,\n  rcases this with ⟨s, has, hs⟩,\n  exact ⟨s, has, λ x hx y hy, hs (mk_mem_prod hx hy)⟩\nend\n\nlemma map_nhds_eq_of_surj [complete_space E] [complete_space F]\n  {f : E → F} {f' : E →L[𝕜] F} {a : E}\n  (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) (h : f'.range = ⊤) :\n  map f (𝓝 a) = 𝓝 (f a) :=\nbegin\n  let f'symm := f'.nonlinear_right_inverse_of_surjective h,\n  set c : ℝ≥0 := f'symm.nnnorm⁻¹ / 2 with hc,\n  have f'symm_pos : 0 < f'symm.nnnorm := f'.nonlinear_right_inverse_of_surjective_nnnorm_pos h,\n  have cpos : 0 < c, by simp [hc, nnreal.half_pos, nnreal.inv_pos, f'symm_pos],\n  obtain ⟨s, s_nhds, hs⟩ : ∃ s ∈ 𝓝 a, approximates_linear_on f f' s c :=\n    hf.approximates_deriv_on_nhds (or.inr cpos),\n  apply hs.map_nhds_eq f'symm s_nhds (or.inr (nnreal.half_lt_self _)),\n  simp [ne_of_gt f'symm_pos],\nend\n\nvariables [cs : complete_space E] {f : E → F} {f' : E ≃L[𝕜] F} {a : E}\n\nlemma approximates_deriv_on_open_nhds (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∃ (s : set E) (hs : a ∈ s ∧ is_open s),\n    approximates_linear_on f (f' : E →L[𝕜] F) s ((nnnorm (f'.symm : F →L[𝕜] E))⁻¹ / 2) :=\nbegin\n  refine ((nhds_basis_opens a).exists_iff _).1 _,\n  exact (λ s t, approximates_linear_on.mono_set),\n  exact (hf.approximates_deriv_on_nhds $ f'.subsingleton_or_nnnorm_symm_pos.imp id $\n    λ hf', nnreal.half_pos $ nnreal.inv_pos.2 $ hf')\nend\n\ninclude cs\n\nvariable (f)\n\n/-- Given a function with an invertible strict derivative at `a`, returns a `local_homeomorph`\nwith `to_fun = f` and `a ∈ source`. This is a part of the inverse function theorem.\nThe other part `has_strict_fderiv_at.to_local_inverse` states that the inverse function\nof this `local_homeomorph` has derivative `f'.symm`. -/\ndef to_local_homeomorph (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) : local_homeomorph E F :=\napproximates_linear_on.to_local_homeomorph f\n  (classical.some hf.approximates_deriv_on_open_nhds)\n  (classical.some_spec hf.approximates_deriv_on_open_nhds).snd\n  (f'.subsingleton_or_nnnorm_symm_pos.imp id $ λ hf', nnreal.half_lt_self $ ne_of_gt $\n    nnreal.inv_pos.2 $ hf')\n  (classical.some_spec hf.approximates_deriv_on_open_nhds).fst.2\n\nvariable {f}\n\n@[simp] lemma to_local_homeomorph_coe (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  (hf.to_local_homeomorph f : E → F) = f := rfl\n\nlemma mem_to_local_homeomorph_source (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  a ∈ (hf.to_local_homeomorph f).source :=\n(classical.some_spec hf.approximates_deriv_on_open_nhds).fst.1\n\nlemma image_mem_to_local_homeomorph_target (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  f a ∈ (hf.to_local_homeomorph f).target :=\n(hf.to_local_homeomorph f).map_source hf.mem_to_local_homeomorph_source\n\nlemma map_nhds_eq_of_equiv (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  map f (𝓝 a) = 𝓝 (f a) :=\n(hf.to_local_homeomorph f).map_nhds_eq hf.mem_to_local_homeomorph_source\n\nvariables (f f' a)\n\n/-- Given a function `f` with an invertible derivative, returns a function that is locally inverse\nto `f`. -/\ndef local_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) : F → E :=\n(hf.to_local_homeomorph f).symm\n\nvariables {f f' a}\n\nlemma local_inverse_def (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  hf.local_inverse f _ _ = (hf.to_local_homeomorph f).symm :=\nrfl\n\nlemma eventually_left_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∀ᶠ x in 𝓝 a, hf.local_inverse f f' a (f x) = x :=\n(hf.to_local_homeomorph f).eventually_left_inverse hf.mem_to_local_homeomorph_source\n\n@[simp] \n\nlemma eventually_right_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∀ᶠ y in 𝓝 (f a), f (hf.local_inverse f f' a y) = y :=\n(hf.to_local_homeomorph f).eventually_right_inverse' hf.mem_to_local_homeomorph_source\n\nlemma local_inverse_continuous_at (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  continuous_at (hf.local_inverse f f' a) (f a) :=\n(hf.to_local_homeomorph f).continuous_at_symm hf.image_mem_to_local_homeomorph_target\n\nlemma local_inverse_tendsto (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  tendsto (hf.local_inverse f f' a) (𝓝 $ f a) (𝓝 a) :=\n(hf.to_local_homeomorph f).tendsto_symm hf.mem_to_local_homeomorph_source\n\nlemma local_inverse_unique (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) {g : F → E}\n  (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  ∀ᶠ y in 𝓝 (f a), g y = local_inverse f f' a hf y :=\neventually_eq_of_left_inv_of_right_inv hg hf.eventually_right_inverse $\n  (hf.to_local_homeomorph f).tendsto_symm hf.mem_to_local_homeomorph_source\n\n/-- If `f` has an invertible derivative `f'` at `a` in the sense of strict differentiability `(hf)`,\nthen the inverse function `hf.local_inverse f` has derivative `f'.symm` at `f a`. -/\ntheorem to_local_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  has_strict_fderiv_at (hf.local_inverse f f' a) (f'.symm : F →L[𝕜] E) (f a) :=\n(hf.to_local_homeomorph f).has_strict_fderiv_at_symm hf.image_mem_to_local_homeomorph_target $\n  by simpa [← local_inverse_def] using hf\n\n/-- If `f : E → F` has an invertible derivative `f'` at `a` in the sense of strict differentiability\nand `g (f x) = x` in a neighborhood of `a`, then `g` has derivative `f'.symm` at `f a`.\n\nFor a version assuming `f (g y) = y` and continuity of `g` at `f a` but not `[complete_space E]`\nsee `of_local_left_inverse`.  -/\ntheorem to_local_left_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) {g : F → E}\n  (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  has_strict_fderiv_at g (f'.symm : F →L[𝕜] E) (f a) :=\nhf.to_local_inverse.congr_of_eventually_eq $ (hf.local_inverse_unique hg).mono $ λ _, eq.symm\n\nend has_strict_fderiv_at\n\n/-- If a function has an invertible strict derivative at all points, then it is an open map. -/\nlemma open_map_of_strict_fderiv_equiv [complete_space E] {f : E → F} {f' : E → E ≃L[𝕜] F}\n  (hf : ∀ x, has_strict_fderiv_at f (f' x : E →L[𝕜] F) x) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ λ x, (hf x).map_nhds_eq_of_equiv.ge\n\n/-!\n### Inverse function theorem, 1D case\n\nIn this case we prove a version of the inverse function theorem for maps `f : 𝕜 → 𝕜`.\nWe use `continuous_linear_equiv.units_equiv_aut` to translate `has_strict_deriv_at f f' a` and\n`f' ≠ 0` into `has_strict_fderiv_at f (_ : 𝕜 ≃L[𝕜] 𝕜) a`.\n-/\n\nnamespace has_strict_deriv_at\n\nvariables [cs : complete_space 𝕜] {f : 𝕜 → 𝕜} {f' a : 𝕜} (hf : has_strict_deriv_at f f' a)\n  (hf' : f' ≠ 0)\n\ninclude cs\n\nvariables (f f' a)\n\n/-- A function that is inverse to `f` near `a`. -/\n@[reducible] def local_inverse : 𝕜 → 𝕜 :=\n(hf.has_strict_fderiv_at_equiv hf').local_inverse _ _ _\n\nvariables {f f' a}\n\nlemma map_nhds_eq : map f (𝓝 a) = 𝓝 (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').map_nhds_eq_of_equiv\n\ntheorem to_local_inverse : has_strict_deriv_at (hf.local_inverse f f' a hf') f'⁻¹ (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_inverse\n\ntheorem to_local_left_inverse {g : 𝕜 → 𝕜} (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  has_strict_deriv_at g f'⁻¹ (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_left_inverse hg\n\nend has_strict_deriv_at\n\n/-- If a function has a non-zero strict derivative at all points, then it is an open map. -/\nlemma open_map_of_strict_deriv [complete_space 𝕜] {f f' : 𝕜 → 𝕜}\n  (hf : ∀ x, has_strict_deriv_at f (f' x) x) (h0 : ∀ x, f' x ≠ 0) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ λ x, ((hf x).map_nhds_eq (h0 x)).ge\n\n/-!\n### Inverse function theorem, smooth case\n\n-/\n\nnamespace times_cont_diff_at\nvariables {𝕂 : Type*} [is_R_or_C 𝕂]\nvariables {E' : Type*} [normed_group E'] [normed_space 𝕂 E']\nvariables {F' : Type*} [normed_group F'] [normed_space 𝕂 F']\nvariables [complete_space E'] (f : E' → F') {f' : E' ≃L[𝕂] F'} {a : E'}\n\n/-- Given a `times_cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible\nderivative at `a`, returns a `local_homeomorph` with `to_fun = f` and `a ∈ source`. -/\ndef to_local_homeomorph\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  local_homeomorph E' F' :=\n(hf.has_strict_fderiv_at' hf' hn).to_local_homeomorph f\n\nvariable {f}\n\n@[simp] lemma to_local_homeomorph_coe\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  (hf.to_local_homeomorph f hf' hn : E' → F') = f := rfl\n\nlemma mem_to_local_homeomorph_source\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  a ∈ (hf.to_local_homeomorph f hf' hn).source :=\n(hf.has_strict_fderiv_at' hf' hn).mem_to_local_homeomorph_source\n\nlemma image_mem_to_local_homeomorph_target\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  f a ∈ (hf.to_local_homeomorph f hf' hn).target :=\n(hf.has_strict_fderiv_at' hf' hn).image_mem_to_local_homeomorph_target\n\n/-- Given a `times_cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible derivative\nat `a`, returns a function that is locally inverse to `f`. -/\ndef local_inverse\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  F' → E' :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse f f' a\n\nlemma local_inverse_apply_image\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  hf.local_inverse hf' hn (f a) = a :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse_apply_image\n\n/-- Given a `times_cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible derivative\nat `a`, the inverse function (produced by `times_cont_diff.to_local_homeomorph`) is\nalso `times_cont_diff`. -/\nlemma to_local_inverse\n  {n : with_top ℕ} (hf : times_cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  times_cont_diff_at 𝕂 n (hf.local_inverse hf' hn) (f a) :=\nbegin\n  have := hf.local_inverse_apply_image hf' hn,\n  apply (hf.to_local_homeomorph f hf' hn).times_cont_diff_at_symm\n    (image_mem_to_local_homeomorph_target hf hf' hn),\n  { convert hf' },\n  { convert hf }\nend\n\nend times_cont_diff_at\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/analysis/calculus/inverse.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.4844025405500081}}
{"text": "import hilbert.wr.ka_bot\nimport hilbert.wr.proofs.ka\n\nnamespace clfrags\n    namespace hilbert\n        namespace wr\n            namespace ka_bot\n\n                theorem  kab₁_ka {a b c d e : Prop} (h₁ : ka d e (ka a b bot)) : ka d e (ka a b c) :=\n                    have h₂ : ka d e (ka d b bot), from ka.ka₇ h₁,\n                    have h₃ : ka d (ka d e b) bot, from ka.ka₄ h₂,\n                    have h₄ : ka d (ka d e b) c, from kab₁ h₃,\n                    have h₅ : ka d e a, from ka.ka₆ h₁,\n                    have h₆ : ka d e (ka d b c), from ka.ka₄' h₄,\n                    show ka d e (ka a b c), from ka.ka₅ h₅ h₆\n\n                theorem  b₁ {a : Prop} (h₁ : bot) : a :=\n                    have h₂ : ka bot bot bot, from ka.ka₁ h₁ h₁,\n                    have h₃ : ka bot bot a, from kab₁ h₂,\n                    have h₄ : ka bot a bot, from ka.ka₃ h₃,\n                    have h₅ : ka bot a a, from kab₁ h₄,\n                    show a, from ka.ka₂ h₅\n\n            end ka_bot\n        end wr\n    end hilbert\nend clfrags\n\n", "meta": {"author": "greati", "repo": "hilbert-classical-fragments", "sha": "18a21ac6b2e890060eb4ae65752fc0245394d226", "save_path": "github-repos/lean/greati-hilbert-classical-fragments", "path": "github-repos/lean/greati-hilbert-classical-fragments/hilbert-classical-fragments-18a21ac6b2e890060eb4ae65752fc0245394d226/clfrags/src/hilbert/wr/proofs/ka_bot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711832583696, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4843583324054103}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.logic.function.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Semiconjugate and commuting maps\n\nWe define the following predicates:\n\n* `function.semiconj`: `f : α → β` semiconjugates `ga : α → α` to `gb : β → β` if `f ∘ ga = gb ∘ f`;\n* `function.semiconj₂: `f : α → β` semiconjugates a binary operation `ga : α → α → α`\n  to `gb : β → β → β` if `f (ga x y) = gb (f x) (f y)`;\n* `f : α → α` commutes with `g : α → α` if `f ∘ g = g ∘ f`, or equivalently `semiconj f g g`.\n\n-/\n\nnamespace function\n\n\n/-- We say that `f : α → β` semiconjugates `ga : α → α` to `gb : β → β` if `f ∘ ga = gb ∘ f`. -/\ndef semiconj {α : Type u_1} {β : Type u_2} (f : α → β) (ga : α → α) (gb : β → β) :=\n  ∀ (x : α), f (ga x) = gb (f x)\n\nnamespace semiconj\n\n\nprotected theorem comp_eq {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α} {gb : β → β}\n    (h : semiconj f ga gb) : f ∘ ga = gb ∘ f :=\n  funext h\n\nprotected theorem eq {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α} {gb : β → β}\n    (h : semiconj f ga gb) (x : α) : f (ga x) = gb (f x) :=\n  h x\n\ntheorem comp_right {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α} {ga' : α → α} {gb : β → β}\n    {gb' : β → β} (h : semiconj f ga gb) (h' : semiconj f ga' gb') :\n    semiconj f (ga ∘ ga') (gb ∘ gb') :=\n  sorry\n\ntheorem comp_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} {fab : α → β} {fbc : β → γ}\n    {ga : α → α} {gb : β → β} {gc : γ → γ} (hab : semiconj fab ga gb) (hbc : semiconj fbc gb gc) :\n    semiconj (fbc ∘ fab) ga gc :=\n  sorry\n\ntheorem id_right {α : Type u_1} {β : Type u_2} {f : α → β} : semiconj f id id := fun (_x : α) => rfl\n\ntheorem id_left {α : Type u_1} {ga : α → α} : semiconj id ga ga := fun (_x : α) => rfl\n\ntheorem inverses_right {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α} {ga' : α → α}\n    {gb : β → β} {gb' : β → β} (h : semiconj f ga gb) (ha : right_inverse ga' ga)\n    (hb : left_inverse gb' gb) : semiconj f ga' gb' :=\n  sorry\n\nend semiconj\n\n\n/-- Two maps `f g : α → α` commute if `f ∘ g = g ∘ f`. -/\ndef commute {α : Type u_1} (f : α → α) (g : α → α) := semiconj f g g\n\ntheorem semiconj.commute {α : Type u_1} {f : α → α} {g : α → α} (h : semiconj f g g) :\n    commute f g :=\n  h\n\nnamespace commute\n\n\ntheorem refl {α : Type u_1} (f : α → α) : commute f f := fun (_x : α) => Eq.refl (f (f _x))\n\ntheorem symm {α : Type u_1} {f : α → α} {g : α → α} (h : commute f g) : commute g f :=\n  fun (x : α) => Eq.symm (h x)\n\ntheorem comp_right {α : Type u_1} {f : α → α} {g : α → α} {g' : α → α} (h : commute f g)\n    (h' : commute f g') : commute f (g ∘ g') :=\n  semiconj.comp_right h h'\n\ntheorem comp_left {α : Type u_1} {f : α → α} {f' : α → α} {g : α → α} (h : commute f g)\n    (h' : commute f' g) : commute (f ∘ f') g :=\n  symm (comp_right (symm h) (symm h'))\n\ntheorem id_right {α : Type u_1} {f : α → α} : commute f id := semiconj.id_right\n\ntheorem id_left {α : Type u_1} {f : α → α} : commute id f := semiconj.id_left\n\nend commute\n\n\n/-- A map `f` semiconjugates a binary operation `ga` to a binary operation `gb` if\nfor all `x`, `y` we have `f (ga x y) = gb (f x) (f y)`. E.g., a `monoid_hom`\nsemiconjugates `(*)` to `(*)`. -/\ndef semiconj₂ {α : Type u_1} {β : Type u_2} (f : α → β) (ga : α → α → α) (gb : β → β → β) :=\n  ∀ (x y : α), f (ga x y) = gb (f x) (f y)\n\nnamespace semiconj₂\n\n\nprotected theorem eq {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α → α} {gb : β → β → β}\n    (h : semiconj₂ f ga gb) (x : α) (y : α) : f (ga x y) = gb (f x) (f y) :=\n  h x y\n\nprotected theorem comp_eq {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α → α}\n    {gb : β → β → β} (h : semiconj₂ f ga gb) : bicompr f ga = bicompl gb f f :=\n  funext fun (x : α) => funext (h x)\n\ntheorem id_left {α : Type u_1} (op : α → α → α) : semiconj₂ id op op := fun (_x _x_1 : α) => rfl\n\ntheorem comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α → β} {ga : α → α → α}\n    {gb : β → β → β} {f' : β → γ} {gc : γ → γ → γ} (hf' : semiconj₂ f' gb gc)\n    (hf : semiconj₂ f ga gb) : semiconj₂ (f' ∘ f) ga gc :=\n  sorry\n\ntheorem is_associative_right {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α → α}\n    {gb : β → β → β} [is_associative α ga] (h : semiconj₂ f ga gb) (h_surj : surjective f) :\n    is_associative β gb :=\n  sorry\n\ntheorem is_associative_left {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α → α}\n    {gb : β → β → β} [is_associative β gb] (h : semiconj₂ f ga gb) (h_inj : injective f) :\n    is_associative α ga :=\n  sorry\n\ntheorem is_idempotent_right {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α → α}\n    {gb : β → β → β} [is_idempotent α ga] (h : semiconj₂ f ga gb) (h_surj : surjective f) :\n    is_idempotent β gb :=\n  sorry\n\ntheorem is_idempotent_left {α : Type u_1} {β : Type u_2} {f : α → β} {ga : α → α → α}\n    {gb : β → β → β} [is_idempotent β gb] (h : semiconj₂ f ga gb) (h_inj : injective f) :\n    is_idempotent α ga :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/logic/function/conjugate_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.4843579814056898}}
{"text": "namespace hidden\n\ninductive nat\n| zero : nat\n| succ : nat → nat\n| pred : nat → nat\n\nnotation 0 := nat.zero\nnotation `S` := nat.succ\nnotation `P` := nat.pred\nnotation 1 := S 0\naxiom succ_pred : ∀ n : nat, S (P n) = n\n\nexample : S (P 0) = 0 := succ_pred _ -- <=> succ_pred 0\n\nlemma pred_succ_zero : P (S 0) = 0 :=\nbegin\n  have h := λ(n m : nat)(f : nat → nat), n = m → f n = f m,\n  type_check (h 0 0 (λ n, S n)), -- Prop\n  have h2 : ∀ (n m : nat)(f : nat → nat), n = m → f n = f m := sorry,\n  type_check h2 0 1 (λ n, n),\n\n  have h3 := h2 0 0 (λ n, n),\n  simp at h3,\n  clear h3,\nend\n\nend hidden\n\nexample : true := true.intro\n\nlemma test : (1 : hidden.nat) = 1 ∧ 2 = 2 :=\nbegin\n  -- apply and.intro,\n  -- exact eq.refl 1,\n  -- exact eq.refl 2,\n\n  -- apply ⟨eq.refl _, _⟩, -- invalid constructor ⟨...⟩\n  refine ⟨eq.refl _, _⟩, -- 1 goal ⊢ 2 = 2\n   -- rfl <=> eq.refl _, but with imlicit types: @rfl type value\n  exact @rfl nat 2,\nend\n\n#print test\n\n#check nat.succ\n\n\n", "meta": {"author": "mathprocessing", "repo": "lean_mathlib_examples", "sha": "743c6456c0a3219dd1722efdd31ee6f3a113818a", "save_path": "github-repos/lean/mathprocessing-lean_mathlib_examples", "path": "github-repos/lean/mathprocessing-lean_mathlib_examples/lean_mathlib_examples-743c6456c0a3219dd1722efdd31ee6f3a113818a/src/tactics/second_tactics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.48434721505187484}}
{"text": "import .basic\n\nnamespace hidden\n\n-- Can't extend field and ordered_myring as they both extend myring >:(\nclass ordered_myfield (α : Type) extends myfield α, has_le α:=\n-- NOTE: Theses are the ordered_myring axioms\n(f_decidable_le: ∀ a b: α, decidable (a ≤ b))\n(f_le_add_right (a b c : α) : a ≤ b → a + c ≤ b + c)\n(f_zero_le_mul (a b : α) : 0 ≤ a → 0 ≤ b → 0 ≤ a * b)\n(f_le_trans (a b c: α): a ≤ b → b ≤ c → a ≤ c)\n(f_le_total_order (a b: α): a ≤ b ∨ b ≤ a)\n(f_le_antisymm (a b: α): a ≤ b → b ≤ a → a = b)\n\nnamespace ordered_myfield\n\nopen myfield\nopen myring\nopen ordered_myring\n\nvariables {α : Type} [ordered_myfield α] (x y z : α)\n\n-- This is peak L∃∀N\ninstance : ordered_integral_domain α := {\n  oid_decidable_le := f_decidable_le,\n  oid_le_add_right := f_le_add_right,\n  oid_zero_le_mul := f_zero_le_mul,\n  oid_le_trans := f_le_trans,\n  oid_le_total_order := f_le_total_order,\n  oid_le_antisymm := f_le_antisymm\n}\n\ntheorem half_pos {ε : α} : 0 < ε → 0 < ε / 2 := sorry\n-- assume h, by rwa [lt_mul_pos_right zero_lt_two, zero_mul, div_mul_cancel two_nzero]\n\ntheorem pos_impl_inv_pos {x : α} : 0 < x → 0 < x⁻¹ := sorry\n\ntheorem exists_between (a c : α) :\na < c → ∃ b : α, a < b ∧ b < c :=\nbegin\n  assume hac,\n  existsi (a + c) * (2 : α)⁻¹,\n  split; rw add_mul, {\n    conv {\n      to_lhs,\n      rw ←mul_one a,\n    },\n    rw lt_add_cancel_left _ _ (a * -2⁻¹),\n    -- WTF is going on here?\n    sorry,\n    -- rw [lt_add_left (-(a/2)), ←add_assoc, add_comm _ a, neg_self_add],\n    -- conv {\n    --   to_lhs,\n    --   congr,\n    --     rw ←@half_plus_half a, skip,\n    --   skip,\n    -- },\n    -- rw [add_assoc, self_neg_add, add_zero, zero_add],\n    -- rwa [lt_mul_pos_right zero_lt_two, div_mul_cancel two_nzero,\n    --      div_mul_cancel two_nzero],\n  }, {\n    sorry,\n    -- rw [lt_add_right (-(c / 2)), add_assoc, self_neg_add],\n    -- conv {\n    --   to_rhs,\n    --   congr,\n    --     rw ←@half_plus_half c, skip,\n    --   skip,\n    -- },\n    -- rw [add_assoc, self_neg_add, add_zero, add_zero],\n    -- rwa [lt_mul_pos_right zero_lt_two, div_mul_cancel two_nzero,\n    --      div_mul_cancel two_nzero],\n  },\nend\n\n-- theorem lt_mul_comb_nonneg (a b x y : α): 0 ≤ a → 0 ≤ x → a < b → x < y → a * x < b * y :=\n-- begin\n--   assume h0a h0x hab hxy haxby,\n--   have := le_mul_comb_nonneg _ _ _ _ h0a h0x\n--     (lt_impl_le _ _ hab) (lt_impl_le _ _ hxy),\n--   have has := le_antisymm _ _ haxby this,\n--   clear haxby this,\n--   have h1: x * (b - a) + b * (y - x) = 0, {\n--     repeat {rw mul_sub},\n--     rw has,\n--     repeat {rw mul_comm _ x},\n--     rw add_comm,\n--     change x * a + -(x * b) + (x * b + -(x * a)) = 0,\n--     rw add_assoc,\n--     rw add_comm,\n--     repeat {rw add_assoc},\n--     rw neg_add,\n--     rw add_zero,\n--     rw neg_add,\n--   },\n--   have h2: 0 ≤ x * (b - a), {\n--     rw lt_iff_diff_pos at hab,\n--     have := le_mul_comb_nonneg _ _ _ _ (le_refl _) (le_refl _) h0x\n--       (lt_impl_le _ _ hab),\n--     rw zero_mul at this,\n--     assumption,\n--   },\n--   have h3: 0 < b * (y - x), {\n--     rw lt_iff_diff_pos at hxy,\n--     from zero_lt_mul _ _ (le_lt_chain _ h0a hab) hxy,\n--   },\n--   have := lt_le_comb h3 h2,\n--   rw add_zero at this,\n--   rw add_comm at this,\n--   rw h1 at this,\n--   from lt_nrefl _ this,\n-- end\n\n-- private lemma inv_pos: 0 < a → 0 < a⁻¹ :=\n-- begin\n--   assume h0x,\n--   assume hxi0,\n--   by_cases h: 0 ≤ a⁻¹, {\n--     have := le_antisymm hxi0 h,\n--     have hx0: a = 0, {\n--       rw ←@inv_inv a,\n--       rw this,\n--       refl,\n--     },\n--     subst hx0,\n--     from lt_nrefl _ h0x,\n--   }, {\n--     rw ←lt_iff_nle at h,\n--     rw lt_neg_switch at h,\n--     rw neg_zero at h,\n--     have := zero_lt_mul _ _ h0x h,\n--     rw mul_with_neg at this,\n--     rw mul_comm at this,\n--     rw inv_self_mul at this,\n--     rw lt_neg_switch at this,\n--     rw neg_zero at this,\n--     rw neg_neg at this,\n--     from this zero_le_one,\n--     assume hc,\n--     from lt_impl_ne h0x hc.symm,\n--  },\n-- end\n\n-- theorem pos_iff_inv_pos : 0 < a ↔ 0 < a⁻¹ :=\n-- begin\n--   split, {\n--     from inv_pos a,\n--   }, {\n--     have := inv_pos a⁻¹,\n--     rw inv_inv at this,\n--     assumption,\n--   },\n-- end\n\nend ordered_myfield\n\nend hidden", "meta": {"author": "Sterrs", "repo": "leaning", "sha": "3901cc953694b33adda86cb88ca30ba99594db31", "save_path": "github-repos/lean/Sterrs-leaning", "path": "github-repos/lean/Sterrs-leaning/leaning-3901cc953694b33adda86cb88ca30ba99594db31/src/principia/myfield/order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4843472083853727}}
{"text": "import inner_product_spaces.real_ip.ip_normed_space\n\nset_option class.instance_max_depth 100\n\nnoncomputable theory\n\nopen real linear_map\n\nsection cartesian_prod\n\nvariables {α : Type*} {β : Type*}\nvariables [decidable_eq α] [add_comm_group α] [vector_space ℝ α] [ℝ_inner_product_space α]\nvariables [decidable_eq β] [add_comm_group β] [vector_space ℝ β] [ℝ_inner_product_space β]\n\n@[reducible] def prod_inner_product (x y : α×β) : ℝ := ⟪x.1 ∥ y.1⟫ + ⟪x.2 ∥ y.2⟫\n\n@[reducible] instance prod_has_inner_product : has_ℝ_inner_product (α×β) := ⟨prod_inner_product⟩\n\nlemma prod_conj_symm (x y : α × β) : ⟪x ∥ y⟫ = ⟪y ∥ x⟫ :=\nby {dsimp [inner_product, prod_inner_product],\n    rw [conj_symm x.fst, conj_symm x.snd]}\n\nlemma prod_linearity (x y z : α × β) (a : ℝ) : ⟪a • x + y ∥ z⟫ = a * ⟪x ∥ z⟫ + ⟪y ∥ z⟫ :=\nbegin\n    dsimp [inner_product, prod_inner_product],\n    simp [-add_comm, add_comm],\n    simp,\n    rw [left_distrib],\nend\n\nlemma comp_neq_zero_of_neq_zero (x : α × β) : x ≠ 0 → x.1 ≠ 0 ∨ x.2 ≠ 0 :=\nbegin\n    rw [awesome_mt], \n    simp [not_or_distrib],\n    intros a b,\n    rw [←@prod.mk.eta _ _ x, a, b],\n    refl,\nend\n\nlemma prod_pos_def (x : α × β) (h : x ≠ 0) : ⟪x ∥ x⟫ > 0 :=\nbegin\n    dsimp [inner_product, prod_inner_product],\n    have w := comp_neq_zero_of_neq_zero _ h,\n    cases w,\n    \n    exact lt_add_of_pos_of_le (pos_def _ w) (norm_sq_nonneg x.2),\n\n    exact lt_add_of_le_of_pos (norm_sq_nonneg x.1) (pos_def _ w),\nend\n\ninstance prod_inner_product_space : ℝ_inner_product_space (α×β) :=\n{conj_symm := prod_conj_symm, linearity := prod_linearity, pos_def := prod_pos_def}\n\nend cartesian_prod\n\nsection real_ip\n\n@[reducible] instance ℝ_has_ℝ_inner_product : has_ℝ_inner_product ℝ := ⟨λ a b, a*b⟩\n\nlemma ℝ_conj_symm (x y : ℝ) : ⟪x ∥ y⟫ = ⟪y ∥ x⟫ := mul_comm x y\n\nlemma ℝ_linearity (x y z : ℝ) (a : ℝ) : ⟪a•x+y ∥ z⟫ = a*⟪x ∥ z⟫ + ⟪y ∥ z⟫ :=\nby {dsimp [inner_product], rw [right_distrib, mul_assoc]}\n\nlemma ℝ_pos_def (x : ℝ) : x ≠ 0 → ⟪x ∥ x⟫ > 0 := mul_self_pos\n\ninstance ℝ_is_ℝ_inner_product_space : ℝ_inner_product_space ℝ :=\n{conj_symm := ℝ_conj_symm, linearity := ℝ_linearity, pos_def := ℝ_pos_def}\n\nend real_ip\n\nopen function\n\nsection inj_linear_map\n\nvariables {γ : Type*} [decidable_eq γ] [add_comm_group γ] [vector_space ℝ γ] [ℝ_inner_product_space γ]\nvariables {η : Type*} [decidable_eq η] [add_comm_group η] [vector_space ℝ η]\nvariables (f : linear_map ℝ η γ) (h : injective f.to_fun)\n\nlemma fun_coe (f : linear_map ℝ η γ) : ⇑f = f.to_fun := rfl\n\ninclude f h\n\n@[reducible] instance inj_has_inner_product : has_ℝ_inner_product η := ⟨λ x y, ⟪f.to_fun x ∥ f.to_fun y⟫⟩\n\nlemma inj_conj_symm (x y : η) : ⟪f.to_fun x ∥ f.to_fun y⟫ = ⟪f.to_fun y ∥ f.to_fun x⟫ := conj_symm (f.to_fun x) (f.to_fun y)\n\nlemma inj_linearity (x y z : η) (a : ℝ) : ⟪f.to_fun (a • x + y) ∥ f.to_fun z⟫ = a * ⟪f.to_fun x ∥ f.to_fun z⟫ + ⟪f.to_fun y ∥ f.to_fun z⟫ :=\nby {rw [add, smul],\n    exact linearity (f.to_fun x) (f.to_fun y) (f.to_fun z) a}\n\nlemma trivial_ker_of_injective (x : η) (k : f.to_fun x = 0) : x = 0 :=\nbegin\n    have w := map_zero f,\n    dsimp [injective] at h,\n    rw [←w, fun_coe f] at k,\n    exact (h k),\nend\n\nlemma inj_pos_def (x : η) : x ≠ 0 → ⟪f.to_fun x ∥ f.to_fun x⟫ > 0 :=\nbegin\n    rw [awesome_mt],\n    simp,\n    have w := norm_sq_nonneg (f.to_fun x),\n    have k₁ := zero_iff_norm_sq_zero (f.to_fun x),\n    dsimp [norm_sq] at *,\n    intros k,\n    have w₁ := antisymm w k,\n    have w₂ := k₁.1 w₁,\n    exact (trivial_ker_of_injective f h x w₂),\nend\n\ninstance inj_inner_product_space (f : linear_map ℝ η γ) (h : injective f.to_fun) : ℝ_inner_product_space η :=\nbegin\n    refine_struct {..},\n\n    use λ x y, ⟪f.to_fun x ∥ f.to_fun y⟫,\n\n    exact inj_conj_symm f h,\n\n    exact inj_linearity f h,\n\n    exact inj_pos_def f h,\nend\n\nend inj_linear_map\n\nsection subspace\n\nvariables {γ : Type*} [decidable_eq γ] [add_comm_group γ] [vector_space ℝ γ] [ℝ_inner_product_space γ]\nvariables {η : subspace ℝ γ}\n\ndef realise : linear_map ℝ η γ :=\nbegin\n    refine_struct {..},\n    use λ x, x,\n    repeat {simp},\nend\n\nlemma realise_injective : @injective ↥η γ (realise.to_fun) :=\nbegin\n    dsimp [injective, realise],\n    intros x₁ x₂ k,\n    exact set_coe.ext k,\nend\n\ninstance sub_inner_product_space : ℝ_inner_product_space η :=\ninj_inner_product_space realise realise_injective\n\nend subspace\n\n\n\n", "meta": {"author": "MartinSkilleter", "repo": "real_ip_spaces", "sha": "1ad1e0456602038711cbb0de7aa92b88d6eff06f", "save_path": "github-repos/lean/MartinSkilleter-real_ip_spaces", "path": "github-repos/lean/MartinSkilleter-real_ip_spaces/real_ip_spaces-1ad1e0456602038711cbb0de7aa92b88d6eff06f/src/inner_product_spaces/real_ip/new_ip_spaces.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.48434720436371104}}
{"text": "lemma one_mul (m : mynat) : 1 * m = m :=\nbegin\ninduction m with a ha,\nrw mul_zero,\nrefl,\nrw mul_succ,\nrw ha,\nrw succ_eq_add_one,\nrefl,\nend\n", "meta": {"author": "chanha-park", "repo": "naturalNumberGame", "sha": "4e0d7100ce4575e1add92feefa38b1250431b879", "save_path": "github-repos/lean/chanha-park-naturalNumberGame", "path": "github-repos/lean/chanha-park-naturalNumberGame/naturalNumberGame-4e0d7100ce4575e1add92feefa38b1250431b879/Multiplication/3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.484347204363711}}
{"text": "import algebra.homology.additive\nimport algebra.homology.homological_complex\n\nimport for_mathlib.free_abelian_group\nimport for_mathlib.FreeAb\n\nimport breen_deligne.universal_map\n\n/-!\n\n# The category of Breen-Deligne data\n\nThis file defines the category whose objects are the natural numbers\nand whose morphisms `m ⟶ n` are functorial maps `φ_A : ℤ[A^m] → ℤ[A^n]`.\n\n-/\n\nopen_locale big_operators kronecker\n\nnamespace breen_deligne\n\nopen free_abelian_group category_theory\n\n/-- The category whose objects are natural numbers\nand whose morphisms are matrices with integer coefficients. -/\n@[derive comm_semiring] def Mat := ℕ\n\nnamespace Mat\n\ninstance : small_category Mat :=\n{ hom := λ m n, basic_universal_map m n,\n  id := basic_universal_map.id,\n  comp := λ l m n f g, basic_universal_map.comp g f,\n  id_comp' := λ n f, basic_universal_map.comp_id,\n  comp_id' := λ n f, basic_universal_map.id_comp,\n  assoc' := λ k l m n f g h, (basic_universal_map.comp_assoc h g f).symm }\n\nend Mat\n\n/-- The category whose objects are natural numbers\nand whose morphisms are the free abelian groups generated by\nmatrices with integer coefficients. -/\n@[derive comm_semiring] def FreeMat := ℕ\n\nnamespace FreeMat\n\ninstance : small_category FreeMat :=\n{ hom := λ m n, universal_map m n,\n  id := universal_map.id,\n  comp := λ l m n f g, universal_map.comp g f,\n  id_comp' := λ n f, universal_map.comp_id,\n  comp_id' := λ n f, universal_map.id_comp,\n  assoc' := λ k l m n f g h, (universal_map.comp_assoc h g f).symm }\n\ninstance : preadditive FreeMat :=\n{ hom_group := λ m n, infer_instance,\n  add_comp' := λ l m n f g h, add_monoid_hom.map_add _ _ _,\n  comp_add' := λ l m n f g h, show universal_map.comp (g + h) f = _,\n    by { rw [add_monoid_hom.map_add, add_monoid_hom.add_apply], refl } }\n\ndef to_FreeAbMat : FreeMat ⥤ FreeAb Mat :=\n{ obj := λ n, FreeAb.of n,\n  map := λ m n f, f,\n  map_id' := λ m, rfl,\n  map_comp' := λ l m n f g, begin\n    induction f using free_abelian_group.induction_on;\n    try { simp only [limits.zero_comp, preadditive.add_comp, preadditive.neg_comp, *] },\n    induction g using free_abelian_group.induction_on;\n    try { simp only [limits.comp_zero, preadditive.comp_add, preadditive.comp_neg, *] },\n    refl,\n  end }\n\nopen universal_map\n\n@[simps]\ndef mul_functor (N : ℕ) : FreeMat ⥤ FreeMat :=\n{ obj := λ n, N * n,\n  map := λ m n f, mul N f,\n  map_id' := λ n, (free_abelian_group.map_of _ _).trans $ congr_arg _ $\n  begin\n    dsimp [basic_universal_map.mul, basic_universal_map.id],\n    ext i j,\n    simp only [matrix.one_kronecker_one, matrix.submatrix_apply, matrix.one_apply,\n      equiv.apply_eq_iff_eq, eq_self_iff_true],\n  end,\n  map_comp' := λ l m n f g, mul_comp _ _ _ }\n.\ninstance mul_functor.additive (N : ℕ) : (mul_functor N).additive :=\n{ map_add' := λ m n f g, add_monoid_hom.map_add _ _ _ }\n\n@[simps] def iso_mk' {m n : FreeMat}\n  (f : basic_universal_map m n) (g : basic_universal_map n m)\n  (hfg : basic_universal_map.comp g f = basic_universal_map.id _)\n  (hgf : basic_universal_map.comp f g = basic_universal_map.id _) :\n  m ≅ n :=\n{ hom := of f,\n  inv := of g,\n  hom_inv_id' := (comp_of _ _).trans $ congr_arg _ $ hfg,\n  inv_hom_id' := (comp_of _ _).trans $ congr_arg _ $ hgf }\n\ndef one_mul_iso : mul_functor 1 ≅ 𝟭 _ :=\nnat_iso.of_components (λ n, iso_mk'\n  (basic_universal_map.one_mul_hom _) (basic_universal_map.one_mul_inv _)\n  basic_universal_map.one_mul_inv_hom basic_universal_map.one_mul_hom_inv)\nbegin\n  intros m n f,\n  dsimp,\n  show universal_map.comp _ _ = universal_map.comp _ _,\n  rw [← add_monoid_hom.comp_apply, ← add_monoid_hom.comp_hom_apply_apply,\n    ← add_monoid_hom.flip_apply _ f],\n  congr' 1, clear f, ext1 f,\n  have : f = matrix.reindex_linear_equiv ℕ _\n      ((fin_one_equiv.prod_congr $ equiv.refl _).trans $ equiv.punit_prod _)\n      ((fin_one_equiv.prod_congr $ equiv.refl _).trans $ equiv.punit_prod _)\n      (1 ⊗ₖ f),\n  { ext i j, dsimp [matrix.kronecker, matrix.one_apply],\n    simp only [one_mul, if_true, eq_iff_true_of_subsingleton], },\n  conv_rhs { rw this },\n  simp only [comp_of, mul_of, basic_universal_map.comp, add_monoid_hom.mk'_apply,\n    basic_universal_map.mul, basic_universal_map.one_mul_hom,\n    add_monoid_hom.comp_hom_apply_apply, add_monoid_hom.comp_apply, add_monoid_hom.flip_apply,\n    iso_mk'_hom],\n  rw [matrix.reindex_linear_equiv_mul, matrix.reindex_linear_equiv_mul,\n    matrix.one_mul, matrix.mul_one],\nend\n\n/-\nShould `kronecker_reindex_left` and `kronecker_reindex_right` land into `mathlib`?\n-/\n\nvariables {α β γ : Type*}\nvariables {l₁ m₁ n₁ l₂ m₂ n₂ : Type*}\nvariables [fintype l₁] [fintype m₁] [fintype n₁]\nvariables [fintype l₂] [fintype m₂] [fintype n₂]\n\nlemma kronecker_map_reindex_left (f : α → β → γ) (el : l₁ ≃ l₂) (em : m₁ ≃ m₂) (M : matrix l₁ m₁ α)\n  (N : matrix n₁ n₂ β) : matrix.kronecker_map f (matrix.reindex el em M) N =\n  matrix.reindex (el.prod_congr (equiv.refl _)) (em.prod_congr (equiv.refl _))\n  (matrix.kronecker_map f M N) := by { ext ⟨i, i'⟩ ⟨j, j'⟩, refl }\n\nlemma kronecker_map_reindex_right (f : α → β → γ) (em : m₁ ≃ m₂) (en : n₁ ≃ n₂)\n  (M : matrix l₁ l₂ α) (N : matrix m₁ n₁ β) :\n  matrix.kronecker_map f M (matrix.reindex em en N) =\n  matrix.reindex ((equiv.refl _).prod_congr em) ((equiv.refl _).prod_congr en)\n    (matrix.kronecker_map f M N) := by { ext ⟨i, i'⟩ ⟨j, j'⟩, refl }\n\n\nlemma mul_mul_iso_aux (m n i j : ℕ) (f : basic_universal_map i j) :\n  (comp (of (basic_universal_map.mul_mul_hom m n j))) (mul m (mul n (of f))) =\n    comp (mul (m * n) (of f)) (of (basic_universal_map.mul_mul_hom m n i)) :=\nbegin\n  simp only [comp_of, mul_of, basic_universal_map.comp, add_monoid_hom.mk'_apply,\n    basic_universal_map.mul, basic_universal_map.mul_mul_hom, matrix.mul_reindex_linear_equiv_one],\n  rw [matrix.reindex_linear_equiv_mul, matrix.one_mul,\n    ← matrix.reindex_linear_equiv_one ℕ _ (@fin_prod_fin_equiv m n)],\n  simp only [matrix.reindex_linear_equiv_apply],\n  rw [kronecker_map_reindex_left, kronecker_map_reindex_right, ← matrix.kronecker_assoc],\n  simp only [← equiv.trans_apply, matrix.reindex_trans, matrix.one_kronecker_one,\n    equiv.trans_refl],\n  congr' 3, swap 3, { apply_instance },\n  { ext ⟨⟨a, b⟩, c⟩,\n    simp only [equiv.trans_apply, equiv.symm_apply_apply, equiv.apply_symm_apply,\n      equiv.prod_assoc_apply, equiv.prod_assoc_symm_apply, equiv.prod_congr_apply,\n      prod.map_def, equiv.refl_apply], },\n  { ext ⟨⟨a, b⟩, c⟩,\n    simp only [equiv.trans_apply, equiv.symm_apply_apply, equiv.apply_symm_apply,\n      equiv.prod_assoc_apply, equiv.prod_assoc_symm_apply, equiv.prod_congr_apply,\n      prod.map_def, equiv.refl_apply, equiv.symm_trans_apply, equiv.symm_symm,\n      equiv.prod_congr_symm, equiv.refl_symm], },\nend\n\ndef mul_mul_iso (m n : ℕ) : mul_functor n ⋙ mul_functor m ≅ mul_functor (m * n) :=\nnat_iso.of_components (λ i, iso_mk'\n  (basic_universal_map.mul_mul_hom m n i) (basic_universal_map.mul_mul_inv m n i)\n  basic_universal_map.mul_mul_inv_hom basic_universal_map.mul_mul_hom_inv)\nbegin\n  intros i j f,\n  dsimp,\n  show universal_map.comp _ _ = universal_map.comp _ _,\n  rw [← add_monoid_hom.comp_apply, ← add_monoid_hom.comp_apply,\n    ← add_monoid_hom.flip_apply _ (mul (m * n) f),\n    ← add_monoid_hom.comp_apply],\n  congr' 1, clear f, ext1 f,\n  apply mul_mul_iso_aux,\nend\n\nend FreeMat\n\n/-- Roughly speaking, this is a collection of formal finite sums of matrices\nthat encode the data that rolls out of the Breen--Deligne resolution. -/\n@[derive [small_category, preadditive]]\ndef data := chain_complex FreeMat ℕ\n\nnamespace data\n\nvariable (BD : data)\n\nsection mul\n\nopen universal_map\n\n@[simps]\ndef mul (N : ℕ) : data ⥤ data :=\n(FreeMat.mul_functor N).map_homological_complex _\n\ndef mul_one_iso : (mul 1).obj BD ≅ BD :=\nhomological_complex.hom.iso_of_components (λ i, FreeMat.one_mul_iso.app _) $\nλ i j _, (FreeMat.one_mul_iso.hom.naturality (BD.d i j)).symm\n\ndef mul_mul_iso (m n : ℕ) : (mul m).obj ((mul n).obj BD) ≅ (mul (m * n)).obj BD :=\nhomological_complex.hom.iso_of_components (λ i, (FreeMat.mul_mul_iso _ _).app _) $\nλ i j _, ((FreeMat.mul_mul_iso _ _).hom.naturality (BD.d i j)).symm\n\nend mul\n\n/-- `BD.pow N` is the Breen--Deligne data whose `n`-th rank is `2^N * BD.rank n`. -/\ndef pow' : ℕ → data\n| 0     := BD\n| (n+1) := (mul 2).obj (pow' n)\n\n@[simps] def sum (BD : data) (N : ℕ) : (mul N).obj BD ⟶ BD :=\n{ f := λ n, universal_map.sum _ _,\n  comm' := λ m n _, (universal_map.sum_comp_mul _ _).symm }\n\n@[simps] def proj (BD : data) (N : ℕ) : (mul N).obj BD ⟶ BD :=\n{ f := λ n, universal_map.proj _ _,\n  comm' := λ m n _, (universal_map.proj_comp_mul _ _).symm }\n\nopen homological_complex FreeMat category_theory category_theory.limits\n\ndef hom_pow' {BD : data} (f : (mul 2).obj BD ⟶ BD) : Π N, BD.pow' N ⟶ BD\n| 0     := 𝟙 _\n| (n+1) := (mul 2).map (hom_pow' n) ≫ f\n\nopen_locale zero_object\n\ndef pow'_iso_mul : Π N, BD.pow' N ≅ (mul (2^N)).obj BD\n| 0     := BD.mul_one_iso.symm\n| (N+1) := show (mul 2).obj (BD.pow' N) ≅ (mul (2 * 2 ^ N)).obj BD, from\n   (mul 2).map_iso (pow'_iso_mul N) ≪≫ mul_mul_iso _ _ _\n\nlemma hom_pow'_sum : ∀ N, (BD.pow'_iso_mul N).inv ≫ hom_pow' (BD.sum 2) N = BD.sum (2^N)\n| 0     :=\nbegin\n  ext n : 2,\n  simp only [hom_pow', category.comp_id],\n  show (BD.pow'_iso_mul 0).inv.f n = (BD.sum 1).f n,\n  dsimp only [sum_f, universal_map.sum],\n  simp only [fin.default_eq_zero, finset.univ_unique, finset.sum_singleton],\n  refine congr_arg of _,\n  apply basic_universal_map.one_mul_hom_eq_proj,\nend\n| (N+1) :=\nbegin\n  dsimp [pow'_iso_mul, hom_pow'],\n  slice_lhs 2 3 { rw [← functor.map_comp, hom_pow'_sum] },\n  rw iso.inv_comp_eq,\n  ext i : 2,\n  iterate 2 { erw [homological_complex.comp_f] },\n  dsimp [mul_mul_iso, FreeMat.mul_mul_iso, universal_map.sum],\n  rw [universal_map.mul_of],\n  show universal_map.comp _ _ = universal_map.comp _ _,\n  simp only [universal_map.comp_of, add_monoid_hom.map_sum, add_monoid_hom.finset_sum_apply],\n  congr' 1,\n  rw [← finset.sum_product', finset.univ_product_univ, ← fin_prod_fin_equiv.symm.sum_comp],\n  apply fintype.sum_congr,\n  apply basic_universal_map.comp_proj_mul_proj,\nend\n.\n\nlemma hom_pow'_sum' (N : ℕ) : hom_pow' (BD.sum 2) N = (BD.pow'_iso_mul N).hom ≫ BD.sum (2^N) :=\nby { rw ← iso.inv_comp_eq, apply hom_pow'_sum }\n\nlemma hom_pow'_proj : ∀ N, (BD.pow'_iso_mul N).inv ≫ hom_pow' (BD.proj 2) N = BD.proj (2^N)\n| 0     :=\nbegin\n  ext n : 2,\n  simp only [hom_pow', category.comp_id],\n  show (BD.pow'_iso_mul 0).inv.f n = (BD.proj 1).f n,\n  dsimp only [proj_f, universal_map.proj],\n  refine congr_arg of _,\n  apply basic_universal_map.one_mul_hom_eq_proj,\nend\n| (N+1) :=\nbegin\n  dsimp [pow'_iso_mul, hom_pow'],\n  slice_lhs 2 3 { rw [← functor.map_comp, hom_pow'_proj] },\n  rw iso.inv_comp_eq,\n  ext i : 2,\n  iterate 2 { erw [homological_complex.comp_f] },\n  dsimp [mul_mul_iso, FreeMat.mul_mul_iso, universal_map.proj],\n  simp only [add_monoid_hom.map_sum, add_monoid_hom.finset_sum_apply,\n    preadditive.comp_sum, preadditive.sum_comp],\n  rw [← finset.sum_comm, ← finset.sum_product', finset.univ_product_univ,\n      ← fin_prod_fin_equiv.symm.sum_comp],\n  apply fintype.sum_congr,\n  intros j,\n  rw [universal_map.mul_of],\n  show universal_map.comp _ _ = universal_map.comp _ _,\n  simp only [universal_map.comp_of, basic_universal_map.comp_proj_mul_proj],\nend\n\nlemma hom_pow'_proj' (N : ℕ) : hom_pow' (BD.proj 2) N = (BD.pow'_iso_mul N).hom ≫ BD.proj (2^N) :=\nby { rw ← iso.inv_comp_eq, apply hom_pow'_proj }\n\nend data\n\nend breen_deligne\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/breen_deligne/category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.484347204363711}}
{"text": "import inner_product_spaces.real_ip.hilbert_space\nimport linear_algebra.basis\nimport tactic.interactive\n\nnoncomputable theory\n\nvariables {α : Type*}\n\nopen real set module submodule linear_map set\n\nvariables [decidable_eq α] [add_comm_group α] [vector_space ℝ α] [ℝ_inner_product_space α]\n\nsection norm_known\n\ndef α_normed_space : normed_space ℝ α := ip_space_is_normed_space\n\nlocal attribute [instance] α_normed_space\nlocal attribute [instance] classical.prop_decidable\n\ndef orthog_set (L : set α) : Prop :=\n∀ (a b ∈ L), a ≠ b → a ⊥ b\n\nlemma emptyset_orthog : orthog_set (∅ : set α) :=\nby {dsimp [orthog_set], simp}\n\nlemma add_elt_to_orthog (L : set α) (x : α) (h : orthog_set L) (w : ∀ (y ∈ L), x ⊥ y) : orthog_set (L ∪ {x}) :=\nbegin\n    dsimp [orthog_set] at *,\n    intros a b k₁ k₂ k₃,\n    cases k₁,\n    cases k₂,\n\n    exact h a b k₁ k₂ k₃,\n\n    apply orthog_symm,\n    rw [eq_of_mem_singleton k₂],\n    exact w a k₁,\n\n    cases k₂,\n\n    rw [eq_of_mem_singleton k₁],\n    exact w b k₂,\n\n    have k₃ := (eq_of_mem_singleton k₂).symm,\n    rw [←eq_of_mem_singleton k₁] at k₃,\n    contradiction,\nend\n\nlemma orthog_subset (L S : set α) (h : orthog_set L) (w : S ⊆ L) : orthog_set S :=\nby {dsimp [orthog_set] at *,\n    dsimp [(⊆), set.subset] at w,\n    intros a b k₁ k₂ k₃,\n    exact (h a b (w k₁) (w k₂) k₃)}\n\ndef orthonormal (L : set α) : Prop :=\northog_set L ∧ ∀ (a ∈ L), ∥a∥=1\n\ndef normalise (L : set α) := image (λ (a : α), (1/∥a∥ : ℝ) • a) L\n\nlemma elem_of_normalised (L : set α) (x : α) (h : x ∈ normalise L) : ∃ (y ∈ L) (a : ℝ), a • y = x :=\nby {dsimp [normalise, image] at h, rcases h with ⟨y, hl, hr⟩,\n    use y, use hl, use (1 / ∥y∥), exact hr}\n\nlemma elem_of_normalised' (L : set α) (x : α) (h : x ∈ L) : ((1 / ∥x∥ : ℝ) • x) ∈ normalise L :=\nby {dsimp [normalise, image], use x, exact ⟨h, rfl⟩}\n\nlemma norm_one_of_norm_inv (x : α) (h : x ≠ 0) : ∥(1/∥x∥)•x∥ = 1 :=\nby {rw [one_div_eq_inv, @norm_smul ℝ α _ ip_space_is_normed_space _ x, norm_inv,\n    @norm_norm α ip_space_is_normed_group, inv_mul_cancel],\n    exact (@norm_neq_zero_iff_neq_zero α ip_space_is_normed_space x).2 h}\n\nlemma norm_one_of_normalised (L : set α) (h : (0 : α) ∉ L) (a : α) (w : a ∈ normalise L) : ∥a∥=1 :=\nbegin\n    dsimp [normalise] at w,\n    simp at w,\n    rcases w with ⟨b, k₁, k₂⟩,\n    have k₃ : b ≠ 0, begin\n        by_contradiction,\n        simp only [not_not] at a_1,\n        rw [a_1] at k₁,\n        contradiction,\n    end,\n    rw [←k₂, ←one_div_eq_inv],\n    exact norm_one_of_norm_inv b k₃,\nend\n\nlemma zero_not_elem_of_normalised (L : set α) (h : (0 : α) ∉ L) : (0 : α) ∉ normalise L :=\nby {by_contradiction, have w := norm_one_of_normalised L h 0 a, simp at w, exact w}\n\nlemma orthog_normalised_of_orthog (L : set α) (h : orthog_set L) : orthog_set (normalise L) :=\nbegin\n    dsimp [orthog_set] at *,\n    dsimp [normalise],\n    simp,\n    intros a b x k₁ k₂ y k₃ k₄ k₅,\n    have k₆ : x ≠ y, begin\n        by_contradiction,\n        simp only [not_not] at a_1,\n        rw [a_1] at k₂,\n        rw [k₂] at k₄,\n        contradiction,\n    end,\n    rw [←k₄, ←k₂],\n    exact mul_orthog x y (∥x∥)⁻¹ (∥y∥)⁻¹ (h x y k₁ k₃ k₆),\nend\n\nlemma orthonormal_normalised_of_orthog_set (L : set α) (h : orthog_set L) (w : (0 : α) ∉ L) : orthonormal (normalise L) :=\nby {dsimp [orthonormal], exact ⟨orthog_normalised_of_orthog L h, norm_one_of_normalised L w⟩}\n\nlemma orthog_set_is_lin_indep (L : set α) (h : orthog_set L) (w : (0 : α) ∉ L) : linear_independent ℝ L :=\nbegin\n    rw [linear_independent_iff],\n    intros l k₁ k₂,\n    -- rw [linear_combination.mem_supported] at k₁,\n    sorry,\nend\n\nlemma scale_elem_in_span (L : set α) (x : α) (a : ℝ) (h : x ∈ span ℝ L) : (a • x) ∈ span ℝ L :=\nby {rw [mem_span] at *, intros p k, exact smul p a (h p k)}\n\nlemma elem_span_of_elem_normalised (L : set α) (x : α) (a : x ∈ normalise L) : x ∈ span ℝ L :=\nbegin\n    have w₁ := elem_of_normalised L x a,\n    rcases w₁ with ⟨y, w₁, a, w₂⟩,\n    have w₃ := @subset_span ℝ _ _ _ _ _,\n    rw [←w₂],\n    exact scale_elem_in_span L y a (w₃ w₁),\nend\n\nlemma normalised_subset_span (L : set α) : normalise L ⊆ ↑(span ℝ L) := elem_span_of_elem_normalised L\n\nlemma in_submodule_of_normalised_in_submodule (L : set α) (p : submodule ℝ α) (k : normalise L ⊆ ↑p) : L ⊆ ↑p :=\nbegin\n    have w : ∀ (x : α), x ∈ L → x ∈ ↑p := begin\n        intros x l,\n        by_cases (x = 0),\n\n        rw [mem_coe p, h],\n        exact zero_mem p,\n\n        have w₁ := elem_of_normalised' L x l,\n        have w₂ := k w₁,\n        rw [mem_coe] at w₂,\n        have w₃ := smul p (∥x∥) w₂,\n        rw [smul_smul, one_div_eq_inv, mul_inv_cancel, one_smul] at w₃,\n        rw [mem_coe],\n        exact w₃,\n        rw [←ne.def] at h,\n        exact (norm_neq_zero_iff_neq_zero x).2 h,\n    end,\n    exact w,\nend\n\nlemma span_of_normalised_is_span (L : set α) : span ℝ (normalise L) = span ℝ L :=\nbegin\n    ext,\n    rw [mem_span],\n    constructor,\n\n    intros h,\n    exact (h (span ℝ L)) (normalised_subset_span L),\n\n    intros h p w,\n    have h' := mem_span.1 h,\n    have h₁ := h' p,\n    exact h₁ (in_submodule_of_normalised_in_submodule L p w),\nend\n\ndef orthonormal_basis (L : set α) := orthonormal L ∧ is_basis ℝ L\n\ntheorem normalised_basis_is_orthonormal_basis (L : set α) (h : is_basis ℝ L) (k : orthog_set L) : orthonormal_basis (normalise L) :=\nbegin\n    dsimp [orthonormal_basis, is_basis] at *,\n    cases h,\n    have w := zero_not_mem_of_linear_independent (@zero_ne_one ℝ _) h_left,\n    exact ⟨by {dsimp [orthonormal],\n    exact ⟨orthog_normalised_of_orthog L k, norm_one_of_normalised L w⟩},\n    by {exact ⟨orthog_set_is_lin_indep _ (orthog_normalised_of_orthog L k) (zero_not_elem_of_normalised L w), \n    by {simpa [span_of_normalised_is_span]}⟩}⟩,\nend\n\n-- The Gram-Schimdt Procedure. Never finished defining it because I ended up\n-- doing most of my work without fixing a basis.\n\n-- def gram_partial (s : ℕ → α) : ℕ → set α\n-- | 0 := {∥s 0∥⁻¹ • s 0}\n-- | n := sorry\n\n-- def gram_schmidt (s : ℕ → α) : ℕ → α :=\n-- ⋃₀ {L | ∃ (n : ℕ), L = gram_partial s n}\n\nend norm_known\n\nsection perp_space\n\ndef perp (L : set α) : set α := {x | ∀ (y ∈ L), x ⊥ y}\n\nlemma perp_perp (L : set α) : L ⊆ perp (perp L) :=\nbegin\n    have w : ∀ (x : α), x ∈ L → x ∈ perp (perp L) := begin\n        intros x h,\n        dsimp [perp],\n        intros y k,\n        have k₁ := orthog_symm (k x h),\n        exact k₁,\n    end,\n    exact w,\nend\n\nlemma perp_antitone (S : set α) (L : set α) (h : S ⊆ L) : perp L ⊆ perp S :=\nbegin\n    have w : ∀ (x : α), x ∈ perp L → x ∈ perp S := begin\n        intros x w,\n        dsimp [perp] at *,\n        intros y k,\n        exact w y (h k),\n    end,\n    exact w,\nend\n\nvariables {S : set α}\n\nlemma perp_add_closed (x y : α) (hx : x ∈ perp S) (hy : y ∈ perp S) : x + y ∈ perp S :=\nbegin\n    dsimp [perp] at *,\n    intros z hz,\n    exact add_orthog (hx z hz) (hy z hz),\nend\n\nlemma perp_smul_closed (c : ℝ) (x : α) (hx : x ∈ perp S) : c•x ∈ perp S :=\nbegin\n    dsimp [perp] at *,\n    intros z hz,\n    rw [←one_smul ℝ z],\n    exact @mul_orthog α _ _ _ _ x z c 1 (hx z hz),\nend\n\nlemma zero_in_perp : (0 : α) ∈ perp S :=\nbegin\n    dsimp [perp],\n    intros y h,\n    exact right_orthog_to_zero y,\nend\n\ndef perp_subspace : subspace ℝ α :=\n{carrier := perp S,\n zero := zero_in_perp,\n add := perp_add_closed,\n smul := perp_smul_closed}\n\nlemma sub_simp {α : Type*} [add_comm_group α] [vector_space ℝ α] {S : subspace ℝ α} {y : α} : y ∈ S ↔ y ∈ S.carrier :=\nby {rw [←submodule.mem_coe], unfold_coes}\n\nlemma perp_singleton_ker (x : α) : perp {x} = (linear_map.ker (ip_map x)).carrier :=\nbegin\n    ext y,\n    rw [←sub_simp, mem_ker, ip_map_to_fun],\n    dsimp [perp],\n    split,\n\n    intros h,\n    have h₁ := h x (mem_singleton x),\n    dsimp [orthog] at h₁,\n    rw [conj_symm] at h₁,\n    exact h₁,\n\n    intros h z w,\n    have k := eq_of_mem_singleton w,\n    dsimp [orthog],\n    rw [conj_symm, k],\n    exact h,\nend\n\nlemma functional_ker_is_preimage_zero {f : α →ₗ[ℝ] ℝ} : (linear_map.ker f).carrier = f⁻¹' {0} :=\nby {ext, rw [←sub_simp], simp}\n\nlemma bounded_functional_ker_closed {f : α →ₗ[ℝ] ℝ} {w : @is_bounded_linear_map ℝ _ α ip_space_is_normed_space _ _ f} : @is_closed α α_topological_space (linear_map.ker f).carrier :=\nby {rw [@functional_ker_is_preimage_zero α _ _ _ _],\n    apply ((@continuous_iff_is_closed α ℝ α_topological_space ℝ_topological_space f).1 (@is_bounded_linear_map.continuous ℝ _ α ip_space_is_normed_space ℝ _ _ w) {0}),\n    exact is_closed_singleton}\n\nlemma ip_map_ker_is_preimage_zero (x : α) : (linear_map.ker (ip_map x)).carrier = (ip_map x)⁻¹' {0} :=\nfunctional_ker_is_preimage_zero\n\nlemma ip_map_ker_is_closed (x : α) : @is_closed α α_topological_space (linear_map.ker (ip_map x)).carrier :=\n@bounded_functional_ker_closed α _ _ _ _ _ (ip_map_is_bounded_linear_map x)\n\nlemma perp_singleton_closed (x : α) : @is_closed α α_topological_space (perp {x}) :=\nby {rw [perp_singleton_ker], exact ip_map_ker_is_closed x}\n\nlemma perp_int_singleton (S : set α) : perp S = ⋂₀ {L | ∃ (a ∈ S), L = perp ({a})} :=\nbegin\n    ext x,\n    rw [mem_sInter],\n    split,\n\n    intros h t w,\n    simp at w,\n    cases w with a w,\n    cases w,\n    dsimp [perp] at *,\n    rw [w_right],\n    simp,\n    exact h a w_left,\n\n    intros h y w,\n    simp at h,\n    have h₁ := h (perp {y}) y w rfl,\n    dsimp [perp] at h₁,\n    exact h₁ y (mem_singleton y),\nend\n\nlemma perp_int_trivial {l : (0 : α) ∈ S}: S ∩ perp S = {0} :=\nbegin\n    ext,\n    split,\n\n    simp,\n    intros h w,\n    dsimp [perp] at w,\n    have k := w x h,\n    have k₁ := zero_of_norm_sq_zero x,\n    dsimp [norm_sq] at k₁,\n    dsimp [orthog] at k,\n    exact k₁ k,\n\n    intros h,\n    have k := eq_of_mem_singleton h,\n    rw [k],\n    simp,\n    split,\n    exact l,\n    exact zero_in_perp,\nend\n\n\nlemma perp_singleton_expr (S : set α) {t : set α} (h :t ∈ {L : set α | ∃ (a : α) (H : a ∈ S), L = perp {a}}) : ∃ (a ∈ S), t = perp {a} :=\nby {rw [mem_set_of_eq] at h, exact h}\n\ntheorem perp_space_closed (S : set α) : @is_closed α α_topological_space (perp S) :=\nbegin\n    rw [perp_int_singleton],\n    apply @is_closed_sInter α α_topological_space _,\n    intros t h,\n    have k := perp_singleton_expr S h,\n    rcases k with ⟨a, k₁, k₂⟩,\n    rw [k₂],\n    exact perp_singleton_closed a,\nend\n\nend perp_space\n\nsection orthogonal_projection\n\nlocal attribute [instance] α_normed_space\n\nvariables [Hilbert_space α]\nvariables (S : submodule ℝ α)\nvariables (h : @is_closed α α_topological_space S.carrier)\n\ninclude h\n\ntheorem proj_exists_unique (x : α) : ∃! (y : α), y ∈ S ∧ (∥x-y∥ = Inf {r | ∃ (z ∈ S), r = ∥x-z∥}) :=\nbegin\n    sorry,\nend\n\ndef orthog_proj (x : α) := classical.some (exists_of_exists_unique (proj_exists_unique S h x))\n\nlemma orthog_classical (x : α) : orthog_proj S h x = classical.some (exists_of_exists_unique (proj_exists_unique S h x)) := rfl\n\nlemma orthog_proj_mem (x : α) : orthog_proj S h x ∈ S :=\nbegin\n    have w := classical.some_spec (exists_of_exists_unique (proj_exists_unique S h x)),\n    rw [←orthog_classical] at w,\n    cases w,\n    exact w_left,\nend\n\nlemma orthog_proj_dist (x : α) : ∥x -  orthog_proj S h x∥ = Inf {r | ∃ (z ∈ S), r = ∥x-z∥} :=\nbegin\n    have w := classical.some_spec (exists_of_exists_unique (proj_exists_unique S h x)),\n    rw [←orthog_classical] at w,\n    cases w,\n    exact w_right,\nend\n\nlemma orthog_unique (x y z : α) (w : (y ∈ S ∧ (∥x-y∥ = Inf {r | ∃ (j ∈ S), r = ∥x-j∥})) ∧ (z ∈ S ∧ (∥x-z∥ = Inf {r | ∃ (j ∈ S), r = ∥x-j∥}))) : y = z :=\nby {cases w, exact unique_of_exists_unique (proj_exists_unique S h x) w_left w_right}\n\nlemma orthog_proj_suff (x y : α) (w : y ∈ S ∧ (∥x-y∥ = Inf {r | ∃ (z ∈ S), r = ∥x-z∥})) : y = orthog_proj S h x :=\nby {apply orthog_unique S h, exact ⟨w, ⟨orthog_proj_mem S h x, orthog_proj_dist S h x⟩⟩}\n\nlemma orthog_proj_suff' (x y : α) (w : y ∈ S ∧ (∥x-y∥ = Inf {r | ∃ (z ∈ S), r = ∥x-z∥})) : orthog_proj S h x = y :=\nby {apply symm, exact orthog_proj_suff S h x y w}\n\nlemma dist_bounded_below (x : α): ∃ (l : ℝ), ∀ (y : ℝ), y ∈ {r : ℝ | ∃ (z ∈ S), r = ∥x - z∥} → l ≤ y :=\nbegin\n    use 0,\n    intros y,\n    simp,\n    intros z w₁ w₂,\n    rw [w₂],\n    exact norm_nonneg _,\nend\n\nlemma dist_nonempty (x : α) : (∃ (r : ℝ), r ∈ {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥}) :=\nbegin\n    use ∥x∥,\n    simp,\n    use 0,\n    exact ⟨zero_mem S, by {simp}⟩,\nend\n\nlemma orthog_proj_id_on_S (x : α) (k : x ∈ S) : orthog_proj S h x = x :=\nbegin\n    apply symm,\n    apply orthog_proj_suff,\n    split,\n\n    exact k,\n    simp,\n    have w₁ : (0 : ℝ) ∈ {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥} := begin\n        simp,\n        use x,\n        split,\n\n        exact k,\n\n        simp,\n    end,\n    have w₂ := @Inf_le {r | ∃ (z ∈ S), r = ∥x-z∥} (dist_bounded_below S h x) 0 w₁,\n    have w₃ : (∀ (z : ℝ), z ∈ {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥} → 0 ≤ z) := begin\n        intros z k₁,\n        simp at k₁,\n        cases k₁,\n        cases k₁_h,\n        rw [k₁_h_right],\n        exact norm_nonneg _,\n    end,\n    have w₄ := (le_Inf {r | ∃ (z ∈ S), r = ∥x-z∥} (dist_nonempty S h _) (dist_bounded_below S h x)).2 w₃,\n    have w₅ := (antisymm w₂ w₄).symm,\n    simp at w₅,\n    exact w₅,\nend\n\nlemma orthog_proj_zero_on_perp_S (x : α) (k : x ∈ perp S.carrier) : orthog_proj S h x = 0 :=\nbegin\n    apply orthog_proj_suff',\n    split,\n\n    exact zero_mem S,\n    rw [sub_zero],\n    have w₁ : ∥x∥ ∈ {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥} := begin\n        simp,\n        use 0,\n        split,\n\n        exact zero_mem S,\n\n        simp,\n    end,\n    have w₂ := Inf_le {r | ∃ (z ∈ S), r = ∥x-z∥} (dist_bounded_below S h x) w₁,\n    have w₃ : (∃ (r : ℝ), r ∈ {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥}) := begin\n        use ∥x∥,\n        exact w₁,\n    end,\n    have w₄ : (∀ (z : ℝ), z ∈ {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥} → ∥x∥ ≤ z) := begin\n        intros r l,\n        simp at l,\n        cases l with z l,\n        cases l,\n        rw ←norm_sqr_leq_iff_norm_leq,\n\n        rw [l_right, pythagoras],\n        simp,\n        exact (norm_sq_nonneg z),\n\n        dsimp [perp] at k,\n        have k₁ := @mul_orthog α _ _ _ _ x z 1 (-1) (k z l_left),\n        rw [one_smul, neg_one_smul] at k₁,\n        exact k₁,\n        rw [l_right],\n        exact norm_nonneg _,\n    end,\n    have w₅ := (le_Inf {r | ∃ (z ∈ S), r = ∥x-z∥} w₃ (dist_bounded_below S h x)).2 w₄,\n    exact (antisymm w₂ w₅).symm,\nend\n\nlemma orthog_proj_idempotent (x : α) : orthog_proj S h (orthog_proj S h x) = orthog_proj S h x :=\nby {apply orthog_proj_id_on_S, exact orthog_proj_mem S h x}\n\nlemma perp_mem_of_orthog_to_units (x : α) (k : ∀ (y ∈ S), ∥y∥=1 → x ⊥ y) : x ∈ perp S.carrier :=\nbegin\n    dsimp [perp, orthog] at *,\n    intros y k₁,\n    by_cases (y=0),\n\n    rw [h],\n    exact left_orthog_to_zero x,\n\n    revert h,\n    intros k₂,\n    rw [←ne.def] at k₂,\n    have w₁ := k ((1/∥y∥) • y) (smul_mem S (1/∥y∥) k₁) (norm_one_of_norm_inv y k₂),\n    have w₂ := mul_orthog x _ 1 (∥y∥) w₁,\n    rw [one_smul, one_div_eq_inv, ←mul_smul, mul_inv_cancel ((norm_neq_zero_iff_neq_zero y).2 k₂), one_smul] at w₂,\n    exact w₂,\nend\n\nlemma min_dist_expr (x y : α) (k : ∥y∥ = 1) : ∥x-(orthog_proj S h x + ⟪y ∥ x - orthog_proj S h x⟫•y)∥^2 = ∥x - orthog_proj S h x∥^2 - ⟪y ∥ x - orthog_proj S h x⟫^2 :=\nbegin\n    rw [sub_eq_add_neg, ←neg_one_smul ℝ, smul_add, ←add_assoc, neg_one_smul ℝ, neg_one_smul ℝ,\n    sqr_norm, sqr_norm, norm_sq_add (x + -orthog_proj S h x) (-(⟪y∥x - orthog_proj S h x⟫ • y))],\n    dsimp [norm_sq],\n    rw [←neg_one_smul ℝ (⟪y∥x + -orthog_proj S h x⟫ • y), smul_smul, mul_right, conj_symm y,\n    mul_assoc, ←pow_two],\n    ring,\n    rw [add_assoc, sub_eq_add_neg (⟪x-orthog_proj S h x∥x-orthog_proj S h x⟫) (⟪x - orthog_proj S h x∥y⟫ ^ 2)],\n    apply congr_arg (λ r, ⟪x - orthog_proj S h x∥x - orthog_proj S h x⟫ + r),\n    rw [mul_left, mul_right],\n    have w : norm_sq y = ⟪y ∥ y⟫ := rfl,\n    rw [←w, ←sqr_norm, pow_two ∥y∥, k, mul_one, mul_one, ←pow_two, ←neg_one_mul ⟪x - orthog_proj S h x∥y⟫,\n    mul_pow, neg_one_pow_eq_pow_mod_two],\n    have w₁ : 2 % 2 = 0 := rfl,\n    rw [w₁, pow_zero, ←neg_one_mul, ←mul_assoc, ←right_distrib],\n    apply congr_arg (λ r, r * ⟪x - orthog_proj S h x∥y⟫ ^ 2),\n    rw [←neg_neg (1 : ℝ), mul_comm, ←neg_one_mul, ←neg_one_mul (-(1 : ℝ)), mul_assoc, ←left_distrib],\n    apply congr_arg (λ r, (-(1 : ℝ))*r),\n    rw [neg_one_mul, neg_neg, one_mul, ←sub_eq_add_neg],\n    have w₂ : (2 : ℝ) = 1 + 1 := rfl,\n    rw [w₂, sub_eq_add_neg, add_assoc, add_right_neg, add_zero],\nend\n\nlemma orthog_of_orthog_proj_sub (x : α) : (x - orthog_proj S h x) ∈ perp S.carrier:=\nbegin\n    apply perp_mem_of_orthog_to_units S h,\n    intros y k₁ k₂,\n    dsimp [orthog],\n    have w₁ : ∥x-orthog_proj S h x∥ ≤ ∥x - (orthog_proj S h x + ⟪y ∥ x - orthog_proj S h x⟫ • y)∥ := begin\n        have w₁ := orthog_proj_dist S h x,\n        rw [w₁],\n        have w₂ : ∥x - (orthog_proj S h x + ⟪y ∥ x - orthog_proj S h x⟫ • y)∥ ∈ {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥} := begin\n            simp,\n            existsi orthog_proj S h x + ⟪y ∥ x - orthog_proj S h x⟫ • y,\n            split,\n            exact add_mem S (orthog_proj_mem S h x) (smul_mem S _ k₁),\n            simp,\n        end,\n        have w₃ := Inf_le {r : ℝ | ∃ (z : α) (H : z ∈ S), r = ∥x - z∥} (dist_bounded_below S h x) w₂,\n        exact w₃,\n    end,\n    by_contradiction,\n    rw [conj_symm, ←ne.def, ←sqr_pos_iff_neq_zero] at a,\n    have w₃ : ∥x - orthog_proj S h x∥ ^ 2 - ⟪y ∥ x - orthog_proj S h x⟫ ^ 2 < ∥x-orthog_proj S h x∥^2 := begin\n        rw [sub_eq_add_neg],\n        conv {to_rhs, rw [←add_zero (∥x - orthog_proj S h x∥ ^ 2)]},\n        apply (real.add_lt_add_iff_left (∥x - orthog_proj S h x∥ ^ 2)).2,\n        exact neg_lt_zero.2 a,\n    end,\n    rw [←min_dist_expr S h x y k₂] at w₃,\n    rw [←norm_sqr_leq_iff_norm_leq] at w₁,\n    rw [lt_iff_not_ge] at w₃,\n    exact absurd w₁ w₃,\n    exact norm_nonneg _,\nend\n\nlemma orthog_proj_norm_leq (x : α) : ∥orthog_proj S h x∥ ≤ ∥x∥ :=\nbegin\n    have k₁ := orthog_of_orthog_proj_sub S h x,\n    dsimp [perp] at k₁,\n    have w := pythagoras (k₁ (orthog_proj S h x) (orthog_proj_mem S h x)),\n    rw [add_assoc, add_left_neg, add_zero, add_comm] at w,\n    rw [←@norm_sqr_leq_iff_norm_leq _ _ _ _ (norm_nonneg _)],\n    exact @leq_of_add_nonneg _ _ _ (sqr_nonneg _) (sqr_nonneg _) (sqr_nonneg _) w,\nend\n\nlemma orthog_proj_has_bound : ∃ M > 0, ∀ x : α, ∥orthog_proj S h x ∥ ≤ M * ∥ x ∥ :=\nbegin\n    use 1,\n    use zero_lt_one,\n    intros x,\n    rw [one_mul],\n    exact orthog_proj_norm_leq S h x,\nend\n\ntheorem orthog_direct_sum_exists (x : α) : ∃ (u ∈ S), ∃ (v ∈ perp S.carrier), x = u + v :=\nbegin\n    use orthog_proj S h x,\n    use orthog_proj_mem S h x,\n    use (x-orthog_proj S h x),\n    use orthog_of_orthog_proj_sub S h x,\n    simp,\nend\n\ntheorem orthog_direct_sum_unique (x u₁ u₂ v₁ v₂ : α) (U₁ : u₁ ∈ S) (U₂ : u₂ ∈ S) (V₁ : v₁ ∈ perp S.carrier) (V₂ : v₂ ∈ perp S.carrier)\n(k₁ : x = u₁ + v₁) (k₂ : x = u₂ + v₂) : (u₁ = u₂ ∧ v₁ = v₂) :=\nbegin\n    rw [k₁] at k₂,\n    have k₃ : u₁ - u₂ = v₂ - v₁ := begin\n        have l₁ := congr_arg (λ (z : α), z - u₂ - v₁) k₂,\n        simp at l₁,\n        rw [sub_eq_add_neg],\n        exact l₁,\n    end,\n    have w₁ := sub_mem S U₁ U₂,\n    have w₂ := @sub_mem ℝ α _ _ _ (@perp_subspace α _ _ _ _ S.carrier) v₂ v₁ V₂ V₁,\n    have w₃ : u₁ - u₂ ∈ S.carrier ∩ perp S.carrier := begin\n        split,\n        exact w₁,\n        rw [k₃],\n        exact w₂,\n    end,\n    rw [@perp_int_trivial α _ _ _ _ S.carrier (zero_mem S)] at w₃,\n    have w₄ := sub_eq_zero.1 (eq_of_mem_singleton w₃),\n    rw [k₃] at w₃,\n    exact ⟨w₄, (sub_eq_zero.1 (eq_of_mem_singleton w₃)).symm⟩,\nend\n\ntheorem orthog_proj_of_orthog_direct_sum (x u v : α) (U : u ∈ S) (V : v ∈ perp S.carrier) (k : x = u + v) : orthog_proj S h x = u :=\nbegin\n    have w₁ := orthog_direct_sum_unique S h x u (orthog_proj S h x) v (x - orthog_proj S h x) U (orthog_proj_mem S h x) V (orthog_of_orthog_proj_sub S h x) k (by simp),\n    cases w₁,\n    exact (w₁_left).symm,\nend\n\nlemma orthog_proj_add (x y : α) : orthog_proj S h (x+y) = orthog_proj S h x + orthog_proj S h y :=\nbegin\n    have w₁ := orthog_direct_sum_exists S h x,\n    rcases w₁ with ⟨ux, Ux, vx, Vx, w₁⟩,\n    have w₂ := orthog_direct_sum_exists S h y,\n    rcases w₂ with ⟨uy, Uy, vy, Vy, w₂⟩,\n    have w₃ := orthog_proj_of_orthog_direct_sum S h x ux vx Ux Vx w₁,\n    have w₄ := orthog_proj_of_orthog_direct_sum S h y uy vy Uy Vy w₂,\n    rw [w₃, w₄],\n    have w₅ : x + y = (ux + uy) + (vx + vy) := begin\n        rw [w₁, w₂],\n        simp,\n    end,\n    exact (orthog_proj_of_orthog_direct_sum S h (x+y) (ux+uy) (vx+vy) (add_mem S Ux Uy) (add_mem (perp_subspace) Vx Vy) w₅),\nend\n\nlemma orthog_proj_smul (c : ℝ) (x : α) : orthog_proj S h (c • x) = c • (orthog_proj S h x) :=\nbegin\n    have w₁ := orthog_direct_sum_exists S h x,\n    rcases w₁ with ⟨u, U, v, V, w₁⟩,\n    have w₂ := orthog_proj_of_orthog_direct_sum S h x u v U V w₁,\n    rw [w₂],\n    have w₃ : c•x = c•u + c•v := begin\n        rw [←smul_add, w₁],\n    end,\n    have w₅ := orthog_proj_of_orthog_direct_sum S h (c•x) (c•u) (c•v) (smul_mem S c U) (smul_mem (@perp_subspace α _ _ _ _ S.carrier) c V) w₃,\n    rw [w₅],\nend\n\ndef orthog_proj_linear : is_linear_map ℝ (orthog_proj S h) :=\n{add := orthog_proj_add S h, smul := orthog_proj_smul S h}\n\nlemma perp_of_orthog_proj_zero (x : α) (w : orthog_proj S h x = 0) : x ∈ perp S.carrier :=\nbegin\n    have w₁ := orthog_direct_sum_exists S h x,\n    rcases w₁ with ⟨u, U, v, V, w₁⟩,\n    dsimp [perp, orthog] at *,\n    intros y k,\n    rw [w₁, add_left],\n    have w₂ := orthog_proj_of_orthog_direct_sum S h x u v U V w₁,\n    rw [w] at w₂,\n    rw [←w₂, right_orthog_to_zero, zero_add],\n    exact V y k,\nend\n\ntheorem ker_orthog_img : (linear_map.ker (is_linear_map.mk' (orthog_proj S h) (orthog_proj_linear S h))).carrier = @perp α _ _ _ _ (linear_map.range ((is_linear_map.mk' (orthog_proj S h) (orthog_proj_linear S h)))).carrier :=\nbegin\n    ext,\n    rw [←sub_simp, mem_ker],\n    split,\n\n    intros k,\n    dsimp [perp],\n    intros y w,\n    rw [←sub_simp] at w,\n    simp at w,\n    cases w with z w,\n    simp at k,\n    have w₁ := perp_of_orthog_proj_zero S h x k,\n    have w₂ := orthog_proj_mem S h z,\n    rw [w] at w₂,\n    dsimp [perp] at w₁,\n    exact w₁ y w₂,\n\n    dsimp [perp],\n    intros w,\n    apply orthog_proj_zero_on_perp_S,\n    dsimp [perp],\n    intros y k,\n    have w₁ := orthog_proj_id_on_S S h y k,\n    have w₂ := w y,\n    rw [←sub_simp] at w₂,\n    simp at w₂,\n    exact w₂ y w₁,\nend\n\nlemma orthog_proj_is_symmetric (x y : α) : ⟪orthog_proj S h x ∥ y⟫ = ⟪x ∥ orthog_proj S h y⟫ :=\nbegin\n    have w₁ := orthog_direct_sum_exists S h x,\n    rcases w₁ with ⟨u₁, U₁, v₁, V₁, w₁⟩,\n    have w₂ := orthog_direct_sum_exists S h y,\n    rcases w₂ with ⟨u₂, U₂, v₂, V₂, w₂⟩,\n    rw [w₁, w₂],\n    simp [orthog_proj_add],\n    dsimp [perp] at *,\n    have k₁ := V₂ (orthog_proj S h u₁) (orthog_proj_mem S h u₁),\n    have k₂ := orthog_proj_zero_on_perp_S S h v₁ V₁,\n    have k₃ := orthog_proj_zero_on_perp_S S h v₂ V₂,\n    have k₄ := V₁ (orthog_proj S h u₂) (orthog_proj_mem S h u₂),\n    dsimp [orthog] at *,\n    rw [conj_symm] at k₁,\n    rw [k₁, zero_add, k₂, right_orthog_to_zero, right_orthog_to_zero, add_zero, add_zero,\n        k₃, left_orthog_to_zero, left_orthog_to_zero, add_zero, zero_add, k₄, add_zero,\n        orthog_proj_id_on_S S h u₁ U₁, orthog_proj_id_on_S S h u₂ U₂],\nend\n\nlemma orthog_proj_is_bounded_linear_map : is_bounded_linear_map ℝ (orthog_proj S h) :=\nbegin\n    constructor,\n\n    constructor,\n    exact orthog_proj_add S h,\n    exact orthog_proj_smul S h,\n\n    exact orthog_proj_has_bound S h,\nend\n\nend orthogonal_projection\n\nsection riesz_representation\n\nlocal attribute [instance] classical.prop_decidable\n\nvariables (f : α →ₗ[ℝ] ℝ)\n\nlemma fun_coe : ⇑f = f.to_fun := rfl\n\nvariables [Hilbert_space α]\nvariables (S : @submodule ℝ α _ _ _)\n\nlemma perp_trivial_of_subspace_all (h : @is_closed α α_topological_space S.carrier) (k₁ : ∀ (x : α), x ∈ S) (y : α) (k₂ : y ∈ perp S.carrier) : y = 0 :=\nby {dsimp [perp] at k₂, exact zero_of_orthog_self (k₂ y (k₁ y))}\n\nlemma perp_nonempty_of_subspace_not_all (h : @is_closed α α_topological_space S.carrier) : (∃ (x : α), x ∉ S) → (∃ (y : α), y ≠ 0 ∧ y ∈ perp S.carrier) :=\nbegin\n    rw [awesome_mt],\n    simp,\n    intros k,\n    intros x,\n    have k₁ := orthog_direct_sum_exists S h x,\n    rcases k₁ with ⟨u, ⟨U, ⟨v, ⟨V, k₁⟩⟩⟩⟩,\n    rw [k₁],\n    have k₂ := k v,\n    rw [awesome_mt] at k₂,\n    simp at k₂,\n    have k₃ := k₂ V,\n    rw [k₃, add_zero],\n    exact U,\nend\n\nlemma perp_nonempty_of_subspace_not_all' (h : @is_closed α α_topological_space S.carrier) (k : ∃ (x : α), x ∉ S) : ∃ (y : α), ∥y∥=1 ∧ y ∈ perp S.carrier :=\nbegin\n    have k₁ := perp_nonempty_of_subspace_not_all S h k,\n    rcases k₁ with ⟨z, k₁, k₂⟩,\n    use ((1/∥z∥)•z),\n    exact ⟨norm_one_of_norm_inv z k₁, smul_mem perp_subspace (1/∥z∥) k₂⟩,\nend\n\ntheorem riesz_rep_exists (w : @is_bounded_linear_map ℝ _ α ip_space_is_normed_space _ _ f) : ∃ (x : α), f.to_fun = ip_map x :=\nbegin\n    have w₁ := @bounded_functional_ker_closed α _ _ _ _ f w,\n    have w₂ := orthog_direct_sum_exists (linear_map.ker f) w₁,\n    by_cases k : (∀ (x : α), x ∈ linear_map.ker f),\n\n    use 0,\n    ext,\n    simp,\n    have w₃ := w₂ x,\n    cases w₃ with u w₃,\n    cases w₃ with w₃ w₄,\n    cases w₄ with v w₄,\n    cases w₄ with w₄ w₅,\n    rw [w₅, linear_map.add],\n    simp at w₃,\n    rw [fun_coe] at w₃,\n    simp [w₃],\n    have w₆ := perp_trivial_of_subspace_all (linear_map.ker f) w₁ k v w₄,\n    rw [w₆],\n    exact linear_map.map_zero f,\n\n    rw [not_forall] at k,\n    have k₁ := perp_nonempty_of_subspace_not_all' (linear_map.ker f) w₁ k,\n    rcases k₁ with ⟨z, ⟨k₁, k₂⟩⟩,\n    use ((f z) • z),\n    ext,\n    have k₃ : (f x) • z - (f z) • x ∈ linear_map.ker f := begin\n        simp,\n        ring,\n    end,\n    dsimp [perp] at k₂,\n    rw [←mul_one (f.to_fun x), ←mul_one ((f.to_fun x)*1), mul_assoc, ←pow_two, ←k₁, sqr_norm],\n    dsimp [norm_sq],\n    rw [←mul_left, ←add_zero (f.to_fun x • z), ←add_left_neg (f.to_fun z • x), ←add_assoc,\n    add_left],\n    have k₄ := k₂ _ k₃,\n    dsimp [orthog] at k₄,\n    rw [conj_symm, fun_coe] at k₄,\n    rw [k₄, zero_add, fun_coe, mul_left, conj_symm, ←mul_left],\nend\n\ntheorem riesz_rep_unique {x y : α} (h : f.to_fun = ip_map x) (w : f.to_fun = ip_map y) : x = y :=\nbegin\n    apply left_ext x y,\n    intros z,\n    rw [h, fun_coe, fun_coe] at w,\n    dsimp [ip_map] at w,\n    have k₁ := @congr_arg _ _ z z (λ z, inner_product x z) rfl,\n    conv at k₁ {to_rhs, rw [w]},\n    exact k₁,\nend\n\nend riesz_representation\n\nsection adjoint\n\nvariables (f : α →ₗ[ℝ] α)\nvariables (h : @is_bounded_linear_map ℝ _ α ip_space_is_normed_space α ip_space_is_normed_space f)\nvariables [Hilbert_space α]\n\ninclude f h\n\ndef adjoint_map (y : α): α →ₗ[ℝ] ℝ :=\nbegin\n    refine_struct {..},\n    use (λ x, ⟪f x ∥ y⟫),\n    repeat {simp},\nend\n\nlemma adjoint_map_fun (y : α) : (adjoint_map f h y).to_fun = λ x, ⟪f.to_fun x ∥ y⟫ := rfl\n\nlemma adjoint_map_bounded (y : α) : @is_bounded_linear_map ℝ _ α ip_space_is_normed_space _ _ (adjoint_map f h y) :=\nbegin\n    constructor,\n\n    constructor,\n    repeat {simp},\n\n    have h₁ := @is_bounded_linear_map.bound ℝ _ α ip_space_is_normed_space α ip_space_is_normed_space f h,\n    by_cases (y=0),\n\n    use 1,\n    use zero_lt_one,\n    intros x,\n    have w₁ : (λ (x : α), ⟪f.to_fun x ∥ 0⟫) x = ⟪f.to_fun x ∥ 0⟫ := rfl,\n    rw [fun_coe, adjoint_map_fun, h, w₁, left_orthog_to_zero, norm_zero, one_mul],\n    apply norm_nonneg _,\n\n    rcases h₁ with ⟨M, H, h₁⟩,\n    use M*∥y∥,\n    rw [←ne.def] at h,\n    have w₁ := (@norm_pos_iff α ip_space_is_normed_group y).2 h,\n    use mul_pos H w₁,\n    intros x,\n    apply le_trans (cauchy_schwarz (f x) y),\n    rw [mul_assoc, mul_comm ∥y∥, ←mul_assoc],\n    apply (mul_le_mul_right w₁).2,\n    exact h₁ x,\nend\n\ndef adjoint_to_fun : α → α :=\nλ y, classical.some (riesz_rep_exists (adjoint_map f h y) (adjoint_map_bounded f h y))\n\nlemma adjoint_ip_switch (x y : α) : ⟪f x ∥ y⟫ = ⟪x ∥ adjoint_to_fun f h y⟫ :=\nbegin\n    have w := classical.some_spec (riesz_rep_exists (adjoint_map f h y) (adjoint_map_bounded f h y)),\n    have k := adjoint_map_fun f h y,\n    rw [w] at k,\n    simp at k,\n    dsimp [adjoint_to_fun],\n    have k' := @congr_arg _ _ x x (λ (x : α), ⟪f.to_fun x ∥ y⟫) rfl,\n    conv at k' {to_rhs, rw [←k, conj_symm]},\n    exact k',\nend\n\nlemma adjoint_ip_switch' (x y : α) : ⟪adjoint_to_fun f h x ∥ y⟫ = ⟪x ∥ f y⟫ :=\nby {rw [conj_symm, ←adjoint_ip_switch, conj_symm]}\n\nlemma adjoint_to_fun_unique (S : α → α) (w : ∀ (x y : α), ⟪f x ∥ y⟫ = ⟪x ∥ S y⟫) : S = adjoint_to_fun f h :=\nbegin\n    ext,\n    apply @left_ext α _ _ _ _ _ _,\n    intros z,\n    have w' := w z x,\n    have k := (adjoint_ip_switch f h) z x,\n    rw [w', conj_symm, conj_symm z] at k,\n    exact k,\nend\n\nlemma adjoint_to_fun_add (x y : α) : adjoint_to_fun f h (x+y) = adjoint_to_fun f h x + adjoint_to_fun f h y :=\nbegin\n    apply @left_ext α _ _ _ _ _ _,\n    intros z,\n    rw [add_left, adjoint_ip_switch', adjoint_ip_switch', adjoint_ip_switch', add_left],\nend\n\nlemma adjoint_to_fun_smul (c : ℝ) (x : α) : adjoint_to_fun f h (c • x) = c • adjoint_to_fun f h x :=\nbegin\n    apply @left_ext α _ _ _ _ _ _,\n    intros z,\n    rw [adjoint_ip_switch', mul_left, mul_left, adjoint_ip_switch'],\nend\n\ndef adjoint : α →ₗ[ℝ] α :=\n{to_fun := adjoint_to_fun f h, add := adjoint_to_fun_add f h, smul := adjoint_to_fun_smul f h}\n\nlocal attribute [instance] α_normed_space\n\nlemma adjoint_fun : (adjoint f h).to_fun = adjoint_to_fun f h := rfl\n\nlemma adjoint_bounded : @is_bounded_linear_map ℝ _ α ip_space_is_normed_space α ip_space_is_normed_space (adjoint f h):=\nbegin\n    constructor,\n    constructor,\n    exact adjoint_to_fun_add f h,\n    exact adjoint_to_fun_smul f h,\n\n    have w := h.bound,\n    rcases w with ⟨M, H, w⟩,\n    use M,\n    use H,\n\n    have k : ∀ (x y : α), ∥⟪adjoint_to_fun f h x ∥ y⟫∥≤M*∥x∥*∥y∥ := begin\n        intros x y,\n        rw [adjoint_ip_switch'],\n        apply le_trans (cauchy_schwarz x _),\n        have k := w y,\n        by_cases (x=0),\n\n        revert h,\n        intros l,\n        rw [l, norm_zero, zero_mul, mul_zero, zero_mul],\n\n        revert h,\n        intros l,\n        rw [←ne.def] at l,\n        rw [mul_comm, mul_assoc, mul_comm ∥x∥, ←mul_assoc],\n        apply (mul_le_mul_right ((norm_pos_iff x).2 l)).2,\n        exact k,\n    end,\n    intros x,\n    by_cases (∥(adjoint f h).to_fun x∥ = 0),\n    have k₁ : 0 ≤ M * ∥x∥ := mul_nonneg (le_of_lt H) (norm_nonneg x),\n    rw [←h] at k₁,\n    exact k₁,\n\n    revert h,\n    intros l,\n    rw [←ne.def] at l,\n    have k₁ := k x (adjoint_to_fun f h x),\n    have k₂ := @sqr_norm α _ _ _ _ (adjoint_to_fun f h x),\n    dsimp [norm_sq] at k₂,\n    rw [←k₂, norm_sqr_eq_sqr, pow_two] at k₁,\n    have k₄ := mul_le_mul_of_nonneg_right k₁ ((inv_nonneg.mpr (norm_nonneg (adjoint_to_fun f h x)))),\n    rw [mul_assoc, mul_inv_cancel, mul_one, mul_assoc, mul_inv_cancel, mul_one] at k₄,\n    exact k₄,\n    rw [adjoint_fun] at l,\n    repeat {exact l},\nend\n\nlemma adjoint_ext (S : α →ₗ[ℝ] α) (k : ∀ (x y : α), ⟪f x ∥ y⟫ = ⟪x ∥ S y⟫) : S = adjoint f h :=\nbegin\n    ext,\n    have k₁ := adjoint_to_fun_unique f h _ k,\n    simp only [] at k₁,\n    rw [k₁, ←adjoint_fun],\n    refl,\nend\n\nlemma adjoint_is_involution : adjoint (adjoint f h) (adjoint_bounded f h) = f :=\nbegin\n    apply eq.symm,\n    apply adjoint_ext _ _,\n    intros x y,\n    exact adjoint_ip_switch' f h x y,\nend\n\nend adjoint\n\n\n", "meta": {"author": "MartinSkilleter", "repo": "real_ip_spaces", "sha": "1ad1e0456602038711cbb0de7aa92b88d6eff06f", "save_path": "github-repos/lean/MartinSkilleter-real_ip_spaces", "path": "github-repos/lean/MartinSkilleter-real_ip_spaces/real_ip_spaces-1ad1e0456602038711cbb0de7aa92b88d6eff06f/src/inner_product_spaces/real_ip/orthogonality.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.484347204363711}}
{"text": "import data.int.interval\nimport algebra.big_operators.ring\nimport data.fintype.card\nimport category_theory.Fintype\nimport topology.order\nimport topology.separation\nimport topology.subset_properties\nimport data.real.nnreal\n\n/-!\n\n# \\overline{\\mathcal{M}}_r(S)_{\\leq c}\n\nThroughout, `S` is finite (not profinite).\n\n`ℳ-bar_{r'}(S)_{≤c}` is the filtration on `ℳ-bar_{r'}(S)` by profinite subsets described\nat the beginning of section 9 of `analytic.pdf`. It's defined not as a subset\nof `ℳ-bar_{r'}(S)` but as an independent type. It's a projective limit of\ntypes `Lbar_bdd r' S c M` which have an additional hypothesis that the power\nseries involved are actually polynomials of degree at most `M`.\n\n## Main definitions\n\n- `Lbar_bdd r' S c M`: the subset of `S → Tℤ[[T]]/(T^{M+1})` consisting of\n  elements `F_s = ∑_{n=1}^M a_{n,s} T^n` such that `∑_{s,n} |a_{n,s}| (r')^n ≤ c`.\n- `Lbar_bdd.limit r' S c`: the projective limit of `Lbar_bdd r' S c M`, as a subtype\n  of the product.\n\n-/\nnoncomputable theory\nopen_locale big_operators classical nnreal\nopen set\n\n/-- `Lbar_bdd r' S c M` is the subset of `S → Tℤ[[T]]/(T^{M+1})` consisting of elements\n`F_s = ∑_{n=1}^M a_{n,s} T^n` such that `∑_{s,n} |a_{n,s}| r^n ≤ c`.\nThis is an auxiliary object used to define the profinite topology on `Lbar r' S`. -/\nstructure Lbar_bdd (r : ℝ≥0) (S : Fintype) (c : ℝ≥0) (M : ℕ) :=\n(to_fun      : S → fin (M + 1) → ℤ)\n(coeff_zero' : ∀ s, to_fun s 0 = 0)\n(sum_le'     : (∑ s i, (↑(to_fun s i).nat_abs * r^(i : ℕ))) ≤ c)\n\nnamespace Lbar_bdd\n\nvariables {r' : ℝ≥0} {S : Fintype} {c c₁ c₂ : ℝ≥0} {M : ℕ}\n\ninstance has_coe_to_fun : has_coe_to_fun (Lbar_bdd r' S c M) (λ _, S → fin (M + 1) → ℤ) :=\n⟨Lbar_bdd.to_fun⟩\n\n@[simp] lemma coe_mk (x h₁ h₂) : ((⟨x, h₁, h₂⟩ : Lbar_bdd r' S c M) : S → ℕ → ℤ) = x := rfl\n\n@[simp] protected lemma coeff_zero (x : Lbar_bdd r' S c M) (s : S) : x s 0 = 0 := x.coeff_zero' s\n\nprotected lemma sum_le (x : Lbar_bdd r' S c M) :\n  (∑ s i, ((↑(x s i).nat_abs * r'^(i:ℕ)))) ≤ c := x.sum_le'\n\n/-- The obvious map from `Lbar_bdd r' S c₁ M` to `Lbar_bdd r' S c₂ M`, for `c₁ ≤ c₂`. -/\nprotected def cast_le [hc : fact (c₁ ≤ c₂)] (x : Lbar_bdd r' S c₁ M) : Lbar_bdd r' S c₂ M :=\n⟨x.1, x.coeff_zero, x.sum_le.trans hc.out⟩\n\n@[ext] lemma ext (x y : Lbar_bdd r' S c M) (h : (⇑x : S → fin (M + 1) → ℤ) = y) : x = y :=\nby { cases x, cases y, congr, exact h }\n\ninstance : has_zero (Lbar_bdd r' S c M) :=\n{ zero :=\n  { to_fun := 0,\n    coeff_zero' := λ s, rfl,\n    sum_le' := by simp only [zero_mul, pi.zero_apply, finset.sum_const_zero,\n      nat.cast_zero, zero_le', int.nat_abs_zero] } }\n\ninstance : inhabited (Lbar_bdd r' S c M) := ⟨0⟩\n\nlemma coeff_bound [h0r : fact (0 < r')] (F : S → fin (M + 1) → ℤ)\n  (hF : ∑ s i, (↑(F s i).nat_abs * r'^(i : ℕ)) ≤ c) (n : fin (M + 1)) (s : S) :\n  ↑(F s n).nat_abs ≤ c / min (r' ^ M) 1 :=\nbegin\n  rw [div_eq_mul_inv],\n  apply le_mul_inv_of_mul_le ((lt_min (pow_pos h0r.out _) zero_lt_one).ne.symm),\n  calc ↑(F s n).nat_abs * min (r' ^ M) 1 ≤ ↑(F s n).nat_abs * r' ^ (n:ℕ) : _ -- see below for proof\n  ... ≤ ∑ i, (↑(F s i).nat_abs * r' ^ (i:ℕ)) :\n    finset.single_le_sum (λ (i : fin (M + 1)) _, _) (finset.mem_univ n)\n  ... ≤ ∑ s i, (↑(F s i).nat_abs * r'^(i:ℕ)) :\n    by { refine finset.single_le_sum (λ _ _, _) (finset.mem_univ s),\n      exact finset.sum_nonneg (λ _ _, (subtype.property (_ : ℝ≥0))) }\n  ... ≤ c : hF,\n  { refine mul_le_mul_of_nonneg_left _ (subtype.property (_ : ℝ≥0)),\n    cases le_or_lt r' 1 with hr1 hr1,\n    { refine le_trans (min_le_left _ _) _,\n      exact pow_le_pow_of_le_one h0r.out.le hr1 (nat.lt_add_one_iff.1 n.2) },\n    { exact le_trans (min_le_right _ _) (one_le_pow_of_one_le (le_of_lt hr1) _) } },\n  apply subtype.property (_ : ℝ≥0)\nend\n\n/-- An auxiliary function used to prove finiteness of `Lbar_bdd r' S c M`. -/\nprivate def temp_map [fact (0 < r')] (F : Lbar_bdd r' S c M) (n : fin (M + 1)) (s : S) :\n  Icc (⌈(-(c / min (r' ^ M) 1) : ℝ)⌉) (⌊(c / min (r' ^ M) 1 : ℝ)⌋) :=\nhave h : (-(c / min (r' ^ M) 1) : ℝ) ≤ F s n ∧ (F s n : ℝ) ≤ (c / min (r' ^ M) 1 : ℝ),\nby { rw [← abs_le, ← real.coe_nnabs, ← real.cast_nat_abs_eq_nnabs_cast],\n    exact_mod_cast coeff_bound F F.sum_le n s },\n⟨F s n, int.ceil_le.2 h.1, int.le_floor.2 h.2⟩\n\ninstance [fact (0 < r')] : fintype (Lbar_bdd r' S c M) :=\nfintype.of_injective temp_map\nbegin\n  rintros ⟨f1, hf1, hf1'⟩ ⟨f2, hf2, hf2'⟩ h,\n  ext s n,\n  change (temp_map ⟨f1, hf1, hf1'⟩ n s).1 = (temp_map ⟨f2, hf2, hf2'⟩ n s).1,\n  rw h,\nend\n\n/-- The transition map from `Lbar_bdd r' S c N` to `Lbar_bdd r' S c M`, given `M ≤ N`. -/\ndef transition (r' : ℝ≥0) {S : Fintype} {c : ℝ≥0} {M N : ℕ} (h : M ≤ N) (x : Lbar_bdd r' S c N) :\n  Lbar_bdd r' S c M :=\n{ to_fun := λ s i, x s (fin.cast_le (add_le_add_right h 1) i),\n  coeff_zero' := λ s, x.coeff_zero _,\n  sum_le' :=\n  begin\n    refine le_trans _ x.sum_le,\n    apply finset.sum_le_sum,\n    intros s hs,\n    let I := finset.map (fin.cast_le (add_le_add_right h 1)).to_embedding\n      (finset.univ : finset (fin (M+1))),\n    refine le_trans _\n      (finset.sum_le_sum_of_subset_of_nonneg (finset.subset_univ I) _),\n    { rw finset.sum_map,\n      apply le_of_eq,\n      congr },\n    { intros, exact subtype.property (_ : ℝ≥0) }\n  end }\n\nlemma transition_eq {r' : ℝ≥0} {S : Fintype} {c : ℝ≥0} {M N : ℕ} (h : M ≤ N)\n  (F : Lbar_bdd r' S c N) (s : S) (i : fin (M+1)) :\n  (transition r' h F).1 s i = F.1 s (fin.cast_le (add_le_add_right h 1) i) := rfl\n\nlemma transition_transition {r' : ℝ≥0} {S : Fintype} {c : ℝ≥0}\n  {M N K : ℕ} (h : M ≤ N) (hh : N ≤ K) (x : Lbar_bdd r' S c K) :\n  transition r' h (transition r' hh x) = transition r' (le_trans h hh) x := rfl\n\nlemma transition_cast_le {N : ℕ} (h : M ≤ N) [hc : fact (c₁ ≤ c₂)] (x : Lbar_bdd r' S c₁ N) :\n  transition r' h (Lbar_bdd.cast_le x : Lbar_bdd r' S c₂ N) =\n    Lbar_bdd.cast_le (transition r' h x) := rfl\n\n/-- The limit of `Lbar_bdd r' S c M` along the `transition` maps as `M` increases. -/\nabbreviation limit (r' S c) :=\n{ F : Π (M : ℕ), Lbar_bdd r' S c M // ∀ (M N : ℕ) (h : M ≤ N), transition r' h (F N) = F M }\n\n/-- The obvious embedding `Lbar_bdd.limit r' S c`\ninto the product of `Lbar_bdd r' S c M` as `M` varies. -/\ndef emb_aux : limit r' S c → (Π (M : ℕ), Lbar_bdd r' S c M) := coe\n\nsection topological_structure\n\ninstance : topological_space (Lbar_bdd r' S c M) := ⊥\ninstance : discrete_topology (Lbar_bdd r' S c M) := ⟨rfl⟩\n\n-- sanity check\nexample : t2_space (limit r' S c) := by apply_instance\nexample : totally_disconnected_space (limit r' S c) := by apply_instance\nexample [fact (0 < r')] : compact_space (Lbar_bdd r' S c M) := by apply_instance\n\nlemma emb (r' S c) : closed_embedding (@emb_aux r' S c) :=\n{ induced := rfl,\n  inj := subtype.coe_injective,\n  closed_range :=\n  begin\n    have : range emb_aux = ⋂ (x : {y : ℕ × ℕ // y.1 ≤ y.2}),\n      {F : Π M, Lbar_bdd r' S c M | transition r' x.2 (F x.val.2) = F x.val.1},\n    { ext,\n      simp only [emb_aux, prod.forall, mem_Inter, mem_set_of_eq,\n        subtype.range_coe_subtype, subtype.forall], },\n    rw this,\n    apply is_closed_Inter,\n    rintros ⟨⟨m, n⟩, h0 : m ≤ n⟩,\n    refine is_closed_eq (continuous.comp _ $ continuous_apply _) (continuous_apply _),\n    exact continuous_of_discrete_topology,\n  end }\n\ninstance [fact (0 < r')] : compact_space (limit r' S c) :=\nbegin\n  erw [← is_compact_iff_compact_space, is_compact_iff_is_compact_univ,\n    compact_iff_compact_in_subtype],\n  apply is_closed.is_compact,\n  exact (emb r' S c).is_closed_map _ is_closed_univ\nend\n\n/-- The projection from `Lbar_bdd.limit r' S c M` to `Lbar_bdd r' S c M`.  -/\ndef proj (M : ℕ) : Lbar_bdd.limit r' S c → Lbar_bdd r' S c M := λ F, F.1 M\n\nlemma continuous_iff {α : Type*} [topological_space α] (f : α → Lbar_bdd.limit r' S c) :\n  continuous f ↔ (∀ (M : ℕ), continuous ((proj M) ∘ f)) :=\nbegin\n  split,\n  { intros hf M,\n    exact continuous.comp ((continuous_apply _).comp continuous_subtype_val) hf, },\n  { intros h,\n    rw [embedding.continuous_iff (emb r' S c).to_embedding],\n    exact continuous_pi h }\nend\n\nend topological_structure\n\nsection addition\n\n/-- The addition on `Lbar_bdd r' S c M`.\nIt takes a term of type `Lbar_bdd r' S c₁ M` and a term of type `Lbar_bdd r' S c₂ M`\nand produces a term of type `Lbar_bdd r' S (c₁ + c₂) M`. -/\ndef add (F : Lbar_bdd r' S c₁ M) (G : Lbar_bdd r' S c₂ M) : Lbar_bdd r' S (c₁ + c₂) M :=\n{ to_fun := F + G,\n  coeff_zero' := λ s, by simp,\n  sum_le' :=\n  begin\n    refine le_trans _ (add_le_add F.sum_le G.sum_le),\n    rw ← finset.sum_add_distrib,\n    refine finset.sum_le_sum _,\n    rintro s -,\n    rw ← finset.sum_add_distrib,\n    refine finset.sum_le_sum _,\n    rintro i -,\n    rw ← add_mul,\n    apply mul_le_mul_right',\n    norm_cast,\n    apply int.nat_abs_add_le\n  end }\n\n/-- Negation on `Lbar_bdd r' S c M` -/\ndef neg (F : Lbar_bdd r' S c M) : Lbar_bdd r' S c M :=\n{ to_fun := -F,\n  coeff_zero' := λ s, by simp,\n  sum_le' := by { simp only [abs_neg, pi.neg_apply, int.nat_abs_neg], exact F.sum_le } }\n\nend addition\n\nsection map\n\n-- To avoid defeq nonsense, we need to use ⟨S⟩ as opposed to S.\n-- TODO: Use `Fintype` everywhere?!\n/-- TODO -/\ndef map {S T : Type*} [fintype S] [fintype T] (f : S → T) :\n  Lbar_bdd r' ⟨S⟩ c M → Lbar_bdd r' ⟨T⟩ c M := λ F,\n{ to_fun := λ t i, ∑ s in finset.univ.filter (λ s', f s' = t), F s i,\n  coeff_zero' := by simp,\n  sum_le' := calc\n    ∑ (t : T) (i : fin (M+1)),\n      ↑((∑ (s : S) in finset.univ.filter (λ s', f s' = t), F s i).nat_abs) * r' ^ (i : ℕ)\n    ≤ ∑ (t : T) (i : fin (M+1)),\n      ∑ s in finset.univ.filter (λ s', f s' = t), ↑(F s i).nat_abs * r' ^ (i : ℕ) :\n    begin\n      apply finset.sum_le_sum,\n      rintros t -,\n      apply finset.sum_le_sum,\n      rintros i -,\n      rw ← finset.sum_mul,\n      refine mul_le_mul _ (le_refl _) zero_le' zero_le',\n      rw ← nat.cast_sum,\n      rw nat.cast_le,\n      apply nat_abs_sum_le,\n    end\n    ... ≤ ∑ (s : S) (i : fin (M+1)), ↑(F s i).nat_abs * r' ^ (i : ℕ) :\n    begin\n      rw finset.sum_comm,\n      nth_rewrite 1 finset.sum_comm,\n      apply finset.sum_le_sum,\n      rintro i -,\n      rw ← finset.sum_bUnion,\n      { apply finset.sum_le_sum_of_subset,\n        intros _ _, simp },\n      { rintros t1 - t2 - h s hs,\n        simp at hs ⊢,\n        apply h,\n        rw [← hs.1, ← hs.2] }\n    end\n    ... ≤ _ : F.sum_le }\n\nend map\n\nend Lbar_bdd\n\n#lint-\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/Lbar/bounded.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6297745935070808, "lm_q1q2_score": 0.48434720034204876}}
{"text": "import breen_deligne.constants\nimport system_of_complexes.completion\nimport thm95.homotopy\nimport thm95.col_exact\nimport thm95.row_iso\nimport combinatorial_lemma.profinite\n\n\nnoncomputable theory\n\nuniverses u v\n\nopen_locale nnreal -- enable the notation `ℝ≥0` for the nonnegative real numbers.\n\n\nopen polyhedral_lattice opposite\nopen thm95.universal_constants system_of_double_complexes category_theory breen_deligne\nopen ProFiltPseuNormGrpWithTinv (of)\n\nsection\n\nvariables (r r' : ℝ≥0) [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' < 1)]\nvariables (BD : package)\nvariables (V : SemiNormedGroup.{v}) [normed_with_aut r V]\nvariables (κ κ' : ℕ → ℝ≥0) [BD.data.very_suitable r r' κ]\nvariables (M : ProFiltPseuNormGrpWithTinv.{u} r')\nvariables (m : ℕ)\nvariables (Λ : PolyhedralLattice.{u})\n\ninclude BD κ κ' r r' M V\n\ndef thm95.IH (m : ℕ) : Prop := ∀ Λ : PolyhedralLattice.{u},\n  ​((BD.data.system κ r V r').obj (op $ Hom Λ M)).is_weak_bounded_exact\n    (k κ' m) (K r r' BD κ' m) m (c₀ r r' BD κ κ' m Λ)\n\nomit BD κ κ' r r' M V\n\nlemma NSC_row_exact (IH : ∀ m' < m, thm95.IH r r' BD V κ κ' M m')\n  (h0m : 0 < m) (i : ℕ) (hi : i ≤ m + 1) :\n  ((thm95.double_complex BD.data κ r r' V Λ M (N r r' BD κ' m)).row i).is_weak_bounded_exact\n    (k₁ κ' m) (K₁ r r' BD κ' m) (m - 1) (c₀ r r' BD κ κ' m Λ) :=\nbegin\n  haveI h0m_ : fact (0 < m) := ⟨h0m⟩,\n  have hm' : m - 1 < m := nat.pred_lt h0m.ne',\n  rcases i with (i|i|i),\n  { rw thm95.double_complex.row_zero,\n    refine (IH (m-1) hm' Λ).of_le BD.data.system_admissible _ _ le_rfl _,\n    swap 3,\n    { apply c₀_mono, },\n    all_goals { apply_instance } },\n  { rw thm95.double_complex.row_one,\n    refine (IH (m-1) hm' _).of_le BD.data.system_admissible _ _ le_rfl _,\n    swap 3,\n    { apply c₀_pred_le, exact h0m },\n    all_goals { apply_instance } },\n  { rw thm95.double_complex.row,\n    apply system_of_complexes.rescale_is_weak_bounded_exact,\n    refine (IH (m-1) hm' _).of_le BD.data.system_admissible _ _ le_rfl _,\n    swap 3,\n    { apply c₀_pred_le_of_le, exact hi },\n    all_goals { apply_instance } }\nend\n.\n\nvariables [package.adept BD κ κ']\n\ndef NSC_htpy :\n  normed_spectral_homotopy\n    ((thm95.double_complex BD.data κ r r' V Λ M (N r r' BD κ' m)).row_map 0 1)\n      m (k' κ' m) (ε r r' BD κ' m) (c₀ r r' BD κ κ' m Λ) (H r r' BD κ' m) :=\n(NSH_aux BD r r' V κ κ' m Λ (op (Hom Λ M))).of_iso _ _ _\n  (iso.refl _) (thm95.mul_rescale_iso_row_one BD.data κ r V _ _ (by norm_cast) Λ M)\n  (λ _ _ _, rfl) (thm95.mul_rescale_iso_row_one_strict BD.data κ r V _ _ (by norm_cast) Λ M)\n  (by apply thm95.row_map_eq_sum_comp)\n\ndef NSC (IH : ∀ m' < m, thm95.IH r r' BD V κ κ' M m')\n  [pseudo_normed_group.splittable (Λ →+ M) (N r r' BD κ' m) (lem98.d Λ (N r r' BD κ' m))] :\n  normed_spectral_conditions (thm95.double_complex BD.data κ r r' V Λ M (N r r' BD κ' m)) m\n    (k₁ κ' m) (K₁ r r' BD κ' m) (k' κ' m) (ε r r' BD κ' m) (c₀ r r' BD κ κ' m Λ) (H r r' BD κ' m) :=\n{ row_exact := NSC_row_exact _ _ _ _ _ _ _ _ _ IH,\n  col_exact :=\n  begin\n    let N := N r r' BD κ' m,\n    haveI : fact (r < 1) := ⟨(fact.out _ : r < r').trans (fact.out _ : r' < 1)⟩,\n    intros j hj,\n    refine thm95.col_exact BD.data κ r r' V Λ M N j (lem98.d Λ N) (k₁_sqrt κ' m) m _ _\n      (k₁ κ' m) (K₁ r r' BD κ' m) (le_of_eq _) _ _ (c₀ r r' BD κ κ' m Λ) ⟨le_rfl⟩ infer_instance ⟨le_rfl⟩,\n    { apply c₀_spec, assumption', },\n    { ext, delta k₁_sqrt, dsimp, simp only [real.mul_self_sqrt, nnreal.zero_le_coe], },\n    { apply K₁_spec }\n  end,\n  htpy := NSC_htpy r r' BD V κ κ' M m Λ,\n  admissible := thm95.double_complex_admissible _ }\n\ninclude BD κ κ' r r' m\n\n/-- A variant of Theorem 9.5 in [Analytic] using weak bounded exactness. -/\ntheorem thm95' : ∀ (Λ : PolyhedralLattice.{u}) (S : Type u) [fintype S]\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n  ​((BD.data.system κ r V r').obj (op $ Hom Λ (Lbar r' S))).is_weak_bounded_exact\n    (k κ' m) (K r r' BD κ' m) m (c₀ r r' BD κ κ' m Λ) :=\nbegin\n  apply nat.strong_induction_on m; clear m,\n  introsI m IH Λ S _S_fin V _V_r,\n  haveI : pseudo_normed_group.splittable\n    (Λ →+ (of r' (Lbar r' S))) (N r r' BD κ' m) (lem98.d Λ (N r r' BD κ' m)) :=\n    lem98_finite Λ S (N r r' BD κ' m),\n  let cond := NSC.{u} r r' BD V κ κ' (of r' $ Lbar r' S) m Λ _,\n  swap,\n  { introsI m' hm' Λ,\n    apply IH, assumption },\n  exact normed_spectral cond\nend\n\n/-- A variant of Theorem 9.5 in [Analytic] using weak bounded exactness. -/\ntheorem thm95'.profinite : ∀ (Λ : PolyhedralLattice.{u}) (S : Profinite.{u})\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n  ​((BD.data.system κ r V r').obj (op $ Hom Λ ((Lbar.functor.{u u} r').obj S))).is_weak_bounded_exact\n    (k κ' m) (K r r' BD κ' m) m (c₀ r r' BD κ κ' m Λ) :=\nbegin\n  apply nat.strong_induction_on m; clear m,\n  introsI m IH Λ S V _V_r,\n  haveI : pseudo_normed_group.splittable\n    (Λ →+ (of r' ((Lbar.functor.{u u} r').obj S))) (N r r' BD κ' m) (lem98.d Λ (N r r' BD κ' m)) :=\n    lem98.main r' Λ S (N r r' BD κ' m),\n  let cond := NSC.{u} r r' BD V κ κ' (of r' $ (Lbar.functor.{u u} r').obj S) m Λ _,\n  swap,\n  { introsI m' hm' Λ,\n    apply IH, assumption },\n  exact normed_spectral cond\nend\n\nomit BD κ κ' r r' m\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm95 (Λ : PolyhedralLattice.{u}) (S : Type u) [fintype S]\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V] :\n  ((BD.data.system κ r V r').obj (op $ Hom Λ (Lbar r' S))).is_bounded_exact\n    (k κ' m ^ 2) (K r r' BD κ' m + 1) m (c₀ r r' BD κ κ' m Λ) :=\nbegin\n  refine system_of_complexes.is_weak_bounded_exact.strong_of_complete\n    _ (thm95' r r' BD κ κ' m Λ S V) _ 1 zero_lt_one,\n  apply data.system_admissible\nend\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm95.profinite (Λ : PolyhedralLattice.{u}) (S : Profinite.{u})\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V] :\n  ((BD.data.system κ r V r').obj (op $ Hom Λ ((Lbar.functor.{u u} r').obj S))).is_bounded_exact\n    (k κ' m ^ 2) (K r r' BD κ' m + 1) m (c₀ r r' BD κ κ' m Λ) :=\nbegin\n  refine system_of_complexes.is_weak_bounded_exact.strong_of_complete\n    _ (thm95'.profinite r r' BD κ κ' m Λ S V) _ 1 zero_lt_one,\n  apply data.system_admissible\nend\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm94.explicit (S : Profinite.{0})\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V] :\n  ((BD.data.system κ r V r').obj (op $ ⟨(Lbar.functor.{0 0} r').obj S⟩)).is_bounded_exact\n    (k κ' m ^ 2) (K r r' BD κ' m + 1) m (c₀ r r' BD κ κ' m ⟨ℤ⟩) :=\nbegin\n  refine (thm95.profinite r r' BD κ κ' m ⟨ℤ⟩ S V).of_iso\n    ((BD.data.system κ r V r').map_iso (HomZ_iso ⟨(Lbar.functor.{0 0} r').obj S⟩).symm.op) _,\n  intros c n,\n  rw ← system_of_complexes.apply_hom_eq_hom_apply,\n  apply SemiNormedGroup.iso_isometry_of_norm_noninc;\n  apply breen_deligne.data.complex.map_norm_noninc\nend\n\nend\n\n\n\n/- ===\nOnce we have determined the final shape of the statement,\nwe can update the proof `thm95' → first_target`, and then delete the theorem below.\nNow I just want flexibility in changing `thm95`\nand not be troubled with fixing the proof of the implication.\n=== -/\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm95'' (BD : package)\n  (r r' : ℝ≥0) [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' < 1)]\n  (κ : ℕ → ℝ≥0) [BD.data.very_suitable r r' κ] [∀ (i : ℕ), fact (0 < κ i)] :\n  ∀ m : ℕ,\n  ∃ (k K : ℝ≥0) (hk : fact (1 ≤ k)),\n  ∀ (Λ : Type u) [polyhedral_lattice Λ],\n  ∃ c₀ : ℝ≥0,\n  ∀ (S : Type u) [fintype S],\n  ∀ (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n    by exactI system_of_complexes.is_weak_bounded_exact\n    (​(BD.data.system κ r V r').obj (op $ Hom Λ (Lbar r' S))) k K m c₀ :=\nbegin\n  intro m,\n  let κ' := package.κ' BD κ,\n  haveI _inst_κ' : package.adept BD κ κ' := package.κ'_adept BD κ,\n  refine ⟨(k κ' m), (K r r' BD κ' m), infer_instance, λ Λ _inst_Λ, _⟩,\n  refine ⟨c₀ r r' BD κ κ' m (@PolyhedralLattice.of Λ _inst_Λ), λ S _inst_S V _inst_V, _⟩,\n  apply thm95'\nend\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm95''.profinite (BD : package)\n  (r r' : ℝ≥0) [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' < 1)]\n  (κ : ℕ → ℝ≥0) [BD.data.very_suitable r r' κ] [∀ (i : ℕ), fact (0 < κ i)] :\n  ∀ m : ℕ,\n  ∃ (k K : ℝ≥0) (hk : fact (1 ≤ k)),\n  ∀ (Λ : Type u) [polyhedral_lattice Λ],\n  ∃ c₀ : ℝ≥0,\n  ∀ (S : Profinite.{u}),\n  ∀ (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n    by exactI system_of_complexes.is_weak_bounded_exact\n    (​(BD.data.system κ r V r').obj (op $ Hom Λ ((Lbar.functor.{u u} r').obj S))) k K m c₀ :=\nbegin\n  intro m,\n  let κ' := package.κ' BD κ,\n  haveI _inst_κ' : package.adept BD κ κ' := package.κ'_adept BD κ,\n  refine ⟨(k κ' m), (K r r' BD κ' m), infer_instance, λ Λ _inst_Λ, _⟩,\n  refine ⟨c₀ r r' BD κ κ' m (@PolyhedralLattice.of Λ _inst_Λ), λ S _inst_S V _inst_V, _⟩,\n  apply thm95'.profinite\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/thm95/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.484347199019629}}
{"text": "/-\nCopyright (c) 2019 Alexander Bentkamp. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alexander Bentkamp, François Dupuis\n-/\nimport analysis.convex.basic\nimport order.order_dual\nimport tactic.field_simp\nimport tactic.linarith\nimport tactic.ring\n\n/-!\n# Convex and concave functions\n\nThis file defines convex and concave functions in vector spaces and proves the finite Jensen\ninequality. The integral version can be found in `analysis.convex.integral`.\n\nA function `f : E → β` is `convex_on` a set `s` if `s` is itself a convex set, and for any two\npoints `x y ∈ s`, the segment joining `(x, f x)` to `(y, f y)` is above the graph of `f`.\nEquivalently, `convex_on 𝕜 f s` means that the epigraph `{p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2}` is\na convex set.\n\n## Main declarations\n\n* `convex_on 𝕜 s f`: The function `f` is convex on `s` with scalars `𝕜`.\n* `concave_on 𝕜 s f`: The function `f` is concave on `s` with scalars `𝕜`.\n* `strict_convex_on 𝕜 s f`: The function `f` is strictly convex on `s` with scalars `𝕜`.\n* `strict_concave_on 𝕜 s f`: The function `f` is strictly concave on `s` with scalars `𝕜`.\n-/\n\nopen finset linear_map set\nopen_locale big_operators classical convex pointwise\n\nvariables {𝕜 E F β ι : Type*}\n\nsection ordered_semiring\nvariables [ordered_semiring 𝕜]\n\nsection add_comm_monoid\nvariables [add_comm_monoid E] [add_comm_monoid F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection has_scalar\nvariables (𝕜) [has_scalar 𝕜 E] [has_scalar 𝕜 β] (s : set E) (f : E → β)\n\n/-- Convexity of functions -/\ndef convex_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 →\n    f (a • x + b • y) ≤ a • f x + b • f y\n\n/-- Concavity of functions -/\ndef concave_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 →\n    a • f x + b • f y ≤ f (a • x + b • y)\n\n/-- Strict convexity of functions -/\ndef strict_convex_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) < a • f x + b • f y\n\n/-- Strict concavity of functions -/\ndef strict_concave_on : Prop :=\nconvex 𝕜 s ∧\n  ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    a • f x + b • f y < f (a • x + b • y)\n\nvariables {𝕜 s f}\n\nopen order_dual (to_dual of_dual)\n\nlemma convex_on.dual (hf : convex_on 𝕜 s f) : concave_on 𝕜 s (to_dual ∘ f) := hf\n\nlemma concave_on.dual (hf : concave_on 𝕜 s f) : convex_on 𝕜 s (to_dual ∘ f) := hf\n\nlemma strict_convex_on.dual (hf : strict_convex_on 𝕜 s f) : strict_concave_on 𝕜 s (to_dual ∘ f) :=\nhf\n\nlemma strict_concave_on.dual (hf : strict_concave_on 𝕜 s f) : strict_convex_on 𝕜 s (to_dual ∘ f) :=\nhf\n\nlemma convex_on_id {s : set β} (hs : convex 𝕜 s) : convex_on 𝕜 s id := ⟨hs, by { intros, refl }⟩\n\nlemma concave_on_id {s : set β} (hs : convex 𝕜 s) : concave_on 𝕜 s id := ⟨hs, by { intros, refl }⟩\n\nlemma convex_on.subset {t : set E} (hf : convex_on 𝕜 t f) (hst : s ⊆ t) (hs : convex 𝕜 s) :\n  convex_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma concave_on.subset {t : set E} (hf : concave_on 𝕜 t f) (hst : s ⊆ t) (hs : convex 𝕜 s) :\n  concave_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma strict_convex_on.subset {t : set E} (hf : strict_convex_on 𝕜 t f) (hst : s ⊆ t)\n  (hs : convex 𝕜 s) :\n  strict_convex_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nlemma strict_concave_on.subset {t : set E} (hf : strict_concave_on 𝕜 t f) (hst : s ⊆ t)\n  (hs : convex 𝕜 s) :\n  strict_concave_on 𝕜 s f :=\n⟨hs, λ x y hx hy, hf.2 (hst hx) (hst hy)⟩\n\nend has_scalar\n\nsection distrib_mul_action\nvariables [has_scalar 𝕜 E] [distrib_mul_action 𝕜 β] {s : set E} {f g : E → β}\n\nlemma convex_on.add (hf : convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) ≤ (a • f x + b • f y) + (a • g x + b • g y)\n      : add_le_add (hf.2 hx hy ha hb hab) (hg.2 hx hy ha hb hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma concave_on.add (hf : concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  concave_on 𝕜 s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [has_scalar 𝕜 E] [module 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on_const (c : β) (hs : convex 𝕜 s) : convex_on 𝕜 s (λ x:E, c) :=\n⟨hs, λ x y _ _ a b _ _ hab, (convex.combo_self hab c).ge⟩\n\nlemma concave_on_const (c : β) (hs : convex 𝕜 s) : concave_on 𝕜 s (λ x:E, c) :=\n@convex_on_const _ _ (order_dual β) _ _ _ _ _ _ c hs\n\nend module\n\nsection ordered_smul\nvariables [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.convex_le (hf : convex_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | f x ≤ r} :=\nλ x y hx hy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha hb hab,\n  calc\n    f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx.1 hy.1 ha hb hab\n                  ... ≤ a • r + b • r     : add_le_add (smul_le_smul_of_nonneg hx.2 ha)\n                                              (smul_le_smul_of_nonneg hy.2 hb)\n                  ... = r                 : convex.combo_self hab r⟩\n\nlemma concave_on.convex_ge (hf : concave_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | r ≤ f x} :=\nhf.dual.convex_le r\n\nlemma convex_on.convex_epigraph (hf : convex_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2} :=\nbegin\n  rintro ⟨x, r⟩ ⟨y, t⟩ ⟨hx, hr⟩ ⟨hy, ht⟩ a b ha hb hab,\n  refine ⟨hf.1 hx hy ha hb hab, _⟩,\n  calc f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx hy ha hb hab\n  ... ≤ a • r + b • t : add_le_add (smul_le_smul_of_nonneg hr ha)\n                            (smul_le_smul_of_nonneg ht hb)\nend\n\nlemma concave_on.convex_hypograph (hf : concave_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1} :=\nhf.dual.convex_epigraph\n\nlemma convex_on_iff_convex_epigraph :\n  convex_on 𝕜 s f ↔ convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2} :=\n⟨convex_on.convex_epigraph, λ h,\n  ⟨λ x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) ⟨hx, le_rfl⟩ ⟨hy, le_rfl⟩ a b ha hb hab).1,\n  λ x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) ⟨hx, le_rfl⟩ ⟨hy, le_rfl⟩ a b ha hb hab).2⟩⟩\n\nlemma concave_on_iff_convex_hypograph :\n  concave_on 𝕜 s f ↔ convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1} :=\n@convex_on_iff_convex_epigraph 𝕜 E (order_dual β) _ _ _ _ _ _ _ f\n\nend ordered_smul\n\nsection module\nvariables [module 𝕜 E] [has_scalar 𝕜 β] {s : set E} {f : E → β}\n\n/-- Right translation preserves convexity. -/\nlemma convex_on.translate_right (hf : convex_on 𝕜 s f) (c : E) :\n  convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\n⟨hf.1.translate_preimage_right _, λ x y hx hy a b ha hb hab,\n  calc\n    f (c + (a • x + b • y)) = f (a • (c + x) + b • (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... ≤ a • f (c + x) + b • f (c + y) : hf.2 hx hy ha hb hab⟩\n\n/-- Right translation preserves concavity. -/\nlemma concave_on.translate_right (hf : concave_on 𝕜 s f) (c : E) :\n  concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves convexity. -/\nlemma convex_on.translate_left (hf : convex_on 𝕜 s f) (c : E) :\n  convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\n/-- Left translation preserves concavity. -/\nlemma concave_on.translate_left (hf : concave_on 𝕜 s f) (c : E) :\n  concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nhf.dual.translate_left _\n\nend module\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β]\n\nlemma convex_on_iff_forall_pos {s : set E} {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧\n    ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → f (a • x + b • y) ≤ a • f x + b • f y :=\nbegin\n  refine and_congr_right' ⟨λ h x y hx hy a b ha hb hab, h hx hy ha.le hb.le hab,\n    λ h x y hx hy a b ha hb hab, _⟩,\n  obtain rfl | ha' := ha.eq_or_lt,\n  { rw [zero_add] at hab, subst b, simp_rw [zero_smul, zero_add, one_smul] },\n  obtain rfl | hb' := hb.eq_or_lt,\n  { rw [add_zero] at hab, subst a, simp_rw [zero_smul, add_zero, one_smul] },\n  exact h hx hy ha' hb' hab,\nend\n\nlemma concave_on_iff_forall_pos {s : set E} {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧\n    ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → a • f x + b • f y ≤ f (a • x + b • y) :=\n@convex_on_iff_forall_pos 𝕜 E (order_dual β) _ _ _ _ _ _ _\n\nlemma convex_on_iff_pairwise_pos {s : set E} {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧\n    s.pairwise (λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → f (a • x + b • y) ≤ a • f x + b • f y) :=\nbegin\n  rw convex_on_iff_forall_pos,\n  refine and_congr_right' ⟨λ h x hx y hy _ a b ha hb hab, h hx hy ha hb hab,\n    λ h x y hx hy a b ha hb hab, _⟩,\n  obtain rfl | hxy := eq_or_ne x y,\n  { rw [convex.combo_self hab, convex.combo_self hab] },\n  exact h x hx y hy hxy ha hb hab,\nend\n\nlemma concave_on_iff_pairwise_pos {s : set E} {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧\n   s.pairwise (λ x y, ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1\n    → a • f x + b • f y ≤ f (a • x + b • y)) :=\n@convex_on_iff_pairwise_pos 𝕜 E (order_dual β) _ _ _ _ _ _ _\n\n/-- A linear map is convex. -/\nlemma linear_map.convex_on (f : E →ₗ[𝕜] β) {s : set E} (hs : convex 𝕜 s) : convex_on 𝕜 s f :=\n⟨hs, λ _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]⟩\n\n/-- A linear map is concave. -/\nlemma linear_map.concave_on (f : E →ₗ[𝕜] β) {s : set E} (hs : convex 𝕜 s) : concave_on 𝕜 s f :=\n⟨hs, λ _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]⟩\n\nlemma strict_convex_on.convex_on {s : set E} {f : E → β} (hf : strict_convex_on 𝕜 s f) :\n  convex_on 𝕜 s f :=\n⟨hf.1, λ x y hx hy a b ha hb hab, begin\n  obtain rfl | hxy := eq_or_ne x y,\n  { rw [convex.combo_self hab, convex.combo_self hab] },\n  obtain rfl | ha' := ha.eq_or_lt,\n  { rw zero_add at hab,\n    rw [hab, zero_smul, zero_smul, one_smul, one_smul, zero_add, zero_add] },\n  obtain rfl | hb' := hb.eq_or_lt,\n  { rw add_zero at hab,\n    rw [hab, zero_smul, zero_smul, one_smul, one_smul, add_zero, add_zero] },\n  exact (hf.2 hx hy hxy ha' hb' hab).le,\nend⟩\n\nlemma strict_concave_on.concave_on {s : set E} {f : E → β} (hf : strict_concave_on 𝕜 s f) :\n  concave_on 𝕜 s f :=\nhf.dual.convex_on\n\nsection ordered_smul\nvariables [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma strict_convex_on.convex_lt (hf : strict_convex_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | f x < r} :=\nconvex_iff_pairwise_pos.2 $ λ x hx y hy hxy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a • x + b • y) < a • f x + b • f y : hf.2 hx.1 hy.1 hxy ha hb hab\n                  ... ≤ a • r + b • r     : add_le_add (smul_lt_smul_of_pos hx.2 ha).le\n                                              (smul_lt_smul_of_pos hy.2 hb).le\n                  ... = r                 : convex.combo_self hab r⟩\n\nlemma strict_concave_on.convex_gt (hf : strict_concave_on 𝕜 s f) (r : β) :\n  convex 𝕜 {x ∈ s | r < f x} :=\nhf.dual.convex_lt r\n\nend ordered_smul\n\nsection linear_order\nvariables [linear_order E] {s : set E} {f : E → β}\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is convex, it suffices to\nverify the inequality `f (a • x + b • y) ≤ a • f x + b • f y` only for `x < y` and positive `a`,\n`b`. The main use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order.\n-/\nlemma linear_order.convex_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) ≤ a • f x + b • f y) : convex_on 𝕜 s f :=\nbegin\n  refine convex_on_iff_pairwise_pos.2 ⟨hs, λ x hx y hy hxy a b ha hb hab, _⟩,\n  wlog h : x ≤ y using [x y a b, y x b a],\n  { exact le_total _ _ },\n  exact hf hx hy (h.lt_of_ne hxy) ha hb hab,\nend\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is concave it suffices to\nverify the inequality `a • f x + b • f y ≤ f (a • x + b • y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = ℝ` however one can apply it, e.g., to `ℝ^n` with lexicographic order. -/\nlemma linear_order.concave_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n     a • f x + b • f y ≤ f (a • x + b • y)) : concave_on 𝕜 s f :=\n@linear_order.convex_on_of_lt _ _ (order_dual β) _ _ _ _ _ _ s f hs hf\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is convex, it suffices to\nverify the inequality `f (a • x + b • y) ≤ a • f x + b • f y` for `x < y` and positive `a`, `b`. The\nmain use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order. -/\nlemma linear_order.strict_convex_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n    f (a • x + b • y) < a • f x + b • f y) : strict_convex_on 𝕜 s f :=\nbegin\n  refine ⟨hs, λ x y hx hy hxy a b ha hb hab, _⟩,\n  wlog h : x ≤ y using [x y a b, y x b a],\n  { exact le_total _ _ },\n  exact hf hx hy (h.lt_of_ne hxy) ha hb hab,\nend\n\n/-- For a function on a convex set in a linearly ordered space (where the order and the algebraic\nstructures aren't necessarily compatible), in order to prove that it is concave it suffices to\nverify the inequality `a • f x + b • f y ≤ f (a • x + b • y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = 𝕜` however one can apply it, e.g., to `𝕜^n` with lexicographic order. -/\nlemma linear_order.strict_concave_on_of_lt (hs : convex 𝕜 s)\n  (hf : ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x < y → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 →\n     a • f x + b • f y < f (a • x + b • y)) : strict_concave_on 𝕜 s f :=\n@linear_order.strict_convex_on_of_lt _ _ (order_dual β) _ _ _ _ _ _ _ _ hs hf\n\nend linear_order\nend module\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 F] [has_scalar 𝕜 β]\n\n/-- If `g` is convex on `s`, so is `(f ∘ g)` on `f ⁻¹' s` for a linear `f`. -/\nlemma convex_on.comp_linear_map {f : F → β} {s : set F} (hf : convex_on 𝕜 s f) (g : E →ₗ[𝕜] F) :\n  convex_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\n⟨hf.1.linear_preimage _, λ x y hx hy a b ha hb hab,\n  calc\n    f (g (a • x + b • y)) = f (a • (g x) + b • (g y)) : by rw [g.map_add, g.map_smul, g.map_smul]\n                      ... ≤ a • f (g x) + b • f (g y) : hf.2 hx hy ha hb hab⟩\n\n/-- If `g` is concave on `s`, so is `(g ∘ f)` on `f ⁻¹' s` for a linear `f`. -/\nlemma concave_on.comp_linear_map {f : F → β} {s : set F} (hf : concave_on 𝕜 s f) (g : E →ₗ[𝕜] F) :\n  concave_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\nhf.dual.comp_linear_map g\n\nend module\nend ordered_add_comm_monoid\n\nsection ordered_cancel_add_comm_monoid\nvariables [ordered_cancel_add_comm_monoid β]\n\nsection distrib_mul_action\nvariables [has_scalar 𝕜 E] [distrib_mul_action 𝕜 β] {s : set E} {f g : E → β}\n\nlemma strict_convex_on.add (hf : strict_convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f + g) :=\n⟨hf.1, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (a • x + b • y) + g (a • x + b • y) < (a • f x + b • f y) + (a • g x + b • g y)\n      : add_lt_add (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy hxy ha hb hab)\n    ... = a • (f x + g x) + b • (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]⟩\n\nlemma strict_concave_on.add (hf : strict_concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n  strict_concave_on 𝕜 s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.convex_lt (hf : convex_on 𝕜 s f) (r : β) : convex 𝕜 {x ∈ s | f x < r} :=\nconvex_iff_forall_pos.2 $ λ x y hx hy a b ha hb hab, ⟨hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a • x + b • y)\n        ≤ a • f x + b • f y : hf.2 hx.1 hy.1 ha.le hb.le hab\n    ... < a • r + b • r     : add_lt_add_of_lt_of_le (smul_lt_smul_of_pos hx.2 ha)\n                                (smul_le_smul_of_nonneg hy.2.le hb.le)\n    ... = r                 : convex.combo_self hab _⟩\n\nlemma concave_on.convex_gt (hf : concave_on 𝕜 s f) (r : β) : convex 𝕜 {x ∈ s | r < f x} :=\nhf.dual.convex_lt r\n\nlemma convex_on.convex_strict_epigraph (hf : convex_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ f p.1 < p.2} :=\nbegin\n  rw convex_iff_forall_pos,\n  rintro ⟨x, r⟩ ⟨y, t⟩ ⟨hx, hr⟩ ⟨hy, ht⟩ a b ha hb hab,\n  refine ⟨hf.1 hx hy ha.le hb.le hab, _⟩,\n  calc f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx hy ha.le hb.le hab\n  ... < a • r + b • t : add_lt_add (smul_lt_smul_of_pos hr ha)\n                            (smul_lt_smul_of_pos ht hb)\nend\n\nlemma concave_on.convex_strict_hypograph (hf : concave_on 𝕜 s f) :\n  convex 𝕜 {p : E × β | p.1 ∈ s ∧ p.2 < f p.1} :=\nhf.dual.convex_strict_epigraph\n\nend module\nend ordered_cancel_add_comm_monoid\n\nsection linear_ordered_add_comm_monoid\nvariables [linear_ordered_add_comm_monoid β] [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β]\n  {s : set E} {f g : E → β}\n\n/-- The pointwise maximum of convex functions is convex. -/\nlemma convex_on.sup (hf : convex_on 𝕜 s f) (hg : convex_on 𝕜 s g) :\n  convex_on 𝕜 s (f ⊔ g) :=\nbegin\n  refine ⟨hf.left, λ x y hx hy a b ha hb hab, sup_le _ _⟩,\n  { calc f (a • x + b • y) ≤ a • f x + b • f y : hf.right hx hy ha hb hab\n     ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n     (smul_le_smul_of_nonneg le_sup_left ha)\n     (smul_le_smul_of_nonneg le_sup_left hb) },\n  { calc g (a • x + b • y) ≤ a • g x + b • g y : hg.right hx hy ha hb hab\n     ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n     (smul_le_smul_of_nonneg le_sup_right ha)\n     (smul_le_smul_of_nonneg le_sup_right hb) }\nend\n\n/-- The pointwise minimum of concave functions is concave. -/\nlemma concave_on.inf (hf : concave_on 𝕜 s f) (hg : concave_on 𝕜 s g) :\n  concave_on 𝕜 s (f ⊓ g) :=\nhf.dual.sup hg\n\n/-- The pointwise maximum of strictly convex functions is strictly convex. -/\nlemma strict_convex_on.sup (hf : strict_convex_on 𝕜 s f) (hg : strict_convex_on 𝕜 s g) :\n  strict_convex_on 𝕜 s (f ⊔ g) :=\n⟨hf.left, λ x y hx hy hxy a b ha hb hab, max_lt\n  (calc f (a • x + b • y) < a • f x + b • f y : hf.2 hx hy hxy ha hb hab\n    ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n    (smul_le_smul_of_nonneg le_sup_left ha.le)\n    (smul_le_smul_of_nonneg le_sup_left hb.le))\n  (calc g (a • x + b • y) < a • g x + b • g y : hg.2 hx hy hxy ha hb hab\n    ...                   ≤ a • (f x ⊔ g x) + b • (f y ⊔ g y) : add_le_add\n    (smul_le_smul_of_nonneg le_sup_right ha.le)\n    (smul_le_smul_of_nonneg le_sup_right hb.le))⟩\n\n/-- The pointwise minimum of strictly concave functions is strictly concave. -/\nlemma strict_concave_on.inf (hf : strict_concave_on 𝕜 s f) (hg : strict_concave_on 𝕜 s g) :\n   strict_concave_on 𝕜 s (f ⊓ g) :=\nhf.dual.sup hg\n\n/-- A convex function on a segment is upper-bounded by the max of its endpoints. -/\nlemma convex_on.le_on_segment' (hf : convex_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) :\n  f (a • x + b • y) ≤ max (f x) (f y) :=\ncalc\n  f (a • x + b • y) ≤ a • f x + b • f y : hf.2 hx hy ha hb hab\n  ... ≤ a • max (f x) (f y) + b • max (f x) (f y) :\n    add_le_add (smul_le_smul_of_nonneg (le_max_left _ _) ha)\n      (smul_le_smul_of_nonneg (le_max_right _ _) hb)\n  ... = max (f x) (f y) : convex.combo_self hab _\n\n/-- A concave function on a segment is lower-bounded by the min of its endpoints. -/\nlemma concave_on.ge_on_segment' (hf : concave_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) :\n  min (f x) (f y) ≤ f (a • x + b • y) :=\nhf.dual.le_on_segment' hx hy ha hb hab\n\n/-- A convex function on a segment is upper-bounded by the max of its endpoints. -/\nlemma convex_on.le_on_segment (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s) (hy : y ∈ s)\n  (hz : z ∈ [x -[𝕜] y]) :\n  f z ≤ max (f x) (f y) :=\nlet ⟨a, b, ha, hb, hab, hz⟩ := hz in hz ▸ hf.le_on_segment' hx hy ha hb hab\n\n/-- A concave function on a segment is lower-bounded by the min of its endpoints. -/\nlemma concave_on.ge_on_segment (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s) (hy : y ∈ s)\n  (hz : z ∈ [x -[𝕜] y]) :\n  min (f x) (f y) ≤ f z :=\nhf.dual.le_on_segment hx hy hz\n\n/-- A strictly convex function on an open segment is strictly upper-bounded by the max of its\nendpoints. -/\nlemma strict_convex_on.lt_on_open_segment' (hf : strict_convex_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  f (a • x + b • y) < max (f x) (f y) :=\ncalc\n  f (a • x + b • y) < a • f x + b • f y : hf.2 hx hy hxy ha hb hab\n  ... ≤ a • max (f x) (f y) + b • max (f x) (f y) :\n    add_le_add (smul_le_smul_of_nonneg (le_max_left _ _) ha.le)\n      (smul_le_smul_of_nonneg (le_max_right _ _) hb.le)\n  ... = max (f x) (f y) : convex.combo_self hab _\n\n/-- A strictly concave function on an open segment is strictly lower-bounded by the min of its\nendpoints. -/\nlemma strict_concave_on.lt_on_open_segment' (hf : strict_concave_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  min (f x) (f y) < f (a • x + b • y) :=\nhf.dual.lt_on_open_segment' hx hy hxy ha hb hab\n\n/-- A strictly convex function on an open segment is strictly upper-bounded by the max of its\nendpoints. -/\nlemma strict_convex_on.lt_on_open_segment (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) (hz : z ∈ open_segment 𝕜 x y) :\n  f z < max (f x) (f y) :=\nlet ⟨a, b, ha, hb, hab, hz⟩ := hz in hz ▸ hf.lt_on_open_segment' hx hy hxy ha hb hab\n\n/-- A strictly concave function on an open segment is strictly lower-bounded by the min of its\nendpoints. -/\nlemma strict_concave_on.lt_on_open_segment (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hxy : x ≠ y) (hz : z ∈ open_segment 𝕜 x y) :\n  min (f x) (f y) < f z :=\nhf.dual.lt_on_open_segment hx hy hxy hz\n\nend linear_ordered_add_comm_monoid\n\nsection linear_ordered_cancel_add_comm_monoid\nvariables [linear_ordered_cancel_add_comm_monoid β]\n\nsection ordered_smul\nvariables [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f g : E → β}\n\nlemma convex_on.le_left_of_right_le' (hf : convex_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) (hfy : f y ≤ f (a • x + b • y)) :\n  f (a • x + b • y) ≤ f x :=\nle_of_not_lt $ λ h, lt_irrefl (f (a • x + b • y)) $\n  calc\n    f (a • x + b • y)\n        ≤ a • f x + b • f y : hf.2 hx hy ha.le hb hab\n    ... < a • f (a • x + b • y) + b • f (a • x + b • y)\n        : add_lt_add_of_lt_of_le (smul_lt_smul_of_pos h ha) (smul_le_smul_of_nonneg hfy hb)\n    ... = f (a • x + b • y) : convex.combo_self hab _\n\nlemma concave_on.left_le_of_le_right' (hf : concave_on 𝕜 s f) {x y : E} (hx : x ∈ s) (hy : y ∈ s)\n  {a b : 𝕜} (ha : 0 < a) (hb : 0 ≤ b) (hab : a + b = 1) (hfy : f (a • x + b • y) ≤ f y) :\n  f x ≤ f (a • x + b • y) :=\nhf.dual.le_left_of_right_le' hx hy ha hb hab hfy\n\nlemma convex_on.le_right_of_left_le' (hf : convex_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x ≤ f (a • x + b • y)) :\n  f (a • x + b • y) ≤ f y :=\nbegin\n  rw add_comm at ⊢ hab hfx,\n  exact hf.le_left_of_right_le' hy hx hb ha hab hfx,\nend\n\nlemma concave_on.le_right_of_left_le' (hf : concave_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 ≤ a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a • x + b • y) ≤ f x) :\n  f y ≤ f (a • x + b • y) :=\nhf.dual.le_right_of_left_le' hx hy ha hb hab hfx\n\nlemma convex_on.le_left_of_right_le (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f y ≤ f z) :\n  f z ≤ f x :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.le_left_of_right_le' hx hy ha hb.le hab hyz,\nend\n\nlemma concave_on.left_le_of_le_right (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f z ≤ f y) :\n  f x ≤ f z :=\nhf.dual.le_left_of_right_le hx hy hz hyz\n\nlemma convex_on.le_right_of_left_le (hf : convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f x ≤ f z) :\n  f z ≤ f y :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.le_right_of_left_le' hx hy ha.le hb hab hxz,\nend\n\nlemma concave_on.le_right_of_left_le (hf : concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f z ≤ f x) :\n  f y ≤ f z :=\nhf.dual.le_right_of_left_le hx hy hz hxz\n\nend ordered_smul\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f g : E → β}\n\n/- The following lemmas don't require `module 𝕜 E` if you add the hypothesis `x ≠ y`. At the time of\nthe writing, we decided the resulting lemmas wouldn't be useful. Feel free to reintroduce them. -/\nlemma strict_convex_on.lt_left_of_right_lt' (hf : strict_convex_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f y < f (a • x + b • y)) :\n  f (a • x + b • y) < f x :=\nnot_le.1 $ λ h, lt_irrefl (f (a • x + b • y)) $\n  calc\n    f (a • x + b • y)\n        < a • f x + b • f y : hf.2 hx hy begin\n            rintro rfl,\n            rw convex.combo_self hab at hfy,\n            exact lt_irrefl _ hfy,\n          end ha hb hab\n    ... < a • f (a • x + b • y) + b • f (a • x + b • y)\n        : add_lt_add_of_le_of_lt (smul_le_smul_of_nonneg h ha.le) (smul_lt_smul_of_pos hfy hb)\n    ... = f (a • x + b • y) : convex.combo_self hab _\n\nlemma strict_concave_on.left_lt_of_lt_right' (hf : strict_concave_on 𝕜 s f) {x y : E} (hx : x ∈ s)\n  (hy : y ∈ s) {a b : 𝕜} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f (a • x + b • y) < f y) :\n  f x < f (a • x + b • y) :=\nhf.dual.lt_left_of_right_lt' hx hy ha hb hab hfy\n\nlemma strict_convex_on.lt_right_of_left_lt' (hf : strict_convex_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x < f (a • x + b • y)) :\n  f (a • x + b • y) < f y :=\nbegin\n  rw add_comm at ⊢ hab hfx,\n  exact hf.lt_left_of_right_lt' hy hx hb ha hab hfx,\nend\n\nlemma strict_concave_on.lt_right_of_left_lt' (hf : strict_concave_on 𝕜 s f) {x y : E} {a b : 𝕜}\n  (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a • x + b • y) < f x) :\n  f y < f (a • x + b • y) :=\nhf.dual.lt_right_of_left_lt' hx hy ha hb hab hfx\n\nlemma strict_convex_on.lt_left_of_right_lt (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f y < f z) :\n  f z < f x :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.lt_left_of_right_lt' hx hy ha hb hab hyz,\nend\n\nlemma strict_concave_on.left_lt_of_lt_right (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hyz : f z < f y) :\n  f x < f z :=\nhf.dual.lt_left_of_right_lt hx hy hz hyz\n\nlemma strict_convex_on.lt_right_of_left_lt (hf : strict_convex_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f x < f z) :\n  f z < f y :=\nbegin\n  obtain ⟨a, b, ha, hb, hab, rfl⟩ := hz,\n  exact hf.lt_right_of_left_lt' hx hy ha hb hab hxz,\nend\n\nlemma strict_concave_on.lt_right_of_left_lt (hf : strict_concave_on 𝕜 s f) {x y z : E} (hx : x ∈ s)\n  (hy : y ∈ s) (hz : z ∈ open_segment 𝕜 x y) (hxz : f z < f x) :\n  f y < f z :=\nhf.dual.lt_right_of_left_lt hx hy hz hxz\n\nend module\nend linear_ordered_cancel_add_comm_monoid\n\nsection ordered_add_comm_group\nvariables [ordered_add_comm_group β] [has_scalar 𝕜 E] [module 𝕜 β] {s : set E} {f : E → β}\n\n/-- A function `-f` is convex iff `f` is concave. -/\n@[simp] lemma neg_convex_on_iff : convex_on 𝕜 s (-f) ↔ concave_on 𝕜 s f :=\nbegin\n  split,\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy a b ha hb hab, _⟩,\n    simp [neg_apply, neg_le, add_comm] at h,\n    exact h hx hy ha hb hab },\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy a b ha hb hab, _⟩,\n    rw ←neg_le_neg_iff,\n    simp_rw [neg_add, pi.neg_apply, smul_neg, neg_neg],\n    exact h hx hy ha hb hab }\nend\n\n/-- A function `-f` is concave iff `f` is convex. -/\n@[simp] lemma neg_concave_on_iff : concave_on 𝕜 s (-f) ↔ convex_on 𝕜 s f:=\nby rw [← neg_convex_on_iff, neg_neg f]\n\n/-- A function `-f` is strictly convex iff `f` is strictly concave. -/\n@[simp] lemma neg_strict_convex_on_iff : strict_convex_on 𝕜 s (-f) ↔ strict_concave_on 𝕜 s f :=\nbegin\n  split,\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy hxy a b ha hb hab, _⟩,\n    simp [neg_apply, neg_lt, add_comm] at h,\n    exact h hx hy hxy ha hb hab },\n  { rintro ⟨hconv, h⟩,\n    refine ⟨hconv, λ x y hx hy hxy a b ha hb hab, _⟩,\n    rw ←neg_lt_neg_iff,\n    simp_rw [neg_add, pi.neg_apply, smul_neg, neg_neg],\n    exact h hx hy hxy ha hb hab }\nend\n\n/-- A function `-f` is strictly concave iff `f` is strictly convex. -/\n@[simp] lemma neg_strict_concave_on_iff : strict_concave_on 𝕜 s (-f) ↔ strict_convex_on 𝕜 s f :=\nby rw [← neg_strict_convex_on_iff, neg_neg f]\n\nalias neg_convex_on_iff ↔ _ concave_on.neg\nalias neg_concave_on_iff ↔ _ convex_on.neg\nalias neg_strict_convex_on_iff ↔ _ strict_concave_on.neg\nalias neg_strict_concave_on_iff ↔ _ strict_convex_on.neg\n\nend ordered_add_comm_group\nend add_comm_monoid\n\nsection add_cancel_comm_monoid\nvariables [add_cancel_comm_monoid E] [ordered_add_comm_monoid β] [module 𝕜 E] [has_scalar 𝕜 β]\n  {s : set E} {f : E → β}\n\n/-- Right translation preserves strict convexity. -/\nlemma strict_convex_on.translate_right (hf : strict_convex_on 𝕜 s f) (c : E) :\n  strict_convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\n⟨hf.1.translate_preimage_right _, λ x y hx hy hxy a b ha hb hab,\n  calc\n    f (c + (a • x + b • y)) = f (a • (c + x) + b • (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... < a • f (c + x) + b • f (c + y) : hf.2 hx hy ((add_right_injective c).ne hxy) ha hb hab⟩\n\n/-- Right translation preserves strict concavity. -/\nlemma strict_concave_on.translate_right (hf : strict_concave_on 𝕜 s f) (c : E) :\n  strict_concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves strict convexity. -/\nlemma strict_convex_on.translate_left (hf : strict_convex_on 𝕜 s f) (c : E) :\n  strict_convex_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\n/-- Left translation preserves strict concavity. -/\nlemma strict_concave_on.translate_left (hf : strict_concave_on 𝕜 s f) (c : E) :\n  strict_concave_on 𝕜 ((λ z, c + z) ⁻¹' s) (f ∘ (λ z, z + c)) :=\nby simpa only [add_comm] using hf.translate_right _\n\nend add_cancel_comm_monoid\nend ordered_semiring\n\nsection ordered_comm_semiring\nvariables [ordered_comm_semiring 𝕜] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection module\nvariables [has_scalar 𝕜 E] [module 𝕜 β] [ordered_smul 𝕜 β] {s : set E} {f : E → β}\n\nlemma convex_on.smul {c : 𝕜} (hc : 0 ≤ c) (hf : convex_on 𝕜 s f) : convex_on 𝕜 s (λ x, c • f x) :=\n⟨hf.1, λ x y hx hy a b ha hb hab,\n  calc\n    c • f (a • x + b • y) ≤ c • (a • f x + b • f y)\n      : smul_le_smul_of_nonneg (hf.2 hx hy ha hb hab) hc\n    ... = a • (c • f x) + b • (c • f y)\n      : by rw [smul_add, smul_comm c, smul_comm c]; apply_instance⟩\n\nlemma concave_on.smul {c : 𝕜} (hc : 0 ≤ c) (hf : concave_on 𝕜 s f) :\n  concave_on 𝕜 s (λ x, c • f x) :=\nhf.dual.smul hc\n\nend module\nend ordered_add_comm_monoid\nend ordered_comm_semiring\n\nsection ordered_ring\nvariables [linear_ordered_field 𝕜] [add_comm_group E] [add_comm_group F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection module\nvariables [module 𝕜 E] [module 𝕜 F] [has_scalar 𝕜 β]\n\n/-- If a function is convex on `s`, it remains convex when precomposed by an affine map. -/\nlemma convex_on.comp_affine_map {f : F → β} (g : E →ᵃ[𝕜] F) {s : set F} (hf : convex_on 𝕜 s f) :\n  convex_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\n⟨hf.1.affine_preimage _, λ x y hx hy a b ha hb hab,\n  calc\n    (f ∘ g) (a • x + b • y) = f (g (a • x + b • y))         : rfl\n                       ...  = f (a • (g x) + b • (g y))     : by rw [convex.combo_affine_apply hab]\n                       ...  ≤ a • f (g x) + b • f (g y)     : hf.2 hx hy ha hb hab⟩\n\n/-- If a function is concave on `s`, it remains concave when precomposed by an affine map. -/\nlemma concave_on.comp_affine_map {f : F → β} (g : E →ᵃ[𝕜] F) {s : set F} (hf : concave_on 𝕜 s f) :\n  concave_on 𝕜 (g ⁻¹' s) (f ∘ g) :=\nhf.dual.comp_affine_map g\n\nend module\nend ordered_add_comm_monoid\nend ordered_ring\n\nsection linear_ordered_field\nvariables [linear_ordered_field 𝕜] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid β]\n\nsection has_scalar\nvariables [has_scalar 𝕜 E] [has_scalar 𝕜 β] {s : set E}\n\nlemma convex_on_iff_div {f : E → β} :\n  convex_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → 0 < a + b\n  → f ((a/(a+b)) • x + (b/(a+b)) • y) ≤ (a/(a+b)) • f x + (b/(a+b)) • f y :=\nand_congr iff.rfl\n⟨begin\n  intros h x y hx hy a b ha hb hab,\n  apply h hx hy (div_nonneg ha hab.le) (div_nonneg hb hab.le),\n  rw [←add_div, div_self hab.ne'],\nend,\nbegin\n  intros h x y hx hy a b ha hb hab,\n  simpa [hab, zero_lt_one] using h hx hy ha hb,\nend⟩\n\nlemma concave_on_iff_div {f : E → β} :\n  concave_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b\n  → 0 < a + b → (a/(a+b)) • f x + (b/(a+b)) • f y ≤ f ((a/(a+b)) • x + (b/(a+b)) • y) :=\n@convex_on_iff_div _ _ (order_dual β) _ _ _ _ _ _ _\n\nlemma strict_convex_on_iff_div {f : E → β} :\n  strict_convex_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a\n    → 0 < b → f ((a/(a+b)) • x + (b/(a+b)) • y) < (a/(a+b)) • f x + (b/(a+b)) • f y :=\nand_congr iff.rfl\n⟨begin\n  intros h x y hx hy hxy a b ha hb,\n  have hab := add_pos ha hb,\n  apply h hx hy hxy (div_pos ha hab) (div_pos hb hab),\n  rw [←add_div, div_self hab.ne'],\nend,\nbegin\n  intros h x y hx hy hxy a b ha hb hab,\n  simpa [hab, zero_lt_one] using h hx hy hxy ha hb,\nend⟩\n\nlemma strict_concave_on_iff_div {f : E → β} :\n  strict_concave_on 𝕜 s f ↔ convex 𝕜 s ∧ ∀ ⦃x y : E⦄, x ∈ s → y ∈ s → x ≠ y → ∀ ⦃a b : 𝕜⦄, 0 < a\n    → 0 < b → (a/(a+b)) • f x + (b/(a+b)) • f y < f ((a/(a+b)) • x + (b/(a+b)) • y) :=\n@strict_convex_on_iff_div _ _ (order_dual β) _ _ _ _ _ _ _\n\nend has_scalar\nend ordered_add_comm_monoid\nend linear_ordered_field\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/convex/function.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.48433297779083345}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.functor_category\nimport category_theory.isomorphism\n\n/-!\n# Natural isomorphisms\n\nFor the most part, natural isomorphisms are just another sort of isomorphism.\n\nWe provide some special support for extracting components:\n* if `α : F ≅ G`, then `a.app X : F.obj X ≅ G.obj X`,\nand building natural isomorphisms from components:\n*\n```\nnat_iso.of_components\n  (app : ∀ X : C, F.obj X ≅ G.obj X)\n  (naturality : ∀ {X Y : C} (f : X ⟶ Y), F.map f ≫ (app Y).hom = (app X).hom ≫ G.map f) :\nF ≅ G\n```\nonly needing to check naturality in one direction.\n\n## Implementation\n\nNote that `nat_iso` is a namespace without a corresponding definition;\nwe put some declarations that are specifically about natural isomorphisms in the `iso`\nnamespace so that they are available using dot notation.\n-/\n\nopen category_theory\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄\n\nnamespace category_theory\nopen nat_trans\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n  {E : Type u₃} [category.{v₃} E]\n\nnamespace iso\n\n/-- The application of a natural isomorphism to an object. We put this definition in a different\nnamespace, so that we can use `α.app` -/\n@[simps] def app {F G : C ⥤ D} (α : F ≅ G) (X : C) : F.obj X ≅ G.obj X :=\n{ hom := α.hom.app X,\n  inv := α.inv.app X,\n  hom_inv_id' := begin rw [← comp_app, iso.hom_inv_id], refl end,\n  inv_hom_id' := begin rw [← comp_app, iso.inv_hom_id], refl end }\n\n@[simp, reassoc]\nlemma hom_inv_id_app {F G : C ⥤ D} (α : F ≅ G) (X : C) :\n  α.hom.app X ≫ α.inv.app X = 𝟙 (F.obj X) :=\ncongr_fun (congr_arg nat_trans.app α.hom_inv_id) X\n\n@[simp, reassoc]\nlemma inv_hom_id_app {F G : C ⥤ D} (α : F ≅ G) (X : C) :\n  α.inv.app X ≫ α.hom.app X = 𝟙 (G.obj X) :=\ncongr_fun (congr_arg nat_trans.app α.inv_hom_id) X\n\nend iso\n\nnamespace nat_iso\n\nopen category_theory.category category_theory.functor\n\n@[simp] lemma trans_app {F G H : C ⥤ D} (α : F ≅ G) (β : G ≅ H) (X : C) :\n  (α ≪≫ β).app X = α.app X ≪≫ β.app X := rfl\n\nlemma app_hom {F G : C ⥤ D} (α : F ≅ G) (X : C) : (α.app X).hom = α.hom.app X := rfl\nlemma app_inv {F G : C ⥤ D} (α : F ≅ G) (X : C) : (α.app X).inv = α.inv.app X := rfl\n\nvariables {F G : C ⥤ D}\n\ninstance hom_app_is_iso (α : F ≅ G) (X : C) : is_iso (α.hom.app X) :=\n⟨⟨α.inv.app X,\n  ⟨by rw [←comp_app, iso.hom_inv_id, ←id_app], by rw [←comp_app, iso.inv_hom_id, ←id_app]⟩⟩⟩\n\ninstance inv_app_is_iso (α : F ≅ G) (X : C) : is_iso (α.inv.app X) :=\n⟨⟨α.hom.app X,\n  ⟨by rw [←comp_app, iso.inv_hom_id, ←id_app], by rw [←comp_app, iso.hom_inv_id, ←id_app]⟩⟩⟩\n\nsection\n/-!\nUnfortunately we need a separate set of cancellation lemmas for components of natural isomorphisms,\nbecause the `simp` normal form is `α.hom.app X`, rather than `α.app.hom X`.\n\n(With the later, the morphism would be visibly part of an isomorphism, so general lemmas about\nisomorphisms would apply.)\n\nIn the future, we should consider a redesign that changes this simp norm form,\nbut for now it breaks too many proofs.\n-/\n\nvariables (α : F ≅ G)\n\n@[simp] lemma cancel_nat_iso_hom_left {X : C} {Z : D} (g g' : G.obj X ⟶ Z) :\n  α.hom.app X ≫ g = α.hom.app X ≫ g' ↔ g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_nat_iso_inv_left {X : C} {Z : D} (g g' : F.obj X ⟶ Z) :\n  α.inv.app X ≫ g = α.inv.app X ≫ g' ↔ g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_nat_iso_hom_right {X : D} {Y : C} (f f' : X ⟶ F.obj Y) :\n  f ≫ α.hom.app Y = f' ≫ α.hom.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_nat_iso_inv_right {X : D} {Y : C} (f f' : X ⟶ G.obj Y) :\n  f ≫ α.inv.app Y = f' ≫ α.inv.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_nat_iso_hom_right_assoc {W X X' : D} {Y : C}\n  (f : W ⟶ X) (g : X ⟶ F.obj Y) (f' : W ⟶ X') (g' : X' ⟶ F.obj Y)  :\n  f ≫ g ≫ α.hom.app Y = f' ≫ g' ≫ α.hom.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_nat_iso_inv_right_assoc {W X X' : D} {Y : C}\n  (f : W ⟶ X) (g : X ⟶ G.obj Y) (f' : W ⟶ X') (g' : X' ⟶ G.obj Y)  :\n  f ≫ g ≫ α.inv.app Y = f' ≫ g' ≫ α.inv.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\nend\n\nvariables {X Y : C}\nlemma naturality_1 (α : F ≅ G) (f : X ⟶ Y) :\n  (α.inv.app X) ≫ (F.map f) ≫ (α.hom.app Y) = G.map f :=\nby rw [naturality, ←category.assoc, ←nat_trans.comp_app, α.inv_hom_id, id_app, category.id_comp]\nlemma naturality_2 (α : F ≅ G) (f : X ⟶ Y) :\n  (α.hom.app X) ≫ (G.map f) ≫ (α.inv.app Y) = F.map f :=\nby rw [naturality, ←category.assoc, ←nat_trans.comp_app, α.hom_inv_id, id_app, category.id_comp]\n\n/--\nThe components of a natural isomorphism are isomorphisms.\n-/\ninstance is_iso_app_of_is_iso (α : F ⟶ G) [is_iso α] (X) : is_iso (α.app X) :=\n⟨⟨(inv α).app X,\n  ⟨congr_fun (congr_arg nat_trans.app (is_iso.hom_inv_id α)) X,\n   congr_fun (congr_arg nat_trans.app (is_iso.inv_hom_id α)) X⟩⟩⟩\n\n@[simp] lemma is_iso_inv_app (α : F ⟶ G) [is_iso α] (X) : (inv α).app X = inv (α.app X) :=\nby { ext, rw ←nat_trans.comp_app, simp, }\n\n/--\nConstruct a natural isomorphism between functors by giving object level isomorphisms,\nand checking naturality only in the forward direction.\n-/\ndef of_components (app : ∀ X : C, F.obj X ≅ G.obj X)\n  (naturality : ∀ {X Y : C} (f : X ⟶ Y), F.map f ≫ (app Y).hom = (app X).hom ≫ G.map f) :\n  F ≅ G :=\n{ hom := { app := λ X, (app X).hom },\n  inv :=\n  { app := λ X, (app X).inv,\n    naturality' := λ X Y f,\n    begin\n      have h := congr_arg (λ f, (app X).inv ≫ (f ≫ (app Y).inv)) (naturality f).symm,\n      simp only [iso.inv_hom_id_assoc, iso.hom_inv_id, assoc, comp_id, cancel_mono] at h,\n      exact h\n    end }, }\n\n@[simp] lemma of_components.app (app' : ∀ X : C, F.obj X ≅ G.obj X) (naturality) (X) :\n  (of_components app' naturality).app X = app' X :=\nby tidy\n@[simp] lemma of_components.hom_app (app : ∀ X : C, F.obj X ≅ G.obj X) (naturality) (X) :\n  (of_components app naturality).hom.app X = (app X).hom := rfl\n@[simp] lemma of_components.inv_app (app : ∀ X : C, F.obj X ≅ G.obj X) (naturality) (X) :\n  (of_components app naturality).inv.app X = (app X).inv :=\nby simp [of_components]\n\n/--\nA natural transformation is an isomorphism if all its components are isomorphisms.\n-/\n-- Making this an instance would cause a typeclass inference loop with `is_iso_app_of_is_iso`.\nlemma is_iso_of_is_iso_app (α : F ⟶ G) [∀ X : C, is_iso (α.app X)] : is_iso α :=\n⟨(is_iso.of_iso (of_components (λ X, as_iso (α.app X)) (by tidy))).1⟩\n\n/-- Horizontal composition of natural isomorphisms. -/\ndef hcomp {F G : C ⥤ D} {H I : D ⥤ E} (α : F ≅ G) (β : H ≅ I) : F ⋙ H ≅ G ⋙ I :=\nbegin\n  refine ⟨α.hom ◫ β.hom, α.inv ◫ β.inv, _, _⟩,\n  { ext, rw [←nat_trans.exchange], simp, refl },\n  ext, rw [←nat_trans.exchange], simp, refl\nend\n\nend nat_iso\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/natural_isomorphism.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.4843329775999423}}
{"text": "lemma imp_trans (P Q R : Prop) : (P → Q) → ((Q → R) → (P → R)) :=\nbegin\nintros hpq hqr,\nintro p,\napply hqr,\napply hpq,\nexact p,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world06/level07.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.4843329733543518}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport data.rbtree.init\nimport logic.is_empty\nimport tactic.interactive\n\nuniverse u\n\nmeta def tactic.interactive.blast_disjs : tactic unit :=\n`[cases_type* or]\n\nnamespace rbnode\nvariables {α : Type u}\n\nopen color nat\n\ninductive is_node_of : rbnode α → rbnode α → α → rbnode α → Prop\n| of_red   (l v r) : is_node_of (red_node l v r)    l v r\n| of_black (l v r) : is_node_of (black_node l v r)  l v r\n\ndef lift (lt : α → α → Prop) : option α → option α → Prop\n| (some a) (some b) := lt a b\n| _         _       := true\n\ninductive is_searchable (lt : α → α → Prop) : rbnode α → option α → option α → Prop\n| leaf_s  {lo hi} (hlt : lift lt lo hi) : is_searchable leaf lo hi\n| red_s   {l r v lo hi} (hs₁ : is_searchable l lo (some v)) (hs₂ : is_searchable r (some v) hi) :\n  is_searchable (red_node l v r) lo hi\n| black_s {l r v lo hi} (hs₁ : is_searchable l lo (some v)) (hs₂ : is_searchable r (some v) hi) :\n  is_searchable (black_node l v r) lo hi\n\nmeta def is_searchable_tactic : tactic unit :=\n`[\n   constructor_matching*\n     [is_searchable _ leaf _ _,\n      is_searchable _ (red_node _ _ _) _ _,\n      is_searchable _ (black_node _ _ _) _ _];\n   cases_matching*\n     [is_searchable _ leaf _ _,\n      is_searchable _ (red_node _ _ _) _ _,\n      is_searchable _ (black_node _ _ _) _ _];\n   try { assumption }\n]\n\nopen rbnode (mem)\nopen is_searchable\n\nsection is_searchable_lemmas\nvariable {lt : α → α → Prop}\n\nlemma lo_lt_hi {t : rbnode α} {lt} [is_trans α lt] :\n  ∀ {lo hi}, is_searchable lt t lo hi → lift lt lo hi :=\nbegin\n  induction t; intros lo hi hs,\n  case leaf { cases hs, assumption },\n  all_goals\n  { cases hs,\n    have h₁ := t_ih_lchild hs_hs₁,\n    have h₂ := t_ih_rchild hs_hs₂,\n    cases lo; cases hi; simp [lift] at *,\n    apply trans_of lt h₁ h₂, }\nend\n\nlemma is_searchable_of_is_searchable_of_incomp [is_strict_weak_order α lt] {t} :\n  ∀ {lo hi hi'} (hc : ¬ lt hi' hi ∧ ¬ lt hi hi') (hs : is_searchable lt t lo (some hi)),\n    is_searchable lt t lo (some hi') :=\nbegin\n  classical,\n  induction t; intros; is_searchable_tactic,\n  { cases lo; simp [lift, *] at *, apply lt_of_lt_of_incomp, assumption, exact ⟨hc.2, hc.1⟩ },\n  all_goals { apply t_ih_rchild hc hs_hs₂ }\nend\n\nlemma is_searchable_of_incomp_of_is_searchable [is_strict_weak_order α lt] {t} :\n  ∀ {lo lo' hi} (hc : ¬ lt lo' lo ∧ ¬ lt lo lo') (hs : is_searchable lt t (some lo) hi),\n    is_searchable lt t (some lo') hi :=\nbegin\n  classical,\n  induction t; intros; is_searchable_tactic,\n  { cases hi; simp [lift, *] at *, apply lt_of_incomp_of_lt, assumption, assumption },\n  all_goals { apply t_ih_lchild hc hs_hs₁ }\nend\n\nlemma is_searchable_some_low_of_is_searchable_of_lt {t} [is_trans α lt] :\n  ∀ {lo hi lo'} (hlt : lt lo' lo) (hs : is_searchable lt t (some lo) hi),\n    is_searchable lt t (some lo') hi :=\nbegin\n  induction t; intros; is_searchable_tactic,\n  { cases hi; simp [lift, *] at *, apply trans_of lt hlt, assumption },\n  all_goals { apply t_ih_lchild hlt hs_hs₁ }\nend\n\nlemma is_searchable_none_low_of_is_searchable_some_low {t} :\n  ∀ {y hi} (hlt : is_searchable lt t (some y) hi), is_searchable lt t none hi :=\nbegin\n  induction t; intros; is_searchable_tactic,\n  { simp [lift] },\n  all_goals { apply t_ih_lchild hlt_hs₁ }\nend\n\nlemma is_searchable_some_high_of_is_searchable_of_lt {t} [is_trans α lt] :\n  ∀ {lo hi hi'} (hlt : lt hi hi') (hs : is_searchable lt t lo (some hi)),\n    is_searchable lt t lo (some hi') :=\nbegin\n  induction t; intros; is_searchable_tactic,\n  { cases lo; simp [lift, *] at *, apply trans_of lt, assumption, assumption},\n  all_goals { apply t_ih_rchild hlt hs_hs₂ }\nend\n\nlemma is_searchable_none_high_of_is_searchable_some_high {t} :\n  ∀ {lo y} (hlt : is_searchable lt t lo (some y)), is_searchable lt t lo none :=\nbegin\n  induction t; intros; is_searchable_tactic,\n  { cases lo; simp [lift] },\n  all_goals { apply t_ih_rchild hlt_hs₂ }\nend\n\nlemma range [is_strict_weak_order α lt] {t : rbnode α} {x} :\n  ∀ {lo hi}, is_searchable lt t lo hi → mem lt x t → lift lt lo (some x) ∧ lift lt (some x) hi :=\nbegin\n  classical,\n  induction t,\n  case leaf { simp [mem] },\n  all_goals { -- red_node and black_node are identical\n    intros lo hi h₁ h₂, cases h₁,\n    simp only [mem] at h₂,\n    have val_hi : lift lt (some t_val) hi, { apply lo_lt_hi, assumption },\n    have lo_val : lift lt lo (some t_val), { apply lo_lt_hi, assumption },\n    blast_disjs,\n\n    { have h₃ : lift lt lo (some x) ∧ lift lt (some x) (some t_val),\n      { apply t_ih_lchild, assumption, assumption },\n      cases h₃ with lo_x x_val,\n      split,\n      show lift lt lo (some x), { assumption },\n      show lift lt (some x ) hi,\n      { cases hi with hi; simp [lift] at *,\n        apply trans_of lt x_val val_hi } },\n\n    { cases h₂,\n      cases lo with lo; cases hi with hi; simp [lift] at *,\n      { apply lt_of_incomp_of_lt _ val_hi, simp [*] },\n      { apply lt_of_lt_of_incomp lo_val, simp [*] },\n      split,\n      { apply lt_of_lt_of_incomp lo_val, simp [*] },\n      { apply lt_of_incomp_of_lt _ val_hi, simp [*] } },\n\n    { have h₃ : lift lt (some t_val) (some x) ∧ lift lt (some x) hi,\n      { apply t_ih_rchild, assumption, assumption },\n      cases h₃ with val_x x_hi,\n      cases lo with lo; cases hi with hi; simp [lift] at *,\n      { assumption },\n      { apply trans_of lt lo_val val_x },\n      split,\n      { apply trans_of lt lo_val val_x, },\n      { assumption } } }\nend\n\nlemma lt_of_mem_left [is_strict_weak_order α lt] {y : α} {t l r : rbnode α} :\n  ∀ {lo hi}, is_searchable lt t lo hi → is_node_of t l y r → ∀ {x}, mem lt x l → lt x y :=\nbegin\n intros _ _ hs hn x hm, cases hn; cases hs,\n all_goals { exact (range hs_hs₁ hm).2 }\nend\n\nlemma lt_of_mem_right [is_strict_weak_order α lt] {y : α} {t l r : rbnode α} :\n  ∀ {lo hi}, is_searchable lt t lo hi → is_node_of t l y r → ∀ {z}, mem lt z r → lt y z :=\nbegin\n intros _ _ hs hn z hm, cases hn; cases hs,\n all_goals { exact (range hs_hs₂ hm).1 }\nend\n\n\n\nend is_searchable_lemmas\n\ninductive is_red_black : rbnode α → color → nat → Prop\n| leaf_rb  : is_red_black leaf black 0\n| red_rb   {v l r n} (rb_l : is_red_black l black n) (rb_r : is_red_black r black n) :\n  is_red_black (red_node l v r) red n\n| black_rb {v l r n c₁ c₂} (rb_l : is_red_black l c₁ n) (rb_r : is_red_black r c₂ n) :\n  is_red_black (black_node l v r) black (succ n)\n\nopen is_red_black\n\nlemma depth_min : ∀ {c n} {t : rbnode α}, is_red_black t c n → n ≤ depth min t :=\nbegin\n  intros c n' t h,\n  induction h,\n  case leaf_rb {exact le_refl _},\n  case red_rb { simp [depth],\n    have : min (depth min h_l) (depth min h_r) ≥ h_n,\n    { apply le_min; assumption },\n    apply le_succ_of_le, assumption },\n  case black_rb { simp [depth],\n    apply succ_le_succ,\n    apply le_min; assumption }\nend\n\nprivate def upper : color → nat → nat\n| red   n := 2*n + 1\n| black n := 2*n\n\nprivate lemma upper_le : ∀ c n, upper c n ≤ 2 * n + 1\n| red n   := by exact le_refl _\n| black n := by apply le_succ\n\nlemma depth_max' : ∀ {c n} {t : rbnode α}, is_red_black t c n → depth max t ≤ upper c n :=\nbegin\n  intros c n' t h,\n  induction h,\n  case leaf_rb { simp [max, depth, upper, nat.mul_zero] },\n  case red_rb\n  { suffices : succ (max (depth max h_l) (depth max h_r)) ≤ 2 * h_n + 1,\n    { simp [depth, upper, *] at * },\n    apply succ_le_succ,\n    apply max_le; assumption },\n  case black_rb\n  { have : depth max h_l ≤ 2*h_n + 1, from le_trans h_ih_rb_l (upper_le _ _),\n    have : depth max h_r ≤ 2*h_n + 1, from le_trans h_ih_rb_r (upper_le _ _),\n    suffices new : max (depth max h_l) (depth max h_r) + 1 ≤ 2 * h_n + 2*1,\n    { simp [depth, upper, succ_eq_add_one, nat.left_distrib, *] at * },\n    apply succ_le_succ, apply max_le; assumption }\nend\n\nlemma depth_max {c n} {t : rbnode α} (h : is_red_black t c n) : depth max t ≤ 2 * n + 1:=\nle_trans (depth_max' h) (upper_le _ _)\n\nlemma balanced {c n} {t : rbnode α} (h : is_red_black t c n) : depth max t ≤ 2 * depth min t + 1 :=\nbegin\n  have : 2 * depth min t + 1 ≥ 2 * n + 1,\n  { apply succ_le_succ, apply nat.mul_le_mul_left, apply depth_min h },\n  apply le_trans, apply depth_max h, apply this\nend\n\nend rbnode\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/rbtree/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4843329731634606}}
{"text": "import misc.zorns_lemma\nimport misc.prop\nimport misc.set\nimport algebra.comm_rings.basic\nimport algebra.comm_rings.ideals.basic\nimport algebra.comm_rings.ideals.identities\nimport algebra.comm_rings.ideals.instances\nimport algebra.comm_rings.ideals.order\nimport algebra.comm_rings.instances.quotient_ring\n\nnamespace comm_ring\n\nuniverse u\n\nopen set\n\ndef nilpotent {R : Type u} [comm_ring R] (r : R) : Prop := ∃ n : ℕ, r^(nat.succ n) = 0\n\ndef nilradical_set (R : Type u) [comm_ring R] : set R := λ n, nilpotent n\n\nlemma prime_ideal_power_mem (R : Type u) [comm_ring R] (p : Spec R) : \n  ∀ {r : R} {n : ℕ}, r^n.succ ∈ p.body → r ∈ p.body :=\nbegin\n  intros r n hr,\n  induction n with n hn,\n  rw power_of_one at hr,\n  exact hr,\n  cases p.prime r (r^n.succ) hr,\n  exact h,\n  apply hn,\n  exact h,\nend \n\ndef nilradical (R : Type u) [comm_ring R] : ideal R\n  := ⋂₀ (image (λ p : Spec R, p) (@univ (Spec R)))\n\nlemma nilpotents_in_all_prime_ideals {R : Type u} [comm_ring R] : ∀ {x : R} (p : Spec R), \n  nilpotent x → x ∈ p.body :=\nbegin\n  intros x p hx,\n  cases hx with n hx,\n  have h : x^n.succ ∈ p.body,\n    rw hx,\n    exact p.contains_zero,\n  apply prime_ideal_power_mem,\n  exact h,\nend\n\nlemma not_nilpotent_not_zero {R : Type u} [comm_ring R] : ∀ {f : R}, ¬(nilpotent f) → f ≠ 0 :=\nbegin\n  intros f hf ab,\n  apply hf,\n  existsi 0,\n  rw ab,\n  rw power_of_one,\nend\n\nnamespace not_nilpotent_not_in_some_prime_ideal\n\nvariables {R : Type u} [comm_ring R] {f : R}\n\nprivate def no_pows_of_f (hf : ¬ (nilpotent f))\n  : set (ideal R) := λ I : ideal R, ∀ n : ℕ, f^n.succ ∉ I.body\n\n\nprivate lemma no_pows_of_f_implies_proper {hf : ¬ (nilpotent f)} {I : ideal R} \n  : no_pows_of_f hf I → is_proper I :=\nbegin\n  intro hraw,\n  have hf : f ∉ ↑I,\n    have trv : f^1 = f := power_of_one f,\n    rw ← trv,\n    apply hraw,\n  intro ab₁,\n  rw ab₁ at hf,\n  apply hf,\n  trivial,\nend\n\nprivate def cvrt {hf : ¬ (nilpotent f)} : subtype (no_pows_of_f hf) → proper_ideal R \n| ⟨I,hI⟩ := ideal_to_proper (no_pows_of_f_implies_proper hI)\n\nprivate def helper_le (hf : ¬ (nilpotent f)) \n  : subtype (no_pows_of_f hf) → subtype (no_pows_of_f hf) → Prop \n| J₁ J₂:= J₁.val.body ⊆ J₂.val.body\n\nprivate def no_pows_of_f_has_le (hf : ¬ (nilpotent f)) : has_le (subtype (no_pows_of_f hf))\n := ⟨helper_le hf⟩\n\nlocal attribute [instance] no_pows_of_f_has_le\n\nprivate lemma cvrt_body_eq {hf : ¬ (nilpotent f)} : ∀ J : subtype (no_pows_of_f hf), (cvrt J).body = J.val.body\n  | ⟨I,hI⟩ := rfl\n\nprivate lemma cvrt_equal {hf : ¬ (nilpotent f)} :  \n  ∀ J₁ J₂ : subtype (no_pows_of_f hf), J₁ = J₂ ↔ cvrt J₁ = cvrt J₂ :=\nbegin\n  intros J₁ J₂,\n  split,\n  intro h,\n  rw h,\n  intro h,\n  apply val_injective,\n  apply ideal_equality,\n  simp [← cvrt_body_eq],\n  rw h,\nend\n\nprivate lemma cvrt_le {hf : ¬ (nilpotent f)} :  \n  ∀ J₁ J₂ : subtype (no_pows_of_f hf), J₁ ≤ J₂ ↔ cvrt J₁ ≤ cvrt J₂ :=\nbegin\n  intros J₁ J₂,\n  split,\n  intro h,\n  suffices h₁ : (cvrt J₁).body ⊆ (cvrt J₂).body,\n  exact h₁,\n  rw cvrt_body_eq,\n  rw cvrt_body_eq,\n  exact h,\n  intro h,\n  have process : (cvrt J₁).body ⊆ (cvrt J₂).body := h,\n  rw cvrt_body_eq at process,\n  rw cvrt_body_eq at process,\n  exact process,\nend\n\nprivate lemma helper_le_refl {hf : ¬ (nilpotent f)} \n  : ∀ J : subtype (no_pows_of_f hf), J ≤ J :=\nbegin\n  intro J,\n  rw cvrt_le,\n  exact le_refl (cvrt J),\nend\n\nprivate lemma helper_le_trans {hf : ¬ (nilpotent f)} \n  : ∀ J₁ J₂ J₃ : subtype (no_pows_of_f hf), (J₁ ≤ J₂) → (J₂ ≤ J₃) → (J₁ ≤ J₃) :=\nbegin\n  intros J₁ J₂ J₃,\n  simp [cvrt_le],\n  exact le_trans,\nend\n\nprivate lemma helper_le_anti_symm {hf : ¬ (nilpotent f)} \n  : ∀ J₁ J₂ : subtype (no_pows_of_f hf), J₁ ≤ J₂ → J₂ ≤ J₁ → J₁ = J₂ :=\nbegin\n  intros J₁ J₂,\n  simp [cvrt_equal,cvrt_le],\n  exact le_antisymm,\nend\n\nprivate def no_pows_of_f_poset {hf : ¬ (nilpotent f)} : partial_order (subtype (no_pows_of_f hf)) :=\nbegin\n  split,\n  exact helper_le_anti_symm,\n  exact helper_le_refl,\n  exact helper_le_trans,\nend\n\nlocal attribute [instance] no_pows_of_f_poset \n\nprivate lemma cvrt_chain {hf : ¬(nilpotent f)} {s : set (subtype (no_pows_of_f hf))} : is_chain s → is_chain (image cvrt s) :=\nbegin\n  intros hs x y hxy,\n  cases hxy with hx hy,\n  cases hx with x₀ hx₀,\n  cases hx₀ with hx₀ins hx₀rw,\n  cases hy with y₀ hy₀,\n  cases hy₀ with hy₀ins hy₀rw,\n  simp [← hx₀rw, ← hy₀rw, ←cvrt_le],\n  apply hs,\n  exact ⟨hx₀ins,hy₀ins⟩, \nend\n\nprivate def chain_upper_bound {hf : ¬(nilpotent f)} {s : set (subtype (no_pows_of_f hf))} (hs : is_chain s) (ns : s ≠ ∅) : ideal R \n  := proper_ideals_are_ideals (union_of_chain_of_ideals (cvrt_chain hs) (not_empty_image_not_empty cvrt ns))\n\nprivate lemma no_pow_of_f_chain_upper_bound  {hf : ¬(nilpotent f)} {s : set (subtype (no_pows_of_f hf))} (hs : is_chain s) (ns : s ≠ ∅) \n  : no_pows_of_f hf (chain_upper_bound hs ns) :=\nbegin\n  intros n ab,\n  cases ab with A hA,\n  cases hA with hAinIm hfninA,\n  cases hAinIm with I hI,\n  cases hI with hIinIm hIrw,\n  simp at hIrw,\n  cases hIinIm with J hJ,\n  cases hJ with hJins hJrw,\n  rw ← hIrw at hfninA,\n  rw ← hJrw at hfninA,\n  rw cvrt_body_eq at hfninA,\n  have h := J.property n,\n  apply h,\n  assumption, \nend\n\nprivate lemma chain_upper_bound_upper_bound {hf : ¬(nilpotent f)} {C : set (subtype (no_pows_of_f hf))} (hC : is_chain C) (nC : C ≠ ∅)\n  : bounds_subset C ⟨(chain_upper_bound hC nC), no_pow_of_f_chain_upper_bound hC nC⟩ :=\nbegin\n  intros J hJ,\n  rw cvrt_le,\n  intros x hx,\n  simp [cvrt_body_eq],\n  existsi (cvrt J).body,\n  split,\n  existsi cvrt J,\n  split,\n  existsi J,\n  exact ⟨hJ,rfl⟩,\n  refl,\n  assumption,\nend\n\nprivate def zero_ideal_no_f (hf : ¬(nilpotent f)) : subtype (no_pows_of_f hf) :=\nbegin\n  existsi zero_ideal R,\n  intros n ab,\n  apply hf,\n  existsi n,\n  apply zero_ideal_is_just_zero,\n  assumption,\nend\n\nprivate lemma pow_f_in_extension {hf : ¬(nilpotent f)} {J : subtype (no_pows_of_f hf)} \n  : maximal_element J → ∀ {x} , x ∉ J.val.body → ∃ n : ℕ, f^n.succ ∈ (J.val + (princple_ideal x)).body :=\nbegin\n  intros mJ x hx,\n  by_contradiction ab_raw,\n  have ab := forall_not_of_not_exists ab_raw,\n  simp at ab,\n  let J_ex : subtype (no_pows_of_f hf) := {val := J.val + princple_ideal x, property := ab },\n  have trv : J_ex.val = J.val + princple_ideal x := rfl,\n  have nJ_ex : J_ex ≠ J,\n    intro ab,\n    apply ideal_extension_proper hx,\n    rw ← trv,\n    rw ab,\n  apply nJ_ex,\n  apply mJ,\n  intros y hy,\n  rw trv,\n  existsi y,\n  existsi (0:R),\n  split,\n  exact hy,\n  split,\n  apply ideal.contains_zero,\n  rw add_zero,\nend \n\nprivate lemma maximal_no_pow_f_prime {hf : ¬(nilpotent f)} {J : subtype (no_pows_of_f hf)} \n  : maximal_element J → is_prime (cvrt J) := \nbegin\n  intros hJ x y,\n  apply contrapostive,\n  rw not_or_and_not_eqv,\n  simp [cvrt_body_eq],\n  intro hxy,\n  cases hxy with hx hy,\n  cases pow_f_in_extension hJ hx with n hn,\n  cases pow_f_in_extension hJ hy with m hm,\n  have main : f^(n.succ + m.succ) ∈ (J.val + princple_ideal (x*y)).body,\n    apply product_of_ideal_extension,\n    rw power_of_add,\n    apply product_in_product_of_ideals,\n    exact hn,\n    exact hm,\n  apply proper_ext_ideal_not_mem,\n  intro hrw,\n  rw hrw at main,\n  rw nat.add_succ n.succ m at main,\n  apply J.property,\n  exact main,\nend\n\nlemma thm (hf : ¬(nilpotent f)) : ∃ p : Spec R, f ∉ p.body := \nbegin\n  have hmaxnof : ∃ J : subtype (no_pows_of_f hf) , maximal_element J,\n    apply zorns_lemma,\n    intros C hC,\n    by_cases C = ∅,\n    existsi zero_ideal_no_f hf,\n    intros x hx,\n    rw h at hx,\n    exact false.elim hx,\n    existsi (⟨(chain_upper_bound hC h), no_pow_of_f_chain_upper_bound hC h⟩ : subtype (no_pows_of_f hf)),\n    exact chain_upper_bound_upper_bound hC h,\n  cases hmaxnof with J hJ,\n  existsi proper_to_prime (maximal_no_pow_f_prime hJ),\n  have trv : (proper_to_prime (maximal_no_pow_f_prime hJ)).body = (cvrt J).body := rfl,\n  rw trv,\n  rw cvrt_body_eq,\n  have res := J.property 0,\n  rw power_of_one at res,\n  assumption,\nend\n\nend not_nilpotent_not_in_some_prime_ideal\n\ntheorem nilradical_intersection_of_prime_ideals (R : Type u) [comm_ring R] : ↑(nilradical R) = nilradical_set R :=\nbegin\n  apply set.subset_antisymmetric,\n  split,\n  intro x,\n  apply contrapostive,\n  intro hx,\n  cases not_nilpotent_not_in_some_prime_ideal.thm hx with p hp,\n  intro ab,\n  apply hp,\n  apply ab,\n  existsi ↑p,\n  split,\n  apply image_membership,\n  trivial,\n  refl,\n  intros x hx,\n  intros A hA,\n  cases hA with I hI,\n  cases hI with hI hrw₁,\n  cases hI with p hp,\n  cases hp with trv hrw₂,\n  simp at hrw₁,\n  simp at hrw₂,\n  rw [← hrw₁,← hrw₂],\n  apply nilpotents_in_all_prime_ideals,\n  exact hx,\nend\n\ndef radical {R : Type u} [comm_ring R] (I:ideal R) : ideal R \n  := preimage_of_ideal (quot_ring_hom I) (nilradical (R/ᵣI))\n\nprefix `√` : 40 := radical\n\nlemma elements_of_radical {R : Type u} [comm_ring R] (I:ideal R) \n  : ∀ x : R, x ∈ (√I).body ↔ ∃ n : ℕ, x^n.succ ∈ I.body :=\nbegin\n  intro x,\n  split,\n  intro hx,\n  have trv₁ : quot_ring_hom I x ∈ ↑(nilradical (R/ᵣI)) := hx,\n  rw nilradical_intersection_of_prime_ideals (R/ᵣI) at trv₁,\n  cases trv₁ with n hn,\n  existsi n,\n  apply quotient_zero_implies_in_ideal,\n  simp,\n  rw ← ring_hom_prevs_pow at hn,\n  exact hn,\n  intro h,\n  cases h with n hn,\n  have hint : quot_ring_hom I x ∈ ↑(nilradical (R/ᵣI)),\n    rw nilradical_intersection_of_prime_ideals,\n    have hint₁ : nilpotent (quot_ring_hom I x),\n      existsi n,\n      rw ← ring_hom_prevs_pow,\n      apply in_ideal_implies_quotient_zero,\n      exact hn,\n    exact hint₁,\n  exact hint,\nend \n\ntheorem ideal_subset_of_radical {R : Type u} [comm_ring R] (I:ideal R)\n  : I.body ⊆ (√I).body :=\nbegin\n  intros x hx,\n  rw elements_of_radical I,\n  existsi 0,\n  rw power_of_one,\n  exact hx,\nend\n\ntheorem radical_idempotent {R : Type u} [comm_ring R] (I:ideal R)\n  : (√√I) = √I :=\nbegin\n  apply ideal_equality,\n  apply subset_antisymmetric,\n  split,\n  intros x hx,\n  rw elements_of_radical,\n  rw elements_of_radical at hx,\n  cases hx with n hx,\n  rw elements_of_radical at hx,\n  cases hx with m hx,\n  existsi n * m + n + m,\n  have hrw : (x^(n.succ))^m.succ = x^(n * m + n + m).succ,\n    rw power_of_power,\n    have sub : n.succ * m.succ = (n * m + n + m).succ,\n      rw nat.succ_mul,\n      rw nat.add_succ,\n      rw nat.mul_succ,\n    rw sub,\n  rw ← hrw,\n  exact hx,\n  apply ideal_subset_of_radical,\nend\n\n\n\nend comm_ring", "meta": {"author": "CameronTorrance", "repo": "Schemes", "sha": "f407ce80b8407101231170680b03b55984c42496", "save_path": "github-repos/lean/CameronTorrance-Schemes", "path": "github-repos/lean/CameronTorrance-Schemes/Schemes-f407ce80b8407101231170680b03b55984c42496/src/algebra/comm_rings/ideals/radicals.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.48433296467227954}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Abhimanyu Pallavi Sudhir\n\n! This file was ported from Lean 3 source module data.complex.exponential\n! leanprover-community/mathlib commit 372edc36e5d2caafdd135769e0136b5a59186834\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.GeomSum\nimport Mathlib.Data.Complex.Basic\nimport Mathlib.Data.Nat.Choose.Sum\n\n/-!\n# Exponential, trigonometric and hyperbolic trigonometric functions\n\nThis file contains the definitions of the real and complex exponential, sine, cosine, tangent,\nhyperbolic sine, hyperbolic cosine, and hyperbolic tangent functions.\n\n-/\n\n\n@[inherit_doc]\nlocal notation \"abs'\" => Abs.abs\n\nopen IsAbsoluteValue\n\nopen Classical BigOperators ComplexConjugate\n\nsection\n\nopen Real IsAbsoluteValue Finset\n\nsection\n\nvariable {α : Type _} {β : Type _} [Ring β] [LinearOrderedField α] [Archimedean α] {abv : β → α}\n  [IsAbsoluteValue abv]\n\ntheorem isCauSeq_of_decreasing_bounded (f : ℕ → α) {a : α} {m : ℕ} (ham : ∀ n ≥ m, |f n| ≤ a)\n    (hnm : ∀ n ≥ m, f n.succ ≤ f n) : IsCauSeq abs f := fun ε ε0 => by\n  let ⟨k, hk⟩ := Archimedean.arch a ε0\n  have h : ∃ l, ∀ n ≥ m, a - l • ε < f n :=\n    ⟨k + k + 1, fun n hnm =>\n      lt_of_lt_of_le\n        (show a - (k + (k + 1)) • ε < -|f n| from\n          lt_neg.1 <|\n            lt_of_le_of_lt (ham n hnm)\n              (by\n                rw [neg_sub, lt_sub_iff_add_lt, add_nsmul, add_nsmul, one_nsmul]\n                exact add_lt_add_of_le_of_lt hk (lt_of_le_of_lt hk (lt_add_of_pos_right _ ε0))))\n        (neg_le.2 <| abs_neg (f n) ▸ le_abs_self _)⟩\n  let l := Nat.find h\n  have hl : ∀ n : ℕ, n ≥ m → f n > a - l • ε := Nat.find_spec h\n  have hl0 : l ≠ 0 := fun hl0 =>\n    not_lt_of_ge (ham m le_rfl)\n      (lt_of_lt_of_le (by have := hl m (le_refl m); simpa [hl0] using this) (le_abs_self (f m)))\n  cases' not_forall.1 (Nat.find_min h (Nat.pred_lt hl0)) with i hi\n  rw [not_imp, not_lt] at hi\n  exists i\n  intro j hj\n  have hfij : f j ≤ f i := (Nat.rel_of_forall_rel_succ_of_le_of_le (· ≥ ·) hnm hi.1 hj).le\n  rw [abs_of_nonpos (sub_nonpos.2 hfij), neg_sub, sub_lt_iff_lt_add']\n  calc\n    f i ≤ a - Nat.pred l • ε := hi.2\n    _ = a - l • ε + ε := by\n      conv =>\n        rhs\n        rw [← Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hl0), succ_nsmul', sub_add,\n          add_sub_cancel]\n    _ < f j + ε := add_lt_add_right (hl j (le_trans hi.1 hj)) _\n\n#align is_cau_of_decreasing_bounded isCauSeq_of_decreasing_bounded\n\ntheorem isCauSeq_of_mono_bounded (f : ℕ → α) {a : α} {m : ℕ} (ham : ∀ n ≥ m, |f n| ≤ a)\n    (hnm : ∀ n ≥ m, f n ≤ f n.succ) : IsCauSeq abs f := by\n  refine'\n    @Eq.ndrecOn (ℕ → α) _ (IsCauSeq abs) _ _\n      (-⟨_, @isCauSeq_of_decreasing_bounded _ _ _ (fun n => -f n) a m (by simpa) (by simpa)⟩ :\n          CauSeq α abs).2\n  ext\n  exact neg_neg _\n#align is_cau_of_mono_bounded isCauSeq_of_mono_bounded\n\nend\n\nsection NoArchimedean\n\nvariable {α : Type _} {β : Type _} [Ring β] [LinearOrderedField α] {abv : β → α}\n  [IsAbsoluteValue abv]\n\ntheorem isCauSeq_series_of_abv_le_of_isCauSeq {f : ℕ → β} {g : ℕ → α} (n : ℕ) :\n    (∀ m, n ≤ m → abv (f m) ≤ g m) →\n      (IsCauSeq abs fun n => ∑ i in range n, g i) → IsCauSeq abv fun n => ∑ i in range n, f i := by\n  intro hm hg ε ε0\n  cases' hg (ε / 2) (div_pos ε0 (by norm_num)) with i hi\n  exists max n i\n  intro j ji\n  have hi₁ := hi j (le_trans (le_max_right n i) ji)\n  have hi₂ := hi (max n i) (le_max_right n i)\n  have sub_le :=\n    abs_sub_le (∑ k in range j, g k) (∑ k in range i, g k) (∑ k in range (max n i), g k)\n  have := add_lt_add hi₁ hi₂\n  rw [abs_sub_comm (∑ k in range (max n i), g k), add_halves ε] at this\n  refine' lt_of_le_of_lt (le_trans (le_trans _ (le_abs_self _)) sub_le) this\n  generalize hk : j - max n i = k\n  clear this hi₂ hi₁ hi ε0 ε hg sub_le\n  rw [tsub_eq_iff_eq_add_of_le ji] at hk\n  rw [hk]\n  dsimp only\n  clear hk ji j\n  induction' k with k' hi\n  · simp [abv_zero abv]\n  · simp only [Nat.succ_add, Nat.succ_eq_add_one, Finset.sum_range_succ_comm]\n    simp only [add_assoc, sub_eq_add_neg]\n    refine le_trans (abv_add _ _ _) ?_\n    simp only [sub_eq_add_neg] at hi\n    refine add_le_add (hm _ (le_add_of_nonneg_of_le (Nat.zero_le _) (le_max_left _ _))) hi\n#align is_cau_series_of_abv_le_cau isCauSeq_series_of_abv_le_of_isCauSeq\n\ntheorem isCauSeq_series_of_abv_isCauSeq {f : ℕ → β} :\n    (IsCauSeq abs fun m => ∑ n in range m, abv (f n)) → IsCauSeq abv fun m => ∑ n in range m, f n :=\n  isCauSeq_series_of_abv_le_of_isCauSeq 0 fun _ _ => le_rfl\n#align is_cau_series_of_abv_cau isCauSeq_series_of_abv_isCauSeq\n\nend NoArchimedean\n\nsection\n\nvariable {α : Type _} [LinearOrderedField α] [Archimedean α]\n\ntheorem isCauSeq_geo_series {β : Type _} [Ring β] [Nontrivial β] {abv : β → α} [IsAbsoluteValue abv]\n    (x : β) (hx1 : abv x < 1) : IsCauSeq abv fun n => ∑ m in range n, x ^ m :=\n  have hx1' : abv x ≠ 1 := fun h => by simp [h, lt_irrefl] at hx1\n  isCauSeq_series_of_abv_isCauSeq\n    (by\n      simp only [abv_pow abv, geom_sum_eq hx1']\n      conv in _ / _ => rw [← neg_div_neg_eq, neg_sub, neg_sub]\n      refine' @isCauSeq_of_mono_bounded _ _ _ _ ((1 : α) / (1 - abv x)) 0 _ _\n      · intro n hn\n        rw [abs_of_nonneg]\n        refine'\n          div_le_div_of_le (le_of_lt <| sub_pos.2 hx1)\n            (sub_le_self _ (abv_pow abv x n ▸ abv_nonneg _ _))\n        refine' div_nonneg (sub_nonneg.2 _) (sub_nonneg.2 <| le_of_lt hx1)\n        clear hn\n        induction' n with n ih\n        · simp\n        · rw [pow_succ, ← one_mul (1 : α)]\n          refine' mul_le_mul (le_of_lt hx1) ih (abv_pow abv x n ▸ abv_nonneg _ _) (by norm_num)\n      · intro n _\n        refine' div_le_div_of_le (le_of_lt <| sub_pos.2 hx1) (sub_le_sub_left _ _)\n        rw [←one_mul (abv x ^ n), pow_succ]\n        exact mul_le_mul_of_nonneg_right (le_of_lt hx1) (pow_nonneg (abv_nonneg _ _) _))\n#align is_cau_geo_series isCauSeq_geo_series\n\ntheorem isCauSeq_geo_series_const (a : α) {x : α} (hx1 : |x| < 1) :\n    IsCauSeq abs fun m => ∑ n in range m, (a * x ^ n) := by\n  have : IsCauSeq abs fun m => a * ∑ n in range m, (x ^ n) :=\n    (CauSeq.const abs a *\n      (show CauSeq α abs from ⟨fun n => ∑ m in range n, x ^ m, isCauSeq_geo_series x hx1⟩)).2\n  simpa [mul_sum] using this\n#align is_cau_geo_series_const isCauSeq_geo_series_const\n\nvariable {β : Type _} [Ring β] {abv : β → α} [IsAbsoluteValue abv]\n\ntheorem series_ratio_test {f : ℕ → β} (n : ℕ) (r : α) (hr0 : 0 ≤ r) (hr1 : r < 1)\n    (h : ∀ m, n ≤ m → abv (f m.succ) ≤ r * abv (f m)) : IsCauSeq abv fun m => ∑ n in range m, f n :=\n  by\n  have har1 : |r| < 1 := by rwa [abs_of_nonneg hr0]\n  refine'\n    isCauSeq_series_of_abv_le_of_isCauSeq n.succ _\n      (isCauSeq_geo_series_const (abv (f n.succ) * r⁻¹ ^ n.succ) har1)\n  intro m hmn\n  cases' Classical.em (r = 0) with r_zero r_ne_zero\n  · have m_pos := lt_of_lt_of_le (Nat.succ_pos n) hmn\n    have := h m.pred (Nat.le_of_succ_le_succ (by rwa [Nat.succ_pred_eq_of_pos m_pos]))\n    simpa [r_zero, Nat.succ_pred_eq_of_pos m_pos, pow_succ] using this\n  generalize hk : m - n.succ = k\n  have r_pos : 0 < r := lt_of_le_of_ne hr0 (Ne.symm r_ne_zero)\n  replace hk : m = k + n.succ := (tsub_eq_iff_eq_add_of_le hmn).1 hk\n  induction' k with k ih generalizing m n\n  · rw [hk, Nat.zero_add, mul_right_comm, inv_pow _ _, ← div_eq_mul_inv, mul_div_cancel]\n    exact le_refl _\n    exact (ne_of_lt (pow_pos r_pos _)).symm\n  · have kn : k + n.succ ≥ n.succ := by\n      rw [← zero_add n.succ]; exact add_le_add (Nat.zero_le _) (by simp)\n    erw [hk, Nat.succ_add, pow_succ' r, ← mul_assoc]\n    refine\n      le_trans (by rw [mul_comm] <;> exact h _ (Nat.le_of_succ_le kn))\n        (mul_le_mul_of_nonneg_right ?_ hr0)\n    exact ih _ h _ (by simp) rfl\n\n#align series_ratio_test series_ratio_test\n\ntheorem sum_range_diag_flip {α : Type _} [AddCommMonoid α] (n : ℕ) (f : ℕ → ℕ → α) :\n    (∑ m in range n, ∑ k in range (m + 1), f k (m - k)) =\n      ∑ m in range n, ∑ k in range (n - m), f m k := by\n  rw [sum_sigma', sum_sigma']\n  exact\n    sum_bij (fun a _ => ⟨a.2, a.1 - a.2⟩)\n      (fun a ha =>\n        have h₁ : a.1 < n := mem_range.1 (mem_sigma.1 ha).1\n        have h₂ : a.2 < Nat.succ a.1 := mem_range.1 (mem_sigma.1 ha).2\n        mem_sigma.2\n          ⟨mem_range.2 (lt_of_lt_of_le h₂ h₁),\n            mem_range.2 ((tsub_lt_tsub_iff_right (Nat.le_of_lt_succ h₂)).2 h₁)⟩)\n      (fun _ _ => rfl)\n      (fun ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ha hb h =>\n        have ha : a₁ < n ∧ a₂ ≤ a₁ :=\n          ⟨mem_range.1 (mem_sigma.1 ha).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 ha).2)⟩\n        have hb : b₁ < n ∧ b₂ ≤ b₁ :=\n          ⟨mem_range.1 (mem_sigma.1 hb).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 hb).2)⟩\n        have h : a₂ = b₂ ∧ _ := by simpa using h\n        have h' : a₁ = b₁ - b₂ + a₂ := (tsub_eq_iff_eq_add_of_le ha.2).1 (eq_of_heq h.2)\n        Sigma.mk.inj_iff.2 ⟨tsub_add_cancel_of_le hb.2 ▸ h'.symm ▸ h.1 ▸ rfl, heq_of_eq h.1⟩)\n      fun ⟨a₁, a₂⟩ ha =>\n      have ha : a₁ < n ∧ a₂ < n - a₁ :=\n        ⟨mem_range.1 (mem_sigma.1 ha).1, mem_range.1 (mem_sigma.1 ha).2⟩\n      ⟨⟨a₂ + a₁, a₁⟩,\n        ⟨mem_sigma.2\n            ⟨mem_range.2 (lt_tsub_iff_right.1 ha.2),\n              mem_range.2 (Nat.lt_succ_of_le (Nat.le_add_left _ _))⟩,\n          Sigma.mk.inj_iff.2 ⟨rfl, heq_of_eq (add_tsub_cancel_right _ _).symm⟩⟩⟩\n#align sum_range_diag_flip sum_range_diag_flip\n\nend\n\nsection NoArchimedean\n\nvariable {α : Type _} {β : Type _} [LinearOrderedField α] {abv : β → α}\n\nsection\n\nvariable [Semiring β] [IsAbsoluteValue abv]\n\ntheorem abv_sum_le_sum_abv {γ : Type _} (f : γ → β) (s : Finset γ) :\n    abv (∑ k in s, f k) ≤ ∑ k in s, abv (f k) :=\n  haveI := Classical.decEq γ\n  Finset.induction_on s (by simp [abv_zero abv]) fun a s has ih => by\n    rw [sum_insert has, sum_insert has]; exact le_trans (abv_add abv _ _) (add_le_add_left ih _)\n#align abv_sum_le_sum_abv abv_sum_le_sum_abv\n\nend\n\nsection\n\nvariable [Ring β] [IsAbsoluteValue abv]\n\ntheorem cauchy_product {a b : ℕ → β} (ha : IsCauSeq abs fun m => ∑ n in range m, abv (a n))\n    (hb : IsCauSeq abv fun m => ∑ n in range m, b n) (ε : α) (ε0 : 0 < ε) :\n    ∃ i : ℕ,\n      ∀ j ≥ i,\n        abv\n            (((∑ k in range j, a k) * ∑ k in range j, b k) -\n              ∑ n in range j, ∑ m in range (n + 1), a m * b (n - m)) <\n          ε :=\n  let ⟨Q, hQ⟩ := CauSeq.bounded ⟨_, hb⟩\n  let ⟨P, hP⟩ := CauSeq.bounded ⟨_, ha⟩\n  have hP0 : 0 < P := lt_of_le_of_lt (abs_nonneg _) (hP 0)\n  have hPε0 : 0 < ε / (2 * P) := div_pos ε0 (mul_pos (show (2 : α) > 0 by norm_num) hP0)\n  let ⟨N, hN⟩ := CauSeq.cauchy₂ ⟨_, hb⟩ hPε0\n  have hQε0 : 0 < ε / (4 * Q) :=\n    div_pos ε0 (mul_pos (show (0 : α) < 4 by norm_num) (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0)))\n  let ⟨M, hM⟩ := CauSeq.cauchy₂ ⟨_, ha⟩ hQε0\n  ⟨2 * (max N M + 1), fun K hK =>\n    by\n    have h₁ :\n      (∑ m in range K, ∑ k in range (m + 1), a k * b (m - k)) =\n        ∑ m in range K, ∑ n in range (K - m), a m * b n :=\n      by simpa using sum_range_diag_flip K fun m n => a m * b n\n    have h₂ :\n      (fun i => ∑ k in range (K - i), a i * b k) = fun i => a i * ∑ k in range (K - i), b k := by\n      simp [Finset.mul_sum]\n    have h₃ :\n      (∑ i in range K, a i * ∑ k in range (K - i), b k) =\n        (∑ i in range K, a i * ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) +\n          ∑ i in range K, a i * ∑ k in range K, b k :=\n      by rw [← sum_add_distrib]; simp [(mul_add _ _ _).symm]\n    have two_mul_two : (4 : α) = 2 * 2 := by norm_num\n    have hQ0 : Q ≠ 0 := fun h => by simp [h, lt_irrefl] at hQε0\n    have h2Q0 : 2 * Q ≠ 0 := mul_ne_zero two_ne_zero hQ0\n    have hε : ε / (2 * P) * P + ε / (4 * Q) * (2 * Q) = ε := by\n      rw [← div_div, div_mul_cancel _ (Ne.symm (ne_of_lt hP0)), two_mul_two, mul_assoc, ← div_div,\n        div_mul_cancel _ h2Q0, add_halves]\n    have hNMK : max N M + 1 < K :=\n      lt_of_lt_of_le (by rw [two_mul]; exact lt_add_of_pos_left _ (Nat.succ_pos _)) hK\n    have hKN : N < K :=\n      calc\n        N ≤ max N M := le_max_left _ _\n        _ < max N M + 1 := (Nat.lt_succ_self _)\n        _ < K := hNMK\n\n    have hsumlesum :\n      (∑ i in range (max N M + 1),\n          abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) ≤\n        ∑ i in range (max N M + 1), abv (a i) * (ε / (2 * P)) :=\n      sum_le_sum fun m hmJ =>\n        mul_le_mul_of_nonneg_left\n          (le_of_lt\n            (hN (K - m)\n              (le_tsub_of_add_le_left\n                (le_trans\n                  (by\n                    rw [two_mul]\n                    exact\n                      add_le_add (le_of_lt (mem_range.1 hmJ))\n                        (le_trans (le_max_left _ _) (le_of_lt (lt_add_one _))))\n                  hK))\n              K (le_of_lt hKN)))\n          (abv_nonneg abv _)\n    have hsumltP : (∑ n in range (max N M + 1), abv (a n)) < P :=\n      calc\n        (∑ n in range (max N M + 1), abv (a n)) = |∑ n in range (max N M + 1), abv (a n)| :=\n          Eq.symm (abs_of_nonneg (sum_nonneg fun x _ => abv_nonneg abv (a x)))\n        _ < P := hP (max N M + 1)\n\n    rw [h₁, h₂, h₃, sum_mul, ← sub_sub, sub_right_comm, sub_self, zero_sub, abv_neg abv]\n    refine' lt_of_le_of_lt (abv_sum_le_sum_abv _ _) _\n    suffices\n      (∑ i in range (max N M + 1),\n            abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) +\n          ((∑ i in range K, abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) -\n            ∑ i in range (max N M + 1),\n              abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) <\n        ε / (2 * P) * P + ε / (4 * Q) * (2 * Q)\n      by\n      rw [hε] at this\n      simpa [abv_mul abv] using this\n    refine'\n      add_lt_add\n        (lt_of_le_of_lt hsumlesum\n          (by rw [← sum_mul, mul_comm]; exact (mul_lt_mul_left hPε0).mpr hsumltP))\n        _\n    rw [sum_range_sub_sum_range (le_of_lt hNMK)]\n    calc\n      (∑ i in (range K).filter fun k => max N M + 1 ≤ k,\n            abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) ≤\n          ∑ i in (range K).filter fun k => max N M + 1 ≤ k, abv (a i) * (2 * Q) :=\n        sum_le_sum fun n _ =>\n          by\n          refine' mul_le_mul_of_nonneg_left _ (abv_nonneg _ _)\n          rw [sub_eq_add_neg]\n          refine' le_trans (abv_add _ _ _) _\n          rw [two_mul, abv_neg abv]\n          exact add_le_add (le_of_lt (hQ _)) (le_of_lt (hQ _))\n      _ < ε / (4 * Q) * (2 * Q) := by\n        rw [← sum_mul, ← sum_range_sub_sum_range (le_of_lt hNMK)];\n          refine'\n            (mul_lt_mul_right <| by\n                  rw [two_mul]\n                  exact\n                    add_pos (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))\n                      (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))).2\n              (lt_of_le_of_lt (le_abs_self _)\n                (hM _ (le_trans (Nat.le_succ_of_le (le_max_right _ _)) (le_of_lt hNMK)) _\n                  (Nat.le_succ_of_le (le_max_right _ _))))\n      ⟩\n#align cauchy_product cauchy_product\n\nend\n\nend NoArchimedean\n\nend\n\nopen Finset\n\nopen CauSeq\n\nnamespace Complex\n\ntheorem isCauSeq_abs_exp (z : ℂ) :\n    IsCauSeq Abs.abs fun n => ∑ m in range n, abs (z ^ m / m.factorial) :=\n  let ⟨n, hn⟩ := exists_nat_gt (abs z)\n  have hn0 : (0 : ℝ) < n := lt_of_le_of_lt (abs.nonneg _) hn\n  series_ratio_test n (abs z / n) (div_nonneg (abs.nonneg _) (le_of_lt hn0))\n    (by rwa [div_lt_iff hn0, one_mul]) fun m hm => by\n      rw [abs_abs, abs_abs, Nat.factorial_succ, pow_succ, mul_comm m.succ, Nat.cast_mul, ← div_div,\n        mul_div_assoc, mul_div_right_comm, map_mul, map_div₀, abs_cast_nat]\n      exact\n        mul_le_mul_of_nonneg_right\n          (div_le_div_of_le_left (abs.nonneg _) hn0 (Nat.cast_le.2 (le_trans hm (Nat.le_succ _))))\n          (abs.nonneg _)\n#align complex.is_cau_abs_exp Complex.isCauSeq_abs_exp\n\nnoncomputable section\n\ntheorem isCauSeq_exp (z : ℂ) : IsCauSeq abs fun n => ∑ m in range n, z ^ m / m.factorial :=\n  isCauSeq_series_of_abv_isCauSeq (isCauSeq_abs_exp z)\n#align complex.is_cau_exp Complex.isCauSeq_exp\n\n/-- The Cauchy sequence consisting of partial sums of the Taylor series of\nthe complex exponential function -/\n----@[pp_nodot] Porting note: removed Porting note: removed\ndef exp' (z : ℂ) : CauSeq ℂ Complex.abs :=\n  ⟨fun n => ∑ m in range n, z ^ m / m.factorial, isCauSeq_exp z⟩\n#align complex.exp' Complex.exp'\n\n/-- The complex exponential function, defined via its Taylor series -/\n--@[pp_nodot] Porting note: removed\n--Porting note: removed `irreducible` attribute, so I can prove things\ndef exp (z : ℂ) : ℂ :=\n  CauSeq.lim (exp' z)\n#align complex.exp Complex.exp\n\n/-- The complex sine function, defined via `exp` -/\n--@[pp_nodot] Porting note: removed\ndef sin (z : ℂ) : ℂ :=\n  (exp (-z * I) - exp (z * I)) * I / 2\n#align complex.sin Complex.sin\n\n/-- The complex cosine function, defined via `exp` -/\n--@[pp_nodot] Porting note: removed\ndef cos (z : ℂ) : ℂ :=\n  (exp (z * I) + exp (-z * I)) / 2\n#align complex.cos Complex.cos\n\n/-- The complex tangent function, defined as `sin z / cos z` -/\n--@[pp_nodot] Porting note: removed\ndef tan (z : ℂ) : ℂ :=\n  sin z / cos z\n#align complex.tan Complex.tan\n\n/-- The complex hyperbolic sine function, defined via `exp` -/\n--@[pp_nodot] Porting note: removed\ndef sinh (z : ℂ) : ℂ :=\n  (exp z - exp (-z)) / 2\n#align complex.sinh Complex.sinh\n\n/-- The complex hyperbolic cosine function, defined via `exp` -/\n--@[pp_nodot] Porting note: removed\ndef cosh (z : ℂ) : ℂ :=\n  (exp z + exp (-z)) / 2\n#align complex.cosh Complex.cosh\n\n/-- The complex hyperbolic tangent function, defined as `sinh z / cosh z` -/\n--@[pp_nodot] Porting note: removed\ndef tanh (z : ℂ) : ℂ :=\n  sinh z / cosh z\n#align complex.tanh Complex.tanh\n\nend\n\nend Complex\n\nnamespace Real\n\nopen Complex\n\nnoncomputable section\n\n/-- The real exponential function, defined as the real part of the complex exponential -/\n--@[pp_nodot] Porting note: removed\nnonrec def exp (x : ℝ) : ℝ :=\n  (exp x).re\n#align real.exp Real.exp\n\n/-- The real sine function, defined as the real part of the complex sine -/\n--@[pp_nodot] Porting note: removed\nnonrec def sin (x : ℝ) : ℝ :=\n  (sin x).re\n#align real.sin Real.sin\n\n/-- The real cosine function, defined as the real part of the complex cosine -/\n--@[pp_nodot] Porting note: removed\nnonrec def cos (x : ℝ) : ℝ :=\n  (cos x).re\n#align real.cos Real.cos\n\n/-- The real tangent function, defined as the real part of the complex tangent -/\n--@[pp_nodot] Porting note: removed\nnonrec def tan (x : ℝ) : ℝ :=\n  (tan x).re\n#align real.tan Real.tan\n\n/-- The real hypebolic sine function, defined as the real part of the complex hyperbolic sine -/\n--@[pp_nodot] Porting note: removed\nnonrec def sinh (x : ℝ) : ℝ :=\n  (sinh x).re\n#align real.sinh Real.sinh\n\n/-- The real hypebolic cosine function, defined as the real part of the complex hyperbolic cosine -/\n--@[pp_nodot] Porting note: removed\nnonrec def cosh (x : ℝ) : ℝ :=\n  (cosh x).re\n#align real.cosh Real.cosh\n\n/-- The real hypebolic tangent function, defined as the real part of\nthe complex hyperbolic tangent -/\n--@[pp_nodot] Porting note: removed\nnonrec def tanh (x : ℝ) : ℝ :=\n  (tanh x).re\n#align real.tanh Real.tanh\n\nend\n\nend Real\n\nnamespace Complex\n\nvariable (x y : ℂ)\n\n@[simp]\ntheorem exp_zero : exp 0 = 1 := by\n  rw [exp]\n  refine' lim_eq_of_equiv_const fun ε ε0 => ⟨1, fun j hj => _⟩\n  convert (config := .unfoldSameFun) ε0 -- porting note: ε0 : ε > 0 but goal is _ < ε\n  cases' j with j j\n  · exact absurd hj (not_le_of_gt zero_lt_one)\n  · dsimp [exp']\n    induction' j with j ih\n    · dsimp [exp']; simp [show Nat.succ 0 = 1 from rfl]\n    · rw [← ih (by simp [show 1 = Nat.succ 0 from rfl, Nat.succ_le_succ])]\n      simp only [sum_range_succ, pow_succ]\n      simp\n#align complex.exp_zero Complex.exp_zero\n\ntheorem exp_add : exp (x + y) = exp x * exp y := by\n  have hj : ∀ j : ℕ, (∑ m in range j, (x + y) ^ m / m.factorial) =\n        ∑ i in range j, ∑ k in range (i + 1), x ^ k / k.factorial *\n          (y ^ (i - k) / (i - k).factorial) := by\n    intro j\n    refine' Finset.sum_congr rfl fun m _ => _\n    rw [add_pow, div_eq_mul_inv, sum_mul]\n    refine' Finset.sum_congr rfl fun I hi => _\n    have h₁ : (m.choose I : ℂ) ≠ 0 :=\n      Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.choose_pos (Nat.le_of_lt_succ (mem_range.1 hi))))\n    have h₂ := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi)\n    rw [← h₂, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv]\n    simp only [mul_left_comm (m.choose I : ℂ), mul_assoc, mul_left_comm (m.choose I : ℂ)⁻¹,\n      mul_comm (m.choose I : ℂ)]\n    rw [inv_mul_cancel h₁]\n    simp [div_eq_mul_inv, mul_comm, mul_assoc, mul_left_comm]\n  simp_rw [exp, exp', lim_mul_lim]\n  apply (lim_eq_lim_of_equiv _).symm\n  simp only [hj]\n  exact cauchy_product (isCauSeq_abs_exp x) (isCauSeq_exp y)\n#align complex.exp_add Complex.exp_add\n\n--Porting note: New definition\n/-- the exponential function as a monoid hom from `Multiplicative ℂ` to `ℂ` -/\nnoncomputable def expMonoidHom : MonoidHom (Multiplicative ℂ) ℂ :=\n  { toFun := fun z => exp (Multiplicative.toAdd z),\n    map_one' := by simp,\n    map_mul' := by simp [exp_add] }\n\ntheorem exp_list_sum (l : List ℂ) : exp l.sum = (l.map exp).prod :=\n  @MonoidHom.map_list_prod (Multiplicative ℂ) ℂ _ _ expMonoidHom l\n#align complex.exp_list_sum Complex.exp_list_sum\n\ntheorem exp_multiset_sum (s : Multiset ℂ) : exp s.sum = (s.map exp).prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative ℂ) ℂ _ _ expMonoidHom s\n#align complex.exp_multiset_sum Complex.exp_multiset_sum\n\ntheorem exp_sum {α : Type _} (s : Finset α) (f : α → ℂ) :\n    exp (∑ x in s, f x) = ∏ x in s, exp (f x) :=\n  @map_prod (Multiplicative ℂ) α ℂ _ _ _ _ expMonoidHom f s\n#align complex.exp_sum Complex.exp_sum\n\ntheorem exp_nat_mul (x : ℂ) : ∀ n : ℕ, exp (n * x) = exp x ^ n\n  | 0 => by rw [Nat.cast_zero, zero_mul, exp_zero, pow_zero]\n  | Nat.succ n => by rw [pow_succ', Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul _ n, one_mul]\n#align complex.exp_nat_mul Complex.exp_nat_mul\n\ntheorem exp_ne_zero : exp x ≠ 0 := fun h =>\n  zero_ne_one <| by rw [← exp_zero, ← add_neg_self x, exp_add, h]; simp\n#align complex.exp_ne_zero Complex.exp_ne_zero\n\ntheorem exp_neg : exp (-x) = (exp x)⁻¹ := by\n  rw [← mul_right_inj' (exp_ne_zero x), ← exp_add]; simp [mul_inv_cancel (exp_ne_zero x)]\n#align complex.exp_neg Complex.exp_neg\n\ntheorem exp_sub : exp (x - y) = exp x / exp y := by\n  simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv]\n#align complex.exp_sub Complex.exp_sub\n\ntheorem exp_int_mul (z : ℂ) (n : ℤ) : Complex.exp (n * z) = Complex.exp z ^ n := by\n  cases n\n  . simp [exp_nat_mul]\n  . simp [exp_add, add_mul, pow_add, exp_neg, exp_nat_mul]\n#align complex.exp_int_mul Complex.exp_int_mul\n\n@[simp]\n\n\n@[simp]\ntheorem ofReal_exp_ofReal_re (x : ℝ) : ((exp x).re : ℂ) = exp x :=\n  eq_conj_iff_re.1 <| by rw [← exp_conj, conj_ofReal]\n#align complex.of_real_exp_of_real_re Complex.ofReal_exp_ofReal_re\n\n@[simp, norm_cast]\ntheorem ofReal_exp (x : ℝ) : (Real.exp x : ℂ) = exp x :=\n  ofReal_exp_ofReal_re _\n#align complex.of_real_exp Complex.ofReal_exp\n\n@[simp]\ntheorem exp_ofReal_im (x : ℝ) : (exp x).im = 0 := by rw [← ofReal_exp_ofReal_re, ofReal_im]\n#align complex.exp_of_real_im Complex.exp_ofReal_im\n\ntheorem exp_ofReal_re (x : ℝ) : (exp x).re = Real.exp x :=\n  rfl\n#align complex.exp_of_real_re Complex.exp_ofReal_re\n\ntheorem two_sinh : 2 * sinh x = exp x - exp (-x) :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_sinh Complex.two_sinh\n\ntheorem two_cosh : 2 * cosh x = exp x + exp (-x) :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_cosh Complex.two_cosh\n\n@[simp]\ntheorem sinh_zero : sinh 0 = 0 := by simp [sinh]\n#align complex.sinh_zero Complex.sinh_zero\n\n@[simp]\ntheorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul]\n#align complex.sinh_neg Complex.sinh_neg\n\nprivate theorem sinh_add_aux {a b c d : ℂ} :\n    (a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring\n\ntheorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, ←\n    mul_assoc, two_sinh, mul_left_comm, two_sinh, ← mul_right_inj' (two_ne_zero' ℂ), mul_add,\n    mul_left_comm, two_cosh, ← mul_assoc, two_cosh]\n  exact sinh_add_aux\n#align complex.sinh_add Complex.sinh_add\n\n@[simp]\ntheorem cosh_zero : cosh 0 = 1 := by simp [cosh]\n#align complex.cosh_zero Complex.cosh_zero\n\n@[simp]\ntheorem cosh_neg : cosh (-x) = cosh x := by simp [add_comm, cosh, exp_neg]\n#align complex.cosh_neg Complex.cosh_neg\n\nprivate theorem cosh_add_aux {a b c d : ℂ} :\n    (a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring\n\ntheorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, ←\n    mul_assoc, two_cosh, ← mul_assoc, two_sinh, ← mul_right_inj' (two_ne_zero' ℂ), mul_add,\n    mul_left_comm, two_cosh, mul_left_comm, two_sinh]\n  exact cosh_add_aux\n#align complex.cosh_add Complex.cosh_add\n\ntheorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by\n  simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg]\n#align complex.sinh_sub Complex.sinh_sub\n\ntheorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by\n  simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg]\n#align complex.cosh_sub Complex.cosh_sub\n\ntheorem sinh_conj : sinh (conj x) = conj (sinh x) := by\n  rw [sinh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_sub, sinh, map_div₀]\n  --Porting note: not nice\n  simp [← one_add_one_eq_two]\n#align complex.sinh_conj Complex.sinh_conj\n\n@[simp]\ntheorem ofReal_sinh_ofReal_re (x : ℝ) : ((sinh x).re : ℂ) = sinh x :=\n  eq_conj_iff_re.1 <| by rw [← sinh_conj, conj_ofReal]\n#align complex.of_real_sinh_of_real_re Complex.ofReal_sinh_ofReal_re\n\n@[simp, norm_cast]\ntheorem ofReal_sinh (x : ℝ) : (Real.sinh x : ℂ) = sinh x :=\n  ofReal_sinh_ofReal_re _\n#align complex.of_real_sinh Complex.ofReal_sinh\n\n@[simp]\ntheorem sinh_of_real_im (x : ℝ) : (sinh x).im = 0 := by rw [← ofReal_sinh_ofReal_re, ofReal_im]\n#align complex.sinh_of_real_im Complex.sinh_of_real_im\n\ntheorem sinh_of_real_re (x : ℝ) : (sinh x).re = Real.sinh x :=\n  rfl\n#align complex.sinh_of_real_re Complex.sinh_of_real_re\n\ntheorem cosh_conj : cosh (conj x) = conj (cosh x) := by\n  rw [cosh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_add, cosh, map_div₀]\n  --Porting note: not nice\n  simp [← one_add_one_eq_two]\n#align complex.cosh_conj Complex.cosh_conj\n\ntheorem ofReal_cosh_ofReal_re (x : ℝ) : ((cosh x).re : ℂ) = cosh x :=\n  eq_conj_iff_re.1 <| by rw [← cosh_conj, conj_ofReal]\n#align complex.of_real_cosh_of_real_re Complex.ofReal_cosh_ofReal_re\n\n@[simp, norm_cast]\ntheorem ofReal_cosh (x : ℝ) : (Real.cosh x : ℂ) = cosh x :=\n  ofReal_cosh_ofReal_re _\n#align complex.of_real_cosh Complex.ofReal_cosh\n\n@[simp]\ntheorem cosh_ofReal_im (x : ℝ) : (cosh x).im = 0 := by rw [← ofReal_cosh_ofReal_re, ofReal_im]\n#align complex.cosh_of_real_im Complex.cosh_ofReal_im\n\n@[simp]\ntheorem cosh_ofReal_re (x : ℝ) : (cosh x).re = Real.cosh x :=\n  rfl\n#align complex.cosh_of_real_re Complex.cosh_ofReal_re\n\ntheorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x :=\n  rfl\n#align complex.tanh_eq_sinh_div_cosh Complex.tanh_eq_sinh_div_cosh\n\n@[simp]\ntheorem tanh_zero : tanh 0 = 0 := by simp [tanh]\n#align complex.tanh_zero Complex.tanh_zero\n\n@[simp]\ntheorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div]\n#align complex.tanh_neg Complex.tanh_neg\n\ntheorem tanh_conj : tanh (conj x) = conj (tanh x) := by\n  rw [tanh, sinh_conj, cosh_conj, ← map_div₀, tanh]\n#align complex.tanh_conj Complex.tanh_conj\n\n@[simp]\ntheorem ofReal_tanh_ofReal_re (x : ℝ) : ((tanh x).re : ℂ) = tanh x :=\n  eq_conj_iff_re.1 <| by rw [← tanh_conj, conj_ofReal]\n#align complex.of_real_tanh_of_real_re Complex.ofReal_tanh_ofReal_re\n\n@[simp, norm_cast]\ntheorem ofReal_tanh (x : ℝ) : (Real.tanh x : ℂ) = tanh x :=\n  ofReal_tanh_ofReal_re _\n#align complex.of_real_tanh Complex.ofReal_tanh\n\n@[simp]\ntheorem tanh_ofReal_im (x : ℝ) : (tanh x).im = 0 := by rw [← ofReal_tanh_ofReal_re, ofReal_im]\n#align complex.tanh_of_real_im Complex.tanh_ofReal_im\n\ntheorem tanh_ofReal_re (x : ℝ) : (tanh x).re = Real.tanh x :=\n  rfl\n#align complex.tanh_of_real_re Complex.tanh_ofReal_re\n\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), mul_add, two_cosh, two_sinh, add_add_sub_cancel, two_mul]\n#align complex.cosh_add_sinh Complex.cosh_add_sinh\n\n@[simp]\ntheorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh]\n#align complex.sinh_add_cosh Complex.sinh_add_cosh\n\n@[simp]\ntheorem exp_sub_cosh : exp x - cosh x = sinh x :=\n  sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm\n#align complex.exp_sub_cosh Complex.exp_sub_cosh\n\n@[simp]\ntheorem exp_sub_sinh : exp x - sinh x = cosh x :=\n  sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm\n#align complex.exp_sub_sinh Complex.exp_sub_sinh\n\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), mul_sub, two_cosh, two_sinh, add_sub_sub_cancel, two_mul]\n#align complex.cosh_sub_sinh Complex.cosh_sub_sinh\n\n@[simp]\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh]\n#align complex.sinh_sub_cosh Complex.sinh_sub_cosh\n\n@[simp]\ntheorem cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 := by\n  rw [sq_sub_sq, cosh_add_sinh, cosh_sub_sinh, ← exp_add, add_neg_self, exp_zero]\n#align complex.cosh_sq_sub_sinh_sq Complex.cosh_sq_sub_sinh_sq\n\ntheorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by\n  rw [← cosh_sq_sub_sinh_sq x]\n  ring\n#align complex.cosh_sq Complex.cosh_sq\n\ntheorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by\n  rw [← cosh_sq_sub_sinh_sq x]\n  ring\n#align complex.sinh_sq Complex.sinh_sq\n\ntheorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by rw [two_mul, cosh_add, sq, sq]\n#align complex.cosh_two_mul Complex.cosh_two_mul\n\ntheorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by\n  rw [two_mul, sinh_add]\n  ring\n#align complex.sinh_two_mul Complex.sinh_two_mul\n\ntheorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, cosh_add x (2 * x)]\n  simp only [cosh_two_mul, sinh_two_mul]\n  have h2 : sinh x * (2 * sinh x * cosh x) = 2 * cosh x * sinh x ^ 2 := by ring\n  rw [h2, sinh_sq]\n  ring\n#align complex.cosh_three_mul Complex.cosh_three_mul\n\ntheorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, sinh_add x (2 * x)]\n  simp only [cosh_two_mul, sinh_two_mul]\n  have h2 : cosh x * (2 * sinh x * cosh x) = 2 * sinh x * cosh x ^ 2 := by ring\n  rw [h2, cosh_sq]\n  ring\n#align complex.sinh_three_mul Complex.sinh_three_mul\n\n@[simp]\ntheorem sin_zero : sin 0 = 0 := by simp [sin]\n#align complex.sin_zero Complex.sin_zero\n\n@[simp]\ntheorem sin_neg : sin (-x) = -sin x := by\n  simp [sin, sub_eq_add_neg, exp_neg, (neg_div _ _).symm, add_mul]\n#align complex.sin_neg Complex.sin_neg\n\ntheorem two_sin : 2 * sin x = (exp (-x * I) - exp (x * I)) * I :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_sin Complex.two_sin\n\ntheorem two_cos : 2 * cos x = exp (x * I) + exp (-x * I) :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_cos Complex.two_cos\n\ntheorem sinh_mul_I : sinh (x * I) = sin x * I := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_sinh, ← mul_assoc, two_sin, mul_assoc, I_mul_I,\n    mul_neg_one, neg_sub, neg_mul_eq_neg_mul]\nset_option linter.uppercaseLean3 false in\n#align complex.sinh_mul_I Complex.sinh_mul_I\n\ntheorem cosh_mul_I : cosh (x * I) = cos x := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_cosh, two_cos, neg_mul_eq_neg_mul]\nset_option linter.uppercaseLean3 false in\n#align complex.cosh_mul_I Complex.cosh_mul_I\n\ntheorem tanh_mul_I : tanh (x * I) = tan x * I := by\n  rw [tanh_eq_sinh_div_cosh, cosh_mul_I, sinh_mul_I, mul_div_right_comm, tan]\nset_option linter.uppercaseLean3 false in\n#align complex.tanh_mul_I Complex.tanh_mul_I\n\ntheorem cos_mul_I : cos (x * I) = cosh x := by rw [← cosh_mul_I]; ring_nf; simp\nset_option linter.uppercaseLean3 false in\n#align complex.cos_mul_I Complex.cos_mul_I\n\ntheorem sin_mul_I : sin (x * I) = sinh x * I := by\n  have h : I * sin (x * I) = -sinh x :=\n    by\n    rw [mul_comm, ← sinh_mul_I]\n    ring_nf\n    simp\n  rw [← neg_neg (sinh x), ← h]\n  ext <;> simp\nset_option linter.uppercaseLean3 false in\n#align complex.sin_mul_I Complex.sin_mul_I\n\ntheorem tan_mul_I : tan (x * I) = tanh x * I := by\n  rw [tan, sin_mul_I, cos_mul_I, mul_div_right_comm, tanh_eq_sinh_div_cosh]\nset_option linter.uppercaseLean3 false in\n#align complex.tan_mul_I Complex.tan_mul_I\n\ntheorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y := by\n  rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, add_mul, add_mul, mul_right_comm, ← sinh_mul_I,\n    mul_assoc, ← sinh_mul_I, ← cosh_mul_I, ← cosh_mul_I, sinh_add]\n#align complex.sin_add Complex.sin_add\n\n@[simp]\ntheorem cos_zero : cos 0 = 1 := by simp [cos]\n#align complex.cos_zero Complex.cos_zero\n\n@[simp]\ntheorem cos_neg : cos (-x) = cos x := by simp [cos, sub_eq_add_neg, exp_neg, add_comm]\n#align complex.cos_neg Complex.cos_neg\n\nprivate theorem cos_add_aux {a b c d : ℂ} :\n    (a + b) * (c + d) - (b - a) * (d - c) * -1 = 2 * (a * c + b * d) := by ring\n\ntheorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y := by\n  rw [← cosh_mul_I, add_mul, cosh_add, cosh_mul_I, cosh_mul_I, sinh_mul_I, sinh_mul_I,\n    mul_mul_mul_comm, I_mul_I, mul_neg_one, sub_eq_add_neg]\n#align complex.cos_add Complex.cos_add\n\ntheorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by\n  simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg]\n#align complex.sin_sub Complex.sin_sub\n\ntheorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by\n  simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg]\n#align complex.cos_sub Complex.cos_sub\n\ntheorem sin_add_mul_I (x y : ℂ) : sin (x + y * I) = sin x * cosh y + cos x * sinh y * I := by\n  rw [sin_add, cos_mul_I, sin_mul_I, mul_assoc]\nset_option linter.uppercaseLean3 false in\n#align complex.sin_add_mul_I Complex.sin_add_mul_I\n\ntheorem sin_eq (z : ℂ) : sin z = sin z.re * cosh z.im + cos z.re * sinh z.im * I := by\n  convert sin_add_mul_I z.re z.im; exact (re_add_im z).symm\n#align complex.sin_eq Complex.sin_eq\n\ntheorem cos_add_mul_I (x y : ℂ) : cos (x + y * I) = cos x * cosh y - sin x * sinh y * I := by\n  rw [cos_add, cos_mul_I, sin_mul_I, mul_assoc]\nset_option linter.uppercaseLean3 false in\n#align complex.cos_add_mul_I Complex.cos_add_mul_I\n\ntheorem cos_eq (z : ℂ) : cos z = cos z.re * cosh z.im - sin z.re * sinh z.im * I := by\n  convert cos_add_mul_I z.re z.im; exact (re_add_im z).symm\n#align complex.cos_eq Complex.cos_eq\n\ntheorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) := by\n  have s1 := sin_add ((x + y) / 2) ((x - y) / 2)\n  have s2 := sin_sub ((x + y) / 2) ((x - y) / 2)\n  rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel, half_add_self] at s1\n  rw [div_sub_div_same, ← sub_add, add_sub_cancel', half_add_self] at s2\n  rw [s1, s2]\n  ring\n#align complex.sin_sub_sin Complex.sin_sub_sin\n\ntheorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) := by\n  have s1 := cos_add ((x + y) / 2) ((x - y) / 2)\n  have s2 := cos_sub ((x + y) / 2) ((x - y) / 2)\n  rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel, half_add_self] at s1\n  rw [div_sub_div_same, ← sub_add, add_sub_cancel', half_add_self] at s2\n  rw [s1, s2]\n  ring\n#align complex.cos_sub_cos Complex.cos_sub_cos\n\ntheorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := by\n  have h2 : (2 : ℂ) ≠ 0 := by norm_num\n  calc\n    cos x + cos y = cos ((x + y) / 2 + (x - y) / 2) + cos ((x + y) / 2 - (x - y) / 2) := ?_\n    _ =\n        cos ((x + y) / 2) * cos ((x - y) / 2) - sin ((x + y) / 2) * sin ((x - y) / 2) +\n          (cos ((x + y) / 2) * cos ((x - y) / 2) + sin ((x + y) / 2) * sin ((x - y) / 2)) :=\n      ?_\n    _ = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := ?_\n\n  · congr <;> field_simp [h2]\n  · rw [cos_add, cos_sub]\n  ring\n#align complex.cos_add_cos Complex.cos_add_cos\n\ntheorem sin_conj : sin (conj x) = conj (sin x) := by\n  rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← RingHom.map_mul,\n    sinh_conj, mul_neg, sinh_neg, sinh_mul_I, mul_neg]\n#align complex.sin_conj Complex.sin_conj\n\n@[simp]\ntheorem ofReal_sin_ofReal_re (x : ℝ) : ((sin x).re : ℂ) = sin x :=\n  eq_conj_iff_re.1 <| by rw [← sin_conj, conj_ofReal]\n#align complex.of_real_sin_of_real_re Complex.ofReal_sin_ofReal_re\n\n@[simp, norm_cast]\ntheorem ofReal_sin (x : ℝ) : (Real.sin x : ℂ) = sin x :=\n  ofReal_sin_ofReal_re _\n#align complex.of_real_sin Complex.ofReal_sin\n\n@[simp]\ntheorem sin_ofReal_im (x : ℝ) : (sin x).im = 0 := by rw [← ofReal_sin_ofReal_re, ofReal_im]\n#align complex.sin_of_real_im Complex.sin_ofReal_im\n\ntheorem sin_ofReal_re (x : ℝ) : (sin x).re = Real.sin x :=\n  rfl\n#align complex.sin_of_real_re Complex.sin_ofReal_re\n\ntheorem cos_conj : cos (conj x) = conj (cos x) := by\n  rw [← cosh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← cosh_mul_I, cosh_conj, mul_neg, cosh_neg]\n#align complex.cos_conj Complex.cos_conj\n\n@[simp]\ntheorem ofReal_cos_ofReal_re (x : ℝ) : ((cos x).re : ℂ) = cos x :=\n  eq_conj_iff_re.1 <| by rw [← cos_conj, conj_ofReal]\n#align complex.of_real_cos_of_real_re Complex.ofReal_cos_ofReal_re\n\n@[simp, norm_cast]\ntheorem ofReal_cos (x : ℝ) : (Real.cos x : ℂ) = cos x :=\n  ofReal_cos_ofReal_re _\n#align complex.of_real_cos Complex.ofReal_cos\n\n@[simp]\ntheorem cos_ofReal_im (x : ℝ) : (cos x).im = 0 := by rw [← ofReal_cos_ofReal_re, ofReal_im]\n#align complex.cos_of_real_im Complex.cos_ofReal_im\n\ntheorem cos_ofReal_re (x : ℝ) : (cos x).re = Real.cos x :=\n  rfl\n#align complex.cos_of_real_re Complex.cos_ofReal_re\n\n@[simp]\ntheorem tan_zero : tan 0 = 0 := by simp [tan]\n#align complex.tan_zero Complex.tan_zero\n\ntheorem tan_eq_sin_div_cos : tan x = sin x / cos x :=\n  rfl\n#align complex.tan_eq_sin_div_cos Complex.tan_eq_sin_div_cos\n\ntheorem tan_mul_cos {x : ℂ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by\n  rw [tan_eq_sin_div_cos, div_mul_cancel _ hx]\n#align complex.tan_mul_cos Complex.tan_mul_cos\n\n@[simp]\ntheorem tan_neg : tan (-x) = -tan x := by simp [tan, neg_div]\n#align complex.tan_neg Complex.tan_neg\n\ntheorem tan_conj : tan (conj x) = conj (tan x) := by rw [tan, sin_conj, cos_conj, ← map_div₀, tan]\n#align complex.tan_conj Complex.tan_conj\n\n@[simp]\ntheorem ofReal_tan_ofReal_re (x : ℝ) : ((tan x).re : ℂ) = tan x :=\n  eq_conj_iff_re.1 <| by rw [← tan_conj, conj_ofReal]\n#align complex.of_real_tan_of_real_re Complex.ofReal_tan_ofReal_re\n\n@[simp, norm_cast]\ntheorem ofReal_tan (x : ℝ) : (Real.tan x : ℂ) = tan x :=\n  ofReal_tan_ofReal_re _\n#align complex.of_real_tan Complex.ofReal_tan\n\n@[simp]\ntheorem tan_of_real_im (x : ℝ) : (tan x).im = 0 := by rw [← ofReal_tan_ofReal_re, ofReal_im]\n#align complex.tan_of_real_im Complex.tan_of_real_im\n\ntheorem tan_of_real_re (x : ℝ) : (tan x).re = Real.tan x :=\n  rfl\n#align complex.tan_of_real_re Complex.tan_of_real_re\n\ntheorem cos_add_sin_I : cos x + sin x * I = exp (x * I) := by\n  rw [← cosh_add_sinh, sinh_mul_I, cosh_mul_I]\nset_option linter.uppercaseLean3 false in\n#align complex.cos_add_sin_I Complex.cos_add_sin_I\n\ntheorem cos_sub_sin_I : cos x - sin x * I = exp (-x * I) := by\n  rw [neg_mul, ← cosh_sub_sinh, sinh_mul_I, cosh_mul_I]\nset_option linter.uppercaseLean3 false in\n#align complex.cos_sub_sin_I Complex.cos_sub_sin_I\n\n@[simp]\ntheorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=\n  Eq.trans (by rw [cosh_mul_I, sinh_mul_I, mul_pow, I_sq, mul_neg_one, sub_neg_eq_add, add_comm])\n    (cosh_sq_sub_sinh_sq (x * I))\n#align complex.sin_sq_add_cos_sq Complex.sin_sq_add_cos_sq\n\n@[simp]\ntheorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq]\n#align complex.cos_sq_add_sin_sq Complex.cos_sq_add_sin_sq\n\ntheorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 := by rw [two_mul, cos_add, ← sq, ← sq]\n#align complex.cos_two_mul' Complex.cos_two_mul'\n\ntheorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 := by\n  rw [cos_two_mul', eq_sub_iff_add_eq.2 (sin_sq_add_cos_sq x), ← sub_add, sub_add_eq_add_sub,\n    two_mul]\n#align complex.cos_two_mul Complex.cos_two_mul\n\ntheorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x := by\n  rw [two_mul, sin_add, two_mul, add_mul, mul_comm]\n#align complex.sin_two_mul Complex.sin_two_mul\n\ntheorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 := by\n  simp [cos_two_mul, div_add_div_same, mul_div_cancel_left, two_ne_zero, -one_div]\n#align complex.cos_sq Complex.cos_sq\n\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel']\n#align complex.cos_sq' Complex.cos_sq'\n\ntheorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel]\n#align complex.sin_sq Complex.sin_sq\n\ntheorem inv_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 := by\n  have : cos x ^ 2 ≠ 0 := pow_ne_zero 2 hx\n  rw [tan_eq_sin_div_cos, div_pow]\n  field_simp [this]\n#align complex.inv_one_add_tan_sq Complex.inv_one_add_tan_sq\n\ntheorem tan_sq_div_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [← tan_mul_cos hx, mul_pow, ← inv_one_add_tan_sq hx, div_eq_mul_inv, one_mul]\n#align complex.tan_sq_div_one_add_tan_sq Complex.tan_sq_div_one_add_tan_sq\n\ntheorem cos_three_mul : cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x := by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, cos_add x (2 * x)]\n  simp only [cos_two_mul, sin_two_mul, mul_add, mul_sub, mul_one, sq]\n  have h2 : 4 * cos x ^ 3 = 2 * cos x * cos x * cos x + 2 * cos x * cos x ^ 2 := by ring\n  rw [h2, cos_sq']\n  ring\n#align complex.cos_three_mul Complex.cos_three_mul\n\ntheorem sin_three_mul : sin (3 * x) = 3 * sin x - 4 * sin x ^ 3 := by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, sin_add x (2 * x)]\n  simp only [cos_two_mul, sin_two_mul, cos_sq']\n  have h2 : cos x * (2 * sin x * cos x) = 2 * sin x * cos x ^ 2 := by ring\n  rw [h2, cos_sq']\n  ring\n#align complex.sin_three_mul Complex.sin_three_mul\n\ntheorem exp_mul_I : exp (x * I) = cos x + sin x * I :=\n  (cos_add_sin_I _).symm\nset_option linter.uppercaseLean3 false in\n#align complex.exp_mul_I Complex.exp_mul_I\n\ntheorem exp_add_mul_I : exp (x + y * I) = exp x * (cos y + sin y * I) := by rw [exp_add, exp_mul_I]\nset_option linter.uppercaseLean3 false in\n#align complex.exp_add_mul_I Complex.exp_add_mul_I\n\ntheorem exp_eq_exp_re_mul_sin_add_cos : exp x = exp x.re * (cos x.im + sin x.im * I) := by\n  rw [← exp_add_mul_I, re_add_im]\n#align complex.exp_eq_exp_re_mul_sin_add_cos Complex.exp_eq_exp_re_mul_sin_add_cos\n\ntheorem exp_re : (exp x).re = Real.exp x.re * Real.cos x.im := by\n  rw [exp_eq_exp_re_mul_sin_add_cos]\n  simp [exp_ofReal_re, cos_ofReal_re]\n#align complex.exp_re Complex.exp_re\n\ntheorem exp_im : (exp x).im = Real.exp x.re * Real.sin x.im := by\n  rw [exp_eq_exp_re_mul_sin_add_cos]\n  simp [exp_ofReal_re, sin_ofReal_re]\n#align complex.exp_im Complex.exp_im\n\n@[simp]\ntheorem exp_ofReal_mul_I_re (x : ℝ) : (exp (x * I)).re = Real.cos x := by\n  simp [exp_mul_I, cos_ofReal_re]\nset_option linter.uppercaseLean3 false in\n#align complex.exp_of_real_mul_I_re Complex.exp_ofReal_mul_I_re\n\n@[simp]\ntheorem exp_ofReal_mul_I_im (x : ℝ) : (exp (x * I)).im = Real.sin x := by\n  simp [exp_mul_I, sin_ofReal_re]\nset_option linter.uppercaseLean3 false in\n#align complex.exp_of_real_mul_I_im Complex.exp_ofReal_mul_I_im\n\n/-- **De Moivre's formula** -/\ntheorem cos_add_sin_mul_I_pow (n : ℕ) (z : ℂ) :\n    (cos z + sin z * I) ^ n = cos (↑n * z) + sin (↑n * z) * I := by\n  rw [← exp_mul_I, ← exp_mul_I]\n  induction' n with n ih\n  · rw [pow_zero, Nat.cast_zero, zero_mul, zero_mul, exp_zero]\n  · rw [pow_succ', ih, Nat.cast_succ, add_mul, add_mul, one_mul, exp_add]\nset_option linter.uppercaseLean3 false in\n#align complex.cos_add_sin_mul_I_pow Complex.cos_add_sin_mul_I_pow\n\nend Complex\n\nnamespace Real\n\nopen Complex\n\nvariable (x y : ℝ)\n\n@[simp]\ntheorem exp_zero : exp 0 = 1 := by simp [Real.exp]\n#align real.exp_zero Real.exp_zero\n\nnonrec theorem exp_add : exp (x + y) = exp x * exp y := by simp [exp_add, exp]\n#align real.exp_add Real.exp_add\n\n--Porting note: New definition\n/-- the exponential function as a monoid hom from `Multiplicative ℝ` to `ℝ` -/\nnoncomputable def expMonoidHom : MonoidHom (Multiplicative ℝ) ℝ :=\n  { toFun := fun x => exp (Multiplicative.toAdd x),\n    map_one' := by simp,\n    map_mul' := by simp [exp_add] }\n\ntheorem exp_list_sum (l : List ℝ) : exp l.sum = (l.map exp).prod :=\n  @MonoidHom.map_list_prod (Multiplicative ℝ) ℝ _ _ expMonoidHom l\n#align real.exp_list_sum Real.exp_list_sum\n\ntheorem exp_multiset_sum (s : Multiset ℝ) : exp s.sum = (s.map exp).prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative ℝ) ℝ _ _ expMonoidHom s\n#align real.exp_multiset_sum Real.exp_multiset_sum\n\ntheorem exp_sum {α : Type _} (s : Finset α) (f : α → ℝ) :\n    exp (∑ x in s, f x) = ∏ x in s, exp (f x) :=\n  @map_prod (Multiplicative ℝ) α ℝ _ _ _ _ expMonoidHom f s\n#align real.exp_sum Real.exp_sum\n\nnonrec theorem exp_nat_mul (x : ℝ) (n : ℕ) : exp (n * x) = exp x ^ n :=\n  ofReal_injective (by simp [exp_nat_mul])\n#align real.exp_nat_mul Real.exp_nat_mul\n\nnonrec theorem exp_ne_zero : exp x ≠ 0 := fun h =>\n  exp_ne_zero x <| by rw [exp, ← ofReal_inj] at h; simp_all\n#align real.exp_ne_zero Real.exp_ne_zero\n\nnonrec theorem exp_neg : exp (-x) = (exp x)⁻¹ :=\n  ofReal_injective <| by simp [exp_neg]\n#align real.exp_neg Real.exp_neg\n\ntheorem exp_sub : exp (x - y) = exp x / exp y := by\n  simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv]\n#align real.exp_sub Real.exp_sub\n\n@[simp]\ntheorem sin_zero : sin 0 = 0 := by simp [sin]\n#align real.sin_zero Real.sin_zero\n\n@[simp]\ntheorem sin_neg : sin (-x) = -sin x := by simp [sin, exp_neg, (neg_div _ _).symm, add_mul]\n#align real.sin_neg Real.sin_neg\n\nnonrec theorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y :=\n  ofReal_injective <| by simp [sin_add]\n#align real.sin_add Real.sin_add\n\n@[simp]\ntheorem cos_zero : cos 0 = 1 := by simp [cos]\n#align real.cos_zero Real.cos_zero\n\n@[simp]\ntheorem cos_neg : cos (-x) = cos x := by simp [cos, exp_neg]\n#align real.cos_neg Real.cos_neg\n\n@[simp]\ntheorem cos_abs : cos (|x|) = cos x := by\n  cases le_total x 0 <;> simp only [*, _root_.abs_of_nonneg, abs_of_nonpos, cos_neg]\n#align real.cos_abs Real.cos_abs\n\nnonrec theorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y :=\n  ofReal_injective <| by simp [cos_add]\n#align real.cos_add Real.cos_add\n\ntheorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by\n  simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg]\n#align real.sin_sub Real.sin_sub\n\ntheorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by\n  simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg]\n#align real.cos_sub Real.cos_sub\n\nnonrec theorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) :=\n  ofReal_injective <| by simp [sin_sub_sin]\n#align real.sin_sub_sin Real.sin_sub_sin\n\nnonrec theorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) :=\n  ofReal_injective <| by simp [cos_sub_cos]\n#align real.cos_sub_cos Real.cos_sub_cos\n\nnonrec theorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) :=\n  ofReal_injective <| by simp [cos_add_cos]\n#align real.cos_add_cos Real.cos_add_cos\n\nnonrec theorem tan_eq_sin_div_cos : tan x = sin x / cos x :=\n  ofReal_injective <| by simp [tan_eq_sin_div_cos]\n#align real.tan_eq_sin_div_cos Real.tan_eq_sin_div_cos\n\ntheorem tan_mul_cos {x : ℝ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by\n  rw [tan_eq_sin_div_cos, div_mul_cancel _ hx]\n#align real.tan_mul_cos Real.tan_mul_cos\n\n@[simp]\ntheorem tan_zero : tan 0 = 0 := by simp [tan]\n#align real.tan_zero Real.tan_zero\n\n@[simp]\ntheorem tan_neg : tan (-x) = -tan x := by simp [tan, neg_div]\n#align real.tan_neg Real.tan_neg\n\n@[simp]\nnonrec theorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=\n  ofReal_injective (by simp [sin_sq_add_cos_sq])\n#align real.sin_sq_add_cos_sq Real.sin_sq_add_cos_sq\n\n@[simp]\ntheorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq]\n#align real.cos_sq_add_sin_sq Real.cos_sq_add_sin_sq\n\ntheorem sin_sq_le_one : sin x ^ 2 ≤ 1 := by\n  rw [← sin_sq_add_cos_sq x]; exact le_add_of_nonneg_right (sq_nonneg _)\n#align real.sin_sq_le_one Real.sin_sq_le_one\n\ntheorem cos_sq_le_one : cos x ^ 2 ≤ 1 := by\n  rw [← sin_sq_add_cos_sq x]; exact le_add_of_nonneg_left (sq_nonneg _)\n#align real.cos_sq_le_one Real.cos_sq_le_one\n\ntheorem abs_sin_le_one : |sin x| ≤ 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, sin_sq_le_one]\n#align real.abs_sin_le_one Real.abs_sin_le_one\n\ntheorem abs_cos_le_one : |cos x| ≤ 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, cos_sq_le_one]\n#align real.abs_cos_le_one Real.abs_cos_le_one\n\ntheorem sin_le_one : sin x ≤ 1 :=\n  (abs_le.1 (abs_sin_le_one _)).2\n#align real.sin_le_one Real.sin_le_one\n\ntheorem cos_le_one : cos x ≤ 1 :=\n  (abs_le.1 (abs_cos_le_one _)).2\n#align real.cos_le_one Real.cos_le_one\n\ntheorem neg_one_le_sin : -1 ≤ sin x :=\n  (abs_le.1 (abs_sin_le_one _)).1\n#align real.neg_one_le_sin Real.neg_one_le_sin\n\ntheorem neg_one_le_cos : -1 ≤ cos x :=\n  (abs_le.1 (abs_cos_le_one _)).1\n#align real.neg_one_le_cos Real.neg_one_le_cos\n\nnonrec theorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 :=\n  ofReal_injective <| by simp [cos_two_mul]\n#align real.cos_two_mul Real.cos_two_mul\n\nnonrec theorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 :=\n  ofReal_injective <| by simp [cos_two_mul']\n#align real.cos_two_mul' Real.cos_two_mul'\n\nnonrec theorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x :=\n  ofReal_injective <| by simp [sin_two_mul]\n#align real.sin_two_mul Real.sin_two_mul\n\nnonrec theorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 :=\n  ofReal_injective <| by simp [cos_sq]\n#align real.cos_sq Real.cos_sq\n\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel']\n#align real.cos_sq' Real.cos_sq'\n\ntheorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 :=\n  eq_sub_iff_add_eq.2 <| sin_sq_add_cos_sq _\n#align real.sin_sq Real.sin_sq\n\ntheorem abs_sin_eq_sqrt_one_sub_cos_sq (x : ℝ) : |sin x| = sqrt (1 - cos x ^ 2) := by\n  rw [← sin_sq, sqrt_sq_eq_abs]\n#align real.abs_sin_eq_sqrt_one_sub_cos_sq Real.abs_sin_eq_sqrt_one_sub_cos_sq\n\ntheorem abs_cos_eq_sqrt_one_sub_sin_sq (x : ℝ) : |cos x| = sqrt (1 - sin x ^ 2) := by\n  rw [← cos_sq', sqrt_sq_eq_abs]\n#align real.abs_cos_eq_sqrt_one_sub_sin_sq Real.abs_cos_eq_sqrt_one_sub_sin_sq\n\ntheorem inv_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 :=\n  have : Complex.cos x ≠ 0 := mt (congr_arg re) hx\n  ofReal_inj.1 <| by simpa using Complex.inv_one_add_tan_sq this\n#align real.inv_one_add_tan_sq Real.inv_one_add_tan_sq\n\ntheorem tan_sq_div_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [← tan_mul_cos hx, mul_pow, ← inv_one_add_tan_sq hx, div_eq_mul_inv, one_mul]\n#align real.tan_sq_div_one_add_tan_sq Real.tan_sq_div_one_add_tan_sq\n\ntheorem inv_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) : (sqrt (1 + tan x ^ 2))⁻¹ = cos x := by\n  rw [← sqrt_sq hx.le, ← sqrt_inv, inv_one_add_tan_sq hx.ne']\n#align real.inv_sqrt_one_add_tan_sq Real.inv_sqrt_one_add_tan_sq\n\ntheorem tan_div_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) :\n    tan x / sqrt (1 + tan x ^ 2) = sin x := by\n  rw [← tan_mul_cos hx.ne', ← inv_sqrt_one_add_tan_sq hx, div_eq_mul_inv]\n#align real.tan_div_sqrt_one_add_tan_sq Real.tan_div_sqrt_one_add_tan_sq\n\nnonrec theorem cos_three_mul : cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x := by\n  rw [← ofReal_inj]; simp [cos_three_mul]\n#align real.cos_three_mul Real.cos_three_mul\n\nnonrec theorem sin_three_mul : sin (3 * x) = 3 * sin x - 4 * sin x ^ 3 := by\n  rw [← ofReal_inj]; simp [sin_three_mul]\n#align real.sin_three_mul Real.sin_three_mul\n\n/-- The definition of `sinh` in terms of `exp`. -/\nnonrec theorem sinh_eq (x : ℝ) : sinh x = (exp x - exp (-x)) / 2 :=\n  ofReal_injective <| by simp [Complex.sinh]\n#align real.sinh_eq Real.sinh_eq\n\n@[simp]\ntheorem sinh_zero : sinh 0 = 0 := by simp [sinh]\n#align real.sinh_zero Real.sinh_zero\n\n@[simp]\ntheorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul]\n#align real.sinh_neg Real.sinh_neg\n\nnonrec theorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by\n  rw [← ofReal_inj]; simp [sinh_add]\n#align real.sinh_add Real.sinh_add\n\n/-- The definition of `cosh` in terms of `exp`. -/\ntheorem cosh_eq (x : ℝ) : cosh x = (exp x + exp (-x)) / 2 :=\n  eq_div_of_mul_eq two_ne_zero <| by\n    rw [cosh, exp, exp, Complex.ofReal_neg, Complex.cosh, mul_two, ← Complex.add_re, ← mul_two,\n      div_mul_cancel _ (two_ne_zero' ℂ), Complex.add_re]\n#align real.cosh_eq Real.cosh_eq\n\n@[simp]\ntheorem cosh_zero : cosh 0 = 1 := by simp [cosh]\n#align real.cosh_zero Real.cosh_zero\n\n@[simp]\ntheorem cosh_neg : cosh (-x) = cosh x :=\n  ofReal_inj.1 <| by simp\n#align real.cosh_neg Real.cosh_neg\n\n@[simp]\ntheorem cosh_abs : cosh (|x|) = cosh x := by\n  cases le_total x 0 <;> simp [*, _root_.abs_of_nonneg, abs_of_nonpos]\n#align real.cosh_abs Real.cosh_abs\n\nnonrec theorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by\n  rw [← ofReal_inj]; simp [cosh_add]\n#align real.cosh_add Real.cosh_add\n\ntheorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by\n  simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg]\n#align real.sinh_sub Real.sinh_sub\n\ntheorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by\n  simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg]\n#align real.cosh_sub Real.cosh_sub\n\nnonrec theorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x :=\n  ofReal_inj.1 <| by simp [tanh_eq_sinh_div_cosh]\n#align real.tanh_eq_sinh_div_cosh Real.tanh_eq_sinh_div_cosh\n\n@[simp]\ntheorem tanh_zero : tanh 0 = 0 := by simp [tanh]\n#align real.tanh_zero Real.tanh_zero\n\n@[simp]\ntheorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div]\n#align real.tanh_neg Real.tanh_neg\n\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← ofReal_inj]; simp\n#align real.cosh_add_sinh Real.cosh_add_sinh\n\n@[simp]\ntheorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh]\n#align real.sinh_add_cosh Real.sinh_add_cosh\n\n@[simp]\ntheorem exp_sub_cosh : exp x - cosh x = sinh x :=\n  sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm\n#align real.exp_sub_cosh Real.exp_sub_cosh\n\n@[simp]\ntheorem exp_sub_sinh : exp x - sinh x = cosh x :=\n  sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm\n#align real.exp_sub_sinh Real.exp_sub_sinh\n\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by\n  rw [← ofReal_inj]\n  simp\n#align real.cosh_sub_sinh Real.cosh_sub_sinh\n\n@[simp]\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh]\n#align real.sinh_sub_cosh Real.sinh_sub_cosh\n\n@[simp]\ntheorem cosh_sq_sub_sinh_sq (x : ℝ) : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [← ofReal_inj]; simp\n#align real.cosh_sq_sub_sinh_sq Real.cosh_sq_sub_sinh_sq\n\nnonrec theorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← ofReal_inj]; simp [cosh_sq]\n#align real.cosh_sq Real.cosh_sq\n\ntheorem cosh_sq' : cosh x ^ 2 = 1 + sinh x ^ 2 :=\n  (cosh_sq x).trans (add_comm _ _)\n#align real.cosh_sq' Real.cosh_sq'\n\nnonrec theorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [← ofReal_inj]; simp [sinh_sq]\n#align real.sinh_sq Real.sinh_sq\n\nnonrec theorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by\n  rw [← ofReal_inj]; simp [cosh_two_mul]\n#align real.cosh_two_mul Real.cosh_two_mul\n\nnonrec theorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by\n  rw [← ofReal_inj]; simp [sinh_two_mul]\n#align real.sinh_two_mul Real.sinh_two_mul\n\nnonrec theorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by\n  rw [← ofReal_inj]; simp [cosh_three_mul]\n#align real.cosh_three_mul Real.cosh_three_mul\n\nnonrec theorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by\n  rw [← ofReal_inj]; simp [sinh_three_mul]\n#align real.sinh_three_mul Real.sinh_three_mul\n\nopen IsAbsoluteValue\n\n/-- This is an intermediate result that is later replaced by `Real.add_one_le_exp`; use that lemma\ninstead. -/\ntheorem add_one_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : x + 1 ≤ exp x :=\n  calc\n    x + 1 ≤ CauSeq.lim (⟨fun n : ℕ => ((exp' x) n).re, isCauSeq_re (exp' x)⟩ : CauSeq ℝ Abs.abs) :=\n      le_lim\n        (CauSeq.le_of_exists\n          ⟨2, fun j hj =>\n            show x + (1 : ℝ) ≤ (∑ m in range j, ((x : ℂ) ^ m / m.factorial)).re by\n              have h₁ : (((fun m : ℕ => ((x : ℂ) ^ m / m.factorial)) ∘ Nat.succ) 0).re = x :=\n                by simp [show Nat.succ 0 = 1 from rfl, Complex.ofReal_re]\n              have h₂ : ((x : ℂ) ^ 0 / (Nat.factorial 0)).re = 1 := by simp\n              erw [← tsub_add_cancel_of_le hj, sum_range_succ', sum_range_succ', add_re, add_re, h₁,\n                h₂, add_assoc, ← coe_reAddGroupHom, reAddGroupHom.map_sum,\n                coe_reAddGroupHom]\n              refine' le_add_of_nonneg_of_le (sum_nonneg fun m _ => _) le_rfl\n              rw [← ofReal_pow, ← ofReal_nat_cast, ← ofReal_div, ofReal_re]\n              exact div_nonneg (pow_nonneg hx _) (Nat.cast_nonneg _)⟩)\n    _ = exp x := by rw [exp, Complex.exp, ← cauSeqRe, lim_re]\n\n#align real.add_one_le_exp_of_nonneg Real.add_one_le_exp_of_nonneg\n\ntheorem one_le_exp {x : ℝ} (hx : 0 ≤ x) : 1 ≤ exp x := by linarith [add_one_le_exp_of_nonneg hx]\n#align real.one_le_exp Real.one_le_exp\n\ntheorem exp_pos (x : ℝ) : 0 < exp x :=\n  (le_total 0 x).elim (lt_of_lt_of_le zero_lt_one ∘ one_le_exp) fun h => by\n    rw [← neg_neg x, Real.exp_neg]\n    exact inv_pos.2 (lt_of_lt_of_le zero_lt_one (one_le_exp (neg_nonneg.2 h)))\n#align real.exp_pos Real.exp_pos\n\n@[simp]\ntheorem abs_exp (x : ℝ) : |exp x| = exp x :=\n  abs_of_pos (exp_pos _)\n#align real.abs_exp Real.abs_exp\n\n@[mono]\ntheorem exp_strictMono : StrictMono exp := fun x y h => by\n  rw [← sub_add_cancel y x, Real.exp_add]\n  exact (lt_mul_iff_one_lt_left (exp_pos _)).2\n      (lt_of_lt_of_le (by linarith) (add_one_le_exp_of_nonneg (by linarith)))\n#align real.exp_strict_mono Real.exp_strictMono\n\n@[mono]\ntheorem exp_monotone : Monotone exp :=\n  exp_strictMono.monotone\n#align real.exp_monotone Real.exp_monotone\n\n@[simp]\ntheorem exp_lt_exp {x y : ℝ} : exp x < exp y ↔ x < y :=\n  exp_strictMono.lt_iff_lt\n#align real.exp_lt_exp Real.exp_lt_exp\n\n@[simp]\ntheorem exp_le_exp {x y : ℝ} : exp x ≤ exp y ↔ x ≤ y :=\n  exp_strictMono.le_iff_le\n#align real.exp_le_exp Real.exp_le_exp\n\ntheorem exp_injective : Function.Injective exp :=\n  exp_strictMono.injective\n#align real.exp_injective Real.exp_injective\n\n@[simp]\ntheorem exp_eq_exp {x y : ℝ} : exp x = exp y ↔ x = y :=\n  exp_injective.eq_iff\n#align real.exp_eq_exp Real.exp_eq_exp\n\n@[simp]\ntheorem exp_eq_one_iff : exp x = 1 ↔ x = 0 :=\n  exp_injective.eq_iff' exp_zero\n#align real.exp_eq_one_iff Real.exp_eq_one_iff\n\n@[simp]\ntheorem one_lt_exp_iff {x : ℝ} : 1 < exp x ↔ 0 < x := by rw [← exp_zero, exp_lt_exp]\n#align real.one_lt_exp_iff Real.one_lt_exp_iff\n\n@[simp]\ntheorem exp_lt_one_iff {x : ℝ} : exp x < 1 ↔ x < 0 := by rw [← exp_zero, exp_lt_exp]\n#align real.exp_lt_one_iff Real.exp_lt_one_iff\n\n@[simp]\ntheorem exp_le_one_iff {x : ℝ} : exp x ≤ 1 ↔ x ≤ 0 :=\n  exp_zero ▸ exp_le_exp\n#align real.exp_le_one_iff Real.exp_le_one_iff\n\n@[simp]\ntheorem one_le_exp_iff {x : ℝ} : 1 ≤ exp x ↔ 0 ≤ x :=\n  exp_zero ▸ exp_le_exp\n#align real.one_le_exp_iff Real.one_le_exp_iff\n\n/-- `real.cosh` is always positive -/\ntheorem cosh_pos (x : ℝ) : 0 < Real.cosh x :=\n  (cosh_eq x).symm ▸ half_pos (add_pos (exp_pos x) (exp_pos (-x)))\n#align real.cosh_pos Real.cosh_pos\n\ntheorem sinh_lt_cosh : sinh x < cosh x :=\n  lt_of_pow_lt_pow 2 (cosh_pos _).le <| (cosh_sq x).symm ▸ lt_add_one _\n#align real.sinh_lt_cosh Real.sinh_lt_cosh\n\nend Real\n\nnamespace Complex\n\ntheorem sum_div_factorial_le {α : Type _} [LinearOrderedField α] (n j : ℕ) (hn : 0 < n) :\n    (∑ m in filter (fun k => n ≤ k) (range j),\n      (1 / m.factorial : α)) ≤ n.succ / (n.factorial * n) :=\n  calc\n    (∑ m in filter (fun k => n ≤ k) (range j), (1 / m.factorial : α)) =\n        ∑ m in range (j - n), (1 / ((m + n).factorial : α)) :=\n      sum_bij (fun m _ => m - n)\n        (fun m hm =>\n          mem_range.2 <|\n            (tsub_lt_tsub_iff_right (by simp at hm; tauto)).2 (by simp at hm; tauto))\n        (fun m hm => by rw [tsub_add_cancel_of_le]; simp at *; tauto)\n        (fun a₁ a₂ ha₁ ha₂ h => by\n          rwa [tsub_eq_iff_eq_add_of_le, tsub_add_eq_add_tsub, eq_comm, tsub_eq_iff_eq_add_of_le,\n              add_left_inj, eq_comm] at h <;>\n          simp at * <;> aesop)\n        fun b hb =>\n        ⟨b + n,\n          mem_filter.2 ⟨mem_range.2 <| lt_tsub_iff_right.mp (mem_range.1 hb), Nat.le_add_left _ _⟩,\n          by dsimp; rw [add_tsub_cancel_right]⟩\n    _ ≤ ∑ m in range (j - n), ((n.factorial : α) * (n.succ : α) ^ m)⁻¹ := by\n      refine' sum_le_sum fun m _ => _\n      rw [one_div, inv_le_inv]\n      · rw [← Nat.cast_pow, ← Nat.cast_mul, Nat.cast_le, add_comm]\n        exact Nat.factorial_mul_pow_le_factorial\n      · exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      · exact mul_pos (Nat.cast_pos.2 (Nat.factorial_pos _))\n            (pow_pos (Nat.cast_pos.2 (Nat.succ_pos _)) _)\n    _ = (n.factorial : α)⁻¹ * ∑ m in range (j - n), (n.succ : α)⁻¹ ^ m := by\n      simp [mul_inv, mul_sum.symm, sum_mul.symm, -Nat.factorial_succ, mul_comm, inv_pow]\n    _ = ((n.succ : α) - n.succ * (n.succ : α)⁻¹ ^ (j - n)) / (n.factorial * n) :=\n      by\n      have h₁ : (n.succ : α) ≠ 1 :=\n        @Nat.cast_one α _ ▸ mt Nat.cast_inj.1 (mt Nat.succ.inj (pos_iff_ne_zero.1 hn))\n      have h₂ : (n.succ : α) ≠ 0 := Nat.cast_ne_zero.2 (Nat.succ_ne_zero _)\n      have h₃ : (n.factorial * n : α) ≠ 0 :=\n        mul_ne_zero (Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.factorial_pos _)))\n          (Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 hn))\n      have h₄ : (n.succ - 1 : α) = n := by simp\n      rw [geom_sum_inv h₁ h₂, eq_div_iff_mul_eq h₃, mul_comm _ (n.factorial * n : α),\n          ← mul_assoc (n.factorial⁻¹ : α), ← mul_inv_rev, h₄, ← mul_assoc (n.factorial * n : α),\n          mul_comm (n : α) n.factorial, mul_inv_cancel h₃, one_mul, mul_comm]\n    _ ≤ n.succ / (n.factorial * n : α) :=\n      by\n      refine' Iff.mpr (div_le_div_right (mul_pos _ _)) _\n      exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      exact Nat.cast_pos.2 hn\n      exact\n        sub_le_self _\n          (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg (inv_nonneg.2 (Nat.cast_nonneg _)) _))\n#align complex.sum_div_factorial_le Complex.sum_div_factorial_le\n\ntheorem exp_bound {x : ℂ} (hx : abs x ≤ 1) {n : ℕ} (hn : 0 < n) :\n    abs (exp x - ∑ m in range n, x ^ m / m.factorial) ≤\n      abs x ^ n * ((n.succ : ℝ) * (n.factorial * n : ℝ)⁻¹) := by\n  rw [← lim_const (abv := Complex.abs) (∑ m in range n, _), exp, sub_eq_add_neg,\n    ← lim_neg, lim_add, ← lim_abs]\n  refine' lim_le (CauSeq.le_of_exists ⟨n, fun j hj => _⟩)\n  simp_rw [← sub_eq_add_neg]\n  show\n    abs ((∑ m in range j, x ^ m / m.factorial) - ∑ m in range n, x ^ m / m.factorial) ≤\n      abs x ^ n * ((n.succ : ℝ) * (n.factorial * n : ℝ)⁻¹)\n  rw [sum_range_sub_sum_range hj]\n  calc\n    abs (∑ m in (range j).filter fun k => n ≤ k, (x ^ m / m.factorial : ℂ)) =\n        abs (∑ m in (range j).filter fun k => n ≤ k, (x ^ n * (x ^ (m - n) / m.factorial) : ℂ)) :=\n      by\n      refine' congr_arg abs (sum_congr rfl fun m hm => _)\n      rw [mem_filter, mem_range] at hm\n      rw [← mul_div_assoc, ← pow_add, add_tsub_cancel_of_le hm.2]\n    _ ≤ ∑ m in filter (fun k => n ≤ k) (range j), abs (x ^ n * (x ^ (m - n) / m.factorial)) :=\n      (abv_sum_le_sum_abv (abv := Complex.abs) _ _)\n    _ ≤ ∑ m in filter (fun k => n ≤ k) (range j), abs x ^ n * (1 / m.factorial) :=\n      by\n      refine' sum_le_sum fun m _ => _\n      rw [map_mul, map_pow, map_div₀, abs_cast_nat]\n      refine' mul_le_mul_of_nonneg_left ((div_le_div_right _).2 _) _\n      · exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      · rw [abv_pow abs]\n        exact pow_le_one _ (abs.nonneg _) hx\n      · exact pow_nonneg (abs.nonneg _) _\n    _ = abs x ^ n * ∑ m in (range j).filter fun k => n ≤ k, (1 / m.factorial : ℝ) := by\n      simp [abs_mul, abv_pow abs, abs_div, mul_sum.symm]\n    _ ≤ abs x ^ n * (n.succ * (n.factorial * n : ℝ)⁻¹) :=\n      mul_le_mul_of_nonneg_left (sum_div_factorial_le _ _ hn) (pow_nonneg (abs.nonneg _) _)\n\n#align complex.exp_bound Complex.exp_bound\n\ntheorem exp_bound' {x : ℂ} {n : ℕ} (hx : abs x / n.succ ≤ 1 / 2) :\n    abs (exp x - ∑ m in range n, x ^ m / m.factorial) ≤ abs x ^ n / n.factorial * 2 := by\n  rw [← lim_const (abv := Complex.abs) (∑ m in range n, _),\n    exp, sub_eq_add_neg, ← lim_neg, lim_add, ← lim_abs]\n  refine' lim_le (CauSeq.le_of_exists ⟨n, fun j hj => _⟩)\n  simp_rw [← sub_eq_add_neg]\n  show abs ((∑ m in range j, x ^ m / m.factorial) - ∑ m in range n, x ^ m / m.factorial) ≤\n    abs x ^ n / n.factorial * 2\n  let k := j - n\n  have hj : j = n + k := (add_tsub_cancel_of_le hj).symm\n  rw [hj, sum_range_add_sub_sum_range]\n  calc\n    abs (∑ i : ℕ in range k, x ^ (n + i) / ((n + i).factorial : ℂ)) ≤\n        ∑ i : ℕ in range k, abs (x ^ (n + i) / ((n + i).factorial : ℂ)) :=\n      abv_sum_le_sum_abv _ _\n    _ ≤ ∑ i : ℕ in range k, abs x ^ (n + i) / (n + i).factorial := by\n      simp [Complex.abs_cast_nat, map_div₀, abv_pow abs]\n    _ ≤ ∑ i : ℕ in range k, abs x ^ (n + i) / ((n.factorial : ℝ) * (n.succ : ℝ) ^ i) := ?_\n    _ = ∑ i : ℕ in range k, abs x ^ n / n.factorial * (abs x ^ i / (n.succ : ℝ) ^ i) := ?_\n    _ ≤ abs x ^ n / ↑n.factorial * 2 := ?_\n  · refine' sum_le_sum fun m _ => div_le_div (pow_nonneg (abs.nonneg x) (n + m)) le_rfl _ _\n    · exact_mod_cast mul_pos n.factorial_pos (pow_pos n.succ_pos _)\n    · exact_mod_cast Nat.factorial_mul_pow_le_factorial\n  · refine' Finset.sum_congr rfl fun _ _ => _\n    simp only [pow_add, div_eq_inv_mul, mul_inv, mul_left_comm, mul_assoc]\n  · rw [← mul_sum]\n    apply mul_le_mul_of_nonneg_left\n    · simp_rw [← div_pow]\n      rw [geom_sum_eq, div_le_iff_of_neg]\n      · trans (-1 : ℝ)\n        · -- Porting note: was linarith\n          simp [Nat.succ_eq_add_one] at hx\n          rw [mul_comm, ← le_div_iff]\n          simp [hx]\n          . norm_num [this, hx]\n            simp [hx]\n          . exact zero_lt_two\n        · simp only [neg_le_sub_iff_le_add, div_pow, Nat.cast_succ, le_add_iff_nonneg_left]\n          exact\n            div_nonneg (pow_nonneg (abs.nonneg x) k)\n              (pow_nonneg (add_nonneg n.cast_nonneg zero_le_one) k)\n      · -- Porting note: was linarith\n        simp [Nat.succ_eq_add_one] at hx\n        simp\n        apply lt_of_le_of_lt hx\n        norm_num\n      · -- Porting note: was linarith\n        intro h\n        simp at h\n        simp [h] at hx\n        norm_num at hx\n    · exact div_nonneg (pow_nonneg (abs.nonneg x) n) (Nat.cast_nonneg n.factorial)\n#align complex.exp_bound' Complex.exp_bound'\n\ntheorem abs_exp_sub_one_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1) ≤ 2 * abs x :=\n  calc\n    abs (exp x - 1) = abs (exp x - ∑ m in range 1, x ^ m / m.factorial) := by simp [sum_range_succ]\n    _ ≤ abs x ^ 1 * ((Nat.succ 1 : ℝ) * ((Nat.factorial 1) * (1 : ℕ) : ℝ)⁻¹) :=\n      (exp_bound hx (by decide))\n    _ = 2 * abs x := by simp [two_mul, mul_two, mul_add, mul_comm, add_mul]\n\n#align complex.abs_exp_sub_one_le Complex.abs_exp_sub_one_le\n\ntheorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=\n  calc\n    abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m.factorial) := by\n      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc]\n    _ ≤ abs x ^ 2 * ((Nat.succ 2 : ℝ) * (Nat.factorial 2 * (2 : ℕ) : ℝ)⁻¹) :=\n      (exp_bound hx (by decide))\n    _ ≤ abs x ^ 2 * 1 := (mul_le_mul_of_nonneg_left (by norm_num) (sq_nonneg (abs x)))\n    _ = abs x ^ 2 := by rw [mul_one]\n\n#align complex.abs_exp_sub_one_sub_id_le Complex.abs_exp_sub_one_sub_id_le\n\nend Complex\n\nnamespace Real\n\nopen Complex Finset\n\nnonrec theorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) :\n    |exp x - ∑ m in range n, x ^ m / m.factorial| ≤ |x| ^ n * (n.succ / (n.factorial * n)) := by\n  have hxc : Complex.abs x ≤ 1 := by exact_mod_cast hx\n  convert exp_bound hxc hn using 2 <;>\n  --Porting note: was `norm_cast`\n  simp only [← abs_ofReal, ← ofReal_sub, ← ofReal_exp, ← ofReal_sum, ← ofReal_pow,\n    ← ofReal_div, ← ofReal_nat_cast]\n#align real.exp_bound Real.exp_bound\n\ntheorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :\n    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +\n      x ^ n * (n + 1) / (n.factorial * n) := by\n  have h3 : |x| = x := by simpa\n  have h4 : |x| ≤ 1 := by rwa [h3]\n  have h' := Real.exp_bound h4 hn\n  rw [h3] at h'\n  have h'' := (abs_sub_le_iff.1 h').1\n  have t := sub_le_iff_le_add'.1 h''\n  simpa [mul_div_assoc] using t\n#align real.exp_bound' Real.exp_bound'\n\ntheorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| := by\n  have : abs' x ≤ 1 := by exact_mod_cast hx\n  --Porting note: was\n  --exact_mod_cast Complex.abs_exp_sub_one_le (x := x) this\n  have := Complex.abs_exp_sub_one_le (x := x) (by simpa using this)\n  rw [← ofReal_exp, ← ofReal_one, ← ofReal_sub, abs_ofReal, abs_ofReal] at this\n  exact this\n#align real.abs_exp_sub_one_le Real.abs_exp_sub_one_le\n\ntheorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 := by\n  rw [← _root_.sq_abs]\n  --Porting note: was\n  --exact_mod_cast Complex.abs_exp_sub_one_sub_id_le this\n  have : Complex.abs x ≤ 1 := by exact_mod_cast hx\n  have := Complex.abs_exp_sub_one_sub_id_le this\n  rw [← ofReal_one, ← ofReal_exp, ← ofReal_sub, ← ofReal_sub, abs_ofReal, abs_ofReal] at this\n  exact this\n#align real.abs_exp_sub_one_sub_id_le Real.abs_exp_sub_one_sub_id_le\n\n/-- A finite initial segment of the exponential series, followed by an arbitrary tail.\nFor fixed `n` this is just a linear map wrt `r`, and each map is a simple linear function\nof the previous (see `expNear_succ`), with `expNear n x r ⟶ exp x` as `n ⟶ ∞`,\nfor any `r`. -/\nnoncomputable def expNear (n : ℕ) (x r : ℝ) : ℝ :=\n  (∑ m in range n, x ^ m / m.factorial) + x ^ n / n.factorial * r\n#align real.exp_near Real.expNear\n\n@[simp]\ntheorem expNear_zero (x r) : expNear 0 x r = r := by simp [expNear]\n#align real.exp_near_zero Real.expNear_zero\n\n@[simp]\ntheorem expNear_succ (n x r) : expNear (n + 1) x r = expNear n x (1 + x / (n + 1) * r) := by\n  simp [expNear, range_succ, mul_add, add_left_comm, add_assoc, pow_succ, div_eq_mul_inv,\n      mul_inv]\n  ac_rfl\n#align real.exp_near_succ Real.expNear_succ\n\ntheorem expNear_sub (n x r₁ r₂) : expNear n x r₁ -\n    expNear n x r₂ = x ^ n / n.factorial * (r₁ - r₂) := by\n  simp [expNear, mul_sub]\n#align real.exp_near_sub Real.expNear_sub\n\ntheorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) :\n    |exp x - expNear m x 0| ≤ |x| ^ m / m.factorial * ((m + 1) / m) := by\n  simp [expNear]\n  convert exp_bound (n := m) h ?_ using 1\n  field_simp [mul_comm]\n  linarith\n#align real.exp_approx_end Real.exp_approx_end\n\ntheorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)\n    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)\n    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :\n    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by\n  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)\n  subst e₁; rw [expNear_succ, expNear_sub, abs_mul]\n  convert mul_le_mul_of_nonneg_left (a := abs' x ^ n / ↑(Nat.factorial n))\n      (le_sub_iff_add_le'.1 e) ?_ using 1\n  · simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, ← pow_abs, mul_inv]\n    ac_rfl\n  · simp [div_nonneg, abs_nonneg]\n#align real.exp_approx_succ Real.exp_approx_succ\n\ntheorem exp_approx_end' {n} {x a b : ℝ} (m : ℕ) (e₁ : n + 1 = m) (rm : ℝ) (er : ↑m = rm)\n    (h : |x| ≤ 1) (e : |1 - a| ≤ b - |x| / rm * ((rm + 1) / rm)) :\n    |exp x - expNear n x a| ≤ |x| ^ n / n.factorial * b := by\n  subst er\n  exact exp_approx_succ _ e₁ _ _ (by simpa using e) (exp_approx_end _ _ _ e₁ h)\n#align real.exp_approx_end' Real.exp_approx_end'\n\ntheorem exp_1_approx_succ_eq {n} {a₁ b₁ : ℝ} {m : ℕ} (en : n + 1 = m) {rm : ℝ} (er : ↑m = rm)\n    (h : |exp 1 - expNear m 1 ((a₁ - 1) * rm)| ≤ |1| ^ m / m.factorial * (b₁ * rm)) :\n    |exp 1 - expNear n 1 a₁| ≤ |1| ^ n / n.factorial * b₁ := by\n  subst er\n  refine' exp_approx_succ _ en _ _ _ h\n  field_simp [show (m : ℝ) ≠ 0 by norm_cast; linarith]\n#align real.exp_1_approx_succ_eq Real.exp_1_approx_succ_eq\n\ntheorem exp_approx_start (x a b : ℝ) (h : |exp x - expNear 0 x a| ≤ |x| ^ 0 / Nat.factorial 0 * b) :\n    |exp x - a| ≤ b := by simpa using h\n#align real.exp_approx_start Real.exp_approx_start\n\ntheorem cos_bound {x : ℝ} (hx : |x| ≤ 1) : |cos x - (1 - x ^ 2 / 2)| ≤ |x| ^ 4 * (5 / 96) :=\n  calc\n    |cos x - (1 - x ^ 2 / 2)| = Complex.abs (Complex.cos x - (1 - (x : ℂ) ^ 2 / 2)) := by\n      rw [← abs_ofReal]; simp\n    _ = Complex.abs ((Complex.exp (x * I) + Complex.exp (-x * I) - (2 - (x : ℂ) ^ 2)) / 2) := by\n      simp [Complex.cos, sub_div, add_div, neg_div, div_self (two_ne_zero' ℂ)]\n    _ = abs\n          (((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial) +\n              (Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m.factorial)) / 2) :=\n      (congr_arg Complex.abs\n        (congr_arg (fun x : ℂ => x / 2)\n          (by\n            simp only [sum_range_succ]\n            simp [pow_succ]\n            apply Complex.ext <;> simp [div_eq_mul_inv, normSq] <;> ring_nf\n            )))\n    _ ≤ abs ((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial) / 2) +\n          abs ((Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m.factorial) / 2) :=\n      by rw [add_div]; exact Complex.abs.add_le _ _\n    _ = abs (Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial) / 2 +\n          abs (Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m.factorial) / 2 :=\n      by simp [map_div₀]\n    _ ≤ Complex.abs (x * I) ^ 4 * (Nat.succ 4 * ((Nat.factorial 4) * (4 : ℕ) : ℝ)⁻¹) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * ((Nat.factorial 4) * (4 : ℕ) : ℝ)⁻¹) / 2 :=\n      (add_le_add ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide)))\n        ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide))))\n    _ ≤ |x| ^ 4 * (5 / 96) := by norm_num\n#align real.cos_bound Real.cos_bound\n\ntheorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x| ^ 4 * (5 / 96) :=\n  calc\n    |sin x - (x - x ^ 3 / 6)| = Complex.abs (Complex.sin x - (x - x ^ 3 / 6 : ℝ)) := by\n      rw [← abs_ofReal]; simp\n    _ = Complex.abs (((Complex.exp (-x * I) - Complex.exp (x * I)) * I -\n          (2 * x - x ^ 3 / 3 : ℝ)) / 2) := by\n      simp [Complex.sin, sub_div, add_div, neg_div, mul_div_cancel_left _ (two_ne_zero' ℂ), div_div,\n        show (3 : ℂ) * 2 = 6 by norm_num]\n    _ = Complex.abs (((Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m.factorial) -\n                (Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial)) * I / 2) :=\n      (congr_arg Complex.abs\n        (congr_arg (fun x : ℂ => x / 2)\n          (by\n            simp only [sum_range_succ]\n            simp [pow_succ]\n            apply Complex.ext <;> simp [div_eq_mul_inv, normSq]; ring)))\n    _ ≤ abs ((Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m.factorial) * I / 2) +\n          abs (-((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial) * I) / 2) :=\n      by rw [sub_mul, sub_eq_add_neg, add_div]; exact Complex.abs.add_le _ _\n    _ = abs (Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial) / 2 +\n          abs (Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m.factorial) / 2 :=\n      by simp [add_comm, map_div₀]\n    _ ≤ Complex.abs (x * I) ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : ℕ) : ℝ)⁻¹) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : ℕ) : ℝ)⁻¹) / 2 :=\n      (add_le_add ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide)))\n        ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide))))\n    _ ≤ |x| ^ 4 * (5 / 96) := by norm_num\n#align real.sin_bound Real.sin_bound\n\ntheorem cos_pos_of_le_one {x : ℝ} (hx : |x| ≤ 1) : 0 < cos x :=\n  calc 0 < 1 - x ^ 2 / 2 - |x| ^ 4 * (5 / 96) :=\n      sub_pos.2 <|\n        lt_sub_iff_add_lt.2\n          (calc\n            |x| ^ 4 * (5 / 96) + x ^ 2 / 2 ≤ 1 * (5 / 96) + 1 / 2 :=\n              add_le_add (mul_le_mul_of_nonneg_right (pow_le_one _ (abs_nonneg _) hx) (by norm_num))\n                ((div_le_div_right (by norm_num)).2\n                  (by\n                    rw [sq, ← abs_mul_self, abs_mul]\n                    exact mul_le_one hx (abs_nonneg _) hx))\n            _ < 1 := by norm_num)\n    _ ≤ cos x := sub_le_comm.1 (abs_sub_le_iff.1 (cos_bound hx)).2\n#align real.cos_pos_of_le_one Real.cos_pos_of_le_one\n\ntheorem sin_pos_of_pos_of_le_one {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 1) : 0 < sin x :=\n  calc 0 < x - x ^ 3 / 6 - |x| ^ 4 * (5 / 96) :=\n      sub_pos.2 <| lt_sub_iff_add_lt.2\n          (calc\n            |x| ^ 4 * (5 / 96) + x ^ 3 / 6 ≤ x * (5 / 96) + x / 6 :=\n              add_le_add\n                (mul_le_mul_of_nonneg_right\n                  (calc\n                    |x| ^ 4 ≤ |x| ^ 1 :=\n                      pow_le_pow_of_le_one (abs_nonneg _)\n                        (by rwa [_root_.abs_of_nonneg (le_of_lt hx0)]) (by decide)\n                    _ = x := by simp [_root_.abs_of_nonneg (le_of_lt hx0)]\n                    )\n                  (by norm_num))\n                ((div_le_div_right (by norm_num)).2\n                  (calc\n                    x ^ 3 ≤ x ^ 1 := pow_le_pow_of_le_one (le_of_lt hx0) hx (by decide)\n                    _ = x := pow_one _\n                    ))\n            --Porting note : was `_ < x := by linarith`\n            _ = x * (7 / 32) := by ring\n            _ < x := (mul_lt_iff_lt_one_right hx0).2 (by norm_num))\n    _ ≤ sin x :=\n      sub_le_comm.1 (abs_sub_le_iff.1 (sin_bound (by rwa [_root_.abs_of_nonneg (le_of_lt hx0)]))).2\n#align real.sin_pos_of_pos_of_le_one Real.sin_pos_of_pos_of_le_one\n\ntheorem sin_pos_of_pos_of_le_two {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 2) : 0 < sin x :=\n  have : x / 2 ≤ 1 := (div_le_iff (by norm_num)).mpr (by simpa)\n  calc\n    0 < 2 * sin (x / 2) * cos (x / 2) :=\n      mul_pos (mul_pos (by norm_num) (sin_pos_of_pos_of_le_one (half_pos hx0) this))\n        (cos_pos_of_le_one (by rwa [_root_.abs_of_nonneg (le_of_lt (half_pos hx0))]))\n    _ = sin x := by rw [← sin_two_mul, two_mul, add_halves]\n\n#align real.sin_pos_of_pos_of_le_two Real.sin_pos_of_pos_of_le_two\n\ntheorem cos_one_le : cos 1 ≤ 2 / 3 :=\n  calc\n    cos 1 ≤ |(1 : ℝ)| ^ 4 * (5 / 96) + (1 - 1 ^ 2 / 2) :=\n      sub_le_iff_le_add.1 (abs_sub_le_iff.1 (cos_bound (by simp))).1\n    _ ≤ 2 / 3 := by norm_num\n\n#align real.cos_one_le Real.cos_one_le\n\ntheorem cos_one_pos : 0 < cos 1 :=\n  cos_pos_of_le_one (le_of_eq abs_one)\n#align real.cos_one_pos Real.cos_one_pos\n\ntheorem cos_two_neg : cos 2 < 0 :=\n  calc cos 2 = cos (2 * 1) := congr_arg cos (mul_one _).symm\n    _ = _ := (Real.cos_two_mul 1)\n    _ ≤ 2 * (2 / 3) ^ 2 - 1 :=\n      (sub_le_sub_right\n        (mul_le_mul_of_nonneg_left\n          (by\n            rw [sq, sq]\n            exact mul_self_le_mul_self (le_of_lt cos_one_pos) cos_one_le)\n          zero_le_two) _)\n    _ < 0 := by norm_num\n#align real.cos_two_neg Real.cos_two_neg\n\n--Porting note: removed `(h1 : 0 ≤ x)` because it is no longer used\ntheorem exp_bound_div_one_sub_of_interval_approx {x : ℝ} (h2 : x ≤ 1) :\n    (∑ j : ℕ in Finset.range 3, x ^ j / j.factorial) +\n        x ^ 3 * ((3 : ℕ) + 1) / ((3 : ℕ).factorial * (3 : ℕ)) ≤\n      ∑ j in Finset.range 3, x ^ j :=\n  calc\n    (∑ j : ℕ in Finset.range 3, x ^ j / j.factorial) +\n        x ^ 3 * ((3 : ℕ) + 1) / ((3 : ℕ).factorial * (3 : ℕ))\n      = (2 / 9) * x ^ 3 + x ^ 2 / 2 + x + 1 := by simp [Finset.sum]; ring\n    _ ≤ x ^ 2 + x + 1 := sub_nonneg.1 <|\n      calc 0 ≤ x^2 * (2 / 9) * (9 / 4 - x) :=\n          mul_nonneg (mul_nonneg (pow_two_nonneg _) (by norm_num : (0 : ℝ) ≤ 2 / 9))\n            (sub_nonneg.2 (le_trans h2 (by norm_num)))\n        _ = _ := by ring\n    _ = _ := by simp [Finset.sum]; ring\n#align real.exp_bound_div_one_sub_of_interval_approx Real.exp_bound_div_one_sub_of_interval_approxₓ\n\ntheorem exp_bound_div_one_sub_of_interval {x : ℝ} (h1 : 0 ≤ x) (h2 : x < 1) :\n    Real.exp x ≤ 1 / (1 - x) :=\n  haveI h : (∑ j in Finset.range 3, x ^ j) ≤ 1 / (1 - x) :=\n    by\n    norm_num [Finset.sum]\n    have h1x : 0 < 1 - x := by simpa\n    rw [inv_eq_one_div, le_div_iff h1x]\n    norm_num [← add_assoc, mul_sub_left_distrib, mul_one, add_mul, sub_add_eq_sub_sub,\n      pow_succ' x 2]\n    have hx3 : 0 ≤ x ^ 3 := by\n      norm_num\n      simp [h1]\n    simp [Finset.sum]\n    linarith\n  (exp_bound' h1 h2.le <| by linarith).trans\n    ((exp_bound_div_one_sub_of_interval_approx h2.le).trans h)\n#align real.exp_bound_div_one_sub_of_interval Real.exp_bound_div_one_sub_of_interval\n\ntheorem one_sub_le_exp_minus_of_pos {y : ℝ} (h : 0 ≤ y) : 1 - y ≤ Real.exp (-y) := by\n  rw [Real.exp_neg]\n  have r1 : (1 - y) * Real.exp y ≤ 1 :=\n    by\n    cases le_or_lt (1 - y) 0\n    · have h'' : (1 - y) * y.exp ≤ 0 := by\n        rw [mul_nonpos_iff]\n        right\n        exact ⟨by assumption, y.exp_pos.le⟩\n      linarith\n    have hy1 : y < 1 := by linarith\n    rw [← le_div_iff' ‹0 < 1 - y›]\n    exact exp_bound_div_one_sub_of_interval h hy1\n  rw [inv_eq_one_div]\n  rw [le_div_iff' y.exp_pos]\n  rwa [mul_comm] at r1\n#align real.one_sub_le_exp_minus_of_pos Real.one_sub_le_exp_minus_of_pos\n\ntheorem add_one_le_exp_of_nonpos {x : ℝ} (h : x ≤ 0) : x + 1 ≤ Real.exp x := by\n  rw [add_comm]\n  have h1 : 0 ≤ -x := by linarith\n  simpa using one_sub_le_exp_minus_of_pos h1\n#align real.add_one_le_exp_of_nonpos Real.add_one_le_exp_of_nonpos\n\ntheorem add_one_le_exp (x : ℝ) : x + 1 ≤ Real.exp x := by\n  cases' le_or_lt 0 x with h h\n  · exact Real.add_one_le_exp_of_nonneg h\n  exact add_one_le_exp_of_nonpos h.le\n#align real.add_one_le_exp Real.add_one_le_exp\n\ntheorem one_sub_div_pow_le_exp_neg {n : ℕ} {t : ℝ} (ht' : t ≤ n) : (1 - t / n) ^ n ≤ exp (-t) := by\n  rcases eq_or_ne n 0 with (rfl | hn)\n  · simp\n    rwa [Nat.cast_zero] at ht'\n  convert pow_le_pow_of_le_left ?_ (add_one_le_exp (-(t / n))) n using 2\n  · abel\n  · rw [← Real.exp_nat_mul]\n    congr 1\n    field_simp [(Nat.cast_ne_zero (R := ℝ)).mpr hn]\n    ring_nf\n  · rwa [add_comm, ← sub_eq_add_neg, sub_nonneg, div_le_one]\n    positivity\n#align real.one_sub_div_pow_le_exp_neg Real.one_sub_div_pow_le_exp_neg\n\nend Real\n\nnamespace Tactic\nopen Lean.Meta Qq\n\n/-- Extension for the `positivity` tactic: `real.exp` is always positive. -/\n@[positivity Real.exp _]\ndef evalExp : Mathlib.Meta.Positivity.PositivityExt where eval {_ _} _ _ e := do\n  let (.app _ (a : Q(ℝ))) ← withReducible (whnf e) | throwError \"not Real.exp\"\n  pure (.positive (q(Real.exp_pos $a) : Lean.Expr))\n\nend Tactic\n\nnamespace Complex\n\n@[simp]\ntheorem abs_cos_add_sin_mul_I (x : ℝ) : abs (cos x + sin x * I) = 1 := by\n  have := Real.sin_sq_add_cos_sq x\n  simp_all [add_comm, abs, normSq, sq, sin_ofReal_re, cos_ofReal_re, mul_re]\nset_option linter.uppercaseLean3 false in\n#align complex.abs_cos_add_sin_mul_I Complex.abs_cos_add_sin_mul_I\n\n@[simp]\ntheorem abs_exp_ofReal (x : ℝ) : abs (exp x) = Real.exp x := by\n  rw [← ofReal_exp]\n  exact abs_of_nonneg (le_of_lt (Real.exp_pos _))\n#align complex.abs_exp_of_real Complex.abs_exp_ofReal\n\n@[simp]\ntheorem abs_exp_ofReal_mul_I (x : ℝ) : abs (exp (x * I)) = 1 := by\n  rw [exp_mul_I, abs_cos_add_sin_mul_I]\nset_option linter.uppercaseLean3 false in\n#align complex.abs_exp_of_real_mul_I Complex.abs_exp_ofReal_mul_I\n\ntheorem abs_exp (z : ℂ) : abs (exp z) = Real.exp z.re := by\n  rw [exp_eq_exp_re_mul_sin_add_cos, map_mul, abs_exp_ofReal, abs_cos_add_sin_mul_I, mul_one]\n#align complex.abs_exp Complex.abs_exp\n\ntheorem abs_exp_eq_iff_re_eq {x y : ℂ} : abs (exp x) = abs (exp y) ↔ x.re = y.re := by\n  rw [abs_exp, abs_exp, Real.exp_eq_exp]\n#align complex.abs_exp_eq_iff_re_eq Complex.abs_exp_eq_iff_re_eq\n\nend Complex\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Complex/Exponential.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.4843329644813887}}
{"text": "import category_theory.category\nimport category_theory.types\n\nimport tactic.tidy\n\n\nnamespace help_functions\n\nuniverse u\n\n\nopen classical function set\n\nvariables {A B C : Type u}\n\nlemma eq_in_set {A : Type u} {S: set A} {a b: S}\n: a.val = b.val ↔ a = b := \n    by {cases a, cases b, dsimp at *, simp at *}\n\n@[simp , tidy] def inclusion (S : set A) \n    : S → A := λ s , s \nnotation S ` ↪ ` A := @inclusion A S\n\n@[simp , tidy] lemma  inclusion_id\n     (A : Type u) (S : set A) (s : S)\n    : (inclusion S) s = s := by simp \n\n@[simp , tidy] lemma inj_inclusion (A : Type u) (S : set A) \n        : injective (inclusion S) := by tidy\n\n@[simp , tidy] lemma comp_inclusion (A : Type u) (S T: set A) (h: S ⊆ T)\n    : (S ↪ A) = (T ↪ A) ∘ (set.inclusion h)\n        := by tidy\n \n\nnoncomputable def graph_to_map \n                 (G :  A → B → Prop)\n                 (h : ∀ a : A , ∃! b : B, G a b) : A → B :=\n                 λ a , some (h a)\n\n\n\ndef map_to_graph (f : A → B): set (A × B ):= λ r, r.2 = f r.1 \n\n\nlemma bij_map_to_graph_fst (f : A → B) :\n    let π₁ : (map_to_graph f) → A := λ r , r.val.1 in \n    bijective π₁ := \n    begin\n        let R : set (A × B) := map_to_graph f,\n        let π₁ : R → A := λ r , r.val.1, \n        have inj : injective π₁ := \n            begin\n                assume a₁ a₂ (πa₁_πa₂ : a₁.val.1 = a₂.val.1),\n                have a1_p : a₁.val.2 = f a₁.val.1 := a₁.property,\n                have a2_p : a₂.val.2 = f a₂.val.1 := a₂.property,\n                have a_a : f a₁.val.1 = f a₂.val.1 := by tidy,\n                have a2_p : a₁.val.2 = a₂.val.2 := by simp [a1_p, a2_p, a_a],\n                tidy\n            end,\n        have sur : surjective π₁ := \n            begin\n                intro a,\n                let r := (⟨a , f a⟩ : A × B),\n                have r_R : r ∈ R := \n                    have r2_fr1 : r.2 = f r.1 := by simp,\n                    r2_fr1,\n                use r,\n                tidy\n            end,\n        exact ⟨inj, sur⟩\n    end\n\nnoncomputable def invrs (f : A ⟶ B) (bij : bijective f) : B ⟶ A :=\n                some (iff.elim_left bijective_iff_has_inverse bij)\n\nlemma invrs_id (f : A ⟶ B) (bij : bijective f) \n    : \n    f ∘ (invrs f bij) = id := \n        begin\n            have h0 : left_inverse (some _) f ∧ right_inverse (some _) f := \n                some_spec (iff.elim_left bijective_iff_has_inverse bij),\n            have h1: right_inverse _ f := \n                        and.elim_right h0,\n            by tidy\n        end\n\nlemma id_invrs (f : A ⟶ B) (bij : bijective f) :\n    (invrs f bij) ∘ f = id := \n    begin\n        have h0 : left_inverse (some _) f ∧ right_inverse (some _) f := \n            some_spec (iff.elim_left bijective_iff_has_inverse bij),\n        have h1: left_inverse _ f := \n                    and.elim_left h0,\n        by tidy\n    end\n\n\n\n\ndef kern (f : A ⟶ B) : A → A → Prop := \n        λ a₁ a₂ , f a₁ = f a₂\n\ndef sub_kern (f : A ⟶ B) (g : A → C) : Prop :=\n    ∀ a₁ a₂, kern f a₁ a₂ → kern g a₁ a₂\n\n@[simp, tidy] def kern_comp (f : A ⟶ B) (g : B → C) :\n        sub_kern f (g ∘ f) := \n    assume a b k_f, \n    have f_ab : f a = f b := k_f,\n    show g (f a) = g (f b), from by rw [f_ab]\n\n\n\n\n\n\ndef emptyOrNot (S : set A) : (nonempty S) ∨ ¬ (nonempty S)  \n        := em (nonempty S)\n\n\nnoncomputable def nonemptyInhabited {S : set A} (h : nonempty S)\n        : inhabited S \n        := inhabited.mk (choice h)\n\n\n\nlemma map_from_empty (S : set A) (B : Type u) : \n            (¬ ∃ s : S , true) → \n            ∀ f₁ f₂  : S → B, f₁ = f₂ := \n            assume h f₁ f₂,\n            show f₁ = f₂, from \n            have h0 : ∀ s : S , false := by tidy,\n            by tidy\n\n\nlemma nonempty_notexists {S : set A}: \n        ¬ nonempty S → (¬ ∃ s : S , true) :=\n        assume nonemp ext,\n            show false,\n            from nonemp (nonempty_of_exists ext)\n\n\n\nlemma only_one {p q: A → Prop} \n                (ex_uni : ∃! a , p a)\n                (ex : ∃ a , p a ∧ q a)\n        : ∃! a , p a ∧ q a := \n        let a : A := some ex_uni in\n        have h : _ := some_spec ex_uni,\n        have h1 : ∀ a₁ , p a₁ → a₁ = a :=\n                and.right h,\n        let a₁ : A := some ex in\n        have h2 : p a₁ ∧ q a₁ := some_spec ex,\n        have h3 : a₁ = a := h1 a₁ (and.left h2), \n        have h4 : ∀ a₂ , p a₂ ∧ q a₂ → a₂ = a₁ := \n            λ a₂ pq, by rw [h3, (h1 a₂ (and.left pq))],\n        exists.intro a₁ ⟨ h2 , h4⟩  \n\n\nlemma eq_range_if_surjective  (f: A ⟶ B) (g: B ⟶ C)\n    (sur: surjective f) : range g = range (g ∘ f):= \n    calc range g = image g (univ)         : by simp\n          ...    = image g (range f)      : by rw [range_iff_surjective.2 sur]\n          ...    = range (g ∘ f)          : by tidy\n\n\nlemma sub_kern_if_injective {X Y Z U : Type u}\n    (e : X ⟶ Y) (f : Y ⟶ U)\n    (g : X ⟶ Z) (m : Z ⟶ U)\n    (h : e ≫ f = g ≫ m) (inj: injective m) : sub_kern e g := \n        begin\n            assume x₁ x₂ xxe,\n            have h01 : e x₁ = e x₂ := xxe,\n            have h02 : m (g x₁) = m (g x₂) := \n            calc m (g x₁) = (g ≫ m) x₁    : rfl\n                   ...    = (e ≫ f) x₁    : by rw h\n                   ...    = f (e x₁)       : rfl\n                   ...    = f (e x₂)       : by rw h01\n                   ...    = (e ≫ f) x₂    : rfl\n                   ...    = (g ≫ m) x₂    : by rw h,\n            exact inj h02\n        end\n\n\nlemma eq_sets {A : Type u} {S T : set A}\n    : (∀a : A ,a ∈ S ↔ a ∈ T) ↔  S = T  := \n    begin \n        split,\n        assume h,\n        have h1 : ∀s : S , s.val ∈ T :=\n           λ s, (h s.val).1 s.property,\n        have h2 : ∀t : T , t.val ∈ S :=\n           λ t, (h t.val).2 t.property, \n        simp at *,  \n        ext1 x, \n        split, \n        intros s, \n        exact h1 x s, \n        intros t, \n        exact h2 x t,\n        intro h,\n        intro a, \n        induction h, \n        refl\n    end\n\n@[tidy] def fun_of_two_eq_sets {A B: Type u} {S T : set A}\n    (h: ∀a : A ,a ∈ S ↔ a ∈ T)\n    (f: S → B):\n    T → B := \n        λ t , \n        f ⟨t.val , (h t.val).2 t.property⟩\n\n\n@[tidy] lemma eq_fun_of_eq_sets {A B: Type u} (S T : set A) \n    (h: ∀a : A ,a ∈ S ↔ a ∈ T)\n    (f: S → B):\n    let fT : T → B := (fun_of_two_eq_sets h f) in\n    ∀ s , f s = fT ⟨ s.val , (h s.val).1 s.property⟩ \n    := by tidy\n\n\n\n@[tidy] lemma def_of_range {A B: Type u} (T: set A)\n        (f: T → B) (b : B) :\n    (∃ (a : A) (h : a ∈ T), f ⟨a, h⟩ = b) ↔\n    b ∈ range f := by tidy  \n\n\n@[tidy] lemma eq_ranges {A B: Type u} {S T : set A} \n    (h: ∀a : A ,a ∈ S ↔ a ∈ T)\n    (f: S → B):\n    let fT : T → B := (fun_of_two_eq_sets h f) in\n    range f = range fT\n    := \n    begin\n        intro fT,\n        have h1 : ∀b : B ,b ∈ range f ↔ b ∈ range fT :=\n            begin \n                intro b,\n                split,\n                intro bf,\n                let s := some bf,\n                have spec : f s = b := some_spec bf,\n                have eq : fT ⟨ s.val , (h s.val).1 s.property⟩ = f s := \n                    eq.symm (eq_fun_of_eq_sets S T h f s),\n\n                have ex : ∃ t : T , fT t = b := \n                    exists.intro \n                    (⟨ s.val , (h s.val).1 s.property⟩ : T) \n                    (by rw [eq , spec]),\n                exact ex,\n                intro bfT,\n                tidy\n            end,\n        exact eq_sets.1 h1 \n    end\n\ndef img_comp {X Y Z : Type u} (f : X → Y) (g : Y → Z) (s : set X):\n    image g (image f s) = image (g ∘ f) s := \n    begin\n        have h3: ∀ z : Z, (z ∈ image g (image f s)) ↔  \n                    (z ∈ image (g ∘ f) s)\n                    := \n            begin\n                intro z,\n                split,\n                intro el,\n                cases el with fa specFA,\n                cases specFA.1 with a specA,\n                use a,\n                split,\n                exact specA.1,\n                simp [specA.2 , specFA.2],\n                intro ex,\n                cases ex with a spec,\n                have fa_Y : f a ∈ image f s := \n                    begin use a, tidy end,\n                have gfa_Z : g (f a) ∈ image g (image f s) :=\n                    begin \n                        use f a,\n                        split,\n                        simp,\n                        tidy\n\n                    end,\n                rw ← spec.2,\n                exact gfa_Z\n            end,\n        exact eq_sets.1 h3\n\n    end\n\n\n\n\nlemma not_and_left {p q : Prop}: ¬ (p ∧ q) → p → ¬ q :=\n    λ hnpq , λ hp , λ hq, absurd (and.intro hp hq) hnpq\n\nlemma not_and_right {p q : Prop}: ¬ (p ∧ q) → q → ¬ p :=\n    λ hnpq , λ hp , by {intros a, simp at *, solve_by_elim}\n\n\nend help_functions\n\n\n\ndef if_func (p : Prop) [decidable p] : Prop := \n        if p\n            then p\n            else ¬p\n\nlemma solving_if_func (p : Prop) [d : decidable p] : if_func p :=\n    match d with\n    | is_true h := h\n    | is_false nh := nh\n    end\n    \ndef fun_using_if_fun (p : Prop) [decidable p] : ℕ := \n    let some_fun : Prop :=         -- same thing with let ... in\n                if p\n                    then p\n                    else ¬p in\n    have some_proof : some_fun := \n        begin\n            dsimp [some_fun], -- some_fun, \n            split_ifs, \n            exact h,\n            exact h\n        end,\n    1\n\ndef fun_using_if_fun_tactic (p : Prop) [decidable p] : ℕ :=\n    begin\n        let some_fun : Prop :=         -- same thing with let ... in\n                    if p\n                        then p\n                        else ¬p,\n        have some_proof : some_fun := \n            begin\n                dsimp [some_fun],\n                split_ifs, \n                exact h,\n                exact h\n            end,\n        exact 1\n    end\n\n\ndef eff_len {A : Type*} [inhabited A] (n : ℕ) : \n        list A          →   ℕ\n        | []           :=  n\n        | (h::tl)      :=  (eff_len tl)\n\ndef subsubset {A: Type*} {V : set A} {U : set V} : set A\n    :=  subtype.val '' U      -- or just u.val\n\n\n\n", "meta": {"author": "QaisHamarneh", "repo": "Coalgebra-in-Lean", "sha": "bd0452df98bc64b608e5dfd7babc42c301bb6a46", "save_path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean", "path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean/Coalgebra-in-Lean-bd0452df98bc64b608e5dfd7babc42c301bb6a46/src/help_functions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4842579186253507}}
{"text": "\nimport algebra.big_operators.ring\n\nopen_locale big_operators\n\nsection\n\nuniverse variables u v\n\nparameter {F : Type u}\nparameter [field F]\n\n-- Probably not appropriate for mathlib\nlemma mul_sum_symm {α : Type u} {β : Type v} {s : finset α} {b : β} {f : α → β} \n  [non_unital_non_assoc_semiring β] : \n  ∑ (x : α) in s, b * f x = b * ∑ (x : α) in s, f x := finset.mul_sum.symm\n\nexample (n : ℕ) (a : F) (b : fin n -> F) : \n(∑ (i : fin n) in finset.fin_range n, a * b i) = a * (∑ (i : fin n) in finset.fin_range n, b i) :=\nbegin\n  -- rw <-finset.mul_sum, -- works fine\n  rw mul_sum_symm, -- this fails without \"universe variables\" above\nend\n\nend", "meta": {"author": "BoltonBailey", "repo": "formal-snarks-project", "sha": "154414784f90a1e257162fcbdd7e805ecb2a49c2", "save_path": "github-repos/lean/BoltonBailey-formal-snarks-project", "path": "github-repos/lean/BoltonBailey-formal-snarks-project/formal-snarks-project-154414784f90a1e257162fcbdd7e805ecb2a49c2/src/general_lemmas/mul_sum_symm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4841782372683386}}
{"text": "/-\nCopyright (c) 2021 Shing Tak Lam. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Shing Tak Lam\n-/\n\nimport topology.algebra.order.proj_Icc\nimport topology.continuous_function.ordered\nimport topology.compact_open\nimport topology.unit_interval\n\n/-!\n# Homotopy between functions\n\nIn this file, we define a homotopy between two functions `f₀` and `f₁`. First we define\n`continuous_map.homotopy` between the two functions, with no restrictions on the intermediate\nmaps. Then, as in the formalisation in HOL-Analysis, we define\n`continuous_map.homotopy_with f₀ f₁ P`, for homotopies between `f₀` and `f₁`, where the\nintermediate maps satisfy the predicate `P`. Finally, we define\n`continuous_map.homotopy_rel f₀ f₁ S`, for homotopies between `f₀` and `f₁` which are fixed\non `S`.\n\n## Definitions\n\n* `continuous_map.homotopy f₀ f₁` is the type of homotopies between `f₀` and `f₁`.\n* `continuous_map.homotopy_with f₀ f₁ P` is the type of homotopies between `f₀` and `f₁`, where\n  the intermediate maps satisfy the predicate `P`.\n* `continuous_map.homotopy_rel f₀ f₁ S` is the type of homotopies between `f₀` and `f₁` which\n  are fixed on `S`.\n\nFor each of the above, we have\n\n* `refl f`, which is the constant homotopy from `f` to `f`.\n* `symm F`, which reverses the homotopy `F`. For example, if `F : continuous_map.homotopy f₀ f₁`,\n  then `F.symm : continuous_map.homotopy f₁ f₀`.\n* `trans F G`, which concatenates the homotopies `F` and `G`. For example, if\n  `F : continuous_map.homotopy f₀ f₁` and `G : continuous_map.homotopy f₁ f₂`, then\n  `F.trans G : continuous_map.homotopy f₀ f₂`.\n\nWe also define the relations\n\n* `continuous_map.homotopic f₀ f₁` is defined to be `nonempty (continuous_map.homotopy f₀ f₁)`\n* `continuous_map.homotopic_with f₀ f₁ P` is defined to be\n  `nonempty (continuous_map.homotopy_with f₀ f₁ P)`\n* `continuous_map.homotopic_rel f₀ f₁ P` is defined to be\n  `nonempty (continuous_map.homotopy_rel f₀ f₁ P)`\n\nand for `continuous_map.homotopic` and `continuous_map.homotopic_rel`, we also define the\n`setoid` and `quotient` in `C(X, Y)` by these relations.\n\n## References\n\n- [HOL-Analysis formalisation](https://isabelle.in.tum.de/library/HOL/HOL-Analysis/Homotopy.html)\n-/\n\nnoncomputable theory\n\nuniverses u v w\n\nvariables {F : Type*} {X : Type u} {Y : Type v} {Z : Type w}\nvariables [topological_space X] [topological_space Y] [topological_space Z]\n\nopen_locale unit_interval\n\nnamespace continuous_map\n\n/-- `continuous_map.homotopy f₀ f₁` is the type of homotopies from `f₀` to `f₁`.\n\nWhen possible, instead of parametrizing results over `(f : homotopy f₀ f₁)`,\nyou should parametrize over `{F : Type*} [homotopy_like F f₀ f₁] (f : F)`.\n\nWhen you extend this structure, make sure to extend `continuous_map.homotopy_like`. -/\nstructure homotopy (f₀ f₁ : C(X, Y)) extends C(I × X, Y) :=\n(map_zero_left' : ∀ x, to_fun (0, x) = f₀ x)\n(map_one_left' : ∀ x, to_fun (1, x) = f₁ x)\n\n/-- `continuous_map.homotopy_like F f₀ f₁` states that `F` is a type of homotopies between `f₀` and\n`f₁`.\n\nYou should extend this class when you extend `continuous_map.homotopy`. -/\nclass homotopy_like (F : Type*) (f₀ f₁ : out_param $ C(X, Y))\n  extends continuous_map_class F (I × X) Y :=\n(map_zero_left (f : F) : ∀ x, f (0, x) = f₀ x)\n(map_one_left (f : F) : ∀ x, f (1, x) = f₁ x)\n\n-- `f₀` and `f₁` are `out_param` so this is not dangerous\nattribute [nolint dangerous_instance] homotopy_like.to_continuous_map_class\n\nnamespace homotopy\n\nsection\n\nvariables {f₀ f₁ : C(X, Y)}\n\ninstance : homotopy_like (homotopy f₀ f₁) f₀ f₁ :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h, by { obtain ⟨⟨_, _⟩, _⟩ := f, obtain ⟨⟨_, _⟩, _⟩ := g, congr' },\n  map_continuous := λ f, f.continuous_to_fun,\n  map_zero_left := λ f, f.map_zero_left',\n  map_one_left := λ f, f.map_one_left' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (homotopy f₀ f₁) (λ _, I × X → Y) := fun_like.has_coe_to_fun\n\n@[ext]\nlemma ext {F G : homotopy f₀ f₁} (h : ∀ x, F x = G x) : F = G := fun_like.ext _ _ h\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\nbecause it is a composition of multiple projections. -/\ndef simps.apply (F : homotopy f₀ f₁) : I × X → Y := F\n\ninitialize_simps_projections homotopy (to_continuous_map_to_fun -> apply, -to_continuous_map)\n\n/-- Deprecated. Use `map_continuous` instead. -/\nprotected lemma continuous (F : homotopy f₀ f₁) : continuous F := F.continuous_to_fun\n\n@[simp]\nlemma apply_zero (F : homotopy f₀ f₁) (x : X) : F (0, x) = f₀ x := F.map_zero_left' x\n\n@[simp]\nlemma apply_one (F : homotopy f₀ f₁) (x : X) : F (1, x) = f₁ x := F.map_one_left' x\n\n@[simp]\nlemma coe_to_continuous_map (F : homotopy f₀ f₁) : ⇑F.to_continuous_map = F := rfl\n\n/--\nCurrying a homotopy to a continuous function fron `I` to `C(X, Y)`.\n-/\ndef curry (F : homotopy f₀ f₁) : C(I, C(X, Y)) := F.to_continuous_map.curry\n\n@[simp]\nlemma curry_apply (F : homotopy f₀ f₁) (t : I) (x : X) : F.curry t x = F (t, x) := rfl\n\n/--\nContinuously extending a curried homotopy to a function from `ℝ` to `C(X, Y)`.\n-/\ndef extend (F : homotopy f₀ f₁) : C(ℝ, C(X, Y)) := F.curry.Icc_extend zero_le_one\n\nlemma extend_apply_of_le_zero (F : homotopy f₀ f₁) {t : ℝ} (ht : t ≤ 0) (x : X) :\n  F.extend t x = f₀ x :=\nbegin\n  rw [←F.apply_zero],\n  exact continuous_map.congr_fun (set.Icc_extend_of_le_left (@zero_le_one ℝ _) F.curry ht) x,\nend\n\nlemma extend_apply_of_one_le (F : homotopy f₀ f₁) {t : ℝ} (ht : 1 ≤ t) (x : X) :\n  F.extend t x = f₁ x :=\nbegin\n  rw [←F.apply_one],\n  exact continuous_map.congr_fun (set.Icc_extend_of_right_le (@zero_le_one ℝ _) F.curry ht) x,\nend\n\n@[simp]\nlemma extend_apply_coe (F : homotopy f₀ f₁) (t : I) (x : X) : F.extend t x = F (t, x) :=\ncontinuous_map.congr_fun (set.Icc_extend_coe (@zero_le_one ℝ _) F.curry t) x\n\n@[simp]\nlemma extend_apply_of_mem_I (F : homotopy f₀ f₁) {t : ℝ} (ht : t ∈ I) (x : X) :\n  F.extend t x = F (⟨t, ht⟩, x) :=\ncontinuous_map.congr_fun (set.Icc_extend_of_mem (@zero_le_one ℝ _) F.curry ht) x\n\nlemma congr_fun {F G : homotopy f₀ f₁} (h : F = G) (x : I × X) : F x = G x :=\ncontinuous_map.congr_fun (congr_arg _ h) x\n\nlemma congr_arg (F : homotopy f₀ f₁) {x y : I × X} (h : x = y) : F x = F y :=\nF.to_continuous_map.congr_arg h\n\nend\n\n/--\nGiven a continuous function `f`, we can define a `homotopy f f` by `F (t, x) = f x`\n-/\n@[simps]\ndef refl (f : C(X, Y)) : homotopy f f :=\n{ to_fun := λ x, f x.2,\n  map_zero_left' := λ _, rfl,\n  map_one_left' := λ _, rfl }\n\ninstance : inhabited (homotopy (continuous_map.id X) (continuous_map.id X)) := ⟨homotopy.refl _⟩\n\n/--\nGiven a `homotopy f₀ f₁`, we can define a `homotopy f₁ f₀` by reversing the homotopy.\n-/\n@[simps]\ndef symm {f₀ f₁ : C(X, Y)} (F : homotopy f₀ f₁) : homotopy f₁ f₀ :=\n{ to_fun := λ x, F (σ x.1, x.2),\n  map_zero_left' := by norm_num,\n  map_one_left' := by norm_num }\n\n@[simp]\nlemma symm_symm {f₀ f₁ : C(X, Y)} (F : homotopy f₀ f₁) : F.symm.symm = F :=\nby { ext, simp }\n\n/--\nGiven `homotopy f₀ f₁` and `homotopy f₁ f₂`, we can define a `homotopy f₀ f₂` by putting the first\nhomotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans {f₀ f₁ f₂ : C(X, Y)} (F : homotopy f₀ f₁) (G : homotopy f₁ f₂) :\n  homotopy f₀ f₂ :=\n{ to_fun := λ x, if (x.1 : ℝ) ≤ 1/2 then F.extend (2 * x.1) x.2 else G.extend (2 * x.1 - 1) x.2,\n  continuous_to_fun := begin\n    refine continuous_if_le (continuous_induced_dom.comp continuous_fst) continuous_const\n      (F.continuous.comp (by continuity)).continuous_on\n      (G.continuous.comp (by continuity)).continuous_on _,\n    rintros x hx,\n    norm_num [hx],\n  end,\n  map_zero_left' := λ x, by norm_num,\n  map_one_left' := λ x, by norm_num }\n\nlemma trans_apply {f₀ f₁ f₂ : C(X, Y)} (F : homotopy f₀ f₁) (G : homotopy f₁ f₂)\n  (x : I × X) : (F.trans G) x =\n  if h : (x.1 : ℝ) ≤ 1/2 then\n    F (⟨2 * x.1, (unit_interval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2)\n  else\n    G (⟨2 * x.1 - 1, unit_interval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) :=\nshow ite _ _ _ = _,\nby split_ifs; { rw [extend, continuous_map.coe_Icc_extend, set.Icc_extend_of_mem], refl }\n\nlemma symm_trans {f₀ f₁ f₂ : C(X, Y)} (F : homotopy f₀ f₁) (G : homotopy f₁ f₂) :\n  (F.trans G).symm = G.symm.trans F.symm :=\nbegin\n  ext x,\n  simp only [symm_apply, trans_apply],\n  split_ifs with h₁ h₂,\n  { change (x.1 : ℝ) ≤ _ at h₂,\n    change (1 : ℝ) - x.1 ≤ _ at h₁,\n    have ht : (x.1 : ℝ) = 1/2,\n    { linarith },\n    norm_num [ht] },\n  { congr' 2,\n    apply subtype.ext,\n    simp only [unit_interval.coe_symm_eq, subtype.coe_mk],\n    linarith },\n  { congr' 2,\n    apply subtype.ext,\n    simp only [unit_interval.coe_symm_eq, subtype.coe_mk],\n    linarith },\n  { change ¬ (x.1 : ℝ) ≤ _ at h,\n    change ¬ (1 : ℝ) - x.1 ≤ _ at h₁,\n    exfalso, linarith }\nend\n\n/--\nCasting a `homotopy f₀ f₁` to a `homotopy g₀ g₁` where `f₀ = g₀` and `f₁ = g₁`.\n-/\n@[simps]\ndef cast {f₀ f₁ g₀ g₁ : C(X, Y)} (F : homotopy f₀ f₁) (h₀ : f₀ = g₀) (h₁ : f₁ = g₁) :\n  homotopy g₀ g₁ :=\n{ to_fun := F,\n  map_zero_left' := by simp [←h₀],\n  map_one_left' := by simp [←h₁] }\n\n/--\nIf we have a `homotopy f₀ f₁` and a `homotopy g₀ g₁`, then we can compose them and get a\n`homotopy (g₀.comp f₀) (g₁.comp f₁)`.\n-/\n@[simps]\ndef hcomp {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(Y, Z)} (F : homotopy f₀ f₁) (G : homotopy g₀ g₁) :\n  homotopy (g₀.comp f₀) (g₁.comp f₁) :=\n{ to_fun := λ x, G (x.1, F x),\n  map_zero_left' := by simp,\n  map_one_left' := by simp }\n\nend homotopy\n\n/--\nGiven continuous maps `f₀` and `f₁`, we say `f₀` and `f₁` are homotopic if there exists a\n`homotopy f₀ f₁`.\n-/\ndef homotopic (f₀ f₁ : C(X, Y)) : Prop :=\nnonempty (homotopy f₀ f₁)\n\nnamespace homotopic\n\n@[refl]\nlemma refl (f : C(X, Y)) : homotopic f f := ⟨homotopy.refl f⟩\n\n@[symm]\nlemma symm ⦃f g : C(X, Y)⦄ (h : homotopic f g) : homotopic g f := h.map homotopy.symm\n\n@[trans]\n\n\nlemma hcomp {f₀ f₁ : C(X, Y)} {g₀ g₁ : C(Y, Z)} (h₀ : homotopic f₀ f₁) (h₁ : homotopic g₀ g₁) :\n  homotopic (g₀.comp f₀) (g₁.comp f₁) :=\nh₀.map2 homotopy.hcomp h₁\n\nlemma equivalence : equivalence (@homotopic X Y _ _) := ⟨refl, symm, trans⟩\n\nend homotopic\n\n/--\nThe type of homotopies between `f₀ f₁ : C(X, Y)`, where the intermediate maps satisfy the predicate\n`P : C(X, Y) → Prop`\n-/\nstructure homotopy_with (f₀ f₁ : C(X, Y)) (P : C(X, Y) → Prop) extends homotopy f₀ f₁ :=\n(prop' : ∀ t, P ⟨λ x, to_fun (t, x),\n  continuous.comp continuous_to_fun (continuous_const.prod_mk continuous_id')⟩)\n\nnamespace homotopy_with\n\nsection\n\nvariables {f₀ f₁ : C(X, Y)} {P : C(X, Y) → Prop}\n\ninstance : has_coe_to_fun (homotopy_with f₀ f₁ P) (λ _, I × X → Y) := ⟨λ F, F.to_fun⟩\n\nlemma coe_fn_injective : @function.injective (homotopy_with f₀ f₁ P) (I × X → Y) coe_fn :=\nbegin\n  rintros ⟨⟨⟨F, _⟩, _⟩, _⟩ ⟨⟨⟨G, _⟩, _⟩, _⟩ h,\n  congr' 3,\nend\n\n@[ext]\nlemma ext {F G : homotopy_with f₀ f₁ P} (h : ∀ x, F x = G x) : F = G :=\ncoe_fn_injective $ funext h\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\nbecause it is a composition of multiple projections. -/\ndef simps.apply (F : homotopy_with f₀ f₁ P) : I × X → Y := F\n\ninitialize_simps_projections homotopy_with\n  (to_homotopy_to_continuous_map_to_fun -> apply, -to_homotopy_to_continuous_map)\n\n@[continuity]\nprotected lemma continuous (F : homotopy_with f₀ f₁ P) : continuous F := F.continuous_to_fun\n\n@[simp]\nlemma apply_zero (F : homotopy_with f₀ f₁ P) (x : X) : F (0, x) = f₀ x := F.map_zero_left' x\n\n@[simp]\nlemma apply_one (F : homotopy_with f₀ f₁ P) (x : X) : F (1, x) = f₁ x := F.map_one_left' x\n\n@[simp]\nlemma coe_to_continuous_map (F : homotopy_with f₀ f₁ P) : ⇑F.to_continuous_map = F := rfl\n\n@[simp]\nlemma coe_to_homotopy (F : homotopy_with f₀ f₁ P) : ⇑F.to_homotopy = F := rfl\n\nlemma prop (F : homotopy_with f₀ f₁ P) (t : I) : P (F.to_homotopy.curry t) := F.prop' t\n\nlemma extend_prop (F : homotopy_with f₀ f₁ P) (t : ℝ) : P (F.to_homotopy.extend t) :=\nbegin\n  by_cases ht₀ : 0 ≤ t,\n  { by_cases ht₁ : t ≤ 1,\n    { convert F.prop ⟨t, ht₀, ht₁⟩,\n      ext,\n      rw [F.to_homotopy.extend_apply_of_mem_I ⟨ht₀, ht₁⟩, F.to_homotopy.curry_apply] },\n    { convert F.prop 1,\n      ext,\n      rw [F.to_homotopy.extend_apply_of_one_le (le_of_not_le ht₁), F.to_homotopy.curry_apply,\n          F.to_homotopy.apply_one] } },\n  { convert F.prop 0,\n    ext,\n    rw [F.to_homotopy.extend_apply_of_le_zero (le_of_not_le ht₀), F.to_homotopy.curry_apply,\n        F.to_homotopy.apply_zero] }\nend\n\nend\n\nvariable {P : C(X, Y) → Prop}\n\n/--\nGiven a continuous function `f`, and a proof `h : P f`, we can define a `homotopy_with f f P` by\n`F (t, x) = f x`\n-/\n@[simps]\ndef refl (f : C(X, Y)) (hf : P f) : homotopy_with f f P :=\n{ prop' := λ t, by { convert hf, cases f, refl },\n  ..homotopy.refl f }\n\ninstance : inhabited (homotopy_with (continuous_map.id X) (continuous_map.id X) (λ f, true)) :=\n⟨homotopy_with.refl _ trivial⟩\n\n/--\nGiven a `homotopy_with f₀ f₁ P`, we can define a `homotopy_with f₁ f₀ P` by reversing the homotopy.\n-/\n@[simps]\ndef symm {f₀ f₁ : C(X, Y)} (F : homotopy_with f₀ f₁ P) : homotopy_with f₁ f₀ P :=\n{ prop' := λ t, by simpa using F.prop (σ t),\n  ..F.to_homotopy.symm }\n\n@[simp]\nlemma symm_symm {f₀ f₁ : C(X, Y)} (F : homotopy_with f₀ f₁ P) : F.symm.symm = F :=\next $ homotopy.congr_fun $ homotopy.symm_symm _\n\n/--\nGiven `homotopy_with f₀ f₁ P` and `homotopy_with f₁ f₂ P`, we can define a `homotopy_with f₀ f₂ P`\nby putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans {f₀ f₁ f₂ : C(X, Y)} (F : homotopy_with f₀ f₁ P) (G : homotopy_with f₁ f₂ P) :\n  homotopy_with f₀ f₂ P :=\n{ prop' := λ t, begin\n    simp only [homotopy.trans],\n    change P ⟨λ _, ite ((t : ℝ) ≤ _) _ _, _⟩,\n    split_ifs,\n    { exact F.extend_prop _ },\n    { exact G.extend_prop _ }\n  end,\n  ..F.to_homotopy.trans G.to_homotopy }\n\nlemma trans_apply {f₀ f₁ f₂ : C(X, Y)} (F : homotopy_with f₀ f₁ P) (G : homotopy_with f₁ f₂ P)\n  (x : I × X) : (F.trans G) x =\n  if h : (x.1 : ℝ) ≤ 1/2 then\n    F (⟨2 * x.1, (unit_interval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2)\n  else\n    G (⟨2 * x.1 - 1, unit_interval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) :=\nhomotopy.trans_apply _ _ _\n\nlemma symm_trans {f₀ f₁ f₂ : C(X, Y)} (F : homotopy_with f₀ f₁ P) (G : homotopy_with f₁ f₂ P) :\n  (F.trans G).symm = G.symm.trans F.symm :=\next $ homotopy.congr_fun $ homotopy.symm_trans _ _\n\n/--\nCasting a `homotopy_with f₀ f₁ P` to a `homotopy_with g₀ g₁ P` where `f₀ = g₀` and `f₁ = g₁`.\n-/\n@[simps]\ndef cast {f₀ f₁ g₀ g₁ : C(X, Y)} (F : homotopy_with f₀ f₁ P) (h₀ : f₀ = g₀) (h₁ : f₁ = g₁) :\n  homotopy_with g₀ g₁ P :=\n{ prop' := F.prop,\n  ..F.to_homotopy.cast h₀ h₁ }\n\nend homotopy_with\n\n/--\nGiven continuous maps `f₀` and `f₁`, we say `f₀` and `f₁` are homotopic with respect to the\npredicate `P` if there exists a `homotopy_with f₀ f₁ P`.\n-/\ndef homotopic_with (f₀ f₁ : C(X, Y)) (P : C(X, Y) → Prop) : Prop :=\nnonempty (homotopy_with f₀ f₁ P)\n\nnamespace homotopic_with\n\nvariable {P : C(X, Y) → Prop}\n\n@[refl]\nlemma refl (f : C(X, Y)) (hf : P f) : homotopic_with f f P :=\n⟨homotopy_with.refl f hf⟩\n\n@[symm]\nlemma symm ⦃f g : C(X, Y)⦄ (h : homotopic_with f g P) : homotopic_with g f P := ⟨h.some.symm⟩\n\n@[trans]\nlemma trans ⦃f g h : C(X, Y)⦄ (h₀ : homotopic_with f g P) (h₁ : homotopic_with g h P) :\n  homotopic_with f h P :=\n⟨h₀.some.trans h₁.some⟩\n\nend homotopic_with\n\n/--\nA `homotopy_rel f₀ f₁ S` is a homotopy between `f₀` and `f₁` which is fixed on the points in `S`.\n-/\nabbreviation homotopy_rel (f₀ f₁ : C(X, Y)) (S : set X) :=\nhomotopy_with f₀ f₁ (λ f, ∀ x ∈ S, f x = f₀ x ∧ f x = f₁ x)\n\nnamespace homotopy_rel\n\nsection\n\nvariables {f₀ f₁ : C(X, Y)} {S : set X}\n\nlemma eq_fst (F : homotopy_rel f₀ f₁ S) (t : I) {x : X} (hx : x ∈ S) :\n  F (t, x) = f₀ x := (F.prop t x hx).1\n\nlemma eq_snd (F : homotopy_rel f₀ f₁ S) (t : I) {x : X} (hx : x ∈ S) :\n  F (t, x) = f₁ x := (F.prop t x hx).2\n\nlemma fst_eq_snd (F : homotopy_rel f₀ f₁ S) {x : X} (hx : x ∈ S) :\n  f₀ x = f₁ x := F.eq_fst 0 hx ▸ F.eq_snd 0 hx\n\nend\n\nvariables {f₀ f₁ f₂ : C(X, Y)} {S : set X}\n\n/--\nGiven a map `f : C(X, Y)` and a set `S`, we can define a `homotopy_rel f f S` by setting\n`F (t, x) = f x` for all `t`. This is defined using `homotopy_with.refl`, but with the proof\nfilled in.\n-/\n@[simps]\ndef refl (f : C(X, Y)) (S : set X) : homotopy_rel f f S :=\nhomotopy_with.refl f (λ x hx, ⟨rfl, rfl⟩)\n\n/--\nGiven a `homotopy_rel f₀ f₁ S`, we can define a `homotopy_rel f₁ f₀ S` by reversing the homotopy.\n-/\n@[simps]\ndef symm (F : homotopy_rel f₀ f₁ S) : homotopy_rel f₁ f₀ S :=\n{ prop' := λ t x hx, by simp [F.eq_snd _ hx, F.fst_eq_snd hx],\n  ..homotopy_with.symm F }\n\n@[simp]\nlemma symm_symm (F : homotopy_rel f₀ f₁ S) : F.symm.symm = F :=\nhomotopy_with.symm_symm F\n\n/--\nGiven `homotopy_rel f₀ f₁ S` and `homotopy_rel f₁ f₂ S`, we can define a `homotopy_rel f₀ f₂ S`\nby putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans (F : homotopy_rel f₀ f₁ S) (G : homotopy_rel f₁ f₂ S) : homotopy_rel f₀ f₂ S :=\n{ prop' := λ t, begin\n    intros x hx,\n    simp only [homotopy.trans],\n    change (⟨λ _, ite ((t : ℝ) ≤ _) _ _, _⟩ : C(X, Y)) _ = _ ∧ _ = _,\n    split_ifs,\n    { simp [(homotopy_with.extend_prop F (2 * t) x hx).1, F.fst_eq_snd hx, G.fst_eq_snd hx] },\n    { simp [(homotopy_with.extend_prop G (2 * t - 1) x hx).1, F.fst_eq_snd hx, G.fst_eq_snd hx] },\n  end,\n  ..homotopy.trans F.to_homotopy G.to_homotopy }\n\nlemma trans_apply (F : homotopy_rel f₀ f₁ S) (G : homotopy_rel f₁ f₂ S)\n  (x : I × X) : (F.trans G) x =\n  if h : (x.1 : ℝ) ≤ 1/2 then\n    F (⟨2 * x.1, (unit_interval.mul_pos_mem_iff zero_lt_two).2 ⟨x.1.2.1, h⟩⟩, x.2)\n  else\n    G (⟨2 * x.1 - 1, unit_interval.two_mul_sub_one_mem_iff.2 ⟨(not_le.1 h).le, x.1.2.2⟩⟩, x.2) :=\nhomotopy.trans_apply _ _ _\n\nlemma symm_trans (F : homotopy_rel f₀ f₁ S) (G : homotopy_rel f₁ f₂ S) :\n  (F.trans G).symm = G.symm.trans F.symm :=\nhomotopy_with.ext $ homotopy.congr_fun $ homotopy.symm_trans _ _\n\n/--\nCasting a `homotopy_rel f₀ f₁ S` to a `homotopy_rel g₀ g₁ S` where `f₀ = g₀` and `f₁ = g₁`.\n-/\n@[simps]\ndef cast {f₀ f₁ g₀ g₁ : C(X, Y)} (F : homotopy_rel f₀ f₁ S) (h₀ : f₀ = g₀) (h₁ : f₁ = g₁) :\n  homotopy_rel g₀ g₁ S :=\n{ prop' := λ t x hx, by { simpa [←h₀, ←h₁] using F.prop t x hx },\n  ..homotopy.cast F.to_homotopy h₀ h₁ }\n\nend homotopy_rel\n\n/--\nGiven continuous maps `f₀` and `f₁`, we say `f₀` and `f₁` are homotopic relative to a set `S` if\nthere exists a `homotopy_rel f₀ f₁ S`.\n-/\ndef homotopic_rel (f₀ f₁ : C(X, Y)) (S : set X) : Prop :=\nnonempty (homotopy_rel f₀ f₁ S)\n\nnamespace homotopic_rel\n\nvariable {S : set X}\n\n@[refl]\nlemma refl (f : C(X, Y)) : homotopic_rel f f S := ⟨homotopy_rel.refl f S⟩\n\n@[symm]\nlemma symm ⦃f g : C(X, Y)⦄ (h : homotopic_rel f g S) : homotopic_rel g f S :=\n  h.map homotopy_rel.symm\n\n@[trans]\nlemma trans ⦃f g h : C(X, Y)⦄ (h₀ : homotopic_rel f g S) (h₁ : homotopic_rel g h S) :\n  homotopic_rel f h S :=\nh₀.map2 homotopy_rel.trans h₁\n\nlemma equivalence : equivalence (λ f g : C(X, Y), homotopic_rel f g S) :=\n⟨refl, symm, trans⟩\n\nend homotopic_rel\n\nend continuous_map\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/homotopy/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.48413285972895015}}
{"text": "import localization_UMP\nimport massot_indexed_products\nimport data.fintype\nimport data.set.finite\nimport group_theory.submonoid\nimport tactic.ring\nimport chris_ring_lemma\nlocal attribute [instance] classical.prop_decidable\n-- Chris' proof of exactness\nuniverses u v w\n\nopen finset classical quotient \n\nsection\nvariables {α : Type u} {β : Type v} {γ : Type w}\n\nlemma is_ring_hom.inj_of_kernel_eq_zero [comm_ring α] [comm_ring β] {f : α → β} [hf : is_ring_hom f] \n    (h : ∀ {x}, f x = 0 → x = 0) : function.injective f := \nλ x y hxy, by rw [← sub_eq_zero_iff_eq, ← is_ring_hom.map_sub f] at hxy;\n  exact sub_eq_zero_iff_eq.1 (h hxy)\n\ninstance indexed_product.is_ring_hom [comm_ring α] {I : Type v} {f : I → Type w} [∀ i, comm_ring (f i)]\n(g : α → Π i : I, f i) [rh : ∀ i : I, is_ring_hom (λ a : α, g a i)] : is_ring_hom g :=\n{ map_add := λ x y, funext $ λ i, @is_ring_hom.map_add _ _ _ _ _ (rh i) x y,\n  map_mul := λ x y, funext $ λ i, @is_ring_hom.map_mul _ _ _ _ _ (rh i) x y,\n  map_one := funext $ λ i, @is_ring_hom.map_one _ _ _ _ _ (rh i) }\n\nopen finset\n\nlemma exists_sum_iff_mem_span_finset {x : β} [ring α] [module α β] {s : finset β} \n    : x ∈ span (↑s : set β) ↔ ∃ r : β → α, x = s.sum (λ y, r y • y) :=\n⟨λ ⟨r, hr⟩, ⟨r, hr.2.symm ▸ sum_bij_ne_zero (λ a _ _, a)\n  (λ a has ha, classical.by_contradiction (λ h, ha (by simp [hr.1 _ h])))\n  (λ _ _ _ _ _ _, id)\n  (λ b hbr hb, ⟨b, (finsupp.mem_support_iff).2 (λ h, hb (by simp [h])), hb, rfl⟩)\n  (λ _ _ _, rfl)⟩,\nλ ⟨r, hr⟩, hr.symm ▸ is_submodule.sum (λ c hc, is_submodule.smul _ (subset_span hc))⟩\n\nlemma exists_sum_iff_mem_span_image_finset {x : β} [ring α] [module α β] {s : finset γ}\n    {f : γ → β} : x ∈ span (↑(s.image f) : set β) ↔ \n    ∃ r : γ → α, x = s.sum (λ b, r b • f b) :=\n⟨λ h, let ⟨r, hr⟩ := exists_sum_iff_mem_span_finset.1 h in\nhave hc : ∀ y ∈ s, ∃ z ∈ s, f z = f y := λ y hy, ⟨y, hy, rfl⟩,\n⟨λ y, if ∃ hy : y ∈ s, y = some (hc y hy) then r (f y) else 0, \n  hr.symm ▸ sum_bij_ne_zero (λ a ha _, some (mem_image.1 ha)) \n    (λ a ha _, let ⟨h, _⟩ := some_spec (mem_image.1 ha) in h) \n    (λ a₁ a₂ ha₁ _ ha₂ _ h, \n      let ⟨_, h₁⟩ := some_spec (mem_image.1 ha₁) in\n      let ⟨_, h₂⟩ := some_spec (mem_image.1 ha₂) in\n      h₁ ▸ h₂ ▸ h ▸ rfl)\n    (λ b hbs hb0,\n      have hfb : f b ∈ image f s := mem_image.2 ⟨b, hbs, rfl⟩,\n      have hb : b = some (mem_image.1 hfb) := classical.by_contradiction\n        (λ h, have h' : ¬∃ (x : b ∈ s), b = some _ := not_exists.2 (λ hy : b ∈ s, h), \n        by rw [if_neg h', zero_smul] at hb0; exact hb0 rfl),\n      ⟨f b, hfb, by rwa if_pos at hb0; exact ⟨hbs, hb⟩, hb⟩)\n    (λ a ha ha0, let ⟨h₁, h₂⟩ := some_spec (mem_image.1 ha) in\n      by rw [if_pos, h₂]; exact ⟨h₁, by simp only [h₂]⟩)⟩,\nλ ⟨r, hr⟩, hr.symm ▸ is_submodule.sum (λ c hc, is_submodule.smul _ \n    (subset_span (mem_image.2 ⟨c, hc, rfl⟩)))⟩\n \nlemma sum_pow_mem_span {α R : Type*} [comm_ring R] (s : finset α)\n    (f : α → R) (n : α → ℕ) (r : α → R) : s.sum (λ a, r a • f a) ^ (s.sum n + 1) ∈ span \n    (↑(s.image (λ a, f a ^ n a)) : set R) :=\nfinset.induction_on s (by simp) $ λ a s has hi, \nbegin\n  rw [sum_insert has, add_pow],\n  refine @is_submodule.sum R R _ _ (span _) _ _ _ _ _ (λ k hk, _),\n  cases le_total (n a) k with hak hak,\n  { rw [← nat.add_sub_cancel' hak, pow_add],\n    simp only [mul_assoc, smul_eq_mul, mul_pow, mul_left_comm _ (f a ^ n a)],\n    exact is_submodule.smul' _ (subset_span (mem_image.2 ⟨a, mem_insert_self _ _, rfl⟩)) },\n  { rw [sum_insert has, add_assoc, add_comm (n a), nat.add_sub_assoc hak, pow_add],\n    simp only [mul_assoc, smul_eq_mul, mul_pow, mul_left_comm _ (sum s _ ^ (sum s n + 1))],\n    have : span ↑(image (λ a, f a ^ n a) s) ⊆ span ↑(image (λ a, f a ^ n a) (insert a s)) := \n      span_minimal is_submodule_span (set.subset.trans \n        (by rw [image_insert,coe_subset]; exact subset_insert _ _) subset_span),\n    exact is_submodule.smul' _ (this hi), }\nend\n\nlemma one_mem_span_pow_of_mem_span {α R : Type*} [comm_ring R] {s : finset α}\n    {f : α → R} (n : α → ℕ) (h : (1 : R) ∈ span (↑(s.image f) : set R)) : \n    (1 : R) ∈ span (↑(s.image (λ x, f x ^ n x)) : set R) :=\nlet ⟨r, hr⟩ := exists_sum_iff_mem_span_image_finset.1 h in\n@one_pow R _ (s.sum n + 1) ▸ hr.symm ▸ sum_pow_mem_span _ _ _ _\n\nend\n\nvariables {R : Type u} {γ : Type v} [comm_ring R] [fintype γ]\nopen localization\n\ndef tag00EJ.α (f : γ → R) (x : R) : Π i, loc R (powers (f i)) :=\n  λ i, of_comm_ring R _ x\n\nnoncomputable def tag00EJ.β {f : γ → R}\n    (r : Π i, loc R (powers (f i))) (j k : γ) :\n    loc R (powers (f j * f k)) :=\nlocalize_more_left (f j) (f k) (r j) - localize_more_right (f j) (f k) (r k)\n\n-- β not a ring hom but it's β₁ - β₂ with ring homs defined below.\n\nnoncomputable def tag00EJ.β₁ {f : γ → R}\n    (r : Π i, loc R (powers (f i))) (j k : γ) :\n    loc R (powers (f j * f k)) :=\nlocalize_more_left (f j) (f k) (r j)\n\nnoncomputable def tag00EJ.β₂ {f : γ → R}\n    (r : Π i, loc R (powers (f i))) (j k : γ) :\n    loc R (powers (f j * f k)) :=\nlocalize_more_right (f j) (f k) (r k)\n\nopen tag00EJ \n\nlemma localize_more_left_eq (f g x : R) (n : ℕ) : \n    localize_more_left f g ⟦⟨x, ⟨f^n, n, rfl⟩⟩⟧ = ⟦⟨x * g^n, (f * g)^n, n, rfl⟩⟧ :=\nbegin\n  let h,\n  show ⟦_⟧ * classical.some h = ⟦_⟧,\n  have := some_spec h,\n  rw ← quotient.out_eq (some h) at *,\n  rcases out (some h) with ⟨s₁, s₂, hs⟩, intro this,\n  rcases quotient.exact this with ⟨r, hr₁, hr₂⟩,\n  refine quot.sound ⟨r, hr₁, _⟩,\n  rw [sub_mul, sub_eq_zero_iff_eq] at hr₂,\n  have hr₂' : s₂ * r = f ^ n * s₁ * r,\n  { simpa using hr₂ },\n  suffices : (s₂ * (x * g ^ n) - ((f * g) ^ n * (x * s₁))) * r = 0,\n  { rw ← this, simp },\n  simp only [sub_mul, mul_pow, mul_assoc, mul_left_comm s₂,\n      mul_comm r, mul_left_comm r, hr₂'],\n  ring\nend\n\nlemma localize_more_right_eq (f g x : R) (n : ℕ) : \n    localize_more_right f g ⟦⟨x, ⟨g^n, n, rfl⟩⟩⟧ = ⟦⟨x * f^n, (f * g)^n, n, rfl⟩⟧ := \nbegin\n  let h,\n  show ⟦_⟧ * classical.some h = ⟦_⟧,\n  have := some_spec h,\n  rw ← quotient.out_eq (some h) at *,\n  rcases out (some h) with ⟨s₁, s₂, hs⟩, intro this,\n  rcases quotient.exact this with ⟨r, hr₁, hr₂⟩,\n  refine quot.sound ⟨r, hr₁, _⟩,\n  rw [sub_mul, sub_eq_zero_iff_eq] at hr₂,\n  have hr₂' : s₂ * r = g ^ n * s₁ * r,\n  { simpa using hr₂ },\n  suffices : (s₂ * (x * f ^ n) - ((f * g) ^ n * (x * s₁))) * r = 0,\n  { rw ← this, simp },\n  simp only [sub_mul, mul_pow, mul_assoc, mul_left_comm s₂, \n      mul_comm r, mul_left_comm r, hr₂'],\n  ring\nend\n\nlemma lemma_standard_covering₁ {f : γ → R}\n    (h : (1 : R) ∈ span (↑(univ.image f) : set R)) : function.injective (α f) :=\n@is_ring_hom.inj_of_kernel_eq_zero _ _ _ _ (α f) \n  (@indexed_product.is_ring_hom _ _ _ _ _ (α f) \n  (λ i, by unfold α; apply_instance))\nbegin \n  assume x hx,\n  replace hx := congr_fun hx,\n  have : ∀ i, ∃ e : ℕ, f i ^ e * x = 0 := λ i, begin\n    rcases (quotient.eq.1 (hx i)) with ⟨r, hr₁, hr₂⟩,\n    cases hr₁ with e he,\n    have : x * r = 0 := by simpa using hr₂,\n    exact ⟨e, by rwa [mul_comm, he]⟩\n  end,\n  let e : γ → ℕ := λ i, classical.some (this i),\n  have he : ∀ i, f i ^ e i * x = 0 := λ i, some_spec (this i),\n  cases exists_sum_iff_mem_span_image_finset.1 (one_mem_span_pow_of_mem_span e h) with r hr,\n  rw [← one_mul x, hr, sum_mul, ← @sum_const_zero _ _ (univ : finset γ)],\n  refine finset.sum_congr rfl (λ i _, _),\n  rw [smul_eq_mul, mul_assoc, he, mul_zero],\nend\n\nlemma lemma_standard_covering₂ (f : γ → R) \n    (H : (1:R) ∈ span (↑(univ.image f) : set R)) (s : Π i, loc R (powers (f i))) :\n    β s = 0 ↔ ∃ r : R, α f r = s := \n⟨λ h : β s = 0,\nlet t := λ i, out (s i) in\nlet r := λ i, some (t i).2.2 in\nhave hst : ∀ i, s i = ⟦⟨(t i).1, (f i) ^ (r i), r i, rfl⟩⟧ := \n    λ i, by simp [r, some_spec (t i).2.2],\nhave hi : ∀ i, s i = ⟦⟨(t i).1, (t i).2.1, (t i).2.2⟩⟧ := λ i, by simp,\nhave hβ : _ := λ i j, sub_eq_zero_iff_eq.1 $ show β s i j = 0, by rw h; refl,\nhave hβ : ∀ i j,\n    (⟦⟨(t i).1 * f j ^ r i, ⟨(f i * f j) ^ r i, r i, rfl⟩⟩⟧ : loc R (powers (f i * f j))) =\n    ⟦⟨(t j).1 * f i ^ r j, ⟨(f i * f j) ^ r j, r j, rfl⟩⟩⟧ := by conv at hβ in (_ = _) {rw [hst, hst,\n      localize_more_left_eq, localize_more_right_eq] }; exact hβ,\nhave ∀ i j, ∃ n, \n    ((f i * f j) ^ r i * ((t j).1 * f i ^ r j) - \n    ((f i * f j) ^ r j * ((t i).1 * f j ^ r i)))\n    * (f i * f j) ^ n = 0 :=\n  λ i j, let ⟨t, ⟨n, hn⟩, hnt⟩ := quotient.exact (hβ i j) \n      in ⟨n, by rw hn; exact hnt⟩,\nlet n := λ i j, some (this i j) + r i + r j in\nhave hn : ∀ i j, (f i ^ r i * (t j).1 - \n    f j ^ r j * (t i).1) * (f i * f j) ^ n i j = 0 := \n  λ i j, by rw [← zero_mul (f i ^ r i), \n      ← zero_mul (f j ^ r j), ← some_spec (this i j)];\n    simp [n, pow_add, mul_pow];\n    ring,\nlet N := finset.sum (univ : finset (_ × _)) (λ ij, n ij.1 ij.2) in\nhave Nlt : ∀ i j, n i j ≤ N := λ i j, \n  @single_le_sum _ _ _ (λ h : γ × γ, n h.1 h.2) _\n  _ (λ _ _, nat.zero_le _) _ (mem_univ (i, j)),\nhave hN : ∀ i j, (f i ^ r i * (t j).1 - \n    f j ^ r j * (t i).1) * (f i * f j) ^ N = 0 := λ i j, \n  begin rw [← nat.sub_add_cancel (Nlt i j), \n      ← zero_mul ((f i * f j) ^ (N - n i j)), ← hn i j, \n      pow_add _ (N - n i j), mul_pow, mul_pow],\n    simp [mul_add, add_mul, mul_comm, mul_left_comm, mul_assoc],\n  end,\nlet ⟨a, ha⟩ := exists_sum_iff_mem_span_image_finset.1 \n    (one_mem_span_pow_of_mem_span (λ i, N + r i) H) in\n⟨univ.sum (λ j, a j * (f j) ^ N * (t j).1),\nfunext (λ i, (hst i).symm ▸ quot.sound ⟨(f i) ^ N, ⟨N, rfl⟩,\nhave (λ j, f i ^ r i * (a j * f j ^ N * (t j).fst) * f i ^ N) =\n      (λ j, (a j • (f j) ^ (N + r j) * (t i).1) * (f i) ^ N) := funext (λ j, begin\n  rw [← sub_eq_zero_iff_eq, smul_eq_mul],\n  simp only [mul_assoc, mul_left_comm _ (a j)],\n  rw [← mul_sub],\n  suffices : (f i ^ r i * (f j ^ N * ((t j).fst * f i ^ N))) -\n      (f j ^ (N + r j) * ((t i).fst * f i ^ N)) = 0,\n  { rw [this, mul_zero] },\n  rw ← hN i j,\n  simp [pow_add, mul_pow],\n  ring,\n  end),\nbegin\n  suffices : ((t i).fst - (f i ^ r i * sum univ (λ j, a j * f j ^ N * (t j).1))) * f i ^ N = 0,\n    simpa using this,\n  rw [mul_sum, sub_mul, sum_mul, this, ← sum_mul, ← sum_mul, ← ha, one_mul, sub_self]\nend⟩)⟩,\nλ ⟨r, hr⟩, hr ▸ show β (α f r) = λ i j, 0, from funext $ λ i, funext $ λ j, \n  sub_eq_zero_iff_eq.2 $ loc_commutes _ _ _⟩\n", "meta": {"author": "kbuzzard", "repo": "lean-stacks-project", "sha": "b57be17aa917f1c3a23c59db5ee37b1aa21112c2", "save_path": "github-repos/lean/kbuzzard-lean-stacks-project", "path": "github-repos/lean/kbuzzard-lean-stacks-project/lean-stacks-project-b57be17aa917f1c3a23c59db5ee37b1aa21112c2/src/tag00EJ.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4841328594427568}}
{"text": "/-\nCopyright (c) 2020 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot\n-/\n\nimport analysis.specific_limits\n\n/-!\n# Hofer's lemma\n\nThis is an elementary lemma about complete metric spaces. It is motivated by an\napplication to the bubbling-off analysis for holomorphic curves in symplectic topology.\nWe are *very* far away from having these applications, but the proof here is a nice\nexample of a proof needing to construct a sequence by induction in the middle of the proof.\n\n## References:\n\n* H. Hofer and C. Viterbo, *The Weinstein conjecture in the presence of holomorphic spheres*\n-/\n\nopen_locale classical topological_space big_operators\nopen filter finset\n\nlocal notation `d` := dist\n\nlemma hofer {X: Type*} [metric_space X] [complete_space X]\n  (x : X) (ε : ℝ) (ε_pos : 0 < ε)\n  {ϕ : X → ℝ} (cont : continuous ϕ) (nonneg : ∀ y, 0 ≤ ϕ y) :\n  ∃ (ε' > 0) (x' : X), ε' ≤ ε ∧\n                       d x' x ≤ 2*ε ∧\n                       ε * ϕ(x) ≤ ε' * ϕ x' ∧\n                       ∀ y, d x' y ≤ ε' → ϕ y ≤ 2*ϕ x' :=\nbegin\n  by_contradiction H,\n  have reformulation : ∀ x' (k : ℕ), ε * ϕ x ≤ ε / 2 ^ k * ϕ x' ↔ 2^k * ϕ x ≤ ϕ x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left ε_pos, mul_comm],\n    exact pow_pos (by norm_num) k, },\n  -- Now let's specialize to `ε/2^k`\n  replace H : ∀ k : ℕ, ∀ x', d x' x ≤ 2 * ε ∧ 2^k * ϕ x ≤ ϕ x' →\n    ∃ y, d x' y ≤ ε/2^k ∧ 2 * ϕ x' < ϕ y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using\n      H (ε/2^k) (by simp [ε_pos, zero_lt_two]) x' (by simp [ε_pos, zero_lt_two, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := ⟨x⟩,\n  choose! F hF using H,  -- Use the axiom of choice\n  -- Now define u by induction starting at x, with u_{n+1} = F(n, u_n)\n  let u : ℕ → X := λ n, nat.rec_on n x F,\n  have hu0 : u 0 = x := rfl,\n  -- The properties of F translate to properties of u\n  have hu :\n    ∀ n,\n      d (u n) x ≤ 2 * ε ∧ 2^n * ϕ x ≤ ϕ (u n) →\n      d (u n) (u $ n + 1) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u $ n + 1),\n  { intro n,\n    exact hF n (u n) },\n  clear hF,\n  -- Key properties of u, to be proven by induction\n  have key : ∀ n, d (u n) (u (n + 1)) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u (n + 1)),\n  { intro n,\n    induction n using nat.case_strong_induction_on with n IH,\n    { specialize hu 0,\n      simpa [hu0, mul_nonneg_iff, zero_le_one, ε_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x ≤ 2 * ε,\n    { rw [dist_comm],\n      let r := range (n+1), -- range (n+1) = {0, ..., n}\n      calc\n      d (u 0) (u (n + 1))\n          ≤ ∑ i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... ≤ ∑ i in r, ε/2^i             : sum_le_sum (λ i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = ∑ i in r, (1/2)^i*ε         : by { congr' with i, field_simp }\n      ... = (∑ i in r, (1/2)^i)*ε       : finset.sum_mul.symm\n      ... ≤ 2*ε                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt ε_pos), },\n    have B : 2^(n+1) * ϕ x ≤ ϕ (u (n + 1)),\n    { refine @geom_le (ϕ ∘ u) _ zero_le_two (n + 1) (λ m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) ⟨A, B⟩, },\n  cases forall_and_distrib.mp key with key₁ key₂,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ ε one_half_lt_one (λ n, _),\n    simpa only [one_div, inv_pow'] using key₁ n },\n  -- So u converges to some y\n  obtain ⟨y, limy⟩ : ∃ y, tendsto u at_top (𝓝 y),\n    from complete_space.complete cauchy_u,\n  -- And ϕ ∘ u goes to +∞\n  have lim_top : tendsto (ϕ ∘ u) at_top at_top,\n  { let v := λ n, (ϕ ∘ u) (n+1),\n    suffices : tendsto v at_top at_top,\n      by rwa tendsto_add_at_top_iff_nat at this,\n    have hv₀ : 0 < v 0,\n    { have : 0 ≤ ϕ (u 0) := nonneg x,\n      calc 0 ≤ 2 * ϕ (u 0) : by linarith\n      ... < ϕ (u (0 + 1)) : key₂ 0 },\n    apply tendsto_at_top_of_geom_le hv₀ one_lt_two,\n    exact λ n, (key₂ (n+1)).le },\n  -- But ϕ ∘ u also needs to go to ϕ(y)\n  have lim : tendsto (ϕ ∘ u) at_top (𝓝 (ϕ y)),\n    from tendsto.comp cont.continuous_at limy,\n  -- So we have our contradiction!\n  exact not_tendsto_at_top_of_tendsto_nhds lim lim_top,\nend\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/analysis/hofer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4841328512389159}}
{"text": "import GMLInit.Prelude\n\n-- Stable Propositions --\n\nclass inductive Stable (a : Prop) : Prop\n| protected intro : (¬¬a → a) → Stable a\n\nabbrev inferStable (a : Prop) [inst : Stable a] := inst\n\nprotected def Stable.by_contradiction {a : Prop} [inst : Stable a] : ¬¬a → a :=\n  match inst with | Stable.intro h => h\n\n/-- double negation elimination (DNE) -/\ntheorem Stable.dne (a : Prop) [inst : Stable a] : ¬¬a → a :=\n  match inst with | Stable.intro h => h\n\n/-- Pierces's law -/\ntheorem Stable.pierce (a b : Prop) [Stable a] : ((a → b) → a) → a :=\n  λ h => Stable.by_contradiction λ na => na (h λ ha => absurd ha na)\n\nabbrev StablePred {α} (p : α → Prop) := (x : α) → Stable (p x)\n\nabbrev StableRel {α β} (r : α → β → Prop) := (x : α) → (y : β) → Stable (r x y)\n\nabbrev StableEq (α) := StableRel (@Eq α)\n\nclass inductive StableList : List Prop → Prop\n| nil : StableList []\n| cons {a as} : Stable a → StableList as → StableList (a :: as)\n\nnamespace StableList\n\ninstance : StableList [] := StableList.nil\n\ninstance (a as) [Stable a] [StableList as] : StableList (a :: as) :=\n  StableList.cons inferInstance inferInstance\n\nprotected def head (a as) : [StableList (a :: as)] → Stable a\n| StableList.cons inst _ => inst\n\nprotected def tail (a as) : [StableList (a :: as)] → StableList as\n| StableList.cons _ inst => inst\n\nend StableList\n\n-- Complemented Propositions --\n\nclass inductive Complemented (a : Prop) : Prop\n| isTrue : a → Complemented a\n| isFalse : ¬a → Complemented a\n\nabbrev inferComplemented (a : Prop) [inst : Complemented a] := inst\n\n/-- eliminator for `Complemented` -/\nprotected def Complemented.by_cases (a : Prop) [inst : Complemented a] {motive : Prop} (isTrue : a → motive) (isFalse : ¬a → motive) : motive :=\n  match inst with\n  | .isTrue h => isTrue h\n  | .isFalse h => isFalse h\n\n/-- excluded middle (EM) -/\ntheorem Complemented.em (a : Prop) [Complemented a] : a ∨ ¬a := Complemented.by_cases a Or.inl Or.inr\n\nabbrev ComplementedPred {α} (p : α → Prop) := (x : α) → Complemented (p x)\n\nabbrev ComplementedRel {α β} (r : α → β → Prop) := (x : α) → (y : β) → Complemented (r x y)\n\nabbrev ComplementedEq (α) := ComplementedRel (@Eq α)\n\nclass inductive ComplementedList : List Prop → Prop\n| nil : ComplementedList []\n| cons {a as} : Complemented a → ComplementedList as → ComplementedList (a :: as)\n\nnamespace ComplementedList\n\ninstance : ComplementedList [] := ComplementedList.nil\n\ninstance (a as) [Complemented a] [ComplementedList as] : ComplementedList (a :: as) :=\n  ComplementedList.cons inferInstance inferInstance\n\nprotected def head (a as) : [ComplementedList (a :: as)] → Complemented a\n| ComplementedList.cons inst _ => inst\n\nprotected def tail (a as) : [ComplementedList (a :: as)] → ComplementedList as\n| ComplementedList.cons _ inst => inst\n\ninstance instMap {α} (a : α → Prop) [ComplementedPred a] : (xs : List α) → ComplementedList (xs.map a)\n| [] => ComplementedList.nil\n| _::xs => ComplementedList.cons inferInstance (instMap a xs)\n\nend ComplementedList\n\ninstance (a : Prop) : [Complemented a] → Stable a\n| Complemented.isTrue h => Stable.intro (λ _ => h)\n| Complemented.isFalse h => Stable.intro (absurd h)\n\n-- Decidable Propositions --\n\nabbrev inferDecidable (a : Prop) [inst : Decidable a] := inst\n\nclass inductive DecidableList : List Prop → Type\n| nil : DecidableList []\n| cons {a as} : Decidable a → DecidableList as → DecidableList (a :: as)\n\nnamespace DecidableList\n\ninstance : DecidableList [] := DecidableList.nil\n\ninstance (a as) [Decidable a] [DecidableList as] : DecidableList (a :: as) :=\n  DecidableList.cons inferInstance inferInstance\n\nprotected def head (a as) : [DecidableList (a :: as)] → Decidable a\n| DecidableList.cons inst _ => inst\n\nprotected def tail (a as) : [DecidableList (a :: as)] → DecidableList as\n| DecidableList.cons _ inst => inst\n\ninstance instMap {α} (a : α → Prop) [DecidablePred a] : (xs : List α) → DecidableList (xs.map a)\n| [] => DecidableList.nil\n| _::xs => DecidableList.cons inferInstance (instMap a xs)\n\nend DecidableList\n\ninstance (a : Prop) : [Decidable a] → Complemented a\n| Decidable.isTrue h => Complemented.isTrue h\n| Decidable.isFalse h => Complemented.isFalse h\n\n-- Weakly Complemented Propositions --\n\nclass inductive WeaklyComplemented (a : Prop) : Prop\n| protected isFalse : ¬a → WeaklyComplemented a\n| protected isIrrefutable : ¬¬a → WeaklyComplemented a\n\nabbrev inferWeaklyComplemented (a : Prop) [inst : WeaklyComplemented a] := inst\n\n/-- weak excluded middle (WEM) -/\ntheorem WeaklyComplemented.wem (a : Prop) : [WeaklyComplemented a] → ¬¬a ∨ ¬a\n| WeaklyComplemented.isIrrefutable h => Or.inl h\n| WeaklyComplemented.isFalse h => Or.inr h\n\nabbrev WeaklyComplementedPred {α} (p : α → Prop) := (x : α) → WeaklyComplemented (p x)\n\nabbrev WeaklyComplementedRel {α β} (r : α → β → Prop) := (x : α) → (y : β) → WeaklyComplemented (r x y)\n\nabbrev WeaklyComplementedEq (α) := WeaklyComplementedRel (@Eq α)\n\nclass inductive WeaklyComplementedList : List Prop → Prop\n| nil : WeaklyComplementedList []\n| cons {a as} : WeaklyComplemented a → WeaklyComplementedList as → WeaklyComplementedList (a :: as)\n\nnamespace WeaklyComplementedList\n\ninstance : WeaklyComplementedList [] := WeaklyComplementedList.nil\n\ninstance (a as) [WeaklyComplemented a] [WeaklyComplementedList as] : WeaklyComplementedList (a :: as) :=\n  WeaklyComplementedList.cons inferInstance inferInstance\n\nprotected def head (a as) : [WeaklyComplementedList (a :: as)] → WeaklyComplemented a\n| WeaklyComplementedList.cons inst _ => inst\n\nprotected def tail (a as) : [WeaklyComplementedList (a :: as)] → WeaklyComplementedList as\n| WeaklyComplementedList.cons _ inst => inst\n\ninstance instMap {α} (a : α → Prop) [WeaklyComplementedPred a] : (xs : List α) → WeaklyComplementedList (xs.map a)\n| [] => WeaklyComplementedList.nil\n| _::xs => WeaklyComplementedList.cons inferInstance (instMap a xs)\n\nend WeaklyComplementedList\n\ndef complementedOfStableOfWeaklyComplemented (a : Prop) [Stable a] : [WeaklyComplemented a] → Complemented a\n| WeaklyComplemented.isFalse h => Complemented.isFalse h\n| WeaklyComplemented.isIrrefutable h => Complemented.isTrue (Stable.by_contradiction h)\n\ninstance (a : Prop) : [Complemented a] → WeaklyComplemented a\n| Complemented.isTrue h => WeaklyComplemented.isIrrefutable (absurd h)\n| Complemented.isFalse h => WeaklyComplemented.isFalse h\n\ninstance (a : Prop) : [WeaklyComplemented a] → Complemented (¬a)\n| WeaklyComplemented.isFalse h => Complemented.isTrue h\n| WeaklyComplemented.isIrrefutable h => Complemented.isFalse h\n\n-- Weakly Decidable Propositions --\n\nclass inductive WeaklyDecidable (a : Prop) : Type\n| protected isFalse : ¬a → WeaklyDecidable a\n| protected isIrrefutable : ¬¬a → WeaklyDecidable a\n\nabbrev inferWeaklyDecidable (a : Prop) [inst : WeaklyDecidable a] := inst\n\nabbrev WeaklyDecidablePred {α} (p : α → Prop) := (x : α) → WeaklyDecidable (p x)\n\nabbrev WeaklyDecidableRel {α β} (r : α → β → Prop) := (x : α) → (y : β) → WeaklyDecidable (r x y)\n\nabbrev WeaklyDecidableEq (α) := WeaklyDecidableRel (@Eq α)\n\nclass inductive WeaklyDecidableList : List Prop → Type\n| nil : WeaklyDecidableList []\n| cons {a as} : WeaklyDecidable a → WeaklyDecidableList as → WeaklyDecidableList (a :: as)\n\nnamespace WeaklyDecidableList\n\ninstance : WeaklyDecidableList [] := WeaklyDecidableList.nil\n\ninstance (a as) [WeaklyDecidable a] [WeaklyDecidableList as] : WeaklyDecidableList (a :: as) :=\n  WeaklyDecidableList.cons inferInstance inferInstance\n\nprotected def head (a as) : [WeaklyDecidableList (a :: as)] → WeaklyDecidable a\n| WeaklyDecidableList.cons inst _ => inst\n\nprotected def tail (a as) : [WeaklyDecidableList (a :: as)] → WeaklyDecidableList as\n| WeaklyDecidableList.cons _ inst => inst\n\ninstance instMap {α} (a : α → Prop) [WeaklyDecidablePred a] : (xs : List α) → WeaklyDecidableList (xs.map a)\n| [] => WeaklyDecidableList.nil\n| _::xs => WeaklyDecidableList.cons inferInstance (instMap a xs)\n\nend WeaklyDecidableList\n\ndef decidableOfStableOfWeaklyDecidable (a : Prop) [Stable a] : [WeaklyDecidable a] → Decidable a\n| WeaklyDecidable.isFalse h => Decidable.isFalse h\n| WeaklyDecidable.isIrrefutable h => Decidable.isTrue (Stable.by_contradiction h)\n\ninstance (a : Prop) : [Decidable a] → WeaklyDecidable a\n| Decidable.isTrue h => WeaklyDecidable.isIrrefutable (absurd h)\n| Decidable.isFalse h => WeaklyDecidable.isFalse h\n\ninstance (a : Prop) : [WeaklyDecidable a] → Decidable (¬a)\n| WeaklyDecidable.isFalse h => Decidable.isTrue h\n| WeaklyDecidable.isIrrefutable h => Decidable.isFalse h\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Logic/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.4841328506665296}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport data.sum\nimport logic.function.basic\nimport control.functor\nimport tactic.core\n\n/-!\n# Functors with two arguments\n\nThis file defines bifunctors.\n\nA bifunctor is a function `F : Type* → Type* → Type*` along with a bimap which turns `F α β` into\n`F α' β'` given two functions `α → α'` and `β → β'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') ∘ (bimap f g) = bimap (f' ∘ f) (g' ∘ g)`\n\n## Main declarations\n\n* `bifunctor`: A typeclass for the bare bimap of a bifunctor.\n* `is_lawful_bifunctor`: A typeclass asserting this bimap respects the bifunctor laws.\n-/\n\nuniverses u₀ u₁ u₂ v₀ v₁ v₂\n\nopen function\n\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass bifunctor (F : Type u₀ → Type u₁ → Type u₂) :=\n(bimap : Π {α α' β β'}, (α → α') → (β → β') → F α β → F α' β')\nexport bifunctor ( bimap )\n\n/-- Bifunctor. This typeclass asserts that a lawless `bifunctor` is lawful. -/\nclass is_lawful_bifunctor (F : Type u₀ → Type u₁ → Type u₂) [bifunctor F] :=\n(id_bimap : Π {α β} (x : F α β), bimap id id x = x)\n(bimap_bimap : Π {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂)\n  (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀),\n  bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x)\n\nexport is_lawful_bifunctor (id_bimap bimap_bimap)\n\nattribute [higher_order bimap_id_id] id_bimap\nattribute [higher_order bimap_comp_bimap] bimap_bimap\n\nexport is_lawful_bifunctor (bimap_id_id bimap_comp_bimap)\nvariables {F : Type u₀ → Type u₁ → Type u₂} [bifunctor F]\n\nnamespace bifunctor\n\n/-- Left map of a bifunctor. -/\n@[reducible] def fst {α α' β} (f : α → α') : F α β → F α' β := bimap f id\n\n/-- Right map of a bifunctor. -/\n@[reducible] def snd {α β β'} (f : β → β') : F α β → F α β' := bimap id f\n\nvariable [is_lawful_bifunctor F]\n\n@[higher_order fst_id]\nlemma id_fst : Π {α β} (x : F α β), fst id x = x :=\n@id_bimap _ _ _\n\n@[higher_order snd_id]\nlemma id_snd : Π {α β} (x : F α β), snd id x = x :=\n@id_bimap _ _ _\n\n@[higher_order fst_comp_fst]\n\n\n@[higher_order fst_comp_snd]\nlemma fst_snd {α₀ α₁ β₀ β₁}\n  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n  fst f (snd f' x) = bimap f f' x :=\nby simp [fst,bimap_bimap]\n\n@[higher_order snd_comp_fst]\nlemma snd_fst {α₀ α₁ β₀ β₁}\n  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n  snd f' (fst f x) = bimap f f' x :=\nby simp [snd,bimap_bimap]\n\n@[higher_order snd_comp_snd]\nlemma comp_snd {α β₀ β₁ β₂}\n  (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α β₀) :\n  snd g' (snd g x) = snd (g' ∘ g) x :=\nby simp [snd,bimap_bimap]\n\nattribute [functor_norm] bimap_bimap comp_snd comp_fst\n  snd_comp_snd snd_comp_fst fst_comp_snd fst_comp_fst bimap_comp_bimap\n  bimap_id_id fst_id snd_id\n\nend bifunctor\nopen functor\ninstance : bifunctor prod :=\n{ bimap := @prod.map }\n\ninstance : is_lawful_bifunctor prod :=\nby refine { .. }; intros; cases x; refl\n\ninstance bifunctor.const : bifunctor const :=\n{ bimap := (λ α α' β β f _, f) }\n\ninstance is_lawful_bifunctor.const : is_lawful_bifunctor const  :=\nby refine { .. }; intros; refl\n\ninstance bifunctor.flip : bifunctor (flip F) :=\n{ bimap := (λ α α' β β' f f' x, (bimap f' f x : F β' α')) }\n\ninstance is_lawful_bifunctor.flip [is_lawful_bifunctor F] : is_lawful_bifunctor (flip F)  :=\nby refine { .. }; intros; simp [bimap] with functor_norm\n\ninstance : bifunctor sum :=\n{ bimap := @sum.map }\n\ninstance : is_lawful_bifunctor sum :=\nby refine { .. }; intros; cases x; refl\n\nopen bifunctor functor\n\n@[priority 10]\ninstance bifunctor.functor {α} : functor (F α) :=\n{ map := λ _ _, snd }\n\n@[priority 10]\ninstance bifunctor.is_lawful_functor [is_lawful_bifunctor F] {α} : is_lawful_functor (F α) :=\nby refine {..}; intros; simp [functor.map] with functor_norm\n\nsection bicompl\n\nvariables (G : Type* → Type u₀) (H : Type* → Type u₁) [functor G] [functor H]\n\ninstance : bifunctor (bicompl F G H) :=\n{ bimap := λ α α' β β' f f' x, (bimap (map f) (map f') x : F (G α') (H β')) }\n\ninstance [is_lawful_functor G]  [is_lawful_functor H] [is_lawful_bifunctor F] :\n  is_lawful_bifunctor (bicompl F G H) :=\nby constructor; intros; simp [bimap,map_id,map_comp_map] with functor_norm\n\nend bicompl\nsection bicompr\n\nvariables (G : Type u₂ → Type*) [functor G]\n\ninstance : bifunctor (bicompr G F) :=\n{ bimap := λ α α' β β' f f' x, (map (bimap f f') x : G (F α' β')) }\n\ninstance [is_lawful_functor G] [is_lawful_bifunctor F] :\n  is_lawful_bifunctor (bicompr G F) :=\nby constructor; intros; simp [bimap] with functor_norm\n\nend bicompr\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/control/bifunctor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.48406610402810407}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebraic_geometry.presheafed_space\nimport topology.sheaves.sheaf\n\n/-!\n# Sheafed spaces\n\nIntroduces the category of topological spaces equipped with a sheaf (taking values in an\narbitrary target category `C`.)\n\nWe further describe how to apply functors and natural transformations to the values of the\npresheaves.\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.limits\nopen category_theory.category category_theory.functor\n\nvariables (C : Type u) [category.{v} C] [limits.has_products C]\n\nlocal attribute [tidy] tactic.op_induction'\n\nnamespace algebraic_geometry\n\n/-- A `SheafedSpace C` is a topological space equipped with a sheaf of `C`s. -/\nstructure SheafedSpace extends PresheafedSpace C :=\n(sheaf_condition : presheaf.sheaf_condition)\n\nvariables {C}\n\nnamespace SheafedSpace\n\ninstance coe_carrier : has_coe (SheafedSpace C) Top :=\n{ coe := λ X, X.carrier }\n\n/-- Extract the `sheaf C (X : Top)` from a `SheafedSpace C`. -/\ndef sheaf (X : SheafedSpace C) : sheaf C (X : Top.{v}) := ⟨X.presheaf, X.sheaf_condition⟩\n\n@[simp] lemma as_coe (X : SheafedSpace C) : X.carrier = (X : Top.{v}) := rfl\n@[simp] lemma mk_coe (carrier) (presheaf) (h) :\n  (({ carrier := carrier, presheaf := presheaf, sheaf_condition := h } : SheafedSpace.{v} C) :\n  Top.{v}) = carrier :=\nrfl\n\ninstance (X : SheafedSpace.{v} C) : topological_space X := X.carrier.str\n\n/-- The trivial `punit` valued sheaf on any topological space. -/\nnoncomputable\ndef punit (X : Top) : SheafedSpace (discrete punit) :=\n{ sheaf_condition := presheaf.sheaf_condition_punit _,\n  ..@PresheafedSpace.const (discrete punit) _ X punit.star }\n\nnoncomputable\ninstance : inhabited (SheafedSpace (discrete _root_.punit)) := ⟨punit (Top.of pempty)⟩\n\ninstance : category (SheafedSpace C) :=\nshow category (induced_category (PresheafedSpace C) SheafedSpace.to_PresheafedSpace),\nby apply_instance\n\n/-- Forgetting the sheaf condition is a functor from `SheafedSpace C` to `PresheafedSpace C`. -/\ndef forget_to_PresheafedSpace : (SheafedSpace C) ⥤ (PresheafedSpace C) :=\ninduced_functor _\n\nvariables {C}\n\nsection\nlocal attribute [simp] id comp\n\n@[simp] lemma id_base (X : SheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).base = (𝟙 (X : Top.{v})) := rfl\n\nlemma id_c (X : SheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).c =\n  (((functor.left_unitor _).inv) ≫\n  (whisker_right (nat_trans.op (opens.map_id (X.carrier)).hom) _)) := rfl\n\n@[simp] lemma id_c_app (X : SheafedSpace C) (U) :\n  ((𝟙 X) : X ⟶ X).c.app U = eq_to_hom (by { op_induction U, cases U, refl }) :=\nby { op_induction U, cases U, simp only [id_c], dsimp, simp, }\n\n@[simp] lemma comp_base {X Y Z : SheafedSpace C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).base = f.base ≫ g.base := rfl\n\n@[simp] lemma comp_c_app {X Y Z : SheafedSpace C} (α : X ⟶ Y) (β : Y ⟶ Z) (U) :\n  (α ≫ β).c.app U = (β.c).app U ≫ (α.c).app (op ((opens.map (β.base)).obj (unop U))) ≫\n    (Top.presheaf.pushforward.comp _ _ _).inv.app U := rfl\n\nvariables (C)\n\n/-- The forgetful functor from `SheafedSpace` to `Top`. -/\ndef forget : SheafedSpace C ⥤ Top :=\n{ obj := λ X, (X : Top.{v}),\n  map := λ X Y f, f.base }\n\nend\n\nopen Top.presheaf\n\n/--\nThe restriction of a sheafed space along an open embedding into the space.\n-/\nnoncomputable\ndef restrict {U : Top} (X : SheafedSpace C)\n  (f : U ⟶ (X : Top.{v})) (h : open_embedding f) : SheafedSpace C :=\n{ sheaf_condition := λ ι 𝒰, is_limit.of_iso_limit\n    ((is_limit.postcompose_inv_equiv _ _).inv_fun (X.sheaf_condition _))\n    (sheaf_condition_equalizer_products.fork.iso_of_open_embedding h 𝒰).symm,\n  ..X.to_PresheafedSpace.restrict f h }\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : (SheafedSpace C)ᵒᵖ ⥤ C :=\nforget_to_PresheafedSpace.op ⋙ PresheafedSpace.Γ\n\nlemma Γ_def : (Γ : _ ⥤ C) = forget_to_PresheafedSpace.op ⋙ PresheafedSpace.Γ := rfl\n\n@[simp] \n\nlemma Γ_obj_op (X : SheafedSpace C) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\n@[simp] lemma Γ_map {X Y : (SheafedSpace C)ᵒᵖ} (f : X ⟶ Y) :\n  Γ.map f = f.unop.c.app (op ⊤) ≫ (unop Y).presheaf.map (opens.le_map_top _ _).op := rfl\n\nlemma Γ_map_op {X Y : SheafedSpace C} (f : X ⟶ Y) :\n  Γ.map f.op = f.c.app (op ⊤) ≫ X.presheaf.map (opens.le_map_top _ _).op := rfl\n\nend SheafedSpace\n\nend algebraic_geometry\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebraic_geometry/sheafed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.4840660976739238}}
{"text": "/-\nCopyright (c) 2018 Sean Leather. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sean Leather, Mario Carneiro\n-/\nimport data.list.alist\nimport data.finset.basic\nimport data.pfun\n/-!\n# Finite maps over `multiset`\n-/\n\nuniverses u v w\nopen list\nvariables {α : Type u} {β : α → Type v}\n\n/-! ### multisets of sigma types-/\n\nnamespace multiset\n\n/-- Multiset of keys of an association multiset. -/\ndef keys (s : multiset (sigma β)) : multiset α :=\ns.map sigma.fst\n\n@[simp] theorem coe_keys {l : list (sigma β)} :\n  keys (l : multiset (sigma β)) = (l.keys : multiset α) :=\nrfl\n\n/-- `nodupkeys s` means that `s` has no duplicate keys. -/\ndef nodupkeys (s : multiset (sigma β)) : Prop :=\nquot.lift_on s list.nodupkeys (λ s t p, propext $ perm_nodupkeys p)\n\n@[simp] theorem coe_nodupkeys {l : list (sigma β)} : @nodupkeys α β l ↔ l.nodupkeys := iff.rfl\n\nend multiset\n\n/-! ### finmap -/\n\n/-- `finmap β` is the type of finite maps over a multiset. It is effectively\n  a quotient of `alist β` by permutation of the underlying list. -/\nstructure finmap (β : α → Type v) : Type (max u v) :=\n(entries : multiset (sigma β))\n(nodupkeys : entries.nodupkeys)\n\n/-- The quotient map from `alist` to `finmap`. -/\ndef alist.to_finmap (s : alist β) : finmap β := ⟨s.entries, s.nodupkeys⟩\n\nlocal notation `⟦`:max a `⟧`:0 := alist.to_finmap a\n\ntheorem alist.to_finmap_eq {s₁ s₂ : alist β} :\n  ⟦s₁⟧ = ⟦s₂⟧ ↔ s₁.entries ~ s₂.entries :=\nby cases s₁; cases s₂; simp [alist.to_finmap]\n\n@[simp] theorem alist.to_finmap_entries (s : alist β) : ⟦s⟧.entries = s.entries := rfl\n\n/-- Given `l : list (sigma β)`, create a term of type `finmap β` by removing\nentries with duplicate keys. -/\ndef list.to_finmap [decidable_eq α] (s : list (sigma β)) : finmap β := s.to_alist.to_finmap\n\nnamespace finmap\nopen alist\n\n/-! ### lifting from alist -/\n\n/-- Lift a permutation-respecting function on `alist` to `finmap`. -/\n@[elab_as_eliminator] def lift_on\n  {γ} (s : finmap β) (f : alist β → γ)\n  (H : ∀ a b : alist β, a.entries ~ b.entries → f a = f b) : γ :=\nbegin\n  refine (quotient.lift_on s.1 (λ l, (⟨_, λ nd, f ⟨l, nd⟩⟩ : roption γ))\n    (λ l₁ l₂ p, roption.ext' (perm_nodupkeys p) _) : roption γ).get _,\n  { exact λ h₁ h₂, H _ _ (by exact p) },\n  { have := s.nodupkeys, rcases s.entries with ⟨l⟩, exact id }\nend\n\n@[simp] theorem lift_on_to_finmap {γ} (s : alist β) (f : alist β → γ) (H) :\n  lift_on ⟦s⟧ f H = f s := by cases s; refl\n\n/-- Lift a permutation-respecting function on 2 `alist`s to 2 `finmap`s. -/\n@[elab_as_eliminator] def lift_on₂\n  {γ} (s₁ s₂ : finmap β) (f : alist β → alist β → γ)\n  (H : ∀ a₁ b₁ a₂ b₂ : alist β, a₁.entries ~ a₂.entries → b₁.entries ~ b₂.entries →\n    f a₁ b₁ = f a₂ b₂) : γ :=\nlift_on s₁\n  (λ l₁, lift_on s₂ (f l₁) (λ b₁ b₂ p, H _ _ _ _ (perm.refl _) p))\n  (λ a₁ a₂ p, have H' : f a₁ = f a₂ := funext (λ _, H _ _ _ _ p (perm.refl _)), by simp only [H'])\n\n@[simp] theorem lift_on₂_to_finmap {γ} (s₁ s₂ : alist β) (f : alist β → alist β → γ) (H) :\n  lift_on₂ ⟦s₁⟧ ⟦s₂⟧ f H = f s₁ s₂ :=\nby cases s₁; cases s₂; refl\n\n/-! ### induction -/\n\n@[elab_as_eliminator] theorem induction_on\n  {C : finmap β → Prop} (s : finmap β) (H : ∀ (a : alist β), C ⟦a⟧) : C s :=\nby rcases s with ⟨⟨a⟩, h⟩; exact H ⟨a, h⟩\n\n@[elab_as_eliminator] theorem induction_on₂ {C : finmap β → finmap β → Prop}\n  (s₁ s₂ : finmap β) (H : ∀ (a₁ a₂ : alist β), C ⟦a₁⟧ ⟦a₂⟧) : C s₁ s₂ :=\ninduction_on s₁ $ λ l₁, induction_on s₂ $ λ l₂, H l₁ l₂\n\n@[elab_as_eliminator] theorem induction_on₃ {C : finmap β →  finmap β → finmap β → Prop}\n  (s₁ s₂ s₃ : finmap β) (H : ∀ (a₁ a₂ a₃ : alist β), C ⟦a₁⟧ ⟦a₂⟧ ⟦a₃⟧) : C s₁ s₂ s₃ :=\ninduction_on₂ s₁ s₂ $ λ l₁ l₂, induction_on s₃ $ λ l₃, H l₁ l₂ l₃\n\n/-! ### extensionality -/\n\n@[ext] theorem ext : ∀ {s t : finmap β}, s.entries = t.entries → s = t\n| ⟨l₁, h₁⟩ ⟨l₂, h₂⟩ H := by congr'\n\n@[simp] theorem ext_iff {s t : finmap β} : s.entries = t.entries ↔ s = t :=\n⟨ext, congr_arg _⟩\n\n/-! ### mem -/\n\n/-- The predicate `a ∈ s` means that `s` has a value associated to the key `a`. -/\ninstance : has_mem α (finmap β) := ⟨λ a s, a ∈ s.entries.keys⟩\n\ntheorem mem_def {a : α} {s : finmap β} :\n  a ∈ s ↔ a ∈ s.entries.keys := iff.rfl\n\n@[simp] theorem mem_to_finmap {a : α} {s : alist β} :\n  a ∈ ⟦s⟧ ↔ a ∈ s := iff.rfl\n\n/-! ### keys -/\n\n/-- The set of keys of a finite map. -/\ndef keys (s : finmap β) : finset α :=\n⟨s.entries.keys, induction_on s keys_nodup⟩\n\n@[simp] theorem keys_val (s : alist β) : (keys ⟦s⟧).val = s.keys := rfl\n\n@[simp] theorem keys_ext {s₁ s₂ : alist β} :\n  keys ⟦s₁⟧ = keys ⟦s₂⟧ ↔ s₁.keys ~ s₂.keys :=\nby simp [keys, alist.keys]\n\ntheorem mem_keys {a : α} {s : finmap β} : a ∈ s.keys ↔ a ∈ s :=\ninduction_on s $ λ s, alist.mem_keys\n\n/-! ### empty -/\n\n/-- The empty map. -/\ninstance : has_emptyc (finmap β) := ⟨⟨0, nodupkeys_nil⟩⟩\n\ninstance : inhabited (finmap β) := ⟨∅⟩\n\n@[simp] theorem empty_to_finmap : (⟦∅⟧ : finmap β) = ∅ := rfl\n\n@[simp] theorem to_finmap_nil [decidable_eq α] : ([].to_finmap : finmap β) = ∅ := rfl\n\ntheorem not_mem_empty {a : α} : a ∉ (∅ : finmap β) :=\nmultiset.not_mem_zero a\n\n@[simp] theorem keys_empty : (∅ : finmap β).keys = ∅ := rfl\n\n/-! ### singleton -/\n\n/-- The singleton map. -/\ndef singleton (a : α) (b : β a) : finmap β := ⟦alist.singleton a b⟧\n\n@[simp] theorem keys_singleton (a : α) (b : β a) :\n  (singleton a b).keys = {a} := rfl\n\n@[simp] lemma mem_singleton (x y : α) (b : β y) : x ∈ singleton y b ↔ x = y :=\nby simp only [singleton]; erw [mem_cons_eq, mem_nil_iff, or_false]\n\nsection\n\nvariables [decidable_eq α]\n\ninstance has_decidable_eq [∀ a, decidable_eq (β a)] : decidable_eq (finmap β)\n| s₁ s₂ := decidable_of_iff _ ext_iff\n\n/-! ### lookup -/\n\n/-- Look up the value associated to a key in a map. -/\ndef lookup (a : α) (s : finmap β) : option (β a) :=\nlift_on s (lookup a) (λ s t, perm_lookup)\n\n@[simp] theorem lookup_to_finmap (a : α) (s : alist β) :\n  lookup a ⟦s⟧ = s.lookup a := rfl\n\n@[simp] theorem lookup_list_to_finmap (a : α) (s : list (sigma β)) :\n  lookup a s.to_finmap = s.lookup a :=\nby rw [list.to_finmap, lookup_to_finmap, lookup_to_alist]\n\n@[simp] theorem lookup_empty (a) : lookup a (∅ : finmap β) = none :=\nrfl\n\ntheorem lookup_is_some {a : α} {s : finmap β} :\n  (s.lookup a).is_some ↔ a ∈ s :=\ninduction_on s $ λ s, alist.lookup_is_some\n\ntheorem lookup_eq_none {a} {s : finmap β} : lookup a s = none ↔ a ∉ s :=\ninduction_on s $ λ s, alist.lookup_eq_none\n\n@[simp] lemma lookup_singleton_eq {a : α} {b : β a} : (singleton a b).lookup a = some b :=\nby rw [singleton, lookup_to_finmap, alist.singleton, alist.lookup, lookup_cons_eq]\n\ninstance (a : α) (s : finmap β) : decidable (a ∈ s) :=\ndecidable_of_iff _ lookup_is_some\n\nlemma mem_iff {a : α} {s : finmap β} : a ∈ s ↔ ∃ b, s.lookup a = some b :=\ninduction_on s $ λ s,\niff.trans list.mem_keys $ exists_congr $ λ b,\n(mem_lookup_iff s.nodupkeys).symm\n\nlemma mem_of_lookup_eq_some {a : α} {b : β a} {s : finmap β} (h : s.lookup a = some b) : a ∈ s :=\nmem_iff.mpr ⟨_, h⟩\n\ntheorem ext_lookup {s₁ s₂ : finmap β} : (∀ x, s₁.lookup x = s₂.lookup x) → s₁ = s₂ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂ h,\nbegin\n  simp only [alist.lookup, lookup_to_finmap] at h,\n  rw [alist.to_finmap_eq],\n  apply lookup_ext s₁.nodupkeys s₂.nodupkeys,\n  intros x y,\n  rw h,\nend\n\n/-! ### replace -/\n\n/-- Replace a key with a given value in a finite map.\n  If the key is not present it does nothing. -/\ndef replace (a : α) (b : β a) (s : finmap β) : finmap β :=\nlift_on s (λ t, ⟦replace a b t⟧) $\nλ s₁ s₂ p, to_finmap_eq.2 $ perm_replace p\n\n@[simp] theorem replace_to_finmap (a : α) (b : β a) (s : alist β) :\n  replace a b ⟦s⟧ = ⟦s.replace a b⟧ := by simp [replace]\n\n@[simp] theorem keys_replace (a : α) (b : β a) (s : finmap β) :\n  (replace a b s).keys = s.keys :=\ninduction_on s $ λ s, by simp\n\n@[simp] theorem mem_replace {a a' : α} {b : β a} {s : finmap β} :\n  a' ∈ replace a b s ↔ a' ∈ s :=\ninduction_on s $ λ s, by simp\n\nend\n\n/-! ### foldl -/\n\n/-- Fold a commutative function over the key-value pairs in the map -/\ndef foldl {δ : Type w} (f : δ → Π a, β a → δ)\n  (H : ∀ d a₁ b₁ a₂ b₂, f (f d a₁ b₁) a₂ b₂ = f (f d a₂ b₂) a₁ b₁)\n  (d : δ) (m : finmap β) : δ :=\nm.entries.foldl (λ d s, f d s.1 s.2) (λ d s t, H _ _ _ _ _) d\n\n/-- `any f s` returns `tt` iff there exists a value `v` in `s` such that `f v = tt`. -/\ndef any (f : Π x, β x → bool) (s : finmap β) : bool :=\ns.foldl (λ x y z, x ∨ f y z) (by { intros,  simp [or.right_comm] }) ff\n\n/-- `all f s` returns `tt` iff `f v = tt` for all values `v` in `s`. -/\ndef all (f : Π x, β x → bool) (s : finmap β) : bool :=\ns.foldl (λ x y z, x ∧ f y z) (by { intros, simp [and.right_comm] }) ff\n\n/-! ### erase -/\n\nsection\n\nvariables [decidable_eq α]\n\n/-- Erase a key from the map. If the key is not present it does nothing. -/\ndef erase (a : α) (s : finmap β) : finmap β :=\nlift_on s (λ t, ⟦erase a t⟧) $\nλ s₁ s₂ p, to_finmap_eq.2 $ perm_erase p\n\n@[simp] theorem erase_to_finmap (a : α) (s : alist β) :\n  erase a ⟦s⟧ = ⟦s.erase a⟧ := by simp [erase]\n\n@[simp] \n\n@[simp] theorem keys_erase (a : α) (s : finmap β) :\n  (erase a s).keys = s.keys.erase a :=\ninduction_on s $ λ s, by simp\n\n@[simp] theorem mem_erase {a a' : α} {s : finmap β} : a' ∈ erase a s ↔ a' ≠ a ∧ a' ∈ s :=\ninduction_on s $ λ s, by simp\n\ntheorem not_mem_erase_self {a : α} {s : finmap β} : ¬ a ∈ erase a s :=\nby rw [mem_erase, not_and_distrib, not_not]; left; refl\n\n@[simp] theorem lookup_erase (a) (s : finmap β) : lookup a (erase a s) = none :=\ninduction_on s $ lookup_erase a\n\n@[simp] theorem lookup_erase_ne {a a'} {s : finmap β} (h : a ≠ a') :\n  lookup a (erase a' s) = lookup a s :=\ninduction_on s $ λ s, lookup_erase_ne h\n\ntheorem erase_erase {a a' : α} {s : finmap β} : erase a (erase a' s) = erase a' (erase a s) :=\ninduction_on s $ λ s, ext (by simp only [erase_erase, erase_to_finmap])\n\n/-! ### sdiff -/\n\n/-- `sdiff s s'` consists of all key-value pairs from `s` and `s'` where the keys are in `s` or\n`s'` but not both. -/\ndef sdiff (s s' : finmap β) : finmap β :=\ns'.foldl (λ s x _, s.erase x) (λ a₀ a₁ _ a₂ _, erase_erase) s\n\ninstance : has_sdiff (finmap β) := ⟨sdiff⟩\n\n/-! ### insert -/\n\n/-- Insert a key-value pair into a finite map, replacing any existing pair with\n  the same key. -/\ndef insert (a : α) (b : β a) (s : finmap β) : finmap β :=\nlift_on s (λ t, ⟦insert a b t⟧) $\nλ s₁ s₂ p, to_finmap_eq.2 $ perm_insert p\n\n@[simp] theorem insert_to_finmap (a : α) (b : β a) (s : alist β) :\n  insert a b ⟦s⟧ = ⟦s.insert a b⟧ := by simp [insert]\n\ntheorem insert_entries_of_neg {a : α} {b : β a} {s : finmap β} : a ∉ s →\n  (insert a b s).entries = ⟨a, b⟩ ::ₘ s.entries :=\ninduction_on s $ λ s h,\nby simp [insert_entries_of_neg (mt mem_to_finmap.1 h)]\n\n@[simp] theorem mem_insert {a a' : α} {b' : β a'} {s : finmap β} :\n  a ∈ insert a' b' s ↔ a = a' ∨ a ∈ s :=\ninduction_on s mem_insert\n\n@[simp] theorem lookup_insert {a} {b : β a} (s : finmap β) :\n  lookup a (insert a b s) = some b :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert]\n\n@[simp] theorem lookup_insert_of_ne {a a'} {b : β a} (s : finmap β) (h : a' ≠ a) :\n  lookup a' (insert a b s) = lookup a' s :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert_ne h]\n\n@[simp] theorem insert_insert {a} {b b' : β a} (s : finmap β) :\n  (s.insert a b).insert a b' = s.insert a b' :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, insert_insert]\n\ntheorem insert_insert_of_ne {a a'} {b : β a} {b' : β a'} (s : finmap β) (h : a ≠ a') :\n  (s.insert a b).insert a' b' = (s.insert a' b').insert a b :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, alist.to_finmap_eq, insert_insert_of_ne _ h]\n\ntheorem to_finmap_cons (a : α) (b : β a) (xs : list (sigma β)) :\n  list.to_finmap (⟨a,b⟩ :: xs) = insert a b xs.to_finmap := rfl\n\ntheorem mem_list_to_finmap (a : α) (xs : list (sigma β)) :\n  a ∈ xs.to_finmap ↔ (∃ b : β a, sigma.mk a b ∈ xs) :=\nby { induction xs with x xs; [skip, cases x];\n     simp only [to_finmap_cons, *, not_mem_empty, exists_or_distrib, not_mem_nil, to_finmap_nil,\n                exists_false, mem_cons_iff, mem_insert, exists_and_distrib_left];\n     apply or_congr _ iff.rfl,\n     conv { to_lhs, rw ← and_true (a = x_fst) },\n     apply and_congr_right, rintro ⟨⟩, simp only [exists_eq, iff_self, heq_iff_eq] }\n\n@[simp] theorem insert_singleton_eq {a : α} {b b' : β a} :\n  insert a b (singleton a b') = singleton a b :=\nby simp only [singleton, finmap.insert_to_finmap, alist.insert_singleton_eq]\n\n/-! ### extract -/\n\n/-- Erase a key from the map, and return the corresponding value, if found. -/\ndef extract (a : α) (s : finmap β) : option (β a) × finmap β :=\nlift_on s (λ t, prod.map id to_finmap (extract a t)) $\nλ s₁ s₂ p, by simp [perm_lookup p, to_finmap_eq, perm_erase p]\n\n@[simp] theorem extract_eq_lookup_erase (a : α) (s : finmap β) :\n  extract a s = (lookup a s, erase a s) :=\ninduction_on s $ λ s, by simp [extract]\n\n/-! ### union -/\n\n/-- `s₁ ∪ s₂` is the key-based union of two finite maps. It is left-biased: if\nthere exists an `a ∈ s₁`, `lookup a (s₁ ∪ s₂) = lookup a s₁`. -/\ndef union (s₁ s₂ : finmap β) : finmap β :=\nlift_on₂ s₁ s₂ (λ s₁ s₂, ⟦s₁ ∪ s₂⟧) $\nλ s₁ s₂ s₃ s₄ p₁₃ p₂₄, to_finmap_eq.mpr $ perm_union p₁₃ p₂₄\n\ninstance : has_union (finmap β) := ⟨union⟩\n\n@[simp] theorem mem_union {a} {s₁ s₂ : finmap β} :\n  a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂ :=\ninduction_on₂ s₁ s₂ $ λ _ _, mem_union\n\n@[simp] theorem union_to_finmap (s₁ s₂ : alist β) : ⟦s₁⟧ ∪ ⟦s₂⟧ = ⟦s₁ ∪ s₂⟧ :=\nby simp [(∪), union]\n\ntheorem keys_union {s₁ s₂ : finmap β} : (s₁ ∪ s₂).keys = s₁.keys ∪ s₂.keys :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, finset.ext $ by simp [keys]\n\n@[simp] theorem lookup_union_left {a} {s₁ s₂ : finmap β} :\n  a ∈ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₁ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, lookup_union_left\n\n@[simp] theorem lookup_union_right {a} {s₁ s₂ : finmap β} :\n  a ∉ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₂ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, lookup_union_right\n\ntheorem lookup_union_left_of_not_in {a} {s₁ s₂ : finmap β} (h : a ∉ s₂) :\n  lookup a (s₁ ∪ s₂) = lookup a s₁ :=\nbegin\n  by_cases h' : a ∈ s₁,\n  { rw lookup_union_left h' },\n  { rw [lookup_union_right h', lookup_eq_none.mpr h, lookup_eq_none.mpr h'] }\nend\n\n@[simp] theorem mem_lookup_union {a} {b : β a} {s₁ s₂ : finmap β} :\n  b ∈ lookup a (s₁ ∪ s₂) ↔ b ∈ lookup a s₁ ∨ a ∉ s₁ ∧ b ∈ lookup a s₂ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, mem_lookup_union\n\ntheorem mem_lookup_union_middle {a} {b : β a} {s₁ s₂ s₃ : finmap β} :\n  b ∈ lookup a (s₁ ∪ s₃) → a ∉ s₂ → b ∈ lookup a (s₁ ∪ s₂ ∪ s₃) :=\ninduction_on₃ s₁ s₂ s₃ $ λ s₁ s₂ s₃, mem_lookup_union_middle\n\ntheorem insert_union {a} {b : β a} {s₁ s₂ : finmap β} :\n  insert a b (s₁ ∪ s₂) = insert a b s₁ ∪ s₂ :=\ninduction_on₂ s₁ s₂ $ λ a₁ a₂, by simp [insert_union]\n\ntheorem union_assoc {s₁ s₂ s₃ : finmap β} : (s₁ ∪ s₂) ∪ s₃ = s₁ ∪ (s₂ ∪ s₃) :=\ninduction_on₃ s₁ s₂ s₃ $ λ s₁ s₂ s₃,\nby simp only [alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\n@[simp] theorem empty_union {s₁ : finmap β} : ∅ ∪ s₁ = s₁ :=\ninduction_on s₁ $ λ s₁, by rw ← empty_to_finmap;\n  simp [- empty_to_finmap, alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\n@[simp] theorem union_empty {s₁ : finmap β} : s₁ ∪ ∅ = s₁ :=\ninduction_on s₁ $ λ s₁, by rw ← empty_to_finmap;\n  simp [- empty_to_finmap, alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\ntheorem erase_union_singleton (a : α) (b : β a) (s : finmap β) (h : s.lookup a = some b) :\n  s.erase a ∪ singleton a b = s :=\next_lookup\n(λ x, by { by_cases h' : x = a,\n      { subst a, rw [lookup_union_right not_mem_erase_self, lookup_singleton_eq, h], },\n      { have : x ∉ singleton a b, { rwa mem_singleton },\n        rw [lookup_union_left_of_not_in this, lookup_erase_ne h'] } } )\n\nend\n\n/-! ### disjoint -/\n\n/-- `disjoint s₁ s₂` holds if `s₁` and `s₂` have no keys in common. -/\ndef disjoint (s₁ s₂ : finmap β) : Prop :=\n∀ x ∈ s₁, ¬ x ∈ s₂\n\nlemma disjoint_empty (x : finmap β) : disjoint ∅ x .\n\n@[symm]\nlemma disjoint.symm (x y : finmap β) (h : disjoint x y) : disjoint y x :=\nλ p hy hx, h p hx hy\n\nlemma disjoint.symm_iff (x y : finmap β) : disjoint x y ↔ disjoint y x :=\n⟨disjoint.symm x y, disjoint.symm y x⟩\n\nsection\n\nvariables [decidable_eq α]\n\ninstance : decidable_rel (@disjoint α β) :=\nλ x y, by dsimp only [disjoint]; apply_instance\n\nlemma disjoint_union_left (x y z : finmap β) : disjoint (x ∪ y) z ↔ disjoint x z ∧ disjoint y z :=\nby simp [disjoint, finmap.mem_union, or_imp_distrib, forall_and_distrib]\n\nlemma disjoint_union_right (x y z : finmap β) : disjoint x (y ∪ z) ↔ disjoint x y ∧ disjoint x z :=\nby rw [disjoint.symm_iff, disjoint_union_left, disjoint.symm_iff _ x, disjoint.symm_iff _ x]\n\ntheorem union_comm_of_disjoint {s₁ s₂ : finmap β} : disjoint s₁ s₂ → s₁ ∪ s₂ = s₂ ∪ s₁ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂,\nby { intros h, simp only [alist.to_finmap_eq, union_to_finmap, alist.union_comm_of_disjoint h] }\n\ntheorem union_cancel {s₁ s₂ s₃ : finmap β} (h : disjoint s₁ s₃) (h' : disjoint s₂ s₃) :\n  s₁ ∪ s₃ = s₂ ∪ s₃ ↔ s₁ = s₂ :=\n⟨λ h'', begin\n          apply ext_lookup, intro x,\n          have : (s₁ ∪ s₃).lookup x = (s₂ ∪ s₃).lookup x, from h'' ▸ rfl,\n          by_cases hs₁ : x ∈ s₁,\n          { rwa [lookup_union_left hs₁, lookup_union_left_of_not_in (h _ hs₁)] at this, },\n          { by_cases hs₂ : x ∈ s₂,\n            { rwa [lookup_union_left_of_not_in (h' _ hs₂), lookup_union_left hs₂] at this, },\n            { rw [lookup_eq_none.mpr hs₁, lookup_eq_none.mpr hs₂] } }\n        end,\n λ h, h ▸ rfl⟩\n\nend\n\nend finmap\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/finmap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.74316801430083, "lm_q1q2_score": 0.4840660913197429}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yury Kudryashov\n\n! This file was ported from Lean 3 source module measure_theory.constructions.borel_space\n! leanprover-community/mathlib commit fbde2f60a46865c85f49b4193175c6e339ff9020\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.Complex.Basic\nimport Mathbin.Analysis.NormedSpace.FiniteDimension\nimport Mathbin.MeasureTheory.Function.AeMeasurableSequence\nimport Mathbin.MeasureTheory.Group.Arithmetic\nimport Mathbin.MeasureTheory.Lattice\nimport Mathbin.MeasureTheory.Measure.OpenPos\nimport Mathbin.Topology.Algebra.Order.LiminfLimsup\nimport Mathbin.Topology.ContinuousFunction.Basic\nimport Mathbin.Topology.Instances.AddCircle\nimport Mathbin.Topology.Instances.Ereal\nimport Mathbin.Topology.GDelta\nimport Mathbin.Topology.Order.Lattice\nimport Mathbin.Topology.Semicontinuous\nimport Mathbin.Topology.MetricSpace.Metrizable\n\n/-!\n# Borel (measurable) space\n\n## Main definitions\n\n* `borel α` : the least `σ`-algebra that contains all open sets;\n* `class borel_space` : a space with `topological_space` and `measurable_space` structures\n  such that `‹measurable_space α› = borel α`;\n* `class opens_measurable_space` : a space with `topological_space` and `measurable_space`\n  structures such that all open sets are measurable; equivalently, `borel α ≤ ‹measurable_space α›`.\n* `borel_space` instances on `empty`, `unit`, `bool`, `nat`, `int`, `rat`;\n* `measurable` and `borel_space` instances on `ℝ`, `ℝ≥0`, `ℝ≥0∞`.\n\n## Main statements\n\n* `is_open.measurable_set`, `is_closed.measurable_set`: open and closed sets are measurable;\n* `continuous.measurable` : a continuous function is measurable;\n* `continuous.measurable2` : if `f : α → β` and `g : α → γ` are measurable and `op : β × γ → δ`\n  is continuous, then `λ x, op (f x, g y)` is measurable;\n* `measurable.add` etc : dot notation for arithmetic operations on `measurable` predicates,\n  and similarly for `dist` and `edist`;\n* `ae_measurable.add` : similar dot notation for almost everywhere measurable functions;\n* `measurable.ennreal*` : special cases for arithmetic operations on `ℝ≥0∞`.\n-/\n\n\nnoncomputable section\n\nopen Classical Set Filter MeasureTheory\n\nopen Classical BigOperators Topology NNReal ENNReal MeasureTheory\n\nuniverse u v w x y\n\nvariable {α β γ γ₂ δ : Type _} {ι : Sort y} {s t u : Set α}\n\nopen MeasurableSpace TopologicalSpace\n\n/-- `measurable_space` structure generated by `topological_space`. -/\ndef borel (α : Type u) [TopologicalSpace α] : MeasurableSpace α :=\n  generateFrom { s : Set α | IsOpen s }\n#align borel borel\n\ntheorem borel_eq_top_of_discrete [TopologicalSpace α] [DiscreteTopology α] : borel α = ⊤ :=\n  top_le_iff.1 fun s hs => GenerateMeasurable.basic s (isOpen_discrete s)\n#align borel_eq_top_of_discrete borel_eq_top_of_discrete\n\ntheorem borel_eq_top_of_countable [TopologicalSpace α] [T1Space α] [Countable α] : borel α = ⊤ :=\n  by\n  refine' top_le_iff.1 fun s hs => bUnion_of_singleton s ▸ _\n  apply MeasurableSet.bunionᵢ s.to_countable\n  intro x hx\n  apply MeasurableSet.of_compl\n  apply generate_measurable.basic\n  exact is_closed_singleton.is_open_compl\n#align borel_eq_top_of_countable borel_eq_top_of_countable\n\ntheorem borel_eq_generateFrom_of_subbasis {s : Set (Set α)} [t : TopologicalSpace α]\n    [SecondCountableTopology α] (hs : t = generateFrom s) : borel α = generateFrom s :=\n  le_antisymm\n    (generateFrom_le fun u (hu : t.IsOpen u) =>\n      by\n      rw [hs] at hu\n      induction hu\n      case basic u hu => exact generate_measurable.basic u hu\n      case univ => exact @MeasurableSet.univ α (generate_from s)\n      case inter s₁ s₂ _ _ hs₁ hs₂ => exact @MeasurableSet.inter α (generate_from s) _ _ hs₁ hs₂\n      case\n        sUnion f hf ih =>\n        rcases is_open_sUnion_countable f (by rwa [hs]) with ⟨v, hv, vf, vu⟩\n        rw [← vu]\n        exact @MeasurableSet.unionₛ α (generate_from s) _ hv fun x xv => ih _ (vf xv))\n    (generateFrom_le fun u hu =>\n      GenerateMeasurable.basic _ <| show t.IsOpen u by rw [hs] <;> exact generate_open.basic _ hu)\n#align borel_eq_generate_from_of_subbasis borel_eq_generateFrom_of_subbasis\n\ntheorem TopologicalSpace.IsTopologicalBasis.borel_eq_generateFrom [TopologicalSpace α]\n    [SecondCountableTopology α] {s : Set (Set α)} (hs : IsTopologicalBasis s) :\n    borel α = generateFrom s :=\n  borel_eq_generateFrom_of_subbasis hs.eq_generateFrom\n#align topological_space.is_topological_basis.borel_eq_generate_from TopologicalSpace.IsTopologicalBasis.borel_eq_generateFrom\n\ntheorem isPiSystem_isOpen [TopologicalSpace α] : IsPiSystem (IsOpen : Set α → Prop) :=\n  fun s hs t ht hst => IsOpen.inter hs ht\n#align is_pi_system_is_open isPiSystem_isOpen\n\ntheorem borel_eq_generateFrom_isClosed [TopologicalSpace α] :\n    borel α = generateFrom { s | IsClosed s } :=\n  le_antisymm\n    (generateFrom_le fun t ht =>\n      @MeasurableSet.of_compl α _ (generateFrom { s | IsClosed s })\n        (GenerateMeasurable.basic _ <| isClosed_compl_iff.2 ht))\n    (generateFrom_le fun t ht =>\n      @MeasurableSet.of_compl α _ (borel α) (GenerateMeasurable.basic _ <| isOpen_compl_iff.2 ht))\n#align borel_eq_generate_from_is_closed borel_eq_generateFrom_isClosed\n\nsection OrderTopology\n\nvariable (α)\n\nvariable [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α]\n\ntheorem borel_eq_generateFrom_Iio : borel α = generateFrom (range Iio) :=\n  by\n  refine' le_antisymm _ (generate_from_le _)\n  · rw [borel_eq_generateFrom_of_subbasis (@OrderTopology.topology_eq_generate_intervals α _ _ _)]\n    letI : MeasurableSpace α := MeasurableSpace.generateFrom (range Iio)\n    have H : ∀ a : α, MeasurableSet (Iio a) := fun a => generate_measurable.basic _ ⟨_, rfl⟩\n    refine' generate_from_le _\n    rintro _ ⟨a, rfl | rfl⟩ <;> [skip, apply H]\n    by_cases h : ∃ a', ∀ b, a < b ↔ a' ≤ b\n    · rcases h with ⟨a', ha'⟩\n      rw [(_ : Ioi a = Iio a'ᶜ)]\n      · exact (H _).compl\n      simp [Set.ext_iff, ha']\n    · rcases is_open_Union_countable (fun a' : { a' : α // a < a' } => { b | a'.1 < b }) fun a' =>\n          isOpen_lt' _ with ⟨v, ⟨hv⟩, vu⟩\n      simp [Set.ext_iff] at vu\n      have : Ioi a = ⋃ x : v, Iio x.1.1ᶜ :=\n        by\n        simp [Set.ext_iff]\n        refine' fun x => ⟨fun ax => _, fun ⟨a', ⟨h, av⟩, ax⟩ => lt_of_lt_of_le h ax⟩\n        rcases(vu x).2 _ with ⟨a', h₁, h₂⟩\n        · exact ⟨a', h₁, le_of_lt h₂⟩\n        refine' not_imp_comm.1 (fun h => _) h\n        exact ⟨x, fun b => ⟨fun ab => le_of_not_lt fun h' => h ⟨b, ab, h'⟩, lt_of_lt_of_le ax⟩⟩\n      rw [this]\n      skip\n      apply MeasurableSet.unionᵢ\n      exact fun _ => (H _).compl\n  · rw [forall_range_iff]\n    intro a\n    exact generate_measurable.basic _ isOpen_Iio\n#align borel_eq_generate_from_Iio borel_eq_generateFrom_Iio\n\ntheorem borel_eq_generateFrom_Ioi : borel α = generateFrom (range Ioi) :=\n  @borel_eq_generateFrom_Iio αᵒᵈ _ (by infer_instance : SecondCountableTopology α) _ _\n#align borel_eq_generate_from_Ioi borel_eq_generateFrom_Ioi\n\nend OrderTopology\n\ntheorem borel_comap {f : α → β} {t : TopologicalSpace β} :\n    @borel α (t.induced f) = (@borel β t).comap f :=\n  comap_generateFrom.symm\n#align borel_comap borel_comap\n\ntheorem Continuous.borel_measurable [TopologicalSpace α] [TopologicalSpace β] {f : α → β}\n    (hf : Continuous f) : @Measurable α β (borel α) (borel β) f :=\n  Measurable.of_le_map <|\n    generateFrom_le fun s hs => GenerateMeasurable.basic (f ⁻¹' s) (hs.Preimage hf)\n#align continuous.borel_measurable Continuous.borel_measurable\n\n/-- A space with `measurable_space` and `topological_space` structures such that\nall open sets are measurable. -/\nclass OpensMeasurableSpace (α : Type _) [TopologicalSpace α] [h : MeasurableSpace α] : Prop where\n  borel_le : borel α ≤ h\n#align opens_measurable_space OpensMeasurableSpace\n\n/-- A space with `measurable_space` and `topological_space` structures such that\nthe `σ`-algebra of measurable sets is exactly the `σ`-algebra generated by open sets. -/\nclass BorelSpace (α : Type _) [TopologicalSpace α] [MeasurableSpace α] : Prop where\n  measurable_eq : ‹MeasurableSpace α› = borel α\n#align borel_space BorelSpace\n\nnamespace Tactic\n\n/-- Add instances `borel α : measurable_space α` and `⟨rfl⟩ : borel_space α`. -/\nunsafe def add_borel_instance (α : expr) : tactic Unit := do\n  let n1 ← get_unused_name \"_inst\"\n  to_expr ``(borel $(α)) >>= pose n1\n  reset_instance_cache\n  let n2 ← get_unused_name \"_inst\"\n  let v ← to_expr ``((BorelSpace.mk rfl : BorelSpace $(α)))\n  note n2 none v\n  reset_instance_cache\n#align tactic.add_borel_instance tactic.add_borel_instance\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/--\n      Given a type `α`, an assumption `i : measurable_space α`, and an instance `[borel_space α]`,\n      replace `i` with `borel α`. -/\n    unsafe\n  def\n    borel_to_refl\n    ( α i : expr ) : tactic Unit\n    :=\n      do\n        let n ← get_unused_name \"h\"\n          to_expr ` `( $ ( i ) = borel $ ( α ) ) >>= assert n\n          applyc `borel_space.measurable_eq\n          unfreezing ( tactic.subst i )\n          let n1 ← get_unused_name \"_inst\"\n          to_expr ` `( borel $ ( α ) ) >>= pose n1\n          reset_instance_cache\n#align tactic.borel_to_refl tactic.borel_to_refl\n\n/-- Given a type `α`, if there is an assumption `[i : measurable_space α]`, then try to prove\n`[borel_space α]` and replace `i` with `borel α`. Otherwise, add instances\n`borel α : measurable_space α` and `⟨rfl⟩ : borel_space α`. -/\nunsafe def borelize (α : expr) : tactic Unit := do\n  let i ← optional (to_expr ``(MeasurableSpace $(α)) >>= find_assumption)\n  i (add_borel_instance α) (borel_to_refl α)\n#align tactic.borelize tactic.borelize\n\nnamespace Interactive\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\n/-- The behaviour of `borelize α` depends on the existing assumptions on `α`.\n\n- if `α` is a topological space with instances `[measurable_space α] [borel_space α]`, then\n  `borelize α` replaces the former instance by `borel α`;\n- otherwise, `borelize α` adds instances `borel α : measurable_space α` and `⟨rfl⟩ : borel_space α`.\n\nFinally, `borelize [α, β, γ]` runs `borelize α, borelize β, borelize γ`.\n-/\nunsafe def borelize (ts : parse pexpr_list_or_texpr) : tactic Unit :=\n  mapM' (fun t => to_expr t >>= tactic.borelize) ts\n#align tactic.interactive.borelize tactic.interactive.borelize\n\nadd_tactic_doc\n  { Name := \"borelize\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.borelize]\n    tags := [\"type class\"] }\n\nend Interactive\n\nend Tactic\n\ninstance (priority := 100) OrderDual.opensMeasurableSpace {α : Type _} [TopologicalSpace α]\n    [MeasurableSpace α] [h : OpensMeasurableSpace α] : OpensMeasurableSpace αᵒᵈ\n    where borel_le := h.borel_le\n#align order_dual.opens_measurable_space OrderDual.opensMeasurableSpace\n\ninstance (priority := 100) OrderDual.borelSpace {α : Type _} [TopologicalSpace α]\n    [MeasurableSpace α] [h : BorelSpace α] : BorelSpace αᵒᵈ where measurable_eq := h.measurable_eq\n#align order_dual.borel_space OrderDual.borelSpace\n\n/-- In a `borel_space` all open sets are measurable. -/\ninstance (priority := 100) BorelSpace.opens_measurable {α : Type _} [TopologicalSpace α]\n    [MeasurableSpace α] [BorelSpace α] : OpensMeasurableSpace α :=\n  ⟨ge_of_eq <| BorelSpace.measurable_eq⟩\n#align borel_space.opens_measurable BorelSpace.opens_measurable\n\ninstance Subtype.borelSpace {α : Type _} [TopologicalSpace α] [MeasurableSpace α]\n    [hα : BorelSpace α] (s : Set α) : BorelSpace s :=\n  ⟨by\n    rw [hα.1, Subtype.measurableSpace, ← borel_comap]\n    rfl⟩\n#align subtype.borel_space Subtype.borelSpace\n\ninstance Subtype.opensMeasurableSpace {α : Type _} [TopologicalSpace α] [MeasurableSpace α]\n    [h : OpensMeasurableSpace α] (s : Set α) : OpensMeasurableSpace s :=\n  ⟨by\n    rw [borel_comap]\n    exact comap_mono h.1⟩\n#align subtype.opens_measurable_space Subtype.opensMeasurableSpace\n\ntheorem MeasurableSet.induction_on_open [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α]\n    {C : Set α → Prop} (h_open : ∀ U, IsOpen U → C U)\n    (h_compl : ∀ t, MeasurableSet t → C t → C (tᶜ))\n    (h_union :\n      ∀ f : ℕ → Set α,\n        Pairwise (Disjoint on f) → (∀ i, MeasurableSet (f i)) → (∀ i, C (f i)) → C (⋃ i, f i)) :\n    ∀ ⦃t⦄, MeasurableSet t → C t :=\n  MeasurableSpace.induction_on_inter BorelSpace.measurable_eq isPiSystem_isOpen\n    (h_open _ isOpen_empty) h_open h_compl h_union\n#align measurable_set.induction_on_open MeasurableSet.induction_on_open\n\nsection\n\nvariable [TopologicalSpace α] [MeasurableSpace α] [OpensMeasurableSpace α] [TopologicalSpace β]\n  [MeasurableSpace β] [OpensMeasurableSpace β] [TopologicalSpace γ] [MeasurableSpace γ]\n  [BorelSpace γ] [TopologicalSpace γ₂] [MeasurableSpace γ₂] [BorelSpace γ₂] [MeasurableSpace δ]\n\ntheorem IsOpen.measurableSet (h : IsOpen s) : MeasurableSet s :=\n  OpensMeasurableSpace.borel_le _ <| GenerateMeasurable.basic _ h\n#align is_open.measurable_set IsOpen.measurableSet\n\n@[measurability]\ntheorem measurableSet_interior : MeasurableSet (interior s) :=\n  isOpen_interior.MeasurableSet\n#align measurable_set_interior measurableSet_interior\n\ntheorem IsGδ.measurableSet (h : IsGδ s) : MeasurableSet s :=\n  by\n  rcases h with ⟨S, hSo, hSc, rfl⟩\n  exact MeasurableSet.interₛ hSc fun t ht => (hSo t ht).MeasurableSet\n#align is_Gδ.measurable_set IsGδ.measurableSet\n\ntheorem measurableSet_of_continuousAt {β} [EMetricSpace β] (f : α → β) :\n    MeasurableSet { x | ContinuousAt f x } :=\n  (isGδ_setOf_continuousAt f).MeasurableSet\n#align measurable_set_of_continuous_at measurableSet_of_continuousAt\n\ntheorem IsClosed.measurableSet (h : IsClosed s) : MeasurableSet s :=\n  h.isOpen_compl.MeasurableSet.ofCompl\n#align is_closed.measurable_set IsClosed.measurableSet\n\ntheorem IsCompact.measurableSet [T2Space α] (h : IsCompact s) : MeasurableSet s :=\n  h.IsClosed.MeasurableSet\n#align is_compact.measurable_set IsCompact.measurableSet\n\n@[measurability]\ntheorem measurableSet_closure : MeasurableSet (closure s) :=\n  isClosed_closure.MeasurableSet\n#align measurable_set_closure measurableSet_closure\n\ntheorem measurable_of_isOpen {f : δ → γ} (hf : ∀ s, IsOpen s → MeasurableSet (f ⁻¹' s)) :\n    Measurable f := by\n  rw [‹BorelSpace γ›.measurable_eq]\n  exact measurable_generateFrom hf\n#align measurable_of_is_open measurable_of_isOpen\n\ntheorem measurable_of_isClosed {f : δ → γ} (hf : ∀ s, IsClosed s → MeasurableSet (f ⁻¹' s)) :\n    Measurable f := by\n  apply measurable_of_isOpen; intro s hs\n  rw [← MeasurableSet.compl_iff, ← preimage_compl]; apply hf; rw [isClosed_compl_iff]; exact hs\n#align measurable_of_is_closed measurable_of_isClosed\n\ntheorem measurable_of_is_closed' {f : δ → γ}\n    (hf : ∀ s, IsClosed s → s.Nonempty → s ≠ univ → MeasurableSet (f ⁻¹' s)) : Measurable f :=\n  by\n  apply measurable_of_isClosed; intro s hs\n  cases' eq_empty_or_nonempty s with h1 h1; · simp [h1]\n  by_cases h2 : s = univ; · simp [h2]\n  exact hf s hs h1 h2\n#align measurable_of_is_closed' measurable_of_is_closed'\n\ninstance nhds_isMeasurablyGenerated (a : α) : (𝓝 a).IsMeasurablyGenerated :=\n  by\n  rw [nhds, infᵢ_subtype']\n  refine' @Filter.infᵢ_isMeasurablyGenerated _ _ _ _ fun i => _\n  exact i.2.2.MeasurableSet.principal_isMeasurablyGenerated\n#align nhds_is_measurably_generated nhds_isMeasurablyGenerated\n\n/-- If `s` is a measurable set, then `𝓝[s] a` is a measurably generated filter for\neach `a`. This cannot be an `instance` because it depends on a non-instance `hs : measurable_set s`.\n-/\ntheorem MeasurableSet.nhdsWithin_isMeasurablyGenerated {s : Set α} (hs : MeasurableSet s) (a : α) :\n    (𝓝[s] a).IsMeasurablyGenerated :=\n  haveI := hs.principal_is_measurably_generated\n  Filter.inf_isMeasurablyGenerated _ _\n#align measurable_set.nhds_within_is_measurably_generated MeasurableSet.nhdsWithin_isMeasurablyGenerated\n\n-- see Note [lower instance priority]\ninstance (priority := 100) OpensMeasurableSpace.to_measurableSingletonClass [T1Space α] :\n    MeasurableSingletonClass α :=\n  ⟨fun x => isClosed_singleton.MeasurableSet⟩\n#align opens_measurable_space.to_measurable_singleton_class OpensMeasurableSpace.to_measurableSingletonClass\n\ninstance Pi.opensMeasurableSpace {ι : Type _} {π : ι → Type _} [Countable ι]\n    [t' : ∀ i, TopologicalSpace (π i)] [∀ i, MeasurableSpace (π i)]\n    [∀ i, SecondCountableTopology (π i)] [∀ i, OpensMeasurableSpace (π i)] :\n    OpensMeasurableSpace (∀ i, π i) := by\n  constructor\n  have :\n    Pi.topologicalSpace =\n      generate_from\n        { t |\n          ∃ (s : ∀ a, Set (π a))(i : Finset ι),\n            (∀ a ∈ i, s a ∈ countable_basis (π a)) ∧ t = pi (↑i) s } :=\n    by rw [funext fun a => @eq_generate_from_countable_basis (π a) _ _, pi_generateFrom_eq]\n  rw [borel_eq_generateFrom_of_subbasis this]\n  apply generate_from_le\n  rintro _ ⟨s, i, hi, rfl⟩\n  refine' MeasurableSet.pi i.countable_to_set fun a ha => IsOpen.measurableSet _\n  rw [eq_generate_from_countable_basis (π a)]\n  exact generate_open.basic _ (hi a ha)\n#align pi.opens_measurable_space Pi.opensMeasurableSpace\n\ninstance Prod.opensMeasurableSpace [SecondCountableTopology α] [SecondCountableTopology β] :\n    OpensMeasurableSpace (α × β) := by\n  constructor\n  rw [((is_basis_countable_basis α).Prod (is_basis_countable_basis β)).borel_eq_generateFrom]\n  apply generate_from_le\n  rintro _ ⟨u, v, hu, hv, rfl⟩\n  exact\n    (is_open_of_mem_countable_basis hu).MeasurableSet.Prod\n      (is_open_of_mem_countable_basis hv).MeasurableSet\n#align prod.opens_measurable_space Prod.opensMeasurableSpace\n\nvariable {α' : Type _} [TopologicalSpace α'] [MeasurableSpace α']\n\ntheorem interior_ae_eq_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) :\n    interior s =ᵐ[μ] s :=\n  interior_subset.EventuallyLE.antisymm <| subset_closure.EventuallyLE.trans (ae_le_set.2 h)\n#align interior_ae_eq_of_null_frontier interior_ae_eq_of_null_frontier\n\ntheorem measure_interior_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) :\n    μ (interior s) = μ s :=\n  measure_congr (interior_ae_eq_of_null_frontier h)\n#align measure_interior_of_null_frontier measure_interior_of_null_frontier\n\ntheorem nullMeasurableSetOfNullFrontier {s : Set α} {μ : Measure α} (h : μ (frontier s) = 0) :\n    NullMeasurableSet s μ :=\n  ⟨interior s, isOpen_interior.MeasurableSet, (interior_ae_eq_of_null_frontier h).symm⟩\n#align null_measurable_set_of_null_frontier nullMeasurableSetOfNullFrontier\n\ntheorem closure_ae_eq_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) :\n    closure s =ᵐ[μ] s :=\n  ((ae_le_set.2 h).trans interior_subset.EventuallyLE).antisymm <| subset_closure.EventuallyLE\n#align closure_ae_eq_of_null_frontier closure_ae_eq_of_null_frontier\n\ntheorem measure_closure_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) :\n    μ (closure s) = μ s :=\n  measure_congr (closure_ae_eq_of_null_frontier h)\n#align measure_closure_of_null_frontier measure_closure_of_null_frontier\n\nsection Preorder\n\nvariable [Preorder α] [OrderClosedTopology α] {a b x : α}\n\n@[simp, measurability]\ntheorem measurableSet_Ici : MeasurableSet (Ici a) :=\n  isClosed_Ici.MeasurableSet\n#align measurable_set_Ici measurableSet_Ici\n\n@[simp, measurability]\ntheorem measurableSet_Iic : MeasurableSet (Iic a) :=\n  isClosed_Iic.MeasurableSet\n#align measurable_set_Iic measurableSet_Iic\n\n@[simp, measurability]\ntheorem measurableSet_Icc : MeasurableSet (Icc a b) :=\n  isClosed_Icc.MeasurableSet\n#align measurable_set_Icc measurableSet_Icc\n\ninstance nhdsWithin_Ici_isMeasurablyGenerated : (𝓝[Ici b] a).IsMeasurablyGenerated :=\n  measurableSet_Ici.nhdsWithin_isMeasurablyGenerated _\n#align nhds_within_Ici_is_measurably_generated nhdsWithin_Ici_isMeasurablyGenerated\n\ninstance nhdsWithin_Iic_isMeasurablyGenerated : (𝓝[Iic b] a).IsMeasurablyGenerated :=\n  measurableSet_Iic.nhdsWithin_isMeasurablyGenerated _\n#align nhds_within_Iic_is_measurably_generated nhdsWithin_Iic_isMeasurablyGenerated\n\ninstance nhdsWithin_Icc_isMeasurablyGenerated : IsMeasurablyGenerated (𝓝[Icc a b] x) :=\n  by\n  rw [← Ici_inter_Iic, nhdsWithin_inter]\n  infer_instance\n#align nhds_within_Icc_is_measurably_generated nhdsWithin_Icc_isMeasurablyGenerated\n\ninstance atTop_isMeasurablyGenerated : (Filter.atTop : Filter α).IsMeasurablyGenerated :=\n  @Filter.infᵢ_isMeasurablyGenerated _ _ _ _ fun a =>\n    (measurableSet_Ici : MeasurableSet (Ici a)).principal_isMeasurablyGenerated\n#align at_top_is_measurably_generated atTop_isMeasurablyGenerated\n\ninstance atBot_isMeasurablyGenerated : (Filter.atBot : Filter α).IsMeasurablyGenerated :=\n  @Filter.infᵢ_isMeasurablyGenerated _ _ _ _ fun a =>\n    (measurableSet_Iic : MeasurableSet (Iic a)).principal_isMeasurablyGenerated\n#align at_bot_is_measurably_generated atBot_isMeasurablyGenerated\n\nend Preorder\n\nsection PartialOrder\n\nvariable [PartialOrder α] [OrderClosedTopology α] [SecondCountableTopology α] {a b : α}\n\n@[measurability]\ntheorem measurableSet_le' : MeasurableSet { p : α × α | p.1 ≤ p.2 } :=\n  OrderClosedTopology.isClosed_le'.MeasurableSet\n#align measurable_set_le' measurableSet_le'\n\n@[measurability]\ntheorem measurableSet_le {f g : δ → α} (hf : Measurable f) (hg : Measurable g) :\n    MeasurableSet { a | f a ≤ g a } :=\n  hf.prod_mk hg measurableSet_le'\n#align measurable_set_le measurableSet_le\n\nend PartialOrder\n\nsection LinearOrder\n\nvariable [LinearOrder α] [OrderClosedTopology α] {a b x : α}\n\n-- we open this locale only here to avoid issues with list being treated as intervals above\nopen Interval\n\n@[simp, measurability]\ntheorem measurableSet_Iio : MeasurableSet (Iio a) :=\n  isOpen_Iio.MeasurableSet\n#align measurable_set_Iio measurableSet_Iio\n\n@[simp, measurability]\ntheorem measurableSet_Ioi : MeasurableSet (Ioi a) :=\n  isOpen_Ioi.MeasurableSet\n#align measurable_set_Ioi measurableSet_Ioi\n\n@[simp, measurability]\ntheorem measurableSet_Ioo : MeasurableSet (Ioo a b) :=\n  isOpen_Ioo.MeasurableSet\n#align measurable_set_Ioo measurableSet_Ioo\n\n@[simp, measurability]\ntheorem measurableSet_Ioc : MeasurableSet (Ioc a b) :=\n  measurableSet_Ioi.inter measurableSet_Iic\n#align measurable_set_Ioc measurableSet_Ioc\n\n@[simp, measurability]\ntheorem measurableSet_Ico : MeasurableSet (Ico a b) :=\n  measurableSet_Ici.inter measurableSet_Iio\n#align measurable_set_Ico measurableSet_Ico\n\ninstance nhdsWithin_Ioi_isMeasurablyGenerated : (𝓝[Ioi b] a).IsMeasurablyGenerated :=\n  measurableSet_Ioi.nhdsWithin_isMeasurablyGenerated _\n#align nhds_within_Ioi_is_measurably_generated nhdsWithin_Ioi_isMeasurablyGenerated\n\ninstance nhdsWithin_Iio_isMeasurablyGenerated : (𝓝[Iio b] a).IsMeasurablyGenerated :=\n  measurableSet_Iio.nhdsWithin_isMeasurablyGenerated _\n#align nhds_within_Iio_is_measurably_generated nhdsWithin_Iio_isMeasurablyGenerated\n\ninstance nhdsWithin_uIcc_isMeasurablyGenerated : IsMeasurablyGenerated (𝓝[[a, b]] x) :=\n  nhdsWithin_Icc_isMeasurablyGenerated\n#align nhds_within_uIcc_is_measurably_generated nhdsWithin_uIcc_isMeasurablyGenerated\n\n@[measurability]\ntheorem measurableSet_lt' [SecondCountableTopology α] : MeasurableSet { p : α × α | p.1 < p.2 } :=\n  (isOpen_lt continuous_fst continuous_snd).MeasurableSet\n#align measurable_set_lt' measurableSet_lt'\n\n@[measurability]\ntheorem measurableSet_lt [SecondCountableTopology α] {f g : δ → α} (hf : Measurable f)\n    (hg : Measurable g) : MeasurableSet { a | f a < g a } :=\n  hf.prod_mk hg measurableSet_lt'\n#align measurable_set_lt measurableSet_lt\n\ntheorem nullMeasurableSetLt [SecondCountableTopology α] {μ : Measure δ} {f g : δ → α}\n    (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) : NullMeasurableSet { a | f a < g a } μ :=\n  (hf.prod_mk hg).NullMeasurable measurableSet_lt'\n#align null_measurable_set_lt nullMeasurableSetLt\n\ntheorem Set.OrdConnected.measurableSet (h : OrdConnected s) : MeasurableSet s :=\n  by\n  let u := ⋃ (x ∈ s) (y ∈ s), Ioo x y\n  have huopen : IsOpen u := isOpen_bunionᵢ fun x hx => isOpen_bunionᵢ fun y hy => isOpen_Ioo\n  have humeas : MeasurableSet u := huopen.measurable_set\n  have hfinite : (s \\ u).Finite := s.finite_diff_Union_Ioo\n  have : u ⊆ s :=\n    Union₂_subset fun x hx => Union₂_subset fun y hy => Ioo_subset_Icc_self.trans (h.out hx hy)\n  rw [← union_diff_cancel this]\n  exact humeas.union hfinite.measurable_set\n#align set.ord_connected.measurable_set Set.OrdConnected.measurableSet\n\ntheorem IsPreconnected.measurableSet (h : IsPreconnected s) : MeasurableSet s :=\n  h.OrdConnected.MeasurableSet\n#align is_preconnected.measurable_set IsPreconnected.measurableSet\n\ntheorem generateFrom_Ico_mem_le_borel {α : Type _} [TopologicalSpace α] [LinearOrder α]\n    [OrderClosedTopology α] (s t : Set α) :\n    MeasurableSpace.generateFrom { S | ∃ l ∈ s, ∃ u ∈ t, ∃ h : l < u, Ico l u = S } ≤ borel α :=\n  by\n  apply generate_from_le\n  borelize α\n  rintro _ ⟨a, -, b, -, -, rfl⟩\n  exact measurableSet_Ico\n#align generate_from_Ico_mem_le_borel generateFrom_Ico_mem_le_borel\n\ntheorem Dense.borel_eq_generateFrom_Ico_mem_aux {α : Type _} [TopologicalSpace α] [LinearOrder α]\n    [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s)\n    (hbot : ∀ x, IsBot x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → y ∈ s) :\n    borel α = generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, ∃ h : l < u, Ico l u = S } :=\n  by\n  set S : Set (Set α) := { S | ∃ l ∈ s, ∃ u ∈ s, ∃ h : l < u, Ico l u = S }\n  refine' le_antisymm _ (generateFrom_Ico_mem_le_borel _ _)\n  letI : MeasurableSpace α := generate_from S\n  rw [borel_eq_generateFrom_Iio]\n  refine' generate_from_le (forall_range_iff.2 fun a => _)\n  rcases hd.exists_countable_dense_subset_bot_top with ⟨t, hts, hc, htd, htb, htt⟩\n  by_cases ha : ∀ b < a, (Ioo b a).Nonempty\n  · convert_to MeasurableSet (⋃ (l ∈ t) (u ∈ t) (hlu : l < u) (hu : u ≤ a), Ico l u)\n    · ext y\n      simp only [mem_Union, mem_Iio, mem_Ico]\n      constructor\n      · intro hy\n        rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) y with ⟨l, hlt, hly⟩\n        rcases htd.exists_mem_open isOpen_Ioo (ha y hy) with ⟨u, hut, hyu, hua⟩\n        exact ⟨l, hlt, u, hut, hly.trans_lt hyu, hua.le, hly, hyu⟩\n      · rintro ⟨l, -, u, -, -, hua, -, hyu⟩\n        exact hyu.trans_le hua\n    · refine' MeasurableSet.bunionᵢ hc fun a ha => MeasurableSet.bunionᵢ hc fun b hb => _\n      refine' MeasurableSet.unionᵢ fun hab => MeasurableSet.unionᵢ fun hb' => _\n      exact generate_measurable.basic _ ⟨a, hts ha, b, hts hb, hab, mem_singleton _⟩\n  · simp only [not_forall, not_nonempty_iff_eq_empty] at ha\n    replace ha : a ∈ s := hIoo ha.some a ha.some_spec.fst ha.some_spec.snd\n    convert_to MeasurableSet (⋃ (l ∈ t) (hl : l < a), Ico l a)\n    · symm\n      simp only [← Ici_inter_Iio, ← Union_inter, inter_eq_right_iff_subset, subset_def, mem_Union,\n        mem_Ici, mem_Iio]\n      intro x hx\n      rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) x with ⟨z, hzt, hzx⟩\n      exact ⟨z, hzt, hzx.trans_lt hx, hzx⟩\n    · refine' MeasurableSet.bunionᵢ hc fun x hx => MeasurableSet.unionᵢ fun hlt => _\n      exact generate_measurable.basic _ ⟨x, hts hx, a, ha, hlt, mem_singleton _⟩\n#align dense.borel_eq_generate_from_Ico_mem_aux Dense.borel_eq_generateFrom_Ico_mem_aux\n\ntheorem Dense.borel_eq_generateFrom_Ico_mem {α : Type _} [TopologicalSpace α] [LinearOrder α]\n    [OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMinOrder α] {s : Set α}\n    (hd : Dense s) :\n    borel α = generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, ∃ h : l < u, Ico l u = S } :=\n  hd.borel_eq_generateFrom_Ico_mem_aux (by simp) fun x y hxy H =>\n    ((nonempty_Ioo.2 hxy).ne_empty H).elim\n#align dense.borel_eq_generate_from_Ico_mem Dense.borel_eq_generateFrom_Ico_mem\n\ntheorem borel_eq_generateFrom_Ico (α : Type _) [TopologicalSpace α] [SecondCountableTopology α]\n    [LinearOrder α] [OrderTopology α] :\n    borel α = generateFrom { S : Set α | ∃ (l u : _)(h : l < u), Ico l u = S } := by\n  simpa only [exists_prop, mem_univ, true_and_iff] using\n    (@dense_univ α _).borel_eq_generateFrom_Ico_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ =>\n      mem_univ _\n#align borel_eq_generate_from_Ico borel_eq_generateFrom_Ico\n\ntheorem Dense.borel_eq_generateFrom_Ioc_mem_aux {α : Type _} [TopologicalSpace α] [LinearOrder α]\n    [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s)\n    (hbot : ∀ x, IsTop x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → x ∈ s) :\n    borel α = generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, ∃ h : l < u, Ioc l u = S } :=\n  by\n  convert hd.order_dual.borel_eq_generate_from_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _\n  · ext s\n    constructor <;> rintro ⟨l, hl, u, hu, hlt, rfl⟩\n    exacts[⟨u, hu, l, hl, hlt, dual_Ico⟩, ⟨u, hu, l, hl, hlt, dual_Ioc⟩]\n  · erw [dual_Ioo]\n    exact he\n#align dense.borel_eq_generate_from_Ioc_mem_aux Dense.borel_eq_generateFrom_Ioc_mem_aux\n\ntheorem Dense.borel_eq_generateFrom_Ioc_mem {α : Type _} [TopologicalSpace α] [LinearOrder α]\n    [OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMaxOrder α] {s : Set α}\n    (hd : Dense s) :\n    borel α = generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, ∃ h : l < u, Ioc l u = S } :=\n  hd.borel_eq_generateFrom_Ioc_mem_aux (by simp) fun x y hxy H =>\n    ((nonempty_Ioo.2 hxy).ne_empty H).elim\n#align dense.borel_eq_generate_from_Ioc_mem Dense.borel_eq_generateFrom_Ioc_mem\n\ntheorem borel_eq_generateFrom_Ioc (α : Type _) [TopologicalSpace α] [SecondCountableTopology α]\n    [LinearOrder α] [OrderTopology α] :\n    borel α = generateFrom { S : Set α | ∃ (l u : _)(h : l < u), Ioc l u = S } := by\n  simpa only [exists_prop, mem_univ, true_and_iff] using\n    (@dense_univ α _).borel_eq_generateFrom_Ioc_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ =>\n      mem_univ _\n#align borel_eq_generate_from_Ioc borel_eq_generateFrom_Ioc\n\nnamespace MeasureTheory.Measure\n\n/-- Two finite measures on a Borel space are equal if they agree on all closed-open intervals.  If\n`α` is a conditionally complete linear order with no top element,\n`measure_theory.measure..ext_of_Ico` is an extensionality lemma with weaker assumptions on `μ` and\n`ν`. -/\ntheorem ext_of_Ico_finite {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)\n    [IsFiniteMeasure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) :\n    μ = ν :=\n  by\n  refine'\n    ext_of_generate_finite _ (borel_space.measurable_eq.trans (borel_eq_generateFrom_Ico α))\n      (isPiSystem_Ico (id : α → α) id) _ hμν\n  · rintro - ⟨a, b, hlt, rfl⟩\n    exact h hlt\n#align measure_theory.measure.ext_of_Ico_finite MeasureTheory.Measure.ext_of_Ico_finite\n\n/-- Two finite measures on a Borel space are equal if they agree on all open-closed intervals.  If\n`α` is a conditionally complete linear order with no top element,\n`measure_theory.measure..ext_of_Ioc` is an extensionality lemma with weaker assumptions on `μ` and\n`ν`. -/\ntheorem ext_of_Ioc_finite {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)\n    [IsFiniteMeasure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) :\n    μ = ν := by\n  refine' @ext_of_Ico_finite αᵒᵈ _ _ _ _ _ ‹_› μ ν _ hμν fun a b hab => _\n  erw [dual_Ico]\n  exact h hab\n#align measure_theory.measure.ext_of_Ioc_finite MeasureTheory.Measure.ext_of_Ioc_finite\n\n/-- Two measures which are finite on closed-open intervals are equal if the agree on all\nclosed-open intervals. -/\ntheorem ext_of_Ico' {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] [NoMaxOrder α]\n    (μ ν : Measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ico a b) ≠ ∞)\n    (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν :=\n  by\n  rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, hsb, hst⟩\n  have : (⋃ (l ∈ s) (u ∈ s) (h : l < u), {Ico l u} : Set (Set α)).Countable :=\n    hsc.bUnion fun l hl => hsc.bUnion fun u hu => countable_Union fun _ => countable_singleton _\n  simp only [← set_of_eq_eq_singleton, ← set_of_exists] at this\n  refine'\n    measure.ext_of_generate_from_of_cover_subset\n      (borel_space.measurable_eq.trans (borel_eq_generateFrom_Ico α)) (isPiSystem_Ico id id) _ this\n      _ _ _\n  · rintro _ ⟨l, -, u, -, h, rfl⟩\n    exact ⟨l, u, h, rfl⟩\n  · refine' sUnion_eq_univ_iff.2 fun x => _\n    rcases hsd.exists_le' hsb x with ⟨l, hls, hlx⟩\n    rcases hsd.exists_gt x with ⟨u, hus, hxu⟩\n    exact ⟨_, ⟨l, hls, u, hus, hlx.trans_lt hxu, rfl⟩, hlx, hxu⟩\n  · rintro _ ⟨l, -, u, -, hlt, rfl⟩\n    exact hμ hlt\n  · rintro _ ⟨l, u, hlt, rfl⟩\n    exact h hlt\n#align measure_theory.measure.ext_of_Ico' MeasureTheory.Measure.ext_of_Ico'\n\n/-- Two measures which are finite on closed-open intervals are equal if the agree on all\nopen-closed intervals. -/\ntheorem ext_of_Ioc' {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] [NoMinOrder α]\n    (μ ν : Measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ioc a b) ≠ ∞)\n    (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν :=\n  by\n  refine' @ext_of_Ico' αᵒᵈ _ _ _ _ _ ‹_› _ μ ν _ _ <;> intro a b hab <;> erw [dual_Ico]\n  exacts[hμ hab, h hab]\n#align measure_theory.measure.ext_of_Ioc' MeasureTheory.Measure.ext_of_Ioc'\n\n/-- Two measures which are finite on closed-open intervals are equal if the agree on all\nclosed-open intervals. -/\ntheorem ext_of_Ico {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [ConditionallyCompleteLinearOrder α] [OrderTopology α]\n    [BorelSpace α] [NoMaxOrder α] (μ ν : Measure α) [IsLocallyFiniteMeasure μ]\n    (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν :=\n  μ.ext_of_Ico' ν (fun a b hab => measure_Ico_lt_top.Ne) h\n#align measure_theory.measure.ext_of_Ico MeasureTheory.Measure.ext_of_Ico\n\n/-- Two measures which are finite on closed-open intervals are equal if the agree on all\nopen-closed intervals. -/\ntheorem ext_of_Ioc {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [ConditionallyCompleteLinearOrder α] [OrderTopology α]\n    [BorelSpace α] [NoMinOrder α] (μ ν : Measure α) [IsLocallyFiniteMeasure μ]\n    (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν :=\n  μ.ext_of_Ioc' ν (fun a b hab => measure_Ioc_lt_top.Ne) h\n#align measure_theory.measure.ext_of_Ioc MeasureTheory.Measure.ext_of_Ioc\n\n/-- Two finite measures on a Borel space are equal if they agree on all left-infinite right-closed\nintervals. -/\ntheorem ext_of_Iic {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)\n    [IsFiniteMeasure μ] (h : ∀ a, μ (Iic a) = ν (Iic a)) : μ = ν :=\n  by\n  refine' ext_of_Ioc_finite μ ν _ fun a b hlt => _\n  · rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, -, hst⟩\n    have : DirectedOn (· ≤ ·) s := directedOn_iff_directed.2 (directed_of_sup fun _ _ => id)\n    simp only [← bsupr_measure_Iic hsc (hsd.exists_ge' hst) this, h]\n  rw [← Iic_diff_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) measurableSet_Iic,\n    measure_diff (Iic_subset_Iic.2 hlt.le) measurableSet_Iic, h a, h b]\n  · rw [← h a]\n    exact (measure_lt_top μ _).Ne\n  · exact (measure_lt_top μ _).Ne\n#align measure_theory.measure.ext_of_Iic MeasureTheory.Measure.ext_of_Iic\n\n/-- Two finite measures on a Borel space are equal if they agree on all left-closed right-infinite\nintervals. -/\ntheorem ext_of_Ici {α : Type _} [TopologicalSpace α] {m : MeasurableSpace α}\n    [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α)\n    [IsFiniteMeasure μ] (h : ∀ a, μ (Ici a) = ν (Ici a)) : μ = ν :=\n  @ext_of_Iic αᵒᵈ _ _ _ _ _ ‹_› _ _ _ h\n#align measure_theory.measure.ext_of_Ici MeasureTheory.Measure.ext_of_Ici\n\nend MeasureTheory.Measure\n\nend LinearOrder\n\nsection LinearOrder\n\nvariable [LinearOrder α] [OrderClosedTopology α] {a b : α}\n\n@[measurability]\ntheorem measurableSet_uIcc : MeasurableSet (uIcc a b) :=\n  measurableSet_Icc\n#align measurable_set_uIcc measurableSet_uIcc\n\n@[measurability]\ntheorem measurableSet_uIoc : MeasurableSet (uIoc a b) :=\n  measurableSet_Ioc\n#align measurable_set_uIoc measurableSet_uIoc\n\nvariable [SecondCountableTopology α]\n\n@[measurability]\ntheorem Measurable.max {f g : δ → α} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun a => max (f a) (g a) := by\n  simpa only [max_def'] using hf.piecewise (measurableSet_le hg hf) hg\n#align measurable.max Measurable.max\n\n@[measurability]\ntheorem AeMeasurable.max {f g : δ → α} {μ : Measure δ} (hf : AeMeasurable f μ)\n    (hg : AeMeasurable g μ) : AeMeasurable (fun a => max (f a) (g a)) μ :=\n  ⟨fun a => max (hf.mk f a) (hg.mk g a), hf.measurable_mk.max hg.measurable_mk,\n    EventuallyEq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩\n#align ae_measurable.max AeMeasurable.max\n\n@[measurability]\ntheorem Measurable.min {f g : δ → α} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun a => min (f a) (g a) := by\n  simpa only [min_def] using hf.piecewise (measurableSet_le hf hg) hg\n#align measurable.min Measurable.min\n\n@[measurability]\ntheorem AeMeasurable.min {f g : δ → α} {μ : Measure δ} (hf : AeMeasurable f μ)\n    (hg : AeMeasurable g μ) : AeMeasurable (fun a => min (f a) (g a)) μ :=\n  ⟨fun a => min (hf.mk f a) (hg.mk g a), hf.measurable_mk.min hg.measurable_mk,\n    EventuallyEq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩\n#align ae_measurable.min AeMeasurable.min\n\nend LinearOrder\n\n/-- A continuous function from an `opens_measurable_space` to a `borel_space`\nis measurable. -/\ntheorem Continuous.measurable {f : α → γ} (hf : Continuous f) : Measurable f :=\n  hf.borel_measurable.mono OpensMeasurableSpace.borel_le (le_of_eq <| BorelSpace.measurable_eq)\n#align continuous.measurable Continuous.measurable\n\n/-- A continuous function from an `opens_measurable_space` to a `borel_space`\nis ae-measurable. -/\ntheorem Continuous.aeMeasurable {f : α → γ} (h : Continuous f) {μ : Measure α} : AeMeasurable f μ :=\n  h.Measurable.AeMeasurable\n#align continuous.ae_measurable Continuous.aeMeasurable\n\ntheorem ClosedEmbedding.measurable {f : α → γ} (hf : ClosedEmbedding f) : Measurable f :=\n  hf.Continuous.Measurable\n#align closed_embedding.measurable ClosedEmbedding.measurable\n\ntheorem Continuous.isOpenPosMeasureMap {f : β → γ} (hf : Continuous f)\n    (hf_surj : Function.Surjective f) {μ : Measure β} [μ.IsOpenPosMeasure] :\n    (Measure.map f μ).IsOpenPosMeasure :=\n  by\n  refine' ⟨fun U hUo hUne => _⟩\n  rw [measure.map_apply hf.measurable hUo.measurable_set]\n  exact (hUo.preimage hf).measure_ne_zero μ (hf_surj.nonempty_preimage.mpr hUne)\n#align continuous.is_open_pos_measure_map Continuous.isOpenPosMeasureMap\n\n/-- If a function is defined piecewise in terms of functions which are continuous on their\nrespective pieces, then it is measurable. -/\ntheorem ContinuousOn.measurable_piecewise {f g : α → γ} {s : Set α} [∀ j : α, Decidable (j ∈ s)]\n    (hf : ContinuousOn f s) (hg : ContinuousOn g (sᶜ)) (hs : MeasurableSet s) :\n    Measurable (s.piecewise f g) :=\n  by\n  refine' measurable_of_isOpen fun t ht => _\n  rw [piecewise_preimage, Set.ite]\n  apply MeasurableSet.union\n  · rcases _root_.continuous_on_iff'.1 hf t ht with ⟨u, u_open, hu⟩\n    rw [hu]\n    exact u_open.measurable_set.inter hs\n  · rcases _root_.continuous_on_iff'.1 hg t ht with ⟨u, u_open, hu⟩\n    rw [diff_eq_compl_inter, inter_comm, hu]\n    exact u_open.measurable_set.inter hs.compl\n#align continuous_on.measurable_piecewise ContinuousOn.measurable_piecewise\n\n@[to_additive]\ninstance (priority := 100) ContinuousMul.hasMeasurableMul [Mul γ] [ContinuousMul γ] :\n    HasMeasurableMul γ\n    where\n  measurable_const_mul c := (continuous_const.mul continuous_id).Measurable\n  measurable_mul_const c := (continuous_id.mul continuous_const).Measurable\n#align has_continuous_mul.has_measurable_mul ContinuousMul.hasMeasurableMul\n#align has_continuous_add.has_measurable_add ContinuousAdd.has_measurable_add\n\ninstance (priority := 100) ContinuousSub.hasMeasurableSub [Sub γ] [ContinuousSub γ] :\n    HasMeasurableSub γ\n    where\n  measurable_const_sub c := (continuous_const.sub continuous_id).Measurable\n  measurable_sub_const c := (continuous_id.sub continuous_const).Measurable\n#align has_continuous_sub.has_measurable_sub ContinuousSub.hasMeasurableSub\n\n@[to_additive]\ninstance (priority := 100) TopologicalGroup.hasMeasurableInv [Group γ] [TopologicalGroup γ] :\n    HasMeasurableInv γ :=\n  ⟨continuous_inv.Measurable⟩\n#align topological_group.has_measurable_inv TopologicalGroup.hasMeasurableInv\n#align topological_add_group.has_measurable_neg TopologicalAddGroup.has_measurable_neg\n\ninstance (priority := 100) ContinuousSMul.hasMeasurableSmul {M α} [TopologicalSpace M]\n    [TopologicalSpace α] [MeasurableSpace M] [MeasurableSpace α] [OpensMeasurableSpace M]\n    [BorelSpace α] [SMul M α] [ContinuousSMul M α] : HasMeasurableSmul M α :=\n  ⟨fun c => (continuous_const_smul _).Measurable, fun y =>\n    (continuous_id.smul continuous_const).Measurable⟩\n#align has_continuous_smul.has_measurable_smul ContinuousSMul.hasMeasurableSmul\n\nsection Lattice\n\ninstance (priority := 100) ContinuousSup.hasMeasurableSup [Sup γ] [ContinuousSup γ] :\n    HasMeasurableSup γ\n    where\n  measurable_const_sup c := (continuous_const.sup continuous_id).Measurable\n  measurable_sup_const c := (continuous_id.sup continuous_const).Measurable\n#align has_continuous_sup.has_measurable_sup ContinuousSup.hasMeasurableSup\n\ninstance (priority := 100) ContinuousSup.hasMeasurableSup₂ [SecondCountableTopology γ] [Sup γ]\n    [ContinuousSup γ] : HasMeasurableSup₂ γ :=\n  ⟨continuous_sup.Measurable⟩\n#align has_continuous_sup.has_measurable_sup₂ ContinuousSup.hasMeasurableSup₂\n\ninstance (priority := 100) ContinuousInf.hasMeasurableInf [Inf γ] [ContinuousInf γ] :\n    HasMeasurableInf γ\n    where\n  measurable_const_inf c := (continuous_const.inf continuous_id).Measurable\n  measurable_inf_const c := (continuous_id.inf continuous_const).Measurable\n#align has_continuous_inf.has_measurable_inf ContinuousInf.hasMeasurableInf\n\ninstance (priority := 100) ContinuousInf.hasMeasurableInf₂ [SecondCountableTopology γ] [Inf γ]\n    [ContinuousInf γ] : HasMeasurableInf₂ γ :=\n  ⟨continuous_inf.Measurable⟩\n#align has_continuous_inf.has_measurable_inf₂ ContinuousInf.hasMeasurableInf₂\n\nend Lattice\n\nsection Homeomorph\n\n@[measurability]\nprotected theorem Homeomorph.measurable (h : α ≃ₜ γ) : Measurable h :=\n  h.Continuous.Measurable\n#align homeomorph.measurable Homeomorph.measurable\n\n/-- A homeomorphism between two Borel spaces is a measurable equivalence.-/\ndef Homeomorph.toMeasurableEquiv (h : γ ≃ₜ γ₂) : γ ≃ᵐ γ₂\n    where\n  measurable_to_fun := h.Measurable\n  measurable_inv_fun := h.symm.Measurable\n  toEquiv := h.toEquiv\n#align homeomorph.to_measurable_equiv Homeomorph.toMeasurableEquiv\n\n@[simp]\ntheorem Homeomorph.toMeasurableEquiv_coe (h : γ ≃ₜ γ₂) : (h.toMeasurableEquiv : γ → γ₂) = h :=\n  rfl\n#align homeomorph.to_measurable_equiv_coe Homeomorph.toMeasurableEquiv_coe\n\n@[simp]\ntheorem Homeomorph.toMeasurableEquiv_symm_coe (h : γ ≃ₜ γ₂) :\n    (h.toMeasurableEquiv.symm : γ₂ → γ) = h.symm :=\n  rfl\n#align homeomorph.to_measurable_equiv_symm_coe Homeomorph.toMeasurableEquiv_symm_coe\n\nend Homeomorph\n\n@[measurability]\ntheorem ContinuousMap.measurable (f : C(α, γ)) : Measurable f :=\n  f.Continuous.Measurable\n#align continuous_map.measurable ContinuousMap.measurable\n\ntheorem measurable_of_continuousOn_compl_singleton [T1Space α] {f : α → γ} (a : α)\n    (hf : ContinuousOn f ({a}ᶜ)) : Measurable f :=\n  measurable_of_measurable_on_compl_singleton a\n    (continuousOn_iff_continuous_restrict.1 hf).Measurable\n#align measurable_of_continuous_on_compl_singleton measurable_of_continuousOn_compl_singleton\n\ntheorem Continuous.measurable2 [SecondCountableTopology α] [SecondCountableTopology β] {f : δ → α}\n    {g : δ → β} {c : α → β → γ} (h : Continuous fun p : α × β => c p.1 p.2) (hf : Measurable f)\n    (hg : Measurable g) : Measurable fun a => c (f a) (g a) :=\n  h.Measurable.comp (hf.prod_mk hg)\n#align continuous.measurable2 Continuous.measurable2\n\ntheorem Continuous.aeMeasurable2 [SecondCountableTopology α] [SecondCountableTopology β] {f : δ → α}\n    {g : δ → β} {c : α → β → γ} {μ : Measure δ} (h : Continuous fun p : α × β => c p.1 p.2)\n    (hf : AeMeasurable f μ) (hg : AeMeasurable g μ) : AeMeasurable (fun a => c (f a) (g a)) μ :=\n  h.Measurable.compAeMeasurable (hf.prod_mk hg)\n#align continuous.ae_measurable2 Continuous.aeMeasurable2\n\ninstance (priority := 100) HasContinuousInv₀.hasMeasurableInv [GroupWithZero γ] [T1Space γ]\n    [HasContinuousInv₀ γ] : HasMeasurableInv γ :=\n  ⟨measurable_of_continuousOn_compl_singleton 0 continuousOn_inv₀⟩\n#align has_continuous_inv₀.has_measurable_inv HasContinuousInv₀.hasMeasurableInv\n\n@[to_additive]\ninstance (priority := 100) ContinuousMul.hasMeasurableMul₂ [SecondCountableTopology γ] [Mul γ]\n    [ContinuousMul γ] : HasMeasurableMul₂ γ :=\n  ⟨continuous_mul.Measurable⟩\n#align has_continuous_mul.has_measurable_mul₂ ContinuousMul.hasMeasurableMul₂\n#align has_continuous_add.has_measurable_mul₂ ContinuousAdd.hasMeasurableMul₂\n\ninstance (priority := 100) ContinuousSub.hasMeasurableSub₂ [SecondCountableTopology γ] [Sub γ]\n    [ContinuousSub γ] : HasMeasurableSub₂ γ :=\n  ⟨continuous_sub.Measurable⟩\n#align has_continuous_sub.has_measurable_sub₂ ContinuousSub.hasMeasurableSub₂\n\ninstance (priority := 100) ContinuousSMul.hasMeasurableSmul₂ {M α} [TopologicalSpace M]\n    [SecondCountableTopology M] [MeasurableSpace M] [OpensMeasurableSpace M] [TopologicalSpace α]\n    [SecondCountableTopology α] [MeasurableSpace α] [BorelSpace α] [SMul M α] [ContinuousSMul M α] :\n    HasMeasurableSmul₂ M α :=\n  ⟨continuous_smul.Measurable⟩\n#align has_continuous_smul.has_measurable_smul₂ ContinuousSMul.hasMeasurableSmul₂\n\nend\n\nsection BorelSpace\n\nvariable [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] [TopologicalSpace β]\n  [MeasurableSpace β] [BorelSpace β] [TopologicalSpace γ] [MeasurableSpace γ] [BorelSpace γ]\n  [MeasurableSpace δ]\n\ntheorem pi_le_borel_pi {ι : Type _} {π : ι → Type _} [∀ i, TopologicalSpace (π i)]\n    [∀ i, MeasurableSpace (π i)] [∀ i, BorelSpace (π i)] : MeasurableSpace.pi ≤ borel (∀ i, π i) :=\n  by\n  have : ‹∀ i, MeasurableSpace (π i)› = fun i => borel (π i) :=\n    funext fun i => BorelSpace.measurable_eq\n  rw [this]\n  exact supᵢ_le fun i => comap_le_iff_le_map.2 <| (continuous_apply i).borel_measurable\n#align pi_le_borel_pi pi_le_borel_pi\n\ntheorem prod_le_borel_prod : Prod.measurableSpace ≤ borel (α × β) :=\n  by\n  rw [‹BorelSpace α›.measurable_eq, ‹BorelSpace β›.measurable_eq]\n  refine' sup_le _ _\n  · exact comap_le_iff_le_map.mpr continuous_fst.borel_measurable\n  · exact comap_le_iff_le_map.mpr continuous_snd.borel_measurable\n#align prod_le_borel_prod prod_le_borel_prod\n\ninstance Pi.borelSpace {ι : Type _} {π : ι → Type _} [Countable ι] [∀ i, TopologicalSpace (π i)]\n    [∀ i, MeasurableSpace (π i)] [∀ i, SecondCountableTopology (π i)] [∀ i, BorelSpace (π i)] :\n    BorelSpace (∀ i, π i) :=\n  ⟨le_antisymm pi_le_borel_pi OpensMeasurableSpace.borel_le⟩\n#align pi.borel_space Pi.borelSpace\n\ninstance Prod.borelSpace [SecondCountableTopology α] [SecondCountableTopology β] :\n    BorelSpace (α × β) :=\n  ⟨le_antisymm prod_le_borel_prod OpensMeasurableSpace.borel_le⟩\n#align prod.borel_space Prod.borelSpace\n\nprotected theorem Embedding.measurableEmbedding {f : α → β} (h₁ : Embedding f)\n    (h₂ : MeasurableSet (range f)) : MeasurableEmbedding f :=\n  show MeasurableEmbedding (coe ∘ (Homeomorph.ofEmbedding f h₁).toMeasurableEquiv) from\n    (MeasurableEmbedding.subtype_coe h₂).comp (MeasurableEquiv.measurableEmbedding _)\n#align embedding.measurable_embedding Embedding.measurableEmbedding\n\nprotected theorem ClosedEmbedding.measurableEmbedding {f : α → β} (h : ClosedEmbedding f) :\n    MeasurableEmbedding f :=\n  h.toEmbedding.MeasurableEmbedding h.closed_range.MeasurableSet\n#align closed_embedding.measurable_embedding ClosedEmbedding.measurableEmbedding\n\nprotected theorem OpenEmbedding.measurableEmbedding {f : α → β} (h : OpenEmbedding f) :\n    MeasurableEmbedding f :=\n  h.toEmbedding.MeasurableEmbedding h.open_range.MeasurableSet\n#align open_embedding.measurable_embedding OpenEmbedding.measurableEmbedding\n\nsection LinearOrder\n\nvariable [LinearOrder α] [OrderTopology α] [SecondCountableTopology α]\n\ntheorem measurable_of_Iio {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iio x)) : Measurable f :=\n  by\n  convert measurable_generateFrom _\n  exact borel_space.measurable_eq.trans (borel_eq_generateFrom_Iio _)\n  rintro _ ⟨x, rfl⟩; exact hf x\n#align measurable_of_Iio measurable_of_Iio\n\ntheorem UpperSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α}\n    (hf : UpperSemicontinuous f) : Measurable f :=\n  measurable_of_Iio fun y => (hf.isOpen_preimage y).MeasurableSet\n#align upper_semicontinuous.measurable UpperSemicontinuous.measurable\n\ntheorem measurable_of_Ioi {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ioi x)) : Measurable f :=\n  by\n  convert measurable_generateFrom _\n  exact borel_space.measurable_eq.trans (borel_eq_generateFrom_Ioi _)\n  rintro _ ⟨x, rfl⟩; exact hf x\n#align measurable_of_Ioi measurable_of_Ioi\n\ntheorem LowerSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α}\n    (hf : LowerSemicontinuous f) : Measurable f :=\n  measurable_of_Ioi fun y => (hf.isOpen_preimage y).MeasurableSet\n#align lower_semicontinuous.measurable LowerSemicontinuous.measurable\n\ntheorem measurable_of_Iic {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iic x)) : Measurable f :=\n  by\n  apply measurable_of_Ioi\n  simp_rw [← compl_Iic, preimage_compl, MeasurableSet.compl_iff]\n  assumption\n#align measurable_of_Iic measurable_of_Iic\n\ntheorem measurable_of_Ici {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ici x)) : Measurable f :=\n  by\n  apply measurable_of_Iio\n  simp_rw [← compl_Ici, preimage_compl, MeasurableSet.compl_iff]\n  assumption\n#align measurable_of_Ici measurable_of_Ici\n\ntheorem Measurable.isLUB {ι} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, Measurable (f i))\n    (hg : ∀ b, IsLUB { a | ∃ i, f i b = a } (g b)) : Measurable g :=\n  by\n  change ∀ b, IsLUB (range fun i => f i b) (g b) at hg\n  rw [‹BorelSpace α›.measurable_eq, borel_eq_generateFrom_Ioi α]\n  apply measurable_generateFrom\n  rintro _ ⟨a, rfl⟩\n  simp_rw [Set.preimage, mem_Ioi, lt_isLUB_iff (hg _), exists_range_iff, set_of_exists]\n  exact MeasurableSet.unionᵢ fun i => hf i (isOpen_lt' _).MeasurableSet\n#align measurable.is_lub Measurable.isLUB\n\nprivate theorem ae_measurable.is_lub_of_nonempty {ι} (hι : Nonempty ι) {μ : Measure δ} [Countable ι]\n    {f : ι → δ → α} {g : δ → α} (hf : ∀ i, AeMeasurable (f i) μ)\n    (hg : ∀ᵐ b ∂μ, IsLUB { a | ∃ i, f i b = a } (g b)) : AeMeasurable g μ :=\n  by\n  let p : δ → (ι → α) → Prop := fun x f' => IsLUB { a | ∃ i, f' i = a } (g x)\n  let g_seq x := ite (x ∈ aeSeqSet hf p) (g x) (⟨g x⟩ : Nonempty α).some\n  have hg_seq : ∀ b, IsLUB { a | ∃ i, aeSeq hf p i b = a } (g_seq b) :=\n    by\n    intro b\n    haveI hα : Nonempty α := Nonempty.map g ⟨b⟩\n    simp only [aeSeq, g_seq]\n    split_ifs\n    · have h_set_eq : { a : α | ∃ i : ι, (hf i).mk (f i) b = a } = { a : α | ∃ i : ι, f i b = a } :=\n        by\n        ext x\n        simp_rw [Set.mem_setOf_eq, aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h]\n      rw [h_set_eq]\n      exact aeSeq.funPropOfMemAeSeqSet hf h\n    · have h_singleton : { a : α | ∃ i : ι, hα.some = a } = {hα.some} :=\n        by\n        ext1 x\n        exact ⟨fun hx => hx.some_spec.symm, fun hx => ⟨hι.some, hx.symm⟩⟩\n      rw [h_singleton]\n      exact isLUB_singleton\n  refine' ⟨g_seq, Measurable.isLUB (aeSeq.measurable hf p) hg_seq, _⟩\n  exact\n    (ite_ae_eq_of_measure_compl_zero g (fun x => (⟨g x⟩ : Nonempty α).some) (aeSeqSet hf p)\n        (aeSeq.measure_compl_aeSeqSet_eq_zero hf hg)).symm\n#align ae_measurable.is_lub_of_nonempty ae_measurable.is_lub_of_nonempty\n\ntheorem AeMeasurable.isLub {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} {g : δ → α}\n    (hf : ∀ i, AeMeasurable (f i) μ) (hg : ∀ᵐ b ∂μ, IsLUB { a | ∃ i, f i b = a } (g b)) :\n    AeMeasurable g μ := by\n  by_cases hμ : μ = 0\n  · rw [hμ]\n    exact aeMeasurableZeroMeasure\n  have : μ.ae.ne_bot := by simpa [ne_bot_iff]\n  by_cases hι : Nonempty ι\n  · exact ae_measurable.is_lub_of_nonempty hι hf hg\n  suffices ∃ x, g =ᵐ[μ] fun y => g x by\n    exact ⟨fun y => g this.some, measurable_const, this.some_spec⟩\n  have h_empty : ∀ x, { a : α | ∃ i : ι, f i x = a } = ∅ :=\n    by\n    intro x\n    ext1 y\n    rw [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false_iff]\n    exact fun hi => hι (nonempty_of_exists hi)\n  simp_rw [h_empty] at hg\n  exact ⟨hg.exists.some, hg.mono fun y hy => IsLUB.unique hy hg.exists.some_spec⟩\n#align ae_measurable.is_lub AeMeasurable.isLub\n\ntheorem Measurable.isGLB {ι} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, Measurable (f i))\n    (hg : ∀ b, IsGLB { a | ∃ i, f i b = a } (g b)) : Measurable g :=\n  by\n  change ∀ b, IsGLB (range fun i => f i b) (g b) at hg\n  rw [‹BorelSpace α›.measurable_eq, borel_eq_generateFrom_Iio α]\n  apply measurable_generateFrom\n  rintro _ ⟨a, rfl⟩\n  simp_rw [Set.preimage, mem_Iio, isGLB_lt_iff (hg _), exists_range_iff, set_of_exists]\n  exact MeasurableSet.unionᵢ fun i => hf i (isOpen_gt' _).MeasurableSet\n#align measurable.is_glb Measurable.isGLB\n\ntheorem AeMeasurable.isGlb {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} {g : δ → α}\n    (hf : ∀ i, AeMeasurable (f i) μ) (hg : ∀ᵐ b ∂μ, IsGLB { a | ∃ i, f i b = a } (g b)) :\n    AeMeasurable g μ := by\n  nontriviality α\n  haveI hα : Nonempty α := inferInstance\n  cases' isEmpty_or_nonempty ι with hι hι\n  · simp only [IsEmpty.exists_iff, set_of_false, isGLB_empty_iff] at hg\n    exact aeMeasurableConst' (hg.mono fun a ha => hg.mono fun b hb => (hb _).antisymm (ha _))\n  let p : δ → (ι → α) → Prop := fun x f' => IsGLB { a | ∃ i, f' i = a } (g x)\n  let g_seq := (aeSeqSet hf p).piecewise g fun _ => hα.some\n  have hg_seq : ∀ b, IsGLB { a | ∃ i, aeSeq hf p i b = a } (g_seq b) :=\n    by\n    intro b\n    simp only [aeSeq, g_seq, Set.piecewise]\n    split_ifs\n    · have h_set_eq : { a : α | ∃ i : ι, (hf i).mk (f i) b = a } = { a : α | ∃ i : ι, f i b = a } :=\n        by\n        ext x\n        simp_rw [Set.mem_setOf_eq, aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h]\n      rw [h_set_eq]\n      exact aeSeq.funPropOfMemAeSeqSet hf h\n    · exact IsLeast.isGLB ⟨(@exists_const (hα.some = hα.some) ι _).2 rfl, fun x ⟨i, hi⟩ => hi.le⟩\n  refine' ⟨g_seq, Measurable.isGLB (aeSeq.measurable hf p) hg_seq, _⟩\n  exact\n    (ite_ae_eq_of_measure_compl_zero g (fun x => hα.some) (aeSeqSet hf p)\n        (aeSeq.measure_compl_aeSeqSet_eq_zero hf hg)).symm\n#align ae_measurable.is_glb AeMeasurable.isGlb\n\nprotected theorem Monotone.measurable [LinearOrder β] [OrderClosedTopology β] {f : β → α}\n    (hf : Monotone f) : Measurable f :=\n  suffices h : ∀ x, OrdConnected (f ⁻¹' Ioi x) from measurable_of_Ioi fun x => (h x).MeasurableSet\n  fun x => ordConnected_def.mpr fun a ha b hb c hc => lt_of_lt_of_le ha (hf hc.1)\n#align monotone.measurable Monotone.measurable\n\ntheorem aeMeasurableRestrictOfMonotoneOn [LinearOrder β] [OrderClosedTopology β] {μ : Measure β}\n    {s : Set β} (hs : MeasurableSet s) {f : β → α} (hf : MonotoneOn f s) :\n    AeMeasurable f (μ.restrict s) :=\n  have this : Monotone (f ∘ coe : s → α) := fun ⟨x, hx⟩ ⟨y, hy⟩ (hxy : x ≤ y) => hf hx hy hxy\n  aeMeasurableRestrictOfMeasurableSubtype hs this.Measurable\n#align ae_measurable_restrict_of_monotone_on aeMeasurableRestrictOfMonotoneOn\n\nprotected theorem Antitone.measurable [LinearOrder β] [OrderClosedTopology β] {f : β → α}\n    (hf : Antitone f) : Measurable f :=\n  @Monotone.measurable αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ hf\n#align antitone.measurable Antitone.measurable\n\ntheorem aeMeasurableRestrictOfAntitoneOn [LinearOrder β] [OrderClosedTopology β] {μ : Measure β}\n    {s : Set β} (hs : MeasurableSet s) {f : β → α} (hf : AntitoneOn f s) :\n    AeMeasurable f (μ.restrict s) :=\n  @aeMeasurableRestrictOfMonotoneOn αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ _ hs _ hf\n#align ae_measurable_restrict_of_antitone_on aeMeasurableRestrictOfAntitoneOn\n\ntheorem measurableSet_of_mem_nhdsWithin_Ioi_aux {s : Set α} (h : ∀ x ∈ s, s ∈ 𝓝[>] x)\n    (h' : ∀ x ∈ s, ∃ y, x < y) : MeasurableSet s :=\n  by\n  choose! M hM using h'\n  suffices H : (s \\ interior s).Countable\n  · have : s = interior s ∪ s \\ interior s := by rw [union_diff_cancel interior_subset]\n    rw [this]\n    exact is_open_interior.measurable_set.union H.measurable_set\n  have A : ∀ x ∈ s, ∃ y ∈ Ioi x, Ioo x y ⊆ s := fun x hx =>\n    (mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' (hM x hx)).1 (h x hx)\n  choose! y hy h'y using A\n  have B : Set.PairwiseDisjoint (s \\ interior s) fun x => Ioo x (y x) :=\n    by\n    intro x hx x' hx' hxx'\n    rcases lt_or_gt_of_ne hxx' with (h' | h')\n    · apply disjoint_left.2 fun z hz h'z => _\n      have : x' ∈ interior s :=\n        mem_interior.2 ⟨Ioo x (y x), h'y _ hx.1, isOpen_Ioo, ⟨h', h'z.1.trans hz.2⟩⟩\n      exact False.elim (hx'.2 this)\n    · apply disjoint_left.2 fun z hz h'z => _\n      have : x ∈ interior s :=\n        mem_interior.2 ⟨Ioo x' (y x'), h'y _ hx'.1, isOpen_Ioo, ⟨h', hz.1.trans h'z.2⟩⟩\n      exact False.elim (hx.2 this)\n  exact B.countable_of_Ioo fun x hx => hy x hx.1\n#align measurable_set_of_mem_nhds_within_Ioi_aux measurableSet_of_mem_nhdsWithin_Ioi_aux\n\n/-- If a set is a right-neighborhood of all of its points, then it is measurable. -/\ntheorem measurableSet_of_mem_nhdsWithin_Ioi {s : Set α} (h : ∀ x ∈ s, s ∈ 𝓝[>] x) :\n    MeasurableSet s := by\n  by_cases H : ∃ x ∈ s, IsTop x\n  · rcases H with ⟨x₀, x₀s, h₀⟩\n    have : s = {x₀} ∪ s \\ {x₀} := by rw [union_diff_cancel (singleton_subset_iff.2 x₀s)]\n    rw [this]\n    refine' (measurable_set_singleton _).union _\n    have A : ∀ x ∈ s \\ {x₀}, x < x₀ := fun x hx => lt_of_le_of_ne (h₀ _) (by simpa using hx.2)\n    refine' measurableSet_of_mem_nhdsWithin_Ioi_aux (fun x hx => _) fun x hx => ⟨x₀, A x hx⟩\n    obtain ⟨u, hu, us⟩ : ∃ (u : α)(H : u ∈ Ioi x), Ioo x u ⊆ s :=\n      (mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' (A x hx)).1 (h x hx.1)\n    refine' (mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' (A x hx)).2 ⟨u, hu, fun y hy => ⟨us hy, _⟩⟩\n    exact ne_of_lt (hy.2.trans_le (h₀ _))\n  · apply measurableSet_of_mem_nhdsWithin_Ioi_aux h\n    simp only [IsTop] at H\n    push_neg  at H\n    exact H\n#align measurable_set_of_mem_nhds_within_Ioi measurableSet_of_mem_nhdsWithin_Ioi\n\nend LinearOrder\n\n@[measurability]\ntheorem Measurable.supᵢ_Prop {α} [MeasurableSpace α] [CompleteLattice α] (p : Prop) {f : δ → α}\n    (hf : Measurable f) : Measurable fun b => ⨆ h : p, f b :=\n  by_cases (fun h : p => by convert hf; funext; exact supᵢ_pos h) fun h : ¬p => by\n    convert measurable_const; funext; exact supᵢ_neg h\n#align measurable.supr_Prop Measurable.supᵢ_Prop\n\n@[measurability]\ntheorem Measurable.infᵢ_Prop {α} [MeasurableSpace α] [CompleteLattice α] (p : Prop) {f : δ → α}\n    (hf : Measurable f) : Measurable fun b => ⨅ h : p, f b :=\n  by_cases (fun h : p => by convert hf; funext; exact infᵢ_pos h) fun h : ¬p => by\n    convert measurable_const; funext; exact infᵢ_neg h\n#align measurable.infi_Prop Measurable.infᵢ_Prop\n\nsection CompleteLinearOrder\n\nvariable [CompleteLinearOrder α] [OrderTopology α] [SecondCountableTopology α]\n\n@[measurability]\ntheorem measurable_supᵢ {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) :\n    Measurable fun b => ⨆ i, f i b :=\n  Measurable.isLUB hf fun b => isLUB_supᵢ\n#align measurable_supr measurable_supᵢ\n\n@[measurability]\ntheorem aeMeasurableSupr {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α}\n    (hf : ∀ i, AeMeasurable (f i) μ) : AeMeasurable (fun b => ⨆ i, f i b) μ :=\n  AeMeasurable.isLub hf <| ae_of_all μ fun b => isLUB_supᵢ\n#align ae_measurable_supr aeMeasurableSupr\n\n@[measurability]\ntheorem measurable_infᵢ {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) :\n    Measurable fun b => ⨅ i, f i b :=\n  Measurable.isGLB hf fun b => isGLB_infᵢ\n#align measurable_infi measurable_infᵢ\n\n@[measurability]\ntheorem aeMeasurableInfi {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α}\n    (hf : ∀ i, AeMeasurable (f i) μ) : AeMeasurable (fun b => ⨅ i, f i b) μ :=\n  AeMeasurable.isGlb hf <| ae_of_all μ fun b => isGLB_infᵢ\n#align ae_measurable_infi aeMeasurableInfi\n\ntheorem measurable_bsupr {ι} (s : Set ι) {f : ι → δ → α} (hs : s.Countable)\n    (hf : ∀ i, Measurable (f i)) : Measurable fun b => ⨆ i ∈ s, f i b :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [supᵢ_subtype']\n  exact measurable_supᵢ fun i => hf i\n#align measurable_bsupr measurable_bsupr\n\ntheorem aeMeasurableBsupr {ι} {μ : Measure δ} (s : Set ι) {f : ι → δ → α} (hs : s.Countable)\n    (hf : ∀ i, AeMeasurable (f i) μ) : AeMeasurable (fun b => ⨆ i ∈ s, f i b) μ :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [supᵢ_subtype']\n  exact aeMeasurableSupr fun i => hf i\n#align ae_measurable_bsupr aeMeasurableBsupr\n\ntheorem measurable_binfi {ι} (s : Set ι) {f : ι → δ → α} (hs : s.Countable)\n    (hf : ∀ i, Measurable (f i)) : Measurable fun b => ⨅ i ∈ s, f i b :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [infᵢ_subtype']\n  exact measurable_infᵢ fun i => hf i\n#align measurable_binfi measurable_binfi\n\ntheorem aeMeasurableBinfi {ι} {μ : Measure δ} (s : Set ι) {f : ι → δ → α} (hs : s.Countable)\n    (hf : ∀ i, AeMeasurable (f i) μ) : AeMeasurable (fun b => ⨅ i ∈ s, f i b) μ :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [infᵢ_subtype']\n  exact aeMeasurableInfi fun i => hf i\n#align ae_measurable_binfi aeMeasurableBinfi\n\n/-- `liminf` over a general filter is measurable. See `measurable_liminf` for the version over `ℕ`.\n-/\ntheorem measurable_liminf' {ι ι'} {f : ι → δ → α} {u : Filter ι} (hf : ∀ i, Measurable (f i))\n    {p : ι' → Prop} {s : ι' → Set ι} (hu : u.HasCountableBasis p s) (hs : ∀ i, (s i).Countable) :\n    Measurable fun x => liminf (fun i => f i x) u :=\n  by\n  simp_rw [hu.to_has_basis.liminf_eq_supr_infi]\n  refine' measurable_bsupr _ hu.countable _\n  exact fun i => measurable_binfi _ (hs i) hf\n#align measurable_liminf' measurable_liminf'\n\n/-- `limsup` over a general filter is measurable. See `measurable_limsup` for the version over `ℕ`.\n-/\ntheorem measurable_limsup' {ι ι'} {f : ι → δ → α} {u : Filter ι} (hf : ∀ i, Measurable (f i))\n    {p : ι' → Prop} {s : ι' → Set ι} (hu : u.HasCountableBasis p s) (hs : ∀ i, (s i).Countable) :\n    Measurable fun x => limsup (fun i => f i x) u :=\n  by\n  simp_rw [hu.to_has_basis.limsup_eq_infi_supr]\n  refine' measurable_binfi _ hu.countable _\n  exact fun i => measurable_bsupr _ (hs i) hf\n#align measurable_limsup' measurable_limsup'\n\n/-- `liminf` over `ℕ` is measurable. See `measurable_liminf'` for a version with a general filter.\n-/\n@[measurability]\ntheorem measurable_liminf {f : ℕ → δ → α} (hf : ∀ i, Measurable (f i)) :\n    Measurable fun x => liminf (fun i => f i x) atTop :=\n  measurable_liminf' hf atTop_countable_basis fun i => to_countable _\n#align measurable_liminf measurable_liminf\n\n/-- `limsup` over `ℕ` is measurable. See `measurable_limsup'` for a version with a general filter.\n-/\n@[measurability]\ntheorem measurable_limsup {f : ℕ → δ → α} (hf : ∀ i, Measurable (f i)) :\n    Measurable fun x => limsup (fun i => f i x) atTop :=\n  measurable_limsup' hf atTop_countable_basis fun i => to_countable _\n#align measurable_limsup measurable_limsup\n\nend CompleteLinearOrder\n\nsection ConditionallyCompleteLinearOrder\n\nvariable [ConditionallyCompleteLinearOrder α] [OrderTopology α] [SecondCountableTopology α]\n\ntheorem measurable_cSup {ι} {f : ι → δ → α} {s : Set ι} (hs : s.Countable)\n    (hf : ∀ i, Measurable (f i)) (bdd : ∀ x, BddAbove ((fun i => f i x) '' s)) :\n    Measurable fun x => supₛ ((fun i => f i x) '' s) :=\n  by\n  cases' eq_empty_or_nonempty s with h2s h2s\n  · simp [h2s, measurable_const]\n  · apply measurable_of_Iic\n    intro y\n    simp_rw [preimage, mem_Iic, csupₛ_le_iff (bdd _) (h2s.image _), ball_image_iff, set_of_forall]\n    exact MeasurableSet.binterᵢ hs fun i hi => measurableSet_le (hf i) measurable_const\n#align measurable_cSup measurable_cSup\n\nend ConditionallyCompleteLinearOrder\n\n/-- Convert a `homeomorph` to a `measurable_equiv`. -/\ndef Homemorph.toMeasurableEquiv (h : α ≃ₜ β) : α ≃ᵐ β\n    where\n  toEquiv := h.toEquiv\n  measurable_to_fun := h.continuous_toFun.Measurable\n  measurable_inv_fun := h.continuous_invFun.Measurable\n#align homemorph.to_measurable_equiv Homemorph.toMeasurableEquiv\n\nprotected theorem IsFiniteMeasureOnCompacts.map {α : Type _} {m0 : MeasurableSpace α}\n    [TopologicalSpace α] [OpensMeasurableSpace α] {β : Type _} [MeasurableSpace β]\n    [TopologicalSpace β] [BorelSpace β] [T2Space β] (μ : Measure α) [IsFiniteMeasureOnCompacts μ]\n    (f : α ≃ₜ β) : IsFiniteMeasureOnCompacts (Measure.map f μ) :=\n  ⟨by\n    intro K hK\n    rw [measure.map_apply f.measurable hK.measurable_set]\n    apply IsCompact.measure_lt_top\n    rwa [f.is_compact_preimage]⟩\n#align is_finite_measure_on_compacts.map IsFiniteMeasureOnCompacts.map\n\nend BorelSpace\n\ninstance Empty.borelSpace : BorelSpace Empty :=\n  ⟨borel_eq_top_of_discrete.symm⟩\n#align empty.borel_space Empty.borelSpace\n\ninstance Unit.borelSpace : BorelSpace Unit :=\n  ⟨borel_eq_top_of_discrete.symm⟩\n#align unit.borel_space Unit.borelSpace\n\ninstance Bool.borelSpace : BorelSpace Bool :=\n  ⟨borel_eq_top_of_discrete.symm⟩\n#align bool.borel_space Bool.borelSpace\n\ninstance Nat.borelSpace : BorelSpace ℕ :=\n  ⟨borel_eq_top_of_discrete.symm⟩\n#align nat.borel_space Nat.borelSpace\n\ninstance Int.borelSpace : BorelSpace ℤ :=\n  ⟨borel_eq_top_of_discrete.symm⟩\n#align int.borel_space Int.borelSpace\n\ninstance Rat.borelSpace : BorelSpace ℚ :=\n  ⟨borel_eq_top_of_countable.symm⟩\n#align rat.borel_space Rat.borelSpace\n\ninstance (priority := 900) IsROrC.measurableSpace {𝕜 : Type _} [IsROrC 𝕜] : MeasurableSpace 𝕜 :=\n  borel 𝕜\n#align is_R_or_C.measurable_space IsROrC.measurableSpace\n\ninstance (priority := 900) IsROrC.borelSpace {𝕜 : Type _} [IsROrC 𝕜] : BorelSpace 𝕜 :=\n  ⟨rfl⟩\n#align is_R_or_C.borel_space IsROrC.borelSpace\n\n/- Instances on `real` and `complex` are special cases of `is_R_or_C` but without these instances,\nLean fails to prove `borel_space (ι → ℝ)`, so we leave them here. -/\ninstance Real.measurableSpace : MeasurableSpace ℝ :=\n  borel ℝ\n#align real.measurable_space Real.measurableSpace\n\ninstance Real.borelSpace : BorelSpace ℝ :=\n  ⟨rfl⟩\n#align real.borel_space Real.borelSpace\n\ninstance NNReal.measurableSpace : MeasurableSpace ℝ≥0 :=\n  Subtype.measurableSpace\n#align nnreal.measurable_space NNReal.measurableSpace\n\ninstance NNReal.borelSpace : BorelSpace ℝ≥0 :=\n  Subtype.borelSpace _\n#align nnreal.borel_space NNReal.borelSpace\n\ninstance ENNReal.measurableSpace : MeasurableSpace ℝ≥0∞ :=\n  borel ℝ≥0∞\n#align ennreal.measurable_space ENNReal.measurableSpace\n\ninstance ENNReal.borelSpace : BorelSpace ℝ≥0∞ :=\n  ⟨rfl⟩\n#align ennreal.borel_space ENNReal.borelSpace\n\ninstance EReal.measurableSpace : MeasurableSpace EReal :=\n  borel EReal\n#align ereal.measurable_space EReal.measurableSpace\n\ninstance EReal.borelSpace : BorelSpace EReal :=\n  ⟨rfl⟩\n#align ereal.borel_space EReal.borelSpace\n\ninstance Complex.measurableSpace : MeasurableSpace ℂ :=\n  borel ℂ\n#align complex.measurable_space Complex.measurableSpace\n\ninstance Complex.borelSpace : BorelSpace ℂ :=\n  ⟨rfl⟩\n#align complex.borel_space Complex.borelSpace\n\ninstance AddCircle.measurableSpace {a : ℝ} : MeasurableSpace (AddCircle a) :=\n  borel (AddCircle a)\n#align add_circle.measurable_space AddCircle.measurableSpace\n\ninstance AddCircle.borelSpace {a : ℝ} : BorelSpace (AddCircle a) :=\n  ⟨rfl⟩\n#align add_circle.borel_space AddCircle.borelSpace\n\n@[measurability]\nprotected theorem AddCircle.measurable_mk' {a : ℝ} : Measurable (coe : ℝ → AddCircle a) :=\n  Continuous.measurable <| AddCircle.continuous_mk' a\n#align add_circle.measurable_mk' AddCircle.measurable_mk'\n\n/-- One can cut out `ℝ≥0∞` into the sets `{0}`, `Ico (t^n) (t^(n+1))` for `n : ℤ` and `{∞}`. This\ngives a way to compute the measure of a set in terms of sets on which a given function `f` does not\nfluctuate by more than `t`. -/\ntheorem measure_eq_measure_preimage_add_measure_tsum_Ico_zpow [MeasurableSpace α] (μ : Measure α)\n    {f : α → ℝ≥0∞} (hf : Measurable f) {s : Set α} (hs : MeasurableSet s) {t : ℝ≥0} (ht : 1 < t) :\n    μ s =\n      μ (s ∩ f ⁻¹' {0}) + μ (s ∩ f ⁻¹' {∞}) + ∑' n : ℤ, μ (s ∩ f ⁻¹' Ico (t ^ n) (t ^ (n + 1))) :=\n  by\n  have A : μ s = μ (s ∩ f ⁻¹' {0}) + μ (s ∩ f ⁻¹' Ioi 0) :=\n    by\n    rw [← measure_union]\n    · congr 1\n      ext x\n      have : 0 = f x ∨ 0 < f x := eq_or_lt_of_le bot_le\n      rw [eq_comm] at this\n      simp only [← and_or_left, this, mem_singleton_iff, mem_inter_iff, and_true_iff, mem_union,\n        mem_Ioi, mem_preimage]\n    · apply disjoint_left.2 fun x hx h'x => _\n      have : 0 < f x := h'x.2\n      exact lt_irrefl 0 (this.trans_le hx.2.le)\n    · exact hs.inter (hf measurableSet_Ioi)\n  have B : μ (s ∩ f ⁻¹' Ioi 0) = μ (s ∩ f ⁻¹' {∞}) + μ (s ∩ f ⁻¹' Ioo 0 ∞) :=\n    by\n    rw [← measure_union]\n    · rw [← inter_union_distrib_left]\n      congr\n      ext x\n      simp only [mem_singleton_iff, mem_union, mem_Ioo, mem_Ioi, mem_preimage]\n      have H : f x = ∞ ∨ f x < ∞ := eq_or_lt_of_le le_top\n      cases H\n      ·\n        simp only [H, eq_self_iff_true, or_false_iff, WithTop.zero_lt_top, not_top_lt,\n          and_false_iff]\n      · simp only [H, H.ne, and_true_iff, false_or_iff]\n    · apply disjoint_left.2 fun x hx h'x => _\n      have : f x < ∞ := h'x.2.2\n      exact lt_irrefl _ (this.trans_le (le_of_eq hx.2.symm))\n    · exact hs.inter (hf measurableSet_Ioo)\n  have C : μ (s ∩ f ⁻¹' Ioo 0 ∞) = ∑' n : ℤ, μ (s ∩ f ⁻¹' Ico (t ^ n) (t ^ (n + 1))) :=\n    by\n    rw [← measure_Union,\n      ENNReal.Ioo_zero_top_eq_unionᵢ_Ico_zpow (ENNReal.one_lt_coe_iff.2 ht) ENNReal.coe_ne_top,\n      preimage_Union, inter_Union]\n    · intro i j\n      simp only [Function.onFun]\n      intro hij\n      wlog h : i < j generalizing i j\n      · exact (this hij.symm (hij.lt_or_lt.resolve_left h)).symm\n      apply disjoint_left.2 fun x hx h'x => lt_irrefl (f x) _\n      calc\n        f x < t ^ (i + 1) := hx.2.2\n        _ ≤ t ^ j := (ENNReal.zpow_le_of_le (ENNReal.one_le_coe_iff.2 ht.le) h)\n        _ ≤ f x := h'x.2.1\n        \n    · intro n\n      exact hs.inter (hf measurableSet_Ico)\n  rw [A, B, C, add_assoc]\n#align measure_eq_measure_preimage_add_measure_tsum_Ico_zpow measure_eq_measure_preimage_add_measure_tsum_Ico_zpow\n\nsection PseudoMetricSpace\n\nvariable [PseudoMetricSpace α] [MeasurableSpace α] [OpensMeasurableSpace α]\n\nvariable [MeasurableSpace β] {x : α} {ε : ℝ}\n\nopen Metric\n\n@[measurability]\ntheorem measurableSet_ball : MeasurableSet (Metric.ball x ε) :=\n  Metric.isOpen_ball.MeasurableSet\n#align measurable_set_ball measurableSet_ball\n\n@[measurability]\ntheorem measurableSet_closedBall : MeasurableSet (Metric.closedBall x ε) :=\n  Metric.isClosed_ball.MeasurableSet\n#align measurable_set_closed_ball measurableSet_closedBall\n\n@[measurability]\ntheorem measurable_infDist {s : Set α} : Measurable fun x => infDist x s :=\n  (continuous_infDist_pt s).Measurable\n#align measurable_inf_dist measurable_infDist\n\n@[measurability]\ntheorem Measurable.infDist {f : β → α} (hf : Measurable f) {s : Set α} :\n    Measurable fun x => infDist (f x) s :=\n  measurable_infDist.comp hf\n#align measurable.inf_dist Measurable.infDist\n\n@[measurability]\ntheorem measurable_infNndist {s : Set α} : Measurable fun x => infNndist x s :=\n  (continuous_infNndist_pt s).Measurable\n#align measurable_inf_nndist measurable_infNndist\n\n@[measurability]\ntheorem Measurable.infNndist {f : β → α} (hf : Measurable f) {s : Set α} :\n    Measurable fun x => infNndist (f x) s :=\n  measurable_infNndist.comp hf\n#align measurable.inf_nndist Measurable.infNndist\n\nsection\n\nvariable [SecondCountableTopology α]\n\n@[measurability]\ntheorem measurable_dist : Measurable fun p : α × α => dist p.1 p.2 :=\n  continuous_dist.Measurable\n#align measurable_dist measurable_dist\n\n@[measurability]\ntheorem Measurable.dist {f g : β → α} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun b => dist (f b) (g b) :=\n  (@continuous_dist α _).measurable2 hf hg\n#align measurable.dist Measurable.dist\n\n@[measurability]\ntheorem measurable_nndist : Measurable fun p : α × α => nndist p.1 p.2 :=\n  continuous_nndist.Measurable\n#align measurable_nndist measurable_nndist\n\n@[measurability]\ntheorem Measurable.nndist {f g : β → α} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun b => nndist (f b) (g b) :=\n  (@continuous_nndist α _).measurable2 hf hg\n#align measurable.nndist Measurable.nndist\n\nend\n\n/-- If a set has a closed thickening with finite measure, then the measure of its `r`-closed\nthickenings converges to the measure of its closure as `r` tends to `0`. -/\ntheorem tendsto_measure_cthickening {μ : Measure α} {s : Set α}\n    (hs : ∃ R > 0, μ (cthickening R s) ≠ ∞) :\n    Tendsto (fun r => μ (cthickening r s)) (𝓝 0) (𝓝 (μ (closure s))) :=\n  by\n  have A : tendsto (fun r => μ (cthickening r s)) (𝓝[Ioi 0] 0) (𝓝 (μ (closure s))) :=\n    by\n    rw [closure_eq_Inter_cthickening]\n    exact\n      tendsto_measure_bInter_gt (fun r hr => is_closed_cthickening.measurable_set)\n        (fun i j ipos ij => cthickening_mono ij _) hs\n  have B : tendsto (fun r => μ (cthickening r s)) (𝓝[Iic 0] 0) (𝓝 (μ (closure s))) :=\n    by\n    apply tendsto.congr' _ tendsto_const_nhds\n    filter_upwards [self_mem_nhdsWithin]with _ hr\n    rw [cthickening_of_nonpos hr]\n  convert B.sup A\n  exact (nhds_left_sup_nhds_right' 0).symm\n#align tendsto_measure_cthickening tendsto_measure_cthickening\n\n/-- If a closed set has a closed thickening with finite measure, then the measure of its `r`-closed\nthickenings converges to its measure as `r` tends to `0`. -/\ntheorem tendsto_measure_cthickening_of_isClosed {μ : Measure α} {s : Set α}\n    (hs : ∃ R > 0, μ (cthickening R s) ≠ ∞) (h's : IsClosed s) :\n    Tendsto (fun r => μ (cthickening r s)) (𝓝 0) (𝓝 (μ s)) :=\n  by\n  convert tendsto_measure_cthickening hs\n  exact h's.closure_eq.symm\n#align tendsto_measure_cthickening_of_is_closed tendsto_measure_cthickening_of_isClosed\n\nend PseudoMetricSpace\n\n/-- Given a compact set in a proper space, the measure of its `r`-closed thickenings converges to\nits measure as `r` tends to `0`. -/\ntheorem tendsto_measure_cthickening_of_isCompact [MetricSpace α] [MeasurableSpace α]\n    [OpensMeasurableSpace α] [ProperSpace α] {μ : Measure α} [IsFiniteMeasureOnCompacts μ]\n    {s : Set α} (hs : IsCompact s) :\n    Tendsto (fun r => μ (Metric.cthickening r s)) (𝓝 0) (𝓝 (μ s)) :=\n  tendsto_measure_cthickening_of_isClosed ⟨1, zero_lt_one, hs.Bounded.cthickening.measure_lt_top.Ne⟩\n    hs.IsClosed\n#align tendsto_measure_cthickening_of_is_compact tendsto_measure_cthickening_of_isCompact\n\nsection PseudoEMetricSpace\n\nvariable [PseudoEMetricSpace α] [MeasurableSpace α] [OpensMeasurableSpace α]\n\nvariable [MeasurableSpace β] {x : α} {ε : ℝ≥0∞}\n\nopen Emetric\n\n@[measurability]\ntheorem measurableSet_eball : MeasurableSet (EMetric.ball x ε) :=\n  EMetric.isOpen_ball.MeasurableSet\n#align measurable_set_eball measurableSet_eball\n\n@[measurability]\ntheorem measurable_edist_right : Measurable (edist x) :=\n  (continuous_const.edist continuous_id).Measurable\n#align measurable_edist_right measurable_edist_right\n\n@[measurability]\ntheorem measurable_edist_left : Measurable fun y => edist y x :=\n  (continuous_id.edist continuous_const).Measurable\n#align measurable_edist_left measurable_edist_left\n\n@[measurability]\ntheorem measurable_infEdist {s : Set α} : Measurable fun x => infEdist x s :=\n  continuous_infEdist.Measurable\n#align measurable_inf_edist measurable_infEdist\n\n@[measurability]\ntheorem Measurable.infEdist {f : β → α} (hf : Measurable f) {s : Set α} :\n    Measurable fun x => infEdist (f x) s :=\n  measurable_infEdist.comp hf\n#align measurable.inf_edist Measurable.infEdist\n\nvariable [SecondCountableTopology α]\n\n@[measurability]\ntheorem measurable_edist : Measurable fun p : α × α => edist p.1 p.2 :=\n  continuous_edist.Measurable\n#align measurable_edist measurable_edist\n\n@[measurability]\ntheorem Measurable.edist {f g : β → α} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun b => edist (f b) (g b) :=\n  (@continuous_edist α _).measurable2 hf hg\n#align measurable.edist Measurable.edist\n\n@[measurability]\ntheorem AeMeasurable.edist {f g : β → α} {μ : Measure β} (hf : AeMeasurable f μ)\n    (hg : AeMeasurable g μ) : AeMeasurable (fun a => edist (f a) (g a)) μ :=\n  (@continuous_edist α _).aeMeasurable2 hf hg\n#align ae_measurable.edist AeMeasurable.edist\n\nend PseudoEMetricSpace\n\nnamespace Real\n\nopen MeasurableSpace MeasureTheory\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (a b) -/\ntheorem borel_eq_generateFrom_Ioo_rat :\n    borel ℝ = generateFrom (⋃ (a : ℚ) (b : ℚ) (h : a < b), {Ioo a b}) :=\n  isTopologicalBasis_Ioo_rat.borel_eq_generateFrom\n#align real.borel_eq_generate_from_Ioo_rat Real.borel_eq_generateFrom_Ioo_rat\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (a b) -/\ntheorem isPiSystem_Ioo_rat : @IsPiSystem ℝ (⋃ (a : ℚ) (b : ℚ) (h : a < b), {Ioo a b}) :=\n  by\n  convert isPiSystem_Ioo (coe : ℚ → ℝ) (coe : ℚ → ℝ)\n  ext x\n  simp [eq_comm]\n#align real.is_pi_system_Ioo_rat Real.isPiSystem_Ioo_rat\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (a b) -/\n/-- The intervals `(-(n + 1), (n + 1))` form a finite spanning sets in the set of open intervals\nwith rational endpoints for a locally finite measure `μ` on `ℝ`. -/\ndef finiteSpanningSetsInIooRat (μ : Measure ℝ) [IsLocallyFiniteMeasure μ] :\n    μ.FiniteSpanningSetsIn (⋃ (a : ℚ) (b : ℚ) (h : a < b), {Ioo a b})\n    where\n  Set n := Ioo (-(n + 1)) (n + 1)\n  set_mem n := by\n    simp only [mem_Union, mem_singleton_iff]\n    refine' ⟨-(n + 1 : ℕ), n + 1, _, by simp⟩\n    -- TODO: norm_cast fails here?\n    exact (neg_nonpos.2 (@Nat.cast_nonneg ℚ _ (n + 1))).trans_lt n.cast_add_one_pos\n  Finite n := measure_Ioo_lt_top\n  spanning :=\n    unionᵢ_eq_univ_iff.2 fun x =>\n      ⟨⌊|x|⌋₊, neg_lt.1 ((neg_le_abs_self x).trans_lt (Nat.lt_floor_add_one _)),\n        (le_abs_self x).trans_lt (Nat.lt_floor_add_one _)⟩\n#align real.finite_spanning_sets_in_Ioo_rat Real.finiteSpanningSetsInIooRat\n\ntheorem measure_ext_Ioo_rat {μ ν : Measure ℝ} [IsLocallyFiniteMeasure μ]\n    (h : ∀ a b : ℚ, μ (Ioo a b) = ν (Ioo a b)) : μ = ν :=\n  (finiteSpanningSetsInIooRat μ).ext borel_eq_generateFrom_Ioo_rat isPiSystem_Ioo_rat <|\n    by\n    simp only [mem_Union, mem_singleton_iff]\n    rintro _ ⟨a, b, -, rfl⟩\n    apply h\n#align real.measure_ext_Ioo_rat Real.measure_ext_Ioo_rat\n\ntheorem borel_eq_generateFrom_Iio_rat : borel ℝ = generateFrom (⋃ a : ℚ, {Iio a}) :=\n  by\n  let g : MeasurableSpace ℝ := generate_from (⋃ a : ℚ, {Iio a})\n  refine' le_antisymm _ _\n  · rw [borel_eq_generate_from_Ioo_rat]\n    refine' generate_from_le fun t => _\n    simp only [mem_Union, mem_singleton_iff]\n    rintro ⟨a, b, h, rfl⟩\n    rw [(Set.ext fun x => _ : Ioo (a : ℝ) b = (⋃ c > a, Iio cᶜ) ∩ Iio b)]\n    · have hg : ∀ q : ℚ, measurable_set[g] (Iio q) := fun q =>\n        generate_measurable.basic (Iio q) (by simp)\n      refine' @MeasurableSet.inter _ g _ _ _ (hg _)\n      refine' @MeasurableSet.bunionᵢ _ _ g _ _ (to_countable _) fun c h => _\n      exact @MeasurableSet.compl _ _ g (hg _)\n    · suffices x < ↑b → (↑a < x ↔ ∃ i : ℚ, a < i ∧ ↑i ≤ x) by simpa\n      refine' fun _ => ⟨fun h => _, fun ⟨i, hai, hix⟩ => (Rat.cast_lt.2 hai).trans_le hix⟩\n      rcases exists_rat_btwn h with ⟨c, ac, cx⟩\n      exact ⟨c, Rat.cast_lt.1 ac, cx.le⟩\n  · refine' MeasurableSpace.generateFrom_le fun _ => _\n    simp only [mem_Union, mem_singleton_iff]\n    rintro ⟨r, rfl⟩\n    exact measurableSet_Iio\n#align real.borel_eq_generate_from_Iio_rat Real.borel_eq_generateFrom_Iio_rat\n\nend Real\n\nvariable [MeasurableSpace α]\n\n@[measurability]\ntheorem measurable_real_toNNReal : Measurable Real.toNNReal :=\n  continuous_real_toNNReal.Measurable\n#align measurable_real_to_nnreal measurable_real_toNNReal\n\n@[measurability]\ntheorem Measurable.real_toNNReal {f : α → ℝ} (hf : Measurable f) :\n    Measurable fun x => Real.toNNReal (f x) :=\n  measurable_real_toNNReal.comp hf\n#align measurable.real_to_nnreal Measurable.real_toNNReal\n\n@[measurability]\ntheorem AeMeasurable.realToNnreal {f : α → ℝ} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => Real.toNNReal (f x)) μ :=\n  measurable_real_toNNReal.compAeMeasurable hf\n#align ae_measurable.real_to_nnreal AeMeasurable.realToNnreal\n\n@[measurability]\ntheorem measurable_coe_nNReal_real : Measurable (coe : ℝ≥0 → ℝ) :=\n  NNReal.continuous_coe.Measurable\n#align measurable_coe_nnreal_real measurable_coe_nNReal_real\n\n@[measurability]\ntheorem Measurable.coe_nNReal_real {f : α → ℝ≥0} (hf : Measurable f) :\n    Measurable fun x => (f x : ℝ) :=\n  measurable_coe_nNReal_real.comp hf\n#align measurable.coe_nnreal_real Measurable.coe_nNReal_real\n\n@[measurability]\ntheorem AeMeasurable.coeNnrealReal {f : α → ℝ≥0} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => (f x : ℝ)) μ :=\n  measurable_coe_nNReal_real.compAeMeasurable hf\n#align ae_measurable.coe_nnreal_real AeMeasurable.coeNnrealReal\n\n@[measurability]\ntheorem measurable_coe_nNReal_eNNReal : Measurable (coe : ℝ≥0 → ℝ≥0∞) :=\n  ENNReal.continuous_coe.Measurable\n#align measurable_coe_nnreal_ennreal measurable_coe_nNReal_eNNReal\n\n@[measurability]\ntheorem Measurable.coe_nNReal_eNNReal {f : α → ℝ≥0} (hf : Measurable f) :\n    Measurable fun x => (f x : ℝ≥0∞) :=\n  ENNReal.continuous_coe.Measurable.comp hf\n#align measurable.coe_nnreal_ennreal Measurable.coe_nNReal_eNNReal\n\n@[measurability]\ntheorem AeMeasurable.coeNnrealEnnreal {f : α → ℝ≥0} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => (f x : ℝ≥0∞)) μ :=\n  ENNReal.continuous_coe.Measurable.compAeMeasurable hf\n#align ae_measurable.coe_nnreal_ennreal AeMeasurable.coeNnrealEnnreal\n\n@[measurability]\ntheorem Measurable.eNNReal_ofReal {f : α → ℝ} (hf : Measurable f) :\n    Measurable fun x => ENNReal.ofReal (f x) :=\n  ENNReal.continuous_ofReal.Measurable.comp hf\n#align measurable.ennreal_of_real Measurable.eNNReal_ofReal\n\n@[simp, norm_cast]\ntheorem measurable_coe_nNReal_real_iff {f : α → ℝ≥0} :\n    Measurable (fun x => f x : α → ℝ) ↔ Measurable f :=\n  ⟨fun h => by simpa only [Real.toNNReal_coe] using h.real_to_nnreal, Measurable.coe_nNReal_real⟩\n#align measurable_coe_nnreal_real_iff measurable_coe_nNReal_real_iff\n\n@[simp, norm_cast]\ntheorem aeMeasurable_coe_nNReal_real_iff {f : α → ℝ≥0} {μ : Measure α} :\n    AeMeasurable (fun x => f x : α → ℝ) μ ↔ AeMeasurable f μ :=\n  ⟨fun h => by simpa only [Real.toNNReal_coe] using h.real_to_nnreal, AeMeasurable.coeNnrealReal⟩\n#align ae_measurable_coe_nnreal_real_iff aeMeasurable_coe_nNReal_real_iff\n\n/-- The set of finite `ℝ≥0∞` numbers is `measurable_equiv` to `ℝ≥0`. -/\ndef MeasurableEquiv.ennrealEquivNnreal : { r : ℝ≥0∞ | r ≠ ∞ } ≃ᵐ ℝ≥0 :=\n  ENNReal.neTopHomeomorphNNReal.toMeasurableEquiv\n#align measurable_equiv.ennreal_equiv_nnreal MeasurableEquiv.ennrealEquivNnreal\n\nnamespace ENNReal\n\ntheorem measurable_of_measurable_nNReal {f : ℝ≥0∞ → α} (h : Measurable fun p : ℝ≥0 => f p) :\n    Measurable f :=\n  measurable_of_measurable_on_compl_singleton ∞\n    (MeasurableEquiv.ennrealEquivNnreal.symm.measurable_comp_iff.1 h)\n#align ennreal.measurable_of_measurable_nnreal ENNReal.measurable_of_measurable_nNReal\n\n/-- `ℝ≥0∞` is `measurable_equiv` to `ℝ≥0 ⊕ unit`. -/\ndef ennrealEquivSum : ℝ≥0∞ ≃ᵐ Sum ℝ≥0 Unit :=\n  {\n    Equiv.optionEquivSumPUnit\n      ℝ≥0 with\n    measurable_to_fun := measurable_of_measurable_nNReal measurable_inl\n    measurable_inv_fun :=\n      measurable_sum measurable_coe_nNReal_eNNReal (@measurable_const ℝ≥0∞ Unit _ _ ∞) }\n#align ennreal.ennreal_equiv_sum ENNReal.ennrealEquivSum\n\nopen Function (uncurry)\n\ntheorem measurable_of_measurable_nNReal_prod [MeasurableSpace β] [MeasurableSpace γ]\n    {f : ℝ≥0∞ × β → γ} (H₁ : Measurable fun p : ℝ≥0 × β => f (p.1, p.2))\n    (H₂ : Measurable fun x => f (∞, x)) : Measurable f :=\n  let e : ℝ≥0∞ × β ≃ᵐ Sum (ℝ≥0 × β) (Unit × β) :=\n    (ennrealEquivSum.prodCongr (MeasurableEquiv.refl β)).trans\n      (MeasurableEquiv.sumProdDistrib _ _ _)\n  e.symm.measurable_comp_iff.1 <| measurable_sum H₁ (H₂.comp measurable_id.snd)\n#align ennreal.measurable_of_measurable_nnreal_prod ENNReal.measurable_of_measurable_nNReal_prod\n\ntheorem measurable_of_measurable_nNReal_nNReal [MeasurableSpace β] {f : ℝ≥0∞ × ℝ≥0∞ → β}\n    (h₁ : Measurable fun p : ℝ≥0 × ℝ≥0 => f (p.1, p.2)) (h₂ : Measurable fun r : ℝ≥0 => f (∞, r))\n    (h₃ : Measurable fun r : ℝ≥0 => f (r, ∞)) : Measurable f :=\n  measurable_of_measurable_nNReal_prod\n    (measurable_swap_iff.1 <| measurable_of_measurable_nNReal_prod (h₁.comp measurable_swap) h₃)\n    (measurable_of_measurable_nNReal h₂)\n#align ennreal.measurable_of_measurable_nnreal_nnreal ENNReal.measurable_of_measurable_nNReal_nNReal\n\n@[measurability]\ntheorem measurable_ofReal : Measurable ENNReal.ofReal :=\n  ENNReal.continuous_ofReal.Measurable\n#align ennreal.measurable_of_real ENNReal.measurable_ofReal\n\n@[measurability]\ntheorem measurable_toReal : Measurable ENNReal.toReal :=\n  ENNReal.measurable_of_measurable_nNReal measurable_coe_nNReal_real\n#align ennreal.measurable_to_real ENNReal.measurable_toReal\n\n@[measurability]\ntheorem measurable_toNNReal : Measurable ENNReal.toNNReal :=\n  ENNReal.measurable_of_measurable_nNReal measurable_id\n#align ennreal.measurable_to_nnreal ENNReal.measurable_toNNReal\n\ninstance : HasMeasurableMul₂ ℝ≥0∞ :=\n  by\n  refine' ⟨measurable_of_measurable_nnreal_nnreal _ _ _⟩\n  · simp only [← ENNReal.coe_mul, measurable_mul.coe_nnreal_ennreal]\n  · simp only [ENNReal.top_mul', ENNReal.coe_eq_zero]\n    exact measurable_const.piecewise (measurable_set_singleton _) measurable_const\n  · simp only [ENNReal.mul_top', ENNReal.coe_eq_zero]\n    exact measurable_const.piecewise (measurable_set_singleton _) measurable_const\n\ninstance : HasMeasurableSub₂ ℝ≥0∞ :=\n  ⟨by\n    apply measurable_of_measurable_nnreal_nnreal <;>\n      simp [← WithTop.coe_sub, continuous_sub.measurable.coe_nnreal_ennreal]⟩\n\ninstance : HasMeasurableInv ℝ≥0∞ :=\n  ⟨continuous_inv.Measurable⟩\n\nend ENNReal\n\n@[measurability]\ntheorem Measurable.eNNReal_toNNReal {f : α → ℝ≥0∞} (hf : Measurable f) :\n    Measurable fun x => (f x).toNNReal :=\n  ENNReal.measurable_toNNReal.comp hf\n#align measurable.ennreal_to_nnreal Measurable.eNNReal_toNNReal\n\n@[measurability]\ntheorem AeMeasurable.ennrealToNnreal {f : α → ℝ≥0∞} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => (f x).toNNReal) μ :=\n  ENNReal.measurable_toNNReal.compAeMeasurable hf\n#align ae_measurable.ennreal_to_nnreal AeMeasurable.ennrealToNnreal\n\n@[simp, norm_cast]\ntheorem measurable_coe_nNReal_eNNReal_iff {f : α → ℝ≥0} :\n    (Measurable fun x => (f x : ℝ≥0∞)) ↔ Measurable f :=\n  ⟨fun h => h.eNNReal_toNNReal, fun h => h.coe_nNReal_eNNReal⟩\n#align measurable_coe_nnreal_ennreal_iff measurable_coe_nNReal_eNNReal_iff\n\n@[simp, norm_cast]\ntheorem aeMeasurable_coe_nNReal_eNNReal_iff {f : α → ℝ≥0} {μ : Measure α} :\n    AeMeasurable (fun x => (f x : ℝ≥0∞)) μ ↔ AeMeasurable f μ :=\n  ⟨fun h => h.eNNReal_toNNReal, fun h => h.coe_nNReal_eNNReal⟩\n#align ae_measurable_coe_nnreal_ennreal_iff aeMeasurable_coe_nNReal_eNNReal_iff\n\n@[measurability]\ntheorem Measurable.eNNReal_toReal {f : α → ℝ≥0∞} (hf : Measurable f) :\n    Measurable fun x => ENNReal.toReal (f x) :=\n  ENNReal.measurable_toReal.comp hf\n#align measurable.ennreal_to_real Measurable.eNNReal_toReal\n\n@[measurability]\ntheorem AeMeasurable.ennrealToReal {f : α → ℝ≥0∞} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => ENNReal.toReal (f x)) μ :=\n  ENNReal.measurable_toReal.compAeMeasurable hf\n#align ae_measurable.ennreal_to_real AeMeasurable.ennrealToReal\n\n/-- note: `ℝ≥0∞` can probably be generalized in a future version of this lemma. -/\n@[measurability]\ntheorem Measurable.eNNReal_tsum {ι} [Countable ι] {f : ι → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) :\n    Measurable fun x => ∑' i, f i x :=\n  by\n  simp_rw [ENNReal.tsum_eq_supᵢ_sum]\n  apply measurable_supᵢ\n  exact fun s => s.measurable_sum fun i _ => h i\n#align measurable.ennreal_tsum Measurable.eNNReal_tsum\n\n@[measurability]\ntheorem Measurable.eNNReal_tsum' {ι} [Countable ι] {f : ι → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) :\n    Measurable (∑' i, f i) := by\n  convert Measurable.eNNReal_tsum h\n  ext1 x\n  exact tsum_apply (Pi.summable.2 fun _ => ENNReal.summable)\n#align measurable.ennreal_tsum' Measurable.eNNReal_tsum'\n\n@[measurability]\ntheorem Measurable.nNReal_tsum {ι} [Countable ι] {f : ι → α → ℝ≥0} (h : ∀ i, Measurable (f i)) :\n    Measurable fun x => ∑' i, f i x :=\n  by\n  simp_rw [NNReal.tsum_eq_toNNReal_tsum]\n  exact (Measurable.eNNReal_tsum fun i => (h i).coe_nNReal_eNNReal).eNNReal_toNNReal\n#align measurable.nnreal_tsum Measurable.nNReal_tsum\n\n@[measurability]\ntheorem AeMeasurable.ennrealTsum {ι} [Countable ι] {f : ι → α → ℝ≥0∞} {μ : Measure α}\n    (h : ∀ i, AeMeasurable (f i) μ) : AeMeasurable (fun x => ∑' i, f i x) μ :=\n  by\n  simp_rw [ENNReal.tsum_eq_supᵢ_sum]\n  apply aeMeasurableSupr\n  exact fun s => Finset.ae_measurable_sum s fun i _ => h i\n#align ae_measurable.ennreal_tsum AeMeasurable.ennrealTsum\n\n@[measurability]\ntheorem AeMeasurable.nnrealTsum {α : Type _} [MeasurableSpace α] {ι : Type _} [Countable ι]\n    {f : ι → α → NNReal} {μ : MeasureTheory.Measure α} (h : ∀ i : ι, AeMeasurable (f i) μ) :\n    AeMeasurable (fun x : α => ∑' i : ι, f i x) μ :=\n  by\n  simp_rw [NNReal.tsum_eq_toNNReal_tsum]\n  exact (AeMeasurable.ennrealTsum fun i => (h i).coe_nNReal_eNNReal).eNNReal_toNNReal\n#align ae_measurable.nnreal_tsum AeMeasurable.nnrealTsum\n\n@[measurability]\ntheorem measurable_coe_real_eReal : Measurable (coe : ℝ → EReal) :=\n  continuous_coe_real_ereal.Measurable\n#align measurable_coe_real_ereal measurable_coe_real_eReal\n\n@[measurability]\ntheorem Measurable.coe_real_eReal {f : α → ℝ} (hf : Measurable f) :\n    Measurable fun x => (f x : EReal) :=\n  measurable_coe_real_eReal.comp hf\n#align measurable.coe_real_ereal Measurable.coe_real_eReal\n\n@[measurability]\ntheorem AeMeasurable.coeRealEreal {f : α → ℝ} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => (f x : EReal)) μ :=\n  measurable_coe_real_eReal.compAeMeasurable hf\n#align ae_measurable.coe_real_ereal AeMeasurable.coeRealEreal\n\n/-- The set of finite `ereal` numbers is `measurable_equiv` to `ℝ`. -/\ndef MeasurableEquiv.erealEquivReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ᵐ ℝ :=\n  EReal.neBotTopHomeomorphReal.toMeasurableEquiv\n#align measurable_equiv.ereal_equiv_real MeasurableEquiv.erealEquivReal\n\ntheorem EReal.measurable_of_measurable_real {f : EReal → α} (h : Measurable fun p : ℝ => f p) :\n    Measurable f :=\n  measurable_of_measurable_on_compl_finite {⊥, ⊤} (by simp)\n    (MeasurableEquiv.erealEquivReal.symm.measurable_comp_iff.1 h)\n#align ereal.measurable_of_measurable_real EReal.measurable_of_measurable_real\n\n@[measurability]\ntheorem measurable_eReal_toReal : Measurable EReal.toReal :=\n  EReal.measurable_of_measurable_real (by simpa using measurable_id)\n#align measurable_ereal_to_real measurable_eReal_toReal\n\n@[measurability]\ntheorem Measurable.eReal_toReal {f : α → EReal} (hf : Measurable f) :\n    Measurable fun x => (f x).toReal :=\n  measurable_eReal_toReal.comp hf\n#align measurable.ereal_to_real Measurable.eReal_toReal\n\n@[measurability]\ntheorem AeMeasurable.erealToReal {f : α → EReal} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => (f x).toReal) μ :=\n  measurable_eReal_toReal.compAeMeasurable hf\n#align ae_measurable.ereal_to_real AeMeasurable.erealToReal\n\n@[measurability]\ntheorem measurable_coe_eNNReal_eReal : Measurable (coe : ℝ≥0∞ → EReal) :=\n  continuous_coe_ennreal_ereal.Measurable\n#align measurable_coe_ennreal_ereal measurable_coe_eNNReal_eReal\n\n@[measurability]\ntheorem Measurable.coe_eReal_eNNReal {f : α → ℝ≥0∞} (hf : Measurable f) :\n    Measurable fun x => (f x : EReal) :=\n  measurable_coe_eNNReal_eReal.comp hf\n#align measurable.coe_ereal_ennreal Measurable.coe_eReal_eNNReal\n\n@[measurability]\ntheorem AeMeasurable.coeErealEnnreal {f : α → ℝ≥0∞} {μ : Measure α} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun x => (f x : EReal)) μ :=\n  measurable_coe_eNNReal_eReal.compAeMeasurable hf\n#align ae_measurable.coe_ereal_ennreal AeMeasurable.coeErealEnnreal\n\nsection NormedAddCommGroup\n\nvariable [NormedAddCommGroup α] [OpensMeasurableSpace α] [MeasurableSpace β]\n\n@[measurability]\ntheorem measurable_norm : Measurable (norm : α → ℝ) :=\n  continuous_norm.Measurable\n#align measurable_norm measurable_norm\n\n@[measurability]\ntheorem Measurable.norm {f : β → α} (hf : Measurable f) : Measurable fun a => norm (f a) :=\n  measurable_norm.comp hf\n#align measurable.norm Measurable.norm\n\n@[measurability]\ntheorem AeMeasurable.norm {f : β → α} {μ : Measure β} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun a => norm (f a)) μ :=\n  measurable_norm.compAeMeasurable hf\n#align ae_measurable.norm AeMeasurable.norm\n\n@[measurability]\ntheorem measurable_nnnorm : Measurable (nnnorm : α → ℝ≥0) :=\n  continuous_nnnorm.Measurable\n#align measurable_nnnorm measurable_nnnorm\n\n@[measurability]\ntheorem Measurable.nnnorm {f : β → α} (hf : Measurable f) : Measurable fun a => ‖f a‖₊ :=\n  measurable_nnnorm.comp hf\n#align measurable.nnnorm Measurable.nnnorm\n\n@[measurability]\ntheorem AeMeasurable.nnnorm {f : β → α} {μ : Measure β} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun a => ‖f a‖₊) μ :=\n  measurable_nnnorm.compAeMeasurable hf\n#align ae_measurable.nnnorm AeMeasurable.nnnorm\n\n@[measurability]\ntheorem measurable_ennnorm : Measurable fun x : α => (‖x‖₊ : ℝ≥0∞) :=\n  measurable_nnnorm.coe_nNReal_eNNReal\n#align measurable_ennnorm measurable_ennnorm\n\n@[measurability]\ntheorem Measurable.ennnorm {f : β → α} (hf : Measurable f) : Measurable fun a => (‖f a‖₊ : ℝ≥0∞) :=\n  hf.nnnorm.coe_nNReal_eNNReal\n#align measurable.ennnorm Measurable.ennnorm\n\n@[measurability]\ntheorem AeMeasurable.ennnorm {f : β → α} {μ : Measure β} (hf : AeMeasurable f μ) :\n    AeMeasurable (fun a => (‖f a‖₊ : ℝ≥0∞)) μ :=\n  measurable_ennnorm.compAeMeasurable hf\n#align ae_measurable.ennnorm AeMeasurable.ennnorm\n\nend NormedAddCommGroup\n\nsection Limits\n\nvariable [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β]\n\nopen Metric\n\n/-- A limit (over a general filter) of measurable `ℝ≥0∞` valued functions is measurable. -/\ntheorem measurable_of_tendsto_ennreal' {ι} {f : ι → α → ℝ≥0∞} {g : α → ℝ≥0∞} (u : Filter ι)\n    [NeBot u] [IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) :\n    Measurable g := by\n  rcases u.exists_seq_tendsto with ⟨x, hx⟩\n  rw [tendsto_pi_nhds] at lim\n  have : (fun y => liminf (fun n => (f (x n) y : ℝ≥0∞)) at_top) = g :=\n    by\n    ext1 y\n    exact ((limUnder y).comp hx).liminf_eq\n  rw [← this]\n  show Measurable fun y => liminf (fun n => (f (x n) y : ℝ≥0∞)) at_top\n  exact measurable_liminf fun n => hf (x n)\n#align measurable_of_tendsto_ennreal' measurable_of_tendsto_ennreal'\n\n/-- A sequential limit of measurable `ℝ≥0∞` valued functions is measurable. -/\ntheorem measurable_of_tendsto_eNNReal {f : ℕ → α → ℝ≥0∞} {g : α → ℝ≥0∞} (hf : ∀ i, Measurable (f i))\n    (lim : Tendsto f atTop (𝓝 g)) : Measurable g :=\n  measurable_of_tendsto_ennreal' atTop hf limUnder\n#align measurable_of_tendsto_ennreal measurable_of_tendsto_eNNReal\n\n/-- A limit (over a general filter) of measurable `ℝ≥0` valued functions is measurable. -/\ntheorem measurable_of_tendsto_nnreal' {ι} {f : ι → α → ℝ≥0} {g : α → ℝ≥0} (u : Filter ι) [NeBot u]\n    [IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) :\n    Measurable g := by\n  simp_rw [← measurable_coe_nNReal_eNNReal_iff] at hf⊢\n  refine' measurable_of_tendsto_ennreal' u hf _\n  rw [tendsto_pi_nhds] at lim⊢\n  exact fun x => (ennreal.continuous_coe.tendsto (g x)).comp (limUnder x)\n#align measurable_of_tendsto_nnreal' measurable_of_tendsto_nnreal'\n\n/-- A sequential limit of measurable `ℝ≥0` valued functions is measurable. -/\ntheorem measurable_of_tendsto_nNReal {f : ℕ → α → ℝ≥0} {g : α → ℝ≥0} (hf : ∀ i, Measurable (f i))\n    (lim : Tendsto f atTop (𝓝 g)) : Measurable g :=\n  measurable_of_tendsto_nnreal' atTop hf limUnder\n#align measurable_of_tendsto_nnreal measurable_of_tendsto_nNReal\n\n/-- A limit (over a general filter) of measurable functions valued in a (pseudo) metrizable space is\nmeasurable. -/\ntheorem measurable_of_tendsto_metrizable' {ι} {f : ι → α → β} {g : α → β} (u : Filter ι) [NeBot u]\n    [IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) :\n    Measurable g :=\n  by\n  letI : PseudoMetricSpace β := pseudo_metrizable_space_pseudo_metric β\n  apply measurable_of_is_closed'\n  intro s h1s h2s h3s\n  have : Measurable fun x => inf_nndist (g x) s :=\n    by\n    suffices : tendsto (fun i x => inf_nndist (f i x) s) u (𝓝 fun x => inf_nndist (g x) s)\n    exact measurable_of_tendsto_nnreal' u (fun i => (hf i).infNndist) this\n    rw [tendsto_pi_nhds] at lim⊢\n    intro x\n    exact ((continuous_inf_nndist_pt s).Tendsto (g x)).comp (limUnder x)\n  have h4s : g ⁻¹' s = (fun x => inf_nndist (g x) s) ⁻¹' {0} :=\n    by\n    ext x\n    simp [h1s, ← h1s.mem_iff_inf_dist_zero h2s, ← NNReal.coe_eq_zero]\n  rw [h4s]\n  exact this (measurable_set_singleton 0)\n#align measurable_of_tendsto_metrizable' measurable_of_tendsto_metrizable'\n\n/-- A sequential limit of measurable functions valued in a (pseudo) metrizable space is\nmeasurable. -/\ntheorem measurable_of_tendsto_metrizable {f : ℕ → α → β} {g : α → β} (hf : ∀ i, Measurable (f i))\n    (lim : Tendsto f atTop (𝓝 g)) : Measurable g :=\n  measurable_of_tendsto_metrizable' atTop hf limUnder\n#align measurable_of_tendsto_metrizable measurable_of_tendsto_metrizable\n\ntheorem aeMeasurableOfTendstoMetrizableAe {ι} {μ : Measure α} {f : ι → α → β} {g : α → β}\n    (u : Filter ι) [hu : NeBot u] [IsCountablyGenerated u] (hf : ∀ n, AeMeasurable (f n) μ)\n    (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) u (𝓝 (g x))) : AeMeasurable g μ :=\n  by\n  rcases u.exists_seq_tendsto with ⟨v, hv⟩\n  have h'f : ∀ n, AeMeasurable (f (v n)) μ := fun n => hf (v n)\n  set p : α → (ℕ → β) → Prop := fun x f' => tendsto (fun n => f' n) at_top (𝓝 (g x))\n  have hp : ∀ᵐ x ∂μ, p x fun n => f (v n) x := by\n    filter_upwards [h_tendsto]with x hx using hx.comp hv\n  set ae_seq_lim := fun x => ite (x ∈ aeSeqSet h'f p) (g x) (⟨f (v 0) x⟩ : Nonempty β).some with hs\n  refine'\n    ⟨ae_seq_lim,\n      measurable_of_tendsto_metrizable' at_top (aeSeq.measurable h'f p)\n        (tendsto_pi_nhds.mpr fun x => _),\n      _⟩\n  · simp_rw [aeSeq, ae_seq_lim]\n    split_ifs with hx\n    · simp_rw [aeSeq.mk_eq_fun_of_mem_aeSeqSet h'f hx]\n      exact @aeSeq.funPropOfMemAeSeqSet _ α β _ _ _ _ _ h'f x hx\n    · exact tendsto_const_nhds\n  ·\n    exact\n      (ite_ae_eq_of_measure_compl_zero g (fun x => (⟨f (v 0) x⟩ : Nonempty β).some) (aeSeqSet h'f p)\n          (aeSeq.measure_compl_aeSeqSet_eq_zero h'f hp)).symm\n#align ae_measurable_of_tendsto_metrizable_ae aeMeasurableOfTendstoMetrizableAe\n\ntheorem aeMeasurableOfTendstoMetrizableAe' {μ : Measure α} {f : ℕ → α → β} {g : α → β}\n    (hf : ∀ n, AeMeasurable (f n) μ)\n    (h_ae_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : AeMeasurable g μ :=\n  aeMeasurableOfTendstoMetrizableAe atTop hf h_ae_tendsto\n#align ae_measurable_of_tendsto_metrizable_ae' aeMeasurableOfTendstoMetrizableAe'\n\ntheorem aeMeasurableOfUnifApprox {β} [MeasurableSpace β] [PseudoMetricSpace β] [BorelSpace β]\n    {μ : Measure α} {g : α → β}\n    (hf : ∀ ε > (0 : ℝ), ∃ f : α → β, AeMeasurable f μ ∧ ∀ᵐ x ∂μ, dist (f x) (g x) ≤ ε) :\n    AeMeasurable g μ :=\n  by\n  obtain ⟨u, u_anti, u_pos, u_lim⟩ :\n    ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ tendsto u at_top (𝓝 0) :=\n    exists_seq_strictAnti_tendsto (0 : ℝ)\n  choose f Hf using fun n : ℕ => hf (u n) (u_pos n)\n  have : ∀ᵐ x ∂μ, tendsto (fun n => f n x) at_top (𝓝 (g x)) :=\n    by\n    have : ∀ᵐ x ∂μ, ∀ n, dist (f n x) (g x) ≤ u n := ae_all_iff.2 fun n => (Hf n).2\n    filter_upwards [this]\n    intro x hx\n    rw [tendsto_iff_dist_tendsto_zero]\n    exact squeeze_zero (fun n => dist_nonneg) hx u_lim\n  exact aeMeasurableOfTendstoMetrizableAe' (fun n => (Hf n).1) this\n#align ae_measurable_of_unif_approx aeMeasurableOfUnifApprox\n\ntheorem measurable_of_tendsto_metrizable_ae {μ : Measure α} [μ.IsComplete] {f : ℕ → α → β}\n    {g : α → β} (hf : ∀ n, Measurable (f n))\n    (h_ae_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Measurable g :=\n  aeMeasurable_iff_measurable.mp\n    (aeMeasurableOfTendstoMetrizableAe' (fun i => (hf i).AeMeasurable) h_ae_tendsto)\n#align measurable_of_tendsto_metrizable_ae measurable_of_tendsto_metrizable_ae\n\ntheorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α}\n    {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AeMeasurable (f n) μ)\n    (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) :\n    ∃ (f_lim : α → β)(hf_lim_meas : Measurable f_lim),\n      ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) :=\n  by\n  inhabit ι\n  rcases eq_or_ne L ⊥ with (rfl | hL)\n  · exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot⟩\n  haveI : ne_bot L := ⟨hL⟩\n  let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, tendsto (fun n => f' n) L (𝓝 l)\n  have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx =>\n    aeSeq.funPropOfMemAeSeqSet hf hx\n  have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto\n  let f_lim : α → β := fun x =>\n    dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).some) fun h => (⟨f default x⟩ : Nonempty β).some\n  have hf_lim : ∀ x, tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) :=\n    by\n    intro x\n    simp only [f_lim, aeSeq]\n    split_ifs\n    · refine' (hp_mem x h).choose_spec.congr fun n => _\n      exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm\n    · exact tendsto_const_nhds\n  have h_ae_tendsto_f_lim : ∀ᵐ x ∂μ, tendsto (fun n => f n x) L (𝓝 (f_lim x)) :=\n    h_ae_eq.mono fun x hx => (hf_lim x).congr hx\n  have h_f_lim_meas : Measurable f_lim :=\n    measurable_of_tendsto_metrizable' L (aeSeq.measurable hf p)\n      (tendsto_pi_nhds.mpr fun x => hf_lim x)\n  exact ⟨f_lim, h_f_lim_meas, h_ae_tendsto_f_lim⟩\n#align measurable_limit_of_tendsto_metrizable_ae measurable_limit_of_tendsto_metrizable_ae\n\nend Limits\n\nnamespace ContinuousLinearMap\n\nvariable {𝕜 : Type _} [NormedField 𝕜]\n\nvariable {E : Type _} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E]\n  [OpensMeasurableSpace E] {F : Type _} [NormedAddCommGroup F] [NormedSpace 𝕜 F] [MeasurableSpace F]\n  [BorelSpace F]\n\n@[measurability]\nprotected theorem measurable (L : E →L[𝕜] F) : Measurable L :=\n  L.Continuous.Measurable\n#align continuous_linear_map.measurable ContinuousLinearMap.measurable\n\ntheorem measurable_comp (L : E →L[𝕜] F) {φ : α → E} (φ_meas : Measurable φ) :\n    Measurable fun a : α => L (φ a) :=\n  L.Measurable.comp φ_meas\n#align continuous_linear_map.measurable_comp ContinuousLinearMap.measurable_comp\n\nend ContinuousLinearMap\n\nnamespace ContinuousLinearMap\n\nvariable {𝕜 : Type _} [NontriviallyNormedField 𝕜]\n\nvariable {E : Type _} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type _} [NormedAddCommGroup F]\n  [NormedSpace 𝕜 F]\n\ninstance : MeasurableSpace (E →L[𝕜] F) :=\n  borel _\n\ninstance : BorelSpace (E →L[𝕜] F) :=\n  ⟨rfl⟩\n\n@[measurability]\ntheorem measurable_apply [MeasurableSpace F] [BorelSpace F] (x : E) :\n    Measurable fun f : E →L[𝕜] F => f x :=\n  (apply 𝕜 F x).Continuous.Measurable\n#align continuous_linear_map.measurable_apply ContinuousLinearMap.measurable_apply\n\n@[measurability]\ntheorem measurable_apply' [MeasurableSpace E] [OpensMeasurableSpace E] [MeasurableSpace F]\n    [BorelSpace F] : Measurable fun (x : E) (f : E →L[𝕜] F) => f x :=\n  measurable_pi_lambda _ fun f => f.Measurable\n#align continuous_linear_map.measurable_apply' ContinuousLinearMap.measurable_apply'\n\n@[measurability]\ntheorem measurable_coe [MeasurableSpace F] [BorelSpace F] :\n    Measurable fun (f : E →L[𝕜] F) (x : E) => f x :=\n  measurable_pi_lambda _ measurable_apply\n#align continuous_linear_map.measurable_coe ContinuousLinearMap.measurable_coe\n\nend ContinuousLinearMap\n\nsection ContinuousLinearMapNontriviallyNormedField\n\nvariable {𝕜 : Type _} [NontriviallyNormedField 𝕜]\n\nvariable {E : Type _} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E] [BorelSpace E]\n  {F : Type _} [NormedAddCommGroup F] [NormedSpace 𝕜 F]\n\n@[measurability]\ntheorem Measurable.apply_continuousLinearMap {φ : α → F →L[𝕜] E} (hφ : Measurable φ) (v : F) :\n    Measurable fun a => φ a v :=\n  (ContinuousLinearMap.apply 𝕜 E v).Measurable.comp hφ\n#align measurable.apply_continuous_linear_map Measurable.apply_continuousLinearMap\n\n@[measurability]\ntheorem AeMeasurable.applyContinuousLinearMap {φ : α → F →L[𝕜] E} {μ : Measure α}\n    (hφ : AeMeasurable φ μ) (v : F) : AeMeasurable (fun a => φ a v) μ :=\n  (ContinuousLinearMap.apply 𝕜 E v).Measurable.compAeMeasurable hφ\n#align ae_measurable.apply_continuous_linear_map AeMeasurable.applyContinuousLinearMap\n\nend ContinuousLinearMapNontriviallyNormedField\n\nsection NormedSpace\n\nvariable {𝕜 : Type _} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] [MeasurableSpace 𝕜]\n\nvariable [BorelSpace 𝕜] {E : Type _} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E]\n  [BorelSpace E]\n\ntheorem measurable_smul_const {f : α → 𝕜} {c : E} (hc : c ≠ 0) :\n    (Measurable fun x => f x • c) ↔ Measurable f :=\n  (closedEmbedding_smul_left hc).MeasurableEmbedding.measurable_comp_iff\n#align measurable_smul_const measurable_smul_const\n\ntheorem aeMeasurable_smul_const {f : α → 𝕜} {μ : Measure α} {c : E} (hc : c ≠ 0) :\n    AeMeasurable (fun x => f x • c) μ ↔ AeMeasurable f μ :=\n  (closedEmbedding_smul_left hc).MeasurableEmbedding.aeMeasurable_comp_iff\n#align ae_measurable_smul_const aeMeasurable_smul_const\n\nend NormedSpace\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/MeasureTheory/Constructions/BorelSpace.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4839578333392218}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.category.Group.limits\nimport Mathlib.algebra.category.Group.preadditive\nimport Mathlib.category_theory.limits.shapes.biproducts\nimport Mathlib.category_theory.limits.shapes.types\nimport Mathlib.algebra.group.pi\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\n/-!\n# The category of abelian groups has finite biproducts\n-/\n\nnamespace AddCommGroup\n\n\n/--\nConstruct limit data for a binary product in `AddCommGroup`, using `AddCommGroup.of (G × H)`.\n-/\ndef binary_product_limit_cone (G : AddCommGroup) (H : AddCommGroup) : category_theory.limits.limit_cone (category_theory.limits.pair G H) :=\n  category_theory.limits.limit_cone.mk\n    (category_theory.limits.cone.mk (of (↥G × ↥H))\n      (category_theory.nat_trans.mk\n        fun (j : category_theory.discrete category_theory.limits.walking_pair) =>\n          category_theory.limits.walking_pair.cases_on j (add_monoid_hom.fst ↥G ↥H) (add_monoid_hom.snd ↥G ↥H)))\n    (category_theory.limits.is_limit.mk\n      fun (s : category_theory.limits.cone (category_theory.limits.pair G H)) =>\n        add_monoid_hom.prod\n          (category_theory.nat_trans.app (category_theory.limits.cone.π s) category_theory.limits.walking_pair.left)\n          (category_theory.nat_trans.app (category_theory.limits.cone.π s) category_theory.limits.walking_pair.right))\n\nprotected instance has_binary_product (G : AddCommGroup) (H : AddCommGroup) : category_theory.limits.has_binary_product G H :=\n  category_theory.limits.has_limit.mk (binary_product_limit_cone G H)\n\nprotected instance category_theory.limits.has_binary_biproduct (G : AddCommGroup) (H : AddCommGroup) : category_theory.limits.has_binary_biproduct G H :=\n  category_theory.limits.has_binary_biproduct.of_has_binary_product G H\n\n/--\nWe verify that the biproduct in AddCommGroup is isomorphic to\nthe cartesian product of the underlying types:\n-/\ndef biprod_iso_prod (G : AddCommGroup) (H : AddCommGroup) : G ⊞ H ≅ of (↥G × ↥H) :=\n  category_theory.limits.is_limit.cone_point_unique_up_to_iso (category_theory.limits.binary_biproduct.is_limit G H)\n    (category_theory.limits.limit_cone.is_limit (binary_product_limit_cone G H))\n\n-- Furthermore, our biproduct will automatically function as a coproduct.\n\nnamespace has_limit\n\n\n/--\nThe map from an arbitrary cone over a indexed family of abelian groups\nto the cartesian product of those groups.\n-/\ndef lift {J : Type u} (F : category_theory.discrete J ⥤ AddCommGroup) (s : category_theory.limits.cone F) : category_theory.limits.cone.X s ⟶ of ((j : category_theory.discrete J) → ↥(category_theory.functor.obj F j)) :=\n  add_monoid_hom.mk\n    (fun (x : ↥(category_theory.limits.cone.X s)) (j : category_theory.discrete J) =>\n      coe_fn (category_theory.nat_trans.app (category_theory.limits.cone.π s) j) x)\n    sorry sorry\n\n@[simp] theorem lift_apply {J : Type u} (F : category_theory.discrete J ⥤ AddCommGroup) (s : category_theory.limits.cone F) (x : ↥(category_theory.limits.cone.X s)) (j : J) : coe_fn (lift F s) x j = coe_fn (category_theory.nat_trans.app (category_theory.limits.cone.π s) j) x :=\n  rfl\n\n/--\nConstruct limit data for a product in `AddCommGroup`, using `AddCommGroup.of (Π j, F.obj j)`.\n-/\ndef product_limit_cone {J : Type u} (F : category_theory.discrete J ⥤ AddCommGroup) : category_theory.limits.limit_cone F :=\n  category_theory.limits.limit_cone.mk\n    (category_theory.limits.cone.mk (of ((j : category_theory.discrete J) → ↥(category_theory.functor.obj F j)))\n      (category_theory.discrete.nat_trans\n        fun (j : category_theory.discrete J) =>\n          add_monoid_hom.apply (fun (j : category_theory.discrete J) => ↥(category_theory.functor.obj F j)) j))\n    (category_theory.limits.is_limit.mk (lift F))\n\nend has_limit\n\n\nprotected instance category_theory.limits.has_biproduct {J : Type u} [DecidableEq J] [fintype J] (f : J → AddCommGroup) : category_theory.limits.has_biproduct f :=\n  category_theory.limits.has_biproduct.of_has_product f\n\n/--\nWe verify that the biproduct we've just defined is isomorphic to the AddCommGroup structure\non the dependent function type\n-/\ndef biproduct_iso_pi {J : Type u} [DecidableEq J] [fintype J] (f : J → AddCommGroup) : ⨁ f ≅ of ((j : J) → ↥(f j)) :=\n  category_theory.limits.is_limit.cone_point_unique_up_to_iso (category_theory.limits.biproduct.is_limit f)\n    (category_theory.limits.limit_cone.is_limit (has_limit.product_limit_cone (category_theory.discrete.functor f)))\n\nprotected instance category_theory.limits.has_finite_biproducts : category_theory.limits.has_finite_biproducts AddCommGroup :=\n  category_theory.limits.has_finite_biproducts.mk\n    fun (J : Type u_1) (_x : DecidableEq J) (_x_1 : fintype J) =>\n      category_theory.limits.has_biproducts_of_shape.mk\n        fun (f : J → AddCommGroup) => category_theory.limits.has_biproduct f\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/category/Group/biproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.48390439190601114}}
{"text": "/-\nCopyright (c) 2022 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Dany Fabian\n-/\n\nprelude\nimport Init.Classical\nimport Init.Data.List\n\nnamespace Lean.Data.AC\ninductive Expr\n  | var (x : Nat)\n  | op (lhs rhs : Expr)\n  deriving Inhabited, Repr, BEq\n\nstructure Variable {α : Sort u} (op : α → α → α) : Type u where\n  value : α\n  neutral : Option $ IsNeutral op value\n\nstructure Context (α : Sort u) where\n  op : α → α → α\n  assoc : IsAssociative op\n  comm : Option $ IsCommutative op\n  idem : Option $ IsIdempotent op\n  vars : List (Variable op)\n  arbitrary : α\n\nclass ContextInformation (α : Sort u) where\n  isNeutral : α → Nat → Bool\n  isComm : α → Bool\n  isIdem : α → Bool\n\nclass EvalInformation (α : Sort u) (β : Sort v) where\n  arbitrary : α → β\n  evalOp : α → β → β → β\n  evalVar : α → Nat → β\n\ndef Context.var (ctx : Context α) (idx : Nat) : Variable ctx.op :=\n  ctx.vars.getD idx ⟨ctx.arbitrary, none⟩\n\ninstance : ContextInformation (Context α) where\n  isNeutral ctx x := ctx.var x |>.neutral.isSome\n  isComm ctx := ctx.comm.isSome\n  isIdem ctx := ctx.idem.isSome\n\ninstance : EvalInformation (Context α) α where\n  arbitrary ctx := ctx.arbitrary\n  evalOp ctx := ctx.op\n  evalVar ctx idx := ctx.var idx |>.value\n\ndef eval (β : Sort u) [EvalInformation α β] (ctx : α) : (ex : Expr) → β\n  | Expr.var idx => EvalInformation.evalVar ctx idx\n  | Expr.op l r => EvalInformation.evalOp ctx (eval β ctx l) (eval β ctx r)\n\ndef Expr.toList : Expr → List Nat\n  | Expr.var idx => [idx]\n  | Expr.op l r => l.toList.append r.toList\n\ndef evalList (β : Sort u) [EvalInformation α β] (ctx : α) : List Nat → β\n  | [] => EvalInformation.arbitrary ctx\n  | [x] => EvalInformation.evalVar ctx x\n  | x :: xs => EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList β ctx xs)\n\ndef insert (x : Nat) : List Nat → List Nat\n  | [] => [x]\n  | a :: as => if x < a then x :: a :: as else a :: insert x as\n\ndef sort (xs : List Nat) : List Nat :=\n  let rec loop : List Nat → List Nat → List Nat\n    | acc, [] => acc\n    | acc, x :: xs => loop (insert x acc) xs\n  loop [] xs\n\ndef mergeIdem (xs : List Nat) : List Nat :=\n  let rec loop : Nat → List Nat → List Nat\n    | curr, next :: rest =>\n      if curr = next then\n        loop curr rest\n      else\n        curr :: loop next rest\n    | curr, [] => [curr]\n\n  match xs with\n  | [] => []\n  | x :: xs => loop x xs\n\ndef removeNeutrals [info : ContextInformation α] (ctx : α) : List Nat → List Nat\n  | x :: xs =>\n    match loop (x :: xs) with\n    | [] => [x]\n    | ys => ys\n  | [] => []\n  where loop : List Nat → List Nat\n    | x :: xs =>\n      match info.isNeutral ctx x with\n      | true => loop xs\n      | false => x :: loop xs\n    | [] => []\n\ndef norm [info : ContextInformation α] (ctx : α) (e : Expr) : List Nat :=\n  let xs := e.toList\n  let xs := removeNeutrals ctx xs\n  let xs := if info.isComm ctx then sort xs else xs\n  if info.isIdem ctx then mergeIdem xs else xs\n\ntheorem List.two_step_induction\n  {motive : List Nat → Sort u}\n  (l : List Nat)\n  (empty : motive [])\n  (single : ∀ a, motive [a])\n  (step : ∀ a b l, motive (b :: l) → motive (a :: b :: l))\n  : motive l := by\n  induction l with\n  | nil => assumption\n  | cons a l => cases l; apply single; apply step; assumption\n\ntheorem Context.mergeIdem_nonEmpty (e : List Nat) (h : e ≠ []) : mergeIdem e ≠ [] := by\n  induction e using List.two_step_induction with\n  | empty => simp_all\n  | single => simp [mergeIdem, mergeIdem.loop]\n  | step => simp [mergeIdem, mergeIdem.loop] at *; split <;> simp_all\n\ntheorem Context.mergeIdem_head : mergeIdem (x :: x :: xs) = mergeIdem (x :: xs) := by\n  simp [mergeIdem, mergeIdem.loop]\n\ntheorem Context.mergeIdem_head2 (h : x ≠ y) : mergeIdem (x :: y :: ys) = x :: mergeIdem (y :: ys) := by\n  simp [mergeIdem, mergeIdem.loop, h]\n\ntheorem Context.evalList_mergeIdem (ctx : Context α) (h : ContextInformation.isIdem ctx) (e : List Nat) : evalList α ctx (mergeIdem e) = evalList α ctx e := by\n  have h : IsIdempotent ctx.op := by simp [ContextInformation.isIdem, Option.isSome] at h; cases h₂ : ctx.idem <;> simp [h₂] at h; assumption\n  induction e using List.two_step_induction with\n  | empty => rfl\n  | single => rfl\n  | step x y ys ih =>\n    cases ys with\n    | nil =>\n      simp [mergeIdem, mergeIdem.loop]\n      split\n      case inl h₂ => simp [evalList, h₂, h.1, EvalInformation.evalOp]\n      rfl\n    | cons z zs =>\n      by_cases h₂ : x = y\n      case inl =>\n        rw [h₂, mergeIdem_head, ih]\n        simp [evalList, ←ctx.assoc.1, h.1, EvalInformation.evalOp]\n      case inr =>\n        rw [mergeIdem_head2]\n        by_cases h₃ : y = z\n        case inl =>\n          simp [mergeIdem_head, h₃, evalList]\n          cases h₄ : mergeIdem (z :: zs) with\n          | nil => apply absurd h₄; apply mergeIdem_nonEmpty; simp\n          | cons u us => simp_all [mergeIdem, mergeIdem.loop, evalList]\n        case inr =>\n          simp [mergeIdem_head2, h₃, evalList] at *\n          rw [ih]\n        assumption\n\ntheorem insert_nonEmpty : insert x xs ≠ [] := by\n  induction xs with\n  | nil => simp [insert]\n  | cons x xs _  => simp [insert]; split <;> simp\n\ntheorem Context.sort_loop_nonEmpty (xs : List Nat) (h : xs ≠ []) : sort.loop xs ys ≠ [] := by\n  induction ys generalizing xs with\n  | nil => simp [sort.loop]; assumption\n  | cons y _  ih => simp [sort.loop]; apply ih; apply insert_nonEmpty\n\ntheorem Context.evalList_insert\n  (ctx : Context α)\n  (h : IsCommutative ctx.op)\n  (x : Nat)\n  (xs : List Nat)\n  : evalList α ctx (insert x xs) = evalList α ctx (x::xs) := by\n  induction xs using List.two_step_induction with\n  | empty => rfl\n  | single =>\n    simp [insert]\n    split\n    . rfl\n    . simp [evalList, h.1, EvalInformation.evalOp]\n  | step y z zs ih =>\n    simp [insert] at *; split\n    case inl => rfl\n    case inr =>\n      split\n      case inl => simp [evalList, EvalInformation.evalOp]; rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]\n      case inr => simp_all [evalList, EvalInformation.evalOp]; rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]\n\ntheorem Context.evalList_sort_congr\n  (ctx : Context α)\n  (h : IsCommutative ctx.op)\n  (h₂ : evalList α ctx a = evalList α ctx b)\n  (h₃ : a ≠ [])\n  (h₄ : b ≠ [])\n  : evalList α ctx (sort.loop a c) = evalList α ctx (sort.loop b c) := by\n  induction c generalizing a b with\n  | nil => simp [sort.loop, h₂]\n  | cons c _  ih =>\n    simp [sort.loop]; apply ih; simp [evalList_insert ctx h, evalList]\n    cases a with\n    | nil => apply absurd h₃; simp\n    | cons a as =>\n      cases b with\n      | nil => apply absurd h₄; simp\n      | cons b bs => simp [evalList, h₂]\n    all_goals apply insert_nonEmpty\n\ntheorem Context.evalList_sort_loop_swap\n  (ctx : Context α)\n  (h : IsCommutative ctx.op)\n  (xs ys : List Nat)\n  : evalList α ctx (sort.loop xs (y::ys)) = evalList α ctx (sort.loop (y::xs) ys) := by\n  induction ys generalizing y xs with\n  | nil => simp [sort.loop, evalList_insert ctx h]\n  | cons z zs _  =>\n    simp [sort.loop]; apply evalList_sort_congr ctx h\n    simp [evalList_insert ctx h]\n    cases h₂ : insert y xs\n    . apply absurd h₂; simp [insert_nonEmpty]\n    . simp [evalList, ←h₂, evalList_insert ctx h]\n    all_goals simp [insert_nonEmpty]\n\ntheorem Context.evalList_sort_cons\n  (ctx : Context α)\n  (h : IsCommutative ctx.op)\n  (x : Nat)\n  (xs : List Nat)\n  : evalList α ctx (sort (x :: xs)) = evalList α ctx (x :: sort xs) := by\n  simp [sort, sort.loop]\n  generalize [] = ys\n  induction xs generalizing x ys with\n  | nil => simp [sort.loop, evalList_insert ctx h]\n  | cons z zs ih =>\n    rw [evalList_sort_loop_swap ctx h]; simp [sort.loop, ←ih]; apply evalList_sort_congr ctx h; rw [evalList_insert ctx h]\n    cases h₂ : insert x ys with\n    | nil => apply absurd h₂; simp [insert_nonEmpty]\n    | cons u us =>\n      cases h₃ : insert z ys with\n      | nil => apply absurd h₃; simp [insert_nonEmpty]\n      | cons v vs =>\n        simp [evalList, ←h₂, ←h₃, evalList_insert ctx h]\n        cases ys\n        . simp [evalList, h.1, EvalInformation.evalOp]\n        . simp [evalList, EvalInformation.evalOp]; rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]\n    all_goals simp [insert_nonEmpty]\n\ntheorem Context.evalList_sort (ctx : Context α) (h : ContextInformation.isComm ctx) (e : List Nat) : evalList α ctx (sort e) = evalList α ctx e := by\n  have h : IsCommutative ctx.op := by simp [ContextInformation.isComm, Option.isSome] at h; cases h₂ : ctx.comm <;> simp [h₂] at h; assumption\n  induction e using List.two_step_induction with\n  | empty => rfl\n  | single => rfl\n  | step x y ys ih =>\n    simp [evalList_sort_cons ctx h]\n    cases h₂ : sort (y :: ys) with\n    | nil => simp [sort, sort.loop] at *; apply absurd h₂; apply sort_loop_nonEmpty; apply insert_nonEmpty\n    | cons z zs => simp [evalList, ←h₂, ih]\n\ntheorem Context.toList_nonEmpty (e : Expr) : e.toList ≠ [] := by\n  induction e with\n  | var => simp [Expr.toList]\n  | op l r ih₁ _   =>\n    simp [Expr.toList]\n    cases h : l.toList with\n    | nil => contradiction\n    | cons => simp [List.append]\n\ntheorem Context.unwrap_isNeutral\n  {ctx : Context α}\n  {x : Nat}\n  : ContextInformation.isNeutral ctx x = true → IsNeutral (EvalInformation.evalOp ctx) (EvalInformation.evalVar (β := α) ctx x) := by\n  simp [ContextInformation.isNeutral, Option.isSome, EvalInformation.evalOp, EvalInformation.evalVar]\n  match (var ctx x).neutral with\n  | some hn => intro; assumption\n  | none => intro; contradiction\n\ntheorem Context.evalList_removeNeutrals (ctx : Context α) (e : List Nat) : evalList α ctx (removeNeutrals ctx e) = evalList α ctx e := by\n  induction e using List.two_step_induction with\n  | empty => rfl\n  | single =>\n    simp [removeNeutrals, removeNeutrals.loop]; split\n    case h_1 => rfl\n    case h_2 h => split at h <;> simp_all\n  | step x y ys ih =>\n    cases h₁ : ContextInformation.isNeutral ctx x <;> cases h₂ : ContextInformation.isNeutral ctx y <;> cases h₃ : removeNeutrals.loop ctx ys\n    <;> simp [removeNeutrals, removeNeutrals.loop, h₁, h₂, h₃, evalList, ←ih]\n    <;> (try simp [unwrap_isNeutral h₂ |>.2])\n    <;> (try simp [unwrap_isNeutral h₁ |>.1])\n\ntheorem Context.evalList_append\n  (ctx : Context α)\n  (l r : List Nat)\n  (h₁ : l ≠ [])\n  (h₂ : r ≠ [])\n  : evalList α ctx (l.append r) = ctx.op (evalList α ctx l) (evalList α ctx r) := by\n  induction l using List.two_step_induction with\n  | empty => simp_all\n  | single x =>\n    cases r\n    . simp at h₂\n    . simp [List.append, evalList, EvalInformation.evalOp]\n  | step x y ys ih => simp [List.append, evalList, EvalInformation.evalOp] at *; rw [ih]; simp [ctx.assoc.1]\n\ntheorem Context.eval_toList (ctx : Context α) (e : Expr) : evalList α ctx e.toList = eval α ctx e := by\n  induction e with\n  | var x => rfl\n  | op l r ih₁ ih₂ =>\n    simp [evalList, Expr.toList, eval, ←ih₁, ←ih₂]\n    apply evalList_append <;> apply toList_nonEmpty\n\ntheorem Context.eval_norm (ctx : Context α) (e : Expr) : evalList α ctx (norm ctx e) = eval α ctx e := by\n  simp [norm]\n  cases h₁ : ContextInformation.isIdem ctx <;> cases h₂ : ContextInformation.isComm ctx <;>\n  simp_all [evalList_removeNeutrals, eval_toList, toList_nonEmpty, evalList_mergeIdem, evalList_sort]\n\ntheorem Context.eq_of_norm (ctx : Context α) (a b : Expr) (h : norm ctx a == norm ctx b) : eval α ctx a = eval α ctx b := by\n  have h := congrArg (evalList α ctx) (eq_of_beq h)\n  rw [eval_norm, eval_norm] at h\n  assumption\n\nend Lean.Data.AC\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/src/Init/Data/AC.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.483904389024518}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport set_theory.cardinal.basic\nimport topology.metric_space.closeds\nimport topology.metric_space.completion\nimport topology.metric_space.gromov_hausdorff_realized\nimport topology.metric_space.kuratowski\n\n/-!\n# Gromov-Hausdorff distance\n\nThis file defines the Gromov-Hausdorff distance on the space of nonempty compact metric spaces\nup to isometry.\n\nWe introduce the space of all nonempty compact metric spaces, up to isometry,\ncalled `GH_space`, and endow it with a metric space structure. The distance,\nknown as the Gromov-Hausdorff distance, is defined as follows: given two\nnonempty compact spaces `X` and `Y`, their distance is the minimum Hausdorff distance\nbetween all possible isometric embeddings of `X` and `Y` in all metric spaces.\nTo define properly the Gromov-Hausdorff space, we consider the non-empty\ncompact subsets of `ℓ^∞(ℝ)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `ℓ^∞(ℝ)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `ℓ^∞(ℝ)`, through an\nembedding called the Kuratowski embedding.\nTo prove that we have a distance, we should show that if spaces can be coupled\nto be arbitrarily close, then they are isometric. More generally, the Gromov-Hausdorff\ndistance is realized, i.e., there is a coupling for which the Hausdorff distance\nis exactly the Gromov-Hausdorff distance. This follows from a compactness\nargument, essentially following from Arzela-Ascoli.\n\n## Main results\n\nWe prove the most important properties of the Gromov-Hausdorff space: it is a polish space,\ni.e., it is complete and second countable. We also prove the Gromov compactness criterion.\n\n-/\n\nnoncomputable theory\nopen_locale classical topological_space ennreal\n\nlocal notation `ℓ_infty_ℝ`:= lp (λ n : ℕ, ℝ) ∞\n\nuniverses u v w\n\nopen classical set function topological_space filter metric quotient\nopen bounded_continuous_function nat int Kuratowski_embedding\nopen sum (inl inr)\n\nlocal attribute [instance] metric_space_sum\n\n\nnamespace Gromov_Hausdorff\n\nsection GH_space\n/- In this section, we define the Gromov-Hausdorff space, denoted `GH_space` as the quotient\nof nonempty compact subsets of `ℓ^∞(ℝ)` by identifying isometric sets.\nUsing the Kuratwoski embedding, we get a canonical map `to_GH_space` mapping any nonempty\ncompact type to `GH_space`. -/\n\n/-- Equivalence relation identifying two nonempty compact sets which are isometric -/\nprivate def isometry_rel : nonempty_compacts ℓ_infty_ℝ → nonempty_compacts ℓ_infty_ℝ → Prop :=\nλ x y, nonempty (x ≃ᵢ y)\n\n/-- This is indeed an equivalence relation -/\nprivate lemma is_equivalence_isometry_rel : equivalence isometry_rel :=\n⟨λ x, ⟨isometric.refl _⟩, λ x y ⟨e⟩, ⟨e.symm⟩, λ x y z ⟨e⟩ ⟨f⟩, ⟨e.trans f⟩⟩\n\n/-- setoid instance identifying two isometric nonempty compact subspaces of ℓ^∞(ℝ) -/\ninstance isometry_rel.setoid : setoid (nonempty_compacts ℓ_infty_ℝ) :=\nsetoid.mk isometry_rel is_equivalence_isometry_rel\n\n/-- The Gromov-Hausdorff space -/\ndefinition GH_space : Type := quotient (isometry_rel.setoid)\n\n/-- Map any nonempty compact type to `GH_space` -/\ndefinition to_GH_space (X : Type u) [metric_space X] [compact_space X] [nonempty X] : GH_space :=\n  ⟦nonempty_compacts.Kuratowski_embedding X⟧\n\ninstance : inhabited GH_space := ⟨quot.mk _ ⟨⟨{0}, is_compact_singleton⟩, singleton_nonempty _⟩⟩\n\n/-- A metric space representative of any abstract point in `GH_space` -/\n@[nolint has_inhabited_instance]\ndef GH_space.rep (p : GH_space) : Type := (quotient.out p : nonempty_compacts ℓ_infty_ℝ)\n\nlemma eq_to_GH_space_iff {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {p : nonempty_compacts ℓ_infty_ℝ} :\n  ⟦p⟧ = to_GH_space X ↔ ∃ Ψ : X → ℓ_infty_ℝ, isometry Ψ ∧ range Ψ = p :=\nbegin\n  simp only [to_GH_space, quotient.eq],\n  refine ⟨λ h, _, _⟩,\n  { rcases setoid.symm h with ⟨e⟩,\n    have f := (Kuratowski_embedding.isometry X).isometric_on_range.trans e,\n    use [λ x, f x, isometry_subtype_coe.comp f.isometry],\n    rw [range_comp, f.range_eq_univ, set.image_univ, subtype.range_coe],\n    refl },\n  { rintros ⟨Ψ, ⟨isomΨ, rangeΨ⟩⟩,\n    have f := ((Kuratowski_embedding.isometry X).isometric_on_range.symm.trans\n               isomΨ.isometric_on_range).symm,\n    have E : (range Ψ ≃ᵢ nonempty_compacts.Kuratowski_embedding X) =\n        (p ≃ᵢ range (Kuratowski_embedding X)),\n      by { dunfold nonempty_compacts.Kuratowski_embedding, rw [rangeΨ]; refl },\n    exact ⟨cast E f⟩ }\nend\n\nlemma eq_to_GH_space {p : nonempty_compacts ℓ_infty_ℝ} : ⟦p⟧ = to_GH_space p :=\neq_to_GH_space_iff.2 ⟨λ x, x, isometry_subtype_coe, subtype.range_coe⟩\n\nsection\nlocal attribute [reducible] GH_space.rep\n\ninstance rep_GH_space_metric_space {p : GH_space} : metric_space p.rep := by apply_instance\ninstance rep_GH_space_compact_space {p : GH_space} : compact_space p.rep := by apply_instance\ninstance rep_GH_space_nonempty {p : GH_space} : nonempty p.rep := by apply_instance\n\nend\n\nlemma GH_space.to_GH_space_rep (p : GH_space) : to_GH_space p.rep = p :=\nbegin\n  change to_GH_space (quot.out p : nonempty_compacts ℓ_infty_ℝ) = p,\n  rw ← eq_to_GH_space,\n  exact quot.out_eq p\nend\n\n/-- Two nonempty compact spaces have the same image in `GH_space` if and only if they are\nisometric. -/\nlemma to_GH_space_eq_to_GH_space_iff_isometric {X : Type u} [metric_space X] [compact_space X]\n  [nonempty X] {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y] :\n  to_GH_space X = to_GH_space Y ↔ nonempty (X ≃ᵢ Y) :=\n⟨begin\n  simp only [to_GH_space, quotient.eq],\n  rintro ⟨e⟩,\n  have I : ((nonempty_compacts.Kuratowski_embedding X) ≃ᵢ\n             (nonempty_compacts.Kuratowski_embedding Y))\n          = ((range (Kuratowski_embedding X)) ≃ᵢ (range (Kuratowski_embedding Y))),\n    by { dunfold nonempty_compacts.Kuratowski_embedding, refl },\n  have f := (Kuratowski_embedding.isometry X).isometric_on_range,\n  have g := (Kuratowski_embedding.isometry Y).isometric_on_range.symm,\n  exact ⟨f.trans $ (cast I e).trans g⟩\nend,\nbegin\n  rintro ⟨e⟩,\n  simp only [to_GH_space, quotient.eq],\n  have f := (Kuratowski_embedding.isometry X).isometric_on_range.symm,\n  have g := (Kuratowski_embedding.isometry Y).isometric_on_range,\n  have I : ((range (Kuratowski_embedding X)) ≃ᵢ (range (Kuratowski_embedding Y))) =\n    ((nonempty_compacts.Kuratowski_embedding X) ≃ᵢ\n      (nonempty_compacts.Kuratowski_embedding Y)),\n    by { dunfold nonempty_compacts.Kuratowski_embedding, refl },\n  exact ⟨cast I ((f.trans e).trans g)⟩\nend⟩\n\n/-- Distance on `GH_space`: the distance between two nonempty compact spaces is the infimum\nHausdorff distance between isometric copies of the two spaces in a metric space. For the definition,\nwe only consider embeddings in `ℓ^∞(ℝ)`, but we will prove below that it works for all spaces. -/\ninstance : has_dist (GH_space) :=\n{ dist := λ x y, Inf $\n    (λ p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ,\n      Hausdorff_dist (p.1 : set ℓ_infty_ℝ) p.2) '' ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y}) }\n\n/-- The Gromov-Hausdorff distance between two nonempty compact metric spaces, equal by definition to\nthe distance of the equivalence classes of these spaces in the Gromov-Hausdorff space. -/\ndef GH_dist (X : Type u) (Y : Type v) [metric_space X] [nonempty X] [compact_space X]\n  [metric_space Y] [nonempty Y] [compact_space Y] : ℝ := dist (to_GH_space X) (to_GH_space Y)\n\nlemma dist_GH_dist (p q : GH_space) : dist p q = GH_dist p.rep (q.rep) :=\nby rw [GH_dist, p.to_GH_space_rep, q.to_GH_space_rep]\n\n/-- The Gromov-Hausdorff distance between two spaces is bounded by the Hausdorff distance\nof isometric copies of the spaces, in any metric space. -/\ntheorem GH_dist_le_Hausdorff_dist {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y]\n  {γ : Type w} [metric_space γ] {Φ : X → γ} {Ψ : Y → γ} (ha : isometry Φ) (hb : isometry Ψ) :\n  GH_dist X Y ≤ Hausdorff_dist (range Φ) (range Ψ) :=\nbegin\n  /- For the proof, we want to embed `γ` in `ℓ^∞(ℝ)`, to say that the Hausdorff distance is realized\n  in `ℓ^∞(ℝ)` and therefore bounded below by the Gromov-Hausdorff-distance. However, `γ` is not\n  separable in general. We restrict to the union of the images of `X` and `Y` in `γ`, which is\n  separable and therefore embeddable in `ℓ^∞(ℝ)`. -/\n  rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n  let s : set γ := (range Φ) ∪ (range Ψ),\n  let Φ' : X → subtype s := λ y, ⟨Φ y, mem_union_left _ (mem_range_self _)⟩,\n  let Ψ' : Y → subtype s := λ y, ⟨Ψ y, mem_union_right _ (mem_range_self _)⟩,\n  have IΦ' : isometry Φ' := λ x y, ha x y,\n  have IΨ' : isometry Ψ' := λ x y, hb x y,\n  have : is_compact s, from (is_compact_range ha.continuous).union (is_compact_range hb.continuous),\n  letI : metric_space (subtype s) := by apply_instance,\n  haveI : compact_space (subtype s) := ⟨is_compact_iff_is_compact_univ.1 ‹is_compact s›⟩,\n  haveI : nonempty (subtype s) := ⟨Φ' xX⟩,\n  have ΦΦ' : Φ = subtype.val ∘ Φ', by { funext, refl },\n  have ΨΨ' : Ψ = subtype.val ∘ Ψ', by { funext, refl },\n  have : Hausdorff_dist (range Φ) (range Ψ) = Hausdorff_dist (range Φ') (range Ψ'),\n  { rw [ΦΦ', ΨΨ', range_comp, range_comp],\n    exact Hausdorff_dist_image (isometry_subtype_coe) },\n  rw this,\n  -- Embed `s` in `ℓ^∞(ℝ)` through its Kuratowski embedding\n  let F := Kuratowski_embedding (subtype s),\n  have : Hausdorff_dist (F '' (range Φ')) (F '' (range Ψ')) =\n    Hausdorff_dist (range Φ') (range Ψ') := Hausdorff_dist_image (Kuratowski_embedding.isometry _),\n  rw ← this,\n  -- Let `A` and `B` be the images of `X` and `Y` under this embedding. They are in `ℓ^∞(ℝ)`, and\n  -- their Hausdorff distance is the same as in the original space.\n  let A : nonempty_compacts ℓ_infty_ℝ := ⟨⟨F '' (range Φ'), (is_compact_range IΦ'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous⟩, (range_nonempty _).image _⟩,\n  let B : nonempty_compacts ℓ_infty_ℝ := ⟨⟨F '' (range Ψ'), (is_compact_range IΨ'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous⟩, (range_nonempty _).image _⟩,\n  have AX : ⟦A⟧ = to_GH_space X,\n  { rw eq_to_GH_space_iff,\n    exact ⟨λ x, F (Φ' x), (Kuratowski_embedding.isometry _).comp IΦ', range_comp _ _⟩ },\n  have BY : ⟦B⟧ = to_GH_space Y,\n  { rw eq_to_GH_space_iff,\n    exact ⟨λ x, F (Ψ' x), (Kuratowski_embedding.isometry _).comp IΨ', range_comp _ _⟩ },\n  refine cInf_le ⟨0,\n    begin simp [lower_bounds], assume t _ _ _ _ ht, rw ← ht, exact Hausdorff_dist_nonneg end⟩ _,\n  apply (mem_image _ _ _).2,\n  existsi (⟨A, B⟩ : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n  simp [AX, BY],\nend\n\n/-- The optimal coupling constructed above realizes exactly the Gromov-Hausdorff distance,\nessentially by design. -/\nlemma Hausdorff_dist_optimal {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y] :\n  Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) = GH_dist X Y :=\nbegin\n  inhabit X, inhabit Y,\n  /- we only need to check the inequality `≤`, as the other one follows from the previous lemma.\n     As the Gromov-Hausdorff distance is an infimum, we need to check that the Hausdorff distance\n     in the optimal coupling is smaller than the Hausdorff distance of any coupling.\n     First, we check this for couplings which already have small Hausdorff distance: in this\n     case, the induced \"distance\" on `X ⊕ Y` belongs to the candidates family introduced in the\n     definition of the optimal coupling, and the conclusion follows from the optimality\n     of the optimal coupling within this family.\n  -/\n  have A : ∀ p q : nonempty_compacts ℓ_infty_ℝ, ⟦p⟧ = to_GH_space X → ⟦q⟧ = to_GH_space Y →\n        Hausdorff_dist (p : set ℓ_infty_ℝ) q < diam (univ : set X) + 1 + diam (univ : set Y) →\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤\n        Hausdorff_dist (p : set ℓ_infty_ℝ) q,\n  { assume p q hp hq bound,\n    rcases eq_to_GH_space_iff.1 hp with ⟨Φ, ⟨Φisom, Φrange⟩⟩,\n    rcases eq_to_GH_space_iff.1 hq with ⟨Ψ, ⟨Ψisom, Ψrange⟩⟩,\n    have I : diam (range Φ ∪ range Ψ) ≤ 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y),\n    { rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n      have : ∃ y ∈ range Ψ, dist (Φ xX) y < diam (univ : set X) + 1 + diam (univ : set Y),\n      { rw Ψrange,\n        have : Φ xX ∈ ↑p := Φrange.subst (mem_range_self _),\n        exact exists_dist_lt_of_Hausdorff_dist_lt this bound\n          (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty\n            p.compact.bounded q.compact.bounded) },\n      rcases this with ⟨y, hy, dy⟩,\n      rcases mem_range.1 hy with ⟨z, hzy⟩,\n      rw ← hzy at dy,\n      have DΦ : diam (range Φ) = diam (univ : set X) := Φisom.diam_range,\n      have DΨ : diam (range Ψ) = diam (univ : set Y) := Ψisom.diam_range,\n      calc\n        diam (range Φ ∪ range Ψ) ≤ diam (range Φ) + dist (Φ xX) (Ψ z) + diam (range Ψ) :\n          diam_union (mem_range_self _) (mem_range_self _)\n        ... ≤ diam (univ : set X) + (diam (univ : set X) + 1 + diam (univ : set Y)) +\n              diam (univ : set Y) :\n          by { rw [DΦ, DΨ], apply add_le_add (add_le_add le_rfl (le_of_lt dy)) le_rfl }\n        ... = 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y) : by ring },\n\n    let f : X ⊕ Y → ℓ_infty_ℝ := λ x, match x with | inl y := Φ y | inr z := Ψ z end,\n    let F : (X ⊕ Y) × (X ⊕ Y) → ℝ := λ p, dist (f p.1) (f p.2),\n    -- check that the induced \"distance\" is a candidate\n    have Fgood : F ∈ candidates X Y,\n    { simp only [candidates, forall_const, and_true, add_comm, eq_self_iff_true, dist_eq_zero,\n                 and_self, set.mem_set_of_eq],\n      repeat {split},\n      { exact λ x y, calc\n        F (inl x, inl y) = dist (Φ x) (Φ y) : rfl\n        ... = dist x y : Φisom.dist_eq x y },\n      { exact λ x y, calc\n        F (inr x, inr y) = dist (Ψ x) (Ψ y) : rfl\n        ... = dist x y : Ψisom.dist_eq x y },\n      { exact λ x y, dist_comm _ _ },\n      { exact λ x y z, dist_triangle _ _ _ },\n      { exact λ x y, calc\n        F (x, y) ≤ diam (range Φ ∪ range Ψ) :\n        begin\n          have A : ∀ z : X ⊕ Y, f z ∈ range Φ ∪ range Ψ,\n          { assume z,\n            cases z,\n            { apply mem_union_left, apply mem_range_self },\n            { apply mem_union_right, apply mem_range_self } },\n          refine dist_le_diam_of_mem _ (A _) (A _),\n          rw [Φrange, Ψrange],\n          exact (p ⊔ q).compact.bounded,\n        end\n        ... ≤ 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y) : I } },\n    let Fb := candidates_b_of_candidates F Fgood,\n    have : Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤ HD Fb :=\n      Hausdorff_dist_optimal_le_HD _ _ (candidates_b_of_candidates_mem F Fgood),\n    refine le_trans this (le_of_forall_le_of_dense (λ r hr, _)),\n    have I1 : ∀ x : X, (⨅ y, Fb (inl x, inr y)) ≤ r,\n    { assume x,\n      have : f (inl x) ∈ ↑p := Φrange.subst (mem_range_self _),\n      rcases exists_dist_lt_of_Hausdorff_dist_lt this hr\n        (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty\n          p.compact.bounded q.compact.bounded)\n        with ⟨z, zq, hz⟩,\n      have : z ∈ range Ψ, by rwa [← Ψrange] at zq,\n      rcases mem_range.1 this with ⟨y, hy⟩,\n      calc (⨅ y, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux1 0) y\n        ... = dist (Φ x) (Ψ y) : rfl\n        ... = dist (f (inl x)) z : by rw hy\n        ... ≤ r : le_of_lt hz },\n    have I2 : ∀ y : Y, (⨅ x, Fb (inl x, inr y)) ≤ r,\n    { assume y,\n      have : f (inr y) ∈ ↑q := Ψrange.subst (mem_range_self _),\n      rcases exists_dist_lt_of_Hausdorff_dist_lt' this hr\n        (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty\n          p.compact.bounded q.compact.bounded)\n        with ⟨z, zq, hz⟩,\n      have : z ∈ range Φ, by rwa [← Φrange] at zq,\n      rcases mem_range.1 this with ⟨x, hx⟩,\n      calc (⨅ x, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux2 0) x\n        ... = dist (Φ x) (Ψ y) : rfl\n        ... = dist z (f (inr y)) : by rw hx\n        ... ≤ r : le_of_lt hz },\n    simp [HD, csupr_le I1, csupr_le I2] },\n  /- Get the same inequality for any coupling. If the coupling is quite good, the desired\n  inequality has been proved above. If it is bad, then the inequality is obvious. -/\n  have B : ∀ p q : nonempty_compacts ℓ_infty_ℝ, ⟦p⟧ = to_GH_space X → ⟦q⟧ = to_GH_space Y →\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤\n        Hausdorff_dist (p : set ℓ_infty_ℝ) q,\n  { assume p q hp hq,\n    by_cases h :\n      Hausdorff_dist (p : set ℓ_infty_ℝ) q < diam (univ : set X) + 1 + diam (univ : set Y),\n    { exact A p q hp hq h },\n    { calc Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y))\n               ≤ HD (candidates_b_dist X Y) :\n             Hausdorff_dist_optimal_le_HD _ _ (candidates_b_dist_mem_candidates_b)\n           ... ≤ diam (univ : set X) + 1 + diam (univ : set Y) : HD_candidates_b_dist_le\n           ... ≤ Hausdorff_dist (p : set ℓ_infty_ℝ) q : not_lt.1 h } },\n  refine le_antisymm _ _,\n  { apply le_cInf,\n    { refine (set.nonempty.prod _ _).image _; exact ⟨_, rfl⟩ },\n    { rintro b ⟨⟨p, q⟩, ⟨hp, hq⟩, rfl⟩,\n      exact B p q hp hq } },\n  { exact GH_dist_le_Hausdorff_dist (isometry_optimal_GH_injl X Y) (isometry_optimal_GH_injr X Y) }\nend\n\n/-- The Gromov-Hausdorff distance can also be realized by a coupling in `ℓ^∞(ℝ)`, by embedding\nthe optimal coupling through its Kuratowski embedding. -/\ntheorem GH_dist_eq_Hausdorff_dist (X : Type u) [metric_space X] [compact_space X] [nonempty X]\n  (Y : Type v) [metric_space Y] [compact_space Y] [nonempty Y] :\n  ∃ Φ : X → ℓ_infty_ℝ, ∃ Ψ : Y → ℓ_infty_ℝ, isometry Φ ∧ isometry Ψ ∧\n  GH_dist X Y = Hausdorff_dist (range Φ) (range Ψ) :=\nbegin\n  let F := Kuratowski_embedding (optimal_GH_coupling X Y),\n  let Φ := F ∘ optimal_GH_injl X Y,\n  let Ψ := F ∘ optimal_GH_injr X Y,\n  refine ⟨Φ, Ψ, _, _, _⟩,\n  { exact (Kuratowski_embedding.isometry _).comp (isometry_optimal_GH_injl X Y) },\n  { exact (Kuratowski_embedding.isometry _).comp (isometry_optimal_GH_injr X Y) },\n  { rw [← image_univ, ← image_univ, image_comp F, image_univ, image_comp F (optimal_GH_injr X Y),\n      image_univ, ← Hausdorff_dist_optimal],\n    exact (Hausdorff_dist_image (Kuratowski_embedding.isometry _)).symm },\nend\n\n/-- The Gromov-Hausdorff distance defines a genuine distance on the Gromov-Hausdorff space. -/\ninstance : metric_space GH_space :=\n{ dist := dist,\n  dist_self := λ x, begin\n    rcases exists_rep x with ⟨y, hy⟩,\n    refine le_antisymm _ _,\n    { apply cInf_le,\n      { exact ⟨0, by { rintro b ⟨⟨u, v⟩, ⟨hu, hv⟩, rfl⟩, exact Hausdorff_dist_nonneg } ⟩},\n      { simp, existsi [y, y], simpa } },\n    { apply le_cInf,\n      { exact (nonempty.prod ⟨y, hy⟩ ⟨y, hy⟩).image _ },\n      { rintro b ⟨⟨u, v⟩, ⟨hu, hv⟩, rfl⟩, exact Hausdorff_dist_nonneg } },\n  end,\n  dist_comm := λ x y, begin\n    have A : (λ (p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n                 Hausdorff_dist (p.1 : set ℓ_infty_ℝ) p.2) ''\n             ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y})\n           = ((λ (p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n                 Hausdorff_dist (p.1 : set ℓ_infty_ℝ) p.2) ∘ prod.swap) ''\n                 ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y}) :=\n      by { congr, funext, simp, rw Hausdorff_dist_comm },\n    simp only [dist, A, image_comp, image_swap_prod],\n  end,\n  eq_of_dist_eq_zero := λ x y hxy, begin\n    /- To show that two spaces at zero distance are isometric, we argue that the distance\n    is realized by some coupling. In this coupling, the two spaces are at zero Hausdorff distance,\n    i.e., they coincide. Therefore, the original spaces are isometric. -/\n    rcases GH_dist_eq_Hausdorff_dist x.rep y.rep with ⟨Φ, Ψ, Φisom, Ψisom, DΦΨ⟩,\n    rw [← dist_GH_dist, hxy] at DΦΨ,\n    have : range Φ = range Ψ,\n    { have hΦ : is_compact (range Φ) := is_compact_range Φisom.continuous,\n      have hΨ : is_compact (range Ψ) := is_compact_range Ψisom.continuous,\n      apply (is_closed.Hausdorff_dist_zero_iff_eq _ _ _).1 (DΦΨ.symm),\n      { exact hΦ.is_closed },\n      { exact hΨ.is_closed },\n      { exact Hausdorff_edist_ne_top_of_nonempty_of_bounded (range_nonempty _)\n          (range_nonempty _) hΦ.bounded hΨ.bounded } },\n    have T : ((range Ψ) ≃ᵢ y.rep) = ((range Φ) ≃ᵢ y.rep), by rw this,\n    have eΨ := cast T Ψisom.isometric_on_range.symm,\n    have e := Φisom.isometric_on_range.trans eΨ,\n    rw [← x.to_GH_space_rep, ← y.to_GH_space_rep, to_GH_space_eq_to_GH_space_iff_isometric],\n    exact ⟨e⟩\n  end,\n  dist_triangle := λ x y z, begin\n    /- To show the triangular inequality between `X`, `Y` and `Z`, realize an optimal coupling\n    between `X` and `Y` in a space `γ1`, and an optimal coupling between `Y` and `Z` in a space\n    `γ2`. Then, glue these metric spaces along `Y`. We get a new space `γ` in which `X` and `Y` are\n    optimally coupled, as well as `Y` and `Z`. Apply the triangle inequality for the Hausdorff\n    distance in `γ` to conclude. -/\n    let X := x.rep,\n    let Y := y.rep,\n    let Z := z.rep,\n    let γ1 := optimal_GH_coupling X Y,\n    let γ2 := optimal_GH_coupling Y Z,\n    let Φ : Y → γ1 := optimal_GH_injr X Y,\n    have hΦ : isometry Φ := isometry_optimal_GH_injr X Y,\n    let Ψ : Y → γ2 := optimal_GH_injl Y Z,\n    have hΨ : isometry Ψ := isometry_optimal_GH_injl Y Z,\n    let γ := glue_space hΦ hΨ,\n    letI : metric_space γ := metric.metric_space_glue_space hΦ hΨ,\n    have Comm : (to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y) =\n      (to_glue_r hΦ hΨ) ∘ (optimal_GH_injl Y Z) := to_glue_commute hΦ hΨ,\n    calc dist x z = dist (to_GH_space X) (to_GH_space Z) :\n        by rw [x.to_GH_space_rep, z.to_GH_space_rep]\n      ... ≤ Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injl X Y)))\n                       (range ((to_glue_r hΦ hΨ) ∘ (optimal_GH_injr Y Z))) :\n        GH_dist_le_Hausdorff_dist\n          ((to_glue_l_isometry hΦ hΨ).comp (isometry_optimal_GH_injl X Y))\n          ((to_glue_r_isometry hΦ hΨ).comp (isometry_optimal_GH_injr Y Z))\n      ... ≤ Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injl X Y)))\n                           (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y)))\n          + Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y)))\n                           (range ((to_glue_r hΦ hΨ) ∘ (optimal_GH_injr Y Z))) :\n        begin\n          refine Hausdorff_dist_triangle (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n            (range_nonempty _) (range_nonempty _) _ _),\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry hΦ hΨ).comp\n              (isometry_optimal_GH_injl X Y)))).bounded },\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry hΦ hΨ).comp\n              (isometry_optimal_GH_injr X Y)))).bounded }\n        end\n      ... = Hausdorff_dist ((to_glue_l hΦ hΨ) '' (range (optimal_GH_injl X Y)))\n                           ((to_glue_l hΦ hΨ) '' (range (optimal_GH_injr X Y)))\n          + Hausdorff_dist ((to_glue_r hΦ hΨ) '' (range (optimal_GH_injl Y Z)))\n                           ((to_glue_r hΦ hΨ) '' (range (optimal_GH_injr Y Z))) :\n        by simp only [← range_comp, Comm, eq_self_iff_true, add_right_inj]\n      ... = Hausdorff_dist (range (optimal_GH_injl X Y))\n                           (range (optimal_GH_injr X Y))\n          + Hausdorff_dist (range (optimal_GH_injl Y Z))\n                           (range (optimal_GH_injr Y Z)) :\n        by rw [Hausdorff_dist_image (to_glue_l_isometry hΦ hΨ),\n               Hausdorff_dist_image (to_glue_r_isometry hΦ hΨ)]\n      ... = dist (to_GH_space X) (to_GH_space Y) + dist (to_GH_space Y) (to_GH_space Z) :\n        by rw [Hausdorff_dist_optimal, Hausdorff_dist_optimal, GH_dist, GH_dist]\n      ... = dist x y + dist y z:\n        by rw [x.to_GH_space_rep, y.to_GH_space_rep, z.to_GH_space_rep]\n  end }\n\nend GH_space --section\nend Gromov_Hausdorff\n\n/-- In particular, nonempty compacts of a metric space map to `GH_space`. We register this\nin the topological_space namespace to take advantage of the notation `p.to_GH_space`. -/\ndefinition topological_space.nonempty_compacts.to_GH_space {X : Type u} [metric_space X]\n  (p : nonempty_compacts X) : Gromov_Hausdorff.GH_space := Gromov_Hausdorff.to_GH_space p\n\nopen topological_space\n\nnamespace Gromov_Hausdorff\n\nsection nonempty_compacts\nvariables {X : Type u} [metric_space X]\n\ntheorem GH_dist_le_nonempty_compacts_dist (p q : nonempty_compacts X) :\n  dist p.to_GH_space q.to_GH_space ≤ dist p q :=\nbegin\n  have ha : isometry (coe : p → X) := isometry_subtype_coe,\n  have hb : isometry (coe : q → X) := isometry_subtype_coe,\n  have A : dist p q = Hausdorff_dist (p : set X) q := rfl,\n  have I : ↑p = range (coe : p → X) := subtype.range_coe_subtype.symm,\n  have J : ↑q = range (coe : q → X) := subtype.range_coe_subtype.symm,\n  rw [A, I, J],\n  exact GH_dist_le_Hausdorff_dist ha hb\nend\n\nlemma to_GH_space_lipschitz :\n  lipschitz_with 1 (nonempty_compacts.to_GH_space : nonempty_compacts X → GH_space) :=\nlipschitz_with.mk_one GH_dist_le_nonempty_compacts_dist\n\nlemma to_GH_space_continuous :\n  continuous (nonempty_compacts.to_GH_space : nonempty_compacts X → GH_space) :=\nto_GH_space_lipschitz.continuous\n\nend nonempty_compacts\n\nsection\n/- In this section, we show that if two metric spaces are isometric up to `ε₂`, then their\nGromov-Hausdorff distance is bounded by `ε₂ / 2`. More generally, if there are subsets which are\n`ε₁`-dense and `ε₃`-dense in two spaces, and isometric up to `ε₂`, then the Gromov-Hausdorff\ndistance between the spaces is bounded by `ε₁ + ε₂/2 + ε₃`. For this, we construct a suitable\ncoupling between the two spaces, by gluing them (approximately) along the two matching subsets. -/\n\n\nvariables {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n          {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y]\n\n-- we want to ignore these instances in the following theorem\nlocal attribute [instance, priority 10] sum.topological_space sum.uniform_space\n/-- If there are subsets which are `ε₁`-dense and `ε₃`-dense in two spaces, and\nisometric up to `ε₂`, then the Gromov-Hausdorff distance between the spaces is bounded by\n`ε₁ + ε₂/2 + ε₃`. -/\ntheorem GH_dist_le_of_approx_subsets {s : set X} (Φ : s → Y) {ε₁ ε₂ ε₃ : ℝ}\n  (hs : ∀ x : X, ∃ y ∈ s, dist x y ≤ ε₁) (hs' : ∀ x : Y, ∃ y : s, dist x (Φ y) ≤ ε₃)\n  (H : ∀ x y : s, |dist x y - dist (Φ x) (Φ y)| ≤ ε₂) :\n  GH_dist X Y ≤ ε₁ + ε₂ / 2 + ε₃ :=\nbegin\n  refine le_of_forall_pos_le_add (λ δ δ0, _),\n  rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n  rcases hs xX with ⟨xs, hxs, Dxs⟩,\n  have sne : s.nonempty := ⟨xs, hxs⟩,\n  letI : nonempty s := sne.to_subtype,\n  have : 0 ≤ ε₂ := le_trans (abs_nonneg _) (H ⟨xs, hxs⟩ ⟨xs, hxs⟩),\n  have : ∀ p q : s, |dist p q - dist (Φ p) (Φ q)| ≤ 2 * (ε₂/2 + δ) := λ p q, calc\n    |dist p q - dist (Φ p) (Φ q)| ≤ ε₂ : H p q\n    ... ≤ 2 * (ε₂/2 + δ) : by linarith,\n  -- glue `X` and `Y` along the almost matching subsets\n  letI : metric_space (X ⊕ Y) :=\n    glue_metric_approx (λ x:s, (x:X)) (λ x, Φ x) (ε₂/2 + δ) (by linarith) this,\n  let Fl := @sum.inl X Y,\n  let Fr := @sum.inr X Y,\n  have Il : isometry Fl := isometry_emetric_iff_metric.2 (λ x y, rfl),\n  have Ir : isometry Fr := isometry_emetric_iff_metric.2 (λ x y, rfl),\n  /- The proof goes as follows : the `GH_dist` is bounded by the Hausdorff distance of the images\n  in the coupling, which is bounded (using the triangular inequality) by the sum of the Hausdorff\n  distances of `X` and `s` (in the coupling or, equivalently in the original space), of `s` and\n  `Φ s`, and of `Φ s` and `Y` (in the coupling or, equivalently, in the original space). The first\n  term is bounded by `ε₁`, by `ε₁`-density. The third one is bounded by `ε₃`. And the middle one is\n  bounded by `ε₂/2` as in the coupling the points `x` and `Φ x` are at distance `ε₂/2` by\n  construction of the coupling (in fact `ε₂/2 + δ` where `δ` is an arbitrarily small positive\n  constant where positivity is used to ensure that the coupling is really a metric space and not a\n  premetric space on `X ⊕ Y`). -/\n  have : GH_dist X Y ≤ Hausdorff_dist (range Fl) (range Fr) :=\n    GH_dist_le_Hausdorff_dist Il Ir,\n  have : Hausdorff_dist (range Fl) (range Fr) ≤ Hausdorff_dist (range Fl) (Fl '' s)\n                                              + Hausdorff_dist (Fl '' s) (range Fr),\n  { have B : bounded (range Fl) := (is_compact_range Il.continuous).bounded,\n    exact Hausdorff_dist_triangle (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n      (range_nonempty _) (sne.image _) B (B.mono (image_subset_range _ _))) },\n  have : Hausdorff_dist (Fl '' s) (range Fr) ≤ Hausdorff_dist (Fl '' s) (Fr '' (range Φ))\n                                             + Hausdorff_dist (Fr '' (range Φ)) (range Fr),\n  { have B : bounded (range Fr) := (is_compact_range Ir.continuous).bounded,\n    exact Hausdorff_dist_triangle' (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n      ((range_nonempty _).image _) (range_nonempty _)\n      (bounded.mono (image_subset_range _ _) B) B) },\n  have : Hausdorff_dist (range Fl) (Fl '' s) ≤ ε₁,\n  { rw [← image_univ, Hausdorff_dist_image Il],\n    have : 0 ≤ ε₁ := le_trans dist_nonneg Dxs,\n    refine Hausdorff_dist_le_of_mem_dist this (λ x hx, hs x)\n      (λ x hx, ⟨x, mem_univ _, by simpa⟩) },\n  have : Hausdorff_dist (Fl '' s) (Fr '' (range Φ)) ≤ ε₂/2 + δ,\n  { refine Hausdorff_dist_le_of_mem_dist (by linarith) _ _,\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with ⟨x, ⟨x_in_s, xx'⟩⟩,\n      rw ← xx',\n      use [Fr (Φ ⟨x, x_in_s⟩), mem_image_of_mem Fr (mem_range_self _)],\n      exact le_of_eq (glue_dist_glued_points (λ x:s, (x:X)) Φ (ε₂/2 + δ) ⟨x, x_in_s⟩) },\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with ⟨y, ⟨y_in_s', yx'⟩⟩,\n      rcases mem_range.1 y_in_s' with ⟨x, xy⟩,\n      use [Fl x, mem_image_of_mem _ x.2],\n      rw [← yx', ← xy, dist_comm],\n      exact le_of_eq (glue_dist_glued_points (@subtype.val X s) Φ (ε₂/2 + δ) x) } },\n  have : Hausdorff_dist (Fr '' (range Φ)) (range Fr) ≤ ε₃,\n  { rw [← @image_univ _ _ Fr, Hausdorff_dist_image Ir],\n    rcases exists_mem_of_nonempty Y with ⟨xY, _⟩,\n    rcases hs' xY with ⟨xs', Dxs'⟩,\n    have : 0 ≤ ε₃ := le_trans dist_nonneg Dxs',\n    refine Hausdorff_dist_le_of_mem_dist this (λ x hx, ⟨x, mem_univ _, by simpa⟩) (λ x _, _),\n    rcases hs' x with ⟨y, Dy⟩,\n    exact ⟨Φ y, mem_range_self _, Dy⟩ },\n  linarith\nend\nend --section\n\n/-- The Gromov-Hausdorff space is second countable. -/\ninstance : second_countable_topology GH_space :=\nbegin\n  refine second_countable_of_countable_discretization (λ δ δpos, _),\n  let ε := (2/5) * δ,\n  have εpos : 0 < ε := mul_pos (by norm_num) δpos,\n  have : ∀ p:GH_space, ∃ s : set p.rep, s.finite ∧ (univ ⊆ (⋃x∈s, ball x ε)) :=\n    λ p, by simpa using finite_cover_balls_of_compact (@compact_univ p.rep _ _) εpos,\n  -- for each `p`, `s p` is a finite `ε`-dense subset of `p` (or rather the metric space\n  -- `p.rep` representing `p`)\n  choose s hs using this,\n  have : ∀ p:GH_space, ∀ t:set p.rep, t.finite → ∃ n:ℕ, ∃ e:equiv t (fin n), true,\n  { assume p t ht,\n    letI : fintype t := finite.fintype ht,\n    exact ⟨fintype.card t, fintype.equiv_fin t, trivial⟩ },\n  choose N e hne using this,\n  -- cardinality of the nice finite subset `s p` of `p.rep`, called `N p`\n  let N := λ p:GH_space, N p (s p) (hs p).1,\n  -- equiv from `s p`, a nice finite subset of `p.rep`, to `fin (N p)`, called `E p`\n  let E := λ p:GH_space, e p (s p) (hs p).1,\n  -- A function `F` associating to `p : GH_space` the data of all distances between points\n  -- in the `ε`-dense set `s p`.\n  let F : GH_space → Σn:ℕ, (fin n → fin n → ℤ) :=\n    λp, ⟨N p, λa b, ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋⟩,\n  refine ⟨Σ n, fin n → fin n → ℤ, by apply_instance, F, λp q hpq, _⟩,\n  /- As the target space of F is countable, it suffices to show that two points\n  `p` and `q` with `F p = F q` are at distance `≤ δ`.\n  For this, we construct a map `Φ` from `s p ⊆ p.rep` (representing `p`)\n  to `q.rep` (representing `q`) which is almost an isometry on `s p`, and\n  with image `s q`. For this, we compose the identification of `s p` with `fin (N p)`\n  and the inverse of the identification of `s q` with `fin (N q)`. Together with\n  the fact that `N p = N q`, this constructs `Ψ` between `s p` and `s q`, and then\n  composing with the canonical inclusion we get `Φ`. -/\n  have Npq : N p = N q := (sigma.mk.inj_iff.1 hpq).1,\n  let Ψ : s p → s q := λ x, (E q).symm (fin.cast Npq ((E p) x)),\n  let Φ : s p → q.rep := λ x, Ψ x,\n  -- Use the almost isometry `Φ` to show that `p.rep` and `q.rep`\n  -- are within controlled Gromov-Hausdorff distance.\n  have main : GH_dist p.rep q.rep ≤ ε + ε/2 + ε,\n  { refine GH_dist_le_of_approx_subsets Φ  _ _ _,\n    show ∀ x : p.rep, ∃ (y : p.rep) (H : y ∈ s p), dist x y ≤ ε,\n    { -- by construction, `s p` is `ε`-dense\n      assume x,\n      have : x ∈ ⋃y∈(s p), ball y ε := (hs p).2 (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      exact ⟨y, ys, le_of_lt hy⟩ },\n    show ∀ x : q.rep, ∃ (z : s p), dist x (Φ z) ≤ ε,\n    { -- by construction, `s q` is `ε`-dense, and it is the range of `Φ`\n      assume x,\n      have : x ∈ ⋃y∈(s q), ball y ε := (hs q).2 (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      let i : ℕ := E q ⟨y, ys⟩,\n      let hi := ((E q) ⟨y, ys⟩).is_lt,\n      have ihi_eq : (⟨i, hi⟩ : fin (N q)) = (E q) ⟨y, ys⟩, by rw [fin.ext_iff, fin.coe_mk],\n      have hiq : i < N q := hi,\n      have hip : i < N p, { rwa Npq.symm at hiq },\n      let z := (E p).symm ⟨i, hip⟩,\n      use z,\n      have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩,\n      have C2 : fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl,\n      have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩,\n        by { rw ihi_eq, exact (E q).symm_apply_apply ⟨y, ys⟩ },\n      have : Φ z = y :=\n        by { simp only [Φ, Ψ], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_of_lt hy },\n    show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `Φ x` in `fin (N p) = fin (N q)`\n      let i : ℕ := E p x,\n      have hip : i < N p := ((E p) x).2,\n      have hiq : i < N q, by rwa Npq at hip,\n      have i' : i = ((E q) (Ψ x)), by { simp [Ψ] },\n      -- introduce `j`, that codes both `y` and `Φ y` in `fin (N p) = fin (N q)`\n      let j : ℕ := E p y,\n      have hjp : j < N p := ((E p) y).2,\n      have hjq : j < N q, by rwa Npq at hjp,\n      have j' : j = ((E q) (Ψ y)).1, by { simp [Ψ] },\n      -- Express `dist x y` in terms of `F p`\n      have : (F p).2 ((E p) x) ((E p) y) = floor (ε⁻¹ * dist x y),\n        by simp only [F, (E p).symm_apply_apply],\n      have Ap : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = floor (ε⁻¹ * dist x y),\n        by { rw ← this, congr; apply (fin.ext_iff _ _).2; refl },\n      -- Express `dist (Φ x) (Φ y)` in terms of `F q`\n      have : (F q).2 ((E q) (Ψ x)) ((E q) (Ψ y)) = floor (ε⁻¹ * dist (Ψ x) (Ψ y)),\n        by simp only [F, (E q).symm_apply_apply],\n      have Aq : (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩ = floor (ε⁻¹ * dist (Ψ x) (Ψ y)),\n        by { rw ← this, congr; apply (fin.ext_iff _ _).2; [exact i', exact j'] },\n      -- use the equality between `F p` and `F q` to deduce that the distances have equal\n      -- integer parts\n      have : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩,\n      { -- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works\n        -- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`\n        -- then `subst`\n        revert hiq hjq,\n        change N q with (F q).1,\n        generalize_hyp : F q = f at hpq ⊢,\n        subst hpq,\n        intros,\n        refl },\n      rw [Ap, Aq] at this,\n      -- deduce that the distances coincide up to `ε`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| =\n          |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| : (abs_mul _ _).symm\n        ... = |(ε⁻¹ * dist x y) - (ε⁻¹ * dist (Ψ x) (Ψ y))| : by { congr, ring }\n        ... ≤ 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (Ψ x) (Ψ y)| = (ε * ε⁻¹) * |dist x y - dist (Ψ x) (Ψ y)| :\n          by rw [mul_inv_cancel (ne_of_gt εpos), one_mul]\n        ... = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]\n        ... ≤ ε * 1 : mul_le_mul_of_nonneg_left I (le_of_lt εpos)\n        ... = ε : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... ≤ ε + ε/2 + ε : main\n    ... = δ : by { simp [ε], ring }\nend\n\n/-- Compactness criterion: a closed set of compact metric spaces is compact if the spaces have\na uniformly bounded diameter, and for all `ε` the number of balls of radius `ε` required\nto cover the spaces is uniformly bounded. This is an equivalence, but we only prove the\ninteresting direction that these conditions imply compactness. -/\nlemma totally_bounded {t : set GH_space} {C : ℝ} {u : ℕ → ℝ} {K : ℕ → ℕ}\n  (ulim : tendsto u at_top (𝓝 0))\n  (hdiam : ∀ p ∈ t, diam (univ : set (GH_space.rep p)) ≤ C)\n  (hcov : ∀ p ∈ t, ∀ n:ℕ, ∃ s : set (GH_space.rep p),\n    cardinal.mk s ≤ K n ∧ univ ⊆ ⋃x∈s, ball x (u n)) :\n  totally_bounded t :=\nbegin\n  /- Let `δ>0`, and `ε = δ/5`. For each `p`, we construct a finite subset `s p` of `p`, which\n  is `ε`-dense and has cardinality at most `K n`. Encoding the mutual distances of points in `s p`,\n  up to `ε`, we will get a map `F` associating to `p` finitely many data, and making it possible to\n  reconstruct `p` up to `ε`. This is enough to prove total boundedness. -/\n  refine metric.totally_bounded_of_finite_discretization (λ δ δpos, _),\n  let ε := (1/5) * δ,\n  have εpos : 0 < ε := mul_pos (by norm_num) δpos,\n  -- choose `n` for which `u n < ε`\n  rcases metric.tendsto_at_top.1 ulim ε εpos with ⟨n, hn⟩,\n  have u_le_ε : u n ≤ ε,\n  { have := hn n le_rfl,\n    simp only [real.dist_eq, add_zero, sub_eq_add_neg, neg_zero] at this,\n    exact le_of_lt (lt_of_le_of_lt (le_abs_self _) this) },\n  -- construct a finite subset `s p` of `p` which is `ε`-dense and has cardinal `≤ K n`\n  have : ∀ p:GH_space, ∃ s : set p.rep, ∃ N ≤ K n, ∃ E : equiv s (fin N),\n    p ∈ t → univ ⊆ ⋃x∈s, ball x (u n),\n  { assume p,\n    by_cases hp : p ∉ t,\n    { have : nonempty (equiv (∅ : set p.rep) (fin 0)),\n      { rw ← fintype.card_eq, simp },\n      use [∅, 0, bot_le, choice (this)] },\n    { rcases hcov _ (set.not_not_mem.1 hp) n with ⟨s, ⟨scard, scover⟩⟩,\n      rcases cardinal.lt_aleph_0.1 (lt_of_le_of_lt scard (cardinal.nat_lt_aleph_0 _)) with ⟨N, hN⟩,\n      rw [hN, cardinal.nat_cast_le] at scard,\n      have : cardinal.mk s = cardinal.mk (fin N), by rw [hN, cardinal.mk_fin],\n      cases quotient.exact this with E,\n      use [s, N, scard, E],\n      simp [hp, scover] } },\n  choose s N hN E hs using this,\n  -- Define a function `F` taking values in a finite type and associating to `p` enough data\n  -- to reconstruct it up to `ε`, namely the (discretized) distances between elements of `s p`.\n  let M := ⌊ε⁻¹ * max C 0⌋₊,\n  let F : GH_space → (Σk:fin ((K n).succ), (fin k → fin k → fin (M.succ))) :=\n    λ p, ⟨⟨N p, lt_of_le_of_lt (hN p) (nat.lt_succ_self _)⟩,\n         λ a b, ⟨min M ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋₊,\n                ( min_le_left _ _).trans_lt (nat.lt_succ_self _) ⟩ ⟩,\n  refine ⟨_, _, (λ p, F p), _⟩, apply_instance,\n  -- It remains to show that if `F p = F q`, then `p` and `q` are `ε`-close\n  rintros ⟨p, pt⟩ ⟨q, qt⟩ hpq,\n  have Npq : N p = N q := (fin.ext_iff _ _).1 (sigma.mk.inj_iff.1 hpq).1,\n  let Ψ : s p → s q := λ x, (E q).symm (fin.cast Npq ((E p) x)),\n  let Φ : s p → q.rep := λ x, Ψ x,\n  have main : GH_dist p.rep (q.rep) ≤ ε + ε/2 + ε,\n  { -- to prove the main inequality, argue that `s p` is `ε`-dense in `p`, and `s q` is `ε`-dense\n    -- in `q`, and `s p` and `s q` are almost isometric. Then closeness follows\n    -- from `GH_dist_le_of_approx_subsets`\n    refine GH_dist_le_of_approx_subsets Φ  _ _ _,\n    show ∀ x : p.rep, ∃ (y : p.rep) (H : y ∈ s p), dist x y ≤ ε,\n    { -- by construction, `s p` is `ε`-dense\n      assume x,\n      have : x ∈ ⋃y∈(s p), ball y (u n) := (hs p pt) (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      exact ⟨y, ys, le_trans (le_of_lt hy) u_le_ε⟩ },\n    show ∀ x : q.rep, ∃ (z : s p), dist x (Φ z) ≤ ε,\n    { -- by construction, `s q` is `ε`-dense, and it is the range of `Φ`\n      assume x,\n      have : x ∈ ⋃y∈(s q), ball y (u n) := (hs q qt) (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      let i : ℕ := E q ⟨y, ys⟩,\n      let hi := ((E q) ⟨y, ys⟩).2,\n      have ihi_eq : (⟨i, hi⟩ : fin (N q)) = (E q) ⟨y, ys⟩, by rw [fin.ext_iff, fin.coe_mk],\n      have hiq : i < N q := hi,\n      have hip : i < N p, { rwa Npq.symm at hiq },\n      let z := (E p).symm ⟨i, hip⟩,\n      use z,\n      have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩,\n      have C2 : fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl,\n      have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩,\n        by { rw ihi_eq, exact (E q).symm_apply_apply ⟨y, ys⟩ },\n      have : Φ z = y :=\n        by { simp only [Φ, Ψ], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_trans (le_of_lt hy) u_le_ε },\n    show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `Φ x` in `fin (N p) = fin (N q)`\n      let i : ℕ := E p x,\n      have hip : i < N p := ((E p) x).2,\n      have hiq : i < N q, by rwa Npq at hip,\n      have i' : i = ((E q) (Ψ x)), by { simp [Ψ] },\n      -- introduce `j`, that codes both `y` and `Φ y` in `fin (N p) = fin (N q)`\n      let j : ℕ := E p y,\n      have hjp : j < N p := ((E p) y).2,\n      have hjq : j < N q, by rwa Npq at hjp,\n      have j' : j = ((E q) (Ψ y)), by { simp [Ψ] },\n      -- Express `dist x y` in terms of `F p`\n      have Ap : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ⌊ε⁻¹ * dist x y⌋₊ := calc\n        ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F p).2 ((E p) x) ((E p) y)).1 :\n          by { congr; apply (fin.ext_iff _ _).2; refl }\n        ... = min M ⌊ε⁻¹ * dist x y⌋₊ :\n          by simp only [F, (E p).symm_apply_apply]\n        ... = ⌊ε⁻¹ * dist x y⌋₊ :\n        begin\n          refine min_eq_right (nat.floor_mono _),\n          refine mul_le_mul_of_nonneg_left (le_trans _ (le_max_left _ _)) ((inv_pos.2 εpos).le),\n          change dist (x : p.rep) y ≤ C,\n          refine le_trans (dist_le_diam_of_mem compact_univ.bounded (mem_univ _) (mem_univ _)) _,\n          exact hdiam p pt\n        end,\n      -- Express `dist (Φ x) (Φ y)` in terms of `F q`\n      have Aq : ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ := calc\n        ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ((F q).2 ((E q) (Ψ x)) ((E q) (Ψ y))).1 :\n          by { congr; apply (fin.ext_iff _ _).2; [exact i', exact j'] }\n        ... = min M ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ :\n          by simp only [F, (E q).symm_apply_apply]\n        ... = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ :\n        begin\n          refine min_eq_right (nat.floor_mono _),\n          refine mul_le_mul_of_nonneg_left (le_trans _ (le_max_left _ _)) ((inv_pos.2 εpos).le),\n          change dist (Ψ x : q.rep) (Ψ y) ≤ C,\n          refine le_trans (dist_le_diam_of_mem compact_univ.bounded (mem_univ _) (mem_univ _)) _,\n          exact hdiam q qt\n        end,\n      -- use the equality between `F p` and `F q` to deduce that the distances have equal\n      -- integer parts\n      have : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1,\n      { -- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works\n        -- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`\n        -- then `subst`\n        revert hiq hjq,\n        change N q with (F q).1,\n        generalize_hyp : F q = f at hpq ⊢,\n        subst hpq,\n        intros,\n        refl },\n      have : ⌊ε⁻¹ * dist x y⌋ = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋,\n      { rw [Ap, Aq] at this,\n        have D : 0 ≤ ⌊ε⁻¹ * dist x y⌋ :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg),\n        have D' : 0 ≤ ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋ :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg),\n        rw [← int.to_nat_of_nonneg D, ← int.to_nat_of_nonneg D', int.floor_to_nat,int.floor_to_nat,\n          this] },\n      -- deduce that the distances coincide up to `ε`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| =\n          |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| : (abs_mul _ _).symm\n        ... = |(ε⁻¹ * dist x y) - (ε⁻¹ * dist (Ψ x) (Ψ y))| : by { congr, ring }\n        ... ≤ 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (Ψ x) (Ψ y)| = (ε * ε⁻¹) * |dist x y - dist (Ψ x) (Ψ y)| :\n          by rw [mul_inv_cancel (ne_of_gt εpos), one_mul]\n        ... = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]\n        ... ≤ ε * 1 : mul_le_mul_of_nonneg_left I (le_of_lt εpos)\n        ... = ε : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... ≤ ε + ε/2 + ε : main\n    ... = δ/2 : by { simp [ε], ring }\n    ... < δ : half_lt_self δpos\nend\n\nsection complete\n\n/- We will show that a sequence `u n` of compact metric spaces satisfying\n`dist (u n) (u (n+1)) < 1/2^n` converges, which implies completeness of the Gromov-Hausdorff space.\nWe need to exhibit the limiting compact metric space. For this, start from\na sequence `X n` of representatives of `u n`, and glue in an optimal way `X n` to `X (n+1)`\nfor all `n`, in a common metric space. Formally, this is done as follows.\nStart from `Y 0 = X 0`. Then, glue `X 0` to `X 1` in an optimal way, yielding a space\n`Y 1` (with an embedding of `X 1`). Then, consider an optimal gluing of `X 1` and `X 2`, and\nglue it to `Y 1` along their common subspace `X 1`. This gives a new space `Y 2`, with an\nembedding of `X 2`. Go on, to obtain a sequence of spaces `Y n`. Let `Z0` be the inductive\nlimit of the `Y n`, and finally let `Z` be the completion of `Z0`.\nThe images `X2 n` of `X n` in `Z` are at Hausdorff distance `< 1/2^n` by construction, hence they\nform a Cauchy sequence for the Hausdorff distance. By completeness (of `Z`, and therefore of its\nset of nonempty compact subsets), they converge to a limit `L`. This is the nonempty\ncompact metric space we are looking for.  -/\n\nvariables (X : ℕ → Type) [∀ n, metric_space (X n)] [∀ n, compact_space (X n)] [∀ n, nonempty (X n)]\n\n/-- Auxiliary structure used to glue metric spaces below, recording an isometric embedding\nof a type `A` in another metric space. -/\nstructure aux_gluing_struct (A : Type) [metric_space A] : Type 1 :=\n(space  : Type)\n(metric : metric_space space)\n(embed  : A → space)\n(isom   : isometry embed)\n\ninstance (A : Type) [metric_space A] : inhabited (aux_gluing_struct A) :=\n⟨{ space := A,\n  metric := by apply_instance,\n  embed := id,\n  isom := λ x y, rfl }⟩\n\n/-- Auxiliary sequence of metric spaces, containing copies of `X 0`, ..., `X n`, where each\n`X i` is glued to `X (i+1)` in an optimal way. The space at step `n+1` is obtained from the space\nat step `n` by adding `X (n+1)`, glued in an optimal way to the `X n` already sitting there. -/\ndef aux_gluing (n : ℕ) : aux_gluing_struct (X n) := nat.rec_on n\n  { space  := X 0,\n    metric := by apply_instance,\n    embed  := id,\n    isom   := λ x y, rfl }\n(λ n Y, by letI : metric_space Y.space := Y.metric; exact\n  { space  := glue_space Y.isom (isometry_optimal_GH_injl (X n) (X (n+1))),\n    metric := by apply_instance,\n    embed  := (to_glue_r Y.isom (isometry_optimal_GH_injl (X n) (X (n+1))))\n              ∘ (optimal_GH_injr (X n) (X (n+1))),\n    isom   := (to_glue_r_isometry _ _).comp (isometry_optimal_GH_injr (X n) (X (n+1))) })\n\n/-- The Gromov-Hausdorff space is complete. -/\ninstance : complete_space GH_space :=\nbegin\n  have : ∀ (n : ℕ), 0 < ((1:ℝ) / 2) ^ n, by { apply pow_pos, norm_num },\n  -- start from a sequence of nonempty compact metric spaces within distance `1/2^n` of each other\n  refine metric.complete_of_convergent_controlled_sequences (λ n, (1/2)^n) this (λ u hu, _),\n  -- `X n` is a representative of `u n`\n  let X := λ n, (u n).rep,\n  -- glue them together successively in an optimal way, getting a sequence of metric spaces `Y n`\n  let Y := aux_gluing X,\n  letI : ∀ n, metric_space (Y n).space := λ n, (Y n).metric,\n  have E : ∀ n : ℕ,\n    glue_space (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)) = (Y n.succ).space :=\n    λ n, by { simp [Y, aux_gluing], refl },\n  let c := λ n, cast (E n),\n  have ic : ∀ n, isometry (c n) := λ n x y, rfl,\n  -- there is a canonical embedding of `Y n` in `Y (n+1)`, by construction\n  let f : Πn, (Y n).space → (Y n.succ).space :=\n    λ n, (c n) ∘ (to_glue_l (aux_gluing X n).isom (isometry_optimal_GH_injl (X n) (X n.succ))),\n  have I : ∀ n, isometry (f n),\n  { assume n,\n    apply isometry.comp,\n    { assume x y, refl },\n    { apply to_glue_l_isometry } },\n  -- consider the inductive limit `Z0` of the `Y n`, and then its completion `Z`\n  let Z0 := metric.inductive_limit I,\n  let Z := uniform_space.completion Z0,\n  let Φ := to_inductive_limit I,\n  let coeZ := (coe : Z0 → Z),\n  -- let `X2 n` be the image of `X n` in the space `Z`\n  let X2 := λ n, range (coeZ ∘ (Φ n) ∘ (Y n).embed),\n  have isom : ∀ n, isometry (coeZ ∘ (Φ n) ∘ (Y n).embed),\n  { assume n,\n    refine uniform_space.completion.coe_isometry.comp _,\n    exact (to_inductive_limit_isometry _ _).comp (Y n).isom },\n  -- The Hausdorff distance of `X2 n` and `X2 (n+1)` is by construction the distance between\n  -- `u n` and `u (n+1)`, therefore bounded by `1/2^n`\n  have D2 : ∀ n, Hausdorff_dist (X2 n) (X2 n.succ) < (1/2)^n,\n  { assume n,\n    have X2n : X2 n = range ((coeZ ∘ (Φ n.succ) ∘ (c n)\n      ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      ∘ (optimal_GH_injl (X n) (X n.succ))),\n    { change X2 n = range (coeZ ∘ (Φ n.succ) ∘ (c n)\n        ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)))\n        ∘ (optimal_GH_injl (X n) (X n.succ))),\n      simp only [X2, Φ],\n      rw [← to_inductive_limit_commute I],\n      simp only [f],\n      rw ← to_glue_commute },\n    rw range_comp at X2n,\n    have X2nsucc : X2 n.succ = range ((coeZ ∘ (Φ n.succ) ∘ (c n)\n      ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      ∘ (optimal_GH_injr (X n) (X n.succ))), by refl,\n    rw range_comp at X2nsucc,\n    rw [X2n, X2nsucc, Hausdorff_dist_image, Hausdorff_dist_optimal, ← dist_GH_dist],\n    { exact hu n n n.succ (le_refl n) (le_succ n) },\n    { apply uniform_space.completion.coe_isometry.comp _,\n      exact (to_inductive_limit_isometry _ _).comp ((ic n).comp (to_glue_r_isometry _ _)) } },\n  -- consider `X2 n` as a member `X3 n` of the type of nonempty compact subsets of `Z`, which\n  -- is a metric space\n  let X3 : ℕ → nonempty_compacts Z := λ n,\n    ⟨⟨X2 n, is_compact_range (isom n).continuous⟩, range_nonempty _⟩,\n  -- `X3 n` is a Cauchy sequence by construction, as the successive distances are\n  -- bounded by `(1/2)^n`\n  have : cauchy_seq X3,\n  { refine cauchy_seq_of_le_geometric (1/2) 1 (by norm_num) (λ n, _),\n    rw one_mul,\n    exact le_of_lt (D2 n) },\n  -- therefore, it converges to a limit `L`\n  rcases cauchy_seq_tendsto_of_complete this with ⟨L, hL⟩,\n  -- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L`\n  have M : tendsto (λ n, (X3 n).to_GH_space) at_top (𝓝 L.to_GH_space) :=\n    tendsto.comp (to_GH_space_continuous.tendsto _) hL,\n  -- By construction, the image of `X3 n` in the Gromov-Hausdorff space is `u n`.\n  have : ∀ n, (X3 n).to_GH_space = u n,\n  { assume n,\n    rw [nonempty_compacts.to_GH_space, ← (u n).to_GH_space_rep,\n        to_GH_space_eq_to_GH_space_iff_isometric],\n    constructor,\n    convert (isom n).isometric_on_range.symm, },\n  -- Finally, we have proved the convergence of `u n`\n  exact ⟨L.to_GH_space, by simpa [this] using M⟩\nend\n\nend complete--section\n\nend Gromov_Hausdorff --namespace\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/topology/metric_space/gromov_hausdorff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110202, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.48390438902451793}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz, Scott Morrison\n-/\nimport category_theory.preadditive\nimport category_theory.limits.shapes.biproducts\n\n/-!\n# Additive Functors\n\nA functor between two preadditive categories is called *additive*\nprovided that the induced map on hom types is a morphism of abelian\ngroups.\n\nAn additive functor between preadditive categories creates and preserves biproducts.\n\n# Implementation details\n\n`functor.additive` is a `Prop`-valued class, defined by saying that\nfor every two objects `X` and `Y`, the map\n`F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)` is a morphism of abelian\ngroups.\n\n# Project:\n\n- Prove that a functor is additive if it preserves finite biproducts\n  (See https://stacks.math.columbia.edu/tag/010M.)\n-/\n\nnamespace category_theory\n\n/-- A functor `F` is additive provided `F.map` is an additive homomorphism. -/\nclass functor.additive {C D : Type*} [category C] [category D]\n  [preadditive C] [preadditive D] (F : C ⥤ D) : Prop :=\n(map_zero' : Π {X Y : C}, F.map (0 : X ⟶ Y) = 0 . obviously)\n(map_add' : Π {X Y : C} {f g : X ⟶ Y}, F.map (f + g) = F.map f + F.map g . obviously)\n\nsection preadditive\n\nnamespace functor\n\nsection\nvariables {C D : Type*} [category C] [category D] [preadditive C]\n  [preadditive D] (F : C ⥤ D) [functor.additive F]\n\n@[simp]\nlemma map_zero {X Y : C} : F.map (0 : X ⟶ Y) = 0 :=\nfunctor.additive.map_zero'\n\n@[simp]\n\n\ninstance : additive (𝟭 C) :=\n{}\n\ninstance {E : Type*} [category E] [preadditive E] (G : D ⥤ E) [functor.additive G] :\n  additive (F ⋙ G) :=\n{}\n\n/-- `F.map_add_hom` is an additive homomorphism whose underlying function is `F.map`. -/\n@[simps]\ndef map_add_hom {X Y : C} : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y) :=\n{ to_fun := λ f, F.map f,\n  map_zero' := F.map_zero,\n  map_add' := λ _ _, F.map_add }\n\nlemma coe_map_add_hom {X Y : C} : ⇑(F.map_add_hom : (X ⟶ Y) →+ _) = @map C _ D _ F X Y := rfl\n\n@[simp]\nlemma map_neg {X Y : C} {f : X ⟶ Y} : F.map (-f) = - F.map f :=\nF.map_add_hom.map_neg _\n\n@[simp]\nlemma map_sub {X Y : C} {f g : X ⟶ Y} : F.map (f - g) = F.map f - F.map g :=\nF.map_add_hom.map_sub _ _\n\nopen_locale big_operators\n\n@[simp]\nlemma map_sum {X Y : C} {α : Type*} (f : α → (X ⟶ Y)) (s : finset α) :\n  F.map (∑ a in s, f a) = ∑ a in s, F.map (f a) :=\n(F.map_add_hom : (X ⟶ Y) →+ _).map_sum f s\n\nend\n\nsection induced_category\nvariables {C : Type*} {D : Type*} [category D] [preadditive D] (F : C → D)\n\ninstance induced_functor_additive : functor.additive (induced_functor F) := {}\n\nend induced_category\n\nsection\n-- To talk about preservation of biproducts we need to specify universes explicitly.\n\nnoncomputable theory\nuniverses v u₁ u₂\n\nvariables {C : Type u₁} {D : Type u₂} [category.{v} C] [category.{v} D]\n  [preadditive C] [preadditive D] (F : C ⥤ D) [functor.additive F]\n\nopen category_theory.limits\n\n/--\nAn additive functor between preadditive categories creates finite biproducts.\n-/\ninstance map_has_biproduct {J : Type v} [fintype J] [decidable_eq J] (f : J → C) [has_biproduct f] :\n  has_biproduct (λ j, F.obj (f j)) :=\nhas_biproduct_of_total\n{ X := F.obj (⨁ f),\n  π := λ j, F.map (biproduct.π f j),\n  ι := λ j, F.map (biproduct.ι f j),\n  ι_π := λ j j', by { simp only [←F.map_comp], split_ifs, { subst h, simp, }, { simp [h], }, }, }\n(by simp_rw [←F.map_comp, ←F.map_sum, biproduct.total, functor.map_id])\n\n/--\nAn additive functor between preadditive categories preserves finite biproducts.\n-/\n-- This essentially repeats the work of the previous instance,\n-- but gives good definitional reduction to `biproduct.lift` and `biproduct.desc`.\n@[simps]\ndef map_biproduct {J : Type v} [fintype J] [decidable_eq J] (f : J → C) [has_biproduct f] :\n  F.obj (⨁ f) ≅ ⨁ (λ j, F.obj (f j)) :=\n{ hom := biproduct.lift (λ j, F.map (biproduct.π f j)),\n  inv := biproduct.desc (λ j, F.map (biproduct.ι f j)),\n  hom_inv_id' :=\n  by simp only [biproduct.lift_desc, ←F.map_comp, ←F.map_sum, biproduct.total, F.map_id],\n  inv_hom_id' :=\n  begin\n    ext j j',\n    simp only [category.comp_id,  category.assoc, biproduct.lift_π, biproduct.ι_desc_assoc,\n      ←F.map_comp, biproduct.ι_π, F.map_dite, dif_ctx_congr, eq_to_hom_map, F.map_zero],\n  end }\n\nend\n\nend functor\n\nnamespace equivalence\n\nvariables {C D : Type*} [category C] [category D] [preadditive C] [preadditive D]\n\ninstance inverse_additive (e : C ≌ D) [e.functor.additive] : e.inverse.additive :=\n{ map_zero' := λ X Y, by { apply e.functor.map_injective, simp, },\n  map_add' := λ X Y f g, by { apply e.functor.map_injective, simp, }, }\n\nend equivalence\n\nend preadditive\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/preadditive/additive_functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.48383755173009263}}
{"text": "import GMLInit.Meta.Stable\nimport GMLInit.Meta.Decidable\n\nnamespace Relation\n\nsection Reflexive\n\nclass Reflexive {α} (r : α → α → Prop) : Prop where\n  protected refl (x) : r x x\n\nprotected abbrev Reflexive.rfl {α} {r : α → α → Prop} [Reflexive r] {x : α} := Reflexive.refl (r:=r) x\n\ntheorem Reflexive.of_eq {α} (r : α → α → Prop) [Reflexive r] : {x y : α} → x = y → r x y\n| _, _, rfl => Reflexive.rfl\n\ninstance (α) [Setoid α] : Reflexive (α:=α) (.≈.) := ⟨Setoid.refl⟩\ninstance (α) [Setoid α] : Reflexive (α:=α) Setoid.r := ⟨Setoid.refl⟩\ninstance (α) : Reflexive (α:=α) (.≅.) := ⟨HEq.refl⟩\ninstance (α) : Reflexive (α:=α) (.=.) := ⟨Eq.refl⟩\ninstance : Reflexive (.→.) := ⟨@id⟩\ninstance : Reflexive (.↔.) := ⟨Iff.refl⟩\n\ninstance {α} (r : α → α → Prop) [Reflexive r] : Reflexive (TC r) where\n  refl x := TC.base _ _ (Reflexive.refl x)\n\nend Reflexive\n\nsection Irreflexive\n\nabbrev Irreflexive {α} (r : α → α → Prop) : Prop := Reflexive (¬ r . .)\n\nprotected abbrev Irreflexive.irrefl {α} {r : α → α → Prop} [Irreflexive r] (x : α) := Reflexive.refl (r:=(¬ r . .)) x\n\nprotected abbrev Irreflexive.irrfl {α} {r : α → α → Prop} [Irreflexive r] {x : α} := Irreflexive.irrefl (r:=r) x\n\ntheorem Irreflexive.ne_of {α} {r : α → α → Prop} [Irreflexive r] : {x y : α} → r x y → x ≠ y\n| _, _, h, rfl => Irreflexive.irrfl h\n\ninstance (α) : Irreflexive (α:=α) (.≠.) := ⟨λ x h => h (Eq.refl x)⟩\n\nend Irreflexive\n\nsection Symmetric\n\nclass HSymmetric (r : α → β → Prop) (s : β → α → Prop) : Prop where\n  protected symm {x y} : r x y → s y x\n\nclass Symmetric (r : α → α → Prop) : Prop where\n  protected symm {x y} : r y x → r x y\n\n@[default_instance]\ninstance {α} (r : α → α → Prop) [Symmetric r] : HSymmetric r r := ⟨Symmetric.symm⟩\n\nabbrev Asymmetric (r : α → α → Prop) := HSymmetric r (¬ r . .)\n\nprotected def Asymmetric.asymm {α} {r : α → α → Prop} [Asymmetric r] {x y : α} : r x y → ¬ r y x := HSymmetric.symm (r:=r) (s:=(¬ r . .))\n\ninstance (α) : Symmetric (α:=α) (.=.) := ⟨Eq.symm⟩\ninstance (α) : Symmetric (α:=α) (.≠.) := ⟨Ne.symm⟩\ninstance (α) [Setoid α] : Symmetric (α:=α) (.≈.) := ⟨Setoid.symm⟩\ninstance (α) [Setoid α] : Symmetric (α:=α) Setoid.r := ⟨Setoid.symm⟩\ninstance (α β) : HSymmetric (α:=α) (β:=β) (.≅.) (.≅.) := ⟨HEq.symm⟩\ninstance (α) [LE α] : HSymmetric (α:=α) (.≤.) (.≥.) := ⟨id⟩\ninstance (α) [LE α] : HSymmetric (α:=α) (.≥.) (.≤.) := ⟨id⟩\ninstance (α) [LT α] : HSymmetric (α:=α) (.<.) (.>.) := ⟨id⟩\ninstance (α) [LT α] : HSymmetric (α:=α) (.>.) (.<.) := ⟨id⟩\ninstance : Symmetric (.↔.) := ⟨Iff.symm⟩\n\ninstance {α} (r : α → α → Prop) [Symmetric r] : Symmetric (TC r) where\n  symm := by\n    intros x y hxy\n    induction hxy with\n    | base x y h =>\n      apply TC.base\n      exact Symmetric.symm h\n    | trans x y z _ _ hyx hzy =>\n      apply TC.trans\n      exact hzy\n      exact hyx\n\nend Symmetric\n\nsection Antisymmetric\n\nclass HAntisymmetric {α} (r : α → α → Prop) (s : outParam (α → α → Prop)) : Prop where\n  protected antisymm {x y} : r x y → r y x → s x y\n\nclass Antisymmetric {α} (r : α → α → Prop) : Prop where\n  protected antisymm {x y} : r x y → r y x → x = y\n\n@[default_instance]\ninstance {α} (r : α → α → Prop) [Antisymmetric r] : HAntisymmetric r Eq where\n  antisymm := Antisymmetric.antisymm\n\ninstance : HAntisymmetric (.→.) (.↔.) := ⟨Iff.intro⟩\n\nabbrev WeaklyConnex {α} (r : α → α → Prop) := Antisymmetric (λ x y => ¬ r y x)\n\nabbrev WeaklyConnex.connex {α} {r : α → α → Prop} [WeaklyConnex r] {x y} : ¬ r y x → ¬ r x y → x = y :=\n  Antisymmetric.antisymm (r := λ x y => ¬ r y x)\n\nend Antisymmetric\n\nsection Transitive\n\nclass HTransitive {α β γ} (r : α → β → Prop) (s : β → γ → Prop) (t : outParam (α → γ → Prop)) : Prop where\n  protected trans {x y z} : (left : r x y) → (right : s y z) → t x z\n\ninstance {α β γ} (r : α → β → Prop) (s : β → γ → Prop) (t : α → γ → Prop) [HTransitive r s t] : Trans r s t where\n  trans := HTransitive.trans\n\nclass Transitive {α} (r : α → α → Prop) : Prop where\n  protected trans {x y z} : (left : r x y) → (right : r y z) → r x z\n\n@[default_instance]\ninstance {α} (r : α → α → Prop) [Transitive r] : HTransitive r r r := ⟨Transitive.trans⟩\n\ninstance (α) : Transitive (α:=α) (.=.) := ⟨Eq.trans⟩\ninstance (α β γ) : HTransitive (α:=α) (β:=β) (γ:=γ) (.≅.) (.≅.) (.≅.) := ⟨HEq.trans⟩\ninstance {α β} (r : α → β → Prop) : HTransitive (.=.) r r := ⟨λ he hr => he ▸ hr⟩\ninstance {α β} (r : α → β → Prop) : HTransitive r (.=.) r := ⟨λ hr he => he ▸ hr⟩\ninstance (α) [Setoid α] : Transitive (α:=α) (.≈.) := ⟨Setoid.trans⟩\ninstance (α) [Setoid α] : Transitive (α:=α) Setoid.r := ⟨Setoid.trans⟩\ninstance : Transitive (.→.) := ⟨λ h₁ h₂ h => h₂ (h₁ h)⟩\ninstance : Transitive (.↔.) := ⟨Iff.trans⟩\ninstance {α} (r : α → α → Prop) : Transitive (TC r) := ⟨TC.trans _ _ _⟩\n\ninstance {α} (r : α → α → Prop) [Irreflexive r] [Transitive r] : Asymmetric r := ⟨fun hxy hyx => Irreflexive.irrfl (Transitive.trans hxy hyx)⟩\n\nend Transitive\n\nsection Euclidean\n\nclass HEuclidean {α β γ} (r : α → β → Prop) (s : α → γ → Prop) (t : outParam (β → γ → Prop)) : Prop where\n  protected eucl {x y z} : (left : r x y) → (right : s x z) → t y z\n\nclass Euclidean {α} (r : α → α → Prop) : Prop where\n  protected eucl {x y z} : (left : r x y) → (right : r x z) → r y z\n\n@[default_instance]\ninstance {α} (r : α → α → Prop) [Euclidean r] : HEuclidean r r r := ⟨Euclidean.eucl⟩\n\ninstance [Reflexive r] [Euclidean r] : Symmetric r where\n  symm hxy := Euclidean.eucl hxy (Reflexive.refl _)\n\ninstance [Symmetric r] [Transitive r] : Euclidean r where\n  eucl hxy hxz := Transitive.trans (Symmetric.symm hxy) hxz\n\ndef Euclidean.toSymmetric {α} (r : α → α → Prop) [Reflexive r] [Euclidean r] : Symmetric r where\n  symm hxy := Euclidean.eucl hxy Reflexive.rfl\n\ndef Euclidean.toTransitive {α} (r : α → α → Prop) [Symmetric r] [Euclidean r] : Transitive r where\n  trans hxy hyz := Euclidean.eucl (Symmetric.symm hxy) hyz\n\nend Euclidean\n\nsection Total\n\nclass HTotal {α β} (r : α → β → Prop) (s : β → α → Prop) : Prop where\n  protected total (x y) : (r x y) ∨ (s y x)\n\nclass Total {α} (r : α → α → Prop) : Prop where\n  protected total (x y) : (r x y) ∨ (r y x)\n\n@[default_instance]\ninstance {α} (r : α → α → Prop) [Total r] : HTotal r r := ⟨Total.total⟩\n\nend Total\n\nsection Comparison\n\nclass HComparison {α} (r : α → α → Prop) (s : α → α → Prop) : Prop where\n  protected compare {x y} : s x y → (z : α) → r x z ∨ r z y\n\nclass Comparison {α} (r : α → α → Prop) : Prop where\n  protected compare {x y} : r x y → (z : α) → r x z ∨ r z y\n\n@[default_instance]\ninstance {α} (r : α → α → Prop) [Comparison r] : HComparison r r := ⟨Comparison.compare⟩\n\ndef Transitive.toComparison {α} (r : α → α → Prop) [ComplementedRel r] [Transitive r] : Comparison (λ x y => ¬ r y x) where\n  compare := by\n    intro x y nxy z\n    by_cases r z x using Complemented with\n    | .isFalse nxz =>\n      left\n      exact nxz\n    | .isTrue hxz =>\n      right\n      intro hzy\n      apply nxy\n      exact Transitive.trans hzy hxz\n\ninstance Comparison.toTransitive {α} (r : α → α → Prop) [Comparison r] : Transitive (λ x y => ¬ r y x) where\n  trans := by\n    intros x y z nxy nyz hxz\n    cases Comparison.compare hxz y with\n    | inl hyz => exact nyz hyz\n    | inr hxy => exact nxy hxy\n\nend Comparison\n\nsection Connex\n\nclass HConnex {α} (r : α → α → Prop) (s : α → α → Prop) : Prop where\n  protected connex {x y} : s x y → r x y ∨ r y x\n\nclass Connex {α} (r : α → α → Prop) : Prop where\n  protected connex {x y} : x ≠ y → r x y ∨ r y x\n\n@[default_instance]\ninstance {α} (r : α → α → Prop) [Connex r] : HConnex r (.≠.) := ⟨Connex.connex⟩\n\ndef Connex.toAntisymmetric {α} (r : α → α → Prop) [StableEq α] [Connex r] : Antisymmetric (λ x y => ¬ r y x) where\n  antisymm := by\n    intro x y nxy nyx\n    by_contradiction\n    | assuming hne =>\n      cases Connex.connex (r:=r) hne with\n      | inl hyx => exact nyx hyx\n      | inr hxy => exact nxy hxy\n\ndef Antisymmetric.toConnex {α} (r : α → α → Prop) [WeaklyComplementedRel r] [Antisymmetric r] : Connex fun x y => ¬ r y x where\n  connex := by\n    intro x y hne\n    rw [←And.deMorgan]\n    intro ⟨hyx, hxy⟩\n    absurd hne\n    exact Antisymmetric.antisymm hxy hyx\n\ndef Connex.toComparison {α} (r : α → α → Prop) [ComplementedEq α] [Connex r] [Transitive r] : Comparison r where\n  compare := by\n    intro x y hxy z\n    by_cases x = z using Complemented with\n    | .isTrue rfl => right; exact hxy\n    | .isFalse hne =>\n      match Connex.connex (r:=r) hne with\n      | .inl hxz => left; exact hxz\n      | .inr hzx => right; exact Transitive.trans hzx hxy\n\nend Connex\n\nend Relation\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Logic/Relation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568417, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.483837545307651}}
{"text": "-- From @joehendrix\n-- The imul doesn't type check as Lean won't try to coerce from a reg (bv 64) to a expr (bv ?u)\n\n\ninductive MCType\n| bv : Nat → MCType\n\nopen MCType\n\ninductive Reg : MCType → Type\n| rax (n : Nat) : Reg (bv n)\n\ninductive Expr : MCType → Type\n| r : ∀{tp:MCType}, Reg tp → Expr tp\n| sextC {s:Nat} (x : Expr (bv s)) (t:Nat) : Expr (bv t)\n\ninstance reg_is_expr {tp:MCType} : Coe (Reg tp) (Expr tp) := ⟨Expr.r⟩\n\ndef bvmul {w:Nat} (x y : Expr (bv w)) : Expr (bv w) := x\n\n/-\nRemark: Joe's original example used the following definition.\n```\ndef sext {s:Nat} (x : Expr (bv s)) (t:Nat) : Expr (bv t) := Expr.sextC x t\n```\nThis definition is bad because the parameter `s` is unconstrained.\nType class resolution gets stuck at\n```\nCoeT (Reg (bv 64)) (Reg.rax 64) (Expr (bv ?m_1))\n```\nIt would have to set `?m_1 := 64` which is not allowed since TC should\nnot change external TC metavariables.\nI fixed the problem by changing the definition. Now,\ntype inference will enforce that `?m_1` must be 64, and TC will be able\nto synthesize the instance.\n-/\ndef sext {s:Nat} (x : Expr (bv s)) (n:Nat) : Expr (bv (s+n)) := Expr.sextC x (s+n)\n\nopen MCType\n\nvariable {u:Nat} (e : Expr (bv 64))\n#check (bvmul (sext (Reg.rax 64) 64) (sext e 64) : Expr (bv 128))\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/coeIssue1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.48383753986370986}}
{"text": "/-\nCopyright (c) 2020 Thomas Browning and Patrick Lutz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Thomas Browning and Patrick Lutz\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.field_theory.normal\nimport Mathlib.field_theory.primitive_element\nimport Mathlib.field_theory.fixed\nimport Mathlib.ring_theory.power_basis\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Galois Extensions\n\nIn this file we define Galois extensions as extensions which are both separable and normal.\n\n## Main definitions\n\n- `is_galois F E` where `E` is an extension of `F`\n- `fixed_field H` where `H : subgroup (E ≃ₐ[F] E)`\n- `fixing_subgroup K` where `K : intermediate_field F E`\n- `galois_correspondence` where `E/F` is finite dimensional and Galois\n\n## Main results\n\n- `fixing_subgroup_of_fixed_field` : If `E/F` is finite dimensional (but not necessarily Galois)\n  then `fixing_subgroup (fixed_field H) = H`\n- `fixed_field_of_fixing_subgroup`: If `E/F` is finite dimensional and Galois\n  then `fixed_field (fixing_subgroup K) = K`\nTogether, these two result prove the Galois correspondence\n\n- `is_galois.tfae` : Equivalent characterizations of a Galois extension of finite degree\n-/\n\n/-- A field extension E/F is galois if it is both separable and normal -/\ndef is_galois (F : Type u_1) [field F] (E : Type u_2) [field E] [algebra F E] :=\n  is_separable F E ∧ normal F E\n\nnamespace is_galois\n\n\nprotected instance self (F : Type u_1) [field F] : is_galois F F :=\n  { left := Mathlib.is_separable_self F, right := Mathlib.normal_self F }\n\nprotected instance to_is_separable (F : Type u_1) [field F] (E : Type u_2) [field E] [algebra F E]\n    [h : is_galois F E] : is_separable F E :=\n  and.left h\n\nprotected instance to_normal (F : Type u_1) [field F] (E : Type u_2) [field E] [algebra F E]\n    [h : is_galois F E] : normal F E :=\n  and.right h\n\ntheorem integral (F : Type u_1) [field F] {E : Type u_2} [field E] [algebra F E] [is_galois F E]\n    (x : E) : is_integral F x :=\n  normal.is_integral F x\n\ntheorem separable (F : Type u_1) [field F] {E : Type u_2} [field E] [algebra F E]\n    [h : is_galois F E] (x : E) : polynomial.separable (minpoly F x) :=\n  and.right (and.left h x)\n\n-- TODO(Commelin, Browning): rename this to `splits`\n\ntheorem normal (F : Type u_1) [field F] {E : Type u_2} [field E] [algebra F E] [is_galois F E]\n    (x : E) : polynomial.splits (algebra_map F E) (minpoly F x) :=\n  normal.splits F x\n\nprotected instance of_fixed_field (E : Type u_2) [field E] (G : Type u_1) [group G] [fintype G]\n    [mul_semiring_action G E] : is_galois (↥(mul_action.fixed_points G E)) E :=\n  { left := fixed_points.separable G E, right := fixed_points.normal G E }\n\ntheorem intermediate_field.adjoin_simple.card_aut_eq_findim (F : Type u_1) [field F] (E : Type u_2)\n    [field E] [algebra F E] [finite_dimensional F E] {α : E} (hα : is_integral F α)\n    (h_sep : polynomial.separable (minpoly F α))\n    (h_splits :\n      polynomial.splits\n        (algebra_map F ↥(intermediate_field.adjoin F (intermediate_field.insert.insert ∅ α)))\n        (minpoly F α)) :\n    fintype.card\n          (alg_equiv F ↥(intermediate_field.adjoin F (intermediate_field.insert.insert ∅ α))\n            ↥(intermediate_field.adjoin F (intermediate_field.insert.insert ∅ α))) =\n        finite_dimensional.findim F\n          ↥(intermediate_field.adjoin F (intermediate_field.insert.insert ∅ α)) :=\n  sorry\n\ntheorem card_aut_eq_findim (F : Type u_1) [field F] (E : Type u_2) [field E] [algebra F E]\n    [finite_dimensional F E] [h : is_galois F E] :\n    fintype.card (alg_equiv F E E) = finite_dimensional.findim F E :=\n  sorry\n\nend is_galois\n\n\ntheorem is_galois.tower_top_of_is_galois (F : Type u_1) (K : Type u_2) (E : Type u_3) [field F]\n    [field K] [field E] [algebra F K] [algebra F E] [algebra K E] [is_scalar_tower F K E]\n    [is_galois F E] : is_galois K E :=\n  { left := is_separable_tower_top_of_is_separable F K E,\n    right := normal.tower_top_of_normal F K E }\n\nprotected instance is_galois.tower_top_intermediate_field {F : Type u_1} {E : Type u_3} [field F]\n    [field E] [algebra F E] (K : intermediate_field F E) [h : is_galois F E] : is_galois (↥K) E :=\n  is_galois.tower_top_of_is_galois F (↥K) E\n\ntheorem is_galois_iff_is_galois_bot {F : Type u_1} {E : Type u_3} [field F] [field E]\n    [algebra F E] : is_galois (↥⊥) E ↔ is_galois F E :=\n  { mp := fun (h : is_galois (↥⊥) E) => is_galois.tower_top_of_is_galois (↥⊥) F E,\n    mpr := fun (h : is_galois F E) => is_galois.tower_top_intermediate_field ⊥ }\n\ntheorem is_galois.of_alg_equiv {F : Type u_1} {E : Type u_3} [field F] [field E] {E' : Type u_4}\n    [field E'] [algebra F E'] [algebra F E] [h : is_galois F E] (f : alg_equiv F E E') :\n    is_galois F E' :=\n  { left := is_separable.of_alg_hom F E ↑(alg_equiv.symm f), right := normal.of_alg_equiv f }\n\ntheorem alg_equiv.transfer_galois {F : Type u_1} {E : Type u_3} [field F] [field E] {E' : Type u_4}\n    [field E'] [algebra F E'] [algebra F E] (f : alg_equiv F E E') :\n    is_galois F E ↔ is_galois F E' :=\n  { mp := fun (h : is_galois F E) => is_galois.of_alg_equiv f,\n    mpr := fun (h : is_galois F E') => is_galois.of_alg_equiv (alg_equiv.symm f) }\n\ntheorem is_galois_iff_is_galois_top {F : Type u_1} {E : Type u_3} [field F] [field E]\n    [algebra F E] : is_galois F ↥⊤ ↔ is_galois F E :=\n  alg_equiv.transfer_galois intermediate_field.top_equiv\n\nprotected instance is_galois_bot {F : Type u_1} {E : Type u_3} [field F] [field E] [algebra F E] :\n    is_galois F ↥⊥ :=\n  iff.mpr (alg_equiv.transfer_galois intermediate_field.bot_equiv) (is_galois.self F)\n\nnamespace intermediate_field\n\n\nprotected instance subgroup_action {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (H : subgroup (alg_equiv F E E)) : faithful_mul_semiring_action (↥H) E :=\n  faithful_mul_semiring_action.mk sorry\n\n/-- The intermediate_field fixed by a subgroup -/\ndef fixed_field {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (H : subgroup (alg_equiv F E E)) : intermediate_field F E :=\n  mk (mul_action.fixed_points (↥H) E) sorry sorry sorry sorry sorry sorry sorry\n\ntheorem findim_fixed_field_eq_card {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (H : subgroup (alg_equiv F E E)) [finite_dimensional F E] :\n    finite_dimensional.findim (↥(fixed_field H)) E = fintype.card ↥H :=\n  fixed_points.findim_eq_card (↥H) E\n\n/-- The subgroup fixing an intermediate_field -/\ndef fixing_subgroup {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (K : intermediate_field F E) : subgroup (alg_equiv F E E) :=\n  subgroup.mk (fun (ϕ : alg_equiv F E E) => ∀ (x : ↥K), coe_fn ϕ ↑x = ↑x) sorry sorry sorry\n\ntheorem le_iff_le {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (H : subgroup (alg_equiv F E E)) (K : intermediate_field F E) :\n    K ≤ fixed_field H ↔ H ≤ fixing_subgroup K :=\n  sorry\n\n/-- The fixing_subgroup of `K : intermediate_field F E` is isomorphic to `E ≃ₐ[K] E` -/\ndef fixing_subgroup_equiv {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (K : intermediate_field F E) : ↥(fixing_subgroup K) ≃* alg_equiv (↥K) E E :=\n  mul_equiv.mk\n    (fun (ϕ : ↥(fixing_subgroup K)) =>\n      alg_equiv.of_bijective (alg_hom.mk ⇑ϕ sorry sorry sorry sorry sorry) sorry)\n    (fun (ϕ : alg_equiv (↥K) E E) =>\n      { val := alg_equiv.of_bijective (alg_hom.mk ⇑ϕ sorry sorry sorry sorry sorry) sorry,\n        property := sorry })\n    sorry sorry sorry\n\ntheorem fixing_subgroup_fixed_field {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (H : subgroup (alg_equiv F E E)) [finite_dimensional F E] :\n    fixing_subgroup (fixed_field H) = H :=\n  sorry\n\nprotected instance fixed_field.algebra {F : Type u_1} [field F] {E : Type u_2} [field E]\n    [algebra F E] (K : intermediate_field F E) : algebra ↥K ↥(fixed_field (fixing_subgroup K)) :=\n  algebra.mk\n    (ring_hom.mk (fun (x : ↥K) => { val := ↑x, property := sorry }) sorry sorry sorry sorry) sorry\n    sorry\n\nprotected instance fixed_field.is_scalar_tower {F : Type u_1} [field F] {E : Type u_2} [field E]\n    [algebra F E] (K : intermediate_field F E) :\n    is_scalar_tower (↥K) (↥(fixed_field (fixing_subgroup K))) E :=\n  is_scalar_tower.mk\n    fun (_x : ↥K) (_x_1 : ↥(fixed_field (fixing_subgroup K))) (_x_2 : E) =>\n      mul_assoc (↑_x) (↑_x_1) _x_2\n\nend intermediate_field\n\n\nnamespace is_galois\n\n\ntheorem fixed_field_fixing_subgroup {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    (K : intermediate_field F E) [finite_dimensional F E] [h : is_galois F E] :\n    intermediate_field.fixed_field (intermediate_field.fixing_subgroup K) = K :=\n  sorry\n\ntheorem card_fixing_subgroup_eq_findim {F : Type u_1} [field F] {E : Type u_2} [field E]\n    [algebra F E] (K : intermediate_field F E) [finite_dimensional F E] [is_galois F E] :\n    fintype.card ↥(intermediate_field.fixing_subgroup K) = finite_dimensional.findim (↥K) E :=\n  sorry\n\n/-- The Galois correspondence from intermediate fields to subgroups -/\ndef intermediate_field_equiv_subgroup {F : Type u_1} [field F] {E : Type u_2} [field E]\n    [algebra F E] [finite_dimensional F E] [is_galois F E] :\n    intermediate_field F E ≃o order_dual (subgroup (alg_equiv F E E)) :=\n  rel_iso.mk\n    (equiv.mk intermediate_field.fixing_subgroup intermediate_field.fixed_field sorry sorry) sorry\n\n/-- The Galois correspondence as a galois_insertion -/\ndef galois_insertion_intermediate_field_subgroup {F : Type u_1} [field F] {E : Type u_2} [field E]\n    [algebra F E] [finite_dimensional F E] :\n    galois_insertion (⇑order_dual.to_dual ∘ intermediate_field.fixing_subgroup)\n        (intermediate_field.fixed_field ∘ ⇑order_dual.to_dual) :=\n  galois_insertion.mk\n    (fun (K : intermediate_field F E)\n      (_x :\n      function.comp intermediate_field.fixed_field (⇑order_dual.to_dual)\n          (function.comp (⇑order_dual.to_dual) intermediate_field.fixing_subgroup K) ≤\n        K) =>\n      intermediate_field.fixing_subgroup K)\n    sorry sorry sorry\n\n/-- The Galois correspondence as a galois_coinsertion -/\ndef galois_coinsertion_intermediate_field_subgroup {F : Type u_1} [field F] {E : Type u_2} [field E]\n    [algebra F E] [finite_dimensional F E] [is_galois F E] :\n    galois_coinsertion (⇑order_dual.to_dual ∘ intermediate_field.fixing_subgroup)\n        (intermediate_field.fixed_field ∘ ⇑order_dual.to_dual) :=\n  galois_coinsertion.mk\n    (fun (H : order_dual (subgroup (alg_equiv F E E)))\n      (_x :\n      H ≤\n        function.comp (⇑order_dual.to_dual) intermediate_field.fixing_subgroup\n          (function.comp intermediate_field.fixed_field (⇑order_dual.to_dual) H)) =>\n      intermediate_field.fixed_field H)\n    sorry sorry sorry\n\nend is_galois\n\n\nnamespace is_galois\n\n\ntheorem is_separable_splitting_field (F : Type u_1) [field F] (E : Type u_2) [field E] [algebra F E]\n    [finite_dimensional F E] [h : is_galois F E] :\n    ∃ (p : polynomial F), polynomial.separable p ∧ polynomial.is_splitting_field F E p :=\n  sorry\n\ntheorem of_fixed_field_eq_bot (F : Type u_1) [field F] (E : Type u_2) [field E] [algebra F E]\n    [finite_dimensional F E] (h : intermediate_field.fixed_field ⊤ = ⊥) : is_galois F E :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_galois F E)) (Eq.symm (propext is_galois_iff_is_galois_bot))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (is_galois (↥⊥) E)) (Eq.symm h)))\n      (is_galois.of_fixed_field E ↥⊤))\n\ntheorem of_card_aut_eq_findim (F : Type u_1) [field F] (E : Type u_2) [field E] [algebra F E]\n    [finite_dimensional F E] (h : fintype.card (alg_equiv F E E) = finite_dimensional.findim F E) :\n    is_galois F E :=\n  sorry\n\ntheorem of_separable_splitting_field_aux {F : Type u_1} [field F] {E : Type u_2} [field E]\n    [algebra F E] {p : polynomial F} [hFE : finite_dimensional F E]\n    [sp : polynomial.is_splitting_field F E p] (hp : polynomial.separable p)\n    (K : intermediate_field F E) {x : E}\n    (hx : x ∈ polynomial.roots (polynomial.map (algebra_map F E) p)) :\n    fintype.card\n          (alg_hom F (↥↑(intermediate_field.adjoin (↥K) (intermediate_field.insert.insert ∅ x)))\n            E) =\n        fintype.card (alg_hom F (↥K) E) *\n          finite_dimensional.findim ↥K\n            ↥(intermediate_field.adjoin (↥K) (intermediate_field.insert.insert ∅ x)) :=\n  sorry\n\ntheorem of_separable_splitting_field {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    {p : polynomial F} [sp : polynomial.is_splitting_field F E p] (hp : polynomial.separable p) :\n    is_galois F E :=\n  sorry\n\n/--Equivalent characterizations of a Galois extension of finite degree-/\ntheorem tfae {F : Type u_1} [field F] {E : Type u_2} [field E] [algebra F E]\n    [finite_dimensional F E] :\n    tfae\n        [is_galois F E, intermediate_field.fixed_field ⊤ = ⊥,\n          fintype.card (alg_equiv F E E) = finite_dimensional.findim F E,\n          ∃ (p : polynomial F), polynomial.separable p ∧ polynomial.is_splitting_field F E p] :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/field_theory/galois_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.4837329376524105}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Mario Carneiro\n-/\nimport control.traversable.equiv\nimport data.vector.basic\n\nuniverses u v w\n\nnamespace d_array\nvariables {n : ℕ} {α : fin n → Type u}\n\ninstance [∀ i, inhabited (α i)] : inhabited (d_array n α) :=\n⟨⟨λ _, default⟩⟩\n\nend d_array\n\nnamespace array\n\ninstance {n α} [inhabited α] : inhabited (array n α) :=\nd_array.inhabited\n\ntheorem to_list_of_heq {n₁ n₂ α} {a₁ : array n₁ α} {a₂ : array n₂ α}\n  (hn : n₁ = n₂) (ha : a₁ == a₂) : a₁.to_list = a₂.to_list :=\nby congr; assumption\n\n/- rev_list -/\n\nsection rev_list\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem rev_list_reverse_aux : ∀ i (h : i ≤ n) (t : list α),\n  (a.iterate_aux (λ _, (::)) i h []).reverse_core t = a.rev_iterate_aux (λ _, (::)) i h t\n| 0     h t := rfl\n| (i+1) h t := rev_list_reverse_aux i _ _\n\n@[simp] theorem rev_list_reverse : a.rev_list.reverse = a.to_list :=\nrev_list_reverse_aux _ _ _\n\n@[simp] theorem to_list_reverse : a.to_list.reverse = a.rev_list :=\nby rw [←rev_list_reverse, list.reverse_reverse]\n\nend rev_list\n\n/- mem -/\n\nsection mem\nvariables {n : ℕ} {α : Type u} {v : α} {a : array n α}\n\ntheorem mem.def : v ∈ a ↔ ∃ i, a.read i = v :=\niff.rfl\n\ntheorem mem_rev_list_aux : ∀ {i} (h : i ≤ n),\n  (∃ (j : fin n), (j : ℕ) < i ∧ read a j = v) ↔ v ∈ a.iterate_aux (λ _, (::)) i h []\n| 0     _ := ⟨λ ⟨i, n, _⟩, absurd n i.val.not_lt_zero, false.elim⟩\n| (i+1) h := let IH := mem_rev_list_aux (le_of_lt h) in\n  ⟨λ ⟨j, ji1, e⟩, or.elim (lt_or_eq_of_le $ nat.le_of_succ_le_succ ji1)\n    (λ ji, list.mem_cons_of_mem _ $ IH.1 ⟨j, ji, e⟩)\n    (λ je, by simp [d_array.iterate_aux]; apply or.inl; unfold read at e;\n          have H : j = ⟨i, h⟩ := fin.eq_of_veq je; rwa [←H, e]),\n  λ m, begin\n    simp [d_array.iterate_aux, list.mem] at m,\n    cases m with e m',\n    exact ⟨⟨i, h⟩, nat.lt_succ_self _, eq.symm e⟩,\n    exact let ⟨j, ji, e⟩ := IH.2 m' in\n    ⟨j, nat.le_succ_of_le ji, e⟩\n  end⟩\n\n@[simp] theorem mem_rev_list : v ∈ a.rev_list ↔ v ∈ a :=\niff.symm $ iff.trans\n  (exists_congr $ λ j, iff.symm $\n    show j.1 < n ∧ read a j = v ↔ read a j = v,\n    from and_iff_right j.2)\n  (mem_rev_list_aux _)\n\n@[simp] theorem mem_to_list : v ∈ a.to_list ↔ v ∈ a :=\nby rw ←rev_list_reverse; exact list.mem_reverse.trans mem_rev_list\n\nend mem\n\n/- foldr -/\n\nsection foldr\nvariables {n : ℕ} {α : Type u} {β : Type w} {b : β} {f : α → β → β} {a : array n α}\n\ntheorem rev_list_foldr_aux : ∀ {i} (h : i ≤ n),\n  (d_array.iterate_aux a (λ _, (::)) i h []).foldr f b = d_array.iterate_aux a (λ _, f) i h b\n| 0     h := rfl\n| (j+1) h := congr_arg (f (read a ⟨j, h⟩)) (rev_list_foldr_aux _)\n\ntheorem rev_list_foldr : a.rev_list.foldr f b = a.foldl b f :=\nrev_list_foldr_aux _\n\nend foldr\n\n/- foldl -/\n\nsection foldl\nvariables {n : ℕ} {α : Type u} {β : Type w} {b : β} {f : β → α → β} {a : array n α}\n\ntheorem to_list_foldl : a.to_list.foldl f b = a.foldl b (function.swap f) :=\nby rw [←rev_list_reverse, list.foldl_reverse, rev_list_foldr]\n\nend foldl\n\n/- length -/\n\nsection length\nvariables {n : ℕ} {α : Type u}\n\ntheorem rev_list_length_aux (a : array n α) (i h) :\n  (a.iterate_aux (λ _, (::)) i h []).length = i :=\nby induction i; simp [*, d_array.iterate_aux]\n\n@[simp] theorem rev_list_length (a : array n α) : a.rev_list.length = n :=\nrev_list_length_aux a _ _\n\n@[simp] theorem to_list_length (a : array n α) : a.to_list.length = n :=\nby rw[←rev_list_reverse, list.length_reverse, rev_list_length]\n\nend length\n\n/- nth -/\n\nsection nth\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem to_list_nth_le_aux (i : ℕ) (ih : i < n) : ∀ j {jh t h'},\n  (∀ k tl, j + k = i → list.nth_le t k tl = a.read ⟨i, ih⟩) →\n  (a.rev_iterate_aux (λ _, (::)) j jh t).nth_le i h' = a.read ⟨i, ih⟩\n| 0     _  _ _  al := al i _ $ zero_add _\n| (j+1) jh t h' al := to_list_nth_le_aux j $ λ k tl hjk,\n  show list.nth_le (a.read ⟨j, jh⟩ :: t) k tl = a.read ⟨i, ih⟩, from\n  match k, hjk, tl with\n  | 0,    e, tl := match i, e, ih with ._, rfl, _ := rfl end\n  | k'+1, _, tl := by simp[list.nth_le]; exact al _ _ (by simp [add_comm, add_assoc, *]; cc)\n  end\n\ntheorem to_list_nth_le (i : ℕ) (h h') : list.nth_le a.to_list i h' = a.read ⟨i, h⟩ :=\nto_list_nth_le_aux _ _ _ (λ k tl, absurd tl k.not_lt_zero)\n\n@[simp] theorem to_list_nth_le' (a : array n α) (i : fin n) (h') :\n  list.nth_le a.to_list i h' = a.read i :=\nby cases i; apply to_list_nth_le\n\ntheorem to_list_nth {i v} : list.nth a.to_list i = some v ↔ ∃ h, a.read ⟨i, h⟩ = v :=\nbegin\n  rw list.nth_eq_some,\n  have ll := to_list_length a,\n  split; intro h; cases h with h e; subst v,\n  { exact ⟨ll ▸ h, (to_list_nth_le _ _ _).symm⟩ },\n  { exact ⟨ll.symm ▸ h, to_list_nth_le _ _ _⟩ }\nend\n\ntheorem write_to_list {i v} : (a.write i v).to_list = a.to_list.update_nth i v :=\nlist.ext_le (by simp) $ λ j h₁ h₂, begin\n  have h₃ : j < n, {simpa using h₁},\n  rw [to_list_nth_le _ h₃],\n  refine let ⟨_, e⟩ := list.nth_eq_some.1 _ in e.symm,\n  by_cases ij : (i : ℕ) = j,\n  { subst j, rw [show (⟨(i : ℕ), h₃⟩ : fin _) = i, from fin.eq_of_veq rfl,\n      array.read_write, list.nth_update_nth_of_lt],\n    simp [h₃] },\n  { rw [list.nth_update_nth_ne _ _ ij, a.read_write_of_ne,\n        to_list_nth.2 ⟨h₃, rfl⟩],\n    exact fin.ne_of_vne ij }\nend\n\nend nth\n\n/- enum -/\n\nsection enum\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem mem_to_list_enum {i v} : (i, v) ∈ a.to_list.enum ↔ ∃ h, a.read ⟨i, h⟩ = v :=\nby simp [list.mem_iff_nth, to_list_nth, and.comm, and.assoc, and.left_comm]\n\nend enum\n\n/- to_array -/\n\nsection to_array\nvariables {n : ℕ} {α : Type u}\n\n@[simp] theorem to_list_to_array (a : array n α) : a.to_list.to_array == a :=\nheq_of_heq_of_eq\n  (@@eq.drec_on (λ m (e : a.to_list.length = m), (d_array.mk (λ v, a.to_list.nth_le v.1 v.2)) ==\n    (@d_array.mk m (λ _, α) $ λ v, a.to_list.nth_le v.1 $ e.symm ▸ v.2)) a.to_list_length heq.rfl) $\n  d_array.ext $ λ ⟨i, h⟩, to_list_nth_le i h _\n\n@[simp] theorem to_array_to_list (l : list α) : l.to_array.to_list = l :=\nlist.ext_le (to_list_length _) $ λ n h1 h2, to_list_nth_le _ h2 _\n\nend to_array\n\n/- push_back -/\n\nsection push_back\nvariables {n : ℕ} {α : Type u} {v : α} {a : array n α}\n\nlemma push_back_rev_list_aux : ∀ i h h',\n  d_array.iterate_aux (a.push_back v) (λ _, (::)) i h [] = d_array.iterate_aux a (λ _, (::)) i h' []\n| 0 h h' := rfl\n| (i+1) h h' := begin\n  simp [d_array.iterate_aux],\n  refine ⟨_, push_back_rev_list_aux _ _ _⟩,\n  dsimp [read, d_array.read, push_back],\n  rw [dif_neg], refl,\n  exact ne_of_lt h',\nend\n\n@[simp] theorem push_back_rev_list : (a.push_back v).rev_list = v :: a.rev_list :=\nbegin\n  unfold push_back rev_list foldl iterate d_array.iterate,\n  dsimp [d_array.iterate_aux, read, d_array.read, push_back],\n  rw [dif_pos (eq.refl n)],\n  apply congr_arg,\n  apply push_back_rev_list_aux\nend\n\n@[simp] theorem push_back_to_list : (a.push_back v).to_list = a.to_list ++ [v] :=\nby rw [←rev_list_reverse, ←rev_list_reverse, push_back_rev_list, list.reverse_cons]\n\n@[simp] lemma read_push_back_left (i : fin n) : (a.push_back v).read i.cast_succ = a.read i :=\nbegin\n  cases i with i hi,\n  have : ¬ i = n := ne_of_lt hi,\n  simp [push_back, this, fin.cast_succ, fin.cast_add, fin.cast_le, fin.cast_lt, read, d_array.read]\nend\n\n@[simp] lemma read_push_back_right : (a.push_back v).read (fin.last _) = v :=\nbegin\n  cases hn : fin.last n with k hk,\n  have : k = n := by simpa [fin.eq_iff_veq ] using hn.symm,\n  simp [push_back, this, fin.cast_succ, fin.cast_add, fin.cast_le, fin.cast_lt, read, d_array.read]\nend\n\nend push_back\n\n/- foreach -/\n\nsection foreach\nvariables {n : ℕ} {α : Type u} {β : Type v} {i : fin n} {f : fin n → α → β} {a : array n α}\n\n@[simp] theorem read_foreach : (foreach a f).read i = f i (a.read i) :=\nrfl\n\nend foreach\n\n/- map -/\n\nsection map\nvariables {n : ℕ} {α : Type u} {β : Type v} {i : fin n} {f : α → β} {a : array n α}\n\ntheorem read_map : (a.map f).read i = f (a.read i) :=\nread_foreach\n\nend map\n\n/- map₂ -/\n\nsection map₂\nvariables {n : ℕ} {α : Type u} {i : fin n} {f : α → α → α} {a₁ a₂ : array n α}\n\n@[simp] theorem read_map₂ : (map₂ f a₁ a₂).read i = f (a₁.read i) (a₂.read i) :=\nread_foreach\n\nend map₂\n\nend array\n\nnamespace equiv\n\n/-- The natural equivalence between length-`n` heterogeneous arrays\nand dependent functions from `fin n`. -/\ndef d_array_equiv_fin {n : ℕ} (α : fin n → Type*) : d_array n α ≃ (Π i, α i) :=\n⟨d_array.read, d_array.mk, λ ⟨f⟩, rfl, λ f, rfl⟩\n\n/-- The natural equivalence between length-`n` arrays and functions from `fin n`. -/\ndef array_equiv_fin (n : ℕ) (α : Type*) : array n α ≃ (fin n → α) :=\nd_array_equiv_fin _\n\n/-- The natural equivalence between length-`n` vectors and length-`n` arrays. -/\ndef vector_equiv_array (α : Type*) (n : ℕ) : vector α n ≃ array n α :=\n(vector_equiv_fin _ _).trans (array_equiv_fin _ _).symm\n\nend equiv\n\nnamespace array\nopen function\nvariable {n : ℕ}\n\ninstance : traversable (array n) :=\n@equiv.traversable (flip vector n) _ (λ α, equiv.vector_equiv_array α n) _\n\ninstance : is_lawful_traversable (array n) :=\n@equiv.is_lawful_traversable (flip vector n) _ (λ α, equiv.vector_equiv_array α n) _ _\n\nend array\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/data/array/lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.48373293350384455}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module order.category.BddDistLat\n! leanprover-community/mathlib commit e8ac6315bcfcbaf2d19a046719c3b553206dac75\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Category.BddLat\nimport Mathbin.Order.Category.DistLat\n\n/-!\n# The category of bounded distributive lattices\n\nThis defines `BddDistLat`, the category of bounded distributive lattices.\n\nNote that this category is sometimes called [`DistLat`](https://ncatlab.org/nlab/show/DistLat) when\nbeing a lattice is understood to entail having a bottom and a top element.\n-/\n\n\nuniverse u\n\nopen CategoryTheory\n\n/-- The category of bounded distributive lattices with bounded lattice morphisms. -/\nstructure BddDistLat where\n  toDistLat : DistLat\n  [isBoundedOrder : BoundedOrder to_DistLat]\n#align BddDistLat BddDistLat\n\nnamespace BddDistLat\n\ninstance : CoeSort BddDistLat (Type _) :=\n  ⟨fun X => X.toDistLat⟩\n\ninstance (X : BddDistLat) : DistribLattice X :=\n  X.toDistLat.str\n\nattribute [instance] BddDistLat.isBoundedOrder\n\n/-- Construct a bundled `BddDistLat` from a `bounded_order` `distrib_lattice`. -/\ndef of (α : Type _) [DistribLattice α] [BoundedOrder α] : BddDistLat :=\n  ⟨⟨α⟩⟩\n#align BddDistLat.of BddDistLat.of\n\n@[simp]\ntheorem coe_of (α : Type _) [DistribLattice α] [BoundedOrder α] : ↥(of α) = α :=\n  rfl\n#align BddDistLat.coe_of BddDistLat.coe_of\n\ninstance : Inhabited BddDistLat :=\n  ⟨of PUnit⟩\n\n/-- Turn a `BddDistLat` into a `BddLat` by forgetting it is distributive. -/\ndef toBddLat (X : BddDistLat) : BddLat :=\n  BddLat.of X\n#align BddDistLat.to_BddLat BddDistLat.toBddLat\n\n@[simp]\ntheorem coe_toBddLat (X : BddDistLat) : ↥X.toBddLat = ↥X :=\n  rfl\n#align BddDistLat.coe_to_BddLat BddDistLat.coe_toBddLat\n\ninstance : LargeCategory.{u} BddDistLat :=\n  InducedCategory.category toBddLat\n\ninstance : ConcreteCategory BddDistLat :=\n  InducedCategory.concreteCategory toBddLat\n\ninstance hasForgetToDistLat : HasForget₂ BddDistLat DistLat\n    where forget₂ :=\n    { obj := fun X => ⟨X⟩\n      map := fun X Y => BoundedLatticeHom.toLatticeHom }\n#align BddDistLat.has_forget_to_DistLat BddDistLat.hasForgetToDistLat\n\ninstance hasForgetToBddLat : HasForget₂ BddDistLat BddLat :=\n  InducedCategory.hasForget₂ toBddLat\n#align BddDistLat.has_forget_to_BddLat BddDistLat.hasForgetToBddLat\n\ntheorem forget_bddLat_lat_eq_forget_distLat_lat :\n    forget₂ BddDistLat BddLat ⋙ forget₂ BddLat Lat =\n      forget₂ BddDistLat DistLat ⋙ forget₂ DistLat Lat :=\n  rfl\n#align BddDistLat.forget_BddLat_Lat_eq_forget_DistLat_Lat BddDistLat.forget_bddLat_lat_eq_forget_distLat_lat\n\n/-- Constructs an equivalence between bounded distributive lattices from an order isomorphism\nbetween them. -/\n@[simps]\ndef Iso.mk {α β : BddDistLat.{u}} (e : α ≃o β) : α ≅ β\n    where\n  Hom := (e : BoundedLatticeHom α β)\n  inv := (e.symm : BoundedLatticeHom β α)\n  hom_inv_id' := by\n    ext\n    exact e.symm_apply_apply _\n  inv_hom_id' := by\n    ext\n    exact e.apply_symm_apply _\n#align BddDistLat.iso.mk BddDistLat.Iso.mk\n\n/-- `order_dual` as a functor. -/\n@[simps]\ndef dual : BddDistLat ⥤ BddDistLat where\n  obj X := of Xᵒᵈ\n  map X Y := BoundedLatticeHom.dual\n#align BddDistLat.dual BddDistLat.dual\n\n/-- The equivalence between `BddDistLat` and itself induced by `order_dual` both ways. -/\n@[simps Functor inverse]\ndef dualEquiv : BddDistLat ≌ BddDistLat :=\n  Equivalence.mk dual dual\n    (NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun X Y f => rfl)\n    (NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun X Y f => rfl)\n#align BddDistLat.dual_equiv BddDistLat.dualEquiv\n\nend BddDistLat\n\ntheorem bddDistLat_dual_comp_forget_to_distLat :\n    BddDistLat.dual ⋙ forget₂ BddDistLat DistLat = forget₂ BddDistLat DistLat ⋙ DistLat.dual :=\n  rfl\n#align BddDistLat_dual_comp_forget_to_DistLat bddDistLat_dual_comp_forget_to_distLat\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Category/BddDistLat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225279, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.48373292473020196}}
{"text": "/-\nCopyright (c) 2019 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport tactic.noncomm_ring\nimport data.equiv.module\nimport data.bracket\nimport linear_algebra.basic\n\n/-!\n# Lie algebras\n\nThis file defines Lie rings and Lie algebras over a commutative ring together with their\nmodules, morphisms and equivalences, as well as various lemmas to make these definitions usable.\n\n## Main definitions\n\n  * `lie_ring`\n  * `lie_algebra`\n  * `lie_ring_module`\n  * `lie_module`\n  * `lie_hom`\n  * `lie_equiv`\n  * `lie_module_hom`\n  * `lie_module_equiv`\n\n## Notation\n\nWorking over a fixed commutative ring `R`, we introduce the notations:\n * `L →ₗ⁅R⁆ L'` for a morphism of Lie algebras,\n * `L ≃ₗ⁅R⁆ L'` for an equivalence of Lie algebras,\n * `M →ₗ⁅R,L⁆ N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,\n * `M ≃ₗ⁅R,L⁆ N` for an equivalence of Lie algebra modules `M`, `N` over a Lie algebra `L`.\n\n## Implementation notes\n\nLie algebras are defined as modules with a compatible Lie ring structure and thus, like modules,\nare partially unbundled.\n\n## References\n* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975)\n\n## Tags\n\nlie bracket, jacobi identity, lie ring, lie algebra, lie module\n-/\n\nuniverses u v w w₁ w₂\nopen function\n\n/-- A Lie ring is an additive group with compatible product, known as the bracket, satisfying the\nJacobi identity. -/\n@[protect_proj] class lie_ring (L : Type v) extends add_comm_group L, has_bracket L L :=\n(add_lie  : ∀ (x y z : L), ⁅x + y, z⁆ = ⁅x, z⁆ + ⁅y, z⁆)\n(lie_add  : ∀ (x y z : L), ⁅x, y + z⁆ = ⁅x, y⁆ + ⁅x, z⁆)\n(lie_self : ∀ (x : L), ⁅x, x⁆ = 0)\n(leibniz_lie : ∀ (x y z : L), ⁅x, ⁅y, z⁆⁆ = ⁅⁅x, y⁆, z⁆ + ⁅y, ⁅x, z⁆⁆)\n\n/-- A Lie algebra is a module with compatible product, known as the bracket, satisfying the Jacobi\nidentity. Forgetting the scalar multiplication, every Lie algebra is a Lie ring. -/\n@[protect_proj] class lie_algebra (R : Type u) (L : Type v) [comm_ring R] [lie_ring L]\n  extends module R L :=\n(lie_smul : ∀ (t : R) (x y : L), ⁅x, t • y⁆ = t • ⁅x, y⁆)\n\n/-- A Lie ring module is an additive group, together with an additive action of a\nLie ring on this group, such that the Lie bracket acts as the commutator of endomorphisms.\n(For representations of Lie *algebras* see `lie_module`.) -/\n@[protect_proj] class lie_ring_module (L : Type v) (M : Type w)\n  [lie_ring L] [add_comm_group M] extends has_bracket L M :=\n(add_lie     : ∀ (x y : L) (m : M), ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆)\n(lie_add     : ∀ (x : L) (m n : M), ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆)\n(leibniz_lie : ∀ (x y : L) (m : M), ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆)\n\n/-- A Lie module is a module over a commutative ring, together with a linear action of a Lie\nalgebra on this module, such that the Lie bracket acts as the commutator of endomorphisms. -/\n@[protect_proj] class lie_module (R : Type u) (L : Type v) (M : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [add_comm_group M] [module R M]\n  [lie_ring_module L M] :=\n(smul_lie : ∀ (t : R) (x : L) (m : M), ⁅t • x, m⁆ = t • ⁅x, m⁆)\n(lie_smul : ∀ (t : R) (x : L) (m : M), ⁅x, t • m⁆ = t • ⁅x, m⁆)\n\nsection basic_properties\n\nvariables {R : Type u} {L : Type v} {M : Type w} {N : Type w₁}\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables [add_comm_group M] [module R M] [lie_ring_module L M] [lie_module R L M]\nvariables [add_comm_group N] [module R N] [lie_ring_module L N] [lie_module R L N]\nvariables (t : R) (x y z : L) (m n : M)\n\n@[simp] lemma add_lie : ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆ := lie_ring_module.add_lie x y m\n\n@[simp] lemma lie_add : ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆ := lie_ring_module.lie_add x m n\n\n@[simp] lemma smul_lie : ⁅t • x, m⁆ = t • ⁅x, m⁆ := lie_module.smul_lie t x m\n\n@[simp] lemma lie_smul : ⁅x, t • m⁆ = t • ⁅x, m⁆ := lie_module.lie_smul t x m\n\nlemma leibniz_lie : ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆ := lie_ring_module.leibniz_lie x y m\n\n@[simp] lemma lie_zero : ⁅x, 0⁆ = (0 : M) := (add_monoid_hom.mk' _ (lie_add x)).map_zero\n\n@[simp] lemma zero_lie : ⁅(0 : L), m⁆ = 0 :=\n(add_monoid_hom.mk' (λ (x : L), ⁅x, m⁆) (λ x y, add_lie x y m)).map_zero\n\n@[simp] lemma lie_self : ⁅x, x⁆ = 0 := lie_ring.lie_self x\n\ninstance lie_ring_self_module : lie_ring_module L L := { ..(infer_instance : lie_ring L) }\n\n@[simp] lemma lie_skew : -⁅y, x⁆ = ⁅x, y⁆ :=\nhave h : ⁅x + y, x⁆ + ⁅x + y, y⁆ = 0, { rw ← lie_add, apply lie_self, },\nby simpa [neg_eq_iff_add_eq_zero] using h\n\n/-- Every Lie algebra is a module over itself. -/\ninstance lie_algebra_self_module : lie_module R L L :=\n{ smul_lie := λ t x m, by rw [←lie_skew, ←lie_skew x m, lie_algebra.lie_smul, smul_neg],\n  lie_smul := by apply lie_algebra.lie_smul, }\n\n@[simp] lemma neg_lie : ⁅-x, m⁆ = -⁅x, m⁆ :=\nby { rw [←sub_eq_zero, sub_neg_eq_add, ←add_lie], simp, }\n\n@[simp] lemma lie_neg : ⁅x, -m⁆ = -⁅x, m⁆ :=\nby { rw [←sub_eq_zero, sub_neg_eq_add, ←lie_add], simp, }\n\n@[simp] lemma sub_lie : ⁅x - y, m⁆ = ⁅x, m⁆ - ⁅y, m⁆ :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma lie_sub : ⁅x, m - n⁆ = ⁅x, m⁆ - ⁅x, n⁆ :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma nsmul_lie (n : ℕ) : ⁅n • x, m⁆ = n • ⁅x, m⁆ :=\nadd_monoid_hom.map_nsmul ⟨λ (x : L), ⁅x, m⁆, zero_lie m, λ _ _, add_lie _ _ _⟩ _ _\n\n@[simp] lemma lie_nsmul (n : ℕ) : ⁅x, n • m⁆ = n • ⁅x, m⁆ :=\nadd_monoid_hom.map_nsmul ⟨λ (m : M), ⁅x, m⁆, lie_zero x, λ _ _, lie_add _ _ _⟩ _ _\n\n@[simp] lemma zsmul_lie (a : ℤ) : ⁅a • x, m⁆ = a • ⁅x, m⁆ :=\nadd_monoid_hom.map_zsmul ⟨λ (x : L), ⁅x, m⁆, zero_lie m, λ _ _, add_lie _ _ _⟩ _ _\n\n@[simp] lemma lie_zsmul (a : ℤ) : ⁅x, a • m⁆ = a • ⁅x, m⁆ :=\nadd_monoid_hom.map_zsmul ⟨λ (m : M), ⁅x, m⁆, lie_zero x, λ _ _, lie_add _ _ _⟩ _ _\n\n@[simp] lemma lie_lie : ⁅⁅x, y⁆, m⁆ = ⁅x, ⁅y, m⁆⁆ - ⁅y, ⁅x, m⁆⁆ :=\nby rw [leibniz_lie, add_sub_cancel]\n\nlemma lie_jacobi : ⁅x, ⁅y, z⁆⁆ + ⁅y, ⁅z, x⁆⁆ + ⁅z, ⁅x, y⁆⁆ = 0 :=\nby { rw [← neg_neg ⁅x, y⁆, lie_neg z, lie_skew y x, ← lie_skew, lie_lie], abel, }\n\ninstance lie_ring.int_lie_algebra : lie_algebra ℤ L :=\n{ lie_smul := λ n x y, lie_zsmul x y n, }\n\ninstance : lie_ring_module L (M →ₗ[R] N) :=\n{ bracket     := λ x f,\n  { to_fun    := λ m, ⁅x, f m⁆ - f ⁅x, m⁆,\n    map_add'  := λ m n, by { simp only [lie_add, linear_map.map_add], abel, },\n    map_smul' := λ t m, by simp only [smul_sub, linear_map.map_smul, lie_smul, ring_hom.id_apply] },\n  add_lie     := λ x y f, by\n    { ext n, simp only [add_lie, linear_map.coe_mk, linear_map.add_apply, linear_map.map_add],\n      abel, },\n  lie_add     := λ x f g, by\n    { ext n, simp only [linear_map.coe_mk, lie_add, linear_map.add_apply], abel, },\n  leibniz_lie := λ x y f, by\n    { ext n,\n      simp only [lie_lie, linear_map.coe_mk, linear_map.map_sub, linear_map.add_apply, lie_sub],\n      abel, }, }\n\n@[simp] lemma lie_hom.lie_apply (f : M →ₗ[R] N) (x : L) (m : M) :\n  ⁅x, f⁆ m = ⁅x, f m⁆ - f ⁅x, m⁆ :=\nrfl\n\ninstance : lie_module R L (M →ₗ[R] N) :=\n{ smul_lie := λ t x f, by\n    { ext n,\n      simp only [smul_sub, smul_lie, linear_map.smul_apply, lie_hom.lie_apply,\n        linear_map.map_smul], },\n  lie_smul := λ t x f, by\n    { ext n, simp only [smul_sub, linear_map.smul_apply, lie_hom.lie_apply, lie_smul], }, }\n\nend basic_properties\n\n/-- A morphism of Lie algebras is a linear map respecting the bracket operations. -/\nstructure lie_hom (R : Type u) (L : Type v) (L' : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [lie_ring L'] [lie_algebra R L']\n  extends L →ₗ[R] L' :=\n(map_lie' : ∀ {x y : L}, to_fun ⁅x, y⁆ = ⁅to_fun x, to_fun y⁆)\n\nattribute [nolint doc_blame] lie_hom.to_linear_map\n\nnotation L ` →ₗ⁅`:25 R:25 `⁆ `:0 L':0 := lie_hom R L L'\n\nnamespace lie_hom\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁}\nvariables [comm_ring R]\nvariables [lie_ring L₁] [lie_algebra R L₁]\nvariables [lie_ring L₂] [lie_algebra R L₂]\nvariables [lie_ring L₃] [lie_algebra R L₃]\n\ninstance : has_coe (L₁ →ₗ⁅R⁆ L₂) (L₁ →ₗ[R] L₂) := ⟨lie_hom.to_linear_map⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L₁ →ₗ⁅R⁆ L₂) (λ _, L₁ → L₂) := ⟨λ f, f.to_linear_map.to_fun⟩\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂ := h\n\ninitialize_simps_projections lie_hom (to_linear_map_to_fun → apply)\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : L₁ →ₗ⁅R⁆ L₂) : ((f : L₁ →ₗ[R] L₂) : L₁ → L₂) = f :=\nrfl\n\n@[simp] lemma to_fun_eq_coe (f : L₁ →ₗ⁅R⁆ L₂) : f.to_fun = ⇑f := rfl\n\n@[simp] lemma map_smul (f : L₁ →ₗ⁅R⁆ L₂) (c : R) (x : L₁) : f (c • x) = c • f x :=\nlinear_map.map_smul (f : L₁ →ₗ[R] L₂) c x\n\n@[simp] lemma map_add (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : L₁ →ₗ[R] L₂) x y\n\n@[simp] lemma map_sub (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : L₁ →ₗ[R] L₂) x y\n\n@[simp] lemma map_neg (f : L₁ →ₗ⁅R⁆ L₂) (x : L₁) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : L₁ →ₗ[R] L₂) x\n\n@[simp] lemma map_lie (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f ⁅x, y⁆ = ⁅f x, f y⁆ := lie_hom.map_lie' f\n\n@[simp] lemma map_zero (f : L₁ →ₗ⁅R⁆ L₂) : f 0 = 0 := (f : L₁ →ₗ[R] L₂).map_zero\n\n/-- The identity map is a morphism of Lie algebras. -/\ndef id : L₁ →ₗ⁅R⁆ L₁ :=\n{ map_lie' := λ x y, rfl,\n  .. (linear_map.id : L₁ →ₗ[R] L₁) }\n\n@[simp] lemma coe_id : ((id : L₁ →ₗ⁅R⁆ L₁) : L₁ → L₁) = _root_.id := rfl\n\nlemma id_apply (x : L₁) : (id : L₁ →ₗ⁅R⁆ L₁) x = x := rfl\n\n/-- The constant 0 map is a Lie algebra morphism. -/\ninstance : has_zero (L₁ →ₗ⁅R⁆ L₂) := ⟨{ map_lie' := by simp, ..(0 : L₁ →ₗ[R] L₂)}⟩\n\n@[norm_cast, simp] lemma coe_zero : ((0 : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = 0 := rfl\n\nlemma zero_apply (x : L₁) : (0 : L₁ →ₗ⁅R⁆ L₂) x = 0 := rfl\n\n/-- The identity map is a Lie algebra morphism. -/\ninstance : has_one (L₁ →ₗ⁅R⁆ L₁) := ⟨id⟩\n\n@[simp] lemma coe_one : ((1 : (L₁ →ₗ⁅R⁆ L₁)) : L₁ → L₁) = _root_.id := rfl\n\nlemma one_apply (x : L₁) : (1 : (L₁ →ₗ⁅R⁆ L₁)) x = x := rfl\n\ninstance : inhabited (L₁ →ₗ⁅R⁆ L₂) := ⟨0⟩\n\nlemma coe_injective : @function.injective (L₁ →ₗ⁅R⁆ L₂) (L₁ → L₂) coe_fn :=\nby rintro ⟨⟨f, _⟩⟩ ⟨⟨g, _⟩⟩ ⟨h⟩; congr\n\n@[ext] lemma ext {f g : L₁ →ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : L₁ →ₗ⁅R⁆ L₂} : f = g ↔ ∀ x, f x = g x :=\n⟨by { rintro rfl x, refl }, ext⟩\n\nlemma congr_fun {f g : L₁ →ₗ⁅R⁆ L₂} (h : f = g) (x : L₁) : f x = g x := h ▸ rfl\n\n@[simp] lemma mk_coe (f : L₁ →ₗ⁅R⁆ L₂) (h₁ h₂ h₃) :\n  (⟨⟨f, h₁, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : L₁ → L₂) (h₁ h₂ h₃) :\n  ((⟨⟨f, h₁, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = f := rfl\n\n/-- The composition of morphisms is a morphism. -/\ndef comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) : L₁ →ₗ⁅R⁆ L₃ :=\n{ map_lie' := λ x y, by { change f (g ⁅x, y⁆) = ⁅f (g x), f (g y)⁆, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) (x : L₁) :\n  f.comp g x = f (g x) := rfl\n\n@[norm_cast, simp]\nlemma coe_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) :\n  (f.comp g : L₁ → L₃) = f ∘ g :=\nrfl\n\n@[norm_cast, simp]\nlemma coe_linear_map_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) :\n  (f.comp g : L₁ →ₗ[R] L₃) = (f : L₂ →ₗ[R] L₃).comp (g : L₁ →ₗ[R] L₂) :=\nrfl\n\n@[simp] lemma comp_id (f : L₁ →ₗ⁅R⁆ L₂) : f.comp (id : L₁ →ₗ⁅R⁆ L₁) = f :=\nby { ext, refl, }\n\n@[simp] lemma id_comp (f : L₁ →ₗ⁅R⁆ L₂) : (id : L₂ →ₗ⁅R⁆ L₂).comp f = f :=\nby { ext, refl, }\n\n/-- The inverse of a bijective morphism is a morphism. -/\ndef inverse (f : L₁ →ₗ⁅R⁆ L₂) (g : L₂ → L₁)\n  (h₁ : function.left_inverse g f) (h₂ : function.right_inverse g f) : L₂ →ₗ⁅R⁆ L₁ :=\n{ map_lie' := λ x y,\n  calc g ⁅x, y⁆ = g ⁅f (g x), f (g y)⁆ : by { conv_lhs { rw [←h₂ x, ←h₂ y], }, }\n            ... = g (f ⁅g x, g y⁆) : by rw map_lie\n            ... = ⁅g x, g y⁆ : (h₁ _),\n  ..linear_map.inverse f.to_linear_map g h₁ h₂ }\n\nend lie_hom\n\nsection module_pull_back\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} (M : Type w₁)\nvariables [comm_ring R]  [lie_ring L₁] [lie_algebra R L₁] [lie_ring L₂] [lie_algebra R L₂]\nvariables [add_comm_group M] [lie_ring_module L₂ M]\nvariables (f : L₁ →ₗ⁅R⁆ L₂)\ninclude f\n\n/-- A Lie ring module may be pulled back along a morphism of Lie algebras.\n\nSee note [reducible non-instances]. -/\n@[reducible]\ndef lie_ring_module.comp_lie_hom : lie_ring_module L₁ M :=\n{ bracket     := λ x m, ⁅f x, m⁆,\n  lie_add     := λ x, lie_add (f x),\n  add_lie     := λ x y m, by simp only [lie_hom.map_add, add_lie],\n  leibniz_lie := λ x y m, by simp only [lie_lie, sub_add_cancel, lie_hom.map_lie], }\n\nlemma lie_ring_module.comp_lie_hom_apply (x : L₁) (m : M) :\n  by haveI := lie_ring_module.comp_lie_hom M f; exact\n  ⁅x, m⁆ = ⁅f x, m⁆ :=\nrfl\n\n/-- A Lie module may be pulled back along a morphism of Lie algebras.\n\nSee note [reducible non-instances]. -/\n@[reducible]\ndef lie_module.comp_lie_hom [module R M] [lie_module R L₂ M] :\n  @lie_module R L₁ M _ _ _ _ _ (lie_ring_module.comp_lie_hom M f) :=\n{ smul_lie := λ t x m, by simp only [smul_lie, lie_hom.map_smul],\n  lie_smul := λ t x m, by simp only [lie_smul], }\n\nend module_pull_back\n\n/-- An equivalence of Lie algebras is a morphism which is also a linear equivalence. We could\ninstead define an equivalence to be a morphism which is also a (plain) equivalence. However it is\nmore convenient to define via linear equivalence to get `.to_linear_equiv` for free. -/\nstructure lie_equiv (R : Type u) (L : Type v) (L' : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [lie_ring L'] [lie_algebra R L']\n  extends L →ₗ⁅R⁆ L' :=\n(inv_fun   : L' → L)\n(left_inv  : function.left_inverse inv_fun to_lie_hom.to_fun)\n(right_inv : function.right_inverse inv_fun to_lie_hom.to_fun)\n\nattribute [nolint doc_blame] lie_equiv.to_lie_hom\n\nnotation L ` ≃ₗ⁅`:50 R `⁆ ` L' := lie_equiv R L L'\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁}\nvariables [comm_ring R] [lie_ring L₁] [lie_ring L₂] [lie_ring L₃]\nvariables [lie_algebra R L₁] [lie_algebra R L₂] [lie_algebra R L₃]\n\n/-- Consider an equivalence of Lie algebras as a linear equivalence. -/\ndef to_linear_equiv (f : L₁ ≃ₗ⁅R⁆ L₂) : L₁ ≃ₗ[R] L₂ := { ..f.to_lie_hom, ..f }\n\ninstance has_coe_to_lie_hom : has_coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ →ₗ⁅R⁆ L₂) := ⟨to_lie_hom⟩\ninstance has_coe_to_linear_equiv : has_coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ ≃ₗ[R] L₂) := ⟨to_linear_equiv⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L₁ ≃ₗ⁅R⁆ L₂) (λ _, L₁ → L₂) := ⟨λ e, e.to_lie_hom.to_fun⟩\n\n@[simp, norm_cast] lemma coe_to_lie_hom (e : L₁ ≃ₗ⁅R⁆ L₂) : ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = e :=\nrfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : L₁ ≃ₗ⁅R⁆ L₂) :\n  ((e : L₁ ≃ₗ[R] L₂) : L₁ → L₂) = e := rfl\n\n@[simp] lemma to_linear_equiv_mk (f : L₁ →ₗ⁅R⁆ L₂) (g h₁ h₂) :\n  (mk f g h₁ h₂ : L₁ ≃ₗ[R] L₂) = { inv_fun := g, left_inv := h₁, right_inv := h₂, .. f } := rfl\n\nlemma coe_linear_equiv_injective : injective (coe : (L₁ ≃ₗ⁅R⁆ L₂) → (L₁ ≃ₗ[R] L₂)) :=\nbegin\n  intros f₁ f₂ h, cases f₁, cases f₂, dsimp at h, simp only at h,\n  congr, exacts [lie_hom.coe_injective h.1, h.2]\nend\n\nlemma coe_injective : @injective (L₁ ≃ₗ⁅R⁆ L₂) (L₁ → L₂) coe_fn :=\nlinear_equiv.coe_injective.comp coe_linear_equiv_injective\n\n@[ext] lemma ext {f g : L₁ ≃ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g := coe_injective $ funext h\n\ninstance : has_one (L₁ ≃ₗ⁅R⁆ L₁) :=\n⟨{ map_lie' := λ x y, rfl,\n  ..(1 : L₁ ≃ₗ[R] L₁)}⟩\n\n@[simp] lemma one_apply (x : L₁) : (1 : (L₁ ≃ₗ⁅R⁆ L₁)) x = x := rfl\n\ninstance : inhabited (L₁ ≃ₗ⁅R⁆ L₁) := ⟨1⟩\n\n/-- Lie algebra equivalences are reflexive. -/\n@[refl]\ndef refl : L₁ ≃ₗ⁅R⁆ L₁ := 1\n\n@[simp] lemma refl_apply (x : L₁) : (refl : L₁ ≃ₗ⁅R⁆ L₁) x = x := rfl\n\n/-- Lie algebra equivalences are symmetric. -/\n@[symm]\ndef symm (e : L₁ ≃ₗ⁅R⁆ L₂) : L₂ ≃ₗ⁅R⁆ L₁ :=\n{ ..lie_hom.inverse e.to_lie_hom e.inv_fun e.left_inv e.right_inv,\n  ..e.to_linear_equiv.symm }\n\n@[simp] lemma symm_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.symm = e :=\nby { ext, refl }\n\n@[simp] lemma apply_symm_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n/-- Lie algebra equivalences are transitive. -/\n@[trans]\ndef trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) : L₁ ≃ₗ⁅R⁆ L₃ :=\n{ ..lie_hom.comp e₂.to_lie_hom e₁.to_lie_hom,\n  ..linear_equiv.trans e₁.to_linear_equiv e₂.to_linear_equiv }\n\n@[simp] lemma self_trans_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.trans e.symm = refl :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.trans e = refl :=\ne.symm.self_trans_symm\n\n@[simp] lemma trans_apply (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) (x : L₁) :\n  (e₁.trans e₂) x = e₂ (e₁ x) := rfl\n\n@[simp] lemma symm_trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) :\n  (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl\n\nprotected lemma bijective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.bijective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.bijective\n\nprotected lemma injective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.injective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.injective\n\nprotected lemma surjective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.surjective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.surjective\n\n/-- A bijective morphism of Lie algebras yields an equivalence of Lie algebras. -/\n@[simps] noncomputable def of_bijective (f : L₁ →ₗ⁅R⁆ L₂)\n  (h₁ : function.injective f) (h₂ : function.surjective f) : L₁ ≃ₗ⁅R⁆ L₂ :=\n{ to_fun   := f,\n  map_lie' := f.map_lie,\n  .. (linear_equiv.of_bijective (f : L₁ →ₗ[R] L₂) h₁ h₂), }\n\nend lie_equiv\n\nsection lie_module_morphisms\n\nvariables (R : Type u) (L : Type v) (M : Type w) (N : Type w₁) (P : Type w₂)\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables [add_comm_group M] [add_comm_group N] [add_comm_group P]\nvariables [module R M] [module R N] [module R P]\nvariables [lie_ring_module L M] [lie_ring_module L N] [lie_ring_module L P]\nvariables [lie_module R L M] [lie_module R L N] [lie_module R L P]\n\n/-- A morphism of Lie algebra modules is a linear map which commutes with the action of the Lie\nalgebra. -/\nstructure lie_module_hom extends M →ₗ[R] N :=\n(map_lie' : ∀ {x : L} {m : M}, to_fun ⁅x, m⁆ = ⁅x, to_fun m⁆)\n\nattribute [nolint doc_blame] lie_module_hom.to_linear_map\n\nnotation M ` →ₗ⁅`:25 R,L:25 `⁆ `:0 N:0 := lie_module_hom R L M N\n\nnamespace lie_module_hom\n\nvariables {R L M N P}\n\ninstance : has_coe (M →ₗ⁅R,L⁆ N) (M →ₗ[R] N) := ⟨lie_module_hom.to_linear_map⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M →ₗ⁅R,L⁆ N) (λ _, M → N) := ⟨λ f, f.to_linear_map.to_fun⟩\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : M →ₗ⁅R,L⁆ N) : ((f : M →ₗ[R] N) : M → N) = f :=\nrfl\n\n@[simp] lemma map_smul (f : M →ₗ⁅R,L⁆ N) (c : R) (x : M) : f (c • x) = c • f x :=\nlinear_map.map_smul (f : M →ₗ[R] N) c x\n\n@[simp] lemma map_add (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : M →ₗ[R] N) x y\n\n@[simp] lemma map_sub (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : M →ₗ[R] N) x y\n\n@[simp] lemma map_neg (f : M →ₗ⁅R,L⁆ N) (x : M) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : M →ₗ[R] N) x\n\n@[simp] lemma map_lie (f : M →ₗ⁅R,L⁆ N) (x : L) (m : M) : f ⁅x, m⁆ = ⁅x, f m⁆ :=\nlie_module_hom.map_lie' f\n\nlemma map_lie₂ (f : M →ₗ⁅R,L⁆ N →ₗ[R] P) (x : L) (m : M) (n : N) :\n  ⁅x, f m n⁆ = f ⁅x, m⁆ n + f m ⁅x, n⁆ :=\nby simp only [sub_add_cancel, map_lie, lie_hom.lie_apply]\n\n@[simp] lemma map_zero (f : M →ₗ⁅R,L⁆ N) : f 0 = 0 :=\nlinear_map.map_zero (f : M →ₗ[R] N)\n\n/-- The identity map is a morphism of Lie modules. -/\ndef id : M →ₗ⁅R,L⁆ M :=\n{ map_lie' := λ x m, rfl,\n  .. (linear_map.id : M →ₗ[R] M) }\n\n@[simp] lemma coe_id : ((id : M →ₗ⁅R,L⁆ M) : M → M) = _root_.id := rfl\n\nlemma id_apply (x : M) : (id : M →ₗ⁅R,L⁆ M) x = x := rfl\n\n/-- The constant 0 map is a Lie module morphism. -/\ninstance : has_zero (M →ₗ⁅R,L⁆ N) := ⟨{ map_lie' := by simp, ..(0 : M →ₗ[R] N) }⟩\n\n@[norm_cast, simp] lemma coe_zero : ((0 : M →ₗ⁅R,L⁆ N) : M → N) = 0 := rfl\n\nlemma zero_apply (m : M) : (0 : M →ₗ⁅R,L⁆ N) m = 0 := rfl\n\n/-- The identity map is a Lie module morphism. -/\ninstance : has_one (M →ₗ⁅R,L⁆ M) := ⟨id⟩\n\ninstance : inhabited (M →ₗ⁅R,L⁆ N) := ⟨0⟩\n\nlemma coe_injective : @function.injective (M →ₗ⁅R,L⁆ N) (M → N) coe_fn :=\nby { rintros ⟨⟨f, _⟩⟩ ⟨⟨g, _⟩⟩ ⟨h⟩, congr, }\n\n@[ext] lemma ext {f g : M →ₗ⁅R,L⁆ N} (h : ∀ m, f m = g m) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : M →ₗ⁅R,L⁆ N} : f = g ↔ ∀ m, f m = g m :=\n⟨by { rintro rfl m, refl, }, ext⟩\n\nlemma congr_fun {f g : M →ₗ⁅R,L⁆ N} (h : f = g) (x : M) : f x = g x := h ▸ rfl\n\n@[simp] lemma mk_coe (f : M →ₗ⁅R,L⁆ N) (h) :\n  (⟨f, h⟩ : M →ₗ⁅R,L⁆ N) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : M →ₗ[R] N) (h) :\n  ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M → N) = f :=\nby { ext, refl, }\n\n@[norm_cast, simp] lemma coe_linear_mk (f : M →ₗ[R] N) (h) :\n  ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M →ₗ[R] N) = f :=\nby { ext, refl, }\n\n/-- The composition of Lie module morphisms is a morphism. -/\ndef comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) : M →ₗ⁅R,L⁆ P :=\n{ map_lie' := λ x m, by { change f (g ⁅x, m⁆) = ⁅x, f (g m)⁆, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) (m : M) :\n  f.comp g m = f (g m) := rfl\n\n@[norm_cast, simp] lemma coe_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) :\n  (f.comp g : M → P) = f ∘ g :=\nrfl\n\n@[norm_cast, simp] lemma coe_linear_map_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) :\n  (f.comp g : M →ₗ[R] P) = (f : N →ₗ[R] P).comp (g : M →ₗ[R] N) :=\nrfl\n\n/-- The inverse of a bijective morphism of Lie modules is a morphism of Lie modules. -/\ndef inverse (f : M →ₗ⁅R,L⁆ N) (g : N → M)\n  (h₁ : function.left_inverse g f) (h₂ : function.right_inverse g f) : N →ₗ⁅R,L⁆ M :=\n{ map_lie' := λ x n,\n    calc g ⁅x, n⁆ = g ⁅x, f (g n)⁆ : by rw h₂\n              ... = g (f ⁅x, g n⁆) : by rw map_lie\n              ... = ⁅x, g n⁆ : (h₁ _),\n  ..linear_map.inverse f.to_linear_map g h₁ h₂ }\n\ninstance : has_add (M →ₗ⁅R,L⁆ N) :=\n{ add := λ f g, { map_lie' := by simp, ..((f : M →ₗ[R] N) + (g : M →ₗ[R] N)) }, }\n\ninstance : has_sub (M →ₗ⁅R,L⁆ N) :=\n{ sub := λ f g, { map_lie' := by simp, ..((f : M →ₗ[R] N) - (g : M →ₗ[R] N)) }, }\n\ninstance : has_neg (M →ₗ⁅R,L⁆ N) :=\n{ neg := λ f, { map_lie' := by simp, ..(-(f : (M →ₗ[R] N))) }, }\n\n@[norm_cast, simp] lemma coe_add (f g : M →ₗ⁅R,L⁆ N) : ⇑(f + g) = f + g := rfl\n\nlemma add_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f + g) m = f m + g m := rfl\n\n@[norm_cast, simp] lemma coe_sub (f g : M →ₗ⁅R,L⁆ N) : ⇑(f - g) = f - g := rfl\n\nlemma sub_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f - g) m = f m - g m := rfl\n\n@[norm_cast, simp] lemma coe_neg (f : M →ₗ⁅R,L⁆ N) : ⇑(-f) = -f := rfl\n\nlemma neg_apply (f : M →ₗ⁅R,L⁆ N) (m : M) : (-f) m = -(f m) := rfl\n\ninstance : add_comm_group (M →ₗ⁅R,L⁆ N) :=\n{ zero           := 0,\n  add            := (+),\n  neg            := has_neg.neg,\n  sub            := has_sub.sub,\n  nsmul          := λ n f, { map_lie' := λ x m, by simp, ..(n • (f : M →ₗ[R] N)) },\n  nsmul_zero'    := λ f, by { ext, simp, },\n  nsmul_succ'    := λ n f, by { ext, simp [nat.succ_eq_one_add, add_nsmul], },\n  ..(coe_injective.add_comm_group _ coe_zero coe_add coe_neg coe_sub :\n    add_comm_group (M →ₗ⁅R,L⁆ N)) }\n\ninstance : has_scalar R (M →ₗ⁅R,L⁆ N) :=\n{ smul := λ t f, { map_lie' := by simp, ..(t • (f : M →ₗ[R] N)) }, }\n\n@[norm_cast, simp] lemma coe_smul (t : R) (f : M →ₗ⁅R,L⁆ N) : ⇑(t • f) = t • f := rfl\n\nlemma smul_apply (t : R) (f : M →ₗ⁅R,L⁆ N) (m : M) : (t • f) m = t • (f m) := rfl\n\ninstance : module R (M →ₗ⁅R,L⁆ N) :=\nfunction.injective.module R ⟨λ f, f.to_linear_map.to_fun, rfl, coe_add⟩ coe_injective coe_smul\n\nend lie_module_hom\n\n/-- An equivalence of Lie algebra modules is a linear equivalence which is also a morphism of\nLie algebra modules. -/\nstructure lie_module_equiv extends M →ₗ⁅R,L⁆ N :=\n(inv_fun   : N → M)\n(left_inv  : function.left_inverse inv_fun to_fun)\n(right_inv : function.right_inverse inv_fun to_fun)\n\nattribute [nolint doc_blame] lie_module_equiv.to_lie_module_hom\n\nnotation M ` ≃ₗ⁅`:25 R,L:25 `⁆ `:0 N:0 := lie_module_equiv R L M N\n\nnamespace lie_module_equiv\n\nvariables {R L M N P}\n\n/-- View an equivalence of Lie modules as a linear equivalence. -/\n@[ancestor]\ndef to_linear_equiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ₗ[R] N := { ..e }\n\n/-- View an equivalence of Lie modules as a type level equivalence. -/\n@[ancestor]\ndef to_equiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ N := { ..e }\n\ninstance has_coe_to_equiv : has_coe (M ≃ₗ⁅R,L⁆ N) (M ≃ N) := ⟨to_equiv⟩\ninstance has_coe_to_lie_module_hom : has_coe (M ≃ₗ⁅R,L⁆ N) (M →ₗ⁅R,L⁆ N) := ⟨to_lie_module_hom⟩\ninstance has_coe_to_linear_equiv : has_coe (M ≃ₗ⁅R,L⁆ N) (M ≃ₗ[R] N) := ⟨to_linear_equiv⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M ≃ₗ⁅R,L⁆ N) (λ _, M → N) := ⟨λ e, e.to_lie_module_hom.to_fun⟩\n\nlemma injective (e : M ≃ₗ⁅R,L⁆ N) : function.injective e := e.to_equiv.injective\n\n@[simp] lemma coe_mk (f : M →ₗ⁅R,L⁆ N) (inv_fun h₁ h₂) :\n  ((⟨f, inv_fun, h₁, h₂⟩ : M ≃ₗ⁅R,L⁆ N) : M → N) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_lie_module_hom (e : M ≃ₗ⁅R,L⁆ N) :\n  ((e : M →ₗ⁅R,L⁆ N) : M → N) = e := rfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : M ≃ₗ⁅R,L⁆ N) : ((e : M ≃ₗ[R] N) : M → N) = e :=\nrfl\n\nlemma to_equiv_injective : function.injective (to_equiv : (M ≃ₗ⁅R,L⁆ N) → M ≃ N) :=\nλ e₁ e₂ h, begin\n  rcases e₁ with ⟨⟨⟩⟩, rcases e₂ with ⟨⟨⟩⟩,\n  have inj := equiv.mk.inj h,\n  dsimp at inj,\n  apply lie_module_equiv.mk.inj_eq.mpr,\n  split,\n  { congr,\n    ext,\n    rw inj.1 },\n  { exact inj.2 },\nend\n\n@[ext] lemma ext (e₁ e₂ : M ≃ₗ⁅R,L⁆ N) (h : ∀ m, e₁ m = e₂ m) : e₁ = e₂ :=\nto_equiv_injective (equiv.ext h)\n\ninstance : has_one (M ≃ₗ⁅R,L⁆ M) := ⟨{ map_lie' := λ x m, rfl, ..(1 : M ≃ₗ[R] M) }⟩\n\n@[simp] lemma one_apply (m : M) : (1 : (M ≃ₗ⁅R,L⁆ M)) m = m := rfl\n\ninstance : inhabited (M ≃ₗ⁅R,L⁆ M) := ⟨1⟩\n\n/-- Lie module equivalences are reflexive. -/\n@[refl] def refl : M ≃ₗ⁅R,L⁆ M := 1\n\n@[simp] lemma refl_apply (m : M) : (refl : M ≃ₗ⁅R,L⁆ M) m = m := rfl\n\n/-- Lie module equivalences are syemmtric. -/\n@[symm] def symm (e : M ≃ₗ⁅R,L⁆ N) : N ≃ₗ⁅R,L⁆ M :=\n{ ..lie_module_hom.inverse e.to_lie_module_hom e.inv_fun e.left_inv e.right_inv,\n  ..(e : M ≃ₗ[R] N).symm }\n\n@[simp] lemma apply_symm_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n@[simp] lemma symm_symm (e : M ≃ₗ⁅R,L⁆ N) : e.symm.symm = e :=\nby { ext, apply_fun e.symm using e.symm.injective, simp, }\n\n/-- Lie module equivalences are transitive. -/\n@[trans] def trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) : M ≃ₗ⁅R,L⁆ P :=\n{ ..lie_module_hom.comp e₂.to_lie_module_hom e₁.to_lie_module_hom,\n  ..linear_equiv.trans e₁.to_linear_equiv e₂.to_linear_equiv }\n\n@[simp] lemma trans_apply (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) (m : M) :\n  (e₁.trans e₂) m = e₂ (e₁ m) := rfl\n\n@[simp] lemma symm_trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) :\n  (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl\n\n@[simp] lemma self_trans_symm (e : M ≃ₗ⁅R,L⁆ N) : e.trans e.symm = refl :=\next _ _ e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : M ≃ₗ⁅R,L⁆ N) : e.symm.trans e = refl :=\next _ _ e.apply_symm_apply\n\nend lie_module_equiv\n\nend lie_module_morphisms\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebra/lie/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117983401363, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4837100274022426}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module linear_algebra.clifford_algebra.even\n! leanprover-community/mathlib commit 9264b15ee696b7ca83f13c8ad67c83d6eb70b730\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.CliffordAlgebra.Fold\nimport Mathbin.LinearAlgebra.CliffordAlgebra.Grading\n\n/-!\n# The universal property of the even subalgebra\n\n## Main definitions\n\n* `clifford_algebra.even Q`: The even subalgebra of `clifford_algebra Q`.\n* `clifford_algebra.even_hom`: The type of bilinear maps that satisfy the universal property of the\n  even subalgebra\n* `clifford_algebra.even.lift`: The universal property of the even subalgebra, which states\n  that every bilinear map `f` with `f v v = Q v` and `f u v * f v w = Q v • f u w` is in unique\n  correspondence with an algebra morphism from `clifford_algebra.even Q`.\n\n## Implementation notes\n\nThe approach here is outlined in \"Computing with the universal properties of the Clifford algebra\nand the even subalgebra\" (to appear).\n\nThe broad summary is that we have two tricks available to us for implementing complex recursors on\ntop of `clifford_algebra.lift`: the first is to use morphisms as the output type, such as\n`A = module.End R N` which is how we obtained `clifford_algebra.foldr`; and the second is to use\n`N = (N', S)` where `N'` is the value we wish to compute, and `S` is some auxiliary state passed\nbetween one recursor invocation and the next.\nFor the universal property of the even subalgebra, we apply a variant of the first trick again by\nchoosing `S` to itself be a submodule of morphisms.\n-/\n\n\nnamespace CliffordAlgebra\n\nvariable {R M : Type _} [CommRing R] [AddCommGroup M] [Module R M]\n\nvariable {Q : QuadraticForm R M}\n\n-- put this after `Q` since we want to talk about morphisms from `clifford_algebra Q` to `A` and\n-- that order is more natural\nvariable {A B : Type _} [Ring A] [Ring B] [Algebra R A] [Algebra R B]\n\nopen DirectSum\n\nvariable (Q)\n\n/-- The even submodule `clifford_algebra.even_odd Q 0` is also a subalgebra. -/\ndef even : Subalgebra R (CliffordAlgebra Q) :=\n  (evenOdd Q 0).toSubalgebra SetLike.GradedMonoid.one_mem fun x y hx hy =>\n    add_zero (0 : ZMod 2) ▸ SetLike.GradedMonoid.mul_mem hx hy\n#align clifford_algebra.even CliffordAlgebra.even\n\n@[simp]\ntheorem even_toSubmodule : (even Q).toSubmodule = evenOdd Q 0 :=\n  rfl\n#align clifford_algebra.even_to_submodule CliffordAlgebra.even_toSubmodule\n\nvariable (A)\n\n/-- The type of bilinear maps which are accepted by `clifford_algebra.even.lift`. -/\n@[ext]\nstructure EvenHom : Type max u_2 u_3 where\n  bilin : M →ₗ[R] M →ₗ[R] A\n  contract (m : M) : bilin m m = algebraMap R A (Q m)\n  contract_mid (m₁ m₂ m₃ : M) : bilin m₁ m₂ * bilin m₂ m₃ = Q m₂ • bilin m₁ m₃\n#align clifford_algebra.even_hom CliffordAlgebra.EvenHom\n\nvariable {A Q}\n\n/-- Compose an `even_hom` with an `alg_hom` on the output. -/\n@[simps]\ndef EvenHom.compr₂ (g : EvenHom Q A) (f : A →ₐ[R] B) : EvenHom Q B\n    where\n  bilin := g.bilin.compr₂ f.toLinearMap\n  contract m := (f.congr_arg <| g.contract _).trans <| f.commutes _\n  contract_mid m₁ m₂ m₃ :=\n    (f.map_mul _ _).symm.trans <| (f.congr_arg <| g.contract_mid _ _ _).trans <| f.map_smul _ _\n#align clifford_algebra.even_hom.compr₂ CliffordAlgebra.EvenHom.compr₂\n\nvariable (Q)\n\n/-- The embedding of pairs of vectors into the even subalgebra, as a bilinear map. -/\n@[simps bilin_apply_apply_coe]\ndef even.ι : EvenHom Q (even Q)\n    where\n  bilin :=\n    LinearMap.mk₂ R (fun m₁ m₂ => ⟨ι Q m₁ * ι Q m₂, ι_mul_ι_mem_evenOdd_zero _ _ _⟩)\n      (fun _ _ _ => by\n        simp only [LinearMap.map_add, add_mul]\n        rfl)\n      (fun _ _ _ => by\n        simp only [LinearMap.map_smul, smul_mul_assoc]\n        rfl)\n      (fun _ _ _ => by\n        simp only [LinearMap.map_add, mul_add]\n        rfl)\n      fun _ _ _ => by\n      simp only [LinearMap.map_smul, mul_smul_comm]\n      rfl\n  contract m := Subtype.ext <| ι_sq_scalar Q m\n  contract_mid m₁ m₂ m₃ :=\n    Subtype.ext <|\n      calc\n        ι Q m₁ * ι Q m₂ * (ι Q m₂ * ι Q m₃) = ι Q m₁ * (ι Q m₂ * ι Q m₂ * ι Q m₃) := by\n          simp only [mul_assoc]\n        _ = Q m₂ • (ι Q m₁ * ι Q m₃) := by rw [Algebra.smul_def, ι_sq_scalar, Algebra.left_comm]\n        \n#align clifford_algebra.even.ι CliffordAlgebra.even.ι\n\ninstance : Inhabited (EvenHom Q (even Q)) :=\n  ⟨even.ι Q⟩\n\nvariable (f : EvenHom Q A)\n\n/-- Two algebra morphisms from the even subalgebra are equal if they agree on pairs of generators.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext]\ntheorem even.algHom_ext ⦃f g : even Q →ₐ[R] A⦄ (h : (even.ι Q).compr₂ f = (even.ι Q).compr₂ g) :\n    f = g := by\n  rw [even_hom.ext_iff] at h\n  ext ⟨x, hx⟩\n  refine' even_induction _ _ _ _ _ hx\n  · intro r\n    exact (f.commutes r).trans (g.commutes r).symm\n  · intro x y hx hy ihx ihy\n    have := congr_arg₂ (· + ·) ihx ihy\n    exact (f.map_add _ _).trans (this.trans <| (g.map_add _ _).symm)\n  · intro m₁ m₂ x hx ih\n    have := congr_arg₂ (· * ·) (LinearMap.congr_fun (LinearMap.congr_fun h m₁) m₂) ih\n    exact (f.map_mul _ _).trans (this.trans <| (g.map_mul _ _).symm)\n#align clifford_algebra.even.alg_hom_ext CliffordAlgebra.even.algHom_ext\n\nvariable {Q}\n\nnamespace Even.Lift\n\n/-- An auxiliary submodule used to store the half-applied values of `f`.\nThis is the span of elements `f'` such that `∃ x m₂, ∀ m₁, f' m₁ = f m₁ m₂ * x`.  -/\nprivate def S : Submodule R (M →ₗ[R] A) :=\n  Submodule.span R\n    { f' | ∃ x m₂, f' = LinearMap.lcomp R _ (f.bilin.flip m₂) (LinearMap.mulRight R x) }\n#align clifford_algebra.even.lift.S clifford_algebra.even.lift.S\n\n/-- An auxiliary bilinear map that is later passed into `clifford_algebra.fold`. Our desired result\nis stored in the `A` part of the accumulator, while auxiliary recursion state is stored in the `S f`\npart. -/\nprivate def f_fold : M →ₗ[R] A × s f →ₗ[R] A × s f :=\n  LinearMap.mk₂ R\n    (fun m acc =>\n      /- We could write this `snd` term in a point-free style as follows, but it wouldn't help as we\n        don't have any prod or subtype combinators to deal with n-linear maps of this degree.\n        ```lean\n        (linear_map.lcomp R _ (algebra.lmul R A).to_linear_map.flip).comp $\n          (linear_map.llcomp R M A A).flip.comp f.flip : M →ₗ[R] A →ₗ[R] M →ₗ[R] A)\n        ```\n        -/\n      (Acc.2 m,\n        ⟨(LinearMap.mulRight R Acc.1).comp (f.bilin.flip m), Submodule.subset_span <| ⟨_, _, rfl⟩⟩))\n    (fun m₁ m₂ a =>\n      Prod.ext (LinearMap.map_add _ m₁ m₂)\n        (Subtype.ext <|\n          LinearMap.ext fun m₃ =>\n            show f.bilin m₃ (m₁ + m₂) * a.1 = f.bilin m₃ m₁ * a.1 + f.bilin m₃ m₂ * a.1 by\n              rw [map_add, add_mul]))\n    (fun c m a =>\n      Prod.ext (LinearMap.map_smul _ c m)\n        (Subtype.ext <|\n          LinearMap.ext fun m₃ =>\n            show f.bilin m₃ (c • m) * a.1 = c • (f.bilin m₃ m * a.1) by\n              rw [LinearMap.map_smul, smul_mul_assoc]))\n    (fun m a₁ a₂ => Prod.ext rfl (Subtype.ext <| LinearMap.ext fun m₃ => mul_add _ _ _))\n    fun c m a => Prod.ext rfl (Subtype.ext <| LinearMap.ext fun m₃ => mul_smul_comm _ _ _)\n#align clifford_algebra.even.lift.f_fold clifford_algebra.even.lift.f_fold\n\n@[simp]\nprivate theorem fst_f_fold_f_fold (m₁ m₂ : M) (x : A × s f) :\n    (fFold f m₁ (fFold f m₂ x)).fst = f.bilin m₁ m₂ * x.fst :=\n  rfl\n#align clifford_algebra.even.lift.fst_f_fold_f_fold clifford_algebra.even.lift.fst_f_fold_f_fold\n\n@[simp]\nprivate theorem snd_f_fold_f_fold (m₁ m₂ m₃ : M) (x : A × s f) :\n    ((fFold f m₁ (fFold f m₂ x)).snd : M →ₗ[R] A) m₃ = f.bilin m₃ m₁ * (x.snd : M →ₗ[R] A) m₂ :=\n  rfl\n#align clifford_algebra.even.lift.snd_f_fold_f_fold clifford_algebra.even.lift.snd_f_fold_f_fold\n\nprivate theorem f_fold_f_fold (m : M) (x : A × s f) : fFold f m (fFold f m x) = Q m • x :=\n  by\n  obtain ⟨a, ⟨g, hg⟩⟩ := x\n  ext : 2\n  · change f.bilin m m * a = Q m • a\n    rw [Algebra.smul_def, f.contract]\n  · ext m₁\n    change f.bilin _ _ * g m = Q m • g m₁\n    apply Submodule.span_induction' _ _ _ _ hg\n    · rintro _ ⟨b, m₃, rfl⟩\n      change f.bilin _ _ * (f.bilin _ _ * b) = Q m • (f.bilin _ _ * b)\n      rw [← smul_mul_assoc, ← mul_assoc, f.contract_mid]\n    · change f.bilin m₁ m * 0 = Q m • 0\n      rw [MulZeroClass.mul_zero, smul_zero]\n    · rintro x hx y hy ihx ihy\n      rw [LinearMap.add_apply, LinearMap.add_apply, mul_add, smul_add, ihx, ihy]\n    · rintro x hx c ihx\n      rw [LinearMap.smul_apply, LinearMap.smul_apply, mul_smul_comm, ihx, smul_comm]\n#align clifford_algebra.even.lift.f_fold_f_fold clifford_algebra.even.lift.f_fold_f_fold\n\n/-- The final auxiliary construction for `clifford_algebra.even.lift`. This map is the forwards\ndirection of that equivalence, but not in the fully-bundled form. -/\n@[simps (config := { attrs := [] }) apply]\ndef aux (f : EvenHom Q A) : CliffordAlgebra.even Q →ₗ[R] A :=\n  by\n  refine' _ ∘ₗ (Even Q).val.toLinearMap\n  exact LinearMap.fst _ _ _ ∘ₗ foldr Q (f_fold f) (f_fold_f_fold f) (1, 0)\n#align clifford_algebra.even.lift.aux CliffordAlgebra.even.Lift.aux\n\n@[simp]\ntheorem aux_one : aux f 1 = 1 :=\n  congr_arg Prod.fst (foldr_one _ _ _ _)\n#align clifford_algebra.even.lift.aux_one CliffordAlgebra.even.Lift.aux_one\n\n@[simp]\ntheorem aux_ι (m₁ m₂ : M) : aux f ((even.ι Q).bilin m₁ m₂) = f.bilin m₁ m₂ :=\n  (congr_arg Prod.fst (foldr_mul _ _ _ _ _ _)).trans\n    (by\n      rw [foldr_ι, foldr_ι]\n      exact mul_one _)\n#align clifford_algebra.even.lift.aux_ι CliffordAlgebra.even.Lift.aux_ι\n\n@[simp]\ntheorem aux_algebraMap (r) (hr) : aux f ⟨algebraMap R _ r, hr⟩ = algebraMap R _ r :=\n  (congr_arg Prod.fst (foldr_algebraMap _ _ _ _ _)).trans (Algebra.algebraMap_eq_smul_one r).symm\n#align clifford_algebra.even.lift.aux_algebra_map CliffordAlgebra.even.Lift.aux_algebraMap\n\n@[simp]\ntheorem aux_mul (x y : even Q) : aux f (x * y) = aux f x * aux f y :=\n  by\n  cases x\n  cases y\n  refine' (congr_arg Prod.fst (foldr_mul _ _ _ _ _ _)).trans _\n  dsimp only\n  refine' even_induction Q _ _ _ _ x_property\n  · intro r\n    rw [foldr_algebra_map, aux_algebra_map]\n    exact Algebra.smul_def r _\n  · intro x y hx hy ihx ihy\n    rw [LinearMap.map_add, Prod.fst_add, ihx, ihy, ← add_mul, ← LinearMap.map_add]\n    rfl\n  · rintro m₁ m₂ x (hx : x ∈ Even Q) ih\n    rw [aux_apply, foldr_mul, foldr_mul, foldr_ι, foldr_ι, fst_f_fold_f_fold, ih, ← mul_assoc,\n      Subtype.coe_mk, foldr_mul, foldr_mul, foldr_ι, foldr_ι, fst_f_fold_f_fold]\n    rfl\n#align clifford_algebra.even.lift.aux_mul CliffordAlgebra.even.Lift.aux_mul\n\nend Even.Lift\n\nopen Even.Lift\n\nvariable (Q) {A}\n\n/-- Every algebra morphism from the even subalgebra is in one-to-one correspondence with a\nbilinear map that sends duplicate arguments to the quadratic form, and contracts across\nmultiplication. -/\n@[simps symm_apply_bilin]\ndef even.lift : EvenHom Q A ≃ (CliffordAlgebra.even Q →ₐ[R] A)\n    where\n  toFun f := AlgHom.ofLinearMap (aux f) (aux_one f) (aux_mul f)\n  invFun F := (even.ι Q).compr₂ F\n  left_inv f := EvenHom.ext _ _ <| LinearMap.ext₂ <| even.Lift.aux_ι f\n  right_inv F := even.algHom_ext Q <| EvenHom.ext _ _ <| LinearMap.ext₂ <| even.Lift.aux_ι _\n#align clifford_algebra.even.lift CliffordAlgebra.even.lift\n\n@[simp]\ntheorem even.lift_ι (f : EvenHom Q A) (m₁ m₂ : M) :\n    even.lift Q f ((even.ι Q).bilin m₁ m₂) = f.bilin m₁ m₂ :=\n  even.Lift.aux_ι _ _ _\n#align clifford_algebra.even.lift_ι CliffordAlgebra.even.lift_ι\n\nend CliffordAlgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/CliffordAlgebra/Even.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.754914997895581, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4836256253674458}}
{"text": "\nimport counit_ker_abelian\nimport pq_group_homo_locus\nimport pq_induction_principles\n\nuniverse u\n\nsection pq_group_homo_locus_pres\n\ninductive pre_homo_locus_pres (G : Type u) [group G] : Type u\n| unit : pre_homo_locus_pres\n| incl (x y : G) : pre_homo_locus_pres\n| mul (x y : pre_homo_locus_pres) : pre_homo_locus_pres\n| inv (x : pre_homo_locus_pres) : pre_homo_locus_pres\n\nopen pre_homo_locus_pres\n\ninductive pre_homo_locus_pres_rel' (G : Type u) [group G] : pre_homo_locus_pres G → pre_homo_locus_pres G → Type u\n| refl {a : pre_homo_locus_pres G} : pre_homo_locus_pres_rel' a a\n| symm {a b : pre_homo_locus_pres G} (hab : pre_homo_locus_pres_rel' a b) : pre_homo_locus_pres_rel' b a\n| trans {a b c : pre_homo_locus_pres G} \n  (hab : pre_homo_locus_pres_rel' a b) (hbc : pre_homo_locus_pres_rel' b c) : pre_homo_locus_pres_rel' a c\n| congr_mul {a b a' b' : pre_homo_locus_pres G} \n  (ha : pre_homo_locus_pres_rel' a a') (hb : pre_homo_locus_pres_rel' b b') : \n  pre_homo_locus_pres_rel' (mul a b) (mul a' b') \n| congr_inv {a a' : pre_homo_locus_pres G} (ha : pre_homo_locus_pres_rel' a a') : \n  pre_homo_locus_pres_rel' (inv a) (inv a')\n| assoc (a b c : pre_homo_locus_pres G) : pre_homo_locus_pres_rel' (mul (mul a b) c) (mul a (mul b c))\n| one_mul (a : pre_homo_locus_pres G) : pre_homo_locus_pres_rel' (mul unit a) a\n| mul_one (a : pre_homo_locus_pres G) : pre_homo_locus_pres_rel' (mul a unit) a\n| mul_left_inv (a : pre_homo_locus_pres G) : pre_homo_locus_pres_rel' (mul (inv a) a) unit\n| comm (a1 a2 b1 b2 : G) : pre_homo_locus_pres_rel' (mul (incl a1 a2) (incl b1 b2)) (mul (incl b1 b2) (incl a1 a2))\n| homo_locus_eq_zero (a b : G) (hab : homo_locus (a, b)) : pre_homo_locus_pres_rel' (incl a b) unit\n| third_cancel (a b x : G) : pre_homo_locus_pres_rel' (incl a b) (mul (mul (incl x a)  (incl (x * a) (b))) (inv (incl x (a * b))))\n| rhd_inv (a b : G) : pre_homo_locus_pres_rel' (incl a b) (inv (incl (a * b) (a⁻¹)))\n\ninductive pre_homo_locus_pres_rel (G : Type u) [group G] : pre_homo_locus_pres G → pre_homo_locus_pres G → Prop\n| rel {a b : pre_homo_locus_pres G} (r : pre_homo_locus_pres_rel' G a b) : pre_homo_locus_pres_rel a b\n\n\nvariables {G : Type*} [group G]\n\nlemma pre_homo_locus_pres_rel'.rel {a b : pre_homo_locus_pres G} : pre_homo_locus_pres_rel' G a b → pre_homo_locus_pres_rel G a b := pre_homo_locus_pres_rel.rel\n\n\n@[refl]\nlemma pre_homo_locus_pres_rel.refl {a : pre_homo_locus_pres G} : pre_homo_locus_pres_rel G a a := \npre_homo_locus_pres_rel'.rel pre_homo_locus_pres_rel'.refl\n\n\n@[symm]\nlemma pre_homo_locus_pres_rel.symm {a b : pre_homo_locus_pres G} : pre_homo_locus_pres_rel G a b → pre_homo_locus_pres_rel G b a\n| ⟨r⟩ := r.symm.rel\n\n\n@[trans]\nlemma pre_homo_locus_pres_rel.trans {a b c : pre_homo_locus_pres G} : \npre_homo_locus_pres_rel G a b → pre_homo_locus_pres_rel G b c → pre_homo_locus_pres_rel G a c\n| ⟨rab⟩ ⟨rbc⟩ := (rab.trans rbc).rel\n\n\ninstance pre_homo_locus_pres.setoid (G : Type*) [group G] : setoid (pre_homo_locus_pres G) :=\n{\n    r := pre_homo_locus_pres_rel G,\n    iseqv := begin\n        split, apply pre_homo_locus_pres_rel.refl,\n        split, apply pre_homo_locus_pres_rel.symm,\n        apply pre_homo_locus_pres_rel.trans,\n    end\n}\n\n\ndef homo_locus_pres (G : Type*) [group G] := quotient (pre_homo_locus_pres.setoid G)\n\n\ninstance homo_locus_pres_is_group : group (homo_locus_pres G) := \n{ mul := λ a b, quotient.lift_on₂ a b\n                  (λ a b, ⟦pre_homo_locus_pres.mul a b⟧)\n                  (λ a b a' b' ⟨ha⟩ ⟨hb⟩,\n                    quotient.sound (pre_homo_locus_pres_rel'.congr_mul ha hb).rel),\n  one := ⟦unit⟧,\n  inv := λ a, quotient.lift_on a\n                (λ a, ⟦pre_homo_locus_pres.inv a⟧)\n                (λ a a' ⟨ha⟩,\n                  quotient.sound (pre_homo_locus_pres_rel'.congr_inv ha).rel),\n  mul_assoc := λ a b c,\n    quotient.induction_on₃ a b c (λ a b c, quotient.sound (pre_homo_locus_pres_rel'.assoc a b c).rel),\n  one_mul := λ a,\n    quotient.induction_on a (λ a, quotient.sound (pre_homo_locus_pres_rel'.one_mul a).rel),\n  mul_one := λ a,\n    quotient.induction_on a (λ a, quotient.sound (pre_homo_locus_pres_rel'.mul_one a).rel),\n  mul_left_inv := λ a,\n    quotient.induction_on a (λ a, quotient.sound (pre_homo_locus_pres_rel'.mul_left_inv a).rel) }\n\ndef homo_locus_of (x : G × G) : homo_locus_pres G := ⟦incl x.1 x.2⟧\n\nlemma homo_locus_of_def (x : G × G) : homo_locus_of x = ⟦incl x.1 x.2⟧ := rfl\n\nlemma homo_locus_pres_one_def : (1 : homo_locus_pres G) = ⟦unit⟧ := rfl\n\nlemma homo_locus_pres_mul_def (x y : pre_homo_locus_pres G) : (⟦x⟧ * ⟦y⟧ : homo_locus_pres G) = ⟦x.mul y⟧ := rfl \n\nlemma homo_locus_pres_inv_def (x : pre_homo_locus_pres G) : (⟦x⟧⁻¹ : homo_locus_pres G) = ⟦x.inv⟧ := rfl \n\nlemma homo_locus_pres_quot_mk_helper (x : pre_homo_locus_pres G) : quot.mk setoid.r x = ⟦x⟧ := rfl\n\nvariables {H : Type*} [group H]\n\ndef is_homo_locus_liftable (f : G × G → H) : Prop := (∀ a b : G × G, f a * f b = f b * f a) ∧ (∀ a b : G, homo_locus (a, b) → f (a, b) = 1) ∧ (∀ a b x : G, f (a, b) = f (x, a) * f (x * a, b) * ((f (x, (a * b)))⁻¹)) ∧ (∀ a b : G, f (a, b) = (f (a * b, a⁻¹))⁻¹)\n\n\ndef lift_homo_locus_pres_morph_pre (f : G × G → H) (hf : is_homo_locus_liftable f) : pre_homo_locus_pres G → H\n| unit := 1\n| (incl a b) := f (a, b)\n| (mul a b) := lift_homo_locus_pres_morph_pre a * lift_homo_locus_pres_morph_pre b\n| (inv a) := (lift_homo_locus_pres_morph_pre a)⁻¹\n\ndef lift_homo_locus_pres_morph (f : G × G → H) (hf : is_homo_locus_liftable f) : homo_locus_pres G →* H := { \n  to_fun := quotient.lift (lift_homo_locus_pres_morph_pre f hf) begin \n    intros a b hab,\n    induction hab,\n    induction hab_r,\n    {\n      refl,\n    },\n    {\n      symmetry,\n      assumption,\n    },\n    {\n      transitivity,\n      assumption,\n      assumption,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      congr,\n      assumption,\n      assumption,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      congr,\n      assumption,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw mul_assoc,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw one_mul,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw mul_one,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw mul_left_inv,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw hf.1,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw hf.2.1,\n      assumption,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw hf.2.2.1,\n    },\n    {\n      unfold lift_homo_locus_pres_morph_pre,\n      rw hf.2.2.2,\n    },\n  end,\n  map_one' := begin \n    refl,\n  end,\n  map_mul' := begin \n    intros x y,\n    induction x,\n    induction y,\n    refl,\n    refl,\n    refl,\n  end }\n\nlemma homo_locus_of_inv_alt (x y : G) : (homo_locus_of (x * y, x⁻¹))⁻¹ = homo_locus_of (x, y) :=\nbegin\n  symmetry,\n  apply quotient.sound,\n  simp only,\n  fconstructor,\n  exact pre_homo_locus_pres_rel'.rhd_inv x y,\nend\n\nlemma homo_locus_of_inv (x y : G) : (homo_locus_of (x, y))⁻¹ = homo_locus_of (x * y, x⁻¹) :=\nbegin\n  rw ←homo_locus_of_inv_alt,\n  simp only [inv_inv],\nend\n\nlemma homo_locus_of_one (x y : G) (hxy : homo_locus (x, y)) : homo_locus_of (x, y) = 1 :=\nbegin\n  apply quotient.sound,\n  simp only,\n  fconstructor,\n  exact pre_homo_locus_pres_rel'.homo_locus_eq_zero x y hxy,\nend\n\nlemma homo_locus_third_cancel (a b x : G) : homo_locus_of (a, b) = (homo_locus_of (x, a) * homo_locus_of (x * a, b) * (homo_locus_of (x, a * b))⁻¹) :=\nbegin\n  apply quotient.sound,\n  simp only,\n  fconstructor,\n  exact pre_homo_locus_pres_rel'.third_cancel a b x,\nend\n\n\nlemma homo_locus_pres_comm (x y : homo_locus_pres G) : x * y = y * x :=\nbegin\n  induction x,\n  induction y,\n  {\n    rw homo_locus_pres_quot_mk_helper,\n    rw homo_locus_pres_quot_mk_helper,\n    induction x,\n    {\n      rw ←homo_locus_pres_one_def,\n      simp only [mul_one, one_mul],\n    },\n    {\n      induction y,\n      {\n        rw ←homo_locus_pres_one_def,\n        simp only [mul_one, one_mul],\n      },\n      {\n        apply quotient.sound,\n        fconstructor,\n        exact pre_homo_locus_pres_rel'.comm x_x x_y y_x y_y,\n      },\n      {\n        rw ←homo_locus_pres_mul_def,\n        rw ←mul_assoc,\n        rw y_ih_x,\n        rw mul_assoc,\n        rw y_ih_y,\n        rw ←mul_assoc,\n      },\n      {\n        rw ←homo_locus_pres_inv_def,\n        have : (⟦y_x⟧ * ⟦y_x⟧⁻¹ * ⟦incl x_x x_y⟧ * ⟦y_x⟧ : homo_locus_pres G) = ⟦y_x⟧ * ⟦incl x_x x_y⟧ * ⟦y_x⟧⁻¹ * ⟦y_x⟧,\n        {\n          simp only [one_mul, mul_right_inv, inv_mul_cancel_right],\n          rw y_ih,\n        },\n        rw mul_left_inj at this,\n        rw mul_assoc at this,\n        rw mul_assoc at this,\n        rw mul_right_inj at this,\n        rw this,\n      },\n    },\n    {\n      rw ←homo_locus_pres_mul_def,\n      rw mul_assoc,\n      rw x_ih_y,\n      rw ←mul_assoc,\n      rw x_ih_x,\n      rw ←mul_assoc,\n    },\n    {\n      rw ←homo_locus_pres_inv_def,\n      have : (⟦x_x⟧ * ⟦x_x⟧⁻¹ * ⟦y⟧ * ⟦x_x⟧ : homo_locus_pres G) = ⟦x_x⟧ * ⟦y⟧ * ⟦x_x⟧⁻¹ * ⟦x_x⟧,\n      {\n        simp only [one_mul, mul_right_inv, inv_mul_cancel_right],\n        rw x_ih,\n      },\n      rw mul_left_inj at this,\n      rw mul_assoc at this,\n      rw mul_assoc at this,\n      rw mul_right_inj at this,\n      rw this,\n    },\n  },\n  refl,\n  refl,\nend\n\nlemma homo_locus_assoc (a b c : G) : homo_locus_of (a * b, c) * homo_locus_of (a, b) = homo_locus_of (a, b * c) * homo_locus_of (b, c) :=\nbegin\n  rw homo_locus_third_cancel b c a,\n  rw homo_locus_pres_comm,\n  conv {\n    to_rhs,\n    rw homo_locus_pres_comm,\n  },\n  simp only [inv_mul_cancel_right],\nend\n\nlemma homo_locus_assoc_alt (a b c : G) : homo_locus_of (a * b, c) = homo_locus_of (a, b * c) * homo_locus_of (b, c) * (homo_locus_of (a, b))⁻¹ :=\nbegin\n  rw ←homo_locus_assoc,\n  simp only [mul_inv_cancel_right],\nend\n\nlemma homo_locus_of_inv_assoc (a b : G) : (homo_locus_of (a, b))⁻¹ = homo_locus_of (b⁻¹, a * b) :=\nbegin\n  have : (homo_locus_of (b⁻¹, a))⁻¹ * homo_locus_of (b⁻¹, a) = 1,\n  {\n    simp only [mul_left_inv],\n  },\n  rw homo_locus_of_inv at this,\n  rw homo_locus_assoc_alt at this,\n  simp only [inv_inv, inv_mul_cancel_right] at this,\n  group,\n  simp only [gpow_one, gpow_neg],\n  refine inv_inj.mp _,\n  simp only [mul_inv_rev, one_inv, inv_inv],\n  exact this,\nend\n\nlemma homo_locus_of_inv_cancel (a b : G) : (homo_locus_of (a, b))⁻¹ = homo_locus_of (a * b, b⁻¹) :=\nbegin\n  rw homo_locus_assoc_alt,\n  have : homo_locus_of (a, b * b⁻¹) = 1,\n  {\n    simp only [mul_right_inv],\n    rw homo_locus_of_one,\n    exact homo_locus_closed_right_one a,\n  },\n  rw this,\n  clear this,\n  have : homo_locus_of (b, b⁻¹) = 1,\n  {\n    rw homo_locus_of_one,\n    exact homo_locus_closed_right_inv b,\n  },\n  rw this,\n  clear this,\n  simp only [one_mul],\nend\n\nlemma homo_locus_of_symm (a b c : G) : homo_locus_of (a, b) = homo_locus_of (b, a) :=\nbegin\n  have : ∀ a b : G, homo_locus_of (b⁻¹, a * b) = homo_locus_of (a * b, b⁻¹),\n  {\n    intros a b,\n    rw ←homo_locus_of_inv_cancel,\n    rw ←homo_locus_of_inv_assoc,\n  },\n  specialize this (a * b) (b⁻¹),\n  simp only [inv_inv, mul_inv_cancel_right] at this,\n  symmetry,\n  exact this,\nend\n\nlemma homo_locus_of_shift (a b : G) : homo_locus_of (a, b) = homo_locus_of (a, (a*b)⁻¹) :=\nbegin\n  have : ∀ a b : G, homo_locus_of (a * b, b⁻¹) = homo_locus_of (a * b, a⁻¹),\n  {\n    intros a b,\n    rw ←homo_locus_of_inv a b,\n    rw ←homo_locus_of_inv_cancel,\n  },\n  specialize this (a * b) (b⁻¹),\n  simp only [mul_inv_rev, inv_inv, mul_inv_cancel_right] at this,\n  convert this,\n  simp only [mul_inv_rev],\nend\n\n-- Try to prove another way, and remove from quotient rel\n-- An idea: use isomorphism to obtain this\nlemma homo_locus_of_inv_rev (a b : G) : (homo_locus_of (a, b))⁻¹ = homo_locus_of (b⁻¹, a⁻¹) :=\nbegin\n  refine inv_inj.mp _,\n  simp only [inv_inv],\n  rw homo_locus_of_inv_assoc,\n  simp only [inv_inv],\n  rw homo_locus_of_shift,\n  simp only [mul_inv_rev],\nend\n\nend pq_group_homo_locus_pres\n\nsection pq_group_homo_locus_pres_double_list\n\nvariables {G : Type u} [group G]\n\nopen pre_homo_locus_pres\n\ndef pre_homo_locus_pres_to_list : pre_homo_locus_pres G → list G\n| unit := []\n| (incl a b) := [a, b]\n| (mul a b) := let x := (pre_homo_locus_pres_to_list a) in let y := (pre_homo_locus_pres_to_list b) in x ++ y ++ [x.prod⁻¹]\n| (inv a) := let x := (pre_homo_locus_pres_to_list a) in (x.map (λ x : G, x⁻¹)).reverse\n\nlemma pre_homo_locus_pres_to_list_eq_id (x : pre_homo_locus_pres G) : ((counit_ker_decomp (pre_homo_locus_pres_to_list x)).map (homo_locus_of)).prod = ⟦x⟧ :=\nbegin\n  induction x,\n  {\n    unfold pre_homo_locus_pres_to_list,\n    unfold counit_ker_decomp,\n    unfold counit_ker_decomp_pre,\n    simp only [list.prod_nil, list.map],\n    refl,\n  },\n  {\n    unfold pre_homo_locus_pres_to_list,\n    unfold counit_ker_decomp,\n    unfold counit_ker_decomp_pre,\n    simp only [mul_one, one_mul, list.prod_cons, list.prod_nil, list.map],\n    suffices : homo_locus_of (1, x_x) = 1,\n    simp only [this, one_mul], refl,\n    apply quotient.sound,\n    simp only,\n    fconstructor,\n    refine pre_homo_locus_pres_rel'.homo_locus_eq_zero 1 x_x _,\n    exact homo_locus_closed_left_one x_x,\n  },\n  {\n    unfold pre_homo_locus_pres_to_list,\n    simp only,\n    rw ←homo_locus_pres_mul_def,\n    rw ←x_ih_x,\n    rw ←x_ih_y,\n    clear x_ih_x x_ih_y,\n    rw counit_ker_decomp_append,\n    rw counit_ker_decomp_append,\n    simp only [mul_right_inj, list.map_append, list.prod_append, list.append_assoc],\n    unfold counit_ker_decomp_pre,\n    simp only [mul_one, list.prod_cons, list.prod_nil, list.map],\n    generalize : pre_homo_locus_pres_to_list x_x = x,\n    generalize : pre_homo_locus_pres_to_list x_y = y,\n    clear x_x x_y,\n    unfold counit_ker_decomp,\n    suffices : (list.map homo_locus_of (counit_ker_decomp_pre x.prod y)).prod = (list.map homo_locus_of (counit_ker_decomp_pre 1 y)).prod * (homo_locus_of (x.prod * y.prod, (x.prod)⁻¹))⁻¹,\n    {\n      rw this,\n      simp only [inv_mul_cancel_right],\n    },\n    rw homo_locus_of_inv_alt,\n    generalize : x.prod = b,\n    clear x,\n    induction y generalizing b,\n    {\n      simp only [mul_one, list.prod_nil],\n      unfold counit_ker_decomp_pre,\n      simp only [one_mul, list.prod_nil, list.map],\n      symmetry,\n      apply homo_locus_of_one,\n      exact homo_locus_closed_right_one b,\n    },\n    {\n      unfold counit_ker_decomp_pre,\n      simp only [one_mul, list.prod_cons, list.map],\n      have hy1 := y_ih (b * y_hd),\n      rw hy1,\n      clear hy1,\n      have hy2 := y_ih (y_hd),\n      rw hy2,\n      clear hy2,\n      rw ←mul_assoc,\n      have one_rw : homo_locus_of (1, y_hd) = 1,\n      {\n        apply homo_locus_of_one,\n        exact homo_locus_closed_left_one y_hd,\n      },\n      rw one_rw,\n      rw one_mul,\n      clear one_rw,\n      rw homo_locus_pres_comm,\n      rw ←mul_assoc,\n      conv {\n        to_rhs,\n        rw homo_locus_pres_comm,\n        congr,\n        skip,\n        rw homo_locus_pres_comm,\n      },\n      rw ←mul_assoc,\n      simp only [mul_left_inj],\n      generalize : y_tl.prod = c,\n      rename y_hd a,\n      clear y_ih y_tl,\n      apply homo_locus_assoc,\n    },\n  },\n  {\n    unfold pre_homo_locus_pres_to_list,\n    simp only,\n    rw ←homo_locus_pres_inv_def,\n    rw ←x_ih,\n    clear x_ih,\n    generalize : pre_homo_locus_pres_to_list x_x = x,\n    clear x_x,\n    induction x,\n    {\n      simp only [list.map, list.reverse_nil],\n      exact one_inv.symm,\n    },\n    {\n      simp only [list.reverse_cons, list.map],\n      rw counit_ker_decomp_append_one,\n      simp only [mul_one, list.map_append, list.prod_append, list.prod_cons, list.prod_nil, list.map],\n      rw x_ih,\n      clear x_ih,\n      unfold counit_ker_decomp,\n      unfold counit_ker_decomp_pre,\n      simp only [mul_inv_rev, one_mul, list.prod_cons, list.map],\n      have : (homo_locus_of (1, x_hd))⁻¹ = 1,\n      {\n        refine inv_eq_one.mpr _,\n        apply homo_locus_of_one,\n        exact homo_locus_closed_left_one x_hd,\n      },\n      rw this,\n      clear this,\n      rw mul_one,\n      have : (list.map has_inv.inv x_tl).reverse.prod = (x_tl.prod)⁻¹,\n      {\n        clear x_hd,\n        induction x_tl,\n        {\n          simp only [one_inv, list.prod_nil, list.map, list.reverse_nil],\n        },\n        {\n          simp only [list.reverse_cons, mul_inv_rev, mul_one, list.prod_append, list.prod_cons, list.prod_nil, mul_left_inj, list.map, x_tl_ih],\n        },\n      },\n      rw this,\n      clear this,\n      rw ←inv_inj,\n      simp only [mul_inv_rev, inv_inv],\n      induction x_tl generalizing x_hd,\n      {\n        simp only [one_inv, list.prod_nil],\n        unfold counit_ker_decomp_pre,\n        simp only [mul_one, inv_eq_one, list.prod_nil, list.map],\n        apply homo_locus_of_one,\n        exact homo_locus_closed_left_one x_hd⁻¹,\n      },\n      {\n        simp only [mul_inv_rev, list.prod_cons],\n        unfold counit_ker_decomp_pre,\n        simp only [one_mul, list.prod_cons, list.map],\n        rw ←x_tl_ih (x_tl_hd),\n        rw ←x_tl_ih (x_hd * x_tl_hd),\n        simp only [←mul_assoc],\n        simp only [mul_inv_rev, mul_left_inj],\n        generalize : (x_tl_tl.prod)⁻¹ = c,\n        generalize hb : (x_tl_hd)⁻¹ = b,\n        generalize ha : (x_hd)⁻¹ = a,\n        clear x_tl_ih x_tl_tl,\n        have ha1 : x_hd = a⁻¹,\n        {\n          rw ←ha,\n          rw inv_inv,\n        },\n        have hb1 : x_tl_hd = b⁻¹,\n        {\n          rw ←hb,\n          rw inv_inv,\n        },\n        rw ha1,\n        rw hb1,\n        clear ha1 hb1 ha hb x_tl_hd x_hd,\n        have : homo_locus_of (1, b⁻¹) = 1,\n        {\n          apply homo_locus_of_one,\n          exact homo_locus_closed_left_one b⁻¹,\n        },\n        rw this,\n        clear this,\n        rw mul_one,\n        rw ←inv_inj,\n        simp only [mul_inv_rev, inv_inv],\n        rw homo_locus_pres_comm,\n        rw homo_locus_assoc c b a,\n        rw homo_locus_of_inv_rev,\n        simp only [inv_inv],\n      },\n    },\n  },\nend\n\nend pq_group_homo_locus_pres_double_list\n\nsection pq_group_homo_locus_pres_iso_ker_counit\n\nvariables {G : Type u} [group G]\n\ndef homo_locus_pres_iso_ker_counit_forward : homo_locus_pres G →* (counit : pq_group G →* G).ker :=\nbegin\n  fapply lift_homo_locus_pres_morph,\n  {\n    intro g,\n    fconstructor,\n    exact of g.1 * of g.2 * (of (g.1 * g.2))⁻¹,\n    refine counit.mem_ker.mpr _,\n    simp only [counit_of, mul_inv_rev, monoid_hom.map_mul, monoid_hom.map_mul_inv],\n    group,\n  },\n  {\n    split,\n    {\n      intros a b,\n      cases a with a1 a2,\n      cases b with b1 b2,\n      simp only,\n      rw counit_ker_abelian,\n    },\n    split,\n    {\n      intros a b hab,\n      simp only,\n      ext1,\n      simp only [subgroup.coe_one, subgroup.coe_mk],\n      simp only [homo_locus_def] at hab,\n      rw hab,\n      simp only [mul_right_inv],\n    },\n    split,\n    {\n      intros a b x,\n      simp only,\n      ext1,\n      simp only [mul_inv_rev, subgroup.coe_inv, subgroup.coe_mul, inv_inv, subgroup.coe_mk],\n      suffices : of a * (of (x * a))⁻¹ * (of (x * a) * of b * (of (x * a * b))⁻¹) * of (x * (a * b)) * (of (a * b))⁻¹ = of a * of b * (of (a * b))⁻¹,\n      {\n        assoc_rw this,\n        clear this _inst,\n        assoc_rw counit_ker_abelian_counit (of a * of b * (of (a * b))⁻¹) _ _,\n        simp only [one_mul, mul_right_inv],\n        simp only [counit_of, mul_inv_rev, monoid_hom.map_mul, monoid_hom.map_mul_inv],\n        group,\n      },\n      group,\n    },\n    {\n      intros a b,\n      simp only,\n      ext1,\n      simp only [mul_inv_rev, subgroup.coe_inv, inv_inv, subgroup.coe_mk],\n      rw ←rhd_def_group,\n      rw ←rhd_of_eq_of_rhd,\n      rw rhd_def_group,\n      rw inv_of,\n      simp only [inv_inv],\n      group,\n    },\n  },\nend\n\nlemma homo_locus_pres_iso_ker_counit_forward_homo_locus_of (a b : G) : homo_locus_pres_iso_ker_counit_forward (homo_locus_of (a, b)) = ⟨of a * of b * (of (a * b))⁻¹, begin \n  refine counit.mem_ker.mpr _,\n  simp only [counit_of, mul_inv_rev, monoid_hom.map_mul, monoid_hom.map_mul_inv],\n  group,\nend⟩  :=\nbegin\n  refl,\nend\n\ntheorem homo_locus_pres_iso_ker_counit_forward_from_list (x : pre_homo_locus_pres G) : homo_locus_pres_iso_ker_counit_forward ⟦x⟧ = ⟨((counit_ker_decomp (pre_homo_locus_pres_to_list x)).map (λ (a : G × G), of a.1 * of a.2 * (of (a.1 * a.2))⁻¹)).prod, begin \n  apply counit_ker_decomp_comp_in_ker,\nend⟩ :=\nbegin\n  rw ←pre_homo_locus_pres_to_list_eq_id,\n  generalize : counit_ker_decomp (pre_homo_locus_pres_to_list x) = y,\n  clear x,\n  rw hom_list_prod,\n  ext1,\n  simp only [list.map_map, subgroup.coe_mk],\n  have coe_prod : ∀ x : list ((counit : pq_group G →* G).ker), (↑(x.prod) : pq_group G) = (x.map (λ x, ↑x)).prod,\n  {\n    intros x,\n    clear y,\n    induction x,\n    {\n      simp only [subgroup.coe_one, list.prod_nil, list.map],\n    },\n    {\n      simp only [mul_right_inj, subgroup.coe_mul, list.prod_cons, list.map],\n      exact x_ih,\n    },\n  },\n  rw coe_prod,\n  simp only [list.map_map],\n  refl,\nend\n\n/-\n\nvariables {H : Type u} [group H]\n\ndef counit_ker_data_induction (f : G × G → H) (hf : is_homo_locus_liftable f) : (counit : pq_group G →* G).ker →* H :=\nbegin\n  rcases hf with ⟨hf1, hf2, hf3, hf4, hf5⟩,\n  fconstructor,\n  {\n    intro x,\n    cases x with x hx,\n    clear hx,\n    induction x,\n    {\n      --rw quot_mk_helper at hx,\n      exact ((counit_ker_decomp (create_list_from_pq x)).map f).prod,\n    },\n    {\n      sorry,\n    },\n  },\n  {\n    sorry,\n  },\n  {\n    sorry,\n  },\nend\n\n-/\n\n/-\n\ndef homo_locus_pres_iso_ker_counit_backward_fun_aux_pre : G → list G → homo_locus_pres G\n| y (a :: x) := homo_locus_of (y, a) * homo_locus_pres_iso_ker_counit_backward_fun_aux_pre (y * a) x\n| y [] := 1\n   \ndef homo_locus_pres_iso_ker_counit_backward_fun_aux : list G → homo_locus_pres G := λ x, homo_locus_pres_iso_ker_counit_backward_fun_aux_pre 1 (x)\n\ndef homo_locus_pres_iso_ker_counit_backward_fun : (counit : pq_group G →* G).ker → homo_locus_pres G := \nbegin \n  fapply pq_group_list_data_property,\n  exact (λ ⟨x, hx⟩, homo_locus_pres_iso_ker_counit_backward_fun_aux x),\n  {\n    intros x y hx hy hxy,\n    \n    induction hxy,\n    induction hxy_r,\n    {\n      refl,\n    },\n    {\n      symmetry,\n      solve_by_elim\n    },\n    {\n      have hb : ⟦hxy_r_b⟧ ∈ has_coe_t_aux.coe counit.ker,\n      {\n        suffices : ⟦hxy_r_a⟧ = ⟦hxy_r_b⟧, \n        rw ←this,\n        exact hx,\n        apply quotient.sound,\n        fconstructor,\n        assumption,\n      },\n      transitivity,\n      apply hxy_r_ih_hab,\n      assumption,\n      solve_by_elim,\n    },\n    {\n      unfold create_list_from_pq,\n\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n    {\n      sorry,\n    },\n  },\nend\n\n-/\n\n/-\n\ndef homo_locus_pres_iso_ker_counit_backward : (counit : pq_group G →* G).ker →* homo_locus_pres G := { \n  to_fun := homo_locus_pres_iso_ker_counit_backward_fun,\n  map_one' := sorry,\n  map_mul' := sorry }\n\ntheorem homo_locus_pres_iso_ker_counit_forward_bijective : function.bijective (homo_locus_pres_iso_ker_counit_forward : homo_locus_pres G → (counit : pq_group G →* G).ker) :=\nbegin\n  split,\n  {\n    refine homo_locus_pres_iso_ker_counit_forward.injective_iff.mpr _,\n    intros a ha,\n    induction a,\n    {\n      rw homo_locus_pres_quot_mk_helper at *,\n      rw homo_locus_pres_iso_ker_counit_forward_from_list at ha,\n      injections_and_clear,\n      rename h_1 ha,\n      rw ←pre_homo_locus_pres_to_list_eq_id,\n      generalize hax : (pre_homo_locus_pres_to_list a) = x,\n      rw hax at ha,\n      clear hax a,\n      rename ha hx,\n      rw ←counit_ker_decomp_comp_alt at hx,\n\n    },\n    {refl,},\n  },\n  {\n    refine counit_ker_induction _ _,\n    {\n      intros a b,\n      use homo_locus_of (a, b),\n      refl,\n    },\n    {\n      intros a b ha hb,\n      cases ha with x hx,\n      cases hb with y hy,\n      use x * y,\n      simp only [monoid_hom.map_mul, hx, hy],\n    },\n  },\nend\n\n\ndef homo_locus_pres_iso_ker_counit : homo_locus_pres G ≃* (counit : pq_group G →* G).ker := { \n  to_fun := homo_locus_pres_iso_ker_counit_forward,\n  inv_fun := sorry,\n  left_inv := sorry,\n  right_inv := sorry,\n  map_mul' := begin \n    intros x y,\n    simp only [monoid_hom.map_mul],\n  end }\n\n-/\n\nend pq_group_homo_locus_pres_iso_ker_counit\n", "meta": {"author": "torstein-vik", "repo": "power-quandle-lean", "sha": "452437602c4be2e6c5ad5f5224b068baabfdf9e1", "save_path": "github-repos/lean/torstein-vik-power-quandle-lean", "path": "github-repos/lean/torstein-vik-power-quandle-lean/power-quandle-lean-452437602c4be2e6c5ad5f5224b068baabfdf9e1/src/pq_group_homo_locus_pres.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.48362560794339343}}
{"text": "import to_mathlib.analysis.normed_group\nimport to_mathlib.linear_algebra.basis\nimport to_mathlib.topology.algebra.order.basic\n\nimport loops.exists\n\nimport local.corrugation\nimport local.ample_relation\n\nimport interactive_expr\nset_option trace.filter_inst_type true\n\n/-!\n# Local h-principle for open and ample relations\n\nThis file proves lem:h_principle_open_ample_loc from the blueprint. This is the local\nversion of the h-principle for open and ample relations. The proof brings together the\nmain result `exist_loops` from the loop folder (Chapter 1 in the blueprint) and\nthe corrugation technique.\n\nOne formalization issue is that the whole construction carries around a lot of data.\nOn paper it is easy to state one lemma listing once all this data and proving many properties.\nHere it is more convenient to give each property its own lemma so carrying around data,\nassumptions and constructions requires some planning. Our way to mitigate this issue\nis to use two ad-hoc structures `landscape` and `step_landscape` which partly bundle\nall this.\n\nThe `landscape` structure record three sets in a vector space, a closed\nset `C` and two nested compact sets `K₀` and `K₁`. This is the ambiant data for\nthe local h-principle result. We call this partly bundled because it doesn't include\nthe data of the formal solution we want to improve. Instead we have a Prop-valued\nstructure `landscape.accepts` that takes a landscape and a formal solution and assert\nsome compatibility conditions. There are four conditions, which is already enough\nmotivation to introduce a structure instead of one definition using the logical\nconjunction operator that would lead to awkward and error prone access to the\nindividual conditions.\n\nThe proof of this proposition involves an induction on a flag of subspaces (nested\nsubspaces of increasing dimensions). For the purpose of this induction we use\na second structure `step_landscape` that extends `landscape` with two more pieces\nof data, a subspace and a dual pair, and a compatibility condition, namely the subspace\nhas to be in the hyperplane defined by the dual pair.\n\nIn this setup, given `(L : step_landscape E) {𝓕 : formal_sol R} (h : L.accepts R 𝓕)`,\nthe loop family constructed by Chapter 2 is `L.loop h`. Together with corrugation,\nit is used to build `L.improve_step h` which is the homotopy of 1-jet sections improving\nthe formal solution `𝓕` in that step of the main inductive proof. A rather long series of\nlemmas prove all the required properties of that homotopy, corresponding to\nlemma lem:integration_step from the blueprint.\n\nThe inductive proof itself is the proof of `rel_loc.formal_sol.improve`.\nHere all conclusions are stated at once this the induction requires to know about each\nof them to proceed to the next step. We could have introduced one more ad-hoc structure\nto record those conclusion but this isn't needed (at least in that Chapter) since we\nneed to access its components only once.\n\n-/\n\nnoncomputable theory\n\nopen_locale unit_interval classical filter topology\nopen filter set rel_loc linear_map (ker)\n\nvariables (E : Type*) [normed_add_comm_group E] [normed_space ℝ E]\n          {F : Type*} [normed_add_comm_group F] [normed_space ℝ F]\n          {G : Type*} [normed_add_comm_group G] [normed_space ℝ G]\n\n/--\nThe setup for local h-principle is two compact subsets `K₀ ⊆ K₁` in `E` with\n`K₀ ⊆ interior K₁` and a closed subset `C`.\n-/\nstructure landscape :=\n(C K₀ K₁ : set E)\n(hC : is_closed C)\n(hK₀ : is_compact K₀)\n(hK₁ : is_compact K₁)\n(h₀₁ : K₀ ⊆ interior K₁)\n\nsection improve_step\n/-!\n## Improvement step\n\nThis section proves lem:integration_step.\n-/\n\n/--\nThe setup for a one-step improvement towards a local h-principle is two compact subsets\n`K₀ ⊆ K₁` in `E` with `K₀ ⊆ interior K₁` and a closed subset `C`\ntogether with a dual pair `p` and a subspace `E'` of the corresponding hyperplane `ker p.π`.\n-/\nstructure step_landscape extends landscape E :=\n(E' : submodule ℝ E)\n(p : dual_pair E)\n(hEp : E' ≤ ker p.π)\n\nvariables {E}\n\nopen_locale classical\n\nvariables (R : rel_loc E F)\n\nnamespace step_landscape\n\n/-- A one-step improvement landscape accepts a formal solution if it can improve it. -/\nstructure accepts (L : step_landscape E) (𝓕 : jet_sec E F) : Prop :=\n(h_op : is_open R)\n(hK₀ : ∀ᶠ x near L.K₀, 𝓕.is_part_holonomic_at L.E' x)\n(h_short : ∀ x, 𝓕.is_short_at R L.p x)\n(hC : ∀ᶠ x near L.C, 𝓕.is_holonomic_at x)\n\n/-- The union of all slices of `R` corresponding to `𝓕`. -/\ndef Ω (L : step_landscape E) (𝓕 : jet_sec E F) : set (E × F) :=\n{p | p.2 ∈ 𝓕.slice_at R L.p p.1}\n--⋃ x, ({x} : set E) ×ˢ (connected_component_in (𝓕.slice_at R L.p x) $ 𝓕.φ x L.p.v)\n\n/-- The linear form in a `step_landscape`, coming from the underlying dual pair. -/\ndef π (L : step_landscape E) : E →L[ℝ] ℝ := L.p.π\n\n/-- The vector in a `step_landscape`, coming from the underlying dual pair. -/\ndef v (L : step_landscape E) : E := L.p.v\n\n/-- One more compact set in the landscape: K₁ ∩ C, needed as an input to the\nloop construction. -/\ndef K (L : step_landscape E) : set E := L.K₁ ∩ L.C\n\n/-- The base function for the loop family associated in any jet section in a\nstep landscape. -/\ndef b (L : step_landscape E) (𝓕 : jet_sec E F) : E → F := λ x, 𝓕.φ x L.v\n\n/-- The desired average for the loop family associated in any jet section in a\nstep landscape. -/\ndef g (L : step_landscape E) (𝓕 : jet_sec E F) : E → F := λ x, D 𝓕.f x L.v\n\nlemma is_compact_K (L : step_landscape E) : is_compact L.K :=\nL.hK₁.inter_right L.hC\n\nvariables {R}\n\nlemma accepts.open [finite_dimensional ℝ E]  {L : step_landscape E} {𝓕 : jet_sec E F} (h : L.accepts R 𝓕) :\n  is_open (L.Ω R 𝓕) :=\nbegin\n  set ψ : E × F → one_jet E F := λ p, (p.1, 𝓕.f p.1, L.p.update (𝓕.φ p.1) p.2),\n  change is_open {p : E × F | ψ p ∈ R},\n  apply is_open.preimage _ h.h_op,\n  apply continuous_fst.prod_mk (𝓕.f_diff.continuous.fst'.prod_mk _),\n  exact L.p.continuous_update 𝓕.φ_diff.continuous.fst' continuous_snd\nend\n\nlemma smooth_b (L : step_landscape E) (𝓕 : jet_sec E F) :\n  𝒞 ∞ (L.b 𝓕) :=\n(continuous_linear_map.apply ℝ F L.v).cont_diff.comp 𝓕.φ_diff\n\nlemma smooth_g (L : step_landscape E) (𝓕 : jet_sec E F) :\n  𝒞 ∞ (L.g 𝓕) :=\n(continuous_linear_map.apply ℝ F L.v).cont_diff.comp (cont_diff_top_iff_fderiv.mp 𝓕.f_diff).2\n\nlemma accepts.rel {L : step_landscape E} {𝓕 : jet_sec E F} (h : L.accepts R 𝓕) :\n  ∀ᶠ (x : E) near L.K, (L.g 𝓕) x = (L.b 𝓕) x :=\nbegin\n  apply (h.hC.filter_mono $ monotone_nhds_set (inter_subset_right L.K₁ L.C)).mono,\n  intros x hx,\n  dsimp [jet_sec.is_holonomic_at] at hx,\n  dsimp [step_landscape.g, step_landscape.b],\n  rw hx\nend\n\nvariables [finite_dimensional ℝ E]  [finite_dimensional ℝ F]\n\nopen_locale borelize\n\n/-- The loop family to use in some landscape to improve a formal solution. -/\ndef loop (L : step_landscape E) {𝓕 : formal_sol R} (h : L.accepts R 𝓕) :\nℝ → E → loop F :=\nclassical.some (exist_loops L.is_compact_K h.open (L.smooth_g 𝓕) (L.smooth_b 𝓕) h.rel h.h_short)\n\nlemma nice (L : step_landscape E) {𝓕 : formal_sol R} (h : L.accepts R 𝓕) :\n  nice_loop (L.g ↑𝓕) (L.b ↑𝓕) (Ω R L 𝓕) L.K (L.loop h) :=\nclassical.some_spec $ exist_loops L.is_compact_K h.open (L.smooth_g 𝓕) (L.smooth_b 𝓕) h.rel h.h_short\n\nlemma update_zero (L : step_landscape E) {𝓕 : formal_sol R} (h : L.accepts R 𝓕) (x : E) (s : ℝ) :\nL.p.update (𝓕.φ x) ((L.loop h 0 x) s) = 𝓕.φ x :=\nbegin\n  rw (L.nice h).t_zero x s,\n  exact L.p.update_self _,\nend\n\nlemma loop_smooth (L : step_landscape E) {𝓕 : formal_sol R} (h : L.accepts R 𝓕) :\n  𝒞 ∞ ↿(L.loop h) :=\n(L.nice h).smooth\n\nlemma loop_smooth' (L : step_landscape E) {𝓕 : formal_sol R} (h : L.accepts R 𝓕)\n  {t : G → ℝ} (ht : 𝒞 ∞ t) {s : G → ℝ} (hs : 𝒞 ∞ s) {x : G → E} (hx : 𝒞 ∞ x) :\n  𝒞 ∞ (λ g, L.loop h (t g) (x g) (s g)) :=\n(L.loop_smooth h).comp (ht.prod $ hx.prod hs)\n\nlemma loop_C1 (L : step_landscape E) {𝓕 : formal_sol R} (h : L.accepts R 𝓕) :\n∀ t, 𝒞 1 ↿(L.loop h t) :=\nλ t, (L.loop_smooth' h cont_diff_const cont_diff_snd cont_diff_fst).of_le le_top\n\nvariables (L : step_landscape E)\n\n/-- The cut-off function associated to a step landscape, equal to one near K₀ and\nzero outside K₁. -/\ndef ρ (L : step_landscape E) : E → ℝ :=\n(exists_cont_diff_one_nhds_of_interior L.hK₀.is_closed L.h₀₁).some\n\nlemma ρ_smooth (L : step_landscape E) : 𝒞 ∞ L.ρ :=\n(exists_cont_diff_one_nhds_of_interior L.hK₀.is_closed L.h₀₁).some_spec.1\n\nlemma ρ_mem (L : step_landscape E) (x : E) : L.ρ x ∈ I :=\n(exists_cont_diff_one_nhds_of_interior L.hK₀.is_closed L.h₀₁).some_spec.2.2.2 x\n\nlemma ρ_le (L : step_landscape E) (x : E) : |L.ρ x| ≤ 1 :=\nbegin\n  cases L.ρ_mem x with h h',\n  rw abs_le,\n  refine ⟨_, h'⟩,\n  linarith\nend\n\nlemma hρ₀ (L : step_landscape E) : ∀ᶠ x near L.K₀, L.ρ x = 1 :=\n(exists_cont_diff_one_nhds_of_interior L.hK₀.is_closed L.h₀₁).some_spec.2.1\n\nlemma hρ_compl_K₁ (L : step_landscape E) {x : E} : x ∉ L.K₁ → L.ρ x = 0 :=\n(exists_cont_diff_one_nhds_of_interior L.hK₀.is_closed L.h₀₁).some_spec.2.2.1 x\n\n/--\nHomotopy of formal solutions obtained by corrugation in the direction of `p : dual_pair E`\nin some landscape to improve a formal solution `𝓕` from being `L.E'`-holonomic to\n`L.E' ⊔ span {p.v}`-holonomic near `L.K₀`.\n-/\ndef improve_step {𝓕 : formal_sol R} (h : L.accepts R 𝓕) (N : ℝ) : htpy_jet_sec E F :=\n{ f := λ t x, 𝓕.f x + (smooth_step t*L.ρ x) • corrugation L.π N (L.loop h t) x,\n  f_diff :=  𝓕.f_diff.snd'.add $\n    (smooth_step.smooth.fst'.mul L.ρ_smooth.snd').smul $\n    corrugation.cont_diff' N (L.loop_smooth h) cont_diff_snd cont_diff_fst,\n  φ := λ t x, L.p.update (𝓕.φ x) (L.loop h (smooth_step t*L.ρ x) x $ N * L.π x) +\n                (smooth_step t*L.ρ x) • (corrugation.remainder L.p.π N (L.loop h 1) x),\n  φ_diff := begin\n    apply cont_diff.add,\n    apply L.p.smooth_update,\n    apply 𝓕.φ_diff.snd',\n    apply L.loop_smooth',\n    exact smooth_step.smooth.fst'.mul L.ρ_smooth.snd',\n    apply cont_diff_const.mul L.π.cont_diff.snd',\n    exact cont_diff_snd,\n    apply cont_diff.smul,\n    exact smooth_step.smooth.fst'.mul L.ρ_smooth.snd',\n    exact remainder.smooth _ _ (L.loop_smooth h) cont_diff_snd cont_diff_const\n  end }\n\nvariables {L} {𝓕 : formal_sol R} (h : L.accepts R 𝓕) (N : ℝ)\n\n@[simp]\nlemma improve_step_apply (t : ℝ) (x : E) :\n  L.improve_step h N t x = (𝓕.f x + (smooth_step t*L.ρ x) • corrugation L.π N (L.loop h t) x,\n  L.p.update (𝓕.φ x) (L.loop h (smooth_step t*L.ρ x) x $ N * L.π x) +\n                 (smooth_step t*L.ρ x) • (corrugation.remainder L.p.π N (L.loop h 1) x)) :=\nby { simp [improve_step, h], refl }\n\n@[simp]\nlemma improve_step_apply_f (t : ℝ) (x : E) :\n  (L.improve_step h N t).f x = 𝓕.f x + (smooth_step t*L.ρ x) • corrugation L.π N (L.loop h t) x :=\nrfl\n\n@[simp]\nlemma improve_step_apply_φ (t : ℝ) (x : E) :\n  (L.improve_step h N t).φ x = L.p.update (𝓕.φ x) (L.loop h (smooth_step t*L.ρ x) x $ N * L.π x) +\n                 (smooth_step t*L.ρ x) • (corrugation.remainder L.p.π N (L.loop h 1) x) :=\nrfl\n\nlemma improve_step_of_support (t : ℝ) {x : E}\n  (H : ∀ t, x ∉ loop.support (L.loop h t)) :\n  L.improve_step h N t x = 𝓕 x :=\nbegin\n  have : ∀ t s, L.loop h t x s = 𝓕.φ x L.v,\n      { intros t s,\n        rw loop.is_const_of_not_mem_support (H t) s 0,\n        apply (L.nice h).s_zero x t },\n  rw [improve_step_apply h, corrugation_eq_zero _ _ _ _ (H t),\n      remainder_eq_zero _ _ (L.loop_C1 h 1) (H 1)],\n  simp only [formal_sol.to_jet_sec_eq_coe, smul_zero, add_zero, this],\n  erw L.p.update_self,\n  refl\nend\n\nlemma improve_step_rel_t_eq_0 : L.improve_step h N 0 = 𝓕 :=\nbegin\n  ext x,\n  { rw improve_step_apply_f h,\n    simp [(L.nice h).t_zero x] },\n  { ext x,\n    rw improve_step_apply_φ h,\n    simp only [formal_sol.to_jet_sec_eq_coe, zero_mul, smooth_step.zero, zero_smul, add_zero],\n    erw L.update_zero h, refl }\nend\n\nlemma improve_step_rel_compl_K₁ {x} (hx : x ∉ L.K₁) (t) : L.improve_step h N t x = 𝓕 x :=\nbegin\n  rw [improve_step_apply h, L.hρ_compl_K₁ hx],\n  simp only [formal_sol.to_jet_sec_eq_coe, mul_zero, zero_smul, add_zero],\n  erw L.update_zero h,\n  refl\nend\n\nlemma improve_step_rel_K : ∀ᶠ x near L.K, ∀ t, L.improve_step h N t x = 𝓕 x :=\nbegin\n  have : ∀ᶠ x near L.K, ∀ t, x ∉ loop.support (L.loop h t),\n  { apply (L.nice h).rel_K.eventually_nhds_set.mono,\n    intros x hx t,\n    apply loop.not_mem_support,\n    apply hx.mono,\n    intros y hy,\n    exact loop.is_const_of_eq (hy t) },\n  apply this.mono,\n  intros x hx t,\n  exact improve_step_of_support _ _ _ hx\nend\n\nlemma improve_step_rel_C : ∀ᶠ x near L.C, ∀ t, L.improve_step h N t x = 𝓕 x :=\nbegin\n  apply eventually.filter_mono (L.hK₁.is_closed.nhds_set_le_sup' L.C),\n  rw eventually_sup,\n  split,\n  { apply improve_step_rel_K },\n  { rw eventually_principal,\n    exact λ x, improve_step_rel_compl_K₁ h N }\nend\n\n-- In the next lemma we reintroduce F to appaise the unused argument linter since\n-- `finite_dimensional ℝ F` isn't needed here.\n\nlemma bu_lt {F : Type*} [normed_add_comm_group F] [normed_space ℝ F]\n  (t : ℝ) (x : E) {v : F} {ε : ℝ} (hv : ‖v‖ < ε) :\n  ‖(smooth_step t * L.ρ x) • v‖ < ε :=\ncalc ‖(smooth_step t * L.ρ x) • v‖ = |smooth_step t| * |L.ρ x| * ‖v‖ : by\n             rw [norm_smul, real.norm_eq_abs, abs_mul]\n... ≤ ‖v‖ : mul_le_of_le_one_left (norm_nonneg _) (mul_le_one (smooth_step.abs_le t)\n                                                          (abs_nonneg _) (L.ρ_le x))\n... < ε : hv\n\nlemma improve_step_c0_close {ε : ℝ} (ε_pos : 0 < ε) :\n  ∀ᶠ N in at_top, ∀ x t, ‖(L.improve_step h N t).f x - 𝓕.f x‖ ≤ ε :=\nbegin\n  set γ := L.loop h,\n  have γ_cont : continuous ↿(λ t x, γ t x) := (L.nice h).smooth.continuous,\n  have γ_C1 : 𝒞 1 ↿(γ 1) := ((L.nice h).smooth.comp (cont_diff_prod_mk_right 1)).of_le le_top,\n  apply ((corrugation.c0_small_on L.hK₁ (L.nice h).t_le_zero (L.nice h).t_ge_one γ_cont ε_pos).and $\n        remainder_c0_small_on L.π L.hK₁ γ_C1 ε_pos).mono,\n  rintros N ⟨H, H'⟩ x t,\n  by_cases hx : x ∈ L.K₁,\n  { rw [improve_step_apply_f h],\n    suffices : ‖(smooth_step t * L.ρ x) • corrugation L.π N (L.loop h t) x‖ ≤ ε, by simpa,\n    exact (bu_lt _ _ $ H _ hx t).le },\n  { rw show (L.improve_step h N t).f x = 𝓕.f x, from congr_arg prod.fst (improve_step_rel_compl_K₁ h N hx t),\n    simp [ε_pos.le] }\nend\n\nlemma improve_step_part_hol {N : ℝ} (hN : N ≠ 0) :\n  ∀ᶠ x near L.K₀, (L.improve_step h N 1).is_part_holonomic_at (L.E' ⊔ L.p.span_v) x :=\nbegin\n  have γ_C1 : 𝒞 1 ↿(L.loop h 1) := ((L.nice h).smooth.comp (cont_diff_prod_mk_right 1)).of_le le_top,\n  let 𝓕' : jet_sec E F :=\n  { f := λ x, 𝓕.f x + corrugation L.π N (L.loop h 1) x,\n    f_diff := 𝓕.f_diff.add\n     (corrugation.cont_diff' _ (L.loop_smooth h) cont_diff_id cont_diff_const),\n    φ := λ x , L.p.update (𝓕.φ x) (L.loop h 1 x $ N * L.π x) +\n               corrugation.remainder L.p.π N (L.loop h 1) x,\n    φ_diff := begin\n      apply cont_diff.add,\n      apply L.p.smooth_update,\n      apply 𝓕.φ_diff,\n      apply L.loop_smooth',\n      apply cont_diff_const,\n      apply cont_diff_const.mul L.π.cont_diff,\n      exact cont_diff_id,\n      exact remainder.smooth _ _ (L.loop_smooth h) cont_diff_id cont_diff_const\n    end },\n  have H : ∀ᶠ x near L.K₀, L.improve_step h N 1 x = 𝓕' x,\n  { apply L.hρ₀.mono,\n    intros x hx,\n    simp [improve_step_apply h, hx],\n    refl },\n  have fderiv_𝓕' := λ x, fderiv_corrugated_map N hN γ_C1 (𝓕.f_diff.of_le le_top) L.p ((L.nice h).avg x),\n  rw eventually_congr (H.is_part_holonomic_at_congr (L.E' ⊔ L.p.span_v)),\n  apply h.hK₀.mono,\n  intros x hx,\n  apply jet_sec.is_part_holonomic_at.sup,\n  { intros u hu,\n    have hu_ker := L.hEp hu,\n    dsimp [𝓕'],\n    erw [fderiv_𝓕', continuous_linear_map.add_apply, L.p.update_ker_pi _ _ hu_ker,\n         L.p.update_ker_pi _ _ hu_ker, hx u hu] },\n  { intros u hu,\n    rcases submodule.mem_span_singleton.mp hu with ⟨l, rfl⟩,\n    rw [(D 𝓕'.f x).map_smul, (𝓕'.φ x).map_smul],\n    apply congr_arg,\n    dsimp [𝓕'],\n    erw [fderiv_𝓕', L.p.update_v, continuous_linear_map.add_apply, L.p.update_v],\n    refl }\nend\n\nlemma improve_step_formal_sol :\n  ∀ᶠ N in at_top, ∀ t, (L.improve_step h N t).is_formal_sol R :=\nbegin\n  set γ := L.loop h,\n  have γ_cont : continuous ↿(λ t x, γ t x) := (L.nice h).smooth.continuous,\n    have γ_C1 : 𝒞 1 ↿(γ 1) := ((L.nice h).smooth.comp (cont_diff_prod_mk_right 1)).of_le le_top,\n  set K := (λ p : E × ℝ × ℝ, (p.1, 𝓕.f p.1, L.p.update (𝓕.φ p.1) (L.loop h p.2.1 p.1 p.2.2))) '' (L.K₁ ×ˢ (I ×ˢ I)),\n  have K_cpt : is_compact K,\n  { refine (L.hK₁.prod (is_compact_Icc.prod is_compact_Icc)).image _,\n    refine continuous_fst.prod_mk (𝓕.f_diff.continuous.fst'.prod_mk _ ),\n    apply L.p.continuous_update 𝓕.φ_diff.continuous.fst',\n    change continuous (↿(L.loop h) ∘ (λ (g : E × ℝ × ℝ), (g.snd.fst, g.fst, g.snd.snd))),\n    exact (L.loop_smooth h).continuous.comp₃ continuous_snd.fst continuous_fst continuous_snd.snd },\n  have K_sub : K ⊆ R,\n  { rintros _ ⟨⟨x, t, s⟩, ⟨x_in, t_in, s_in⟩, rfl⟩,\n    exact (L.nice h).mem_Ω x t s },\n  obtain ⟨ε, ε_pos, hε⟩ : ∃ ε, 0 < ε ∧ metric.thickening ε K ⊆ R,\n    from  K_cpt.exists_thickening_subset_open h.h_op K_sub,\n\n  apply ((corrugation.c0_small_on L.hK₁ (L.nice h).t_le_zero (L.nice h).t_ge_one γ_cont ε_pos).and $\n         remainder_c0_small_on L.π L.hK₁ γ_C1 ε_pos).mono,\n  rintros N ⟨H, H'⟩ t x,\n  by_cases hxK₁ : x ∈ L.K₁,\n  { apply hε,\n    rw metric.mem_thickening_iff,\n    refine ⟨(x, 𝓕.f x, L.p.update (𝓕.φ x) $ L.loop h (smooth_step t*L.ρ x) x $ N * L.π x), _, _⟩,\n    { simp only [hxK₁, formal_sol.to_jet_sec_eq_coe, exists_prop, mem_set_of_eq, eq_self_iff_true, true_and, K],\n      exact ⟨⟨x, smooth_step t * L.ρ x, int.fract (N * L.π x)⟩,\n            ⟨hxK₁, unit_interval.mul_mem (smooth_step.mem t) (L.ρ_mem x),\n              unit_interval.fract_mem _⟩, by simp only [loop.fract_eq]⟩ },\n    { simp only [h, improve_step_apply_f, formal_sol.to_jet_sec_eq_coe, improve_step_apply_φ],\n      rw [prod.dist_eq, max_lt_iff, prod.dist_eq, max_lt_iff],\n      refine ⟨by simpa using ε_pos, _, _⟩ ; dsimp only ; rw dist_self_add_left,\n      { exact (bu_lt _ _ $ H _ hxK₁ _) },\n      { exact (bu_lt _ _ $ H' _ hxK₁) } } },\n  { rw [show ((L.improve_step h N) t).f x = 𝓕.f x,\n          from congr_arg prod.fst $ improve_step_rel_compl_K₁ h N hxK₁ t,\n        show ((L.improve_step h N) t).φ x = 𝓕.φ x,\n          from congr_arg prod.snd $ improve_step_rel_compl_K₁ h N hxK₁ t],\n    exact 𝓕.is_sol _ }\nend\n\nend step_landscape\n\nend improve_step\n\nsection improve\n/-!\n## Full improvement\n\nThis section proves lem:h_principle_open_ample_loc.\n-/\n\nopen finite_dimensional submodule step_landscape\n\nvariables {E} [finite_dimensional ℝ E] [finite_dimensional ℝ F]\n  {R : rel_loc E F} (h_op : is_open R) (h_ample : R.is_ample)\nvariables (L : landscape E)\nvariables {ε : ℝ} (ε_pos : 0 < ε)\n\ninclude h_op h_ample ε_pos\n\n/--\nHomotopy of formal solutions obtained by successive corrugations in some landscape `L` to improve a\nformal solution `𝓕` until it becomes holonomic near `L.K₀`.\n-/\nlemma rel_loc.formal_sol.improve (𝓕 : formal_sol R)\n  (h_hol : ∀ᶠ x near L.C, 𝓕.is_holonomic_at x) :\n  ∃ H : htpy_jet_sec E F,\n    (∀ᶠ t near Iic 0, H t = 𝓕) ∧\n    (∀ᶠ t near Ici 1, H t = H 1) ∧\n    (∀ᶠ x near L.C, ∀ t, H t x = 𝓕 x ) ∧\n    (∀ x, x ∉ L.K₁ → ∀ t, H t x = 𝓕 x) ∧\n    (∀ x t, ‖(H t).f x - 𝓕.f x‖ ≤ ε) ∧\n    (∀ t, (H t).is_formal_sol R) ∧\n    (∀ᶠ x near L.K₀, (H 1).is_holonomic_at x) :=\nbegin\n  let n := finrank ℝ E,\n  let e := fin_basis ℝ E,\n  let E' := e.flag,\n  suffices : ∀ k : fin (n + 1), ∀ δ > (0 : ℝ), ∃ H : htpy_jet_sec E F,\n    (∀ᶠ t near Iic 0, H t = 𝓕) ∧\n    (∀ᶠ t near Ici 1, H t = H 1) ∧\n    (∀ᶠ x near L.C, ∀ t, H t x = 𝓕 x ) ∧\n    (∀ x, x ∉ L.K₁ → ∀ t, H t x = 𝓕 x) ∧\n    (∀ x t, ‖(H t).f x - 𝓕.f x‖ ≤ δ) ∧\n    (∀ t, (H t).is_formal_sol R) ∧\n    (∀ᶠ x near L.K₀, (H 1).is_part_holonomic_at (E' k) x),\n  { simpa only [show E' (fin.last n) = ⊤, from e.flag_last, jet_sec.is_part_holonomic_top] using\n      this (fin.last n) ε ε_pos },\n  clear ε_pos ε,\n  intro k,\n  apply fin.induction_on k ; clear k,\n  { intros δ δ_pos,\n    use 𝓕.to_jet_sec.const_htpy,\n    simp [show E' 0 = ⊥, from e.flag_zero, le_of_lt δ_pos] },\n  { rintros k HH δ δ_pos,\n    rcases HH (δ/2) (half_pos δ_pos) with ⟨H, hH₀, hH₁, hHC, hHK₁, hHc0, hH_sol, hH_hol⟩, clear HH,\n    let S : step_landscape E :=\n    { E' := E' k,\n      p := e.dual_pair k,\n      hEp := by simpa only [E', basis.dual_pair] using e.flag_le_ker_dual k,\n      ..L},\n    set H₁ : formal_sol R := (hH_sol 1).formal_sol,\n    have h_span : S.E' ⊔ S.p.span_v = E' k.succ := e.flag_span_succ k,\n    have acc : S.accepts R H₁ :=\n    { h_op := h_op,\n      hK₀ := begin\n        apply hH_hol.mono,\n        intros x hx,\n        dsimp [S],\n        convert hx,\n        rw [← fin.coe_eq_cast_succ, coe_coe]\n      end,\n      h_short := λ x, h_ample.is_short_at H₁ S.p x,\n      hC := begin\n        apply h_hol.congr (formal_sol.is_holonomic_at_congr _ _ _),\n        apply hHC.mono,\n        tauto,\n      end  },\n    have hH₁_rel_C : ∀ᶠ (x : E) near S.C, H₁ x = 𝓕 x,\n    { apply hHC.mono,\n      intros x hx,\n      apply hx },\n    have hH₁_C : ∀ᶠ (x : E) near S.to_landscape.C, H₁.is_holonomic_at x,\n    { apply h_hol.congr (formal_sol.is_holonomic_at_congr _ _ _),\n      exact (h_hol.and hH₁_rel_C).mono (λ x hx, hx.2.symm) },\n    have hH₁_K₁ : ∀ x ∉ L.K₁, H₁ x = 𝓕 x,\n    { intros x hx,\n      apply hHK₁ x hx },\n    obtain ⟨N, ⟨hN_close, hN_sol⟩, hNneq⟩ :=\n      (((improve_step_c0_close acc $ half_pos δ_pos).and\n      (improve_step_formal_sol acc)).and $ eventually_ne_at_top (0 :ℝ)).exists,\n    have glue : H 1 = S.improve_step acc N 0,\n    { rw improve_step_rel_t_eq_0,\n      refl  },\n    refine ⟨H.comp (S.improve_step acc N) glue, _, _, _, _, _, _, _⟩,\n    { apply (H.comp_le_0 _ _).mono,\n      intros t ht,\n      rw ht,\n      exact hH₀.on_set 0 right_mem_Iic }, -- t = 0\n    { apply (H.comp_ge_1 _ _).mono,\n      intros t ht,\n      rw [ht, H.comp_1] },\n    { -- rel C\n      apply (hHC.and $ hH₁_rel_C.and $ improve_step_rel_C acc N).mono,\n      rintros x ⟨hx, hx', hx''⟩ t,\n      by_cases ht : t ≤ 1/2,\n      { simp only [ht, hx, htpy_jet_sec.comp_of_le]},\n      { simp only [ht, hx', hx'', htpy_jet_sec.comp_of_not_le, not_false_iff]} },\n    { -- rel K₁\n      intros x hx t,\n      by_cases ht : t ≤ 1/2,\n      { simp only [ht, hx, hHK₁, htpy_jet_sec.comp_of_le, not_false_iff]},\n      { simp only [ht, hx, hH₁_K₁, improve_step_rel_compl_K₁, htpy_jet_sec.comp_of_not_le,\n                   not_false_iff] } },\n    { -- C⁰-close\n      intros x t,\n      by_cases ht : t ≤ 1/2,\n      { apply le_trans _ (half_le_self $ le_of_lt δ_pos),\n        simp only [ht, hHc0, htpy_jet_sec.comp_of_le]},\n      { simp only [ht, htpy_jet_sec.comp_of_not_le, not_false_iff],\n        rw ← add_halves δ,\n        exact norm_sub_le_add_of_le (hN_close _ _) (hHc0 _ _) } },\n    { -- formal solution\n      intros t,\n      by_cases ht : t ≤ 1/2,\n      { simp only [ht, hH_sol, htpy_jet_sec.comp_of_le]},\n      { simp only [ht, hN_sol, htpy_jet_sec.comp_of_not_le, not_false_iff] } },\n    {  -- part-hol E' (k + 1)\n      rw [← h_span, htpy_jet_sec.comp_1],\n      apply improve_step_part_hol acc hNneq } }\nend\n\n/-- A repackaging of `rel_loc.formal_sol.improve` for convenience. -/\nlemma rel_loc.formal_sol.improve_htpy' (𝓕 : formal_sol R)\n  (h_hol : ∀ᶠ x near L.C, 𝓕.is_holonomic_at x) :\n  ∃ H : htpy_formal_sol R,\n    (∀ᶠ t near Iic 0, H t = 𝓕) ∧\n    (∀ᶠ t near Ici 1, H t = H 1) ∧\n    (∀ᶠ x near L.C, ∀ t, H t x = 𝓕 x ) ∧\n    (∀ x, x ∉ L.K₁ → ∀ t, H t x = 𝓕 x) ∧\n    (∀ x t, ‖(H t).f x - 𝓕.f x‖ < ε)  ∧\n    (∀ᶠ x near L.K₀, (H 1).is_holonomic_at x) :=\nbegin\n  rcases 𝓕.improve h_op h_ample L (half_pos ε_pos) h_hol with ⟨H, h₁, h₂, h₃, h₄, h₅, h₆, h₇⟩,\n  exact ⟨{is_sol := h₆, ..H}, h₁, h₂, h₃, h₄, λ x t, (h₅ x t).trans_lt (half_lt_self ε_pos), h₇⟩\nend\n\n\nend improve\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/local/h_principle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.48362560794339343}}
{"text": "/-\nCopyright (c) 2021-2022 Julien Marquet. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Julien Marquet\n-/\n\nimport Lean.Elab.Tactic.Basic\n\nimport Flows.Groundwork\n\nopen Lean Parser.Tactic Elab Elab.Tactic Meta\n\n-- From mathlib4\nnamespace Lean.Expr\n/-- If the expression is a constant, return that name. Otherwise return `Name.anonymous`. -/\ndef constName (e : Expr) : Name :=\ne.constName?.getD Name.anonymous\n\n/-- Return the function (name) and arguments of an application. -/\ndef getAppFnArgs (e : Expr) : Name × Array Expr :=\n  Expr.withApp e λ e a => (e.constName, a)\n\nend Lean.Expr\n-- End of copied block\n\nnamespace Tactic.SolveSet\n\nsection Lemmas\n\nvariable {α : Type u}\n\ndef general_union (l : List (Fintype α)) : Fintype α := List.foldl HasUnion.union ∅ l\n\ntheorem in_singleton (a : Fintype α) : a ⊆ general_union [a] :=\n  Fintype.included_union_l _ Fintype.included_refl\n\ntheorem included_of_included_l (a b c : Fintype α) (h : a ⊆ b) : a ⊆ b ∪ c := sorry\ntheorem included_of_included_r (a b c : Fintype α) (h : a ⊆ c) : a ⊆ b ∪ c := sorry\n\ntheorem union_included (a b c : Fintype α) (h : a ⊆ c) (h' : b ⊆ c) : a ∪ b ⊆ c := sorry\n\nend Lemmas\n\nstructure Cache :=\n  α : Expr\n  univ : Level\n\nstructure State :=\n  atoms : Array Expr := #[]\n  numAtoms : Nat := 0\n\ninductive SetExpr : Type :=\n  | void\n  | atom (i : Nat)\n  | union (l : SetExpr) (r : SetExpr)\n\ninstance : Inhabited SetExpr := Inhabited.mk (SetExpr.void)\n\nabbrev SolveM := ReaderT Cache <| StateRefT State MetaM\n\ndef SolveM.run (ty : Expr) (m : SolveM α) : MetaM α := do\n  let Level.succ u _ ← getLevel ty | throwError \"fail\"\n  (m {α := ty, univ := u }).run' {}\n\ndef mkApp (f : Name) (args : Array Expr) : SolveM Expr := do\n  let c ← read\n  pure $ mkAppN (mkConst f [c.univ]) (#[c.α] ++ args)\n\ndef addAtom (e : Expr) : SolveM Nat := do\n  let c ← get\n  for i in [:c.numAtoms] do\n    if ← isDefEq e c.atoms[i] then\n      return i\n  modify λ c => { c with atoms := c.atoms.push e, numAtoms := c.numAtoms + 1 }\n  return c.numAtoms\n\ndef getAtomIndex (e : Expr) : SolveM Nat := do\n  let c ← get\n  for i in [:c.numAtoms] do\n    if ← isDefEq e c.atoms[i] then\n      return i\n  throwError \"Atom not found -- this is a bug\"\n\ndef isAtom (e : Expr) : SolveM Bool := do\n  let c ← get\n  for i in [:c.numAtoms] do\n    if ← isDefEq e c.atoms[i] then\n      return true\n  return false\n\ndef getAtom (i : Nat) : SolveM Expr := do\n  let c ← get\n  return c.atoms[i]\n\n-- Assumes l and r are ordered according to their first coordinate\npartial def concat_map_assocs (l r : List (Nat × Expr)) (f g : Nat → Expr → SolveM Expr) :\n  SolveM (List (Nat × Expr)) := go l r [] >>= pure ∘ List.reverse\n  where go l r acc :\n    SolveM (List (Nat × Expr)) := match (l, r) with\n    | ([], []) => pure acc\n    | ([], (j, eᵣ) :: r') => do go [] r' <| (j, ← g j eᵣ) :: acc\n    | ((i, eₗ) :: l', []) => do go l' [] <| (i, ← f i eₗ) :: acc\n    | ((i, eₗ) :: l', (j, eᵣ) :: r') =>\n      if i < j then do go l' r <| (i, ← f i eₗ) :: acc\n      else if i == j then do go l' r' <| (i, ← f i eₗ) :: acc\n      else do go l r' <| (j, ← g j eᵣ) :: acc\n\npartial def atomize (e : Expr) : SolveM (List (Nat × Expr)) :=\n  match e.getAppFnArgs with\n  | (``EmptyCollection.emptyCollection, #[_, _]) => pure []\n  | (``HasUnion.union, #[_, _, eₗ, eᵣ]) => do\n    let ml ← atomize eₗ\n    let mr ← atomize eᵣ\n    let process_l i included : SolveM Expr := do\n        let a ← getAtom i\n        mkApp ``included_of_included_l #[a, eₗ, eᵣ, included]\n    let process_r j included : SolveM Expr := do\n        let a ← getAtom j\n        mkApp ``included_of_included_r #[a, eₗ, eᵣ, included]\n    return (← concat_map_assocs ml mr process_l process_r)\n  | _ => do\n    let i ← addAtom e\n    return [(i, ← mkApp ``Fintype.included_refl #[e])]\n\npartial def prove_included (atomics : Array Expr) (l r : Expr) : SolveM Expr :=\n  go l r\n  where go l r : SolveM Expr := match l.getAppFnArgs with\n    | (``EmptyCollection.emptyCollection, #[_, _]) =>\n      mkApp ``Fintype.empty_included #[r]\n    | (``HasUnion.union, #[_, _, eₗ, eᵣ]) => do\n      let pₗ ← go eₗ r\n      let pᵣ ← go eᵣ r\n      mkApp ``union_included #[eₗ, eᵣ, r, pₗ, pᵣ]\n    | _ => do\n      let i ← getAtomIndex l\n      pure atomics[i]\n\npartial def check_atoms (e : Expr) : SolveM Bool :=\n  match e.getAppFnArgs with\n  | (``EmptyCollection.emptyCollection, #[_, _]) => pure true\n  | (``HasUnion.union, #[_, _, eₗ, eᵣ]) => do\n    return (← check_atoms eₗ) && (← check_atoms eᵣ)\n  | _ => isAtom e\n\ndef solve_sets (l r : Expr) : SolveM Expr := do\n  let atoms := Array.mk\n    <| List.map (λ x => x.2)\n    <| ← atomize r\n  if !(← check_atoms l) then\n    throwError \"Some atomic formulas on the left aren't included in the right\"\n  let p ← prove_included atoms l r\n  return p\n\nelab \"solve_sets \" : tactic => liftMetaMAtMain λ g => do\n  match (← instantiateMVars (← getMVarDecl g).type).getAppFnArgs with\n  | (``HasIncluded.included, #[ty, _, l, r]) =>\n    let ty ← match ty.getAppFnArgs with\n    | (``Fintype, #[a]) => pure a\n    | _ => throwError \"Expected Fintype\"\n    let p ← (solve_sets l r).run ty\n    assignExprMVar g p\n  | _ => throwError \"solve_sets failed, expected an inclusion\"\n\nset_option trace.Elab.debug true in\ndef ex₁ (a b c : Fintype α) : ∅ ∪ b ∪ a ⊆ a ∪ ∅ ∪ b := by solve_sets\n\nend Tactic.SolveSet\n", "meta": {"author": "thejohncrafter", "repo": "flows", "sha": "f4732e6784aa6ea13b07dc042be2c3816a73fa84", "save_path": "github-repos/lean/thejohncrafter-flows", "path": "github-repos/lean/thejohncrafter-flows/flows-f4732e6784aa6ea13b07dc042be2c3816a73fa84/Flows/SolveSets.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.48362560087849127}}
{"text": "lemma eq_zero_of_add_right_eq_self {a b : mynat} : a + b = a → b = 0 :=\nbegin\nintro h,\napply add_left_cancel a,\nrw add_zero,\nexact h,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world08/level08.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.483625597584243}}
{"text": "/-\nCopyright (c) 2015 Joe Hendrix. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joe Hendrix, Sebastian Ullrich\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.vector2\nimport Mathlib.data.nat.basic\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# Basic operations on bitvectors\n\nThis is a work-in-progress, and contains additions to other theories.\n\nThis file was moved to mathlib from core Lean in the switch to Lean 3.20.0c. It is not fully in compliance with mathlib style standards.\n-/\n\n/-- `bitvec n` is a `vector` of `bool` with length `n`. -/\ndef bitvec (n : ℕ) := vector Bool n\n\nnamespace bitvec\n\n\n/-- Create a zero bitvector -/\nprotected def zero (n : ℕ) : bitvec n := vector.repeat false n\n\n/-- Create a bitvector of length `n` whose `n-1`st entry is 1 and other entries are 0. -/\nprotected def one (n : ℕ) : bitvec n := sorry\n\n/-- Create a bitvector from another with a provably equal length. -/\nprotected def cong {a : ℕ} {b : ℕ} (h : a = b) : bitvec a → bitvec b := sorry\n\n/-- `bitvec` specific version of `vector.append` -/\ndef append {m : ℕ} {n : ℕ} : bitvec m → bitvec n → bitvec (m + n) := vector.append\n\n/-! ### Shift operations -/\n\n/-- `shl x i` is the bitvector obtained by left-shifting `x` `i` times and padding with `ff`.\nIf `x.length < i` then this will return the all-`ff`s bitvector. -/\ndef shl {n : ℕ} (x : bitvec n) (i : ℕ) : bitvec n :=\n  bitvec.cong sorry (vector.append (vector.drop i x) (vector.repeat false (min n i)))\n\n/-- `fill_shr x i fill` is the bitvector obtained by right-shifting `x` `i` times and then\npadding with `fill : bool`. If `x.length < i` then this will return the constant `fill`\nbitvector. -/\ndef fill_shr {n : ℕ} (x : bitvec n) (i : ℕ) (fill : Bool) : bitvec n :=\n  bitvec.cong sorry (vector.append (vector.repeat fill (min n i)) (vector.take (n - i) x))\n\n/-- unsigned shift right -/\ndef ushr {n : ℕ} (x : bitvec n) (i : ℕ) : bitvec n := fill_shr x i false\n\n/-- signed shift right -/\ndef sshr {m : ℕ} : bitvec m → ℕ → bitvec m := sorry\n\n/-! ### Bitwise operations -/\n\n/-- bitwise not -/\n/-- bitwise and -/\ndef not {n : ℕ} : bitvec n → bitvec n := vector.map bnot\n\n/-- bitwise or -/\ndef and {n : ℕ} : bitvec n → bitvec n → bitvec n := vector.map₂ band\n\n/-- bitwise xor -/\ndef or {n : ℕ} : bitvec n → bitvec n → bitvec n := vector.map₂ bor\n\ndef xor {n : ℕ} : bitvec n → bitvec n → bitvec n := vector.map₂ bxor\n\n/-! ### Arithmetic operators -/\n\n/-- `xor3 x y c` is `((x XOR y) XOR c)`. -/\n/-- `carry x y c` is `x && y || x && c || y && c`. -/\nprotected def xor3 (x : Bool) (y : Bool) (c : Bool) : Bool := bxor (bxor x y) c\n\nprotected def carry (x : Bool) (y : Bool) (c : Bool) : Bool := x && y || x && c || y && c\n\n/-- `neg x` is the two's complement of `x`. -/\nprotected def neg {n : ℕ} (x : bitvec n) : bitvec n :=\n  let f : Bool → Bool → Bool × Bool := fun (y c : Bool) => (y || c, bxor y c);\n  prod.snd (vector.map_accumr f x false)\n\n/-- Add with carry (no overflow) -/\ndef adc {n : ℕ} (x : bitvec n) (y : bitvec n) (c : Bool) : bitvec (n + 1) :=\n  let f : Bool → Bool → Bool → Bool × Bool :=\n    fun (x y c : Bool) => (bitvec.carry x y c, bitvec.xor3 x y c);\n  sorry\n\n/-- The sum of two bitvectors -/\nprotected def add {n : ℕ} (x : bitvec n) (y : bitvec n) : bitvec n := vector.tail (adc x y false)\n\n/-- Subtract with borrow -/\ndef sbb {n : ℕ} (x : bitvec n) (y : bitvec n) (b : Bool) : Bool × bitvec n :=\n  let f : Bool → Bool → Bool → Bool × Bool :=\n    fun (x y c : Bool) => (bitvec.carry (!x) y c, bitvec.xor3 x y c);\n  vector.map_accumr₂ f x y b\n\n/-- The difference of two bitvectors -/\nprotected def sub {n : ℕ} (x : bitvec n) (y : bitvec n) : bitvec n := prod.snd (sbb x y false)\n\nprotected instance has_zero {n : ℕ} : HasZero (bitvec n) := { zero := bitvec.zero n }\n\nprotected instance has_one {n : ℕ} : HasOne (bitvec n) := { one := bitvec.one n }\n\nprotected instance has_add {n : ℕ} : Add (bitvec n) := { add := bitvec.add }\n\nprotected instance has_sub {n : ℕ} : Sub (bitvec n) := { sub := bitvec.sub }\n\nprotected instance has_neg {n : ℕ} : Neg (bitvec n) := { neg := bitvec.neg }\n\n/-- The product of two bitvectors -/\nprotected def mul {n : ℕ} (x : bitvec n) (y : bitvec n) : bitvec n :=\n  let f : bitvec n → Bool → bitvec n := fun (r : bitvec n) (b : Bool) => cond b (r + r + y) (r + r);\n  list.foldl f 0 (vector.to_list x)\n\nprotected instance has_mul {n : ℕ} : Mul (bitvec n) := { mul := bitvec.mul }\n\n/-! ### Comparison operators -/\n\n/-- `uborrow x y` returns `tt` iff the \"subtract with borrow\" operation on `x`, `y` and `ff`\nrequired a borrow. -/\ndef uborrow {n : ℕ} (x : bitvec n) (y : bitvec n) : Bool := prod.fst (sbb x y false)\n\n/-- unsigned less-than proposition -/\n/-- unsigned greater-than proposition -/\ndef ult {n : ℕ} (x : bitvec n) (y : bitvec n) := ↥(uborrow x y)\n\ndef ugt {n : ℕ} (x : bitvec n) (y : bitvec n) := ult y x\n\n/-- unsigned less-than-or-equal-to proposition -/\n/-- unsigned greater-than-or-equal-to proposition -/\ndef ule {n : ℕ} (x : bitvec n) (y : bitvec n) := ¬ult y x\n\ndef uge {n : ℕ} (x : bitvec n) (y : bitvec n) := ule y x\n\n/-- `sborrow x y` returns `tt` iff `x < y` as two's complement integers -/\ndef sborrow {n : ℕ} : bitvec n → bitvec n → Bool := sorry\n\n/-- signed less-than proposition -/\n/-- signed greater-than proposition -/\ndef slt {n : ℕ} (x : bitvec n) (y : bitvec n) := ↥(sborrow x y)\n\n/-- signed less-than-or-equal-to proposition -/\ndef sgt {n : ℕ} (x : bitvec n) (y : bitvec n) := slt y x\n\n/-- signed greater-than-or-equal-to proposition -/\ndef sle {n : ℕ} (x : bitvec n) (y : bitvec n) := ¬slt y x\n\ndef sge {n : ℕ} (x : bitvec n) (y : bitvec n) := sle y x\n\n/-! ### Conversion to `nat` and `int` -/\n\n/-- Create a bitvector from a `nat` -/\nprotected def of_nat (n : ℕ) : ℕ → bitvec n := sorry\n\n/-- Create a bitvector in the two's complement representation from an `int` -/\nprotected def of_int (n : ℕ) : ℤ → bitvec (Nat.succ n) := sorry\n\n/-- `add_lsb r b` is `r + r + 1` if `b` is `tt` and `r + r` otherwise. -/\ndef add_lsb (r : ℕ) (b : Bool) : ℕ := r + r + cond b 1 0\n\n/-- Given a `list` of `bool`s, return the `nat` they represent as a list of binary digits. -/\ndef bits_to_nat (v : List Bool) : ℕ := list.foldl add_lsb 0 v\n\n/-- Return the natural number encoded by the input bitvector -/\nprotected def to_nat {n : ℕ} (v : bitvec n) : ℕ := bits_to_nat (vector.to_list v)\n\ntheorem bits_to_nat_to_list {n : ℕ} (x : bitvec n) :\n    bitvec.to_nat x = bits_to_nat (vector.to_list x) :=\n  rfl\n\n-- mul_left_comm\n\ntheorem to_nat_append {m : ℕ} (xs : bitvec m) (b : Bool) :\n    bitvec.to_nat (vector.append xs (b::ᵥvector.nil)) =\n        bitvec.to_nat xs * bit0 1 + bitvec.to_nat (b::ᵥvector.nil) :=\n  sorry\n\ntheorem bits_to_nat_to_bool (n : ℕ) :\n    bitvec.to_nat (to_bool (n % bit0 1 = 1)::ᵥvector.nil) = n % bit0 1 :=\n  sorry\n\ntheorem of_nat_succ {k : ℕ} {n : ℕ} :\n    bitvec.of_nat (Nat.succ k) n =\n        vector.append (bitvec.of_nat k (n / bit0 1)) (to_bool (n % bit0 1 = 1)::ᵥvector.nil) :=\n  rfl\n\ntheorem to_nat_of_nat {k : ℕ} {n : ℕ} : bitvec.to_nat (bitvec.of_nat k n) = n % bit0 1 ^ k := sorry\n\n/-- Return the integer encoded by the input bitvector -/\nprotected def to_int {n : ℕ} : bitvec n → ℤ := sorry\n\n/-! ### Miscellaneous instances -/\n\nprotected instance has_repr (n : ℕ) : has_repr (bitvec n) := has_repr.mk repr\n\nend bitvec\n\n\nprotected instance bitvec.ult.decidable {n : ℕ} {x : bitvec n} {y : bitvec n} :\n    Decidable (bitvec.ult x y) :=\n  bool.decidable_eq (bitvec.uborrow x y) tt\n\nprotected instance bitvec.ugt.decidable {n : ℕ} {x : bitvec n} {y : bitvec n} :\n    Decidable (bitvec.ugt x y) :=\n  bool.decidable_eq (bitvec.uborrow y x) tt\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/bitvec/core_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837527911057, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4835984557360052}}
{"text": "import combinatorics.simple_graph.metric\nimport graph_theory.path\n\nnamespace simple_graph\nnamespace cayley\n\nstructure genset (G : Type*) [group G] :=\n  (els : finset G)\n  (sym : ∀ {s : G}, s ∈ els → s⁻¹ ∈ els)\n  (gen : subgroup.closure (coe els) = (⊤ : subgroup G))\n  (nem : els.nonempty)\n  (irr : (1:G) ∉ els)\n\nvariables {G : Type*} [group G] {S S1 S2 : genset G} {a x y z : G}\n\ninstance : has_mem G (genset G) := ⟨λ a s, a ∈ s.els⟩\n\ndef genset.adj (S : genset G) (x y : G) := x⁻¹ * y ∈ S\n\nlemma shift_adj ⦃x y⦄ (h : S.adj x y) : S.adj (a*x) (a*y) :=\nby { unfold genset.adj, convert h using 1, group }\n\n@[symm] lemma adj_symm ⦃x y⦄ (h : S.adj x y) : S.adj y x\n:= by { unfold genset.adj, convert S.sym h, group }\n\ndef Cay (S : genset G) : simple_graph G :=\n{ adj := S.adj,\n  symm := adj_symm,\n  loopless := λ x h, S.irr (by { convert h, group }) }\n\ndef left_shift (a : G) : Cay S →g Cay S := ⟨(*) a, shift_adj⟩\n\nlemma shift : reachable (Cay S) x y → reachable (Cay S) (a*x) (a*y) :=\nnonempty.map (walk.map (left_shift a))\n\nlemma inv {h : reachable (Cay S) 1 x} : reachable (Cay S) 1 x⁻¹ :=\nby { symmetry, convert @shift _ _ _ x⁻¹ _ _ h; group }\n\nlemma reachable_mp : reachable (Cay S) 1 x :=\nbegin\n  apply subgroup.closure_induction,\n  { rw S.gen, trivial },\n  { intros y h, apply reachable.step, simpa only [Cay,genset.adj,one_inv,one_mul] },\n  { refl },\n  { intros u v h1 h2, refine reachable.trans h1 _, convert shift h2, group },\n  { intros y h, apply inv, exact h }\nend\n\ntheorem Cay.connected : connected (Cay S) :=\n⟨λ x y, reachable_mp.symm.trans reachable_mp, ⟨1⟩⟩\n\nlemma covariant : (Cay S).dist (a*x) (a*y) = (Cay S).dist x y :=\nbegin\n  have lem : ∀ a {x y}, (Cay S).dist (a*x) (a*y) ≤ (Cay S).dist x y :=\n  by { intros a x y, obtain ⟨p,hp⟩ := Cay.connected.exists_walk_of_dist x y,\n    rw [←hp,←walk.length_map], exact dist_le (p.map (left_shift a)) },\n  apply le_antisymm (lem a), convert lem a⁻¹, group\nend\n\nnoncomputable def distorsion (S1 S2 : genset G) :=\nclassical.some (finset.max_of_nonempty (S1.nem.image ((Cay S2).dist 1)))\n\nlemma distorsion_spec : distorsion S1 S2 ∈ (finset.image ((Cay S2).dist 1) S1.els).max :=\nclassical.some_spec (finset.max_of_nonempty (S1.nem.image ((Cay S2).dist 1)))\n\nlemma distorsion_le {h : (Cay S1).adj x y} : (Cay S2).dist x y ≤ distorsion S1 S2 :=\nbegin\n  refine finset.le_max_of_mem _ distorsion_spec,\n  rw [finset.mem_image], refine ⟨x⁻¹ * y, h, _⟩, convert covariant, group\nend\n\nlemma lipschitz : (Cay S2).dist x y <= (distorsion S1 S2) * (Cay S1).dist x y :=\nbegin\n  obtain ⟨p,hp⟩ := (@Cay.connected _ _ S1).exists_walk_of_dist x y, rw <-hp, clear hp,\n  induction p with u u v w h p ih,\n  { simp only [dist_self, walk.length_nil, mul_zero] },\n  { simp only [walk.length_cons], transitivity (Cay S2).dist u v + (Cay S2).dist v w,\n    apply Cay.connected.dist_triangle, rw [mul_add,mul_one,add_comm],\n    apply add_le_add ih, apply distorsion_le, exact h }\nend\n\nend cayley\nend simple_graph\n", "meta": {"author": "vbeffara", "repo": "lean", "sha": "0004b1d502ac3f4ccd213dbd23589d4c4f9fece8", "save_path": "github-repos/lean/vbeffara-lean", "path": "github-repos/lean/vbeffara-lean/lean-0004b1d502ac3f4ccd213dbd23589d4c4f9fece8/src/graph_theory/cayley.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006919925839875, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.48356338333093896}}
{"text": "import Mathlib.Data.List.Perm\nimport WaterSortPuzzle.Utils\n\nnamespace WaterSortPuzzle\n\n/-!\n# 水排序拼图的问题定义\n-/\n\n/-!\n## 定义：颜色\n-/\n\nabbrev Color (m : Nat) := Fin m\n\n/-!\n## 定义：试管\n-/\n\nstructure Tube (m h : Nat) where\n  val : List (Color m)\n  h_volume : val.length ≤ h\n\nnamespace Tube\n\nvariable (t : Tube m h)\n\ndef length : Nat := t.val.length\n\ndef sameColorAux : List (Color m) → Prop\n| [] => True\n| [_] => true\n| c₁ :: c₂ :: cs => c₁ = c₂ ∧ sameColorAux (c₂ :: cs)\n\ndef sameColor : Prop := sameColorAux t.val\n\ndef isEmpty : Prop := t.val = []\n\ninstance : Decidable t.isEmpty := \n  if h : t.val = [] then isTrue h else isFalse h\n\ndef isFull : Prop := t.length = h\n\ninstance : Decidable t.isFull := \n  if h' : t.length = h then isTrue h' else isFalse h'\n\ndef topColor (h : ¬t.isEmpty) : Color m := \n  match h' : t.val with\n  | [] => absurd h' h\n  | c :: cs => c\n\ndef topColor? : Option (Color m) :=\n  if h : t.isEmpty then none else topColor t h\n\ndef empty : Tube m h := ⟨ [], by simp ⟩ \n\ndef fullSameColor (i : Fin m) : Tube m h := ⟨ List.replicate h i, by simp ⟩ \n\nend Tube\n\n/-!\n## 定义：试管组\n\n关键类型：\n\n- `ColorPerm`: 试管颜色打乱的命题。\n- `ColorComplete`: 试管颜色完备的命题。\n- `Tubes`: 试管组\n-/\n\n/--\n实际上是二维列表的打乱，因而在符号上选择 `~²`\n-/\ndef colorPerm (ts₁ ts₂ : List (Tube m h)) : Prop :=\n  let f₁ := ts₁.map Tube.val |>.join\n  let f₂ := ts₂.map Tube.val |>.join\n  f₁ ~ f₂\n\ninfixl:50 \" ~² \" => colorPerm\n\ntheorem colorPerm.mod_h :\n  ∀ {ts₁ ts₂ : List (Tube m h)} {i : Fin m}, ts₁ ~² ts₂ →\n    let f₁ := ts₁.map Tube.val |>.join ;\n    let f₂ := ts₂.map Tube.val |>.join ;\n    (f₁.count i) % h = (f₂.count i) % h := by\n  intro ts₁ ts₂ i h\n  simp_all [List.join, List.count, List.countp, colorPerm]\n\n/--\n试管颜色是否完备。有三种不同情况：\n\n- 空列表 是完备的\n- 完备列表 加上 装满同一种颜色的试管 是完备的\n- 完备列表 打乱颜色顺序是完备的\n-/\ninductive ColorComplete : List (Tube m h) → Prop\n| nil : ColorComplete []\n| cons : ColorComplete ts → ColorComplete ((.fullSameColor i)::ts)\n| perm : ColorComplete ts → ts ~² ts' → ColorComplete ts'\n\ntheorem ColorComplete.mod_h : ∀ {ts : List (Tube m h)}, ColorComplete ts → \n  let f := ts.map Tube.val |>.join ;\n  ∀ i : Fin m, (f.count i) % h = 0 := by\n    intro ts colorComplete_ts\n    simp\n    induction colorComplete_ts <;> simp [List.count_join]\n    . intro i\n      exact Nat.zero_mod h\n    . rename_i a b c d\n      intro i\n      sorry\n    . sorry\n\n\nstructure Tubes (m h n : Nat) where\n  val : List (Tube m h)\n  h_num : val.length = n\n  h_colorComplete : ColorComplete val\n\nnamespace Tubes\n\nvariable (ts : Tubes m h n)\n\ndef length := ts.val.length\n\ninstance : Membership (Tube m h) (Tubes m h n) where\n  mem t ts := t ∈ ts.val\n\ndef sorted : Prop :=\n  ∀ t, t ∈ ts → t.sameColor ∧ t.isFull\n\ndef get (m : Fin n) :=\n  have m : Fin ts.val.length := by\n    rw [ts.h_num]\n    assumption\n  ts.val.get m\n\ndef set (i : Fin n) (t : Tube m h) (hc : ColorComplete (ts.val.set i t)) : Tubes m h n :=\n  { \n    val := ts.val.set i t\n    h_num := by\n      rw [List.length_set ts.val i t, ts.h_num]\n    h_colorComplete := hc\n  }\n\nend Tubes\n\n/-!\n## 定义：倾倒过程\n-/\n\n/-- 描述倾倒过程 -/\nstructure PourStep (n : Nat) where\n  source : Fin n\n  sink : Fin n\n\n/-- 进行一次倾倒 -/\ndef PourStep.pour (ts : Tubes m h n) (s : PourStep n) : Tubes m h n :=\n  let t₁ := ts.get s.source\n  let t₂ := ts.get s.sink\n  let (t₁', t₂') := match t₁, t₂ with\n  | ⟨[], _⟩ , _ => (t₁, t₂)\n  | ⟨c::cs, h₁⟩ , ⟨[], h₂⟩ => \n    -- 一些定理证明\n    have hc : (c::cs).length > 0  := cs.length_cons_gt_zero c\n    have hgt : h > 0              := Nat.lt_of_lt_of_le hc h₁\n    have hge : h ≥ 1              := Nat.ge_one_of_gt_zero hgt\n    have hlt : cs.length < h      := Nat.lt_of_lt_of_le (cs.length_cons_lt c) h₁\n    have hle : cs.length ≤ h      := Nat.le_of_lt hlt\n    have hle' : [c].length ≤ h    := hge\n    (⟨cs, hle⟩, ⟨[c], hle'⟩)\n  | ⟨c₁::cs₁, h₁⟩, ⟨c₂::cs₂, h₂⟩ =>\n    if c₁ = c₂ then\n      if h' : (c₂::cs₂).length + 1 ≤ h then\n        -- 一些定理证明\n        have hlt : cs₁.length < h             := Nat.lt_of_lt_of_le (cs₁.length_cons_lt c₁) h₁\n        have hle : cs₁.length ≤ h             := Nat.le_of_lt hlt\n        have hle' : (c₁::c₂::cs₂).length ≤ h  := by simp only [List.length_cons c₁ (c₂::cs₂), h']\n        (⟨cs₁, hle⟩, ⟨c₁::c₂::cs₂, hle'⟩)\n      else \n        (⟨c₁::cs₁, h₁⟩, ⟨c₂::cs₂, h₂⟩)\n    else \n      (⟨c₁::cs₁, h₁⟩, ⟨c₂::cs₂, h₂⟩)\n  ts\n  |>.set s.source t₁' (by sorry)\n  |>.set s.sink t₂' sorry\n  \n/-- 进行一系列倾倒过程 -/\ndef Tubes.apply (ts : Tubes m h n) (ss : List (PourStep n)) : Tubes m h n :=\n  ss.foldl (λ acc s => s.pour acc) ts\n\n/-!\n## 定义：水排序问题\n\n关键类型：\n\n- `Puzzle`: 问题的定义，包括 初始状态及约束、空试管数量 等配置。\n- `Solution`: 问题的解，包含一系列步骤，以及正确性证明。\n\n目标即为寻找到一个函数具有 `(p : Puzzle m h n) → Solution p` 的类型。\n-/\n\n/-- 问题定义 -/\nstructure Puzzle (m h n : Nat) where\n  /-- 初始状态 -/\n  initial : Tubes m h n\n  /-- 空试管的数量 -/\n  k : Nat := 0\n  /-- 初始状态要求所有试管为满的 -/\n  h_full : ∀ t, t ∈ initial → t.isFull\n\n/-- 问题解的定义 -/\nstructure Solution (p : Puzzle m h n) where\n  /-- 一系列解的步骤 -/\n  steps : List (PourStep n)\n  /-- 正确性证明 -/\n  h_sorted : (p.initial.apply steps).sorted\n\nend WaterSortPuzzle\n", "meta": {"author": "xubaiw", "repo": "WaterSortPuzzle.lean", "sha": "aab60303198cd6db9e6a1e46e1b1eedf9cb8bc5a", "save_path": "github-repos/lean/xubaiw-WaterSortPuzzle.lean", "path": "github-repos/lean/xubaiw-WaterSortPuzzle.lean/WaterSortPuzzle.lean-aab60303198cd6db9e6a1e46e1b1eedf9cb8bc5a/WaterSortPuzzle/Defs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.483531061671867}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.data.nat.basic\n\nuniverses l \n\nnamespace Mathlib\n\ndef is_valid_char (n : ℕ) :=\n  n <\n      bit0\n        (bit0\n          (bit0\n            (bit0\n              (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit1 (bit1 (bit0 (bit1 1)))))))))))))) ∨\n    bit1\n          (bit1\n            (bit1\n              (bit1\n                (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit0 (bit1 1)))))))))))))) <\n        n ∧\n      n <\n        bit0\n          (bit0\n            (bit0\n              (bit0\n                (bit0\n                  (bit0\n                    (bit0\n                      (bit0\n                        (bit0\n                          (bit0\n                            (bit0\n                              (bit0\n                                (bit0 (bit0 (bit0 (bit0 (bit1 (bit0 (bit0 (bit0 1)))))))))))))))))))\n\ntheorem is_valid_char_range_1 (n : ℕ)\n    (h :\n      n <\n        bit0\n          (bit0\n            (bit0\n              (bit0\n                (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit1 (bit1 (bit0 (bit1 1))))))))))))))) :\n    is_valid_char n :=\n  Or.inl h\n\ntheorem is_valid_char_range_2 (n : ℕ)\n    (h₁ :\n      bit1\n          (bit1\n            (bit1\n              (bit1\n                (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit0 (bit1 1)))))))))))))) <\n        n)\n    (h₂ :\n      n <\n        bit0\n          (bit0\n            (bit0\n              (bit0\n                (bit0\n                  (bit0\n                    (bit0\n                      (bit0\n                        (bit0\n                          (bit0\n                            (bit0\n                              (bit0\n                                (bit0\n                                  (bit0 (bit0 (bit0 (bit1 (bit0 (bit0 (bit0 1)))))))))))))))))))) :\n    is_valid_char n :=\n  Or.inr { left := h₁, right := h₂ }\n\n/-- The `char` type represents an unicode scalar value.\n    See http://www.unicode.org/glossary/#unicode_scalar_value). -/\nstructure char where\n  val : ℕ\n  valid : is_valid_char val\n\nprotected instance char.has_sizeof : SizeOf char := { sizeOf := fun (c : char) => char.val c }\n\nnamespace char\n\n\nprotected def lt (a : char) (b : char) := val a < val b\n\nprotected def le (a : char) (b : char) := val a ≤ val b\n\nprotected instance has_lt : HasLess char := { Less := char.lt }\n\nprotected instance has_le : HasLessEq char := { LessEq := char.le }\n\nprotected instance decidable_lt (a : char) (b : char) : Decidable (a < b) :=\n  nat.decidable_lt (val a) (val b)\n\nprotected instance decidable_le (a : char) (b : char) : Decidable (a ≤ b) :=\n  nat.decidable_le (val a) (val b)\n\n/-\nWe cannot use tactics dec_trivial or comp_val here because the tactic framework has not been defined yet.\nWe also do not use `zero_lt_succ _` as a proof term because this proof may not be trivial to check by\nexternal type checkers. See discussion at: https://github.com/leanprover/tc/issues/8\n-/\n\ntheorem zero_lt_d800 :\n    0 <\n        bit0\n          (bit0\n            (bit0\n              (bit0\n                (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit1 (bit1 (bit0 (bit1 1)))))))))))))) :=\n  sorry\n\ndef of_nat (n : ℕ) : char :=\n  dite (is_valid_char n) (fun (h : is_valid_char n) => mk n h)\n    fun (h : ¬is_valid_char n) => mk 0 sorry\n\ndef to_nat (c : char) : ℕ := val c\n\ntheorem eq_of_veq {c : char} {d : char} : val c = val d → c = d := sorry\n\ntheorem veq_of_eq {c : char} {d : char} : c = d → val c = val d := sorry\n\ntheorem ne_of_vne {c : char} {d : char} (h : val c ≠ val d) : c ≠ d :=\n  fun (h' : c = d) => absurd (veq_of_eq h') h\n\ntheorem vne_of_ne {c : char} {d : char} (h : c ≠ d) : val c ≠ val d :=\n  fun (h' : val c = val d) => absurd (eq_of_veq h') h\n\nend char\n\n\nprotected instance char.decidable_eq : DecidableEq char :=\n  fun (i j : char) =>\n    decidable_of_decidable_of_iff (nat.decidable_eq (char.val i) (char.val j)) sorry\n\nprotected instance char.inhabited : Inhabited char :=\n  { default := char.of_nat (bit1 (bit0 (bit0 (bit0 (bit0 (bit0 1)))))) }\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/data/char/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631541, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.48349212318759227}}
{"text": "/-\n  Stalk of rings.\n\n  https://stacks.math.columbia.edu/tag/007L\n  (just says that the category of rings is a type of algebraic structure)\n-/\n\nimport topology.basic\nimport sheaves.stalk\nimport sheaves.presheaf_of_rings\n\nuniverses u v w\n\nopen topological_space\n\nsection stalk_of_rings\n\nvariables {α : Type u} [topological_space α] \nvariables (F : presheaf_of_rings α) (x : α)\n\ndefinition stalk_of_rings := stalk F.to_presheaf x\n\nend stalk_of_rings\n\n-- Stalks are rings.\n\nsection stalk_of_rings_is_ring\n\nparameters {α : Type u} [topological_space α] \nparameters (F : presheaf_of_rings α) (x : α)\n\n-- Add.\n\nprivate def stalk_of_rings_add_aux : \nstalk.elem F.to_presheaf x → \nstalk.elem F.to_presheaf x → \nstalk F.to_presheaf x :=\nλ s t, \n⟦{U := s.U ∩ t.U, \nHxU := ⟨s.HxU, t.HxU⟩, \ns := F.res s.U _ (set.inter_subset_left _ _) s.s + \n     F.res t.U _ (set.inter_subset_right _ _) t.s}⟧\n\ninstance stalk_of_rings_has_add : has_add (stalk_of_rings F x) := \n{ add := quotient.lift₂ (stalk_of_rings_add_aux) $\n  begin\n    intros a1 a2 b1 b2 H1 H2, \n    let F' := F.to_presheaf,\n    rcases H1 with ⟨U1, ⟨HxU1, ⟨HU1a1U, HU1b1U, HresU1⟩⟩⟩,\n    rcases H2 with ⟨U2, ⟨HxU2, ⟨HU2a2U, HU2b2U, HresU2⟩⟩⟩,\n    apply quotient.sound,\n    use [U1 ∩ U2, ⟨HxU1, HxU2⟩],\n    use [set.inter_subset_inter HU1a1U HU2a2U, set.inter_subset_inter HU1b1U HU2b2U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    have HresU1' : \n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res b1.U U1 HU1b1U) (b1.s)))\n    := by rw HresU1,\n    have HresU2' :\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw ←(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw ←(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw ←(presheaf.Hcomp' F') },\n    rw [HresU1', HresU2'],\n  end }\n\ninstance stalk_of_rings_add_semigroup : add_semigroup (stalk_of_rings F x) :=\n{ add := stalk_of_rings_has_add.add,\n  add_assoc := \n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W) \n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩],\n    use [set.subset.refl _, HUVWsub],\n    dsimp,\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw ←presheaf.Hcomp' },\n    rw add_assoc,\n  end }\n\ninstance stalk_of_rings_add_comm_semigroup : add_comm_semigroup (stalk_of_rings F x) :=\n{ add_comm := \n  begin\n    intros a b,\n    refine quotient.induction_on₂ a b _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩,\n    apply quotient.sound,\n    have HUVUV : U ∩ V ⊆ U ∩ V := λ x HxUV, HxUV,\n    have HUVVU : U ∩ V ⊆ V ∩ U := λ x ⟨HxU, HxV⟩, ⟨HxV, HxU⟩,\n    use [U ∩ V, ⟨HxU, HxV⟩, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    rw add_comm,\n  end,\n  ..stalk_of_rings_add_semigroup }\n\n-- Zero.\n\nprivate def stalk_of_rings_zero : stalk_of_rings F x := \n⟦{U := opens.univ, HxU := trivial, s:= 0}⟧\n\ninstance stalk_of_rings_has_zero : has_zero (stalk_of_rings F x) := \n{ zero := stalk_of_rings_zero }\n\ninstance stalk_of_rings_add_comm_monoid : add_comm_monoid (stalk_of_rings F x) :=\n{ zero := stalk_of_rings_zero,\n  zero_add := \n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ opens.univ ∩ U := λ x HxU, ⟨trivial, HxU⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw zero_add,\n    refl,\n  end,\n  add_zero := \n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ U ∩ opens.univ := λ x HxU, ⟨HxU, trivial⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw ←presheaf.Hcomp' },\n    dsimp,\n    erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw add_zero,\n    refl,\n  end,\n  ..stalk_of_rings_add_comm_semigroup }\n\n-- Neg.\n\nprivate def stalk_sub_aux : \nstalk.elem F.to_presheaf x → \nstalk F.to_presheaf x :=\nλ s, ⟦{U := s.U, HxU := s.HxU, s := -s.s}⟧\n\ninstance stalk_of_rings_has_neg : has_neg (stalk_of_rings F x) :=\n{ neg := quotient.lift stalk_sub_aux $ \n  begin\n    intros a b H,\n    rcases H with ⟨U, ⟨HxU, ⟨HUaU, HUbU, HresU⟩⟩⟩,\n    apply quotient.sound,\n    use [U, HxU, HUaU, HUbU],\n    repeat { rw @is_ring_hom.map_neg _ _ _ _ _ (F.res_is_ring_hom _ _ _) },\n    rw HresU,\n  end }\n\ninstance stalk_of_rings_add_comm_group : add_comm_group (stalk_of_rings F x) :=\n{ neg := stalk_of_rings_has_neg.neg,\n  add_left_neg := \n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUUU : U ⊆ U ∩ U := λ x HxU, ⟨HxU, HxU⟩,\n    have HUuniv : U ⊆ opens.univ := λ x HxU, trivial,\n    use [U, HxU, HUUU, HUuniv],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    erw (is_ring_hom.map_neg ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw add_left_neg,\n    erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n  end,\n  ..stalk_of_rings_add_comm_monoid }\n\n-- Mul.\n\nprivate def stalk_of_rings_mul_aux : \nstalk.elem F.to_presheaf x → \nstalk.elem F.to_presheaf x → \nstalk F.to_presheaf x :=\nλ s t, \n⟦{U := s.U ∩ t.U, \nHxU := ⟨s.HxU, t.HxU⟩, \ns := F.res s.U _ (set.inter_subset_left _ _) s.s * \n     F.res t.U _ (set.inter_subset_right _ _) t.s}⟧\n\ninstance stalk_of_rings_has_mul : has_mul (stalk_of_rings F x) := \n{ mul := quotient.lift₂ (stalk_of_rings_mul_aux) $ \n  begin\n    intros a1 a2 b1 b2 H1 H2, \n    let F' := F.to_presheaf,\n    rcases H1 with ⟨U1, ⟨HxU1, ⟨HU1a1U, HU1b1U, HresU1⟩⟩⟩,\n    rcases H2 with ⟨U2, ⟨HxU2, ⟨HU2a2U, HU2b2U, HresU2⟩⟩⟩,\n    apply quotient.sound,\n    use [U1 ∩ U2, ⟨HxU1, HxU2⟩],\n    use [set.inter_subset_inter HU1a1U HU2a2U, set.inter_subset_inter HU1b1U HU2b2U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    have HresU1' : \n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res b1.U U1 HU1b1U) (b1.s)))\n    := by rw HresU1,\n    have HresU2' :\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw ←(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw ←(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw ←(presheaf.Hcomp' F') },\n    rw [HresU1', HresU2'],\n  end }\n\ninstance stalk_of_rings_mul_semigroup : semigroup (stalk_of_rings F x) :=\n{ mul := stalk_of_rings_has_mul.mul,\n  mul_assoc :=\n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W) \n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩],\n    use [set.subset.refl _, HUVWsub],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    rw mul_assoc,\n  end }\n\ninstance stalk_of_rings_mul_comm_semigroup : comm_semigroup (stalk_of_rings F x) :=\n{ mul_comm := \n  begin\n    intros a b,\n    refine quotient.induction_on₂ a b _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩,\n    apply quotient.sound,\n    have HUVUV : U ∩ V ⊆ U ∩ V := λ x HxUV, HxUV,\n    have HUVVU : U ∩ V ⊆ V ∩ U := λ x ⟨HxU, HxV⟩, ⟨HxV, HxU⟩,\n    use [U ∩ V, ⟨HxU, HxV⟩, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    rw mul_comm,\n  end,\n  ..stalk_of_rings_mul_semigroup }\n\n-- One.\n\nprivate def stalk_of_rings_one : stalk_of_rings F x := \n⟦{U := opens.univ, HxU := trivial, s:= 1}⟧\n\ninstance stalk_of_rings_has_one : has_one (stalk_of_rings F x) := \n{ one := stalk_of_rings_one }\n\ninstance stalk_of_rings_mul_comm_monoid : comm_monoid (stalk_of_rings F x) :=\n{ one := stalk_of_rings_one,\n  one_mul := \n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ opens.univ ∩ U := λ x HxU, ⟨trivial, HxU⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    erw (is_ring_hom.map_one ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw one_mul,\n    refl,\n  end,\n  mul_one := \n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ U ∩ opens.univ := λ x HxU, ⟨HxU, trivial⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    dsimp, \n    erw (is_ring_hom.map_one ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw mul_one,\n    refl,\n  end,\n  ..stalk_of_rings_mul_comm_semigroup }\n\n-- Ring.\n\ninstance stalk_of_rings_is_comm_ring : comm_ring (stalk_of_rings F x) := \n{ left_distrib := \n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W) \n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩,\n    have HUVWsub2 : U ∩ V ∩ W ⊆ U ∩ V ∩ (U ∩ W)\n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨⟨HxU, HxV⟩, ⟨HxU, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩, HUVWsub, HUVWsub2],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    rw mul_add,\n  end,\n  right_distrib := \n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWrfl : U ∩ V ∩ W ⊆ U ∩ V ∩ W := λ x Hx, Hx,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ W ∩ (V ∩ W)\n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨⟨HxU, HxW⟩, ⟨HxV, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩, HUVWrfl, HUVWsub],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    rw add_mul,\n  end,\n  ..stalk_of_rings_add_comm_group,\n  ..stalk_of_rings_mul_comm_monoid }\n\nend stalk_of_rings_is_ring\n\n-- Stalks are colimits.\n\nsection stalk_colimit\n\nvariables {α : Type u} [topological_space α] \nvariables (F : presheaf_of_rings α) (x : α)\n\nvariables (S : Type w) [comm_ring S] [decidable_eq S]\nvariables (G : Π U, F.F U → S) [HG : Π U, is_ring_hom (G U)]\nvariables (hg : ∀ U V (H : U ⊆ V) r, G U (F.res V U H r) = G V r)\n\ndef to_stalk (U : opens α) (HxU : x ∈ U) (s : F.F U) : stalk_of_rings F x \n:= ⟦{U := U, HxU := HxU, s := s}⟧\n\nlemma to_stalk.is_ring_hom (U) (HxU) : is_ring_hom (to_stalk F x U HxU) :=\n{ map_one := quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, trivial,\n    begin\n        erw (F.res_is_ring_hom _ _ _).map_one, \n        erw (F.res_is_ring_hom _ _ _).map_one,\n    end⟩,\n  map_add := λ y z, quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, ⟨Hx, Hx⟩,\n    begin\n        erw ←(F.res_is_ring_hom _ _ _).map_add,\n        erw presheaf.Hcomp',\n    end⟩, \n  map_mul := λ y z, quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, ⟨Hx, Hx⟩,\n    begin\n        erw ←(F.res_is_ring_hom _ _ _).map_mul,\n        erw presheaf.Hcomp',\n    end⟩ }\n\ninclude hg\n\nprotected def to_stalk.rec (y : stalk_of_rings F x) : S :=\nquotient.lift_on' y (λ Us, G Us.1 Us.3) \n(λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩ ⟨W, HxW, HWU, HWV, Hres⟩,\nby dsimp; rw [←hg W U HWU s, ←hg W V HWV t, Hres])\n\n\ntheorem to_stalk.rec_to_stalk (U HxU) \n: (to_stalk.rec F x S G hg) ∘ (to_stalk F x U HxU) = G U := rfl\n\ninclude HG\n\nlemma to_stalk.rec_is_ring_hom : is_ring_hom (to_stalk.rec F x S G hg) :=\n{ map_one := (HG opens.univ).map_one ▸ rfl,\n  map_add := λ y z, quotient.induction_on₂' y z $ λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩,\n    begin\n        show G (U ∩ V) (_ + _) = G _ _ + G _ _,\n        rw (HG (U ∩ V)).map_add,\n        rw ←hg (U ∩ V) U (set.inter_subset_left _ _),\n        rw ←hg (U ∩ V) V (set.inter_subset_right _ _),\n    end,\n  map_mul := λ y z, quotient.induction_on₂' y z $ λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩,\n    begin\n        show G (U ∩ V) (_ * _) = G _ _ * G _ _,\n        rw (HG (U ∩ V)).map_mul,\n        rw ←hg (U ∩ V) U (set.inter_subset_left _ _),\n        rw ←hg (U ∩ V) V (set.inter_subset_right _ _),\n    end }\n\nend stalk_colimit\n", "meta": {"author": "ramonfmir", "repo": "lean-scheme", "sha": "6d3ec18fecfd174b79d0ce5c85a783f326dd50f6", "save_path": "github-repos/lean/ramonfmir-lean-scheme", "path": "github-repos/lean/ramonfmir-lean-scheme/lean-scheme-6d3ec18fecfd174b79d0ce5c85a783f326dd50f6/src/sheaves/stalk_of_rings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.795658090372256, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4834921172987905}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Scott Morrison\n-/\nimport tactic data.set.lattice data.prod data.vector\n       tactic.rewrite data.stream.basic\n       tactic.tfae tactic.converter.interactive\n       tactic.ring tactic.ring2\n\nsection tauto₀\nvariables p q r : Prop\nvariables h : p ∧ q ∨ p ∧ r\ninclude h\nexample : p ∧ p :=\nby tauto\n\nend tauto₀\n\nsection tauto₁\nvariables α : Type\nvariables p q r : α → Prop\nvariables h : (∃ x, p x ∧ q x) ∨ (∃ x, p x ∧ r x)\ninclude h\nexample : ∃ x, p x :=\nby tauto\n\nend tauto₁\n\nsection tauto₂\nvariables α : Type\nvariables x : α\nvariables p q r : α → Prop\nvariables h₀ : (∀ x, p x → q x → r x) ∨ r x\nvariables h₁ : p x\nvariables h₂ : q x\n\ninclude h₀ h₁ h₂\nexample : ∃ x, r x :=\nby tauto\n\nend tauto₂\n\nsection tauto₃\n\n\nexample (p : Prop) : p ∧ true ↔ p := by tauto\nexample (p : Prop) : p ∨ false ↔ p := by tauto\nexample (p q r : Prop) [decidable p] [decidable r] : p ∨ (q ∧ r) ↔ (p ∨ q) ∧ (r ∨ p ∨ r) := by tauto\nexample (p q r : Prop) [decidable q] [decidable r] : p ∨ (q ∧ r) ↔ (p ∨ q) ∧ (r ∨ p ∨ r) := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : ¬ (p ↔ q)) (h' : ¬ p) : q := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : ¬ (p ↔ q)) (h' : p) : ¬ q := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : ¬ (p ↔ q)) (h' : q) : ¬ p := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : ¬ (p ↔ q)) (h' : ¬ q) : p := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : ¬ (p ↔ q)) (h' : ¬ q) (h'' : ¬ p) : false := by tauto\nexample (p q r : Prop) [decidable q] [decidable p] (h : p ↔ q) (h' : r ↔ q) (h'' : ¬ r) : ¬ p := by tauto\nexample (p q r : Prop) (h : p ↔ q) (h' : r ↔ q) : p ↔ r :=\nby tauto!\nexample (p q r : Prop) (h : ¬ p = q) (h' : r = q) : p ↔ ¬ r := by tauto!\n\nsection modulo_symmetry\nvariables {p q r : Prop} {α : Type} {x y : α}\nvariables (h : x = y)\nvariables (h'' : (p ∧ q ↔ q ∨ r) ↔ (r ∧ p ↔ r ∨ q))\ninclude h\ninclude h''\nexample (h' : ¬ y = x) : p ∧ q := by tauto\nexample (h' : p ∧ ¬ y = x) : p ∧ q := by tauto\nexample : y = x := by tauto\nexample (h' : ¬ x = y) : p ∧ q := by tauto\nexample : x = y := by tauto\n\nend modulo_symmetry\n\nend tauto₃\n\nsection wlog\n\nexample {x y : ℕ} (a : x = 1) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x = y,\n  { guard_target x = y ∨ y = x,\n    admit },\n  { guard_hyp h := x = y,\n    guard_hyp a := x = 1,\n    admit }\nend\n\nexample {x y : ℕ} : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x ≤ y,\n  { guard_hyp h := x ≤ y,\n    guard_target false,\n    admit }\nend\n\nexample {x y z : ℕ} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : x ≤ y + z using x y,\n  { guard_target x ≤ y + z ∨ y ≤ x + z,\n    admit },\n  { guard_hyp case := x ≤ y + z,\n    guard_target false,\n    admit },\nend\n\nexample {x : ℕ} (S₀ S₁ : set ℕ) (P : ℕ → Prop)\n  (h : x ∈ S₀ ∪ S₁) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h' : x ∈ S₀ using S₀ S₁,\n  { guard_target x ∈ S₀ ∨ x ∈ S₁,\n    admit },\n  { guard_hyp h  := x ∈ S₀ ∪ S₁,\n    guard_hyp h' := x ∈ S₀,\n    admit }\nend\n\nexample {n m i : ℕ} {p : ℕ → ℕ → ℕ → Prop} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : p n m i using [n m i, n i m, i n m],\n  { guard_target p n m i ∨ p n i m ∨ p i n m,\n    admit },\n  { guard_hyp case := p n m i,\n    admit }\nend\n\nexample {n m i : ℕ} {p : ℕ → Prop} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : p n using [n m i, m n i, i n m],\n  { guard_target p n ∨ p m ∨ p i,\n    admit },\n  { guard_hyp case := p n,\n    admit }\nend\n\nexample {n m i : ℕ} {p : ℕ → ℕ → Prop} {q : ℕ → ℕ → ℕ → Prop} : true :=\nbegin\n  suffices : q n m i, trivial,\n  have h : p n i ∨ p i m ∨ p m i, from sorry,\n  wlog : p n i := h using n m i,\n  { guard_hyp h := p n i,\n    guard_target q n m i,\n    admit },\n  { guard_hyp h := p i m,\n    guard_hyp this := q i m n,\n    guard_target q n m i,\n    admit },\n  { guard_hyp h := p m i,\n    guard_hyp this := q m i n,\n    guard_target q n m i,\n    admit },\nend\n\nexample (X : Type) (A B C : set X) : A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x ∈ B using B C,\n    { assumption },\n    { exact or.inl ⟨hyp_left, x_in⟩ } },\n  { intro hyp,\n    wlog x_in : x ∈ A ∩ B using B C,\n    { assumption },\n    { exact ⟨x_in.left, or.inl x_in.right⟩ } }\nend\n\nexample (X : Type) (A B C : set X) : A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    wlog x_in : x ∈ B := hyp.2 using B C,\n    { exact or.inl ⟨hyp.1, x_in⟩ } },\n  { intro hyp,\n    wlog x_in : x ∈ A ∩ B := hyp using B C,\n    { exact ⟨x_in.left, or.inl x_in.right⟩ } }\nend\n\nexample (X : Type) (A B C : set X) : A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x ∈ B := hyp_right using B C,\n    { exact or.inl ⟨hyp_left, x_in⟩ }, },\n  { intro hyp,\n    wlog x_in : x ∈ A ∩ B := hyp using B C,\n    { exact ⟨x_in.left, or.inl x_in.right⟩ } }\nend\n\nend wlog\n\nexample (m n p q : nat) (h : m + n = p) : true :=\nbegin\n  have : m + n = q,\n  { generalize_hyp h' : m + n = x at h,\n    guard_hyp h' := m + n = x,\n    guard_hyp h := x = p,\n    guard_target m + n = q,\n    admit },\n  have : m + n = q,\n  { generalize_hyp h' : m + n = x at h ⊢,\n    guard_hyp h' := m + n = x,\n    guard_hyp h := x = p,\n    guard_target x = q,\n    admit },\n  trivial\nend\n\nexample (α : Sort*) (L₁ L₂ L₃ : list α)\n  (H : L₁ ++ L₂ = L₃) : true :=\nbegin\n  have : L₁ ++ L₂ = L₂,\n  { generalize_hyp h : L₁ ++ L₂ = L at H,\n    induction L with hd tl ih,\n    case list.nil\n    { tactic.cleanup,\n      change list.nil = L₃ at H,\n      admit },\n    case list.cons\n    { change list.cons hd tl = L₃ at H,\n      admit } },\n  trivial\nend\n\nsection convert\nopen set\n\nvariables {α β : Type}\nlocal attribute [simp]\nprivate lemma singleton_inter_singleton_eq_empty {x y : α} :\n  ({x} ∩ {y} = (∅ : set α)) ↔ x ≠ y :=\nby simp [singleton_inter_eq_empty]\n\nexample {f : β → α} {x y : α} (h : x ≠ y) : f ⁻¹' {x} ∩ f ⁻¹' {y} = ∅ :=\nbegin\n  have : {x} ∩ {y} = (∅ : set α) := by simpa using h,\n  convert preimage_empty,\n  rw [←preimage_inter,this],\nend\n\nend convert\n\nsection rcases\n\nuniverse u\nvariables {α β γ : Type u}\n\nexample (x : α × β × γ) : true :=\nbegin\n  rcases x with ⟨a, b, c⟩,\n  { guard_hyp a := α,\n    guard_hyp b := β,\n    guard_hyp c := γ,\n    trivial }\nend\n\nexample (x : α × β × γ) : true :=\nbegin\n  rcases x with ⟨a, ⟨b, c⟩⟩,\n  { guard_hyp a := α,\n    guard_hyp b := β,\n    guard_hyp c := γ,\n    trivial }\nend\n\nexample (x : (α × β) × γ) : true :=\nbegin\n  rcases x with ⟨⟨a, b⟩, c⟩,\n  { guard_hyp a := α,\n    guard_hyp b := β,\n    guard_hyp c := γ,\n    trivial }\nend\n\nexample (x : inhabited α × option β ⊕ γ) : true :=\nbegin\n  rcases x with ⟨⟨a⟩, _ | b⟩ | c,\n  { guard_hyp a := α, trivial },\n  { guard_hyp a := α, guard_hyp b := β, trivial },\n  { guard_hyp c := γ, trivial }\nend\n\nexample (x y : ℕ) (h : x = y) : true :=\nbegin\n  rcases x with _|⟨⟩|z,\n  { guard_hyp h := nat.zero = y, trivial },\n  { guard_hyp h := nat.succ nat.zero = y, trivial },\n  { guard_hyp z := ℕ,\n    guard_hyp h := z.succ.succ = y, trivial },\nend\n\n-- from equiv.sum_empty\nexample (s : α ⊕ empty) : true :=\nbegin\n  rcases s with _ | ⟨⟨⟩⟩,\n  { guard_hyp s := α, trivial }\nend\n\nend rcases\n\nsection ext\n\n@[extensionality] lemma unit.ext (x y : unit) : x = y :=\nbegin\n  cases x, cases y, refl\nend\n\nexample : subsingleton unit :=\nbegin\n  split, intros, ext\nend\n\nexample (x y : ℕ) : true :=\nbegin\n  have : x = y,\n  { ext <|> admit },\n  have : x = y,\n  { ext i <|> admit },\n  have : x = y,\n  { ext : 1 <|> admit },\n  trivial\nend\n\nexample (X Y : ℕ × ℕ)  (h : X.1 = Y.1) (h : X.2 = Y.2) : X = Y :=\nbegin\n  ext; assumption\nend\n\nexample (X Y : (ℕ → ℕ) × ℕ)  (h : ∀ i, X.1 i = Y.1 i) (h : X.2 = Y.2) : X = Y :=\nbegin\n  ext x; solve_by_elim,\nend\n\nexample (X Y : ℕ → ℕ × ℕ)  (h : ∀ i, X i = Y i) : true :=\nbegin\n  have : X = Y,\n  { ext i : 1,\n    guard_target X i = Y i,\n    admit },\n  have : X = Y,\n  { ext i,\n    guard_target (X i).fst = (Y i).fst, admit,\n    guard_target (X i).snd = (Y i).snd, admit, },\n  have : X = Y,\n  { ext : 1,\n    guard_target X x = Y x,\n    admit },\n  trivial,\nend\n\nexample (s₀ s₁ : set ℕ) (h : s₁ = s₀) : s₀ = s₁ :=\nby { ext1, guard_target x ∈ s₀ ↔ x ∈ s₁, simp * }\n\nexample (s₀ s₁ : stream ℕ) (h : s₁ = s₀) : s₀ = s₁ :=\nby { ext1, guard_target s₀.nth n = s₁.nth n, simp * }\n\nexample (s₀ s₁ : ℤ → set (ℕ × ℕ))\n        (h : ∀ i a b, (a,b) ∈ s₀ i ↔ (a,b) ∈ s₁ i) : s₀ = s₁ :=\nbegin\n  ext i ⟨a,b⟩,\n  apply h\nend\n\ndef my_foo {α} (x : semigroup α) (y : group α) : true := trivial\n\nexample {α : Type} : true :=\nbegin\n  have : true,\n  { refine_struct (@my_foo α { .. } { .. } ),\n      -- 9 goals\n    guard_tags _field mul semigroup, admit,\n      -- case semigroup, mul\n      -- α : Type\n      -- ⊢ α → α → α\n\n    guard_tags _field mul_assoc semigroup, admit,\n      -- case semigroup, mul_assoc\n      -- α : Type\n      -- ⊢ ∀ (a b c : α), a * b * c = a * (b * c)\n\n    guard_tags _field mul group, admit,\n      -- case group, mul\n      -- α : Type\n      -- ⊢ α → α → α\n\n    guard_tags _field mul_assoc group, admit,\n      -- case group, mul_assoc\n      -- α : Type\n      -- ⊢ ∀ (a b c : α), a * b * c = a * (b * c)\n\n    guard_tags _field one group, admit,\n      -- case group, one\n      -- α : Type\n      -- ⊢ α\n\n    guard_tags _field one_mul group, admit,\n      -- case group, one_mul\n      -- α : Type\n      -- ⊢ ∀ (a : α), 1 * a = a\n\n    guard_tags _field mul_one group, admit,\n      -- case group, mul_one\n      -- α : Type\n      -- ⊢ ∀ (a : α), a * 1 = a\n\n    guard_tags _field inv group, admit,\n      -- case group, inv\n      -- α : Type\n      -- ⊢ α → α\n\n    guard_tags _field mul_left_inv group, admit,\n      -- case group, mul_left_inv\n      -- α : Type\n      -- ⊢ ∀ (a : α), a⁻¹ * a = 1\n  },\n  trivial\nend\n\ndef my_bar {α} (x : semigroup α) (y : group α) (i j : α) : α := i\n\nexample {α : Type} : true :=\nbegin\n  have : monoid α,\n  { refine_struct { mul := my_bar { .. } { .. } },\n    guard_tags _field mul semigroup, admit,\n    guard_tags _field mul_assoc semigroup, admit,\n    guard_tags _field mul group, admit,\n    guard_tags _field mul_assoc group, admit,\n    guard_tags _field one group, admit,\n    guard_tags _field one_mul group, admit,\n    guard_tags _field mul_one group, admit,\n    guard_tags _field inv group, admit,\n    guard_tags _field mul_left_inv group, admit,\n    guard_tags _field mul_assoc monoid, admit,\n    guard_tags _field one monoid, admit,\n    guard_tags _field one_mul monoid, admit,\n    guard_tags _field mul_one monoid, admit, },\n  trivial\nend\n\nstructure dependent_fields :=\n(a : bool)\n(v : if a then ℕ else ℤ)\n\n@[extensionality] lemma df.ext (s t : dependent_fields) (h : s.a = t.a)\n (w : (@eq.rec _ s.a (λ b, if b then ℕ else ℤ) s.v t.a h) = t.v): s = t :=\nbegin\n  cases s, cases t,\n  dsimp at *,\n  congr,\n  exact h,\n  subst h,\n  simp,\n  simp at w,\n  exact w,\nend\n\nexample (s : dependent_fields) : s = s :=\nbegin\n  tactic.ext1 [] {tactic.apply_cfg . new_goals := tactic.new_goals.all},\n  guard_target s.a = s.a,\n  refl,\n  refl,\nend\n\nend ext\n\nsection apply_rules\n\nexample {a b c d e : nat} (h1 : a ≤ b) (h2 : c ≤ d) (h3 : 0 ≤ e) :\na + c * e + a + c + 0 ≤ b + d * e + b + d + e :=\nadd_le_add (add_le_add (add_le_add (add_le_add h1 (mul_le_mul_of_nonneg_right h2 h3)) h1 ) h2) h3\n\nexample {a b c d e : nat} (h1 : a ≤ b) (h2 : c ≤ d) (h3 : 0 ≤ e) :\na + c * e + a + c + 0 ≤ b + d * e + b + d + e :=\nby apply_rules [add_le_add, mul_le_mul_of_nonneg_right]\n\n@[user_attribute]\nmeta def mono_rules : user_attribute :=\n{ name := `mono_rules,\n  descr := \"lemmas usable to prove monotonicity\" }\nattribute [mono_rules] add_le_add mul_le_mul_of_nonneg_right\n\nexample {a b c d e : nat} (h1 : a ≤ b) (h2 : c ≤ d) (h3 : 0 ≤ e) :\na + c * e + a + c + 0 ≤ b + d * e + b + d + e :=\nby apply_rules [mono_rules]\n\nexample {a b c d e : nat} (h1 : a ≤ b) (h2 : c ≤ d) (h3 : 0 ≤ e) :\na + c * e + a + c + 0 ≤ b + d * e + b + d + e :=\nby apply_rules mono_rules\n\nend apply_rules\n\nsection h_generalize\n\nvariables {α β γ φ ψ : Type} (f : α → α → α → φ → γ)\n          (x y : α) (a b : β) (z : φ)\n          (h₀ : β = α) (h₁ : β = α) (h₂ : φ = β)\n          (hx : x == a) (hy : y == b) (hz : z == a)\ninclude f x y z a b hx hy hz\n\nexample : f x y x z = f (eq.rec_on h₀ a) (cast h₀ b) (eq.mpr h₁.symm a) (eq.mpr h₂ a) :=\nbegin\n  guard_hyp_nums 16,\n  h_generalize hp : a == p with hh,\n  guard_hyp_nums 19,\n  guard_hyp' hh := β = α,\n  guard_target f x y x z = f p (cast h₀ b) p (eq.mpr h₂ a),\n  h_generalize hq : _ == q,\n  guard_hyp_nums 21,\n  guard_target f x y x z = f p q p (eq.mpr h₂ a),\n  h_generalize _ : _ == r,\n  guard_hyp_nums 23,\n  guard_target f x y x z = f p q p r,\n  casesm* [_ == _, _ = _], refl\nend\n\nend h_generalize\n\nsection h_generalize\n\nvariables {α β γ φ ψ : Type} (f : list α → list α → γ)\n          (x : list α) (a : list β) (z : φ)\n          (h₀ : β = α) (h₁ : list β = list α)\n          (hx : x == a)\ninclude f x z a hx h₀ h₁\n\nexample : true :=\nbegin\n  have : f x x = f (eq.rec_on h₀ a) (cast h₁ a),\n  { guard_hyp_nums 11,\n    h_generalize : a == p with _,\n    guard_hyp_nums 13,\n    guard_hyp' h := β = α,\n    guard_target f x x = f p (cast h₁ a),\n    h_generalize! : a == q ,\n    guard_hyp_nums 13,\n    guard_target ∀ q, f x x = f p q,\n    casesm* [_ == _, _ = _],\n    success_if_fail { refl },\n    admit },\n  trivial\nend\n\nend h_generalize\n\nsection assoc_rw\nopen tactic\nexample : ∀ x y z a b c : ℕ, true :=\nbegin\n intros,\n have : x + (y + z) = 3 + y, admit,\n have : a + (b + x) + y + (z + b + c) ≤ 0,\n (do this ← get_local `this,\n     tgt ← to_expr ```(a + (b + x) + y + (z + b + c)),\n     assoc ← mk_mapp ``add_monoid.add_assoc [`(ℕ),none],\n     (l,p) ← assoc_rewrite_intl assoc this tgt,\n     note `h none p  ),\n erw h,\n guard_target a + b + 3 + y + b + c ≤ 0,\n admit,\n trivial\nend\n\nexample : ∀ x y z a b c : ℕ, true :=\nbegin\n intros,\n have : ∀ y, x + (y + z) = 3 + y, admit,\n have : a + (b + x) + y + (z + b + c) ≤ 0,\n (do this ← get_local `this,\n     tgt ← to_expr ```(a + (b + x) + y + (z + b + c)),\n     assoc_rewrite_target this ),\n guard_target a + b + 3 + y + b + c ≤ 0,\n admit,\n trivial\nend\n\nvariables x y z a b c : ℕ\nvariables h₀ : ∀ (y : ℕ), x + (y + z) = 3 + y\nvariables h₁ : a + (b + x) + y + (z + b + a) ≤ 0\nvariables h₂ : y + b + c = y + b + a\ninclude h₀ h₁ h₂\nexample : a + (b + x) + y + (z + b + c) ≤ 0 :=\nby { assoc_rw [h₀,h₂] at *,\n     guard_hyp _inst := is_associative ℕ has_add.add,\n       -- keep a local instance of is_associative to cache\n       -- type class queries\n     exact h₁ }\n\nend assoc_rw\n\n-- section tfae\n\n-- example (p q r s : Prop)\n--   (h₀ : p ↔ q)\n--   (h₁ : q ↔ r)\n--   (h₂ : r ↔ s) :\n--   p ↔ s :=\n-- begin\n--   scc,\n-- end\n\n-- example (p' p q r r' s s' : Prop)\n--   (h₀ : p' → p)\n--   (h₀ : p → q)\n--   (h₁ : q → r)\n--   (h₁ : r' → r)\n--   (h₂ : r ↔ s)\n--   (h₂ : s → p)\n--   (h₂ : s → s') :\n--   p ↔ s :=\n-- begin\n--   scc,\n-- end\n\n-- example (p' p q r r' s s' : Prop)\n--   (h₀ : p' → p)\n--   (h₀ : p → q)\n--   (h₁ : q → r)\n--   (h₁ : r' → r)\n--   (h₂ : r ↔ s)\n--   (h₂ : s → p)\n--   (h₂ : s → s') :\n--   p ↔ s :=\n-- begin\n--   scc',\n--   assumption\n-- end\n\n-- example : tfae [true, ∀ n : ℕ, 0 ≤ n * n, true, true] := begin\n--   tfae_have : 3 → 1, { intro h, constructor },\n--   tfae_have : 2 → 3, { intro h, constructor },\n--   tfae_have : 2 ← 1, { intros h n, apply nat.zero_le },\n--   tfae_have : 4 ↔ 2, { tauto },\n--   tfae_finish,\n-- end\n\n-- example : tfae [] := begin\n--   tfae_finish,\n-- end\n\n-- end tfae\n\nsection conv\n\nexample : 0 + 0 = 0 :=\nbegin\n  conv_lhs {erw [add_zero]}\nend\n\nexample : 0 + 0 = 0 :=\nbegin\n  conv_lhs {simp}\nend\n\nexample : 0 = 0 + 0 :=\nbegin\n  conv_rhs {simp}\nend\n\n-- Example with ring discharging the goal\nexample : 22 + 7 * 4 + 3 * 8 = 0 + 7 * 4 + 46 :=\nbegin\n  conv { ring, },\nend\n\n-- Example with ring failing to discharge, to normalizing the goal\nexample : (22 + 7 * 4 + 3 * 8 = 0 + 7 * 4 + 47) = (74 = 75) :=\nbegin\n  conv { ring, },\nend\n\n-- Example with ring discharging the goal\nexample (x : ℕ) : 22 + 7 * x + 3 * 8 = 0 + 7 * x + 46 :=\nbegin\n  conv { ring, },\nend\n\n-- Example with ring failing to discharge, to normalizing the goal\nexample (x : ℕ) : (22 + 7 * x + 3 * 8 = 0 + 7 * x + 46 + 1)\n                    = (7 * x + 46 = 7 * x + 47) :=\nbegin\n  conv { ring, },\nend\n\n-- norm_num examples:\nexample : 22 + 7 * 4 + 3 * 8 = 74 :=\nbegin\n  conv { norm_num, },\nend\n\nexample (x : ℕ) : 22 + 7 * x + 3 * 8 = 7 * x + 46 :=\nbegin\n  conv { norm_num, },\nend\n\nend conv\n\nsection clear_aux_decl\n\nexample (n m : ℕ) (h₁ : n = m) (h₂ : ∃ a : ℕ, a = n ∧ a = m) : 2 * m = 2 * n :=\nlet ⟨a, ha⟩ := h₂ in\nbegin\n  clear_aux_decl, -- subst will fail without this line\n  subst h₁\nend\n\nexample (x y : ℕ) (h₁ : ∃ n : ℕ, n * 1 = 2) (h₂ : 1 + 1 = 2 → x * 1 = y) : x = y :=\nlet ⟨n, hn⟩ := h₁ in\nbegin\n  clear_aux_decl, -- finish produces an error without this line\n  finish\nend\n\nend clear_aux_decl\n\nsection congr\n\nexample (c : Prop → Prop → Prop → Prop) (x x' y z z' : Prop)\n  (h₀ : x ↔ x')\n  (h₁ : z ↔ z') :\n  c x y z ↔ c x' y z' :=\nbegin\n  congr',\n  { guard_target x = x', ext, assumption },\n  { guard_target z = z', ext, assumption },\nend\n\nend congr\n\nprivate meta def get_exception_message (t : lean.parser unit) : lean.parser string\n| s := match t s with\n       | result.success a s' := result.success \"No exception\" s\n       | result.exception none pos s' := result.success \"Exception no msg\" s\n       | result.exception (some msg) pos s' := result.success (msg ()).to_string s\n       end\n\n@[user_command] meta def test_parser1_fail_cmd\n(_ : interactive.parse (lean.parser.tk \"test_parser1\")) : lean.parser unit :=\ndo\n  let msg := \"oh, no!\",\n  let t : lean.parser unit := tactic.fail msg,\n  s ← get_exception_message t,\n  if s = msg then tactic.skip\n  else interaction_monad.fail \"Message was corrupted while being passed through `lean.parser.of_tactic`\"\n.\n\n-- Due to `lean.parser.of_tactic'` priority, the following *should not* fail with\n-- a VM check error, and instead catch the error gracefully and just\n-- run and succeed silently.\ntest_parser1\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/test/tactics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.4834582204133538}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Scott Morrison\n\n! This file was ported from Lean 3 source module algebra.homology.complex_shape\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Group.Defs\nimport Mathbin.Logic.Relation\n\n/-!\n# Shapes of homological complexes\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define a structure `complex_shape ι` for describing the shapes of homological complexes\nindexed by a type `ι`.\nThis is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,\nas well as more exotic examples.\n\nRather than insisting that the indexing type has a `succ` function\nspecifying where differentials should go,\ninside `c : complex_shape` we have `c.rel : ι → ι → Prop`,\nand when we define `homological_complex`\nwe only allow nonzero differentials `d i j` from `i` to `j` if `c.rel i j`.\nFurther, we require that `{ j // c.rel i j }` and `{ i // c.rel i j }` are subsingletons.\nThis means that the shape consists of some union of lines, rays, intervals, and circles.\n\nConvenience functions `c.next` and `c.prev` provide these related elements\nwhen they exist, and return their input otherwise.\n\nThis design aims to avoid certain problems arising from dependent type theory.\nIn particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as\nexpected (which would often require rewriting by equations in the indexing type).\nInstead such identities become separate proof obligations when verifying that a\ncomplex we've constructed is of the desired shape.\n\nIf `α` is an `add_right_cancel_semigroup`, then we define `up α : complex_shape α`,\nthe shape appropriate for cohomology,so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,\nas well as `down α : complex_shape α`, appropriate for homology,\nso `d : X i ⟶ X j` is nonzero only when `i = j + 1`.\n(Later we'll introduce `cochain_complex` and `chain_complex` as abbreviations for\n`homological_complex` with one of these shapes baked in.)\n-/\n\n\nopen Classical\n\nnoncomputable section\n\n#print ComplexShape /-\n/-- A `c : complex_shape ι` describes the shape of a chain complex,\nwith chain groups indexed by `ι`.\nTypically `ι` will be `ℕ`, `ℤ`, or `fin n`.\n\nThere is a relation `rel : ι → ι → Prop`,\nand we will only allow a non-zero differential from `i` to `j` when `rel i j`.\n\nThere are axioms which imply `{ j // c.rel i j }` and `{ i // c.rel i j }` are subsingletons.\nThis means that the shape consists of some union of lines, rays, intervals, and circles.\n\nBelow we define `c.next` and `c.prev` which provide these related elements.\n-/\n@[ext, nolint has_nonempty_instance]\nstructure ComplexShape (ι : Type _) where\n  Rel : ι → ι → Prop\n  next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'\n  prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'\n#align complex_shape ComplexShape\n-/\n\nnamespace ComplexShape\n\nvariable {ι : Type _}\n\n#print ComplexShape.refl /-\n/-- The complex shape where only differentials from each `X.i` to itself are allowed.\n\nThis is mostly only useful so we can describe the relation of \"related in `k` steps\" below.\n-/\n@[simps]\ndef refl (ι : Type _) : ComplexShape ι\n    where\n  Rel i j := i = j\n  next_eq i j j' w w' := w.symm.trans w'\n  prev_eq i i' j w w' := w.trans w'.symm\n#align complex_shape.refl ComplexShape.refl\n-/\n\n#print ComplexShape.symm /-\n/-- The reverse of a `complex_shape`.\n-/\n@[simps]\ndef symm (c : ComplexShape ι) : ComplexShape ι\n    where\n  Rel i j := c.Rel j i\n  next_eq i j j' w w' := c.prev_eq w w'\n  prev_eq i i' j w w' := c.next_eq w w'\n#align complex_shape.symm ComplexShape.symm\n-/\n\n#print ComplexShape.symm_symm /-\n@[simp]\ntheorem symm_symm (c : ComplexShape ι) : c.symm.symm = c :=\n  by\n  ext\n  simp\n#align complex_shape.symm_symm ComplexShape.symm_symm\n-/\n\n#print ComplexShape.trans /-\n/-- The \"composition\" of two `complex_shape`s.\n\nWe need this to define \"related in k steps\" later.\n-/\n@[simp]\ndef trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι\n    where\n  Rel := Relation.Comp c₁.Rel c₂.Rel\n  next_eq i j j' w w' := by\n    obtain ⟨k, w₁, w₂⟩ := w\n    obtain ⟨k', w₁', w₂'⟩ := w'\n    rw [c₁.next_eq w₁ w₁'] at w₂\n    exact c₂.next_eq w₂ w₂'\n  prev_eq i i' j w w' := by\n    obtain ⟨k, w₁, w₂⟩ := w\n    obtain ⟨k', w₁', w₂'⟩ := w'\n    rw [c₂.prev_eq w₂ w₂'] at w₁\n    exact c₁.prev_eq w₁ w₁'\n#align complex_shape.trans ComplexShape.trans\n-/\n\n#print ComplexShape.subsingleton_next /-\ninstance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } :=\n  by\n  fconstructor\n  rintro ⟨j, rij⟩ ⟨k, rik⟩\n  congr\n  exact c.next_eq rij rik\n#align complex_shape.subsingleton_next ComplexShape.subsingleton_next\n-/\n\n#print ComplexShape.subsingleton_prev /-\ninstance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } :=\n  by\n  fconstructor\n  rintro ⟨i, rik⟩ ⟨j, rjk⟩\n  congr\n  exact c.prev_eq rik rjk\n#align complex_shape.subsingleton_prev ComplexShape.subsingleton_prev\n-/\n\n#print ComplexShape.next /-\n/-- An arbitary choice of index `j` such that `rel i j`, if such exists.\nReturns `i` otherwise.\n-/\ndef next (c : ComplexShape ι) (i : ι) : ι :=\n  if h : ∃ j, c.Rel i j then h.some else i\n#align complex_shape.next ComplexShape.next\n-/\n\n#print ComplexShape.prev /-\n/-- An arbitary choice of index `i` such that `rel i j`, if such exists.\nReturns `j` otherwise.\n-/\ndef prev (c : ComplexShape ι) (j : ι) : ι :=\n  if h : ∃ i, c.Rel i j then h.some else j\n#align complex_shape.prev ComplexShape.prev\n-/\n\n#print ComplexShape.next_eq' /-\ntheorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j :=\n  by\n  apply c.next_eq _ h\n  dsimp only [next]\n  rw [dif_pos]\n  exact Exists.choose_spec ⟨j, h⟩\n#align complex_shape.next_eq' ComplexShape.next_eq'\n-/\n\n#print ComplexShape.prev_eq' /-\ntheorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i :=\n  by\n  apply c.prev_eq _ h\n  dsimp only [prev]\n  rw [dif_pos]\n  exact Exists.choose_spec ⟨i, h⟩\n#align complex_shape.prev_eq' ComplexShape.prev_eq'\n-/\n\n#print ComplexShape.up' /-\n/-- The `complex_shape` allowing differentials from `X i` to `X (i+a)`.\n(For example when `a = 1`, a cohomology theory indexed by `ℕ` or `ℤ`)\n-/\n@[simps]\ndef up' {α : Type _} [AddRightCancelSemigroup α] (a : α) : ComplexShape α\n    where\n  Rel i j := i + a = j\n  next_eq i j k hi hj := hi.symm.trans hj\n  prev_eq i j k hi hj := add_right_cancel (hi.trans hj.symm)\n#align complex_shape.up' ComplexShape.up'\n-/\n\n#print ComplexShape.down' /-\n/-- The `complex_shape` allowing differentials from `X (j+a)` to `X j`.\n(For example when `a = 1`, a homology theory indexed by `ℕ` or `ℤ`)\n-/\n@[simps]\ndef down' {α : Type _} [AddRightCancelSemigroup α] (a : α) : ComplexShape α\n    where\n  Rel i j := j + a = i\n  next_eq i j k hi hj := add_right_cancel (hi.trans hj.symm)\n  prev_eq i j k hi hj := hi.symm.trans hj\n#align complex_shape.down' ComplexShape.down'\n-/\n\n/- warning: complex_shape.down'_mk -> ComplexShape.down'_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} α] (a : α) (i : α) (j : α), (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddSemigroup.toHasAdd.{u1} α (AddRightCancelSemigroup.toAddSemigroup.{u1} α _inst_1))) j a) i) -> (ComplexShape.Rel.{u1} α (ComplexShape.down'.{u1} α _inst_1 a) i j)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} α] (a : α) (i : α) (j : α), (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddSemigroup.toAdd.{u1} α (AddRightCancelSemigroup.toAddSemigroup.{u1} α _inst_1))) j a) i) -> (ComplexShape.Rel.{u1} α (ComplexShape.down'.{u1} α _inst_1 a) i j)\nCase conversion may be inaccurate. Consider using '#align complex_shape.down'_mk ComplexShape.down'_mkₓ'. -/\ntheorem down'_mk {α : Type _} [AddRightCancelSemigroup α] (a : α) (i j : α) (h : j + a = i) :\n    (down' a).Rel i j :=\n  h\n#align complex_shape.down'_mk ComplexShape.down'_mk\n\n#print ComplexShape.up /-\n/-- The `complex_shape` appropriate for cohomology, so `d : X i ⟶ X j` only when `j = i + 1`.\n-/\n@[simps]\ndef up (α : Type _) [AddRightCancelSemigroup α] [One α] : ComplexShape α :=\n  up' 1\n#align complex_shape.up ComplexShape.up\n-/\n\n#print ComplexShape.down /-\n/-- The `complex_shape` appropriate for homology, so `d : X i ⟶ X j` only when `i = j + 1`.\n-/\n@[simps]\ndef down (α : Type _) [AddRightCancelSemigroup α] [One α] : ComplexShape α :=\n  down' 1\n#align complex_shape.down ComplexShape.down\n-/\n\n/- warning: complex_shape.down_mk -> ComplexShape.down_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} α] [_inst_2 : One.{u1} α] (i : α) (j : α), (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddSemigroup.toHasAdd.{u1} α (AddRightCancelSemigroup.toAddSemigroup.{u1} α _inst_1))) j (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_2)))) i) -> (ComplexShape.Rel.{u1} α (ComplexShape.down.{u1} α _inst_1 _inst_2) i j)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} α] [_inst_2 : One.{u1} α] (i : α) (j : α), (Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddSemigroup.toAdd.{u1} α (AddRightCancelSemigroup.toAddSemigroup.{u1} α _inst_1))) j (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_2))) i) -> (ComplexShape.Rel.{u1} α (ComplexShape.down.{u1} α _inst_1 _inst_2) i j)\nCase conversion may be inaccurate. Consider using '#align complex_shape.down_mk ComplexShape.down_mkₓ'. -/\ntheorem down_mk {α : Type _} [AddRightCancelSemigroup α] [One α] (i j : α) (h : j + 1 = i) :\n    (down α).Rel i j :=\n  down'_mk (1 : α) i j h\n#align complex_shape.down_mk ComplexShape.down_mk\n\nend ComplexShape\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Homology/ComplexShape.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4834582157417127}}
{"text": "import group_theory.free_group group_theory.subgroup\n\nvariables {α : Type*} {β : Type*} [decidable_eq α] (T : set α) (r : free_group α)\n\nopen group subgroup free_group\n\n\n\n\ndef blah (t : α) : free_group α →* free_group unit :=\nto_group (λ a, if a = t then of () else 1)\n\ninstance {α : Type*} [subsingleton α] : comm_group (free_group α) :=\n{ mul_comm := λ a b, sorry,\n  ..free_group.group }\n\ndef ker_blah_free (t : α) (e : α ≃ option β) (he : e.symm none = t) :\n  free_group (β × ℤ) ≃* (blah t).ker :=\n{ to_fun := free_group.to_group\n    (λ b : β × ℤ, (⟨of t ^ b.2 * of (e.symm (some b.1)) * of t ^ -b.2,\n      monoid_hom.mem_ker.2 begin\n        rw [monoid_hom.map_mul, monoid_hom.map_mul, mul_right_comm,\n          ← monoid_hom.map_mul, ← gpow_add, add_neg_self],\n        simp [blah, he.symm]\n      end⟩ : (blah t).ker)),\n  inv_fun := λ x, begin\n    have := x.1,\n\n  end,  }\n\n@[elab_as_eliminator]\nlemma normal_closure_induction {G : Type*} [group G] {P : G → Prop} {x : G} {s : set G}\n  (h : x ∈ subgroup.normal_closure s)\n  (hs : ∀ x ∈ s, P x)\n  (h1 : P 1)\n  (hmul : ∀ x ∈ s, ∀ y, P y → P (x * y))\n  (hinv : ∀ x ∈ s, P x → P x⁻¹) : P x := sorry\n\ntheorem freiheitsatz (x : free_group α)\n  (hxr : x ∈ subgroup.normal_closure ({r} : set (free_group α)))\n  (hxT : x ∈ subgroup.normal_closure (free_group.of '' T)) (hx1 : x ≠ 1) :\n  r ∈ subgroup.normal_closure (free_group.of '' T) :=\nbegin\n  revert hxT hx1,\n  refine normal_closure_induction hxr _ _ _ _,\n  { assume x,\n    simp {contextual := tt} },\n  { simp },\n  { simp only [set.mem_singleton_iff, forall_eq, ne.def] {contextual := tt},\n    assume y hy hry, generalize hz : r * y = z, rw hz at hry, clear hxr, revert hz hy y r,\n    refine normal_closure_induction hry _ _ _ _,\n    { rintros _ ⟨a, haT, rfl⟩ r y ih, }\n   },\n\n\nend\n-- begin\n--   revert hxr hxT,\n--   refine free_group.induction_on r _ _ _ _ x,\n--   { intros,\n--     exact is_submonoid.one_mem },\n--   { assume r x hxr hxT,\n--     sorry },\n--   { assume y ih x hxr hxT, sorry,\n--      },\n--   { intros, }\n-- end\n", "meta": {"author": "ChrisHughes24", "repo": "leanstuff", "sha": "9efa85f72efaccd1d540385952a6acc18fce8687", "save_path": "github-repos/lean/ChrisHughes24-leanstuff", "path": "github-repos/lean/ChrisHughes24-leanstuff/leanstuff-9efa85f72efaccd1d540385952a6acc18fce8687/single_relation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.48339649093997017}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.subobject.well_powered\nimport category_theory.limits.preserves.finite\nimport category_theory.limits.shapes.finite_limits\n\n/-!\n# Subobjects in the category of structured arrows\n\nWe compute the subobjects of an object `A` in the category `structured_arrow S T` for `T : C ⥤ D`\nand `S : D` as a subtype of the subobjects of `A.right`. We deduce that `structured_arrow S T` is\nwell-powered if `C` is.\n\n## Main declarations\n* `structured_arrow.equiv_subtype`: the order-equivalence between `subobject A` and a subtype of\n  `subobject A.right`.\n\n## Implementation notes\nOur computation requires that `C` has all limits and `T` preserves all limits. Furthermore, we\nrequire that the morphisms of `C` and `D` are in the same universe. It is possible that both of\nthese requirements can be relaxed by refining the results about limits in comma categories.\n\nWe also provide the dual results. As usual, we use `subobject (op A)` for the quotient objects of\n`A`.\n\n-/\n\nnoncomputable theory\n\nopen category_theory.limits opposite\n\nuniverses v u₁ u₂\n\nnamespace category_theory\nvariables {C : Type u₁} [category.{v} C] {D : Type u₂} [category.{v} D]\n\nnamespace structured_arrow\nvariables {S : D} {T : C ⥤ D}\n\n/-- Every subobject of a structured arrow can be projected to a subobject of the underlying\n    object. -/\ndef project_subobject [has_limits C] [preserves_limits T] {A : structured_arrow S T} :\n  subobject A → subobject A.right :=\nbegin\n  refine subobject.lift (λ P f hf, by exactI subobject.mk f.right) _,\n  introsI P Q f g hf hg i hi,\n  refine subobject.mk_eq_mk_of_comm _ _ ((proj S T).map_iso i) _,\n  exact congr_arg comma_morphism.right hi\nend\n\n@[simp]\nlemma project_subobject_mk [has_limits C] [preserves_limits T] {A P : structured_arrow S T}\n  (f : P ⟶ A) [mono f] : project_subobject (subobject.mk f) = subobject.mk f.right :=\nrfl\n\nlemma project_subobject_factors [has_limits C] [preserves_limits T] {A : structured_arrow S T} :\n  ∀ P : subobject A, ∃ q, q ≫ T.map (project_subobject P).arrow = A.hom :=\nsubobject.ind _ $ λ P f hf,\n  ⟨P.hom ≫ T.map (subobject.underlying_iso _).inv, by { dsimp, simp [← T.map_comp] }⟩\n\n/-- A subobject of the underlying object of a structured arrow can be lifted to a subobject of\n    the structured arrow, provided that there is a morphism making the subobject into a structured\n    arrow. -/\n@[simp]\ndef lift_subobject {A : structured_arrow S T} (P : subobject A.right) {q}\n  (hq : q ≫ T.map P.arrow = A.hom) : subobject A :=\nsubobject.mk (hom_mk P.arrow hq : mk q ⟶ A)\n\n/-- Projecting and then lifting a subobject recovers the original subobject, because there is at\n    most one morphism making the projected subobject into a structured arrow. -/\nlemma lift_project_subobject [has_limits C] [preserves_limits T] {A : structured_arrow S T} :\n  ∀ (P : subobject A) {q} (hq : q ≫ T.map (project_subobject P).arrow = A.hom),\n    lift_subobject (project_subobject P) hq = P := subobject.ind _\nbegin\n  introsI P f hf q hq,\n  fapply subobject.mk_eq_mk_of_comm,\n  { fapply iso_mk,\n    { exact subobject.underlying_iso _ },\n    { exact (cancel_mono (T.map f.right)).1 (by { dsimp, simpa [← T.map_comp] using hq }) } },\n  { exact ext _ _ (by { dsimp, simp })}\nend\n\n/-- If `A : S → T.obj B` is a structured arrow for `S : D` and `T : C ⥤ D`, then we can explicitly\n    describe the subobjects of `A` as the subobjects `P` of `B` in `C` for which `A.hom` factors\n    through the image of `P` under `T`. -/\n@[simps]\ndef subobject_equiv [has_limits C] [preserves_limits T] (A : structured_arrow S T) :\n  subobject A ≃o { P : subobject A.right // ∃ q, q ≫ T.map P.arrow = A.hom } :=\n{ to_fun := λ P, ⟨project_subobject P, project_subobject_factors P⟩,\n  inv_fun := λ P, lift_subobject P.val P.prop.some_spec,\n  left_inv := λ P, lift_project_subobject _ _,\n  right_inv := λ P, subtype.ext (by simp),\n  map_rel_iff' := subobject.ind₂ _\n  begin\n    introsI P Q f g hf hg,\n    refine ⟨λ h, subobject.mk_le_mk_of_comm _ (ext _ _ _), λ h, _⟩,\n    { refine hom_mk (subobject.of_mk_le_mk _ _ h) ((cancel_mono (T.map g.right)).1 _),\n      simp [← T.map_comp] },\n    { simp only [mono_over.mk'_arrow, subobject.of_mk_le_mk_comp, comma.comp_right, hom_mk_right] },\n    { refine subobject.mk_le_mk_of_comm (subobject.of_mk_le_mk _ _ h).right _,\n      exact congr_arg comma_morphism.right (subobject.of_mk_le_mk_comp h) }\n  end }\n\n/-- If `C` is well-powered and complete and `T` preserves limits, then `structured_arrow S T` is\n    well-powered. -/\ninstance well_powered_structured_arrow [well_powered C] [has_limits C] [preserves_limits T] :\n  well_powered (structured_arrow S T) :=\n{ subobject_small := λ X, small_map (subobject_equiv X).to_equiv }\n\nend structured_arrow\n\nnamespace costructured_arrow\nvariables {S : C ⥤ D} {T : D}\n\n/-- Every quotient of a costructured arrow can be projected to a quotient of the underlying\n    object. -/\ndef project_quotient [has_colimits C] [preserves_colimits S] {A : costructured_arrow S T} :\n  subobject (op A) → subobject (op A.left) :=\nbegin\n  refine subobject.lift (λ P f hf, by exactI subobject.mk f.unop.left.op) _,\n  introsI P Q f g hf hg i hi,\n  refine subobject.mk_eq_mk_of_comm _ _ ((proj S T).map_iso i.unop).op (quiver.hom.unop_inj _),\n  have := congr_arg quiver.hom.unop hi,\n  simpa using congr_arg comma_morphism.left this,\nend\n\n@[simp]\nlemma project_quotient_mk [has_colimits C] [preserves_colimits S] {A : costructured_arrow S T}\n  {P : (costructured_arrow S T)ᵒᵖ} (f : P ⟶ op A) [mono f] :\n  (project_quotient (subobject.mk f)) = subobject.mk f.unop.left.op :=\nrfl\n\n\n\n/-- A quotient of the underlying object of a costructured arrow can be lifted to a quotient of\n    the costructured arrow, provided that there is a morphism making the quotient into a\n    costructured arrow. -/\n@[simp]\ndef lift_quotient {A : costructured_arrow S T} (P : subobject (op A.left)) {q}\n  (hq : S.map P.arrow.unop ≫ q = A.hom) : subobject (op A) :=\nsubobject.mk (hom_mk P.arrow.unop hq : A ⟶ mk q).op\n\n/-- Technical lemma for `lift_project_quotient`. -/\n@[simp]\nlemma unop_left_comp_underlying_iso_hom_unop {A : costructured_arrow S T}\n  {P : (costructured_arrow S T)ᵒᵖ} (f : P ⟶ op A) [mono f.unop.left.op] :\n  f.unop.left ≫ (subobject.underlying_iso f.unop.left.op).hom.unop =\n    (subobject.mk f.unop.left.op).arrow.unop :=\nbegin\n  conv_lhs { congr, rw [← quiver.hom.unop_op f.unop.left] },\n  rw [← unop_comp, subobject.underlying_iso_hom_comp_eq_mk]\nend\n\n/-- Projecting and then lifting a quotient recovers the original quotient, because there is at most\n    one morphism making the projected quotient into a costructured arrow. -/\nlemma lift_project_quotient [has_colimits C] [preserves_colimits S] {A : costructured_arrow S T} :\n  ∀ (P : subobject (op A)) {q} (hq : S.map (project_quotient P).arrow.unop ≫ q = A.hom),\n    lift_quotient (project_quotient P) hq = P := subobject.ind _\nbegin\n  introsI P f hf q hq,\n  fapply subobject.mk_eq_mk_of_comm,\n  { refine (iso.op (iso_mk _ _) : _ ≅ op (unop P)),\n    { exact (subobject.underlying_iso f.unop.left.op).unop },\n    { refine (cancel_epi (S.map f.unop.left)).1 _,\n      simpa [← category.assoc, ← S.map_comp] using hq } },\n  { exact quiver.hom.unop_inj (ext _ _ (by { dsimp, simp })) }\nend\n\n/-- Technical lemma for `quotient_equiv`. -/\nlemma unop_left_comp_of_mk_le_mk_unop {A : costructured_arrow S T}\n  {P Q : (costructured_arrow S T)ᵒᵖ} {f : P ⟶ op A} {g : Q ⟶ op A} [mono f.unop.left.op]\n  [mono g.unop.left.op] (h : subobject.mk f.unop.left.op ≤ subobject.mk g.unop.left.op) :\n  g.unop.left ≫ (subobject.of_mk_le_mk f.unop.left.op g.unop.left.op h).unop = f.unop.left :=\nbegin\n  conv_lhs { congr, rw [← quiver.hom.unop_op g.unop.left] },\n  rw [← unop_comp],\n  simp only [subobject.of_mk_le_mk_comp, quiver.hom.unop_op]\nend\n\n/-- If `A : S.obj B ⟶ T` is a costructured arrow for `S : C ⥤ D` and `T : D`, then we can\n    explicitly describe the quotients of `A` as the quotients `P` of `B` in `C` for which `A.hom`\n    factors through the image of `P` under `S`. -/\ndef quotient_equiv [has_colimits C] [preserves_colimits S] (A : costructured_arrow S T) :\n  subobject (op A) ≃o { P : subobject (op A.left) // ∃ q, S.map P.arrow.unop ≫ q = A.hom } :=\n{ to_fun := λ P, ⟨project_quotient P, project_quotient_factors P⟩,\n  inv_fun := λ P, lift_quotient P.val P.prop.some_spec,\n  left_inv := λ P, lift_project_quotient _ _,\n  right_inv := λ P, subtype.ext (by simp),\n  map_rel_iff' := subobject.ind₂ _\n  begin\n    introsI P Q f g hf hg,\n    refine ⟨λ h, subobject.mk_le_mk_of_comm _ (quiver.hom.unop_inj (ext _ _ _)), λ h, _⟩,\n    { refine (hom_mk (subobject.of_mk_le_mk _ _ h).unop ((cancel_epi (S.map g.unop.left)).1 _)).op,\n      dsimp only [mono_over.mk'_arrow],\n      rw [← category.assoc, ← S.map_comp, unop_left_comp_of_mk_le_mk_unop],\n      dsimp,\n      simp },\n    { exact unop_left_comp_of_mk_le_mk_unop _ },\n    { refine subobject.mk_le_mk_of_comm (subobject.of_mk_le_mk _ _ h).unop.left.op _,\n      refine quiver.hom.unop_inj _,\n      have := congr_arg quiver.hom.unop (subobject.of_mk_le_mk_comp h),\n      simpa [-subobject.of_mk_le_mk_comp] using congr_arg comma_morphism.left this }\n  end }\n\n/-- If `C` is well-copowered and cocomplete and `S` preserves colimits, then\n    `costructured_arrow S T` is well-copowered. -/\ninstance well_copowered_costructured_arrow [well_powered Cᵒᵖ] [has_colimits C]\n  [preserves_colimits S] : well_powered (costructured_arrow S T)ᵒᵖ :=\n{ subobject_small := λ X, small_map (quotient_equiv (unop X)).to_equiv }\n\nend costructured_arrow\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/subobject/comma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4833964854793605}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.fin_category\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.shapes.equalizers\nimport category_theory.limits.shapes.wide_pullbacks\nimport category_theory.limits.shapes.pullbacks\nimport data.fintype.basic\n\n/-!\n# Categories with finite limits.\n\nA typeclass for categories with all finite (co)limits.\n-/\n\nuniverses v' u' v u\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables (C : Type u) [category.{v} C]\n\n/--\nA category has all finite limits if every functor `J ⥤ C` with a `fin_category J` instance\nhas a limit.\n\nThis is often called 'finitely complete'.\n-/\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\nclass has_finite_limits : Prop :=\n(out (J : Type v) [𝒥 : small_category J] [@fin_category J 𝒥] : @has_limits_of_shape J 𝒥 C _)\n\n@[priority 100]\ninstance has_limits_of_shape_of_has_finite_limits\n  (J : Type v) [small_category J] [fin_category J] [has_finite_limits C] :\n  has_limits_of_shape J C := has_finite_limits.out J\n\n@[priority 100]\ninstance has_finite_limits_of_has_limits_of_size [has_limits_of_size.{v' u'} C] :\n  has_finite_limits C :=\n⟨λ J hJ hJ', by { haveI := has_limits_of_size_shrink.{0 0} C,\n  exact has_limits_of_shape_of_equivalence (fin_category.equiv_as_type J) }⟩\n\n/-- If `C` has all limits, it has finite limits. -/\n@[priority 100]\ninstance has_finite_limits_of_has_limits [has_limits C] : has_finite_limits C := infer_instance\n\n/--\nA category has all finite colimits if every functor `J ⥤ C` with a `fin_category J` instance\nhas a colimit.\n\nThis is often called 'finitely cocomplete'.\n-/\nclass has_finite_colimits : Prop :=\n(out (J : Type v) [𝒥 : small_category J] [@fin_category J 𝒥] : @has_colimits_of_shape J 𝒥 C _)\n\n@[priority 100]\ninstance has_limits_of_shape_of_has_finite_colimits\n  (J : Type v) [small_category J] [fin_category J] [has_finite_colimits C] :\n  has_colimits_of_shape J C := has_finite_colimits.out J\n\n@[priority 100]\ninstance has_finite_colimits_of_has_colimits_of_size [has_colimits_of_size.{v' u'} C] :\n  has_finite_colimits C :=\n⟨λ J hJ hJ', by { haveI := has_colimits_of_size_shrink.{0 0} C,\n  exact has_colimits_of_shape_of_equivalence (fin_category.equiv_as_type J) }⟩\n\n/-- If `C` has all colimits, it has finite colimits. -/\n@[priority 100]\ninstance has_finite_colimits_of_has_colimits [has_colimits C] : has_finite_colimits C :=\ninfer_instance\n\nsection\n\nopen walking_parallel_pair walking_parallel_pair_hom\n\ninstance fintype_walking_parallel_pair : fintype walking_parallel_pair :=\n{ elems := [walking_parallel_pair.zero, walking_parallel_pair.one].to_finset,\n  complete := λ x, by { cases x; simp } }\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance (j j' : walking_parallel_pair) : fintype (walking_parallel_pair_hom j j') :=\n{ elems := walking_parallel_pair.rec_on j\n    (walking_parallel_pair.rec_on j' [walking_parallel_pair_hom.id zero].to_finset\n      [left, right].to_finset)\n    (walking_parallel_pair.rec_on j' ∅ [walking_parallel_pair_hom.id one].to_finset),\n  complete := by tidy }\n\nend\n\ninstance : fin_category walking_parallel_pair := { }\n\n/-- Equalizers are finite limits, so if `C` has all finite limits, it also has all equalizers -/\nexample [has_finite_limits C] : has_equalizers C := by apply_instance\n\n/-- Coequalizers are finite colimits, of if `C` has all finite colimits, it also has all\n    coequalizers -/\nexample [has_finite_colimits C] : has_coequalizers C := by apply_instance\n\nvariables {J : Type v}\n\nlocal attribute [tidy] tactic.case_bash\n\nnamespace wide_pullback_shape\n\ninstance fintype_obj [fintype J] : fintype (wide_pullback_shape J) :=\nby { rw wide_pullback_shape, apply_instance }\n\ninstance fintype_hom [decidable_eq J] (j j' : wide_pullback_shape J) :\n  fintype (j ⟶ j') :=\n{ elems :=\n  begin\n    cases j',\n    { cases j,\n      { exact {hom.id none} },\n      { exact {hom.term j} } },\n    { by_cases some j' = j,\n      { rw h,\n        exact {hom.id j} },\n      { exact ∅ } }\n  end,\n  complete := by tidy }\n\nend wide_pullback_shape\n\nnamespace wide_pushout_shape\n\ninstance fintype_obj [fintype J] : fintype (wide_pushout_shape J) :=\nby { rw wide_pushout_shape, apply_instance }\n\ninstance fintype_hom [decidable_eq J] (j j' : wide_pushout_shape J) :\n  fintype (j ⟶ j') :=\n{ elems :=\n  begin\n    cases j,\n    { cases j',\n      { exact {hom.id none} },\n      { exact {hom.init j'} } },\n    { by_cases some j = j',\n      { rw h,\n        exact {hom.id j'} },\n      { exact ∅ } }\n  end,\n  complete := by tidy }\n\nend wide_pushout_shape\n\ninstance fin_category_wide_pullback [decidable_eq J] [fintype J] :\n  fin_category (wide_pullback_shape J) :=\n{ fintype_hom := wide_pullback_shape.fintype_hom }\n\ninstance fin_category_wide_pushout [decidable_eq J] [fintype J] :\n  fin_category (wide_pushout_shape J) :=\n{ fintype_hom := wide_pushout_shape.fintype_hom }\n\n/--\n`has_finite_wide_pullbacks` represents a choice of wide pullback\nfor every finite collection of morphisms\n-/\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\nclass has_finite_wide_pullbacks : Prop :=\n(out (J : Type v) [decidable_eq J] [fintype J] : has_limits_of_shape (wide_pullback_shape J) C)\n\ninstance has_limits_of_shape_wide_pullback_shape\n  (J : Type v) [fintype J] [has_finite_wide_pullbacks C] :\n  has_limits_of_shape (wide_pullback_shape J) C :=\nby { haveI := @has_finite_wide_pullbacks.out C _ _ J (classical.dec_eq _), apply_instance }\n\n/--\n`has_finite_wide_pushouts` represents a choice of wide pushout\nfor every finite collection of morphisms\n-/\nclass has_finite_wide_pushouts : Prop :=\n(out (J : Type v) [decidable_eq J] [fintype J] : has_colimits_of_shape (wide_pushout_shape J) C)\n\ninstance has_colimits_of_shape_wide_pushout_shape\n  (J : Type v) [fintype J] [has_finite_wide_pushouts C] :\n  has_colimits_of_shape (wide_pushout_shape J) C :=\nby { haveI := @has_finite_wide_pushouts.out C _ _ J (classical.dec_eq _), apply_instance }\n\n/--\nFinite wide pullbacks are finite limits, so if `C` has all finite limits,\nit also has finite wide pullbacks\n-/\n\n\n/--\nFinite wide pushouts are finite colimits, so if `C` has all finite colimits,\nit also has finite wide pushouts\n-/\nlemma has_finite_wide_pushouts_of_has_finite_limits [has_finite_colimits C] :\n  has_finite_wide_pushouts C :=\n⟨λ J _ _, by exactI has_finite_colimits.out _⟩\n\ninstance fintype_walking_pair : fintype walking_pair :=\n{ elems := {walking_pair.left, walking_pair.right},\n  complete := λ x, by { cases x; simp } }\n\n/-- Pullbacks are finite limits, so if `C` has all finite limits, it also has all pullbacks -/\nexample [has_finite_wide_pullbacks C] : has_pullbacks C := by apply_instance\n\n/-- Pushouts are finite colimits, so if `C` has all finite colimits, it also has all pushouts -/\nexample [has_finite_wide_pushouts C] : has_pushouts C := by apply_instance\n\nend category_theory.limits\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/limits/shapes/finite_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.48335715167524806}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl\n\n! This file was ported from Lean 3 source module topology.algebra.uniform_group\n! leanprover-community/mathlib commit ee05e9ce1322178f0c12004eb93c00d2c8c00ed2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Topology.UniformSpace.UniformConvergence\nimport Mathbin.Topology.UniformSpace.UniformEmbedding\nimport Mathbin.Topology.UniformSpace.CompleteSeparated\nimport Mathbin.Topology.UniformSpace.Compact\nimport Mathbin.Topology.Algebra.Group.Basic\nimport Mathbin.Tactic.Abel\n\n/-!\n# Uniform structure on topological groups\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines uniform groups and its additive counterpart. These typeclasses should be\npreferred over using `[topological_space α] [topological_group α]` since every topological\ngroup naturally induces a uniform structure.\n\n## Main declarations\n* `uniform_group` and `uniform_add_group`: Multiplicative and additive uniform groups, that\n  i.e., groups with uniformly continuous `(*)` and `(⁻¹)` / `(+)` and `(-)`.\n\n## Main results\n\n* `topological_add_group.to_uniform_space` and `topological_add_comm_group_is_uniform` can be used\n  to construct a canonical uniformity for a topological add group.\n\n* extension of ℤ-bilinear maps to complete groups (useful for ring completions)\n\n* `quotient_group.complete_space` and `quotient_add_group.complete_space` guarantee that quotients\n  of first countable topological groups by normal subgroups are themselves complete. In particular,\n  the quotient of a Banach space by a subspace is complete.\n-/\n\n\nnoncomputable section\n\nopen Classical uniformity Topology Filter Pointwise\n\nsection UniformGroup\n\nopen Filter Set\n\nvariable {α : Type _} {β : Type _}\n\n#print UniformGroup /-\n/-- A uniform group is a group in which multiplication and inversion are uniformly continuous. -/\nclass UniformGroup (α : Type _) [UniformSpace α] [Group α] : Prop where\n  uniformContinuous_div : UniformContinuous fun p : α × α => p.1 / p.2\n#align uniform_group UniformGroup\n-/\n\n#print UniformAddGroup /-\n/-- A uniform additive group is an additive group in which addition\n  and negation are uniformly continuous.-/\nclass UniformAddGroup (α : Type _) [UniformSpace α] [AddGroup α] : Prop where\n  uniformContinuous_sub : UniformContinuous fun p : α × α => p.1 - p.2\n#align uniform_add_group UniformAddGroup\n-/\n\nattribute [to_additive] UniformGroup\n\n/- warning: uniform_group.mk' -> UniformGroup.mk' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α], (UniformContinuous.{u1, u1} (Prod.{u1, u1} α α) α (Prod.uniformSpace.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))) -> (UniformContinuous.{u1, u1} α α _inst_1 _inst_1 (fun (p : α) => Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) p)) -> (UniformGroup.{u1} α _inst_1 _inst_2)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α], (UniformContinuous.{u1, u1} (Prod.{u1, u1} α α) α (instUniformSpaceProd.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))) -> (UniformContinuous.{u1, u1} α α _inst_1 _inst_1 (fun (p : α) => Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))) p)) -> (UniformGroup.{u1} α _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align uniform_group.mk' UniformGroup.mk'ₓ'. -/\n@[to_additive]\ntheorem UniformGroup.mk' {α} [UniformSpace α] [Group α]\n    (h₁ : UniformContinuous fun p : α × α => p.1 * p.2) (h₂ : UniformContinuous fun p : α => p⁻¹) :\n    UniformGroup α :=\n  ⟨by\n    simpa only [div_eq_mul_inv] using\n      h₁.comp (uniform_continuous_fst.prod_mk (h₂.comp uniformContinuous_snd))⟩\n#align uniform_group.mk' UniformGroup.mk'\n#align uniform_add_group.mk' UniformAddGroup.mk'\n\nvariable [UniformSpace α] [Group α] [UniformGroup α]\n\n/- warning: uniform_continuous_div -> uniformContinuous_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} α α) α (Prod.uniformSpace.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} α α) α (instUniformSpaceProd.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_div uniformContinuous_divₓ'. -/\n@[to_additive]\ntheorem uniformContinuous_div : UniformContinuous fun p : α × α => p.1 / p.2 :=\n  UniformGroup.uniformContinuous_div\n#align uniform_continuous_div uniformContinuous_div\n#align uniform_continuous_sub uniformContinuous_sub\n\n/- warning: uniform_continuous.div -> UniformContinuous.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] {f : β -> α} {g : β -> α}, (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 (fun (x : β) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (f x) (g x)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] {f : β -> α} {g : β -> α}, (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 (fun (x : β) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (f x) (g x)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.div UniformContinuous.divₓ'. -/\n@[to_additive]\ntheorem UniformContinuous.div [UniformSpace β] {f : β → α} {g : β → α} (hf : UniformContinuous f)\n    (hg : UniformContinuous g) : UniformContinuous fun x => f x / g x :=\n  uniformContinuous_div.comp (hf.prod_mk hg)\n#align uniform_continuous.div UniformContinuous.div\n#align uniform_continuous.sub UniformContinuous.sub\n\n/- warning: uniform_continuous.inv -> UniformContinuous.inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] {f : β -> α}, (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 (fun (x : β) => Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) (f x)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] {f : β -> α}, (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 (fun (x : β) => Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))) (f x)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.inv UniformContinuous.invₓ'. -/\n@[to_additive]\ntheorem UniformContinuous.inv [UniformSpace β] {f : β → α} (hf : UniformContinuous f) :\n    UniformContinuous fun x => (f x)⁻¹ :=\n  by\n  have : UniformContinuous fun x => 1 / f x := uniformContinuous_const.div hf\n  simp_all\n#align uniform_continuous.inv UniformContinuous.inv\n#align uniform_continuous.neg UniformContinuous.neg\n\n/- warning: uniform_continuous_inv -> uniformContinuous_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], UniformContinuous.{u1, u1} α α _inst_1 _inst_1 (fun (x : α) => Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) x)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], UniformContinuous.{u1, u1} α α _inst_1 _inst_1 (fun (x : α) => Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))) x)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_inv uniformContinuous_invₓ'. -/\n@[to_additive]\ntheorem uniformContinuous_inv : UniformContinuous fun x : α => x⁻¹ :=\n  uniformContinuous_id.inv\n#align uniform_continuous_inv uniformContinuous_inv\n#align uniform_continuous_neg uniformContinuous_neg\n\n/- warning: uniform_continuous.mul -> UniformContinuous.mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] {f : β -> α} {g : β -> α}, (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 (fun (x : β) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (f x) (g x)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] {f : β -> α} {g : β -> α}, (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} β α _inst_4 _inst_1 (fun (x : β) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (f x) (g x)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.mul UniformContinuous.mulₓ'. -/\n@[to_additive]\ntheorem UniformContinuous.mul [UniformSpace β] {f : β → α} {g : β → α} (hf : UniformContinuous f)\n    (hg : UniformContinuous g) : UniformContinuous fun x => f x * g x :=\n  by\n  have : UniformContinuous fun x => f x / (g x)⁻¹ := hf.div hg.inv\n  simp_all\n#align uniform_continuous.mul UniformContinuous.mul\n#align uniform_continuous.add UniformContinuous.add\n\n/- warning: uniform_continuous_mul -> uniformContinuous_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} α α) α (Prod.uniformSpace.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} α α) α (instUniformSpaceProd.{u1, u1} α α _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_mul uniformContinuous_mulₓ'. -/\n@[to_additive]\ntheorem uniformContinuous_mul : UniformContinuous fun p : α × α => p.1 * p.2 :=\n  uniformContinuous_fst.mul uniformContinuous_snd\n#align uniform_continuous_mul uniformContinuous_mul\n#align uniform_continuous_add uniformContinuous_add\n\n#print UniformContinuous.pow_const /-\n@[to_additive UniformContinuous.const_nsmul]\ntheorem UniformContinuous.pow_const [UniformSpace β] {f : β → α} (hf : UniformContinuous f) :\n    ∀ n : ℕ, UniformContinuous fun x => f x ^ n\n  | 0 => by\n    simp_rw [pow_zero]\n    exact uniformContinuous_const\n  | n + 1 => by\n    simp_rw [pow_succ]\n    exact hf.mul (UniformContinuous.pow_const n)\n#align uniform_continuous.pow_const UniformContinuous.pow_const\n#align uniform_continuous.const_nsmul UniformContinuous.const_nsmul\n-/\n\n#print uniformContinuous_pow_const /-\n@[to_additive uniformContinuous_const_nsmul]\ntheorem uniformContinuous_pow_const (n : ℕ) : UniformContinuous fun x : α => x ^ n :=\n  uniformContinuous_id.pow_const n\n#align uniform_continuous_pow_const uniformContinuous_pow_const\n#align uniform_continuous_const_nsmul uniformContinuous_const_nsmul\n-/\n\n#print UniformContinuous.zpow_const /-\n@[to_additive UniformContinuous.const_zsmul]\ntheorem UniformContinuous.zpow_const [UniformSpace β] {f : β → α} (hf : UniformContinuous f) :\n    ∀ n : ℤ, UniformContinuous fun x => f x ^ n\n  | (n : ℕ) => by\n    simp_rw [zpow_ofNat]\n    exact hf.pow_const _\n  | -[n+1] => by\n    simp_rw [zpow_negSucc]\n    exact (hf.pow_const _).inv\n#align uniform_continuous.zpow_const UniformContinuous.zpow_const\n#align uniform_continuous.const_zsmul UniformContinuous.const_zsmul\n-/\n\n#print uniformContinuous_zpow_const /-\n@[to_additive uniformContinuous_const_zsmul]\ntheorem uniformContinuous_zpow_const (n : ℤ) : UniformContinuous fun x : α => x ^ n :=\n  uniformContinuous_id.zpow_const n\n#align uniform_continuous_zpow_const uniformContinuous_zpow_const\n#align uniform_continuous_const_zsmul uniformContinuous_const_zsmul\n-/\n\n#print UniformGroup.to_topologicalGroup /-\n@[to_additive]\ninstance (priority := 10) UniformGroup.to_topologicalGroup : TopologicalGroup α\n    where\n  continuous_mul := uniformContinuous_mul.Continuous\n  continuous_inv := uniformContinuous_inv.Continuous\n#align uniform_group.to_topological_group UniformGroup.to_topologicalGroup\n#align uniform_add_group.to_topological_add_group UniformAddGroup.to_topologicalAddGroup\n-/\n\n@[to_additive]\ninstance [UniformSpace β] [Group β] [UniformGroup β] : UniformGroup (α × β) :=\n  ⟨((uniformContinuous_fst.comp uniformContinuous_fst).div\n          (uniformContinuous_fst.comp uniformContinuous_snd)).prod_mk\n      ((uniformContinuous_snd.comp uniformContinuous_fst).div\n        (uniformContinuous_snd.comp uniformContinuous_snd))⟩\n\n/- warning: uniformity_translate_mul -> uniformity_translate_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.map.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Prod.mk.{u1, u1} α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.fst.{u1, u1} α α x) a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.snd.{u1, u1} α α x) a)) (uniformity.{u1} α _inst_1)) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] (a : α), Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.map.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Prod.mk.{u1, u1} α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.fst.{u1, u1} α α x) a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Prod.snd.{u1, u1} α α x) a)) (uniformity.{u1} α _inst_1)) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align uniformity_translate_mul uniformity_translate_mulₓ'. -/\n@[to_additive]\ntheorem uniformity_translate_mul (a : α) : ((𝓤 α).map fun x : α × α => (x.1 * a, x.2 * a)) = 𝓤 α :=\n  le_antisymm (uniformContinuous_id.mul uniformContinuous_const)\n    (calc\n      𝓤 α =\n          ((𝓤 α).map fun x : α × α => (x.1 * a⁻¹, x.2 * a⁻¹)).map fun x : α × α =>\n            (x.1 * a, x.2 * a) :=\n        by simp [Filter.map_map, (· ∘ ·)] <;> exact filter.map_id.symm\n      _ ≤ (𝓤 α).map fun x : α × α => (x.1 * a, x.2 * a) :=\n        Filter.map_mono (uniformContinuous_id.mul uniformContinuous_const)\n      )\n#align uniformity_translate_mul uniformity_translate_mul\n#align uniformity_translate_add uniformity_translate_add\n\n/- warning: uniform_embedding_translate_mul -> uniformEmbedding_translate_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] (a : α), UniformEmbedding.{u1, u1} α α _inst_1 _inst_1 (fun (x : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) x a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] (a : α), UniformEmbedding.{u1, u1} α α _inst_1 _inst_1 (fun (x : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) x a)\nCase conversion may be inaccurate. Consider using '#align uniform_embedding_translate_mul uniformEmbedding_translate_mulₓ'. -/\n/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:132:4: warning: unsupported: rw with cfg: { occs := occurrences.pos[occurrences.pos] «expr[ ,]»([1]) } -/\n@[to_additive]\ntheorem uniformEmbedding_translate_mul (a : α) : UniformEmbedding fun x : α => x * a :=\n  { comap_uniformity := by\n      rw [← uniformity_translate_mul a, comap_map]\n      rintro ⟨p₁, p₂⟩ ⟨q₁, q₂⟩\n      simp (config := { contextual := true }) [Prod.eq_iff_fst_eq_snd_eq]\n    inj := mul_left_injective a }\n#align uniform_embedding_translate_mul uniformEmbedding_translate_mul\n#align uniform_embedding_translate_add uniformEmbedding_translate_add\n\nnamespace MulOpposite\n\n@[to_additive]\ninstance : UniformGroup αᵐᵒᵖ :=\n  ⟨uniformContinuous_op.comp\n      ((uniformContinuous_unop.comp uniformContinuous_snd).inv.mul <|\n        uniformContinuous_unop.comp uniformContinuous_fst)⟩\n\nend MulOpposite\n\nnamespace Subgroup\n\n@[to_additive]\ninstance (S : Subgroup α) : UniformGroup S :=\n  ⟨uniformContinuous_comap'\n      (uniformContinuous_div.comp <|\n        uniformContinuous_subtype_val.Prod_map uniformContinuous_subtype_val)⟩\n\nend Subgroup\n\nsection LatticeOps\n\nvariable [Group β]\n\n/- warning: uniform_group_Inf -> uniformGroup_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} [_inst_4 : Group.{u1} β] {us : Set.{u1} (UniformSpace.{u1} β)}, (forall (u : UniformSpace.{u1} β), (Membership.Mem.{u1, u1} (UniformSpace.{u1} β) (Set.{u1} (UniformSpace.{u1} β)) (Set.hasMem.{u1} (UniformSpace.{u1} β)) u us) -> (UniformGroup.{u1} β u _inst_4)) -> (UniformGroup.{u1} β (InfSet.infₛ.{u1} (UniformSpace.{u1} β) (UniformSpace.hasInf.{u1} β) us) _inst_4)\nbut is expected to have type\n  forall {β : Type.{u1}} [_inst_4 : Group.{u1} β] {us : Set.{u1} (UniformSpace.{u1} β)}, (forall (u : UniformSpace.{u1} β), (Membership.mem.{u1, u1} (UniformSpace.{u1} β) (Set.{u1} (UniformSpace.{u1} β)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} β)) u us) -> (UniformGroup.{u1} β u _inst_4)) -> (UniformGroup.{u1} β (InfSet.infₛ.{u1} (UniformSpace.{u1} β) (instInfSetUniformSpace.{u1} β) us) _inst_4)\nCase conversion may be inaccurate. Consider using '#align uniform_group_Inf uniformGroup_infₛₓ'. -/\n@[to_additive]\ntheorem uniformGroup_infₛ {us : Set (UniformSpace β)} (h : ∀ u ∈ us, @UniformGroup β u _) :\n    @UniformGroup β (infₛ us) _ :=\n  {\n    uniformContinuous_div :=\n      uniformContinuous_infₛ_rng fun u hu =>\n        uniformContinuous_infₛ_dom₂ hu hu (@UniformGroup.uniformContinuous_div β u _ (h u hu)) }\n#align uniform_group_Inf uniformGroup_infₛ\n#align uniform_add_group_Inf uniformAddGroup_infₛ\n\n/- warning: uniform_group_infi -> uniformGroup_infᵢ is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} [_inst_4 : Group.{u1} β] {ι : Sort.{u2}} {us' : ι -> (UniformSpace.{u1} β)}, (forall (i : ι), UniformGroup.{u1} β (us' i) _inst_4) -> (UniformGroup.{u1} β (infᵢ.{u1, u2} (UniformSpace.{u1} β) (UniformSpace.hasInf.{u1} β) ι (fun (i : ι) => us' i)) _inst_4)\nbut is expected to have type\n  forall {β : Type.{u1}} [_inst_4 : Group.{u1} β] {ι : Sort.{u2}} {us' : ι -> (UniformSpace.{u1} β)}, (forall (i : ι), UniformGroup.{u1} β (us' i) _inst_4) -> (UniformGroup.{u1} β (infᵢ.{u1, u2} (UniformSpace.{u1} β) (instInfSetUniformSpace.{u1} β) ι (fun (i : ι) => us' i)) _inst_4)\nCase conversion may be inaccurate. Consider using '#align uniform_group_infi uniformGroup_infᵢₓ'. -/\n@[to_additive]\ntheorem uniformGroup_infᵢ {ι : Sort _} {us' : ι → UniformSpace β}\n    (h' : ∀ i, @UniformGroup β (us' i) _) : @UniformGroup β (⨅ i, us' i) _ :=\n  by\n  rw [← infₛ_range]\n  exact uniformGroup_infₛ (set.forall_range_iff.mpr h')\n#align uniform_group_infi uniformGroup_infᵢ\n#align uniform_add_group_infi uniformAddGroup_infᵢ\n\n#print uniformGroup_inf /-\n@[to_additive]\ntheorem uniformGroup_inf {u₁ u₂ : UniformSpace β} (h₁ : @UniformGroup β u₁ _)\n    (h₂ : @UniformGroup β u₂ _) : @UniformGroup β (u₁ ⊓ u₂) _ :=\n  by\n  rw [inf_eq_infᵢ]\n  refine' uniformGroup_infᵢ fun b => _\n  cases b <;> assumption\n#align uniform_group_inf uniformGroup_inf\n#align uniform_add_group_inf uniformAddGroup_inf\n-/\n\n/- warning: uniform_group_comap -> uniformGroup_comap is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} [_inst_4 : Group.{u1} β] {γ : Type.{u2}} [_inst_5 : Group.{u2} γ] {u : UniformSpace.{u2} γ} [_inst_6 : UniformGroup.{u2} γ u _inst_5] {F : Type.{u3}} [_inst_7 : MonoidHomClass.{u3, u1, u2} F β γ (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (Group.toDivInvMonoid.{u1} β _inst_4))) (Monoid.toMulOneClass.{u2} γ (DivInvMonoid.toMonoid.{u2} γ (Group.toDivInvMonoid.{u2} γ _inst_5)))] (f : F), UniformGroup.{u1} β (UniformSpace.comap.{u1, u2} β γ (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => β -> γ) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F β (fun (_x : β) => γ) (MulHomClass.toFunLike.{u3, u1, u2} F β γ (MulOneClass.toHasMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (Group.toDivInvMonoid.{u1} β _inst_4)))) (MulOneClass.toHasMul.{u2} γ (Monoid.toMulOneClass.{u2} γ (DivInvMonoid.toMonoid.{u2} γ (Group.toDivInvMonoid.{u2} γ _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F β γ (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (Group.toDivInvMonoid.{u1} β _inst_4))) (Monoid.toMulOneClass.{u2} γ (DivInvMonoid.toMonoid.{u2} γ (Group.toDivInvMonoid.{u2} γ _inst_5))) _inst_7))) f) u) _inst_4\nbut is expected to have type\n  forall {β : Type.{u1}} [_inst_4 : Group.{u1} β] {γ : Type.{u3}} [_inst_5 : Group.{u3} γ] {u : UniformSpace.{u3} γ} [_inst_6 : UniformGroup.{u3} γ u _inst_5] {F : Type.{u2}} [_inst_7 : MonoidHomClass.{u2, u1, u3} F β γ (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (Group.toDivInvMonoid.{u1} β _inst_4))) (Monoid.toMulOneClass.{u3} γ (DivInvMonoid.toMonoid.{u3} γ (Group.toDivInvMonoid.{u3} γ _inst_5)))] (f : F), UniformGroup.{u1} β (UniformSpace.comap.{u1, u3} β γ (FunLike.coe.{succ u2, succ u1, succ u3} F β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) _x) (MulHomClass.toFunLike.{u2, u1, u3} F β γ (MulOneClass.toMul.{u1} β (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (Group.toDivInvMonoid.{u1} β _inst_4)))) (MulOneClass.toMul.{u3} γ (Monoid.toMulOneClass.{u3} γ (DivInvMonoid.toMonoid.{u3} γ (Group.toDivInvMonoid.{u3} γ _inst_5)))) (MonoidHomClass.toMulHomClass.{u2, u1, u3} F β γ (Monoid.toMulOneClass.{u1} β (DivInvMonoid.toMonoid.{u1} β (Group.toDivInvMonoid.{u1} β _inst_4))) (Monoid.toMulOneClass.{u3} γ (DivInvMonoid.toMonoid.{u3} γ (Group.toDivInvMonoid.{u3} γ _inst_5))) _inst_7)) f) u) _inst_4\nCase conversion may be inaccurate. Consider using '#align uniform_group_comap uniformGroup_comapₓ'. -/\n@[to_additive]\ntheorem uniformGroup_comap {γ : Type _} [Group γ] {u : UniformSpace γ} [UniformGroup γ] {F : Type _}\n    [MonoidHomClass F β γ] (f : F) : @UniformGroup β (u.comap f) _ :=\n  {\n    uniformContinuous_div := by\n      letI : UniformSpace β := u.comap f\n      refine' uniformContinuous_comap' _\n      simp_rw [Function.comp, map_div]\n      change UniformContinuous ((fun p : γ × γ => p.1 / p.2) ∘ Prod.map f f)\n      exact\n        uniform_continuous_div.comp (uniform_continuous_comap.prod_map uniformContinuous_comap) }\n#align uniform_group_comap uniformGroup_comap\n#align uniform_add_group_comap uniformAddGroup_comap\n\nend LatticeOps\n\nsection\n\nvariable (α)\n\n/- warning: uniformity_eq_comap_nhds_one -> uniformity_eq_comap_nhds_one is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.snd.{u1, u1} α α x) (Prod.fst.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.snd.{u1, u1} α α x) (Prod.fst.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_nhds_one uniformity_eq_comap_nhds_oneₓ'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_nhds_one : 𝓤 α = comap (fun x : α × α => x.2 / x.1) (𝓝 (1 : α)) :=\n  by\n  rw [nhds_eq_comap_uniformity, Filter.comap_comap]\n  refine' le_antisymm (Filter.map_le_iff_le_comap.1 _) _\n  · intro s hs\n    rcases mem_uniformity_of_uniformContinuous_invariant uniformContinuous_div hs with ⟨t, ht, hts⟩\n    refine' mem_map.2 (mem_of_superset ht _)\n    rintro ⟨a, b⟩\n    simpa [subset_def] using hts a b a\n  · intro s hs\n    rcases mem_uniformity_of_uniformContinuous_invariant uniformContinuous_mul hs with ⟨t, ht, hts⟩\n    refine' ⟨_, ht, _⟩\n    rintro ⟨a, b⟩\n    simpa [subset_def] using hts 1 (b / a) a\n#align uniformity_eq_comap_nhds_one uniformity_eq_comap_nhds_one\n#align uniformity_eq_comap_nhds_zero uniformity_eq_comap_nhds_zero\n\n/- warning: uniformity_eq_comap_nhds_one_swapped -> uniformity_eq_comap_nhds_one_swapped is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.fst.{u1, u1} α α x) (Prod.snd.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))))\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.fst.{u1, u1} α α x) (Prod.snd.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_nhds_one_swapped uniformity_eq_comap_nhds_one_swappedₓ'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_nhds_one_swapped :\n    𝓤 α = comap (fun x : α × α => x.1 / x.2) (𝓝 (1 : α)) :=\n  by\n  rw [← comap_swap_uniformity, uniformity_eq_comap_nhds_one, comap_comap, (· ∘ ·)]\n  rfl\n#align uniformity_eq_comap_nhds_one_swapped uniformity_eq_comap_nhds_one_swapped\n#align uniformity_eq_comap_nhds_zero_swapped uniformity_eq_comap_nhds_zero_swapped\n\n/- warning: uniform_group.ext -> UniformGroup.ext is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_4 : Group.{u1} G] {u : UniformSpace.{u1} G} {v : UniformSpace.{u1} G}, (UniformGroup.{u1} G u _inst_4) -> (UniformGroup.{u1} G v _inst_4) -> (Eq.{succ u1} (Filter.{u1} G) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G u) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_4)))))))) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G v) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_4))))))))) -> (Eq.{succ u1} (UniformSpace.{u1} G) u v)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_4 : Group.{u1} G] {u : UniformSpace.{u1} G} {v : UniformSpace.{u1} G}, (UniformGroup.{u1} G u _inst_4) -> (UniformGroup.{u1} G v _inst_4) -> (Eq.{succ u1} (Filter.{u1} G) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G u) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_4))))))) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G v) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_4)))))))) -> (Eq.{succ u1} (UniformSpace.{u1} G) u v)\nCase conversion may be inaccurate. Consider using '#align uniform_group.ext UniformGroup.extₓ'. -/\n@[to_additive]\ntheorem UniformGroup.ext {G : Type _} [Group G] {u v : UniformSpace G} (hu : @UniformGroup G u _)\n    (hv : @UniformGroup G v _)\n    (h : @nhds _ u.toTopologicalSpace 1 = @nhds _ v.toTopologicalSpace 1) : u = v :=\n  uniformSpace_eq <| by\n    rw [@uniformity_eq_comap_nhds_one _ u _ hu, @uniformity_eq_comap_nhds_one _ v _ hv, h]\n#align uniform_group.ext UniformGroup.ext\n#align uniform_add_group.ext UniformAddGroup.ext\n\n/- warning: uniform_group.ext_iff -> UniformGroup.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_4 : Group.{u1} G] {u : UniformSpace.{u1} G} {v : UniformSpace.{u1} G}, (UniformGroup.{u1} G u _inst_4) -> (UniformGroup.{u1} G v _inst_4) -> (Iff (Eq.{succ u1} (UniformSpace.{u1} G) u v) (Eq.{succ u1} (Filter.{u1} G) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G u) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_4)))))))) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G v) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_4))))))))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_4 : Group.{u1} G] {u : UniformSpace.{u1} G} {v : UniformSpace.{u1} G}, (UniformGroup.{u1} G u _inst_4) -> (UniformGroup.{u1} G v _inst_4) -> (Iff (Eq.{succ u1} (UniformSpace.{u1} G) u v) (Eq.{succ u1} (Filter.{u1} G) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G u) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_4))))))) (nhds.{u1} G (UniformSpace.toTopologicalSpace.{u1} G v) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_4)))))))))\nCase conversion may be inaccurate. Consider using '#align uniform_group.ext_iff UniformGroup.ext_iffₓ'. -/\n@[to_additive]\ntheorem UniformGroup.ext_iff {G : Type _} [Group G] {u v : UniformSpace G}\n    (hu : @UniformGroup G u _) (hv : @UniformGroup G v _) :\n    u = v ↔ @nhds _ u.toTopologicalSpace 1 = @nhds _ v.toTopologicalSpace 1 :=\n  ⟨fun h => h ▸ rfl, hu.ext hv⟩\n#align uniform_group.ext_iff UniformGroup.ext_iff\n#align uniform_add_group.ext_iff UniformAddGroup.ext_iff\n\nvariable {α}\n\n/- warning: uniform_group.uniformity_countably_generated -> UniformGroup.uniformity_countably_generated is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : Filter.IsCountablyGenerated.{u1} α (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))))))], Filter.IsCountablyGenerated.{u1} (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : Filter.IsCountablyGenerated.{u1} α (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))))))], Filter.IsCountablyGenerated.{u1} (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align uniform_group.uniformity_countably_generated UniformGroup.uniformity_countably_generatedₓ'. -/\n@[to_additive]\ntheorem UniformGroup.uniformity_countably_generated [(𝓝 (1 : α)).IsCountablyGenerated] :\n    (𝓤 α).IsCountablyGenerated :=\n  by\n  rw [uniformity_eq_comap_nhds_one]\n  exact Filter.comap.isCountablyGenerated _ _\n#align uniform_group.uniformity_countably_generated UniformGroup.uniformity_countably_generated\n#align uniform_add_group.uniformity_countably_generated UniformAddGroup.uniformity_countably_generated\n\nopen MulOpposite\n\n/- warning: uniformity_eq_comap_inv_mul_nhds_one -> uniformity_eq_comap_inv_mul_nhds_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) (Prod.fst.{u1, u1} α α x)) (Prod.snd.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))) (Prod.fst.{u1, u1} α α x)) (Prod.snd.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_inv_mul_nhds_one uniformity_eq_comap_inv_mul_nhds_oneₓ'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_inv_mul_nhds_one :\n    𝓤 α = comap (fun x : α × α => x.1⁻¹ * x.2) (𝓝 (1 : α)) :=\n  by\n  rw [← comap_uniformity_mulOpposite, uniformity_eq_comap_nhds_one, ← op_one, ← comap_unop_nhds,\n    comap_comap, comap_comap]\n  simp [(· ∘ ·)]\n#align uniformity_eq_comap_inv_mul_nhds_one uniformity_eq_comap_inv_mul_nhds_one\n#align uniformity_eq_comap_neg_add_nhds_zero uniformity_eq_comap_neg_add_nhds_zero\n\n/- warning: uniformity_eq_comap_inv_mul_nhds_one_swapped -> uniformity_eq_comap_inv_mul_nhds_one_swapped is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) (Prod.snd.{u1, u1} α α x)) (Prod.fst.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} α α) α (fun (x : Prod.{u1, u1} α α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))) (Prod.snd.{u1, u1} α α x)) (Prod.fst.{u1, u1} α α x)) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_inv_mul_nhds_one_swapped uniformity_eq_comap_inv_mul_nhds_one_swappedₓ'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_inv_mul_nhds_one_swapped :\n    𝓤 α = comap (fun x : α × α => x.2⁻¹ * x.1) (𝓝 (1 : α)) :=\n  by\n  rw [← comap_swap_uniformity, uniformity_eq_comap_inv_mul_nhds_one, comap_comap, (· ∘ ·)]\n  rfl\n#align uniformity_eq_comap_inv_mul_nhds_one_swapped uniformity_eq_comap_inv_mul_nhds_one_swapped\n#align uniformity_eq_comap_neg_add_nhds_zero_swapped uniformity_eq_comap_neg_add_nhds_zero_swapped\n\nend\n\n/- warning: filter.has_basis.uniformity_of_nhds_one -> Filter.HasBasis.uniformity_of_nhds_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.snd.{u1, u1} α α x) (Prod.fst.{u1, u1} α α x)) (U i))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.snd.{u1, u1} α α x) (Prod.fst.{u1, u1} α α x)) (U i))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniformity_of_nhds_one Filter.HasBasis.uniformity_of_nhds_oneₓ'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one {ι} {p : ι → Prop} {U : ι → Set α}\n    (h : (𝓝 (1 : α)).HasBasis p U) : (𝓤 α).HasBasis p fun i => { x : α × α | x.2 / x.1 ∈ U i } :=\n  by\n  rw [uniformity_eq_comap_nhds_one]\n  exact h.comap _\n#align filter.has_basis.uniformity_of_nhds_one Filter.HasBasis.uniformity_of_nhds_one\n#align filter.has_basis.uniformity_of_nhds_zero Filter.HasBasis.uniformity_of_nhds_zero\n\n/- warning: filter.has_basis.uniformity_of_nhds_one_inv_mul -> Filter.HasBasis.uniformity_of_nhds_one_inv_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) (Prod.fst.{u1, u1} α α x)) (Prod.snd.{u1, u1} α α x)) (U i))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))) (Prod.fst.{u1, u1} α α x)) (Prod.snd.{u1, u1} α α x)) (U i))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniformity_of_nhds_one_inv_mul Filter.HasBasis.uniformity_of_nhds_one_inv_mulₓ'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one_inv_mul {ι} {p : ι → Prop} {U : ι → Set α}\n    (h : (𝓝 (1 : α)).HasBasis p U) : (𝓤 α).HasBasis p fun i => { x : α × α | x.1⁻¹ * x.2 ∈ U i } :=\n  by\n  rw [uniformity_eq_comap_inv_mul_nhds_one]\n  exact h.comap _\n#align filter.has_basis.uniformity_of_nhds_one_inv_mul Filter.HasBasis.uniformity_of_nhds_one_inv_mul\n#align filter.has_basis.uniformity_of_nhds_zero_neg_add Filter.HasBasis.uniformity_of_nhds_zero_neg_add\n\n/- warning: filter.has_basis.uniformity_of_nhds_one_swapped -> Filter.HasBasis.uniformity_of_nhds_one_swapped is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.fst.{u1, u1} α α x) (Prod.snd.{u1, u1} α α x)) (U i))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Prod.fst.{u1, u1} α α x) (Prod.snd.{u1, u1} α α x)) (U i))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniformity_of_nhds_one_swapped Filter.HasBasis.uniformity_of_nhds_one_swappedₓ'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one_swapped {ι} {p : ι → Prop} {U : ι → Set α}\n    (h : (𝓝 (1 : α)).HasBasis p U) : (𝓤 α).HasBasis p fun i => { x : α × α | x.1 / x.2 ∈ U i } :=\n  by\n  rw [uniformity_eq_comap_nhds_one_swapped]\n  exact h.comap _\n#align filter.has_basis.uniformity_of_nhds_one_swapped Filter.HasBasis.uniformity_of_nhds_one_swapped\n#align filter.has_basis.uniformity_of_nhds_zero_swapped Filter.HasBasis.uniformity_of_nhds_zero_swapped\n\n/- warning: filter.has_basis.uniformity_of_nhds_one_inv_mul_swapped -> Filter.HasBasis.uniformity_of_nhds_one_inv_mul_swapped is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) (Prod.snd.{u1, u1} α α x)) (Prod.fst.{u1, u1} α α x)) (U i))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Sort.{u2}} {p : ι -> Prop} {U : ι -> (Set.{u1} α)}, (Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))) (Prod.snd.{u1, u1} α α x)) (Prod.fst.{u1, u1} α α x)) (U i))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniformity_of_nhds_one_inv_mul_swapped Filter.HasBasis.uniformity_of_nhds_one_inv_mul_swappedₓ'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one_inv_mul_swapped {ι} {p : ι → Prop} {U : ι → Set α}\n    (h : (𝓝 (1 : α)).HasBasis p U) : (𝓤 α).HasBasis p fun i => { x : α × α | x.2⁻¹ * x.1 ∈ U i } :=\n  by\n  rw [uniformity_eq_comap_inv_mul_nhds_one_swapped]\n  exact h.comap _\n#align filter.has_basis.uniformity_of_nhds_one_inv_mul_swapped Filter.HasBasis.uniformity_of_nhds_one_inv_mul_swapped\n#align filter.has_basis.uniformity_of_nhds_zero_neg_add_swapped Filter.HasBasis.uniformity_of_nhds_zero_neg_add_swapped\n\n/- warning: group_separation_rel -> group_separationRel is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] (x : α) (y : α), Iff (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) (separationRel.{u1} α _inst_1)) (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) x y) (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.hasSingleton.{u1} α) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] (x : α) (y : α), Iff (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) (separationRel.{u1} α _inst_1)) (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) x y) (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (Singleton.singleton.{u1, u1} α (Set.{u1} α) (Set.instSingletonSet.{u1} α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align group_separation_rel group_separationRelₓ'. -/\n@[to_additive]\ntheorem group_separationRel (x y : α) : (x, y) ∈ separationRel α ↔ x / y ∈ closure ({1} : Set α) :=\n  have : Embedding fun a => a * (y / x) := (uniformEmbedding_translate_mul (y / x)).Embedding\n  show (x, y) ∈ ⋂₀ (𝓤 α).sets ↔ x / y ∈ closure ({1} : Set α)\n    by\n    rw [this.closure_eq_preimage_closure_image, uniformity_eq_comap_nhds_one α, sInter_comap_sets]\n    simp [mem_closure_iff_nhds, inter_singleton_nonempty, sub_eq_add_neg, add_assoc]\n#align group_separation_rel group_separationRel\n#align add_group_separation_rel addGroup_separationRel\n\n/- warning: uniform_continuous_of_tendsto_one -> uniformContinuous_of_tendsto_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} β] [_inst_5 : Group.{u2} β] [_inst_6 : UniformGroup.{u2} β _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))] {f : hom}, (Filter.Tendsto.{u1, u2} α β (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7))) f) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))) (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_4) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (MulOneClass.toHasOne.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))))))))) -> (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7))) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} β] [_inst_5 : Group.{u2} β] [_inst_6 : UniformGroup.{u2} β _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))] {f : hom}, (Filter.Tendsto.{u1, u2} α β (FunLike.coe.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7)) f) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))) (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_4) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (InvOneClass.toOne.{u2} β (DivInvOneMonoid.toInvOneClass.{u2} β (DivisionMonoid.toDivInvOneMonoid.{u2} β (Group.toDivisionMonoid.{u2} β _inst_5)))))))) -> (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (FunLike.coe.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7)) f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_of_tendsto_one uniformContinuous_of_tendsto_oneₓ'. -/\n@[to_additive]\ntheorem uniformContinuous_of_tendsto_one {hom : Type _} [UniformSpace β] [Group β] [UniformGroup β]\n    [MonoidHomClass hom α β] {f : hom} (h : Tendsto f (𝓝 1) (𝓝 1)) : UniformContinuous f :=\n  by\n  have :\n    ((fun x : β × β => x.2 / x.1) ∘ fun x : α × α => (f x.1, f x.2)) = fun x : α × α =>\n      f (x.2 / x.1) :=\n    by simp only [map_div]\n  rw [UniformContinuous, uniformity_eq_comap_nhds_one α, uniformity_eq_comap_nhds_one β,\n    tendsto_comap_iff, this]\n  exact tendsto.comp h tendsto_comap\n#align uniform_continuous_of_tendsto_one uniformContinuous_of_tendsto_one\n#align uniform_continuous_of_tendsto_zero uniformContinuous_of_tendsto_zero\n\n/- warning: uniform_continuous_of_continuous_at_one -> uniformContinuous_of_continuousAt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} β] [_inst_5 : Group.{u2} β] [_inst_6 : UniformGroup.{u2} β _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))] (f : hom), (ContinuousAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_4) (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7))) f) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))) -> (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7))) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} β] [_inst_5 : Group.{u2} β] [_inst_6 : UniformGroup.{u2} β _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))] (f : hom), (ContinuousAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_4) (FunLike.coe.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7)) f) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))) -> (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (FunLike.coe.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) _inst_7)) f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_of_continuous_at_one uniformContinuous_of_continuousAt_oneₓ'. -/\n/-- A group homomorphism (a bundled morphism of a type that implements `monoid_hom_class`) between\ntwo uniform groups is uniformly continuous provided that it is continuous at one. See also\n`continuous_of_continuous_at_one`. -/\n@[to_additive\n      \"An additive group homomorphism (a bundled morphism of a type that implements\\n`add_monoid_hom_class`) between two uniform additive groups is uniformly continuous provided that it\\nis continuous at zero. See also `continuous_of_continuous_at_zero`.\"]\ntheorem uniformContinuous_of_continuousAt_one {hom : Type _} [UniformSpace β] [Group β]\n    [UniformGroup β] [MonoidHomClass hom α β] (f : hom) (hf : ContinuousAt f 1) :\n    UniformContinuous f :=\n  uniformContinuous_of_tendsto_one (by simpa using hf.tendsto)\n#align uniform_continuous_of_continuous_at_one uniformContinuous_of_continuousAt_one\n#align uniform_continuous_of_continuous_at_zero uniformContinuous_of_continuousAt_zero\n\n/- warning: monoid_hom.uniform_continuous_of_continuous_at_one -> MonoidHom.uniformContinuous_of_continuousAt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] [_inst_5 : Group.{u2} β] [_inst_6 : UniformGroup.{u2} β _inst_4 _inst_5] (f : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))), (ContinuousAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_4) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) f) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))))) -> (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (fun (_x : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} β] [_inst_5 : Group.{u2} β] [_inst_6 : UniformGroup.{u2} β _inst_4 _inst_5] (f : MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))), (ContinuousAt.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_4) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) α β (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) (MonoidHom.monoidHomClass.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))))) f) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))))) -> (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) α β (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) (MonoidHom.monoidHomClass.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))))) f))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.uniform_continuous_of_continuous_at_one MonoidHom.uniformContinuous_of_continuousAt_oneₓ'. -/\n@[to_additive]\ntheorem MonoidHom.uniformContinuous_of_continuousAt_one [UniformSpace β] [Group β] [UniformGroup β]\n    (f : α →* β) (hf : ContinuousAt f 1) : UniformContinuous f :=\n  uniformContinuous_of_continuousAt_one f hf\n#align monoid_hom.uniform_continuous_of_continuous_at_one MonoidHom.uniformContinuous_of_continuousAt_one\n#align add_monoid_hom.uniform_continuous_of_continuous_at_zero AddMonoidHom.uniformContinuous_of_continuousAt_zero\n\n/- warning: uniform_group.uniform_continuous_iff_open_ker -> UniformGroup.uniformContinuous_iff_open_ker is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} β] [_inst_5 : DiscreteTopology.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_4)] [_inst_6 : Group.{u2} β] [_inst_7 : UniformGroup.{u2} β _inst_4 _inst_6] [_inst_8 : MonoidHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6)))] {f : hom}, Iff (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6))) _inst_8))) f)) (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subgroup.{u1} α _inst_2) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Subgroup.{u1} α _inst_2) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Subgroup.{u1} α _inst_2) (Set.{u1} α) (SetLike.Set.hasCoeT.{u1, u1} (Subgroup.{u1} α _inst_2) α (Subgroup.setLike.{u1} α _inst_2)))) (MonoidHom.ker.{u1, u2} α _inst_2 β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6))) ((fun (a : Type.{u3}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{succ u3, max (succ u2) (succ u1)} a b] => self.0) hom (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6)))) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} hom (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6)))) (CoeTCₓ.coe.{succ u3, max (succ u2) (succ u1)} hom (MonoidHom.{u1, u2} α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6)))) (MonoidHom.hasCoeT.{u1, u2, u3} α β hom (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6))) _inst_8))) f))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} β] [_inst_5 : DiscreteTopology.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_4)] [_inst_6 : Group.{u2} β] [_inst_7 : UniformGroup.{u2} β _inst_4 _inst_6] [_inst_8 : MonoidHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6)))] {f : hom}, Iff (UniformContinuous.{u1, u2} α β _inst_1 _inst_4 (FunLike.coe.{succ u3, succ u1, succ u2} hom α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom α β (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MulOneClass.toMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom α β (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6))) _inst_8)) f)) (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (SetLike.coe.{u1, u1} (Subgroup.{u1} α _inst_2) α (Subgroup.instSetLikeSubgroup.{u1} α _inst_2) (MonoidHom.ker.{u1, u2} α _inst_2 β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6))) (MonoidHomClass.toMonoidHom.{u1, u2, u3} α β hom (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_6))) _inst_8 f))))\nCase conversion may be inaccurate. Consider using '#align uniform_group.uniform_continuous_iff_open_ker UniformGroup.uniformContinuous_iff_open_kerₓ'. -/\n/-- A homomorphism from a uniform group to a discrete uniform group is continuous if and only if\nits kernel is open. -/\n@[to_additive\n      \"A homomorphism from a uniform additive group to a discrete uniform additive group is\\ncontinuous if and only if its kernel is open.\"]\ntheorem UniformGroup.uniformContinuous_iff_open_ker {hom : Type _} [UniformSpace β]\n    [DiscreteTopology β] [Group β] [UniformGroup β] [MonoidHomClass hom α β] {f : hom} :\n    UniformContinuous f ↔ IsOpen ((f : α →* β).ker : Set α) :=\n  by\n  refine' ⟨fun hf => _, fun hf => _⟩\n  · apply (isOpen_discrete ({1} : Set β)).Preimage (UniformContinuous.continuous hf)\n  · apply uniformContinuous_of_continuousAt_one\n    rw [ContinuousAt, nhds_discrete β, map_one, tendsto_pure]\n    exact hf.mem_nhds (map_one f)\n#align uniform_group.uniform_continuous_iff_open_ker UniformGroup.uniformContinuous_iff_open_ker\n#align uniform_add_group.uniform_continuous_iff_open_ker UniformAddGroup.uniformContinuous_iff_open_ker\n\n#print uniformContinuous_monoidHom_of_continuous /-\n@[to_additive]\ntheorem uniformContinuous_monoidHom_of_continuous {hom : Type _} [UniformSpace β] [Group β]\n    [UniformGroup β] [MonoidHomClass hom α β] {f : hom} (h : Continuous f) : UniformContinuous f :=\n  uniformContinuous_of_tendsto_one <|\n    suffices Tendsto f (𝓝 1) (𝓝 (f 1)) by rwa [map_one] at this\n    h.Tendsto 1\n#align uniform_continuous_monoid_hom_of_continuous uniformContinuous_monoidHom_of_continuous\n#align uniform_continuous_add_monoid_hom_of_continuous uniformContinuous_addMonoidHom_of_continuous\n-/\n\n/- warning: cauchy_seq.mul -> CauchySeq.mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α} {v : ι -> α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 v) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (ι -> α) (ι -> α) (ι -> α) (instHMul.{max u2 u1} (ι -> α) (Pi.instMul.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))) u v))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α} {v : ι -> α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 v) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (ι -> α) (ι -> α) (ι -> α) (instHMul.{max u1 u2} (ι -> α) (Pi.instMul.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))) u v))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.mul CauchySeq.mulₓ'. -/\n@[to_additive]\ntheorem CauchySeq.mul {ι : Type _} [SemilatticeSup ι] {u v : ι → α} (hu : CauchySeq u)\n    (hv : CauchySeq v) : CauchySeq (u * v) :=\n  uniformContinuous_mul.comp_cauchySeq (hu.Prod hv)\n#align cauchy_seq.mul CauchySeq.mul\n#align cauchy_seq.add CauchySeq.add\n\n/- warning: cauchy_seq.mul_const -> CauchySeq.mul_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α} {x : α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (fun (n : ι) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (u n) x))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α} {x : α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (fun (n : ι) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) (u n) x))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.mul_const CauchySeq.mul_constₓ'. -/\n@[to_additive]\ntheorem CauchySeq.mul_const {ι : Type _} [SemilatticeSup ι] {u : ι → α} {x : α} (hu : CauchySeq u) :\n    CauchySeq fun n => u n * x :=\n  (uniformContinuous_id.mul uniformContinuous_const).comp_cauchySeq hu\n#align cauchy_seq.mul_const CauchySeq.mul_const\n#align cauchy_seq.add_const CauchySeq.add_const\n\n/- warning: cauchy_seq.const_mul -> CauchySeq.const_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α} {x : α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (fun (n : ι) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) x (u n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α} {x : α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (fun (n : ι) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) x (u n)))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.const_mul CauchySeq.const_mulₓ'. -/\n@[to_additive]\ntheorem CauchySeq.const_mul {ι : Type _} [SemilatticeSup ι] {u : ι → α} {x : α} (hu : CauchySeq u) :\n    CauchySeq fun n => x * u n :=\n  (uniformContinuous_const.mul uniformContinuous_id).comp_cauchySeq hu\n#align cauchy_seq.const_mul CauchySeq.const_mul\n#align cauchy_seq.const_add CauchySeq.const_add\n\n/- warning: cauchy_seq.inv -> CauchySeq.inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (Inv.inv.{max u2 u1} (ι -> α) (Pi.instInv.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) u))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} ι] {u : ι -> α}, (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} α ι _inst_1 _inst_4 (Inv.inv.{max u2 u1} (ι -> α) (Pi.instInv.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2))))) u))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.inv CauchySeq.invₓ'. -/\n@[to_additive]\ntheorem CauchySeq.inv {ι : Type _} [SemilatticeSup ι] {u : ι → α} (h : CauchySeq u) :\n    CauchySeq u⁻¹ :=\n  uniformContinuous_inv.comp_cauchySeq h\n#align cauchy_seq.inv CauchySeq.inv\n#align cauchy_seq.neg CauchySeq.neg\n\n/- warning: totally_bounded_iff_subset_finite_Union_nhds_one -> totallyBounded_iff_subset_finite_unionᵢ_nhds_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {s : Set.{u1} α}, Iff (TotallyBounded.{u1} α _inst_1 s) (forall (U : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) U (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))))))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (y : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t) => SMul.smul.{u1, u1} α (Set.{u1} α) (Set.smulSet.{u1, u1} α α (Mul.toSMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))) y U)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {s : Set.{u1} α}, Iff (TotallyBounded.{u1} α _inst_1 s) (forall (U : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) U (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (InvOneClass.toOne.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_2)))))))) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Set.Finite.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.unionᵢ.{u1, succ u1} α α (fun (y : α) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) (fun (H : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t) => HSMul.hSMul.{u1, u1, u1} α (Set.{u1} α) (Set.{u1} α) (instHSMul.{u1, u1} α (Set.{u1} α) (Set.smulSet.{u1, u1} α α (MulAction.toSMul.{u1, u1} α α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)) (Monoid.toMulAction.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))) y U)))))))\nCase conversion may be inaccurate. Consider using '#align totally_bounded_iff_subset_finite_Union_nhds_one totallyBounded_iff_subset_finite_unionᵢ_nhds_oneₓ'. -/\n@[to_additive]\ntheorem totallyBounded_iff_subset_finite_unionᵢ_nhds_one {s : Set α} :\n    TotallyBounded s ↔ ∀ U ∈ 𝓝 (1 : α), ∃ t : Set α, t.Finite ∧ s ⊆ ⋃ y ∈ t, y • U :=\n  (𝓝 (1 : α)).basis_sets.uniformity_of_nhds_one_inv_mul_swapped.totallyBounded_iff.trans <| by\n    simp [← preimage_smul_inv, preimage]\n#align totally_bounded_iff_subset_finite_Union_nhds_one totallyBounded_iff_subset_finite_unionᵢ_nhds_one\n#align totally_bounded_iff_subset_finite_Union_nhds_zero totallyBounded_iff_subset_finite_unionᵢ_nhds_zero\n\nsection UniformConvergence\n\nvariable {ι : Type _} {l : Filter ι} {l' : Filter β} {f f' : ι → β → α} {g g' : β → α} {s : Set β}\n\n/- warning: tendsto_uniformly_on_filter.mul -> TendstoUniformlyOnFilter.mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {l' : Filter.{u2} β} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformlyOnFilter.{u2, u1, u3} β α ι _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} β α ι _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} β α ι _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max u3 u2 u1} (ι -> β -> α) (Pi.instMul.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))))) f f') (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (β -> α) (β -> α) (β -> α) (instHMul.{max u2 u1} (β -> α) (Pi.instMul.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))) g g') l l')\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {l' : Filter.{u3} β} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformlyOnFilter.{u3, u2, u1} β α ι _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} β α ι _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} β α ι _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instMul.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))))) f f') (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (β -> α) (β -> α) (β -> α) (instHMul.{max u2 u3} (β -> α) (Pi.instMul.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))))) g g') l l')\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.mul TendstoUniformlyOnFilter.mulₓ'. -/\n@[to_additive]\ntheorem TendstoUniformlyOnFilter.mul (hf : TendstoUniformlyOnFilter f g l l')\n    (hf' : TendstoUniformlyOnFilter f' g' l l') : TendstoUniformlyOnFilter (f * f') (g * g') l l' :=\n  fun u hu =>\n  ((uniformContinuous_mul.comp_tendstoUniformlyOnFilter (hf.Prod hf')) u hu).diag_of_prod_left\n#align tendsto_uniformly_on_filter.mul TendstoUniformlyOnFilter.mul\n#align tendsto_uniformly_on_filter.add TendstoUniformlyOnFilter.add\n\n/- warning: tendsto_uniformly_on_filter.div -> TendstoUniformlyOnFilter.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {l' : Filter.{u2} β} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformlyOnFilter.{u2, u1, u3} β α ι _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} β α ι _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} β α ι _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max u3 u2 u1} (ι -> β -> α) (Pi.instDiv.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) f f') (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (β -> α) (β -> α) (β -> α) (instHDiv.{max u2 u1} (β -> α) (Pi.instDiv.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) g g') l l')\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {l' : Filter.{u3} β} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformlyOnFilter.{u3, u2, u1} β α ι _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} β α ι _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} β α ι _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instDiv.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))) f f') (HDiv.hDiv.{max u2 u3, max u2 u3, max u2 u3} (β -> α) (β -> α) (β -> α) (instHDiv.{max u2 u3} (β -> α) (Pi.instDiv.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))) g g') l l')\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.div TendstoUniformlyOnFilter.divₓ'. -/\n@[to_additive]\ntheorem TendstoUniformlyOnFilter.div (hf : TendstoUniformlyOnFilter f g l l')\n    (hf' : TendstoUniformlyOnFilter f' g' l l') : TendstoUniformlyOnFilter (f / f') (g / g') l l' :=\n  fun u hu =>\n  ((uniformContinuous_div.comp_tendstoUniformlyOnFilter (hf.Prod hf')) u hu).diag_of_prod_left\n#align tendsto_uniformly_on_filter.div TendstoUniformlyOnFilter.div\n#align tendsto_uniformly_on_filter.sub TendstoUniformlyOnFilter.sub\n\n/- warning: tendsto_uniformly_on.mul -> TendstoUniformlyOn.mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α} {s : Set.{u2} β}, (TendstoUniformlyOn.{u2, u1, u3} β α ι _inst_1 f g l s) -> (TendstoUniformlyOn.{u2, u1, u3} β α ι _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u2, u1, u3} β α ι _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max u3 u2 u1} (ι -> β -> α) (Pi.instMul.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))))) f f') (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (β -> α) (β -> α) (β -> α) (instHMul.{max u2 u1} (β -> α) (Pi.instMul.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))) g g') l s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α} {s : Set.{u3} β}, (TendstoUniformlyOn.{u3, u2, u1} β α ι _inst_1 f g l s) -> (TendstoUniformlyOn.{u3, u2, u1} β α ι _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u3, u2, u1} β α ι _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instMul.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))))) f f') (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (β -> α) (β -> α) (β -> α) (instHMul.{max u2 u3} (β -> α) (Pi.instMul.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))))) g g') l s)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on.mul TendstoUniformlyOn.mulₓ'. -/\n@[to_additive]\ntheorem TendstoUniformlyOn.mul (hf : TendstoUniformlyOn f g l s)\n    (hf' : TendstoUniformlyOn f' g' l s) : TendstoUniformlyOn (f * f') (g * g') l s := fun u hu =>\n  ((uniformContinuous_mul.comp_tendstoUniformlyOn (hf.Prod hf')) u hu).diag_of_prod\n#align tendsto_uniformly_on.mul TendstoUniformlyOn.mul\n#align tendsto_uniformly_on.add TendstoUniformlyOn.add\n\n/- warning: tendsto_uniformly_on.div -> TendstoUniformlyOn.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α} {s : Set.{u2} β}, (TendstoUniformlyOn.{u2, u1, u3} β α ι _inst_1 f g l s) -> (TendstoUniformlyOn.{u2, u1, u3} β α ι _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u2, u1, u3} β α ι _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max u3 u2 u1} (ι -> β -> α) (Pi.instDiv.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) f f') (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (β -> α) (β -> α) (β -> α) (instHDiv.{max u2 u1} (β -> α) (Pi.instDiv.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) g g') l s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α} {s : Set.{u3} β}, (TendstoUniformlyOn.{u3, u2, u1} β α ι _inst_1 f g l s) -> (TendstoUniformlyOn.{u3, u2, u1} β α ι _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u3, u2, u1} β α ι _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instDiv.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))) f f') (HDiv.hDiv.{max u2 u3, max u2 u3, max u2 u3} (β -> α) (β -> α) (β -> α) (instHDiv.{max u2 u3} (β -> α) (Pi.instDiv.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))) g g') l s)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on.div TendstoUniformlyOn.divₓ'. -/\n@[to_additive]\ntheorem TendstoUniformlyOn.div (hf : TendstoUniformlyOn f g l s)\n    (hf' : TendstoUniformlyOn f' g' l s) : TendstoUniformlyOn (f / f') (g / g') l s := fun u hu =>\n  ((uniformContinuous_div.comp_tendstoUniformlyOn (hf.Prod hf')) u hu).diag_of_prod\n#align tendsto_uniformly_on.div TendstoUniformlyOn.div\n#align tendsto_uniformly_on.sub TendstoUniformlyOn.sub\n\n/- warning: tendsto_uniformly.mul -> TendstoUniformly.mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformly.{u2, u1, u3} β α ι _inst_1 f g l) -> (TendstoUniformly.{u2, u1, u3} β α ι _inst_1 f' g' l) -> (TendstoUniformly.{u2, u1, u3} β α ι _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max u3 u2 u1} (ι -> β -> α) (Pi.instMul.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))))) f f') (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (β -> α) (β -> α) (β -> α) (instHMul.{max u2 u1} (β -> α) (Pi.instMul.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))))) g g') l)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformly.{u3, u2, u1} β α ι _inst_1 f g l) -> (TendstoUniformly.{u3, u2, u1} β α ι _inst_1 f' g' l) -> (TendstoUniformly.{u3, u2, u1} β α ι _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instMul.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))))) f f') (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (β -> α) (β -> α) (β -> α) (instHMul.{max u2 u3} (β -> α) (Pi.instMul.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))))) g g') l)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly.mul TendstoUniformly.mulₓ'. -/\n@[to_additive]\ntheorem TendstoUniformly.mul (hf : TendstoUniformly f g l) (hf' : TendstoUniformly f' g' l) :\n    TendstoUniformly (f * f') (g * g') l := fun u hu =>\n  ((uniformContinuous_mul.comp_tendstoUniformly (hf.Prod hf')) u hu).diag_of_prod\n#align tendsto_uniformly.mul TendstoUniformly.mul\n#align tendsto_uniformly.add TendstoUniformly.add\n\n/- warning: tendsto_uniformly.div -> TendstoUniformly.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformly.{u2, u1, u3} β α ι _inst_1 f g l) -> (TendstoUniformly.{u2, u1, u3} β α ι _inst_1 f' g' l) -> (TendstoUniformly.{u2, u1, u3} β α ι _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max u3 u2 u1} (ι -> β -> α) (Pi.instDiv.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) f f') (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (β -> α) (β -> α) (β -> α) (instHDiv.{max u2 u1} (β -> α) (Pi.instDiv.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) g g') l)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {g : β -> α} {g' : β -> α}, (TendstoUniformly.{u3, u2, u1} β α ι _inst_1 f g l) -> (TendstoUniformly.{u3, u2, u1} β α ι _inst_1 f' g' l) -> (TendstoUniformly.{u3, u2, u1} β α ι _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instDiv.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))) f f') (HDiv.hDiv.{max u2 u3, max u2 u3, max u2 u3} (β -> α) (β -> α) (β -> α) (instHDiv.{max u2 u3} (β -> α) (Pi.instDiv.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))) g g') l)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly.div TendstoUniformly.divₓ'. -/\n@[to_additive]\ntheorem TendstoUniformly.div (hf : TendstoUniformly f g l) (hf' : TendstoUniformly f' g' l) :\n    TendstoUniformly (f / f') (g / g') l := fun u hu =>\n  ((uniformContinuous_div.comp_tendstoUniformly (hf.Prod hf')) u hu).diag_of_prod\n#align tendsto_uniformly.div TendstoUniformly.div\n#align tendsto_uniformly.sub TendstoUniformly.sub\n\n/- warning: uniform_cauchy_seq_on.mul -> UniformCauchySeqOn.mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {s : Set.{u2} β}, (UniformCauchySeqOn.{u2, u1, u3} β α ι _inst_1 f l s) -> (UniformCauchySeqOn.{u2, u1, u3} β α ι _inst_1 f' l s) -> (UniformCauchySeqOn.{u2, u1, u3} β α ι _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max u3 u2 u1} (ι -> β -> α) (Pi.instMul.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))))) f f') l s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {s : Set.{u3} β}, (UniformCauchySeqOn.{u3, u2, u1} β α ι _inst_1 f l s) -> (UniformCauchySeqOn.{u3, u2, u1} β α ι _inst_1 f' l s) -> (UniformCauchySeqOn.{u3, u2, u1} β α ι _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHMul.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instMul.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instMul.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))))) f f') l s)\nCase conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.mul UniformCauchySeqOn.mulₓ'. -/\n@[to_additive]\ntheorem UniformCauchySeqOn.mul (hf : UniformCauchySeqOn f l s) (hf' : UniformCauchySeqOn f' l s) :\n    UniformCauchySeqOn (f * f') l s := fun u hu => by\n  simpa using (uniform_continuous_mul.comp_uniform_cauchy_seq_on (hf.prod' hf')) u hu\n#align uniform_cauchy_seq_on.mul UniformCauchySeqOn.mul\n#align uniform_cauchy_seq_on.add UniformCauchySeqOn.add\n\n/- warning: uniform_cauchy_seq_on.div -> UniformCauchySeqOn.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : UniformGroup.{u1} α _inst_1 _inst_2] {ι : Type.{u3}} {l : Filter.{u3} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {s : Set.{u2} β}, (UniformCauchySeqOn.{u2, u1, u3} β α ι _inst_1 f l s) -> (UniformCauchySeqOn.{u2, u1, u3} β α ι _inst_1 f' l s) -> (UniformCauchySeqOn.{u2, u1, u3} β α ι _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max u3 u2 u1} (ι -> β -> α) (Pi.instDiv.{u3, max u2 u1} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toHasDiv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))))) f f') l s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : UniformGroup.{u2} α _inst_1 _inst_2] {ι : Type.{u1}} {l : Filter.{u1} ι} {f : ι -> β -> α} {f' : ι -> β -> α} {s : Set.{u3} β}, (UniformCauchySeqOn.{u3, u2, u1} β α ι _inst_1 f l s) -> (UniformCauchySeqOn.{u3, u2, u1} β α ι _inst_1 f' l s) -> (UniformCauchySeqOn.{u3, u2, u1} β α ι _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (ι -> β -> α) (ι -> β -> α) (ι -> β -> α) (instHDiv.{max (max u2 u3) u1} (ι -> β -> α) (Pi.instDiv.{u1, max u2 u3} ι (fun (ᾰ : ι) => β -> α) (fun (i : ι) => Pi.instDiv.{u3, u2} β (fun (ᾰ : β) => α) (fun (i : β) => DivInvMonoid.toDiv.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))))) f f') l s)\nCase conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.div UniformCauchySeqOn.divₓ'. -/\n@[to_additive]\ntheorem UniformCauchySeqOn.div (hf : UniformCauchySeqOn f l s) (hf' : UniformCauchySeqOn f' l s) :\n    UniformCauchySeqOn (f / f') l s := fun u hu => by\n  simpa using (uniform_continuous_div.comp_uniform_cauchy_seq_on (hf.prod' hf')) u hu\n#align uniform_cauchy_seq_on.div UniformCauchySeqOn.div\n#align uniform_cauchy_seq_on.sub UniformCauchySeqOn.sub\n\nend UniformConvergence\n\nend UniformGroup\n\nsection TopologicalGroup\n\nopen Filter\n\nvariable (G : Type _) [Group G] [TopologicalSpace G] [TopologicalGroup G]\n\n#print TopologicalGroup.toUniformSpace /-\n/-- The right uniformity on a topological group (as opposed to the left uniformity).\n\nWarning: in general the right and left uniformities do not coincide and so one does not obtain a\n`uniform_group` structure. Two important special cases where they _do_ coincide are for\ncommutative groups (see `topological_comm_group_is_uniform`) and for compact groups (see\n`topological_group_is_uniform_of_compact_space`). -/\n@[to_additive\n      \"The right uniformity on a topological additive group (as opposed to the left\\nuniformity).\\n\\nWarning: in general the right and left uniformities do not coincide and so one does not obtain a\\n`uniform_add_group` structure. Two important special cases where they _do_ coincide are for\\ncommutative additive groups (see `topological_add_comm_group_is_uniform`) and for compact\\nadditive groups (see `topological_add_comm_group_is_uniform_of_compact_space`).\"]\ndef TopologicalGroup.toUniformSpace : UniformSpace G\n    where\n  uniformity := comap (fun p : G × G => p.2 / p.1) (𝓝 1)\n  refl := by\n    refine' map_le_iff_le_comap.1 (le_trans _ (pure_le_nhds 1)) <;>\n      simp (config := { contextual := true }) [Set.subset_def]\n  symm :=\n    by\n    suffices\n      tendsto (fun p : G × G => (p.2 / p.1)⁻¹) (comap (fun p : G × G => p.2 / p.1) (𝓝 1)) (𝓝 1⁻¹) by\n      simpa [tendsto_comap_iff]\n    exact tendsto.comp (tendsto.inv tendsto_id) tendsto_comap\n  comp := by\n    intro D H\n    rw [mem_lift'_sets]\n    · rcases H with ⟨U, U_nhds, U_sub⟩\n      rcases exists_nhds_one_split U_nhds with ⟨V, ⟨V_nhds, V_sum⟩⟩\n      exists (fun p : G × G => p.2 / p.1) ⁻¹' V\n      have H :\n        (fun p : G × G => p.2 / p.1) ⁻¹' V ∈ comap (fun p : G × G => p.2 / p.1) (𝓝 (1 : G)) := by\n        exists V, V_nhds <;> rfl\n      exists H\n      have comp_rel_sub :\n        compRel ((fun p : G × G => p.2 / p.1) ⁻¹' V) ((fun p => p.2 / p.1) ⁻¹' V) ⊆\n          (fun p : G × G => p.2 / p.1) ⁻¹' U :=\n        by\n        intro p p_comp_rel\n        rcases p_comp_rel with ⟨z, ⟨Hz1, Hz2⟩⟩\n        simpa using V_sum _ Hz2 _ Hz1\n      exact Set.Subset.trans comp_rel_sub U_sub\n    · exact monotone_id.comp_rel monotone_id\n  isOpen_uniformity := by\n    intro S\n    let S' x := { p : G × G | p.1 = x → p.2 ∈ S }\n    show IsOpen S ↔ ∀ x : G, x ∈ S → S' x ∈ comap (fun p : G × G => p.2 / p.1) (𝓝 (1 : G))\n    rw [isOpen_iff_mem_nhds]\n    refine' forall₂_congr fun a ha => _\n    rw [← nhds_translation_div, mem_comap, mem_comap]\n    refine' exists₂_congr fun t ht => _\n    show (fun y : G => y / a) ⁻¹' t ⊆ S ↔ (fun p : G × G => p.snd / p.fst) ⁻¹' t ⊆ S' a\n    constructor\n    · rintro h ⟨x, y⟩ hx rfl\n      exact h hx\n    · rintro h x hx\n      exact @h (a, x) hx rfl\n#align topological_group.to_uniform_space TopologicalGroup.toUniformSpace\n#align topological_add_group.to_uniform_space TopologicalAddGroup.toUniformSpace\n-/\n\nattribute [local instance] TopologicalGroup.toUniformSpace\n\n/- warning: uniformity_eq_comap_nhds_one' -> uniformity_eq_comap_nhds_one' is a dubious translation:\nlean 3 declaration is\n  forall (G : Type.{u1}) [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} G G)) (uniformity.{u1} G (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3)) (Filter.comap.{u1, u1} (Prod.{u1, u1} G G) G (fun (p : Prod.{u1, u1} G G) => HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Prod.snd.{u1, u1} G G p) (Prod.fst.{u1, u1} G G p)) (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))))))\nbut is expected to have type\n  forall (G : Type.{u1}) [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} G G)) (uniformity.{u1} G (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3)) (Filter.comap.{u1, u1} (Prod.{u1, u1} G G) G (fun (p : Prod.{u1, u1} G G) => HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Prod.snd.{u1, u1} G G p) (Prod.fst.{u1, u1} G G p)) (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_nhds_one' uniformity_eq_comap_nhds_one'ₓ'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_nhds_one' : 𝓤 G = comap (fun p : G × G => p.2 / p.1) (𝓝 (1 : G)) :=\n  rfl\n#align uniformity_eq_comap_nhds_one' uniformity_eq_comap_nhds_one'\n#align uniformity_eq_comap_nhds_zero' uniformity_eq_comap_nhds_zero'\n\n#print topologicalGroup_is_uniform_of_compactSpace /-\n@[to_additive]\ntheorem topologicalGroup_is_uniform_of_compactSpace [CompactSpace G] : UniformGroup G :=\n  ⟨by\n    apply CompactSpace.uniformContinuous_of_continuous\n    exact continuous_div'⟩\n#align topological_group_is_uniform_of_compact_space topologicalGroup_is_uniform_of_compactSpace\n#align topological_add_group_is_uniform_of_compact_space topologicalAddGroup_is_uniform_of_compactSpace\n-/\n\nvariable {G}\n\n/- warning: subgroup.is_closed_of_discrete -> Subgroup.isClosed_of_discrete is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] [_inst_4 : T2Space.{u1} G _inst_2] {H : Subgroup.{u1} G _inst_1} [_inst_5 : DiscreteTopology.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) H) (Subtype.topologicalSpace.{u1} G (fun (x : G) => Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x H) _inst_2)], IsClosed.{u1} G _inst_2 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subgroup.{u1} G _inst_1) (Set.{u1} G) (HasLiftT.mk.{succ u1, succ u1} (Subgroup.{u1} G _inst_1) (Set.{u1} G) (CoeTCₓ.coe.{succ u1, succ u1} (Subgroup.{u1} G _inst_1) (Set.{u1} G) (SetLike.Set.hasCoeT.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)))) H)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] [_inst_4 : T2Space.{u1} G _inst_2] {H : Subgroup.{u1} G _inst_1} [_inst_5 : DiscreteTopology.{u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x H)) (instTopologicalSpaceSubtype.{u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x H) _inst_2)], IsClosed.{u1} G _inst_2 (SetLike.coe.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1) H)\nCase conversion may be inaccurate. Consider using '#align subgroup.is_closed_of_discrete Subgroup.isClosed_of_discreteₓ'. -/\n@[to_additive]\ninstance Subgroup.isClosed_of_discrete [T2Space G] {H : Subgroup G} [DiscreteTopology H] :\n    IsClosed (H : Set G) :=\n  by\n  obtain ⟨V, V_in, VH⟩ : ∃ (V : Set G)(hV : V ∈ 𝓝 (1 : G)), V ∩ (H : Set G) = {1}\n  exact nhds_inter_eq_singleton_of_mem_discrete H.one_mem\n  haveI : SeparatedSpace G := separated_iff_t2.mpr ‹_›\n  have : (fun p : G × G => p.2 / p.1) ⁻¹' V ∈ 𝓤 G := preimage_mem_comap V_in\n  apply isClosed_of_spaced_out this\n  intro h h_in h' h'_in\n  contrapose!\n  rintro (hyp : h' / h ∈ V)\n  have : h' / h ∈ ({1} : Set G) := VH ▸ Set.mem_inter hyp (H.div_mem h'_in h_in)\n  exact (eq_of_div_eq_one this).symm\n#align subgroup.is_closed_of_discrete Subgroup.isClosed_of_discrete\n#align add_subgroup.is_closed_of_discrete AddSubgroup.isClosed_of_discrete\n\n/- warning: topological_group.tendsto_uniformly_iff -> TopologicalGroup.tendstoUniformly_iff is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u2}} {α : Type.{u3}} (F : ι -> α -> G) (f : α -> G) (p : Filter.{u2} ι), Iff (TendstoUniformly.{u3, u1, u2} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) F f p) (forall (u : Set.{u1} G), (Membership.Mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (Filter.hasMem.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))))))) -> (Filter.Eventually.{u2} ι (fun (i : ι) => forall (a : α), Membership.Mem.{u1, u1} G (Set.{u1} G) (Set.hasMem.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u) p))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u3}} {α : Type.{u2}} (F : ι -> α -> G) (f : α -> G) (p : Filter.{u3} ι), Iff (TendstoUniformly.{u2, u1, u3} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) F f p) (forall (u : Set.{u1} G), (Membership.mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (instMembershipSetFilter.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))))))) -> (Filter.Eventually.{u3} ι (fun (i : ι) => forall (a : α), Membership.mem.{u1, u1} G (Set.{u1} G) (Set.instMembershipSet.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u) p))\nCase conversion may be inaccurate. Consider using '#align topological_group.tendsto_uniformly_iff TopologicalGroup.tendstoUniformly_iffₓ'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoUniformly_iff {ι α : Type _} (F : ι → α → G) (f : α → G)\n    (p : Filter ι) :\n    @TendstoUniformly α G ι (TopologicalGroup.toUniformSpace G) F f p ↔\n      ∀ u ∈ 𝓝 (1 : G), ∀ᶠ i in p, ∀ a, F i a / f a ∈ u :=\n  ⟨fun h u hu => h _ ⟨u, hu, fun _ => id⟩, fun h v ⟨u, hu, hv⟩ =>\n    mem_of_superset (h u hu) fun i hi a => hv (hi a)⟩\n#align topological_group.tendsto_uniformly_iff TopologicalGroup.tendstoUniformly_iff\n#align topological_add_group.tendsto_uniformly_iff TopologicalAddGroup.tendstoUniformly_iff\n\n/- warning: topological_group.tendsto_uniformly_on_iff -> TopologicalGroup.tendstoUniformlyOn_iff is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u2}} {α : Type.{u3}} (F : ι -> α -> G) (f : α -> G) (p : Filter.{u2} ι) (s : Set.{u3} α), Iff (TendstoUniformlyOn.{u3, u1, u2} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) F f p s) (forall (u : Set.{u1} G), (Membership.Mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (Filter.hasMem.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))))))) -> (Filter.Eventually.{u2} ι (fun (i : ι) => forall (a : α), (Membership.Mem.{u3, u3} α (Set.{u3} α) (Set.hasMem.{u3} α) a s) -> (Membership.Mem.{u1, u1} G (Set.{u1} G) (Set.hasMem.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u)) p))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u3}} {α : Type.{u2}} (F : ι -> α -> G) (f : α -> G) (p : Filter.{u3} ι) (s : Set.{u2} α), Iff (TendstoUniformlyOn.{u2, u1, u3} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) F f p s) (forall (u : Set.{u1} G), (Membership.mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (instMembershipSetFilter.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))))))) -> (Filter.Eventually.{u3} ι (fun (i : ι) => forall (a : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a s) -> (Membership.mem.{u1, u1} G (Set.{u1} G) (Set.instMembershipSet.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u)) p))\nCase conversion may be inaccurate. Consider using '#align topological_group.tendsto_uniformly_on_iff TopologicalGroup.tendstoUniformlyOn_iffₓ'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoUniformlyOn_iff {ι α : Type _} (F : ι → α → G) (f : α → G)\n    (p : Filter ι) (s : Set α) :\n    @TendstoUniformlyOn α G ι (TopologicalGroup.toUniformSpace G) F f p s ↔\n      ∀ u ∈ 𝓝 (1 : G), ∀ᶠ i in p, ∀ a ∈ s, F i a / f a ∈ u :=\n  ⟨fun h u hu => h _ ⟨u, hu, fun _ => id⟩, fun h v ⟨u, hu, hv⟩ =>\n    mem_of_superset (h u hu) fun i hi a ha => hv (hi a ha)⟩\n#align topological_group.tendsto_uniformly_on_iff TopologicalGroup.tendstoUniformlyOn_iff\n#align topological_add_group.tendsto_uniformly_on_iff TopologicalAddGroup.tendstoUniformlyOn_iff\n\n/- warning: topological_group.tendsto_locally_uniformly_iff -> TopologicalGroup.tendstoLocallyUniformly_iff is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u2}} {α : Type.{u3}} [_inst_4 : TopologicalSpace.{u3} α] (F : ι -> α -> G) (f : α -> G) (p : Filter.{u2} ι), Iff (TendstoLocallyUniformly.{u3, u1, u2} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) _inst_4 F f p) (forall (u : Set.{u1} G), (Membership.Mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (Filter.hasMem.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))))))) -> (forall (x : α), Exists.{succ u3} (Set.{u3} α) (fun (t : Set.{u3} α) => Exists.{0} (Membership.Mem.{u3, u3} (Set.{u3} α) (Filter.{u3} α) (Filter.hasMem.{u3} α) t (nhds.{u3} α _inst_4 x)) (fun (H : Membership.Mem.{u3, u3} (Set.{u3} α) (Filter.{u3} α) (Filter.hasMem.{u3} α) t (nhds.{u3} α _inst_4 x)) => Filter.Eventually.{u2} ι (fun (i : ι) => forall (a : α), (Membership.Mem.{u3, u3} α (Set.{u3} α) (Set.hasMem.{u3} α) a t) -> (Membership.Mem.{u1, u1} G (Set.{u1} G) (Set.hasMem.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u)) p))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u3}} {α : Type.{u2}} [_inst_4 : TopologicalSpace.{u2} α] (F : ι -> α -> G) (f : α -> G) (p : Filter.{u3} ι), Iff (TendstoLocallyUniformly.{u2, u1, u3} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) _inst_4 F f p) (forall (u : Set.{u1} G), (Membership.mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (instMembershipSetFilter.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))))))) -> (forall (x : α), Exists.{succ u2} (Set.{u2} α) (fun (t : Set.{u2} α) => And (Membership.mem.{u2, u2} (Set.{u2} α) (Filter.{u2} α) (instMembershipSetFilter.{u2} α) t (nhds.{u2} α _inst_4 x)) (Filter.Eventually.{u3} ι (fun (i : ι) => forall (a : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a t) -> (Membership.mem.{u1, u1} G (Set.{u1} G) (Set.instMembershipSet.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u)) p))))\nCase conversion may be inaccurate. Consider using '#align topological_group.tendsto_locally_uniformly_iff TopologicalGroup.tendstoLocallyUniformly_iffₓ'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoLocallyUniformly_iff {ι α : Type _} [TopologicalSpace α]\n    (F : ι → α → G) (f : α → G) (p : Filter ι) :\n    @TendstoLocallyUniformly α G ι (TopologicalGroup.toUniformSpace G) _ F f p ↔\n      ∀ u ∈ 𝓝 (1 : G), ∀ (x : α), ∃ t ∈ 𝓝 x, ∀ᶠ i in p, ∀ a ∈ t, F i a / f a ∈ u :=\n  ⟨fun h u hu => h _ ⟨u, hu, fun _ => id⟩, fun h v ⟨u, hu, hv⟩ x =>\n    Exists.imp (fun a => Exists.imp fun ha hp => mem_of_superset hp fun i hi a ha => hv (hi a ha))\n      (h u hu x)⟩\n#align topological_group.tendsto_locally_uniformly_iff TopologicalGroup.tendstoLocallyUniformly_iff\n#align topological_add_group.tendsto_locally_uniformly_iff TopologicalAddGroup.tendstoLocallyUniformly_iff\n\n/- warning: topological_group.tendsto_locally_uniformly_on_iff -> TopologicalGroup.tendstoLocallyUniformlyOn_iff is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u2}} {α : Type.{u3}} [_inst_4 : TopologicalSpace.{u3} α] (F : ι -> α -> G) (f : α -> G) (p : Filter.{u2} ι) (s : Set.{u3} α), Iff (TendstoLocallyUniformlyOn.{u3, u1, u2} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) _inst_4 F f p s) (forall (u : Set.{u1} G), (Membership.Mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (Filter.hasMem.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))))))) -> (forall (x : α), (Membership.Mem.{u3, u3} α (Set.{u3} α) (Set.hasMem.{u3} α) x s) -> (Exists.{succ u3} (Set.{u3} α) (fun (t : Set.{u3} α) => Exists.{0} (Membership.Mem.{u3, u3} (Set.{u3} α) (Filter.{u3} α) (Filter.hasMem.{u3} α) t (nhdsWithin.{u3} α _inst_4 x s)) (fun (H : Membership.Mem.{u3, u3} (Set.{u3} α) (Filter.{u3} α) (Filter.hasMem.{u3} α) t (nhdsWithin.{u3} α _inst_4 x s)) => Filter.Eventually.{u2} ι (fun (i : ι) => forall (a : α), (Membership.Mem.{u3, u3} α (Set.{u3} α) (Set.hasMem.{u3} α) a t) -> (Membership.Mem.{u1, u1} G (Set.{u1} G) (Set.hasMem.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u)) p)))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 _inst_1] {ι : Type.{u3}} {α : Type.{u2}} [_inst_4 : TopologicalSpace.{u2} α] (F : ι -> α -> G) (f : α -> G) (p : Filter.{u3} ι) (s : Set.{u2} α), Iff (TendstoLocallyUniformlyOn.{u2, u1, u3} α G ι (TopologicalGroup.toUniformSpace.{u1} G _inst_1 _inst_2 _inst_3) _inst_4 F f p s) (forall (u : Set.{u1} G), (Membership.mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (instMembershipSetFilter.{u1} G) u (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))))))) -> (forall (x : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x s) -> (Exists.{succ u2} (Set.{u2} α) (fun (t : Set.{u2} α) => And (Membership.mem.{u2, u2} (Set.{u2} α) (Filter.{u2} α) (instMembershipSetFilter.{u2} α) t (nhdsWithin.{u2} α _inst_4 x s)) (Filter.Eventually.{u3} ι (fun (i : ι) => forall (a : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) a t) -> (Membership.mem.{u1, u1} G (Set.{u1} G) (Set.instMembershipSet.{u1} G) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (F i a) (f a)) u)) p)))))\nCase conversion may be inaccurate. Consider using '#align topological_group.tendsto_locally_uniformly_on_iff TopologicalGroup.tendstoLocallyUniformlyOn_iffₓ'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoLocallyUniformlyOn_iff {ι α : Type _} [TopologicalSpace α]\n    (F : ι → α → G) (f : α → G) (p : Filter ι) (s : Set α) :\n    @TendstoLocallyUniformlyOn α G ι (TopologicalGroup.toUniformSpace G) _ F f p s ↔\n      ∀ u ∈ 𝓝 (1 : G), ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∀ᶠ i in p, ∀ a ∈ t, F i a / f a ∈ u :=\n  ⟨fun h u hu => h _ ⟨u, hu, fun _ => id⟩, fun h v ⟨u, hu, hv⟩ x =>\n    (Exists.imp fun a => Exists.imp fun ha hp => mem_of_superset hp fun i hi a ha => hv (hi a ha)) ∘\n      h u hu x⟩\n#align topological_group.tendsto_locally_uniformly_on_iff TopologicalGroup.tendstoLocallyUniformlyOn_iff\n#align topological_add_group.tendsto_locally_uniformly_on_iff TopologicalAddGroup.tendstoLocallyUniformlyOn_iff\n\nend TopologicalGroup\n\nsection TopologicalCommGroup\n\nuniverse u v w x\n\nopen Filter\n\nvariable (G : Type _) [CommGroup G] [TopologicalSpace G] [TopologicalGroup G]\n\nsection\n\nattribute [local instance] TopologicalGroup.toUniformSpace\n\nvariable {G}\n\n#print comm_topologicalGroup_is_uniform /-\n@[to_additive]\ntheorem comm_topologicalGroup_is_uniform : UniformGroup G :=\n  by\n  have :\n    Tendsto\n      ((fun p : G × G => p.1 / p.2) ∘ fun p : (G × G) × G × G => (p.1.2 / p.1.1, p.2.2 / p.2.1))\n      (comap (fun p : (G × G) × G × G => (p.1.2 / p.1.1, p.2.2 / p.2.1)) ((𝓝 1).Prod (𝓝 1)))\n      (𝓝 (1 / 1)) :=\n    (tendsto_fst.div' tendsto_snd).comp tendsto_comap\n  constructor\n  rw [UniformContinuous, uniformity_prod_eq_prod, tendsto_map'_iff, uniformity_eq_comap_nhds_one' G,\n    tendsto_comap_iff, prod_comap_comap_eq]\n  simpa [(· ∘ ·), div_eq_mul_inv, mul_comm, mul_left_comm] using this\n#align topological_comm_group_is_uniform comm_topologicalGroup_is_uniform\n#align topological_add_comm_group_is_uniform comm_topologicalAddGroup_is_uniform\n-/\n\nopen Set\n\n/- warning: topological_group.t2_space_iff_one_closed -> TopologicalGroup.t2Space_iff_one_closed is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : CommGroup.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 (CommGroup.toGroup.{u1} G _inst_1)], Iff (T2Space.{u1} G _inst_2) (IsClosed.{u1} G _inst_2 (Singleton.singleton.{u1, u1} G (Set.{u1} G) (Set.hasSingleton.{u1} G) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G _inst_1))))))))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : CommGroup.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 (CommGroup.toGroup.{u1} G _inst_1)], Iff (T2Space.{u1} G _inst_2) (IsClosed.{u1} G _inst_2 (Singleton.singleton.{u1, u1} G (Set.{u1} G) (Set.instSingletonSet.{u1} G) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (DivisionCommMonoid.toDivisionMonoid.{u1} G (CommGroup.toDivisionCommMonoid.{u1} G _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align topological_group.t2_space_iff_one_closed TopologicalGroup.t2Space_iff_one_closedₓ'. -/\n@[to_additive]\ntheorem TopologicalGroup.t2Space_iff_one_closed : T2Space G ↔ IsClosed ({1} : Set G) :=\n  by\n  haveI : UniformGroup G := comm_topologicalGroup_is_uniform\n  rw [← separated_iff_t2, separatedSpace_iff, ← closure_eq_iff_isClosed]\n  constructor <;> intro h\n  · apply subset.antisymm\n    · intro x x_in\n      have := group_separationRel x 1\n      rw [div_one] at this\n      rw [← this, h] at x_in\n      change x = 1 at x_in\n      simp [x_in]\n    · exact subset_closure\n  · ext p\n    cases' p with x y\n    rw [group_separationRel x, h, mem_singleton_iff, div_eq_one]\n    rfl\n#align topological_group.t2_space_iff_one_closed TopologicalGroup.t2Space_iff_one_closed\n#align topological_add_group.t2_space_iff_zero_closed TopologicalAddGroup.t2Space_iff_zero_closed\n\n/- warning: topological_group.t2_space_of_one_sep -> TopologicalGroup.t2Space_of_one_sep is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : CommGroup.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 (CommGroup.toGroup.{u1} G _inst_1)], (forall (x : G), (Ne.{succ u1} G x (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G _inst_1))))))))) -> (Exists.{succ u1} (Set.{u1} G) (fun (U : Set.{u1} G) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (Filter.hasMem.{u1} G) U (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G _inst_1)))))))))) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (Filter.hasMem.{u1} G) U (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G _inst_1)))))))))) => Not (Membership.Mem.{u1, u1} G (Set.{u1} G) (Set.hasMem.{u1} G) x U))))) -> (T2Space.{u1} G _inst_2)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : CommGroup.{u1} G] [_inst_2 : TopologicalSpace.{u1} G] [_inst_3 : TopologicalGroup.{u1} G _inst_2 (CommGroup.toGroup.{u1} G _inst_1)], (forall (x : G), (Ne.{succ u1} G x (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (DivisionCommMonoid.toDivisionMonoid.{u1} G (CommGroup.toDivisionCommMonoid.{u1} G _inst_1)))))))) -> (Exists.{succ u1} (Set.{u1} G) (fun (U : Set.{u1} G) => And (Membership.mem.{u1, u1} (Set.{u1} G) (Filter.{u1} G) (instMembershipSetFilter.{u1} G) U (nhds.{u1} G _inst_2 (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (DivisionCommMonoid.toDivisionMonoid.{u1} G (CommGroup.toDivisionCommMonoid.{u1} G _inst_1))))))))) (Not (Membership.mem.{u1, u1} G (Set.{u1} G) (Set.instMembershipSet.{u1} G) x U))))) -> (T2Space.{u1} G _inst_2)\nCase conversion may be inaccurate. Consider using '#align topological_group.t2_space_of_one_sep TopologicalGroup.t2Space_of_one_sepₓ'. -/\n@[to_additive]\ntheorem TopologicalGroup.t2Space_of_one_sep (H : ∀ x : G, x ≠ 1 → ∃ U ∈ nhds (1 : G), x ∉ U) :\n    T2Space G :=\n  by\n  rw [TopologicalGroup.t2Space_iff_one_closed, ← isOpen_compl_iff, isOpen_iff_mem_nhds]\n  intro x x_not\n  have : x ≠ 1 := mem_compl_singleton_iff.mp x_not\n  rcases H x this with ⟨U, U_in, xU⟩\n  rw [← nhds_one_symm G] at U_in\n  rcases U_in with ⟨W, W_in, UW⟩\n  rw [← nhds_translation_mul_inv]\n  use W, W_in\n  rw [subset_compl_comm]\n  suffices x⁻¹ ∉ W by simpa\n  exact fun h => xU (UW h)\n#align topological_group.t2_space_of_one_sep TopologicalGroup.t2Space_of_one_sep\n#align topological_add_group.t2_space_of_zero_sep TopologicalAddGroup.t2Space_of_zero_sep\n\nend\n\n#print UniformGroup.toUniformSpace_eq /-\n@[to_additive]\ntheorem UniformGroup.toUniformSpace_eq {G : Type _} [u : UniformSpace G] [Group G]\n    [UniformGroup G] : TopologicalGroup.toUniformSpace G = u :=\n  by\n  ext : 1\n  rw [uniformity_eq_comap_nhds_one' G, uniformity_eq_comap_nhds_one G]\n#align uniform_group.to_uniform_space_eq UniformGroup.toUniformSpace_eq\n#align uniform_add_group.to_uniform_space_eq UniformAddGroup.toUniformSpace_eq\n-/\n\nend TopologicalCommGroup\n\nopen Filter Set Function\n\nsection\n\nvariable {α : Type _} {β : Type _} {hom : Type _}\n\nvariable [TopologicalSpace α] [Group α] [TopologicalGroup α]\n\n-- β is a dense subgroup of α, inclusion is denoted by e\nvariable [TopologicalSpace β] [Group β]\n\nvariable [MonoidHomClass hom β α] {e : hom} (de : DenseInducing e)\n\ninclude de\n\n/- warning: tendsto_div_comap_self -> tendsto_div_comap_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {hom : Type.{u3}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : Group.{u1} α] [_inst_3 : TopologicalGroup.{u1} α _inst_1 _inst_2] [_inst_4 : TopologicalSpace.{u2} β] [_inst_5 : Group.{u2} β] [_inst_6 : MonoidHomClass.{u3, u2, u1} hom β α (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))] {e : hom}, (DenseInducing.{u2, u1} β α _inst_4 _inst_1 (coeFn.{succ u3, max (succ u2) (succ u1)} hom (fun (_x : hom) => β -> α) (FunLike.hasCoeToFun.{succ u3, succ u2, succ u1} hom β (fun (_x : β) => α) (MulHomClass.toFunLike.{u3, u2, u1} hom β α (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MonoidHomClass.toMulHomClass.{u3, u2, u1} hom β α (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) _inst_6))) e)) -> (forall (x₀ : α), Filter.Tendsto.{u2, u2} (Prod.{u2, u2} β β) β (fun (t : Prod.{u2, u2} β β) => HDiv.hDiv.{u2, u2, u2} β β β (instHDiv.{u2} β (DivInvMonoid.toHasDiv.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) (Prod.snd.{u2, u2} β β t) (Prod.fst.{u2, u2} β β t)) (Filter.comap.{u2, u1} (Prod.{u2, u2} β β) (Prod.{u1, u1} α α) (fun (p : Prod.{u2, u2} β β) => Prod.mk.{u1, u1} α α (coeFn.{succ u3, max (succ u2) (succ u1)} hom (fun (_x : hom) => β -> α) (FunLike.hasCoeToFun.{succ u3, succ u2, succ u1} hom β (fun (_x : β) => α) (MulHomClass.toFunLike.{u3, u2, u1} hom β α (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MonoidHomClass.toMulHomClass.{u3, u2, u1} hom β α (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) _inst_6))) e (Prod.fst.{u2, u2} β β p)) (coeFn.{succ u3, max (succ u2) (succ u1)} hom (fun (_x : hom) => β -> α) (FunLike.hasCoeToFun.{succ u3, succ u2, succ u1} hom β (fun (_x : β) => α) (MulHomClass.toFunLike.{u3, u2, u1} hom β α (MulOneClass.toHasMul.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))) (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2)))) (MonoidHomClass.toMulHomClass.{u3, u2, u1} hom β α (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5))) (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_2))) _inst_6))) e (Prod.snd.{u2, u2} β β p))) (nhds.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α _inst_1 _inst_1) (Prod.mk.{u1, u1} α α x₀ x₀))) (nhds.{u2} β _inst_4 (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (MulOneClass.toHasOne.{u2} β (Monoid.toMulOneClass.{u2} β (DivInvMonoid.toMonoid.{u2} β (Group.toDivInvMonoid.{u2} β _inst_5)))))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {hom : Type.{u1}} [_inst_1 : TopologicalSpace.{u2} α] [_inst_2 : Group.{u2} α] [_inst_3 : TopologicalGroup.{u2} α _inst_1 _inst_2] [_inst_4 : TopologicalSpace.{u3} β] [_inst_5 : Group.{u3} β] [_inst_6 : MonoidHomClass.{u1, u3, u2} hom β α (Monoid.toMulOneClass.{u3} β (DivInvMonoid.toMonoid.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5))) (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))] {e : hom}, (DenseInducing.{u3, u2} β α _inst_4 _inst_1 (FunLike.coe.{succ u1, succ u3, succ u2} hom β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => α) _x) (MulHomClass.toFunLike.{u1, u3, u2} hom β α (MulOneClass.toMul.{u3} β (Monoid.toMulOneClass.{u3} β (DivInvMonoid.toMonoid.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5)))) (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} hom β α (Monoid.toMulOneClass.{u3} β (DivInvMonoid.toMonoid.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5))) (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))) _inst_6)) e)) -> (forall (x₀ : α), Filter.Tendsto.{u3, u3} (Prod.{u3, u3} β β) β (fun (t : Prod.{u3, u3} β β) => HDiv.hDiv.{u3, u3, u3} β β β (instHDiv.{u3} β (DivInvMonoid.toDiv.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5))) (Prod.snd.{u3, u3} β β t) (Prod.fst.{u3, u3} β β t)) (Filter.comap.{u3, u2} (Prod.{u3, u3} β β) (Prod.{u2, u2} α α) (fun (p : Prod.{u3, u3} β β) => Prod.mk.{u2, u2} α α (FunLike.coe.{succ u1, succ u3, succ u2} hom β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => α) _x) (MulHomClass.toFunLike.{u1, u3, u2} hom β α (MulOneClass.toMul.{u3} β (Monoid.toMulOneClass.{u3} β (DivInvMonoid.toMonoid.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5)))) (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} hom β α (Monoid.toMulOneClass.{u3} β (DivInvMonoid.toMonoid.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5))) (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))) _inst_6)) e (Prod.fst.{u3, u3} β β p)) (FunLike.coe.{succ u1, succ u3, succ u2} hom β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => α) _x) (MulHomClass.toFunLike.{u1, u3, u2} hom β α (MulOneClass.toMul.{u3} β (Monoid.toMulOneClass.{u3} β (DivInvMonoid.toMonoid.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5)))) (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} hom β α (Monoid.toMulOneClass.{u3} β (DivInvMonoid.toMonoid.{u3} β (Group.toDivInvMonoid.{u3} β _inst_5))) (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_2))) _inst_6)) e (Prod.snd.{u3, u3} β β p))) (nhds.{u2} (Prod.{u2, u2} α α) (instTopologicalSpaceProd.{u2, u2} α α _inst_1 _inst_1) (Prod.mk.{u2, u2} α α x₀ x₀))) (nhds.{u3} β _inst_4 (OfNat.ofNat.{u3} β 1 (One.toOfNat1.{u3} β (InvOneClass.toOne.{u3} β (DivInvOneMonoid.toInvOneClass.{u3} β (DivisionMonoid.toDivInvOneMonoid.{u3} β (Group.toDivisionMonoid.{u3} β _inst_5))))))))\nCase conversion may be inaccurate. Consider using '#align tendsto_div_comap_self tendsto_div_comap_selfₓ'. -/\n@[to_additive]\ntheorem tendsto_div_comap_self (x₀ : α) :\n    Tendsto (fun t : β × β => t.2 / t.1) ((comap fun p : β × β => (e p.1, e p.2)) <| 𝓝 (x₀, x₀))\n      (𝓝 1) :=\n  by\n  have comm :\n    ((fun x : α × α => x.2 / x.1) ∘ fun t : β × β => (e t.1, e t.2)) =\n      e ∘ fun t : β × β => t.2 / t.1 :=\n    by\n    ext t\n    change e t.2 / e t.1 = e (t.2 / t.1)\n    rwa [← map_div e t.2 t.1]\n  have lim : tendsto (fun x : α × α => x.2 / x.1) (𝓝 (x₀, x₀)) (𝓝 (e 1)) := by\n    simpa using (continuous_div'.comp (@continuous_swap α α _ _)).Tendsto (x₀, x₀)\n  simpa using de.tendsto_comap_nhds_nhds limUnder comm\n#align tendsto_div_comap_self tendsto_div_comap_self\n#align tendsto_sub_comap_self tendsto_sub_comap_self\n\nend\n\nnamespace DenseInducing\n\nvariable {α : Type _} {β : Type _} {γ : Type _} {δ : Type _}\n\nvariable {G : Type _}\n\n-- β is a dense subgroup of α, inclusion is denoted by e\n-- δ is a dense subgroup of γ, inclusion is denoted by f\nvariable [TopologicalSpace α] [AddCommGroup α] [TopologicalAddGroup α]\n\nvariable [TopologicalSpace β] [AddCommGroup β] [TopologicalAddGroup β]\n\nvariable [TopologicalSpace γ] [AddCommGroup γ] [TopologicalAddGroup γ]\n\nvariable [TopologicalSpace δ] [AddCommGroup δ] [TopologicalAddGroup δ]\n\nvariable [UniformSpace G] [AddCommGroup G] [UniformAddGroup G] [SeparatedSpace G] [CompleteSpace G]\n\nvariable {e : β →+ α} (de : DenseInducing e)\n\nvariable {f : δ →+ γ} (df : DenseInducing f)\n\nvariable {φ : β →+ δ →+ G}\n\n-- mathport name: exprΦ\nlocal notation \"Φ\" => fun p : β × δ => φ p.1 p.2\n\nvariable (hφ : Continuous Φ)\n\ninclude de df hφ\n\nvariable {W' : Set G} (W'_nhd : W' ∈ 𝓝 (0 : G))\n\ninclude W'_nhd\n\n/- warning: dense_inducing.extend_Z_bilin_aux clashes with [anonymous] -> [anonymous]\nCase conversion may be inaccurate. Consider using '#align dense_inducing.extend_Z_bilin_aux [anonymous]ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x x' «expr ∈ » U₂) -/\n#print [anonymous] /-\nprivate theorem [anonymous] (x₀ : α) (y₁ : δ) :\n    ∃ U₂ ∈ comap e (𝓝 x₀), ∀ (x) (_ : x ∈ U₂) (x') (_ : x' ∈ U₂), Φ (x' - x, y₁) ∈ W' :=\n  by\n  let Nx := 𝓝 x₀\n  let ee := fun u : β × β => (e u.1, e u.2)\n  have lim1 : tendsto (fun a : β × β => (a.2 - a.1, y₁)) (comap e Nx ×ᶠ comap e Nx) (𝓝 (0, y₁)) :=\n    by\n    have :=\n      tendsto.prod_mk (tendsto_sub_comap_self de x₀)\n        (tendsto_const_nhds : tendsto (fun p : β × β => y₁) (comap ee <| 𝓝 (x₀, x₀)) (𝓝 y₁))\n    rw [nhds_prod_eq, prod_comap_comap_eq, ← nhds_prod_eq]\n    exact (this : _)\n  have lim2 : tendsto Φ (𝓝 (0, y₁)) (𝓝 0) := by simpa using hφ.tendsto (0, y₁)\n  have lim := lim2.comp lim1\n  rw [tendsto_prod_self_iff] at lim\n  simp_rw [ball_mem_comm]\n  exact limUnder W' W'_nhd\n#align dense_inducing.extend_Z_bilin_aux [anonymous]\n-/\n\n/- warning: dense_inducing.extend_Z_bilin_key clashes with [anonymous] -> [anonymous]\nCase conversion may be inaccurate. Consider using '#align dense_inducing.extend_Z_bilin_key [anonymous]ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x x' «expr ∈ » U₁) -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y y' «expr ∈ » V₁) -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x x' «expr ∈ » U) -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y y' «expr ∈ » V) -/\n#print [anonymous] /-\nprivate theorem [anonymous] (x₀ : α) (y₀ : γ) :\n    ∃ U ∈ comap e (𝓝 x₀),\n      ∃ V ∈ comap f (𝓝 y₀),\n        ∀ (x) (_ : x ∈ U) (x') (_ : x' ∈ U),\n          ∀ (y) (_ : y ∈ V) (y') (_ : y' ∈ V), Φ (x', y') - Φ (x, y) ∈ W' :=\n  by\n  let Nx := 𝓝 x₀\n  let Ny := 𝓝 y₀\n  let dp := DenseInducing.prod de df\n  let ee := fun u : β × β => (e u.1, e u.2)\n  let ff := fun u : δ × δ => (f u.1, f u.2)\n  have lim_φ : Filter.Tendsto Φ (𝓝 (0, 0)) (𝓝 0) := by simpa using hφ.tendsto (0, 0)\n  have lim_φ_sub_sub :\n    tendsto (fun p : (β × β) × δ × δ => Φ (p.1.2 - p.1.1, p.2.2 - p.2.1))\n      ((comap ee <| 𝓝 (x₀, x₀)) ×ᶠ (comap ff <| 𝓝 (y₀, y₀))) (𝓝 0) :=\n    by\n    have lim_sub_sub :\n      tendsto (fun p : (β × β) × δ × δ => (p.1.2 - p.1.1, p.2.2 - p.2.1))\n        (comap ee (𝓝 (x₀, x₀)) ×ᶠ comap ff (𝓝 (y₀, y₀))) (𝓝 0 ×ᶠ 𝓝 0) :=\n      by\n      have := Filter.prod_mono (tendsto_sub_comap_self de x₀) (tendsto_sub_comap_self df y₀)\n      rwa [prod_map_map_eq] at this\n    rw [← nhds_prod_eq] at lim_sub_sub\n    exact tendsto.comp lim_φ lim_sub_sub\n  rcases exists_nhds_zero_quarter W'_nhd with ⟨W, W_nhd, W4⟩\n  have :\n    ∃ U₁ ∈ comap e (𝓝 x₀),\n      ∃ V₁ ∈ comap f (𝓝 y₀),\n        ∀ (x) (_ : x ∈ U₁) (x') (_ : x' ∈ U₁),\n          ∀ (y) (_ : y ∈ V₁) (y') (_ : y' ∈ V₁), Φ (x' - x, y' - y) ∈ W :=\n    by\n    have := tendsto_prod_iff.1 lim_φ_sub_sub W W_nhd\n    repeat' rw [nhds_prod_eq, ← prod_comap_comap_eq] at this\n    rcases this with ⟨U, U_in, V, V_in, H⟩\n    rw [mem_prod_same_iff] at U_in V_in\n    rcases U_in with ⟨U₁, U₁_in, HU₁⟩\n    rcases V_in with ⟨V₁, V₁_in, HV₁⟩\n    exists U₁, U₁_in, V₁, V₁_in\n    intro x x_in x' x'_in y y_in y' y'_in\n    exact H _ _ (HU₁ (mk_mem_prod x_in x'_in)) (HV₁ (mk_mem_prod y_in y'_in))\n  rcases this with ⟨U₁, U₁_nhd, V₁, V₁_nhd, H⟩\n  obtain ⟨x₁, x₁_in⟩ : U₁.nonempty := (de.comap_nhds_ne_bot _).nonempty_of_mem U₁_nhd\n  obtain ⟨y₁, y₁_in⟩ : V₁.nonempty := (df.comap_nhds_ne_bot _).nonempty_of_mem V₁_nhd\n  have cont_flip : Continuous fun p : δ × β => φ.flip p.1 p.2 :=\n    by\n    show Continuous (Φ ∘ Prod.swap)\n    exact hφ.comp continuous_swap\n  rcases extend_Z_bilin_aux de df hφ W_nhd x₀ y₁ with ⟨U₂, U₂_nhd, HU⟩\n  rcases extend_Z_bilin_aux df de cont_flip W_nhd y₀ x₁ with ⟨V₂, V₂_nhd, HV⟩\n  exists U₁ ∩ U₂, inter_mem U₁_nhd U₂_nhd, V₁ ∩ V₂, inter_mem V₁_nhd V₂_nhd\n  rintro x ⟨xU₁, xU₂⟩ x' ⟨x'U₁, x'U₂⟩ y ⟨yV₁, yV₂⟩ y' ⟨y'V₁, y'V₂⟩\n  have key_formula :\n    φ x' y' - φ x y = φ (x' - x) y₁ + φ (x' - x) (y' - y₁) + φ x₁ (y' - y) + φ (x - x₁) (y' - y) :=\n    by\n    simp\n    abel\n  rw [key_formula]\n  have h₁ := HU x xU₂ x' x'U₂\n  have h₂ := H x xU₁ x' x'U₁ y₁ y₁_in y' y'V₁\n  have h₃ := HV y yV₂ y' y'V₂\n  have h₄ := H x₁ x₁_in x xU₁ y yV₁ y' y'V₁\n  exact W4 h₁ h₂ h₃ h₄\n#align dense_inducing.extend_Z_bilin_key [anonymous]\n-/\n\nomit W'_nhd\n\nopen DenseInducing\n\n/- warning: dense_inducing.extend_Z_bilin -> DenseInducing.extend_Z_bilin is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {G : Type.{u5}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : AddCommGroup.{u1} α] [_inst_3 : TopologicalAddGroup.{u1} α _inst_1 (AddCommGroup.toAddGroup.{u1} α _inst_2)] [_inst_4 : TopologicalSpace.{u2} β] [_inst_5 : AddCommGroup.{u2} β] [_inst_6 : TopologicalAddGroup.{u2} β _inst_4 (AddCommGroup.toAddGroup.{u2} β _inst_5)] [_inst_7 : TopologicalSpace.{u3} γ] [_inst_8 : AddCommGroup.{u3} γ] [_inst_9 : TopologicalAddGroup.{u3} γ _inst_7 (AddCommGroup.toAddGroup.{u3} γ _inst_8)] [_inst_10 : TopologicalSpace.{u4} δ] [_inst_11 : AddCommGroup.{u4} δ] [_inst_12 : TopologicalAddGroup.{u4} δ _inst_10 (AddCommGroup.toAddGroup.{u4} δ _inst_11)] [_inst_13 : UniformSpace.{u5} G] [_inst_14 : AddCommGroup.{u5} G] [_inst_15 : UniformAddGroup.{u5} G _inst_13 (AddCommGroup.toAddGroup.{u5} G _inst_14)] [_inst_16 : SeparatedSpace.{u5} G _inst_13] [_inst_17 : CompleteSpace.{u5} G _inst_13] {e : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))} (de : DenseInducing.{u2, u1} β α _inst_4 _inst_1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) e)) {f : AddMonoidHom.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))} (df : DenseInducing.{u4, u3} δ γ _inst_10 _inst_7 (coeFn.{max (succ u3) (succ u4), max (succ u4) (succ u3)} (AddMonoidHom.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) (fun (_x : AddMonoidHom.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) => δ -> γ) (AddMonoidHom.hasCoeToFun.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) f)) {φ : AddMonoidHom.{u2, max u5 u4} β (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (SubNegMonoid.toAddMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddGroup.toSubNegMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddCommGroup.toAddGroup.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) _inst_14)))))}, (Continuous.{max u2 u4, u5} (Prod.{u2, u4} β δ) G (Prod.topologicalSpace.{u2, u4} β δ _inst_4 _inst_10) (UniformSpace.toTopologicalSpace.{u5} G _inst_13) (fun (p : Prod.{u2, u4} β δ) => coeFn.{max (succ u5) (succ u4), max (succ u4) (succ u5)} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (fun (_x : AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) => δ -> G) (AddMonoidHom.hasCoeToFun.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (coeFn.{max (succ (max u5 u4)) (succ u2), max (succ u2) (succ (max u5 u4))} (AddMonoidHom.{u2, max u5 u4} β (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (SubNegMonoid.toAddMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddGroup.toSubNegMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddCommGroup.toAddGroup.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) _inst_14)))))) (fun (_x : AddMonoidHom.{u2, max u5 u4} β (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (SubNegMonoid.toAddMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddGroup.toSubNegMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddCommGroup.toAddGroup.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) _inst_14)))))) => β -> (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14)))))) (AddMonoidHom.hasCoeToFun.{u2, max u5 u4} β (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (SubNegMonoid.toAddMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddGroup.toSubNegMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddCommGroup.toAddGroup.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) _inst_14)))))) φ (Prod.fst.{u2, u4} β δ p)) (Prod.snd.{u2, u4} β δ p))) -> (Continuous.{max u1 u3, u5} (Prod.{u1, u3} α γ) G (Prod.topologicalSpace.{u1, u3} α γ _inst_1 _inst_7) (UniformSpace.toTopologicalSpace.{u5} G _inst_13) (DenseInducing.extend.{max u2 u4, max u1 u3, u5} (Prod.{u2, u4} β δ) (Prod.{u1, u3} α γ) G (Prod.topologicalSpace.{u2, u4} β δ _inst_4 _inst_10) (Prod.topologicalSpace.{u1, u3} α γ _inst_1 _inst_7) (fun (p : Prod.{u2, u4} β δ) => Prod.mk.{u1, u3} α γ (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) e (Prod.fst.{u2, u4} β δ p)) (coeFn.{max (succ u3) (succ u4), max (succ u4) (succ u3)} (AddMonoidHom.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) (fun (_x : AddMonoidHom.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) => δ -> γ) (AddMonoidHom.hasCoeToFun.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) f (Prod.snd.{u2, u4} β δ p))) (UniformSpace.toTopologicalSpace.{u5} G _inst_13) (DenseInducing.prod.{u2, u1, u4, u3} β α δ γ _inst_4 _inst_1 _inst_10 _inst_7 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u1} α (SubNegMonoid.toAddMonoid.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddCommGroup.toAddGroup.{u1} α _inst_2))))) e) (coeFn.{max (succ u3) (succ u4), max (succ u4) (succ u3)} (AddMonoidHom.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) (fun (_x : AddMonoidHom.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) => δ -> γ) (AddMonoidHom.hasCoeToFun.{u4, u3} δ γ (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u3} γ (SubNegMonoid.toAddMonoid.{u3} γ (AddGroup.toSubNegMonoid.{u3} γ (AddCommGroup.toAddGroup.{u3} γ _inst_8))))) f) de df) (fun (p : Prod.{u2, u4} β δ) => coeFn.{max (succ u5) (succ u4), max (succ u4) (succ u5)} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (fun (_x : AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) => δ -> G) (AddMonoidHom.hasCoeToFun.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (coeFn.{max (succ (max u5 u4)) (succ u2), max (succ u2) (succ (max u5 u4))} (AddMonoidHom.{u2, max u5 u4} β (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (SubNegMonoid.toAddMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddGroup.toSubNegMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddCommGroup.toAddGroup.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) _inst_14)))))) (fun (_x : AddMonoidHom.{u2, max u5 u4} β (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (SubNegMonoid.toAddMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddGroup.toSubNegMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddCommGroup.toAddGroup.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) _inst_14)))))) => β -> (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14)))))) (AddMonoidHom.hasCoeToFun.{u2, max u5 u4} β (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (SubNegMonoid.toAddMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddGroup.toSubNegMonoid.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddCommGroup.toAddGroup.{max u5 u4} (AddMonoidHom.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} δ G (AddMonoid.toAddZeroClass.{u4} δ (SubNegMonoid.toAddMonoid.{u4} δ (AddGroup.toSubNegMonoid.{u4} δ (AddCommGroup.toAddGroup.{u4} δ _inst_11)))) _inst_14)))))) φ (Prod.fst.{u2, u4} β δ p)) (Prod.snd.{u2, u4} β δ p))))\nbut is expected to have type\n  forall {α : Type.{u5}} {β : Type.{u2}} {γ : Type.{u4}} {δ : Type.{u1}} {G : Type.{u3}} [_inst_1 : TopologicalSpace.{u5} α] [_inst_2 : AddCommGroup.{u5} α] [_inst_3 : TopologicalAddGroup.{u5} α _inst_1 (AddCommGroup.toAddGroup.{u5} α _inst_2)] [_inst_4 : TopologicalSpace.{u2} β] [_inst_5 : AddCommGroup.{u2} β] [_inst_6 : TopologicalSpace.{u4} γ] [_inst_7 : AddCommGroup.{u4} γ] [_inst_8 : TopologicalAddGroup.{u4} γ _inst_6 (AddCommGroup.toAddGroup.{u4} γ _inst_7)] [_inst_9 : TopologicalSpace.{u1} δ] [_inst_10 : AddCommGroup.{u1} δ] [_inst_11 : UniformSpace.{u3} G] [_inst_12 : AddCommGroup.{u3} G] [_inst_13 : UniformAddGroup.{u3} G _inst_11 (AddCommGroup.toAddGroup.{u3} G _inst_12)] [_inst_14 : SeparatedSpace.{u3} G _inst_11] [_inst_15 : CompleteSpace.{u3} G _inst_11] {_inst_16 : AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))} (_inst_17 : DenseInducing.{u2, u5} β α _inst_4 _inst_1 (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β (fun (a : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) a) (AddHomClass.toFunLike.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β α (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5))))) (AddZeroClass.toAdd.{u5} α (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) (AddMonoidHomClass.toAddHomClass.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2)))) (AddMonoidHom.addMonoidHomClass.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))))) _inst_16)) {e : AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))} (de : DenseInducing.{u1, u4} δ γ _inst_9 _inst_6 (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ (fun (_x : δ) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : δ) => γ) _x) (AddHomClass.toFunLike.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ γ (AddZeroClass.toAdd.{u1} δ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10))))) (AddZeroClass.toAdd.{u4} γ (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) (AddMonoidHomClass.toAddHomClass.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7)))) (AddMonoidHom.addMonoidHomClass.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))))) e)) {f : AddMonoidHom.{u2, max u3 u1} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))}, (Continuous.{max u2 u1, u3} (Prod.{u2, u1} β δ) G (instTopologicalSpaceProd.{u2, u1} β δ _inst_4 _inst_9) (UniformSpace.toTopologicalSpace.{u3} G _inst_11) (fun (p : Prod.{u2, u1} β δ) => FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} β δ p)) δ (fun (a : δ) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : δ) => G) a) (AddHomClass.toFunLike.{max u1 u3, u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} β δ p)) δ G (AddZeroClass.toAdd.{u1} δ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10))))) (AddZeroClass.toAdd.{u3} G (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHomClass.toAddHomClass.{max u1 u3, u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} β δ p)) δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12)))) (AddMonoidHom.addMonoidHomClass.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))))) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), succ u2, max (succ u1) (succ u3)} (AddMonoidHom.{u2, max u3 u1} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) β (fun (a : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) a) (AddHomClass.toFunLike.{max (max u2 u1) u3, u2, max u1 u3} (AddMonoidHom.{u2, max u3 u1} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5))))) (AddZeroClass.toAdd.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) (AddMonoidHomClass.toAddHomClass.{max (max u2 u1) u3, u2, max u1 u3} (AddMonoidHom.{u2, max u3 u1} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12))))) (AddMonoidHom.addMonoidHomClass.{u2, max u1 u3} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))))) f (Prod.fst.{u2, u1} β δ p)) (Prod.snd.{u2, u1} β δ p))) -> (Continuous.{max u5 u4, u3} (Prod.{u5, u4} α γ) G (instTopologicalSpaceProd.{u5, u4} α γ _inst_1 _inst_6) (UniformSpace.toTopologicalSpace.{u3} G _inst_11) (DenseInducing.extend.{max u2 u1, max u5 u4, u3} (Prod.{u2, u1} β δ) (Prod.{u5, u4} α γ) G (instTopologicalSpaceProd.{u2, u1} β δ _inst_4 _inst_9) (instTopologicalSpaceProd.{u5, u4} α γ _inst_1 _inst_6) (fun (p : Prod.{u2, u1} β δ) => Prod.mk.{u5, u4} α γ (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β (fun (a : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) a) (AddHomClass.toFunLike.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β α (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5))))) (AddZeroClass.toAdd.{u5} α (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) (AddMonoidHomClass.toAddHomClass.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2)))) (AddMonoidHom.addMonoidHomClass.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))))) _inst_16 (Prod.fst.{u2, u1} β δ p)) (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ (fun (a : δ) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : δ) => γ) a) (AddHomClass.toFunLike.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ γ (AddZeroClass.toAdd.{u1} δ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10))))) (AddZeroClass.toAdd.{u4} γ (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) (AddMonoidHomClass.toAddHomClass.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7)))) (AddMonoidHom.addMonoidHomClass.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))))) e (Prod.snd.{u2, u1} β δ p))) (UniformSpace.toTopologicalSpace.{u3} G _inst_11) (DenseInducing.prod.{u5, u2, u4, u1} β α δ γ _inst_4 _inst_1 _inst_9 _inst_6 (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β (fun (a : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) a) (AddHomClass.toFunLike.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β α (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5))))) (AddZeroClass.toAdd.{u5} α (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) (AddMonoidHomClass.toAddHomClass.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))) β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2)))) (AddMonoidHom.addMonoidHomClass.{u2, u5} β α (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{u5} α (SubNegMonoid.toAddMonoid.{u5} α (AddGroup.toSubNegMonoid.{u5} α (AddCommGroup.toAddGroup.{u5} α _inst_2))))))) _inst_16) (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ (fun (a : δ) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : δ) => γ) a) (AddHomClass.toFunLike.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ γ (AddZeroClass.toAdd.{u1} δ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10))))) (AddZeroClass.toAdd.{u4} γ (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) (AddMonoidHomClass.toAddHomClass.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))) δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7)))) (AddMonoidHom.addMonoidHomClass.{u1, u4} δ γ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u4} γ (SubNegMonoid.toAddMonoid.{u4} γ (AddGroup.toSubNegMonoid.{u4} γ (AddCommGroup.toAddGroup.{u4} γ _inst_7))))))) e) _inst_17 de) (fun (p : Prod.{u2, u1} β δ) => FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} β δ p)) δ (fun (a : δ) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : δ) => G) a) (AddHomClass.toFunLike.{max u1 u3, u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} β δ p)) δ G (AddZeroClass.toAdd.{u1} δ (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10))))) (AddZeroClass.toAdd.{u3} G (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHomClass.toAddHomClass.{max u1 u3, u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} β δ p)) δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12)))) (AddMonoidHom.addMonoidHomClass.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))))) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), succ u2, max (succ u1) (succ u3)} (AddMonoidHom.{u2, max u3 u1} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) β (fun (a : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) a) (AddHomClass.toFunLike.{max (max u2 u1) u3, u2, max u1 u3} (AddMonoidHom.{u2, max u3 u1} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5))))) (AddZeroClass.toAdd.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) (AddMonoidHomClass.toAddHomClass.{max (max u2 u1) u3, u2, max u1 u3} (AddMonoidHom.{u2, max u3 u1} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))) β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12))))) (AddMonoidHom.addMonoidHomClass.{u2, max u1 u3} β (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} β (SubNegMonoid.toAddMonoid.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddCommGroup.toAddGroup.{u2} β _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (SubNegMonoid.toAddMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddGroup.toSubNegMonoid.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddCommGroup.toAddGroup.{max u1 u3} (AddMonoidHom.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} δ G (AddMonoid.toAddZeroClass.{u1} δ (SubNegMonoid.toAddMonoid.{u1} δ (AddGroup.toSubNegMonoid.{u1} δ (AddCommGroup.toAddGroup.{u1} δ _inst_10)))) _inst_12)))))))) f (Prod.fst.{u2, u1} β δ p)) (Prod.snd.{u2, u1} β δ p))))\nCase conversion may be inaccurate. Consider using '#align dense_inducing.extend_Z_bilin DenseInducing.extend_Z_bilinₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Bourbaki GT III.6.5 Theorem I:\nℤ-bilinear continuous maps from dense images into a complete Hausdorff group extend by continuity.\nNote: Bourbaki assumes that α and β are also complete Hausdorff, but this is not necessary. -/\ntheorem extend_Z_bilin : Continuous (extend (de.Prod df) Φ) :=\n  by\n  refine' continuous_extend_of_cauchy _ _\n  rintro ⟨x₀, y₀⟩\n  constructor\n  · apply ne_bot.map\n    apply comap_ne_bot\n    intro U h\n    rcases mem_closure_iff_nhds.1 ((de.prod df).dense (x₀, y₀)) U h with ⟨x, x_in, ⟨z, z_x⟩⟩\n    exists z\n    cc\n  · suffices\n      map (fun p : (β × δ) × β × δ => Φ p.2 - Φ p.1)\n          (comap (fun p : (β × δ) × β × δ => ((e p.1.1, f p.1.2), (e p.2.1, f p.2.2)))\n            (𝓝 (x₀, y₀) ×ᶠ 𝓝 (x₀, y₀))) ≤\n        𝓝 0\n      by\n      rwa [uniformity_eq_comap_nhds_zero G, prod_map_map_eq, ← map_le_iff_le_comap, Filter.map_map,\n        prod_comap_comap_eq]\n    intro W' W'_nhd\n    have key := extend_Z_bilin_key de df hφ W'_nhd x₀ y₀\n    rcases key with ⟨U, U_nhd, V, V_nhd, h⟩\n    rw [mem_comap] at U_nhd\n    rcases U_nhd with ⟨U', U'_nhd, U'_sub⟩\n    rw [mem_comap] at V_nhd\n    rcases V_nhd with ⟨V', V'_nhd, V'_sub⟩\n    rw [mem_map, mem_comap, nhds_prod_eq]\n    exists (U' ×ˢ V') ×ˢ U' ×ˢ V'\n    rw [mem_prod_same_iff]\n    simp only [exists_prop]\n    constructor\n    · change U' ∈ 𝓝 x₀ at U'_nhd\n      change V' ∈ 𝓝 y₀ at V'_nhd\n      have := prod_mem_prod U'_nhd V'_nhd\n      tauto\n    · intro p h'\n      simp only [Set.mem_preimage, Set.prod_mk_mem_set_prod_eq] at h'\n      rcases p with ⟨⟨x, y⟩, ⟨x', y'⟩⟩\n      apply h <;> tauto\n#align dense_inducing.extend_Z_bilin DenseInducing.extend_Z_bilin\n\nend DenseInducing\n\nsection CompleteQuotient\n\nuniverse u\n\nopen TopologicalSpace Classical\n\n#print QuotientGroup.completeSpace' /-\n/-- The quotient `G ⧸ N` of a complete first countable topological group `G` by a normal subgroup\nis itself complete. [N. Bourbaki, *General Topology*, IX.3.1 Proposition 4][bourbaki1966b]\n\nBecause a topological group is not equipped with a `uniform_space` instance by default, we must\nexplicitly provide it in order to consider completeness. See `quotient_group.complete_space` for a\nversion in which `G` is already equipped with a uniform structure. -/\n@[to_additive\n      \"The quotient `G ⧸ N` of a complete first countable topological additive group\\n`G` by a normal additive subgroup is itself complete. Consequently, quotients of Banach spaces by\\nsubspaces are complete. [N. Bourbaki, *General Topology*, IX.3.1 Proposition 4][bourbaki1966b]\\n\\nBecause an additive topological group is not equipped with a `uniform_space` instance by default,\\nwe must explicitly provide it in order to consider completeness. See\\n`quotient_add_group.complete_space` for a version in which `G` is already equipped with a uniform\\nstructure.\"]\ninstance QuotientGroup.completeSpace' (G : Type u) [Group G] [TopologicalSpace G]\n    [TopologicalGroup G] [FirstCountableTopology G] (N : Subgroup G) [N.normal]\n    [@CompleteSpace G (TopologicalGroup.toUniformSpace G)] :\n    @CompleteSpace (G ⧸ N) (TopologicalGroup.toUniformSpace (G ⧸ N)) :=\n  by\n  /- Since `G ⧸ N` is a topological group it is a uniform space, and since `G` is first countable\n    the uniformities of both `G` and `G ⧸ N` are countably generated. Moreover, we may choose a\n    sequential antitone neighborhood basis `u` for `𝓝 (1 : G)` so that `(u (n + 1)) ^ 2 ⊆ u n`, and\n    this descends to an antitone neighborhood basis `v` for `𝓝 (1 : G ⧸ N)`. Since `𝓤 (G ⧸ N)` is\n    countably generated, it suffices to show any Cauchy sequence `x` converges. -/\n  letI : UniformSpace (G ⧸ N) := TopologicalGroup.toUniformSpace (G ⧸ N)\n  letI : UniformSpace G := TopologicalGroup.toUniformSpace G\n  haveI : (𝓤 (G ⧸ N)).IsCountablyGenerated := comap.is_countably_generated _ _\n  obtain ⟨u, hu, u_mul⟩ := TopologicalGroup.exists_antitone_basis_nhds_one G\n  obtain ⟨hv, v_anti⟩ := @has_antitone_basis.map _ _ _ _ _ _ (coe : G → G ⧸ N) hu\n  rw [← QuotientGroup.nhds_eq N 1, QuotientGroup.mk_one] at hv\n  refine' UniformSpace.complete_of_cauchySeq_tendsto fun x hx => _\n  /- Given `n : ℕ`, for sufficiently large `a b : ℕ`, given any lift of `x b`, we can find a lift\n    of `x a` such that the quotient of the lifts lies in `u n`. -/\n  have key₀ :\n    ∀ i j : ℕ,\n      ∃ M : ℕ,\n        j < M ∧ ∀ a b : ℕ, M ≤ a → M ≤ b → ∀ g : G, x b = g → ∃ g' : G, g / g' ∈ u i ∧ x a = g' :=\n    by\n    have h𝓤GN : (𝓤 (G ⧸ N)).HasBasis (fun _ => True) fun i => { x | x.snd / x.fst ∈ coe '' u i } :=\n      by simpa [uniformity_eq_comap_nhds_one'] using hv.comap _\n    simp only [h𝓤GN.cauchy_seq_iff, ge_iff_le, mem_set_of_eq, forall_true_left, mem_image] at hx\n    intro i j\n    rcases hx i with ⟨M, hM⟩\n    refine' ⟨max j M + 1, (le_max_left _ _).trans_lt (lt_add_one _), fun a b ha hb g hg => _⟩\n    obtain ⟨y, y_mem, hy⟩ :=\n      hM a (((le_max_right j _).trans (lt_add_one _).le).trans ha) b\n        (((le_max_right j _).trans (lt_add_one _).le).trans hb)\n    refine'\n      ⟨y⁻¹ * g, by\n        simpa only [div_eq_mul_inv, mul_inv_rev, inv_inv, mul_inv_cancel_left] using y_mem, _⟩\n    rw [QuotientGroup.mk_mul, QuotientGroup.mk_inv, hy, hg, inv_div, div_mul_cancel']\n  /- Inductively construct a subsequence `φ : ℕ → ℕ` using `key₀` so that if `a b : ℕ` exceed\n    `φ (n + 1)`, then we may find lifts whose quotients lie within `u n`. -/\n  set φ : ℕ → ℕ := fun n => Nat.recOn n (some <| key₀ 0 0) fun k yk => some <| key₀ (k + 1) yk\n  have hφ :\n    ∀ n : ℕ,\n      φ n < φ (n + 1) ∧\n        ∀ a b : ℕ,\n          φ (n + 1) ≤ a →\n            φ (n + 1) ≤ b → ∀ g : G, x b = g → ∃ g' : G, g / g' ∈ u (n + 1) ∧ x a = g' :=\n    fun n => some_spec (key₀ (n + 1) (φ n))\n  /- Inductively construct a sequence `x' n : G` of lifts of `x (φ (n + 1))` such that quotients of\n    successive terms lie in `x' n / x' (n + 1) ∈ u (n + 1)`. We actually need the proofs that each\n    term is a lift to construct the next term, so we use a Σ-type. -/\n  set x' : ∀ n, PSigma fun g : G => x (φ (n + 1)) = g := fun n =>\n    Nat.recOn n\n      ⟨some (QuotientGroup.mk_surjective (x (φ 1))),\n        (some_spec (QuotientGroup.mk_surjective (x (φ 1)))).symm⟩\n      fun k hk =>\n      ⟨some <| (hφ k).2 _ _ (hφ (k + 1)).1.le le_rfl hk.fst hk.snd,\n        (some_spec <| (hφ k).2 _ _ (hφ (k + 1)).1.le le_rfl hk.fst hk.snd).2⟩\n  have hx' : ∀ n : ℕ, (x' n).fst / (x' (n + 1)).fst ∈ u (n + 1) := fun n =>\n    (some_spec <| (hφ n).2 _ _ (hφ (n + 1)).1.le le_rfl (x' n).fst (x' n).snd).1\n  /- The sequence `x'` is Cauchy. This is where we exploit the condition on `u`. The key idea\n    is to show by decreasing induction that `x' m / x' n ∈ u m` if `m ≤ n`. -/\n  have x'_cauchy : CauchySeq fun n => (x' n).fst :=\n    by\n    have h𝓤G : (𝓤 G).HasBasis (fun _ => True) fun i => { x | x.snd / x.fst ∈ u i } := by\n      simpa [uniformity_eq_comap_nhds_one'] using hu.to_has_basis.comap _\n    simp only [h𝓤G.cauchy_seq_iff', ge_iff_le, mem_set_of_eq, forall_true_left]\n    exact fun m =>\n      ⟨m, fun n hmn =>\n        Nat.decreasingInduction'\n          (fun k hkn hkm hk => u_mul k ⟨_, _, hx' k, hk, div_mul_div_cancel' _ _ _⟩) hmn\n          (by simpa only [div_self'] using mem_of_mem_nhds (hu.mem _))⟩\n  /- Since `G` is complete, `x'` converges to some `x₀`, and so the image of this sequence under\n    the quotient map converges to `↑x₀`. The image of `x'` is a convergent subsequence of `x`, and\n    since `x` is Cauchy, this implies it converges. -/\n  rcases cauchySeq_tendsto_of_complete x'_cauchy with ⟨x₀, hx₀⟩\n  refine'\n    ⟨↑x₀,\n      tendsto_nhds_of_cauchySeq_of_subseq hx\n        (strictMono_nat_of_lt_succ fun n => (hφ (n + 1)).1).tendsto_atTop _⟩\n  convert((continuous_coinduced_rng : Continuous (coe : G → G ⧸ N)).Tendsto x₀).comp hx₀\n  exact funext fun n => (x' n).snd\n#align quotient_group.complete_space' QuotientGroup.completeSpace'\n#align quotient_add_group.complete_space' QuotientAddGroup.completeSpace'\n-/\n\n#print QuotientGroup.completeSpace /-\n/-- The quotient `G ⧸ N` of a complete first countable uniform group `G` by a normal subgroup\nis itself complete. In constrast to `quotient_group.complete_space'`, in this version `G` is\nalready equipped with a uniform structure.\n[N. Bourbaki, *General Topology*, IX.3.1 Proposition 4][bourbaki1966b]\n\nEven though `G` is equipped with a uniform structure, the quotient `G ⧸ N` does not inherit a\nuniform structure, so it is still provided manually via `topological_group.to_uniform_space`.\nIn the most common use cases, this coincides (definitionally) with the uniform structure on the\nquotient obtained via other means.  -/\n@[to_additive\n      \"The quotient `G ⧸ N` of a complete first countable uniform additive group\\n`G` by a normal additive subgroup is itself complete. Consequently, quotients of Banach spaces by\\nsubspaces are complete. In constrast to `quotient_add_group.complete_space'`, in this version\\n`G` is already equipped with a uniform structure.\\n[N. Bourbaki, *General Topology*, IX.3.1 Proposition 4][bourbaki1966b]\\n\\nEven though `G` is equipped with a uniform structure, the quotient `G ⧸ N` does not inherit a\\nuniform structure, so it is still provided manually via `topological_add_group.to_uniform_space`.\\nIn the most common use case ─ quotients of normed additive commutative groups by subgroups ─\\nsignificant care was taken so that the uniform structure inherent in that setting coincides\\n(definitionally) with the uniform structure provided here.\"]\ninstance QuotientGroup.completeSpace (G : Type u) [Group G] [us : UniformSpace G] [UniformGroup G]\n    [FirstCountableTopology G] (N : Subgroup G) [N.normal] [hG : CompleteSpace G] :\n    @CompleteSpace (G ⧸ N) (TopologicalGroup.toUniformSpace (G ⧸ N)) :=\n  by\n  rw [← @UniformGroup.toUniformSpace_eq _ us _ _] at hG\n  infer_instance\n#align quotient_group.complete_space QuotientGroup.completeSpace\n#align quotient_add_group.complete_space QuotientAddGroup.completeSpace\n-/\n\nend CompleteQuotient\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Algebra/UniformGroup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.48335715167524806}}
{"text": "import o_minimal.coordinates\nimport o_minimal.structure\n\n-- Stripped-down version of `o_minimal.definable`\n-- without implicit definability hypotheses on the types.\n\nuniverse u\n\nnamespace o_minimal\n\nopen_locale finvec\n\nvariables {R : Type u} (S : struc R)\n\nvariables {X : Type*} [has_coordinates R X]\nvariables {Y : Type*} [has_coordinates R Y]\n\ndef struc.def_coords (s : set X) : Prop :=\nS.definable (coords R '' s)\n\nnamespace struc.def_coords\n\nvariables {S}\n\nlemma diag (dX : S.def_coords (set.univ : set X)) :\n  S.def_coords {p : X × X | p.1 = p.2} :=\nbegin\n  unfold struc.def_coords,\n  convert S.definable_inter (S.definable_prod_rn dX) S.definable_diag_rn,\n  refine set.ext (finvec.rec (λ v w, _)),\n  have :\n    (∃ (x : X), coords R x = v ∧ coords R x = w) ↔\n    v ∈ coordinate_image R X ∧ v = w,\n  { split,\n    { rintros ⟨x, rfl, rfl⟩, exact ⟨⟨x, rfl⟩, rfl⟩ },\n    { rintros ⟨⟨x, rfl⟩, rfl⟩, exact ⟨x, rfl, rfl⟩ } },\n  simp,\n  dsimp,\n  simpa [finvec.append.inj_iff]\nend\n\nlemma reindex (dX : S.def_coords (set.univ : set X)) {f : X → Y} (hf : is_reindexing R f)\n  {s : set Y} (ds : S.def_coords s) : S.def_coords (f ⁻¹' s) :=\nbegin\n  cases hf with fσ hf,\n  unfold struc.def_coords,\n  -- The preimage f ⁻¹' s, as a subset of the Rⁿ in which X lives,\n  -- is the intersection of X with the preimage of s under the reindexing.\n  convert S.definable_inter dX (S.definable_reindex fσ ds),\n  ext z,\n  suffices : (∃ (x : X), f x ∈ s ∧ coords R x = z) ↔\n    z ∈ set.range (@coords R X _) ∧ ∃ (y : Y), y ∈ s ∧ coords R y = z ∘ fσ,\n  { simpa },\n  -- TODO: funext'd version of `is_reindexing.hf`\n  replace hf : ∀ (x : X), coords R x ∘ fσ = coords R (f x) := λ x, funext (λ i, (hf x i)),\n  split,\n  { rintro ⟨x, hfx, rfl⟩,\n    refine ⟨set.mem_range_self _, f x, hfx, (hf x).symm⟩ },\n  { rintro ⟨⟨x, rfl⟩, y, hy, H⟩,\n    rw hf x at H,\n    replace hf := injective_coords _ H,\n    subst y,\n    exact ⟨x, hy, rfl⟩ }\nend\n\nlemma «exists» {s : X → Y → Prop} (ds : S.def_coords {p : X × Y | s p.1 p.2}) :\n  S.def_coords {x | ∃ y, s x y} :=\nbegin\n  unfold struc.def_coords at ⊢ ds,\n  convert S.definable_proj ds using 1,\n  ext x,\n  rw [set.image_image],\n  simp\nend\n\nlemma inter {s t : set X} (ds : S.def_coords s) (dt : S.def_coords t) :\n  S.def_coords (s ∩ t) :=\nbegin\n  unfold struc.def_coords,\n  convert S.definable_inter ds dt,\n  simp [set.image_inter (injective_coords X)]\nend\n\nlemma prod_univ (dX : S.def_coords (set.univ : set X)) (dY : S.def_coords (set.univ : set Y)) :\n  S.def_coords (set.univ : set (X × Y)) :=\nbegin\n  unfold struc.def_coords,\n  convert S.definable_external_prod dX dY,\n  refine set.ext (finvec.rec (λ v w, _)),\n  simp [finvec.append.inj_iff, finvec.append_mem_prod_iff]\nend\n\nend struc.def_coords\n\nend o_minimal\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/omin/def_coords.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.48335714893569615}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n\n! This file was ported from Lean 3 source module init.data.unsigned.basic\n! leanprover-community/mathlib commit 9e76153313954b399b860a365081d803e6ed2bf8\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nprelude\nimport Leanbin.Init.Data.Fin.Basic\n\nopen Nat\n\ndef unsignedSz : Nat :=\n  succ 4294967295\n#align unsigned_sz unsignedSz\n\ndef Unsigned :=\n  Fin unsignedSz\n#align unsigned Unsigned\n\nnamespace Unsigned\n\n-- We cannot use tactic dec_trivial here because the tactic framework has not been defined yet.\nprivate theorem zero_lt_unsigned_sz : 0 < unsignedSz :=\n  zero_lt_succ _\n#align unsigned.zero_lt_unsigned_sz unsigned.zero_lt_unsigned_sz\n\n-- Later, we define of_nat using mod, the following version is used to define the metaprogramming system.\nprotected def ofNat' (n : Nat) : Unsigned :=\n  if h : n < unsignedSz then ⟨n, h⟩ else ⟨0, zero_lt_unsignedSz⟩\n#align unsigned.of_nat' Unsigned.ofNat'\n\ndef toNat (c : Unsigned) : Nat :=\n  c.val\n#align unsigned.to_nat Unsigned.toNat\n\nend Unsigned\n\ninstance : DecidableEq Unsigned :=\n  have : DecidableEq (Fin unsignedSz) := Fin.decidableEq _\n  this\n\n", "meta": {"author": "leanprover-community", "repo": "lean3port", "sha": "9ed1898f23e4379865ee93d62cb6353e5ed6c270", "save_path": "github-repos/lean/leanprover-community-lean3port", "path": "github-repos/lean/leanprover-community-lean3port/lean3port-9ed1898f23e4379865ee93d62cb6353e5ed6c270/Leanbin/Init/Data/Unsigned/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303285397348, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.48331599221149657}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n-/\nimport category_theory.sites.sheafification\nimport category_theory.sites.whiskering\n\n/-!\n\nIn this file, we prove that the plus functor is compatible with functors which\npreserve the correct limits and colimits.\n\nSee `category_theory/sites/compatible_sheafification` for the compatibility\nof sheafification, which follows easily from the content in this file.\n\n-/\n\nnamespace category_theory.grothendieck_topology\n\nopen category_theory\nopen category_theory.limits\nopen opposite\n\nuniverses w₁ w₂ v u\nvariables {C : Type u} [category.{v} C] (J : grothendieck_topology C)\nvariables {D : Type w₁} [category.{max v u} D]\nvariables {E : Type w₂} [category.{max v u} E]\nvariables (F : D ⥤ E)\n\nnoncomputable theory\n\nvariables [∀ (α β : Type (max v u)) (fst snd : β → α),\n  has_limits_of_shape (walking_multicospan fst snd) D]\nvariables [∀ (α β : Type (max v u)) (fst snd : β → α),\n  has_limits_of_shape (walking_multicospan fst snd) E]\nvariables [∀ (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D), preserves_limit (W.index P).multicospan F]\n\nvariables (P : Cᵒᵖ ⥤ D)\n\n/-- The diagram used to define `P⁺`, composed with `F`, is isomorphic\nto the diagram used to define `P ⋙ F`. -/\ndef diagram_comp_iso (X : C) : J.diagram P X ⋙ F ≅ J.diagram (P ⋙ F) X :=\nnat_iso.of_components\n(λ W, begin\n  refine _ ≪≫ has_limit.iso_of_nat_iso (W.unop.multicospan_comp _ _).symm,\n  refine (is_limit_of_preserves F (limit.is_limit _)).cone_point_unique_up_to_iso\n    (limit.is_limit _)\nend) begin\n  intros A B f,\n  ext,\n  dsimp,\n  simp only [functor.map_cone_π_app, multiequalizer.multifork_π_app_left,\n    iso.symm_hom, multiequalizer.lift_ι, eq_to_hom_refl, category.comp_id,\n    limit.cone_point_unique_up_to_iso_hom_comp,\n    grothendieck_topology.cover.multicospan_comp_hom_inv_left,\n    has_limit.iso_of_nat_iso_hom_π, category.assoc],\n  simp only [← F.map_comp, multiequalizer.lift_ι],\nend\n\n@[simp, reassoc]\nlemma diagram_comp_iso_hom_ι (X : C) (W : (J.cover X)ᵒᵖ) (i : W.unop.arrow):\n  (J.diagram_comp_iso F P X).hom.app W ≫ multiequalizer.ι _ i =\n  F.map (multiequalizer.ι _ _) :=\nbegin\n  delta diagram_comp_iso,\n  dsimp,\n  simp,\nend\n\nvariables [∀ (X : C), has_colimits_of_shape (J.cover X)ᵒᵖ D]\nvariables [∀ (X : C), has_colimits_of_shape (J.cover X)ᵒᵖ E]\nvariables [∀ (X : C), preserves_colimits_of_shape (J.cover X)ᵒᵖ F]\n\n/-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`. -/\ndef plus_comp_iso : J.plus_obj P ⋙ F ≅ J.plus_obj (P ⋙ F) :=\nnat_iso.of_components\n(λ X, begin\n  refine _ ≪≫ has_colimit.iso_of_nat_iso (J.diagram_comp_iso F P X.unop),\n  refine (is_colimit_of_preserves F (colimit.is_colimit\n    (J.diagram P (unop X)))).cocone_point_unique_up_to_iso (colimit.is_colimit _)\nend) begin\n  intros X Y f,\n  apply (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).hom_ext,\n  intros W,\n  dsimp [plus_obj, plus_map],\n  simp only [functor.map_comp, category.assoc],\n  slice_rhs 1 2\n  { erw (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).fac },\n  slice_lhs 1 3\n  { simp only [← F.map_comp],\n    dsimp [colim_map, is_colimit.map, colimit.pre],\n    simp only [colimit.ι_desc_assoc, colimit.ι_desc],\n    dsimp [cocones.precompose],\n    rw [category.assoc, colimit.ι_desc],\n    dsimp [cocone.whisker],\n    rw F.map_comp },\n  simp only [category.assoc],\n  slice_lhs 2 3\n  { erw (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P Y.unop))).fac },\n  dsimp,\n  simp only [has_colimit.iso_of_nat_iso_ι_hom_assoc,\n    grothendieck_topology.diagram_pullback_app, colimit.ι_pre,\n    has_colimit.iso_of_nat_iso_ι_hom, ι_colim_map_assoc],\n  simp only [← category.assoc],\n  congr' 1,\n  ext,\n  dsimp,\n  simp only [category.assoc],\n  erw [multiequalizer.lift_ι, diagram_comp_iso_hom_ι, diagram_comp_iso_hom_ι,\n    ← F.map_comp, multiequalizer.lift_ι],\nend\n\n@[simp, reassoc]\nlemma ι_plus_comp_iso_hom (X) (W) : F.map (colimit.ι _ W) ≫ (J.plus_comp_iso F P).hom.app X =\n  (J.diagram_comp_iso F P X.unop).hom.app W ≫ colimit.ι _ W :=\nbegin\n  delta diagram_comp_iso plus_comp_iso,\n  dsimp [is_colimit.cocone_point_unique_up_to_iso],\n  simp only [← category.assoc],\n  erw (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P (unop X)))).fac,\n  dsimp,\n  simp,\nend\n\n@[simp, reassoc]\nlemma plus_comp_iso_whisker_left {F G : D ⥤ E} (η : F ⟶ G) (P : Cᵒᵖ ⥤ D)\n  [∀ (X : C), preserves_colimits_of_shape (J.cover X)ᵒᵖ F]\n  [∀ (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D), preserves_limit (W.index P).multicospan F]\n  [∀ (X : C), preserves_colimits_of_shape (J.cover X)ᵒᵖ G]\n  [∀ (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D), preserves_limit (W.index P).multicospan G] :\n  whisker_left _ η ≫ (J.plus_comp_iso G P).hom =\n  (J.plus_comp_iso F P).hom ≫ J.plus_map (whisker_left _ η) :=\nbegin\n  ext X,\n  apply (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).hom_ext,\n  intros W,\n  dsimp [plus_obj, plus_map],\n  simp only [ι_plus_comp_iso_hom, ι_colim_map, whisker_left_app, ι_plus_comp_iso_hom_assoc,\n    nat_trans.naturality_assoc, grothendieck_topology.diagram_nat_trans_app],\n  simp only [← category.assoc],\n  congr' 1,\n  ext,\n  dsimp,\n  simpa,\nend\n\n/-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`, functorially in `F`. -/\n@[simps hom_app inv_app]\ndef plus_functor_whisker_left_iso (P : Cᵒᵖ ⥤ D)\n  [∀ (F : D ⥤ E) (X : C), preserves_colimits_of_shape (J.cover X)ᵒᵖ F]\n  [∀ (F : D ⥤ E) (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D),\n    preserves_limit (W.index P).multicospan F] :\n  (whiskering_left _ _ E).obj (J.plus_obj P) ≅\n  (whiskering_left _ _ _).obj P ⋙ J.plus_functor E :=\nnat_iso.of_components\n(λ X, plus_comp_iso _ _ _) $ λ F G η, plus_comp_iso_whisker_left _ _ _\n\n@[simp, reassoc]\nlemma plus_comp_iso_whisker_right {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) :\n  whisker_right (J.plus_map η) F ≫ (J.plus_comp_iso F Q).hom =\n  (J.plus_comp_iso F P).hom ≫ J.plus_map (whisker_right η F) :=\nbegin\n  ext X,\n  apply (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).hom_ext,\n  intros W,\n  dsimp [plus_obj, plus_map],\n  simp only [ι_colim_map, whisker_right_app, ι_plus_comp_iso_hom_assoc,\n    grothendieck_topology.diagram_nat_trans_app],\n  simp only [← category.assoc, ← F.map_comp],\n  dsimp [colim_map, is_colimit.map],\n  simp only [colimit.ι_desc],\n  dsimp [cocones.precompose],\n  simp only [functor.map_comp, category.assoc, ι_plus_comp_iso_hom],\n  simp only [← category.assoc],\n  congr' 1,\n  ext,\n  dsimp,\n  simp only [diagram_comp_iso_hom_ι_assoc, multiequalizer.lift_ι,\n    diagram_comp_iso_hom_ι, category.assoc],\n  simp only [← F.map_comp, multiequalizer.lift_ι],\nend\n\n/-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`, functorially in `P`. -/\n@[simps hom_app inv_app]\ndef plus_functor_whisker_right_iso : J.plus_functor D ⋙ (whiskering_right _ _ _).obj F ≅\n  (whiskering_right _ _ _).obj F ⋙ J.plus_functor E :=\nnat_iso.of_components (λ P, J.plus_comp_iso _ _) $ λ P Q η, plus_comp_iso_whisker_right _ _ _\n\n@[simp, reassoc]\nlemma whisker_right_to_plus_comp_plus_comp_iso_hom :\n  whisker_right (J.to_plus _) _ ≫ (J.plus_comp_iso F P).hom = J.to_plus _ :=\nbegin\n  ext,\n  dsimp [to_plus],\n  simp only [ι_plus_comp_iso_hom, functor.map_comp, category.assoc],\n  simp only [← category.assoc],\n  congr' 1,\n  ext,\n  delta cover.to_multiequalizer,\n  simp only [diagram_comp_iso_hom_ι, category.assoc, ← F.map_comp],\n  erw [multiequalizer.lift_ι, multiequalizer.lift_ι],\n  refl,\nend\n\n@[simp]\nlemma to_plus_comp_plus_comp_iso_inv : J.to_plus _ ≫ (J.plus_comp_iso F P).inv =\n  whisker_right (J.to_plus _) _ :=\nby simp [iso.comp_inv_eq]\n\nlemma plus_comp_iso_inv_eq_plus_lift (hP : presheaf.is_sheaf J ((J.plus_obj P) ⋙ F)) :\n  (J.plus_comp_iso F P).inv = J.plus_lift (whisker_right (J.to_plus _) _) hP :=\nby { apply J.plus_lift_unique, simp [iso.comp_inv_eq] }\n\nend category_theory.grothendieck_topology\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/sites/compatible_plus.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.4832698858030477}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.sums.basic\n\n/-!\n# Associator for binary disjoint union of categories.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe associator functor `((C ⊕ D) ⊕ E) ⥤ (C ⊕ (D ⊕ E))` and its inverse form an equivalence.\n-/\n\nuniverses v u\n\nopen category_theory\nopen sum\n\nnamespace category_theory.sum\n\nvariables (C : Type u) [category.{v} C]\n          (D : Type u) [category.{v} D]\n          (E : Type u) [category.{v} E]\n\n/--\nThe associator functor `(C ⊕ D) ⊕ E ⥤ C ⊕ (D ⊕ E)` for sums of categories.\n-/\ndef associator : (C ⊕ D) ⊕ E ⥤ C ⊕ (D ⊕ E) :=\n{ obj := λ X, match X with\n  | inl (inl X) := inl X\n  | inl (inr X) := inr (inl X)\n  | inr X := inr (inr X)\n  end,\n  map := λ X Y f, match X, Y, f with\n  | inl (inl X), inl (inl Y), f := f\n  | inl (inr X), inl (inr Y), f := f\n  | inr X, inr Y, f := f\n  end }\n\n@[simp] lemma associator_obj_inl_inl (X) : (associator C D E).obj (inl (inl X)) = inl X := rfl\n@[simp] lemma associator_obj_inl_inr (X) : (associator C D E).obj (inl (inr X)) = inr (inl X) := rfl\n@[simp] lemma associator_obj_inr (X) : (associator C D E).obj (inr X) = inr (inr X) := rfl\n@[simp] lemma associator_map_inl_inl {X Y : C} (f : inl (inl X) ⟶ inl (inl Y)) :\n  (associator C D E).map f = f := rfl\n@[simp] lemma associator_map_inl_inr {X Y : D} (f : inl (inr X) ⟶ inl (inr Y)) :\n  (associator C D E).map f = f := rfl\n@[simp] lemma associator_map_inr {X Y : E} (f : inr X ⟶ inr Y) :\n  (associator C D E).map f = f := rfl\n\n/--\nThe inverse associator functor `C ⊕ (D ⊕ E) ⥤ (C ⊕ D) ⊕ E` for sums of categories.\n-/\ndef inverse_associator : C ⊕ (D ⊕ E) ⥤ (C ⊕ D) ⊕ E :=\n{ obj := λ X, match X with\n  | inl X := inl (inl X)\n  | inr (inl X) := inl (inr X)\n  | inr (inr X) := inr X\n  end,\n  map := λ X Y f, match X, Y, f with\n  | inl X, inl Y, f := f\n  | inr (inl X), inr (inl Y), f := f\n  | inr (inr X), inr (inr Y), f := f\n  end }\n\n@[simp] lemma inverse_associator_obj_inl (X) :\n  (inverse_associator C D E).obj (inl X) = inl (inl X) := rfl\n@[simp] lemma inverse_associator_obj_inr_inl (X) :\n  (inverse_associator C D E).obj (inr (inl X)) = inl (inr X) := rfl\n@[simp] lemma inverse_associator_obj_inr_inr (X) :\n  (inverse_associator C D E).obj (inr (inr X)) = inr X := rfl\n@[simp] \n\n/--\nThe equivalence of categories expressing associativity of sums of categories.\n-/\ndef associativity : (C ⊕ D) ⊕ E ≌ C ⊕ (D ⊕ E) :=\nequivalence.mk (associator C D E) (inverse_associator C D E)\n  (nat_iso.of_components (λ X, eq_to_iso (by tidy)) (by tidy))\n  (nat_iso.of_components (λ X, eq_to_iso (by tidy)) (by tidy))\n\ninstance associator_is_equivalence : is_equivalence (associator C D E) :=\n(by apply_instance : is_equivalence (associativity C D E).functor)\n\ninstance inverse_associator_is_equivalence : is_equivalence (inverse_associator C D E) :=\n(by apply_instance : is_equivalence (associativity C D E).inverse)\n\n-- TODO unitors?\n-- TODO pentagon natural transformation? ...satisfying?\nend category_theory.sum\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/sums/associator.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.48326988580304764}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.functor\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l u₃ v₃ \n\nnamespace Mathlib\n\n/-!\n# Unbundled functors, as a typeclass decorating the object-level function.\n-/\n\nnamespace category_theory\n\n\n/-- A unbundled functor. -/\n-- Perhaps in the future we could redefine `functor` in terms of this, but that isn't the\n\n-- immediate plan.\n\nclass functorial {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C → D) \nwhere\n  map : {X Y : C} → (X ⟶ Y) → (F X ⟶ F Y)\n  map_id' : autoParam (C → map 𝟙 = 𝟙)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  map_comp' : autoParam (∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = map f ≫ map g)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n/--\nIf `F : C → D` (just a function) has `[functorial F]`,\nwe can write `map F f : F X ⟶ F Y` for the action of `F` on a morphism `f : X ⟶ Y`.\n-/\ndef map {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C → D) [functorial F] {X : C} {Y : C} (f : X ⟶ Y) : F X ⟶ F Y :=\n  functorial.map f\n\n@[simp] theorem map_as_map {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C → D} [functorial F] {X : C} {Y : C} {f : X ⟶ Y} : functorial.map f = map F f :=\n  rfl\n\n@[simp] theorem functorial.map_id {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C → D} [functorial F] {X : C} : map F 𝟙 = 𝟙 :=\n  functorial.map_id' X\n\n@[simp] theorem functorial.map_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C → D} [functorial F] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} : map F (f ≫ g) = map F f ≫ map F g :=\n  functorial.map_comp' f g\n\nnamespace functor\n\n\n/--\nBundle a functorial function as a functor.\n-/\ndef of {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C → D) [I : functorial F] : C ⥤ D :=\n  mk F functorial.map\n\nend functor\n\n\nprotected instance functor.obj.functorial {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) : functorial (functor.obj F) :=\n  functorial.mk (functor.map F)\n\n@[simp] theorem map_functorial_obj {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) {X : C} {Y : C} (f : X ⟶ Y) : map (functor.obj F) f = functor.map F f :=\n  rfl\n\nprotected instance functorial_id {C : Type u₁} [category C] : functorial id :=\n  functorial.mk fun (X Y : C) (f : X ⟶ Y) => f\n\n/--\n`G ∘ F` is a functorial if both `F` and `G` are.\n-/\n-- This is no longer viable as an instance in Lean 3.7,\n\n-- #lint reports an instance loop\n\n-- Will this be a problem?\n\ndef functorial_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C → D) [functorial F] (G : D → E) [functorial G] : functorial (G ∘ F) :=\n  functorial.mk (functor.map (functor.of F ⋙ functor.of G))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/functorial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.6261241772283035, "lm_q1q2_score": 0.4832698816055839}}
{"text": "import category_theory.adjunction.basic\nimport category_theory.types\n\nopen category_theory category_theory.category category_theory.functor category_theory.adjunction\n\nuniverses v u\n\nnoncomputable theory\n\nvariables {C D : Type u} [category.{v} C] [category.{v} D] (L : C ⥤ D) (R : D ⥤ C)\n\n/-\n  Some more results about adjucntion. We promote any adjunction to a natural\n  isomomorphism between hom functors, and we promote such iso to an adjunction\n-/\n\nopen opposite\n\n-- (c, d) --> C(c, Rd)\ndef right_hom : Cᵒᵖ × D ⥤ Type v := \n{ obj := λ x, (x.1.unop ⟶ R.obj x.2),\n  map := λ _ _ f g, f.fst.unop ≫ g ≫ R.map f.snd,\n  map_id' := λ x, \n    by {funext, rw [prod_id_fst, prod_id_snd, unop_id, id_comp, map_id, comp_id], refl}, \n  map_comp' := λ _ _ _ f g, by tidy }\n\n-- (c, d) --> D(Lc, d)\ndef left_hom : Cᵒᵖ × D ⥤ Type v := \n{ obj := λ x, (L.obj x.1.unop ⟶ x.2),\n  map := λ _ _ f g, L.map f.fst.unop ≫ g ≫ f.snd,\n  map_id' := λ x, \n    by {funext, rw [prod_id_fst, prod_id_snd, unop_id, map_id, id_comp, comp_id], refl},\n  map_comp' := λ _ _ _ f g, by tidy }\n\n@[simp] lemma left_hom_obj (x : Cᵒᵖ × D) : (left_hom L).obj x = (L.obj x.1.unop ⟶ x.2) := rfl\n@[simp] lemma right_hom_obj (x : Cᵒᵖ × D) : (right_hom R).obj x = (x.1.unop ⟶ R.obj x.2) := rfl\n\nlemma left_hom_map {x y : Cᵒᵖ × D} (f : x ⟶ y) (g : (left_hom L).obj x) : \n  (left_hom L).map f g = L.map f.fst.unop ≫ g ≫ f.snd := rfl\nlemma right_hom_map {x y : Cᵒᵖ × D} (f : x ⟶ y) (g : (right_hom R).obj x) : \n  (right_hom R).map f g = f.fst.unop ≫ g ≫ R.map f.snd := rfl\n\nvariables {L R}\n\nlemma left_hom_iso_right_hom_of_adjunction (adj : L ⊣ R) : left_hom L ≅ right_hom R   :=\nnat_iso.of_components \n  (λ x, (equiv.to_iso (adj.hom_equiv x.1.unop x.2) : (left_hom L).obj x ≅ (right_hom R).obj x)) \n  (begin  intros x y f,  \n    ext g, simp, \n    rw [left_hom_map, map_comp, ←assoc, unit_naturality adj, map_comp, right_hom_map],\n    simp only [assoc]  \n   end)\n\ndef core_adjunction_of_left_hom_iso_right (i : left_hom L ≅ right_hom R) : \n  adjunction.core_hom_equiv L R :=\n{ hom_equiv := λ x y, iso.to_equiv (i.app (op x, y)),\n  hom_equiv_naturality_left_symm' := \n  begin\n    intros c c' d f g, simp,\n    convert congr_fun (i.inv.naturality ((f.op, 𝟙 d) : (op c', d) ⟶ (op c, d))) g; simp,\n  end,\n  hom_equiv_naturality_right' := \n  begin\n    intros c d d' f g, simp,\n    have g' := congr_fun (i.hom.naturality ((𝟙 (op c), g) : (op c, d) ⟶ (op c, d'))) f,\n    simp at g', rw [left_hom_map, right_hom_map] at g',\n    simp at g', rw [L.map_id c, id_comp (f ≫ g)] at g',\n    rw g', apply id_comp,\n  end }\n \ndef adjunction_of_left_hom_iso_right (i : left_hom L ≅ right_hom R) : L ⊣ R :=\nmk_of_hom_equiv (core_adjunction_of_left_hom_iso_right i)", "meta": {"author": "cchanavat", "repo": "lean-topos", "sha": "c8e22c35ed4dc4ea0d74a59c91785b8a4c8e48a4", "save_path": "github-repos/lean/cchanavat-lean-topos", "path": "github-repos/lean/cchanavat-lean-topos/lean-topos-c8e22c35ed4dc4ea0d74a59c91785b8a4c8e48a4/adjunction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4832698750335064}}
{"text": "variables (f : ℕ → ℕ) (k : ℕ)\n\nexample (h₁ : f 0 = 0) (h₂ : k = 0) : f k = 0 :=\n  by simp [h₁, h₂]\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch5/ex0708.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4832698750335063}}
{"text": "import topology.uniform_space.cauchy\nimport topology.algebra.uniform_group\nimport for_mathlib.topological_groups\n\nopen filter set\n\nlocal infixr ` ×ᶠ `:51 := filter.prod\nlocal notation `𝓤` := uniformity\nlocal notation `𝓝` x:70 := nhds x\n\nsection\nopen tactic\nmeta def clean_step : tactic unit :=\ndo tgt ← target,\n   match tgt with\n   | `(%%a → %%b) := `[intros]\n   | `(%%a ↔ %%b) := match a with\n                     | `(%%c → %%d) := if c.has_var then `[apply imp_congr] else `[apply forall_congr]\n                     | `(Exists %%c) := `[apply exists_congr]\n                     | _ := `[exact iff.rfl]\n                     end\n   | _ := fail \"Goal is not a forall, implies or iff\"\n   end\n\nmeta def tactic.interactive.clean_iff : tactic unit := do repeat clean_step\nend\n\nvariables (α : Type*) [uniform_space α] [add_group α] [uniform_add_group α]\n\nlemma add_group_filter_basis.cauchy_iff {B : add_group_filter_basis α}\n  (h : uniform_space.to_topological_space α = B.topology) {F : filter α} :\n  cauchy F ↔ F ≠ ⊥ ∧ ∀ U ∈ B, ∃ M ∈ F, ∀ x y ∈ M, y - x ∈ U :=\nbegin\n  suffices : F ×ᶠ F ≤ 𝓤 α ↔ ∀ U ∈ B, ∃ M ∈ F, ∀ x y ∈ M, y - x ∈ U,\n    by split ; rintros ⟨h', h⟩ ; refine ⟨h', _⟩ ; [rwa ← this, rwa this],\n  rw [uniformity_eq_comap_nhds_zero α, ← map_le_iff_le_comap],\n  change tendsto _ _ _ ↔ _,\n  rw [B.nhds_zero_eq h, filter_basis.tendsto_into],\n  simp only [mem_prod_same_iff],\n  clean_iff,\n  rw [subset_def, prod.forall],\n  clean_iff,\n  rw [prod_mk_mem_set_prod_eq],\n  tauto!\nend\n\nlemma test {α : Type*} [has_sub α] (S T : set $ set α) :\n (∀ {V : set α}, V ∈ S → (∃ (t : set α) (H : t ∈ T), set.prod t t ⊆ (λ (x : α × α), x.snd - x.fst) ⁻¹' V)) ↔\n    ∀ (U : set α), U ∈ S → (∃ (M : set α) (H : M ∈ T), ∀ (x y : α), x ∈ M → y ∈ M → y - x ∈ U) :=\nbegin\n  clean_iff,\n  rw [subset_def, prod.forall],\n  clean_iff,\n  rw [set.prod_mk_mem_set_prod_eq],\n  tauto!\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-perfectoid-spaces", "sha": "95a6520ce578b30a80b4c36e36ab2d559a842690", "save_path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces", "path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces/lean-perfectoid-spaces-95a6520ce578b30a80b4c36e36ab2d559a842690/src/for_mathlib/uniform_space/group_basis.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4832698750335063}}
{"text": "\n/- In-memory representation of values. -/\n\nimport .ast .integers .values\n\nnamespace memdata\nopen ast integers values word floats\n     ast.memory_chunk\n\ninductive quantity : Type | Q32 | Q64\nopen quantity\n\ninstance quantity_eq : decidable_eq quantity := by tactic.mk_dec_eq_instance\n\ndef quantity.size : quantity → ℕ\n| Q32 := 4\n| Q64 := 8\n\nlemma quantity.size_pos (q : quantity) : q.size > 0 :=\nby cases q; exact dec_trivial\n\n\n/- * Memory values -/\n\n/- A ``memory value'' is a byte-sized quantity that describes the current\n  content of a memory cell.  It can be either:\n- a concrete 8-bit integer;\n- a byte-sized fragment of an opaque value;\n- the special constant [Undef] that represents uninitialized memory.\n-/\n\n/- Values stored in memory cells. -/\n\ninductive memval : Type\n| Undef : memval\n| Byte : byte → memval\n| Fragment : val → quantity → nat → memval.\nopen memval\n\n/- * Encoding and decoding integers -/\n\n/- We define functions to convert between integers and lists of bytes\n  of a given length -/\n\ndef rev_if_be (l : list byte) : list byte :=\nif archi.big_endian then l.reverse else l\n\ndef encode_int (sz : ℕ) (x : ℤ) : list byte :=\nrev_if_be (words_of_int sz x)\n\ndef decode_int (b : list byte) : ℕ :=\nnat_of_words (rev_if_be b)\n\n/- Length properties -/\n\n@[simp] lemma rev_if_be_length (l) : (rev_if_be l).length = l.length :=\nby delta rev_if_be; by_cases (archi.big_endian : Prop); simp [h]\n\n@[simp] lemma encode_int_length (sz x) : (encode_int sz x).length = sz :=\nby simp [encode_int]\n\n/- Decoding after encoding -/\n\nlemma rev_if_be_involutive (l) : rev_if_be (rev_if_be l) = l :=\nby delta rev_if_be; by_cases (archi.big_endian : Prop); simp [h]\n\nlemma decode_encode_int (n x) : decode_int (encode_int n x) = x.nat_mod (2^(n * 8)) :=\nby simp [decode_int, encode_int, rev_if_be_involutive]; refl\n\nlemma decode_encode_int_1 (x : int32) :\n  repr (decode_int (encode_int 1 (unsigned x))) = zero_ext 8 x := sorry'\n\nlemma decode_encode_int_2 (x : int32) :\n  repr (decode_int (encode_int 2 (unsigned x))) = zero_ext 16 x := sorry'\n\nlemma decode_encode_int_4 (x : int32) :\n  repr (decode_int (encode_int 4 (unsigned x))) = x := sorry'\n\nlemma decode_encode_int_8 (x : int64) :\n  repr (decode_int (encode_int 8 (unsigned x))) = x := sorry'\n\n/- A length-[n] encoding depends only on the low [8*n] bits of the integer. -/\n\nlemma encode_int_mod (n) {x y} (h : (repr x : word (8*n)) = repr y) :\n  encode_int n x = encode_int n y :=\nby dsimp [encode_int]; rw words_of_int_mod _ (mod_eq_of_repr_eq h)\n\nlemma encode_int_8_mod (x y) : (repr x : byte) = repr y →\n  encode_int 1 x = encode_int 1 y :=\nencode_int_mod 1\n\nlemma encode_int_16_mod (x y) : (repr x : word 16) = repr y →\n  encode_int 2 x = encode_int 2 y :=\nencode_int_mod 2\n\n/- * Encoding and decoding values -/\n\ndef inj_bytes (bl : list byte) : list memval :=\nbl.map Byte\n\ndef proj_bytes : list memval → option (list byte)\n| []              := some []\n| (Byte b :: vl') := list.cons b <$> proj_bytes vl'\n| _               := none\n\ntheorem length_inj_bytes (bl) : (inj_bytes bl).length = bl.length :=\nlist.length_map _ _\n\ntheorem proj_inj_bytes (bl) : proj_bytes (inj_bytes bl) = some bl :=\nbegin\n  simp [inj_bytes],\n  induction bl with b bl IH; simp [inj_bytes, proj_bytes],\n  simp [IH], refl\nend\n\nlemma inj_proj_bytes (cl bl) : proj_bytes cl = some bl → cl = inj_bytes bl := sorry'\n\ndef inj_value_rec (v : val) (q : quantity) : ℕ → list memval\n| 0 := []\n| (m + 1) := Fragment v q m :: inj_value_rec m\n\ndef inj_value (q : quantity) (v : val) : list memval :=\ninj_value_rec v q q.size\n\ndef check_value (v : val) (q : quantity) : ℕ → list memval → bool\n| 0 [] := tt\n| (m + 1) (Fragment v' q' m' :: vl') :=\n  v = v' ∧ q = q' ∧ m = m' ∧ check_value m vl'\n| _ _ := ff\n\ndef proj_value (q : quantity) (vl : list memval) : val :=\nmatch vl with\n| Fragment v q' n :: vl' :=\n      if check_value v q q.size vl then v else Vundef\n| _ := Vundef\nend\n\ndef encode_val : memory_chunk → val → list memval\n| Mint8signed    (Vint n)     := inj_bytes (encode_int 1 (unsigned n))\n| Mint8unsigned  (Vint n)     := inj_bytes (encode_int 1 (unsigned n))\n| Mint16signed   (Vint n)     := inj_bytes (encode_int 2 (unsigned n))\n| Mint16unsigned (Vint n)     := inj_bytes (encode_int 2 (unsigned n))\n| Mint32         (Vint n)     := inj_bytes (encode_int 4 (unsigned n))\n| Mint32         (Vptr b ofs) := if archi.ptr64 then list.repeat Undef 4 else inj_value Q32 (Vptr b ofs)\n| Mint64         (Vlong n)    := inj_bytes (encode_int 8 (unsigned n))\n| Mint64         (Vptr b ofs) := if archi.ptr64 then inj_value Q64 (Vptr b ofs) else list.repeat Undef 8\n| Mfloat32       (Vsingle n)  := inj_bytes (encode_int 4 (unsigned n.to_bits))\n| Mfloat64       (Vfloat n)   := inj_bytes (encode_int 8 (unsigned n.to_bits))\n| Many32         v            := inj_value Q32 v\n| Many64         v            := inj_value Q64 v\n| chunk          _            := list.repeat Undef chunk.size\n\ndef decode_val (chunk : memory_chunk) (vl : list memval) : val :=\nmatch proj_bytes vl, chunk with\n| some bl, Mint8signed    := Vint (sign_ext W8 (repr (decode_int bl)))\n| some bl, Mint8unsigned  := Vint (zero_ext 8 (repr (decode_int bl)))\n| some bl, Mint16signed   := Vint (sign_ext W16 (repr (decode_int bl)))\n| some bl, Mint16unsigned := Vint (zero_ext 16 (repr (decode_int bl)))\n| some bl, Mint32         := Vint (repr (decode_int bl))\n| some bl, Mint64         := Vlong (repr (decode_int bl))\n| some bl, Mfloat32       := float32.of_bits (repr (decode_int bl))\n| some bl, Mfloat64       := float.of_bits (repr (decode_int bl))\n| some bl, Many32         := Vundef\n| some bl, Many64         := Vundef\n| none,    Mint32         := if archi.ptr64 then Vundef else val.load_result chunk (proj_value Q32 vl)\n| none,    Many32         := val.load_result chunk (proj_value Q32 vl)\n| none,    Mint64         := if archi.ptr64 then val.load_result chunk (proj_value Q64 vl) else Vundef\n| none,    Many64         := val.load_result chunk (proj_value Q64 vl)\n| none,    _              := Vundef\nend\n\nlemma encode_val_length (chunk v) : (encode_val chunk v).length = chunk.size := sorry'\n\nlemma check_inj_value (v q n) : check_value v q n (inj_value_rec v q n) := sorry'\n\nlemma proj_inj_value (q v) : proj_value q (inj_value q v) = v := sorry'\n\ntheorem in_inj_value (mv v q) : mv ∈ inj_value q v → ∃ n, mv = Fragment v q n := sorry'\n\nlemma proj_inj_value_mismatch (q1 q2 v) : q1 ≠ q2 → proj_value q1 (inj_value q2 v) = Vundef := sorry'\n\ndef decode_encode_val : val → memory_chunk → memory_chunk → val → Prop\n| (Vundef)      _               _               v2 := v2 = Vundef\n| (Vint n)      Mint8signed     Mint8signed     v2 := v2 = Vint (sign_ext W8 n)\n| (Vint n)      Mint8unsigned   Mint8signed     v2 := v2 = Vint (sign_ext W8 n)\n| (Vint n)      Mint8signed     Mint8unsigned   v2 := v2 = Vint (zero_ext 8 n)\n| (Vint n)      Mint8unsigned   Mint8unsigned   v2 := v2 = Vint (zero_ext 8 n)\n| (Vint n)      Mint16signed    Mint16signed    v2 := v2 = Vint (sign_ext W16 n)\n| (Vint n)      Mint16unsigned  Mint16signed    v2 := v2 = Vint (sign_ext W16 n)\n| (Vint n)      Mint16signed    Mint16unsigned  v2 := v2 = Vint (zero_ext 16 n)\n| (Vint n)      Mint16unsigned  Mint16unsigned  v2 := v2 = Vint (zero_ext 16 n)\n| (Vint n)      Mint32          Mint32          v2 := v2 = Vint n\n| (Vint n)      Many32          Many32          v2 := v2 = Vint n\n| (Vint n)      Mint32          Mfloat32        v2 := v2 = float32.of_bits n\n| (Vint n)      Many64          Many64          v2 := v2 = Vint n\n| (Vint n)      Mint64          _               v2 := v2 = Vundef\n| (Vint n)      Mfloat32        _               v2 := v2 = Vundef\n| (Vint n)      Mfloat64        _               v2 := v2 = Vundef\n| (Vint n)      Many64          _               v2 := v2 = Vundef\n| (Vint n)      _               _               v2 := true /- nothing meaningful to say about v2 -/\n| (Vptr b ofs)  Mint32          Mint32          v2 := v2 = if archi.ptr64 then Vundef else Vptr b ofs\n| (Vptr b ofs)  Mint32          Many32          v2 := v2 = if archi.ptr64 then Vundef else Vptr b ofs\n| (Vptr b ofs)  Many32          Mint32          v2 := v2 = if archi.ptr64 then Vundef else Vptr b ofs\n| (Vptr b ofs)  Many32          Many32          v2 := v2 = if archi.ptr64 then Vundef else Vptr b ofs\n| (Vptr b ofs)  Mint64          Mint64          v2 := v2 = if archi.ptr64 then Vptr b ofs else Vundef\n| (Vptr b ofs)  Mint64          Many64          v2 := v2 = if archi.ptr64 then Vptr b ofs else Vundef\n| (Vptr b ofs)  Many64          Many64          v2 := v2 = Vptr b ofs\n| (Vptr b ofs)  Many64          Mint64          v2 := v2 = if archi.ptr64 then Vptr b ofs else Vundef\n| (Vptr b ofs)  _               _               v2 := v2 = Vundef\n| (Vlong n)     Mint64          Mint64          v2 := v2 = Vlong n\n| (Vlong n)     Mint64          Mfloat64        v2 := v2 = float.of_bits n\n| (Vlong n)     Many64          Many64          v2 := v2 = Vlong n\n| (Vlong n)     Mint8signed     _               v2 := v2 = Vundef\n| (Vlong n)     Mint8unsigned   _               v2 := v2 = Vundef\n| (Vlong n)     Mint16signed    _               v2 := v2 = Vundef\n| (Vlong n)     Mint16unsigned  _               v2 := v2 = Vundef\n| (Vlong n)     Mint32          _               v2 := v2 = Vundef\n| (Vlong n)     Mfloat32        _               v2 := v2 = Vundef\n| (Vlong n)     Mfloat64        _               v2 := v2 = Vundef\n| (Vlong n)     Many32          _               v2 := v2 = Vundef\n| (Vlong n)     _               _               v2 := true /- nothing meaningful to say about v2 -/\n| (Vfloat f)    Mfloat64        Mfloat64        v2 := v2 = Vfloat f\n| (Vfloat f)    Mfloat64        Mint64          v2 := v2 = float.to_bits f\n| (Vfloat f)    Many64          Many64          v2 := v2 = Vfloat f\n| (Vfloat f)    Mint8signed     _               v2 := v2 = Vundef\n| (Vfloat f)    Mint8unsigned   _               v2 := v2 = Vundef\n| (Vfloat f)    Mint16signed    _               v2 := v2 = Vundef\n| (Vfloat f)    Mint16unsigned  _               v2 := v2 = Vundef\n| (Vfloat f)    Mint32          _               v2 := v2 = Vundef\n| (Vfloat f)    Mfloat32        _               v2 := v2 = Vundef\n| (Vfloat f)    Mint64          _               v2 := v2 = Vundef\n| (Vfloat f)    Many32          _               v2 := v2 = Vundef\n| (Vfloat f)    _               _               v2 := true   /- nothing interesting to say about v2 -/\n| (Vsingle f)   Mfloat32        Mfloat32        v2 := v2 = Vsingle f\n| (Vsingle f)   Mfloat32        Mint32          v2 := v2 = float32.to_bits f\n| (Vsingle f)   Many32          Many32          v2 := v2 = Vsingle f\n| (Vsingle f)   Many64          Many64          v2 := v2 = Vsingle f\n| (Vsingle f)   Mint8signed     _               v2 := v2 = Vundef\n| (Vsingle f)   Mint8unsigned   _               v2 := v2 = Vundef\n| (Vsingle f)   Mint16signed    _               v2 := v2 = Vundef\n| (Vsingle f)   Mint16unsigned  _               v2 := v2 = Vundef\n| (Vsingle f)   Mint32          _               v2 := v2 = Vundef\n| (Vsingle f)   Mint64          _               v2 := v2 = Vundef\n| (Vsingle f)   Mfloat64        _               v2 := v2 = Vundef\n| (Vsingle f)   Many64          _               v2 := v2 = Vundef\n| (Vsingle f)   _               _               v2 := true /- nothing interesting to say about v2 -/\n\ntheorem decode_val_undef (bl chunk) : decode_val chunk (Undef :: bl) = Vundef := sorry'\n\ntheorem proj_bytes_inj_value (q v) : proj_bytes (inj_value q v) = none := sorry'\n\nlemma decode_encode_val_general (v chunk1 chunk2) :\n  decode_encode_val v chunk1 chunk2 (decode_val chunk2 (encode_val chunk1 v)) := sorry'\n\nlemma decode_encode_val_similar {v1 chunk1 chunk2 v2} :\n  decode_encode_val v1 chunk1 chunk2 v2 →\n  chunk1.type = chunk2.type →\n  chunk1.size = chunk2.size →\n  v2 = val.load_result chunk2 v1 := sorry'\n\nlemma decode_val_type (chunk cl) :\n  val.has_type (decode_val chunk cl) chunk.type := sorry'\n\nlemma encode_val_int8_signed_unsigned (v) : encode_val Mint8signed v = encode_val Mint8unsigned v := sorry'\n\nlemma encode_val_int16_signed_unsigned (v) : encode_val Mint16signed v = encode_val Mint16unsigned v := sorry'\n\nlemma encode_val_int8_zero_ext (n : int32) :\n  encode_val Mint8unsigned (Vint (zero_ext 8 n)) = encode_val Mint8unsigned (Vint n) := sorry'\n\nlemma encode_val_int8_sign_ext (n) :\n  encode_val Mint8signed (Vint (sign_ext W8 n)) = encode_val Mint8signed (Vint n) := sorry'\n\nlemma encode_val_int16_zero_ext (n) :\n  encode_val Mint16unsigned (Vint (zero_ext 16 n)) = encode_val Mint16unsigned (Vint n) := sorry'\n\nlemma encode_val_int16_sign_ext (n) :\n  encode_val Mint16signed (Vint (sign_ext W16 n)) = encode_val Mint16signed (Vint n) := sorry'\n\nlemma decode_val_cast_type (v : val) : memory_chunk → Prop\n| Mint8signed    := v = val.sign_ext W8 v\n| Mint8unsigned  := v = val.zero_ext 8 v\n| Mint16signed   := v = val.sign_ext W16 v\n| Mint16unsigned := v = val.zero_ext 16 v\n| _              := true\n\nlemma decode_val_cast (chunk l) : decode_val_cast_type (decode_val chunk l) chunk := sorry'\n\n/- Pointers cannot be forged. -/\n\ndef quantity_chunk : memory_chunk → quantity\n| Mint64   := Q64\n| Mfloat64 := Q64\n| Many64   := Q64\n| _        := Q32\n\ndef shape_encoding.b.type : val → Prop\n| (Vint _)    := true\n| (Vlong _)   := true\n| (Vfloat _)  := true\n| (Vsingle _) := true\n| _           := false\n\ninductive shape_encoding (chunk : memory_chunk) (v : val) : list memval → Prop\n| f (q i) : ∀ mvl,\n      (chunk = Mint32 ∨ chunk = Many32 ∨ chunk = Mint64 ∨ chunk = Many64) →\n      q = quantity_chunk chunk →\n      i+1 = q.size →\n      (∀ mv ∈ mvl, ∃ j, mv = Fragment v q j ∧ j+1 ≠ q.size) →\n      shape_encoding (Fragment v q i :: mvl)\n| b (b mvl) : memdata.shape_encoding.b.type v →\n      (∀ mv ∈ mvl, ∃ b', mv = Byte b') → shape_encoding (Byte b :: mvl)\n| u (mvl) : (∀ mv ∈ mvl, mv = Undef) → shape_encoding (Undef :: mvl)\n\nlemma encode_val_shape (chunk v) : shape_encoding chunk v (encode_val chunk v) := sorry'\n\ninductive shape_decoding (chunk : memory_chunk) : list memval → val → Prop\n| f (v q i) : ∀ mvl,\n      (chunk = Mint32 ∨ chunk = Many32 ∨ chunk = Mint64 ∨ chunk = Many64) →\n      q = quantity_chunk chunk →\n      i+1 = q.size →\n      (∀ mv ∈ mvl, ∃ j, mv = Fragment v q j ∧ j+1 ≠ q.size) →\n      shape_decoding (Fragment v q i :: mvl) (val.load_result chunk v)\n| b (b mvl v) : shape_encoding.b.type v →\n      (∀ mv ∈ mvl, ∃ b', mv = Byte b') →\n      shape_decoding (Byte b :: mvl) v\n| u (mvl) : shape_decoding mvl Vundef\n\nlemma decode_val_shape (chunk mv1 mvl) :\n  shape_decoding chunk (mv1 :: mvl) (decode_val chunk (mv1 :: mvl)) := sorry'\n\n/- * Compatibility with memory injections -/\n\n/- Relating two memory values according to a memory injection. -/\n\ninductive memval_inject (f : meminj) : memval → memval → Prop\n| byte (n) : memval_inject (Byte n) (Byte n)\n| frag (v1 v2 q n) : inject f v1 v2 →\n      memval_inject (Fragment v1 q n) (Fragment v2 q n)\n| undef (mv) : memval_inject Undef mv\n\nlemma memval_inject.incr (f f' v1 v2) :\n  memval_inject f v1 v2 → inject_incr f f' → memval_inject f' v1 v2 := sorry'\n\n/- [decode_val], applied to lists of memory values that are pairwise\n  related by [memval_inject], returns values that are related by [inject]. -/\n\nlemma proj_bytes_inject (f vl vl') :\n  list.forall2 (memval_inject f) vl vl' →\n  ∀ bl, proj_bytes vl = some bl → proj_bytes vl' = some bl := sorry'\n\nlemma check_value_inject (f vl vl') :\n  list.forall2 (memval_inject f) vl vl' →\n  ∀ v v' q n,\n  check_value v q n vl →\n  inject f v v' → v ≠ Vundef →\n  check_value v' q n vl' := sorry'\n\nlemma proj_value_inject (f q vl1 vl2) :\n  list.forall2 (memval_inject f) vl1 vl2 →\n  inject f (proj_value q vl1) (proj_value q vl2) := sorry'\n\nlemma proj_bytes_not_inject (f vl vl') :\n  list.forall2 (memval_inject f) vl vl' →\n  proj_bytes vl = none → proj_bytes vl' ≠ none → Undef ∈ vl := sorry'\n\nlemma check_value_undef (n q v vl) :\n  Undef ∈ vl → ¬ check_value v q n vl := sorry'\n\nlemma proj_value_undef (q vl) : Undef ∈ vl → proj_value q vl = Vundef := sorry'\n\ntheorem decode_val_inject (f vl1 vl2 chunk) :\n  list.forall2 (memval_inject f) vl1 vl2 →\n  inject f (decode_val chunk vl1) (decode_val chunk vl2) := sorry'\n\n/- Symmetrically, [encode_val], applied to values related by [inject],\n  returns lists of memory values that are pairwise\n  related by [memval_inject]. -/\n\nlemma inj_bytes_inject (f bl) :\n  list.forall2 (memval_inject f) (inj_bytes bl) (inj_bytes bl) := sorry'\n\nlemma repeat_Undef_inject_any (f) (vl : list memval) :\n  list.forall2 (memval_inject f) (list.repeat Undef vl.length) vl := sorry'\n\nlemma repeat_Undef_inject_encode_val (f) (chunk : memory_chunk) (v) :\n  list.forall2 (memval_inject f) (list.repeat Undef chunk.size) (encode_val chunk v) := sorry'\n\nlemma repeat_Undef_inject_self (f n) :\n  list.forall2 (memval_inject f) (list.repeat Undef n) (list.repeat Undef n) := sorry'\n\nlemma inj_value_inject (f v1 v2 q) : inject f v1 v2 →\n  list.forall2 (memval_inject f) (inj_value q v1) (inj_value q v2) := sorry'\n\ntheorem encode_val_inject (f v1 v2 chunk) : inject f v1 v2 →\n  list.forall2 (memval_inject f) (encode_val chunk v1) (encode_val chunk v2) := sorry'\n\ndef memval_lessdef : memval → memval → Prop := memval_inject inject_id\n\nlemma memval_lessdef_refl (mv) : memval_lessdef mv mv :=\nby dsimp [memval_lessdef]; cases mv; constructor; apply val_inject_id.2; constructor\n\n/- [memval_inject] and compositions -/\n\nlemma memval_inject_compose {f f' v1 v2 v3} :\n  memval_inject f v1 v2 → memval_inject f' v2 v3 →\n  memval_inject (f.comp f') v1 v3 := sorry'\n\n/- * Breaking 64-bit memory accesses into two 32-bit accesses -/\n\nlemma length_proj_bytes {l b} : proj_bytes l = some b → b.length = l.length := sorry'\n\nlemma proj_bytes_append (l2 l1) : proj_bytes (l1 ++ l2) =\n  do b1 ← proj_bytes l1, b2 ← proj_bytes l2, some (b1 ++ b2) := sorry'\n\nlemma decode_val_int64 {l1 l2 : list memval} : l1.length = 4 → l2.length = 4 → ¬ archi.ptr64 →\n  lessdef (decode_val Mint64 (l1 ++ l2)) (long_of_words\n    (decode_val Mint32 (if archi.big_endian then l1 else l2))\n    (decode_val Mint32 (if archi.big_endian then l2 else l1))) := sorry'\n\nlemma encode_val_int64 (v) : ¬ archi.ptr64 → encode_val Mint64 v =\n     encode_val Mint32 (if archi.big_endian then hiword v else loword v)\n  ++ encode_val Mint32 (if archi.big_endian then loword v else hiword v) := sorry'\n\nend memdata", "meta": {"author": "digama0", "repo": "kremlin", "sha": "d4665929ce9012e93a0b05fc7063b96256bab86f", "save_path": "github-repos/lean/digama0-kremlin", "path": "github-repos/lean/digama0-kremlin/kremlin-d4665929ce9012e93a0b05fc7063b96256bab86f/memdata.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.48326986964873564}}
{"text": "/-\nCopyright (c) 2021 Kalle Kytölä. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kalle Kytölä\n-/\nimport portmanteau_definitions\nimport portmanteau_topological_lemmas\nimport portmanteau_open_equiv_closed\n\n\n\nnoncomputable theory\nopen measure_theory\n\n\n\nnamespace portmanteau\n\nsection portmanteau_open_closed_implies_borel\n\n\n\nvariables {α : Type} [topological_space α]\n\n\nlemma portmanteau_open_closed_imp_borel_cond\n  (μseq : ℕ → @measure_theory.measure α (borel α)) (μ : @measure_theory.measure α (borel α)) : \n    portmanteau_open μseq μ ∧ portmanteau_closed μseq μ\n    → portmanteau_borel μseq μ :=\nbegin\n  rintros ⟨ hopcond , hclcond ⟩ ,\n  intros E hEborel hEnullbdry ,\n  set Ecl := closure E with hEcl ,\n  set Eint := interior E with hEint ,\n  have h_E_subset_Ecl : E ⊆ Ecl := subset_closure ,\n  have h_Eint_subset_E : Eint ⊆ E := interior_subset ,\n  have ineq_E_le_Ecl := @measure_mono α (borel(α)) μ E Ecl subset_closure ,\n  have ineq_E_le_Ecl_seq := (λ (n : ℕ) , @measure_mono α (borel(α)) (μseq(n)) E Ecl subset_closure ) ,\n  have ineq_Eint_le_E := @measure_mono α (borel(α)) μ Eint E interior_subset ,\n  have ineq_Eint_le_E_seq := (λ (n : ℕ) , @measure_mono α (borel(α)) (μseq(n)) Eint E interior_subset) ,\n  have equalities := meas_eq_various_of_null_bdry μ E hEnullbdry ,\n  have pt_limsup : limsup_enn (λ n , (μseq(n))(E)) ≤ μ(E) ,\n  { calc limsup_enn (λ n , (μseq(n))(E))\n        ≤ limsup_enn (λ n , (μseq(n))(Ecl))  : limsup_enn_mono ineq_E_le_Ecl_seq\n    ... ≤ μ(Ecl)                             : hclcond Ecl is_closed_closure\n    ... = μ(E)                               : by rw equalities.2 ,\n    } ,\n  have pt_liminf : μ(E) ≤ liminf_enn (λ n , (μseq(n))(E)) ,\n  { calc μ(E) = μ(Eint)                      : by rw equalities.1\n    ... ≤ liminf_enn (λ n , (μseq(n))(Eint)) : hopcond Eint is_open_interior\n    ... ≤ liminf_enn (λ n , (μseq(n))(E))    : liminf_enn_mono ineq_Eint_le_E_seq ,\n    } ,\n  have key := lim_eq_liminf_of_limsup_le_liminf_ennreal (le_trans pt_limsup pt_liminf) ,\n  suffices : liminf_enn (λ n , (μseq(n))(E)) = μ(E) ,\n  { rw ← this ,\n    exact key , } , \n  apply le_antisymm ,\n  { exact le_trans (liminf_le_limsup_enn (λ n , (μseq(n))(E))) pt_limsup , } ,\n  { exact pt_liminf , } ,\nend\n\n\nlemma portmanteau_open_imp_borel\n  (μseq : ℕ → @measure_theory.measure α (borel α)) \n  (μseq_fin : ∀ (n : ℕ) , @probability_measure α (borel(α)) (μseq(n)))\n  (μ : @measure_theory.measure α (borel α)) (μ_fin : @probability_measure α (borel(α)) μ) : \n    portmanteau_open μseq μ → portmanteau_borel μseq μ :=\nbegin\n  intros hopcond ,\n  have hclcond := portmanteau_open_imp_closed_cond μseq μseq_fin μ μ_fin hopcond ,\n  exact portmanteau_open_closed_imp_borel_cond μseq μ ⟨ hopcond , hclcond ⟩ ,\nend\n\n\nlemma portmanteau_closed_imp_borel\n  (μseq : ℕ → @measure_theory.measure α (borel α)) \n  (μseq_fin : ∀ (n : ℕ) , @probability_measure α (borel(α)) (μseq(n)))\n  (μ : @measure_theory.measure α (borel α)) (μ_fin : @probability_measure α (borel(α)) μ) : \n    portmanteau_closed μseq μ → portmanteau_borel μseq μ :=\nbegin\n  intros hclcond ,\n  have hopcond := portmanteau_closed_imp_open_cond μseq μseq_fin μ μ_fin hclcond ,\n  exact portmanteau_open_closed_imp_borel_cond μseq μ ⟨ hopcond , hclcond ⟩ ,\nend\n\n\nend portmanteau_open_closed_implies_borel\n\nend portmanteau\n", "meta": {"author": "kkytola", "repo": "lean_portmanteau", "sha": "ac55eb4e24be43032cbc082e2b68d8fb8bd63f22", "save_path": "github-repos/lean/kkytola-lean_portmanteau", "path": "github-repos/lean/kkytola-lean_portmanteau/lean_portmanteau-ac55eb4e24be43032cbc082e2b68d8fb8bd63f22/portmanteau_open_closed_imp_borel.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4832166754253233}}
{"text": "import for_mathlib.locally_closed\n\nnamespace topological_space\n\nvariables (α β : Type*) [topological_space α] [topological_space β] (f : α → β)\n\ndef closed_points : set α := { x : α | is_closed ({x} : set α) }\n\nlemma mem_closed_points {x} : x ∈ closed_points α ↔ is_closed ({x} : set α) := iff.rfl\n\ndef is_jacobson : Prop :=\n∀ Z, is_closed Z → closure (Z ∩ closed_points α) = Z\n\nvariables {α β f}\n\nlemma is_jacobson_iff_locally_closed : \n  is_jacobson α ↔ ∀ Z : set α, Z.nonempty → is_locally_closed Z → (Z ∩ closed_points α).nonempty :=\nbegin\n  split,\n  { simp_rw [is_locally_closed_iff_is_open_coboundary, coboundary, is_open_compl_iff,\n      ← set.ne_empty_iff_nonempty],\n    intros H Z hZ hZ' e,\n    have : Z ⊆ closure Z \\ Z,\n    { refine subset_closure.trans _,\n      nth_rewrite 0 ← H (closure Z) is_closed_closure,\n      rw [hZ'.closure_subset_iff, set.subset_diff, set.disjoint_iff, set.inter_assoc,\n        set.inter_comm _ Z, e],\n      exact ⟨set.inter_subset_left _ _, set.inter_subset_right _ _⟩ },\n    rw [set.subset_diff, disjoint_self, set.bot_eq_empty] at this,\n    exact hZ this.2 },\n  { intros H Z hZ,\n    refine subset_antisymm (hZ.closure_subset_iff.mpr $ set.inter_subset_left _ _) _,\n    rw [← set.disjoint_compl_left_iff_subset, set.disjoint_iff_inter_eq_empty, \n      ← set.not_nonempty_iff_eq_empty],\n    intro H',\n    have := H _ H' (is_closed_closure.is_open_compl.is_locally_closed.inter hZ.is_locally_closed),\n    rw [← set.ne_empty_iff_nonempty, ne.def, set.inter_assoc,\n      ← set.disjoint_iff_inter_eq_empty, set.disjoint_compl_left_iff_subset] at this,\n    exact this subset_closure }\nend\n\nalias is_jacobson_iff_locally_closed ↔ is_jacobson.nonempty_inter_closed_points _\n\nlemma is_jacobson.is_closed_of_is_locally_closed (hα : is_jacobson α) {x : α}\n  (hx : is_locally_closed ({x} : set α)) : is_closed ({x} : set α) :=\nbegin\n  obtain ⟨_, ⟨y, rfl : y = x, rfl⟩, hy'⟩ := hα.nonempty_inter_closed_points _\n    (set.singleton_nonempty x) hx,\n  exact hy' \nend\n\nlemma preimage_closed_points_subset (hf : embedding f) :\n  f ⁻¹' closed_points β ⊆ closed_points α :=\nbegin\n  intros x hx,\n  rw mem_closed_points,\n  convert continuous_iff_is_closed.mp hf.continuous _ hx,\n  rw [← set.image_singleton, set.preimage_image_eq _ hf.inj]\nend\n\nlemma closed_embedding.preimage_closed_points (hf : closed_embedding f) :\n  f ⁻¹' closed_points β = closed_points α :=\nbegin\n  ext x, simp [mem_closed_points, ← set.image_singleton, hf.closed_iff_image_closed],\nend\n\nlemma open_embedding.preimage_closed_points (hf : open_embedding f) (hβ : is_jacobson β) :\n  f ⁻¹' closed_points β = closed_points α :=\nbegin\n  apply subset_antisymm (preimage_closed_points_subset hf.to_embedding),\n  intros x hx,\n  apply hβ.is_closed_of_is_locally_closed,\n  rw ← set.image_singleton,\n  exact (hx.is_locally_closed.image hf.to_inducing hf.open_range.is_locally_closed)\nend\n\nlemma is_jacobson.of_open_embedding (hα : is_jacobson β)\n  (hf : open_embedding f) : is_jacobson α :=\nbegin\n  rw is_jacobson_iff_locally_closed,\n  rw ← hf.preimage_closed_points hα,\n  rw is_jacobson_iff_locally_closed at hα,\n  intros Z hZ hZ',\n  obtain ⟨_, ⟨x, hx, rfl⟩, hx'⟩ := hα _ (hZ.image f) (hZ'.image hf.to_inducing \n    hf.open_range.is_locally_closed),\n  exact ⟨_, hx, hx'⟩\nend\n\nlemma is_jacobson.of_closed_embedding (hα : is_jacobson β)\n  (hf : closed_embedding f) : is_jacobson α :=\nbegin\n  rw is_jacobson_iff_locally_closed at hα ⊢,\n  rw ← hf.preimage_closed_points,\n  intros Z hZ hZ',\n  obtain ⟨_, ⟨x, hx, rfl⟩, hx'⟩ := hα _ (hZ.image f) (hZ'.image hf.to_inducing \n    hf.closed_range.is_locally_closed),\n  exact ⟨_, hx, hx'⟩\nend\n\nlemma is_jacobson.discrete_of_finite [finite α] (hα : is_jacobson α) : discrete_topology α :=\nbegin\n  suffices : closed_points α = set.univ,\n  { rw ← forall_open_iff_discrete,\n    intro s,\n    rw [← is_closed_compl_iff, ← set.bUnion_of_singleton sᶜ],\n    refine is_closed_bUnion (set.to_finite _) (λ x hx, _),\n    rw [← mem_closed_points, this],\n    trivial },\n  rw [← set.univ_subset_iff, ← hα _ is_closed_univ, set.univ_inter, closure_subset_iff_is_closed,\n    ← set.bUnion_of_singleton (closed_points α)],\n  exact is_closed_bUnion (set.to_finite _) (λ _, id),\nend\n\nlemma {u} is_jacobson_iff_of_supr_eq_top {α : Type u} [topological_space α]\n  {ι : Type u} {U : ι → opens α} (hU : supr U = ⊤) :\n  is_jacobson α ↔ ∀ i, is_jacobson (U i) :=\nbegin\n  refine ⟨λ h i, h.of_open_embedding (U i).2.open_embedding_subtype_coe, λ H, _⟩,\n  rw is_jacobson_iff_locally_closed,\n  intros Z hZ hZ',\n  have : (⋃ i, (U i : set α)) = set.univ, { rw ← opens.coe_supr, injection hU },\n  have : (⋃ i, Z ∩ U i) = Z, { rw [← set.inter_Union, this, set.inter_univ] },\n  rw [← this, set.nonempty_Union] at hZ,\n  obtain ⟨i, x, hx, hx'⟩ := hZ,\n  obtain ⟨y, hy, hy'⟩ := (is_jacobson_iff_locally_closed.mp $ H i) (coe ⁻¹' Z) ⟨⟨x, hx'⟩, hx⟩\n    (hZ'.preimage continuous_subtype_coe),\n  refine ⟨y, hy, (is_closed_iff_coe_preimage_of_supr_eq_top hU _).mpr $ λ j, _⟩,\n  by_cases (y : α) ∈ U j,\n  { convert_to is_closed {(⟨y, h⟩ : U j)}, { ext z, exact @subtype.coe_inj _ _ z ⟨y, h⟩ },\n    apply (H j).is_closed_of_is_locally_closed,\n    convert (hy'.is_locally_closed.image embedding_subtype_coe.to_inducing\n      (U i).2.open_embedding_subtype_coe.open_range.is_locally_closed).preimage\n      continuous_subtype_coe,\n    rw set.image_singleton, ext z, exact (@subtype.coe_inj _ _ z ⟨y, h⟩).symm },\n  { convert is_closed_empty, rw set.eq_empty_iff_forall_not_mem, rintros z (hz : ↑z = ↑y),\n    rw ← hz at h, exact h z.2 }\nend\n\nend topological_space", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/for_mathlib/jacobson_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430520409024, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.483146024918924}}
{"text": "import data.finset\n\n/-! This file implements terms of a pure type system -/\n\n@[derive decidable_eq]\ninductive PTSSort : Type | star | box\nopen PTSSort\n\ninstance ptssort_has_repr : has_repr PTSSort :=\n  { repr := λ s, match s with star := \"*\" | box := \"□\" end }\n\ninductive Exp : Type\n| free : string → Exp\n| bound : nat → Exp\n| sort : PTSSort → Exp\n| app : Exp → Exp → Exp\n| lam : string → Exp → Exp → Exp\n| pi : string → Exp → Exp → Exp\n\n/-- A pretty printing of formulae. It doesn't try to interpolate\n  de-bruijn variables, which means that (Π x, 0) is the identity\n  function and (Π x, x) is the constant function for the free variable x. -/\ndef exp_repr : Exp → string\n| (Exp.free x) := x\n| (Exp.bound n) := repr n\n| (Exp.sort s) := repr s\n| (Exp.app a b) := exp_repr a ++ \" (\" ++ exp_repr b ++ \")\"\n| (Exp.lam x a b) := \"λ(\" ++ x ++ \" : \" ++ exp_repr a ++ \") → \" ++ exp_repr b\n| (Exp.pi x a b) := \"Π(\" ++ x ++ \" : \" ++ exp_repr a ++ \") → \" ++ exp_repr b\n\ninstance exp_has_repr : has_repr Exp :=\n  { repr := exp_repr }\n\n -- apply_instance fails below, so we restate the lemma here.\ndef decidable_and {p q : Prop} [decidable p] [decidable q] : decidable (p ∧ q) :=\n  infer_instance\n\ninstance exp_decidable_eq : decidable_eq Exp :=\nλ a b, begin\n  induction a generalizing b,\n    cases b, repeat { simp, from decidable.false },\n      simp, from string.has_decidable_eq a b, \n    cases b, repeat { simp, from decidable.false },\n      simp, from nat.decidable_eq a b,\n    cases b, repeat { simp, from decidable.false },\n      simp, let d : decidable_eq PTSSort := infer_instance,\n      from d a b,\n    cases b, repeat { simp, from decidable.false },\n      simp, letI h1 := a_ih_a b_a, letI h2 := a_ih_a_1 b_a_1,\n      from @decidable_and _ _ h1 h2,\n    repeat { cases b, repeat { simp, from decidable.false },\n      simp, letI h1 := a_ih_a b_a_1, letI h2 := a_ih_a_1 b_a_2,\n      letI h3 := string.has_decidable_eq a_a b_a,\n      apply_instance, }\nend\n\n@[simp] def abstract_help (x : string) : Exp → nat → Exp\n| e@(Exp.free y) n := if x = y then Exp.bound n else e\n| e@(Exp.bound _) n := e\n| e@(Exp.sort _) n := e\n| (Exp.app f e) n := Exp.app (abstract_help f n) (abstract_help e n)\n| (Exp.lam y t e) n := Exp.lam y (abstract_help t n) (abstract_help e (n+1))\n| (Exp.pi y t e) n := Exp.pi y (abstract_help t n) (abstract_help e (n+1))\n\n/-- Turn the free variable x into a fresh de-bruijn index.\n    Given an expression e, we can turn it into a function with:\n    Exp.lam x _ (abstract x e) -/\ndef abstract (x : string) (e : Exp) : Exp :=\n  abstract_help x e 0\n\n@[simp] def instantiate_help (x : Exp) : Exp → nat → Exp\n| e@(Exp.free _) n := e\n| e@(Exp.bound b) n := if b = n then x else e\n| e@(Exp.sort _) n := e\n| (Exp.app f e) n := Exp.app (instantiate_help f n) (instantiate_help e n)\n| (Exp.lam y t e) n := Exp.lam y (instantiate_help t n) (instantiate_help e (n + 1))\n| (Exp.pi y t e) n := Exp.pi y (instantiate_help t n) (instantiate_help e (n + 1))\n\n/-- Instantiate the top-most de-bruijn index with x.\n    Given a expression (Exp.lam x _ e), we can use A for x\n    by instantiate A e. -/\ndef instantiate (x : Exp) (e : Exp) : Exp :=\n  instantiate_help x e 0\n\n/-- Substitute the free variable x by r in e. -/\ndef substitute (x : string) (r : Exp) (e : Exp) : Exp :=\n  instantiate r (abstract x e)\n\n/-- The free variables in an expression -/\n@[simp] def free_vars : Π (e : Exp), finset string\n| (Exp.free x) := finset.singleton x\n| (Exp.app a b) := free_vars a ∪ free_vars b\n| (Exp.lam _ a b) := free_vars a ∪ free_vars b\n| (Exp.pi _ a b) := free_vars a ∪ free_vars b\n| (Exp.bound _) := ∅\n| (Exp.sort _) := ∅\n\n/-- The bound variables -/\n@[simp] def bound_vars : Π (e : Exp), finset string\n| (Exp.app a b) := free_vars a ∪ free_vars b\n| (Exp.lam x a b) := insert x (free_vars a ∪ free_vars b)\n| (Exp.pi x a b) := insert x (free_vars a ∪ free_vars b)\n| _ := ∅ \n", "meta": {"author": "anfelor", "repo": "coc-lean", "sha": "fdd967d2b7bc349202a1deabbbce155eed4db73a", "save_path": "github-repos/lean/anfelor-coc-lean", "path": "github-repos/lean/anfelor-coc-lean/coc-lean-fdd967d2b7bc349202a1deabbbce155eed4db73a/src/Terms.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.4831337984137405}}
{"text": "/-\nCopyright (c) 2021 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport analysis.normed_space.basic\nimport analysis.specific_limits\nimport topology.sequences\n\n/-!\n# Normed groups homomorphisms\n\nThis file gathers definitions and elementary constructions about bounded group homomorphisms\nbetween normed (abelian) groups (abbreviated to \"normed group homs\").\n\nThe main lemmas relate the boundedness condition to continuity and Lipschitzness.\n\nThe main construction is to endow the type of normed group homs between two given normed groups\nwith a group structure and a norm, giving rise to a normed group structure. We provide several\nsimple constructions for normed group homs, like kernel, range and equalizer.\n\nSome easy other constructions are related to subgroups of normed groups.\n\nSince a lot of elementary properties don't require `∥x∥ = 0 → x = 0` we start setting up the\ntheory of `semi_normed_group_hom` and we specialize to `normed_group_hom` when needed.\n-/\n\nnoncomputable theory\nopen_locale nnreal big_operators\n\n/-- A morphism of seminormed abelian groups is a bounded group homomorphism. -/\nstructure normed_group_hom (V W : Type*) [semi_normed_group V] [semi_normed_group W] :=\n(to_fun : V → W)\n(map_add' : ∀ v₁ v₂, to_fun (v₁ + v₂) = to_fun v₁ + to_fun v₂)\n(bound' : ∃ C, ∀ v, ∥to_fun v∥ ≤ C * ∥v∥)\n\nnamespace add_monoid_hom\n\nvariables {V W : Type*} [semi_normed_group V] [semi_normed_group W] {f g : normed_group_hom V W}\n\n/-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition.\n\nSee `add_monoid_hom.mk_normed_group_hom'` for a version that uses `ℝ≥0` for the bound. -/\ndef mk_normed_group_hom (f : V →+ W)\n  (C : ℝ) (h : ∀ v, ∥f v∥ ≤ C * ∥v∥) : normed_group_hom V W :=\n{ bound' := ⟨C, h⟩, ..f }\n\n/-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition.\n\nSee `add_monoid_hom.mk_normed_group_hom` for a version that uses `ℝ` for the bound. -/\ndef mk_normed_group_hom' (f : V →+ W) (C : ℝ≥0) (hC : ∀ x, nnnorm (f x) ≤ C * nnnorm x) :\n  normed_group_hom V W :=\n{ bound' := ⟨C, hC⟩ .. f}\n\nend add_monoid_hom\n\nlemma exists_pos_bound_of_bound {V W : Type*} [semi_normed_group V] [semi_normed_group W]\n  {f : V → W} (M : ℝ) (h : ∀x, ∥f x∥ ≤ M * ∥x∥) :\n  ∃ N, 0 < N ∧ ∀x, ∥f x∥ ≤ N * ∥x∥ :=\n⟨max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), λx, calc\n  ∥f x∥ ≤ M * ∥x∥ : h x\n  ... ≤ max M 1 * ∥x∥ : mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg _) ⟩\n\nnamespace normed_group_hom\n\nvariables {V V₁ V₂ V₃ : Type*}\nvariables [semi_normed_group V] [semi_normed_group V₁] [semi_normed_group V₂] [semi_normed_group V₃]\nvariables {f g : normed_group_hom V₁ V₂}\n\ninstance : has_coe_to_fun (normed_group_hom V₁ V₂) (λ _, V₁ → V₂) := ⟨normed_group_hom.to_fun⟩\n\ninitialize_simps_projections normed_group_hom (to_fun → apply)\n\nlemma coe_inj (H : (f : V₁ → V₂) = g) : f = g :=\nby cases f; cases g; congr'; exact funext H\n\nlemma coe_injective : @function.injective (normed_group_hom V₁ V₂) (V₁ → V₂) coe_fn :=\nby apply coe_inj\n\nlemma coe_inj_iff : f = g ↔ (f : V₁ → V₂) = g := ⟨congr_arg _, coe_inj⟩\n\n@[ext] lemma ext (H : ∀ x, f x = g x) : f = g := coe_inj $ funext H\n\nlemma ext_iff : f = g ↔ ∀ x, f x = g x := ⟨by rintro rfl x; refl, ext⟩\n\nvariables (f g)\n\n@[simp] lemma to_fun_eq_coe : f.to_fun = f := rfl\n\n@[simp] lemma coe_mk (f) (h₁) (h₂) (h₃) : ⇑(⟨f, h₁, h₂, h₃⟩ : normed_group_hom V₁ V₂) = f := rfl\n\n@[simp] lemma coe_mk_normed_group_hom (f : V₁ →+ V₂) (C) (hC) :\n  ⇑(f.mk_normed_group_hom C hC) = f := rfl\n\n@[simp] lemma coe_mk_normed_group_hom' (f : V₁ →+ V₂) (C) (hC) :\n  ⇑(f.mk_normed_group_hom' C hC) = f := rfl\n\n/-- The group homomorphism underlying a bounded group homomorphism. -/\ndef to_add_monoid_hom (f : normed_group_hom V₁ V₂) : V₁ →+ V₂ :=\nadd_monoid_hom.mk' f f.map_add'\n\n@[simp] lemma coe_to_add_monoid_hom : ⇑f.to_add_monoid_hom = f := rfl\n\nlemma to_add_monoid_hom_injective :\n  function.injective (@normed_group_hom.to_add_monoid_hom V₁ V₂ _ _) :=\nλ f g h, coe_inj $ show ⇑f.to_add_monoid_hom = g, by { rw h, refl }\n\n@[simp] \n\n@[simp] lemma map_zero : f 0 = 0 := f.to_add_monoid_hom.map_zero\n\n@[simp] lemma map_add (x y) : f (x + y) = f x + f y := f.to_add_monoid_hom.map_add _ _\n\n@[simp] lemma map_sum {ι : Type*} (v : ι → V₁) (s : finset ι) :\n  f (∑ i in s, v i) = ∑ i in s, f (v i) :=\nf.to_add_monoid_hom.map_sum _ _\n\n@[simp] lemma map_sub (x y) : f (x - y) = f x - f y := f.to_add_monoid_hom.map_sub _ _\n\n@[simp] lemma map_neg (x) : f (-x) = -(f x) := f.to_add_monoid_hom.map_neg _\n\nlemma bound : ∃ C, 0 < C ∧ ∀ x, ∥f x∥ ≤ C * ∥x∥ :=\nlet ⟨C, hC⟩ := f.bound' in exists_pos_bound_of_bound _ hC\n\ntheorem antilipschitz_of_norm_ge {K : ℝ≥0} (h : ∀ x, ∥x∥ ≤ K * ∥f x∥) :\n  antilipschitz_with K f :=\nantilipschitz_with.of_le_mul_dist $\nλ x y, by simpa only [dist_eq_norm, f.map_sub] using h (x - y)\n\n/-- A normed group hom is surjective on the subgroup `K` with constant `C` if every element\n`x` of `K` has a preimage whose norm is bounded above by `C*∥x∥`. This is a more\nabstract version of `f` having a right inverse defined on `K` with operator norm\nat most `C`. -/\ndef surjective_on_with (f : normed_group_hom V₁ V₂) (K : add_subgroup V₂) (C : ℝ) : Prop :=\n  ∀ h ∈ K, ∃ g, f g = h ∧ ∥g∥ ≤ C*∥h∥\n\nlemma surjective_on_with.mono {f : normed_group_hom V₁ V₂} {K : add_subgroup V₂} {C C' : ℝ}\n  (h : f.surjective_on_with K C) (H : C ≤ C') : f.surjective_on_with K C' :=\nbegin\n  intros k k_in,\n  rcases h k k_in with ⟨g, rfl, hg⟩,\n  use [g, rfl],\n  by_cases Hg : ∥f g∥ = 0,\n  { simpa [Hg] using hg },\n  { exact hg.trans ((mul_le_mul_right $ (ne.symm Hg).le_iff_lt.mp (norm_nonneg _)).mpr H) }\nend\n\nlemma surjective_on_with.exists_pos {f : normed_group_hom V₁ V₂} {K : add_subgroup V₂} {C : ℝ}\n  (h : f.surjective_on_with K C) : ∃ C' > 0, f.surjective_on_with K C' :=\nbegin\n  refine ⟨|C| + 1, _, _⟩,\n  { linarith [abs_nonneg C] },\n  { apply h.mono,\n    linarith [le_abs_self C] }\nend\n\nlemma surjective_on_with.surj_on {f : normed_group_hom V₁ V₂} {K : add_subgroup V₂} {C : ℝ}\n  (h : f.surjective_on_with K C) : set.surj_on f set.univ K :=\nλ x hx, (h x hx).imp $ λ a ⟨ha, _⟩, ⟨set.mem_univ _, ha⟩\n\n/-! ### The operator norm -/\n\n/-- The operator norm of a seminormed group homomorphism is the inf of all its bounds. -/\ndef op_norm (f : normed_group_hom V₁ V₂) := Inf {c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥}\ninstance has_op_norm : has_norm (normed_group_hom V₁ V₂) := ⟨op_norm⟩\n\nlemma norm_def : ∥f∥ = Inf {c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥} := rfl\n\n-- So that invocations of `le_cInf` make sense: we show that the set of\n-- bounds is nonempty and bounded below.\nlemma bounds_nonempty {f : normed_group_hom V₁ V₂} :\n  ∃ c, c ∈ { c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥ } :=\nlet ⟨M, hMp, hMb⟩ := f.bound in ⟨M, le_of_lt hMp, hMb⟩\n\nlemma bounds_bdd_below {f : normed_group_hom V₁ V₂} :\n  bdd_below {c | 0 ≤ c ∧ ∀ x, ∥f x∥ ≤ c * ∥x∥} :=\n⟨0, λ _ ⟨hn, _⟩, hn⟩\n\nlemma op_norm_nonneg : 0 ≤ ∥f∥ :=\nle_cInf bounds_nonempty (λ _ ⟨hx, _⟩, hx)\n\n/-- The fundamental property of the operator norm: `∥f x∥ ≤ ∥f∥ * ∥x∥`. -/\ntheorem le_op_norm (x : V₁) : ∥f x∥ ≤ ∥f∥ * ∥x∥ :=\nbegin\n  obtain ⟨C, Cpos, hC⟩ := f.bound,\n  replace hC := hC x,\n  by_cases h : ∥x∥ = 0,\n  { rwa [h, mul_zero] at ⊢ hC },\n  have hlt : 0 < ∥x∥ := lt_of_le_of_ne (norm_nonneg x) (ne.symm h),\n  exact (div_le_iff hlt).mp (le_cInf bounds_nonempty (λ c ⟨_, hc⟩,\n    (div_le_iff hlt).mpr $ by { apply hc })),\nend\n\ntheorem le_op_norm_of_le {c : ℝ} {x} (h : ∥x∥ ≤ c) : ∥f x∥ ≤ ∥f∥ * c :=\nle_trans (f.le_op_norm x) (mul_le_mul_of_nonneg_left h f.op_norm_nonneg)\n\ntheorem le_of_op_norm_le {c : ℝ} (h : ∥f∥ ≤ c) (x : V₁) : ∥f x∥ ≤ c * ∥x∥ :=\n(f.le_op_norm x).trans (mul_le_mul_of_nonneg_right h (norm_nonneg x))\n\n/-- continuous linear maps are Lipschitz continuous. -/\ntheorem lipschitz : lipschitz_with ⟨∥f∥, op_norm_nonneg f⟩ f :=\nlipschitz_with.of_dist_le_mul $ λ x y,\n  by { rw [dist_eq_norm, dist_eq_norm, ←map_sub], apply le_op_norm }\n\nprotected lemma uniform_continuous (f : normed_group_hom V₁ V₂) :\n  uniform_continuous f := f.lipschitz.uniform_continuous\n\n@[continuity]\nprotected lemma continuous (f : normed_group_hom V₁ V₂) : continuous f :=\nf.uniform_continuous.continuous\n\nlemma ratio_le_op_norm (x : V₁) : ∥f x∥ / ∥x∥ ≤ ∥f∥ :=\ndiv_le_of_nonneg_of_le_mul (norm_nonneg _) f.op_norm_nonneg (le_op_norm _ _)\n\n/-- If one controls the norm of every `f x`, then one controls the norm of `f`. -/\nlemma op_norm_le_bound {M : ℝ} (hMp: 0 ≤ M) (hM : ∀ x, ∥f x∥ ≤ M * ∥x∥) :\n  ∥f∥ ≤ M :=\ncInf_le bounds_bdd_below ⟨hMp, hM⟩\n\nlemma op_norm_eq_of_bounds {M : ℝ} (M_nonneg : 0 ≤ M)\n  (h_above : ∀ x, ∥f x∥ ≤ M*∥x∥) (h_below : ∀ N ≥ 0, (∀ x, ∥f x∥ ≤ N*∥x∥) → M ≤ N) :\n  ∥f∥ = M :=\nle_antisymm (f.op_norm_le_bound M_nonneg h_above)\n  ((le_cInf_iff normed_group_hom.bounds_bdd_below ⟨M, M_nonneg, h_above⟩).mpr $\n   λ N ⟨N_nonneg, hN⟩, h_below N N_nonneg hN)\n\ntheorem op_norm_le_of_lipschitz {f : normed_group_hom V₁ V₂} {K : ℝ≥0} (hf : lipschitz_with K f) :\n  ∥f∥ ≤ K :=\nf.op_norm_le_bound K.2 $ λ x, by simpa only [dist_zero_right, f.map_zero] using hf.dist_le_mul x 0\n\n/-- If a bounded group homomorphism map is constructed from a group homomorphism via the constructor\n`mk_normed_group_hom`, then its norm is bounded by the bound given to the constructor if it is\nnonnegative. -/\nlemma mk_normed_group_hom_norm_le (f : V₁ →+ V₂) {C : ℝ} (hC : 0 ≤ C) (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  ∥f.mk_normed_group_hom C h∥ ≤ C :=\nop_norm_le_bound _ hC h\n\n/-- If a bounded group homomorphism map is constructed from a group homomorphism\nvia the constructor `mk_normed_group_hom`, then its norm is bounded by the bound\ngiven to the constructor or zero if this bound is negative. -/\nlemma mk_normed_group_hom_norm_le' (f : V₁ →+ V₂) {C : ℝ} (h : ∀x, ∥f x∥ ≤ C * ∥x∥) :\n  ∥f.mk_normed_group_hom C h∥ ≤ max C 0 :=\nop_norm_le_bound _ (le_max_right _ _) $ λ x, (h x).trans $\n  mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg x)\n\nalias mk_normed_group_hom_norm_le ← add_monoid_hom.mk_normed_group_hom_norm_le\nalias mk_normed_group_hom_norm_le' ← add_monoid_hom.mk_normed_group_hom_norm_le'\n\n/-! ### Addition of normed group homs -/\n\n/-- Addition of normed group homs. -/\ninstance : has_add (normed_group_hom V₁ V₂) :=\n⟨λ f g, (f.to_add_monoid_hom + g.to_add_monoid_hom).mk_normed_group_hom (∥f∥ + ∥g∥) $ λ v, calc\n  ∥f v + g v∥\n      ≤ ∥f v∥ + ∥g v∥ : norm_add_le _ _\n  ... ≤ ∥f∥ * ∥v∥ + ∥g∥ * ∥v∥ : add_le_add (le_op_norm f v) (le_op_norm g v)\n  ... = (∥f∥ + ∥g∥) * ∥v∥ : by rw add_mul⟩\n\n/-- The operator norm satisfies the triangle inequality. -/\ntheorem op_norm_add_le : ∥f + g∥ ≤ ∥f∥ + ∥g∥ :=\nmk_normed_group_hom_norm_le _ (add_nonneg (op_norm_nonneg _) (op_norm_nonneg _)) _\n\n/--\nTerms containing `@has_add.add (has_coe_to_fun.F ...) pi.has_add`\nseem to cause leanchecker to [crash due to an out-of-memory\ncondition](https://github.com/leanprover-community/lean/issues/543).\nAs a workaround, we add a type annotation: `(f + g : V₁ → V₂)`\n-/\nlibrary_note \"addition on function coercions\"\n\n-- see Note [addition on function coercions]\n@[simp] lemma coe_add (f g : normed_group_hom V₁ V₂) : ⇑(f + g) = (f + g : V₁ → V₂) := rfl\n@[simp] lemma add_apply (f g : normed_group_hom V₁ V₂) (v : V₁) :\n  (f + g : normed_group_hom V₁ V₂) v = f v + g v := rfl\n\n/-! ### The zero normed group hom -/\n\ninstance : has_zero (normed_group_hom V₁ V₂) :=\n⟨(0 : V₁ →+ V₂).mk_normed_group_hom 0 (by simp)⟩\n\ninstance : inhabited (normed_group_hom V₁ V₂) := ⟨0⟩\n\n/-- The norm of the `0` operator is `0`. -/\ntheorem op_norm_zero : ∥(0 : normed_group_hom V₁ V₂)∥ = 0 :=\nle_antisymm (cInf_le bounds_bdd_below\n    ⟨ge_of_eq rfl, λ _, le_of_eq (by { rw [zero_mul], exact norm_zero })⟩)\n    (op_norm_nonneg _)\n\n/-- For normed groups, an operator is zero iff its norm vanishes. -/\ntheorem op_norm_zero_iff {V₁ V₂ : Type*} [normed_group V₁] [normed_group V₂]\n  {f : normed_group_hom V₁ V₂} : ∥f∥ = 0 ↔ f = 0 :=\niff.intro\n  (λ hn, ext (λ x, norm_le_zero_iff.1\n    (calc _ ≤ ∥f∥ * ∥x∥ : le_op_norm _ _\n     ...     = _ : by rw [hn, zero_mul])))\n  (λ hf, by rw [hf, op_norm_zero] )\n\n-- see Note [addition on function coercions]\n@[simp] lemma coe_zero : ⇑(0 : normed_group_hom V₁ V₂) = (0 : V₁ → V₂) := rfl\n@[simp] lemma zero_apply (v : V₁) : (0 : normed_group_hom V₁ V₂) v = 0 := rfl\n\nvariables {f g}\n\n/-! ### The identity normed group hom -/\n\nvariable (V)\n\n/-- The identity as a continuous normed group hom. -/\n@[simps]\ndef id : normed_group_hom V V :=\n(add_monoid_hom.id V).mk_normed_group_hom 1 (by simp [le_refl])\n\n/-- The norm of the identity is at most `1`. It is in fact `1`, except when the norm of every\nelement vanishes, where it is `0`. (Since we are working with seminorms this can happen even if the\nspace is non-trivial.) It means that one can not do better than an inequality in general. -/\nlemma norm_id_le : ∥(id V : normed_group_hom V V)∥ ≤ 1 :=\nop_norm_le_bound _ zero_le_one (λx, by simp)\n\n/-- If there is an element with norm different from `0`, then the norm of the identity equals `1`.\n(Since we are working with seminorms supposing that the space is non-trivial is not enough.) -/\nlemma norm_id_of_nontrivial_seminorm (h : ∃ (x : V), ∥x∥ ≠ 0 ) :\n  ∥(id V)∥ = 1 :=\nle_antisymm (norm_id_le V) $ let ⟨x, hx⟩ := h in\nhave _ := (id V).ratio_le_op_norm x,\nby rwa [id_apply, div_self hx] at this\n\n/-- If a normed space is non-trivial, then the norm of the identity equals `1`. -/\nlemma norm_id {V : Type*} [normed_group V] [nontrivial V] : ∥(id V)∥ = 1 :=\nbegin\n  refine norm_id_of_nontrivial_seminorm V _,\n  obtain ⟨x, hx⟩ := exists_ne (0 : V),\n  exact ⟨x, ne_of_gt (norm_pos_iff.2 hx)⟩,\nend\n\nlemma coe_id : ((normed_group_hom.id V) : V → V) = (_root_.id : V → V) := rfl\n\n/-! ### The negation of a normed group hom -/\n\n/-- Opposite of a normed group hom. -/\ninstance : has_neg (normed_group_hom V₁ V₂) :=\n⟨λ f, (-f.to_add_monoid_hom).mk_normed_group_hom (∥f∥) (λ v, by simp [le_op_norm f v])⟩\n\n-- see Note [addition on function coercions]\n@[simp] lemma coe_neg (f : normed_group_hom V₁ V₂) : ⇑(-f) = (-f : V₁ → V₂) := rfl\n@[simp] lemma neg_apply (f : normed_group_hom V₁ V₂) (v : V₁) :\n  (-f : normed_group_hom V₁ V₂) v = - (f v) := rfl\n\nlemma op_norm_neg (f : normed_group_hom V₁ V₂) : ∥-f∥ = ∥f∥ :=\nby simp only [norm_def, coe_neg, norm_neg, pi.neg_apply]\n\n/-! ### Subtraction of normed group homs -/\n\n/-- Subtraction of normed group homs. -/\ninstance : has_sub (normed_group_hom V₁ V₂) :=\n⟨λ f g,\n{ bound' :=\n  begin\n    simp only [add_monoid_hom.sub_apply, add_monoid_hom.to_fun_eq_coe, sub_eq_add_neg],\n    exact (f + -g).bound'\n  end,\n  .. (f.to_add_monoid_hom - g.to_add_monoid_hom) }⟩\n\n-- see Note [addition on function coercions]\n@[simp] lemma coe_sub (f g : normed_group_hom V₁ V₂) : ⇑(f - g) = (f - g : V₁ → V₂) := rfl\n@[simp] lemma sub_apply (f g : normed_group_hom V₁ V₂) (v : V₁) :\n  (f - g : normed_group_hom V₁ V₂) v = f v - g v := rfl\n\n/-! ### Normed group structure on normed group homs -/\n\n/-- Homs between two given normed groups form a commutative additive group. -/\ninstance : add_comm_group (normed_group_hom V₁ V₂) :=\ncoe_injective.add_comm_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl)\n\n/-- Normed group homomorphisms themselves form a seminormed group with respect to\n    the operator norm. -/\ninstance to_semi_normed_group : semi_normed_group (normed_group_hom V₁ V₂) :=\nsemi_normed_group.of_core _ ⟨op_norm_zero, op_norm_add_le, op_norm_neg⟩\n\n/-- Normed group homomorphisms themselves form a normed group with respect to\n    the operator norm. -/\ninstance to_normed_group {V₁ V₂ : Type*} [normed_group V₁] [normed_group V₂] :\n  normed_group (normed_group_hom V₁ V₂) :=\nnormed_group.of_core _ ⟨λ f, op_norm_zero_iff, op_norm_add_le, op_norm_neg⟩\n\n/-- Coercion of a `normed_group_hom` is an `add_monoid_hom`. Similar to `add_monoid_hom.coe_fn` -/\n@[simps]\ndef coe_fn_add_hom : normed_group_hom V₁ V₂ →+ (V₁ → V₂) :=\n{ to_fun := coe_fn, map_zero' := coe_zero, map_add' := coe_add}\n\n@[simp] lemma coe_sum {ι : Type*} (s : finset ι) (f : ι → normed_group_hom V₁ V₂) :\n  ⇑(∑ i in s, f i) = ∑ i in s, (f i) :=\n(coe_fn_add_hom : _ →+ (V₁ → V₂)).map_sum f s\n\nlemma sum_apply {ι : Type*} (s : finset ι) (f : ι → normed_group_hom V₁ V₂) (v : V₁) :\n  (∑ i in s, f i) v = ∑ i in s, (f i v) :=\nby simp only [coe_sum, finset.sum_apply]\n\n/-! ### Composition of normed group homs -/\n\n/-- The composition of continuous normed group homs. -/\n@[simps]\nprotected def comp (g : normed_group_hom V₂ V₃) (f : normed_group_hom V₁ V₂) :\n  normed_group_hom V₁ V₃ :=\n(g.to_add_monoid_hom.comp f.to_add_monoid_hom).mk_normed_group_hom (∥g∥ * ∥f∥) $ λ v, calc\n∥g (f v)∥ ≤ ∥g∥ * ∥f v∥ : le_op_norm _ _\n... ≤ ∥g∥ * (∥f∥ * ∥v∥) : mul_le_mul_of_nonneg_left (le_op_norm _ _) (op_norm_nonneg _)\n... = ∥g∥ * ∥f∥ * ∥v∥   : by rw mul_assoc\n\nlemma norm_comp_le (g : normed_group_hom V₂ V₃) (f : normed_group_hom V₁ V₂) :\n  ∥g.comp f∥ ≤ ∥g∥ * ∥f∥ :=\nmk_normed_group_hom_norm_le _ (mul_nonneg (op_norm_nonneg _) (op_norm_nonneg _)) _\n\nlemma norm_comp_le_of_le {g : normed_group_hom V₂ V₃} {C₁ C₂ : ℝ} (hg : ∥g∥ ≤ C₂) (hf : ∥f∥ ≤ C₁) :\n  ∥g.comp f∥ ≤ C₂ * C₁ :=\nle_trans (norm_comp_le g f) $ mul_le_mul hg hf (norm_nonneg _) (le_trans (norm_nonneg _) hg)\n\nlemma norm_comp_le_of_le' {g : normed_group_hom V₂ V₃} (C₁ C₂ C₃ : ℝ) (h : C₃ = C₂ * C₁)\n  (hg : ∥g∥ ≤ C₂) (hf : ∥f∥ ≤ C₁) : ∥g.comp f∥ ≤ C₃ :=\nby { rw h, exact norm_comp_le_of_le hg hf }\n\n/-- Composition of normed groups hom as an additive group morphism. -/\ndef comp_hom : (normed_group_hom V₂ V₃) →+ (normed_group_hom V₁ V₂) →+ (normed_group_hom V₁ V₃) :=\nadd_monoid_hom.mk' (λ g, add_monoid_hom.mk' (λ f, g.comp f)\n  (by { intros, ext, exact g.map_add _ _ }))\n  (by { intros, ext, simp only [comp_apply, pi.add_apply, function.comp_app,\n                                add_monoid_hom.add_apply, add_monoid_hom.mk'_apply, coe_add] })\n\n@[simp] lemma comp_zero (f : normed_group_hom V₂ V₃) : f.comp (0 : normed_group_hom V₁ V₂) = 0 :=\nby { ext, exact f.map_zero }\n\n@[simp] lemma zero_comp (f : normed_group_hom V₁ V₂) : (0 : normed_group_hom V₂ V₃).comp f = 0 :=\nby { ext, refl }\n\nlemma comp_assoc {V₄: Type* } [semi_normed_group V₄] (h : normed_group_hom V₃ V₄)\n  (g : normed_group_hom V₂ V₃) (f : normed_group_hom V₁ V₂) :\n  (h.comp g).comp f = h.comp (g.comp f) :=\nby { ext, refl }\n\nlemma coe_comp (f : normed_group_hom V₁ V₂) (g : normed_group_hom V₂ V₃) :\n  (g.comp f : V₁ → V₃) = (g : V₂ → V₃) ∘ (f : V₁ → V₂) := rfl\n\nend normed_group_hom\n\nnamespace normed_group_hom\n\nvariables {V W V₁ V₂ V₃ : Type*}\nvariables [semi_normed_group V] [semi_normed_group W] [semi_normed_group V₁] [semi_normed_group V₂]\n[semi_normed_group V₃]\n\n/-- The inclusion of an `add_subgroup`, as bounded group homomorphism. -/\n@[simps] def incl (s : add_subgroup V) : normed_group_hom s V :=\n{ to_fun := (coe : s → V),\n  map_add' := λ v w, add_subgroup.coe_add _ _ _,\n  bound' := ⟨1, λ v, by { rw [one_mul], refl }⟩ }\n\nlemma norm_incl {V' : add_subgroup V} (x : V') : ∥incl _ x∥ = ∥x∥ :=\nrfl\n\n/-!### Kernel -/\nsection kernels\nvariables (f : normed_group_hom V₁ V₂) (g : normed_group_hom V₂ V₃)\n\n/-- The kernel of a bounded group homomorphism. Naturally endowed with a\n`semi_normed_group` instance. -/\ndef ker : add_subgroup V₁ := f.to_add_monoid_hom.ker\n\nlemma mem_ker (v : V₁) : v ∈ f.ker ↔ f v = 0 :=\nby { erw f.to_add_monoid_hom.mem_ker, refl }\n\n/-- Given a normed group hom `f : V₁ → V₂` satisfying `g.comp f = 0` for some `g : V₂ → V₃`,\n    the corestriction of `f` to the kernel of `g`. -/\n@[simps] def ker.lift (h : g.comp f = 0) :\n  normed_group_hom V₁ g.ker :=\n{ to_fun := λ v, ⟨f v, by { erw g.mem_ker, show (g.comp f) v = 0, rw h, refl }⟩,\n  map_add' := λ v w, by { simp only [map_add], refl },\n  bound' := f.bound' }\n\n@[simp] lemma ker.incl_comp_lift (h : g.comp f = 0) :\n  (incl g.ker).comp (ker.lift f g h) = f :=\nby { ext, refl }\n\n@[simp]\nlemma ker_zero : (0 : normed_group_hom V₁ V₂).ker = ⊤ :=\nby { ext, simp [mem_ker] }\n\nlemma coe_ker : (f.ker : set V₁) = (f : V₁ → V₂) ⁻¹' {0} := rfl\n\nlemma is_closed_ker {V₂ : Type*} [normed_group V₂] (f : normed_group_hom V₁ V₂) :\n  is_closed (f.ker : set V₁) :=\nf.coe_ker ▸ is_closed.preimage f.continuous (t1_space.t1 0)\n\nend kernels\n\n/-! ### Range -/\nsection range\n\nvariables (f : normed_group_hom V₁ V₂) (g : normed_group_hom V₂ V₃)\n\n/-- The image of a bounded group homomorphism. Naturally endowed with a\n`semi_normed_group` instance. -/\ndef range : add_subgroup V₂ := f.to_add_monoid_hom.range\n\nlemma mem_range (v : V₂) : v ∈ f.range ↔ ∃ w, f w = v :=\nby { rw [range, add_monoid_hom.mem_range], refl }\n\n@[simp]\nlemma mem_range_self (v : V₁) : f v ∈ f.range :=\n⟨v, rfl⟩\n\nlemma comp_range : (g.comp f).range = add_subgroup.map g.to_add_monoid_hom f.range :=\nby { erw add_monoid_hom.map_range, refl }\n\nlemma incl_range (s : add_subgroup V₁) : (incl s).range = s :=\nby { ext x, exact ⟨λ ⟨y, hy⟩, by { rw ← hy; simp }, λ hx, ⟨⟨x, hx⟩, by simp⟩⟩ }\n\n@[simp]\nlemma range_comp_incl_top : (f.comp (incl (⊤ : add_subgroup V₁))).range = f.range :=\nby simpa [comp_range, incl_range, ← add_monoid_hom.range_eq_map]\n\nend range\n\nvariables {f : normed_group_hom V W}\n\n/-- A `normed_group_hom` is *norm-nonincreasing* if `∥f v∥ ≤ ∥v∥` for all `v`. -/\ndef norm_noninc (f : normed_group_hom V W) : Prop :=\n∀ v, ∥f v∥ ≤ ∥v∥\n\nnamespace norm_noninc\n\nlemma norm_noninc_iff_norm_le_one : f.norm_noninc ↔ ∥f∥ ≤ 1 :=\nbegin\n  refine ⟨λ h, _, λ h, λ v, _⟩,\n  { refine op_norm_le_bound _ (zero_le_one) (λ v, _),\n    simpa [one_mul] using h v },\n  { simpa using le_of_op_norm_le f h v }\nend\n\nlemma zero : (0 : normed_group_hom V₁ V₂).norm_noninc :=\nλ v, by simp\n\nlemma id : (id V).norm_noninc :=\nλ v, le_rfl\n\nlemma comp {g : normed_group_hom V₂ V₃} {f : normed_group_hom V₁ V₂}\n  (hg : g.norm_noninc) (hf : f.norm_noninc) :\n  (g.comp f).norm_noninc :=\nλ v, (hg (f v)).trans (hf v)\n\n@[simp] lemma neg_iff {f : normed_group_hom V₁ V₂} : (-f).norm_noninc ↔ f.norm_noninc :=\n⟨λ h x, by { simpa using h x }, λ h x, (norm_neg (f x)).le.trans (h x)⟩\n\nend norm_noninc\n\nsection isometry\n\nlemma isometry_iff_norm (f : normed_group_hom V W) :\n  isometry f ↔ ∀ v, ∥f v∥ = ∥v∥ :=\nadd_monoid_hom.isometry_iff_norm f.to_add_monoid_hom\n\nlemma isometry_of_norm (f : normed_group_hom V W) (hf : ∀ v, ∥f v∥ = ∥v∥) :\n  isometry f :=\nf.isometry_iff_norm.mpr hf\n\nlemma norm_eq_of_isometry {f : normed_group_hom V W} (hf : isometry f) (v : V) :\n  ∥f v∥ = ∥v∥ :=\nf.isometry_iff_norm.mp hf v\n\nlemma isometry_id : @isometry V V _ _ (id V) :=\nisometry_id\n\nlemma isometry_comp {g : normed_group_hom V₂ V₃} {f : normed_group_hom V₁ V₂}\n  (hg : isometry g) (hf : isometry f) :\n  isometry (g.comp f) :=\nhg.comp hf\n\nlemma norm_noninc_of_isometry (hf : isometry f) : f.norm_noninc :=\nλ v, le_of_eq $ norm_eq_of_isometry hf v\n\nend isometry\n\nvariables {W₁ W₂ W₃ : Type*} [semi_normed_group W₁] [semi_normed_group W₂] [semi_normed_group W₃]\nvariables (f) (g : normed_group_hom V W)\nvariables {f₁ g₁ : normed_group_hom V₁ W₁}\nvariables {f₂ g₂ : normed_group_hom V₂ W₂}\nvariables {f₃ g₃ : normed_group_hom V₃ W₃}\n\n/-- The equalizer of two morphisms `f g : normed_group_hom V W`. -/\ndef equalizer := (f - g).ker\n\nnamespace equalizer\n\n/-- The inclusion of `f.equalizer g` as a `normed_group_hom`. -/\ndef ι : normed_group_hom (f.equalizer g) V := incl _\n\nlemma comp_ι_eq : f.comp (ι f g) = g.comp (ι f g) :=\nby { ext, rw [comp_apply, comp_apply, ← sub_eq_zero, ← normed_group_hom.sub_apply], exact x.2 }\n\nvariables {f g}\n\n/-- If `φ : normed_group_hom V₁ V` is such that `f.comp φ = g.comp φ`, the induced morphism\n`normed_group_hom V₁ (f.equalizer g)`. -/\n@[simps]\ndef lift (φ : normed_group_hom V₁ V) (h : f.comp φ = g.comp φ) :\n  normed_group_hom V₁ (f.equalizer g) :=\n{ to_fun := λ v, ⟨φ v, show (f - g) (φ v) = 0,\n    by rw [normed_group_hom.sub_apply, sub_eq_zero, ← comp_apply, h, comp_apply]⟩,\n  map_add' := λ v₁ v₂, by { ext, simp only [map_add, add_subgroup.coe_add, subtype.coe_mk] },\n  bound' := by { obtain ⟨C, C_pos, hC⟩ := φ.bound, exact ⟨C, hC⟩ } }\n\n@[simp] lemma ι_comp_lift (φ : normed_group_hom V₁ V) (h : f.comp φ = g.comp φ) :\n  (ι _ _).comp (lift φ h) = φ :=\nby { ext, refl }\n\n/-- The lifting property of the equalizer as an equivalence. -/\n@[simps]\ndef lift_equiv : {φ : normed_group_hom V₁ V // f.comp φ = g.comp φ} ≃\n  normed_group_hom V₁ (f.equalizer g) :=\n{ to_fun := λ φ, lift φ φ.prop,\n  inv_fun := λ ψ, ⟨(ι f g).comp ψ, by { rw [← comp_assoc, ← comp_assoc, comp_ι_eq] }⟩,\n  left_inv := λ φ, by simp,\n  right_inv := λ ψ, by { ext, refl } }\n\n/-- Given `φ : normed_group_hom V₁ V₂` and `ψ : normed_group_hom W₁ W₂` such that\n`ψ.comp f₁ = f₂.comp φ` and `ψ.comp g₁ = g₂.comp φ`, the induced morphism\n`normed_group_hom (f₁.equalizer g₁) (f₂.equalizer g₂)`. -/\ndef map (φ : normed_group_hom V₁ V₂) (ψ : normed_group_hom W₁ W₂)\n  (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ) :\n  normed_group_hom (f₁.equalizer g₁) (f₂.equalizer g₂) :=\nlift (φ.comp $ ι _ _) $\nby { simp only [← comp_assoc, ← hf, ← hg], simp only [comp_assoc, comp_ι_eq] }\n\nvariables {φ : normed_group_hom V₁ V₂} {ψ : normed_group_hom W₁ W₂}\nvariables {φ' : normed_group_hom V₂ V₃} {ψ' : normed_group_hom W₂ W₃}\n\n@[simp] lemma ι_comp_map (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ) :\n  (ι f₂ g₂).comp (map φ ψ hf hg) = φ.comp (ι _ _) :=\nι_comp_lift _ _\n\n@[simp] lemma map_id : map (id V₁) (id W₁) rfl rfl = id (f₁.equalizer g₁) :=\nby { ext, refl }\n\nlemma comm_sq₂ (hf : ψ.comp f₁ = f₂.comp φ) (hf' : ψ'.comp f₂ = f₃.comp φ') :\n  (ψ'.comp ψ).comp f₁ = f₃.comp (φ'.comp φ) :=\nby rw [comp_assoc, hf, ← comp_assoc, hf', comp_assoc]\n\nlemma map_comp_map (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ)\n  (hf' : ψ'.comp f₂ = f₃.comp φ') (hg' : ψ'.comp g₂ = g₃.comp φ') :\n  (map φ' ψ' hf' hg').comp (map φ ψ hf hg) =\n    map (φ'.comp φ) (ψ'.comp ψ) (comm_sq₂ hf hf') (comm_sq₂ hg hg') :=\nby { ext, refl }\n\nlemma ι_norm_noninc : (ι f g).norm_noninc := λ v, le_rfl\n\n/-- The lifting of a norm nonincreasing morphism is norm nonincreasing. -/\nlemma lift_norm_noninc (φ : normed_group_hom V₁ V) (h : f.comp φ = g.comp φ) (hφ : φ.norm_noninc) :\n  (lift φ h).norm_noninc :=\nhφ\n\n/-- If `φ` satisfies `∥φ∥ ≤ C`, then the same is true for the lifted morphism. -/\nlemma norm_lift_le (φ : normed_group_hom V₁ V) (h : f.comp φ = g.comp φ)\n  (C : ℝ) (hφ : ∥φ∥ ≤ C) : ∥(lift φ h)∥ ≤ C := hφ\n\nlemma map_norm_noninc (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ)\n  (hφ : φ.norm_noninc) : (map φ ψ hf hg).norm_noninc :=\nlift_norm_noninc _ _ $ hφ.comp ι_norm_noninc\n\nlemma norm_map_le (hf : ψ.comp f₁ = f₂.comp φ) (hg : ψ.comp g₁ = g₂.comp φ)\n  (C : ℝ) (hφ : ∥φ.comp (ι f₁ g₁)∥ ≤ C) : ∥map φ ψ hf hg∥ ≤ C :=\nnorm_lift_le _ _ _ hφ\n\nend equalizer\n\nend normed_group_hom\n\nsection controlled_closure\nopen filter finset\nopen_locale topological_space\nvariables {G : Type*} [normed_group G] [complete_space G]\nvariables {H : Type*} [normed_group H]\n\n/-- Given `f : normed_group_hom G H` for some complete `G` and a subgroup `K` of `H`, if every\nelement `x` of `K` has a preimage under `f` whose norm is at most `C*∥x∥` then the same holds for\nelements of the (topological) closure of `K` with constant `C+ε` instead of `C`, for any\npositive `ε`.\n-/\nlemma controlled_closure_of_complete  {f : normed_group_hom G H} {K : add_subgroup H}\n  {C ε : ℝ} (hC : 0 < C) (hε : 0 < ε) (hyp : f.surjective_on_with K C) :\n  f.surjective_on_with K.topological_closure (C + ε) :=\nbegin\n  rintros (h : H) (h_in : h ∈ K.topological_closure),\n  /- We first get rid of the easy case where `h = 0`.-/\n  by_cases hyp_h : h = 0,\n  { rw hyp_h,\n    use 0,\n    simp },\n  /- The desired preimage will be constructed as the sum of a series. Convergence of\n  the series will be guaranteed by completeness of `G`. We first write `h` as the sum\n  of a sequence `v` of elements of `K` which starts close to `h` and then quickly goes to zero.\n  The sequence `b` below quantifies this. -/\n  set b : ℕ → ℝ := λ i, (1/2)^i*(ε*∥h∥/2)/C,\n  have b_pos : ∀ i, 0 < b i,\n  { intro i,\n    field_simp [b, hC],\n    exact div_pos (mul_pos hε (norm_pos_iff.mpr hyp_h))\n                  (mul_pos (by norm_num : (0 : ℝ) < 2^i*2) hC) },\n  obtain ⟨v : ℕ → H, lim_v : tendsto (λ (n : ℕ), ∑ k in range (n + 1), v k) at_top (𝓝 h),\n    v_in : ∀ n, v n ∈ K, hv₀ : ∥v 0 - h∥ < b 0, hv : ∀ n > 0, ∥v n∥ < b n⟩ :=\n    controlled_sum_of_mem_closure h_in b_pos,\n  /- The controlled surjectivity assumption on `f` allows to build preimages `u n` for all\n  elements `v n` of the `v` sequence.-/\n  have : ∀ n, ∃ m' : G, f m' = v n ∧ ∥m'∥ ≤ C * ∥v n∥ := λ (n : ℕ), hyp (v n) (v_in n),\n  choose u hu hnorm_u using this,\n  /- The desired series `s` is then obtained by summing `u`. We then check our choice of\n  `b` ensures `s` is Cauchy. -/\n  set s : ℕ → G := λ n, ∑ k in range (n+1), u k,\n  have : cauchy_seq s,\n  { apply normed_group.cauchy_series_of_le_geometric'' (by norm_num) one_half_lt_one,\n    rintro n (hn : n ≥ 1),\n    calc ∥u n∥ ≤ C*∥v n∥ : hnorm_u n\n    ... ≤ C * b n : mul_le_mul_of_nonneg_left (hv _ $ nat.succ_le_iff.mp hn).le hC.le\n    ... = (1/2)^n * (ε * ∥h∥/2) : by simp [b, mul_div_cancel' _ hC.ne.symm]\n    ... = (ε * ∥h∥/2) * (1/2)^n : mul_comm _ _ },\n  /- We now show that the limit `g` of `s` is the desired preimage. -/\n  obtain ⟨g : G, hg⟩ := cauchy_seq_tendsto_of_complete this,\n  refine ⟨g, _, _⟩,\n  { /- We indeed get a preimage. First note: -/\n    have : f ∘ s = λ n, ∑ k in range (n + 1), v k,\n    { ext n,\n      simp [f.map_sum, hu] },\n    /- In the above equality, the left-hand-side converges to `f g` by continuity of `f` and\n       definition of `g` while the right-hand-side converges to `h` by construction of `v` so\n       `g` is indeed a preimage of `h`. -/\n    rw ← this at lim_v,\n    exact tendsto_nhds_unique ((f.continuous.tendsto g).comp hg) lim_v },\n  { /- Then we need to estimate the norm of `g`, using our careful choice of `b`. -/\n    suffices : ∀ n, ∥s n∥ ≤ (C + ε) * ∥h∥,\n      from le_of_tendsto' (continuous_norm.continuous_at.tendsto.comp hg) this,\n    intros n,\n    have hnorm₀ : ∥u 0∥ ≤ C*b 0 + C*∥h∥,\n    { have := calc\n      ∥v 0∥ ≤ ∥h∥ + ∥v 0 - h∥ : norm_le_insert' _ _\n      ... ≤ ∥h∥ + b 0 : by apply add_le_add_left hv₀.le,\n      calc ∥u 0∥ ≤ C*∥v 0∥ : hnorm_u 0\n      ... ≤ C*(∥h∥ + b 0) : mul_le_mul_of_nonneg_left this hC.le\n      ... = C * b 0 + C * ∥h∥ : by rw [add_comm, mul_add] },\n    have : ∑ k in range (n + 1), C * b k ≤ ε * ∥h∥ := calc\n      ∑ k in range (n + 1), C * b k = (∑ k in range (n + 1), (1 / 2) ^ k) * (ε * ∥h∥ / 2) :\n                     by simp only [b, mul_div_cancel' _ hC.ne.symm, ← sum_mul]\n      ... ≤  2 * (ε * ∥h∥ / 2) : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                                            (by nlinarith [hε, norm_nonneg h])\n      ... = ε * ∥h∥ : mul_div_cancel' _ two_ne_zero,\n    calc ∥s n∥ ≤ ∑ k in range (n+1), ∥u k∥ : norm_sum_le _ _\n    ... = ∑ k in range n, ∥u (k + 1)∥ + ∥u 0∥ : sum_range_succ' _ _\n    ... ≤ ∑ k in range n, C*∥v (k + 1)∥ + ∥u 0∥ : add_le_add_right (sum_le_sum (λ _ _, hnorm_u _)) _\n    ... ≤ ∑ k in range n, C*b (k+1) + (C*b 0 + C*∥h∥) :\n      add_le_add (sum_le_sum (λ k _, mul_le_mul_of_nonneg_left (hv _ k.succ_pos).le hC.le)) hnorm₀\n    ... = ∑ k in range (n+1), C*b k + C*∥h∥ : by rw [← add_assoc, sum_range_succ']\n    ... ≤ (C+ε)*∥h∥ : by { rw [add_comm, add_mul], apply add_le_add_left this } }\nend\n\n/-- Given `f : normed_group_hom G H` for some complete `G`, if every element `x` of the image of\nan isometric immersion `j : normed_group_hom K H` has a preimage under `f` whose norm is at most\n`C*∥x∥` then the same holds for elements of the (topological) closure of this image with constant\n`C+ε` instead of `C`, for any positive `ε`.\nThis is useful in particular if `j` is the inclusion of a normed group into its completion\n(in this case the closure is the full target group).\n-/\nlemma controlled_closure_range_of_complete {f : normed_group_hom G H}\n  {K : Type*} [semi_normed_group K] {j : normed_group_hom K H} (hj : ∀ x, ∥j x∥ = ∥x∥)\n  {C ε : ℝ} (hC : 0 < C) (hε : 0 < ε) (hyp : ∀ k, ∃ g, f g = j k ∧ ∥g∥ ≤ C*∥k∥) :\n  f.surjective_on_with j.range.topological_closure (C + ε) :=\nbegin\n  replace hyp : ∀ h ∈ j.range, ∃ g, f g = h ∧ ∥g∥ ≤ C*∥h∥,\n  { intros h h_in,\n    rcases (j.mem_range _).mp h_in with ⟨k, rfl⟩,\n    rw hj,\n    exact hyp k },\n  exact controlled_closure_of_complete hC hε hyp\nend\nend controlled_closure\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/normed/group/hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.672331705744791, "lm_q1q2_score": 0.4831337936958057}}
{"text": "import tactic.alias\nimport tactic.basic\nimport tactic.linarith\n\n@[reducible]\ndef symbol := ℕ\n\n/-- Representation of formulas in modal logic. -/\n@[derive decidable_eq]\ninductive formula : Type\n| bottom : formula\n| top : formula\n| symbol (s : symbol) : formula\n| not (a : formula) : formula\n| and (a b : formula) : formula\n| or (a b : formula) : formula\n| implies (a b : formula) : formula\n| iff (a b : formula) : formula\n| box (a : formula) : formula\n| diamond (a : formula) : formula\n\nreserve infixr ` ⟶ ` :(std.prec.arrow+1)\nreserve prefix `□` :40\nreserve prefix `◇` :40\n\nnotation `⊥` := formula.bottom\nnotation `⊤` := formula.top\nnotation ¬ a := formula.not a\nnotation a ` ∧ ` b := (formula.and a b)\nnotation a ` ∨ ` b := formula.or a b\nnotation a ` ⟶ ` b := formula.implies a b\nnotation a ` ↔ ` b := formula.iff a b\nnotation □a := formula.box a\nnotation ◇a := formula.diamond a\n\n-- Used to construct formulas containing arbitrary symbols e.g. `0 ∨ 1` (`p ∨ q`).\ninstance formula.has_zero : has_zero formula := { zero := formula.symbol 0 }\ninstance formula.has_one : has_one formula := { one := formula.symbol 1 }\ninstance formula.has_add : has_add formula := {\n  add := λx y, match (x, y) with\n  | (formula.symbol x, formula.symbol y) := formula.symbol (x + y)\n  | (x, _) := x\n  end\n}\n\n/-- A formula is modal free iff it contains no modal operators. -/\n@[simp] def modal_free : formula → Prop\n| ⊤ := true\n| ⊥ := true\n| (formula.symbol _) := true\n| ¬a := modal_free a\n| (a ∧ b) := modal_free a ∧ modal_free b\n| (a ∨ b) := modal_free a ∧ modal_free b\n| (a ⟶ b) := modal_free a ∧ modal_free b\n| (a ↔ b) := modal_free a ∧ modal_free b\n| □_ := false\n| ◇_ := false\n\n/-- Substitutes sentence symbols for formulas in a formula according to a mapping function. -/\n@[simp] def subst (substs : symbol → formula) : formula → formula\n| ⊤ := ⊤\n| ⊥ := ⊥\n| (formula.symbol s) := substs s\n| ¬a := ¬subst a\n| (a ∧ b) := subst a ∧ subst b\n| (a ∨ b) := subst a ∨ subst b\n| (a ⟶ b) := subst a ⟶ subst b\n| (a ↔ b) := subst a ↔ subst b\n| □a := □subst a\n| ◇a := ◇subst a\n\n@[simp] lemma subst.ident (a : formula) : subst formula.symbol a = a :=\nbegin\n  induction a,\n  repeat { simp [a_ih, subst] },\n  repeat { simp },\n  repeat { tauto },\nend\n\n@[simp] def substitution_inst (a b : formula) : Prop :=\n∃substs, subst substs a = b", "meta": {"author": "max-heller", "repo": "cs1951x-final-project", "sha": "5c71e2c87289e208ed8513c10a0d480c79a07894", "save_path": "github-repos/lean/max-heller-cs1951x-final-project", "path": "github-repos/lean/max-heller-cs1951x-final-project/cs1951x-final-project-5c71e2c87289e208ed8513c10a0d480c79a07894/src/formula.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.48313379031009795}}
{"text": "/-\nCopyright (c) 2019 Minchao Wu. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Minchao Wu, Mario Carneiro\n\n! This file was ported from Lean 3 source module computability.reduce\n! leanprover-community/mathlib commit d13b3a4a392ea7273dfa4727dbd1892e26cfd518\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Computability.Halting\n\n/-!\n# Strong reducibility and degrees.\n\nThis file defines the notions of computable many-one reduction and one-one\nreduction between sets, and shows that the corresponding degrees form a\nsemilattice.\n\n## Notations\n\nThis file uses the local notation `⊕'` for `sum.elim` to denote the disjoint union of two degrees.\n\n## References\n\n* [Robert Soare, *Recursively enumerable sets and degrees*][soare1987]\n\n## Tags\n\ncomputability, reducibility, reduction\n-/\n\n\nuniverse u v w\n\nopen Function\n\n/--\n`p` is many-one reducible to `q` if there is a computable function translating questions about `p`\nto questions about `q`.\n-/\ndef ManyOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) :=\n  ∃ f, Computable f ∧ ∀ a, p a ↔ q (f a)\n#align many_one_reducible ManyOneReducible\n\n-- mathport name: «expr ≤₀ »\ninfixl:1000 \" ≤₀ \" => ManyOneReducible\n\ntheorem ManyOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop)\n    (h : Computable f) : (fun a => q (f a)) ≤₀ q :=\n  ⟨f, h, fun a => Iff.rfl⟩\n#align many_one_reducible.mk ManyOneReducible.mk\n\n@[refl]\ntheorem manyOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₀ p :=\n  ⟨id, Computable.id, by simp⟩\n#align many_one_reducible_refl manyOneReducible_refl\n\n@[trans]\ntheorem ManyOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₀ q → q ≤₀ r → p ≤₀ r\n  | ⟨f, c₁, h₁⟩, ⟨g, c₂, h₂⟩ =>\n    ⟨g ∘ f, c₂.comp c₁, fun a => ⟨fun h => by rwa [← h₂, ← h₁], fun h => by rwa [h₁, h₂]⟩⟩\n#align many_one_reducible.trans ManyOneReducible.trans\n\ntheorem reflexive_manyOneReducible {α} [Primcodable α] : Reflexive (@ManyOneReducible α α _ _) :=\n  manyOneReducible_refl\n#align reflexive_many_one_reducible reflexive_manyOneReducible\n\ntheorem transitive_manyOneReducible {α} [Primcodable α] : Transitive (@ManyOneReducible α α _ _) :=\n  fun p q r => ManyOneReducible.trans\n#align transitive_many_one_reducible transitive_manyOneReducible\n\n/--\n`p` is one-one reducible to `q` if there is an injective computable function translating questions\nabout `p` to questions about `q`.\n-/\ndef OneOneReducible {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) :=\n  ∃ f, Computable f ∧ Injective f ∧ ∀ a, p a ↔ q (f a)\n#align one_one_reducible OneOneReducible\n\n-- mathport name: «expr ≤₁ »\ninfixl:1000 \" ≤₁ \" => OneOneReducible\n\ntheorem OneOneReducible.mk {α β} [Primcodable α] [Primcodable β] {f : α → β} (q : β → Prop)\n    (h : Computable f) (i : Injective f) : (fun a => q (f a)) ≤₁ q :=\n  ⟨f, h, i, fun a => Iff.rfl⟩\n#align one_one_reducible.mk OneOneReducible.mk\n\n@[refl]\ntheorem oneOneReducible_refl {α} [Primcodable α] (p : α → Prop) : p ≤₁ p :=\n  ⟨id, Computable.id, injective_id, by simp⟩\n#align one_one_reducible_refl oneOneReducible_refl\n\n@[trans]\ntheorem OneOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop}\n    {q : β → Prop} {r : γ → Prop} : p ≤₁ q → q ≤₁ r → p ≤₁ r\n  | ⟨f, c₁, i₁, h₁⟩, ⟨g, c₂, i₂, h₂⟩ =>\n    ⟨g ∘ f, c₂.comp c₁, i₂.comp i₁, fun a =>\n      ⟨fun h => by rwa [← h₂, ← h₁], fun h => by rwa [h₁, h₂]⟩⟩\n#align one_one_reducible.trans OneOneReducible.trans\n\ntheorem OneOneReducible.to_many_one {α β} [Primcodable α] [Primcodable β] {p : α → Prop}\n    {q : β → Prop} : p ≤₁ q → p ≤₀ q\n  | ⟨f, c, i, h⟩ => ⟨f, c, h⟩\n#align one_one_reducible.to_many_one OneOneReducible.to_many_one\n\ntheorem OneOneReducible.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (q : β → Prop)\n    (h : Computable e) : (q ∘ e) ≤₁ q :=\n  OneOneReducible.mk _ h e.Injective\n#align one_one_reducible.of_equiv OneOneReducible.of_equiv\n\ntheorem OneOneReducible.of_equiv_symm {α β} [Primcodable α] [Primcodable β] {e : α ≃ β}\n    (q : β → Prop) (h : Computable e.symm) : q ≤₁ (q ∘ e) := by\n  convert OneOneReducible.of_equiv _ h <;> funext <;> simp\n#align one_one_reducible.of_equiv_symm OneOneReducible.of_equiv_symm\n\ntheorem reflexive_oneOneReducible {α} [Primcodable α] : Reflexive (@OneOneReducible α α _ _) :=\n  oneOneReducible_refl\n#align reflexive_one_one_reducible reflexive_oneOneReducible\n\ntheorem transitive_oneOneReducible {α} [Primcodable α] : Transitive (@OneOneReducible α α _ _) :=\n  fun p q r => OneOneReducible.trans\n#align transitive_one_one_reducible transitive_oneOneReducible\n\nnamespace ComputablePred\n\nvariable {α : Type _} {β : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable σ]\n\nopen Computable\n\ntheorem computable_of_manyOneReducible {p : α → Prop} {q : β → Prop} (h₁ : p ≤₀ q)\n    (h₂ : ComputablePred q) : ComputablePred p :=\n  by\n  rcases h₁ with ⟨f, c, hf⟩\n  rw [show p = fun a => q (f a) from Set.ext hf]\n  rcases computable_iff.1 h₂ with ⟨g, hg, rfl⟩\n  exact ⟨by infer_instance, by simpa using hg.comp c⟩\n#align computable_pred.computable_of_many_one_reducible ComputablePred.computable_of_manyOneReducible\n\ntheorem computable_of_oneOneReducible {p : α → Prop} {q : β → Prop} (h : p ≤₁ q) :\n    ComputablePred q → ComputablePred p :=\n  computable_of_manyOneReducible h.to_many_one\n#align computable_pred.computable_of_one_one_reducible ComputablePred.computable_of_oneOneReducible\n\nend ComputablePred\n\n/-- `p` and `q` are many-one equivalent if each one is many-one reducible to the other. -/\ndef ManyOneEquiv {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) :=\n  p ≤₀ q ∧ q ≤₀ p\n#align many_one_equiv ManyOneEquiv\n\n/-- `p` and `q` are one-one equivalent if each one is one-one reducible to the other. -/\ndef OneOneEquiv {α β} [Primcodable α] [Primcodable β] (p : α → Prop) (q : β → Prop) :=\n  p ≤₁ q ∧ q ≤₁ p\n#align one_one_equiv OneOneEquiv\n\n@[refl]\ntheorem manyOneEquiv_refl {α} [Primcodable α] (p : α → Prop) : ManyOneEquiv p p :=\n  ⟨manyOneReducible_refl _, manyOneReducible_refl _⟩\n#align many_one_equiv_refl manyOneEquiv_refl\n\n@[symm]\ntheorem ManyOneEquiv.symm {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} :\n    ManyOneEquiv p q → ManyOneEquiv q p :=\n  And.symm\n#align many_one_equiv.symm ManyOneEquiv.symm\n\n@[trans]\ntheorem ManyOneEquiv.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop}\n    {q : β → Prop} {r : γ → Prop} : ManyOneEquiv p q → ManyOneEquiv q r → ManyOneEquiv p r\n  | ⟨pq, qp⟩, ⟨qr, rq⟩ => ⟨pq.trans qr, rq.trans qp⟩\n#align many_one_equiv.trans ManyOneEquiv.trans\n\ntheorem equivalence_of_manyOneEquiv {α} [Primcodable α] : Equivalence (@ManyOneEquiv α α _ _) :=\n  ⟨manyOneEquiv_refl, fun x y => ManyOneEquiv.symm, fun x y z => ManyOneEquiv.trans⟩\n#align equivalence_of_many_one_equiv equivalence_of_manyOneEquiv\n\n@[refl]\ntheorem oneOneEquiv_refl {α} [Primcodable α] (p : α → Prop) : OneOneEquiv p p :=\n  ⟨oneOneReducible_refl _, oneOneReducible_refl _⟩\n#align one_one_equiv_refl oneOneEquiv_refl\n\n@[symm]\ntheorem OneOneEquiv.symm {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} :\n    OneOneEquiv p q → OneOneEquiv q p :=\n  And.symm\n#align one_one_equiv.symm OneOneEquiv.symm\n\n@[trans]\ntheorem OneOneEquiv.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop}\n    {q : β → Prop} {r : γ → Prop} : OneOneEquiv p q → OneOneEquiv q r → OneOneEquiv p r\n  | ⟨pq, qp⟩, ⟨qr, rq⟩ => ⟨pq.trans qr, rq.trans qp⟩\n#align one_one_equiv.trans OneOneEquiv.trans\n\ntheorem equivalence_of_oneOneEquiv {α} [Primcodable α] : Equivalence (@OneOneEquiv α α _ _) :=\n  ⟨oneOneEquiv_refl, fun x y => OneOneEquiv.symm, fun x y z => OneOneEquiv.trans⟩\n#align equivalence_of_one_one_equiv equivalence_of_oneOneEquiv\n\ntheorem OneOneEquiv.to_many_one {α β} [Primcodable α] [Primcodable β] {p : α → Prop}\n    {q : β → Prop} : OneOneEquiv p q → ManyOneEquiv p q\n  | ⟨pq, qp⟩ => ⟨pq.to_many_one, qp.to_many_one⟩\n#align one_one_equiv.to_many_one OneOneEquiv.to_many_one\n\n/-- a computable bijection -/\ndef Equiv.Computable {α β} [Primcodable α] [Primcodable β] (e : α ≃ β) :=\n  Computable e ∧ Computable e.symm\n#align equiv.computable Equiv.Computable\n\ntheorem Equiv.Computable.symm {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} :\n    e.Computable → e.symm.Computable :=\n  And.symm\n#align equiv.computable.symm Equiv.Computable.symm\n\ntheorem Equiv.Computable.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {e₁ : α ≃ β}\n    {e₂ : β ≃ γ} : e₁.Computable → e₂.Computable → (e₁.trans e₂).Computable\n  | ⟨l₁, r₁⟩, ⟨l₂, r₂⟩ => ⟨l₂.comp l₁, r₁.comp r₂⟩\n#align equiv.computable.trans Equiv.Computable.trans\n\ntheorem Computable.eqv (α) [Denumerable α] : (Denumerable.eqv α).Computable :=\n  ⟨Computable.encode, Computable.ofNat _⟩\n#align computable.eqv Computable.eqv\n\ntheorem Computable.equiv₂ (α β) [Denumerable α] [Denumerable β] :\n    (Denumerable.equiv₂ α β).Computable :=\n  (Computable.eqv _).trans (Computable.eqv _).symm\n#align computable.equiv₂ Computable.equiv₂\n\ntheorem OneOneEquiv.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (h : e.Computable)\n    {p} : OneOneEquiv (p ∘ e) p :=\n  ⟨OneOneReducible.of_equiv _ h.1, OneOneReducible.of_equiv_symm _ h.2⟩\n#align one_one_equiv.of_equiv OneOneEquiv.of_equiv\n\ntheorem ManyOneEquiv.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (h : e.Computable)\n    {p} : ManyOneEquiv (p ∘ e) p :=\n  (OneOneEquiv.of_equiv h).to_many_one\n#align many_one_equiv.of_equiv ManyOneEquiv.of_equiv\n\ntheorem ManyOneEquiv.le_congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv p q) : p ≤₀ r ↔ q ≤₀ r :=\n  ⟨h.2.trans, h.1.trans⟩\n#align many_one_equiv.le_congr_left ManyOneEquiv.le_congr_left\n\ntheorem ManyOneEquiv.le_congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv q r) : p ≤₀ q ↔ p ≤₀ r :=\n  ⟨fun h' => h'.trans h.1, fun h' => h'.trans h.2⟩\n#align many_one_equiv.le_congr_right ManyOneEquiv.le_congr_right\n\ntheorem OneOneEquiv.le_congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv p q) : p ≤₁ r ↔ q ≤₁ r :=\n  ⟨h.2.trans, h.1.trans⟩\n#align one_one_equiv.le_congr_left OneOneEquiv.le_congr_left\n\ntheorem OneOneEquiv.le_congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv q r) : p ≤₁ q ↔ p ≤₁ r :=\n  ⟨fun h' => h'.trans h.1, fun h' => h'.trans h.2⟩\n#align one_one_equiv.le_congr_right OneOneEquiv.le_congr_right\n\ntheorem ManyOneEquiv.congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv p q) :\n    ManyOneEquiv p r ↔ ManyOneEquiv q r :=\n  and_congr h.le_congr_left h.le_congr_right\n#align many_one_equiv.congr_left ManyOneEquiv.congr_left\n\ntheorem ManyOneEquiv.congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv q r) :\n    ManyOneEquiv p q ↔ ManyOneEquiv p r :=\n  and_congr h.le_congr_right h.le_congr_left\n#align many_one_equiv.congr_right ManyOneEquiv.congr_right\n\ntheorem OneOneEquiv.congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv p q) :\n    OneOneEquiv p r ↔ OneOneEquiv q r :=\n  and_congr h.le_congr_left h.le_congr_right\n#align one_one_equiv.congr_left OneOneEquiv.congr_left\n\ntheorem OneOneEquiv.congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv q r) :\n    OneOneEquiv p q ↔ OneOneEquiv p r :=\n  and_congr h.le_congr_right h.le_congr_left\n#align one_one_equiv.congr_right OneOneEquiv.congr_right\n\n@[simp]\ntheorem Ulower.down_computable {α} [Primcodable α] : (Ulower.equiv α).Computable :=\n  ⟨Primrec.ulower_down.to_comp, Primrec.ulower_up.to_comp⟩\n#align ulower.down_computable Ulower.down_computable\n\ntheorem manyOneEquiv_up {α} [Primcodable α] {p : α → Prop} : ManyOneEquiv (p ∘ Ulower.up) p :=\n  ManyOneEquiv.of_equiv Ulower.down_computable.symm\n#align many_one_equiv_up manyOneEquiv_up\n\n-- mathport name: «expr ⊕' »\nlocal infixl:1001 \" ⊕' \" => Sum.elim\n\nopen Nat.Primrec\n\ntheorem OneOneReducible.disjoin_left {α β} [Primcodable α] [Primcodable β] {p : α → Prop}\n    {q : β → Prop} : p ≤₁ p ⊕' q :=\n  ⟨Sum.inl, Computable.sum_inl, fun x y => Sum.inl.inj_iff.1, fun a => Iff.rfl⟩\n#align one_one_reducible.disjoin_left OneOneReducible.disjoin_left\n\ntheorem OneOneReducible.disjoin_right {α β} [Primcodable α] [Primcodable β] {p : α → Prop}\n    {q : β → Prop} : q ≤₁ p ⊕' q :=\n  ⟨Sum.inr, Computable.sum_inr, fun x y => Sum.inr.inj_iff.1, fun a => Iff.rfl⟩\n#align one_one_reducible.disjoin_right OneOneReducible.disjoin_right\n\ntheorem disjoin_manyOneReducible {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ]\n    {p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₀ r → q ≤₀ r → p ⊕' q ≤₀ r\n  | ⟨f, c₁, h₁⟩, ⟨g, c₂, h₂⟩ =>\n    ⟨Sum.elim f g,\n      Computable.id.sum_cases (c₁.comp Computable.snd).to₂ (c₂.comp Computable.snd).to₂, fun x => by\n      cases x <;> [apply h₁, apply h₂]⟩\n#align disjoin_many_one_reducible disjoin_manyOneReducible\n\ntheorem disjoin_le {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop}\n    {q : β → Prop} {r : γ → Prop} : p ⊕' q ≤₀ r ↔ p ≤₀ r ∧ q ≤₀ r :=\n  ⟨fun h =>\n    ⟨OneOneReducible.disjoin_left.to_many_one.trans h,\n      OneOneReducible.disjoin_right.to_many_one.trans h⟩,\n    fun ⟨h₁, h₂⟩ => disjoin_manyOneReducible h₁ h₂⟩\n#align disjoin_le disjoin_le\n\nvariable {α : Type u} [Primcodable α] [Inhabited α]\n\nvariable {β : Type v} [Primcodable β] [Inhabited β]\n\nvariable {γ : Type w} [Primcodable γ] [Inhabited γ]\n\n/-- Computable and injective mapping of predicates to sets of natural numbers.\n-/\ndef toNat (p : Set α) : Set ℕ :=\n  { n | p ((Encodable.decode α n).getD default) }\n#align to_nat toNat\n\n@[simp]\ntheorem toNat_manyOneReducible {p : Set α} : toNat p ≤₀ p :=\n  ⟨fun n => (Encodable.decode α n).getD default,\n    Computable.option_getD Computable.decode (Computable.const _), fun _ => Iff.rfl⟩\n#align to_nat_many_one_reducible toNat_manyOneReducible\n\n@[simp]\ntheorem manyOneReducible_toNat {p : Set α} : p ≤₀ toNat p :=\n  ⟨Encodable.encode, Computable.encode, by simp [toNat, setOf]⟩\n#align many_one_reducible_to_nat manyOneReducible_toNat\n\n@[simp]\ntheorem manyOneReducible_toNat_toNat {p : Set α} {q : Set β} : toNat p ≤₀ toNat q ↔ p ≤₀ q :=\n  ⟨fun h => manyOneReducible_toNat.trans (h.trans toNat_manyOneReducible), fun h =>\n    toNat_manyOneReducible.trans (h.trans manyOneReducible_toNat)⟩\n#align many_one_reducible_to_nat_to_nat manyOneReducible_toNat_toNat\n\n@[simp]\ntheorem toNat_manyOneEquiv {p : Set α} : ManyOneEquiv (toNat p) p := by simp [ManyOneEquiv]\n#align to_nat_many_one_equiv toNat_manyOneEquiv\n\n@[simp]\ntheorem manyOneEquiv_toNat (p : Set α) (q : Set β) :\n    ManyOneEquiv (toNat p) (toNat q) ↔ ManyOneEquiv p q := by simp [ManyOneEquiv]\n#align many_one_equiv_to_nat manyOneEquiv_toNat\n\n/-- A many-one degree is an equivalence class of sets up to many-one equivalence. -/\ndef ManyOneDegree : Type :=\n  Quotient (⟨ManyOneEquiv, equivalence_of_manyOneEquiv⟩ : Setoid (Set ℕ))\n#align many_one_degree ManyOneDegree\n\nnamespace ManyOneDegree\n\n/-- The many-one degree of a set on a primcodable type. -/\ndef of (p : α → Prop) : ManyOneDegree :=\n  Quotient.mk'' (toNat p)\n#align many_one_degree.of ManyOneDegree.of\n\n@[elab_as_elim]\nprotected theorem ind_on {C : ManyOneDegree → Prop} (d : ManyOneDegree)\n    (h : ∀ p : Set ℕ, C (of p)) : C d :=\n  Quotient.inductionOn' d h\n#align many_one_degree.ind_on ManyOneDegree.ind_on\n\n/-- Lifts a function on sets of natural numbers to many-one degrees.\n-/\n@[elab_as_elim, reducible]\nprotected def liftOn {φ} (d : ManyOneDegree) (f : Set ℕ → φ)\n    (h : ∀ p q, ManyOneEquiv p q → f p = f q) : φ :=\n  Quotient.liftOn' d f h\n#align many_one_degree.lift_on ManyOneDegree.liftOn\n\n@[simp]\nprotected theorem liftOn_eq {φ} (p : Set ℕ) (f : Set ℕ → φ)\n    (h : ∀ p q, ManyOneEquiv p q → f p = f q) : (of p).liftOn f h = f p :=\n  rfl\n#align many_one_degree.lift_on_eq ManyOneDegree.liftOn_eq\n\n/-- Lifts a binary function on sets of natural numbers to many-one degrees.\n-/\n@[elab_as_elim, reducible, simp]\nprotected def liftOn₂ {φ} (d₁ d₂ : ManyOneDegree) (f : Set ℕ → Set ℕ → φ)\n    (h : ∀ p₁ p₂ q₁ q₂, ManyOneEquiv p₁ p₂ → ManyOneEquiv q₁ q₂ → f p₁ q₁ = f p₂ q₂) : φ :=\n  d₁.liftOn (fun p => d₂.liftOn (f p) fun q₁ q₂ hq => h _ _ _ _ (by rfl) hq)\n    (by\n      intro p₁ p₂ hp\n      induction d₂ using ManyOneDegree.ind_on\n      apply h\n      assumption\n      rfl)\n#align many_one_degree.lift_on₂ ManyOneDegree.liftOn₂\n\n@[simp]\nprotected theorem liftOn₂_eq {φ} (p q : Set ℕ) (f : Set ℕ → Set ℕ → φ)\n    (h : ∀ p₁ p₂ q₁ q₂, ManyOneEquiv p₁ p₂ → ManyOneEquiv q₁ q₂ → f p₁ q₁ = f p₂ q₂) :\n    (of p).liftOn₂ (of q) f h = f p q :=\n  rfl\n#align many_one_degree.lift_on₂_eq ManyOneDegree.liftOn₂_eq\n\n@[simp]\ntheorem of_eq_of {p : α → Prop} {q : β → Prop} : of p = of q ↔ ManyOneEquiv p q := by\n  simp [of, Quotient.eq'']\n#align many_one_degree.of_eq_of ManyOneDegree.of_eq_of\n\ninstance : Inhabited ManyOneDegree :=\n  ⟨of (∅ : Set ℕ)⟩\n\n/-- For many-one degrees `d₁` and `d₂`, `d₁ ≤ d₂` if the sets in `d₁` are many-one reducible to the\nsets in `d₂`.\n-/\ninstance : LE ManyOneDegree :=\n  ⟨fun d₁ d₂ =>\n    ManyOneDegree.liftOn₂ d₁ d₂ (· ≤₀ ·) fun p₁ p₂ q₁ q₂ hp hq =>\n      propext (hp.le_congr_left.trans hq.le_congr_right)⟩\n\n@[simp]\ntheorem of_le_of {p : α → Prop} {q : β → Prop} : of p ≤ of q ↔ p ≤₀ q :=\n  manyOneReducible_toNat_toNat\n#align many_one_degree.of_le_of ManyOneDegree.of_le_of\n\nprivate theorem le_refl (d : ManyOneDegree) : d ≤ d := by\n  induction d using ManyOneDegree.ind_on <;> simp\n#align many_one_degree.le_refl many_one_degree.le_refl\n\nprivate theorem le_antisymm {d₁ d₂ : ManyOneDegree} : d₁ ≤ d₂ → d₂ ≤ d₁ → d₁ = d₂ :=\n  by\n  induction d₁ using ManyOneDegree.ind_on\n  induction d₂ using ManyOneDegree.ind_on\n  intro hp hq\n  simp_all only [ManyOneEquiv, of_le_of, of_eq_of, true_and_iff]\n#align many_one_degree.le_antisymm many_one_degree.le_antisymm\n\nprivate theorem le_trans {d₁ d₂ d₃ : ManyOneDegree} : d₁ ≤ d₂ → d₂ ≤ d₃ → d₁ ≤ d₃ :=\n  by\n  induction d₁ using ManyOneDegree.ind_on\n  induction d₂ using ManyOneDegree.ind_on\n  induction d₃ using ManyOneDegree.ind_on\n  apply ManyOneReducible.trans\n#align many_one_degree.le_trans many_one_degree.le_trans\n\ninstance : PartialOrder ManyOneDegree where\n  le := (· ≤ ·)\n  le_refl := le_refl\n  le_trans _ _ _ := le_trans\n  le_antisymm _ _ := le_antisymm\n\n/-- The join of two degrees, induced by the disjoint union of two underlying sets. -/\ninstance : Add ManyOneDegree :=\n  ⟨fun d₁ d₂ =>\n    d₁.liftOn₂ d₂ (fun a b => of (a ⊕' b))\n      (by\n        rintro a b c d ⟨hl₁, hr₁⟩ ⟨hl₂, hr₂⟩\n        rw [of_eq_of]\n        exact\n          ⟨disjoin_manyOneReducible (hl₁.trans one_one_reducible.disjoin_left.to_many_one)\n              (hl₂.trans one_one_reducible.disjoin_right.to_many_one),\n            disjoin_manyOneReducible (hr₁.trans one_one_reducible.disjoin_left.to_many_one)\n              (hr₂.trans one_one_reducible.disjoin_right.to_many_one)⟩)⟩\n\n@[simp]\ntheorem add_of (p : Set α) (q : Set β) : of (p ⊕' q) = of p + of q :=\n  of_eq_of.mpr\n    ⟨disjoin_manyOneReducible\n        (manyOneReducible_toNat.trans OneOneReducible.disjoin_left.to_many_one)\n        (manyOneReducible_toNat.trans OneOneReducible.disjoin_right.to_many_one),\n      disjoin_manyOneReducible\n        (toNat_manyOneReducible.trans OneOneReducible.disjoin_left.to_many_one)\n        (toNat_manyOneReducible.trans OneOneReducible.disjoin_right.to_many_one)⟩\n#align many_one_degree.add_of ManyOneDegree.add_of\n\n@[simp]\nprotected theorem add_le {d₁ d₂ d₃ : ManyOneDegree} : d₁ + d₂ ≤ d₃ ↔ d₁ ≤ d₃ ∧ d₂ ≤ d₃ :=\n  by\n  induction d₁ using ManyOneDegree.ind_on\n  induction d₂ using ManyOneDegree.ind_on\n  induction d₃ using ManyOneDegree.ind_on\n  simpa only [← add_of, of_le_of] using disjoin_le\n#align many_one_degree.add_le ManyOneDegree.add_le\n\n@[simp]\nprotected theorem le_add_left (d₁ d₂ : ManyOneDegree) : d₁ ≤ d₁ + d₂ :=\n  (ManyOneDegree.add_le.1 (by rfl)).1\n#align many_one_degree.le_add_left ManyOneDegree.le_add_left\n\n@[simp]\nprotected theorem le_add_right (d₁ d₂ : ManyOneDegree) : d₂ ≤ d₁ + d₂ :=\n  (ManyOneDegree.add_le.1 (by rfl)).2\n#align many_one_degree.le_add_right ManyOneDegree.le_add_right\n\ninstance : SemilatticeSup ManyOneDegree :=\n  { ManyOneDegree.partialOrder with\n    sup := (· + ·)\n    le_sup_left := ManyOneDegree.le_add_left\n    le_sup_right := ManyOneDegree.le_add_right\n    sup_le := fun a b c h₁ h₂ => ManyOneDegree.add_le.2 ⟨h₁, h₂⟩ }\n\nend ManyOneDegree\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Computability/Reduce.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.7185943805178139, "lm_q1q2_score": 0.48313379031009795}}
{"text": "import data.real.nnreal\nimport analysis.mean_inequalities_pow\nimport for_mathlib.ennreal\n\nopen_locale nnreal\n\n-- There doesn't seem to be a real analogue of this one, but probably should be?\nlemma nnreal.div_le_div_left_of {a b c : ℝ≥0} (w : 0 < c) (h : c ≤ b) : a / b ≤ a / c :=\nbegin\n  rcases a with ⟨a, a_pos⟩,\n  rcases b with ⟨b, b_pos⟩,\n  rcases c with ⟨c, c_pos⟩,\n  change a / b ≤ a / c,\n  change 0 < c at w,\n  change c ≤ b at h,\n  by_cases p : 0 < a,\n  { rw div_le_div_left p (lt_of_lt_of_le w h) w,\n    exact h, },\n  { have q : a = 0, linarith,\n    subst q,\n    simp, }\nend\n\nattribute [norm_cast] nnreal.coe_zpow\n\nopen_locale ennreal big_operators\n\n/-- sum of row sums equals sum of column sums -/\nlemma nnreal.summable_symm {α β: Type*} (F : α → β → ℝ≥0)\n  (h_rows : ∀ n, summable (λ k, F n k)) (h_cols : ∀ k, summable (λ n, F n k))\n  (h_col_row : summable (λ k, ∑' n, F n k)) : summable (λ n, ∑' k, F n k) :=\nbegin\n  cases h_col_row with a ha,\n  use a,\n  rw ← ennreal.has_sum_coe,\n  convert_to has_sum (λ n, ∑' k, (F n k : ℝ≥0∞)) a,\n  { ext1 n,\n    exact ennreal.coe_tsum (h_rows n) },\n  { rw ennreal.has_sum_comm,\n    rw ← ennreal.has_sum_coe at ha,\n    convert ha,\n    ext1 k,\n    exact (ennreal.coe_tsum (h_cols k)).symm },\nend\n\nopen nnreal\n\nlemma nnreal.summable_of_comp_injective {α β : Type*} {f : α → ℝ≥0} {i : β → α}\n  (hi : function.injective i) (hi' : ∀ a, a ∉ set.range i → f a = 0) (hfi : summable (f ∘ i)) :\n  summable f :=\nbegin\n  rw ← summable_coe at hfi ⊢,\n  let e : β ≃ ({x : α | x ∈ set.range i} : set α) :=\n  { to_fun := λ b, ⟨i b, b, rfl⟩,\n  inv_fun := λ x, x.2.some,\n  left_inv := begin intro b, simp, apply hi, exact Exists.some_spec (⟨b, rfl⟩ : ∃ y, i y = i b) end,\n  right_inv := begin rintro ⟨x, b, rfl⟩, simp, exact Exists.some_spec (⟨b, rfl⟩ : ∃ y, i y = i b) end },\n  have this2 : summable ((λ (x : {x : α // x ∈ set.range i}), (f x.1 : ℝ)) ∘ ⇑e : β → ℝ),\n  { convert (summable_congr _).1 hfi,\n    intro b, refl },\n  rw e.summable_iff at this2,\n  change summable ((λ a, (f a : ℝ)) ∘ (coe : {x // x ∈ set.range i} → α)) at this2,\n  rw ← this2.summable_compl_iff,\n  convert summable_zero,\n  ext1 ⟨x, hx⟩,\n  simp [hi' x hx],\nend\n\nlemma nnreal.summable_subtype {β : Type*} {f : β → ℝ≥0} (hf : summable f)\n  (s : set β) :  summable (f ∘ (coe : s → β)) :=\nbegin\n  rw ← summable_coe at ⊢ hf,\n  exact hf.subtype s,\nend\n\nlemma nnreal.mul_le_mul_right {a b : ℝ≥0} (h : a ≤ b) (c : ℝ≥0) : a * c ≤ b * c :=\nbegin\n  suffices : (a : ℝ) * c ≤ b * c, by assumption_mod_cast,\n  apply mul_le_mul_of_nonneg_right (by assumption_mod_cast),\n  apply zero_le',\nend\n\nlemma nnreal.mul_le_mul_left {a b : ℝ≥0} (h : a ≤ b) (c : ℝ≥0) : c * a ≤ c * b :=\nby simpa [mul_comm] using nnreal.mul_le_mul_right h c\n\nlemma nnreal.rpow_sum_le_sum_rpow\n  {ι : Type*} (s : finset ι) {p : ℝ} (a : ι → ℝ≥0) (hp_pos : 0 < p) (hp1 : p ≤ 1) :\n  (∑ i in s, a i) ^ p ≤ ∑ i in s, (a i ^ p) :=\nbegin\n  classical,\n  induction s using finset.induction_on with i s his IH,\n  { simp only [nnreal.zero_rpow hp_pos.ne', finset.sum_empty, le_zero_iff], },\n  { simp only [his, finset.sum_insert, not_false_iff],\n    exact (nnreal.rpow_add_le_add_rpow _ _ hp_pos.le hp1).trans (add_le_add le_rfl IH), }\nend\n\nlemma nnreal.le_self_rpow {a : ℝ≥0} {m : ℝ} (ha : 1 ≤ a) (hm : 1 ≤ m) : a ≤ a ^ m :=\nbegin\n  suffices : a ^ (1 : ℝ) ≤ a ^ m,\n    simpa,\n  exact rpow_le_rpow_of_exponent_le ha hm,\nend\n\n\nlemma nnreal.le_self_rpow' {a : ℝ≥0} {m : ℝ} (ha : a ≤ 1) (hm : m ≤ 1) : a ≤ a ^ m :=\nbegin\n  obtain (rfl|⟨u, rfl⟩) := group_with_zero.eq_zero_or_unit a, apply zero_le, -- a=0 special case\n  suffices : (u : ℝ≥0) ^ (1 : ℝ) ≤ u ^ m,\n    simpa,\n  exact rpow_le_rpow_of_exponent_ge (by simp) ha hm,\nend\n\n-- no need to prove for nnreal because need positive (not non-negative)\nlemma real.injective_log {r s : ℝ} (hr : 0 < r) (hs : 0 < s) (h : real.log r = real.log s) : r = s :=\nbegin\n  apply_fun real.exp at h,\n  rwa [real.exp_log hr, real.exp_log hs] at h,\nend\n\nlemma nnreal.pow_log_div_log_self {r : ℝ} {s : ℝ} (hr : 0 < r) (hs : 0 < s) (hs' : s ≠ 1) :\n  s ^ (real.log r / real.log s) = r :=\nbegin\n  apply real.injective_log (real.rpow_pos_of_pos hs _) hr,\n  rw real.log_rpow hs,\n  rw ← eq_div_iff,\n  apply mt (λ h, _) hs',\n  rw real.log_eq_zero at h,\n  rcases h with (h|h|h); linarith,\nend\n\nlemma nnreal.div_inv {a b : ℝ≥0} : a / b⁻¹ = a * b :=\nbegin\n  rcases eq_or_ne b 0 with (rfl | hb),\n  { rw [inv_zero, div_zero, mul_zero] },\n  rw [div_eq_iff (inv_ne_zero hb), mul_assoc, mul_inv_cancel hb, mul_one],\nend\n\nlemma nnreal.tsum_le_tsum {X : Type*} {f g : X → ℝ≥0} (hle : ∀ x, f x ≤ g x)\n  (hsummable : summable g) : ∑' x, f x ≤ ∑' x, g x :=\ntsum_le_tsum hle (summable_of_le hle hsummable) hsummable\n\nlemma nnreal.summable_iff_summable_nnnorm {X : Type*} {f : X → ℝ} :\n  summable f ↔ summable (λ x, ∥f x∥₊) :=\nbegin\n  rw ← summable_norm_iff,\n  rw ← summable_coe,\n  congr',\nend\n\nlemma nnreal.le_zero_iff {a : ℝ≥0} : a ≤ 0 ↔ a = 0 := le_bot_iff\n\nlemma nnreal.sub_pos {a b : ℝ≥0} : 0 < a - b ↔ b < a :=\nbegin\n  rw ← not_iff_not,\n  push_neg,\n  rw nnreal.le_zero_iff,\n  apply tsub_eq_zero_iff_le,\nend\n\nlemma nnreal.inv_lt_of_inv_lt {a b : ℝ≥0} (ha : a ≠ 0) (hab : a⁻¹ < b) : b⁻¹ < a :=\nbegin\n  suffices : (b : ℝ)⁻¹ < a,\n    exact_mod_cast this,\n  apply inv_lt_of_inv_lt,\n  { norm_cast,\n    rwa zero_lt_iff, },\n  { exact_mod_cast hab, },\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/nnreal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.48313378897787074}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Yury Kudryashov\n-/\nimport algebra.algebra.operations\nimport data.set.Union_lift\nimport ring_theory.subring.pointwise\n\n/-!\n# Subalgebras over Commutative Semiring\n\nIn this file we define `subalgebra`s and the usual operations on them (`map`, `comap'`).\n\nMore lemmas about `adjoin` can be found in `ring_theory.adjoin`.\n-/\nuniverses u u' v w w'\n\nopen_locale tensor_product big_operators\n\nset_option old_structure_cmd true\n\n/-- A subalgebra is a sub(semi)ring that includes the range of `algebra_map`. -/\nstructure subalgebra (R : Type u) (A : Type v)\n  [comm_semiring R] [semiring A] [algebra R A] extends subsemiring A : Type v :=\n(algebra_map_mem' : ∀ r, algebra_map R A r ∈ carrier)\n(zero_mem' := (algebra_map R A).map_zero ▸ algebra_map_mem' 0)\n(one_mem' := (algebra_map R A).map_one ▸ algebra_map_mem' 1)\n\n/-- Reinterpret a `subalgebra` as a `subsemiring`. -/\nadd_decl_doc subalgebra.to_subsemiring\n\nnamespace subalgebra\n\nvariables {R' : Type u'} {R : Type u} {A : Type v} {B : Type w} {C : Type w'}\nvariables [comm_semiring R]\nvariables [semiring A] [algebra R A] [semiring B] [algebra R B] [semiring C] [algebra R C]\ninclude R\n\ninstance : set_like (subalgebra R A) A :=\n⟨subalgebra.carrier, λ p q h, by cases p; cases q; congr'⟩\n\n@[simp]\nlemma mem_carrier {s : subalgebra R A} {x : A} : x ∈ s.carrier ↔ x ∈ s := iff.rfl\n\n@[ext] theorem ext {S T : subalgebra R A} (h : ∀ x : A, x ∈ S ↔ x ∈ T) : S = T := set_like.ext h\n\n@[simp] lemma mem_to_subsemiring {S : subalgebra R A} {x} : x ∈ S.to_subsemiring ↔ x ∈ S := iff.rfl\n\n@[simp] lemma coe_to_subsemiring (S : subalgebra R A) : (↑S.to_subsemiring : set A) = S := rfl\n\ntheorem to_subsemiring_injective :\n  function.injective (to_subsemiring : subalgebra R A → subsemiring A) :=\nλ S T h, ext $ λ x, by rw [← mem_to_subsemiring, ← mem_to_subsemiring, h]\n\ntheorem to_subsemiring_inj {S U : subalgebra R A} : S.to_subsemiring = U.to_subsemiring ↔ S = U :=\nto_subsemiring_injective.eq_iff\n\n/-- Copy of a subalgebra with a new `carrier` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (S : subalgebra R A) (s : set A) (hs : s = ↑S) : subalgebra R A :=\n{ carrier := s,\n  add_mem' := hs.symm ▸ S.add_mem',\n  mul_mem' := hs.symm ▸ S.mul_mem',\n  algebra_map_mem' := hs.symm ▸ S.algebra_map_mem' }\n\n@[simp] lemma coe_copy (S : subalgebra R A) (s : set A) (hs : s = ↑S) :\n  (S.copy s hs : set A) = s := rfl\n\nlemma copy_eq (S : subalgebra R A) (s : set A) (hs : s = ↑S) : S.copy s hs = S :=\nset_like.coe_injective hs\n\nvariables (S : subalgebra R A)\n\ntheorem algebra_map_mem (r : R) : algebra_map R A r ∈ S :=\nS.algebra_map_mem' r\n\ntheorem srange_le : (algebra_map R A).srange ≤ S.to_subsemiring :=\nλ x ⟨r, hr⟩, hr ▸ S.algebra_map_mem r\n\ntheorem range_subset : set.range (algebra_map R A) ⊆ S :=\nλ x ⟨r, hr⟩, hr ▸ S.algebra_map_mem r\n\ntheorem range_le : set.range (algebra_map R A) ≤ S :=\nS.range_subset\n\ntheorem one_mem : (1 : A) ∈ S :=\nS.to_subsemiring.one_mem\n\ntheorem mul_mem {x y : A} (hx : x ∈ S) (hy : y ∈ S) : x * y ∈ S :=\nS.to_subsemiring.mul_mem hx hy\n\ntheorem smul_mem {x : A} (hx : x ∈ S) (r : R) : r • x ∈ S :=\n(algebra.smul_def r x).symm ▸ S.mul_mem (S.algebra_map_mem r) hx\n\ntheorem pow_mem {x : A} (hx : x ∈ S) (n : ℕ) : x ^ n ∈ S :=\nS.to_subsemiring.pow_mem hx n\n\ntheorem zero_mem : (0 : A) ∈ S :=\nS.to_subsemiring.zero_mem\n\ntheorem add_mem {x y : A} (hx : x ∈ S) (hy : y ∈ S) : x + y ∈ S :=\nS.to_subsemiring.add_mem hx hy\n\ntheorem neg_mem {R : Type u} {A : Type v} [comm_ring R] [ring A]\n  [algebra R A] (S : subalgebra R A) {x : A} (hx : x ∈ S) : -x ∈ S :=\nneg_one_smul R x ▸ S.smul_mem hx _\n\ntheorem sub_mem {R : Type u} {A : Type v} [comm_ring R] [ring A]\n  [algebra R A] (S : subalgebra R A) {x y : A} (hx : x ∈ S) (hy : y ∈ S) : x - y ∈ S :=\nby simpa only [sub_eq_add_neg] using S.add_mem hx (S.neg_mem hy)\n\ntheorem nsmul_mem {x : A} (hx : x ∈ S) (n : ℕ) : n • x ∈ S :=\nS.to_subsemiring.nsmul_mem hx n\n\ntheorem zsmul_mem {R : Type u} {A : Type v} [comm_ring R] [ring A]\n  [algebra R A] (S : subalgebra R A) {x : A} (hx : x ∈ S) : ∀ (n : ℤ), n • x ∈ S\n| (n : ℕ) := by { rw [coe_nat_zsmul], exact S.nsmul_mem hx n }\n| -[1+ n] := by { rw [zsmul_neg_succ_of_nat], exact S.neg_mem (S.nsmul_mem hx _) }\n\ntheorem coe_nat_mem (n : ℕ) : (n : A) ∈ S :=\nS.to_subsemiring.coe_nat_mem n\n\ntheorem coe_int_mem {R : Type u} {A : Type v} [comm_ring R] [ring A]\n  [algebra R A] (S : subalgebra R A) (n : ℤ) : (n : A) ∈ S :=\nint.cases_on n (λ i, S.coe_nat_mem i) (λ i, S.neg_mem $ S.coe_nat_mem $ i + 1)\n\ntheorem list_prod_mem {L : list A} (h : ∀ x ∈ L, x ∈ S) : L.prod ∈ S :=\nS.to_subsemiring.list_prod_mem h\n\ntheorem list_sum_mem {L : list A} (h : ∀ x ∈ L, x ∈ S) : L.sum ∈ S :=\nS.to_subsemiring.list_sum_mem h\n\ntheorem multiset_prod_mem {R : Type u} {A : Type v} [comm_semiring R] [comm_semiring A]\n  [algebra R A] (S : subalgebra R A) {m : multiset A} (h : ∀ x ∈ m, x ∈ S) : m.prod ∈ S :=\nS.to_subsemiring.multiset_prod_mem m h\n\ntheorem multiset_sum_mem {m : multiset A} (h : ∀ x ∈ m, x ∈ S) : m.sum ∈ S :=\nS.to_subsemiring.multiset_sum_mem m h\n\ntheorem prod_mem {R : Type u} {A : Type v} [comm_semiring R] [comm_semiring A]\n  [algebra R A] (S : subalgebra R A) {ι : Type w} {t : finset ι} {f : ι → A}\n  (h : ∀ x ∈ t, f x ∈ S) : ∏ x in t, f x ∈ S :=\nS.to_subsemiring.prod_mem h\n\ntheorem sum_mem {ι : Type w} {t : finset ι} {f : ι → A}\n  (h : ∀ x ∈ t, f x ∈ S) : ∑ x in t, f x ∈ S :=\nS.to_subsemiring.sum_mem h\n\n/-- The projection from a subalgebra of `A` to an additive submonoid of `A`. -/\ndef to_add_submonoid {R : Type u} {A : Type v} [comm_semiring R] [semiring A] [algebra R A]\n  (S : subalgebra R A) : add_submonoid A :=\nS.to_subsemiring.to_add_submonoid\n\n/-- The projection from a subalgebra of `A` to a submonoid of `A`. -/\ndef to_submonoid {R : Type u} {A : Type v} [comm_semiring R] [semiring A] [algebra R A]\n  (S : subalgebra R A) : submonoid A :=\nS.to_subsemiring.to_submonoid\n\n/-- A subalgebra over a ring is also a `subring`. -/\ndef to_subring {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A] (S : subalgebra R A) :\n  subring A :=\n{ neg_mem' := λ _, S.neg_mem,\n  .. S.to_subsemiring }\n\n@[simp] lemma mem_to_subring {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A]\n  {S : subalgebra R A} {x} : x ∈ S.to_subring ↔ x ∈ S := iff.rfl\n\n@[simp] lemma coe_to_subring {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A]\n  (S : subalgebra R A) : (↑S.to_subring : set A) = S := rfl\n\ntheorem to_subring_injective {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A] :\n  function.injective (to_subring : subalgebra R A → subring A) :=\nλ S T h, ext $ λ x, by rw [← mem_to_subring, ← mem_to_subring, h]\n\ntheorem to_subring_inj {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A]\n  {S U : subalgebra R A} : S.to_subring = U.to_subring ↔ S = U :=\nto_subring_injective.eq_iff\n\ninstance : inhabited S := ⟨(0 : S.to_subsemiring)⟩\n\nsection\n\n/-! `subalgebra`s inherit structure from their `subsemiring` / `semiring` coercions. -/\n\ninstance to_semiring {R A}\n  [comm_semiring R] [semiring A] [algebra R A] (S : subalgebra R A) :\n  semiring S := S.to_subsemiring.to_semiring\ninstance to_comm_semiring {R A}\n  [comm_semiring R] [comm_semiring A] [algebra R A] (S : subalgebra R A) :\n  comm_semiring S := S.to_subsemiring.to_comm_semiring\ninstance to_ring {R A}\n  [comm_ring R] [ring A] [algebra R A] (S : subalgebra R A) :\n  ring S := S.to_subring.to_ring\ninstance to_comm_ring {R A}\n  [comm_ring R] [comm_ring A] [algebra R A] (S : subalgebra R A) :\n  comm_ring S := S.to_subring.to_comm_ring\n\ninstance to_ordered_semiring {R A}\n  [comm_semiring R] [ordered_semiring A] [algebra R A] (S : subalgebra R A) :\n  ordered_semiring S := S.to_subsemiring.to_ordered_semiring\ninstance to_ordered_comm_semiring {R A}\n  [comm_semiring R] [ordered_comm_semiring A] [algebra R A] (S : subalgebra R A) :\n  ordered_comm_semiring S := S.to_subsemiring.to_ordered_comm_semiring\ninstance to_ordered_ring {R A}\n  [comm_ring R] [ordered_ring A] [algebra R A] (S : subalgebra R A) :\n  ordered_ring S := S.to_subring.to_ordered_ring\ninstance to_ordered_comm_ring {R A}\n  [comm_ring R] [ordered_comm_ring A] [algebra R A] (S : subalgebra R A) :\n  ordered_comm_ring S := S.to_subring.to_ordered_comm_ring\n\ninstance to_linear_ordered_semiring {R A}\n  [comm_semiring R] [linear_ordered_semiring A] [algebra R A] (S : subalgebra R A) :\n  linear_ordered_semiring S := S.to_subsemiring.to_linear_ordered_semiring\n/-! There is no `linear_ordered_comm_semiring`. -/\ninstance to_linear_ordered_ring {R A}\n  [comm_ring R] [linear_ordered_ring A] [algebra R A] (S : subalgebra R A) :\n  linear_ordered_ring S := S.to_subring.to_linear_ordered_ring\ninstance to_linear_ordered_comm_ring {R A}\n  [comm_ring R] [linear_ordered_comm_ring A] [algebra R A] (S : subalgebra R A) :\n  linear_ordered_comm_ring S := S.to_subring.to_linear_ordered_comm_ring\n\nend\n\n/-- Convert a `subalgebra` to `submodule` -/\ndef to_submodule : submodule R A :=\n{ carrier := S,\n  zero_mem' := (0:S).2,\n  add_mem' := λ x y hx hy, (⟨x, hx⟩ + ⟨y, hy⟩ : S).2,\n  smul_mem' := λ c x hx, (algebra.smul_def c x).symm ▸\n    (⟨algebra_map R A c, S.range_le ⟨c, rfl⟩⟩ * ⟨x, hx⟩:S).2 }\n\n@[simp] lemma mem_to_submodule {x} : x ∈ S.to_submodule ↔ x ∈ S := iff.rfl\n\n@[simp] lemma coe_to_submodule (S : subalgebra R A) : (↑S.to_submodule : set A) = S := rfl\n\ntheorem to_submodule_injective :\n  function.injective (to_submodule : subalgebra R A → submodule R A) :=\nλ S T h, ext $ λ x, by rw [← mem_to_submodule, ← mem_to_submodule, h]\n\ntheorem to_submodule_inj {S U : subalgebra R A} : S.to_submodule = U.to_submodule ↔ S = U :=\nto_submodule_injective.eq_iff\n\nsection\n\n/-! `subalgebra`s inherit structure from their `submodule` coercions. -/\n\ninstance module' [semiring R'] [has_scalar R' R] [module R' A] [is_scalar_tower R' R A] :\n  module R' S :=\nS.to_submodule.module'\ninstance : module R S := S.module'\n\ninstance [semiring R'] [has_scalar R' R] [module R' A] [is_scalar_tower R' R A] :\n  is_scalar_tower R' R S :=\nS.to_submodule.is_scalar_tower\n\ninstance algebra' [comm_semiring R'] [has_scalar R' R] [algebra R' A]\n  [is_scalar_tower R' R A] : algebra R' S :=\n{ commutes' := λ c x, subtype.eq $ algebra.commutes _ _,\n  smul_def' := λ c x, subtype.eq $ algebra.smul_def _ _,\n  .. (algebra_map R' A).cod_srestrict S.to_subsemiring $ λ x, begin\n    rw [algebra.algebra_map_eq_smul_one, ←smul_one_smul R x (1 : A),\n      ←algebra.algebra_map_eq_smul_one],\n    exact algebra_map_mem S _,\n  end }\ninstance : algebra R S := S.algebra'\n\n\nend\n\ninstance nontrivial [nontrivial A] : nontrivial S :=\nS.to_subsemiring.nontrivial\n\ninstance no_zero_smul_divisors_bot [no_zero_smul_divisors R A] : no_zero_smul_divisors R S :=\n⟨λ c x h,\n  have c = 0 ∨ (x : A) = 0,\n  from eq_zero_or_eq_zero_of_smul_eq_zero (congr_arg coe h),\n  this.imp_right (@subtype.ext_iff _ _ x 0).mpr⟩\n\n@[simp, norm_cast] lemma coe_add (x y : S) : (↑(x + y) : A) = ↑x + ↑y := rfl\n@[simp, norm_cast] lemma coe_mul (x y : S) : (↑(x * y) : A) = ↑x * ↑y := rfl\n@[simp, norm_cast] lemma coe_zero : ((0 : S) : A) = 0 := rfl\n@[simp, norm_cast] lemma coe_one : ((1 : S) : A) = 1 := rfl\n@[simp, norm_cast] lemma coe_neg {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A]\n  {S : subalgebra R A} (x : S) : (↑(-x) : A) = -↑x := rfl\n@[simp, norm_cast] lemma coe_sub {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A]\n  {S : subalgebra R A} (x y : S) : (↑(x - y) : A) = ↑x - ↑y := rfl\n@[simp, norm_cast] lemma coe_smul [semiring R'] [has_scalar R' R] [module R' A]\n  [is_scalar_tower R' R A] (r : R') (x : S) : (↑(r • x) : A) = r • ↑x := rfl\n@[simp, norm_cast] lemma coe_algebra_map [comm_semiring R'] [has_scalar R' R] [algebra R' A]\n  [is_scalar_tower R' R A] (r : R') :\n  ↑(algebra_map R' S r) = algebra_map R' A r := rfl\n\n@[simp, norm_cast] lemma coe_pow (x : S) (n : ℕ) : (↑(x^n) : A) = (↑x)^n :=\nbegin\n  induction n with n ih,\n  { simp, },\n  { simp [pow_succ, ih], },\nend\n\n@[simp, norm_cast] lemma coe_eq_zero {x : S} : (x : A) = 0 ↔ x = 0 :=\n(subtype.ext_iff.symm : (x : A) = (0 : S) ↔ x = 0)\n@[simp, norm_cast] lemma coe_eq_one {x : S} : (x : A) = 1 ↔ x = 1 :=\n(subtype.ext_iff.symm : (x : A) = (1 : S) ↔ x = 1)\n\n-- todo: standardize on the names these morphisms\n-- compare with submodule.subtype\n\n/-- Embedding of a subalgebra into the algebra. -/\ndef val : S →ₐ[R] A :=\nby refine_struct { to_fun := (coe : S → A) }; intros; refl\n\n@[simp] lemma coe_val : (S.val : S → A) = coe := rfl\n\nlemma val_apply (x : S) : S.val x = (x : A) := rfl\n\n@[simp] lemma to_subsemiring_subtype : S.to_subsemiring.subtype = (S.val : S →+* A) :=\nrfl\n\n@[simp] lemma to_subring_subtype {R A : Type*} [comm_ring R] [ring A]\n  [algebra R A] (S : subalgebra R A) : S.to_subring.subtype = (S.val : S →+* A) :=\nrfl\n\n\n/-- As submodules, subalgebras are idempotent. -/\n@[simp] theorem mul_self : S.to_submodule * S.to_submodule = S.to_submodule :=\nbegin\n  apply le_antisymm,\n  { rw submodule.mul_le,\n    intros y hy z hz,\n    exact mul_mem S hy hz },\n  { intros x hx1,\n    rw ← mul_one x,\n    exact submodule.mul_mem_mul hx1 (one_mem S) }\nend\n\n/-- Linear equivalence between `S : submodule R A` and `S`. Though these types are equal,\nwe define it as a `linear_equiv` to avoid type equalities. -/\ndef to_submodule_equiv (S : subalgebra R A) : S.to_submodule ≃ₗ[R] S :=\nlinear_equiv.of_eq _ _ rfl\n\n/-- Transport a subalgebra via an algebra homomorphism. -/\ndef map (S : subalgebra R A) (f : A →ₐ[R] B) : subalgebra R B :=\n{ algebra_map_mem' := λ r, f.commutes r ▸ set.mem_image_of_mem _ (S.algebra_map_mem r),\n  .. S.to_subsemiring.map (f : A →+* B) }\n\nlemma map_mono {S₁ S₂ : subalgebra R A} {f : A →ₐ[R] B} :\n  S₁ ≤ S₂ → S₁.map f ≤ S₂.map f :=\nset.image_subset f\n\nlemma map_injective {S₁ S₂ : subalgebra R A} (f : A →ₐ[R] B)\n  (hf : function.injective f) (ih : S₁.map f = S₂.map f) : S₁ = S₂ :=\next $ set.ext_iff.1 $ set.image_injective.2 hf $ set.ext $ set_like.ext_iff.mp ih\n\n@[simp] lemma map_id (S : subalgebra R A) : S.map (alg_hom.id R A) = S :=\nset_like.coe_injective $ set.image_id _\n\nlemma map_map (S : subalgebra R A) (g : B →ₐ[R] C) (f : A →ₐ[R] B) :\n  (S.map f).map g = S.map (g.comp f) :=\nset_like.coe_injective $ set.image_image _ _ _\n\nlemma mem_map {S : subalgebra R A} {f : A →ₐ[R] B} {y : B} :\n  y ∈ map S f ↔ ∃ x ∈ S, f x = y :=\nsubsemiring.mem_map\n\nlemma map_to_submodule {S : subalgebra R A} {f : A →ₐ[R] B} :\n  (S.map f).to_submodule = S.to_submodule.map f.to_linear_map :=\nset_like.coe_injective rfl\n\nlemma map_to_subsemiring {S : subalgebra R A} {f : A →ₐ[R] B} :\n  (S.map f).to_subsemiring = S.to_subsemiring.map f.to_ring_hom :=\nset_like.coe_injective rfl\n\n@[simp] lemma coe_map (S : subalgebra R A) (f : A →ₐ[R] B) :\n  (S.map f : set B) = f '' S :=\nrfl\n\n/-- Preimage of a subalgebra under an algebra homomorphism. -/\ndef comap' (S : subalgebra R B) (f : A →ₐ[R] B) : subalgebra R A :=\n{ algebra_map_mem' := λ r, show f (algebra_map R A r) ∈ S,\n    from (f.commutes r).symm ▸ S.algebra_map_mem r,\n  .. S.to_subsemiring.comap (f : A →+* B) }\n\ntheorem map_le {S : subalgebra R A} {f : A →ₐ[R] B} {U : subalgebra R B} :\n  map S f ≤ U ↔ S ≤ comap' U f :=\nset.image_subset_iff\n\nlemma gc_map_comap (f : A →ₐ[R] B) : galois_connection (λ S, map S f) (λ S, comap' S f) :=\nλ S U, map_le\n\n@[simp] lemma mem_comap (S : subalgebra R B) (f : A →ₐ[R] B) (x : A) :\n  x ∈ S.comap' f ↔ f x ∈ S :=\niff.rfl\n\n@[simp, norm_cast] lemma coe_comap (S : subalgebra R B) (f : A →ₐ[R] B) :\n  (S.comap' f : set A) = f ⁻¹' (S : set B) :=\nrfl\n\ninstance no_zero_divisors {R A : Type*} [comm_ring R] [semiring A] [no_zero_divisors A]\n  [algebra R A] (S : subalgebra R A) : no_zero_divisors S :=\nS.to_subsemiring.no_zero_divisors\n\ninstance is_domain {R A : Type*} [comm_ring R] [ring A] [is_domain A] [algebra R A]\n  (S : subalgebra R A) : is_domain S :=\nsubring.is_domain S.to_subring\n\nend subalgebra\n\nnamespace alg_hom\n\nvariables {R' : Type u'} {R : Type u} {A : Type v} {B : Type w} {C : Type w'}\nvariables [comm_semiring R]\nvariables [semiring A] [algebra R A] [semiring B] [algebra R B] [semiring C] [algebra R C]\nvariables (φ : A →ₐ[R] B)\n\n/-- Range of an `alg_hom` as a subalgebra. -/\nprotected def range (φ : A →ₐ[R] B) : subalgebra R B :=\n{ algebra_map_mem' := λ r, ⟨algebra_map R A r, φ.commutes r⟩,\n  .. φ.to_ring_hom.srange }\n\n@[simp] lemma mem_range (φ : A →ₐ[R] B) {y : B} :\n  y ∈ φ.range ↔ ∃ x, φ x = y := ring_hom.mem_srange\n\ntheorem mem_range_self (φ : A →ₐ[R] B) (x : A) : φ x ∈ φ.range := φ.mem_range.2 ⟨x, rfl⟩\n\n@[simp] lemma coe_range (φ : A →ₐ[R] B) : (φ.range : set B) = set.range φ :=\nby { ext, rw [set_like.mem_coe, mem_range], refl }\n\ntheorem range_comp (f : A →ₐ[R] B) (g : B →ₐ[R] C) : (g.comp f).range = f.range.map g :=\nset_like.coe_injective (set.range_comp g f)\n\ntheorem range_comp_le_range (f : A →ₐ[R] B) (g : B →ₐ[R] C) : (g.comp f).range ≤ g.range :=\nset_like.coe_mono (set.range_comp_subset_range f g)\n\n/-- Restrict the codomain of an algebra homomorphism. -/\ndef cod_restrict (f : A →ₐ[R] B) (S : subalgebra R B) (hf : ∀ x, f x ∈ S) : A →ₐ[R] S :=\n{ commutes' := λ r, subtype.eq $ f.commutes r,\n  .. ring_hom.cod_srestrict (f : A →+* B) S.to_subsemiring hf }\n\n@[simp] lemma val_comp_cod_restrict (f : A →ₐ[R] B) (S : subalgebra R B) (hf : ∀ x, f x ∈ S) :\n  S.val.comp (f.cod_restrict S hf) = f :=\nalg_hom.ext $ λ _, rfl\n\n@[simp] lemma coe_cod_restrict (f : A →ₐ[R] B) (S : subalgebra R B) (hf : ∀ x, f x ∈ S) (x : A) :\n  ↑(f.cod_restrict S hf x) = f x := rfl\n\ntheorem injective_cod_restrict (f : A →ₐ[R] B) (S : subalgebra R B) (hf : ∀ x, f x ∈ S) :\n  function.injective (f.cod_restrict S hf) ↔ function.injective f :=\n⟨λ H x y hxy, H $ subtype.eq hxy, λ H x y hxy, H (congr_arg subtype.val hxy : _)⟩\n\n/-- Restrict the codomain of a alg_hom `f` to `f.range`.\n\nThis is the bundled version of `set.range_factorization`. -/\n@[reducible] def range_restrict (f : A →ₐ[R] B) : A →ₐ[R] f.range :=\nf.cod_restrict f.range f.mem_range_self\n\n/-- The equalizer of two R-algebra homomorphisms -/\ndef equalizer (ϕ ψ : A →ₐ[R] B) : subalgebra R A :=\n{ carrier := {a | ϕ a = ψ a},\n  add_mem' := λ x y (hx : ϕ x = ψ x) (hy : ϕ y = ψ y),\n    by rw [set.mem_set_of_eq, ϕ.map_add, ψ.map_add, hx, hy],\n  mul_mem' := λ x y (hx : ϕ x = ψ x) (hy : ϕ y = ψ y),\n    by rw [set.mem_set_of_eq, ϕ.map_mul, ψ.map_mul, hx, hy],\n  algebra_map_mem' := λ x,\n    by rw [set.mem_set_of_eq, alg_hom.commutes, alg_hom.commutes] }\n\n@[simp] lemma mem_equalizer (ϕ ψ : A →ₐ[R] B) (x : A) :\n  x ∈ ϕ.equalizer ψ ↔ ϕ x = ψ x := iff.rfl\n\n/-- The range of a morphism of algebras is a fintype, if the domain is a fintype.\n\nNote that this instance can cause a diamond with `subtype.fintype` if `B` is also a fintype. -/\ninstance fintype_range [fintype A] [decidable_eq B] (φ : A →ₐ[R] B) : fintype φ.range :=\nset.fintype_range φ\n\nend alg_hom\n\nnamespace alg_equiv\n\nvariables {R : Type u} {A : Type v} {B : Type w}\nvariables [comm_semiring R] [semiring A] [semiring B] [algebra R A] [algebra R B]\n\n/-- Restrict an algebra homomorphism with a left inverse to an algebra isomorphism to its range.\n\nThis is a computable alternative to `alg_equiv.of_injective`. -/\ndef of_left_inverse\n  {g : B → A} {f : A →ₐ[R] B} (h : function.left_inverse g f) :\n  A ≃ₐ[R] f.range :=\n{ to_fun := f.range_restrict,\n  inv_fun := g ∘ f.range.val,\n  left_inv := h,\n  right_inv := λ x, subtype.ext $\n    let ⟨x', hx'⟩ := f.mem_range.mp x.prop in\n    show f (g x) = x, by rw [←hx', h x'],\n  ..f.range_restrict }\n\n@[simp] lemma of_left_inverse_apply\n  {g : B → A} {f : A →ₐ[R] B} (h : function.left_inverse g f) (x : A) :\n  ↑(of_left_inverse h x) = f x := rfl\n\n@[simp] lemma of_left_inverse_symm_apply\n  {g : B → A} {f : A →ₐ[R] B} (h : function.left_inverse g f) (x : f.range) :\n  (of_left_inverse h).symm x = g x := rfl\n\n/-- Restrict an injective algebra homomorphism to an algebra isomorphism -/\nnoncomputable def of_injective (f : A →ₐ[R] B) (hf : function.injective f) :\n  A ≃ₐ[R] f.range :=\nof_left_inverse (classical.some_spec hf.has_left_inverse)\n\n@[simp] lemma of_injective_apply (f : A →ₐ[R] B) (hf : function.injective f) (x : A) :\n  ↑(of_injective f hf x) = f x := rfl\n\n/-- Restrict an algebra homomorphism between fields to an algebra isomorphism -/\nnoncomputable def of_injective_field {E F : Type*} [division_ring E] [semiring F]\n  [nontrivial F] [algebra R E] [algebra R F] (f : E →ₐ[R] F) : E ≃ₐ[R] f.range :=\nof_injective f f.to_ring_hom.injective\n\n/-- Given an equivalence `e : A ≃ₐ[R] B` of `R`-algebras and a subalgebra `S` of `A`,\n`subalgebra_map` is the induced equivalence between `S` and `S.map e` -/\n@[simps] def subalgebra_map (e : A ≃ₐ[R] B) (S : subalgebra R A) :\n  S ≃ₐ[R] (S.map e.to_alg_hom) :=\n{ commutes' := λ r, by { ext, simp },\n  ..e.to_ring_equiv.subsemiring_map S.to_subsemiring }\n\nend alg_equiv\n\nnamespace algebra\n\nvariables (R : Type u) {A : Type v} {B : Type w}\nvariables [comm_semiring R] [semiring A] [algebra R A] [semiring B] [algebra R B]\n\n/-- The minimal subalgebra that includes `s`. -/\ndef adjoin (s : set A) : subalgebra R A :=\n{ algebra_map_mem' := λ r, subsemiring.subset_closure $ or.inl ⟨r, rfl⟩,\n  .. subsemiring.closure (set.range (algebra_map R A) ∪ s) }\nvariables {R}\n\nprotected lemma gc : galois_connection (adjoin R : set A → subalgebra R A) coe :=\nλ s S, ⟨λ H, le_trans (le_trans (set.subset_union_right _ _) subsemiring.subset_closure) H,\nλ H, show subsemiring.closure (set.range (algebra_map R A) ∪ s) ≤ S.to_subsemiring,\n     from subsemiring.closure_le.2 $ set.union_subset S.range_subset H⟩\n\n/-- Galois insertion between `adjoin` and `coe`. -/\nprotected def gi : galois_insertion (adjoin R : set A → subalgebra R A) coe :=\n{ choice := λ s hs, (adjoin R s).copy s $ le_antisymm (algebra.gc.le_u_l s) hs,\n  gc := algebra.gc,\n  le_l_u := λ S, (algebra.gc (S : set A) (adjoin R S)).1 $ le_rfl,\n  choice_eq := λ _ _, subalgebra.copy_eq _ _ _ }\n\ninstance : complete_lattice (subalgebra R A) :=\ngalois_insertion.lift_complete_lattice algebra.gi\n\n@[simp]\nlemma coe_top : (↑(⊤ : subalgebra R A) : set A) = set.univ := rfl\n\n@[simp] lemma mem_top {x : A} : x ∈ (⊤ : subalgebra R A) :=\nset.mem_univ x\n\n@[simp] lemma top_to_submodule : (⊤ : subalgebra R A).to_submodule = ⊤ := rfl\n\n@[simp] lemma top_to_subsemiring : (⊤ : subalgebra R A).to_subsemiring = ⊤ := rfl\n\n@[simp] lemma top_to_subring {R A : Type*} [comm_ring R] [ring A] [algebra R A] :\n  (⊤ : subalgebra R A).to_subring = ⊤ := rfl\n\n@[simp] lemma to_submodule_eq_top {S : subalgebra R A} : S.to_submodule = ⊤ ↔ S = ⊤ :=\nsubalgebra.to_submodule_injective.eq_iff' top_to_submodule\n\n@[simp] lemma to_subsemiring_eq_top {S : subalgebra R A} : S.to_subsemiring = ⊤ ↔ S = ⊤ :=\nsubalgebra.to_subsemiring_injective.eq_iff' top_to_subsemiring\n\n@[simp] lemma to_subring_eq_top {R A : Type*} [comm_ring R] [ring A] [algebra R A]\n  {S : subalgebra R A} : S.to_subring = ⊤ ↔ S = ⊤ :=\nsubalgebra.to_subring_injective.eq_iff' top_to_subring\n\nlemma mem_sup_left {S T : subalgebra R A} : ∀ {x : A}, x ∈ S → x ∈ S ⊔ T :=\nshow S ≤ S ⊔ T, from le_sup_left\n\nlemma mem_sup_right {S T : subalgebra R A} : ∀ {x : A}, x ∈ T → x ∈ S ⊔ T :=\nshow T ≤ S ⊔ T, from le_sup_right\n\nlemma mul_mem_sup {S T : subalgebra R A} {x y : A} (hx : x ∈ S) (hy : y ∈ T) :\n  x * y ∈ S ⊔ T :=\n(S ⊔ T).mul_mem (mem_sup_left hx) (mem_sup_right hy)\n\nlemma map_sup (f : A →ₐ[R] B) (S T : subalgebra R A) : (S ⊔ T).map f = S.map f ⊔ T.map f :=\n(subalgebra.gc_map_comap f).l_sup\n\n@[simp, norm_cast]\nlemma coe_inf (S T : subalgebra R A) : (↑(S ⊓ T) : set A) = S ∩ T := rfl\n\n@[simp]\nlemma mem_inf {S T : subalgebra R A} {x : A} : x ∈ S ⊓ T ↔ x ∈ S ∧ x ∈ T := iff.rfl\n\n@[simp] lemma inf_to_submodule (S T : subalgebra R A) :\n  (S ⊓ T).to_submodule = S.to_submodule ⊓ T.to_submodule := rfl\n\n@[simp] lemma inf_to_subsemiring (S T : subalgebra R A) :\n  (S ⊓ T).to_subsemiring = S.to_subsemiring ⊓ T.to_subsemiring := rfl\n\n@[simp, norm_cast]\nlemma coe_Inf (S : set (subalgebra R A)) : (↑(Inf S) : set A) = ⋂ s ∈ S, ↑s := Inf_image\n\nlemma mem_Inf {S : set (subalgebra R A)} {x : A} : x ∈ Inf S ↔ ∀ p ∈ S, x ∈ p :=\nby simp only [← set_like.mem_coe, coe_Inf, set.mem_Inter₂]\n\n@[simp] lemma Inf_to_submodule (S : set (subalgebra R A)) :\n  (Inf S).to_submodule = Inf (subalgebra.to_submodule '' S) :=\nset_like.coe_injective $ by simp\n\n@[simp] lemma Inf_to_subsemiring (S : set (subalgebra R A)) :\n  (Inf S).to_subsemiring = Inf (subalgebra.to_subsemiring '' S) :=\nset_like.coe_injective $ by simp\n\n@[simp, norm_cast]\nlemma coe_infi {ι : Sort*} {S : ι → subalgebra R A} : (↑(⨅ i, S i) : set A) = ⋂ i, S i :=\nby simp [infi]\n\nlemma mem_infi {ι : Sort*} {S : ι → subalgebra R A} {x : A} : (x ∈ ⨅ i, S i) ↔ ∀ i, x ∈ S i :=\nby simp only [infi, mem_Inf, set.forall_range_iff]\n\n@[simp] lemma infi_to_submodule {ι : Sort*} (S : ι → subalgebra R A) :\n  (⨅ i, S i).to_submodule = ⨅ i, (S i).to_submodule :=\nset_like.coe_injective $ by simp\n\ninstance : inhabited (subalgebra R A) := ⟨⊥⟩\n\ntheorem mem_bot {x : A} : x ∈ (⊥ : subalgebra R A) ↔ x ∈ set.range (algebra_map R A) :=\nsuffices (of_id R A).range = (⊥ : subalgebra R A),\nby { rw [← this, ←set_like.mem_coe, alg_hom.coe_range], refl },\nle_bot_iff.mp (λ x hx, subalgebra.range_le _ ((of_id R A).coe_range ▸ hx))\n\ntheorem to_submodule_bot : (⊥ : subalgebra R A).to_submodule = R ∙ 1 :=\nby { ext x, simp [mem_bot, -set.singleton_one, submodule.mem_span_singleton, algebra.smul_def] }\n\n@[simp] theorem coe_bot : ((⊥ : subalgebra R A) : set A) = set.range (algebra_map R A) :=\nby simp [set.ext_iff, algebra.mem_bot]\n\ntheorem eq_top_iff {S : subalgebra R A} :\n  S = ⊤ ↔ ∀ x : A, x ∈ S :=\n⟨λ h x, by rw h; exact mem_top, λ h, by ext x; exact ⟨λ _, mem_top, λ _, h x⟩⟩\n\n@[simp] theorem range_id : (alg_hom.id R A).range = ⊤ :=\nset_like.coe_injective set.range_id\n\n@[simp] theorem map_top (f : A →ₐ[R] B) : subalgebra.map (⊤ : subalgebra R A) f = f.range :=\nset_like.coe_injective set.image_univ\n\n@[simp] theorem map_bot (f : A →ₐ[R] B) : subalgebra.map (⊥ : subalgebra R A) f = ⊥ :=\nset_like.coe_injective $\n  by simp only [← set.range_comp, (∘), algebra.coe_bot, subalgebra.coe_map, f.commutes]\n\n@[simp] theorem comap_top (f : A →ₐ[R] B) : subalgebra.comap' (⊤ : subalgebra R B) f = ⊤ :=\neq_top_iff.2 $ λ x, mem_top\n\n/-- `alg_hom` to `⊤ : subalgebra R A`. -/\ndef to_top : A →ₐ[R] (⊤ : subalgebra R A) :=\n(alg_hom.id R A).cod_restrict ⊤ (λ _, mem_top)\n\ntheorem surjective_algebra_map_iff :\n  function.surjective (algebra_map R A) ↔ (⊤ : subalgebra R A) = ⊥ :=\n⟨λ h, eq_bot_iff.2 $ λ y _, let ⟨x, hx⟩ := h y in hx ▸ subalgebra.algebra_map_mem _ _,\nλ h y, algebra.mem_bot.1 $ eq_bot_iff.1 h (algebra.mem_top : y ∈ _)⟩\n\ntheorem bijective_algebra_map_iff {R A : Type*} [field R] [semiring A] [nontrivial A]\n  [algebra R A] :\n  function.bijective (algebra_map R A) ↔ (⊤ : subalgebra R A) = ⊥ :=\n⟨λ h, surjective_algebra_map_iff.1 h.2,\nλ h, ⟨(algebra_map R A).injective, surjective_algebra_map_iff.2 h⟩⟩\n\n/-- The bottom subalgebra is isomorphic to the base ring. -/\nnoncomputable def bot_equiv_of_injective (h : function.injective (algebra_map R A)) :\n  (⊥ : subalgebra R A) ≃ₐ[R] R :=\nalg_equiv.symm $ alg_equiv.of_bijective (algebra.of_id R _)\n⟨λ x y hxy, h (congr_arg subtype.val hxy : _),\n λ ⟨y, hy⟩, let ⟨x, hx⟩ := algebra.mem_bot.1 hy in ⟨x, subtype.eq hx⟩⟩\n\n/-- The bottom subalgebra is isomorphic to the field. -/\n@[simps symm_apply]\nnoncomputable def bot_equiv (F R : Type*) [field F] [semiring R] [nontrivial R] [algebra F R] :\n  (⊥ : subalgebra F R) ≃ₐ[F] F :=\nbot_equiv_of_injective (ring_hom.injective _)\n\n/-- The top subalgebra is isomorphic to the field. -/\n@[simps] def top_equiv : (⊤ : subalgebra R A) ≃ₐ[R] A :=\nalg_equiv.of_alg_hom (subalgebra.val ⊤) to_top rfl $ alg_hom.ext $ λ x, subtype.ext rfl\n\nend algebra\n\nnamespace subalgebra\nopen algebra\n\nvariables {R : Type u} {A : Type v} {B : Type w}\nvariables [comm_semiring R] [semiring A] [algebra R A] [semiring B] [algebra R B]\nvariables (S : subalgebra R A)\n\n-- TODO[gh-6025]: make this an instance once safe to do so\nlemma subsingleton_of_subsingleton [subsingleton A] : subsingleton (subalgebra R A) :=\n⟨λ B C, ext (λ x, by { simp only [subsingleton.elim x 0, zero_mem] })⟩\n\n/--\nFor performance reasons this is not an instance. If you need this instance, add\n```\nlocal attribute [instance] alg_hom.subsingleton subalgebra.subsingleton_of_subsingleton\n```\nin the section that needs it.\n-/\n-- TODO[gh-6025]: make this an instance once safe to do so\nlemma _root_.alg_hom.subsingleton [subsingleton (subalgebra R A)] : subsingleton (A →ₐ[R] B) :=\n⟨λ f g, alg_hom.ext $ λ a,\n  have a ∈ (⊥ : subalgebra R A) := subsingleton.elim (⊤ : subalgebra R A) ⊥ ▸ mem_top,\n  let ⟨x, hx⟩ := set.mem_range.mp (mem_bot.mp this) in\n  hx ▸ (f.commutes _).trans (g.commutes _).symm⟩\n\n-- TODO[gh-6025]: make this an instance once safe to do so\nlemma _root_.alg_equiv.subsingleton_left [subsingleton (subalgebra R A)] :\n  subsingleton (A ≃ₐ[R] B) :=\nbegin\n  haveI : subsingleton (A →ₐ[R] B) := alg_hom.subsingleton,\n  exact ⟨λ f g, alg_equiv.ext\n    (λ x, alg_hom.ext_iff.mp (subsingleton.elim f.to_alg_hom g.to_alg_hom) x)⟩,\nend\n\n-- TODO[gh-6025]: make this an instance once safe to do so\nlemma _root_.alg_equiv.subsingleton_right [subsingleton (subalgebra R B)] :\n  subsingleton (A ≃ₐ[R] B) :=\nbegin\n  haveI : subsingleton (B ≃ₐ[R] A) := alg_equiv.subsingleton_left,\n  exact ⟨λ f g, eq.trans (alg_equiv.symm_symm _).symm\n    (by rw [subsingleton.elim f.symm g.symm, alg_equiv.symm_symm])⟩\nend\n\nlemma range_val : S.val.range = S :=\next $ set.ext_iff.1 $ S.val.coe_range.trans subtype.range_val\n\ninstance : unique (subalgebra R R) :=\n{ uniq :=\n  begin\n    intro S,\n    refine le_antisymm (λ r hr, _) bot_le,\n    simp only [set.mem_range, mem_bot, id.map_eq_self, exists_apply_eq_apply, default],\n  end\n  .. algebra.subalgebra.inhabited }\n\n/-- The map `S → T` when `S` is a subalgebra contained in the subalgebra `T`.\n\nThis is the subalgebra version of `submodule.of_le`, or `subring.inclusion`  -/\ndef inclusion {S T : subalgebra R A} (h : S ≤ T) : S →ₐ[R] T :=\n{ to_fun := set.inclusion h,\n  map_one' := rfl,\n  map_add' := λ _ _, rfl,\n  map_mul' := λ _ _, rfl,\n  map_zero' := rfl,\n  commutes' := λ _, rfl }\n\nlemma inclusion_injective {S T : subalgebra R A} (h : S ≤ T) :\n  function.injective (inclusion h) :=\nλ _ _, subtype.ext ∘ subtype.mk.inj\n\n@[simp] lemma inclusion_self {S : subalgebra R A}:\n  inclusion (le_refl S) = alg_hom.id R S :=\nalg_hom.ext $ λ x, subtype.ext rfl\n\n@[simp] lemma inclusion_right {S T : subalgebra R A} (h : S ≤ T) (x : T)\n  (m : (x : A) ∈ S) : inclusion h ⟨x, m⟩ = x := subtype.ext rfl\n\n@[simp] lemma inclusion_inclusion {S T U : subalgebra R A} (hst : S ≤ T) (htu : T ≤ U)\n  (x : S) : inclusion htu (inclusion hst x) = inclusion (le_trans hst htu) x :=\nsubtype.ext rfl\n\n@[simp] lemma coe_inclusion {S T : subalgebra R A} (h : S ≤ T) (s : S) :\n  (inclusion h s : A) = s := rfl\n\n/-- Two subalgebras that are equal are also equivalent as algebras.\n\nThis is the `subalgebra` version of `linear_equiv.of_eq` and `equiv.set.of_eq`. -/\n@[simps apply]\ndef equiv_of_eq (S T : subalgebra R A) (h : S = T) : S ≃ₐ[R] T :=\n{ to_fun := λ x, ⟨x, h ▸ x.2⟩,\n  inv_fun := λ x, ⟨x, h.symm ▸ x.2⟩,\n  map_mul' := λ _ _, rfl,\n  commutes' := λ _, rfl,\n  .. linear_equiv.of_eq _ _ (congr_arg to_submodule h) }\n\n@[simp] lemma equiv_of_eq_symm (S T : subalgebra R A) (h : S = T) :\n  (equiv_of_eq S T h).symm = equiv_of_eq T S h.symm :=\nrfl\n\n@[simp] lemma equiv_of_eq_rfl (S : subalgebra R A) :\n  equiv_of_eq S S rfl = alg_equiv.refl :=\nby { ext, refl }\n\n@[simp] lemma equiv_of_eq_trans (S T U : subalgebra R A) (hST : S = T) (hTU : T = U) :\n  (equiv_of_eq S T hST).trans (equiv_of_eq T U hTU) = equiv_of_eq S U (trans hST hTU) :=\nrfl\n\nsection prod\n\nvariables (S₁ : subalgebra R B)\n\n/-- The product of two subalgebras is a subalgebra. -/\ndef prod : subalgebra R (A × B) :=\n{ carrier := (S : set A) ×ˢ (S₁ : set B),\n  algebra_map_mem' := λ r, ⟨algebra_map_mem _ _, algebra_map_mem _ _⟩,\n  .. S.to_subsemiring.prod S₁.to_subsemiring }\n\n@[simp] lemma coe_prod :\n  (prod S S₁ : set (A × B)) = (S : set A) ×ˢ (S₁ : set B):= rfl\n\nlemma prod_to_submodule :\n  (S.prod S₁).to_submodule = S.to_submodule.prod S₁.to_submodule := rfl\n\n@[simp] lemma mem_prod {S : subalgebra R A} {S₁ : subalgebra R B} {x : A × B} :\n  x ∈ prod S S₁ ↔ x.1 ∈ S ∧ x.2 ∈ S₁ := set.mem_prod\n\n@[simp] lemma prod_top : (prod ⊤ ⊤ : subalgebra R (A × B)) = ⊤ :=\nby ext; simp\n\nlemma prod_mono {S T : subalgebra R A} {S₁ T₁ : subalgebra R B} :\n  S ≤ T → S₁ ≤ T₁ → prod S S₁ ≤ prod T T₁ := set.prod_mono\n\n@[simp] lemma prod_inf_prod {S T : subalgebra R A} {S₁ T₁ : subalgebra R B} :\n  S.prod S₁ ⊓ T.prod T₁ = (S ⊓ T).prod (S₁ ⊓ T₁) :=\nset_like.coe_injective set.prod_inter_prod\n\nend prod\n\nsection supr_lift\nvariables {ι : Type*}\n\nlemma coe_supr_of_directed [nonempty ι] {S : ι → subalgebra R A}\n  (dir : directed (≤) S) : ↑(supr S) = ⋃ i, (S i : set A) :=\nlet K : subalgebra R A :=\n  { carrier := ⋃ i, (S i),\n    mul_mem' := λ x y hx hy,\n      let ⟨i, hi⟩ := set.mem_Union.1 hx in\n      let ⟨j, hj⟩ := set.mem_Union.1 hy in\n      let ⟨k, hik, hjk⟩ := dir i j in\n      set.mem_Union.2 ⟨k, subalgebra.mul_mem (S k) (hik hi) (hjk hj)⟩ ,\n    add_mem' := λ x y hx hy,\n      let ⟨i, hi⟩ := set.mem_Union.1 hx in\n      let ⟨j, hj⟩ := set.mem_Union.1 hy in\n      let ⟨k, hik, hjk⟩ := dir i j in\n      set.mem_Union.2 ⟨k, subalgebra.add_mem (S k) (hik hi) (hjk hj)⟩,\n    algebra_map_mem' := λ r, let i := @nonempty.some ι infer_instance in\n      set.mem_Union.2 ⟨i, subalgebra.algebra_map_mem _ _⟩ } in\nhave supr S = K,\n  from le_antisymm (supr_le (λ i, set.subset_Union (λ i, ↑(S i)) i))\n    (set_like.coe_subset_coe.1\n      (set.Union_subset (λ i, set_like.coe_subset_coe.2 (le_supr _ _)))),\nthis.symm ▸ rfl\n\n/-- Define an algebra homomorphism on a directed supremum of subalgebras by defining\nit on each subalgebra, and proving that it agrees on the intersection of subalgebras. -/\nnoncomputable def supr_lift [nonempty ι]\n  (K : ι → subalgebra R A)\n  (dir : directed (≤) K)\n  (f : Π i, K i →ₐ[R] B)\n  (hf : ∀ (i j : ι) (h : K i ≤ K j), f i = (f j).comp (inclusion h))\n  (T : subalgebra R A) (hT : T = supr K) :\n  ↥T →ₐ[R] B :=\nby subst hT; exact\n{ to_fun := set.Union_lift (λ i, ↑(K i)) (λ i x, f i x)\n    (λ i j x hxi hxj,\n      let ⟨k, hik, hjk⟩ := dir i j in\n      begin\n        rw [hf i k hik, hf j k hjk],\n        refl\n      end) ↑(supr K)\n    (by rw coe_supr_of_directed dir; refl),\n  map_one' := set.Union_lift_const _ (λ _, 1) (λ _, rfl) _ (by simp),\n  map_zero' := set.Union_lift_const _ (λ _, 0) (λ _, rfl) _ (by simp),\n  map_mul' := set.Union_lift_binary (coe_supr_of_directed dir) dir _\n    (λ _, (*)) (λ _ _ _, rfl) _ (by simp),\n  map_add' := set.Union_lift_binary (coe_supr_of_directed dir) dir _\n    (λ _, (+)) (λ _ _ _, rfl) _ (by simp),\n  commutes' := λ r, set.Union_lift_const _ (λ _, algebra_map _ _ r)\n    (λ _, rfl) _ (λ i, by erw [alg_hom.commutes (f i)]) }\n\nvariables [nonempty ι] {K : ι → subalgebra R A} {dir : directed (≤) K}\n  {f : Π i, K i →ₐ[R] B}\n  {hf : ∀ (i j : ι) (h : K i ≤ K j), f i = (f j).comp (inclusion h)}\n  {T : subalgebra R A} {hT : T = supr K}\n\n@[simp] lemma supr_lift_inclusion {i : ι} (x : K i) (h : K i ≤ T) :\n  supr_lift K dir f hf T hT (inclusion h x) = f i x :=\nby subst T; exact set.Union_lift_inclusion _ _\n\n@[simp] lemma supr_lift_comp_inclusion {i : ι} (h : K i ≤ T) :\n  (supr_lift K dir f hf T hT).comp (inclusion h) = f i :=\nby ext; simp\n\n@[simp] lemma supr_lift_mk {i : ι} (x : K i) (hx : (x : A) ∈ T) :\n  supr_lift K dir f hf T hT ⟨x, hx⟩ = f i x :=\nby subst hT; exact set.Union_lift_mk x hx\n\nlemma supr_lift_of_mem {i : ι} (x : T) (hx : (x : A) ∈ K i) :\n  supr_lift K dir f hf T hT x = f i ⟨x, hx⟩ :=\nby subst hT; exact set.Union_lift_of_mem x hx\n\nend supr_lift\n\n/-! ## Actions by `subalgebra`s\n\nThese are just copies of the definitions about `subsemiring` starting from\n`subring.mul_action`.\n-/\nsection actions\n\nvariables {α β : Type*}\n\n/-- The action by a subalgebra is the action by the underlying ring. -/\ninstance [mul_action A α] (S : subalgebra R A) : mul_action S α :=\nS.to_subsemiring.mul_action\n\nlemma smul_def [mul_action A α] {S : subalgebra R A} (g : S) (m : α) : g • m = (g : A) • m := rfl\n\ninstance smul_comm_class_left\n  [mul_action A β] [has_scalar α β] [smul_comm_class A α β] (S : subalgebra R A) :\n  smul_comm_class S α β :=\nS.to_subsemiring.smul_comm_class_left\n\ninstance smul_comm_class_right\n  [has_scalar α β] [mul_action A β] [smul_comm_class α A β] (S : subalgebra R A) :\n  smul_comm_class α S β :=\nS.to_subsemiring.smul_comm_class_right\n\n/-- Note that this provides `is_scalar_tower S R R` which is needed by `smul_mul_assoc`. -/\ninstance is_scalar_tower_left\n  [has_scalar α β] [mul_action A α] [mul_action A β] [is_scalar_tower A α β] (S : subalgebra R A) :\n  is_scalar_tower S α β :=\nS.to_subsemiring.is_scalar_tower\n\ninstance [mul_action A α] [has_faithful_scalar A α] (S : subalgebra R A) :\n  has_faithful_scalar S α :=\nS.to_subsemiring.has_faithful_scalar\n\n/-- The action by a subalgebra is the action by the underlying algebra. -/\ninstance [add_monoid α] [distrib_mul_action A α] (S : subalgebra R A) : distrib_mul_action S α :=\nS.to_subsemiring.distrib_mul_action\n\n/-- The action by a subalgebra is the action by the underlying algebra. -/\ninstance module_left [add_comm_monoid α] [module A α] (S : subalgebra R A) : module S α :=\nS.to_subsemiring.module\n\n/-- The action by a subalgebra is the action by the underlying algebra. -/\ninstance to_algebra {R A : Type*} [comm_semiring R] [comm_semiring A] [semiring α]\n  [algebra R A] [algebra A α] (S : subalgebra R A) : algebra S α :=\nalgebra.of_subsemiring S.to_subsemiring\n\nlemma algebra_map_eq {R A : Type*} [comm_semiring R] [comm_semiring A] [semiring α]\n  [algebra R A] [algebra A α] (S : subalgebra R A) :\n  algebra_map S α = (algebra_map A α).comp S.val := rfl\n\n@[simp] lemma srange_algebra_map {R A : Type*} [comm_semiring R] [comm_semiring A]\n  [algebra R A] (S : subalgebra R A) :\n  (algebra_map S A).srange = S.to_subsemiring :=\nby rw [algebra_map_eq, algebra.id.map_eq_id, ring_hom.id_comp, ← to_subsemiring_subtype,\n       subsemiring.srange_subtype]\n\n@[simp] lemma range_algebra_map {R A : Type*} [comm_ring R] [comm_ring A]\n  [algebra R A] (S : subalgebra R A) :\n  (algebra_map S A).range = S.to_subring :=\nby rw [algebra_map_eq, algebra.id.map_eq_id, ring_hom.id_comp, ← to_subring_subtype,\n       subring.range_subtype]\n\ninstance no_zero_smul_divisors_top [no_zero_divisors A] (S : subalgebra R A) :\n  no_zero_smul_divisors S A :=\n⟨λ c x h,\n  have (c : A) = 0 ∨ x = 0,\n  from eq_zero_or_eq_zero_of_mul_eq_zero h,\n  this.imp_left (@subtype.ext_iff _ _ c 0).mpr⟩\n\nend actions\n\nsection pointwise\nvariables {R' : Type*} [semiring R'] [mul_semiring_action R' A] [smul_comm_class R' R A]\n\n/-- The action on a subalgebra corresponding to applying the action to every element.\n\nThis is available as an instance in the `pointwise` locale. -/\nprotected def pointwise_mul_action : mul_action R' (subalgebra R A) :=\n{ smul := λ a S, S.map (mul_semiring_action.to_alg_hom _ _ a),\n  one_smul := λ S,\n    (congr_arg (λ f, S.map f) (alg_hom.ext $ by exact one_smul R')).trans S.map_id,\n  mul_smul := λ a₁ a₂ S,\n    (congr_arg (λ f, S.map f) (alg_hom.ext $ by exact mul_smul _ _)).trans (S.map_map _ _).symm }\n\nlocalized \"attribute [instance] subalgebra.pointwise_mul_action\" in pointwise\nopen_locale pointwise\n\n@[simp] lemma coe_pointwise_smul (m : R') (S : subalgebra R A) : ↑(m • S) = m • (S : set A) := rfl\n\n@[simp] lemma pointwise_smul_to_subsemiring (m : R') (S : subalgebra R A) :\n  (m • S).to_subsemiring = m • S.to_subsemiring := rfl\n\n@[simp] lemma pointwise_smul_to_submodule (m : R') (S : subalgebra R A) :\n  (m • S).to_submodule = m • S.to_submodule := rfl\n\n@[simp] lemma pointwise_smul_to_subring {R' R A : Type*} [semiring R'] [comm_ring R] [ring A]\n  [mul_semiring_action R' A] [algebra R A] [smul_comm_class R' R A] (m : R') (S : subalgebra R A) :\n  (m • S).to_subring = m • S.to_subring := rfl\n\nlemma smul_mem_pointwise_smul (m : R') (r : A) (S : subalgebra R A) : r ∈ S → m • r ∈ m • S :=\n(set.smul_mem_smul_set : _ → _ ∈ m • (S : set A))\n\nend pointwise\n\nsection center\n\nlemma _root_.set.algebra_map_mem_center (r : R) : algebra_map R A r ∈ set.center A :=\nby simp [algebra.commutes, set.mem_center_iff]\n\nvariables (R A)\n\n/-- The center of an algebra is the set of elements which commute with every element. They form a\nsubalgebra. -/\ndef center : subalgebra R A :=\n{ algebra_map_mem' := set.algebra_map_mem_center,\n  .. subsemiring.center A }\n\nlemma coe_center : (center R A : set A) = set.center A := rfl\n\n@[simp] lemma center_to_subsemiring :\n  (center R A).to_subsemiring = subsemiring.center A :=\nrfl\n\n@[simp] lemma center_to_subring (R A : Type*) [comm_ring R] [ring A] [algebra R A] :\n  (center R A).to_subring = subring.center A :=\nrfl\n\n@[simp] lemma center_eq_top (A : Type*) [comm_semiring A] [algebra R A] : center R A = ⊤ :=\nset_like.coe_injective (set.center_eq_univ A)\n\nvariables {R A}\n\ninstance : comm_semiring (center R A) := subsemiring.center.comm_semiring\n\ninstance {A : Type*} [ring A] [algebra R A] : comm_ring (center R A) := subring.center.comm_ring\n\nlemma mem_center_iff {a : A} : a ∈ center R A ↔ ∀ (b : A), b*a = a*b := iff.rfl\n\nend center\n\nend subalgebra\n\nsection nat\n\nvariables {R : Type*} [semiring R]\n\n/-- A subsemiring is a `ℕ`-subalgebra. -/\ndef subalgebra_of_subsemiring (S : subsemiring R) : subalgebra ℕ R :=\n{ algebra_map_mem' := λ i, S.coe_nat_mem i,\n  .. S }\n\n@[simp] lemma mem_subalgebra_of_subsemiring {x : R} {S : subsemiring R} :\n  x ∈ subalgebra_of_subsemiring S ↔ x ∈ S :=\niff.rfl\n\nend nat\n\nsection int\n\nvariables {R : Type*} [ring R]\n\n/-- A subring is a `ℤ`-subalgebra. -/\ndef subalgebra_of_subring (S : subring R) : subalgebra ℤ R :=\n{ algebra_map_mem' := λ i, int.induction_on i S.zero_mem\n  (λ i ih, S.add_mem ih S.one_mem)\n  (λ i ih, show ((-i - 1 : ℤ) : R) ∈ S, by { rw [int.cast_sub, int.cast_one],\n    exact S.sub_mem ih S.one_mem }),\n  .. S }\n\nvariables {S : Type*} [semiring S]\n\n@[simp] lemma mem_subalgebra_of_subring {x : R} {S : subring R} :\n  x ∈ subalgebra_of_subring S ↔ x ∈ S :=\niff.rfl\n\nend int\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebra/algebra/subalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.48313378492604947}}
{"text": "/-\n    A faster, computable version of matrices implemented entirely in terms of d_array, \n    trying to rely on fast pre-existing array and d_array functions as much as possible.\n\n    A slightly more \"serious\" version of fast_matrix (?)\n\n    Still a WIP.\n\n    The second half of the document is a bit of a mess.\n-/\n\nimport data.vector\nimport data.list.basic\nimport .matrices\n\nuniverses u v\n\ndef computable_d_matrix (m n : ℕ) (α : fin m → fin n → Type u) := d_array m (λ j, d_array n (α j))\n\nnamespace computable_d_matrix\n    variables {m n : ℕ} {α : fin m → fin n → Type u} {β : Type v}\n    def nil {α} : computable_d_matrix 0 0 α := \n    ⟨λ i, absurd (fin.is_lt i) (nat.not_lt_zero (fin.val i))⟩\n\n    def read (a : computable_d_matrix m n α) (i : fin m) (j : fin n) : α i j :=\n    d_array.read (d_array.read a i) j\n\n    def read_row (a : computable_d_matrix m n α) (i : fin m) : d_array n (α i) :=\n    d_array.read a i\n    \n    def read_col (a : computable_d_matrix m n α) (j : fin n) : d_array m (λ i, α i j) :=\n    ⟨λ i, d_array.read (d_array.read a i) j⟩\n\n    def transpose (a : computable_d_matrix m n α) : computable_d_matrix n m (λ (j : fin n) (i : fin m), α i j) :=\n    ⟨λ j, ⟨λ i, a.read i j⟩⟩ -- TODO: This can probably be optimised\n\n    def write (a : computable_d_matrix m n α) (i : fin m) (j : fin n) (v : α i j) : computable_d_matrix m n α :=\n    d_array.write a i (d_array.write (d_array.read a i) j v)\n\n    def write_row (a : computable_d_matrix m n α) (i : fin m) (v : d_array n (α i)) : computable_d_matrix m n α :=\n    d_array.write a i v\n    \n    def write_col (a : computable_d_matrix m n α) (j : fin n) (v : d_array m (λ i, α i j)) : computable_d_matrix m n α :=\n    transpose (d_array.write (transpose a) j v) -- TODO: This can probably be optimised, by not relying on transpose\n\n    def iterate (a : computable_d_matrix m n α) (b : β) (f : Π (i : fin m) (j : fin n), α i j → β → β) : β :=\n    d_array.iterate a b (λ i arr state, d_array.iterate arr state (λ j, f i j))            \n\n    def iterate_row (a : computable_d_matrix m n α) (b : β) (f : Π (i : fin m), (d_array n (α i)) → β → β) : β :=\n    d_array.iterate a b f\n\n    def iterate_col (a : computable_d_matrix m n α) (b : β) (f : Π (j : fin n), d_array m (λ i, α i j) → β → β) : β :=\n    d_array.iterate (transpose a) b f -- TODO: this can probably be optimised, by not relying on transpose\n\n    def foreach (a : computable_d_matrix m n α) (f : Π (i : fin m) (j : fin n), α i j → α i j) : computable_d_matrix m n α :=\n    iterate a a $ λ i j v a', a'.write i j (f i j v)\n\n    def map (f : Π (i : fin m) (j : fin n), α i j → α i j) (a : computable_d_matrix m n α) : computable_d_matrix m n α :=\n    foreach a f\n\n    def map₂ (f : Π (i : fin m) (j : fin n), α i j → α i j → α i j) (a b : computable_d_matrix m n α) : computable_d_matrix m n α :=\n    foreach b (λ i j, f i j (a.read i j))\n\n    def foldl (a : computable_d_matrix m n α) (b : β) (f : Π (i : fin m) (j : fin n), α i j → β → β) : β :=\n    iterate a b f\n\n    @[simp] lemma read_write (a : computable_d_matrix m n α) (i : fin m) (j : fin n) (v : α i j) : read (write a i j v) i j = v :=\n    by simp [read, write]\n\n    @[simp] lemma read_write_row (a : computable_d_matrix m n α) (i : fin m) (v : d_array n (α i)) : read_row (write_row a i v) i = v :=\n    by simp [read_row, write_row]\n\n    -- TODO: This one\n    -- @[simp] lemma read_write_col (a : computable_d_matrix m n α) (j : fin n) (v : d_array m (λ i, α i j)) : read_col (write_col a j v) j = v :=\n    -- by simp [read_col, write_col, transpose, d_array.write, d_array.read, read, write, read_row, write_row]\n\n    @[simp] lemma read_write_of_ne (a : computable_d_matrix m n α) {i j : fin m} {k l : fin n} (v : α i k) : i ≠ j → k ≠ l → (read (write a i k v) j l) = (read a j l):=\n    by intros h₁ h₂; simp [read, write, h₁, h₂]\n\n    protected lemma ext {a b : computable_d_matrix m n α} (h : ∀ i j, read a i j = read b i j) : a = b :=\n    by cases a; cases b; congr; funext i; exact d_array.ext (h i)\n\n    protected lemma ext' {a b : computable_d_matrix m n α} (h : ∀ (i j : nat) (h₁ : i < m) (h₂ : j < n), read a ⟨i, h₁⟩ ⟨j, h₂⟩ = read b ⟨i, h₁⟩ ⟨j, h₂⟩) : a = b :=\n    begin   -- TODO: Clean this up\n    cases a,\n    cases b,\n    congr,\n    funext i,\n    apply d_array.ext,\n    intros j,\n    have hi : i = ⟨i.val, (fin.is_lt i)⟩, by simp,\n    have hj : j = ⟨j.val, (fin.is_lt j)⟩, by simp,\n    rw hi,\n    rw hj,\n    from (h (fin.val i) (fin.val j) (fin.is_lt i) (fin.is_lt j)),\n    end\n\n    protected def beq_aux [∀ i j, decidable_eq (α i j)] (a b : computable_d_matrix m n α) : Π (i : nat), i ≤ m → bool :=\n    @d_array.beq_aux _ _ _ a b\n\n    protected def beq [∀ i j, decidable_eq (α i j)] (a b : computable_d_matrix m n α) : bool :=\n    @d_array.beq_aux _ _ _ a b _ (le_refl m)\n\n    instance [∀ i j, decidable_eq (α i j)] : decidable_eq (computable_d_matrix m n α) :=\n    d_array.decidable_eq\n\nend computable_d_matrix\n\ndef computable_matrix (m n : ℕ) (α : Type u) := computable_d_matrix m n (λ i j, α)\n\nnamespace computable_matrix\n    variables {m n : nat} {α : Type u} {β : Type v}\n    def nil : computable_matrix 0 0 α :=\n    computable_d_matrix.nil\n\n    def read (a : computable_matrix m n α) (i : fin m) (j : fin n) : α :=\n    computable_d_matrix.read a i j\n\n    def read_row (a : computable_matrix m n α) (i : fin m) : array n α :=\n    computable_d_matrix.read_row a i\n\n    def read_col (a : computable_matrix m n α) (j : fin n) : array m α :=\n    computable_d_matrix.read_col a j\n\n    def transpose (a : computable_matrix m n α) : computable_matrix n m α :=\n    computable_d_matrix.transpose a\n\n    def write (a : computable_matrix m n α) (i : fin m) (j : fin n) (v : α) : computable_matrix m n α :=\n    computable_d_matrix.write a i j v\n\n    def write_row (a : computable_matrix m n α) (i : fin m) (v : array n α) : computable_matrix m n α :=\n    computable_d_matrix.write_row a i v\n\n    def write_col (a : computable_matrix m n α) (j : fin n) (v : array m α) : computable_matrix m n α :=\n    computable_d_matrix.write_col a j v\n\n    def iterate_row (a : computable_matrix m n α) (b : β) (f : fin m → array n α → β → β) : β :=\n    computable_d_matrix.iterate_row a b (λ i V₁, f i ⟨V₁.data⟩)\n\n    def iterate_col (a : computable_matrix m n α) (b : β) (f : fin n → array m α → β → β) : β :=\n    computable_d_matrix.iterate_col a b (λ i V₁, f i ⟨V₁.data⟩)\n\n    def iterate (a : computable_matrix m n α) (b : β) (f : fin m → fin n → α → β → β) : β :=\n    computable_d_matrix.iterate a b (λ i j v, f i j v)\n\n    def foreach (a : computable_matrix m n α) (f : fin m → fin n → α → α) : computable_matrix m n α :=\n    iterate a a (λ i j v a', a'.write i j (f i j v))\n\n    def map (f : α → α) (a : computable_matrix m n α) : computable_matrix m n α :=\n    foreach a (λ _ _, f)\n\n    def map₂ (f : α → α → α) (a b : computable_matrix m n α) : computable_matrix m n α :=\n    foreach b (λ i j, f (a.read i j))\n\n    def foldl_row (a : computable_matrix m n α) (b : β) (f : (array n α) → β → β) : β :=\n    iterate_row a b (λ _, f)\n\n    def foldl_col (a : computable_matrix m n α) (b : β) (f : (array m α) → β → β) : β :=\n    iterate_col a b (λ _, f)\n\n    def rev_list_row (a : computable_matrix m n α) : list (array n α) :=\n    a.foldl_row [] (::)\n\n    def rev_list_col (a : computable_matrix m n α) : list (array m α) :=\n    a.foldl_col [] (::)\n\n    @[simp] lemma read_write (a : computable_matrix m n α) (i : fin m) (j : fin n) (v : α) : read (write a i j v) i j = v :=\n    by simp [read, write]\n\n    @[simp] lemma read_write_of_ne (a : computable_matrix m n α) {i j : fin m} {k l : fin n} (v : α) : i ≠ j → k ≠ l → (read (write a i k v) j l) = (read a j l):=\n    by intros h₁ h₂; simp [read, write, h₁, h₂]\n\n    protected lemma ext {a b : computable_matrix m n α} (h : ∀ i j, read a i j = read b i j) : a = b :=\n    by cases a; cases b; congr; funext i; exact array.ext (h i)\n\n    protected lemma ext' {a b : computable_matrix m n α} (h : ∀ (i j : nat) (h₁ : i < m) (h₂ : j < n), read a ⟨i, h₁⟩ ⟨j, h₂⟩ = read b ⟨i, h₁⟩ ⟨j, h₂⟩) : a = b :=\n    begin   -- TODO: Golf this one\n    cases a,\n    cases b,\n    congr,\n    funext i,\n    apply array.ext,\n    intros j,\n    have hi : i = ⟨i.val, (fin.is_lt i)⟩, by simp,\n    have hj : j = ⟨j.val, (fin.is_lt j)⟩, by simp,\n    rw hi,\n    rw hj,\n    from (h (fin.val i) (fin.val j) (fin.is_lt i) (fin.is_lt j)),\n    end\n\n    protected def beq [decidable_eq α] (a b : computable_matrix m n α) : bool :=\n    @computable_d_matrix.beq m n (λ i j, α) _ a b\n\n    instance [decidable_eq α] : decidable_eq (computable_matrix m n α) :=\n    computable_d_matrix.decidable_eq\n\n    def to_list (a : computable_matrix m n α) : list (list (α)) :=\n    iterate_row a [] (λ i v b, list.concat b (array.to_list v))\n\n    instance repr [has_repr α] : has_repr (computable_matrix m n α) :=\n    ⟨λ a, list.repr (to_list a)⟩\n\n    -- Matrix row operations. Not sure if it's actually worth having these implemented like this here.\n\n    def exchange_rows (a : computable_matrix m n α) (i₁ i₂ : fin m) : computable_matrix m n α :=\n    ⟨λ i, if h₁ : i₁ = i then eq.rec_on h₁ (a.read_row i₂) else if h₂ : i₂ = i then eq.rec_on h₂ (a.read_row i₁) else a.read_row i⟩\n\n    def exchange_cols (a : computable_matrix m n α) (j₁ j₂ : fin n) : computable_matrix m n α :=\n    (computable_matrix.exchange_rows (a.transpose) j₁ j₂).transpose -- TODO: Can probably be optimised without transpose\n\n    def add_multiple_of_row_to_row (a : computable_matrix m n α) [has_add α] [has_mul α] (i₁ : fin m) (s : α) (i₂ : fin m) : computable_matrix m n α :=\n    computable_matrix.write_row a i₁ (array.map₂ (has_add.add) (a.read_row i₁) (array.map (has_mul.mul s) (a.read_row i₂)))\n\n    def add_multiple_of_col_to_col (a : computable_matrix m n α) [has_add α] [has_mul α] (j₁ : fin n) (s : α) (j₂ : fin n) : computable_matrix m n α :=\n    (add_multiple_of_row_to_row (a.transpose) j₁ s j₂).transpose -- TODO: Can probably be optimised without transpose\n\nend computable_matrix\n\n\n-- A number of these coercions are probably completely unncessary. \n-- I think I probably went more than a bit overboard. Will probably remove some later.\n\ndef array_of_vector {α : Type u} {n : ℕ} : vector α n → array n α :=\nλ v, ⟨λ i, vector.nth v i⟩\n\ninstance coe_array_of_vector {α : Type u} {n : ℕ} : has_coe (vector α n) (array n α) :=\n⟨array_of_vector⟩\n\ndef vector_of_array {α : Type u} {n : ℕ} : array n α → vector α n :=\n λ a, ⟨list.reverse (array.to_list a), by simp ⟩\n\ninstance coe_vector_of_array {α : Type u} {n : ℕ} : has_coe (array n α) (vector α n) :=\n⟨vector_of_array⟩ \n\n-- TODO: These coes are unrelated and probably shouldn't be here.\ninstance coe_matrix_of_array_of_array {α : Type u} {m n : ℕ} : has_coe (array m (array n α)) (computable_matrix m n α) :=\n⟨λ M, M⟩\n\ninstance coe_distributes_over_list {α β : Type u} [has_coe α β] : has_coe (list α) (list β) :=\n⟨λ l, l.map coe⟩\n\ninstance coe_distributes_over_array {α β : Type u} {n : ℕ} [has_coe α β] : has_coe (array n α) (array n β) :=\n⟨λ a, ⟨λ i, a.read i⟩⟩\n\ninstance coe_distributes_over_vector {α β : Type u} {n : ℕ} [has_coe α β] : has_coe (vector α n) (vector β n) :=\n⟨λv, v.map coe⟩\n-----------------------------------------------------------------\n\ninstance coe_matrix_of_vector_of_vector {α : Type u} {m n : ℕ} : has_coe (vector (vector α n) m) (computable_matrix m n α) :=\nbegin\n    constructor,\n    intros M,\n    unfold computable_matrix,\n    unfold computable_d_matrix,\n    apply coe_array_of_vector.coe,\n    apply coe_distributes_over_vector.coe, \n    from M, \n    from coe_array_of_vector,\nend -- Todo: Golf this\n\ninstance coe_distributes_over_computable_matrix {m n : ℕ} {α β : Type u} [has_coe α β] : has_coe (computable_matrix m n α) (computable_matrix m n β) :=\n⟨λ M, ⟨λ i, ⟨λ j, M.read i j⟩⟩⟩\n\n-- Notation\n\ndef array.mk {α : Type*} {n : ℕ} (l : list α) (pr : l.length = n) : array n α :=\narray_of_vector ⟨l, pr⟩\n\nnotation `![` l:(foldr `, ` (h t, list.cons h t) list.nil `]`) :=\n  array.mk l (refl _)\n\ndef test1 : computable_matrix 2 3 ℤ := -- Just like our old friend fast_matrix!\n![![ 1 , 1,  5 ], \n  ![ 0 , 1, 2 ]]\n\n#eval test1 -- Reads the right value!\n\n\n\n\n", "meta": {"author": "semorrison", "repo": "kbb", "sha": "229bd06e840bc7a7438b8fee6802a4f8024419e3", "save_path": "github-repos/lean/semorrison-kbb", "path": "github-repos/lean/semorrison-kbb/kbb-229bd06e840bc7a7438b8fee6802a4f8024419e3/src/computable_matrix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4831337842599357}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.full_subcategory\n! leanprover-community/mathlib commit f47581155c818e6361af4e4fda60d27d020c226b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Creates\n\n/-!\n# Limits in full subcategories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe introduce the notion of a property closed under taking limits and show that if `P` is closed\nunder taking limits, then limits in `full_subcategory P` can be constructed from limits in `C`.\nMore precisely, the inclusion creates such limits.\n\n-/\n\n\nnoncomputable section\n\nuniverse w' w v u\n\nopen CategoryTheory\n\nnamespace CategoryTheory.Limits\n\n#print CategoryTheory.Limits.ClosedUnderLimitsOfShape /-\n/-- We say that a property is closed under limits of shape `J` if whenever all objects in a\n    `J`-shaped diagram have the property, any limit of this diagram also has the property. -/\ndef ClosedUnderLimitsOfShape {C : Type u} [Category.{v} C] (J : Type w) [Category.{w'} J]\n    (P : C → Prop) : Prop :=\n  ∀ ⦃F : J ⥤ C⦄ ⦃c : Cone F⦄ (hc : IsLimit c), (∀ j, P (F.obj j)) → P c.pt\n#align category_theory.limits.closed_under_limits_of_shape CategoryTheory.Limits.ClosedUnderLimitsOfShape\n-/\n\n#print CategoryTheory.Limits.ClosedUnderColimitsOfShape /-\n/-- We say that a property is closed under colimits of shape `J` if whenever all objects in a\n    `J`-shaped diagram have the property, any colimit of this diagram also has the property. -/\ndef ClosedUnderColimitsOfShape {C : Type u} [Category.{v} C] (J : Type w) [Category.{w'} J]\n    (P : C → Prop) : Prop :=\n  ∀ ⦃F : J ⥤ C⦄ ⦃c : Cocone F⦄ (hc : IsColimit c), (∀ j, P (F.obj j)) → P c.pt\n#align category_theory.limits.closed_under_colimits_of_shape CategoryTheory.Limits.ClosedUnderColimitsOfShape\n-/\n\nsection\n\nvariable {C : Type u} [Category.{v} C] {J : Type w} [Category.{w'} J] {P : C → Prop}\n\n/- warning: category_theory.limits.closed_under_limits_of_shape.limit -> CategoryTheory.Limits.ClosedUnderLimitsOfShape.limit is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u3, u4} C] {J : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} J] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_1 J _inst_2 P) -> (forall {F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_2 C _inst_1} [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F], (forall (j : J), P (CategoryTheory.Functor.obj.{u1, u3, u2, u4} J _inst_2 C _inst_1 F j)) -> (P (CategoryTheory.Limits.limit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F _inst_3)))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u3, u4} C] {J : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} J] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_1 J _inst_2 P) -> (forall {F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_2 C _inst_1} [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F], (forall (j : J), P (Prefunctor.obj.{succ u1, succ u3, u2, u4} J (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} J (CategoryTheory.Category.toCategoryStruct.{u1, u2} J _inst_2)) C (CategoryTheory.CategoryStruct.toQuiver.{u3, u4} C (CategoryTheory.Category.toCategoryStruct.{u3, u4} C _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u3, u2, u4} J _inst_2 C _inst_1 F) j)) -> (P (CategoryTheory.Limits.limit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F _inst_3)))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.closed_under_limits_of_shape.limit CategoryTheory.Limits.ClosedUnderLimitsOfShape.limitₓ'. -/\ntheorem ClosedUnderLimitsOfShape.limit (h : ClosedUnderLimitsOfShape J P) {F : J ⥤ C} [HasLimit F] :\n    (∀ j, P (F.obj j)) → P (limit F) :=\n  h (limit.isLimit _)\n#align category_theory.limits.closed_under_limits_of_shape.limit CategoryTheory.Limits.ClosedUnderLimitsOfShape.limit\n\n/- warning: category_theory.limits.closed_under_colimits_of_shape.colimit -> CategoryTheory.Limits.ClosedUnderColimitsOfShape.colimit is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u3, u4} C] {J : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} J] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_1 J _inst_2 P) -> (forall {F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_2 C _inst_1} [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F], (forall (j : J), P (CategoryTheory.Functor.obj.{u1, u3, u2, u4} J _inst_2 C _inst_1 F j)) -> (P (CategoryTheory.Limits.colimit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F _inst_3)))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u3, u4} C] {J : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} J] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_1 J _inst_2 P) -> (forall {F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_2 C _inst_1} [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F], (forall (j : J), P (Prefunctor.obj.{succ u1, succ u3, u2, u4} J (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} J (CategoryTheory.Category.toCategoryStruct.{u1, u2} J _inst_2)) C (CategoryTheory.CategoryStruct.toQuiver.{u3, u4} C (CategoryTheory.Category.toCategoryStruct.{u3, u4} C _inst_1)) (CategoryTheory.Functor.toPrefunctor.{u1, u3, u2, u4} J _inst_2 C _inst_1 F) j)) -> (P (CategoryTheory.Limits.colimit.{u1, u2, u3, u4} J _inst_2 C _inst_1 F _inst_3)))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.closed_under_colimits_of_shape.colimit CategoryTheory.Limits.ClosedUnderColimitsOfShape.colimitₓ'. -/\ntheorem ClosedUnderColimitsOfShape.colimit (h : ClosedUnderColimitsOfShape J P) {F : J ⥤ C}\n    [HasColimit F] : (∀ j, P (F.obj j)) → P (colimit F) :=\n  h (colimit.isColimit _)\n#align category_theory.limits.closed_under_colimits_of_shape.colimit CategoryTheory.Limits.ClosedUnderColimitsOfShape.colimit\n\nend\n\nsection\n\nvariable {J : Type w} [Category.{w'} J] {C : Type u} [Category.{v} C] {P : C → Prop}\n\n/- warning: category_theory.limits.creates_limit_full_subcategory_inclusion' -> CategoryTheory.Limits.createsLimitFullSubcategoryInclusion' is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) {c : CategoryTheory.Limits.Cone.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))}, (CategoryTheory.Limits.IsLimit.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c) -> (P (CategoryTheory.Limits.Cone.pt.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c)) -> (CategoryTheory.CreatesLimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) {c : CategoryTheory.Limits.Cone.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))}, (CategoryTheory.Limits.IsLimit.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c) -> (P (CategoryTheory.Limits.Cone.pt.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c)) -> (CategoryTheory.CreatesLimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_limit_full_subcategory_inclusion' CategoryTheory.Limits.createsLimitFullSubcategoryInclusion'ₓ'. -/\n/-- If a `J`-shaped diagram in `full_subcategory P` has a limit cone in `C` whose cone point lives\n    in the full subcategory, then this defines a limit in the full subcategory. -/\ndef createsLimitFullSubcategoryInclusion' (F : J ⥤ FullSubcategory P)\n    {c : Cone (F ⋙ fullSubcategoryInclusion P)} (hc : IsLimit c) (h : P c.pt) :\n    CreatesLimit F (fullSubcategoryInclusion P) :=\n  createsLimitOfFullyFaithfulOfIso' hc ⟨_, h⟩ (Iso.refl _)\n#align category_theory.limits.creates_limit_full_subcategory_inclusion' CategoryTheory.Limits.createsLimitFullSubcategoryInclusion'\n\n/- warning: category_theory.limits.creates_limit_full_subcategory_inclusion -> CategoryTheory.Limits.createsLimitFullSubcategoryInclusion is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], (P (CategoryTheory.Limits.limit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) _inst_3)) -> (CategoryTheory.CreatesLimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], (P (CategoryTheory.Limits.limit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) _inst_3)) -> (CategoryTheory.CreatesLimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_limit_full_subcategory_inclusion CategoryTheory.Limits.createsLimitFullSubcategoryInclusionₓ'. -/\n/-- If a `J`-shaped diagram in `full_subcategory P` has a limit in `C` whose cone point lives in the\n    full subcategory, then this defines a limit in the full subcategory. -/\ndef createsLimitFullSubcategoryInclusion (F : J ⥤ FullSubcategory P)\n    [HasLimit (F ⋙ fullSubcategoryInclusion P)] (h : P (limit (F ⋙ fullSubcategoryInclusion P))) :\n    CreatesLimit F (fullSubcategoryInclusion P) :=\n  createsLimitFullSubcategoryInclusion' F (limit.isLimit _) h\n#align category_theory.limits.creates_limit_full_subcategory_inclusion CategoryTheory.Limits.createsLimitFullSubcategoryInclusion\n\n/- warning: category_theory.limits.creates_colimit_full_subcategory_inclusion' -> CategoryTheory.Limits.createsColimitFullSubcategoryInclusion' is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) {c : CategoryTheory.Limits.Cocone.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))}, (CategoryTheory.Limits.IsColimit.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c) -> (P (CategoryTheory.Limits.Cocone.pt.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c)) -> (CategoryTheory.CreatesColimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) {c : CategoryTheory.Limits.Cocone.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))}, (CategoryTheory.Limits.IsColimit.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c) -> (P (CategoryTheory.Limits.Cocone.pt.{u1, u3, u2, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) c)) -> (CategoryTheory.CreatesColimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_colimit_full_subcategory_inclusion' CategoryTheory.Limits.createsColimitFullSubcategoryInclusion'ₓ'. -/\n/-- If a `J`-shaped diagram in `full_subcategory P` has a colimit cocone in `C` whose cocone point\n    lives in the full subcategory, then this defines a colimit in the full subcategory. -/\ndef createsColimitFullSubcategoryInclusion' (F : J ⥤ FullSubcategory P)\n    {c : Cocone (F ⋙ fullSubcategoryInclusion P)} (hc : IsColimit c) (h : P c.pt) :\n    CreatesColimit F (fullSubcategoryInclusion P) :=\n  createsColimitOfFullyFaithfulOfIso' hc ⟨_, h⟩ (Iso.refl _)\n#align category_theory.limits.creates_colimit_full_subcategory_inclusion' CategoryTheory.Limits.createsColimitFullSubcategoryInclusion'\n\n/- warning: category_theory.limits.creates_colimit_full_subcategory_inclusion -> CategoryTheory.Limits.createsColimitFullSubcategoryInclusion is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], (P (CategoryTheory.Limits.colimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) _inst_3)) -> (CategoryTheory.CreatesColimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop} (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], (P (CategoryTheory.Limits.colimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P)) _inst_3)) -> (CategoryTheory.CreatesColimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_colimit_full_subcategory_inclusion CategoryTheory.Limits.createsColimitFullSubcategoryInclusionₓ'. -/\n/-- If a `J`-shaped diagram in `full_subcategory P` has a colimit in `C` whose cocone point lives in\n    the full subcategory, then this defines a colimit in the full subcategory. -/\ndef createsColimitFullSubcategoryInclusion (F : J ⥤ FullSubcategory P)\n    [HasColimit (F ⋙ fullSubcategoryInclusion P)]\n    (h : P (colimit (F ⋙ fullSubcategoryInclusion P))) :\n    CreatesColimit F (fullSubcategoryInclusion P) :=\n  createsColimitFullSubcategoryInclusion' F (colimit.isColimit _) h\n#align category_theory.limits.creates_colimit_full_subcategory_inclusion CategoryTheory.Limits.createsColimitFullSubcategoryInclusion\n\n/- warning: category_theory.limits.creates_limit_full_subcategory_inclusion_of_closed -> CategoryTheory.Limits.createsLimitFullSubcategoryInclusionOfClosed is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.CreatesLimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.CreatesLimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_limit_full_subcategory_inclusion_of_closed CategoryTheory.Limits.createsLimitFullSubcategoryInclusionOfClosedₓ'. -/\n/-- If `P` is closed under limits of shape `J`, then the inclusion creates such limits. -/\ndef createsLimitFullSubcategoryInclusionOfClosed (h : ClosedUnderLimitsOfShape J P)\n    (F : J ⥤ FullSubcategory P) [HasLimit (F ⋙ fullSubcategoryInclusion P)] :\n    CreatesLimit F (fullSubcategoryInclusion P) :=\n  createsLimitFullSubcategoryInclusion F (h.limit fun j => (F.obj j).property)\n#align category_theory.limits.creates_limit_full_subcategory_inclusion_of_closed CategoryTheory.Limits.createsLimitFullSubcategoryInclusionOfClosed\n\n/- warning: category_theory.limits.creates_limits_of_shape_full_subcategory_inclusion -> CategoryTheory.Limits.createsLimitsOfShapeFullSubcategoryInclusion is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasLimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.CreatesLimitsOfShape.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.InducedCategory.category.{u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) C _inst_2 (CategoryTheory.FullSubcategoryₓ.obj.{u3, u4} C _inst_2 P)) C _inst_2 J _inst_1 (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasLimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.CreatesLimitsOfShape.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_limits_of_shape_full_subcategory_inclusion CategoryTheory.Limits.createsLimitsOfShapeFullSubcategoryInclusionₓ'. -/\n/-- If `P` is closed under limits of shape `J`, then the inclusion creates such limits. -/\ndef createsLimitsOfShapeFullSubcategoryInclusion (h : ClosedUnderLimitsOfShape J P)\n    [HasLimitsOfShape J C] : CreatesLimitsOfShape J (fullSubcategoryInclusion P)\n    where CreatesLimit F := createsLimitFullSubcategoryInclusionOfClosed h F\n#align category_theory.limits.creates_limits_of_shape_full_subcategory_inclusion CategoryTheory.Limits.createsLimitsOfShapeFullSubcategoryInclusion\n\n/- warning: category_theory.limits.has_limit_of_closed_under_limits -> CategoryTheory.Limits.hasLimit_of_closed_under_limits is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) F)\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.Limits.HasLimit.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) F)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.has_limit_of_closed_under_limits CategoryTheory.Limits.hasLimit_of_closed_under_limitsₓ'. -/\ntheorem hasLimit_of_closed_under_limits (h : ClosedUnderLimitsOfShape J P)\n    (F : J ⥤ FullSubcategory P) [HasLimit (F ⋙ fullSubcategoryInclusion P)] : HasLimit F :=\n  have : CreatesLimit F (fullSubcategoryInclusion P) :=\n    createsLimitFullSubcategoryInclusionOfClosed h F\n  has_limit_of_created F (full_subcategory_inclusion P)\n#align category_theory.limits.has_limit_of_closed_under_limits CategoryTheory.Limits.hasLimit_of_closed_under_limits\n\n/- warning: category_theory.limits.has_limits_of_shape_of_closed_under_limits -> CategoryTheory.Limits.hasLimitsOfShape_of_closed_under_limits is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasLimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.Limits.HasLimitsOfShape.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderLimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasLimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.Limits.HasLimitsOfShape.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.has_limits_of_shape_of_closed_under_limits CategoryTheory.Limits.hasLimitsOfShape_of_closed_under_limitsₓ'. -/\ntheorem hasLimitsOfShape_of_closed_under_limits (h : ClosedUnderLimitsOfShape J P)\n    [HasLimitsOfShape J C] : HasLimitsOfShape J (FullSubcategory P) :=\n  { HasLimit := fun F => hasLimit_of_closed_under_limits h F }\n#align category_theory.limits.has_limits_of_shape_of_closed_under_limits CategoryTheory.Limits.hasLimitsOfShape_of_closed_under_limits\n\n/- warning: category_theory.limits.creates_colimit_full_subcategory_inclusion_of_closed -> CategoryTheory.Limits.createsColimitFullSubcategoryInclusionOfClosed is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.CreatesColimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.CreatesColimit.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_colimit_full_subcategory_inclusion_of_closed CategoryTheory.Limits.createsColimitFullSubcategoryInclusionOfClosedₓ'. -/\n/-- If `P` is closed under colimits of shape `J`, then the inclusion creates such colimits. -/\ndef createsColimitFullSubcategoryInclusionOfClosed (h : ClosedUnderColimitsOfShape J P)\n    (F : J ⥤ FullSubcategory P) [HasColimit (F ⋙ fullSubcategoryInclusion P)] :\n    CreatesColimit F (fullSubcategoryInclusion P) :=\n  createsColimitFullSubcategoryInclusion F (h.colimit fun j => (F.obj j).property)\n#align category_theory.limits.creates_colimit_full_subcategory_inclusion_of_closed CategoryTheory.Limits.createsColimitFullSubcategoryInclusionOfClosed\n\n/- warning: category_theory.limits.creates_colimits_of_shape_full_subcategory_inclusion -> CategoryTheory.Limits.createsColimitsOfShapeFullSubcategoryInclusion is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasColimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.CreatesColimitsOfShape.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.InducedCategory.category.{u3, u4, u4} (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) C _inst_2 (CategoryTheory.FullSubcategoryₓ.obj.{u3, u4} C _inst_2 P)) C _inst_2 J _inst_1 (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasColimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.CreatesColimitsOfShape.{u1, u2, u3, u3, u4, u4} (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 J _inst_1 (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.creates_colimits_of_shape_full_subcategory_inclusion CategoryTheory.Limits.createsColimitsOfShapeFullSubcategoryInclusionₓ'. -/\n/-- If `P` is closed under colimits of shape `J`, then the inclusion creates such colimits. -/\ndef createsColimitsOfShapeFullSubcategoryInclusion (h : ClosedUnderColimitsOfShape J P)\n    [HasColimitsOfShape J C] : CreatesColimitsOfShape J (fullSubcategoryInclusion P)\n    where CreatesColimit F := createsColimitFullSubcategoryInclusionOfClosed h F\n#align category_theory.limits.creates_colimits_of_shape_full_subcategory_inclusion CategoryTheory.Limits.createsColimitsOfShapeFullSubcategoryInclusion\n\n/- warning: category_theory.limits.has_colimit_of_closed_under_colimits -> CategoryTheory.Limits.hasColimit_of_closed_under_colimits is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) F)\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall (F : CategoryTheory.Functor.{u1, u3, u2, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P)) [_inst_3 : CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u3, u3, u2, u4, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) C _inst_2 F (CategoryTheory.fullSubcategoryInclusion.{u3, u4} C _inst_2 P))], CategoryTheory.Limits.HasColimit.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P) F)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.has_colimit_of_closed_under_colimits CategoryTheory.Limits.hasColimit_of_closed_under_colimitsₓ'. -/\ntheorem hasColimit_of_closed_under_colimits (h : ClosedUnderColimitsOfShape J P)\n    (F : J ⥤ FullSubcategory P) [HasColimit (F ⋙ fullSubcategoryInclusion P)] : HasColimit F :=\n  have : CreatesColimit F (fullSubcategoryInclusion P) :=\n    createsColimitFullSubcategoryInclusionOfClosed h F\n  has_colimit_of_created F (full_subcategory_inclusion P)\n#align category_theory.limits.has_colimit_of_closed_under_colimits CategoryTheory.Limits.hasColimit_of_closed_under_colimits\n\n/- warning: category_theory.limits.has_colimits_of_shape_of_closed_under_colimits -> CategoryTheory.Limits.hasColimitsOfShape_of_closed_under_colimits is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasColimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.Limits.HasColimitsOfShape.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategoryₓ.{u3, u4} C _inst_2 P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P))\nbut is expected to have type\n  forall {J : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} J] {C : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u3, u4} C] {P : C -> Prop}, (CategoryTheory.Limits.ClosedUnderColimitsOfShape.{u1, u2, u3, u4} C _inst_2 J _inst_1 P) -> (forall [_inst_3 : CategoryTheory.Limits.HasColimitsOfShape.{u1, u2, u3, u4} J _inst_1 C _inst_2], CategoryTheory.Limits.HasColimitsOfShape.{u1, u2, u3, u4} J _inst_1 (CategoryTheory.FullSubcategory.{u4} C P) (CategoryTheory.FullSubcategory.category.{u3, u4} C _inst_2 P))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.has_colimits_of_shape_of_closed_under_colimits CategoryTheory.Limits.hasColimitsOfShape_of_closed_under_colimitsₓ'. -/\ntheorem hasColimitsOfShape_of_closed_under_colimits (h : ClosedUnderColimitsOfShape J P)\n    [HasColimitsOfShape J C] : HasColimitsOfShape J (FullSubcategory P) :=\n  { HasColimit := fun F => hasColimit_of_closed_under_colimits h F }\n#align category_theory.limits.has_colimits_of_shape_of_closed_under_colimits CategoryTheory.Limits.hasColimitsOfShape_of_closed_under_colimits\n\nend\n\nend CategoryTheory.Limits\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/FullSubcategory.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.48276099754301754}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, E. W. Ayers\n-/\n\nimport category_theory.over\nimport category_theory.limits.shapes.finite_limits\nimport category_theory.yoneda\nimport order.complete_lattice\nimport data.set.lattice\n\n/-!\n# Theory of sieves\n\n- For an object `X` of a category `C`, a `sieve X` is a set of morphisms to `X`\n  which is closed under left-composition.\n- The complete lattice structure on sieves is given, as well as the Galois insertion\n  given by downward-closing.\n- A `sieve X` (functorially) induces a presheaf on `C` together with a monomorphism to\n  the yoneda embedding of `X`.\n\n## Tags\n\nsieve, pullback\n-/\n\nuniverses v u\nnamespace category_theory\n\nopen category limits\n\nvariables {C : Type u} [category.{v} C]\nvariables {X Y Z : C} (f : Y ⟶ X)\n\n/-- A set of arrows all with codomain `X`. -/\n@[derive complete_lattice]\ndef presieve (X : C) := Π ⦃Y⦄, set (Y ⟶ X)\n\nnamespace presieve\n\ninstance : inhabited (presieve X) := ⟨⊤⟩\n\n/--\nGiven a set of arrows `S` all with codomain `X`, and a set of arrows with codomain `Y` for each\n`f : Y ⟶ X` in `S`, produce a set of arrows with codomain `X`:\n`{ g ≫ f | (f : Y ⟶ X) ∈ S, (g : Z ⟶ Y) ∈ R f }`.\n-/\ndef bind (S : presieve X) (R : Π ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → presieve Y) :\n  presieve X :=\nλ Z h, ∃ (Y : C) (g : Z ⟶ Y) (f : Y ⟶ X) (H : S f), R H g ∧ g ≫ f = h\n\n@[simp]\nlemma bind_comp {S : presieve X}\n  {R : Π ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, S f → presieve Y} {g : Z ⟶ Y} (h₁ : S f) (h₂ : R h₁ g) :\nbind S R (g ≫ f) :=\n⟨_, _, _, h₁, h₂, rfl⟩\n\n/-- The singleton presieve.  -/\n-- Note we can't make this into `has_singleton` because of the out-param.\ninductive singleton : presieve X\n| mk : singleton f\n\n@[simp] lemma singleton_eq_iff_domain (f g : Y ⟶ X) : singleton f g ↔ f = g :=\nbegin\n  split,\n  { rintro ⟨a, rfl⟩,\n    refl },\n  { rintro rfl,\n    apply singleton.mk, }\nend\n\nlemma singleton_self : singleton f f := singleton.mk\n\n/--\nPullback a set of arrows with given codomain along a fixed map, by taking the pullback in the\ncategory.\nThis is not the same as the arrow set of `sieve.pullback`, but there is a relation between them\nin `pullback_arrows_comm`.\n-/\ninductive pullback_arrows [has_pullbacks C] (R : presieve X) :\n  presieve Y\n| mk (Z : C) (h : Z ⟶ X) : R h → pullback_arrows (pullback.snd : pullback h f ⟶ Y)\n\nlemma pullback_singleton [has_pullbacks C] (g : Z ⟶ X) :\n pullback_arrows f (singleton g) = singleton (pullback.snd : pullback g f ⟶ _) :=\nbegin\n  ext W h,\n  split,\n  { rintro ⟨W, _, _, _⟩,\n    exact singleton.mk },\n  { rintro ⟨_⟩,\n    exact pullback_arrows.mk Z g singleton.mk }\nend\n\n/-- Construct the presieve given by the family of arrows indexed by `ι`. -/\ninductive of_arrows {ι : Type*} (Y : ι → C) (f : Π i, Y i ⟶ X) : presieve X\n| mk (i : ι) : of_arrows (f i)\n\nlemma of_arrows_punit :\n  of_arrows _ (λ _ : punit, f) = singleton f :=\nbegin\n  ext Y g,\n  split,\n  { rintro ⟨_⟩,\n    apply singleton.mk },\n  { rintro ⟨_⟩,\n    exact of_arrows.mk punit.star },\nend\n\nlemma of_arrows_pullback [has_pullbacks C] {ι : Type*}\n  (Z : ι → C) (g : Π (i : ι), Z i ⟶ X) :\n  of_arrows (λ i, pullback (g i) f) (λ i, pullback.snd) =\n    pullback_arrows f (of_arrows Z g) :=\nbegin\n  ext T h,\n  split,\n  { rintro ⟨hk⟩,\n   exact pullback_arrows.mk _ _ (of_arrows.mk hk) },\n  { rintro ⟨W, k, hk₁⟩,\n    cases hk₁ with i hi,\n    apply of_arrows.mk },\nend\n\nlemma of_arrows_bind {ι : Type*} (Z : ι → C) (g : Π (i : ι), Z i ⟶ X)\n  (j : Π ⦃Y⦄ (f : Y ⟶ X), of_arrows Z g f → Type*)\n  (W : Π ⦃Y⦄ (f : Y ⟶ X) H, j f H → C)\n  (k : Π ⦃Y⦄ (f : Y ⟶ X) H i, W f H i ⟶ Y) :\n  (of_arrows Z g).bind (λ Y f H, of_arrows (W f H) (k f H)) =\n    of_arrows (λ (i : Σ i, j _ (of_arrows.mk i)), W (g i.1) _ i.2)\n      (λ ij, k (g ij.1) _ ij.2 ≫ g ij.1) :=\nbegin\n  ext Y f,\n  split,\n  { rintro ⟨_, _, _, ⟨i⟩, ⟨i'⟩, rfl⟩,\n    exact of_arrows.mk (sigma.mk _ _) },\n  { rintro ⟨i⟩,\n    exact bind_comp _ (of_arrows.mk _) (of_arrows.mk _) }\nend\n\nend presieve\n\n/--\nFor an object `X` of a category `C`, a `sieve X` is a set of morphisms to `X` which is closed under\nleft-composition.\n-/\nstructure sieve {C : Type u} [category.{v} C] (X : C) :=\n(arrows : presieve X)\n(downward_closed' : ∀ {Y Z f} (hf : arrows f) (g : Z ⟶ Y), arrows (g ≫ f))\n\nnamespace sieve\n\ninstance {X : C} : has_coe_to_fun (sieve X) := ⟨_, sieve.arrows⟩\n\ninitialize_simps_projections sieve (arrows → apply)\n\nvariables {S R : sieve X}\n\n@[simp, priority 100] lemma downward_closed (S : sieve X) {f : Y ⟶ X} (hf : S f)\n  (g : Z ⟶ Y) : S (g ≫ f) :=\nS.downward_closed' hf g\n\nlemma arrows_ext : Π {R S : sieve X}, R.arrows = S.arrows → R = S\n| ⟨Ra, _⟩ ⟨Sa, _⟩ rfl := rfl\n\n@[ext]\nprotected lemma ext {R S : sieve X}\n  (h : ∀ ⦃Y⦄ (f : Y ⟶ X), R f ↔ S f) :\n  R = S :=\narrows_ext $ funext $ λ x, funext $ λ f, propext $ h f\n\nprotected lemma ext_iff {R S : sieve X} :\n  R = S ↔ (∀ ⦃Y⦄ (f : Y ⟶ X), R f ↔ S f) :=\n⟨λ h Y f, h ▸ iff.rfl, sieve.ext⟩\n\nopen lattice\n\n/-- The supremum of a collection of sieves: the union of them all. -/\nprotected def Sup (𝒮 : set (sieve X)) : (sieve X) :=\n{ arrows := λ Y, {f | ∃ S ∈ 𝒮, sieve.arrows S f},\n  downward_closed' := λ Y Z f, by { rintro ⟨S, hS, hf⟩ g, exact ⟨S, hS, S.downward_closed hf _⟩ } }\n\n/-- The infimum of a collection of sieves: the intersection of them all. -/\nprotected def Inf (𝒮 : set (sieve X)) : (sieve X) :=\n{ arrows := λ Y, {f | ∀ S ∈ 𝒮, sieve.arrows S f},\n  downward_closed' := λ Y Z f hf g S H, S.downward_closed (hf S H) g }\n\n/-- The union of two sieves is a sieve. -/\nprotected def union (S R : sieve X) : sieve X :=\n{ arrows := λ Y f, S f ∨ R f,\n  downward_closed' := by { rintros Y Z f (h | h) g; simp [h] } }\n\n/-- The intersection of two sieves is a sieve. -/\nprotected def inter (S R : sieve X) : sieve X :=\n{ arrows := λ Y f, S f ∧ R f,\n  downward_closed' := by { rintros Y Z f ⟨h₁, h₂⟩ g, simp [h₁, h₂] } }\n\n/--\nSieves on an object `X` form a complete lattice.\nWe generate this directly rather than using the galois insertion for nicer definitional properties.\n-/\ninstance : complete_lattice (sieve X) :=\n{ le           := λ S R, ∀ ⦃Y⦄ (f : Y ⟶ X), S f → R f,\n  le_refl      := λ S f q, id,\n  le_trans     := λ S₁ S₂ S₃ S₁₂ S₂₃ Y f h, S₂₃ _ (S₁₂ _ h),\n  le_antisymm  := λ S R p q, sieve.ext (λ Y f, ⟨p _, q _⟩),\n  top          := { arrows := λ _, set.univ, downward_closed' := λ Y Z f g h, ⟨⟩ },\n  bot          := { arrows := λ _, ∅, downward_closed' := λ _ _ _ p _, false.elim p },\n  sup          := sieve.union,\n  inf          := sieve.inter,\n  Sup          := sieve.Sup,\n  Inf          := sieve.Inf,\n  le_Sup       := λ 𝒮 S hS Y f hf, ⟨S, hS, hf⟩,\n  Sup_le       := λ ℰ S hS Y f, by { rintro ⟨R, hR, hf⟩, apply hS R hR _ hf },\n  Inf_le       := λ _ _ hS _ _ h, h _ hS,\n  le_Inf       := λ _ _ hS _ _ hf _ hR, hS _ hR _ hf,\n  le_sup_left  := λ _ _ _ _, or.inl,\n  le_sup_right := λ _ _ _ _, or.inr,\n  sup_le       := λ _ _ _ a b _ _ hf, hf.elim (a _) (b _),\n  inf_le_left  := λ _ _ _ _, and.left,\n  inf_le_right := λ _ _ _ _, and.right,\n  le_inf       := λ _ _ _ p q _ _ z, ⟨p _ z, q _ z⟩,\n  le_top       := λ _ _ _ _, trivial,\n  bot_le       := λ _ _ _, false.elim }\n\n/-- The maximal sieve always exists. -/\ninstance sieve_inhabited : inhabited (sieve X) := ⟨⊤⟩\n\n@[simp]\nlemma Inf_apply {Ss : set (sieve X)} {Y} (f : Y ⟶ X) :\n  Inf Ss f ↔ ∀ (S : sieve X) (H : S ∈ Ss), S f :=\niff.rfl\n\n@[simp]\nlemma Sup_apply {Ss : set (sieve X)} {Y} (f : Y ⟶ X) :\n  Sup Ss f ↔ ∃ (S : sieve X) (H : S ∈ Ss), S f :=\niff.rfl\n\n@[simp]\nlemma inter_apply {R S : sieve X} {Y} (f : Y ⟶ X) :\n  (R ⊓ S) f ↔ R f ∧ S f :=\niff.rfl\n\n@[simp]\nlemma union_apply {R S : sieve X} {Y} (f : Y ⟶ X) :\n  (R ⊔ S) f ↔ R f ∨ S f :=\niff.rfl\n\n@[simp]\nlemma top_apply (f : Y ⟶ X) : (⊤ : sieve X) f := trivial\n\n/-- Generate the smallest sieve containing the given set of arrows. -/\n@[simps]\ndef generate (R : presieve X) : sieve X :=\n{ arrows := λ Z f, ∃ Y (h : Z ⟶ Y) (g : Y ⟶ X), R g ∧ h ≫ g = f,\n  downward_closed' :=\n  begin\n    rintro Y Z _ ⟨W, g, f, hf, rfl⟩ h,\n    exact ⟨_, h ≫ g, _, hf, by simp⟩,\n  end }\n\n/--\nGiven a presieve on `X`, and a sieve on each domain of an arrow in the presieve, we can bind to\nproduce a sieve on `X`.\n-/\n@[simps]\ndef bind (S : presieve X) (R : Π ⦃Y⦄ ⦃f : Y ⟶ X⦄, S f → sieve Y) : sieve X :=\n{ arrows := S.bind (λ Y f h, R h),\n  downward_closed' :=\n  begin\n    rintro Y Z f ⟨W, f, h, hh, hf, rfl⟩ g,\n    exact ⟨_, g ≫ f, _, hh, by simp [hf]⟩,\n  end }\n\nopen order lattice\n\nlemma sets_iff_generate (R : presieve X) (S : sieve X) :\n  generate R ≤ S ↔ R ≤ S :=\n⟨λ H Y g hg, H _ ⟨_, 𝟙 _, _, hg, category.id_comp _⟩,\n λ ss Y f,\n  begin\n    rintro ⟨Z, f, g, hg, rfl⟩,\n    exact S.downward_closed (ss Z hg) f,\n  end⟩\n\n/-- Show that there is a galois insertion (generate, set_over). -/\ndef gi_generate : galois_insertion (generate : presieve X → sieve X) arrows :=\n{ gc := sets_iff_generate,\n  choice := λ 𝒢 _, generate 𝒢,\n  choice_eq := λ _ _, rfl,\n  le_l_u := λ S Y f hf, ⟨_, 𝟙 _, _, hf, category.id_comp _⟩ }\n\nlemma le_generate (R : presieve X) : R ≤ generate R :=\ngi_generate.gc.le_u_l R\n\n@[simp] lemma generate_sieve (S : sieve X) : generate S = S :=\ngi_generate.l_u_eq S\n\n/-- If the identity arrow is in a sieve, the sieve is maximal. -/\nlemma id_mem_iff_eq_top : S (𝟙 X) ↔ S = ⊤ :=\n⟨λ h, top_unique $ λ Y f _, by simpa using downward_closed _ h f,\n λ h, h.symm ▸ trivial⟩\n\n/-- If an arrow set contains a split epi, it generates the maximal sieve. -/\nlemma generate_of_contains_split_epi {R : presieve X} (f : Y ⟶ X) [split_epi f]\n  (hf : R f) : generate R = ⊤ :=\nbegin\n  rw ← id_mem_iff_eq_top,\n  exact ⟨_, section_ f, f, hf, by simp⟩,\nend\n\n@[simp]\nlemma generate_of_singleton_split_epi (f : Y ⟶ X) [split_epi f] :\n  generate (presieve.singleton f) = ⊤ :=\ngenerate_of_contains_split_epi f (presieve.singleton_self _)\n\n@[simp]\nlemma generate_top : generate (⊤ : presieve X) = ⊤ :=\ngenerate_of_contains_split_epi (𝟙 _) ⟨⟩\n\n/-- Given a morphism `h : Y ⟶ X`, send a sieve S on X to a sieve on Y\n    as the inverse image of S with `_ ≫ h`.\n    That is, `sieve.pullback S h := (≫ h) '⁻¹ S`. -/\n@[simps]\ndef pullback (h : Y ⟶ X) (S : sieve X) : sieve Y :=\n{ arrows := λ Y sl, S (sl ≫ h),\n  downward_closed' := λ Z W f g h, by simp [g] }\n\n@[simp]\nlemma pullback_id : S.pullback (𝟙 _) = S :=\nby simp [sieve.ext_iff]\n\n@[simp]\nlemma pullback_top {f : Y ⟶ X} : (⊤ : sieve X).pullback f = ⊤ :=\ntop_unique (λ _ g, id)\n\nlemma pullback_comp {f : Y ⟶ X} {g : Z ⟶ Y} (S : sieve X) :\n  S.pullback (g ≫ f) = (S.pullback f).pullback g :=\nby simp [sieve.ext_iff]\n\n@[simp]\nlemma pullback_inter {f : Y ⟶ X} (S R : sieve X) :\n (S ⊓ R).pullback f = S.pullback f ⊓ R.pullback f :=\nby simp [sieve.ext_iff]\n\nlemma pullback_eq_top_iff_mem (f : Y ⟶ X) : S f ↔ S.pullback f = ⊤ :=\nby rw [← id_mem_iff_eq_top, pullback_apply, category.id_comp]\n\nlemma pullback_eq_top_of_mem (S : sieve X) {f : Y ⟶ X} : S f → S.pullback f = ⊤ :=\n(pullback_eq_top_iff_mem f).1\n\n/--\nPush a sieve `R` on `Y` forward along an arrow `f : Y ⟶ X`: `gf : Z ⟶ X` is in the sieve if `gf`\nfactors through some `g : Z ⟶ Y` which is in `R`.\n-/\n@[simps]\ndef pushforward (f : Y ⟶ X) (R : sieve Y) : sieve X :=\n{ arrows := λ Z gf, ∃ g, g ≫ f = gf ∧ R g,\n  downward_closed' := λ Z₁ Z₂ g ⟨j, k, z⟩ h, ⟨h ≫ j, by simp [k], by simp [z]⟩ }\n\nlemma pushforward_apply_comp {R : sieve Y} {Z : C} {g : Z ⟶ Y} (hg : R g) (f : Y ⟶ X) :\n  R.pushforward f (g ≫ f) :=\n⟨g, rfl, hg⟩\n\nlemma pushforward_comp {f : Y ⟶ X} {g : Z ⟶ Y} (R : sieve Z) :\n  R.pushforward (g ≫ f) = (R.pushforward g).pushforward f :=\nsieve.ext (λ W h, ⟨λ ⟨f₁, hq, hf₁⟩, ⟨f₁ ≫ g, by simpa, f₁, rfl, hf₁⟩,\n                   λ ⟨y, hy, z, hR, hz⟩, ⟨z, by rwa reassoc_of hR, hz⟩⟩)\n\nlemma galois_connection (f : Y ⟶ X) : galois_connection (sieve.pushforward f) (sieve.pullback f) :=\nλ S R, ⟨λ hR Z g hg, hR _ ⟨g, rfl, hg⟩, λ hS Z g ⟨h, hg, hh⟩, hg ▸ hS h hh⟩\n\nlemma pullback_monotone (f : Y ⟶ X) : monotone (sieve.pullback f) :=\n(galois_connection f).monotone_u\n\nlemma pushforward_monotone (f : Y ⟶ X) : monotone (sieve.pushforward f) :=\n(galois_connection f).monotone_l\n\nlemma le_pushforward_pullback (f : Y ⟶ X) (R : sieve Y) :\n  R ≤ (R.pushforward f).pullback f :=\n(galois_connection f).le_u_l _\n\nlemma pullback_pushforward_le (f : Y ⟶ X) (R : sieve X) :\n  (R.pullback f).pushforward f ≤ R :=\n(galois_connection f).l_u_le _\n\nlemma pushforward_union {f : Y ⟶ X} (S R : sieve Y) :\n  (S ⊔ R).pushforward f = S.pushforward f ⊔ R.pushforward f :=\n(galois_connection f).l_sup\n\nlemma pushforward_le_bind_of_mem (S : presieve X)\n  (R : Π ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, S f → sieve Y) (f : Y ⟶ X) (h : S f) :\n  (R h).pushforward f ≤ bind S R :=\nbegin\n  rintro Z _ ⟨g, rfl, hg⟩,\n  exact ⟨_, g, f, h, hg, rfl⟩,\nend\n\nlemma le_pullback_bind (S : presieve X) (R : Π ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, S f → sieve Y)\n  (f : Y ⟶ X) (h : S f) :\n  R h ≤ (bind S R).pullback f :=\nbegin\n  rw ← galois_connection f,\n  apply pushforward_le_bind_of_mem,\nend\n\n/-- If `f` is a monomorphism, the pushforward-pullback adjunction on sieves is coreflective. -/\ndef galois_coinsertion_of_mono (f : Y ⟶ X) [mono f] :\n  galois_coinsertion (sieve.pushforward f) (sieve.pullback f) :=\nbegin\n  apply (galois_connection f).to_galois_coinsertion,\n  rintros S Z g ⟨g₁, hf, hg₁⟩,\n  rw cancel_mono f at hf,\n  rwa ← hf,\nend\n\n/-- If `f` is a split epi, the pushforward-pullback adjunction on sieves is reflective. -/\ndef galois_insertion_of_split_epi (f : Y ⟶ X) [split_epi f] :\n  galois_insertion (sieve.pushforward f) (sieve.pullback f) :=\nbegin\n  apply (galois_connection f).to_galois_insertion,\n  intros S Z g hg,\n  refine ⟨g ≫ section_ f, by simpa⟩,\nend\n\nlemma pullback_arrows_comm [has_pullbacks C] {X Y : C} (f : Y ⟶ X)\n  (R : presieve X) :\n  sieve.generate (R.pullback_arrows f) = (sieve.generate R).pullback f :=\nbegin\n  ext Z g,\n  split,\n  { rintro ⟨_, h, k, hk, rfl⟩,\n    cases hk with W g hg,\n    change (sieve.generate R).pullback f (h ≫ pullback.snd),\n    rw [sieve.pullback_apply, assoc, ← pullback.condition, ← assoc],\n    exact sieve.downward_closed _ (sieve.le_generate R W hg) (h ≫ pullback.fst)},\n  { rintro ⟨W, h, k, hk, comm⟩,\n    exact ⟨_, _, _, presieve.pullback_arrows.mk _ _ hk, pullback.lift_snd _ _ comm⟩ },\nend\n\n/-- A sieve induces a presheaf. -/\n@[simps]\ndef functor (S : sieve X) : Cᵒᵖ ⥤ Type v :=\n{ obj := λ Y, {g : Y.unop ⟶ X // S g},\n  map := λ Y Z f g, ⟨f.unop ≫ g.1, downward_closed _ g.2 _⟩ }\n\n/--\nIf a sieve S is contained in a sieve T, then we have a morphism of presheaves on their induced\npresheaves.\n-/\n@[simps]\ndef nat_trans_of_le {S T : sieve X} (h : S ≤ T) : S.functor ⟶ T.functor :=\n{ app := λ Y f, ⟨f.1, h _ f.2⟩ }.\n\n/-- The natural inclusion from the functor induced by a sieve to the yoneda embedding. -/\n@[simps]\ndef functor_inclusion (S : sieve X) : S.functor ⟶ yoneda.obj X :=\n{ app := λ Y f, f.1 }.\n\nlemma nat_trans_of_le_comm {S T : sieve X} (h : S ≤ T) :\n  nat_trans_of_le h ≫ functor_inclusion _ = functor_inclusion _ :=\nrfl\n\n/-- The presheaf induced by a sieve is a subobject of the yoneda embedding. -/\ninstance functor_inclusion_is_mono : mono S.functor_inclusion :=\n⟨λ Z f g h, by { ext Y y, apply congr_fun (nat_trans.congr_app h Y) y }⟩\n\n/--\nA natural transformation to a representable functor induces a sieve. This is the left inverse of\n`functor_inclusion`, shown in `sieve_of_functor_inclusion`.\n-/\n-- TODO: Show that when `f` is mono, this is right inverse to `functor_inclusion` up to isomorphism.\n@[simps]\ndef sieve_of_subfunctor {R} (f : R ⟶ yoneda.obj X) : sieve X :=\n{ arrows := λ Y g, ∃ t, f.app (opposite.op Y) t = g,\n  downward_closed' := λ Y Z _,\n  begin\n    rintro ⟨t, rfl⟩ g,\n    refine ⟨R.map g.op t, _⟩,\n    rw functor_to_types.naturality _ _ f,\n    simp,\n  end }\n\nlemma sieve_of_subfunctor_functor_inclusion : sieve_of_subfunctor S.functor_inclusion = S :=\nbegin\n  ext,\n  simp only [functor_inclusion_app, sieve_of_subfunctor_apply, subtype.val_eq_coe],\n  split,\n  { rintro ⟨⟨f, hf⟩, rfl⟩,\n    exact hf },\n  { intro hf,\n    exact ⟨⟨_, hf⟩, rfl⟩ }\nend\n\ninstance functor_inclusion_top_is_iso : is_iso ((⊤ : sieve X).functor_inclusion) :=\n⟨⟨{ app := λ Y a, ⟨a, ⟨⟩⟩ }, by tidy⟩⟩\n\nend sieve\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/sites/sieves.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4827609951759042}}
{"text": "import tactic.basic\n\n-- Lean version 3.45.0\n\n@[derive decidable_eq] inductive prop : Type\n| and : prop → prop → prop\n| true : prop\n| impl : prop → prop → prop\n| other : ℕ → prop\n\nabbreviation context : Type := list prop\n\ninductive entails₁ : context → prop → Prop\n| refl₁ {Γ A} : entails₁ (A :: Γ) A\n| trans {Γ A C} : entails₁ (A :: Γ) C → entails₁ Γ A → entails₁ Γ C\n| weak {Γ A C} : entails₁ Γ C → entails₁ (A :: Γ) C\n| contr {Γ A C} : entails₁ (A :: A :: Γ) C → entails₁ (A :: Γ) C\n| exch {Γ A B C} : entails₁ (B :: A :: Γ) C → entails₁ (A :: B :: Γ) C\n| and_intro {Γ A B} : entails₁ Γ A → entails₁ Γ B → entails₁ Γ (prop.and A B)\n| and_elim₁ {Γ A B} : entails₁ Γ (prop.and A B) → entails₁ Γ A\n| and_elim₂ {Γ A B} : entails₁ Γ (prop.and A B) → entails₁ Γ B\n| true_intro {Γ} : entails₁ Γ prop.true\n| impl_intro {Γ A B} : entails₁ (A :: Γ) B → entails₁ Γ (prop.impl A B)\n| impl_elim {Γ A B} : entails₁ Γ (prop.impl A B) → entails₁ Γ A → entails₁ Γ B\n\ninductive entails₂ : context → prop → Prop\n| refl₂ {Γ A} : list.mem A Γ → entails₂ Γ A\n| and_intro {Γ A B} : entails₂ Γ A → entails₂ Γ B → entails₂ Γ (prop.and A B)\n| and_elim₁ {Γ A B} : entails₂ Γ (prop.and A B) → entails₂ Γ A\n| and_elim₂ {Γ A B} : entails₂ Γ (prop.and A B) → entails₂ Γ B\n| true_intro {Γ} : entails₂ Γ prop.true\n| impl_intro {Γ A B} : entails₂ (A :: Γ) B → entails₂ Γ (prop.impl A B)\n| impl_elim {Γ A B} : entails₂ Γ (prop.impl A B) → entails₂ Γ A → entails₂ Γ B\n\nlemma entails₁.refl₂ {Γ A} : list.mem A Γ → entails₁ Γ A :=\nbegin\n  intro h,\n  induction Γ with B Γ ih,\n  { cases h },\n  { by_cases h' : A = B,\n    { subst h',\n      exact entails₁.refl₁ },\n    { replace h : list.mem A Γ,\n      { cases h, exact false.elim (h' h), exact h },\n      specialize ih h, clear h h',\n      exact entails₁.weak ih } }\nend\n\nlemma entails₂.refl₁ {Γ A} : entails₂ (A :: Γ) A :=\nbegin\n  exact entails₂.refl₂ (list.mem_cons_self A Γ)\nend\n\nlemma aux {Γ₁ Γ₂ C} (hΓ : ∀ (A : prop), list.mem A Γ₁ → list.mem A Γ₂) :\n  entails₂ Γ₁ C → entails₂ Γ₂ C :=\nbegin\n  intro h,\n  induction h with Γ₁ C h Γ₁ A B h₁ h₂ ih₁ ih₂ Γ₁ A B h ih Γ₁ A B h ih Γ₁ Γ₁ A B h ih Γ₁ A B h₁ h₂ ih₁ ih₂ generalizing Γ₂,\n  any_goals { specialize ih₁ hΓ, specialize ih₂ hΓ },\n  { exact entails₂.refl₂ (hΓ C h) },\n  { exact entails₂.and_intro ih₁ ih₂ },\n  { exact entails₂.and_elim₁ (ih hΓ) },\n  { exact entails₂.and_elim₂ (ih hΓ) },\n  { exact entails₂.true_intro },\n  { replace hΓ : ∀ B, list.mem B (A :: Γ₁) → list.mem B (A :: Γ₂),\n    { intro B,\n      by_cases h : B = A,\n      { subst h,\n        intro h',\n        exact or.inl rfl },\n      { intro h',\n        cases h', exact false.elim (h h'),\n        exact or.inr (hΓ B h') } },\n    exact entails₂.impl_intro (ih hΓ) },\n  { exact entails₂.impl_elim ih₁ ih₂ }\nend\n\nlemma entails₂.exch {Γ A B C} :\n  entails₂ (B :: A :: Γ) C → entails₂ (A :: B :: Γ) C :=\nbegin\n  apply aux; clear C,\n  intro C,\n  by_cases h₁ : C = A,\n  { subst h₁,\n    intro h,\n    exact or.inl rfl },\n  { by_cases h₂ : C = B,\n    { subst h₂,\n      intro h,\n      exact or.inr (or.inl rfl) },\n    { intro h,\n      cases h, exact false.elim (h₂ h),\n      cases h, exact false.elim (h₁ h),\n      exact or.inr (or.inr h) } }\nend\n\nlemma entails₂.weak {Γ A C} : entails₂ Γ C → entails₂ (A :: Γ) C :=\nbegin\n  intro h,\n  induction h with Γ C h Γ B C h₁ h₂ ih₁ ih₂ Γ C B h ih Γ B C h ih Γ Γ B C h ih Γ B C h₁ h₂ ih₁ ih₂,\n  { exact entails₂.refl₂ (or.inr h) },\n  { exact entails₂.and_intro ih₁ ih₂ },\n  { exact entails₂.and_elim₁ ih },\n  { exact entails₂.and_elim₂ ih },\n  { exact entails₂.true_intro },\n  { exact entails₂.impl_intro (entails₂.exch ih) },\n  { exact entails₂.impl_elim ih₁ ih₂ }\nend\n\nlemma entails₂.trans {Γ A C} :\n  entails₂ (A :: Γ) C → entails₂ Γ A → entails₂ Γ C :=\nbegin\n  intros H₁ H₂,\n  have hΓ : ∀ (B : prop), list.mem B (A :: Γ) → B = A ∨ list.mem B Γ,\n  { intros B h, exact h },\n  induction H₁ with Γ' C h Γ' A' B h₁ h₂ ih₁ ih₂ Γ' A' B h ih Γ' A' B h ih Γ' Γ' A' B h ih Γ' A' B h₁ h₂ ih₁ ih₂ generalizing Γ,\n  any_goals { specialize ih₁ H₂ hΓ, specialize ih₂ H₂ hΓ },\n  { by_cases h' : C = A,\n    { subst h',\n      exact H₂ },\n    { replace hΓ : list.mem C Γ,\n      { specialize hΓ C h,\n        cases hΓ,\n        { exact false.elim (h' hΓ) },\n        { exact hΓ } },\n      exact entails₂.refl₂ hΓ } },\n  { exact entails₂.and_intro ih₁ ih₂ },\n  { exact entails₂.and_elim₁ (ih H₂ hΓ) },\n  { exact entails₂.and_elim₂ (ih H₂ hΓ) },\n  { exact entails₂.true_intro },\n  { replace H₂ : entails₂ (A' :: Γ) A := entails₂.weak H₂,\n    replace hΓ : ∀ (B : prop), list.mem B (A' :: Γ') → B = A ∨ list.mem B (A' :: Γ),\n    { clear_dependent B,\n      intros B h,\n      cases h,\n      { subst h,\n        exact or.inr (or.inl rfl) },\n      { specialize hΓ B h,\n        cases hΓ,\n        { subst hΓ,\n          exact or.inl rfl },\n        { exact or.inr (or.inr hΓ) } } },\n    exact entails₂.impl_intro (ih H₂ hΓ) },\n  { exact entails₂.impl_elim ih₁ ih₂ }\nend\n\nlemma entails₂.contr {Γ A C} :\n  entails₂ (A :: A :: Γ) C → entails₂ (A :: Γ) C :=\nbegin\n  apply aux; clear C,\n  intro B,\n  by_cases h : B = A,\n  { subst h,\n    intro h',\n    exact or.inl rfl },\n  { intro h',\n    cases h', exact false.elim (h h'),\n    cases h', exact false.elim (h h'),\n    exact or.inr h' }\nend\n\ntheorem entails₁_iff_entails₂ {Γ C} :\n  entails₁ Γ C ↔ entails₂ Γ C :=\nbegin\n  split; intro h,\n  { induction h with Γ A Γ A C h₁ h₂ ih₁ ih₂ Γ A C h ih Γ A C h ih Γ A B C h ih Γ A B h₁ h₂ ih₁ ih₂ Γ A B h ih Γ A B h ih Γ Γ A B h ih Γ A B h₁ h₂ ih₁ ih₂,\n    { exact entails₂.refl₁ },\n    { exact entails₂.trans ih₁ ih₂ },\n    { exact entails₂.weak ih },\n    { exact entails₂.contr ih },\n    { exact entails₂.exch ih },\n    { exact entails₂.and_intro ih₁ ih₂ },\n    { exact entails₂.and_elim₁ ih },\n    { exact entails₂.and_elim₂ ih },\n    { exact entails₂.true_intro },\n    { exact entails₂.impl_intro ih },\n    { exact entails₂.impl_elim ih₁ ih₂ } },\n  { induction h with Γ C h Γ A B h₁ h₂ ih₁ ih₂ Γ A B h ih Γ A B h ih Γ Γ A B h ih Γ A B h₁ h₂ ih₁ ih₂,\n    { exact entails₁.refl₂ h },\n    { exact entails₁.and_intro ih₁ ih₂ },\n    { exact entails₁.and_elim₁ ih },\n    { exact entails₁.and_elim₂ ih },\n    { exact entails₁.true_intro },\n    { exact entails₁.impl_intro ih },\n    { exact entails₁.impl_elim ih₁ ih₂ } }\nend\n\n#print axioms entails₁_iff_entails₂ -- no axioms\n", "meta": {"author": "pedrominicz", "repo": "learn", "sha": "b79b802a9846c86c21d4b6f3e17af36e7382f0ef", "save_path": "github-repos/lean/pedrominicz-learn", "path": "github-repos/lean/pedrominicz-learn/learn-b79b802a9846c86c21d4b6f3e17af36e7382f0ef/src/surreal/ipl.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.48276098761268343}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.shapes.terminal\nimport category_theory.subobject.mono_over\n\n/-!\n# Subterminal objects\n\nSubterminal objects are the objects which can be thought of as subobjects of the terminal object.\nIn fact, the definition can be constructed to not require a terminal object, by defining `A` to be\nsubterminal iff for any `Z`, there is at most one morphism `Z ⟶ A`.\nAn alternate definition is that the diagonal morphism `A ⟶ A ⨯ A` is an isomorphism.\nIn this file we define subterminal objects and show the equivalence of these three definitions.\n\nWe also construct the subcategory of subterminal objects.\n\n## TODO\n\n* Define exponential ideals, and show this subcategory is an exponential ideal.\n* Use the above to show that in a locally cartesian closed category, every subobject lattice\n  is cartesian closed (equivalently, a Heyting algebra).\n\n-/\nuniverses v₁ v₂ u₁ u₂\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen limits category\n\nvariables {C : Type u₁} [category.{v₁} C] {A : C}\n\n/-- An object `A` is subterminal iff for any `Z`, there is at most one morphism `Z ⟶ A`. -/\ndef is_subterminal (A : C) : Prop := ∀ ⦃Z : C⦄ (f g : Z ⟶ A), f = g\n\nlemma is_subterminal.def : is_subterminal A ↔ ∀ ⦃Z : C⦄ (f g : Z ⟶ A), f = g := iff.rfl\n\n/--\nIf `A` is subterminal, the unique morphism from it to a terminal object is a monomorphism.\nThe converse of `is_subterminal_of_mono_is_terminal_from`.\n-/\nlemma is_subterminal.mono_is_terminal_from (hA : is_subterminal A) {T : C} (hT : is_terminal T) :\n  mono (hT.from A) :=\n{ right_cancellation := λ Z g h _, hA _ _ }\n\n/--\nIf `A` is subterminal, the unique morphism from it to the terminal object is a monomorphism.\nThe converse of `is_subterminal_of_mono_terminal_from`.\n-/\nlemma is_subterminal.mono_terminal_from [has_terminal C] (hA : is_subterminal A) :\n  mono (terminal.from A) :=\nhA.mono_is_terminal_from terminal_is_terminal\n\n/--\nIf the unique morphism from `A` to a terminal object is a monomorphism, `A` is subterminal.\nThe converse of `is_subterminal.mono_is_terminal_from`.\n-/\nlemma is_subterminal_of_mono_is_terminal_from {T : C} (hT : is_terminal T) [mono (hT.from A)] :\n  is_subterminal A :=\nλ Z f g, by { rw ← cancel_mono (hT.from A), apply hT.hom_ext }\n\n/--\nIf the unique morphism from `A` to the terminal object is a monomorphism, `A` is subterminal.\nThe converse of `is_subterminal.mono_terminal_from`.\n-/\nlemma is_subterminal_of_mono_terminal_from [has_terminal C] [mono (terminal.from A)] :\n  is_subterminal A :=\nλ Z f g, by { rw ← cancel_mono (terminal.from A), apply subsingleton.elim }\n\nlemma is_subterminal_of_is_terminal {T : C} (hT : is_terminal T) : is_subterminal T :=\nλ Z f g, hT.hom_ext _ _\n\nlemma is_subterminal_of_terminal [has_terminal C] : is_subterminal (⊤_ C) :=\nλ Z f g, subsingleton.elim _ _\n\n/--\nIf `A` is subterminal, its diagonal morphism is an isomorphism.\nThe converse of `is_subterminal_of_is_iso_diag`.\n-/\nlemma is_subterminal.is_iso_diag (hA : is_subterminal A) [has_binary_product A A] :\n  is_iso (diag A) :=\n⟨⟨limits.prod.fst, ⟨by simp, by { rw is_subterminal.def at hA, tidy }⟩⟩⟩\n\n/--\nIf the diagonal morphism of `A` is an isomorphism, then it is subterminal.\nThe converse of `is_subterminal.is_iso_diag`.\n-/\nlemma is_subterminal_of_is_iso_diag [has_binary_product A A] [is_iso (diag A)] :\n  is_subterminal A :=\nλ Z f g,\nbegin\n  have : (limits.prod.fst : A ⨯ A ⟶ _) = limits.prod.snd,\n  { simp [←cancel_epi (diag A)] },\n  rw [←prod.lift_fst f g, this, prod.lift_snd],\nend\n\n/-- If `A` is subterminal, it is isomorphic to `A ⨯ A`. -/\n@[simps]\ndef is_subterminal.iso_diag (hA : is_subterminal A) [has_binary_product A A] :\n  A ⨯ A ≅ A :=\nbegin\n  letI := is_subterminal.is_iso_diag hA,\n  apply (as_iso (diag A)).symm,\nend\n\nvariables (C)\n/--\nThe (full sub)category of subterminal objects.\nTODO: If `C` is the category of sheaves on a topological space `X`, this category is equivalent\nto the lattice of open subsets of `X`. More generally, if `C` is a topos, this is the lattice of\n\"external truth values\".\n-/\n@[derive category]\ndef subterminals (C : Type u₁) [category.{v₁} C] :=\nfull_subcategory (λ (A : C), is_subterminal A)\n\ninstance [has_terminal C] : inhabited (subterminals C) :=\n⟨⟨⊤_ C, is_subterminal_of_terminal⟩⟩\n\n/-- The inclusion of the subterminal objects into the original category. -/\n@[derive [full, faithful], simps]\ndef subterminal_inclusion : subterminals C ⥤ C := full_subcategory_inclusion _\n\ninstance subterminals_thin (X Y : subterminals C) : subsingleton (X ⟶ Y) :=\n⟨λ f g, Y.2 f g⟩\n\n/--\nThe category of subterminal objects is equivalent to the category of monomorphisms to the terminal\nobject (which is in turn equivalent to the subobjects of the terminal object).\n-/\n@[simps]\ndef subterminals_equiv_mono_over_terminal [has_terminal C] :\n  subterminals C ≌ mono_over (⊤_ C) :=\n{ functor :=\n  { obj := λ X, ⟨over.mk (terminal.from X.1), X.2.mono_terminal_from⟩,\n    map := λ X Y f, mono_over.hom_mk f (by ext1 ⟨⟨⟩⟩) },\n  inverse :=\n  { obj := λ X, ⟨X.obj.left, λ Z f g, by { rw ← cancel_mono X.arrow, apply subsingleton.elim }⟩,\n    map := λ X Y f, f.1 },\n  unit_iso :=\n  { hom := { app := λ X, 𝟙 _ },\n    inv := { app := λ X, 𝟙 _ } },\n  counit_iso :=\n  { hom := { app := λ X, over.hom_mk (𝟙 _) },\n    inv := { app := λ X, over.hom_mk (𝟙 _) } } }\n\n@[simp]\nlemma subterminals_to_mono_over_terminal_comp_forget [has_terminal C] :\n  (subterminals_equiv_mono_over_terminal C).functor ⋙ mono_over.forget _ ⋙ over.forget _ =\n    subterminal_inclusion C :=\nrfl\n\n@[simp]\nlemma mono_over_terminal_to_subterminals_comp [has_terminal C] :\n  (subterminals_equiv_mono_over_terminal C).inverse ⋙ subterminal_inclusion C =\n    mono_over.forget _ ⋙ over.forget _ :=\nrfl\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/subterminal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.4827609826475162}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov, Eric Wieser\n-/\nimport linear_algebra.span\nimport order.partial_sups\nimport algebra.algebra.basic\n\n/-! ### Products of modules\n\nThis file defines constructors for linear maps whose domains or codomains are products.\n\nIt contains theorems relating these to each other, as well as to `submodule.prod`, `submodule.map`,\n`submodule.comap`, `linear_map.range`, and `linear_map.ker`.\n\n## Main definitions\n\n- products in the domain:\n  - `linear_map.fst`\n  - `linear_map.snd`\n  - `linear_map.coprod`\n  - `linear_map.prod_ext`\n- products in the codomain:\n  - `linear_map.inl`\n  - `linear_map.inr`\n  - `linear_map.prod`\n- products in both domain and codomain:\n  - `linear_map.prod_map`\n  - `linear_equiv.prod_map`\n  - `linear_equiv.skew_prod`\n-/\n\nuniverses u v w x y z u' v' w' y'\nvariables {R : Type u} {K : Type u'} {M : Type v} {V : Type v'} {M₂ : Type w} {V₂ : Type w'}\nvariables {M₃ : Type y} {V₃ : Type y'} {M₄ : Type z} {ι : Type x}\nvariables {M₅ M₆ : Type*}\n\nsection prod\n\nnamespace linear_map\n\nvariables (S : Type*) [semiring R] [semiring S]\nvariables [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\nvariables [add_comm_monoid M₅] [add_comm_monoid M₆]\nvariables [module R M] [module R M₂] [module R M₃] [module R M₄]\nvariables [module R M₅] [module R M₆]\nvariables (f : M →ₗ[R] M₂)\n\nsection\nvariables (R M M₂)\n\n/-- The first projection of a product is a linear map. -/\ndef fst : M × M₂ →ₗ[R] M := { to_fun := prod.fst, map_add' := λ x y, rfl, map_smul' := λ x y, rfl }\n\n/-- The second projection of a product is a linear map. -/\ndef snd : M × M₂ →ₗ[R] M₂ := { to_fun := prod.snd, map_add' := λ x y, rfl, map_smul' := λ x y, rfl }\nend\n\n@[simp] theorem fst_apply (x : M × M₂) : fst R M M₂ x = x.1 := rfl\n@[simp] theorem snd_apply (x : M × M₂) : snd R M M₂ x = x.2 := rfl\n\ntheorem fst_surjective : function.surjective (fst R M M₂) := λ x, ⟨(x, 0), rfl⟩\ntheorem snd_surjective : function.surjective (snd R M M₂) := λ x, ⟨(0, x), rfl⟩\n\n/-- The prod of two linear maps is a linear map. -/\n@[simps] def prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : (M →ₗ[R] M₂ × M₃) :=\n{ to_fun    := pi.prod f g,\n  map_add'  := λ x y, by simp only [pi.prod, prod.mk_add_mk, map_add],\n  map_smul' := λ c x, by simp only [pi.prod, prod.smul_mk, map_smul, ring_hom.id_apply] }\n\nlemma coe_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : ⇑(f.prod g) = pi.prod f g := rfl\n\n@[simp] theorem fst_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  (fst R M₂ M₃).comp (prod f g) = f := by ext; refl\n\n@[simp] theorem snd_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  (snd R M₂ M₃).comp (prod f g) = g := by ext; refl\n\n@[simp] theorem pair_fst_snd : prod (fst R M M₂) (snd R M M₂) = linear_map.id :=\nfun_like.coe_injective pi.prod_fst_snd\n\n/-- Taking the product of two maps with the same domain is equivalent to taking the product of\ntheir codomains.\n\nSee note [bundled maps over different rings] for why separate `R` and `S` semirings are used. -/\n@[simps] def prod_equiv\n  [module S M₂] [module S M₃] [smul_comm_class R S M₂] [smul_comm_class R S M₃] :\n  ((M →ₗ[R] M₂) × (M →ₗ[R] M₃)) ≃ₗ[S] (M →ₗ[R] M₂ × M₃) :=\n{ to_fun := λ f, f.1.prod f.2,\n  inv_fun := λ f, ((fst _ _ _).comp f, (snd _ _ _).comp f),\n  left_inv := λ f, by ext; refl,\n  right_inv := λ f, by ext; refl,\n  map_add' := λ a b, rfl,\n  map_smul' := λ r a, rfl }\n\nsection\nvariables (R M M₂)\n\n/-- The left injection into a product is a linear map. -/\ndef inl : M →ₗ[R] M × M₂ := prod linear_map.id 0\n\n/-- The right injection into a product is a linear map. -/\ndef inr : M₂ →ₗ[R] M × M₂ := prod 0 linear_map.id\n\ntheorem range_inl : range (inl R M M₂) = ker (snd R M M₂) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros ⟨y, rfl⟩, refl },\n  { intro h, exact ⟨x.fst, prod.ext rfl h.symm⟩ }\nend\n\ntheorem ker_snd : ker (snd R M M₂) = range (inl R M M₂) :=\neq.symm $ range_inl R M M₂\n\ntheorem range_inr : range (inr R M M₂) = ker (fst R M M₂) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros ⟨y, rfl⟩, refl },\n  { intro h, exact ⟨x.snd, prod.ext h.symm rfl⟩ }\nend\n\ntheorem ker_fst : ker (fst R M M₂) = range (inr R M M₂) :=\neq.symm $ range_inr R M M₂\n\nend\n\n@[simp] theorem coe_inl : (inl R M M₂ : M → M × M₂) = λ x, (x, 0) := rfl\ntheorem inl_apply (x : M) : inl R M M₂ x = (x, 0) := rfl\n\n@[simp] theorem coe_inr : (inr R M M₂ : M₂ → M × M₂) = prod.mk 0 := rfl\ntheorem inr_apply (x : M₂) : inr R M M₂ x = (0, x) := rfl\n\ntheorem inl_eq_prod : inl R M M₂ = prod linear_map.id 0 := rfl\n\ntheorem inr_eq_prod : inr R M M₂ = prod 0 linear_map.id := rfl\n\ntheorem inl_injective : function.injective (inl R M M₂) :=\nλ _, by simp\n\n\n\n/-- The coprod function `λ x : M × M₂, f x.1 + g x.2` is a linear map. -/\ndef coprod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) : M × M₂ →ₗ[R] M₃ :=\nf.comp (fst _ _ _) + g.comp (snd _ _ _)\n\n@[simp] theorem coprod_apply (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) (x : M × M₂) :\n  coprod f g x = f x.1 + g x.2 := rfl\n\n@[simp] theorem coprod_inl (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (coprod f g).comp (inl R M M₂) = f :=\nby ext; simp only [map_zero, add_zero, coprod_apply, inl_apply, comp_apply]\n\n@[simp] theorem coprod_inr (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (coprod f g).comp (inr R M M₂) = g :=\nby ext; simp only [map_zero, coprod_apply, inr_apply, zero_add, comp_apply]\n\n@[simp] theorem coprod_inl_inr : coprod (inl R M M₂) (inr R M M₂) = linear_map.id :=\nby ext; simp only [prod.mk_add_mk, add_zero, id_apply, coprod_apply,\n  inl_apply, inr_apply, zero_add]\n\ntheorem comp_coprod (f : M₃ →ₗ[R] M₄) (g₁ : M →ₗ[R] M₃) (g₂ : M₂ →ₗ[R] M₃) :\n  f.comp (g₁.coprod g₂) = (f.comp g₁).coprod (f.comp g₂) :=\next $ λ x, f.map_add (g₁ x.1) (g₂ x.2)\n\ntheorem fst_eq_coprod : fst R M M₂ = coprod linear_map.id 0 := by ext; simp\n\ntheorem snd_eq_coprod : snd R M M₂ = coprod 0 linear_map.id := by ext; simp\n\n@[simp] theorem coprod_comp_prod (f : M₂ →ₗ[R] M₄) (g : M₃ →ₗ[R] M₄)\n  (f' : M →ₗ[R] M₂) (g' : M →ₗ[R] M₃) :\n  (f.coprod g).comp (f'.prod g') = f.comp f' + g.comp g' :=\nrfl\n\n@[simp]\nlemma coprod_map_prod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) (S : submodule R M)\n  (S' : submodule R M₂) :\n  (submodule.prod S S').map (linear_map.coprod f g) = S.map f ⊔ S'.map g :=\nset_like.coe_injective $ begin\n  simp only [linear_map.coprod_apply, submodule.coe_sup, submodule.map_coe],\n  rw [←set.image2_add, set.image2_image_left, set.image2_image_right],\n  exact set.image_prod (λ m m₂, f m + g m₂),\nend\n\n/-- Taking the product of two maps with the same codomain is equivalent to taking the product of\ntheir domains.\n\nSee note [bundled maps over different rings] for why separate `R` and `S` semirings are used. -/\n@[simps] def coprod_equiv [module S M₃] [smul_comm_class R S M₃] :\n  ((M →ₗ[R] M₃) × (M₂ →ₗ[R] M₃)) ≃ₗ[S] (M × M₂ →ₗ[R] M₃) :=\n{ to_fun := λ f, f.1.coprod f.2,\n  inv_fun := λ f, (f.comp (inl _ _ _), f.comp (inr _ _ _)),\n  left_inv := λ f, by simp only [prod.mk.eta, coprod_inl, coprod_inr],\n  right_inv := λ f, by simp only [←comp_coprod, comp_id, coprod_inl_inr],\n  map_add' := λ a b,\n    by { ext, simp only [prod.snd_add, add_apply, coprod_apply, prod.fst_add, add_add_add_comm] },\n  map_smul' := λ r a,\n    by { dsimp, ext, simp only [smul_add, smul_apply, prod.smul_snd, prod.smul_fst,\n                                coprod_apply] } }\n\ntheorem prod_ext_iff {f g : M × M₂ →ₗ[R] M₃} :\n  f = g ↔ f.comp (inl _ _ _) = g.comp (inl _ _ _) ∧ f.comp (inr _ _ _) = g.comp (inr _ _ _) :=\n(coprod_equiv ℕ).symm.injective.eq_iff.symm.trans prod.ext_iff\n\n/--\nSplit equality of linear maps from a product into linear maps over each component, to allow `ext`\nto apply lemmas specific to `M →ₗ M₃` and `M₂ →ₗ M₃`.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext] theorem prod_ext {f g : M × M₂ →ₗ[R] M₃}\n  (hl : f.comp (inl _ _ _) = g.comp (inl _ _ _))\n  (hr : f.comp (inr _ _ _) = g.comp (inr _ _ _)) :\n  f = g :=\nprod_ext_iff.2 ⟨hl, hr⟩\n\n/-- `prod.map` of two linear maps. -/\ndef prod_map (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) : (M × M₂) →ₗ[R] (M₃ × M₄) :=\n(f.comp (fst R M M₂)).prod (g.comp (snd R M M₂))\n\n@[simp] theorem prod_map_apply (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) (x) :\n  f.prod_map g x = (f x.1, g x.2) := rfl\n\nlemma prod_map_comap_prod (f : M →ₗ[R] M₂) (g : M₃ →ₗ[R] M₄) (S : submodule R M₂)\n  (S' : submodule R M₄) :\n  (submodule.prod S S').comap (linear_map.prod_map f g) = (S.comap f).prod (S'.comap g) :=\nset_like.coe_injective $ set.preimage_prod_map_prod f g _ _\n\nlemma ker_prod_map (f : M →ₗ[R] M₂) (g : M₃ →ₗ[R] M₄) :\n  (linear_map.prod_map f g).ker = submodule.prod f.ker g.ker :=\nbegin\n  dsimp only [ker],\n  rw [←prod_map_comap_prod, submodule.prod_bot],\nend\n\n@[simp]\nlemma prod_map_id : (id : M →ₗ[R] M).prod_map (id : M₂ →ₗ[R] M₂) = id :=\nlinear_map.ext $ λ _, prod.mk.eta\n\n@[simp]\nlemma prod_map_one : (1 : M →ₗ[R] M).prod_map (1 : M₂ →ₗ[R] M₂) = 1 :=\nlinear_map.ext $ λ _, prod.mk.eta\n\nlemma prod_map_comp (f₁₂ : M →ₗ[R] M₂) (f₂₃ : M₂ →ₗ[R] M₃) (g₁₂ : M₄ →ₗ[R] M₅) (g₂₃ : M₅ →ₗ[R] M₆) :\n  f₂₃.prod_map g₂₃ ∘ₗ f₁₂.prod_map g₁₂ = (f₂₃ ∘ₗ f₁₂).prod_map (g₂₃ ∘ₗ g₁₂) := rfl\n\nlemma prod_map_mul (f₁₂ : M →ₗ[R] M) (f₂₃ : M →ₗ[R] M) (g₁₂ : M₂ →ₗ[R] M₂) (g₂₃ : M₂ →ₗ[R] M₂) :\n  f₂₃.prod_map g₂₃ * f₁₂.prod_map g₁₂ = (f₂₃ * f₁₂).prod_map (g₂₃ * g₁₂) := rfl\n\nlemma prod_map_add (f₁ : M →ₗ[R] M₃) (f₂ : M →ₗ[R] M₃) (g₁ : M₂ →ₗ[R] M₄) (g₂ : M₂ →ₗ[R] M₄) :\n  (f₁ + f₂).prod_map (g₁ + g₂) = f₁.prod_map g₁ + f₂.prod_map g₂ := rfl\n\n@[simp] lemma prod_map_zero :\n  (0 : M →ₗ[R] M₂).prod_map (0 : M₃ →ₗ[R] M₄) = 0 := rfl\n\n@[simp] lemma prod_map_smul\n [module S M₃] [module S M₄] [smul_comm_class R S M₃] [smul_comm_class R S M₄]\n (s : S) (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) : prod_map (s • f) (s • g) = s • prod_map f g := rfl\n\nvariables (R M M₂ M₃ M₄)\n\n/-- `linear_map.prod_map` as a `linear_map` -/\n@[simps]\ndef prod_map_linear\n [module S M₃] [module S M₄] [smul_comm_class R S M₃] [smul_comm_class R S M₄] :\n ((M →ₗ[R] M₃) × (M₂ →ₗ[R] M₄)) →ₗ[S] ((M × M₂) →ₗ[R] (M₃ × M₄)) :=\n{ to_fun := λ f, prod_map f.1 f.2,\n  map_add' := λ _ _, rfl,\n  map_smul' := λ _ _, rfl}\n\n/-- `linear_map.prod_map` as a `ring_hom` -/\n@[simps]\ndef prod_map_ring_hom : (M →ₗ[R] M) × (M₂ →ₗ[R] M₂) →+* ((M × M₂) →ₗ[R] (M × M₂)) :=\n{ to_fun := λ f, prod_map f.1 f.2,\n  map_one' := prod_map_one,\n  map_zero' := rfl,\n  map_add' := λ _ _, rfl,\n  map_mul' := λ _ _, rfl }\n\nvariables {R M M₂ M₃ M₄}\n\nsection map_mul\n\nvariables {A : Type*} [non_unital_non_assoc_semiring A] [module R A]\nvariables {B : Type*} [non_unital_non_assoc_semiring B] [module R B]\n\nlemma inl_map_mul (a₁ a₂ : A) : linear_map.inl R A B (a₁ * a₂) =\n  linear_map.inl R A B a₁ * linear_map.inl R A B a₂ :=\nprod.ext rfl (by simp)\n\nlemma inr_map_mul (b₁ b₂ : B) : linear_map.inr R A B (b₁ * b₂) =\n  linear_map.inr R A B b₁ * linear_map.inr R A B b₂ :=\nprod.ext (by simp) rfl\n\nend map_mul\n\nend linear_map\n\nend prod\n\nnamespace linear_map\n\nvariables (R M M₂)\n\nvariables [comm_semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂]\nvariables [module R M] [module R M₂]\n\n/-- `linear_map.prod_map` as an `algebra_hom` -/\n@[simps]\ndef prod_map_alg_hom : (module.End R M) × (module.End R M₂) →ₐ[R] module.End R (M × M₂) :=\n{ commutes' := λ _, rfl, ..prod_map_ring_hom R M M₂ }\n\nend linear_map\n\nnamespace linear_map\nopen submodule\n\nvariables [semiring R]\n  [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n  [module R M] [module R M₂] [module R M₃] [module R M₄]\n\nlemma range_coprod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (f.coprod g).range = f.range ⊔ g.range :=\nsubmodule.ext $ λ x, by simp [mem_sup]\n\nlemma is_compl_range_inl_inr : is_compl (inl R M M₂).range (inr R M M₂).range :=\nbegin\n  split,\n  { rintros ⟨_, _⟩ ⟨⟨x, hx⟩, ⟨y, hy⟩⟩,\n    simp only [prod.ext_iff, inl_apply, inr_apply, mem_bot] at hx hy ⊢,\n    exact ⟨hy.1.symm, hx.2.symm⟩ },\n  { rintros ⟨x, y⟩ -,\n    simp only [mem_sup, mem_range, exists_prop],\n    refine ⟨(x, 0), ⟨x, rfl⟩, (0, y), ⟨y, rfl⟩, _⟩,\n    simp }\nend\n\nlemma sup_range_inl_inr : (inl R M M₂).range ⊔ (inr R M M₂).range = ⊤ :=\nis_compl_range_inl_inr.sup_eq_top\n\nlemma disjoint_inl_inr : disjoint (inl R M M₂).range (inr R M M₂).range :=\nby simp [disjoint_def, @eq_comm M 0, @eq_comm M₂ 0] {contextual := tt}; intros; refl\ntheorem map_coprod_prod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃)\n  (p : submodule R M) (q : submodule R M₂) :\n  map (coprod f g) (p.prod q) = map f p ⊔ map g q :=\nbegin\n  refine le_antisymm _ (sup_le (map_le_iff_le_comap.2 _) (map_le_iff_le_comap.2 _)),\n  { rw set_like.le_def, rintro _ ⟨x, ⟨h₁, h₂⟩, rfl⟩,\n    exact mem_sup.2 ⟨_, ⟨_, h₁, rfl⟩, _, ⟨_, h₂, rfl⟩, rfl⟩ },\n  { exact λ x hx, ⟨(x, 0), by simp [hx]⟩ },\n  { exact λ x hx, ⟨(0, x), by simp [hx]⟩ }\nend\n\ntheorem comap_prod_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃)\n  (p : submodule R M₂) (q : submodule R M₃) :\n  comap (prod f g) (p.prod q) = comap f p ⊓ comap g q :=\nsubmodule.ext $ λ x, iff.rfl\n\ntheorem prod_eq_inf_comap (p : submodule R M) (q : submodule R M₂) :\n  p.prod q = p.comap (linear_map.fst R M M₂) ⊓ q.comap (linear_map.snd R M M₂) :=\nsubmodule.ext $ λ x, iff.rfl\n\ntheorem prod_eq_sup_map (p : submodule R M) (q : submodule R M₂) :\n  p.prod q = p.map (linear_map.inl R M M₂) ⊔ q.map (linear_map.inr R M M₂) :=\nby rw [← map_coprod_prod, coprod_inl_inr, map_id]\n\nlemma span_inl_union_inr {s : set M} {t : set M₂} :\n  span R (inl R M  M₂ '' s ∪ inr R M M₂ '' t) = (span R s).prod (span R t) :=\nby rw [span_union, prod_eq_sup_map, ← span_image, ← span_image]\n\n@[simp] lemma ker_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  ker (prod f g) = ker f ⊓ ker g :=\nby rw [ker, ← prod_bot, comap_prod_prod]; refl\n\nlemma range_prod_le (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  range (prod f g) ≤ (range f).prod (range g) :=\nbegin\n  simp only [set_like.le_def, prod_apply, mem_range, set_like.mem_coe, mem_prod,\n    exists_imp_distrib],\n  rintro _ x rfl,\n  exact ⟨⟨x, rfl⟩, ⟨x, rfl⟩⟩\nend\n\nlemma ker_prod_ker_le_ker_coprod {M₂ : Type*} [add_comm_group M₂] [module R M₂]\n  {M₃ : Type*} [add_comm_group M₃] [module R M₃]\n  (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (ker f).prod (ker g) ≤ ker (f.coprod g) :=\nby { rintros ⟨y, z⟩, simp {contextual := tt} }\n\nlemma ker_coprod_of_disjoint_range {M₂ : Type*} [add_comm_group M₂] [module R M₂]\n  {M₃ : Type*} [add_comm_group M₃] [module R M₃]\n  (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) (hd : disjoint f.range g.range) :\n  ker (f.coprod g) = (ker f).prod (ker g) :=\nbegin\n  apply le_antisymm _ (ker_prod_ker_le_ker_coprod f g),\n  rintros ⟨y, z⟩ h,\n  simp only [mem_ker, mem_prod, coprod_apply] at h ⊢,\n  have : f y ∈ f.range ⊓ g.range,\n  { simp only [true_and, mem_range, mem_inf, exists_apply_eq_apply],\n    use -z,\n    rwa [eq_comm, map_neg, ← sub_eq_zero, sub_neg_eq_add] },\n  rw [hd.eq_bot, mem_bot] at this,\n  rw [this] at h,\n  simpa [this] using h,\nend\n\nend linear_map\n\nnamespace submodule\nopen linear_map\n\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂]\nvariables [module R M] [module R M₂]\n\nlemma sup_eq_range (p q : submodule R M) : p ⊔ q = (p.subtype.coprod q.subtype).range :=\nsubmodule.ext $ λ x, by simp [submodule.mem_sup, set_like.exists]\n\nvariables (p : submodule R M) (q : submodule R M₂)\n\n@[simp] theorem map_inl : p.map (inl R M M₂) = prod p ⊥ :=\nby { ext ⟨x, y⟩, simp only [and.left_comm, eq_comm, mem_map, prod.mk.inj_iff, inl_apply, mem_bot,\n  exists_eq_left', mem_prod] }\n\n@[simp] theorem map_inr : q.map (inr R M M₂) = prod ⊥ q :=\nby ext ⟨x, y⟩; simp [and.left_comm, eq_comm]\n\n@[simp] theorem comap_fst : p.comap (fst R M M₂) = prod p ⊤ :=\nby ext ⟨x, y⟩; simp\n\n@[simp] theorem comap_snd : q.comap (snd R M M₂) = prod ⊤ q :=\nby ext ⟨x, y⟩; simp\n\n@[simp] theorem prod_comap_inl : (prod p q).comap (inl R M M₂) = p := by ext; simp\n\n@[simp] theorem prod_comap_inr : (prod p q).comap (inr R M M₂) = q := by ext; simp\n\n@[simp] theorem prod_map_fst : (prod p q).map (fst R M M₂) = p :=\nby ext x; simp [(⟨0, zero_mem _⟩ : ∃ x, x ∈ q)]\n\n@[simp] theorem prod_map_snd : (prod p q).map (snd R M M₂) = q :=\nby ext x; simp [(⟨0, zero_mem _⟩ : ∃ x, x ∈ p)]\n\n@[simp] theorem ker_inl : (inl R M M₂).ker = ⊥ :=\nby rw [ker, ← prod_bot, prod_comap_inl]\n\n@[simp] theorem ker_inr : (inr R M M₂).ker = ⊥ :=\nby rw [ker, ← prod_bot, prod_comap_inr]\n\n@[simp] theorem range_fst : (fst R M M₂).range = ⊤ :=\nby rw [range_eq_map, ← prod_top, prod_map_fst]\n\n@[simp] theorem range_snd : (snd R M M₂).range = ⊤ :=\nby rw [range_eq_map, ← prod_top, prod_map_snd]\n\nvariables (R M M₂)\n\n/-- `M` as a submodule of `M × N`. -/\ndef fst : submodule R (M × M₂) := (⊥ : submodule R M₂).comap (linear_map.snd R M M₂)\n\n/-- `M` as a submodule of `M × N` is isomorphic to `M`. -/\n@[simps] def fst_equiv : submodule.fst R M M₂ ≃ₗ[R] M :=\n{ to_fun := λ x, x.1.1,\n  inv_fun := λ m, ⟨⟨m, 0⟩, by tidy⟩,\n  map_add' := by simp,\n  map_smul' := by simp,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\nlemma fst_map_fst : (submodule.fst R M M₂).map (linear_map.fst R M M₂) = ⊤ :=\nby tidy\nlemma fst_map_snd : (submodule.fst R M M₂).map (linear_map.snd R M M₂) = ⊥ :=\nby { tidy, exact 0, }\n\n/-- `N` as a submodule of `M × N`. -/\ndef snd : submodule R (M × M₂) := (⊥ : submodule R M).comap (linear_map.fst R M M₂)\n\n/-- `N` as a submodule of `M × N` is isomorphic to `N`. -/\n@[simps] def snd_equiv : submodule.snd R M M₂ ≃ₗ[R] M₂ :=\n{ to_fun := λ x, x.1.2,\n  inv_fun := λ n, ⟨⟨0, n⟩, by tidy⟩,\n  map_add' := by simp,\n  map_smul' := by simp,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\nlemma snd_map_fst : (submodule.snd R M M₂).map (linear_map.fst R M M₂) = ⊥ :=\nby { tidy, exact 0, }\nlemma snd_map_snd : (submodule.snd R M M₂).map (linear_map.snd R M M₂) = ⊤ :=\nby tidy\n\nlemma fst_sup_snd : submodule.fst R M M₂ ⊔ submodule.snd R M M₂ = ⊤ :=\nbegin\n  rw eq_top_iff,\n  rintro ⟨m, n⟩ -,\n  rw [show (m, n) = (m, 0) + (0, n), by simp],\n  apply submodule.add_mem (submodule.fst R M M₂ ⊔ submodule.snd R M M₂),\n  { exact submodule.mem_sup_left (submodule.mem_comap.mpr (by simp)), },\n  { exact submodule.mem_sup_right (submodule.mem_comap.mpr (by simp)), },\nend\n\nlemma fst_inf_snd : submodule.fst R M M₂ ⊓ submodule.snd R M M₂ = ⊥ := by tidy\n\nlemma le_prod_iff {p₁ : submodule R M} {p₂ : submodule R M₂} {q : submodule R (M × M₂)} :\n  q ≤ p₁.prod p₂ ↔ map (linear_map.fst R M M₂) q ≤ p₁ ∧ map (linear_map.snd R M M₂) q ≤ p₂ :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros x ⟨⟨y1,y2⟩, ⟨hy1,rfl⟩⟩, exact (h hy1).1 },\n    { rintros x ⟨⟨y1,y2⟩, ⟨hy1,rfl⟩⟩, exact (h hy1).2 }, },\n  { rintros ⟨hH, hK⟩ ⟨x1, x2⟩ h, exact ⟨hH ⟨_ , h, rfl⟩, hK ⟨ _, h, rfl⟩⟩, }\nend\n\nlemma prod_le_iff {p₁ : submodule R M} {p₂ : submodule R M₂} {q : submodule R (M × M₂)} :\n  p₁.prod p₂ ≤ q ↔ map (linear_map.inl R M M₂) p₁ ≤ q ∧ map (linear_map.inr R M M₂) p₂ ≤ q :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros _ ⟨x, hx, rfl⟩, apply h, exact ⟨hx, zero_mem p₂⟩, },\n    { rintros _ ⟨x, hx, rfl⟩, apply h, exact ⟨zero_mem p₁, hx⟩, }, },\n  { rintros ⟨hH, hK⟩ ⟨x1, x2⟩ ⟨h1, h2⟩,\n    have h1' : (linear_map.inl R _ _) x1 ∈ q, { apply hH, simpa using h1, },\n    have h2' : (linear_map.inr R _ _) x2 ∈ q, { apply hK, simpa using h2, },\n    simpa using add_mem h1' h2', }\nend\n\nlemma prod_eq_bot_iff {p₁ : submodule R M} {p₂ : submodule R M₂} :\n  p₁.prod p₂ = ⊥ ↔ p₁ = ⊥ ∧ p₂ = ⊥ :=\nby simp only [eq_bot_iff, prod_le_iff, (gc_map_comap _).le_iff_le, comap_bot, ker_inl, ker_inr]\n\nlemma prod_eq_top_iff {p₁ : submodule R M} {p₂ : submodule R M₂} :\n  p₁.prod p₂ = ⊤ ↔ p₁ = ⊤ ∧ p₂ = ⊤ :=\nby simp only [eq_top_iff, le_prod_iff, ← (gc_map_comap _).le_iff_le, map_top, range_fst, range_snd]\n\nend submodule\n\nnamespace linear_equiv\n\n/-- Product of modules is commutative up to linear isomorphism. -/\n@[simps apply]\ndef prod_comm (R M N : Type*) [semiring R] [add_comm_monoid M] [add_comm_monoid N]\n  [module R M] [module R N] : (M × N) ≃ₗ[R] (N × M) :=\n{ to_fun := prod.swap,\n  map_smul' := λ r ⟨m, n⟩, rfl,\n  ..add_equiv.prod_comm }\n\nsection\n\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\nvariables {module_M : module R M} {module_M₂ : module R M₂}\nvariables {module_M₃ : module R M₃} {module_M₄ : module R M₄}\nvariables (e₁ : M ≃ₗ[R] M₂) (e₂ : M₃ ≃ₗ[R] M₄)\n\n/-- Product of linear equivalences; the maps come from `equiv.prod_congr`. -/\nprotected def prod :\n  (M × M₃) ≃ₗ[R] (M₂ × M₄) :=\n{ map_smul' := λ c x, prod.ext (e₁.map_smulₛₗ c _) (e₂.map_smulₛₗ c _),\n  .. e₁.to_add_equiv.prod_congr e₂.to_add_equiv }\n\nlemma prod_symm : (e₁.prod e₂).symm = e₁.symm.prod e₂.symm := rfl\n\n@[simp] lemma prod_apply (p) :\n  e₁.prod e₂ p = (e₁ p.1, e₂ p.2) := rfl\n\n@[simp, norm_cast] lemma coe_prod :\n  (e₁.prod e₂ : (M × M₃) →ₗ[R] (M₂ × M₄)) = (e₁ : M →ₗ[R] M₂).prod_map (e₂ : M₃ →ₗ[R] M₄) := rfl\n\nend\n\nsection\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_group M₄]\nvariables {module_M : module R M} {module_M₂ : module R M₂}\nvariables {module_M₃ : module R M₃} {module_M₄ : module R M₄}\nvariables (e₁ : M ≃ₗ[R] M₂) (e₂ : M₃ ≃ₗ[R] M₄)\n\n/-- Equivalence given by a block lower diagonal matrix. `e₁` and `e₂` are diagonal square blocks,\n  and `f` is a rectangular block below the diagonal. -/\nprotected def skew_prod (f : M →ₗ[R] M₄) :\n  (M × M₃) ≃ₗ[R] M₂ × M₄ :=\n{ inv_fun := λ p : M₂ × M₄, (e₁.symm p.1, e₂.symm (p.2 - f (e₁.symm p.1))),\n  left_inv := λ p, by simp,\n  right_inv := λ p, by simp,\n  .. ((e₁ : M →ₗ[R] M₂).comp (linear_map.fst R M M₃)).prod\n    ((e₂ : M₃ →ₗ[R] M₄).comp (linear_map.snd R M M₃) +\n      f.comp (linear_map.fst R M M₃)) }\n\n@[simp] lemma skew_prod_apply (f : M →ₗ[R] M₄) (x) :\n  e₁.skew_prod e₂ f x = (e₁ x.1, e₂ x.2 + f x.1) := rfl\n\n@[simp] lemma skew_prod_symm_apply (f : M →ₗ[R] M₄) (x) :\n  (e₁.skew_prod e₂ f).symm x = (e₁.symm x.1, e₂.symm (x.2 - f (e₁.symm x.1))) := rfl\n\nend\nend linear_equiv\n\nnamespace linear_map\nopen submodule\n\nvariables [ring R]\nvariables [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃]\nvariables [module R M] [module R M₂] [module R M₃]\n\n/-- If the union of the kernels `ker f` and `ker g` spans the domain, then the range of\n`prod f g` is equal to the product of `range f` and `range g`. -/\nlemma range_prod_eq {f : M →ₗ[R] M₂} {g : M →ₗ[R] M₃} (h : ker f ⊔ ker g = ⊤) :\n  range (prod f g) = (range f).prod (range g) :=\nbegin\n  refine le_antisymm (f.range_prod_le g) _,\n  simp only [set_like.le_def, prod_apply, mem_range, set_like.mem_coe, mem_prod, exists_imp_distrib,\n    and_imp, prod.forall, pi.prod],\n  rintros _ _ x rfl y rfl,\n  simp only [prod.mk.inj_iff, ← sub_mem_ker_iff],\n  have : y - x ∈ ker f ⊔ ker g, { simp only [h, mem_top] },\n  rcases mem_sup.1 this with ⟨x', hx', y', hy', H⟩,\n  refine ⟨x' + x, _, _⟩,\n  { rwa add_sub_cancel },\n  { rwa [← eq_sub_iff_add_eq.1 H, add_sub_add_right_eq_sub, ← neg_mem_iff, neg_sub,\n      add_sub_cancel'] }\nend\n\nend linear_map\n\nnamespace linear_map\n/-!\n## Tunnels and tailings\n\nSome preliminary work for establishing the strong rank condition for noetherian rings.\n\nGiven a morphism `f : M × N →ₗ[R] M` which is `i : injective f`,\nwe can find an infinite decreasing `tunnel f i n` of copies of `M` inside `M`,\nand sitting beside these, an infinite sequence of copies of `N`.\n\nWe picturesquely name these as `tailing f i n` for each individual copy of `N`,\nand `tailings f i n` for the supremum of the first `n+1` copies:\nthey are the pieces left behind, sitting inside the tunnel.\n\nBy construction, each `tailing f i (n+1)` is disjoint from `tailings f i n`;\nlater, when we assume `M` is noetherian, this implies that `N` must be trivial,\nand establishes the strong rank condition for any left-noetherian ring.\n-/\nsection tunnel\n\n-- (This doesn't work over a semiring: we need to use that `submodule R M` is a modular lattice,\n-- which requires cancellation.)\nvariables [ring R]\nvariables {N : Type*} [add_comm_group M] [module R M] [add_comm_group N] [module R N]\n\nopen function\n\n/-- An auxiliary construction for `tunnel`.\nThe composition of `f`, followed by the isomorphism back to `K`,\nfollowed by the inclusion of this submodule back into `M`. -/\ndef tunnel_aux (f : M × N →ₗ[R] M) (Kφ : Σ K : submodule R M, K ≃ₗ[R] M) :\n  M × N →ₗ[R] M :=\n(Kφ.1.subtype.comp Kφ.2.symm.to_linear_map).comp f\n\nlemma tunnel_aux_injective\n  (f : M × N →ₗ[R] M) (i : injective f) (Kφ : Σ K : submodule R M, K ≃ₗ[R] M) :\n  injective (tunnel_aux f Kφ) :=\n(subtype.val_injective.comp Kφ.2.symm.injective).comp i\n\nnoncomputable theory\n\n/-- Auxiliary definition for `tunnel`. -/\n-- Even though we have `noncomputable theory`,\n-- we get an error without another `noncomputable` here.\nnoncomputable def tunnel' (f : M × N →ₗ[R] M) (i : injective f) :\n  ℕ → Σ (K : submodule R M), K ≃ₗ[R] M\n| 0 := ⟨⊤, linear_equiv.of_top ⊤ rfl⟩\n| (n+1) :=\n⟨(submodule.fst R M N).map (tunnel_aux f (tunnel' n)),\n  ((submodule.fst R M N).equiv_map_of_injective _ (tunnel_aux_injective f i (tunnel' n))).symm.trans\n    (submodule.fst_equiv R M N)⟩\n\n/--\nGive an injective map `f : M × N →ₗ[R] M` we can find a nested sequence of submodules\nall isomorphic to `M`.\n-/\ndef tunnel (f : M × N →ₗ[R] M) (i : injective f) : ℕ →o (submodule R M)ᵒᵈ :=\n⟨λ n, (tunnel' f i n).1, monotone_nat_of_le_succ (λ n, begin\n    dsimp [tunnel', tunnel_aux],\n    rw [submodule.map_comp, submodule.map_comp],\n    apply submodule.map_subtype_le,\n  end)⟩\n\n/--\nGive an injective map `f : M × N →ₗ[R] M` we can find a sequence of submodules\nall isomorphic to `N`.\n-/\ndef tailing (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) : submodule R M :=\n(submodule.snd R M N).map (tunnel_aux f (tunnel' f i n))\n\n/-- Each `tailing f i n` is a copy of `N`. -/\ndef tailing_linear_equiv (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) : tailing f i n ≃ₗ[R] N :=\n((submodule.snd R M N).equiv_map_of_injective _\n  (tunnel_aux_injective f i (tunnel' f i n))).symm.trans (submodule.snd_equiv R M N)\n\nlemma tailing_le_tunnel (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  tailing f i n ≤ tunnel f i n :=\nbegin\n  dsimp [tailing, tunnel_aux],\n  rw [submodule.map_comp, submodule.map_comp],\n  apply submodule.map_subtype_le,\nend\n\nlemma tailing_disjoint_tunnel_succ (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  disjoint (tailing f i n) (tunnel f i (n+1)) :=\nbegin\n  rw disjoint_iff,\n  dsimp [tailing, tunnel, tunnel'],\n  rw [submodule.map_inf_eq_map_inf_comap,\n    submodule.comap_map_eq_of_injective (tunnel_aux_injective _ i _), inf_comm,\n    submodule.fst_inf_snd, submodule.map_bot],\nend\n\nlemma tailing_sup_tunnel_succ_le_tunnel (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  tailing f i n ⊔ tunnel f i (n+1) ≤ tunnel f i n :=\nbegin\n  dsimp [tailing, tunnel, tunnel', tunnel_aux],\n  rw [←submodule.map_sup, sup_comm, submodule.fst_sup_snd, submodule.map_comp, submodule.map_comp],\n  apply submodule.map_subtype_le,\nend\n\n/-- The supremum of all the copies of `N` found inside the tunnel. -/\ndef tailings (f : M × N →ₗ[R] M) (i : injective f) : ℕ → submodule R M :=\npartial_sups (tailing f i)\n\n@[simp] lemma tailings_zero (f : M × N →ₗ[R] M) (i : injective f) :\n  tailings f i 0 = tailing f i 0 :=\nby simp [tailings]\n\n@[simp] lemma tailings_succ (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  tailings f i (n+1) = tailings f i n ⊔ tailing f i (n+1) :=\nby simp [tailings]\n\nlemma tailings_disjoint_tunnel (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  disjoint (tailings f i n) (tunnel f i (n+1)) :=\nbegin\n  induction n with n ih,\n  { simp only [tailings_zero],\n    apply tailing_disjoint_tunnel_succ, },\n  { simp only [tailings_succ],\n    refine disjoint.disjoint_sup_left_of_disjoint_sup_right _ _,\n    apply tailing_disjoint_tunnel_succ,\n    apply disjoint.mono_right _ ih,\n    apply tailing_sup_tunnel_succ_le_tunnel, },\nend\n\nlemma tailings_disjoint_tailing (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  disjoint (tailings f i n) (tailing f i (n+1)) :=\ndisjoint.mono_right (tailing_le_tunnel f i _) (tailings_disjoint_tunnel f i _)\n\nend tunnel\n\nsection graph\n\nvariables [semiring R] [add_comm_monoid M] [add_comm_monoid M₂]\n  [add_comm_group M₃] [add_comm_group M₄] [module R M] [module R M₂]\n  [module R M₃] [module R M₄] (f : M →ₗ[R] M₂) (g : M₃ →ₗ[R] M₄)\n\n/-- Graph of a linear map. -/\ndef graph : submodule R (M × M₂) :=\n{ carrier := {p | p.2 = f p.1},\n  add_mem' := λ a b (ha : _ = _) (hb : _ = _),\n  begin\n    change _ + _ = f (_ + _),\n    rw [map_add, ha, hb]\n  end,\n  zero_mem' := eq.symm (map_zero f),\n  smul_mem' := λ c x (hx : _ = _),\n  begin\n    change _ • _ = f (_ • _),\n    rw [map_smul, hx]\n  end }\n\n@[simp] lemma mem_graph_iff (x : M × M₂) : x ∈ f.graph ↔ x.2 = f x.1 := iff.rfl\n\nlemma graph_eq_ker_coprod : g.graph = ((-g).coprod linear_map.id).ker :=\nbegin\n  ext x,\n  change _ = _ ↔ -(g x.1) + x.2 = _,\n  rw [add_comm, add_neg_eq_zero]\nend\n\nlemma graph_eq_range_prod : f.graph = (linear_map.id.prod f).range :=\nbegin\n  ext x,\n  exact ⟨λ hx, ⟨x.1, prod.ext rfl hx.symm⟩, λ ⟨u, hu⟩, hu ▸ rfl⟩\nend\n\nend graph\n\nend linear_map\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/linear_algebra/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.7217432003123989, "lm_q1q2_score": 0.4827597892738418}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Minchao Wu\n\n! This file was ported from Lean 3 source module data.prod.lex\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.BoundedOrder\n\n/-!\n# Lexicographic order\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the lexicographic relation for pairs of orders, partial orders and linear orders.\n\n## Main declarations\n\n* `prod.lex.<pre/partial_/linear_>order`: Instances lifting the orders on `α` and `β` to `α ×ₗ β`.\n\n## Notation\n\n* `α ×ₗ β`: `α × β` equipped with the lexicographic order\n\n## See also\n\nRelated files are:\n* `data.finset.colex`: Colexicographic order on finite sets.\n* `data.list.lex`: Lexicographic order on lists.\n* `data.pi.lex`: Lexicographic order on `Πₗ i, α i`.\n* `data.psigma.order`: Lexicographic order on `Σ' i, α i`.\n* `data.sigma.order`: Lexicographic order on `Σ i, α i`.\n-/\n\n\nvariable {α β γ : Type _}\n\nnamespace Prod.Lex\n\n-- mathport name: «expr ×ₗ »\nnotation:35 α \" ×ₗ \" β:34 => Lex (Prod α β)\n\nunsafe instance [has_to_format α] [has_to_format β] : has_to_format (α ×ₗ β) :=\n  prod.has_to_format\n\n#print Prod.Lex.decidableEq /-\ninstance decidableEq (α β : Type _) [DecidableEq α] [DecidableEq β] : DecidableEq (α ×ₗ β) :=\n  Prod.decidableEq\n#align prod.lex.decidable_eq Prod.Lex.decidableEq\n-/\n\n#print Prod.Lex.inhabited /-\ninstance inhabited (α β : Type _) [Inhabited α] [Inhabited β] : Inhabited (α ×ₗ β) :=\n  Prod.inhabited\n#align prod.lex.inhabited Prod.Lex.inhabited\n-/\n\n#print Prod.Lex.instLE /-\n/-- Dictionary / lexicographic ordering on pairs.  -/\ninstance instLE (α β : Type _) [LT α] [LE β] : LE (α ×ₗ β) where le := Prod.Lex (· < ·) (· ≤ ·)\n#align prod.lex.has_le Prod.Lex.instLE\n-/\n\n#print Prod.Lex.instLT /-\ninstance instLT (α β : Type _) [LT α] [LT β] : LT (α ×ₗ β) where lt := Prod.Lex (· < ·) (· < ·)\n#align prod.lex.has_lt Prod.Lex.instLT\n-/\n\n/- warning: prod.lex.le_iff -> Prod.Lex.le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LT.{u1} α] [_inst_2 : LE.{u2} β] (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β), Iff (LE.le.{max u1 u2} (Lex.{max u1 u2} (Prod.{u1, u2} α β)) (Prod.Lex.instLE.{u1, u2} α β _inst_1 _inst_2) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) => (Prod.{u1, u2} α β) -> (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (toLex.{max u1 u2} (Prod.{u1, u2} α β)) a) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) => (Prod.{u1, u2} α β) -> (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (toLex.{max u1 u2} (Prod.{u1, u2} α β)) b)) (Or (LT.lt.{u1} α _inst_1 (Prod.fst.{u1, u2} α β a) (Prod.fst.{u1, u2} α β b)) (And (Eq.{succ u1} α (Prod.fst.{u1, u2} α β a) (Prod.fst.{u1, u2} α β b)) (LE.le.{u2} β _inst_2 (Prod.snd.{u1, u2} α β a) (Prod.snd.{u1, u2} α β b))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LT.{u2} α] [_inst_2 : LE.{u1} β] (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β), Iff (LE.le.{max u2 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) a) (Prod.Lex.instLE.{u2, u1} α β _inst_1 _inst_2) (FunLike.coe.{succ (max u2 u1), succ (max u2 u1), succ (max u2 u1)} (Equiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (toLex.{max u2 u1} (Prod.{u2, u1} α β)) a) (FunLike.coe.{succ (max u2 u1), succ (max u2 u1), succ (max u2 u1)} (Equiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (toLex.{max u2 u1} (Prod.{u2, u1} α β)) b)) (Or (LT.lt.{u2} α _inst_1 (Prod.fst.{u2, u1} α β a) (Prod.fst.{u2, u1} α β b)) (And (Eq.{succ u2} α (Prod.fst.{u2, u1} α β a) (Prod.fst.{u2, u1} α β b)) (LE.le.{u1} β _inst_2 (Prod.snd.{u2, u1} α β a) (Prod.snd.{u2, u1} α β b))))\nCase conversion may be inaccurate. Consider using '#align prod.lex.le_iff Prod.Lex.le_iffₓ'. -/\ntheorem le_iff [LT α] [LE β] (a b : α × β) :\n    toLex a ≤ toLex b ↔ a.1 < b.1 ∨ a.1 = b.1 ∧ a.2 ≤ b.2 :=\n  Prod.lex_def (· < ·) (· ≤ ·)\n#align prod.lex.le_iff Prod.Lex.le_iff\n\n/- warning: prod.lex.lt_iff -> Prod.Lex.lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LT.{u1} α] [_inst_2 : LT.{u2} β] (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β), Iff (LT.lt.{max u1 u2} (Lex.{max u1 u2} (Prod.{u1, u2} α β)) (Prod.Lex.instLT.{u1, u2} α β _inst_1 _inst_2) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) => (Prod.{u1, u2} α β) -> (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (toLex.{max u1 u2} (Prod.{u1, u2} α β)) a) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) => (Prod.{u1, u2} α β) -> (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (toLex.{max u1 u2} (Prod.{u1, u2} α β)) b)) (Or (LT.lt.{u1} α _inst_1 (Prod.fst.{u1, u2} α β a) (Prod.fst.{u1, u2} α β b)) (And (Eq.{succ u1} α (Prod.fst.{u1, u2} α β a) (Prod.fst.{u1, u2} α β b)) (LT.lt.{u2} β _inst_2 (Prod.snd.{u1, u2} α β a) (Prod.snd.{u1, u2} α β b))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LT.{u2} α] [_inst_2 : LT.{u1} β] (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β), Iff (LT.lt.{max u2 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) a) (Prod.Lex.instLT.{u2, u1} α β _inst_1 _inst_2) (FunLike.coe.{succ (max u2 u1), succ (max u2 u1), succ (max u2 u1)} (Equiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (toLex.{max u2 u1} (Prod.{u2, u1} α β)) a) (FunLike.coe.{succ (max u2 u1), succ (max u2 u1), succ (max u2 u1)} (Equiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (toLex.{max u2 u1} (Prod.{u2, u1} α β)) b)) (Or (LT.lt.{u2} α _inst_1 (Prod.fst.{u2, u1} α β a) (Prod.fst.{u2, u1} α β b)) (And (Eq.{succ u2} α (Prod.fst.{u2, u1} α β a) (Prod.fst.{u2, u1} α β b)) (LT.lt.{u1} β _inst_2 (Prod.snd.{u2, u1} α β a) (Prod.snd.{u2, u1} α β b))))\nCase conversion may be inaccurate. Consider using '#align prod.lex.lt_iff Prod.Lex.lt_iffₓ'. -/\ntheorem lt_iff [LT α] [LT β] (a b : α × β) :\n    toLex a < toLex b ↔ a.1 < b.1 ∨ a.1 = b.1 ∧ a.2 < b.2 :=\n  Prod.lex_def (· < ·) (· < ·)\n#align prod.lex.lt_iff Prod.Lex.lt_iff\n\n#print Prod.Lex.preorder /-\n/-- Dictionary / lexicographic preorder for pairs. -/\ninstance preorder (α β : Type _) [Preorder α] [Preorder β] : Preorder (α ×ₗ β) :=\n  { Prod.Lex.instLE α β,\n    Prod.Lex.instLT α β with\n    le_refl := refl_of <| Prod.Lex _ _\n    le_trans := fun _ _ _ => trans_of <| Prod.Lex _ _\n    lt_iff_le_not_le := fun x₁ x₂ =>\n      match x₁, x₂ with\n      | toLex (a₁, b₁), toLex (a₂, b₂) => by\n        constructor\n        · rintro (⟨_, _, hlt⟩ | ⟨_, hlt⟩)\n          · constructor\n            · left\n              assumption\n            · rintro ⟨⟩\n              · apply lt_asymm hlt\n                assumption\n              · apply lt_irrefl _ hlt\n          · constructor\n            · right\n              rw [lt_iff_le_not_le] at hlt\n              exact hlt.1\n            · rintro ⟨⟩\n              · apply lt_irrefl a₁\n                assumption\n              · rw [lt_iff_le_not_le] at hlt\n                apply hlt.2\n                assumption\n        · rintro ⟨⟨⟩, h₂r⟩\n          · left\n            assumption\n          · right\n            rw [lt_iff_le_not_le]\n            constructor\n            · assumption\n            · intro h\n              apply h₂r\n              right\n              exact h }\n#align prod.lex.preorder Prod.Lex.preorder\n-/\n\nsection Preorder\n\nvariable [PartialOrder α] [Preorder β]\n\n/- warning: prod.lex.to_lex_mono -> Prod.Lex.toLex_mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : Preorder.{u2} β], Monotone.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β)) (Prod.preorder.{u1, u2} α β (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2) (Prod.Lex.preorder.{u1, u2} α β (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) => (Prod.{u1, u2} α β) -> (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (toLex.{max u1 u2} (Prod.{u1, u2} α β)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : PartialOrder.{u2} α] [_inst_2 : Preorder.{u1} β], Monotone.{max u2 u1, max u2 u1} (Prod.{u2, u1} α β) (Lex.{max u1 u2} (Prod.{u2, u1} α β)) (Prod.instPreorderProd.{u2, u1} α β (PartialOrder.toPreorder.{u2} α _inst_1) _inst_2) (Prod.Lex.preorder.{u2, u1} α β (PartialOrder.toPreorder.{u2} α _inst_1) _inst_2) (FunLike.coe.{succ (max u2 u1), succ (max u2 u1), succ (max u2 u1)} (Equiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (toLex.{max u2 u1} (Prod.{u2, u1} α β)))\nCase conversion may be inaccurate. Consider using '#align prod.lex.to_lex_mono Prod.Lex.toLex_monoₓ'. -/\ntheorem toLex_mono : Monotone (toLex : α × β → α ×ₗ β) :=\n  by\n  rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ ⟨ha, hb⟩\n  obtain rfl | ha : a₁ = a₂ ∨ _ := ha.eq_or_lt\n  · exact right _ hb\n  · exact left _ _ ha\n#align prod.lex.to_lex_mono Prod.Lex.toLex_mono\n\n/- warning: prod.lex.to_lex_strict_mono -> Prod.Lex.toLex_strictMono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : Preorder.{u2} β], StrictMono.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β)) (Prod.preorder.{u1, u2} α β (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2) (Prod.Lex.preorder.{u1, u2} α β (PartialOrder.toPreorder.{u1} α _inst_1) _inst_2) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) => (Prod.{u1, u2} α β) -> (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} α β) (Lex.{max u1 u2} (Prod.{u1, u2} α β))) (toLex.{max u1 u2} (Prod.{u1, u2} α β)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : PartialOrder.{u2} α] [_inst_2 : Preorder.{u1} β], StrictMono.{max u2 u1, max u2 u1} (Prod.{u2, u1} α β) (Lex.{max u1 u2} (Prod.{u2, u1} α β)) (Prod.instPreorderProd.{u2, u1} α β (PartialOrder.toPreorder.{u2} α _inst_1) _inst_2) (Prod.Lex.preorder.{u2, u1} α β (PartialOrder.toPreorder.{u2} α _inst_1) _inst_2) (FunLike.coe.{succ (max u2 u1), succ (max u2 u1), succ (max u2 u1)} (Equiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (Prod.{u2, u1} α β) (fun (_x : Prod.{u2, u1} α β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} α β) => Lex.{max u2 u1} (Prod.{u2, u1} α β)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} α β) (Lex.{max u2 u1} (Prod.{u2, u1} α β))) (toLex.{max u2 u1} (Prod.{u2, u1} α β)))\nCase conversion may be inaccurate. Consider using '#align prod.lex.to_lex_strict_mono Prod.Lex.toLex_strictMonoₓ'. -/\ntheorem toLex_strictMono : StrictMono (toLex : α × β → α ×ₗ β) :=\n  by\n  rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ h\n  obtain rfl | ha : a₁ = a₂ ∨ _ := h.le.1.eq_or_lt\n  · exact right _ (Prod.mk_lt_mk_iff_right.1 h)\n  · exact left _ _ ha\n#align prod.lex.to_lex_strict_mono Prod.Lex.toLex_strictMono\n\nend Preorder\n\n#print Prod.Lex.partialOrder /-\n/-- Dictionary / lexicographic partial_order for pairs. -/\ninstance partialOrder (α β : Type _) [PartialOrder α] [PartialOrder β] : PartialOrder (α ×ₗ β) :=\n  { Prod.Lex.preorder α β with\n    le_antisymm :=\n      by\n      haveI : IsStrictOrder α (· < ·) :=\n        { irrefl := lt_irrefl\n          trans := fun _ _ _ => lt_trans }\n      haveI : IsAntisymm β (· ≤ ·) := ⟨fun _ _ => le_antisymm⟩\n      exact @antisymm _ (Prod.Lex _ _) _ }\n#align prod.lex.partial_order Prod.Lex.partialOrder\n-/\n\n#print Prod.Lex.linearOrder /-\n/-- Dictionary / lexicographic linear_order for pairs. -/\ninstance linearOrder (α β : Type _) [LinearOrder α] [LinearOrder β] : LinearOrder (α ×ₗ β) :=\n  { Prod.Lex.partialOrder α β with\n    le_total := total_of (Prod.Lex _ _)\n    decidableLe := Prod.Lex.decidable _ _\n    decidableLt := Prod.Lex.decidable _ _\n    DecidableEq := Lex.decidableEq _ _ }\n#align prod.lex.linear_order Prod.Lex.linearOrder\n-/\n\n#print Prod.Lex.orderBot /-\ninstance orderBot [PartialOrder α] [Preorder β] [OrderBot α] [OrderBot β] : OrderBot (α ×ₗ β)\n    where\n  bot := toLex ⊥\n  bot_le a := toLex_mono bot_le\n#align prod.lex.order_bot Prod.Lex.orderBot\n-/\n\n#print Prod.Lex.orderTop /-\ninstance orderTop [PartialOrder α] [Preorder β] [OrderTop α] [OrderTop β] : OrderTop (α ×ₗ β)\n    where\n  top := toLex ⊤\n  le_top a := toLex_mono le_top\n#align prod.lex.order_top Prod.Lex.orderTop\n-/\n\n#print Prod.Lex.boundedOrder /-\ninstance boundedOrder [PartialOrder α] [Preorder β] [BoundedOrder α] [BoundedOrder β] :\n    BoundedOrder (α ×ₗ β) :=\n  { Lex.orderBot, Lex.orderTop with }\n#align prod.lex.bounded_order Prod.Lex.boundedOrder\n-/\n\ninstance [Preorder α] [Preorder β] [DenselyOrdered α] [DenselyOrdered β] :\n    DenselyOrdered (α ×ₗ β) :=\n  ⟨by\n    rintro _ _ (@⟨a₁, b₁, a₂, b₂, h⟩ | @⟨a, b₁, b₂, h⟩)\n    · obtain ⟨c, h₁, h₂⟩ := exists_between h\n      exact ⟨(c, b₁), left _ _ h₁, left _ _ h₂⟩\n    · obtain ⟨c, h₁, h₂⟩ := exists_between h\n      exact ⟨(a, c), right _ h₁, right _ h₂⟩⟩\n\n#print Prod.Lex.noMaxOrder_of_left /-\ninstance noMaxOrder_of_left [Preorder α] [Preorder β] [NoMaxOrder α] : NoMaxOrder (α ×ₗ β) :=\n  ⟨by\n    rintro ⟨a, b⟩\n    obtain ⟨c, h⟩ := exists_gt a\n    exact ⟨⟨c, b⟩, left _ _ h⟩⟩\n#align prod.lex.no_max_order_of_left Prod.Lex.noMaxOrder_of_left\n-/\n\n#print Prod.Lex.noMinOrder_of_left /-\ninstance noMinOrder_of_left [Preorder α] [Preorder β] [NoMinOrder α] : NoMinOrder (α ×ₗ β) :=\n  ⟨by\n    rintro ⟨a, b⟩\n    obtain ⟨c, h⟩ := exists_lt a\n    exact ⟨⟨c, b⟩, left _ _ h⟩⟩\n#align prod.lex.no_min_order_of_left Prod.Lex.noMinOrder_of_left\n-/\n\n#print Prod.Lex.noMaxOrder_of_right /-\ninstance noMaxOrder_of_right [Preorder α] [Preorder β] [NoMaxOrder β] : NoMaxOrder (α ×ₗ β) :=\n  ⟨by\n    rintro ⟨a, b⟩\n    obtain ⟨c, h⟩ := exists_gt b\n    exact ⟨⟨a, c⟩, right _ h⟩⟩\n#align prod.lex.no_max_order_of_right Prod.Lex.noMaxOrder_of_right\n-/\n\n#print Prod.Lex.noMinOrder_of_right /-\ninstance noMinOrder_of_right [Preorder α] [Preorder β] [NoMinOrder β] : NoMinOrder (α ×ₗ β) :=\n  ⟨by\n    rintro ⟨a, b⟩\n    obtain ⟨c, h⟩ := exists_lt b\n    exact ⟨⟨a, c⟩, right _ h⟩⟩\n#align prod.lex.no_min_order_of_right Prod.Lex.noMinOrder_of_right\n-/\n\nend Prod.Lex\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Prod/Lex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4827597885132836}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\nimport algebraic_geometry.Gamma_Spec_adjunction\nimport algebraic_geometry.open_immersion\nimport category_theory.limits.opposites\n\n/-!\n# Affine schemes\n\nWe define the category of `AffineScheme`s as the essential image of `Spec`.\nWe also define predicates about affine schemes and affine open sets.\n\n## Main definitions\n\n* `algebraic_geometry.AffineScheme`: The category of affine schemes.\n* `algebraic_geometry.is_affine`: A scheme is affine if the canonical map `X ⟶ Spec Γ(X)` is an\n  isomorphism.\n* `algebraic_geometry.Scheme.iso_Spec`: The canonical isomorphism `X ≅ Spec Γ(X)` for an affine\n  scheme.\n* `algebraic_geometry.AffineScheme.equiv_CommRing`: The equivalence of categories\n  `AffineScheme ≌ CommRingᵒᵖ` given by `AffineScheme.Spec : CommRingᵒᵖ ⥤ AffineScheme` and\n  `AffineScheme.Γ : AffineSchemeᵒᵖ ⥤ CommRing`.\n* `algebraic_geometry.is_affine_open`: An open subset of a scheme is affine if the open subscheme is\n  affine.\n* `algebraic_geometry.is_affine_open.from_Spec`: The immersion `Spec 𝒪ₓ(U) ⟶ X` for an affine `U`.\n\n-/\n\nnoncomputable theory\n\nopen category_theory category_theory.limits opposite topological_space\n\nuniverse u\n\nnamespace algebraic_geometry\n\n/-- The category of affine schemes -/\ndef AffineScheme := Scheme.Spec.ess_image\n\n/-- A Scheme is affine if the canonical map `X ⟶ Spec Γ(X)` is an isomorphism. -/\nclass is_affine (X : Scheme) : Prop :=\n(affine : is_iso (Γ_Spec.adjunction.unit.app X))\n\nattribute [instance] is_affine.affine\n\n/-- The canonical isomorphism `X ≅ Spec Γ(X)` for an affine scheme. -/\ndef Scheme.iso_Spec (X : Scheme) [is_affine X] :\n  X ≅ Scheme.Spec.obj (op $ Scheme.Γ.obj $ op X) :=\nas_iso (Γ_Spec.adjunction.unit.app X)\n\nlemma mem_AffineScheme (X : Scheme) : X ∈ AffineScheme ↔ is_affine X :=\n⟨λ h, ⟨functor.ess_image.unit_is_iso h⟩, λ h, @@mem_ess_image_of_unit_is_iso _ _ _ X h.1⟩\n\ninstance is_affine_AffineScheme (X : AffineScheme.{u}) : is_affine (X : Scheme.{u}) :=\n(mem_AffineScheme _).mp X.prop\n\ninstance Spec_is_affine (R : CommRingᵒᵖ) : is_affine (Scheme.Spec.obj R) :=\n(mem_AffineScheme _).mp (Scheme.Spec.obj_mem_ess_image R)\n\nlemma is_affine_of_iso {X Y : Scheme} (f : X ⟶ Y) [is_iso f] [h : is_affine Y] :\n  is_affine X :=\nby { rw [← mem_AffineScheme] at h ⊢, exact functor.ess_image.of_iso (as_iso f).symm h }\n\nnamespace AffineScheme\n\n/-- The `Spec` functor into the category of affine schemes. -/\n@[derive [full, faithful, ess_surj], simps]\ndef Spec : CommRingᵒᵖ ⥤ AffineScheme := Scheme.Spec.to_ess_image\n\n/-- The forgetful functor `AffineScheme ⥤ Scheme`. -/\n@[derive [full, faithful], simps]\ndef forget_to_Scheme : AffineScheme ⥤ Scheme := Scheme.Spec.ess_image_inclusion\n\n/-- The global section functor of an affine scheme. -/\ndef Γ : AffineSchemeᵒᵖ ⥤ CommRing := forget_to_Scheme.op ⋙ Scheme.Γ\n\n/-- The category of affine schemes is equivalent to the category of commutative rings. -/\ndef equiv_CommRing : AffineScheme ≌ CommRingᵒᵖ :=\nequiv_ess_image_of_reflective.symm\n\ninstance Γ_is_equiv : is_equivalence Γ.{u} :=\nbegin\n  haveI : is_equivalence Γ.{u}.right_op.op := is_equivalence.of_equivalence equiv_CommRing.op,\n  exact (functor.is_equivalence_trans Γ.{u}.right_op.op (op_op_equivalence _).functor : _),\nend\n\ninstance : has_colimits AffineScheme.{u} :=\nbegin\n  haveI := adjunction.has_limits_of_equivalence.{u} Γ.{u},\n  haveI : has_colimits AffineScheme.{u} ᵒᵖᵒᵖ := has_colimits_op_of_has_limits,\n  exactI adjunction.has_colimits_of_equivalence.{u} (op_op_equivalence AffineScheme.{u}).inverse\nend\n\ninstance : has_limits AffineScheme.{u} :=\nbegin\n  haveI := adjunction.has_colimits_of_equivalence Γ.{u},\n  haveI : has_limits AffineScheme.{u} ᵒᵖᵒᵖ := limits.has_limits_op_of_has_colimits,\n  exactI adjunction.has_limits_of_equivalence (op_op_equivalence AffineScheme.{u}).inverse\nend\n\nend AffineScheme\n\n/-- An open subset of a scheme is affine if the open subscheme is affine. -/\ndef is_affine_open {X : Scheme} (U : opens X.carrier) : Prop :=\nis_affine (X.restrict U.open_embedding)\n\nlemma range_is_affine_open_of_open_immersion {X Y : Scheme} [is_affine X] (f : X ⟶ Y)\n  [H : is_open_immersion f] : is_affine_open ⟨set.range f.1.base, H.base_open.open_range⟩ :=\nbegin\n  refine is_affine_of_iso (is_open_immersion.iso_of_range_eq f (Y.of_restrict _) _).inv,\n  exact subtype.range_coe.symm,\n  apply_instance\nend\n\nlemma top_is_affine_open (X : Scheme) [is_affine X] : is_affine_open (⊤ : opens X.carrier) :=\nbegin\n  convert range_is_affine_open_of_open_immersion (𝟙 X),\n  ext1,\n  exact set.range_id.symm\nend\n\ninstance Scheme.affine_basis_cover_is_affine (X : Scheme) (i : X.affine_basis_cover.J) :\n  is_affine (X.affine_basis_cover.obj i) :=\nalgebraic_geometry.Spec_is_affine _\n\nlemma is_basis_affine_open (X : Scheme) :\n  opens.is_basis { U : opens X.carrier | is_affine_open U } :=\nbegin\n  rw opens.is_basis_iff_nbhd,\n  rintros U x (hU : x ∈ (U : set X.carrier)),\n  obtain ⟨S, hS, hxS, hSU⟩ := X.affine_basis_cover_is_basis.exists_subset_of_mem_open hU U.prop,\n  refine ⟨⟨S, X.affine_basis_cover_is_basis.is_open hS⟩, _, hxS, hSU⟩,\n  rcases hS with ⟨i, rfl⟩,\n  exact range_is_affine_open_of_open_immersion _,\nend\n\n/-- The open immersion `Spec 𝒪ₓ(U) ⟶ X` for an affine `U`. -/\ndef is_affine_open.from_Spec {X : Scheme} {U : opens X.carrier} (hU : is_affine_open U) :\n  Scheme.Spec.obj (op $ X.presheaf.obj $ op U) ⟶ X :=\nbegin\n  haveI : is_affine (X.restrict U.open_embedding) := hU,\n  have : U.open_embedding.is_open_map.functor.obj ⊤ = U,\n  { ext1, exact set.image_univ.trans subtype.range_coe },\n  exact Scheme.Spec.map (X.presheaf.map (eq_to_hom this.symm).op).op ≫\n    (X.restrict U.open_embedding).iso_Spec.inv ≫ X.of_restrict _\nend\n\ninstance is_affine_open.is_open_immersion_from_Spec {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) :\n  is_open_immersion hU.from_Spec :=\nby { delta is_affine_open.from_Spec, apply_instance }\n\nlemma is_affine_open.from_Spec_range {X : Scheme} {U : opens X.carrier} (hU : is_affine_open U) :\n  set.range hU.from_Spec.1.base = (U : set X.carrier) :=\nbegin\n  delta is_affine_open.from_Spec,\n  erw [← category.assoc, Scheme.comp_val_base],\n  rw [coe_comp, set.range_comp, set.range_iff_surjective.mpr, set.image_univ],\n  exact subtype.range_coe,\n  rw ← Top.epi_iff_surjective,\n  apply_instance\nend\n\nlemma is_affine_open.from_Spec_image_top {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) :\n  hU.is_open_immersion_from_Spec.base_open.is_open_map.functor.obj ⊤ = U :=\nby { ext1, exact set.image_univ.trans hU.from_Spec_range }\n\nlemma is_affine_open.is_compact {X : Scheme} {U : opens X.carrier} (hU : is_affine_open U) :\n  is_compact (U : set X.carrier) :=\nbegin\n  convert @is_compact.image _ _ _ _ set.univ hU.from_Spec.1.base\n    prime_spectrum.compact_space.1 (by continuity),\n  convert hU.from_Spec_range.symm,\n  exact set.image_univ\nend\n\ninstance Scheme.quasi_compact_of_affine (X : Scheme) [is_affine X] : compact_space X.carrier :=\n⟨(top_is_affine_open X).is_compact⟩\n\nlemma is_affine_open.from_Spec_base_preimage\n  {X : Scheme} {U : opens X.carrier} (hU : is_affine_open U) :\n    (opens.map hU.from_Spec.val.base).obj U = ⊤ :=\nbegin\n  ext1,\n  change hU.from_Spec.1.base ⁻¹' (U : set X.carrier) = set.univ,\n  rw [← hU.from_Spec_range, ← set.image_univ],\n  exact set.preimage_image_eq _ PresheafedSpace.is_open_immersion.base_open.inj\nend\n\nlemma Scheme.Spec_map_presheaf_map_eq_to_hom {X : Scheme} {U V : opens X.carrier} (h : U = V) (W) :\n  (Scheme.Spec.map (X.presheaf.map (eq_to_hom h).op).op).val.c.app W =\n    eq_to_hom (by { cases h, dsimp, induction W using opposite.rec, congr, ext1, simpa }) :=\nbegin\n  have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _,\n  { rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]  },\n  cases h,\n  refine (Scheme.congr_app this _).trans _,\n  erw category.id_comp,\n  simpa\nend\n\nlemma is_affine_open.Spec_Γ_identity_hom_app_from_Spec {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) :\n  (Spec_Γ_identity.hom.app (X.presheaf.obj $ op U)) ≫ hU.from_Spec.1.c.app (op U) =\n    (Scheme.Spec.obj _).presheaf.map (eq_to_hom hU.from_Spec_base_preimage).op :=\nbegin\n  haveI : is_affine _ := hU,\n  have e₁ :=\n    Spec_Γ_identity.hom.naturality (X.presheaf.map (eq_to_hom U.open_embedding_obj_top).op),\n  rw ← is_iso.comp_inv_eq at e₁,\n  have e₂ := Γ_Spec.adjunction_unit_app_app_top (X.restrict U.open_embedding),\n  erw ← e₂ at e₁,\n  simp only [functor.id_map, quiver.hom.unop_op, functor.comp_map, ← functor.map_inv, ← op_inv,\n    LocallyRingedSpace.Γ_map, category.assoc, functor.right_op_map, inv_eq_to_hom] at e₁,\n  delta is_affine_open.from_Spec Scheme.iso_Spec,\n  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app, ← e₁],\n  simp_rw category.assoc,\n  erw ← X.presheaf.map_comp_assoc,\n  rw ← op_comp,\n  have e₃ : U.open_embedding.is_open_map.adjunction.counit.app U ≫\n    eq_to_hom U.open_embedding_obj_top.symm =\n    U.open_embedding.is_open_map.functor.map (eq_to_hom U.inclusion_map_eq_top) :=\n    subsingleton.elim _ _,\n  have e₄ : X.presheaf.map _ ≫ _ = _ :=\n    (as_iso (Γ_Spec.adjunction.unit.app (X.restrict U.open_embedding)))\n    .inv.1.c.naturality_assoc (eq_to_hom U.inclusion_map_eq_top).op _,\n  erw [e₃, e₄, ← Scheme.comp_val_c_app_assoc, iso.inv_hom_id],\n  simp only [eq_to_hom_map, eq_to_hom_op, Scheme.Spec_map_presheaf_map_eq_to_hom],\n  erw [Scheme.Spec_map_presheaf_map_eq_to_hom, category.id_comp],\n  simpa only [eq_to_hom_trans]\nend\n\n@[elementwise]\nlemma is_affine_open.from_Spec_app_eq {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) :\n  hU.from_Spec.1.c.app (op U) = Spec_Γ_identity.inv.app (X.presheaf.obj $ op U) ≫\n    (Scheme.Spec.obj _).presheaf.map (eq_to_hom hU.from_Spec_base_preimage).op :=\nby rw [← hU.Spec_Γ_identity_hom_app_from_Spec, iso.inv_hom_id_app_assoc]\n\nlemma is_affine_open.basic_open_is_affine {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) (f : X.presheaf.obj (op U)) : is_affine_open (X.basic_open f) :=\nbegin\n  convert range_is_affine_open_of_open_immersion (Scheme.Spec.map (CommRing.of_hom\n    (algebra_map (X.presheaf.obj (op U)) (localization.away f))).op ≫ hU.from_Spec),\n  ext1,\n  have : hU.from_Spec.val.base '' (hU.from_Spec.val.base ⁻¹' (X.basic_open f : set X.carrier)) =\n    (X.basic_open f : set X.carrier),\n  { rw [set.image_preimage_eq_inter_range, set.inter_eq_left_iff_subset, hU.from_Spec_range],\n    exact Scheme.basic_open_subset _ _ },\n  rw [subtype.coe_mk, Scheme.comp_val_base, ← this, coe_comp, set.range_comp],\n  congr' 1,\n  refine (congr_arg coe $ Scheme.preimage_basic_open hU.from_Spec f).trans _,\n  refine eq.trans _ (prime_spectrum.localization_away_comap_range (localization.away f) f).symm,\n  congr' 1,\n  have : (opens.map hU.from_Spec.val.base).obj U = ⊤,\n  { ext1,\n    change hU.from_Spec.1.base ⁻¹' (U : set X.carrier) = set.univ,\n    rw [← hU.from_Spec_range, ← set.image_univ],\n    exact set.preimage_image_eq _ PresheafedSpace.is_open_immersion.base_open.inj },\n  refine eq.trans _ (basic_open_eq_of_affine f),\n  have lm : ∀ s, (opens.map hU.from_Spec.val.base).obj U ⊓ s = s := λ s, this.symm ▸ top_inf_eq,\n  refine eq.trans _ (lm _),\n  refine eq.trans _\n    ((Scheme.Spec.obj $ op $ X.presheaf.obj $ op U).basic_open_res _ (eq_to_hom this).op),\n  rw ← comp_apply,\n  congr' 2,\n  rw iso.eq_inv_comp,\n  erw hU.Spec_Γ_identity_hom_app_from_Spec,\nend\n\nlemma Scheme.map_prime_spectrum_basic_open_of_affine (X : Scheme) [is_affine X]\n  (f : Scheme.Γ.obj (op X)) :\n  (opens.map X.iso_Spec.hom.1.base).obj (prime_spectrum.basic_open f) = X.basic_open f :=\nbegin\n  rw ← basic_open_eq_of_affine,\n  transitivity (opens.map X.iso_Spec.hom.1.base).obj ((Scheme.Spec.obj\n    (op (Scheme.Γ.obj (op X)))).basic_open ((inv (X.iso_Spec.hom.1.c.app\n      (op ((opens.map (inv X.iso_Spec.hom).val.base).obj ⊤)))) ((X.presheaf.map (eq_to_hom _)) f))),\n  congr,\n  { rw [← is_iso.inv_eq_inv, is_iso.inv_inv, is_iso.iso.inv_inv, nat_iso.app_hom],\n    erw ← Γ_Spec.adjunction_unit_app_app_top,\n    refl },\n  { rw eq_to_hom_map, refl },\n  { dsimp, congr },\n  { refine (Scheme.preimage_basic_open _ _).trans _,\n    rw [is_iso.inv_hom_id_apply, Scheme.basic_open_res_eq] }\nend\n\nlemma is_basis_basic_open (X : Scheme) [is_affine X] :\n  opens.is_basis (set.range (X.basic_open : X.presheaf.obj (op ⊤) → opens X.carrier)) :=\nbegin\n  delta opens.is_basis,\n  convert prime_spectrum.is_basis_basic_opens.inducing\n    (Top.homeo_of_iso (Scheme.forget_to_Top.map_iso X.iso_Spec)).inducing using 1,\n  ext,\n  simp only [set.mem_image, exists_exists_eq_and],\n  split,\n  { rintro ⟨_, ⟨x, rfl⟩, rfl⟩,\n    refine ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, _⟩,\n    exact congr_arg subtype.val (X.map_prime_spectrum_basic_open_of_affine x) },\n  { rintro ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, rfl⟩,\n    refine ⟨_, ⟨x, rfl⟩, _⟩,\n    exact congr_arg subtype.val (X.map_prime_spectrum_basic_open_of_affine x).symm }\nend\n\n/-- The prime ideal of `𝒪ₓ(U)` corresponding to a point `x : U`. -/\nnoncomputable\ndef is_affine_open.prime_ideal_of {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) (x : U) :\n  prime_spectrum (X.presheaf.obj $ op U) :=\n((Scheme.Spec.map (X.presheaf.map (eq_to_hom $\n  show U.open_embedding.is_open_map.functor.obj ⊤ = U, from\n    opens.ext (set.image_univ.trans subtype.range_coe)).op).op).1.base\n  ((@@Scheme.iso_Spec (X.restrict U.open_embedding) hU).hom.1.base x))\n\nlemma is_affine_open.from_Spec_prime_ideal_of {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) (x : U) :\n  hU.from_Spec.val.base (hU.prime_ideal_of x) = x.1 :=\nbegin\n  dsimp only [is_affine_open.from_Spec, subtype.coe_mk],\n  erw [← Scheme.comp_val_base_apply, ← Scheme.comp_val_base_apply],\n  simpa only [← functor.map_comp_assoc, ← functor.map_comp, ← op_comp, eq_to_hom_trans, op_id,\n    eq_to_hom_refl, category_theory.functor.map_id, category.id_comp, iso.hom_inv_id_assoc]\nend\n\nlemma is_affine_open.is_localization_stalk_aux {X : Scheme} (U : opens X.carrier)\n  [is_affine (X.restrict U.open_embedding)] :\n  (inv (Γ_Spec.adjunction.unit.app (X.restrict U.open_embedding))).1.c.app\n    (op ((opens.map U.inclusion).obj U)) =\n      X.presheaf.map (eq_to_hom $ by rw opens.inclusion_map_eq_top :\n        U.open_embedding.is_open_map.functor.obj ⊤ ⟶\n          (U.open_embedding.is_open_map.functor.obj ((opens.map U.inclusion).obj U))).op ≫\n      to_Spec_Γ (X.presheaf.obj $ op (U.open_embedding.is_open_map.functor.obj ⊤)) ≫\n      (Scheme.Spec.obj $ op $ X.presheaf.obj $ _).presheaf.map\n        (eq_to_hom (by { rw [opens.inclusion_map_eq_top], refl }) : unop _ ⟶ ⊤).op :=\nbegin\n  have e : (opens.map (inv (Γ_Spec.adjunction.unit.app (X.restrict U.open_embedding))).1.base).obj\n    ((opens.map U.inclusion).obj U) = ⊤,\n  by { rw [opens.inclusion_map_eq_top], refl },\n  rw [Scheme.inv_val_c_app, is_iso.comp_inv_eq, Scheme.app_eq _ e,\n    Γ_Spec.adjunction_unit_app_app_top],\n  simp only [category.assoc, eq_to_hom_op],\n  erw ← functor.map_comp_assoc,\n  rw [eq_to_hom_trans, eq_to_hom_refl, category_theory.functor.map_id,\n    category.id_comp],\n  erw Spec_Γ_identity.inv_hom_id_app_assoc,\n  simp only [eq_to_hom_map, eq_to_hom_trans],\nend\n\nlemma is_affine_open.is_localization_stalk {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) (x : U) :\n  is_localization.at_prime (X.presheaf.stalk x) (hU.prime_ideal_of x).as_ideal :=\nbegin\n  haveI : is_affine _ := hU,\n  haveI : nonempty U := ⟨x⟩,\n  rcases x with ⟨x, hx⟩,\n  let y := hU.prime_ideal_of ⟨x, hx⟩,\n  have : hU.from_Spec.val.base y = x := hU.from_Spec_prime_ideal_of ⟨x, hx⟩,\n  change is_localization y.as_ideal.prime_compl _,\n  clear_value y,\n  subst this,\n  apply (is_localization.is_localization_iff_of_ring_equiv _\n    (as_iso $ PresheafedSpace.stalk_map hU.from_Spec.1 y).CommRing_iso_to_ring_equiv).mpr,\n  convert structure_sheaf.is_localization.to_stalk _ _ using 1,\n  delta structure_sheaf.stalk_algebra,\n  congr' 1,\n  rw ring_hom.algebra_map_to_algebra,\n  refine (PresheafedSpace.stalk_map_germ hU.from_Spec.1 _ ⟨_, _⟩).trans _,\n  delta is_affine_open.from_Spec Scheme.iso_Spec structure_sheaf.to_stalk,\n  simp only [Scheme.comp_val_c_app, category.assoc],\n  dsimp only [functor.op, as_iso_inv, unop_op],\n  erw is_affine_open.is_localization_stalk_aux,\n  simp only [category.assoc],\n  conv_lhs { rw ← category.assoc },\n  erw [← X.presheaf.map_comp, Spec_Γ_naturality_assoc],\n  congr' 1,\n  simp only [← category.assoc],\n  transitivity _ ≫ (structure_sheaf (X.presheaf.obj $ op U)).1.germ ⟨_, _⟩,\n  { refl },\n  convert ((structure_sheaf (X.presheaf.obj $ op U)).1.germ_res (hom_of_le le_top) ⟨_, _⟩) using 2,\n  rw category.assoc,\n  erw nat_trans.naturality,\n  rw [← LocallyRingedSpace.Γ_map_op, ← LocallyRingedSpace.Γ.map_comp_assoc, ← op_comp],\n  erw ← Scheme.Spec.map_comp,\n  rw [← op_comp, ← X.presheaf.map_comp],\n  transitivity LocallyRingedSpace.Γ.map (quiver.hom.op $ Scheme.Spec.map\n    (X.presheaf.map (𝟙 (op U))).op) ≫ _,\n  { congr },\n  simp only [category_theory.functor.map_id, op_id],\n  erw category_theory.functor.map_id,\n  rw category.id_comp,\n  refl\nend\n\nend algebraic_geometry\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebraic_geometry/AffineScheme.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679957, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4827597869921667}}
{"text": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\n\nimport algebra.group_power.identities\nimport data.zmod.basic\nimport field_theory.finite.basic\nimport data.int.parity\nimport data.fintype.card\n\n/-!\n# Lagrange's four square theorem\n\nThe main result in this file is `sum_four_squares`,\na proof that every natural number is the sum of four square numbers.\n\n## Implementation Notes\n\nThe proof used is close to Lagrange's original proof.\n-/\n\nopen finset polynomial finite_field equiv\nopen_locale big_operators\n\nnamespace int\n\nlemma sq_add_sq_of_two_mul_sq_add_sq {m x y : ℤ} (h : 2 * m = x^2 + y^2) :\n  m = ((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2 :=\nhave even (x^2 + y^2), by simp [h.symm, even_mul],\nhave hxaddy : even (x + y), by simpa [sq] with parity_simps,\nhave hxsuby : even (x - y), by simpa [sq] with parity_simps,\n(mul_right_inj' (show (2*2 : ℤ) ≠ 0, from dec_trivial)).1 $\ncalc 2 * 2 * m = (x - y)^2 + (x + y)^2 : by rw [mul_assoc, h]; ring\n... = (2 * ((x - y) / 2))^2 + (2 * ((x + y) / 2))^2 :\n  by rw [int.mul_div_cancel' hxsuby, int.mul_div_cancel' hxaddy]\n... = 2 * 2 * (((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2) :\n  by simp [mul_add, pow_succ, mul_comm, mul_assoc, mul_left_comm]\n\nlemma exists_sq_add_sq_add_one_eq_k (p : ℕ) [hp : fact p.prime] :\n  ∃ (a b : ℤ) (k : ℕ), a^2 + b^2 + 1 = k * p ∧ k < p :=\nhp.1.eq_two_or_odd.elim (λ hp2, hp2.symm ▸ ⟨1, 0, 1, rfl, dec_trivial⟩) $ λ hp1,\nlet ⟨a, b, hab⟩ := zmod.sq_add_sq p (-1) in\nhave hab' : (p : ℤ) ∣ a.val_min_abs ^ 2 + b.val_min_abs ^ 2 + 1,\n  from (char_p.int_cast_eq_zero_iff (zmod p) p _).1 $ by simpa [eq_neg_iff_add_eq_zero] using hab,\nlet ⟨k, hk⟩ := hab' in\nhave hk0 : 0 ≤ k, from nonneg_of_mul_nonneg_left\n  (by rw ← hk; exact (add_nonneg (add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_le_one))\n  (int.coe_nat_pos.2 hp.1.pos),\n⟨a.val_min_abs, b.val_min_abs, k.nat_abs,\n    by rw [hk, int.nat_abs_of_nonneg hk0, mul_comm],\n  lt_of_mul_lt_mul_left\n    (calc p * k.nat_abs = a.val_min_abs.nat_abs ^ 2 + b.val_min_abs.nat_abs ^ 2 + 1 :\n        by rw [← int.coe_nat_inj', int.coe_nat_add, int.coe_nat_add, int.coe_nat_pow,\n          int.coe_nat_pow, int.nat_abs_sq, int.nat_abs_sq,\n          int.coe_nat_one, hk, int.coe_nat_mul, int.nat_abs_of_nonneg hk0]\n      ... ≤ (p / 2) ^ 2 + (p / 2)^2 + 1 :\n        add_le_add\n          (add_le_add\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))\n          (le_refl _)\n      ... < (p / 2) ^ 2 + (p / 2)^ 2 + (p % 2)^2 + ((2 * (p / 2)^2 + (4 * (p / 2) * (p % 2)))) :\n        by rw [hp1, one_pow, mul_one];\n          exact (lt_add_iff_pos_right _).2\n            (add_pos_of_nonneg_of_pos (nat.zero_le _) (mul_pos dec_trivial\n              (nat.div_pos hp.1.two_le dec_trivial)))\n      ... = p * p : by { conv_rhs { rw [← nat.mod_add_div p 2] }, ring })\n    (show 0 ≤ p, from nat.zero_le _)⟩\n\nend int\n\nnamespace nat\n\nopen int\n\nopen_locale classical\n\nprivate lemma sum_four_squares_of_two_mul_sum_four_squares {m a b c d : ℤ}\n  (h : a^2 + b^2 + c^2 + d^2 = 2 * m) : ∃ w x y z : ℤ, w^2 + x^2 + y^2 + z^2 = m :=\nhave ∀ f : fin 4 → zmod 2, (f 0)^2 + (f 1)^2 + (f 2)^2 + (f 3)^2 = 0 →\n    ∃ i : (fin 4), (f i)^2 + f (swap i 0 1)^2 = 0 ∧ f (swap i 0 2)^2 + f (swap i 0 3)^2 = 0,\n  from dec_trivial,\nlet f : fin 4 → ℤ :=\n  vector.nth (a ::ᵥ b ::ᵥ c ::ᵥ d ::ᵥ vector.nil) in\nlet ⟨i, hσ⟩ := this (coe ∘ f) (by rw [← @zero_mul (zmod 2) _ m,\n  ← show ((2 : ℤ) : zmod 2) = 0, from rfl,\n  ← int.cast_mul, ← h]; simp only [int.cast_add, int.cast_pow]; refl) in\nlet σ := swap i 0 in\nhave h01 : 2 ∣ f (σ 0) ^ 2 + f (σ 1) ^ 2,\n  from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $ by simpa [σ] using hσ.1,\nhave h23 : 2 ∣ f (σ 2) ^ 2 + f (σ 3) ^ 2,\n  from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $ by simpa using hσ.2,\nlet ⟨x, hx⟩ := h01 in let ⟨y, hy⟩ := h23 in\n⟨(f (σ 0) - f (σ 1)) / 2, (f (σ 0) + f (σ 1)) / 2, (f (σ 2) - f (σ 3)) / 2, (f (σ 2) + f (σ 3)) / 2,\n  begin\n    rw [← int.sq_add_sq_of_two_mul_sq_add_sq hx.symm, add_assoc,\n      ← int.sq_add_sq_of_two_mul_sq_add_sq hy.symm,\n      ← mul_right_inj' (show (2 : ℤ) ≠ 0, from dec_trivial), ← h, mul_add, ← hx, ← hy],\n    have : ∑ x, f (σ x)^2 = ∑ x, f x^2,\n    { conv_rhs { rw ← σ.sum_comp } },\n    have fin4univ : (univ : finset (fin 4)).1 = 0 ::ₘ 1 ::ₘ 2 ::ₘ 3 ::ₘ 0, from dec_trivial,\n    simpa [finset.sum_eq_multiset_sum, fin4univ, multiset.sum_cons, f, add_assoc]\n  end⟩\n\nprivate lemma prime_sum_four_squares (p : ℕ) [hp : _root_.fact p.prime] :\n  ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = p :=\nhave hm : ∃ m < p, 0 < m ∧ ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = m * p,\n  from let ⟨a, b, k, hk⟩ := exists_sq_add_sq_add_one_eq_k p in\n  ⟨k, hk.2, nat.pos_of_ne_zero $\n    (λ hk0, by { rw [hk0, int.coe_nat_zero, zero_mul] at hk,\n      exact ne_of_gt (show a^2 + b^2 + 1 > 0, from add_pos_of_nonneg_of_pos\n        (add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_lt_one) hk.1 }),\n    a, b, 1, 0, by simpa [sq] using hk.1⟩,\nlet m := nat.find hm in\nlet ⟨a, b, c, d, (habcd : a^2 + b^2 + c^2 + d^2 = m * p)⟩ := (nat.find_spec hm).snd.2 in\nby haveI hm0 : _root_.fact (0 < m) := ⟨(nat.find_spec hm).snd.1⟩; exact\nhave hmp : m < p, from (nat.find_spec hm).fst,\nm.mod_two_eq_zero_or_one.elim\n  (λ hm2 : m % 2 = 0,\n    let ⟨k, hk⟩ := (nat.dvd_iff_mod_eq_zero _ _).2 hm2 in\n    have hk0 : 0 < k, from nat.pos_of_ne_zero $ λ _, by { simp [*, lt_irrefl] at * },\n    have hkm : k < m, { rw [hk, two_mul], exact (lt_add_iff_pos_left _).2 hk0 },\n    false.elim $ nat.find_min hm hkm ⟨lt_trans hkm hmp, hk0,\n      sum_four_squares_of_two_mul_sum_four_squares\n        (show a^2 + b^2 + c^2 + d^2 = 2 * (k * p),\n          by { rw [habcd, hk, int.coe_nat_mul, mul_assoc], simp })⟩)\n  (λ hm2 : m % 2 = 1,\n    if hm1 : m = 1 then ⟨a, b, c, d, by simp only [hm1, habcd, int.coe_nat_one, one_mul]⟩\n    else\n      let w := (a : zmod m).val_min_abs, x := (b : zmod m).val_min_abs,\n          y := (c : zmod m).val_min_abs, z := (d : zmod m).val_min_abs in\n      have hnat_abs : w^2 + x^2 + y^2 + z^2 =\n          (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs ^2 + z.nat_abs ^ 2 : ℕ),\n        by simp [sq],\n      have hwxyzlt : w^2 + x^2 + y^2 + z^2 < m^2,\n        from calc w^2 + x^2 + y^2 + z^2\n            = (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs ^2 + z.nat_abs ^ 2 : ℕ) : hnat_abs\n        ... ≤ ((m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 : ℕ) :\n          int.coe_nat_le.2 $ add_le_add (add_le_add (add_le_add\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)\n        ... = 4 * (m / 2 : ℕ) ^ 2 : by simp [sq, bit0, bit1, mul_add, add_mul, add_assoc]\n        ... < 4 * (m / 2 : ℕ) ^ 2 + ((4 * (m / 2) : ℕ) * (m % 2 : ℕ) + (m % 2 : ℕ)^2) :\n          (lt_add_iff_pos_right _).2 (by { rw [hm2, int.coe_nat_one, one_pow, mul_one],\n            exact add_pos_of_nonneg_of_pos (int.coe_nat_nonneg _) zero_lt_one })\n        ... = m ^ 2 : by { conv_rhs {rw [← nat.mod_add_div m 2]},\n          simp [-nat.mod_add_div, mul_add, add_mul, bit0, bit1, mul_comm, mul_assoc, mul_left_comm,\n            pow_add, add_comm, add_left_comm] },\n      have hwxyzabcd : ((w^2 + x^2 + y^2 + z^2 : ℤ) : zmod m) =\n          ((a^2 + b^2 + c^2 + d^2 : ℤ) : zmod m),\n        by simp [w, x, y, z, sq],\n      have hwxyz0 : ((w^2 + x^2 + y^2 + z^2 : ℤ) : zmod m) = 0,\n        by rw [hwxyzabcd, habcd, int.cast_mul, cast_coe_nat, zmod.nat_cast_self, zero_mul],\n      let ⟨n, hn⟩ := ((char_p.int_cast_eq_zero_iff _ m _).1 hwxyz0) in\n      have hn0 : 0 < n.nat_abs, from int.nat_abs_pos_of_ne_zero (λ hn0,\n        have hwxyz0 : (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs^2 + z.nat_abs^2 : ℕ) = 0,\n          by { rw [← int.coe_nat_eq_zero, ← hnat_abs], rwa [hn0, mul_zero] at hn },\n        have habcd0 : (m : ℤ) ∣ a ∧ (m : ℤ) ∣ b ∧ (m : ℤ) ∣ c ∧ (m : ℤ) ∣ d,\n          by simpa [@add_eq_zero_iff_eq_zero_of_nonneg ℤ _ _ _ (sq_nonneg _)\n              (sq_nonneg _),\n            sq, w, x, y, z, (char_p.int_cast_eq_zero_iff _ m _), and.assoc] using hwxyz0,\n        let ⟨ma, hma⟩ := habcd0.1,     ⟨mb, hmb⟩ := habcd0.2.1,\n            ⟨mc, hmc⟩ := habcd0.2.2.1, ⟨md, hmd⟩ := habcd0.2.2.2 in\n        have hmdvdp : m ∣ p,\n          from int.coe_nat_dvd.1 ⟨ma^2 + mb^2 + mc^2 + md^2,\n            (mul_right_inj' (show (m : ℤ) ≠ 0, from int.coe_nat_ne_zero_iff_pos.2 hm0.1)).1 $\n              by { rw [← habcd, hma, hmb, hmc, hmd], ring }⟩,\n        (hp.1.2 _ hmdvdp).elim hm1 (λ hmeqp, by simpa [lt_irrefl, hmeqp] using hmp)),\n      have hawbxcydz : ((m : ℕ) : ℤ) ∣ a * w + b * x + c * y + d * z,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { rw [← hwxyz0], simp, ring },\n      have haxbwczdy : ((m : ℕ) : ℤ) ∣ a * x - b * w - c * z + d * y,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { simp [sub_eq_add_neg], ring },\n      have haybzcwdx : ((m : ℕ) : ℤ) ∣ a * y + b * z - c * w - d * x,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { simp [sub_eq_add_neg], ring },\n      have hazbycxdw : ((m : ℕ) : ℤ) ∣ a * z - b * y + c * x - d * w,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { simp [sub_eq_add_neg], ring },\n      let ⟨s, hs⟩ := hawbxcydz, ⟨t, ht⟩ := haxbwczdy, ⟨u, hu⟩ := haybzcwdx, ⟨v, hv⟩ := hazbycxdw in\n      have hn_nonneg : 0 ≤ n,\n        from nonneg_of_mul_nonneg_left\n          (by { erw [← hn], repeat {try {refine add_nonneg _ _}, try {exact sq_nonneg _}} })\n          (int.coe_nat_pos.2 hm0.1),\n      have hnm : n.nat_abs < m,\n        from int.coe_nat_lt.1 (lt_of_mul_lt_mul_left\n          (by { rw [int.nat_abs_of_nonneg hn_nonneg, ← hn, ← sq], exact hwxyzlt })\n          (int.coe_nat_nonneg m)),\n      have hstuv : s^2 + t^2 + u^2 + v^2 = n.nat_abs * p,\n        from (mul_right_inj' (show (m^2 : ℤ) ≠ 0, from pow_ne_zero 2\n            (int.coe_nat_ne_zero_iff_pos.2 hm0.1))).1 $\n          calc (m : ℤ)^2 * (s^2 + t^2 + u^2 + v^2) = ((m : ℕ) * s)^2 + ((m : ℕ) * t)^2 +\n              ((m : ℕ) * u)^2 + ((m : ℕ) * v)^2 :\n            by { simp [mul_pow], ring }\n          ... = (w^2 + x^2 + y^2 + z^2) * (a^2 + b^2 + c^2 + d^2) :\n            by { simp only [hs.symm, ht.symm, hu.symm, hv.symm], ring }\n          ... = _ : by { rw [hn, habcd, int.nat_abs_of_nonneg hn_nonneg], dsimp [m], ring },\n      false.elim $ nat.find_min hm hnm ⟨lt_trans hnm hmp, hn0, s, t, u, v, hstuv⟩)\n\nlemma sum_four_squares : ∀ n : ℕ, ∃ a b c d : ℕ, a^2 + b^2 + c^2 + d^2 = n\n| 0 := ⟨0, 0, 0, 0, rfl⟩\n| 1 := ⟨1, 0, 0, 0, rfl⟩\n| n@(k+2) :=\nhave hm : _root_.fact (min_fac (k+2)).prime := ⟨min_fac_prime dec_trivial⟩,\nhave n / min_fac n < n := factors_lemma,\nlet ⟨a, b, c, d, h₁⟩ := show ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = min_fac n,\n  by exactI prime_sum_four_squares (min_fac (k+2)) in\nlet ⟨w, x, y, z, h₂⟩ := sum_four_squares (n / min_fac n) in\n⟨(a * w - b * x - c * y - d * z).nat_abs,\n (a * x + b * w + c * z - d * y).nat_abs,\n (a * y - b * z + c * w + d * x).nat_abs,\n (a * z + b * y - c * x + d * w).nat_abs,\n  begin\n    rw [← int.coe_nat_inj', ← nat.mul_div_cancel' (min_fac_dvd (k+2)), int.coe_nat_mul, ← h₁, ← h₂],\n    simp [sum_four_sq_mul_sum_four_sq],\n  end⟩\n\nend nat\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/number_theory/sum_four_squares.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6688802603710085, "lm_q1q2_score": 0.48275978374934375}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.fully_faithful\nimport category_theory.full_subcategory\nimport category_theory.whiskering\nimport category_theory.essential_image\nimport tactic.slice\n\n/-!\n# Equivalence of categories\n\nAn equivalence of categories `C` and `D` is a pair of functors `F : C ⥤ D` and `G : D ⥤ C` such\nthat `η : 𝟭 C ≅ F ⋙ G` and `ε : G ⋙ F ≅ 𝟭 D`. In many situations, equivalences are a better\nnotion of \"sameness\" of categories than the stricter isomorphims of categories.\n\nRecall that one way to express that two functors `F : C ⥤ D` and `G : D ⥤ C` are adjoint is using\ntwo natural transformations `η : 𝟭 C ⟶ F ⋙ G` and `ε : G ⋙ F ⟶ 𝟭 D`, called the unit and the\ncounit, such that the compositions `F ⟶ FGF ⟶ F` and `G ⟶ GFG ⟶ G` are the identity. Unfortunately,\nit is not the case that the natural isomorphisms `η` and `ε` in the definition of an equivalence\nautomatically give an adjunction. However, it is true that\n* if one of the two compositions is the identity, then so is the other, and\n* given an equivalence of categories, it is always possible to refine `η` in such a way that the\n  identities are satisfied.\n\nFor this reason, in mathlib we define an equivalence to be a \"half-adjoint equivalence\", which is\na tuple `(F, G, η, ε)` as in the first paragraph such that the composite `F ⟶ FGF ⟶ F` is the\nidentity. By the remark above, this already implies that the tuple is an \"adjoint equivalence\",\ni.e., that the composite `G ⟶ GFG ⟶ G` is also the identity.\n\nWe also define essentially surjective functors and show that a functor is an equivalence if and only\nif it is full, faithful and essentially surjective.\n\n## Main definitions\n\n* `equivalence`: bundled (half-)adjoint equivalences of categories\n* `is_equivalence`: type class on a functor `F` containing the data of the inverse `G` as well as\n  the natural isomorphisms `η` and `ε`.\n* `ess_surj`: type class on a functor `F` containing the data of the preimages and the isomorphisms\n  `F.obj (preimage d) ≅ d`.\n\n## Main results\n\n* `equivalence.mk`: upgrade an equivalence to a (half-)adjoint equivalence\n* `equivalence_of_fully_faithfully_ess_surj`: a fully faithful essentially surjective functor is an\n  equivalence.\n\n## Notations\n\nWe write `C ≌ D` (`\\backcong`, not to be confused with `≅`/`\\cong`) for a bundled equivalence.\n\n-/\n\nnamespace category_theory\nopen category_theory.functor nat_iso category\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\n/-- We define an equivalence as a (half)-adjoint equivalence, a pair of functors with\n  a unit and counit which are natural isomorphisms and the triangle law `Fη ≫ εF = 1`, or in other\n  words the composite `F ⟶ FGF ⟶ F` is the identity.\n\n  In `unit_inverse_comp`, we show that this is actually an adjoint equivalence, i.e., that the\n  composite `G ⟶ GFG ⟶ G` is also the identity.\n\n  The triangle equation is written as a family of equalities between morphisms, it is more\n  complicated if we write it as an equality of natural transformations, because then we would have\n  to insert natural transformations like `F ⟶ F1`.\n\nSee https://stacks.math.columbia.edu/tag/001J\n-/\nstructure equivalence (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D] :=\nmk' ::\n(functor : C ⥤ D)\n(inverse : D ⥤ C)\n(unit_iso   : 𝟭 C ≅ functor ⋙ inverse)\n(counit_iso : inverse ⋙ functor ≅ 𝟭 D)\n(functor_unit_iso_comp' : ∀(X : C), functor.map ((unit_iso.hom : 𝟭 C ⟶ functor ⋙ inverse).app X) ≫\n  counit_iso.hom.app (functor.obj X) = 𝟙 (functor.obj X) . obviously)\n\nrestate_axiom equivalence.functor_unit_iso_comp'\n\ninfixr ` ≌ `:10  := equivalence\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\nnamespace equivalence\n\n/-- The unit of an equivalence of categories. -/\nabbreviation unit (e : C ≌ D) : 𝟭 C ⟶ e.functor ⋙ e.inverse := e.unit_iso.hom\n/-- The counit of an equivalence of categories. -/\nabbreviation counit (e : C ≌ D) : e.inverse ⋙ e.functor ⟶ 𝟭 D := e.counit_iso.hom\n/-- The inverse of the unit of an equivalence of categories. -/\nabbreviation unit_inv (e : C ≌ D) : e.functor ⋙ e.inverse ⟶ 𝟭 C := e.unit_iso.inv\n/-- The inverse of the counit of an equivalence of categories. -/\nabbreviation counit_inv (e : C ≌ D) : 𝟭 D ⟶ e.inverse ⋙ e.functor := e.counit_iso.inv\n\n/- While these abbreviations are convenient, they also cause some trouble,\npreventing structure projections from unfolding. -/\n@[simp] lemma equivalence_mk'_unit (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit = unit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit = counit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_unit_inv (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit_inv = unit_iso.inv := rfl\n@[simp] lemma equivalence_mk'_counit_inv (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit_inv = counit_iso.inv := rfl\n\n@[simp] lemma functor_unit_comp (e : C ≌ D) (X : C) :\n  e.functor.map (e.unit.app X) ≫ e.counit.app (e.functor.obj X) = 𝟙 (e.functor.obj X) :=\ne.functor_unit_iso_comp X\n\n@[simp] lemma counit_inv_functor_comp (e : C ≌ D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) ≫ e.functor.map (e.unit_inv.app X) = 𝟙 (e.functor.obj X) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.functor.map_iso (e.unit_iso.app X) ≪≫ e.counit_iso.app (e.functor.obj X)) (iso.refl _)],\n  exact e.functor_unit_comp X\nend\n\nlemma counit_inv_app_functor (e : C ≌ D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) = e.functor.map (e.unit.app X) :=\nby { symmetry, erw [←iso.comp_hom_eq_id (e.counit_iso.app _), functor_unit_comp], refl }\n\nlemma counit_app_functor (e : C ≌ D) (X : C) :\n  e.counit.app (e.functor.obj X) = e.functor.map (e.unit_inv.app X) :=\nby { erw [←iso.hom_comp_eq_id (e.functor.map_iso (e.unit_iso.app X)), functor_unit_comp], refl }\n\n/-- The other triangle equality. The proof follows the following proof in Globular:\n  http://globular.science/1905.001 -/\n@[simp] lemma unit_inverse_comp (e : C ≌ D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) ≫ e.inverse.map (e.counit.app Y) = 𝟙 (e.inverse.obj Y) :=\nbegin\n  rw [←id_comp (e.inverse.map _), ←map_id e.inverse, ←counit_inv_functor_comp, map_comp,\n      ←iso.hom_inv_id_assoc (e.unit_iso.app _) (e.inverse.map (e.functor.map _)),\n      app_hom, app_inv],\n  slice_lhs 2 3 { erw [e.unit.naturality] },\n  slice_lhs 1 2 { erw [e.unit.naturality] },\n  slice_lhs 4 4\n  { rw [←iso.hom_inv_id_assoc (e.inverse.map_iso (e.counit_iso.app _)) (e.unit_inv.app _)] },\n  slice_lhs 3 4 { erw [←map_comp e.inverse, e.counit.naturality],\n    erw [(e.counit_iso.app _).hom_inv_id, map_id] }, erw [id_comp],\n  slice_lhs 2 3 { erw [←map_comp e.inverse, e.counit_iso.inv.naturality, map_comp] },\n  slice_lhs 3 4 { erw [e.unit_inv.naturality] },\n  slice_lhs 4 5 { erw [←map_comp (e.functor ⋙ e.inverse), (e.unit_iso.app _).hom_inv_id, map_id] },\n  erw [id_comp],\n  slice_lhs 3 4 { erw [←e.unit_inv.naturality] },\n  slice_lhs 2 3 { erw [←map_comp e.inverse, ←e.counit_iso.inv.naturality,\n    (e.counit_iso.app _).hom_inv_id, map_id] }, erw [id_comp, (e.unit_iso.app _).hom_inv_id], refl\nend\n\n@[simp] lemma inverse_counit_inv_comp (e : C ≌ D) (Y : D) :\n  e.inverse.map (e.counit_inv.app Y) ≫ e.unit_inv.app (e.inverse.obj Y) = 𝟙 (e.inverse.obj Y) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.unit_iso.app (e.inverse.obj Y) ≪≫ e.inverse.map_iso (e.counit_iso.app Y)) (iso.refl _)],\n  exact e.unit_inverse_comp Y\nend\n\nlemma unit_app_inverse (e : C ≌ D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counit_inv.app Y) :=\nby { erw [←iso.comp_hom_eq_id (e.inverse.map_iso (e.counit_iso.app Y)), unit_inverse_comp], refl }\n\nlemma unit_inv_app_inverse (e : C ≌ D) (Y : D) :\n  e.unit_inv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) :=\nby { symmetry, erw [←iso.hom_comp_eq_id (e.unit_iso.app _), unit_inverse_comp], refl }\n\n@[simp] lemma fun_inv_map (e : C ≌ D) (X Y : D) (f : X ⟶ Y) :\n  e.functor.map (e.inverse.map f) = e.counit.app X ≫ f ≫ e.counit_inv.app Y :=\n(nat_iso.naturality_2 (e.counit_iso) f).symm\n\n@[simp] lemma inv_fun_map (e : C ≌ D) (X Y : C) (f : X ⟶ Y) :\n  e.inverse.map (e.functor.map f) = e.unit_inv.app X ≫ f ≫ e.unit.app Y :=\n(nat_iso.naturality_1 (e.unit_iso) f).symm\n\nsection\n-- In this section we convert an arbitrary equivalence to a half-adjoint equivalence.\nvariables {F : C ⥤ D} {G : D ⥤ C} (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D)\n\n/-- If `η : 𝟭 C ≅ F ⋙ G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it\nto a refined natural isomorphism `adjointify_η η : 𝟭 C ≅ F ⋙ G` which exhibits the properties\nrequired for a half-adjoint equivalence. See `equivalence.mk`. -/\ndef adjointify_η : 𝟭 C ≅ F ⋙ G :=\ncalc\n  𝟭 C ≅ F ⋙ G               : η\n  ... ≅ F ⋙ (𝟭 D ⋙ G)      : iso_whisker_left F (left_unitor G).symm\n  ... ≅ F ⋙ ((G ⋙ F) ⋙ G) : iso_whisker_left F (iso_whisker_right ε.symm G)\n  ... ≅ F ⋙ (G ⋙ (F ⋙ G)) : iso_whisker_left F (associator G F G)\n  ... ≅ (F ⋙ G) ⋙ (F ⋙ G) : (associator F G (F ⋙ G)).symm\n  ... ≅ 𝟭 C ⋙ (F ⋙ G)      : iso_whisker_right η.symm (F ⋙ G)\n  ... ≅ F ⋙ G               : left_unitor (F ⋙ G)\n\nlemma adjointify_η_ε (X : C) :\n  F.map ((adjointify_η η ε).hom.app X) ≫ ε.hom.app (F.obj X) = 𝟙 (F.obj X) :=\nbegin\n  dsimp [adjointify_η], simp,\n  have := ε.hom.naturality (F.map (η.inv.app X)), dsimp at this, rw [this], clear this,\n  rw [←assoc _ _ (F.map _)],\n  have := ε.hom.naturality (ε.inv.app $ F.obj X), dsimp at this, rw [this], clear this,\n  have := (ε.app $ F.obj X).hom_inv_id, dsimp at this, rw [this], clear this,\n  rw [id_comp], have := (F.map_iso $ η.app X).hom_inv_id, dsimp at this, rw [this]\nend\n\nend\n\n/-- Every equivalence of categories consisting of functors `F` and `G` such that `F ⋙ G` and\n    `G ⋙ F` are naturally isomorphic to identity functors can be transformed into a half-adjoint\n    equivalence without changing `F` or `G`. -/\nprotected definition mk (F : C ⥤ D) (G : D ⥤ C)\n  (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : C ≌ D :=\n⟨F, G, adjointify_η η ε, ε, adjointify_η_ε η ε⟩\n\n/-- Equivalence of categories is reflexive. -/\n@[refl, simps] def refl : C ≌ C :=\n⟨𝟭 C, 𝟭 C, iso.refl _, iso.refl _, λ X, category.id_comp _⟩\n\ninstance : inhabited (C ≌ C) :=\n⟨refl⟩\n\n/-- Equivalence of categories is symmetric. -/\n@[symm, simps] def symm (e : C ≌ D) : D ≌ C :=\n⟨e.inverse, e.functor, e.counit_iso.symm, e.unit_iso.symm, e.inverse_counit_inv_comp⟩\n\nvariables {E : Type u₃} [category.{v₃} E]\n\n/-- Equivalence of categories is transitive. -/\n@[trans, simps] def trans (e : C ≌ D) (f : D ≌ E) : C ≌ E :=\n{ functor := e.functor ⋙ f.functor,\n  inverse := f.inverse ⋙ e.inverse,\n  unit_iso :=\n  begin\n    refine iso.trans e.unit_iso _,\n    exact iso_whisker_left e.functor (iso_whisker_right f.unit_iso e.inverse) ,\n  end,\n  counit_iso :=\n  begin\n    refine iso.trans _ f.counit_iso,\n    exact iso_whisker_left f.inverse (iso_whisker_right e.counit_iso f.functor)\n  end,\n  -- We wouldn't have needed to give this proof if we'd used `equivalence.mk`,\n  -- but we choose to avoid using that here, for the sake of good structure projection `simp`\n  -- lemmas.\n  functor_unit_iso_comp' := λ X,\n  begin\n    dsimp,\n    rw [← f.functor.map_comp_assoc, e.functor.map_comp, ←counit_inv_app_functor, fun_inv_map,\n        iso.inv_hom_id_app_assoc, assoc, iso.inv_hom_id_app, counit_app_functor,\n        ← functor.map_comp],\n    erw [comp_id, iso.hom_inv_id_app, functor.map_id],\n  end }\n\n/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic\nfunctor. -/\ndef fun_inv_id_assoc (e : C ≌ D) (F : C ⥤ E) : e.functor ⋙ e.inverse ⋙ F ≅ F :=\n(functor.associator _ _ _).symm ≪≫ iso_whisker_right e.unit_iso.symm F ≪≫ F.left_unitor\n\n@[simp] lemma fun_inv_id_assoc_hom_app (e : C ≌ D) (F : C ⥤ E) (X : C) :\n  (fun_inv_id_assoc e F).hom.app X = F.map (e.unit_inv.app X) :=\nby { dsimp [fun_inv_id_assoc], tidy }\n\n@[simp] lemma fun_inv_id_assoc_inv_app (e : C ≌ D) (F : C ⥤ E) (X : C) :\n  (fun_inv_id_assoc e F).inv.app X = F.map (e.unit.app X) :=\nby { dsimp [fun_inv_id_assoc], tidy }\n\n/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic\nfunctor. -/\ndef inv_fun_id_assoc (e : C ≌ D) (F : D ⥤ E) : e.inverse ⋙ e.functor ⋙ F ≅ F :=\n(functor.associator _ _ _).symm ≪≫ iso_whisker_right e.counit_iso F ≪≫ F.left_unitor\n\n@[simp] lemma inv_fun_id_assoc_hom_app (e : C ≌ D) (F : D ⥤ E) (X : D) :\n  (inv_fun_id_assoc e F).hom.app X = F.map (e.counit.app X) :=\nby { dsimp [inv_fun_id_assoc], tidy }\n\n@[simp] lemma inv_fun_id_assoc_inv_app (e : C ≌ D) (F : D ⥤ E) (X : D) :\n  (inv_fun_id_assoc e F).inv.app X = F.map (e.counit_inv.app X) :=\nby { dsimp [inv_fun_id_assoc], tidy }\n\n/-- If `C` is equivalent to `D`, then `C ⥤ E` is equivalent to `D ⥤ E`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_left (e : C ≌ D) : (C ⥤ E) ≌ (D ⥤ E) :=\nequivalence.mk\n  ((whiskering_left _ _ _).obj e.inverse)\n  ((whiskering_left _ _ _).obj e.functor)\n  (nat_iso.of_components (λ F, (e.fun_inv_id_assoc F).symm) (by tidy))\n  (nat_iso.of_components (λ F, e.inv_fun_id_assoc F) (by tidy))\n\n/-- If `C` is equivalent to `D`, then `E ⥤ C` is equivalent to `E ⥤ D`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_right (e : C ≌ D) : (E ⥤ C) ≌ (E ⥤ D) :=\nequivalence.mk\n  ((whiskering_right _ _ _).obj e.functor)\n  ((whiskering_right _ _ _).obj e.inverse)\n  (nat_iso.of_components\n    (λ F, F.right_unitor.symm ≪≫ iso_whisker_left F e.unit_iso ≪≫ functor.associator _ _ _)\n    (by tidy))\n  (nat_iso.of_components\n    (λ F, functor.associator _ _ _ ≪≫ iso_whisker_left F e.counit_iso ≪≫ F.right_unitor)\n    (by tidy))\n\nsection cancellation_lemmas\nvariables (e : C ≌ D)\n\n/- We need special forms of `cancel_nat_iso_hom_right(_assoc)` and\n`cancel_nat_iso_inv_right(_assoc)` for units and counits, because neither `simp` or `rw` will apply\nthose lemmas in this setting without providing `e.unit_iso` (or similar) as an explicit argument.\nWe also provide the lemmas for length four compositions, since they're occasionally useful.\n(e.g. in proving that equivalences take monos to monos) -/\n\n@[simp] lemma cancel_unit_right {X Y : C}\n  (f f' : X ⟶ Y) :\n  f ≫ e.unit.app Y = f' ≫ e.unit.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_inv_right {X Y : C}\n  (f f' : X ⟶ e.inverse.obj (e.functor.obj Y))   :\n  f ≫ e.unit_inv.app Y = f' ≫ e.unit_inv.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_right {X Y : D}\n  (f f' : X ⟶ e.functor.obj (e.inverse.obj Y))   :\n  f ≫ e.counit.app Y = f' ≫ e.counit.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right {X Y : D}\n  (f f' : X ⟶ Y) :\n  f ≫ e.counit_inv.app Y = f' ≫ e.counit_inv.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc {W X X' Y : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) :\n  f ≫ g ≫ e.unit.app Y = f' ≫ g' ≫ e.unit.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right_assoc {W X X' Y : D}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) :\n  f ≫ g ≫ e.counit_inv.app Y = f' ≫ g' ≫ e.counit_inv.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc' {W X X' Y Y' Z : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z) (f' : W ⟶ X') (g' : X' ⟶ Y') (h' : Y' ⟶ Z) :\n  f ≫ g ≫ h ≫ e.unit.app Z = f' ≫ g' ≫ h' ≫ e.unit.app Z ↔ f ≫ g ≫ h = f' ≫ g' ≫ h' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] \n\nend cancellation_lemmas\n\nsection\n\n-- There's of course a monoid structure on `C ≌ C`,\n-- but let's not encourage using it.\n-- The power structure is nevertheless useful.\n\n/-- Natural number powers of an auto-equivalence.  Use `(^)` instead. -/\ndef pow_nat (e : C ≌ C) : ℕ → (C ≌ C)\n| 0 := equivalence.refl\n| 1 := e\n| (n+2) := e.trans (pow_nat (n+1))\n\n/-- Powers of an auto-equivalence.  Use `(^)` instead. -/\ndef pow (e : C ≌ C) : ℤ → (C ≌ C)\n| (int.of_nat n) := e.pow_nat n\n| (int.neg_succ_of_nat n) := e.symm.pow_nat (n+1)\n\ninstance : has_pow (C ≌ C) ℤ := ⟨pow⟩\n\n@[simp] lemma pow_zero (e : C ≌ C) : e^(0 : ℤ) = equivalence.refl := rfl\n@[simp] lemma pow_one (e : C ≌ C) : e^(1 : ℤ) = e := rfl\n@[simp] lemma pow_neg_one (e : C ≌ C) : e^(-1 : ℤ) = e.symm := rfl\n\n-- TODO as necessary, add the natural isomorphisms `(e^a).trans e^b ≅ e^(a+b)`.\n-- At this point, we haven't even defined the category of equivalences.\n\nend\n\nend equivalence\n\n\n/-- A functor that is part of a (half) adjoint equivalence -/\nclass is_equivalence (F : C ⥤ D) :=\nmk' ::\n(inverse    : D ⥤ C)\n(unit_iso   : 𝟭 C ≅ F ⋙ inverse)\n(counit_iso : inverse ⋙ F ≅ 𝟭 D)\n(functor_unit_iso_comp' : ∀ (X : C), F.map ((unit_iso.hom : 𝟭 C ⟶ F ⋙ inverse).app X) ≫\n  counit_iso.hom.app (F.obj X) = 𝟙 (F.obj X) . obviously)\n\nrestate_axiom is_equivalence.functor_unit_iso_comp'\n\nnamespace is_equivalence\n\ninstance of_equivalence (F : C ≌ D) : is_equivalence F.functor :=\n{ ..F }\n\ninstance of_equivalence_inverse (F : C ≌ D) : is_equivalence F.inverse :=\nis_equivalence.of_equivalence F.symm\n\nopen equivalence\n/-- To see that a functor is an equivalence, it suffices to provide an inverse functor `G` such that\n    `F ⋙ G` and `G ⋙ F` are naturally isomorphic to identity functors. -/\nprotected definition mk {F : C ⥤ D} (G : D ⥤ C)\n  (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : is_equivalence F :=\n⟨G, adjointify_η η ε, ε, adjointify_η_ε η ε⟩\n\nend is_equivalence\n\n\nnamespace functor\n\n/-- Interpret a functor that is an equivalence as an equivalence. -/\ndef as_equivalence (F : C ⥤ D) [is_equivalence F] : C ≌ D :=\n⟨F, is_equivalence.inverse F, is_equivalence.unit_iso, is_equivalence.counit_iso,\n  is_equivalence.functor_unit_iso_comp⟩\n\ninstance is_equivalence_refl : is_equivalence (𝟭 C) :=\nis_equivalence.of_equivalence equivalence.refl\n\n/-- The inverse functor of a functor that is an equivalence. -/\ndef inv (F : C ⥤ D) [is_equivalence F] : D ⥤ C :=\nis_equivalence.inverse F\n\ninstance is_equivalence_inv (F : C ⥤ D) [is_equivalence F] : is_equivalence F.inv :=\nis_equivalence.of_equivalence F.as_equivalence.symm\n\n@[simp] lemma as_equivalence_functor (F : C ⥤ D) [is_equivalence F] :\n  F.as_equivalence.functor = F := rfl\n\n@[simp] lemma as_equivalence_inverse (F : C ⥤ D) [is_equivalence F] :\n  F.as_equivalence.inverse = inv F := rfl\n\n@[simp] lemma inv_inv (F : C ⥤ D) [is_equivalence F] :\n  inv (inv F) = F := rfl\n\nvariables {E : Type u₃} [category.{v₃} E]\n\ninstance is_equivalence_trans (F : C ⥤ D) (G : D ⥤ E) [is_equivalence F] [is_equivalence G] :\n  is_equivalence (F ⋙ G) :=\nis_equivalence.of_equivalence (equivalence.trans (as_equivalence F) (as_equivalence G))\n\nend functor\n\nnamespace equivalence\n\n@[simp]\nlemma functor_inv (E : C ≌ D) : E.functor.inv = E.inverse := rfl\n\n@[simp]\nlemma inverse_inv (E : C ≌ D) : E.inverse.inv = E.functor := rfl\n\n@[simp]\nlemma functor_as_equivalence (E : C ≌ D) : E.functor.as_equivalence = E :=\nby { cases E, congr, }\n\n@[simp]\nlemma inverse_as_equivalence (E : C ≌ D) : E.inverse.as_equivalence = E.symm :=\nby { cases E, congr, }\n\nend equivalence\n\nnamespace is_equivalence\n\n@[simp] lemma fun_inv_map (F : C ⥤ D) [is_equivalence F] (X Y : D) (f : X ⟶ Y) :\n  F.map (F.inv.map f) = F.as_equivalence.counit.app X ≫ f ≫ F.as_equivalence.counit_inv.app Y :=\nbegin\n  erw [nat_iso.naturality_2],\n  refl\nend\n@[simp] lemma inv_fun_map (F : C ⥤ D) [is_equivalence F] (X Y : C) (f : X ⟶ Y) :\n  F.inv.map (F.map f) = F.as_equivalence.unit_inv.app X ≫ f ≫ F.as_equivalence.unit.app Y :=\nbegin\n  erw [nat_iso.naturality_1],\n  refl\nend\n\nend is_equivalence\n\nnamespace equivalence\n\n/--\nAn equivalence is essentially surjective.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\nlemma ess_surj_of_equivalence (F : C ⥤ D) [is_equivalence F] : ess_surj F :=\n⟨λ Y, ⟨F.inv.obj Y, ⟨F.as_equivalence.counit_iso.app Y⟩⟩⟩\n\n/--\nAn equivalence is faithful.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\n@[priority 100] -- see Note [lower instance priority]\ninstance faithful_of_equivalence (F : C ⥤ D) [is_equivalence F] : faithful F :=\n{ map_injective' := λ X Y f g w,\n  begin\n    have p := congr_arg (@category_theory.functor.map _ _ _ _ F.inv _ _) w,\n    simpa only [cancel_epi, cancel_mono, is_equivalence.inv_fun_map] using p\n  end }.\n\n/--\nAn equivalence is full.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\n@[priority 100] -- see Note [lower instance priority]\ninstance full_of_equivalence (F : C ⥤ D) [is_equivalence F] : full F :=\n{ preimage := λ X Y f, F.as_equivalence.unit.app X ≫ F.inv.map f ≫ F.as_equivalence.unit_inv.app Y,\n  witness' := λ X Y f, F.inv.map_injective $\n  by simpa only [is_equivalence.inv_fun_map, assoc, iso.inv_hom_id_app_assoc, iso.inv_hom_id_app]\n    using comp_id _ }\n\n@[simps] private noncomputable def equivalence_inverse (F : C ⥤ D) [full F] [faithful F]\n  [ess_surj F] : D ⥤ C :=\n{ obj  := λ X, F.obj_preimage X,\n  map := λ X Y f, F.preimage ((F.obj_obj_preimage_iso X).hom ≫ f ≫ (F.obj_obj_preimage_iso Y).inv),\n  map_id' := λ X, begin apply F.map_injective, tidy end,\n  map_comp' := λ X Y Z f g, by apply F.map_injective; simp }\n\n/--\nA functor which is full, faithful, and essentially surjective is an equivalence.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\nnoncomputable def equivalence_of_fully_faithfully_ess_surj\n  (F : C ⥤ D) [full F] [faithful F] [ess_surj F] : is_equivalence F :=\nis_equivalence.mk (equivalence_inverse F)\n  (nat_iso.of_components\n    (λ X, (preimage_iso $ F.obj_obj_preimage_iso $ F.obj X).symm)\n    (λ X Y f, by { apply F.map_injective, obviously }))\n  (nat_iso.of_components F.obj_obj_preimage_iso (by tidy))\n\n@[simp] lemma functor_map_inj_iff (e : C ≌ D) {X Y : C} (f g : X ⟶ Y) :\n  e.functor.map f = e.functor.map g ↔ f = g :=\n⟨λ h, e.functor.map_injective h, λ h, h ▸ rfl⟩\n\n@[simp] lemma inverse_map_inj_iff (e : C ≌ D) {X Y : D} (f g : X ⟶ Y) :\n  e.inverse.map f = e.inverse.map g ↔ f = g :=\nfunctor_map_inj_iff e.symm f g\n\ninstance ess_surj_induced_functor {C' : Type*} (e : C' ≃ D) : ess_surj (induced_functor e) :=\n{ mem_ess_image := λ Y, ⟨e.symm Y, by simp⟩, }\n\nnoncomputable\ninstance induced_functor_of_equiv {C' : Type*} (e : C' ≃ D) : is_equivalence (induced_functor e) :=\nequivalence_of_fully_faithfully_ess_surj _\n\nend equivalence\n\nsection partial_order\nvariables {α β : Type*} [partial_order α] [partial_order β]\n\n/--\nA categorical equivalence between partial orders is just an order isomorphism.\n-/\ndef equivalence.to_order_iso (e : α ≌ β) : α ≃o β :=\n{ to_fun := e.functor.obj,\n  inv_fun := e.inverse.obj,\n  left_inv := λ a, (e.unit_iso.app a).to_eq.symm,\n  right_inv := λ b, (e.counit_iso.app b).to_eq,\n  map_rel_iff' := λ a a',\n    ⟨λ h, le_of_hom\n      ((equivalence.unit e).app a ≫ e.inverse.map (hom_of_le h) ≫ (equivalence.unit_inv e).app a'),\n     λ (h : a ≤ a'), le_of_hom (e.functor.map (hom_of_le h))⟩, }\n\n-- `@[simps]` on `equivalence.to_order_iso` produces lemmas that fail the `simp_nf` linter,\n-- so we provide them by hand:\n@[simp]\nlemma equivalence.to_order_iso_apply (e : α ≌ β) (a : α) :\n  e.to_order_iso a = e.functor.obj a := rfl\n\n@[simp]\nlemma equivalence.to_order_iso_symm_apply (e : α ≌ β) (b : β) :\n  e.to_order_iso.symm b = e.inverse.obj b := rfl\n\nend partial_order\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/equivalence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.482759778985404}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.algebra.basic\nimport Mathlib.algebra.star.basic\nimport Mathlib.PostPort\n\nuniverses u v l \n\nnamespace Mathlib\n\n/-!\n# Star algebras\n\nIntroduces the notion of a star algebra over a star ring.\n-/\n\n/--\nA star algebra `A` over a star ring `R` is an algebra which is a star ring,\nand the two star structures are compatible in the sense\n`star (r • a) = star r • star a`.\n-/\n-- Note that we take `star_ring A` as a typeclass argument, rather than extending it,\n\n-- to avoid having multiple definitions of the star operation.\n\nclass star_algebra (R : Type u) (A : Type v) [comm_semiring R] [star_ring R] [semiring A]\n    [star_ring A] [algebra R A]\n    where\n  star_smul : ∀ (r : R) (a : A), star (r • a) = has_star.star r • star a\n\n@[simp] theorem star_smul (R : Type u) (A : Type v) [comm_semiring R] [star_ring R] [semiring A]\n    [star_ring A] [algebra R A] [star_algebra R A] (r : R) (a : A) :\n    star (r • a) = star r • star a :=\n  star_algebra.star_smul r a\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/star/algebra_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4826443451363598}}
{"text": "/- ACL and MIdFF, Lean 2022 meeting at Icerm -/\nimport divided_powers.basic\nimport basic_lemmas\n\nopen subtype\n\n-- We should PR this lemma\nlemma submodule.supr_eq_span' {R M : Type*} [semiring R] [add_comm_monoid M] [module R M] \n  {ι : Sort*} (p : ι → submodule R M) (h : ι → Prop) : \n  (⨆ (i : ι) (hi : h i), p i) = submodule.span R (⋃ (i : ι) (hi : h i), ↑(p i)) :=\nby simp_rw [← submodule.supr_span, submodule.span_eq]\n\nnamespace subideal\n\nvariables {A : Type*} [comm_ring A] {I : ideal A}\n\ndef galois_coinsertion : galois_coinsertion (λ J : {J : ideal A // J ≤ I}, (J : ideal A))\n  (λ J : ideal A, ⟨J ⊓ I, by exact inf_le_right⟩) :=\ngalois_coinsertion.monotone_intro (λ J J' h, mk_le_mk.mpr (inf_le_inf_right I h))\n  (λ J J' h, h) (λ J, inf_le_left) (λ ⟨J, hJ⟩, by simp only [coe_mk]; exact inf_eq_left.mpr hJ) \n\ninstance : complete_lattice {J : ideal A // J ≤ I} := \ngalois_coinsertion.lift_complete_lattice (galois_coinsertion)\n\nlemma top_def : (⟨I, le_refl I⟩ : {J : ideal A // J ≤ I}) = ⊤ := \neq_top_iff.mpr (⊤ : {J : ideal A // J ≤ I}).property\n\nlemma bot_def : (⟨⊥, bot_le⟩ : {J : ideal A // J ≤ I}) = ⊥ := by rw mk_bot\n\nlemma inf_def (J J' : {J : ideal A // J ≤ I}) : \n  (J ⊓ J' : {J : ideal A // J ≤ I} ) = ⟨(J : ideal A) ⊓ (J' : ideal A), inf_le_of_left_le J.2⟩ :=\nby { ext x, exact ⟨λ ⟨h, h'⟩, h, λ h, ⟨h, J.property h.left⟩⟩ }\n\nlemma  Inf_def (S : set {J : ideal A // J ≤ I}) : \n  (Inf S : {J : ideal A // J ≤ I} ) = ⟨(Inf ((coe : _ → ideal A) '' S)) ⊓ I, inf_le_right⟩ :=\nby { ext x, refl }\n\nlemma sup_def (J J' : {J : ideal A // J ≤ I}) : \n  (J ⊔ J' : {J : ideal A // J ≤ I} ) = \n    ⟨Inf {B | (J : ideal A) ≤ B ∧ (J' : ideal A) ≤ B}, Inf_le_of_le ⟨J.2, J'.2⟩ (le_refl I)⟩ :=\nbegin\n  ext x,\n  refine ⟨λ ⟨h, h'⟩, h, λ h, ⟨h, _⟩⟩,\n  rw [coe_mk, submodule.mem_Inf] at h,\n  exact h I ⟨J.2, J'.2⟩\nend\n\nlemma Sup_def (S : set {J : ideal A // J ≤ I}) : \n  (Sup S : {J : ideal A // J ≤ I} ) = ⟨(Sup ((coe : _ → ideal A) '' S)) ⊓ I, inf_le_right⟩ :=\nby { ext x, refl }\n\nend subideal\n\nnamespace divided_powers\n\n/-- The structure of a sub-pd-ideal of a pd-ideal -/\nstructure is_sub_pd_ideal {A : Type*} [comm_ring A] {I : ideal A} (hI : divided_powers I)\n  (J : ideal A) : Prop :=\n(is_sub_ideal : J ≤ I)\n(dpow_mem_ideal : ∀ (n : ℕ) (hn : n ≠ 0) (j ∈ J), hI.dpow n j ∈ J )\n\nsection is_sub_pd_ideal\n\nvariables {A : Type*} [comm_ring A] {I : ideal A} (hI : divided_powers I)\n\n/-- The ideal J ⊓ I is a sub-pd-ideal of I, if and only if (on I) the divided powers have some \n  compatiblity mod J. (The necessity was proved as a sanity check.) -/\nlemma is_sub_pd_ideal_inf_iff (J : ideal A) :\n  (is_sub_pd_ideal hI (J ⊓ I)) ↔ (∀ (n : ℕ) (a b : A) (ha : a ∈ I) (hb : b ∈ I) (hab : (a - b) ∈ J),\n    hI.dpow n a - hI.dpow n b ∈ J) := \nbegin\n  refine ⟨λ hIJ n a b ha hb hab, _, λ hIJ, _⟩,\n  { have hab' : a - b ∈ I := I.sub_mem ha hb,  \n    rw [← add_sub_cancel'_right b a, hI.dpow_add n hb hab', finset.range_succ, \n      finset.sum_insert (finset.not_mem_range_self), tsub_self, hI.dpow_zero hab', mul_one,\n      add_sub_cancel'], \n    apply ideal.sum_mem,\n    intros i hi, \n    apply semilattice_inf.inf_le_left J I,\n    exact (J ⊓ I).smul_mem _ (hIJ.dpow_mem_ideal (n - i) \n      (ne_of_gt (nat.sub_pos_of_lt (finset.mem_range.mp hi))) _ ⟨hab, hab'⟩) },\n  { refine ⟨semilattice_inf.inf_le_right J I, λ n hn a ha,  ⟨_, hI.dpow_mem hn ha.right⟩⟩,\n    rw [← sub_zero (hI.dpow n a), ← hI.dpow_eval_zero hn], \n    exact hIJ n a 0 ha.right (I.zero_mem) (J.sub_mem ha.left J.zero_mem) },\nend\n\n/-- Lemma 3.6 of [BO] (Antoine) -/\nlemma span_is_sub_pd_ideal_iff (S : set A) (hS : S ⊆ I) :\n  is_sub_pd_ideal hI (ideal.span S) ↔ \n  ∀ (n : ℕ) (hn : n ≠ 0) (s ∈ S), hI.dpow n s ∈ ideal.span S := \nbegin \n  split,\n  { -- trivial direction\n    intros hhI h hn s hs, \n    apply hhI.dpow_mem_ideal h hn s (ideal.subset_span hs), },\n  { -- interesting direction,\n    intro hhI,\n    have hSI := ideal.span_le.mpr hS,\n    apply is_sub_pd_ideal.mk (hSI),\n    intros n hn z hz, revert n,\n    refine submodule.span_induction' _ _ _ _ hz, \n    { -- case of elements of S \n      intros s hs n hn, exact hhI n hn s hs, },\n    { -- case of 0 \n      intros n hn, rw hI.dpow_eval_zero hn, apply ideal.zero_mem _, },\n    { -- case of sum\n      rintros x hxI y hyI hx hy n hn,\n      rw hI.dpow_add n (hSI hxI) (hSI hyI),\n      apply submodule.sum_mem (ideal.span S),\n      intros m hm,\n      by_cases hm0 : m = 0,\n      { rw hm0,\n        exact ideal.mul_mem_left (ideal.span S) _ (hy n hn), },\n      { exact ideal.mul_mem_right _ (ideal.span S) (hx m hm0), } },\n    { -- case : product,\n      intros a x hxI hx n hn,\n      simp only [algebra.id.smul_eq_mul],\n      rw hI.dpow_smul n (hSI hxI),\n      exact ideal.mul_mem_left (ideal.span S) (a ^ n) (hx n hn), }, },\nend\n\nlemma generated_dpow_is_sub_ideal {S : set A} (hS : S ⊆ I) :\n  ideal.span { y : A | ∃ (n : ℕ) (hn : n ≠ 0) (x : A) (hx : x ∈ S), y = hI.dpow n x } ≤ I :=\nbegin\n  rw ideal.span_le,\n  rintros y ⟨n, hn, x, hx, hxy⟩,\n  rw hxy,\n  exact hI.dpow_mem hn (hS hx)\nend\n\nend is_sub_pd_ideal\n\n/-- A `sub-pd-ideal` of `I` is a sub-ideal `J` of `I` such that for all `n ∈ ℕ ≥ 0` and all\n  `j ∈ J`, `hI.dpow n j ∈ J`. -/\n@[ext] structure sub_pd_ideal {A : Type*} [comm_ring A] {I : ideal A} (hI : divided_powers I) :=\n(carrier : ideal A)\n(is_sub_ideal : carrier ≤ I)\n(dpow_mem_ideal : ∀ (n : ℕ) (hn : n ≠ 0) (j ∈ carrier), hI.dpow n j ∈ carrier)\n\nnamespace sub_pd_ideal\n\nvariables {A : Type*} [comm_ring A] {I : ideal A} (hI : divided_powers I)\n\ndef mk' (J : ideal A) (hJ : is_sub_pd_ideal hI J) : sub_pd_ideal hI := ⟨J, hJ.1, hJ.2⟩\n\ninstance : set_like (sub_pd_ideal hI) A :=\n{ coe := λ s, s.carrier,\n  coe_injective' := λ p q h, by rw [set_like.coe_set_eq] at h; cases p; cases q; congr'  }\n\ninstance : has_coe (sub_pd_ideal hI) (ideal A) := ⟨λ J, J.carrier⟩\n\nlemma coe_def (J : sub_pd_ideal hI) : (J : ideal A) = J.carrier := rfl\n\n@[simp] lemma mem_carrier {s : sub_pd_ideal hI} {x : A} : x ∈ s.carrier ↔ x ∈ s := iff.rfl\n\n/-- If there is a pd-structure on I(A/J) such that the quotient map is \n   a pd-morphism, then J ⊓ I is a sub-pd-ideal of I -/\ndef inter_quot (J : ideal A) (hJ : divided_powers (I.map (ideal.quotient.mk J)))\n  (φ : pd_morphism hI hJ) (hφ:  φ.to_ring_hom = ideal.quotient.mk J) : \n  sub_pd_ideal hI := \n{ carrier        := J ⊓ I,\n  is_sub_ideal   := set.inter_subset_right J I, \n  dpow_mem_ideal := λ n hn a ⟨haJ, haI⟩,\n  begin\n    refine ⟨_, hI.dpow_mem hn haI⟩,\n    rw [set_like.mem_coe,← ideal.quotient.eq_zero_iff_mem, ← hφ, ← φ.dpow_comp n a haI], \n    suffices ha0 : (φ.to_ring_hom) a = 0,\n    { rw ha0,\n      exact hJ.dpow_eval_zero hn },\n    rw [hφ, ideal.quotient.eq_zero_iff_mem], \n    exact haJ, \n  end }\n\n/-- If J is an ideal of A, then J ⬝ I is a sub-pd-ideal of I. (Berthelot, 1.6.1 (i)) -/\ndef prod (J : ideal A) : sub_pd_ideal hI  :=\n{ carrier        := I • J,\n  is_sub_ideal   := ideal.mul_le_right,\n  dpow_mem_ideal := λ n hn x hx,\n  begin\n    revert n,\n    apply submodule.smul_induction_on' hx,\n    { -- mul \n      intros a ha b hb n hn,\n      rw [algebra.id.smul_eq_mul, mul_comm a b, hI.dpow_smul n ha, mul_comm], \n      exact submodule.mul_mem_mul (hI.dpow_mem hn ha)\n        (J.pow_mem_of_mem hb n (zero_lt_iff.mpr hn)) },\n    { -- add \n      intros x hx y hy hx' hy' n hn, \n      rw hI.dpow_add n (ideal.mul_le_right hx) (ideal.mul_le_right hy),\n      apply submodule.sum_mem (I • J),\n      intros k hk,\n      by_cases hk0 : k = 0,\n      { rw hk0, apply ideal.mul_mem_left (I • J), exact hy' _ hn, },\n      { apply ideal.mul_mem_right _ (I • J), exact hx' k hk0, }, }\n  end }\n\nsection complete_lattice\n\ninstance : has_coe (sub_pd_ideal hI) {J : ideal A // J ≤ I} :=  ⟨λ J, ⟨J.carrier, J.is_sub_ideal⟩⟩\n\ninstance : has_le (sub_pd_ideal hI) := ⟨λ J J', J.carrier ≤ J'.carrier⟩\n\nlemma le_iff {J J' : sub_pd_ideal hI} : J ≤ J' ↔ J.carrier ≤ J'.carrier := iff.rfl\n\ninstance : has_lt (sub_pd_ideal hI) := ⟨λ J J', J.carrier < J'.carrier⟩\n\nlemma lt_iff {J J' : sub_pd_ideal hI} : J < J' ↔ J.carrier < J'.carrier := iff.rfl\n\n/-- I is a sub-pd-ideal ot itself. -/\ninstance : has_top (sub_pd_ideal hI) :=\n⟨{ carrier       := I,\n  is_sub_ideal   := le_refl _,\n  dpow_mem_ideal := λ n hn x hx, hI.dpow_mem hn hx }⟩\n\ninstance inhabited : inhabited hI.sub_pd_ideal := ⟨⊤⟩\n\n/-- (0) is a sub-pd-ideal ot the pd-ideal I. -/\ninstance : has_bot (sub_pd_ideal hI) :=\n⟨{ carrier       := ⊥,\n  is_sub_ideal   := bot_le,\n  dpow_mem_ideal := λ n hn x hx, \n  by rw [ideal.mem_bot.mp hx, hI.dpow_eval_zero hn, ideal.mem_bot]}⟩\n\n--Section 1.8 of [B]\n/- The intersection of two sub-PD ideals is a sub-PD ideal. -/\ninstance : has_inf (sub_pd_ideal hI) := ⟨λ J J',\n{ carrier := J.carrier ⊓ J'.carrier,\n  is_sub_ideal := λ x hx, J.is_sub_ideal hx.1,\n  dpow_mem_ideal :=  λ n hn x hx, ⟨J.dpow_mem_ideal n hn x hx.1, J'.dpow_mem_ideal n hn x hx.2⟩ }⟩\n\nlemma inf_carrier_def (J J' : sub_pd_ideal hI) :\n  (J ⊓ J').carrier = J.carrier ⊓ J'.carrier := rfl\n\ninstance : has_Inf (sub_pd_ideal hI) := ⟨λ S,\n{ carrier := ⨅ s ∈ (has_insert.insert ⊤ S), (s : hI.sub_pd_ideal).carrier, \n  is_sub_ideal := λ x hx,\n  begin\n    simp only [ideal.mem_infi] at hx,\n    exact hx ⊤ (set.mem_insert ⊤ S),\n  end,\n  dpow_mem_ideal := λ n hn x hx,\n  begin\n    simp only [ideal.mem_infi] at hx ⊢,\n    intros s hs,\n    refine (s : hI.sub_pd_ideal).dpow_mem_ideal n hn x (hx s hs),\n  end }⟩\n\nlemma Inf_carrier_def (S : set (sub_pd_ideal hI)) :\n  (Inf S).carrier = ⨅ s ∈ (has_insert.insert ⊤ S), (s : hI.sub_pd_ideal).carrier := rfl\n\ninstance : has_sup (sub_pd_ideal hI) := \n⟨λ J J', sub_pd_ideal.mk' hI ((J : ideal A) ⊔ J')  $ begin\n  have hJJ' : (J : ideal A) ⊔ (J' : ideal A) = ideal.span(J ∪ J'),\n  { simp only [ideal.span_union, coe_coe, ideal.span_eq] },\n  rw [hJJ', span_is_sub_pd_ideal_iff hI (J ∪ J') (set.union_subset J.is_sub_ideal J'.is_sub_ideal)],\n  rintros n hn x (hx | hx),\n  { exact ideal.subset_span (set.mem_union_left _ (J.dpow_mem_ideal n hn x hx)) },\n  { exact ideal.subset_span (set.mem_union_right _ (J'.dpow_mem_ideal n hn x hx)) }\nend⟩\n\nlemma sup_carrier_def (J J' : sub_pd_ideal hI) : (J ⊔ J').carrier = J ⊔ J' := rfl\n\ninstance : has_Sup (sub_pd_ideal hI) := \n⟨λ S, sub_pd_ideal.mk' hI (Sup ((coe : sub_pd_ideal hI → ideal A) '' S)) $ \n  begin\n    have h : (⋃ (i : ideal A) (hi : i ∈ coe '' S), ↑i) ⊆ (I : set A),\n    { rintros a ⟨-, ⟨J, rfl⟩, haJ⟩,\n      rw [set.mem_Union, set_like.mem_coe, exists_prop] at haJ,\n      obtain ⟨J', hJ'⟩ := (set.mem_image _ _ _).mp haJ.1,\n      rw [← hJ'.2, coe_def] at haJ,\n      exact J'.is_sub_ideal haJ.2, },\n    rw [Sup_eq_supr, submodule.supr_eq_span', ideal.submodule_span_eq, \n      span_is_sub_pd_ideal_iff hI _ h],\n    rintros n hn x ⟨T, hT, hTx⟩,\n    obtain ⟨J, hJ⟩ := hT,\n    rw ← hJ at hTx,\n    obtain ⟨J', ⟨⟨hJ', rfl⟩, h'⟩⟩ := hTx,\n    apply ideal.subset_span,\n    apply set.mem_bUnion hJ',\n    obtain ⟨K, hKS, rfl⟩ := hJ',\n    exact K.dpow_mem_ideal n hn x h', \nend⟩\n\nlemma Sup_carrier_def (S : set (sub_pd_ideal hI)) :\n  (Sup S).carrier = Sup ((coe : sub_pd_ideal hI → ideal A) '' S) := rfl\n\ninstance : complete_lattice (sub_pd_ideal hI) :=\nbegin\n  refine function.injective.complete_lattice (λ J : sub_pd_ideal hI, (J : {J : ideal A // J ≤ I}))\n    (λ J J' h, (ext_iff _ _).mpr (subtype.ext_iff.mp h)) (λ J J', by rw subideal.sup_def; refl)\n    (λ J J', by rw subideal.inf_def; refl) _ _ (by rw ← subideal.top_def; refl) \n    (by rw ← subideal.bot_def; refl),\n  { intro S,\n    conv_rhs { rw supr },\n    rw [subideal.Sup_def, subtype.ext_iff,← coe_coe, coe_def, Sup_carrier_def, coe_mk, \n      Sup_image, Sup_image, supr_range], \n    have : ∀ (J : hI.sub_pd_ideal),\n      ((⨆ (H : J ∈ S), (J : {B : ideal A // B ≤ I}) : {B : ideal A // B ≤ I} ) : ideal A) =\n      (⨆ (H : J ∈ S), (J : ideal A)),\n    { intro J,\n      by_cases hJ : J ∈ S,\n      { rw [csupr_pos hJ, csupr_pos hJ], refl },\n      { simp only [hJ, supr_false, coe_eq_bot_iff, bot_le] }},\n    simp_rw this,\n    ext a,\n    refine ⟨λ ha, ⟨ha, _⟩, λ ha, ha.1⟩,\n    apply (submodule.mem_supr _).mp ha I,\n    intro J,\n    by_cases hJ : J ∈ S,\n    { rw csupr_pos hJ, exact J.is_sub_ideal, },\n    { simp only [hJ, supr_false, bot_le] }},\n  { intro S,\n    conv_rhs { rw infi },\n    rw [subideal.Inf_def, subtype.ext_iff, ← coe_coe, coe_def, Inf_carrier_def, coe_mk,\n      Inf_image, infi_range, infi_inf, infi_insert, inf_infi],\n    apply infi_congr,\n    intro J,\n    by_cases hJ : J ∈ S,\n    { rw [cinfi_pos hJ, cinfi_pos hJ, inf_comm], refl, },\n    { simp only [hJ, infi_false, inf_top_eq, ← subideal.top_def, coe_mk, inf_idem], refl }}\nend\n\nend complete_lattice \n\nsection generated\n\n/-- The sub-pd-ideal of I generated by a family of elements of A. -/\ndef generated (S : set A) : sub_pd_ideal hI := \nInf { J : sub_pd_ideal hI | S ⊆ J.carrier }\n\n/-- The sub-pd-ideal of I generated by the family `hI.dpow n x`, where `n ∈ ℕ ≥ 0` and `x ∈ S`. -/\ndef generated_dpow {S : set A} (hS : S ⊆ I) :\n  sub_pd_ideal hI := \n{ carrier := ideal.span { y : A | ∃ (n : ℕ) (hn : n ≠ 0) (x : A) (hx : x ∈ S), y = hI.dpow n x },\n  is_sub_ideal := generated_dpow_is_sub_ideal hI hS,\n  dpow_mem_ideal := λ n hn z hz, \n  begin\n    have hSI := generated_dpow_is_sub_ideal hI hS,\n    revert n,\n    refine submodule.span_induction' _ _ _ _ hz,\n    { -- Elements of S\n      rintros y ⟨m, hm, x, hxS, hxy⟩ n hn,\n      rw [hxy, hI.dpow_comp n hm (hS hxS)],\n      exact ideal.mul_mem_left _ _ (ideal.subset_span ⟨n*m, mul_ne_zero hn hm, x, hxS, rfl⟩) },\n    { -- Zero\n      intros n hn,\n      rw hI.dpow_eval_zero hn, exact ideal.zero_mem _ },\n    { intros x hx y hy hx_pow hy_pow n hn,\n      rw hI.dpow_add n (hSI hx) (hSI hy),\n      apply submodule.sum_mem (ideal.span _),\n      intros m hm,\n      by_cases hm0 : m = 0,\n      { rw hm0, exact ideal.mul_mem_left (ideal.span _) _ (hy_pow n hn), },\n      { exact ideal.mul_mem_right _ (ideal.span _) (hx_pow m hm0), }, },\n    { intros a x hx hx_pow n hn,\n      rw [smul_eq_mul, hI.dpow_smul n (hSI hx)],\n      exact ideal.mul_mem_left (ideal.span _) (a ^ n) (hx_pow n hn) }\n  end }\n\nlemma generated_dpow_carrier {S : set A} (hS : S ⊆ I) :\n  (generated_dpow hI hS).carrier = \n  ideal.span { y : A | ∃ (n : ℕ) (hn : n ≠ 0) (x : A) (hx : x ∈ S), y = hI.dpow n x } := rfl\n\nlemma le_generated_dpow {S : set A} (hS : S ⊆ I) :\n  S ⊆ (generated_dpow hI hS).carrier :=\nλ x hx, ideal.subset_span ⟨1, one_ne_zero, x, hx, by rw hI.dpow_one (hS hx)⟩\n\nlemma generated_dpow_le (S : set A) (J : sub_pd_ideal hI) \n  (hSJ : S ⊆ J.carrier) :\n  ideal.span { y : A | ∃ (n : ℕ) (hn : n ≠ 0) (x : A) (hx : x ∈ S), y = hI.dpow n x } ≤ J.carrier :=\nbegin\n  rw ideal.span_le,\n  rintros y ⟨n, hn, x, hx, hxy⟩,\n  rw hxy,\n  exact J.dpow_mem_ideal n hn x (hSJ hx),\nend\n\nlemma generated_carrier_eq {S : set A} (hS : S ⊆ I) :\n  (generated hI S).carrier =\n    ideal.span { y : A | ∃ (n : ℕ) (hn : n ≠ 0) (x : A) (hx : x ∈ S), y = hI.dpow n x } := \nbegin\n  simp only [generated, Inf_carrier_def],\n  apply le_antisymm,\n  { have h : generated_dpow hI hS ∈ insert ⊤ {J : hI.sub_pd_ideal | S ⊆ ↑(J.carrier)},\n  { apply set.mem_insert_of_mem,\n    simp only [set.mem_set_of_eq, generated_dpow_carrier],\n    exact le_generated_dpow hI hS },\n    refine Inf_le_of_le ⟨generated_dpow hI hS, _⟩ (le_refl _),\n    simp only [h, cinfi_pos],\n    refl },\n  { rw le_infi₂_iff,\n    rintros J hJ,\n    refine generated_dpow_le hI S J _,\n    cases set.mem_insert_iff.mp hJ with hJI hJS,\n    { rw hJI, exact hS },\n    { exact hJS }}\nend\n\nend generated\n\n\nend sub_pd_ideal\n\nnamespace quot\n\nvariables {A : Type*} [comm_ring A] {I : ideal A} (hI : divided_powers I)\n\n/- Tagged as noncomputable because it makes use of function.extend, \nbut under is_sub_pd_ideal hI (J ⊓ I), dpow_quot_eq proves that no choices are involved -/\n/-- The definition of divided powers on A ⧸ J -/\nnoncomputable def dpow (J : ideal A) : ℕ → (A ⧸ J) → (A ⧸ J) := \nλ n, function.extend (λ a, ideal.quotient.mk J ↑a : I → A ⧸ J) \n  (λ a, (ideal.quotient.mk J) (hI.dpow n a) : I → A ⧸ J) 0\n\nvariables {J : ideal A} (hIJ : is_sub_pd_ideal hI (J ⊓ I))\n\ninclude hIJ\n\nopen_locale classical\n\n/-- Divided powers on the quotient are compatible with quotient map -/\nlemma dpow_eq {n : ℕ} {a : A} (ha : a ∈ I) :\n  dpow hI J n (ideal.quotient.mk J a) = (ideal.quotient.mk J) (hI.dpow n a) :=\nbegin\n  have ha' : ∃ (a' : ↥I), (ideal.quotient.mk J) ↑a' = (ideal.quotient.mk J) a := ⟨⟨a, ha⟩, rfl⟩,\n  simp only [dpow],\n  rw [ function.extend_def, dif_pos ha', ideal.quotient.eq], \n  apply (is_sub_pd_ideal_inf_iff hI J).mp hIJ n _ _ (set_like.coe_mem _) ha,\n  rw [← ideal.quotient.eq, classical.some_spec ha'], \nend\n\n-- We wish for a better API to denote I.map (ideal.quotient.mk J) as I ⧸ J \n/-- When `I ⊓ J` is a `sub_pd_ideal` of `I`, the dpow map for the ideal `I(A⧸J)` of the quotient -/\nnoncomputable def divided_powers : divided_powers (I.map (ideal.quotient.mk J)) :=\n{ dpow := dpow hI J, \n  dpow_null := λ n x hx, \n  begin\n    simp only [dpow, function.extend_def], \n    have ha' : ¬ ∃ (a' : ↥I), (ideal.quotient.mk J) ↑a' = x,\n    { rintro ⟨a, rfl⟩, \n      exact hx (ideal.apply_coe_mem_map (ideal.quotient.mk J) I a), },\n    rw [dif_neg ha', pi.zero_apply],\n  end,\n  dpow_zero := λ x hx, \n  begin\n    obtain ⟨a, ha, hax⟩ := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    rw [← hax, dpow_eq hI hIJ ha, hI.dpow_zero ha, map_one],\n  end,\n  dpow_one := λ x hx, \n  begin\n    obtain ⟨a, ha, hax⟩ := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    rw [← hax, dpow_eq hI hIJ ha, hI.dpow_one ha],\n  end,\n  dpow_mem := λ n hn x hx, \n  begin \n    simp only [dpow], rw function.extend_def,\n    split_ifs with ha,\n    { rw [ideal.mem_quotient_iff_mem_sup],\n      exact ideal.mem_sup_left (hI.dpow_mem hn (set_like.coe_mem _)) },\n    { exact ideal.zero_mem _ }\n  end, \n  dpow_add := λ n x y hx hy, \n  begin\n    obtain ⟨a, ha, hax⟩ := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    obtain ⟨b, hb, hby⟩ := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hy,\n    rw [← hax, ← hby, ← map_add, dpow_eq hI hIJ (I.add_mem ha hb), hI.dpow_add n ha hb, \n      map_sum, \n finset.sum_congr rfl],\n    { intros k hk, \n      rw [dpow_eq hI hIJ ha, dpow_eq hI hIJ hb, ← map_mul] },\n  end,\n  dpow_smul := λ n x y hy, \n  begin\n    obtain ⟨a, rfl⟩ := ideal.quotient.mk_surjective x, \n    obtain ⟨b, hb, hby⟩ := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hy,\n    rw [← hby, dpow_eq hI hIJ hb, ← map_mul, ← map_pow, dpow_eq hI hIJ (ideal.mul_mem_left I a hb),\n      hI.dpow_smul n hb, map_mul],\n    end,\n  dpow_mul := λ m n x hx, \n  begin\n    obtain ⟨a, ha, hax⟩ := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    simp only [← hax, dpow_eq hI hIJ ha], \n    rw [← map_mul, hI.dpow_mul m n ha, map_mul, map_nat_cast],\n  end,\n  dpow_comp := λ m n hn x hx,\n  begin \n    obtain ⟨a, ha, hax⟩ := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    simp only [← hax, dpow_eq hI hIJ, ha, hI.dpow_mem hn ha],\n    rw [hI.dpow_comp m hn ha, map_mul, map_nat_cast],\n  end }\n\nlemma divided_powers_dpow_quot_apply {n : ℕ} {x : A ⧸ J} :\n  (divided_powers hI hIJ).dpow n x = dpow hI J n x :=\nrfl\n\nlemma divided_powers_quot_unique (hquot : _root_.divided_powers (I.map (ideal.quotient.mk J)))\n  (hm : is_pd_morphism hI hquot (ideal.quotient.mk J)) :\n  hquot = divided_powers hI hIJ := eq_of_eq_on_ideal _ _ $ λ n x hx,\nbegin\n  obtain ⟨a, ha, hax⟩ := \n  (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n  rw [← hax, hm.dpow_comp n a ha, divided_powers_dpow_quot_apply, dpow_eq hI hIJ ha],\nend\n\nend quot\n\nend divided_powers", "meta": {"author": "AntoineChambert-Loir", "repo": "divided_powers", "sha": "86b6f8716590d38e63ed11d34c0140de8ae2af7d", "save_path": "github-repos/lean/AntoineChambert-Loir-divided_powers", "path": "github-repos/lean/AntoineChambert-Loir-divided_powers/divided_powers-86b6f8716590d38e63ed11d34c0140de8ae2af7d/src/divided_powers/sub_pd_ideal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4826443451363598}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.category.preorder\nimport category_theory.isomorphism_classes\nimport category_theory.thin\n\n/-!\n# Skeleton of a category\n\nDefine skeletal categories as categories in which any two isomorphic objects are equal.\n\nConstruct the skeleton of an arbitrary category by taking isomorphism classes, and show it is a\nskeleton of the original category.\n\nIn addition, construct the skeleton of a thin category as a partial ordering, and (noncomputably)\nshow it is a skeleton of the original category. The advantage of this special case being handled\nseparately is that lemmas and definitions about orderings can be used directly, for example for the\nsubobject lattice. In addition, some of the commutative diagrams about the functors commute\ndefinitionally on the nose which is convenient in practice.\n-/\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\nnamespace category_theory\n\nopen category\n\nvariables (C : Type u₁) [category.{v₁} C]\nvariables (D : Type u₂) [category.{v₂} D]\nvariables {E : Type u₃} [category.{v₃} E]\n\n/-- A category is skeletal if isomorphic objects are equal. -/\ndef skeletal : Prop := ∀ ⦃X Y : C⦄, is_isomorphic X Y → X = Y\n\n/--\n`is_skeleton_of C D F` says that `F : D ⥤ C` exhibits `D` as a skeletal full subcategory of `C`,\nin particular `F` is a (strong) equivalence and `D` is skeletal.\n-/\nstructure is_skeleton_of (F : D ⥤ C) :=\n(skel : skeletal D)\n(eqv : is_equivalence F)\n\nlocal attribute [instance] is_isomorphic_setoid\n\nvariables {C D}\n/-- If `C` is thin and skeletal, then any naturally isomorphic functors to `C` are equal. -/\nlemma functor.eq_of_iso {F₁ F₂ : D ⥤ C} [∀ X Y : C, subsingleton (X ⟶ Y)] (hC : skeletal C)\n  (hF : F₁ ≅ F₂) : F₁ = F₂ :=\nfunctor.ext (λ X, hC ⟨hF.app X⟩) (λ _ _ _, subsingleton.elim _ _)\n\n/--\nIf `C` is thin and skeletal, `D ⥤ C` is skeletal.\n`category_theory.functor_thin` shows it is thin also.\n-/\nlemma functor_skeletal [∀ X Y : C, subsingleton (X ⟶ Y)] (hC : skeletal C) : skeletal (D ⥤ C) :=\nλ F₁ F₂ h, h.elim (functor.eq_of_iso hC)\nvariables (C D)\n\n/--\nConstruct the skeleton category as the induced category on the isomorphism classes, and derive\nits category structure.\n-/\n@[derive category]\ndef skeleton : Type u₁ := induced_category C quotient.out\n\ninstance [inhabited C] : inhabited (skeleton C) := ⟨⟦default C⟧⟩\n\n/-- The functor from the skeleton of `C` to `C`. -/\n@[simps, derive [full, faithful]]\nnoncomputable def from_skeleton : skeleton C ⥤ C := induced_functor _\n\ninstance : ess_surj (from_skeleton C) :=\n{ mem_ess_image := λ X, ⟨quotient.mk X, quotient.mk_out X⟩ }\n\nnoncomputable instance : is_equivalence (from_skeleton C) :=\nequivalence.of_fully_faithfully_ess_surj (from_skeleton C)\n\n/-- The equivalence between the skeleton and the category itself. -/\nnoncomputable def skeleton_equivalence : skeleton C ≌ C :=\n(from_skeleton C).as_equivalence\n\nlemma skeleton_skeletal : skeletal (skeleton C) :=\nbegin\n  rintro X Y ⟨h⟩,\n  have : X.out ≈ Y.out := ⟨(from_skeleton C).map_iso h⟩,\n  simpa using quotient.sound this,\nend\n\n/-- The `skeleton` of `C` given by choice is a skeleton of `C`. -/\nnoncomputable def skeleton_is_skeleton : is_skeleton_of C (skeleton C) (from_skeleton C) :=\n{ skel := skeleton_skeletal C,\n  eqv := from_skeleton.is_equivalence C }\n\nsection\nvariables {C D}\n\n/--\nTwo categories which are categorically equivalent have skeletons with equivalent objects.\n-/\nnoncomputable\ndef equivalence.skeleton_equiv (e : C ≌ D) : skeleton C ≃ skeleton D :=\nlet f := ((skeleton_equivalence C).trans e).trans (skeleton_equivalence D).symm in\n{ to_fun := f.functor.obj,\n  inv_fun := f.inverse.obj,\n  left_inv := λ X, skeleton_skeletal C ⟨(f.unit_iso.app X).symm⟩,\n  right_inv := λ Y, skeleton_skeletal D ⟨(f.counit_iso.app Y)⟩, }\n\nend\n\n/--\nConstruct the skeleton category by taking the quotient of objects. This construction gives a\npreorder with nice definitional properties, but is only really appropriate for thin categories.\nIf your original category is not thin, you probably want to be using `skeleton` instead of this.\n-/\ndef thin_skeleton : Type u₁ := quotient (is_isomorphic_setoid C)\n\ninstance inhabited_thin_skeleton [inhabited C] : inhabited (thin_skeleton C) :=\n⟨quotient.mk (default _)⟩\n\ninstance thin_skeleton.preorder : preorder (thin_skeleton C) :=\n{ le := quotient.lift₂ (λ X Y, nonempty (X ⟶ Y))\n  begin\n    rintros _ _ _ _ ⟨i₁⟩ ⟨i₂⟩,\n    exact propext ⟨nonempty.map (λ f, i₁.inv ≫ f ≫ i₂.hom),\n      nonempty.map (λ f, i₁.hom ≫ f ≫ i₂.inv)⟩,\n  end,\n  le_refl :=\n  begin\n    refine quotient.ind (λ a, _),\n    exact ⟨𝟙 _⟩,\n  end,\n  le_trans := λ a b c, quotient.induction_on₃ a b c $ λ A B C, nonempty.map2 (≫) }\n\n/-- The functor from a category to its thin skeleton. -/\n@[simps]\ndef to_thin_skeleton : C ⥤ thin_skeleton C :=\n{ obj := quotient.mk,\n  map := λ X Y f, hom_of_le (nonempty.intro f) }\n\n/-!\nThe constructions here are intended to be used when the category `C` is thin, even though\nsome of the statements can be shown without this assumption.\n-/\nnamespace thin_skeleton\n\n/-- The thin skeleton is thin. -/\ninstance thin {X Y : thin_skeleton C} : subsingleton (X ⟶ Y) :=\n⟨by { rintros ⟨⟨f₁⟩⟩ ⟨⟨f₂⟩⟩, refl }⟩\n\nvariables {C} {D}\n\n/-- A functor `C ⥤ D` computably lowers to a functor `thin_skeleton C ⥤ thin_skeleton D`. -/\n@[simps]\ndef map (F : C ⥤ D) : thin_skeleton C ⥤ thin_skeleton D :=\n{ obj := quotient.map F.obj $ λ X₁ X₂ ⟨hX⟩, ⟨F.map_iso hX⟩,\n  map := λ X Y, quotient.rec_on_subsingleton₂ X Y $\n           λ x y k, hom_of_le (k.le.elim (λ t, ⟨F.map t⟩)) }\n\nlemma comp_to_thin_skeleton (F : C ⥤ D) : F ⋙ to_thin_skeleton D = to_thin_skeleton C ⋙ map F :=\nrfl\n\n/-- Given a natural transformation `F₁ ⟶ F₂`, induce a natural transformation `map F₁ ⟶ map F₂`.-/\ndef map_nat_trans {F₁ F₂ : C ⥤ D} (k : F₁ ⟶ F₂) : map F₁ ⟶ map F₂ :=\n{ app := λ X, quotient.rec_on_subsingleton X (λ x, ⟨⟨⟨k.app x⟩⟩⟩) }\n\n-- TODO: state the lemmas about what happens when you compose with `to_thin_skeleton`\n/-- A functor `C ⥤ D ⥤ E` computably lowers to a functor\n`thin_skeleton C ⥤ thin_skeleton D ⥤ thin_skeleton E` -/\n@[simps]\ndef map₂ (F : C ⥤ D ⥤ E) :\n  thin_skeleton C ⥤ thin_skeleton D ⥤ thin_skeleton E :=\n{ obj := λ x,\n  { obj := λ y, quotient.map₂ (λ X Y, (F.obj X).obj Y)\n                (λ X₁ X₂ ⟨hX⟩ Y₁ Y₂ ⟨hY⟩, ⟨(F.obj X₁).map_iso hY ≪≫ (F.map_iso hX).app Y₂⟩) x y,\n    map := λ y₁ y₂, quotient.rec_on_subsingleton x $\n            λ X, quotient.rec_on_subsingleton₂ y₁ y₂ $\n              λ Y₁ Y₂ hY, hom_of_le (hY.le.elim (λ g, ⟨(F.obj X).map g⟩)) },\n  map := λ x₁ x₂, quotient.rec_on_subsingleton₂ x₁ x₂ $\n           λ X₁ X₂ f,\n           { app := λ y, quotient.rec_on_subsingleton y\n              (λ Y, hom_of_le (f.le.elim (λ f', ⟨(F.map f').app Y⟩))) } }\n\nvariables (C)\n\nsection\nvariables [∀ X Y : C, subsingleton (X ⟶ Y)]\n\ninstance to_thin_skeleton_faithful : faithful (to_thin_skeleton C) := {}\n\n/-- Use `quotient.out` to create a functor out of the thin skeleton. -/\n@[simps]\nnoncomputable def from_thin_skeleton : thin_skeleton C ⥤ C :=\n{ obj := quotient.out,\n  map := λ x y, quotient.rec_on_subsingleton₂ x y $\n    λ X Y f,\n            (nonempty.some (quotient.mk_out X)).hom\n          ≫ f.le.some\n          ≫ (nonempty.some (quotient.mk_out Y)).inv }\n\nnoncomputable instance from_thin_skeleton_equivalence : is_equivalence (from_thin_skeleton C) :=\n{ inverse := to_thin_skeleton C,\n  counit_iso := nat_iso.of_components (λ X, (nonempty.some (quotient.mk_out X))) (by tidy),\n  unit_iso :=\n    nat_iso.of_components\n      (λ x, quotient.rec_on_subsingleton x\n        (λ X, eq_to_iso (quotient.sound ⟨(nonempty.some (quotient.mk_out X)).symm⟩)))\n      (by tidy) }\n\n/-- The equivalence between the thin skeleton and the category itself. -/\nnoncomputable def equivalence : thin_skeleton C ≌ C :=\n(from_thin_skeleton C).as_equivalence\n\nvariables {C}\n\nlemma equiv_of_both_ways {X Y : C} (f : X ⟶ Y) (g : Y ⟶ X) : X ≈ Y :=\n⟨iso_of_both_ways f g⟩\n\ninstance thin_skeleton_partial_order : partial_order (thin_skeleton C) :=\n{ le_antisymm := quotient.ind₂\n  begin\n    rintros _ _ ⟨f⟩ ⟨g⟩,\n    apply quotient.sound (equiv_of_both_ways f g),\n  end,\n  ..category_theory.thin_skeleton.preorder C }\n\nlemma skeletal : skeletal (thin_skeleton C) :=\nλ X Y, quotient.induction_on₂ X Y $ λ x y h, h.elim $ λ i, i.1.le.antisymm i.2.le\n\nlemma map_comp_eq (F : E ⥤ D) (G : D ⥤ C) : map (F ⋙ G) = map F ⋙ map G :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (λ X, quotient.rec_on_subsingleton X (λ x, iso.refl _)) (by tidy)\n\nlemma map_id_eq : map (𝟭 C) = 𝟭 (thin_skeleton C) :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (λ X, quotient.rec_on_subsingleton X (λ x, iso.refl _)) (by tidy)\n\nlemma map_iso_eq {F₁ F₂ : D ⥤ C} (h : F₁ ≅ F₂) : map F₁ = map F₂ :=\nfunctor.eq_of_iso skeletal { hom := map_nat_trans h.hom, inv := map_nat_trans h.inv }\n\n/-- `from_thin_skeleton C` exhibits the thin skeleton as a skeleton. -/\nnoncomputable def thin_skeleton_is_skeleton : is_skeleton_of C (thin_skeleton C)\n  (from_thin_skeleton C) :=\n{ skel := skeletal,\n  eqv := thin_skeleton.from_thin_skeleton_equivalence C }\n\nnoncomputable instance is_skeleton_of_inhabited :\n  inhabited (is_skeleton_of C (thin_skeleton C) (from_thin_skeleton C)) :=\n⟨thin_skeleton_is_skeleton⟩\n\nend\n\nvariables {C}\n\n/-- An adjunction between thin categories gives an adjunction between their thin skeletons. -/\ndef lower_adjunction\n  (R : D ⥤ C) (L : C ⥤ D) (h : L ⊣ R) :\n  thin_skeleton.map L ⊣ thin_skeleton.map R :=\nadjunction.mk_of_unit_counit\n{ unit :=\n  { app := λ X,\n    begin\n      letI := is_isomorphic_setoid C,\n      refine quotient.rec_on_subsingleton X (λ x, hom_of_le ⟨h.unit.app x⟩),\n      -- TODO: make quotient.rec_on_subsingleton' so the letI isn't needed\n    end },\n  counit :=\n  { app := λ X,\n    begin\n      letI := is_isomorphic_setoid D,\n      refine quotient.rec_on_subsingleton X (λ x, hom_of_le ⟨h.counit.app x⟩),\n    end } }\n\nend thin_skeleton\n\nopen thin_skeleton\n\nsection\nvariables {C} {α : Type*} [partial_order α]\n\n/--\nWhen `e : C ≌ α` is a categorical equivalence from a thin category `C` to some partial order `α`,\nthe `thin_skeleton C` is order isomorphic to `α`.\n-/\nnoncomputable\ndef equivalence.thin_skeleton_order_iso\n  [∀ X Y : C, subsingleton (X ⟶ Y)] (e : C ≌ α) : thin_skeleton C ≃o α :=\n((thin_skeleton.equivalence C).trans e).to_order_iso\n\nend\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/skeletal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6187804267137441, "lm_q1q2_score": 0.4826443396529271}}
{"text": "import rescale.polyhedral_lattice\nimport polyhedral_lattice.cech\n\nimport facts.nnreal\n\n/-!\n# The cosimplicial polyhedral lattice attached to `Λ → Λ'`\n\nLet `Λ` be a polyhedral lattice, and let `0 < n` be a natural number.\nLet `Λ' := rescale n (fin n →₀ Λ)` be the polyhedral lattice\nthat is the `n`-fold direct sum of `Λ` with itself,\nendowed with the norm `∥(l₁, l₂, ..., lₙ)∥ = (∥l₁∥ + ∥l₂∥ + ... + ∥lₙ∥) / n`.\n\nThe diagonal embedding `Λ → Λ'` is a norm-nonincreasing map.\nIn this file we construct the Cech conerve of this map.\nIt is a cosimplicial object in the category `PolyhedralLattice`.\n\nConcretely, but in pseudo-code:\nit consists of the objects `Λ'^(m)` defined as `(Λ')^m/L`,\nwhere `L` is the sublattice `Λ ⊗ {x : ℤ^m | ∑ x = 0}`.\n-/\n\nnoncomputable theory\n\nuniverse variables u\n\nopen_locale nnreal big_operators\nopen category_theory finsupp\n\nnamespace PolyhedralLattice\n\nvariables (Λ : PolyhedralLattice.{u}) (N : ℕ) [hN : fact (0 < N)]\n\ninclude hN\n\ndef rescaled_power : PolyhedralLattice :=\nof (rescale N $ fin N →₀ Λ)\n\ndef diagonal_embedding : Λ ⟶ rescaled_power Λ N :=\n{ to_fun := λ l, @rescale.of N (fin N →₀ Λ) $ ∑ i, single_add_hom i l,\n  map_add' := λ l₁ l₂, by { simp only [add_monoid_hom.map_add, finset.sum_add_distrib], refl }, -- defeq abuse\n  strict' := λ l,\n  begin\n    rw [rescale.norm_def, equiv.symm_apply_apply, norm_def, nnreal.coe_nat_cast,\n      sum_fintype],\n    swap, { intro, exact norm_zero },\n    apply le_of_eq,\n    rw div_eq_iff, swap,\n    { norm_cast, exact hN.out.ne' },\n    simp only [← apply_add_hom_apply, add_monoid_hom.map_sum],\n    simp only [apply_add_hom_apply, single_add_hom_apply, single_apply],\n    convert finset.sum_const (∥l∥ : ℝ),\n    { ext i, simp only [finset.sum_ite_eq', finset.mem_univ, if_true] },\n    rw [mul_comm, nsmul_eq_mul, finset.card_univ, fintype.card_fin],\n  end }\n.\n\nlemma diagonal_embedding_apply (l : Λ) (i : fin N) :\n  ((@rescale.of N ((fin N) →₀ Λ)).symm (Λ.diagonal_embedding N l) : fin N →₀ Λ) i = l :=\nby simp only [diagonal_embedding, single_add_hom_apply, finset.sum_apply',\n    polyhedral_lattice_hom.coe_mk, equiv.symm_apply_apply, finsupp.single_apply,\n    finset.sum_ite_eq', finset.mem_univ, if_true]\n\ndef cosimplicial_lift {M : Type*} [add_comm_group M] (m : ℕ) (g₀ : Λ →+ M)\n  (g : fin (m + 1) → (Λ.rescaled_power N →+ M))\n  (hg : ∀ i l, (g i) (Λ.diagonal_embedding N l) = g₀ l) :\n  polyhedral_lattice.conerve.obj (Λ.diagonal_embedding N) (m + 1) →+ M :=\npolyhedral_lattice.conerve.lift' _ m g₀ g hg $\nbegin\n  intros l₁ l₂ h,\n  rw [finsupp.ext_iff] at h,\n  specialize h ⟨0, fact.out _⟩,\n  erw [diagonal_embedding_apply, diagonal_embedding_apply] at h,\n  exact h\nend\n\nlemma zsmul_rescaled_power (n : ℤ) (l : Λ.rescaled_power N) :\n  n • (@rescale.of N ((fin N) →₀ Λ)).symm l = (@rescale.of N ((fin N) →₀ Λ)).symm (n • l) :=\nrfl\n\ninstance : fact (polyhedral_lattice_hom.to_add_monoid_hom (Λ.diagonal_embedding N)).range.saturated :=\nbegin\n  constructor,\n  rw add_subgroup.saturated_iff_zsmul,\n  intros n l' h,\n  by_cases hn : n = 0, { exact or.inl hn },\n  let l₀ : ↥Λ := ((@rescale.of N ((fin N) →₀ Λ)).symm l' : fin N →₀ Λ) ⟨0, hN.1⟩,\n  refine or.inr ⟨l₀, _⟩,\n  simp only [polyhedral_lattice_hom.coe_to_add_monoid_hom, add_monoid_hom.mem_range] at h ⊢,\n  obtain ⟨l, hl⟩ := h,\n  refine @smul_right_injective ℤ _ _ _ _ _ n hn _ _ _,\n  rw [← hl, ← polyhedral_lattice_hom.map_zsmul],\n  dsimp only [l₀],\n  rw [← finsupp.smul_apply, zsmul_rescaled_power _ _ n l', ← hl, diagonal_embedding_apply],\nend\n\ndef cosimplicial : cosimplicial_object PolyhedralLattice.{u} :=\nCech_conerve $ diagonal_embedding Λ N\n\nopen simplex_category\n\ndef cosimplicial_augmentation_map : Λ ⟶ (cosimplicial Λ N).obj (mk 0) :=\nCech_augmentation_map _\n\ndef augmented_cosimplicial : cosimplicial_object.augmented PolyhedralLattice.{u} :=\naugmented_Cech_conerve $ diagonal_embedding Λ N\n\nend PolyhedralLattice\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/polyhedral_lattice/cosimplicial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.48264433880722957}}
{"text": "-- An exploration of examples from Conor McBride's CS410: Advanced Functional\n-- Programming. Originally written in Agda, translated to Lean 4.\n\nuniverse u\n\ninductive Zero : Type u where\n#check Zero\n\nstructure One : Type where\n#check One\n#check One.mk\n#check ({ } : One)\n\n-- This is Conor's `+`.\ninductive Either (S : Type u) (T : Type u) : Type u where\n  | inl : S → Either S T\n  | inr : T → Either S T\n\nstructure Product (S : Type u) (T : Type u) : Type u where\n  fst : S\n  snd : T\n\ntheorem productIsCommutative : Product α β → Product β α := by\n  intro h\n  let a := h.fst\n  let b := h.snd\n  apply Product.mk\n  assumption\n  assumption\n\ntheorem eitherIsCommutative : Either A B → Either B A := by\n  intro h\n  cases h\n  apply Either.inr\n  assumption\n  apply Either.inl\n  assumption\n\n-- An alternate proof with pattern matching, using Lean 4's built in `Sum` type\n-- instead.\n--\n-- The bullet notation `. <tactics>` is just a way of structuring the proof,\n-- i.e. starting work on a specific subgoal and increasing the indentation\n-- level. It is not an operator, and removing the bullets and the indentation\n-- will result in an identical proof. See TPIL, specifically, the 'Tactics'\n-- section.\ntheorem sumIsCommutative {α β : Type u} : Sum α β → Sum β α := by\n  intro h\n  cases h\n  . apply Sum.inr\n    assumption\n  . apply Sum.inl\n    assumption\n\n\ntheorem eitherIsAssociative : Either (Either α β) γ → Either α (Either β γ) := by\n  intro h\n  cases h\n  case inl h =>\n    cases h\n    apply Either.inl\n    assumption\n    apply Either.inr\n    apply Either.inl\n    assumption\n  case inr h =>\n    apply Either.inr\n    apply Either.inr\n    assumption\n\n#check eitherIsAssociative\n\n\ntheorem vBad : Zero → α := by\n  intro z\n  cases z\n\n\ndef hello := \"world\"\n", "meta": {"author": "langfield", "repo": "mcbride", "sha": "4daa0da257fc77e6ec1aa52526b3d0107c8ea23d", "save_path": "github-repos/lean/langfield-mcbride", "path": "github-repos/lean/langfield-mcbride/mcbride-4daa0da257fc77e6ec1aa52526b3d0107c8ea23d/Mcbride.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257127, "lm_q2_score": 0.6187804267137442, "lm_q1q2_score": 0.4826443333237971}}
{"text": "lemma ne_succ_self (n : mynat) : n ≠ succ n :=\nbegin\ninduction n with h hd,\napply zero_ne_succ,\nintro hs,\napply hd,\napply succ_inj,\nexact hs,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world08/level13.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.629774621301746, "lm_q1q2_score": 0.4825922888803957}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen\n-/\nimport ring_theory.localization.fraction_ring\nimport ring_theory.localization.integer\nimport ring_theory.unique_factorization_domain\n\n/-!\n# Numerator and denominator in a localization\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n## Implementation notes\n\nSee `src/ring_theory/localization/basic.lean` for a design overview.\n\n## Tags\nlocalization, ring localization, commutative ring localization, characteristic predicate,\ncommutative ring, field of fractions\n-/\nvariables {R : Type*} [comm_ring R] (M : submonoid R) {S : Type*} [comm_ring S]\nvariables [algebra R S] {P : Type*} [comm_ring P]\n\nnamespace is_fraction_ring\n\nopen is_localization\n\nsection num_denom\n\nvariables (A : Type*) [comm_ring A] [is_domain A] [unique_factorization_monoid A]\nvariables {K : Type*} [field K] [algebra A K] [is_fraction_ring A K]\n\nlemma exists_reduced_fraction (x : K) :\n  ∃ (a : A) (b : non_zero_divisors A),\n  (∀ {d}, d ∣ a → d ∣ b → is_unit d) ∧ mk' K a b = x :=\nbegin\n  obtain ⟨⟨b, b_nonzero⟩, a, hab⟩ := exists_integer_multiple (non_zero_divisors A) x,\n  obtain ⟨a', b', c', no_factor, rfl, rfl⟩ :=\n    unique_factorization_monoid.exists_reduced_factors' a b\n      (mem_non_zero_divisors_iff_ne_zero.mp b_nonzero),\n  obtain ⟨c'_nonzero, b'_nonzero⟩ := mul_mem_non_zero_divisors.mp b_nonzero,\n  refine ⟨a', ⟨b', b'_nonzero⟩, @no_factor, _⟩,\n  refine mul_left_cancel₀\n    (is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors b_nonzero) _,\n  simp only [subtype.coe_mk, ring_hom.map_mul, algebra.smul_def] at *,\n  erw [←hab, mul_assoc, mk'_spec' _ a' ⟨b', b'_nonzero⟩],\nend\n\n/-- `f.num x` is the numerator of `x : f.codomain` as a reduced fraction. -/\nnoncomputable def num (x : K) : A :=\nclassical.some (exists_reduced_fraction A x)\n\n/-- `f.num x` is the denominator of `x : f.codomain` as a reduced fraction. -/\nnoncomputable def denom (x : K) : non_zero_divisors A :=\nclassical.some (classical.some_spec (exists_reduced_fraction A x))\n\nlemma num_denom_reduced (x : K) {d} : d ∣ num A x → d ∣ denom A x → is_unit d :=\n(classical.some_spec (classical.some_spec (exists_reduced_fraction A x))).1\n\n@[simp] lemma mk'_num_denom (x : K) : mk' K (num A x) (denom A x) = x :=\n(classical.some_spec (classical.some_spec (exists_reduced_fraction A x))).2\n\nvariables {A}\n\nlemma num_mul_denom_eq_num_iff_eq {x y : K} :\n  x * algebra_map A K (denom A y) = algebra_map A K (num A y) ↔ x = y :=\n⟨λ h, by simpa only [mk'_num_denom] using eq_mk'_iff_mul_eq.mpr h,\n λ h, eq_mk'_iff_mul_eq.mp (by rw [h, mk'_num_denom])⟩\n\nlemma num_mul_denom_eq_num_iff_eq' {x y : K} :\n  y * algebra_map A K (denom A x) = algebra_map A K (num A x) ↔ x = y :=\n⟨λ h, by simpa only [eq_comm, mk'_num_denom] using eq_mk'_iff_mul_eq.mpr h,\n λ h, eq_mk'_iff_mul_eq.mp (by rw [h, mk'_num_denom])⟩\n\nlemma num_mul_denom_eq_num_mul_denom_iff_eq {x y : K} :\n  num A y * denom A x = num A x * denom A y ↔ x = y :=\n⟨λ h, by simpa only [mk'_num_denom] using mk'_eq_of_eq' h,\n λ h, by rw h⟩\n\nlemma eq_zero_of_num_eq_zero {x : K} (h : num A x = 0) : x = 0 :=\nnum_mul_denom_eq_num_iff_eq'.mp (by rw [zero_mul, h, ring_hom.map_zero])\n\nlemma is_integer_of_is_unit_denom {x : K} (h : is_unit (denom A x : A)) : is_integer A x :=\nbegin\n  cases h with d hd,\n  have d_ne_zero : algebra_map A K (denom A x) ≠ 0 :=\n    is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors (denom A x).2,\n  use ↑d⁻¹ * num A x,\n  refine trans _ (mk'_num_denom A x),\n  rw [map_mul, map_units_inv, hd],\n  apply mul_left_cancel₀ d_ne_zero,\n  rw [←mul_assoc, mul_inv_cancel d_ne_zero, one_mul, mk'_spec']\nend\n\nlemma is_unit_denom_of_num_eq_zero {x : K} (h : num A x = 0) : is_unit (denom A x : A) :=\nnum_denom_reduced A x (h.symm ▸ dvd_zero _) dvd_rfl\n\nend num_denom\n\nvariables (S)\n\nend is_fraction_ring\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/localization/num_denom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.48259228888039557}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.algebraic_topology.homotopical_algebra.fundamental_lemma\nimport for_mathlib.algebraic_topology.homotopical_algebra.over\nimport for_mathlib.category_theory.functor_misc\n\nnoncomputable theory\n\nopen algebraic_topology\nopen category_theory category_theory.category\n\nlemma category_theory.functor.is_iso_map_iff {C D : Type*} [category C] [category D]\n  (F : C ⥤ D) [reflects_isomorphisms F] {X Y : C} (f : X ⟶ Y) : is_iso (F.map f) ↔ is_iso f :=\nbegin\n  split,\n  { introI,\n    exact is_iso_of_reflects_iso f F, },\n  { introI,\n    apply_instance, },\nend\n\nnamespace category_theory.morphism_property.three_of_two\n\nvariables {C : Type*} [category C] {X Y X' Y' : C}\n  {f : X ⟶ Y} {f' : X' ⟶ Y'} {g : X ⟶ X'} {g' : Y ⟶ Y'}\n\nlemma left_iff_right_of_sq {P : morphism_property C}\n  (h : P.three_of_two) (sq : comm_sq g f f' g') (hg : P g) (hg' : P g'):\n  P f ↔ P f' :=\nbegin\n  split,\n  { intro hf,\n    refine h.of_comp_left g f' hg _,\n    rw sq.w,\n    exact h.of_comp _ _ hf hg', },\n  { intro hf',\n    refine h.of_comp_right f g' hg' _,\n    rw ← sq.w,\n    exact h.of_comp _ _ hg hf', },\nend\n\nend category_theory.morphism_property.three_of_two\n\nopen category_theory\n\nnamespace algebraic_topology\n\nnamespace model_category\n\nvariables {C : Type*} [category C] [model_category C]\n  {Ho : Type*} [category Ho] (L : C ⥤ Ho) [L.is_localization weq]\n  {Hocof : Type*} [category Hocof] (Lcof : cofibrant_object C ⥤ Hocof)\n    [Lcof.is_localization cofibrant_object.weq]\n  {Hobif : Type*} [category Hobif] (Lbif : bifibrant_object C ⥤ Hobif)\n    [Lbif.is_localization bifibrant_object.weq]\n\nlemma strong_deformation_retract_of_cofibration_and_homotopy_equivalence\n  {X Y : bifibrant_object C} (f : X ⟶ Y) [is_iso (Lbif.map f)] :\n  ∃ (g : Y ⟶ X) (hg₁ : f ≫ g = 𝟙 X) (P : path_object Y.obj)\n    (H : right_homotopy P.pre ((bifibrant_object.forget C).map (g ≫ f)) (𝟙 Y.obj)),\n    (bifibrant_object.forget C).map f ≫ H.h = (bifibrant_object.forget C).map f ≫ P.σ :=\nbegin\n  sorry,\nend\n\nlemma bifibrant_object.is_iso_Lbif_map_cofibration_iff\n  {X Y : bifibrant_object C} (f : X ⟶ Y) [cofibration ((bifibrant_object.forget C).map f)] :\n  is_iso (Lbif.map f) ↔ bifibrant_object.weq f :=\nbegin\n  refine ⟨_, localization.inverts Lbif bifibrant_object.weq f⟩,\n  introI,\n  rcases strong_deformation_retract_of_cofibration_and_homotopy_equivalence Lbif f\n    with ⟨g, hg₁, P, H, property⟩,\n  let f' := (bifibrant_object.forget C).map f,\n  let W := CM5a.obj f',\n  let i : X.obj ⟶ W := CM5a.i f',\n  let p : W ⟶ Y.obj := CM5a.p f',\n  have sq : comm_sq i f' p (𝟙 Y.obj) :=\n    comm_sq.mk (by simpa only [CM5a.fac f'] using (comp_id f').symm),\n  suffices : sq.has_lift,\n  { haveI := this,\n    refine CM3a f' i _ weak_eq.property,\n    have fac₁ : 𝟙 X.obj ≫ i = f' ≫ sq.lift := by rw [id_comp, sq.fac_left],\n    have fac₂ : 𝟙 X.obj ≫ f' = i ≫ p := by rw [id_comp, CM5a.fac f'],\n    refine is_retract.mk (arrow.hom_mk fac₁) (arrow.hom_mk fac₂) _,\n    ext,\n    { apply comp_id, },\n    { exact sq.fac_right, }, },\n  sorry,\nend\n\nlemma bifibrant_object.is_iso_Lbif_map_iff\n  {X Y : bifibrant_object C} (f : X ⟶ Y) :\n  is_iso (Lbif.map f) ↔ bifibrant_object.weq f :=\nbegin\n  split,\n  { intro hf,\n    let f' := (bifibrant_object.forget C).map f,\n    let Z := CM5b.obj f',\n    let i : X ⟶ bifibrant_object.mk Z := CM5b.i f',\n    let p : bifibrant_object.mk Z ⟶ Y := CM5b.p f',\n    have h : i ≫ p = f := CM5b.fac f',\n    rw ← h,\n    rw [← h, Lbif.map_comp] at hf,\n    haveI := hf,\n    haveI : weak_eq ((bifibrant_object.forget C).map p) := (infer_instance : weak_eq (CM5b.p f')),\n    haveI : cofibration ((bifibrant_object.forget C).map i) := (infer_instance : cofibration (CM5b.i f')),\n    haveI := is_iso_Lbif_map Lbif p,\n    haveI : is_iso (Lbif.map i) := is_iso.of_is_iso_comp_right _ (Lbif.map p),\n    refine CM2.of_comp _ _ _ weak_eq.property,\n    exact (bifibrant_object.is_iso_Lbif_map_cofibration_iff Lbif i).mp infer_instance, },\n  { exact localization.inverts Lbif bifibrant_object.weq f, },\nend\n\nlemma bifibrant_object.is_iso_Lbif_map_iff_is_iso_Lcof_map\n  {X Y : bifibrant_object C} (f : X ⟶ Y) :\n  is_iso (Lbif.map f) ↔ is_iso (Lcof.map ((bifibrant_object.forget_fib C).map f)) :=\nby rw [← (Hobif_to_Hocof Lcof Lbif).is_iso_map_iff, ← functor.comp_map,\n  is_iso_map_iff_of_nat_iso (Lbif_comp_Hobif_to_Hocof_iso Lcof Lbif), functor.comp_map]\n\nlemma cofibrant_object.is_iso_Lcof_map_iff\n  {X Y : cofibrant_object C} (f : X ⟶ Y) :\n  is_iso (Lcof.map f) ↔ cofibrant_object.weq f :=\nbegin\n  split,\n  { intro hf,\n    change (morphism_property.isomorphisms _).inverse_image Lcof f at hf,\n    have sq := comm_sq.mk (bifibrant_replacement.fac f),\n    rw ((morphism_property.three_of_two.for_isomorphisms _).for_inverse_image Lcof).left_iff_right_of_sq sq\n      (is_iso_Lcof_map' Lcof _ weak_eq.property) (is_iso_Lcof_map' Lcof _ weak_eq.property) at hf,\n    change is_iso _ at hf,\n    rw ← bifibrant_object.is_iso_Lbif_map_iff_is_iso_Lcof_map Lcof\n      bifibrant_object.homotopy_category.Q at hf,\n    rw bifibrant_object.is_iso_Lbif_map_iff at hf,\n    exact (CM2.left_iff_right_of_sq ((cofibrant_object.forget C).map_comm_sq sq) weak_eq.property weak_eq.property).mpr hf, },\n  { exact localization.inverts Lcof cofibrant_object.weq f, },\nend\n\nlemma is_iso_Lcof_map_iff_is_iso_L_map\n  {X Y : cofibrant_object C} (f : X ⟶ Y) :\n  is_iso (Lcof.map f) ↔ is_iso (L.map ((cofibrant_object.forget C).map f)) :=\nby rw [← (Hocof_to_Ho Lcof L).is_iso_map_iff, ← functor.comp_map,\n  is_iso_map_iff_of_nat_iso (Lcof_comp_Hocof_to_Ho_iso Lcof L), functor.comp_map]\n\nlemma is_iso_L_map_iff {X Y : C} (f : X ⟶ Y) :\n  is_iso (L.map f) ↔ weq f :=\nbegin\n  split,\n  { intro hf,\n    change (morphism_property.isomorphisms _).inverse_image L f at hf,\n    have sq := comm_sq.mk (cofibrant_replacement.fac f),\n    have eq := ((morphism_property.three_of_two.for_isomorphisms _).for_inverse_image L).left_iff_right_of_sq sq.flip (by { change is_iso _, apply_instance, }) (by { change is_iso _, apply_instance, }),\n    rw ← eq at hf,\n    change is_iso _ at hf,\n    rw ← is_iso_Lcof_map_iff_is_iso_L_map L Lcof' at hf,\n    rw cofibrant_object.is_iso_Lcof_map_iff at hf,\n    exact (CM2.left_iff_right_of_sq sq.flip weak_eq.property weak_eq.property).mp hf, },\n  { exact localization.inverts L weq f, },\nend\n\nend model_category\n\nend algebraic_topology\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebraic_topology/homotopical_algebra/homotopy_equivalences.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.48259228495346074}}
{"text": "import measure_theory.measurable_space\nimport measure_theory.integration\nimport measure_theory.borel_space\n\n\nnamespace measure_theory\n\nsection product\nuniverses u_1 u_2\nvariables (α:Type u_1) (β:Type u_2) (s:set α)\nopen measure_theory measure_theory.simple_func\n\nlemma lintegral_mul_indicator_eq_lintegral_mul_lintegral_indicator\n  {α} [M:measurable_space α] (μ:measure_theory.measure α) \n  (Mf:measurable_space α) (hMf:Mf ≤ M)\n  (c:ennreal) (T:set α) (h_meas_T:M.measurable_set' T)\n  (h_ind:∀ (S:set α), Mf.measurable_set' S →\n  (μ S * μ T = μ (S ∩ T)))   \n  (f:α → ennreal) (h_meas_f:@measurable α ennreal Mf _ f):\n@lintegral α M μ (λ a, (f * (T.indicator (λ (_x : α), c))) a) =\n  @lintegral α M μ f * \n  @lintegral α M μ (T.indicator (λ (_x : α), c)) :=\nbegin\n  revert f,\n  apply measurable.ennreal_induction,\n  { intros c' s' h_meas_s',\n      have h1:(λ a, (s'.indicator (λ (_x : α), c') * T.indicator (λ (_x : α), c)) a) =\n         (λ a, (s' ∩ T).indicator (λ (_x :α), c * c') a),\n      { ext1 a, cases classical.em (a ∈ s' ∩ T) with h1_1 h1_1,\n        { rw set.indicator_of_mem h1_1, simp at h1_1,\n          simp, rw if_pos,\n          rw if_pos,\n          rw mul_comm,\n          apply h1_1.right,\n          apply h1_1.left },\n        { rw set.indicator_of_not_mem h1_1, \n          simp,\n          simp at h1_1,\n          intros h1_2 h1_3,\n          exfalso,\n          apply h1_1,\n          apply h1_2,\n          apply h1_3 } },\n      rw h1,\n      rw measure_theory.lintegral_indicator,\n      rw measure_theory.lintegral_indicator,\n      rw measure_theory.lintegral_indicator,\n      simp,\n      rw ← h_ind,\n      ring, apply h_meas_s',\n      apply h_meas_T,\n      apply hMf,\n      apply h_meas_s',\n      apply measurable_set.inter,\n      apply hMf,\n      apply h_meas_s',\n      apply h_meas_T  },\n  { intros f' g h_univ h_meas_f' h_meas_g h_ind_f' h_ind_g,\n    have h_measM_f' := measurable.mono h_meas_f' hMf (le_refl _),\n    have h_measM_g := measurable.mono h_meas_g hMf (le_refl _),\n    have h_indicator:@measurable α ennreal M ennreal.measurable_space (λ (a : α), T.indicator (λ (_x : α), c) a),\n    { apply measurable.indicator,\n      apply measurable_const,\n      apply h_meas_T,   },\n    have h8:(f' + g) * T.indicator (λ (_x : α), c)= \n             (λ a, (f' * (T.indicator (λ _, c))) a + (g * (T.indicator (λ _, c))) a),\n    { ext1 a, simp [right_distrib] },\n    rw h8,\n    have h_add:(f' + g) = (λ a, (f' a + g a)),\n   { refl },\n   rw h_add,\n   rw measure_theory.lintegral_add,\n   rw measure_theory.lintegral_add,\n   rw right_distrib,\n   rw h_ind_f',\n   rw h_ind_g,\n   apply h_measM_f',\n   apply h_measM_g,\n   apply measurable.ennreal_mul,\n   apply h_measM_f',\n   apply h_indicator,\n   apply measurable.ennreal_mul,\n   apply h_measM_g, \n   apply h_indicator, },\n  { intros f h_meas_f h_mono_f h_ind_f,\n    have h_measM_f := (λ n, measurable.mono (h_meas_f n) hMf (le_refl _)),\n    have h_mul:\n     (λ a, ((λ (x : α), ⨆ (n : ℕ), f n x) * T.indicator (λ (_x : α), c)) a) =\n      (λ (a : α), ⨆ (n : ℕ), (λ (x:α), f n x * (T.indicator (λ (_x : α), c) x)) a),\n    { ext1 a, rw @pi.mul_apply, rw ennreal.supr_mul, },\n    rw h_mul,\n    rw lintegral_supr,\n    rw lintegral_supr,\n    rw ennreal.supr_mul,\n    have h_mul2:(λ (n:ℕ), (@lintegral α M μ \n       (λ (x : α), f n x * T.indicator (λ (_x : α), c) x)))  =\n        (λ n, @lintegral α M μ (f n) * @lintegral α M μ (T.indicator (λ (_x : α), c))), \n    { ext1 n, rw ← h_ind_f n, refl },\n    rw h_mul2,\n    apply h_measM_f,\n    apply h_mono_f,\n    { intros n,\n      apply measurable.ennreal_mul, apply h_measM_f, apply measurable.indicator,\n      apply measurable_const, apply h_meas_T },\n    { intros m n h_le a,\n      apply ennreal.mul_le_mul, apply h_mono_f, apply h_le, apply le_refl _  },\n    },\nend\n\nlemma lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurable_space \n{α} [M:measurable_space α] (μ:measure_theory.measure α) \n(Mf:measurable_space α) (Mg:measurable_space α) (hMf:Mf ≤ M)\n(hMg:Mg ≤ M)\n(h_ind:∀ (S T:set α), Mf.measurable_set' S → Mg.measurable_set' T →\n (μ S * μ T = μ (S ∩ T)))   \n(f g:α → ennreal) (h_meas_f:@measurable α ennreal Mf _ f) (h_meas_g:@measurable α ennreal Mg _ g):\n   @lintegral α M μ (λ a, (f * g) a) =\n   @lintegral α M μ f * \n   @lintegral α M μ g :=\nbegin\n  revert g,\n  have h_meas_Mf:∀ ⦃f:α → ennreal⦄, (@measurable α ennreal Mf _ f) → (@measurable α ennreal M _ f),\n  { intros f' h_meas_f', apply measurable.mono h_meas_f' hMf, apply le_refl _ }, \n  have h_meas_Mg:∀ ⦃f:α → ennreal⦄, (@measurable α ennreal Mg _ f) → (@measurable α ennreal M _ f),\n  { intros f' h_meas_f', apply measurable.mono h_meas_f' hMg, apply le_refl _ }, \n  have H1:= h_meas_Mf h_meas_f,\n  apply measurable.ennreal_induction,\n  intros c s h_s,\n  { apply lintegral_mul_indicator_eq_lintegral_mul_lintegral_indicator,\n    apply hMf, \n    apply hMg,\n    apply h_s,\n    { intros S h_meas_S,\n      apply h_ind, apply h_meas_S,\n      apply h_s, },\n    apply h_meas_f,\n },\n  { intros f' g h_univ h_measMg_f' h_measMg_g h_ind_f' h_ind_g',\n    have h_measM_f' := h_meas_Mg h_measMg_f',\n    have h_measM_g := h_meas_Mg h_measMg_g,\n    have h_add:(f' + g) = (λ a, (f' a + g a)),\n    { refl },\n    rw h_add,\n    rw measure_theory.lintegral_add,\n    have h8:(λ a, (f * λ a', (f' a' + g a')) a ) = (λ a, (f a * f' a) + (f a * g a)),\n    { ext1 a, simp [left_distrib], },\n    rw h8,\n    rw measure_theory.lintegral_add,\n    rw left_distrib,\n    have h9:(λ a, (f * f') a) = (λ a, f a * f' a),\n    { ext1 a, refl },\n    rw ← h9,\n    rw h_ind_f',\n    have h10:(λ a, (f * g) a) = (λ a, f a * g a),\n    { ext1 a, refl },\n    rw ← h10,\n    rw h_ind_g',\n    apply measurable.ennreal_mul,\n    apply H1,\n    apply h_measM_f',\n    apply measurable.ennreal_mul,\n    apply H1,\n    apply h_measM_g,\n    apply h_measM_f',\n    apply h_measM_g },\n  { intros f' h_meas_f' h_mono_f' h_ind_f',\n    have h_measM_f' := (λ n, h_meas_Mg (h_meas_f' n)),\n    have h_mul:(λ (a : α), (f * λ (x : α), ⨆ (n : ℕ), f' n x) a) = \n      (λ (a : α), ⨆ (n : ℕ), (λ (x:α), (f x * f' n x)) a),\n    { ext1 a, simp, rw ennreal.mul_supr },\n    rw h_mul,\n    rw lintegral_supr,\n    rw lintegral_supr,\n    rw ennreal.mul_supr,\n    have h_mul2:(λ (n:ℕ), (@lintegral α M μ (λ (x : α), f x * f' n x))) =\n        (λ n, @lintegral α M μ f * @lintegral α M μ (f' n)), \n    { ext1 n, rw ← h_ind_f' n, refl },\n    rw h_mul2,\n    { apply h_measM_f', },\n    { apply h_mono_f', },\n    { intros n, apply measurable.ennreal_mul,\n      apply H1, apply h_measM_f' },\n    { intros n m h_le a, apply ennreal.mul_le_mul,\n       apply le_refl _, apply h_mono_f' h_le, },\n},\nend\n\n\nlemma lintegral_mul_eq_lintegral_mul_lintegral_of_independent_fn {α} [M:measurable_space α] (μ:measure_theory.measure α) \n(f g:α → ennreal) (h_meas_f:measurable f) (h_meas_g:measurable g)\n(h_ind:∀ (S T:set ennreal), measurable_set S → measurable_set T →\n (μ (f ⁻¹' S) * μ (g ⁻¹' T) = μ ((f ⁻¹' S) ∩ (g ⁻¹' T)))):\n∫⁻ (a : α), (f * g) a ∂μ =\n(∫⁻ (a : α), f a ∂μ) *\n(∫⁻ (a : α), g a ∂μ) :=\nbegin\n  let Mf := ennreal.measurable_space.comap f,\n  let Mg := ennreal.measurable_space.comap g,\n  begin\n    apply lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurable_space μ Mf Mg,\n    { rw measurable_iff_comap_le at h_meas_f,\n      apply h_meas_f },\n    { rw measurable_iff_comap_le at h_meas_g,\n      apply h_meas_g },\n    { intros S T h_S h_T,\n      have h_S':∃ (A:set ennreal), (measurable_set A) ∧ (f ⁻¹' A = S),\n      { apply h_S },\n      have h_T':∃ (B:set ennreal), (measurable_set B) ∧ (g ⁻¹' B = T),\n      { apply h_T },\n      cases h_S' with A h_S',\n      cases h_T' with B h_T',\n      rw ← h_S'.right,\n      rw ← h_T'.right,\n      apply h_ind,\n      apply h_S'.left,\n      apply h_T'.left },\n    { rw measurable_iff_comap_le, apply le_refl _ },\n    { rw measurable_iff_comap_le, apply le_refl _ },\n  end\nend\nend product\nend measure_theory\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/expected_product_independent.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.482592278230958}}
{"text": "/-\nThis defines the ArithM monad basic operations used to generate a system of\nnumerical equations from a Lean local context.\n-/\nimport ClausalExtraction.Basic\nimport ClausalExtraction.ArithTheory.Int\n\nopen Lean -- (Expr levelZero levelOne mkApp mkAppN mkConst mkRawNatLit)\nopen Std (HashMap)\n\nnamespace ClausalExtraction\n\nnamespace ArithTheory\n\nsection ExpressionUtils\n\ndef natExpr : Expr := mkConst ``Nat\ndef intExpr := mkConst ``Int\n\nprivate def notExpr : Expr := mkConst ``Not\n\ndef intAddConst : Expr :=\n  let f := mkConst ``HAdd.hAdd [levelZero, levelZero, levelZero]\n  let inst := mkAppN (mkConst ``instHAdd [levelZero]) #[intExpr, mkConst ``Int.instAddInt]\n  mkAppN f #[intExpr, intExpr, intExpr, inst]\n\ndef intSubConst : Expr :=\n  let f := mkConst ``HSub.hSub [levelZero, levelZero, levelZero]\n  let inst := mkAppN (mkConst ``instHAdd [levelZero]) #[intExpr, mkConst ``Int.instSubInt]\n  mkAppN f #[intExpr, intExpr, intExpr, inst]\n\ndef intMulConst : Expr :=\n  let f := mkConst ``HMul.hMul [levelZero, levelZero, levelZero]\n  let inst := mkAppN (mkConst ``instHMul [levelZero]) #[intExpr, mkConst ``Int.instMulInt]\n  mkAppN f #[intExpr, intExpr, intExpr, inst]\n\ndef intNegConst : Expr :=\n  let f := mkConst ``Neg.neg [levelZero]\n  let inst := mkConst ``Int.instNegInt\n  mkAppN f #[intExpr, inst]\n\n-- A structure used to denote an integer expression\nstructure IntExpr where\n  toExpr : Expr\n  deriving BEq, Hashable, Inhabited\n\nnamespace IntExpr\n\ninstance : Coe IntExpr Expr where\n  coe := IntExpr.toExpr\n\ninstance : Add IntExpr where\n  add := λx y => IntExpr.mk (mkAppN intAddConst #[x, y])\n\nend IntExpr\n\n-- Create a nat as an int\ndef mkOfNat (n:Expr) : IntExpr :=\n  let ofNat := mkConst ``OfNat.ofNat [levelZero]\n  let inst := mkConst ``Int.instOfNatInt\n  IntExpr.mk (mkAppN ofNat #[intExpr, n, mkApp inst n])\n\n-- Create a nat lit as an int\ndef natLitAsIntExpr (n:Nat) : IntExpr := mkOfNat (mkRawNatLit n)\n\ndef mkIntLit : Int → IntExpr\n| Int.ofNat n => natLitAsIntExpr n\n| Int.negSucc n => IntExpr.mk (mkApp intNegConst (natLitAsIntExpr (n+1)))\n\ninstance : Coe Int IntExpr where\n  coe := mkIntLit\n\ndef intZeroExpr : IntExpr := mkIntLit 0\n\nprivate def intNonNegExpr : Expr := mkConst ``Int.NonNeg\ndef mkIntNonNegExpr (e:Expr) : Expr := mkApp intNonNegExpr e\n\nprivate def intEqExpr : Expr := mkApp (mkConst ``Eq [levelOne]) (mkConst ``Int)\ndef mkIntEq0Expr (e:Expr) : Expr := mkAppN intEqExpr #[e, intZeroExpr]\n\nend ExpressionUtils\n\n-- Represents a polynomial.\nstructure Poly where\n  -- Poly should be a sorted array of non-zero integers and variable pairs.\n  elements : Array (Int × TheoryVar)\n  deriving BEq, Hashable, Repr\n\nnamespace Poly\n\n-- | Create polynomial denoting constant zero.\nprotected def const (z:Int) : Poly := ⟨#[(z, ⟨0⟩)]⟩\n\n-- | Create polynomial denoting constant zero.\nprotected def zero : Poly := Poly.const 0\n\n-- | Create polynomial denoting constant zero.\nprotected def one : Poly := Poly.const 1\n\ninstance : Inhabited Poly := ⟨Poly.zero⟩\n\n-- | Create polynomial denoting constant zero.\n-- protected def one : Poly := ⟨#[(1, ⟨0⟩)]⟩\n\ndef addc : Poly → Int → Poly\n| ⟨a⟩, q =>\n  let (p,v) := a.get! 0\n  ⟨a.set! 0 (p+q, v)⟩\n\n-- | @add p i _ v@ returns poly denoting @p + i*v@.\ndef add : Poly → Int → TheoryVar → Poly\n| ⟨a⟩, q, v =>\n  let rec loop : ∀(i : Nat), Poly\n      | 0 => ⟨a.insertAt 1 (q, v)⟩\n      | Nat.succ i =>\n        let (p,u) := a[i+1]\n        if v < u then\n          loop i\n        else if u < v then\n          ⟨a.insertAt (i+2) (q,v)⟩\n        else -- v = u\n          let q := p+q\n          if q = 0 then\n            ⟨a.eraseIdx (i+1)⟩\n          else\n            ⟨a.set! (i+1) (q,v)⟩\n  loop (a.size-1)\n\nprotected def toString : Poly → String\n| ⟨a⟩ =>\n  let scalarProd : Int × TheoryVar → String\n        | (m,v) => s!\"{m}*{v}\"\n  let firstScalarProd : Int × TheoryVar → String\n        | (m, _) => toString m\n  let polyIns := λ(e:String) h => s!\"{e} + {scalarProd h}\"\n  a[1:].foldl polyIns (firstScalarProd a[0])\n\ninstance : ToString Poly where\n  toString := Poly.toString\n\ndef scalarProd (f: v → IO IntExpr) : Int × v → IO IntExpr\n| (m,  v) => do IntExpr.mk (mkAppN intMulConst #[m, ← f v])\n\n-- | Create an reflexivity proof from the int expression.\ndef mkIntRefl (e:IntExpr) : Expr := mkApp (mkApp (mkConst ``rfl [levelOne]) intExpr) e\n\n-- | Map polynomial to expression given mapping from variables\n-- to expressions.\n-- The optional parameter allowss this to to only take the first n elements.\nprotected\ndef expr (poly:Poly) (f: TheoryVar → IO IntExpr) (limit: optParam Nat (poly.elements.size - 1)) : IO IntExpr := do\n  if poly.elements.size = 0 then\n    panic! \"Empty polyExpr\"\n  if limit ≥ poly.elements.size then\n    panic! \"polyExpr given bad limit.\"\n  let mut e : IntExpr ← poly.elements[0].fst\n  for p in poly.elements[1:limit+1] do\n    e := e + (← scalarProd f p)\n  pure e\n\nprivate\ntheorem polyProofAddContextLemma {c x a:Int} (h:x + c = a) (y:Int)\n  : (x + y) + c = a + y := by\n  simp [h.symm, Int.add_assoc, Int.add_comm y c]\n\n-- polyProofAddContext s x c a h poly idx where h is a proof of \"x + c = a\" returns\n-- a proof \"(x + poly[idx] + poly[idx+1] + ..) + c = a + poly[idx] + poly[idx+1] + ..\"\nprivate\ndef polyProofAddContext (f:TheoryVar → IO IntExpr) (x c a:IntExpr) (h:Expr) (poly:Poly) (idx:Nat) : IO Expr := do\n  let mut x := x\n  let mut a := a\n  let mut h := h\n  let pr := mkApp (mkConst ``polyProofAddContextLemma) c\n  for p in poly.elements[idx:] do\n    let y ← scalarProd f p\n    h := mkAppN pr #[x, a, h, y]\n    x := x + y\n    a := a + y\n  pure h\n\nsection Lemmas\n\nprivate\ntheorem sum0Lemma (p q v:Int) : p*v + q*v = (p+q)*v := Eq.symm (Int.add_mul _ _ _)\n\nprivate\ntheorem sumLemma (r p q v:Int) : (r + p*v) + q*v = r + (p+q)*v := by\n  apply Eq.trans (Int.add_assoc r _ _)\n  apply congrArg (fun y => r + y)\n  exact sum0Lemma _ _ _\n\nprivate\ntheorem cancel0Lemma {p q:Int} (h : p+q = 0) (v:Int) : p*v + q*v = 0 := by\n  apply Eq.trans (sum0Lemma p q v)\n  exact @Eq.substr Int (λx => x * v = 0) _ _ h (Int.zero_mul v)\n\nexample        : (64:Int) + -64 = 0   := @cancel0Lemma (64) (-64) (@rfl Int 0) 1\nexample        : (-64:Int) + 64 = 0   := @cancel0Lemma (-64) (64) (@rfl Int 0) 1\nexample (v:Int): -64 * v + 64 * v = 0 := @cancel0Lemma (-64) 64   (@rfl Int 0) v\nexample (v:Int): 64 * v + -64 * v = 0 := @cancel0Lemma (64) (-64) (@rfl Int 0) v\n\nprivate\ntheorem cancelLemma (r p q v:Int) (h : p+q = 0) : (r + p*v) + q*v = r := by\n  apply Eq.trans (Int.add_assoc r _ _)\n  exact Eq.trans (cancel0Lemma h v ▸ rfl) (Int.add_zero r)\n\nend Lemmas\n\ndef addcProof (f:TheoryVar → IO IntExpr) (poly:Poly) (c:Int) (g:c ≠ 0) : IO Expr := do\n  let x := poly.elements[0].fst\n  let a := x + c\n  let h := mkIntRefl a\n  polyProofAddContext f x c a h poly 1\n\n-- | @addProof f p m v@ returns proof showing that\n-- @p.expr + scalarProd f (m, v) = (p.add m v).expr@.\ndef addProof (f:TheoryVar → IO IntExpr) : ∀(poly:Poly) (q:Int), q ≠ 0 → TheoryVar → IO Expr\n| poly, q, g, v => do\n  let c ← scalarProd f (q, v)\n  let rec loop : ∀(i : Nat), IO Expr\n      | 0 => do\n        -- Handle case where var is zero.\n        let x : IntExpr := poly.elements[0].fst\n        let a := x + c\n        let h := mkIntRefl a\n        polyProofAddContext f x c a h poly 1\n      | Nat.succ i => do\n        let (p,u) := poly.elements[i+1]\n        if v < u then\n          loop i\n        else if u < v then\n          let x ← poly.expr f (limit := i+1)\n          let a := x + c\n          let h := mkIntRefl a\n          polyProofAddContext f x c a h poly (i+2)\n        else -- v = u\n          if p+q = 0 then\n            let a ← poly.expr f (limit := i)\n            let x := a + (← scalarProd f (p,u))\n            let rflExpr := mkIntRefl intZeroExpr\n            -- Create proof: (a + -q*v) + q*v = a.\n            let h := mkAppN (mkConst ``cancelLemma) #[a, (-q : Int), q, ← f v, rflExpr]\n            polyProofAddContext f x c a h poly (i+2)\n          else\n            let r ← poly.expr f (limit := i)\n            let x := r + (←scalarProd f (p, u))\n            let a := r + (←scalarProd f (p+q, u))\n            let h := mkAppN (mkConst ``sumLemma) #[r, p, q, ←f v]\n            polyProofAddContext f x c a h poly (i+2)\n  loop (poly.elements.size - 1)\n\nend Poly\n\n-- Definition associated with a variable.\ninductive Decl\n  -- A int variable from another theory.\n| uninterpInt : Var → Decl\n  -- A nat variable from another theory.\n| uninterpNat : Var → Decl\n  -- Theory variable is equal to polynomial.\n| poly : Poly → Decl\nderiving BEq, Hashable\n\nnamespace Decl\n\nprotected def toString : Decl → String\n| uninterpInt v => s!\"{v}\"\n| uninterpNat v => s!\"ofNat {v}\"\n| poly p => s!\"poly {p}\"\n\ninstance : ToString Decl where\n  toString := Decl.toString\n\ninstance : Inhabited Decl := ⟨uninterpInt arbitrary⟩\n\nend Decl\n\n-- | An atomic predicate\ninductive Pred where\n-- This denotes a proof of the form (v = 0)\n| IsEq0 : TheoryVar → Pred\n-- This denotes a proof of the form (Not (v = 0))\n| IsNe0 : TheoryVar → Pred\n-- This denotes a proof of the form (Int.NonNeg v)\n| IsGe0 : TheoryVar → Pred\n  deriving Inhabited\n\nnamespace Pred\n\nprotected def toString : Pred → String\n| IsEq0 v => s!\"IsEq0 {v}\"\n| IsNe0 v => s!\"IsNe0 {v}\"\n| IsGe0 v => s!\"IsGe0 {v}\"\n\ninstance : ToString Pred := ⟨Pred.toString⟩\n\nend Pred\n\ndef oneVar : TheoryVar := ⟨0⟩\n\nstructure State : Type where\n\n  exprMap : HashMap Decl TheoryVar := Std.mkHashMap.insert (Decl.poly Poly.one) oneVar\n  vars : Array Decl := #[Decl.poly Poly.one]\n  preds : Array Pred := #[]\n\nsection\n\nvariable (r:IO.Ref State)\nvariable (f: Var → IO Expr)\n\n-- | Return Lean expression associated with IntExpr\npartial def thvarExpr (v:TheoryVar) : IO IntExpr := do\n  let s ← r.get\n  if p : v.toNat < s.vars.size then\n    match s.vars.get ⟨v.toNat, p⟩  with\n    | Decl.uninterpInt v => do\n      IntExpr.mk <$> f v\n    | Decl.uninterpNat v => do\n      mkOfNat <$> f v\n    | Decl.poly p => p.expr (thvarExpr)\n  else\n    panic! s!\"Invalid theory variable index {v} (max = {s.vars.size})\"\n\nend\n\nabbrev ArithM := ReaderT (IO.Ref State) SolverM\n\n-- | Return a theory variable associated with the given uninterpreted Lean expression.\ndef getTheoryVar (d:Decl) : ArithM TheoryVar := do\n  let r ← read\n  let s ← r.get\n  match s.exprMap.find? d with\n  | none => pure ()\n  | some v => return v\n  let newVar := ⟨OfNat.ofNat s.vars.size⟩\n  if (newVar.index : UInt32) = 0 then\n    throwError m!\"Only 2^32 arithmetic variables allowed.\"\n  r.set\n    { s with exprMap := s.exprMap.insert d newVar,\n             vars := s.vars.push d }\n  return newVar\n\n-- | Return a theory variable associated with the given uninterpreted Lean expression.\ndef getPolyVar (p:Poly) : ArithM TheoryVar := getTheoryVar (Decl.poly p)\n\ndef getThvarExpr (v:TheoryVar) : ArithM IntExpr := do\n  let svc ← (read : SolverM _)\n  let r ← read\n  thvarExpr r svc.varExpr v\n\n-- | Return expression associated with in solver.\ndef getPolyExpr (poly:Poly) : ArithM IntExpr := do\n  let svc ← (read : SolverM _)\n  let r ← read\n  let f (v:TheoryVar) : IO IntExpr := thvarExpr r svc.varExpr v\n  poly.expr f\n\ndef getTheoryPred (p:Pred) : ArithM TheoryPred := do\n  let r ← read\n  let s ← r.get\n  if TheoryPred.max ≤ s.preds.size then\n    throwError \"Only 2^32 arithmetic variables allowed.\"\n  let n := TheoryPred.ofNat (s.preds.size)\n  r.set { s with preds := s.preds.push p }\n  pure n\n\ndef mthvarExpr (r: IO.Ref State) (f : Var → IO Expr)  (thv : TheoryVar) : IO Expr := do\n  IntExpr.toExpr <$> thvarExpr r f thv\n\ndef predExpr (r : IO.Ref State) (f : Var → IO Expr) (idx : TheoryPred) : IO Expr := do\n  let s ← r.get\n  if lt : idx.toNat < s.preds.size  then\n    match s.preds.get ⟨idx.toNat, lt⟩  with\n    | Pred.IsEq0 v => mkIntEq0Expr <$> mthvarExpr r f v\n    | Pred.IsNe0 v => mkApp notExpr <$> (mkIntEq0Expr <$> mthvarExpr r f v)\n    | Pred.IsGe0 v => mkIntNonNegExpr <$> mthvarExpr r f v\n  else\n    panic s!\"Invalid predicate index {idx} (max = {s.preds.size})\"\n\nend ArithTheory\n\nend ClausalExtraction", "meta": {"author": "joehendrix", "repo": "lean-arith-solver", "sha": "95041be7b67fa1525644ad60896ae71881efdd29", "save_path": "github-repos/lean/joehendrix-lean-arith-solver", "path": "github-repos/lean/joehendrix-lean-arith-solver/lean-arith-solver-95041be7b67fa1525644ad60896ae71881efdd29/lib/ClausalExtraction/ArithTheory/ArithM.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6297746074044135, "lm_q1q2_score": 0.482592278230958}}
{"text": "import GMLInit.Data.Basic\nimport GMLInit.Data.Ord\nimport GMLInit.Logic.Relation\nimport GMLInit.Meta.Basic\n\nabbrev xor : Bool → Bool → Bool := bne\ninfixl:30 \" ^^ \" => xor\n\nnamespace Bool\nvariable (x y z : Bool)\n\nlocal syntax \"bool_tt\" (&\"using\" tactic)? (colGt term:max)* : tactic\nmacro_rules\n| `(tactic| bool_tt) => `(tactic| rfl)\n| `(tactic| bool_tt using $tac) => `(tactic| $tac)\n| `(tactic| bool_tt $[using $tac]? $x:term $xs:term*) => `(tactic| cases ($x : Bool) <;> bool_tt $[using $tac]? $xs*)\n\ninstance : LinearOrd Bool where\n  symm (x y) := by bool_tt x y\n  le_trans {x y z} _ _ _ := by bool_tt using contradiction x y z\n  eq_strict {x y} _ := by bool_tt using first | rfl | contradiction x y\n\ninstance : LE Bool := leOfOrd\ninstance : LT Bool := ltOfOrd\n\ntheorem eq_iff_iff : x = y ↔ (x ↔ y) := by bool_tt using simp x y\n\n-- assert not_not : !(!x) = x := by bool_tt x\ntheorem not_and : (!(x && y)) = (!x || !y) := by bool_tt x y\ntheorem not_or : (!(x || y)) = (!x && !y) := by bool_tt x y\n\ntheorem and_false_left : (false && x) = false := by bool_tt x\ntheorem and_false_right : (x && false) = false := by bool_tt x\ntheorem and_true_left : (true && x) = x := by bool_tt x\ntheorem and_true_right : (x && true) = x := by bool_tt x\ntheorem and_not_self_left : (!x && x) = false := by bool_tt x\ntheorem and_not_self_right : (x && !x) = false := by bool_tt x\ntheorem and_idem : (x && x) = x := by bool_tt x\ntheorem and_comm : (x && y) = (y && x) := by bool_tt x y\ntheorem and_left_comm : (x && (y && z)) = (y && (x && z)) := by bool_tt x y z\ntheorem and_right_comm : ((x && y) && z) = ((x && z) && y) := by bool_tt x y z\n-- assert and_assoc : ((x && y) && z) = (x && (y && z)) := by bool_tt x y z\ntheorem and_or_distrib_left : (x && (y || z)) = ((x && y) || (x && z)) := by bool_tt x y z\ntheorem and_or_distrib_right : ((x || y) && z) = ((x && z) || (y && z)) := by bool_tt x y z\ntheorem and_xor_distrib_left : (x && (y ^^ z)) = ((x && y) ^^ (x && z)) := by bool_tt x y z\ntheorem and_xor_distrib_right : ((x ^^ y) && z) = ((x && z) ^^ (y && z)) := by bool_tt x y z\ntheorem and_deMorgan : (!(x && y)) = (!x || !y) := by bool_tt x y\ntheorem and_eq_true_iff : (x && y) = true ↔ x = true ∧ y = true := by bool_tt using simp x y\ntheorem and_eq_false_iff : (x && y) = false ↔ x = false ∨ y = false := by bool_tt using simp x y\n\ntheorem or_false_left : (false || x) = x := by bool_tt x\ntheorem or_false_right : (x || false) = x := by bool_tt x\ntheorem or_true_left : (true || x) = true := by bool_tt x\ntheorem or_true_right : (x || true) = true := by bool_tt x\ntheorem or_not_self_left : (!x || x) = true := by bool_tt x\ntheorem or_not_self_right : (x || !x) = true := by bool_tt x\ntheorem or_idem : (x || x) = x := by bool_tt x\ntheorem or_comm : (x || y) = (y || x) := by bool_tt x y\ntheorem or_left_comm : (x || (y || z)) = (y || (x || z)) := by bool_tt x y z\ntheorem or_right_comm : ((x || y) || z) = ((x || z) || y) := by bool_tt x y z\n-- assort or_assoc : ((x || y) || z) = (x || (y || z)) := by bool_tt x y z\ntheorem or_and_distrib_left : (x || (y && z)) = ((x || y) && (x || z)) := by bool_tt x y z\ntheorem or_and_distrib_right : ((x && y) || z) = ((x || z) && (y || z)) := by bool_tt x y z\ntheorem or_deMorgan : (!(x || y)) = (!x && !y) := by bool_tt x y\ntheorem or_eq_true_iff : (x || y) = true ↔ x = true ∨ y = true := by bool_tt using simp x y\ntheorem or_eq_false_iff : (x || y) = false ↔ x = false ∧ y = false := by bool_tt using simp x y\n\ntheorem xor_false_left : (false ^^ x) = x := by bool_tt x\ntheorem xor_false_right : (x ^^ false) = x := by bool_tt x\ntheorem xor_true_left : (true ^^ x) = !x := by bool_tt x\ntheorem xor_true_right : (x ^^ true) = !x := by bool_tt x\ntheorem xor_self : (x ^^ x) = false := by bool_tt x\ntheorem xor_not_self_left : (!x ^^ x) = true := by bool_tt x\ntheorem xor_not_self_right : (x ^^ !x) = true := by bool_tt x\ntheorem xor_comm : (x ^^ y) = (y ^^ x) := by bool_tt x y\ntheorem xor_left_comm : (x ^^ (y ^^ z)) = (y ^^ (x ^^ z)) := by bool_tt x y z\ntheorem xor_right_comm : ((x ^^ y) ^^ z) = ((x ^^ z) ^^ y) := by bool_tt x y z\ntheorem xor_assoc : ((x ^^ y) ^^ z) = (x ^^ (y ^^ z)) := by bool_tt x y z\n\nprotected abbrev beq := x == y\nprotected abbrev bne := x != y\nprotected abbrev bge := x || !y\nprotected abbrev bgt := x && !y\nprotected abbrev ble := !x || y\nprotected abbrev blt := !x && y\n\ntheorem beq_eq_decide_eq : Bool.beq x y = decide (x = y) := by bool_tt x y\ntheorem bne_eq_decide_ne : Bool.bne x y = decide (x ≠ y) := by bool_tt x y\ntheorem bge_eq_decide_ge : Bool.bge x y = decide (x ≥ y) := by bool_tt x y\ntheorem bgt_eq_decide_gt : Bool.bgt x y = decide (x > y) := by bool_tt x y\ntheorem ble_eq_decide_le : Bool.ble x y = decide (x ≤ y) := by bool_tt x y\ntheorem blt_eq_decide_lt : Bool.blt x y = decide (x < y) := by bool_tt x y\n\nprotected theorem le_refl : x ≤ x := by bool_tt x\nprotected theorem le_trans {x y z : Bool} : x ≤ y → y ≤ z → x ≤ z := by bool_tt using simp x y z\nprotected theorem le_antisymm {x y : Bool} : x ≤ y → y ≤ x → x = y := by bool_tt using simp x y\nprotected theorem lt_irrefl : ¬ x < x := by bool_tt using simp x\nprotected theorem lt_asymm {x y : Bool} : x < y → ¬ y < x := by bool_tt using simp x y\nprotected theorem lt_trans {x y z : Bool} : x < y → y < z → x < z := by bool_tt using simp x y z\nprotected theorem lt_of_le_of_lt {x y z : Bool} : x ≤ y → y < z → x < z := by bool_tt using simp x y z\nprotected theorem lt_of_lt_of_le {x y z : Bool} : x < y → y ≤ z → x < z := by bool_tt using simp x y z\nprotected theorem le_of_lt {x y : Bool} : x < y → x ≤ y := by bool_tt using simp x y z\nprotected theorem le_of_eq {x y : Bool} : x = y → x ≤ y := by bool_tt using simp x y z\nprotected theorem ne_of_lt {x y : Bool} : x < y → x ≠ y := by bool_tt using simp x y z\nprotected theorem lt_of_le_of_ne {x y : Bool} : x ≤ y → x ≠ y → x < y := by bool_tt using simp x y z\nprotected theorem le_of_lt_or_eq {x y : Bool} : x < y ∨ x = y → x ≤ y := by bool_tt using simp x y z\nprotected theorem le_true : x ≤ true := by bool_tt x\nprotected theorem false_le : false ≤ x := by bool_tt x\nprotected theorem eq_true_of_true_le {x : Bool} : true ≤ x → x = true := by bool_tt using simp x\nprotected theorem eq_false_of_le_false {x : Bool} : x ≤ false → x = false := by bool_tt using simp x\n\ninstance : Relation.Reflexive (α:=Bool) (.≤.) := ⟨Bool.le_refl⟩\ninstance : Relation.Irreflexive (α:=Bool) (.<.) := ⟨Bool.lt_irrefl⟩\ninstance : Relation.Antisymmetric (α:=Bool) (.≤.) := ⟨Bool.le_antisymm⟩\ninstance : Relation.Asymmetric (α:=Bool) (.<.) := ⟨Bool.lt_asymm⟩\ninstance : Relation.Transitive (α:=Bool) (.≤.) := ⟨Bool.le_trans⟩\ninstance : Relation.Transitive (α:=Bool) (.<.) := ⟨Bool.lt_trans⟩\ninstance : Relation.HTransitive (α:=Bool) (β:=Bool) (γ:=Bool) (.<.) (.≤.) (.<.) := ⟨Bool.lt_of_lt_of_le⟩\ninstance : Relation.HTransitive (α:=Bool) (β:=Bool) (γ:=Bool) (.≤.) (.<.) (.<.) := ⟨Bool.lt_of_le_of_lt⟩\n\ntheorem not_inj {x y : Bool} : (!x) = (!y) → x = y := by\n  bool_tt using simp x y\n\ntheorem and_or_inj_right {m x y : Bool}: (x && m) = (y && m) → (x || m) = (y || m) → x = y := by\n  bool_tt using simp m x y\n\ntheorem and_or_inj_left {m x y : Bool} : (m && x) = (m && y) → (m || x) = (m || y) → x = y := by\n  bool_tt using simp m x y\n\nsection\nvariable (xs ys : List Bool)\n\nabbrev all : Bool := xs.all id\n\ntheorem all_nil : all [] = true := rfl\ntheorem all_one : all [x] = x := Bool.and_true x\ntheorem all_cons  : all (x :: xs) = (x && all xs) := rfl\n\ntheorem all_append : all (xs ++ ys) = (all xs && all ys) := by\n  induction xs with\n  | nil => rw [List.nil_append, all_nil, true_and]\n  | cons x xs ih => rw [List.cons_append, all_cons, all_cons, and_assoc, ih]\n\ntheorem all_join (xss : List (List Bool)) : all (xss.map all) = all xss.join := by\n  induction xss with\n  | nil => rfl\n  | cons xs xss ih => rw [List.map, List.join, all_cons, all_append, ih]\n\nabbrev any : Bool := xs.any id\n\ntheorem any_nil : any [] = false := rfl\ntheorem any_one : any [x] = x := Bool.or_false x\ntheorem any_cons : any (x :: xs) = (x || any xs) := rfl\n\ntheorem any_append : any (xs ++ ys) = (any xs || any ys) := by\n  induction xs with\n  | nil => rw [List.nil_append, any_nil, false_or]\n  | cons x xs ih => rw [List.cons_append, any_cons, any_cons, or_assoc, ih]\n\ntheorem any_join (xss : List (List Bool)) : any (xss.map any) = any xss.join := by\n  induction xss with\n  | nil => rfl\n  | cons xs xss ih => rw [List.map, List.join, any_cons, any_append, ih]\n\ntheorem all_deMorgan : (!all xs) = any (xs.map (!.)) := by\n  induction xs with\n  | nil => rfl\n  | cons x xs ih => rw [List.map, all_cons, any_cons, and_deMorgan, ih]\n\ntheorem any_deMorgan : (!any xs) = all (xs.map (!.)) := by\n  induction xs with\n  | nil => rfl\n  | cons x xs ih => rw [List.map, any_cons, all_cons, or_deMorgan, ih]\n\nend\n\nend Bool\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/Bool.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.48259227823095796}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Sean Leather\n-/\nimport data.list.range\nimport data.list.perm\n\n/-!\n# Utilities for lists of sigmas\n\nThis file includes several ways of interacting with `list (sigma β)`, treated as a key-value store.\n\nIf `α : Type*` and `β : α → Type*`, then we regard `s : sigma β` as having key `s.1 : α` and value\n`s.2 : β s.1`. Hence, `list (sigma β)` behaves like a key-value store.\n\n## Main Definitions\n\n- `list.keys` extracts the list of keys.\n- `list.nodupkeys` determines if the store has duplicate keys.\n- `list.lookup`/`lookup_all` accesses the value(s) of a particular key.\n- `list.kreplace` replaces the first value with a given key by a given value.\n- `list.kerase` removes a value.\n- `list.kinsert` inserts a value.\n- `list.kunion` computes the union of two stores.\n- `list.kextract` returns a value with a given key and the rest of the values.\n-/\n\nuniverses u v\n\nnamespace list\nvariables {α : Type u} {β : α → Type v}\n\n/-! ### `keys` -/\n\n/-- List of keys from a list of key-value pairs -/\ndef keys : list (sigma β) → list α := map sigma.fst\n\n@[simp] theorem keys_nil : @keys α β [] = [] := rfl\n\n@[simp] theorem keys_cons {s} {l : list (sigma β)} : (s :: l).keys = s.1 :: l.keys := rfl\n\ntheorem mem_keys_of_mem {s : sigma β} {l : list (sigma β)} : s ∈ l → s.1 ∈ l.keys :=\nmem_map_of_mem sigma.fst\n\ntheorem exists_of_mem_keys {a} {l : list (sigma β)} (h : a ∈ l.keys) :\n  ∃ (b : β a), sigma.mk a b ∈ l :=\nlet ⟨⟨a', b'⟩, m, e⟩ := exists_of_mem_map h in\neq.rec_on e (exists.intro b' m)\n\ntheorem mem_keys {a} {l : list (sigma β)} : a ∈ l.keys ↔ ∃ (b : β a), sigma.mk a b ∈ l :=\n⟨exists_of_mem_keys, λ ⟨b, h⟩, mem_keys_of_mem h⟩\n\ntheorem not_mem_keys {a} {l : list (sigma β)} : a ∉ l.keys ↔ ∀ b : β a, sigma.mk a b ∉ l :=\n(not_iff_not_of_iff mem_keys).trans not_exists\n\ntheorem not_eq_key {a} {l : list (sigma β)} : a ∉ l.keys ↔ ∀ s : sigma β, s ∈ l → a ≠ s.1 :=\niff.intro\n  (λ h₁ s h₂ e, absurd (mem_keys_of_mem h₂) (by rwa e at h₁))\n  (λ f h₁, let ⟨b, h₂⟩ := exists_of_mem_keys h₁ in f _ h₂ rfl)\n\n/-! ### `nodupkeys` -/\n\n/-- Determines whether the store uses a key several times. -/\ndef nodupkeys (l : list (sigma β)) : Prop := l.keys.nodup\n\ntheorem nodupkeys_iff_pairwise {l} : nodupkeys l ↔\n  pairwise (λ s s' : sigma β, s.1 ≠ s'.1) l := pairwise_map _\n\ntheorem nodupkeys.pairwise_ne {l} (h : nodupkeys l) :\n  pairwise (λ s s' : sigma β, s.1 ≠ s'.1) l :=\nnodupkeys_iff_pairwise.1 h\n\n@[simp] theorem nodupkeys_nil : @nodupkeys α β [] := pairwise.nil\n\n@[simp] theorem nodupkeys_cons {s : sigma β} {l : list (sigma β)} :\n  nodupkeys (s::l) ↔ s.1 ∉ l.keys ∧ nodupkeys l :=\nby simp [keys, nodupkeys]\n\ntheorem nodupkeys.eq_of_fst_eq {l : list (sigma β)}\n  (nd : nodupkeys l) {s s' : sigma β} (h : s ∈ l) (h' : s' ∈ l) :\n  s.1 = s'.1 → s = s' :=\n@forall_of_forall_of_pairwise _\n  (λ s s' : sigma β, s.1 = s'.1 → s = s')\n  (λ s s' H h, (H h.symm).symm) _ (λ x h _, rfl)\n  ((nodupkeys_iff_pairwise.1 nd).imp (λ s s' h h', (h h').elim)) _ h _ h'\n\ntheorem nodupkeys.eq_of_mk_mem {a : α} {b b' : β a} {l : list (sigma β)}\n  (nd : nodupkeys l) (h : sigma.mk a b ∈ l) (h' : sigma.mk a b' ∈ l) : b = b' :=\nby cases nd.eq_of_fst_eq h h' rfl; refl\n\ntheorem nodupkeys_singleton (s : sigma β) : nodupkeys [s] := nodup_singleton _\n\ntheorem nodupkeys_of_sublist {l₁ l₂ : list (sigma β)} (h : l₁ <+ l₂) :\n  nodupkeys l₂ → nodupkeys l₁ :=\nnodup_of_sublist (h.map _)\n\ntheorem nodup_of_nodupkeys {l : list (sigma β)} : nodupkeys l → nodup l :=\nnodup_of_nodup_map _\n\ntheorem perm_nodupkeys {l₁ l₂ : list (sigma β)} (h : l₁ ~ l₂) : nodupkeys l₁ ↔ nodupkeys l₂ :=\n(h.map _).nodup_iff\n\ntheorem nodupkeys_join {L : list (list (sigma β))} :\n  nodupkeys (join L) ↔ (∀ l ∈ L, nodupkeys l) ∧ pairwise disjoint (L.map keys) :=\nbegin\n  rw [nodupkeys_iff_pairwise, pairwise_join, pairwise_map],\n  refine and_congr (ball_congr $ λ l h, by simp [nodupkeys_iff_pairwise]) _,\n  apply iff_of_eq, congr' with l₁ l₂,\n  simp [keys, disjoint_iff_ne]\nend\n\ntheorem nodup_enum_map_fst (l : list α) : (l.enum.map prod.fst).nodup :=\nby simp [list.nodup_range]\n\nlemma mem_ext {l₀ l₁ : list (sigma β)}\n  (nd₀ : l₀.nodup) (nd₁ : l₁.nodup)\n  (h : ∀ x, x ∈ l₀ ↔ x ∈ l₁) : l₀ ~ l₁ :=\nbegin\n  induction l₀ with x xs generalizing l₁; cases l₁ with y ys,\n  { constructor },\n  iterate 2\n  { specialize h x <|> specialize h y, simp at h,\n    cases h },\n  simp at nd₀ nd₁, classical,\n  cases nd₀, cases nd₁,\n  by_cases h' : x = y,\n  { subst y, constructor, apply l₀_ih ‹ _ › ‹ nodup ys ›,\n    intro a, specialize h a, simp at h,\n    by_cases h' : a = x,\n    { subst a, rw ← not_iff_not, split; intro; assumption },\n    { simp [h'] at h, exact h } },\n  { transitivity x :: y :: ys.erase x,\n    { constructor, apply l₀_ih ‹ _ ›,\n      { simp, split, { intro, apply nd₁_left, apply mem_of_mem_erase ‹_› },\n        apply nodup_erase_of_nodup; assumption },\n      { intro a, specialize h a, simp at h,\n        by_cases h' : a = x,\n        { subst a, rw ← not_iff_not, split; intro, simp [mem_erase_of_nodup,*], assumption },\n        { simp [h'] at h, simp [h], apply or_congr, refl,\n          simp [mem_erase_of_ne,*] } } },\n    transitivity y :: x :: ys.erase x,\n    { constructor },\n    { constructor, symmetry, apply perm_cons_erase,\n      specialize h x, simp [h'] at h, exact h } }\nend\n\nvariables [decidable_eq α]\n\n/-! ### `lookup` -/\n\n/-- `lookup a l` is the first value in `l` corresponding to the key `a`,\n  or `none` if no such element exists. -/\ndef lookup (a : α) : list (sigma β) → option (β a)\n| []             := none\n| (⟨a', b⟩ :: l) := if h : a' = a then some (eq.rec_on h b) else lookup l\n\n@[simp] theorem lookup_nil (a : α) : lookup a [] = @none (β a) := rfl\n\n@[simp] theorem lookup_cons_eq (l) (a : α) (b : β a) : lookup a (⟨a, b⟩::l) = some b :=\ndif_pos rfl\n\n@[simp] theorem lookup_cons_ne (l) {a} :\n  ∀ s : sigma β, a ≠ s.1 → lookup a (s::l) = lookup a l\n| ⟨a', b⟩ h := dif_neg h.symm\n\ntheorem lookup_is_some {a : α} : ∀ {l : list (sigma β)},\n  (lookup a l).is_some ↔ a ∈ l.keys\n| []             := by simp\n| (⟨a', b⟩ :: l) := begin\n  by_cases h : a = a',\n  { subst a', simp },\n  { simp [h, lookup_is_some] },\nend\n\ntheorem lookup_eq_none {a : α} {l : list (sigma β)} :\n  lookup a l = none ↔ a ∉ l.keys :=\nby simp [← lookup_is_some, option.is_none_iff_eq_none]\n\ntheorem of_mem_lookup\n  {a : α} {b : β a} : ∀ {l : list (sigma β)}, b ∈ lookup a l → sigma.mk a b ∈ l\n| (⟨a', b'⟩ :: l) H := begin\n  by_cases h : a = a',\n  { subst a', simp at H, simp [H] },\n  { simp [h] at H, exact or.inr (of_mem_lookup H) }\nend\n\ntheorem mem_lookup {a} {b : β a} {l : list (sigma β)} (nd : l.nodupkeys)\n  (h : sigma.mk a b ∈ l) : b ∈ lookup a l :=\nbegin\n  cases option.is_some_iff_exists.mp (lookup_is_some.mpr (mem_keys_of_mem h)) with b' h',\n  cases nd.eq_of_mk_mem h (of_mem_lookup h'),\n  exact h'\nend\n\ntheorem map_lookup_eq_find (a : α) : ∀ l : list (sigma β),\n  (lookup a l).map (sigma.mk a) = find (λ s, a = s.1) l\n| [] := rfl\n| (⟨a', b'⟩ :: l) := begin\n  by_cases h : a = a',\n  { subst a', simp },\n  { simp [h, map_lookup_eq_find] }\nend\n\ntheorem mem_lookup_iff {a : α} {b : β a} {l : list (sigma β)} (nd : l.nodupkeys) :\n  b ∈ lookup a l ↔ sigma.mk a b ∈ l :=\n⟨of_mem_lookup, mem_lookup nd⟩\n\ntheorem perm_lookup (a : α) {l₁ l₂ : list (sigma β)}\n  (nd₁ : l₁.nodupkeys) (nd₂ : l₂.nodupkeys) (p : l₁ ~ l₂) : lookup a l₁ = lookup a l₂ :=\nby ext b; simp [mem_lookup_iff, nd₁, nd₂]; exact p.mem_iff\n\nlemma lookup_ext {l₀ l₁ : list (sigma β)}\n  (nd₀ : l₀.nodupkeys) (nd₁ : l₁.nodupkeys)\n  (h : ∀ x y, y ∈ l₀.lookup x ↔ y ∈ l₁.lookup x) : l₀ ~ l₁ :=\nmem_ext (nodup_of_nodupkeys nd₀) (nodup_of_nodupkeys nd₁)\n  (λ ⟨a,b⟩, by rw [← mem_lookup_iff, ← mem_lookup_iff, h]; assumption)\n\n/-! ### `lookup_all` -/\n\n/-- `lookup_all a l` is the list of all values in `l` corresponding to the key `a`. -/\ndef lookup_all (a : α) : list (sigma β) → list (β a)\n| []             := []\n| (⟨a', b⟩ :: l) := if h : a' = a then eq.rec_on h b :: lookup_all l else lookup_all l\n\n@[simp] \n\n@[simp] theorem lookup_all_cons_eq (l) (a : α) (b : β a) :\n  lookup_all a (⟨a, b⟩::l) = b :: lookup_all a l :=\ndif_pos rfl\n\n@[simp] theorem lookup_all_cons_ne (l) {a} :\n  ∀ s : sigma β, a ≠ s.1 → lookup_all a (s::l) = lookup_all a l\n| ⟨a', b⟩ h := dif_neg h.symm\n\ntheorem lookup_all_eq_nil {a : α} : ∀ {l : list (sigma β)},\n  lookup_all a l = [] ↔ ∀ b : β a, sigma.mk a b ∉ l\n| []             := by simp\n| (⟨a', b⟩ :: l) := begin\n  by_cases h : a = a',\n  { subst a', simp },\n  { simp [h, lookup_all_eq_nil] },\nend\n\ntheorem head_lookup_all (a : α) : ∀ l : list (sigma β),\n  head' (lookup_all a l) = lookup a l\n| []             := by simp\n| (⟨a', b⟩ :: l) := by by_cases h : a = a'; [{subst h, simp}, simp *]\n\ntheorem mem_lookup_all {a : α} {b : β a} :\n  ∀ {l : list (sigma β)}, b ∈ lookup_all a l ↔ sigma.mk a b ∈ l\n| []              := by simp\n| (⟨a', b'⟩ :: l) := by by_cases h : a = a'; [{subst h, simp *}, simp *]\n\ntheorem lookup_all_sublist (a : α) :\n  ∀ l : list (sigma β), (lookup_all a l).map (sigma.mk a) <+ l\n| []              := by simp\n| (⟨a', b'⟩ :: l) := begin\n    by_cases h : a = a',\n    { subst h, simp, exact (lookup_all_sublist l).cons2 _ _ _ },\n    { simp [h], exact (lookup_all_sublist l).cons _ _ _ }\n  end\n\ntheorem lookup_all_length_le_one (a : α) {l : list (sigma β)} (h : l.nodupkeys) :\n  length (lookup_all a l) ≤ 1 :=\nby have := nodup_of_sublist ((lookup_all_sublist a l).map _) h;\n   rw map_map at this; rwa [← nodup_repeat, ← map_const _ a]\n\ntheorem lookup_all_eq_lookup (a : α) {l : list (sigma β)} (h : l.nodupkeys) :\n  lookup_all a l = (lookup a l).to_list :=\nbegin\n  rw ← head_lookup_all,\n  have := lookup_all_length_le_one a h, revert this,\n  rcases lookup_all a l with _|⟨b, _|⟨c, l⟩⟩; intro; try {refl},\n  exact absurd this dec_trivial\nend\n\ntheorem lookup_all_nodup (a : α) {l : list (sigma β)} (h : l.nodupkeys) :\n  (lookup_all a l).nodup :=\nby rw lookup_all_eq_lookup a h; apply option.to_list_nodup\n\ntheorem perm_lookup_all (a : α) {l₁ l₂ : list (sigma β)}\n  (nd₁ : l₁.nodupkeys) (nd₂ : l₂.nodupkeys) (p : l₁ ~ l₂) : lookup_all a l₁ = lookup_all a l₂ :=\nby simp [lookup_all_eq_lookup, nd₁, nd₂, perm_lookup a nd₁ nd₂ p]\n\n/-! ### `kreplace` -/\n\n/-- Replaces the first value with key `a` by `b`. -/\ndef kreplace (a : α) (b : β a) : list (sigma β) → list (sigma β) :=\nlookmap $ λ s, if a = s.1 then some ⟨a, b⟩ else none\n\ntheorem kreplace_of_forall_not (a : α) (b : β a) {l : list (sigma β)}\n  (H : ∀ b : β a, sigma.mk a b ∉ l) : kreplace a b l = l :=\nlookmap_of_forall_not _ $ begin\n  rintro ⟨a', b'⟩ h, dsimp, split_ifs,\n  { subst a', exact H _ h }, {refl}\nend\n\ntheorem kreplace_self {a : α} {b : β a} {l : list (sigma β)}\n  (nd : nodupkeys l) (h : sigma.mk a b ∈ l) : kreplace a b l = l :=\nbegin\n  refine (lookmap_congr _).trans\n    (lookmap_id' (option.guard (λ s, a = s.1)) _ _),\n  { rintro ⟨a', b'⟩ h', dsimp [option.guard], split_ifs,\n    { subst a', exact ⟨rfl, heq_of_eq $ nd.eq_of_mk_mem h h'⟩ },\n    { refl } },\n  { rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩, dsimp [option.guard], split_ifs,\n    { subst a₁, rintro ⟨⟩, simp }, { rintro ⟨⟩ } },\nend\n\ntheorem keys_kreplace (a : α) (b : β a) : ∀ l : list (sigma β),\n  (kreplace a b l).keys = l.keys :=\nlookmap_map_eq _ _ $ by rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩;\n  dsimp; split_ifs; simp [h] {contextual := tt}\n\ntheorem kreplace_nodupkeys (a : α) (b : β a) {l : list (sigma β)} :\n  (kreplace a b l).nodupkeys ↔ l.nodupkeys :=\nby simp [nodupkeys, keys_kreplace]\n\ntheorem perm.kreplace {a : α} {b : β a} {l₁ l₂ : list (sigma β)}\n  (nd : l₁.nodupkeys) : l₁ ~ l₂ →\n  kreplace a b l₁ ~ kreplace a b l₂ :=\nperm_lookmap _ $ begin\n  refine nd.pairwise_ne.imp _,\n  intros x y h z h₁ w h₂,\n  split_ifs at h₁ h₂; cases h₁; cases h₂,\n  exact (h (h_2.symm.trans h_1)).elim\nend\n\n/-! ### `kerase` -/\n\n/-- Remove the first pair with the key `a`. -/\ndef kerase (a : α) : list (sigma β) → list (sigma β) :=\nerasep $ λ s, a = s.1\n\n@[simp] theorem kerase_nil {a} : @kerase _ β _ a [] = [] :=\nrfl\n\n@[simp, priority 990]\ntheorem kerase_cons_eq {a} {s : sigma β} {l : list (sigma β)} (h : a = s.1) :\n  kerase a (s :: l) = l :=\nby simp [kerase, h]\n\n@[simp, priority 990]\ntheorem kerase_cons_ne {a} {s : sigma β} {l : list (sigma β)} (h : a ≠ s.1) :\n  kerase a (s :: l) = s :: kerase a l :=\nby simp [kerase, h]\n\n@[simp, priority 980]\ntheorem kerase_of_not_mem_keys {a} {l : list (sigma β)} (h : a ∉ l.keys) :\n  kerase a l = l :=\nby induction l with _ _ ih;\n   [refl, { simp [not_or_distrib] at h, simp [h.1, ih h.2] }]\n\ntheorem kerase_sublist (a : α) (l : list (sigma β)) : kerase a l <+ l :=\nerasep_sublist _\n\ntheorem kerase_keys_subset (a) (l : list (sigma β)) :\n  (kerase a l).keys ⊆ l.keys :=\n((kerase_sublist a l).map _).subset\n\ntheorem mem_keys_of_mem_keys_kerase {a₁ a₂} {l : list (sigma β)} :\n  a₁ ∈ (kerase a₂ l).keys → a₁ ∈ l.keys :=\n@kerase_keys_subset _ _ _ _ _ _\n\ntheorem exists_of_kerase {a : α} {l : list (sigma β)} (h : a ∈ l.keys) :\n  ∃ (b : β a) (l₁ l₂ : list (sigma β)),\n    a ∉ l₁.keys ∧\n    l = l₁ ++ ⟨a, b⟩ :: l₂ ∧\n    kerase a l = l₁ ++ l₂ :=\nbegin\n  induction l,\n  case list.nil { cases h },\n  case list.cons : hd tl ih\n  { by_cases e : a = hd.1,\n    { subst e,\n      exact ⟨hd.2, [], tl, by simp, by cases hd; refl, by simp⟩ },\n    { simp at h,\n      cases h,\n      case or.inl : h { exact absurd h e },\n      case or.inr : h\n      { rcases ih h with ⟨b, tl₁, tl₂, h₁, h₂, h₃⟩,\n        exact ⟨b, hd :: tl₁, tl₂, not_mem_cons_of_ne_of_not_mem e h₁,\n               by rw h₂; refl, by simp [e, h₃]⟩ } } }\nend\n\n@[simp, priority 990]\ntheorem mem_keys_kerase_of_ne {a₁ a₂} {l : list (sigma β)} (h : a₁ ≠ a₂) :\n  a₁ ∈ (kerase a₂ l).keys ↔ a₁ ∈ l.keys :=\niff.intro mem_keys_of_mem_keys_kerase $ λ p,\n  if q : a₂ ∈ l.keys then\n    match l, kerase a₂ l, exists_of_kerase q, p with\n    | _, _, ⟨_, _, _, _, rfl, rfl⟩, p := by simpa [keys, h] using p\n    end\n  else\n    by simp [q, p]\n\ntheorem keys_kerase {a} {l : list (sigma β)} : (kerase a l).keys = l.keys.erase a :=\nby rw [keys, kerase, ←erasep_map sigma.fst l, erase_eq_erasep]\n\ntheorem kerase_kerase {a a'} {l : list (sigma β)} :\n  (kerase a' l).kerase a = (kerase a l).kerase a' :=\nbegin\n  by_cases a = a',\n  { subst a' },\n  induction l with x xs, { refl },\n  { by_cases a' = x.1,\n    { subst a', simp [kerase_cons_ne h,kerase_cons_eq rfl] },\n    by_cases h' : a = x.1,\n    { subst a, simp [kerase_cons_eq rfl,kerase_cons_ne (ne.symm h)] },\n    { simp [kerase_cons_ne,*] } }\nend\n\ntheorem kerase_nodupkeys (a : α) {l : list (sigma β)} : nodupkeys l → (kerase a l).nodupkeys :=\nnodupkeys_of_sublist $ kerase_sublist _ _\n\ntheorem perm.kerase {a : α} {l₁ l₂ : list (sigma β)}\n  (nd : l₁.nodupkeys) : l₁ ~ l₂ → kerase a l₁ ~ kerase a l₂ :=\nperm.erasep _ $ (nodupkeys_iff_pairwise.1 nd).imp $\nby rintro x y h rfl; exact h\n\n@[simp] theorem not_mem_keys_kerase (a) {l : list (sigma β)} (nd : l.nodupkeys) :\n  a ∉ (kerase a l).keys :=\nbegin\n  induction l,\n  case list.nil { simp },\n  case list.cons : hd tl ih\n  { simp at nd,\n    by_cases h : a = hd.1,\n    { subst h, simp [nd.1] },\n    { simp [h, ih nd.2] } }\nend\n\n@[simp] theorem lookup_kerase (a) {l : list (sigma β)} (nd : l.nodupkeys) :\n  lookup a (kerase a l) = none :=\nlookup_eq_none.mpr (not_mem_keys_kerase a nd)\n\n@[simp] theorem lookup_kerase_ne {a a'} {l : list (sigma β)} (h : a ≠ a') :\n  lookup a (kerase a' l) = lookup a l :=\nbegin\n  induction l,\n  case list.nil { refl },\n  case list.cons : hd tl ih\n  { cases hd with ah bh,\n    by_cases h₁ : a = ah; by_cases h₂ : a' = ah,\n    { substs h₁ h₂, cases ne.irrefl h },\n    { subst h₁, simp [h₂] },\n    { subst h₂, simp [h] },\n    { simp [h₁, h₂, ih] } }\nend\n\ntheorem kerase_append_left {a} : ∀ {l₁ l₂ : list (sigma β)},\n  a ∈ l₁.keys → kerase a (l₁ ++ l₂) = kerase a l₁ ++ l₂\n| []        _  h  := by cases h\n| (s :: l₁) l₂ h₁ :=\n  if h₂ : a = s.1 then\n    by simp [h₂]\n  else\n    by simp at h₁;\n       cases h₁;\n       [exact absurd h₁ h₂, simp [h₂, kerase_append_left h₁]]\n\ntheorem kerase_append_right {a} : ∀ {l₁ l₂ : list (sigma β)},\n  a ∉ l₁.keys → kerase a (l₁ ++ l₂) = l₁ ++ kerase a l₂\n| []        _  h := rfl\n| (_ :: l₁) l₂ h := by simp [not_or_distrib] at h;\n                       simp [h.1, kerase_append_right h.2]\n\ntheorem kerase_comm (a₁ a₂) (l : list (sigma β)) :\n  kerase a₂ (kerase a₁ l) = kerase a₁ (kerase a₂ l) :=\nif h : a₁ = a₂ then\n  by simp [h]\nelse if ha₁ : a₁ ∈ l.keys then\n  if ha₂ : a₂ ∈ l.keys then\n    match l, kerase a₁ l, exists_of_kerase ha₁, ha₂ with\n    | _, _, ⟨b₁, l₁, l₂, a₁_nin_l₁, rfl, rfl⟩, a₂_in_l₁_app_l₂ :=\n      if h' : a₂ ∈ l₁.keys then\n        by simp [kerase_append_left h',\n                 kerase_append_right (mt (mem_keys_kerase_of_ne h).mp a₁_nin_l₁)]\n      else\n        by simp [kerase_append_right h', kerase_append_right a₁_nin_l₁,\n                 @kerase_cons_ne _ _ _ a₂ ⟨a₁, b₁⟩ _ (ne.symm h)]\n    end\n  else\n    by simp [ha₂, mt mem_keys_of_mem_keys_kerase ha₂]\nelse\n  by simp [ha₁, mt mem_keys_of_mem_keys_kerase ha₁]\n\nlemma sizeof_kerase {α} {β : α → Type*} [decidable_eq α] [has_sizeof (sigma β)] (x : α)\n  (xs : list (sigma β)) :\n  sizeof (list.kerase x xs) ≤ sizeof xs :=\nbegin\n  unfold_wf,\n  induction xs with y ys,\n  { simp },\n  { by_cases x = y.1; simp [*, list.sizeof] },\nend\n\n/-! ### `kinsert` -/\n\n/-- Insert the pair `⟨a, b⟩` and erase the first pair with the key `a`. -/\ndef kinsert (a : α) (b : β a) (l : list (sigma β)) : list (sigma β) :=\n⟨a, b⟩ :: kerase a l\n\n@[simp] theorem kinsert_def {a} {b : β a} {l : list (sigma β)} :\n  kinsert a b l = ⟨a, b⟩ :: kerase a l := rfl\n\ntheorem mem_keys_kinsert {a a'} {b' : β a'} {l : list (sigma β)} :\n  a ∈ (kinsert a' b' l).keys ↔ a = a' ∨ a ∈ l.keys :=\nby by_cases h : a = a'; simp [h]\n\ntheorem kinsert_nodupkeys (a) (b : β a) {l : list (sigma β)} (nd : l.nodupkeys) :\n  (kinsert a b l).nodupkeys :=\nnodupkeys_cons.mpr ⟨not_mem_keys_kerase a nd, kerase_nodupkeys a nd⟩\n\ntheorem perm.kinsert {a} {b : β a} {l₁ l₂ : list (sigma β)} (nd₁ : l₁.nodupkeys)\n  (p : l₁ ~ l₂) : kinsert a b l₁ ~ kinsert a b l₂ :=\n(p.kerase nd₁).cons _\n\ntheorem lookup_kinsert {a} {b : β a} (l : list (sigma β)) :\n  lookup a (kinsert a b l) = some b :=\nby simp only [kinsert, lookup_cons_eq]\n\ntheorem lookup_kinsert_ne {a a'} {b' : β a'} {l : list (sigma β)} (h : a ≠ a') :\n  lookup a (kinsert a' b' l) = lookup a l :=\nby simp [h]\n\n/-! ### `kextract` -/\n\n/-- Finds the first entry with a given key `a` and returns its value (as an `option` because there\nmight be no entry with key `a`) alongside with the rest of the entries. -/\ndef kextract (a : α) : list (sigma β) → option (β a) × list (sigma β)\n| []     := (none, [])\n| (s::l) := if h : s.1 = a then (some (eq.rec_on h s.2), l) else\n  let (b', l') := kextract l in (b', s :: l')\n\n@[simp] theorem kextract_eq_lookup_kerase (a : α) :\n  ∀ l : list (sigma β), kextract a l = (lookup a l, kerase a l)\n| []     := rfl\n| (⟨a', b⟩::l) := begin\n    simp [kextract], dsimp, split_ifs,\n    { subst a', simp [kerase] },\n    { simp [kextract, ne.symm h, kextract_eq_lookup_kerase l, kerase] }\n  end\n\n/-! ### `erase_dupkeys` -/\n\n/-- Remove entries with duplicate keys from `l : list (sigma β)`. -/\ndef erase_dupkeys : list (sigma β) → list (sigma β) :=\nlist.foldr (λ x, kinsert x.1 x.2) []\n\nlemma erase_dupkeys_cons {x : sigma β} (l : list (sigma β)) :\n  erase_dupkeys (x :: l) = kinsert x.1 x.2 (erase_dupkeys l) := rfl\n\nlemma nodupkeys_erase_dupkeys (l : list (sigma β)) : nodupkeys (erase_dupkeys l) :=\nbegin\n  dsimp [erase_dupkeys], generalize hl : nil = l',\n  have : nodupkeys l', { rw ← hl, apply nodup_nil },\n  clear hl,\n  induction l with x xs,\n  { apply this },\n  { cases x, simp [erase_dupkeys], split,\n    { simp [keys_kerase], apply mem_erase_of_nodup l_ih },\n    apply kerase_nodupkeys _ l_ih, }\nend\n\nlemma lookup_erase_dupkeys (a : α) (l : list (sigma β)) : lookup a (erase_dupkeys l) = lookup a l :=\nbegin\n  induction l, refl,\n  cases l_hd with a' b,\n  by_cases a = a',\n  { subst a', rw [erase_dupkeys_cons,lookup_kinsert,lookup_cons_eq] },\n  { rw [erase_dupkeys_cons,lookup_kinsert_ne h,l_ih,lookup_cons_ne], exact h },\nend\n\nlemma sizeof_erase_dupkeys {α} {β : α → Type*} [decidable_eq α] [has_sizeof (sigma β)]\n  (xs : list (sigma β)) :\n  sizeof (list.erase_dupkeys xs) ≤ sizeof xs :=\nbegin\n  unfold_wf,\n  induction xs with x xs,\n  { simp [list.erase_dupkeys] },\n  { simp only [erase_dupkeys_cons, list.sizeof, kinsert_def, add_le_add_iff_left, sigma.eta],\n    transitivity, apply sizeof_kerase,\n    assumption }\nend\n\n/-! ### `kunion` -/\n\n/-- `kunion l₁ l₂` is the append to l₁ of l₂ after, for each key in l₁, the\nfirst matching pair in l₂ is erased. -/\ndef kunion : list (sigma β) → list (sigma β) → list (sigma β)\n| []        l₂ := l₂\n| (s :: l₁) l₂ := s :: kunion l₁ (kerase s.1 l₂)\n\n@[simp] theorem nil_kunion {l : list (sigma β)} : kunion [] l = l :=\nrfl\n\n@[simp] theorem kunion_nil : ∀ {l : list (sigma β)}, kunion l [] = l\n| []       := rfl\n| (_ :: l) := by rw [kunion, kerase_nil, kunion_nil]\n\n@[simp] theorem kunion_cons {s} {l₁ l₂ : list (sigma β)} :\n  kunion (s :: l₁) l₂ = s :: kunion l₁ (kerase s.1 l₂) :=\nrfl\n\n@[simp] theorem mem_keys_kunion {a} {l₁ l₂ : list (sigma β)} :\n  a ∈ (kunion l₁ l₂).keys ↔ a ∈ l₁.keys ∨ a ∈ l₂.keys :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp },\n  case list.cons : s l₁ ih { by_cases h : a = s.1; [simp [h], simp [h, ih]] }\nend\n\n@[simp] theorem kunion_kerase {a} : ∀ {l₁ l₂ : list (sigma β)},\n  kunion (kerase a l₁) (kerase a l₂) = kerase a (kunion l₁ l₂)\n| []       _ := rfl\n| (s :: _) l := by by_cases h : a = s.1;\n                   simp [h, kerase_comm a s.1 l, kunion_kerase]\n\ntheorem kunion_nodupkeys {l₁ l₂ : list (sigma β)}\n  (nd₁ : l₁.nodupkeys) (nd₂ : l₂.nodupkeys) : (kunion l₁ l₂).nodupkeys :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp only [nil_kunion, nd₂] },\n  case list.cons : s l₁ ih\n  { simp at nd₁,\n    simp [not_or_distrib, nd₁.1, nd₂, ih nd₁.2 (kerase_nodupkeys s.1 nd₂)] }\nend\n\ntheorem perm.kunion_right {l₁ l₂ : list (sigma β)} (p : l₁ ~ l₂) (l) :\n  kunion l₁ l ~ kunion l₂ l :=\nbegin\n  induction p generalizing l,\n  case list.perm.nil { refl },\n  case list.perm.cons : hd tl₁ tl₂ p ih\n  { simp [ih (kerase hd.1 l), perm.cons] },\n  case list.perm.swap : s₁ s₂ l\n  { simp [kerase_comm, perm.swap] },\n  case list.perm.trans : l₁ l₂ l₃ p₁₂ p₂₃ ih₁₂ ih₂₃\n  { exact perm.trans (ih₁₂ l) (ih₂₃ l) }\nend\n\ntheorem perm.kunion_left : ∀ l {l₁ l₂ : list (sigma β)},\n  l₁.nodupkeys → l₁ ~ l₂ → kunion l l₁ ~ kunion l l₂\n| []       _  _  _   p := p\n| (s :: l) l₁ l₂ nd₁ p :=\n  by simp [((p.kerase nd₁).kunion_left l (kerase_nodupkeys s.1 nd₁)).cons s]\n\ntheorem perm.kunion {l₁ l₂ l₃ l₄ : list (sigma β)} (nd₃ : l₃.nodupkeys)\n  (p₁₂ : l₁ ~ l₂) (p₃₄ : l₃ ~ l₄) : kunion l₁ l₃ ~ kunion l₂ l₄ :=\n(p₁₂.kunion_right l₃).trans (p₃₄.kunion_left l₂ nd₃)\n\n@[simp] theorem lookup_kunion_left {a} {l₁ l₂ : list (sigma β)} (h : a ∈ l₁.keys) :\n  lookup a (kunion l₁ l₂) = lookup a l₁ :=\nbegin\n  induction l₁ with s _ ih generalizing l₂; simp at h; cases h; cases s with a',\n  { subst h, simp },\n  { rw kunion_cons,\n    by_cases h' : a = a',\n    { subst h', simp },\n    { simp [h', ih h] } }\nend\n\n@[simp] theorem lookup_kunion_right {a} {l₁ l₂ : list (sigma β)} (h : a ∉ l₁.keys) :\n  lookup a (kunion l₁ l₂) = lookup a l₂ :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp },\n  case list.cons : _ _ ih { simp [not_or_distrib] at h, simp [h.1, ih h.2] }\nend\n\n@[simp] theorem mem_lookup_kunion {a} {b : β a} {l₁ l₂ : list (sigma β)} :\n  b ∈ lookup a (kunion l₁ l₂) ↔ b ∈ lookup a l₁ ∨ a ∉ l₁.keys ∧ b ∈ lookup a l₂ :=\nbegin\n  induction l₁ generalizing l₂,\n  case list.nil { simp },\n  case list.cons : s _ ih\n  { cases s with a',\n    by_cases h₁ : a = a',\n    { subst h₁, simp },\n    { let h₂ := @ih (kerase a' l₂), simp [h₁] at h₂, simp [h₁, h₂] } }\nend\n\ntheorem mem_lookup_kunion_middle {a} {b : β a} {l₁ l₂ l₃ : list (sigma β)}\n  (h₁ : b ∈ lookup a (kunion l₁ l₃)) (h₂ : a ∉ keys l₂) :\n  b ∈ lookup a (kunion (kunion l₁ l₂) l₃) :=\nmatch mem_lookup_kunion.mp h₁ with\n| or.inl h := mem_lookup_kunion.mpr (or.inl (mem_lookup_kunion.mpr (or.inl h)))\n| or.inr h := mem_lookup_kunion.mpr $\n  or.inr ⟨mt mem_keys_kunion.mp (not_or_distrib.mpr ⟨h.1, h₂⟩), h.2⟩\nend\n\nend list\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/list/sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.48259227823095796}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module algebra.direct_sum.ring\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GradedMonoid\nimport Mathbin.Algebra.DirectSum.Basic\n\n/-!\n# Additively-graded multiplicative structures on `⨁ i, A i`\n\nThis module provides a set of heterogeneous typeclasses for defining a multiplicative structure\nover `⨁ i, A i` such that `(*) : A i → A j → A (i + j)`; that is to say, `A` forms an\nadditively-graded ring. The typeclasses are:\n\n* `direct_sum.gnon_unital_non_assoc_semiring A`\n* `direct_sum.gsemiring A`\n* `direct_sum.gring A`\n* `direct_sum.gcomm_semiring A`\n* `direct_sum.gcomm_ring A`\n\nRespectively, these imbue the external direct sum `⨁ i, A i` with:\n\n* `direct_sum.non_unital_non_assoc_semiring`, `direct_sum.non_unital_non_assoc_ring`\n* `direct_sum.semiring`\n* `direct_sum.ring`\n* `direct_sum.comm_semiring`\n* `direct_sum.comm_ring`\n\nthe base ring `A 0` with:\n\n* `direct_sum.grade_zero.non_unital_non_assoc_semiring`,\n  `direct_sum.grade_zero.non_unital_non_assoc_ring`\n* `direct_sum.grade_zero.semiring`\n* `direct_sum.grade_zero.ring`\n* `direct_sum.grade_zero.comm_semiring`\n* `direct_sum.grade_zero.comm_ring`\n\nand the `i`th grade `A i` with `A 0`-actions (`•`) defined as left-multiplication:\n\n* `direct_sum.grade_zero.has_smul (A 0)`, `direct_sum.grade_zero.smul_with_zero (A 0)`\n* `direct_sum.grade_zero.module (A 0)`\n* (nothing)\n* (nothing)\n* (nothing)\n\nNote that in the presence of these instances, `⨁ i, A i` itself inherits an `A 0`-action.\n\n`direct_sum.of_zero_ring_hom : A 0 →+* ⨁ i, A i` provides `direct_sum.of A 0` as a ring\nhomomorphism.\n\n`direct_sum.to_semiring` extends `direct_sum.to_add_monoid` to produce a `ring_hom`.\n\n## Direct sums of subobjects\n\nAdditionally, this module provides helper functions to construct `gsemiring` and `gcomm_semiring`\ninstances for:\n\n* `A : ι → submonoid S`:\n  `direct_sum.gsemiring.of_add_submonoids`, `direct_sum.gcomm_semiring.of_add_submonoids`.\n* `A : ι → subgroup S`:\n  `direct_sum.gsemiring.of_add_subgroups`, `direct_sum.gcomm_semiring.of_add_subgroups`.\n* `A : ι → submodule S`:\n  `direct_sum.gsemiring.of_submodules`, `direct_sum.gcomm_semiring.of_submodules`.\n\nIf `complete_lattice.independent (set.range A)`, these provide a gradation of `⨆ i, A i`, and the\nmapping `⨁ i, A i →+ ⨆ i, A i` can be obtained as\n`direct_sum.to_monoid (λ i, add_submonoid.inclusion $ le_supr A i)`.\n\n## tags\n\ngraded ring, filtered ring, direct sum, add_submonoid\n-/\n\n\nvariable {ι : Type _} [DecidableEq ι]\n\nnamespace DirectSum\n\nopen DirectSum\n\n/-! ### Typeclasses -/\n\n\nsection Defs\n\nvariable (A : ι → Type _)\n\n/-- A graded version of `non_unital_non_assoc_semiring`. -/\nclass GnonUnitalNonAssocSemiring [Add ι] [∀ i, AddCommMonoid (A i)] extends\n  GradedMonoid.GMul A where\n  mul_zero : ∀ {i j} (a : A i), mul a (0 : A j) = 0\n  zero_mul : ∀ {i j} (b : A j), mul (0 : A i) b = 0\n  mul_add : ∀ {i j} (a : A i) (b c : A j), mul a (b + c) = mul a b + mul a c\n  add_mul : ∀ {i j} (a b : A i) (c : A j), mul (a + b) c = mul a c + mul b c\n#align direct_sum.gnon_unital_non_assoc_semiring DirectSum.GnonUnitalNonAssocSemiring\n\nend Defs\n\nsection Defs\n\nvariable (A : ι → Type _)\n\n/-- A graded version of `semiring`. -/\nclass Gsemiring [AddMonoid ι] [∀ i, AddCommMonoid (A i)] extends GnonUnitalNonAssocSemiring A,\n  GradedMonoid.GMonoid A where\n  natCast : ℕ → A 0\n  natCast_zero : nat_cast 0 = 0\n  natCast_succ : ∀ n : ℕ, nat_cast (n + 1) = nat_cast n + GradedMonoid.GOne.one\n#align direct_sum.gsemiring DirectSum.Gsemiring\n\n/-- A graded version of `comm_semiring`. -/\nclass GcommSemiring [AddCommMonoid ι] [∀ i, AddCommMonoid (A i)] extends Gsemiring A,\n  GradedMonoid.GCommMonoid A\n#align direct_sum.gcomm_semiring DirectSum.GcommSemiring\n\n/-- A graded version of `ring`. -/\nclass Gring [AddMonoid ι] [∀ i, AddCommGroup (A i)] extends Gsemiring A where\n  intCast : ℤ → A 0\n  intCast_ofNat : ∀ n : ℕ, int_cast n = nat_cast n\n  intCast_negSucc : ∀ n : ℕ, int_cast (-(n + 1 : ℕ)) = -nat_cast (n + 1 : ℕ)\n#align direct_sum.gring DirectSum.Gring\n\n/-- A graded version of `comm_ring`. -/\nclass GcommRing [AddCommMonoid ι] [∀ i, AddCommGroup (A i)] extends Gring A, GcommSemiring A\n#align direct_sum.gcomm_ring DirectSum.GcommRing\n\nend Defs\n\ntheorem of_eq_of_gradedMonoid_eq {A : ι → Type _} [∀ i : ι, AddCommMonoid (A i)] {i j : ι} {a : A i}\n    {b : A j} (h : GradedMonoid.mk i a = GradedMonoid.mk j b) :\n    DirectSum.of A i a = DirectSum.of A j b :=\n  Dfinsupp.single_eq_of_sigma_eq h\n#align direct_sum.of_eq_of_graded_monoid_eq DirectSum.of_eq_of_gradedMonoid_eq\n\nvariable (A : ι → Type _)\n\n/-! ### Instances for `⨁ i, A i` -/\n\n\nsection One\n\nvariable [Zero ι] [GradedMonoid.GOne A] [∀ i, AddCommMonoid (A i)]\n\ninstance : One (⨁ i, A i) where one := DirectSum.of (fun i => A i) 0 GradedMonoid.GOne.one\n\nend One\n\nsection Mul\n\nvariable [Add ι] [∀ i, AddCommMonoid (A i)] [GnonUnitalNonAssocSemiring A]\n\nopen AddMonoidHom (flip_apply coe_comp compHom_apply_apply)\n\n/-- The piecewise multiplication from the `has_mul` instance, as a bundled homomorphism. -/\n@[simps]\ndef gmulHom {i j} : A i →+ A j →+ A (i + j)\n    where\n  toFun a :=\n    { toFun := fun b => GradedMonoid.GMul.mul a b\n      map_zero' := GnonUnitalNonAssocSemiring.mul_zero _\n      map_add' := GnonUnitalNonAssocSemiring.mul_add _ }\n  map_zero' := AddMonoidHom.ext fun a => GnonUnitalNonAssocSemiring.zero_mul a\n  map_add' a₁ a₂ := AddMonoidHom.ext fun b => GnonUnitalNonAssocSemiring.add_mul _ _ _\n#align direct_sum.gmul_hom DirectSum.gmulHom\n\n/-- The multiplication from the `has_mul` instance, as a bundled homomorphism. -/\ndef mulHom : (⨁ i, A i) →+ (⨁ i, A i) →+ ⨁ i, A i :=\n  DirectSum.toAddMonoid fun i =>\n    AddMonoidHom.flip <|\n      DirectSum.toAddMonoid fun j =>\n        AddMonoidHom.flip <| (DirectSum.of A _).compHom.comp <| gmulHom A\n#align direct_sum.mul_hom DirectSum.mulHom\n\ninstance : NonUnitalNonAssocSemiring (⨁ i, A i) :=\n  { DirectSum.addCommMonoid _ _ with\n    mul := fun a b => mulHom A a b\n    zero := 0\n    add := (· + ·)\n    zero_mul := fun a => by simp only [AddMonoidHom.map_zero, AddMonoidHom.zero_apply]\n    mul_zero := fun a => by simp only [AddMonoidHom.map_zero]\n    left_distrib := fun a b c => by simp only [AddMonoidHom.map_add]\n    right_distrib := fun a b c => by simp only [AddMonoidHom.map_add, AddMonoidHom.add_apply] }\n\nvariable {A}\n\ntheorem mulHom_of_of {i j} (a : A i) (b : A j) :\n    mulHom A (of _ i a) (of _ j b) = of _ (i + j) (GradedMonoid.GMul.mul a b) :=\n  by\n  unfold MulHom\n  rw [to_add_monoid_of, flip_apply, to_add_monoid_of, flip_apply, coe_comp, Function.comp_apply,\n    comp_hom_apply_apply, coe_comp, Function.comp_apply, gmul_hom_apply_apply]\n#align direct_sum.mul_hom_of_of DirectSum.mulHom_of_of\n\ntheorem of_mul_of {i j} (a : A i) (b : A j) :\n    of _ i a * of _ j b = of _ (i + j) (GradedMonoid.GMul.mul a b) :=\n  mulHom_of_of a b\n#align direct_sum.of_mul_of DirectSum.of_mul_of\n\nend Mul\n\nsection Semiring\n\nvariable [∀ i, AddCommMonoid (A i)] [AddMonoid ι] [Gsemiring A]\n\nopen AddMonoidHom (flipHom coe_comp compHom_apply_apply flip_apply flipHom_apply)\n\nprivate theorem one_mul (x : ⨁ i, A i) : 1 * x = x :=\n  by\n  suffices mulHom A 1 = AddMonoidHom.id (⨁ i, A i) from AddMonoidHom.congr_fun this x\n  apply add_hom_ext; intro i xi\n  unfold One.one\n  rw [mul_hom_of_of]\n  exact of_eq_of_graded_monoid_eq (one_mul <| GradedMonoid.mk i xi)\n#align direct_sum.one_mul direct_sum.one_mul\n\nprivate theorem mul_one (x : ⨁ i, A i) : x * 1 = x :=\n  by\n  suffices (mulHom A).flip 1 = AddMonoidHom.id (⨁ i, A i) from AddMonoidHom.congr_fun this x\n  apply add_hom_ext; intro i xi\n  unfold One.one\n  rw [flip_apply, mul_hom_of_of]\n  exact of_eq_of_graded_monoid_eq (mul_one <| GradedMonoid.mk i xi)\n#align direct_sum.mul_one direct_sum.mul_one\n\nprivate theorem mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) :=\n  by\n  suffices\n    (-- `λ a b c, a * b * c` as a bundled hom\n              mulHom\n              A).compHom.comp\n        (mulHom A) =\n      (AddMonoidHom.compHom flipHom <|\n          (-- `λ a b c, a * (b * c)` as a bundled hom\n                    mulHom\n                    A).flip.compHom.comp\n            (mulHom A)).flip\n    from AddMonoidHom.congr_fun (AddMonoidHom.congr_fun (AddMonoidHom.congr_fun this a) b) c\n  ext (ai ax bi bx ci cx) : 6\n  dsimp only [coe_comp, Function.comp_apply, comp_hom_apply_apply, flip_apply, flip_hom_apply]\n  rw [mul_hom_of_of, mul_hom_of_of, mul_hom_of_of, mul_hom_of_of]\n  exact of_eq_of_graded_monoid_eq (mul_assoc (GradedMonoid.mk ai ax) ⟨bi, bx⟩ ⟨ci, cx⟩)\n#align direct_sum.mul_assoc direct_sum.mul_assoc\n\n/-- The `semiring` structure derived from `gsemiring A`. -/\ninstance semiring : Semiring (⨁ i, A i) :=\n  { DirectSum.nonUnitalNonAssocSemiring _ with\n    one := 1\n    mul := (· * ·)\n    zero := 0\n    add := (· + ·)\n    one_mul := one_mul A\n    mul_one := mul_one A\n    mul_assoc := mul_assoc A\n    natCast := fun n => of _ _ (Gsemiring.natCast n)\n    natCast_zero := by rw [gsemiring.nat_cast_zero, map_zero]\n    natCast_succ := fun n => by\n      rw [gsemiring.nat_cast_succ, map_add]\n      rfl }\n#align direct_sum.semiring DirectSum.semiring\n\ntheorem of_pow {i} (a : A i) (n : ℕ) :\n    of _ i a ^ n = of _ (n • i) (GradedMonoid.GMonoid.gnpow _ a) :=\n  by\n  induction' n with n\n  · exact of_eq_of_graded_monoid_eq (pow_zero <| GradedMonoid.mk _ a).symm\n  · rw [pow_succ, n_ih, of_mul_of]\n    exact of_eq_of_graded_monoid_eq (pow_succ (GradedMonoid.mk _ a) n).symm\n#align direct_sum.of_pow DirectSum.of_pow\n\ntheorem of_list_dProd {α} (l : List α) (fι : α → ι) (fA : ∀ a, A (fι a)) :\n    of A _ (l.dProd fι fA) = (l.map fun a => of A (fι a) (fA a)).Prod :=\n  by\n  induction l\n  · simp only [List.map_nil, List.prod_nil, List.dProd_nil]\n    rfl\n  · simp only [List.map_cons, List.prod_cons, List.dProd_cons, ← l_ih, DirectSum.of_mul_of]\n    rfl\n#align direct_sum.of_list_dprod DirectSum.of_list_dProd\n\ntheorem list_prod_ofFn_of_eq_dProd (n : ℕ) (fι : Fin n → ι) (fA : ∀ a, A (fι a)) :\n    (List.ofFn fun a => of A (fι a) (fA a)).Prod = of A _ ((List.finRange n).dProd fι fA) := by\n  rw [List.ofFn_eq_map, of_list_dprod]\n#align direct_sum.list_prod_of_fn_of_eq_dprod DirectSum.list_prod_ofFn_of_eq_dProd\n\nopen BigOperators\n\ntheorem mul_eq_dfinsupp_sum [∀ (i : ι) (x : A i), Decidable (x ≠ 0)] (a a' : ⨁ i, A i) :\n    a * a' = a.Sum fun i ai => a'.Sum fun j aj => DirectSum.of _ _ <| GradedMonoid.GMul.mul ai aj :=\n  by\n  change MulHom _ a a' = _\n  simpa only [MulHom, to_add_monoid, Dfinsupp.liftAddHom_apply, Dfinsupp.sumAddHom_apply,\n    AddMonoidHom.dfinsupp_sum_apply, flip_apply, AddMonoidHom.dfinsupp_sumAddHom_apply]\n#align direct_sum.mul_eq_dfinsupp_sum DirectSum.mul_eq_dfinsupp_sum\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- A heavily unfolded version of the definition of multiplication -/\ntheorem mul_eq_sum_support_ghas_mul [∀ (i : ι) (x : A i), Decidable (x ≠ 0)] (a a' : ⨁ i, A i) :\n    a * a' =\n      ∑ ij in Dfinsupp.support a ×ˢ Dfinsupp.support a',\n        DirectSum.of _ _ (GradedMonoid.GMul.mul (a ij.fst) (a' ij.snd)) :=\n  by simp only [mul_eq_dfinsupp_sum, Dfinsupp.sum, Finset.sum_product]\n#align direct_sum.mul_eq_sum_support_ghas_mul DirectSum.mul_eq_sum_support_ghas_mul\n\nend Semiring\n\nsection CommSemiring\n\nvariable [∀ i, AddCommMonoid (A i)] [AddCommMonoid ι] [GcommSemiring A]\n\nprivate theorem mul_comm (a b : ⨁ i, A i) : a * b = b * a :=\n  by\n  suffices mulHom A = (mulHom A).flip from AddMonoidHom.congr_fun (AddMonoidHom.congr_fun this a) b\n  apply add_hom_ext; intro ai ax; apply add_hom_ext; intro bi bx\n  rw [AddMonoidHom.flip_apply, mul_hom_of_of, mul_hom_of_of]\n  exact of_eq_of_graded_monoid_eq (gcomm_semiring.mul_comm ⟨ai, ax⟩ ⟨bi, bx⟩)\n#align direct_sum.mul_comm direct_sum.mul_comm\n\n/-- The `comm_semiring` structure derived from `gcomm_semiring A`. -/\ninstance commSemiring : CommSemiring (⨁ i, A i) :=\n  { DirectSum.semiring _ with\n    one := 1\n    mul := (· * ·)\n    zero := 0\n    add := (· + ·)\n    mul_comm := mul_comm A }\n#align direct_sum.comm_semiring DirectSum.commSemiring\n\nend CommSemiring\n\nsection NonUnitalNonAssocRing\n\nvariable [∀ i, AddCommGroup (A i)] [Add ι] [GnonUnitalNonAssocSemiring A]\n\n/-- The `ring` derived from `gsemiring A`. -/\ninstance nonAssocRing : NonUnitalNonAssocRing (⨁ i, A i) :=\n  { DirectSum.nonUnitalNonAssocSemiring _,\n    DirectSum.addCommGroup _ with\n    mul := (· * ·)\n    zero := 0\n    add := (· + ·)\n    neg := Neg.neg }\n#align direct_sum.non_assoc_ring DirectSum.nonAssocRing\n\nend NonUnitalNonAssocRing\n\nsection Ring\n\nvariable [∀ i, AddCommGroup (A i)] [AddMonoid ι] [Gring A]\n\n/-- The `ring` derived from `gsemiring A`. -/\ninstance ring : Ring (⨁ i, A i) :=\n  { DirectSum.semiring _,\n    DirectSum.addCommGroup _ with\n    one := 1\n    mul := (· * ·)\n    zero := 0\n    add := (· + ·)\n    neg := Neg.neg\n    intCast := fun z => of _ _ (Gring.intCast z)\n    intCast_ofNat := fun z => congr_arg _ <| Gring.intCast_of_nat _\n    intCast_negSucc := fun z =>\n      (congr_arg _ <| Gring.intCast_neg_succ_of_nat _).trans (map_neg _ _) }\n#align direct_sum.ring DirectSum.ring\n\nend Ring\n\nsection CommRing\n\nvariable [∀ i, AddCommGroup (A i)] [AddCommMonoid ι] [GcommRing A]\n\n/-- The `comm_ring` derived from `gcomm_semiring A`. -/\ninstance commRing : CommRing (⨁ i, A i) :=\n  { DirectSum.ring _,\n    DirectSum.commSemiring _ with\n    one := 1\n    mul := (· * ·)\n    zero := 0\n    add := (· + ·)\n    neg := Neg.neg }\n#align direct_sum.comm_ring DirectSum.commRing\n\nend CommRing\n\n/-! ### Instances for `A 0`\n\nThe various `g*` instances are enough to promote the `add_comm_monoid (A 0)` structure to various\ntypes of multiplicative structure.\n-/\n\n\nsection GradeZero\n\nsection One\n\nvariable [Zero ι] [GradedMonoid.GOne A] [∀ i, AddCommMonoid (A i)]\n\n@[simp]\ntheorem of_zero_one : of _ 0 (1 : A 0) = 1 :=\n  rfl\n#align direct_sum.of_zero_one DirectSum.of_zero_one\n\nend One\n\nsection Mul\n\nvariable [AddZeroClass ι] [∀ i, AddCommMonoid (A i)] [GnonUnitalNonAssocSemiring A]\n\n@[simp]\ntheorem of_zero_smul {i} (a : A 0) (b : A i) : of _ _ (a • b) = of _ _ a * of _ _ b :=\n  (of_eq_of_gradedMonoid_eq (GradedMonoid.mk_zero_smul a b)).trans (of_mul_of _ _).symm\n#align direct_sum.of_zero_smul DirectSum.of_zero_smul\n\n@[simp]\ntheorem of_zero_mul (a b : A 0) : of _ 0 (a * b) = of _ 0 a * of _ 0 b :=\n  of_zero_smul A a b\n#align direct_sum.of_zero_mul DirectSum.of_zero_mul\n\ninstance GradeZero.nonUnitalNonAssocSemiring : NonUnitalNonAssocSemiring (A 0) :=\n  Function.Injective.nonUnitalNonAssocSemiring (of A 0) Dfinsupp.single_injective (of A 0).map_zero\n    (of A 0).map_add (of_zero_mul A) fun x n => Dfinsupp.single_smul n x\n#align direct_sum.grade_zero.non_unital_non_assoc_semiring DirectSum.GradeZero.nonUnitalNonAssocSemiring\n\ninstance GradeZero.smulWithZero (i : ι) : SMulWithZero (A 0) (A i) :=\n  by\n  letI := SMulWithZero.compHom (⨁ i, A i) (of A 0).toZeroHom\n  refine' dfinsupp.single_injective.smul_with_zero (of A i).toZeroHom (of_zero_smul A)\n#align direct_sum.grade_zero.smul_with_zero DirectSum.GradeZero.smulWithZero\n\nend Mul\n\nsection Semiring\n\nvariable [∀ i, AddCommMonoid (A i)] [AddMonoid ι] [Gsemiring A]\n\n@[simp]\ntheorem of_zero_pow (a : A 0) : ∀ n : ℕ, of _ 0 (a ^ n) = of _ 0 a ^ n\n  | 0 => by rw [pow_zero, pow_zero, DirectSum.of_zero_one]\n  | n + 1 => by rw [pow_succ, pow_succ, of_zero_mul, of_zero_pow]\n#align direct_sum.of_zero_pow DirectSum.of_zero_pow\n\ninstance : NatCast (A 0) :=\n  ⟨Gsemiring.natCast⟩\n\n@[simp]\ntheorem of_nat_cast (n : ℕ) : of A 0 n = n :=\n  rfl\n#align direct_sum.of_nat_cast DirectSum.of_nat_cast\n\n/-- The `semiring` structure derived from `gsemiring A`. -/\ninstance GradeZero.semiring : Semiring (A 0) :=\n  Function.Injective.semiring (of A 0) Dfinsupp.single_injective (of A 0).map_zero (of_zero_one A)\n    (of A 0).map_add (of_zero_mul A) (of A 0).map_nsmul (fun x n => of_zero_pow _ _ _)\n    (of_nat_cast A)\n#align direct_sum.grade_zero.semiring DirectSum.GradeZero.semiring\n\n/-- `of A 0` is a `ring_hom`, using the `direct_sum.grade_zero.semiring` structure. -/\ndef ofZeroRingHom : A 0 →+* ⨁ i, A i :=\n  { of _ 0 with\n    map_one' := of_zero_one A\n    map_mul' := of_zero_mul A }\n#align direct_sum.of_zero_ring_hom DirectSum.ofZeroRingHom\n\n/-- Each grade `A i` derives a `A 0`-module structure from `gsemiring A`. Note that this results\nin an overall `module (A 0) (⨁ i, A i)` structure via `direct_sum.module`.\n-/\ninstance GradeZero.module {i} : Module (A 0) (A i) :=\n  letI := Module.compHom (⨁ i, A i) (of_zero_ring_hom A)\n  dfinsupp.single_injective.module (A 0) (of A i) fun a => of_zero_smul A a\n#align direct_sum.grade_zero.module DirectSum.GradeZero.module\n\nend Semiring\n\nsection CommSemiring\n\nvariable [∀ i, AddCommMonoid (A i)] [AddCommMonoid ι] [GcommSemiring A]\n\n/-- The `comm_semiring` structure derived from `gcomm_semiring A`. -/\ninstance GradeZero.commSemiring : CommSemiring (A 0) :=\n  Function.Injective.commSemiring (of A 0) Dfinsupp.single_injective (of A 0).map_zero\n    (of_zero_one A) (of A 0).map_add (of_zero_mul A) (fun x n => Dfinsupp.single_smul n x)\n    (fun x n => of_zero_pow _ _ _) (of_nat_cast A)\n#align direct_sum.grade_zero.comm_semiring DirectSum.GradeZero.commSemiring\n\nend CommSemiring\n\nsection Ring\n\nvariable [∀ i, AddCommGroup (A i)] [AddZeroClass ι] [GnonUnitalNonAssocSemiring A]\n\n/-- The `non_unital_non_assoc_ring` derived from `gnon_unital_non_assoc_semiring A`. -/\ninstance GradeZero.nonUnitalNonAssocRing : NonUnitalNonAssocRing (A 0) :=\n  Function.Injective.nonUnitalNonAssocRing (of A 0) Dfinsupp.single_injective (of A 0).map_zero\n    (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub\n    (fun x n =>\n      letI : ∀ i, DistribMulAction ℕ (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    fun x n =>\n    letI : ∀ i, DistribMulAction ℤ (A i) := fun i => inferInstance\n    Dfinsupp.single_smul n x\n#align direct_sum.grade_zero.non_unital_non_assoc_ring DirectSum.GradeZero.nonUnitalNonAssocRing\n\nend Ring\n\nsection Ring\n\nvariable [∀ i, AddCommGroup (A i)] [AddMonoid ι] [Gring A]\n\ninstance : IntCast (A 0) :=\n  ⟨Gring.intCast⟩\n\n@[simp]\ntheorem of_int_cast (n : ℤ) : of A 0 n = n :=\n  rfl\n#align direct_sum.of_int_cast DirectSum.of_int_cast\n\n/-- The `ring` derived from `gsemiring A`. -/\ninstance GradeZero.ring : Ring (A 0) :=\n  Function.Injective.ring (of A 0) Dfinsupp.single_injective (of A 0).map_zero (of_zero_one A)\n    (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub\n    (fun x n =>\n      letI : ∀ i, DistribMulAction ℕ (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    (fun x n =>\n      letI : ∀ i, DistribMulAction ℤ (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    (fun x n => of_zero_pow _ _ _) (of_nat_cast A) (of_int_cast A)\n#align direct_sum.grade_zero.ring DirectSum.GradeZero.ring\n\nend Ring\n\nsection CommRing\n\nvariable [∀ i, AddCommGroup (A i)] [AddCommMonoid ι] [GcommRing A]\n\n/-- The `comm_ring` derived from `gcomm_semiring A`. -/\ninstance GradeZero.commRing : CommRing (A 0) :=\n  Function.Injective.commRing (of A 0) Dfinsupp.single_injective (of A 0).map_zero (of_zero_one A)\n    (of A 0).map_add (of_zero_mul A) (of A 0).map_neg (of A 0).map_sub\n    (fun x n =>\n      letI : ∀ i, DistribMulAction ℕ (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    (fun x n =>\n      letI : ∀ i, DistribMulAction ℤ (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    (fun x n => of_zero_pow _ _ _) (of_nat_cast A) (of_int_cast A)\n#align direct_sum.grade_zero.comm_ring DirectSum.GradeZero.commRing\n\nend CommRing\n\nend GradeZero\n\nsection ToSemiring\n\nvariable {R : Type _} [∀ i, AddCommMonoid (A i)] [AddMonoid ι] [Gsemiring A] [Semiring R]\n\nvariable {A}\n\n/-- If two ring homomorphisms from `⨁ i, A i` are equal on each `of A i y`,\nthen they are equal.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext]\ntheorem ringHom_ext' ⦃F G : (⨁ i, A i) →+* R⦄\n    (h : ∀ i, (↑F : _ →+ R).comp (of A i) = (↑G : _ →+ R).comp (of A i)) : F = G :=\n  RingHom.coe_addMonoidHom_injective <| DirectSum.addHom_ext' h\n#align direct_sum.ring_hom_ext' DirectSum.ringHom_ext'\n\n/-- Two `ring_hom`s out of a direct sum are equal if they agree on the generators. -/\ntheorem ringHom_ext ⦃f g : (⨁ i, A i) →+* R⦄ (h : ∀ i x, f (of A i x) = g (of A i x)) : f = g :=\n  ringHom_ext' fun i => AddMonoidHom.ext <| h i\n#align direct_sum.ring_hom_ext DirectSum.ringHom_ext\n\n/-- A family of `add_monoid_hom`s preserving `direct_sum.ghas_one.one` and `direct_sum.ghas_mul.mul`\ndescribes a `ring_hom`s on `⨁ i, A i`. This is a stronger version of `direct_sum.to_monoid`.\n\nOf particular interest is the case when `A i` are bundled subojects, `f` is the family of\ncoercions such as `add_submonoid.subtype (A i)`, and the `[gsemiring A]` structure originates from\n`direct_sum.gsemiring.of_add_submonoids`, in which case the proofs about `ghas_one` and `ghas_mul`\ncan be discharged by `rfl`. -/\n@[simps]\ndef toSemiring (f : ∀ i, A i →+ R) (hone : f _ GradedMonoid.GOne.one = 1)\n    (hmul : ∀ {i j} (ai : A i) (aj : A j), f _ (GradedMonoid.GMul.mul ai aj) = f _ ai * f _ aj) :\n    (⨁ i, A i) →+* R :=\n  { toAddMonoid f with\n    toFun := toAddMonoid f\n    map_one' := by\n      change (to_add_monoid f) (of _ 0 _) = 1\n      rw [to_add_monoid_of]\n      exact hone\n    map_mul' := by\n      rw [(to_add_monoid f).map_mul_iff]\n      ext (xi xv yi yv) : 4\n      show\n        to_add_monoid f (of A xi xv * of A yi yv) =\n          to_add_monoid f (of A xi xv) * to_add_monoid f (of A yi yv)\n      rw [of_mul_of, to_add_monoid_of, to_add_monoid_of, to_add_monoid_of]\n      exact hmul _ _ }\n#align direct_sum.to_semiring DirectSum.toSemiring\n\n@[simp]\ntheorem toSemiring_of (f : ∀ i, A i →+ R) (hone hmul) (i : ι) (x : A i) :\n    toSemiring f hone hmul (of _ i x) = f _ x :=\n  toAddMonoid_of f i x\n#align direct_sum.to_semiring_of DirectSum.toSemiring_of\n\n@[simp]\ntheorem toSemiring_coe_addMonoidHom (f : ∀ i, A i →+ R) (hone hmul) :\n    (toSemiring f hone hmul : (⨁ i, A i) →+ R) = toAddMonoid f :=\n  rfl\n#align direct_sum.to_semiring_coe_add_monoid_hom DirectSum.toSemiring_coe_addMonoidHom\n\n/-- Families of `add_monoid_hom`s preserving `direct_sum.ghas_one.one` and `direct_sum.ghas_mul.mul`\nare isomorphic to `ring_hom`s on `⨁ i, A i`. This is a stronger version of `dfinsupp.lift_add_hom`.\n-/\n@[simps]\ndef liftRingHom :\n    { f : ∀ {i}, A i →+ R //\n        f GradedMonoid.GOne.one = 1 ∧\n          ∀ {i j} (ai : A i) (aj : A j), f (GradedMonoid.GMul.mul ai aj) = f ai * f aj } ≃\n      ((⨁ i, A i) →+* R)\n    where\n  toFun f := toSemiring (fun _ => f.1) f.2.1 fun _ _ => f.2.2\n  invFun F :=\n    ⟨fun i => (F : (⨁ i, A i) →+ R).comp (of _ i),\n      by\n      simp only [AddMonoidHom.comp_apply, [anonymous]]\n      rw [← F.map_one]\n      rfl, fun i j ai aj =>\n      by\n      simp only [AddMonoidHom.comp_apply, [anonymous]]\n      rw [← F.map_mul, of_mul_of]⟩\n  left_inv f := by\n    ext (xi xv)\n    exact to_add_monoid_of (fun _ => f.1) xi xv\n  right_inv F := by\n    apply RingHom.coe_addMonoidHom_injective\n    ext (xi xv)\n    simp only [RingHom.coe_addMonoidHom_mk, DirectSum.toAddMonoid_of, AddMonoidHom.mk_coe,\n      AddMonoidHom.comp_apply, to_semiring_coe_add_monoid_hom]\n#align direct_sum.lift_ring_hom DirectSum.liftRingHom\n\nend ToSemiring\n\nend DirectSum\n\n/-! ### Concrete instances -/\n\n\nsection Uniform\n\nvariable (ι)\n\n/-- A direct sum of copies of a `semiring` inherits the multiplication structure. -/\ninstance NonUnitalNonAssocSemiring.directSumGnonUnitalNonAssocSemiring {R : Type _} [AddMonoid ι]\n    [NonUnitalNonAssocSemiring R] : DirectSum.GnonUnitalNonAssocSemiring fun i : ι => R :=\n  { Mul.gMul ι with\n    mul_zero := fun i j => MulZeroClass.mul_zero\n    zero_mul := fun i j => MulZeroClass.zero_mul\n    mul_add := fun i j => mul_add\n    add_mul := fun i j => add_mul }\n#align non_unital_non_assoc_semiring.direct_sum_gnon_unital_non_assoc_semiring NonUnitalNonAssocSemiring.directSumGnonUnitalNonAssocSemiring\n\n/-- A direct sum of copies of a `semiring` inherits the multiplication structure. -/\ninstance Semiring.directSumGsemiring {R : Type _} [AddMonoid ι] [Semiring R] :\n    DirectSum.Gsemiring fun i : ι => R :=\n  { NonUnitalNonAssocSemiring.directSumGnonUnitalNonAssocSemiring ι,\n    Monoid.gMonoid ι with\n    natCast := fun n => n\n    natCast_zero := Nat.cast_zero\n    natCast_succ := Nat.cast_succ }\n#align semiring.direct_sum_gsemiring Semiring.directSumGsemiring\n\nopen DirectSum\n\n-- To check `has_mul.ghas_mul_mul` matches\nexample {R : Type _} [AddMonoid ι] [Semiring R] (i j : ι) (a b : R) :\n    (DirectSum.of _ i a * DirectSum.of _ j b : ⨁ i, R) = DirectSum.of _ (i + j) (a * b) := by\n  rw [DirectSum.of_mul_of, Mul.gMul_mul]\n\n/-- A direct sum of copies of a `comm_semiring` inherits the commutative multiplication structure.\n-/\ninstance CommSemiring.directSumGcommSemiring {R : Type _} [AddCommMonoid ι] [CommSemiring R] :\n    DirectSum.GcommSemiring fun i : ι => R :=\n  { CommMonoid.gCommMonoid ι, Semiring.directSumGsemiring ι with }\n#align comm_semiring.direct_sum_gcomm_semiring CommSemiring.directSumGcommSemiring\n\nend Uniform\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/DirectSum/Ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.48259227290623913}}
{"text": "/-\nCopyright (c) 2023 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module topology.instances.triv_sq_zero_ext\n! leanprover-community/mathlib commit b8d2eaa69d69ce8f03179a5cda774fc0cde984e4\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.TrivSqZeroExt\nimport Mathbin.Topology.Algebra.InfiniteSum.Basic\nimport Mathbin.Topology.Algebra.Module.Basic\n\n/-!\n# Topology on `triv_sq_zero_ext R M`\n\nThe type `triv_sq_zero_ext R M` inherits the topology from `R × M`.\n\nNote that this is not the topology induced by the seminorm on the dual numbers suggested by\n[this Math.SE answer](https://math.stackexchange.com/a/1056378/1896), which instead induces\nthe topology pulled back through the projection map `triv_sq_zero_ext.fst : tsze R M → R`.\nObviously, that topology is not Hausdorff and using it would result in `exp` converging to more than\none value.\n\n## Main results\n\n* `triv_sq_zero_ext.topological_ring`: the ring operations are continuous\n\n-/\n\n\nvariable {α S R M : Type _}\n\n-- mathport name: exprtsze\nlocal notation \"tsze\" => TrivSqZeroExt\n\nnamespace TrivSqZeroExt\n\nvariable [TopologicalSpace R] [TopologicalSpace M]\n\ninstance : TopologicalSpace (tsze R M) :=\n  TopologicalSpace.induced fst ‹_› ⊓ TopologicalSpace.induced snd ‹_›\n\ninstance [T2Space R] [T2Space M] : T2Space (tsze R M) :=\n  Prod.t2Space\n\ntheorem nhds_def (x : tsze R M) : nhds x = (nhds x.fst).Prod (nhds x.snd) := by\n  cases x <;> exact nhds_prod_eq\n#align triv_sq_zero_ext.nhds_def TrivSqZeroExt.nhds_def\n\ntheorem nhds_inl [Zero M] (x : R) : nhds (inl x : tsze R M) = (nhds x).Prod (nhds 0) :=\n  nhds_def _\n#align triv_sq_zero_ext.nhds_inl TrivSqZeroExt.nhds_inl\n\ntheorem nhds_inr [Zero R] (m : M) : nhds (inr m : tsze R M) = (nhds 0).Prod (nhds m) :=\n  nhds_def _\n#align triv_sq_zero_ext.nhds_inr TrivSqZeroExt.nhds_inr\n\ntheorem continuous_fst : Continuous (fst : tsze R M → R) :=\n  continuous_fst\n#align triv_sq_zero_ext.continuous_fst TrivSqZeroExt.continuous_fst\n\ntheorem continuous_snd : Continuous (snd : tsze R M → M) :=\n  continuous_snd\n#align triv_sq_zero_ext.continuous_snd TrivSqZeroExt.continuous_snd\n\ntheorem continuous_inl [Zero M] : Continuous (inl : R → tsze R M) :=\n  continuous_id.prod_mk continuous_const\n#align triv_sq_zero_ext.continuous_inl TrivSqZeroExt.continuous_inl\n\ntheorem continuous_inr [Zero R] : Continuous (inr : M → tsze R M) :=\n  continuous_const.prod_mk continuous_id\n#align triv_sq_zero_ext.continuous_inr TrivSqZeroExt.continuous_inr\n\ntheorem embedding_inl [Zero M] : Embedding (inl : R → tsze R M) :=\n  embedding_of_embedding_compose continuous_inl continuous_fst embedding_id\n#align triv_sq_zero_ext.embedding_inl TrivSqZeroExt.embedding_inl\n\ntheorem embedding_inr [Zero R] : Embedding (inr : M → tsze R M) :=\n  embedding_of_embedding_compose continuous_inr continuous_snd embedding_id\n#align triv_sq_zero_ext.embedding_inr TrivSqZeroExt.embedding_inr\n\nvariable (R M)\n\n/-- `triv_sq_zero_ext.fst` as a continuous linear map. -/\n@[simps]\ndef fstClm [CommSemiring R] [AddCommMonoid M] [Module R M] : tsze R M →L[R] R :=\n  { ContinuousLinearMap.fst R R M with toFun := fst }\n#align triv_sq_zero_ext.fst_clm TrivSqZeroExt.fstClm\n\n/-- `triv_sq_zero_ext.snd` as a continuous linear map. -/\n@[simps]\ndef sndClm [CommSemiring R] [AddCommMonoid M] [Module R M] : tsze R M →L[R] M :=\n  { ContinuousLinearMap.snd R R M with\n    toFun := snd\n    cont := continuous_snd }\n#align triv_sq_zero_ext.snd_clm TrivSqZeroExt.sndClm\n\n/-- `triv_sq_zero_ext.inl` as a continuous linear map. -/\n@[simps]\ndef inlClm [CommSemiring R] [AddCommMonoid M] [Module R M] : R →L[R] tsze R M :=\n  { ContinuousLinearMap.inl R R M with toFun := inl }\n#align triv_sq_zero_ext.inl_clm TrivSqZeroExt.inlClm\n\n/-- `triv_sq_zero_ext.inr` as a continuous linear map. -/\n@[simps]\ndef inrClm [CommSemiring R] [AddCommMonoid M] [Module R M] : M →L[R] tsze R M :=\n  { ContinuousLinearMap.inr R R M with toFun := inr }\n#align triv_sq_zero_ext.inr_clm TrivSqZeroExt.inrClm\n\nvariable {R M}\n\ninstance [Add R] [Add M] [ContinuousAdd R] [ContinuousAdd M] : ContinuousAdd (tsze R M) :=\n  Prod.has_continuous_add\n\ninstance [Mul R] [Add M] [SMul R M] [SMul Rᵐᵒᵖ M] [ContinuousMul R] [ContinuousSMul R M]\n    [ContinuousSMul Rᵐᵒᵖ M] [ContinuousAdd M] : ContinuousMul (tsze R M) :=\n  ⟨((continuous_fst.comp continuous_fst).mul (continuous_fst.comp continuous_snd)).prod_mk <|\n      ((continuous_fst.comp continuous_fst).smul (continuous_snd.comp continuous_snd)).add\n        ((MulOpposite.continuous_op.comp <| continuous_fst.comp <| continuous_snd).smul\n          (continuous_snd.comp continuous_fst))⟩\n\ninstance [Neg R] [Neg M] [ContinuousNeg R] [ContinuousNeg M] : ContinuousNeg (tsze R M) :=\n  Prod.has_continuous_neg\n\n/-- This is not an instance due to complaints by the `fails_quickly` linter. At any rate, we only\nreally care about the `topological_ring` instance below. -/\ntheorem topologicalSemiring [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M]\n    [TopologicalSemiring R] [ContinuousAdd M] [ContinuousSMul R M]\n    [ContinuousSMul Rᵐᵒᵖ\n        M] :-- note: lean times out looking for the non_assoc_semiring instance without this hint\n      @TopologicalSemiring\n      (tsze R M) _ (NonAssocSemiring.toNonUnitalNonAssocSemiring _) :=\n  { }\n#align triv_sq_zero_ext.topological_semiring TrivSqZeroExt.topologicalSemiring\n\ninstance [Ring R] [AddCommGroup M] [Module R M] [Module Rᵐᵒᵖ M] [TopologicalRing R]\n    [TopologicalAddGroup M] [ContinuousSMul R M] [ContinuousSMul Rᵐᵒᵖ M] :\n    TopologicalRing (tsze R M) where\n\ninstance [SMul S R] [SMul S M] [ContinuousConstSMul S R] [ContinuousConstSMul S M] :\n    ContinuousConstSMul S (tsze R M) :=\n  Prod.continuousConstSMul\n\ninstance [TopologicalSpace S] [SMul S R] [SMul S M] [ContinuousSMul S R] [ContinuousSMul S M] :\n    ContinuousSMul S (tsze R M) :=\n  Prod.continuousSMul\n\nvariable (M)\n\ntheorem hasSum_inl [AddCommMonoid R] [AddCommMonoid M] {f : α → R} {a : R} (h : HasSum f a) :\n    HasSum (fun x => inl (f x)) (inl a : tsze R M) :=\n  h.map (⟨inl, inl_zero _, inl_add _⟩ : R →+ tsze R M) continuous_inl\n#align triv_sq_zero_ext.has_sum_inl TrivSqZeroExt.hasSum_inl\n\ntheorem hasSum_inr [AddCommMonoid R] [AddCommMonoid M] {f : α → M} {a : M} (h : HasSum f a) :\n    HasSum (fun x => inr (f x)) (inr a : tsze R M) :=\n  h.map (⟨inr, inr_zero _, inr_add _⟩ : M →+ tsze R M) continuous_inr\n#align triv_sq_zero_ext.has_sum_inr TrivSqZeroExt.hasSum_inr\n\ntheorem hasSum_fst [AddCommMonoid R] [AddCommMonoid M] {f : α → tsze R M} {a : tsze R M}\n    (h : HasSum f a) : HasSum (fun x => fst (f x)) (fst a) :=\n  h.map (⟨fst, fst_zero, fst_add⟩ : tsze R M →+ R) continuous_fst\n#align triv_sq_zero_ext.has_sum_fst TrivSqZeroExt.hasSum_fst\n\ntheorem hasSum_snd [AddCommMonoid R] [AddCommMonoid M] {f : α → tsze R M} {a : tsze R M}\n    (h : HasSum f a) : HasSum (fun x => snd (f x)) (snd a) :=\n  h.map (⟨snd, snd_zero, snd_add⟩ : tsze R M →+ M) continuous_snd\n#align triv_sq_zero_ext.has_sum_snd TrivSqZeroExt.hasSum_snd\n\nend TrivSqZeroExt\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Instances/TrivSqZeroExt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.48259227150845496}}
{"text": "-- Copyright 2022-2023 VMware, Inc.\n-- SPDX-License-Identifier: BSD-2-Clause\n\nimport .linear\n\nvariables {a: Type} [ordered_add_comm_group a].\n\ndef positive (s: stream a) := 0 <= s.\ndef stream_monotone (s: stream a) := ∀ t, s t ≤ s (t+1).\ndef is_positive {b: Type} [ordered_add_comm_group b]\n  (f: stream a → stream b) := ∀ s, positive s → positive (f s).\n\n-- TODO: could not get library monotone definition to work, possibly due to\n-- partial_order.to_preorder?\n\n-- set_option pp.notation false.\n-- set_option pp.implicit true.\n\n-- prove that [stream_monotone] can be rephrased in terms of order preservation\ntheorem stream_monotone_order (s: stream a) :\n  stream_monotone s ↔ (∀ t1 t2, t1 ≤ t2 → s t1 ≤ s t2) :=\nbegin\n  unfold stream_monotone, split; intro h; introv,\n  { intros hle, have heq : t2 = t1 + (t2 - t1) := by omega,\n    rw heq at *,\n    generalize : (t2 - t1) = d,\n    clear_dependent t2,\n    induction d,\n    { simp, },\n    { transitivity s (t1 + d_n), assumption,\n      apply h, }\n   },\n  { apply h, linarith, },\nend\n\nlemma integral_monotone (s: stream a) :\n  positive s → stream_monotone (I s) :=\nbegin\n  intros hp,\n  intros t,\n  repeat { rw integral_sum_vals },\n  repeat { simp [sum_vals] },\n  have h := hp (t + 1), simp at h,\n  assumption,\nend\n\nlemma derivative_pos (s: stream a) :\n  -- NOTE: paper is missing this, but it is also necessary (maybe they\n  -- intend `s[-1] =0` in the definition of monotone)\n  0 ≤ s 0 →\n  stream_monotone s → positive (D s) :=\nbegin\n  intros h0 hp, intros t; simp,\n  unfold D delay; simp,\n  split_ifs,\n  { subst t, assumption },\n  { have hle := hp (t - 1),\n    have heq : t - 1 + 1 = t := by omega, rw heq at hle,\n    assumption,\n   },\nend\n\nlemma derivative_pos_counter_example :\n  (∃ (x:a), x < 0) →\n  ¬(∀ (s: stream a), stream_monotone s → positive (D s)) :=\nbegin\n  intros h, cases h with x hneg,\n  simp,\n  -- pushing the negation through, we're going to prove\n  -- ∃ (x : stream a), stream_monotone x ∧ ¬positive (D x)\n  use (λ _n, x),\n  split,\n  { intros t, simp, },\n  { unfold positive,\n    rw stream_le_ext, simp,\n    use 0, simp [D],\n    apply not_le_of_gt, assumption,\n   },\nend\n", "meta": {"author": "tchajed", "repo": "database-stream-processing-theory", "sha": "c4c3b7ced9f964f3ea17db77958df78f2d761509", "save_path": "github-repos/lean/tchajed-database-stream-processing-theory", "path": "github-repos/lean/tchajed-database-stream-processing-theory/database-stream-processing-theory-c4c3b7ced9f964f3ea17db77958df78f2d761509/src/ordering.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.48259226758152024}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport algebraic_geometry.sheafed_space\nimport algebra.category.CommRing.limits\nimport algebra.category.CommRing.colimits\nimport algebraic_geometry.stalks\nimport ring_theory.ideal.basic\n\n/-!\n# The category of locally ringed spaces\n\nWe define (bundled) locally ringed spaces (as `SheafedSpace CommRing` along with the fact that the\nstalks are local rings), and morphisms between these (morphisms in `SheafedSpace` with\n`is_local_ring_hom` on the stalk maps).\n\n## Future work\n* Define the restriction along an open embedding\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.category category_theory.functor\n\nnamespace algebraic_geometry\n\n/-- A `LocallyRingedSpace` is a topological space equipped with a sheaf of commutative rings\nsuch that all the stalks are local rings.\n\nA morphism of locally ringed spaces is a morphism of ringed spaces\nsuch that the morphims induced on stalks are local ring homomorphisms. -/\n@[nolint has_inhabited_instance]\nstructure LocallyRingedSpace extends SheafedSpace CommRing :=\n(local_ring : ∀ x, local_ring (presheaf.stalk x))\n\nattribute [instance] LocallyRingedSpace.local_ring\n\nnamespace LocallyRingedSpace\n\nvariables (X : LocallyRingedSpace)\n\n/-- The underlying topological space of a locally ringed space. -/\ndef to_Top : Top := X.1.carrier\n\ninstance : has_coe_to_sort LocallyRingedSpace :=\n{ S := Type u,\n  coe := λ X : LocallyRingedSpace, (X.to_Top : Type u), }\n\n-- PROJECT: how about a typeclass \"has_structure_sheaf\" to mediate the 𝒪 notation, rather\n-- than defining it over and over for PresheafedSpace, LRS, Scheme, etc.\n\n/-- The structure sheaf of a locally ringed space. -/\ndef 𝒪 : sheaf CommRing X.to_Top := X.to_SheafedSpace.sheaf\n\n/-- A morphism of locally ringed spaces is a morphism of ringed spaces\n such that the morphims induced on stalks are local ring homomorphisms. -/\ndef hom (X Y : LocallyRingedSpace) : Type* :=\n{ f : X.to_SheafedSpace ⟶ Y.to_SheafedSpace //\n    ∀ x, is_local_ring_hom (PresheafedSpace.stalk_map f x) }\n\ninstance : quiver LocallyRingedSpace := ⟨hom⟩\n\n@[ext] lemma hom_ext {X Y : LocallyRingedSpace} (f g : hom X Y) (w : f.1 = g.1) : f = g :=\nsubtype.eq w\n\n/--\nThe stalk of a locally ringed space, just as a `CommRing`.\n-/\n-- TODO perhaps we should make a bundled `LocalRing` and return one here?\n-- TODO define `sheaf.stalk` so we can write `X.𝒪.stalk` here?\nnoncomputable\ndef stalk (X : LocallyRingedSpace) (x : X) : CommRing := X.presheaf.stalk x\n\n/--\nA morphism of locally ringed spaces `f : X ⟶ Y` induces\na local ring homomorphism from `Y.stalk (f x)` to `X.stalk x` for any `x : X`.\n-/\nnoncomputable\ndef stalk_map {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n  Y.stalk (f.1.1 x) ⟶ X.stalk x :=\nPresheafedSpace.stalk_map f.1 x\n\ninstance {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n  is_local_ring_hom (stalk_map f x) := f.2 x\n\n/-- The identity morphism on a locally ringed space. -/\n@[simps]\ndef id (X : LocallyRingedSpace) : hom X X :=\n⟨𝟙 _, λ x, by { erw PresheafedSpace.stalk_map.id, apply is_local_ring_hom_id, }⟩\n\ninstance (X : LocallyRingedSpace) : inhabited (hom X X) := ⟨id X⟩\n\n/-- Composition of morphisms of locally ringed spaces. -/\n@[simps]\ndef comp {X Y Z : LocallyRingedSpace} (f : hom X Y) (g : hom Y Z) : hom X Z :=\n⟨f.val ≫ g.val, λ x,\nbegin\n  erw PresheafedSpace.stalk_map.comp,\n  exact @is_local_ring_hom_comp _ _ _ _ _ _ _ _ (f.2 _) (g.2 _),\nend⟩\n\n/-- The category of locally ringed spaces. -/\ninstance : category LocallyRingedSpace :=\n{ hom := hom,\n  id := id,\n  comp := λ X Y Z f g, comp f g,\n  comp_id' := by { intros, ext1, simp, },\n  id_comp' := by { intros, ext1, simp, },\n  assoc' := by { intros, ext1, simp, }, }.\n\n/-- The forgetful functor from `LocallyRingedSpace` to `SheafedSpace CommRing`. -/\ndef forget_to_SheafedSpace : LocallyRingedSpace ⥤ SheafedSpace CommRing :=\n{ obj := λ X, X.to_SheafedSpace,\n  map := λ X Y f, f.1, }\n\ninstance : faithful forget_to_SheafedSpace := {}\n\n-- PROJECT: once we have `PresheafedSpace.restrict_stalk_iso`\n-- (that restriction doesn't change stalks) we can uncomment this.\n/-\ndef restrict {U : Top} (X : LocallyRingedSpace)\n  (f : U ⟶ X.to_Top) (h : open_embedding f) : LocallyRingedSpace :=\n{ local_ring :=\n  begin\n    intro x,\n    dsimp at *,\n    -- We show that the stalk of the restriction is isomorphic to the original stalk,\n    have := X.to_SheafedSpace.to_PresheafedSpace.restrict_stalk_iso f h x,\n    -- and then transfer `local_ring` across the ring equivalence.\n    apply (this.CommRing_iso_to_ring_equiv).local_ring, -- import data.equiv.transfer_instance\n    apply X.local_ring,\n  end,\n  .. X.to_SheafedSpace.restrict _ f h }\n-/\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : LocallyRingedSpaceᵒᵖ ⥤ CommRing :=\nforget_to_SheafedSpace.op ⋙ SheafedSpace.Γ\n\nlemma Γ_def : Γ = forget_to_SheafedSpace.op ⋙ SheafedSpace.Γ := rfl\n\n@[simp] lemma Γ_obj (X : LocallyRingedSpaceᵒᵖ) : Γ.obj X = (unop X).presheaf.obj (op ⊤) := rfl\n\nlemma Γ_obj_op (X : LocallyRingedSpace) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\n@[simp] lemma Γ_map {X Y : LocallyRingedSpaceᵒᵖ} (f : X ⟶ Y) :\n  Γ.map f = f.unop.1.c.app (op ⊤) ≫ (unop Y).presheaf.map (opens.le_map_top _ _).op := rfl\n\nlemma Γ_map_op {X Y : LocallyRingedSpace} (f : X ⟶ Y) :\n  Γ.map f.op = f.1.c.app (op ⊤) ≫ X.presheaf.map (opens.le_map_top _ _).op := rfl\n\nend LocallyRingedSpace\n\nend algebraic_geometry\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebraic_geometry/locally_ringed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.48258079265267245}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Justus Springer\n-/\nimport algebraic_geometry.locally_ringed_space\nimport algebraic_geometry.structure_sheaf\nimport logic.equiv.transfer_instance\nimport ring_theory.localization.localization_localization\nimport topology.sheaves.sheaf_condition.sites\nimport topology.sheaves.functors\nimport algebra.module.localized_module\n\n/-!\n# $Spec$ as a functor to locally ringed spaces.\n\nWe define the functor $Spec$ from commutative rings to locally ringed spaces.\n\n## Implementation notes\n\nWe define $Spec$ in three consecutive steps, each with more structure than the last:\n\n1. `Spec.to_Top`, valued in the category of topological spaces,\n2. `Spec.to_SheafedSpace`, valued in the category of sheafed spaces and\n3. `Spec.to_LocallyRingedSpace`, valued in the category of locally ringed spaces.\n\nAdditionally, we provide `Spec.to_PresheafedSpace` as a composition of `Spec.to_SheafedSpace` with\na forgetful functor.\n\n## Related results\n\nThe adjunction `Γ ⊣ Spec` is constructed in `algebraic_geometry/Gamma_Spec_adjunction.lean`.\n\n-/\n\nnoncomputable theory\nuniverses u v\n\nnamespace algebraic_geometry\nopen opposite\nopen category_theory\nopen structure_sheaf Spec (structure_sheaf)\n\n/--\nThe spectrum of a commutative ring, as a topological space.\n-/\ndef Spec.Top_obj (R : CommRing) : Top := Top.of (prime_spectrum R)\n\n/--\nThe induced map of a ring homomorphism on the ring spectra, as a morphism of topological spaces.\n-/\ndef Spec.Top_map {R S : CommRing} (f : R ⟶ S) :\n  Spec.Top_obj S ⟶ Spec.Top_obj R :=\nprime_spectrum.comap f\n\n@[simp] lemma Spec.Top_map_id (R : CommRing) :\n  Spec.Top_map (𝟙 R) = 𝟙 (Spec.Top_obj R) :=\nprime_spectrum.comap_id\n\nlemma Spec.Top_map_comp {R S T : CommRing} (f : R ⟶ S) (g : S ⟶ T) :\n  Spec.Top_map (f ≫ g) = Spec.Top_map g ≫ Spec.Top_map f :=\nprime_spectrum.comap_comp _ _\n\n/--\nThe spectrum, as a contravariant functor from commutative rings to topological spaces.\n-/\n@[simps] def Spec.to_Top : CommRingᵒᵖ ⥤ Top :=\n{ obj := λ R, Spec.Top_obj (unop R),\n  map := λ R S f, Spec.Top_map f.unop,\n  map_id' := λ R, by rw [unop_id, Spec.Top_map_id],\n  map_comp' := λ R S T f g, by rw [unop_comp, Spec.Top_map_comp] }\n\n/--\nThe spectrum of a commutative ring, as a `SheafedSpace`.\n-/\n@[simps] def Spec.SheafedSpace_obj (R : CommRing) : SheafedSpace CommRing :=\n{ carrier := Spec.Top_obj R,\n  presheaf := (structure_sheaf R).1,\n  is_sheaf := (structure_sheaf R).2 }\n\n/--\nThe induced map of a ring homomorphism on the ring spectra, as a morphism of sheafed spaces.\n-/\n@[simps] def Spec.SheafedSpace_map {R S : CommRing.{u}} (f : R ⟶ S) :\n  Spec.SheafedSpace_obj S ⟶ Spec.SheafedSpace_obj R :=\n{ base := Spec.Top_map f,\n  c :=\n  { app := λ U, comap f (unop U) ((topological_space.opens.map (Spec.Top_map f)).obj (unop U))\n      (λ p, id),\n    naturality' := λ U V i, ring_hom.ext $ λ s, subtype.eq $ funext $ λ p, rfl } }\n\n@[simp] lemma Spec.SheafedSpace_map_id {R : CommRing} :\n  Spec.SheafedSpace_map (𝟙 R) = 𝟙 (Spec.SheafedSpace_obj R) :=\nPresheafedSpace.ext _ _ (Spec.Top_map_id R) $ nat_trans.ext _ _ $ funext $ λ U,\nbegin\n  dsimp,\n  erw [PresheafedSpace.id_c_app, comap_id], swap,\n  { rw [Spec.Top_map_id, topological_space.opens.map_id_obj_unop] },\n  simpa [eq_to_hom_map],\nend\n\nlemma Spec.SheafedSpace_map_comp {R S T : CommRing} (f : R ⟶ S) (g : S ⟶ T) :\n  Spec.SheafedSpace_map (f ≫ g) = Spec.SheafedSpace_map g ≫ Spec.SheafedSpace_map f :=\nPresheafedSpace.ext _ _ (Spec.Top_map_comp f g) $ nat_trans.ext _ _ $ funext $ λ U,\nby { dsimp, rw category_theory.functor.map_id, rw category.comp_id, erw comap_comp f g, refl }\n\n/--\nSpec, as a contravariant functor from commutative rings to sheafed spaces.\n-/\n@[simps] def Spec.to_SheafedSpace : CommRingᵒᵖ ⥤ SheafedSpace CommRing :=\n{ obj := λ R, Spec.SheafedSpace_obj (unop R),\n  map := λ R S f, Spec.SheafedSpace_map f.unop,\n  map_id' := λ R, by rw [unop_id, Spec.SheafedSpace_map_id],\n  map_comp' := λ R S T f g, by rw [unop_comp, Spec.SheafedSpace_map_comp] }\n\n/--\nSpec, as a contravariant functor from commutative rings to presheafed spaces.\n-/\ndef Spec.to_PresheafedSpace : CommRingᵒᵖ ⥤ PresheafedSpace.{u} CommRing.{u} :=\n  Spec.to_SheafedSpace ⋙ SheafedSpace.forget_to_PresheafedSpace\n\n@[simp] lemma Spec.to_PresheafedSpace_obj (R : CommRingᵒᵖ) :\n  Spec.to_PresheafedSpace.obj R = (Spec.SheafedSpace_obj (unop R)).to_PresheafedSpace := rfl\n\nlemma Spec.to_PresheafedSpace_obj_op (R : CommRing) :\n  Spec.to_PresheafedSpace.obj (op R) = (Spec.SheafedSpace_obj R).to_PresheafedSpace := rfl\n\n@[simp] lemma Spec.to_PresheafedSpace_map (R S : CommRingᵒᵖ) (f : R ⟶ S) :\n  Spec.to_PresheafedSpace.map f = Spec.SheafedSpace_map f.unop := rfl\n\nlemma Spec.to_PresheafedSpace_map_op (R S : CommRing) (f : R ⟶ S) :\n  Spec.to_PresheafedSpace.map f.op = Spec.SheafedSpace_map f := rfl\n\nlemma Spec.basic_open_hom_ext {X : RingedSpace} {R : CommRing} {α β : X ⟶ Spec.SheafedSpace_obj R}\n  (w : α.base = β.base) (h : ∀ r : R, let U := prime_spectrum.basic_open r in\n    (to_open R U ≫ α.c.app (op U)) ≫ X.presheaf.map (eq_to_hom (by rw w)) =\n     to_open R U ≫ β.c.app (op U)) : α = β :=\nbegin\n  ext1,\n  { apply ((Top.sheaf.pushforward β.base).obj X.sheaf).hom_ext _\n      prime_spectrum.is_basis_basic_opens,\n    intro r,\n    apply (structure_sheaf.to_basic_open_epi R r).1,\n    simpa using h r },\n  exact w,\nend\n\n/--\nThe spectrum of a commutative ring, as a `LocallyRingedSpace`.\n-/\n@[simps] def Spec.LocallyRingedSpace_obj (R : CommRing) : LocallyRingedSpace :=\n{ local_ring := λ x, @@ring_equiv.local_ring _\n    (show local_ring (localization.at_prime _), by apply_instance) _\n    (iso.CommRing_iso_to_ring_equiv $ stalk_iso R x).symm,\n  .. Spec.SheafedSpace_obj R }\n\n@[elementwise]\nlemma stalk_map_to_stalk {R S : CommRing} (f : R ⟶ S) (p : prime_spectrum S) :\n  to_stalk R (prime_spectrum.comap f p) ≫\n  PresheafedSpace.stalk_map (Spec.SheafedSpace_map f) p =\n  f ≫ to_stalk S p :=\nbegin\n  erw [← to_open_germ S ⊤ ⟨p, trivial⟩, ← to_open_germ R ⊤ ⟨prime_spectrum.comap f p, trivial⟩,\n    category.assoc, PresheafedSpace.stalk_map_germ (Spec.SheafedSpace_map f) ⊤ ⟨p, trivial⟩,\n    Spec.SheafedSpace_map_c_app, to_open_comp_comap_assoc],\n  refl\nend\n\n/--\nUnder the isomorphisms `stalk_iso`, the map `stalk_map (Spec.SheafedSpace_map f) p` corresponds\nto the induced local ring homomorphism `localization.local_ring_hom`.\n-/\n@[elementwise]\nlemma local_ring_hom_comp_stalk_iso {R S : CommRing} (f : R ⟶ S) (p : prime_spectrum S) :\n  (stalk_iso R (prime_spectrum.comap f p)).hom ≫\n    @category_struct.comp _ _\n      (CommRing.of (localization.at_prime (prime_spectrum.comap f p).as_ideal))\n      (CommRing.of (localization.at_prime p.as_ideal)) _\n      (localization.local_ring_hom (prime_spectrum.comap f p).as_ideal p.as_ideal f rfl)\n      (stalk_iso S p).inv =\n  PresheafedSpace.stalk_map (Spec.SheafedSpace_map f) p :=\n(stalk_iso R (prime_spectrum.comap f p)).eq_inv_comp.mp $ (stalk_iso S p).comp_inv_eq.mpr $\nlocalization.local_ring_hom_unique _ _ _ _ $ λ x, by\nrw [stalk_iso_hom, stalk_iso_inv, comp_apply, comp_apply, localization_to_stalk_of,\n  stalk_map_to_stalk_apply, stalk_to_fiber_ring_hom_to_stalk]\n\n/--\nThe induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.\n-/\n@[simps] def Spec.LocallyRingedSpace_map {R S : CommRing} (f : R ⟶ S) :\n  Spec.LocallyRingedSpace_obj S ⟶ Spec.LocallyRingedSpace_obj R :=\nLocallyRingedSpace.hom.mk (Spec.SheafedSpace_map f) $ λ p, is_local_ring_hom.mk $ λ a ha,\nbegin\n  -- Here, we are showing that the map on prime spectra induced by `f` is really a morphism of\n  -- *locally* ringed spaces, i.e. that the induced map on the stalks is a local ring homomorphism.\n  rw ← local_ring_hom_comp_stalk_iso_apply at ha,\n  replace ha := (stalk_iso S p).hom.is_unit_map ha,\n  rw iso.inv_hom_id_apply at ha,\n  replace ha := is_local_ring_hom.map_nonunit _ ha,\n  convert ring_hom.is_unit_map (stalk_iso R (prime_spectrum.comap f p)).inv ha,\n  rw iso.hom_inv_id_apply\nend\n\n@[simp] lemma Spec.LocallyRingedSpace_map_id (R : CommRing) :\n  Spec.LocallyRingedSpace_map (𝟙 R) = 𝟙 (Spec.LocallyRingedSpace_obj R) :=\nLocallyRingedSpace.hom.ext _ _ $\n  by { rw [Spec.LocallyRingedSpace_map_val, Spec.SheafedSpace_map_id], refl }\n\nlemma Spec.LocallyRingedSpace_map_comp {R S T : CommRing} (f : R ⟶ S) (g : S ⟶ T) :\n  Spec.LocallyRingedSpace_map (f ≫ g) =\n  Spec.LocallyRingedSpace_map g ≫ Spec.LocallyRingedSpace_map f :=\nLocallyRingedSpace.hom.ext _ _ $\n  by { rw [Spec.LocallyRingedSpace_map_val, Spec.SheafedSpace_map_comp], refl }\n\n/--\nSpec, as a contravariant functor from commutative rings to locally ringed spaces.\n-/\n@[simps] def Spec.to_LocallyRingedSpace : CommRingᵒᵖ ⥤ LocallyRingedSpace :=\n{ obj := λ R, Spec.LocallyRingedSpace_obj (unop R),\n  map := λ R S f, Spec.LocallyRingedSpace_map f.unop,\n  map_id' := λ R, by rw [unop_id, Spec.LocallyRingedSpace_map_id],\n  map_comp' := λ R S T f g, by rw [unop_comp, Spec.LocallyRingedSpace_map_comp] }\n\nsection Spec_Γ\nopen algebraic_geometry.LocallyRingedSpace\n\n/-- The counit morphism `R ⟶ Γ(Spec R)` given by `algebraic_geometry.structure_sheaf.to_open`.  -/\n@[simps {rhs_md := tactic.transparency.semireducible}]\ndef to_Spec_Γ (R : CommRing) : R ⟶ Γ.obj (op (Spec.to_LocallyRingedSpace.obj (op R))) :=\nstructure_sheaf.to_open R ⊤\n\ninstance is_iso_to_Spec_Γ (R : CommRing) : is_iso (to_Spec_Γ R) :=\nby { cases R, apply structure_sheaf.is_iso_to_global }\n\n@[reassoc]\nlemma Spec_Γ_naturality {R S : CommRing} (f : R ⟶ S) :\n  f ≫ to_Spec_Γ S = to_Spec_Γ R ≫ Γ.map (Spec.to_LocallyRingedSpace.map f.op).op :=\nby { ext, symmetry, apply localization.local_ring_hom_to_map }\n\n/-- The counit (`Spec_Γ_identity.inv.op`) of the adjunction `Γ ⊣ Spec` is an isomorphism. -/\n@[simps hom_app inv_app] def Spec_Γ_identity : Spec.to_LocallyRingedSpace.right_op ⋙ Γ ≅ 𝟭 _ :=\niso.symm $ nat_iso.of_components (λ R, as_iso (to_Spec_Γ R) : _) (λ _ _, Spec_Γ_naturality)\n\nend Spec_Γ\n\n/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/\nlemma Spec_map_localization_is_iso (R : CommRing) (M : submonoid R)\n  (x : prime_spectrum (localization M)) :\n  is_iso (PresheafedSpace.stalk_map (Spec.to_PresheafedSpace.map\n    (CommRing.of_hom (algebra_map R (localization M))).op) x) :=\nbegin\n  erw ← local_ring_hom_comp_stalk_iso,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  apply_instance,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  /- I do not know why this is defeq to the goal, but I'm happy to accept that it is. -/\n  exact (show is_iso (is_localization.localization_localization_at_prime_iso_localization\n    M x.as_ideal).to_ring_equiv.to_CommRing_iso.hom, by apply_instance),\n  apply_instance\nend\n\nnamespace structure_sheaf\n\nvariables {R S : CommRing.{u}} (f : R ⟶ S) (p : prime_spectrum R)\n\n/--\nFor an algebra `f : R →+* S`, this is the ring homomorphism `S →+* (f∗ 𝒪ₛ)ₚ` for a `p : Spec R`.\nThis is shown to be the localization at `p` in `is_localized_module_to_pushforward_stalk_alg_hom`.\n-/\ndef to_pushforward_stalk :\n  S ⟶ (Spec.Top_map f _* (structure_sheaf S).1).stalk p :=\nstructure_sheaf.to_open S ⊤ ≫\n  @Top.presheaf.germ _ _ _ _ (Spec.Top_map f _* (structure_sheaf S).1) ⊤ ⟨p, trivial⟩\n\n@[reassoc]\nlemma to_pushforward_stalk_comp :\n  f ≫ structure_sheaf.to_pushforward_stalk f p =\n  structure_sheaf.to_stalk R p ≫\n    (Top.presheaf.stalk_functor _ _).map (Spec.SheafedSpace_map f).c :=\nbegin\n  rw structure_sheaf.to_stalk,\n  erw category.assoc,\n  rw Top.presheaf.stalk_functor_map_germ,\n  exact Spec_Γ_naturality_assoc f _,\nend\n\ninstance : algebra R ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) :=\n(f ≫ structure_sheaf.to_pushforward_stalk f p).to_algebra\n\nlemma algebra_map_pushforward_stalk :\n  algebra_map R ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) =\n    f ≫ structure_sheaf.to_pushforward_stalk f p := rfl\n\nvariables (R S) [algebra R S]\n\n/--\nThis is the `alg_hom` version of `to_pushforward_stalk`, which is the map `S ⟶ (f∗ 𝒪ₛ)ₚ` for some\nalgebra `R ⟶ S` and some `p : Spec R`.\n-/\n@[simps]\ndef to_pushforward_stalk_alg_hom :\n  S →ₐ[R] (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).stalk p :=\n{ commutes' := λ _, rfl, ..(structure_sheaf.to_pushforward_stalk (algebra_map R S) p) }\n\nlemma is_localized_module_to_pushforward_stalk_alg_hom_aux (y) :\n  ∃ (x : S × p.as_ideal.prime_compl), x.2 • y = to_pushforward_stalk_alg_hom R S p x.1 :=\nbegin\n  obtain ⟨U, hp, s, e⟩ := Top.presheaf.germ_exist _ _ y,\n  obtain ⟨_, ⟨r, rfl⟩, hpr : p ∈ prime_spectrum.basic_open r,\n    hrU : prime_spectrum.basic_open r ≤ U⟩ := prime_spectrum.is_topological_basis_basic_opens\n      .exists_subset_of_mem_open (show p ∈ ↑U, from hp) U.2,\n  change prime_spectrum.basic_open r ≤ U at hrU,\n  replace e := ((Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1)\n    .germ_res_apply (hom_of_le hrU) ⟨p, hpr⟩ _).trans e,\n  set s' := (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).map (hom_of_le hrU).op s\n    with h,\n  rw ← h at e,\n  clear_value s', clear_dependent U,\n  obtain ⟨⟨s, ⟨_, n, rfl⟩⟩, hsn⟩ := @is_localization.surj _ _ _\n    _ _ _ (structure_sheaf.is_localization.to_basic_open S $ algebra_map R S r) s',\n  refine ⟨⟨s, ⟨r, hpr⟩ ^ n⟩, _⟩,\n  rw [submonoid.smul_def, algebra.smul_def, algebra_map_pushforward_stalk, to_pushforward_stalk,\n    comp_apply, comp_apply],\n  iterate 2 { erw ← (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).germ_res_apply\n    (hom_of_le le_top) ⟨p, hpr⟩ },\n  rw [← e, ← map_mul, mul_comm],\n  dsimp only [subtype.coe_mk] at hsn,\n  rw ← map_pow (algebra_map R S) at hsn,\n  congr' 1\nend\n\ninstance is_localized_module_to_pushforward_stalk_alg_hom :\n  is_localized_module p.as_ideal.prime_compl (to_pushforward_stalk_alg_hom R S p).to_linear_map :=\nbegin\n  apply is_localized_module.mk_of_algebra,\n  { intros x hx, rw [algebra_map_pushforward_stalk, to_pushforward_stalk_comp, comp_apply],\n    exact (is_localization.map_units ((structure_sheaf R).presheaf.stalk p) ⟨x, hx⟩).map _ },\n  { apply is_localized_module_to_pushforward_stalk_alg_hom_aux },\n  { intros x hx,\n    rw [to_pushforward_stalk_alg_hom_apply, ring_hom.to_fun_eq_coe,\n      ← (to_pushforward_stalk (algebra_map R S) p).map_zero, to_pushforward_stalk, comp_apply,\n      comp_apply, map_zero] at hx,\n    obtain ⟨U, hpU, i₁, i₂, e⟩ := Top.presheaf.germ_eq _ _ _ _ _ _ hx,\n    obtain ⟨_, ⟨r, rfl⟩, hpr, hrU⟩ := prime_spectrum.is_topological_basis_basic_opens\n      .exists_subset_of_mem_open (show p ∈ U.1, from hpU) U.2,\n    change prime_spectrum.basic_open r ≤ U at hrU,\n    apply_fun (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).map (hom_of_le hrU).op at e,\n    simp only [Top.presheaf.pushforward_obj_map, functor.op_map, map_zero, ← comp_apply,\n      to_open_res] at e,\n    have : to_open S (prime_spectrum.basic_open $ algebra_map R S r) x = 0,\n    { refine eq.trans _ e, refl },\n    have := (@is_localization.mk'_one _ _ _\n      _ _ _ (structure_sheaf.is_localization.to_basic_open S $ algebra_map R S r) x).trans this,\n    obtain ⟨⟨_, n, rfl⟩, e⟩ := (is_localization.mk'_eq_zero_iff _ _).mp this,\n    refine ⟨⟨r, hpr⟩ ^ n, _⟩,\n    rw [submonoid.smul_def, algebra.smul_def, submonoid.coe_pow, subtype.coe_mk, map_pow],\n    exact e },\nend\n\nend structure_sheaf\n\nend algebraic_geometry\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_geometry/Spec.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6442251064863695, "lm_q1q2_score": 0.48258078963641315}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.limits.shapes.products\nimport category_theory.limits.preserves.basic\n\n/-!\n# Preserving products\n\nConstructions to relate the notions of preserving products and reflecting products\nto concrete fans.\n\nIn particular, we show that `pi_comparison G f` is an isomorphism iff `G` preserves\nthe limit of `f`.\n-/\n\nnoncomputable theory\n\nuniverses v u₁ u₂\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u₁} [category.{v} C]\nvariables {D : Type u₂} [category.{v} D]\nvariables (G : C ⥤ D)\n\nnamespace category_theory.limits\n\nvariables {J : Type v} (f : J → C)\n\n/--\nThe map of a fan is a limit iff the fan consisting of the mapped morphisms is a limit. This\nessentially lets us commute `fan.mk` with `functor.map_cone`.\n-/\ndef is_limit_map_cone_fan_mk_equiv {P : C} (g : Π j, P ⟶ f j) :\n  is_limit (G.map_cone (fan.mk P g)) ≃\n  is_limit (fan.mk _ (λ j, G.map (g j)) : fan (λ j, G.obj (f j))) :=\nbegin\n  refine (is_limit.postcompose_hom_equiv _ _).symm.trans (is_limit.equiv_iso_limit _),\n  refine discrete.nat_iso (λ j, iso.refl (G.obj (f j.as))),\n  refine cones.ext (iso.refl _) (λ j, by { discrete_cases, dsimp, simp }),\nend\n\n/-- The property of preserving products expressed in terms of fans. -/\ndef is_limit_fan_mk_obj_of_is_limit [preserves_limit (discrete.functor f) G]\n  {P : C} (g : Π j, P ⟶ f j) (t : is_limit (fan.mk _ g)) :\n  is_limit (fan.mk (G.obj P) (λ j, G.map (g j)) : fan (λ j, G.obj (f j))) :=\nis_limit_map_cone_fan_mk_equiv _ _ _ (preserves_limit.preserves t)\n\n/-- The property of reflecting products expressed in terms of fans. -/\ndef is_limit_of_is_limit_fan_mk_obj [reflects_limit (discrete.functor f) G]\n  {P : C} (g : Π j, P ⟶ f j) (t : is_limit (fan.mk _ (λ j, G.map (g j)) : fan (λ j, G.obj (f j)))) :\n  is_limit (fan.mk P g) :=\nreflects_limit.reflects ((is_limit_map_cone_fan_mk_equiv _ _ _).symm t)\n\nsection\n\nvariables [has_product f]\n\n/--\nIf `G` preserves products and `C` has them, then the fan constructed of the mapped projection of a\nproduct is a limit.\n-/\ndef is_limit_of_has_product_of_preserves_limit [preserves_limit (discrete.functor f) G] :\n  is_limit (fan.mk _ (λ (j : J), G.map (pi.π f j)) : fan (λ j, G.obj (f j))) :=\nis_limit_fan_mk_obj_of_is_limit G f _ (product_is_product _)\n\nvariables [has_product (λ (j : J), G.obj (f j))]\n\n/-- If `pi_comparison G f` is an isomorphism, then `G` preserves the limit of `f`. -/\ndef preserves_product.of_iso_comparison [i : is_iso (pi_comparison G f)] :\n  preserves_limit (discrete.functor f) G :=\nbegin\n  apply preserves_limit_of_preserves_limit_cone (product_is_product f),\n  apply (is_limit_map_cone_fan_mk_equiv _ _ _).symm _,\n  apply is_limit.of_point_iso (limit.is_limit (discrete.functor (λ (j : J), G.obj (f j)))),\n  apply i,\nend\n\nvariable [preserves_limit (discrete.functor f) G]\n\n/--\nIf `G` preserves limits, we have an isomorphism from the image of a product to the product of the\nimages.\n-/\ndef preserves_product.iso : G.obj (∏ f) ≅ ∏ (λ j, G.obj (f j)) :=\nis_limit.cone_point_unique_up_to_iso\n  (is_limit_of_has_product_of_preserves_limit G f)\n  (limit.is_limit _)\n\n@[simp]\nlemma preserves_product.iso_hom : (preserves_product.iso G f).hom = pi_comparison G f :=\nrfl\n\ninstance : is_iso (pi_comparison G f) :=\nbegin\n  rw ← preserves_product.iso_hom,\n  apply_instance,\nend\n\nend\n\n/--\nThe map of a cofan is a colimit iff the cofan consisting of the mapped morphisms is a colimit.\nThis essentially lets us commute `cofan.mk` with `functor.map_cocone`.\n-/\ndef is_colimit_map_cocone_cofan_mk_equiv {P : C} (g : Π j, f j ⟶ P) :\n  is_colimit (G.map_cocone (cofan.mk P g)) ≃\n  is_colimit (cofan.mk _ (λ j, G.map (g j)) : cofan (λ j, G.obj (f j))) :=\nbegin\n  refine (is_colimit.precompose_hom_equiv _ _).symm.trans (is_colimit.equiv_iso_colimit _),\n  refine discrete.nat_iso (λ j, iso.refl (G.obj (f j.as))),\n  refine cocones.ext (iso.refl _) (λ j, by { discrete_cases, dsimp, simp }),\nend\n\n/-- The property of preserving coproducts expressed in terms of cofans. -/\ndef is_colimit_cofan_mk_obj_of_is_colimit [preserves_colimit (discrete.functor f) G]\n  {P : C} (g : Π j, f j ⟶ P) (t : is_colimit (cofan.mk _ g)) :\n  is_colimit (cofan.mk (G.obj P) (λ j, G.map (g j)) : cofan (λ j, G.obj (f j))) :=\nis_colimit_map_cocone_cofan_mk_equiv _ _ _ (preserves_colimit.preserves t)\n\n/-- The property of reflecting coproducts expressed in terms of cofans. -/\ndef is_colimit_of_is_colimit_cofan_mk_obj [reflects_colimit (discrete.functor f) G]\n  {P : C} (g : Π j, f j ⟶ P)\n  (t : is_colimit (cofan.mk _ (λ j, G.map (g j)) : cofan (λ j, G.obj (f j)))) :\n  is_colimit (cofan.mk P g) :=\nreflects_colimit.reflects ((is_colimit_map_cocone_cofan_mk_equiv _ _ _).symm t)\n\nsection\n\nvariables [has_coproduct f]\n\n/--\nIf `G` preserves coproducts and `C` has them,\nthen the cofan constructed of the mapped inclusion of a coproduct is a colimit.\n-/\ndef is_colimit_of_has_coproduct_of_preserves_colimit [preserves_colimit (discrete.functor f) G] :\n  is_colimit (cofan.mk _ (λ (j : J), G.map (sigma.ι f j)) : cofan (λ j, G.obj (f j))) :=\nis_colimit_cofan_mk_obj_of_is_colimit G f _ (coproduct_is_coproduct _)\n\nvariables [has_coproduct (λ (j : J), G.obj (f j))]\n\n/-- If `sigma_comparison G f` is an isomorphism, then `G` preserves the colimit of `f`. -/\ndef preserves_coproduct.of_iso_comparison [i : is_iso (sigma_comparison G f)] :\n  preserves_colimit (discrete.functor f) G :=\nbegin\n  apply preserves_colimit_of_preserves_colimit_cocone (coproduct_is_coproduct f),\n  apply (is_colimit_map_cocone_cofan_mk_equiv _ _ _).symm _,\n  apply is_colimit.of_point_iso (colimit.is_colimit (discrete.functor (λ (j : J), G.obj (f j)))),\n  apply i,\nend\n\nvariable [preserves_colimit (discrete.functor f) G]\n\n/--\nIf `G` preserves colimits,\nwe have an isomorphism from the image of a coproduct to the coproduct of the images.\n-/\ndef preserves_coproduct.iso : G.obj (∐ f) ≅ ∐ (λ j, G.obj (f j)) :=\nis_colimit.cocone_point_unique_up_to_iso\n  (is_colimit_of_has_coproduct_of_preserves_colimit G f)\n  (colimit.is_colimit _)\n\n@[simp]\nlemma preserves_coproduct.inv_hom : (preserves_coproduct.iso G f).inv = sigma_comparison G f :=\nrfl\n\ninstance : is_iso (sigma_comparison G f) :=\nbegin\n  rw ← preserves_coproduct.inv_hom,\n  apply_instance,\nend\n\nend\n\nend category_theory.limits\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/preserves/shapes/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.482580779402884}}
{"text": "inductive Two : Type\n| C21 : Two\n| C22 : Two\n\ninductive Three : Type\n| C31 : Three\n| C32 : Three\n| C33 : Three\n\ntheorem two_is_not_three : Two ≠ Three := begin\n    intro two_is_three,\n    have hatonosu : ∀a b c: Two, a = b ∨ b = c ∨ c = a :=\n        by intros a b c; cases a; cases b; cases c; simp,\n    rw two_is_three at hatonosu,\n    have uso := hatonosu Three.C31 Three.C32 Three.C33,\n    simp at uso,\n    assumption\nend\n", "meta": {"author": "zeptometer", "repo": "LearnLean", "sha": "bb84d5dbe521127ba134d4dbf9559b294a80b9f7", "save_path": "github-repos/lean/zeptometer-LearnLean", "path": "github-repos/lean/zeptometer-LearnLean/LearnLean-bb84d5dbe521127ba134d4dbf9559b294a80b9f7/zeptometer/topprover/27.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835371034368, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.482487870366283}}
{"text": "/-\nCopyright (c) 2022 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n\n! This file was ported from Lean 3 source module order.succ_pred.interval_succ\n! leanprover-community/mathlib commit c227d107bbada5d0d9d20287e3282c0a7f1651a0\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Pairwise.Basic\nimport Mathbin.Order.SuccPred.Basic\n\n/-!\n# Intervals `Ixx (f x) (f (order.succ x))`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we prove\n\n* `monotone.bUnion_Ico_Ioc_map_succ`: if `α` is a linear archimedean succ order and `β` is a linear\n  order, then for any monotone function `f` and `m n : α`, the union of intervals\n  `set.Ioc (f i) (f (order.succ i))`, `m ≤ i < n`, is equal to `set.Ioc (f m) (f n)`;\n\n* `monotone.pairwise_disjoint_on_Ioc_succ`: if `α` is a linear succ order, `β` is a preorder, and\n  `f : α → β` is a monotone function, then the intervals `set.Ioc (f n) (f (order.succ n))` are\n  pairwise disjoint.\n\nFor the latter lemma, we also prove various order dual versions.\n-/\n\n\nopen Set Order\n\nvariable {α β : Type _} [LinearOrder α]\n\nnamespace Monotone\n\n/- warning: monotone.bUnion_Ico_Ioc_map_succ -> Monotone.bunionᵢ_Ico_Ioc_map_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : SuccOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : IsSuccArchimedean.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2] [_inst_4 : LinearOrder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (LinearOrder.toLattice.{u2} β _inst_4)))) f) -> (forall (m : α) (n : α), Eq.{succ u2} (Set.{u2} β) (Set.unionᵢ.{u2, succ u1} β α (fun (i : α) => Set.unionᵢ.{u2, 0} β (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) i (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) m n)) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) i (Set.Ico.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) m n)) => Set.Ioc.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (LinearOrder.toLattice.{u2} β _inst_4)))) (f i) (f (Order.succ.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 i))))) (Set.Ioc.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (LinearOrder.toLattice.{u2} β _inst_4)))) (f m) (f n)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : SuccOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : IsSuccArchimedean.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2] [_inst_4 : LinearOrder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (DistribLattice.toLattice.{u1} β (instDistribLattice.{u1} β _inst_4))))) f) -> (forall (m : α) (n : α), Eq.{succ u1} (Set.{u1} β) (Set.unionᵢ.{u1, succ u2} β α (fun (i : α) => Set.unionᵢ.{u1, 0} β (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) i (Set.Ico.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) m n)) (fun (H : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) i (Set.Ico.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) m n)) => Set.Ioc.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (DistribLattice.toLattice.{u1} β (instDistribLattice.{u1} β _inst_4))))) (f i) (f (Order.succ.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 i))))) (Set.Ioc.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (DistribLattice.toLattice.{u1} β (instDistribLattice.{u1} β _inst_4))))) (f m) (f n)))\nCase conversion may be inaccurate. Consider using '#align monotone.bUnion_Ico_Ioc_map_succ Monotone.bunionᵢ_Ico_Ioc_map_succₓ'. -/\n/-- If `α` is a linear archimedean succ order and `β` is a linear order, then for any monotone\nfunction `f` and `m n : α`, the union of intervals `set.Ioc (f i) (f (order.succ i))`, `m ≤ i < n`,\nis equal to `set.Ioc (f m) (f n)` -/\ntheorem bunionᵢ_Ico_Ioc_map_succ [SuccOrder α] [IsSuccArchimedean α] [LinearOrder β] {f : α → β}\n    (hf : Monotone f) (m n : α) : (⋃ i ∈ Ico m n, Ioc (f i) (f (succ i))) = Ioc (f m) (f n) :=\n  by\n  cases' le_total n m with hnm hmn\n  · rw [Ico_eq_empty_of_le hnm, Ioc_eq_empty_of_le (hf hnm), bUnion_empty]\n  · refine' Succ.rec _ _ hmn\n    · simp only [Ioc_self, Ico_self, bUnion_empty]\n    · intro k hmk ihk\n      rw [← Ioc_union_Ioc_eq_Ioc (hf hmk) (hf <| le_succ _), union_comm, ← ihk]\n      by_cases hk : IsMax k\n      · rw [hk.succ_eq, Ioc_self, empty_union]\n      · rw [Ico_succ_right_eq_insert_of_not_is_max hmk hk, bUnion_insert]\n#align monotone.bUnion_Ico_Ioc_map_succ Monotone.bunionᵢ_Ico_Ioc_map_succ\n\n/- warning: monotone.pairwise_disjoint_on_Ioc_succ -> Monotone.pairwise_disjoint_on_Ioc_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : SuccOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioc.{u2} β _inst_3 (f n) (f (Order.succ.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : SuccOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioc.{u1} β _inst_3 (f n) (f (Order.succ.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)))))\nCase conversion may be inaccurate. Consider using '#align monotone.pairwise_disjoint_on_Ioc_succ Monotone.pairwise_disjoint_on_Ioc_succₓ'. -/\n/-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is a monotone function, then\nthe intervals `set.Ioc (f n) (f (order.succ n))` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioc_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ioc (f n) (f (succ n))) :=\n  (pairwise_disjoint_on _).2 fun m n hmn =>\n    disjoint_iff_inf_le.mpr fun x ⟨⟨_, h₁⟩, ⟨h₂, _⟩⟩ =>\n      h₂.not_le <| h₁.trans <| hf <| succ_le_of_lt hmn\n#align monotone.pairwise_disjoint_on_Ioc_succ Monotone.pairwise_disjoint_on_Ioc_succ\n\n/- warning: monotone.pairwise_disjoint_on_Ico_succ -> Monotone.pairwise_disjoint_on_Ico_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : SuccOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ico.{u2} β _inst_3 (f n) (f (Order.succ.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : SuccOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ico.{u1} β _inst_3 (f n) (f (Order.succ.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)))))\nCase conversion may be inaccurate. Consider using '#align monotone.pairwise_disjoint_on_Ico_succ Monotone.pairwise_disjoint_on_Ico_succₓ'. -/\n/-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is a monotone function, then\nthe intervals `set.Ico (f n) (f (order.succ n))` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ico_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ico (f n) (f (succ n))) :=\n  (pairwise_disjoint_on _).2 fun m n hmn =>\n    disjoint_iff_inf_le.mpr fun x ⟨⟨_, h₁⟩, ⟨h₂, _⟩⟩ =>\n      h₁.not_le <| (hf <| succ_le_of_lt hmn).trans h₂\n#align monotone.pairwise_disjoint_on_Ico_succ Monotone.pairwise_disjoint_on_Ico_succ\n\n/- warning: monotone.pairwise_disjoint_on_Ioo_succ -> Monotone.pairwise_disjoint_on_Ioo_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : SuccOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioo.{u2} β _inst_3 (f n) (f (Order.succ.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : SuccOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioo.{u1} β _inst_3 (f n) (f (Order.succ.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)))))\nCase conversion may be inaccurate. Consider using '#align monotone.pairwise_disjoint_on_Ioo_succ Monotone.pairwise_disjoint_on_Ioo_succₓ'. -/\n/-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is a monotone function, then\nthe intervals `set.Ioo (f n) (f (order.succ n))` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioo_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ioo (f n) (f (succ n))) :=\n  hf.pairwise_disjoint_on_Ico_succ.mono fun i j h => h.mono Ioo_subset_Ico_self Ioo_subset_Ico_self\n#align monotone.pairwise_disjoint_on_Ioo_succ Monotone.pairwise_disjoint_on_Ioo_succ\n\n/- warning: monotone.pairwise_disjoint_on_Ioc_pred -> Monotone.pairwise_disjoint_on_Ioc_pred is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : PredOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioc.{u2} β _inst_3 (f (Order.pred.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : PredOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioc.{u1} β _inst_3 (f (Order.pred.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)) (f n))))\nCase conversion may be inaccurate. Consider using '#align monotone.pairwise_disjoint_on_Ioc_pred Monotone.pairwise_disjoint_on_Ioc_predₓ'. -/\n/-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is a monotone function, then\nthe intervals `set.Ioc (f order.pred n) (f n)` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioc_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ioc (f (pred n)) (f n)) := by\n  simpa only [(· ∘ ·), dual_Ico] using hf.dual.pairwise_disjoint_on_Ico_succ\n#align monotone.pairwise_disjoint_on_Ioc_pred Monotone.pairwise_disjoint_on_Ioc_pred\n\n/- warning: monotone.pairwise_disjoint_on_Ico_pred -> Monotone.pairwise_disjoint_on_Ico_pred is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : PredOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ico.{u2} β _inst_3 (f (Order.pred.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : PredOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ico.{u1} β _inst_3 (f (Order.pred.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)) (f n))))\nCase conversion may be inaccurate. Consider using '#align monotone.pairwise_disjoint_on_Ico_pred Monotone.pairwise_disjoint_on_Ico_predₓ'. -/\n/-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is a monotone function, then\nthe intervals `set.Ico (f order.pred n) (f n)` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ico_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ico (f (pred n)) (f n)) := by\n  simpa only [(· ∘ ·), dual_Ioc] using hf.dual.pairwise_disjoint_on_Ioc_succ\n#align monotone.pairwise_disjoint_on_Ico_pred Monotone.pairwise_disjoint_on_Ico_pred\n\n/- warning: monotone.pairwise_disjoint_on_Ioo_pred -> Monotone.pairwise_disjoint_on_Ioo_pred is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : PredOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioo.{u2} β _inst_3 (f (Order.pred.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : PredOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioo.{u1} β _inst_3 (f (Order.pred.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)) (f n))))\nCase conversion may be inaccurate. Consider using '#align monotone.pairwise_disjoint_on_Ioo_pred Monotone.pairwise_disjoint_on_Ioo_predₓ'. -/\n/-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is a monotone function, then\nthe intervals `set.Ioo (f order.pred n) (f n)` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioo_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ioo (f (pred n)) (f n)) := by\n  simpa only [(· ∘ ·), dual_Ioo] using hf.dual.pairwise_disjoint_on_Ioo_succ\n#align monotone.pairwise_disjoint_on_Ioo_pred Monotone.pairwise_disjoint_on_Ioo_pred\n\nend Monotone\n\nnamespace Antitone\n\n/- warning: antitone.pairwise_disjoint_on_Ioc_succ -> Antitone.pairwise_disjoint_on_Ioc_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : SuccOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioc.{u2} β _inst_3 (f (Order.succ.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : SuccOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Antitone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioc.{u1} β _inst_3 (f (Order.succ.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)) (f n))))\nCase conversion may be inaccurate. Consider using '#align antitone.pairwise_disjoint_on_Ioc_succ Antitone.pairwise_disjoint_on_Ioc_succₓ'. -/\n/-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is an antitone function, then\nthe intervals `set.Ioc (f (order.succ n)) (f n)` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioc_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Antitone f) :\n    Pairwise (Disjoint on fun n => Ioc (f (succ n)) (f n)) :=\n  hf.dual_left.pairwise_disjoint_on_Ioc_pred\n#align antitone.pairwise_disjoint_on_Ioc_succ Antitone.pairwise_disjoint_on_Ioc_succ\n\n/- warning: antitone.pairwise_disjoint_on_Ico_succ -> Antitone.pairwise_disjoint_on_Ico_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : SuccOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ico.{u2} β _inst_3 (f (Order.succ.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : SuccOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Antitone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ico.{u1} β _inst_3 (f (Order.succ.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)) (f n))))\nCase conversion may be inaccurate. Consider using '#align antitone.pairwise_disjoint_on_Ico_succ Antitone.pairwise_disjoint_on_Ico_succₓ'. -/\n/-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is an antitone function, then\nthe intervals `set.Ico (f (order.succ n)) (f n)` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ico_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Antitone f) :\n    Pairwise (Disjoint on fun n => Ico (f (succ n)) (f n)) :=\n  hf.dual_left.pairwise_disjoint_on_Ico_pred\n#align antitone.pairwise_disjoint_on_Ico_succ Antitone.pairwise_disjoint_on_Ico_succ\n\n/- warning: antitone.pairwise_disjoint_on_Ioo_succ -> Antitone.pairwise_disjoint_on_Ioo_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : SuccOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioo.{u2} β _inst_3 (f (Order.succ.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : SuccOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Antitone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioo.{u1} β _inst_3 (f (Order.succ.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)) (f n))))\nCase conversion may be inaccurate. Consider using '#align antitone.pairwise_disjoint_on_Ioo_succ Antitone.pairwise_disjoint_on_Ioo_succₓ'. -/\n/-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is an antitone function, then\nthe intervals `set.Ioo (f (order.succ n)) (f n)` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioo_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Antitone f) :\n    Pairwise (Disjoint on fun n => Ioo (f (succ n)) (f n)) :=\n  hf.dual_left.pairwise_disjoint_on_Ioo_pred\n#align antitone.pairwise_disjoint_on_Ioo_succ Antitone.pairwise_disjoint_on_Ioo_succ\n\n/- warning: antitone.pairwise_disjoint_on_Ioc_pred -> Antitone.pairwise_disjoint_on_Ioc_pred is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : PredOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioc.{u2} β _inst_3 (f n) (f (Order.pred.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : PredOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Antitone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioc.{u1} β _inst_3 (f n) (f (Order.pred.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)))))\nCase conversion may be inaccurate. Consider using '#align antitone.pairwise_disjoint_on_Ioc_pred Antitone.pairwise_disjoint_on_Ioc_predₓ'. -/\n/-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is an antitone function, then\nthe intervals `set.Ioc (f n) (f (order.pred n))` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioc_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Antitone f) :\n    Pairwise (Disjoint on fun n => Ioc (f n) (f (pred n))) :=\n  hf.dual_left.pairwise_disjoint_on_Ioc_succ\n#align antitone.pairwise_disjoint_on_Ioc_pred Antitone.pairwise_disjoint_on_Ioc_pred\n\n/- warning: antitone.pairwise_disjoint_on_Ico_pred -> Antitone.pairwise_disjoint_on_Ico_pred is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : PredOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ico.{u2} β _inst_3 (f n) (f (Order.pred.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : PredOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Antitone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ico.{u1} β _inst_3 (f n) (f (Order.pred.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)))))\nCase conversion may be inaccurate. Consider using '#align antitone.pairwise_disjoint_on_Ico_pred Antitone.pairwise_disjoint_on_Ico_predₓ'. -/\n/-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is an antitone function, then\nthe intervals `set.Ico (f n) (f (order.pred n))` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ico_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Antitone f) :\n    Pairwise (Disjoint on fun n => Ico (f n) (f (pred n))) :=\n  hf.dual_left.pairwise_disjoint_on_Ico_succ\n#align antitone.pairwise_disjoint_on_Ico_pred Antitone.pairwise_disjoint_on_Ico_pred\n\n/- warning: antitone.pairwise_disjoint_on_Ioo_pred -> Antitone.pairwise_disjoint_on_Ioo_pred is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : PredOrder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_3 : Preorder.{u2} β] {f : α -> β}, (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_3 f) -> (Pairwise.{u1} α (Function.onFun.{succ u1, succ u2, 1} α (Set.{u2} β) Prop (Disjoint.{u2} (Set.{u2} β) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} β) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} β) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} β) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} β) (Set.completeBooleanAlgebra.{u2} β)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} β) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} β) (Set.booleanAlgebra.{u2} β)))) (fun (n : α) => Set.Ioo.{u2} β _inst_3 (f n) (f (Order.pred.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : PredOrder.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_3 : Preorder.{u1} β] {f : α -> β}, (Antitone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_3 f) -> (Pairwise.{u2} α (Function.onFun.{succ u2, succ u1, 1} α (Set.{u1} β) Prop (Disjoint.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} β) (Preorder.toLE.{u1} (Set.{u1} β) (PartialOrder.toPreorder.{u1} (Set.{u1} β) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} β) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} β) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} β) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} β) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} β) (Set.instCompleteBooleanAlgebraSet.{u1} β))))))) (fun (n : α) => Set.Ioo.{u1} β _inst_3 (f n) (f (Order.pred.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 n)))))\nCase conversion may be inaccurate. Consider using '#align antitone.pairwise_disjoint_on_Ioo_pred Antitone.pairwise_disjoint_on_Ioo_predₓ'. -/\n/-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is an antitone function, then\nthe intervals `set.Ioo (f n) (f (order.pred n))` are pairwise disjoint. -/\ntheorem pairwise_disjoint_on_Ioo_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Antitone f) :\n    Pairwise (Disjoint on fun n => Ioo (f n) (f (pred n))) :=\n  hf.dual_left.pairwise_disjoint_on_Ioo_succ\n#align antitone.pairwise_disjoint_on_Ioo_pred Antitone.pairwise_disjoint_on_Ioo_pred\n\nend Antitone\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/SuccPred/IntervalSucc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619306896955, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.48239362724316526}}
{"text": "import Lean\nimport Mathlib.Order.BoundedOrder\n\nuniverse u v\n\nsection logicNotation\n\n@[notation_class] class HasNeg (α : Sort _) where\n  neg : α → α\n\nprefix:75 \"~\" => HasNeg.neg\n\n@[notation_class] class HasArrow (α : Sort _) where\n  arrow : α → α → α\n\ninfixr:60 \" ⟶ \" => HasArrow.arrow\n\n@[notation_class] class HasAnd (α : Sort _) where\n  and : α → α → α\n\ninfixl:69 \" ⋏ \" => HasAnd.and\n\n@[match_pattern, notation_class] class HasOr (α : Sort _) where\n  or : α → α → α\n\ninfixl:68 \" ⋎ \" => HasOr.or\n\nclass HasLogicSymbols (α : Sort _)\n  extends Top α, Bot α, HasNeg α, HasArrow α, HasAnd α, HasOr α\n\n@[notation_class] class HasUniv (α : ℕ → Sort _) where\n  univ : ∀ {n}, α (n + 1) → α n\n\nprefix:64 \"∀' \" => HasUniv.univ\n\nsection HasUniv\n\nvariable {α : ℕ → Sort u} [HasUniv α]\n\ndef univClosure : {n : ℕ} → α n → α 0\n  | 0,     a => a\n  | _ + 1, a => univClosure (∀' a)\n\n@[simp] lemma univ_closure_zero (a : α 0) : univClosure a = a := rfl\n\n@[simp] lemma univ_closure_succ {n} (a : α (n + 1)) : univClosure a = univClosure (∀' a) := rfl\n\nend HasUniv\n\n@[notation_class] class HasEx (α : ℕ → Sort _) where\n  ex : ∀ {n}, α (n + 1) → α n\n\nprefix:64 \"∃' \" => HasEx.ex\n\nattribute [match_pattern] HasNeg.neg HasArrow.arrow HasAnd.and HasOr.or HasUniv.univ HasEx.ex\n\n@[notation_class] class HasTurnstile (α : Sort _) (β : Sort _) where\n  turnstile : Set α → α → β\n\ninfix:45 \" ⊢ \" => HasTurnstile.turnstile\n\n@[notation_class] class HasVdash (α : Sort _) (β : outParam (Sort _)) where\n  vdash : α → β\n\nprefix:45 \"⊩ \" => HasVdash.vdash\n\nend logicNotation\n\nnamespace HasLogicSymbols\n\nsection\nvariable {α : Sort _} [HasLogicSymbols α]\n\n@[match_pattern] def iff (a b : α) := (a ⟶ b) ⋏ (b ⟶ a)\n\ninfix:61 \" ⟷ \" => HasLogicSymbols.iff\n\nend\n\n@[reducible]\ninstance Prop_HasLogicSymbols : HasLogicSymbols Prop where\n  top := True\n  bot := False\n  neg := Not\n  arrow := fun P Q => (P → Q)\n  and := And\n  or := Or\n\n@[simp] lemma Prop_top_eq : ⊤ = True := rfl\n\n@[simp] lemma Prop_bot_eq : ⊥ = False := rfl\n\n@[simp] lemma Prop_neg_eq (p : Prop) : ~ p = ¬p := rfl\n\n@[simp] lemma Prop_arrow_eq (p q : Prop) : (p ⟶ q) = (p → q) := rfl\n\n@[simp] lemma Prop_and_eq (p q : Prop) : (p ⋏ q) = (p ∧ q) := rfl\n\n@[simp] lemma Prop_or_eq (p q : Prop) : (p ⋎ q) = (p ∨ q) := rfl\n\n@[simp] lemma Prop_iff_eq (p q : Prop) : (p ⟷ q) = (p ↔ q) := by simp[HasLogicSymbols.iff, iff_iff_implies_and_implies]\n\nvariable (α β γ : Type _) [HasLogicSymbols α] [HasLogicSymbols β] [HasLogicSymbols γ]\n\nstructure Hom where\n  toFun : α → β\n  map_top' : toFun ⊤ = ⊤\n  map_bot' : toFun ⊥ = ⊥\n  map_neg' : ∀ p, toFun (~ p) = ~toFun p\n  map_imp' : ∀ p q, toFun (p ⟶ q) = toFun p ⟶ toFun q\n  map_and' : ∀ p q, toFun (p ⋏ q) = toFun p ⋏ toFun q\n  map_or'  : ∀ p q, toFun (p ⋎ q) = toFun p ⋎ toFun q\n\ninfix:25 \" →L \" => Hom\n\nnamespace Hom\nvariable {α β γ}\n\ninstance coeToFun : CoeFun (α →L β) (fun _ => α → β) := ⟨fun f => f.toFun⟩\n\nvariable (f : α →L β) (a b : α)\n\n@[simp] lemma map_top : f ⊤ = ⊤ := map_top' f\n\n@[simp] lemma map_bot : f ⊥ = ⊥ := map_bot' f\n\n@[simp] lemma map_neg : f (~a) = ~f a := Hom.map_neg' f a\n\n@[simp] lemma map_imply : f (a ⟶ b) = f a ⟶ f b := map_imp' f a b\n\n@[simp] lemma map_and : f (a ⋏ b) = f a ⋏ f b := map_and' f a b\n\n@[simp] lemma map_or : f (a ⋎ b) = f a ⋎ f b := map_or' f a b\n\n@[simp] lemma map_iff : f (a ⟷ b) = f a ⟷ f b := by simp[HasLogicSymbols.iff]\n\nprotected def id : α →L α where\n  toFun := id\n  map_top' := by simp\n  map_bot' := by simp\n  map_neg' := by simp\n  map_imp' := by simp\n  map_and' := by simp\n  map_or' := by simp\n\n@[simp] lemma app_id (a : α) : HasLogicSymbols.Hom.id a = a := rfl\n\ndef comp (g : β →L γ) (f : α →L β) : α →L γ where\n  toFun := g.toFun ∘ f.toFun\n  map_top' := by simp\n  map_bot' := by simp\n  map_neg' := by simp\n  map_imp' := by simp\n  map_and' := by simp\n  map_or' := by simp  \n\n@[simp] lemma app_comp (g : β →L γ) (f : α →L β) (a : α) :\n     g.comp f a = g (f a) := rfl\n\n@[ext] lemma ext (f g : α →L β) (h : ∀ x, f x = g x) : f = g :=\n  by rcases f; rcases g; simp; funext x; exact h x\n\nend Hom\n\nend HasLogicSymbols\n\n", "meta": {"author": "iehality", "repo": "lean4-logic", "sha": "ef518051931fb1ecd0b89e94240b2900cd54d95c", "save_path": "github-repos/lean/iehality-lean4-logic", "path": "github-repos/lean/iehality-lean4-logic/lean4-logic-ef518051931fb1ecd0b89e94240b2900cd54d95c/Logic/Vorspiel/Notation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.48233633548977833}}
{"text": "/-\nCopyright © 2020 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicolò Cavalleri\n-/\n\nimport geometry.manifold.algebra.monoid\n\n/-!\n# Lie groups\n\nA Lie group is a group that is also a smooth manifold, in which the group operations of\nmultiplication and inversion are smooth maps. Smoothness of the group multiplication means that\nmultiplication is a smooth mapping of the product manifold `G` × `G` into `G`.\n\nNote that, since a manifold here is not second-countable and Hausdorff a Lie group here is not\nguaranteed to be second-countable (even though it can be proved it is Hausdorff). Note also that Lie\ngroups here are not necessarily finite dimensional.\n\n## Main definitions and statements\n\n* `lie_add_group I G` : a Lie additive group where `G` is a manifold on the model with corners `I`.\n* `lie_group I G`     : a Lie multiplicative group where `G` is a manifold on the model with\n                        corners `I`.\n* `normed_space_lie_add_group` : a normed vector space over a nondiscrete normed field\n                                 is an additive Lie group.\n\n## Implementation notes\nA priori, a Lie group here is a manifold with corners.\n\nThe definition of Lie group cannot require `I : model_with_corners 𝕜 E E` with the same space as the\nmodel space and as the model vector space, as one might hope, beause in the product situation,\nthe model space is `model_prod E E'` and the model vector space is `E × E'`, which are not the same,\nso the definition does not apply. Hence the definition should be more general, allowing\n`I : model_with_corners 𝕜 E H`.\n-/\n\nnoncomputable theory\n\nopen_locale manifold\n\nsection\nset_option old_structure_cmd true\n\n/-- A Lie (additive) group is a group and a smooth manifold at the same time in which\nthe addition and negation operations are smooth. -/\n-- See note [Design choices about smooth algebraic structures]\n@[ancestor has_smooth_add]\nclass lie_add_group {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space 𝕜 E] (I : model_with_corners 𝕜 E H)\n  (G : Type*) [add_group G] [topological_space G] [charted_space H G]\n  extends has_smooth_add I G : Prop :=\n(smooth_neg : smooth I I (λ a:G, -a))\n\n/-- A Lie group is a group and a smooth manifold at the same time in which\nthe multiplication and inverse operations are smooth. -/\n-- See note [Design choices about smooth algebraic structures]\n@[ancestor has_smooth_mul, to_additive]\nclass lie_group {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space 𝕜 E] (I : model_with_corners 𝕜 E H)\n  (G : Type*) [group G] [topological_space G] [charted_space H G]\n  extends has_smooth_mul I G : Prop :=\n(smooth_inv : smooth I I (λ a:G, a⁻¹))\n\nend\n\nsection lie_group\n\nvariables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n{H : Type*} [topological_space H]\n{E : Type*} [normed_group E] [normed_space 𝕜 E] {I : model_with_corners 𝕜 E H}\n{F : Type*} [normed_group F] [normed_space 𝕜 F] {J : model_with_corners 𝕜 F F}\n{G : Type*} [topological_space G] [charted_space H G] [group G] [lie_group I G]\n{E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n{H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}\n{M : Type*} [topological_space M] [charted_space H' M]\n{E'' : Type*} [normed_group E''] [normed_space 𝕜 E'']\n{H'' : Type*} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''}\n{M' : Type*} [topological_space M'] [charted_space H'' M']\n\nlocalized \"notation `L_add` := left_add\" in lie_group\n\nlocalized \"notation `R_add` := right_add\" in lie_group\n\nlocalized \"notation `L` := left_mul\" in lie_group\n\nlocalized \"notation `R` := right_mul\" in lie_group\n\nsection\n\nvariable (I)\n\n@[to_additive]\nlemma smooth_inv : smooth I I (λ x : G, x⁻¹) :=\nlie_group.smooth_inv\n\n/-- A Lie group is a topological group. This is not an instance for technical reasons,\nsee note [Design choices about smooth algebraic structures]. -/\n@[to_additive\n\"An additive Lie group is an additive topological group. This is not an instance for technical\nreasons, see note [Design choices about smooth algebraic structures].\"]\nlemma topological_group_of_lie_group : topological_group G :=\n{ continuous_inv := (smooth_inv I).continuous,\n  .. has_continuous_mul_of_smooth I }\n\nend\n\n@[to_additive]\nlemma smooth.inv {f : M → G}\n  (hf : smooth I' I f) : smooth I' I (λx, (f x)⁻¹) :=\n(smooth_inv I).comp hf\n\n@[to_additive]\nlemma smooth_on.inv {f : M → G} {s : set M}\n  (hf : smooth_on I' I f s) : smooth_on I' I (λx, (f x)⁻¹) s :=\n(smooth_inv I).comp_smooth_on hf\n\n@[to_additive]\nlemma smooth.div {f g : M → G}\n  (hf : smooth I' I f) (hg : smooth I' I g) : smooth I' I (f / g) :=\nby { rw div_eq_mul_inv, exact ((smooth_mul I).comp (hf.prod_mk hg.inv) : _), }\n\n@[to_additive]\nlemma smooth_on.div {f g : M → G} {s : set M}\n  (hf : smooth_on I' I f s) (hg : smooth_on I' I g s) : smooth_on I' I (f / g) s :=\nby { rw div_eq_mul_inv, exact ((smooth_mul I).comp_smooth_on (hf.prod_mk hg.inv) : _), }\n\nend lie_group\n\nsection prod_lie_group\n\n/- Instance of product group -/\n@[to_additive]\ninstance {𝕜 : Type*} [nondiscrete_normed_field 𝕜] {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space 𝕜 E]  {I : model_with_corners 𝕜 E H}\n  {G : Type*} [topological_space G] [charted_space H G] [group G] [lie_group I G]\n  {E' : Type*} [normed_group E'] [normed_space 𝕜 E']\n  {H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}\n  {G' : Type*} [topological_space G'] [charted_space H' G']\n  [group G'] [lie_group I' G'] :\n  lie_group (I.prod I') (G×G') :=\n{ smooth_inv := smooth_fst.inv.prod_mk smooth_snd.inv,\n  ..has_smooth_mul.prod _ _ _ _ }\n\nend prod_lie_group\n\n/-! ### Normed spaces are Lie groups -/\n\ninstance normed_space_lie_add_group {𝕜 : Type*} [nondiscrete_normed_field 𝕜]\n  {E : Type*} [normed_group E] [normed_space 𝕜 E] :\n  lie_add_group (𝓘(𝕜, E)) E :=\n{ smooth_add := smooth_iff.2 ⟨continuous_add, λ x y, times_cont_diff_add.times_cont_diff_on⟩,\n  smooth_neg := smooth_iff.2 ⟨continuous_neg, λ x y, times_cont_diff_neg.times_cont_diff_on⟩,\n  .. model_space_smooth }\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/geometry/manifold/algebra/lie_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.4823363337803417}}
{"text": "\n-- https://github.com/leanprover-community/lean/blob/ec1613aef1eee72e601f192b16740629c6d49690/tests/lean/run/back3.lean\n\n/- Lean has a backward chaining tactic that can be configured using\n   attributes. -/\nopen list tactic\n\nuniverse variable u\nlemma in_tail  {α : Type u} {a : α} (b : α) {l : list α}        : a ∈ l → a ∈ b::l   := mem_cons_of_mem _\nlemma in_head  {α : Type u} (a : α) (l : list α)                : a ∈ a::l           := mem_cons_self _ _\nlemma in_left  {α : Type u} {a : α}   {l : list α} (r : list α) : a ∈ l → a ∈ l ++ r := mem_append_left _\nlemma in_right {α : Type u} {a : α}   (l : list α) {r : list α} : a ∈ r → a ∈ l ++ r := mem_append_right _\n\n/- It is trivial to define mk_mem_list using backward chaining -/\nattribute [intro] in_tail in_head in_left in_right\n\nmeta def mk_mem_list : tactic unit :=\nsolve1 (back_chaining)\n\nset_option trace.tactic.back_chaining true\nexample (a b c : nat) : a ∈ [b, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a ∈ [b, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a ∈ [b, c] ++ [b, c, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) (l : list nat) : a ∈ l → a ∈ [b, c] ++ b::l :=\nbegin intros, mk_mem_list end\n\nexample (a b c : nat) (l₁ l₂ : list nat) : a ∈ l₁ → a ∈ b::b::c::l₂ ++ b::c::l₁ ++ [c, c, b] :=\nbegin intros, mk_mem_list end", "meta": {"author": "mathprocessing", "repo": "lean_mathlib_examples", "sha": "743c6456c0a3219dd1722efdd31ee6f3a113818a", "save_path": "github-repos/lean/mathprocessing-lean_mathlib_examples", "path": "github-repos/lean/mathprocessing-lean_mathlib_examples/lean_mathlib_examples-743c6456c0a3219dd1722efdd31ee6f3a113818a/src/tactics/back3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.7248702702332476, "lm_q1q2_score": 0.48233633153485933}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module computability.primrec\n! leanprover-community/mathlib commit 959c3b69db8a8b404d5813421f2e6ca8660d19e5\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Logic.Equiv.Array\nimport Mathbin.Logic.Equiv.List\nimport Mathbin.Logic.Function.Iterate\n\n/-!\n# The primitive recursive functions\n\nThe primitive recursive functions are the least collection of functions\n`nat → nat` which are closed under projections (using the mkpair\npairing function), composition, zero, successor, and primitive recursion\n(i.e. nat.rec where the motive is C n := nat).\n\nWe can extend this definition to a large class of basic types by\nusing canonical encodings of types as natural numbers (Gödel numbering),\nwhich we implement through the type class `encodable`. (More precisely,\nwe need that the composition of encode with decode yields a\nprimitive recursive function, so we have the `primcodable` type class\nfor this.)\n\n## References\n\n* [Mario Carneiro, *Formalizing computability theory via partial recursive functions*][carneiro2019]\n-/\n\n\nopen Denumerable Encodable Function\n\nnamespace Nat\n\n/- warning: nat.elim -> Nat.rec is a dubious translation:\nlean 3 declaration is\n  forall {C : Sort.{u1}}, C -> (Nat -> C -> C) -> Nat -> C\nbut is expected to have type\n  forall {C : Nat -> Sort.{u1}}, (C Nat.zero) -> (forall (ᾰ : Nat), (C ᾰ) -> (C (Nat.succ ᾰ))) -> (forall (ᾰ : Nat), C ᾰ)\nCase conversion may be inaccurate. Consider using '#align nat.elim Nat.recₓ'. -/\n/-- The non-dependent recursor on naturals. -/\ndef rec {C : Sort _} : C → (ℕ → C → C) → ℕ → C :=\n  @Nat.rec fun _ => C\n#align nat.elim Nat.rec\n\n/- warning: nat.elim_zero clashes with nat.rec_zero -> Nat.rec_zero\nwarning: nat.elim_zero -> Nat.rec_zero is a dubious translation:\nlean 3 declaration is\n  forall {C : Sort.{u1}} (a : C) (f : Nat -> C -> C), Eq.{u1} C (Nat.rec.{u1} C a f (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) a\nbut is expected to have type\n  forall {C : Nat -> Sort.{u1}} (a : C (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (f : forall (ᾰ : Nat), (C ᾰ) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) ᾰ (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))), Eq.{u1} (C (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) ((fun (t : Nat) => Nat.rec.{u1} (fun (x._@.Mathlib.Data.Nat.Basic._hyg.2994 : Nat) => C x._@.Mathlib.Data.Nat.Basic._hyg.2994) a f t) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) a\nCase conversion may be inaccurate. Consider using '#align nat.elim_zero Nat.rec_zeroₓ'. -/\n@[simp]\ntheorem rec_zero {C} (a f) : @Nat.rec C a f 0 = a :=\n  rfl\n#align nat.elim_zero Nat.rec_zero\n\n/- warning: nat.elim_succ clashes with nat.rec_add_one -> Nat.rec_add_one\nwarning: nat.elim_succ -> Nat.rec_add_one is a dubious translation:\nlean 3 declaration is\n  forall {C : Sort.{u1}} (a : C) (f : Nat -> C -> C) (n : Nat), Eq.{u1} C (Nat.rec.{u1} C a f (Nat.succ n)) (f n (Nat.rec.{u1} C a f n))\nbut is expected to have type\n  forall {C : Nat -> Sort.{u1}} (a : C (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (f : forall (ᾰ : Nat), (C ᾰ) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) ᾰ (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (n : Nat), Eq.{u1} (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) ((fun (t : Nat) => Nat.rec.{u1} (fun (x._@.Mathlib.Data.Nat.Basic._hyg.3047 : Nat) => C x._@.Mathlib.Data.Nat.Basic._hyg.3047) a f t) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (f n ((fun (t : Nat) => Nat.rec.{u1} (fun (x._@.Mathlib.Data.Nat.Basic._hyg.3070 : Nat) => C x._@.Mathlib.Data.Nat.Basic._hyg.3070) a f t) n))\nCase conversion may be inaccurate. Consider using '#align nat.elim_succ Nat.rec_add_oneₓ'. -/\n@[simp]\ntheorem rec_add_one {C} (a f n) : @Nat.rec C a f (succ n) = f n (Nat.rec a f n) :=\n  rfl\n#align nat.elim_succ Nat.rec_add_one\n\n/- warning: nat.cases -> Nat.casesOn is a dubious translation:\nlean 3 declaration is\n  forall {C : Sort.{u1}}, C -> (Nat -> C) -> Nat -> C\nbut is expected to have type\n  forall {C : Nat -> Sort.{u1}} (a : Nat), (C Nat.zero) -> (forall (n : Nat), C (Nat.succ n)) -> (C a)\nCase conversion may be inaccurate. Consider using '#align nat.cases Nat.casesOnₓ'. -/\n/-- Cases on whether the input is 0 or a successor. -/\ndef casesOn {C : Sort _} (a : C) (f : ℕ → C) : ℕ → C :=\n  Nat.rec a fun n _ => f n\n#align nat.cases Nat.casesOn\n\n/- warning: nat.cases_zero clashes with nat.rec_zero -> Nat.rec_zero\nwarning: nat.cases_zero -> Nat.rec_zero is a dubious translation:\nlean 3 declaration is\n  forall {C : Sort.{u1}} (a : C) (f : Nat -> C), Eq.{u1} C (Nat.casesOn.{u1} C a f (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) a\nbut is expected to have type\n  forall {C : Nat -> Sort.{u1}} (a : C (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (f : forall (ᾰ : Nat), (C ᾰ) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) ᾰ (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))), Eq.{u1} (C (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) ((fun (t : Nat) => Nat.rec.{u1} (fun (x._@.Mathlib.Data.Nat.Basic._hyg.2994 : Nat) => C x._@.Mathlib.Data.Nat.Basic._hyg.2994) a f t) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) a\nCase conversion may be inaccurate. Consider using '#align nat.cases_zero Nat.rec_zeroₓ'. -/\n@[simp]\ntheorem rec_zero {C} (a f) : @Nat.casesOn C a f 0 = a :=\n  rfl\n#align nat.cases_zero Nat.rec_zero\n\n/- warning: nat.cases_succ clashes with nat.rec_add_one -> Nat.rec_add_one\nwarning: nat.cases_succ -> Nat.rec_add_one is a dubious translation:\nlean 3 declaration is\n  forall {C : Sort.{u1}} (a : C) (f : Nat -> C) (n : Nat), Eq.{u1} C (Nat.casesOn.{u1} C a f (Nat.succ n)) (f n)\nbut is expected to have type\n  forall {C : Nat -> Sort.{u1}} (a : C (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (f : forall (ᾰ : Nat), (C ᾰ) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) ᾰ (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (n : Nat), Eq.{u1} (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) ((fun (t : Nat) => Nat.rec.{u1} (fun (x._@.Mathlib.Data.Nat.Basic._hyg.3047 : Nat) => C x._@.Mathlib.Data.Nat.Basic._hyg.3047) a f t) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (f n ((fun (t : Nat) => Nat.rec.{u1} (fun (x._@.Mathlib.Data.Nat.Basic._hyg.3070 : Nat) => C x._@.Mathlib.Data.Nat.Basic._hyg.3070) a f t) n))\nCase conversion may be inaccurate. Consider using '#align nat.cases_succ Nat.rec_add_oneₓ'. -/\n@[simp]\ntheorem rec_add_one {C} (a f n) : @Nat.casesOn C a f (succ n) = f n :=\n  rfl\n#align nat.cases_succ Nat.rec_add_one\n\n#print Nat.unpaired /-\n/-- Calls the given function on a pair of entries `n`, encoded via the pairing function. -/\n@[simp, reducible]\ndef unpaired {α} (f : ℕ → ℕ → α) (n : ℕ) : α :=\n  f n.unpair.1 n.unpair.2\n#align nat.unpaired Nat.unpaired\n-/\n\n#print Nat.Primrec /-\n/-- The primitive recursive functions `ℕ → ℕ`. -/\ninductive Primrec : (ℕ → ℕ) → Prop\n  | zero : Primrec fun n => 0\n  | succ : Primrec succ\n  | left : Primrec fun n => n.unpair.1\n  | right : Primrec fun n => n.unpair.2\n  | pair {f g} : Primrec f → Primrec g → Primrec fun n => pair (f n) (g n)\n  | comp {f g} : Primrec f → Primrec g → Primrec fun n => f (g n)\n  |\n  prec {f g} :\n    Primrec f →\n      Primrec g → Primrec (unpaired fun z n => n.elim (f z) fun y IH => g <| pair z <| pair y IH)\n#align nat.primrec Nat.Primrec\n-/\n\nnamespace Primrec\n\n#print Nat.Primrec.of_eq /-\ntheorem of_eq {f g : ℕ → ℕ} (hf : Primrec f) (H : ∀ n, f n = g n) : Primrec g :=\n  (funext H : f = g) ▸ hf\n#align nat.primrec.of_eq Nat.Primrec.of_eq\n-/\n\n#print Nat.Primrec.const /-\ntheorem const : ∀ n : ℕ, Primrec fun _ => n\n  | 0 => zero\n  | n + 1 => succ.comp (const n)\n#align nat.primrec.const Nat.Primrec.const\n-/\n\n#print Nat.Primrec.id /-\nprotected theorem id : Primrec id :=\n  (left.pair right).of_eq fun n => by simp\n#align nat.primrec.id Nat.Primrec.id\n-/\n\n#print Nat.Primrec.prec1 /-\ntheorem prec1 {f} (m : ℕ) (hf : Primrec f) : Primrec fun n => n.elim m fun y IH => f <| pair y IH :=\n  ((prec (const m) (hf.comp right)).comp (zero.pair Primrec.id)).of_eq fun n => by simp\n#align nat.primrec.prec1 Nat.Primrec.prec1\n-/\n\n#print Nat.Primrec.cases1 /-\ntheorem cases1 {f} (m : ℕ) (hf : Primrec f) : Primrec (Nat.casesOn m f) :=\n  (prec1 m (hf.comp left)).of_eq <| by simp [cases]\n#align nat.primrec.cases1 Nat.Primrec.cases1\n-/\n\n#print Nat.Primrec.cases /-\ntheorem cases {f g} (hf : Primrec f) (hg : Primrec g) :\n    Primrec (unpaired fun z n => n.cases (f z) fun y => g <| pair z y) :=\n  (prec hf (hg.comp (pair left (left.comp right)))).of_eq <| by simp [cases]\n#align nat.primrec.cases Nat.Primrec.cases\n-/\n\n#print Nat.Primrec.swap /-\nprotected theorem swap : Primrec (unpaired (swap pair)) :=\n  (pair right left).of_eq fun n => by simp\n#align nat.primrec.swap Nat.Primrec.swap\n-/\n\n#print Nat.Primrec.swap' /-\ntheorem swap' {f} (hf : Primrec (unpaired f)) : Primrec (unpaired (swap f)) :=\n  (hf.comp Primrec.swap).of_eq fun n => by simp\n#align nat.primrec.swap' Nat.Primrec.swap'\n-/\n\n#print Nat.Primrec.pred /-\ntheorem pred : Primrec pred :=\n  (cases1 0 Primrec.id).of_eq fun n => by cases n <;> simp [*]\n#align nat.primrec.pred Nat.Primrec.pred\n-/\n\n#print Nat.Primrec.add /-\ntheorem add : Primrec (unpaired (· + ·)) :=\n  (prec Primrec.id ((succ.comp right).comp right)).of_eq fun p => by\n    simp <;> induction p.unpair.2 <;> simp [*, -add_comm, add_succ]\n#align nat.primrec.add Nat.Primrec.add\n-/\n\n#print Nat.Primrec.sub /-\ntheorem sub : Primrec (unpaired Sub.sub) :=\n  (prec Primrec.id ((pred.comp right).comp right)).of_eq fun p => by\n    simp <;> induction p.unpair.2 <;> simp [*, -add_comm, sub_succ]\n#align nat.primrec.sub Nat.Primrec.sub\n-/\n\n#print Nat.Primrec.mul /-\ntheorem mul : Primrec (unpaired (· * ·)) :=\n  (prec zero (add.comp (pair left (right.comp right)))).of_eq fun p => by\n    simp <;> induction p.unpair.2 <;> simp [*, mul_succ, add_comm]\n#align nat.primrec.mul Nat.Primrec.mul\n-/\n\n#print Nat.Primrec.pow /-\ntheorem pow : Primrec (unpaired (· ^ ·)) :=\n  (prec (const 1) (mul.comp (pair (right.comp right) left))).of_eq fun p => by\n    simp <;> induction p.unpair.2 <;> simp [*, pow_succ']\n#align nat.primrec.pow Nat.Primrec.pow\n-/\n\nend Primrec\n\nend Nat\n\n#print Primcodable /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`prim] [] -/\n/-- A `primcodable` type is an `encodable` type for which\n  the encode/decode functions are primitive recursive. -/\nclass Primcodable (α : Type _) extends Encodable α where\n  prim : Nat.Primrec fun n => Encodable.encode (decode n)\n#align primcodable Primcodable\n-/\n\nnamespace Primcodable\n\nopen Nat.Primrec\n\n#print Primcodable.ofDenumerable /-\ninstance (priority := 10) ofDenumerable (α) [Denumerable α] : Primcodable α :=\n  ⟨succ.of_eq <| by simp⟩\n#align primcodable.of_denumerable Primcodable.ofDenumerable\n-/\n\n#print Primcodable.ofEquiv /-\n/-- Builds a `primcodable` instance from an equivalence to a `primcodable` type. -/\ndef ofEquiv (α) {β} [Primcodable α] (e : β ≃ α) : Primcodable β :=\n  { Encodable.ofEquiv α e with\n    prim :=\n      (Primcodable.prim α).of_eq fun n =>\n        show\n          encode (decode α n) =\n            (Option.casesOn (Option.map e.symm (decode α n)) 0 fun a => Nat.succ (encode (e a)) : ℕ)\n          by cases decode α n <;> dsimp <;> simp }\n#align primcodable.of_equiv Primcodable.ofEquiv\n-/\n\n#print Primcodable.empty /-\ninstance empty : Primcodable Empty :=\n  ⟨zero⟩\n#align primcodable.empty Primcodable.empty\n-/\n\n#print Primcodable.unit /-\ninstance unit : Primcodable PUnit :=\n  ⟨(cases1 1 zero).of_eq fun n => by cases n <;> simp⟩\n#align primcodable.unit Primcodable.unit\n-/\n\n#print Primcodable.option /-\ninstance option {α : Type _} [h : Primcodable α] : Primcodable (Option α) :=\n  ⟨(cases1 1 ((cases1 0 (succ.comp succ)).comp (Primcodable.prim α))).of_eq fun n => by\n      cases n <;> simp <;> cases decode α n <;> rfl⟩\n#align primcodable.option Primcodable.option\n-/\n\n#print Primcodable.bool /-\ninstance bool : Primcodable Bool :=\n  ⟨(cases1 1 (cases1 2 zero)).of_eq fun n => by\n      cases n; · rfl; cases n; · rfl\n      rw [decode_ge_two]; · rfl\n      exact by decide⟩\n#align primcodable.bool Primcodable.bool\n-/\n\nend Primcodable\n\n#print Primrec /-\n/-- `primrec f` means `f` is primitive recursive (after\n  encoding its input and output as natural numbers). -/\ndef Primrec {α β} [Primcodable α] [Primcodable β] (f : α → β) : Prop :=\n  Nat.Primrec fun n => encode ((decode α n).map f)\n#align primrec Primrec\n-/\n\nnamespace Primrec\n\nvariable {α : Type _} {β : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable σ]\n\nopen Nat.Primrec\n\n#print Primrec.encode /-\nprotected theorem encode : Primrec (@encode α _) :=\n  (Primcodable.prim α).of_eq fun n => by cases decode α n <;> rfl\n#align primrec.encode Primrec.encode\n-/\n\n#print Primrec.decode /-\nprotected theorem decode : Primrec (decode α) :=\n  succ.comp (Primcodable.prim α)\n#align primrec.decode Primrec.decode\n-/\n\n/- warning: primrec.dom_denumerable -> Primrec.dom_denumerable is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_4 : Denumerable.{u1} α] [_inst_5 : Primcodable.{u2} β] {f : α -> β}, Iff (Primrec.{u1, u2} α β (Primcodable.ofDenumerable.{u1} α _inst_4) _inst_5 f) (Nat.Primrec (fun (n : Nat) => Encodable.encode.{u2} β (Primcodable.toEncodable.{u2} β _inst_5) (f (Denumerable.ofNat.{u1} α _inst_4 n))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_4 : Denumerable.{u2} α] [_inst_5 : Primcodable.{u1} β] {f : α -> β}, Iff (Primrec.{u2, u1} α β (Primcodable.ofDenumerable.{u2} α _inst_4) _inst_5 f) (Nat.Primrec (fun (n : Nat) => Encodable.encode.{u1} β (Primcodable.toEncodable.{u1} β _inst_5) (f (Denumerable.ofNat.{u2} α _inst_4 n))))\nCase conversion may be inaccurate. Consider using '#align primrec.dom_denumerable Primrec.dom_denumerableₓ'. -/\ntheorem dom_denumerable {α β} [Denumerable α] [Primcodable β] {f : α → β} :\n    Primrec f ↔ Nat.Primrec fun n => encode (f (ofNat α n)) :=\n  ⟨fun h => (pred.comp h).of_eq fun n => by simp <;> rfl, fun h =>\n    (succ.comp h).of_eq fun n => by simp <;> rfl⟩\n#align primrec.dom_denumerable Primrec.dom_denumerable\n\n#print Primrec.nat_iff /-\ntheorem nat_iff {f : ℕ → ℕ} : Primrec f ↔ Nat.Primrec f :=\n  dom_denumerable\n#align primrec.nat_iff Primrec.nat_iff\n-/\n\n#print Primrec.encdec /-\ntheorem encdec : Primrec fun n => encode (decode α n) :=\n  nat_iff.2 (Primcodable.prim α)\n#align primrec.encdec Primrec.encdec\n-/\n\n#print Primrec.option_some /-\ntheorem option_some : Primrec (@some α) :=\n  ((cases1 0 (succ.comp succ)).comp (Primcodable.prim α)).of_eq fun n => by\n    cases decode α n <;> simp\n#align primrec.option_some Primrec.option_some\n-/\n\n/- warning: primrec.of_eq -> Primrec.of_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_3 : Primcodable.{u2} σ] {f : α -> σ} {g : α -> σ}, (Primrec.{u1, u2} α σ _inst_1 _inst_3 f) -> (forall (n : α), Eq.{succ u2} σ (f n) (g n)) -> (Primrec.{u1, u2} α σ _inst_1 _inst_3 g)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_3 : Primcodable.{u1} σ] {f : α -> σ} {g : α -> σ}, (Primrec.{u2, u1} α σ _inst_1 _inst_3 f) -> (forall (n : α), Eq.{succ u1} σ (f n) (g n)) -> (Primrec.{u2, u1} α σ _inst_1 _inst_3 g)\nCase conversion may be inaccurate. Consider using '#align primrec.of_eq Primrec.of_eqₓ'. -/\ntheorem of_eq {f g : α → σ} (hf : Primrec f) (H : ∀ n, f n = g n) : Primrec g :=\n  (funext H : f = g) ▸ hf\n#align primrec.of_eq Primrec.of_eq\n\n/- warning: primrec.const -> Primrec.const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_3 : Primcodable.{u2} σ] (x : σ), Primrec.{u1, u2} α σ _inst_1 _inst_3 (fun (a : α) => x)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_3 : Primcodable.{u1} σ] (x : σ), Primrec.{u2, u1} α σ _inst_1 _inst_3 (fun (a : α) => x)\nCase conversion may be inaccurate. Consider using '#align primrec.const Primrec.constₓ'. -/\ntheorem const (x : σ) : Primrec fun a : α => x :=\n  ((cases1 0 (const (encode x).succ)).comp (Primcodable.prim α)).of_eq fun n => by\n    cases decode α n <;> rfl\n#align primrec.const Primrec.const\n\n#print Primrec.id /-\nprotected theorem id : Primrec (@id α) :=\n  (Primcodable.prim α).of_eq <| by simp\n#align primrec.id Primrec.id\n-/\n\n/- warning: primrec.comp -> Primrec.comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : β -> σ} {g : α -> β}, (Primrec.{u2, u3} β σ _inst_2 _inst_3 f) -> (Primrec.{u1, u2} α β _inst_1 _inst_2 g) -> (Primrec.{u1, u3} α σ _inst_1 _inst_3 (fun (a : α) => f (g a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u3} β] [_inst_3 : Primcodable.{u2} σ] {f : β -> σ} {g : α -> β}, (Primrec.{u3, u2} β σ _inst_2 _inst_3 f) -> (Primrec.{u1, u3} α β _inst_1 _inst_2 g) -> (Primrec.{u1, u2} α σ _inst_1 _inst_3 (fun (a : α) => f (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.comp Primrec.compₓ'. -/\ntheorem comp {f : β → σ} {g : α → β} (hf : Primrec f) (hg : Primrec g) : Primrec fun a => f (g a) :=\n  ((cases1 0 (hf.comp <| pred.comp hg)).comp (Primcodable.prim α)).of_eq fun n =>\n    by\n    cases decode α n; · rfl\n    simp [encodek]\n#align primrec.comp Primrec.comp\n\n#print Primrec.succ /-\ntheorem succ : Primrec Nat.succ :=\n  nat_iff.2 Nat.Primrec.succ\n#align primrec.succ Primrec.succ\n-/\n\n#print Primrec.pred /-\ntheorem pred : Primrec Nat.pred :=\n  nat_iff.2 Nat.Primrec.pred\n#align primrec.pred Primrec.pred\n-/\n\n/- warning: primrec.encode_iff -> Primrec.encode_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_3 : Primcodable.{u2} σ] {f : α -> σ}, Iff (Primrec.{u1, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) => Encodable.encode.{u2} σ (Primcodable.toEncodable.{u2} σ _inst_3) (f a))) (Primrec.{u1, u2} α σ _inst_1 _inst_3 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_3 : Primcodable.{u1} σ] {f : α -> σ}, Iff (Primrec.{u2, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) => Encodable.encode.{u1} σ (Primcodable.toEncodable.{u1} σ _inst_3) (f a))) (Primrec.{u2, u1} α σ _inst_1 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec.encode_iff Primrec.encode_iffₓ'. -/\ntheorem encode_iff {f : α → σ} : (Primrec fun a => encode (f a)) ↔ Primrec f :=\n  ⟨fun h => Nat.Primrec.of_eq h fun n => by cases decode α n <;> rfl, Primrec.encode.comp⟩\n#align primrec.encode_iff Primrec.encode_iff\n\n/- warning: primrec.of_nat_iff -> Primrec.ofNat_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_4 : Denumerable.{u1} α] [_inst_5 : Primcodable.{u2} β] {f : α -> β}, Iff (Primrec.{u1, u2} α β (Primcodable.ofDenumerable.{u1} α _inst_4) _inst_5 f) (Primrec.{0, u2} Nat β (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_5 (fun (n : Nat) => f (Denumerable.ofNat.{u1} α _inst_4 n)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_4 : Denumerable.{u2} α] [_inst_5 : Primcodable.{u1} β] {f : α -> β}, Iff (Primrec.{u2, u1} α β (Primcodable.ofDenumerable.{u2} α _inst_4) _inst_5 f) (Primrec.{0, u1} Nat β (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_5 (fun (n : Nat) => f (Denumerable.ofNat.{u2} α _inst_4 n)))\nCase conversion may be inaccurate. Consider using '#align primrec.of_nat_iff Primrec.ofNat_iffₓ'. -/\ntheorem ofNat_iff {α β} [Denumerable α] [Primcodable β] {f : α → β} :\n    Primrec f ↔ Primrec fun n => f (ofNat α n) :=\n  dom_denumerable.trans <| nat_iff.symm.trans encode_iff\n#align primrec.of_nat_iff Primrec.ofNat_iff\n\n#print Primrec.ofNat /-\nprotected theorem ofNat (α) [Denumerable α] : Primrec (ofNat α) :=\n  ofNat_iff.1 Primrec.id\n#align primrec.of_nat Primrec.ofNat\n-/\n\n/- warning: primrec.option_some_iff -> Primrec.option_some_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_3 : Primcodable.{u2} σ] {f : α -> σ}, Iff (Primrec.{u1, u2} α (Option.{u2} σ) _inst_1 (Primcodable.option.{u2} σ _inst_3) (fun (a : α) => Option.some.{u2} σ (f a))) (Primrec.{u1, u2} α σ _inst_1 _inst_3 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_3 : Primcodable.{u1} σ] {f : α -> σ}, Iff (Primrec.{u2, u1} α (Option.{u1} σ) _inst_1 (Primcodable.option.{u1} σ _inst_3) (fun (a : α) => Option.some.{u1} σ (f a))) (Primrec.{u2, u1} α σ _inst_1 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec.option_some_iff Primrec.option_some_iffₓ'. -/\ntheorem option_some_iff {f : α → σ} : (Primrec fun a => some (f a)) ↔ Primrec f :=\n  ⟨fun h => encode_iff.1 <| pred.comp <| encode_iff.2 h, option_some.comp⟩\n#align primrec.option_some_iff Primrec.option_some_iff\n\n#print Primrec.ofEquiv /-\ntheorem ofEquiv {β} {e : β ≃ α} :\n    haveI := Primcodable.ofEquiv α e\n    Primrec e :=\n  letI : Primcodable β := Primcodable.ofEquiv α e\n  encode_iff.1 Primrec.encode\n#align primrec.of_equiv Primrec.ofEquiv\n-/\n\n#print Primrec.ofEquiv_symm /-\ntheorem ofEquiv_symm {β} {e : β ≃ α} :\n    haveI := Primcodable.ofEquiv α e\n    Primrec e.symm :=\n  letI := Primcodable.ofEquiv α e\n  encode_iff.1 (show Primrec fun a => encode (e (e.symm a)) by simp [Primrec.encode])\n#align primrec.of_equiv_symm Primrec.ofEquiv_symm\n-/\n\n/- warning: primrec.of_equiv_iff -> Primrec.ofEquiv_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_3 : Primcodable.{u2} σ] {β : Type.{u3}} (e : Equiv.{succ u3, succ u1} β α) {f : σ -> β}, Iff (Primrec.{u2, u1} σ α _inst_3 _inst_1 (fun (a : σ) => coeFn.{max 1 (max (succ u3) (succ u1)) (succ u1) (succ u3), max (succ u3) (succ u1)} (Equiv.{succ u3, succ u1} β α) (fun (_x : Equiv.{succ u3, succ u1} β α) => β -> α) (Equiv.hasCoeToFun.{succ u3, succ u1} β α) e (f a))) (Primrec.{u2, u3} σ β _inst_3 (Primcodable.ofEquiv.{u1, u3} α β _inst_1 e) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_3 : Primcodable.{u1} σ] {β : Type.{u3}} (e : Equiv.{succ u3, succ u2} β α) {f : σ -> β}, Iff (Primrec.{u1, u2} σ α _inst_3 _inst_1 (fun (a : σ) => FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u2} (Equiv.{succ u3, succ u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => α) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} β α) e (f a))) (Primrec.{u1, u3} σ β _inst_3 (Primcodable.ofEquiv.{u2, u3} α β _inst_1 e) f)\nCase conversion may be inaccurate. Consider using '#align primrec.of_equiv_iff Primrec.ofEquiv_iffₓ'. -/\ntheorem ofEquiv_iff {β} (e : β ≃ α) {f : σ → β} :\n    haveI := Primcodable.ofEquiv α e\n    (Primrec fun a => e (f a)) ↔ Primrec f :=\n  letI := Primcodable.ofEquiv α e\n  ⟨fun h => (of_equiv_symm.comp h).of_eq fun a => by simp, of_equiv.comp⟩\n#align primrec.of_equiv_iff Primrec.ofEquiv_iff\n\n/- warning: primrec.of_equiv_symm_iff -> Primrec.ofEquiv_symm_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_3 : Primcodable.{u2} σ] {β : Type.{u3}} (e : Equiv.{succ u3, succ u1} β α) {f : σ -> α}, Iff (Primrec.{u2, u3} σ β _inst_3 (Primcodable.ofEquiv.{u1, u3} α β _inst_1 e) (fun (a : σ) => coeFn.{max 1 (max (succ u1) (succ u3)) (succ u3) (succ u1), max (succ u1) (succ u3)} (Equiv.{succ u1, succ u3} α β) (fun (_x : Equiv.{succ u1, succ u3} α β) => α -> β) (Equiv.hasCoeToFun.{succ u1, succ u3} α β) (Equiv.symm.{succ u3, succ u1} β α e) (f a))) (Primrec.{u2, u1} σ α _inst_3 _inst_1 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_3 : Primcodable.{u1} σ] {β : Type.{u3}} (e : Equiv.{succ u3, succ u2} β α) {f : σ -> α}, Iff (Primrec.{u1, u3} σ β _inst_3 (Primcodable.ofEquiv.{u2, u3} α β _inst_1 e) (fun (a : σ) => FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (Equiv.{succ u2, succ u3} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => β) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u3} α β) (Equiv.symm.{succ u3, succ u2} β α e) (f a))) (Primrec.{u1, u2} σ α _inst_3 _inst_1 f)\nCase conversion may be inaccurate. Consider using '#align primrec.of_equiv_symm_iff Primrec.ofEquiv_symm_iffₓ'. -/\ntheorem ofEquiv_symm_iff {β} (e : β ≃ α) {f : σ → α} :\n    haveI := Primcodable.ofEquiv α e\n    (Primrec fun a => e.symm (f a)) ↔ Primrec f :=\n  letI := Primcodable.ofEquiv α e\n  ⟨fun h => (of_equiv.comp h).of_eq fun a => by simp, of_equiv_symm.comp⟩\n#align primrec.of_equiv_symm_iff Primrec.ofEquiv_symm_iff\n\nend Primrec\n\nnamespace Primcodable\n\nopen Nat.Primrec\n\n#print Primcodable.prod /-\ninstance prod {α β} [Primcodable α] [Primcodable β] : Primcodable (α × β) :=\n  ⟨((cases zero ((cases zero succ).comp (pair right ((Primcodable.prim β).comp left)))).comp\n          (pair right ((Primcodable.prim α).comp left))).of_eq\n      fun n => by\n      simp [Nat.unpaired]\n      cases decode α n.unpair.1; · simp\n      cases decode β n.unpair.2 <;> simp⟩\n#align primcodable.prod Primcodable.prod\n-/\n\nend Primcodable\n\nnamespace Primrec\n\nvariable {α : Type _} {σ : Type _} [Primcodable α] [Primcodable σ]\n\nopen Nat.Primrec\n\n/- warning: primrec.fst -> Primrec.fst is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_3 : Primcodable.{u1} α] [_inst_4 : Primcodable.{u2} β], Primrec.{max u1 u2, u1} (Prod.{u1, u2} α β) α (Primcodable.prod.{u1, u2} α β _inst_3 _inst_4) _inst_3 (Prod.fst.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_3 : Primcodable.{u2} α] [_inst_4 : Primcodable.{u1} β], Primrec.{max u2 u1, u2} (Prod.{u2, u1} α β) α (Primcodable.prod.{u2, u1} α β _inst_3 _inst_4) _inst_3 (Prod.fst.{u2, u1} α β)\nCase conversion may be inaccurate. Consider using '#align primrec.fst Primrec.fstₓ'. -/\ntheorem fst {α β} [Primcodable α] [Primcodable β] : Primrec (@Prod.fst α β) :=\n  ((cases zero\n            ((cases zero (Nat.Primrec.succ.comp left)).comp\n              (pair right ((Primcodable.prim β).comp left)))).comp\n        (pair right ((Primcodable.prim α).comp left))).of_eq\n    fun n => by\n    simp\n    cases decode α n.unpair.1 <;> simp\n    cases decode β n.unpair.2 <;> simp\n#align primrec.fst Primrec.fst\n\n/- warning: primrec.snd -> Primrec.snd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_3 : Primcodable.{u1} α] [_inst_4 : Primcodable.{u2} β], Primrec.{max u1 u2, u2} (Prod.{u1, u2} α β) β (Primcodable.prod.{u1, u2} α β _inst_3 _inst_4) _inst_4 (Prod.snd.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_3 : Primcodable.{u2} α] [_inst_4 : Primcodable.{u1} β], Primrec.{max u2 u1, u1} (Prod.{u2, u1} α β) β (Primcodable.prod.{u2, u1} α β _inst_3 _inst_4) _inst_4 (Prod.snd.{u2, u1} α β)\nCase conversion may be inaccurate. Consider using '#align primrec.snd Primrec.sndₓ'. -/\ntheorem snd {α β} [Primcodable α] [Primcodable β] : Primrec (@Prod.snd α β) :=\n  ((cases zero\n            ((cases zero (Nat.Primrec.succ.comp right)).comp\n              (pair right ((Primcodable.prim β).comp left)))).comp\n        (pair right ((Primcodable.prim α).comp left))).of_eq\n    fun n => by\n    simp\n    cases decode α n.unpair.1 <;> simp\n    cases decode β n.unpair.2 <;> simp\n#align primrec.snd Primrec.snd\n\n/- warning: primrec.pair -> Primrec.pair is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : Primcodable.{u1} α] [_inst_4 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u3} γ] {f : α -> β} {g : α -> γ}, (Primrec.{u1, u2} α β _inst_3 _inst_4 f) -> (Primrec.{u1, u3} α γ _inst_3 _inst_5 g) -> (Primrec.{u1, max u2 u3} α (Prod.{u2, u3} β γ) _inst_3 (Primcodable.prod.{u2, u3} β γ _inst_4 _inst_5) (fun (a : α) => Prod.mk.{u2, u3} β γ (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : Primcodable.{u3} α] [_inst_4 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u1} γ] {f : α -> β} {g : α -> γ}, (Primrec.{u3, u2} α β _inst_3 _inst_4 f) -> (Primrec.{u3, u1} α γ _inst_3 _inst_5 g) -> (Primrec.{u3, max u1 u2} α (Prod.{u2, u1} β γ) _inst_3 (Primcodable.prod.{u2, u1} β γ _inst_4 _inst_5) (fun (a : α) => Prod.mk.{u2, u1} β γ (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.pair Primrec.pairₓ'. -/\ntheorem pair {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {f : α → β} {g : α → γ}\n    (hf : Primrec f) (hg : Primrec g) : Primrec fun a => (f a, g a) :=\n  ((cases1 0\n            (Nat.Primrec.succ.comp <|\n              pair (Nat.Primrec.pred.comp hf) (Nat.Primrec.pred.comp hg))).comp\n        (Primcodable.prim α)).of_eq\n    fun n => by cases decode α n <;> simp [encodek] <;> rfl\n#align primrec.pair Primrec.pair\n\n#print Primrec.unpair /-\ntheorem unpair : Primrec Nat.unpair :=\n  (pair (nat_iff.2 Nat.Primrec.left) (nat_iff.2 Nat.Primrec.right)).of_eq fun n => by simp\n#align primrec.unpair Primrec.unpair\n-/\n\n#print Primrec.list_get?₁ /-\ntheorem list_get?₁ : ∀ l : List α, Primrec l.get?\n  | [] => dom_denumerable.2 zero\n  | a :: l =>\n    dom_denumerable.2 <|\n      (cases1 (encode a).succ <| dom_denumerable.1 <| list_nth₁ l).of_eq fun n => by\n        cases n <;> simp\n#align primrec.list_nth₁ Primrec.list_get?₁\n-/\n\nend Primrec\n\n#print Primrec₂ /-\n/-- `primrec₂ f` means `f` is a binary primitive recursive function.\n  This is technically unnecessary since we can always curry all\n  the arguments together, but there are enough natural two-arg\n  functions that it is convenient to express this directly. -/\ndef Primrec₂ {α β σ} [Primcodable α] [Primcodable β] [Primcodable σ] (f : α → β → σ) :=\n  Primrec fun p : α × β => f p.1 p.2\n#align primrec₂ Primrec₂\n-/\n\n#print PrimrecPred /-\n/-- `primrec_pred p` means `p : α → Prop` is a (decidable)\n  primitive recursive predicate, which is to say that\n  `to_bool ∘ p : α → bool` is primitive recursive. -/\ndef PrimrecPred {α} [Primcodable α] (p : α → Prop) [DecidablePred p] :=\n  Primrec fun a => decide (p a)\n#align primrec_pred PrimrecPred\n-/\n\n#print PrimrecRel /-\n/-- `primrec_rel p` means `p : α → β → Prop` is a (decidable)\n  primitive recursive relation, which is to say that\n  `to_bool ∘ p : α → β → bool` is primitive recursive. -/\ndef PrimrecRel {α β} [Primcodable α] [Primcodable β] (s : α → β → Prop)\n    [∀ a b, Decidable (s a b)] :=\n  Primrec₂ fun a b => decide (s a b)\n#align primrec_rel PrimrecRel\n-/\n\nnamespace Primrec₂\n\nvariable {α : Type _} {β : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable σ]\n\n/- warning: primrec₂.of_eq -> Primrec₂.of_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : α -> β -> σ} {g : α -> β -> σ}, (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 f) -> (forall (a : α) (b : β), Eq.{succ u3} σ (f a b) (g a b)) -> (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 g)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] {f : α -> β -> σ} {g : α -> β -> σ}, (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 f) -> (forall (a : α) (b : β), Eq.{succ u1} σ (f a b) (g a b)) -> (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 g)\nCase conversion may be inaccurate. Consider using '#align primrec₂.of_eq Primrec₂.of_eqₓ'. -/\ntheorem of_eq {f g : α → β → σ} (hg : Primrec₂ f) (H : ∀ a b, f a b = g a b) : Primrec₂ g :=\n  (by funext a b <;> apply H : f = g) ▸ hg\n#align primrec₂.of_eq Primrec₂.of_eq\n\n/- warning: primrec₂.const -> Primrec₂.const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] (x : σ), Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 (fun (a : α) (b : β) => x)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] (x : σ), Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 (fun (a : α) (b : β) => x)\nCase conversion may be inaccurate. Consider using '#align primrec₂.const Primrec₂.constₓ'. -/\ntheorem const (x : σ) : Primrec₂ fun (a : α) (b : β) => x :=\n  Primrec.const _\n#align primrec₂.const Primrec₂.const\n\n/- warning: primrec₂.pair -> Primrec₂.pair is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β], Primrec₂.{u1, u2, max u1 u2} α β (Prod.{u1, u2} α β) _inst_1 _inst_2 (Primcodable.prod.{u1, u2} α β _inst_1 _inst_2) (Prod.mk.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β], Primrec₂.{u2, u1, max u2 u1} α β (Prod.{u2, u1} α β) _inst_1 _inst_2 (Primcodable.prod.{u2, u1} α β _inst_1 _inst_2) (Prod.mk.{u2, u1} α β)\nCase conversion may be inaccurate. Consider using '#align primrec₂.pair Primrec₂.pairₓ'. -/\nprotected theorem pair : Primrec₂ (@Prod.mk α β) :=\n  Primrec.pair Primrec.fst Primrec.snd\n#align primrec₂.pair Primrec₂.pair\n\n/- warning: primrec₂.left -> Primrec₂.left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β], Primrec₂.{u1, u2, u1} α β α _inst_1 _inst_2 _inst_1 (fun (a : α) (b : β) => a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β], Primrec₂.{u2, u1, u2} α β α _inst_1 _inst_2 _inst_1 (fun (a : α) (b : β) => a)\nCase conversion may be inaccurate. Consider using '#align primrec₂.left Primrec₂.leftₓ'. -/\ntheorem left : Primrec₂ fun (a : α) (b : β) => a :=\n  Primrec.fst\n#align primrec₂.left Primrec₂.left\n\n/- warning: primrec₂.right -> Primrec₂.right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β], Primrec₂.{u1, u2, u2} α β β _inst_1 _inst_2 _inst_2 (fun (a : α) (b : β) => b)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β], Primrec₂.{u2, u1, u1} α β β _inst_1 _inst_2 _inst_2 (fun (a : α) (b : β) => b)\nCase conversion may be inaccurate. Consider using '#align primrec₂.right Primrec₂.rightₓ'. -/\ntheorem right : Primrec₂ fun (a : α) (b : β) => b :=\n  Primrec.snd\n#align primrec₂.right Primrec₂.right\n\n#print Primrec₂.natPair /-\ntheorem natPair : Primrec₂ Nat.pair := by simp [Primrec₂, Primrec] <;> constructor\n#align primrec₂.mkpair Primrec₂.natPair\n-/\n\n#print Primrec₂.unpaired /-\ntheorem unpaired {f : ℕ → ℕ → α} : Primrec (Nat.unpaired f) ↔ Primrec₂ f :=\n  ⟨fun h => by simpa using h.comp mkpair, fun h => h.comp Primrec.unpair⟩\n#align primrec₂.unpaired Primrec₂.unpaired\n-/\n\n#print Primrec₂.unpaired' /-\ntheorem unpaired' {f : ℕ → ℕ → ℕ} : Nat.Primrec (Nat.unpaired f) ↔ Primrec₂ f :=\n  Primrec.nat_iff.symm.trans unpaired\n#align primrec₂.unpaired' Primrec₂.unpaired'\n-/\n\n/- warning: primrec₂.encode_iff -> Primrec₂.encode_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u1, u2, 0} α β Nat _inst_1 _inst_2 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) (b : β) => Encodable.encode.{u3} σ (Primcodable.toEncodable.{u3} σ _inst_3) (f a b))) (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 f)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u3, u2, 0} α β Nat _inst_1 _inst_2 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) (b : β) => Encodable.encode.{u1} σ (Primcodable.toEncodable.{u1} σ _inst_3) (f a b))) (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec₂.encode_iff Primrec₂.encode_iffₓ'. -/\ntheorem encode_iff {f : α → β → σ} : (Primrec₂ fun a b => encode (f a b)) ↔ Primrec₂ f :=\n  Primrec.encode_iff\n#align primrec₂.encode_iff Primrec₂.encode_iff\n\n/- warning: primrec₂.option_some_iff -> Primrec₂.option_some_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u1, u2, u3} α β (Option.{u3} σ) _inst_1 _inst_2 (Primcodable.option.{u3} σ _inst_3) (fun (a : α) (b : β) => Option.some.{u3} σ (f a b))) (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 f)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u3, u2, u1} α β (Option.{u1} σ) _inst_1 _inst_2 (Primcodable.option.{u1} σ _inst_3) (fun (a : α) (b : β) => Option.some.{u1} σ (f a b))) (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec₂.option_some_iff Primrec₂.option_some_iffₓ'. -/\ntheorem option_some_iff {f : α → β → σ} : (Primrec₂ fun a b => some (f a b)) ↔ Primrec₂ f :=\n  Primrec.option_some_iff\n#align primrec₂.option_some_iff Primrec₂.option_some_iff\n\n/- warning: primrec₂.of_nat_iff -> Primrec₂.ofNat_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_4 : Denumerable.{u1} α] [_inst_5 : Denumerable.{u2} β] [_inst_6 : Primcodable.{u3} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u1, u2, u3} α β σ (Primcodable.ofDenumerable.{u1} α _inst_4) (Primcodable.ofDenumerable.{u2} β _inst_5) _inst_6 f) (Primrec₂.{0, 0, u3} Nat Nat σ (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_6 (fun (m : Nat) (n : Nat) => f (Denumerable.ofNat.{u1} α _inst_4 m) (Denumerable.ofNat.{u2} β _inst_5 n)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_4 : Denumerable.{u3} α] [_inst_5 : Denumerable.{u2} β] [_inst_6 : Primcodable.{u1} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u3, u2, u1} α β σ (Primcodable.ofDenumerable.{u3} α _inst_4) (Primcodable.ofDenumerable.{u2} β _inst_5) _inst_6 f) (Primrec₂.{0, 0, u1} Nat Nat σ (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_6 (fun (m : Nat) (n : Nat) => f (Denumerable.ofNat.{u3} α _inst_4 m) (Denumerable.ofNat.{u2} β _inst_5 n)))\nCase conversion may be inaccurate. Consider using '#align primrec₂.of_nat_iff Primrec₂.ofNat_iffₓ'. -/\ntheorem ofNat_iff {α β σ} [Denumerable α] [Denumerable β] [Primcodable σ] {f : α → β → σ} :\n    Primrec₂ f ↔ Primrec₂ fun m n : ℕ => f (ofNat α m) (ofNat β n) :=\n  (Primrec.ofNat_iff.trans <| by simp).trans unpaired\n#align primrec₂.of_nat_iff Primrec₂.ofNat_iff\n\n/- warning: primrec₂.uncurry -> Primrec₂.uncurry is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : α -> β -> σ}, Iff (Primrec.{max u1 u2, u3} (Prod.{u1, u2} α β) σ (Primcodable.prod.{u1, u2} α β _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} α β σ f)) (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u3} β] [_inst_3 : Primcodable.{u1} σ] {f : α -> β -> σ}, Iff (Primrec.{max u3 u2, u1} (Prod.{u2, u3} α β) σ (Primcodable.prod.{u2, u3} α β _inst_1 _inst_2) _inst_3 (Function.uncurry.{u2, u3, u1} α β σ f)) (Primrec₂.{u2, u3, u1} α β σ _inst_1 _inst_2 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec₂.uncurry Primrec₂.uncurryₓ'. -/\ntheorem uncurry {f : α → β → σ} : Primrec (Function.uncurry f) ↔ Primrec₂ f := by\n  rw [show Function.uncurry f = fun p : α × β => f p.1 p.2 from funext fun ⟨a, b⟩ => rfl] <;> rfl\n#align primrec₂.uncurry Primrec₂.uncurry\n\n/- warning: primrec₂.curry -> Primrec₂.curry is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : (Prod.{u1, u2} α β) -> σ}, Iff (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 (Function.curry.{u1, u2, u3} α β σ f)) (Primrec.{max u1 u2, u3} (Prod.{u1, u2} α β) σ (Primcodable.prod.{u1, u2} α β _inst_1 _inst_2) _inst_3 f)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] {f : (Prod.{u3, u2} α β) -> σ}, Iff (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 (Function.curry.{u3, u2, u1} α β σ f)) (Primrec.{max u3 u2, u1} (Prod.{u3, u2} α β) σ (Primcodable.prod.{u3, u2} α β _inst_1 _inst_2) _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec₂.curry Primrec₂.curryₓ'. -/\ntheorem curry {f : α × β → σ} : Primrec₂ (Function.curry f) ↔ Primrec f := by\n  rw [← uncurry, Function.uncurry_curry]\n#align primrec₂.curry Primrec₂.curry\n\nend Primrec₂\n\nsection Comp\n\nvariable {α : Type _} {β : Type _} {γ : Type _} {δ : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable γ] [Primcodable δ] [Primcodable σ]\n\n/- warning: primrec.comp₂ -> Primrec.comp₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {σ : Type.{u4}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} γ] [_inst_5 : Primcodable.{u4} σ] {f : γ -> σ} {g : α -> β -> γ}, (Primrec.{u3, u4} γ σ _inst_3 _inst_5 f) -> (Primrec₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g) -> (Primrec₂.{u1, u2, u4} α β σ _inst_1 _inst_2 _inst_5 (fun (a : α) (b : β) => f (g a b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u4}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] [_inst_3 : Primcodable.{u4} γ] [_inst_5 : Primcodable.{u3} σ] {f : γ -> σ} {g : α -> β -> γ}, (Primrec.{u4, u3} γ σ _inst_3 _inst_5 f) -> (Primrec₂.{u2, u1, u4} α β γ _inst_1 _inst_2 _inst_3 g) -> (Primrec₂.{u2, u1, u3} α β σ _inst_1 _inst_2 _inst_5 (fun (a : α) (b : β) => f (g a b)))\nCase conversion may be inaccurate. Consider using '#align primrec.comp₂ Primrec.comp₂ₓ'. -/\ntheorem Primrec.comp₂ {f : γ → σ} {g : α → β → γ} (hf : Primrec f) (hg : Primrec₂ g) :\n    Primrec₂ fun a b => f (g a b) :=\n  hf.comp hg\n#align primrec.comp₂ Primrec.comp₂\n\n/- warning: primrec₂.comp -> Primrec₂.comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {σ : Type.{u4}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} γ] [_inst_5 : Primcodable.{u4} σ] {f : β -> γ -> σ} {g : α -> β} {h : α -> γ}, (Primrec₂.{u2, u3, u4} β γ σ _inst_2 _inst_3 _inst_5 f) -> (Primrec.{u1, u2} α β _inst_1 _inst_2 g) -> (Primrec.{u1, u3} α γ _inst_1 _inst_3 h) -> (Primrec.{u1, u4} α σ _inst_1 _inst_5 (fun (a : α) => f (g a) (h a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u4}} {γ : Type.{u3}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u4} β] [_inst_3 : Primcodable.{u3} γ] [_inst_5 : Primcodable.{u2} σ] {f : β -> γ -> σ} {g : α -> β} {h : α -> γ}, (Primrec₂.{u4, u3, u2} β γ σ _inst_2 _inst_3 _inst_5 f) -> (Primrec.{u1, u4} α β _inst_1 _inst_2 g) -> (Primrec.{u1, u3} α γ _inst_1 _inst_3 h) -> (Primrec.{u1, u2} α σ _inst_1 _inst_5 (fun (a : α) => f (g a) (h a)))\nCase conversion may be inaccurate. Consider using '#align primrec₂.comp Primrec₂.compₓ'. -/\ntheorem Primrec₂.comp {f : β → γ → σ} {g : α → β} {h : α → γ} (hf : Primrec₂ f) (hg : Primrec g)\n    (hh : Primrec h) : Primrec fun a => f (g a) (h a) :=\n  hf.comp (hg.pair hh)\n#align primrec₂.comp Primrec₂.comp\n\n/- warning: primrec₂.comp₂ -> Primrec₂.comp₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {σ : Type.{u5}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} γ] [_inst_4 : Primcodable.{u4} δ] [_inst_5 : Primcodable.{u5} σ] {f : γ -> δ -> σ} {g : α -> β -> γ} {h : α -> β -> δ}, (Primrec₂.{u3, u4, u5} γ δ σ _inst_3 _inst_4 _inst_5 f) -> (Primrec₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g) -> (Primrec₂.{u1, u2, u4} α β δ _inst_1 _inst_2 _inst_4 h) -> (Primrec₂.{u1, u2, u5} α β σ _inst_1 _inst_2 _inst_5 (fun (a : α) (b : β) => f (g a b) (h a b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u5}} {δ : Type.{u4}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] [_inst_3 : Primcodable.{u5} γ] [_inst_4 : Primcodable.{u4} δ] [_inst_5 : Primcodable.{u3} σ] {f : γ -> δ -> σ} {g : α -> β -> γ} {h : α -> β -> δ}, (Primrec₂.{u5, u4, u3} γ δ σ _inst_3 _inst_4 _inst_5 f) -> (Primrec₂.{u2, u1, u5} α β γ _inst_1 _inst_2 _inst_3 g) -> (Primrec₂.{u2, u1, u4} α β δ _inst_1 _inst_2 _inst_4 h) -> (Primrec₂.{u2, u1, u3} α β σ _inst_1 _inst_2 _inst_5 (fun (a : α) (b : β) => f (g a b) (h a b)))\nCase conversion may be inaccurate. Consider using '#align primrec₂.comp₂ Primrec₂.comp₂ₓ'. -/\ntheorem Primrec₂.comp₂ {f : γ → δ → σ} {g : α → β → γ} {h : α → β → δ} (hf : Primrec₂ f)\n    (hg : Primrec₂ g) (hh : Primrec₂ h) : Primrec₂ fun a b => f (g a b) (h a b) :=\n  hf.comp hg hh\n#align primrec₂.comp₂ Primrec₂.comp₂\n\n#print PrimrecPred.comp /-\ntheorem PrimrecPred.comp {p : β → Prop} [DecidablePred p] {f : α → β} :\n    PrimrecPred p → Primrec f → PrimrecPred fun a => p (f a) :=\n  Primrec.comp\n#align primrec_pred.comp PrimrecPred.comp\n-/\n\n/- warning: primrec_rel.comp -> PrimrecRel.comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} γ] {R : β -> γ -> Prop} [_inst_6 : forall (a : β) (b : γ), Decidable (R a b)] {f : α -> β} {g : α -> γ}, (PrimrecRel.{u2, u3} β γ _inst_2 _inst_3 R (fun (a : β) (b : γ) => _inst_6 a b)) -> (Primrec.{u1, u2} α β _inst_1 _inst_2 f) -> (Primrec.{u1, u3} α γ _inst_1 _inst_3 g) -> (PrimrecPred.{u1} α _inst_1 (fun (a : α) => R (f a) (g a)) (fun (a : α) => _inst_6 (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u3} β] [_inst_3 : Primcodable.{u2} γ] {R : β -> γ -> Prop} [_inst_6 : forall (a : β) (b : γ), Decidable (R a b)] {f : α -> β} {g : α -> γ}, (PrimrecRel.{u3, u2} β γ _inst_2 _inst_3 R (fun (a : β) (b : γ) => _inst_6 a b)) -> (Primrec.{u1, u3} α β _inst_1 _inst_2 f) -> (Primrec.{u1, u2} α γ _inst_1 _inst_3 g) -> (PrimrecPred.{u1} α _inst_1 (fun (a : α) => R (f a) (g a)) (fun (a : α) => _inst_6 (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec_rel.comp PrimrecRel.compₓ'. -/\ntheorem PrimrecRel.comp {R : β → γ → Prop} [∀ a b, Decidable (R a b)] {f : α → β} {g : α → γ} :\n    PrimrecRel R → Primrec f → Primrec g → PrimrecPred fun a => R (f a) (g a) :=\n  Primrec₂.comp\n#align primrec_rel.comp PrimrecRel.comp\n\n/- warning: primrec_rel.comp₂ -> PrimrecRel.comp₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} γ] [_inst_4 : Primcodable.{u4} δ] {R : γ -> δ -> Prop} [_inst_6 : forall (a : γ) (b : δ), Decidable (R a b)] {f : α -> β -> γ} {g : α -> β -> δ}, (PrimrecRel.{u3, u4} γ δ _inst_3 _inst_4 R (fun (a : γ) (b : δ) => _inst_6 a b)) -> (Primrec₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f) -> (Primrec₂.{u1, u2, u4} α β δ _inst_1 _inst_2 _inst_4 g) -> (PrimrecRel.{u1, u2} α β _inst_1 _inst_2 (fun (a : α) (b : β) => R (f a b) (g a b)) (fun (a : α) (b : β) => _inst_6 (f a b) (g a b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u4}} {δ : Type.{u3}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] [_inst_3 : Primcodable.{u4} γ] [_inst_4 : Primcodable.{u3} δ] {R : γ -> δ -> Prop} [_inst_6 : forall (a : γ) (b : δ), Decidable (R a b)] {f : α -> β -> γ} {g : α -> β -> δ}, (PrimrecRel.{u4, u3} γ δ _inst_3 _inst_4 R (fun (a : γ) (b : δ) => _inst_6 a b)) -> (Primrec₂.{u2, u1, u4} α β γ _inst_1 _inst_2 _inst_3 f) -> (Primrec₂.{u2, u1, u3} α β δ _inst_1 _inst_2 _inst_4 g) -> (PrimrecRel.{u2, u1} α β _inst_1 _inst_2 (fun (a : α) (b : β) => R (f a b) (g a b)) (fun (a : α) (b : β) => _inst_6 (f a b) (g a b)))\nCase conversion may be inaccurate. Consider using '#align primrec_rel.comp₂ PrimrecRel.comp₂ₓ'. -/\ntheorem PrimrecRel.comp₂ {R : γ → δ → Prop} [∀ a b, Decidable (R a b)] {f : α → β → γ}\n    {g : α → β → δ} :\n    PrimrecRel R → Primrec₂ f → Primrec₂ g → PrimrecRel fun a b => R (f a b) (g a b) :=\n  PrimrecRel.comp\n#align primrec_rel.comp₂ PrimrecRel.comp₂\n\nend Comp\n\n#print PrimrecPred.of_eq /-\ntheorem PrimrecPred.of_eq {α} [Primcodable α] {p q : α → Prop} [DecidablePred p] [DecidablePred q]\n    (hp : PrimrecPred p) (H : ∀ a, p a ↔ q a) : PrimrecPred q :=\n  Primrec.of_eq hp fun a => Bool.decide_congr (H a)\n#align primrec_pred.of_eq PrimrecPred.of_eq\n-/\n\n/- warning: primrec_rel.of_eq -> PrimrecRel.of_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {r : α -> β -> Prop} {s : α -> β -> Prop} [_inst_3 : forall (a : α) (b : β), Decidable (r a b)] [_inst_4 : forall (a : α) (b : β), Decidable (s a b)], (PrimrecRel.{u1, u2} α β _inst_1 _inst_2 r (fun (a : α) (b : β) => _inst_3 a b)) -> (forall (a : α) (b : β), Iff (r a b) (s a b)) -> (PrimrecRel.{u1, u2} α β _inst_1 _inst_2 s (fun (a : α) (b : β) => _inst_4 a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] {r : α -> β -> Prop} {s : α -> β -> Prop} [_inst_3 : forall (a : α) (b : β), Decidable (r a b)] [_inst_4 : forall (a : α) (b : β), Decidable (s a b)], (PrimrecRel.{u2, u1} α β _inst_1 _inst_2 r (fun (a : α) (b : β) => _inst_3 a b)) -> (forall (a : α) (b : β), Iff (r a b) (s a b)) -> (PrimrecRel.{u2, u1} α β _inst_1 _inst_2 s (fun (a : α) (b : β) => _inst_4 a b))\nCase conversion may be inaccurate. Consider using '#align primrec_rel.of_eq PrimrecRel.of_eqₓ'. -/\ntheorem PrimrecRel.of_eq {α β} [Primcodable α] [Primcodable β] {r s : α → β → Prop}\n    [∀ a b, Decidable (r a b)] [∀ a b, Decidable (s a b)] (hr : PrimrecRel r)\n    (H : ∀ a b, r a b ↔ s a b) : PrimrecRel s :=\n  Primrec₂.of_eq hr fun a b => Bool.decide_congr (H a b)\n#align primrec_rel.of_eq PrimrecRel.of_eq\n\nnamespace Primrec₂\n\nvariable {α : Type _} {β : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable σ]\n\nopen Nat.Primrec\n\n/- warning: primrec₂.swap -> Primrec₂.swap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : α -> β -> σ}, (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 f) -> (Primrec₂.{u2, u1, u3} β α σ _inst_2 _inst_1 _inst_3 (Function.swap.{succ u1, succ u2, succ u3} α β (fun (ᾰ : α) (ᾰ : β) => σ) f))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] {f : α -> β -> σ}, (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 f) -> (Primrec₂.{u2, u3, u1} β α σ _inst_2 _inst_1 _inst_3 (Function.swap.{succ u3, succ u2, succ u1} α β (fun (ᾰ : α) (ᾰ : β) => σ) f))\nCase conversion may be inaccurate. Consider using '#align primrec₂.swap Primrec₂.swapₓ'. -/\ntheorem swap {f : α → β → σ} (h : Primrec₂ f) : Primrec₂ (swap f) :=\n  h.comp₂ Primrec₂.right Primrec₂.left\n#align primrec₂.swap Primrec₂.swap\n\n/- warning: primrec₂.nat_iff -> Primrec₂.nat_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 f) (Nat.Primrec (Nat.unpaired.{1} Nat (fun (m : Nat) (n : Nat) => Encodable.encode.{u3} (Option.{u3} σ) (Option.encodable.{u3} σ (Primcodable.toEncodable.{u3} σ _inst_3)) (Option.bind.{u1, u3} α σ (Encodable.decode.{u1} α (Primcodable.toEncodable.{u1} α _inst_1) m) (fun (a : α) => Option.map.{u2, u3} β σ (f a) (Encodable.decode.{u2} β (Primcodable.toEncodable.{u2} β _inst_2) n))))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 f) (Nat.Primrec (Nat.unpaired.{1} Nat (fun (m : Nat) (n : Nat) => Encodable.encode.{u1} (Option.{u1} σ) (Option.encodable.{u1} σ (Primcodable.toEncodable.{u1} σ _inst_3)) (Option.bind.{u3, u1} α σ (Encodable.decode.{u3} α (Primcodable.toEncodable.{u3} α _inst_1) m) (fun (a : α) => Option.map.{u2, u1} β σ (f a) (Encodable.decode.{u2} β (Primcodable.toEncodable.{u2} β _inst_2) n))))))\nCase conversion may be inaccurate. Consider using '#align primrec₂.nat_iff Primrec₂.nat_iffₓ'. -/\ntheorem nat_iff {f : α → β → σ} :\n    Primrec₂ f ↔\n      Nat.Primrec\n        (Nat.unpaired fun m n : ℕ => encode <| (decode α m).bind fun a => (decode β n).map (f a)) :=\n  by\n  have :\n    ∀ (a : Option α) (b : Option β),\n      Option.map (fun p : α × β => f p.1 p.2)\n          (Option.bind a fun a : α => Option.map (Prod.mk a) b) =\n        Option.bind a fun a => Option.map (f a) b :=\n    by intros <;> cases a <;> [rfl, · cases b <;> rfl]\n  simp [Primrec₂, Primrec, this]\n#align primrec₂.nat_iff Primrec₂.nat_iff\n\n/- warning: primrec₂.nat_iff' -> Primrec₂.nat_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_3 f) (Primrec₂.{0, 0, u3} Nat Nat (Option.{u3} σ) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} σ _inst_3) (fun (m : Nat) (n : Nat) => Option.bind.{u1, u3} α σ (Encodable.decode.{u1} α (Primcodable.toEncodable.{u1} α _inst_1) m) (fun (a : α) => Option.map.{u2, u3} β σ (f a) (Encodable.decode.{u2} β (Primcodable.toEncodable.{u2} β _inst_2) n))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u1} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_3 f) (Primrec₂.{0, 0, u1} Nat Nat (Option.{u1} σ) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u1} σ _inst_3) (fun (m : Nat) (n : Nat) => Option.bind.{u3, u1} α σ (Encodable.decode.{u3} α (Primcodable.toEncodable.{u3} α _inst_1) m) (fun (a : α) => Option.map.{u2, u1} β σ (f a) (Encodable.decode.{u2} β (Primcodable.toEncodable.{u2} β _inst_2) n))))\nCase conversion may be inaccurate. Consider using '#align primrec₂.nat_iff' Primrec₂.nat_iff'ₓ'. -/\ntheorem nat_iff' {f : α → β → σ} :\n    Primrec₂ f ↔\n      Primrec₂ fun m n : ℕ => Option.bind (decode α m) fun a => Option.map (f a) (decode β n) :=\n  nat_iff.trans <| unpaired'.trans encode_iff\n#align primrec₂.nat_iff' Primrec₂.nat_iff'\n\nend Primrec₂\n\nnamespace Primrec\n\nvariable {α : Type _} {β : Type _} {γ : Type _} {δ : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable γ] [Primcodable δ] [Primcodable σ]\n\n/- warning: primrec.to₂ -> Primrec.to₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u3} σ] {f : (Prod.{u1, u2} α β) -> σ}, (Primrec.{max u1 u2, u3} (Prod.{u1, u2} α β) σ (Primcodable.prod.{u1, u2} α β _inst_1 _inst_2) _inst_5 f) -> (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_5 (fun (a : α) (b : β) => f (Prod.mk.{u1, u2} α β a b)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u1} σ] {f : (Prod.{u3, u2} α β) -> σ}, (Primrec.{max u3 u2, u1} (Prod.{u3, u2} α β) σ (Primcodable.prod.{u3, u2} α β _inst_1 _inst_2) _inst_5 f) -> (Primrec₂.{u3, u2, u1} α β σ _inst_1 _inst_2 _inst_5 (fun (a : α) (b : β) => f (Prod.mk.{u3, u2} α β a b)))\nCase conversion may be inaccurate. Consider using '#align primrec.to₂ Primrec.to₂ₓ'. -/\ntheorem to₂ {f : α × β → σ} (hf : Primrec f) : Primrec₂ fun a b => f (a, b) :=\n  hf.of_eq fun ⟨a, b⟩ => rfl\n#align primrec.to₂ Primrec.to₂\n\n#print Primrec.nat_elim /-\ntheorem nat_elim {f : α → β} {g : α → ℕ × β → β} (hf : Primrec f) (hg : Primrec₂ g) :\n    Primrec₂ fun a (n : ℕ) => n.elim (f a) fun n IH => g a (n, IH) :=\n  Primrec₂.nat_iff.2 <|\n    ((Nat.Primrec.cases Nat.Primrec.zero <|\n              (Nat.Primrec.prec hf <|\n                    Nat.Primrec.comp hg <|\n                      Nat.Primrec.left.pair <|\n                        (Nat.Primrec.left.comp Nat.Primrec.right).pair <|\n                          Nat.Primrec.pred.comp <| Nat.Primrec.right.comp Nat.Primrec.right).comp <|\n                Nat.Primrec.right.pair <| Nat.Primrec.right.comp Nat.Primrec.left).comp <|\n          Nat.Primrec.id.pair <| (Primcodable.prim α).comp Nat.Primrec.left).of_eq\n      fun n => by\n      simp\n      cases' decode α n.unpair.1 with a; · rfl\n      simp [encodek]\n      induction' n.unpair.2 with m <;> simp [encodek]\n      simp [ih, encodek]\n#align primrec.nat_elim Primrec.nat_elim\n-/\n\n#print Primrec.nat_elim' /-\ntheorem nat_elim' {f : α → ℕ} {g : α → β} {h : α → ℕ × β → β} (hf : Primrec f) (hg : Primrec g)\n    (hh : Primrec₂ h) : Primrec fun a => (f a).elim (g a) fun n IH => h a (n, IH) :=\n  (nat_elim hg hh).comp Primrec.id hf\n#align primrec.nat_elim' Primrec.nat_elim'\n-/\n\n#print Primrec.nat_elim₁ /-\ntheorem nat_elim₁ {f : ℕ → α → α} (a : α) (hf : Primrec₂ f) : Primrec (Nat.rec a f) :=\n  nat_elim' Primrec.id (const a) <| comp₂ hf Primrec₂.right\n#align primrec.nat_elim₁ Primrec.nat_elim₁\n-/\n\n/- warning: primrec.nat_cases' -> Primrec.nat_cases' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {f : α -> β} {g : α -> Nat -> β}, (Primrec.{u1, u2} α β _inst_1 _inst_2 f) -> (Primrec₂.{u1, 0, u2} α Nat β _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 g) -> (Primrec₂.{u1, 0, u2} α Nat β _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 (fun (a : α) => Nat.casesOn.{succ u2} β (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] {f : α -> β} {g : α -> Nat -> β}, (Primrec.{u2, u1} α β _inst_1 _inst_2 f) -> (Primrec₂.{u2, 0, u1} α Nat β _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 g) -> (Primrec₂.{u2, 0, u1} α Nat β _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 (fun (a : α) (n : Nat) => Nat.casesOn.{succ u1} (fun (x._@.Mathlib.Computability.Primrec._hyg.4800 : Nat) => β) n (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.nat_cases' Primrec.nat_cases'ₓ'. -/\ntheorem nat_cases' {f : α → β} {g : α → ℕ → β} (hf : Primrec f) (hg : Primrec₂ g) :\n    Primrec₂ fun a => Nat.casesOn (f a) (g a) :=\n  nat_elim hf <| hg.comp₂ Primrec₂.left <| comp₂ fst Primrec₂.right\n#align primrec.nat_cases' Primrec.nat_cases'\n\n/- warning: primrec.nat_cases -> Primrec.nat_cases is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {f : α -> Nat} {g : α -> β} {h : α -> Nat -> β}, (Primrec.{u1, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u1, u2} α β _inst_1 _inst_2 g) -> (Primrec₂.{u1, 0, u2} α Nat β _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 h) -> (Primrec.{u1, u2} α β _inst_1 _inst_2 (fun (a : α) => Nat.casesOn.{succ u2} β (g a) (h a) (f a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] {f : α -> Nat} {g : α -> β} {h : α -> Nat -> β}, (Primrec.{u2, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u2, u1} α β _inst_1 _inst_2 g) -> (Primrec₂.{u2, 0, u1} α Nat β _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 h) -> (Primrec.{u2, u1} α β _inst_1 _inst_2 (fun (a : α) => Nat.casesOn.{succ u1} (fun (x._@.Mathlib.Computability.Primrec._hyg.4875 : Nat) => β) (f a) (g a) (h a)))\nCase conversion may be inaccurate. Consider using '#align primrec.nat_cases Primrec.nat_casesₓ'. -/\ntheorem nat_cases {f : α → ℕ} {g : α → β} {h : α → ℕ → β} (hf : Primrec f) (hg : Primrec g)\n    (hh : Primrec₂ h) : Primrec fun a => (f a).cases (g a) (h a) :=\n  (nat_cases' hg hh).comp Primrec.id hf\n#align primrec.nat_cases Primrec.nat_cases\n\n#print Primrec.nat_cases₁ /-\ntheorem nat_cases₁ {f : ℕ → α} (a : α) (hf : Primrec f) : Primrec (Nat.casesOn a f) :=\n  nat_cases Primrec.id (const a) (comp₂ hf Primrec₂.right)\n#align primrec.nat_cases₁ Primrec.nat_cases₁\n-/\n\n/- warning: primrec.nat_iterate -> Primrec.nat_iterate is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {f : α -> Nat} {g : α -> β} {h : α -> β -> β}, (Primrec.{u1, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u1, u2} α β _inst_1 _inst_2 g) -> (Primrec₂.{u1, u2, u2} α β β _inst_1 _inst_2 _inst_2 h) -> (Primrec.{u1, u2} α β _inst_1 _inst_2 (fun (a : α) => Nat.iterate.{succ u2} β (h a) (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] {f : α -> Nat} {g : α -> β} {h : α -> β -> β}, (Primrec.{u2, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u2, u1} α β _inst_1 _inst_2 g) -> (Primrec₂.{u2, u1, u1} α β β _inst_1 _inst_2 _inst_2 h) -> (Primrec.{u2, u1} α β _inst_1 _inst_2 (fun (a : α) => Nat.iterate.{succ u1} β (h a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.nat_iterate Primrec.nat_iterateₓ'. -/\ntheorem nat_iterate {f : α → ℕ} {g : α → β} {h : α → β → β} (hf : Primrec f) (hg : Primrec g)\n    (hh : Primrec₂ h) : Primrec fun a => (h a^[f a]) (g a) :=\n  (nat_elim' hf hg (hh.comp₂ Primrec₂.left <| snd.comp₂ Primrec₂.right)).of_eq fun a => by\n    induction f a <;> simp [*, Function.iterate_succ']\n#align primrec.nat_iterate Primrec.nat_iterate\n\n/- warning: primrec.option_cases -> Primrec.option_cases is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u3} σ] {o : α -> (Option.{u2} β)} {f : α -> σ} {g : α -> β -> σ}, (Primrec.{u1, u2} α (Option.{u2} β) _inst_1 (Primcodable.option.{u2} β _inst_2) o) -> (Primrec.{u1, u3} α σ _inst_1 _inst_5 f) -> (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u1, u3} α σ _inst_1 _inst_5 (fun (a : α) => Option.casesOn.{succ u3, u2} β (fun (_x : Option.{u2} β) => σ) (o a) (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u3} β] [_inst_5 : Primcodable.{u1} σ] {o : α -> (Option.{u3} β)} {f : α -> σ} {g : α -> β -> σ}, (Primrec.{u2, u3} α (Option.{u3} β) _inst_1 (Primcodable.option.{u3} β _inst_2) o) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 f) -> (Primrec₂.{u2, u3, u1} α β σ _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 (fun (a : α) => Option.casesOn.{succ u1, u3} β (fun (_x : Option.{u3} β) => σ) (o a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.option_cases Primrec.option_casesₓ'. -/\ntheorem option_cases {o : α → Option β} {f : α → σ} {g : α → β → σ} (ho : Primrec o)\n    (hf : Primrec f) (hg : Primrec₂ g) :\n    @Primrec _ σ _ _ fun a => Option.casesOn (o a) (f a) (g a) :=\n  encode_iff.1 <|\n    (nat_cases (encode_iff.2 ho) (encode_iff.2 hf) <|\n          pred.comp₂ <|\n            Primrec₂.encode_iff.2 <|\n              (Primrec₂.nat_iff'.1 hg).comp₂ ((@Primrec.encode α _).comp fst).to₂\n                Primrec₂.right).of_eq\n      fun a => by cases' o a with b <;> simp [encodek] <;> rfl\n#align primrec.option_cases Primrec.option_cases\n\n/- warning: primrec.option_bind -> Primrec.option_bind is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u3} σ] {f : α -> (Option.{u2} β)} {g : α -> β -> (Option.{u3} σ)}, (Primrec.{u1, u2} α (Option.{u2} β) _inst_1 (Primcodable.option.{u2} β _inst_2) f) -> (Primrec₂.{u1, u2, u3} α β (Option.{u3} σ) _inst_1 _inst_2 (Primcodable.option.{u3} σ _inst_5) g) -> (Primrec.{u1, u3} α (Option.{u3} σ) _inst_1 (Primcodable.option.{u3} σ _inst_5) (fun (a : α) => Option.bind.{u2, u3} β σ (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u3} β] [_inst_5 : Primcodable.{u2} σ] {f : α -> (Option.{u3} β)} {g : α -> β -> (Option.{u2} σ)}, (Primrec.{u1, u3} α (Option.{u3} β) _inst_1 (Primcodable.option.{u3} β _inst_2) f) -> (Primrec₂.{u1, u3, u2} α β (Option.{u2} σ) _inst_1 _inst_2 (Primcodable.option.{u2} σ _inst_5) g) -> (Primrec.{u1, u2} α (Option.{u2} σ) _inst_1 (Primcodable.option.{u2} σ _inst_5) (fun (a : α) => Option.bind.{u3, u2} β σ (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.option_bind Primrec.option_bindₓ'. -/\ntheorem option_bind {f : α → Option β} {g : α → β → Option σ} (hf : Primrec f) (hg : Primrec₂ g) :\n    Primrec fun a => (f a).bind (g a) :=\n  (option_cases hf (const none) hg).of_eq fun a => by cases f a <;> rfl\n#align primrec.option_bind Primrec.option_bind\n\n#print Primrec.option_bind₁ /-\ntheorem option_bind₁ {f : α → Option σ} (hf : Primrec f) : Primrec fun o => Option.bind o f :=\n  option_bind Primrec.id (hf.comp snd).to₂\n#align primrec.option_bind₁ Primrec.option_bind₁\n-/\n\n/- warning: primrec.option_map -> Primrec.option_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u3} σ] {f : α -> (Option.{u2} β)} {g : α -> β -> σ}, (Primrec.{u1, u2} α (Option.{u2} β) _inst_1 (Primcodable.option.{u2} β _inst_2) f) -> (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u1, u3} α (Option.{u3} σ) _inst_1 (Primcodable.option.{u3} σ _inst_5) (fun (a : α) => Option.map.{u2, u3} β σ (g a) (f a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u3} β] [_inst_5 : Primcodable.{u1} σ] {f : α -> (Option.{u3} β)} {g : α -> β -> σ}, (Primrec.{u2, u3} α (Option.{u3} β) _inst_1 (Primcodable.option.{u3} β _inst_2) f) -> (Primrec₂.{u2, u3, u1} α β σ _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u2, u1} α (Option.{u1} σ) _inst_1 (Primcodable.option.{u1} σ _inst_5) (fun (a : α) => Option.map.{u3, u1} β σ (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.option_map Primrec.option_mapₓ'. -/\ntheorem option_map {f : α → Option β} {g : α → β → σ} (hf : Primrec f) (hg : Primrec₂ g) :\n    Primrec fun a => (f a).map (g a) :=\n  option_bind hf (option_some.comp₂ hg)\n#align primrec.option_map Primrec.option_map\n\n/- warning: primrec.option_map₁ -> Primrec.option_map₁ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_5 : Primcodable.{u2} σ] {f : α -> σ}, (Primrec.{u1, u2} α σ _inst_1 _inst_5 f) -> (Primrec.{u1, u2} (Option.{u1} α) (Option.{u2} σ) (Primcodable.option.{u1} α _inst_1) (Primcodable.option.{u2} σ _inst_5) (Option.map.{u1, u2} α σ f))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_5 : Primcodable.{u1} σ] {f : α -> σ}, (Primrec.{u2, u1} α σ _inst_1 _inst_5 f) -> (Primrec.{u2, u1} (Option.{u2} α) (Option.{u1} σ) (Primcodable.option.{u2} α _inst_1) (Primcodable.option.{u1} σ _inst_5) (Option.map.{u2, u1} α σ f))\nCase conversion may be inaccurate. Consider using '#align primrec.option_map₁ Primrec.option_map₁ₓ'. -/\ntheorem option_map₁ {f : α → σ} (hf : Primrec f) : Primrec (Option.map f) :=\n  option_map Primrec.id (hf.comp snd).to₂\n#align primrec.option_map₁ Primrec.option_map₁\n\n#print Primrec.option_iget /-\ntheorem option_iget [Inhabited α] : Primrec (@Option.iget α _) :=\n  (option_cases Primrec.id (const <| @default α _) Primrec₂.right).of_eq fun o => by cases o <;> rfl\n#align primrec.option_iget Primrec.option_iget\n-/\n\n#print Primrec.option_isSome /-\ntheorem option_isSome : Primrec (@Option.isSome α) :=\n  (option_cases Primrec.id (const false) (const true).to₂).of_eq fun o => by cases o <;> rfl\n#align primrec.option_is_some Primrec.option_isSome\n-/\n\n#print Primrec.option_getD /-\ntheorem option_getD : Primrec₂ (@Option.getD α) :=\n  Primrec.of_eq (option_cases Primrec₂.left Primrec₂.right Primrec₂.right) fun ⟨o, a⟩ => by\n    cases o <;> rfl\n#align primrec.option_get_or_else Primrec.option_getD\n-/\n\n/- warning: primrec.bind_decode_iff -> Primrec.bind_decode_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u3} σ] {f : α -> β -> (Option.{u3} σ)}, Iff (Primrec₂.{u1, 0, u3} α Nat (Option.{u3} σ) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} σ _inst_5) (fun (a : α) (n : Nat) => Option.bind.{u2, u3} β σ (Encodable.decode.{u2} β (Primcodable.toEncodable.{u2} β _inst_2) n) (f a))) (Primrec₂.{u1, u2, u3} α β (Option.{u3} σ) _inst_1 _inst_2 (Primcodable.option.{u3} σ _inst_5) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] [_inst_5 : Primcodable.{u3} σ] {f : α -> β -> (Option.{u3} σ)}, Iff (Primrec₂.{u2, 0, u3} α Nat (Option.{u3} σ) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} σ _inst_5) (fun (a : α) (n : Nat) => Option.bind.{u1, u3} β σ (Encodable.decode.{u1} β (Primcodable.toEncodable.{u1} β _inst_2) n) (f a))) (Primrec₂.{u2, u1, u3} α β (Option.{u3} σ) _inst_1 _inst_2 (Primcodable.option.{u3} σ _inst_5) f)\nCase conversion may be inaccurate. Consider using '#align primrec.bind_decode_iff Primrec.bind_decode_iffₓ'. -/\ntheorem bind_decode_iff {f : α → β → Option σ} :\n    (Primrec₂ fun a n => (decode β n).bind (f a)) ↔ Primrec₂ f :=\n  ⟨fun h => by simpa [encodek] using h.comp fst ((@Primrec.encode β _).comp snd), fun h =>\n    option_bind (Primrec.decode.comp snd) <| h.comp (fst.comp fst) snd⟩\n#align primrec.bind_decode_iff Primrec.bind_decode_iff\n\n/- warning: primrec.map_decode_iff -> Primrec.map_decode_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_5 : Primcodable.{u3} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u1, 0, u3} α Nat (Option.{u3} σ) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} σ _inst_5) (fun (a : α) (n : Nat) => Option.map.{u2, u3} β σ (f a) (Encodable.decode.{u2} β (Primcodable.toEncodable.{u2} β _inst_2) n))) (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_5 f)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u3} α] [_inst_2 : Primcodable.{u1} β] [_inst_5 : Primcodable.{u2} σ] {f : α -> β -> σ}, Iff (Primrec₂.{u3, 0, u2} α Nat (Option.{u2} σ) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u2} σ _inst_5) (fun (a : α) (n : Nat) => Option.map.{u1, u2} β σ (f a) (Encodable.decode.{u1} β (Primcodable.toEncodable.{u1} β _inst_2) n))) (Primrec₂.{u3, u1, u2} α β σ _inst_1 _inst_2 _inst_5 f)\nCase conversion may be inaccurate. Consider using '#align primrec.map_decode_iff Primrec.map_decode_iffₓ'. -/\ntheorem map_decode_iff {f : α → β → σ} :\n    (Primrec₂ fun a n => (decode β n).map (f a)) ↔ Primrec₂ f :=\n  bind_decode_iff.trans Primrec₂.option_some_iff\n#align primrec.map_decode_iff Primrec.map_decode_iff\n\n#print Primrec.nat_add /-\ntheorem nat_add : Primrec₂ ((· + ·) : ℕ → ℕ → ℕ) :=\n  Primrec₂.unpaired'.1 Nat.Primrec.add\n#align primrec.nat_add Primrec.nat_add\n-/\n\n#print Primrec.nat_sub /-\ntheorem nat_sub : Primrec₂ (Sub.sub : ℕ → ℕ → ℕ) :=\n  Primrec₂.unpaired'.1 Nat.Primrec.sub\n#align primrec.nat_sub Primrec.nat_sub\n-/\n\n#print Primrec.nat_mul /-\ntheorem nat_mul : Primrec₂ ((· * ·) : ℕ → ℕ → ℕ) :=\n  Primrec₂.unpaired'.1 Nat.Primrec.mul\n#align primrec.nat_mul Primrec.nat_mul\n-/\n\n/- warning: primrec.cond -> Primrec.cond is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_5 : Primcodable.{u2} σ] {c : α -> Bool} {f : α -> σ} {g : α -> σ}, (Primrec.{u1, 0} α Bool _inst_1 Primcodable.bool c) -> (Primrec.{u1, u2} α σ _inst_1 _inst_5 f) -> (Primrec.{u1, u2} α σ _inst_1 _inst_5 g) -> (Primrec.{u1, u2} α σ _inst_1 _inst_5 (fun (a : α) => cond.{u2} σ (c a) (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_5 : Primcodable.{u1} σ] {c : α -> Bool} {f : α -> σ} {g : α -> σ}, (Primrec.{u2, 0} α Bool _inst_1 Primcodable.bool c) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 f) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 g) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 (fun (a : α) => cond.{u1} σ (c a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.cond Primrec.condₓ'. -/\ntheorem cond {c : α → Bool} {f : α → σ} {g : α → σ} (hc : Primrec c) (hf : Primrec f)\n    (hg : Primrec g) : Primrec fun a => cond (c a) (f a) (g a) :=\n  (nat_cases (encode_iff.2 hc) hg (hf.comp fst).to₂).of_eq fun a => by cases c a <;> rfl\n#align primrec.cond Primrec.cond\n\n/- warning: primrec.ite -> Primrec.ite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_5 : Primcodable.{u2} σ] {c : α -> Prop} [_inst_6 : DecidablePred.{succ u1} α c] {f : α -> σ} {g : α -> σ}, (PrimrecPred.{u1} α _inst_1 c (fun (a : α) => _inst_6 a)) -> (Primrec.{u1, u2} α σ _inst_1 _inst_5 f) -> (Primrec.{u1, u2} α σ _inst_1 _inst_5 g) -> (Primrec.{u1, u2} α σ _inst_1 _inst_5 (fun (a : α) => ite.{succ u2} σ (c a) (_inst_6 a) (f a) (g a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_5 : Primcodable.{u1} σ] {c : α -> Prop} [_inst_6 : DecidablePred.{succ u2} α c] {f : α -> σ} {g : α -> σ}, (PrimrecPred.{u2} α _inst_1 c (fun (a : α) => _inst_6 a)) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 f) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 g) -> (Primrec.{u2, u1} α σ _inst_1 _inst_5 (fun (a : α) => ite.{succ u1} σ (c a) (_inst_6 a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.ite Primrec.iteₓ'. -/\ntheorem ite {c : α → Prop} [DecidablePred c] {f : α → σ} {g : α → σ} (hc : PrimrecPred c)\n    (hf : Primrec f) (hg : Primrec g) : Primrec fun a => if c a then f a else g a := by\n  simpa using cond hc hf hg\n#align primrec.ite Primrec.ite\n\n/- warning: primrec.nat_le -> Primrec.nat_le is a dubious translation:\nlean 3 declaration is\n  PrimrecRel.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (LE.le.{0} Nat Nat.hasLe) (fun (a : Nat) (b : Nat) => Nat.decidableLe a b)\nbut is expected to have type\n  PrimrecRel.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (x._@.Mathlib.Computability.Primrec._hyg.6194 : Nat) (x._@.Mathlib.Computability.Primrec._hyg.6196 : Nat) => LE.le.{0} Nat instLENat x._@.Mathlib.Computability.Primrec._hyg.6194 x._@.Mathlib.Computability.Primrec._hyg.6196) (fun (a : Nat) (b : Nat) => Nat.decLe a b)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_le Primrec.nat_leₓ'. -/\ntheorem nat_le : PrimrecRel ((· ≤ ·) : ℕ → ℕ → Prop) :=\n  (nat_cases nat_sub (const true) (const false).to₂).of_eq fun p =>\n    by\n    dsimp [swap]\n    cases' e : p.1 - p.2 with n\n    · simp [tsub_eq_zero_iff_le.1 e]\n    · simp [not_le.2 (Nat.lt_of_sub_eq_succ e)]\n#align primrec.nat_le Primrec.nat_le\n\n/- warning: primrec.nat_min -> Primrec.nat_min is a dubious translation:\nlean 3 declaration is\n  Primrec₂.{0, 0, 0} Nat Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (LinearOrder.min.{0} Nat Nat.linearOrder)\nbut is expected to have type\n  Primrec₂.{0, 0, 0} Nat Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Min.min.{0} Nat instMinNat)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_min Primrec.nat_minₓ'. -/\ntheorem nat_min : Primrec₂ (@min ℕ _) :=\n  ite nat_le fst snd\n#align primrec.nat_min Primrec.nat_min\n\n/- warning: primrec.nat_max -> Primrec.nat_max is a dubious translation:\nlean 3 declaration is\n  Primrec₂.{0, 0, 0} Nat Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (LinearOrder.max.{0} Nat Nat.linearOrder)\nbut is expected to have type\n  Primrec₂.{0, 0, 0} Nat Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Max.max.{0} Nat Nat.instMaxNat)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_max Primrec.nat_maxₓ'. -/\ntheorem nat_max : Primrec₂ (@max ℕ _) :=\n  ite (nat_le.comp Primrec.fst Primrec.snd) snd fst\n#align primrec.nat_max Primrec.nat_max\n\n#print Primrec.dom_bool /-\ntheorem dom_bool (f : Bool → α) : Primrec f :=\n  (cond Primrec.id (const (f true)) (const (f false))).of_eq fun b => by cases b <;> rfl\n#align primrec.dom_bool Primrec.dom_bool\n-/\n\n#print Primrec.dom_bool₂ /-\ntheorem dom_bool₂ (f : Bool → Bool → α) : Primrec₂ f :=\n  (cond fst ((dom_bool (f true)).comp snd) ((dom_bool (f false)).comp snd)).of_eq fun ⟨a, b⟩ => by\n    cases a <;> rfl\n#align primrec.dom_bool₂ Primrec.dom_bool₂\n-/\n\n#print Primrec.not /-\nprotected theorem not : Primrec not :=\n  dom_bool _\n#align primrec.bnot Primrec.not\n-/\n\n#print Primrec.and /-\nprotected theorem and : Primrec₂ and :=\n  dom_bool₂ _\n#align primrec.band Primrec.and\n-/\n\n#print Primrec.or /-\nprotected theorem or : Primrec₂ or :=\n  dom_bool₂ _\n#align primrec.bor Primrec.or\n-/\n\n#print PrimrecPred.not /-\nprotected theorem not {p : α → Prop} [DecidablePred p] (hp : PrimrecPred p) :\n    PrimrecPred fun a => ¬p a :=\n  (Primrec.not.comp hp).of_eq fun n => by simp\n#align primrec.not PrimrecPred.not\n-/\n\n#print PrimrecPred.and /-\nprotected theorem and {p q : α → Prop} [DecidablePred p] [DecidablePred q] (hp : PrimrecPred p)\n    (hq : PrimrecPred q) : PrimrecPred fun a => p a ∧ q a :=\n  (Primrec.and.comp hp hq).of_eq fun n => by simp\n#align primrec.and PrimrecPred.and\n-/\n\n#print PrimrecPred.or /-\nprotected theorem or {p q : α → Prop} [DecidablePred p] [DecidablePred q] (hp : PrimrecPred p)\n    (hq : PrimrecPred q) : PrimrecPred fun a => p a ∨ q a :=\n  (Primrec.or.comp hp hq).of_eq fun n => by simp\n#align primrec.or PrimrecPred.or\n-/\n\n#print Primrec.eq /-\nprotected theorem eq [DecidableEq α] : PrimrecRel (@Eq α) :=\n  have : PrimrecRel fun a b : ℕ => a = b :=\n    (PrimrecPred.and nat_le nat_le.symm).of_eq fun a => by simp [le_antisymm_iff]\n  (this.comp₂ (Primrec.encode.comp₂ Primrec₂.left) (Primrec.encode.comp₂ Primrec₂.right)).of_eq\n    fun a b => encode_injective.eq_iff\n#align primrec.eq Primrec.eq\n-/\n\n/- warning: primrec.nat_lt -> Primrec.nat_lt is a dubious translation:\nlean 3 declaration is\n  PrimrecRel.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (LT.lt.{0} Nat Nat.hasLt) (fun (a : Nat) (b : Nat) => Nat.decidableLt a b)\nbut is expected to have type\n  PrimrecRel.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (x._@.Mathlib.Computability.Primrec._hyg.6908 : Nat) (x._@.Mathlib.Computability.Primrec._hyg.6910 : Nat) => LT.lt.{0} Nat instLTNat x._@.Mathlib.Computability.Primrec._hyg.6908 x._@.Mathlib.Computability.Primrec._hyg.6910) (fun (a : Nat) (b : Nat) => Nat.decLt a b)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_lt Primrec.nat_ltₓ'. -/\ntheorem nat_lt : PrimrecRel ((· < ·) : ℕ → ℕ → Prop) :=\n  (nat_le.comp snd fst).Not.of_eq fun p => by simp\n#align primrec.nat_lt Primrec.nat_lt\n\n/- warning: primrec.option_guard -> Primrec.option_guard is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {p : α -> β -> Prop} [_inst_6 : forall (a : α) (b : β), Decidable (p a b)], (PrimrecRel.{u1, u2} α β _inst_1 _inst_2 p (fun (a : α) (b : β) => _inst_6 a b)) -> (forall {f : α -> β}, (Primrec.{u1, u2} α β _inst_1 _inst_2 f) -> (Primrec.{u1, u2} α (Option.{u2} β) _inst_1 (Primcodable.option.{u2} β _inst_2) (fun (a : α) => Option.guard.{u2} β (p a) (fun (a_1 : β) => _inst_6 a a_1) (f a))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] {p : α -> β -> Prop} [_inst_6 : forall (a : α) (b : β), Decidable (p a b)], (PrimrecRel.{u2, u1} α β _inst_1 _inst_2 p (fun (a : α) (b : β) => _inst_6 a b)) -> (forall {f : α -> β}, (Primrec.{u2, u1} α β _inst_1 _inst_2 f) -> (Primrec.{u2, u1} α (Option.{u1} β) _inst_1 (Primcodable.option.{u1} β _inst_2) (fun (a : α) => Option.guard.{u1} β (p a) (fun (a_1 : β) => _inst_6 a a_1) (f a))))\nCase conversion may be inaccurate. Consider using '#align primrec.option_guard Primrec.option_guardₓ'. -/\ntheorem option_guard {p : α → β → Prop} [∀ a b, Decidable (p a b)] (hp : PrimrecRel p) {f : α → β}\n    (hf : Primrec f) : Primrec fun a => Option.guard (p a) (f a) :=\n  ite (hp.comp Primrec.id hf) (option_some_iff.2 hf) (const none)\n#align primrec.option_guard Primrec.option_guard\n\n/- warning: primrec.option_orelse -> Primrec.option_orElse is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Primcodable.{u1} α], Primrec₂.{u1, u1, u1} (Option.{u1} α) (Option.{u1} α) (Option.{u1} α) (Primcodable.option.{u1} α _inst_1) (Primcodable.option.{u1} α _inst_1) (Primcodable.option.{u1} α _inst_1) (HasOrelse.orelse.{u1, u1} Option.{u1} (Alternative.toHasOrelse.{u1, u1} Option.{u1} Option.alternative.{u1}) α)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Primcodable.{u1} α], Primrec₂.{u1, u1, u1} (Option.{u1} α) (Option.{u1} α) (Option.{u1} α) (Primcodable.option.{u1} α _inst_1) (Primcodable.option.{u1} α _inst_1) (Primcodable.option.{u1} α _inst_1) (fun (x._@.Mathlib.Computability.Primrec._hyg.7041 : Option.{u1} α) (x._@.Mathlib.Computability.Primrec._hyg.7043 : Option.{u1} α) => HOrElse.hOrElse.{u1, u1, u1} (Option.{u1} α) (Option.{u1} α) (Option.{u1} α) (instHOrElse.{u1} (Option.{u1} α) (Option.instOrElseOption.{u1} α)) x._@.Mathlib.Computability.Primrec._hyg.7041 (fun (x._@.Mathlib.Computability.Primrec._hyg.7053 : Unit) => x._@.Mathlib.Computability.Primrec._hyg.7043))\nCase conversion may be inaccurate. Consider using '#align primrec.option_orelse Primrec.option_orElseₓ'. -/\ntheorem option_orElse : Primrec₂ ((· <|> ·) : Option α → Option α → Option α) :=\n  (option_cases fst snd (fst.comp fst).to₂).of_eq fun ⟨o₁, o₂⟩ => by cases o₁ <;> cases o₂ <;> rfl\n#align primrec.option_orelse Primrec.option_orElse\n\n#print Primrec.decode₂ /-\nprotected theorem decode₂ : Primrec (decode₂ α) :=\n  option_bind Primrec.decode <|\n    option_guard ((@Primrec.eq _ _ Nat.decidableEq).comp (encode_iff.2 snd) (fst.comp fst)) snd\n#align primrec.decode₂ Primrec.decode₂\n-/\n\n/- warning: primrec.list_find_index₁ -> Primrec.list_findIdx₁ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {p : α -> β -> Prop} [_inst_6 : forall (a : α) (b : β), Decidable (p a b)], (PrimrecRel.{u1, u2} α β _inst_1 _inst_2 p (fun (a : α) (b : β) => _inst_6 a b)) -> (forall (l : List.{u2} β), Primrec.{u1, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) => List.findIndex.{u2} β (p a) (fun (a_1 : β) => _inst_6 a a_1) l))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β] {p : α -> β -> Bool}, (Primrec₂.{u2, u1, 0} α β Bool _inst_1 _inst_2 Primcodable.bool p) -> (forall (hp : List.{u1} β), Primrec.{u2, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) => List.findIdx.{u1} β (p a) hp))\nCase conversion may be inaccurate. Consider using '#align primrec.list_find_index₁ Primrec.list_findIdx₁ₓ'. -/\ntheorem list_findIdx₁ {p : α → β → Prop} [∀ a b, Decidable (p a b)] (hp : PrimrecRel p) :\n    ∀ l : List β, Primrec fun a => l.findIndex (p a)\n  | [] => const 0\n  | a :: l => ite (hp.comp Primrec.id (const a)) (const 0) (succ.comp (list_find_index₁ l))\n#align primrec.list_find_index₁ Primrec.list_findIdx₁\n\n#print Primrec.list_indexOf₁ /-\ntheorem list_indexOf₁ [DecidableEq α] (l : List α) : Primrec fun a => l.indexOfₓ a :=\n  list_findIdx₁ Primrec.eq l\n#align primrec.list_index_of₁ Primrec.list_indexOf₁\n-/\n\n/- warning: primrec.dom_fintype -> Primrec.dom_fintype is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_5 : Primcodable.{u2} σ] [_inst_6 : Fintype.{u1} α] (f : α -> σ), Primrec.{u1, u2} α σ _inst_1 _inst_5 f\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_5 : Primcodable.{u1} σ] [_inst_6 : Fintype.{u2} α] (f : α -> σ), Primrec.{u2, u1} α σ _inst_1 _inst_5 f\nCase conversion may be inaccurate. Consider using '#align primrec.dom_fintype Primrec.dom_fintypeₓ'. -/\ntheorem dom_fintype [Fintype α] (f : α → σ) : Primrec f :=\n  let ⟨l, nd, m⟩ := Finite.exists_univ_list α\n  option_some_iff.1 <| by\n    haveI := decidable_eq_of_encodable α\n    refine' ((list_nth₁ (l.map f)).comp (list_index_of₁ l)).of_eq fun a => _\n    rw [List.get?_map, List.nthLe_get? (List.indexOf_lt_length.2 (m _)), List.indexOf_nthLe] <;> rfl\n#align primrec.dom_fintype Primrec.dom_fintype\n\n/- warning: primrec.nat_bodd_div2 clashes with [anonymous] -> [anonymous]\nwarning: primrec.nat_bodd_div2 -> [anonymous] is a dubious translation:\nlean 3 declaration is\n  Primrec.{0, 0} Nat (Prod.{0, 0} Bool Nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.prod.{0, 0} Bool Nat Primcodable.bool (Primcodable.ofDenumerable.{0} Nat Denumerable.nat)) Nat.boddDiv2\nbut is expected to have type\n  forall {α : Type.{u}} {β : Type.{v}}, (Nat -> α -> β) -> Nat -> (List.{u} α) -> (List.{v} β)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_bodd_div2 [anonymous]ₓ'. -/\ntheorem [anonymous] : Primrec Nat.boddDiv2 :=\n  (nat_elim' Primrec.id (const (false, 0))\n        (((cond fst (pair (const false) (succ.comp snd)) (pair (const true) snd)).comp snd).comp\n            snd).to₂).of_eq\n    fun n => by\n    simp [-Nat.boddDiv2_eq]\n    induction' n with n IH; · rfl\n    simp [-Nat.boddDiv2_eq, Nat.boddDiv2, *]\n    rcases Nat.boddDiv2 n with ⟨_ | _, m⟩ <;> simp [Nat.boddDiv2]\n#align primrec.nat_bodd_div2 [anonymous]\n\n#print Primrec.nat_bodd /-\ntheorem nat_bodd : Primrec Nat.bodd :=\n  fst.comp [anonymous]\n#align primrec.nat_bodd Primrec.nat_bodd\n-/\n\n#print Primrec.nat_div2 /-\ntheorem nat_div2 : Primrec Nat.div2 :=\n  snd.comp [anonymous]\n#align primrec.nat_div2 Primrec.nat_div2\n-/\n\n/- warning: primrec.nat_bit0 -> Primrec.nat_double is a dubious translation:\nlean 3 declaration is\n  Primrec.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (bit0.{0} Nat Nat.hasAdd)\nbut is expected to have type\n  Primrec.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (n : Nat) => HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)) n)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_bit0 Primrec.nat_doubleₓ'. -/\ntheorem nat_double : Primrec (@bit0 ℕ _) :=\n  nat_add.comp Primrec.id Primrec.id\n#align primrec.nat_bit0 Primrec.nat_double\n\n/- warning: primrec.nat_bit1 -> Primrec.nat_double_succ is a dubious translation:\nlean 3 declaration is\n  Primrec.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (bit1.{0} Nat Nat.hasOne Nat.hasAdd)\nbut is expected to have type\n  Primrec.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (n : Nat) => HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)) n) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align primrec.nat_bit1 Primrec.nat_double_succₓ'. -/\ntheorem nat_double_succ : Primrec (@bit1 ℕ _ _) :=\n  nat_add.comp nat_double (const 1)\n#align primrec.nat_bit1 Primrec.nat_double_succ\n\ntheorem nat_bit : Primrec₂ Nat.bit :=\n  (cond Primrec.fst (nat_double_succ.comp Primrec.snd) (nat_double.comp Primrec.snd)).of_eq fun n =>\n    by cases n.1 <;> rfl\n#align primrec.nat_bit Primrec.nat_bit\n\n/- warning: primrec.nat_div_mod clashes with [anonymous] -> [anonymous]\nwarning: primrec.nat_div_mod -> [anonymous] is a dubious translation:\nlean 3 declaration is\n  Primrec₂.{0, 0, 0} Nat Nat (Prod.{0, 0} Nat Nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.prod.{0, 0} Nat Nat (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat)) (fun (n : Nat) (k : Nat) => Prod.mk.{0, 0} Nat Nat (HDiv.hDiv.{0, 0, 0} Nat Nat Nat (instHDiv.{0} Nat Nat.hasDiv) n k) (HMod.hMod.{0, 0, 0} Nat Nat Nat (instHMod.{0} Nat Nat.hasMod) n k))\nbut is expected to have type\n  forall {α : Type.{u}} {β : Type.{v}}, (Nat -> α -> β) -> Nat -> (List.{u} α) -> (List.{v} β)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_div_mod [anonymous]ₓ'. -/\ntheorem [anonymous] : Primrec₂ fun n k : ℕ => (n / k, n % k) :=\n  let f (a : ℕ × ℕ) : ℕ × ℕ :=\n    a.1.elim (0, 0) fun _ IH =>\n      if Nat.succ IH.2 = a.2 then (Nat.succ IH.1, 0) else (IH.1, Nat.succ IH.2)\n  have hf : Primrec f :=\n    nat_elim' fst (const (0, 0)) <|\n      ((ite ((@Primrec.eq ℕ _ _).comp (succ.comp <| snd.comp snd) fst)\n              (pair (succ.comp <| fst.comp snd) (const 0))\n              (pair (fst.comp snd) (succ.comp <| snd.comp snd))).comp\n          (pair (snd.comp fst) (snd.comp snd))).to₂\n  suffices ∀ k n, (n / k, n % k) = f (n, k) from hf.of_eq fun ⟨m, n⟩ => by simp [this]\n  fun k n =>\n  by\n  have :\n    (f (n, k)).2 + k * (f (n, k)).1 = n ∧ (0 < k → (f (n, k)).2 < k) ∧ (k = 0 → (f (n, k)).1 = 0) :=\n    by\n    induction' n with n IH\n    · exact ⟨rfl, id, fun _ => rfl⟩\n    rw [fun n : ℕ =>\n      show\n        f (n.succ, k) =\n          _root_.ite ((f (n, k)).2.succ = k) (Nat.succ (f (n, k)).1, 0)\n            ((f (n, k)).1, (f (n, k)).2.succ)\n        from rfl]\n    by_cases h : (f (n, k)).2.succ = k <;> simp [h]\n    · have := congr_arg Nat.succ IH.1\n      refine' ⟨_, fun k0 => Nat.noConfusion (h.trans k0)⟩\n      rwa [← Nat.succ_add, h, add_comm, ← Nat.mul_succ] at this\n    · exact ⟨by rw [Nat.succ_add, IH.1], fun k0 => lt_of_le_of_ne (IH.2.1 k0) h, IH.2.2⟩\n  revert this\n  cases' f (n, k) with D M\n  simp\n  intro h₁ h₂ h₃\n  cases Nat.eq_zero_or_pos k\n  · simp [h, h₃ h] at h₁⊢\n    simp [h₁]\n  · exact (Nat.div_mod_unique h).2 ⟨h₁, h₂ h⟩\n#align primrec.nat_div_mod [anonymous]\n\n#print Primrec.nat_div /-\ntheorem nat_div : Primrec₂ ((· / ·) : ℕ → ℕ → ℕ) :=\n  fst.comp₂ [anonymous]\n#align primrec.nat_div Primrec.nat_div\n-/\n\n#print Primrec.nat_mod /-\ntheorem nat_mod : Primrec₂ ((· % ·) : ℕ → ℕ → ℕ) :=\n  snd.comp₂ [anonymous]\n#align primrec.nat_mod Primrec.nat_mod\n-/\n\nend Primrec\n\nsection\n\nvariable {α : Type _} {β : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable σ]\n\nvariable (H : Nat.Primrec fun n => Encodable.encode (decode (List β) n))\n\ninclude H\n\nopen Primrec\n\nprivate def prim : Primcodable (List β) :=\n  ⟨H⟩\n#align prim prim\n\nprivate theorem list_cases' {f : α → List β} {g : α → σ} {h : α → β × List β → σ}\n    (hf :\n      haveI := prim H\n      Primrec f)\n    (hg : Primrec g)\n    (hh :\n      haveI := prim H\n      Primrec₂ h) :\n    @Primrec _ σ _ _ fun a => List.casesOn (f a) (g a) fun b l => h a (b, l) :=\n  letI := prim H\n  have :\n    @Primrec _ (Option σ) _ _ fun a =>\n      (decode (Option (β × List β)) (encode (f a))).map fun o => Option.casesOn o (g a) (h a) :=\n    ((@map_decode_iff _ (Option (β × List β)) _ _ _ _ _).2 <|\n          to₂ <|\n            option_cases snd (hg.comp fst) (hh.comp₂ (fst.comp₂ Primrec₂.left) Primrec₂.right)).comp\n      Primrec.id (encode_iff.2 hf)\n  option_some_iff.1 <| this.of_eq fun a => by cases' f a with b l <;> simp [encodek] <;> rfl\n#align list_cases' list_cases'\n\nprivate theorem list_foldl' {f : α → List β} {g : α → σ} {h : α → σ × β → σ}\n    (hf :\n      haveI := prim H\n      Primrec f)\n    (hg : Primrec g)\n    (hh :\n      haveI := prim H\n      Primrec₂ h) :\n    Primrec fun a => (f a).foldl (fun s b => h a (s, b)) (g a) :=\n  letI := prim H\n  let G (a : α) (IH : σ × List β) : σ × List β := List.casesOn IH.2 IH fun b l => (h a (IH.1, b), l)\n  let F (a : α) (n : ℕ) := (G a^[n]) (g a, f a)\n  have : Primrec fun a => (F a (encode (f a))).1 :=\n    fst.comp <|\n      nat_iterate (encode_iff.2 hf) (pair hg hf) <|\n        list_cases' H (snd.comp snd) snd <|\n          to₂ <|\n            pair (hh.comp (fst.comp fst) <| pair ((fst.comp snd).comp fst) (fst.comp snd))\n              (snd.comp snd)\n  this.of_eq fun a =>\n    by\n    have :\n      ∀ n, F a n = ((List.take n (f a)).foldl (fun s b => h a (s, b)) (g a), List.drop n (f a)) :=\n      by\n      intro\n      simp [F]\n      generalize f a = l\n      generalize g a = x\n      induction' n with n IH generalizing l x\n      · rfl\n      simp\n      cases' l with b l <;> simp [IH]\n    rw [this, List.take_all_of_le (length_le_encode _)]\n#align list_foldl' list_foldl'\n\nprivate theorem list_cons' :\n    haveI := prim H\n    Primrec₂ (@List.cons β) :=\n  letI := prim H\n  encode_iff.1 (succ.comp <| primrec₂.mkpair.comp (encode_iff.2 fst) (encode_iff.2 snd))\n#align list_cons' list_cons'\n\nprivate theorem list_reverse' :\n    haveI := prim H\n    Primrec (@List.reverse β) :=\n  letI := prim H\n  (list_foldl' H Primrec.id (const []) <| to₂ <| ((list_cons' H).comp snd fst).comp snd).of_eq\n    (suffices ∀ l r, List.foldl (fun (s : List β) (b : β) => b :: s) r l = List.reverseAux l r from\n      fun l => this l []\n    fun l => by induction l <;> simp [*, List.reverseAux])\n#align list_reverse' list_reverse'\n\nend\n\nnamespace Primcodable\n\nvariable {α : Type _} {β : Type _}\n\nvariable [Primcodable α] [Primcodable β]\n\nopen Primrec\n\n#print Primcodable.sum /-\ninstance sum : Primcodable (Sum α β) :=\n  ⟨Primrec.nat_iff.1 <|\n      (encode_iff.2\n            (cond nat_bodd\n              (((@Primrec.decode β _).comp nat_div2).option_map <|\n                to₂ <| nat_bit.comp (const true) (Primrec.encode.comp snd))\n              (((@Primrec.decode α _).comp nat_div2).option_map <|\n                to₂ <| nat_bit.comp (const false) (Primrec.encode.comp snd)))).of_eq\n        fun n =>\n        show _ = encode (decodeSum n) by\n          simp [decode_sum]\n          cases Nat.bodd n <;> simp [decode_sum]\n          · cases decode α n.div2 <;> rfl\n          · cases decode β n.div2 <;> rfl⟩\n#align primcodable.sum Primcodable.sum\n-/\n\n#print Primcodable.list /-\ninstance list : Primcodable (List α) :=\n  ⟨letI H := Primcodable.prim (List ℕ)\n    have : Primrec₂ fun (a : α) (o : Option (List ℕ)) => o.map (List.cons (encode a)) :=\n      option_map snd <| (list_cons' H).comp ((@Primrec.encode α _).comp (fst.comp fst)) snd\n    have :\n      Primrec fun n =>\n        (of_nat (List ℕ) n).reverse.foldl\n          (fun o m => (decode α m).bind fun a => o.map (List.cons (encode a))) (some []) :=\n      list_foldl' H ((list_reverse' H).comp (Primrec.ofNat (List ℕ))) (const (some []))\n        (Primrec.comp₂ (bind_decode_iff.2 <| Primrec₂.swap this) Primrec₂.right)\n    nat_iff.1 <|\n      (encode_iff.2 this).of_eq fun n => by\n        rw [List.foldl_reverse]\n        apply Nat.case_strong_induction_on n; · simp\n        intro n IH; simp\n        cases' decode α n.unpair.1 with a; · rfl\n        simp\n        suffices :\n          ∀ (o : Option (List ℕ)) (p) (_ : encode o = encode p),\n            encode (Option.map (List.cons (encode a)) o) = encode (Option.map (List.cons a) p)\n        exact this _ _ (IH _ (Nat.unpair_right_le n))\n        intro o p IH\n        cases o <;> cases p <;> injection IH with h\n        exact congr_arg (fun k => (Nat.pair (encode a) k).succ.succ) h⟩\n#align primcodable.list Primcodable.list\n-/\n\nend Primcodable\n\nnamespace Primrec\n\nvariable {α : Type _} {β : Type _} {γ : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable γ] [Primcodable σ]\n\n/- warning: primrec.sum_inl -> Primrec.sum_inl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β], Primrec.{u1, max u1 u2} α (Sum.{u1, u2} α β) _inst_1 (Primcodable.sum.{u1, u2} α β _inst_1 _inst_2) (Sum.inl.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u1} β], Primrec.{u2, max u2 u1} α (Sum.{u2, u1} α β) _inst_1 (Primcodable.sum.{u2, u1} α β _inst_1 _inst_2) (Sum.inl.{u2, u1} α β)\nCase conversion may be inaccurate. Consider using '#align primrec.sum_inl Primrec.sum_inlₓ'. -/\ntheorem sum_inl : Primrec (@Sum.inl α β) :=\n  encode_iff.1 <| nat_double.comp Primrec.encode\n#align primrec.sum_inl Primrec.sum_inl\n\n#print Primrec.sum_inr /-\ntheorem sum_inr : Primrec (@Sum.inr α β) :=\n  encode_iff.1 <| nat_double_succ.comp Primrec.encode\n#align primrec.sum_inr Primrec.sum_inr\n-/\n\n/- warning: primrec.sum_cases -> Primrec.sum_cases is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {σ : Type.{u4}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_3 : Primcodable.{u3} γ] [_inst_4 : Primcodable.{u4} σ] {f : α -> (Sum.{u2, u3} β γ)} {g : α -> β -> σ} {h : α -> γ -> σ}, (Primrec.{u1, max u2 u3} α (Sum.{u2, u3} β γ) _inst_1 (Primcodable.sum.{u2, u3} β γ _inst_2 _inst_3) f) -> (Primrec₂.{u1, u2, u4} α β σ _inst_1 _inst_2 _inst_4 g) -> (Primrec₂.{u1, u3, u4} α γ σ _inst_1 _inst_3 _inst_4 h) -> (Primrec.{u1, u4} α σ _inst_1 _inst_4 (fun (a : α) => Sum.casesOn.{succ u4, u2, u3} β γ (fun (_x : Sum.{u2, u3} β γ) => σ) (f a) (g a) (h a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u4}} {γ : Type.{u3}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u4} β] [_inst_3 : Primcodable.{u3} γ] [_inst_4 : Primcodable.{u1} σ] {f : α -> (Sum.{u4, u3} β γ)} {g : α -> β -> σ} {h : α -> γ -> σ}, (Primrec.{u2, max u4 u3} α (Sum.{u4, u3} β γ) _inst_1 (Primcodable.sum.{u4, u3} β γ _inst_2 _inst_3) f) -> (Primrec₂.{u2, u4, u1} α β σ _inst_1 _inst_2 _inst_4 g) -> (Primrec₂.{u2, u3, u1} α γ σ _inst_1 _inst_3 _inst_4 h) -> (Primrec.{u2, u1} α σ _inst_1 _inst_4 (fun (a : α) => Sum.casesOn.{succ u1, u4, u3} β γ (fun (_x : Sum.{u4, u3} β γ) => σ) (f a) (g a) (h a)))\nCase conversion may be inaccurate. Consider using '#align primrec.sum_cases Primrec.sum_casesₓ'. -/\ntheorem sum_cases {f : α → Sum β γ} {g : α → β → σ} {h : α → γ → σ} (hf : Primrec f)\n    (hg : Primrec₂ g) (hh : Primrec₂ h) : @Primrec _ σ _ _ fun a => Sum.casesOn (f a) (g a) (h a) :=\n  option_some_iff.1 <|\n    (cond (nat_bodd.comp <| encode_iff.2 hf)\n          (option_map (Primrec.decode.comp <| nat_div2.comp <| encode_iff.2 hf) hh)\n          (option_map (Primrec.decode.comp <| nat_div2.comp <| encode_iff.2 hf) hg)).of_eq\n      fun a => by cases' f a with b c <;> simp [Nat.div2_bit, Nat.bodd_bit, encodek] <;> rfl\n#align primrec.sum_cases Primrec.sum_cases\n\n#print Primrec.list_cons /-\ntheorem list_cons : Primrec₂ (@List.cons α) :=\n  list_cons' (Primcodable.prim _)\n#align primrec.list_cons Primrec.list_cons\n-/\n\n/- warning: primrec.list_cases -> Primrec.list_cases is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_4 : Primcodable.{u3} σ] {f : α -> (List.{u2} β)} {g : α -> σ} {h : α -> (Prod.{u2, u2} β (List.{u2} β)) -> σ}, (Primrec.{u1, u2} α (List.{u2} β) _inst_1 (Primcodable.list.{u2} β _inst_2) f) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u1, u2, u3} α (Prod.{u2, u2} β (List.{u2} β)) σ _inst_1 (Primcodable.prod.{u2, u2} β (List.{u2} β) _inst_2 (Primcodable.list.{u2} β _inst_2)) _inst_4 h) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 (fun (a : α) => List.casesOn.{succ u3, u2} β (fun (_x : List.{u2} β) => σ) (f a) (g a) (fun (b : β) (l : List.{u2} β) => h a (Prod.mk.{u2, u2} β (List.{u2} β) b l))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u3} β] [_inst_4 : Primcodable.{u1} σ] {f : α -> (List.{u3} β)} {g : α -> σ} {h : α -> (Prod.{u3, u3} β (List.{u3} β)) -> σ}, (Primrec.{u2, u3} α (List.{u3} β) _inst_1 (Primcodable.list.{u3} β _inst_2) f) -> (Primrec.{u2, u1} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u2, u3, u1} α (Prod.{u3, u3} β (List.{u3} β)) σ _inst_1 (Primcodable.prod.{u3, u3} β (List.{u3} β) _inst_2 (Primcodable.list.{u3} β _inst_2)) _inst_4 h) -> (Primrec.{u2, u1} α σ _inst_1 _inst_4 (fun (a : α) => List.casesOn.{succ u1, u3} β (fun (_x : List.{u3} β) => σ) (f a) (g a) (fun (b : β) (l : List.{u3} β) => h a (Prod.mk.{u3, u3} β (List.{u3} β) b l))))\nCase conversion may be inaccurate. Consider using '#align primrec.list_cases Primrec.list_casesₓ'. -/\ntheorem list_cases {f : α → List β} {g : α → σ} {h : α → β × List β → σ} :\n    Primrec f →\n      Primrec g →\n        Primrec₂ h → @Primrec _ σ _ _ fun a => List.casesOn (f a) (g a) fun b l => h a (b, l) :=\n  list_cases' (Primcodable.prim _)\n#align primrec.list_cases Primrec.list_cases\n\n/- warning: primrec.list_foldl -> Primrec.list_foldl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_4 : Primcodable.{u3} σ] {f : α -> (List.{u2} β)} {g : α -> σ} {h : α -> (Prod.{u3, u2} σ β) -> σ}, (Primrec.{u1, u2} α (List.{u2} β) _inst_1 (Primcodable.list.{u2} β _inst_2) f) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u1, max u3 u2, u3} α (Prod.{u3, u2} σ β) σ _inst_1 (Primcodable.prod.{u3, u2} σ β _inst_4 _inst_2) _inst_4 h) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 (fun (a : α) => List.foldl.{u3, u2} σ β (fun (s : σ) (b : β) => h a (Prod.mk.{u3, u2} σ β s b)) (g a) (f a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u3} β] [_inst_4 : Primcodable.{u2} σ] {f : α -> (List.{u3} β)} {g : α -> σ} {h : α -> (Prod.{u2, u3} σ β) -> σ}, (Primrec.{u1, u3} α (List.{u3} β) _inst_1 (Primcodable.list.{u3} β _inst_2) f) -> (Primrec.{u1, u2} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u1, max u3 u2, u2} α (Prod.{u2, u3} σ β) σ _inst_1 (Primcodable.prod.{u2, u3} σ β _inst_4 _inst_2) _inst_4 h) -> (Primrec.{u1, u2} α σ _inst_1 _inst_4 (fun (a : α) => List.foldl.{u2, u3} σ β (fun (s : σ) (b : β) => h a (Prod.mk.{u2, u3} σ β s b)) (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_foldl Primrec.list_foldlₓ'. -/\ntheorem list_foldl {f : α → List β} {g : α → σ} {h : α → σ × β → σ} :\n    Primrec f →\n      Primrec g → Primrec₂ h → Primrec fun a => (f a).foldl (fun s b => h a (s, b)) (g a) :=\n  list_foldl' (Primcodable.prim _)\n#align primrec.list_foldl Primrec.list_foldl\n\n#print Primrec.list_reverse /-\ntheorem list_reverse : Primrec (@List.reverse α) :=\n  list_reverse' (Primcodable.prim _)\n#align primrec.list_reverse Primrec.list_reverse\n-/\n\n/- warning: primrec.list_foldr -> Primrec.list_foldr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_4 : Primcodable.{u3} σ] {f : α -> (List.{u2} β)} {g : α -> σ} {h : α -> (Prod.{u2, u3} β σ) -> σ}, (Primrec.{u1, u2} α (List.{u2} β) _inst_1 (Primcodable.list.{u2} β _inst_2) f) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u1, max u2 u3, u3} α (Prod.{u2, u3} β σ) σ _inst_1 (Primcodable.prod.{u2, u3} β σ _inst_2 _inst_4) _inst_4 h) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 (fun (a : α) => List.foldr.{u2, u3} β σ (fun (b : β) (s : σ) => h a (Prod.mk.{u2, u3} β σ b s)) (g a) (f a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u3} β] [_inst_4 : Primcodable.{u2} σ] {f : α -> (List.{u3} β)} {g : α -> σ} {h : α -> (Prod.{u3, u2} β σ) -> σ}, (Primrec.{u1, u3} α (List.{u3} β) _inst_1 (Primcodable.list.{u3} β _inst_2) f) -> (Primrec.{u1, u2} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u1, max u3 u2, u2} α (Prod.{u3, u2} β σ) σ _inst_1 (Primcodable.prod.{u3, u2} β σ _inst_2 _inst_4) _inst_4 h) -> (Primrec.{u1, u2} α σ _inst_1 _inst_4 (fun (a : α) => List.foldr.{u3, u2} β σ (fun (b : β) (s : σ) => h a (Prod.mk.{u3, u2} β σ b s)) (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_foldr Primrec.list_foldrₓ'. -/\ntheorem list_foldr {f : α → List β} {g : α → σ} {h : α → β × σ → σ} (hf : Primrec f)\n    (hg : Primrec g) (hh : Primrec₂ h) :\n    Primrec fun a => (f a).foldr (fun b s => h a (b, s)) (g a) :=\n  (list_foldl (list_reverse.comp hf) hg <| to₂ <| hh.comp fst <| (pair snd fst).comp snd).of_eq\n    fun a => by simp [List.foldl_reverse]\n#align primrec.list_foldr Primrec.list_foldr\n\n#print Primrec.list_head? /-\ntheorem list_head? : Primrec (@List.head? α) :=\n  (list_cases Primrec.id (const none) (option_some_iff.2 <| fst.comp snd).to₂).of_eq fun l => by\n    cases l <;> rfl\n#align primrec.list_head' Primrec.list_head?\n-/\n\n#print Primrec.list_headI /-\ntheorem list_headI [Inhabited α] : Primrec (@List.headI α _) :=\n  (option_iget.comp list_head?).of_eq fun l => l.head!_eq_head?.symm\n#align primrec.list_head Primrec.list_headI\n-/\n\n#print Primrec.list_tail /-\ntheorem list_tail : Primrec (@List.tail α) :=\n  (list_cases Primrec.id (const []) (snd.comp snd).to₂).of_eq fun l => by cases l <;> rfl\n#align primrec.list_tail Primrec.list_tail\n-/\n\n/- warning: primrec.list_rec -> Primrec.list_rec is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_4 : Primcodable.{u3} σ] {f : α -> (List.{u2} β)} {g : α -> σ} {h : α -> (Prod.{u2, max u2 u3} β (Prod.{u2, u3} (List.{u2} β) σ)) -> σ}, (Primrec.{u1, u2} α (List.{u2} β) _inst_1 (Primcodable.list.{u2} β _inst_2) f) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u1, max u2 u3, u3} α (Prod.{u2, max u2 u3} β (Prod.{u2, u3} (List.{u2} β) σ)) σ _inst_1 (Primcodable.prod.{u2, max u2 u3} β (Prod.{u2, u3} (List.{u2} β) σ) _inst_2 (Primcodable.prod.{u2, u3} (List.{u2} β) σ (Primcodable.list.{u2} β _inst_2) _inst_4)) _inst_4 h) -> (Primrec.{u1, u3} α σ _inst_1 _inst_4 (fun (a : α) => List.recOn.{succ u3, u2} β (fun (_x : List.{u2} β) => σ) (f a) (g a) (fun (b : β) (l : List.{u2} β) (IH : σ) => h a (Prod.mk.{u2, max u2 u3} β (Prod.{u2, u3} (List.{u2} β) σ) b (Prod.mk.{u2, u3} (List.{u2} β) σ l IH)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u3} β] [_inst_4 : Primcodable.{u2} σ] {f : α -> (List.{u3} β)} {g : α -> σ} {h : α -> (Prod.{u3, max u2 u3} β (Prod.{u3, u2} (List.{u3} β) σ)) -> σ}, (Primrec.{u1, u3} α (List.{u3} β) _inst_1 (Primcodable.list.{u3} β _inst_2) f) -> (Primrec.{u1, u2} α σ _inst_1 _inst_4 g) -> (Primrec₂.{u1, max u3 u2, u2} α (Prod.{u3, max u2 u3} β (Prod.{u3, u2} (List.{u3} β) σ)) σ _inst_1 (Primcodable.prod.{u3, max u3 u2} β (Prod.{u3, u2} (List.{u3} β) σ) _inst_2 (Primcodable.prod.{u3, u2} (List.{u3} β) σ (Primcodable.list.{u3} β _inst_2) _inst_4)) _inst_4 h) -> (Primrec.{u1, u2} α σ _inst_1 _inst_4 (fun (a : α) => List.recOn.{succ u2, u3} β (fun (_x : List.{u3} β) => σ) (f a) (g a) (fun (b : β) (l : List.{u3} β) (IH : σ) => h a (Prod.mk.{u3, max u3 u2} β (Prod.{u3, u2} (List.{u3} β) σ) b (Prod.mk.{u3, u2} (List.{u3} β) σ l IH)))))\nCase conversion may be inaccurate. Consider using '#align primrec.list_rec Primrec.list_recₓ'. -/\ntheorem list_rec {f : α → List β} {g : α → σ} {h : α → β × List β × σ → σ} (hf : Primrec f)\n    (hg : Primrec g) (hh : Primrec₂ h) :\n    @Primrec _ σ _ _ fun a => List.recOn (f a) (g a) fun b l IH => h a (b, l, IH) :=\n  let F (a : α) := (f a).foldr (fun (b : β) (s : List β × σ) => (b :: s.1, h a (b, s))) ([], g a)\n  have : Primrec F :=\n    list_foldr hf (pair (const []) hg) <|\n      to₂ <| pair ((list_cons.comp fst (fst.comp snd)).comp snd) hh\n  (snd.comp this).of_eq fun a =>\n    by\n    suffices F a = (f a, List.recOn (f a) (g a) fun b l IH => h a (b, l, IH)) by rw [this]\n    simp [F]\n    induction' f a with b l IH <;> simp [*]\n#align primrec.list_rec Primrec.list_rec\n\n#print Primrec.list_get? /-\ntheorem list_get? : Primrec₂ (@List.get? α) :=\n  let F (l : List α) (n : ℕ) :=\n    l.foldl\n      (fun (s : Sum ℕ α) (a : α) =>\n        Sum.casesOn s (@Nat.casesOn (Sum ℕ α) (Sum.inr a) Sum.inl) Sum.inr)\n      (Sum.inl n)\n  have hF : Primrec₂ F :=\n    list_foldl fst (sum_inl.comp snd)\n      ((sum_cases fst (nat_cases snd (sum_inr.comp <| snd.comp fst) (sum_inl.comp snd).to₂).to₂\n              (sum_inr.comp snd).to₂).comp\n          snd).to₂\n  have :\n    @Primrec _ (Option α) _ _ fun p : List α × ℕ => Sum.casesOn (F p.1 p.2) (fun _ => none) some :=\n    sum_cases hF (const none).to₂ (option_some.comp snd).to₂\n  this.to₂.of_eq fun l n => by\n    dsimp; symm\n    induction' l with a l IH generalizing n; · rfl\n    cases' n with n\n    · rw [(_ : F (a :: l) 0 = Sum.inr a)]\n      · rfl\n      clear IH\n      dsimp [F]\n      induction' l with b l IH <;> simp [*]\n    · apply IH\n#align primrec.list_nth Primrec.list_get?\n-/\n\n#print Primrec.list_getD /-\ntheorem list_getD (d : α) : Primrec₂ fun l n => List.getD l n d :=\n  by\n  simp only [List.getD_eq_getD_get?]\n  exact option_get_or_else.comp₂ list_nth (const _)\n#align primrec.list_nthd Primrec.list_getD\n-/\n\n#print Primrec.list_getI /-\ntheorem list_getI [Inhabited α] : Primrec₂ (@List.getI α _) :=\n  list_getD _\n#align primrec.list_inth Primrec.list_getI\n-/\n\n#print Primrec.list_append /-\ntheorem list_append : Primrec₂ ((· ++ ·) : List α → List α → List α) :=\n  (list_foldr fst snd <| to₂ <| comp (@list_cons α _) snd).to₂.of_eq fun l₁ l₂ => by\n    induction l₁ <;> simp [*]\n#align primrec.list_append Primrec.list_append\n-/\n\n#print Primrec.list_concat /-\ntheorem list_concat : Primrec₂ fun l (a : α) => l ++ [a] :=\n  list_append.comp fst (list_cons.comp snd (const []))\n#align primrec.list_concat Primrec.list_concat\n-/\n\n/- warning: primrec.list_map -> Primrec.list_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {σ : Type.{u3}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] [_inst_4 : Primcodable.{u3} σ] {f : α -> (List.{u2} β)} {g : α -> β -> σ}, (Primrec.{u1, u2} α (List.{u2} β) _inst_1 (Primcodable.list.{u2} β _inst_2) f) -> (Primrec₂.{u1, u2, u3} α β σ _inst_1 _inst_2 _inst_4 g) -> (Primrec.{u1, u3} α (List.{u3} σ) _inst_1 (Primcodable.list.{u3} σ _inst_4) (fun (a : α) => List.map.{u2, u3} β σ (g a) (f a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_2 : Primcodable.{u3} β] [_inst_4 : Primcodable.{u1} σ] {f : α -> (List.{u3} β)} {g : α -> β -> σ}, (Primrec.{u2, u3} α (List.{u3} β) _inst_1 (Primcodable.list.{u3} β _inst_2) f) -> (Primrec₂.{u2, u3, u1} α β σ _inst_1 _inst_2 _inst_4 g) -> (Primrec.{u2, u1} α (List.{u1} σ) _inst_1 (Primcodable.list.{u1} σ _inst_4) (fun (a : α) => List.map.{u3, u1} β σ (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_map Primrec.list_mapₓ'. -/\ntheorem list_map {f : α → List β} {g : α → β → σ} (hf : Primrec f) (hg : Primrec₂ g) :\n    Primrec fun a => (f a).map (g a) :=\n  (list_foldr hf (const []) <|\n        to₂ <| list_cons.comp (hg.comp fst (fst.comp snd)) (snd.comp snd)).of_eq\n    fun a => by induction f a <;> simp [*]\n#align primrec.list_map Primrec.list_map\n\n#print Primrec.list_range /-\ntheorem list_range : Primrec List.range :=\n  (nat_elim' Primrec.id (const []) ((list_concat.comp snd fst).comp snd).to₂).of_eq fun n => by\n    simp <;> induction n <;> simp [*, List.range_succ] <;> rfl\n#align primrec.list_range Primrec.list_range\n-/\n\n#print Primrec.list_join /-\ntheorem list_join : Primrec (@List.join α) :=\n  (list_foldr Primrec.id (const []) <| to₂ <| comp (@list_append α _) snd).of_eq fun l => by\n    dsimp <;> induction l <;> simp [*]\n#align primrec.list_join Primrec.list_join\n-/\n\n#print Primrec.list_length /-\ntheorem list_length : Primrec (@List.length α) :=\n  (list_foldr (@Primrec.id (List α) _) (const 0) <| to₂ <| (succ.comp <| snd.comp snd).to₂).of_eq\n    fun l => by dsimp <;> induction l <;> simp [*, -add_comm]\n#align primrec.list_length Primrec.list_length\n-/\n\n/- warning: primrec.list_find_index -> Primrec.list_findIdx is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {f : α -> (List.{u2} β)} {p : α -> β -> Prop} [_inst_5 : forall (a : α) (b : β), Decidable (p a b)], (Primrec.{u1, u2} α (List.{u2} β) _inst_1 (Primcodable.list.{u2} β _inst_2) f) -> (PrimrecRel.{u1, u2} α β _inst_1 _inst_2 p (fun (a : α) (b : β) => _inst_5 a b)) -> (Primrec.{u1, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) => List.findIndex.{u2} β (p a) (fun (a_1 : β) => _inst_5 a a_1) (f a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_2 : Primcodable.{u2} β] {f : α -> (List.{u2} β)} {p : α -> β -> Bool}, (Primrec.{u1, u2} α (List.{u2} β) _inst_1 (Primcodable.list.{u2} β _inst_2) f) -> (Primrec₂.{u1, u2, 0} α β Bool _inst_1 _inst_2 Primcodable.bool p) -> (Primrec.{u1, 0} α Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : α) => List.findIdx.{u2} β (p a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_find_index Primrec.list_findIdxₓ'. -/\ntheorem list_findIdx {f : α → List β} {p : α → β → Prop} [∀ a b, Decidable (p a b)] (hf : Primrec f)\n    (hp : PrimrecRel p) : Primrec fun a => (f a).findIndex (p a) :=\n  (list_foldr hf (const 0) <|\n        to₂ <| ite (hp.comp fst <| fst.comp snd) (const 0) (succ.comp <| snd.comp snd)).of_eq\n    fun a => Eq.symm <| by dsimp <;> induction' f a with b l <;> [rfl, simp [*, List.findIndex]]\n#align primrec.list_find_index Primrec.list_findIdx\n\ntheorem list_indexOf [DecidableEq α] : Primrec₂ (@List.indexOf α _) :=\n  to₂ <| list_findIdx snd <| Primrec.eq.comp₂ (fst.comp fst).to₂ snd.to₂\n#align primrec.list_index_of Primrec.list_indexOfₓ\n\n#print Primrec.nat_strong_rec /-\ntheorem nat_strong_rec (f : α → ℕ → σ) {g : α → List σ → Option σ} (hg : Primrec₂ g)\n    (H : ∀ a n, g a ((List.range n).map (f a)) = some (f a n)) : Primrec₂ f :=\n  suffices Primrec₂ fun a n => (List.range n).map (f a) from\n    Primrec₂.option_some_iff.1 <|\n      (list_get?.comp (this.comp fst (succ.comp snd)) snd).to₂.of_eq fun a n => by\n        simp [List.get?_range (Nat.lt_succ_self n)] <;> rfl\n  Primrec₂.option_some_iff.1 <|\n    (nat_elim (const (some []))\n          (to₂ <|\n            option_bind (snd.comp snd) <|\n              to₂ <|\n                option_map (hg.comp (fst.comp fst) snd)\n                  (to₂ <| list_concat.comp (snd.comp fst) snd))).of_eq\n      fun a n => by\n      simp; induction' n with n IH; · rfl\n      simp [IH, H, List.range_succ]\n#align primrec.nat_strong_rec Primrec.nat_strong_rec\n-/\n\nend Primrec\n\nnamespace Primcodable\n\nvariable {α : Type _} {β : Type _}\n\nvariable [Primcodable α] [Primcodable β]\n\nopen Primrec\n\n#print Primcodable.subtype /-\n/-- A subtype of a primitive recursive predicate is `primcodable`. -/\ndef subtype {p : α → Prop} [DecidablePred p] (hp : PrimrecPred p) : Primcodable (Subtype p) :=\n  ⟨have : Primrec fun n => (decode α n).bind fun a => Option.guard p a :=\n      option_bind Primrec.decode (option_guard (hp.comp snd) snd)\n    nat_iff.1 <|\n      (encode_iff.2 this).of_eq fun n =>\n        show _ = encode ((decode α n).bind fun a => _)\n          by\n          cases' decode α n with a; · rfl\n          dsimp [Option.guard]\n          by_cases h : p a <;> simp [h] <;> rfl⟩\n#align primcodable.subtype Primcodable.subtype\n-/\n\n#print Primcodable.fin /-\ninstance fin {n} : Primcodable (Fin n) :=\n  @ofEquiv _ _ (subtype <| nat_lt.comp Primrec.id (const n)) Fin.equivSubtype\n#align primcodable.fin Primcodable.fin\n-/\n\n#print Primcodable.vector /-\ninstance vector {n} : Primcodable (Vector α n) :=\n  subtype ((@Primrec.eq _ _ Nat.decidableEq).comp list_length (const _))\n#align primcodable.vector Primcodable.vector\n-/\n\n#print Primcodable.finArrow /-\ninstance finArrow {n} : Primcodable (Fin n → α) :=\n  ofEquiv _ (Equiv.vectorEquivFin _ _).symm\n#align primcodable.fin_arrow Primcodable.finArrow\n-/\n\ninstance array {n} : Primcodable (Array' n α) :=\n  ofEquiv _ (Equiv.arrayEquivFin _ _)\n#align primcodable.array Primcodable.array\n\nsection Ulower\n\nattribute [local instance] Encodable.decidableRangeEncode Encodable.decidableEqOfEncodable\n\n#print Primcodable.ulower /-\ninstance ulower : Primcodable (Ulower α) :=\n  have : PrimrecPred fun n => Encodable.decode₂ α n ≠ none :=\n    PrimrecPred.not\n      (Primrec.eq.comp\n        (Primrec.option_bind Primrec.decode\n          (Primrec.ite (Primrec.eq.comp (Primrec.encode.comp Primrec.snd) Primrec.fst)\n            (Primrec.option_some.comp Primrec.snd) (Primrec.const _)))\n        (Primrec.const _))\n  Primcodable.subtype <| PrimrecPred.of_eq this fun n => decode₂_ne_none_iff\n#align primcodable.ulower Primcodable.ulower\n-/\n\nend Ulower\n\nend Primcodable\n\nnamespace Primrec\n\nvariable {α : Type _} {β : Type _} {γ : Type _} {σ : Type _}\n\nvariable [Primcodable α] [Primcodable β] [Primcodable γ] [Primcodable σ]\n\n#print Primrec.subtype_val /-\ntheorem subtype_val {p : α → Prop} [DecidablePred p] {hp : PrimrecPred p} :\n    haveI := Primcodable.subtype hp\n    Primrec (@Subtype.val α p) :=\n  by\n  letI := Primcodable.subtype hp\n  refine' (Primcodable.prim (Subtype p)).of_eq fun n => _\n  rcases decode (Subtype p) n with (_ | ⟨a, h⟩) <;> rfl\n#align primrec.subtype_val Primrec.subtype_val\n-/\n\n#print Primrec.subtype_val_iff /-\ntheorem subtype_val_iff {p : β → Prop} [DecidablePred p] {hp : PrimrecPred p} {f : α → Subtype p} :\n    haveI := Primcodable.subtype hp\n    (Primrec fun a => (f a).1) ↔ Primrec f :=\n  by\n  letI := Primcodable.subtype hp\n  refine' ⟨fun h => _, fun hf => subtype_val.comp hf⟩\n  refine' Nat.Primrec.of_eq h fun n => _\n  cases' decode α n with a; · rfl\n  simp; cases f a <;> rfl\n#align primrec.subtype_val_iff Primrec.subtype_val_iff\n-/\n\n#print Primrec.subtype_mk /-\ntheorem subtype_mk {p : β → Prop} [DecidablePred p] {hp : PrimrecPred p} {f : α → β}\n    {h : ∀ a, p (f a)} (hf : Primrec f) :\n    haveI := Primcodable.subtype hp\n    Primrec fun a => @Subtype.mk β p (f a) (h a) :=\n  subtype_val_iff.1 hf\n#align primrec.subtype_mk Primrec.subtype_mk\n-/\n\n#print Primrec.option_get /-\ntheorem option_get {f : α → Option β} {h : ∀ a, (f a).isSome} :\n    Primrec f → Primrec fun a => Option.get (h a) :=\n  by\n  intro hf\n  refine' (nat.primrec.pred.comp hf).of_eq fun n => _\n  generalize hx : decode α n = x\n  cases x <;> simp\n#align primrec.option_get Primrec.option_get\n-/\n\n#print Primrec.ulower_down /-\ntheorem ulower_down : Primrec (Ulower.down : α → Ulower α) :=\n  letI : ∀ a, Decidable (a ∈ Set.range (encode : α → ℕ)) := decidable_range_encode _\n  subtype_mk Primrec.encode\n#align primrec.ulower_down Primrec.ulower_down\n-/\n\n#print Primrec.ulower_up /-\ntheorem ulower_up : Primrec (Ulower.up : Ulower α → α) :=\n  letI : ∀ a, Decidable (a ∈ Set.range (encode : α → ℕ)) := decidable_range_encode _\n  option_get (primrec.decode₂.comp subtype_val)\n#align primrec.ulower_up Primrec.ulower_up\n-/\n\n#print Primrec.fin_val_iff /-\ntheorem fin_val_iff {n} {f : α → Fin n} : (Primrec fun a => (f a).1) ↔ Primrec f :=\n  by\n  let : Primcodable { a // id a < n }; swap\n  exact (Iff.trans (by rfl) subtype_val_iff).trans (of_equiv_iff _)\n#align primrec.fin_val_iff Primrec.fin_val_iff\n-/\n\n#print Primrec.fin_val /-\ntheorem fin_val {n} : Primrec (coe : Fin n → ℕ) :=\n  fin_val_iff.2 Primrec.id\n#align primrec.fin_val Primrec.fin_val\n-/\n\n#print Primrec.fin_succ /-\ntheorem fin_succ {n} : Primrec (@Fin.succ n) :=\n  fin_val_iff.1 <| by simp [succ.comp fin_val]\n#align primrec.fin_succ Primrec.fin_succ\n-/\n\n#print Primrec.vector_toList /-\ntheorem vector_toList {n} : Primrec (@Vector.toList α n) :=\n  subtype_val\n#align primrec.vector_to_list Primrec.vector_toList\n-/\n\n#print Primrec.vector_toList_iff /-\ntheorem vector_toList_iff {n} {f : α → Vector β n} : (Primrec fun a => (f a).toList) ↔ Primrec f :=\n  subtype_val_iff\n#align primrec.vector_to_list_iff Primrec.vector_toList_iff\n-/\n\n#print Primrec.vector_cons /-\ntheorem vector_cons {n} : Primrec₂ (@Vector.cons α n) :=\n  vector_toList_iff.1 <| by simp <;> exact list_cons.comp fst (vector_to_list_iff.2 snd)\n#align primrec.vector_cons Primrec.vector_cons\n-/\n\n#print Primrec.vector_length /-\ntheorem vector_length {n} : Primrec (@Vector.length α n) :=\n  const _\n#align primrec.vector_length Primrec.vector_length\n-/\n\n#print Primrec.vector_head /-\ntheorem vector_head {n} : Primrec (@Vector.head α n) :=\n  option_some_iff.1 <| (list_head?.comp vector_toList).of_eq fun ⟨a :: l, h⟩ => rfl\n#align primrec.vector_head Primrec.vector_head\n-/\n\n#print Primrec.vector_tail /-\ntheorem vector_tail {n} : Primrec (@Vector.tail α n) :=\n  vector_toList_iff.1 <| (list_tail.comp vector_toList).of_eq fun ⟨l, h⟩ => by cases l <;> rfl\n#align primrec.vector_tail Primrec.vector_tail\n-/\n\n#print Primrec.vector_get /-\ntheorem vector_get {n} : Primrec₂ (@Vector.get α n) :=\n  option_some_iff.1 <|\n    (list_get?.comp (vector_toList.comp fst) (fin_val.comp snd)).of_eq fun a => by\n      simp [Vector.get_eq_get] <;> rw [← List.nthLe_get?]\n#align primrec.vector_nth Primrec.vector_get\n-/\n\n/- warning: primrec.list_of_fn -> Primrec.list_ofFn is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_4 : Primcodable.{u2} σ] {n : Nat} {f : (Fin n) -> α -> σ}, (forall (i : Fin n), Primrec.{u1, u2} α σ _inst_1 _inst_4 (f i)) -> (Primrec.{u1, u2} α (List.{u2} σ) _inst_1 (Primcodable.list.{u2} σ _inst_4) (fun (a : α) => List.ofFn.{u2} σ n (fun (i : Fin n) => f i a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_4 : Primcodable.{u1} σ] {n : Nat} {f : (Fin n) -> α -> σ}, (forall (i : Fin n), Primrec.{u2, u1} α σ _inst_1 _inst_4 (f i)) -> (Primrec.{u2, u1} α (List.{u1} σ) _inst_1 (Primcodable.list.{u1} σ _inst_4) (fun (a : α) => List.ofFn.{u1} σ n (fun (i : Fin n) => f i a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_of_fn Primrec.list_ofFnₓ'. -/\ntheorem list_ofFn :\n    ∀ {n} {f : Fin n → α → σ}, (∀ i, Primrec (f i)) → Primrec fun a => List.ofFn fun i => f i a\n  | 0, f, hf => const []\n  | n + 1, f, hf => by\n    simp [List.ofFn_succ] <;> exact list_cons.comp (hf 0) (list_of_fn fun i => hf i.succ)\n#align primrec.list_of_fn Primrec.list_ofFn\n\n/- warning: primrec.vector_of_fn -> Primrec.vector_ofFn is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_4 : Primcodable.{u2} σ] {n : Nat} {f : (Fin n) -> α -> σ}, (forall (i : Fin n), Primrec.{u1, u2} α σ _inst_1 _inst_4 (f i)) -> (Primrec.{u1, u2} α (Vector.{u2} σ n) _inst_1 (Primcodable.vector.{u2} σ _inst_4 n) (fun (a : α) => Vector.ofFn.{u2} σ n (fun (i : Fin n) => f i a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_4 : Primcodable.{u1} σ] {n : Nat} {f : (Fin n) -> α -> σ}, (forall (i : Fin n), Primrec.{u2, u1} α σ _inst_1 _inst_4 (f i)) -> (Primrec.{u2, u1} α (Vector.{u1} σ n) _inst_1 (Primcodable.vector.{u1} σ _inst_4 n) (fun (a : α) => Vector.ofFn.{u1} σ n (fun (i : Fin n) => f i a)))\nCase conversion may be inaccurate. Consider using '#align primrec.vector_of_fn Primrec.vector_ofFnₓ'. -/\ntheorem vector_ofFn {n} {f : Fin n → α → σ} (hf : ∀ i, Primrec (f i)) :\n    Primrec fun a => Vector.ofFn fun i => f i a :=\n  vector_toList_iff.1 <| by simp [list_of_fn hf]\n#align primrec.vector_of_fn Primrec.vector_ofFn\n\n#print Primrec.vector_nth' /-\ntheorem vector_nth' {n} : Primrec (@Vector.get α n) :=\n  ofEquiv_symm\n#align primrec.vector_nth' Primrec.vector_nth'\n-/\n\n#print Primrec.vector_of_fn' /-\ntheorem vector_of_fn' {n} : Primrec (@Vector.ofFn α n) :=\n  ofEquiv\n#align primrec.vector_of_fn' Primrec.vector_of_fn'\n-/\n\n#print Primrec.fin_app /-\ntheorem fin_app {n} : Primrec₂ (@id (Fin n → σ)) :=\n  (vector_get.comp (vector_of_fn'.comp fst) snd).of_eq fun ⟨v, i⟩ => by simp\n#align primrec.fin_app Primrec.fin_app\n-/\n\n/- warning: primrec.fin_curry₁ -> Primrec.fin_curry₁ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_4 : Primcodable.{u2} σ] {n : Nat} {f : (Fin n) -> α -> σ}, Iff (Primrec₂.{0, u1, u2} (Fin n) α σ (Primcodable.fin n) _inst_1 _inst_4 f) (forall (i : Fin n), Primrec.{u1, u2} α σ _inst_1 _inst_4 (f i))\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_4 : Primcodable.{u1} σ] {n : Nat} {f : (Fin n) -> α -> σ}, Iff (Primrec₂.{0, u2, u1} (Fin n) α σ (Primcodable.fin n) _inst_1 _inst_4 f) (forall (i : Fin n), Primrec.{u2, u1} α σ _inst_1 _inst_4 (f i))\nCase conversion may be inaccurate. Consider using '#align primrec.fin_curry₁ Primrec.fin_curry₁ₓ'. -/\ntheorem fin_curry₁ {n} {f : Fin n → α → σ} : Primrec₂ f ↔ ∀ i, Primrec (f i) :=\n  ⟨fun h i => h.comp (const i) Primrec.id, fun h =>\n    (vector_get.comp ((vector_ofFn h).comp snd) fst).of_eq fun a => by simp⟩\n#align primrec.fin_curry₁ Primrec.fin_curry₁\n\n/- warning: primrec.fin_curry -> Primrec.fin_curry is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {σ : Type.{u2}} [_inst_1 : Primcodable.{u1} α] [_inst_4 : Primcodable.{u2} σ] {n : Nat} {f : α -> (Fin n) -> σ}, Iff (Primrec.{u1, u2} α ((Fin n) -> σ) _inst_1 (Primcodable.finArrow.{u2} σ _inst_4 n) f) (Primrec₂.{u1, 0, u2} α (Fin n) σ _inst_1 (Primcodable.fin n) _inst_4 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {σ : Type.{u1}} [_inst_1 : Primcodable.{u2} α] [_inst_4 : Primcodable.{u1} σ] {n : Nat} {f : α -> (Fin n) -> σ}, Iff (Primrec.{u2, u1} α ((Fin n) -> σ) _inst_1 (Primcodable.finArrow.{u1} σ _inst_4 n) f) (Primrec₂.{u2, 0, u1} α (Fin n) σ _inst_1 (Primcodable.fin n) _inst_4 f)\nCase conversion may be inaccurate. Consider using '#align primrec.fin_curry Primrec.fin_curryₓ'. -/\ntheorem fin_curry {n} {f : α → Fin n → σ} : Primrec f ↔ Primrec₂ f :=\n  ⟨fun h => fin_app.comp (h.comp fst) snd, fun h =>\n    (vector_nth'.comp\n          (vector_ofFn fun i => show Primrec fun a => f a i from h.comp Primrec.id (const i))).of_eq\n      fun a => by funext i <;> simp⟩\n#align primrec.fin_curry Primrec.fin_curry\n\nend Primrec\n\nnamespace Nat\n\nopen Vector\n\n#print Nat.Primrec' /-\n/-- An alternative inductive definition of `primrec` which\n  does not use the pairing function on ℕ, and so has to\n  work with n-ary functions on ℕ instead of unary functions.\n  We prove that this is equivalent to the regular notion\n  in `to_prim` and `of_prim`. -/\ninductive Primrec' : ∀ {n}, (Vector ℕ n → ℕ) → Prop\n  | zero : @primrec' 0 fun _ => 0\n  | succ : @primrec' 1 fun v => succ v.headI\n  | nth {n} (i : Fin n) : primrec' fun v => v.get? i\n  |\n  comp {m n f} (g : Fin n → Vector ℕ m → ℕ) :\n    primrec' f → (∀ i, primrec' (g i)) → primrec' fun a => f (ofFn fun i => g i a)\n  |\n  prec {n f g} :\n    @primrec' n f →\n      @primrec' (n + 2) g →\n        primrec' fun v : Vector ℕ (n + 1) =>\n          v.headI.elim (f v.tail) fun y IH => g (y ::ᵥ IH ::ᵥ v.tail)\n#align nat.primrec' Nat.Primrec'\n-/\n\nend Nat\n\nnamespace Nat.Primrec'\n\nopen Vector Primrec\n\nopen Nat (Primrec')\n\nopen Nat.Primrec'\n\n/- ./././Mathport/Syntax/Translate/Command.lean:691:6: unsupported: hide command -/\n#print Nat.Primrec'.to_prim /-\ntheorem to_prim {n f} (pf : @Primrec' n f) : Primrec f :=\n  by\n  induction pf\n  case zero => exact const 0\n  case succ => exact primrec.succ.comp vector_head\n  case nth n i => exact vector_nth.comp Primrec.id (const i)\n  case comp m n f g _ _ hf hg => exact hf.comp (vector_of_fn fun i => hg i)\n  case prec n f g _ _ hf hg =>\n    exact\n      nat_elim' vector_head (hf.comp vector_tail)\n        (hg.comp <|\n            vector_cons.comp (fst.comp snd) <|\n              vector_cons.comp (snd.comp snd) <| (@vector_tail _ _ (n + 1)).comp fst).to₂\n#align nat.primrec'.to_prim Nat.Primrec'.to_prim\n-/\n\n#print Nat.Primrec'.of_eq /-\ntheorem of_eq {n} {f g : Vector ℕ n → ℕ} (hf : Primrec' f) (H : ∀ i, f i = g i) : Primrec' g :=\n  (funext H : f = g) ▸ hf\n#align nat.primrec'.of_eq Nat.Primrec'.of_eq\n-/\n\n#print Nat.Primrec'.const /-\ntheorem const {n} : ∀ m, @Primrec' n fun v => m\n  | 0 => zero.comp Fin.elim0 fun i => i.elim0ₓ\n  | m + 1 => succ.comp _ fun i => const m\n#align nat.primrec'.const Nat.Primrec'.const\n-/\n\n#print Nat.Primrec'.head /-\ntheorem head {n : ℕ} : @Primrec' n.succ head :=\n  (get 0).of_eq fun v => by simp [nth_zero]\n#align nat.primrec'.head Nat.Primrec'.head\n-/\n\n#print Nat.Primrec'.tail /-\ntheorem tail {n f} (hf : @Primrec' n f) : @Primrec' n.succ fun v => f v.tail :=\n  (hf.comp _ fun i => @get _ i.succ).of_eq fun v => by\n    rw [← of_fn_nth v.tail] <;> congr <;> funext i <;> simp\n#align nat.primrec'.tail Nat.Primrec'.tail\n-/\n\n#print Nat.Primrec'.Vec /-\n/-- A function from vectors to vectors is primitive recursive when all of its projections are. -/\ndef Vec {n m} (f : Vector ℕ n → Vector ℕ m) : Prop :=\n  ∀ i, Primrec' fun v => (f v).get? i\n#align nat.primrec'.vec Nat.Primrec'.Vec\n-/\n\n#print Nat.Primrec'.nil /-\nprotected theorem nil {n} : @Vec n 0 fun _ => nil := fun i => i.elim0ₓ\n#align nat.primrec'.nil Nat.Primrec'.nil\n-/\n\n#print Nat.Primrec'.cons /-\nprotected theorem cons {n m f g} (hf : @Primrec' n f) (hg : @Vec n m g) :\n    Vec fun v => f v ::ᵥ g v := fun i => Fin.cases (by simp [*]) (fun i => by simp [hg i]) i\n#align nat.primrec'.cons Nat.Primrec'.cons\n-/\n\n#print Nat.Primrec'.idv /-\ntheorem idv {n} : @Vec n n id :=\n  get\n#align nat.primrec'.idv Nat.Primrec'.idv\n-/\n\n#print Nat.Primrec'.comp' /-\ntheorem comp' {n m f g} (hf : @Primrec' m f) (hg : @Vec n m g) : Primrec' fun v => f (g v) :=\n  (hf.comp _ hg).of_eq fun v => by simp\n#align nat.primrec'.comp' Nat.Primrec'.comp'\n-/\n\n#print Nat.Primrec'.comp₁ /-\ntheorem comp₁ (f : ℕ → ℕ) (hf : @Primrec' 1 fun v => f v.headI) {n g} (hg : @Primrec' n g) :\n    Primrec' fun v => f (g v) :=\n  hf.comp _ fun i => hg\n#align nat.primrec'.comp₁ Nat.Primrec'.comp₁\n-/\n\n#print Nat.Primrec'.comp₂ /-\ntheorem comp₂ (f : ℕ → ℕ → ℕ) (hf : @Primrec' 2 fun v => f v.headI v.tail.headI) {n g h}\n    (hg : @Primrec' n g) (hh : @Primrec' n h) : Primrec' fun v => f (g v) (h v) := by\n  simpa using hf.comp' (hg.cons <| hh.cons primrec'.nil)\n#align nat.primrec'.comp₂ Nat.Primrec'.comp₂\n-/\n\n#print Nat.Primrec'.prec' /-\ntheorem prec' {n f g h} (hf : @Primrec' n f) (hg : @Primrec' n g) (hh : @Primrec' (n + 2) h) :\n    @Primrec' n fun v => (f v).elim (g v) fun y IH : ℕ => h (y ::ᵥ IH ::ᵥ v) := by\n  simpa using comp' (prec hg hh) (hf.cons idv)\n#align nat.primrec'.prec' Nat.Primrec'.prec'\n-/\n\n#print Nat.Primrec'.pred /-\ntheorem pred : @Primrec' 1 fun v => v.headI.pred :=\n  (prec' head (const 0) head).of_eq fun v => by simp <;> cases v.head <;> rfl\n#align nat.primrec'.pred Nat.Primrec'.pred\n-/\n\n#print Nat.Primrec'.add /-\ntheorem add : @Primrec' 2 fun v => v.headI + v.tail.headI :=\n  (prec head (succ.comp₁ _ (tail head))).of_eq fun v => by\n    simp <;> induction v.head <;> simp [*, Nat.succ_add]\n#align nat.primrec'.add Nat.Primrec'.add\n-/\n\n#print Nat.Primrec'.sub /-\ntheorem sub : @Primrec' 2 fun v => v.headI - v.tail.headI :=\n  by\n  suffices; simpa using comp₂ (fun a b => b - a) this (tail head) head\n  refine' (prec head (pred.comp₁ _ (tail head))).of_eq fun v => _\n  simp; induction v.head <;> simp [*, Nat.sub_succ]\n#align nat.primrec'.sub Nat.Primrec'.sub\n-/\n\n#print Nat.Primrec'.mul /-\ntheorem mul : @Primrec' 2 fun v => v.headI * v.tail.headI :=\n  (prec (const 0) (tail (add.comp₂ _ (tail head) head))).of_eq fun v => by\n    simp <;> induction v.head <;> simp [*, Nat.succ_mul] <;> rw [add_comm]\n#align nat.primrec'.mul Nat.Primrec'.mul\n-/\n\n/- warning: nat.primrec'.if_lt -> Nat.Primrec'.if_lt is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {a : (Vector.{0} Nat n) -> Nat} {b : (Vector.{0} Nat n) -> Nat} {f : (Vector.{0} Nat n) -> Nat} {g : (Vector.{0} Nat n) -> Nat}, (Nat.Primrec' n a) -> (Nat.Primrec' n b) -> (Nat.Primrec' n f) -> (Nat.Primrec' n g) -> (Nat.Primrec' n (fun (v : Vector.{0} Nat n) => ite.{1} Nat (LT.lt.{0} Nat Nat.hasLt (a v) (b v)) (Nat.decidableLt (a v) (b v)) (f v) (g v)))\nbut is expected to have type\n  forall {n : Nat} {a : (Vector.{0} Nat n) -> Nat} {b : (Vector.{0} Nat n) -> Nat} {f : (Vector.{0} Nat n) -> Nat} {g : (Vector.{0} Nat n) -> Nat}, (Nat.Primrec' n a) -> (Nat.Primrec' n b) -> (Nat.Primrec' n f) -> (Nat.Primrec' n g) -> (Nat.Primrec' n (fun (v : Vector.{0} Nat n) => ite.{1} Nat (LT.lt.{0} Nat instLTNat (a v) (b v)) (Nat.decLt (a v) (b v)) (f v) (g v)))\nCase conversion may be inaccurate. Consider using '#align nat.primrec'.if_lt Nat.Primrec'.if_ltₓ'. -/\ntheorem if_lt {n a b f g} (ha : @Primrec' n a) (hb : @Primrec' n b) (hf : @Primrec' n f)\n    (hg : @Primrec' n g) : @Primrec' n fun v => if a v < b v then f v else g v :=\n  (prec' (sub.comp₂ _ hb ha) hg (tail <| tail hf)).of_eq fun v =>\n    by\n    cases e : b v - a v\n    · simp [not_lt.2 (tsub_eq_zero_iff_le.mp e)]\n    · simp [Nat.lt_of_sub_eq_succ e]\n#align nat.primrec'.if_lt Nat.Primrec'.if_lt\n\n#print Nat.Primrec'.natPair /-\ntheorem natPair : @Primrec' 2 fun v => v.headI.pair v.tail.headI :=\n  if_lt head (tail head) (add.comp₂ _ (tail <| mul.comp₂ _ head head) head)\n    (add.comp₂ _ (add.comp₂ _ (mul.comp₂ _ head head) head) (tail head))\n#align nat.primrec'.mkpair Nat.Primrec'.natPair\n-/\n\n#print Nat.Primrec'.encode /-\nprotected theorem encode : ∀ {n}, @Primrec' n encode\n  | 0 => (const 0).of_eq fun v => by rw [v.eq_nil] <;> rfl\n  | n + 1 => (succ.comp₁ _ (natPair.comp₂ _ head (tail encode))).of_eq fun ⟨a :: l, e⟩ => rfl\n#align nat.primrec'.encode Nat.Primrec'.encode\n-/\n\n#print Nat.Primrec'.sqrt /-\ntheorem sqrt : @Primrec' 1 fun v => v.headI.sqrt :=\n  by\n  suffices H : ∀ n : ℕ, n.sqrt = n.elim 0 fun x y => if x.succ < y.succ * y.succ then y else y.succ\n  · simp [H]\n    have :=\n      @prec' 1 _ _\n        (fun v => by\n          have x := v.head <;> have y := v.tail.head <;>\n            exact if x.succ < y.succ * y.succ then y else y.succ)\n        head (const 0) _\n    · convert this\n      funext\n      congr\n      funext x y\n      congr <;> simp\n    have x1 := succ.comp₁ _ head\n    have y1 := succ.comp₁ _ (tail head)\n    exact if_lt x1 (mul.comp₂ _ y1 y1) (tail head) y1\n  intro ; symm\n  induction' n with n IH; · simp\n  dsimp; rw [IH]; split_ifs\n  · exact le_antisymm (Nat.sqrt_le_sqrt (Nat.le_succ _)) (Nat.lt_succ_iff.1 <| Nat.sqrt_lt.2 h)\n  ·\n    exact\n      Nat.eq_sqrt.2 ⟨not_lt.1 h, Nat.sqrt_lt.1 <| Nat.lt_succ_iff.2 <| Nat.sqrt_succ_le_succ_sqrt _⟩\n#align nat.primrec'.sqrt Nat.Primrec'.sqrt\n-/\n\n#print Nat.Primrec'.unpair₁ /-\ntheorem unpair₁ {n f} (hf : @Primrec' n f) : @Primrec' n fun v => (f v).unpair.1 :=\n  by\n  have s := sqrt.comp₁ _ hf\n  have fss := sub.comp₂ _ hf (mul.comp₂ _ s s)\n  refine' (if_lt fss s fss s).of_eq fun v => _\n  simp [Nat.unpair]; split_ifs <;> rfl\n#align nat.primrec'.unpair₁ Nat.Primrec'.unpair₁\n-/\n\n#print Nat.Primrec'.unpair₂ /-\ntheorem unpair₂ {n f} (hf : @Primrec' n f) : @Primrec' n fun v => (f v).unpair.2 :=\n  by\n  have s := sqrt.comp₁ _ hf\n  have fss := sub.comp₂ _ hf (mul.comp₂ _ s s)\n  refine' (if_lt fss s s (sub.comp₂ _ fss s)).of_eq fun v => _\n  simp [Nat.unpair]; split_ifs <;> rfl\n#align nat.primrec'.unpair₂ Nat.Primrec'.unpair₂\n-/\n\n#print Nat.Primrec'.of_prim /-\ntheorem of_prim : ∀ {n f}, Primrec f → @Primrec' n f :=\n  suffices ∀ f, Nat.Primrec f → @Primrec' 1 fun v => f v.headI from fun n f hf =>\n    (pred.comp₁ _ <|\n          (this _ hf).comp₁ (fun m => Encodable.encode <| (decode (Vector ℕ n) m).map f)\n            Primrec'.encode).of_eq\n      fun i => by simp [encodek]\n  fun f hf => by\n  induction hf\n  case zero => exact const 0\n  case succ => exact succ\n  case left => exact unpair₁ head\n  case right => exact unpair₂ head\n  case pair f g _ _ hf hg => exact mkpair.comp₂ _ hf hg\n  case comp f g _ _ hf hg => exact hf.comp₁ _ hg\n  case prec f g _ _ hf hg =>\n    simpa using\n      prec' (unpair₂ head) (hf.comp₁ _ (unpair₁ head))\n        (hg.comp₁ _ <|\n          mkpair.comp₂ _ (unpair₁ <| tail <| tail head) (mkpair.comp₂ _ head (tail head)))\n#align nat.primrec'.of_prim Nat.Primrec'.of_prim\n-/\n\n#print Nat.Primrec'.prim_iff /-\ntheorem prim_iff {n f} : @Primrec' n f ↔ Primrec f :=\n  ⟨to_prim, of_prim⟩\n#align nat.primrec'.prim_iff Nat.Primrec'.prim_iff\n-/\n\n#print Nat.Primrec'.prim_iff₁ /-\ntheorem prim_iff₁ {f : ℕ → ℕ} : (@Primrec' 1 fun v => f v.headI) ↔ Primrec f :=\n  prim_iff.trans\n    ⟨fun h => (h.comp <| vector_ofFn fun i => Primrec.id).of_eq fun v => by simp, fun h =>\n      h.comp vector_head⟩\n#align nat.primrec'.prim_iff₁ Nat.Primrec'.prim_iff₁\n-/\n\n#print Nat.Primrec'.prim_iff₂ /-\ntheorem prim_iff₂ {f : ℕ → ℕ → ℕ} : (@Primrec' 2 fun v => f v.headI v.tail.headI) ↔ Primrec₂ f :=\n  prim_iff.trans\n    ⟨fun h =>\n      (h.comp <| vector_cons.comp fst <| vector_cons.comp snd (Primrec.const nil)).of_eq fun v => by\n        simp,\n      fun h => h.comp vector_head (vector_head.comp vector_tail)⟩\n#align nat.primrec'.prim_iff₂ Nat.Primrec'.prim_iff₂\n-/\n\n#print Nat.Primrec'.vec_iff /-\ntheorem vec_iff {m n f} : @Vec m n f ↔ Primrec f :=\n  ⟨fun h => by simpa using vector_of_fn fun i => to_prim (h i), fun h i =>\n    of_prim <| vector_get.comp h (Primrec.const i)⟩\n#align nat.primrec'.vec_iff Nat.Primrec'.vec_iff\n-/\n\nend Nat.Primrec'\n\n#print Primrec.nat_sqrt /-\ntheorem Primrec.nat_sqrt : Primrec Nat.sqrt :=\n  Nat.Primrec'.prim_iff₁.1 Nat.Primrec'.sqrt\n#align primrec.nat_sqrt Primrec.nat_sqrt\n-/\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Computability/Primrec.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.48233633068014115}}
{"text": "import Lean.Data.Json\nimport Mathlib.Data.Nat.Basic\nimport Mathlib.Init.Algebra.Order\nimport Mathlib.Init.Data.Nat.Basic\nimport Mathlib.Init.Data.Nat.Lemmas\nimport Mathlib.Init.Data.Int.Basic\nimport Mathlib.Tactic.LibrarySearch\nimport Mathlib.Data.Equiv.Basic\nimport Mathlib.Init.Data.Int.Order\nimport Timelib.Date.Year\nimport Timelib.Date.Month\n\nopen Lean\n\nstructure Ymd where\n  year : Year\n  month : Month\n  day : Nat\n  dayGe : day >= 1\n  dayLe : day <= month.numDays year\nderiving Repr\n\ninstance : ToJson Ymd where\n  toJson ymd := Json.mkObj [(\"year\", ToJson.toJson ymd.year.val), (\"month\", ToJson.toJson ymd.month), (\"day\", ymd.day)]\n\ninstance : FromJson Ymd where\n  fromJson? j := do\n    let (year : Year) ← (fromJson? (← j.getObjVal? \"year\")).map Year.mk\n    let (month : Month) ← (fromJson? (← j.getObjVal? \"month\"))\n    let (day : Nat) ← fromJson? (← j.getObjVal? \"day\")\n    if h : day >= 1 ∧ day <= month.numDays year\n    then return Ymd.mk year month day h.left h.right\n    else Except.error s!\"Ymd day out of range: {day}\"\n\ntheorem Ymd.eq_of_val_eq : ∀ {o₁ o₂ : Ymd} (h_year : o₁.year = o₂.year) (h_month : o₁.month = o₂.month) (h_day : o₁.day = o₂.day), o₁ = o₂\n| ⟨y₁, m₁, d₁, hGt₁, hLt₁⟩, ⟨y₂, m₂, d₂, hGt₂, hLt₂⟩, hy, hm, hd => by simp [hy, hm, hd]\n\ninstance : Ord Ymd where\n  compare d₁ d₂ :=  \n    match Ord.compare d₁.year d₂.year with\n    | Ordering.eq =>\n      match Ord.compare d₁.month d₂.month with\n      | Ordering.eq => Ord.compare d₁.day d₂.day\n      | owise => owise\n    | owise => owise\n\ninstance : LE Ymd := leOfOrd  \ninstance : LT Ymd := ltOfOrd\n\ntheorem Ymd.le_def (d₁ d₂ : Ymd) : (d₁ <= d₂) = (compare d₁ d₂).isLE := rfl \ntheorem Ymd.lt_def (d₁ d₂ : Ymd) : (d₁ < d₂) = (Ord.compare d₁ d₂ == Ordering.lt) := rfl \n\ntheorem Ymd.le_def' (d₁ d₂ : Ymd) : \n  (d₁ <= d₂) = \n  (d₁.year < d₂.year ∨ (d₁.year = d₂.year ∧ d₁.month < d₂.month) ∨ (d₁.year = d₂.year ∧ d₁.month = d₂.month ∧ d₁.day <= d₂.day)) := by\n   simp [Ymd.le_def, Ordering.isLE, compare, compareOfLessAndEq]\n   match lt_trichotomy d₁.year d₂.year with\n   | .inl y_lt => simp [y_lt]\n   | .inr (.inr y_gt) => simp [not_lt_of_gt y_gt, ne_of_gt y_gt]\n   | .inr (.inl y_eq) => \n     simp [y_eq, lt_irrefl]\n     match lt_trichotomy d₁.month d₂.month with\n     | .inl m_lt => simp [m_lt]\n     | .inr (.inr m_gt) => simp [not_lt_of_gt m_gt, ne_of_gt m_gt]\n     | .inr (.inl m_eq) => \n       simp [m_eq, lt_irrefl]\n       match lt_trichotomy d₁.day d₂.day with\n       | .inl d_lt => simp [d_lt]; exact le_of_lt d_lt\n       | .inr (.inr d_gt) => simp [not_lt_of_gt d_gt, ne_of_gt d_gt]; assumption\n       | .inr (.inl d_eq) => simp [d_eq, lt_irrefl d₂.day]\n\ntheorem Ymd.lt_def' (d₁ d₂ : Ymd) : \n  (d₁ < d₂) = \n  (d₁.year < d₂.year \n   ∨ (d₁.year = d₂.year ∧ d₁.month < d₂.month)\n   ∨ (d₁.year = d₂.year ∧ d₁.month = d₂.month ∧ d₁.day < d₂.day)) := by\n   simp [Ymd.lt_def, compare, compareOfLessAndEq]\n   match lt_trichotomy d₁.year d₂.year with\n   | .inl y_lt => simp [y_lt]\n   | .inr (.inr y_gt) => simp [not_lt_of_gt y_gt, ne_of_gt y_gt]\n   | .inr (.inl y_eq) => \n     simp [y_eq, lt_irrefl]\n     match lt_trichotomy d₁.month d₂.month with\n     | .inl m_lt => simp [m_lt]\n     | .inr (.inr m_gt) => simp [not_lt_of_gt m_gt, ne_of_gt m_gt]\n     | .inr (.inl m_eq) => \n       simp [m_eq, lt_irrefl]\n       match lt_trichotomy d₁.day d₂.day with\n       | .inl d_lt => simp [d_lt] \n       | .inr (.inr d_gt) => simp [not_lt_of_gt d_gt, ne_of_gt d_gt]\n       | .inr (.inl d_eq) => simp [d_eq, lt_irrefl d₂.day]\n\ninstance : LinearOrder Ymd where\n  le_refl (a) := by simp [Ymd.le_def']\n  le_trans (a b c) := by \n    simp only [Ymd.le_def']\n    rintro (ay_lt_by | ⟨ay_eq_by, am_lt_bm⟩ | ⟨ay_eq_by, am_eq_bm, ad_le_bd⟩)\n    <;> rintro (by_lt_cy | ⟨by_eq_cy, bm_lt_cm⟩ | ⟨by_eq_cy, bm_eq_cm, bd_le_cd⟩)\n    . exact .inl $ lt_trans ay_lt_by by_lt_cy\n    . exact .inl $ by_eq_cy ▸ ay_lt_by\n    . exact .inl $ by_eq_cy ▸ ay_lt_by\n    . exact .inl $ ay_eq_by ▸ by_lt_cy\n    . exact .inr $ .inl ⟨ay_eq_by ▸ by_eq_cy, lt_trans am_lt_bm bm_lt_cm⟩\n    . exact .inr $ .inl ⟨ay_eq_by ▸ by_eq_cy, bm_eq_cm ▸ am_lt_bm⟩\n    . exact .inl $ ay_eq_by ▸ by_lt_cy\n    . exact .inr $ .inl ⟨ay_eq_by ▸ by_eq_cy, am_eq_bm ▸ bm_lt_cm⟩\n    . exact .inr $ .inr ⟨ay_eq_by ▸ by_eq_cy, ⟨am_eq_bm ▸ bm_eq_cm, le_trans ad_le_bd bd_le_cd⟩⟩\n  lt_iff_le_not_le (a b) := by\n    simp only [Ymd.le_def', Ymd.lt_def']\n    refine Iff.intro ?mp ?mpr    \n    case mp =>\n      rintro (y_lt | ⟨y_eq, m_lt⟩ | ⟨y_eq, m_eq, d_le⟩)\n      case inl =>\n        have hr : ¬(b.year < a.year ∨ b.year = a.year ∧ b.month < a.month ∨ b.year = a.year ∧ b.month = a.month ∧ b.day ≤ a.day) := by\n          rintro (y_lt' | ⟨y_eq', m_lt'⟩ | ⟨y_eq', m_lt', d_le'⟩)           \n          . exact (not_lt_of_gt y_lt) y_lt'\n          . exact (lt_irrefl a.year (y_eq' ▸ y_lt))\n          . exact (lt_irrefl a.year (y_eq' ▸ y_lt))\n        exact ⟨Or.inl y_lt, hr⟩\n      case inr.inl.intro =>\n        have hr : ¬(b.year < a.year ∨ b.year = a.year ∧ b.month < a.month ∨ b.year = a.year ∧ b.month = a.month ∧ b.day ≤ a.day) := by\n          rintro (y_lt' | ⟨y_eq', m_le⟩ | ⟨y_eq', m_eq', d_le'⟩)           \n          . exact (lt_irrefl a.year (y_eq ▸ y_lt'))\n          . exact (not_lt_of_gt m_lt) m_le\n          . exact (lt_irrefl a.month (m_eq' ▸ m_lt))\n        exact ⟨.inr $ .inl ⟨y_eq, m_lt⟩, hr⟩ \n      case inr.inr.intro.intro =>\n        have hr : ¬(b.year < a.year ∨ b.year = a.year ∧ b.month < a.month ∨ b.year = a.year ∧ b.month = a.month ∧ b.day ≤ a.day) := by\n          rintro (y_lt' | ⟨y_eq', m_lt⟩ | ⟨y_eq', m_eq, d_le'⟩)\n          . exact (lt_irrefl a.year (y_eq ▸ y_lt'))\n          . exact (lt_irrefl a.month (m_eq ▸ m_lt))\n          . exact (not_le_of_gt d_le d_le')\n        exact ⟨.inr $ .inr ⟨y_eq, ⟨m_eq, le_of_lt d_le⟩⟩, hr⟩\n    case mpr =>\n      rintro (y_lt | ⟨y_eq, m_lt⟩ | ⟨y_eq, m_eq, d_le⟩)\n      case intro.inl => exact .inl y_lt\n      case intro.inr.inl.intro => exact .inr $ .inl ⟨y_eq, m_lt⟩\n      case intro.inr.inr.intro.intro hnot => \n        match lt_or_eq_of_le d_le with\n        | .inl d_lt => exact Or.inr $ .inr ⟨y_eq, ⟨m_eq, d_lt⟩⟩\n        | .inr d_eq => exact False.elim $ hnot $ .inr $ .inr ⟨y_eq.symm, ⟨m_eq.symm, (le_of_eq d_eq.symm)⟩⟩\n  le_antisymm (a b) := by \n    simp [Ymd.le_def']\n    rintro (ay_lt_by | ⟨ay_eq_by, am_lt_bm⟩ | ⟨ay_eq_by, am_eq_bm, ad_le_bd⟩) \n    <;> rintro (by_lt_ay | ⟨by_eq_ay, bm_lt_am⟩ | ⟨by_eq_ay, bm_eq_am, bd_le_ad⟩)\n    . exact absurd ay_lt_by (not_lt_of_gt by_lt_ay)\n    . rw [by_eq_ay] at ay_lt_by; exact absurd (ay_lt_by) (lt_irrefl _)\n    . rw [by_eq_ay] at ay_lt_by; exact absurd (ay_lt_by) (lt_irrefl _)\n    . rw [ay_eq_by] at by_lt_ay; exact absurd (by_lt_ay) (lt_irrefl _)\n    . exact absurd am_lt_bm (not_lt_of_gt bm_lt_am)\n    . rw [bm_eq_am] at am_lt_bm; exact absurd (am_lt_bm) (lt_irrefl _)\n    . rw [ay_eq_by] at by_lt_ay; exact absurd (by_lt_ay) (lt_irrefl _)\n    . rw [am_eq_bm] at bm_lt_am; exact absurd (bm_lt_am) (lt_irrefl _)\n    . exact Ymd.eq_of_val_eq ay_eq_by am_eq_bm (le_antisymm ad_le_bd bd_le_ad)\n  le_total (a b) := by\n    simp [Ymd.le_def']\n    match lt_trichotomy a.year b.year with\n    | .inl y_lt => simp [y_lt]\n    | .inr (.inr y_gt) => simp [y_gt]\n    | .inr (.inl y_eq) => \n      simp [y_eq, lt_irrefl]\n      match lt_trichotomy a.month b.month with\n      | .inl m_lt => simp [m_lt] \n      | .inr (.inr m_gt) => simp [m_gt]\n      | .inr (.inl m_eq) => \n        simp [m_eq, lt_irrefl]\n        match lt_trichotomy a.day b.day with\n        | .inl d_lt => simp [le_of_lt d_lt] \n        | .inr (.inr d_gt) => simp [le_of_lt d_gt]\n        | .inr (.inl d_eq) => simp [d_eq]\n  decidable_le := inferInstance\n\ntheorem Ymd.numDays_pos (ymd : Ymd) : 0 < ymd.month.numDays ymd.year := by\n  simp only [Month.numDays]\n  by_cases hy : ymd.year.isLeapYear <;> (split <;> simp [hy, if_true, if_false])\n\ntheorem Ymd.numDays_lt_numDaysInGregorianYear (ymd : Ymd) : ymd.month.numDays ymd.year < ymd.year.numDaysInGregorianYear := by\n  simp only [Month.numDays, Year.numDaysInGregorianYear]\n  by_cases hy : ymd.year.isLeapYear <;> (split <;> simp [hy, if_true, if_false])\n\ntheorem Ymd.numDays_lt_31 (ymd : Ymd) : ymd.month.numDays ymd.year <= 31 := by\n  simp only [Month.numDays, Year.numDaysInGregorianYear]\n  by_cases hy : ymd.year.isLeapYear <;> (split <;> simp [hy, if_true, if_false])\n", "meta": {"author": "ammkrn", "repo": "timelib", "sha": "185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15", "save_path": "github-repos/lean/ammkrn-timelib", "path": "github-repos/lean/ammkrn-timelib/timelib-185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15/Timelib/Date/Ymd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.72487026428967, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.48233632757994005}}
{"text": "import data.set.basic\nimport tactic.lift\n\n/-! Some tests of the `lift` tactic. -/\nexample (n m k x z u : ℤ) (hn : 0 < n) (hk : 0 ≤ k + n) (hu : 0 ≤ u)\n  (h : k + n = 2 + x) (f : false) :\n  k + n = m + x :=\nbegin\n  lift n to ℕ using le_of_lt hn,\n    guard_target (k + ↑n = m + x), guard_hyp hn : (0 : ℤ) < ↑n,\n  lift m to ℕ,\n    guard_target (0 ≤ m), tactic.swap, guard_target (k + ↑n = ↑m + x),\n    tactic.num_goals >>= λ n, guard (n = 2),\n  lift (k + n) to ℕ using hk with l hl,\n    guard_hyp l : ℕ, guard_hyp hl : ↑l = k + ↑n, guard_target (↑l = ↑m + x),\n    tactic.success_if_fail (tactic.get_local `hk),\n  lift x to ℕ with y hy,\n    tactic.swap, guard_hyp y : ℕ, guard_hyp hy : ↑y = x, guard_target (↑l = ↑m + x), tactic.swap,\n  lift z to ℕ with w,\n    tactic.swap, guard_hyp w : ℕ, tactic.success_if_fail (tactic.get_local `z), tactic.swap,\n  lift u to ℕ using hu with u rfl hu,\n    guard_hyp hu : (0 : ℤ) ≤ ↑u,\n\n  all_goals { exfalso, assumption },\nend\n\n-- test lift of functions\nexample (α : Type*) (f : α → ℤ) (hf : ∀ a, 0 ≤ f a) (hf' : ∀ a, f a < 1) (a : α) : 0 ≤ 2 * f a :=\nbegin\n  lift f to α → ℕ using hf,\n    guard_target ((0:ℤ) ≤ 2 * (λ i : α, (f i : ℤ)) a),\n    guard_hyp hf' : ∀ a, ((λ i : α, (f i:ℤ)) a) < 1,\n  constructor,\nend\n\n-- fail gracefully when the lifted variable is a local definition\nexample : let n : ℤ := 3 in n = n :=\nbegin\n  intro n,\n  success_if_fail_with_msg { lift n to ℕ }\n    (\"Cannot substitute variable n, it is a local definition. \" ++\n    \"If you really want to do this, use `clear_value` first.\"),\n  refl\nend\n\ninstance can_lift_unit : can_lift unit unit id (λ _, true) := ⟨λ x _, ⟨x, rfl⟩⟩\n\n/- test error messages -/\nexample (n : ℤ) (hn : 0 < n) : true :=\nbegin\n  success_if_fail_with_msg {lift n to ℕ using hn} (\"lift tactic failed.\\n\" ++\n    \"invalid type ascription, term has type\\n  0 < n\\nbut is expected to have type\\n  0 ≤ n\"),\n  success_if_fail_with_msg {lift (n : option ℤ) to ℕ}\n    (\"Failed to find a lift from option ℤ to ℕ. \" ++\n    \"Provide an instance of\\n  can_lift (option ℤ) ℕ ?m_1 ?m_2\"),\n  trivial\nend\n\nexample (n : ℤ) : ℕ :=\nbegin\n  success_if_fail_with_msg {lift n to ℕ}\n    \"lift tactic failed. Tactic is only applicable when the target is a proposition.\",\n  exact 0\nend\n\ninstance can_lift_set (R : Type*) (s : set R) : can_lift R s coe (λ x, x ∈ s) :=\n{ prf := λ x hx, ⟨⟨x, hx⟩, rfl⟩ }\n\nexample {R : Type*} {P : R → Prop} (x : R) (hx : P x) : true :=\nby { lift x to {x // P x} using hx with y, trivial }\n\n/-! Test that `lift` elaborates `s` as a type, not as a set. -/\nexample {R : Type*} {s : set R} (x : R) (hx : x ∈ s) : true :=\nby { lift x to s using hx with y, trivial }\n\nexample (n : ℤ) (hn : 0 ≤ n) : true :=\nby { lift n to ℕ, exact hn, trivial }\n\nexample (n : ℤ) (hn : 0 ≤ n) : true :=\nby { lift n to ℕ using hn, trivial }\n\nexample (n : ℤ) (hn : n ≥ 0) : true :=\nby { lift n to ℕ using ge.le _, trivial, guard_target (n ≥ 0), exact hn }\n\nexample (n : ℤ) (hn : 0 ≤ 1 * n) : true :=\nbegin\n  lift n to ℕ using by { simpa [int.one_mul] using hn } with k,\n  -- the above braces are optional, but it would be bad style to remove them (see next example)\n  guard_hyp hn : 0 ≤ 1 * ((k : ℕ) : ℤ),\n  trivial\nend\n\nexample (n : ℤ) (hn : 0 ≤ n ↔ true) : true :=\nbegin\n  lift n to ℕ using by { simp [hn] } with k, -- the braces are not optional here\n  trivial\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/lift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6654105454764746, "lm_q1q2_score": 0.48233632587050373}}
{"text": "/- Author: E.W.Ayers © 2019 -/\nimport ..equate\nnamespace rats\nopen robot\n\n/- Example within the context of defining the rationals as ordered pairs of integers\nquotiented by the relation (⟨a,b⟩ ~ ⟨c,d⟩) ↔ (a * d = c * b).\n -/\n\nmeta def blast : tactic unit :=\ntactic.timetac \"blast\" $ (using_smt_with {cc_cfg := {ac:=ff}} $ tactic.intros >> smt_tactic.iterate (smt_tactic.ematch >> smt_tactic.try smt_tactic.close))\nattribute [ematch] mul_comm mul_assoc\n\nuniverses u\nstructure q (α : Type u) [integral_domain α] := (n : α) (d : α ) (nz : d ≠ 0)\nlemma q.ext {α : Type u} [integral_domain α] : Π (q1 q2 : q α), q1.n = q2.n → q1.d = q2.d → q1 = q2\n|⟨n,d,nz⟩ ⟨_,_,_⟩ rfl rfl := rfl\n\ninstance (α : Type u) [integral_domain α] : setoid (q α) :=\n{ r := (λ a b, a.1 * b.2 = b.1 * a.2)\n, iseqv :=\n  ⟨ λ a, rfl\n  , λ a b, eq.symm\n  , λ ⟨a,b,_⟩ ⟨c,d,h⟩ ⟨e,f,_⟩\n     (p : a * d = c * b)\n     (q : c * f = e * d),\n    suffices d * (a * f) = d * (e * b), from eq_of_mul_eq_mul_left h this,\n    -- by blast -- takes about 2 seconds\n    by equate -- also about 2 seconds, but much slower because implemented in Lean VM\n  ⟩\n}\ndef free (α : Type u) [integral_domain α] : Type* := @quotient (q α) (by apply_instance)\nvariables {α : Type u} [integral_domain α]\n\n-- [TODO]\n-- namespace free\n-- def add : free α → free α → free α\n-- := λ x y, quotient.lift_on₂ x y\n--   (λ x y, ⟦(⟨x.1 * y.2 + y.1 * x.2, x.2 * y.2, mul_ne_zero x.nz y.nz⟩ : q α)⟧)\n--   (λ a1 a2 b1 b2,\n--       assume p : a1.n * b1.d = b1.1 * a1.2,\n--       assume q : a2.1 * b2.2 = b2.1 * a2.2,\n--       suffices (a1.1 * a2.2 + a2.1 * a1.2) * (b1.2 * b2.2)\n--                 = (b1.1 * b2.2 + b2.1 * b1.2) * (a1.2 * a2.2),\n--         from quotient.sound this,\n--         calc ((a1.1 * a2.2) + (a2.1 * a1.2)) * (b1.2 * b2.2)\n--               = ((b1.1 * a1.2) * (a2.2 * b2.2) + (b1.2 * a1.2) * (b2.1 * a2.2))\n--                 : by equate\n--          ...  = (b1.1 * b2.2 + b2.1 * b1.2) * (a1.2 * a2.2)\n--                 : by symmetry; clear p q; equate\n--   )\n-- end free\n\nend rats", "meta": {"author": "EdAyers", "repo": "lean-subtask", "sha": "04ac5a6c3bc3bfd190af4d6dcce444ddc8914e4b", "save_path": "github-repos/lean/EdAyers-lean-subtask", "path": "github-repos/lean/EdAyers-lean-subtask/lean-subtask-04ac5a6c3bc3bfd190af4d6dcce444ddc8914e4b/src/examples/rat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649232, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.4821466552673672}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport algebra.group.hom\nimport category_theory.limits.shapes.kernels\nimport algebra.big_operators.basic\nimport category_theory.endomorphism\n\n/-!\n# Preadditive categories\n\nA preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that\ncomposition of morphisms is linear in both variables.\n\nThis file contains a definition of preadditive category that directly encodes the definition given\nabove. The definition could also be phrased as follows: A preadditive category is a category\nenriched over the category of Abelian groups. Once the general framework to state this in Lean is\navailable, the contents of this file should become obsolete.\n\n## Main results\n\n* Definition of preadditive categories and basic properties\n* In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all\n  composable `g`.\n* A preadditive category with kernels has equalizers.\n\n## Implementation notes\n\nThe simp normal form for negation and composition is to push negations as far as possible to\nthe outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)`\nis simplified to `f ≫ g`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n\n## Tags\n\nadditive, preadditive, Hom group, Ab-category, Ab-enriched\n-/\n\nuniverses v u\n\nopen category_theory.limits\nopen add_monoid_hom\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is\n    linear in both variables. -/\nclass preadditive :=\n(hom_group : Π P Q : C, add_comm_group (P ⟶ Q) . tactic.apply_instance)\n(add_comp' : ∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R),\n  (f + f') ≫ g = f ≫ g + f' ≫ g . obviously)\n(comp_add' : ∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R),\n  f ≫ (g + g') = f ≫ g + f ≫ g' . obviously)\n\nattribute [instance] preadditive.hom_group\nrestate_axiom preadditive.add_comp'\nrestate_axiom preadditive.comp_add'\nattribute [simp,reassoc] preadditive.add_comp\nattribute [reassoc] preadditive.comp_add -- (the linter doesn't like `simp` on this lemma)\nattribute [simp] preadditive.comp_add\n\nend category_theory\n\nopen category_theory\n\nnamespace category_theory.preadditive\n\nsection preadditive\nvariables {C : Type u} [category.{v} C] [preadditive C]\n\nsection induced_category\nuniverses u'\nvariables {C} {D : Type u'} (F : D → C)\n\ninstance induced_category.category : preadditive.{v} (induced_category C F) :=\n{ hom_group := λ P Q, @preadditive.hom_group C _ _ (F P) (F Q),\n  add_comp' := λ P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := λ P Q R f g g', comp_add' _ _ _ _ _ _, }\n\nend induced_category\n\ninstance (X : C) : add_comm_group (End X) := by { dsimp [End], apply_instance, }\n\ninstance (X : C) : ring (End X) :=\n{ left_distrib := λ f g h, preadditive.add_comp X X X g h f,\n  right_distrib := λ f g h, preadditive.comp_add X X X h f g,\n  ..(infer_instance : add_comm_group (End X)),\n  ..(infer_instance : monoid (End X)) }\n\n/-- Composition by a fixed left argument as a group homomorphism -/\ndef left_comp {P Q : C} (R : C) (f : P ⟶ Q) : (Q ⟶ R) →+ (P ⟶ R) :=\nmk' (λ g, f ≫ g) $ λ g g', by simp\n\n/-- Composition by a fixed right argument as a group homomorphism -/\ndef right_comp (P : C) {Q R : C} (g : Q ⟶ R) : (P ⟶ Q) →+ (P ⟶ R) :=\nmk' (λ f, f ≫ g) $ λ f f', by simp\n\n@[simp, reassoc] lemma sub_comp {P Q R : C} (f f' : P ⟶ Q) (g : Q ⟶ R) :\n  (f - f') ≫ g = f ≫ g - f' ≫ g :=\nmap_sub (right_comp P g) f f'\n\n-- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma.\n@[reassoc, simp] lemma comp_sub {P Q R : C} (f : P ⟶ Q) (g g' : Q ⟶ R) :\n  f ≫ (g - g') = f ≫ g - f ≫ g' :=\nmap_sub (left_comp R f) g g'\n\n@[simp, reassoc] lemma neg_comp {P Q R : C} (f : P ⟶ Q) (g : Q ⟶ R) : (-f) ≫ g = -(f ≫ g) :=\nmap_neg (right_comp _ _) _\n\n/- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma. -/\n@[reassoc, simp] lemma comp_neg {P Q R : C} (f : P ⟶ Q) (g : Q ⟶ R) : f ≫ (-g) = -(f ≫ g) :=\nmap_neg (left_comp _ _) _\n\n@[reassoc] lemma neg_comp_neg {P Q R : C} (f : P ⟶ Q) (g : Q ⟶ R) : (-f) ≫ (-g) = f ≫ g :=\nby simp\n\nsection big_operators\n\nopen_locale big_operators\n\n@[reassoc] lemma comp_sum {P Q R : C} {J : Type*} {s : finset J} (f : P ⟶ Q) (g : J → (Q ⟶ R)) :\n  f ≫ ∑ j in s, g j = ∑ j in s, f ≫ g j :=\nbegin\n  change left_comp R f _ = _,\n  rw [add_monoid_hom.map_sum],\n  refl,\nend\n\n@[reassoc] lemma sum_comp {P Q R : C} {J : Type*} {s : finset J} (f : J → (P ⟶ Q)) (g : Q ⟶ R) :\n  (∑ j in s, f j) ≫ g  = ∑ j in s, f j ≫ g :=\nbegin\n  change right_comp P g _ = _,\n  rw [add_monoid_hom.map_sum],\n  refl,\nend\n\nend big_operators\n\ninstance {P Q : C} {f : P ⟶ Q} [epi f] : epi (-f) :=\n⟨λ R g g' H, by rwa [neg_comp, neg_comp, ←comp_neg, ←comp_neg, cancel_epi, neg_inj] at H⟩\n\ninstance {P Q : C} {f : P ⟶ Q} [mono f] : mono (-f) :=\n⟨λ R g g' H, by rwa [comp_neg, comp_neg, ←neg_comp, ←neg_comp, cancel_mono, neg_inj] at H⟩\n\n@[priority 100]\ninstance preadditive_has_zero_morphisms : has_zero_morphisms C :=\n{ has_zero := infer_instance,\n  comp_zero' := λ P Q f R, map_zero $ left_comp R f,\n  zero_comp' := λ P Q R f, map_zero $ right_comp P f }\n\nlemma mono_of_cancel_zero {Q R : C} (f : Q ⟶ R) (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) :\n  mono f :=\n⟨λ P g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (right_comp P f) g g').trans $ sub_eq_zero.2 hg⟩\n\nlemma mono_iff_cancel_zero {Q R : C} (f : Q ⟶ R) :\n  mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 :=\n⟨λ m P g, by exactI zero_of_comp_mono _, mono_of_cancel_zero f⟩\n\nlemma mono_of_kernel_zero {X Y : C} {f : X ⟶ Y} [has_limit (parallel_pair f 0)]\n  (w : kernel.ι f = 0) : mono f :=\nmono_of_cancel_zero f (λ P g h, by rw [←kernel.lift_ι f g h, w, limits.comp_zero])\n\nlemma epi_of_cancel_zero {P Q : C} (f : P ⟶ Q) (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) :\n  epi f :=\n⟨λ R g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (left_comp R f) g g').trans $ sub_eq_zero.2 hg⟩\n\nlemma epi_iff_cancel_zero {P Q : C} (f : P ⟶ Q) :\n  epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 :=\n⟨λ e R g, by exactI zero_of_epi_comp _, epi_of_cancel_zero f⟩\n\nlemma epi_of_cokernel_zero {X Y : C} (f : X ⟶ Y) [has_colimit (parallel_pair f 0 )]\n  (w : cokernel.π f = 0) : epi f :=\nepi_of_cancel_zero f (λ P g h, by rw [←cokernel.π_desc f g h, w, limits.zero_comp])\n\nend preadditive\n\nsection equalizers\nvariables {C : Type u} [category.{v} C] [preadditive C]\n\nsection\nvariables {X Y : C} (f : X ⟶ Y) (g : X ⟶ Y)\n\n/-- A kernel of `f - g` is an equalizer of `f` and `g`. -/\nlemma has_limit_parallel_pair [has_kernel (f - g)] :\n  has_limit (parallel_pair f g) :=\nhas_limit.mk { cone := fork.of_ι (kernel.ι (f - g)) (sub_eq_zero.1 $\n    by { rw ←comp_sub, exact kernel.condition _ }),\n  is_limit := fork.is_limit.mk _\n    (λ s, kernel.lift (f - g) (fork.ι s) $\n      by { rw comp_sub, apply sub_eq_zero.2, exact fork.condition _ })\n    (λ s, by simp)\n    (λ s m h, by { ext, simpa using h walking_parallel_pair.zero }) }\n\nend\n\nsection\n\n/-- If a preadditive category has all kernels, then it also has all equalizers. -/\nlemma has_equalizers_of_has_kernels [has_kernels C] : has_equalizers C :=\n@has_equalizers_of_has_limit_parallel_pair _ _ (λ _ _ f g, has_limit_parallel_pair f g)\n\nend\n\nsection\nvariables {X Y : C} (f : X ⟶ Y) (g : X ⟶ Y)\n\n/-- A cokernel of `f - g` is a coequalizer of `f` and `g`. -/\nlemma has_colimit_parallel_pair [has_cokernel (f - g)] :\n  has_colimit (parallel_pair f g) :=\nhas_colimit.mk { cocone := cofork.of_π (cokernel.π (f - g)) (sub_eq_zero.1 $\n    by { rw ←sub_comp, exact cokernel.condition _ }),\n  is_colimit := cofork.is_colimit.mk _\n    (λ s, cokernel.desc (f - g) (cofork.π s) $\n      by { rw sub_comp, apply sub_eq_zero.2, exact cofork.condition _ })\n    (λ s, by simp)\n    (λ s m h, by { ext, simpa using h walking_parallel_pair.one }) }\n\nend\n\nsection\n\n/-- If a preadditive category has all cokernels, then it also has all coequalizers. -/\nlemma has_coequalizers_of_has_cokernels [has_cokernels C] : has_coequalizers C :=\n@has_coequalizers_of_has_colimit_parallel_pair _ _ (λ _ _ f g, has_colimit_parallel_pair f g)\n\nend\n\nend equalizers\nend category_theory.preadditive\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/preadditive/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.48211618890044355}}
{"text": "opaque f : Nat → Nat\nopaque g : Nat → Nat\n\nnamespace Foo\n\n@[scoped simp] axiom ax1 (x : Nat) : f (g x) = x\n@[scoped simp] axiom ax2 (x : Nat) : g (g x) = g x\n\nend Foo\n\ntheorem ex1 : f (g (g (g x))) = x := by\n  simp -- does not use ax1 and ax2\n  simp [Foo.ax1, Foo.ax2]\n\ntheorem ex2 : f (g (g (g x))) = x :=\n  have h₁ : f (g (g (g x))) = f (g x) := by simp; /- try again with `Foo` scoped lemmas -/ open Foo in simp\n  have h₂ : f (g x) = x               := by simp; open Foo in simp\n  Eq.trans h₁ h₂\n  -- open Foo in simp -- works\n\ntheorem ex3 : f (g (g (g x))) = x := by\n  simp\n  simp [Foo.ax1, Foo.ax2]\n\nopen Foo in\ntheorem ex4 : f (g (g (g x))) = x := by\n  simp\n\ntheorem ex5 : f (g (g (g x))) = x ∧ f (g x) = x := by\n  apply And.intro\n  { simp; open Foo in simp }\n  { simp; open Foo in simp }\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/openInScopeBug.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390162, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.48211616640580984}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.sites.canonical\nimport Mathlib.category_theory.sites.sheaf_of_types\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\n/-!\n# Grothendieck Topology and Sheaves on the Category of Types\n\nIn this file we define a Grothendieck topology on the category of types,\nand construct the canonical functor that sends a type to a sheaf over\nthe category of types, and make this an equivalence of categories.\n\nThen we prove that the topology defined is the canonical topology.\n-/\n\nnamespace category_theory\n\n\n/-- A Grothendieck topology associated to the category of all types.\nA sieve is a covering iff it is jointly surjective. -/\ndef types_grothendieck_topology : grothendieck_topology (Type u) :=\n  grothendieck_topology.mk (fun (α : Type u) (S : sieve α) => ∀ (x : α), coe_fn S PUnit fun (_x : PUnit) => x) sorry sorry\n    sorry\n\n/-- The discrete sieve on a type, which only includes arrows whose image is a subsingleton. -/\n@[simp] theorem discrete_sieve_apply (α : Type u) (β : Type u) (f : β ⟶ α) : coe_fn (discrete_sieve α) β f = ∃ (x : α), ∀ (y : β), f y = x :=\n  Eq.refl (coe_fn (discrete_sieve α) β f)\n\ntheorem discrete_sieve_mem (α : Type u) : discrete_sieve α ∈ coe_fn types_grothendieck_topology α :=\n  fun (x : α) => Exists.intro x fun (y : PUnit) => rfl\n\n/-- The discrete presieve on a type, which only includes arrows whose domain is a singleton. -/\ndef discrete_presieve (α : Type u) : presieve α :=\n  fun (β : Type u) (f : β ⟶ α) => ∃ (x : β), ∀ (y : β), y = x\n\ntheorem generate_discrete_presieve_mem (α : Type u) : sieve.generate (discrete_presieve α) ∈ coe_fn types_grothendieck_topology α := sorry\n\ntheorem is_sheaf_yoneda' {α : Type u} : presieve.is_sheaf types_grothendieck_topology (functor.obj yoneda α) := sorry\n\n/-- The yoneda functor that sends a type to a sheaf over the category of types -/\n@[simp] theorem yoneda'_map (α : Type u) (β : Type u) (f : α ⟶ β) : functor.map yoneda' f = functor.map yoneda f :=\n  Eq.refl (functor.map yoneda' f)\n\n@[simp] theorem yoneda'_comp : yoneda' ⋙ induced_functor subtype.val = yoneda :=\n  rfl\n\n/-- Given a presheaf `P` on the category of types, construct\na map `P(α) → (α → P(*))` for all type `α`. -/\ndef eval (P : Type uᵒᵖ ⥤ Type u) (α : Type u) (s : functor.obj P (opposite.op α)) (x : α) : functor.obj P (opposite.op PUnit) :=\n  functor.map P (has_hom.hom.op (↾fun (_x : PUnit) => x)) s\n\n/-- Given a sheaf `S` on the category of types, construct a map\n`(α → S(*)) → S(α)` that is inverse to `eval`. -/\ndef types_glue (S : Type uᵒᵖ ⥤ Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) (α : Type u) (f : α → functor.obj S (opposite.op PUnit)) : functor.obj S (opposite.op α) :=\n  presieve.is_sheaf_for.amalgamate sorry\n    (fun (β : Type u) (g : β ⟶ α) (hg : discrete_presieve α g) =>\n      functor.map S (has_hom.hom.op (↾fun (x : β) => PUnit.unit)) (f (g (classical.some hg))))\n    sorry\n\ntheorem eval_types_glue {S : Type uᵒᵖ ⥤ Type u} {hs : presieve.is_sheaf types_grothendieck_topology S} {α : Type u} (f : α → functor.obj S (opposite.op PUnit)) : eval S α (types_glue S hs α f) = f := sorry\n\ntheorem types_glue_eval {S : Type uᵒᵖ ⥤ Type u} {hs : presieve.is_sheaf types_grothendieck_topology S} {α : Type u} (s : functor.obj S (opposite.op α)) : types_glue S hs α (eval S α s) = s := sorry\n\n/-- Given a sheaf `S`, construct an equivalence `S(α) ≃ (α → S(*))`. -/\ndef eval_equiv (S : Type uᵒᵖ ⥤ Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) (α : Type u) : functor.obj S (opposite.op α) ≃ (α → functor.obj S (opposite.op PUnit)) :=\n  equiv.mk (eval S α) (types_glue S hs α) types_glue_eval eval_types_glue\n\ntheorem eval_map (S : Type uᵒᵖ ⥤ Type u) (α : Type u) (β : Type u) (f : β ⟶ α) (s : functor.obj S (opposite.op α)) (x : β) : eval S β (functor.map S (has_hom.hom.op f) s) x = eval S α s (f x) := sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S ≅ [-, S(*)]`. -/\ndef equiv_yoneda (S : Type uᵒᵖ ⥤ Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) : S ≅ functor.obj yoneda (functor.obj S (opposite.op PUnit)) :=\n  nat_iso.of_components (fun (α : Type uᵒᵖ) => equiv.to_iso (eval_equiv S hs (opposite.unop α))) sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S ≅ [-, S(*)]`. -/\n@[simp] theorem equiv_yoneda'_inv (S : SheafOfTypes types_grothendieck_topology) : iso.inv (equiv_yoneda' S) = iso.inv (equiv_yoneda (subtype.val S) (equiv_yoneda'._proof_1 S)) :=\n  Eq.refl (iso.inv (equiv_yoneda' S))\n\ntheorem eval_app (S₁ : SheafOfTypes types_grothendieck_topology) (S₂ : SheafOfTypes types_grothendieck_topology) (f : S₁ ⟶ S₂) (α : Type u) (s : functor.obj (subtype.val S₁) (opposite.op α)) (x : α) : eval (subtype.val S₂) α (nat_trans.app f (opposite.op α) s) x =\n  nat_trans.app f (opposite.op PUnit) (eval (subtype.val S₁) α s x) :=\n  Eq.symm (congr_fun (nat_trans.naturality' f (has_hom.hom.op (↾fun (_x : PUnit) => x))) s)\n\n/-- `yoneda'` induces an equivalence of category between `Type u` and\n`Sheaf types_grothendieck_topology`. -/\n@[simp] theorem type_equiv_inverse_obj (X : SheafOfTypes types_grothendieck_topology) : functor.obj (equivalence.inverse type_equiv) X = functor.obj (↑X) (opposite.op PUnit) :=\n  Eq.refl (functor.obj (↑X) (opposite.op PUnit))\n\ntheorem subcanonical_types_grothendieck_topology : sheaf.subcanonical types_grothendieck_topology :=\n  sheaf.subcanonical.of_yoneda_is_sheaf types_grothendieck_topology fun (X : Type u) => is_sheaf_yoneda'\n\ntheorem types_grothendieck_topology_eq_canonical : types_grothendieck_topology = sheaf.canonical_topology (Type u) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/sites/types.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.803173801068221, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.48205556586391785}}
{"text": "import ground_zero.types.heq\n\n/-\n  Integers ℤ as a quotient of ℕ × ℕ.\n  * HoTT 6.10, remark 6.10.7\n-/\n\nabbreviation builtin.int := int\n\nnamespace ground_zero.HITs\n\ndef int.rel : ℕ × ℕ → ℕ × ℕ → Prop\n| ⟨a, b⟩ ⟨c, d⟩ := a + d = b + c\n\ndef int := quot int.rel\nlocal notation ℤ := int\n\nnamespace nat.product\n  def add (x y : ℕ × ℕ) : ℕ × ℕ := begin\n    cases x with a b, cases y with c d,\n    split, apply a + c, apply b + d\n  end\n  instance : has_add (ℕ × ℕ) := ⟨add⟩\n\n  def mul (x y : ℕ × ℕ) : ℕ × ℕ := begin\n    cases x with a b, cases y with c d,\n    split, apply a * c + b * d,\n    apply a * d + b * c\n  end\n  instance : has_mul (ℕ × ℕ) := ⟨mul⟩\n\n  lemma add_comm (x y : ℕ × ℕ) : x + y = y + x := begin\n    cases x with a b, cases y with c d,\n    simp [has_add.add], simp [add]\n  end\n\n  lemma mul_comm (x y : ℕ × ℕ) : x * y = y * x := begin\n    cases x with a b, cases y with c d,\n    simp [has_mul.mul], simp [mul], split,\n    { rw [nat.mul_comm c a], rw [nat.mul_comm d b] },\n    { rw [nat.mul_comm c b], rw [nat.mul_comm d a],\n      rw [nat.add_comm (b * c) (a * d)] }\n  end\n\n  lemma rw.add (a b : ℕ × ℕ) : nat.product.add a b = a + b :=\n  by trivial\n\n  lemma rw.mul (a b : ℕ × ℕ) : nat.product.mul a b = a * b :=\n  by trivial\nend nat.product\n\nnamespace int\n  universes u v\n\n  def mk : ℕ × ℕ → ℤ := quot.mk rel\n  def elem (a b : ℕ) : ℤ := quot.mk rel ⟨a, b⟩\n\n  def pos (n : ℕ) := mk ⟨n, 0⟩\n  instance : has_coe ℕ ℤ := ⟨pos⟩\n\n  def neg (n : ℕ) := mk ⟨0, n⟩\n\n  instance : has_zero int := ⟨mk ⟨0, 0⟩⟩\n  instance : has_one int := ⟨mk ⟨1, 0⟩⟩\n\n  def knife {a b c d : ℕ} (H : a + d = b + c :> ℕ) :\n    mk ⟨a, b⟩ = mk ⟨c, d⟩ :> ℤ :=\n  ground_zero.support.inclusion $ @quot.sound _ int.rel\n    ⟨a, b⟩ ⟨c, d⟩ (ground_zero.support.truncation H)\n\n  def ind {π : ℤ → Sort u}\n    (mk₁ : Π (x : ℕ × ℕ), π (mk x))\n    (knife₁ : Π {a b c d : ℕ} (H : a + d = b + c :> ℕ),\n      mk₁ ⟨a, b⟩ =[knife H] mk₁ ⟨c, d⟩) (x : ℤ) : π x := begin\n    refine quot.hrec_on x _ _,\n    exact mk₁, intros x y p,\n    cases x with a b, cases y with c d,\n    refine ground_zero.types.eq.rec _\n      (ground_zero.types.equiv.subst_from_pathover\n        (knife₁ (ground_zero.support.inclusion p))),\n    apply ground_zero.types.heq.eq_subst_heq\n  end\n\n  def injs {β : Sort u} (pos₁ : ℕ → β) (zero₁ : β) (neg₁ : ℕ → β) :\n    ℕ × ℕ → β\n  | ⟨0, 0⟩ := zero₁\n  | ⟨n, 0⟩ := pos₁ n\n  | ⟨0, n⟩ := neg₁ n\n  | ⟨n + 1, m + 1⟩ := if n > m\n    then injs ⟨n + 1, m⟩\n    else injs ⟨n, m + 1⟩\n\n  def simplify : ℕ × ℕ → ℕ × ℕ\n  | ⟨0, 0⟩ := ⟨0, 0⟩\n  | ⟨n + 1, 0⟩ := ⟨n + 1, 0⟩\n  | ⟨0, n + 1⟩ := ⟨0, n + 1⟩\n  | ⟨n + 1, m + 1⟩ := if n > m then ⟨n - m, 0⟩ else ⟨0, m - n⟩\n\n  lemma ite.left {c : Prop} [decidable c] {α : Sort u} {x y : α}\n    (h : not c) : ite c x y = y := begin\n    unfold ite, tactic.unfreeze_local_instances,\n    cases _inst_1 with u v, trivial, contradiction\n  end\n\n  lemma ite.right {c : Prop} [decidable c] {α : Sort u} {x y : α}\n    (h : c) : ite c x y = x := begin\n    unfold ite, tactic.unfreeze_local_instances,\n    cases _inst_1 with u v, contradiction, trivial\n  end\n\n  /- theorem simplify_correct (x : ℕ × ℕ) : mk x = mk (simplify x) := begin\n    apply quot.sound, cases x with u v,\n    induction u with u ih₁,\n    { induction v with v ih,\n      repeat { simp [simplify, rel] } },\n    { induction v with v ih₂,\n      { simp [simplify, rel] },\n      { simp [simplify],\n        have H := nat.decidable_le (v + 1) u, induction H;\n        unfold gt; unfold has_lt.lt; unfold nat.lt;\n        unfold has_le.le at H,\n        { rw [ite.left H], unfold rel,\n          admit },\n        { rw [ite.right H], unfold rel,\n          admit } } }\n  end\n\n  def blade {π : ℤ → Sort u}\n    (pos₁ : Π (n : ℕ), π (elem n 0))\n    (zero₁ : π 0)\n    (neg₁ : Π (n : ℕ), π (elem 0 n)) :\n    Π x, π x := begin\n    fapply ind,\n    { intro x, cases x with u v, rw [simplify_correct],\n      admit },\n    admit\n  end -/\n\n  instance : has_neg int :=\n  ⟨quot.lift\n    (λ (x : ℕ × ℕ), mk ⟨x.pr₂, x.pr₁⟩)\n    (begin\n      intros x y H, simp,\n      cases x with a b,\n      cases y with c d,\n      simp, apply quot.sound,\n      simp [rel], simp [rel] at H,\n      symmetry, assumption\n    end)⟩\n\n  lemma nat_rw (a b : ℕ) : nat.add a b = a + b :=\n  by trivial\n\n  def lift₂ (f : ℕ × ℕ → ℕ × ℕ → ℕ × ℕ)\n    (h₁ : Π (a b x : ℕ × ℕ) (H : rel a b),\n      mk (f x a) = mk (f x b))\n    (h₂ : Π (a b : ℕ × ℕ),\n      mk (f a b) = mk (f b a))\n    (x y : int) : int :=\n  quot.lift\n    (λ x, quot.lift\n          (λ y, mk (f x y))\n          (begin intros a b H, simp, apply h₁, assumption end) y)\n    (begin\n      intros a b H, simp,\n      induction y, simp,\n      rw [h₂ a y], rw [h₂ b y], apply h₁,\n      assumption, trivial\n    end) x\n\n  lemma add_saves_int {a b c d : ℕ} (H : a + d = b + c)\n    (y : ℕ × ℕ) :\n    mk (⟨a, b⟩ + y) = mk (⟨c, d⟩ + y) := begin\n    cases y with u v,\n    simp [has_add.add],\n    apply quot.sound, simp [nat.product.add], simp [rel],\n    rw [←nat.add_assoc], rw [H],\n    rw [nat.add_assoc]\n  end\n\n  def eq_map {α : Sort u} {β : Sort v} {a b : α}\n    (f : α → β) (p : a = b) : f a = f b :=\n  begin induction p, reflexivity end\n\n  def add : int → int → int := begin\n    apply lift₂ nat.product.add,\n    { intros x y u H,\n      cases x with a b, cases y with c d,\n      repeat { rw [nat.product.rw.add] },\n      rw [nat.product.add_comm u ⟨a, b⟩],\n      rw [nat.product.add_comm u ⟨c, d⟩],\n      apply add_saves_int, assumption },\n    { intros x y,\n      apply eq_map mk,\n      apply nat.product.add_comm }\n  end\n\n  instance : has_add int := ⟨add⟩\n  instance : has_sub int := ⟨λ a b, a + (-b)⟩\n\n  theorem inv_append (a : ℤ) : a + (-a) = 0 := begin\n    induction a, cases a with u v,\n    simp [has_neg.neg], apply quot.sound,\n    simp [nat.product.add], simp [rel],\n  end\n\n  theorem send_to_right {a b c : ℤ} : (a + b = c) → (a = c - b) := begin\n    intro h, induction a, induction b, induction c,\n    cases a with x y, cases b with u v, cases c with p q,\n    simp [has_sub.sub, has_neg.neg],\n    rw [←h], simp [mk],\n    simp [has_add.add] at *, apply quot.sound,\n    simp [nat.product.add], simp [rel],\n    repeat { trivial }\n  end\n\n  def mul : ℤ → ℤ → ℤ := begin\n    apply lift₂ nat.product.mul,\n    { intros x y z H,\n      cases x with a b, cases y with c d,\n      cases z with u v, simp [nat.product.mul],\n      apply quot.sound, simp [rel],\n      rw [←nat.add_assoc (u * a)],\n      rw [←nat.add_assoc (u * b)],\n\n      rw [←nat.left_distrib u a d],\n      rw [←nat.left_distrib v b c],\n\n      rw [←nat.left_distrib u b c],\n      rw [←nat.left_distrib v a d],\n      \n      simp [rel] at H, rw [H] },\n    { intros x y,\n      apply eq_map mk,\n      apply nat.product.mul_comm }\n  end\n  instance : has_mul int := ⟨mul⟩\n\n  theorem k_equiv (a b k : ℕ) : mk ⟨a, b⟩ = mk ⟨a + k, b + k⟩ :=\n  begin apply quot.sound, simp [rel] end\nend int\n\nend ground_zero.HITs", "meta": {"author": "jfrancese", "repo": "lean", "sha": "06e7efaecce4093d97fb5ecc75479df2ef1dbbdb", "save_path": "github-repos/lean/jfrancese-lean", "path": "github-repos/lean/jfrancese-lean/lean-06e7efaecce4093d97fb5ecc75479df2ef1dbbdb/ground_zero/HITs/int.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569014, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4820555630362387}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.group_theory.submonoid.basic\nimport Mathlib.algebra.big_operators.basic\nimport Mathlib.PostPort\n\nuniverses u_2 l u_1 \n\nnamespace Mathlib\n\n/-!\n# Submonoids\n\nThis file defines unbundled multiplicative and additive submonoids (deprecated). For bundled form\nsee `group_theory/submonoid`.\n\nWe some results about images and preimages of submonoids under monoid homomorphisms. These theorems\nuse unbundled monoid homomorphisms (also deprecated).\n\nThere are also theorems about the submonoids generated by an element or a subset of a monoid,\ndefined inductively.\n\n## Implementation notes\n\nUnbundled submonoids will slowly be removed from mathlib.\n\n## Tags\nsubmonoid, submonoids, is_submonoid\n-/\n\n/-- `s` is an additive submonoid: a set containing 0 and closed under addition. -/\nclass is_add_submonoid {A : Type u_2} [add_monoid A] (s : set A) where\n  zero_mem : 0 ∈ s\n  add_mem : ∀ {a b : A}, a ∈ s → b ∈ s → a + b ∈ s\n\n/-- `s` is a submonoid: a set containing 1 and closed under multiplication. -/\nclass is_submonoid {M : Type u_1} [monoid M] (s : set M) where\n  one_mem : 1 ∈ s\n  mul_mem : ∀ {a b : M}, a ∈ s → b ∈ s → a * b ∈ s\n\ntheorem additive.is_add_submonoid {M : Type u_1} [monoid M] (s : set M) [is_submonoid s] :\n    is_add_submonoid s :=\n  is_submonoid.dcases_on _inst_3\n    fun (one_mem : 1 ∈ s) (mul_mem : ∀ {a b : M}, a ∈ s → b ∈ s → a * b ∈ s) =>\n      idRhs (is_add_submonoid s) (is_add_submonoid.mk one_mem mul_mem)\n\ntheorem additive.is_add_submonoid_iff {M : Type u_1} [monoid M] {s : set M} :\n    is_add_submonoid s ↔ is_submonoid s :=\n  sorry\n\ntheorem multiplicative.is_submonoid {A : Type u_2} [add_monoid A] (s : set A) [is_add_submonoid s] :\n    is_submonoid s :=\n  is_add_submonoid.dcases_on _inst_3\n    fun (zero_mem : 0 ∈ s) (add_mem : ∀ {a b : A}, a ∈ s → b ∈ s → a + b ∈ s) =>\n      idRhs (is_submonoid s) (is_submonoid.mk zero_mem add_mem)\n\ntheorem multiplicative.is_submonoid_iff {A : Type u_2} [add_monoid A] {s : set A} :\n    is_submonoid s ↔ is_add_submonoid s :=\n  sorry\n\n/-- The intersection of two submonoids of a monoid `M` is a submonoid of `M`. -/\nprotected instance is_submonoid.inter {M : Type u_1} [monoid M] (s₁ : set M) (s₂ : set M)\n    [is_submonoid s₁] [is_submonoid s₂] : is_submonoid (s₁ ∩ s₂) :=\n  is_submonoid.mk { left := is_submonoid.one_mem, right := is_submonoid.one_mem }\n    fun (x y : M) (hx : x ∈ s₁ ∩ s₂) (hy : y ∈ s₁ ∩ s₂) =>\n      { left := is_submonoid.mul_mem (and.left hx) (and.left hy),\n        right := is_submonoid.mul_mem (and.right hx) (and.right hy) }\n\n/-- The intersection of an indexed set of submonoids of a monoid `M` is a submonoid of `M`. -/\nprotected instance is_add_submonoid.Inter {M : Type u_1} [add_monoid M] {ι : Sort u_2}\n    (s : ι → set M) [h : ∀ (y : ι), is_add_submonoid (s y)] : is_add_submonoid (set.Inter s) :=\n  is_add_submonoid.mk (iff.mpr set.mem_Inter fun (y : ι) => is_add_submonoid.zero_mem)\n    fun (x₁ x₂ : M) (h₁ : x₁ ∈ set.Inter s) (h₂ : x₂ ∈ set.Inter s) =>\n      iff.mpr set.mem_Inter\n        fun (y : ι) =>\n          is_add_submonoid.add_mem (iff.mp set.mem_Inter h₁ y) (iff.mp set.mem_Inter h₂ y)\n\n/-- The union of an indexed, directed, nonempty set of submonoids of a monoid `M` is a submonoid\n    of `M`. -/\ntheorem is_add_submonoid_Union_of_directed {M : Type u_1} [add_monoid M] {ι : Type u_2}\n    [hι : Nonempty ι] (s : ι → set M) [∀ (i : ι), is_add_submonoid (s i)]\n    (directed : ∀ (i j : ι), ∃ (k : ι), s i ⊆ s k ∧ s j ⊆ s k) :\n    is_add_submonoid (set.Union fun (i : ι) => s i) :=\n  sorry\n\n/-- The set of natural number powers `1, x, x², ...` of an element `x` of a monoid. -/\n/-- The set of natural number multiples `0, x, 2x, ...` of an element `x` of an `add_monoid`. -/\ndef powers {M : Type u_1} [monoid M] (x : M) : set M := set_of fun (y : M) => ∃ (n : ℕ), x ^ n = y\n\ndef multiples {A : Type u_2} [add_monoid A] (x : A) : set A :=\n  set_of fun (y : A) => ∃ (n : ℕ), n •ℕ x = y\n\n/-- 1 is in the set of natural number powers of an element of a monoid. -/\ntheorem powers.one_mem {M : Type u_1} [monoid M] {x : M} : 1 ∈ powers x :=\n  Exists.intro 0 (pow_zero x)\n\n/-- 0 is in the set of natural number multiples of an element of an `add_monoid`. -/\ntheorem multiples.zero_mem {A : Type u_2} [add_monoid A] {x : A} : 0 ∈ multiples x :=\n  Exists.intro 0 (zero_nsmul x)\n\n/-- An element of a monoid is in the set of that element's natural number powers. -/\ntheorem powers.self_mem {M : Type u_1} [monoid M] {x : M} : x ∈ powers x :=\n  Exists.intro 1 (pow_one x)\n\n/-- An element of an `add_monoid` is in the set of that element's natural number multiples. -/\ntheorem multiples.self_mem {A : Type u_2} [add_monoid A] {x : A} : x ∈ multiples x :=\n  Exists.intro 1 (one_nsmul x)\n\n/-- The set of natural number powers of an element of a monoid is closed under multiplication. -/\ntheorem powers.mul_mem {M : Type u_1} [monoid M] {x : M} {y : M} {z : M} :\n    y ∈ powers x → z ∈ powers x → y * z ∈ powers x :=\n  sorry\n\n/-- The set of natural number multiples of an element of an `add_monoid` is closed under\n    addition. -/\ntheorem multiples.add_mem {A : Type u_2} [add_monoid A] {x : A} {y : A} {z : A} :\n    y ∈ multiples x → z ∈ multiples x → y + z ∈ multiples x :=\n  powers.mul_mem\n\n/-- The set of natural number powers of an element of a monoid `M` is a submonoid of `M`. -/\nprotected instance multiples.is_add_submonoid {M : Type u_1} [add_monoid M] (x : M) :\n    is_add_submonoid (multiples x) :=\n  is_add_submonoid.mk multiples.zero_mem fun (y z : M) => multiples.add_mem\n\n/-- A monoid is a submonoid of itself. -/\nprotected instance univ.is_submonoid {M : Type u_1} [monoid M] : is_submonoid set.univ :=\n  is_submonoid.mk\n    (eq.mpr (id (propext ((fun {α : Type u_1} (x : α) => iff_true_intro (set.mem_univ x)) 1)))\n      trivial)\n    (eq.mpr\n      (id\n        (Eq.trans\n          (Eq.trans\n            (forall_congr_eq\n              fun (a : M) =>\n                forall_congr_eq\n                  fun (b : M) =>\n                    Eq.trans\n                      (imp_congr_eq\n                        (propext\n                          ((fun {α : Type u_1} (x : α) => iff_true_intro (set.mem_univ x)) a))\n                        (Eq.trans\n                          (imp_congr_eq\n                            (propext\n                              ((fun {α : Type u_1} (x : α) => iff_true_intro (set.mem_univ x)) b))\n                            (propext\n                              ((fun {α : Type u_1} (x : α) => iff_true_intro (set.mem_univ x))\n                                (a * b))))\n                          (propext (forall_prop_of_true True.intro))))\n                      (propext (forall_prop_of_true True.intro)))\n            (propext (forall_const M)))\n          (propext (forall_const M))))\n      trivial)\n\n/-- The preimage of a submonoid under a monoid hom is a submonoid of the domain. -/\nprotected instance preimage.is_add_submonoid {M : Type u_1} [add_monoid M] {N : Type u_2}\n    [add_monoid N] (f : M → N) [is_add_monoid_hom f] (s : set N) [is_add_submonoid s] :\n    is_add_submonoid (f ⁻¹' s) :=\n  is_add_submonoid.mk\n    ((fun (this : f 0 ∈ s) => this)\n      (eq.mpr (id (Eq._oldrec (Eq.refl (f 0 ∈ s)) (is_add_monoid_hom.map_zero f)))\n        is_add_submonoid.zero_mem))\n    fun (a b : M) (ha : f a ∈ s) (hb : f b ∈ s) =>\n      (fun (this : f (a + b) ∈ s) => this)\n        (eq.mpr (id (Eq._oldrec (Eq.refl (f (a + b) ∈ s)) (is_add_monoid_hom.map_add f a b)))\n          (is_add_submonoid.add_mem ha hb))\n\n/-- The image of a submonoid under a monoid hom is a submonoid of the codomain. -/\ninstance image.is_add_submonoid {M : Type u_1} [add_monoid M] {γ : Type u_2} [add_monoid γ]\n    (f : M → γ) [is_add_monoid_hom f] (s : set M) [is_add_submonoid s] :\n    is_add_submonoid (f '' s) :=\n  sorry\n\n/-- The image of a monoid hom is a submonoid of the codomain. -/\nprotected instance range.is_add_submonoid {M : Type u_1} [add_monoid M] {γ : Type u_2}\n    [add_monoid γ] (f : M → γ) [is_add_monoid_hom f] : is_add_submonoid (set.range f) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_add_submonoid (set.range f))) (Eq.symm set.image_univ)))\n    (image.is_add_submonoid f set.univ)\n\n/-- Submonoids are closed under natural powers. -/\ntheorem is_submonoid.pow_mem {M : Type u_1} [monoid M] {s : set M} {a : M} [is_submonoid s]\n    (h : a ∈ s) {n : ℕ} : a ^ n ∈ s :=\n  sorry\n\n/-- An `add_submonoid` is closed under multiplication by naturals. -/\ntheorem is_add_submonoid.smul_mem {A : Type u_2} [add_monoid A] {t : set A} {a : A}\n    [is_add_submonoid t] (h : a ∈ t) {n : ℕ} : n •ℕ a ∈ t :=\n  is_submonoid.pow_mem\n\n/-- The set of natural number powers of an element of a submonoid is a subset of the submonoid. -/\ntheorem is_submonoid.power_subset {M : Type u_1} [monoid M] {s : set M} {a : M} [is_submonoid s]\n    (h : a ∈ s) : powers a ⊆ s :=\n  sorry\n\n/-- The set of natural number multiples of an element of an `add_submonoid` is a subset of the\n    `add_submonoid`. -/\ntheorem is_add_submonoid.multiple_subset {A : Type u_2} [add_monoid A] {t : set A} {a : A}\n    [is_add_submonoid t] : a ∈ t → multiples a ⊆ t :=\n  is_submonoid.power_subset\n\nnamespace is_submonoid\n\n\n/-- The product of a list of elements of a submonoid is an element of the submonoid. -/\ntheorem list_prod_mem {M : Type u_1} [monoid M] {s : set M} [is_submonoid s] {l : List M} :\n    (∀ (x : M), x ∈ l → x ∈ s) → list.prod l ∈ s :=\n  sorry\n\n/-- The product of a multiset of elements of a submonoid of a `comm_monoid` is an element of\nthe submonoid. -/\ntheorem Mathlib.is_add_submonoid.multiset_sum_mem {M : Type u_1} [add_comm_monoid M] (s : set M)\n    [is_add_submonoid s] (m : multiset M) : (∀ (a : M), a ∈ m → a ∈ s) → multiset.sum m ∈ s :=\n  sorry\n\n/-- The product of elements of a submonoid of a `comm_monoid` indexed by a `finset` is an element\nof the submonoid. -/\ntheorem finset_prod_mem {M : Type u_1} {A : Type u_2} [comm_monoid M] (s : set M) [is_submonoid s]\n    (f : A → M) (t : finset A) :\n    (∀ (b : A), b ∈ t → f b ∈ s) → (finset.prod t fun (b : A) => f b) ∈ s :=\n  sorry\n\nend is_submonoid\n\n\n-- TODO: modify `subtype_instance` to produce this definition, then use it here\n\n--  and for `subtype.group`\n\n/-- Submonoids are themselves monoids. -/\ndef subtype.add_monoid {M : Type u_1} [add_monoid M] {s : set M} [is_add_submonoid s] :\n    add_monoid ↥s :=\n  add_monoid.mk (fun (x y : ↥s) => { val := ↑x + ↑y, property := sorry }) sorry\n    { val := 0, property := is_add_submonoid.zero_mem } sorry sorry\n\n/-- Submonoids of commutative monoids are themselves commutative monoids. -/\ndef subtype.add_comm_monoid {M : Type u_1} [add_comm_monoid M] {s : set M} [is_add_submonoid s] :\n    add_comm_monoid ↥s :=\n  add_comm_monoid.mk add_monoid.add sorry add_monoid.zero sorry sorry sorry\n\n/-- Submonoids inherit the 1 of the monoid. -/\n@[simp] theorem is_submonoid.coe_one {M : Type u_1} [monoid M] {s : set M} [is_submonoid s] :\n    ↑1 = 1 :=\n  rfl\n\n/-- Submonoids inherit the multiplication of the monoid. -/\n@[simp] theorem is_add_submonoid.coe_add {M : Type u_1} [add_monoid M] {s : set M}\n    [is_add_submonoid s] (a : ↥s) (b : ↥s) : ↑(a + b) = ↑a + ↑b :=\n  rfl\n\n/-- Submonoids inherit the exponentiation by naturals of the monoid. -/\n@[simp] theorem is_submonoid.coe_pow {M : Type u_1} [monoid M] {s : set M} [is_submonoid s] (a : ↥s)\n    (n : ℕ) : ↑(a ^ n) = ↑a ^ n :=\n  sorry\n\n/-- An `add_submonoid` inherits the multiplication by naturals of the `add_monoid`. -/\n@[simp] theorem is_add_submonoid.smul_coe {A : Type u_1} [add_monoid A] {s : set A}\n    [is_add_submonoid s] (a : ↥s) (n : ℕ) : ↑(n •ℕ a) = n •ℕ ↑a :=\n  sorry\n\n/-- The natural injection from a submonoid into the monoid is a monoid hom. -/\nprotected instance subtype_val.is_add_monoid_hom {M : Type u_1} [add_monoid M] {s : set M}\n    [is_add_submonoid s] : is_add_monoid_hom subtype.val :=\n  is_add_monoid_hom.mk rfl\n\n/-- The natural injection from a submonoid into the monoid is a monoid hom. -/\nprotected instance coe.is_add_monoid_hom {M : Type u_1} [add_monoid M] {s : set M}\n    [is_add_submonoid s] : is_add_monoid_hom coe :=\n  subtype_val.is_add_monoid_hom\n\n/-- Given a monoid hom `f : γ → M` whose image is contained in a submonoid `s`, the induced map\n    from `γ` to `s` is a monoid hom. -/\nprotected instance subtype_mk.is_add_monoid_hom {M : Type u_1} [add_monoid M] {s : set M}\n    {γ : Type u_2} [add_monoid γ] [is_add_submonoid s] (f : γ → M) [is_add_monoid_hom f]\n    (h : ∀ (x : γ), f x ∈ s) : is_add_monoid_hom fun (x : γ) => { val := f x, property := h x } :=\n  is_add_monoid_hom.mk (subtype.eq (is_add_monoid_hom.map_zero f))\n\n/-- Given two submonoids `s` and `t` such that `s ⊆ t`, the natural injection from `s` into `t` is\n    a monoid hom. -/\nprotected instance set_inclusion.is_monoid_hom {M : Type u_1} [monoid M] {s : set M} (t : set M)\n    [is_submonoid s] [is_submonoid t] (h : s ⊆ t) : is_monoid_hom (set.inclusion h) :=\n  subtype_mk.is_monoid_hom (fun (x : ↥s) => ↑x) fun (x : ↥s) => set.inclusion._proof_1 h x\n\nnamespace add_monoid\n\n\n/-- The inductively defined membership predicate for the submonoid generated by a subset of a\n    monoid. -/\ninductive in_closure {A : Type u_2} [add_monoid A] (s : set A) : A → Prop where\n| basic : ∀ {a : A}, a ∈ s → in_closure s a\n| zero : in_closure s 0\n| add : ∀ {a b : A}, in_closure s a → in_closure s b → in_closure s (a + b)\n\nend add_monoid\n\n\nnamespace monoid\n\n\n/-- The inductively defined membership predicate for the `add_submonoid` generated by a subset of an\n    add_monoid. -/\ninductive in_closure {M : Type u_1} [monoid M] (s : set M) : M → Prop where\n| basic : ∀ {a : M}, a ∈ s → in_closure s a\n| one : in_closure s 1\n| mul : ∀ {a b : M}, in_closure s a → in_closure s b → in_closure s (a * b)\n\n/-- The inductively defined submonoid generated by a subset of a monoid. -/\ndef Mathlib.add_monoid.closure {M : Type u_1} [add_monoid M] (s : set M) : set M :=\n  set_of fun (a : M) => add_monoid.in_closure s a\n\nprotected instance Mathlib.add_monoid.closure.is_add_submonoid {M : Type u_1} [add_monoid M]\n    (s : set M) : is_add_submonoid (add_monoid.closure s) :=\n  is_add_submonoid.mk add_monoid.in_closure.zero fun (a b : M) => add_monoid.in_closure.add\n\n/-- A subset of a monoid is contained in the submonoid it generates. -/\ntheorem Mathlib.add_monoid.subset_closure {M : Type u_1} [add_monoid M] {s : set M} :\n    s ⊆ add_monoid.closure s :=\n  fun (a : M) => add_monoid.in_closure.basic\n\n/-- The submonoid generated by a set is contained in any submonoid that contains the set. -/\ntheorem Mathlib.add_monoid.closure_subset {M : Type u_1} [add_monoid M] {s : set M} {t : set M}\n    [is_add_submonoid t] (h : s ⊆ t) : add_monoid.closure s ⊆ t :=\n  sorry\n\n/-- Given subsets `t` and `s` of a monoid `M`, if `s ⊆ t`, the submonoid of `M` generated by `s` is\n    contained in the submonoid generated by `t`. -/\ntheorem Mathlib.add_monoid.closure_mono {M : Type u_1} [add_monoid M] {s : set M} {t : set M}\n    (h : s ⊆ t) : add_monoid.closure s ⊆ add_monoid.closure t :=\n  add_monoid.closure_subset (set.subset.trans h add_monoid.subset_closure)\n\n/-- The submonoid generated by an element of a monoid equals the set of natural number powers of\n    the element. -/\ntheorem closure_singleton {M : Type u_1} [monoid M] {x : M} : closure (singleton x) = powers x :=\n  set.eq_of_subset_of_subset (closure_subset (iff.mpr set.singleton_subset_iff powers.self_mem))\n    (is_submonoid.power_subset (iff.mp set.singleton_subset_iff subset_closure))\n\n/-- The image under a monoid hom of the submonoid generated by a set equals the submonoid generated\n    by the image of the set under the monoid hom. -/\ntheorem Mathlib.add_monoid.image_closure {M : Type u_1} [add_monoid M] {A : Type u_2} [add_monoid A]\n    (f : M → A) [is_add_monoid_hom f] (s : set M) :\n    f '' add_monoid.closure s = add_monoid.closure (f '' s) :=\n  sorry\n\n/-- Given an element `a` of the submonoid of a monoid `M` generated by a set `s`, there exists\na list of elements of `s` whose product is `a`. -/\ntheorem Mathlib.add_monoid.exists_list_of_mem_closure {M : Type u_1} [add_monoid M] {s : set M}\n    {a : M} (h : a ∈ add_monoid.closure s) :\n    ∃ (l : List M), (∀ (x : M), x ∈ l → x ∈ s) ∧ list.sum l = a :=\n  sorry\n\n/-- Given sets `s, t` of a commutative monoid `M`, `x ∈ M` is in the submonoid of `M` generated by\n    `s ∪ t` iff there exists an element of the submonoid generated by `s` and an element of the\n    submonoid generated by `t` whose product is `x`. -/\ntheorem Mathlib.add_monoid.mem_closure_union_iff {M : Type u_1} [add_comm_monoid M] {s : set M}\n    {t : set M} {x : M} :\n    x ∈ add_monoid.closure (s ∪ t) ↔\n        ∃ (y : M),\n          ∃ (H : y ∈ add_monoid.closure s),\n            ∃ (z : M), ∃ (H : z ∈ add_monoid.closure t), y + z = x :=\n  sorry\n\nend monoid\n\n\n/-- Create a bundled submonoid from a set `s` and `[is_submonoid s]`. -/\ndef add_submonoid.of {M : Type u_1} [add_monoid M] (s : set M) [h : is_add_submonoid s] :\n    add_submonoid M :=\n  add_submonoid.mk s is_add_submonoid.zero_mem is_add_submonoid.add_mem\n\nprotected instance submonoid.is_submonoid {M : Type u_1} [monoid M] (S : submonoid M) :\n    is_submonoid ↑S :=\n  is_submonoid.mk (submonoid.one_mem' S) (submonoid.mul_mem' S)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/deprecated/submonoid_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4820499587505823}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport data.set.pairwise\nimport data.set_like.basic\n\n/-!\n# Chains and flags\n\nThis file defines chains for an arbitrary relation and flags for an order and proves Hausdorff's\nMaximality Principle.\n\n## Main declarations\n\n* `is_chain s`: A chain `s` is a set of comparable elements.\n* `max_chain_spec`: Hausdorff's Maximality Principle.\n* `flag`: The type of flags, aka maximal chains, of an order.\n\n## Notes\n\nOriginally ported from Isabelle/HOL. The\n[original file](https://isabelle.in.tum.de/dist/library/HOL/HOL/Zorn.html) was written by Jacques D.\nFleuriot, Tobias Nipkow, Christian Sternagel.\n-/\n\nopen classical set\n\nvariables {α β : Type*}\n\n/-! ### Chains -/\n\nsection chain\nvariables (r : α → α → Prop)\n\nlocal infix ` ≺ `:50 := r\n\n/-- A chain is a set `s` satisfying `x ≺ y ∨ x = y ∨ y ≺ x` for all `x y ∈ s`. -/\ndef is_chain (s : set α) : Prop := s.pairwise (λ x y, x ≺ y ∨ y ≺ x)\n\n/-- `super_chain s t` means that `t` is a chain that strictly includes `s`. -/\ndef super_chain (s t : set α) : Prop := is_chain r t ∧ s ⊂ t\n\n/-- A chain `s` is a maximal chain if there does not exists a chain strictly including `s`. -/\ndef is_max_chain (s : set α) : Prop := is_chain r s ∧ ∀ ⦃t⦄, is_chain r t → s ⊆ t → s = t\n\nvariables {r} {c c₁ c₂ c₃ s t : set α} {a b x y : α}\n\nlemma is_chain_empty : is_chain r ∅ := set.pairwise_empty _\n\nlemma set.subsingleton.is_chain (hs : s.subsingleton) : is_chain r s := hs.pairwise _\n\nlemma is_chain.mono : s ⊆ t → is_chain r t → is_chain r s := set.pairwise.mono\n\nlemma is_chain.mono_rel {r' : α → α → Prop} (h : is_chain r s)\n  (h_imp : ∀ x y, r x y → r' x y) : is_chain r' s :=\nh.mono' $ λ x y, or.imp (h_imp x y) (h_imp y x)\n\n/-- This can be used to turn `is_chain (≥)` into `is_chain (≤)` and vice-versa. -/\nlemma is_chain.symm (h : is_chain r s) : is_chain (flip r) s := h.mono' $ λ _ _, or.symm\n\nlemma is_chain_of_trichotomous [is_trichotomous α r] (s : set α) : is_chain r s :=\nλ a _ b _ hab, (trichotomous_of r a b).imp_right $ λ h, h.resolve_left hab\n\nlemma is_chain.insert (hs : is_chain r s) (ha : ∀ b ∈ s, a ≠ b → a ≺ b ∨ b ≺ a) :\n  is_chain r (insert a s) :=\nhs.insert_of_symmetric (λ _ _, or.symm) ha\n\nlemma is_chain_univ_iff : is_chain r (univ : set α) ↔ is_trichotomous α r :=\nbegin\n  refine ⟨λ h, ⟨λ a b , _⟩, λ h, @is_chain_of_trichotomous _ _ h univ⟩,\n  rw [or.left_comm, or_iff_not_imp_left],\n  exact h trivial trivial,\nend\n\nlemma is_chain.image (r : α → α → Prop) (s : β → β → Prop) (f : α → β)\n  (h : ∀ x y, r x y → s (f x) (f y)) {c : set α} (hrc : is_chain r c) :\n  is_chain s (f '' c) :=\nλ x ⟨a, ha₁, ha₂⟩ y ⟨b, hb₁, hb₂⟩, ha₂ ▸ hb₂ ▸ λ hxy,\n  (hrc ha₁ hb₁ $ ne_of_apply_ne f hxy).imp (h _ _) (h _ _)\n\nsection total\nvariables [is_refl α r]\n\nlemma is_chain.total (h : is_chain r s) (hx : x ∈ s) (hy : y ∈ s) : x ≺ y ∨ y ≺ x :=\n(eq_or_ne x y).elim (λ e, or.inl $ e ▸ refl _) (h hx hy)\n\nlemma is_chain.directed_on (H : is_chain r s) : directed_on r s :=\nλ x hx y hy, (H.total hx hy).elim (λ h, ⟨y, hy, h, refl _⟩) $ λ h, ⟨x, hx, refl _, h⟩\n\nprotected lemma is_chain.directed {f : β → α} {c : set β} (h : is_chain (f ⁻¹'o r) c) :\n  directed r (λ x : {a : β // a ∈ c}, f x) :=\nλ ⟨a, ha⟩ ⟨b, hb⟩, by_cases\n  (λ hab : a = b, by simp only [hab, exists_prop, and_self, subtype.exists];\n    exact ⟨b, hb, refl _⟩) $\n  λ hab, (h ha hb hab).elim (λ h, ⟨⟨b, hb⟩, h, refl _⟩) $ λ h, ⟨⟨a, ha⟩, refl _, h⟩\n\nend total\n\nlemma is_max_chain.is_chain (h : is_max_chain r s) : is_chain r s := h.1\nlemma is_max_chain.not_super_chain (h : is_max_chain r s) : ¬super_chain r s t :=\nλ ht, ht.2.ne $ h.2 ht.1 ht.2.1\n\nlemma is_max_chain.bot_mem [has_le α] [order_bot α] (h : is_max_chain (≤) s) : ⊥ ∈ s :=\n(h.2 (h.1.insert $ λ a _ _, or.inl bot_le) $ subset_insert _ _).symm ▸ mem_insert _ _\n\nlemma is_max_chain.top_mem [has_le α] [order_top α] (h : is_max_chain (≤) s) : ⊤ ∈ s :=\n(h.2 (h.1.insert $ λ a _ _, or.inr le_top) $ subset_insert _ _).symm ▸ mem_insert _ _\n\nopen_locale classical\n\n/-- Given a set `s`, if there exists a chain `t` strictly including `s`, then `succ_chain s`\nis one of these chains. Otherwise it is `s`. -/\ndef succ_chain (r : α → α → Prop) (s : set α) : set α :=\nif h : ∃ t, is_chain r s ∧ super_chain r s t then some h else s\n\nlemma succ_chain_spec (h : ∃ t, is_chain r s ∧ super_chain r s t) :\n  super_chain r s (succ_chain r s) :=\nlet ⟨t, hc'⟩ := h in\nhave is_chain r s ∧ super_chain r s (some h),\n  from @some_spec _ (λ t, is_chain r s ∧ super_chain r s t) _,\nby simp [succ_chain, dif_pos, h, this.right]\n\nlemma is_chain.succ (hs : is_chain r s) : is_chain r (succ_chain r s) :=\nif h : ∃ t, is_chain r s ∧ super_chain r s t then (succ_chain_spec h).1\n  else by { simp [succ_chain, dif_neg, h], exact hs }\n\nlemma is_chain.super_chain_succ_chain (hs₁ : is_chain r s) (hs₂ : ¬ is_max_chain r s) :\n  super_chain r s (succ_chain r s) :=\nbegin\n  simp [is_max_chain, not_and_distrib, not_forall_not] at hs₂,\n  obtain ⟨t, ht, hst⟩ := hs₂.neg_resolve_left hs₁,\n  exact succ_chain_spec ⟨t, hs₁, ht, ssubset_iff_subset_ne.2 hst⟩,\nend\n\nlemma subset_succ_chain : s ⊆ succ_chain r s :=\nif h : ∃ t, is_chain r s ∧ super_chain r s t then (succ_chain_spec h).2.1\n  else by simp [succ_chain, dif_neg, h, subset.rfl]\n\n/-- Predicate for whether a set is reachable from `∅` using `succ_chain` and `⋃₀`. -/\ninductive chain_closure (r : α → α → Prop) : set α → Prop\n| succ : ∀ {s}, chain_closure s → chain_closure (succ_chain r s)\n| union : ∀ {s}, (∀ a ∈ s, chain_closure a) → chain_closure (⋃₀ s)\n\n/-- An explicit maximal chain. `max_chain` is taken to be the union of all sets in `chain_closure`.\n-/\ndef max_chain (r : α → α → Prop) := ⋃₀ set_of (chain_closure r)\n\nlemma chain_closure_empty : chain_closure r ∅ :=\nhave chain_closure r (⋃₀ ∅),\n  from chain_closure.union $ λ a h, h.rec _,\nby simpa using this\n\nlemma chain_closure_max_chain : chain_closure r (max_chain r) := chain_closure.union $ λ s, id\n\nprivate lemma chain_closure_succ_total_aux (hc₁ : chain_closure r c₁) (hc₂ : chain_closure r c₂)\n  (h : ∀ ⦃c₃⦄, chain_closure r c₃ → c₃ ⊆ c₂ → c₂ = c₃ ∨ succ_chain r c₃ ⊆ c₂) :\n  succ_chain r c₂ ⊆ c₁ ∨ c₁ ⊆ c₂ :=\nbegin\n  induction hc₁,\n  case succ : c₃ hc₃ ih\n  { cases ih with ih ih,\n    { exact or.inl (ih.trans subset_succ_chain) },\n    { exact (h hc₃ ih).imp_left (λ h, h ▸ subset.rfl) } },\n  case union : s hs ih\n  { refine (or_iff_not_imp_left.2 $ λ hn, sUnion_subset $ λ a ha, _),\n    exact (ih a ha).resolve_left (λ h, hn $ h.trans $ subset_sUnion_of_mem ha) }\nend\n\nprivate lemma chain_closure_succ_total (hc₁ : chain_closure r c₁) (hc₂ : chain_closure r c₂)\n  (h : c₁ ⊆ c₂) :\n  c₂ = c₁ ∨ succ_chain r c₁ ⊆ c₂ :=\nbegin\n  induction hc₂ generalizing c₁ hc₁ h,\n  case succ : c₂ hc₂ ih\n  { refine (chain_closure_succ_total_aux hc₁ hc₂ $ λ c₁, ih).imp h.antisymm' (λ h₁, _),\n    obtain rfl | h₂ := ih hc₁ h₁,\n    { exact subset.rfl },\n    { exact h₂.trans subset_succ_chain } },\n  case union : s hs ih\n  { apply or.imp_left h.antisymm',\n    apply classical.by_contradiction,\n    simp [not_or_distrib, sUnion_subset_iff, not_forall],\n    intros c₃ hc₃ h₁ h₂,\n    obtain h | h := chain_closure_succ_total_aux hc₁ (hs c₃ hc₃) (λ c₄, ih _ hc₃),\n    { exact h₁ (subset_succ_chain.trans h) },\n    obtain h' | h' := ih c₃ hc₃ hc₁ h,\n    { exact h₁ h'.subset },\n    { exact h₂ (h'.trans $ subset_sUnion_of_mem hc₃) } }\nend\n\nlemma chain_closure.total (hc₁ : chain_closure r c₁) (hc₂ : chain_closure r c₂) :\n  c₁ ⊆ c₂ ∨ c₂ ⊆ c₁ :=\n(chain_closure_succ_total_aux hc₂ hc₁ $ λ c₃ hc₃, chain_closure_succ_total hc₃ hc₁).imp_left\n  subset_succ_chain.trans\n\nlemma chain_closure.succ_fixpoint (hc₁ : chain_closure r c₁) (hc₂ : chain_closure r c₂)\n  (hc : succ_chain r c₂ = c₂) :\n  c₁ ⊆ c₂ :=\nbegin\n  induction hc₁,\n  case succ : s₁ hc₁ h\n  { exact (chain_closure_succ_total hc₁ hc₂ h).elim (λ h, h ▸ hc.subset) id },\n  case union : s hs ih\n  { exact sUnion_subset ih }\nend\n\nlemma chain_closure.succ_fixpoint_iff (hc : chain_closure r c) :\n  succ_chain r c = c ↔ c = max_chain r :=\n⟨λ h, (subset_sUnion_of_mem hc).antisymm $ chain_closure_max_chain.succ_fixpoint hc h,\n  λ h, subset_succ_chain.antisymm' $ (subset_sUnion_of_mem hc.succ).trans h.symm.subset⟩\n\nlemma chain_closure.is_chain (hc : chain_closure r c) : is_chain r c :=\nbegin\n  induction hc,\n  case succ : c hc h\n  { exact h.succ },\n  case union : s hs h\n  { change ∀ c ∈ s, is_chain r c at h,\n    exact λ c₁ ⟨t₁, ht₁, (hc₁ : c₁ ∈ t₁)⟩ c₂ ⟨t₂, ht₂, (hc₂ : c₂ ∈ t₂)⟩ hneq,\n      ((hs _ ht₁).total $ hs _ ht₂).elim\n        (λ ht, h t₂ ht₂ (ht hc₁) hc₂ hneq)\n        (λ ht, h t₁ ht₁ hc₁ (ht hc₂) hneq) }\nend\n\n/-- **Hausdorff's maximality principle**\n\nThere exists a maximal totally ordered set of `α`.\nNote that we do not require `α` to be partially ordered by `r`. -/\nlemma max_chain_spec : is_max_chain r (max_chain r) :=\nclassical.by_contradiction $ λ h,\nlet ⟨h₁, H⟩ := chain_closure_max_chain.is_chain.super_chain_succ_chain h in\n  H.ne (chain_closure_max_chain.succ_fixpoint_iff.mpr rfl).symm\n\nend chain\n\n/-! ### Flags -/\n\n/-- The type of flags, aka maximal chains, of an order. -/\nstructure flag (α : Type*) [has_le α] :=\n(carrier : set α)\n(chain' : is_chain (≤) carrier)\n(max_chain' : ∀ ⦃s⦄, is_chain (≤) s → carrier ⊆ s → carrier = s)\n\nnamespace flag\nsection has_le\nvariables [has_le α] {s t : flag α} {a : α}\n\ninstance : set_like (flag α) α :=\n{ coe := carrier,\n  coe_injective' := λ s t h, by { cases s, cases t, congr' } }\n\n@[ext] lemma ext : (s : set α) = t → s = t := set_like.ext'\n@[simp] lemma mem_coe_iff : a ∈ (s : set α) ↔ a ∈ s := iff.rfl\n@[simp] lemma coe_mk (s : set α) (h₁ h₂) : (mk s h₁ h₂ : set α) = s := rfl\n@[simp] lemma mk_coe (s : flag α) : mk (s : set α) s.chain' s.max_chain' = s := ext rfl\n\nlemma chain_le (s : flag α) : is_chain (≤) (s : set α) := s.chain'\nprotected lemma max_chain (s : flag α) : is_max_chain (≤) (s : set α) := ⟨s.chain_le, s.max_chain'⟩\n\nlemma top_mem [order_top α] (s : flag α) : (⊤ : α) ∈ s := s.max_chain.top_mem\nlemma bot_mem [order_bot α] (s : flag α) : (⊥ : α) ∈ s := s.max_chain.bot_mem\n\nend has_le\n\nsection preorder\nvariables [preorder α] {a b : α}\n\nprotected lemma le_or_le (s : flag α) (ha : a ∈ s) (hb : b ∈ s) : a ≤ b ∨ b ≤ a :=\ns.chain_le.total ha hb\n\ninstance [order_top α] (s : flag α) : order_top s := subtype.order_top s.top_mem\ninstance [order_bot α] (s : flag α) : order_bot s := subtype.order_bot s.bot_mem\ninstance [bounded_order α] (s : flag α) : bounded_order s :=\nsubtype.bounded_order s.bot_mem s.top_mem\n\nend preorder\n\nsection partial_order\nvariables [partial_order α]\n\nlemma chain_lt (s : flag α) : is_chain (<) (s : set α) :=\nλ a ha b hb h, (s.le_or_le ha hb).imp h.lt_of_le h.lt_of_le'\n\ninstance [decidable_eq α] [@decidable_rel α (≤)] [@decidable_rel α (<)] (s : flag α) :\n  linear_order s :=\n{ le_total := λ a b, s.le_or_le a.2 b.2,\n  decidable_eq := subtype.decidable_eq,\n  decidable_le := subtype.decidable_le,\n  decidable_lt := subtype.decidable_lt,\n  ..subtype.partial_order _ }\n\nend partial_order\n\ninstance [linear_order α] : unique (flag α) :=\n{ default := ⟨univ, is_chain_of_trichotomous _, λ s _, s.subset_univ.antisymm'⟩,\n  uniq := λ s, set_like.coe_injective $ s.3 (is_chain_of_trichotomous _) $ subset_univ _ }\n\nend flag\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/order/chain.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.48204995443029985}}
{"text": "\nsection\nvariables {α : Type*} [semiring α]\n\ntheorem mul_two_eq_add_self (x : α) : x * 2 = x + x :=\nshow x * (1 + 1) = x + x, by rw [mul_add, mul_one]\n\ntheorem two_mul_eq_add_self (x : α) : 2 * x = x + x :=\nshow (1 + 1) * x = x + x, by rw [add_mul, one_mul]\n\nend\n\nnamespace linear_ordered_ring\nvariables (α : Type*) [i : linear_ordered_ring α]\ninclude i\n\nlemma one_pos : (0:α) < 1 := zero_lt_one α\n\nlemma two_pos : (0:α) < 2 := _root_.add_pos (one_pos α) (one_pos α)\n\nvariable {α}\n\nlemma add_pos (x y : α) : 0 < x → 0 < y → 0 < x + y := _root_.add_pos\n\nlemma succ_pos (x : α) : 0 < x → 0 < x + 1 := λ h, add_pos x 1 h (one_pos α)\n\n-- linear_ordered_ring.mul_pos (x y : α) : 0 < x → 0 < y → 0 < x * y\n\nlemma bit0_pos (x : α) : 0 < x → 0 < bit0 x := λ h, add_pos x x h h\n\nlemma bit1_pos (x : α) : 0 < x → 0 < bit1 x := λ h, succ_pos (bit0 x) (bit0_pos x h)\n\nclass num_pos (x : α) := (elim : (0:α) < x)\n\nnamespace num_pos\nvariable {i}\n\n@[priority 30] instance one : @num_pos α i (1:α) := ⟨one_pos α⟩\n@[priority 30] instance two : @num_pos α i (2:α) := ⟨two_pos α⟩\n@[priority 30] instance bit0 (x : α) [@num_pos α i x] : @num_pos α i (bit0 x) := ⟨bit0_pos x (elim x)⟩\n@[priority 30] instance bit1 (x : α) [@num_pos α i x] : @num_pos α i (bit1 x) := ⟨bit1_pos x (elim x)⟩\n@[priority 10] instance succ (x : α) [@num_pos α i x] : @num_pos α i (x+1) := ⟨succ_pos x (elim x)⟩\n@[priority 20] instance add (x y : α) [@num_pos α i x] [@num_pos α i y] : @num_pos α i (x + y) := ⟨add_pos x y (elim x) (elim y)⟩\n@[priority 30] instance mul (x y : α) [@num_pos α i x] [@num_pos α i y] : @num_pos α i (x * y) := ⟨mul_pos x y (elim x) (elim y)⟩\n\nend num_pos\n\nclass num_nonzero (x : α) := (elim : x ≠ (0:α))\n\n@[priority 30] instance of_pos (x : α) {i : linear_ordered_ring α} [@num_pos α i x] : num_nonzero x := ⟨ne_of_gt $ num_pos.elim x⟩\n\nend linear_ordered_ring\n\ntheorem pos_trivial {α : Type*} [linear_ordered_ring α] (x : α) [linear_ordered_ring.num_pos x] : (0:α) < x := linear_ordered_ring.num_pos.elim x\ntheorem nonzero_trivial {α : Type*} [linear_ordered_ring α] (x : α) [linear_ordered_ring.num_nonzero x] : x ≠ 0 := linear_ordered_ring.num_nonzero.elim x\n\nsection\nvariables {α : Type*} [linear_ordered_ring α]\n\ntheorem le_of_mul_ge_mul_left {a b c : α} : c * b ≤ c * a → c < 0 → a ≤ b :=\nbegin\nintros h hc,\nhave hc : -c > 0 := neg_pos_of_neg hc,\napply le_of_mul_le_mul_left _ hc,\napply le_of_neg_le_neg,\nrw [neg_mul_eq_neg_mul, neg_mul_eq_neg_mul, neg_neg],\nassumption,\nend\n\ntheorem le_of_mul_ge_mul_right {a b c : α} : b * c ≤ a * c → c < 0 → a ≤ b :=\nbegin\nintros h hc,\nhave hc : -c > 0 := neg_pos_of_neg hc,\napply le_of_mul_le_mul_right _ hc,\napply le_of_neg_le_neg,\nrw [neg_mul_eq_mul_neg, neg_mul_eq_mul_neg, neg_neg],\nassumption,\nend\n\nend\n\nsection\nvariables {α : Type*} [linear_ordered_field α]\n\ntheorem div_le_of_le_mul_of_pos {x y : α} (z : α) : x ≤ y*z → 0 < z → x/z ≤ y :=\nbegin\nintros hm hz,\napply le_of_mul_le_mul_right _ hz,\ntransitivity x,\n{ apply le_of_eq,\n  apply div_mul_cancel,\n  apply ne_of_gt,\n  assumption },\n{ assumption },\nend\n\ntheorem le_div_of_mul_le_of_pos {x y : α} (z : α) : x*z ≤ y → 0 < z → x ≤ y/z :=\nbegin\nintros hm hz,\napply le_of_mul_le_mul_right _ hz,\ntransitivity y,\n{ assumption },\n{ apply le_of_eq,\n  symmetry,\n  apply div_mul_cancel,\n  apply ne_of_gt,\n  assumption },\nend\n\ntheorem le_div_of_mul_ge_of_neg {x y : α} (z : α) : y ≤ x*z → z < 0 → x ≤ y/z :=\nbegin\nintros hm hz,\napply le_of_mul_ge_mul_right _ hz,\ntransitivity y,\n{ apply le_of_eq,\n  apply div_mul_cancel,\n  apply ne_of_lt,\n  assumption },\n{ assumption },\nend\n\ntheorem div_le_of_ge_mul_of_neg {x y : α} (z : α) : y*z ≤ x → z < 0 → x/z ≤ y :=\nbegin\nintros hm hz,\napply le_of_mul_ge_mul_right _ hz,\ntransitivity x,\n{ assumption },\n{ apply le_of_eq,\n  symmetry,\n  apply div_mul_cancel,\n  apply ne_of_lt,\n  assumption },\nend\n\nend\n\nnamespace order\n\ninductive {u} lt_cmp {α : Type u} [has_lt α] (x y : α) : Type u\n| eq : x = y → lt_cmp\n| lt : x < y → lt_cmp\n| gt : y < x → lt_cmp\n\ninductive {u} le_cmp {α : Type u} [has_le α] (x y : α) : Type u\n| le : x ≤ y → le_cmp\n| ge : y ≤ x → le_cmp\n\nvariables {α : Type*} [decidable_linear_order α]\n\ndef lt_compare (x y : α) : lt_cmp x y :=\nif hlt : x < y then\nlt_cmp.lt hlt\nelse if hgt : y < x then\nlt_cmp.gt hgt\nelse\nlt_cmp.eq $ le_antisymm (le_of_not_gt hgt) (le_of_not_gt hlt)\n\ndef le_compare (x y : α) : le_cmp x y :=\nif h : x < y then\nle_cmp.le (le_of_lt h)\nelse\nle_cmp.ge (le_of_not_gt h)\n\n@[elab_as_eliminator]\ndef trichotomy_on (x y : α) {C : Sort*} : (x = y → C) → (x < y → C) → (y < x → C) → C :=\nλ heq hlt hgt, lt_cmp.cases_on (lt_compare x y) heq hlt hgt\n\n@[elab_as_eliminator]\ndef dichotomy_on (x y : α) {C : Sort*} : (x ≤ y → C) → (y ≤ x → C) → C :=\nλ hle hge, le_cmp.cases_on (le_compare x y) hle hge\n\nend order\n\nnamespace tactic\nopen interactive\n\n/--\n`by_trichotomy (x, y)` splits the goal into three branches, the first assuming `x = y`,\nthe second assuming `x < y` and the third assuming `y < x`.\n\nThis tactic requires that terms `x` and `y` have the same type and that this type has \n`decidable_linear_order` instance.\n-/\nmeta def interactive.by_trichotomy : parse types.texpr → tactic unit :=\nλ e, do {\n  `(@prod.mk %%t %%.(t) %%x %%y) ← to_expr e,\n  d ← to_expr ``(decidable_linear_order %%t) >>= mk_instance\n    <|> fail (\"cannot find decidable_linear_order instance for type \" ++ to_string t),\n  to_expr ``(@order.trichotomy_on %%t %%d %%x %%y) >>= apply >> skip\n}\n\n/--\n`by_trichotomy (x, y)` splits the goal into two branches, the first assuming `x ≤ y`\nand the second assuming `y ≤ x`.\n\nThis tactic requires that terms `x` and `y` have the same type and that this type has \n`decidable_linear_order` instance.\n-/\nmeta def interactive.by_dichotomy : parse types.texpr → tactic unit :=\nλ e, do {\n  `(@prod.mk %%t %%.(t) %%x %%y) ← to_expr e,\n  d ← to_expr ``(decidable_linear_order %%t) >>= mk_instance\n    <|> fail (\"cannot find decidable_linear_order instance for \" ++ to_string t),\n  to_expr ``(@order.dichotomy_on %%t %%d %%x %%y) >>= apply >> skip\n}\n\nend tactic\n", "meta": {"author": "UVM-M52", "repo": "week-8-mhill13", "sha": "37cb83fd8f4661101b00f9baca5703be2add45de", "save_path": "github-repos/lean/UVM-M52-week-8-mhill13", "path": "github-repos/lean/UVM-M52-week-8-mhill13/week-8-mhill13-37cb83fd8f4661101b00f9baca5703be2add45de/src/utils/cmp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.48204995001473067}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.group_action_hom\nimport algebra.module.basic\nimport data.set_like.basic\nimport group_theory.group_action.basic\n/-!\n\n# Sets invariant to a `mul_action`\n\nIn this file we define `sub_mul_action R M`; a subset of a `mul_action R M` which is closed with\nrespect to scalar multiplication.\n\nFor most uses, typically `submodule R M` is more powerful.\n\n## Main definitions\n\n* `sub_mul_action.mul_action` - the `mul_action R M` transferred to the subtype.\n* `sub_mul_action.mul_action'` - the `mul_action S M` transferred to the subtype when\n  `is_scalar_tower S R M`.\n* `sub_mul_action.is_scalar_tower` - the `is_scalar_tower S R M` transferred to the subtype.\n\n## Tags\n\nsubmodule, mul_action\n-/\n\nopen function\n\nuniverses u u' u'' v\nvariables {S : Type u'} {T : Type u''} {R : Type u} {M : Type v}\n\nset_option old_structure_cmd true\n\n/-- A sub_mul_action is a set which is closed under scalar multiplication.  -/\nstructure sub_mul_action (R : Type u) (M : Type v) [has_scalar R M] : Type v :=\n(carrier : set M)\n(smul_mem' : ∀ (c : R) {x : M}, x ∈ carrier → c • x ∈ carrier)\n\nnamespace sub_mul_action\n\nvariables [has_scalar R M]\n\ninstance : set_like (sub_mul_action R M) M :=\n⟨sub_mul_action.carrier, λ p q h, by cases p; cases q; congr'⟩\n\n@[simp] lemma mem_carrier {p : sub_mul_action R M} {x : M} : x ∈ p.carrier ↔ x ∈ (p : set M) :=\niff.rfl\n\n@[ext] theorem ext {p q : sub_mul_action R M} (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := set_like.ext h\n\n/-- Copy of a sub_mul_action with a new `carrier` equal to the old one. Useful to fix definitional\nequalities.-/\nprotected def copy (p : sub_mul_action R M) (s : set M) (hs : s = ↑p) : sub_mul_action R M :=\n{ carrier := s,\n  smul_mem' := hs.symm ▸ p.smul_mem' }\n\n@[simp] lemma coe_copy (p : sub_mul_action R M) (s : set M) (hs : s = ↑p) :\n  (p.copy s hs : set M) = s := rfl\n\nlemma copy_eq (p : sub_mul_action R M) (s : set M) (hs : s = ↑p) : p.copy s hs = p :=\nset_like.coe_injective hs\n\ninstance : has_bot (sub_mul_action R M) :=\n⟨{ carrier := ∅, smul_mem' := λ c, set.not_mem_empty}⟩\n\ninstance : inhabited (sub_mul_action R M) := ⟨⊥⟩\n\nend sub_mul_action\n\nnamespace sub_mul_action\n\nsection has_scalar\n\nvariables [has_scalar R M]\nvariables (p : sub_mul_action R M)\nvariables {r : R} {x : M}\n\nlemma smul_mem (r : R) (h : x ∈ p) : r • x ∈ p := p.smul_mem' r h\n\ninstance : has_scalar R p :=\n{ smul := λ c x, ⟨c • x.1, smul_mem _ c x.2⟩ }\n\nvariables {p}\n@[simp, norm_cast] lemma coe_smul (r : R) (x : p) : ((r • x : p) : M) = r • ↑x := rfl\n@[simp, norm_cast] lemma coe_mk (x : M) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : M) = x := rfl\n\nvariables (p)\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype : p →[R] M :=\nby refine {to_fun := coe, ..}; simp [coe_smul]\n\n@[simp] theorem subtype_apply (x : p) : p.subtype x = x := rfl\n\nlemma subtype_eq_val : ((sub_mul_action.subtype p) : p → M) = subtype.val := rfl\n\nend has_scalar\n\nsection mul_action\n\nvariables [monoid R] [mul_action R M]\n\nsection\nvariables [has_scalar S R] [has_scalar S M] [is_scalar_tower S R M]\nvariables (p : sub_mul_action R M)\n\nlemma smul_of_tower_mem (s : S) {x : M} (h : x ∈ p) : s • x ∈ p :=\nby { rw [←one_smul R x, ←smul_assoc], exact p.smul_mem _ h }\n\ninstance has_scalar' : has_scalar S p :=\n{ smul := λ c x, ⟨c • x.1, smul_of_tower_mem _ c x.2⟩ }\n\ninstance : is_scalar_tower S R p :=\n{ smul_assoc := λ s r x, subtype.ext $ smul_assoc s r ↑x }\n\n@[simp, norm_cast] lemma coe_smul_of_tower (s : S) (x : p) : ((s • x : p) : M) = s • ↑x := rfl\n\n@[simp] lemma smul_mem_iff' {G} [group G] [has_scalar G R] [mul_action G M]\n  [is_scalar_tower G R M] (g : G) {x : M} :\n  g • x ∈ p ↔ x ∈ p :=\n⟨λ h, inv_smul_smul g x ▸ p.smul_of_tower_mem g⁻¹ h, p.smul_of_tower_mem g⟩\n\nend\n\nsection\nvariables [monoid S] [has_scalar S R] [mul_action S M] [is_scalar_tower S R M]\nvariables (p : sub_mul_action R M)\n\n/-- If the scalar product forms a `mul_action`, then the subset inherits this action -/\ninstance mul_action' : mul_action S p :=\n{ smul := (•),\n  one_smul := λ x, subtype.ext $ one_smul _ x,\n  mul_smul := λ c₁ c₂ x, subtype.ext $ mul_smul c₁ c₂ x }\n\ninstance : mul_action R p := p.mul_action'\n\nend\n\nend mul_action\n\nsection module\n\nvariables [semiring R] [add_comm_monoid M]\nvariables [module R M]\nvariables (p : sub_mul_action R M)\n\nlemma zero_mem (h : (p : set M).nonempty) : (0 : M) ∈ p :=\nlet ⟨x, hx⟩ := h in zero_smul R (x : M) ▸ p.smul_mem 0 hx\n\n/-- If the scalar product forms a `module`, and the `sub_mul_action` is not `⊥`, then the\nsubset inherits the zero. -/\ninstance [n_empty : nonempty p] : has_zero p :=\n{ zero := ⟨0, n_empty.elim $ λ x, p.zero_mem ⟨x, x.prop⟩⟩ }\n\nend module\n\nsection add_comm_group\n\nvariables [ring R] [add_comm_group M]\nvariables [module R M]\nvariables (p p' : sub_mul_action R M)\nvariables {r : R} {x y : M}\n\nlemma neg_mem (hx : x ∈ p) : -x ∈ p := by { rw ← neg_one_smul R, exact p.smul_mem _ hx }\n\n@[simp] lemma neg_mem_iff : -x ∈ p ↔ x ∈ p :=\n⟨λ h, by { rw ←neg_neg x, exact neg_mem _ h}, neg_mem _⟩\n\ninstance : has_neg p := ⟨λx, ⟨-x.1, neg_mem _ x.2⟩⟩\n\n@[simp, norm_cast] lemma coe_neg (x : p) : ((-x : p) : M) = -x := rfl\n\nend add_comm_group\n\nend sub_mul_action\n\nnamespace sub_mul_action\n\nvariables [division_ring S] [semiring R] [mul_action R M]\nvariables [has_scalar S R] [mul_action S M] [is_scalar_tower S R M]\nvariables (p : sub_mul_action R M) {s : S} {x y : M}\n\ntheorem smul_mem_iff (s0 : s ≠ 0) : s • x ∈ p ↔ x ∈ p :=\np.smul_mem_iff' (units.mk0 s s0)\n\nend sub_mul_action\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/group_theory/group_action/sub_mul_action.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347362, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.48204994569444787}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Sébastien Gouëzel, Zhouhang Zhou, Reid Barton\n-/\nimport topology.dense_embedding\n\nopen set filter\nopen_locale topological_space\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\n\n/-- Homeomorphism between `α` and `β`, also called topological isomorphism -/\n@[nolint has_inhabited_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (α : Type*) (β : Type*) [topological_space α] [topological_space β]\n  extends α ≃ β :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` ≃ₜ `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n\ninstance : has_coe_to_fun (α ≃ₜ β) := ⟨λ_, α → β, λe, e.to_equiv⟩\n\n@[simp] lemma homeomorph_mk_coe (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c) : α → β) = a :=\nrfl\n\n@[simp] lemma coe_to_equiv (h : α ≃ₜ β) : ⇑h.to_equiv = h := rfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : α ≃ₜ β) : β ≃ₜ α :=\n{ continuous_to_fun  := h.continuous_inv_fun,\n  continuous_inv_fun := h.continuous_to_fun,\n  to_equiv := h.to_equiv.symm }\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : α ≃ₜ β) : α → β := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : α ≃ₜ β) : β → α := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply, -to_equiv)\n\nlemma to_equiv_injective : function.injective (to_equiv : α ≃ₜ β → α ≃ β)\n| ⟨e, h₁, h₂⟩ ⟨e', h₁', h₂'⟩ rfl := rfl\n\n@[ext] lemma ext {h h' : α ≃ₜ β} (H : ∀ x, h x = h' x) : h = h' :=\nto_equiv_injective $ equiv.ext H\n\n/-- Identity map as a homeomorphism. -/\n@[simps apply {fully_applied := ff}]\nprotected def refl (α : Type*) [topological_space α] : α ≃ₜ α :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl α }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) : α ≃ₜ γ :=\n{ continuous_to_fun  := h₂.continuous_to_fun.comp h₁.continuous_to_fun,\n  continuous_inv_fun := h₁.continuous_inv_fun.comp h₂.continuous_inv_fun,\n  to_equiv := equiv.trans h₁.to_equiv h₂.to_equiv }\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv α β) (b c) :\n  ((homeomorph.mk a b c).symm : β → α) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl α).symm = homeomorph.refl α := rfl\n\n@[continuity]\nprotected lemma continuous (h : α ≃ₜ β) : continuous h := h.continuous_to_fun\n\n@[continuity] -- otherwise `by continuity` can't prove continuity of `h.to_equiv.symm`\nprotected lemma continuous_symm (h : α ≃ₜ β) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : α ≃ₜ β) (x : β) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : α ≃ₜ β) (x : α) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : α ≃ₜ β) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : α ≃ₜ β) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : α ≃ₜ β) : function.surjective h := h.to_equiv.surjective\n\n/-- Change the homeomorphism `f` to make the inverse function definitionally equal to `g`. -/\ndef change_inv (f : α ≃ₜ β) (g : β → α) (hg : function.right_inverse g f) : α ≃ₜ β :=\nhave g = f.symm, from funext (λ x, calc g x = f.symm (f (g x)) : (f.left_inv (g x)).symm\n                                        ... = f.symm x : by rw hg x),\n{ to_fun := f,\n  inv_fun := g,\n  left_inv := by convert f.left_inv,\n  right_inv := by convert f.right_inv,\n  continuous_to_fun := f.continuous,\n  continuous_inv_fun := by convert f.symm.continuous }\n\n@[simp] lemma symm_comp_self (h : α ≃ₜ β) : ⇑h.symm ∘ ⇑h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : α ≃ₜ β) : ⇑h ∘ ⇑h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : α ≃ₜ β) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : α ≃ₜ β) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : α ≃ₜ β) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : α ≃ₜ β) (s : set β) : h '' (h ⁻¹' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : α ≃ₜ β) (s : set α) : h ⁻¹' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : α ≃ₜ β) : inducing h :=\ninducing_of_inducing_compose h.continuous h.symm.continuous $\n  by simp only [symm_comp_self, inducing_id]\n\nlemma induced_eq (h : α ≃ₜ β) : topological_space.induced h ‹_› = ‹_› := h.inducing.1.symm\n\nprotected lemma quotient_map (h : α ≃ₜ β) : quotient_map h :=\nquotient_map.of_quotient_map_compose h.symm.continuous h.continuous $\n  by simp only [self_comp_symm, quotient_map.id]\n\nlemma coinduced_eq (h : α ≃ₜ β) : topological_space.coinduced h ‹_› = ‹_› :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : α ≃ₜ β) : embedding h :=\n⟨h.inducing, h.injective⟩\n\nprotected lemma second_countable_topology [topological_space.second_countable_topology β]\n  (h : α ≃ₜ β) :\n  topological_space.second_countable_topology α :=\nh.inducing.second_countable_topology\n\nlemma compact_image {s : set α} (h : α ≃ₜ β) : is_compact (h '' s) ↔ is_compact s :=\nh.embedding.compact_iff_compact_image.symm\n\nlemma compact_preimage {s : set β} (h : α ≃ₜ β) : is_compact (h ⁻¹' s) ↔ is_compact s :=\nby rw ← image_symm; exact h.symm.compact_image\n\nprotected lemma dense_embedding (h : α ≃ₜ β) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : α ≃ₜ β) {s : set β} : is_open (h ⁻¹' s) ↔ is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : α ≃ₜ β) {s : set α} : is_open (h '' s) ↔ is_open s :=\nby rw [← preimage_symm, is_open_preimage]\n\n@[simp] lemma is_closed_preimage (h : α ≃ₜ β) {s : set β} : is_closed (h ⁻¹' s) ↔ is_closed s :=\nby simp only [← is_open_compl_iff, ← preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : α ≃ₜ β) {s : set α} : is_closed (h '' s) ↔ is_closed s :=\nby rw [← preimage_symm, is_closed_preimage]\n\nlemma preimage_closure (h : α ≃ₜ β) (s : set β) : h ⁻¹' (closure s) = closure (h ⁻¹' s) :=\nby rw [h.embedding.closure_eq_preimage_closure_image, h.image_preimage]\n\nlemma image_closure (h : α ≃ₜ β) (s : set α) : h '' (closure s) = closure (h '' s) :=\nby rw [← preimage_symm, preimage_closure]\n\nprotected lemma is_open_map (h : α ≃ₜ β) : is_open_map h := λ s, h.is_open_image.2\n\nprotected lemma is_closed_map (h : α ≃ₜ β) : is_closed_map h := λ s, h.is_closed_image.2\n\nprotected lemma closed_embedding (h : α ≃ₜ β) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\n@[simp] lemma map_nhds_eq (h : α ≃ₜ β) (x : α) : map h (𝓝 x) = 𝓝 (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : α ≃ₜ β) (x : α) : map h.symm (𝓝 (h x)) = 𝓝 x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : α ≃ₜ β) (x : α) : 𝓝 x = comap h (𝓝 (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : α ≃ₜ β) (y : β) : comap h (𝓝 y) = 𝓝 (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : α ≃ β` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : α ≃ β) (h₁ : continuous e) (h₂ : is_open_map e) :\n  α ≃ₜ β :=\n{ continuous_to_fun := h₁,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert ← h₂ s hs using 1,\n    apply e.image_eq_preimage\n  end,\n  to_equiv := e }\n\n@[simp] lemma comp_continuous_on_iff (h : α ≃ₜ β) (f : γ → α) (s : set γ) :\n  continuous_on (h ∘ f) s ↔ continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : α ≃ₜ β) {f : γ → α} :\n  continuous (h ∘ f) ↔ continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : α ≃ₜ β) {f : β → γ} :\n  continuous (f ∘ h) ↔ continuous f :=\nh.quotient_map.continuous_iff.symm\n\n/-- If two sets are equal, then they are homeomorphic. -/\ndef set_congr {s t : set α} (h : s = t) : s ≃ₜ t :=\n{ continuous_to_fun := continuous_subtype_mk _ continuous_subtype_val,\n  continuous_inv_fun := continuous_subtype_mk _ continuous_subtype_val,\n  to_equiv := equiv.set_congr h }\n\n/-- Sum of two homeomorphisms. -/\ndef sum_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α ⊕ γ ≃ₜ β ⊕ δ :=\n{ continuous_to_fun  :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h₁.continuous)\n      (continuous_inr.comp h₂.continuous),\n    ext x, cases x; refl,\n  end,\n  continuous_inv_fun :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h₁.symm.continuous)\n      (continuous_inr.comp h₂.symm.continuous),\n    ext x, cases x; refl\n  end,\n  to_equiv := h₁.to_equiv.sum_congr h₂.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) : α × γ ≃ₜ β × δ :=\n{ continuous_to_fun  := (h₁.continuous.comp continuous_fst).prod_mk\n    (h₂.continuous.comp continuous_snd),\n  continuous_inv_fun := (h₁.symm.continuous.comp continuous_fst).prod_mk\n    (h₂.symm.continuous.comp continuous_snd),\n  to_equiv := h₁.to_equiv.prod_congr h₂.to_equiv }\n\n@[simp] lemma prod_congr_symm (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  (h₁.prod_congr h₂).symm = h₁.symm.prod_congr h₂.symm := rfl\n\n@[simp] lemma coe_prod_congr (h₁ : α ≃ₜ β) (h₂ : γ ≃ₜ δ) :\n  ⇑(h₁.prod_congr h₂) = prod.map h₁ h₂ := rfl\n\nsection\nvariables (α β γ)\n\n/-- `α × β` is homeomorphic to `β × α`. -/\ndef prod_comm : α × β ≃ₜ β × α :=\n{ continuous_to_fun  := continuous_snd.prod_mk continuous_fst,\n  continuous_inv_fun := continuous_snd.prod_mk continuous_fst,\n  to_equiv := equiv.prod_comm α β }\n\n@[simp] lemma prod_comm_symm : (prod_comm α β).symm = prod_comm β α := rfl\n@[simp] lemma coe_prod_comm : ⇑(prod_comm α β) = prod.swap := rfl\n\n/-- `(α × β) × γ` is homeomorphic to `α × (β × γ)`. -/\ndef prod_assoc : (α × β) × γ ≃ₜ α × (β × γ) :=\n{ continuous_to_fun  := (continuous_fst.comp continuous_fst).prod_mk\n    ((continuous_snd.comp continuous_fst).prod_mk continuous_snd),\n  continuous_inv_fun := (continuous_fst.prod_mk (continuous_fst.comp continuous_snd)).prod_mk\n    (continuous_snd.comp continuous_snd),\n  to_equiv := equiv.prod_assoc α β γ }\n\n/-- `α × {*}` is homeomorphic to `α`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : α × punit ≃ₜ α :=\n{ to_equiv := equiv.prod_punit α,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} × α` is homeomorphic to `α`. -/\ndef punit_prod : punit × α ≃ₜ α :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : ⇑(punit_prod α) = prod.snd := rfl\n\nend\n\n/-- `ulift α` is homeomorphic to `α`. -/\ndef {u v} ulift {α : Type u} [topological_space α] : ulift.{v u} α ≃ₜ α :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(α ⊕ β) × γ` is homeomorphic to `α × γ ⊕ β × γ`. -/\ndef sum_prod_distrib : (α ⊕ β) × γ ≃ₜ α × γ ⊕ β × γ :=\nbegin\n  refine (homeomorph.homeomorph_of_continuous_open (equiv.sum_prod_distrib α β γ).symm _ _).symm,\n  { convert continuous_sum_rec\n      ((continuous_inl.comp continuous_fst).prod_mk continuous_snd)\n      ((continuous_inr.comp continuous_fst).prod_mk continuous_snd),\n    ext1 x, cases x; refl, },\n  { exact (is_open_map_sum\n    (open_embedding_inl.prod open_embedding_id).is_open_map\n    (open_embedding_inr.prod open_embedding_id).is_open_map) }\nend\n\n/-- `α × (β ⊕ γ)` is homeomorphic to `α × β ⊕ α × γ`. -/\ndef prod_sum_distrib : α × (β ⊕ γ) ≃ₜ α × β ⊕ α × γ :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {ι : Type*} {σ : ι → Type*} [Π i, topological_space (σ i)]\n\n/-- `(Σ i, σ i) × β` is homeomorphic to `Σ i, (σ i × β)`. -/\ndef sigma_prod_distrib : ((Σ i, σ i) × β) ≃ₜ (Σ i, (σ i × β)) :=\nhomeomorph.symm $\nhomeomorph_of_continuous_open (equiv.sigma_prod_distrib σ β).symm\n  (continuous_sigma $ λ i,\n    (continuous_sigma_mk.comp continuous_fst).prod_mk continuous_snd)\n  (is_open_map_sigma $ λ i,\n    (open_embedding_sigma_mk.prod open_embedding_id).is_open_map)\n\nend distrib\n\n/--\nA subset of a topological space is homeomorphic to its image under a homeomorphism.\n-/\ndef image (e : α ≃ₜ β) (s : set α) : s ≃ₜ e '' s :=\n{ continuous_to_fun := by continuity!,\n  continuous_inv_fun := by continuity!,\n  ..e.to_equiv.image s, }\n\nend homeomorph\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/homeomorph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4820499455991613}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang\n\n! This file was ported from Lean 3 source module algebra.category.Module.change_of_rings\n! leanprover-community/mathlib commit 8f66240cab125b938b327d3850169d490cfbcdd8\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Category.Module.Basic\nimport Mathbin.RingTheory.TensorProduct\n\n/-!\n# Change Of Rings\n\n## Main definitions\n\n* `category_theory.Module.restrict_scalars`: given rings `R, S` and a ring homomorphism `R ⟶ S`,\n  then `restrict_scalars : Module S ⥤ Module R` is defined by `M ↦ M` where `M : S-module` is seen\n  as `R-module` by `r • m := f r • m` and `S`-linear map `l : M ⟶ M'` is `R`-linear as well.\n\n* `category_theory.Module.extend_scalars`: given **commutative** rings `R, S` and ring homomorphism\n  `f : R ⟶ S`, then `extend_scalars : Module R ⥤ Module S` is defined by `M ↦ S ⨂ M` where the\n  module structure is defined by `s • (s' ⊗ m) := (s * s') ⊗ m` and `R`-linear map `l : M ⟶ M'`\n  is sent to `S`-linear map `s ⊗ m ↦ s ⊗ l m : S ⨂ M ⟶ S ⨂ M'`.\n\n## List of notations\nLet `R, S` be rings and `f : R →+* S`\n* if `M` is an `R`-module, `s : S` and `m : M`, then `s ⊗ₜ[R, f] m` is the pure tensor\n  `s ⊗ m : S ⊗[R, f] M`.\n-/\n\n\nnamespace CategoryTheory.Module\n\nuniverse v u₁ u₂\n\nnamespace RestrictScalars\n\nvariable {R : Type u₁} {S : Type u₂} [Ring R] [Ring S] (f : R →+* S)\n\nvariable (M : ModuleCat.{v} S)\n\n/-- Any `S`-module M is also an `R`-module via a ring homomorphism `f : R ⟶ S` by defining\n    `r • m := f r • m` (`module.comp_hom`). This is called restriction of scalars. -/\ndef obj' : ModuleCat R where\n  carrier := M\n  isModule := Module.compHom M f\n#align category_theory.Module.restrict_scalars.obj' CategoryTheory.Module.RestrictScalars.obj'\n\n/-- Given an `S`-linear map `g : M → M'` between `S`-modules, `g` is also `R`-linear between `M` and\n`M'` by means of restriction of scalars.\n-/\ndef map' {M M' : ModuleCat.{v} S} (g : M ⟶ M') : obj' f M ⟶ obj' f M' :=\n  { g with map_smul' := fun r => g.map_smul (f r) }\n#align category_theory.Module.restrict_scalars.map' CategoryTheory.Module.RestrictScalars.map'\n\nend RestrictScalars\n\n/-- The restriction of scalars operation is functorial. For any `f : R →+* S` a ring homomorphism,\n* an `S`-module `M` can be considered as `R`-module by `r • m = f r • m`\n* an `S`-linear map is also `R`-linear\n-/\ndef restrictScalars {R : Type u₁} {S : Type u₂} [Ring R] [Ring S] (f : R →+* S) :\n    ModuleCat.{v} S ⥤ ModuleCat.{v} R\n    where\n  obj := RestrictScalars.obj' f\n  map _ _ := RestrictScalars.map' f\n  map_id' _ := LinearMap.ext fun m => rfl\n  map_comp' _ _ _ g h := LinearMap.ext fun m => rfl\n#align category_theory.Module.restrict_scalars CategoryTheory.Module.restrictScalars\n\n@[simp]\ntheorem restrictScalars.map_apply {R : Type u₁} {S : Type u₂} [Ring R] [Ring S] (f : R →+* S)\n    {M M' : ModuleCat.{v} S} (g : M ⟶ M') (x) : (restrictScalars f).map g x = g x :=\n  rfl\n#align category_theory.Module.restrict_scalars.map_apply CategoryTheory.Module.restrictScalars.map_apply\n\n@[simp]\ntheorem restrictScalars.smul_def {R : Type u₁} {S : Type u₂} [Ring R] [Ring S] (f : R →+* S)\n    {M : ModuleCat.{v} S} (r : R) (m : (restrictScalars f).obj M) : r • m = (f r • m : M) :=\n  rfl\n#align category_theory.Module.restrict_scalars.smul_def CategoryTheory.Module.restrictScalars.smul_def\n\ntheorem restrictScalars.smul_def' {R : Type u₁} {S : Type u₂} [Ring R] [Ring S] (f : R →+* S)\n    {M : ModuleCat.{v} S} (r : R) (m : M) : (r • m : (restrictScalars f).obj M) = (f r • m : M) :=\n  rfl\n#align category_theory.Module.restrict_scalars.smul_def' CategoryTheory.Module.restrictScalars.smul_def'\n\ninstance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type u₂} [Ring R] [CommRing S]\n    (f : R →+* S) (M : Type v) [AddCommGroup M] [Module S M] :\n    @SMulCommClass R S M (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul _\n    where smul_comm r s m := (by simp [← mul_smul, mul_comm] : f r • s • m = s • f r • m)\n#align category_theory.Module.smul_comm_class_mk CategoryTheory.Module.sMulCommClass_mk\n\nnamespace ExtendScalars\n\nopen TensorProduct\n\nvariable {R : Type u₁} {S : Type u₂} [CommRing R] [CommRing S] (f : R →+* S)\n\nsection Unbundled\n\nvariable (M : Type v) [AddCommMonoid M] [Module R M]\n\n-- mathport name: «expr ⊗ₜ[ , ] »\n-- This notation is necessary because we need to reason about `s ⊗ₜ m` where `s : S` and `m : M`;\n-- without this notation, one need to work with `s : (restrict_scalars f).obj ⟨S⟩`.\nscoped[ChangeOfRings]\n  notation s \"⊗ₜ[\" R \",\" f \"]\" m => @TensorProduct.tmul R _ _ _ _ _ (Module.compHom _ f) _ s m\n\nend Unbundled\n\nopen ChangeOfRings\n\nvariable (M : ModuleCat.{v} R)\n\n/-- Extension of scalars turn an `R`-module into `S`-module by M ↦ S ⨂ M\n-/\ndef obj' : ModuleCat S :=\n  ⟨TensorProduct R ((restrictScalars f).obj ⟨S⟩) M⟩\n#align category_theory.Module.extend_scalars.obj' CategoryTheory.Module.ExtendScalars.obj'\n\n/-- Extension of scalars is a functor where an `R`-module `M` is sent to `S ⊗ M` and\n`l : M1 ⟶ M2` is sent to `s ⊗ m ↦ s ⊗ l m`\n-/\ndef map' {M1 M2 : ModuleCat.{v} R} (l : M1 ⟶ M2) : obj' f M1 ⟶ obj' f M2 :=\n  by-- The \"by apply\" part makes this require 75% fewer heartbeats to process (#16371).\n  apply @LinearMap.baseChange R S M1 M2 _ _ ((algebraMap S _).comp f).toAlgebra _ _ _ _ l\n#align category_theory.Module.extend_scalars.map' CategoryTheory.Module.ExtendScalars.map'\n\ntheorem map'_id {M : ModuleCat.{v} R} : map' f (𝟙 M) = 𝟙 _ :=\n  LinearMap.ext fun x : obj' f M =>\n    by\n    dsimp only [map', ModuleCat.id_apply]\n    induction' x using TensorProduct.induction_on with _ _ m s ihx ihy\n    · simp only [map_zero]\n    · rw [LinearMap.baseChange_tmul, ModuleCat.id_apply]\n    · rw [map_add, ihx, ihy]\n#align category_theory.Module.extend_scalars.map'_id CategoryTheory.Module.ExtendScalars.map'_id\n\ntheorem map'_comp {M₁ M₂ M₃ : ModuleCat.{v} R} (l₁₂ : M₁ ⟶ M₂) (l₂₃ : M₂ ⟶ M₃) :\n    map' f (l₁₂ ≫ l₂₃) = map' f l₁₂ ≫ map' f l₂₃ :=\n  LinearMap.ext fun x : obj' f M₁ => by\n    dsimp only [map']\n    induction' x using TensorProduct.induction_on with _ _ x y ihx ihy\n    · rfl\n    · rfl\n    · simp only [map_add, ihx, ihy]\n#align category_theory.Module.extend_scalars.map'_comp CategoryTheory.Module.ExtendScalars.map'_comp\n\nend ExtendScalars\n\n/-- Extension of scalars is a functor where an `R`-module `M` is sent to `S ⊗ M` and\n`l : M1 ⟶ M2` is sent to `s ⊗ m ↦ s ⊗ l m`\n-/\ndef extendScalars {R : Type u₁} {S : Type u₂} [CommRing R] [CommRing S] (f : R →+* S) :\n    ModuleCat.{v} R ⥤ ModuleCat.{max v u₂} S\n    where\n  obj M := ExtendScalars.obj' f M\n  map M1 M2 l := ExtendScalars.map' f l\n  map_id' _ := ExtendScalars.map'_id f\n  map_comp' _ _ _ := ExtendScalars.map'_comp f\n#align category_theory.Module.extend_scalars CategoryTheory.Module.extendScalars\n\nnamespace ExtendScalars\n\nopen ChangeOfRings\n\nvariable {R : Type u₁} {S : Type u₂} [CommRing R] [CommRing S] (f : R →+* S)\n\n@[simp]\nprotected theorem smul_tmul {M : ModuleCat.{v} R} (s s' : S) (m : M) :\n    s • (s'⊗ₜ[R,f]m : (extendScalars f).obj M) = (s * s')⊗ₜ[R,f]m :=\n  rfl\n#align category_theory.Module.extend_scalars.smul_tmul CategoryTheory.Module.extendScalars.smul_tmul\n\n@[simp]\ntheorem map_tmul {M M' : ModuleCat.{v} R} (g : M ⟶ M') (s : S) (m : M) :\n    (extendScalars f).map g (s⊗ₜ[R,f]m) = s⊗ₜ[R,f]g m :=\n  rfl\n#align category_theory.Module.extend_scalars.map_tmul CategoryTheory.Module.extendScalars.map_tmul\n\nend ExtendScalars\n\nend CategoryTheory.Module\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Category/Module/ChangeOfRings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334525, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4820499455991612}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.lie.basic\nimport ring_theory.noetherian\n\n/-!\n# Lie subalgebras\n\nThis file defines Lie subalgebras of a Lie algebra and provides basic related definitions and\nresults.\n\n## Main definitions\n\n  * `lie_subalgebra`\n  * `lie_subalgebra.incl`\n  * `lie_subalgebra.map`\n  * `lie_hom.range`\n  * `lie_equiv.of_injective`\n  * `lie_equiv.of_eq`\n  * `lie_equiv.of_subalgebra`\n  * `lie_equiv.of_subalgebras`\n\n## Tags\n\nlie algebra, lie subalgebra\n-/\n\nuniverses u v w w₁ w₂\n\nsection lie_subalgebra\n\nvariables (R : Type u) (L : Type v) [comm_ring R] [lie_ring L] [lie_algebra R L]\n\n/-- A Lie subalgebra of a Lie algebra is submodule that is closed under the Lie bracket.\nThis is a sufficient condition for the subset itself to form a Lie algebra. -/\nstructure lie_subalgebra extends submodule R L :=\n(lie_mem' : ∀ {x y}, x ∈ carrier → y ∈ carrier → ⁅x, y⁆ ∈ carrier)\n\nattribute [nolint doc_blame] lie_subalgebra.to_submodule\n\n/-- The zero algebra is a subalgebra of any Lie algebra. -/\ninstance : has_zero (lie_subalgebra R L) :=\n⟨{ lie_mem' := λ x y hx hy, by { rw [((submodule.mem_bot R).1 hx), zero_lie],\n                                exact submodule.zero_mem (0 : submodule R L), },\n   ..(0 : submodule R L) }⟩\n\ninstance : inhabited (lie_subalgebra R L) := ⟨0⟩\ninstance : has_coe (lie_subalgebra R L) (submodule R L) := ⟨lie_subalgebra.to_submodule⟩\ninstance : has_mem L (lie_subalgebra R L) := ⟨λ x L', x ∈ (L' : set L)⟩\n\nnamespace lie_subalgebra\n\n/-- A Lie subalgebra forms a new Lie ring. -/\ninstance (L' : lie_subalgebra R L) : lie_ring L' :=\n{ bracket      := λ x y, ⟨⁅x.val, y.val⁆, L'.lie_mem' x.property y.property⟩,\n  lie_add      := by { intros, apply set_coe.ext, apply lie_add, },\n  add_lie      := by { intros, apply set_coe.ext, apply add_lie, },\n  lie_self     := by { intros, apply set_coe.ext, apply lie_self, },\n  leibniz_lie  := by { intros, apply set_coe.ext, apply leibniz_lie, } }\n\nsection\n\nvariables {R₁ : Type*} [semiring R₁]\n\n/-- A Lie subalgebra inherits module structures from `L`. -/\ninstance [has_scalar R₁ R] [module R₁ L] [is_scalar_tower R₁ R L]\n  (L' : lie_subalgebra R L) : module R₁ L' :=\nL'.to_submodule.module'\n\ninstance [has_scalar R₁ R] [has_scalar R₁ᵐᵒᵖ R] [module R₁ L] [module R₁ᵐᵒᵖ L]\n  [is_scalar_tower R₁ R L] [is_scalar_tower R₁ᵐᵒᵖ R L] [is_central_scalar R₁ L]\n  (L' : lie_subalgebra R L) : is_central_scalar R₁ L' :=\nL'.to_submodule.is_central_scalar\n\ninstance [has_scalar R₁ R] [module R₁ L] [is_scalar_tower R₁ R L]\n  (L' : lie_subalgebra R L) : is_scalar_tower R₁ R L' :=\nL'.to_submodule.is_scalar_tower\n\nend\n\n/-- A Lie subalgebra forms a new Lie algebra. -/\ninstance (L' : lie_subalgebra R L) : lie_algebra R L' :=\n{ lie_smul := by { intros, apply set_coe.ext, apply lie_smul } }\n\nvariables {R L} (L' : lie_subalgebra R L)\n\n@[simp] lemma zero_mem : (0 : L) ∈ L' := (L' : submodule R L).zero_mem\n\nlemma smul_mem (t : R) {x : L} (h : x ∈ L') : t • x ∈ L' := (L' : submodule R L).smul_mem t h\n\nlemma add_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (x + y : L) ∈ L' :=\n(L' : submodule R L).add_mem hx hy\n\nlemma sub_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (x - y : L) ∈ L' :=\n(L' : submodule R L).sub_mem hx hy\n\n@[simp] lemma neg_mem_iff {x : L} : -x ∈ L' ↔ x ∈ L' := L'.to_submodule.neg_mem_iff\n\nlemma lie_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (⁅x, y⁆ : L) ∈ L' := L'.lie_mem' hx hy\n\n@[simp] lemma mem_carrier {x : L} : x ∈ L'.carrier ↔ x ∈ (L' : set L) := iff.rfl\n\n@[simp] lemma mem_mk_iff (S : set L) (h₁ h₂ h₃ h₄) {x : L} :\n  x ∈ (⟨⟨S, h₁, h₂, h₃⟩, h₄⟩ : lie_subalgebra R L) ↔ x ∈ S :=\niff.rfl\n\n@[simp] lemma mem_coe_submodule {x : L} : x ∈ (L' : submodule R L) ↔ x ∈ L' := iff.rfl\n\nlemma mem_coe {x : L} : x ∈ (L' : set L) ↔ x ∈ L' := iff.rfl\n\n@[simp, norm_cast] lemma coe_bracket (x y : L') : (↑⁅x, y⁆ : L) = ⁅(↑x : L), ↑y⁆ := rfl\n\nlemma ext_iff (x y : L') : x = y ↔ (x : L) = y := subtype.ext_iff\n\nlemma coe_zero_iff_zero (x : L') : (x : L) = 0 ↔ x = 0 := (ext_iff L' x 0).symm\n\n@[ext] lemma ext (L₁' L₂' : lie_subalgebra R L) (h : ∀ x, x ∈ L₁' ↔ x ∈ L₂') :\n  L₁' = L₂' :=\nby { cases L₁', cases L₂', simp only [], ext x, exact h x, }\n\nlemma ext_iff' (L₁' L₂' : lie_subalgebra R L) : L₁' = L₂' ↔ ∀ x, x ∈ L₁' ↔ x ∈ L₂' :=\n⟨λ h x, by rw h, ext L₁' L₂'⟩\n\n@[simp] lemma mk_coe (S : set L) (h₁ h₂ h₃ h₄) :\n  ((⟨⟨S, h₁, h₂, h₃⟩, h₄⟩ : lie_subalgebra R L) : set L) = S := rfl\n\n@[simp] lemma coe_to_submodule_mk (p : submodule R L) (h) :\n  (({lie_mem' := h, ..p} : lie_subalgebra R L) : submodule R L) = p :=\nby { cases p, refl, }\n\nlemma coe_injective : function.injective (coe : lie_subalgebra R L → set L) :=\nby { rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩ h, congr' }\n\ninstance : set_like (lie_subalgebra R L) L := ⟨coe, coe_injective⟩\n\n@[norm_cast] theorem coe_set_eq (L₁' L₂' : lie_subalgebra R L) :\n  (L₁' : set L) = L₂' ↔ L₁' = L₂' := coe_injective.eq_iff\n\nlemma to_submodule_injective :\n  function.injective (coe : lie_subalgebra R L → submodule R L) :=\nλ L₁' L₂' h, by { rw set_like.ext'_iff at h, rw ← coe_set_eq, exact h, }\n\n@[simp] lemma coe_to_submodule_eq_iff (L₁' L₂' : lie_subalgebra R L) :\n  (L₁' : submodule R L) = (L₂' : submodule R L) ↔ L₁' = L₂' :=\nto_submodule_injective.eq_iff\n\n@[norm_cast]\nlemma coe_to_submodule : ((L' : submodule R L) : set L) = L' := rfl\n\nsection lie_module\n\nvariables {M : Type w} [add_comm_group M] [lie_ring_module L M]\nvariables {N : Type w₁} [add_comm_group N] [lie_ring_module L N] [module R N] [lie_module R L N]\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie ring module\n`M` of `L`, we may regard `M` as a Lie ring module of `L'` by restriction. -/\ninstance : lie_ring_module L' M :=\n{ bracket     := λ x m, ⁅(x : L), m⁆,\n  add_lie     := λ x y m, add_lie x y m,\n  lie_add     := λ x y m, lie_add x y m,\n  leibniz_lie := λ x y m, leibniz_lie x y m, }\n\n@[simp] lemma coe_bracket_of_module (x : L') (m : M) : ⁅x, m⁆ = ⁅(x : L), m⁆ := rfl\n\nvariables [module R M] [lie_module R L M]\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie module `M` of\n`L`, we may regard `M` as a Lie module of `L'` by restriction. -/\ninstance : lie_module R L' M :=\n{ smul_lie := λ t x m, by simp only [coe_bracket_of_module, smul_lie, submodule.coe_smul_of_tower],\n  lie_smul := λ t x m, by simp only [coe_bracket_of_module, lie_smul], }\n\n/-- An `L`-equivariant map of Lie modules `M → N` is `L'`-equivariant for any Lie subalgebra\n`L' ⊆ L`. -/\ndef _root_.lie_module_hom.restrict_lie (f : M →ₗ⁅R,L⁆ N) (L' : lie_subalgebra R L) : M →ₗ⁅R,L'⁆ N :=\n{ map_lie' := λ x m, f.map_lie ↑x m,\n  .. (f : M →ₗ[R] N)}\n\n@[simp] lemma _root_.lie_module_hom.coe_restrict_lie (f : M →ₗ⁅R,L⁆ N) :\n  ⇑(f.restrict_lie L') = f :=\nrfl\n\nend lie_module\n\n/-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie algebras. -/\ndef incl : L' →ₗ⁅R⁆ L :=\n{ map_lie' := λ x y, by { simp only [linear_map.to_fun_eq_coe, submodule.subtype_apply], refl, },\n  .. (L' : submodule R L).subtype, }\n\n@[simp] lemma coe_incl : ⇑L'.incl = coe := rfl\n\n/-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie modules. -/\ndef incl' : L' →ₗ⁅R,L'⁆ L :=\n{ map_lie' := λ x y, by simp only [coe_bracket_of_module, linear_map.to_fun_eq_coe,\n    submodule.subtype_apply, coe_bracket],\n  .. (L' : submodule R L).subtype, }\n\n@[simp] lemma coe_incl' : ⇑L'.incl' = coe := rfl\n\nend lie_subalgebra\n\nvariables {R L} {L₂ : Type w} [lie_ring L₂] [lie_algebra R L₂]\nvariables (f : L →ₗ⁅R⁆ L₂)\n\nnamespace lie_hom\n\n/-- The range of a morphism of Lie algebras is a Lie subalgebra. -/\ndef range : lie_subalgebra R L₂ :=\n{ lie_mem' := λ x y,\n    show x ∈ f.to_linear_map.range → y ∈ f.to_linear_map.range → ⁅x, y⁆ ∈ f.to_linear_map.range,\n    by { repeat { rw linear_map.mem_range }, rintros ⟨x', hx⟩ ⟨y', hy⟩, refine ⟨⁅x', y'⁆, _⟩,\n         rw [←hx, ←hy], change f ⁅x', y'⁆ = ⁅f x', f y'⁆, rw map_lie, },\n  ..(f : L →ₗ[R] L₂).range }\n\n@[simp] lemma range_coe : (f.range : set L₂) = set.range f :=\nlinear_map.range_coe ↑f\n\n@[simp] lemma mem_range (x : L₂) : x ∈ f.range ↔ ∃ (y : L), f y = x := linear_map.mem_range\n\nlemma mem_range_self (x : L) : f x ∈ f.range := linear_map.mem_range_self f x\n\n/-- We can restrict a morphism to a (surjective) map to its range. -/\ndef range_restrict : L →ₗ⁅R⁆ f.range :=\n{ map_lie' := λ x y, by { apply subtype.ext, exact f.map_lie x y, },\n  ..(f : L →ₗ[R] L₂).range_restrict, }\n\n@[simp] lemma range_restrict_apply (x : L) : f.range_restrict x = ⟨f x, f.mem_range_self x⟩ := rfl\n\nlemma surjective_range_restrict : function.surjective (f.range_restrict) :=\nbegin\n  rintros ⟨y, hy⟩,\n  erw mem_range at hy, obtain ⟨x, rfl⟩ := hy,\n  use x,\n  simp only [subtype.mk_eq_mk, range_restrict_apply],\nend\n\n/-- A Lie algebra is equivalent to its range under an injective Lie algebra morphism. -/\nnoncomputable def equiv_range_of_injective (h : function.injective f) : L ≃ₗ⁅R⁆ f.range :=\nlie_equiv.of_bijective f.range_restrict (λ x y hxy,\nbegin\n  simp only [subtype.mk_eq_mk, range_restrict_apply] at hxy,\n  exact h hxy,\nend) f.surjective_range_restrict\n\n@[simp] lemma equiv_range_of_injective_apply (h : function.injective f) (x : L) :\n  f.equiv_range_of_injective h x = ⟨f x, mem_range_self f x⟩ :=\nrfl\n\nend lie_hom\n\nlemma submodule.exists_lie_subalgebra_coe_eq_iff (p : submodule R L) :\n  (∃ (K : lie_subalgebra R L), ↑K = p) ↔ ∀ (x y : L), x ∈ p → y ∈ p → ⁅x, y⁆ ∈ p :=\nbegin\n  split,\n  { rintros ⟨K, rfl⟩, exact K.lie_mem', },\n  { intros h, use { lie_mem' := h, ..p }, exact lie_subalgebra.coe_to_submodule_mk p _, },\nend\n\nnamespace lie_subalgebra\n\nvariables (K K' : lie_subalgebra R L) (K₂ : lie_subalgebra R L₂)\n\n@[simp] lemma incl_range : K.incl.range = K :=\nby { rw ← coe_to_submodule_eq_iff, exact (K : submodule R L).range_subtype, }\n\n/-- The image of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the\ncodomain. -/\ndef map : lie_subalgebra R L₂ :=\n{ lie_mem' := λ x y hx hy, by\n  { erw submodule.mem_map at hx, rcases hx with ⟨x', hx', hx⟩, rw ←hx,\n    erw submodule.mem_map at hy, rcases hy with ⟨y', hy', hy⟩, rw ←hy,\n    erw submodule.mem_map,\n    exact ⟨⁅x', y'⁆, K.lie_mem hx' hy', f.map_lie x' y'⟩, },\n..((K : submodule R L).map (f : L →ₗ[R] L₂)) }\n\n@[simp] lemma mem_map (x : L₂) : x ∈ K.map f ↔ ∃ (y : L), y ∈ K ∧ f y = x := submodule.mem_map\n\n-- TODO Rename and state for homs instead of equivs.\n@[simp] lemma mem_map_submodule (e : L ≃ₗ⁅R⁆ L₂) (x : L₂) :\n  x ∈ K.map (e : L →ₗ⁅R⁆ L₂) ↔ x ∈ (K : submodule R L).map (e : L →ₗ[R] L₂) :=\niff.rfl\n\n/-- The preimage of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the\ndomain. -/\ndef comap : lie_subalgebra R L :=\n{ lie_mem' := λ x y hx hy, by\n    { suffices : ⁅f x, f y⁆ ∈ K₂, by { simp [this], }, exact K₂.lie_mem hx hy, },\n  ..((K₂ : submodule R L₂).comap (f : L →ₗ[R] L₂)), }\n\nsection lattice_structure\n\nopen set\n\ninstance : partial_order (lie_subalgebra R L) :=\n{ le := λ N N', ∀ ⦃x⦄, x ∈ N → x ∈ N', -- Overriding `le` like this gives a better defeq.\n  ..partial_order.lift (coe : lie_subalgebra R L → set L) coe_injective }\n\nlemma le_def : K ≤ K' ↔ (K : set L) ⊆ K' := iff.rfl\n\n@[simp, norm_cast] lemma coe_submodule_le_coe_submodule : (K : submodule R L) ≤ K' ↔ K ≤ K' :=\niff.rfl\n\ninstance : has_bot (lie_subalgebra R L) := ⟨0⟩\n\n@[simp] lemma bot_coe : ((⊥ : lie_subalgebra R L) : set L) = {0} := rfl\n\n@[simp] lemma bot_coe_submodule : ((⊥ : lie_subalgebra R L) : submodule R L) = ⊥ := rfl\n\n@[simp] lemma mem_bot (x : L) : x ∈ (⊥ : lie_subalgebra R L) ↔ x = 0 := mem_singleton_iff\n\ninstance : has_top (lie_subalgebra R L) :=\n⟨{ lie_mem' := λ x y hx hy, mem_univ ⁅x, y⁆,\n   ..(⊤ : submodule R L) }⟩\n\n@[simp] lemma top_coe : ((⊤ : lie_subalgebra R L) : set L) = univ := rfl\n\n@[simp] lemma top_coe_submodule : ((⊤ : lie_subalgebra R L) : submodule R L) = ⊤ := rfl\n\n@[simp] lemma mem_top (x : L) : x ∈ (⊤ : lie_subalgebra R L) := mem_univ x\n\nlemma _root_.lie_hom.range_eq_map : f.range = map f ⊤ :=\nby { ext, simp }\n\ninstance : has_inf (lie_subalgebra R L) :=\n⟨λ K K', { lie_mem' := λ x y hx hy, mem_inter (K.lie_mem hx.1 hy.1) (K'.lie_mem hx.2 hy.2),\n            ..(K ⊓ K' : submodule R L) }⟩\n\ninstance : has_Inf (lie_subalgebra R L) :=\n⟨λ S, { lie_mem' := λ x y hx hy, by\n        { simp only [submodule.mem_carrier, mem_Inter, submodule.Inf_coe, mem_set_of_eq,\n            forall_apply_eq_imp_iff₂, exists_imp_distrib] at *,\n          intros K hK, exact K.lie_mem (hx K hK) (hy K hK), },\n        ..Inf {(s : submodule R L) | s ∈ S} }⟩\n\n@[simp] theorem inf_coe : (↑(K ⊓ K') : set L) = K ∩ K' := rfl\n\n@[simp] lemma Inf_coe_to_submodule (S : set (lie_subalgebra R L)) :\n  (↑(Inf S) : submodule R L) = Inf {(s : submodule R L) | s ∈ S} := rfl\n\n@[simp] lemma Inf_coe (S : set (lie_subalgebra R L)) : (↑(Inf S) : set L) = ⋂ s ∈ S, (s : set L) :=\nbegin\n  rw [← coe_to_submodule, Inf_coe_to_submodule, submodule.Inf_coe],\n  ext x,\n  simpa only [mem_Inter, mem_set_of_eq, forall_apply_eq_imp_iff₂, exists_imp_distrib],\nend\n\nlemma Inf_glb (S : set (lie_subalgebra R L)) : is_glb S (Inf S) :=\nbegin\n  have h : ∀ (K K' : lie_subalgebra R L), (K : set L) ≤ K' ↔ K ≤ K', { intros, exact iff.rfl, },\n  apply is_glb.of_image h,\n  simp only [Inf_coe],\n  exact is_glb_binfi\nend\n\n/-- The set of Lie subalgebras of a Lie algebra form a complete lattice.\n\nWe provide explicit values for the fields `bot`, `top`, `inf` to get more convenient definitions\nthan we would otherwise obtain from `complete_lattice_of_Inf`. -/\ninstance : complete_lattice (lie_subalgebra R L) :=\n{ bot          := ⊥,\n  bot_le       := λ N _ h, by { rw mem_bot at h, rw h, exact N.zero_mem', },\n  top          := ⊤,\n  le_top       := λ _ _ _, trivial,\n  inf          := (⊓),\n  le_inf       := λ N₁ N₂ N₃ h₁₂ h₁₃ m hm, ⟨h₁₂ hm, h₁₃ hm⟩,\n  inf_le_left  := λ _ _ _, and.left,\n  inf_le_right := λ _ _ _, and.right,\n  ..complete_lattice_of_Inf _ Inf_glb }\n\ninstance : add_comm_monoid (lie_subalgebra R L) :=\n{ add       := (⊔),\n  add_assoc := λ _ _ _, sup_assoc,\n  zero      := ⊥,\n  zero_add  := λ _, bot_sup_eq,\n  add_zero  := λ _, sup_bot_eq,\n  add_comm  := λ _ _, sup_comm, }\n\n@[simp] lemma add_eq_sup : K + K' = K ⊔ K' := rfl\n\n@[norm_cast, simp] lemma inf_coe_to_submodule :\n  (↑(K ⊓ K') : submodule R L) = (K : submodule R L) ⊓ (K' : submodule R L) := rfl\n\n@[simp] lemma mem_inf (x : L) : x ∈ K ⊓ K' ↔ x ∈ K ∧ x ∈ K' :=\nby rw [← mem_coe_submodule, ← mem_coe_submodule, ← mem_coe_submodule, inf_coe_to_submodule,\n  submodule.mem_inf]\n\nlemma eq_bot_iff : K = ⊥ ↔ ∀ (x : L), x ∈ K → x = 0 :=\nby { rw eq_bot_iff, exact iff.rfl, }\n\n-- TODO[gh-6025]: make this an instance once safe to do so\nlemma subsingleton_of_bot : subsingleton (lie_subalgebra R ↥(⊥ : lie_subalgebra R L)) :=\nbegin\n  apply subsingleton_of_bot_eq_top,\n  ext ⟨x, hx⟩, change x ∈ ⊥ at hx, rw submodule.mem_bot at hx, subst hx,\n  simp only [true_iff, eq_self_iff_true, submodule.mk_eq_zero, mem_bot],\nend\n\nvariables (R L)\n\nlemma well_founded_of_noetherian [is_noetherian R L] :\n  well_founded ((>) : lie_subalgebra R L → lie_subalgebra R L → Prop) :=\n  let f : ((>) : lie_subalgebra R L → lie_subalgebra R L → Prop) →r\n          ((>) : submodule R L → submodule R L → Prop) :=\n  { to_fun       := coe,\n    map_rel' := λ N N' h, h, }\nin rel_hom_class.well_founded f (is_noetherian_iff_well_founded.mp infer_instance)\n\nvariables {R L K K' f}\n\nsection nested_subalgebras\n\nvariables (h : K ≤ K')\n\n/-- Given two nested Lie subalgebras `K ⊆ K'`, the inclusion `K ↪ K'` is a morphism of Lie\nalgebras. -/\ndef hom_of_le : K →ₗ⁅R⁆ K' :=\n{ map_lie' := λ x y, rfl,\n  ..submodule.of_le h }\n\n@[simp] lemma coe_hom_of_le (x : K) : (hom_of_le h x : L) = x := rfl\n\nlemma hom_of_le_apply (x : K) : hom_of_le h x = ⟨x.1, h x.2⟩ := rfl\n\nlemma hom_of_le_injective : function.injective (hom_of_le h) :=\nλ x y, by simp only [hom_of_le_apply, imp_self, subtype.mk_eq_mk, set_like.coe_eq_coe,\n  subtype.val_eq_coe]\n\n/-- Given two nested Lie subalgebras `K ⊆ K'`, we can view `K` as a Lie subalgebra of `K'`,\nregarded as Lie algebra in its own right. -/\ndef of_le : lie_subalgebra R K' := (hom_of_le h).range\n\n@[simp] lemma mem_of_le (x : K') : x ∈ of_le h ↔ (x : L) ∈ K :=\nbegin\n  simp only [of_le, hom_of_le_apply, lie_hom.mem_range],\n  split,\n  { rintros ⟨y, rfl⟩, exact y.property, },\n  { intros h, use ⟨(x : L), h⟩, simp, },\nend\n\nlemma of_le_eq_comap_incl : of_le h = K.comap K'.incl :=\nby { ext, rw mem_of_le, refl, }\n\n@[simp] lemma coe_of_le : (of_le h : submodule R K') = (submodule.of_le h).range := rfl\n\n/-- Given nested Lie subalgebras `K ⊆ K'`, there is a natural equivalence from `K` to its image in\n`K'`.  -/\nnoncomputable def equiv_of_le : K ≃ₗ⁅R⁆ of_le h :=\n(hom_of_le h).equiv_range_of_injective (hom_of_le_injective h)\n\n@[simp] \n\nend nested_subalgebras\n\nlemma map_le_iff_le_comap {K : lie_subalgebra R L} {K' : lie_subalgebra R L₂} :\n  map f K ≤ K' ↔ K ≤ comap f K' := set.image_subset_iff\n\nlemma gc_map_comap : galois_connection (map f) (comap f) := λ K K', map_le_iff_le_comap\n\nend lattice_structure\n\nsection lie_span\n\nvariables (R L) (s : set L)\n\n/-- The Lie subalgebra of a Lie algebra `L` generated by a subset `s ⊆ L`. -/\ndef lie_span : lie_subalgebra R L := Inf {N | s ⊆ N}\n\nvariables {R L s}\n\nlemma mem_lie_span {x : L} : x ∈ lie_span R L s ↔ ∀ K : lie_subalgebra R L, s ⊆ K → x ∈ K :=\nby { change x ∈ (lie_span R L s : set L) ↔ _, erw Inf_coe, exact set.mem_Inter₂, }\n\nlemma subset_lie_span : s ⊆ lie_span R L s :=\nby { intros m hm, erw mem_lie_span, intros K hK, exact hK hm, }\n\nlemma submodule_span_le_lie_span : submodule.span R s ≤ lie_span R L s :=\nby { rw submodule.span_le, apply subset_lie_span, }\n\nlemma lie_span_le {K} : lie_span R L s ≤ K ↔ s ⊆ K :=\nbegin\n  split,\n  { exact set.subset.trans subset_lie_span, },\n  { intros hs m hm, rw mem_lie_span at hm, exact hm _ hs, },\nend\n\nlemma lie_span_mono {t : set L} (h : s ⊆ t) : lie_span R L s ≤ lie_span R L t :=\nby { rw lie_span_le, exact set.subset.trans h subset_lie_span, }\n\nlemma lie_span_eq : lie_span R L (K : set L) = K :=\nle_antisymm (lie_span_le.mpr rfl.subset) subset_lie_span\n\nlemma coe_lie_span_submodule_eq_iff {p : submodule R L} :\n  (lie_span R L (p : set L) : submodule R L) = p ↔ ∃ (K : lie_subalgebra R L), ↑K = p :=\nbegin\n  rw p.exists_lie_subalgebra_coe_eq_iff, split; intros h,\n  { intros x m hm, rw [← h, mem_coe_submodule], exact lie_mem _ (subset_lie_span hm), },\n  { rw [← coe_to_submodule_mk p h, coe_to_submodule, coe_to_submodule_eq_iff, lie_span_eq], },\nend\n\nvariables (R L)\n\n/-- `lie_span` forms a Galois insertion with the coercion from `lie_subalgebra` to `set`. -/\nprotected def gi : galois_insertion (lie_span R L : set L → lie_subalgebra R L) coe :=\n{ choice    := λ s _, lie_span R L s,\n  gc        := λ s t, lie_span_le,\n  le_l_u    := λ s, subset_lie_span,\n  choice_eq := λ s h, rfl }\n\n@[simp] lemma span_empty : lie_span R L (∅ : set L) = ⊥ :=\n(lie_subalgebra.gi R L).gc.l_bot\n\n@[simp] lemma span_univ : lie_span R L (set.univ : set L) = ⊤ :=\neq_top_iff.2 $ set_like.le_def.2 $ subset_lie_span\n\nvariables {L}\n\nlemma span_union (s t : set L) : lie_span R L (s ∪ t) = lie_span R L s ⊔ lie_span R L t :=\n(lie_subalgebra.gi R L).gc.l_sup\n\nlemma span_Union {ι} (s : ι → set L) : lie_span R L (⋃ i, s i) = ⨆ i, lie_span R L (s i) :=\n(lie_subalgebra.gi R L).gc.l_supr\n\nend lie_span\n\nend lie_subalgebra\n\nend lie_subalgebra\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w}\nvariables [comm_ring R] [lie_ring L₁] [lie_ring L₂] [lie_algebra R L₁] [lie_algebra R L₂]\n\n/-- An injective Lie algebra morphism is an equivalence onto its range. -/\nnoncomputable def of_injective (f : L₁ →ₗ⁅R⁆ L₂) (h : function.injective f) :\n  L₁ ≃ₗ⁅R⁆ f.range :=\n{ map_lie' := λ x y, by { apply set_coe.ext, simpa, },\n..(linear_equiv.of_injective ↑f $ by rwa [lie_hom.coe_to_linear_map])}\n\n@[simp] lemma of_injective_apply (f : L₁ →ₗ⁅R⁆ L₂) (h : function.injective f) (x : L₁) :\n  ↑(of_injective f h x) = f x := rfl\n\nvariables (L₁' L₁'' : lie_subalgebra R L₁) (L₂' : lie_subalgebra R L₂)\n\n/-- Lie subalgebras that are equal as sets are equivalent as Lie algebras. -/\ndef of_eq (h : (L₁' : set L₁) = L₁'') : L₁' ≃ₗ⁅R⁆ L₁'' :=\n{ map_lie' := λ x y, by { apply set_coe.ext, simp, },\n  ..(linear_equiv.of_eq ↑L₁' ↑L₁''\n      (by {ext x, change x ∈ (L₁' : set L₁) ↔ x ∈ (L₁'' : set L₁), rw h, } )) }\n\n@[simp] lemma of_eq_apply (L L' : lie_subalgebra R L₁) (h : (L : set L₁) = L') (x : L) :\n  (↑(of_eq L L' h x) : L₁) = x := rfl\n\nvariables (e : L₁ ≃ₗ⁅R⁆ L₂)\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef lie_subalgebra_map : L₁'' ≃ₗ⁅R⁆ (L₁''.map e : lie_subalgebra R L₂) :=\n{ map_lie' := λ x y, by { apply set_coe.ext, exact lie_hom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y, }\n  ..(linear_equiv.submodule_map (e : L₁ ≃ₗ[R] L₂) ↑L₁'') }\n\n@[simp] lemma lie_subalgebra_map_apply (x : L₁'') : ↑(e.lie_subalgebra_map _  x) = e x := rfl\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef of_subalgebras (h : L₁'.map ↑e = L₂') : L₁' ≃ₗ⁅R⁆ L₂' :=\n{ map_lie' := λ x y, by { apply set_coe.ext, exact lie_hom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y, },\n  ..(linear_equiv.of_submodules (e : L₁ ≃ₗ[R] L₂) ↑L₁' ↑L₂' (by { rw ←h, refl, })) }\n\n@[simp] lemma of_subalgebras_apply (h : L₁'.map ↑e = L₂') (x : L₁') :\n  ↑(e.of_subalgebras _ _ h x) = e x := rfl\n\n@[simp] lemma of_subalgebras_symm_apply (h : L₁'.map ↑e = L₂') (x : L₂') :\n  ↑((e.of_subalgebras _ _ h).symm x) = e.symm x := rfl\n\nend lie_equiv\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebra/lie/subalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.48204994127887857}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module category_theory.sites.surjective\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Sites.Subsheaf\nimport Mathbin.CategoryTheory.Sites.CompatibleSheafification\n\n/-!\n\n# Locally surjective morphisms\n\n## Main definitions\n\n- `is_locally_surjective` : A morphism of presheaves valued in a concrete category is locally\n  surjective with respect to a grothendieck topology if every section in the target is locally\n  in the set-theoretic image, i.e. the image sheaf coincides with the target.\n\n## Main results\n\n- `to_sheafify_is_locally_surjective` : `to_sheafify` is locally surjective.\n\n-/\n\n\nuniverse v u w v' u' w'\n\nopen Opposite CategoryTheory CategoryTheory.GrothendieckTopology\n\nnamespace CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C)\n\nattribute [local instance] concrete_category.has_coe_to_sort concrete_category.has_coe_to_fun\n\nvariable {A : Type u'} [Category.{v'} A] [ConcreteCategory.{w'} A]\n\n/-- Given `f : F ⟶ G`, a morphism between presieves, and `s : G.obj (op U)`, this is the sieve\nof `U` consisting of the `i : V ⟶ U` such that `s` restricted along `i` is in the image of `f`. -/\n@[simps (config := lemmasOnly)]\ndef imageSieve {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) : Sieve U\n    where\n  arrows V i := ∃ t : F.obj (op V), f.app _ t = G.map i.op s\n  downward_closed' := by\n    rintro V W i ⟨t, ht⟩ j\n    refine' ⟨F.map j.op t, _⟩\n    rw [op_comp, G.map_comp, comp_apply, ← ht, elementwise_of f.naturality]\n#align category_theory.image_sieve CategoryTheory.imageSieve\n\ntheorem imageSieve_eq_sieveOfSection {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) :\n    imageSieve f s = (imagePresheaf (whiskerRight f (forget A))).sieveOfSection s :=\n  rfl\n#align category_theory.image_sieve_eq_sieve_of_section CategoryTheory.imageSieve_eq_sieveOfSection\n\ntheorem imageSieve_whisker_forget {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : G.obj (op U)) :\n    imageSieve (whiskerRight f (forget A)) s = imageSieve f s :=\n  rfl\n#align category_theory.image_sieve_whisker_forget CategoryTheory.imageSieve_whisker_forget\n\ntheorem imageSieve_app {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) {U : C} (s : F.obj (op U)) :\n    imageSieve f (f.app _ s) = ⊤ := by\n  ext (V i)\n  simp only [sieve.top_apply, iff_true_iff, image_sieve_apply]\n  have := elementwise_of (f.naturality i.op)\n  exact ⟨F.map i.op s, this s⟩\n#align category_theory.image_sieve_app CategoryTheory.imageSieve_app\n\n/-- A morphism of presheaves `f : F ⟶ G` is locally surjective with respect to a grothendieck\ntopology if every section of `G` is locally in the image of `f`. -/\ndef IsLocallySurjective {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) : Prop :=\n  ∀ (U : C) (s : G.obj (op U)), imageSieve f s ∈ J U\n#align category_theory.is_locally_surjective CategoryTheory.IsLocallySurjective\n\ntheorem isLocallySurjective_iff_imagePresheaf_sheafify_eq_top {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) :\n    IsLocallySurjective J f ↔ (imagePresheaf (whiskerRight f (forget A))).sheafify J = ⊤ :=\n  by\n  simp only [subpresheaf.ext_iff, Function.funext_iff, Set.ext_iff, top_subpresheaf_obj,\n    Set.top_eq_univ, Set.mem_univ, iff_true_iff]\n  exact ⟨fun H U => H (unop U), fun H U => H (op U)⟩\n#align category_theory.is_locally_surjective_iff_image_presheaf_sheafify_eq_top CategoryTheory.isLocallySurjective_iff_imagePresheaf_sheafify_eq_top\n\ntheorem isLocallySurjective_iff_imagePresheaf_sheafify_eq_top' {F G : Cᵒᵖ ⥤ Type w} (f : F ⟶ G) :\n    IsLocallySurjective J f ↔ (imagePresheaf f).sheafify J = ⊤ :=\n  by\n  simp only [subpresheaf.ext_iff, Function.funext_iff, Set.ext_iff, top_subpresheaf_obj,\n    Set.top_eq_univ, Set.mem_univ, iff_true_iff]\n  exact ⟨fun H U => H (unop U), fun H U => H (op U)⟩\n#align category_theory.is_locally_surjective_iff_image_presheaf_sheafify_eq_top' CategoryTheory.isLocallySurjective_iff_imagePresheaf_sheafify_eq_top'\n\ntheorem isLocallySurjective_iff_isIso {F G : Sheaf J (Type w)} (f : F ⟶ G) :\n    IsLocallySurjective J f.1 ↔ IsIso (imageSheafι f) :=\n  by\n  rw [image_sheaf_ι, is_locally_surjective_iff_image_presheaf_sheafify_eq_top',\n    subpresheaf.eq_top_iff_is_iso]\n  exact\n    ⟨fun h => @is_iso_of_reflects_iso _ _ (image_sheaf_ι f) (Sheaf_to_presheaf J _) h _, fun h =>\n      @functor.map_is_iso _ _ (Sheaf_to_presheaf J _) _ h⟩\n#align category_theory.is_locally_surjective_iff_is_iso CategoryTheory.isLocallySurjective_iff_isIso\n\ntheorem isLocallySurjective_iff_whisker_forget {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) :\n    IsLocallySurjective J f ↔ IsLocallySurjective J (whiskerRight f (forget A)) := by\n  simpa only [is_locally_surjective_iff_image_presheaf_sheafify_eq_top]\n#align category_theory.is_locally_surjective_iff_whisker_forget CategoryTheory.isLocallySurjective_iff_whisker_forget\n\ntheorem isLocallySurjective_of_surjective {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G)\n    (H : ∀ U, Function.Surjective (f.app U)) : IsLocallySurjective J f :=\n  by\n  intro U s\n  obtain ⟨t, rfl⟩ := H _ s\n  rw [image_sieve_app]\n  exact J.top_mem _\n#align category_theory.is_locally_surjective_of_surjective CategoryTheory.isLocallySurjective_of_surjective\n\ntheorem isLocallySurjective_of_iso {F G : Cᵒᵖ ⥤ A} (f : F ⟶ G) [IsIso f] :\n    IsLocallySurjective J f :=\n  by\n  apply is_locally_surjective_of_surjective\n  intro U\n  apply Function.Bijective.surjective\n  rw [← is_iso_iff_bijective]\n  infer_instance\n#align category_theory.is_locally_surjective_of_iso CategoryTheory.isLocallySurjective_of_iso\n\ntheorem IsLocallySurjective.comp {F₁ F₂ F₃ : Cᵒᵖ ⥤ A} {f₁ : F₁ ⟶ F₂} {f₂ : F₂ ⟶ F₃}\n    (h₁ : IsLocallySurjective J f₁) (h₂ : IsLocallySurjective J f₂) :\n    IsLocallySurjective J (f₁ ≫ f₂) := by\n  intro U s\n  have :\n    (sieve.bind (image_sieve f₂ s) fun _ _ h => image_sieve f₁ h.some) ≤ image_sieve (f₁ ≫ f₂) s :=\n    by\n    rintro V i ⟨W, i, j, H, ⟨t', ht'⟩, rfl⟩\n    refine' ⟨t', _⟩\n    rw [op_comp, F₃.map_comp, nat_trans.comp_app, comp_apply, comp_apply, ht',\n      elementwise_of f₂.naturality, H.some_spec]\n  apply J.superset_covering this\n  apply J.bind_covering\n  · apply h₂\n  · intros\n    apply h₁\n#align category_theory.is_locally_surjective.comp CategoryTheory.IsLocallySurjective.comp\n\nsection\n\nvariable (F : Cᵒᵖ ⥤ Type max u v)\n\n/-- The image of `F` in `J.sheafify F` is isomorphic to the sheafification. -/\nnoncomputable def sheafificationIsoImagePresheaf :\n    J.sheafify F ≅ ((imagePresheaf (J.toSheafify F)).sheafify J).toPresheaf\n    where\n  Hom :=\n    J.sheafifyLift (toImagePresheafSheafify J _)\n      ((isSheaf_iff_isSheaf_of_type J _).mpr <|\n        Subpresheaf.sheafify_isSheaf _ <|\n          (isSheaf_iff_isSheaf_of_type J _).mp <| sheafify_isSheaf J _)\n  inv := Subpresheaf.ι _\n  hom_inv_id' :=\n    J.sheafify_hom_ext _ _ (J.sheafify_isSheaf _) (by simp [to_image_presheaf_sheafify])\n  inv_hom_id' :=\n    by\n    rw [← cancel_mono (subpresheaf.ι _), category.id_comp, category.assoc]\n    refine' Eq.trans _ (category.comp_id _)\n    congr 1\n    exact J.sheafify_hom_ext _ _ (J.sheafify_is_sheaf _) (by simp [to_image_presheaf_sheafify])\n    infer_instance\n#align category_theory.sheafification_iso_image_presheaf CategoryTheory.sheafificationIsoImagePresheaf\n\n-- We need to sheafify\nvariable {B : Type w} [Category.{max u v} B] [ConcreteCategory.{max u v} B]\n  [∀ X : C, Limits.HasColimitsOfShape (J.cover X)ᵒᵖ B]\n  [∀ (P : Cᵒᵖ ⥤ B) (X : C) (S : J.cover X), Limits.HasMultiequalizer (S.index P)]\n  [∀ (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ B),\n      Limits.PreservesLimit (W.index P).multicospan (forget B)]\n  [∀ X : C, Limits.PreservesColimitsOfShape (J.cover X)ᵒᵖ (forget B)]\n  [∀ (α β : Type max u v) (fst snd : β → α),\n      Limits.HasLimitsOfShape (Limits.WalkingMulticospan fst snd) B]\n\ntheorem toSheafify_isLocallySurjective (F : Cᵒᵖ ⥤ B) : IsLocallySurjective J (J.toSheafify F) :=\n  by\n  rw [is_locally_surjective_iff_whisker_forget, ← to_sheafify_comp_sheafify_comp_iso_inv]\n  apply is_locally_surjective.comp\n  · rw [is_locally_surjective_iff_image_presheaf_sheafify_eq_top, subpresheaf.eq_top_iff_is_iso]\n    exact is_iso.of_iso_inv (sheafification_iso_image_presheaf J (F ⋙ forget B))\n  · exact is_locally_surjective_of_iso _ _\n#align category_theory.to_sheafify_is_locally_surjective CategoryTheory.toSheafify_isLocallySurjective\n\nend\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Sites/Surjective.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505784, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.48200000892393274}}
{"text": "import formula\nimport semantics\nimport data.list.alist\nimport data.subtype\n\nvariables {vars : Type} [denumerable vars]\nvariables {A B C : form vars} {p q r : vars}\n\n/-- A schema is the set of substitution instances of some formula A. A is called\nthe *characteristic* formula of the schema, which is unique up to a renaming of\nvariables. -/\ndef schema (A : form vars) := {B | ∃s, subst.apply s A = B}\n\n/-- A renaming of variables is a mapping from variables to variables. -/\ndef rename (vars : Type) [decidable_eq vars] : Type := \n  { r : subst vars //\n    -- r maps only to variables\n    (∀ x, (r.lookup x).is_some → ∃ y, (⦃y⦄ ∈ r.lookup x)) ∧\n    -- r is injective\n    (∀ x y, r.lookup x = r.lookup y → \n           (r.lookup x).is_some → (r.lookup y).is_some → x = y) }\n\ndef rename.apply (r : rename vars) := subst.apply (r.val)\n\ndef rename.union (r₁ r₂ : rename vars) : rename vars := ⟨r₁.val ∪ r₂.val, sorry⟩\n\ninstance : has_union (rename vars) := ⟨rename.union⟩\ninstance : has_mem vars (rename vars) := ⟨λ x r, x ∈ r.val⟩\ninstance : has_emptyc (rename vars) := ⟨⟨∅, by simp⟩⟩\n\nuniverses u v\n\n@[simp]\ntheorem list.lookup_cons_not_mem {α : Type u} {β : α → Type v} [decidable_eq α]\n(l : list (sigma β)) {a : α} (s : sigma β) \n: a ∉ l.keys → ((list.lookup a (s :: l)).is_some ↔ a = s.fst) :=\nbegin\n  rcases s with ⟨s_fst, s_snd⟩,\n  simp only,\n  intro ha,\n  split,\n  { intro hsome,\n    simp only [list.lookup] at hsome,\n    split_ifs at hsome,\n    { simp only [h] },\n    { rw list.lookup_is_some at hsome, exfalso, exact ha hsome }\n  },\n  {\n    rintro rfl,\n    simp only [list.lookup_cons_eq, option.is_some_some, coe_sort_tt],\n  }\nend\n\ntheorem schema.characteristic_unique_up_to_renaming (h : schema A = schema B) \n  : ∃ (r : rename vars), r.apply A = B :=\nbegin\n  simp [set.ext_iff, schema] at h,\n  induction A generalizing B,\n  case form.Bottom {\n    simp [subst.apply] at ⊢ h,\n    specialize h B,\n    cases h.mpr ⟨∅, subst.apply_empty_id⟩ with _ this,\n    exact ⟨∅, this⟩,\n  },\n  case form.Var : a {\n    cases B,\n    case form.Var : b {\n      -- the renaming just takes variable a to b\n      set r : rename vars := ⟨⟨[⟨a, ⦃b⦄⟩], (by simp)⟩, by {\n        simp [alist.lookup],\n        intros x y hxy hx hy,\n        rw [hx, hy]\n      }⟩ with hr,\n      use r,\n      simp [rename.apply, subst.apply, subst.get, alist.lookup, hr,\n            sigma.map, list.lookup],\n    },\n    all_goals {\n      -- If B is some connective, then it cannot be\n      -- substituted to become ⦃A⦄, which contradicts h\n      exfalso,\n      cases (h ⦃a⦄).mp ⟨∅, subst.apply_empty_id⟩ with s this,\n      simp only [subst.apply] at this,\n      exact this\n    },\n  },\n  case form.Not : A ih {\n    cases B,\n    case form.Not : b {\n      simp only [rename.apply, subst.apply] at ⊢ h,\n      -- Now we know that the variable x in h has to be of the form (~ x), which\n      -- means we can simplify it to the following:\n      have : ∀ (x : form vars), (∃ (s : subst vars), s.apply A = x) ↔ \n                                (∃ (s : subst vars), s.apply b = x),\n        intro x,\n        specialize h (~x),\n        simp only at h,\n        exact h,\n      -- which is exactly what we need to use the ih\n      exact ih this,\n    },\n    case form.Var {\n      -- if B is a variable, then ~A cannot be substituted to become B,\n      -- but this contradicts h\n      exfalso,\n      cases (h ⦃B⦄).mpr ⟨∅, subst.apply_empty_id⟩ with s this,\n      simp only [subst.apply] at this,\n      exact this\n    },\n    all_goals {\n      exfalso,\n      cases (h (~A)).mp ⟨∅, subst.apply_empty_id⟩ with s this,\n      simp only [subst.apply] at this,\n      exact this\n    }\n  },\n  case form.And : A₁ A₂ ih₁ ih₂  {\n    cases B,\n    case form.And : B₁ B₂ {\n      simp only [rename.apply, subst.apply] at ⊢ h,\n      -- Now we know that the variable x in h has to be of the form (x₁ ⋀ x₂), \n      -- which means we can simplify it to the following:\n      have : ∀ (x₁ x₂ : form vars), \n        (∃ (s : subst vars), s.apply A₁ = x₁ ∧ s.apply A₂ = x₂) ↔ \n        (∃ (s : subst vars), s.apply B₁ = x₁ ∧ s.apply B₂ = x₂),\n        intros x₁ x₂,\n        specialize h (x₁ ⋀ x₂),\n        simp only at h,\n        exact h,\n      have hAB₁ : ∀ (x : form vars),\n        (∃ (s : subst vars), s.apply A₁ = x) ↔\n        (∃ (s : subst vars), s.apply B₁ = x),\n        intros x,\n        split,\n        { rintro ⟨sA₁, hA₁⟩,\n          obtain ⟨sB₁, hB₁, _⟩ := (this x (sA₁.apply A₂)).mp ⟨sA₁, hA₁, rfl⟩,\n          exact ⟨sB₁, hB₁⟩\n        },\n        { rintro ⟨sB₁, hB₁⟩,\n          obtain ⟨sA₁, hA₁, _⟩ := (this x (sB₁.apply B₂)).mpr ⟨sB₁, hB₁, rfl⟩,\n          exact ⟨sA₁, hA₁⟩\n        },\n      have hAB₂ : ∀ (x : form vars),\n        (∃ (s : subst vars), s.apply A₂ = x) ↔\n        (∃ (s : subst vars), s.apply B₂ = x),\n        intros x,\n        split,\n        { rintro ⟨sA₂, hA₂⟩,\n          obtain ⟨sB₂, _, hB₂⟩ := (this (sA₂.apply A₁) x).mp ⟨sA₂, rfl, hA₂⟩,\n          exact ⟨sB₂, hB₂⟩\n        },\n        { rintro ⟨sB₂, hB₂⟩,\n          obtain ⟨sA₂, _, hA₂⟩ := (this (sB₂.apply B₁) x).mpr ⟨sB₂, rfl, hB₂⟩,\n          exact ⟨sA₂, hA₂⟩\n        },\n      obtain ⟨r₁, hr₁⟩ := ih₁ hAB₁,\n      obtain ⟨r₂, hr₂⟩ := ih₂ hAB₂,\n      use r₁ ∪ r₂,\n      split,\n      simp [has_union.union, rename.union, subst.apply],\n      sorry, sorry\n    },\n    case form.Var {\n      exfalso,\n      cases (h ⦃B⦄).mpr ⟨∅, subst.apply_empty_id⟩ with s this,\n      simp only [subst.apply] at this,\n      exact this\n    },\n    all_goals {\n      exfalso,\n      cases (h (A₁ ⋀ A₂)).mp ⟨∅, subst.apply_empty_id⟩ with s this,\n      simp only [subst.apply] at this,\n      exact this\n    }\n  },\n  -- the remaining connectives will have basically the same proof as either\n  -- form.Not or form.And\n  sorry,\n  sorry,\n  sorry,\nend\n\ndef eval_schema (M : model vars) (S : set (form vars)) := ∀ B ∈ S, M ⊩ B\nnotation M ` ⊨ ` S := eval_schema M S\nnotation M ` ⊭ ` S := ¬ eval_schema M S\n\ndef valid_schema (S : set (form vars)) :=\n∀ M : model vars, M ⊨ S\n\nexample : valid_schema (schema (□ (⦃p⦄ ⟹ ⦃q⦄) ⟹ □ ⦃p⦄ ⟹ □ ⦃q⦄)) :=\nbegin\n  intros M C hC w,\n  simp only [schema, subst.apply, set.mem_set_of_eq] at hC,\n  cases hC with s hC,\n  rw ←hC,\n  simp [eval],\n  intros hAB hA w' hrel,\n  exact hAB w' hrel (hA w' hrel)\nend\n\nlemma eval_instance_iff_eval {A : form vars} {W : Type} [nonempty W] \n{R : W → W → Prop} {V V' : vars → set W} {w : W} \n{s : subst vars} (hM' : ∀ x, V' x = {w | ⟪W, R, V⟫ @@ w ⊩ s.get x}) \n: (⟪W, R, V⟫ @@ w ⊩ s.apply A) ↔ (⟪W, R, V'⟫ @@ w ⊩ A)\n:= begin\n  induction A generalizing w,\n  case form.Bottom { \n    simp only [subst.apply, bottom_eq_bot, eval],\n  },\n  case form.Var {\n    simp only [subst.apply, eval, hM' A, set.mem_set_of_eq],\n  },\n  case form.Not : A ih {\n    simp only [subst.apply, eval, not_iff_not, ih],\n  },\n  case form.And : A₁ A₂ ih₁ ih₂ {\n    simp only [subst.apply, eval, ih₁, ih₂],\n  },\n  case form.Or : A₁ A₂ ih₁ ih₂ {\n    simp only [subst.apply, eval, ih₁, ih₂],\n  },\n  case form.Imply : A₁ A₂ ih₁ ih₂ {\n    simp only [subst.apply, eval, ih₁, ih₂],\n  },\n  case form.Box : A ih {\n    simp only [subst.apply, eval],\n    split,\n    { intros h w' hw', specialize h w' hw', exact ih.mp h },\n    { intros h w' hw', specialize h w' hw', exact ih.mpr h }\n  }\nend\n\n/-- This is a generalisation of tautological_instance_is_valid where we have \nsubstitutions over arbitrary formulas, not just tautologies. -/\ntheorem valid_schema_iff_valid : valid_schema (schema A) ↔ valid A :=\nbegin\n  split,\n  -- the left-to-right direction is easy since A must be in its own schema.\n  { intros hv M w, exact hv M A ⟨∅, subst.apply_empty_id⟩ w },\n  rintros hv ⟨⟨W, hnonempty, R⟩, V⟩ A' ⟨s, rfl⟩ w,\n  resetI,\n  by_contra h,\n  -- We construct M' that re-assigns variables based on the truth value of their substitutions in the original model M.\n  set V' := λ x, {w | ⟪W, R, V⟫@@w ⊩ s.get x} with hV',\n  set M' : model vars := ⟪W, R, V'⟫ with hM',\n  have this := congr_fun hV',\n  dsimp at this,\n  -- Hence, whenever the substituted formula A' holds in the original model, \n  -- the pre-substituted formula A holds in our new model. This is represented\n  -- by the lemma `eval_instance_iff_eval`.\n  have := (eval_instance_iff_eval this).mpr (hv M' w),\n  exact h this,\nend\n\n/- What does this equivalence under validity mean for us? It means that we don't\nactually need the notion of schema in the first place =/, because we can always\njust reason about the characteristic formula. However, note that this \nequivalence under validity between the schema and its characteristic \nformula breaks down when we replace validity with truth in a specific model. \nConsider the following counterexample: -/\n\n/-- At least one direction holds, since A is an instance of its own schema. -/\ntheorem characteristic_true_of_schema_true {M : model vars} \n  : (M ⊨ schema A) → (M ⊩ A) :=\nbegin\n  intros hsA w,\n  exact hsA A ⟨∅, subst.apply_empty_id⟩ w,\nend\n\n/-- but consider the following model with one world: -/\ndef myM : model vars := {\n  F := {\n    W := unit, -- one world only: the unit element ()\n    R := λ _ _, false }, -- the frame relation doesn't matter\n  V := λ x, {()} -- every variable is true at the one and only world ()\n}\n\n/-- This model is a counter-example for the other direction of the equivalence:\nThe variable p is true in myM at any world by definition of myM.V. However it \nhas a substitution instance ⊥ that is never true at any world. -/\ntheorem characteristic_true_but_schema_not_true {p : vars}\n  : (myM ⊩ ⦃p⦄) ∧ (myM ⊭ schema ⦃p⦄) :=\nbegin\n  split,\n  { rintro ⟨⟩, simp only [eval], tauto }, -- hint told me to use tauto \n  { simp only [eval_schema, not_forall, exists_prop], \n    use ⊥,\n    split,\n    { use ⟨[⟨p, ⊥⟩], by simp⟩, simp [subst.apply, subst.get, alist.lookup] },\n    { use ⟨⟩, simp [eval] }\n  }\nend\n\n/-- Classes of models defined by a property of their frames. -/\ndef ℂ (F_prop : ∀ {W : Type}, (W → W → Prop) → Prop) : set (model vars) := \n{M | F_prop M.F.R}\n\n/- The following are some example classes that contain models with particular \nframe properties. -/\n\n/-- Models with reflexive frames -/\ndef ℂ_reflexive : set (model vars) :=\n ℂ (λ W R, ∀ w, R w w)\n\n/-- Models with transitive frames -/\ndef ℂ_transitive : set (model vars) :=\nℂ (λ W R, ∀ w1 w2 w3, R w1 w2 ∧ R w2 w3 → R w1 w3)\n\n/-- The general class of all models -/\ndef ℂ_all : set (model vars) := ℂ (λ _ _, true)\n\n/-- It is also possible to define a restricted notion of validity to classes of \nmodels. -/\ndef ℂ_valid (ℂ : set (model vars)) (A : form vars) :=\n∀ M ∈ ℂ, M ⊩ A\n\ndef ℂ_schema_valid (ℂ : set (model vars)) (𝕊 : set (form vars)) :=\n∀ M ∈ ℂ, M ⊨ 𝕊\n\n/-- We can modify the proof of valid_schema_iff_valid to adapt it to \nclass validity, but only for classes constructed by ℂ. -/\ntheorem class_valid_schema_iff_class_valid \n{F_prop : ∀ {W : Type}, (W → W → Prop) → Prop} \n: ℂ_schema_valid (ℂ @F_prop) (schema A) ↔ ℂ_valid (ℂ @F_prop) A :=\nbegin\n  split,\n  -- the mp direction is easy since A must be in its own schema.\n  { intros hv M hMℂ w, exact hv M hMℂ A ⟨∅, subst.apply_empty_id⟩ w },\n  rintros hv ⟨⟨W, _, R⟩, V⟩ hMℂ A' ⟨s, rfl⟩ w,\n  resetI,\n  by_contra h,\n  -- We construct M' that re-assigns variables based on the truth value of their\n  -- substitutions in the original model M.\n  set V' := λ x, {w | ⟪W, R, V⟫@@w ⊩ s.get x} with hV',\n  set M' : model vars := ⟪W, R, V'⟫ with hM',\n  -- This wouldn't work if we use arbitrary sets as classes since we'd know \n  -- nothing about what frames are included in the set. But we know that ℂ\n  -- aserts some kind of property on R which we know to be preserved since we\n  -- use the same R.\n  have hM'ℂ : M' ∈ (@ℂ vars _ @F_prop), { \n    simp only [ℂ, set.mem_set_of_eq], exact hMℂ\n  },\n  -- Hence, whenever the substituted formula A' holds in the original model, \n  -- the pre-substituted formula A holds in our new model. This is represented\n  -- by the lemma `eval_instance_iff_eval`.\n  have := (eval_instance_iff_eval (congr_fun hV')).mpr (hv M' hM'ℂ w),\n  exact h this,\nend\n\n/- There is a vague sense in which the formula T ≡ □ p ⟹ p \"characterizes\"\nmodels with reflexive relations. Semantically T reads that if p holds in this \nworld, then p holds in some related world. In general, this holds iff the \naccessibility relation is reflexive, since the only world we can guarantee to\nhave p hold is the current one. We can see one direction of the correspondence\nvia the following theorem of validity: for any model, if it is reflexive, then T\nholds in the model. -/\n\ntheorem T_is_ℂ_valid_reflexive {p : vars} \n: ℂ_valid ℂ_reflexive (□ ⦃p⦄ ⟹ ⦃p⦄) := \nbegin\n  unfold ℂ_valid,\n  intros M hM w,\n  simp only [ℂ_reflexive, ℂ, set.mem_set_of_eq] at hM,\n  simp only [eval, not_forall, exists_prop, set.not_not_mem],\n  intros hbA,\n  exact hbA w (hM w)\nend\n\n/- However, the converse doesn't hold: when T holds in a model, it is not \nnecessarily reflexive. This is because we can have specific valuations that\nmake it trivial to prove the statement. So, the statement is true by virtue of \nthe valuation, not the frame. For example, in a model where the antecedent p is\nnever true. -/\n\ndef myM' : model vars := {\n  F := {\n    W := unit,\n    R := λ _ _, false }, -- the frame relation is not reflexive\n  V := λ x, {} -- no variable is ever true at any world\n}\n\ntheorem T_true_in_non_reflexive_model {p : vars} \n: (myM' ⊩ ⦃p⦄ ⟹ ◇⦃p⦄) ∧ (myM' ∉ @ℂ_reflexive vars _) :=\nbegin\n  split,\n  { rintro w ⟨⟩ }, -- ⟨⟩ : false allows to prove anything\n  { simp [ℂ_reflexive, ℂ, myM'], }\nend\n\n/- This doesn't work because it is the frame relation that we care about, but\nwe are reasoning about classes of models. Instead, we should work with classes\nof frames and work from there. This is done in src/frame_definability.lean. -/\n\n/- The following are some small theorems about class validity. -/\n\ntheorem box_class_valid_of_class_valid {C : set (model vars)}\n(hvA : ℂ_valid C A) : ℂ_valid C (□ A) :=\nbegin\n  unfold ℂ_valid,\n  intros M hMinC _,\n  unfold eval,\n  intros w' hrel,\n  exact hvA M hMinC w',\nend\n\ntheorem class_valid_subset {C C' : set (model vars)} (hsub : C' ⊆ C) \n(hvA : ℂ_valid C A) : ℂ_valid C' A :=\nbegin\n  unfold ℂ_valid,\n  intros M hMinC',\n  exact hvA M (hsub hMinC')\nend", "meta": {"author": "alyata", "repo": "formalising-math-2", "sha": "30a001f2ff3d54a8a3432a178d0314a4abda57aa", "save_path": "github-repos/lean/alyata-formalising-math-2", "path": "github-repos/lean/alyata-formalising-math-2/formalising-math-2-30a001f2ff3d54a8a3432a178d0314a4abda57aa/src/schemas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.48200000863810916}}
{"text": "import data.rat.default data.pnat.basic tactic.fin_cases\n\n/-! # IMO 2013 N6 -/\n\nnamespace IMOSL\nnamespace IMO2013N6\n\nopen function\n\ndef fn_eq (f : ℚ → ℤ) := ∀ (x : ℚ) (a : ℤ) (b : ℕ+), f ((x + a) / b) = f (((f x : ℚ) + a) / b)\n\n\n\nsection extra\n\nvariables {α : Type*} [linear_ordered_ring α] [floor_ring α]\n\nlemma floor_eq_floor_iff (x y : α) : ⌊x⌋ = ⌊y⌋ ↔ (∀ k : ℤ, ↑k ≤ x ↔ ↑k ≤ y) :=\n  ⟨λ h k, by rw [← int.le_floor, h, int.le_floor],\n   λ h, le_antisymm (int.le_floor.mpr ((h _).mp (int.floor_le x)))\n                    (int.le_floor.mpr ((h _).mpr (int.floor_le y)))⟩\n\nend extra\n\n\n\nsection results\n\nvariables {f : ℚ → ℤ} (feq : fn_eq f)\ninclude feq\n\nprivate lemma lem1 (h : f 0 = f 1) : ∃ C : ℤ, f = const ℚ C :=\nbegin\n  suffices : ∀ (n : ℕ) (a : ℤ) (b : ℕ+), f (a / b) = f ((a + n) / b),\n  { use f 0; ext x; rw const_apply,\n    induction x using rat.num_denom_cases_on with a b h0 h1,\n    lift b to ℕ+ using h0,\n    rw [← rat.coe_int_div_eq_mk, ← coe_coe, ← coe_coe],\n    cases le_total 0 a with h0 h0,\n    { lift a to ℕ using h0,\n      replace h1 := this a 0 b,\n      rw [int.cast_zero, zero_div, zero_add] at h1,\n      rw [← coe_coe, ← h1] },\n    { rw ← neg_nonneg at h0,\n      lift (-a) to ℕ using h0 with x h0,\n      replace h1 := this x a b,\n      rw [h1, ← int.cast_coe_nat, h0, int.cast_neg, add_neg_self, zero_div] } },\n  intros n; induction n with n n_ih; intros a b,\n  rw [nat.cast_zero, add_zero],\n  have h1 := feq 0 a b,\n  rw [zero_add, h, ← feq, add_comm, ← int.cast_one, ← int.cast_add] at h1,\n  rw [h1, n_ih, int.cast_add, nat.cast_succ, add_right_comm, add_assoc, int.cast_one]\nend\n\nprivate lemma lem2 (h : f 0 ≠ f 1) (m : ℤ) : f m = m :=\nbegin\n  apply le_antisymm; rw ← not_lt; intros h0,\n  { lift (f m - m) to ℕ+ using (by rwa sub_pos) with k h1,\n    replace feq := feq m (-m) k,\n    rw [← int.cast_add, add_neg_self, int.cast_zero, zero_div, ← int.cast_add,\n        ← sub_eq_add_neg, ← h1, coe_coe, int.cast_coe_nat, ← coe_coe, div_self] at feq,\n    exacts [h feq, by rw [coe_coe, nat.cast_ne_zero]; exact pnat.ne_zero k] },\n  { lift (m - f m) to ℕ+ using (by rwa sub_pos) with k h1,\n    replace feq := feq m (-f m) k,\n    rw [← int.cast_add, ← sub_eq_add_neg, ← h1, coe_coe, int.cast_coe_nat, ← coe_coe,\n        div_self, ← int.cast_add, add_neg_self, int.cast_zero, zero_div, eq_comm] at feq,\n    exacts [h feq, by rw [coe_coe, nat.cast_ne_zero]; exact pnat.ne_zero k] }\nend\n\nprivate lemma lem3 (h : ∀ m : ℤ, f m = m) : f (1 / 2) = 0 ∨ f (1 / 2) = 1 :=\nbegin\n  cases le_or_lt (f (1 / 2)) 0 with h0 h0,\n  { have h1 : 0 < 1 - 2 * f (1 / 2) := by rw sub_pos;\n      exact lt_of_le_of_lt (mul_nonpos_of_nonneg_of_nonpos zero_le_two h0) one_pos,\n    lift 1 - 2 * f (1 / 2) to ℕ+ using h1 with b h1,\n    replace feq := feq (1 / 2) (-f (1 / 2)) b,\n    left; rw int.cast_neg at feq; convert feq using 2,\n    rw [← sub_eq_add_neg, eq_div_iff, div_sub', coe_coe, ← int.cast_coe_nat, h1,\n        int.cast_sub, int.cast_mul, int.cast_one, int.cast_two, div_mul_comm, mul_one],\n    exact two_ne_zero,\n    rw [coe_coe, nat.cast_ne_zero]; exact b.ne_zero,\n    rw [add_neg_self, zero_div, eq_comm, ← int.cast_zero, h] },\n  { have h1 : 0 < 2 * f (1 / 2) - 1 := begin\n      rw [int.lt_iff_add_one_le, zero_add] at h0,\n      rw [sub_pos, int.lt_iff_add_one_le, ← mul_one (1 + 1 : ℤ), ← bit0, mul_le_mul_left],\n      exacts [h0, two_pos]\n    end,\n    lift 2 * f (1 / 2) - 1 to ℕ+ using h1 with b h1,\n    replace feq := feq (1 / 2) (f (1 / 2) - 1) b,\n    have h2 : (b : ℚ) ≠ 0 := by rw [coe_coe, nat.cast_ne_zero]; exact b.ne_zero,\n    right; convert feq using 2,\n    rw [eq_div_iff h2, div_add', coe_coe, ← int.cast_coe_nat, h1, int.cast_sub, int.cast_sub,\n        sub_mul, add_sub_left_comm, int.cast_one, mul_two (1 : ℚ), int.cast_mul, sub_add_cancel',\n        ← sub_eq_add_neg, int.cast_two, mul_comm (2 : ℚ), div_mul_comm, mul_one],\n    exact two_ne_zero,\n    rw [← int.cast_add, ← add_sub_assoc, ← two_mul, ← h1, coe_coe, int.cast_coe_nat,\n        ← coe_coe b, div_self h2, eq_comm, ← int.cast_one, h] }\nend\n\nprivate lemma lem4 (h : ∀ m : ℤ, f m = m) (h0 : f (1 / 2) = 0)\n  (a : ℕ) (b : ℕ+) (h1 : a < b) : f (a / b) = 0 :=\nbegin\n  revert a h1; induction b using pnat.case_strong_induction_on with b b_ih; intros a h1,\n  rw [pnat.one_coe, nat.lt_one_iff] at h1,\n  rw [h1, nat.cast_zero, zero_div, ← int.cast_zero, h],\n  rw [pnat.add_coe, pnat.one_coe, nat.lt_add_one_iff, le_iff_lt_or_eq] at h1,\n  suffices : ∀ a : ℕ, a < b → f (a / ↑(b + 1)) = 0,\n  { rcases h1 with h1 | rfl,\n    exact this a h1,\n    rcases eq_or_ne b 1 with rfl | h1,\n    rw [coe_coe, pnat.add_coe, pnat.one_coe, nat.cast_add, nat.cast_one, ← bit0, h0],\n    replace h1 := pnat.exists_eq_succ_of_ne_one h1,\n    rcases h1 with ⟨k, rfl⟩,\n    replace this := this 1 (by rw [pnat.add_coe, pnat.one_coe]; exact pnat.lt_add_left 1 k),\n    rw nat.cast_one at this,\n    replace feq := feq (1 / ↑(k + 1 + 1)) k (k + 1),\n    replace b_ih := b_ih (k + 1) (le_refl _) k\n      (by rw [pnat.add_coe, pnat.one_coe]; exact pnat.lt_add_right k 1),\n    rw [this, int.cast_zero, zero_add, coe_coe k, ← coe_coe, b_ih,\n        div_add', div_div, mul_comm ↑(k + 1 + 1), ← div_div] at feq,\n    convert feq; rw eq_div_iff,\n    simp only [pnat.one_coe, nat.cast_add, pnat.add_coe, nat.cast_one, coe_coe],\n    rw [int.cast_add, int.cast_add, int.cast_one, ← coe_coe],\n    generalize : ((k : ℕ) : ℚ) = m,\n    rw [mul_add_one, mul_add_one, add_comm (1 : ℚ), add_assoc, mul_comm],\n    all_goals { apply ne_of_gt, rw [coe_coe, nat.cast_pos], exact pnat.pos _ } },\n  clear h1 a; intros a h1,\n  replace feq := feq (a / b) a (b + 1),\n  replace b_ih := b_ih b (le_refl b) a h1,\n  suffices : ((b : ℚ)⁻¹ + 1) / ↑(b + 1) = (b : ℚ)⁻¹,\n    rwa [b_ih, int.cast_zero, zero_add, ← coe_coe, div_eq_mul_inv (a : ℚ),\n         ← mul_add_one, mul_div_assoc, this, ← div_eq_mul_inv, b_ih, eq_comm] at feq,\n  simp only [pnat.one_coe, nat.cast_add, pnat.add_coe, nat.cast_one, coe_coe],\n  rw [int.cast_add, int.cast_one, ← coe_coe],\n  generalize h : ((b : ℕ) : ℚ) = k,\n  replace h : 0 < k := by rw [← h, nat.cast_pos]; exact pnat.pos b,\n  rw [inv_eq_one_div, div_add_one, add_comm, div_div, div_mul_left],\n  exacts [ne_of_gt (add_pos h one_pos), ne_of_gt h]\nend\n\nprivate lemma lem5 (h : ∀ m : ℤ, f m = m) (h0 : f (1 / 2) = 0) : f = int.floor :=\nbegin\n  suffices : ∀ x : ℚ, ⌊x⌋ = 0 → f x = 0,\n  { ext x,\n    replace feq := feq (x - ⌊x⌋) ⌊x⌋ 1,\n    rwa [coe_coe (1 : ℕ+), pnat.one_coe, nat.cast_one, div_one, div_one,\n         sub_add_cancel, this (x - ⌊x⌋), int.cast_zero, zero_add, h] at feq,\n    rw [int.floor_sub_int, sub_self] },\n  intros x h1,\n  induction x using rat.num_denom_cases_on with a b h2 h3; clear h3,\n  lift b to ℕ+ using h2,\n  rw [← rat.coe_int_div_eq_mk, int.cast_coe_nat] at h1 ⊢,\n  have h2 : 0 < ((b : ℕ) : ℚ) := nat.cast_pos.mpr b.pos,\n  rw [int.floor_eq_iff, int.cast_zero, zero_add, div_lt_one h2, le_div_iff h2,\n      zero_mul, int.cast_nonneg, ← int.cast_coe_nat, int.cast_lt, ← coe_coe] at h1,\n  cases h1 with h3 h1,\n  lift a to ℕ using h3,\n  rw [coe_coe, nat.cast_lt] at h1,\n  rw [← coe_coe, ← coe_coe, lem4 feq h h0 a b h1]\nend\n\nend results\n\n\n\n/-- Final solution -/\ntheorem final_solution (f : ℚ → ℤ) : fn_eq f ↔\n  ((∃ C : ℤ, f = const ℚ C) ∨ f = int.floor ∨ f = int.ceil) :=\nbegin\n  split,\n  { intros feq,\n    cases eq_or_ne (f 0) (f 1) with h h,\n    left; exact lem1 feq h,\n    right; replace h := lem2 feq h,\n    cases lem3 feq h with h0 h0,\n    left; exact lem5 feq h h0,\n    right; suffices : (λ x, -f (-x)) = int.floor,\n    { ext x; convert congr_arg has_neg.neg (congr_fun this (-x)),\n      rw [neg_neg, neg_neg] },\n    refine lem5 (λ x a b, _) (λ m, _) _,\n    rw [neg_inj, ← neg_div, ← neg_div, neg_add, neg_add,\n        int.cast_neg, neg_neg, ← int.cast_neg, feq],\n    rw [← int.cast_neg, h, neg_neg],\n    rw [neg_eq_zero, ← h 0],\n    convert feq (1 / 2) (-1) 1; field_simp,\n    rw [bit0, neg_add, ← add_assoc, add_neg_self, zero_add],\n    rw [h0, int.cast_one, add_neg_self] },\n  suffices : fn_eq int.floor,\n  { rintros (⟨C, rfl⟩ | rfl | rfl),\n    intros x a b; rw const_apply,\n    exact this,\n    intros x a b,\n    replace this := this (-x) (-a) b,\n    rwa [int.cast_neg, ← neg_add, neg_div, int.floor_neg, int.floor_neg,\n         int.cast_neg, ← neg_add, neg_div, int.floor_neg, neg_inj] at this },\n  intros x a b,\n  rw floor_eq_floor_iff; intros k,\n  have h : 0 < (b : ℚ) := by rw [coe_coe, nat.cast_pos]; exact b.pos,\n  rw [le_div_iff h, le_div_iff h, ← sub_le_iff_le_add, ← sub_le_iff_le_add, coe_coe,\n      ← int.cast_coe_nat, ← coe_coe b, ← int.cast_mul, ← int.cast_sub, int.cast_le, int.le_floor]\nend\n\nend IMO2013N6\nend IMOSL\n", "meta": {"author": "mortarsanjaya", "repo": "imo-A-and-N", "sha": "645a924da7442f41d56ee6a0d96dc4d777b593a9", "save_path": "github-repos/lean/mortarsanjaya-imo-A-and-N", "path": "github-repos/lean/mortarsanjaya-imo-A-and-N/imo-A-and-N-645a924da7442f41d56ee6a0d96dc4d777b593a9/src/IMO2013/N6/N6.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.48200000863810916}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport data.matrix.basis\nimport linear_algebra.basis\nimport linear_algebra.pi\n\n/-!\n# The standard basis\n\nThis file defines the standard basis `pi.basis (s : ∀ j, basis (ι j) R (M j))`,\nwhich is the `Σ j, ι j`-indexed basis of Π j, M j`. The basis vectors are given by\n`pi.basis s ⟨j, i⟩ j' = linear_map.std_basis R M j' (s j) i = if j = j' then s i else 0`.\n\nThe standard basis on `R^η`, i.e. `η → R` is called `pi.basis_fun`.\n\nTo give a concrete example, `linear_map.std_basis R (λ (i : fin 3), R) i 1`\ngives the `i`th unit basis vector in `R³`, and `pi.basis_fun R (fin 3)` proves\nthis is a basis over `fin 3 → R`.\n\n## Main definitions\n\n - `linear_map.std_basis R M`: if `x` is a basis vector of `M i`, then\n   `linear_map.std_basis R M i x` is the `i`th standard basis vector of `Π i, M i`.\n - `pi.basis s`: given a basis `s i` for each `M i`, the standard basis on `Π i, M i`\n - `pi.basis_fun R η`: the standard basis on `R^η`, i.e. `η → R`, given by\n   `pi.basis_fun R η i j = if i = j then 1 else 0`.\n - `matrix.std_basis R n m`: the standard basis on `matrix n m R`, given by\n   `matrix.std_basis R n m (i, j) i' j' = if (i, j) = (i', j') then 1 else 0`.\n\n-/\n\nopen function submodule\nopen_locale big_operators\n\nnamespace linear_map\n\nvariables (R : Type*) {ι : Type*} [semiring R] (φ : ι → Type*)\n  [Π i, add_comm_monoid (φ i)] [Π i, module R (φ i)] [decidable_eq ι]\n\n/-- The standard basis of the product of `φ`. -/\ndef std_basis : Π (i : ι), φ i →ₗ[R] (Πi, φ i) := single\n\nlemma std_basis_apply (i : ι) (b : φ i) : std_basis R φ i b = update 0 i b :=\nrfl\n\n@[simp] lemma std_basis_apply' (i i' : ι) : (std_basis R (λ (_x : ι), R) i) 1 i' =\n  ite (i = i') 1 0  :=\nbegin\n  rw [linear_map.std_basis_apply, function.update_apply, pi.zero_apply],\n  congr' 1, rw [eq_iff_iff, eq_comm],\nend\n\nlemma coe_std_basis (i : ι) : ⇑(std_basis R φ i) = pi.single i :=\nrfl\n\n@[simp] lemma std_basis_same (i : ι) (b : φ i) : std_basis R φ i b i = b :=\npi.single_eq_same i b\n\nlemma std_basis_ne (i j : ι) (h : j ≠ i) (b : φ i) : std_basis R φ i b j = 0 :=\npi.single_eq_of_ne h b\n\nlemma std_basis_eq_pi_diag (i : ι) : std_basis R φ i = pi (diag i) :=\nbegin\n  ext x j,\n  convert (update_apply 0 x i j _).symm,\n  refl,\nend\n\nlemma ker_std_basis (i : ι) : ker (std_basis R φ i) = ⊥ :=\nker_eq_bot_of_injective $ pi.single_injective _ _\n\nlemma proj_comp_std_basis (i j : ι) : (proj i).comp (std_basis R φ j) = diag j i :=\nby rw [std_basis_eq_pi_diag, proj_pi]\n\nlemma proj_std_basis_same (i : ι) : (proj i).comp (std_basis R φ i) = id :=\nlinear_map.ext $ std_basis_same R φ i\n\nlemma proj_std_basis_ne (i j : ι) (h : i ≠ j) : (proj i).comp (std_basis R φ j) = 0 :=\nlinear_map.ext $ std_basis_ne R φ _ _ h\n\nlemma supr_range_std_basis_le_infi_ker_proj (I J : set ι) (h : disjoint I J) :\n  (⨆i∈I, range (std_basis R φ i)) ≤ (⨅i∈J, ker (proj i : (Πi, φ i) →ₗ[R] φ i)) :=\nbegin\n  refine (supr_le $ λ i, supr_le $ λ hi, range_le_iff_comap.2 _),\n  simp only [(ker_comp _ _).symm, eq_top_iff, set_like.le_def, mem_ker, comap_infi, mem_infi],\n  rintro b - j hj,\n  rw [proj_std_basis_ne R φ j i, zero_apply],\n  rintro rfl,\n  exact h.le_bot ⟨hi, hj⟩\nend\n\nlemma infi_ker_proj_le_supr_range_std_basis {I : finset ι} {J : set ι} (hu : set.univ ⊆ ↑I ∪ J) :\n  (⨅ i∈J, ker (proj i : (Πi, φ i) →ₗ[R] φ i)) ≤ (⨆i∈I, range (std_basis R φ i)) :=\nset_like.le_def.2\nbegin\n  assume b hb,\n  simp only [mem_infi, mem_ker, proj_apply] at hb,\n  rw ← show ∑ i in I, std_basis R φ i (b i) = b,\n  { ext i,\n    rw [finset.sum_apply, ← std_basis_same R φ i (b i)],\n    refine finset.sum_eq_single i (assume j hjI ne, std_basis_ne _ _ _ _ ne.symm _) _,\n    assume hiI,\n    rw [std_basis_same],\n    exact hb _ ((hu trivial).resolve_left hiI) },\n  exact sum_mem_bsupr (λ i hi, mem_range_self (std_basis R φ i) (b i))\nend\n\nlemma supr_range_std_basis_eq_infi_ker_proj {I J : set ι}\n  (hd : disjoint I J) (hu : set.univ ⊆ I ∪ J) (hI : set.finite I) :\n  (⨆i∈I, range (std_basis R φ i)) = (⨅i∈J, ker (proj i : (Πi, φ i) →ₗ[R] φ i)) :=\nbegin\n  refine le_antisymm (supr_range_std_basis_le_infi_ker_proj _ _ _ _ hd) _,\n  have : set.univ ⊆ ↑hI.to_finset ∪ J, { rwa [hI.coe_to_finset] },\n  refine le_trans (infi_ker_proj_le_supr_range_std_basis R φ this) (supr_mono $ assume i, _),\n  rw [set.finite.mem_to_finset],\n  exact le_rfl\nend\n\nlemma supr_range_std_basis [finite ι] : (⨆ i, range (std_basis R φ i)) = ⊤ :=\nbegin\n  casesI nonempty_fintype ι,\n  convert top_unique (infi_emptyset.ge.trans $ infi_ker_proj_le_supr_range_std_basis R φ _),\n  { exact funext (λ i, (@supr_pos _ _ _ (λ h, range $ std_basis R φ i) $ finset.mem_univ i).symm) },\n  { rw [finset.coe_univ, set.union_empty] }\nend\n\nlemma disjoint_std_basis_std_basis (I J : set ι) (h : disjoint I J) :\n  disjoint (⨆i∈I, range (std_basis R φ i)) (⨆i∈J, range (std_basis R φ i)) :=\nbegin\n  refine disjoint.mono\n    (supr_range_std_basis_le_infi_ker_proj _ _ _ _ $ disjoint_compl_right)\n    (supr_range_std_basis_le_infi_ker_proj _ _ _ _ $ disjoint_compl_right) _,\n  simp only [disjoint_iff_inf_le, set_like.le_def, mem_infi, mem_inf, mem_ker, mem_bot, proj_apply,\n    funext_iff],\n  rintros b ⟨hI, hJ⟩ i,\n  classical,\n  by_cases hiI : i ∈ I,\n  { by_cases hiJ : i ∈ J,\n    { exact (h.le_bot ⟨hiI, hiJ⟩).elim },\n    { exact hJ i hiJ } },\n  { exact hI i hiI }\nend\n\nlemma std_basis_eq_single {a : R} :\n  (λ (i : ι), (std_basis R (λ _ : ι, R) i) a) = λ (i : ι), (finsupp.single i a) :=\nfunext $ λ i, (finsupp.single_eq_pi_single i a).symm\n\nend linear_map\n\nnamespace pi\nopen linear_map\nopen set\n\nvariables {R : Type*}\n\nsection module\nvariables {η : Type*} {ιs : η → Type*} {Ms : η → Type*}\n\nlemma linear_independent_std_basis [ring R] [∀i, add_comm_group (Ms i)] [∀i, module R (Ms i)]\n  [decidable_eq η] (v : Πj, ιs j → (Ms j)) (hs : ∀i, linear_independent R (v i)) :\n  linear_independent R (λ (ji : Σ j, ιs j), std_basis R Ms ji.1 (v ji.1 ji.2)) :=\nbegin\n  have hs' : ∀j : η, linear_independent R (λ i : ιs j, std_basis R Ms j (v j i)),\n  { intro j,\n    exact (hs j).map' _ (ker_std_basis _ _ _) },\n  apply linear_independent_Union_finite hs',\n  { assume j J _ hiJ,\n    simp [(set.Union.equations._eqn_1 _).symm, submodule.span_image, submodule.span_Union],\n    have h₀ : ∀ j, span R (range (λ (i : ιs j), std_basis R Ms j (v j i)))\n        ≤ range (std_basis R Ms j),\n    { intro j,\n      rw [span_le, linear_map.range_coe],\n      apply range_comp_subset_range },\n    have h₁ : span R (range (λ (i : ιs j), std_basis R Ms j (v j i)))\n        ≤ ⨆ i ∈ {j}, range (std_basis R Ms i),\n    { rw @supr_singleton _ _ _ (λ i, linear_map.range (std_basis R (λ (j : η), Ms j) i)),\n      apply h₀ },\n    have h₂ : (⨆ j ∈ J, span R (range (λ (i : ιs j), std_basis R Ms j (v j i)))) ≤\n               ⨆ j ∈ J, range (std_basis R (λ (j : η), Ms j) j) :=\n      supr₂_mono (λ i _, h₀ i),\n    have h₃ : disjoint (λ (i : η), i ∈ {j}) J,\n    { convert set.disjoint_singleton_left.2 hiJ using 0 },\n    exact (disjoint_std_basis_std_basis _ _ _ _ h₃).mono h₁ h₂ }\nend\n\nvariables [semiring R] [∀i, add_comm_monoid (Ms i)] [∀i, module R (Ms i)]\n\nvariable [fintype η]\n\nsection\n\nopen linear_equiv\n\n/-- `pi.basis (s : ∀ j, basis (ιs j) R (Ms j))` is the `Σ j, ιs j`-indexed basis on `Π j, Ms j`\ngiven by `s j` on each component.\n\nFor the standard basis over `R` on the finite-dimensional space `η → R` see `pi.basis_fun`.\n-/\nprotected noncomputable def basis (s : ∀ j, basis (ιs j) R (Ms j)) :\n  basis (Σ j, ιs j) R (Π j, Ms j) :=\n-- The `add_comm_monoid (Π j, Ms j)` instance was hard to find.\n-- Defining this in tactic mode seems to shake up instance search enough that it works by itself.\nby { refine basis.of_repr (_ ≪≫ₗ (finsupp.sigma_finsupp_lequiv_pi_finsupp R).symm),\n     exact linear_equiv.Pi_congr_right (λ j, (s j).repr) }\n\n@[simp] lemma basis_repr_std_basis [decidable_eq η] (s : ∀ j, basis (ιs j) R (Ms j)) (j i) :\n  (pi.basis s).repr (std_basis R _ j (s j i)) = finsupp.single ⟨j, i⟩ 1 :=\nbegin\n  ext ⟨j', i'⟩,\n  by_cases hj : j = j',\n  { subst hj,\n    simp only [pi.basis, linear_equiv.trans_apply, basis.repr_self, std_basis_same,\n        linear_equiv.Pi_congr_right_apply, finsupp.sigma_finsupp_lequiv_pi_finsupp_symm_apply],\n    symmetry,\n    exact finsupp.single_apply_left\n      (λ i i' (h : (⟨j, i⟩ : Σ j, ιs j) = ⟨j, i'⟩), eq_of_heq (sigma.mk.inj h).2) _ _ _ },\n  simp only [pi.basis, linear_equiv.trans_apply, finsupp.sigma_finsupp_lequiv_pi_finsupp_symm_apply,\n      linear_equiv.Pi_congr_right_apply],\n  dsimp,\n  rw [std_basis_ne _ _ _ _ (ne.symm hj), linear_equiv.map_zero, finsupp.zero_apply,\n      finsupp.single_eq_of_ne],\n  rintros ⟨⟩,\n  contradiction\nend\n\n@[simp] lemma basis_apply [decidable_eq η] (s : ∀ j, basis (ιs j) R (Ms j)) (ji) :\n  pi.basis s ji = std_basis R _ ji.1 (s ji.1 ji.2) :=\nbasis.apply_eq_iff.mpr (by simp)\n\n@[simp] lemma basis_repr (s : ∀ j, basis (ιs j) R (Ms j)) (x) (ji) :\n  (pi.basis s).repr x ji = (s ji.1).repr (x ji.1) ji.2 :=\nrfl\n\nend\n\nsection\nvariables (R η)\n\n/-- The basis on `η → R` where the `i`th basis vector is `function.update 0 i 1`. -/\nnoncomputable def basis_fun : basis η R (Π (j : η), R) :=\nbasis.of_equiv_fun (linear_equiv.refl _ _)\n\n@[simp] lemma basis_fun_apply [decidable_eq η] (i) :\n  basis_fun R η i = std_basis R (λ (i : η), R) i 1 :=\nby { simp only [basis_fun, basis.coe_of_equiv_fun, linear_equiv.refl_symm,\n                linear_equiv.refl_apply, std_basis_apply] }\n\n@[simp] lemma basis_fun_repr (x : η → R) (i : η) :\n  (pi.basis_fun R η).repr x i = x i :=\nby simp [basis_fun]\n\nend\n\nend module\n\nend pi\n\nnamespace matrix\n\nvariables (R : Type*) (m n : Type*) [fintype m] [fintype n] [semiring R]\n\n/-- The standard basis of `matrix m n R`. -/\nnoncomputable def std_basis : basis (m × n) R (matrix m n R) :=\nbasis.reindex (pi.basis (λ (i : m), pi.basis_fun R n)) (equiv.sigma_equiv_prod _ _)\n\nvariables {n m}\n\nlemma std_basis_eq_std_basis_matrix (i : n) (j : m) [decidable_eq n] [decidable_eq m] :\n  std_basis R n m (i, j) = std_basis_matrix i j (1 : R) :=\nbegin\n  ext a b,\n  by_cases hi : i = a; by_cases hj : j = b,\n  { simp [std_basis, hi, hj] },\n  { simp [std_basis, hi, hj, ne.symm hj, linear_map.std_basis_ne] },\n  { simp [std_basis, hi, hj, ne.symm hi, linear_map.std_basis_ne] },\n  { simp [std_basis, hi, hj, ne.symm hj, ne.symm hi, linear_map.std_basis_ne] }\nend\n\nend matrix\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/linear_algebra/std_basis.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4820000041750714}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport order.filter.lift\nimport topology.opens\nimport topology.algebra.ring\n\nopen topological_space\nopen_locale topological_space\n\nset_option old_structure_cmd true\n\n/-- The type of open subgroups of a topological additive group. -/\n@[ancestor add_subgroup]\nstructure open_add_subgroup  (G : Type*) [add_group G] [topological_space G]\n  extends add_subgroup G :=\n(is_open' : is_open carrier)\n\n/-- The type of open subgroups of a topological group. -/\n@[ancestor subgroup, to_additive]\nstructure open_subgroup (G : Type*) [group G] [topological_space G] extends subgroup G :=\n(is_open' : is_open carrier)\n\n/-- Reinterpret an `open_subgroup` as a `subgroup`. -/\nadd_decl_doc open_subgroup.to_subgroup\n\n/-- Reinterpret an `open_add_subgroup` as an `add_subgroup`. -/\nadd_decl_doc open_add_subgroup.to_add_subgroup\n\n-- Tell Lean that `open_add_subgroup` is a namespace\nnamespace open_add_subgroup\nend open_add_subgroup\n\nnamespace open_subgroup\nopen function topological_space\nvariables {G : Type*} [group G] [topological_space G]\nvariables {U V : open_subgroup G} {g : G}\n\n@[to_additive]\ninstance has_coe_set : has_coe_t (open_subgroup G) (set G) := ⟨λ U, U.1⟩\n\n@[to_additive]\ninstance : has_mem G (open_subgroup G) := ⟨λ g U, g ∈ (U : set G)⟩\n\n@[to_additive]\ninstance has_coe_subgroup : has_coe_t (open_subgroup G) (subgroup G) := ⟨to_subgroup⟩\n\n@[to_additive]\ninstance has_coe_opens : has_coe_t (open_subgroup G) (opens G) := ⟨λ U, ⟨U, U.is_open'⟩⟩\n\n@[simp, to_additive] lemma mem_coe : g ∈ (U : set G) ↔ g ∈ U := iff.rfl\n@[simp, to_additive] lemma mem_coe_opens : g ∈ (U : opens G) ↔ g ∈ U := iff.rfl\n@[simp, to_additive]\nlemma mem_coe_subgroup : g ∈ (U : subgroup G) ↔ g ∈ U := iff.rfl\n\nattribute [norm_cast] mem_coe mem_coe_opens mem_coe_subgroup open_add_subgroup.mem_coe\n  open_add_subgroup.mem_coe_opens open_add_subgroup.mem_coe_add_subgroup\n\n@[to_additive] lemma coe_injective : injective (coe : open_subgroup G → set G) :=\nλ U V h, by cases U; cases V; congr; assumption\n\n@[ext, to_additive]\nlemma ext (h : ∀ x, x ∈ U ↔ x ∈ V) : (U = V) := coe_injective $ set.ext h\n\n@[to_additive]\nlemma ext_iff : (U = V) ↔ (∀ x, x ∈ U ↔ x ∈ V) := ⟨λ h x, h ▸ iff.rfl, ext⟩\n\nvariable (U)\n@[to_additive]\nprotected lemma is_open : is_open (U : set G) := U.is_open'\n\n@[to_additive]\nprotected lemma one_mem : (1 : G) ∈ U := U.one_mem'\n\n@[to_additive]\nprotected lemma inv_mem {g : G} (h : g ∈ U) : g⁻¹ ∈ U := U.inv_mem' h\n\n@[to_additive]\nprotected lemma mul_mem {g₁ g₂ : G} (h₁ : g₁ ∈ U) (h₂ : g₂ ∈ U) : g₁ * g₂ ∈ U := U.mul_mem' h₁ h₂\n\n@[to_additive]\nlemma mem_nhds_one : (U : set G) ∈ 𝓝 (1 : G) :=\nmem_nhds_sets U.is_open U.one_mem\nvariable {U}\n\n@[to_additive]\ninstance : has_top (open_subgroup G) := ⟨{ is_open' := is_open_univ, .. (⊤ : subgroup G) }⟩\n\n@[to_additive]\ninstance : inhabited (open_subgroup G) := ⟨⊤⟩\n\n@[to_additive]\nlemma is_closed [has_continuous_mul G] (U : open_subgroup G) : is_closed (U : set G) :=\nbegin\n  apply is_open_compl_iff.1,\n  refine is_open_iff_forall_mem_open.2 (λ x hx, ⟨(λ y, y * x⁻¹) ⁻¹' U, _, _, _⟩),\n  { intros u hux,\n    simp only [set.mem_preimage, set.mem_compl_iff, mem_coe] at hux hx ⊢,\n    refine mt (λ hu, _) hx,\n    convert U.mul_mem (U.inv_mem hux) hu,\n    simp },\n  { exact U.is_open.preimage (continuous_mul_right _) },\n  { simp [U.one_mem] }\nend\n\nsection\nvariables {H : Type*} [group H] [topological_space H]\n\n/-- The product of two open subgroups as an open subgroup of the product group. -/\n@[to_additive \"The product of two open subgroups as an open subgroup of the product group.\"]\ndef prod (U : open_subgroup G) (V : open_subgroup H) : open_subgroup (G × H) :=\n{ carrier := (U : set G).prod (V : set H),\n  is_open' := U.is_open.prod V.is_open,\n  .. (U : subgroup G).prod (V : subgroup H) }\n\nend\n\n@[to_additive]\ninstance : partial_order (open_subgroup G) :=\n{ le := λ U V, ∀ ⦃x⦄, x ∈ U → x ∈ V,\n  .. partial_order.lift (coe : open_subgroup G → set G) coe_injective }\n\n@[to_additive]\ninstance : semilattice_inf_top (open_subgroup G) :=\n{ inf := λ U V, { is_open' := is_open_inter U.is_open V.is_open, .. (U : subgroup G) ⊓ V },\n  inf_le_left := λ U V, set.inter_subset_left _ _,\n  inf_le_right := λ U V, set.inter_subset_right _ _,\n  le_inf := λ U V W hV hW, set.subset_inter hV hW,\n  top := ⊤,\n  le_top := λ U, set.subset_univ _,\n  ..open_subgroup.partial_order }\n\n@[simp, to_additive] lemma coe_inf : (↑(U ⊓ V) : set G) = (U : set G) ∩ V := rfl\n\n@[simp, to_additive] lemma coe_subset : (U : set G) ⊆ V ↔ U ≤ V := iff.rfl\n\n@[simp, to_additive] lemma coe_subgroup_le : (U : subgroup G) ≤ (V : subgroup G) ↔ U ≤ V := iff.rfl\n\nattribute [norm_cast] coe_inf coe_subset coe_subgroup_le open_add_subgroup.coe_inf\n  open_add_subgroup.coe_subset open_add_subgroup.coe_add_subgroup_le\n\nvariables {N : Type*} [group N] [topological_space N]\n\n/-- The preimage of an `open_subgroup` along a continuous `monoid` homomorphism\n  is an `open_subgroup`. -/\n@[to_additive \"The preimage of an `open_add_subgroup` along a continuous `add_monoid` homomorphism\nis an `open_add_subgroup`.\"]\ndef comap (f : G →* N)\n  (hf : continuous f) (H : open_subgroup N) : open_subgroup G :=\n{ is_open' := H.is_open.preimage hf,\n  .. (H : subgroup N).comap f }\n\n@[simp, to_additive]\nlemma coe_comap (H : open_subgroup N) (f : G →* N) (hf : continuous f) :\n  (H.comap f hf : set G) = f ⁻¹' H := rfl\n\n@[simp, to_additive]\nlemma mem_comap {H : open_subgroup N} {f : G →* N} {hf : continuous f} {x : G} :\n  x ∈ H.comap f hf ↔ f x ∈ H := iff.rfl\n\n@[to_additive]\nlemma comap_comap {P : Type*} [group P] [topological_space P]\n  (K : open_subgroup P) (f₂ : N →* P) (hf₂ : continuous f₂) (f₁ : G →* N) (hf₁ : continuous f₁) :\n  (K.comap f₂ hf₂).comap f₁ hf₁ = K.comap (f₂.comp f₁) (hf₂.comp hf₁) :=\nrfl\n\nend open_subgroup\n\nnamespace subgroup\n\nvariables {G : Type*} [group G] [topological_space G] [has_continuous_mul G] (H : subgroup G)\n\n@[to_additive]\nlemma is_open_of_mem_nhds {g : G} (hg : (H : set G) ∈ 𝓝 g) :\n  is_open (H : set G) :=\nbegin\n  simp only [is_open_iff_mem_nhds, set_like.mem_coe] at hg ⊢,\n  intros x hx,\n  have : filter.tendsto (λ y, y * (x⁻¹ * g)) (𝓝 x) (𝓝 $ x * (x⁻¹ * g)) :=\n    (continuous_id.mul continuous_const).tendsto _,\n  rw [mul_inv_cancel_left] at this,\n  have := filter.mem_map.1 (this hg),\n  replace hg : g ∈ H := set_like.mem_coe.1 (mem_of_nhds hg),\n  simp only [set_like.mem_coe, H.mul_mem_cancel_right (H.mul_mem (H.inv_mem hx) hg)] at this,\n  exact this\nend\n\n@[to_additive]\nlemma is_open_of_open_subgroup {U : open_subgroup G} (h : U.1 ≤ H) :\n  is_open (H : set G) :=\nH.is_open_of_mem_nhds (filter.mem_sets_of_superset U.mem_nhds_one h)\n\n@[to_additive]\n\n\nend subgroup\n\nnamespace open_subgroup\n\nvariables {G : Type*} [group G] [topological_space G] [has_continuous_mul G]\n\n@[to_additive]\ninstance : semilattice_sup_top (open_subgroup G) :=\n{ sup := λ U V,\n  { is_open' := show is_open (((U : subgroup G) ⊔ V : subgroup G) : set G),\n    from subgroup.is_open_mono le_sup_left U.is_open,\n    .. ((U : subgroup G) ⊔ V) },\n  le_sup_left := λ U V, coe_subgroup_le.1 le_sup_left,\n  le_sup_right := λ U V, coe_subgroup_le.1 le_sup_right,\n  sup_le := λ U V W hU hV, coe_subgroup_le.1 (sup_le hU hV),\n  ..open_subgroup.semilattice_inf_top }\n\nend open_subgroup\n\nnamespace submodule\nopen open_add_subgroup\nvariables {R : Type*} {M : Type*} [comm_ring R]\nvariables [add_comm_group M] [topological_space M] [topological_add_group M] [module R M]\n\nlemma is_open_mono {U P : submodule R M} (h : U ≤ P) (hU : is_open (U : set M)) :\n  is_open (P : set M) :=\n@add_subgroup.is_open_mono M _ _ _ U.to_add_subgroup P.to_add_subgroup h hU\n\nend submodule\n\nnamespace ideal\nvariables {R : Type*} [comm_ring R]\nvariables [topological_space R] [topological_ring R]\n\nlemma is_open_of_open_subideal {U I : ideal R} (h : U ≤ I) (hU : is_open (U : set R)) :\n  is_open (I : set R) :=\nsubmodule.is_open_mono h hU\n\nend ideal\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/algebra/open_subgroup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.48199999999785753}}
{"text": "/-\nCopyright (c) 2020 Kenji Nakagawa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio\n\n! This file was ported from Lean 3 source module ring_theory.dedekind_domain.dvr\n! leanprover-community/mathlib commit 926daa81fd8acb2a04e15572c4ff20af2753c2ae\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.RingTheory.DedekindDomain.Ideal\nimport Mathbin.RingTheory.DiscreteValuationRing\nimport Mathbin.RingTheory.Localization.AtPrime\nimport Mathbin.RingTheory.Localization.Submodule\nimport Mathbin.RingTheory.Valuation.Tfae\n\n/-!\n# Dedekind domains\n\nThis file defines an equivalent notion of a Dedekind domain (or Dedekind ring),\nnamely a Noetherian integral domain where the localization at all nonzero prime ideals is a DVR\n(TODO: and shows that implies the main definition).\n\n## Main definitions\n\n - `is_dedekind_domain_dvr` alternatively defines a Dedekind domain as an integral domain that\n   is Noetherian, and the localization at every nonzero prime ideal is a DVR.\n\n## Main results\n - `is_localization.at_prime.discrete_valuation_ring_of_dedekind_domain` shows that\n   `is_dedekind_domain` implies the localization at each nonzero prime ideal is a DVR.\n - `is_dedekind_domain.is_dedekind_domain_dvr` is one direction of the equivalence of definitions\n   of a Dedekind domain\n\n## Implementation notes\n\nThe definitions that involve a field of fractions choose a canonical field of fractions,\nbut are independent of that choice. The `..._iff` lemmas express this independence.\n\nOften, definitions assume that Dedekind domains are not fields. We found it more practical\nto add a `(h : ¬ is_field A)` assumption whenever this is explicitly needed.\n\n## References\n\n* [D. Marcus, *Number Fields*][marcus1977number]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]\n\n## Tags\n\ndedekind domain, dedekind ring\n-/\n\n\nvariable (R A K : Type _) [CommRing R] [CommRing A] [IsDomain A] [Field K]\n\nopen nonZeroDivisors Polynomial\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (P «expr ≠ » («expr⊥»() : ideal[ideal] A)) -/\n/-- A Dedekind domain is an integral domain that is Noetherian, and the\nlocalization at every nonzero prime is a discrete valuation ring.\n\nThis is equivalent to `is_dedekind_domain`.\nTODO: prove the equivalence.\n-/\nstructure IsDedekindDomainDvr : Prop where\n  IsNoetherianRing : IsNoetherianRing A\n  is_dvr_at_nonzero_prime :\n    ∀ (P) (_ : P ≠ (⊥ : Ideal A)), P.IsPrime → DiscreteValuationRing (Localization.AtPrime P)\n#align is_dedekind_domain_dvr IsDedekindDomainDvr\n\n/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.\n\nNote that the same proof can/should be generalized to preserving any Krull dimension,\nonce we have a suitable definition.\n-/\ntheorem Ring.DimensionLeOne.localization {R : Type _} (Rₘ : Type _) [CommRing R] [IsDomain R]\n    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)\n    (h : Ring.DimensionLeOne R) : Ring.DimensionLeOne Rₘ :=\n  by\n  intro p hp0 hpp\n  refine' ideal.is_maximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩\n  have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.is_prime⟩ := hpP\n  rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP'\n  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p) :=\n    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨p, hpp⟩).2.1\n  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P) :=\n    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨P, hPm.is_prime⟩).2.1\n  have hlt : Ideal.comap (algebraMap R Rₘ) p < Ideal.comap (algebraMap R Rₘ) P := hpP'\n  refine' h.not_lt_lt ⊥ (Ideal.comap _ _) (Ideal.comap _ _) ⟨_, hpP'⟩\n  exact IsLocalization.bot_lt_comap_prime _ _ hM _ hp0\n#align ring.dimension_le_one.localization Ring.DimensionLeOne.localization\n\n/-- The localization of a Dedekind domain is a Dedekind domain. -/\ntheorem IsLocalization.isDedekindDomain [IsDedekindDomain A] {M : Submonoid A} (hM : M ≤ A⁰)\n    (Aₘ : Type _) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization M Aₘ] :\n    IsDedekindDomain Aₘ :=\n  by\n  have : ∀ y : M, IsUnit (algebraMap A (FractionRing A) y) :=\n    by\n    rintro ⟨y, hy⟩\n    exact IsUnit.mk0 _ (mt is_fraction_ring.to_map_eq_zero_iff.mp (nonZeroDivisors.ne_zero (hM hy)))\n  letI : Algebra Aₘ (FractionRing A) := RingHom.toAlgebra (IsLocalization.lift this)\n  haveI : IsScalarTower A Aₘ (FractionRing A) :=\n    IsScalarTower.of_algebraMap_eq fun x => (IsLocalization.lift_eq this x).symm\n  haveI : IsFractionRing Aₘ (FractionRing A) :=\n    IsFractionRing.isFractionRing_of_isDomain_of_isLocalization M _ _\n  refine' (isDedekindDomain_iff _ (FractionRing A)).mpr ⟨_, _, _⟩\n  · exact IsLocalization.isNoetherianRing M _ (by infer_instance)\n  · exact is_dedekind_domain.dimension_le_one.localization Aₘ hM\n  · intro x hx\n    obtain ⟨⟨y, y_mem⟩, hy⟩ := hx.exists_multiple_integral_of_is_localization M _\n    obtain ⟨z, hz⟩ := (isIntegrallyClosed_iff _).mp IsDedekindDomain.isIntegrallyClosed hy\n    refine' ⟨IsLocalization.mk' Aₘ z ⟨y, y_mem⟩, (IsLocalization.lift_mk'_spec _ _ _ _).mpr _⟩\n    rw [hz, [anonymous], ← Algebra.smul_def]\n    rfl\n#align is_localization.is_dedekind_domain IsLocalization.isDedekindDomain\n\n/-- The localization of a Dedekind domain at every nonzero prime ideal is a Dedekind domain. -/\ntheorem IsLocalization.AtPrime.isDedekindDomain [IsDedekindDomain A] (P : Ideal A) [P.IsPrime]\n    (Aₘ : Type _) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] :\n    IsDedekindDomain Aₘ :=\n  IsLocalization.isDedekindDomain A P.primeCompl_le_nonZeroDivisors Aₘ\n#align is_localization.at_prime.is_dedekind_domain IsLocalization.AtPrime.isDedekindDomain\n\ntheorem IsLocalization.AtPrime.not_isField {P : Ideal A} (hP : P ≠ ⊥) [pP : P.IsPrime] (Aₘ : Type _)\n    [CommRing Aₘ] [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] : ¬IsField Aₘ :=\n  by\n  intro h\n  letI := h.to_field\n  obtain ⟨x, x_mem, x_ne⟩ := P.ne_bot_iff.mp hP\n  exact\n    (LocalRing.maximalIdeal.isMaximal _).ne_top\n      (Ideal.eq_top_of_isUnit_mem _\n        ((IsLocalization.AtPrime.to_map_mem_maximal_iff Aₘ P _).mpr x_mem)\n        (is_unit_iff_ne_zero.mpr\n          ((map_ne_zero_iff (algebraMap A Aₘ)\n                (IsLocalization.injective Aₘ P.prime_compl_le_non_zero_divisors)).mpr\n            x_ne)))\n#align is_localization.at_prime.not_is_field IsLocalization.AtPrime.not_isField\n\n/-- In a Dedekind domain, the localization at every nonzero prime ideal is a DVR. -/\ntheorem IsLocalization.AtPrime.discreteValuationRing_of_dedekind_domain [IsDedekindDomain A]\n    {P : Ideal A} (hP : P ≠ ⊥) [pP : P.IsPrime] (Aₘ : Type _) [CommRing Aₘ] [IsDomain Aₘ]\n    [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] : DiscreteValuationRing Aₘ := by\n  classical\n    letI : IsNoetherianRing Aₘ :=\n      IsLocalization.isNoetherianRing P.prime_compl _ IsDedekindDomain.isNoetherianRing\n    letI : LocalRing Aₘ := IsLocalization.AtPrime.localRing Aₘ P\n    have hnf := IsLocalization.AtPrime.not_isField A hP Aₘ\n    exact\n      ((DiscreteValuationRing.tFAE Aₘ hnf).out 0 2).mpr\n        (IsLocalization.AtPrime.isDedekindDomain A P _)\n#align is_localization.at_prime.discrete_valuation_ring_of_dedekind_domain IsLocalization.AtPrime.discreteValuationRing_of_dedekind_domain\n\n/-- Dedekind domains, in the sense of Noetherian integrally closed domains of Krull dimension ≤ 1,\nare also Dedekind domains in the sense of Noetherian domains where the localization at every\nnonzero prime ideal is a DVR. -/\ntheorem IsDedekindDomain.isDedekindDomainDvr [IsDedekindDomain A] : IsDedekindDomainDvr A :=\n  { IsNoetherianRing := IsDedekindDomain.isNoetherianRing\n    is_dvr_at_nonzero_prime := fun P hP pP =>\n      IsLocalization.AtPrime.discreteValuationRing_of_dedekind_domain A hP _ }\n#align is_dedekind_domain.is_dedekind_domain_dvr IsDedekindDomain.isDedekindDomainDvr\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/DedekindDomain/Dvr.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4819999999978575}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro, Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Kevin Buzzard\n\n! This file was ported from Lean 3 source module ring_theory.noetherian\n! leanprover-community/mathlib commit aa3a420527e0fbfd0f6615b95b761254a9166e12\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Subalgebra.Basic\nimport Mathbin.Algebra.Algebra.Tower\nimport Mathbin.Algebra.Ring.Idempotents\nimport Mathbin.GroupTheory.Finiteness\nimport Mathbin.LinearAlgebra.LinearIndependent\nimport Mathbin.Order.CompactlyGenerated\nimport Mathbin.Order.OrderIsoNat\nimport Mathbin.RingTheory.Finiteness\nimport Mathbin.RingTheory.Nilpotent\n\n/-!\n# Noetherian rings and modules\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe following are equivalent for a module M over a ring R:\n1. Every increasing chain of submodules M₁ ⊆ M₂ ⊆ M₃ ⊆ ⋯ eventually stabilises.\n2. Every submodule is finitely generated.\n\nA module satisfying these equivalent conditions is said to be a *Noetherian* R-module.\nA ring is a *Noetherian ring* if it is Noetherian as a module over itself.\n\n(Note that we do not assume yet that our rings are commutative,\nso perhaps this should be called \"left Noetherian\".\nTo avoid cumbersome names once we specialize to the commutative case,\nwe don't make this explicit in the declaration names.)\n\n## Main definitions\n\nLet `R` be a ring and let `M` and `P` be `R`-modules. Let `N` be an `R`-submodule of `M`.\n\n* `is_noetherian R M` is the proposition that `M` is a Noetherian `R`-module. It is a class,\n  implemented as the predicate that all `R`-submodules of `M` are finitely generated.\n\n## Main statements\n\n* `is_noetherian_iff_well_founded` is the theorem that an R-module M is Noetherian iff\n  `>` is well-founded on `submodule R M`.\n\nNote that the Hilbert basis theorem, that if a commutative ring R is Noetherian then so is R[X],\nis proved in `ring_theory.polynomial`.\n\n## References\n\n* [M. F. Atiyah and I. G. Macdonald, *Introduction to commutative algebra*][atiyah-macdonald]\n* [samuel1967]\n\n## Tags\n\nNoetherian, noetherian, Noetherian ring, Noetherian module, noetherian ring, noetherian module\n\n-/\n\n\nopen Set\n\nopen BigOperators Pointwise\n\n#print IsNoetherian /-\n/-- `is_noetherian R M` is the proposition that `M` is a Noetherian `R`-module,\nimplemented as the predicate that all `R`-submodules of `M` are finitely generated.\n-/\nclass IsNoetherian (R M) [Semiring R] [AddCommMonoid M] [Module R M] : Prop where\n  noetherian : ∀ s : Submodule R M, s.Fg\n#align is_noetherian IsNoetherian\n-/\n\nsection\n\nvariable {R : Type _} {M : Type _} {P : Type _}\n\nvariable [Semiring R] [AddCommMonoid M] [AddCommMonoid P]\n\nvariable [Module R M] [Module R P]\n\nopen IsNoetherian\n\ninclude R\n\n/- warning: is_noetherian_def -> isNoetherian_def is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2], Iff (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_4) (forall (s : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4), Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_4 s)\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_4 : Module.{u2, u1} R M _inst_1 _inst_2], Iff (IsNoetherian.{u2, u1} R M _inst_1 _inst_2 _inst_4) (forall (s : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4), Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_4 s)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_def isNoetherian_defₓ'. -/\n/-- An R-module is Noetherian iff all its submodules are finitely-generated. -/\ntheorem isNoetherian_def : IsNoetherian R M ↔ ∀ s : Submodule R M, s.Fg :=\n  ⟨fun h => h.noetherian, IsNoetherian.mk⟩\n#align is_noetherian_def isNoetherian_def\n\n/- warning: is_noetherian_submodule -> isNoetherian_submodule is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] {N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4}, Iff (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u1, u2} R M _inst_1 _inst_2 _inst_4)) N) _inst_1 (Submodule.addCommMonoid.{u1, u2} R M _inst_1 _inst_2 _inst_4 N) (Submodule.module.{u1, u2} R M _inst_1 _inst_2 _inst_4 N)) (forall (s : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4), (LE.le.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Preorder.toLE.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Submodule.completeLattice.{u1, u2} R M _inst_1 _inst_2 _inst_4))))) s N) -> (Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_4 s))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_4 : Module.{u2, u1} R M _inst_1 _inst_2] {N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4}, Iff (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u2, u1} R M _inst_1 _inst_2 _inst_4)) x N)) _inst_1 (Submodule.addCommMonoid.{u2, u1} R M _inst_1 _inst_2 _inst_4 N) (Submodule.module.{u2, u1} R M _inst_1 _inst_2 _inst_4 N)) (forall (s : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4), (LE.le.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Preorder.toLE.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (PartialOrder.toPreorder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Submodule.completeLattice.{u2, u1} R M _inst_1 _inst_2 _inst_4))))) s N) -> (Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_4 s))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_submodule isNoetherian_submoduleₓ'. -/\ntheorem isNoetherian_submodule {N : Submodule R M} :\n    IsNoetherian R N ↔ ∀ s : Submodule R M, s ≤ N → s.Fg :=\n  by\n  refine'\n    ⟨fun ⟨hn⟩ => fun s hs =>\n      have : s ≤ N.subtype.range := N.range_subtype.symm ▸ hs\n      Submodule.map_comap_eq_self this ▸ (hn _).map _,\n      fun h => ⟨fun s => _⟩⟩\n  have f := (Submodule.equivMapOfInjective N.subtype Subtype.val_injective s).symm\n  have h₁ := h (s.map N.subtype) (Submodule.map_subtype_le N s)\n  have h₂ : (⊤ : Submodule R (s.map N.subtype)).map f = ⊤ := by simp\n  have h₃ := ((Submodule.fg_top _).2 h₁).map (↑f : _ →ₗ[R] s)\n  exact (Submodule.fg_top _).1 (h₂ ▸ h₃)\n#align is_noetherian_submodule isNoetherian_submodule\n\n/- warning: is_noetherian_submodule_left -> isNoetherian_submodule_left is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] {N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4}, Iff (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u1, u2} R M _inst_1 _inst_2 _inst_4)) N) _inst_1 (Submodule.addCommMonoid.{u1, u2} R M _inst_1 _inst_2 _inst_4 N) (Submodule.module.{u1, u2} R M _inst_1 _inst_2 _inst_4 N)) (forall (s : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4), Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_4 (Inf.inf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Submodule.hasInf.{u1, u2} R M _inst_1 _inst_2 _inst_4) N s))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_4 : Module.{u2, u1} R M _inst_1 _inst_2] {N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4}, Iff (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u2, u1} R M _inst_1 _inst_2 _inst_4)) x N)) _inst_1 (Submodule.addCommMonoid.{u2, u1} R M _inst_1 _inst_2 _inst_4 N) (Submodule.module.{u2, u1} R M _inst_1 _inst_2 _inst_4 N)) (forall (s : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4), Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_4 (Inf.inf.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Submodule.instInfSubmodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) N s))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_submodule_left isNoetherian_submodule_leftₓ'. -/\ntheorem isNoetherian_submodule_left {N : Submodule R M} :\n    IsNoetherian R N ↔ ∀ s : Submodule R M, (N ⊓ s).Fg :=\n  isNoetherian_submodule.trans ⟨fun H s => H _ inf_le_left, fun H s hs => inf_of_le_right hs ▸ H _⟩\n#align is_noetherian_submodule_left isNoetherian_submodule_left\n\n/- warning: is_noetherian_submodule_right -> isNoetherian_submodule_right is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] {N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4}, Iff (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u1, u2} R M _inst_1 _inst_2 _inst_4)) N) _inst_1 (Submodule.addCommMonoid.{u1, u2} R M _inst_1 _inst_2 _inst_4 N) (Submodule.module.{u1, u2} R M _inst_1 _inst_2 _inst_4 N)) (forall (s : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4), Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_4 (Inf.inf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Submodule.hasInf.{u1, u2} R M _inst_1 _inst_2 _inst_4) s N))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_4 : Module.{u2, u1} R M _inst_1 _inst_2] {N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4}, Iff (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u2, u1} R M _inst_1 _inst_2 _inst_4)) x N)) _inst_1 (Submodule.addCommMonoid.{u2, u1} R M _inst_1 _inst_2 _inst_4 N) (Submodule.module.{u2, u1} R M _inst_1 _inst_2 _inst_4 N)) (forall (s : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4), Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_4 (Inf.inf.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Submodule.instInfSubmodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) s N))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_submodule_right isNoetherian_submodule_rightₓ'. -/\ntheorem isNoetherian_submodule_right {N : Submodule R M} :\n    IsNoetherian R N ↔ ∀ s : Submodule R M, (s ⊓ N).Fg :=\n  isNoetherian_submodule.trans ⟨fun H s => H _ inf_le_right, fun H s hs => inf_of_le_left hs ▸ H _⟩\n#align is_noetherian_submodule_right isNoetherian_submodule_right\n\n#print isNoetherian_submodule' /-\ninstance isNoetherian_submodule' [IsNoetherian R M] (N : Submodule R M) : IsNoetherian R N :=\n  isNoetherian_submodule.2 fun _ _ => IsNoetherian.noetherian _\n#align is_noetherian_submodule' isNoetherian_submodule'\n-/\n\n/- warning: is_noetherian_of_le -> isNoetherian_of_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] {s : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4} {t : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4} [ht : IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u1, u2} R M _inst_1 _inst_2 _inst_4)) t) _inst_1 (Submodule.addCommMonoid.{u1, u2} R M _inst_1 _inst_2 _inst_4 t) (Submodule.module.{u1, u2} R M _inst_1 _inst_2 _inst_4 t)], (LE.le.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Preorder.toLE.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Submodule.completeLattice.{u1, u2} R M _inst_1 _inst_2 _inst_4))))) s t) -> (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u1, u2} R M _inst_1 _inst_2 _inst_4)) s) _inst_1 (Submodule.addCommMonoid.{u1, u2} R M _inst_1 _inst_2 _inst_4 s) (Submodule.module.{u1, u2} R M _inst_1 _inst_2 _inst_4 s))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_4 : Module.{u2, u1} R M _inst_1 _inst_2] {s : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4} {t : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4} [ht : IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u2, u1} R M _inst_1 _inst_2 _inst_4)) x t)) _inst_1 (Submodule.addCommMonoid.{u2, u1} R M _inst_1 _inst_2 _inst_4 t) (Submodule.module.{u2, u1} R M _inst_1 _inst_2 _inst_4 t)], (LE.le.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Preorder.toLE.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (PartialOrder.toPreorder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Submodule.completeLattice.{u2, u1} R M _inst_1 _inst_2 _inst_4))))) s t) -> (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u2, u1} R M _inst_1 _inst_2 _inst_4)) x s)) _inst_1 (Submodule.addCommMonoid.{u2, u1} R M _inst_1 _inst_2 _inst_4 s) (Submodule.module.{u2, u1} R M _inst_1 _inst_2 _inst_4 s))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_le isNoetherian_of_leₓ'. -/\ntheorem isNoetherian_of_le {s t : Submodule R M} [ht : IsNoetherian R t] (h : s ≤ t) :\n    IsNoetherian R s :=\n  isNoetherian_submodule.mpr fun s' hs' => isNoetherian_submodule.mp ht _ (le_trans hs' h)\n#align is_noetherian_of_le isNoetherian_of_le\n\nvariable (M)\n\n/- warning: is_noetherian_of_surjective -> isNoetherian_of_surjective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} (M : Type.{u2}) {P : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : AddCommMonoid.{u3} P] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] [_inst_5 : Module.{u1, u3} R P _inst_1 _inst_3] (f : LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5), (Eq.{succ u3} (Submodule.{u1, u3} R P _inst_1 _inst_3 _inst_5) (LinearMap.range.{u1, u1, u2, u3, max u2 u3} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) (LinearMap.semilinearMapClass.{u1, u1, u2, u3} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (RingHomSurjective.ids.{u1} R _inst_1) f) (Top.top.{u3} (Submodule.{u1, u3} R P _inst_1 _inst_3 _inst_5) (Submodule.hasTop.{u1, u3} R P _inst_1 _inst_3 _inst_5))) -> (forall [_inst_6 : IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_4], IsNoetherian.{u1, u3} R P _inst_1 _inst_3 _inst_5)\nbut is expected to have type\n  forall {R : Type.{u3}} (M : Type.{u2}) {P : Type.{u1}} [_inst_1 : Semiring.{u3} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : AddCommMonoid.{u1} P] [_inst_4 : Module.{u3, u2} R M _inst_1 _inst_2] [_inst_5 : Module.{u3, u1} R P _inst_1 _inst_3] (f : LinearMap.{u3, u3, u2, u1} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5), (Eq.{succ u1} (Submodule.{u3, u1} R P _inst_1 _inst_3 _inst_5) (LinearMap.range.{u3, u3, u2, u1, max u2 u1} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) (LinearMap.{u3, u3, u2, u1} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) (LinearMap.instSemilinearMapClassLinearMap.{u3, u3, u2, u1} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) (RingHomSurjective.ids.{u3} R _inst_1) f) (Top.top.{u1} (Submodule.{u3, u1} R P _inst_1 _inst_3 _inst_5) (Submodule.instTopSubmodule.{u3, u1} R P _inst_1 _inst_3 _inst_5))) -> (forall [_inst_6 : IsNoetherian.{u3, u2} R M _inst_1 _inst_2 _inst_4], IsNoetherian.{u3, u1} R P _inst_1 _inst_3 _inst_5)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_surjective isNoetherian_of_surjectiveₓ'. -/\ntheorem isNoetherian_of_surjective (f : M →ₗ[R] P) (hf : f.range = ⊤) [IsNoetherian R M] :\n    IsNoetherian R P :=\n  ⟨fun s =>\n    have : (s.comap f).map f = s := Submodule.map_comap_eq_self <| hf.symm ▸ le_top\n    this ▸ (noetherian _).map _⟩\n#align is_noetherian_of_surjective isNoetherian_of_surjective\n\nvariable {M}\n\n/- warning: is_noetherian_of_linear_equiv -> isNoetherian_of_linearEquiv is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} {P : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : AddCommMonoid.{u3} P] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] [_inst_5 : Module.{u1, u3} R P _inst_1 _inst_3], (LinearEquiv.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) M P _inst_2 _inst_3 _inst_4 _inst_5) -> (forall [_inst_6 : IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_4], IsNoetherian.{u1, u3} R P _inst_1 _inst_3 _inst_5)\nbut is expected to have type\n  forall {R : Type.{u3}} {M : Type.{u2}} {P : Type.{u1}} [_inst_1 : Semiring.{u3} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : AddCommMonoid.{u1} P] [_inst_4 : Module.{u3, u2} R M _inst_1 _inst_2] [_inst_5 : Module.{u3, u1} R P _inst_1 _inst_3], (LinearEquiv.{u3, u3, u2, u1} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) (RingHomInvPair.ids.{u3} R _inst_1) (RingHomInvPair.ids.{u3} R _inst_1) M P _inst_2 _inst_3 _inst_4 _inst_5) -> (forall [_inst_6 : IsNoetherian.{u3, u2} R M _inst_1 _inst_2 _inst_4], IsNoetherian.{u3, u1} R P _inst_1 _inst_3 _inst_5)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_linear_equiv isNoetherian_of_linearEquivₓ'. -/\ntheorem isNoetherian_of_linearEquiv (f : M ≃ₗ[R] P) [IsNoetherian R M] : IsNoetherian R P :=\n  isNoetherian_of_surjective _ f.toLinearMap f.range\n#align is_noetherian_of_linear_equiv isNoetherian_of_linearEquiv\n\n/- warning: is_noetherian_top_iff -> isNoetherian_top_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2], Iff (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u1, u2} R M _inst_1 _inst_2 _inst_4)) (Top.top.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Submodule.hasTop.{u1, u2} R M _inst_1 _inst_2 _inst_4))) _inst_1 (Submodule.addCommMonoid.{u1, u2} R M _inst_1 _inst_2 _inst_4 (Top.top.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Submodule.hasTop.{u1, u2} R M _inst_1 _inst_2 _inst_4))) (Submodule.module.{u1, u2} R M _inst_1 _inst_2 _inst_4 (Top.top.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4) (Submodule.hasTop.{u1, u2} R M _inst_1 _inst_2 _inst_4)))) (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_4)\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_4 : Module.{u2, u1} R M _inst_1 _inst_2], Iff (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) M (Submodule.setLike.{u2, u1} R M _inst_1 _inst_2 _inst_4)) x (Top.top.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Submodule.instTopSubmodule.{u2, u1} R M _inst_1 _inst_2 _inst_4)))) _inst_1 (Submodule.addCommMonoid.{u2, u1} R M _inst_1 _inst_2 _inst_4 (Top.top.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Submodule.instTopSubmodule.{u2, u1} R M _inst_1 _inst_2 _inst_4))) (Submodule.module.{u2, u1} R M _inst_1 _inst_2 _inst_4 (Top.top.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_4) (Submodule.instTopSubmodule.{u2, u1} R M _inst_1 _inst_2 _inst_4)))) (IsNoetherian.{u2, u1} R M _inst_1 _inst_2 _inst_4)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_top_iff isNoetherian_top_iffₓ'. -/\ntheorem isNoetherian_top_iff : IsNoetherian R (⊤ : Submodule R M) ↔ IsNoetherian R M :=\n  by\n  constructor <;> intro h\n  · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl)\n  · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl).symm\n#align is_noetherian_top_iff isNoetherian_top_iff\n\n/- warning: is_noetherian_of_injective -> isNoetherian_of_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} {P : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : AddCommMonoid.{u3} P] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] [_inst_5 : Module.{u1, u3} R P _inst_1 _inst_3] [_inst_6 : IsNoetherian.{u1, u3} R P _inst_1 _inst_3 _inst_5] (f : LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5), (Function.Injective.{succ u2, succ u3} M P (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) (fun (_x : LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) => M -> P) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) f)) -> (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_4)\nbut is expected to have type\n  forall {R : Type.{u3}} {M : Type.{u1}} {P : Type.{u2}} [_inst_1 : Semiring.{u3} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : AddCommMonoid.{u2} P] [_inst_4 : Module.{u3, u1} R M _inst_1 _inst_2] [_inst_5 : Module.{u3, u2} R P _inst_1 _inst_3] [_inst_6 : IsNoetherian.{u3, u2} R P _inst_1 _inst_3 _inst_5] (f : LinearMap.{u3, u3, u1, u2} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5), (Function.Injective.{succ u1, succ u2} M P (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (LinearMap.{u3, u3, u1, u2} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, u1, u2} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) f)) -> (IsNoetherian.{u3, u1} R M _inst_1 _inst_2 _inst_4)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_injective isNoetherian_of_injectiveₓ'. -/\ntheorem isNoetherian_of_injective [IsNoetherian R P] (f : M →ₗ[R] P) (hf : Function.Injective f) :\n    IsNoetherian R M :=\n  isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f hf).symm\n#align is_noetherian_of_injective isNoetherian_of_injective\n\n/- warning: fg_of_injective -> fg_of_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} {P : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : AddCommMonoid.{u3} P] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] [_inst_5 : Module.{u1, u3} R P _inst_1 _inst_3] [_inst_6 : IsNoetherian.{u1, u3} R P _inst_1 _inst_3 _inst_5] {N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_4} (f : LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5), (Function.Injective.{succ u2, succ u3} M P (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) (fun (_x : LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) => M -> P) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) f)) -> (Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_4 N)\nbut is expected to have type\n  forall {R : Type.{u3}} {M : Type.{u1}} {P : Type.{u2}} [_inst_1 : Semiring.{u3} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : AddCommMonoid.{u2} P] [_inst_4 : Module.{u3, u1} R M _inst_1 _inst_2] [_inst_5 : Module.{u3, u2} R P _inst_1 _inst_3] [_inst_6 : IsNoetherian.{u3, u2} R P _inst_1 _inst_3 _inst_5] {N : Submodule.{u3, u1} R M _inst_1 _inst_2 _inst_4} (f : LinearMap.{u3, u3, u1, u2} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5), (Function.Injective.{succ u1, succ u2} M P (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (LinearMap.{u3, u3, u1, u2} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M P _inst_2 _inst_3 _inst_4 _inst_5) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, u1, u2} R R M P _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) f)) -> (Submodule.Fg.{u3, u1} R M _inst_1 _inst_2 _inst_4 N)\nCase conversion may be inaccurate. Consider using '#align fg_of_injective fg_of_injectiveₓ'. -/\ntheorem fg_of_injective [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P)\n    (hf : Function.Injective f) : N.Fg :=\n  @IsNoetherian.noetherian _ _ _ (isNoetherian_of_injective f hf) N\n#align fg_of_injective fg_of_injective\n\nend\n\nnamespace Module\n\nvariable {R M N : Type _}\n\nvariable [Semiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N]\n\nvariable (R M)\n\n#print Module.IsNoetherian.finite /-\n-- see Note [lower instance priority]\ninstance (priority := 100) IsNoetherian.finite [IsNoetherian R M] : Finite R M :=\n  ⟨IsNoetherian.noetherian ⊤⟩\n#align module.is_noetherian.finite Module.IsNoetherian.finite\n-/\n\nvariable {R M}\n\n/- warning: module.finite.of_injective -> Module.Finite.of_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : AddCommMonoid.{u3} N] [_inst_4 : Module.{u1, u2} R M _inst_1 _inst_2] [_inst_5 : Module.{u1, u3} R N _inst_1 _inst_3] [_inst_6 : IsNoetherian.{u1, u3} R N _inst_1 _inst_3 _inst_5] (f : LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M N _inst_2 _inst_3 _inst_4 _inst_5), (Function.Injective.{succ u2, succ u3} M N (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M N _inst_2 _inst_3 _inst_4 _inst_5) (fun (_x : LinearMap.{u1, u1, u2, u3} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M N _inst_2 _inst_3 _inst_4 _inst_5) => M -> N) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R M N _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) f)) -> (Module.Finite.{u1, u2} R M _inst_1 _inst_2 _inst_4)\nbut is expected to have type\n  forall {R : Type.{u3}} {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : Semiring.{u3} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : AddCommMonoid.{u2} N] [_inst_4 : Module.{u3, u1} R M _inst_1 _inst_2] [_inst_5 : Module.{u3, u2} R N _inst_1 _inst_3] [_inst_6 : IsNoetherian.{u3, u2} R N _inst_1 _inst_3 _inst_5] (f : LinearMap.{u3, u3, u1, u2} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M N _inst_2 _inst_3 _inst_4 _inst_5), (Function.Injective.{succ u1, succ u2} M N (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (LinearMap.{u3, u3, u1, u2} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M N _inst_2 _inst_3 _inst_4 _inst_5) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => N) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, u1, u2} R R M N _inst_1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) f)) -> (Module.Finite.{u3, u1} R M _inst_1 _inst_2 _inst_4)\nCase conversion may be inaccurate. Consider using '#align module.finite.of_injective Module.Finite.of_injectiveₓ'. -/\ntheorem Finite.of_injective [IsNoetherian R N] (f : M →ₗ[R] N) (hf : Function.Injective f) :\n    Finite R M :=\n  ⟨fg_of_injective f hf⟩\n#align module.finite.of_injective Module.Finite.of_injective\n\nend Module\n\nsection\n\nvariable {R : Type _} {M : Type _} {P : Type _}\n\nvariable [Ring R] [AddCommGroup M] [AddCommGroup P]\n\nvariable [Module R M] [Module R P]\n\nopen IsNoetherian\n\ninclude R\n\n/- warning: is_noetherian_of_ker_bot -> isNoetherian_of_ker_bot is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} {P : Type.{u3}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : AddCommGroup.{u3} P] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_5 : Module.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3)] [_inst_6 : IsNoetherian.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_5] (f : LinearMap.{u1, u1, u2, u3} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5), (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4) (LinearMap.ker.{u1, u1, u2, u3, max u2 u3} R R M P (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5) (LinearMap.semilinearMapClass.{u1, u1, u2, u3} R R M P (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) f) (Bot.bot.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4) (Submodule.hasBot.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4))) -> (IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4)\nbut is expected to have type\n  forall {R : Type.{u3}} {M : Type.{u1}} {P : Type.{u2}} [_inst_1 : Ring.{u3} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : AddCommGroup.{u2} P] [_inst_4 : Module.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_5 : Module.{u3, u2} R P (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3)] [_inst_6 : IsNoetherian.{u3, u2} R P (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_5] (f : LinearMap.{u3, u3, u1, u2} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5), (Eq.{succ u1} (Submodule.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4) (LinearMap.ker.{u3, u3, u1, u2, max u1 u2} R R M P (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) (LinearMap.{u3, u3, u1, u2} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5) (LinearMap.instSemilinearMapClassLinearMap.{u3, u3, u1, u2} R R M P (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1)))) f) (Bot.bot.{u1} (Submodule.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4) (Submodule.instBotSubmodule.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4))) -> (IsNoetherian.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_ker_bot isNoetherian_of_ker_botₓ'. -/\ntheorem isNoetherian_of_ker_bot [IsNoetherian R P] (f : M →ₗ[R] P) (hf : f.ker = ⊥) :\n    IsNoetherian R M :=\n  isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f <| LinearMap.ker_eq_bot.mp hf).symm\n#align is_noetherian_of_ker_bot isNoetherian_of_ker_bot\n\n/- warning: fg_of_ker_bot -> fg_of_ker_bot is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} {P : Type.{u3}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : AddCommGroup.{u3} P] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_5 : Module.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3)] [_inst_6 : IsNoetherian.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_5] {N : Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4} (f : LinearMap.{u1, u1, u2, u3} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5), (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4) (LinearMap.ker.{u1, u1, u2, u3, max u2 u3} R R M P (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5) (LinearMap.semilinearMapClass.{u1, u1, u2, u3} R R M P (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) f) (Bot.bot.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4) (Submodule.hasBot.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4))) -> (Submodule.Fg.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4 N)\nbut is expected to have type\n  forall {R : Type.{u3}} {M : Type.{u1}} {P : Type.{u2}} [_inst_1 : Ring.{u3} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : AddCommGroup.{u2} P] [_inst_4 : Module.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_5 : Module.{u3, u2} R P (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3)] [_inst_6 : IsNoetherian.{u3, u2} R P (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_5] {N : Submodule.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4} (f : LinearMap.{u3, u3, u1, u2} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5), (Eq.{succ u1} (Submodule.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4) (LinearMap.ker.{u3, u3, u1, u2, max u1 u2} R R M P (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) (LinearMap.{u3, u3, u1, u2} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) M P (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5) (LinearMap.instSemilinearMapClassLinearMap.{u3, u3, u1, u2} R R M P (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} P _inst_3) _inst_4 _inst_5 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1)))) f) (Bot.bot.{u1} (Submodule.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4) (Submodule.instBotSubmodule.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4))) -> (Submodule.Fg.{u3, u1} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_4 N)\nCase conversion may be inaccurate. Consider using '#align fg_of_ker_bot fg_of_ker_botₓ'. -/\ntheorem fg_of_ker_bot [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P) (hf : f.ker = ⊥) :\n    N.Fg :=\n  @IsNoetherian.noetherian _ _ _ (isNoetherian_of_ker_bot f hf) N\n#align fg_of_ker_bot fg_of_ker_bot\n\n/- warning: is_noetherian_prod -> isNoetherian_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} {P : Type.{u3}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : AddCommGroup.{u3} P] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_5 : Module.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3)] [_inst_6 : IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4] [_inst_7 : IsNoetherian.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_5], IsNoetherian.{u1, max u2 u3} R (Prod.{u2, u3} M P) (Ring.toSemiring.{u1} R _inst_1) (Prod.addCommMonoid.{u2, u3} M P (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3)) (Prod.module.{u1, u2, u3} R M P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5)\nbut is expected to have type\n  forall {R : Type.{u1}} {M : Type.{u2}} {P : Type.{u3}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : AddCommGroup.{u3} P] [_inst_4 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_5 : Module.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3)] [_inst_6 : IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_4] [_inst_7 : IsNoetherian.{u1, u3} R P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_5], IsNoetherian.{u1, max u3 u2} R (Prod.{u2, u3} M P) (Ring.toSemiring.{u1} R _inst_1) (Prod.instAddCommMonoidSum.{u2, u3} M P (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3)) (Prod.module.{u1, u2, u3} R M P (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u3} P _inst_3) _inst_4 _inst_5)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_prod isNoetherian_prodₓ'. -/\ninstance isNoetherian_prod [IsNoetherian R M] [IsNoetherian R P] : IsNoetherian R (M × P) :=\n  ⟨fun s =>\n    Submodule.fg_of_fg_map_of_fg_inf_ker (LinearMap.snd R M P) (noetherian _) <|\n      have : s ⊓ LinearMap.ker (LinearMap.snd R M P) ≤ LinearMap.range (LinearMap.inl R M P) :=\n        fun x ⟨hx1, hx2⟩ => ⟨x.1, Prod.ext rfl <| Eq.symm <| LinearMap.mem_ker.1 hx2⟩\n      Submodule.map_comap_eq_self this ▸ (noetherian _).map _⟩\n#align is_noetherian_prod isNoetherian_prod\n\n#print isNoetherian_pi /-\ninstance isNoetherian_pi {R ι : Type _} {M : ι → Type _} [Ring R] [∀ i, AddCommGroup (M i)]\n    [∀ i, Module R (M i)] [Finite ι] [∀ i, IsNoetherian R (M i)] : IsNoetherian R (∀ i, M i) :=\n  by\n  cases nonempty_fintype ι\n  haveI := Classical.decEq ι\n  suffices on_finset : ∀ s : Finset ι, IsNoetherian R (∀ i : s, M i)\n  · let coe_e := Equiv.subtypeUnivEquiv Finset.mem_univ\n    letI : IsNoetherian R (∀ i : Finset.univ, M (coe_e i)) := on_finset Finset.univ\n    exact isNoetherian_of_linearEquiv (LinearEquiv.piCongrLeft R M coe_e)\n  intro s\n  induction' s using Finset.induction with a s has ih\n  · exact ⟨fun s => by convert Submodule.fg_bot⟩\n  refine'\n    @isNoetherian_of_linearEquiv _ _ _ _ _ _ _ _ _ (@isNoetherian_prod _ (M a) _ _ _ _ _ _ _ ih)\n  fconstructor\n  ·\n    exact fun f i =>\n      Or.by_cases (Finset.mem_insert.1 i.2) (fun h : i.1 = a => show M i.1 from Eq.recOn h.symm f.1)\n        fun h : i.1 ∈ s => show M i.1 from f.2 ⟨i.1, h⟩\n  · intro f g\n    ext i\n    unfold Or.by_cases\n    cases' i with i hi\n    rcases Finset.mem_insert.1 hi with (rfl | h)\n    · change _ = _ + _\n      simp only [dif_pos]\n      rfl\n    · change _ = _ + _\n      have : ¬i = a := by\n        rintro rfl\n        exact has h\n      simp only [dif_neg this, dif_pos h]\n      rfl\n  · intro c f\n    ext i\n    unfold Or.by_cases\n    cases' i with i hi\n    rcases Finset.mem_insert.1 hi with (rfl | h)\n    · change _ = c • _\n      simp only [dif_pos]\n      rfl\n    · change _ = c • _\n      have : ¬i = a := by\n        rintro rfl\n        exact has h\n      simp only [dif_neg this, dif_pos h]\n      rfl\n  ·\n    exact fun f =>\n      (f ⟨a, Finset.mem_insert_self _ _⟩, fun i => f ⟨i.1, Finset.mem_insert_of_mem i.2⟩)\n  · intro f\n    apply Prod.ext\n    · simp only [Or.by_cases, dif_pos]\n    · ext ⟨i, his⟩\n      have : ¬i = a := by\n        rintro rfl\n        exact has his\n      simp only [Or.by_cases, this, not_false_iff, dif_neg]\n  · intro f\n    ext ⟨i, hi⟩\n    rcases Finset.mem_insert.1 hi with (rfl | h)\n    · simp only [Or.by_cases, dif_pos]\n    · have : ¬i = a := by\n        rintro rfl\n        exact has h\n      simp only [Or.by_cases, dif_neg this, dif_pos h]\n#align is_noetherian_pi isNoetherian_pi\n-/\n\n#print isNoetherian_pi' /-\n/-- A version of `is_noetherian_pi` for non-dependent functions. We need this instance because\nsometimes Lean fails to apply the dependent version in non-dependent settings (e.g., it fails to\nprove that `ι → ℝ` is finite dimensional over `ℝ`). -/\ninstance isNoetherian_pi' {R ι M : Type _} [Ring R] [AddCommGroup M] [Module R M] [Finite ι]\n    [IsNoetherian R M] : IsNoetherian R (ι → M) :=\n  isNoetherian_pi\n#align is_noetherian_pi' isNoetherian_pi'\n-/\n\nend\n\nopen IsNoetherian Submodule Function\n\nsection\n\nuniverse w\n\nvariable {R M P : Type _} {N : Type w} [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N]\n  [Module R N] [AddCommMonoid P] [Module R P]\n\n/- warning: is_noetherian_iff_well_founded -> isNoetherian_iff_wellFounded is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M _inst_1 _inst_2], Iff (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_3) (WellFounded.{succ u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (GT.gt.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Preorder.toLT.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u1, u2} R M _inst_1 _inst_2 _inst_3)))))))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : Module.{u2, u1} R M _inst_1 _inst_2], Iff (IsNoetherian.{u2, u1} R M _inst_1 _inst_2 _inst_3) (WellFounded.{succ u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (fun (x._@.Mathlib.RingTheory.Noetherian._hyg.2248 : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (x._@.Mathlib.RingTheory.Noetherian._hyg.2250 : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) => GT.gt.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (Preorder.toLT.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u2, u1} R M _inst_1 _inst_2 _inst_3))))) x._@.Mathlib.RingTheory.Noetherian._hyg.2248 x._@.Mathlib.RingTheory.Noetherian._hyg.2250))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_iff_well_founded isNoetherian_iff_wellFoundedₓ'. -/\ntheorem isNoetherian_iff_wellFounded :\n    IsNoetherian R M ↔ WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) :=\n  by\n  rw [(CompleteLattice.wellFounded_characterisations <| Submodule R M).out 0 3]\n  exact\n    ⟨fun ⟨h⟩ => fun k => (fg_iff_compact k).mp (h k), fun h =>\n      ⟨fun k => (fg_iff_compact k).mpr (h k)⟩⟩\n#align is_noetherian_iff_well_founded isNoetherian_iff_wellFounded\n\n/- warning: is_noetherian_iff_fg_well_founded -> isNoetherian_iff_fg_wellFounded is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M _inst_1 _inst_2], Iff (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_3) (WellFounded.{succ u2} (Subtype.{succ u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (fun (N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_3 N)) (GT.gt.{u2} (Subtype.{succ u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (fun (N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_3 N)) (Subtype.hasLt.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Preorder.toLT.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u1, u2} R M _inst_1 _inst_2 _inst_3))))) (fun (N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u1, u2} R M _inst_1 _inst_2 _inst_3 N))))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : Module.{u2, u1} R M _inst_1 _inst_2], Iff (IsNoetherian.{u2, u1} R M _inst_1 _inst_2 _inst_3) (WellFounded.{succ u1} (Subtype.{succ u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (fun (N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_3 N)) (fun (x._@.Mathlib.RingTheory.Noetherian._hyg.2457 : Subtype.{succ u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (fun (N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_3 N)) (x._@.Mathlib.RingTheory.Noetherian._hyg.2459 : Subtype.{succ u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (fun (N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_3 N)) => GT.gt.{u1} (Subtype.{succ u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (fun (N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_3 N)) (Subtype.lt.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (Preorder.toLT.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u2, u1} R M _inst_1 _inst_2 _inst_3))))) (fun (N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) => Submodule.Fg.{u2, u1} R M _inst_1 _inst_2 _inst_3 N)) x._@.Mathlib.RingTheory.Noetherian._hyg.2457 x._@.Mathlib.RingTheory.Noetherian._hyg.2459))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_iff_fg_well_founded isNoetherian_iff_fg_wellFoundedₓ'. -/\ntheorem isNoetherian_iff_fg_wellFounded :\n    IsNoetherian R M ↔\n      WellFounded\n        ((· > ·) : { N : Submodule R M // N.Fg } → { N : Submodule R M // N.Fg } → Prop) :=\n  by\n  let α := { N : Submodule R M // N.Fg }\n  constructor\n  · intro H\n    let f : α ↪o Submodule R M := OrderEmbedding.subtype _\n    exact OrderEmbedding.wellFounded f.dual (is_noetherian_iff_well_founded.mp H)\n  · intro H\n    constructor\n    intro N\n    obtain ⟨⟨N₀, h₁⟩, e : N₀ ≤ N, h₂⟩ :=\n      well_founded.well_founded_iff_has_max'.mp H { N' : α | N'.1 ≤ N }\n        ⟨⟨⊥, Submodule.fg_bot⟩, bot_le⟩\n    convert h₁\n    refine' (e.antisymm _).symm\n    by_contra h₃\n    obtain ⟨x, hx₁ : x ∈ N, hx₂ : x ∉ N₀⟩ := set.not_subset.mp h₃\n    apply hx₂\n    have := h₂ ⟨(R ∙ x) ⊔ N₀, _⟩ _ _\n    · injection this with eq\n      rw [← Eq]\n      exact (le_sup_left : (R ∙ x) ≤ (R ∙ x) ⊔ N₀) (Submodule.mem_span_singleton_self _)\n    · exact Submodule.Fg.sup ⟨{x}, by rw [Finset.coe_singleton]⟩ h₁\n    · exact sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx₁) e\n    · show N₀ ≤ (R ∙ x) ⊔ N₀\n      exact le_sup_right\n#align is_noetherian_iff_fg_well_founded isNoetherian_iff_fg_wellFounded\n\nvariable (R M)\n\n/- warning: well_founded_submodule_gt -> wellFounded_submodule_gt is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (M : Type.{u2}) [_inst_8 : Semiring.{u1} R] [_inst_9 : AddCommMonoid.{u2} M] [_inst_10 : Module.{u1, u2} R M _inst_8 _inst_9] [_inst_11 : IsNoetherian.{u1, u2} R M _inst_8 _inst_9 _inst_10], WellFounded.{succ u2} (Submodule.{u1, u2} R M _inst_8 _inst_9 _inst_10) (GT.gt.{u2} (Submodule.{u1, u2} R M _inst_8 _inst_9 _inst_10) (Preorder.toLT.{u2} (Submodule.{u1, u2} R M _inst_8 _inst_9 _inst_10) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_8 _inst_9 _inst_10) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_8 _inst_9 _inst_10) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M _inst_8 _inst_9 _inst_10) (Submodule.completeLattice.{u1, u2} R M _inst_8 _inst_9 _inst_10))))))\nbut is expected to have type\n  forall (R : Type.{u2}) (M : Type.{u1}) [_inst_8 : Semiring.{u2} R] [_inst_9 : AddCommMonoid.{u1} M] [_inst_10 : Module.{u2, u1} R M _inst_8 _inst_9] [_inst_11 : IsNoetherian.{u2, u1} R M _inst_8 _inst_9 _inst_10], WellFounded.{succ u1} (Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) (fun (x._@.Mathlib.RingTheory.Noetherian._hyg.2938 : Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) (x._@.Mathlib.RingTheory.Noetherian._hyg.2940 : Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) => GT.gt.{u1} (Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) (Preorder.toLT.{u1} (Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) (PartialOrder.toPreorder.{u1} (Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u2, u1} R M _inst_8 _inst_9 _inst_10) (Submodule.completeLattice.{u2, u1} R M _inst_8 _inst_9 _inst_10))))) x._@.Mathlib.RingTheory.Noetherian._hyg.2938 x._@.Mathlib.RingTheory.Noetherian._hyg.2940)\nCase conversion may be inaccurate. Consider using '#align well_founded_submodule_gt wellFounded_submodule_gtₓ'. -/\ntheorem wellFounded_submodule_gt (R M) [Semiring R] [AddCommMonoid M] [Module R M] :\n    ∀ [IsNoetherian R M], WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) :=\n  isNoetherian_iff_wellFounded.mp\n#align well_founded_submodule_gt wellFounded_submodule_gt\n\nvariable {R M}\n\n/- warning: set_has_maximal_iff_noetherian -> set_has_maximal_iff_noetherian is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M _inst_1 _inst_2], Iff (forall (a : Set.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)), (Set.Nonempty.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) a) -> (Exists.{succ u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (fun (M' : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) => Exists.{0} (Membership.Mem.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Set.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) (Set.hasMem.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) M' a) (fun (H : Membership.Mem.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Set.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) (Set.hasMem.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) M' a) => forall (I : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3), (Membership.Mem.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Set.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) (Set.hasMem.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) I a) -> (LE.le.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Preorder.toLE.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u1, u2} R M _inst_1 _inst_2 _inst_3))))) M' I) -> (Eq.{succ u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) I M'))))) (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_3)\nbut is expected to have type\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M _inst_1 _inst_2], Iff (forall (a : Set.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)), (Set.Nonempty.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) a) -> (Exists.{succ u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (fun (M' : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) => And (Membership.mem.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Set.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) (Set.instMembershipSet.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) M' a) (forall (I : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3), (Membership.mem.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Set.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) (Set.instMembershipSet.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3)) I a) -> (LE.le.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Preorder.toLE.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (OmegaCompletePartialOrder.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.instOmegaCompletePartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u1, u2} R M _inst_1 _inst_2 _inst_3))))) M' I) -> (Eq.{succ u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) I M'))))) (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_3)\nCase conversion may be inaccurate. Consider using '#align set_has_maximal_iff_noetherian set_has_maximal_iff_noetherianₓ'. -/\n/-- A module is Noetherian iff every nonempty set of submodules has a maximal submodule among them.\n-/\ntheorem set_has_maximal_iff_noetherian :\n    (∀ a : Set <| Submodule R M, a.Nonempty → ∃ M' ∈ a, ∀ I ∈ a, M' ≤ I → I = M') ↔\n      IsNoetherian R M :=\n  by rw [isNoetherian_iff_wellFounded, WellFounded.wellFounded_iff_has_max']\n#align set_has_maximal_iff_noetherian set_has_maximal_iff_noetherian\n\n#print monotone_stabilizes_iff_noetherian /-\n/-- A module is Noetherian iff every increasing chain of submodules stabilizes. -/\ntheorem monotone_stabilizes_iff_noetherian :\n    (∀ f : ℕ →o Submodule R M, ∃ n, ∀ m, n ≤ m → f n = f m) ↔ IsNoetherian R M := by\n  rw [isNoetherian_iff_wellFounded, WellFounded.monotone_chain_condition]\n#align monotone_stabilizes_iff_noetherian monotone_stabilizes_iff_noetherian\n-/\n\n/- warning: is_noetherian.induction -> IsNoetherian.induction is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M _inst_1 _inst_2] [_inst_8 : IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_3] {P : (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) -> Prop}, (forall (I : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3), (forall (J : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3), (GT.gt.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Preorder.toLT.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u1, u2} R M _inst_1 _inst_2 _inst_3))))) J I) -> (P J)) -> (P I)) -> (forall (I : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3), P I)\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : Module.{u2, u1} R M _inst_1 _inst_2] [_inst_8 : IsNoetherian.{u2, u1} R M _inst_1 _inst_2 _inst_3] {P : (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) -> Prop}, (forall (I : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3), (forall (J : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3), (GT.gt.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (Preorder.toLT.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (PartialOrder.toPreorder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (Submodule.completeLattice.{u2, u1} R M _inst_1 _inst_2 _inst_3))))) J I) -> (P J)) -> (P I)) -> (forall (I : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3), P I)\nCase conversion may be inaccurate. Consider using '#align is_noetherian.induction IsNoetherian.inductionₓ'. -/\n/-- If `∀ I > J, P I` implies `P J`, then `P` holds for all submodules. -/\ntheorem IsNoetherian.induction [IsNoetherian R M] {P : Submodule R M → Prop}\n    (hgt : ∀ I, (∀ J > I, P J) → P I) (I : Submodule R M) : P I :=\n  WellFounded.recursion (wellFounded_submodule_gt R M) I hgt\n#align is_noetherian.induction IsNoetherian.induction\n\nend\n\nsection\n\nuniverse w\n\nvariable {R M P : Type _} {N : Type w} [Ring R] [AddCommGroup M] [Module R M] [AddCommGroup N]\n  [Module R N] [AddCommGroup P] [Module R P]\n\n/- warning: finite_of_linear_independent -> finite_of_linearIndependent is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_8 : Nontrivial.{u1} R] [_inst_9 : IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3] {s : Set.{u2} M}, (LinearIndependent.{u2, u1, u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} M) Type.{u2} (Set.hasCoeToSort.{u2} M) s) R M ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Set.{u2} M) Type.{u2} (Set.hasCoeToSort.{u2} M) s) M (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} M) Type.{u2} (Set.hasCoeToSort.{u2} M) s) M (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} M) Type.{u2} (Set.hasCoeToSort.{u2} M) s) M (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} M) Type.{u2} (Set.hasCoeToSort.{u2} M) s) M (coeSubtype.{succ u2} M (fun (x : M) => Membership.Mem.{u2, u2} M (Set.{u2} M) (Set.hasMem.{u2} M) x s)))))) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) -> (Set.Finite.{u2} M s)\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_8 : Nontrivial.{u2} R] [_inst_9 : IsNoetherian.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3] {s : Set.{u1} M}, (LinearIndependent.{u1, u2, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s)) R M (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x s)) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) -> (Set.Finite.{u1} M s)\nCase conversion may be inaccurate. Consider using '#align finite_of_linear_independent finite_of_linearIndependentₓ'. -/\ntheorem finite_of_linearIndependent [Nontrivial R] [IsNoetherian R M] {s : Set M}\n    (hs : LinearIndependent R (coe : s → M)) : s.Finite :=\n  by\n  refine'\n    by_contradiction fun hf =>\n      (RelEmbedding.wellFounded_iff_no_descending_seq.1 (wellFounded_submodule_gt R M)).elim' _\n  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf\n  have : ∀ n, coe ∘ f '' { m | m ≤ n } ⊆ s :=\n    by\n    rintro n x ⟨y, hy₁, rfl⟩\n    exact (f y).2\n  have : ∀ a b : ℕ, a ≤ b ↔ span R (coe ∘ f '' { m | m ≤ a }) ≤ span R (coe ∘ f '' { m | m ≤ b }) :=\n    by\n    intro a b\n    rw [span_le_span_iff hs (this a) (this b),\n      Set.image_subset_image_iff (subtype.coe_injective.comp f.injective), Set.subset_def]\n    exact ⟨fun hab x (hxa : x ≤ a) => le_trans hxa hab, fun hx => hx a (le_refl a)⟩\n  exact\n    ⟨⟨fun n => span R (coe ∘ f '' { m | m ≤ n }), fun x y => by\n        simp (config := { contextual := true }) [le_antisymm_iff, (this _ _).symm]⟩,\n      by dsimp [GT.gt] <;> simp only [lt_iff_le_not_le, (this _ _).symm] <;> tauto⟩\n#align finite_of_linear_independent finite_of_linearIndependent\n\n/- warning: is_noetherian_of_range_eq_ker -> isNoetherian_of_range_eq_ker is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u2}} {M : Type.{u3}} {P : Type.{u4}} {N : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u3} M] [_inst_3 : Module.{u2, u3} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2)] [_inst_4 : AddCommGroup.{u1} N] [_inst_5 : Module.{u2, u1} R N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)] [_inst_6 : AddCommGroup.{u4} P] [_inst_7 : Module.{u2, u4} R P (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6)] [_inst_8 : IsNoetherian.{u2, u3} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) _inst_3] [_inst_9 : IsNoetherian.{u2, u4} R P (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_7] (f : LinearMap.{u2, u2, u3, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) (g : LinearMap.{u2, u2, u1, u4} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) N P (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_5 _inst_7), (Function.Injective.{succ u3, succ u1} M N (coeFn.{max (succ u3) (succ u1), max (succ u3) (succ u1)} (LinearMap.{u2, u2, u3, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) (fun (_x : LinearMap.{u2, u2, u3, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) => M -> N) (LinearMap.hasCoeToFun.{u2, u2, u3, u1} R R M N (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) f)) -> (Function.Surjective.{succ u1, succ u4} N P (coeFn.{max (succ u1) (succ u4), max (succ u1) (succ u4)} (LinearMap.{u2, u2, u1, u4} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) N P (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_5 _inst_7) (fun (_x : LinearMap.{u2, u2, u1, u4} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) N P (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_5 _inst_7) => N -> P) (LinearMap.hasCoeToFun.{u2, u2, u1, u4} R R N P (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_5 _inst_7 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) g)) -> (Eq.{succ u1} (Submodule.{u2, u1} R N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_5) (LinearMap.range.{u2, u2, u3, u1, max u3 u1} R R M N (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (LinearMap.{u2, u2, u3, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) (LinearMap.semilinearMapClass.{u2, u2, u3, u1} R R M N (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) (RingHomSurjective.ids.{u2} R (Ring.toSemiring.{u2} R _inst_1)) f) (LinearMap.ker.{u2, u2, u1, u4, max u1 u4} R R N P (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_5 _inst_7 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (LinearMap.{u2, u2, u1, u4} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) N P (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_5 _inst_7) (LinearMap.semilinearMapClass.{u2, u2, u1, u4} R R N P (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u4} P _inst_6) _inst_5 _inst_7 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) g)) -> (IsNoetherian.{u2, u1} R N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_5)\nbut is expected to have type\n  forall {R : Type.{u3}} {M : Type.{u2}} {P : Type.{u1}} {N : Type.{u4}} [_inst_1 : Ring.{u3} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u3, u2} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_4 : AddCommGroup.{u4} N] [_inst_5 : Module.{u3, u4} R N (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4)] [_inst_6 : AddCommGroup.{u1} P] [_inst_7 : Module.{u3, u1} R P (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6)] [_inst_8 : IsNoetherian.{u3, u2} R M (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3] [_inst_9 : IsNoetherian.{u3, u1} R P (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6) _inst_7] (f : LinearMap.{u3, u3, u2, u4} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) M N (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_3 _inst_5) (g : LinearMap.{u3, u3, u4, u1} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) N P (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6) _inst_5 _inst_7), (Function.Injective.{succ u2, succ u4} M N (FunLike.coe.{max (succ u4) (succ u2), succ u2, succ u4} (LinearMap.{u3, u3, u2, u4} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) M N (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_3 _inst_5) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => N) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, u2, u4} R R M N (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_3 _inst_5 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1)))) f)) -> (Function.Surjective.{succ u4, succ u1} N P (FunLike.coe.{max (succ u4) (succ u1), succ u4, succ u1} (LinearMap.{u3, u3, u4, u1} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) N P (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6) _inst_5 _inst_7) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, u4, u1} R R N P (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6) _inst_5 _inst_7 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1)))) g)) -> (Eq.{succ u4} (Submodule.{u3, u4} R N (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_5) (LinearMap.range.{u3, u3, u2, u4, max u4 u2} R R M N (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_3 _inst_5 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) (LinearMap.{u3, u3, u2, u4} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) M N (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_3 _inst_5) (LinearMap.instSemilinearMapClassLinearMap.{u3, u3, u2, u4} R R M N (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_3 _inst_5 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1)))) (RingHomSurjective.ids.{u3} R (Ring.toSemiring.{u3} R _inst_1)) f) (LinearMap.ker.{u3, u3, u4, u1, max u4 u1} R R N P (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6) _inst_5 _inst_7 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) (LinearMap.{u3, u3, u4, u1} R R (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1))) N P (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6) _inst_5 _inst_7) (LinearMap.instSemilinearMapClassLinearMap.{u3, u3, u4, u1} R R N P (Ring.toSemiring.{u3} R _inst_1) (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) (AddCommGroup.toAddCommMonoid.{u1} P _inst_6) _inst_5 _inst_7 (RingHom.id.{u3} R (NonAssocRing.toNonAssocSemiring.{u3} R (Ring.toNonAssocRing.{u3} R _inst_1)))) g)) -> (IsNoetherian.{u3, u4} R N (Ring.toSemiring.{u3} R _inst_1) (AddCommGroup.toAddCommMonoid.{u4} N _inst_4) _inst_5)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_range_eq_ker isNoetherian_of_range_eq_kerₓ'. -/\n/-- If the first and final modules in a short exact sequence are noetherian,\n  then the middle module is also noetherian. -/\ntheorem isNoetherian_of_range_eq_ker [IsNoetherian R M] [IsNoetherian R P] (f : M →ₗ[R] N)\n    (g : N →ₗ[R] P) (hf : Function.Injective f) (hg : Function.Surjective g) (h : f.range = g.ker) :\n    IsNoetherian R N :=\n  isNoetherian_iff_wellFounded.2 <|\n    wellFounded_gt_exact_sequence (wellFounded_submodule_gt R M) (wellFounded_submodule_gt R P)\n      f.range (Submodule.map f) (Submodule.comap f) (Submodule.comap g) (Submodule.map g)\n      (Submodule.gciMapComap hf) (Submodule.giMapComap hg)\n      (by simp [Submodule.map_comap_eq, inf_comm]) (by simp [Submodule.comap_map_eq, h])\n#align is_noetherian_of_range_eq_ker isNoetherian_of_range_eq_ker\n\n/- warning: is_noetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot -> IsNoetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [I : IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3), Exists.{1} Nat (fun (n : Nat) => And (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Inf.inf.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.hasInf.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) (HPow.hPow.{u2, 0, u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) Nat (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (instHPow.{u2, 0} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) Nat (Monoid.Pow.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (Module.End.monoid.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))) f n)) (LinearMap.range.{u1, u1, u2, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) (RingHomSurjective.ids.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (HPow.hPow.{u2, 0, u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) Nat (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (instHPow.{u2, 0} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) Nat (Monoid.Pow.{u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (Module.End.monoid.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))) f n))) (Bot.bot.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.hasBot.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [I : IsNoetherian.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3] (f : LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3), Exists.{1} Nat (fun (n : Nat) => And (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (Eq.{succ u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Inf.inf.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Submodule.instInfSubmodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (LinearMap.ker.{u2, u2, u1, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) (LinearMap.instSemilinearMapClassLinearMap.{u2, u2, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) (HPow.hPow.{u1, 0, u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) Nat (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) (instHPow.{u1, 0} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) Nat (Monoid.Pow.{u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) (Module.End.monoid.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))) f n)) (LinearMap.range.{u2, u2, u1, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) (LinearMap.instSemilinearMapClassLinearMap.{u2, u2, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) (RingHomSurjective.ids.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (HPow.hPow.{u1, 0, u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) Nat (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) (instHPow.{u1, 0} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) Nat (Monoid.Pow.{u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) (Module.End.monoid.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))) f n))) (Bot.bot.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Submodule.instBotSubmodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align is_noetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot IsNoetherian.exists_endomorphism_iterate_ker_inf_range_eq_botₓ'. -/\n/-- For any endomorphism of a Noetherian module, there is some nontrivial iterate\nwith disjoint kernel and range.\n-/\ntheorem IsNoetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot [I : IsNoetherian R M]\n    (f : M →ₗ[R] M) : ∃ n : ℕ, n ≠ 0 ∧ (f ^ n).ker ⊓ (f ^ n).range = ⊥ :=\n  by\n  obtain ⟨n, w⟩ :=\n    monotone_stabilizes_iff_noetherian.mpr I\n      (f.iterate_ker.comp ⟨fun n => n + 1, fun n m w => by linarith⟩)\n  specialize w (2 * n + 1) (by linarith only)\n  dsimp at w\n  refine' ⟨n + 1, Nat.succ_ne_zero _, _⟩\n  rw [eq_bot_iff]\n  rintro - ⟨h, ⟨y, rfl⟩⟩\n  rw [mem_bot, ← LinearMap.mem_ker, w]\n  erw [LinearMap.mem_ker] at h⊢\n  change (f ^ (n + 1) * f ^ (n + 1)) y = 0 at h\n  rw [← pow_add] at h\n  convert h using 3\n  ring\n#align is_noetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot IsNoetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot\n\n/- warning: is_noetherian.injective_of_surjective_endomorphism -> IsNoetherian.injective_of_surjective_endomorphism is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_8 : IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3), (Function.Surjective.{succ u2, succ u2} M M (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) f)) -> (Function.Injective.{succ u2, succ u2} M M (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) f))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_8 : IsNoetherian.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3] (f : LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3), (Function.Surjective.{succ u1, succ u1} M M (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) f)) -> (Function.Injective.{succ u1, succ u1} M M (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) f))\nCase conversion may be inaccurate. Consider using '#align is_noetherian.injective_of_surjective_endomorphism IsNoetherian.injective_of_surjective_endomorphismₓ'. -/\n/-- Any surjective endomorphism of a Noetherian module is injective. -/\ntheorem IsNoetherian.injective_of_surjective_endomorphism [IsNoetherian R M] (f : M →ₗ[R] M)\n    (s : Surjective f) : Injective f :=\n  by\n  obtain ⟨n, ne, w⟩ := IsNoetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot f\n  rw [linear_map.range_eq_top.mpr (LinearMap.iterate_surjective s n), inf_top_eq,\n    LinearMap.ker_eq_bot] at w\n  exact LinearMap.injective_of_iterate_injective Ne w\n#align is_noetherian.injective_of_surjective_endomorphism IsNoetherian.injective_of_surjective_endomorphism\n\n/- warning: is_noetherian.bijective_of_surjective_endomorphism -> IsNoetherian.bijective_of_surjective_endomorphism is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_8 : IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3] (f : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3), (Function.Surjective.{succ u2, succ u2} M M (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) f)) -> (Function.Bijective.{succ u2, succ u2} M M (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)))) f))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_8 : IsNoetherian.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3] (f : LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3), (Function.Surjective.{succ u1, succ u1} M M (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) f)) -> (Function.Bijective.{succ u1, succ u1} M M (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u1, u1} R R M M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) f))\nCase conversion may be inaccurate. Consider using '#align is_noetherian.bijective_of_surjective_endomorphism IsNoetherian.bijective_of_surjective_endomorphismₓ'. -/\n/-- Any surjective endomorphism of a Noetherian module is bijective. -/\ntheorem IsNoetherian.bijective_of_surjective_endomorphism [IsNoetherian R M] (f : M →ₗ[R] M)\n    (s : Surjective f) : Bijective f :=\n  ⟨IsNoetherian.injective_of_surjective_endomorphism f s, s⟩\n#align is_noetherian.bijective_of_surjective_endomorphism IsNoetherian.bijective_of_surjective_endomorphism\n\n/- warning: is_noetherian.disjoint_partial_sups_eventually_bot -> IsNoetherian.disjoint_partialSups_eventually_bot is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [I : IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3] (f : Nat -> (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)), (forall (n : Nat), Disjoint.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))) (Submodule.orderBot.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (coeFn.{succ u2, succ u2} (OrderHom.{0, u2} Nat (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (SemilatticeSup.toPartialOrder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))))))) (fun (_x : OrderHom.{0, u2} Nat (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (SemilatticeSup.toPartialOrder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))))))) => Nat -> (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)) (OrderHom.hasCoeToFun.{0, u2} Nat (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (SemilatticeSup.toPartialOrder.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))))))) (partialSups.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Lattice.toSemilatticeSup.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (ConditionallyCompleteLattice.toLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.completeLattice.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))) f) n) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) -> (Exists.{1} Nat (fun (n : Nat) => forall (m : Nat), (LE.le.{0} Nat Nat.hasLe n m) -> (Eq.{succ u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (f m) (Bot.bot.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.hasBot.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [I : IsNoetherian.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3] (f : Nat -> (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3)), (forall (n : Nat), Disjoint.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Submodule.completeLattice.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))) (Submodule.instOrderBotSubmoduleToLEToPreorderInstPartialOrderSetLike.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (OrderHom.toFun.{0, u1} Nat (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (SemilatticeSup.toPartialOrder.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Lattice.toSemilatticeSup.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (ConditionallyCompleteLattice.toLattice.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Submodule.completeLattice.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3)))))) (partialSups.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Lattice.toSemilatticeSup.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (ConditionallyCompleteLattice.toLattice.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Submodule.completeLattice.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3)))) f) n) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) -> (Exists.{1} Nat (fun (n : Nat) => forall (m : Nat), (LE.le.{0} Nat instLENat n m) -> (Eq.{succ u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (f m) (Bot.bot.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Submodule.instBotSubmodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3)))))\nCase conversion may be inaccurate. Consider using '#align is_noetherian.disjoint_partial_sups_eventually_bot IsNoetherian.disjoint_partialSups_eventually_botₓ'. -/\n/-- A sequence `f` of submodules of a noetherian module,\nwith `f (n+1)` disjoint from the supremum of `f 0`, ..., `f n`,\nis eventually zero.\n-/\ntheorem IsNoetherian.disjoint_partialSups_eventually_bot [I : IsNoetherian R M]\n    (f : ℕ → Submodule R M) (h : ∀ n, Disjoint (partialSups f n) (f (n + 1))) :\n    ∃ n : ℕ, ∀ m, n ≤ m → f m = ⊥ :=\n  by\n  -- A little off-by-one cleanup first:\n  suffices t : ∃ n : ℕ, ∀ m, n ≤ m → f (m + 1) = ⊥\n  · obtain ⟨n, w⟩ := t\n    use n + 1\n    rintro (_ | m) p\n    · cases p\n    · apply w\n      exact nat.succ_le_succ_iff.mp p\n  obtain ⟨n, w⟩ := monotone_stabilizes_iff_noetherian.mpr I (partialSups f)\n  exact\n    ⟨n, fun m p =>\n      (h m).eq_bot_of_ge <| sup_eq_left.1 <| (w (m + 1) <| le_add_right p).symm.trans <| w m p⟩\n#align is_noetherian.disjoint_partial_sups_eventually_bot IsNoetherian.disjoint_partialSups_eventually_bot\n\n/- warning: is_noetherian.equiv_punit_of_prod_injective -> IsNoetherian.equivPunitOfProdInjective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u2}} {M : Type.{u3}} {N : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u3} M] [_inst_3 : Module.{u2, u3} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2)] [_inst_4 : AddCommGroup.{u1} N] [_inst_5 : Module.{u2, u1} R N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)] [_inst_8 : IsNoetherian.{u2, u3} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) _inst_3] (f : LinearMap.{u2, u2, max u3 u1, u3} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (Prod.{u3, u1} M N) M (Prod.addCommMonoid.{u3, u1} M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (Prod.module.{u2, u3, u1} R M N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) _inst_3), (Function.Injective.{max (succ u3) (succ u1), succ u3} (Prod.{u3, u1} M N) M (coeFn.{max (succ (max u3 u1)) (succ u3), max (succ (max u3 u1)) (succ u3)} (LinearMap.{u2, u2, max u3 u1, u3} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (Prod.{u3, u1} M N) M (Prod.addCommMonoid.{u3, u1} M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (Prod.module.{u2, u3, u1} R M N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) _inst_3) (fun (_x : LinearMap.{u2, u2, max u3 u1, u3} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (Prod.{u3, u1} M N) M (Prod.addCommMonoid.{u3, u1} M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (Prod.module.{u2, u3, u1} R M N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) _inst_3) => (Prod.{u3, u1} M N) -> M) (LinearMap.hasCoeToFun.{u2, u2, max u3 u1, u3} R R (Prod.{u3, u1} M N) M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (Prod.addCommMonoid.{u3, u1} M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (Prod.module.{u2, u3, u1} R M N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) f)) -> (LinearEquiv.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (IsNoetherian.equivPunitOfProdInjective._proof_1.{u2} R _inst_1) (IsNoetherian.equivPunitOfProdInjective._proof_2.{u2} R _inst_1) N PUnit.{succ u1} (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (AddCommGroup.toAddCommMonoid.{u1} PUnit.{succ u1} PUnit.addCommGroup.{u1}) _inst_5 (PUnit.module.{u2, u1} R (Ring.toSemiring.{u2} R _inst_1)))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u3}} {N : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u3} M] [_inst_3 : Module.{u2, u3} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2)] [_inst_4 : AddCommGroup.{u1} N] [_inst_5 : Module.{u2, u1} R N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)] [_inst_8 : IsNoetherian.{u2, u3} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) _inst_3] (f : LinearMap.{u2, u2, max u1 u3, u3} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (Prod.{u3, u1} M N) M (Prod.instAddCommMonoidSum.{u3, u1} M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (Prod.module.{u2, u3, u1} R M N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) _inst_3), (Function.Injective.{max (succ u1) (succ u3), succ u3} (Prod.{u3, u1} M N) M (FunLike.coe.{max (succ u1) (succ u3), max (succ u1) (succ u3), succ u3} (LinearMap.{u2, u2, max u1 u3, u3} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (Prod.{u3, u1} M N) M (Prod.instAddCommMonoidSum.{u3, u1} M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (Prod.module.{u2, u3, u1} R M N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) _inst_3) (Prod.{u3, u1} M N) (fun (_x : Prod.{u3, u1} M N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Prod.{u3, u1} M N) => M) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, max u1 u3, u3} R R (Prod.{u3, u1} M N) M (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (Prod.instAddCommMonoidSum.{u3, u1} M N (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4)) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (Prod.module.{u2, u3, u1} R M N (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_2) (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) _inst_3 _inst_5) _inst_3 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)))) f)) -> (LinearEquiv.{u2, u2, u1, u1} R R (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (RingHomInvPair.ids.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (RingHomInvPair.ids.{u2} R (Ring.toSemiring.{u2} R _inst_1)) N PUnit.{succ u1} (AddCommGroup.toAddCommMonoid.{u1} N _inst_4) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} PUnit.{succ u1} (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u1} PUnit.{succ u1} PUnit.linearOrderedCancelAddCommMonoid.{u1})) _inst_5 (PUnit.module.{u2, u1} R (Ring.toSemiring.{u2} R _inst_1)))\nCase conversion may be inaccurate. Consider using '#align is_noetherian.equiv_punit_of_prod_injective IsNoetherian.equivPunitOfProdInjectiveₓ'. -/\n/-- If `M ⊕ N` embeds into `M`, for `M` noetherian over `R`, then `N` is trivial.\n-/\nnoncomputable def IsNoetherian.equivPunitOfProdInjective [IsNoetherian R M] (f : M × N →ₗ[R] M)\n    (i : Injective f) : N ≃ₗ[R] PUnit.{w + 1} :=\n  by\n  apply Nonempty.some\n  obtain ⟨n, w⟩ :=\n    IsNoetherian.disjoint_partialSups_eventually_bot (f.tailing i) (f.tailings_disjoint_tailing i)\n  specialize w n (le_refl n)\n  apply Nonempty.intro\n  refine' (f.tailing_linear_equiv i n).symm ≪≫ₗ _\n  rw [w]\n  exact Submodule.botEquivPUnit\n#align is_noetherian.equiv_punit_of_prod_injective IsNoetherian.equivPunitOfProdInjective\n\nend\n\n#print IsNoetherianRing /-\n/-- A (semi)ring is Noetherian if it is Noetherian as a module over itself,\ni.e. all its ideals are finitely generated.\n-/\n@[reducible]\ndef IsNoetherianRing (R) [Semiring R] :=\n  IsNoetherian R R\n#align is_noetherian_ring IsNoetherianRing\n-/\n\n#print isNoetherianRing_iff /-\ntheorem isNoetherianRing_iff {R} [Semiring R] : IsNoetherianRing R ↔ IsNoetherian R R :=\n  Iff.rfl\n#align is_noetherian_ring_iff isNoetherianRing_iff\n-/\n\n#print isNoetherianRing_iff_ideal_fg /-\n/-- A ring is Noetherian if and only if all its ideals are finitely-generated. -/\ntheorem isNoetherianRing_iff_ideal_fg (R : Type _) [Semiring R] :\n    IsNoetherianRing R ↔ ∀ I : Ideal R, I.Fg :=\n  isNoetherianRing_iff.trans isNoetherian_def\n#align is_noetherian_ring_iff_ideal_fg isNoetherianRing_iff_ideal_fg\n-/\n\n#print isNoetherian_of_finite /-\n-- see Note [lower instance priority]\ninstance (priority := 80) isNoetherian_of_finite (R M) [Finite M] [Semiring R] [AddCommMonoid M]\n    [Module R M] : IsNoetherian R M :=\n  ⟨fun s => ⟨(s : Set M).toFinite.toFinset, by rw [Set.Finite.coe_toFinset, Submodule.span_eq]⟩⟩\n#align is_noetherian_of_finite isNoetherian_of_finite\n-/\n\n#print isNoetherian_of_subsingleton /-\n-- see Note [lower instance priority]\n/-- Modules over the trivial ring are Noetherian. -/\ninstance (priority := 100) isNoetherian_of_subsingleton (R M) [Subsingleton R] [Semiring R]\n    [AddCommMonoid M] [Module R M] : IsNoetherian R M :=\n  haveI := Module.subsingleton R M\n  isNoetherian_of_finite R M\n#align is_noetherian_of_subsingleton isNoetherian_of_subsingleton\n-/\n\n/- warning: is_noetherian_of_submodule_of_noetherian -> isNoetherian_of_submodule_of_noetherian is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (M : Type.{u2}) [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M _inst_1 _inst_2] (N : Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3), (IsNoetherian.{u1, u2} R M _inst_1 _inst_2 _inst_3) -> (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M _inst_1 _inst_2 _inst_3) M (Submodule.setLike.{u1, u2} R M _inst_1 _inst_2 _inst_3)) N) _inst_1 (Submodule.addCommMonoid.{u1, u2} R M _inst_1 _inst_2 _inst_3 N) (Submodule.module.{u1, u2} R M _inst_1 _inst_2 _inst_3 N))\nbut is expected to have type\n  forall (R : Type.{u2}) (M : Type.{u1}) [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : Module.{u2, u1} R M _inst_1 _inst_2] (N : Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3), (IsNoetherian.{u2, u1} R M _inst_1 _inst_2 _inst_3) -> (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M _inst_1 _inst_2 _inst_3) M (Submodule.setLike.{u2, u1} R M _inst_1 _inst_2 _inst_3)) x N)) _inst_1 (Submodule.addCommMonoid.{u2, u1} R M _inst_1 _inst_2 _inst_3 N) (Submodule.module.{u2, u1} R M _inst_1 _inst_2 _inst_3 N))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_submodule_of_noetherian isNoetherian_of_submodule_of_noetherianₓ'. -/\ntheorem isNoetherian_of_submodule_of_noetherian (R M) [Semiring R] [AddCommMonoid M] [Module R M]\n    (N : Submodule R M) (h : IsNoetherian R M) : IsNoetherian R N :=\n  by\n  rw [isNoetherian_iff_wellFounded] at h⊢\n  exact OrderEmbedding.wellFounded (Submodule.MapSubtype.orderEmbedding N).dual h\n#align is_noetherian_of_submodule_of_noetherian isNoetherian_of_submodule_of_noetherian\n\n#print Submodule.Quotient.isNoetherian /-\ninstance Submodule.Quotient.isNoetherian {R} [Ring R] {M} [AddCommGroup M] [Module R M]\n    (N : Submodule R M) [h : IsNoetherian R M] : IsNoetherian R (M ⧸ N) :=\n  by\n  rw [isNoetherian_iff_wellFounded] at h⊢\n  exact OrderEmbedding.wellFounded (Submodule.comapMkQOrderEmbedding N).dual h\n#align submodule.quotient.is_noetherian Submodule.Quotient.isNoetherian\n-/\n\n/- warning: is_noetherian_of_tower -> isNoetherian_of_tower is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {S : Type.{u2}} {M : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u3} M] [_inst_4 : SMul.{u1, u2} R S] [_inst_5 : Module.{u2, u3} S M _inst_2 _inst_3] [_inst_6 : Module.{u1, u3} R M _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R S M _inst_4 (SMulZeroClass.toHasSmul.{u2, u3} S M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S M (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S M (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_3))) (Module.toMulActionWithZero.{u2, u3} S M _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_3))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_3))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_3))) (Module.toMulActionWithZero.{u1, u3} R M _inst_1 _inst_3 _inst_6))))], (IsNoetherian.{u1, u3} R M _inst_1 _inst_3 _inst_6) -> (IsNoetherian.{u2, u3} S M _inst_2 _inst_3 _inst_5)\nbut is expected to have type\n  forall (R : Type.{u3}) {S : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u3} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u1} M] [_inst_4 : SMul.{u3, u2} R S] [_inst_5 : Module.{u2, u1} S M _inst_2 _inst_3] [_inst_6 : Module.{u3, u1} R M _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u3, u2, u1} R S M _inst_4 (SMulZeroClass.toSMul.{u2, u1} S M (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u1} S M (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u1} S M (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_3)) (Module.toMulActionWithZero.{u2, u1} S M _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toSMul.{u3, u1} R M (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_3)) (SMulWithZero.toSMulZeroClass.{u3, u1} R M (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R _inst_1)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_3)) (MulActionWithZero.toSMulWithZero.{u3, u1} R M (Semiring.toMonoidWithZero.{u3} R _inst_1) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_3)) (Module.toMulActionWithZero.{u3, u1} R M _inst_1 _inst_3 _inst_6))))], (IsNoetherian.{u3, u1} R M _inst_1 _inst_3 _inst_6) -> (IsNoetherian.{u2, u1} S M _inst_2 _inst_3 _inst_5)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_tower isNoetherian_of_towerₓ'. -/\n/-- If `M / S / R` is a scalar tower, and `M / R` is Noetherian, then `M / S` is\nalso noetherian. -/\ntheorem isNoetherian_of_tower (R) {S M} [Semiring R] [Semiring S] [AddCommMonoid M] [SMul R S]\n    [Module S M] [Module R M] [IsScalarTower R S M] (h : IsNoetherian R M) : IsNoetherian S M :=\n  by\n  rw [isNoetherian_iff_wellFounded] at h⊢\n  refine' (Submodule.restrictScalarsEmbedding R S M).dual.WellFounded h\n#align is_noetherian_of_tower isNoetherian_of_tower\n\n/- warning: is_noetherian_of_fg_of_noetherian -> isNoetherian_of_fg_of_noetherian is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] (N : Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) [_inst_4 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R _inst_1)], (Submodule.Fg.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 N) -> (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) M (Submodule.setLike.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)) N) (Ring.toSemiring.{u1} R _inst_1) (Submodule.addCommMonoid.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 N) (Submodule.module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 N))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] (N : Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) [_inst_4 : IsNoetherianRing.{u2} R (Ring.toSemiring.{u2} R _inst_1)], (Submodule.Fg.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 N) -> (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) M (Submodule.setLike.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3)) x N)) (Ring.toSemiring.{u2} R _inst_1) (Submodule.addCommMonoid.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 N) (Submodule.module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 N))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_fg_of_noetherian isNoetherian_of_fg_of_noetherianₓ'. -/\ntheorem isNoetherian_of_fg_of_noetherian {R M} [Ring R] [AddCommGroup M] [Module R M]\n    (N : Submodule R M) [IsNoetherianRing R] (hN : N.Fg) : IsNoetherian R N :=\n  by\n  let ⟨s, hs⟩ := hN\n  haveI := Classical.decEq M\n  haveI := Classical.decEq R\n  letI : IsNoetherian R R := by infer_instance\n  have : ∀ x ∈ s, x ∈ N := fun x hx => hs ▸ Submodule.subset_span hx\n  refine'\n    @isNoetherian_of_surjective ((↑s : Set M) → R) _ _ _ (Pi.module _ _ _) _ _ _ isNoetherian_pi\n  · fapply LinearMap.mk\n    · exact fun f => ⟨∑ i in s.attach, f i • i.1, N.sum_mem fun c _ => N.smul_mem _ <| this _ c.2⟩\n    · intro f g\n      apply Subtype.eq\n      change (∑ i in s.attach, (f i + g i) • _) = _\n      simp only [add_smul, Finset.sum_add_distrib]\n      rfl\n    · intro c f\n      apply Subtype.eq\n      change (∑ i in s.attach, (c • f i) • _) = _\n      simp only [smul_eq_mul, mul_smul]\n      exact finset.smul_sum.symm\n  rw [LinearMap.range_eq_top]\n  rintro ⟨n, hn⟩\n  change n ∈ N at hn\n  rw [← hs, ← Set.image_id ↑s, Finsupp.mem_span_image_iff_total] at hn\n  rcases hn with ⟨l, hl1, hl2⟩\n  refine' ⟨fun x => l x, Subtype.ext _⟩\n  change (∑ i in s.attach, l i • (i : M)) = n\n  rw [@Finset.sum_attach M M s _ fun i => l i • i, ← hl2, Finsupp.total_apply, Finsupp.sum, eq_comm]\n  refine' Finset.sum_subset hl1 fun x _ hx => _\n  rw [Finsupp.not_mem_support_iff.1 hx, zero_smul]\n#align is_noetherian_of_fg_of_noetherian isNoetherian_of_fg_of_noetherian\n\n/- warning: is_noetherian_of_fg_of_noetherian' -> isNoetherian_of_fg_of_noetherian' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_4 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R _inst_1)], (Submodule.Fg.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 (Top.top.{u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) (Submodule.hasTop.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3))) -> (IsNoetherian.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_4 : IsNoetherianRing.{u2} R (Ring.toSemiring.{u2} R _inst_1)], (Submodule.Fg.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 (Top.top.{u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (Submodule.instTopSubmodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))) -> (IsNoetherian.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3)\nCase conversion may be inaccurate. Consider using '#align is_noetherian_of_fg_of_noetherian' isNoetherian_of_fg_of_noetherian'ₓ'. -/\ntheorem isNoetherian_of_fg_of_noetherian' {R M} [Ring R] [AddCommGroup M] [Module R M]\n    [IsNoetherianRing R] (h : (⊤ : Submodule R M).Fg) : IsNoetherian R M :=\n  have : IsNoetherian R (⊤ : Submodule R M) := isNoetherian_of_fg_of_noetherian _ h\n  isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl)\n#align is_noetherian_of_fg_of_noetherian' isNoetherian_of_fg_of_noetherian'\n\n/- warning: is_noetherian_span_of_finite -> isNoetherian_span_of_finite is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_4 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R _inst_1)] {A : Set.{u2} M}, (Set.Finite.{u2} M A) -> (IsNoetherian.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3) M (Submodule.setLike.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)) (Submodule.span.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 A)) (Ring.toSemiring.{u1} R _inst_1) (Submodule.addCommMonoid.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 (Submodule.span.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 A)) (Submodule.module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 (Submodule.span.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3 A)))\nbut is expected to have type\n  forall (R : Type.{u2}) {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_4 : IsNoetherianRing.{u2} R (Ring.toSemiring.{u2} R _inst_1)] {A : Set.{u1} M}, (Set.Finite.{u1} M A) -> (IsNoetherian.{u2, u1} R (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Submodule.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3) M (Submodule.setLike.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3)) x (Submodule.span.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 A))) (Ring.toSemiring.{u2} R _inst_1) (Submodule.addCommMonoid.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 (Submodule.span.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 A)) (Submodule.module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 (Submodule.span.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3 A)))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_span_of_finite isNoetherian_span_of_finiteₓ'. -/\n/-- In a module over a noetherian ring, the submodule generated by finitely many vectors is\nnoetherian. -/\ntheorem isNoetherian_span_of_finite (R) {M} [Ring R] [AddCommGroup M] [Module R M]\n    [IsNoetherianRing R] {A : Set M} (hA : A.Finite) : IsNoetherian R (Submodule.span R A) :=\n  isNoetherian_of_fg_of_noetherian _ (Submodule.fg_def.mpr ⟨A, hA, rfl⟩)\n#align is_noetherian_span_of_finite isNoetherian_span_of_finite\n\n/- warning: is_noetherian_ring_of_surjective -> isNoetherianRing_of_surjective is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R] (S : Type.{u2}) [_inst_2 : Ring.{u2} S] (f : RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))), (Function.Surjective.{succ u1, succ u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) (fun (_x : RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) f)) -> (forall [H : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R _inst_1)], IsNoetherianRing.{u2} S (Ring.toSemiring.{u2} S _inst_2))\nbut is expected to have type\n  forall (R : Type.{u2}) [_inst_1 : Ring.{u2} R] (S : Type.{u1}) [_inst_2 : Ring.{u1} S] (f : RingHom.{u2, u1} R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2))), (Function.Surjective.{succ u2, succ u1} R S (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2))) R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2))) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2))) R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2)) (RingHom.instRingHomClassRingHom.{u2, u1} R S (NonAssocRing.toNonAssocSemiring.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2)))))) f)) -> (forall [H : IsNoetherianRing.{u2} R (Ring.toSemiring.{u2} R _inst_1)], IsNoetherianRing.{u1} S (Ring.toSemiring.{u1} S _inst_2))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_ring_of_surjective isNoetherianRing_of_surjectiveₓ'. -/\ntheorem isNoetherianRing_of_surjective (R) [Ring R] (S) [Ring S] (f : R →+* S)\n    (hf : Function.Surjective f) [H : IsNoetherianRing R] : IsNoetherianRing S :=\n  by\n  rw [isNoetherianRing_iff, isNoetherian_iff_wellFounded] at H⊢\n  exact OrderEmbedding.wellFounded (Ideal.orderEmbeddingOfSurjective f hf).dual H\n#align is_noetherian_ring_of_surjective isNoetherianRing_of_surjective\n\n/- warning: is_noetherian_ring_range -> isNoetherianRing_range is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {S : Type.{u2}} [_inst_2 : Ring.{u2} S] (f : RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) [_inst_3 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R _inst_1)], IsNoetherianRing.{u2} (coeSort.{succ u2, succ (succ u2)} (Subring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subring.{u2} S _inst_2) S (Subring.setLike.{u2} S _inst_2)) (RingHom.range.{u1, u2} R S _inst_1 _inst_2 f)) (Ring.toSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subring.{u2} S _inst_2) S (Subring.setLike.{u2} S _inst_2)) (RingHom.range.{u1, u2} R S _inst_1 _inst_2 f)) (Subring.toRing.{u2} S _inst_2 (RingHom.range.{u1, u2} R S _inst_1 _inst_2 f)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {S : Type.{u2}} [_inst_2 : Ring.{u2} S] (f : RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) [_inst_3 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R _inst_1)], IsNoetherianRing.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subring.{u2} S _inst_2) S (Subring.instSetLikeSubring.{u2} S _inst_2)) x (RingHom.range.{u1, u2} R S _inst_1 _inst_2 f))) (Ring.toSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subring.{u2} S _inst_2) S (Subring.instSetLikeSubring.{u2} S _inst_2)) x (RingHom.range.{u1, u2} R S _inst_1 _inst_2 f))) (Subring.toRing.{u2} S _inst_2 (RingHom.range.{u1, u2} R S _inst_1 _inst_2 f)))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_ring_range isNoetherianRing_rangeₓ'. -/\ninstance isNoetherianRing_range {R} [Ring R] {S} [Ring S] (f : R →+* S) [IsNoetherianRing R] :\n    IsNoetherianRing f.range :=\n  isNoetherianRing_of_surjective R f.range f.range_restrict f.rangeRestrict_surjective\n#align is_noetherian_ring_range isNoetherianRing_range\n\n/- warning: is_noetherian_ring_of_ring_equiv -> isNoetherianRing_of_ringEquiv is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : Ring.{u1} R] {S : Type.{u2}} [_inst_2 : Ring.{u2} S], (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1)) (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R _inst_1)) (Distrib.toHasMul.{u2} S (Ring.toDistrib.{u2} S _inst_2)) (Distrib.toHasAdd.{u2} S (Ring.toDistrib.{u2} S _inst_2))) -> (forall [_inst_3 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R _inst_1)], IsNoetherianRing.{u2} S (Ring.toSemiring.{u2} S _inst_2))\nbut is expected to have type\n  forall (R : Type.{u2}) [_inst_1 : Ring.{u2} R] {S : Type.{u1}} [_inst_2 : Ring.{u1} S], (RingEquiv.{u2, u1} R S (NonUnitalNonAssocRing.toMul.{u2} R (NonAssocRing.toNonUnitalNonAssocRing.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1))) (NonUnitalNonAssocRing.toMul.{u1} S (NonAssocRing.toNonUnitalNonAssocRing.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2))) (Distrib.toAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} R (NonAssocRing.toNonUnitalNonAssocRing.{u2} R (Ring.toNonAssocRing.{u2} R _inst_1))))) (Distrib.toAdd.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} S (NonAssocRing.toNonUnitalNonAssocRing.{u1} S (Ring.toNonAssocRing.{u1} S _inst_2)))))) -> (forall [_inst_3 : IsNoetherianRing.{u2} R (Ring.toSemiring.{u2} R _inst_1)], IsNoetherianRing.{u1} S (Ring.toSemiring.{u1} S _inst_2))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_ring_of_ring_equiv isNoetherianRing_of_ringEquivₓ'. -/\ntheorem isNoetherianRing_of_ringEquiv (R) [Ring R] {S} [Ring S] (f : R ≃+* S) [IsNoetherianRing R] :\n    IsNoetherianRing S :=\n  isNoetherianRing_of_surjective R S f.toRingHom f.toEquiv.Surjective\n#align is_noetherian_ring_of_ring_equiv isNoetherianRing_of_ringEquiv\n\n/- warning: is_noetherian_ring.is_nilpotent_nilradical -> IsNoetherianRing.isNilpotent_nilradical is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : CommRing.{u1} R] [_inst_2 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))], IsNilpotent.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toNonAssocSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (IdemSemiring.toSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Submodule.idemSemiring.{u1, u1} R (CommRing.toCommSemiring.{u1} R _inst_1) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (Monoid.Pow.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toMonoidWithZero.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (IdemSemiring.toSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Submodule.idemSemiring.{u1, u1} R (CommRing.toCommSemiring.{u1} R _inst_1) R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (nilradical.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : CommRing.{u1} R] [_inst_2 : IsNoetherianRing.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))], IsNilpotent.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommMonoidWithZero.toZero.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toCommMonoidWithZero.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (IdemCommSemiring.toCommSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Ideal.instIdemCommSemiringIdealToSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Monoid.Pow.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (MonoidWithZero.toMonoid.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Semiring.toMonoidWithZero.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (IdemSemiring.toSemiring.{u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (Submodule.idemSemiring.{u1, u1} R (CommRing.toCommSemiring.{u1} R _inst_1) R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Algebra.id.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))))) (nilradical.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align is_noetherian_ring.is_nilpotent_nilradical IsNoetherianRing.isNilpotent_nilradicalₓ'. -/\ntheorem IsNoetherianRing.isNilpotent_nilradical (R : Type _) [CommRing R] [IsNoetherianRing R] :\n    IsNilpotent (nilradical R) :=\n  by\n  obtain ⟨n, hn⟩ := Ideal.exists_radical_pow_le_of_fg (⊥ : Ideal R) (IsNoetherian.noetherian _)\n  exact ⟨n, eq_bot_iff.mpr hn⟩\n#align is_noetherian_ring.is_nilpotent_nilradical IsNoetherianRing.isNilpotent_nilradical\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/Noetherian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.48199999567773166}}
{"text": "import data.hash_map\nimport data.nat.basic\nimport data.rat.basic\nimport data.real.basic\nimport data.real.sqrt\nimport data.rat.sqrt\nimport analysis.normed.group.basic\n\nimport core.util\nimport core.point\nimport core.grid\n\ndef pt_in_ball (p q : point) (c : ℕ⁺) (qs : list point) : Prop :=\n  q ∈ qs ∧\n  q ≠ p ∧\n  ∥q - p∥ ≤ c\n\n-- def min_dist_pair_aux : list (point × ℚ) → option (point × ℚ)\n-- | [] := none\n-- | ((p, d) :: pds) :=\n--     match min_dist_pair_aux pds with\n--     | none :=\n--         some (p, d)\n--     | some (p', d') :=\n--         some (if d < d' then (p, d) else (p', d'))\n--     end\n\n-- def min_dist_pair : list (point × ℚ) → option point\n-- | [] := none\n-- | pds := min_dist_pair_aux pds >>= (λ (p : point × ℚ), some p.1)\n\ndef min_dist_pair (p : point) : list point → option (point × point)\n| [] := none\n| (q :: ps') :=\n    let pq' := min_dist_pair ps' in\n    if point_lt' (p, q) pq' then some (p, q) else pq'\n\n/-\n  All points within distance `c` from the current point are included in the list.\n-/\n\n/-\n  Get minimum distance pair, wrt the grid `g`, with `p` as the center of the\n  pair, and only considering the neighbors of `p`.\n-/\ndef mdp_with (p : point) (g : grid_2D) : option (point × point) :=\n  let ps := get_neighbs p g in\n  min_dist_pair p ps\n\nlemma range_in_hypercube :\n  ∀ (i j : ℤ) (n : ℕ),\n    ((-(↑n) ≤ i) ∧ (i ≤ n) ∧\n     (-(↑n) ≤ j) ∧ (j ≤ n))\n    ↔\n    (i, j) ∈ (get_hypercube n) := sorry\n\nlemma norm_bd_on_coords :\n  ∀ (a b : ℤ) (c : ℕ),\n    ∥(a, b)∥ ≤ c →\n    a*a ≤ c ∧ b*b ≤ c := sorry\n  -- (Something bounding `a` and `b` below and above by (+|-)nat.sqrt(c) (not sure whether inclusive or exclusive))\n\n-- lemma nat_sqrt_plus_one_sq_gt_nat :\n--   ∀ (c : ℕ),\n--     ((nat.sqrt c) + 1)*((nat.sqrt c) + 1) > c := sorry\n\nlemma sq_neg_lt :\n  ∀ (a b : ℤ),\n    a ≤ 0 →\n    b ≤ 0 →\n    a < b →\n    b*b < a*a := begin\n  intros a b h1 h2 h3,\n  sorry\nend\n\nlemma sq_nonneg_lt :\n  ∀ (a b : ℤ),\n    a ≥ 0 →\n    b ≥ 0 →\n    a < b →\n    a*a < b*b := begin\n  intros a b h1 h2 h3,\n  exact mul_lt_mul'' h3 h3 h1 h1,\nend\n\nlemma nat_ge_zero :\n  ∀ (n : ℕ), n ≥ 0 := begin\n  intros n,\n  linarith,\nend\n\nlemma ge_neg_le :\n  ∀ (n : ℤ),\n    n ≥ 0 →\n    -n ≤ 0 := begin\n  intros n h,\n  linarith,\nend\n\nlemma coe_nat_int_ge :\n  ∀ (n : ℕ),\n  n ≥ 0 →\n  (↑n : ℤ) ≥ 0 := begin\n  intros n h,\n  simp [h],\nend\n\nlemma lt_to_le :\n  ∀ (a b : ℤ),\n    a < b → a ≤ b := begin\n  intros a b h,\n  linarith,\nend\n\nlemma neg_sq_sq :\n  ∀ (a : ℤ),\n    (-a)*(-a) = a*a := begin\n  intros a,\n  ring,\nend\n\nlemma succ_sqrt_sq_gt_orig :\n  ∀ (c : ℕ),\n    ((nat.sqrt c) + 1) * ((nat.sqrt c) + 1) > c := begin\n  intros c,\n  exact nat.lt_succ_sqrt c,\nend\n\nlemma coe_preserves_lt :\n  ∀ (a b : ℕ),\n    a < b →\n    (↑a : ℤ) < ↑b := begin\n  intros a b h,\n  simp [h],\nend\n\nlemma coe_preserves_ge :\n  ∀ (a b : ℕ),\n    a ≥ b →\n    (↑a : ℤ) ≥ ↑b := begin\n  intros a b h,\n  linarith,\nend\n\nlemma coe_nat_nat_nop :\n  ∀ (n : ℕ),\n    (↑n : ℕ) = n := begin\n  intros n,\n  simp,\nend\n\nlemma bounded_norm_in_hypercube:\n  ∀ (ab : ℤ × ℤ) (c : ℕ),\n    ∥ab∥ ≤ c →\n    (ab ∈ get_hypercube ((nat.sqrt c) + 1)) := begin\n  intros ab c ab_le_c,\n  cases ab with a b,\n  apply (range_in_hypercube a b ((nat.sqrt c) + 1)).mp,\n  split,\n  {\n    by_cases h : -↑((nat.sqrt c) + 1) ≤ a,\n    assumption,\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a ≤ c ∧ b*b ≤ c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have h : a < -(↑(nat.sqrt c) + 1) := begin\n      simp,\n      rw [add_comm],\n      exact h,\n    end,\n    have sq_succ_sqrt_lt_sq_a : -(↑(nat.sqrt c) + 1) * -(↑(nat.sqrt c) + 1) < a * a := begin\n      apply sq_neg_lt,\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(↑(↑(nat.sqrt c) + 1) : ℤ) ≤ 0 := begin\n          apply ge_neg_le,\n          apply coe_nat_int_ge,\n          assumption,\n        end,\n        have h_le : a ≤ -(↑(nat.sqrt c) + 1) := begin\n          apply lt_to_le,\n          assumption,\n        end,\n        apply le_trans,\n        exact h_le,\n        simp at *,\n        exact neg_succ_sqrt_le_zero,\n      },\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(↑(↑(nat.sqrt c) + 1) : ℤ) ≤ 0 := begin\n          apply ge_neg_le,\n          apply coe_nat_int_ge,\n          assumption,\n        end,\n        simp at *,\n        exact neg_succ_sqrt_le_zero,\n      },\n      {\n        exact h,\n      },\n    end,\n    rw [neg_sq_sq] at sq_succ_sqrt_lt_sq_a,\n    have succ_sqrt_c_sq_gt_c : ((nat.sqrt c) + 1) * ((nat.sqrt c) + 1) > c := begin\n      apply succ_sqrt_sq_gt_orig,\n    end,\n    cases a_sq_le_c_and_b_sq_le_c with a_sq_le_c b_sq_le_c,\n    have c_lt_a_sq : (↑c : ℤ) < a*a := begin\n      fapply lt_trans,\n      exact ↑((nat.sqrt c + 1) * (nat.sqrt c + 1)),\n      simp at succ_sqrt_c_sq_gt_c,\n      apply coe_preserves_lt,\n      assumption,\n      simp,\n      assumption,\n    end,\n    exfalso,\n    apply not_le_and_gt,\n    split,\n    exact a_sq_le_c,\n    exact c_lt_a_sq,\n  },\n  split,\n  {\n    by_cases h : a ≤ ↑(nat.sqrt c + 1),\n    { assumption, },\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a ≤ c ∧ b*b ≤ c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have sq_succ_sqrt_lt_sq_a : (↑(nat.sqrt c) + 1) * (↑(nat.sqrt c) + 1) < a * a := begin\n      apply sq_nonneg_lt,\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        apply coe_preserves_ge,\n        rw [coe_nat_nat_nop] at succ_sqrt_ge_zero,\n        exact succ_sqrt_ge_zero,\n      },\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        fapply le_trans,\n        exact (↑(nat.sqrt c) + 1),\n        simp only [ge] at succ_sqrt_ge_zero,\n        apply coe_preserves_ge,\n        rw [coe_nat_nat_nop] at succ_sqrt_ge_zero,\n        exact succ_sqrt_ge_zero,\n        apply lt_to_le,\n        exact h,\n      },\n      {\n        exact h,\n      },\n    end,\n    have succ_sqrt_c_sq_gt_c : ((nat.sqrt c) + 1) * ((nat.sqrt c) + 1) > c := begin\n      apply succ_sqrt_sq_gt_orig,\n    end,\n    cases a_sq_le_c_and_b_sq_le_c with a_sq_le_c b_sq_le_c,\n    have c_lt_a_sq : (↑c : ℤ) < a*a := begin\n      fapply lt_trans,\n      exact ↑((nat.sqrt c + 1) * (nat.sqrt c + 1)),\n      simp at succ_sqrt_c_sq_gt_c,\n      apply coe_preserves_lt,\n      assumption,\n      simp,\n      assumption,\n    end,\n    exfalso,\n    apply not_le_and_gt,\n    split,\n    exact a_sq_le_c,\n    exact c_lt_a_sq,\n  },\n  split,\n  {\n    by_cases h : -↑((nat.sqrt c) + 1) ≤ b,\n    assumption,\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a ≤ c ∧ b*b ≤ c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have h : b < -(↑(nat.sqrt c) + 1) := begin\n      simp,\n      rw [add_comm],\n      exact h,\n    end,\n    have sq_succ_sqrt_lt_sq_a : -(↑(nat.sqrt c) + 1) * -(↑(nat.sqrt c) + 1) < b * b := begin\n      apply sq_neg_lt,\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(↑(↑(nat.sqrt c) + 1) : ℤ) ≤ 0 := begin\n          apply ge_neg_le,\n          apply coe_nat_int_ge,\n          assumption,\n        end,\n        have h_le : b ≤ -(↑(nat.sqrt c) + 1) := begin\n          apply lt_to_le,\n          assumption,\n        end,\n        apply le_trans,\n        exact h_le,\n        simp at *,\n        exact neg_succ_sqrt_le_zero,\n      },\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(↑(↑(nat.sqrt c) + 1) : ℤ) ≤ 0 := begin\n          apply ge_neg_le,\n          apply coe_nat_int_ge,\n          assumption,\n        end,\n        simp at *,\n        exact neg_succ_sqrt_le_zero,\n      },\n      {\n        exact h,\n      },\n    end,\n    rw [neg_sq_sq] at sq_succ_sqrt_lt_sq_a,\n    have succ_sqrt_c_sq_gt_c : ((nat.sqrt c) + 1) * ((nat.sqrt c) + 1) > c := begin\n      apply succ_sqrt_sq_gt_orig,\n    end,\n    cases a_sq_le_c_and_b_sq_le_c with a_sq_le_c b_sq_le_c,\n    have c_lt_a_sq : (↑c : ℤ) < b*b := begin\n      fapply lt_trans,\n      exact ↑((nat.sqrt c + 1) * (nat.sqrt c + 1)),\n      simp at succ_sqrt_c_sq_gt_c,\n      apply coe_preserves_lt,\n      assumption,\n      simp,\n      assumption,\n    end,\n    exfalso,\n    apply not_le_and_gt,\n    split,\n    exact b_sq_le_c,\n    exact c_lt_a_sq,\n  },\n  {\n    by_cases h : b ≤ ↑(nat.sqrt c + 1),\n    { assumption, },\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a ≤ c ∧ b*b ≤ c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have sq_succ_sqrt_lt_sq_a : (↑(nat.sqrt c) + 1) * (↑(nat.sqrt c) + 1) < b*b := begin\n      apply sq_nonneg_lt,\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        apply coe_preserves_ge,\n        rw [coe_nat_nat_nop] at succ_sqrt_ge_zero,\n        exact succ_sqrt_ge_zero,\n      },\n      {\n        have succ_sqrt_ge_zero : ↑(nat.sqrt c) + 1 ≥ 0 := begin\n          apply nat_ge_zero,\n        end,\n        fapply le_trans,\n        exact (↑(nat.sqrt c) + 1),\n        simp only [ge] at succ_sqrt_ge_zero,\n        apply coe_preserves_ge,\n        rw [coe_nat_nat_nop] at succ_sqrt_ge_zero,\n        exact succ_sqrt_ge_zero,\n        apply lt_to_le,\n        exact h,\n      },\n      {\n        exact h,\n      },\n    end,\n    have succ_sqrt_c_sq_gt_c : ((nat.sqrt c) + 1) * ((nat.sqrt c) + 1) > c := begin\n      apply succ_sqrt_sq_gt_orig,\n    end,\n    cases a_sq_le_c_and_b_sq_le_c with a_sq_le_c b_sq_le_c,\n    have c_lt_a_sq : (↑c : ℤ) < b*b := begin\n      fapply lt_trans,\n      exact ↑((nat.sqrt c + 1) * (nat.sqrt c + 1)),\n      simp at succ_sqrt_c_sq_gt_c,\n      apply coe_preserves_lt,\n      assumption,\n      simp,\n      assumption,\n    end,\n    exfalso,\n    apply not_le_and_gt,\n    split,\n    exact b_sq_le_c,\n    exact c_lt_a_sq,\n  }\nend\n\nlemma in_ball_exists_idx :\n  ∀ (p q : point) (c : ℕ⁺) (qs : list point),\n    pt_in_ball p q c qs →\n    (∃ (a b : ℤ),\n      (∥(a, b)∥ ≤ c) ∧ (p + (a, b) = q)) := sorry\n\nlemma q_in_ball_means_grid_idx_in_get_idxs :\n  ∀ (p q : point) (c : ℕ⁺) (qs : list point),\n  pt_in_ball p q c qs →\n  (get_grid_idx q) ∈ (get_idxs p c) := begin\n  intros p q c qs q_in_p_ball,\n  have exists_idx : (∃ (a b : ℤ), (∥(a, b)∥ ≤ c) ∧ (p + (a, b) = q)) := begin\n    apply in_ball_exists_idx,\n    assumption,\n  end,\n  cases exists_idx with a exists_idx,\n  cases exists_idx with b exists_idx,\n  unfold pt_in_ball at q_in_p_ball,\n  cases q_in_p_ball with q_in_qs q_ne_p_and_bded_norm,\n  cases q_ne_p_and_bded_norm with q_ne_p q_bded_norm,\n  simp [point_norm] at q_bded_norm,\n  simp [get_idxs, get_grid_idx],\n  fapply exists.intro,\n  exact a,\n  fapply exists.intro,\n  exact b,\n  split,\n  {\n    apply bounded_norm_in_hypercube,\n    exact exists_idx.left,\n  },\n  {\n    exact exists_idx.right,\n  }\nend\n\nlemma x_in_some_l_x_in_join_ls :\n  ∀ (x : point) (ls : list (list point)),\n    (∃ (l : list point), x ∈ l ∧ l ∈ ls) →\n    x ∈ ls.join := sorry\n\nlemma x_in_grid_idxs_x_in_find_res :\n  ∀ (p x : point) (g : grid_2D),\n    (get_grid_idx x ∈ get_idxs p g.c) →\n    (∃ l, (in_opt_list x l) ∧ (l ∈ (get_idxs p g.c).map g.data.find)) := sorry\n\nlemma some_l_in_ls_l_in_lift :\n  ∀ {α} (l : list α) (ls : list (option (list α))),\n    some l ∈ ls →\n    l ∈ list.map lift_option_list ls := begin\n  sorry\nend\n\nlemma get_neighbs_gets_neighbs :\n  ∀ (p : point) (g : grid_2D),\n    ∀ (x : point),\n      (pt_in_ball p x g.c g.ps) →\n      (x ∈ get_neighbs p g) := begin\n  intros p g x x_in_ball,\n  simp only [get_neighbs],\n  have grid_idx_x_in_idxs : (get_grid_idx x) ∈ (get_idxs p g.c) := begin\n    apply q_in_ball_means_grid_idx_in_get_idxs,\n    assumption,\n  end,\n  apply (list.mem_filter.mpr),\n  split,\n  {\n    apply x_in_some_l_x_in_join_ls,\n    have x_in_opt_list : (∃ l, (in_opt_list x l) ∧ (l ∈ (get_idxs p g.c).map g.data.find)) := begin\n      apply x_in_grid_idxs_x_in_find_res,\n      assumption,\n    end,\n    cases x_in_opt_list with l x_in_opt_list,\n    cases x_in_opt_list with x_in_opt_list l_in_res,\n    cases l,\n    { cases x_in_opt_list, },\n    fapply exists.intro,\n    exact l,\n    split,\n    unfold in_opt_list at x_in_opt_list,\n    assumption,\n    apply some_l_in_ls_l_in_lift,\n    assumption,\n  },\n  {\n    unfold pt_in_ball at x_in_ball,\n    exact x_in_ball.right.left,\n  },\nend\n\nlemma min_dist_pair_closest :\n  ∀ (p : point) (ps : list point),\n    ∀ (x : point),\n      (x ∈ ps) →\n      (min_dist_pair p ps ≤ some (p, x)) :=\nbegin\n  sorry\nend\n\n-- lemma min_dist_pair_includes_center :\n--   ∀ (p : point) (ps : list point),\n--     (∃ (z w : point), min_dist_pair p ps = some (z, w)) →\n--     (∃ (q : point), min_dist_pair p ps = some (p, q)) := begin\n--   sorry\n-- end\n\n-- lemma pt_in_ball_mdp_is_some :\n--   ∀ (p : point) (g : grid_2D),\n--     (∃ (x : point), pt_in_ball p x g.c g.ps) →\n--     (∃ (x : point), mdp_with p g = some (p, x)) := begin\n--   intros p g exists_x_in_ball,\n--   simp [mdp_with],\n--   cases exists_x_in_ball with x exists_x_in_ball,\n--   have x_in_neighbs : x ∈ get_neighbs p g := begin\n--     apply get_neighbs_gets_neighbs,\n--     assumption,\n--   end,\n--   have mdp_le_px : min_dist_pair p (get_neighbs p g) ≤ some (p, x) := begin\n--     apply min_dist_pair_closest,\n--     assumption,\n--   end,\n--   have mdp_is_some : ∃ (z w : point), min_dist_pair p (get_neighbs p g) = some (z, w) := begin\n--     apply option_pt_le_some_eq_some,\n--     exact mdp_le_px,\n--   end,\n--   apply min_dist_pair_includes_center,\n--   assumption,\n-- end\n\nlemma get_min_dist_pair_correct :\n  ∀ (p : point) (g : grid_2D),\n    ∀ (x : point),\n      (pt_in_ball p x g.c g.ps) →\n      ((mdp_with p g) ≤ some (p, x)) := begin\n  intros p g x x_in_ball,\n  simp [mdp_with],\n  apply min_dist_pair_closest,\n  apply get_neighbs_gets_neighbs,\n  assumption,\nend\n\nlemma min_dist_pair_in_ball :\n  ∀ (p q : point) (g : grid_2D),\n    (mdp_with p g = some (p, q)) →\n    pt_in_ball p q g.c g.ps := begin\n  sorry\nend\n\n-- lemma get_neighbs_contains_all_within_ball :\n--   ∀ (c : ℕ⁺) (ps : list point) (p q : point) (g : grid_2D),\n--     (∥ p - q ∥ ≤ c) →\n--     (q ∈ get_neighbs p g) := begin\n--   sorry\n-- end\n\n\ndef aux (g : grid_2D) : list point → option (point × point)\n| [] := none\n| (p :: ps) :=\n    let rec_res := aux ps in\n    let curr_res := mdp_with p g in\n    -- TODO figure out why we can't get decidable to work on `point_le`.\n    if point_lt' curr_res rec_res then curr_res else rec_res\n\n\n/-\nWe can only get `none` if `c` wasn't actually a valid hint.\n-/\ndef find_closest_pair\n  (c : ℕ⁺)\n  (points : list point)\n  : option (point × point) :=\n  let g := grid_points c points in\n  aux g points >>= (\n    λ pq : point × point,\n      if ∥ pq.1 - pq.2 ∥ > c\n      then none\n      else some pq\n  )\n\n\n#eval find_closest_pair ⟨3, by simp⟩ [(0, 0), (2, 0), (5, 0)]\n#eval find_closest_pair ⟨4, by simp⟩ [(0, 0), (2, 0), (5, 0)]\n#eval find_closest_pair ⟨7, by simp⟩ [(0, 0), (2, 2), (5, 0)]\n#eval find_closest_pair ⟨8, by simp⟩ [(0, 0), (2, 2), (5, 0)]\n\ndef closest_pair (p q : point) (ps : list point) : Prop :=\n  (p ∈ ps) ∧\n  (q ∈ ps) ∧\n  (p ≠ q) ∧\n  (∀ (r s : point), r ≠ s → ∥p - q∥ ≤ ∥r - s∥)\n\n/-\n  Closest pair with help\n-/\ndef cp_with_help (p q : point) (ps : list point) (c : ℕ⁺) : Prop :=\n  (closest_pair p q ps) ∧ (1 < ∥ p - q ∥) ∧ (∥ p - q ∥ ≤ c)\n\ninductive closest_pair_in_ball_union (c : ℕ⁺) (qs : list point) : option (point × point) → list point → Prop\n| no_ball : closest_pair_in_ball_union none []\n| cons_ball_no_update (xy : option (point × point)) (p : point) (ps' : list point) :\n    closest_pair_in_ball_union xy ps' →\n    (∀ (q : point),\n      pt_in_ball p q c qs →\n      (xy ≤ some (p, q))) →\n    closest_pair_in_ball_union xy (p :: ps')\n| cons_ball_update\n    (xy : option (point × point))\n    (p : point)\n    (ps' : list point)\n    (q : point) :\n    (\n      pt_in_ball p q c qs ∧\n      (∀ (x : point), (pt_in_ball p x c qs) → ∥q - p∥ ≤ ∥x - p∥) ∧\n      some (p, q) < xy\n    ) →\n    closest_pair_in_ball_union xy ps' →\n    closest_pair_in_ball_union (some (p, q)) (p :: ps')\n\n\nlemma point_lt_iff_point_lt'_eq_true :\n  ∀ (xy zw : option (point × point)),\n    xy < zw ↔ (point_lt' xy zw = true) := begin\n  intros xy zw,\n  constructor,\n  sorry,\n  sorry,\nend\n\nlemma opt_point_le_some_implies_is_some :\n  ∀ (xy : option (point × point)) (z w : point),\n    xy ≤ some (z, w) ↔ (∃ (x y : point), xy = some (x, y)) := begin\n  sorry,\nend\n\nlemma get_mdp_includes_center_pt :\n  ∀ (p : point) (g : grid_2D),\n    (∃ (q : point), (mdp_with p g) = some (p, q)) ∨\n    (mdp_with p g) = none := begin\n  sorry\nend\n\nlemma closer_than_pt_in_ball_is_in_ball :\n  ∀ (p x y : point) (c : ℕ⁺) (qs : list point),\n    pt_in_ball p y c qs →\n    some (p, x) ≤ some (p, y) →\n    pt_in_ball p x c qs := begin\n  sorry\nend\n\nlemma aux_monotonic_in_pt_list :\n  ∀ (c : ℕ⁺) (g : grid_2D) (p : point) (ps' : list point),\n    (aux g (p :: ps')) ≤ (aux g ps')\n     := begin\n  intros c qs ps' p,\n  sorry,\nend\n\nlemma cp_in_ball_union_downward_closed :\n  ∀ (c : ℕ⁺) (xy zw : option (point × point)) (qs ps : list point),\n    closest_pair_in_ball_union c qs zw ps →\n    xy ≤ zw →\n    closest_pair_in_ball_union c qs xy ps\n     := begin\n  sorry,\nend\n\nlemma pt_in_ball_subset_to_pt_in_ball :\n  ∀ (ps' ps : list point) (p q : point) (c : ℕ⁺),\n    pt_in_ball p q c ps' →\n    ps' ⊆ ps →\n    pt_in_ball p q c ps := sorry\n\n\nlemma aux_finds_closest_pair_in_ball_union:\n  ∀ (g : grid_2D),\n    -- `aux` finds the closest pair in union of balls of radius ≤ `c`\n    -- (intersected with `qs`) around all points in `ps`.\n    (∀ (ps : list point),\n      ps ⊆ g.ps →\n      closest_pair_in_ball_union g.c g.ps (aux g ps) ps) := begin\n  intros g ps ps_subseteq_qs,\n  induction ps,\n  {\n    apply closest_pair_in_ball_union.no_ball,\n  },\n  {\n    rename [ps_hd → p, ps_tl → ps'],\n    have ps'_subseteq_qs : ps' ⊆ g.ps :=\n      (list.cons_subset.mp ps_subseteq_qs).right,\n    have ih : closest_pair_in_ball_union g.c g.ps (aux g ps') ps' := ps_ih ps'_subseteq_qs,\n    clear ps_ih,\n    by_cases (\n      ∃ (q : point),\n        pt_in_ball p q g.c g.ps ∧\n        (∀ (x : point), pt_in_ball p x g.c g.ps → ∥ q - p ∥ ≤ ∥ x - p ∥) ∧\n        some (p, q) < (aux g ps')),\n    -- Case: there is a point within a ball of `p` that is closer than the\n    -- recursive result.\n    {\n      -- Load up the environment with useful facts.\n      cases h with q hq,\n      have h_min_dist_pair : ∀ (x : point), (pt_in_ball p x g.c g.ps) → ((mdp_with p g) ≤ some (p, x)) := begin\n        intros x x_in_ball,\n        apply get_min_dist_pair_correct,\n        assumption,\n      end,\n      have min_dist_pair_closer_than_q : mdp_with p g ≤ some (p, q) := begin\n        exact h_min_dist_pair q hq.left,\n      end,\n      have min_dist_pair_closer_than_rec_res : mdp_with p g < aux g ps' := begin\n        apply option_pt_le_lt_trans,\n        assumption,\n        exact hq.right.right,\n      end,\n      have min_dist_pair_closer_than_rec_res_bool :\n        point_lt'\n          (mdp_with p g)\n          (aux g ps') = true :=\n        (point_lt_iff_point_lt'_eq_true (mdp_with p g) (aux g ps')).mp min_dist_pair_closer_than_rec_res,\n      simp [aux, min_dist_pair_closer_than_rec_res_bool],\n      have md_pair_is_some: (∃ (x y : point), mdp_with p g = some (x, y)) := begin\n        exact ((opt_point_le_some_implies_is_some (mdp_with p g) p q).mp min_dist_pair_closer_than_q),\n      end,\n      cases md_pair_is_some with x md_pair_is_some',\n      cases md_pair_is_some' with y md_pair_is_some'',\n      rw [md_pair_is_some''],\n      have x_eq_p : x = p := begin\n        have md_pair_disj :\n          (∃ (z : point), mdp_with p g = some (p, z)) ∨\n          mdp_with p g = none := begin\n          exact (get_mdp_includes_center_pt p g),\n        end,\n        cases md_pair_disj,\n        {\n          cases md_pair_disj with z hz,\n          rw [md_pair_is_some''] at hz,\n          cases hz,\n          refl,\n        },\n        {\n          rw [md_pair_is_some''] at md_pair_disj,\n          cases md_pair_disj,\n        },\n      end,\n      rw [x_eq_p] at *,\n\n      fapply closest_pair_in_ball_union.cons_ball_update,\n      exact (aux g ps'),\n      {\n        constructor,\n        {\n          rw [md_pair_is_some''] at min_dist_pair_closer_than_q,\n          apply closer_than_pt_in_ball_is_in_ball,\n          exact hq.left,\n          assumption,\n        },\n        constructor,\n        {\n          intros z z_in_ball,\n          have q_closer_than_z : ∥q - p∥ ≤ ∥z - p∥ := hq.right.left z z_in_ball,\n          have y_closer_than_q : ∥y - p∥ ≤ ∥q - p∥ := begin\n            rw [md_pair_is_some''] at min_dist_pair_closer_than_q,\n            simp [has_le.le, point_le] at min_dist_pair_closer_than_q ⊢,\n            rw point_norm_symm y p,\n            rw point_norm_symm q p,\n            assumption,\n          end,\n          exact le_trans y_closer_than_q q_closer_than_z,\n        },\n        {\n          rw [md_pair_is_some''] at min_dist_pair_closer_than_q,\n          apply option_pt_le_lt_trans,\n          exact min_dist_pair_closer_than_q,\n          exact hq.right.right,\n        },\n      },\n      {\n        exact ih,\n      },\n    },\n    -- Case: there is *no* point within a ball of `p` that is closer than the\n    -- recursive result.\n    {\n      apply closest_pair_in_ball_union.cons_ball_no_update,\n      {\n        apply cp_in_ball_union_downward_closed,\n        exact ih,\n        apply aux_monotonic_in_pt_list,\n        exact g.c,\n      },\n      {\n        intros q q_in_ball,\n        have mdp_p_closest : ∀ (x : point), pt_in_ball p x g.c g.ps → (mdp_with p g) ≤ some (p, x) := begin\n          apply get_min_dist_pair_correct,\n        end,\n        -- aux ps' ≤ mdp p\n        -- intuitively, by `h`\n        have aux_ps'_le_mdp_p : aux g ps' ≤ mdp_with p g := begin\n          by_cases aux_ps'_le_mdp_p : aux g ps' ≤ mdp_with p g,\n          { assumption, },\n          {\n            have mdp_p_lt_aux_ps' : mdp_with p g < aux g ps' :=\n              (neg_le_iff_lt (aux g ps') (mdp_with p g)).mp aux_ps'_le_mdp_p,\n            have mdp_p_eq_some_p_z_or_none : (∃ (y : point), mdp_with p g = some (p, y)) ∨ (mdp_with p g) = none := get_mdp_includes_center_pt p g,\n            have mdp_p_eq_some : ∃ (z w : point), mdp_with p g = some (z, w) := begin\n               apply option_pt_le_some_eq_some,\n               apply get_min_dist_pair_correct,\n               apply pt_in_ball_subset_to_pt_in_ball,\n               exact q_in_ball,\n               refl,\n            end,\n            have mdp_p_eq_some : (∃ (y : point), mdp_with p g = some (p, y)) := begin\n              cases mdp_p_eq_some with z mdp_p_eq_some',\n              cases mdp_p_eq_some' with w mdp_p_eq_some'',\n              cases mdp_p_eq_some_p_z_or_none,\n              { assumption, },\n              {\n                 rw [mdp_p_eq_some_p_z_or_none] at mdp_p_eq_some'',\n                 contradiction,\n              },\n            end,\n            cases mdp_p_eq_some with y mdp_p_eq_some',\n            have h_premise :\n              pt_in_ball p y g.c g.ps ∧\n              (∀ (x : point), pt_in_ball p x g.c g.ps → ∥y - p∥ ≤ ∥x - p∥) ∧\n              some (p, y) < aux g ps' := begin\n                rw [mdp_p_eq_some'] at mdp_p_closest,\n                simp only [has_le.le, point_le] at mdp_p_closest ⊢,\n                rw [point_norm_sub_comm p y] at mdp_p_closest,\n                have mdp_p_closest' : ∀ (x : point), (pt_in_ball p x g.c g.ps) → (∥y - p∥.le ∥x - p∥) := begin\n                  intros x,\n                  rw [point_norm_sub_comm x p],\n                  apply mdp_p_closest,\n                end,\n                have mdp_p_in_ball : pt_in_ball p y g.c g.ps := begin\n                  apply min_dist_pair_in_ball,\n                  exact mdp_p_eq_some',\n                end,\n                rw [mdp_p_eq_some'] at mdp_p_lt_aux_ps',\n                constructor,\n                exact mdp_p_in_ball,\n                constructor,\n                exact mdp_p_closest',\n                exact mdp_p_lt_aux_ps',\n            end,\n            exfalso,\n            apply h,\n            fapply exists.intro,\n            exact y,\n            exact h_premise,\n          },\n        end,\n        -- mdp p ≤ q\n        -- intuitively, by univ property of `mdp` given by `mdp_correct` lemma\n        have mdp_p_le_q : mdp_with p g ≤ some (p, q) := begin\n          apply mdp_p_closest,\n          apply pt_in_ball_subset_to_pt_in_ball,\n          exact q_in_ball,\n          refl,\n        end,\n        -- ¬(mdp p < aux ps')\n        have mdp_not_lt_aux : ¬(point_lt'\n          (mdp_with p g)\n          (aux g ps')) := begin\n          intros mdp_p_lt_aux_ps',\n          apply not_x_le_y_and_gt_y,\n          exact aux_ps'_le_mdp_p,\n          simp [has_lt.lt],\n          exact ((point_lt_iff_point_lt' _ _).mpr mdp_p_lt_aux_ps'),\n        end,\n        simp [aux, mdp_not_lt_aux],\n        apply option_pt_le_trans,\n        exact aux_ps'_le_mdp_p,\n        exact mdp_p_le_q,\n      }\n    }\n  },\nend\n\n-- lemma cp_in_ball_union_in_ps :\n--   ∀ (c : ℕ⁺) (z w : point) (ps qs : list point),\n--     closest_pair_in_ball_union c qs (some (z, w)) ps →\n--     z ∈ ps := sorry\n\nlemma cp_in_ball_union_closer_than_all_pts_in_dist_c :\n  ∀ (c : ℕ⁺) (r s : point) (zw : option (point × point)) (ps qs : list point),\n    ps ⊆ qs →\n    r ∈ ps →\n    pt_in_ball r s c qs →\n    closest_pair_in_ball_union c qs zw ps →\n    zw ≤ some (r, s) := begin\n  intros\n    c r s zw ps qs\n    ps_subset_qs r_in_ps s_in_r_ball zw_cp_in_balls,\n  induction zw_cp_in_balls,\n  {\n    cases r_in_ps,\n  },\n  {\n    rename [\n      zw_cp_in_balls_xy → zw,\n      zw_cp_in_balls_p → p,\n      zw_cp_in_balls_ps' → ps',\n      zw_cp_in_balls_ᾰ → zw_cp_in_union_ps'_balls,\n      zw_cp_in_balls_ᾰ_1 → zw_closest_in_p_ball,\n      zw_cp_in_balls_ih → ih\n    ],\n    cases r_in_ps,\n    {\n      rw [r_in_ps] at *,\n      apply zw_closest_in_p_ball,\n      assumption,\n    },\n    {\n      have ps_decomp : p ∈ qs ∧ ps' ⊆ qs := begin\n        apply list.cons_subset.mp,\n        assumption,\n      end,\n      apply ih,\n      exact ps_decomp.right,\n      exact r_in_ps,\n    }\n  },\n  {\n    rename [\n      zw_cp_in_balls_xy → zw',\n      zw_cp_in_balls_p → p,\n      zw_cp_in_balls_ps' → ps',\n      zw_cp_in_balls_q → q,\n      zw_cp_in_balls_ᾰ → q_closest_in_p_ball_and_pq_le_zw',\n      zw_cp_in_balls_ᾰ_1 → zw_cp_in_union_ps'_balls,\n      zw_cp_in_balls_ih → ih\n    ],\n    cases r_in_ps,\n    {\n      rw [r_in_ps] at *,\n      simp [has_le.le, point_le],\n      rw [point_norm_sub_comm p q, point_norm_sub_comm p s],\n      apply q_closest_in_p_ball_and_pq_le_zw'.right.left,\n      assumption,\n    },\n    {\n      apply option_pt_lt_to_le,\n      apply option_pt_lt_le_trans,\n      exact q_closest_in_p_ball_and_pq_le_zw'.right.right,\n      have ps_decomp : p ∈ qs ∧ ps' ⊆ qs := begin\n        apply list.cons_subset.mp,\n        assumption,\n      end,\n      apply ih,\n      exact ps_decomp.right,\n      exact r_in_ps,\n    }\n  }\nend\n\nlemma some_cp_in_balls_in_pt_list_and_neq :\n  ∀ (c : ℕ⁺) (x y : point) (xy : option (point × point)) (ps : list point),\n    xy = some (x, y) →\n    closest_pair_in_ball_union c ps xy ps →\n    x ∈ ps ∧ y ∈ ps ∧ x ≠ y := sorry\n\nlemma cp_with_help_and_cp_in_balls_implies_closest_pair :\n  ∀ (c : ℕ⁺) (ps : list point) (xy : option (point × point)),\n    -- If there's a closest pair within distance `c`\n    (∃ (p q : point),\n      cp_with_help p q ps c) →\n    -- and `xy` gives the closest pair in all balls of radius ≥ `c` around\n    -- points in `ps`,\n    (closest_pair_in_ball_union c ps xy ps) →\n    -- then `xy` contains the closest pair in all `ps`.\n    ∃ (x y : point),\n      xy = some (x, y) ∧ (closest_pair x y ps) := begin\n  intros c ps xy h_cp_help h_cp_in_ball_union,\n  cases h_cp_help with p h_cp_help,\n  cases h_cp_help with q h_cp_help,\n  unfold cp_with_help closest_pair at h_cp_help,\n  have xy_leq_pq : xy ≤ some (p, q) := begin\n    fapply cp_in_ball_union_closer_than_all_pts_in_dist_c,\n    exact c,\n    exact ps,\n    exact ps,\n    refl,\n    exact h_cp_help.left.left,\n    unfold pt_in_ball,\n    repeat {split},\n    exact h_cp_help.left.right.left,\n    apply ne.symm,\n    exact h_cp_help.left.right.right.left,\n    rw [point_norm_sub_comm],\n    exact h_cp_help.right.right,\n    assumption,\n  end,\n  have xy_is_some : ∃ (x y : point), xy = some (x, y) := begin\n    apply option_pt_le_some_eq_some,\n    exact xy_leq_pq,\n  end,\n  cases xy_is_some with x xy_is_some,\n  cases xy_is_some with y xy_is_some,\n  have x_sub_y_leq_p_sub_q : ∥x - y∥ ≤ ∥p - q∥ := begin\n    rw [xy_is_some] at xy_leq_pq,\n    simp [has_le.le, point_le] at xy_leq_pq ⊢,\n    exact xy_leq_pq,\n  end,\n  have xy_closest : closest_pair x y ps := begin\n    unfold closest_pair,\n    have xy_in_pt_list_and_neq : x ∈ ps ∧ y ∈ ps ∧ x ≠ y := begin\n      apply some_cp_in_balls_in_pt_list_and_neq,\n      exact xy_is_some,\n      exact h_cp_in_ball_union,\n    end,\n    repeat {split},\n    { exact xy_in_pt_list_and_neq.left, },\n    { exact xy_in_pt_list_and_neq.right.left, },\n    { exact xy_in_pt_list_and_neq.right.right, },\n    {\n      intros r s r_neq_s,\n      have pq_le_rs : ∥p - q∥ ≤ ∥r - s∥ := begin\n        apply h_cp_help.left.right.right.right,\n        exact r_neq_s,\n      end,\n      apply int_le_trans,\n      exact x_sub_y_leq_p_sub_q,\n      exact pq_le_rs,\n    }\n  end,\n  fapply exists.intro,\n  exact x,\n  fapply exists.intro,\n  exact y,\n  exact ⟨xy_is_some, xy_closest⟩,\nend\n\n\nlemma aux_gives_closest_pair:\n  ∀ (g : grid_2D),\n    (∃ (p q : point),\n      cp_with_help p q g.ps g.c) →\n    (∃ (p q : point),\n      aux g g.ps = some (p, q)\n      ∧ closest_pair p q g.ps) := begin\n  intros g cp_help,\n  apply cp_with_help_and_cp_in_balls_implies_closest_pair,\n  assumption,\n  apply aux_finds_closest_pair_in_ball_union,\n  simp,\nend\n\nlemma grid_pts_dot_c_with_c_eq_c :\n  ∀ (c : ℕ⁺) (ps : list point),\n    (grid_points c ps).c = c := sorry\n\nlemma grid_pts_dot_ps_with_ps_eq_ps :\n  ∀ (c : ℕ⁺) (ps : list point),\n    (grid_points c ps).ps = ps := sorry\n\ntheorem find_closest_pair_correct :\n  ∀ (c : ℕ⁺) (ps : list point),\n    -- If there's a closest pair within distance `c`\n    (∃ (p q : point),\n      cp_with_help p q ps c) →\n    -- then our algorithm finds a closest pair.\n    (∃ (p q : point),\n      (find_closest_pair c ps) = some (p, q) ∧\n      closest_pair p q ps) := begin\n  intros c ps exists_pair,\n  have aux_gives_closest :\n    (∃ (p q : point),\n        aux (grid_points c ps) ps = some (p, q)\n        ∧ closest_pair p q ps) := begin\n    have expand_ps : aux (grid_points c ps) ps = aux (grid_points c ps) (grid_points c ps).ps := begin\n      congr,\n      symmetry,\n      apply grid_pts_dot_ps_with_ps_eq_ps,\n    end,\n    rw [expand_ps],\n    have dumb_rw :\n      (∃ (p q : point), aux (grid_points c ps) (grid_points c ps).ps = some (p, q) ∧ closest_pair p q (grid_points c ps).ps) →\n      (∃ (p q : point), aux (grid_points c ps) (grid_points c ps).ps = some (p, q) ∧ closest_pair p q ps) := begin\n      intros h,\n      cases h with p h',\n      cases h' with q h'',\n      fapply exists.intro,\n      exact p,\n      fapply exists.intro,\n      exact q,\n      constructor,\n      exact h''.left,\n      rw [grid_pts_dot_ps_with_ps_eq_ps] at h'',\n      exact h''.right,\n    end,\n    apply dumb_rw,\n    apply aux_gives_closest_pair,\n    rw [grid_pts_dot_ps_with_ps_eq_ps, grid_pts_dot_c_with_c_eq_c],\n    assumption,\n  end,\n  cases aux_gives_closest with p aux_gives_closest,\n  cases aux_gives_closest with q aux_gives_closest,\n\n  fapply exists.intro,\n  exact p,\n  fapply exists.intro,\n  exact q,\n\n  simp [find_closest_pair],\n  apply and.intro,\n  {\n    fapply exists.intro,\n    exact p,\n    fapply exists.intro,\n    exact q,\n    apply and.intro,\n    exact aux_gives_closest.left,\n\n    have aux_closest_dist_leq_c : (∥p - q∥ ≤ ↑c) := begin\n      cases exists_pair with p' exists_pair,\n      cases exists_pair with q' exists_pair,\n      have aux_closer_than_cp : ∥p - q∥ ≤ ∥p' - q'∥ := begin\n        unfold closest_pair at aux_gives_closest,\n        apply aux_gives_closest.right.right.right.right,\n        exact exists_pair.left.right.right.left,\n      end,\n      apply int_le_trans,\n      exact aux_closer_than_cp,\n      exact exists_pair.right.right,\n    end,\n\n    by_cases (↑c < ∥p - q∥),\n\n    rw [←coe_to_ℕ_then_ℤ_eq_coe_to_ℤ] at h,\n    simp [h],\n    fapply not_leq_and_gt,\n    exact (p - q),\n    exact c,\n    apply and.intro,\n    exact aux_closest_dist_leq_c,\n    exact h,\n    rw [←coe_to_ℕ_then_ℤ_eq_coe_to_ℤ] at h,\n    simp [h],\n  },\n  {\n    exact aux_gives_closest.right,\n  }\nend\n\n", "meta": {"author": "weberlo", "repo": "verified-gridding", "sha": "d034c061a1735c8cb41a8ea493ec5d770767e6cd", "save_path": "github-repos/lean/weberlo-verified-gridding", "path": "github-repos/lean/weberlo-verified-gridding/verified-gridding-d034c061a1735c8cb41a8ea493ec5d770767e6cd/src/core/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.48194127630986816}}
{"text": "/-\nCopyright (c) 2020 Fox Thomson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fox Thomson\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.set_theory.game.winner\nimport Mathlib.tactic.nth_rewrite.default\nimport Mathlib.tactic.equiv_rw\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n# Basic definitions about impartial (pre-)games\n\nWe will define an impartial game, one in which left and right can make exactly the same moves.\nOur definition differs slightly by saying that the game is always equivalent to its negative,\nno matter what moves are played. This allows for games such as poker-nim to be classifed as\nimpartial.\n-/\n\nnamespace pgame\n\n\n/-- The definition for a impartial game, defined using Conway induction -/\ndef impartial : pgame → Prop :=\n  sorry\n\ntheorem impartial_def {G : pgame} : impartial G ↔\n  equiv G (-G) ∧ (∀ (i : left_moves G), impartial (move_left G i)) ∧ ∀ (j : right_moves G), impartial (move_right G j) := sorry\n\nnamespace impartial\n\n\nprotected instance impartial_zero : impartial 0 := sorry\n\ntheorem neg_equiv_self (G : pgame) [h : impartial G] : equiv G (-G) :=\n  and.left (iff.mp impartial_def h)\n\nprotected instance move_left_impartial {G : pgame} [h : impartial G] (i : left_moves G) : impartial (move_left G i) :=\n  and.left (and.right (iff.mp impartial_def h)) i\n\nprotected instance move_right_impartial {G : pgame} [h : impartial G] (j : right_moves G) : impartial (move_right G j) :=\n  and.right (and.right (iff.mp impartial_def h)) j\n\nprotected instance impartial_add (G : pgame) (H : pgame) [impartial G] [impartial H] : impartial (G + H) :=\n  sorry\n\nprotected instance impartial_neg (G : pgame) [impartial G] : impartial (-G) :=\n  sorry\n\ntheorem winner_cases (G : pgame) [impartial G] : first_loses G ∨ first_wins G := sorry\n\ntheorem not_first_wins (G : pgame) [impartial G] : ¬first_wins G ↔ first_loses G := sorry\n\ntheorem not_first_loses (G : pgame) [impartial G] : ¬first_loses G ↔ first_wins G :=\n  iff.symm (iff.mp iff_not_comm (iff.symm (not_first_wins G)))\n\ntheorem add_self (G : pgame) [impartial G] : first_loses (G + G) :=\n  iff.mpr first_loses_is_zero (equiv_trans (add_congr (neg_equiv_self G) (equiv_refl G)) add_left_neg_equiv)\n\ntheorem equiv_iff_sum_first_loses (G : pgame) (H : pgame) [impartial G] [impartial H] : equiv G H ↔ first_loses (G + H) := sorry\n\ntheorem le_zero_iff {G : pgame} [impartial G] : G ≤ 0 ↔ 0 ≤ G :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (G ≤ 0 ↔ 0 ≤ G)) (propext le_zero_iff_zero_le_neg)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (0 ≤ -G ↔ 0 ≤ G)) (propext (le_congr (equiv_refl 0) (neg_equiv_self G)))))\n      (iff.refl (0 ≤ -G)))\n\ntheorem lt_zero_iff {G : pgame} [impartial G] : G < 0 ↔ 0 < G := sorry\n\ntheorem first_loses_symm (G : pgame) [impartial G] : first_loses G ↔ G ≤ 0 :=\n  { mp := and.left, mpr := fun (h : G ≤ 0) => { left := h, right := iff.mp le_zero_iff h } }\n\ntheorem first_wins_symm (G : pgame) [impartial G] : first_wins G ↔ G < 0 :=\n  { mp := and.right, mpr := fun (h : G < 0) => { left := iff.mp lt_zero_iff h, right := h } }\n\ntheorem first_loses_symm' (G : pgame) [impartial G] : first_loses G ↔ 0 ≤ G :=\n  { mp := and.right, mpr := fun (h : 0 ≤ G) => { left := iff.mpr le_zero_iff h, right := h } }\n\ntheorem first_wins_symm' (G : pgame) [impartial G] : first_wins G ↔ 0 < G :=\n  { mp := and.left, mpr := fun (h : 0 < G) => { left := h, right := iff.mpr lt_zero_iff h } }\n\ntheorem no_good_left_moves_iff_first_loses (G : pgame) [impartial G] : (∀ (i : left_moves G), first_wins (move_left G i)) ↔ first_loses G := sorry\n\ntheorem no_good_right_moves_iff_first_loses (G : pgame) [impartial G] : (∀ (j : right_moves G), first_wins (move_right G j)) ↔ first_loses G := sorry\n\ntheorem good_left_move_iff_first_wins (G : pgame) [impartial G] : (∃ (i : left_moves G), first_loses (move_left G i)) ↔ first_wins G := sorry\n\ntheorem good_right_move_iff_first_wins (G : pgame) [impartial G] : (∃ (j : right_moves G), first_loses (move_right G j)) ↔ first_wins G := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/set_theory/game/impartial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4819412703666422}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.concrete_category.bundled_hom\nimport algebra.punit_instances\nimport category_theory.functor.reflects_isomorphisms\n\n/-!\n# Category instances for monoid, add_monoid, comm_monoid, and add_comm_monoid.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe introduce the bundled categories:\n* `Mon`\n* `AddMon`\n* `CommMon`\n* `AddCommMon`\nalong with the relevant forgetful functors between them.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of monoids and monoid morphisms. -/\n@[to_additive AddMon]\ndef Mon : Type (u+1) := bundled monoid\n\n/-- The category of additive monoids and monoid morphisms. -/\nadd_decl_doc AddMon\n\nnamespace Mon\n\n/-- `monoid_hom` doesn't actually assume associativity. This alias is needed to make the category\ntheory machinery work. -/\n@[to_additive \"`add_monoid_hom` doesn't actually assume associativity. This alias is needed to make\nthe category theory machinery work.\"]\nabbreviation assoc_monoid_hom (M N : Type*) [monoid M] [monoid N] := monoid_hom M N\n\n@[to_additive]\ninstance bundled_hom : bundled_hom assoc_monoid_hom :=\n⟨λ M N [monoid M] [monoid N], by exactI @monoid_hom.to_fun M N _ _,\n λ M [monoid M], by exactI @monoid_hom.id M _,\n λ M N P [monoid M] [monoid N] [monoid P], by exactI @monoid_hom.comp M N P _ _ _,\n λ M N [monoid M] [monoid N], by exactI @monoid_hom.coe_inj M N _ _⟩\n\nattribute [derive [large_category, concrete_category]] Mon\nattribute [to_additive] Mon.large_category Mon.concrete_category\n\n@[to_additive] instance : has_coe_to_sort Mon Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `Mon` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [monoid M] : Mon := bundled.of M\n\n/-- Construct a bundled `Mon` from the underlying type and typeclass. -/\nadd_decl_doc AddMon.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `Mon`. -/\n@[to_additive] def of_hom {X Y : Type u} [monoid X] [monoid Y] (f : X →* Y) :\n  of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddMon`. -/\nadd_decl_doc AddMon.of_hom\n\n@[simp] lemma of_hom_apply {X Y : Type u} [monoid X] [monoid Y] (f : X →* Y)\n  (x : X) : of_hom f x = f x := rfl\n\n@[to_additive]\ninstance : inhabited Mon :=\n-- The default instance for `monoid punit` is derived via `punit.comm_ring`,\n-- which breaks to_additive.\n⟨@of punit $ @group.to_monoid _ $ @comm_group.to_group _ punit.comm_group⟩\n\n@[to_additive]\ninstance (M : Mon) : monoid M := M.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [monoid R] : (Mon.of R : Type u) = R := rfl\n\n@[to_additive] instance {G : Type*} [group G] : group (Mon.of G) := by assumption\n\nend Mon\n\n/-- The category of commutative monoids and monoid morphisms. -/\n@[to_additive AddCommMon]\ndef CommMon : Type (u+1) := bundled comm_monoid\n\n/-- The category of additive commutative monoids and monoid morphisms. -/\nadd_decl_doc AddCommMon\n\nnamespace CommMon\n\n@[to_additive]\ninstance : bundled_hom.parent_projection comm_monoid.to_monoid := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommMon\nattribute [to_additive] CommMon.large_category CommMon.concrete_category\n\n@[to_additive] instance : has_coe_to_sort CommMon Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `CommMon` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [comm_monoid M] : CommMon := bundled.of M\n\n/-- Construct a bundled `AddCommMon` from the underlying type and typeclass. -/\nadd_decl_doc AddCommMon.of\n\n@[to_additive]\ninstance : inhabited CommMon :=\n-- The default instance for `comm_monoid punit` is derived via `punit.comm_ring`,\n-- which breaks to_additive.\n⟨@of punit $ @comm_group.to_comm_monoid _ punit.comm_group⟩\n\n@[to_additive]\ninstance (M : CommMon) : comm_monoid M := M.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [comm_monoid R] : (CommMon.of R : Type u) = R := rfl\n\n@[to_additive has_forget_to_AddMon]\ninstance has_forget_to_Mon : has_forget₂ CommMon Mon := bundled_hom.forget₂ _ _\n\n@[to_additive] instance : has_coe CommMon.{u} Mon.{u} :=\n{ coe := (forget₂ CommMon Mon).obj, }\n\nend CommMon\n\n-- We verify that the coercions of morphisms to functions work correctly:\nexample {R S : Mon}     (f : R ⟶ S) : (R : Type) → (S : Type) := f\nexample {R S : CommMon} (f : R ⟶ S) : (R : Type) → (S : Type) := f\n\n-- We verify that when constructing a morphism in `CommMon`,\n-- when we construct the `to_fun` field, the types are presented as `↥R`,\n-- rather than `R.α` or (as we used to have) `↥(bundled.map comm_monoid.to_monoid R)`.\nexample (R : CommMon.{u}) : R ⟶ R :=\n{ to_fun := λ x,\n  begin\n    match_target (R : Type u),\n    match_hyp x : (R : Type u),\n    exact x * x\n  end ,\n  map_one' := by simp,\n  map_mul' := λ x y,\n  begin rw [mul_assoc x y (x * y), ←mul_assoc y x y, mul_comm y x, mul_assoc, mul_assoc], end, }\n\nvariables {X Y : Type u}\n\nsection\nvariables [monoid X] [monoid Y]\n\n/-- Build an isomorphism in the category `Mon` from a `mul_equiv` between `monoid`s. -/\n@[to_additive add_equiv.to_AddMon_iso \"Build an isomorphism in the category `AddMon` from\nan `add_equiv` between `add_monoid`s.\", simps]\ndef mul_equiv.to_Mon_iso (e : X ≃* Y) : Mon.of X ≅ Mon.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\nend\n\nsection\nvariables [comm_monoid X] [comm_monoid Y]\n\n/-- Build an isomorphism in the category `CommMon` from a `mul_equiv` between `comm_monoid`s. -/\n@[to_additive add_equiv.to_AddCommMon_iso \"Build an isomorphism in the category `AddCommMon`\nfrom an `add_equiv` between `add_comm_monoid`s.\", simps]\ndef mul_equiv.to_CommMon_iso (e : X ≃* Y) : CommMon.of X ≅ CommMon.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\nend\n\nnamespace category_theory.iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Mon`. -/\n@[to_additive AddMon_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism in the category\n`AddMon`.\"]\ndef Mon_iso_to_mul_equiv {X Y : Mon} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\n/-- Build a `mul_equiv` from an isomorphism in the category `CommMon`. -/\n@[to_additive \"Build an `add_equiv` from an isomorphism in the category\n`AddCommMon`.\"]\ndef CommMon_iso_to_mul_equiv {X Y : CommMon} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\nend category_theory.iso\n\n/-- multiplicative equivalences between `monoid`s are the same as (isomorphic to) isomorphisms\nin `Mon` -/\n@[to_additive add_equiv_iso_AddMon_iso \"additive equivalences between `add_monoid`s are the same\nas (isomorphic to) isomorphisms in `AddMon`\"]\ndef mul_equiv_iso_Mon_iso {X Y : Type u} [monoid X] [monoid Y] :\n  (X ≃* Y) ≅ (Mon.of X ≅ Mon.of Y) :=\n{ hom := λ e, e.to_Mon_iso,\n  inv := λ i, i.Mon_iso_to_mul_equiv, }\n\n/-- multiplicative equivalences between `comm_monoid`s are the same as (isomorphic to) isomorphisms\nin `CommMon` -/\n@[to_additive add_equiv_iso_AddCommMon_iso \"additive equivalences between `add_comm_monoid`s are\nthe same as (isomorphic to) isomorphisms in `AddCommMon`\"]\ndef mul_equiv_iso_CommMon_iso {X Y : Type u} [comm_monoid X] [comm_monoid Y] :\n  (X ≃* Y) ≅ (CommMon.of X ≅ CommMon.of Y) :=\n{ hom := λ e, e.to_CommMon_iso,\n  inv := λ i, i.CommMon_iso_to_mul_equiv, }\n\n@[to_additive]\ninstance Mon.forget_reflects_isos : reflects_isomorphisms (forget Mon.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Mon).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Mon_iso).1⟩,\n  end }\n\n@[to_additive]\ninstance CommMon.forget_reflects_isos : reflects_isomorphisms (forget CommMon.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommMon).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommMon_iso).1⟩,\n  end }\n\n/-!\nOnce we've shown that the forgetful functors to type reflect isomorphisms,\nwe automatically obtain that the `forget₂` functors between our concrete categories\nreflect isomorphisms.\n-/\nexample : reflects_isomorphisms (forget₂ CommMon Mon) := by apply_instance\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/category/Mon/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.7025300636233415, "lm_q1q2_score": 0.48190011426930196}}
{"text": "/-\nCopyright (c) 2018 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Scott Morrison\n-/\nimport category_theory.opposites\n\n/-!\n# Morphisms from equations between objects.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWhen working categorically, sometimes one encounters an equation `h : X = Y` between objects.\n\nYour initial aversion to this is natural and appropriate:\nyou're in for some trouble, and if there is another way to approach the problem that won't\nrely on this equality, it may be worth pursuing.\n\nYou have two options:\n1. Use the equality `h` as one normally would in Lean (e.g. using `rw` and `subst`).\n   This may immediately cause difficulties, because in category theory everything is dependently\n   typed, and equations between objects quickly lead to nasty goals with `eq.rec`.\n2. Promote `h` to a morphism using `eq_to_hom h : X ⟶ Y`, or `eq_to_iso h : X ≅ Y`.\n\nThis file introduces various `simp` lemmas which in favourable circumstances\nresult in the various `eq_to_hom` morphisms to drop out at the appropriate moment!\n-/\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n-- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen opposite\n\nvariables {C : Type u₁} [category.{v₁} C]\n\n/--\nAn equality `X = Y` gives us a morphism `X ⟶ Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `𝟙 _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_hom {X Y : C} (p : X = Y) : X ⟶ Y := by rw p; exact 𝟙 _\n\n@[simp] lemma eq_to_hom_refl (X : C) (p : X = X) : eq_to_hom p = 𝟙 X := rfl\n@[simp, reassoc] lemma eq_to_hom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) :\n  eq_to_hom p ≫ eq_to_hom q = eq_to_hom (p.trans q) :=\nby { cases p, cases q, simp, }\n\nlemma comp_eq_to_hom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') :\n  f ≫ eq_to_hom p = g ↔ f = g ≫ eq_to_hom p.symm :=\n{ mp := λ h, h ▸ by simp,\n  mpr := λ h, by simp [eq_whisker h (eq_to_hom p)] }\n\nlemma eq_to_hom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) :\n  eq_to_hom p ≫ g = f ↔ g = eq_to_hom p.symm ≫ f :=\n{ mp := λ h, h ▸ by simp,\n  mpr := λ h, h ▸ by simp [whisker_eq _ h] }\n\n/--\nIf we (perhaps unintentionally) perform equational rewriting on\nthe source object of a morphism,\nwe can replace the resulting `_.mpr f` term by a composition with an `eq_to_hom`.\n\nIt may be advisable to introduce any necessary `eq_to_hom` morphisms manually,\nrather than relying on this lemma firing.\n-/\n@[simp]\nlemma congr_arg_mpr_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) :\n  (congr_arg (λ W : C, W ⟶ Z) p).mpr q = eq_to_hom p ≫ q :=\nby { cases p, simp, }\n\n/--\nIf we (perhaps unintentionally) perform equational rewriting on\nthe target object of a morphism,\nwe can replace the resulting `_.mpr f` term by a composition with an `eq_to_hom`.\n\nIt may be advisable to introduce any necessary `eq_to_hom` morphisms manually,\nrather than relying on this lemma firing.\n-/\n@[simp]\nlemma congr_arg_mpr_hom_right {X Y Z : C} (p : X ⟶ Y) (q : Z = Y) :\n  (congr_arg (λ W : C, X ⟶ W) q).mpr p = p ≫ eq_to_hom q.symm :=\nby { cases q, simp, }\n\n/--\nAn equality `X = Y` gives us an isomorphism `X ≅ Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `iso.refl _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_iso {X Y : C} (p : X = Y) : X ≅ Y :=\n⟨eq_to_hom p, eq_to_hom p.symm, by simp, by simp⟩\n\n@[simp] lemma eq_to_iso.hom {X Y : C} (p : X = Y) : (eq_to_iso p).hom = eq_to_hom p :=\nrfl\n@[simp] lemma eq_to_iso.inv {X Y : C} (p : X = Y) : (eq_to_iso p).inv = eq_to_hom p.symm :=\nrfl\n\n@[simp] \n\n@[simp] lemma eq_to_hom_op {X Y : C} (h : X = Y) :\n  (eq_to_hom h).op = eq_to_hom (congr_arg op h.symm) :=\nby { cases h, refl, }\n\n@[simp] lemma eq_to_hom_unop {X Y : Cᵒᵖ} (h : X = Y) :\n  (eq_to_hom h).unop = eq_to_hom (congr_arg unop h.symm) :=\nby { cases h, refl, }\n\ninstance {X Y : C} (h : X = Y) : is_iso (eq_to_hom h) := is_iso.of_iso (eq_to_iso h)\n\n@[simp] lemma inv_eq_to_hom {X Y : C} (h : X = Y) : inv (eq_to_hom h) = eq_to_hom h.symm :=\nby { ext, simp, }\n\nvariables {D : Type u₂} [category.{v₂} D]\n\nnamespace functor\n\n/-- Proving equality between functors. This isn't an extensionality lemma,\n  because usually you don't really want to do this. -/\nlemma ext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ X Y f, F.map f = eq_to_hom (h_obj X) ≫ G.map f ≫ eq_to_hom (h_obj Y).symm) :\n  F = G :=\nbegin\n  cases F with F_obj _ _ _, cases G with G_obj _ _ _,\n  obtain rfl : F_obj = G_obj, by { ext X, apply h_obj },\n  congr,\n  funext X Y f,\n  simpa using h_map X Y f\nend\n\n/-- Two morphisms are conjugate via eq_to_hom if and only if they are heterogeneously equal. -/\nlemma conj_eq_to_hom_iff_heq {W X Y Z : C} (f : W ⟶ X) (g : Y ⟶ Z) (h : W = Y) (h' : X = Z) :\n  f = eq_to_hom h ≫ g ≫ eq_to_hom h'.symm ↔ f == g :=\nby { cases h, cases h', simp }\n\n/-- Proving equality between functors using heterogeneous equality. -/\nlemma hext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ X Y (f : X ⟶ Y), F.map f == G.map f) : F = G :=\nfunctor.ext h_obj (λ _ _ f,\n  (conj_eq_to_hom_iff_heq _ _ (h_obj _) (h_obj _)).2 $ h_map _ _ f)\n\n-- Using equalities between functors.\n\nlemma congr_obj {F G : C ⥤ D} (h : F = G) (X) : F.obj X = G.obj X :=\nby subst h\n\nlemma congr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) :\n  F.map f = eq_to_hom (congr_obj h X) ≫ G.map f ≫ eq_to_hom (congr_obj h Y).symm :=\nby subst h; simp\n\nlemma congr_inv_of_congr_hom (F G : C ⥤ D) {X Y : C} (e : X ≅ Y)\n  (hX : F.obj X = G.obj X) (hY : F.obj Y = G.obj Y)\n  (h₂ : F.map e.hom = eq_to_hom (by rw hX) ≫ G.map e.hom ≫ eq_to_hom (by rw hY)) :\nF.map e.inv = eq_to_hom (by rw hY) ≫ G.map e.inv ≫ eq_to_hom (by rw hX) :=\nby simp only [← is_iso.iso.inv_hom e, functor.map_inv, h₂, is_iso.inv_comp,\n  inv_eq_to_hom, category.assoc]\n\nlemma congr_map (F : C ⥤ D) {X Y : C} {f g : X ⟶ Y} (h : f = g) :\n  F.map f = F.map g := by rw h\n\nsection heq\n\n/- Composition of functors and maps w.r.t. heq -/\n\nvariables {E : Type u₃} [category.{v₃} E] {F G : C ⥤ D} {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z}\n\nlemma map_comp_heq (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y) (hz : F.obj Z = G.obj Z)\n  (hf : F.map f == G.map f) (hg : F.map g == G.map g) : F.map (f ≫ g) == G.map (f ≫ g) :=\nby { rw [F.map_comp, G.map_comp], congr' }\n\nlemma map_comp_heq' (hobj : ∀ X : C, F.obj X = G.obj X)\n  (hmap : ∀ {X Y} (f : X ⟶ Y), F.map f == G.map f) :\n  F.map (f ≫ g) == G.map (f ≫ g) :=\nby rw functor.hext hobj (λ _ _, hmap)\n\nlemma precomp_map_heq (H : E ⥤ C)\n  (hmap : ∀ {X Y} (f : X ⟶ Y), F.map f == G.map f) {X Y : E} (f : X ⟶ Y) :\n  (H ⋙ F).map f == (H ⋙ G).map f := hmap _\n\nlemma postcomp_map_heq (H : D ⥤ E) (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y)\n  (hmap : F.map f == G.map f) : (F ⋙ H).map f == (G ⋙ H).map f :=\nby { dsimp, congr' }\n\nlemma postcomp_map_heq' (H : D ⥤ E) (hobj : ∀ X : C, F.obj X = G.obj X)\n  (hmap : ∀ {X Y} (f : X ⟶ Y), F.map f == G.map f) :\n  (F ⋙ H).map f == (G ⋙ H).map f :=\nby rw functor.hext hobj (λ _ _, hmap)\n\nlemma hcongr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) : F.map f == G.map f :=\nby subst h\n\nend heq\n\nend functor\n\n/--\nThis is not always a good idea as a `@[simp]` lemma,\nas we lose the ability to use results that interact with `F`,\ne.g. the naturality of a natural transformation.\n\nIn some files it may be appropriate to use `local attribute [simp] eq_to_hom_map`, however.\n-/\nlemma eq_to_hom_map (F : C ⥤ D) {X Y : C} (p : X = Y) :\n  F.map (eq_to_hom p) = eq_to_hom (congr_arg F.obj p) :=\nby cases p; simp\n\n/--\nSee the note on `eq_to_hom_map` regarding using this as a `simp` lemma.\n-/\nlemma eq_to_iso_map (F : C ⥤ D) {X Y : C} (p : X = Y) :\n  F.map_iso (eq_to_iso p) = eq_to_iso (congr_arg F.obj p) :=\nby ext; cases p; simp\n\n@[simp] lemma eq_to_hom_app {F G : C ⥤ D} (h : F = G) (X : C) :\n  (eq_to_hom h : F ⟶ G).app X = eq_to_hom (functor.congr_obj h X) :=\nby subst h; refl\n\nlemma nat_trans.congr {F G : C ⥤ D} (α : F ⟶ G) {X Y : C} (h : X = Y) :\n  α.app X = F.map (eq_to_hom h) ≫ α.app Y ≫ G.map (eq_to_hom h.symm) :=\nby { rw [α.naturality_assoc], simp [eq_to_hom_map], }\n\nlemma eq_conj_eq_to_hom {X Y : C} (f : X ⟶ Y) :\n  f = eq_to_hom rfl ≫ f ≫ eq_to_hom rfl :=\nby simp only [category.id_comp, eq_to_hom_refl, category.comp_id]\n\nlemma dcongr_arg {ι : Type*} {F G : ι → C} (α : ∀ i, F i ⟶ G i) {i j : ι} (h : i = j) :\n  α i = eq_to_hom (congr_arg F h) ≫ α j ≫ eq_to_hom (congr_arg G h.symm) :=\nby { subst h, simp }\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/eq_to_hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.4819001099971153}}
{"text": "/-\nCopyright (c) 2019 Amelia Livingston. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Amelia Livingston, Jireh Loreaux\n\n! This file was ported from Lean 3 source module algebra.hom.ring\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GroupWithZero.InjSurj\nimport Mathbin.Algebra.Ring.Basic\nimport Mathbin.Algebra.Divisibility.Basic\nimport Mathbin.Data.Pi.Algebra\nimport Mathbin.Algebra.Hom.Units\nimport Mathbin.Data.Set.Image\n\n/-!\n# Homomorphisms of semirings and rings\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines bundled homomorphisms of (non-unital) semirings and rings. As with monoid and\ngroups, we use the same structure `ring_hom a β`, a.k.a. `α →+* β`, for both types of homomorphisms.\n\nThe unbundled homomorphisms are defined in `deprecated.ring`. They are deprecated and the plan is to\nslowly remove them from mathlib.\n\n## Main definitions\n\n* `non_unital_ring_hom`: Non-unital (semi)ring homomorphisms. Additive monoid homomorphism which\n  preserve multiplication.\n* `ring_hom`: (Semi)ring homomorphisms. Monoid homomorphisms which are also additive monoid\n  homomorphism.\n\n## Notations\n\n* `→ₙ+*`: Non-unital (semi)ring homs\n* `→+*`: (Semi)ring homs\n\n## Implementation notes\n\n* There's a coercion from bundled homs to fun, and the canonical notation is to\n  use the bundled hom as a function via this coercion.\n\n* There is no `semiring_hom` -- the idea is that `ring_hom` is used.\n  The constructor for a `ring_hom` between semirings needs a proof of `map_zero`,\n  `map_one` and `map_add` as well as `map_mul`; a separate constructor\n  `ring_hom.mk'` will construct ring homs between rings from monoid homs given\n  only a proof that addition is preserved.\n\n## Tags\n\n`ring_hom`, `semiring_hom`\n-/\n\n\nopen Function\n\nvariable {F α β γ : Type _}\n\n#print NonUnitalRingHom /-\n/-- Bundled non-unital semiring homomorphisms `α →ₙ+* β`; use this for bundled non-unital ring\nhomomorphisms too.\n\nWhen possible, instead of parametrizing results over `(f : α →ₙ+* β)`,\nyou should parametrize over `(F : Type*) [non_unital_ring_hom_class F α β] (f : F)`.\n\nWhen you extend this structure, make sure to extend `non_unital_ring_hom_class`. -/\nstructure NonUnitalRingHom (α β : Type _) [NonUnitalNonAssocSemiring α]\n  [NonUnitalNonAssocSemiring β] extends α →ₙ* β, α →+ β\n#align non_unital_ring_hom NonUnitalRingHom\n-/\n\n-- mathport name: «expr →ₙ+* »\ninfixr:25 \" →ₙ+* \" => NonUnitalRingHom\n\n/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as a semigroup\nhomomorphism `α →ₙ* β`. The `simp`-normal form is `(f : α →ₙ* β)`. -/\nadd_decl_doc NonUnitalRingHom.toMulHom\n\n/-- Reinterpret a non-unital ring homomorphism `f : α →ₙ+* β` as an additive\nmonoid homomorphism `α →+ β`. The `simp`-normal form is `(f : α →+ β)`. -/\nadd_decl_doc NonUnitalRingHom.toAddMonoidHom\n\nsection NonUnitalRingHomClass\n\n#print NonUnitalRingHomClass /-\n/-- `non_unital_ring_hom_class F α β` states that `F` is a type of non-unital (semi)ring\nhomomorphisms. You should extend this class when you extend `non_unital_ring_hom`. -/\nclass NonUnitalRingHomClass (F : Type _) (α β : outParam (Type _)) [NonUnitalNonAssocSemiring α]\n  [NonUnitalNonAssocSemiring β] extends MulHomClass F α β, AddMonoidHomClass F α β\n#align non_unital_ring_hom_class NonUnitalRingHomClass\n-/\n\nvariable [NonUnitalNonAssocSemiring α] [NonUnitalNonAssocSemiring β] [NonUnitalRingHomClass F α β]\n\ninstance : CoeTC F (α →ₙ+* β) :=\n  ⟨fun f =>\n    { toFun := f\n      map_zero' := map_zero f\n      map_mul' := map_mul f\n      map_add' := map_add f }⟩\n\nend NonUnitalRingHomClass\n\nnamespace NonUnitalRingHom\n\nsection coe\n\n/-!\nThroughout this section, some `semiring` arguments are specified with `{}` instead of `[]`.\nSee note [implicit instance arguments].\n-/\n\n\nvariable {rα : NonUnitalNonAssocSemiring α} {rβ : NonUnitalNonAssocSemiring β}\n\ninclude rα rβ\n\ninstance : NonUnitalRingHomClass (α →ₙ+* β) α β\n    where\n  coe := NonUnitalRingHom.toFun\n  coe_injective' f g h := by cases f <;> cases g <;> congr\n  map_add := NonUnitalRingHom.map_add'\n  map_zero := NonUnitalRingHom.map_zero'\n  map_mul := NonUnitalRingHom.map_mul'\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : CoeFun (α →ₙ+* β) fun _ => α → β :=\n  ⟨NonUnitalRingHom.toFun⟩\n\n/- warning: non_unital_ring_hom.to_fun_eq_coe clashes with [anonymous] -> [anonymous]\nwarning: non_unital_ring_hom.to_fun_eq_coe -> [anonymous] is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (α -> β) (NonUnitalRingHom.toFun.{u1, u2} α β rα rβ f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}}, (Nat -> α -> β) -> Nat -> (List.{u1} α) -> (List.{u2} β)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.to_fun_eq_coe [anonymous]ₓ'. -/\n@[simp]\ntheorem [anonymous] (f : α →ₙ+* β) : f.toFun = f :=\n  rfl\n#align non_unital_ring_hom.to_fun_eq_coe [anonymous]\n\n/- warning: non_unital_ring_hom.coe_mk clashes with [anonymous] -> [anonymous]\nwarning: non_unital_ring_hom.coe_mk -> [anonymous] is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : α -> β) (h₁ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (f x) (f y))) (h₂ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))))))) (h₃ : forall (x : α) (y : α), Eq.{succ u2} β (f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))) (f x) (f y))), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) (NonUnitalRingHom.mk.{u1, u2} α β rα rβ f h₁ h₂ h₃)) f\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}}, (Nat -> α -> β) -> Nat -> (List.{u1} α) -> (List.{u2} β)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mk [anonymous]ₓ'. -/\n@[simp]\ntheorem [anonymous] (f : α → β) (h₁ h₂ h₃) : ⇑(⟨f, h₁, h₂, h₃⟩ : α →ₙ+* β) = f :=\n  rfl\n#align non_unital_ring_hom.coe_mk [anonymous]\n\n/- warning: non_unital_ring_hom.coe_coe clashes with [anonymous] -> [anonymous]\nwarning: non_unital_ring_hom.coe_coe -> [anonymous] is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u_1}} {α : Type.{u_2}} {β : Type.{u_3}} {rα : NonUnitalNonAssocSemiring.{u_2} α} {rβ : NonUnitalNonAssocSemiring.{u_3} β} [_inst_1 : NonUnitalRingHomClass.{u_1, u_2, u_3} F α β rα rβ] (f : F), Eq.{max (succ u_2) (succ u_3)} ((fun (_x : NonUnitalRingHom.{u_2, u_3} α β rα rβ) => α -> β) ((fun (a : Type.{u_1}) (b : Sort.{max (succ u_2) (succ u_3)}) [self : HasLiftT.{succ u_1, max (succ u_2) (succ u_3)} a b] => self.0) F (NonUnitalRingHom.{u_2, u_3} α β rα rβ) (HasLiftT.mk.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} α β rα rβ) (CoeTCₓ.coe.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} α β rα rβ) (NonUnitalRingHom.hasCoeT.{u_1, u_2, u_3} F α β rα rβ _inst_1))) f)) (coeFn.{max (succ u_2) (succ u_3), max (succ u_2) (succ u_3)} (NonUnitalRingHom.{u_2, u_3} α β rα rβ) (fun (_x : NonUnitalRingHom.{u_2, u_3} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u_2, u_3} α β rα rβ) ((fun (a : Type.{u_1}) (b : Sort.{max (succ u_2) (succ u_3)}) [self : HasLiftT.{succ u_1, max (succ u_2) (succ u_3)} a b] => self.0) F (NonUnitalRingHom.{u_2, u_3} α β rα rβ) (HasLiftT.mk.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} α β rα rβ) (CoeTCₓ.coe.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} α β rα rβ) (NonUnitalRingHom.hasCoeT.{u_1, u_2, u_3} F α β rα rβ _inst_1))) f)) (coeFn.{succ u_1, max (succ u_2) (succ u_3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u_1, succ u_2, succ u_3} F α (fun (_x : α) => β) (MulHomClass.toFunLike.{u_1, u_2, u_3} F α β (Distrib.toHasMul.{u_2} α (NonUnitalNonAssocSemiring.toDistrib.{u_2} α rα)) (Distrib.toHasMul.{u_3} β (NonUnitalNonAssocSemiring.toDistrib.{u_3} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{u_1, u_2, u_3} F α β rα rβ _inst_1))) f)\nbut is expected to have type\n  forall {F : Type.{u}} {α : Type.{v}}, (Nat -> F -> α) -> Nat -> (List.{u} F) -> (List.{v} α)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_coe [anonymous]ₓ'. -/\n@[simp]\ntheorem [anonymous] [NonUnitalRingHomClass F α β] (f : F) : ((f : α →ₙ+* β) : α → β) = f :=\n  rfl\n#align non_unital_ring_hom.coe_coe [anonymous]\n\n/- warning: non_unital_ring_hom.coe_to_mul_hom -> NonUnitalRingHom.coe_toMulHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (fun (_x : MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) => α -> β) (MulHom.hasCoeToFun.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (NonUnitalRingHom.toMulHom.{u1, u2} α β rα rβ f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β} (f : NonUnitalRingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (MulHom.mulHomClass.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ))) (NonUnitalRingHom.toMulHom.{u2, u1} α β rα rβ f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHomₓ'. -/\n@[simp]\ntheorem coe_toMulHom (f : α →ₙ+* β) : ⇑f.toMulHom = f :=\n  rfl\n#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom\n\n/- warning: non_unital_ring_hom.coe_mul_hom_mk -> NonUnitalRingHom.coe_mulHom_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : α -> β) (h₁ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (f x) (f y))) (h₂ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))))))) (h₃ : forall (x : α) (y : α), Eq.{succ u2} β (f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (MulHom.hasCoeT.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} α β rα rβ))))) (NonUnitalRingHom.mk.{u1, u2} α β rα rβ f h₁ h₂ h₃)) (MulHom.mk.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) f h₁)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : α -> β) (h₁ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α rα)) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (NonUnitalNonAssocSemiring.toMul.{u2} β rβ)) (f x) (f y))) (h₂ : Eq.{succ u2} β (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (AddZeroClass.toZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))))) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddZeroClass.toZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))))) (h₃ : forall (x : α) (y : α), Eq.{succ u2} β (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))) (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) x) (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) y))), Eq.{max (succ u1) (succ u2)} (MulHom.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ)) (MulHomClass.toMulHom.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} α β rα rβ)) (NonUnitalRingHom.mk.{u1, u2} α β rα rβ (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) h₂ h₃)) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mkₓ'. -/\n@[simp]\ntheorem coe_mulHom_mk (f : α → β) (h₁ h₂ h₃) : ((⟨f, h₁, h₂, h₃⟩ : α →ₙ+* β) : α →ₙ* β) = ⟨f, h₁⟩ :=\n  rfl\n#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk\n\n/- warning: non_unital_ring_hom.coe_to_add_monoid_hom -> NonUnitalRingHom.coe_toAddMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (fun (_x : AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) => α -> β) (AddMonoidHom.hasCoeToFun.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (NonUnitalRingHom.toAddMonoidHom.{u1, u2} α β rα rβ f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β} (f : NonUnitalRingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (AddMonoidHom.{u2, u1} α β (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))) (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{max u2 u1, u2, u1} (AddMonoidHom.{u2, u1} α β (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))) (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ)))) α β (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα)))) (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ)))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u2, u1} (AddMonoidHom.{u2, u1} α β (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))) (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ)))) α β (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))) (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ))) (AddMonoidHom.addMonoidHomClass.{u2, u1} α β (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))) (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ)))))) (NonUnitalRingHom.toAddMonoidHom.{u2, u1} α β rα rβ f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHomₓ'. -/\n@[simp]\ntheorem coe_toAddMonoidHom (f : α →ₙ+* β) : ⇑f.toAddMonoidHom = f :=\n  rfl\n#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom\n\n/- warning: non_unital_ring_hom.coe_add_monoid_hom_mk -> NonUnitalRingHom.coe_addMonoidHom_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : α -> β) (h₁ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (f x) (f y))) (h₂ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))))))) (h₃ : forall (x : α) (y : α), Eq.{succ u2} β (f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} α β rα rβ))))) (NonUnitalRingHom.mk.{u1, u2} α β rα rβ f h₁ h₂ h₃)) (AddMonoidHom.mk.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) f h₂ h₃)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : α -> β) (h₁ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α rα)) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (NonUnitalNonAssocSemiring.toMul.{u2} β rβ)) (f x) (f y))) (h₂ : Eq.{succ u2} β (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (AddZeroClass.toZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))))) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddZeroClass.toZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))))) (h₃ : forall (x : α) (y : α), Eq.{succ u2} β (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))) (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) x) (MulHom.toFun.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) y))), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (AddMonoidHomClass.toAddMonoidHom.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} α β rα rβ)) (NonUnitalRingHom.mk.{u1, u2} α β rα rβ (MulHom.mk.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) f h₁) h₂ h₃)) (AddMonoidHom.mk.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (ZeroHom.mk.{u1, u2} α β (AddZeroClass.toZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))) (AddZeroClass.toZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) f h₂) h₃)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mkₓ'. -/\n@[simp]\ntheorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃) :\n    ((⟨f, h₁, h₂, h₃⟩ : α →ₙ+* β) : α →+ β) = ⟨f, h₂, h₃⟩ :=\n  rfl\n#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk\n\n/- warning: non_unital_ring_hom.copy -> NonUnitalRingHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)) -> (NonUnitalRingHom.{u1, u2} α β rα rβ)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} α β rα rβ))) f)) -> (NonUnitalRingHom.{u1, u2} α β rα rβ)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.copy NonUnitalRingHom.copyₓ'. -/\n/-- Copy of a `ring_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : α →ₙ+* β :=\n  { f.toMulHom.copy f' h, f.toAddMonoidHom.copy f' h with }\n#align non_unital_ring_hom.copy NonUnitalRingHom.copy\n\n/- warning: non_unital_ring_hom.coe_copy -> NonUnitalRingHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) (NonUnitalRingHom.copy.{u1, u2} α β rα rβ f f' h)) f'\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β} (f : NonUnitalRingHom.{u2, u1} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) (NonUnitalRingHom.copy.{u2, u1} α β rα rβ f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy\n\n/- warning: non_unital_ring_hom.copy_eq -> NonUnitalRingHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.copy.{u1, u2} α β rα rβ f f' h) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β} (f : NonUnitalRingHom.{u2, u1} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f)), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) (NonUnitalRingHom.copy.{u2, u1} α β rα rβ f f' h) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eqₓ'. -/\ntheorem copy_eq (f : α →ₙ+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq\n\nend coe\n\nvariable [rα : NonUnitalNonAssocSemiring α] [rβ : NonUnitalNonAssocSemiring β]\n\nsection\n\ninclude rα rβ\n\nvariable (f : α →ₙ+* β) {x y : α} {rα rβ}\n\n/- warning: non_unital_ring_hom.ext -> NonUnitalRingHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} {{f : NonUnitalRingHom.{u1, u2} α β rα rβ}} {{g : NonUnitalRingHom.{u1, u2} α β rα rβ}}, (forall (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) g x)) -> (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β} {{f : NonUnitalRingHom.{u2, u1} α β rα rβ}} {{g : NonUnitalRingHom.{u2, u1} α β rα rβ}}, (forall (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) g x)) -> (Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) f g)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.ext NonUnitalRingHom.extₓ'. -/\n@[ext]\ntheorem ext ⦃f g : α →ₙ+* β⦄ : (∀ x, f x = g x) → f = g :=\n  FunLike.ext _ _\n#align non_unital_ring_hom.ext NonUnitalRingHom.ext\n\n/- warning: non_unital_ring_hom.ext_iff -> NonUnitalRingHom.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} {f : NonUnitalRingHom.{u1, u2} α β rα rβ} {g : NonUnitalRingHom.{u1, u2} α β rα rβ}, Iff (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) f g) (forall (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) g x))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β} {f : NonUnitalRingHom.{u2, u1} α β rα rβ} {g : NonUnitalRingHom.{u2, u1} α β rα rβ}, Iff (Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) f g) (forall (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) g x))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iffₓ'. -/\ntheorem ext_iff {f g : α →ₙ+* β} : f = g ↔ ∀ x, f x = g x :=\n  FunLike.ext_iff\n#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff\n\n/- warning: non_unital_ring_hom.mk_coe -> NonUnitalRingHom.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β} (f : NonUnitalRingHom.{u1, u2} α β rα rβ) (h₁ : forall (x : α) (y : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f y))) (h₂ : Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))))))) (h₃ : forall (x : α) (y : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f y))), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.mk.{u1, u2} α β rα rβ (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f) h₁ h₂ h₃) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β} (f : NonUnitalRingHom.{u2, u1} α β rα rβ) (h₁ : forall (x : α) (y : α), Eq.{succ u1} β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocSemiring.toMul.{u2} α rα)) x y)) (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (NonUnitalNonAssocSemiring.toMul.{u1} β rβ)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f y))) (h₂ : Eq.{succ u1} β (MulHom.toFun.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (MulHom.mk.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f) h₁) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (AddZeroClass.toZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))))))) (OfNat.ofNat.{u1} β 0 (Zero.toOfNat0.{u1} β (AddZeroClass.toZero.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ))))))) (h₃ : forall (x : α) (y : α), Eq.{succ u1} β (MulHom.toFun.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (MulHom.mk.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f) h₁) (HAdd.hAdd.{u2, u2, u2} α α α (instHAdd.{u2} α (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))))) x y)) (HAdd.hAdd.{u1, u1, u1} β β β (instHAdd.{u1} β (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ))))) (MulHom.toFun.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (MulHom.mk.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f) h₁) x) (MulHom.toFun.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (MulHom.mk.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f) h₁) y))), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) (NonUnitalRingHom.mk.{u2, u1} α β rα rβ (MulHom.mk.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) f) h₁) h₂ h₃) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coeₓ'. -/\n@[simp]\ntheorem mk_coe (f : α →ₙ+* β) (h₁ h₂ h₃) : NonUnitalRingHom.mk f h₁ h₂ h₃ = f :=\n  ext fun _ => rfl\n#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe\n\n/- warning: non_unital_ring_hom.coe_add_monoid_hom_injective -> NonUnitalRingHom.coe_addMonoidHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} α β rα rβ))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) (AddMonoidHom.{u2, u1} α β (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))) (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ)))) (fun (f : NonUnitalRingHom.{u2, u1} α β rα rβ) => AddMonoidHomClass.toAddMonoidHom.{u2, u1, max u2 u1} α β (NonUnitalRingHom.{u2, u1} α β rα rβ) (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α rα))) (AddMonoid.toAddZeroClass.{u1} β (AddCommMonoid.toAddMonoid.{u1} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β rβ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ)) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injectiveₓ'. -/\ntheorem coe_addMonoidHom_injective : Injective (coe : (α →ₙ+* β) → α →+ β) := fun f g h =>\n  ext <| AddMonoidHom.congr_fun h\n#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective\n\n/- warning: non_unital_ring_hom.coe_mul_hom_injective -> NonUnitalRingHom.coe_mulHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonUnitalNonAssocSemiring.{u1} α} {rβ : NonUnitalNonAssocSemiring.{u2} β}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (MulHom.hasCoeT.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} α β rα rβ))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonUnitalNonAssocSemiring.{u2} α} {rβ : NonUnitalNonAssocSemiring.{u1} β}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) (MulHom.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ)) (fun (f : NonUnitalRingHom.{u2, u1} α β rα rβ) => MulHomClass.toMulHom.{u2, u1, max u2 u1} α β (NonUnitalRingHom.{u2, u1} α β rα rβ) (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ)) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injectiveₓ'. -/\ntheorem coe_mulHom_injective : Injective (coe : (α →ₙ+* β) → α →ₙ* β) := fun f g h =>\n  ext <| MulHom.congr_fun h\n#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective\n\nend\n\n#print NonUnitalRingHom.id /-\n/-- The identity non-unital ring homomorphism from a non-unital semiring to itself. -/\nprotected def id (α : Type _) [NonUnitalNonAssocSemiring α] : α →ₙ+* α := by\n  refine' { toFun := id.. } <;> intros <;> rfl\n#align non_unital_ring_hom.id NonUnitalRingHom.id\n-/\n\ninclude rα rβ\n\ninstance : Zero (α →ₙ+* β) :=\n  ⟨{  toFun := 0\n      map_mul' := fun x y => (MulZeroClass.mul_zero (0 : β)).symm\n      map_zero' := rfl\n      map_add' := fun x y => (add_zero (0 : β)).symm }⟩\n\ninstance : Inhabited (α →ₙ+* β) :=\n  ⟨0⟩\n\n/- warning: non_unital_ring_hom.coe_zero -> NonUnitalRingHom.coe_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β], Eq.{succ (max u1 u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), succ (max u1 u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) 0 (OfNat.mk.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) 0 (Zero.zero.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.hasZero.{u1, u2} α β rα rβ))))) (OfNat.ofNat.{max u1 u2} (α -> β) 0 (OfNat.mk.{max u1 u2} (α -> β) 0 (Zero.zero.{max u1 u2} (α -> β) (Pi.instZero.{u1, u2} α (fun (ᾰ : α) => β) (fun (i : α) => MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β rβ))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u2} α] [rβ : NonUnitalNonAssocSemiring.{u1} β], Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} α β rα rβ))) (OfNat.ofNat.{max u2 u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) 0 (Zero.toOfNat0.{max u2 u1} (NonUnitalRingHom.{u2, u1} α β rα rβ) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u2, u1} α β rα rβ)))) (OfNat.ofNat.{max u2 u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) ᾰ) 0 (Zero.toOfNat0.{max u2 u1} (forall (a : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (Pi.instZero.{u2, u1} α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (fun (i : α) => MulZeroClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) i) (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) i) rβ)))))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zeroₓ'. -/\n@[simp]\ntheorem coe_zero : ⇑(0 : α →ₙ+* β) = 0 :=\n  rfl\n#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero\n\n/- warning: non_unital_ring_hom.zero_apply -> NonUnitalRingHom.zero_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) 0 (OfNat.mk.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) 0 (Zero.zero.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.hasZero.{u1, u2} α β rα rβ)))) x) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β rβ)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] (x : α), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} α β rα rβ))) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) 0 (Zero.toOfNat0.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u1, u2} α β rα rβ))) x) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (MulZeroClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) rβ))))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_applyₓ'. -/\n@[simp]\ntheorem zero_apply (x : α) : (0 : α →ₙ+* β) x = 0 :=\n  rfl\n#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply\n\nomit rβ\n\n/- warning: non_unital_ring_hom.id_apply -> NonUnitalRingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α] (x : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (fun (_x : NonUnitalRingHom.{u1, u1} α α rα rα) => α -> α) (NonUnitalRingHom.hasCoeToFun.{u1, u1} α α rα rα) (NonUnitalRingHom.id.{u1} α rα) x) x\nbut is expected to have type\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α] (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} α α rα rα))) (NonUnitalRingHom.id.{u1} α rα) x) x\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_applyₓ'. -/\n@[simp]\ntheorem id_apply (x : α) : NonUnitalRingHom.id α x = x :=\n  rfl\n#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply\n\n/- warning: non_unital_ring_hom.coe_add_monoid_hom_id -> NonUnitalRingHom.coe_addMonoidHom_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (NonUnitalRingHom.{u1, u1} α α rα rα) (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))) (HasLiftT.mk.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))) (CoeTCₓ.coe.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))) (AddMonoidHom.hasCoeT.{u1, u1, u1} α α (NonUnitalRingHom.{u1, u1} α α rα rα) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (NonUnitalRingHomClass.toAddMonoidHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u1} α α rα rα))))) (NonUnitalRingHom.id.{u1} α rα)) (AddMonoidHom.id.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))\nbut is expected to have type\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))) (AddMonoidHomClass.toAddMonoidHom.{u1, u1, u1} α α (NonUnitalRingHom.{u1, u1} α α rα rα) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (NonUnitalRingHomClass.toAddMonoidHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} α α rα rα)) (NonUnitalRingHom.id.{u1} α rα)) (AddMonoidHom.id.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_idₓ'. -/\n@[simp]\ntheorem coe_addMonoidHom_id : (NonUnitalRingHom.id α : α →+ α) = AddMonoidHom.id α :=\n  rfl\n#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id\n\n/- warning: non_unital_ring_hom.coe_mul_hom_id -> NonUnitalRingHom.coe_mulHom_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (MulHom.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (NonUnitalRingHom.{u1, u1} α α rα rα) (MulHom.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) (HasLiftT.mk.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulHom.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) (CoeTCₓ.coe.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulHom.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα))) (MulHom.hasCoeT.{u1, u1, u1} α α (NonUnitalRingHom.{u1, u1} α α rα rα) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u1} α α rα rα))))) (NonUnitalRingHom.id.{u1} α rα)) (MulHom.id.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)))\nbut is expected to have type\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (MulHom.{u1, u1} α α (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα)) (MulHomClass.toMulHom.{u1, u1, u1} α α (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} α α rα rα)) (NonUnitalRingHom.id.{u1} α rα)) (MulHom.id.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α rα))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_idₓ'. -/\n@[simp]\ntheorem coe_mulHom_id : (NonUnitalRingHom.id α : α →ₙ* α) = MulHom.id α :=\n  rfl\n#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id\n\nvariable {rγ : NonUnitalNonAssocSemiring γ}\n\ninclude rβ rγ\n\n#print NonUnitalRingHom.comp /-\n/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/\ndef comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : α →ₙ+* γ :=\n  { g.toMulHom.comp f.toMulHom, g.toAddMonoidHom.comp f.toAddMonoidHom with }\n#align non_unital_ring_hom.comp NonUnitalRingHom.comp\n-/\n\n/- warning: non_unital_ring_hom.comp_assoc -> NonUnitalRingHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} {δ : Type.{u4}} {rδ : NonUnitalNonAssocSemiring.{u4} δ} (f : NonUnitalRingHom.{u1, u2} α β rα rβ) (g : NonUnitalRingHom.{u2, u3} β γ rβ rγ) (h : NonUnitalRingHom.{u3, u4} γ δ rγ rδ), Eq.{max (succ u1) (succ u4)} (NonUnitalRingHom.{u1, u4} α δ rα rδ) (NonUnitalRingHom.comp.{u1, u2, u4} α β δ rα rβ rδ (NonUnitalRingHom.comp.{u2, u3, u4} β γ δ rβ rγ rδ h g) f) (NonUnitalRingHom.comp.{u1, u3, u4} α γ δ rα rγ rδ h (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u3} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u1} γ} {δ : Type.{u4}} {rδ : NonUnitalNonAssocSemiring.{u4} δ} (f : NonUnitalRingHom.{u3, u2} α β rα rβ) (g : NonUnitalRingHom.{u2, u1} β γ rβ rγ) (h : NonUnitalRingHom.{u1, u4} γ δ rγ rδ), Eq.{max (succ u3) (succ u4)} (NonUnitalRingHom.{u3, u4} α δ rα rδ) (NonUnitalRingHom.comp.{u3, u2, u4} α β δ rα rβ rδ (NonUnitalRingHom.comp.{u2, u1, u4} β γ δ rβ rγ rδ h g) f) (NonUnitalRingHom.comp.{u3, u1, u4} α γ δ rα rγ rδ h (NonUnitalRingHom.comp.{u3, u2, u1} α β γ rα rβ rγ g f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assocₓ'. -/\n/-- Composition of non-unital ring homomorphisms is associative. -/\ntheorem comp_assoc {δ} {rδ : NonUnitalNonAssocSemiring δ} (f : α →ₙ+* β) (g : β →ₙ+* γ)\n    (h : γ →ₙ+* δ) : (h.comp g).comp f = h.comp (g.comp f) :=\n  rfl\n#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc\n\n/- warning: non_unital_ring_hom.coe_comp -> NonUnitalRingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} (g : NonUnitalRingHom.{u2, u3} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u3)} (α -> γ) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (fun (_x : NonUnitalRingHom.{u1, u3} α γ rα rγ) => α -> γ) (NonUnitalRingHom.hasCoeToFun.{u1, u3} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f)) (Function.comp.{succ u1, succ u2, succ u3} α β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (fun (_x : NonUnitalRingHom.{u2, u3} β γ rβ rγ) => β -> γ) (NonUnitalRingHom.hasCoeToFun.{u2, u3} β γ rβ rγ) g) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u3} β] {rγ : NonUnitalNonAssocSemiring.{u2} γ} (g : NonUnitalRingHom.{u3, u2} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u3} α β rα rβ), Eq.{max (succ u1) (succ u2)} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) ᾰ) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) α γ (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) α γ rα rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} α γ rα rγ))) (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f)) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} β γ rβ rγ))) g) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} α β rα rβ))) f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_compₓ'. -/\n@[simp]\ntheorem coe_comp (g : β →ₙ+* γ) (f : α →ₙ+* β) : ⇑(g.comp f) = g ∘ f :=\n  rfl\n#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp\n\n/- warning: non_unital_ring_hom.comp_apply -> NonUnitalRingHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} (g : NonUnitalRingHom.{u2, u3} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u2} α β rα rβ) (x : α), Eq.{succ u3} γ (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (fun (_x : NonUnitalRingHom.{u1, u3} α γ rα rγ) => α -> γ) (NonUnitalRingHom.hasCoeToFun.{u1, u3} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f) x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (fun (_x : NonUnitalRingHom.{u2, u3} β γ rβ rγ) => β -> γ) (NonUnitalRingHom.hasCoeToFun.{u2, u3} β γ rβ rγ) g (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u3} β] {rγ : NonUnitalNonAssocSemiring.{u2} γ} (g : NonUnitalRingHom.{u3, u2} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u3} α β rα rβ) (x : α), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) α γ (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) α γ rα rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} α γ rα rγ))) (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} β γ rβ rγ))) g (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} α β rα rβ))) f x))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_applyₓ'. -/\n@[simp]\ntheorem comp_apply (g : β →ₙ+* γ) (f : α →ₙ+* β) (x : α) : g.comp f x = g (f x) :=\n  rfl\n#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply\n\n/- warning: non_unital_ring_hom.coe_comp_add_monoid_hom -> NonUnitalRingHom.coe_comp_addMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} (g : NonUnitalRingHom.{u2, u3} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u3) (succ u1)} (AddMonoidHom.{u1, u3} α γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ)))) ((fun (a : Sort.{max (succ u1) (succ u3)}) (b : Sort.{max (succ u3) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u3), max (succ u3) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u3} α γ rα rγ) (AddMonoidHom.{u1, u3} α γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ)))) (HasLiftT.mk.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (AddMonoidHom.{u1, u3} α γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ)))) (CoeTCₓ.coe.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (AddMonoidHom.{u1, u3} α γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ)))) (AddMonoidHom.hasCoeT.{u1, u3, max u1 u3} α γ (NonUnitalRingHom.{u1, u3} α γ rα rγ) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) α γ rα rγ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u3} α γ rα rγ))))) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f)) (AddMonoidHom.comp.{u1, u2, u3} α β γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ))) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u3) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u3) (succ u2)} a b] => self.0) (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (AddMonoidHom.{u2, u3} β γ (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ)))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (AddMonoidHom.{u2, u3} β γ (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ)))) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (AddMonoidHom.{u2, u3} β γ (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ)))) (AddMonoidHom.hasCoeT.{u2, u3, max u2 u3} β γ (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (AddMonoid.toAddZeroClass.{u3} γ (AddCommMonoid.toAddMonoid.{u3} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} γ rγ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u2 u3, u2, u3} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.nonUnitalRingHomClass.{u2, u3} β γ rβ rγ))))) g) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ)))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β rβ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} α β rα rβ))))) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u3} β] {rγ : NonUnitalNonAssocSemiring.{u2} γ} (g : NonUnitalRingHom.{u3, u2} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u3} α β rα rβ), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} α γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} γ (AddCommMonoid.toAddMonoid.{u2} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} γ rγ)))) (AddMonoidHom.mk.{u1, u2} α γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u2} γ (AddCommMonoid.toAddMonoid.{u2} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} γ rγ))) (ZeroHom.mk.{u1, u2} α γ (AddZeroClass.toZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα)))) (AddZeroClass.toZero.{u2} γ (AddMonoid.toAddZeroClass.{u2} γ (AddCommMonoid.toAddMonoid.{u2} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} γ rγ)))) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β (fun (a : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) a) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} β γ rβ rγ))) g) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} α β rα rβ))) f)) (NonUnitalRingHom.map_zero'.{u1, u2} α γ rα rγ (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f))) (NonUnitalRingHom.map_add'.{u1, u2} α γ rα rγ (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f))) (AddMonoidHom.comp.{u1, u3, u2} α β γ (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u3} β (AddCommMonoid.toAddMonoid.{u3} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} β rβ))) (AddMonoid.toAddZeroClass.{u2} γ (AddCommMonoid.toAddMonoid.{u2} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} γ rγ))) (AddMonoidHomClass.toAddMonoidHom.{u3, u2, max u3 u2} β γ (NonUnitalRingHom.{u3, u2} β γ rβ rγ) (AddMonoid.toAddZeroClass.{u3} β (AddCommMonoid.toAddMonoid.{u3} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} β rβ))) (AddMonoid.toAddZeroClass.{u2} γ (AddCommMonoid.toAddMonoid.{u2} γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} γ rγ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} β γ rβ rγ)) g) (AddMonoidHomClass.toAddMonoidHom.{u1, u3, max u1 u3} α β (NonUnitalRingHom.{u1, u3} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} α rα))) (AddMonoid.toAddZeroClass.{u3} β (AddCommMonoid.toAddMonoid.{u3} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} β rβ))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} α β rα rβ)) f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHomₓ'. -/\n@[simp]\ntheorem coe_comp_addMonoidHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :\n    (g.comp f : α →+ γ) = (g : β →+ γ).comp f :=\n  rfl\n#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom\n\n/- warning: non_unital_ring_hom.coe_comp_mul_hom -> NonUnitalRingHom.coe_comp_mulHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} (g : NonUnitalRingHom.{u2, u3} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u3) (succ u1)} (MulHom.{u1, u3} α γ (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ))) ((fun (a : Sort.{max (succ u1) (succ u3)}) (b : Sort.{max (succ u3) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u3), max (succ u3) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u3} α γ rα rγ) (MulHom.{u1, u3} α γ (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ))) (HasLiftT.mk.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (MulHom.{u1, u3} α γ (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ))) (CoeTCₓ.coe.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (MulHom.{u1, u3} α γ (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ))) (MulHom.hasCoeT.{u1, u3, max u1 u3} α γ (NonUnitalRingHom.{u1, u3} α γ rα rγ) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) α γ rα rγ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u3} α γ rα rγ))))) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f)) (MulHom.comp.{u1, u2, u3} α β γ (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ)) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u3) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u3) (succ u2)} a b] => self.0) (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (MulHom.{u2, u3} β γ (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (MulHom.{u2, u3} β γ (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ))) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (MulHom.{u2, u3} β γ (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ))) (MulHom.hasCoeT.{u2, u3, max u2 u3} β γ (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (Distrib.toHasMul.{u3} γ (NonUnitalNonAssocSemiring.toDistrib.{u3} γ rγ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.nonUnitalRingHomClass.{u2, u3} β γ rβ rγ))))) g) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (MulHom.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ))) (MulHom.hasCoeT.{u1, u2, max u1 u2} α β (NonUnitalRingHom.{u1, u2} α β rα rβ) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α rα)) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) α β rα rβ (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} α β rα rβ))))) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u3} β] {rγ : NonUnitalNonAssocSemiring.{u2} γ} (g : NonUnitalRingHom.{u3, u2} β γ rβ rγ) (f : NonUnitalRingHom.{u1, u3} α β rα rβ), Eq.{max (succ u1) (succ u2)} (MulHom.{u1, u2} α γ (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ)) (MulHom.mk.{u1, u2} α γ (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β (fun (a : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) a) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} β γ rβ rγ))) g) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} α β rα rβ))) f)) (MulHom.map_mul'.{u1, u2} α γ (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHom.toMulHom.{u1, u2} α γ rα rγ (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f)))) (MulHom.comp.{u1, u3, u2} α β γ (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (MulHomClass.toMulHom.{u3, u2, max u3 u2} β γ (NonUnitalRingHom.{u3, u2} β γ rβ rγ) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} β γ rβ rγ)) g) (MulHomClass.toMulHom.{u1, u3, max u1 u3} α β (NonUnitalRingHom.{u1, u3} α β rα rβ) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} α β rα rβ)) f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHomₓ'. -/\n@[simp]\ntheorem coe_comp_mulHom (g : β →ₙ+* γ) (f : α →ₙ+* β) :\n    (g.comp f : α →ₙ* γ) = (g : β →ₙ* γ).comp f :=\n  rfl\n#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom\n\n/- warning: non_unital_ring_hom.comp_zero -> NonUnitalRingHom.comp_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} (g : NonUnitalRingHom.{u2, u3} β γ rβ rγ), Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) 0 (OfNat.mk.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) 0 (Zero.zero.{max u1 u2} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.hasZero.{u1, u2} α β rα rβ))))) (OfNat.ofNat.{max u1 u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) 0 (OfNat.mk.{max u1 u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) 0 (Zero.zero.{max u1 u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (NonUnitalRingHom.hasZero.{u1, u3} α γ rα rγ))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u3} β] {rγ : NonUnitalNonAssocSemiring.{u2} γ} (g : NonUnitalRingHom.{u3, u2} β γ rβ rγ), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g (OfNat.ofNat.{max u1 u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) 0 (Zero.toOfNat0.{max u1 u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u1, u3} α β rα rβ)))) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) 0 (Zero.toOfNat0.{max u1 u2} (NonUnitalRingHom.{u1, u2} α γ rα rγ) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u1, u2} α γ rα rγ)))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zeroₓ'. -/\n@[simp]\ntheorem comp_zero (g : β →ₙ+* γ) : g.comp (0 : α →ₙ+* β) = 0 :=\n  by\n  ext\n  simp\n#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero\n\n/- warning: non_unital_ring_hom.zero_comp -> NonUnitalRingHom.zero_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ (OfNat.ofNat.{max u2 u3} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) 0 (OfNat.mk.{max u2 u3} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) 0 (Zero.zero.{max u2 u3} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (NonUnitalRingHom.hasZero.{u2, u3} β γ rβ rγ)))) f) (OfNat.ofNat.{max u1 u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) 0 (OfNat.mk.{max u1 u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) 0 (Zero.zero.{max u1 u3} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (NonUnitalRingHom.hasZero.{u1, u3} α γ rα rγ))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u3} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u1} γ} (f : NonUnitalRingHom.{u3, u2} α β rα rβ), Eq.{max (succ u3) (succ u1)} (NonUnitalRingHom.{u3, u1} α γ rα rγ) (NonUnitalRingHom.comp.{u3, u2, u1} α β γ rα rβ rγ (OfNat.ofNat.{max u2 u1} (NonUnitalRingHom.{u2, u1} β γ rβ rγ) 0 (Zero.toOfNat0.{max u2 u1} (NonUnitalRingHom.{u2, u1} β γ rβ rγ) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u2, u1} β γ rβ rγ))) f) (OfNat.ofNat.{max u3 u1} (NonUnitalRingHom.{u3, u1} α γ rα rγ) 0 (Zero.toOfNat0.{max u3 u1} (NonUnitalRingHom.{u3, u1} α γ rα rγ) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u3, u1} α γ rα rγ)))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_compₓ'. -/\n@[simp]\ntheorem zero_comp (f : α →ₙ+* β) : (0 : β →ₙ+* γ).comp f = 0 :=\n  by\n  ext\n  rfl\n#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp\n\nomit rγ\n\n/- warning: non_unital_ring_hom.comp_id -> NonUnitalRingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.comp.{u1, u1, u2} α α β rα rα rβ f (NonUnitalRingHom.id.{u1} α rα)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u2} α] [rβ : NonUnitalNonAssocSemiring.{u1} β] (f : NonUnitalRingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) (NonUnitalRingHom.comp.{u2, u2, u1} α α β rα rα rβ f (NonUnitalRingHom.id.{u2} α rα)) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_idₓ'. -/\n@[simp]\ntheorem comp_id (f : α →ₙ+* β) : f.comp (NonUnitalRingHom.id α) = f :=\n  ext fun x => rfl\n#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id\n\n/- warning: non_unital_ring_hom.id_comp -> NonUnitalRingHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] (f : NonUnitalRingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (NonUnitalRingHom.comp.{u1, u2, u2} α β β rα rβ rβ (NonUnitalRingHom.id.{u2} β rβ) f) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u2} α] [rβ : NonUnitalNonAssocSemiring.{u1} β] (f : NonUnitalRingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} α β rα rβ) (NonUnitalRingHom.comp.{u2, u1, u1} α β β rα rβ rβ (NonUnitalRingHom.id.{u1} β rβ) f) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_compₓ'. -/\n@[simp]\ntheorem id_comp (f : α →ₙ+* β) : (NonUnitalRingHom.id β).comp f = f :=\n  ext fun x => rfl\n#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp\n\nomit rβ\n\ninstance : MonoidWithZero (α →ₙ+* α)\n    where\n  one := NonUnitalRingHom.id α\n  mul := comp\n  mul_one := comp_id\n  one_mul := id_comp\n  mul_assoc f g h := comp_assoc _ _ _\n  zero := 0\n  mul_zero := comp_zero\n  zero_mul := zero_comp\n\n/- warning: non_unital_ring_hom.one_def -> NonUnitalRingHom.one_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) 1 (OfNat.mk.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) 1 (One.one.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulOneClass.toHasOne.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.monoidWithZero.{u1} α rα))))))) (NonUnitalRingHom.id.{u1} α rα)\nbut is expected to have type\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) 1 (One.toOfNat1.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (Monoid.toOne.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMonoid.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} α rα))))) (NonUnitalRingHom.id.{u1} α rα)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.one_def NonUnitalRingHom.one_defₓ'. -/\ntheorem one_def : (1 : α →ₙ+* α) = NonUnitalRingHom.id α :=\n  rfl\n#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def\n\n/- warning: non_unital_ring_hom.coe_one -> NonUnitalRingHom.coe_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (fun (_x : NonUnitalRingHom.{u1, u1} α α rα rα) => α -> α) (NonUnitalRingHom.hasCoeToFun.{u1, u1} α α rα rα) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) 1 (OfNat.mk.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) 1 (One.one.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulOneClass.toHasOne.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.monoidWithZero.{u1} α rα)))))))) (id.{succ u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α], Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} α α rα rα))) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) 1 (One.toOfNat1.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (Monoid.toOne.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMonoid.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} α rα)))))) (id.{succ u1} α)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_oneₓ'. -/\n@[simp]\ntheorem coe_one : ⇑(1 : α →ₙ+* α) = id :=\n  rfl\n#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one\n\n/- warning: non_unital_ring_hom.mul_def -> NonUnitalRingHom.mul_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α] (f : NonUnitalRingHom.{u1, u1} α α rα rα) (g : NonUnitalRingHom.{u1, u1} α α rα rα), Eq.{succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroClass.toHasMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.monoidWithZero.{u1} α rα))))) f g) (NonUnitalRingHom.comp.{u1, u1, u1} α α α rα rα rα f g)\nbut is expected to have type\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α] (f : NonUnitalRingHom.{u1, u1} α α rα rα) (g : NonUnitalRingHom.{u1, u1} α α rα rα), Eq.{succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroClass.toMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} α rα))))) f g) (NonUnitalRingHom.comp.{u1, u1, u1} α α α rα rα rα f g)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_defₓ'. -/\ntheorem mul_def (f g : α →ₙ+* α) : f * g = f.comp g :=\n  rfl\n#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def\n\n/- warning: non_unital_ring_hom.coe_mul -> NonUnitalRingHom.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α] (f : NonUnitalRingHom.{u1, u1} α α rα rα) (g : NonUnitalRingHom.{u1, u1} α α rα rα), Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (fun (_x : NonUnitalRingHom.{u1, u1} α α rα rα) => α -> α) (NonUnitalRingHom.hasCoeToFun.{u1, u1} α α rα rα) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroClass.toHasMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.monoidWithZero.{u1} α rα))))) f g)) (Function.comp.{succ u1, succ u1, succ u1} α α α (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (fun (_x : NonUnitalRingHom.{u1, u1} α α rα rα) => α -> α) (NonUnitalRingHom.hasCoeToFun.{u1, u1} α α rα rα) f) (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (fun (_x : NonUnitalRingHom.{u1, u1} α α rα rα) => α -> α) (NonUnitalRingHom.hasCoeToFun.{u1, u1} α α rα rα) g))\nbut is expected to have type\n  forall {α : Type.{u1}} [rα : NonUnitalNonAssocSemiring.{u1} α] (f : NonUnitalRingHom.{u1, u1} α α rα rα) (g : NonUnitalRingHom.{u1, u1} α α rα rα), Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} α α rα rα))) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.{u1, u1} α α rα rα) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroClass.toMul.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} α α rα rα) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} α rα))))) f g)) (Function.comp.{succ u1, succ u1, succ u1} α α α (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} α α rα rα))) f) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} α α rα rα) α α rα rα (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} α α rα rα))) g))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mulₓ'. -/\n@[simp]\ntheorem coe_mul (f g : α →ₙ+* α) : ⇑(f * g) = f ∘ g :=\n  rfl\n#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul\n\ninclude rβ rγ\n\n/- warning: non_unital_ring_hom.cancel_right -> NonUnitalRingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} {g₁ : NonUnitalRingHom.{u2, u3} β γ rβ rγ} {g₂ : NonUnitalRingHom.{u2, u3} β γ rβ rγ} {f : NonUnitalRingHom.{u1, u2} α β rα rβ}, (Function.Surjective.{succ u1, succ u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) (fun (_x : NonUnitalRingHom.{u1, u2} α β rα rβ) => α -> β) (NonUnitalRingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g₁ f) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g₂ f)) (Eq.{max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) g₁ g₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u3} β] {rγ : NonUnitalNonAssocSemiring.{u2} γ} {g₁ : NonUnitalRingHom.{u3, u2} β γ rβ rγ} {g₂ : NonUnitalRingHom.{u3, u2} β γ rβ rγ} {f : NonUnitalRingHom.{u1, u3} α β rα rβ}, (Function.Surjective.{succ u1, succ u3} α β (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α rα) (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} α β rα rβ) α β rα rβ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} α β rα rβ))) f)) -> (Iff (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g₁ f) (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g₂ f)) (Eq.{max (succ u3) (succ u2)} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_rightₓ'. -/\ntheorem cancel_right {g₁ g₂ : β →ₙ+* γ} {f : α →ₙ+* β} (hf : Surjective f) :\n    g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩\n#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right\n\n/- warning: non_unital_ring_hom.cancel_left -> NonUnitalRingHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u2} β] {rγ : NonUnitalNonAssocSemiring.{u3} γ} {g : NonUnitalRingHom.{u2, u3} β γ rβ rγ} {f₁ : NonUnitalRingHom.{u1, u2} α β rα rβ} {f₂ : NonUnitalRingHom.{u1, u2} α β rα rβ}, (Function.Injective.{succ u2, succ u3} β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} β γ rβ rγ) (fun (_x : NonUnitalRingHom.{u2, u3} β γ rβ rγ) => β -> γ) (NonUnitalRingHom.hasCoeToFun.{u2, u3} β γ rβ rγ) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f₁) (NonUnitalRingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f₂)) (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α β rα rβ) f₁ f₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [rα : NonUnitalNonAssocSemiring.{u1} α] [rβ : NonUnitalNonAssocSemiring.{u3} β] {rγ : NonUnitalNonAssocSemiring.{u2} γ} {g : NonUnitalRingHom.{u3, u2} β γ rβ rγ} {f₁ : NonUnitalRingHom.{u1, u3} α β rα rβ} {f₂ : NonUnitalRingHom.{u1, u3} α β rα rβ}, (Function.Injective.{succ u3, succ u2} β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β rβ) (NonUnitalNonAssocSemiring.toMul.{u2} γ rγ) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} β γ rβ rγ))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} α γ rα rγ) (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f₁) (NonUnitalRingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f₂)) (Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} α β rα rβ) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_leftₓ'. -/\ntheorem cancel_left {g : β →ₙ+* γ} {f₁ f₂ : α →ₙ+* β} (hg : Injective g) :\n    g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩\n#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left\n\nomit rα rβ rγ\n\nend NonUnitalRingHom\n\n#print RingHom /-\n/-- Bundled semiring homomorphisms; use this for bundled ring homomorphisms too.\n\nThis extends from both `monoid_hom` and `monoid_with_zero_hom` in order to put the fields in a\nsensible order, even though `monoid_with_zero_hom` already extends `monoid_hom`. -/\nstructure RingHom (α : Type _) (β : Type _) [NonAssocSemiring α] [NonAssocSemiring β] extends\n  α →* β, α →+ β, α →ₙ+* β, α →*₀ β\n#align ring_hom RingHom\n-/\n\n-- mathport name: «expr →+* »\ninfixr:25 \" →+* \" => RingHom\n\n/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid with zero homomorphism `α →*₀ β`.\nThe `simp`-normal form is `(f : α →*₀ β)`. -/\nadd_decl_doc RingHom.toMonoidWithZeroHom\n\n/-- Reinterpret a ring homomorphism `f : α →+* β` as a monoid homomorphism `α →* β`.\nThe `simp`-normal form is `(f : α →* β)`. -/\nadd_decl_doc RingHom.toMonoidHom\n\n/-- Reinterpret a ring homomorphism `f : α →+* β` as an additive monoid homomorphism `α →+ β`.\nThe `simp`-normal form is `(f : α →+ β)`. -/\nadd_decl_doc RingHom.toAddMonoidHom\n\n/-- Reinterpret a ring homomorphism `f : α →+* β` as a non-unital ring homomorphism `α →ₙ+* β`. The\n`simp`-normal form is `(f : α →ₙ+* β)`. -/\nadd_decl_doc RingHom.toNonUnitalRingHom\n\nsection RingHomClass\n\n#print RingHomClass /-\n/-- `ring_hom_class F α β` states that `F` is a type of (semi)ring homomorphisms.\nYou should extend this class when you extend `ring_hom`.\n\nThis extends from both `monoid_hom_class` and `monoid_with_zero_hom_class` in\norder to put the fields in a sensible order, even though\n`monoid_with_zero_hom_class` already extends `monoid_hom_class`. -/\nclass RingHomClass (F : Type _) (α β : outParam (Type _)) [NonAssocSemiring α]\n  [NonAssocSemiring β] extends MonoidHomClass F α β, AddMonoidHomClass F α β,\n  MonoidWithZeroHomClass F α β\n#align ring_hom_class RingHomClass\n-/\n\nvariable [NonAssocSemiring α] [NonAssocSemiring β] [RingHomClass F α β]\n\n/- warning: map_bit1 -> map_bit1 is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : NonAssocSemiring.{u3} β] [_inst_3 : RingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : α), Eq.{succ u3} β (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (MulHomClass.toFunLike.{u1, u2, u3} F α β (MulOneClass.toHasMul.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1))) (MulOneClass.toHasMul.{u3} β (MulZeroOneClass.toMulOneClass.{u3} β (NonAssocSemiring.toMulZeroOneClass.{u3} β _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u3} β (NonAssocSemiring.toMulZeroOneClass.{u3} β _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f (bit1.{u2} α (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1))) (Distrib.toHasAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) a)) (bit1.{u3} β (AddMonoidWithOne.toOne.{u3} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} β (NonAssocSemiring.toAddCommMonoidWithOne.{u3} β _inst_2))) (Distrib.toHasAdd.{u3} β (NonUnitalNonAssocSemiring.toDistrib.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_2))) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (MulHomClass.toFunLike.{u1, u2, u3} F α β (MulOneClass.toHasMul.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1))) (MulOneClass.toHasMul.{u3} β (MulZeroOneClass.toMulOneClass.{u3} β (NonAssocSemiring.toMulZeroOneClass.{u3} β _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u3} β (NonAssocSemiring.toMulZeroOneClass.{u3} β _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f a))\nbut is expected to have type\n  forall {F : Type.{u1}} {α : Type.{u3}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u3} α] [_inst_2 : NonAssocSemiring.{u2} β] [_inst_3 : RingHomClass.{u1, u3, u2} F α β _inst_1 _inst_2] (f : F) (a : α), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (bit1.{u3} α (NonAssocSemiring.toOne.{u3} α _inst_1) (Distrib.toAdd.{u3} α (NonUnitalNonAssocSemiring.toDistrib.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α _inst_1))) a)) (FunLike.coe.{succ u1, succ u3, succ u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u1, u3, u2} F α β (MulOneClass.toMul.{u3} α (MulZeroOneClass.toMulOneClass.{u3} α (NonAssocSemiring.toMulZeroOneClass.{u3} α _inst_1))) (MulOneClass.toMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F α β (MulZeroOneClass.toMulOneClass.{u3} α (NonAssocSemiring.toMulZeroOneClass.{u3} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u3, u2} F α β _inst_1 _inst_2 _inst_3))) f (bit1.{u3} α (NonAssocSemiring.toOne.{u3} α _inst_1) (Distrib.toAdd.{u3} α (NonUnitalNonAssocSemiring.toDistrib.{u3} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} α _inst_1))) a)) (bit1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonAssocSemiring.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) _inst_2) (Distrib.toAdd.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonUnitalNonAssocSemiring.toDistrib.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) _inst_2))) (FunLike.coe.{succ u1, succ u3, succ u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u1, u3, u2} F α β (MulOneClass.toMul.{u3} α (MulZeroOneClass.toMulOneClass.{u3} α (NonAssocSemiring.toMulZeroOneClass.{u3} α _inst_1))) (MulOneClass.toMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F α β (MulZeroOneClass.toMulOneClass.{u3} α (NonAssocSemiring.toMulZeroOneClass.{u3} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u3, u2} F α β _inst_1 _inst_2 _inst_3))) f a))\nCase conversion may be inaccurate. Consider using '#align map_bit1 map_bit1ₓ'. -/\n/-- Ring homomorphisms preserve `bit1`. -/\n@[simp]\ntheorem map_bit1 (f : F) (a : α) : (f (bit1 a) : β) = bit1 (f a) := by simp [bit1]\n#align map_bit1 map_bit1\n\ninstance : CoeTC F (α →+* β) :=\n  ⟨fun f =>\n    { toFun := f\n      map_zero' := map_zero f\n      map_one' := map_one f\n      map_mul' := map_mul f\n      map_add' := map_add f }⟩\n\n#print RingHomClass.toNonUnitalRingHomClass /-\ninstance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F α β :=\n  { ‹RingHomClass F α β› with }\n#align ring_hom_class.to_non_unital_ring_hom_class RingHomClass.toNonUnitalRingHomClass\n-/\n\nend RingHomClass\n\nnamespace RingHom\n\nsection coe\n\n/-!\nThroughout this section, some `semiring` arguments are specified with `{}` instead of `[]`.\nSee note [implicit instance arguments].\n-/\n\n\nvariable {rα : NonAssocSemiring α} {rβ : NonAssocSemiring β}\n\ninclude rα rβ\n\ninstance : RingHomClass (α →+* β) α β\n    where\n  coe := RingHom.toFun\n  coe_injective' f g h := by cases f <;> cases g <;> congr\n  map_add := RingHom.map_add'\n  map_zero := RingHom.map_zero'\n  map_mul := RingHom.map_mul'\n  map_one := RingHom.map_one'\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly.\n-/\ninstance : CoeFun (α →+* β) fun _ => α → β :=\n  ⟨RingHom.toFun⟩\n\ninitialize_simps_projections RingHom (toFun → apply)\n\n/- warning: ring_hom.to_fun_eq_coe -> RingHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (α -> β) (RingHom.toFun.{u1, u2} α β rα rβ f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (α -> β) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (RingHom.toMonoidHom.{u2, u1} α β rα rβ f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coeₓ'. -/\n@[simp]\ntheorem toFun_eq_coe (f : α →+* β) : f.toFun = f :=\n  rfl\n#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe\n\n/- warning: ring_hom.coe_mk -> RingHom.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : α -> β) (h₁ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (MulOneClass.toHasOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))))))) (h₂ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (MulOneClass.toHasMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (f x) (f y))) (h₃ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))))) (h₄ : forall (x : α) (y : α), Eq.{succ u2} β (f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))) (f x) (f y))), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) (RingHom.mk.{u1, u2} α β rα rβ f h₁ h₂ h₃ h₄)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (h₁ : Eq.{succ u1} β (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (AddZeroClass.toZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))))))) (OfNat.ofNat.{u1} β 0 (Zero.toOfNat0.{u1} β (AddZeroClass.toZero.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))))))) (h₂ : forall (x : α) (y : α), Eq.{succ u1} β (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) (HAdd.hAdd.{u2, u2, u2} α α α (instHAdd.{u2} α (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))))) x y)) (HAdd.hAdd.{u1, u1, u1} β β β (instHAdd.{u1} β (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))))) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) x) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) y))), Eq.{max (succ u2) (succ u1)} (forall (a : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) (RingHom.mk.{u2, u1} α β rα rβ f h₁ h₂)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) α β (MulOneClass.toMul.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toMul.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (MonoidHom.monoidHomClass.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_mk RingHom.coe_mkₓ'. -/\n@[simp]\ntheorem coe_mk (f : α → β) (h₁ h₂ h₃ h₄) : ⇑(⟨f, h₁, h₂, h₃, h₄⟩ : α →+* β) = f :=\n  rfl\n#align ring_hom.coe_mk RingHom.coe_mk\n\n/- warning: ring_hom.coe_coe -> RingHom.coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u1, u2} F α β rα rβ] (f : F), Eq.{max (succ u1) (succ u2)} ((fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) ((fun (a : Type.{u3}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{succ u3, max (succ u1) (succ u2)} a b] => self.0) F (RingHom.{u1, u2} α β rα rβ) (HasLiftT.mk.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} α β rα rβ) (CoeTCₓ.coe.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} α β rα rβ) (RingHom.hasCoeT.{u3, u1, u2} F α β rα rβ _inst_1))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) ((fun (a : Type.{u3}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{succ u3, max (succ u1) (succ u2)} a b] => self.0) F (RingHom.{u1, u2} α β rα rβ) (HasLiftT.mk.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} α β rα rβ) (CoeTCₓ.coe.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} α β rα rβ) (RingHom.hasCoeT.{u3, u1, u2} F α β rα rβ _inst_1))) f)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} F α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα))) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F α β rα rβ _inst_1)))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u2, u1} F α β rα rβ] (f : F), Eq.{max (succ u2) (succ u1)} (forall (a : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) (RingHomClass.toRingHom.{u3, u2, u1} F α β rα rβ _inst_1 f)) (FunLike.coe.{succ u3, succ u2, succ u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u2, u1} F α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{u3, u2, u1} F α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{u3, u2, u1} F α β rα rβ _inst_1))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_coe RingHom.coe_coeₓ'. -/\n@[simp]\ntheorem coe_coe {F : Type _} [RingHomClass F α β] (f : F) : ((f : α →+* β) : α → β) = f :=\n  rfl\n#align ring_hom.coe_coe RingHom.coe_coe\n\n#print RingHom.coeToMonoidHom /-\ninstance coeToMonoidHom : Coe (α →+* β) (α →* β) :=\n  ⟨RingHom.toMonoidHom⟩\n#align ring_hom.has_coe_monoid_hom RingHom.coeToMonoidHom\n-/\n\n/- warning: ring_hom.coe_monoid_hom clashes with [anonymous] -> [anonymous]\nwarning: ring_hom.coe_monoid_hom -> [anonymous] is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (fun (_x : MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}}, (Nat -> α -> β) -> Nat -> (List.{u1} α) -> (List.{u2} β)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom [anonymous]ₓ'. -/\n@[simp, norm_cast]\ntheorem [anonymous] (f : α →+* β) : ⇑(f : α →* β) = f :=\n  rfl\n#align ring_hom.coe_monoid_hom [anonymous]\n\n/- warning: ring_hom.to_monoid_hom_eq_coe -> RingHom.toMonoidHom_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (RingHom.toMonoidHom.{u1, u2} α β rα rβ f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (RingHom.toMonoidHom.{u2, u1} α β rα rβ f) (MonoidHomClass.toMonoidHom.{u2, u1, max u2 u1} α β (RingHom.{u2, u1} α β rα rβ) (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (RingHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coeₓ'. -/\n@[simp]\ntheorem toMonoidHom_eq_coe (f : α →+* β) : f.toMonoidHom = f :=\n  rfl\n#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe\n\n/- warning: ring_hom.to_monoid_with_zero_hom_eq_coe -> RingHom.toMonoidWithZeroHom_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidWithZeroHom.{u1, u2} α β (NonAssocSemiring.toMulZeroOneClass.{u1} α rα) (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) => α -> β) (RingHom.toMonoidWithZeroHom.{u1, u2} α β rα rβ f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} α β (NonAssocSemiring.toMulZeroOneClass.{u1} α rα) (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (fun (_x : MonoidWithZeroHom.{u1, u2} α β (NonAssocSemiring.toMulZeroOneClass.{u1} α rα) (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) => α -> β) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} α β (NonAssocSemiring.toMulZeroOneClass.{u1} α rα) (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (RingHom.toMonoidWithZeroHom.{u1, u2} α β rα rβ f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (forall (a : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} α β (NonAssocSemiring.toMulZeroOneClass.{u2} α rα) (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} α β (NonAssocSemiring.toMulZeroOneClass.{u2} α rα) (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) α β (MulOneClass.toMul.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toMul.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} α β (NonAssocSemiring.toMulZeroOneClass.{u2} α rα) (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} α β (NonAssocSemiring.toMulZeroOneClass.{u2} α rα) (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) α β (NonAssocSemiring.toMulZeroOneClass.{u2} α rα) (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ) (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} α β (NonAssocSemiring.toMulZeroOneClass.{u2} α rα) (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))))) (RingHom.toMonoidWithZeroHom.{u2, u1} α β rα rβ f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coeₓ'. -/\n@[simp]\ntheorem toMonoidWithZeroHom_eq_coe (f : α →+* β) : (f.toMonoidWithZeroHom : α → β) = f :=\n  rfl\n#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe\n\n/- warning: ring_hom.coe_monoid_hom_mk -> RingHom.coe_monoidHom_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : α -> β) (h₁ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (MulOneClass.toHasOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))))))) (h₂ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (MulOneClass.toHasMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (f x) (f y))) (h₃ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))))) (h₄ : forall (x : α) (y : α), Eq.{succ u2} β (f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))) (RingHom.mk.{u1, u2} α β rα rβ f h₁ h₂ h₃ h₄)) (MonoidHom.mk.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) f h₁ h₂)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (h₁ : Eq.{succ u1} β (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (AddZeroClass.toZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))))))) (OfNat.ofNat.{u1} β 0 (Zero.toOfNat0.{u1} β (AddZeroClass.toZero.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))))))) (h₂ : forall (x : α) (y : α), Eq.{succ u1} β (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) (HAdd.hAdd.{u2, u2, u2} α α α (instHAdd.{u2} α (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))))) x y)) (HAdd.hAdd.{u1, u1, u1} β β β (instHAdd.{u1} β (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))))) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) x) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) f) y))), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHomClass.toMonoidHom.{u2, u1, max u2 u1} α β (RingHom.{u2, u1} α β rα rβ) (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (RingHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)) (RingHom.mk.{u2, u1} α β rα rβ f h₁ h₂)) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mkₓ'. -/\n@[simp]\ntheorem coe_monoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :\n    ((⟨f, h₁, h₂, h₃, h₄⟩ : α →+* β) : α →* β) = ⟨f, h₁, h₂⟩ :=\n  rfl\n#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk\n\n/- warning: ring_hom.coe_add_monoid_hom clashes with [anonymous] -> [anonymous]\nwarning: ring_hom.coe_add_monoid_hom -> [anonymous] is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (fun (_x : AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) => α -> β) (AddMonoidHom.hasCoeToFun.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}}, (Nat -> α -> β) -> Nat -> (List.{u1} α) -> (List.{u2} β)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom [anonymous]ₓ'. -/\n@[simp, norm_cast]\ntheorem [anonymous] (f : α →+* β) : ⇑(f : α →+ β) = f :=\n  rfl\n#align ring_hom.coe_add_monoid_hom [anonymous]\n\n/- warning: ring_hom.to_add_monoid_hom_eq_coe -> RingHom.toAddMonoidHom_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (RingHom.toAddMonoidHom.{u1, u2} α β rα rβ f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} α β (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ))))) (RingHom.toAddMonoidHom.{u2, u1} α β rα rβ f) (AddMonoidHomClass.toAddMonoidHom.{u2, u1, max u2 u1} α β (RingHom.{u2, u1} α β rα rβ) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coeₓ'. -/\n@[simp]\ntheorem toAddMonoidHom_eq_coe (f : α →+* β) : f.toAddMonoidHom = f :=\n  rfl\n#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe\n\n/- warning: ring_hom.coe_add_monoid_hom_mk -> RingHom.coe_addMonoidHom_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : α -> β) (h₁ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (MulOneClass.toHasOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))))))) (h₂ : forall (x : α) (y : α), Eq.{succ u2} β (f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (MulOneClass.toHasMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (f x) (f y))) (h₃ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))))) (h₄ : forall (x : α) (y : α), Eq.{succ u2} β (f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))) (RingHom.mk.{u1, u2} α β rα rβ f h₁ h₂ h₃ h₄)) (AddMonoidHom.mk.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))) f h₃ h₄)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : α -> β) (h₁ : Eq.{succ u2} β (f (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))))) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))))) (h₂ : forall (x : α) (y : α), Eq.{succ u2} β (OneHom.toFun.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (MulOneClass.toMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (OneHom.toFun.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) x) (OneHom.toFun.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) y))) (h₃ : Eq.{succ u2} β (OneHom.toFun.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.toOneHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (MonoidHom.mk.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) h₂)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (AddZeroClass.toZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))))) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddZeroClass.toZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))))) (h₄ : forall (x : α) (y : α), Eq.{succ u2} β (OneHom.toFun.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.toOneHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (MonoidHom.mk.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) h₂)) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))) (OneHom.toFun.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.toOneHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (MonoidHom.mk.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) h₂)) x) (OneHom.toFun.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.toOneHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (MonoidHom.mk.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) h₂)) y))), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (AddMonoidHomClass.toAddMonoidHom.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u2} α β rα rβ)) (RingHom.mk.{u1, u2} α β rα rβ (MonoidHom.mk.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (OneHom.mk.{u1, u2} α β (MulOneClass.toOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MulOneClass.toOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) f h₁) h₂) h₃ h₄)) (AddMonoidHom.mk.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))) (ZeroHom.mk.{u1, u2} α β (AddZeroClass.toZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))) (AddZeroClass.toZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) f h₃) h₄)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mkₓ'. -/\n@[simp]\ntheorem coe_addMonoidHom_mk (f : α → β) (h₁ h₂ h₃ h₄) :\n    ((⟨f, h₁, h₂, h₃, h₄⟩ : α →+* β) : α →+ β) = ⟨f, h₃, h₄⟩ :=\n  rfl\n#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk\n\n/- warning: ring_hom.copy -> RingHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)) -> (RingHom.{u1, u2} α β rα rβ)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u2} α β rα rβ)))) f)) -> (RingHom.{u1, u2} α β rα rβ)\nCase conversion may be inaccurate. Consider using '#align ring_hom.copy RingHom.copyₓ'. -/\n/-- Copy of a `ring_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\ndef copy (f : α →+* β) (f' : α → β) (h : f' = f) : α →+* β :=\n  { f.toMonoidWithZeroHom.copy f' h, f.toAddMonoidHom.copy f' h with }\n#align ring_hom.copy RingHom.copy\n\n/- warning: ring_hom.coe_copy -> RingHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) (RingHom.copy.{u1, u2} α β rα rβ f f' h)) f'\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) (RingHom.copy.{u2, u1} α β rα rβ f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_copy RingHom.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (f : α →+* β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align ring_hom.coe_copy RingHom.coe_copy\n\n/- warning: ring_hom.copy_eq -> RingHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (RingHom.copy.{u1, u2} α β rα rβ f f' h) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f)), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) (RingHom.copy.{u2, u1} α β rα rβ f f' h) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.copy_eq RingHom.copy_eqₓ'. -/\ntheorem copy_eq (f : α →+* β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align ring_hom.copy_eq RingHom.copy_eq\n\nend coe\n\nvariable [rα : NonAssocSemiring α] [rβ : NonAssocSemiring β]\n\nsection\n\ninclude rα rβ\n\nvariable (f : α →+* β) {x y : α} {rα rβ}\n\n/- warning: ring_hom.congr_fun -> RingHom.congr_fun is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} {f : RingHom.{u1, u2} α β rα rβ} {g : RingHom.{u1, u2} α β rα rβ}, (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) f g) -> (forall (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) g x))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} {f : RingHom.{u2, u1} α β rα rβ} {g : RingHom.{u2, u1} α β rα rβ}, (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) f g) -> (forall (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) g x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.congr_fun RingHom.congr_funₓ'. -/\ntheorem congr_fun {f g : α →+* β} (h : f = g) (x : α) : f x = g x :=\n  FunLike.congr_fun h x\n#align ring_hom.congr_fun RingHom.congr_fun\n\n/- warning: ring_hom.congr_arg -> RingHom.congr_arg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) {x : α} {y : α}, (Eq.{succ u1} α x y) -> (Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f y))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ) {x : α} {y : α}, (Eq.{succ u2} α x y) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f y))\nCase conversion may be inaccurate. Consider using '#align ring_hom.congr_arg RingHom.congr_argₓ'. -/\ntheorem congr_arg (f : α →+* β) {x y : α} (h : x = y) : f x = f y :=\n  FunLike.congr_arg f h\n#align ring_hom.congr_arg RingHom.congr_arg\n\n/- warning: ring_hom.coe_inj -> RingHom.coe_inj is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} {{f : RingHom.{u1, u2} α β rα rβ}} {{g : RingHom.{u1, u2} α β rα rβ}}, (Eq.{max (succ u1) (succ u2)} ((fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) g)) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} {{f : RingHom.{u2, u1} α β rα rβ}} {{g : RingHom.{u2, u1} α β rα rβ}}, (Eq.{max (succ u2) (succ u1)} (forall (a : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) g)) -> (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_inj RingHom.coe_injₓ'. -/\ntheorem coe_inj ⦃f g : α →+* β⦄ (h : (f : α → β) = g) : f = g :=\n  FunLike.coe_injective h\n#align ring_hom.coe_inj RingHom.coe_inj\n\n/- warning: ring_hom.ext -> RingHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} {{f : RingHom.{u1, u2} α β rα rβ}} {{g : RingHom.{u1, u2} α β rα rβ}}, (forall (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) g x)) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} {{f : RingHom.{u2, u1} α β rα rβ}} {{g : RingHom.{u2, u1} α β rα rβ}}, (forall (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) g x)) -> (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.ext RingHom.extₓ'. -/\n@[ext]\ntheorem ext ⦃f g : α →+* β⦄ : (∀ x, f x = g x) → f = g :=\n  FunLike.ext _ _\n#align ring_hom.ext RingHom.ext\n\n/- warning: ring_hom.ext_iff -> RingHom.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} {f : RingHom.{u1, u2} α β rα rβ} {g : RingHom.{u1, u2} α β rα rβ}, Iff (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) f g) (forall (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) g x))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} {f : RingHom.{u2, u1} α β rα rβ} {g : RingHom.{u2, u1} α β rα rβ}, Iff (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) f g) (forall (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) g x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.ext_iff RingHom.ext_iffₓ'. -/\ntheorem ext_iff {f g : α →+* β} : f = g ↔ ∀ x, f x = g x :=\n  FunLike.ext_iff\n#align ring_hom.ext_iff RingHom.ext_iff\n\n/- warning: ring_hom.mk_coe -> RingHom.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) (h₁ : Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (MulOneClass.toHasOne.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))))))) (h₂ : forall (x : α) (y : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))) x y)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (MulOneClass.toHasMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f y))) (h₃ : Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))))) (h₄ : forall (x : α) (y : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (AddZeroClass.toHasAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))) x y)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f y))), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (RingHom.mk.{u1, u2} α β rα rβ (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f) h₁ h₂ h₃ h₄) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ) (h₁ : Eq.{succ u1} β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)))))) (h₂ : forall (x : α) (y : α), Eq.{succ u1} β (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) x y)) (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (MulOneClass.toMul.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)))) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) x) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) y))) (h₃ : Eq.{succ u1} β (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (MonoidHom.mk.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) h₂)) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (AddZeroClass.toZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))))))) (OfNat.ofNat.{u1} β 0 (Zero.toOfNat0.{u1} β (AddZeroClass.toZero.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))))))) (h₄ : forall (x : α) (y : α), Eq.{succ u1} β (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (MonoidHom.mk.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) h₂)) (HAdd.hAdd.{u2, u2, u2} α α α (instHAdd.{u2} α (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))))) x y)) (HAdd.hAdd.{u1, u1, u1} β β β (instHAdd.{u1} β (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))))) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (MonoidHom.mk.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) h₂)) x) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (MonoidHom.mk.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) h₂)) y))), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) (RingHom.mk.{u2, u1} α β rα rβ (MonoidHom.mk.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (OneHom.mk.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (a : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f) h₁) h₂) h₃ h₄) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.mk_coe RingHom.mk_coeₓ'. -/\n@[simp]\ntheorem mk_coe (f : α →+* β) (h₁ h₂ h₃ h₄) : RingHom.mk f h₁ h₂ h₃ h₄ = f :=\n  ext fun _ => rfl\n#align ring_hom.mk_coe RingHom.mk_coe\n\n/- warning: ring_hom.coe_add_monoid_hom_injective -> RingHom.coe_addMonoidHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (AddMonoidHom.{u1, u2} α β (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) (AddMonoidHom.{u2, u1} α β (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ))))) (fun (f : RingHom.{u2, u1} α β rα rβ) => AddMonoidHomClass.toAddMonoidHom.{u2, u1, max u2 u1} α β (RingHom.{u2, u1} α β rα rβ) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α rα)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β rβ)))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injectiveₓ'. -/\ntheorem coe_addMonoidHom_injective : Injective (coe : (α →+* β) → α →+ β) := fun f g h =>\n  ext <| AddMonoidHom.congr_fun h\n#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective\n\n/- warning: ring_hom.coe_monoid_hom_injective -> RingHom.coe_monoidHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u2) (succ u1)} a b] => self.0) (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} α β rα rβ) (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} α β (RingHom.{u1, u2} α β rα rβ) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.ringHomClass.{u1, u2} α β rα rβ))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) (MonoidHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ))) (fun (f : RingHom.{u2, u1} α β rα rβ) => MonoidHomClass.toMonoidHom.{u2, u1, max u2 u1} α β (RingHom.{u2, u1} α β rα rβ) (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β rβ)) (RingHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injectiveₓ'. -/\ntheorem coe_monoidHom_injective : Injective (coe : (α →+* β) → α →* β) := fun f g h =>\n  ext <| MonoidHom.congr_fun h\n#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective\n\n/- warning: ring_hom.map_zero -> RingHom.map_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))))) (MulZeroOneClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))))) (NonAssocSemiring.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα))))) rβ))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_zero RingHom.map_zeroₓ'. -/\n/-- Ring homomorphisms map zero to zero. -/\nprotected theorem map_zero (f : α →+* β) : f 0 = 0 :=\n  map_zero f\n#align ring_hom.map_zero RingHom.map_zero\n\n/- warning: ring_hom.map_one -> RingHom.map_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα)))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα)))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα)))) (NonAssocSemiring.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα)))) rβ)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_one RingHom.map_oneₓ'. -/\n/-- Ring homomorphisms map one to one. -/\nprotected theorem map_one (f : α →+* β) : f 1 = 1 :=\n  map_one f\n#align ring_hom.map_one RingHom.map_one\n\n/- warning: ring_hom.map_add -> RingHom.map_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) (a : α) (b : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)))) a b)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ) (a : α) (b : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (HAdd.hAdd.{u2, u2, u2} α α α (instHAdd.{u2} α (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)))) a b)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f (HAdd.hAdd.{u2, u2, u2} α α α (instHAdd.{u2} α (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)))) a b)) (HAdd.hAdd.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (instHAdd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (Distrib.toAdd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonUnitalNonAssocSemiring.toDistrib.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) rβ)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f b))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_add RingHom.map_addₓ'. -/\n/-- Ring homomorphisms preserve addition. -/\nprotected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=\n  map_add f\n#align ring_hom.map_add RingHom.map_add\n\n/- warning: ring_hom.map_mul -> RingHom.map_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) (a : α) (b : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)))) a b)) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ) (a : α) (b : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα))) a b)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα))) a b)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonUnitalNonAssocSemiring.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) rβ))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u2, u1} α β rα rβ)))) f b))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_mul RingHom.map_mulₓ'. -/\n/-- Ring homomorphisms preserve multiplication. -/\nprotected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=\n  map_mul f\n#align ring_hom.map_mul RingHom.map_mul\n\n/-- Ring homomorphisms preserve `bit0`. -/\nprotected theorem map_bit0 (f : α →+* β) : ∀ a, f (bit0 a) = bit0 (f a) :=\n  map_bit0 f\n#align ring_hom.map_bit0 RingHom.map_bit0\n\n/-- Ring homomorphisms preserve `bit1`. -/\nprotected theorem map_bit1 (f : α →+* β) : ∀ a, f (bit1 a) = bit1 (f a) :=\n  map_bit1 f\n#align ring_hom.map_bit1 RingHom.map_bit1\n\n/- warning: ring_hom.map_ite_zero_one -> RingHom.map_ite_zero_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u1, u2} F α β rα rβ] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u2} β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} F α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα))) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F α β rα rβ _inst_1)))) f (ite.{succ u1} α p _inst_2 (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))))) (ite.{succ u2} β p _inst_2 (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u2, u1} F α β rα rβ] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) (FunLike.coe.{succ u3, succ u2, succ u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u2, u1} F α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{u3, u2, u1} F α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{u3, u2, u1} F α β rα rβ _inst_1))) f (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) (ite.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) p _inst_2 (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) (MulZeroOneClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) (NonAssocSemiring.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) rβ)))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) (NonAssocSemiring.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))))) rβ))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_oneₓ'. -/\n@[simp]\ntheorem map_ite_zero_one {F : Type _} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :\n    f (ite p 0 1) = ite p 0 1 := by split_ifs <;> simp [h]\n#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one\n\n/- warning: ring_hom.map_ite_one_zero -> RingHom.map_ite_one_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u1, u2} F α β rα rβ] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u2} β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (MulHomClass.toFunLike.{u3, u1, u2} F α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα))) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F α β rα rβ _inst_1)))) f (ite.{succ u1} α p _inst_2 (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)))))))) (ite.{succ u2} β p _inst_2 (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ)))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u2, u1} F α β rα rβ] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) (FunLike.coe.{succ u3, succ u2, succ u1} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{u3, u2, u1} F α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{u3, u2, u1} F α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β rβ) (RingHomClass.toNonUnitalRingHomClass.{u3, u2, u1} F α β rα rβ _inst_1))) f (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) (ite.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) p _inst_2 (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) (NonAssocSemiring.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) rβ))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) (MulZeroOneClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) (NonAssocSemiring.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (ite.{succ u2} α p _inst_2 (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocSemiring.toOne.{u2} α rα))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α rα)))))) rβ)))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_ite_one_zero RingHom.map_ite_one_zeroₓ'. -/\n@[simp]\ntheorem map_ite_one_zero {F : Type _} [RingHomClass F α β] (f : F) (p : Prop) [Decidable p] :\n    f (ite p 1 0) = ite p 1 0 := by split_ifs <;> simp [h]\n#align ring_hom.map_ite_one_zero RingHom.map_ite_one_zero\n\n/- warning: ring_hom.codomain_trivial_iff_map_one_eq_zero -> RingHom.codomain_trivial_iff_map_one_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Iff (Eq.{succ u2} β (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))) (Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Iff (Eq.{succ u2} β (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (MulZeroOneClass.toZero.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocSemiring.toOne.{u2} β rβ)))) (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u2} α β rα rβ)))) f (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (MulZeroOneClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (NonAssocSemiring.toMulZeroOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) rβ)))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.codomain_trivial_iff_map_one_eq_zero RingHom.codomain_trivial_iff_map_one_eq_zeroₓ'. -/\n/-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/\ntheorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 := by rw [map_one, eq_comm]\n#align ring_hom.codomain_trivial_iff_map_one_eq_zero RingHom.codomain_trivial_iff_map_one_eq_zero\n\n/- warning: ring_hom.codomain_trivial_iff_range_trivial -> RingHom.codomain_trivial_iff_range_trivial is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Iff (Eq.{succ u2} β (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))) (forall (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f x) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Iff (Eq.{succ u2} β (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (MulZeroOneClass.toZero.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocSemiring.toOne.{u2} β rβ)))) (forall (x : α), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u2} α β rα rβ)))) f x) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (MulZeroOneClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (NonAssocSemiring.toMulZeroOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) rβ)))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.codomain_trivial_iff_range_trivial RingHom.codomain_trivial_iff_range_trivialₓ'. -/\n/-- `f : α →+* β` has a trivial codomain iff it has a trivial range. -/\ntheorem codomain_trivial_iff_range_trivial : (0 : β) = 1 ↔ ∀ x, f x = 0 :=\n  f.codomain_trivial_iff_map_one_eq_zero.trans\n    ⟨fun h x => by rw [← mul_one x, map_mul, h, MulZeroClass.mul_zero], fun h => h 1⟩\n#align ring_hom.codomain_trivial_iff_range_trivial RingHom.codomain_trivial_iff_range_trivial\n\n/- warning: ring_hom.codomain_trivial_iff_range_eq_singleton_zero -> RingHom.codomain_trivial_iff_range_eq_singleton_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Iff (Eq.{succ u2} β (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)))))) (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β rβ))))))) (Eq.{succ u2} (Set.{u2} β) (Set.range.{u2, succ u1} β α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)) (Singleton.singleton.{u2, u2} β (Set.{u2} β) (Set.hasSingleton.{u2} β) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ), Iff (Eq.{succ u2} β (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (MulZeroOneClass.toZero.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ)))) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocSemiring.toOne.{u2} β rβ)))) (Eq.{succ u2} (Set.{u2} β) (Set.range.{u2, succ u1} β α (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u2} α β rα rβ)))) f)) (Singleton.singleton.{u2, u2} β (Set.{u2} β) (Set.instSingletonSet.{u2} β) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (MulZeroOneClass.toZero.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β rβ))))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.codomain_trivial_iff_range_eq_singleton_zero RingHom.codomain_trivial_iff_range_eq_singleton_zeroₓ'. -/\n/-- `f : α →+* β` has a trivial codomain iff its range is `{0}`. -/\ntheorem codomain_trivial_iff_range_eq_singleton_zero : (0 : β) = 1 ↔ Set.range f = {0} :=\n  f.codomain_trivial_iff_range_trivial.trans\n    ⟨fun h =>\n      Set.ext fun y => ⟨fun ⟨x, hx⟩ => by simp [← hx, h x], fun hy => ⟨0, by simpa using hy.symm⟩⟩,\n      fun h x => Set.mem_singleton_iff.mp (h ▸ Set.mem_range_self x)⟩\n#align ring_hom.codomain_trivial_iff_range_eq_singleton_zero RingHom.codomain_trivial_iff_range_eq_singleton_zero\n\n/- warning: ring_hom.map_one_ne_zero -> RingHom.map_one_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) [_inst_1 : Nontrivial.{u2} β], Ne.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (MulZeroClass.toHasZero.{u2} β (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β} (f : RingHom.{u1, u2} α β rα rβ) [_inst_1 : Nontrivial.{u2} β], Ne.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u2} α β rα rβ)))) f (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (MulZeroOneClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) (NonAssocSemiring.toMulZeroOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocSemiring.toOne.{u1} α rα)))) rβ))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_one_ne_zero RingHom.map_one_ne_zeroₓ'. -/\n/-- `f : α →+* β` doesn't map `1` to `0` if `β` is nontrivial -/\ntheorem map_one_ne_zero [Nontrivial β] : f 1 ≠ 0 :=\n  mt f.codomain_trivial_iff_map_one_eq_zero.mpr zero_ne_one\n#align ring_hom.map_one_ne_zero RingHom.map_one_ne_zero\n\n#print RingHom.domain_nontrivial /-\n/-- If there is a homomorphism `f : α →+* β` and `β` is nontrivial, then `α` is nontrivial. -/\ntheorem domain_nontrivial [Nontrivial β] : Nontrivial α :=\n  ⟨⟨1, 0, mt (fun h => show f 1 = 0 by rw [h, map_zero]) f.map_one_ne_zero⟩⟩\n#align ring_hom.domain_nontrivial RingHom.domain_nontrivial\n-/\n\n/- warning: ring_hom.codomain_trivial -> RingHom.codomain_trivial is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u2} β}, (RingHom.{u1, u2} α β rα rβ) -> (forall [h : Subsingleton.{succ u1} α], Subsingleton.{succ u2} β)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β}, (RingHom.{u2, u1} α β rα rβ) -> (forall [h : Subsingleton.{succ u2} α], Subsingleton.{succ u1} β)\nCase conversion may be inaccurate. Consider using '#align ring_hom.codomain_trivial RingHom.codomain_trivialₓ'. -/\ntheorem codomain_trivial (f : α →+* β) [h : Subsingleton α] : Subsingleton β :=\n  (subsingleton_or_nontrivial β).resolve_right fun _ =>\n    not_nontrivial_iff_subsingleton.mpr h f.domain_nontrivial\n#align ring_hom.codomain_trivial RingHom.codomain_trivial\n\nend\n\n/- warning: ring_hom.map_neg -> RingHom.map_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocRing.{u1} α] [_inst_2 : NonAssocRing.{u2} β] (f : RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) (x : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) f (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (NonAssocRing.toAddCommGroupWithOne.{u1} α _inst_1))))) x)) (Neg.neg.{u2} β (SubNegMonoid.toHasNeg.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddGroupWithOne.toAddGroup.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (NonAssocRing.toAddCommGroupWithOne.{u2} β _inst_2))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) f x))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocRing.{u2} α] [_inst_2 : NonAssocRing.{u1} β] (f : RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (Neg.neg.{u2} α (AddGroupWithOne.toNeg.{u2} α (AddCommGroupWithOne.toAddGroupWithOne.{u2} α (NonAssocRing.toAddCommGroupWithOne.{u2} α _inst_1))) x)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))))) f (Neg.neg.{u2} α (AddGroupWithOne.toNeg.{u2} α (AddCommGroupWithOne.toAddGroupWithOne.{u2} α (NonAssocRing.toAddCommGroupWithOne.{u2} α _inst_1))) x)) (Neg.neg.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (AddGroupWithOne.toNeg.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (AddCommGroupWithOne.toAddGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (NonAssocRing.toAddCommGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) _inst_2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))))) f x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_neg RingHom.map_negₓ'. -/\n/-- Ring homomorphisms preserve additive inverse. -/\nprotected theorem map_neg [NonAssocRing α] [NonAssocRing β] (f : α →+* β) (x : α) : f (-x) = -f x :=\n  map_neg f x\n#align ring_hom.map_neg RingHom.map_neg\n\n/- warning: ring_hom.map_sub -> RingHom.map_sub is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocRing.{u1} α] [_inst_2 : NonAssocRing.{u2} β] (f : RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) (x : α) (y : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) f (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (NonAssocRing.toAddCommGroupWithOne.{u1} α _inst_1)))))) x y)) (HSub.hSub.{u2, u2, u2} β β β (instHSub.{u2} β (SubNegMonoid.toHasSub.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddGroupWithOne.toAddGroup.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (NonAssocRing.toAddCommGroupWithOne.{u2} β _inst_2)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (NonAssocRing.toNonAssocSemiring.{u1} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)) f y))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocRing.{u2} α] [_inst_2 : NonAssocRing.{u1} β] (f : RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) (x : α) (y : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (HSub.hSub.{u2, u2, u2} α α α (instHSub.{u2} α (AddGroupWithOne.toSub.{u2} α (AddCommGroupWithOne.toAddGroupWithOne.{u2} α (NonAssocRing.toAddCommGroupWithOne.{u2} α _inst_1)))) x y)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))))) f (HSub.hSub.{u2, u2, u2} α α α (instHSub.{u2} α (AddGroupWithOne.toSub.{u2} α (AddCommGroupWithOne.toAddGroupWithOne.{u2} α (NonAssocRing.toAddCommGroupWithOne.{u2} α _inst_1)))) x y)) (HSub.hSub.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) y) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (instHSub.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (AddGroupWithOne.toSub.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (AddCommGroupWithOne.toAddGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) (NonAssocRing.toAddCommGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) x) _inst_2)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (NonAssocRing.toNonAssocSemiring.{u2} α _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} β _inst_2))))) f y))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_sub RingHom.map_subₓ'. -/\n/-- Ring homomorphisms preserve subtraction. -/\nprotected theorem map_sub [NonAssocRing α] [NonAssocRing β] (f : α →+* β) (x y : α) :\n    f (x - y) = f x - f y :=\n  map_sub f x y\n#align ring_hom.map_sub RingHom.map_sub\n\n/- warning: ring_hom.mk' -> RingHom.mk' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : NonAssocRing.{u2} β] (f : MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))), (forall (a : α) (b : α), Eq.{succ u2} β (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) (fun (_x : MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)))) a b)) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β _inst_2))))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) (fun (_x : MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) f a) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) (fun (_x : MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) => α -> β) (MonoidHom.hasCoeToFun.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) f b))) -> (RingHom.{u1, u2} α β _inst_1 (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : NonAssocRing.{u2} β] (f : MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))), (forall (a : α) (b : α), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)))) a b)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α β (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1))) (MulOneClass.toMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2))) (MonoidHom.monoidHomClass.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))))) f (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)))) a b)) (HAdd.hAdd.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (instHAdd.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (Distrib.toAdd.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonUnitalNonAssocSemiring.toDistrib.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonAssocRing.toNonUnitalNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) _inst_2))))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α β (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1))) (MulOneClass.toMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2))) (MonoidHom.monoidHomClass.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))))) f a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α β (MulOneClass.toMul.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1))) (MulOneClass.toMul.{u2} β (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))) α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2))) (MonoidHom.monoidHomClass.{u1, u2} α β (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} β (NonAssocSemiring.toMulZeroOneClass.{u2} β (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2)))))) f b))) -> (RingHom.{u1, u2} α β _inst_1 (NonAssocRing.toNonAssocSemiring.{u2} β _inst_2))\nCase conversion may be inaccurate. Consider using '#align ring_hom.mk' RingHom.mk'ₓ'. -/\n/-- Makes a ring homomorphism from a monoid homomorphism of rings which preserves addition. -/\ndef mk' [NonAssocSemiring α] [NonAssocRing β] (f : α →* β)\n    (map_add : ∀ a b, f (a + b) = f a + f b) : α →+* β :=\n  { AddMonoidHom.mk' f map_add, f with }\n#align ring_hom.mk' RingHom.mk'\n\nsection Semiring\n\nvariable [Semiring α] [Semiring β]\n\n/- warning: ring_hom.is_unit_map -> RingHom.isUnit_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Semiring.{u1} α] [_inst_2 : Semiring.{u2} β] (f : RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) {a : α}, (IsUnit.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α _inst_1)) a) -> (IsUnit.{u2} β (MonoidWithZero.toMonoid.{u2} β (Semiring.toMonoidWithZero.{u2} β _inst_2)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) f a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Semiring.{u2} α] [_inst_2 : Semiring.{u1} β] (f : RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) {a : α}, (IsUnit.{u2} α (MonoidWithZero.toMonoid.{u2} α (Semiring.toMonoidWithZero.{u2} α _inst_1)) a) -> (IsUnit.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) _inst_2)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (Semiring.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (Semiring.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2))))) f a))\nCase conversion may be inaccurate. Consider using '#align ring_hom.is_unit_map RingHom.isUnit_mapₓ'. -/\ntheorem isUnit_map (f : α →+* β) {a : α} : IsUnit a → IsUnit (f a) :=\n  IsUnit.map f\n#align ring_hom.is_unit_map RingHom.isUnit_map\n\n/- warning: ring_hom.map_dvd -> RingHom.map_dvd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Semiring.{u1} α] [_inst_2 : Semiring.{u2} β] (f : RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) {a : α} {b : α}, (Dvd.Dvd.{u1} α (semigroupDvd.{u1} α (SemigroupWithZero.toSemigroup.{u1} α (NonUnitalSemiring.toSemigroupWithZero.{u1} α (Semiring.toNonUnitalSemiring.{u1} α _inst_1)))) a b) -> (Dvd.Dvd.{u2} β (semigroupDvd.{u2} β (SemigroupWithZero.toSemigroup.{u2} β (NonUnitalSemiring.toSemigroupWithZero.{u2} β (Semiring.toNonUnitalSemiring.{u2} β _inst_2)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) (fun (_x : RingHom.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β (Semiring.toNonAssocSemiring.{u1} α _inst_1) (Semiring.toNonAssocSemiring.{u2} β _inst_2)) f b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Semiring.{u2} α] [_inst_2 : Semiring.{u1} β] (f : RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) {a : α} {b : α}, (Dvd.dvd.{u2} α (semigroupDvd.{u2} α (SemigroupWithZero.toSemigroup.{u2} α (NonUnitalSemiring.toSemigroupWithZero.{u2} α (Semiring.toNonUnitalSemiring.{u2} α _inst_1)))) a b) -> (Dvd.dvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (semigroupDvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (SemigroupWithZero.toSemigroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (NonUnitalSemiring.toSemigroupWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (Semiring.toNonUnitalSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) _inst_2)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (Semiring.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (Semiring.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (Semiring.toNonAssocSemiring.{u1} β _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (Semiring.toNonAssocSemiring.{u1} β _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2)) α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} α β (Semiring.toNonAssocSemiring.{u2} α _inst_1) (Semiring.toNonAssocSemiring.{u1} β _inst_2))))) f b))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_dvd RingHom.map_dvdₓ'. -/\nprotected theorem map_dvd (f : α →+* β) {a b : α} : a ∣ b → f a ∣ f b :=\n  map_dvd f\n#align ring_hom.map_dvd RingHom.map_dvd\n\nend Semiring\n\n#print RingHom.id /-\n/-- The identity ring homomorphism from a semiring to itself. -/\ndef id (α : Type _) [NonAssocSemiring α] : α →+* α := by\n  refine' { toFun := id.. } <;> intros <;> rfl\n#align ring_hom.id RingHom.id\n-/\n\ninclude rα\n\ninstance : Inhabited (α →+* α) :=\n  ⟨id α⟩\n\n/- warning: ring_hom.id_apply -> RingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonAssocSemiring.{u1} α] (x : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (fun (_x : RingHom.{u1, u1} α α rα rα) => α -> α) (RingHom.hasCoeToFun.{u1, u1} α α rα rα) (RingHom.id.{u1} α rα) x) x\nbut is expected to have type\n  forall {α : Type.{u1}} {rα : NonAssocSemiring.{u1} α} (x : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) x) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.instRingHomClassRingHom.{u1, u1} α α rα rα)))) (RingHom.id.{u1} α rα) x) x\nCase conversion may be inaccurate. Consider using '#align ring_hom.id_apply RingHom.id_applyₓ'. -/\n@[simp]\ntheorem id_apply (x : α) : RingHom.id α x = x :=\n  rfl\n#align ring_hom.id_apply RingHom.id_apply\n\n/- warning: ring_hom.coe_add_monoid_hom_id -> RingHom.coe_addMonoidHom_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonAssocSemiring.{u1} α], Eq.{succ u1} (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (RingHom.{u1, u1} α α rα rα) (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))) (HasLiftT.mk.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))) (CoeTCₓ.coe.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))) (AddMonoidHom.hasCoeT.{u1, u1, u1} α α (RingHom.{u1, u1} α α rα rα) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (RingHomClass.toAddMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.ringHomClass.{u1, u1} α α rα rα))))) (RingHom.id.{u1} α rα)) (AddMonoidHom.id.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {rα : NonAssocSemiring.{u1} α}, Eq.{succ u1} (AddMonoidHom.{u1, u1} α α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα))))) (AddMonoidHomClass.toAddMonoidHom.{u1, u1, u1} α α (RingHom.{u1, u1} α α rα rα) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))) (RingHomClass.toAddMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.instRingHomClassRingHom.{u1, u1} α α rα rα)) (RingHom.id.{u1} α rα)) (AddMonoidHom.id.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α rα)))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom_id RingHom.coe_addMonoidHom_idₓ'. -/\n@[simp]\ntheorem coe_addMonoidHom_id : (id α : α →+ α) = AddMonoidHom.id α :=\n  rfl\n#align ring_hom.coe_add_monoid_hom_id RingHom.coe_addMonoidHom_id\n\n/- warning: ring_hom.coe_monoid_hom_id -> RingHom.coe_monoidHom_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonAssocSemiring.{u1} α], Eq.{succ u1} (MonoidHom.{u1, u1} α α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (RingHom.{u1, u1} α α rα rα) (MonoidHom.{u1, u1} α α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (HasLiftT.mk.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (MonoidHom.{u1, u1} α α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (CoeTCₓ.coe.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (MonoidHom.{u1, u1} α α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MonoidHom.hasCoeT.{u1, u1, u1} α α (RingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (RingHomClass.toMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.ringHomClass.{u1, u1} α α rα rα))))) (RingHom.id.{u1} α rα)) (MonoidHom.id.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))\nbut is expected to have type\n  forall {α : Type.{u1}} {rα : NonAssocSemiring.{u1} α}, Eq.{succ u1} (MonoidHom.{u1, u1} α α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα))) (MonoidHomClass.toMonoidHom.{u1, u1, u1} α α (RingHom.{u1, u1} α α rα rα) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)) (RingHomClass.toMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.instRingHomClassRingHom.{u1, u1} α α rα rα)) (RingHom.id.{u1} α rα)) (MonoidHom.id.{u1} α (MulZeroOneClass.toMulOneClass.{u1} α (NonAssocSemiring.toMulZeroOneClass.{u1} α rα)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom_id RingHom.coe_monoidHom_idₓ'. -/\n@[simp]\ntheorem coe_monoidHom_id : (id α : α →* α) = MonoidHom.id α :=\n  rfl\n#align ring_hom.coe_monoid_hom_id RingHom.coe_monoidHom_id\n\nvariable {rγ : NonAssocSemiring γ}\n\ninclude rβ rγ\n\n#print RingHom.comp /-\n/-- Composition of ring homomorphisms is a ring homomorphism. -/\ndef comp (g : β →+* γ) (f : α →+* β) : α →+* γ :=\n  {\n    g.toNonUnitalRingHom.comp f.toNonUnitalRingHom with\n    toFun := g ∘ f\n    map_one' := by simp }\n#align ring_hom.comp RingHom.comp\n-/\n\n/- warning: ring_hom.comp_assoc -> RingHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonAssocSemiring.{u1} α] [rβ : NonAssocSemiring.{u2} β] {rγ : NonAssocSemiring.{u3} γ} {δ : Type.{u4}} {rδ : NonAssocSemiring.{u4} δ} (f : RingHom.{u1, u2} α β rα rβ) (g : RingHom.{u2, u3} β γ rβ rγ) (h : RingHom.{u3, u4} γ δ rγ rδ), Eq.{max (succ u1) (succ u4)} (RingHom.{u1, u4} α δ rα rδ) (RingHom.comp.{u1, u2, u4} α β δ rα rβ rδ (RingHom.comp.{u2, u3, u4} β γ δ rβ rγ rδ h g) f) (RingHom.comp.{u1, u3, u4} α γ δ rα rγ rδ h (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} {rα : NonAssocSemiring.{u3} α} {rβ : NonAssocSemiring.{u2} β} {rγ : NonAssocSemiring.{u1} γ} {δ : Type.{u4}} {rδ : NonAssocSemiring.{u4} δ} (f : RingHom.{u3, u2} α β rα rβ) (g : RingHom.{u2, u1} β γ rβ rγ) (h : RingHom.{u1, u4} γ δ rγ rδ), Eq.{max (succ u3) (succ u4)} (RingHom.{u3, u4} α δ rα rδ) (RingHom.comp.{u3, u2, u4} α β δ rα rβ rδ (RingHom.comp.{u2, u1, u4} β γ δ rβ rγ rδ h g) f) (RingHom.comp.{u3, u1, u4} α γ δ rα rγ rδ h (RingHom.comp.{u3, u2, u1} α β γ rα rβ rγ g f))\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_assoc RingHom.comp_assocₓ'. -/\n/-- Composition of semiring homomorphisms is associative. -/\ntheorem comp_assoc {δ} {rδ : NonAssocSemiring δ} (f : α →+* β) (g : β →+* γ) (h : γ →+* δ) :\n    (h.comp g).comp f = h.comp (g.comp f) :=\n  rfl\n#align ring_hom.comp_assoc RingHom.comp_assoc\n\n/- warning: ring_hom.coe_comp -> RingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonAssocSemiring.{u1} α] [rβ : NonAssocSemiring.{u2} β] {rγ : NonAssocSemiring.{u3} γ} (hnp : RingHom.{u2, u3} β γ rβ rγ) (hmn : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u3)} ((fun (_x : RingHom.{u1, u3} α γ rα rγ) => α -> γ) (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ hnp hmn)) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} α γ rα rγ) (fun (_x : RingHom.{u1, u3} α γ rα rγ) => α -> γ) (RingHom.hasCoeToFun.{u1, u3} α γ rα rγ) (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ hnp hmn)) (Function.comp.{succ u1, succ u2, succ u3} α β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} β γ rβ rγ) (fun (_x : RingHom.{u2, u3} β γ rβ rγ) => β -> γ) (RingHom.hasCoeToFun.{u2, u3} β γ rβ rγ) hnp) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) hmn))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u3} β} {rγ : NonAssocSemiring.{u2} γ} (hnp : RingHom.{u3, u2} β γ rβ rγ) (hmn : RingHom.{u1, u3} α β rα rβ), Eq.{max (succ u1) (succ u2)} (forall (a : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} α γ rα rγ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} α γ rα rγ) α γ (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u2} γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α γ rα rγ) α γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α γ rα rγ) α γ rα rγ (RingHom.instRingHomClassRingHom.{u1, u2} α γ rα rγ)))) (RingHom.comp.{u1, u3, u2} α β γ rα rβ rγ hnp hmn)) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} β γ rβ rγ) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ)) (NonUnitalNonAssocSemiring.toMul.{u2} γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (RingHom.instRingHomClassRingHom.{u3, u2} β γ rβ rγ)))) hnp) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u3} α β rα rβ)))) hmn))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_comp RingHom.coe_compₓ'. -/\n@[simp]\ntheorem coe_comp (hnp : β →+* γ) (hmn : α →+* β) : (hnp.comp hmn : α → γ) = hnp ∘ hmn :=\n  rfl\n#align ring_hom.coe_comp RingHom.coe_comp\n\n/- warning: ring_hom.comp_apply -> RingHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonAssocSemiring.{u1} α] [rβ : NonAssocSemiring.{u2} β] {rγ : NonAssocSemiring.{u3} γ} (hnp : RingHom.{u2, u3} β γ rβ rγ) (hmn : RingHom.{u1, u2} α β rα rβ) (x : α), Eq.{succ u3} γ (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} α γ rα rγ) (fun (_x : RingHom.{u1, u3} α γ rα rγ) => α -> γ) (RingHom.hasCoeToFun.{u1, u3} α γ rα rγ) (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ hnp hmn) x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} β γ rβ rγ) (fun (_x : RingHom.{u2, u3} β γ rβ rγ) => β -> γ) (RingHom.hasCoeToFun.{u2, u3} β γ rβ rγ) hnp (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) hmn x))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u3} β} {rγ : NonAssocSemiring.{u2} γ} (hnp : RingHom.{u3, u2} β γ rβ rγ) (hmn : RingHom.{u1, u3} α β rα rβ) (x : α), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} α γ rα rγ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => γ) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} α γ rα rγ) α γ (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u2} γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α γ rα rγ) α γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} α γ rα rγ) α γ rα rγ (RingHom.instRingHomClassRingHom.{u1, u2} α γ rα rγ)))) (RingHom.comp.{u1, u3, u2} α β γ rα rβ rγ hnp hmn) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} β γ rβ rγ) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ)) (NonUnitalNonAssocSemiring.toMul.{u2} γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (RingHom.instRingHomClassRingHom.{u3, u2} β γ rβ rγ)))) hnp (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u3} α β rα rβ)))) hmn x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_apply RingHom.comp_applyₓ'. -/\ntheorem comp_apply (hnp : β →+* γ) (hmn : α →+* β) (x : α) :\n    (hnp.comp hmn : α → γ) x = hnp (hmn x) :=\n  rfl\n#align ring_hom.comp_apply RingHom.comp_apply\n\nomit rγ\n\n/- warning: ring_hom.comp_id -> RingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [rα : NonAssocSemiring.{u1} α] [rβ : NonAssocSemiring.{u2} β] (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (RingHom.comp.{u1, u1, u2} α α β rα rα rβ f (RingHom.id.{u1} α rα)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) (RingHom.comp.{u2, u2, u1} α α β rα rα rβ f (RingHom.id.{u2} α rα)) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_id RingHom.comp_idₓ'. -/\n@[simp]\ntheorem comp_id (f : α →+* β) : f.comp (id α) = f :=\n  ext fun x => rfl\n#align ring_hom.comp_id RingHom.comp_id\n\n/- warning: ring_hom.id_comp -> RingHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [rα : NonAssocSemiring.{u1} α] [rβ : NonAssocSemiring.{u2} β] (f : RingHom.{u1, u2} α β rα rβ), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (RingHom.comp.{u1, u2, u2} α β β rα rβ rβ (RingHom.id.{u2} β rβ) f) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {rα : NonAssocSemiring.{u2} α} {rβ : NonAssocSemiring.{u1} β} (f : RingHom.{u2, u1} α β rα rβ), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β rα rβ) (RingHom.comp.{u2, u1, u1} α β β rα rβ rβ (RingHom.id.{u1} β rβ) f) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.id_comp RingHom.id_compₓ'. -/\n@[simp]\ntheorem id_comp (f : α →+* β) : (id β).comp f = f :=\n  ext fun x => rfl\n#align ring_hom.id_comp RingHom.id_comp\n\nomit rβ\n\ninstance : Monoid (α →+* α) where\n  one := id α\n  mul := comp\n  mul_one := comp_id\n  one_mul := id_comp\n  mul_assoc f g h := comp_assoc _ _ _\n\n/- warning: ring_hom.one_def -> RingHom.one_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonAssocSemiring.{u1} α], Eq.{succ u1} (RingHom.{u1, u1} α α rα rα) (OfNat.ofNat.{u1} (RingHom.{u1, u1} α α rα rα) 1 (OfNat.mk.{u1} (RingHom.{u1, u1} α α rα rα) 1 (One.one.{u1} (RingHom.{u1, u1} α α rα rα) (MulOneClass.toHasOne.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.monoid.{u1} α rα)))))) (RingHom.id.{u1} α rα)\nbut is expected to have type\n  forall {α : Type.{u1}} {rα : NonAssocSemiring.{u1} α}, Eq.{succ u1} (RingHom.{u1, u1} α α rα rα) (OfNat.ofNat.{u1} (RingHom.{u1, u1} α α rα rα) 1 (One.toOfNat1.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toOne.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.instMonoidRingHom.{u1} α rα)))) (RingHom.id.{u1} α rα)\nCase conversion may be inaccurate. Consider using '#align ring_hom.one_def RingHom.one_defₓ'. -/\ntheorem one_def : (1 : α →+* α) = id α :=\n  rfl\n#align ring_hom.one_def RingHom.one_def\n\n/- warning: ring_hom.mul_def -> RingHom.mul_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonAssocSemiring.{u1} α] (f : RingHom.{u1, u1} α α rα rα) (g : RingHom.{u1, u1} α α rα rα), Eq.{succ u1} (RingHom.{u1, u1} α α rα rα) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (instHMul.{u1} (RingHom.{u1, u1} α α rα rα) (MulOneClass.toHasMul.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.monoid.{u1} α rα)))) f g) (RingHom.comp.{u1, u1, u1} α α α rα rα rα f g)\nbut is expected to have type\n  forall {α : Type.{u1}} {rα : NonAssocSemiring.{u1} α} (f : RingHom.{u1, u1} α α rα rα) (g : RingHom.{u1, u1} α α rα rα), Eq.{succ u1} (RingHom.{u1, u1} α α rα rα) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (instHMul.{u1} (RingHom.{u1, u1} α α rα rα) (MulOneClass.toMul.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.instMonoidRingHom.{u1} α rα)))) f g) (RingHom.comp.{u1, u1, u1} α α α rα rα rα f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.mul_def RingHom.mul_defₓ'. -/\ntheorem mul_def (f g : α →+* α) : f * g = f.comp g :=\n  rfl\n#align ring_hom.mul_def RingHom.mul_def\n\n/- warning: ring_hom.coe_one -> RingHom.coe_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonAssocSemiring.{u1} α], Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (fun (_x : RingHom.{u1, u1} α α rα rα) => α -> α) (RingHom.hasCoeToFun.{u1, u1} α α rα rα) (OfNat.ofNat.{u1} (RingHom.{u1, u1} α α rα rα) 1 (OfNat.mk.{u1} (RingHom.{u1, u1} α α rα rα) 1 (One.one.{u1} (RingHom.{u1, u1} α α rα rα) (MulOneClass.toHasOne.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.monoid.{u1} α rα))))))) (id.{succ u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} {rα : NonAssocSemiring.{u1} α}, Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.instRingHomClassRingHom.{u1, u1} α α rα rα)))) (OfNat.ofNat.{u1} (RingHom.{u1, u1} α α rα rα) 1 (One.toOfNat1.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toOne.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.instMonoidRingHom.{u1} α rα))))) (id.{succ u1} α)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_one RingHom.coe_oneₓ'. -/\n@[simp]\ntheorem coe_one : ⇑(1 : α →+* α) = id :=\n  rfl\n#align ring_hom.coe_one RingHom.coe_one\n\n/- warning: ring_hom.coe_mul -> RingHom.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [rα : NonAssocSemiring.{u1} α] (f : RingHom.{u1, u1} α α rα rα) (g : RingHom.{u1, u1} α α rα rα), Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (fun (_x : RingHom.{u1, u1} α α rα rα) => α -> α) (RingHom.hasCoeToFun.{u1, u1} α α rα rα) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (instHMul.{u1} (RingHom.{u1, u1} α α rα rα) (MulOneClass.toHasMul.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.monoid.{u1} α rα)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} α α α (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (fun (_x : RingHom.{u1, u1} α α rα rα) => α -> α) (RingHom.hasCoeToFun.{u1, u1} α α rα rα) f) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) (fun (_x : RingHom.{u1, u1} α α rα rα) => α -> α) (RingHom.hasCoeToFun.{u1, u1} α α rα rα) g))\nbut is expected to have type\n  forall {α : Type.{u1}} {rα : NonAssocSemiring.{u1} α} (f : RingHom.{u1, u1} α α rα rα) (g : RingHom.{u1, u1} α α rα rα), Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.instRingHomClassRingHom.{u1, u1} α α rα rα)))) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (RingHom.{u1, u1} α α rα rα) (instHMul.{u1} (RingHom.{u1, u1} α α rα rα) (MulOneClass.toMul.{u1} (RingHom.{u1, u1} α α rα rα) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} α α rα rα) (RingHom.instMonoidRingHom.{u1} α rα)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} α α α (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.instRingHomClassRingHom.{u1, u1} α α rα rα)))) f) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} α α rα rα) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} α α rα rα) α α rα rα (RingHom.instRingHomClassRingHom.{u1, u1} α α rα rα)))) g))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_mul RingHom.coe_mulₓ'. -/\n@[simp]\ntheorem coe_mul (f g : α →+* α) : ⇑(f * g) = f ∘ g :=\n  rfl\n#align ring_hom.coe_mul RingHom.coe_mul\n\ninclude rβ rγ\n\n/- warning: ring_hom.cancel_right -> RingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonAssocSemiring.{u1} α] [rβ : NonAssocSemiring.{u2} β] {rγ : NonAssocSemiring.{u3} γ} {g₁ : RingHom.{u2, u3} β γ rβ rγ} {g₂ : RingHom.{u2, u3} β γ rβ rγ} {f : RingHom.{u1, u2} α β rα rβ}, (Function.Surjective.{succ u1, succ u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) (fun (_x : RingHom.{u1, u2} α β rα rβ) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β rα rβ) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} α γ rα rγ) (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g₁ f) (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g₂ f)) (Eq.{max (succ u2) (succ u3)} (RingHom.{u2, u3} β γ rβ rγ) g₁ g₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u3} β} {rγ : NonAssocSemiring.{u2} γ} {g₁ : RingHom.{u3, u2} β γ rβ rγ} {g₂ : RingHom.{u3, u2} β γ rβ rγ} {f : RingHom.{u1, u3} α β rα rβ}, (Function.Surjective.{succ u1, succ u3} α β (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} α β rα rβ) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα)) (NonUnitalNonAssocSemiring.toMul.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α rα) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} α β rα rβ) α β rα rβ (RingHom.instRingHomClassRingHom.{u1, u3} α β rα rβ)))) f)) -> (Iff (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α γ rα rγ) (RingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g₁ f) (RingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g₂ f)) (Eq.{max (succ u3) (succ u2)} (RingHom.{u3, u2} β γ rβ rγ) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align ring_hom.cancel_right RingHom.cancel_rightₓ'. -/\ntheorem cancel_right {g₁ g₂ : β →+* γ} {f : α →+* β} (hf : Surjective f) :\n    g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => RingHom.ext <| hf.forall.2 (ext_iff.1 h), fun h => h ▸ rfl⟩\n#align ring_hom.cancel_right RingHom.cancel_right\n\n/- warning: ring_hom.cancel_left -> RingHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [rα : NonAssocSemiring.{u1} α] [rβ : NonAssocSemiring.{u2} β] {rγ : NonAssocSemiring.{u3} γ} {g : RingHom.{u2, u3} β γ rβ rγ} {f₁ : RingHom.{u1, u2} α β rα rβ} {f₂ : RingHom.{u1, u2} α β rα rβ}, (Function.Injective.{succ u2, succ u3} β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} β γ rβ rγ) (fun (_x : RingHom.{u2, u3} β γ rβ rγ) => β -> γ) (RingHom.hasCoeToFun.{u2, u3} β γ rβ rγ) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} α γ rα rγ) (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f₁) (RingHom.comp.{u1, u2, u3} α β γ rα rβ rγ g f₂)) (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β rα rβ) f₁ f₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} {rα : NonAssocSemiring.{u1} α} {rβ : NonAssocSemiring.{u3} β} {rγ : NonAssocSemiring.{u2} γ} {g : RingHom.{u3, u2} β γ rβ rγ} {f₁ : RingHom.{u1, u3} α β rα rβ} {f₂ : RingHom.{u1, u3} α β rα rβ}, (Function.Injective.{succ u3, succ u2} β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} β γ rβ rγ) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => γ) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ (NonUnitalNonAssocSemiring.toMul.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ)) (NonUnitalNonAssocSemiring.toMul.{u2} γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β rβ) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} γ rγ) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} β γ rβ rγ) β γ rβ rγ (RingHom.instRingHomClassRingHom.{u3, u2} β γ rβ rγ)))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α γ rα rγ) (RingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f₁) (RingHom.comp.{u1, u3, u2} α β γ rα rβ rγ g f₂)) (Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} α β rα rβ) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align ring_hom.cancel_left RingHom.cancel_leftₓ'. -/\ntheorem cancel_left {g : β →+* γ} {f₁ f₂ : α →+* β} (hg : Injective g) :\n    g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => RingHom.ext fun x => hg <| by rw [← comp_apply, h, comp_apply], fun h => h ▸ rfl⟩\n#align ring_hom.cancel_left RingHom.cancel_left\n\nend RingHom\n\n/- warning: function.injective.is_domain -> Function.Injective.isDomain is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Ring.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α _inst_1)] [_inst_3 : Ring.{u2} β] (f : RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))), (Function.Injective.{succ u2, succ u1} β α (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) (fun (_x : RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) => β -> α) (RingHom.hasCoeToFun.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α _inst_1))) f)) -> (IsDomain.{u2} β (Ring.toSemiring.{u2} β _inst_3))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Ring.{u2} α] [_inst_2 : IsDomain.{u2} α (Ring.toSemiring.{u2} α _inst_1)] [_inst_3 : Ring.{u1} β] (f : RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1))), (Function.Injective.{succ u1, succ u2} β α (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => α) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1))) β α (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)))) (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1))) β α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1))) β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α _inst_1)))))) f)) -> (IsDomain.{u1} β (Ring.toSemiring.{u1} β _inst_3))\nCase conversion may be inaccurate. Consider using '#align function.injective.is_domain Function.Injective.isDomainₓ'. -/\n/-- Pullback `is_domain` instance along an injective function. -/\nprotected theorem Function.Injective.isDomain [Ring α] [IsDomain α] [Ring β] (f : β →+* α)\n    (hf : Injective f) : IsDomain β :=\n  by\n  haveI := pullback_nonzero f f.map_zero f.map_one\n  haveI := IsRightCancelMulZero.to_noZeroDivisors α\n  haveI := hf.no_zero_divisors f f.map_zero f.map_mul\n  exact NoZeroDivisors.to_isDomain β\n#align function.injective.is_domain Function.Injective.isDomain\n\nnamespace AddMonoidHom\n\nvariable [CommRing α] [IsDomain α] [CommRing β] (f : β →+ α)\n\n/- warning: add_monoid_hom.mk_ring_hom_of_mul_self_of_two_ne_zero -> AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : CommRing.{u2} β] (f : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))), (forall (x : β), Eq.{succ u1} α (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (Ring.toDistrib.{u2} β (CommRing.toRing.{u2} β _inst_3)))) x x)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f x) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f x))) -> (Ne.{succ u1} α (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (CommRing.toRing.{u1} α _inst_1))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))))) -> (Eq.{succ u1} α (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))))) -> (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : CommRing.{u2} β] (f : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))), (forall (x : β), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (NonUnitalNonAssocRing.toMul.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))))) x x)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))) f (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (NonUnitalNonAssocRing.toMul.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))))) x x)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (NonUnitalNonAssocRing.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (NonAssocRing.toNonUnitalNonAssocRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (Ring.toNonAssocRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (CommRing.toRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) _inst_1))))) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))) f x) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))) f x))) -> (Ne.{succ u1} α (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommSemiring.toCommMonoidWithZero.{u1} α (CommRing.toCommSemiring.{u1} α _inst_1)))))) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocRing.toOne.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (Ring.toAddGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (Ring.toAddGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))) f (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocRing.toOne.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocRing.toOne.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocRing.toOne.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (NonAssocRing.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocRing.toOne.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (Ring.toNonAssocRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocRing.toOne.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (CommRing.toRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u2} β 1 (One.toOfNat1.{u2} β (NonAssocRing.toOne.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) _inst_1)))))) -> (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1))))\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.mk_ring_hom_of_mul_self_of_two_ne_zero AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZeroₓ'. -/\n/-- Make a ring homomorphism from an additive group homomorphism from a commutative ring to an\nintegral domain that commutes with self multiplication, assumes that two is nonzero and `1` is sent\nto `1`. -/\ndef mkRingHomOfMulSelfOfTwoNeZero (h : ∀ x, f (x * x) = f x * f x) (h_two : (2 : α) ≠ 0)\n    (h_one : f 1 = 1) : β →+* α :=\n  { f with\n    map_one' := h_one\n    map_mul' := fun x y => by\n      have hxy := h (x + y)\n      rw [mul_add, add_mul, add_mul, f.map_add, f.map_add, f.map_add, f.map_add, h x, h y, add_mul,\n        mul_add, mul_add, ← sub_eq_zero, add_comm, ← sub_sub, ← sub_sub, ← sub_sub, mul_comm y x,\n        mul_comm (f y) (f x)] at hxy\n      simp only [add_assoc, add_sub_assoc, add_sub_cancel'_right] at hxy\n      rw [sub_sub, ← two_mul, ← add_sub_assoc, ← two_mul, ← mul_sub, mul_eq_zero, sub_eq_zero,\n        or_iff_not_imp_left] at hxy\n      exact hxy h_two }\n#align add_monoid_hom.mk_ring_hom_of_mul_self_of_two_ne_zero AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero\n\n/- warning: add_monoid_hom.coe_fn_mk_ring_hom_of_mul_self_of_two_ne_zero -> AddMonoidHom.coe_fn_mkRingHomOfMulSelfOfTwoNeZero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : CommRing.{u2} β] (f : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (h : forall (x : β), Eq.{succ u1} α (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (Ring.toDistrib.{u2} β (CommRing.toRing.{u2} β _inst_3)))) x x)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f x) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f x))) (h_two : Ne.{succ u1} α (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (CommRing.toRing.{u1} α _inst_1))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))))) (h_one : Eq.{succ u1} α (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))))), Eq.{max (succ u2) (succ u1)} ((fun (_x : RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) => β -> α) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u1, u2} α β _inst_1 _inst_2 _inst_3 f h h_two h_one)) (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (fun (_x : RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) => β -> α) (RingHom.hasCoeToFun.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u1, u2} α β _inst_1 _inst_2 _inst_3 f h h_two h_one)) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CommRing.{u2} α] [_inst_2 : IsDomain.{u2} α (Ring.toSemiring.{u2} α (CommRing.toRing.{u2} α _inst_1))] [_inst_3 : CommRing.{u1} β] (f : AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (h : forall (x : β), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (NonUnitalNonAssocRing.toMul.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))))) x x)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (NonUnitalNonAssocRing.toMul.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))))) x x)) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (NonUnitalNonAssocRing.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (NonAssocRing.toNonUnitalNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f x))) (h_two : Ne.{succ u2} α (OfNat.ofNat.{u2} α 2 (instOfNat.{u2} α 2 (NonAssocRing.toNatCast.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (CommMonoidWithZero.toZero.{u2} α (CommSemiring.toCommMonoidWithZero.{u2} α (CommRing.toCommSemiring.{u2} α _inst_1)))))) (h_one : Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (NonAssocRing.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) _inst_1)))))), Eq.{max (succ u2) (succ u1)} (forall (a : β), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => α) a) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1)))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : β) => α) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1)))) β α (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1)))) β α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1)))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1)))) β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1))))))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u2, u1} α β _inst_1 _inst_2 _inst_3 f h h_two h_one)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f)\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.coe_fn_mk_ring_hom_of_mul_self_of_two_ne_zero AddMonoidHom.coe_fn_mkRingHomOfMulSelfOfTwoNeZeroₓ'. -/\n@[simp]\ntheorem coe_fn_mkRingHomOfMulSelfOfTwoNeZero (h h_two h_one) :\n    (f.mkRingHomOfMulSelfOfTwoNeZero h h_two h_one : β → α) = f :=\n  rfl\n#align add_monoid_hom.coe_fn_mk_ring_hom_of_mul_self_of_two_ne_zero AddMonoidHom.coe_fn_mkRingHomOfMulSelfOfTwoNeZero\n\n/- warning: add_monoid_hom.coe_add_monoid_hom_mk_ring_hom_of_mul_self_of_two_ne_zero -> AddMonoidHom.coe_addMonoidHom_mkRingHomOfMulSelfOfTwoNeZero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CommRing.{u1} α] [_inst_2 : IsDomain.{u1} α (Ring.toSemiring.{u1} α (CommRing.toRing.{u1} α _inst_1))] [_inst_3 : CommRing.{u2} β] (f : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (h : forall (x : β), Eq.{succ u1} α (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (Ring.toDistrib.{u2} β (CommRing.toRing.{u2} β _inst_3)))) x x)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f x) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f x))) (h_two : Ne.{succ u1} α (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (CommRing.toRing.{u1} α _inst_1))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))))) (h_one : Eq.{succ u1} α (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) => β -> α) (AddMonoidHom.hasCoeToFun.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) f (OfNat.ofNat.{u2} β 1 (OfNat.mk.{u2} β 1 (One.one.{u2} β (AddMonoidWithOne.toOne.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))))), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) ((fun (a : Sort.{max (succ u2) (succ u1)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u1), max (succ u1) (succ u2)} a b] => self.0) (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (HasLiftT.mk.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (CoeTCₓ.coe.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (AddMonoidHom.{u2, u1} β α (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1))))))) (AddMonoidHom.hasCoeT.{u2, u1, max u2 u1} β α (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddGroupWithOne.toAddMonoidWithOne.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β (CommRing.toRing.{u2} β _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (CommRing.toRing.{u1} α _inst_1)))))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))) β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1))) (RingHom.ringHomClass.{u2, u1} β α (NonAssocRing.toNonAssocSemiring.{u2} β (Ring.toNonAssocRing.{u2} β (CommRing.toRing.{u2} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} α (Ring.toNonAssocRing.{u1} α (CommRing.toRing.{u1} α _inst_1)))))))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u1, u2} α β _inst_1 _inst_2 _inst_3 f h h_two h_one)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CommRing.{u2} α] [_inst_2 : IsDomain.{u2} α (Ring.toSemiring.{u2} α (CommRing.toRing.{u2} α _inst_1))] [_inst_3 : CommRing.{u1} β] (f : AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (h : forall (x : β), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (NonUnitalNonAssocRing.toMul.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))))) x x)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (NonUnitalNonAssocRing.toMul.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))))) x x)) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (NonUnitalNonAssocRing.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (NonAssocRing.toNonUnitalNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) x) _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f x))) (h_two : Ne.{succ u2} α (OfNat.ofNat.{u2} α 2 (instOfNat.{u2} α 2 (NonAssocRing.toNatCast.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (CommMonoidWithZero.toZero.{u2} α (CommSemiring.toCommMonoidWithZero.{u2} α (CommRing.toCommSemiring.{u2} α _inst_1)))))) (h_one : Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β (fun (_x : β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddZeroClass.toAdd.{u1} β (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))))) f (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (NonAssocRing.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : β) => α) (OfNat.ofNat.{u1} β 1 (One.toOfNat1.{u1} β (NonAssocRing.toOne.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3)))))) _inst_1)))))), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} β α (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1)))))) (AddMonoidHomClass.toAddMonoidHom.{u1, u2, max u2 u1} β α (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddGroupWithOne.toAddMonoidWithOne.{u1} β (Ring.toAddGroupWithOne.{u1} β (CommRing.toRing.{u1} β _inst_3))))) (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddGroupWithOne.toAddMonoidWithOne.{u2} α (Ring.toAddGroupWithOne.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1)))) β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u2} β α (NonAssocRing.toNonAssocSemiring.{u1} β (Ring.toNonAssocRing.{u1} β (CommRing.toRing.{u1} β _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} α (Ring.toNonAssocRing.{u2} α (CommRing.toRing.{u2} α _inst_1))))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u2, u1} α β _inst_1 _inst_2 _inst_3 f h h_two h_one)) f\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.coe_add_monoid_hom_mk_ring_hom_of_mul_self_of_two_ne_zero AddMonoidHom.coe_addMonoidHom_mkRingHomOfMulSelfOfTwoNeZeroₓ'. -/\n@[simp]\ntheorem coe_addMonoidHom_mkRingHomOfMulSelfOfTwoNeZero (h h_two h_one) :\n    (f.mkRingHomOfMulSelfOfTwoNeZero h h_two h_one : β →+ α) = f :=\n  by\n  ext\n  rfl\n#align add_monoid_hom.coe_add_monoid_hom_mk_ring_hom_of_mul_self_of_two_ne_zero AddMonoidHom.coe_addMonoidHom_mkRingHomOfMulSelfOfTwoNeZero\n\nend AddMonoidHom\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Hom/Ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.48190010145274187}}
{"text": "import data.multiset data.equiv.basic data.nat.basic group_theory.perm\n\nopen equiv.perm equiv list\n\nvariables {α : Type*} {β : Type*} [decidable_eq α]\n\ndef thing : list α → list (perm α)\n| []       := [1]\n| (a :: l) := thing l ++ l.bind (λ b, (thing l).map (λ f, swap a b * f))\n\n@[simp] lemma thing_nil : thing ([] : list α) = [1] := rfl\n\nlemma length_thing : ∀ l : list α, length (thing l) = l.length.fact\n| []       := rfl\n| (a :: l) := by rw [length_cons, nat.fact_succ];\n  simp [thing, length_bind, length_thing, function.comp, nat.succ_mul]\n\nlemma mem_thing : ∀ (l : list α) (f : perm α) (hl : l.nodup) (h : ∀ x, f x ≠ x → x ∈ l), f ∈ thing l\n| []     f hl h := list.mem_singleton.2 $ equiv.ext _ _$ λ x, by simp [imp_false, *] at *\n| (a::l) f hl h :=\nif hfa : f a = a\nthen\n  mem_append_left _ $ mem_thing _ _ (list.nodup_of_nodup_cons hl)\n    (λ x hx, mem_of_ne_of_mem (λ h, by rw h at hx; exact hx hfa) (h x hx))\nelse\nhave hfa' : f (f a) ≠ f a, from mt (λ h, f.bijective.1 h) hfa,\nhave ∀ (x : α), (swap a (f a) * f) x ≠ x → x ∈ l,\n  from λ x hx, have hxa : x ≠ a, from λ h, by simpa [h, mul_apply] using hx,\n    have hfxa : f x ≠ f a, from mt (λ h, f.bijective.1 h) hxa,\n    list.mem_of_ne_of_mem hxa\n      (h x (λ h, by simp [h, mul_apply, swap_apply_def] at hx; split_ifs at hx; cc)),\nsuffices f ∈ thing l ∨ ∃ (b : α), b ∈ l ∧ ∃ g : perm α, g ∈ thing l ∧ swap a b * g = f,\n  by simpa [thing],\n(@or_iff_not_imp_left _ _ (classical.prop_decidable _)).2\n  (λ hfl, ⟨f a,\n    if hffa : f (f a) = a then mem_of_ne_of_mem hfa (h _ (mt (λ h, f.bijective.1 h) hfa))\n      else this _ $ by simp [mul_apply, swap_apply_def]; split_ifs; cc,\n    ⟨swap a (f a) * f, mem_thing _ _ (list.nodup_of_nodup_cons hl) this,\n      by rw [← mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, ← one_def, one_mul]⟩⟩)\n\nlemma mem_thing' : ∀ (l : list α) (f : perm α), f ∈ thing l → ∀ x, f x ≠ x → x ∈ l\n| []     f h := have f = 1 := by simpa [thing] using h, by rw this; simp\n| (a::l) f h :=\n(mem_append.1 h).elim\n  (λ h x hx, mem_cons_of_mem _ (mem_thing' l f h x hx))\n  (λ h x hx,\n    let ⟨y, hy, hy'⟩ := mem_bind.1 h in\n    let ⟨g, hg₁, hg₂⟩ := mem_map.1 hy' in\n    if hxa : x = a then by simp [hxa]\n    else if hxy : x = y then mem_cons_of_mem _ $ by rwa hxy\n    else mem_cons_of_mem _ $\n    mem_thing' l g hg₁ _ $\n      by rw [eq_inv_mul_iff_mul_eq.2 hg₂, mul_apply, swap_inv, swap_apply_def];\n        split_ifs; cc)\n\nlemma nodup_thing : ∀ (l : list α) (hl : l.nodup), (thing l).nodup\n| []     hl := by simp [thing]\n| (a::l) hl :=\nhave hl' : l.nodup, from nodup_of_nodup_cons hl,\nhave hln' : (thing l).nodup, from nodup_thing _ hl',\nhave hmeml : ∀ {f : perm α}, f ∈ thing l → f a = a,\n  from λ f hf, not_not.1 (mt (mem_thing' l f hf a) (nodup_cons.1 hl).1),\nby rw [thing, list.nodup_append, list.nodup_bind, pairwise_iff_nth_le]; exact\n⟨hln', ⟨λ _ _, nodup_map (λ _ _, (mul_left_inj _).1) hln',\n  λ i j hj hij x hx₁ hx₂,\n    let ⟨f, hf⟩ := mem_map.1 hx₁ in\n    let ⟨g, hg⟩ := mem_map.1 hx₂ in\n    have hix : x a = nth_le l i (lt_trans hij hj),\n      by rw [← hf.2, mul_apply, hmeml hf.1, swap_apply_left],\n    have hiy : x a = nth_le l j hj,\n      by rw [← hg.2, mul_apply, hmeml hg.1, swap_apply_left],\n    absurd (hf.2.trans (hg.2.symm)) $\n      λ h, ne_of_lt hij $ nodup_iff_nth_le_inj.1 hl' i j (lt_trans hij hj) hj $\n        by rw [← hix, hiy]⟩,\n  λ f hf₁ hf₂,\n    let ⟨x, hx, hx'⟩ := mem_bind.1 hf₂ in\n    let ⟨g, hg⟩ := mem_map.1 hx' in\n    have hgxa : g⁻¹ x = a, from f.bijective.1 $\n      by rw [hmeml hf₁, ← hg.2]; simp,\n    have hxa : x ≠ a, from λ h, (list.nodup_cons.1 hl).1 (h ▸ hx),\n    (list.nodup_cons.1 hl).1 $\n      hgxa ▸ mem_thing' _ _ hg.1 _ (by rwa [apply_inv_self, hgxa])⟩\n\ndef perm_fintype_aux [decidable_eq (perm α)] {s : multiset α} :\n  (∀ x, x ∈ s) → s.nodup → fintype (perm α) :=\nquotient.rec_on_subsingleton s (λ l hl hln, ⟨⟨thing l, nodup_thing _ hln⟩,\n  (λ x, mem_thing _ _ hln (λ _ _, (hl _)))⟩)\n\ninstance perm.fintype [fintype α] : fintype (perm α) := perm_fintype_aux finset.mem_univ finset.univ.2\n\nlemma card_perm [fintype α] : fintype.card (perm α) = (fintype.card α).fact :=\nquotient.induction_on (@finset.univ α _).1 begin end\n\n#exit\n\nlemma thing_cons (m : multiset α) (a : α) :\n  thing (a :: m) = thing m + m.bind (λ b, (thing m).map (λ f, swap a b * f)) :=\nby simp [thing]\n\nlemma mem_perm (m : multiset α) (f : perm α) : (∀ x, f x ≠ x → x ∈ m) → f ∈ thing m :=\nmultiset.induction_on m\n  (λ h, mem_singleton.2 $ equiv.ext _ _ $ λ x, not_not.1 $ by simpa [-not_not, not_mem_zero] using h x)\n  $ λ a s ih h, begin\n    simp [thing_cons],\n\n  end\n\nlemma card_perm (m : multiset α) : (thing m).card = nat.fact m.card :=\nmultiset.induction_on m rfl (λ a s ih, by rw [card_cons, nat.fact_succ];\n  simp [thing_cons, card_add, ih, card_bind, mul_comm, nat.mul_succ])\n\ndef perm.cons (e : α ≃ β) (m : multiset α) (a : α) (b : β) (f : α ≃ β) : α ≃ β :=\n(swap a (e.symm b)).trans f\n\ndef list_to_function : Π (l₁ : list α) (l₂ : list β), l₁.length = l₂.length → Π a ∈ l₁, β\n| []      l₂      h₁ a h₂ := absurd h₂ (list.not_mem_nil _)\n| (b::l₁) []      h₁ a h₂ := absurd h₁ (nat.succ_ne_zero _)\n| (b::l₁) (c::l₂) h₁ a h₂ := if h : a = b then c\n  else list_to_function l₁ l₂ (nat.succ_inj h₁) a (list.mem_of_ne_of_mem h h₂)\n\nopen list nat\n\ndef list_to_perm : Π (l₁ : list α) (l₂ : list β), l₁.length = l₂.length →\n  {a // a ∈ l₁} ≃ {b // b ∈ l₂}\n| []      []      h := ⟨λ a, (not_mem_nil _ a.2).elim, λ b, (not_mem_nil _ b.2).elim,\n  λ a, (not_mem_nil _ a.2).elim, λ b, (not_mem_nil _ b.2).elim⟩\n| []      (b::l₂) h := (succ_ne_zero _ h.symm).elim\n| (a::l₁) []      h := (succ_ne_zero _ h).elim\n| (a::l₁) (b::l₂) h :=\nlet f := list_to_perm l₁ l₂ (succ_inj h) in\n{ to_fun := λ x, if h : x.1 = a then ⟨b, list.mem_cons_self _ _⟩\n            else ⟨(f ⟨x, mem_of_ne_of_mem h x.2⟩).1, mem_cons_of_mem _ begin end⟩  }\n\ndef multiset.perm (m : multiset α) (t : multiset β) : multiset (α ≃ β) :=\nmultiset.rec_on m (e :: 0)\n  (λ a m ih, m.bind (λ b, ih.map (λ f, begin end)))\n  (λ x y s t, heq_of_eq begin\n    simp [multiset.map_bind, bind_bind, swap_comm],\n    rw [bind_map_comm],\n\n  end)", "meta": {"author": "ChrisHughes24", "repo": "leanstuff", "sha": "9efa85f72efaccd1d540385952a6acc18fce8687", "save_path": "github-repos/lean/ChrisHughes24-leanstuff", "path": "github-repos/lean/ChrisHughes24-leanstuff/leanstuff-9efa85f72efaccd1d540385952a6acc18fce8687/fintype_perm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.4818635929780176}}
{"text": "import deduction.deduction_monadic data.set.basic\nopen deduction_basic\n\n\n\nnamespace MPPC_defn\n\n    inductive MPPC_Form : Type\n    | top : MPPC_Form\n    | var : ℕ → MPPC_Form\n    | and : MPPC_Form → MPPC_Form → MPPC_Form\n    | impl : MPPC_Form → MPPC_Form → MPPC_Form\n    | diamond : MPPC_Form → MPPC_Form\n\n\n    @[reducible] def MPPC_Hyp : Type := set (MPPC_Form)\n\n    instance : has_union MPPC_Hyp := infer_instance\n    instance : has_mem MPPC_Form MPPC_Hyp := infer_instance\n    instance : has_insert MPPC_Form MPPC_Hyp := infer_instance\n    instance : has_emptyc MPPC_Hyp := infer_instance\n\n    inductive isModal : MPPC_Hyp → Prop\n    | ModalEmpty : isModal ∅\n    | ModalInsert : ∀ (Φ : MPPC_Hyp) (φ : MPPC_Form), \n        isModal Φ → isModal (insert (MPPC_Form.diamond φ) Φ)\n\n    inductive MPPC_derives : MPPC_Hyp → MPPC_Form → Prop \n    | hyp {Φ : MPPC_Hyp} {φ : MPPC_Form}  \n        : (φ ∈ Φ) →  MPPC_derives Φ φ\n    | truth {Φ}                               \n        : MPPC_derives Φ MPPC_Form.top \n    | and_intro {Φ} {φ ψ : MPPC_Form}    \n        : MPPC_derives Φ φ → MPPC_derives Φ ψ → MPPC_derives Φ (MPPC_Form.and φ ψ)\n    | and_eliml {Φ} {φ ψ : MPPC_Form}    \n        : MPPC_derives Φ (MPPC_Form.and φ ψ) → MPPC_derives Φ φ\n    | and_elimr {Φ} {φ ψ : MPPC_Form}    \n        : MPPC_derives Φ (MPPC_Form.and φ ψ) → MPPC_derives Φ ψ\n    | impl_intro {Φ : MPPC_Hyp} (φ : MPPC_Form) {ψ : MPPC_Form}   \n        : MPPC_derives (insert φ Φ) ψ → MPPC_derives Φ (MPPC_Form.impl φ ψ)\n    | impl_elim {Φ : MPPC_Hyp} (φ : MPPC_Form) {ψ : MPPC_Form} \n        : MPPC_derives Φ (MPPC_Form.impl φ ψ) → MPPC_derives Φ φ → MPPC_derives Φ ψ\n    | weak {Φ Ψ : MPPC_Hyp} {φ : MPPC_Form}\n        : MPPC_derives Φ φ → MPPC_derives (Φ ∪ Ψ) φ\n    | dmap {Φ : MPPC_Hyp}{φ ψ : MPPC_Form} \n        : MPPC_derives (insert φ Φ) ψ → MPPC_derives (insert (MPPC_Form.diamond φ) Φ) (MPPC_Form.diamond ψ)\n    | dpure {Φ : MPPC_Hyp} {φ : MPPC_Form}\n        : MPPC_derives Φ φ → MPPC_derives Φ (MPPC_Form.diamond φ)\n    | djoin {Φ : MPPC_Hyp} {φ : MPPC_Form}\n        : MPPC_derives Φ (MPPC_Form.diamond(MPPC_Form.diamond φ)) → MPPC_derives Φ (MPPC_Form.diamond φ)\n    open MPPC_derives\n\nnotation (name:= MPPC.diamond) `◇`:81 φ := MPPC_Form.diamond φ \n\nend MPPC_defn\n\n\nnamespace MPPC_has_derives\n\n    open MPPC_defn\n    open MPPC_defn.MPPC_derives\n    open deduction_basic\n    open deduction_cart\n    open deduction_monadic\n    open MPPC_defn.MPPC_Form\n\n    instance MPPC_hasHyp : has_Hyp MPPC_Form :=\n      { Hyp := MPPC_Hyp }\n\n    instance MPPC_singleton : has_singleton MPPC_Form MPPC_Hyp :=\n      deduction_basic.singleHyp\n    @[simp] \n    lemma same_singles : ∀ φ : MPPC_Form, \n        MPPC_has_derives.MPPC_singleton.singleton φ = set.has_singleton.singleton φ :=\n    begin \n      assume φ,\n      dsimp[MPPC_has_derives.MPPC_singleton,deduction_basic.singleHyp],\n      rw set.is_lawful_singleton.insert_emptyc_eq,\n    end\n\n    lemma single_union {Φ : MPPC_Hyp} {φ : MPPC_Form}\n        : insert φ Φ = {φ} ∪ Φ := by simp\n\n\n    instance MPPC_Der : has_struct_derives MPPC_Form :=\n    {\n      derives := MPPC_derives,\n      derive_Trans := \n        begin\n          assume Φ ψ θ hφψ hψθ,\n          have helper : MPPC_derives Φ (MPPC_Form.impl ψ θ),\n            apply impl_intro,\n            rw single_union,\n            apply weak,\n            exact hψθ,\n          apply impl_elim ψ,\n          exact helper,\n          exact hφψ,\n        end,\n      inInsert := set.mem_insert,\n      hyp := @hyp,\n      weak1 := \n        begin\n          assume Φ φ ψ h,\n          rw single_union,\n          rw set.union_comm,\n          apply weak,\n          exact h,\n        end,\n    }\n\n    instance MPPC_top : deduction_cart.has_ltop MPPC_Form :=\n    {\n      top := MPPC_Form.top,\n      truth := @truth,\n    }\n    instance MPPC_and : deduction_cart.has_and MPPC_Form :=\n    {\n      and := MPPC_Form.and,\n      and_intro := @and_intro,\n      and_eliml := @and_eliml,\n      and_elimr := @and_elimr,\n    }\n    instance MPPC_impl : deduction_cart.has_impl MPPC_Form :=\n    {\n      impl := MPPC_Form.impl,\n      impl_intro := @impl_intro,\n      impl_elim := @impl_elim,\n    }\n    instance MPPC_diamond : deduction_monadic.has_diamond MPPC_Form :=\n    {\n      diamond := MPPC_Form.diamond,\n      dmap := @dmap,\n      dpure := @dpure,\n      djoin := @djoin,\n    }\n\nend MPPC_has_derives\n", "meta": {"author": "lean-catLogic", "repo": "formalization", "sha": "bf4eda918a90ed04b8867bfcc587cc0dda1c4347", "save_path": "github-repos/lean/lean-catLogic-formalization", "path": "github-repos/lean/lean-catLogic-formalization/formalization-bf4eda918a90ed04b8867bfcc587cc0dda1c4347/src/deduction/MPPC_natDeduct.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.661922862511608, "lm_q1q2_score": 0.48186359297801745}}
{"text": "/-\nCopyright (c) 2018 Sean Leather. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sean Leather, Mario Carneiro\n-/\nimport data.list.alist\nimport data.finset.basic\nimport data.part\n/-!\n# Finite maps over `multiset`\n-/\n\nuniverses u v w\nopen list\nvariables {α : Type u} {β : α → Type v}\n\n/-! ### multisets of sigma types-/\n\nnamespace multiset\n\n/-- Multiset of keys of an association multiset. -/\ndef keys (s : multiset (sigma β)) : multiset α :=\ns.map sigma.fst\n\n@[simp] theorem coe_keys {l : list (sigma β)} :\n  keys (l : multiset (sigma β)) = (l.keys : multiset α) :=\nrfl\n\n/-- `nodupkeys s` means that `s` has no duplicate keys. -/\ndef nodupkeys (s : multiset (sigma β)) : Prop :=\nquot.lift_on s list.nodupkeys (λ s t p, propext $ perm_nodupkeys p)\n\n@[simp] theorem coe_nodupkeys {l : list (sigma β)} : @nodupkeys α β l ↔ l.nodupkeys := iff.rfl\n\nend multiset\n\n/-! ### finmap -/\n\n/-- `finmap β` is the type of finite maps over a multiset. It is effectively\n  a quotient of `alist β` by permutation of the underlying list. -/\nstructure finmap (β : α → Type v) : Type (max u v) :=\n(entries : multiset (sigma β))\n(nodupkeys : entries.nodupkeys)\n\n/-- The quotient map from `alist` to `finmap`. -/\ndef alist.to_finmap (s : alist β) : finmap β := ⟨s.entries, s.nodupkeys⟩\n\nlocal notation `⟦`:max a `⟧`:0 := alist.to_finmap a\n\ntheorem alist.to_finmap_eq {s₁ s₂ : alist β} :\n  ⟦s₁⟧ = ⟦s₂⟧ ↔ s₁.entries ~ s₂.entries :=\nby cases s₁; cases s₂; simp [alist.to_finmap]\n\n@[simp] theorem alist.to_finmap_entries (s : alist β) : ⟦s⟧.entries = s.entries := rfl\n\n/-- Given `l : list (sigma β)`, create a term of type `finmap β` by removing\nentries with duplicate keys. -/\ndef list.to_finmap [decidable_eq α] (s : list (sigma β)) : finmap β := s.to_alist.to_finmap\n\nnamespace finmap\nopen alist\n\n/-! ### lifting from alist -/\n\n/-- Lift a permutation-respecting function on `alist` to `finmap`. -/\n@[elab_as_eliminator] def lift_on\n  {γ} (s : finmap β) (f : alist β → γ)\n  (H : ∀ a b : alist β, a.entries ~ b.entries → f a = f b) : γ :=\nbegin\n  refine (quotient.lift_on s.1 (λ l, (⟨_, λ nd, f ⟨l, nd⟩⟩ : part γ))\n    (λ l₁ l₂ p, part.ext' (perm_nodupkeys p) _) : part γ).get _,\n  { exact λ h₁ h₂, H _ _ (by exact p) },\n  { have := s.nodupkeys, rcases s.entries with ⟨l⟩, exact id }\nend\n\n@[simp] theorem lift_on_to_finmap {γ} (s : alist β) (f : alist β → γ) (H) :\n  lift_on ⟦s⟧ f H = f s := by cases s; refl\n\n/-- Lift a permutation-respecting function on 2 `alist`s to 2 `finmap`s. -/\n@[elab_as_eliminator] def lift_on₂\n  {γ} (s₁ s₂ : finmap β) (f : alist β → alist β → γ)\n  (H : ∀ a₁ b₁ a₂ b₂ : alist β, a₁.entries ~ a₂.entries → b₁.entries ~ b₂.entries →\n    f a₁ b₁ = f a₂ b₂) : γ :=\nlift_on s₁\n  (λ l₁, lift_on s₂ (f l₁) (λ b₁ b₂ p, H _ _ _ _ (perm.refl _) p))\n  (λ a₁ a₂ p, have H' : f a₁ = f a₂ := funext (λ _, H _ _ _ _ p (perm.refl _)), by simp only [H'])\n\n@[simp] theorem lift_on₂_to_finmap {γ} (s₁ s₂ : alist β) (f : alist β → alist β → γ) (H) :\n  lift_on₂ ⟦s₁⟧ ⟦s₂⟧ f H = f s₁ s₂ :=\nby cases s₁; cases s₂; refl\n\n/-! ### induction -/\n\n@[elab_as_eliminator] theorem induction_on\n  {C : finmap β → Prop} (s : finmap β) (H : ∀ (a : alist β), C ⟦a⟧) : C s :=\nby rcases s with ⟨⟨a⟩, h⟩; exact H ⟨a, h⟩\n\n@[elab_as_eliminator] theorem induction_on₂ {C : finmap β → finmap β → Prop}\n  (s₁ s₂ : finmap β) (H : ∀ (a₁ a₂ : alist β), C ⟦a₁⟧ ⟦a₂⟧) : C s₁ s₂ :=\ninduction_on s₁ $ λ l₁, induction_on s₂ $ λ l₂, H l₁ l₂\n\n@[elab_as_eliminator] theorem induction_on₃ {C : finmap β →  finmap β → finmap β → Prop}\n  (s₁ s₂ s₃ : finmap β) (H : ∀ (a₁ a₂ a₃ : alist β), C ⟦a₁⟧ ⟦a₂⟧ ⟦a₃⟧) : C s₁ s₂ s₃ :=\ninduction_on₂ s₁ s₂ $ λ l₁ l₂, induction_on s₃ $ λ l₃, H l₁ l₂ l₃\n\n/-! ### extensionality -/\n\n@[ext] theorem ext : ∀ {s t : finmap β}, s.entries = t.entries → s = t\n| ⟨l₁, h₁⟩ ⟨l₂, h₂⟩ H := by congr'\n\n@[simp] theorem ext_iff {s t : finmap β} : s.entries = t.entries ↔ s = t :=\n⟨ext, congr_arg _⟩\n\n/-! ### mem -/\n\n/-- The predicate `a ∈ s` means that `s` has a value associated to the key `a`. -/\ninstance : has_mem α (finmap β) := ⟨λ a s, a ∈ s.entries.keys⟩\n\ntheorem mem_def {a : α} {s : finmap β} :\n  a ∈ s ↔ a ∈ s.entries.keys := iff.rfl\n\n@[simp] theorem mem_to_finmap {a : α} {s : alist β} :\n  a ∈ ⟦s⟧ ↔ a ∈ s := iff.rfl\n\n/-! ### keys -/\n\n/-- The set of keys of a finite map. -/\ndef keys (s : finmap β) : finset α :=\n⟨s.entries.keys, induction_on s keys_nodup⟩\n\n@[simp] theorem keys_val (s : alist β) : (keys ⟦s⟧).val = s.keys := rfl\n\n@[simp] theorem keys_ext {s₁ s₂ : alist β} :\n  keys ⟦s₁⟧ = keys ⟦s₂⟧ ↔ s₁.keys ~ s₂.keys :=\nby simp [keys, alist.keys]\n\ntheorem mem_keys {a : α} {s : finmap β} : a ∈ s.keys ↔ a ∈ s :=\ninduction_on s $ λ s, alist.mem_keys\n\n/-! ### empty -/\n\n/-- The empty map. -/\ninstance : has_emptyc (finmap β) := ⟨⟨0, nodupkeys_nil⟩⟩\n\ninstance : inhabited (finmap β) := ⟨∅⟩\n\n@[simp] theorem empty_to_finmap : (⟦∅⟧ : finmap β) = ∅ := rfl\n\n@[simp] theorem to_finmap_nil [decidable_eq α] : ([].to_finmap : finmap β) = ∅ := rfl\n\ntheorem not_mem_empty {a : α} : a ∉ (∅ : finmap β) :=\nmultiset.not_mem_zero a\n\n@[simp] theorem keys_empty : (∅ : finmap β).keys = ∅ := rfl\n\n/-! ### singleton -/\n\n/-- The singleton map. -/\ndef singleton (a : α) (b : β a) : finmap β := ⟦alist.singleton a b⟧\n\n@[simp] theorem keys_singleton (a : α) (b : β a) :\n  (singleton a b).keys = {a} := rfl\n\n@[simp] lemma mem_singleton (x y : α) (b : β y) : x ∈ singleton y b ↔ x = y :=\nby simp only [singleton]; erw [mem_cons_eq, mem_nil_iff, or_false]\n\nsection\n\nvariables [decidable_eq α]\n\ninstance has_decidable_eq [∀ a, decidable_eq (β a)] : decidable_eq (finmap β)\n| s₁ s₂ := decidable_of_iff _ ext_iff\n\n/-! ### lookup -/\n\n/-- Look up the value associated to a key in a map. -/\ndef lookup (a : α) (s : finmap β) : option (β a) :=\nlift_on s (lookup a) (λ s t, perm_lookup)\n\n@[simp] theorem lookup_to_finmap (a : α) (s : alist β) :\n  lookup a ⟦s⟧ = s.lookup a := rfl\n\n@[simp] theorem lookup_list_to_finmap (a : α) (s : list (sigma β)) :\n  lookup a s.to_finmap = s.lookup a :=\nby rw [list.to_finmap, lookup_to_finmap, lookup_to_alist]\n\n@[simp] theorem lookup_empty (a) : lookup a (∅ : finmap β) = none :=\nrfl\n\ntheorem lookup_is_some {a : α} {s : finmap β} :\n  (s.lookup a).is_some ↔ a ∈ s :=\ninduction_on s $ λ s, alist.lookup_is_some\n\ntheorem lookup_eq_none {a} {s : finmap β} : lookup a s = none ↔ a ∉ s :=\ninduction_on s $ λ s, alist.lookup_eq_none\n\n@[simp] lemma lookup_singleton_eq {a : α} {b : β a} : (singleton a b).lookup a = some b :=\nby rw [singleton, lookup_to_finmap, alist.singleton, alist.lookup, lookup_cons_eq]\n\ninstance (a : α) (s : finmap β) : decidable (a ∈ s) :=\ndecidable_of_iff _ lookup_is_some\n\nlemma mem_iff {a : α} {s : finmap β} : a ∈ s ↔ ∃ b, s.lookup a = some b :=\ninduction_on s $ λ s,\niff.trans list.mem_keys $ exists_congr $ λ b,\n(mem_lookup_iff s.nodupkeys).symm\n\nlemma mem_of_lookup_eq_some {a : α} {b : β a} {s : finmap β} (h : s.lookup a = some b) : a ∈ s :=\nmem_iff.mpr ⟨_, h⟩\n\ntheorem ext_lookup {s₁ s₂ : finmap β} : (∀ x, s₁.lookup x = s₂.lookup x) → s₁ = s₂ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂ h,\nbegin\n  simp only [alist.lookup, lookup_to_finmap] at h,\n  rw [alist.to_finmap_eq],\n  apply lookup_ext s₁.nodupkeys s₂.nodupkeys,\n  intros x y,\n  rw h,\nend\n\n/-! ### replace -/\n\n/-- Replace a key with a given value in a finite map.\n  If the key is not present it does nothing. -/\ndef replace (a : α) (b : β a) (s : finmap β) : finmap β :=\nlift_on s (λ t, ⟦replace a b t⟧) $\nλ s₁ s₂ p, to_finmap_eq.2 $ perm_replace p\n\n@[simp] theorem replace_to_finmap (a : α) (b : β a) (s : alist β) :\n  replace a b ⟦s⟧ = ⟦s.replace a b⟧ := by simp [replace]\n\n@[simp] theorem keys_replace (a : α) (b : β a) (s : finmap β) :\n  (replace a b s).keys = s.keys :=\ninduction_on s $ λ s, by simp\n\n@[simp] theorem mem_replace {a a' : α} {b : β a} {s : finmap β} :\n  a' ∈ replace a b s ↔ a' ∈ s :=\ninduction_on s $ λ s, by simp\n\nend\n\n/-! ### foldl -/\n\n/-- Fold a commutative function over the key-value pairs in the map -/\ndef foldl {δ : Type w} (f : δ → Π a, β a → δ)\n  (H : ∀ d a₁ b₁ a₂ b₂, f (f d a₁ b₁) a₂ b₂ = f (f d a₂ b₂) a₁ b₁)\n  (d : δ) (m : finmap β) : δ :=\nm.entries.foldl (λ d s, f d s.1 s.2) (λ d s t, H _ _ _ _ _) d\n\n/-- `any f s` returns `tt` iff there exists a value `v` in `s` such that `f v = tt`. -/\ndef any (f : Π x, β x → bool) (s : finmap β) : bool :=\ns.foldl (λ x y z, x ∨ f y z) (by { intros,  simp [or.right_comm] }) ff\n\n/-- `all f s` returns `tt` iff `f v = tt` for all values `v` in `s`. -/\ndef all (f : Π x, β x → bool) (s : finmap β) : bool :=\ns.foldl (λ x y z, x ∧ f y z) (by { intros, simp [and.right_comm] }) ff\n\n/-! ### erase -/\n\nsection\n\nvariables [decidable_eq α]\n\n/-- Erase a key from the map. If the key is not present it does nothing. -/\ndef erase (a : α) (s : finmap β) : finmap β :=\nlift_on s (λ t, ⟦erase a t⟧) $\nλ s₁ s₂ p, to_finmap_eq.2 $ perm_erase p\n\n@[simp] theorem erase_to_finmap (a : α) (s : alist β) :\n  erase a ⟦s⟧ = ⟦s.erase a⟧ := by simp [erase]\n\n@[simp] \n\n@[simp] theorem keys_erase (a : α) (s : finmap β) :\n  (erase a s).keys = s.keys.erase a :=\ninduction_on s $ λ s, by simp\n\n@[simp] theorem mem_erase {a a' : α} {s : finmap β} : a' ∈ erase a s ↔ a' ≠ a ∧ a' ∈ s :=\ninduction_on s $ λ s, by simp\n\ntheorem not_mem_erase_self {a : α} {s : finmap β} : ¬ a ∈ erase a s :=\nby rw [mem_erase, not_and_distrib, not_not]; left; refl\n\n@[simp] theorem lookup_erase (a) (s : finmap β) : lookup a (erase a s) = none :=\ninduction_on s $ lookup_erase a\n\n@[simp] theorem lookup_erase_ne {a a'} {s : finmap β} (h : a ≠ a') :\n  lookup a (erase a' s) = lookup a s :=\ninduction_on s $ λ s, lookup_erase_ne h\n\ntheorem erase_erase {a a' : α} {s : finmap β} : erase a (erase a' s) = erase a' (erase a s) :=\ninduction_on s $ λ s, ext (by simp only [erase_erase, erase_to_finmap])\n\n/-! ### sdiff -/\n\n/-- `sdiff s s'` consists of all key-value pairs from `s` and `s'` where the keys are in `s` or\n`s'` but not both. -/\ndef sdiff (s s' : finmap β) : finmap β :=\ns'.foldl (λ s x _, s.erase x) (λ a₀ a₁ _ a₂ _, erase_erase) s\n\ninstance : has_sdiff (finmap β) := ⟨sdiff⟩\n\n/-! ### insert -/\n\n/-- Insert a key-value pair into a finite map, replacing any existing pair with\n  the same key. -/\ndef insert (a : α) (b : β a) (s : finmap β) : finmap β :=\nlift_on s (λ t, ⟦insert a b t⟧) $\nλ s₁ s₂ p, to_finmap_eq.2 $ perm_insert p\n\n@[simp] theorem insert_to_finmap (a : α) (b : β a) (s : alist β) :\n  insert a b ⟦s⟧ = ⟦s.insert a b⟧ := by simp [insert]\n\ntheorem insert_entries_of_neg {a : α} {b : β a} {s : finmap β} : a ∉ s →\n  (insert a b s).entries = ⟨a, b⟩ ::ₘ s.entries :=\ninduction_on s $ λ s h,\nby simp [insert_entries_of_neg (mt mem_to_finmap.1 h)]\n\n@[simp] theorem mem_insert {a a' : α} {b' : β a'} {s : finmap β} :\n  a ∈ insert a' b' s ↔ a = a' ∨ a ∈ s :=\ninduction_on s mem_insert\n\n@[simp] theorem lookup_insert {a} {b : β a} (s : finmap β) :\n  lookup a (insert a b s) = some b :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert]\n\n@[simp] theorem lookup_insert_of_ne {a a'} {b : β a} (s : finmap β) (h : a' ≠ a) :\n  lookup a' (insert a b s) = lookup a' s :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert_ne h]\n\n@[simp] theorem insert_insert {a} {b b' : β a} (s : finmap β) :\n  (s.insert a b).insert a b' = s.insert a b' :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, insert_insert]\n\ntheorem insert_insert_of_ne {a a'} {b : β a} {b' : β a'} (s : finmap β) (h : a ≠ a') :\n  (s.insert a b).insert a' b' = (s.insert a' b').insert a b :=\ninduction_on s $ λ s,\nby simp only [insert_to_finmap, alist.to_finmap_eq, insert_insert_of_ne _ h]\n\ntheorem to_finmap_cons (a : α) (b : β a) (xs : list (sigma β)) :\n  list.to_finmap (⟨a,b⟩ :: xs) = insert a b xs.to_finmap := rfl\n\ntheorem mem_list_to_finmap (a : α) (xs : list (sigma β)) :\n  a ∈ xs.to_finmap ↔ (∃ b : β a, sigma.mk a b ∈ xs) :=\nby { induction xs with x xs; [skip, cases x];\n     simp only [to_finmap_cons, *, not_mem_empty, exists_or_distrib, not_mem_nil, to_finmap_nil,\n                exists_false, mem_cons_iff, mem_insert, exists_and_distrib_left];\n     apply or_congr _ iff.rfl,\n     conv { to_lhs, rw ← and_true (a = x_fst) },\n     apply and_congr_right, rintro ⟨⟩, simp only [exists_eq, iff_self, heq_iff_eq] }\n\n@[simp] theorem insert_singleton_eq {a : α} {b b' : β a} :\n  insert a b (singleton a b') = singleton a b :=\nby simp only [singleton, finmap.insert_to_finmap, alist.insert_singleton_eq]\n\n/-! ### extract -/\n\n/-- Erase a key from the map, and return the corresponding value, if found. -/\ndef extract (a : α) (s : finmap β) : option (β a) × finmap β :=\nlift_on s (λ t, prod.map id to_finmap (extract a t)) $\nλ s₁ s₂ p, by simp [perm_lookup p, to_finmap_eq, perm_erase p]\n\n@[simp] theorem extract_eq_lookup_erase (a : α) (s : finmap β) :\n  extract a s = (lookup a s, erase a s) :=\ninduction_on s $ λ s, by simp [extract]\n\n/-! ### union -/\n\n/-- `s₁ ∪ s₂` is the key-based union of two finite maps. It is left-biased: if\nthere exists an `a ∈ s₁`, `lookup a (s₁ ∪ s₂) = lookup a s₁`. -/\ndef union (s₁ s₂ : finmap β) : finmap β :=\nlift_on₂ s₁ s₂ (λ s₁ s₂, ⟦s₁ ∪ s₂⟧) $\nλ s₁ s₂ s₃ s₄ p₁₃ p₂₄, to_finmap_eq.mpr $ perm_union p₁₃ p₂₄\n\ninstance : has_union (finmap β) := ⟨union⟩\n\n@[simp] theorem mem_union {a} {s₁ s₂ : finmap β} :\n  a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂ :=\ninduction_on₂ s₁ s₂ $ λ _ _, mem_union\n\n@[simp] theorem union_to_finmap (s₁ s₂ : alist β) : ⟦s₁⟧ ∪ ⟦s₂⟧ = ⟦s₁ ∪ s₂⟧ :=\nby simp [(∪), union]\n\ntheorem keys_union {s₁ s₂ : finmap β} : (s₁ ∪ s₂).keys = s₁.keys ∪ s₂.keys :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, finset.ext $ by simp [keys]\n\n@[simp] theorem lookup_union_left {a} {s₁ s₂ : finmap β} :\n  a ∈ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₁ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, lookup_union_left\n\n@[simp] theorem lookup_union_right {a} {s₁ s₂ : finmap β} :\n  a ∉ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₂ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, lookup_union_right\n\ntheorem lookup_union_left_of_not_in {a} {s₁ s₂ : finmap β} (h : a ∉ s₂) :\n  lookup a (s₁ ∪ s₂) = lookup a s₁ :=\nbegin\n  by_cases h' : a ∈ s₁,\n  { rw lookup_union_left h' },\n  { rw [lookup_union_right h', lookup_eq_none.mpr h, lookup_eq_none.mpr h'] }\nend\n\n@[simp] theorem mem_lookup_union {a} {b : β a} {s₁ s₂ : finmap β} :\n  b ∈ lookup a (s₁ ∪ s₂) ↔ b ∈ lookup a s₁ ∨ a ∉ s₁ ∧ b ∈ lookup a s₂ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂, mem_lookup_union\n\ntheorem mem_lookup_union_middle {a} {b : β a} {s₁ s₂ s₃ : finmap β} :\n  b ∈ lookup a (s₁ ∪ s₃) → a ∉ s₂ → b ∈ lookup a (s₁ ∪ s₂ ∪ s₃) :=\ninduction_on₃ s₁ s₂ s₃ $ λ s₁ s₂ s₃, mem_lookup_union_middle\n\ntheorem insert_union {a} {b : β a} {s₁ s₂ : finmap β} :\n  insert a b (s₁ ∪ s₂) = insert a b s₁ ∪ s₂ :=\ninduction_on₂ s₁ s₂ $ λ a₁ a₂, by simp [insert_union]\n\ntheorem union_assoc {s₁ s₂ s₃ : finmap β} : (s₁ ∪ s₂) ∪ s₃ = s₁ ∪ (s₂ ∪ s₃) :=\ninduction_on₃ s₁ s₂ s₃ $ λ s₁ s₂ s₃,\nby simp only [alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\n@[simp] theorem empty_union {s₁ : finmap β} : ∅ ∪ s₁ = s₁ :=\ninduction_on s₁ $ λ s₁, by rw ← empty_to_finmap;\n  simp [- empty_to_finmap, alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\n@[simp] theorem union_empty {s₁ : finmap β} : s₁ ∪ ∅ = s₁ :=\ninduction_on s₁ $ λ s₁, by rw ← empty_to_finmap;\n  simp [- empty_to_finmap, alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\ntheorem erase_union_singleton (a : α) (b : β a) (s : finmap β) (h : s.lookup a = some b) :\n  s.erase a ∪ singleton a b = s :=\next_lookup\n(λ x, by { by_cases h' : x = a,\n      { subst a, rw [lookup_union_right not_mem_erase_self, lookup_singleton_eq, h], },\n      { have : x ∉ singleton a b, { rwa mem_singleton },\n        rw [lookup_union_left_of_not_in this, lookup_erase_ne h'] } } )\n\nend\n\n/-! ### disjoint -/\n\n/-- `disjoint s₁ s₂` holds if `s₁` and `s₂` have no keys in common. -/\ndef disjoint (s₁ s₂ : finmap β) : Prop :=\n∀ x ∈ s₁, ¬ x ∈ s₂\n\nlemma disjoint_empty (x : finmap β) : disjoint ∅ x .\n\n@[symm]\nlemma disjoint.symm (x y : finmap β) (h : disjoint x y) : disjoint y x :=\nλ p hy hx, h p hx hy\n\nlemma disjoint.symm_iff (x y : finmap β) : disjoint x y ↔ disjoint y x :=\n⟨disjoint.symm x y, disjoint.symm y x⟩\n\nsection\n\nvariables [decidable_eq α]\n\ninstance : decidable_rel (@disjoint α β) :=\nλ x y, by dsimp only [disjoint]; apply_instance\n\nlemma disjoint_union_left (x y z : finmap β) : disjoint (x ∪ y) z ↔ disjoint x z ∧ disjoint y z :=\nby simp [disjoint, finmap.mem_union, or_imp_distrib, forall_and_distrib]\n\nlemma disjoint_union_right (x y z : finmap β) : disjoint x (y ∪ z) ↔ disjoint x y ∧ disjoint x z :=\nby rw [disjoint.symm_iff, disjoint_union_left, disjoint.symm_iff _ x, disjoint.symm_iff _ x]\n\ntheorem union_comm_of_disjoint {s₁ s₂ : finmap β} : disjoint s₁ s₂ → s₁ ∪ s₂ = s₂ ∪ s₁ :=\ninduction_on₂ s₁ s₂ $ λ s₁ s₂,\nby { intros h, simp only [alist.to_finmap_eq, union_to_finmap, alist.union_comm_of_disjoint h] }\n\ntheorem union_cancel {s₁ s₂ s₃ : finmap β} (h : disjoint s₁ s₃) (h' : disjoint s₂ s₃) :\n  s₁ ∪ s₃ = s₂ ∪ s₃ ↔ s₁ = s₂ :=\n⟨λ h'', begin\n          apply ext_lookup, intro x,\n          have : (s₁ ∪ s₃).lookup x = (s₂ ∪ s₃).lookup x, from h'' ▸ rfl,\n          by_cases hs₁ : x ∈ s₁,\n          { rwa [lookup_union_left hs₁, lookup_union_left_of_not_in (h _ hs₁)] at this, },\n          { by_cases hs₂ : x ∈ s₂,\n            { rwa [lookup_union_left_of_not_in (h' _ hs₂), lookup_union_left hs₂] at this, },\n            { rw [lookup_eq_none.mpr hs₁, lookup_eq_none.mpr hs₂] } }\n        end,\n λ h, h ▸ rfl⟩\n\nend\n\nend finmap\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/finmap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.7520125793176222, "lm_q1q2_score": 0.48176622160150157}}
{"text": "-- 3. higher order logic\n\nimport moromoro\nimport logic.basic\n\nnamespace hol\n\ninductive type : Type\n| base : type\n| prop : type\n| arrow : type → type → type\nopen type\n\nvariable ν : type → Type\n\ninductive term : type → Type\n| var : Π {t}, ν t → term t\n| lam : Π {t₁ t₂}, (ν t₁ → term t₂) → term (arrow t₁ t₂)\n| app : Π {t₁ t₂}, term (arrow t₁ t₂) → term t₁ → term t₂\n| eq : Π {t}, term t → term t → term prop\nopen term\n\ndef Term (t : type) : Type 1 :=\nΠ ν, term ν t\n\ndef judgment : list type → type → Type :=\nλ Γ t, list.foldr (λ t α, ν t → α) (term ν t) Γ\n\ndef Judgment (Γ : list type) (t : type) : Type 1 :=\nΠ ν, judgment ν Γ t\n\n----\n\nuniverse u\nvariables {α β : Type u}\n\ninductive mem : α → list α → Type u\n| here : Π {x l}, mem x (x :: l)\n| there : Π {x l y}, mem x l → mem x (y :: l)\nopen mem\n\nlocal infix ` ∈' `:50 := mem\n\nvariables {Γ Γ₁ Γ₂ : list type} {t t₁ t₂ t₃ : type}\n\ndef subst' : Π {t : type}, term (term ν) t → term ν t\n| _ (var m) := m\n| _ (lam f) := lam (λ x, subst' (f (var x)))\n| _ (app m₁ m₂) := app (subst' m₁) (subst' m₂)\n| _ (eq m₁ m₂) := eq (subst' m₁) (subst' m₂)\n\nnamespace judgment\n  def weak : Judgment Γ t₂ → Judgment (t₁ :: Γ) t₂ :=\n  λ m ν x, m ν\n\n  def var' : Π {Γ}, judgment ν (t :: Γ) t\n  | [] := λ x, var x\n  | (t :: Γ) := λ x y, var' x\n\n  def var : Π {Γ}, t ∈' Γ → Judgment Γ t\n  | _ here := λ ν, var' ν\n  | _ (there h) := weak (var h)\n\n  def lam' : Π {Γ}, judgment ν (t₁ :: Γ) t₂ → judgment ν Γ (arrow t₁ t₂)\n  | [] m := lam (λ x, m x)\n  | (t :: Γ) f := λ x, lam' (λ y, f y x)\n\n  def lam : Judgment (t₁ :: Γ) t₂ → Judgment Γ (arrow t₁ t₂) :=\n  λ m ν, lam' ν (m ν)\n\n  def app' : Π {Γ}, judgment ν Γ (arrow t₁ t₂) → judgment ν Γ t₁ → judgment ν Γ t₂\n  | [] m₁ m₂ := app m₁ m₂\n  | (t :: Γ) f m := λ x, app' (f x) (m x)\n\n  def app : Judgment Γ (arrow t₁ t₂) → Judgment Γ t₁ → Judgment Γ t₂ :=\n  λ m₁ m₂ ν, app' ν (m₁ ν) (m₂ ν)\n\n  def eq' : Π {Γ : list type}, judgment ν Γ t → judgment ν Γ t → judgment ν Γ prop\n  | [] m₁ m₂ := eq m₁ m₂\n  | (t :: Γ) m₁ m₂ := λ x, eq' (m₁ x) (m₂ x)\n\n  def eq : Judgment Γ t → Judgment Γ t → Judgment Γ prop :=\n  λ m₁ m₂ ν, eq' ν (m₁ ν) (m₂ ν)\n\n  def subst'' : Π {Γ}, judgment (term ν) (t₁ :: Γ) t₂ → judgment ν Γ t₁ → judgment ν Γ t₂\n  | [] m₁ m₂ := subst' ν (m₁ m₂)\n  | (t :: Γ) f m := λ x, subst'' (λ x', f x' (term.var x)) (m x)\n\n  def subst : Judgment (t₁ :: Γ) t₂ → Judgment Γ t₁ → Judgment Γ t₂ :=\n  λ m₁ m₂ ν, subst'' ν (m₁ _) (m₂ ν)\nend judgment\nopen judgment\n\n----\n\ndef type.foldr : list type → type → type :=\nλ Γ t, list.foldr arrow t Γ\n\ndef judgment.to_term' : Π {Γ : list type}, judgment ν Γ t → term ν (type.foldr Γ t)\n| [] m := m\n| (t :: Γ) f := lam (λ x, judgment.to_term' (f x))\n\ndef judgment.to_term : Judgment Γ t → Term (type.foldr Γ t) :=\nλ m ν, judgment.to_term' ν (m ν)\n\ndef term.to_judgment' : Π {Γ : list type}, term (term ν) (type.foldr Γ t) → judgment ν Γ t\n| [] m := subst' ν m\n| (t :: Γ) m :=\n  match m with\n  | (var x) := λ x, term.to_judgment' (app m (var (var x)))\n  | (lam f) := λ x, term.to_judgment' (f (var x))\n  | (app m₁ m₂) := λ x, term.to_judgment' (app m (var (var x)))\n  end\n\ndef term.to_judgment : Term (type.foldr Γ t) → Judgment Γ t :=\nλ m ν, term.to_judgment' ν (m _)\n\n----\n\ndef domain : type → Type\n| base := term ν base\n| prop := term ν prop\n| (arrow t₁ t₂) := domain t₁ → domain t₂\n\ndef Domain (t : type) : Type 1 :=\nΠ ν, domain ν t\n\ndef reify_reflect : Π (t : type), (domain ν t → term ν t) × (term ν t → domain ν t)\n| base := ⟨ id, id ⟩\n| prop := ⟨ id, id ⟩\n| (arrow t₁ t₂) :=\n   let r₁ := reify_reflect t₁ in\n   let r₂ := reify_reflect t₂ in\n   let reify (f : domain ν t₁ → domain ν t₂) := lam (λ x, r₂.1 (f (r₁.2 (var x)))) in\n   let reflect (f : term ν (arrow t₁ t₂)) := λ x, r₂.2 (app f (r₁.1 x)) in\n   ⟨reify, reflect⟩\n\ndef reify' : domain ν t → term ν t :=\nλ x, (reify_reflect ν t).1 x\n\ndef reify : Domain t → Term t :=\nλ x ν, reify' ν (x ν)\n\ndef eval' : Π {t : type}, term (domain ν) t → domain ν t\n| _ (var x) := x\n| _ (lam f) := λ x, eval' (f x)\n| _ (app m₁ m₂) := (eval' m₁) (eval' m₂)\n| _ (eq m₁ m₂) := eq (reify' ν (eval' m₁)) (reify' ν (eval' m₂))\n\ndef eval : Term t → Domain t :=\nλ m ν, eval' ν (m _)\n\ndef normalize : Term t → Term t :=\nreify ∘ eval\n\ninstance term_setoid : setoid (Term t) :=\n⟨inv_image eq normalize,\n inv_image.equivalence eq normalize eq_equivalence⟩\n\ninstance judgment_setoid [h : setoid (Term (type.foldr Γ t))] : setoid (Judgment Γ t) :=\n⟨inv_image h.r judgment.to_term,\n inv_image.equivalence h.r judgment.to_term h.iseqv⟩\n\nmeta def canonicity : tactic unit :=\n`[ try { unfold has_equiv.equiv setoid.r inv_image }, try { reflexivity } ]\n\n----\n\nnamespace term\n  def top : Term prop :=\n  λ ν, eq (lam (λ x : ν prop, var x)) (lam (λ x, var x))\n\n  def and : Term (arrow prop (arrow prop prop)) :=\n  λ ν, lam (λ p₁, lam (λ p₂, eq (lam (λ f : ν (arrow _ (arrow _ prop)), app (app (var f) (top ν)) (top ν))) (lam (λ f, app (app (var f) (var p₁)) (var p₂)))))\n\n  def Forall : Term (arrow (arrow t prop) prop) :=\n  λ ν, lam (λ f, eq (var f) (lam (λ x, (top ν))))\n\n  def bot : Term prop :=\n  λ ν, app (Forall ν) (lam (λ p, var p))\n\n  def implies : Term (arrow prop (arrow prop prop)) :=\n  λ ν, lam (λ p₁, lam (λ p₂, eq (app (app (and ν) (var p₁)) (var p₂)) (var p₁)))\n\n  def not : Term (arrow prop prop) :=\n  λ ν, lam (λ p, app (app (implies ν) (var p)) (bot ν))\n\n  def iff : Term (arrow prop (arrow prop prop)) :=\n  λ ν, lam (λ p₁, lam (λ p₂, app (app (and ν) (app (app (implies ν) (var p₁)) (var p₂))) (app (app (implies ν) (var p₂)) (var p₁))))\n\n  def or : Term (arrow prop (arrow prop prop)) :=\n  λ ν, lam (λ p₁, lam (λ p₂, app (Forall ν) (lam (λ r, app (app (implies ν) (app (app (and ν) (app (app (implies ν) (var p₁)) (var r))) (app (app (implies ν) (var p₂)) (var r)))) (var r)))))\n\n  def Exists : Term (arrow (arrow t prop) prop) :=\n  λ ν, lam (λ f, app (Forall ν) (lam (λ r, app (app (implies ν) (app (Forall ν) (lam (λ x, app (app (implies ν) (app (var f) (var x))) (var r))))) (var r))))\nend term\nopen term\n\n#reduce @id (Judgment [] prop) $ app (app and top) (app (app or bot) top)\n\n----\n\ninductive Theorem : Π {Γ}, list (Judgment Γ prop) → Judgment Γ prop → Prop\n| hyp : Π {Γ Φ} {φ : Judgment Γ prop}, φ ∈ Φ → Theorem Φ φ\n| refl : Π {Γ Φ t} {m₁ m₂ : Judgment Γ t}, m₁ ≈ m₂ → Theorem Φ (eq m₁ m₂)\n| subst : Π {Γ Φ t} (m : Judgment (t :: Γ) prop) (m₂ m₁ : Judgment Γ t), Theorem Φ (eq m₁ m₂) → Theorem Φ (subst m m₁) → Theorem Φ (subst m m₂)\n| prop_ext : Π {Γ Φ} {φ₁ φ₂ : Judgment Γ prop}, Theorem (φ₁ :: Φ) φ₂ → Theorem (φ₂ :: Φ) φ₁ → Theorem Φ (eq φ₁ φ₂)\n| fun_ext : Π {Γ Φ t₁ t₂} (m₁ m₂ : Judgment (t₁ :: Γ) t₂), Theorem (list.map weak Φ) (eq m₁ m₂) → Theorem Φ (eq (lam m₁) (lam m₂))\n\n-- Let's prove!\n\nexample : @Theorem [prop] [var here] (eq (weak top) (var here)) :=\nbegin\n  apply Theorem.prop_ext,\n  { apply Theorem.hyp,\n    simp },\n  { apply Theorem.refl,\n    canonicity }\nend\n\nexample {φ₁ φ₂} {Φ : list (Judgment [] prop)} : Theorem Φ (app (app and φ₁) φ₂) → Theorem Φ φ₁ :=\nbegin\n  intro p,\n  apply Theorem.subst\n    (var here)\n    φ₁\n    (λ ν, app (lam (λ f, app (app (var f) (φ₁ ν)) (φ₂ ν))) (lam (λ p₁, lam (λ p₂, var p₁)))),\n  { apply Theorem.refl,\n    canonicity, },\n  { apply Theorem.subst\n      (@id (Judgment [arrow _ prop] prop) $ λ ν f, app (var f) (lam (λ p₁, lam (λ p₂, var p₁))))\n      (λ ν, lam (λ f, app (app (var f) (φ₁ ν)) (φ₂ ν)))\n      (@id (Judgment [] (arrow _ prop)) $ λ ν, lam (λ f, app (app (var f) (top ν)) (top ν))),\n    { apply Theorem.subst\n        (var here)\n        (eq\n          (@id (Judgment [] (arrow _ prop)) $ λ ν, lam (λ f, app (app (var f) (top ν)) (top ν)))\n          (λ ν, lam (λ f, app (app (var f) (φ₁ ν)) (φ₂ ν))))\n        (λ ν, app (app (lam (λ p₁, lam (λ p₂, eq (lam (λ f : ν (arrow _ (arrow _ prop)), app (app (var f) (top ν)) (top ν))) (lam (λ f, app (app (var f) (var p₁)) (var p₂)))))) (φ₁ ν)) (φ₂ ν)),\n      { apply Theorem.refl,\n        canonicity },\n      { from p } },\n    { apply Theorem.subst\n        (var here)\n        (@id (Judgment [] _) $ λ ν, app (lam (λ f, app (app (var f) (top ν)) (top ν))) (lam (λ p₁, lam (λ p₂, var p₁))))\n        top,\n      { apply Theorem.refl,\n        canonicity },\n      { apply Theorem.refl,\n        canonicity } } }\nend\n\nend hol", "meta": {"author": "nyuichi", "repo": "LeanHOL", "sha": "8190f2d4234f0f39c9e7b5612e552e72ab002798", "save_path": "github-repos/lean/nyuichi-LeanHOL", "path": "github-repos/lean/nyuichi-LeanHOL/LeanHOL-8190f2d4234f0f39c9e7b5612e552e72ab002798/src/hol.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.48176620772163686}}
{"text": "import galois.tactic\n       .init .tail .inter .map_accum_lemmas .nth\n       .take_drop_lemmas .preds .fin_nth .mem\n\nuniverse u\n\ndef second {X A B : Type} (f : A -> B) : X × A -> X × B\n| (x, y) := (x, f y)\n\nlemma second_simpl {X A B : Type} (f : A -> B)\n  (x : X) (y : A)\n  : second f (x, y) = (x, f y)\n  := rfl\n\nnamespace list\n\n-- This runs a function over a list returning the intermediate results and a\n-- a final result.\ndef map_accuml {α  σ β : Type} (f : σ → α → β × σ) : σ → list α → (list β × σ)\n| c [] := ([], c)\n| c (y::yr) :=\n  let z := f c y in\n  let r := map_accuml z.2 yr in\n  (z.1 :: r.1, r.2)\n\ndef first_index_of_core {α : Type} (p : α → bool) : ℕ → list α → option (ℕ × α)\n| c [] := option.none\n| c (h::r) :=\n  if p h = tt then\n    option.some (c,h)\n  else\n    first_index_of_core (c+1) r\n\n-- This searches a list for an element that satisfies a predicate.\n--\n-- If it finds an element, it returns the index and element.  Otherwise, it\n-- returns none.\ndef first_index_of {α : Type} (p : α → bool) (l : list α) : option (ℕ × α) :=\n  first_index_of_core p 0 l\n\n\ndef find_option {A} [decidable_eq A] (item: A) (l : list A) : option ℕ :=\nlet index := list.index_of item l in\nif index = l.length then none else some index\n\nlemma find_option_mem_len {A} [decidable_eq A] {x : A} {xs : list A}\n  (H : x ∈ xs)\n  : ∃ n, xs.find_option x = some n ∧ n < xs.length\n:= begin\nrw ← list.index_of_lt_length at H,\ndestruct (find_option x xs),\n{ intros Hnone, exfalso,\n  unfold find_option at Hnone, dsimp at Hnone,\n  rw if_neg at Hnone, injection Hnone,\n  apply ne_of_lt, assumption },\n{ intros n Hn, constructor, split, assumption,\n  unfold find_option at Hn, dsimp at Hn,\n  have H : index_of x xs ≠ length xs,\n  apply ne_of_lt, assumption,\n  rw (if_neg H) at Hn, injection Hn with Hn',\n  rw ← Hn', assumption\n}\nend\n\nlemma find_option_mem {A} [decidable_eq A] {x : A} {xs : list A}\n  (H : x ∈ xs)\n  : ∃ n, xs.find_option x = some n\n:= begin\napply_in H find_option_mem_len,\ninduction H with n H, induction H with H H',\nconstructor, assumption,\nend\n\nlemma find_index_append {A} {P : A → Prop} [decidable_pred P]\n  (xs ys : list A)\n  (n : ℕ)\n  (Hn : n ≠ xs.length)\n  (H : xs.find_index P = n)\n  : (xs ++ ys).find_index P = n\n:= begin\nrevert n,\ninduction xs; intros,\n{ dsimp [list.index_of, list.find_index] at H, subst n,\n  exfalso, apply Hn, reflexivity, },\n{ dsimp [list.index_of, list.find_index] at H,\n  rename a x,\n  apply (if HPx : P x then _ else _),\n  { rw (if_pos HPx) at H, subst n,\n    dsimp [list.index_of, list.find_index],\n    rw (if_pos HPx), },\n  { rw (if_neg HPx) at H,\n    dsimp, dsimp [list.index_of, list.find_index],\n    rw (if_neg HPx),\n    cases n, injection H,\n    rename a n, injection H with H', clear H,\n    f_equal, apply ih_1, intros contra, apply Hn,\n    dsimp [list.length], dsimp [has_add.add, nat.add],\n    f_equal, assumption, assumption\n  }\n}\nend\n\nlemma index_of_append {A} [decidable_eq A] (x : A) (xs ys : list A)\n  (n : ℕ)\n  (Hn : n ≠ xs.length)\n  (H : list.index_of x xs = n)\n  : list.index_of x (xs ++ ys) = n\n:= begin\napply list.find_index_append; assumption\nend\n\nlemma not_not_iff {a : Prop} [decidable a] : ¬¬a ↔ a :=\niff.intro by_contradiction not_not_intro\n\nlemma find_option_append {A} [decidable_eq A] (x : A) (xs ys : list A)\n  (n : ℕ)\n  (Hn : xs.find_option x = some n)\n  : (xs ++ ys).find_option x = some n\n:= begin\nunfold find_option at Hn, dsimp at Hn,\napply (if H : list.index_of x xs = list.length xs then _ else _),\n{ rw (if_pos H) at Hn, contradiction, },\n{ rw (if_neg H) at Hn,\n  injection Hn with Hn', clear Hn,\n  dsimp, dsimp [find_option],\n  rw list.index_of_append, tactic.rotate 2, assumption,\n  tactic.swap, intros contra, apply H, subst n, assumption,\n  rw list.index_of_eq_length at H, subst Hn',\n  rw [not_not_iff] at H,\n  rw ← list.index_of_lt_length at H,\n  have H1 : list.index_of x xs ≠ list.length (xs ++ ys),\n  apply ne_of_lt, rw list.length_append,\n  apply lt_of_lt_of_le, assumption,\n  rw add_comm,\n  apply le_add_of_nonneg_left, apply nat.zero_le,\n  simp [H1],\n }\nend\n\nlemma nth_cons_drop {A : Type} : forall h t n (i :A),\nn ≠ 0 ->\nlist.nth (h :: t) (n) = some i ->\nlist.nth t (n - 1) = some i :=\nbegin\nintros,\ncases n,\n{ contradiction },\n{\n  dsimp at *,\n  simp at *,\n  assumption,\n}\nend\n\nlemma pair_induction_same_length {X Y}\n  (P : list X → list Y → Sort u)\n  (P0 : P [] [])\n  (PS : ∀ x y xs ys, P xs ys → P (x :: xs) (y :: ys))\n  (xs : list X) (ys : list Y) (H : xs.length = ys.length)\n  : P xs ys\n:= begin\nrevert xs, induction ys; intros; dsimp at H,\n{ apply_in H list.eq_nil_of_length_eq_zero, subst xs,\n  assumption, },\n{ cases xs; dsimp at H, contradiction,\n  apply PS, apply ih_1,\n  apply nat.add_right_cancel, assumption,\n}\nend\n\nlemma map_compose {A B C : Type}\n  (f : A -> B) (g : B -> C) (xs : list A)\n  : map (g ∘ f) xs = map g (map f xs)\n:=\nbegin\ninduction xs,\n{ reflexivity },\n{ simp [map] }\nend\n\nlemma reverse_core_app {A : Type} (xs ys zs : list A)\n  : list.reverse_core xs (ys ++ zs)\n  = list.reverse_core xs ys ++ zs\n:= begin\nrevert ys zs,\ninduction xs; intros,\n{ simp [list.reverse_core] },\n{ simp [list.reverse_core],\n  rw <- list.cons_append,\n  rw ih_1 }\nend\n\nlemma cons_reverse {A : Type} (x : A) (xs : list A)\n  : list.reverse (x :: xs) = list.reverse xs ++ [x]\n:=\nbegin\nunfold list.reverse,\nsimp [list.reverse_core],\ninduction xs,\n{ reflexivity },\n{ simp [list.reverse_core],\n  rw <- (reverse_core_app a_1 [a] [x]),\n  dsimp, reflexivity\n }\nend\n\nlemma cons_reverse_app {A : Type} (x : A) (xs : list A)\n: (list.reverse ∘ list.cons x) xs =\n   ((λ xs, xs ++ [x]) ∘ list.reverse) xs\n:=\nbegin\ninduction xs,\n{ reflexivity },\n{ simp [function.comp], }\nend\n\nlemma zip_same_length {X Y}\n  (xs ys : list X) (xs' ys' : list Y) (H : xs.length = xs'.length)\n  : zip (xs ++ ys) (xs' ++ ys')\n  = zip xs xs' ++ zip ys ys'\n:= begin\nrevert H xs' xs,\napply list.pair_induction_same_length,\nreflexivity, intros, dsimp [list.zip, list.zip_with],\nf_equal, assumption\nend\n\nlemma zip_map_r {X Y Z} (xs : list X) (ys : list Y)\n  (f : Y → Z)\n  : zip xs (map f ys) =\n  list.map (second f) (list.zip xs ys)\n:= begin\nrevert ys, induction xs; intros,\n{ reflexivity },\n{ cases ys,\n  { reflexivity },\n  { dsimp [list.zip, list.zip_with], f_equal,\n    specialize (ih_1 a_3),\n    unfold list.zip at ih_1,\n    rw ih_1,\n  }\n }\nend\n\nlemma map_fst_second {X A B : Type}\n  (xs : list (X × A)) (f : A -> B)\n  : map (prod.fst ∘ second f) xs\n  = map prod.fst xs\n:= begin\ninduction xs,\n{ reflexivity },\n{ simp only [list.map],\n  cases a with i1 i2,\n  simp only [second],\n  rw ih_1, reflexivity\n}\nend\n\nlemma map_not_nil {A B} (xs) (f : A -> B)\n  (H : xs ≠ []) : list.map f xs ≠ [] :=\nbegin\ncases xs,\n{ contradiction },\n{ simp [list.map], }\nend\n\nlemma map_nil {A B : Type} (f : A -> B)\n  (xs : list A)\n  (H : xs = [])\n  : list.map f xs = []\n  :=\nbegin\nrw H, reflexivity\nend\n\nlemma repeat_length {A} (x : A) (n : ℕ)\n  : (list.repeat x n).length = n\n:= begin\ninduction n; simp [list.repeat, list.length],\nend\n\nend list\n\nuniverse variable v\n\nnamespace list\n\nvariables {α : Type u} {β : Type v}\n\n/- null theorems -/\n\n-- Return true if list is empty\n--\n-- null x is equivalent to x = nil, but always decidable even if equality\n-- of list elements is undecidable\ndef null : list α → Prop := λx, x = nil\n\ninstance null_decidable : ∀ xs : list α, decidable (null xs)\n| nil := is_true (begin unfold null end)\n| (x :: xs) := is_false (begin unfold null, contradiction end)\n\n/- foldl theorem -/\n\n-- Recursor to prove properties about a list and a left-fold over that list\nprotected\nlemma foldl_rec_gen (P : list β → α → Prop)\n                    (f : α → β → α)\n                    (h : ∀(l : list β) (t : α) (e : β), P l t →  P (l ++ [e]) (f t e))\n: ∀(r : list β) (s : α), P r s → ∀ (l : list β), P (r ++ l) (foldl f s l)\n| r s p l :=\nbegin\n  revert r s p,\n  induction l,\n  case list.nil { intros r s p, simp, exact p, },\n  case list.cons e l ind {\n    intros r s p,\n    simp [foldl],\n    have g := ind (r ++ [e]) (f s e) (h r s e p),\n    simp at g,\n    exact g,\n  }\nend\n\n-- Recursor to prove properties about a list and a left-fold over that list\nprotected\ntheorem foldl_rec (P : list β → α → Prop)\n                  (f : α → β → α)\n                  (ind_step : ∀(l : list β) (t : α) (e : β), P l t →  P (l ++ [e]) (f t e))\n                  (s : α)\n                  (base_case : P nil s)\n                  (l : list β)\n: P l (foldl f s l) :=\n  list.foldl_rec_gen P f ind_step nil s base_case l\n\ndef drop_last {a : Type} (l : list a) := list.remove_nth l (list.length l - 1)\n\n\nend list", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/list/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.48175033548189566}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport topology.bornology.basic\n\n/-!\n# Locally bounded maps\n\nThis file defines locally bounded maps between bornologies.\n\nWe use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to\nbe satisfied by itself and all stricter types.\n\n## Types of morphisms\n\n* `locally_bounded_map`: Locally bounded maps. Maps which preserve boundedness.\n\n## Typeclasses\n\n* `locally_bounded_map_class`\n-/\n\nopen bornology filter function set\n\nvariables {F α β γ δ : Type*}\n\n/-- The type of bounded maps from `α` to `β`, the maps which send a bounded set to a bounded set. -/\nstructure locally_bounded_map (α β : Type*) [bornology α] [bornology β] :=\n(to_fun : α → β)\n(comap_cobounded_le' : (cobounded β).comap to_fun ≤ cobounded α)\n\n/-- `locally_bounded_map_class F α β` states that `F` is a type of bounded maps.\n\nYou should extend this class when you extend `locally_bounded_map`. -/\nclass locally_bounded_map_class (F : Type*) (α β : out_param $ Type*) [bornology α]\n  [bornology β]\n  extends fun_like F α (λ _, β) :=\n(comap_cobounded_le (f : F) : (cobounded β).comap f ≤ cobounded α)\n\nexport locally_bounded_map_class (comap_cobounded_le)\n\nlemma is_bounded.image [bornology α] [bornology β] [locally_bounded_map_class F α β] {f : F}\n  {s : set α} (hs : is_bounded s) : is_bounded (f '' s) :=\ncomap_cobounded_le_iff.1 (comap_cobounded_le f) hs\n\ninstance [bornology α] [bornology β] [locally_bounded_map_class F α β] :\n  has_coe_t F (locally_bounded_map α β) :=\n⟨λ f, ⟨f, comap_cobounded_le f⟩⟩\n\nnamespace locally_bounded_map\nvariables [bornology α] [bornology β] [bornology γ]\n  [bornology δ]\n\ninstance : locally_bounded_map_class (locally_bounded_map α β) α β :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h, by { cases f, cases g, congr' },\n  comap_cobounded_le := λ f, f.comap_cobounded_le' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (locally_bounded_map α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : locally_bounded_map α β} : f.to_fun = (f : α → β) := rfl\n\n@[ext] lemma ext {f g : locally_bounded_map α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of a `locally_bounded_map` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\nprotected def copy (f : locally_bounded_map α β) (f' : α → β) (h : f' = f) :\n  locally_bounded_map α β :=\n⟨f', h.symm ▸ f.comap_cobounded_le'⟩\n\n/-- Construct a `locally_bounded_map` from the fact that the function maps bounded sets to bounded\nsets. -/\ndef of_map_bounded (f : α → β) (h) : locally_bounded_map α β := ⟨f, comap_cobounded_le_iff.2 h⟩\n\n@[simp] lemma coe_of_map_bounded (f : α → β) {h} : ⇑(of_map_bounded f h) = f := rfl\n@[simp] lemma of_map_bounded_apply (f : α → β) {h} (a : α) : of_map_bounded f h a = f a := rfl\n\nvariables (α)\n\n/-- `id` as a `locally_bounded_map`. -/\nprotected def id : locally_bounded_map α α := ⟨id, comap_id.le⟩\n\ninstance : inhabited (locally_bounded_map α α) := ⟨locally_bounded_map.id α⟩\n\n@[simp] lemma coe_id : ⇑(locally_bounded_map.id α) = id := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : locally_bounded_map.id α a = a := rfl\n\n/-- Composition of `locally_bounded_map`s as a `locally_bounded_map`. -/\ndef comp (f : locally_bounded_map β γ) (g : locally_bounded_map α β) : locally_bounded_map α γ :=\n{ to_fun := f ∘ g,\n  comap_cobounded_le' :=\n    comap_comap.ge.trans $ (comap_mono f.comap_cobounded_le').trans g.comap_cobounded_le' }\n\n@[simp] lemma coe_comp (f : locally_bounded_map β γ) (g : locally_bounded_map α β) :\n  ⇑(f.comp g) = f ∘ g := rfl\n@[simp] lemma comp_apply (f : locally_bounded_map β γ) (g : locally_bounded_map α β) (a : α) :\n  f.comp g a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : locally_bounded_map γ δ) (g : locally_bounded_map β γ)\n  (h : locally_bounded_map α β) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : locally_bounded_map α β) :\n  f.comp (locally_bounded_map.id α) = f := ext $ λ a, rfl\n@[simp] lemma id_comp (f : locally_bounded_map α β) :\n  (locally_bounded_map.id β).comp f = f := ext $ λ a, rfl\n\nlemma cancel_right {g₁ g₂ : locally_bounded_map β γ} {f : locally_bounded_map α β}\n  (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : locally_bounded_map β γ} {f₁ f₂ : locally_bounded_map α β}\n  (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, ext $ λ a, hg $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩\n\nend locally_bounded_map\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/bornology/hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.48175033125776934}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo, Yury Kudryashov, Frédéric Dupuis,\n  Heather Macbeth\n-/\nimport topology.algebra.ring\nimport topology.algebra.mul_action\nimport topology.uniform_space.uniform_embedding\nimport algebra.algebra.basic\nimport linear_algebra.projection\nimport linear_algebra.pi\n\n/-!\n# Theory of topological modules and continuous linear maps.\n\nWe use the class `has_continuous_smul` for topological (semi) modules and topological vector spaces.\n\nIn this file we define continuous (semi-)linear maps, as semilinear maps between topological\nmodules which are continuous. The set of continuous semilinear maps between the topological\n`R₁`-module `M` and `R₂`-module `M₂` with respect to the `ring_hom` `σ` is denoted by `M →SL[σ] M₂`.\nPlain linear maps are denoted by `M →L[R] M₂` and star-linear maps by `M →L⋆[R] M₂`.\n\nThe corresponding notation for equivalences is `M ≃SL[σ] M₂`, `M ≃L[R] M₂` and `M ≃L⋆[R] M₂`.\n-/\n\nopen filter\nopen_locale topological_space big_operators filter\n\nuniverses u v w u'\n\nsection\n\nvariables {R : Type*} {M : Type*}\n[ring R] [topological_space R]\n[topological_space M] [add_comm_group M]\n[module R M]\n\nlemma has_continuous_smul.of_nhds_zero [topological_ring R] [topological_add_group M]\n  (hmul : tendsto (λ p : R × M, p.1 • p.2) (𝓝 0 ×ᶠ (𝓝 0)) (𝓝 0))\n  (hmulleft : ∀ m : M, tendsto (λ a : R, a • m) (𝓝 0) (𝓝 0))\n  (hmulright : ∀ a : R, tendsto (λ m : M, a • m) (𝓝 0) (𝓝 0)) : has_continuous_smul R M :=\n⟨begin\n  rw continuous_iff_continuous_at,\n  rintros ⟨a₀, m₀⟩,\n  have key : ∀ p : R × M,\n    p.1 • p.2 = a₀ • m₀ + ((p.1 - a₀) • m₀ + a₀ • (p.2 - m₀) + (p.1 - a₀) • (p.2 - m₀)),\n  { rintro ⟨a, m⟩,\n    simp [sub_smul, smul_sub],\n    abel },\n  rw funext key, clear key,\n  refine tendsto_const_nhds.add (tendsto.add (tendsto.add _ _) _),\n  { rw [sub_self, zero_smul],\n    apply (hmulleft m₀).comp,\n    rw [show (λ p : R × M, p.1 - a₀) = (λ a, a - a₀) ∘ prod.fst, by {ext, refl }, nhds_prod_eq],\n    have : tendsto (λ a, a - a₀) (𝓝 a₀) (𝓝 0),\n    { rw ← sub_self a₀,\n      exact tendsto_id.sub tendsto_const_nhds },\n    exact this.comp tendsto_fst  },\n  { rw [sub_self, smul_zero],\n    apply (hmulright a₀).comp,\n    rw [show (λ p : R × M, p.2 - m₀) = (λ m, m - m₀) ∘ prod.snd, by {ext, refl }, nhds_prod_eq],\n    have : tendsto (λ m, m - m₀) (𝓝 m₀) (𝓝 0),\n    { rw ← sub_self m₀,\n      exact tendsto_id.sub tendsto_const_nhds },\n    exact this.comp tendsto_snd },\n  { rw [sub_self, zero_smul, nhds_prod_eq,\n        show (λ p : R × M, (p.fst - a₀) • (p.snd - m₀)) =\n             (λ  p : R × M, p.1 • p.2) ∘ (prod.map (λ a, a - a₀) (λ m, m - m₀)), by { ext, refl }],\n    apply hmul.comp (tendsto.prod_map _ _);\n    { rw ← sub_self ,\n      exact tendsto_id.sub tendsto_const_nhds } },\nend⟩\nend\n\nsection\nvariables {R : Type*} {M : Type*}\n[ring R] [topological_space R]\n[topological_space M] [add_comm_group M] [has_continuous_add M]\n[module R M] [has_continuous_smul R M]\n\n/-- If `M` is a topological module over `R` and `0` is a limit of invertible elements of `R`, then\n`⊤` is the only submodule of `M` with a nonempty interior.\nThis is the case, e.g., if `R` is a nondiscrete normed field. -/\nlemma submodule.eq_top_of_nonempty_interior'\n  [ne_bot (𝓝[{x : R | is_unit x}] 0)]\n  (s : submodule R M) (hs : (interior (s:set M)).nonempty) :\n  s = ⊤ :=\nbegin\n  rcases hs with ⟨y, hy⟩,\n  refine (submodule.eq_top_iff'.2 $ λ x, _),\n  rw [mem_interior_iff_mem_nhds] at hy,\n  have : tendsto (λ c:R, y + c • x) (𝓝[{x : R | is_unit x}] 0) (𝓝 (y + (0:R) • x)),\n    from tendsto_const_nhds.add ((tendsto_nhds_within_of_tendsto_nhds tendsto_id).smul\n      tendsto_const_nhds),\n  rw [zero_smul, add_zero] at this,\n  obtain ⟨_, hu : y + _ • _ ∈ s, u, rfl⟩ :=\n    nonempty_of_mem (inter_mem (mem_map.1 (this hy)) self_mem_nhds_within),\n  have hy' : y ∈ ↑s := mem_of_mem_nhds hy,\n  rwa [s.add_mem_iff_right hy', ←units.smul_def, s.smul_mem_iff' u] at hu,\nend\n\nvariables (R M)\n\n/-- Let `R` be a topological ring such that zero is not an isolated point (e.g., a nondiscrete\nnormed field, see `normed_field.punctured_nhds_ne_bot`). Let `M` be a nontrivial module over `R`\nsuch that `c • x = 0` implies `c = 0 ∨ x = 0`. Then `M` has no isolated points. We formulate this\nusing `ne_bot (𝓝[{x}ᶜ] x)`.\n\nThis lemma is not an instance because Lean would need to find `[has_continuous_smul ?m_1 M]` with\nunknown `?m_1`. We register this as an instance for `R = ℝ` in `real.punctured_nhds_module_ne_bot`.\nOne can also use `haveI := module.punctured_nhds_ne_bot R M` in a proof.\n-/\nlemma module.punctured_nhds_ne_bot [nontrivial M] [ne_bot (𝓝[{0}ᶜ] (0 : R))]\n  [no_zero_smul_divisors R M] (x : M) :\n  ne_bot (𝓝[{x}ᶜ] x) :=\nbegin\n  rcases exists_ne (0 : M) with ⟨y, hy⟩,\n  suffices : tendsto (λ c : R, x + c • y) (𝓝[{0}ᶜ] 0) (𝓝[{x}ᶜ] x), from this.ne_bot,\n  refine tendsto.inf _ (tendsto_principal_principal.2 $ _),\n  { convert tendsto_const_nhds.add ((@tendsto_id R _).smul_const y),\n    rw [zero_smul, add_zero] },\n  { intros c hc,\n    simpa [hy] using hc }\nend\n\nend\n\nnamespace submodule\n\nvariables {α β : Type*} [topological_space β]\n\ninstance [topological_space α] [semiring α] [add_comm_monoid β] [module α β]\n  [has_continuous_smul α β] (S : submodule α β) :\n  has_continuous_smul α S :=\n{ continuous_smul :=\n  begin\n    rw embedding_subtype_coe.to_inducing.continuous_iff,\n    exact continuous_fst.smul\n      (continuous_subtype_coe.comp continuous_snd)\n  end }\n\ninstance [ring α] [add_comm_group β] [module α β] [topological_add_group β] (S : submodule α β) :\n  topological_add_group S :=\nS.to_add_subgroup.topological_add_group\n\nend submodule\n\nsection closure\nvariables {R : Type u} {M : Type v}\n[semiring R] [topological_space R]\n[topological_space M] [add_comm_monoid M]\n[module R M] [has_continuous_smul R M]\n\nlemma submodule.closure_smul_self_subset (s : submodule R M) :\n  (λ p : R × M, p.1 • p.2) '' ((set.univ : set R).prod (closure (s : set M)))\n  ⊆ closure (s : set M) :=\ncalc\n(λ p : R × M, p.1 • p.2) '' ((set.univ : set R).prod (closure (s : set M)))\n    = (λ p : R × M, p.1 • p.2) '' (closure ((set.univ : set R).prod s)) : by simp [closure_prod_eq]\n... ⊆ closure ((λ p : R × M, p.1 • p.2) '' ((set.univ : set R).prod s)) :\n  image_closure_subset_closure_image continuous_smul\n... = closure s : begin\n  congr,\n  ext x,\n  refine ⟨_, λ hx, ⟨⟨1, x⟩, ⟨set.mem_univ _, hx⟩, one_smul R _⟩⟩,\n  rintros ⟨⟨c, y⟩, ⟨hc, hy⟩, rfl⟩,\n  simp [s.smul_mem c hy]\nend\n\nlemma submodule.closure_smul_self_eq (s : submodule R M) :\n  (λ p : R × M, p.1 • p.2) '' ((set.univ : set R).prod (closure (s : set M)))\n  = closure (s : set M) :=\nset.subset.antisymm s.closure_smul_self_subset\n  (λ x hx, ⟨⟨1, x⟩, ⟨set.mem_univ _, hx⟩, one_smul R _⟩)\n\nvariables [has_continuous_add M]\n\n/-- The (topological-space) closure of a submodule of a topological `R`-module `M` is itself\na submodule. -/\ndef submodule.topological_closure (s : submodule R M) : submodule R M :=\n{ carrier := closure (s : set M),\n  smul_mem' := λ c x hx, s.closure_smul_self_subset ⟨⟨c, x⟩, ⟨set.mem_univ _, hx⟩, rfl⟩,\n  ..s.to_add_submonoid.topological_closure }\n\n@[simp] lemma submodule.topological_closure_coe (s : submodule R M) :\n  (s.topological_closure : set M) = closure (s : set M) :=\nrfl\n\ninstance submodule.topological_closure_has_continuous_smul (s : submodule R M) :\n  has_continuous_smul R (s.topological_closure) :=\n{ continuous_smul :=\n  begin\n    apply continuous_induced_rng,\n    change continuous (λ p : R × s.topological_closure, p.1 • (p.2 : M)),\n    continuity,\n  end,\n  ..s.to_add_submonoid.topological_closure_has_continuous_add }\n\nlemma submodule.submodule_topological_closure (s : submodule R M) :\n  s ≤ s.topological_closure :=\nsubset_closure\n\nlemma submodule.is_closed_topological_closure (s : submodule R M) :\n  is_closed (s.topological_closure : set M) :=\nby convert is_closed_closure\n\nlemma submodule.topological_closure_minimal\n  (s : submodule R M) {t : submodule R M} (h : s ≤ t) (ht : is_closed (t : set M)) :\n  s.topological_closure ≤ t :=\nclosure_minimal h ht\n\nlemma submodule.topological_closure_mono {s : submodule R M} {t : submodule R M} (h : s ≤ t) :\n  s.topological_closure ≤ t.topological_closure :=\ns.topological_closure_minimal (h.trans t.submodule_topological_closure)\n  t.is_closed_topological_closure\n\nend closure\n\n/-- Continuous linear maps between modules. We only put the type classes that are necessary for the\ndefinition, although in applications `M` and `M₂` will be topological modules over the topological\nring `R`. -/\nstructure continuous_linear_map\n  {R : Type*} {S : Type*} [semiring R] [semiring S] (σ : R →+* S)\n  (M : Type*) [topological_space M] [add_comm_monoid M]\n  (M₂ : Type*) [topological_space M₂] [add_comm_monoid M₂]\n  [module R M] [module S M₂]\n  extends M →ₛₗ[σ] M₂ :=\n(cont : continuous to_fun . tactic.interactive.continuity')\n\nnotation M ` →SL[`:25 σ `] ` M₂ := continuous_linear_map σ M M₂\nnotation M ` →L[`:25 R `] ` M₂ := continuous_linear_map (ring_hom.id R) M M₂\nnotation M ` →L⋆[`:25 R `] ` M₂ := continuous_linear_map (@star_ring_aut R _ _ : R →+* R) M M₂\n\n/-- Continuous linear equivalences between modules. We only put the type classes that are necessary\nfor the definition, although in applications `M` and `M₂` will be topological modules over the\ntopological ring `R`. -/\n@[nolint has_inhabited_instance]\nstructure continuous_linear_equiv\n  {R : Type*} {S : Type*} [semiring R] [semiring S] (σ : R →+* S)\n  {σ' : S →+* R} [ring_hom_inv_pair σ σ'] [ring_hom_inv_pair σ' σ]\n  (M : Type*) [topological_space M] [add_comm_monoid M]\n  (M₂ : Type*) [topological_space M₂] [add_comm_monoid M₂]\n  [module R M] [module S M₂]\n  extends M ≃ₛₗ[σ] M₂ :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\nnotation M ` ≃SL[`:50 σ `] ` M₂ := continuous_linear_equiv σ M M₂\nnotation M ` ≃L[`:50 R `] ` M₂ := continuous_linear_equiv (ring_hom.id R) M M₂\nnotation M ` ≃L⋆[`:50 R `] ` M₂ := continuous_linear_equiv (@star_ring_aut R _ _ : R →+* R) M M₂\n\nnamespace continuous_linear_map\n\nsection semiring\n/-!\n### Properties that hold for non-necessarily commutative semirings.\n-/\n\nvariables\n{R₁ : Type*} {R₂ : Type*} {R₃ : Type*} [semiring R₁] [semiring R₂] [semiring R₃]\n{σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃}\n{M₁ : Type*} [topological_space M₁] [add_comm_monoid M₁]\n{M₂ : Type*} [topological_space M₂] [add_comm_monoid M₂]\n{M₃ : Type*} [topological_space M₃] [add_comm_monoid M₃]\n{M₄ : Type*} [topological_space M₄] [add_comm_monoid M₄]\n[module R₁ M₁] [module R₂ M₂] [module R₃ M₃]\n\n/-- Coerce continuous linear maps to linear maps. -/\ninstance : has_coe (M₁ →SL[σ₁₂] M₂) (M₁ →ₛₗ[σ₁₂] M₂) := ⟨to_linear_map⟩\n\n-- make the coercion the preferred form\n@[simp] lemma to_linear_map_eq_coe (f : M₁ →SL[σ₁₂] M₂) : f.to_linear_map = f := rfl\n\n/-- Coerce continuous linear maps to functions. -/\n-- see Note [function coercion]\ninstance to_fun : has_coe_to_fun (M₁ →SL[σ₁₂] M₂) (λ _, M₁ → M₂) := ⟨λ f, f⟩\n\n@[simp] lemma coe_mk (f : M₁ →ₛₗ[σ₁₂] M₂) (h) : (mk f h : M₁ →ₛₗ[σ₁₂] M₂) = f := rfl\n@[simp] lemma coe_mk' (f : M₁ →ₛₗ[σ₁₂] M₂) (h) : (mk f h : M₁ → M₂) = f := rfl\n\n@[continuity]\nprotected lemma continuous (f : M₁ →SL[σ₁₂] M₂) : continuous f := f.2\n\ntheorem coe_injective : function.injective (coe : (M₁ →SL[σ₁₂] M₂) → (M₁ →ₛₗ[σ₁₂] M₂)) :=\nby { intros f g H, cases f, cases g, congr' }\n\n@[simp, norm_cast] lemma coe_inj {f g : M₁ →SL[σ₁₂] M₂} :\n  (f : M₁ →ₛₗ[σ₁₂] M₂) = g ↔ f = g :=\ncoe_injective.eq_iff\n\ntheorem coe_fn_injective : @function.injective (M₁ →SL[σ₁₂] M₂) (M₁ → M₂) coe_fn :=\nlinear_map.coe_injective.comp coe_injective\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : M₁ →SL[σ₁₂] M₂) : M₁ → M₂ := h\n\n/-- See Note [custom simps projection]. -/\ndef simps.coe (h : M₁ →SL[σ₁₂] M₂) : M₁ →ₛₗ[σ₁₂] M₂ := h\n\ninitialize_simps_projections continuous_linear_map\n  (to_linear_map_to_fun → apply, to_linear_map → coe)\n\n@[ext] theorem ext {f g : M₁ →SL[σ₁₂] M₂} (h : ∀ x, f x = g x) : f = g :=\ncoe_fn_injective $ funext h\n\ntheorem ext_iff {f g : M₁ →SL[σ₁₂] M₂} : f = g ↔ ∀ x, f x = g x :=\n⟨λ h x, by rw h, by ext⟩\n\nvariables (f g : M₁ →SL[σ₁₂] M₂) (c : R₁) (h : M₂ →SL[σ₂₃] M₃) (x y z : M₁)\n\n-- make some straightforward lemmas available to `simp`.\n@[simp] lemma map_zero : f (0 : M₁) = 0 := (to_linear_map _).map_zero\n@[simp] lemma map_add  : f (x + y) = f x + f y := (to_linear_map _).map_add _ _\n@[simp] lemma map_smulₛₗ : f (c • x) = (σ₁₂ c) • f x := (to_linear_map _).map_smulₛₗ _ _\n\n@[simp] lemma map_smul [module R₁ M₂] (f : M₁ →L[R₁] M₂)(c : R₁) (x : M₁) : f (c • x) = c • f x :=\nby simp only [ring_hom.id_apply, map_smulₛₗ]\n\n@[simp, priority 900]\nlemma map_smul_of_tower {R S : Type*} [semiring S] [has_scalar R M₁]\n  [module S M₁] [has_scalar R M₂] [module S M₂]\n  [linear_map.compatible_smul M₁ M₂ R S] (f : M₁ →L[S] M₂) (c : R) (x : M₁) :\n  f (c • x) = c • f x :=\nlinear_map.compatible_smul.map_smul f c x\n\nlemma map_sum {ι : Type*} (s : finset ι) (g : ι → M₁) :\n  f (∑ i in s, g i) = ∑ i in s, f (g i) := f.to_linear_map.map_sum\n\n@[simp, norm_cast] lemma coe_coe : ((f : M₁ →ₛₗ[σ₁₂] M₂) : (M₁ → M₂)) = (f : M₁ → M₂) := rfl\n\n@[ext] theorem ext_ring [topological_space R₁] {f g : R₁ →L[R₁] M₁} (h : f 1 = g 1) : f = g :=\ncoe_inj.1 $ linear_map.ext_ring h\n\ntheorem ext_ring_iff [topological_space R₁] {f g : R₁ →L[R₁] M₁} : f = g ↔ f 1 = g 1 :=\n⟨λ h, h ▸ rfl, ext_ring⟩\n\n/-- If two continuous linear maps are equal on a set `s`, then they are equal on the closure\nof the `submodule.span` of this set. -/\nlemma eq_on_closure_span [t2_space M₂] {s : set M₁} {f g : M₁ →SL[σ₁₂] M₂} (h : set.eq_on f g s) :\n  set.eq_on f g (closure (submodule.span R₁ s : set M₁)) :=\n(linear_map.eq_on_span' h).closure f.continuous g.continuous\n\n/-- If the submodule generated by a set `s` is dense in the ambient module, then two continuous\nlinear maps equal on `s` are equal. -/\nlemma ext_on [t2_space M₂] {s : set M₁} (hs : dense (submodule.span R₁ s : set M₁))\n  {f g : M₁ →SL[σ₁₂] M₂} (h : set.eq_on f g s) :\n  f = g :=\next $ λ x, eq_on_closure_span h (hs x)\n\n/-- Under a continuous linear map, the image of the `topological_closure` of a submodule is\ncontained in the `topological_closure` of its image. -/\nlemma _root_.submodule.topological_closure_map [ring_hom_surjective σ₁₂] [topological_space R₁]\n  [topological_space R₂] [has_continuous_smul R₁ M₁] [has_continuous_add M₁]\n  [has_continuous_smul R₂ M₂] [has_continuous_add M₂] (f : M₁ →SL[σ₁₂] M₂) (s : submodule R₁ M₁) :\n  (s.topological_closure.map (f : M₁ →ₛₗ[σ₁₂] M₂))\n  ≤ (s.map (f : M₁ →ₛₗ[σ₁₂] M₂)).topological_closure :=\nimage_closure_subset_closure_image f.continuous\n\n/-- Under a dense continuous linear map, a submodule whose `topological_closure` is `⊤` is sent to\nanother such submodule.  That is, the image of a dense set under a map with dense range is dense.\n-/\nlemma _root_.dense_range.topological_closure_map_submodule [ring_hom_surjective σ₁₂]\n  [topological_space R₁] [topological_space R₂] [has_continuous_smul R₁ M₁] [has_continuous_add M₁]\n  [has_continuous_smul R₂ M₂] [has_continuous_add M₂] {f : M₁ →SL[σ₁₂] M₂} (hf' : dense_range f)\n  {s : submodule R₁ M₁} (hs : s.topological_closure = ⊤) :\n  (s.map (f : M₁ →ₛₗ[σ₁₂] M₂)).topological_closure = ⊤ :=\nbegin\n  rw set_like.ext'_iff at hs ⊢,\n  simp only [submodule.topological_closure_coe, submodule.top_coe, ← dense_iff_closure_eq] at hs ⊢,\n  exact hf'.dense_image f.continuous hs\nend\n\n/-- The continuous map that is constantly zero. -/\ninstance: has_zero (M₁ →SL[σ₁₂] M₂) := ⟨⟨0, continuous_zero⟩⟩\ninstance : inhabited (M₁ →SL[σ₁₂] M₂) := ⟨0⟩\n\n@[simp] lemma default_def : default (M₁ →SL[σ₁₂] M₂) = 0 := rfl\n@[simp] lemma zero_apply : (0 : M₁ →SL[σ₁₂] M₂) x = 0 := rfl\n@[simp, norm_cast] lemma coe_zero : ((0 : M₁ →SL[σ₁₂] M₂) : M₁ →ₛₗ[σ₁₂] M₂) = 0 := rfl\n/- no simp attribute on the next line as simp does not always simplify `0 x` to `0`\nwhen `0` is the zero function, while it does for the zero continuous linear map,\nand this is the most important property we care about. -/\n@[norm_cast] lemma coe_zero' : ((0 : M₁ →SL[σ₁₂] M₂) : M₁ → M₂) = 0 := rfl\n\ninstance unique_of_left [subsingleton M₁] : unique (M₁ →SL[σ₁₂] M₂) :=\ncoe_injective.unique\n\ninstance unique_of_right [subsingleton M₂] : unique (M₁ →SL[σ₁₂] M₂) :=\ncoe_injective.unique\n\nsection\n\nvariables (R₁ M₁)\n\n/-- the identity map as a continuous linear map. -/\ndef id : M₁ →L[R₁] M₁ :=\n⟨linear_map.id, continuous_id⟩\n\nend\n\ninstance : has_one (M₁ →L[R₁] M₁) := ⟨id R₁ M₁⟩\n\nlemma one_def : (1 : M₁ →L[R₁] M₁) = id R₁ M₁ := rfl\nlemma id_apply : id R₁ M₁ x = x := rfl\n@[simp, norm_cast] lemma coe_id : (id R₁ M₁ : M₁ →ₗ[R₁] M₁) = linear_map.id := rfl\n@[simp, norm_cast] lemma coe_id' : (id R₁ M₁ : M₁ → M₁) = _root_.id := rfl\n\n@[simp, norm_cast] lemma coe_eq_id {f : M₁ →L[R₁] M₁} :\n  (f : M₁ →ₗ[R₁] M₁) = linear_map.id ↔ f = id _ _ :=\nby rw [← coe_id, coe_inj]\n\n@[simp] lemma one_apply : (1 : M₁ →L[R₁] M₁) x = x := rfl\n\nsection add\nvariables [has_continuous_add M₂]\n\ninstance : has_add (M₁ →SL[σ₁₂] M₂) :=\n⟨λ f g, ⟨f + g, f.2.add g.2⟩⟩\n\nlemma continuous_nsmul (n : ℕ) : continuous (λ (x : M₂), n • x) :=\nbegin\n  induction n with n ih,\n  { simp [continuous_const] },\n  { simp [nat.succ_eq_add_one, add_smul], exact ih.add continuous_id }\nend\n\n@[continuity]\nlemma continuous.nsmul {α : Type*} [topological_space α] {n : ℕ} {f : α → M₂} (hf : continuous f) :\n  continuous (λ (x : α), n • (f x)) :=\n(continuous_nsmul n).comp hf\n\n@[simp] lemma add_apply : (f + g) x = f x + g x := rfl\n@[simp, norm_cast] lemma coe_add : (((f + g) : M₁ →SL[σ₁₂] M₂) : M₁ →ₛₗ[σ₁₂] M₂) = f + g := rfl\n@[norm_cast] lemma coe_add' : (((f + g) : M₁ →SL[σ₁₂] M₂) : M₁ → M₂) = (f : M₁ → M₂) + g := rfl\n\ninstance : add_comm_monoid (M₁ →SL[σ₁₂] M₂) :=\n{ zero := (0 : M₁ →SL[σ₁₂] M₂),\n  add := (+),\n  zero_add := by intros; ext; apply_rules [zero_add, add_assoc, add_zero, add_left_neg, add_comm],\n  add_zero := by intros; ext; apply_rules [zero_add, add_assoc, add_zero, add_left_neg, add_comm],\n  add_comm := by intros; ext; apply_rules [zero_add, add_assoc, add_zero, add_left_neg, add_comm],\n  add_assoc := by intros; ext; apply_rules [zero_add, add_assoc, add_zero, add_left_neg, add_comm],\n  nsmul := λ n f,\n    { to_fun := λ x, n • (f x),\n      map_add' := by simp,\n      map_smul' := by simp [smul_comm n] },\n  nsmul_zero' := λ f, by { ext, simp },\n  nsmul_succ' := λ n f, by { ext, simp [nat.succ_eq_one_add, add_smul] } }\n\n@[simp, norm_cast] lemma coe_sum {ι : Type*} (t : finset ι) (f : ι → M₁ →SL[σ₁₂] M₂) :\n  ↑(∑ d in t, f d) = (∑ d in t, f d : M₁ →ₛₗ[σ₁₂] M₂) :=\n(add_monoid_hom.mk (coe : (M₁ →SL[σ₁₂] M₂) → (M₁ →ₛₗ[σ₁₂] M₂)) rfl (λ _ _, rfl)).map_sum _ _\n\n@[simp, norm_cast] lemma coe_sum' {ι : Type*} (t : finset ι) (f : ι → M₁ →SL[σ₁₂] M₂) :\n  ⇑(∑ d in t, f d) = ∑ d in t, f d :=\nby simp only [← coe_coe, coe_sum, linear_map.coe_fn_sum]\n\nlemma sum_apply {ι : Type*} (t : finset ι) (f : ι → M₁ →SL[σ₁₂] M₂) (b : M₁) :\n  (∑ d in t, f d) b = ∑ d in t, f d b :=\nby simp only [coe_sum', finset.sum_apply]\n\nend add\n\nvariables {σ₁₃ : R₁ →+* R₃} [ring_hom_comp_triple σ₁₂ σ₂₃ σ₁₃]\n\n/-- Composition of bounded linear maps. -/\ndef comp (g : M₂ →SL[σ₂₃] M₃) (f : M₁ →SL[σ₁₂] M₂) : M₁ →SL[σ₁₃] M₃ :=\n⟨(g : M₂ →ₛₗ[σ₂₃] M₃).comp ↑f, g.2.comp f.2⟩\n\ninfixr ` ∘L `:80 := @continuous_linear_map.comp _ _ _ _ _ _ (ring_hom.id _) (ring_hom.id _)\n  _ _ _ _ _ _ _ _ _ _ _ _ (ring_hom.id _) ring_hom_comp_triple.ids\n\n@[simp, norm_cast] lemma coe_comp :\n  ((h.comp f) : (M₁ →ₛₗ[σ₁₃] M₃)) = (h : M₂ →ₛₗ[σ₂₃] M₃).comp (f : M₁ →ₛₗ[σ₁₂] M₂) := rfl\n\ninclude σ₁₃\n@[simp, norm_cast] lemma coe_comp' : ((h.comp f) : (M₁ → M₃)) = (h : M₂ → M₃) ∘ f := rfl\n\nlemma comp_apply (g : M₂ →SL[σ₂₃] M₃) (f : M₁ →SL[σ₁₂] M₂) (x : M₁) : (g.comp f) x = g (f x) := rfl\nomit σ₁₃\n\n@[simp] theorem comp_id : f.comp (id R₁ M₁) = f :=\next $ λ x, rfl\n\n@[simp] theorem id_comp : (id R₂ M₂).comp f = f :=\next $ λ x, rfl\n\ninclude σ₁₃\n@[simp] theorem comp_zero (g : M₂ →SL[σ₂₃] M₃) : g.comp (0 : M₁ →SL[σ₁₂] M₂) = 0 :=\nby { ext, simp }\n\n@[simp] theorem zero_comp : (0 : M₂ →SL[σ₂₃] M₃).comp f = 0 :=\nby { ext, simp }\n\n@[simp] lemma comp_add [has_continuous_add M₂] [has_continuous_add M₃]\n  (g : M₂ →SL[σ₂₃] M₃) (f₁ f₂ : M₁ →SL[σ₁₂] M₂) :\n  g.comp (f₁ + f₂) = g.comp f₁ + g.comp f₂ :=\nby { ext, simp }\n\n@[simp] lemma add_comp [has_continuous_add M₃]\n  (g₁ g₂ : M₂ →SL[σ₂₃] M₃) (f : M₁ →SL[σ₁₂] M₂) :\n  (g₁ + g₂).comp f = g₁.comp f + g₂.comp f :=\nby { ext, simp }\nomit σ₁₃\n\ntheorem comp_assoc {R₄ : Type*} [semiring R₄] [module R₄ M₄] {σ₁₄ : R₁ →+* R₄} {σ₂₄ : R₂ →+* R₄}\n  {σ₃₄ : R₃ →+* R₄} [ring_hom_comp_triple σ₁₃ σ₃₄ σ₁₄] [ring_hom_comp_triple σ₂₃ σ₃₄ σ₂₄]\n  [ring_hom_comp_triple σ₁₂ σ₂₄ σ₁₄] (h : M₃ →SL[σ₃₄] M₄) (g : M₂ →SL[σ₂₃] M₃)\n  (f : M₁ →SL[σ₁₂] M₂) :\n  (h.comp g).comp f = h.comp (g.comp f) :=\nrfl\n\ninstance : has_mul (M₁ →L[R₁] M₁) := ⟨comp⟩\n\nlemma mul_def (f g : M₁ →L[R₁] M₁) : f * g = f.comp g := rfl\n\n@[simp] lemma coe_mul (f g : M₁ →L[R₁] M₁) : ⇑(f * g) = f ∘ g := rfl\n\nlemma mul_apply (f g : M₁ →L[R₁] M₁) (x : M₁) : (f * g) x = f (g x) := rfl\n\n/-- The cartesian product of two bounded linear maps, as a bounded linear map. -/\nprotected def prod [module R₁ M₂] [module R₁ M₃] (f₁ : M₁ →L[R₁] M₂) (f₂ : M₁ →L[R₁] M₃) :\n  M₁ →L[R₁] (M₂ × M₃) :=\n⟨(f₁ : M₁ →ₗ[R₁] M₂).prod f₂, f₁.2.prod_mk f₂.2⟩\n\n@[simp, norm_cast] lemma coe_prod [module R₁ M₂] [module R₁ M₃] (f₁ : M₁ →L[R₁] M₂)\n  (f₂ : M₁ →L[R₁] M₃) :\n  (f₁.prod f₂ : M₁ →ₗ[R₁] M₂ × M₃) = linear_map.prod f₁ f₂ :=\nrfl\n\n@[simp, norm_cast] lemma prod_apply [module R₁ M₂] [module R₁ M₃] (f₁ : M₁ →L[R₁] M₂)\n  (f₂ : M₁ →L[R₁] M₃) (x : M₁) :\n  f₁.prod f₂ x = (f₁ x, f₂ x) :=\nrfl\n\nsection\n\nvariables (R₁ M₁ M₂)\n\n/-- The left injection into a product is a continuous linear map. -/\ndef inl [module R₁ M₂] : M₁ →L[R₁] M₁ × M₂ := (id R₁ M₁).prod 0\n\n/-- The right injection into a product is a continuous linear map. -/\ndef inr [module R₁ M₂] : M₂ →L[R₁] M₁ × M₂ := (0 : M₂ →L[R₁] M₁).prod (id R₁ M₂)\n\nend\n\n@[simp] lemma inl_apply [module R₁ M₂] (x : M₁) : inl R₁ M₁ M₂ x = (x, 0) := rfl\n@[simp] lemma inr_apply [module R₁ M₂] (x : M₂) : inr R₁ M₁ M₂ x = (0, x) := rfl\n\n@[simp, norm_cast] lemma coe_inl [module R₁ M₂] :\n  (inl R₁ M₁ M₂ : M₁ →ₗ[R₁] M₁ × M₂) = linear_map.inl R₁ M₁ M₂ := rfl\n@[simp, norm_cast] lemma coe_inr [module R₁ M₂] :\n  (inr R₁ M₁ M₂ : M₂ →ₗ[R₁] M₁ × M₂) = linear_map.inr R₁ M₁ M₂ := rfl\n\n/-- Kernel of a continuous linear map. -/\ndef ker (f : M₁ →SL[σ₁₂] M₂) : submodule R₁ M₁ := (f : M₁ →ₛₗ[σ₁₂] M₂).ker\n\n@[norm_cast] lemma ker_coe : (f : M₁ →ₛₗ[σ₁₂] M₂).ker = f.ker := rfl\n\n@[simp] lemma mem_ker {f : M₁ →SL[σ₁₂] M₂} {x} : x ∈ f.ker ↔ f x = 0 := linear_map.mem_ker\n\nlemma is_closed_ker [t1_space M₂] : is_closed (f.ker : set M₁) :=\ncontinuous_iff_is_closed.1 f.cont _ is_closed_singleton\n\n@[simp] lemma apply_ker (x : f.ker) : f x = 0 := mem_ker.1 x.2\n\nlemma is_complete_ker {M' : Type*} [uniform_space M'] [complete_space M'] [add_comm_monoid M']\n  [module R₁ M'] [t1_space M₂] (f : M' →SL[σ₁₂] M₂) :\n  is_complete (f.ker : set M') :=\nf.is_closed_ker.is_complete\n\ninstance complete_space_ker {M' : Type*} [uniform_space M'] [complete_space M'] [add_comm_monoid M']\n  [module R₁ M'] [t1_space M₂] (f : M' →SL[σ₁₂] M₂) :\n  complete_space f.ker :=\nf.is_closed_ker.complete_space_coe\n\n@[simp] lemma ker_prod [module R₁ M₂] [module R₁ M₃] (f : M₁ →L[R₁] M₂) (g : M₁ →L[R₁] M₃) :\n  ker (f.prod g) = ker f ⊓ ker g :=\nlinear_map.ker_prod f g\n\n/-- Range of a continuous linear map. -/\ndef range [ring_hom_surjective σ₁₂] (f : M₁ →SL[σ₁₂] M₂) : submodule R₂ M₂ :=\n(f : M₁ →ₛₗ[σ₁₂] M₂).range\n\nlemma range_coe [ring_hom_surjective σ₁₂] : (f.range : set M₂) = set.range f :=\nlinear_map.range_coe _\nlemma mem_range [ring_hom_surjective σ₁₂] {f : M₁ →SL[σ₁₂] M₂} {y} : y ∈ f.range ↔ ∃ x, f x = y :=\nlinear_map.mem_range\n\nlemma mem_range_self [ring_hom_surjective σ₁₂] (f : M₁ →SL[σ₁₂] M₂) (x : M₁) : f x ∈ f.range :=\nmem_range.2 ⟨x, rfl⟩\n\nlemma range_prod_le [module R₁ M₂] [module R₁ M₃] (f : M₁ →L[R₁] M₂) (g : M₁ →L[R₁] M₃) :\n  range (f.prod g) ≤ (range f).prod (range g) :=\n(f : M₁ →ₗ[R₁] M₂).range_prod_le g\n\n/-- Restrict codomain of a continuous linear map. -/\ndef cod_restrict (f : M₁ →SL[σ₁₂] M₂) (p : submodule R₂ M₂) (h : ∀ x, f x ∈ p) :\n  M₁ →SL[σ₁₂] p :=\n{ cont := continuous_subtype_mk h f.continuous,\n  to_linear_map := (f : M₁ →ₛₗ[σ₁₂] M₂).cod_restrict p h}\n\n@[norm_cast] lemma coe_cod_restrict (f : M₁ →SL[σ₁₂] M₂) (p : submodule R₂ M₂) (h : ∀ x, f x ∈ p) :\n  (f.cod_restrict p h : M₁ →ₛₗ[σ₁₂] p) = (f : M₁ →ₛₗ[σ₁₂] M₂).cod_restrict p h :=\nrfl\n\n@[simp] lemma coe_cod_restrict_apply (f : M₁ →SL[σ₁₂] M₂) (p : submodule R₂ M₂) (h : ∀ x, f x ∈ p)\n  (x) :\n  (f.cod_restrict p h x : M₂) = f x :=\nrfl\n\n@[simp] lemma ker_cod_restrict (f : M₁ →SL[σ₁₂] M₂) (p : submodule R₂ M₂) (h : ∀ x, f x ∈ p) :\n  ker (f.cod_restrict p h) = ker f :=\n(f : M₁ →ₛₗ[σ₁₂] M₂).ker_cod_restrict p h\n\n/-- Embedding of a submodule into the ambient space as a continuous linear map. -/\ndef subtype_val (p : submodule R₁ M₁) : p →L[R₁] M₁ :=\n{ cont := continuous_subtype_val,\n  to_linear_map := p.subtype }\n\n@[simp, norm_cast] lemma coe_subtype_val (p : submodule R₁ M₁) :\n  (subtype_val p : p →ₗ[R₁] M₁) = p.subtype :=\nrfl\n\n@[simp, norm_cast] lemma subtype_val_apply (p : submodule R₁ M₁) (x : p) :\n  (subtype_val p : p → M₁) x = x :=\nrfl\n\nvariables (R₁ M₁ M₂)\n\n/-- `prod.fst` as a `continuous_linear_map`. -/\ndef fst [module R₁ M₂] : M₁ × M₂ →L[R₁] M₁ :=\n{ cont := continuous_fst, to_linear_map := linear_map.fst R₁ M₁ M₂ }\n\n/-- `prod.snd` as a `continuous_linear_map`. -/\ndef snd [module R₁ M₂] : M₁ × M₂ →L[R₁] M₂ :=\n{ cont := continuous_snd, to_linear_map := linear_map.snd R₁ M₁ M₂ }\n\nvariables {R₁ M₁ M₂}\n\n@[simp, norm_cast] lemma coe_fst [module R₁ M₂] :\n  (fst R₁ M₁ M₂ : M₁ × M₂ →ₗ[R₁] M₁) = linear_map.fst R₁ M₁ M₂ := rfl\n\n@[simp, norm_cast] lemma coe_fst' [module R₁ M₂] : (fst R₁ M₁ M₂ : M₁ × M₂ → M₁) = prod.fst := rfl\n\n@[simp, norm_cast] lemma coe_snd [module R₁ M₂] :\n  (snd R₁ M₁ M₂ : M₁ × M₂ →ₗ[R₁] M₂) = linear_map.snd R₁ M₁ M₂ := rfl\n\n@[simp, norm_cast] lemma coe_snd' [module R₁ M₂] : (snd R₁ M₁ M₂ : M₁ × M₂ → M₂) = prod.snd := rfl\n\n@[simp] lemma fst_prod_snd [module R₁ M₂] : (fst R₁ M₁ M₂).prod (snd R₁ M₁ M₂) = id R₁ (M₁ × M₂) :=\n  ext $ λ ⟨x, y⟩, rfl\n\n@[simp] lemma fst_comp_prod [module R₁ M₂] [module R₁ M₃] (f : M₁ →L[R₁] M₂) (g : M₁ →L[R₁] M₃) :\n  (fst R₁ M₂ M₃).comp (f.prod g) = f :=\next $ λ x, rfl\n\n@[simp] lemma snd_comp_prod [module R₁ M₂] [module R₁ M₃] (f : M₁ →L[R₁] M₂) (g : M₁ →L[R₁] M₃) :\n  (snd R₁ M₂ M₃).comp (f.prod g) = g :=\next $ λ x, rfl\n\n/-- `prod.map` of two continuous linear maps. -/\ndef prod_map [module R₁ M₂] [module R₁ M₃] [module R₁ M₄] (f₁ : M₁ →L[R₁] M₂) (f₂ : M₃ →L[R₁] M₄) :\n  (M₁ × M₃) →L[R₁] (M₂ × M₄) :=\n(f₁.comp (fst R₁ M₁ M₃)).prod (f₂.comp (snd R₁ M₁ M₃))\n\n@[simp, norm_cast] lemma coe_prod_map [module R₁ M₂] [module R₁ M₃] [module R₁ M₄]\n  (f₁ : M₁ →L[R₁] M₂) (f₂ : M₃ →L[R₁] M₄) :\n  (f₁.prod_map f₂ : (M₁ × M₃) →ₗ[R₁] (M₂ × M₄))\n  = ((f₁ : M₁ →ₗ[R₁] M₂).prod_map (f₂ : M₃ →ₗ[R₁] M₄)) :=\nrfl\n\n@[simp, norm_cast] lemma coe_prod_map' [module R₁ M₂] [module R₁ M₃] [module R₁ M₄]\n  (f₁ : M₁ →L[R₁] M₂) (f₂ : M₃ →L[R₁] M₄) :\n  ⇑(f₁.prod_map f₂) = prod.map f₁ f₂ :=\nrfl\n\n/-- The continuous linear map given by `(x, y) ↦ f₁ x + f₂ y`. -/\ndef coprod [module R₁ M₂] [module R₁ M₃] [has_continuous_add M₃] (f₁ : M₁ →L[R₁] M₃)\n  (f₂ : M₂ →L[R₁] M₃) :\n  (M₁ × M₂) →L[R₁] M₃ :=\n⟨linear_map.coprod f₁ f₂, (f₁.cont.comp continuous_fst).add (f₂.cont.comp continuous_snd)⟩\n\n@[norm_cast, simp] lemma coe_coprod [module R₁ M₂] [module R₁ M₃] [has_continuous_add M₃]\n  (f₁ : M₁ →L[R₁] M₃) (f₂ : M₂ →L[R₁] M₃) :\n  (f₁.coprod f₂ : (M₁ × M₂) →ₗ[R₁] M₃) = linear_map.coprod f₁ f₂ :=\nrfl\n\n@[simp] lemma coprod_apply [module R₁ M₂] [module R₁ M₃] [has_continuous_add M₃]\n  (f₁ : M₁ →L[R₁] M₃) (f₂ : M₂ →L[R₁] M₃) (x) :\n  f₁.coprod f₂ x = f₁ x.1 + f₂ x.2 := rfl\n\nlemma range_coprod [module R₁ M₂] [module R₁ M₃] [has_continuous_add M₃] (f₁ : M₁ →L[R₁] M₃)\n  (f₂ : M₂ →L[R₁] M₃) :\n  (f₁.coprod f₂).range = f₁.range ⊔ f₂.range :=\nlinear_map.range_coprod _ _\n\nsection\n\nvariables {R S : Type*} [semiring R] [semiring S] [module R M₁] [module R M₂] [module R S]\n  [module S M₂] [is_scalar_tower R S M₂] [topological_space S] [has_continuous_smul S M₂]\n\n/-- The linear map `λ x, c x • f`.  Associates to a scalar-valued linear map and an element of\n`M₂` the `M₂`-valued linear map obtained by multiplying the two (a.k.a. tensoring by `M₂`).\nSee also `continuous_linear_map.smul_rightₗ` and `continuous_linear_map.smul_rightL`. -/\ndef smul_right (c : M₁ →L[R] S) (f : M₂) : M₁ →L[R] M₂ :=\n{ cont := c.2.smul continuous_const,\n  ..c.to_linear_map.smul_right f }\n\n@[simp]\nlemma smul_right_apply {c : M₁ →L[R] S} {f : M₂} {x : M₁} :\n  (smul_right c f : M₁ → M₂) x = c x • f :=\nrfl\n\nend\n\nvariables [module R₁ M₂] [topological_space R₁] [has_continuous_smul R₁ M₂]\n\n@[simp]\nlemma smul_right_one_one (c : R₁ →L[R₁] M₂) : smul_right (1 : R₁ →L[R₁] R₁) (c 1) = c :=\nby ext; simp [← continuous_linear_map.map_smul_of_tower]\n\n@[simp]\nlemma smul_right_one_eq_iff {f f' : M₂} :\n  smul_right (1 : R₁ →L[R₁] R₁) f = smul_right (1 : R₁ →L[R₁] R₁) f' ↔ f = f' :=\nby simp only [ext_ring_iff, smul_right_apply, one_apply, one_smul]\n\nlemma smul_right_comp [has_continuous_mul R₁] {x : M₂} {c : R₁} :\n  (smul_right (1 : R₁ →L[R₁] R₁) x).comp (smul_right (1 : R₁ →L[R₁] R₁) c) =\n    smul_right (1 : R₁ →L[R₁] R₁) (c • x) :=\nby { ext, simp [mul_smul] }\n\nend semiring\n\nsection pi\nvariables\n  {R : Type*} [semiring R]\n  {M : Type*} [topological_space M] [add_comm_monoid M] [module R M]\n  {M₂ : Type*} [topological_space M₂] [add_comm_monoid M₂] [module R M₂]\n  {ι : Type*} {φ : ι → Type*} [∀i, topological_space (φ i)] [∀i, add_comm_monoid (φ i)]\n  [∀i, module R (φ i)]\n\n/-- `pi` construction for continuous linear functions. From a family of continuous linear functions\nit produces a continuous linear function into a family of topological modules. -/\ndef pi (f : Πi, M →L[R] φ i) : M →L[R] (Πi, φ i) :=\n⟨linear_map.pi (λ i, f i), continuous_pi (λ i, (f i).continuous)⟩\n\n@[simp] lemma coe_pi' (f : Π i, M →L[R] φ i) : ⇑(pi f) = λ c i, f i c := rfl\n@[simp] lemma coe_pi (f : Π i, M →L[R] φ i) :\n  (pi f : M →ₗ[R] Π i, φ i) = linear_map.pi (λ i, f i) :=\nrfl\n\nlemma pi_apply (f : Πi, M →L[R] φ i) (c : M) (i : ι) :\n  pi f c i = f i c := rfl\n\nlemma pi_eq_zero (f : Πi, M →L[R] φ i) : pi f = 0 ↔ (∀i, f i = 0) :=\nby { simp only [ext_iff, pi_apply, function.funext_iff], exact forall_swap }\n\nlemma pi_zero : pi (λi, 0 : Πi, M →L[R] φ i) = 0 := ext $ λ _, rfl\n\nlemma pi_comp (f : Πi, M →L[R] φ i) (g : M₂ →L[R] M) : (pi f).comp g = pi (λi, (f i).comp g) := rfl\n\n/-- The projections from a family of topological modules are continuous linear maps. -/\ndef proj (i : ι) : (Πi, φ i) →L[R] φ i :=\n⟨linear_map.proj i, continuous_apply _⟩\n\n@[simp] lemma proj_apply (i : ι) (b : Πi, φ i) : (proj i : (Πi, φ i) →L[R] φ i) b = b i := rfl\n\nlemma proj_pi (f : Πi, M₂ →L[R] φ i) (i : ι) : (proj i).comp (pi f) = f i :=\next $ assume c, rfl\n\nlemma infi_ker_proj : (⨅i, ker (proj i) : submodule R (Πi, φ i)) = ⊥ :=\nlinear_map.infi_ker_proj\n\nvariables (R φ)\n\n/-- If `I` and `J` are complementary index sets, the product of the kernels of the `J`th projections\nof `φ` is linearly equivalent to the product over `I`. -/\ndef infi_ker_proj_equiv {I J : set ι} [decidable_pred (λi, i ∈ I)]\n  (hd : disjoint I J) (hu : set.univ ⊆ I ∪ J) :\n  (⨅i ∈ J, ker (proj i) : submodule R (Πi, φ i)) ≃L[R] (Πi:I, φ i) :=\n⟨ linear_map.infi_ker_proj_equiv R φ hd hu,\n  continuous_pi (λ i, begin\n    have := @continuous_subtype_coe _ _ (λ x, x ∈ (⨅i ∈ J, ker (proj i) : submodule R (Πi, φ i))),\n    have := continuous.comp (by exact continuous_apply i) this,\n    exact this\n  end),\n  continuous_subtype_mk _ (continuous_pi (λ i, begin\n    dsimp, split_ifs; [apply continuous_apply, exact continuous_zero]\n  end)) ⟩\n\nend pi\n\nsection ring\n\nvariables\n{R : Type*} [ring R] {R₂ : Type*} [ring R₂]\n{M : Type*} [topological_space M] [add_comm_group M]\n{M₂ : Type*} [topological_space M₂] [add_comm_group M₂]\n{M₃ : Type*} [topological_space M₃] [add_comm_group M₃]\n{M₄ : Type*} [topological_space M₄] [add_comm_group M₄]\n[module R M] [module R₂ M₂]\n{σ₁₂ : R →+* R₂}\n\nsection\nvariables (f g : M →SL[σ₁₂] M₂) (x y : M)\n\n@[simp] lemma map_neg  : f (-x) = - (f x) := (to_linear_map _).map_neg _\n@[simp] lemma map_sub  : f (x - y) = f x - f y := (to_linear_map _).map_sub _ _\n@[simp] lemma sub_apply' (x : M) : ((f : M →ₛₗ[σ₁₂] M₂) - g) x = f x - g x := rfl\nend\n\nsection\nvariables [module R M₂] [module R M₃] [module R M₄]\nvariables (c : R) (f g : M →L[R] M₂) (h : M₂ →L[R] M₃) (x y z : M)\n\nlemma range_prod_eq  {f : M →L[R] M₂} {g : M →L[R] M₃} (h : ker f ⊔ ker g = ⊤) :\n  range (f.prod g) = (range f).prod (range g) :=\nlinear_map.range_prod_eq h\n\nlemma ker_prod_ker_le_ker_coprod [has_continuous_add M₃]\n  (f : M →L[R] M₃) (g : M₂ →L[R] M₃) :\n  (ker f).prod (ker g) ≤ ker (f.coprod g) :=\nlinear_map.ker_prod_ker_le_ker_coprod f.to_linear_map g.to_linear_map\n\nlemma ker_coprod_of_disjoint_range [has_continuous_add M₃]\n  (f : M →L[R] M₃) (g : M₂ →L[R] M₃) (hd : disjoint f.range g.range) :\n  ker (f.coprod g) = (ker f).prod (ker g) :=\nlinear_map.ker_coprod_of_disjoint_range f.to_linear_map g.to_linear_map hd\nend\n\nsection\nvariables [topological_add_group M₂]\nvariables (f g : M →SL[σ₁₂] M₂) (x y : M)\n\ninstance : has_neg (M →SL[σ₁₂] M₂) := ⟨λ f, ⟨-f, f.2.neg⟩⟩\n\n@[simp] lemma neg_apply : (-f) x = - (f x) := rfl\n\n@[simp, norm_cast] lemma coe_neg :\n  (((-f) : M →SL[σ₁₂] M₂) : M →ₛₗ[σ₁₂] M₂) = -(f : M →ₛₗ[σ₁₂] M₂) :=\nrfl\n@[norm_cast] lemma coe_neg' : (((-f) : M →SL[σ₁₂] M₂) : M → M₂) = -(f : M → M₂) := rfl\n\ninstance : has_sub (M →SL[σ₁₂] M₂) := ⟨λ f g, ⟨f - g, f.2.sub g.2⟩⟩\n\nlemma continuous_zsmul : ∀ (n : ℤ), continuous (λ (x : M₂), n • x)\n| (n : ℕ) := by { simp only [coe_nat_zsmul], exact continuous_nsmul _ }\n| -[1+ n] := by { simp only [zsmul_neg_succ_of_nat], exact (continuous_nsmul _).neg }\n\n@[continuity]\nlemma continuous.zsmul {α : Type*} [topological_space α] {n : ℤ} {f : α → M₂} (hf : continuous f) :\n  continuous (λ (x : α), n • (f x)) :=\n(continuous_zsmul n).comp hf\n\ninstance : add_comm_group (M →SL[σ₁₂] M₂) :=\nby refine\n{ zero := 0,\n  add := (+),\n  neg := has_neg.neg,\n  sub := has_sub.sub,\n  sub_eq_add_neg := _,\n  nsmul := λ n f,\n    { to_fun := λ x, n • (f x),\n      map_add' := by simp,\n      map_smul' := by simp [smul_comm n] },\n  zsmul := λ n f,\n    { to_fun := λ x, n • (f x),\n      map_add' := by simp,\n      map_smul' := by simp [smul_comm n] },\n  zsmul_zero' := λ f, by { ext, simp },\n  zsmul_succ' := λ n f, by { ext, simp [add_smul, add_comm] },\n  zsmul_neg' := λ n f, by { ext, simp [nat.succ_eq_add_one, add_smul] },\n  .. continuous_linear_map.add_comm_monoid, .. };\nintros; ext; apply_rules [zero_add, add_assoc, add_zero, add_left_neg, add_comm, sub_eq_add_neg]\n\nlemma sub_apply (x : M) : (f - g) x = f x - g x := rfl\n@[simp, norm_cast] lemma coe_sub : (((f - g) : M →SL[σ₁₂] M₂) : M →ₛₗ[σ₁₂] M₂) = f - g := rfl\n@[simp, norm_cast] lemma coe_sub' : (((f - g) : M →SL[σ₁₂] M₂) : M → M₂) = (f : M → M₂) - g := rfl\n\nend\n\ninstance [topological_add_group M] : ring (M →L[R] M) :=\n{ mul := (*),\n  one := 1,\n  mul_one := λ _, ext $ λ _, rfl,\n  one_mul := λ _, ext $ λ _, rfl,\n  mul_assoc := λ _ _ _, ext $ λ _, rfl,\n  left_distrib := λ _ _ _, ext $ λ _, map_add _ _ _,\n  right_distrib := λ _ _ _, ext $ λ _, linear_map.add_apply _ _ _,\n  ..continuous_linear_map.add_comm_group }\n\nlemma smul_right_one_pow [topological_space R] [topological_ring R] (c : R) (n : ℕ) :\n  (smul_right (1 : R →L[R] R) c)^n = smul_right (1 : R →L[R] R) (c^n) :=\nbegin\n  induction n with n ihn,\n  { ext, simp },\n  { rw [pow_succ, ihn, mul_def, smul_right_comp, smul_eq_mul, pow_succ'] }\nend\n\nsection\nvariables {σ₂₁ : R₂ →+* R} [ring_hom_inv_pair σ₁₂ σ₂₁]\n\n/-- Given a right inverse `f₂ : M₂ →L[R] M` to `f₁ : M →L[R] M₂`,\n`proj_ker_of_right_inverse f₁ f₂ h` is the projection `M →L[R] f₁.ker` along `f₂.range`. -/\ndef proj_ker_of_right_inverse [topological_add_group M] (f₁ : M →SL[σ₁₂] M₂) (f₂ : M₂ →SL[σ₂₁] M)\n  (h : function.right_inverse f₂ f₁) :\n  M →L[R] f₁.ker :=\n(id R M - f₂.comp f₁).cod_restrict f₁.ker $ λ x, by simp [h (f₁ x)]\n\n@[simp] lemma coe_proj_ker_of_right_inverse_apply [topological_add_group M]\n  (f₁ : M →SL[σ₁₂] M₂) (f₂ : M₂ →SL[σ₂₁] M) (h : function.right_inverse f₂ f₁) (x : M) :\n  (f₁.proj_ker_of_right_inverse f₂ h x : M) = x - f₂ (f₁ x) :=\nrfl\n\n@[simp] lemma proj_ker_of_right_inverse_apply_idem [topological_add_group M]\n  (f₁ : M →SL[σ₁₂] M₂) (f₂ : M₂ →SL[σ₂₁] M) (h : function.right_inverse f₂ f₁) (x : f₁.ker) :\n  f₁.proj_ker_of_right_inverse f₂ h x = x :=\nsubtype.ext_iff_val.2 $ by simp\n\n@[simp] lemma proj_ker_of_right_inverse_comp_inv [topological_add_group M]\n  (f₁ : M →SL[σ₁₂] M₂) (f₂ : M₂ →SL[σ₂₁] M) (h : function.right_inverse f₂ f₁) (y : M₂) :\n  f₁.proj_ker_of_right_inverse f₂ h (f₂ y) = 0 :=\nsubtype.ext_iff_val.2 $ by simp [h y]\n\nend\n\nend ring\n\nsection smul_monoid\n\nvariables {R S : Type*} [semiring R] [monoid S] [topological_space S]\n  {M : Type*} [topological_space M] [add_comm_monoid M] [module R M]\n  {M₂ : Type*} [topological_space M₂] [add_comm_monoid M₂] [module R M₂]\n  {M₃ : Type*} [topological_space M₃] [add_comm_monoid M₃] [module R M₃]\n  [distrib_mul_action S M₃] [smul_comm_class R S M₃] [has_continuous_smul S M₃]\n\ninstance : mul_action S (M →L[R] M₃) :=\n{ smul := λ c f, ⟨c • f, (continuous_const.smul f.2 : continuous (λ x, c • f x))⟩,\n  one_smul := λ f, ext $ λ x, one_smul _ _,\n  mul_smul := λ a b f, ext $ λ x, mul_smul _ _ _ }\n\nvariables (c : S) (h : M₂ →L[R] M₃) (f g : M →L[R] M₂) (x y z : M)\n\n@[simp] lemma smul_comp : (c • h).comp f = c • (h.comp f) := rfl\n\nvariables [distrib_mul_action S M₂] [has_continuous_smul S M₂] [smul_comm_class R S M₂]\n\nlemma smul_apply : (c • f) x = c • (f x) := rfl\n@[simp, norm_cast] lemma coe_smul : (((c • f) : M →L[R] M₂) : M →ₗ[R] M₂) = c • f := rfl\n@[simp, norm_cast] lemma coe_smul' : (((c • f) : M →L[R] M₂) : M → M₂) = c • f := rfl\n\n@[simp] lemma comp_smul [linear_map.compatible_smul M₂ M₃ S R] : h.comp (c • f) = c • (h.comp f) :=\nby { ext x, exact h.map_smul_of_tower c (f x) }\n\ninstance {T : Type*} [monoid T] [topological_space T] [distrib_mul_action T M₂]\n  [has_continuous_smul T M₂] [smul_comm_class R T M₂] [has_scalar S T]\n  [is_scalar_tower S T M₂] : is_scalar_tower S T (M →L[R] M₂) :=\n⟨λ a b f, ext $ λ x, smul_assoc a b (f x)⟩\n\ninstance {T : Type*} [monoid T] [topological_space T] [distrib_mul_action T M₂]\n  [has_continuous_smul T M₂] [smul_comm_class R T M₂] [smul_comm_class S T M₂] :\n  smul_comm_class S T (M →L[R] M₂) :=\n⟨λ a b f, ext $ λ x, smul_comm a b (f x)⟩\n\ninstance [has_continuous_add M₂] : distrib_mul_action S (M →L[R] M₂) :=\n{ smul_add := λ a f g, ext $ λ x, smul_add a (f x) (g x),\n  smul_zero := λ a, ext $ λ x, smul_zero _ }\n\nend smul_monoid\n\nsection smul\n\nvariables {R S : Type*} [semiring R] [semiring S] [topological_space S]\n  {M : Type*} [topological_space M] [add_comm_monoid M] [module R M]\n  {M₂ : Type*} [topological_space M₂] [add_comm_monoid M₂] [module R M₂]\n  {M₃ : Type*} [topological_space M₃] [add_comm_monoid M₃] [module R M₃]\n  [module S M₃] [has_continuous_smul S M₃] [smul_comm_class R S M₃]\n  [module S M₂] [has_continuous_smul S M₂] [smul_comm_class R S M₂]\n  (c : S) (h : M₂ →L[R] M₃) (f g : M →L[R] M₂) (x y z : M)\n\n/-- `continuous_linear_map.prod` as an `equiv`. -/\n@[simps apply] def prod_equiv : ((M →L[R] M₂) × (M →L[R] M₃)) ≃ (M →L[R] M₂ × M₃) :=\n{ to_fun := λ f, f.1.prod f.2,\n  inv_fun := λ f, ⟨(fst _ _ _).comp f, (snd _ _ _).comp f⟩,\n  left_inv := λ f, by ext; refl,\n  right_inv := λ f, by ext; refl }\n\nlemma prod_ext_iff {f g : M × M₂ →L[R] M₃} :\n  f = g ↔ f.comp (inl _ _ _) = g.comp (inl _ _ _) ∧ f.comp (inr _ _ _) = g.comp (inr _ _ _) :=\nby { simp only [← coe_inj, linear_map.prod_ext_iff], refl }\n\n@[ext] lemma prod_ext {f g : M × M₂ →L[R] M₃} (hl : f.comp (inl _ _ _) = g.comp (inl _ _ _))\n  (hr : f.comp (inr _ _ _) = g.comp (inr _ _ _)) : f = g :=\nprod_ext_iff.2 ⟨hl, hr⟩\n\nvariables [has_continuous_add M₂]\n\ninstance : module S (M →L[R] M₂) :=\n{ zero_smul := λ _, ext $ λ _, zero_smul _ _,\n  add_smul  := λ _ _ _, ext $ λ _, add_smul _ _ _, }\n\nvariables (S) [has_continuous_add M₃]\n\n/-- `continuous_linear_map.prod` as a `linear_equiv`. -/\n@[simps apply] def prodₗ : ((M →L[R] M₂) × (M →L[R] M₃)) ≃ₗ[S] (M →L[R] M₂ × M₃) :=\n{ map_add' := λ f g, rfl,\n  map_smul' := λ c f, rfl,\n  .. prod_equiv }\n\n/-- The coercion from `M →L[R] M₂` to `M →ₗ[R] M₂`, as a linear map. -/\n@[simps]\ndef coe_lm : (M →L[R] M₂) →ₗ[S] (M →ₗ[R] M₂) :=\n{ to_fun := coe,\n  map_add' := λ f g, coe_add f g,\n  map_smul' := λ c f, coe_smul c f }\n\nend smul\n\nsection smul_rightₗ\n\nvariables {R S T M M₂ : Type*} [ring R] [ring S] [ring T] [module R S]\n  [add_comm_group M₂] [module R M₂] [module S M₂] [is_scalar_tower R S M₂]\n  [topological_space S] [topological_space M₂] [has_continuous_smul S M₂]\n  [topological_space M] [add_comm_group M] [module R M] [topological_add_group M₂]\n  [topological_space T] [module T M₂] [has_continuous_smul T M₂]\n  [smul_comm_class R T M₂] [smul_comm_class S T M₂]\n\n/-- Given `c : E →L[𝕜] 𝕜`, `c.smul_rightₗ` is the linear map from `F` to `E →L[𝕜] F`\nsending `f` to `λ e, c e • f`. See also `continuous_linear_map.smul_rightL`. -/\ndef smul_rightₗ (c : M →L[R] S) : M₂ →ₗ[T] (M →L[R] M₂) :=\n{ to_fun := c.smul_right,\n  map_add' := λ x y, by { ext e, apply smul_add },\n  map_smul' := λ a x, by { ext e, dsimp, apply smul_comm } }\n\n@[simp] lemma coe_smul_rightₗ (c : M →L[R] S) :\n  ⇑(smul_rightₗ c : M₂ →ₗ[T] (M →L[R] M₂)) = c.smul_right := rfl\n\nend smul_rightₗ\n\nsection comm_ring\n\nvariables\n{R : Type*} [comm_ring R] [topological_space R]\n{M : Type*} [topological_space M] [add_comm_group M]\n{M₂ : Type*} [topological_space M₂] [add_comm_group M₂]\n{M₃ : Type*} [topological_space M₃] [add_comm_group M₃]\n[module R M] [module R M₂] [module R M₃] [has_continuous_smul R M₃]\n\nvariables [topological_add_group M₂] [has_continuous_smul R M₂]\n\ninstance : algebra R (M₂ →L[R] M₂) :=\nalgebra.of_module smul_comp (λ _ _ _, comp_smul _ _ _)\n\nend comm_ring\n\nsection restrict_scalars\n\nvariables {A M M₂ : Type*} [ring A] [add_comm_group M] [add_comm_group M₂]\n  [module A M] [module A M₂] [topological_space M] [topological_space M₂]\n  (R : Type*) [ring R] [module R M] [module R M₂] [linear_map.compatible_smul M M₂ R A]\n\n/-- If `A` is an `R`-algebra, then a continuous `A`-linear map can be interpreted as a continuous\n`R`-linear map. We assume `linear_map.compatible_smul M M₂ R A` to match assumptions of\n`linear_map.map_smul_of_tower`. -/\ndef restrict_scalars (f : M →L[A] M₂) : M →L[R] M₂ :=\n⟨(f : M →ₗ[A] M₂).restrict_scalars R, f.continuous⟩\n\nvariable {R}\n\n@[simp, norm_cast] lemma coe_restrict_scalars (f : M →L[A] M₂) :\n  (f.restrict_scalars R : M →ₗ[R] M₂) = (f : M →ₗ[A] M₂).restrict_scalars R := rfl\n\n@[simp] lemma coe_restrict_scalars' (f : M →L[A] M₂) : ⇑(f.restrict_scalars R) = f := rfl\n\n@[simp] lemma restrict_scalars_zero : (0 : M →L[A] M₂).restrict_scalars R = 0 := rfl\n\nsection\nvariable [topological_add_group M₂]\n\n@[simp] lemma restrict_scalars_add (f g : M →L[A] M₂) :\n  (f + g).restrict_scalars R = f.restrict_scalars R + g.restrict_scalars R := rfl\n\n@[simp] lemma restrict_scalars_neg (f : M →L[A] M₂) :\n  (-f).restrict_scalars R = -f.restrict_scalars R := rfl\nend\n\nvariables {S : Type*} [ring S] [topological_space S] [module S M₂] [has_continuous_smul S M₂]\n  [smul_comm_class A S M₂] [smul_comm_class R S M₂]\n\n@[simp] lemma restrict_scalars_smul (c : S) (f : M →L[A] M₂) :\n  (c • f).restrict_scalars R = c • f.restrict_scalars R := rfl\n\nvariables (A M M₂ R S) [topological_add_group M₂]\n\n/-- `continuous_linear_map.restrict_scalars` as a `linear_map`. See also\n`continuous_linear_map.restrict_scalarsL`. -/\ndef restrict_scalarsₗ : (M →L[A] M₂) →ₗ[S] (M →L[R] M₂) :=\n{ to_fun := restrict_scalars R,\n  map_add' := restrict_scalars_add,\n  map_smul' := restrict_scalars_smul }\n\nvariables {A M M₂ R S}\n\n@[simp] lemma coe_restrict_scalarsₗ : ⇑(restrict_scalarsₗ A M M₂ R S) = restrict_scalars R := rfl\n\nend restrict_scalars\n\nend continuous_linear_map\n\nnamespace continuous_linear_equiv\n\nsection add_comm_monoid\n\nvariables {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} [semiring R₁] [semiring R₂] [semiring R₃]\n{σ₁₂ : R₁ →+* R₂} {σ₂₁ : R₂ →+* R₁} [ring_hom_inv_pair σ₁₂ σ₂₁] [ring_hom_inv_pair σ₂₁ σ₁₂]\n{σ₂₃ : R₂ →+* R₃} {σ₃₂ : R₃ →+* R₂} [ring_hom_inv_pair σ₂₃ σ₃₂] [ring_hom_inv_pair σ₃₂ σ₂₃]\n{σ₁₃ : R₁ →+* R₃} {σ₃₁ : R₃ →+* R₁} [ring_hom_inv_pair σ₁₃ σ₃₁] [ring_hom_inv_pair σ₃₁ σ₁₃]\n[ring_hom_comp_triple σ₁₂ σ₂₃ σ₁₃] [ring_hom_comp_triple σ₃₂ σ₂₁ σ₃₁]\n{M₁ : Type*} [topological_space M₁] [add_comm_monoid M₁]\n{M₂ : Type*} [topological_space M₂] [add_comm_monoid M₂]\n{M₃ : Type*} [topological_space M₃] [add_comm_monoid M₃]\n{M₄ : Type*} [topological_space M₄] [add_comm_monoid M₄]\n[module R₁ M₁] [module R₂ M₂] [module R₃ M₃]\n\ninclude σ₂₁\n/-- A continuous linear equivalence induces a continuous linear map. -/\ndef to_continuous_linear_map (e : M₁ ≃SL[σ₁₂] M₂) : M₁ →SL[σ₁₂] M₂ :=\n{ cont := e.continuous_to_fun,\n  ..e.to_linear_equiv.to_linear_map }\n\n/-- Coerce continuous linear equivs to continuous linear maps. -/\ninstance : has_coe (M₁ ≃SL[σ₁₂] M₂) (M₁ →SL[σ₁₂] M₂) := ⟨to_continuous_linear_map⟩\n\n/-- Coerce continuous linear equivs to maps. -/\n-- see Note [function coercion]\ninstance : has_coe_to_fun (M₁ ≃SL[σ₁₂] M₂) (λ _, M₁ → M₂) := ⟨λ f, f⟩\n\n@[simp] theorem coe_def_rev (e : M₁ ≃SL[σ₁₂] M₂) : e.to_continuous_linear_map = e := rfl\n\ntheorem coe_apply (e : M₁ ≃SL[σ₁₂] M₂) (b : M₁) : (e : M₁ →SL[σ₁₂] M₂) b = e b := rfl\n\n@[simp] lemma coe_to_linear_equiv (f : M₁ ≃SL[σ₁₂] M₂) : ⇑f.to_linear_equiv = f := rfl\n\n@[simp, norm_cast] lemma coe_coe (e : M₁ ≃SL[σ₁₂] M₂) : ((e : M₁ →SL[σ₁₂] M₂) : M₁ → M₂) = e := rfl\n\nlemma to_linear_equiv_injective :\n  function.injective (to_linear_equiv : (M₁ ≃SL[σ₁₂] M₂) → (M₁ ≃ₛₗ[σ₁₂] M₂))\n| ⟨e, _, _⟩ ⟨e', _, _⟩ rfl := rfl\n\n@[ext] lemma ext {f g : M₁ ≃SL[σ₁₂] M₂} (h : (f : M₁ → M₂) = g) : f = g :=\nto_linear_equiv_injective $ linear_equiv.ext $ congr_fun h\n\nlemma coe_injective : function.injective (coe : (M₁ ≃SL[σ₁₂] M₂) → (M₁ →SL[σ₁₂] M₂)) :=\nλ e e' h, ext $ funext $ continuous_linear_map.ext_iff.1 h\n\n@[simp, norm_cast] lemma coe_inj {e e' : M₁ ≃SL[σ₁₂] M₂} : (e : M₁ →SL[σ₁₂] M₂) = e' ↔ e = e' :=\ncoe_injective.eq_iff\n\n/-- A continuous linear equivalence induces a homeomorphism. -/\ndef to_homeomorph (e : M₁ ≃SL[σ₁₂] M₂) : M₁ ≃ₜ M₂ := { to_equiv := e.to_linear_equiv.to_equiv, ..e }\n\n@[simp] lemma coe_to_homeomorph (e : M₁ ≃SL[σ₁₂] M₂) : ⇑e.to_homeomorph = e := rfl\n\nlemma image_closure (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₁) : e '' closure s = closure (e '' s) :=\ne.to_homeomorph.image_closure s\n\nlemma preimage_closure (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₂) : e ⁻¹' closure s = closure (e ⁻¹' s) :=\ne.to_homeomorph.preimage_closure s\n\n@[simp] lemma is_closed_image (e : M₁ ≃SL[σ₁₂] M₂) {s : set M₁} :\n  is_closed (e '' s) ↔ is_closed s :=\ne.to_homeomorph.is_closed_image\n\nlemma map_nhds_eq (e : M₁ ≃SL[σ₁₂] M₂) (x : M₁) : map e (𝓝 x) = 𝓝 (e x) :=\ne.to_homeomorph.map_nhds_eq x\n\n-- Make some straightforward lemmas available to `simp`.\n@[simp] lemma map_zero (e : M₁ ≃SL[σ₁₂] M₂) : e (0 : M₁) = 0 := (e : M₁ →SL[σ₁₂] M₂).map_zero\n@[simp] lemma map_add (e : M₁ ≃SL[σ₁₂] M₂) (x y : M₁) : e (x + y) = e x + e y :=\n(e : M₁ →SL[σ₁₂] M₂).map_add x y\n@[simp] lemma map_smulₛₗ (e : M₁ ≃SL[σ₁₂] M₂) (c : R₁) (x : M₁) : e (c • x) = σ₁₂ c • (e x) :=\n(e : M₁ →SL[σ₁₂] M₂).map_smulₛₗ c x\nomit σ₂₁\n\n@[simp] lemma map_smul [module R₁ M₂] (e : M₁ ≃L[R₁] M₂) (c : R₁) (x : M₁) :\n  e (c • x) = c • (e x) :=\n(e : M₁ →L[R₁] M₂).map_smul c x\n\ninclude σ₂₁\n@[simp] lemma map_eq_zero_iff (e : M₁ ≃SL[σ₁₂] M₂) {x : M₁} : e x = 0 ↔ x = 0 :=\ne.to_linear_equiv.map_eq_zero_iff\n\nattribute [continuity]\n  continuous_linear_equiv.continuous_to_fun continuous_linear_equiv.continuous_inv_fun\n\n@[continuity]\nprotected lemma continuous (e : M₁ ≃SL[σ₁₂] M₂) : continuous (e : M₁ → M₂) :=\ne.continuous_to_fun\n\nprotected lemma continuous_on (e : M₁ ≃SL[σ₁₂] M₂) {s : set M₁} : continuous_on (e : M₁ → M₂) s :=\ne.continuous.continuous_on\n\nprotected lemma continuous_at (e : M₁ ≃SL[σ₁₂] M₂) {x : M₁} : continuous_at (e : M₁ → M₂) x :=\ne.continuous.continuous_at\n\nprotected lemma continuous_within_at (e : M₁ ≃SL[σ₁₂] M₂) {s : set M₁} {x : M₁} :\n  continuous_within_at (e : M₁ → M₂) s x :=\ne.continuous.continuous_within_at\n\nlemma comp_continuous_on_iff\n  {α : Type*} [topological_space α] (e : M₁ ≃SL[σ₁₂] M₂) {f : α → M₁} {s : set α} :\n  continuous_on (e ∘ f) s ↔ continuous_on f s :=\ne.to_homeomorph.comp_continuous_on_iff _ _\n\nlemma comp_continuous_iff\n  {α : Type*} [topological_space α] (e : M₁ ≃SL[σ₁₂] M₂) {f : α → M₁} :\n  continuous (e ∘ f) ↔ continuous f :=\ne.to_homeomorph.comp_continuous_iff\nomit σ₂₁\n\n/-- An extensionality lemma for `R ≃L[R] M`. -/\nlemma ext₁ [topological_space R₁] {f g : R₁ ≃L[R₁] M₁} (h : f 1 = g 1) : f = g :=\next $ funext $ λ x, mul_one x ▸ by rw [← smul_eq_mul, map_smul, h, map_smul]\n\nsection\nvariables (R₁ M₁)\n\n/-- The identity map as a continuous linear equivalence. -/\n@[refl] protected def refl : M₁ ≃L[R₁] M₁ :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  .. linear_equiv.refl R₁ M₁ }\nend\n\n@[simp, norm_cast] lemma coe_refl :\n  (continuous_linear_equiv.refl R₁ M₁ : M₁ →L[R₁] M₁) = continuous_linear_map.id R₁ M₁ := rfl\n\n@[simp, norm_cast] lemma coe_refl' :\n  (continuous_linear_equiv.refl R₁ M₁ : M₁ → M₁) = id := rfl\n\n/-- The inverse of a continuous linear equivalence as a continuous linear equivalence-/\n@[symm] protected def symm (e : M₁ ≃SL[σ₁₂] M₂) : M₂ ≃SL[σ₂₁] M₁ :=\n{ continuous_to_fun := e.continuous_inv_fun,\n  continuous_inv_fun := e.continuous_to_fun,\n  .. e.to_linear_equiv.symm }\n\ninclude σ₂₁\n@[simp] lemma symm_to_linear_equiv (e : M₁ ≃SL[σ₁₂] M₂) :\n  e.symm.to_linear_equiv = e.to_linear_equiv.symm :=\nby { ext, refl }\n\n@[simp] lemma symm_to_homeomorph (e : M₁ ≃SL[σ₁₂] M₂) :\n  e.to_homeomorph.symm = e.symm.to_homeomorph :=\nrfl\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : M₁ ≃SL[σ₁₂] M₂) : M₁ → M₂ := h\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : M₁ ≃SL[σ₁₂] M₂) : M₂ → M₁ := h.symm\n\ninitialize_simps_projections continuous_linear_equiv\n  (to_linear_equiv_to_fun → apply, to_linear_equiv_inv_fun → symm_apply)\n\nlemma symm_map_nhds_eq (e : M₁ ≃SL[σ₁₂] M₂) (x : M₁) : map e.symm (𝓝 (e x)) = 𝓝 x :=\ne.to_homeomorph.symm_map_nhds_eq x\nomit σ₂₁\n\ninclude σ₂₁ σ₃₂ σ₃₁\n/-- The composition of two continuous linear equivalences as a continuous linear equivalence. -/\n@[trans] protected def trans (e₁ : M₁ ≃SL[σ₁₂] M₂) (e₂ : M₂ ≃SL[σ₂₃] M₃) : M₁ ≃SL[σ₁₃] M₃ :=\n{ continuous_to_fun := e₂.continuous_to_fun.comp e₁.continuous_to_fun,\n  continuous_inv_fun := e₁.continuous_inv_fun.comp e₂.continuous_inv_fun,\n  .. e₁.to_linear_equiv.trans e₂.to_linear_equiv }\n\ninclude σ₁₃\n@[simp] lemma trans_to_linear_equiv (e₁ : M₁ ≃SL[σ₁₂] M₂) (e₂ : M₂ ≃SL[σ₂₃] M₃) :\n  (e₁.trans e₂).to_linear_equiv = e₁.to_linear_equiv.trans e₂.to_linear_equiv :=\nby { ext, refl }\nomit σ₁₃ σ₂₁ σ₃₂ σ₃₁\n\n/-- Product of two continuous linear equivalences. The map comes from `equiv.prod_congr`. -/\ndef prod [module R₁ M₂] [module R₁ M₃] [module R₁ M₄] (e : M₁ ≃L[R₁] M₂) (e' : M₃ ≃L[R₁] M₄) :\n  (M₁ × M₃) ≃L[R₁] (M₂ × M₄) :=\n{ continuous_to_fun := e.continuous_to_fun.prod_map e'.continuous_to_fun,\n  continuous_inv_fun := e.continuous_inv_fun.prod_map e'.continuous_inv_fun,\n  .. e.to_linear_equiv.prod e'.to_linear_equiv }\n\n@[simp, norm_cast] lemma prod_apply [module R₁ M₂] [module R₁ M₃] [module R₁ M₄] (e : M₁ ≃L[R₁] M₂)\n  (e' : M₃ ≃L[R₁] M₄) (x) :\n  e.prod e' x = (e x.1, e' x.2) := rfl\n\n@[simp, norm_cast] lemma coe_prod [module R₁ M₂] [module R₁ M₃] [module R₁ M₄] (e : M₁ ≃L[R₁] M₂)\n  (e' : M₃ ≃L[R₁] M₄) :\n  (e.prod e' : (M₁ × M₃) →L[R₁] (M₂ × M₄)) = (e : M₁ →L[R₁] M₂).prod_map (e' : M₃ →L[R₁] M₄) :=\nrfl\n\ninclude σ₂₁\ntheorem bijective (e : M₁ ≃SL[σ₁₂] M₂) : function.bijective e :=\ne.to_linear_equiv.to_equiv.bijective\ntheorem injective (e : M₁ ≃SL[σ₁₂] M₂) : function.injective e :=\ne.to_linear_equiv.to_equiv.injective\ntheorem surjective (e : M₁ ≃SL[σ₁₂] M₂) : function.surjective e :=\ne.to_linear_equiv.to_equiv.surjective\n\ninclude σ₃₂ σ₃₁ σ₁₃\n@[simp] theorem trans_apply (e₁ : M₁ ≃SL[σ₁₂] M₂) (e₂ : M₂ ≃SL[σ₂₃] M₃) (c : M₁) :\n  (e₁.trans e₂) c = e₂ (e₁ c) :=\nrfl\nomit σ₃₂ σ₃₁ σ₁₃\n\n@[simp] theorem apply_symm_apply (e : M₁ ≃SL[σ₁₂] M₂) (c : M₂) : e (e.symm c) = c :=\ne.1.right_inv c\n@[simp] theorem symm_apply_apply (e : M₁ ≃SL[σ₁₂] M₂) (b : M₁) : e.symm (e b) = b := e.1.left_inv b\n\ninclude σ₁₂ σ₂₃ σ₁₃ σ₃₁\n@[simp] theorem symm_trans_apply (e₁ : M₂ ≃SL[σ₂₁] M₁) (e₂ : M₃ ≃SL[σ₃₂] M₂) (c : M₁) :\n  (e₂.trans e₁).symm c = e₂.symm (e₁.symm c) :=\nrfl\nomit σ₁₂ σ₂₃ σ₁₃ σ₃₁\n\n@[simp] theorem symm_image_image (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₁) : e.symm '' (e '' s) = s :=\ne.to_linear_equiv.to_equiv.symm_image_image s\n@[simp] theorem image_symm_image (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₂) : e '' (e.symm '' s) = s :=\ne.symm.symm_image_image s\n\ninclude σ₃₂ σ₃₁\n@[simp, norm_cast]\nlemma comp_coe (f : M₁ ≃SL[σ₁₂] M₂) (f' : M₂ ≃SL[σ₂₃] M₃) :\n  (f' : M₂ →SL[σ₂₃] M₃).comp (f : M₁ →SL[σ₁₂] M₂) = (f.trans f' : M₁ →SL[σ₁₃] M₃) :=\nrfl\nomit σ₃₂ σ₃₁ σ₂₁\n\n@[simp] theorem coe_comp_coe_symm (e : M₁ ≃SL[σ₁₂] M₂) :\n  (e : M₁ →SL[σ₁₂] M₂).comp (e.symm : M₂ →SL[σ₂₁] M₁) = continuous_linear_map.id R₂ M₂ :=\ncontinuous_linear_map.ext e.apply_symm_apply\n\n@[simp] theorem coe_symm_comp_coe (e : M₁ ≃SL[σ₁₂] M₂) :\n  (e.symm : M₂ →SL[σ₂₁] M₁).comp (e : M₁ →SL[σ₁₂] M₂) = continuous_linear_map.id R₁ M₁ :=\ncontinuous_linear_map.ext e.symm_apply_apply\n\ninclude σ₂₁\n@[simp] lemma symm_comp_self (e : M₁ ≃SL[σ₁₂] M₂) :\n  (e.symm : M₂ → M₁) ∘ (e : M₁ → M₂) = id :=\nby{ ext x, exact symm_apply_apply e x }\n\n@[simp] lemma self_comp_symm (e : M₁ ≃SL[σ₁₂] M₂) :\n  (e : M₁ → M₂) ∘ (e.symm : M₂ → M₁) = id :=\nby{ ext x, exact apply_symm_apply e x }\n\n@[simp] theorem symm_symm (e : M₁ ≃SL[σ₁₂] M₂) : e.symm.symm = e :=\nby { ext x, refl }\nomit σ₂₁\n\n@[simp] lemma refl_symm :\n (continuous_linear_equiv.refl R₁ M₁).symm = continuous_linear_equiv.refl R₁ M₁ :=\nrfl\n\ninclude σ₂₁\ntheorem symm_symm_apply (e : M₁ ≃SL[σ₁₂] M₂) (x : M₁) : e.symm.symm x = e x :=\nrfl\n\nlemma symm_apply_eq (e : M₁ ≃SL[σ₁₂] M₂) {x y} : e.symm x = y ↔ x = e y :=\ne.to_linear_equiv.symm_apply_eq\n\nlemma eq_symm_apply (e : M₁ ≃SL[σ₁₂] M₂) {x y} : y = e.symm x ↔ e y = x :=\ne.to_linear_equiv.eq_symm_apply\n\nprotected lemma image_eq_preimage (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₁) : e '' s = e.symm ⁻¹' s :=\ne.to_linear_equiv.to_equiv.image_eq_preimage s\n\nprotected lemma image_symm_eq_preimage (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₂) : e.symm '' s = e ⁻¹' s :=\nby rw [e.symm.image_eq_preimage, e.symm_symm]\n\n@[simp] protected lemma symm_preimage_preimage (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₂) :\n  e.symm ⁻¹' (e ⁻¹' s) = s := e.to_linear_equiv.to_equiv.symm_preimage_preimage s\n\n@[simp] protected lemma preimage_symm_preimage (e : M₁ ≃SL[σ₁₂] M₂) (s : set M₁) :\n  e ⁻¹' (e.symm ⁻¹' s) = s := e.symm.symm_preimage_preimage s\n\nomit σ₂₁\n\n/-- Create a `continuous_linear_equiv` from two `continuous_linear_map`s that are\ninverse of each other. -/\ndef equiv_of_inverse (f₁ : M₁ →SL[σ₁₂] M₂) (f₂ : M₂ →SL[σ₂₁] M₁) (h₁ : function.left_inverse f₂ f₁)\n  (h₂ : function.right_inverse f₂ f₁) :\n  M₁ ≃SL[σ₁₂] M₂ :=\n{ to_fun := f₁,\n  continuous_to_fun := f₁.continuous,\n  inv_fun := f₂,\n  continuous_inv_fun := f₂.continuous,\n  left_inv := h₁,\n  right_inv := h₂,\n  .. f₁ }\n\ninclude σ₂₁\n@[simp] lemma equiv_of_inverse_apply (f₁ : M₁ →SL[σ₁₂] M₂) (f₂ h₁ h₂ x) :\n  equiv_of_inverse f₁ f₂ h₁ h₂ x = f₁ x :=\nrfl\n\n@[simp] lemma symm_equiv_of_inverse (f₁ : M₁ →SL[σ₁₂] M₂) (f₂ h₁ h₂) :\n  (equiv_of_inverse f₁ f₂ h₁ h₂).symm = equiv_of_inverse f₂ f₁ h₂ h₁ :=\nrfl\nomit σ₂₁\n\nvariable (M₁)\n\n/-- The continuous linear equivalences from `M` to itself form a group under composition. -/\ninstance automorphism_group : group (M₁ ≃L[R₁] M₁) :=\n{ mul          := λ f g, g.trans f,\n  one          := continuous_linear_equiv.refl R₁ M₁,\n  inv          := λ f, f.symm,\n  mul_assoc    := λ f g h, by {ext, refl},\n  mul_one      := λ f, by {ext, refl},\n  one_mul      := λ f, by {ext, refl},\n  mul_left_inv := λ f, by {ext, exact f.left_inv x} }\n\nvariables {M₁} {R₄ : Type*} [semiring R₄] [module R₄ M₄]\n  {σ₃₄ : R₃ →+* R₄} {σ₄₃ : R₄ →+* R₃} [ring_hom_inv_pair σ₃₄ σ₄₃] [ring_hom_inv_pair σ₄₃ σ₃₄]\n  {σ₂₄ : R₂ →+* R₄} {σ₁₄ : R₁ →+* R₄}\n  [ring_hom_comp_triple σ₂₁ σ₁₄ σ₂₄] [ring_hom_comp_triple σ₂₄ σ₄₃ σ₂₃]\n  [ring_hom_comp_triple σ₁₃ σ₃₄ σ₁₄]\n\ninclude σ₂₁ σ₃₄ σ₂₃ σ₂₄ σ₁₃\n\n/-- A pair of continuous (semi)linear equivalences generates an equivalence between the spaces of\ncontinuous linear maps. -/\n@[simps] def arrow_congr_equiv (e₁₂ : M₁ ≃SL[σ₁₂] M₂) (e₄₃ : M₄ ≃SL[σ₄₃] M₃) :\n  (M₁ →SL[σ₁₄] M₄) ≃ (M₂ →SL[σ₂₃] M₃) :=\n{ to_fun := λ f, (e₄₃ : M₄ →SL[σ₄₃] M₃).comp (f.comp (e₁₂.symm : M₂ →SL[σ₂₁] M₁)),\n  inv_fun := λ f, (e₄₃.symm : M₃ →SL[σ₃₄] M₄).comp (f.comp (e₁₂ : M₁ →SL[σ₁₂] M₂)),\n  left_inv := λ f, continuous_linear_map.ext $ λ x,\n    by simp only [continuous_linear_map.comp_apply, symm_apply_apply, coe_coe],\n  right_inv := λ f, continuous_linear_map.ext $ λ x,\n    by simp only [continuous_linear_map.comp_apply, apply_symm_apply, coe_coe] }\n\nend add_comm_monoid\n\nsection add_comm_group\n\nvariables {R : Type*} [semiring R]\n{M : Type*} [topological_space M] [add_comm_group M]\n{M₂ : Type*} [topological_space M₂] [add_comm_group M₂]\n{M₃ : Type*} [topological_space M₃] [add_comm_group M₃]\n{M₄ : Type*} [topological_space M₄] [add_comm_group M₄]\n[module R M] [module R M₂] [module R M₃] [module R M₄]\n\nvariables [topological_add_group M₄]\n\n/-- Equivalence given by a block lower diagonal matrix. `e` and `e'` are diagonal square blocks,\n  and `f` is a rectangular block below the diagonal. -/\ndef skew_prod (e : M ≃L[R] M₂) (e' : M₃ ≃L[R] M₄) (f : M →L[R] M₄) :\n  (M × M₃) ≃L[R] M₂ × M₄ :=\n{ continuous_to_fun := (e.continuous_to_fun.comp continuous_fst).prod_mk\n    ((e'.continuous_to_fun.comp continuous_snd).add $ f.continuous.comp continuous_fst),\n  continuous_inv_fun := (e.continuous_inv_fun.comp continuous_fst).prod_mk\n    (e'.continuous_inv_fun.comp $ continuous_snd.sub $ f.continuous.comp $\n      e.continuous_inv_fun.comp continuous_fst),\n.. e.to_linear_equiv.skew_prod e'.to_linear_equiv ↑f }\n@[simp] lemma skew_prod_apply (e : M ≃L[R] M₂) (e' : M₃ ≃L[R] M₄) (f : M →L[R] M₄) (x) :\n  e.skew_prod e' f x = (e x.1, e' x.2 + f x.1) := rfl\n\n@[simp] lemma skew_prod_symm_apply (e : M ≃L[R] M₂) (e' : M₃ ≃L[R] M₄) (f : M →L[R] M₄) (x) :\n  (e.skew_prod e' f).symm x = (e.symm x.1, e'.symm (x.2 - f (e.symm x.1))) := rfl\n\nend add_comm_group\n\nsection ring\n\nvariables {R : Type*} [ring R] {R₂ : Type*} [ring R₂]\n{M : Type*} [topological_space M] [add_comm_group M] [module R M]\n{M₂ : Type*} [topological_space M₂] [add_comm_group M₂] [module R₂ M₂]\nvariables {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} [ring_hom_inv_pair σ₁₂ σ₂₁] [ring_hom_inv_pair σ₂₁ σ₁₂]\n\ninclude σ₂₁\n@[simp] lemma map_sub (e : M ≃SL[σ₁₂] M₂) (x y : M) : e (x - y) = e x - e y :=\n(e : M →SL[σ₁₂] M₂).map_sub x y\n\n@[simp] lemma map_neg (e : M ≃SL[σ₁₂] M₂) (x : M) : e (-x) = -e x := (e : M →SL[σ₁₂] M₂).map_neg x\nomit σ₂₁\n\nsection\n/-! The next theorems cover the identification between `M ≃L[𝕜] M`and the group of units of the ring\n`M →L[R] M`. -/\nvariables [topological_add_group M]\n\n/-- An invertible continuous linear map `f` determines a continuous equivalence from `M` to itself.\n-/\ndef of_unit (f : units (M →L[R] M)) : (M ≃L[R] M) :=\n{ to_linear_equiv :=\n  { to_fun    := f.val,\n    map_add'  := by simp,\n    map_smul' := by simp,\n    inv_fun   := f.inv,\n    left_inv  := λ x, show (f.inv * f.val) x = x, by {rw f.inv_val, simp},\n    right_inv := λ x, show (f.val * f.inv) x = x, by {rw f.val_inv, simp}, },\n  continuous_to_fun  := f.val.continuous,\n  continuous_inv_fun := f.inv.continuous }\n\n/-- A continuous equivalence from `M` to itself determines an invertible continuous linear map. -/\ndef to_unit (f : (M ≃L[R] M)) : units (M →L[R] M) :=\n{ val     := f,\n  inv     := f.symm,\n  val_inv := by {ext, simp},\n  inv_val := by {ext, simp} }\n\nvariables (R M)\n\n/-- The units of the algebra of continuous `R`-linear endomorphisms of `M` is multiplicatively\nequivalent to the type of continuous linear equivalences between `M` and itself. -/\ndef units_equiv : units (M →L[R] M) ≃* (M ≃L[R] M) :=\n{ to_fun    := of_unit,\n  inv_fun   := to_unit,\n  left_inv  := λ f, by {ext, refl},\n  right_inv := λ f, by {ext, refl},\n  map_mul'  := λ x y, by {ext, refl} }\n\n@[simp] lemma units_equiv_apply (f : units (M →L[R] M)) (x : M) :\n  units_equiv R M f x = f x := rfl\n\nend\n\nsection\nvariables (R) [topological_space R] [has_continuous_mul R]\n\n/-- Continuous linear equivalences `R ≃L[R] R` are enumerated by `units R`. -/\ndef units_equiv_aut : units R ≃ (R ≃L[R] R) :=\n{ to_fun := λ u, equiv_of_inverse\n    (continuous_linear_map.smul_right (1 : R →L[R] R) ↑u)\n    (continuous_linear_map.smul_right (1 : R →L[R] R) ↑u⁻¹)\n    (λ x, by simp) (λ x, by simp),\n  inv_fun := λ e, ⟨e 1, e.symm 1,\n    by rw [← smul_eq_mul, ← map_smul, smul_eq_mul, mul_one, symm_apply_apply],\n    by rw [← smul_eq_mul, ← map_smul, smul_eq_mul, mul_one, apply_symm_apply]⟩,\n  left_inv := λ u, units.ext $ by simp,\n  right_inv := λ e, ext₁ $ by simp }\n\nvariable {R}\n\n@[simp] lemma units_equiv_aut_apply (u : units R) (x : R) : units_equiv_aut R u x = x * u := rfl\n\n@[simp] lemma units_equiv_aut_apply_symm (u : units R) (x : R) :\n  (units_equiv_aut R u).symm x = x * ↑u⁻¹ := rfl\n\n@[simp] lemma units_equiv_aut_symm_apply (e : R ≃L[R] R) :\n  ↑((units_equiv_aut R).symm e) = e 1 :=\nrfl\n\nend\n\nvariables [module R M₂] [topological_add_group M]\n\nopen _root_.continuous_linear_map (id fst snd subtype_val mem_ker)\n\n/-- A pair of continuous linear maps such that `f₁ ∘ f₂ = id` generates a continuous\nlinear equivalence `e` between `M` and `M₂ × f₁.ker` such that `(e x).2 = x` for `x ∈ f₁.ker`,\n`(e x).1 = f₁ x`, and `(e (f₂ y)).2 = 0`. The map is given by `e x = (f₁ x, x - f₂ (f₁ x))`. -/\ndef equiv_of_right_inverse (f₁ : M →L[R] M₂) (f₂ : M₂ →L[R] M) (h : function.right_inverse f₂ f₁) :\n  M ≃L[R] M₂ × f₁.ker :=\nequiv_of_inverse (f₁.prod (f₁.proj_ker_of_right_inverse f₂ h)) (f₂.coprod (subtype_val f₁.ker))\n  (λ x, by simp)\n  (λ ⟨x, y⟩, by simp [h x])\n\n@[simp] lemma fst_equiv_of_right_inverse (f₁ : M →L[R] M₂) (f₂ : M₂ →L[R] M)\n  (h : function.right_inverse f₂ f₁) (x : M) :\n  (equiv_of_right_inverse f₁ f₂ h x).1 = f₁ x := rfl\n\n@[simp] lemma snd_equiv_of_right_inverse (f₁ : M →L[R] M₂) (f₂ : M₂ →L[R] M)\n  (h : function.right_inverse f₂ f₁) (x : M) :\n  ((equiv_of_right_inverse f₁ f₂ h x).2 : M) = x - f₂ (f₁ x) := rfl\n\n@[simp] lemma equiv_of_right_inverse_symm_apply (f₁ : M →L[R] M₂) (f₂ : M₂ →L[R] M)\n  (h : function.right_inverse f₂ f₁) (y : M₂ × f₁.ker) :\n  (equiv_of_right_inverse f₁ f₂ h).symm y = f₂ y.1 + y.2 := rfl\n\nend ring\n\nsection\n\nvariables (ι R M : Type*) [unique ι] [semiring R] [add_comm_monoid M] [module R M]\n  [topological_space M]\n\n/-- If `ι` has a unique element, then `ι → M` is continuously linear equivalent to `M`. -/\ndef fun_unique : (ι → M) ≃L[R] M :=\n{ to_linear_equiv := linear_equiv.fun_unique ι R M,\n  .. homeomorph.fun_unique ι M }\n\nvariables {ι R M}\n\n@[simp] lemma coe_fun_unique : ⇑(fun_unique ι R M) = function.eval (default ι) := rfl\n@[simp] lemma coe_fun_unique_symm : ⇑(fun_unique ι R M).symm = function.const ι := rfl\n\nvariables (R M)\n\n/-- Continuous linear equivalence between dependent functions `Π i : fin 2, M i` and `M 0 × M 1`. -/\n@[simps { fully_applied := ff }]\ndef pi_fin_two (M : fin 2 → Type*) [Π i, add_comm_monoid (M i)] [Π i, module R (M i)]\n  [Π i, topological_space (M i)] :\n  (Π i, M i) ≃L[R] M 0 × M 1 :=\n{ to_linear_equiv := linear_equiv.pi_fin_two R M, .. homeomorph.pi_fin_two M }\n\n/-- Continuous linear equivalence between vectors in `M² = fin 2 → M` and `M × M`. -/\n@[simps { fully_applied := ff }]\ndef fin_two_arrow : (fin 2 → M) ≃L[R] M × M :=\n{ to_linear_equiv := linear_equiv.fin_two_arrow R M, .. pi_fin_two R (λ _, M) }\n\nend\n\nend continuous_linear_equiv\n\nnamespace continuous_linear_map\n\nopen_locale classical\n\nvariables {R : Type*} {M : Type*} {M₂ : Type*} [topological_space M] [topological_space M₂]\n\nsection\nvariables [semiring R]\nvariables [add_comm_monoid M₂] [module R M₂]\nvariables [add_comm_monoid M] [module R M]\n\n/-- Introduce a function `inverse` from `M →L[R] M₂` to `M₂ →L[R] M`, which sends `f` to `f.symm` if\n`f` is a continuous linear equivalence and to `0` otherwise.  This definition is somewhat ad hoc,\nbut one needs a fully (rather than partially) defined inverse function for some purposes, including\nfor calculus. -/\nnoncomputable def inverse : (M →L[R] M₂) → (M₂ →L[R] M) :=\nλ f, if h : ∃ (e : M ≃L[R] M₂), (e : M →L[R] M₂) = f then ((classical.some h).symm : M₂ →L[R] M)\nelse 0\n\n/-- By definition, if `f` is invertible then `inverse f = f.symm`. -/\n@[simp] lemma inverse_equiv (e : M ≃L[R] M₂) : inverse (e : M →L[R] M₂) = e.symm :=\nbegin\n  have h : ∃ (e' : M ≃L[R] M₂), (e' : M →L[R] M₂) = ↑e := ⟨e, rfl⟩,\n  simp only [inverse, dif_pos h],\n  congr,\n  exact_mod_cast (classical.some_spec h)\nend\n\n/-- By definition, if `f` is not invertible then `inverse f = 0`. -/\n@[simp] lemma inverse_non_equiv (f : M →L[R] M₂) (h : ¬∃ (e' : M ≃L[R] M₂), ↑e' = f) :\n  inverse f = 0 :=\ndif_neg h\n\nend\n\nsection\nvariables [ring R]\nvariables [add_comm_group M] [topological_add_group M] [module R M]\nvariables [add_comm_group M₂] [module R M₂]\n\n@[simp] lemma ring_inverse_equiv (e : M ≃L[R] M) :\n  ring.inverse ↑e = inverse (e : M →L[R] M) :=\nbegin\n  suffices :\n    ring.inverse ((((continuous_linear_equiv.units_equiv _ _).symm e) : M →L[R] M)) = inverse ↑e,\n  { convert this },\n  simp,\n  refl,\nend\n\n/-- The function `continuous_linear_equiv.inverse` can be written in terms of `ring.inverse` for the\nring of self-maps of the domain. -/\nlemma to_ring_inverse (e : M ≃L[R] M₂) (f : M →L[R] M₂) :\n  inverse f = (ring.inverse ((e.symm : (M₂ →L[R] M)).comp f)) ∘L ↑e.symm :=\nbegin\n  by_cases h₁ : ∃ (e' : M ≃L[R] M₂), ↑e' = f,\n  { obtain ⟨e', he'⟩ := h₁,\n    rw ← he',\n    change _ = (ring.inverse ↑(e'.trans e.symm)) ∘L ↑e.symm,\n    ext,\n    simp },\n  { suffices : ¬is_unit ((e.symm : M₂ →L[R] M).comp f),\n    { simp [this, h₁] },\n    contrapose! h₁,\n    rcases h₁ with ⟨F, hF⟩,\n    use (continuous_linear_equiv.units_equiv _ _ F).trans e,\n    ext,\n    dsimp, rw [coe_fn_coe_base' F, hF], simp }\nend\n\nlemma ring_inverse_eq_map_inverse : ring.inverse = @inverse R M M _ _ _ _ _ _ _ :=\nbegin\n  ext,\n  simp [to_ring_inverse (continuous_linear_equiv.refl R M)],\nend\n\nend\n\nend continuous_linear_map\n\nnamespace submodule\n\nvariables\n{R : Type*} [ring R]\n{M : Type*} [topological_space M] [add_comm_group M] [module R M]\n{M₂ : Type*} [topological_space M₂] [add_comm_group M₂] [module R M₂]\n\nopen continuous_linear_map\n\n/-- A submodule `p` is called *complemented* if there exists a continuous projection `M →ₗ[R] p`. -/\ndef closed_complemented (p : submodule R M) : Prop := ∃ f : M →L[R] p, ∀ x : p, f x = x\n\nlemma closed_complemented.has_closed_complement {p : submodule R M} [t1_space p]\n  (h : closed_complemented p) :\n  ∃ (q : submodule R M) (hq : is_closed (q : set M)), is_compl p q :=\nexists.elim h $ λ f hf, ⟨f.ker, f.is_closed_ker, linear_map.is_compl_of_proj hf⟩\n\nprotected lemma closed_complemented.is_closed [topological_add_group M] [t1_space M]\n  {p : submodule R M} (h : closed_complemented p) :\n  is_closed (p : set M) :=\nbegin\n  rcases h with ⟨f, hf⟩,\n  have : ker (id R M - (subtype_val p).comp f) = p := linear_map.ker_id_sub_eq_of_proj hf,\n  exact this ▸ (is_closed_ker _)\nend\n\n@[simp] lemma closed_complemented_bot : closed_complemented (⊥ : submodule R M) :=\n⟨0, λ x, by simp only [zero_apply, eq_zero_of_bot_submodule x]⟩\n\n@[simp] lemma closed_complemented_top : closed_complemented (⊤ : submodule R M) :=\n⟨(id R M).cod_restrict ⊤ (λ x, trivial), λ x, subtype.ext_iff_val.2 $ by simp⟩\n\nend submodule\n\nlemma continuous_linear_map.closed_complemented_ker_of_right_inverse {R : Type*} [ring R]\n  {M : Type*} [topological_space M] [add_comm_group M]\n  {M₂ : Type*} [topological_space M₂] [add_comm_group M₂] [module R M] [module R M₂]\n  [topological_add_group M] (f₁ : M →L[R] M₂) (f₂ : M₂ →L[R] M)\n  (h : function.right_inverse f₂ f₁) :\n  f₁.ker.closed_complemented :=\n⟨f₁.proj_ker_of_right_inverse f₂ h, f₁.proj_ker_of_right_inverse_apply_idem f₂ h⟩\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/topology/algebra/module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.4817503267003921}}
{"text": "/-\nCopyright (c) 2020 Kenji Nakagawa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio\n\n! This file was ported from Lean 3 source module ring_theory.dedekind_domain.basic\n! leanprover-community/mathlib commit 926daa81fd8acb2a04e15572c4ff20af2753c2ae\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.RingTheory.Ideal.Over\nimport Mathbin.RingTheory.Polynomial.RationalRoot\n\n/-!\n# Dedekind domains\n\nThis file defines the notion of a Dedekind domain (or Dedekind ring),\nas a Noetherian integrally closed commutative ring of Krull dimension at most one.\n\n## Main definitions\n\n - `is_dedekind_domain` defines a Dedekind domain as a commutative ring that is\n   Noetherian, integrally closed in its field of fractions and has Krull dimension at most one.\n   `is_dedekind_domain_iff` shows that this does not depend on the choice of field of fractions.\n\n## Implementation notes\n\nThe definitions that involve a field of fractions choose a canonical field of fractions,\nbut are independent of that choice. The `..._iff` lemmas express this independence.\n\nOften, definitions assume that Dedekind domains are not fields. We found it more practical\nto add a `(h : ¬ is_field A)` assumption whenever this is explicitly needed.\n\n## References\n\n* [D. Marcus, *Number Fields*][marcus1977number]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]\n\n## Tags\n\ndedekind domain, dedekind ring\n-/\n\n\nvariable (R A K : Type _) [CommRing R] [CommRing A] [Field K]\n\nopen nonZeroDivisors Polynomial\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (p «expr ≠ » («expr⊥»() : ideal[ideal] R)) -/\n/-- A ring `R` has Krull dimension at most one if all nonzero prime ideals are maximal. -/\ndef Ring.DimensionLeOne : Prop :=\n  ∀ (p) (_ : p ≠ (⊥ : Ideal R)), p.IsPrime → p.IsMaximal\n#align ring.dimension_le_one Ring.DimensionLeOne\n\nopen Ideal Ring\n\nnamespace Ring\n\ntheorem DimensionLeOne.principal_ideal_ring [IsDomain A] [IsPrincipalIdealRing A] :\n    DimensionLeOne A := fun p nonzero prime =>\n  haveI := Prime\n  IsPrime.to_maximal_ideal nonzero\n#align ring.dimension_le_one.principal_ideal_ring Ring.DimensionLeOne.principal_ideal_ring\n\ntheorem DimensionLeOne.isIntegralClosure (B : Type _) [CommRing B] [IsDomain B] [Nontrivial R]\n    [Algebra R A] [Algebra R B] [Algebra B A] [IsScalarTower R B A] [IsIntegralClosure B R A]\n    (h : DimensionLeOne R) : DimensionLeOne B := fun p ne_bot prime =>\n  is_integral_closure.is_maximal_of_is_maximal_comap A p\n    (h _ (is_integral_closure.comap_ne_bot A ne_bot) inferInstance)\n#align ring.dimension_le_one.is_integral_closure Ring.DimensionLeOne.isIntegralClosure\n\ntheorem DimensionLeOne.integralClosure [Nontrivial R] [IsDomain A] [Algebra R A]\n    (h : DimensionLeOne R) : DimensionLeOne (integralClosure R A) :=\n  h.IsIntegralClosure R A (integralClosure R A)\n#align ring.dimension_le_one.integral_closure Ring.DimensionLeOne.integralClosure\n\nvariable {R}\n\ntheorem DimensionLeOne.not_lt_lt (h : Ring.DimensionLeOne R) (p₀ p₁ p₂ : Ideal R) [hp₁ : p₁.IsPrime]\n    [hp₂ : p₂.IsPrime] : ¬(p₀ < p₁ ∧ p₁ < p₂)\n  | ⟨h01, h12⟩ => h12.Ne ((h p₁ (bot_le.trans_lt h01).ne' hp₁).eq_of_le hp₂.ne_top h12.le)\n#align ring.dimension_le_one.not_lt_lt Ring.DimensionLeOne.not_lt_lt\n\ntheorem DimensionLeOne.eq_bot_of_lt (h : Ring.DimensionLeOne R) (p P : Ideal R) [hp : p.IsPrime]\n    [hP : P.IsPrime] (hpP : p < P) : p = ⊥ :=\n  by_contra fun hp0 => h.not_lt_lt ⊥ p P ⟨Ne.bot_lt hp0, hpP⟩\n#align ring.dimension_le_one.eq_bot_of_lt Ring.DimensionLeOne.eq_bot_of_lt\n\nend Ring\n\nvariable [IsDomain A]\n\n/-- A Dedekind domain is an integral domain that is Noetherian, integrally closed, and\nhas Krull dimension at most one.\n\nThis is definition 3.2 of [Neukirch1992].\n\nThe integral closure condition is independent of the choice of field of fractions:\nuse `is_dedekind_domain_iff` to prove `is_dedekind_domain` for a given `fraction_map`.\n\nThis is the default implementation, but there are equivalent definitions,\n`is_dedekind_domain_dvr` and `is_dedekind_domain_inv`.\nTODO: Prove that these are actually equivalent definitions.\n-/\nclass IsDedekindDomain : Prop where\n  IsNoetherianRing : IsNoetherianRing A\n  DimensionLeOne : DimensionLeOne A\n  IsIntegrallyClosed : IsIntegrallyClosed A\n#align is_dedekind_domain IsDedekindDomain\n\n-- See library note [lower instance priority]\nattribute [instance] IsDedekindDomain.isNoetherianRing IsDedekindDomain.isIntegrallyClosed\n\n/-- An integral domain is a Dedekind domain iff and only if it is\nNoetherian, has dimension ≤ 1, and is integrally closed in a given fraction field.\nIn particular, this definition does not depend on the choice of this fraction field. -/\ntheorem isDedekindDomain_iff (K : Type _) [Field K] [Algebra A K] [IsFractionRing A K] :\n    IsDedekindDomain A ↔\n      IsNoetherianRing A ∧\n        DimensionLeOne A ∧ ∀ {x : K}, IsIntegral A x → ∃ y, algebraMap A K y = x :=\n  ⟨fun ⟨hr, hd, hi⟩ => ⟨hr, hd, fun x => (isIntegrallyClosed_iff K).mp hi⟩, fun ⟨hr, hd, hi⟩ =>\n    ⟨hr, hd, (isIntegrallyClosed_iff K).mpr @hi⟩⟩\n#align is_dedekind_domain_iff isDedekindDomain_iff\n\n-- See library note [lower instance priority]\ninstance (priority := 100) IsPrincipalIdealRing.isDedekindDomain [IsPrincipalIdealRing A] :\n    IsDedekindDomain A :=\n  ⟨PrincipalIdealRing.isNoetherianRing, Ring.DimensionLeOne.principal_ideal_ring A,\n    UniqueFactorizationMonoid.isIntegrallyClosed⟩\n#align is_principal_ideal_ring.is_dedekind_domain IsPrincipalIdealRing.isDedekindDomain\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/DedekindDomain/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6825737279551493, "lm_q1q2_score": 0.48175032603388984}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport topology.sheaves.presheaf\nimport category_theory.adjunction.fully_faithful\n\n/-!\n# Presheafed spaces\n\nIntroduces the category of topological spaces equipped with a presheaf (taking values in an\narbitrary target category `C`.)\n\nWe further describe how to apply functors and natural transformations to the values of the\npresheaves.\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.category category_theory.functor\n\nvariables (C : Type u) [category.{v} C]\n\nlocal attribute [tidy] tactic.op_induction'\n\nnamespace algebraic_geometry\n\n/-- A `PresheafedSpace C` is a topological space equipped with a presheaf of `C`s. -/\nstructure PresheafedSpace :=\n(carrier : Top)\n(presheaf : carrier.presheaf C)\n\nvariables {C}\n\nnamespace PresheafedSpace\n\nattribute [protected] presheaf\n\ninstance coe_carrier : has_coe (PresheafedSpace C) Top :=\n{ coe := λ X, X.carrier }\n\n@[simp] lemma as_coe (X : PresheafedSpace C) : X.carrier = (X : Top.{v}) := rfl\n@[simp] lemma mk_coe (carrier) (presheaf) : (({ carrier := carrier, presheaf := presheaf } :\n  PresheafedSpace.{v} C) : Top.{v}) = carrier := rfl\n\ninstance (X : PresheafedSpace.{v} C) : topological_space X := X.carrier.str\n\n/-- The constant presheaf on `X` with value `Z`. -/\ndef const (X : Top) (Z : C) : PresheafedSpace C :=\n{ carrier := X,\n  presheaf :=\n  { obj := λ U, Z,\n    map := λ U V f, 𝟙 Z, } }\n\ninstance [inhabited C] : inhabited (PresheafedSpace C) := ⟨const (Top.of pempty) (default C)⟩\n\n/-- A morphism between presheafed spaces `X` and `Y` consists of a continuous map\n    `f` between the underlying topological spaces, and a (notice contravariant!) map\n    from the presheaf on `Y` to the pushforward of the presheaf on `X` via `f`. -/\nstructure hom (X Y : PresheafedSpace C) :=\n(base : (X : Top.{v}) ⟶ (Y : Top.{v}))\n(c : Y.presheaf ⟶ base _* X.presheaf)\n\n@[ext] lemma ext {X Y : PresheafedSpace C} (α β : hom X Y)\n  (w : α.base = β.base)\n  (h : α.c ≫ (whisker_right (eq_to_hom (by rw w)) _) = β.c) :\n  α = β :=\nbegin\n  cases α, cases β,\n  dsimp [presheaf.pushforward_obj] at *,\n  tidy, -- TODO including `injections` would make tidy work earlier.\nend\n\nlemma hext {X Y : PresheafedSpace C} (α β : hom X Y)\n  (w : α.base = β.base)\n  (h : α.c == β.c) :\n  α = β :=\nby { cases α, cases β, congr, exacts [w,h] }\n\n.\n\n/-- The identity morphism of a `PresheafedSpace`. -/\ndef id (X : PresheafedSpace C) : hom X X :=\n{ base := 𝟙 (X : Top.{v}),\n  c := eq_to_hom (presheaf.pushforward.id_eq X.presheaf).symm }\n\ninstance hom_inhabited (X : PresheafedSpace C) : inhabited (hom X X) := ⟨id X⟩\n\n/-- Composition of morphisms of `PresheafedSpace`s. -/\ndef comp {X Y Z : PresheafedSpace C} (α : hom X Y) (β : hom Y Z) : hom X Z :=\n{ base := α.base ≫ β.base,\n  c := β.c ≫ (presheaf.pushforward _ β.base).map α.c }\n\nlemma comp_c {X Y Z : PresheafedSpace C} (α : hom X Y) (β : hom Y Z) :\n  (comp α β).c = β.c ≫ (presheaf.pushforward _ β.base).map α.c := rfl\n\n\nvariables (C)\n\nsection\nlocal attribute [simp] id comp\n\n/- The proofs below can be done by `tidy`, but it is too slow,\n   and we don't have a tactic caching mechanism. -/\n/-- The category of PresheafedSpaces. Morphisms are pairs, a continuous map and a presheaf map\n    from the presheaf on the target to the pushforward of the presheaf on the source. -/\ninstance category_of_PresheafedSpaces : category (PresheafedSpace C) :=\n{ hom := hom,\n  id := id,\n  comp := λ X Y Z f g, comp f g,\n  id_comp' := λ X Y f, begin\n    ext1,\n    { rw comp_c,\n      erw eq_to_hom_map,\n      simp only [eq_to_hom_refl, assoc, whisker_right_id'],\n      erw [comp_id, comp_id] },\n    apply id_comp\n  end,\n  comp_id' := λ X Y f, begin\n    ext1,\n    { rw comp_c,\n      erw congr_hom (presheaf.id_pushforward _) f.c,\n      simp only [comp_id, functor.id_map, eq_to_hom_refl, assoc, whisker_right_id'],\n      erw eq_to_hom_trans_assoc,\n      simp only [id_comp, eq_to_hom_refl],\n      erw comp_id },\n    apply comp_id\n  end,\n  assoc' := λ W X Y Z f g h, begin\n    ext1,\n    repeat {rw comp_c},\n    simp only [eq_to_hom_refl, assoc, functor.map_comp, whisker_right_id'],\n    erw comp_id,\n    congr,\n    refl\n  end }\n\nend\n\nvariables {C}\n\n@[simp] lemma id_base (X : PresheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).base = 𝟙 (X : Top.{v}) := rfl\n\nlemma id_c (X : PresheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).c = eq_to_hom (presheaf.pushforward.id_eq X.presheaf).symm := rfl\n\n@[simp] lemma id_c_app (X : PresheafedSpace C) (U) :\n  ((𝟙 X) : X ⟶ X).c.app U = X.presheaf.map\n    (eq_to_hom (by { induction U using opposite.rec, cases U, refl })) :=\nby { induction U using opposite.rec, cases U, simp only [id_c], dsimp, simp, }\n\n@[simp] lemma comp_base {X Y Z : PresheafedSpace C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).base = f.base ≫ g.base := rfl\n\n-- The `reassoc` attribute was added despite the LHS not being a composition of two homs,\n-- for the reasons explained in the docstring.\n/-- Sometimes rewriting with `comp_c_app` doesn't work because of dependent type issues.\nIn that case, `erw comp_c_app_assoc` might make progress.\nThe lemma `comp_c_app_assoc` is also better suited for rewrites in the opposite direction. -/\n@[reassoc, simp] lemma comp_c_app {X Y Z : PresheafedSpace C} (α : X ⟶ Y) (β : Y ⟶ Z) (U) :\n  (α ≫ β).c.app U = (β.c).app U ≫ (α.c).app (op ((opens.map (β.base)).obj (unop U))) := rfl\n\nlemma congr_app {X Y : PresheafedSpace C} {α β : X ⟶ Y} (h : α = β) (U) :\n  α.c.app U = β.c.app U ≫ X.presheaf.map (eq_to_hom (by subst h)) :=\nby { subst h, dsimp, simp, }\n\nsection\nvariables (C)\n\n/-- The forgetful functor from `PresheafedSpace` to `Top`. -/\n@[simps]\ndef forget : PresheafedSpace C ⥤ Top :=\n{ obj := λ X, (X : Top.{v}),\n  map := λ X Y f, f.base }\n\nend\n\nsection iso\n\nvariables {X Y : PresheafedSpace C}\n\n/--\nAn isomorphism of PresheafedSpaces is a homeomorphism of the underlying space, and a\nnatural transformation between the sheaves.\n-/\n@[simps hom inv]\ndef iso_of_components (H : X.1 ≅ Y.1) (α : H.hom _* X.2 ≅ Y.2) : X ≅ Y :=\n{ hom := { base := H.hom, c := α.inv },\n  inv := { base := H.inv,\n    c := presheaf.to_pushforward_of_iso H α.hom },\n  hom_inv_id' := by { ext, { simp, erw category.id_comp, simpa }, simp },\n  inv_hom_id' :=\n  begin\n    ext x,\n    induction x using opposite.rec,\n    simp only [comp_c_app, whisker_right_app, presheaf.to_pushforward_of_iso_app,\n      nat_trans.comp_app, eq_to_hom_app, id_c_app, category.assoc],\n    erw [← α.hom.naturality],\n    have := nat_trans.congr_app (α.inv_hom_id) (op x),\n    cases x,\n    rw nat_trans.comp_app at this,\n    convert this,\n    { dsimp, simp },\n    { simp },\n    { simp }\n  end }\n\n/-- Isomorphic PresheafedSpaces have natural isomorphic presheaves. -/\n@[simps]\ndef sheaf_iso_of_iso (H : X ≅ Y) : Y.2 ≅ H.hom.base _* X.2 :=\n{ hom := H.hom.c,\n  inv := presheaf.pushforward_to_of_iso ((forget _).map_iso H).symm H.inv.c,\n  hom_inv_id' :=\n  begin\n    ext U,\n    have := congr_app H.inv_hom_id U,\n    simp only [comp_c_app, id_c_app,\n      eq_to_hom_map, eq_to_hom_trans] at this,\n    generalize_proofs h at this,\n    simpa using congr_arg (λ f, f ≫ eq_to_hom h.symm) this,\n  end,\n  inv_hom_id' :=\n  begin\n    ext U,\n    simp only [presheaf.pushforward_to_of_iso_app, nat_trans.comp_app, category.assoc,\n      nat_trans.id_app, H.hom.c.naturality],\n    have := congr_app H.hom_inv_id ((opens.map H.hom.base).op.obj U),\n    generalize_proofs h at this,\n    simpa using congr_arg (λ f, f ≫ X.presheaf.map (eq_to_hom h.symm)) this\n  end }\n\ninstance base_is_iso_of_iso (f : X ⟶ Y) [is_iso f] : is_iso f.base :=\nis_iso.of_iso ((forget _).map_iso (as_iso f))\n\ninstance c_is_iso_of_iso (f : X ⟶ Y) [is_iso f] : is_iso f.c :=\nis_iso.of_iso (sheaf_iso_of_iso (as_iso f))\n\n/-- This could be used in conjunction with `category_theory.nat_iso.is_iso_of_is_iso_app`. -/\nlemma is_iso_of_components (f : X ⟶ Y) [is_iso f.base] [is_iso f.c] : is_iso f :=\nbegin\n  convert is_iso.of_iso (iso_of_components (as_iso f.base) (as_iso f.c).symm),\n  ext, { simpa }, { simp },\nend\n\nend iso\n\nsection restrict\n\n/--\nThe restriction of a presheafed space along an open embedding into the space.\n-/\n@[simps]\ndef restrict {U : Top} (X : PresheafedSpace C)\n  {f : U ⟶ (X : Top.{v})} (h : open_embedding f) : PresheafedSpace C :=\n{ carrier := U,\n  presheaf := h.is_open_map.functor.op ⋙ X.presheaf }\n\n/--\nThe map from the restriction of a presheafed space.\n-/\n@[simps]\ndef of_restrict {U : Top} (X : PresheafedSpace C)\n  {f : U ⟶ (X : Top.{v})} (h : open_embedding f) :\n  X.restrict h ⟶ X :=\n{ base := f,\n  c := { app := λ V, X.presheaf.map (h.is_open_map.adjunction.counit.app V.unop).op,\n    naturality' := λ U V f, show _ = _ ≫ X.presheaf.map _,\n      by { rw [← map_comp, ← map_comp], refl } } }\n\ninstance of_restrict_mono {U : Top} (X : PresheafedSpace C) (f : U ⟶ X.1)\n   (hf : open_embedding f) : mono (X.of_restrict hf) :=\n begin\n   haveI : mono f := (Top.mono_iff_injective _).mpr hf.inj,\n   constructor,\n   intros Z g₁ g₂ eq,\n   ext V,\n   { induction V using opposite.rec,\n     have hV : (opens.map (X.of_restrict hf).base).obj (hf.is_open_map.functor.obj V) = V,\n     { cases V, simp[opens.map, set.preimage_image_eq _ hf.inj] },\n     haveI : is_iso (hf.is_open_map.adjunction.counit.app\n               (unop (op (hf.is_open_map.functor.obj V)))) :=\n       (nat_iso.is_iso_app_of_is_iso (whisker_left\n         hf.is_open_map.functor hf.is_open_map.adjunction.counit) V : _),\n     have := PresheafedSpace.congr_app eq (op (hf.is_open_map.functor.obj V)),\n     simp only [PresheafedSpace.comp_c_app, PresheafedSpace.of_restrict_c_app, category.assoc,\n       cancel_epi] at this,\n     have h : _ ≫ _ = _ ≫ _ ≫ _ :=\n       congr_arg (λ f, (X.restrict hf).presheaf.map (eq_to_hom hV).op ≫ f) this,\n     erw [g₁.c.naturality, g₂.c.naturality_assoc] at h,\n     simp only [presheaf.pushforward_obj_map, eq_to_hom_op,\n       category.assoc, eq_to_hom_map, eq_to_hom_trans] at h,\n     rw ←is_iso.comp_inv_eq at h,\n     simpa using h },\n   { have := congr_arg PresheafedSpace.hom.base eq,\n     simp only [PresheafedSpace.comp_base, PresheafedSpace.of_restrict_base] at this,\n     rw cancel_mono at this,\n     exact this }\n end\n\n\n\nlemma of_restrict_top_c (X : PresheafedSpace C) :\n  (X.of_restrict (opens.open_embedding ⊤)).c = eq_to_hom\n    (by { rw [restrict_top_presheaf, ←presheaf.pushforward.comp_eq],\n          erw iso.inv_hom_id, rw presheaf.pushforward.id_eq }) :=\n  /- another approach would be to prove the left hand side\n     is a natural isoomorphism, but I encountered a universe\n     issue when `apply nat_iso.is_iso_of_is_iso_app`. -/\nbegin\n  ext U, change X.presheaf.map _ = _, convert eq_to_hom_map _ _ using 1,\n  congr, simpa,\n  { induction U using opposite.rec, dsimp, congr, ext,\n    exact ⟨ λ h, ⟨⟨x,trivial⟩,h,rfl⟩, λ ⟨⟨_,_⟩,h,rfl⟩, h ⟩ },\n  /- or `rw [opens.inclusion_top_functor, ←comp_obj, ←opens.map_comp_eq],\n         erw iso.inv_hom_id, cases U, refl` after `dsimp` -/\nend\n\n/--\nThe map to the restriction of a presheafed space along the canonical inclusion from the top\nsubspace.\n-/\n@[simps]\ndef to_restrict_top (X : PresheafedSpace C) :\n  X ⟶ X.restrict (opens.open_embedding ⊤) :=\n{ base := (opens.inclusion_top_iso X.carrier).inv,\n  c := eq_to_hom (restrict_top_presheaf X) }\n\n/--\nThe isomorphism from the restriction to the top subspace.\n-/\n@[simps]\ndef restrict_top_iso (X : PresheafedSpace C) :\n  X.restrict (opens.open_embedding ⊤) ≅ X :=\n{ hom := X.of_restrict _,\n  inv := X.to_restrict_top,\n  hom_inv_id' := ext _ _ (concrete_category.hom_ext _ _ $ λ ⟨x, _⟩, rfl) $\n    by { erw comp_c, rw X.of_restrict_top_c, ext, simp },\n  inv_hom_id' := ext _ _ rfl $\n    by { erw comp_c, rw X.of_restrict_top_c, ext, simpa [-eq_to_hom_refl] } }\n\nend restrict\n\n/--\nThe global sections, notated Gamma.\n-/\n@[simps]\ndef Γ : (PresheafedSpace C)ᵒᵖ ⥤ C :=\n{ obj := λ X, (unop X).presheaf.obj (op ⊤),\n  map := λ X Y f, f.unop.c.app (op ⊤) }\n\nlemma Γ_obj_op (X : PresheafedSpace C) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\nlemma Γ_map_op {X Y : PresheafedSpace C} (f : X ⟶ Y) :\n  Γ.map f.op = f.c.app (op ⊤) := rfl\n\nend PresheafedSpace\n\nend algebraic_geometry\n\nopen algebraic_geometry algebraic_geometry.PresheafedSpace\n\nvariables {C}\n\nnamespace category_theory\n\nvariables {D : Type u} [category.{v} D]\n\nlocal attribute [simp] presheaf.pushforward_obj\n\nnamespace functor\n\n/-- We can apply a functor `F : C ⥤ D` to the values of the presheaf in any `PresheafedSpace C`,\n    giving a functor `PresheafedSpace C ⥤ PresheafedSpace D` -/\ndef map_presheaf (F : C ⥤ D) : PresheafedSpace C ⥤ PresheafedSpace D :=\n{ obj := λ X, { carrier := X.carrier, presheaf := X.presheaf ⋙ F },\n  map := λ X Y f, { base := f.base, c := whisker_right f.c F }, }\n\n@[simp] lemma map_presheaf_obj_X (F : C ⥤ D) (X : PresheafedSpace C) :\n  ((F.map_presheaf.obj X) : Top.{v}) = (X : Top.{v}) := rfl\n@[simp] lemma map_presheaf_obj_presheaf (F : C ⥤ D) (X : PresheafedSpace C) :\n  (F.map_presheaf.obj X).presheaf = X.presheaf ⋙ F := rfl\n@[simp] lemma map_presheaf_map_f (F : C ⥤ D) {X Y : PresheafedSpace C} (f : X ⟶ Y) :\n  (F.map_presheaf.map f).base = f.base := rfl\n@[simp] lemma map_presheaf_map_c (F : C ⥤ D) {X Y : PresheafedSpace C} (f : X ⟶ Y) :\n  (F.map_presheaf.map f).c = whisker_right f.c F := rfl\n\nend functor\n\nnamespace nat_trans\n\n/--\nA natural transformation induces a natural transformation between the `map_presheaf` functors.\n-/\ndef on_presheaf {F G : C ⥤ D} (α : F ⟶ G) : G.map_presheaf ⟶ F.map_presheaf :=\n{ app := λ X,\n  { base := 𝟙 _,\n    c := whisker_left X.presheaf α ≫ eq_to_hom (presheaf.pushforward.id_eq _).symm } }\n\n-- TODO Assemble the last two constructions into a functor\n--   `(C ⥤ D) ⥤ (PresheafedSpace C ⥤ PresheafedSpace D)`\nend nat_trans\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebraic_geometry/presheafed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.4817503228095166}}
{"text": "/-\nCopyright (c) 2020 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz, Bhavik Mehta\n-/\n\nimport category_theory.adjunction.reflective\nimport topology.category.Top\nimport topology.stone_cech\nimport category_theory.monad.limits\n\n/-!\n\n# The category of Compact Hausdorff Spaces\n\nWe construct the category of compact Hausdorff spaces.\nThe type of compact Hausdorff spaces is denoted `CompHaus`, and it is endowed with a category\ninstance making it a full subcategory of `Top`.\nThe fully faithful functor `CompHaus ⥤ Top` is denoted `CompHaus_to_Top`.\n\n**Note:** The file `topology/category/Compactum.lean` provides the equivalence between `Compactum`,\nwhich is defined as the category of algebras for the ultrafilter monad, and `CompHaus`.\n`Compactum_to_CompHaus` is the functor from `Compactum` to `CompHaus` which is proven to be an\nequivalence of categories in `Compactum_to_CompHaus.is_equivalence`.\nSee `topology/category/Compactum.lean` for a more detailed discussion where these definitions are\nintroduced.\n\n-/\n\nuniverse u\n\nopen category_theory\n\n/-- The type of Compact Hausdorff topological spaces. -/\nstructure CompHaus :=\n(to_Top : Top)\n[is_compact : compact_space to_Top]\n[is_hausdorff : t2_space to_Top]\n\nnamespace CompHaus\n\ninstance : inhabited CompHaus := ⟨{to_Top := { α := pempty }}⟩\n\ninstance : has_coe_to_sort CompHaus := ⟨Type*, λ X, X.to_Top⟩\ninstance {X : CompHaus} : compact_space X := X.is_compact\ninstance {X : CompHaus} : t2_space X := X.is_hausdorff\n\ninstance category : category CompHaus := induced_category.category to_Top\n\ninstance concrete_category : concrete_category CompHaus :=\ninduced_category.concrete_category _\n\n@[simp]\nlemma coe_to_Top {X : CompHaus} : (X.to_Top : Type*) = X :=\nrfl\n\nvariables (X : Type*) [topological_space X] [compact_space X] [t2_space X]\n\n/-- A constructor for objects of the category `CompHaus`,\ntaking a type, and bundling the compact Hausdorff topology\nfound by typeclass inference. -/\ndef of : CompHaus :=\n{ to_Top := Top.of X,\n  is_compact := ‹_›,\n  is_hausdorff := ‹_› }\n\n@[simp] lemma coe_of : (CompHaus.of X : Type _) = X := rfl\n\n/-- Any continuous function on compact Hausdorff spaces is a closed map. -/\nlemma is_closed_map {X Y : CompHaus} (f : X ⟶ Y) : is_closed_map f :=\nλ C hC, (hC.compact.image f.continuous).is_closed\n\n/-- Any continuous bijection of compact Hausdorff spaces is an isomorphism. -/\nlemma is_iso_of_bijective {X Y : CompHaus} (f : X ⟶ Y) (bij : function.bijective f) : is_iso f :=\nbegin\n  let E := equiv.of_bijective _ bij,\n  have hE : continuous E.symm,\n  { rw continuous_iff_is_closed,\n    intros S hS,\n    rw ← E.image_eq_preimage,\n    exact is_closed_map f S hS },\n  refine ⟨⟨⟨E.symm, hE⟩, _, _⟩⟩,\n  { ext x,\n    apply E.symm_apply_apply },\n  { ext x,\n    apply E.apply_symm_apply }\nend\n\n/-- Any continuous bijection of compact Hausdorff spaces induces an isomorphism. -/\nnoncomputable\ndef iso_of_bijective {X Y : CompHaus} (f : X ⟶ Y) (bij : function.bijective f) : X ≅ Y :=\nby letI := is_iso_of_bijective _ bij; exact as_iso f\n\nend CompHaus\n\n/-- The fully faithful embedding of `CompHaus` in `Top`. -/\n@[simps {rhs_md := semireducible}, derive [full, faithful]]\ndef CompHaus_to_Top : CompHaus.{u} ⥤ Top.{u} := induced_functor _\n\ninstance CompHaus.forget_reflects_isomorphisms : reflects_isomorphisms (forget CompHaus) :=\n⟨by introsI A B f hf; exact CompHaus.is_iso_of_bijective _ ((is_iso_iff_bijective ⇑f).mp hf)⟩\n\n/--\n(Implementation) The object part of the compactification functor from topological spaces to\ncompact Hausdorff spaces.\n-/\n@[simps]\ndef StoneCech_obj (X : Top) : CompHaus := CompHaus.of (stone_cech X)\n\n/--\n(Implementation) The bijection of homsets to establish the reflective adjunction of compact\nHausdorff spaces in topological spaces.\n-/\nnoncomputable def stone_cech_equivalence (X : Top) (Y : CompHaus) :\n  (StoneCech_obj X ⟶ Y) ≃ (X ⟶ CompHaus_to_Top.obj Y) :=\n{ to_fun := λ f,\n  { to_fun := f ∘ stone_cech_unit,\n    continuous_to_fun := f.2.comp (@continuous_stone_cech_unit X _) },\n  inv_fun := λ f,\n  { to_fun := stone_cech_extend f.2,\n    continuous_to_fun := continuous_stone_cech_extend f.2 },\n  left_inv :=\n  begin\n    rintro ⟨f : stone_cech X ⟶ Y, hf : continuous f⟩,\n    ext (x : stone_cech X),\n    refine congr_fun _ x,\n    apply continuous.ext_on dense_range_stone_cech_unit (continuous_stone_cech_extend _) hf,\n    rintro _ ⟨y, rfl⟩,\n    apply congr_fun (stone_cech_extend_extends (hf.comp _)) y,\n  end,\n  right_inv :=\n  begin\n    rintro ⟨f : ↥X ⟶ Y, hf : continuous f⟩,\n    ext,\n    exact congr_fun (stone_cech_extend_extends hf) x,\n  end }\n\n/--\nThe Stone-Cech compactification functor from topological spaces to compact Hausdorff spaces,\nleft adjoint to the inclusion functor.\n-/\nnoncomputable def Top_to_CompHaus : Top.{u} ⥤ CompHaus.{u} :=\nadjunction.left_adjoint_of_equiv stone_cech_equivalence.{u u} (λ _ _ _ _ _, rfl)\n\nlemma Top_to_CompHaus_obj (X : Top) : ↥(Top_to_CompHaus.obj X) = stone_cech X :=\nrfl\n\n/--\nThe category of compact Hausdorff spaces is reflective in the category of topological spaces.\n-/\nnoncomputable instance CompHaus_to_Top.reflective : reflective CompHaus_to_Top :=\n{ to_is_right_adjoint := ⟨Top_to_CompHaus, adjunction.adjunction_of_equiv_left _ _⟩ }\n\nnoncomputable instance CompHaus_to_Top.creates_limits : creates_limits CompHaus_to_Top :=\nmonadic_creates_limits _\n\ninstance CompHaus.has_limits : limits.has_limits CompHaus :=\nhas_limits_of_has_limits_creates_limits CompHaus_to_Top\n\ninstance CompHaus.has_colimits : limits.has_colimits CompHaus :=\nhas_colimits_of_reflective CompHaus_to_Top\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/category/CompHaus.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.48175032214301494}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.functor.epi_mono\n! leanprover-community/mathlib commit 32253a1a1071173b33dc7d6a218cf722c6feb514\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.EpiMono\nimport Mathlib.CategoryTheory.Limits.Shapes.StrongEpi\nimport Mathlib.CategoryTheory.LiftingProperties.Adjunction\n\n/-!\n# Preservation and reflection of monomorphisms and epimorphisms\n\nWe provide typeclasses that state that a functor preserves or reflects monomorphisms or\nepimorphisms.\n-/\n\n\nopen CategoryTheory\n\nuniverse v₁ v₂ v₃ u₁ u₂ u₃\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] {E : Type u₃}\n  [Category.{v₃} E]\n\n/-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/\nclass PreservesMonomorphisms (F : C ⥤ D) : Prop where\n  /-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/\n  preserves : ∀ {X Y : C} (f : X ⟶ Y) [Mono f], Mono (F.map f)\n#align category_theory.functor.preserves_monomorphisms CategoryTheory.Functor.PreservesMonomorphisms\n\ninstance map_mono (F : C ⥤ D) [PreservesMonomorphisms F] {X Y : C} (f : X ⟶ Y) [Mono f] :\n    Mono (F.map f) :=\n  PreservesMonomorphisms.preserves f\n#align category_theory.functor.map_mono CategoryTheory.Functor.map_mono\n\n/-- A functor preserves epimorphisms if it maps epimorphisms to epimorphisms. -/\nclass PreservesEpimorphisms (F : C ⥤ D) : Prop where\n  /-- A functor preserves epimorphisms if it maps epimorphisms to epimorphisms. -/\n  preserves : ∀ {X Y : C} (f : X ⟶ Y) [Epi f], Epi (F.map f)\n#align category_theory.functor.preserves_epimorphisms CategoryTheory.Functor.PreservesEpimorphisms\n\ninstance map_epi (F : C ⥤ D) [PreservesEpimorphisms F] {X Y : C} (f : X ⟶ Y) [Epi f] :\n    Epi (F.map f) :=\n  PreservesEpimorphisms.preserves f\n#align category_theory.functor.map_epi CategoryTheory.Functor.map_epi\n\n/-- A functor reflects monomorphisms if morphisms that are mapped to monomorphisms are themselves\n    monomorphisms. -/\nclass ReflectsMonomorphisms (F : C ⥤ D) : Prop where\n   /-- A functor reflects monomorphisms if morphisms that are mapped to monomorphisms are themselves\n    monomorphisms. -/\n  reflects : ∀ {X Y : C} (f : X ⟶ Y), Mono (F.map f) → Mono f\n#align category_theory.functor.reflects_monomorphisms CategoryTheory.Functor.ReflectsMonomorphisms\n\ntheorem mono_of_mono_map (F : C ⥤ D) [ReflectsMonomorphisms F] {X Y : C} {f : X ⟶ Y}\n    (h : Mono (F.map f)) : Mono f :=\n  ReflectsMonomorphisms.reflects f h\n#align category_theory.functor.mono_of_mono_map CategoryTheory.Functor.mono_of_mono_map\n\n/-- A functor reflects epimorphisms if morphisms that are mapped to epimorphisms are themselves\n    epimorphisms. -/\nclass ReflectsEpimorphisms (F : C ⥤ D) : Prop where\n  /-- A functor reflects epimorphisms if morphisms that are mapped to epimorphisms are themselves\n      epimorphisms. -/\n  reflects : ∀ {X Y : C} (f : X ⟶ Y), Epi (F.map f) → Epi f\n#align category_theory.functor.reflects_epimorphisms CategoryTheory.Functor.ReflectsEpimorphisms\n\ntheorem epi_of_epi_map (F : C ⥤ D) [ReflectsEpimorphisms F] {X Y : C} {f : X ⟶ Y}\n    (h : Epi (F.map f)) : Epi f :=\n  ReflectsEpimorphisms.reflects f h\n#align category_theory.functor.epi_of_epi_map CategoryTheory.Functor.epi_of_epi_map\n\ninstance preservesMonomorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [PreservesMonomorphisms F]\n    [PreservesMonomorphisms G] : PreservesMonomorphisms (F ⋙ G) where\n  preserves f h := by\n    rw [comp_map]\n    exact inferInstance\n#align category_theory.functor.preserves_monomorphisms_comp CategoryTheory.Functor.preservesMonomorphisms_comp\n\ninstance preservesEpimorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [PreservesEpimorphisms F]\n    [PreservesEpimorphisms G] : PreservesEpimorphisms (F ⋙ G) where\n  preserves f h := by\n    rw [comp_map]\n    exact inferInstance\n#align category_theory.functor.preserves_epimorphisms_comp CategoryTheory.Functor.preservesEpimorphisms_comp\n\ninstance reflectsMonomorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [ReflectsMonomorphisms F]\n    [ReflectsMonomorphisms G] : ReflectsMonomorphisms (F ⋙ G) where\n  reflects _ h := F.mono_of_mono_map (G.mono_of_mono_map h)\n#align category_theory.functor.reflects_monomorphisms_comp CategoryTheory.Functor.reflectsMonomorphisms_comp\n\ninstance reflectsEpimorphisms_comp (F : C ⥤ D) (G : D ⥤ E) [ReflectsEpimorphisms F]\n    [ReflectsEpimorphisms G] : ReflectsEpimorphisms (F ⋙ G) where\n  reflects _ h := F.epi_of_epi_map (G.epi_of_epi_map h)\n#align category_theory.functor.reflects_epimorphisms_comp CategoryTheory.Functor.reflectsEpimorphisms_comp\n\n\n\ntheorem preservesMonomorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)\n    [PreservesMonomorphisms (F ⋙ G)] [ReflectsMonomorphisms G] : PreservesMonomorphisms F :=\n  ⟨fun f _ => G.mono_of_mono_map <| show Mono ((F ⋙ G).map f) from inferInstance⟩\n#align category_theory.functor.preserves_monomorphisms_of_preserves_of_reflects CategoryTheory.Functor.preservesMonomorphisms_of_preserves_of_reflects\n\ntheorem reflectsEpimorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)\n    [PreservesEpimorphisms G] [ReflectsEpimorphisms (F ⋙ G)] : ReflectsEpimorphisms F :=\n  ⟨fun f _ => (F ⋙ G).epi_of_epi_map <| show Epi (G.map (F.map f)) from inferInstance⟩\n#align category_theory.functor.reflects_epimorphisms_of_preserves_of_reflects CategoryTheory.Functor.reflectsEpimorphisms_of_preserves_of_reflects\n\ntheorem reflectsMonomorphisms_of_preserves_of_reflects (F : C ⥤ D) (G : D ⥤ E)\n    [PreservesMonomorphisms G] [ReflectsMonomorphisms (F ⋙ G)] : ReflectsMonomorphisms F :=\n  ⟨fun f _ => (F ⋙ G).mono_of_mono_map <| show Mono (G.map (F.map f)) from inferInstance⟩\n#align category_theory.functor.reflects_monomorphisms_of_preserves_of_reflects CategoryTheory.Functor.reflectsMonomorphisms_of_preserves_of_reflects\n\ntheorem preservesMonomorphisms.of_iso {F G : C ⥤ D} [PreservesMonomorphisms F] (α : F ≅ G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun {X} {Y} f h =>\n      by\n      haveI : Mono (F.map f ≫ (α.app Y).hom) := mono_comp _ _\n      convert (mono_comp _ _ : Mono ((α.app X).inv ≫ F.map f ≫ (α.app Y).hom))\n      rw [Iso.eq_inv_comp, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }\n#align category_theory.functor.preserves_monomorphisms.of_iso CategoryTheory.Functor.preservesMonomorphisms.of_iso\n\ntheorem preservesMonomorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    PreservesMonomorphisms F ↔ PreservesMonomorphisms G :=\n  ⟨fun _ => preservesMonomorphisms.of_iso α, fun _ => preservesMonomorphisms.of_iso α.symm⟩\n#align category_theory.functor.preserves_monomorphisms.iso_iff CategoryTheory.Functor.preservesMonomorphisms.iso_iff\n\ntheorem preservesEpimorphisms.of_iso {F G : C ⥤ D} [PreservesEpimorphisms F] (α : F ≅ G) :\n    PreservesEpimorphisms G :=\n  {\n    preserves := fun {X} {Y} f h =>\n      by\n      haveI : Epi (F.map f ≫ (α.app Y).hom) := epi_comp _ _\n      convert (epi_comp _ _ : Epi ((α.app X).inv ≫ F.map f ≫ (α.app Y).hom))\n      rw [Iso.eq_inv_comp, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }\n#align category_theory.functor.preserves_epimorphisms.of_iso CategoryTheory.Functor.preservesEpimorphisms.of_iso\n\ntheorem preservesEpimorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    PreservesEpimorphisms F ↔ PreservesEpimorphisms G :=\n  ⟨fun _ => preservesEpimorphisms.of_iso α, fun _ => preservesEpimorphisms.of_iso α.symm⟩\n#align category_theory.functor.preserves_epimorphisms.iso_iff CategoryTheory.Functor.preservesEpimorphisms.iso_iff\n\ntheorem reflectsMonomorphisms.of_iso {F G : C ⥤ D} [ReflectsMonomorphisms F] (α : F ≅ G) :\n    ReflectsMonomorphisms G :=\n  {\n    reflects := fun {X} {Y} f h => by\n      apply F.mono_of_mono_map\n      haveI : Mono (G.map f ≫ (α.app Y).inv) := mono_comp _ _\n      convert (mono_comp _ _ : Mono ((α.app X).hom ≫ G.map f ≫ (α.app Y).inv))\n      rw [← Category.assoc, Iso.eq_comp_inv, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }\n#align category_theory.functor.reflects_monomorphisms.of_iso CategoryTheory.Functor.reflectsMonomorphisms.of_iso\n\ntheorem reflectsMonomorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    ReflectsMonomorphisms F ↔ ReflectsMonomorphisms G :=\n  ⟨fun _ => reflectsMonomorphisms.of_iso α, fun _ => reflectsMonomorphisms.of_iso α.symm⟩\n#align category_theory.functor.reflects_monomorphisms.iso_iff CategoryTheory.Functor.reflectsMonomorphisms.iso_iff\n\ntheorem reflectsEpimorphisms.of_iso {F G : C ⥤ D} [ReflectsEpimorphisms F] (α : F ≅ G) :\n    ReflectsEpimorphisms G :=\n  {\n    reflects := fun {X} {Y} f h => by\n      apply F.epi_of_epi_map\n      haveI : Epi (G.map f ≫ (α.app Y).inv) := epi_comp _ _\n      convert (epi_comp _ _ : Epi ((α.app X).hom ≫ G.map f ≫ (α.app Y).inv))\n      rw [← Category.assoc, Iso.eq_comp_inv, Iso.app_hom, Iso.app_hom, NatTrans.naturality] }\n#align category_theory.functor.reflects_epimorphisms.of_iso CategoryTheory.Functor.reflectsEpimorphisms.of_iso\n\ntheorem reflectsEpimorphisms.iso_iff {F G : C ⥤ D} (α : F ≅ G) :\n    ReflectsEpimorphisms F ↔ ReflectsEpimorphisms G :=\n  ⟨fun _ => reflectsEpimorphisms.of_iso α, fun _ => reflectsEpimorphisms.of_iso α.symm⟩\n#align category_theory.functor.reflects_epimorphisms.iso_iff CategoryTheory.Functor.reflectsEpimorphisms.iso_iff\n\ntheorem preservesEpimorphsisms_of_adjunction {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :\n    PreservesEpimorphisms F :=\n  {\n    preserves := fun {X} {Y} f hf =>\n      ⟨by\n        intro Z g h H\n        replace H := congr_arg (adj.homEquiv X Z) H\n        rwa [adj.homEquiv_naturality_left, adj.homEquiv_naturality_left, cancel_epi,\n          Equiv.apply_eq_iff_eq] at H⟩ }\n#align category_theory.functor.preserves_epimorphsisms_of_adjunction CategoryTheory.Functor.preservesEpimorphsisms_of_adjunction\n\ninstance (priority := 100) preservesEpimorphisms_of_isLeftAdjoint (F : C ⥤ D) [IsLeftAdjoint F] :\n    PreservesEpimorphisms F :=\n  preservesEpimorphsisms_of_adjunction (Adjunction.ofLeftAdjoint F)\n#align category_theory.functor.preserves_epimorphisms_of_is_left_adjoint CategoryTheory.Functor.preservesEpimorphisms_of_isLeftAdjoint\n\ntheorem preservesMonomorphisms_of_adjunction {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun {X} {Y} f hf =>\n      ⟨by\n        intro Z g h H\n        replace H := congr_arg (adj.homEquiv Z Y).symm H\n        rwa [adj.homEquiv_naturality_right_symm, adj.homEquiv_naturality_right_symm, cancel_mono,\n          Equiv.apply_eq_iff_eq] at H⟩ }\n#align category_theory.functor.preserves_monomorphisms_of_adjunction CategoryTheory.Functor.preservesMonomorphisms_of_adjunction\n\ninstance (priority := 100) preservesMonomorphisms_of_isRightAdjoint (F : C ⥤ D) [IsRightAdjoint F] :\n    PreservesMonomorphisms F :=\n  preservesMonomorphisms_of_adjunction (Adjunction.ofRightAdjoint F)\n#align category_theory.functor.preserves_monomorphisms_of_is_right_adjoint CategoryTheory.Functor.preservesMonomorphisms_of_isRightAdjoint\n\ninstance (priority := 100) reflectsMonomorphisms_of_faithful (F : C ⥤ D) [Faithful F] :\n    ReflectsMonomorphisms F\n    where reflects {X} {Y} f hf :=\n    ⟨fun {Z} g h hgh =>\n      F.map_injective ((cancel_mono (F.map f)).1 (by rw [← F.map_comp, hgh, F.map_comp]))⟩\n#align category_theory.functor.reflects_monomorphisms_of_faithful CategoryTheory.Functor.reflectsMonomorphisms_of_faithful\n\ninstance (priority := 100) reflectsEpimorphisms_of_faithful (F : C ⥤ D) [Faithful F] :\n    ReflectsEpimorphisms F\n    where reflects {X} {Y} f hf :=\n    ⟨fun {Z} g h hgh =>\n      F.map_injective ((cancel_epi (F.map f)).1 (by rw [← F.map_comp, hgh, F.map_comp]))⟩\n#align category_theory.functor.reflects_epimorphisms_of_faithful CategoryTheory.Functor.reflectsEpimorphisms_of_faithful\n\nsection\n\nvariable (F : C ⥤ D) {X Y : C} (f : X ⟶ Y)\n\n/-- If `F` is a fully faithful functor, split epimorphisms are preserved and reflected by `F`. -/\ndef splitEpiEquiv [Full F] [Faithful F] : SplitEpi f ≃ SplitEpi (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' ⟨F.preimage s.section_, _⟩\n    apply F.map_injective\n    simp only [map_comp, image_preimage, map_id]\n    apply SplitEpi.id\n  left_inv := by aesop_cat\n  right_inv := by\n      simp only [Function.RightInverse,Function.LeftInverse]\n      intro x\n      simp only [SplitEpi.map, preimage]\n      aesop_cat\n#align category_theory.functor.split_epi_equiv CategoryTheory.Functor.splitEpiEquiv\n\n@[simp]\ntheorem isSplitEpi_iff [Full F] [Faithful F] : IsSplitEpi (F.map f) ↔ IsSplitEpi f := by\n  constructor\n  · intro h\n    exact IsSplitEpi.mk' ((splitEpiEquiv F f).invFun h.exists_splitEpi.some)\n  · intro h\n    exact IsSplitEpi.mk' ((splitEpiEquiv F f).toFun h.exists_splitEpi.some)\n#align category_theory.functor.is_split_epi_iff CategoryTheory.Functor.isSplitEpi_iff\n\n/-- If `F` is a fully faithful functor, split monomorphisms are preserved and reflected by `F`. -/\ndef splitMonoEquiv [Full F] [Faithful F] : SplitMono f ≃ SplitMono (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' ⟨F.preimage s.retraction, _⟩\n    apply F.map_injective\n    simp only [map_comp, image_preimage, map_id]\n    apply SplitMono.id\n  left_inv := by aesop_cat\n  right_inv := by\n    simp only [Function.RightInverse, Function.LeftInverse]\n    intro x\n    simp only [SplitMono.map,preimage]\n    aesop_cat\n\n#align category_theory.functor.split_mono_equiv CategoryTheory.Functor.splitMonoEquiv\n\n@[simp]\ntheorem isSplitMono_iff [Full F] [Faithful F] : IsSplitMono (F.map f) ↔ IsSplitMono f := by\n  constructor\n  · intro h\n    exact IsSplitMono.mk' ((splitMonoEquiv F f).invFun h.exists_splitMono.some)\n  · intro h\n    exact IsSplitMono.mk' ((splitMonoEquiv F f).toFun h.exists_splitMono.some)\n#align category_theory.functor.is_split_mono_iff CategoryTheory.Functor.isSplitMono_iff\n\n@[simp]\ntheorem epi_map_iff_epi [hF₁ : PreservesEpimorphisms F] [hF₂ : ReflectsEpimorphisms F] :\n    Epi (F.map f) ↔ Epi f := by\n  constructor\n  · exact F.epi_of_epi_map\n  · intro h\n    exact F.map_epi f\n#align category_theory.functor.epi_map_iff_epi CategoryTheory.Functor.epi_map_iff_epi\n\n@[simp]\ntheorem mono_map_iff_mono [hF₁ : PreservesMonomorphisms F] [hF₂ : ReflectsMonomorphisms F] :\n    Mono (F.map f) ↔ Mono f := by\n  constructor\n  · exact F.mono_of_mono_map\n  · intro h\n    exact F.map_mono f\n#align category_theory.functor.mono_map_iff_mono CategoryTheory.Functor.mono_map_iff_mono\n\n/-- If `F : C ⥤ D` is an equivalence of categories and `C` is a `split_epi_category`,\nthen `D` also is. -/\ndef splitEpiCategoryImpOfIsEquivalence [IsEquivalence F] [SplitEpiCategory C] :\n    SplitEpiCategory D :=\n  ⟨fun {X} {Y} f => by\n    intro\n    rw [← F.inv.isSplitEpi_iff f]\n    apply isSplitEpi_of_epi⟩\n#align category_theory.functor.split_epi_category_imp_of_is_equivalence CategoryTheory.Functor.splitEpiCategoryImpOfIsEquivalence\n\nend\n\nend CategoryTheory.Functor\n\nnamespace CategoryTheory.Adjunction\n\nvariable {C D : Type _} [Category C] [Category D] {F : C ⥤ D} {F' : D ⥤ C} {A B : C}\n\ntheorem strongEpi_map_of_strongEpi (adj : F ⊣ F') (f : A ⟶ B) [h₁ : F'.PreservesMonomorphisms]\n    [h₂ : F.PreservesEpimorphisms] [StrongEpi f] : StrongEpi (F.map f) :=\n  ⟨inferInstance, fun X Y Z => by\n    intro\n    rw [adj.hasLiftingProperty_iff]\n    infer_instance⟩\n#align category_theory.adjunction.strong_epi_map_of_strong_epi CategoryTheory.Adjunction.strongEpi_map_of_strongEpi\n\ninstance strongEpi_map_of_isEquivalence [IsEquivalence F] (f : A ⟶ B) [_h : StrongEpi f] :\n    StrongEpi (F.map f) :=\n  F.asEquivalence.toAdjunction.strongEpi_map_of_strongEpi f\n#align category_theory.adjunction.strong_epi_map_of_is_equivalence CategoryTheory.Adjunction.strongEpi_map_of_isEquivalence\n\nend CategoryTheory.Adjunction\n\nnamespace CategoryTheory.Functor\n\nvariable {C D : Type _} [Category C] [Category D] {F : C ⥤ D} {A B : C} (f : A ⟶ B)\n\n@[simp]\ntheorem strongEpi_map_iff_strongEpi_of_isEquivalence [IsEquivalence F] :\n    StrongEpi (F.map f) ↔ StrongEpi f := by\n  constructor\n  · intro\n    have e : Arrow.mk f ≅ Arrow.mk (F.inv.map (F.map f)) :=\n      Arrow.isoOfNatIso F.asEquivalence.unitIso (Arrow.mk f)\n    rw [StrongEpi.iff_of_arrow_iso e]\n    infer_instance\n  · intro\n    infer_instance\n#align category_theory.functor.strong_epi_map_iff_strong_epi_of_is_equivalence CategoryTheory.Functor.strongEpi_map_iff_strongEpi_of_isEquivalence\n\nend CategoryTheory.Functor\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Functor/EpiMono.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.48175031758563763}}
{"text": "import tactic\n\nopen tactic\n\n/-!\n\nThis file contains three tactic-programming exercises of increasing difficulty.\n\nThey were (hastily) written to follow the metaprogramming tutorial at\nLean for the Curious Mathematician 2020.\n\nIf you're looking for more (better) exercises, we strongly recommend the\nexercises by Blanchette et al\nfor the course Logical Verification at the Vrije Universiteit Amsterdam,\nand the corresponding chapter of the course notes:\n\nhttps://github.com/blanchette/logical_verification_2020/blob/master/lean/love07_metaprogramming_exercise_sheet.lean\nhttps://github.com/blanchette/logical_verification_2020/raw/master/hitchhikers_guide.pdf\n\n\n\n## Exercise 1\n\nWrite a `contradiction` tactic.\nThe tactic should look through the hypotheses in the local context\ntrying to find two that contradict each other,\ni.e. proving `P` and `¬ P` for some proposition `P`.\nIt should use this contradiction to close the goal.\n\nBonus: handle `P → false` as well as `¬ P`.\n\nThis exercise is to practice manipulating the hypotheses and goal.\n\nNote: this exists as `tactic.interactive.contradiction`.\n\n-/\n\nmeta def tactic.interactive.contr : tactic unit := sorry\n\n-- it only costs a factor of two to check all pairs, let's start with that\n-- mmap reduces to the case of having one expr and checking for a contradiction\n-- to start, can we just trace the pair h, p for all p in the context\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hnq : ¬ Q) : false :=\nby contr\n\n\nexample (P Q R : Prop) (hnq : ¬ Q) (hp : P) (hq : Q) (hr : ¬ R) : 0 = 1 :=\nby contr\n\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hnq : Q → false) : false :=\nby contr\n\n\n\n/-!\n\n## Exercise 2\n\nWrite a tactic that proves a given `nat`-valued declaration is nonnegative.\nThe tactic should take the name of a declaration whose return type is `ℕ`\n(presumably with some arguments), e.g. `nat.add : ℕ → ℕ → ℕ`\nor `list.length : Π α : Type, list α → ℕ`.\nIt should add a new declaration to the environment which proves all applications\nof this function are nonnegative,\ne.g. `nat.add_nonneg : ∀ m n : ℕ, 0 ≤ nat.add m n`.\n\nBonus: create reasonable names for these declarations, and/or take an optional argument\nfor the new name.\n\nThis tactic is not useful by itself, but it's a good way to practice\nquerying and modifying an environment and working under binders.\nIt is not a tactic to be used during a proof, but rather as a command.\n\n\nHints:\n* For looking at declarations in the environment, you will need the `declaration` type,\n  as well as the tactics `get_decl` and `add_decl`.\n* You will have to manipulate an expression under binders.\n  The tactics `mk_local_pis` and `pis`, or their lambda equivalents, will be helpful here.\n* `mk_mapp` is a variant of `mk_app` that lets you provide implicit arguments.\n-/\n\n\nmeta def add_nonneg_proof (n : name) : tactic unit := sorry\n\nrun_cmd add_nonneg_proof `nat.add\nrun_cmd add_nonneg_proof `list.length\n\n#check nat.add_nonneg\n#check list.length_nonneg\n\n\n/-!\n\n## Exercise 3 (challenge!)\n\nThe mathlib tactic `cancel_denoms` is intended to get rid of division by numerals\nin expressions where this makes sense. For example,\n\n-/\n\nexample (q : ℚ) (h : q / 3 > 0) : q > 0 :=\nbegin\n  cancel_denoms at h, exact h\nend\n\n/-!\n\nBut it is not complete. In particular, it doesn't like nested division\nor other operators in denominators. These all fail:\n\n-/\n\nexample (q : ℚ) (h : q / (3 / 4) > 0) : false :=\nbegin\n  cancel_denoms at h,\nend\n\nexample (p q : ℚ) (h : q / 2 / 3 < q) : false :=\nbegin\n  cancel_denoms at h,\nend\n\nexample (p q : ℚ) (h : q / 2 < 3 / (4*q)) : false :=\nbegin\n  cancel_denoms at h,\nend\n\n-- this one succeeds but doesn't do what it should\nexample (p q : ℚ) (h : q / (2*3) < q) : false :=\nbegin\n  cancel_denoms at h,\nend\n\n/-!\n\nLook at the code in `src/tactic/cancel_denoms.lean` and try to fix it.\nSee if you can solve any or all of these failing test cases.\n\nIf you succeed, a pull request to mathlib is strongly encouraged!\n\n-/\n", "meta": {"author": "apurvanakade", "repo": "mc2020-lean-projects", "sha": "02466225aa629ab1232043bcc0a053a099fdb939", "save_path": "github-repos/lean/apurvanakade-mc2020-lean-projects", "path": "github-repos/lean/apurvanakade-mc2020-lean-projects/mc2020-lean-projects-02466225aa629ab1232043bcc0a053a099fdb939/src/nitin+maya/lftcm2020_exercises.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7879311931529758, "lm_q1q2_score": 0.48172692768988123}}
{"text": "import data.zmod.basic subgroup.cyclic data.vector2\n\n-- Lists of n elements of a group whose product is 1\n\n-- lists will be modelled as functions `fin n → M` with (n : ℕ)\n-- and M a group (or a monoid)\n\n-- In this file I am going to define a predicate `prod_eq_one`\n-- on `fin n → M`, and I am going to define a bijection `S`\n-- of `fin n → M` (in fact an `equiv`) and I'm going to show\n-- that its n'th power is 1.\n\n/-! ## equiv stuff : stuff which is \"the same\". -/\ndef fin.to_zmod {n : ℕ} (a : fin n.succ) : zmod n.succ := a\ndef zmod.to_fin {n : ℕ} (a : zmod n.succ) : fin n.succ := a\n\n-- if we are only thinking of ℕ as an ordered set then these ideas are \"the same\"\ndef fin.equiv_zmod {n : ℕ} : fin n.succ ≃ zmod n.succ := equiv.refl _\n\ndef zmod.S {m : ℕ} : zmod m ≃ zmod m := \n  ⟨λ n, n + 1, λ n, n - 1, by { intro _, simp }, by { intro _, simp }⟩\n\nlemma list.ext' {n : ℕ} {α : Type} {L M : list α} (hL : L.length = n)\n  (hM : M.length = n) (hLM : ∀ (i : fin n),\n    L.nth_le i.1 (hL.symm ▸ i.2) = M.nth_le i.1 (hM.symm ▸ i.2)) : L = M :=\nbegin\n  suffices : (⟨L, hL⟩ : vector α n) = ⟨M, hM⟩,\n    exact subtype.mk.inj this,\n  exact vector.ext (λ i, hLM i),\nend\n\nlemma vector.to_list.succ (n : ℕ) (M : Type) (v : vector M n.succ) :\nv.to_list = v.nth 0 :: list.of_fn\n  (λ (i : fin n), v.nth i.succ : fin n → M) :=\nbegin\n  have h1 : v.to_list.length = n.succ := by simp,  \n  have h2 : (list.cons (v.nth 0) (list.of_fn (λ (i : fin n), v.nth (i.succ)))).length = n.succ,\n  simp,\n  apply list.ext' h1 h2,\n  intros i,\n  by_cases hi : i = 0,\n  { subst hi, \n    suffices : v.to_list.nth_le 0 _ = v.head,\n      simpa,\n    rcases v with ⟨_ | ⟨v_val_hd, _⟩⟩,\n    { suffices : 0 = n.succ,\n        cases this,\n      rw ←h1, simp },\n    { simp, refl } },\n  { -- i ≠ 0\n    have hj : ∃ j : fin n, i = j.succ,\n    { have hi3 : i.val - 1 < n,\n        have hi2 : i.val < n.succ := i.is_lt, \n        have hi' : i.val ≠ 0,\n          cases i, intro hp, apply hi, ext, rw hp, refl,\n        generalize hk : i.val = k,\n        rw hk at hi2 hi',\n        omega,\n      use ⟨_, hi3⟩,\n      cases i with i hin,\n      simp,\n      ext,\n      simp,\n      have hi4 : i ≠ 0,\n        rintro rfl,apply hi,refl,\n      rw nat.succ_eq_add_one,\n      have hi5 : 0 < i,\n        exact nat.pos_of_ne_zero hi4,\n      apply (nat.sub_add_cancel _).symm,\n      linarith },\n    rcases hj with ⟨⟨j,hj⟩, rfl⟩,\n    suffices : v.to_list.nth_le j.succ (h1.symm ▸ _) = v.nth (⟨j, hj⟩ : fin n).succ,\n      simpa,\n    rcases v with ⟨_ | ⟨hd,tl⟩⟩,\n    { cases h1 },\n    simp [vector.nth] },\nend\n\nlemma vector.to_list.succ' (n : ℕ) (M : Type) (v : vector M n.succ) :\nv.to_list = list.of_fn\n  (λ (i : fin n), v.nth i.cast_succ : fin n → M) ++ [v.nth ⟨n, nat.lt_succ_self _⟩] :=\nbegin\n  have ht1 : v.to_list.length = n.succ := by simp,\n  apply list.ext' ht1,\n  { rintro ⟨i, hi⟩,\n    by_cases h : i < n,\n    { rw list.nth_le_append,\n      { simp,\n        suffices : v.to_list.nth_le i _ = v.nth ⟨i, hi⟩,\n          convert this,\n          convert h,\n          simp,\n        cases v with L hL,\n        refl,\n      } },\n    have hin : i = n,\n      rw nat.succ_eq_add_one at hi,\n      linarith,\n    subst hin,\n    rw list.nth_le_append_right,\n    simp,\n    cases v, refl, simp },\n  { simp }\nend\n\nsection list\n\nvariables {G : Type} [mygroup.group G]\n\ndef list.prod' : list G → G\n| [] := 1\n| (h :: tl) := h * list.prod' tl \n\n@[simp] lemma list.prod_nil' : list.prod' ([] : list G) = 1 := rfl\n\n@[simp] lemma list.prod_cons' (h : G) (tl : list G) :\n  list.prod' (h :: tl) = h * list.prod' tl := rfl\n\nlemma list.prod_append' (a b : list G) : (a ++ b).prod' = a.prod' * b.prod' :=\nbegin\n  induction a with d hd I,\n  { simp },\n  { simp [*, mygroup.group.mul_assoc] },\nend\n\nlemma list.prod_singleton' (g : G) : [g].prod' = g :=\nbegin\n  exact mygroup.group.mul_one g,\nend\n\nlemma list.prod_repeat' (d : ℕ) (g : G) : (list.repeat g d).prod' = g ^ (d : ℤ) :=\nbegin\n  induction d with e he,\n    { refl },\n    { suffices : g * (list.repeat g e).prod' = g ^ ((e  : ℤ) + 1),\n        simpa [list.prod'],\n      rw [he, add_comm, mygroup.group.pow_add, mygroup.group.pow_one] }\nend\n\nend list\n\nnamespace mygroup\n\nvariables {G : Type} [group G]\n\n/-! ## The Predicate -/\n/-- The type of vectors with terms from `G`, length `n`, and product equal to `1:G`. -/\ndef finmap.prod_eq_one {n : ℕ} : set (fin n → G) :=\nλ f, (vector.of_fn f).to_list.prod' = 1\n\nlemma mem_finmap_prod_eq_one {n : ℕ} (v : fin n → G) :\n  v ∈ (finmap.prod_eq_one : set (fin n → G)) ↔ (vector.of_fn v).to_list.prod' = 1 :=\niff.rfl\n\nvariables {n : ℕ}\n\ndef fin.S.succ {n : ℕ} : fin n.succ ≃ fin n.succ :=\ncalc\nfin n.succ ≃ zmod n.succ : fin.equiv_zmod\n...         ≃ zmod n.succ : zmod.S\n...         ≃ fin n.succ : fin.equiv_zmod.symm\n\ndef fin.S.succ' (n : ℕ) := @fin.S.succ n\n\n-- I never use the next two things.\ndef fin.S.zero : fin 0 ≃ fin 0 := equiv.refl _\n\ndef fin.S (n : ℕ) : fin n ≃ fin n := nat.rec_on n fin.S.zero (λ d IH,\n  fin.S.succ)\n\n/-- the twist by fin.S.succ preserves the property that prod eq one -/\ntheorem finmap.prod_eq_one_succ {f : fin n.succ → G} :\nfinmap.prod_eq_one f → finmap.prod_eq_one (f ∘ fin.S.succ) :=\nbegin\n  intro h,\n  set p := (vector.of_fn f).to_list.prod' with hp,\n  unfold finmap.prod_eq_one at *,\n  -- want to break the goal into a product over fin n and last,\n  -- and to break h into a product over head and tail\n  -- want to break the goal into prod of either head and tail or of first and rest\n  change (vector.of_fn (f ∘ (fin.S.succ' n))).to_list.prod' = 1,\n  change (vector.of_fn (λ x, (f ∘ (fin.S.succ' n)) x)).to_list.prod' = 1,\n  change (vector.of_fn (λ x, (f ((fin.S.succ' n) x)))).to_list.prod' = 1,\n  rw vector.to_list.succ',\n  rw list.prod_append',\n  rw vector.to_list.succ at h,\n  rw list.prod_cons' at h,\n  apply (show ∀ a b : G, a * b = 1 → b * a = 1, begin\n    intros a b hab,\n    replace hab := mygroup.group.eq_inv_of_mul_eq_one hab,\n    rw hab, simp,\n  end),\n  convert h,\n  { simp, \n    congr',\n    unfold fin.S.succ' fin.S.succ,\n    simp,\n    unfold zmod.S,\n    simp,\n    symmetry,\n    rw equiv.eq_symm_apply,\n    suffices : (0 : zmod n.succ) = fin.equiv_zmod ⟨n, (nat.lt_succ_self n)⟩ + 1,\n      convert this,\n    have h1 : (0 : zmod n.succ) = n + 1 := by simp,\n    convert h1,\n    ext, \n    convert eq.refl n,\n    clear h hp p f h1,\n    change zmod.val ((n : ℕ) : zmod n.succ) = n,\n    erw zmod.val_cast_of_lt,\n    exact nat.lt_succ_self n\n  },\n  unfold fin.S.succ' fin.S.succ,\n  ext i,\n  simp,\n  congr',\n  cases i with i hi,\n  unfold zmod.S,\n  symmetry,\n  rw equiv.eq_symm_apply,\n  simp,\n  apply fin.eq_of_veq,\n  unfold fin.equiv_zmod,\n  change i.succ = _,\n  simp,\n  have : i.succ = ((i + 1 : ℕ) : zmod (n + 1)).val,\n    rw zmod.val_cast_of_lt, apply nat.succ_lt_succ hi,\n  convert this,\n  simp,\n  apply fin.eq_of_veq,\n  exact (zmod.val_cast_of_lt (nat.lt_succ_of_lt hi)).symm,\nend\n\nlemma finmap.prod_eq_one_iterate {f : fin n.succ → G} (d : ℕ) :\nfinmap.prod_eq_one f → finmap.prod_eq_one \n  (λ i, f (((fin.S.succ : fin n.succ ≃ fin n.succ) ^ (d : ℤ) : \n  fin n.succ ≃ fin n.succ).to_fun i)) :=\nbegin\n  intro h,\n  induction d with e he,\n    { convert h },\n    { convert finmap.prod_eq_one_succ he,\n      ext i, simp, congr' 1,\n      rw [group.pow_add, group.pow_one], refl }\nend\n\n--instance foo : group (zmod n ≃ zmod n) := by apply_instance\n\nlemma zmod.S.pow_k (k : ℕ) (n : ℕ) (d : zmod n) :\n  ((zmod.S : zmod n ≃ zmod n) ^ (k : ℤ)) d = k + d :=\nbegin\n  induction k with e he,\n    { simp },\n    { rw [nat.succ_eq_add_one, add_comm, int.coe_nat_add],\n      rw group.pow_add,\n      simp [he],\n      simp [zmod.S],\n      abel }\nend\n\nlemma fin.S.succ.pow_k (k : ℕ) (n : ℕ) (d : fin n.succ) :\n  ((fin.S.succ' n : fin n.succ ≃ fin n.succ) ^ (k : ℤ)) d = k + d :=\nbegin\n  -- evil proof\n  apply zmod.S.pow_k k n.succ \nend\n\nlemma zmod.S.pow_n (n : ℕ) (d : zmod n) :\n  ((zmod.S : zmod n ≃ zmod n) ^ (n : ℤ)) d = d := by simp [zmod.S.pow_k]\n\nlemma fin.S.succ.pow_n (n : ℕ) (d : fin n.succ) :\n  ((fin.S.succ' n) ^ (((n.succ : ℕ) : ℤ))) d = d := zmod.S.pow_n n.succ d\n\nend mygroup", "meta": {"author": "ImperialCollegeLondon", "repo": "group-theory-game", "sha": "152ec4a92ad67b6174a3d240c63fa56a6df6017e", "save_path": "github-repos/lean/ImperialCollegeLondon-group-theory-game", "path": "github-repos/lean/ImperialCollegeLondon-group-theory-game/group-theory-game-152ec4a92ad67b6174a3d240c63fa56a6df6017e/src/sylow/prod_eq_one.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.48155069757883556}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nQuotients -- extends the core library\n-/\nvariables {α : Sort*} {β : Sort*}\n\nnamespace setoid\n\nlemma ext {α : Sort*} :\n  ∀{s t : setoid α}, (∀a b, @setoid.r α s a b ↔ @setoid.r α t a b) → s = t\n| ⟨r, _⟩ ⟨p, _⟩ eq :=\n  have r = p, from funext $ assume a, funext $ assume b, propext $ eq a b,\n  by subst this\n\nend setoid\n\nnamespace quot\nvariables {ra : α → α → Prop} {rb : β → β → Prop} {φ : quot ra → quot rb → Sort*}\nlocal notation `⟦`:max a `⟧` := quot.mk _ a\n\nprotected def hrec_on₂ (qa : quot ra) (qb : quot rb) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧)\n  (ca : ∀ {b a₁ a₂}, ra a₁ a₂ → f a₁ b == f a₂ b)\n  (cb : ∀ {a b₁ b₂}, rb b₁ b₂ → f a b₁ == f a b₂) : φ qa qb :=\nquot.hrec_on qa (λ a, quot.hrec_on qb (f a) (λ b₁ b₂ pb, cb pb)) $ λ a₁ a₂ pa,\n  quot.induction_on qb $ λ b,\n    calc @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₁) (@cb _)\n          == f a₁ b                                     : by simp\n      ... == f a₂ b                                     : ca pa\n      ... == @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₂) (@cb _) : by simp\n\nprotected def map {α} (r r' : α → α → Prop) (h : ∀a b, r a b → r' a b) (a : quot r) : quot r' :=\nquot.hrec_on a (quot.mk r') $ assume a b hab, by rw [quot.sound (h a b hab)]\nend quot\n\nnamespace quotient\nvariables [sa : setoid α] [sb : setoid β]\nvariables {φ : quotient sa → quotient sb → Sort*}\n\nprotected def hrec_on₂ (qa : quotient sa) (qb : quotient sb) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧)\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) : φ qa qb :=\nquot.hrec_on₂ qa qb f\n  (λ _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (λ _ _ _ p, c _ _ _ _ (setoid.refl _) p)\nend quotient\n\n@[simp] theorem quotient.eq [r : setoid α] {x y : α} : ⟦x⟧ = ⟦y⟧ ↔ x ≈ y :=\n⟨quotient.exact, quotient.sound⟩\n\ntheorem forall_quotient_iff {α : Type*} [r : setoid α] {p : quotient r → Prop} :\n  (∀a:quotient r, p a) ↔ (∀a:α, p ⟦a⟧) :=\n⟨assume h x, h _, assume h a, a.induction_on h⟩\n\n@[simp] lemma quotient.lift_beta [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b) (x : α):\nquotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift_on_beta [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b) (x : α):\nquotient.lift_on (quotient.mk x) f h = f x := rfl\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quot.out {r : α → α → Prop} (q : quot r) : α :=\nclassical.some (quot.exists_rep q)\n\n/-- Unwrap the VM representation of a quotient to obtain an element of the equivalence class.\n  Computable but unsound. -/\nmeta def quot.unquot {r : α → α → Prop} : quot r → α := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : α → α → Prop} (q : quot r) : quot.mk r q.out = q :=\nclassical.some_spec (quot.exists_rep q)\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quotient.out [s : setoid α] : quotient s → α := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid α] (q : quotient s) : ⟦q.out⟧ = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid α] (a : α) : ⟦a⟧.out ≈ a :=\nquotient.exact (quotient.out_eq _)\n\ninstance pi_setoid {ι : Sort*} {α : ι → Sort*} [∀ i, setoid (α i)] : setoid (Π i, α i) :=\n{ r := λ a b, ∀ i, a i ≈ b i,\n  iseqv := ⟨\n    λ a i, setoid.refl _,\n    λ a b h i, setoid.symm (h _),\n    λ a b c h₁ h₂ i, setoid.trans (h₁ _) (h₂ _)⟩ }\n\nnoncomputable def quotient.choice {ι : Type*} {α : ι → Type*} [S : ∀ i, setoid (α i)]\n  (f : ∀ i, quotient (S i)) : @quotient (Π i, α i) (by apply_instance) :=\n⟦λ i, (f i).out⟧\n\ntheorem quotient.choice_eq {ι : Type*} {α : ι → Type*} [∀ i, setoid (α i)]\n  (f : ∀ i, α i) : quotient.choice (λ i, ⟦f i⟧) = ⟦f⟧ :=\nquotient.sound $ λ i, quotient.mk_out _\n\nlemma nonempty_quotient_iff (s : setoid α): nonempty (quotient s) ↔ nonempty α :=\n⟨assume ⟨a⟩, quotient.induction_on a nonempty.intro, assume ⟨a⟩, ⟨⟦a⟧⟩⟩\n\n/-- `trunc α` is the quotient of `α` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty α`, but unlike `nonempty α`, `trunc α` is data,\n  so the VM representation is the same as `α`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (α : Sort u) : Sort u := @quot α (λ _ _, true)\n\ntheorem true_equivalence : @equivalence α (λ _ _, true) :=\n⟨λ _, trivial, λ _ _ _, trivial, λ _ _ _ _ _, trivial⟩\n\nnamespace trunc\n\n/-- Constructor for `trunc α` -/\ndef mk (a : α) : trunc α := quot.mk _ a\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : α → β) (c : ∀ a b : α, f a = f b) : trunc α → β :=\nquot.lift f (λ a b _, c a b)\n\ntheorem ind {β : trunc α → Prop} : (∀ a : α, β (mk a)) → ∀ q : trunc α, β q := quot.ind\n\nprotected theorem lift_beta (f : α → β) (c) (a : α) : lift f c (mk a) = f a := rfl\n\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc α) (f : α → β)\n  (c : ∀ a b : α, f a = f b) : β := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {β : trunc α → Prop} (q : trunc α)\n  (h : ∀ a, β (mk a)) : β q := ind h q\n\ntheorem exists_rep (q : trunc α) : ∃ a : α, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on₂\n   {C : trunc α → trunc β → Prop} (q₁ : trunc α) (q₂ : trunc β) (h : ∀ a b, C (mk a) (mk b)) : C q₁ q₂ :=\ntrunc.induction_on q₁ $ λ a₁, trunc.induction_on q₂ (h a₁)\n\nprotected theorem eq (a b : trunc α) : a = b :=\ntrunc.induction_on₂ a b (λ x y, quot.sound trivial)\n\ninstance : subsingleton (trunc α) := ⟨trunc.eq⟩\n\ndef bind (q : trunc α) (f : α → trunc β) : trunc β :=\ntrunc.lift_on q f (λ a b, trunc.eq _ _)\n\ndef map (f : α → β) (q : trunc α) : trunc β := bind q (trunc.mk ∘ f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := λ α q, trunc.eq _ _,\n  pure_bind := λ α β q f, rfl,\n  bind_assoc := λ α β γ x f g, trunc.eq _ _ }\n\nvariable {C : trunc α → Sort*}\n\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : Π a, C (mk a)) (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc α) : C q :=\nquot.rec f (λ a b _, h a b) q\n\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc α) (f : Π a, C (mk a))\n  (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b) : C q :=\ntrunc.rec f h q\n\n@[reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton\n   [∀ a, subsingleton (C (mk a))] (q : trunc α) (f : Π a, C (mk a)) : C q :=\ntrunc.rec f (λ a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc α` (using the axiom of choice). -/\nnoncomputable def out : trunc α → α := quot.out\n\n@[simp] theorem out_eq (q : trunc α) : mk q.out = q := trunc.eq _ _\n\nend trunc\n\ntheorem nonempty_of_trunc (q : trunc α) : nonempty α :=\nlet ⟨a, _⟩ := q.exists_rep in ⟨a⟩\n\nnamespace quotient\nvariables {γ : Sort*} {φ : Sort*}\n  {s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}\n\n/- Versions of quotient definitions and lemmas ending in `'` use unification instead\nof typeclass inference for inferring the `setoid` argument. This is useful when there are\nseveral different quotient relations on a type, for example quotient groups, rings and modules -/\n\nprotected def mk' (a : α) : quotient s₁ := quot.mk s₁.1 a\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s₁) (f : α → φ)\n  (h : ∀ a b, @setoid.r α s₁ a b → f a = f b) : φ := quotient.lift_on q f h\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on₂' (q₁ : quotient s₁) (q₂ : quotient s₂) (f : α → β → γ)\n  (h : ∀ a₁ a₂ b₁ b₂, @setoid.r α s₁ a₁ b₁ → @setoid.r β s₂ a₂ b₂ → f a₁ a₂ = f b₁ b₂) : γ :=\nquotient.lift_on₂ q₁ q₂ f h\n\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s₁ → Prop}\n  (h : ∀ a, p (quotient.mk' a)) (q : quotient s₁) : p q :=\nquotient.ind h q\n\n@[elab_as_eliminator]\nprotected lemma ind₂' {p : quotient s₁ → quotient s₂ → Prop}\n  (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂))\n  (q₁ : quotient s₁) (q₂ : quotient s₂) : p q₁ q₂ :=\nquotient.ind₂ h q₁ q₂\n\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s₁ → Prop} (q : quotient s₁)\n  (h : ∀ a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n@[elab_as_eliminator]\nprotected lemma induction_on₂' {p : quotient s₁ → quotient s₂ → Prop} (q₁ : quotient s₁)\n  (q₂ : quotient s₂) (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂)) : p q₁ q₂ :=\nquotient.induction_on₂ q₁ q₂ h\n\n@[elab_as_eliminator]\nprotected lemma induction_on₃' {p : quotient s₁ → quotient s₂ → quotient s₃ → Prop}\n  (q₁ : quotient s₁) (q₂ : quotient s₂) (q₃ : quotient s₃)\n  (h : ∀ a₁ a₂ a₃, p (quotient.mk' a₁) (quotient.mk' a₂) (quotient.mk' a₃)) : p q₁ q₂ q₃ :=\nquotient.induction_on₃ q₁ q₂ q₃ h\n\nlemma exact' {a b : α} :\n  (quotient.mk' a : quotient s₁) = quotient.mk' b → @setoid.r _ s₁ a b :=\nquotient.exact\n\nlemma sound' {a b : α} : @setoid.r _ s₁ a b → @quotient.mk' α s₁ a = quotient.mk' b :=\nquotient.sound\n\n@[simp] protected lemma eq' {a b : α} : @quotient.mk' α s₁ a = quotient.mk' b ↔ @setoid.r _ s₁ a b :=\nquotient.eq\n\nnoncomputable def out' (a : quotient s₁) : α := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s₁) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : α) : @setoid.r α s₁ (quotient.mk' a : quotient s₁).out' a :=\nquotient.exact (quotient.out_eq _)\nend quotient\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/data/quot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4815506971505857}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.big_operators.pi\nimport Mathlib.algebra.module.pi\nimport Mathlib.algebra.module.prod\nimport Mathlib.algebra.module.submodule\nimport Mathlib.algebra.group.prod\nimport Mathlib.data.finsupp.basic\nimport Mathlib.data.dfinsupp\nimport Mathlib.algebra.pointwise\nimport Mathlib.PostPort\n\nuniverses u v w y z x u_1 u_2 u' v' w' u_4 u_5 u_3 u_6 i \n\nnamespace Mathlib\n\n/-!\n# Linear algebra\n\nThis file defines the basics of linear algebra. It sets up the \"categorical/lattice structure\" of\nmodules over a ring, submodules, and linear maps. If `p` and `q` are submodules of a module, `p ≤ q`\nmeans that `p ⊆ q`.\n\nMany of the relevant definitions, including `module`, `submodule`, and `linear_map`, are found in\n`src/algebra/module`.\n\n## Main definitions\n\n* Many constructors for linear maps, including `prod` and `coprod`\n* `submodule.span s` is defined to be the smallest submodule containing the set `s`.\n* If `p` is a submodule of `M`, `submodule.quotient p` is the quotient of `M` with respect to `p`:\n  that is, elements of `M` are identified if their difference is in `p`. This is itself a module.\n* The kernel `ker` and range `range` of a linear map are submodules of the domain and codomain\n  respectively.\n* The general linear group is defined to be the group of invertible linear maps from `M` to itself.\n\n## Main statements\n\n* The first and second isomorphism laws for modules are proved as `quot_ker_equiv_range` and\n  `quotient_inf_equiv_sup_quotient`.\n\n## Notations\n\n* We continue to use the notation `M →ₗ[R] M₂` for the type of linear maps from `M` to `M₂` over the\n  ring `R`.\n* We introduce the notations `M ≃ₗ M₂` and `M ≃ₗ[R] M₂` for `linear_equiv M M₂`. In the first, the\n  ring `R` is implicit.\n* We introduce the notation `R ∙ v` for the span of a singleton, `submodule.span R {v}`.  This is\n  `\\.`, not the same as the scalar multiplication `•`/`\\bub`.\n\n## Implementation notes\n\nWe note that, when constructing linear maps, it is convenient to use operations defined on bundled\nmaps (`prod`, `coprod`, arithmetic operations like `+`) instead of defining a function and proving\nit is linear.\n\n## Tags\nlinear algebra, vector space, module\n\n-/\n\nnamespace finsupp\n\n\ntheorem smul_sum {α : Type u} {β : Type v} {R : Type w} {M : Type y} [HasZero β] [semiring R]\n    [add_comm_monoid M] [semimodule R M] {v : α →₀ β} {c : R} {h : α → β → M} :\n    c • sum v h = sum v fun (a : α) (b : β) => c • h a b :=\n  finset.smul_sum\n\nend finsupp\n\n\n/-- decomposing `x : ι → R` as a sum along the canonical basis -/\ntheorem pi_eq_sum_univ {ι : Type u} [fintype ι] {R : Type v} [semiring R] (x : ι → R) :\n    x = finset.sum finset.univ fun (i : ι) => x i • fun (j : ι) => ite (i = j) 1 0 :=\n  sorry\n\n/-! ### Properties of linear maps -/\n\nnamespace linear_map\n\n\n@[simp] theorem comp_id {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    comp f id = f :=\n  ext fun (x : M) => rfl\n\n@[simp] theorem id_comp {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    comp id f = f :=\n  ext fun (x : M) => rfl\n\ntheorem comp_assoc {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n    [semimodule R M] [semimodule R M₂] [semimodule R M₃] [semimodule R M₄] (f : linear_map R M M₂)\n    (g : linear_map R M₂ M₃) (h : linear_map R M₃ M₄) : comp (comp h g) f = comp h (comp g f) :=\n  rfl\n\n/-- The restriction of a linear map `f : M → M₂` to a submodule `p ⊆ M` gives a linear map\n`p → M₂`. -/\ndef dom_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (p : submodule R M) : linear_map R (↥p) M₂ :=\n  comp f (submodule.subtype p)\n\n@[simp] theorem dom_restrict_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (f : linear_map R M M₂) (p : submodule R M) (x : ↥p) :\n    coe_fn (dom_restrict f p) x = coe_fn f ↑x :=\n  rfl\n\n/-- A linear map `f : M₂ → M` whose values lie in a submodule `p ⊆ M` can be restricted to a\nlinear map M₂ → p. -/\ndef cod_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M₂ M) (h : ∀ (c : M₂), coe_fn f c ∈ p) : linear_map R M₂ ↥p :=\n  mk (fun (c : M₂) => { val := coe_fn f c, property := h c }) sorry sorry\n\n@[simp] theorem cod_restrict_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M₂ M) {h : ∀ (c : M₂), coe_fn f c ∈ p} (x : M₂) :\n    ↑(coe_fn (cod_restrict p f h) x) = coe_fn f x :=\n  rfl\n\n@[simp] theorem comp_cod_restrict {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (p : submodule R M₂) (h : ∀ (b : M), coe_fn f b ∈ p)\n    (g : linear_map R M₃ M) :\n    comp (cod_restrict p f h) g = cod_restrict p (comp f g) fun (b : M₃) => h (coe_fn g b) :=\n  ext fun (b : M₃) => rfl\n\n@[simp] theorem subtype_comp_cod_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (f : linear_map R M M₂) (p : submodule R M₂) (h : ∀ (b : M), coe_fn f b ∈ p) :\n    comp (submodule.subtype p) (cod_restrict p f h) = f :=\n  ext fun (b : M) => rfl\n\n/-- Restrict domain and codomain of an endomorphism. -/\ndef restrict {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (f : linear_map R M M) {p : submodule R M} (hf : ∀ (x : M), x ∈ p → coe_fn f x ∈ p) :\n    linear_map R ↥p ↥p :=\n  cod_restrict p (dom_restrict f p) sorry\n\ntheorem restrict_apply {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {f : linear_map R M M} {p : submodule R M} (hf : ∀ (x : M), x ∈ p → coe_fn f x ∈ p) (x : ↥p) :\n    coe_fn (restrict f hf) x =\n        { val := coe_fn f ↑x, property := hf (subtype.val x) (subtype.property x) } :=\n  rfl\n\ntheorem subtype_comp_restrict {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {f : linear_map R M M} {p : submodule R M}\n    (hf : ∀ (x : M), x ∈ p → coe_fn f x ∈ p) :\n    comp (submodule.subtype p) (restrict f hf) = dom_restrict f p :=\n  rfl\n\ntheorem restrict_eq_cod_restrict_dom_restrict {R : Type u} {M : Type v} [semiring R]\n    [add_comm_monoid M] [semimodule R M] {f : linear_map R M M} {p : submodule R M}\n    (hf : ∀ (x : M), x ∈ p → coe_fn f x ∈ p) :\n    restrict f hf =\n        cod_restrict p (dom_restrict f p) fun (x : ↥p) => hf (subtype.val x) (subtype.property x) :=\n  rfl\n\ntheorem restrict_eq_dom_restrict_cod_restrict {R : Type u} {M : Type v} [semiring R]\n    [add_comm_monoid M] [semimodule R M] {f : linear_map R M M} {p : submodule R M}\n    (hf : ∀ (x : M), coe_fn f x ∈ p) :\n    (restrict f fun (x : M) (_x : x ∈ p) => hf x) = dom_restrict (cod_restrict p f hf) p :=\n  rfl\n\n/-- The constant 0 map is linear. -/\nprotected instance has_zero {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : HasZero (linear_map R M M₂) :=\n  { zero := mk (fun (_x : M) => 0) sorry sorry }\n\nprotected instance inhabited {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    Inhabited (linear_map R M M₂) :=\n  { default := 0 }\n\n@[simp] theorem zero_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (x : M) : coe_fn 0 x = 0 :=\n  rfl\n\n@[simp] theorem default_def {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : Inhabited.default = 0 :=\n  rfl\n\nprotected instance unique_of_left {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] [subsingleton M] :\n    unique (linear_map R M M₂) :=\n  unique.mk { default := Inhabited.default } sorry\n\nprotected instance unique_of_right {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] [subsingleton M₂] :\n    unique (linear_map R M M₂) :=\n  function.injective.unique coe_injective\n\n/-- The sum of two linear maps is linear. -/\nprotected instance has_add {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : Add (linear_map R M M₂) :=\n  { add :=\n      fun (f g : linear_map R M M₂) => mk (fun (b : M) => coe_fn f b + coe_fn g b) sorry sorry }\n\n@[simp] theorem add_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (g : linear_map R M M₂) (x : M) : coe_fn (f + g) x = coe_fn f x + coe_fn g x :=\n  rfl\n\n/-- The type of linear maps is an additive monoid. -/\nprotected instance add_comm_monoid {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    add_comm_monoid (linear_map R M M₂) :=\n  add_comm_monoid.mk Add.add sorry 0 sorry sorry sorry\n\nprotected instance linear_map_apply_is_add_monoid_hom {R : Type u} {M : Type v} {M₂ : Type w}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (a : M) : is_add_monoid_hom fun (f : linear_map R M M₂) => coe_fn f a :=\n  is_add_monoid_hom.mk rfl\n\ntheorem add_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) (h : linear_map R M₂ M₃) :\n    comp (h + g) f = comp h f + comp g f :=\n  rfl\n\ntheorem comp_add {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₂) (h : linear_map R M₂ M₃) :\n    comp h (f + g) = comp h f + comp h g :=\n  sorry\n\ntheorem sum_apply {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (t : finset ι)\n    (f : ι → linear_map R M M₂) (b : M) :\n    coe_fn (finset.sum t fun (d : ι) => f d) b = finset.sum t fun (d : ι) => coe_fn (f d) b :=\n  Eq.symm (finset.sum_hom t fun (g : linear_map R M M₂) => coe_fn g b)\n\n/-- `λb, f b • x` is a linear map. -/\ndef smul_right {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M₂ R) (x : M) :\n    linear_map R M₂ M :=\n  mk (fun (b : M₂) => coe_fn f b • x) sorry sorry\n\n@[simp] theorem smul_right_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (f : linear_map R M₂ R) (x : M) (c : M₂) : coe_fn (smul_right f x) c = coe_fn f c • x :=\n  rfl\n\nprotected instance has_one {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : HasOne (linear_map R M M) :=\n  { one := id }\n\nprotected instance has_mul {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : Mul (linear_map R M M) :=\n  { mul := comp }\n\ntheorem mul_eq_comp {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (f : linear_map R M M) (g : linear_map R M M) : f * g = comp f g :=\n  rfl\n\n@[simp] theorem one_app {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (x : M) : coe_fn 1 x = x :=\n  rfl\n\n@[simp] theorem mul_app {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (A : linear_map R M M) (B : linear_map R M M) (x : M) :\n    coe_fn (A * B) x = coe_fn A (coe_fn B x) :=\n  rfl\n\n@[simp] theorem comp_zero {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) : comp f 0 = 0 :=\n  sorry\n\n@[simp] theorem zero_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) : comp 0 f = 0 :=\n  rfl\n\ntheorem coe_fn_sum {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {ι : Type u_1} (t : finset ι)\n    (f : ι → linear_map R M M₂) :\n    ⇑(finset.sum t fun (i : ι) => f i) = finset.sum t fun (i : ι) => ⇑(f i) :=\n  add_monoid_hom.map_sum (add_monoid_hom.mk to_fun rfl fun (x y : linear_map R M M₂) => rfl)\n    (fun (x : ι) => f x) t\n\nprotected instance monoid {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : monoid (linear_map R M M) :=\n  monoid.mk Mul.mul sorry 1 sorry sorry\n\n/-- A linear map `f` applied to `x : ι → R` can be computed using the image under `f` of elements\nof the canonical basis. -/\ntheorem pi_apply_eq_sum_univ {R : Type u} {M : Type v} {ι : Type x} [semiring R] [add_comm_monoid M]\n    [semimodule R M] [fintype ι] (f : linear_map R (ι → R) M) (x : ι → R) :\n    coe_fn f x =\n        finset.sum finset.univ fun (i : ι) => x i • coe_fn f fun (j : ι) => ite (i = j) 1 0 :=\n  sorry\n\n/-- The first projection of a product is a linear map. -/\ndef fst (R : Type u) (M : Type v) (M₂ : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : linear_map R (M × M₂) M :=\n  mk prod.fst sorry sorry\n\n/-- The second projection of a product is a linear map. -/\ndef snd (R : Type u) (M : Type v) (M₂ : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : linear_map R (M × M₂) M₂ :=\n  mk prod.snd sorry sorry\n\n@[simp] theorem fst_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (x : M × M₂) :\n    coe_fn (fst R M M₂) x = prod.fst x :=\n  rfl\n\n@[simp] theorem snd_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (x : M × M₂) :\n    coe_fn (snd R M M₂) x = prod.snd x :=\n  rfl\n\n/-- The prod of two linear maps is a linear map. -/\ndef prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂] [semimodule R M₃]\n    (f : linear_map R M M₂) (g : linear_map R M M₃) : linear_map R M (M₂ × M₃) :=\n  mk (fun (x : M) => (coe_fn f x, coe_fn g x)) sorry sorry\n\n@[simp] theorem prod_apply {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₃) (x : M) :\n    coe_fn (prod f g) x = (coe_fn f x, coe_fn g x) :=\n  rfl\n\n@[simp] theorem fst_prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₃) :\n    comp (fst R M₂ M₃) (prod f g) = f :=\n  ext fun (x : M) => Eq.refl (coe_fn (comp (fst R M₂ M₃) (prod f g)) x)\n\n@[simp] theorem snd_prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₃) :\n    comp (snd R M₂ M₃) (prod f g) = g :=\n  ext fun (x : M) => Eq.refl (coe_fn (comp (snd R M₂ M₃) (prod f g)) x)\n\n@[simp] theorem pair_fst_snd {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    prod (fst R M M₂) (snd R M M₂) = id :=\n  sorry\n\n/-- The left injection into a product is a linear map. -/\ndef inl (R : Type u) (M : Type v) (M₂ : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : linear_map R M (M × M₂) :=\n  mk ⇑(add_monoid_hom.inl M M₂) sorry sorry\n\n/-- The right injection into a product is a linear map. -/\ndef inr (R : Type u) (M : Type v) (M₂ : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : linear_map R M₂ (M × M₂) :=\n  mk ⇑(add_monoid_hom.inr M M₂) sorry sorry\n\n@[simp] theorem inl_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (x : M) :\n    coe_fn (inl R M M₂) x = (x, 0) :=\n  rfl\n\n@[simp] theorem inr_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (x : M₂) :\n    coe_fn (inr R M M₂) x = (0, x) :=\n  rfl\n\ntheorem inl_injective {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : function.injective ⇑(inl R M M₂) :=\n  sorry\n\ntheorem inr_injective {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : function.injective ⇑(inr R M M₂) :=\n  sorry\n\n/-- The coprod function `λ x : M × M₂, f x.1 + g x.2` is a linear map. -/\ndef coprod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂] [semimodule R M₃]\n    (f : linear_map R M M₃) (g : linear_map R M₂ M₃) : linear_map R (M × M₂) M₃ :=\n  mk (fun (x : M × M₂) => coe_fn f (prod.fst x) + coe_fn g (prod.snd x)) sorry sorry\n\n@[simp] theorem coprod_apply {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₃) (g : linear_map R M₂ M₃) (x : M) (y : M₂) :\n    coe_fn (coprod f g) (x, y) = coe_fn f x + coe_fn g y :=\n  rfl\n\n@[simp] theorem coprod_inl {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₃) (g : linear_map R M₂ M₃) :\n    comp (coprod f g) (inl R M M₂) = f :=\n  sorry\n\n@[simp] theorem coprod_inr {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₃) (g : linear_map R M₂ M₃) :\n    comp (coprod f g) (inr R M M₂) = g :=\n  sorry\n\n@[simp] theorem coprod_inl_inr {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    coprod (inl R M M₂) (inr R M M₂) = id :=\n  sorry\n\ntheorem fst_eq_coprod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : fst R M M₂ = coprod id 0 :=\n  sorry\n\ntheorem snd_eq_coprod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : snd R M M₂ = coprod 0 id :=\n  sorry\n\ntheorem inl_eq_prod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : inl R M M₂ = prod id 0 :=\n  rfl\n\ntheorem inr_eq_prod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : inr R M M₂ = prod 0 id :=\n  rfl\n\n/-- `prod.map` of two linear maps. -/\ndef prod_map {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n    [semimodule R M] [semimodule R M₂] [semimodule R M₃] [semimodule R M₄] (f : linear_map R M M₃)\n    (g : linear_map R M₂ M₄) : linear_map R (M × M₂) (M₃ × M₄) :=\n  prod (comp f (fst R M M₂)) (comp g (snd R M M₂))\n\n@[simp] theorem prod_map_apply {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n    [semimodule R M] [semimodule R M₂] [semimodule R M₃] [semimodule R M₄] (f : linear_map R M M₃)\n    (g : linear_map R M₂ M₄) (x : M × M₂) :\n    coe_fn (prod_map f g) x = (coe_fn f (prod.fst x), coe_fn g (prod.snd x)) :=\n  rfl\n\n/-- The negation of a linear map is linear. -/\nprotected instance has_neg {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] : Neg (linear_map R M M₂) :=\n  { neg := fun (f : linear_map R M M₂) => mk (fun (b : M) => -coe_fn f b) sorry sorry }\n\n@[simp] theorem neg_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) (x : M) :\n    coe_fn (-f) x = -coe_fn f x :=\n  rfl\n\n@[simp] theorem comp_neg {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_group M₂] [add_comm_group M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) : comp g (-f) = -comp g f :=\n  sorry\n\n/-- The negation of a linear map is linear. -/\nprotected instance has_sub {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] : Sub (linear_map R M M₂) :=\n  { sub :=\n      fun (f g : linear_map R M M₂) => mk (fun (b : M) => coe_fn f b - coe_fn g b) sorry sorry }\n\n@[simp] theorem sub_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (g : linear_map R M M₂) (x : M) : coe_fn (f - g) x = coe_fn f x - coe_fn g x :=\n  rfl\n\ntheorem sub_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_group M₂] [add_comm_group M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) (h : linear_map R M₂ M₃) :\n    comp (g - h) f = comp g f - comp h f :=\n  rfl\n\ntheorem comp_sub {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_group M₂] [add_comm_group M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₂) (h : linear_map R M₂ M₃) :\n    comp h (g - f) = comp h g - comp h f :=\n  sorry\n\n/-- The type of linear maps is an additive group. -/\nprotected instance add_comm_group {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_group M₂] [semimodule R M] [semimodule R M₂] :\n    add_comm_group (linear_map R M M₂) :=\n  add_comm_group.mk Add.add sorry 0 sorry sorry Neg.neg Sub.sub sorry sorry\n\nprotected instance linear_map_apply_is_add_group_hom {R : Type u} {M : Type v} {M₂ : Type w}\n    [semiring R] [add_comm_monoid M] [add_comm_group M₂] [semimodule R M] [semimodule R M₂]\n    (a : M) : is_add_group_hom fun (f : linear_map R M M₂) => coe_fn f a :=\n  is_add_group_hom.mk\n\nprotected instance has_scalar {R : Type u} {M : Type v} {M₂ : Type w} {S : Type u_1} [semiring R]\n    [monoid S] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    [distrib_mul_action S M₂] [smul_comm_class R S M₂] : has_scalar S (linear_map R M M₂) :=\n  has_scalar.mk\n    fun (a : S) (f : linear_map R M M₂) => mk (fun (b : M) => a • coe_fn f b) sorry sorry\n\n@[simp] theorem smul_apply {R : Type u} {M : Type v} {M₂ : Type w} {S : Type u_1} [semiring R]\n    [monoid S] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    [distrib_mul_action S M₂] [smul_comm_class R S M₂] (f : linear_map R M M₂) (a : S) (x : M) :\n    coe_fn (a • f) x = a • coe_fn f x :=\n  rfl\n\nprotected instance distrib_mul_action {R : Type u} {M : Type v} {M₂ : Type w} {S : Type u_1}\n    [semiring R] [monoid S] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M]\n    [semimodule R M₂] [distrib_mul_action S M₂] [smul_comm_class R S M₂] :\n    distrib_mul_action S (linear_map R M M₂) :=\n  distrib_mul_action.mk sorry sorry\n\ntheorem smul_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {S : Type u_1} [semiring R]\n    [monoid S] [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M]\n    [semimodule R M₂] [semimodule R M₃] [distrib_mul_action S M₂] [smul_comm_class R S M₂] (a : S)\n    (g : linear_map R M₃ M₂) (f : linear_map R M M₃) : comp (a • g) f = a • comp g f :=\n  rfl\n\nprotected instance semimodule {R : Type u} {M : Type v} {M₂ : Type w} {S : Type u_1} [semiring R]\n    [semiring S] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    [semimodule S M₂] [smul_comm_class R S M₂] : semimodule S (linear_map R M M₂) :=\n  semimodule.mk sorry sorry\n\n/-- Applying a linear map at `v : M`, seen as `S`-linear map from `M →ₗ[R] M₂` to `M₂`.\n\n See `applyₗ` for a version where `S = R` -/\ndef applyₗ' {R : Type u} {M : Type v} {M₂ : Type w} (S : Type u_1) [semiring R] [semiring S]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] [semimodule S M₂]\n    [smul_comm_class R S M₂] (v : M) : linear_map S (linear_map R M M₂) M₂ :=\n  mk (fun (f : linear_map R M M₂) => coe_fn f v) sorry sorry\n\ntheorem comp_smul {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [comm_semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) (a : R) :\n    comp g (a • f) = a • comp g f :=\n  sorry\n\n/-- Composition by `f : M₂ → M₃` is a linear map from the space of linear maps `M → M₂`\nto the space of linear maps `M₂ → M₃`. -/\ndef comp_right {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [comm_semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M₂ M₃) :\n    linear_map R (linear_map R M M₂) (linear_map R M M₃) :=\n  mk (comp f) sorry sorry\n\n/-- Applying a linear map at `v : M`, seen as a linear map from `M →ₗ[R] M₂` to `M₂`.\nSee also `linear_map.applyₗ'` for a version that works with two different semirings. -/\ndef applyₗ {R : Type u} {M : Type v} {M₂ : Type w} [comm_semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (v : M) :\n    linear_map R (linear_map R M M₂) M₂ :=\n  applyₗ' R v\n\nprotected instance endomorphism_semiring {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : semiring (linear_map R M M) :=\n  semiring.mk add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry sorry Mul.mul sorry 1 sorry\n    sorry sorry sorry sorry sorry\n\ntheorem mul_apply {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (f : linear_map R M M) (g : linear_map R M M) (x : M) :\n    coe_fn (f * g) x = coe_fn f (coe_fn g x) :=\n  rfl\n\nprotected instance endomorphism_ring {R : Type u} {M : Type v} [ring R] [add_comm_group M]\n    [semimodule R M] : ring (linear_map R M M) :=\n  ring.mk semiring.add sorry semiring.zero sorry sorry add_comm_group.neg add_comm_group.sub sorry\n    sorry semiring.mul sorry semiring.one sorry sorry sorry sorry\n\n/--\nThe family of linear maps `M₂ → M` parameterised by `f ∈ M₂ → R`, `x ∈ M`, is linear in `f`, `x`.\n-/\ndef smul_rightₗ {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] :\n    linear_map R (linear_map R M₂ R) (linear_map R M (linear_map R M₂ M)) :=\n  mk (fun (f : linear_map R M₂ R) => mk (smul_right f) sorry sorry) sorry sorry\n\n@[simp] theorem smul_rightₗ_apply {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R]\n    [add_comm_group M] [add_comm_group M₂] [semimodule R M] [semimodule R M₂]\n    (f : linear_map R M₂ R) (x : M) (c : M₂) :\n    coe_fn (coe_fn (coe_fn smul_rightₗ f) x) c = coe_fn f c • x :=\n  rfl\n\nend linear_map\n\n\n/-! ### Properties of submodules -/\n\nnamespace submodule\n\n\nprotected instance partial_order {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : partial_order (submodule R M) :=\n  partial_order.mk (fun (p p' : submodule R M) => ∀ {x : M}, x ∈ p → x ∈ p') partial_order.lt sorry\n    sorry sorry\n\ntheorem le_def {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} : p ≤ p' ↔ ↑p ⊆ ↑p' :=\n  iff.rfl\n\ntheorem le_def' {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} : p ≤ p' ↔ ∀ (x : M), x ∈ p → x ∈ p' :=\n  iff.rfl\n\ntheorem lt_def {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} : p < p' ↔ ↑p ⊂ ↑p' :=\n  iff.rfl\n\ntheorem not_le_iff_exists {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {p : submodule R M} {p' : submodule R M} :\n    ¬p ≤ p' ↔ ∃ (x : M), ∃ (H : x ∈ p), ¬x ∈ p' :=\n  set.not_subset\n\ntheorem exists_of_lt {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} : p < p' → ∃ (x : M), ∃ (H : x ∈ p'), ¬x ∈ p :=\n  set.exists_of_ssubset\n\ntheorem lt_iff_le_and_exists {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {p : submodule R M} {p' : submodule R M} :\n    p < p' ↔ p ≤ p' ∧ ∃ (x : M), ∃ (H : x ∈ p'), ¬x ∈ p :=\n  sorry\n\n/-- If two submodules `p` and `p'` satisfy `p ⊆ p'`, then `of_le p p'` is the linear map version of\nthis inclusion. -/\ndef of_le {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} (h : p ≤ p') : linear_map R ↥p ↥p' :=\n  linear_map.cod_restrict p' (submodule.subtype p) sorry\n\n@[simp] theorem coe_of_le {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {p : submodule R M} {p' : submodule R M} (h : p ≤ p') (x : ↥p) :\n    ↑(coe_fn (of_le h) x) = ↑x :=\n  rfl\n\ntheorem of_le_apply {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} (h : p ≤ p') (x : ↥p) :\n    coe_fn (of_le h) x = { val := ↑x, property := h (subtype.property x) } :=\n  rfl\n\ntheorem subtype_comp_of_le {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) (q : submodule R M) (h : p ≤ q) :\n    linear_map.comp (submodule.subtype q) (of_le h) = submodule.subtype p :=\n  sorry\n\n/-- The set `{0}` is the bottom element of the lattice of submodules. -/\nprotected instance has_bot {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : has_bot (submodule R M) :=\n  has_bot.mk (mk (singleton 0) sorry sorry sorry)\n\nprotected instance inhabited' {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : Inhabited (submodule R M) :=\n  { default := ⊥ }\n\n@[simp] theorem bot_coe {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : ↑⊥ = singleton 0 :=\n  rfl\n\n@[simp] theorem mem_bot (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {x : M} : x ∈ ⊥ ↔ x = 0 :=\n  set.mem_singleton_iff\n\ntheorem nonzero_mem_of_bot_lt {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {I : submodule R M} (bot_lt : ⊥ < I) : ∃ (a : ↥I), a ≠ 0 :=\n  sorry\n\nprotected instance order_bot {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : order_bot (submodule R M) :=\n  order_bot.mk ⊥ partial_order.le partial_order.lt sorry sorry sorry sorry\n\nprotected theorem eq_bot_iff {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) : p = ⊥ ↔ ∀ (x : M), x ∈ p → x = 0 :=\n  { mp := fun (h : p = ⊥) => Eq.symm h ▸ fun (x : M) (hx : x ∈ ⊥) => iff.mp (mem_bot R) hx,\n    mpr :=\n      fun (h : ∀ (x : M), x ∈ p → x = 0) =>\n        iff.mpr eq_bot_iff fun (x : M) (hx : x ∈ p) => iff.mpr (mem_bot R) (h x hx) }\n\nprotected theorem ne_bot_iff {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) : p ≠ ⊥ ↔ ∃ (x : M), ∃ (H : x ∈ p), x ≠ 0 :=\n  sorry\n\n/-- The universal set is the top element of the lattice of submodules. -/\nprotected instance has_top {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : has_top (submodule R M) :=\n  has_top.mk (mk set.univ sorry sorry sorry)\n\n@[simp] theorem top_coe {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : ↑⊤ = set.univ :=\n  rfl\n\n@[simp] theorem mem_top {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {x : M} : x ∈ ⊤ :=\n  trivial\n\ntheorem eq_bot_of_zero_eq_one {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) (zero_eq_one : 0 = 1) : p = ⊥ :=\n  sorry\n\nprotected instance order_top {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : order_top (submodule R M) :=\n  order_top.mk ⊤ partial_order.le partial_order.lt sorry sorry sorry sorry\n\nprotected instance has_Inf {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : has_Inf (submodule R M) :=\n  has_Inf.mk\n    fun (S : set (submodule R M)) =>\n      mk (set.Inter fun (s : submodule R M) => set.Inter fun (H : s ∈ S) => ↑s) sorry sorry sorry\n\nprotected instance has_inf {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : has_inf (submodule R M) :=\n  has_inf.mk fun (p p' : submodule R M) => mk (↑p ∩ ↑p') sorry sorry sorry\n\nprotected instance complete_lattice {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : complete_lattice (submodule R M) :=\n  complete_lattice.mk\n    (fun (a b : submodule R M) => Inf (set_of fun (x : submodule R M) => a ≤ x ∧ b ≤ x))\n    order_top.le order_top.lt sorry sorry sorry sorry sorry sorry has_inf.inf sorry sorry sorry\n    order_top.top sorry order_bot.bot sorry\n    (fun (tt : set (submodule R M)) =>\n      Inf (set_of fun (t : submodule R M) => ∀ (t' : submodule R M), t' ∈ tt → t' ≤ t))\n    Inf sorry sorry sorry sorry\n\nprotected instance add_comm_monoid_submodule {R : Type u} {M : Type v} [semiring R]\n    [add_comm_monoid M] [semimodule R M] : add_comm_monoid (submodule R M) :=\n  add_comm_monoid.mk has_sup.sup sorry ⊥ sorry sorry sorry\n\n@[simp] theorem add_eq_sup {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) (q : submodule R M) : p + q = p ⊔ q :=\n  rfl\n\n@[simp] theorem zero_eq_bot {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : 0 = ⊥ :=\n  rfl\n\ntheorem eq_top_iff' {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} : p = ⊤ ↔ ∀ (x : M), x ∈ p :=\n  iff.trans eq_top_iff\n    { mp := fun (h : ⊤ ≤ p) (x : M) => h trivial,\n      mpr := fun (h : ∀ (x : M), x ∈ p) (x : M) (_x : x ∈ ⊤) => h x }\n\ntheorem bot_ne_top {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    [nontrivial M] : ⊥ ≠ ⊤ :=\n  sorry\n\n@[simp] theorem inf_coe {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (p : submodule R M) (p' : submodule R M) : ↑p ⊓ ↑p' = ↑p ∩ ↑p' :=\n  rfl\n\n@[simp] theorem mem_inf {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {x : M} {p : submodule R M} {p' : submodule R M} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=\n  iff.rfl\n\n@[simp] theorem Inf_coe {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (P : set (submodule R M)) :\n    ↑(Inf P) = set.Inter fun (p : submodule R M) => set.Inter fun (H : p ∈ P) => ↑p :=\n  rfl\n\n@[simp] theorem infi_coe {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {ι : Sort u_1} (p : ι → submodule R M) :\n    ↑(infi fun (i : ι) => p i) = set.Inter fun (i : ι) => ↑(p i) :=\n  sorry\n\n@[simp] theorem mem_Inf {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {S : set (submodule R M)} {x : M} : x ∈ Inf S ↔ ∀ (p : submodule R M), p ∈ S → x ∈ p :=\n  set.mem_bInter_iff\n\n@[simp] theorem mem_infi {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {x : M} {ι : Sort u_1} (p : ι → submodule R M) :\n    (x ∈ infi fun (i : ι) => p i) ↔ ∀ (i : ι), x ∈ p i :=\n  sorry\n\ntheorem disjoint_def {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} : disjoint p p' ↔ ∀ (x : M), x ∈ p → x ∈ p' → x = 0 :=\n  sorry\n\ntheorem disjoint_def' {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} :\n    disjoint p p' ↔ ∀ (x : M), x ∈ p → ∀ (y : M), y ∈ p' → x = y → x = 0 :=\n  sorry\n\ntheorem mem_right_iff_eq_zero_of_disjoint {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {p : submodule R M} {p' : submodule R M} (h : disjoint p p') {x : ↥p} :\n    ↑x ∈ p' ↔ x = 0 :=\n  { mp :=\n      fun (hx : ↑x ∈ p') => iff.mp coe_eq_zero (iff.mp disjoint_def h (↑x) (subtype.property x) hx),\n    mpr := fun (h : x = 0) => Eq.symm h ▸ zero_mem p' }\n\ntheorem mem_left_iff_eq_zero_of_disjoint {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {p : submodule R M} {p' : submodule R M} (h : disjoint p p') {x : ↥p'} :\n    ↑x ∈ p ↔ x = 0 :=\n  { mp :=\n      fun (hx : ↑x ∈ p) => iff.mp coe_eq_zero (iff.mp disjoint_def h (↑x) hx (subtype.property x)),\n    mpr := fun (h : x = 0) => Eq.symm h ▸ zero_mem p }\n\n/-- The pushforward of a submodule `p ⊆ M` by `f : M → M₂` -/\ndef map {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (p : submodule R M) : submodule R M₂ :=\n  mk (⇑f '' ↑p) sorry sorry sorry\n\n@[simp] theorem map_coe {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (p : submodule R M) : ↑(map f p) = ⇑f '' ↑p :=\n  rfl\n\n@[simp] theorem mem_map {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} {x : M₂} : x ∈ map f p ↔ ∃ (y : M), y ∈ p ∧ coe_fn f y = x :=\n  iff.rfl\n\ntheorem mem_map_of_mem {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} {r : M} (h : r ∈ p) : coe_fn f r ∈ map f p :=\n  set.mem_image_of_mem (fun (a : M) => coe_fn f a) h\n\n@[simp] theorem map_id {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (p : submodule R M) : map linear_map.id p = p :=\n  sorry\n\ntheorem map_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) (p : submodule R M) :\n    map (linear_map.comp g f) p = map g (map f p) :=\n  sorry\n\ntheorem map_mono {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} {p' : submodule R M} : p ≤ p' → map f p ≤ map f p' :=\n  set.image_subset fun (a : M) => coe_fn f a\n\n@[simp] theorem map_zero {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M) : map 0 p = ⊥ :=\n  sorry\n\n/-- The pullback of a submodule `p ⊆ M₂` along `f : M → M₂` -/\ndef comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (p : submodule R M₂) : submodule R M :=\n  mk (⇑f ⁻¹' ↑p) sorry sorry sorry\n\n@[simp] theorem comap_coe {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (p : submodule R M₂) : ↑(comap f p) = ⇑f ⁻¹' ↑p :=\n  rfl\n\n@[simp] theorem mem_comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {x : M} {f : linear_map R M M₂}\n    {p : submodule R M₂} : x ∈ comap f p ↔ coe_fn f x ∈ p :=\n  iff.rfl\n\ntheorem comap_id {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (p : submodule R M) : comap linear_map.id p = p :=\n  coe_injective rfl\n\ntheorem comap_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) (p : submodule R M₃) :\n    comap (linear_map.comp g f) p = comap f (comap g p) :=\n  rfl\n\ntheorem comap_mono {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {q : submodule R M₂} {q' : submodule R M₂} : q ≤ q' → comap f q ≤ comap f q' :=\n  set.preimage_mono\n\ntheorem map_le_iff_le_comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} {q : submodule R M₂} : map f p ≤ q ↔ p ≤ comap f q :=\n  set.image_subset_iff\n\ntheorem gc_map_comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    galois_connection (map f) (comap f) :=\n  fun (a : submodule R M) (b : submodule R M₂) =>\n    idRhs (map f a ≤ b ↔ a ≤ comap f b) map_le_iff_le_comap\n\n@[simp] theorem map_bot {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) : map f ⊥ = ⊥ :=\n  galois_connection.l_bot (gc_map_comap f)\n\n@[simp] theorem map_sup {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M) (p' : submodule R M)\n    (f : linear_map R M M₂) : map f (p ⊔ p') = map f p ⊔ map f p' :=\n  galois_connection.l_sup (gc_map_comap f)\n\n@[simp] theorem map_supr {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {ι : Sort u_1} (f : linear_map R M M₂)\n    (p : ι → submodule R M) : map f (supr fun (i : ι) => p i) = supr fun (i : ι) => map f (p i) :=\n  galois_connection.l_supr (gc_map_comap f)\n\n@[simp] theorem comap_top {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    comap f ⊤ = ⊤ :=\n  rfl\n\n@[simp] theorem comap_inf {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (q : submodule R M₂)\n    (q' : submodule R M₂) (f : linear_map R M M₂) : comap f (q ⊓ q') = comap f q ⊓ comap f q' :=\n  rfl\n\n@[simp] theorem comap_infi {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {ι : Sort u_1} (f : linear_map R M M₂)\n    (p : ι → submodule R M₂) :\n    comap f (infi fun (i : ι) => p i) = infi fun (i : ι) => comap f (p i) :=\n  galois_connection.u_infi (gc_map_comap f)\n\n@[simp] theorem comap_zero {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (q : submodule R M₂) : comap 0 q = ⊤ :=\n  sorry\n\ntheorem map_comap_le {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (q : submodule R M₂) : map f (comap f q) ≤ q :=\n  galois_connection.l_u_le (gc_map_comap f) q\n\ntheorem le_comap_map {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (p : submodule R M) : p ≤ comap f (map f p) :=\n  galois_connection.le_u_l (gc_map_comap f) p\n\n--TODO(Mario): is there a way to prove this from order properties?\n\ntheorem map_inf_eq_map_inf_comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    {f : linear_map R M M₂} {p : submodule R M} {p' : submodule R M₂} :\n    map f p ⊓ p' = map f (p ⊓ comap f p') :=\n  sorry\n\ntheorem map_comap_subtype {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) (p' : submodule R M) :\n    map (submodule.subtype p) (comap (submodule.subtype p) p') = p ⊓ p' :=\n  sorry\n\ntheorem eq_zero_of_bot_submodule {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (b : ↥⊥) : b = 0 :=\n  sorry\n\n/-- The span of a set `s ⊆ M` is the smallest submodule of M that contains `s`. -/\ndef span (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] (s : set M) :\n    submodule R M :=\n  Inf (set_of fun (p : submodule R M) => s ⊆ ↑p)\n\ntheorem mem_span {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] {x : M}\n    {s : set M} : x ∈ span R s ↔ ∀ (p : submodule R M), s ⊆ ↑p → x ∈ p :=\n  set.mem_bInter_iff\n\ntheorem subset_span {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {s : set M} : s ⊆ ↑(span R s) :=\n  fun (x : M) (h : x ∈ s) => iff.mpr mem_span fun (p : submodule R M) (hp : s ⊆ ↑p) => hp h\n\ntheorem span_le {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {s : set M} {p : submodule R M} : span R s ≤ p ↔ s ⊆ ↑p :=\n  { mp := set.subset.trans subset_span,\n    mpr := fun (ss : s ⊆ ↑p) (x : M) (h : x ∈ span R s) => iff.mp mem_span h p ss }\n\ntheorem span_mono {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {s : set M} {t : set M} (h : s ⊆ t) : span R s ≤ span R t :=\n  iff.mpr span_le (set.subset.trans h subset_span)\n\ntheorem span_eq_of_le {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (p : submodule R M) {s : set M} (h₁ : s ⊆ ↑p) (h₂ : p ≤ span R s) : span R s = p :=\n  le_antisymm (iff.mpr span_le h₁) h₂\n\n@[simp] theorem span_eq {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (p : submodule R M) : span R ↑p = p :=\n  span_eq_of_le p (set.subset.refl ↑p) subset_span\n\ntheorem map_span {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) (s : set M) :\n    map f (span R s) = span R (⇑f '' s) :=\n  sorry\n\n/- See also `span_preimage_eq` below. -/\n\ntheorem span_preimage_le {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) (s : set M₂) :\n    span R (⇑f ⁻¹' s) ≤ comap f (span R s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (span R (⇑f ⁻¹' s) ≤ comap f (span R s))) (propext span_le)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (⇑f ⁻¹' s ⊆ ↑(comap f (span R s)))) (comap_coe f (span R s))))\n      (set.preimage_mono subset_span))\n\n/-- An induction principle for span membership. If `p` holds for 0 and all elements of `s`, and is\npreserved under addition and scalar multiplication, then `p` holds for all elements of the span of\n`s`. -/\ntheorem span_induction {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {x : M} {s : set M} {p : M → Prop} (h : x ∈ span R s) (Hs : ∀ (x : M), x ∈ s → p x) (H0 : p 0)\n    (H1 : ∀ (x y : M), p x → p y → p (x + y)) (H2 : ∀ (a : R) (x : M), p x → p (a • x)) : p x :=\n  iff.mpr span_le Hs x h\n\n/-- `span` forms a Galois insertion with the coercion from submodule to set. -/\nprotected def gi (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M] [semimodule R M] :\n    galois_insertion (span R) coe :=\n  galois_insertion.mk (fun (s : set M) (_x : ↑(span R s) ≤ s) => span R s) sorry sorry sorry\n\n@[simp] theorem span_empty {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : span R ∅ = ⊥ :=\n  galois_connection.l_bot (galois_insertion.gc (submodule.gi R M))\n\n@[simp] theorem span_univ {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : span R set.univ = ⊤ :=\n  iff.mpr eq_top_iff (iff.mpr le_def subset_span)\n\ntheorem span_union {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (s : set M) (t : set M) : span R (s ∪ t) = span R s ⊔ span R t :=\n  galois_connection.l_sup (galois_insertion.gc (submodule.gi R M))\n\ntheorem span_Union {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {ι : Sort u_1} (s : ι → set M) :\n    span R (set.Union fun (i : ι) => s i) = supr fun (i : ι) => span R (s i) :=\n  galois_connection.l_supr (galois_insertion.gc (submodule.gi R M))\n\ntheorem span_eq_supr_of_singleton_spans {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (s : set M) :\n    span R s = supr fun (x : M) => supr fun (H : x ∈ s) => span R (singleton x) :=\n  sorry\n\n@[simp] theorem coe_supr_of_directed {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {ι : Sort u_1} [hι : Nonempty ι] (S : ι → submodule R M)\n    (H : directed LessEq S) : ↑(supr S) = set.Union fun (i : ι) => ↑(S i) :=\n  sorry\n\ntheorem mem_sup_left {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {S : submodule R M} {T : submodule R M} {x : M} : x ∈ S → x ∈ S ⊔ T :=\n  (fun (this : S ≤ S ⊔ T) => this) le_sup_left\n\ntheorem mem_sup_right {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {S : submodule R M} {T : submodule R M} {x : M} : x ∈ T → x ∈ S ⊔ T :=\n  (fun (this : T ≤ S ⊔ T) => this) le_sup_right\n\ntheorem mem_supr_of_mem {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {ι : Sort u_1} {b : M} {p : ι → submodule R M} (i : ι) (h : b ∈ p i) :\n    b ∈ supr fun (i : ι) => p i :=\n  (fun (this : p i ≤ supr fun (i : ι) => p i) => this h) (le_supr p i)\n\ntheorem mem_Sup_of_mem {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {S : set (submodule R M)} {s : submodule R M} (hs : s ∈ S) {x : M} : x ∈ s → x ∈ Sup S :=\n  (fun (this : s ≤ Sup S) => this) (le_Sup hs)\n\n@[simp] theorem mem_supr_of_directed {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {ι : Sort u_1} [Nonempty ι] (S : ι → submodule R M) (H : directed LessEq S)\n    {x : M} : x ∈ supr S ↔ ∃ (i : ι), x ∈ S i :=\n  sorry\n\ntheorem mem_Sup_of_directed {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {s : set (submodule R M)} {z : M} (hs : set.nonempty s)\n    (hdir : directed_on LessEq s) : z ∈ Sup s ↔ ∃ (y : submodule R M), ∃ (H : y ∈ s), z ∈ y :=\n  sorry\n\ntheorem mem_sup {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} {x : M} :\n    x ∈ p ⊔ p' ↔ ∃ (y : M), ∃ (H : y ∈ p), ∃ (z : M), ∃ (H : z ∈ p'), y + z = x :=\n  sorry\n\ntheorem mem_sup' {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {p' : submodule R M} {x : M} :\n    x ∈ p ⊔ p' ↔ ∃ (y : ↥p), ∃ (z : ↥p'), ↑y + ↑z = x :=\n  sorry\n\ntheorem mem_span_singleton_self {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (x : M) : x ∈ span R (singleton x) :=\n  subset_span rfl\n\ntheorem nontrivial_span_singleton {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {x : M} (h : x ≠ 0) : nontrivial ↥(span R (singleton x)) :=\n  sorry\n\ntheorem mem_span_singleton {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {x : M} {y : M} : x ∈ span R (singleton y) ↔ ∃ (a : R), a • y = x :=\n  sorry\n\ntheorem le_span_singleton_iff {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {s : submodule R M} {v₀ : M} :\n    s ≤ span R (singleton v₀) ↔ ∀ (v : M), v ∈ s → ∃ (r : R), r • v₀ = v :=\n  sorry\n\n@[simp] theorem span_zero_singleton {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : span R (singleton 0) = ⊥ :=\n  sorry\n\ntheorem span_singleton_eq_range {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (y : M) : ↑(span R (singleton y)) = set.range fun (_x : R) => _x • y :=\n  set.ext fun (x : M) => mem_span_singleton\n\ntheorem span_singleton_smul_le {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (r : R) (x : M) : span R (singleton (r • x)) ≤ span R (singleton x) :=\n  sorry\n\ntheorem span_singleton_smul_eq {K : Type u_1} {E : Type u_2} [division_ring K] [add_comm_group E]\n    [module K E] {r : K} (x : E) (hr : r ≠ 0) : span K (singleton (r • x)) = span K (singleton x) :=\n  sorry\n\ntheorem disjoint_span_singleton {K : Type u_1} {E : Type u_2} [division_ring K] [add_comm_group E]\n    [module K E] {s : submodule K E} {x : E} : disjoint s (span K (singleton x)) ↔ x ∈ s → x = 0 :=\n  sorry\n\ntheorem disjoint_span_singleton' {K : Type u_1} {E : Type u_2} [division_ring K] [add_comm_group E]\n    [module K E] {p : submodule K E} {x : E} (x0 : x ≠ 0) :\n    disjoint p (span K (singleton x)) ↔ ¬x ∈ p :=\n  iff.trans disjoint_span_singleton\n    { mp := fun (h₁ : x ∈ p → x = 0) (h₂ : x ∈ p) => x0 (h₁ h₂),\n      mpr := fun (h₁ : ¬x ∈ p) (h₂ : x ∈ p) => false.elim (h₁ h₂) }\n\ntheorem mem_span_insert {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {x : M} {s : set M} {y : M} :\n    x ∈ span R (insert y s) ↔ ∃ (a : R), ∃ (z : M), ∃ (H : z ∈ span R s), x = a • y + z :=\n  sorry\n\ntheorem span_insert_eq_span {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {x : M} {s : set M} (h : x ∈ span R s) : span R (insert x s) = span R s :=\n  span_eq_of_le (span R s) (iff.mpr set.insert_subset { left := h, right := subset_span })\n    (span_mono (set.subset_insert x s))\n\ntheorem span_span {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {s : set M} : span R ↑(span R s) = span R s :=\n  span_eq (span R s)\n\ntheorem span_eq_bot {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {s : set M} : span R s = ⊥ ↔ ∀ (x : M), x ∈ s → x = 0 :=\n  sorry\n\n@[simp] theorem span_singleton_eq_bot {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {x : M} : span R (singleton x) = ⊥ ↔ x = 0 :=\n  sorry\n\n@[simp] theorem span_zero {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : span R 0 = ⊥ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (span R 0 = ⊥)) (Eq.symm set.singleton_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (span R (singleton 0) = ⊥)) (propext span_singleton_eq_bot)))\n      (Eq.refl 0))\n\n@[simp] theorem span_image {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {s : set M} (f : linear_map R M M₂) :\n    span R (⇑f '' s) = map f (span R s) :=\n  span_eq_of_le (map f (span R s)) (set.image_subset (⇑f) subset_span)\n    (iff.mpr map_le_iff_le_comap (iff.mpr span_le (iff.mp set.image_subset_iff subset_span)))\n\ntheorem supr_eq_span {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {ι : Sort w} (p : ι → submodule R M) :\n    (supr fun (i : ι) => p i) = span R (set.Union fun (i : ι) => ↑(p i)) :=\n  sorry\n\ntheorem span_singleton_le_iff_mem {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (m : M) (p : submodule R M) : span R (singleton m) ≤ p ↔ m ∈ p :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (span R (singleton m) ≤ p ↔ m ∈ p)) (propext span_le)))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (singleton m ⊆ ↑p ↔ m ∈ p)) (propext set.singleton_subset_iff)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (m ∈ ↑p ↔ m ∈ p)) (propext (mem_coe p))))\n        (iff.refl (m ∈ p))))\n\ntheorem lt_add_iff_not_mem {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {I : submodule R M} {a : M} : I < I + span R (singleton a) ↔ ¬a ∈ I :=\n  sorry\n\ntheorem mem_supr {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {ι : Sort w} (p : ι → submodule R M) {m : M} :\n    (m ∈ supr fun (i : ι) => p i) ↔ ∀ (N : submodule R M), (∀ (i : ι), p i ≤ N) → m ∈ N :=\n  sorry\n\n/-- For every element in the span of a set, there exists a finite subset of the set\nsuch that the element is contained in the span of the subset. -/\ntheorem mem_span_finite_of_mem_span {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {S : set M} {x : M} (hx : x ∈ span R S) :\n    ∃ (T : finset M), ↑T ⊆ S ∧ x ∈ span R ↑T :=\n  sorry\n\n/-- The product of two submodules is a submodule. -/\ndef prod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) : submodule R (M × M₂) :=\n  mk (set.prod ↑p ↑q) sorry sorry sorry\n\n@[simp] theorem prod_coe {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) : ↑(prod p q) = set.prod ↑p ↑q :=\n  rfl\n\n@[simp] theorem mem_prod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {p : submodule R M} {q : submodule R M₂}\n    {x : M × M₂} : x ∈ prod p q ↔ prod.fst x ∈ p ∧ prod.snd x ∈ q :=\n  set.mem_prod\n\ntheorem span_prod_le {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (s : set M) (t : set M₂) :\n    span R (set.prod s t) ≤ prod (span R s) (span R t) :=\n  iff.mpr span_le (set.prod_mono subset_span subset_span)\n\n@[simp] theorem prod_top {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : prod ⊤ ⊤ = ⊤ :=\n  sorry\n\n@[simp] theorem prod_bot {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : prod ⊥ ⊥ = ⊥ :=\n  sorry\n\ntheorem prod_mono {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {p : submodule R M} {p' : submodule R M}\n    {q : submodule R M₂} {q' : submodule R M₂} : p ≤ p' → q ≤ q' → prod p q ≤ prod p' q' :=\n  set.prod_mono\n\n@[simp] theorem prod_inf_prod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (p' : submodule R M) (q : submodule R M₂) (q' : submodule R M₂) :\n    prod p q ⊓ prod p' q' = prod (p ⊓ p') (q ⊓ q') :=\n  coe_injective set.prod_inter_prod\n\n@[simp] theorem prod_sup_prod {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (p' : submodule R M) (q : submodule R M₂) (q' : submodule R M₂) :\n    prod p q ⊔ prod p' q' = prod (p ⊔ p') (q ⊔ q') :=\n  sorry\n\n@[simp] theorem neg_coe {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : -↑p = ↑p :=\n  set.ext fun (x : M) => neg_mem_iff p\n\n@[simp] protected theorem map_neg {R : Type u} {M : Type v} {M₂ : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) : map (-f) p = map f p :=\n  sorry\n\n@[simp] theorem span_neg {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (s : set M) : span R (-s) = span R s :=\n  sorry\n\ntheorem mem_span_insert' {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    {x : M} {y : M} {s : set M} : x ∈ span R (insert y s) ↔ ∃ (a : R), x + a • y ∈ span R s :=\n  sorry\n\n-- TODO(Mario): Factor through add_subgroup\n\n/-- The equivalence relation associated to a submodule `p`, defined by `x ≈ y` iff `y - x ∈ p`. -/\ndef quotient_rel {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : setoid M :=\n  setoid.mk (fun (x y : M) => x - y ∈ p) sorry\n\n/-- The quotient of a module `M` by a submodule `p ⊆ M`. -/\ndef quotient {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) :=\n  quotient (quotient_rel p)\n\nnamespace quotient\n\n\n/-- Map associating to an element of `M` the corresponding element of `M/p`,\nwhen `p` is a submodule of `M`. -/\ndef mk {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M] {p : submodule R M} :\n    M → quotient p :=\n  quotient.mk'\n\n@[simp] theorem mk_eq_mk {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    {p : submodule R M} (x : M) : mk x = mk x :=\n  rfl\n\n@[simp] theorem mk'_eq_mk {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    {p : submodule R M} (x : M) : quotient.mk' x = mk x :=\n  rfl\n\n@[simp] theorem quot_mk_eq_mk {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    {p : submodule R M} (x : M) : Quot.mk setoid.r x = mk x :=\n  rfl\n\nprotected theorem eq {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) {x : M} {y : M} : mk x = mk y ↔ x - y ∈ p :=\n  quotient.eq'\n\nprotected instance has_zero {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : HasZero (quotient p) :=\n  { zero := mk 0 }\n\nprotected instance inhabited {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : Inhabited (quotient p) :=\n  { default := 0 }\n\n@[simp] theorem mk_zero {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : mk 0 = 0 :=\n  rfl\n\n@[simp] theorem mk_eq_zero {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) {x : M} : mk x = 0 ↔ x ∈ p :=\n  sorry\n\nprotected instance has_add {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : Add (quotient p) :=\n  { add := fun (a b : quotient p) => quotient.lift_on₂' a b (fun (a b : M) => mk (a + b)) sorry }\n\n@[simp] theorem mk_add {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) {x : M} {y : M} : mk (x + y) = mk x + mk y :=\n  rfl\n\nprotected instance has_neg {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : Neg (quotient p) :=\n  { neg := fun (a : quotient p) => quotient.lift_on' a (fun (a : M) => mk (-a)) sorry }\n\n@[simp] theorem mk_neg {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) {x : M} : mk (-x) = -mk x :=\n  rfl\n\nprotected instance has_sub {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : Sub (quotient p) :=\n  { sub := fun (a b : quotient p) => quotient.lift_on₂' a b (fun (a b : M) => mk (a - b)) sorry }\n\n@[simp] theorem mk_sub {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) {x : M} {y : M} : mk (x - y) = mk x - mk y :=\n  rfl\n\nprotected instance add_comm_group {R : Type u} {M : Type v} [ring R] [add_comm_group M]\n    [semimodule R M] (p : submodule R M) : add_comm_group (quotient p) :=\n  add_comm_group.mk Add.add sorry 0 sorry sorry Neg.neg Sub.sub sorry sorry\n\nprotected instance has_scalar {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : has_scalar R (quotient p) :=\n  has_scalar.mk\n    fun (a : R) (x : quotient p) => quotient.lift_on' x (fun (x : M) => mk (a • x)) sorry\n\n@[simp] theorem mk_smul {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) {r : R} {x : M} : mk (r • x) = r • mk x :=\n  rfl\n\nprotected instance semimodule {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : semimodule R (quotient p) :=\n  semimodule.of_core (semimodule.core.mk (has_scalar.mk has_scalar.smul) sorry sorry sorry sorry)\n\ntheorem mk_surjective {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : function.surjective mk :=\n  id fun (b : quotient p) => quot.induction_on b fun (x : M) => Exists.intro x rfl\n\ntheorem nontrivial_of_lt_top {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M]\n    (p : submodule R M) (h : p < ⊤) : nontrivial (quotient p) :=\n  sorry\n\nend quotient\n\n\ntheorem quot_hom_ext {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    {f : linear_map R (quotient p) M₂} {g : linear_map R (quotient p) M₂}\n    (h : ∀ (x : M), coe_fn f (quotient.mk x) = coe_fn g (quotient.mk x)) : f = g :=\n  linear_map.ext fun (x : quotient p) => quotient.induction_on' x h\n\nend submodule\n\n\nnamespace submodule\n\n\ntheorem comap_smul {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂)\n    (p : submodule K V₂) (a : K) (h : a ≠ 0) : comap (a • f) p = comap f p :=\n  sorry\n\ntheorem map_smul {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂)\n    (p : submodule K V) (a : K) (h : a ≠ 0) : map (a • f) p = map f p :=\n  sorry\n\ntheorem comap_smul' {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂)\n    (p : submodule K V₂) (a : K) : comap (a • f) p = infi fun (h : a ≠ 0) => comap f p :=\n  sorry\n\ntheorem map_smul' {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂)\n    (p : submodule K V) (a : K) : map (a • f) p = supr fun (h : a ≠ 0) => map f p :=\n  sorry\n\nend submodule\n\n\n/-! ### Properties of linear maps -/\n\nnamespace linear_map\n\n\n/-- If two linear maps are equal on a set `s`, then they are equal on `submodule.span s`.\n\nSee also `linear_map.eq_on_span'` for a version using `set.eq_on`. -/\ntheorem eq_on_span {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {s : set M} {f : linear_map R M M₂}\n    {g : linear_map R M M₂} (H : set.eq_on (⇑f) (⇑g) s) {x : M} (h : x ∈ submodule.span R s) :\n    coe_fn f x = coe_fn g x :=\n  sorry\n\n/-- If two linear maps are equal on a set `s`, then they are equal on `submodule.span s`.\n\nThis version uses `set.eq_on`, and the hidden argument will expand to `h : x ∈ (span R s : set M)`.\nSee `linear_map.eq_on_span` for a version that takes `h : x ∈ span R s` as an argument. -/\ntheorem eq_on_span' {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {s : set M} {f : linear_map R M M₂}\n    {g : linear_map R M M₂} (H : set.eq_on (⇑f) (⇑g) s) : set.eq_on ⇑f ⇑g ↑(submodule.span R s) :=\n  eq_on_span H\n\n/-- If `s` generates the whole semimodule and linear maps `f`, `g` are equal on `s`, then they are\nequal. -/\ntheorem ext_on {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {s : set M} {f : linear_map R M M₂}\n    {g : linear_map R M M₂} (hv : submodule.span R s = ⊤) (h : set.eq_on (⇑f) (⇑g) s) : f = g :=\n  ext fun (x : M) => eq_on_span h (iff.mp submodule.eq_top_iff' hv x)\n\n/-- If the range of `v : ι → M` generates the whole semimodule and linear maps `f`, `g` are equal at\neach `v i`, then they are equal. -/\ntheorem ext_on_range {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {v : ι → M}\n    {f : linear_map R M M₂} {g : linear_map R M M₂} (hv : submodule.span R (set.range v) = ⊤)\n    (h : ∀ (i : ι), coe_fn f (v i) = coe_fn g (v i)) : f = g :=\n  ext_on hv (iff.mpr set.forall_range_iff h)\n\n@[simp] theorem map_finsupp_sum {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {γ : Type u_1}\n    [HasZero γ] (f : linear_map R M M₂) {t : ι →₀ γ} {g : ι → γ → M} :\n    coe_fn f (finsupp.sum t g) = finsupp.sum t fun (i : ι) (d : γ) => coe_fn f (g i d) :=\n  map_sum f\n\ntheorem coe_finsupp_sum {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {γ : Type u_1}\n    [HasZero γ] (t : ι →₀ γ) (g : ι → γ → linear_map R M M₂) :\n    ⇑(finsupp.sum t g) = finsupp.sum t fun (i : ι) (d : γ) => ⇑(g i d) :=\n  coe_fn_sum (finsupp.support t) fun (a : ι) => g a (coe_fn t a)\n\n@[simp] theorem finsupp_sum_apply {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {γ : Type u_1}\n    [HasZero γ] (t : ι →₀ γ) (g : ι → γ → linear_map R M M₂) (b : M) :\n    coe_fn (finsupp.sum t g) b = finsupp.sum t fun (i : ι) (d : γ) => coe_fn (g i d) b :=\n  sum_apply (finsupp.support t) (fun (a : ι) => g a (coe_fn t a)) b\n\n@[simp] theorem map_dfinsupp_sum {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {γ : ι → Type u_1}\n    [DecidableEq ι] [(i : ι) → HasZero (γ i)] [(i : ι) → (x : γ i) → Decidable (x ≠ 0)]\n    (f : linear_map R M M₂) {t : dfinsupp fun (i : ι) => γ i} {g : (i : ι) → γ i → M} :\n    coe_fn f (dfinsupp.sum t g) = dfinsupp.sum t fun (i : ι) (d : γ i) => coe_fn f (g i d) :=\n  map_sum f\n\ntheorem coe_dfinsupp_sum {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {γ : ι → Type u_1}\n    [DecidableEq ι] [(i : ι) → HasZero (γ i)] [(i : ι) → (x : γ i) → Decidable (x ≠ 0)]\n    (t : dfinsupp fun (i : ι) => γ i) (g : (i : ι) → γ i → linear_map R M M₂) :\n    ⇑(dfinsupp.sum t g) = dfinsupp.sum t fun (i : ι) (d : γ i) => ⇑(g i d) :=\n  coe_fn_sum (dfinsupp.support t) fun (i : ι) => g i (coe_fn t i)\n\n@[simp] theorem dfinsupp_sum_apply {R : Type u} {M : Type v} {M₂ : Type w} {ι : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {γ : ι → Type u_1}\n    [DecidableEq ι] [(i : ι) → HasZero (γ i)] [(i : ι) → (x : γ i) → Decidable (x ≠ 0)]\n    (t : dfinsupp fun (i : ι) => γ i) (g : (i : ι) → γ i → linear_map R M M₂) (b : M) :\n    coe_fn (dfinsupp.sum t g) b = dfinsupp.sum t fun (i : ι) (d : γ i) => coe_fn (g i d) b :=\n  sum_apply (dfinsupp.support t) (fun (i : ι) => g i (coe_fn t i)) b\n\ntheorem map_cod_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M₂ M) (h : ∀ (c : M₂), coe_fn f c ∈ p) (p' : submodule R M₂) :\n    submodule.map (cod_restrict p f h) p' =\n        submodule.comap (submodule.subtype p) (submodule.map f p') :=\n  sorry\n\ntheorem comap_cod_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M₂ M) (hf : ∀ (c : M₂), coe_fn f c ∈ p) (p' : submodule R ↥p) :\n    submodule.comap (cod_restrict p f hf) p' =\n        submodule.comap f (submodule.map (submodule.subtype p) p') :=\n  sorry\n\n/-- The range of a linear map `f : M → M₂` is a submodule of `M₂`. -/\ndef range {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    submodule R M₂ :=\n  submodule.map f ⊤\n\ntheorem range_coe {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    ↑(range f) = set.range ⇑f :=\n  set.image_univ\n\n@[simp] theorem mem_range {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} {x : M₂} :\n    x ∈ range f ↔ ∃ (y : M), coe_fn f y = x :=\n  iff.mp set.ext_iff (range_coe f)\n\ntheorem mem_range_self {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) (x : M) :\n    coe_fn f x ∈ range f :=\n  iff.mpr mem_range (Exists.intro x rfl)\n\n@[simp] theorem range_id {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : range id = ⊤ :=\n  submodule.map_id ⊤\n\ntheorem range_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) :\n    range (comp g f) = submodule.map g (range f) :=\n  submodule.map_comp f g ⊤\n\ntheorem range_comp_le_range {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) :\n    range (comp g f) ≤ range g :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (range (comp g f) ≤ range g)) (range_comp f g)))\n    (submodule.map_mono le_top)\n\ntheorem range_eq_top {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} :\n    range f = ⊤ ↔ function.surjective ⇑f :=\n  sorry\n\ntheorem range_le_iff_comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M₂} : range f ≤ p ↔ submodule.comap f p = ⊤ :=\n  sorry\n\ntheorem map_le_range {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} : submodule.map f p ≤ range f :=\n  submodule.map_mono le_top\n\ntheorem range_coprod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₃) (g : linear_map R M₂ M₃) :\n    range (coprod f g) = range f ⊔ range g :=\n  sorry\n\ntheorem is_compl_range_inl_inr {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    is_compl (range (inl R M M₂)) (range (inr R M M₂)) :=\n  sorry\n\ntheorem sup_range_inl_inr {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    range (inl R M M₂) ⊔ range (inr R M M₂) = ⊤ :=\n  is_compl.sup_eq_top is_compl_range_inl_inr\n\n/-- Restrict the codomain of a linear map `f` to `f.range`. -/\ndef range_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    linear_map R M ↥(range f) :=\n  cod_restrict (range f) f (mem_range_self f)\n\n/-- Given an element `x` of a module `M` over `R`, the natural map from\n    `R` to scalar multiples of `x`.-/\ndef to_span_singleton (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M] [semimodule R M]\n    (x : M) : linear_map R R M :=\n  smul_right id x\n\n/-- The range of `to_span_singleton x` is the span of `x`.-/\ntheorem span_singleton_eq_range (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] (x : M) : submodule.span R (singleton x) = range (to_span_singleton R M x) :=\n  submodule.ext fun (y : M) => iff.trans submodule.mem_span_singleton (iff.symm mem_range)\n\ntheorem to_span_singleton_one (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] (x : M) : coe_fn (to_span_singleton R M x) 1 = x :=\n  one_smul R x\n\n/-- The kernel of a linear map `f : M → M₂` is defined to be `comap f ⊥`. This is equivalent to the\nset of `x : M` such that `f x = 0`. The kernel is a submodule of `M`. -/\ndef ker {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    submodule R M :=\n  submodule.comap f ⊥\n\n@[simp] theorem mem_ker {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} {y : M} :\n    y ∈ ker f ↔ coe_fn f y = 0 :=\n  submodule.mem_bot R\n\n@[simp] theorem ker_id {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] :\n    ker id = ⊥ :=\n  rfl\n\n@[simp] theorem map_coe_ker {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) (x : ↥(ker f)) :\n    coe_fn f ↑x = 0 :=\n  iff.mp mem_ker (subtype.property x)\n\ntheorem comp_ker_subtype {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    comp f (submodule.subtype (ker f)) = 0 :=\n  sorry\n\ntheorem ker_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) :\n    ker (comp g f) = submodule.comap f (ker g) :=\n  rfl\n\ntheorem ker_le_ker_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M₂ M₃) : ker f ≤ ker (comp g f) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (ker f ≤ ker (comp g f))) (ker_comp f g)))\n    (submodule.comap_mono bot_le)\n\ntheorem disjoint_ker {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} : disjoint p (ker f) ↔ ∀ (x : M), x ∈ p → coe_fn f x = 0 → x = 0 :=\n  sorry\n\ntheorem disjoint_inl_inr {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    disjoint (range (inl R M M₂)) (range (inr R M M₂)) :=\n  sorry\n\ntheorem ker_eq_bot' {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} :\n    ker f = ⊥ ↔ ∀ (m : M), coe_fn f m = 0 → m = 0 :=\n  sorry\n\ntheorem ker_eq_bot_of_inverse {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    {f : linear_map R M M₂} {g : linear_map R M₂ M} (h : comp g f = id) : ker f = ⊥ :=\n  sorry\n\ntheorem le_ker_iff_map {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} : p ≤ ker f ↔ submodule.map f p = ⊥ :=\n  sorry\n\ntheorem ker_cod_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M₂ M) (hf : ∀ (c : M₂), coe_fn f c ∈ p) : ker (cod_restrict p f hf) = ker f :=\n  sorry\n\ntheorem range_cod_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M₂ M) (hf : ∀ (c : M₂), coe_fn f c ∈ p) :\n    range (cod_restrict p f hf) = submodule.comap (submodule.subtype p) (range f) :=\n  map_cod_restrict p f hf ⊤\n\ntheorem ker_restrict {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {p : submodule R M} {f : linear_map R M M} (hf : ∀ (x : M), x ∈ p → coe_fn f x ∈ p) :\n    ker (restrict f hf) = ker (dom_restrict f p) :=\n  sorry\n\ntheorem map_comap_eq {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (q : submodule R M₂) : submodule.map f (submodule.comap f q) = range f ⊓ q :=\n  sorry\n\ntheorem map_comap_eq_self {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {q : submodule R M₂} (h : q ≤ range f) : submodule.map f (submodule.comap f q) = q :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (submodule.map f (submodule.comap f q) = q)) (map_comap_eq f q)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (range f ⊓ q = q)) (propext inf_eq_right))) h)\n\n@[simp] theorem ker_zero {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : ker 0 = ⊤ :=\n  sorry\n\n@[simp] theorem range_zero {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] : range 0 = ⊥ :=\n  submodule.map_zero ⊤\n\ntheorem ker_eq_top {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} :\n    ker f = ⊤ ↔ f = 0 :=\n  { mp := fun (h : ker f = ⊤) => ext fun (x : M) => iff.mp mem_ker (Eq.symm h ▸ trivial),\n    mpr := fun (h : f = 0) => Eq.symm h ▸ ker_zero }\n\ntheorem range_le_bot_iff {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    range f ≤ ⊥ ↔ f = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (range f ≤ ⊥ ↔ f = 0)) (propext range_le_iff_comap))) ker_eq_top\n\ntheorem range_eq_bot {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} :\n    range f = ⊥ ↔ f = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (range f = ⊥ ↔ f = 0)) (Eq.symm (propext (range_le_bot_iff f)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (range f = ⊥ ↔ range f ≤ ⊥)) (propext le_bot_iff)))\n      (iff.refl (range f = ⊥)))\n\ntheorem range_le_ker_iff {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] {f : linear_map R M M₂} {g : linear_map R M₂ M₃} :\n    range f ≤ ker g ↔ comp g f = 0 :=\n  sorry\n\ntheorem comap_le_comap_iff {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    (hf : range f = ⊤) {p : submodule R M₂} {p' : submodule R M₂} :\n    submodule.comap f p ≤ submodule.comap f p' ↔ p ≤ p' :=\n  sorry\n\ntheorem comap_injective {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    (hf : range f = ⊤) : function.injective (submodule.comap f) :=\n  fun (p p' : submodule R M₂) (h : submodule.comap f p = submodule.comap f p') =>\n    le_antisymm (iff.mp (comap_le_comap_iff hf) (le_of_eq h))\n      (iff.mp (comap_le_comap_iff hf) (ge_of_eq h))\n\ntheorem map_coprod_prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₃) (g : linear_map R M₂ M₃) (p : submodule R M)\n    (q : submodule R M₂) :\n    submodule.map (coprod f g) (submodule.prod p q) = submodule.map f p ⊔ submodule.map g q :=\n  sorry\n\ntheorem comap_prod_prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₃) (p : submodule R M₂)\n    (q : submodule R M₃) :\n    submodule.comap (prod f g) (submodule.prod p q) = submodule.comap f p ⊓ submodule.comap g q :=\n  submodule.ext fun (x : M) => iff.rfl\n\ntheorem prod_eq_inf_comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) :\n    submodule.prod p q = submodule.comap (fst R M M₂) p ⊓ submodule.comap (snd R M M₂) q :=\n  submodule.ext fun (x : M × M₂) => iff.rfl\n\ntheorem prod_eq_sup_map {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) :\n    submodule.prod p q = submodule.map (inl R M M₂) p ⊔ submodule.map (inr R M M₂) q :=\n  sorry\n\ntheorem span_inl_union_inr {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] {s : set M} {t : set M₂} :\n    submodule.span R (⇑(inl R M M₂) '' s ∪ ⇑(inr R M M₂) '' t) =\n        submodule.prod (submodule.span R s) (submodule.span R t) :=\n  sorry\n\n@[simp] theorem ker_prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₃) :\n    ker (prod f g) = ker f ⊓ ker g :=\n  sorry\n\ntheorem range_prod_le {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_map R M M₂) (g : linear_map R M M₃) :\n    range (prod f g) ≤ submodule.prod (range f) (range g) :=\n  sorry\n\ntheorem ker_eq_bot_of_injective {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    {f : linear_map R M M₂} (hf : function.injective ⇑f) : ker f = ⊥ :=\n  sorry\n\ntheorem comap_map_eq {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    (p : submodule R M) : submodule.comap f (submodule.map f p) = p ⊔ ker f :=\n  sorry\n\ntheorem comap_map_eq_self {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} (h : ker f ≤ p) : submodule.comap f (submodule.map f p) = p :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (submodule.comap f (submodule.map f p) = p)) (comap_map_eq f p)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (p ⊔ ker f = p)) (sup_of_le_left h))) (Eq.refl p))\n\ntheorem map_le_map_iff {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂)\n    {p : submodule R M} {p' : submodule R M} :\n    submodule.map f p ≤ submodule.map f p' ↔ p ≤ p' ⊔ ker f :=\n  sorry\n\ntheorem map_le_map_iff' {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} (hf : ker f = ⊥)\n    {p : submodule R M} {p' : submodule R M} : submodule.map f p ≤ submodule.map f p' ↔ p ≤ p' :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (submodule.map f p ≤ submodule.map f p' ↔ p ≤ p'))\n        (propext (map_le_map_iff f))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (p ≤ p' ⊔ ker f ↔ p ≤ p')) hf))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (p ≤ p' ⊔ ⊥ ↔ p ≤ p')) sup_bot_eq)) (iff.refl (p ≤ p'))))\n\ntheorem map_injective {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    (hf : ker f = ⊥) : function.injective (submodule.map f) :=\n  fun (p p' : submodule R M) (h : submodule.map f p = submodule.map f p') =>\n    le_antisymm (iff.mp (map_le_map_iff' hf) (le_of_eq h))\n      (iff.mp (map_le_map_iff' hf) (ge_of_eq h))\n\ntheorem map_eq_top_iff {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    (hf : range f = ⊤) {p : submodule R M} : submodule.map f p = ⊤ ↔ p ⊔ ker f = ⊤ :=\n  sorry\n\ntheorem sub_mem_ker_iff {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} {x : M} {y : M} :\n    x - y ∈ ker f ↔ coe_fn f x = coe_fn f y :=\n  sorry\n\ntheorem disjoint_ker' {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} :\n    disjoint p (ker f) ↔ ∀ (x y : M), x ∈ p → y ∈ p → coe_fn f x = coe_fn f y → x = y :=\n  sorry\n\ntheorem inj_of_disjoint_ker {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} {s : set M} (h : s ⊆ ↑p) (hd : disjoint p (ker f)) (x : M) (y : M)\n    (H : x ∈ s) : y ∈ s → coe_fn f x = coe_fn f y → x = y :=\n  fun (hy : y ∈ s) => iff.mp disjoint_ker' hd x y (h hx) (h hy)\n\ntheorem ker_eq_bot {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} :\n    ker f = ⊥ ↔ function.injective ⇑f :=\n  sorry\n\ntheorem ker_le_iff {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂}\n    {p : submodule R M} : ker f ≤ p ↔ ∃ (y : M₂), ∃ (H : y ∈ range f), ⇑f ⁻¹' singleton y ⊆ ↑p :=\n  sorry\n\n/-- If the union of the kernels `ker f` and `ker g` spans the domain, then the range of\n`prod f g` is equal to the product of `range f` and `range g`. -/\ntheorem range_prod_eq {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [ring R]\n    [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] {f : linear_map R M M₂} {g : linear_map R M M₃} (h : ker f ⊔ ker g = ⊤) :\n    range (prod f g) = submodule.prod (range f) (range g) :=\n  sorry\n\ntheorem ker_smul {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂) (a : K)\n    (h : a ≠ 0) : ker (a • f) = ker f :=\n  submodule.comap_smul f ⊥ a h\n\ntheorem ker_smul' {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂) (a : K) :\n    ker (a • f) = infi fun (h : a ≠ 0) => ker f :=\n  submodule.comap_smul' f ⊥ a\n\ntheorem range_smul {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂) (a : K)\n    (h : a ≠ 0) : range (a • f) = range f :=\n  submodule.map_smul f ⊤ a h\n\ntheorem range_smul' {K : Type u'} {V : Type v'} {V₂ : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V V₂) (a : K) :\n    range (a • f) = supr fun (h : a ≠ 0) => range f :=\n  submodule.map_smul' f ⊤ a\n\nend linear_map\n\n\ntheorem submodule.sup_eq_range {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) (q : submodule R M) :\n    p ⊔ q = linear_map.range (linear_map.coprod (submodule.subtype p) (submodule.subtype q)) :=\n  sorry\n\nnamespace is_linear_map\n\n\ntheorem is_linear_map_add {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : is_linear_map R fun (x : M × M) => prod.fst x + prod.snd x :=\n  sorry\n\ntheorem is_linear_map_sub {R : Type u_1} {M : Type u_2} [semiring R] [add_comm_group M]\n    [semimodule R M] : is_linear_map R fun (x : M × M) => prod.fst x - prod.snd x :=\n  sorry\n\nend is_linear_map\n\n\nnamespace submodule\n\n\n@[simp] theorem map_top {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : linear_map R M M₂) :\n    map f ⊤ = linear_map.range f :=\n  rfl\n\n@[simp] theorem comap_bot {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (f : linear_map R M M₂) : comap f ⊥ = linear_map.ker f :=\n  rfl\n\n@[simp] theorem ker_subtype {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) : linear_map.ker (submodule.subtype p) = ⊥ :=\n  linear_map.ker_eq_bot_of_injective fun (x y : ↥p) => subtype.ext_val\n\n@[simp] theorem range_subtype {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) : linear_map.range (submodule.subtype p) = p :=\n  sorry\n\ntheorem map_subtype_le {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) (p' : submodule R ↥p) : map (submodule.subtype p) p' ≤ p :=\n  sorry\n\n/-- Under the canonical linear map from a submodule `p` to the ambient space `M`, the image of the\nmaximal submodule of `p` is just `p `. -/\n@[simp] theorem map_subtype_top {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) : map (submodule.subtype p) ⊤ = p :=\n  sorry\n\n@[simp] theorem comap_subtype_eq_top {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M]\n    [semimodule R M] {p : submodule R M} {p' : submodule R M} :\n    comap (submodule.subtype p) p' = ⊤ ↔ p ≤ p' :=\n  sorry\n\n@[simp] theorem comap_subtype_self {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) : comap (submodule.subtype p) p = ⊤ :=\n  iff.mpr comap_subtype_eq_top (le_refl p)\n\n@[simp] theorem ker_of_le {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M]\n    [semimodule R M] (p : submodule R M) (p' : submodule R M) (h : p ≤ p') :\n    linear_map.ker (of_le h) = ⊥ :=\n  sorry\n\ntheorem range_of_le {R : Type u} {M : Type v} {T : semiring R} [add_comm_monoid M] [semimodule R M]\n    (p : submodule R M) (q : submodule R M) (h : p ≤ q) :\n    linear_map.range (of_le h) = comap (submodule.subtype q) p :=\n  sorry\n\n@[simp] theorem map_inl {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M) :\n    map (linear_map.inl R M M₂) p = prod p ⊥ :=\n  sorry\n\n@[simp] theorem map_inr {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (q : submodule R M₂) :\n    map (linear_map.inr R M M₂) q = prod ⊥ q :=\n  sorry\n\n@[simp] theorem comap_fst {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (p : submodule R M) : comap (linear_map.fst R M M₂) p = prod p ⊤ :=\n  sorry\n\n@[simp] theorem comap_snd {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (q : submodule R M₂) : comap (linear_map.snd R M M₂) q = prod ⊤ q :=\n  sorry\n\n@[simp] theorem prod_comap_inl {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) : comap (linear_map.inl R M M₂) (prod p q) = p :=\n  sorry\n\n@[simp] theorem prod_comap_inr {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) : comap (linear_map.inr R M M₂) (prod p q) = q :=\n  sorry\n\n@[simp] theorem prod_map_fst {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) : map (linear_map.fst R M M₂) (prod p q) = p :=\n  sorry\n\n@[simp] theorem prod_map_snd {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (q : submodule R M₂) : map (linear_map.snd R M M₂) (prod p q) = q :=\n  sorry\n\n@[simp] theorem ker_inl {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    linear_map.ker (linear_map.inl R M M₂) = ⊥ :=\n  sorry\n\n@[simp] theorem ker_inr {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    linear_map.ker (linear_map.inr R M M₂) = ⊥ :=\n  sorry\n\n@[simp] theorem range_fst {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    linear_map.range (linear_map.fst R M M₂) = ⊤ :=\n  sorry\n\n@[simp] theorem range_snd {R : Type u} {M : Type v} {M₂ : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] :\n    linear_map.range (linear_map.snd R M M₂) = ⊤ :=\n  sorry\n\ntheorem disjoint_iff_comap_eq_bot {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] {p : submodule R M} {q : submodule R M} :\n    disjoint p q ↔ comap (submodule.subtype p) q = ⊥ :=\n  sorry\n\n/-- If `N ⊆ M` then submodules of `N` are the same as submodules of `M` contained in `N` -/\ndef map_subtype.rel_iso {R : Type u} {M : Type v} {T : ring R} [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : submodule R ↥p ≃o Subtype fun (p' : submodule R M) => p' ≤ p :=\n  rel_iso.mk\n    (equiv.mk\n      (fun (p' : submodule R ↥p) => { val := map (submodule.subtype p) p', property := sorry })\n      (fun (q : Subtype fun (p' : submodule R M) => p' ≤ p) => comap (submodule.subtype p) ↑q) sorry\n      sorry)\n    sorry\n\n/-- If `p ⊆ M` is a submodule, the ordering of submodules of `p` is embedded in the ordering of\nsubmodules of `M`. -/\ndef map_subtype.order_embedding {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] (p : submodule R M) : submodule R ↥p ↪o submodule R M :=\n  rel_embedding.trans (rel_iso.to_rel_embedding (map_subtype.rel_iso p))\n    (subtype.rel_embedding LessEq fun (p' : submodule R M) => p' ≤ p)\n\n@[simp] theorem map_subtype_embedding_eq {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] (p : submodule R M) (p' : submodule R ↥p) :\n    coe_fn (map_subtype.order_embedding p) p' = map (submodule.subtype p) p' :=\n  rfl\n\n/-- The map from a module `M` to the quotient of `M` by a submodule `p` as a linear map. -/\ndef mkq {R : Type u} {M : Type v} {T : ring R} [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : linear_map R M (quotient p) :=\n  linear_map.mk quotient.mk sorry sorry\n\n@[simp] theorem mkq_apply {R : Type u} {M : Type v} {T : ring R} [add_comm_group M] [semimodule R M]\n    (p : submodule R M) (x : M) : coe_fn (mkq p) x = quotient.mk x :=\n  rfl\n\n/-- The map from the quotient of `M` by a submodule `p` to `M₂` induced by a linear map `f : M → M₂`\nvanishing on `p`, as a linear map. -/\ndef liftq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) (h : p ≤ linear_map.ker f) : linear_map R (quotient p) M₂ :=\n  linear_map.mk (fun (x : quotient p) => quotient.lift_on' x ⇑f sorry) sorry sorry\n\n@[simp] theorem liftq_apply {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) {h : p ≤ linear_map.ker f} (x : M) :\n    coe_fn (liftq p f h) (quotient.mk x) = coe_fn f x :=\n  rfl\n\n@[simp] theorem liftq_mkq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) (h : p ≤ linear_map.ker f) :\n    linear_map.comp (liftq p f h) (mkq p) = f :=\n  linear_map.ext fun (x : M) => Eq.refl (coe_fn (linear_map.comp (liftq p f h) (mkq p)) x)\n\n@[simp] theorem range_mkq {R : Type u} {M : Type v} {T : ring R} [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : linear_map.range (mkq p) = ⊤ :=\n  iff.mpr eq_top_iff'\n    fun (x : quotient p) =>\n      quot.induction_on x fun (x : M) => Exists.intro x { left := trivial, right := rfl }\n\n@[simp] theorem ker_mkq {R : Type u} {M : Type v} {T : ring R} [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : linear_map.ker (mkq p) = p :=\n  sorry\n\ntheorem le_comap_mkq {R : Type u} {M : Type v} {T : ring R} [add_comm_group M] [semimodule R M]\n    (p : submodule R M) (p' : submodule R (quotient p)) : p ≤ comap (mkq p) p' :=\n  sorry\n\n@[simp] theorem mkq_map_self {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] (p : submodule R M) : map (mkq p) p = ⊥ :=\n  sorry\n\n@[simp] theorem comap_map_mkq {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] (p : submodule R M) (p' : submodule R M) :\n    comap (mkq p) (map (mkq p) p') = p ⊔ p' :=\n  sorry\n\n@[simp] theorem map_mkq_eq_top {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] (p : submodule R M) (p' : submodule R M) : map (mkq p) p' = ⊤ ↔ p ⊔ p' = ⊤ :=\n  sorry\n\n/-- The map from the quotient of `M` by submodule `p` to the quotient of `M₂` by submodule `q` along\n`f : M → M₂` is linear. -/\ndef mapq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M] [add_comm_group M₂]\n    [semimodule R M] [semimodule R M₂] (p : submodule R M) (q : submodule R M₂)\n    (f : linear_map R M M₂) (h : p ≤ comap f q) : linear_map R (quotient p) (quotient q) :=\n  liftq p (linear_map.comp (mkq q) f) sorry\n\n@[simp] theorem mapq_apply {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M) (q : submodule R M₂)\n    (f : linear_map R M M₂) {h : p ≤ comap f q} (x : M) :\n    coe_fn (mapq p q f h) (quotient.mk x) = quotient.mk (coe_fn f x) :=\n  rfl\n\ntheorem mapq_mkq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M) (q : submodule R M₂)\n    (f : linear_map R M M₂) {h : p ≤ comap f q} :\n    linear_map.comp (mapq p q f h) (mkq p) = linear_map.comp (mkq q) f :=\n  linear_map.ext fun (x : M) => Eq.refl (coe_fn (linear_map.comp (mapq p q f h) (mkq p)) x)\n\ntheorem comap_liftq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M) (q : submodule R M₂)\n    (f : linear_map R M M₂) (h : p ≤ linear_map.ker f) :\n    comap (liftq p f h) q = map (mkq p) (comap f q) :=\n  sorry\n\ntheorem map_liftq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) (h : p ≤ linear_map.ker f) (q : submodule R (quotient p)) :\n    map (liftq p f h) q = map f (comap (mkq p) q) :=\n  sorry\n\ntheorem ker_liftq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) (h : p ≤ linear_map.ker f) :\n    linear_map.ker (liftq p f h) = map (mkq p) (linear_map.ker f) :=\n  comap_liftq p ⊥ f h\n\ntheorem range_liftq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) (h : p ≤ linear_map.ker f) :\n    linear_map.range (liftq p f h) = linear_map.range f :=\n  map_liftq p f h ⊤\n\ntheorem ker_liftq_eq_bot {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (p : submodule R M)\n    (f : linear_map R M M₂) (h : p ≤ linear_map.ker f) (h' : linear_map.ker f ≤ p) :\n    linear_map.ker (liftq p f h) = ⊥ :=\n  sorry\n\n/-- The correspondence theorem for modules: there is an order isomorphism between submodules of the\nquotient of `M` by `p`, and submodules of `M` larger than `p`. -/\ndef comap_mkq.rel_iso {R : Type u} {M : Type v} {T : ring R} [add_comm_group M] [semimodule R M]\n    (p : submodule R M) : submodule R (quotient p) ≃o Subtype fun (p' : submodule R M) => p ≤ p' :=\n  rel_iso.mk\n    (equiv.mk\n      (fun (p' : submodule R (quotient p)) =>\n        { val := comap (mkq p) p', property := le_comap_mkq p p' })\n      (fun (q : Subtype fun (p' : submodule R M) => p ≤ p') => map (mkq p) ↑q) sorry sorry)\n    sorry\n\n/-- The ordering on submodules of the quotient of `M` by `p` embeds into the ordering on submodules\nof `M`. -/\ndef comap_mkq.order_embedding {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] (p : submodule R M) : submodule R (quotient p) ↪o submodule R M :=\n  rel_embedding.trans (rel_iso.to_rel_embedding (comap_mkq.rel_iso p))\n    (subtype.rel_embedding LessEq fun (p' : submodule R M) => p ≤ p')\n\n@[simp] theorem comap_mkq_embedding_eq {R : Type u} {M : Type v} {T : ring R} [add_comm_group M]\n    [semimodule R M] (p : submodule R M) (p' : submodule R (quotient p)) :\n    coe_fn (comap_mkq.order_embedding p) p' = comap (mkq p) p' :=\n  rfl\n\ntheorem span_preimage_eq {R : Type u} {M : Type v} {M₂ : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] {f : linear_map R M M₂} {s : set M₂}\n    (h₀ : set.nonempty s) (h₁ : s ⊆ ↑(linear_map.range f)) :\n    span R (⇑f ⁻¹' s) = comap f (span R s) :=\n  sorry\n\nend submodule\n\n\nnamespace linear_map\n\n\ntheorem range_mkq_comp {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] (f : linear_map R M M₂) :\n    comp (submodule.mkq (range f)) f = 0 :=\n  sorry\n\ntheorem ker_le_range_iff {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [ring R]\n    [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃] [module R M] [module R M₂]\n    [module R M₃] {f : linear_map R M M₂} {g : linear_map R M₂ M₃} :\n    ker g ≤ range f ↔ comp (submodule.mkq (range f)) (submodule.subtype (ker g)) = 0 :=\n  sorry\n\n/-- A monomorphism is injective. -/\ntheorem ker_eq_bot_of_cancel {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] {f : linear_map R M M₂}\n    (h : ∀ (u v : linear_map R (↥(ker f)) M), comp f u = comp f v → u = v) : ker f = ⊥ :=\n  sorry\n\n/-- An epimorphism is surjective. -/\ntheorem range_eq_top_of_cancel {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] {f : linear_map R M M₂}\n    (h : ∀ (u v : linear_map R M₂ (submodule.quotient (range f))), comp u f = comp v f → u = v) :\n    range f = ⊤ :=\n  sorry\n\nend linear_map\n\n\n@[simp] theorem linear_map.range_range_restrict {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂]\n    (f : linear_map R M M₂) : linear_map.range (linear_map.range_restrict f) = ⊤ :=\n  sorry\n\n/-! ### Linear equivalences -/\n\nnamespace linear_equiv\n\n\ntheorem map_eq_comap {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (e : linear_equiv R M M₂) {p : submodule R M} :\n    submodule.map (↑e) p = submodule.comap (↑(symm e)) p :=\n  sorry\n\n/-- A linear equivalence of two modules restricts to a linear equivalence from any submodule\nof the domain onto the image of the submodule. -/\ndef of_submodule {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (e : linear_equiv R M M₂) (p : submodule R M) : linear_equiv R ↥p ↥(submodule.map (↑e) p) :=\n  mk\n    (linear_map.to_fun\n      (linear_map.cod_restrict (submodule.map (↑e) p) (linear_map.dom_restrict (↑e) p) sorry))\n    sorry sorry\n    (fun (y : ↥(submodule.map (↑e) p)) => { val := coe_fn (symm e) ↑y, property := sorry }) sorry\n    sorry\n\n@[simp] theorem of_submodule_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (e : linear_equiv R M M₂) (p : submodule R M) (x : ↥p) :\n    ↑(coe_fn (of_submodule e p) x) = coe_fn e ↑x :=\n  rfl\n\n@[simp] theorem of_submodule_symm_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (e : linear_equiv R M M₂) (p : submodule R M)\n    (x : ↥(submodule.map (↑e) p)) : ↑(coe_fn (symm (of_submodule e p)) x) = coe_fn (symm e) ↑x :=\n  rfl\n\n/-- Product of linear equivalences; the maps come from `equiv.prod_congr`. -/\nprotected def prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n    {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    {semimodule_M₃ : semimodule R M₃} {semimodule_M₄ : semimodule R M₄} (e₁ : linear_equiv R M M₂)\n    (e₂ : linear_equiv R M₃ M₄) : linear_equiv R (M × M₃) (M₂ × M₄) :=\n  mk (equiv.to_fun (equiv.prod_congr (to_equiv e₁) (to_equiv e₂))) sorry sorry\n    (equiv.inv_fun (equiv.prod_congr (to_equiv e₁) (to_equiv e₂))) sorry sorry\n\ntheorem prod_symm {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n    {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    {semimodule_M₃ : semimodule R M₃} {semimodule_M₄ : semimodule R M₄} (e₁ : linear_equiv R M M₂)\n    (e₂ : linear_equiv R M₃ M₄) :\n    symm (linear_equiv.prod e₁ e₂) = linear_equiv.prod (symm e₁) (symm e₂) :=\n  rfl\n\n@[simp] theorem prod_apply {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n    {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    {semimodule_M₃ : semimodule R M₃} {semimodule_M₄ : semimodule R M₄} (e₁ : linear_equiv R M M₂)\n    (e₂ : linear_equiv R M₃ M₄) (p : M × M₃) :\n    coe_fn (linear_equiv.prod e₁ e₂) p = (coe_fn e₁ (prod.fst p), coe_fn e₂ (prod.snd p)) :=\n  rfl\n\n@[simp] theorem coe_prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n    {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    {semimodule_M₃ : semimodule R M₃} {semimodule_M₄ : semimodule R M₄} (e₁ : linear_equiv R M M₂)\n    (e₂ : linear_equiv R M₃ M₄) : ↑(linear_equiv.prod e₁ e₂) = linear_map.prod_map ↑e₁ ↑e₂ :=\n  rfl\n\n/-- Linear equivalence between a curried and uncurried function.\n  Differs from `tensor_product.curry`. -/\nprotected def uncurry (R : Type u) (V : Type v') (V₂ : Type w') [semiring R] :\n    linear_equiv R (V → V₂ → R) (V × V₂ → R) :=\n  mk (equiv.to_fun (equiv.arrow_arrow_equiv_prod_arrow V V₂ R)) sorry sorry\n    (equiv.inv_fun (equiv.arrow_arrow_equiv_prod_arrow V V₂ R)) sorry sorry\n\n@[simp] theorem coe_uncurry (R : Type u) (V : Type v') (V₂ : Type w') [semiring R] :\n    ⇑(linear_equiv.uncurry R V V₂) = function.uncurry :=\n  rfl\n\n@[simp] theorem coe_uncurry_symm (R : Type u) (V : Type v') (V₂ : Type w') [semiring R] :\n    ⇑(symm (linear_equiv.uncurry R V V₂)) = function.curry :=\n  rfl\n\n/-- Linear equivalence between two equal submodules. -/\ndef of_eq {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] {semimodule_M : semimodule R M}\n    (p : submodule R M) (q : submodule R M) (h : p = q) : linear_equiv R ↥p ↥q :=\n  mk (equiv.to_fun (equiv.set.of_eq sorry)) sorry sorry (equiv.inv_fun (equiv.set.of_eq sorry))\n    sorry sorry\n\n@[simp] theorem coe_of_eq_apply {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    {semimodule_M : semimodule R M} {p : submodule R M} {q : submodule R M} (h : p = q) (x : ↥p) :\n    ↑(coe_fn (of_eq p q h) x) = ↑x :=\n  rfl\n\n@[simp] theorem of_eq_symm {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    {semimodule_M : semimodule R M} {p : submodule R M} {q : submodule R M} (h : p = q) :\n    symm (of_eq p q h) = of_eq q p (Eq.symm h) :=\n  rfl\n\n/-- A linear equivalence which maps a submodule of one module onto another, restricts to a linear\nequivalence of the two submodules. -/\ndef of_submodules {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (e : linear_equiv R M M₂) (p : submodule R M) (q : submodule R M₂)\n    (h : submodule.map (↑e) p = q) : linear_equiv R ↥p ↥q :=\n  trans (of_submodule e p) (of_eq (submodule.map (↑e) p) q h)\n\n@[simp] theorem of_submodules_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (e : linear_equiv R M M₂) {p : submodule R M}\n    {q : submodule R M₂} (h : submodule.map (↑e) p = q) (x : ↥p) :\n    ↑(coe_fn (of_submodules e p q h) x) = coe_fn e ↑x :=\n  rfl\n\n@[simp] theorem of_submodules_symm_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (e : linear_equiv R M M₂) {p : submodule R M}\n    {q : submodule R M₂} (h : submodule.map (↑e) p = q) (x : ↥q) :\n    ↑(coe_fn (symm (of_submodules e p q h)) x) = coe_fn (symm e) ↑x :=\n  rfl\n\n/-- The top submodule of `M` is linearly equivalent to `M`. -/\ndef of_top {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    {semimodule_M : semimodule R M} (p : submodule R M) (h : p = ⊤) : linear_equiv R (↥p) M :=\n  mk (linear_map.to_fun (submodule.subtype p)) sorry sorry\n    (fun (x : M) => { val := x, property := sorry }) sorry sorry\n\n@[simp] theorem of_top_apply {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    {semimodule_M : semimodule R M} (p : submodule R M) {h : p = ⊤} (x : ↥p) :\n    coe_fn (of_top p h) x = ↑x :=\n  rfl\n\n@[simp] theorem coe_of_top_symm_apply {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    {semimodule_M : semimodule R M} (p : submodule R M) {h : p = ⊤} (x : M) :\n    ↑(coe_fn (symm (of_top p h)) x) = x :=\n  rfl\n\ntheorem of_top_symm_apply {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    {semimodule_M : semimodule R M} (p : submodule R M) {h : p = ⊤} (x : M) :\n    coe_fn (symm (of_top p h)) x = { val := x, property := Eq.symm h ▸ trivial } :=\n  rfl\n\n/-- If a linear map has an inverse, it is a linear equivalence. -/\ndef of_linear {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (f : linear_map R M M₂) (g : linear_map R M₂ M) (h₁ : linear_map.comp f g = linear_map.id)\n    (h₂ : linear_map.comp g f = linear_map.id) : linear_equiv R M M₂ :=\n  mk (linear_map.to_fun f) (linear_map.map_add' f) (linear_map.map_smul' f) ⇑g sorry sorry\n\n@[simp] theorem of_linear_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (f : linear_map R M M₂) (g : linear_map R M₂ M)\n    {h₁ : linear_map.comp f g = linear_map.id} {h₂ : linear_map.comp g f = linear_map.id} (x : M) :\n    coe_fn (of_linear f g h₁ h₂) x = coe_fn f x :=\n  rfl\n\n@[simp] theorem of_linear_symm_apply {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (f : linear_map R M M₂) (g : linear_map R M₂ M)\n    {h₁ : linear_map.comp f g = linear_map.id} {h₂ : linear_map.comp g f = linear_map.id} (x : M₂) :\n    coe_fn (symm (of_linear f g h₁ h₂)) x = coe_fn g x :=\n  rfl\n\n@[simp] protected theorem range {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (e : linear_equiv R M M₂) : linear_map.range ↑e = ⊤ :=\n  iff.mpr linear_map.range_eq_top (equiv.surjective (to_equiv e))\n\ntheorem eq_bot_of_equiv {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M₂] {semimodule_M : semimodule R M} (p : submodule R M) [semimodule R M₂]\n    (e : linear_equiv R ↥p ↥⊥) : p = ⊥ :=\n  sorry\n\n@[simp] protected theorem ker {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (e : linear_equiv R M M₂) : linear_map.ker ↑e = ⊥ :=\n  linear_map.ker_eq_bot_of_injective (equiv.injective (to_equiv e))\n\n@[simp] theorem map_neg {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (e : linear_equiv R M M₂) (a : M) : coe_fn e (-a) = -coe_fn e a :=\n  linear_map.map_neg (to_linear_map e) a\n\n@[simp] theorem map_sub {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (e : linear_equiv R M M₂) (a : M) (b : M) : coe_fn e (a - b) = coe_fn e a - coe_fn e b :=\n  linear_map.map_sub (to_linear_map e) a b\n\n/-- Equivalence given by a block lower diagonal matrix. `e₁` and `e₂` are diagonal square blocks,\n  and `f` is a rectangular block below the diagonal. -/\nprotected def skew_prod {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z}\n    [semiring R] [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃] [add_comm_group M₄]\n    {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    {semimodule_M₃ : semimodule R M₃} {semimodule_M₄ : semimodule R M₄} (e₁ : linear_equiv R M M₂)\n    (e₂ : linear_equiv R M₃ M₄) (f : linear_map R M M₄) : linear_equiv R (M × M₃) (M₂ × M₄) :=\n  mk\n    (linear_map.to_fun\n      (linear_map.prod (linear_map.comp (↑e₁) (linear_map.fst R M M₃))\n        (linear_map.comp (↑e₂) (linear_map.snd R M M₃) +\n          linear_map.comp f (linear_map.fst R M M₃))))\n    sorry sorry\n    (fun (p : M₂ × M₄) =>\n      (coe_fn (symm e₁) (prod.fst p),\n      coe_fn (symm e₂) (prod.snd p - coe_fn f (coe_fn (symm e₁) (prod.fst p)))))\n    sorry sorry\n\n@[simp] theorem skew_prod_apply {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} {M₄ : Type z}\n    [semiring R] [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃] [add_comm_group M₄]\n    {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    {semimodule_M₃ : semimodule R M₃} {semimodule_M₄ : semimodule R M₄} (e₁ : linear_equiv R M M₂)\n    (e₂ : linear_equiv R M₃ M₄) (f : linear_map R M M₄) (x : M × M₃) :\n    coe_fn (linear_equiv.skew_prod e₁ e₂ f) x =\n        (coe_fn e₁ (prod.fst x), coe_fn e₂ (prod.snd x) + coe_fn f (prod.fst x)) :=\n  rfl\n\n@[simp] theorem skew_prod_symm_apply {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y}\n    {M₄ : Type z} [semiring R] [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃]\n    [add_comm_group M₄] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    {semimodule_M₃ : semimodule R M₃} {semimodule_M₄ : semimodule R M₄} (e₁ : linear_equiv R M M₂)\n    (e₂ : linear_equiv R M₃ M₄) (f : linear_map R M M₄) (x : M₂ × M₄) :\n    coe_fn (symm (linear_equiv.skew_prod e₁ e₂ f)) x =\n        (coe_fn (symm e₁) (prod.fst x),\n        coe_fn (symm e₂) (prod.snd x - coe_fn f (coe_fn (symm e₁) (prod.fst x)))) :=\n  rfl\n\n/-- `x ↦ -x` as a `linear_equiv` -/\ndef neg (R : Type u) {M : Type v} [semiring R] [add_comm_group M] [semimodule R M] :\n    linear_equiv R M M :=\n  mk (equiv.to_fun (equiv.neg M)) sorry sorry (equiv.inv_fun (equiv.neg M)) sorry sorry\n\n@[simp] theorem coe_neg {R : Type u} {M : Type v} [semiring R] [add_comm_group M] [semimodule R M] :\n    ⇑(neg R) = -id :=\n  rfl\n\ntheorem neg_apply {R : Type u} {M : Type v} [semiring R] [add_comm_group M] [semimodule R M]\n    (x : M) : coe_fn (neg R) x = -x :=\n  sorry\n\n@[simp] theorem symm_neg {R : Type u} {M : Type v} [semiring R] [add_comm_group M]\n    [semimodule R M] : symm (neg R) = neg R :=\n  rfl\n\n/-- An `injective` linear map `f : M →ₗ[R] M₂` defines a linear equivalence\nbetween `M` and `f.range`. -/\ndef of_injective {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (f : linear_map R M M₂) (h : linear_map.ker f = ⊥) : linear_equiv R M ↥(linear_map.range f) :=\n  mk (equiv.to_fun (equiv.trans (equiv.set.range ⇑f sorry) (equiv.set.of_eq sorry))) sorry sorry\n    (equiv.inv_fun (equiv.trans (equiv.set.range ⇑f sorry) (equiv.set.of_eq sorry))) sorry sorry\n\n@[simp] theorem of_injective_apply {R : Type u} {M : Type v} {M₂ : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (f : linear_map R M M₂) {h : linear_map.ker f = ⊥} (x : M) :\n    ↑(coe_fn (of_injective f h) x) = coe_fn f x :=\n  rfl\n\n/-- A bijective linear map is a linear equivalence. Here, bijectivity is described by saying that\nthe kernel of `f` is `{0}` and the range is the universal set. -/\ndef of_bijective {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] {semimodule_M : semimodule R M} {semimodule_M₂ : semimodule R M₂}\n    (f : linear_map R M M₂) (hf₁ : linear_map.ker f = ⊥) (hf₂ : linear_map.range f = ⊤) :\n    linear_equiv R M M₂ :=\n  trans (of_injective f hf₁) (of_top (linear_map.range f) hf₂)\n\n@[simp] theorem of_bijective_apply {R : Type u} {M : Type v} {M₂ : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M₂] {semimodule_M : semimodule R M}\n    {semimodule_M₂ : semimodule R M₂} (f : linear_map R M M₂) {hf₁ : linear_map.ker f = ⊥}\n    {hf₂ : linear_map.range f = ⊤} (x : M) : coe_fn (of_bijective f hf₁ hf₂) x = coe_fn f x :=\n  rfl\n\n/-- Multiplying by a unit `a` of the ring `R` is a linear equivalence. -/\ndef smul_of_unit {R : Type u} {M : Type v} [comm_ring R] [add_comm_group M] [semimodule R M]\n    (a : units R) : linear_equiv R M M :=\n  of_linear (↑a • 1) (↑(a⁻¹) • 1) sorry sorry\n\n/-- A linear isomorphism between the domains and codomains of two spaces of linear maps gives a\nlinear isomorphism between the two function spaces. -/\ndef arrow_congr {R : Type u_1} {M₁ : Type u_2} {M₂ : Type u_3} {M₂₁ : Type u_4} {M₂₂ : Type u_5}\n    [comm_ring R] [add_comm_group M₁] [add_comm_group M₂] [add_comm_group M₂₁] [add_comm_group M₂₂]\n    [module R M₁] [module R M₂] [module R M₂₁] [module R M₂₂] (e₁ : linear_equiv R M₁ M₂)\n    (e₂ : linear_equiv R M₂₁ M₂₂) : linear_equiv R (linear_map R M₁ M₂₁) (linear_map R M₂ M₂₂) :=\n  mk (fun (f : linear_map R M₁ M₂₁) => linear_map.comp (↑e₂) (linear_map.comp f ↑(symm e₁))) sorry\n    sorry (fun (f : linear_map R M₂ M₂₂) => linear_map.comp (↑(symm e₂)) (linear_map.comp f ↑e₁))\n    sorry sorry\n\n@[simp] theorem arrow_congr_apply {R : Type u_1} {M₁ : Type u_2} {M₂ : Type u_3} {M₂₁ : Type u_4}\n    {M₂₂ : Type u_5} [comm_ring R] [add_comm_group M₁] [add_comm_group M₂] [add_comm_group M₂₁]\n    [add_comm_group M₂₂] [module R M₁] [module R M₂] [module R M₂₁] [module R M₂₂]\n    (e₁ : linear_equiv R M₁ M₂) (e₂ : linear_equiv R M₂₁ M₂₂) (f : linear_map R M₁ M₂₁) (x : M₂) :\n    coe_fn (coe_fn (arrow_congr e₁ e₂) f) x = coe_fn e₂ (coe_fn f (coe_fn (symm e₁) x)) :=\n  rfl\n\n@[simp] theorem arrow_congr_symm_apply {R : Type u_1} {M₁ : Type u_2} {M₂ : Type u_3}\n    {M₂₁ : Type u_4} {M₂₂ : Type u_5} [comm_ring R] [add_comm_group M₁] [add_comm_group M₂]\n    [add_comm_group M₂₁] [add_comm_group M₂₂] [module R M₁] [module R M₂] [module R M₂₁]\n    [module R M₂₂] (e₁ : linear_equiv R M₁ M₂) (e₂ : linear_equiv R M₂₁ M₂₂)\n    (f : linear_map R M₂ M₂₂) (x : M₁) :\n    coe_fn (coe_fn (symm (arrow_congr e₁ e₂)) f) x = coe_fn (symm e₂) (coe_fn f (coe_fn e₁ x)) :=\n  rfl\n\ntheorem arrow_congr_comp {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [comm_ring R]\n    [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] {N : Type u_1} {N₂ : Type u_2} {N₃ : Type u_3} [add_comm_group N]\n    [add_comm_group N₂] [add_comm_group N₃] [module R N] [module R N₂] [module R N₃]\n    (e₁ : linear_equiv R M N) (e₂ : linear_equiv R M₂ N₂) (e₃ : linear_equiv R M₃ N₃)\n    (f : linear_map R M M₂) (g : linear_map R M₂ M₃) :\n    coe_fn (arrow_congr e₁ e₃) (linear_map.comp g f) =\n        linear_map.comp (coe_fn (arrow_congr e₂ e₃) g) (coe_fn (arrow_congr e₁ e₂) f) :=\n  sorry\n\ntheorem arrow_congr_trans {R : Type u} [comm_ring R] {M₁ : Type u_1} {M₂ : Type u_2} {M₃ : Type u_3}\n    {N₁ : Type u_4} {N₂ : Type u_5} {N₃ : Type u_6} [add_comm_group M₁] [module R M₁]\n    [add_comm_group M₂] [module R M₂] [add_comm_group M₃] [module R M₃] [add_comm_group N₁]\n    [module R N₁] [add_comm_group N₂] [module R N₂] [add_comm_group N₃] [module R N₃]\n    (e₁ : linear_equiv R M₁ M₂) (e₂ : linear_equiv R N₁ N₂) (e₃ : linear_equiv R M₂ M₃)\n    (e₄ : linear_equiv R N₂ N₃) :\n    trans (arrow_congr e₁ e₂) (arrow_congr e₃ e₄) = arrow_congr (trans e₁ e₃) (trans e₂ e₄) :=\n  rfl\n\n/-- If `M₂` and `M₃` are linearly isomorphic then the two spaces of linear maps from `M` into `M₂`\nand `M` into `M₃` are linearly isomorphic. -/\ndef congr_right {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [comm_ring R]\n    [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (f : linear_equiv R M₂ M₃) :\n    linear_equiv R (linear_map R M M₂) (linear_map R M M₃) :=\n  arrow_congr (refl R M) f\n\n/-- If `M` and `M₂` are linearly isomorphic then the two spaces of linear maps from `M` and `M₂` to\nthemselves are linearly isomorphic. -/\ndef conj {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (e : linear_equiv R M M₂) :\n    linear_equiv R (module.End R M) (module.End R M₂) :=\n  arrow_congr e e\n\ntheorem conj_apply {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (e : linear_equiv R M M₂)\n    (f : module.End R M) : coe_fn (conj e) f = linear_map.comp (linear_map.comp (↑e) f) ↑(symm e) :=\n  rfl\n\ntheorem symm_conj_apply {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (e : linear_equiv R M M₂)\n    (f : module.End R M₂) :\n    coe_fn (conj (symm e)) f = linear_map.comp (linear_map.comp (↑(symm e)) f) ↑e :=\n  rfl\n\ntheorem conj_comp {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (e : linear_equiv R M M₂)\n    (f : module.End R M) (g : module.End R M) :\n    coe_fn (conj e) (linear_map.comp g f) =\n        linear_map.comp (coe_fn (conj e) g) (coe_fn (conj e) f) :=\n  arrow_congr_comp e e e f g\n\ntheorem conj_trans {R : Type u} {M : Type v} {M₂ : Type w} {M₃ : Type y} [comm_ring R]\n    [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃] [semimodule R M] [semimodule R M₂]\n    [semimodule R M₃] (e₁ : linear_equiv R M M₂) (e₂ : linear_equiv R M₂ M₃) :\n    trans (conj e₁) (conj e₂) = conj (trans e₁ e₂) :=\n  ext\n    fun (f : module.End R M) =>\n      linear_map.ext fun (x : M₃) => Eq.refl (coe_fn (coe_fn (trans (conj e₁) (conj e₂)) f) x)\n\n@[simp] theorem conj_id {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [semimodule R M] [semimodule R M₂] (e : linear_equiv R M M₂) :\n    coe_fn (conj e) linear_map.id = linear_map.id :=\n  sorry\n\n/-- Multiplying by a nonzero element `a` of the field `K` is a linear equivalence. -/\ndef smul_of_ne_zero (K : Type u') (M : Type v) [field K] [add_comm_group M] [module K M] (a : K)\n    (ha : a ≠ 0) : linear_equiv K M M :=\n  smul_of_unit (units.mk0 a ha)\n\ntheorem ker_to_span_singleton (K : Type u') (M : Type v) [field K] [add_comm_group M] [module K M]\n    {x : M} (h : x ≠ 0) : linear_map.ker (linear_map.to_span_singleton K M x) = ⊥ :=\n  sorry\n\n/-- Given a nonzero element `x` of a vector space `M` over a field `K`, the natural\n    map from `K` to the span of `x`, with invertibility check to consider it as an\n    isomorphism.-/\ndef to_span_nonzero_singleton (K : Type u') (M : Type v) [field K] [add_comm_group M] [module K M]\n    (x : M) (h : x ≠ 0) : linear_equiv K K ↥(submodule.span K (singleton x)) :=\n  trans (of_injective (linear_map.to_span_singleton K M x) (ker_to_span_singleton K M h))\n    (of_eq (linear_map.range (linear_map.to_span_singleton K M x)) (submodule.span K (singleton x))\n      sorry)\n\ntheorem to_span_nonzero_singleton_one (K : Type u') (M : Type v) [field K] [add_comm_group M]\n    [module K M] (x : M) (h : x ≠ 0) :\n    coe_fn (to_span_nonzero_singleton K M x h) 1 =\n        { val := x, property := submodule.mem_span_singleton_self x } :=\n  sorry\n\n/-- Given a nonzero element `x` of a vector space `M` over a field `K`, the natural map\n    from the span of `x` to `K`.-/\ndef coord (K : Type u') (M : Type v) [field K] [add_comm_group M] [module K M] (x : M) (h : x ≠ 0) :\n    linear_equiv K (↥(submodule.span K (singleton x))) K :=\n  symm (to_span_nonzero_singleton K M x h)\n\ntheorem coord_self (K : Type u') (M : Type v) [field K] [add_comm_group M] [module K M] (x : M)\n    (h : x ≠ 0) :\n    coe_fn (coord K M x h) { val := x, property := submodule.mem_span_singleton_self x } = 1 :=\n  sorry\n\nend linear_equiv\n\n\nnamespace submodule\n\n\n/-- If `s ≤ t`, then we can view `s` as a submodule of `t` by taking the comap\nof `t.subtype`. -/\ndef comap_subtype_equiv_of_le {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {p : submodule R M} {q : submodule R M} (hpq : p ≤ q) :\n    linear_equiv R ↥(comap (submodule.subtype q) p) ↥p :=\n  linear_equiv.mk (fun (x : ↥(comap (submodule.subtype q) p)) => { val := ↑x, property := sorry })\n    sorry sorry (fun (x : ↥p) => { val := { val := ↑x, property := sorry }, property := sorry })\n    sorry sorry\n\n/-- If `p = ⊥`, then `M / p ≃ₗ[R] M`. -/\ndef quot_equiv_of_eq_bot {R : Type u} {M : Type v} [ring R] [add_comm_group M] [module R M]\n    (p : submodule R M) (hp : p = ⊥) : linear_equiv R (quotient p) M :=\n  linear_equiv.of_linear (liftq p linear_map.id sorry) (mkq p) sorry sorry\n\n@[simp] theorem quot_equiv_of_eq_bot_apply_mk {R : Type u} {M : Type v} [ring R] [add_comm_group M]\n    [module R M] (p : submodule R M) (hp : p = ⊥) (x : M) :\n    coe_fn (quot_equiv_of_eq_bot p hp) (quotient.mk x) = x :=\n  rfl\n\n@[simp] theorem quot_equiv_of_eq_bot_symm_apply {R : Type u} {M : Type v} [ring R]\n    [add_comm_group M] [module R M] (p : submodule R M) (hp : p = ⊥) (x : M) :\n    coe_fn (linear_equiv.symm (quot_equiv_of_eq_bot p hp)) x = quotient.mk x :=\n  rfl\n\n@[simp] theorem coe_quot_equiv_of_eq_bot_symm {R : Type u} {M : Type v} [ring R] [add_comm_group M]\n    [module R M] (p : submodule R M) (hp : p = ⊥) :\n    ↑(linear_equiv.symm (quot_equiv_of_eq_bot p hp)) = mkq p :=\n  rfl\n\n/-- Quotienting by equal submodules gives linearly equivalent quotients. -/\ndef quot_equiv_of_eq {R : Type u} {M : Type v} [ring R] [add_comm_group M] [module R M]\n    (p : submodule R M) (q : submodule R M) (h : p = q) :\n    linear_equiv R (quotient p) (quotient q) :=\n  linear_equiv.mk (equiv.to_fun (quotient.congr (equiv.refl M) sorry)) sorry sorry\n    (equiv.inv_fun (quotient.congr (equiv.refl M) sorry)) sorry sorry\n\nend submodule\n\n\nnamespace submodule\n\n\n@[simp] theorem mem_map_equiv {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R]\n    [add_comm_group M] [add_comm_group M₂] [module R M] [module R M₂] (p : submodule R M)\n    {e : linear_equiv R M M₂} {x : M₂} : x ∈ map (↑e) p ↔ coe_fn (linear_equiv.symm e) x ∈ p :=\n  sorry\n\ntheorem comap_le_comap_smul {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] (q : submodule R M₂) (f : linear_map R M M₂)\n    (c : R) : comap f q ≤ comap (c • f) q :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (comap f q ≤ comap (c • f) q)) (propext le_def')))\n    fun (m : M) (h : m ∈ comap f q) => id (id (fun (h : coe_fn f m ∈ q) => smul_mem q c h) h)\n\ntheorem inf_comap_le_comap_add {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R]\n    [add_comm_group M] [add_comm_group M₂] [module R M] [module R M₂] (q : submodule R M₂)\n    (f₁ : linear_map R M M₂) (f₂ : linear_map R M M₂) :\n    comap f₁ q ⊓ comap f₂ q ≤ comap (f₁ + f₂) q :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (comap f₁ q ⊓ comap f₂ q ≤ comap (f₁ + f₂) q)) (propext le_def')))\n    fun (m : M) (h : m ∈ comap f₁ q ⊓ comap f₂ q) =>\n      id\n        (id (fun (h : coe_fn f₁ m ∈ q ∧ coe_fn f₂ m ∈ q) => add_mem q (and.left h) (and.right h)) h)\n\n/-- Given modules `M`, `M₂` over a commutative ring, together with submodules `p ⊆ M`, `q ⊆ M₂`, the\nset of maps $\\\\{f ∈ Hom(M, M₂) | f(p) ⊆ q \\\\}$ is a submodule of `Hom(M, M₂)`. -/\ndef compatible_maps {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] (p : submodule R M) (q : submodule R M₂) :\n    submodule R (linear_map R M M₂) :=\n  mk (set_of fun (f : linear_map R M M₂) => p ≤ comap f q) sorry sorry sorry\n\n/-- Given modules `M`, `M₂` over a commutative ring, together with submodules `p ⊆ M`, `q ⊆ M₂`, the\nnatural map $\\\\{f ∈ Hom(M, M₂) | f(p) ⊆ q \\\\} \\to Hom(M/p, M₂/q)$ is linear. -/\ndef mapq_linear {R : Type u} {M : Type v} {M₂ : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] (p : submodule R M) (q : submodule R M₂) :\n    linear_map R (↥(compatible_maps p q)) (linear_map R (quotient p) (quotient q)) :=\n  linear_map.mk (fun (f : ↥(compatible_maps p q)) => mapq p q (subtype.val f) sorry) sorry sorry\n\nend submodule\n\n\nnamespace equiv\n\n\n/-- An equivalence whose underlying function is linear is a linear equivalence. -/\ndef to_linear_equiv {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] [add_comm_monoid M₂] [semimodule R M₂] (e : M ≃ M₂) (h : is_linear_map R ⇑e) :\n    linear_equiv R M M₂ :=\n  linear_equiv.mk (to_fun e) sorry sorry (inv_fun e) (left_inv e) (right_inv e)\n\nend equiv\n\n\nnamespace add_equiv\n\n\n/-- An additive equivalence whose underlying function preserves `smul` is a linear equivalence. -/\ndef to_linear_equiv {R : Type u} {M : Type v} {M₂ : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] [add_comm_monoid M₂] [semimodule R M₂] (e : M ≃+ M₂)\n    (h : ∀ (c : R) (x : M), coe_fn e (c • x) = c • coe_fn e x) : linear_equiv R M M₂ :=\n  linear_equiv.mk (to_fun e) sorry h (inv_fun e) sorry sorry\n\n@[simp] theorem coe_to_linear_equiv {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M₂] [semimodule R M₂] (e : M ≃+ M₂)\n    (h : ∀ (c : R) (x : M), coe_fn e (c • x) = c • coe_fn e x) : ⇑(to_linear_equiv e h) = ⇑e :=\n  rfl\n\n@[simp] theorem coe_to_linear_equiv_symm {R : Type u} {M : Type v} {M₂ : Type w} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M₂] [semimodule R M₂] (e : M ≃+ M₂)\n    (h : ∀ (c : R) (x : M), coe_fn e (c • x) = c • coe_fn e x) :\n    ⇑(linear_equiv.symm (to_linear_equiv e h)) = ⇑(symm e) :=\n  rfl\n\nend add_equiv\n\n\nnamespace linear_map\n\n\n/-- The first isomorphism law for modules. The quotient of `M` by the kernel of `f` is linearly\nequivalent to the range of `f`. -/\ndef quot_ker_equiv_range {R : Type u} {M : Type v} {M₂ : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M₂] [module R M] [module R M₂] (f : linear_map R M M₂) :\n    linear_equiv R (submodule.quotient (ker f)) ↥(range f) :=\n  linear_equiv.trans (linear_equiv.of_injective (submodule.liftq (ker f) f sorry) sorry)\n    (linear_equiv.of_eq (range (submodule.liftq (ker f) f sorry)) (range f) sorry)\n\n@[simp] theorem quot_ker_equiv_range_apply_mk {R : Type u} {M : Type v} {M₂ : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M₂] [module R M] [module R M₂] (f : linear_map R M M₂)\n    (x : M) : ↑(coe_fn (quot_ker_equiv_range f) (submodule.quotient.mk x)) = coe_fn f x :=\n  rfl\n\n@[simp] theorem quot_ker_equiv_range_symm_apply_image {R : Type u} {M : Type v} {M₂ : Type w}\n    [ring R] [add_comm_group M] [add_comm_group M₂] [module R M] [module R M₂]\n    (f : linear_map R M M₂) (x : M) (h : coe_fn f x ∈ range f) :\n    coe_fn (linear_equiv.symm (quot_ker_equiv_range f)) { val := coe_fn f x, property := h } =\n        coe_fn (submodule.mkq (ker f)) x :=\n  linear_equiv.symm_apply_apply (quot_ker_equiv_range f) (coe_fn (submodule.mkq (ker f)) x)\n\n/--\nCanonical linear map from the quotient `p/(p ∩ p')` to `(p+p')/p'`, mapping `x + (p ∩ p')`\nto `x + p'`, where `p` and `p'` are submodules of an ambient module.\n-/\ndef quotient_inf_to_sup_quotient {R : Type u} {M : Type v} [ring R] [add_comm_group M] [module R M]\n    (p : submodule R M) (p' : submodule R M) :\n    linear_map R (submodule.quotient (submodule.comap (submodule.subtype p) (p ⊓ p')))\n        (submodule.quotient (submodule.comap (submodule.subtype (p ⊔ p')) p')) :=\n  submodule.liftq (submodule.comap (submodule.subtype p) (p ⊓ p'))\n    (comp (submodule.mkq (submodule.comap (submodule.subtype (p ⊔ p')) p')) (submodule.of_le sorry))\n    sorry\n\n/--\nSecond Isomorphism Law : the canonical map from `p/(p ∩ p')` to `(p+p')/p'` as a linear isomorphism.\n-/\ndef quotient_inf_equiv_sup_quotient {R : Type u} {M : Type v} [ring R] [add_comm_group M]\n    [module R M] (p : submodule R M) (p' : submodule R M) :\n    linear_equiv R (submodule.quotient (submodule.comap (submodule.subtype p) (p ⊓ p')))\n        (submodule.quotient (submodule.comap (submodule.subtype (p ⊔ p')) p')) :=\n  linear_equiv.of_bijective (quotient_inf_to_sup_quotient p p') sorry sorry\n\n@[simp] theorem coe_quotient_inf_to_sup_quotient {R : Type u} {M : Type v} [ring R]\n    [add_comm_group M] [module R M] (p : submodule R M) (p' : submodule R M) :\n    ⇑(quotient_inf_to_sup_quotient p p') = ⇑(quotient_inf_equiv_sup_quotient p p') :=\n  rfl\n\n@[simp] theorem quotient_inf_equiv_sup_quotient_apply_mk {R : Type u} {M : Type v} [ring R]\n    [add_comm_group M] [module R M] (p : submodule R M) (p' : submodule R M) (x : ↥p) :\n    coe_fn (quotient_inf_equiv_sup_quotient p p') (submodule.quotient.mk x) =\n        submodule.quotient.mk (coe_fn (submodule.of_le le_sup_left) x) :=\n  rfl\n\ntheorem quotient_inf_equiv_sup_quotient_symm_apply_left {R : Type u} {M : Type v} [ring R]\n    [add_comm_group M] [module R M] (p : submodule R M) (p' : submodule R M) (x : ↥(p ⊔ p'))\n    (hx : ↑x ∈ p) :\n    coe_fn (linear_equiv.symm (quotient_inf_equiv_sup_quotient p p')) (submodule.quotient.mk x) =\n        submodule.quotient.mk { val := ↑x, property := hx } :=\n  sorry\n\n@[simp] theorem quotient_inf_equiv_sup_quotient_symm_apply_eq_zero_iff {R : Type u} {M : Type v}\n    [ring R] [add_comm_group M] [module R M] {p : submodule R M} {p' : submodule R M}\n    {x : ↥(p ⊔ p')} :\n    coe_fn (linear_equiv.symm (quotient_inf_equiv_sup_quotient p p')) (submodule.quotient.mk x) =\n          0 ↔\n        ↑x ∈ p' :=\n  sorry\n\ntheorem quotient_inf_equiv_sup_quotient_symm_apply_right {R : Type u} {M : Type v} [ring R]\n    [add_comm_group M] [module R M] (p : submodule R M) (p' : submodule R M) {x : ↥(p ⊔ p')}\n    (hx : ↑x ∈ p') :\n    coe_fn (linear_equiv.symm (quotient_inf_equiv_sup_quotient p p')) (submodule.quotient.mk x) =\n        0 :=\n  iff.mpr quotient_inf_equiv_sup_quotient_symm_apply_eq_zero_iff hx\n\ntheorem is_linear_map_prod_iso {R : Type u_1} {M : Type u_2} {M₂ : Type u_3} {M₃ : Type u_4}\n    [comm_semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_group M₃] [semimodule R M]\n    [semimodule R M₂] [semimodule R M₃] :\n    is_linear_map R\n        fun (p : linear_map R M M₂ × linear_map R M M₃) => prod (prod.fst p) (prod.snd p) :=\n  is_linear_map.mk (fun (u v : linear_map R M M₂ × linear_map R M M₃) => rfl)\n    fun (c : R) (u : linear_map R M M₂ × linear_map R M M₃) => rfl\n\n/-- `pi` construction for linear functions. From a family of linear functions it produces a linear\nfunction into a family of modules. -/\ndef pi {R : Type u} {M₂ : Type w} {ι : Type x} [semiring R] [add_comm_monoid M₂] [semimodule R M₂]\n    {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)]\n    (f : (i : ι) → linear_map R M₂ (φ i)) : linear_map R M₂ ((i : ι) → φ i) :=\n  mk (fun (c : M₂) (i : ι) => coe_fn (f i) c) sorry sorry\n\n@[simp] theorem pi_apply {R : Type u} {M₂ : Type w} {ι : Type x} [semiring R] [add_comm_monoid M₂]\n    [semimodule R M₂] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] (f : (i : ι) → linear_map R M₂ (φ i)) (c : M₂) (i : ι) :\n    coe_fn (pi f) c i = coe_fn (f i) c :=\n  rfl\n\ntheorem ker_pi {R : Type u} {M₂ : Type w} {ι : Type x} [semiring R] [add_comm_monoid M₂]\n    [semimodule R M₂] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] (f : (i : ι) → linear_map R M₂ (φ i)) :\n    ker (pi f) = infi fun (i : ι) => ker (f i) :=\n  sorry\n\ntheorem pi_eq_zero {R : Type u} {M₂ : Type w} {ι : Type x} [semiring R] [add_comm_monoid M₂]\n    [semimodule R M₂] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] (f : (i : ι) → linear_map R M₂ (φ i)) :\n    pi f = 0 ↔ ∀ (i : ι), f i = 0 :=\n  sorry\n\ntheorem pi_zero {R : Type u} {M₂ : Type w} {ι : Type x} [semiring R] [add_comm_monoid M₂]\n    [semimodule R M₂] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] : (pi fun (i : ι) => 0) = 0 :=\n  ext fun (x : M₂) => funext fun (x_1 : ι) => Eq.refl (coe_fn (pi fun (i : ι) => 0) x x_1)\n\ntheorem pi_comp {R : Type u} {M₂ : Type w} {M₃ : Type y} {ι : Type x} [semiring R]\n    [add_comm_monoid M₂] [semimodule R M₂] [add_comm_monoid M₃] [semimodule R M₃] {φ : ι → Type i}\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)]\n    (f : (i : ι) → linear_map R M₂ (φ i)) (g : linear_map R M₃ M₂) :\n    comp (pi f) g = pi fun (i : ι) => comp (f i) g :=\n  rfl\n\n/-- The projections from a family of modules are linear maps. -/\ndef proj {R : Type u} {ι : Type x} [semiring R] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] (i : ι) : linear_map R ((i : ι) → φ i) (φ i) :=\n  mk (fun (a : (i : ι) → φ i) => a i) sorry sorry\n\n@[simp] theorem proj_apply {R : Type u} {ι : Type x} [semiring R] {φ : ι → Type i}\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] (i : ι) (b : (i : ι) → φ i) :\n    coe_fn (proj i) b = b i :=\n  rfl\n\ntheorem proj_pi {R : Type u} {M₂ : Type w} {ι : Type x} [semiring R] [add_comm_monoid M₂]\n    [semimodule R M₂] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] (f : (i : ι) → linear_map R M₂ (φ i)) (i : ι) :\n    comp (proj i) (pi f) = f i :=\n  ext fun (c : M₂) => rfl\n\ntheorem infi_ker_proj {R : Type u} {ι : Type x} [semiring R] {φ : ι → Type i}\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] :\n    (infi fun (i : ι) => ker (proj i)) = ⊥ :=\n  sorry\n\n/-- If `I` and `J` are disjoint index sets, the product of the kernels of the `J`th projections of\n`φ` is linearly equivalent to the product over `I`. -/\ndef infi_ker_proj_equiv (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] {I : set ι} {J : set ι}\n    [decidable_pred fun (i : ι) => i ∈ I] (hd : disjoint I J) (hu : set.univ ⊆ I ∪ J) :\n    linear_equiv R (↥(infi fun (i : ι) => infi fun (H : i ∈ J) => ker (proj i)))\n        ((i : ↥I) → φ ↑i) :=\n  linear_equiv.of_linear\n    (pi\n      fun (i : ↥I) =>\n        comp (proj ↑i)\n          (submodule.subtype (infi fun (i : ι) => infi fun (H : i ∈ J) => ker (proj i))))\n    (cod_restrict (infi fun (i : ι) => infi fun (H : i ∈ J) => ker (proj i))\n      (pi\n        fun (i : ι) =>\n          dite (i ∈ I) (fun (h : i ∈ I) => proj { val := i, property := h }) fun (h : ¬i ∈ I) => 0)\n      sorry)\n    sorry sorry\n\n/-- `diag i j` is the identity map if `i = j`. Otherwise it is the constant 0 map. -/\ndef diag {R : Type u} {ι : Type x} [semiring R] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι) (j : ι) : linear_map R (φ i) (φ j) :=\n  function.update 0 i id j\n\ntheorem update_apply {R : Type u} {M₂ : Type w} {ι : Type x} [semiring R] [add_comm_monoid M₂]\n    [semimodule R M₂] {φ : ι → Type i} [(i : ι) → add_comm_monoid (φ i)]\n    [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (f : (i : ι) → linear_map R M₂ (φ i)) (c : M₂)\n    (i : ι) (j : ι) (b : linear_map R M₂ (φ i)) :\n    coe_fn (function.update f i b j) c =\n        function.update (fun (i : ι) => coe_fn (f i) c) i (coe_fn b c) j :=\n  sorry\n\n/-- The standard basis of the product of `φ`. -/\ndef std_basis (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι) :\n    linear_map R (φ i) ((i : ι) → φ i) :=\n  pi (diag i)\n\ntheorem std_basis_apply (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι)\n    (b : φ i) : coe_fn (std_basis R φ i) b = function.update 0 i b :=\n  sorry\n\n@[simp] theorem std_basis_same (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι)\n    (b : φ i) : coe_fn (std_basis R φ i) b i = b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (std_basis R φ i) b i = b)) (std_basis_apply R φ i b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (function.update 0 i b i = b)) (function.update_same i b 0)))\n      (Eq.refl b))\n\ntheorem std_basis_ne (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι) (j : ι)\n    (h : j ≠ i) (b : φ i) : coe_fn (std_basis R φ i) b j = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (std_basis R φ i) b j = 0)) (std_basis_apply R φ i b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (function.update 0 i b j = 0)) (function.update_noteq h b 0)))\n      (Eq.refl (HasZero.zero j)))\n\ntheorem ker_std_basis (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι) :\n    ker (std_basis R φ i) = ⊥ :=\n  sorry\n\ntheorem proj_comp_std_basis (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι)\n    (j : ι) : comp (proj i) (std_basis R φ j) = diag j i :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (comp (proj i) (std_basis R φ j) = diag j i))\n        (std_basis.equations._eqn_1 R φ j)))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (comp (proj i) (pi (diag j)) = diag j i)) (proj_pi (diag j) i)))\n      (Eq.refl (diag j i)))\n\ntheorem proj_std_basis_same (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι) :\n    comp (proj i) (std_basis R φ i) = id :=\n  sorry\n\ntheorem proj_std_basis_ne (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (i : ι) (j : ι)\n    (h : i ≠ j) : comp (proj i) (std_basis R φ j) = 0 :=\n  sorry\n\ntheorem supr_range_std_basis_le_infi_ker_proj (R : Type u) {ι : Type x} [semiring R]\n    (φ : ι → Type i) [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)]\n    [DecidableEq ι] (I : set ι) (J : set ι) (h : disjoint I J) :\n    (supr fun (i : ι) => supr fun (H : i ∈ I) => range (std_basis R φ i)) ≤\n        infi fun (i : ι) => infi fun (H : i ∈ J) => ker (proj i) :=\n  sorry\n\ntheorem infi_ker_proj_le_supr_range_std_basis (R : Type u) {ι : Type x} [semiring R]\n    (φ : ι → Type i) [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)]\n    [DecidableEq ι] {I : finset ι} {J : set ι} (hu : set.univ ⊆ ↑I ∪ J) :\n    (infi fun (i : ι) => infi fun (H : i ∈ J) => ker (proj i)) ≤\n        supr fun (i : ι) => supr fun (H : i ∈ I) => range (std_basis R φ i) :=\n  sorry\n\ntheorem supr_range_std_basis_eq_infi_ker_proj (R : Type u) {ι : Type x} [semiring R]\n    (φ : ι → Type i) [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)]\n    [DecidableEq ι] {I : set ι} {J : set ι} (hd : disjoint I J) (hu : set.univ ⊆ I ∪ J)\n    (hI : set.finite I) :\n    (supr fun (i : ι) => supr fun (H : i ∈ I) => range (std_basis R φ i)) =\n        infi fun (i : ι) => infi fun (H : i ∈ J) => ker (proj i) :=\n  sorry\n\ntheorem supr_range_std_basis (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] [fintype ι] :\n    (supr fun (i : ι) => range (std_basis R φ i)) = ⊤ :=\n  sorry\n\ntheorem disjoint_std_basis_std_basis (R : Type u) {ι : Type x} [semiring R] (φ : ι → Type i)\n    [(i : ι) → add_comm_monoid (φ i)] [(i : ι) → semimodule R (φ i)] [DecidableEq ι] (I : set ι)\n    (J : set ι) (h : disjoint I J) :\n    disjoint (supr fun (i : ι) => supr fun (H : i ∈ I) => range (std_basis R φ i))\n        (supr fun (i : ι) => supr fun (H : i ∈ J) => range (std_basis R φ i)) :=\n  sorry\n\ntheorem std_basis_eq_single (R : Type u) {ι : Type x} [semiring R] [DecidableEq ι] {a : R} :\n    (fun (i : ι) => coe_fn (std_basis R (fun (_x : ι) => R) i) a) =\n        fun (i : ι) => ⇑(finsupp.single i a) :=\n  sorry\n\n/-- Given an `R`-module `M` and a function `m → n` between arbitrary types,\nconstruct a linear map `(n → M) →ₗ[R] (m → M)` -/\ndef fun_left (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M] [semimodule R M]\n    {m : Type u_1} {n : Type u_2} (f : m → n) : linear_map R (n → M) (m → M) :=\n  mk (fun (_x : n → M) => _x ∘ f) sorry sorry\n\n@[simp] theorem fun_left_apply (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] {m : Type u_1} {n : Type u_2} (f : m → n) (g : n → M) (i : m) :\n    coe_fn (fun_left R M f) g i = g (f i) :=\n  rfl\n\n@[simp] theorem fun_left_id (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] {n : Type u_2} (g : n → M) : coe_fn (fun_left R M id) g = g :=\n  rfl\n\ntheorem fun_left_comp (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M] [semimodule R M]\n    {m : Type u_1} {n : Type u_2} {p : Type u_3} (f₁ : n → p) (f₂ : m → n) :\n    fun_left R M (f₁ ∘ f₂) = comp (fun_left R M f₂) (fun_left R M f₁) :=\n  rfl\n\n/-- Given an `R`-module `M` and an equivalence `m ≃ n` between arbitrary types,\nconstruct a linear equivalence `(n → M) ≃ₗ[R] (m → M)` -/\ndef fun_congr_left (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M] [semimodule R M]\n    {m : Type u_1} {n : Type u_2} (e : m ≃ n) : linear_equiv R (n → M) (m → M) :=\n  linear_equiv.of_linear (fun_left R M ⇑e) (fun_left R M ⇑(equiv.symm e)) sorry sorry\n\n@[simp] theorem fun_congr_left_apply (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] {m : Type u_1} {n : Type u_2} (e : m ≃ n) (x : n → M) :\n    coe_fn (fun_congr_left R M e) x = coe_fn (fun_left R M ⇑e) x :=\n  rfl\n\n@[simp] theorem fun_congr_left_id (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] {n : Type u_2} :\n    fun_congr_left R M (equiv.refl n) = linear_equiv.refl R (n → M) :=\n  rfl\n\n@[simp] theorem fun_congr_left_comp (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] {m : Type u_1} {n : Type u_2} {p : Type u_3} (e₁ : m ≃ n) (e₂ : n ≃ p) :\n    fun_congr_left R M (equiv.trans e₁ e₂) =\n        linear_equiv.trans (fun_congr_left R M e₂) (fun_congr_left R M e₁) :=\n  rfl\n\n@[simp] theorem fun_congr_left_symm (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] {m : Type u_1} {n : Type u_2} (e : m ≃ n) :\n    linear_equiv.symm (fun_congr_left R M e) = fun_congr_left R M (equiv.symm e) :=\n  rfl\n\nprotected instance automorphism_group (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] : group (linear_equiv R M M) :=\n  group.mk (fun (f g : linear_equiv R M M) => linear_equiv.trans g f) sorry (linear_equiv.refl R M)\n    sorry sorry (fun (f : linear_equiv R M M) => linear_equiv.symm f)\n    (div_inv_monoid.div._default (fun (f g : linear_equiv R M M) => linear_equiv.trans g f) sorry\n      (linear_equiv.refl R M) sorry sorry fun (f : linear_equiv R M M) => linear_equiv.symm f)\n    sorry\n\nprotected instance automorphism_group.to_linear_map_is_monoid_hom (R : Type u) (M : Type v)\n    [semiring R] [add_comm_monoid M] [semimodule R M] : is_monoid_hom linear_equiv.to_linear_map :=\n  is_monoid_hom.mk rfl\n\n/-- The group of invertible linear maps from `M` to itself -/\ndef general_linear_group (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] :=\n  units (linear_map R M M)\n\nnamespace general_linear_group\n\n\nprotected instance has_coe_to_fun {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : has_coe_to_fun (general_linear_group R M) :=\n  Mathlib.coe_fn_trans\n\n/-- An invertible linear map `f` determines an equivalence from `M` to itself. -/\ndef to_linear_equiv {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (f : general_linear_group R M) : linear_equiv R M M :=\n  linear_equiv.mk (to_fun (units.val f)) sorry sorry (to_fun (units.inv f)) sorry sorry\n\n/-- An equivalence from `M` to itself determines an invertible linear map. -/\ndef of_linear_equiv {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    (f : linear_equiv R M M) : general_linear_group R M :=\n  units.mk ↑f ↑(linear_equiv.symm f) sorry sorry\n\n/-- The general linear group on `R` and `M` is multiplicatively equivalent to the type of linear\nequivalences between `M` and itself. -/\ndef general_linear_equiv (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M]\n    [semimodule R M] : general_linear_group R M ≃* linear_equiv R M M :=\n  mul_equiv.mk to_linear_equiv of_linear_equiv sorry sorry sorry\n\n@[simp] theorem general_linear_equiv_to_linear_map (R : Type u) (M : Type v) [semiring R]\n    [add_comm_monoid M] [semimodule R M] (f : general_linear_group R M) :\n    ↑(coe_fn (general_linear_equiv R M) f) = ↑f :=\n  ext fun (x : M) => Eq.refl (coe_fn (↑(coe_fn (general_linear_equiv R M) f)) x)\n\nend general_linear_group\n\n\nend linear_map\n\n\nnamespace submodule\n\n\nprotected instance is_modular_lattice {R : Type u} {M : Type v} [ring R] [add_comm_group M]\n    [module R M] : is_modular_lattice (submodule R M) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4815506929746235}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\nOuter measures -- overapproximations of measures\n-/\n\nimport order.galois_connection algebra.big_operators algebra.module\n       analysis.ennreal analysis.limits\n       analysis.measure_theory.measurable_space\n\nnoncomputable theory\n\nopen set lattice finset function filter encodable\nlocal attribute [instance] classical.prop_decidable\n\nnamespace measure_theory\n\nstructure outer_measure (α : Type*) :=\n(measure_of : set α → ennreal)\n(empty : measure_of ∅ = 0)\n(mono : ∀{s₁ s₂}, s₁ ⊆ s₂ → measure_of s₁ ≤ measure_of s₂)\n(Union_nat : ∀(s:ℕ → set α), measure_of (⋃i, s i) ≤ (∑i, measure_of (s i)))\n\nnamespace outer_measure\n\ninstance {α} : has_coe_to_fun (outer_measure α) := ⟨_, λ m, m.measure_of⟩\n\nsection basic\nvariables {α : Type*} {ms : set (outer_measure α)} {m : outer_measure α}\n\n@[simp] theorem empty' (m : outer_measure α) : m ∅ = 0 := m.empty\n\ntheorem mono' (m : outer_measure α) {s₁ s₂}\n  (h : s₁ ⊆ s₂) : m s₁ ≤ m s₂ := m.mono h\n\ntheorem Union_aux (m : set α → ennreal) (m0 : m ∅ = 0)\n  {β} [encodable β] (s : β → set α) :\n  (∑ b, m (s b)) = ∑ i, m (⋃ b ∈ decode2 β i, s b) :=\nbegin\n  have H : ∀ n, m (⋃ b ∈ decode2 β n, s b) ≠ 0 → (decode2 β n).is_some,\n  { intros n h,\n    cases decode2 β n with b,\n    { exact (h (by simp [m0])).elim },\n    { exact rfl } },\n  refine tsum_eq_tsum_of_ne_zero_bij (λ n h, option.get (H n h)) _ _ _,\n  { intros m n hm hn e,\n    have := mem_decode2.1 (option.get_mem (H n hn)),\n    rwa [← e, mem_decode2.1 (option.get_mem (H m hm))] at this },\n  { intros b h,\n    refine ⟨encode b, _, _⟩,\n    { convert h, simp [ext_iff, encodek2] },\n    { exact option.get_of_mem _ (encodek2 _) } },\n  { intros n h,\n    transitivity, swap,\n    rw [show decode2 β n = _, from option.get_mem (H n h)],\n    congr, simp [ext_iff] }\nend\n\nprotected theorem Union (m : outer_measure α)\n  {β} [encodable β] (s : β → set α) :\n  m (⋃i, s i) ≤ (∑i, m (s i)) :=\nby rw [Union_decode2, Union_aux _ m.empty' s]; exact m.Union_nat _\n\nlemma Union_null (m : outer_measure α)\n  {β} [encodable β] {s : β → set α} (h : ∀ i, m (s i) = 0) : m (⋃i, s i) = 0 :=\nby simpa [h] using m.Union s\n\nprotected lemma union (m : outer_measure α) (s₁ s₂ : set α) :\n  m (s₁ ∪ s₂) ≤ m s₁ + m s₂ :=\nbegin\n  convert m.Union (λ b, cond b s₁ s₂),\n  { simp [union_eq_Union] },\n  { rw tsum_fintype, change _ = _ + _, simp }\nend\n\nlemma union_null (m : outer_measure α) {s₁ s₂ : set α}\n  (h₁ : m s₁ = 0) (h₂ : m s₂ = 0) : m (s₁ ∪ s₂) = 0 :=\nby simpa [h₁, h₂] using m.union s₁ s₂\n\n@[extensionality] lemma ext : ∀{μ₁ μ₂ : outer_measure α},\n  (∀s, μ₁ s = μ₂ s) → μ₁ = μ₂\n| ⟨m₁, e₁, _, u₁⟩ ⟨m₂, e₂, _, u₂⟩ h := by congr; exact funext h\n\ninstance : has_zero (outer_measure α) :=\n⟨{ measure_of := λ_, 0,\n   empty      := rfl,\n   mono       := assume _ _ _, le_refl 0,\n   Union_nat  := assume s, zero_le _ }⟩\n\n@[simp] theorem zero_apply (s : set α) : (0 : outer_measure α) s = 0 := rfl\n\ninstance : inhabited (outer_measure α) := ⟨0⟩\n\ninstance : has_add (outer_measure α) :=\n⟨λm₁ m₂,\n  { measure_of := λs, m₁ s + m₂ s,\n    empty      := show m₁ ∅ + m₂ ∅ = 0, by simp [outer_measure.empty],\n    mono       := assume s₁ s₂ h, add_le_add' (m₁.mono h) (m₂.mono h),\n    Union_nat  := assume s,\n      calc m₁ (⋃i, s i) + m₂ (⋃i, s i) ≤\n          (∑i, m₁ (s i)) + (∑i, m₂ (s i)) :\n          add_le_add' (m₁.Union_nat s) (m₂.Union_nat s)\n        ... = _ : ennreal.tsum_add.symm}⟩\n\n@[simp] theorem add_apply (m₁ m₂ : outer_measure α) (s : set α) :\n  (m₁ + m₂) s = m₁ s + m₂ s := rfl\n\ninstance : add_comm_monoid (outer_measure α) :=\n{ zero      := 0,\n  add       := (+),\n  add_comm  := assume a b, ext $ assume s, add_comm _ _,\n  add_assoc := assume a b c, ext $ assume s, add_assoc _ _ _,\n  add_zero  := assume a, ext $ assume s, add_zero _,\n  zero_add  := assume a, ext $ assume s, zero_add _ }\n\ninstance : has_bot (outer_measure α) := ⟨0⟩\n\ninstance outer_measure.order_bot : order_bot (outer_measure α) :=\n{ le          := λm₁ m₂, ∀s, m₁ s ≤ m₂ s,\n  bot         := 0,\n  le_refl     := assume a s, le_refl _,\n  le_trans    := assume a b c hab hbc s, le_trans (hab s) (hbc s),\n  le_antisymm := assume a b hab hba, ext $ assume s, le_antisymm (hab s) (hba s),\n  bot_le      := assume a s, zero_le _ }\n\nsection supremum\n\ninstance : has_Sup (outer_measure α) :=\n⟨λms, {\n  measure_of := λs, ⨆m:ms, m.val s,\n  empty      := le_zero_iff_eq.1 $ supr_le $ λ ⟨m, h⟩, le_of_eq m.empty,\n  mono       := assume s₁ s₂ hs, supr_le_supr $ assume ⟨m, hm⟩, m.mono hs,\n  Union_nat  := assume f, supr_le $ assume m,\n    calc m.val (⋃i, f i) ≤ (∑ (i : ℕ), m.val (f i)) : m.val.Union_nat _\n      ... ≤ (∑i, ⨆m:ms, m.val (f i)) :\n        ennreal.tsum_le_tsum $ assume i, le_supr (λm:ms, m.val (f i)) m }⟩\n\nprivate lemma le_Sup (hm : m ∈ ms) : m ≤ Sup ms :=\nλ s, le_supr (λm:ms, m.val s) ⟨m, hm⟩\n\nprivate lemma Sup_le (hm : ∀m' ∈ ms, m' ≤ m) : Sup ms ≤ m :=\nλ s, (supr_le $ assume ⟨m', h'⟩, (hm m' h') s)\n\ninstance : has_Inf (outer_measure α) := ⟨λs, Sup {m | ∀m'∈s, m ≤ m'}⟩\nprivate lemma Inf_le (hm : m ∈ ms) : Inf ms ≤ m := Sup_le $ assume m' h', h' _ hm\nprivate lemma le_Inf (hm : ∀m' ∈ ms, m ≤ m') : m ≤ Inf ms := le_Sup hm\n\ninstance : complete_lattice (outer_measure α) :=\n{ top          := Sup univ,\n  le_top       := assume a, le_Sup (mem_univ a),\n  Sup          := Sup,\n  Sup_le       := assume s m, Sup_le,\n  le_Sup       := assume s m, le_Sup,\n  Inf          := Inf,\n  Inf_le       := assume s m, Inf_le,\n  le_Inf       := assume s m, le_Inf,\n  sup          := λa b, Sup {a, b},\n  le_sup_left  := assume a b, le_Sup $ by simp,\n  le_sup_right := assume a b, le_Sup $ by simp,\n  sup_le       := assume a b c ha hb, Sup_le $ by simp [or_imp_distrib, ha, hb] {contextual:=tt},\n  inf          := λa b, Inf {a, b},\n  inf_le_left  := assume a b, Inf_le $ by simp,\n  inf_le_right := assume a b, Inf_le $ by simp,\n  le_inf       := assume a b c ha hb, le_Inf $ by simp [or_imp_distrib, ha, hb] {contextual:=tt},\n  .. outer_measure.order_bot }\n\n@[simp] theorem Sup_apply (ms : set (outer_measure α)) (s : set α) :\n  (Sup ms) s = ⨆ m : ms, m s := rfl\n\n@[simp] theorem supr_apply {ι} (f : ι → outer_measure α) (s : set α) :\n  (⨆ i : ι, f i) s = ⨆ i, f i s :=\nle_antisymm\n  (supr_le $ λ ⟨_, i, rfl⟩, le_supr _ i)\n  (supr_le $ λ i, le_supr\n    (λ (m : {a : outer_measure α // ∃ i, a = f i}), m.1 s)\n    ⟨f i, i, rfl⟩)\n\n@[simp] theorem sup_apply (m₁ m₂ : outer_measure α) (s : set α) :\n  (m₁ ⊔ m₂) s = m₁ s ⊔ m₂ s :=\nby have := supr_apply (λ b, cond b m₁ m₂) s;\n  rwa [supr_bool_eq, supr_bool_eq] at this\n\nend supremum\n\ndef map {β} (f : α → β) (m : outer_measure α) : outer_measure β :=\n{ measure_of := λs, m (f ⁻¹' s),\n  empty := m.empty,\n  mono := λ s t h, m.mono (preimage_mono h),\n  Union_nat := λ s, by rw [preimage_Union]; exact\n    m.Union_nat (λ i, f ⁻¹' s i) }\n\n@[simp] theorem map_apply {β} (f : α → β)\n  (m : outer_measure α) (s : set β) : map f m s = m (f ⁻¹' s) := rfl\n\n@[simp] theorem map_id (m : outer_measure α) : map id m = m :=\next $ λ s, rfl\n\n@[simp] theorem map_map {β γ} (f : α → β) (g : β → γ)\n  (m : outer_measure α) : map g (map f m) = map (g ∘ f) m :=\next $ λ s, rfl\n\ninstance : functor outer_measure := {map := λ α β, map}\n\ninstance : is_lawful_functor outer_measure :=\n{ id_map := λ α, map_id,\n  comp_map := λ α β γ f g m, (map_map f g m).symm }\n\n/-- The dirac outer measure. -/\ndef dirac (a : α) : outer_measure α :=\n{ measure_of := λs, ⨆ h : a ∈ s, 1,\n  empty := by simp,\n  mono := λ s t h, supr_le_supr2 (λ h', ⟨h h', le_refl _⟩),\n  Union_nat := λ s, supr_le $ λ h,\n    let ⟨i, h⟩ := mem_Union.1 h in\n    le_trans (by exact le_supr _ h) (ennreal.le_tsum i) }\n\n@[simp] theorem dirac_apply (a : α) (s : set α) :\n  dirac a s = ⨆ h : a ∈ s, 1 := rfl\n\ndef sum {ι} (f : ι → outer_measure α) : outer_measure α :=\n{ measure_of := λs, ∑ i, f i s,\n  empty := by simp,\n  mono := λ s t h, ennreal.tsum_le_tsum (λ i, (f i).mono' h),\n  Union_nat := λ s, by rw ennreal.tsum_comm; exact\n    ennreal.tsum_le_tsum (λ i, (f i).Union_nat _) }\n\n@[simp] theorem sum_apply {ι} (f : ι → outer_measure α) (s : set α) :\n  sum f s = ∑ i, f i s := rfl\n\ninstance : has_scalar ennreal (outer_measure α) :=\n⟨λ a m, {\n  measure_of := λs, a * m s,\n  empty := by simp,\n  mono := λ s t h, canonically_ordered_semiring.mul_le_mul (le_refl _) (m.mono' h),\n  Union_nat := λ s, by rw ennreal.mul_tsum; exact\n    canonically_ordered_semiring.mul_le_mul (le_refl _) (m.Union_nat _) }⟩\n\n@[simp] theorem smul_apply (a : ennreal) (m : outer_measure α) (s : set α) :\n  (a • m) s = a * m s := rfl\n\ninstance : semimodule ennreal (outer_measure α) :=\n{ smul_add := λ a m₁ m₂, ext $ λ s, mul_add _ _ _,\n  add_smul := λ a b m, ext $ λ s, add_mul _ _ _,\n  mul_smul := λ a b m, ext $ λ s, mul_assoc _ _ _,\n  one_smul := λ m, ext $ λ s, one_mul _,\n  zero_smul := λ m, ext $ λ s, zero_mul _,\n  smul_zero := λ a, ext $ λ s, mul_zero _,\n  ..outer_measure.has_scalar }\n\ntheorem smul_dirac_apply (a : ennreal) (b : α) (s : set α) :\n  (a • dirac b) s = ⨆ h : b ∈ s, a :=\nby by_cases b ∈ s; simp [h]\n\ntheorem top_apply {s : set α} (h : s ≠ ∅) : (⊤ : outer_measure α) s = ⊤ :=\nlet ⟨a, as⟩ := set.exists_mem_of_ne_empty h in\ntop_unique $ le_supr_of_le ⟨⊤ • dirac a, trivial⟩ $\nby simp [smul_dirac_apply, as]\n\nend basic\n\nsection of_function\nset_option eqn_compiler.zeta true\n\n/-- Given any function `m` assigning measures to sets satisying `m ∅ = 0`, there is\n  a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : set α`. -/\nprotected def of_function {α : Type*} (m : set α → ennreal) (m_empty : m ∅ = 0) :\n  outer_measure α :=\nlet μ := λs, ⨅{f : ℕ → set α} (h : s ⊆ ⋃i, f i), ∑i, m (f i) in\n{ measure_of := μ,\n  empty      := le_antisymm\n    (infi_le_of_le (λ_, ∅) $ infi_le_of_le (empty_subset _) $ by simp [m_empty])\n    (zero_le _),\n  mono       := assume s₁ s₂ hs, infi_le_infi $ assume f,\n    infi_le_infi2 $ assume hb, ⟨subset.trans hs hb, le_refl _⟩,\n  Union_nat := assume s, ennreal.le_of_forall_epsilon_le $ begin\n    assume ε hε (hb : (∑i, μ (s i)) < ⊤),\n    rcases ennreal.exists_pos_sum_of_encodable (ennreal.coe_lt_coe.2 hε) ℕ with ⟨ε', hε', hl⟩,\n    refine le_trans _ (add_le_add_left' (le_of_lt hl)),\n    rw ← ennreal.tsum_add,\n    have : ∀i, ∃f:ℕ → set α, s i ⊆ (⋃i, f i) ∧ (∑i, m (f i)) < μ (s i) + ε' i,\n    { intro,\n      have : μ (s i) < μ (s i) + ε' i :=\n        ennreal.lt_add_right\n          (lt_of_le_of_lt (by apply ennreal.le_tsum) hb)\n          (by simpa using hε' i),\n      simpa [μ, infi_lt_iff] },\n    cases classical.axiom_of_choice this with f hf,\n    dsimp at f hf, clear this,\n    refine le_trans _ (ennreal.tsum_le_tsum $ λ i, le_of_lt (hf i).2),\n    rw [← ennreal.tsum_prod, ← tsum_equiv equiv.nat_prod_nat_equiv_nat.symm],\n    swap, {apply_instance},\n    refine infi_le_of_le _ (infi_le _ _),\n    exact Union_subset (λ i, subset.trans (hf i).1 $\n      Union_subset $ λ j, subset.trans (by simp) $\n      subset_Union _ $ equiv.nat_prod_nat_equiv_nat (i, j)),\n  end }\n\ntheorem of_function_le {α : Type*} (m : set α → ennreal) (m_empty s) :\n  outer_measure.of_function m m_empty s ≤ m s :=\nlet f : ℕ → set α := λi, nat.rec_on i s (λn s, ∅) in\ninfi_le_of_le f $ infi_le_of_le (subset_Union f 0) $ le_of_eq $\ncalc (∑i, m (f i)) = ({0} : finset ℕ).sum (λi, m (f i)) :\n    tsum_eq_sum $ by intro i; cases i; simp [m_empty]\n  ... = m s : by simp; refl\n\ntheorem le_of_function {α : Type*} {m m_empty} {μ : outer_measure α} :\n  μ ≤ outer_measure.of_function m m_empty ↔ ∀ s, μ s ≤ m s :=\n⟨λ H s, le_trans (H _) (of_function_le _ _ _),\n λ H s, le_infi $ λ f, le_infi $ λ hs,\n  le_trans (μ.mono hs) $ le_trans (μ.Union f) $\n  ennreal.tsum_le_tsum $ λ i, H _⟩\n\nend of_function\n\nsection caratheodory_measurable\nuniverse u\nparameters {α : Type u} (m : outer_measure α)\ninclude m\n\nlocal attribute [simp] set.inter_comm set.inter_left_comm set.inter_assoc\n\nvariables {s s₁ s₂ : set α}\n\nprivate def C (s : set α) := ∀t, m t = m (t ∩ s) + m (t \\ s)\n\nprivate lemma C_iff_le {s : set α} : C s ↔ ∀t, m (t ∩ s) + m (t \\ s) ≤ m t :=\nforall_congr $ λ t, le_antisymm_iff.trans $ and_iff_right $\nby convert m.union _ _; rw inter_union_diff t s\n\n@[simp] private lemma C_empty : C ∅ := by simp [C, m.empty, diff_empty]\n\nprivate lemma C_compl : C s₁ → C (- s₁) := by simp [C, diff_eq]\n\n@[simp] private lemma C_compl_iff : C (- s) ↔ C s :=\n⟨λ h, by simpa using C_compl m h, C_compl⟩\n\nprivate lemma C_union (h₁ : C s₁) (h₂ : C s₂) : C (s₁ ∪ s₂) :=\nλ t, begin\n  rw [h₁ t, h₂ (t ∩ s₁), h₂ (t \\ s₁), h₁ (t ∩ (s₁ ∪ s₂)),\n    inter_diff_assoc _ _ s₁, set.inter_assoc _ _ s₁,\n    inter_eq_self_of_subset_right (set.subset_union_left _ _),\n    union_diff_left, h₂ (t ∩ s₁)],\n  simp [diff_eq]\nend\n\nprivate lemma measure_inter_union (h : s₁ ∩ s₂ ⊆ ∅) (h₁ : C s₁) {t : set α} :\n  m (t ∩ (s₁ ∪ s₂)) = m (t ∩ s₁) + m (t ∩ s₂) :=\nby rw [h₁, set.inter_assoc, union_inter_cancel_left h,\n  inter_diff_assoc, union_diff_cancel_left h]\n\nprivate lemma C_Union_lt {s : ℕ → set α} : ∀{n:ℕ}, (∀i<n, C (s i)) → C (⋃i<n, s i)\n| 0       h := by simp [nat.not_lt_zero]\n| (n + 1) h := by rw Union_lt_succ; exact C_union m\n  (h n (le_refl (n + 1)))\n      (C_Union_lt $ assume i hi, h i $ lt_of_lt_of_le hi $ nat.le_succ _)\n\nprivate lemma C_inter (h₁ : C s₁) (h₂ : C s₂) : C (s₁ ∩ s₂) :=\nby rw [← C_compl_iff, compl_inter]; from C_union _ (C_compl _ h₁) (C_compl _ h₂)\n\nprivate lemma C_sum {s : ℕ → set α} (h : ∀i, C (s i)) (hd : pairwise (disjoint on s)) {t : set α} :\n  ∀ {n}, (finset.range n).sum (λi, m (t ∩ s i)) = m (t ∩ ⋃i<n, s i)\n| 0            := by simp [nat.not_lt_zero, m.empty]\n| (nat.succ n) := begin\n  simp [Union_lt_succ],\n  rw [measure_inter_union m _ (h n), C_sum],\n  intro a, simpa using λ h₁ i hi h₂, hd _ _ (ne_of_gt hi) ⟨h₁, h₂⟩\nend\n\nprivate lemma C_Union_nat {s : ℕ → set α} (h : ∀i, C (s i))\n  (hd : pairwise (disjoint on s)) : C (⋃i, s i) :=\nC_iff_le.2 $ λ t, begin\n  have hp : m (t ∩ ⋃i, s i) ≤ (⨆n, m (t ∩ ⋃i<n, s i)),\n  { convert m.Union (λ i, t ∩ s i),\n    { rw inter_Union_left },\n    { simp [ennreal.tsum_eq_supr_nat, C_sum m h hd] } },\n  refine le_trans (add_le_add_right' hp) _,\n  rw ennreal.supr_add,\n  refine supr_le (λ n, le_trans (add_le_add_left' _)\n    (ge_of_eq (C_Union_lt m (λ i _, h i) _))),\n  refine m.mono (diff_subset_diff_right _),\n  exact bUnion_subset (λ i _, subset_Union _ i),\nend\n\nprivate lemma f_Union {s : ℕ → set α} (h : ∀i, C (s i))\n  (hd : pairwise (disjoint on s)) : m (⋃i, s i) = ∑i, m (s i) :=\nbegin\n  refine le_antisymm (m.Union_nat s) _,\n  rw ennreal.tsum_eq_supr_nat,\n  refine supr_le (λ n, _),\n  have := @C_sum _ m _ h hd univ n,\n  simp at this, simp [this],\n  exact m.mono (bUnion_subset (λ i _, subset_Union _ i)),\nend\n\nprivate def caratheodory_dynkin : measurable_space.dynkin_system α :=\n{ has := C,\n  has_empty := C_empty,\n  has_compl := assume s, C_compl,\n  has_Union_nat := assume f hf hn, C_Union_nat hn hf }\n\n/-- Given an outer measure `μ`, the Caratheodory measurable space is\n  defined such that `s` is measurable if `∀t, μ t = μ (t ∩ s) + μ (t \\ s)`. -/\nprotected def caratheodory : measurable_space α :=\ncaratheodory_dynkin.to_measurable_space $ assume s₁ s₂, C_inter\n\nlemma is_caratheodory {s : set α} :\n  caratheodory.is_measurable s ↔ ∀t, m t = m (t ∩ s) + m (t \\ s) :=\niff.rfl\n\nlemma is_caratheodory_le {s : set α} :\n  caratheodory.is_measurable s ↔ ∀t, m (t ∩ s) + m (t \\ s) ≤ m t :=\nC_iff_le\n\nprotected lemma Union_eq_of_caratheodory {s : ℕ → set α}\n  (h : ∀i, caratheodory.is_measurable (s i)) (hd : pairwise (disjoint on s)) :\n  m (⋃i, s i) = ∑i, m (s i) :=\nf_Union h hd\n\nend caratheodory_measurable\n\nvariables {α : Type*}\n\nlemma caratheodory_is_measurable {m : set α → ennreal} {s : set α}\n  {h₀ : m ∅ = 0} (hs : ∀t, m (t ∩ s) + m (t \\ s) ≤ m t) :\n  (outer_measure.of_function m h₀).caratheodory.is_measurable s :=\nlet o := (outer_measure.of_function m h₀) in\n(is_caratheodory_le o).2 $ λ t,\nle_infi $ λ f, le_infi $ λ hf, begin\n  refine le_trans (add_le_add'\n    (infi_le_of_le (λi, f i ∩ s) $ infi_le _ _)\n    (infi_le_of_le (λi, f i \\ s) $ infi_le _ _)) _,\n  { rw ← inter_Union_right,\n    exact inter_subset_inter_left _ hf },\n  { rw ← diff_Union_right,\n    exact diff_subset_diff_left hf },\n  { rw ← ennreal.tsum_add,\n    exact ennreal.tsum_le_tsum (λ i, hs _) }\nend\n\n@[simp] theorem zero_caratheodory : (0 : outer_measure α).caratheodory = ⊤ :=\ntop_unique $ λ s _ t, (add_zero _).symm\n\ntheorem le_add_caratheodory (m₁ m₂ : outer_measure α) :\n  m₁.caratheodory ⊓ m₂.caratheodory ≤ (m₁ + m₂ : outer_measure α).caratheodory :=\nλ s ⟨hs₁, hs₂⟩ t, by simp [hs₁ t, hs₂ t]\n\ntheorem le_sum_caratheodory {ι} (m : ι → outer_measure α) :\n  (⨅ i, (m i).caratheodory) ≤ (sum m).caratheodory :=\nλ s h t, by simp [λ i,\n  measurable_space.is_measurable_infi.1 h i t, ennreal.tsum_add]\n\ntheorem le_smul_caratheodory (a : ennreal) (m : outer_measure α) :\n  m.caratheodory ≤ (a • m).caratheodory :=\nλ s h t, by simp [h t, mul_add]\n\n@[simp] theorem dirac_caratheodory (a : α) : (dirac a).caratheodory = ⊤ :=\ntop_unique $ λ s _ t, begin\n  by_cases a ∈ t; simp [h],\n  by_cases a ∈ s; simp [h]\nend\n\nend outer_measure\n\nend measure_theory\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/analysis/measure_theory/outer_measure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.4815506846226991}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.functor\n\n/-!\n# Isomorphisms\n\nThis file defines isomorphisms between objects of a category.\n\n## Main definitions\n\n- `structure iso` : a bundled isomorphism between two objects of a category;\n- `class is_iso` : an unbundled version of `iso`;\n  note that `is_iso f` is a `Prop`, and only asserts the existence of an inverse.\n  Of course, this inverse is unique, so it doesn't cost us much to use choice to retrieve it.\n- `inv f`, for the inverse of a morphism with `[is_iso f]`\n- `as_iso` : convert from `is_iso` to `iso` (noncomputable);\n- `of_iso` : convert from `iso` to `is_iso`;\n- standard operations on isomorphisms (composition, inverse etc)\n\n## Notations\n\n- `X ≅ Y` : same as `iso X Y`;\n- `α ≪≫ β` : composition of two isomorphisms; it is called `iso.trans`\n\n## Tags\n\ncategory, category theory, isomorphism\n-/\n\nuniverses v u -- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen category\n\n/--\nAn isomorphism (a.k.a. an invertible morphism) between two objects of a category.\nThe inverse morphism is bundled.\n\nSee also `category_theory.core` for the category with the same objects and isomorphisms playing\nthe role of morphisms.\n\nSee <https://stacks.math.columbia.edu/tag/0017>.\n-/\nstructure iso {C : Type u} [category.{v} C] (X Y : C) :=\n(hom : X ⟶ Y)\n(inv : Y ⟶ X)\n(hom_inv_id' : hom ≫ inv = 𝟙 X . obviously)\n(inv_hom_id' : inv ≫ hom = 𝟙 Y . obviously)\n\nrestate_axiom iso.hom_inv_id'\nrestate_axiom iso.inv_hom_id'\nattribute [simp, reassoc] iso.hom_inv_id iso.inv_hom_id\n\ninfixr ` ≅ `:10  := iso             -- type as \\cong or \\iso\n\nvariables {C : Type u} [category.{v} C]\nvariables {X Y Z : C}\n\nnamespace iso\n\n@[ext] lemma ext ⦃α β : X ≅ Y⦄ (w : α.hom = β.hom) : α = β :=\nsuffices α.inv = β.inv, by cases α; cases β; cc,\ncalc α.inv\n    = α.inv ≫ (β.hom ≫ β.inv) : by rw [iso.hom_inv_id, category.comp_id]\n... = (α.inv ≫ α.hom) ≫ β.inv : by rw [category.assoc, ←w]\n... = β.inv                   : by rw [iso.inv_hom_id, category.id_comp]\n\n/-- Inverse isomorphism. -/\n@[symm] def symm (I : X ≅ Y) : Y ≅ X :=\n{ hom := I.inv,\n  inv := I.hom,\n  hom_inv_id' := I.inv_hom_id',\n  inv_hom_id' := I.hom_inv_id' }\n\n@[simp] lemma symm_hom (α : X ≅ Y) : α.symm.hom = α.inv := rfl\n@[simp] lemma symm_inv (α : X ≅ Y) : α.symm.inv = α.hom := rfl\n\n@[simp] lemma symm_mk {X Y : C} (hom : X ⟶ Y) (inv : Y ⟶ X) (hom_inv_id) (inv_hom_id) :\n  iso.symm {hom := hom, inv := inv, hom_inv_id' := hom_inv_id, inv_hom_id' := inv_hom_id} =\n    {hom := inv, inv := hom, hom_inv_id' := inv_hom_id, inv_hom_id' := hom_inv_id} := rfl\n\n@[simp] lemma symm_symm_eq {X Y : C} (α : X ≅ Y) : α.symm.symm = α :=\nby cases α; refl\n\n@[simp] lemma symm_eq_iff {X Y : C} {α β : X ≅ Y} : α.symm = β.symm ↔ α = β :=\n⟨λ h, symm_symm_eq α ▸ symm_symm_eq β ▸ congr_arg symm h, congr_arg symm⟩\n\n/-- Identity isomorphism. -/\n@[refl, simps] def refl (X : C) : X ≅ X :=\n{ hom := 𝟙 X,\n  inv := 𝟙 X }\n\ninstance : inhabited (X ≅ X) := ⟨iso.refl X⟩\n\n@[simp] lemma refl_symm (X : C) : (iso.refl X).symm = iso.refl X := rfl\n\n/-- Composition of two isomorphisms -/\n@[trans, simps] def trans (α : X ≅ Y) (β : Y ≅ Z) : X ≅ Z :=\n{ hom := α.hom ≫ β.hom,\n  inv := β.inv ≫ α.inv }\n\ninfixr ` ≪≫ `:80 := iso.trans -- type as `\\ll \\gg`.\n\n@[simp] lemma trans_mk {X Y Z : C}\n  (hom : X ⟶ Y) (inv : Y ⟶ X) (hom_inv_id) (inv_hom_id)\n  (hom' : Y ⟶ Z) (inv' : Z ⟶ Y) (hom_inv_id') (inv_hom_id') (hom_inv_id'') (inv_hom_id'') :\n  iso.trans\n    {hom := hom, inv := inv, hom_inv_id' := hom_inv_id, inv_hom_id' := inv_hom_id}\n    {hom := hom', inv := inv', hom_inv_id' := hom_inv_id', inv_hom_id' := inv_hom_id'} =\n  { hom := hom ≫ hom', inv := inv' ≫ inv, hom_inv_id' := hom_inv_id'',\n    inv_hom_id' := inv_hom_id''} :=\nrfl\n\n@[simp] lemma trans_symm (α : X ≅ Y) (β : Y ≅ Z) : (α ≪≫ β).symm = β.symm ≪≫ α.symm := rfl\n@[simp] lemma trans_assoc {Z' : C} (α : X ≅ Y) (β : Y ≅ Z) (γ : Z ≅ Z') :\n  (α ≪≫ β) ≪≫ γ = α ≪≫ β ≪≫ γ :=\nby ext; simp only [trans_hom, category.assoc]\n\n@[simp] lemma refl_trans (α : X ≅ Y) : (iso.refl X) ≪≫ α = α := by ext; apply category.id_comp\n@[simp] lemma trans_refl (α : X ≅ Y) : α ≪≫ (iso.refl Y) = α := by ext; apply category.comp_id\n\n@[simp] lemma symm_self_id (α : X ≅ Y) : α.symm ≪≫ α = iso.refl Y := ext α.inv_hom_id\n@[simp] lemma self_symm_id (α : X ≅ Y) : α ≪≫ α.symm = iso.refl X := ext α.hom_inv_id\n\n@[simp] lemma symm_self_id_assoc (α : X ≅ Y) (β : Y ≅ Z) : α.symm ≪≫ α ≪≫ β = β :=\nby rw [← trans_assoc, symm_self_id, refl_trans]\n\n@[simp] lemma self_symm_id_assoc (α : X ≅ Y) (β : X ≅ Z) : α ≪≫ α.symm ≪≫ β = β :=\nby rw [← trans_assoc, self_symm_id, refl_trans]\n\nlemma inv_comp_eq (α : X ≅ Y) {f : X ⟶ Z} {g : Y ⟶ Z} : α.inv ≫ f = g ↔ f = α.hom ≫ g :=\n⟨λ H, by simp [H.symm], λ H, by simp [H]⟩\n\nlemma eq_inv_comp (α : X ≅ Y) {f : X ⟶ Z} {g : Y ⟶ Z} : g = α.inv ≫ f ↔ α.hom ≫ g = f :=\n(inv_comp_eq α.symm).symm\n\nlemma comp_inv_eq (α : X ≅ Y) {f : Z ⟶ Y} {g : Z ⟶ X} : f ≫ α.inv = g ↔ f = g ≫ α.hom :=\n⟨λ H, by simp [H.symm], λ H, by simp [H]⟩\n\nlemma eq_comp_inv (α : X ≅ Y) {f : Z ⟶ Y} {g : Z ⟶ X} : g = f ≫ α.inv ↔ g ≫ α.hom = f :=\n(comp_inv_eq α.symm).symm\n\nlemma inv_eq_inv (f g : X ≅ Y) : f.inv = g.inv ↔ f.hom = g.hom :=\nhave ∀{X Y : C} (f g : X ≅ Y), f.hom = g.hom → f.inv = g.inv, from λ X Y f g h, by rw [ext h],\n⟨this f.symm g.symm, this f g⟩\n\nlemma hom_comp_eq_id (α : X ≅ Y) {f : Y ⟶ X} : α.hom ≫ f = 𝟙 X ↔ f = α.inv :=\nby rw [←eq_inv_comp, comp_id]\n\nlemma comp_hom_eq_id (α : X ≅ Y) {f : Y ⟶ X} : f ≫ α.hom = 𝟙 Y ↔ f = α.inv :=\nby rw [←eq_comp_inv, id_comp]\n\nlemma inv_comp_eq_id (α : X ≅ Y) {f : X ⟶ Y} : α.inv ≫ f = 𝟙 Y ↔ f = α.hom :=\nhom_comp_eq_id α.symm\n\nlemma comp_inv_eq_id (α : X ≅ Y) {f : X ⟶ Y} : f ≫ α.inv = 𝟙 X ↔ f = α.hom :=\ncomp_hom_eq_id α.symm\n\nlemma hom_eq_inv (α : X ≅ Y) (β : Y ≅ X) : α.hom = β.inv ↔ β.hom = α.inv :=\nby { erw [inv_eq_inv α.symm β, eq_comm], refl }\n\nend iso\n\n/-- `is_iso` typeclass expressing that a morphism is invertible. -/\nclass is_iso (f : X ⟶ Y) : Prop :=\n(out : ∃ inv : Y ⟶ X, f ≫ inv = 𝟙 X ∧ inv ≫ f = 𝟙 Y)\n\n/--\nThe inverse of a morphism `f` when we have `[is_iso f]`.\n-/\nnoncomputable def inv (f : X ⟶ Y) [I : is_iso f] := classical.some I.1\n\nnamespace is_iso\n\n@[simp, reassoc] lemma hom_inv_id (f : X ⟶ Y) [I : is_iso f] : f ≫ inv f = 𝟙 X :=\n(classical.some_spec I.1).left\n@[simp, reassoc] lemma inv_hom_id (f : X ⟶ Y) [I : is_iso f] : inv f ≫ f = 𝟙 Y :=\n(classical.some_spec I.1).right\n\nend is_iso\n\nopen is_iso\n\n/-- Reinterpret a morphism `f` with an `is_iso f` instance as an `iso`. -/\nnoncomputable\ndef as_iso (f : X ⟶ Y) [h : is_iso f] : X ≅ Y := ⟨f, inv f, hom_inv_id f, inv_hom_id f⟩\n\n@[simp] lemma as_iso_hom (f : X ⟶ Y) [is_iso f] : (as_iso f).hom = f := rfl\n@[simp] lemma as_iso_inv (f : X ⟶ Y) [is_iso f] : (as_iso f).inv = inv f := rfl\n\nnamespace is_iso\n\n@[priority 100] -- see Note [lower instance priority]\ninstance epi_of_iso (f : X ⟶ Y) [is_iso f] : epi f  :=\n{ left_cancellation := λ Z g h w,\n  -- This is an interesting test case for better rewrite automation.\n  by rw [← is_iso.inv_hom_id_assoc f g, w, is_iso.inv_hom_id_assoc f h] }\n@[priority 100] -- see Note [lower instance priority]\ninstance mono_of_iso (f : X ⟶ Y) [is_iso f] : mono f :=\n{ right_cancellation := λ Z g h w,\n  by rw [← category.comp_id g, ← category.comp_id h, ← is_iso.hom_inv_id f, ← category.assoc, w,\n    ← category.assoc] }\n\n@[ext] lemma inv_eq_of_hom_inv_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (hom_inv_id : f ≫ g = 𝟙 X) : inv f = g :=\nbegin\n  apply (cancel_epi f).mp,\n  simp [hom_inv_id],\nend\n\nlemma inv_eq_of_inv_hom_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (inv_hom_id : g ≫ f = 𝟙 Y) : inv f = g :=\nbegin\n  apply (cancel_mono f).mp,\n  simp [inv_hom_id],\nend\n\n@[ext] lemma eq_inv_of_hom_inv_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (hom_inv_id : f ≫ g = 𝟙 X) : g = inv f :=\n(inv_eq_of_hom_inv_id hom_inv_id).symm\n\nlemma eq_inv_of_inv_hom_id {f : X ⟶ Y} [is_iso f] {g : Y ⟶ X}\n  (inv_hom_id : g ≫ f = 𝟙 Y) : g = inv f :=\n(inv_eq_of_inv_hom_id inv_hom_id).symm\n\n\ninstance id (X : C) : is_iso (𝟙 X) :=\n⟨⟨𝟙 X, by simp⟩⟩\n\ninstance of_iso (f : X ≅ Y) : is_iso f.hom :=\n⟨⟨f.inv, by simp⟩⟩\n\ninstance of_iso_inv (f : X ≅ Y) : is_iso f.inv :=\nis_iso.of_iso f.symm\n\nvariables {f g : X ⟶ Y} {h : Y ⟶ Z}\n\ninstance inv_is_iso [is_iso f] : is_iso (inv f) :=\nis_iso.of_iso_inv (as_iso f)\n\n/- The following instance has lower priority for the following reason:\nSuppose we are given `f : X ≅ Y` with `X Y : Type u`.\nWithout the lower priority, typeclass inference cannot deduce `is_iso f.hom`\nbecause `f.hom` is defeq to `(λ x, x) ≫ f.hom`, triggering a loop. -/\n@[priority 900]\ninstance comp_is_iso [is_iso f] [is_iso h] : is_iso (f ≫ h) :=\nis_iso.of_iso $ (as_iso f) ≪≫ (as_iso h)\n\n@[simp] lemma inv_id : inv (𝟙 X) = 𝟙 X := by { ext, simp, }\n@[simp] lemma inv_comp [is_iso f] [is_iso h] : inv (f ≫ h) = inv h ≫ inv f := by { ext, simp, }\n@[simp] lemma inv_inv [is_iso f] : inv (inv f) = f := by { ext, simp, }\n@[simp] lemma iso.inv_inv (f : X ≅ Y) : inv (f.inv) = f.hom := by { ext, simp, }\n@[simp] lemma iso.inv_hom (f : X ≅ Y) : inv (f.hom) = f.inv := by { ext, simp, }\n\n@[simp]\nlemma inv_comp_eq (α : X ⟶ Y) [is_iso α] {f : X ⟶ Z} {g : Y ⟶ Z} : inv α ≫ f = g ↔ f = α ≫ g :=\n(as_iso α).inv_comp_eq\n\n@[simp]\nlemma eq_inv_comp (α : X ⟶ Y) [is_iso α] {f : X ⟶ Z} {g : Y ⟶ Z} : g = inv α ≫ f ↔ α ≫ g = f :=\n(as_iso α).eq_inv_comp\n\n@[simp]\nlemma comp_inv_eq (α : X ⟶ Y) [is_iso α] {f : Z ⟶ Y} {g : Z ⟶ X} : f ≫ inv α = g ↔ f = g ≫ α :=\n(as_iso α).comp_inv_eq\n\n@[simp]\nlemma eq_comp_inv (α : X ⟶ Y) [is_iso α] {f : Z ⟶ Y} {g : Z ⟶ X} : g = f ≫ inv α ↔ g ≫ α = f :=\n(as_iso α).eq_comp_inv\n\nlemma of_is_iso_comp_left {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [is_iso f] [is_iso (f ≫ g)] : is_iso g :=\nby { rw [← id_comp g, ← inv_hom_id f, assoc], apply_instance, }\n\nlemma of_is_iso_comp_right {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [is_iso g] [is_iso (f ≫ g)] : is_iso f :=\nby { rw [← comp_id f, ← hom_inv_id g, ← assoc], apply_instance, }\n\nlemma of_is_iso_fac_left {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z}\n  [is_iso f] [hh : is_iso h] (w : f ≫ g = h) : is_iso g :=\nby { rw ← w at hh, haveI := hh, exact of_is_iso_comp_left f g, }\n\nlemma of_is_iso_fac_right {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z}\n  [is_iso g] [hh : is_iso h] (w : f ≫ g = h) : is_iso f :=\nby { rw ← w at hh, haveI := hh, exact of_is_iso_comp_right f g, }\n\nend is_iso\n\nopen is_iso\n\nlemma eq_of_inv_eq_inv {f g : X ⟶ Y} [is_iso f] [is_iso g] (p : inv f = inv g) : f = g :=\nbegin\n  apply (cancel_epi (inv f)).1,\n  erw [inv_hom_id, p, inv_hom_id],\nend\n\nlemma is_iso.inv_eq_inv {f g : X ⟶ Y} [is_iso f] [is_iso g] : inv f = inv g ↔ f = g :=\niso.inv_eq_inv (as_iso f) (as_iso g)\n\nlemma hom_comp_eq_id (g : X ⟶ Y) [is_iso g] {f : Y ⟶ X} : g ≫ f = 𝟙 X ↔ f = inv g :=\n(as_iso g).hom_comp_eq_id\n\nlemma comp_hom_eq_id (g : X ⟶ Y) [is_iso g] {f : Y ⟶ X} : f ≫ g = 𝟙 Y ↔ f = inv g :=\n(as_iso g).comp_hom_eq_id\n\nlemma inv_comp_eq_id (g : X ⟶ Y) [is_iso g] {f : X ⟶ Y} : inv g ≫ f = 𝟙 Y ↔ f = g :=\n(as_iso g).inv_comp_eq_id\n\nlemma comp_inv_eq_id (g : X ⟶ Y) [is_iso g] {f : X ⟶ Y} : f ≫ inv g = 𝟙 X ↔ f = g :=\n(as_iso g).comp_inv_eq_id\n\nlemma is_iso_of_hom_comp_eq_id (g : X ⟶ Y) [is_iso g] {f : Y ⟶ X} (h : g ≫ f = 𝟙 X) : is_iso f :=\nby { rw [(hom_comp_eq_id _).mp h], apply_instance }\n\nlemma is_iso_of_comp_hom_eq_id (g : X ⟶ Y) [is_iso g] {f : Y ⟶ X} (h : f ≫ g = 𝟙 Y) : is_iso f :=\nby { rw [(comp_hom_eq_id _).mp h], apply_instance }\n\nnamespace iso\n\n@[ext] lemma inv_ext {f : X ≅ Y} {g : Y ⟶ X}\n  (hom_inv_id : f.hom ≫ g = 𝟙 X) : f.inv = g :=\n((hom_comp_eq_id f).1 hom_inv_id).symm\n\n@[ext] lemma inv_ext' {f : X ≅ Y} {g : Y ⟶ X}\n  (hom_inv_id : f.hom ≫ g = 𝟙 X) : g = f.inv :=\n(hom_comp_eq_id f).1 hom_inv_id\n\n/-!\nAll these cancellation lemmas can be solved by `simp [cancel_mono]` (or `simp [cancel_epi]`),\nbut with the current design `cancel_mono` is not a good `simp` lemma,\nbecause it generates a typeclass search.\n\nWhen we can see syntactically that a morphism is a `mono` or an `epi`\nbecause it came from an isomorphism, it's fine to do the cancellation via `simp`.\n\nIn the longer term, it might be worth exploring making `mono` and `epi` structures,\nrather than typeclasses, with coercions back to `X ⟶ Y`.\nPresumably we could write `X ↪ Y` and `X ↠ Y`.\n-/\n\n@[simp] lemma cancel_iso_hom_left {X Y Z : C} (f : X ≅ Y) (g g' : Y ⟶ Z) :\n  f.hom ≫ g = f.hom ≫ g' ↔ g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_inv_left {X Y Z : C} (f : Y ≅ X) (g g' : Y ⟶ Z) :\n  f.inv ≫ g = f.inv ≫ g' ↔ g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_hom_right {X Y Z : C} (f f' : X ⟶ Y) (g : Y ≅ Z) :\n  f ≫ g.hom = f' ≫ g.hom ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right {X Y Z : C} (f f' : X ⟶ Y) (g : Z ≅ Y) :\n  f ≫ g.inv = f' ≫ g.inv ↔ f = f' :=\nby simp only [cancel_mono]\n\n/-\nUnfortunately cancelling an isomorphism from the right of a chain of compositions is awkward.\nWe would need separate lemmas for each chain length (worse: for each pair of chain lengths).\n\nWe provide two more lemmas, for case of three morphisms, because this actually comes up in practice,\nbut then stop.\n-/\n\n@[simp] lemma cancel_iso_hom_right_assoc {W X X' Y Z : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y)\n  (h : Y ≅ Z) :\n  f ≫ g ≫ h.hom = f' ≫ g' ≫ h.hom ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right_assoc {W X X' Y Z : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y)\n  (h : Z ≅ Y) :\n  f ≫ g ≫ h.inv = f' ≫ g' ≫ h.inv ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\nend iso\n\nnamespace functor\n\nuniverses u₁ v₁ u₂ v₂\nvariables {D : Type u₂}\n\nvariables [category.{v₂} D]\n\n/-- A functor `F : C ⥤ D` sends isomorphisms `i : X ≅ Y` to isomorphisms `F.obj X ≅ F.obj Y` -/\n@[simps]\ndef map_iso (F : C ⥤ D) {X Y : C} (i : X ≅ Y) : F.obj X ≅ F.obj Y :=\n{ hom := F.map i.hom,\n  inv := F.map i.inv,\n  hom_inv_id' := by rw [←map_comp, iso.hom_inv_id, ←map_id],\n  inv_hom_id' := by rw [←map_comp, iso.inv_hom_id, ←map_id] }\n\n@[simp] lemma map_iso_symm (F : C ⥤ D) {X Y : C} (i : X ≅ Y) :\n  F.map_iso i.symm = (F.map_iso i).symm :=\nrfl\n\n@[simp] lemma map_iso_trans (F : C ⥤ D) {X Y Z : C} (i : X ≅ Y) (j : Y ≅ Z) :\n  F.map_iso (i ≪≫ j) = (F.map_iso i) ≪≫ (F.map_iso j) :=\nby ext; apply functor.map_comp\n\n@[simp] lemma map_iso_refl (F : C ⥤ D) (X : C) : F.map_iso (iso.refl X) = iso.refl (F.obj X) :=\niso.ext $ F.map_id X\n\ninstance map_is_iso (F : C ⥤ D) (f : X ⟶ Y) [is_iso f] : is_iso (F.map f) :=\nis_iso.of_iso $ F.map_iso (as_iso f)\n\n@[simp] \n\nlemma map_hom_inv (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [is_iso f] :\n  F.map f ≫ F.map (inv f) = 𝟙 (F.obj X) :=\nby simp\n\nlemma map_inv_hom (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) [is_iso f] :\n  F.map (inv f) ≫ F.map f = 𝟙 (F.obj Y) :=\nby simp\n\nend functor\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/isomorphism.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879992, "lm_q2_score": 0.679178692681616, "lm_q1q2_score": 0.48155068001848716}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport data.pfun\nimport order.preorder_hom\nimport tactic.wlog\nimport tactic.monotonicity\n\n/-!\n# Omega Complete Partial Orders\n\nAn omega-complete partial order is a partial order with a supremum\noperation on increasing sequences indexed by natural numbers (which we\ncall `ωSup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only ω-sized totally ordered sets have a supremum.\n\nThe concept of an omega-complete partial order (ωCPO) is useful for the\nformalization of the semantics of programming languages. Its notion of\nsupremum helps define the meaning of recursive procedures.\n\n## Main definitions\n\n * class `omega_complete_partial_order`\n * `ite`, `map`, `bind`, `seq` as continuous morphisms\n\n## Instances of `omega_complete_partial_order`\n\n * `roption`\n * every `complete_lattice`\n * pi-types\n * product types\n * `monotone_hom`\n * `continuous_hom` (with notation →𝒄)\n   * an instance of `omega_complete_partial_order (α →𝒄 β)`\n * `continuous_hom.of_fun`\n * `continuous_hom.of_mono`\n * continuous functions:\n   * `id`\n   * `ite`\n   * `const`\n   * `roption.bind`\n   * `roption.map`\n   * `roption.seq`\n\n## References\n\n * [G. Markowsky, *Chain-complete posets and directed sets with applications*, https://doi.org/10.1007/BF02485815][markowsky]\n * [J. M. Cadiou and Zohar Manna, *Recursive definitions of partial functions and their computations.*, https://doi.org/10.1145/942580.807072][cadiou]\n * [Carl A. Gunter, *Semantics of Programming Languages: Structures and Techniques*, ISBN: 0262570955][gunter]\n-/\n\nuniverses u v\n\nlocal attribute [-simp] roption.bind_eq_bind roption.map_eq_map\nopen_locale classical\n\nnamespace preorder_hom\n\nvariables (α : Type*) (β : Type*) {γ : Type*} {φ : Type*}\nvariables [preorder α] [preorder β] [preorder γ] [preorder φ]\n\nvariables {β γ}\n\n/-- The constant function, as a monotone function. -/\n@[simps]\ndef const (f : β) : α →ₘ β :=\n{ to_fun := function.const _ f,\n  monotone' := assume x y h, le_refl _}\n\nvariables {α} {α' : Type*} {β' : Type*} [preorder α'] [preorder β']\n\n/-- The diagonal function, as a monotone function. -/\n@[simps]\ndef prod.diag : α →ₘ (α × α) :=\n{ to_fun := λ x, (x,x),\n  monotone' := λ x y h, ⟨h,h⟩ }\n\n/-- The `prod.map` function, as a monotone function. -/\n@[simps]\ndef prod.map (f : α →ₘ β) (f' : α' →ₘ β') : (α × α') →ₘ (β × β') :=\n{ to_fun := prod.map f f',\n  monotone' := λ ⟨x,x'⟩ ⟨y,y'⟩ ⟨h,h'⟩, ⟨f.monotone h,f'.monotone h'⟩ }\n\n/-- The `prod.fst` projection, as a monotone function. -/\n@[simps]\ndef prod.fst : (α × β) →ₘ α :=\n{ to_fun := prod.fst,\n  monotone' := λ ⟨x,x'⟩ ⟨y,y'⟩ ⟨h,h'⟩, h }\n\n/-- The `prod.snd` projection, as a monotone function. -/\n@[simps]\ndef prod.snd : (α × β) →ₘ β :=\n{ to_fun := prod.snd,\n  monotone' := λ ⟨x,x'⟩ ⟨y,y'⟩ ⟨h,h'⟩, h' }\n\n/-- The `prod` constructor, as a monotone function. -/\n@[simps]\ndef prod.zip (f : α →ₘ β) (g : α →ₘ γ) : α →ₘ (β × γ) :=\n(prod.map f g).comp prod.diag\n\n/-- `roption.bind` as a monotone function -/\n@[simps]\ndef bind {β γ} (f : α →ₘ roption β) (g : α →ₘ β → roption γ) : α →ₘ roption γ :=\n{ to_fun := λ x, f x >>= g x,\n  monotone' :=\n  begin\n    intros x y h a,\n    simp only [and_imp, exists_prop, roption.bind_eq_bind, roption.mem_bind_iff,\n               exists_imp_distrib],\n    intros b hb ha,\n    refine ⟨b, f.monotone h _ hb, g.monotone h _ _ ha⟩,\n  end }\n\nend preorder_hom\n\nnamespace omega_complete_partial_order\n\n/-- A chain is a monotonically increasing sequence.\n\nSee the definition on page 114 of [gunter]. -/\ndef chain (α : Type u) [preorder α] :=\nℕ →ₘ α\n\nnamespace chain\n\nvariables {α : Type u} {β : Type v} {γ : Type*}\nvariables [preorder α] [preorder β] [preorder γ]\n\ninstance : has_coe_to_fun (chain α) :=\n@infer_instance (has_coe_to_fun $ ℕ →ₘ α) _\n\ninstance [inhabited α] : inhabited (chain α) :=\n⟨ ⟨ λ _, default _, λ _ _ _, le_refl _ ⟩ ⟩\n\ninstance : has_mem α (chain α) :=\n⟨λa (c : ℕ →ₘ α), ∃ i, a = c i⟩\n\nvariables (c c' : chain α)\nvariables (f : α →ₘ β)\nvariables (g : β →ₘ γ)\n\ninstance : has_le (chain α) :=\n{ le := λ x y, ∀ i, ∃ j, x i ≤ y j  }\n\n/-- `map` function for `chain` -/\n@[simps] def map : chain β :=\nf.comp c\n\nvariables {f}\n\nlemma mem_map (x : α) : x ∈ c → f x ∈ chain.map c f :=\nλ ⟨i,h⟩, ⟨i, h.symm ▸ rfl⟩\n\nlemma exists_of_mem_map {b : β} : b ∈ c.map f → ∃ a, a ∈ c ∧ f a = b :=\nλ ⟨i,h⟩, ⟨c i, ⟨i, rfl⟩, h.symm⟩\n\nlemma mem_map_iff {b : β} : b ∈ c.map f ↔ ∃ a, a ∈ c ∧ f a = b :=\n⟨ exists_of_mem_map _, λ h, by { rcases h with ⟨w,h,h'⟩, subst b, apply mem_map c _ h, } ⟩\n\n@[simp]\nlemma map_id : c.map preorder_hom.id = c :=\npreorder_hom.comp_id _\n\nlemma map_comp : (c.map f).map g = c.map (g.comp f) := rfl\n\n@[mono]\nlemma map_le_map {g : α →ₘ β} (h : f ≤ g) : c.map f ≤ c.map g :=\nλ i, by simp [mem_map_iff]; intros; existsi i; apply h\n\n/-- `chain.zip` pairs up the elements of two chains that have the same index -/\n@[simps]\ndef zip (c₀ : chain α) (c₁ : chain β) : chain (α × β) :=\npreorder_hom.prod.zip c₀ c₁\n\nend chain\n\nend omega_complete_partial_order\n\nopen omega_complete_partial_order\n\nsection prio\nset_option extends_priority 50\n\n/-- An omega-complete partial order is a partial order with a supremum\noperation on increasing sequences indexed by natural numbers (which we\ncall `ωSup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only ω-sized totally ordered sets have a supremum.\n\nSee the definition on page 114 of [gunter]. -/\nclass omega_complete_partial_order (α : Type*) extends partial_order α :=\n(ωSup     : chain α → α)\n(le_ωSup  : ∀(c:chain α), ∀ i, c i ≤ ωSup c)\n(ωSup_le  : ∀(c:chain α) x, (∀ i, c i ≤ x) → ωSup c ≤ x)\n\nend prio\n\nnamespace omega_complete_partial_order\nvariables {α : Type u} {β : Type v} {γ : Type*}\nvariables [omega_complete_partial_order α]\n\n/-- Transfer a `omega_complete_partial_order` on `β` to a `omega_complete_partial_order` on `α`\nusing a strictly monotone function `f : β →ₘ α`, a definition of ωSup and a proof that `f` is\ncontinuous with regard to the provided `ωSup` and the ωCPO on `α`. -/\n@[reducible]\nprotected def lift [partial_order β] (f : β →ₘ α)\n  (ωSup₀ : chain β → β)\n  (h : ∀ x y, f x ≤ f y → x ≤ y)\n  (h' : ∀ c, f (ωSup₀ c) = ωSup (c.map f)) : omega_complete_partial_order β :=\n{ ωSup := ωSup₀,\n  ωSup_le := λ c x hx, h _ _ (by rw h'; apply ωSup_le; intro; apply f.monotone (hx i)),\n  le_ωSup := λ c i, h _ _ (by rw h'; apply le_ωSup (c.map f)) }\n\nlemma le_ωSup_of_le {c : chain α} {x : α} (i : ℕ) (h : x ≤ c i) : x ≤ ωSup c :=\nle_trans h (le_ωSup c _)\n\nlemma ωSup_total {c : chain α} {x : α} (h : ∀ i, c i ≤ x ∨ x ≤ c i) : ωSup c ≤ x ∨ x ≤ ωSup c :=\nclassical.by_cases\n  (assume : ∀ i, c i ≤ x, or.inl (ωSup_le _ _ this))\n  (assume : ¬ ∀ i, c i ≤ x,\n    have ∃ i, ¬ c i ≤ x,\n      by simp only [not_forall] at this ⊢; assumption,\n    let ⟨i, hx⟩ := this in\n    have x ≤ c i, from (h i).resolve_left hx,\n    or.inr $ le_ωSup_of_le _ this)\n\n@[mono]\nlemma ωSup_le_ωSup_of_le {c₀ c₁ : chain α} (h : c₀ ≤ c₁) : ωSup c₀ ≤ ωSup c₁ :=\nωSup_le _ _ $\nλ i, Exists.rec_on (h i) $\nλ j h, le_trans h (le_ωSup _ _)\n\nlemma ωSup_le_iff (c : chain α) (x : α) : ωSup c ≤ x ↔ (∀ i, c i ≤ x) :=\nbegin\n  split; intros,\n  { transitivity ωSup c,\n    exact le_ωSup _ _, assumption },\n  exact ωSup_le _ _ ‹_›,\nend\n\n/-- A subset `p : α → Prop` of the type closed under `ωSup` induces an\n`omega_complete_partial_order` on the subtype `{a : α // p a}`. -/\ndef subtype {α : Type*} [omega_complete_partial_order α] (p : α → Prop)\n  (hp : ∀ (c : chain α), (∀ i ∈ c, p i) → p (ωSup c)) :\n  omega_complete_partial_order (subtype p) :=\nomega_complete_partial_order.lift\n  (preorder_hom.subtype.val p)\n  (λ c, ⟨ωSup _, hp (c.map (preorder_hom.subtype.val p)) (λ i ⟨n, q⟩, q.symm ▸ (c n).2)⟩)\n  (λ x y h, h)\n  (λ c, rfl)\n\nsection continuity\nopen chain\n\nvariables [omega_complete_partial_order β]\nvariables [omega_complete_partial_order γ]\n\n/-- A monotone function `f : α →ₘ β` is continuous if it distributes over ωSup.\n\nIn order to distinguish it from the (more commonly used) continuity from topology\n(see topology/basic.lean), the present definition is often referred to as\n\"Scott-continuity\" (referring to Dana Scott). It corresponds to continuity\nin Scott topological spaces (not defined here). -/\ndef continuous (f : α →ₘ β) : Prop :=\n∀ c : chain α, f (ωSup c) = ωSup (c.map f)\n\n/-- `continuous' f` asserts that `f` is both monotone and continuous. -/\ndef continuous' (f : α → β) : Prop :=\n∃ hf : monotone f, continuous ⟨f, hf⟩\n\nlemma continuous.to_monotone {f : α → β} (hf : continuous' f) : monotone f := hf.fst\n\nlemma continuous.of_bundled (f : α → β) (hf : monotone f)\n  (hf' : continuous ⟨f, hf⟩) : continuous' f := ⟨hf, hf'⟩\n\nlemma continuous.of_bundled' (f : α →ₘ β) (hf' : continuous f) : continuous' f :=\n⟨f.monotone, hf'⟩\n\nlemma continuous.to_bundled (f : α → β) (hf : continuous' f) :\n  continuous ⟨f, continuous.to_monotone hf⟩ := hf.snd\n\nvariables (f : α →ₘ β) (g : β →ₘ γ)\n\nlemma continuous_id : continuous (@preorder_hom.id α _) :=\nby intro; rw c.map_id; refl\n\nlemma continuous_comp (hfc : continuous f) (hgc : continuous g) : continuous (g.comp f):=\nbegin\n  dsimp [continuous] at *, intro,\n  rw [hfc,hgc,chain.map_comp]\nend\n\nlemma id_continuous' : continuous' (@id α) :=\ncontinuous.of_bundled _ (λ a b h, h)\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp [ωSup_le_iff,function.const],\nend\n\nlemma const_continuous' (x: β) : continuous' (function.const α x) :=\ncontinuous.of_bundled _ (λ a b h, le_refl _)\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp [ωSup_le_iff,function.const],\nend\n\nend continuity\n\nend omega_complete_partial_order\n\nnamespace roption\n\nvariables {α : Type u} {β : Type v} {γ : Type*}\nopen omega_complete_partial_order\n\nlemma eq_of_chain {c : chain (roption α)} {a b : α} (ha : some a ∈ c) (hb : some b ∈ c) : a = b :=\nbegin\n  cases ha with i ha, replace ha := ha.symm,\n  cases hb with j hb, replace hb := hb.symm,\n  wlog h : i ≤ j := le_total i j using [a b i j, b a j i],\n  rw [eq_some_iff] at ha hb,\n  have := c.monotone h _ ha, apply mem_unique this hb\nend\n\n/-- The (noncomputable) `ωSup` definition for the `ω`-CPO structure on `roption α`. -/\nprotected noncomputable def ωSup (c : chain (roption α)) : roption α :=\nif h : ∃a, some a ∈ c then some (classical.some h) else none\n\nlemma ωSup_eq_some {c : chain (roption α)} {a : α} (h : some a ∈ c) : roption.ωSup c = some a :=\nhave ∃a, some a ∈ c, from ⟨a, h⟩,\nhave a' : some (classical.some this) ∈ c, from classical.some_spec this,\ncalc roption.ωSup c = some (classical.some this) : dif_pos this\n                ... = some a : congr_arg _ (eq_of_chain a' h)\n\nlemma ωSup_eq_none {c : chain (roption α)} (h : ¬∃a, some a ∈ c) : roption.ωSup c = none :=\ndif_neg h\n\nlemma mem_chain_of_mem_ωSup {c : chain (roption α)} {a : α} (h : a ∈ roption.ωSup c) : some a ∈ c :=\nbegin\n  simp [roption.ωSup] at h, split_ifs at h,\n  { have h' := classical.some_spec h_1,\n    rw ← eq_some_iff at h, rw ← h, exact h' },\n  { rcases h with ⟨ ⟨ ⟩ ⟩ }\nend\n\nnoncomputable instance omega_complete_partial_order : omega_complete_partial_order (roption α) :=\n{ ωSup    := roption.ωSup,\n  le_ωSup := λ c i, by { intros x hx, rw ← eq_some_iff at hx ⊢,\n                         rw [ωSup_eq_some, ← hx], rw ← hx, exact ⟨i,rfl⟩ },\n  ωSup_le := by { rintros c x hx a ha, replace ha := mem_chain_of_mem_ωSup ha,\n                  cases ha with i ha, apply hx i, rw ← ha, apply mem_some } }\n\nsection inst\n\nlemma mem_ωSup (x : α) (c : chain (roption α)) : x ∈ ωSup c ↔ some x ∈ c :=\nbegin\n  simp [omega_complete_partial_order.ωSup,roption.ωSup],\n  split,\n  { split_ifs, swap, rintro ⟨⟨⟩⟩,\n    intro h', have hh := classical.some_spec h,\n    simp at h', subst x, exact hh },\n  { intro h,\n    have h' : ∃ (a : α), some a ∈ c := ⟨_,h⟩,\n    rw dif_pos h', have hh := classical.some_spec h',\n    rw eq_of_chain hh h, simp }\nend\n\nend inst\n\nend roption\n\nnamespace pi\n\nvariables {α : Type*} {β : α → Type*} {γ : Type*}\n\n/-- Function application `λ f, f a` is monotone with respect to `f` for fixed `a`. -/\n@[simps]\ndef monotone_apply [∀a, partial_order (β a)] (a : α) : (Πa, β a) →ₘ β a :=\n{ to_fun := (λf:Πa, β a, f a),\n  monotone' := assume f g hfg, hfg a }\n\nopen omega_complete_partial_order omega_complete_partial_order.chain\n\ninstance [∀a, omega_complete_partial_order (β a)] : omega_complete_partial_order (Πa, β a) :=\n{ ωSup    := λc a, ωSup (c.map (monotone_apply a)),\n  ωSup_le := assume c f hf a, ωSup_le _ _ $ by { rintro i, apply hf },\n  le_ωSup := assume c i x, le_ωSup_of_le _ $ le_refl _ }\n\nnamespace omega_complete_partial_order\n\nvariables [∀ x, omega_complete_partial_order $ β x]\nvariables [omega_complete_partial_order γ]\n\nlemma flip₁_continuous'\n  (f : ∀ x : α, γ → β x) (a : α) (hf : continuous' (λ x y, f y x)) :\n  continuous' (f a) :=\ncontinuous.of_bundled _\n  (λ x y h, continuous.to_monotone hf h a)\n  (λ c, congr_fun (continuous.to_bundled _ hf c) a)\n\nlemma flip₂_continuous'\n  (f : γ → Π x, β x) (hf : ∀ x, continuous' (λ g, f g x)) : continuous' f :=\ncontinuous.of_bundled _\n  (λ x y h a, continuous.to_monotone (hf a) h)\n  (by intro c; ext a; apply continuous.to_bundled _ (hf a) c)\n\nend omega_complete_partial_order\n\nend pi\n\nnamespace prod\n\nopen omega_complete_partial_order\nvariables {α : Type*} {β : Type*} {γ : Type*}\nvariables [omega_complete_partial_order α]\nvariables [omega_complete_partial_order β]\nvariables [omega_complete_partial_order γ]\n\n/-- The supremum of a chain in the product `ω`-CPO. -/\n@[simps]\nprotected def ωSup (c : chain (α × β)) : α × β :=\n(ωSup (c.map preorder_hom.prod.fst), ωSup (c.map preorder_hom.prod.snd))\n\n@[simps ωSup_fst ωSup_snd]\ninstance : omega_complete_partial_order (α × β) :=\n{ ωSup := prod.ωSup,\n  ωSup_le := λ c ⟨x,x'⟩ h, ⟨ωSup_le _ _ $ λ i, (h i).1, ωSup_le _ _ $ λ i, (h i).2⟩,\n  le_ωSup := λ c i,\n    ⟨le_ωSup (c.map preorder_hom.prod.fst) i, le_ωSup (c.map preorder_hom.prod.snd) i⟩ }\n\nend prod\n\nnamespace complete_lattice\nvariables (α : Type u)\n\n/-- Any complete lattice has an `ω`-CPO structure where the countable supremum is a special case\nof arbitrary suprema. -/\n\n@[priority 100] -- see Note [lower instance priority]\ninstance [complete_lattice α] : omega_complete_partial_order α :=\n{ ωSup    := λc, ⨆ i, c i,\n  ωSup_le := λ ⟨c, _⟩ s hs, by simp only [supr_le_iff, preorder_hom.coe_fun_mk] at ⊢ hs;\n    intros i; apply hs i,\n  le_ωSup := assume ⟨c, _⟩ i, by simp only [preorder_hom.coe_fun_mk]; apply le_supr_of_le i; refl }\n\nvariables {α} {β : Type v} [omega_complete_partial_order α] [complete_lattice β]\nopen omega_complete_partial_order\n\nlemma inf_continuous [is_total β (≤)] (f g : α →ₘ β) (hf : continuous f) (hg : continuous g) :\n  continuous (f ⊓ g) :=\nbegin\n  intro c,\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [inf_le_iff, hf c, hg c, ωSup_le_iff, ←forall_or_distrib_left, ←forall_or_distrib_right,\n             chain.map_to_fun, function.comp_app, preorder_hom.has_inf_inf_to_fun],\n  split,\n  { introv h, apply h },\n  { intros h i j,\n    apply or.imp _ _ (h (max i j)); apply le_trans; mono*,\n    { apply le_max_left },\n    { apply le_max_right }, },\nend\n\nlemma Sup_continuous (s : set $ α →ₘ β) (hs : ∀ f ∈ s, continuous f) :\n  continuous (Sup s) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [ωSup_le_iff, and_imp, preorder_hom.complete_lattice_Sup, set.mem_image,\n             chain.map_to_fun, function.comp_app, Sup_le_iff, preorder_hom.has_Sup_Sup_to_fun,\n             exists_imp_distrib],\n  split; introv h hx hb; subst b,\n  { apply le_trans _ (h _ _ hx rfl),\n    mono, apply le_ωSup },\n  { rw [hs _ hx c, ωSup_le_iff], intro,\n    apply h i _ x hx rfl, }\nend\n\ntheorem Sup_continuous' :\n  ∀s : set (α → β), (∀t∈s, omega_complete_partial_order.continuous' t) →\n  omega_complete_partial_order.continuous' (Sup s) :=\nbegin\n  introv ht, dsimp [continuous'],\n  have : monotone (Sup s),\n  { intros x y h,\n    apply Sup_le_Sup_of_forall_exists_le, intro,\n    simp only [and_imp, exists_prop, set.mem_range, set_coe.exists, subtype.coe_mk,\n      exists_imp_distrib],\n    intros f hfs hfx,\n    subst hfx,\n    refine ⟨f y, ⟨f, hfs, rfl⟩, _⟩,\n    cases ht _ hfs with hf,\n    apply hf h },\n  existsi this,\n  let s' : set (α →ₘ β) := { f | ⇑f ∈ s },\n  suffices : omega_complete_partial_order.continuous (Sup s'),\n  { convert this, ext,\n    simp only [supr, has_Sup.Sup, Sup, set.image, set.mem_set_of_eq],\n    congr, ext,\n    simp only [exists_prop, set.mem_range, set_coe.exists, set.mem_set_of_eq, subtype.coe_mk],\n    split,\n    { rintro ⟨y,hy,hy'⟩,\n      cases ht _ hy,\n      refine ⟨⟨_, w⟩, hy, hy'⟩ },\n    tauto },\n  apply complete_lattice.Sup_continuous,\n  intros f hf,\n  specialize ht f hf, cases ht, exact ht_h,\nend\n\nlemma sup_continuous {f g : α →ₘ β} (hf : continuous f) (hg : continuous g) :\n  continuous (f ⊔ g) :=\nbegin\n  rw ← Sup_pair, apply Sup_continuous,\n  simp only [or_imp_distrib, forall_and_distrib, set.mem_insert_iff, set.mem_singleton_iff,\n    forall_eq],\n  split; assumption,\nend\n\nlemma top_continuous :\n  continuous (⊤ : α →ₘ β) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [ωSup_le_iff, forall_const, chain.map_to_fun, function.comp_app,\n             preorder_hom.has_top_top_to_fun],\nend\n\nlemma bot_continuous :\n  continuous (⊥ : α →ₘ β) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [ωSup_le_iff, forall_const, chain.map_to_fun, function.comp_app,\n             preorder_hom.has_bot_bot_to_fun],\nend\n\nend complete_lattice\n\nnamespace omega_complete_partial_order\n\nvariables {α : Type u} {α' : Type*} {β : Type v} {β' : Type*} {γ : Type*} {φ : Type*}\n\nvariables [omega_complete_partial_order α] [omega_complete_partial_order β]\nvariables [omega_complete_partial_order γ] [omega_complete_partial_order φ]\nvariables [omega_complete_partial_order α'] [omega_complete_partial_order β']\n\nnamespace preorder_hom\n\n/-- Function application `λ f, f a` (for fixed `a`) is a monotone function from the\nmonotone function space `α →ₘ β` to `β`. -/\n@[simps]\ndef monotone_apply (a : α) : (α →ₘ β) →ₘ β :=\n{ to_fun := (λf : α →ₘ β, f a),\n  monotone' := assume f g hfg, hfg a }\n\n/-- The \"forgetful functor\" from `α →ₘ β` to `α → β` that takes the underlying function,\nis monotone. -/\ndef to_fun_hom : (α →ₘ β) →ₘ (α → β) :=\n{ to_fun := λ f, f.to_fun,\n  monotone' := λ x y h, h }\n\n/-- The `ωSup` operator for monotone functions. -/\n@[simps]\nprotected def ωSup (c : chain (α →ₘ β)) : α →ₘ β :=\n{ to_fun := λ a, ωSup (c.map (monotone_apply a)),\n  monotone' := λ x y h, ωSup_le_ωSup_of_le (chain.map_le_map _ $ λ a, a.monotone h) }\n\n@[simps ωSup_to_fun]\ninstance omega_complete_partial_order : omega_complete_partial_order (α →ₘ β) :=\nomega_complete_partial_order.lift preorder_hom.to_fun_hom preorder_hom.ωSup\n  (λ x y h, h) (λ c, rfl)\n\nend preorder_hom\n\nsection old_struct\nset_option old_structure_cmd true\nvariables (α β)\n\n/-- A monotone function on `ω`-continuous partial orders is said to be continuous\nif for every chain `c : chain α`, `f (⊔ i, c i) = ⊔ i, f (c i)`.\nThis is just the bundled version of `preorder_hom.continuous`. -/\nstructure continuous_hom extends preorder_hom α β :=\n(cont : continuous (preorder_hom.mk to_fun monotone'))\n\nattribute [nolint doc_blame] continuous_hom.to_preorder_hom\n\ninfixr ` →𝒄 `:25 := continuous_hom -- Input: \\r\\MIc\n\ninstance : has_coe_to_fun (α →𝒄 β) :=\n{ F := λ _, α → β,\n  coe :=  continuous_hom.to_fun }\n\ninstance : has_coe (α →𝒄 β) (α →ₘ β) :=\n{ coe :=  continuous_hom.to_preorder_hom }\n\ninstance : partial_order (α →𝒄 β) :=\npartial_order.lift continuous_hom.to_fun $ by rintro ⟨⟩ ⟨⟩ h; congr; exact h\n\nend old_struct\n\nnamespace continuous_hom\n\ntheorem congr_fun {f g : α →𝒄 β} (h : f = g) (x : α) : f x = g x :=\ncongr_arg (λ h : α →𝒄 β, h x) h\n\ntheorem congr_arg (f : α →𝒄 β) {x y : α} (h : x = y) : f x = f y :=\ncongr_arg (λ x : α, f x) h\n\n@[mono]\nlemma monotone (f : α →𝒄 β) : monotone f :=\ncontinuous_hom.monotone' f\n\nlemma ite_continuous' {p : Prop} [hp : decidable p] (f g : α → β)\n  (hf : continuous' f) (hg : continuous' g) : continuous' (λ x, if p then f x else g x) :=\nby split_ifs; simp *\n\nlemma ωSup_bind {β γ : Type v} (c : chain α) (f : α →ₘ roption β) (g : α →ₘ β → roption γ) :\n  ωSup (c.map (f.bind g)) = ωSup (c.map f) >>= ωSup (c.map g) :=\nbegin\n  apply eq_of_forall_ge_iff, intro x,\n  simp only [ωSup_le_iff, roption.bind_le, chain.mem_map_iff, and_imp, preorder_hom.bind_to_fun,\n    exists_imp_distrib],\n  split; intro h''',\n  { intros b hb, apply ωSup_le _ _ _,\n    rintros i y hy, simp only [roption.mem_ωSup] at hb,\n    rcases hb with ⟨j,hb⟩, replace hb := hb.symm,\n    simp only [roption.eq_some_iff, chain.map_to_fun, function.comp_app, pi.monotone_apply_to_fun]\n      at hy hb,\n    replace hb : b ∈ f (c (max i j))   := f.monotone (c.monotone (le_max_right i j)) _ hb,\n    replace hy : y ∈ g (c (max i j)) b := g.monotone (c.monotone (le_max_left i j)) _ _ hy,\n    apply h''' (max i j),\n    simp only [exists_prop, roption.bind_eq_bind, roption.mem_bind_iff, chain.map_to_fun,\n               function.comp_app, preorder_hom.bind_to_fun],\n    exact ⟨_,hb,hy⟩, },\n  { intros i, intros y hy,\n    simp only [exists_prop, roption.bind_eq_bind, roption.mem_bind_iff, chain.map_to_fun,\n               function.comp_app, preorder_hom.bind_to_fun] at hy,\n    rcases hy with ⟨b,hb₀,hb₁⟩,\n    apply h''' b _,\n    { apply le_ωSup (c.map g) _ _ _ hb₁ },\n    { apply le_ωSup (c.map f) i _ hb₀ } },\nend\n\nlemma bind_continuous' {β γ : Type v} (f : α → roption β) (g : α → β → roption γ) :\n  continuous' f → continuous' g →\n  continuous' (λ x, f x >>= g x)\n| ⟨hf,hf'⟩ ⟨hg,hg'⟩ :=\ncontinuous.of_bundled' (preorder_hom.bind ⟨f,hf⟩ ⟨g,hg⟩)\n  (by intro c; rw [ωSup_bind, ← hf', ← hg']; refl)\n\nlemma map_continuous' {β γ : Type v} (f : β → γ) (g : α → roption β)\n  (hg : continuous' g) :\n  continuous' (λ x, f <$> g x) :=\nby simp only [map_eq_bind_pure_comp];\n   apply bind_continuous' _ _ hg;\n   apply const_continuous'\n\nlemma seq_continuous' {β γ : Type v} (f : α → roption (β → γ)) (g : α → roption β)\n  (hf : continuous' f) (hg : continuous' g) :\n  continuous' (λ x, f x <*> g x) :=\nby simp only [seq_eq_bind_map];\n   apply bind_continuous' _ _ hf;\n   apply pi.omega_complete_partial_order.flip₂_continuous'; intro;\n   apply map_continuous' _ _ hg\n\nlemma continuous (F : α →𝒄 β) (C : chain α) : F (ωSup C) = ωSup (C.map F) :=\ncontinuous_hom.cont _ _\n\n/-- Construct a continuous function from a bare function, a continuous function, and a proof that\nthey are equal. -/\n@[simps, reducible]\ndef of_fun (f : α → β) (g : α →𝒄 β) (h : f = g) : α →𝒄 β :=\nby refine {to_fun := f, ..}; subst h; cases g; assumption\n\n/-- Construct a continuous function from a monotone function with a proof of continuity. -/\n@[simps, reducible]\ndef of_mono (f : α →ₘ β) (h : ∀ c : chain α, f (ωSup c) = ωSup (c.map f)) : α →𝒄 β :=\n{ to_fun := f,\n  monotone' := f.monotone,\n  cont := h }\n\n/-- The identity as a continuous function. -/\n@[simps]\ndef id : α →𝒄 α :=\nof_mono preorder_hom.id\n  (by intro; rw [chain.map_id]; refl)\n\n/-- The composition of continuous functions. -/\n@[simps]\ndef comp (f : β →𝒄 γ) (g : α →𝒄 β) : α →𝒄 γ :=\nof_mono (preorder_hom.comp (↑f) (↑g))\n  (by intro; rw [preorder_hom.comp, ← preorder_hom.comp, ← chain.map_comp, ← f.continuous,\n                 ← g.continuous]; refl)\n\n@[ext]\nprotected lemma ext (f g : α →𝒄 β) (h : ∀ x, f x = g x) : f = g :=\nby cases f; cases g; congr; ext; apply h\n\nprotected lemma coe_inj (f g : α →𝒄 β) (h : (f : α → β) = g) : f = g :=\ncontinuous_hom.ext _ _ $ _root_.congr_fun h\n\n@[simp]\nlemma comp_id (f : β →𝒄 γ) : f.comp id = f := by ext; refl\n\n@[simp]\nlemma id_comp (f : β →𝒄 γ) : id.comp f = f := by ext; refl\n\n@[simp]\nlemma comp_assoc (f : γ →𝒄 φ) (g : β →𝒄 γ) (h : α →𝒄 β) : f.comp (g.comp h) = (f.comp g).comp h :=\nby ext; refl\n\n@[simp]\nlemma coe_apply (a : α) (f : α →𝒄 β) : (f : α →ₘ β) a = f a := rfl\n\n/-- `function.const` is a continuous function. -/\ndef const (f : β) : α →𝒄 β :=\nof_mono (preorder_hom.const _ f)\n    begin\n      intro c, apply le_antisymm,\n      { simp only [function.const, preorder_hom.const_to_fun],\n        apply le_ωSup_of_le 0, refl },\n      { apply ωSup_le, simp only [preorder_hom.const_to_fun, chain.map_to_fun, function.comp_app],\n        intros, refl },\n    end\n\n@[simp] theorem const_apply (f : β) (a : α) : const f a = f := rfl\n\ninstance [inhabited β] : inhabited (α →𝒄 β) :=\n⟨ const (default β) ⟩\n\nnamespace prod\n\n/-- The application of continuous functions as a monotone function.\n\n(It would make sense to make it a continuous function, but we are currently constructing a\n`omega_complete_partial_order` instance for `α →𝒄 β`, and we cannot use it as the domain or image\nof a continuous function before we do.) -/\n@[simps]\ndef apply : (α →𝒄 β) × α →ₘ β :=\n{ to_fun := λ f, f.1 f.2,\n  monotone' := λ x y h, by dsimp; transitivity y.fst x.snd; [apply h.1, apply y.1.monotone h.2] }\n\nend prod\n\n/-- The map from continuous functions to monotone functions is itself a monotone function. -/\n@[simps]\ndef to_mono : (α →𝒄 β) →ₘ (α →ₘ β) :=\n{ to_fun := λ f, f,\n  monotone' := λ x y h, h }\n\n/-- When proving that a chain of applications is below a bound `z`, it suffices to consider the\nfunctions and values being selected from the same index in the chains.\n\nThis lemma is more specific than necessary, i.e. `c₀` only needs to be a\nchain of monotone functions, but it is only used with continuous functions. -/\n@[simp]\nlemma forall_forall_merge (c₀ : chain (α →𝒄 β)) (c₁ : chain α) (z : β) :\n  (∀ (i j : ℕ), (c₀ i) (c₁ j) ≤ z) ↔ ∀ (i : ℕ), (c₀ i) (c₁ i) ≤ z :=\nbegin\n  split; introv h,\n  { apply h },\n  { apply le_trans _ (h (max i j)),\n    transitivity c₀ i (c₁ (max i j)),\n    { apply (c₀ i).monotone, apply c₁.monotone, apply le_max_right },\n    { apply c₀.monotone, apply le_max_left } }\nend\n\n@[simp]\nlemma forall_forall_merge' (c₀ : chain (α →𝒄 β)) (c₁ : chain α) (z : β) :\n  (∀ (j i : ℕ), (c₀ i) (c₁ j) ≤ z) ↔ ∀ (i : ℕ), (c₀ i) (c₁ i) ≤ z :=\nby rw [forall_swap,forall_forall_merge]\n\n/-- The `ωSup` operator for continuous functions, which takes the pointwise countable supremum\nof the functions in the `ω`-chain. -/\n@[simps]\nprotected def ωSup (c : chain (α →𝒄 β)) : α →𝒄 β :=\ncontinuous_hom.of_mono (ωSup $ c.map to_mono)\nbegin\n  intro c',\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [ωSup_le_iff, (c _).continuous, chain.map_to_fun, preorder_hom.monotone_apply_to_fun,\n    to_mono_to_fun, coe_apply, preorder_hom.omega_complete_partial_order_ωSup_to_fun,\n    forall_forall_merge, forall_forall_merge', function.comp_app],\nend\n\n@[simps ωSup]\ninstance : omega_complete_partial_order (α →𝒄 β) :=\nomega_complete_partial_order.lift continuous_hom.to_mono continuous_hom.ωSup\n  (λ x y h, h) (λ c, rfl)\n\nlemma ωSup_def (c : chain (α →𝒄 β)) (x : α) : ωSup c x = continuous_hom.ωSup c x := rfl\n\nlemma ωSup_ωSup (c₀ : chain (α →𝒄 β)) (c₁ : chain α) :\n  ωSup c₀ (ωSup c₁) = ωSup (continuous_hom.prod.apply.comp $ c₀.zip c₁) :=\nbegin\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [ωSup_le_iff, (c₀ _).continuous, chain.map_to_fun, to_mono_to_fun, coe_apply,\n    preorder_hom.omega_complete_partial_order_ωSup_to_fun, ωSup_def, forall_forall_merge,\n    chain.zip_to_fun, preorder_hom.prod.map_to_fun, preorder_hom.prod.diag_to_fun, prod.map_mk,\n    preorder_hom.monotone_apply_to_fun, function.comp_app, prod.apply_to_fun,\n    preorder_hom.comp_to_fun, ωSup_to_fun],\nend\n\n/-- A family of continuous functions yields a continuous family of functions. -/\n@[simps]\ndef flip {α : Type*} (f : α → β →𝒄 γ) : β →𝒄 α → γ :=\n{ to_fun := λ x y, f y x,\n  monotone' := λ x y h a, (f a).monotone h,\n  cont := by intro; ext; change f x _ = _; rw [(f x).continuous ]; refl, }\n\n/-- `roption.bind` as a continuous function. -/\n@[simps { rhs_md := reducible }]\nnoncomputable def bind {β γ : Type v}\n  (f : α →𝒄 roption β) (g : α →𝒄 β → roption γ) : α →𝒄 roption γ :=\nof_mono (preorder_hom.bind (↑f) (↑g)) $ λ c, begin\n  rw [preorder_hom.bind, ← preorder_hom.bind, ωSup_bind, ← f.continuous, ← g.continuous],\n  refl\nend\n\n/-- `roption.map` as a continuous function. -/\n@[simps {rhs_md := reducible}]\nnoncomputable def map {β γ : Type v} (f : β → γ) (g : α →𝒄 roption β) : α →𝒄 roption γ :=\nof_fun (λ x, f <$> g x) (bind g (const (pure ∘ f))) $\nby ext; simp only [map_eq_bind_pure_comp, bind_to_fun, preorder_hom.bind_to_fun, const_apply,\n  preorder_hom.const_to_fun, coe_apply]\n\n/-- `roption.seq` as a continuous function. -/\n@[simps {rhs_md := reducible}]\nnoncomputable def seq {β γ : Type v} (f : α →𝒄 roption (β → γ)) (g : α →𝒄 roption β) :\n  α →𝒄 roption γ :=\nof_fun (λ x, f x <*> g x) (bind f $ (flip $ _root_.flip map g))\n  (by ext; simp only [seq_eq_bind_map, flip, roption.bind_eq_bind, map_to_fun, roption.mem_bind_iff,\n                      bind_to_fun, preorder_hom.bind_to_fun, coe_apply, flip_to_fun]; refl)\n\nend continuous_hom\n\nend omega_complete_partial_order\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/order/omega_complete_partial_order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.7090191276365463, "lm_q1q2_score": 0.4815506795902373}}
{"text": "namespace hidden\n\n\n\n\n\n\n\ninductive dm_option (α : Type): Type\n| none : dm_option\n| some (a : α) : dm_option\n\n/-\nHeres an example of a representation in Lean of\na partial function, p, from ℕ to ℕ, such that \np(n) = 0 if n=0 and p(n) is undefined otherwise.  \n-/\n\ndef p : ℕ → dm_option ℕ \n| nat.zero := dm_option.some nat.zero\n| _ := dm_option.none ℕ       -- needs explicit type!\n\n\nend hidden\n", "meta": {"author": "kevinsullivan", "repo": "dm.s20", "sha": "6f90ecb3881c602cdd1e3f12aad458bcdabd250a", "save_path": "github-repos/lean/kevinsullivan-dm.s20", "path": "github-repos/lean/kevinsullivan-dm.s20/dm.s20-6f90ecb3881c602cdd1e3f12aad458bcdabd250a/instructor/types/option/dm_option_preliminary.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4815397372863182}}
{"text": "import hilbert.wr.pt_neg\n\nnamespace clfrags\n    namespace hilbert\n        namespace wr\n            namespace pt_neg\n\n                theorem pt₂_neg {a b c : Prop} (h₁ : neg (pt a b c)) : neg (pt b a c) :=\n                    have h₂ : pt (neg a) b c, from ptn₁ h₁,\n                    have h₃ : pt a (neg b) c, from ptn₃ h₂,\n                    have h₄ : pt (neg b) a c, from pt.pt₂ h₃,\n                    show neg (pt b a c), from ptn₂ h₄\n\n                theorem pt₃_neg {a b c : Prop} (h₁ : neg (pt a b c)) : neg (pt a c b) :=\n                    have h₂ : pt (neg a) b c, from ptn₁ h₁,\n                    have h₃ : pt (neg a) c b, from pt.pt₃ h₂,\n                    show neg (pt a c b), from ptn₂ h₃\n\n                theorem pt₄_neg {a b : Prop} (h₁ : neg a) : neg (pt a b b) :=\n                    have h₂ : pt (neg a) b b, from pt.pt₄ h₁,\n                    show neg (pt a b b), from ptn₂ h₂\n\n                theorem pt₅_neg {a b : Prop} (h₁ : neg (pt a b b)) : neg a :=\n                    have h₂ : pt (neg a) b b, from ptn₁ h₁,\n                    show neg a, from pt.pt₅ h₂\n\n                theorem pt₆_neg {a b c d e : Prop} (h₁ : neg (pt a b (pt c d e))) : neg (pt (pt a b c) d e) :=\n                    have h₂ : pt (neg a) b (pt c d e), from ptn₁ h₁,\n                    have h₃ : pt (pt (neg a) b c) d e, from pt.pt₆ h₂,\n                    have h₄ : pt d e (pt (neg a) b c), from pt.pt₃ (pt.pt₂ h₃),\n                    have h₅ : pt (pt d e (neg a)) b c, from pt.pt₆ h₄,\n                    have h₆ : pt b c (pt d e (neg a)), from pt.pt₃ (pt.pt₂ h₅),\n                    have h₇ : pt b c (pt (neg a) d e), from pt.pt₂_pt (pt.pt₃_pt h₆),\n                    have h₈ : pt (pt (neg a) d e) b c, from pt.pt₂ (pt.pt₃ h₇),\n                    have h₉ : pt (neg a) d (pt e b c), from pt.pt₇ h₈,\n                    have h₁₀ : neg (pt a d (pt e b c)), from ptn₂ h₉,\n                    have h₁₁ : neg (pt d a (pt e b c)), from pt₂_neg h₁₀,\n                    have h₁₂ : pt (neg d) a (pt e b c), from ptn₁ h₁₁,\n                    have h₁₃ : pt (pt (neg d) a e) b c, from pt.pt₆ h₁₂,\n                    have h₁₄ : pt b c (pt (neg d) a e), from pt.pt₃ (pt.pt₂ h₁₃),\n                    have h₁₅ : pt b c (pt a (neg d) e), from pt.pt₂_pt h₁₄,\n                    have h₁₆ : pt (pt b c a) (neg d) e, from pt.pt₆ h₁₅,\n                    have h₁₇ : pt (neg d) e (pt b c a), from pt.pt₃ (pt.pt₂ h₁₆),\n                    have h₁₈ : pt (neg d) e (pt a b c), from pt.pt₂_pt (pt.pt₃_pt h₁₇),\n                    have h₁₉ : neg (pt d e (pt a b c)), from ptn₂ h₁₈,\n                    show neg (pt (pt a b c) d e), from pt₂_neg (pt₃_neg h₁₉)\n\n                theorem pt₇_neg {a b c d e : Prop} (h₁ : neg (pt (pt a b c) d e)) : neg (pt a b (pt c d e))  :=\n                    have h₂ : neg (pt d (pt a b c) e), from pt₂_neg h₁,\n                    have h₃ : neg (pt d e (pt a b c)), from pt₃_neg h₂,\n                    have h₄ : neg (pt (pt d e a) b c), from pt₆_neg h₃,\n                    have h₅ : neg (pt b (pt d e a) c), from pt₂_neg h₄,\n                    have h₆ : neg (pt b c (pt d e a)), from pt₃_neg h₅,\n                    have h₇ : neg (pt (pt b c d) e a), from pt₆_neg h₆,\n                    have h₈ : neg (pt e (pt b c d) a), from pt₂_neg h₇,\n                    have h₉ : neg (pt e a (pt b c d)), from pt₃_neg h₈,\n                    have h₁₀ : neg (pt (pt e a b) c d), from pt₆_neg h₉,\n                    have h₁₁ : neg (pt c (pt e a b) d), from pt₂_neg h₁₀,\n                    have h₁₂ : neg (pt c d (pt e a b)), from pt₃_neg h₁₁,\n                    have h₁₃ : neg (pt (pt c d e) a b), from pt₆_neg h₁₂,\n                    have h₁₄ : neg (pt a (pt c d e) b), from pt₂_neg h₁₃,\n                    show neg (pt a b (pt c d e)), from pt₃_neg h₁₄\n\n                theorem n₁_pt {a b c d : Prop} (h₁ : pt c d a) (h₂ : pt c d (neg a)) : pt c d b :=\n                    have h₃ : pt a c d, from pt.pt₂ (pt.pt₃ h₁),\n                    have h₄ : pt (neg a) c d, from pt.pt₂ (pt.pt₃ h₂),\n                    have h₅ : neg (pt a c d), from ptn₂ h₄,\n                    show pt c d b, from n₁ h₃ h₅\n\n                theorem ptn₁_pt {a b c d e : Prop} (h₁ : pt d e (neg (pt a b c))) : pt d e (pt (neg a) b c) :=\n                    have h₂ : pt (neg (pt a b c)) d e, from pt.pt₂ (pt.pt₃ h₁),\n                    have h₃ : neg (pt (pt a b c) d e), from ptn₂ h₂,\n                    have h₄ : neg (pt a b (pt c d e)), from pt₇_neg h₃,\n                    have h₅ : pt (neg a) b (pt c d e), from ptn₁ h₄,\n                    have h₆ : pt (pt (neg a) b c) d e, from pt.pt₆ h₅,\n                    show pt d e (pt (neg a) b c), from pt.pt₃ (pt.pt₂ h₆)\n\n                theorem ptn₂_pt {a b c d e : Prop} (h₁ : pt d e (pt (neg a) b c))  : pt d e (neg (pt a b c)) :=\n                    have h₂ : pt (pt (neg a) b c) d e, from pt.pt₂ (pt.pt₃ h₁),\n                    have h₃ : pt (neg a) b (pt c d e), from pt.pt₇ h₂,\n                    have h₄ : neg (pt a b (pt c d e)), from ptn₂ h₃,\n                    have h₅ : neg (pt (pt a b c) d e), from pt₆_neg h₄,\n                    have h₆ : pt (neg (pt a b c)) d e, from ptn₁ h₅,\n                    show pt d e (neg (pt a b c)), from pt.pt₃ (pt.pt₂ h₆)\n\n                theorem ptn₃_pt {a b c d e : Prop} (h₁ : pt d e (neg (pt a b c))) : pt d e (pt a (neg b) c) :=\n                    have h₂ : pt (neg (pt a b c)) d e, from pt.pt₂ (pt.pt₃ h₁),\n                    have h₃ : neg (pt (pt a b c) d e), from ptn₂ h₂,\n                    have h₄ : neg (pt a b (pt c d e)), from pt₇_neg h₃,\n                    have h₅ : neg (pt b a (pt c d e)), from pt₂_neg h₄,\n                    have h₆ : pt (neg b) a (pt c d e), from ptn₁ h₅,\n                    have h₇ : pt a (neg b) (pt c d e), from pt.pt₂ h₆,\n                    have h₈ : pt (pt a (neg b) c) d e, from pt.pt₆ h₇,\n                    show pt d e (pt a (neg b) c), from pt.pt₃ (pt.pt₂ h₈)\n\n            end pt_neg\n        end wr\n    end hilbert\nend clfrags\n", "meta": {"author": "greati", "repo": "hilbert-classical-fragments", "sha": "18a21ac6b2e890060eb4ae65752fc0245394d226", "save_path": "github-repos/lean/greati-hilbert-classical-fragments", "path": "github-repos/lean/greati-hilbert-classical-fragments/hilbert-classical-fragments-18a21ac6b2e890060eb4ae65752fc0245394d226/clfrags/src/hilbert/wr/proofs/pt_neg.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4815397372863182}}
{"text": "import category_theory.category.default\nimport category_theory.isomorphism\n\nuniverses v u  -- The order in this declaration matters: v often needs to be explicitly specified while u often can be omitted\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n--rewrite this\n\n/-\n# Category world\n\n## Level 1: Isomorphisms\n\nAn isomorphism `f : X ⟶ Y` is a morphism for which there exists a morphism `g : Y ⟶ X`, such that `f ≫ g = 𝟙 X` and `g ≫ f = 𝟙 Y`.\n-/\n\n\n/- Lemma\nIf $$f : X ⟶ Y$$ and $$g : X ⟶ Y$$ are morphisms such that $$f = g$$, then $$f ≫ h = g ≫ h$$.\n-/\nlemma cancel_left_iso' {X Y Z : C} (f : X ⟶ Y) [is_iso f] {g h : Z ⟶ X} : (g ≫ f = h ≫ f) ↔ g = h :=\nbegin\n    split,\n\n    intro hyp,\n    rw ← category.comp_id g,\n    rw ← category.comp_id h,\n    rw ← is_iso.hom_inv_id f,\n    rw ← category.assoc,\n    rw hyp,\n    rw category.assoc,\n\n    intro hyp,\n    rw hyp,\nend\n\nend category_theory", "meta": {"author": "agusakov", "repo": "category-theory-game", "sha": "652dd7e90ae706643b2a597e2c938403653e167d", "save_path": "github-repos/lean/agusakov-category-theory-game", "path": "github-repos/lean/agusakov-category-theory-game/category-theory-game-652dd7e90ae706643b2a597e2c938403653e167d/src/game/world2/level1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.769080247656264, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4815397372863181}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module algebra.category.BoolRing\n! leanprover-community/mathlib commit 67779f73e572fd1fec2218648b2078d167d16c0a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Category.Ring.Basic\nimport Mathbin.Algebra.Ring.BooleanRing\nimport Mathbin.Order.Category.BoolAlg\n\n/-!\n# The category of Boolean rings\n\nThis file defines `BoolRing`, the category of Boolean rings.\n\n## TODO\n\nFinish the equivalence with `BoolAlg`.\n-/\n\n\nuniverse u\n\nopen CategoryTheory Order\n\n/-- The category of Boolean rings. -/\ndef BoolRing :=\n  Bundled BooleanRing\n#align BoolRing BoolRing\n\nnamespace BoolRing\n\ninstance : CoeSort BoolRing (Type _) :=\n  Bundled.hasCoeToSort\n\ninstance (X : BoolRing) : BooleanRing X :=\n  X.str\n\n/-- Construct a bundled `BoolRing` from a `boolean_ring`. -/\ndef of (α : Type _) [BooleanRing α] : BoolRing :=\n  Bundled.of α\n#align BoolRing.of BoolRing.of\n\n@[simp]\ntheorem coe_of (α : Type _) [BooleanRing α] : ↥(of α) = α :=\n  rfl\n#align BoolRing.coe_of BoolRing.coe_of\n\ninstance : Inhabited BoolRing :=\n  ⟨of PUnit⟩\n\ninstance : BundledHom.ParentProjection @BooleanRing.toCommRing :=\n  ⟨⟩\n\nderiving instance LargeCategory, ConcreteCategory for BoolRing\n\n@[simps]\ninstance hasForgetToCommRing : HasForget₂ BoolRing CommRingCat :=\n  BundledHom.forget₂ _ _\n#align BoolRing.has_forget_to_CommRing BoolRing.hasForgetToCommRing\n\n/-- Constructs an isomorphism of Boolean rings from a ring isomorphism between them. -/\n@[simps]\ndef Iso.mk {α β : BoolRing.{u}} (e : α ≃+* β) : α ≅ β\n    where\n  Hom := e\n  inv := e.symm\n  hom_inv_id' := by\n    ext\n    exact e.symm_apply_apply _\n  inv_hom_id' := by\n    ext\n    exact e.apply_symm_apply _\n#align BoolRing.iso.mk BoolRing.Iso.mk\n\nend BoolRing\n\n/-! ### Equivalence between `BoolAlg` and `BoolRing` -/\n\n\n@[simps]\ninstance BoolRing.hasForgetToBoolAlg : HasForget₂ BoolRing BoolAlg\n    where forget₂ :=\n    { obj := fun X => BoolAlg.of (AsBoolalg X)\n      map := fun X Y => RingHom.asBoolalg }\n#align BoolRing.has_forget_to_BoolAlg BoolRing.hasForgetToBoolAlg\n\n@[simps]\ninstance BoolAlg.hasForgetToBoolRing : HasForget₂ BoolAlg BoolRing\n    where forget₂ :=\n    { obj := fun X => BoolRing.of (AsBoolring X)\n      map := fun X Y => BoundedLatticeHom.asBoolring }\n#align BoolAlg.has_forget_to_BoolRing BoolAlg.hasForgetToBoolRing\n\n/-- The equivalence between Boolean rings and Boolean algebras. This is actually an isomorphism. -/\n@[simps Functor inverse]\ndef boolRingEquivBoolAlg : BoolRing ≌ BoolAlg :=\n  Equivalence.mk (forget₂ BoolRing BoolAlg) (forget₂ BoolAlg BoolRing)\n    (NatIso.ofComponents (fun X => BoolRing.Iso.mk <| (RingEquiv.asBoolringAsBoolalg X).symm)\n      fun X Y f => rfl)\n    (NatIso.ofComponents (fun X => BoolAlg.Iso.mk <| OrderIso.asBoolalgAsBoolring X) fun X Y f =>\n      rfl)\n#align BoolRing_equiv_BoolAlg boolRingEquivBoolAlg\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Category/BoolRing.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4815397306584582}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monoidal.functorial\nimport Mathlib.category_theory.monoidal.functor_category\nimport Mathlib.category_theory.limits.limits\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# `lim : (J ⥤ C) ⥤ C` is lax monoidal when `C` is a monoidal category.\n\nWhen `C` is a monoidal category, the functorial association `F ↦ limit F` is lax monoidal,\ni.e. there are morphisms\n* `lim_lax.ε : (𝟙_ C) → limit (𝟙_ (J ⥤ C))`\n* `lim_lax.μ : limit F ⊗ limit G ⟶ limit (F ⊗ G)`\nsatisfying the laws of a lax monoidal functor.\n-/\n\nnamespace category_theory.limits\n\n\nprotected instance limit_functorial {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] : functorial fun (F : J ⥤ C) => limit F :=\n  functorial.mk (functor.map lim)\n\n@[simp] theorem limit_functorial_map {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] {F : J ⥤ C} {G : J ⥤ C} (α : F ⟶ G) : map (fun (F : J ⥤ C) => limit F) α = functor.map lim α :=\n  rfl\n\nprotected instance limit_lax_monoidal {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] : lax_monoidal fun (F : J ⥤ C) => limit F :=\n  lax_monoidal.mk (limit.lift (functor.obj (functor.const J) 𝟙_) (cone.mk 𝟙_ (nat_trans.mk fun (j : J) => 𝟙)))\n    fun (F G : J ⥤ C) =>\n      limit.lift (F ⊗ G) (cone.mk (limit F ⊗ limit G) (nat_trans.mk fun (j : J) => limit.π F j ⊗ limit.π G j))\n\n/-- The limit functor `F ↦ limit F` bundled as a lax monoidal functor. -/\ndef lim_lax {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] : lax_monoidal_functor (J ⥤ C) C :=\n  lax_monoidal_functor.of fun (F : J ⥤ C) => limit F\n\n@[simp] theorem lim_lax_obj {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] (F : J ⥤ C) : functor.obj (lax_monoidal_functor.to_functor lim_lax) F = limit F :=\n  rfl\n\ntheorem lim_lax_obj' {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] (F : J ⥤ C) : functor.obj (lax_monoidal_functor.to_functor lim_lax) F = functor.obj lim F :=\n  rfl\n\n@[simp] theorem lim_lax_map {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] {F : J ⥤ C} {G : J ⥤ C} (α : F ⟶ G) : functor.map (lax_monoidal_functor.to_functor lim_lax) α = functor.map lim α :=\n  rfl\n\n@[simp] theorem lim_lax_ε {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] : lax_monoidal_functor.ε lim_lax =\n  limit.lift (functor.obj (functor.const J) 𝟙_) (cone.mk 𝟙_ (nat_trans.mk fun (j : J) => 𝟙)) :=\n  rfl\n\n@[simp] theorem lim_lax_μ {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] (F : J ⥤ C) (G : J ⥤ C) : lax_monoidal_functor.μ lim_lax F G =\n  limit.lift (F ⊗ G) (cone.mk (limit F ⊗ limit G) (nat_trans.mk fun (j : J) => limit.π F j ⊗ limit.π G j)) :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.48153972529296535}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.homology.homology\nimport algebra.homology.single\nimport category_theory.preadditive.additive_functor\n\n/-!\n# Homology is an additive functor\n\nWhen `V` is preadditive, `homological_complex V c` is also preadditive,\nand `homology_functor` is additive.\n\nTODO: similarly for `R`-linear.\n-/\n\nuniverses v u\n\nopen_locale classical\nnoncomputable theory\n\nopen category_theory category_theory.limits homological_complex\n\nvariables {ι : Type*}\nvariables {V : Type u} [category.{v} V] [preadditive V]\n\nvariables {c : complex_shape ι} {C D E : homological_complex V c}\nvariables (f g : C ⟶ D) (h k : D ⟶ E) (i : ι)\n\nnamespace homological_complex\n\ninstance : has_zero (C ⟶ D) := ⟨{ f := λ i, 0 }⟩\ninstance : has_add (C ⟶ D) := ⟨λ f g, { f := λ i, f.f i + g.f i, }⟩\ninstance : has_neg (C ⟶ D) := ⟨λ f, { f := λ i, -(f.f i), }⟩\ninstance : has_sub (C ⟶ D) := ⟨λ f g, { f := λ i, f.f i - g.f i, }⟩\n\n@[simp] lemma zero_f_apply (i : ι) : (0 : C ⟶ D).f i = 0 := rfl\n@[simp] lemma add_f_apply (f g : C ⟶ D) (i : ι) : (f + g).f i = f.f i + g.f i := rfl\n@[simp] lemma neg_f_apply (f : C ⟶ D) (i : ι) : (-f).f i = -(f.f i) := rfl\n@[simp] lemma sub_f_apply (f g : C ⟶ D) (i : ι) : (f - g).f i = f.f i - g.f i := rfl\n\n/- TODO(jmc/Scott): the instance below doesn't have the correct defeq for `nsmul` and `zsmul`.\nWe should generalize `function.injective.add_comm_group` and friends.\nFor the `R`-linear version, it will be very convenient to have\na good definition of `nsmul` and `zsmul` that matches `smul`. -/\n\ninstance : add_comm_group (C ⟶ D) :=\nfunction.injective.add_comm_group hom.f\n  homological_complex.hom_f_injective (by tidy) (by tidy) (by tidy) (by tidy)\n\ninstance : preadditive (homological_complex V c) := {}\n\n/-- The `i`-th component of a chain map, as an additive map from chain maps to morphisms. -/\n@[simps]\ndef hom.f_add_monoid_hom {C₁ C₂ : homological_complex V c} (i : ι) :\n  (C₁ ⟶ C₂) →+ (C₁.X i ⟶ C₂.X i) :=\nadd_monoid_hom.mk' (λ f, hom.f f i) (λ _ _, rfl)\n\nend homological_complex\n\nnamespace homological_complex\n\ninstance eval_additive (i : ι) : (eval V c i).additive := {}\n\nvariables [has_zero_object V]\n\ninstance cycles_additive [has_equalizers V] : (cycles_functor V c i).additive := {}\n\nvariables [has_images V] [has_image_maps V]\n\ninstance boundaries_additive : (boundaries_functor V c i).additive := {}\n\nvariables [has_equalizers V] [has_cokernels V]\n\ninstance homology_additive : (homology_functor V c i).additive :=\n{ map_add' := λ C D f g, begin\n    dsimp [homology_functor],\n    ext,\n    simp only [homology.π_map, preadditive.comp_add, ←preadditive.add_comp],\n    congr,\n    ext, simp,\n  end }\n\n\nend homological_complex\n\nnamespace category_theory\n\nvariables {W : Type*} [category W] [preadditive W]\n\n/--\nAn additive functor induces a functor between homological complexes.\nThis is sometimes called the \"prolongation\".\n-/\n@[simps]\ndef functor.map_homological_complex (F : V ⥤ W) [F.additive] (c : complex_shape ι) :\n  homological_complex V c ⥤ homological_complex W c :=\n{ obj := λ C,\n  { X := λ i, F.obj (C.X i),\n    d := λ i j, F.map (C.d i j),\n    shape' := λ i j w, by rw [C.shape _ _ w, F.map_zero],\n    d_comp_d' := λ i j k _ _, by rw [←F.map_comp, C.d_comp_d, F.map_zero], },\n  map := λ C D f,\n  { f := λ i, F.map (f.f i),\n    comm' := λ i j h, by { dsimp,  rw [←F.map_comp, ←F.map_comp, f.comm], }, }, }.\n\ninstance functor.map_homogical_complex_additive\n  (F : V ⥤ W) [F.additive] (c : complex_shape ι) : (F.map_homological_complex c).additive := {}\n\n/--\nA natural transformation between functors induces a natural transformation\nbetween those functors applied to homological complexes.\n-/\n@[simps]\ndef nat_trans.map_homological_complex {F G : V ⥤ W} [F.additive] [G.additive]\n  (α : F ⟶ G) (c : complex_shape ι) : F.map_homological_complex c ⟶ G.map_homological_complex c :=\n{ app := λ C, { f := λ i, α.app _, }, }\n\n@[simp] lemma nat_trans.map_homological_complex_id (c : complex_shape ι) (F : V ⥤ W) [F.additive] :\n  nat_trans.map_homological_complex (𝟙 F) c = 𝟙 (F.map_homological_complex c) :=\nby tidy\n\n@[simp] lemma nat_trans.map_homological_complex_comp (c : complex_shape ι)\n  {F G H : V ⥤ W} [F.additive] [G.additive] [H.additive]\n  (α : F ⟶ G) (β : G ⟶ H):\n  nat_trans.map_homological_complex (α ≫ β) c =\n    nat_trans.map_homological_complex α c ≫ nat_trans.map_homological_complex β c :=\nby tidy\n\n@[simp, reassoc] lemma nat_trans.map_homological_complex_naturality {c : complex_shape ι}\n  {F G : V ⥤ W} [F.additive] [G.additive] (α : F ⟶ G) {C D : homological_complex V c} (f : C ⟶ D) :\n  (F.map_homological_complex c).map f ≫ (nat_trans.map_homological_complex α c).app D =\n    (nat_trans.map_homological_complex α c).app C ≫ (G.map_homological_complex c).map f :=\nby tidy\n\nend category_theory\n\nvariables [has_zero_object V] {W : Type*} [category W] [preadditive W] [has_zero_object W]\n\nnamespace homological_complex\n\n/--\nTurning an object into a complex supported at `j` then applying a functor is\nthe same as applying the functor then forming the complex.\n-/\ndef single_map_homological_complex (F : V ⥤ W) [F.additive] (c : complex_shape ι) (j : ι):\n  single V c j ⋙ F.map_homological_complex _ ≅ F ⋙ single W c j :=\nnat_iso.of_components (λ X,\n{ hom := { f := λ i, if h : i = j then\n    eq_to_hom (by simp [h])\n  else\n    0, },\n  inv := { f := λ i, if h : i = j then\n    eq_to_hom (by simp [h])\n  else\n    0, },\n  hom_inv_id' := begin\n    ext i,\n    dsimp,\n    split_ifs with h,\n    { simp [h] },\n    { rw [zero_comp, if_neg h],\n      exact (zero_of_source_iso_zero _ F.map_zero_object).symm, },\n  end,\n  inv_hom_id' := begin\n    ext i,\n    dsimp,\n    split_ifs with h,\n    { simp [h] },\n    { rw [zero_comp, if_neg h],\n      simp, },\n  end, })\n  (λ X Y f, begin\n    ext i,\n    dsimp,\n    split_ifs with h; simp [h],\n  end).\n\nvariables (F : V ⥤ W) [functor.additive F] (c)\n\n@[simp] lemma single_map_homological_complex_hom_app_self (j : ι) (X : V) :\n  ((single_map_homological_complex F c j).hom.app X).f j = eq_to_hom (by simp) :=\nby simp [single_map_homological_complex]\n@[simp] lemma single_map_homological_complex_hom_app_ne\n  {i j : ι} (h : i ≠ j) (X : V) :\n  ((single_map_homological_complex F c j).hom.app X).f i = 0 :=\nby simp [single_map_homological_complex, h]\n@[simp] lemma single_map_homological_complex_inv_app_self (j : ι) (X : V) :\n  ((single_map_homological_complex F c j).inv.app X).f j = eq_to_hom (by simp) :=\nby simp [single_map_homological_complex]\n@[simp] lemma single_map_homological_complex_inv_app_ne\n  {i j : ι} (h : i ≠ j) (X : V):\n  ((single_map_homological_complex F c j).inv.app X).f i = 0 :=\nby simp [single_map_homological_complex, h]\n\nend homological_complex\n\nnamespace chain_complex\n\n-- TODO: dualize to cochain complexes\n\n/--\nTurning an object into a chain complex supported at zero then applying a functor is\nthe same as applying the functor then forming the complex.\n-/\ndef single₀_map_homological_complex (F : V ⥤ W) [F.additive] :\n  single₀ V ⋙ F.map_homological_complex _ ≅ F ⋙ single₀ W :=\nnat_iso.of_components (λ X,\n{ hom := { f := λ i, match i with\n    | 0 := 𝟙 _\n    | (i+1) := F.map_zero_object.hom\n    end, },\n  inv := { f := λ i, match i with\n    | 0 := 𝟙 _\n    | (i+1) := F.map_zero_object.inv\n    end, },\n  hom_inv_id' := begin\n    ext (_|i),\n    { unfold_aux, simp, },\n    { unfold_aux,\n      dsimp,\n      simp only [comp_f, id_f, zero_comp],\n      exact (zero_of_source_iso_zero _ F.map_zero_object).symm, }\n  end,\n  inv_hom_id' := by { ext (_|i); { unfold_aux, dsimp, simp, }, }, })\n  (λ X Y f, by { ext (_|i); { unfold_aux, dsimp, simp, }, }).\n\n@[simp] \n\nend chain_complex\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/homology/additive.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4814229189879885}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Andrew Yang\n\n! This file was ported from Lean 3 source module category_theory.limits.preserves.shapes.pullbacks\n! leanprover-community/mathlib commit f47581155c818e6361af4e4fda60d27d020c226b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Shapes.Pullbacks\nimport Mathbin.CategoryTheory.Limits.Preserves.Basic\n\n/-!\n# Preserving pullbacks\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nConstructions to relate the notions of preserving pullbacks and reflecting pullbacks to concrete\npullback cones.\n\nIn particular, we show that `pullback_comparison G f g` is an isomorphism iff `G` preserves\nthe pullback of `f` and `g`.\n\nThe dual is also given.\n\n## TODO\n\n* Generalise to wide pullbacks\n\n-/\n\n\nnoncomputable section\n\nuniverse v₁ v₂ u₁ u₂\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits\n\nnamespace CategoryTheory.Limits\n\nsection Pullback\n\nvariable {C : Type u₁} [Category.{v₁} C]\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\nvariable (G : C ⥤ D)\n\nvariable {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {h : W ⟶ X} {k : W ⟶ Y} (comm : h ≫ f = k ≫ g)\n\n/- warning: category_theory.limits.is_limit_map_cone_pullback_cone_equiv -> CategoryTheory.Limits.isLimitMapConePullbackConeEquiv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)), Equiv.{max 1 (succ u4) (succ u2), max 1 (succ u4) (succ u2)} (CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Functor.comp.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G) (CategoryTheory.Functor.mapCone.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G (CategoryTheory.Limits.PullbackCone.mk.{u1, u3} C _inst_1 X Y Z f g W h k comm))) (CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X h) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y k) (CategoryTheory.Limits.isLimitMapConePullbackConeEquiv._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G W X Y Z f g h k comm)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)), Equiv.{max (succ u4) (succ u2), max (succ u4) (succ u2)} (CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Functor.comp.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G) (CategoryTheory.Functor.mapCone.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 G (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) (CategoryTheory.Limits.PullbackCone.mk.{u1, u3} C _inst_1 X Y Z f g W h k comm))) (CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (of_eq_true (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.trans.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) True (congr.{succ u2, 1} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (congrArg.{succ u2, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) ((Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) -> Prop) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z))) (Eq.trans.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W X Z h f) (congrArg.{succ u1, succ u2} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z) comm))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W Y Z k g)) (eq_self.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)))))))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_limit_map_cone_pullback_cone_equiv CategoryTheory.Limits.isLimitMapConePullbackConeEquivₓ'. -/\n/-- The map of a pullback cone is a limit iff the fork consisting of the mapped morphisms is a\nlimit. This essentially lets us commute `pullback_cone.mk` with `functor.map_cone`. -/\ndef isLimitMapConePullbackConeEquiv :\n    IsLimit (G.mapCone (PullbackCone.mk h k comm)) ≃\n      IsLimit\n        (PullbackCone.mk (G.map h) (G.map k) (by simp only [← G.map_comp, comm]) :\n          PullbackCone (G.map f) (G.map g)) :=\n  (IsLimit.postcomposeHomEquiv (diagramIsoCospan.{v₂} _) _).symm.trans <|\n    IsLimit.equivIsoLimit <|\n      Cones.ext (Iso.refl _) <| by\n        rintro (_ | _ | _) <;> dsimp <;> simp only [comp_id, id_comp, G.map_comp]\n#align category_theory.limits.is_limit_map_cone_pullback_cone_equiv CategoryTheory.Limits.isLimitMapConePullbackConeEquiv\n\n/- warning: category_theory.limits.is_limit_pullback_cone_map_of_is_limit -> CategoryTheory.Limits.isLimitPullbackConeMapOfIsLimit is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G], (CategoryTheory.Limits.IsLimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) (CategoryTheory.Limits.PullbackCone.mk.{u1, u3} C _inst_1 X Y Z f g W h k comm)) -> (CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X h) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y k) (CategoryTheory.Limits.isLimitMapConePullbackConeEquiv._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G W X Y Z f g h k comm)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G], (CategoryTheory.Limits.IsLimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) (CategoryTheory.Limits.PullbackCone.mk.{u1, u3} C _inst_1 X Y Z f g W h k comm)) -> ([mdata let_fun:1 (fun (this : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) => CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) this)) (Eq.mpr.{0} (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (id.{0} (Eq.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)))) (Eq.ndrec.{0, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (fun (_a : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) => Eq.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) _a (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)))) (Eq.refl.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Z h f)))) (Eq.mpr.{0} (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) (id.{0} (Eq.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)))) (Eq.ndrec.{0, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (fun (_a : Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) => Eq.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) _a)) (Eq.refl.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y Z k g)))) (Eq.mpr.{0} (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) (id.{0} (Eq.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)))) (Eq.ndrec.{0, succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (fun (_a : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) => Eq.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z _a) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)))) (Eq.refl.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)))) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g) comm)) (Eq.refl.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))))))])\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_limit_pullback_cone_map_of_is_limit CategoryTheory.Limits.isLimitPullbackConeMapOfIsLimitₓ'. -/\n/-- The property of preserving pullbacks expressed in terms of binary fans. -/\ndef isLimitPullbackConeMapOfIsLimit [PreservesLimit (cospan f g) G]\n    (l : IsLimit (PullbackCone.mk h k comm)) : IsLimit (PullbackCone.mk (G.map h) (G.map k) _) :=\n  isLimitMapConePullbackConeEquiv G comm (PreservesLimit.preserves l)\n#align category_theory.limits.is_limit_pullback_cone_map_of_is_limit CategoryTheory.Limits.isLimitPullbackConeMapOfIsLimit\n\n/- warning: category_theory.limits.is_limit_of_is_limit_pullback_cone_map -> CategoryTheory.Limits.isLimitOfIsLimitPullbackConeMap is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) [_inst_3 : CategoryTheory.Limits.ReflectsLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G], (CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X h) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y k) (CategoryTheory.Limits.isLimitMapConePullbackConeEquiv._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G W X Y Z f g h k comm))) -> (CategoryTheory.Limits.IsLimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) (CategoryTheory.Limits.PullbackCone.mk.{u1, u3} C _inst_1 X Y Z f g W h k comm))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) [_inst_3 : CategoryTheory.Limits.ReflectsLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G], (CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) ([mdata let_fun:1 (fun (this : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) => this) (of_eq_true (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.trans.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) True (congr.{succ u2, 1} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (congrArg.{succ u2, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) ((Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) -> Prop) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z))) (Eq.trans.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W X Z h f) (congrArg.{succ u1, succ u2} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z h f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z) comm))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W Y Z k g)) (eq_self.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z k g)))))]))) -> (CategoryTheory.Limits.IsLimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) (CategoryTheory.Limits.PullbackCone.mk.{u1, u3} C _inst_1 X Y Z f g W h k comm))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_limit_of_is_limit_pullback_cone_map CategoryTheory.Limits.isLimitOfIsLimitPullbackConeMapₓ'. -/\n/-- The property of reflecting pullbacks expressed in terms of binary fans. -/\ndef isLimitOfIsLimitPullbackConeMap [ReflectsLimit (cospan f g) G]\n    (l : IsLimit (PullbackCone.mk (G.map h) (G.map k) _)) : IsLimit (PullbackCone.mk h k comm) :=\n  ReflectsLimit.reflects ((isLimitMapConePullbackConeEquiv G comm).symm l)\n#align category_theory.limits.is_limit_of_is_limit_pullback_cone_map CategoryTheory.Limits.isLimitOfIsLimitPullbackConeMap\n\nvariable (f g) [PreservesLimit (cospan f g) G]\n\n/- warning: category_theory.limits.is_limit_of_has_pullback_of_preserves_limit -> CategoryTheory.Limits.isLimitOfHasPullbackOfPreservesLimit is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g], CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.isLimitOfHasPullbackOfPreservesLimit._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G X Y Z f g _inst_4))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g], [mdata let_fun:1 (fun (this : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) => CategoryTheory.Limits.IsLimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.cospan.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (CategoryTheory.Limits.PullbackCone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4)) this)) (of_eq_true (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.trans.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g))) True (congr.{succ u2, 1} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g)) (congrArg.{succ u2, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) ((Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) -> Prop) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g)) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z))) (Eq.trans.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X Z (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4) f)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X Z (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4) f) (congrArg.{succ u1, succ u2} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z) (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X Z (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4) f) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z) (CategoryTheory.Limits.pullback.condition.{u1, u3} C _inst_1 X Y Z f g _inst_4)))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g)) (eq_self.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y Z (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4) g)))))]\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_limit_of_has_pullback_of_preserves_limit CategoryTheory.Limits.isLimitOfHasPullbackOfPreservesLimitₓ'. -/\n/-- If `G` preserves pullbacks and `C` has them, then the pullback cone constructed of the mapped\nmorphisms of the pullback cone is a limit. -/\ndef isLimitOfHasPullbackOfPreservesLimit [HasPullback f g] :\n    IsLimit (PullbackCone.mk (G.map pullback.fst) (G.map pullback.snd) _) :=\n  isLimitPullbackConeMapOfIsLimit G _ (pullbackIsPullback f g)\n#align category_theory.limits.is_limit_of_has_pullback_of_preserves_limit CategoryTheory.Limits.isLimitOfHasPullbackOfPreservesLimit\n\n#print CategoryTheory.Limits.preservesPullbackSymmetry /-\n/-- If `F` preserves the pullback of `f, g`, it also preserves the pullback of `g, f`. -/\ndef preservesPullbackSymmetry : PreservesLimit (cospan g f) G\n    where preserves c hc :=\n    by\n    apply (is_limit.postcompose_hom_equiv (diagramIsoCospan.{v₂} _) _).toFun\n    apply is_limit.of_iso_limit _ (pullback_cone.iso_mk _).symm\n    apply pullback_cone.flip_is_limit\n    apply (is_limit_map_cone_pullback_cone_equiv _ _).toFun\n    · apply (config := { instances := false }) preserves_limit.preserves\n      · dsimp\n        infer_instance\n      apply pullback_cone.flip_is_limit\n      apply is_limit.of_iso_limit _ (pullback_cone.iso_mk _)\n      exact (is_limit.postcompose_hom_equiv (diagramIsoCospan.{v₁} _) _).invFun hc\n    ·\n      exact\n        (c.π.naturality walking_cospan.hom.inr).symm.trans\n          (c.π.naturality walking_cospan.hom.inl : _)\n#align category_theory.limits.preserves_pullback_symmetry CategoryTheory.Limits.preservesPullbackSymmetry\n-/\n\n/- warning: category_theory.limits.has_pullback_of_preserves_pullback -> CategoryTheory.Limits.hasPullback_of_preservesPullback is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g], CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g], CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.has_pullback_of_preserves_pullback CategoryTheory.Limits.hasPullback_of_preservesPullbackₓ'. -/\ntheorem hasPullback_of_preservesPullback [HasPullback f g] : HasPullback (G.map f) (G.map g) :=\n  ⟨⟨⟨_, isLimitPullbackConeMapOfIsLimit G _ (pullbackIsPullback _ _)⟩⟩⟩\n#align category_theory.limits.has_pullback_of_preserves_pullback CategoryTheory.Limits.hasPullback_of_preservesPullback\n\nvariable [HasPullback f g] [HasPullback (G.map f) (G.map g)]\n\n/- warning: category_theory.limits.preserves_pullback.iso -> CategoryTheory.Limits.PreservesPullback.iso is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)], CategoryTheory.Iso.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)], CategoryTheory.Iso.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pullback.iso CategoryTheory.Limits.PreservesPullback.isoₓ'. -/\n/-- If `G` preserves the pullback of `(f,g)`, then the pullback comparison map for `G` at `(f,g)` is\nan isomorphism. -/\ndef PreservesPullback.iso : G.obj (pullback f g) ≅ pullback (G.map f) (G.map g) :=\n  IsLimit.conePointUniqueUpToIso (isLimitOfHasPullbackOfPreservesLimit G f g) (limit.isLimit _)\n#align category_theory.limits.preserves_pullback.iso CategoryTheory.Limits.PreservesPullback.iso\n\n/- warning: category_theory.limits.preserves_pullback.iso_hom_fst -> CategoryTheory.Limits.PreservesPullback.iso_hom_fst is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (CategoryTheory.Limits.pullback.fst.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (CategoryTheory.Limits.pullback.fst.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pullback.iso_hom_fst CategoryTheory.Limits.PreservesPullback.iso_hom_fstₓ'. -/\n@[reassoc.1]\ntheorem PreservesPullback.iso_hom_fst :\n    (PreservesPullback.iso G f g).Hom ≫ pullback.fst = G.map pullback.fst := by\n  simp [preserves_pullback.iso]\n#align category_theory.limits.preserves_pullback.iso_hom_fst CategoryTheory.Limits.PreservesPullback.iso_hom_fst\n\n/- warning: category_theory.limits.preserves_pullback.iso_hom_snd -> CategoryTheory.Limits.PreservesPullback.iso_hom_snd is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (CategoryTheory.Limits.pullback.snd.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (CategoryTheory.Limits.pullback.snd.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pullback.iso_hom_snd CategoryTheory.Limits.PreservesPullback.iso_hom_sndₓ'. -/\n@[reassoc.1]\ntheorem PreservesPullback.iso_hom_snd :\n    (PreservesPullback.iso G f g).Hom ≫ pullback.snd = G.map pullback.snd := by\n  simp [preserves_pullback.iso]\n#align category_theory.limits.preserves_pullback.iso_hom_snd CategoryTheory.Limits.PreservesPullback.iso_hom_snd\n\n/- warning: category_theory.limits.preserves_pullback.iso_inv_fst -> CategoryTheory.Limits.PreservesPullback.iso_inv_fst is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4))) (CategoryTheory.Limits.pullback.fst.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) X (CategoryTheory.Limits.pullback.fst.{u1, u3} C _inst_1 X Y Z f g _inst_4))) (CategoryTheory.Limits.pullback.fst.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pullback.iso_inv_fst CategoryTheory.Limits.PreservesPullback.iso_inv_fstₓ'. -/\n@[simp, reassoc.1]\ntheorem PreservesPullback.iso_inv_fst :\n    (PreservesPullback.iso G f g).inv ≫ G.map pullback.fst = pullback.fst := by\n  simp [preserves_pullback.iso, iso.inv_comp_eq]\n#align category_theory.limits.preserves_pullback.iso_inv_fst CategoryTheory.Limits.PreservesPullback.iso_inv_fst\n\n/- warning: category_theory.limits.preserves_pullback.iso_inv_snd -> CategoryTheory.Limits.PreservesPullback.iso_inv_snd is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4))) (CategoryTheory.Limits.pullback.snd.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z g) _inst_5)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z) [_inst_3 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u3} C _inst_1 X Y Z f g) G] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} C _inst_1 X Y Z f g] [_inst_5 : CategoryTheory.Limits.HasPullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4)) (CategoryTheory.Limits.pullback.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Y Z f g _inst_3 _inst_4 _inst_5)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u3} C _inst_1 X Y Z f g _inst_4) Y (CategoryTheory.Limits.pullback.snd.{u1, u3} C _inst_1 X Y Z f g _inst_4))) (CategoryTheory.Limits.pullback.snd.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z g) _inst_5)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pullback.iso_inv_snd CategoryTheory.Limits.PreservesPullback.iso_inv_sndₓ'. -/\n@[simp, reassoc.1]\ntheorem PreservesPullback.iso_inv_snd :\n    (PreservesPullback.iso G f g).inv ≫ G.map pullback.snd = pullback.snd := by\n  simp [preserves_pullback.iso, iso.inv_comp_eq]\n#align category_theory.limits.preserves_pullback.iso_inv_snd CategoryTheory.Limits.PreservesPullback.iso_inv_snd\n\nend Pullback\n\nsection Pushout\n\nvariable {C : Type u₁} [Category.{v₁} C]\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\nvariable (G : C ⥤ D)\n\nvariable {W X Y Z : C} {h : X ⟶ Z} {k : Y ⟶ Z} {f : W ⟶ X} {g : W ⟶ Y} (comm : f ≫ h = g ≫ k)\n\n/- warning: category_theory.limits.is_colimit_map_cocone_pushout_cocone_equiv -> CategoryTheory.Limits.isColimitMapCoconePushoutCoconeEquiv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)), Equiv.{max 1 (succ u4) (succ u2), max 1 (succ u4) (succ u2)} (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Functor.comp.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G) (CategoryTheory.Functor.mapCocone.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G (CategoryTheory.Limits.PushoutCocone.mk.{u1, u3} C _inst_1 W X Y f g Z h k comm))) (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z h) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z k) (CategoryTheory.Limits.isColimitMapCoconePushoutCoconeEquiv._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G W X Y Z h k f g comm)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)), Equiv.{max (succ u4) (succ u2), max (succ u4) (succ u2)} (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Functor.comp.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G) (CategoryTheory.Functor.mapCocone.{0, u1, u2, 0, u3, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 D _inst_2 G (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) (CategoryTheory.Limits.PushoutCocone.mk.{u1, u3} C _inst_1 W X Y f g Z h k comm))) (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k) (of_eq_true (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) (Eq.trans.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k))) True (congr.{succ u2, 1} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (congrArg.{succ u2, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) ((Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) -> Prop) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z))) (Eq.trans.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W X Z f h) (congrArg.{succ u1, succ u2} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z) comm))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W Y Z g k)) (eq_self.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)))))))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_colimit_map_cocone_pushout_cocone_equiv CategoryTheory.Limits.isColimitMapCoconePushoutCoconeEquivₓ'. -/\n/-- The map of a pushout cocone is a colimit iff the cofork consisting of the mapped morphisms is a\ncolimit. This essentially lets us commute `pushout_cocone.mk` with `functor.map_cocone`. -/\ndef isColimitMapCoconePushoutCoconeEquiv :\n    IsColimit (G.mapCocone (PushoutCocone.mk h k comm)) ≃\n      IsColimit\n        (PushoutCocone.mk (G.map h) (G.map k) (by simp only [← G.map_comp, comm]) :\n          PushoutCocone (G.map f) (G.map g)) :=\n  (IsColimit.precomposeHomEquiv (diagramIsoSpan.{v₂} _).symm _).symm.trans <|\n    IsColimit.equivIsoColimit <|\n      Cocones.ext (Iso.refl _) <| by\n        rintro (_ | _ | _) <;> dsimp <;>\n          simp only [category.comp_id, category.id_comp, ← G.map_comp]\n#align category_theory.limits.is_colimit_map_cocone_pushout_cocone_equiv CategoryTheory.Limits.isColimitMapCoconePushoutCoconeEquiv\n\n/- warning: category_theory.limits.is_colimit_pushout_cocone_map_of_is_colimit -> CategoryTheory.Limits.isColimitPushoutCoconeMapOfIsColimit is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G], (CategoryTheory.Limits.IsColimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) (CategoryTheory.Limits.PushoutCocone.mk.{u1, u3} C _inst_1 W X Y f g Z h k comm)) -> (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z h) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z k) (CategoryTheory.Limits.isColimitMapCoconePushoutCoconeEquiv._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G W X Y Z h k f g comm)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G], (CategoryTheory.Limits.IsColimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) (CategoryTheory.Limits.PushoutCocone.mk.{u1, u3} C _inst_1 W X Y f g Z h k comm)) -> (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k) ([mdata let_fun:1 (fun (this : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) => this) (of_eq_true (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) (Eq.trans.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k))) True (congr.{succ u2, 1} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (congrArg.{succ u2, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) ((Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) -> Prop) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z))) (Eq.trans.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W X Z f h) (congrArg.{succ u1, succ u2} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z) comm))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W Y Z g k)) (eq_self.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)))))])))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_colimit_pushout_cocone_map_of_is_colimit CategoryTheory.Limits.isColimitPushoutCoconeMapOfIsColimitₓ'. -/\n/-- The property of preserving pushouts expressed in terms of binary cofans. -/\ndef isColimitPushoutCoconeMapOfIsColimit [PreservesColimit (span f g) G]\n    (l : IsColimit (PushoutCocone.mk h k comm)) :\n    IsColimit (PushoutCocone.mk (G.map h) (G.map k) _) :=\n  isColimitMapCoconePushoutCoconeEquiv G comm (PreservesColimit.preserves l)\n#align category_theory.limits.is_colimit_pushout_cocone_map_of_is_colimit CategoryTheory.Limits.isColimitPushoutCoconeMapOfIsColimit\n\n/- warning: category_theory.limits.is_colimit_of_is_colimit_pushout_cocone_map -> CategoryTheory.Limits.isColimitOfIsColimitPushoutCoconeMap is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) [_inst_3 : CategoryTheory.Limits.ReflectsColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G], (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X Z h) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y Z k) (CategoryTheory.Limits.isColimitMapCoconePushoutCoconeEquiv._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G W X Y Z h k f g comm))) -> (CategoryTheory.Limits.IsColimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) (CategoryTheory.Limits.PushoutCocone.mk.{u1, u3} C _inst_1 W X Y f g Z h k comm))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} {Z : C} {h : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Z} {k : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y Z} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X} {g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y} (comm : Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) [_inst_3 : CategoryTheory.Limits.ReflectsColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G], (CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k) ([mdata let_fun:1 (fun (this : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) => this) (of_eq_true (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) (Eq.trans.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k))) True (congr.{succ u2, 1} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y Z k)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (congrArg.{succ u2, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) ((Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) -> Prop) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z))) (Eq.trans.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X Z h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W X Z f h) (congrArg.{succ u1, succ u2} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Z) (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X Z f h) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z) comm))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W Y Z g k)) (eq_self.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Z)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Z (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y Z g k)))))]))) -> (CategoryTheory.Limits.IsColimit.{0, u1, 0, u3} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) C _inst_1 (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) (CategoryTheory.Limits.PushoutCocone.mk.{u1, u3} C _inst_1 W X Y f g Z h k comm))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_colimit_of_is_colimit_pushout_cocone_map CategoryTheory.Limits.isColimitOfIsColimitPushoutCoconeMapₓ'. -/\n/-- The property of reflecting pushouts expressed in terms of binary cofans. -/\ndef isColimitOfIsColimitPushoutCoconeMap [ReflectsColimit (span f g) G]\n    (l : IsColimit (PushoutCocone.mk (G.map h) (G.map k) _)) :\n    IsColimit (PushoutCocone.mk h k comm) :=\n  ReflectsColimit.reflects ((isColimitMapCoconePushoutCoconeEquiv G comm).symm l)\n#align category_theory.limits.is_colimit_of_is_colimit_pushout_cocone_map CategoryTheory.Limits.isColimitOfIsColimitPushoutCoconeMap\n\nvariable (f g) [PreservesColimit (span f g) G]\n\n/- warning: category_theory.limits.is_colimit_of_has_pushout_of_preserves_colimit -> CategoryTheory.Limits.isColimitOfHasPushoutOfPreservesColimit is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g], CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.isColimitOfHasPushoutOfPreservesColimit._proof_1.{u3, u4, u1, u2} C _inst_1 D _inst_2 G W X Y f g _inst_4))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g], CategoryTheory.Limits.IsColimit.{0, u2, 0, u4} CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) D _inst_2 (CategoryTheory.Limits.span.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)) (CategoryTheory.Limits.PushoutCocone.mk.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)) ([mdata let_fun:1 (fun (this : Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)))) => this) (of_eq_true (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)))) (Eq.trans.{1} Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)))) True (congr.{succ u2, 1} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) Prop (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4)))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))) (congrArg.{succ u2, succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) ((Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) -> Prop) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)))) (Eq.trans.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) f (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) f (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4)) (congrArg.{succ u1, succ u2} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) f (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.condition.{u1, u3} C _inst_1 W X Y f g _inst_4)))) ((fun (x_0 : C) (x_1 : C) (x_2 : C) (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_0 x_1) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) x_1 x_2) => Eq.symm.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_2 (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) x_0 x_1 x_2 f g)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_2) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_0 x_1 f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) x_1 x_2 g)) ((fun (x_0 : C) (x_1 : C) (x_2 : C) => CategoryTheory.Functor.map_comp.{u1, u2, u3, u4} C _inst_1 D _inst_2 G x_0 x_1 x_2) x_0 x_1 x_2 f g)) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))) (eq_self.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.CategoryStruct.comp.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1) W Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) g (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))))))]))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_colimit_of_has_pushout_of_preserves_colimit CategoryTheory.Limits.isColimitOfHasPushoutOfPreservesColimitₓ'. -/\n/-- If `G` preserves pushouts and `C` has them, then the pushout cocone constructed of the mapped\nmorphisms of the pushout cocone is a colimit. -/\ndef isColimitOfHasPushoutOfPreservesColimit [HasPushout f g] :\n    IsColimit (PushoutCocone.mk (G.map pushout.inl) (G.map pushout.inr) _) :=\n  isColimitPushoutCoconeMapOfIsColimit G _ (pushoutIsPushout f g)\n#align category_theory.limits.is_colimit_of_has_pushout_of_preserves_colimit CategoryTheory.Limits.isColimitOfHasPushoutOfPreservesColimit\n\n#print CategoryTheory.Limits.preservesPushoutSymmetry /-\n/-- If `F` preserves the pushout of `f, g`, it also preserves the pushout of `g, f`. -/\ndef preservesPushoutSymmetry : PreservesColimit (span g f) G\n    where preserves c hc :=\n    by\n    apply (is_colimit.precompose_hom_equiv (diagramIsoSpan.{v₂} _).symm _).toFun\n    apply is_colimit.of_iso_colimit _ (pushout_cocone.iso_mk _).symm\n    apply pushout_cocone.flip_is_colimit\n    apply (is_colimit_map_cocone_pushout_cocone_equiv _ _).toFun\n    · apply (config := { instances := false }) preserves_colimit.preserves\n      · dsimp\n        infer_instance\n      apply pushout_cocone.flip_is_colimit\n      apply is_colimit.of_iso_colimit _ (pushout_cocone.iso_mk _)\n      exact (is_colimit.precompose_hom_equiv (diagramIsoSpan.{v₁} _) _).invFun hc\n    · exact (c.ι.naturality walking_span.hom.snd).trans (c.ι.naturality walking_span.hom.fst).symm\n#align category_theory.limits.preserves_pushout_symmetry CategoryTheory.Limits.preservesPushoutSymmetry\n-/\n\n/- warning: category_theory.limits.has_pushout_of_preserves_pushout -> CategoryTheory.Limits.hasPushout_of_preservesPushout is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g], CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g], CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.has_pushout_of_preserves_pushout CategoryTheory.Limits.hasPushout_of_preservesPushoutₓ'. -/\ntheorem hasPushout_of_preservesPushout [HasPushout f g] : HasPushout (G.map f) (G.map g) :=\n  ⟨⟨⟨_, isColimitPushoutCoconeMapOfIsColimit G _ (pushoutIsPushout _ _)⟩⟩⟩\n#align category_theory.limits.has_pushout_of_preserves_pushout CategoryTheory.Limits.hasPushout_of_preservesPushout\n\nvariable [HasPushout f g] [HasPushout (G.map f) (G.map g)]\n\n/- warning: category_theory.limits.preserves_pushout.iso -> CategoryTheory.Limits.PreservesPushout.iso is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)], CategoryTheory.Iso.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)], CategoryTheory.Iso.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pushout.iso CategoryTheory.Limits.PreservesPushout.isoₓ'. -/\n/-- If `G` preserves the pushout of `(f,g)`, then the pushout comparison map for `G` at `(f,g)` is\nan isomorphism. -/\ndef PreservesPushout.iso : pushout (G.map f) (G.map g) ≅ G.obj (pushout f g) :=\n  IsColimit.coconePointUniqueUpToIso (colimit.isColimit _)\n    (isColimitOfHasPushoutOfPreservesColimit G f g)\n#align category_theory.limits.preserves_pushout.iso CategoryTheory.Limits.PreservesPushout.iso\n\n/- warning: category_theory.limits.preserves_pushout.inl_iso_hom -> CategoryTheory.Limits.PreservesPushout.inl_iso_hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.inl.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.inl.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pushout.inl_iso_hom CategoryTheory.Limits.PreservesPushout.inl_iso_homₓ'. -/\n@[reassoc.1]\ntheorem PreservesPushout.inl_iso_hom :\n    pushout.inl ≫ (PreservesPushout.iso G f g).Hom = G.map pushout.inl :=\n  by\n  delta preserves_pushout.iso\n  simp\n#align category_theory.limits.preserves_pushout.inl_iso_hom CategoryTheory.Limits.PreservesPushout.inl_iso_hom\n\n/- warning: category_theory.limits.preserves_pushout.inr_iso_hom -> CategoryTheory.Limits.PreservesPushout.inr_iso_hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.inr.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.inr.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pushout.inr_iso_hom CategoryTheory.Limits.PreservesPushout.inr_iso_homₓ'. -/\n@[reassoc.1]\ntheorem PreservesPushout.inr_iso_hom :\n    pushout.inr ≫ (PreservesPushout.iso G f g).Hom = G.map pushout.inr :=\n  by\n  delta preserves_pushout.iso\n  simp\n#align category_theory.limits.preserves_pushout.inr_iso_hom CategoryTheory.Limits.PreservesPushout.inr_iso_hom\n\n/- warning: category_theory.limits.preserves_pushout.inl_iso_inv -> CategoryTheory.Limits.PreservesPushout.inl_iso_inv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (CategoryTheory.Limits.pushout.inl.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inl.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (CategoryTheory.Limits.pushout.inl.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pushout.inl_iso_inv CategoryTheory.Limits.PreservesPushout.inl_iso_invₓ'. -/\n@[simp, reassoc.1]\ntheorem PreservesPushout.inl_iso_inv :\n    G.map pushout.inl ≫ (PreservesPushout.iso G f g).inv = pushout.inl := by\n  simp [preserves_pushout.iso, iso.comp_inv_eq]\n#align category_theory.limits.preserves_pushout.inl_iso_inv CategoryTheory.Limits.PreservesPushout.inl_iso_inv\n\n/- warning: category_theory.limits.preserves_pushout.inr_iso_inv -> CategoryTheory.Limits.PreservesPushout.inr_iso_inv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (CategoryTheory.Limits.pushout.inr.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W Y g) _inst_5)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] (G : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) {W : C} {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y) [_inst_3 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u2, u3, u4} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u3} C _inst_1 W X Y f g) G] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} C _inst_1 W X Y f g] [_inst_5 : CategoryTheory.Limits.HasPushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4) (CategoryTheory.Limits.pushout.inr.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Limits.pushout.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u3} C _inst_1 W X Y f g _inst_4)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u2, u3, u4} C _inst_1 D _inst_2 G W X Y f g _inst_3 _inst_4 _inst_5))) (CategoryTheory.Limits.pushout.inr.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) Y) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 G) W Y g) _inst_5)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pushout.inr_iso_inv CategoryTheory.Limits.PreservesPushout.inr_iso_invₓ'. -/\n@[simp, reassoc.1]\ntheorem PreservesPushout.inr_iso_inv :\n    G.map pushout.inr ≫ (PreservesPushout.iso G f g).inv = pushout.inr := by\n  simp [preserves_pushout.iso, iso.comp_inv_eq]\n#align category_theory.limits.preserves_pushout.inr_iso_inv CategoryTheory.Limits.PreservesPushout.inr_iso_inv\n\nend Pushout\n\nsection\n\nvariable {C : Type u₁} [Category.{v₁} C]\n\nvariable {D : Type u₂} [Category.{v₁} D]\n\nvariable (G : C ⥤ D)\n\nsection Pullback\n\nvariable {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n\nvariable [HasPullback f g] [HasPullback (G.map f) (G.map g)]\n\n/- warning: category_theory.limits.preserves_pullback.of_iso_comparison -> CategoryTheory.Limits.PreservesPullback.ofIsoComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) Y Z} [_inst_3 : CategoryTheory.Limits.HasPullback.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y Z g)] [i : CategoryTheory.IsIso.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pullback.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y Z g) _inst_4) (CategoryTheory.Limits.pullbackComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)], CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u2} C _inst_1 X Y Z f g) G\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) Y Z} [_inst_3 : CategoryTheory.Limits.HasPullback.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y Z g)] [i : CategoryTheory.IsIso.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pullback.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y Z g) _inst_4) (CategoryTheory.Limits.pullbackComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)], CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u2} C _inst_1 X Y Z f g) G\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pullback.of_iso_comparison CategoryTheory.Limits.PreservesPullback.ofIsoComparisonₓ'. -/\n/-- If the pullback comparison map for `G` at `(f,g)` is an isomorphism, then `G` preserves the\npullback of `(f,g)`. -/\ndef PreservesPullback.ofIsoComparison [i : IsIso (pullbackComparison G f g)] :\n    PreservesLimit (cospan f g) G :=\n  by\n  apply preserves_limit_of_preserves_limit_cone (pullback_is_pullback f g)\n  apply (is_limit_map_cone_pullback_cone_equiv _ _).symm _\n  apply is_limit.of_point_iso (limit.is_limit (cospan (G.map f) (G.map g)))\n  apply i\n#align category_theory.limits.preserves_pullback.of_iso_comparison CategoryTheory.Limits.PreservesPullback.ofIsoComparison\n\nvariable [PreservesLimit (cospan f g) G]\n\n/- warning: category_theory.limits.preserves_pullback.iso_hom -> CategoryTheory.Limits.PreservesPullback.iso_hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) Y Z} [_inst_3 : CategoryTheory.Limits.HasPullback.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y Z g)] [_inst_5 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u2} C _inst_1 X Y Z f g) G], Eq.{succ u1} (Quiver.Hom.{succ u1, u3} D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pullback.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y Z g) _inst_4)) (CategoryTheory.Iso.hom.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pullback.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pullback.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y Z g) _inst_4) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y Z f g _inst_5 _inst_3 _inst_4)) (CategoryTheory.Limits.pullbackComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) Y Z} [_inst_3 : CategoryTheory.Limits.HasPullback.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPullback.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y Z g)] [_inst_5 : CategoryTheory.Limits.PreservesLimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingCospan (CategoryTheory.Limits.WidePullbackShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.cospan.{u1, u2} C _inst_1 X Y Z f g) G], Eq.{succ u1} (Quiver.Hom.{succ u1, u3} D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pullback.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y Z g) _inst_4)) (CategoryTheory.Iso.hom.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pullback.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pullback.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y Z g) _inst_4) (CategoryTheory.Limits.PreservesPullback.iso.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y Z f g _inst_5 _inst_3 _inst_4)) (CategoryTheory.Limits.pullbackComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pullback.iso_hom CategoryTheory.Limits.PreservesPullback.iso_homₓ'. -/\n@[simp]\ntheorem PreservesPullback.iso_hom : (PreservesPullback.iso G f g).Hom = pullbackComparison G f g :=\n  rfl\n#align category_theory.limits.preserves_pullback.iso_hom CategoryTheory.Limits.PreservesPullback.iso_hom\n\ninstance : IsIso (pullbackComparison G f g) :=\n  by\n  rw [← preserves_pullback.iso_hom]\n  infer_instance\n\nend Pullback\n\nsection Pushout\n\nvariable {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n\nvariable [HasPushout f g] [HasPushout (G.map f) (G.map g)]\n\n/- warning: category_theory.limits.preserves_pushout.of_iso_comparison -> CategoryTheory.Limits.PreservesPushout.ofIsoComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Y} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} [_inst_3 : CategoryTheory.Limits.HasPushout.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z g)] [i : CategoryTheory.IsIso.{u1, u3} D _inst_2 (CategoryTheory.Limits.pushout.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z g) _inst_4) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pushoutComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)], CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u2} C _inst_1 X Y Z f g) G\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Y} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} [_inst_3 : CategoryTheory.Limits.HasPushout.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Y f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z g)] [i : CategoryTheory.IsIso.{u1, u3} D _inst_2 (CategoryTheory.Limits.pushout.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Y f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z g) _inst_4) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.pushoutComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)], CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u2} C _inst_1 X Y Z f g) G\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pushout.of_iso_comparison CategoryTheory.Limits.PreservesPushout.ofIsoComparisonₓ'. -/\n/-- If the pushout comparison map for `G` at `(f,g)` is an isomorphism, then `G` preserves the\npushout of `(f,g)`. -/\ndef PreservesPushout.ofIsoComparison [i : IsIso (pushoutComparison G f g)] :\n    PreservesColimit (span f g) G :=\n  by\n  apply preserves_colimit_of_preserves_colimit_cocone (pushout_is_pushout f g)\n  apply (is_colimit_map_cocone_pushout_cocone_equiv _ _).symm _\n  apply is_colimit.of_point_iso (colimit.is_colimit (span (G.map f) (G.map g)))\n  apply i\n#align category_theory.limits.preserves_pushout.of_iso_comparison CategoryTheory.Limits.PreservesPushout.ofIsoComparison\n\nvariable [PreservesColimit (span f g) G]\n\n/- warning: category_theory.limits.preserves_pushout.iso_hom -> CategoryTheory.Limits.PreservesPushout.iso_hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Y} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} [_inst_3 : CategoryTheory.Limits.HasPushout.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z g)] [_inst_5 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u2} C _inst_1 X Y Z f g) G], Eq.{succ u1} (Quiver.Hom.{succ u1, u3} D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Limits.pushout.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z g) _inst_4) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u2} C _inst_1 X Y Z f g _inst_3))) (CategoryTheory.Iso.hom.{u1, u3} D _inst_2 (CategoryTheory.Limits.pushout.{u1, u3} D _inst_2 (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Y) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G Z) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y f) (CategoryTheory.Functor.map.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Z g) _inst_4) (CategoryTheory.Functor.obj.{u1, u1, u2, u3} C _inst_1 D _inst_2 G (CategoryTheory.Limits.pushout.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y Z f g _inst_5 _inst_3 _inst_4)) (CategoryTheory.Limits.pushoutComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {D : Type.{u3}} [_inst_2 : CategoryTheory.Category.{u1, u3} D] (G : CategoryTheory.Functor.{u1, u1, u2, u3} C _inst_1 D _inst_2) {X : C} {Y : C} {Z : C} {f : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Y} {g : Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) X Z} [_inst_3 : CategoryTheory.Limits.HasPushout.{u1, u2} C _inst_1 X Y Z f g] [_inst_4 : CategoryTheory.Limits.HasPushout.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Y f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z g)] [_inst_5 : CategoryTheory.Limits.PreservesColimit.{0, 0, u1, u1, u2, u3} C _inst_1 D _inst_2 CategoryTheory.Limits.WalkingSpan (CategoryTheory.Limits.WidePushoutShape.category.{0} CategoryTheory.Limits.WalkingPair) (CategoryTheory.Limits.span.{u1, u2} C _inst_1 X Y Z f g) G], Eq.{succ u1} (Quiver.Hom.{succ u1, u3} D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Limits.pushout.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Y f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z g) _inst_4) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u2} C _inst_1 X Y Z f g _inst_3))) (CategoryTheory.Iso.hom.{u1, u3} D _inst_2 (CategoryTheory.Limits.pushout.{u1, u3} D _inst_2 (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Y) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) Z) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Y f) (Prefunctor.map.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) X Z g) _inst_4) (Prefunctor.obj.{succ u1, succ u1, u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, u3} C _inst_1 D _inst_2 G) (CategoryTheory.Limits.pushout.{u1, u2} C _inst_1 X Y Z f g _inst_3)) (CategoryTheory.Limits.PreservesPushout.iso.{u1, u1, u2, u3} C _inst_1 D _inst_2 G X Y Z f g _inst_5 _inst_3 _inst_4)) (CategoryTheory.Limits.pushoutComparison.{u1, u1, u2, u3} C _inst_1 D _inst_2 X Y Z G f g _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.preserves_pushout.iso_hom CategoryTheory.Limits.PreservesPushout.iso_homₓ'. -/\n@[simp]\ntheorem PreservesPushout.iso_hom : (PreservesPushout.iso G f g).Hom = pushoutComparison G f g :=\n  rfl\n#align category_theory.limits.preserves_pushout.iso_hom CategoryTheory.Limits.PreservesPushout.iso_hom\n\ninstance : IsIso (pushoutComparison G f g) :=\n  by\n  rw [← preserves_pushout.iso_hom]\n  infer_instance\n\nend Pushout\n\nend\n\nend CategoryTheory.Limits\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Preserves/Shapes/Pullbacks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4814229042483791}}
{"text": "/-\nCopyright (c) 2018 Sean Leather. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sean Leather, Mario Carneiro\n-/\nimport data.list.sigma\n\n/-!\n# Association Lists\n\nThis file defines association lists. An association list is a list where every element consists of\na key and a value, and no two entries have the same key. The type of the value is allowed to be\ndependent on the type of the key.\n\nThis type dependence is implemented using `sigma`: The elements of the list are of type `sigma β`,\nfor some type index `β`.\n\n## Main definitions\n\nAssociation lists are represented by the `alist` structure. This file defines this structure and\nprovides ways to access, modify, and combine `alist`s.\n\n* `alist.keys` returns a list of keys of the alist.\n* `alist.mem` returns membership in the set of keys.\n* `alist.erase` removes a certain key.\n* `alist.insert` adds a key-value mapping to the list.\n* `alist.union` combines two association lists.\n\n## References\n\n* <https://en.wikipedia.org/wiki/Association_list>\n\n-/\n\nuniverses u v w\nopen list\nvariables {α : Type u} {β : α → Type v}\n\n/-- `alist β` is a key-value map stored as a `list` (i.e. a linked list).\n  It is a wrapper around certain `list` functions with the added constraint\n  that the list have unique keys. -/\nstructure alist (β : α → Type v) : Type (max u v) :=\n(entries : list (sigma β))\n(nodupkeys : entries.nodupkeys)\n\n/-- Given `l : list (sigma β)`, create a term of type `alist β` by removing\nentries with duplicate keys. -/\ndef list.to_alist [decidable_eq α] {β : α → Type v} (l : list (sigma β)) : alist β :=\n{ entries := _,\n  nodupkeys := nodupkeys_erase_dupkeys l }\n\nnamespace alist\n\n@[ext] theorem ext : ∀ {s t : alist β}, s.entries = t.entries → s = t\n| ⟨l₁, h₁⟩ ⟨l₂, h₂⟩ H := by congr'\n\nlemma ext_iff {s t : alist β} : s = t ↔ s.entries = t.entries :=\n⟨congr_arg _, ext⟩\n\ninstance [decidable_eq α] [∀ a, decidable_eq (β a)] : decidable_eq (alist β) :=\nλ xs ys, by rw ext_iff; apply_instance\n\n/-! ### keys -/\n\n/-- The list of keys of an association list. -/\ndef keys (s : alist β) : list α := s.entries.keys\n\ntheorem keys_nodup (s : alist β) : s.keys.nodup := s.nodupkeys\n\n/-! ### mem -/\n\n/-- The predicate `a ∈ s` means that `s` has a value associated to the key `a`. -/\ninstance : has_mem α (alist β) := ⟨λ a s, a ∈ s.keys⟩\n\ntheorem mem_keys {a : α} {s : alist β} : a ∈ s ↔ a ∈ s.keys := iff.rfl\n\ntheorem mem_of_perm {a : α} {s₁ s₂ : alist β} (p : s₁.entries ~ s₂.entries) : a ∈ s₁ ↔ a ∈ s₂ :=\n(p.map sigma.fst).mem_iff\n\n/-! ### empty -/\n\n/-- The empty association list. -/\ninstance : has_emptyc (alist β) := ⟨⟨[], nodupkeys_nil⟩⟩\n\ninstance : inhabited (alist β) := ⟨∅⟩\n\ntheorem not_mem_empty (a : α) : a ∉ (∅ : alist β) :=\nnot_mem_nil a\n\n@[simp] theorem empty_entries : (∅ : alist β).entries = [] := rfl\n\n@[simp] theorem keys_empty : (∅ : alist β).keys = [] := rfl\n\n/-! ### singleton -/\n\n/-- The singleton association list. -/\ndef singleton (a : α) (b : β a) : alist β :=\n⟨[⟨a, b⟩], nodupkeys_singleton _⟩\n\n@[simp] \n\n@[simp] theorem keys_singleton (a : α) (b : β a) : (singleton a b).keys = [a] := rfl\n\n/-! ### lookup -/\n\nsection\n\nvariables [decidable_eq α]\n\n/-- Look up the value associated to a key in an association list. -/\ndef lookup (a : α) (s : alist β) : option (β a) :=\ns.entries.lookup a\n\n@[simp] theorem lookup_empty (a) : lookup a (∅ : alist β) = none :=\nrfl\n\ntheorem lookup_is_some {a : α} {s : alist β} :\n  (s.lookup a).is_some ↔ a ∈ s := lookup_is_some\n\ntheorem lookup_eq_none {a : α} {s : alist β} :\n  lookup a s = none ↔ a ∉ s :=\nlookup_eq_none\n\ntheorem perm_lookup {a : α} {s₁ s₂ : alist β} (p : s₁.entries ~ s₂.entries) :\n  s₁.lookup a = s₂.lookup a :=\nperm_lookup _ s₁.nodupkeys s₂.nodupkeys p\n\ninstance (a : α) (s : alist β) : decidable (a ∈ s) :=\ndecidable_of_iff _ lookup_is_some\n\n/-! ### replace -/\n\n/-- Replace a key with a given value in an association list.\n  If the key is not present it does nothing. -/\ndef replace (a : α) (b : β a) (s : alist β) : alist β :=\n⟨kreplace a b s.entries, (kreplace_nodupkeys a b).2 s.nodupkeys⟩\n\n@[simp] theorem keys_replace (a : α) (b : β a) (s : alist β) :\n  (replace a b s).keys = s.keys :=\nkeys_kreplace _ _ _\n\n@[simp] theorem mem_replace {a a' : α} {b : β a} {s : alist β} :\n  a' ∈ replace a b s ↔ a' ∈ s :=\nby rw [mem_keys, keys_replace, ←mem_keys]\n\ntheorem perm_replace {a : α} {b : β a} {s₁ s₂ : alist β} :\n  s₁.entries ~ s₂.entries → (replace a b s₁).entries ~ (replace a b s₂).entries :=\nperm.kreplace s₁.nodupkeys\n\nend\n\n/-- Fold a function over the key-value pairs in the map. -/\ndef foldl {δ : Type w} (f : δ → Π a, β a → δ) (d : δ) (m : alist β) : δ :=\nm.entries.foldl (λ r a, f r a.1 a.2) d\n\n/-! ### erase -/\n\nsection\n\nvariables [decidable_eq α]\n\n/-- Erase a key from the map. If the key is not present, do nothing. -/\ndef erase (a : α) (s : alist β) : alist β :=\n⟨kerase a s.entries, kerase_nodupkeys _ s.nodupkeys⟩\n\n@[simp] theorem keys_erase (a : α) (s : alist β) :\n  (erase a s).keys = s.keys.erase a :=\nby simp only [erase, keys, keys_kerase]\n\n@[simp] theorem mem_erase {a a' : α} {s : alist β} : a' ∈ erase a s ↔ a' ≠ a ∧ a' ∈ s :=\nby rw [mem_keys, keys_erase, mem_erase_iff_of_nodup s.keys_nodup, ←mem_keys]\n\ntheorem perm_erase {a : α} {s₁ s₂ : alist β} :\n  s₁.entries ~ s₂.entries → (erase a s₁).entries ~ (erase a s₂).entries :=\nperm.kerase s₁.nodupkeys\n\n@[simp] theorem lookup_erase (a) (s : alist β) : lookup a (erase a s) = none :=\nlookup_kerase a s.nodupkeys\n\n@[simp] theorem lookup_erase_ne {a a'} {s : alist β} (h : a ≠ a') :\n  lookup a (erase a' s) = lookup a s :=\nlookup_kerase_ne h\n\ntheorem erase_erase (a a' : α) (s : alist β) :\n  (s.erase a).erase a' = (s.erase a').erase a :=\next $ kerase_kerase\n\n/-! ### insert -/\n\n/-- Insert a key-value pair into an association list and erase any existing pair\n  with the same key. -/\ndef insert (a : α) (b : β a) (s : alist β) : alist β :=\n⟨kinsert a b s.entries, kinsert_nodupkeys a b s.nodupkeys⟩\n\n@[simp] theorem insert_entries {a} {b : β a} {s : alist β} :\n  (insert a b s).entries = sigma.mk a b :: kerase a s.entries :=\nrfl\n\ntheorem insert_entries_of_neg {a} {b : β a} {s : alist β} (h : a ∉ s) :\n  (insert a b s).entries = ⟨a, b⟩ :: s.entries :=\nby rw [insert_entries, kerase_of_not_mem_keys h]\n\n@[simp] theorem mem_insert {a a'} {b' : β a'} (s : alist β) :\n  a ∈ insert a' b' s ↔ a = a' ∨ a ∈ s :=\nmem_keys_kinsert\n\n@[simp] theorem keys_insert {a} {b : β a} (s : alist β) :\n  (insert a b s).keys = a :: s.keys.erase a :=\nby simp [insert, keys, keys_kerase]\n\ntheorem perm_insert {a} {b : β a} {s₁ s₂ : alist β} (p : s₁.entries ~ s₂.entries) :\n  (insert a b s₁).entries ~ (insert a b s₂).entries :=\nby simp only [insert_entries]; exact p.kinsert s₁.nodupkeys\n\n@[simp] theorem lookup_insert {a} {b : β a} (s : alist β) : lookup a (insert a b s) = some b :=\nby simp only [lookup, insert, lookup_kinsert]\n\n@[simp] theorem lookup_insert_ne {a a'} {b' : β a'} {s : alist β} (h : a ≠ a') :\n  lookup a (insert a' b' s) = lookup a s :=\nlookup_kinsert_ne h\n\n@[simp] theorem lookup_to_alist {a} (s : list (sigma β)) : lookup a s.to_alist = s.lookup a :=\nby rw [list.to_alist,lookup,lookup_erase_dupkeys]\n\n@[simp] theorem insert_insert {a} {b b' : β a} (s : alist β) :\n  (s.insert a b).insert a b' = s.insert a b' :=\nby ext : 1; simp only [alist.insert_entries, list.kerase_cons_eq];\n   constructor_matching* [_ ∧ _]; refl\n\ntheorem insert_insert_of_ne {a a'} {b : β a} {b' : β a'} (s : alist β) (h : a ≠ a') :\n  ((s.insert a b).insert a' b').entries ~ ((s.insert a' b').insert a b).entries :=\nby simp only [insert_entries]; rw [kerase_cons_ne,kerase_cons_ne,kerase_comm];\n   [apply perm.swap, exact h, exact h.symm]\n\n@[simp] lemma insert_singleton_eq {a : α} {b b' : β a} :\n  insert a b (singleton a b') = singleton a b :=\next $ by simp only [alist.insert_entries, list.kerase_cons_eq, and_self, alist.singleton_entries,\n  heq_iff_eq, eq_self_iff_true]\n\n@[simp] theorem entries_to_alist (xs : list (sigma β)) :\n  (list.to_alist xs).entries = erase_dupkeys xs := rfl\n\ntheorem to_alist_cons (a : α) (b : β a) (xs : list (sigma β)) :\n  list.to_alist (⟨a,b⟩ :: xs) = insert a b xs.to_alist := rfl\n\n/-! ### extract -/\n\n/-- Erase a key from the map, and return the corresponding value, if found. -/\ndef extract (a : α) (s : alist β) : option (β a) × alist β :=\nhave (kextract a s.entries).2.nodupkeys,\nby rw [kextract_eq_lookup_kerase]; exact kerase_nodupkeys _ s.nodupkeys,\nmatch kextract a s.entries, this with\n| (b, l), h := (b, ⟨l, h⟩)\nend\n\n@[simp] theorem extract_eq_lookup_erase (a : α) (s : alist β) :\n  extract a s = (lookup a s, erase a s) :=\nby simp [extract]; split; refl\n\n/-! ### union -/\n\n/-- `s₁ ∪ s₂` is the key-based union of two association lists. It is\nleft-biased: if there exists an `a ∈ s₁`, `lookup a (s₁ ∪ s₂) = lookup a s₁`.\n-/\ndef union (s₁ s₂ : alist β) : alist β :=\n⟨kunion s₁.entries s₂.entries, kunion_nodupkeys s₁.nodupkeys s₂.nodupkeys⟩\n\ninstance : has_union (alist β) := ⟨union⟩\n\n@[simp] theorem union_entries {s₁ s₂ : alist β} :\n  (s₁ ∪ s₂).entries = kunion s₁.entries s₂.entries :=\nrfl\n\n@[simp] theorem empty_union {s : alist β} : (∅ : alist β) ∪ s = s :=\next rfl\n\n@[simp] theorem union_empty {s : alist β} : s ∪ (∅ : alist β) = s :=\next $ by simp\n\n@[simp] theorem mem_union {a} {s₁ s₂ : alist β} :\n  a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂ :=\nmem_keys_kunion\n\ntheorem perm_union {s₁ s₂ s₃ s₄ : alist β}\n  (p₁₂ : s₁.entries ~ s₂.entries) (p₃₄ : s₃.entries ~ s₄.entries) :\n  (s₁ ∪ s₃).entries ~ (s₂ ∪ s₄).entries :=\nby simp [p₁₂.kunion s₃.nodupkeys p₃₄]\n\ntheorem union_erase (a : α) (s₁ s₂ : alist β) : erase a (s₁ ∪ s₂) = erase a s₁ ∪ erase a s₂ :=\next kunion_kerase.symm\n\n@[simp] theorem lookup_union_left {a} {s₁ s₂ : alist β} :\n  a ∈ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₁ :=\nlookup_kunion_left\n\n@[simp] theorem lookup_union_right {a} {s₁ s₂ : alist β} :\n  a ∉ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₂ :=\nlookup_kunion_right\n\n@[simp] theorem mem_lookup_union {a} {b : β a} {s₁ s₂ : alist β} :\n  b ∈ lookup a (s₁ ∪ s₂) ↔ b ∈ lookup a s₁ ∨ a ∉ s₁ ∧ b ∈ lookup a s₂ :=\nmem_lookup_kunion\n\ntheorem mem_lookup_union_middle {a} {b : β a} {s₁ s₂ s₃ : alist β} :\n  b ∈ lookup a (s₁ ∪ s₃) → a ∉ s₂ → b ∈ lookup a (s₁ ∪ s₂ ∪ s₃) :=\nmem_lookup_kunion_middle\n\ntheorem insert_union {a} {b : β a} {s₁ s₂ : alist β} :\n  insert a b (s₁ ∪ s₂) = insert a b s₁ ∪ s₂ :=\nby ext; simp\n\ntheorem union_assoc {s₁ s₂ s₃ : alist β} : ((s₁ ∪ s₂) ∪ s₃).entries ~ (s₁ ∪ (s₂ ∪ s₃)).entries :=\nlookup_ext (alist.nodupkeys _) (alist.nodupkeys _)\n(by simp [decidable.not_or_iff_and_not,or_assoc,and_or_distrib_left,and_assoc])\n\nend\n\n/-! ### disjoint -/\n\n/-- Two associative lists are disjoint if they have no common keys. -/\ndef disjoint (s₁ s₂ : alist β) : Prop :=\n∀ k ∈ s₁.keys, ¬ k ∈ s₂.keys\n\nvariables [decidable_eq α]\n\ntheorem union_comm_of_disjoint {s₁ s₂ : alist β} (h : disjoint s₁ s₂) :\n  (s₁ ∪ s₂).entries ~ (s₂ ∪ s₁).entries :=\nlookup_ext (alist.nodupkeys _) (alist.nodupkeys _)\n(begin\n   intros, simp,\n   split; intro h',\n   cases h',\n   { right, refine ⟨_,h'⟩,\n     apply h, rw [keys,← list.lookup_is_some,h'], exact rfl },\n   { left, rw h'.2 },\n   cases h',\n   { right, refine ⟨_,h'⟩, intro h'',\n     apply h _ h'', rw [keys,← list.lookup_is_some,h'], exact rfl },\n   { left, rw h'.2 },\n end)\n\nend alist\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/list/alist.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160666, "lm_q2_score": 0.7826624840223698, "lm_q1q2_score": 0.4814061888901972}}
{"text": "import algebra.category.Module.adjunctions\nimport group_theory.free_abelian_group_finsupp\nimport algebra.category.Group.adjunctions\nimport algebra.category.Group.filtered_colimits\nimport algebra.category.Group.biproducts\nimport algebra.category.Group.abelian\nimport algebra.category.Group.Z_Module_equivalence\nimport category_theory.limits.preserves.shapes.products\nimport category_theory.limits.preserves.filtered\nimport category_theory.limits.shapes.terminal\nimport linear_algebra.free_module.pid\nimport for_mathlib.AddCommGroup.epi\nimport algebra.group.ulift\n\nopen category_theory\n\nuniverses v u\n\nnamespace AddCommGroup\n\nnoncomputable theory\n\n@[simps]\ndef free' : Type u ⥤ AddCommGroup.{u} :=\n{ obj := λ X, AddCommGroup.of $ X →₀ ℤ,\n  map := λ X Y f, finsupp.map_domain.add_monoid_hom f,\n  map_id' := begin\n    intros X, ext, dsimp, simp,\n  end,\n  map_comp' := begin\n    intros X Y Z f g, ext, dsimp, simp,\n  end } .\n\n@[simps]\ndef of_iso {A B : Type u} [add_comm_group A] [add_comm_group B]\n  (e : A ≃+ B) : of A ≅ of B :=\n{ hom := e.to_add_monoid_hom,\n  inv := e.symm.to_add_monoid_hom,\n  hom_inv_id' := begin\n    ext, dsimp, simp,\n  end,\n  inv_hom_id' := begin\n    ext, dsimp, simp,\n  end } .\n\n@[simps]\ndef free_iso_free' : free.{u} ≅ free'.{u} :=\ncategory_theory.nat_iso.of_components\n(λ X, of_iso (free_abelian_group.equiv_finsupp X))\nbegin\n  intros X Y f, ext, dsimp, simp,\nend\n\ndef adj' : free'.{u} ⊣ forget AddCommGroup.{u} :=\nAddCommGroup.adj.of_nat_iso_left $ free_iso_free'.{u}\n\nend AddCommGroup\n\ndef types.pt {α : Type u} (a : α) : ⊤_ _ ⟶ α :=\nλ x, a\n\ndef types.punit_iso : (punit : Type u) ≅ ⊤_ _ :=\n{ hom := limits.terminal.from _,\n  inv := types.pt punit.star }\n\nnamespace AddCommGroup\n\ndef tunit : AddCommGroup.{u} :=\n  AddCommGroup.free'.obj (⊤_ _)\n\ndef tunit.lift {A : AddCommGroup.{u}} (e : ⊤_ _ ⟶ (forget _).obj A) :\n  tunit ⟶ A :=\n(AddCommGroup.adj'.hom_equiv _ _).symm e\n\n-- Do we really not have this?!\ndef _root_.finsupp.punit_add_equiv (M : Type*) [add_monoid M] :\n  ((punit : Type u) →₀ M) ≃+ M :=\n{ to_fun := λ f, f punit.star,\n  inv_fun := λ m, finsupp.single punit.star m,\n  left_inv := λ x, by { ext, dsimp, simp },\n  right_inv := λ x, by { dsimp, simp },\n  map_add' := λ f g, by simp }\n\n-- Do we really not have this?!\ndef add_equiv_of_iso (A B : AddCommGroup.{u}) (e : A ≅ B) :\n  A ≃+ B :=\n{ to_fun := e.hom,\n  inv_fun := e.inv,\n  left_inv := λ x, by simp,\n  right_inv := λ x, by simp,\n  map_add' := λ x y, e.hom.map_add _ _ }\n\ndef tunit_add_equiv : tunit.{u} ≃+ ℤ :=\nadd_equiv.trans (add_equiv_of_iso _ _ $ AddCommGroup.free'.map_iso\n  types.punit_iso.symm) (finsupp.punit_add_equiv ℤ)\n\ndef tunit.gen : tunit.{u} :=\nAddCommGroup.adj'.unit.app _ $\n  (limits.terminal.from (punit : Type u) : punit → ⊤_ (Type u)) punit.star\n\nopen_locale classical\n\ndef coproduct_cocone_of_basis {ι : Type v} {A : AddCommGroup.{u}} (𝓑 : basis ι ℤ A) :\n  limits.cofan (λ i : ι, tunit.{u}) :=\nlimits.cofan.mk A (λ i, AddCommGroup.of_hom\n  ((zmultiples_add_hom A.α (𝓑 i)).comp tunit_add_equiv.to_add_monoid_hom))\n\ndef coproduct_cocone_of_basis_is_colimit {ι : Type v} {A : AddCommGroup.{u}}\n  (𝓑 : basis ι ℤ A) : limits.is_colimit (coproduct_cocone_of_basis 𝓑) :=\n{ desc := λ s, AddCommGroup.of_hom\n    ((finsupp.total ι s.X.α ℤ (λ i, s.ι.app ⟨i⟩ (tunit_add_equiv.symm 1))).comp\n      𝓑.repr.to_linear_map).to_add_monoid_hom,\n  fac' := begin\n    rintros s ⟨j⟩,\n    apply finsupp.add_hom_ext,\n    intros x y,\n    dsimp [coproduct_cocone_of_basis],\n    simp [← map_zsmul],\n  end,\n  uniq' := begin\n    intros s m e,\n    apply (add_monoid_hom_lequiv_int ℤ).injective,\n    swap, { apply_instance },\n    apply 𝓑.ext,\n    intro i,\n    convert concrete_category.congr_hom (e ⟨i⟩) (tunit_add_equiv.symm 1) using 1,\n   { dsimp [coproduct_cocone_of_basis], simp },\n    { dsimp, simp }\n  end }\n.\n-- set_option pp.universes true\n-- Of course this is true without the fintype assumption...\ndef iso_of_basis {ι : Type v} [limits.has_coproduct (λ (i : ι), tunit.{u})]\n  {A : AddCommGroup.{u}} (𝓑 : basis ι ℤ A) :\n  (∐ (λ i : ι, tunit.{u})) ≅ A :=\nlimits.is_colimit.cocone_point_unique_up_to_iso (limits.coproduct_is_coproduct _)\n  (coproduct_cocone_of_basis_is_colimit 𝓑)\n-- begin\n--   -- This is very messy...\n--   let e : (∐ (λ i : ι, tunit.{u})) ≅ (⨁ (λ i, tunit.{u})) :=\n--     (limits.colimit.is_colimit _).cocone_point_unique_up_to_iso\n--       (limits.biproduct.is_bilimit _).is_colimit,\n--   refine e ≪≫ _,\n--   refine biproduct_iso_pi _ ≪≫ _,\n--   let e : A ≃+ ulift.{u} (ι →₀ ℤ) := 𝓑.repr.to_add_equiv.trans add_equiv.ulift.symm,\n--   refine AddCommGroup.of_iso _ ≪≫ (AddCommGroup.of_iso e).symm ≪≫\n--     ⟨add_monoid_hom.id _, add_monoid_hom.id _, by { ext, refl }, by { ext, refl }⟩,\n--   refine add_equiv.trans _ add_equiv.ulift.symm,\n--   let q : tunit.{u} ≃+ ℤ := tunit_add_equiv,\n--   let e : (ι →₀ ℤ) ≃+ (ι → ℤ),\n--   { fconstructor,\n--     exact finsupp.equiv_fun_on_fintype,\n--     exact finsupp.equiv_fun_on_fintype.symm,\n--     exact finsupp.equiv_fun_on_fintype.left_inverse_symm,\n--     exact finsupp.equiv_fun_on_fintype.right_inverse_symm,\n--     intros x y, refl },\n--   refine add_equiv.trans _ e.symm,\n--   fconstructor,\n--   { intros f i, exact q (f i) },\n--   { intros f i, exact q.symm (f i) },\n--   { intros f, ext, dsimp, simp },\n--   { intros f, ext, dsimp, simp },\n--   { intros f g, ext i, simp, },\n-- end\n\n@[derive partial_order]\ndef index_cat (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] : Type u :=\n{ H : add_subgroup A // H.fg } -- Is this the condition we want?\n\ninstance nonempty_index_cat (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  nonempty A.index_cat := ⟨⟨⊥, ∅, by simp⟩⟩\n\ninstance semilattice_sup_index_cat\n  (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  semilattice_sup A.index_cat :=\n{ sup := λ I J, ⟨I.1 ⊔ J.1, begin\n    obtain ⟨S,hS⟩ := I.2,\n    obtain ⟨T,hT⟩ := J.2,\n    rw [← hS, ← hT],\n    use S ∪ T,\n    simp only [finset.coe_union, add_subgroup.closure_union],\n  end⟩,\n  le_sup_left := λ I J, @le_sup_left (add_subgroup A) _ _ _,\n  le_sup_right := λ I J, @le_sup_right (add_subgroup A) _ _ _,\n  sup_le := λ I J K h1 h2, @sup_le (add_subgroup A) _ _ _ _ h1 h2,\n  ..(infer_instance : partial_order _) }\n\ndef diagram (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  A.index_cat ⥤ AddCommGroup.{u} :=\n{ obj := λ I, AddCommGroup.of I.1,\n  map := λ I J h, add_subgroup.inclusion h.le }\n\ndef cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  limits.cocone A.diagram :=\n{ X := A,\n  ι := { app := λ I, I.1.subtype } }\n\ndef is_colimit_cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  limits.is_colimit A.cocone :=\n{ desc := λ S,\n  { to_fun := λ a, S.ι.app ⟨add_subgroup.closure {a}, {a}, by simp⟩\n      ⟨a, add_subgroup.subset_closure rfl⟩,\n    map_zero' := add_monoid_hom.map_zero _,\n    map_add' := λ x y, begin\n      let I : A.index_cat := ⟨add_subgroup.closure {x}, {x}, by simp⟩,\n      let J : A.index_cat := ⟨add_subgroup.closure {y}, {y}, by simp⟩,\n      let K : A.index_cat := ⟨add_subgroup.closure {x + y}, {x + y}, by simp⟩,\n      let IJ : A.index_cat := ⟨add_subgroup.closure {x,y}, {x,y}, by simp⟩,\n      let iI : I ⟶ IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iJ : J ⟶ IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iK : K ⟶ IJ := hom_of_le ((add_subgroup.closure_le _).2 _),\n      swap,\n      { rintro a (rfl : a = _), change x + y ∈ IJ.1, apply IJ.1.add_mem,\n        { apply add_subgroup.subset_closure, simp },\n        { apply add_subgroup.subset_closure, simp } },\n      rw [← S.w iI, ← S.w iJ, ← S.w iK, comp_apply, comp_apply, comp_apply,\n        ← add_monoid_hom.map_add],\n      refl,\n    end },\n  fac' := begin\n    rintros S J, ext ⟨x,hx⟩,\n    let I : A.index_cat := ⟨add_subgroup.closure {x}, {x}, by simp⟩,\n    let e : I ⟶ J := hom_of_le ((add_subgroup.closure_le _).2 _),\n    { rw comp_apply, dsimp [cocone], rw ← S.w e, refl },\n    rintros x (rfl : x = _), exact hx,\n  end,\n  uniq' := begin\n    intros S m hm, ext x, dsimp [cocone] at x ⊢,\n    let I : A.index_cat := ⟨add_subgroup.closure {x}, {x}, by simp⟩,\n    specialize hm I,\n    let y : I.1 := ⟨x, add_subgroup.subset_closure rfl⟩,\n    apply_fun (λ e, e y) at hm, exact hm,\n  end }\n\ndef colimit_comparison (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  limits.colimit A.diagram ≅ A :=\n(limits.colimit.is_colimit A.diagram).cocone_point_unique_up_to_iso\n  A.is_colimit_cocone\n\nlemma exists_basis_of_index (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A]\n  (I : A.index_cat) : ∃ (ι : Type v) [fintype ι]\n  (𝓑 : basis ι ℤ (AddCommGroup.of I.1)), true :=\nbegin\n  obtain ⟨S,hS⟩ := I.2,\n  let e : S → I.1 := λ s, ⟨s,_⟩,\n  swap, { rw ← hS, apply add_subgroup.subset_closure, exact s.2 },\n  haveI : no_zero_smul_divisors ℤ I.1,\n  { constructor, rintros c ⟨x, hx⟩ h, apply_fun (λ e, e.val) at h,\n    dsimp at h,\n    cases no_zero_smul_divisors.eq_zero_or_eq_zero_of_smul_eq_zero h,\n    left, assumption,\n    right, ext, assumption },\n  obtain ⟨n,B⟩ := @module.free_of_finite_type_torsion_free S ℤ _ _ _ I.1 _ _ _ e _ _,\n  { use [ulift (fin n), infer_instance],\n    refine ⟨_, trivial⟩,\n    apply B.reindex,\n    exact equiv.ulift.symm },\n  { apply le_antisymm, { intros x hx, trivial },\n    rintros ⟨x,hx⟩ -,\n    let J := (submodule.span ℤ (set.range e)).to_add_subgroup,\n    change _ ∈ J,\n    have hJ : J = (J.map I.1.subtype).comap I.1.subtype, -- is this not a lemma?!\n    { apply le_antisymm,\n      { exact add_subgroup.le_comap_map I.val.subtype J },\n      { intros t ht,\n        simpa using ht } },\n    rw [hJ, add_subgroup.mem_comap], clear hJ,\n    dsimp [J],\n    convert hx,\n    rw [← hS, submodule.span_int_eq_add_subgroup_closure, add_monoid_hom.map_closure], congr' 1,\n    ext t,\n    split,\n    { rintros ⟨t,⟨t,rfl⟩,rfl⟩, exact t.2 },\n    { intros ht, refine ⟨⟨t, _⟩, ⟨⟨t, ht⟩, rfl⟩, rfl⟩ } },\nend\n.\n\nlemma exists_sigma_iso_of_index (A : AddCommGroup.{u})\n  [no_zero_smul_divisors ℤ A]\n  (I : A.index_cat) : ∃ (ι : Type v) [fintype ι]\n  (e : by exactI (∐ (λ i : ι, tunit.{u})) ≅ AddCommGroup.of I.1), true :=\nbegin\n  obtain ⟨ι,hι,𝓑,-⟩ := exists_basis_of_index.{v} A I,\n  resetI,\n  exact ⟨ι, hι, iso_of_basis 𝓑, trivial⟩,\nend\n\n@[priority 100]\ninstance {C J : Type*} [fintype J] [category C] [limits.has_zero_morphisms C]\n  [limits.has_finite_biproducts C] : limits.has_biproducts_of_shape J C :=\n⟨λ F, begin\n  have : F = (F ∘ (fintype.equiv_fin J).inv_fun) ∘ (fintype.equiv_fin J).to_fun,\n  { ext, dsimp, rw equiv.symm_apply_apply },\n  rw this,\n  exact ⟨⟨⟨_, (limits.bicone.whisker_is_bilimit_iff _ (fintype.equiv_fin J)).symm\n  (limits.biproduct.is_bilimit $ F ∘ (fintype.equiv_fin J).inv_fun)⟩⟩⟩\nend⟩\n\nlemma exists_biprod_iso_of_index\n  (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A]\n  (I : A.index_cat) : ∃ (ι : Type v) [fintype ι]\n  (e : by exactI (⨁ (λ i : ι, tunit.{u})) ≅ AddCommGroup.of I.1), true :=\nbegin\n  obtain ⟨ι,hι,e,-⟩ := exists_sigma_iso_of_index A I,\n  resetI, use [ι, hι],\n  use (limits.biproduct.is_bilimit _).is_colimit.cocone_point_unique_up_to_iso\n      (limits.colimit.is_colimit _) ≪≫ e,\nend\n\nuniverses u'\n\n\nlemma is_iso_of_preserves {𝓐 : Type u'} [category.{u} 𝓐] [preadditive 𝓐]\n  (F G : AddCommGroup ⥤ 𝓐)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (η : F ⟶ G)\n  [hη : is_iso (η.app tunit)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors ℤ A] :\n  is_iso (η.app A) :=\nbegin\n  let T := (limits.cocones.precompose (whisker_left A.diagram η)).obj\n    (G.map_cocone A.cocone),\n  let S := F.map_cocone A.cocone,\n  let hS : limits.is_colimit S :=\n    limits.is_colimit_of_preserves F A.is_colimit_cocone,\n  have : η.app A = hS.desc T,\n  { apply hS.hom_ext, intros j, rw hS.fac,\n    dsimp, apply η.naturality },\n  rw this, clear this,\n  suffices : ∀ I : A.index_cat, is_iso (η.app (A.diagram.obj I)),\n  { resetI,\n    haveI : is_iso (whisker_left A.diagram η),\n    { apply_with nat_iso.is_iso_of_is_iso_app { instances := ff },\n      intros I, exact this I },\n    let hT : limits.is_colimit T :=\n      (limits.is_colimit.precompose_hom_equiv (as_iso (whisker_left A.diagram η))\n      (G.map_cocone A.cocone)).symm (limits.is_colimit_of_preserves G A.is_colimit_cocone),\n    use hT.desc S,\n    split,\n    { apply hS.hom_ext,\n      intros j,\n      erw [hS.fac_assoc, hT.fac, category.comp_id] },\n    { apply hT.hom_ext,\n      intros j,\n      erw [hT.fac_assoc, hS.fac, category.comp_id] }\n  }, --^ general colimit nonsense..., but I can't find applicable lemmas :-(\n  intros I,\n  obtain ⟨ι : Type,hι,e,-⟩ := A.exists_biprod_iso_of_index.{0} I,\n  -- now use the fact that the functors are additive and that there exists some iso with a biproduct\n  resetI,\n  let eF : F.obj (⨁ λ (i : ι), tunit.{u}) ≅ ⨁ λ (i : ι), F.obj tunit :=\n    (limits.is_bilimit_of_preserves F\n    (limits.biproduct.is_bilimit (λ i : ι, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (λ i : ι, F.obj tunit)).is_colimit,\n  let eG : G.obj (⨁ λ (i : ι), tunit.{u}) ≅ ⨁ λ (i : ι), G.obj tunit :=\n    (limits.is_bilimit_of_preserves G\n    (limits.biproduct.is_bilimit (λ i : ι, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (λ i : ι, G.obj tunit)).is_colimit,\n  have : η.app (A.diagram.obj I) =\n    F.map e.inv ≫ eF.hom ≫ limits.biproduct.map (λ i, η.app _) ≫ eG.inv ≫ G.map e.hom,\n  { rw [← functor.map_iso_inv, iso.eq_inv_comp, ← iso.inv_comp_eq],\n    apply limits.biproduct.hom_ext', intros i,\n    simp only [functor.map_iso_hom, nat_trans.naturality,\n      limits.biproduct.ι_map_assoc, category.assoc],\n    erw [limits.biproduct.ι_desc_assoc, limits.biproduct.ι_desc_assoc],\n    dsimp, rw η.naturality_assoc },\n  rw this,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  apply_instance,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  apply_instance,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  swap,\n  apply_instance,\n  use limits.biproduct.desc\n      (λ i, inv (η.app _) ≫ limits.biproduct.ι _ i),\n  split,\n  { ext, simp },\n  { ext, simp },\nend\n\ndef is_tensor_unit (A : AddCommGroup.{u}) : Prop :=\n∃ a : A, ∀ (B : AddCommGroup.{u}), function.bijective\n  (λ f : A ⟶ B, (f : A → B) a)\n\ndef is_tensor_unit.gen {A : AddCommGroup.{u}} (h : A.is_tensor_unit) :\n  A := h.some\n\ndef is_tensor_unit.as_hom {A B : AddCommGroup.{u}} (h : A.is_tensor_unit)\n  (b : B) : A ⟶ B :=\n((h.some_spec B).2 b).some\n\n@[simp]\nlemma is_tensor_unit.eval_as_hom {A B : AddCommGroup.{u}} (h : A.is_tensor_unit)\n  (b : B) : h.as_hom b h.gen = b :=\n((h.some_spec B).2 b).some_spec\n\nlemma is_tensor_unit.ext {A B : AddCommGroup.{u}} (h : A.is_tensor_unit)\n  (f g : A ⟶ B) (hh : f h.gen = g h.gen) : f = g :=\n(h.some_spec B).1 hh\n\ndef is_tensor_unit.iso {A B : AddCommGroup.{u}} (hA : A.is_tensor_unit)\n  (hB : B.is_tensor_unit) : A ≅ B :=\n{ hom := hA.as_hom hB.gen,\n  inv := hB.as_hom hA.gen,\n  hom_inv_id' := begin\n    apply hA.ext,\n    simp,\n  end,\n  inv_hom_id' := begin\n    apply hB.ext,\n    simp,\n  end }\n\nlemma is_tensor_unit_tunit : tunit.{u}.is_tensor_unit :=\nbegin\n  use tunit.gen,\n  intros B,\n  split,\n  { intros f g h,\n    dsimp [tunit.gen] at h,\n    change (adj'.unit.app _ ≫ (forget _).map f) _ =\n      (adj'.unit.app _ ≫ (forget _).map g) _ at h,\n    apply_fun adj'.hom_equiv _ _,\n    simp only [adjunction.hom_equiv_unit],\n    ext t,\n    let e := limits.terminal.from (punit : Type u),\n    suffices : t = e punit.star,\n    { rw this, exact h },\n    apply_fun types.punit_iso.inv,\n    { simp },\n    intros i j h, apply_fun types.punit_iso.hom at h,\n    simpa using h },\n  { intros t,\n    use tunit.lift (types.pt t),\n    dsimp only [tunit.lift, types.pt, tunit.gen],\n    simp only [adjunction.hom_equiv_counit],\n    change (adj'.unit.app _ ≫\n      (forget _).map (free'.map (λ (x : ⊤_ Type u), t) ≫ adj'.counit.app B)) _ = _,\n    simp only [functor.map_comp, adjunction.unit_naturality_assoc],\n    erw adj'.right_triangle_components, refl }\nend\n\nlemma is_iso_of_preserves_of_is_tensor_unit {𝓐 : Type u'} [category.{u} 𝓐] [preadditive 𝓐]\n  (F G : AddCommGroup ⥤ 𝓐)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (η : F ⟶ G)\n  (U : AddCommGroup)\n  (hU : U.is_tensor_unit)\n  [hη : is_iso (η.app U)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors ℤ A] :\n  is_iso (η.app A) :=\nbegin\n  suffices : is_iso (η.app tunit),\n  { resetI, apply is_iso_of_preserves },\n  let e : tunit ≅ U := is_tensor_unit_tunit.iso hU,\n  suffices : η.app tunit = F.map e.hom ≫ η.app U ≫ G.map e.inv,\n  { rw this, apply is_iso.comp_is_iso, },\n  rw [← η.naturality, ← F.map_comp_assoc, e.hom_inv_id, F.map_id, category.id_comp],\nend\n\nend AddCommGroup\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/AddCommGroup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.48140618577205085}}
{"text": "import data.real.basic tactic.ring tactic.tidy\n\n/- Definitions -/\n\ndefinition double (n : ℕ) : ℕ := n + n\n\n#check double\n\n#check double ∘ double\n\ndefinition quadruple : ℕ → ℕ := double ∘ double\n\ndefinition FLT : Prop :=\n∀ n > 2, ∀ x y z, x^n + y^n = z^n → (x = 0 ∨ y = 0)\n\ntheorem Wiles : FLT :=\nbegin\n  unfold FLT,\n  intros,\n  sorry\nend\n\n--- --- --- --- --- --- --- --- --- --- --- --- --- ---\n\nlemma transitive_imply (P Q R : Prop)\n(P_imp_Q : P → Q)\n(Q_imp_R : Q → R) :\n  P → R :=\nbegin\n  intro P_is_true,\n  apply Q_imp_R,\n  apply P_imp_Q,\n  assumption,\nend\n\nlemma transitive_imply' (P Q R : Prop)\n(P_imp_Q : P → Q)\n(Q_imp_R : Q → R) :\n  P → R := Q_imp_R ∘ P_imp_Q", "meta": {"author": "jcommelin", "repo": "oberharmersbach2019", "sha": "d2cdf780a10baa8502a9b0cae01c7efa318649a6", "save_path": "github-repos/lean/jcommelin-oberharmersbach2019", "path": "github-repos/lean/jcommelin-oberharmersbach2019/oberharmersbach2019-d2cdf780a10baa8502a9b0cae01c7efa318649a6/src/page03.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.615087848460224, "lm_q1q2_score": 0.4814061740134151}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Jens Wagemaker, Aaron Anderson\n-/\n\nimport algebra.big_operators.associated\nimport algebra.gcd_monoid.basic\nimport data.finsupp.multiset\nimport ring_theory.noetherian\nimport ring_theory.multiplicity\n\n/-!\n\n# Unique factorization\n\n## Main Definitions\n* `wf_dvd_monoid` holds for `monoid`s for which a strict divisibility relation is\n  well-founded.\n* `unique_factorization_monoid` holds for `wf_dvd_monoid`s where\n  `irreducible` is equivalent to `prime`\n\n## To do\n* set up the complete lattice structure on `factor_set`.\n\n-/\n\nvariables {α : Type*}\nlocal infix ` ~ᵤ ` : 50 := associated\n\n/-- Well-foundedness of the strict version of |, which is equivalent to the descending chain\ncondition on divisibility and to the ascending chain condition on\nprincipal ideals in an integral domain.\n  -/\nclass wf_dvd_monoid (α : Type*) [comm_monoid_with_zero α] : Prop :=\n(well_founded_dvd_not_unit : well_founded (@dvd_not_unit α _))\n\nexport wf_dvd_monoid (well_founded_dvd_not_unit)\n\n@[priority 100]  -- see Note [lower instance priority]\ninstance is_noetherian_ring.wf_dvd_monoid [comm_ring α] [is_domain α] [is_noetherian_ring α] :\n  wf_dvd_monoid α :=\n⟨by { convert inv_image.wf (λ a, ideal.span ({a} : set α)) (well_founded_submodule_gt _ _),\n      ext,\n      exact ideal.span_singleton_lt_span_singleton.symm }⟩\n\nnamespace wf_dvd_monoid\n\nvariables [comm_monoid_with_zero α]\nopen associates nat\n\ntheorem of_wf_dvd_monoid_associates (h : wf_dvd_monoid (associates α)): wf_dvd_monoid α :=\n⟨begin\n  haveI := h,\n  refine (surjective.well_founded_iff mk_surjective _).2 well_founded_dvd_not_unit,\n  intros, rw mk_dvd_not_unit_mk_iff\nend⟩\n\nvariables [wf_dvd_monoid α]\n\ninstance wf_dvd_monoid_associates : wf_dvd_monoid (associates α) :=\n⟨begin\n  refine (surjective.well_founded_iff mk_surjective _).1 well_founded_dvd_not_unit,\n  intros, rw mk_dvd_not_unit_mk_iff\nend⟩\n\ntheorem well_founded_associates : well_founded ((<) : associates α → associates α → Prop) :=\nsubrelation.wf (λ x y, dvd_not_unit_of_lt) well_founded_dvd_not_unit\n\nlocal attribute [elab_as_eliminator] well_founded.fix\n\nlemma exists_irreducible_factor {a : α} (ha : ¬ is_unit a) (ha0 : a ≠ 0) :\n  ∃ i, irreducible i ∧ i ∣ a :=\nlet ⟨b, hs, hr⟩ := well_founded_dvd_not_unit.has_min {b | b ∣ a ∧ ¬ is_unit b} ⟨a, dvd_rfl, ha⟩ in\n⟨b, ⟨hs.2, λ c d he, let h := dvd_trans ⟨d, he⟩ hs.1 in or_iff_not_imp_left.2 $\n  λ hc, of_not_not $ λ hd, hr c ⟨h, hc⟩ ⟨ne_zero_of_dvd_ne_zero ha0 h, d, hd, he⟩⟩, hs.1⟩\n\n@[elab_as_eliminator] lemma induction_on_irreducible {P : α → Prop} (a : α)\n  (h0 : P 0) (hu : ∀ u : α, is_unit u → P u)\n  (hi : ∀ a i : α, a ≠ 0 → irreducible i → P a → P (i * a)) :\n  P a :=\nby haveI := classical.dec; exact\nwell_founded_dvd_not_unit.fix\n  (λ a ih, if ha0 : a = 0 then ha0.substr h0\n    else if hau : is_unit a then hu a hau\n    else let ⟨i, hii, b, hb⟩ := exists_irreducible_factor hau ha0,\n      hb0 : b ≠ 0 := ne_zero_of_dvd_ne_zero ha0 ⟨i, mul_comm i b ▸ hb⟩ in\n      hb.symm ▸ hi b i hb0 hii $ ih b ⟨hb0, i, hii.1, mul_comm i b ▸ hb⟩)\n  a\n\nlemma exists_factors (a : α) : a ≠ 0 →\n  ∃ f : multiset α, (∀ b ∈ f, irreducible b) ∧ associated f.prod a :=\ninduction_on_irreducible a\n  (λ h, (h rfl).elim)\n  (λ u hu _, ⟨0, λ _ h, h.elim, hu.unit, one_mul _⟩)\n  (λ a i ha0 hi ih _,\n    let ⟨s, hs⟩ := ih ha0 in\n    ⟨i ::ₘ s, λ b H, (multiset.mem_cons.1 H).elim (λ h, h.symm ▸ hi) (hs.1 b),\n      by { rw s.prod_cons i, exact hs.2.mul_left i }⟩)\n\nlemma not_unit_iff_exists_factors_eq (a : α) (hn0 : a ≠ 0) :\n  ¬ is_unit a ↔ ∃ f : multiset α, (∀ b ∈ f, irreducible b) ∧ f.prod = a ∧ f ≠ ∅ :=\n⟨λ hnu, begin\n  obtain ⟨f, hi, u, rfl⟩ := exists_factors a hn0,\n  obtain ⟨b, h⟩ := multiset.exists_mem_of_ne_zero (λ h : f = 0, hnu $ by simp [h]),\n  classical, refine ⟨(f.erase b).cons (b * u), λ a ha, _, _, multiset.cons_ne_zero⟩,\n  { obtain (rfl|ha) := multiset.mem_cons.1 ha,\n    exacts [associated.irreducible ⟨u,rfl⟩ (hi b h), hi a (multiset.mem_of_mem_erase ha)] },\n  { rw [multiset.prod_cons, mul_comm b, mul_assoc, multiset.prod_erase h, mul_comm] },\nend,\nλ ⟨f, hi, he, hne⟩, let ⟨b, h⟩ := multiset.exists_mem_of_ne_zero hne in\n  not_is_unit_of_not_is_unit_dvd (hi b h).not_unit $ he ▸ multiset.dvd_prod h⟩\n\nend wf_dvd_monoid\n\ntheorem wf_dvd_monoid.of_well_founded_associates [cancel_comm_monoid_with_zero α]\n  (h : well_founded ((<) : associates α → associates α → Prop)) : wf_dvd_monoid α :=\nwf_dvd_monoid.of_wf_dvd_monoid_associates\n  ⟨by { convert h, ext, exact associates.dvd_not_unit_iff_lt }⟩\n\ntheorem wf_dvd_monoid.iff_well_founded_associates [cancel_comm_monoid_with_zero α] :\n  wf_dvd_monoid α ↔ well_founded ((<) : associates α → associates α → Prop) :=\n⟨by apply wf_dvd_monoid.well_founded_associates, wf_dvd_monoid.of_well_founded_associates⟩\nsection prio\nset_option default_priority 100 -- see Note [default priority]\n/-- unique factorization monoids.\n\nThese are defined as `cancel_comm_monoid_with_zero`s with well-founded strict divisibility\nrelations, but this is equivalent to more familiar definitions:\n\nEach element (except zero) is uniquely represented as a multiset of irreducible factors.\nUniqueness is only up to associated elements.\n\nEach element (except zero) is non-uniquely represented as a multiset\nof prime factors.\n\nTo define a UFD using the definition in terms of multisets\nof irreducible factors, use the definition `of_exists_unique_irreducible_factors`\n\nTo define a UFD using the definition in terms of multisets\nof prime factors, use the definition `of_exists_prime_factors`\n\n-/\nclass unique_factorization_monoid (α : Type*) [cancel_comm_monoid_with_zero α]\n  extends wf_dvd_monoid α : Prop :=\n(irreducible_iff_prime : ∀ {a : α}, irreducible a ↔ prime a)\n\n/-- Can't be an instance because it would cause a loop `ufm → wf_dvd_monoid → ufm → ...`. -/\n@[reducible] lemma ufm_of_gcd_of_wf_dvd_monoid [cancel_comm_monoid_with_zero α]\n  [wf_dvd_monoid α] [gcd_monoid α] : unique_factorization_monoid α :=\n{ irreducible_iff_prime := λ _, gcd_monoid.irreducible_iff_prime\n  .. ‹wf_dvd_monoid α› }\n\ninstance associates.ufm [cancel_comm_monoid_with_zero α]\n  [unique_factorization_monoid α] : unique_factorization_monoid (associates α) :=\n{ irreducible_iff_prime := by { rw ← associates.irreducible_iff_prime_iff,\n    apply unique_factorization_monoid.irreducible_iff_prime, }\n  .. (wf_dvd_monoid.wf_dvd_monoid_associates : wf_dvd_monoid (associates α)) }\n\nend prio\n\nnamespace unique_factorization_monoid\nvariables [cancel_comm_monoid_with_zero α] [unique_factorization_monoid α]\n\ntheorem exists_prime_factors (a : α) : a ≠ 0 →\n  ∃ f : multiset α, (∀b ∈ f, prime b) ∧ f.prod ~ᵤ a :=\nby { simp_rw ← unique_factorization_monoid.irreducible_iff_prime,\n     apply wf_dvd_monoid.exists_factors a }\n\n@[elab_as_eliminator] lemma induction_on_prime {P : α → Prop}\n  (a : α) (h₁ : P 0) (h₂ : ∀ x : α, is_unit x → P x)\n  (h₃ : ∀ a p : α, a ≠ 0 → prime p → P a → P (p * a)) : P a :=\nbegin\n  simp_rw ← unique_factorization_monoid.irreducible_iff_prime at h₃,\n  exact wf_dvd_monoid.induction_on_irreducible a h₁ h₂ h₃,\nend\n\nlemma factors_unique : ∀{f g : multiset α},\n  (∀x∈f, irreducible x) → (∀x∈g, irreducible x) → f.prod ~ᵤ g.prod →\n  multiset.rel associated f g :=\nby haveI := classical.dec_eq α; exact\nλ f, multiset.induction_on f\n  (λ g _ hg h,\n    multiset.rel_zero_left.2 $\n      multiset.eq_zero_of_forall_not_mem (λ x hx,\n        have is_unit g.prod, by simpa [associated_one_iff_is_unit] using h.symm,\n        (hg x hx).not_unit (is_unit_iff_dvd_one.2 ((multiset.dvd_prod hx).trans\n          (is_unit_iff_dvd_one.1 this)))))\n  (λ p f ih g hf hg hfg,\n    let ⟨b, hbg, hb⟩ := exists_associated_mem_of_dvd_prod\n      (irreducible_iff_prime.1 (hf p (by simp)))\n      (λ q hq, irreducible_iff_prime.1 (hg _ hq)) $\n        hfg.dvd_iff_dvd_right.1\n          (show p ∣ (p ::ₘ f).prod, by simp) in\n    begin\n      rw ← multiset.cons_erase hbg,\n      exact multiset.rel.cons hb (ih (λ q hq, hf _ (by simp [hq]))\n        (λ q (hq : q ∈ g.erase b), hg q (multiset.mem_of_mem_erase hq))\n        (associated.of_mul_left\n          (by rwa [← multiset.prod_cons, ← multiset.prod_cons, multiset.cons_erase hbg]) hb\n        (hf p (by simp)).ne_zero))\n    end)\n\nend unique_factorization_monoid\n\nlemma prime_factors_unique [cancel_comm_monoid_with_zero α] : ∀ {f g : multiset α},\n  (∀ x ∈ f, prime x) → (∀ x ∈ g, prime x) → f.prod ~ᵤ g.prod →\n  multiset.rel associated f g :=\nby haveI := classical.dec_eq α; exact\nλ f, multiset.induction_on f\n  (λ g _ hg h,\n    multiset.rel_zero_left.2 $\n    multiset.eq_zero_of_forall_not_mem $ λ x hx,\n    have is_unit g.prod, by simpa [associated_one_iff_is_unit] using h.symm,\n    (hg x hx).not_unit $ is_unit_iff_dvd_one.2 $\n    (multiset.dvd_prod hx).trans (is_unit_iff_dvd_one.1 this))\n  (λ p f ih g hf hg hfg,\n    let ⟨b, hbg, hb⟩ := exists_associated_mem_of_dvd_prod\n      (hf p (by simp)) (λ q hq, hg _ hq) $\n        hfg.dvd_iff_dvd_right.1\n          (show p ∣ (p ::ₘ f).prod, by simp) in\n    begin\n      rw ← multiset.cons_erase hbg,\n      exact multiset.rel.cons hb (ih (λ q hq, hf _ (by simp [hq]))\n        (λ q (hq : q ∈ g.erase b), hg q (multiset.mem_of_mem_erase hq))\n        (associated.of_mul_left\n          (by rwa [← multiset.prod_cons, ← multiset.prod_cons, multiset.cons_erase hbg]) hb\n        (hf p (by simp)).ne_zero)),\n    end)\n\n/-- If an irreducible has a prime factorization,\n  then it is an associate of one of its prime factors. -/\nlemma prime_factors_irreducible [cancel_comm_monoid_with_zero α] {a : α} {f : multiset α}\n  (ha : irreducible a) (pfa : (∀ b ∈ f, prime b) ∧ f.prod ~ᵤ a) :\n  ∃ p, a ~ᵤ p ∧ f = {p} :=\nbegin\n  haveI := classical.dec_eq α,\n  refine multiset.induction_on f (λ h, (ha.not_unit\n    (associated_one_iff_is_unit.1 (associated.symm h))).elim) _ pfa.2 pfa.1,\n  rintros p s _ ⟨u, hu⟩ hs,\n  use p,\n  have hs0 : s = 0,\n  { by_contra hs0,\n    obtain ⟨q, hq⟩ := multiset.exists_mem_of_ne_zero hs0,\n    apply (hs q (by simp [hq])).2.1,\n    refine (ha.is_unit_or_is_unit (_ : _ = ((p * ↑u) * (s.erase q).prod) * _)).resolve_left _,\n    { rw [mul_right_comm _ _ q, mul_assoc, ← multiset.prod_cons, multiset.cons_erase hq, ← hu,\n        mul_comm, mul_comm p _, mul_assoc],\n      simp, },\n    apply mt is_unit_of_mul_is_unit_left (mt is_unit_of_mul_is_unit_left _),\n    apply (hs p (multiset.mem_cons_self _ _)).2.1 },\n  simp only [mul_one, multiset.prod_cons, multiset.prod_zero, hs0] at *,\n  exact ⟨associated.symm ⟨u, hu⟩, rfl⟩,\nend\n\nsection exists_prime_factors\n\nvariables [cancel_comm_monoid_with_zero α]\nvariables (pf : ∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, prime b) ∧ f.prod ~ᵤ a)\n\ninclude pf\n\nlemma wf_dvd_monoid.of_exists_prime_factors : wf_dvd_monoid α :=\n⟨begin\n  classical,\n  refine rel_hom_class.well_founded\n    (rel_hom.mk _ _ : (dvd_not_unit : α → α → Prop) →r ((<) : with_top ℕ → with_top ℕ → Prop))\n    (with_top.well_founded_lt nat.lt_wf),\n  { intro a,\n    by_cases h : a = 0, { exact ⊤ },\n    exact (classical.some (pf a h)).card },\n\n  rintros a b ⟨ane0, ⟨c, hc, b_eq⟩⟩,\n  rw dif_neg ane0,\n  by_cases h : b = 0, { simp [h, lt_top_iff_ne_top] },\n  rw [dif_neg h, with_top.coe_lt_coe],\n  have cne0 : c ≠ 0, { refine mt (λ con, _) h, rw [b_eq, con, mul_zero] },\n  calc multiset.card (classical.some (pf a ane0))\n      < _ + multiset.card (classical.some (pf c cne0)) :\n    lt_add_of_pos_right _ (multiset.card_pos.mpr (λ con, hc (associated_one_iff_is_unit.mp _)))\n  ... = multiset.card (classical.some (pf a ane0) + classical.some (pf c cne0)) :\n    (multiset.card_add _ _).symm\n  ... = multiset.card (classical.some (pf b h)) :\n    multiset.card_eq_card_of_rel (prime_factors_unique _ (classical.some_spec (pf _ h)).1 _),\n  { convert (classical.some_spec (pf c cne0)).2.symm,\n    rw [con, multiset.prod_zero] },\n  { intros x hadd,\n    rw multiset.mem_add at hadd,\n    cases hadd; apply (classical.some_spec (pf _ _)).1 _ hadd },\n  { rw multiset.prod_add,\n    transitivity a * c,\n    { apply associated.mul_mul; apply (classical.some_spec (pf _ _)).2 },\n    { rw ← b_eq,\n      apply (classical.some_spec (pf _ _)).2.symm, } }\nend⟩\n\nlemma irreducible_iff_prime_of_exists_prime_factors {p : α} : irreducible p ↔ prime p :=\nbegin\n  by_cases hp0 : p = 0,\n  { simp [hp0] },\n  refine ⟨λ h, _, prime.irreducible⟩,\n  obtain ⟨f, hf⟩ := pf p hp0,\n  obtain ⟨q, hq, rfl⟩ := prime_factors_irreducible h hf,\n  rw hq.prime_iff,\n  exact hf.1 q (multiset.mem_singleton_self _)\nend\n\ntheorem unique_factorization_monoid.of_exists_prime_factors :\n  unique_factorization_monoid α :=\n{ irreducible_iff_prime := λ _, irreducible_iff_prime_of_exists_prime_factors pf,\n  .. wf_dvd_monoid.of_exists_prime_factors pf }\n\nend exists_prime_factors\n\ntheorem unique_factorization_monoid.iff_exists_prime_factors [cancel_comm_monoid_with_zero α] :\n  unique_factorization_monoid α ↔\n    (∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, prime b) ∧ f.prod ~ᵤ a) :=\n⟨λ h, @unique_factorization_monoid.exists_prime_factors _ _ h,\n  unique_factorization_monoid.of_exists_prime_factors⟩\n\nsection\nvariables {β : Type*} [cancel_comm_monoid_with_zero α] [cancel_comm_monoid_with_zero β]\n\nlemma mul_equiv.unique_factorization_monoid (e : α ≃* β)\n  (hα : unique_factorization_monoid α) : unique_factorization_monoid β :=\nbegin\n  rw unique_factorization_monoid.iff_exists_prime_factors at hα ⊢, intros a ha,\n  obtain ⟨w,hp,u,h⟩ := hα (e.symm a) (λ h, ha $ by { convert ← map_zero e, simp [← h] }),\n  exact ⟨ w.map e,\n    λ b hb, let ⟨c,hc,he⟩ := multiset.mem_map.1 hb in he ▸ e.prime_iff.1 (hp c hc),\n    units.map e.to_monoid_hom u,\n    by { erw [multiset.prod_hom, ← e.map_mul, h], simp } ⟩,\nend\n\nlemma mul_equiv.unique_factorization_monoid_iff (e : α ≃* β) :\n  unique_factorization_monoid α ↔ unique_factorization_monoid β :=\n⟨ e.unique_factorization_monoid, e.symm.unique_factorization_monoid ⟩\n\nend\n\ntheorem irreducible_iff_prime_of_exists_unique_irreducible_factors [cancel_comm_monoid_with_zero α]\n  (eif : ∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, irreducible b) ∧ f.prod ~ᵤ a)\n  (uif : ∀ (f g : multiset α),\n  (∀ x ∈ f, irreducible x) → (∀ x ∈ g, irreducible x) → f.prod ~ᵤ g.prod →\n    multiset.rel associated f g)\n  (p : α) : irreducible p ↔ prime p :=\n⟨by letI := classical.dec_eq α; exact λ hpi,\n    ⟨hpi.ne_zero, hpi.1,\n      λ a b ⟨x, hx⟩,\n      if hab0 : a * b = 0\n      then (eq_zero_or_eq_zero_of_mul_eq_zero hab0).elim\n        (λ ha0, by simp [ha0])\n        (λ hb0, by simp [hb0])\n      else\n        have hx0 : x ≠ 0, from λ hx0, by simp * at *,\n        have ha0 : a ≠ 0, from left_ne_zero_of_mul hab0,\n        have hb0 : b ≠ 0, from right_ne_zero_of_mul hab0,\n        begin\n          cases eif x hx0 with fx hfx,\n          cases eif a ha0 with fa hfa,\n          cases eif b hb0 with fb hfb,\n          have h : multiset.rel associated (p ::ₘ fx) (fa + fb),\n          { apply uif,\n            { exact λ i hi, (multiset.mem_cons.1 hi).elim (λ hip, hip.symm ▸ hpi) (hfx.1 _), },\n            { exact λ i hi, (multiset.mem_add.1 hi).elim (hfa.1 _) (hfb.1 _), },\n            calc multiset.prod (p ::ₘ fx)\n                  ~ᵤ a * b : by rw [hx, multiset.prod_cons];\n                    exact hfx.2.mul_left _\n              ... ~ᵤ (fa).prod * (fb).prod :\n                hfa.2.symm.mul_mul hfb.2.symm\n              ... = _ : by rw multiset.prod_add, },\n          exact let ⟨q, hqf, hq⟩ := multiset.exists_mem_of_rel_of_mem h\n          (multiset.mem_cons_self p _) in\n        (multiset.mem_add.1 hqf).elim\n          (λ hqa, or.inl $ hq.dvd_iff_dvd_left.2 $\n            hfa.2.dvd_iff_dvd_right.1\n              (multiset.dvd_prod hqa))\n          (λ hqb, or.inr $ hq.dvd_iff_dvd_left.2 $\n            hfb.2.dvd_iff_dvd_right.1\n              (multiset.dvd_prod hqb))\n        end⟩, prime.irreducible⟩\n\ntheorem unique_factorization_monoid.of_exists_unique_irreducible_factors\n  [cancel_comm_monoid_with_zero α]\n  (eif : ∀ (a : α), a ≠ 0 → ∃ f : multiset α, (∀b ∈ f, irreducible b) ∧ f.prod ~ᵤ a)\n  (uif : ∀ (f g : multiset α),\n  (∀ x ∈ f, irreducible x) → (∀ x ∈ g, irreducible x) → f.prod ~ᵤ g.prod →\n    multiset.rel associated f g) :\n  unique_factorization_monoid α :=\nunique_factorization_monoid.of_exists_prime_factors (by\n  { convert eif,\n    simp_rw irreducible_iff_prime_of_exists_unique_irreducible_factors eif uif })\n\nnamespace unique_factorization_monoid\nvariables [cancel_comm_monoid_with_zero α] [decidable_eq α]\nvariables [unique_factorization_monoid α]\n/-- Noncomputably determines the multiset of prime factors. -/\nnoncomputable def factors (a : α) : multiset α := if h : a = 0 then 0 else\nclassical.some (unique_factorization_monoid.exists_prime_factors a h)\n\ntheorem factors_prod {a : α} (ane0 : a ≠ 0) : associated (factors a).prod a :=\nbegin\n  rw [factors, dif_neg ane0],\n  exact (classical.some_spec (exists_prime_factors a ane0)).2\nend\n\ntheorem prime_of_factor {a : α} : ∀ (x : α), x ∈ factors a → prime x :=\nbegin\n  rw [factors],\n  split_ifs with ane0, { simp only [multiset.not_mem_zero, forall_false_left, forall_const] },\n  intros x hx,\n  exact (classical.some_spec (unique_factorization_monoid.exists_prime_factors a ane0)).1 x hx,\nend\n\ntheorem irreducible_of_factor {a : α} : ∀ (x : α), x ∈ factors a → irreducible x :=\nλ x h, (prime_of_factor x h).irreducible\n\nlemma exists_mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) : p ∣ a →\n  ∃ q ∈ factors a, p ~ᵤ q :=\nλ ⟨b, hb⟩,\nhave hb0 : b ≠ 0, from λ hb0, by simp * at *,\nhave multiset.rel associated (p ::ₘ factors b) (factors a),\n  from factors_unique\n    (λ x hx, (multiset.mem_cons.1 hx).elim (λ h, h.symm ▸ hp) (irreducible_of_factor _))\n    irreducible_of_factor\n    (associated.symm $ calc multiset.prod (factors a) ~ᵤ a : factors_prod ha0\n      ... = p * b : hb\n      ... ~ᵤ multiset.prod (p ::ₘ factors b) :\n        by rw multiset.prod_cons; exact (factors_prod hb0).symm.mul_left _),\nmultiset.exists_mem_of_rel_of_mem this (by simp)\n\nend unique_factorization_monoid\n\nnamespace unique_factorization_monoid\nvariables [cancel_comm_monoid_with_zero α] [decidable_eq α] [normalization_monoid α]\nvariables [unique_factorization_monoid α]\n\n/-- Noncomputably determines the multiset of prime factors. -/\nnoncomputable def normalized_factors (a : α) : multiset α :=\nmultiset.map normalize $ factors a\n\n/-- An arbitrary choice of factors of `x : M` is exactly the (unique) normalized set of factors,\nif `M` has a trivial group of units. -/\n@[simp] lemma factors_eq_normalized_factors {M : Type*} [cancel_comm_monoid_with_zero M]\n  [decidable_eq M] [unique_factorization_monoid M] [unique (Mˣ)] (x : M) :\n  factors x = normalized_factors x :=\nbegin\n  unfold normalized_factors,\n  convert (multiset.map_id (factors x)).symm,\n  ext p,\n  exact normalize_eq p\nend\n\ntheorem normalized_factors_prod {a : α} (ane0 : a ≠ 0) : associated (normalized_factors a).prod a :=\nbegin\n  rw [normalized_factors, factors, dif_neg ane0],\n  refine associated.trans _ (classical.some_spec (exists_prime_factors a ane0)).2,\n  rw [← associates.mk_eq_mk_iff_associated, ← associates.prod_mk, ← associates.prod_mk,\n      multiset.map_map],\n  congr' 2,\n  ext,\n  rw [function.comp_apply, associates.mk_normalize],\nend\n\ntheorem prime_of_normalized_factor {a : α} : ∀ (x : α), x ∈ normalized_factors a → prime x :=\nbegin\n  rw [normalized_factors, factors],\n  split_ifs with ane0, { simp },\n  intros x hx, rcases multiset.mem_map.1 hx with ⟨y, ⟨hy, rfl⟩⟩,\n  rw (normalize_associated _).prime_iff,\n  exact (classical.some_spec (unique_factorization_monoid.exists_prime_factors a ane0)).1 y hy,\nend\n\ntheorem irreducible_of_normalized_factor {a : α} :\n  ∀ (x : α), x ∈ normalized_factors a → irreducible x :=\nλ x h, (prime_of_normalized_factor x h).irreducible\n\ntheorem normalize_normalized_factor {a : α} :\n  ∀ (x : α), x ∈ normalized_factors a → normalize x = x :=\nbegin\n  rw [normalized_factors, factors],\n  split_ifs with h, { simp },\n  intros x hx,\n  obtain ⟨y, hy, rfl⟩ := multiset.mem_map.1 hx,\n  apply normalize_idem\nend\n\nlemma normalized_factors_irreducible {a : α} (ha : irreducible a) :\n  normalized_factors a = {normalize a} :=\nbegin\n  obtain ⟨p, a_assoc, hp⟩ := prime_factors_irreducible ha\n    ⟨prime_of_normalized_factor, normalized_factors_prod ha.ne_zero⟩,\n  have p_mem : p ∈ normalized_factors a,\n  { rw hp, exact multiset.mem_singleton_self _ },\n  convert hp,\n  rwa [← normalize_normalized_factor p p_mem, normalize_eq_normalize_iff, dvd_dvd_iff_associated]\nend\n\nlemma exists_mem_normalized_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) : p ∣ a →\n  ∃ q ∈ normalized_factors a, p ~ᵤ q :=\nλ ⟨b, hb⟩,\nhave hb0 : b ≠ 0, from λ hb0, by simp * at *,\nhave multiset.rel associated (p ::ₘ normalized_factors b) (normalized_factors a),\n  from factors_unique\n    (λ x hx, (multiset.mem_cons.1 hx).elim (λ h, h.symm ▸ hp)\n      (irreducible_of_normalized_factor _))\n    irreducible_of_normalized_factor\n    (associated.symm $ calc multiset.prod (normalized_factors a) ~ᵤ a : normalized_factors_prod ha0\n      ... = p * b : hb\n      ... ~ᵤ multiset.prod (p ::ₘ normalized_factors b) :\n        by rw multiset.prod_cons; exact (normalized_factors_prod hb0).symm.mul_left _),\nmultiset.exists_mem_of_rel_of_mem this (by simp)\n\n@[simp] lemma normalized_factors_zero : normalized_factors (0 : α) = 0 :=\nby simp [normalized_factors, factors]\n\n@[simp] lemma normalized_factors_one : normalized_factors (1 : α) = 0 :=\nbegin\n  nontriviality α using [normalized_factors, factors],\n  rw ← multiset.rel_zero_right,\n  apply factors_unique irreducible_of_normalized_factor,\n  { intros x hx,\n    exfalso,\n    apply multiset.not_mem_zero x hx },\n  { simp [normalized_factors_prod (@one_ne_zero α _ _)] },\n  apply_instance\nend\n\n@[simp] lemma normalized_factors_mul {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :\n  normalized_factors (x * y) = normalized_factors x + normalized_factors y :=\nbegin\n  have h : (normalize : α → α) = associates.out ∘ associates.mk,\n  { ext, rw [function.comp_apply, associates.out_mk], },\n  rw [← multiset.map_id' (normalized_factors (x * y)), ← multiset.map_id' (normalized_factors x),\n    ← multiset.map_id' (normalized_factors y), ← multiset.map_congr rfl normalize_normalized_factor,\n    ← multiset.map_congr rfl normalize_normalized_factor,\n    ← multiset.map_congr rfl normalize_normalized_factor,\n    ← multiset.map_add, h, ← multiset.map_map associates.out, eq_comm,\n    ← multiset.map_map associates.out],\n  refine congr rfl _,\n  apply multiset.map_mk_eq_map_mk_of_rel,\n  apply factors_unique,\n  { intros x hx,\n    rcases multiset.mem_add.1 hx with hx | hx;\n    exact irreducible_of_normalized_factor x hx },\n  { exact irreducible_of_normalized_factor },\n  { rw multiset.prod_add,\n    exact ((normalized_factors_prod hx).mul_mul (normalized_factors_prod hy)).trans\n      (normalized_factors_prod (mul_ne_zero hx hy)).symm }\nend\n\n@[simp] lemma normalized_factors_pow {x : α} (n : ℕ) :\n  normalized_factors (x ^ n) = n • normalized_factors x :=\nbegin\n  induction n with n ih,\n  { simp },\n  by_cases h0 : x = 0,\n  { simp [h0, zero_pow n.succ_pos, smul_zero] },\n  rw [pow_succ, succ_nsmul, normalized_factors_mul h0 (pow_ne_zero _ h0), ih],\nend\n\ntheorem _root_.irreducible.normalized_factors_pow {p : α} (hp : irreducible p) (k : ℕ) :\n  normalized_factors (p ^ k) = multiset.repeat (normalize p) k :=\nby rw [normalized_factors_pow, normalized_factors_irreducible hp, multiset.nsmul_singleton]\n\nlemma dvd_iff_normalized_factors_le_normalized_factors {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :\n  x ∣ y ↔ normalized_factors x ≤ normalized_factors y :=\nbegin\n  split,\n  { rintro ⟨c, rfl⟩,\n    simp [hx, right_ne_zero_of_mul hy] },\n  { rw [← (normalized_factors_prod hx).dvd_iff_dvd_left,\n      ← (normalized_factors_prod hy).dvd_iff_dvd_right],\n    apply multiset.prod_dvd_prod_of_le }\nend\n\ntheorem normalized_factors_of_irreducible_pow {p : α} (hp : irreducible p) (k : ℕ) :\n  normalized_factors (p ^ k) = multiset.repeat (normalize p) k :=\nby rw [normalized_factors_pow, normalized_factors_irreducible hp, multiset.nsmul_singleton]\n\nlemma zero_not_mem_normalized_factors (x : α) : (0 : α) ∉ normalized_factors x :=\nλ h, prime.ne_zero (prime_of_normalized_factor _ h) rfl\n\nlemma dvd_of_mem_normalized_factors {a p : α} (H : p ∈ normalized_factors a) : p ∣ a :=\nbegin\n  by_cases hcases : a = 0,\n  { rw hcases,\n    exact dvd_zero p },\n  { exact dvd_trans (multiset.dvd_prod H) (associated.dvd (normalized_factors_prod hcases)) },\nend\n\nlemma exists_associated_prime_pow_of_unique_normalized_factor {p r : α}\n  (h : ∀ {m}, m ∈ normalized_factors r → m = p) (hr : r ≠ 0) : ∃ (i : ℕ), associated (p ^ i) r :=\nbegin\n  use (normalized_factors r).card,\n  have := unique_factorization_monoid.normalized_factors_prod hr,\n  rwa [multiset.eq_repeat_of_mem (λ b, h), multiset.prod_repeat] at this\nend\n\nend unique_factorization_monoid\n\nnamespace unique_factorization_monoid\n\nopen_locale classical\nopen multiset associates\nnoncomputable theory\n\nvariables [cancel_comm_monoid_with_zero α] [nontrivial α] [unique_factorization_monoid α]\n\n/-- Noncomputably defines a `normalization_monoid` structure on a `unique_factorization_monoid`. -/\nprotected def normalization_monoid : normalization_monoid α :=\nnormalization_monoid_of_monoid_hom_right_inverse\n{ to_fun := λ a : associates α, if a = 0 then 0 else ((normalized_factors a).map\n    (classical.some mk_surjective.has_right_inverse : associates α → α)).prod,\n  map_one' := by simp,\n  map_mul' := λ x y, by\n  { by_cases hx : x = 0, { simp [hx] },\n    by_cases hy : y = 0, { simp [hy] },\n    simp [hx, hy] } } begin\n  intro x,\n  dsimp,\n  by_cases hx : x = 0, { simp [hx] },\n  have h : associates.mk_monoid_hom ∘ (classical.some mk_surjective.has_right_inverse) =\n           (id : associates α → associates α),\n  { ext x,\n    rw [function.comp_apply, mk_monoid_hom_apply,\n      classical.some_spec mk_surjective.has_right_inverse x],\n    refl },\n  rw [if_neg hx, ← mk_monoid_hom_apply, monoid_hom.map_multiset_prod, map_map, h, map_id,\n      ← associated_iff_eq],\n  apply normalized_factors_prod hx\nend\n\ninstance : inhabited (normalization_monoid α) := ⟨unique_factorization_monoid.normalization_monoid⟩\n\nend unique_factorization_monoid\n\nnamespace unique_factorization_monoid\n\nvariables {R : Type*} [cancel_comm_monoid_with_zero R] [unique_factorization_monoid R]\n\nlemma no_factors_of_no_prime_factors {a b : R} (ha : a ≠ 0)\n  (h : (∀ {d}, d ∣ a → d ∣ b → ¬ prime d)) : ∀ {d}, d ∣ a → d ∣ b → is_unit d :=\nλ d, induction_on_prime d\n  (by { simp only [zero_dvd_iff], intros, contradiction })\n  (λ x hx _ _, hx)\n  (λ d q hp hq ih dvd_a dvd_b,\n    absurd hq (h (dvd_of_mul_right_dvd dvd_a) (dvd_of_mul_right_dvd dvd_b)))\n\n/-- Euclid's lemma: if `a ∣ b * c` and `a` and `c` have no common prime factors, `a ∣ b`.\nCompare `is_coprime.dvd_of_dvd_mul_left`. -/\nlemma dvd_of_dvd_mul_left_of_no_prime_factors {a b c : R} (ha : a ≠ 0) :\n  (∀ {d}, d ∣ a → d ∣ c → ¬ prime d) → a ∣ b * c → a ∣ b :=\nbegin\n  refine induction_on_prime c _ _ _,\n  { intro no_factors,\n    simp only [dvd_zero, mul_zero, forall_prop_of_true],\n    haveI := classical.prop_decidable,\n    exact is_unit_iff_forall_dvd.mp\n      (no_factors_of_no_prime_factors ha @no_factors (dvd_refl a) (dvd_zero a)) _ },\n  { rintros _ ⟨x, rfl⟩ _ a_dvd_bx,\n    apply units.dvd_mul_right.mp a_dvd_bx },\n  { intros c p hc hp ih no_factors a_dvd_bpc,\n    apply ih (λ q dvd_a dvd_c hq, no_factors dvd_a (dvd_c.mul_left _) hq),\n    rw mul_left_comm at a_dvd_bpc,\n    refine or.resolve_left (hp.left_dvd_or_dvd_right_of_dvd_mul a_dvd_bpc) (λ h, _),\n    exact no_factors h (dvd_mul_right p c) hp }\nend\n\n/-- Euclid's lemma: if `a ∣ b * c` and `a` and `b` have no common prime factors, `a ∣ c`.\nCompare `is_coprime.dvd_of_dvd_mul_right`. -/\nlemma dvd_of_dvd_mul_right_of_no_prime_factors {a b c : R} (ha : a ≠ 0)\n  (no_factors : ∀ {d}, d ∣ a → d ∣ b → ¬ prime d) : a ∣ b * c → a ∣ c :=\nby simpa [mul_comm b c] using dvd_of_dvd_mul_left_of_no_prime_factors ha @no_factors\n\n/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing\nout their common factor `c'` gives `a'` and `b'` with no factors in common. -/\nlemma exists_reduced_factors : ∀ (a ≠ (0 : R)) b,\n  ∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → is_unit d) ∧ c' * a' = a ∧ c' * b' = b :=\nbegin\n  haveI := classical.prop_decidable,\n  intros a,\n  refine induction_on_prime a _ _ _,\n  { intros, contradiction },\n  { intros a a_unit a_ne_zero b,\n    use [a, b, 1],\n    split,\n    { intros p p_dvd_a _,\n      exact is_unit_of_dvd_unit p_dvd_a a_unit },\n    { simp } },\n  { intros a p a_ne_zero p_prime ih_a pa_ne_zero b,\n    by_cases p ∣ b,\n    { rcases h with ⟨b, rfl⟩,\n      obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b,\n      refine ⟨a', b', p * c', @no_factor, _, _⟩,\n      { rw [mul_assoc, ha'] },\n      { rw [mul_assoc, hb'] } },\n    { obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b,\n      refine ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩,\n      intros q q_dvd_pa' q_dvd_b',\n      cases p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a',\n      { have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _,\n        contradiction },\n      exact coprime q_dvd_a' q_dvd_b' } }\nend\n\nlemma exists_reduced_factors' (a b : R) (hb : b ≠ 0) :\n  ∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → is_unit d) ∧ c' * a' = a ∧ c' * b' = b :=\nlet ⟨b', a', c', no_factor, hb, ha⟩ := exists_reduced_factors b hb a\nin ⟨a', b', c', λ _ hpb hpa, no_factor hpa hpb, ha, hb⟩\n\nsection multiplicity\nvariables [nontrivial R] [normalization_monoid R] [decidable_eq R]\nvariables [dec_dvd : decidable_rel (has_dvd.dvd : R → R → Prop)]\nopen multiplicity multiset\n\ninclude dec_dvd\nlemma le_multiplicity_iff_repeat_le_normalized_factors {a b : R} {n : ℕ}\n  (ha : irreducible a) (hb : b ≠ 0) :\n  ↑n ≤ multiplicity a b ↔ repeat (normalize a) n ≤ normalized_factors b :=\nbegin\n  rw ← pow_dvd_iff_le_multiplicity,\n  revert b,\n  induction n with n ih, { simp },\n  intros b hb,\n  split,\n  { rintro ⟨c, rfl⟩,\n    rw [ne.def, pow_succ, mul_assoc, mul_eq_zero, decidable.not_or_iff_and_not] at hb,\n    rw [pow_succ, mul_assoc, normalized_factors_mul hb.1 hb.2, repeat_succ,\n      normalized_factors_irreducible ha, singleton_add, cons_le_cons_iff, ← ih hb.2],\n    apply dvd.intro _ rfl },\n  { rw [multiset.le_iff_exists_add],\n    rintro ⟨u, hu⟩,\n    rw [← (normalized_factors_prod hb).dvd_iff_dvd_right, hu, prod_add, prod_repeat],\n    exact (associated.pow_pow $ associated_normalize a).dvd.trans (dvd.intro u.prod rfl) }\nend\n\n/-- The multiplicity of an irreducible factor of a nonzero element is exactly the number of times\nthe normalized factor occurs in the `normalized_factors`.\n\nSee also `count_normalized_factors_eq` which expands the definition of `multiplicity`\nto produce a specification for `count (normalized_factors _) _`..\n-/\nlemma multiplicity_eq_count_normalized_factors {a b : R} (ha : irreducible a) (hb : b ≠ 0) :\n  multiplicity a b = (normalized_factors b).count (normalize a) :=\nbegin\n  apply le_antisymm,\n  { apply enat.le_of_lt_add_one,\n    rw [← nat.cast_one, ← nat.cast_add, lt_iff_not_ge, ge_iff_le,\n      le_multiplicity_iff_repeat_le_normalized_factors ha hb, ← le_count_iff_repeat_le],\n    simp },\n  rw [le_multiplicity_iff_repeat_le_normalized_factors ha hb, ← le_count_iff_repeat_le],\nend\n\nomit dec_dvd\n/-- The number of times an irreducible factor `p` appears in `normalized_factors x` is defined by\nthe number of times it divides `x`.\n\nSee also `multiplicity_eq_count_normalized_factors` if `n` is given by `multiplicity p x`.\n-/\nlemma count_normalized_factors_eq {p x : R} (hp : irreducible p) (hnorm : normalize p = p) {n : ℕ}\n  (hle : p^n ∣ x) (hlt : ¬ (p^(n+1) ∣ x)) :\n  (normalized_factors x).count p = n :=\nbegin\n  letI : decidable_rel ((∣) : R → R → Prop) := λ _ _, classical.prop_decidable _,\n  by_cases hx0 : x = 0,\n  { simp [hx0] at hlt, contradiction },\n  rw [← enat.coe_inj],\n  convert (multiplicity_eq_count_normalized_factors hp hx0).symm,\n  { exact hnorm.symm },\n  exact (multiplicity.eq_coe_iff.mpr ⟨hle, hlt⟩).symm\nend\n\nend multiplicity\n\nend unique_factorization_monoid\n\n\nnamespace associates\nopen unique_factorization_monoid associated multiset\nvariables [cancel_comm_monoid_with_zero α]\n\n/-- `factor_set α` representation elements of unique factorization domain as multisets.\n`multiset α` produced by `normalized_factors` are only unique up to associated elements, while the\nmultisets in `factor_set α` are unique by equality and restricted to irreducible elements. This\ngives us a representation of each element as a unique multisets (or the added ⊤ for 0), which has a\ncomplete lattice struture. Infimum is the greatest common divisor and supremum is the least common\nmultiple.\n-/\n@[reducible] def {u} factor_set (α : Type u) [cancel_comm_monoid_with_zero α] :\n  Type u :=\nwith_top (multiset { a : associates α // irreducible a })\n\nlocal attribute [instance] associated.setoid\n\ntheorem factor_set.coe_add {a b : multiset { a : associates α // irreducible a }} :\n  (↑(a + b) : factor_set α) = a + b :=\nby norm_cast\n\nlemma factor_set.sup_add_inf_eq_add [decidable_eq (associates α)] :\n  ∀(a b : factor_set α), a ⊔ b + a ⊓ b = a + b\n| none     b        := show ⊤ ⊔ b + ⊤ ⊓ b = ⊤ + b, by simp\n| a        none     := show a ⊔ ⊤ + a ⊓ ⊤ = a + ⊤, by simp\n| (some a) (some b) := show (a : factor_set α) ⊔ b + a ⊓ b = a + b, from\n  begin\n    rw [← with_top.coe_sup, ← with_top.coe_inf, ← with_top.coe_add, ← with_top.coe_add,\n      with_top.coe_eq_coe],\n    exact multiset.union_add_inter _ _\n  end\n\n/-- Evaluates the product of a `factor_set` to be the product of the corresponding multiset,\n  or `0` if there is none. -/\ndef factor_set.prod : factor_set α → associates α\n| none     := 0\n| (some s) := (s.map coe).prod\n\n@[simp] theorem prod_top : (⊤ : factor_set α).prod = 0 := rfl\n\n@[simp] theorem prod_coe {s : multiset { a : associates α // irreducible a }} :\n  (s : factor_set α).prod = (s.map coe).prod :=\nrfl\n\n@[simp] theorem prod_add : ∀(a b : factor_set α), (a + b).prod = a.prod * b.prod\n| none b    := show (⊤ + b).prod = (⊤:factor_set α).prod * b.prod, by simp\n| a    none := show (a + ⊤).prod = a.prod * (⊤:factor_set α).prod, by simp\n| (some a) (some b) :=\n  show (↑a + ↑b:factor_set α).prod = (↑a:factor_set α).prod * (↑b:factor_set α).prod,\n    by rw [← factor_set.coe_add, prod_coe, prod_coe, prod_coe, multiset.map_add, multiset.prod_add]\n\ntheorem prod_mono : ∀{a b : factor_set α}, a ≤ b → a.prod ≤ b.prod\n| none b h := have b = ⊤, from top_unique h, by rw [this, prod_top]; exact le_rfl\n| a none h := show a.prod ≤ (⊤ : factor_set α).prod, by simp; exact le_top\n| (some a) (some b) h := prod_le_prod $ multiset.map_le_map $ with_top.coe_le_coe.1 $ h\n\ntheorem factor_set.prod_eq_zero_iff [nontrivial α] (p : factor_set α) :\n  p.prod = 0 ↔ p = ⊤ :=\nbegin\n  induction p using with_top.rec_top_coe,\n  { simp only [iff_self, eq_self_iff_true, associates.prod_top] },\n  simp only [prod_coe, with_top.coe_ne_top, iff_false, prod_eq_zero_iff, multiset.mem_map],\n  rintro ⟨⟨a, ha⟩, -, eq⟩,\n  rw [subtype.coe_mk] at eq,\n  exact ha.ne_zero eq,\nend\n\n/-- `bcount p s` is the multiplicity of `p` in the factor_set `s` (with bundled `p`)-/\ndef bcount [decidable_eq (associates α)] (p : {a : associates α // irreducible a}) :\n  factor_set α → ℕ\n| none := 0\n| (some s) := s.count p\n\nvariables [dec_irr : Π (p : associates α), decidable (irreducible p)]\ninclude dec_irr\n\n/-- `count p s` is the multiplicity of the irreducible `p` in the factor_set `s`.\n\nIf `p` is not irreducible, `count p s` is defined to be `0`. -/\ndef count [decidable_eq (associates α)] (p : associates α) :\n  factor_set α → ℕ :=\nif hp : irreducible p then bcount ⟨p, hp⟩  else 0\n\n@[simp] lemma count_some [decidable_eq (associates α)] {p : associates α} (hp : irreducible p)\n  (s : multiset _) : count p (some s) = s.count ⟨p, hp⟩:=\nby { dunfold count, split_ifs, refl }\n\n@[simp] lemma count_zero [decidable_eq (associates α)] {p : associates α} (hp : irreducible p) :\n  count p (0 : factor_set α) = 0 :=\nby { dunfold count, split_ifs, refl }\n\nlemma count_reducible [decidable_eq (associates α)] {p : associates α} (hp : ¬ irreducible p) :\n  count p = 0 := dif_neg hp\n\nomit dec_irr\n\n/-- membership in a factor_set (bundled version) -/\ndef bfactor_set_mem : {a : associates α // irreducible a} → (factor_set α) → Prop\n| _ ⊤ := true\n| p (some l) := p ∈ l\n\ninclude dec_irr\n\n/-- `factor_set_mem p s` is the predicate that the irreducible `p` is a member of\n`s : factor_set α`.\n\nIf `p` is not irreducible, `p` is not a member of any `factor_set`. -/\ndef factor_set_mem (p : associates α) (s : factor_set α) : Prop :=\nif hp : irreducible p then bfactor_set_mem ⟨p, hp⟩ s else false\n\ninstance : has_mem (associates α) (factor_set α) := ⟨factor_set_mem⟩\n\n@[simp] lemma factor_set_mem_eq_mem (p : associates α) (s : factor_set α) :\n  factor_set_mem p s = (p ∈ s) := rfl\n\nlemma mem_factor_set_top {p : associates α} {hp : irreducible p} :\n  p ∈ (⊤ : factor_set α) :=\nbegin\n  dunfold has_mem.mem, dunfold factor_set_mem, split_ifs, exact trivial\nend\n\nlemma mem_factor_set_some {p : associates α} {hp : irreducible p}\n   {l : multiset {a : associates α // irreducible a }} :\n  p ∈ (l : factor_set α) ↔ subtype.mk p hp ∈ l :=\nbegin\n  dunfold has_mem.mem, dunfold factor_set_mem, split_ifs, refl\nend\n\nlemma reducible_not_mem_factor_set {p : associates α} (hp : ¬ irreducible p)\n  (s : factor_set α) : ¬ p ∈ s :=\nλ (h : if hp : irreducible p then bfactor_set_mem ⟨p, hp⟩ s else false),\n  by rwa [dif_neg hp] at h\n\nomit dec_irr\n\nvariable [unique_factorization_monoid α]\n\ntheorem unique' {p q : multiset (associates α)} :\n  (∀a∈p, irreducible a) → (∀a∈q, irreducible a) → p.prod = q.prod → p = q :=\nbegin\n  apply multiset.induction_on_multiset_quot p,\n  apply multiset.induction_on_multiset_quot q,\n  assume s t hs ht eq,\n  refine multiset.map_mk_eq_map_mk_of_rel (unique_factorization_monoid.factors_unique _ _ _),\n  { exact assume a ha, ((irreducible_mk _).1 $ hs _ $ multiset.mem_map_of_mem _ ha) },\n  { exact assume a ha, ((irreducible_mk _).1 $ ht _ $ multiset.mem_map_of_mem _ ha) },\n  simpa [quot_mk_eq_mk, prod_mk, mk_eq_mk_iff_associated] using eq\nend\n\ntheorem factor_set.unique [nontrivial α] {p q : factor_set α} (h : p.prod = q.prod) : p = q :=\nbegin\n  induction p using with_top.rec_top_coe;\n  induction q using with_top.rec_top_coe,\n  { refl },\n  { rw [eq_comm, ←factor_set.prod_eq_zero_iff, ←h, associates.prod_top] },\n  { rw [←factor_set.prod_eq_zero_iff, h, associates.prod_top] },\n  { congr' 1,\n    rw  ←multiset.map_eq_map subtype.coe_injective,\n    apply unique' _ _ h;\n    { intros a ha,\n      obtain ⟨⟨a', irred⟩, -, rfl⟩ := multiset.mem_map.mp ha,\n      rwa [subtype.coe_mk] } },\nend\n\ntheorem prod_le_prod_iff_le [nontrivial α] {p q : multiset (associates α)}\n  (hp : ∀a∈p, irreducible a) (hq : ∀a∈q, irreducible a) :\n  p.prod ≤ q.prod ↔ p ≤ q :=\niff.intro\n  begin\n    classical,\n    rintros ⟨c, eqc⟩,\n    refine multiset.le_iff_exists_add.2 ⟨factors c, unique' hq (λ x hx, _) _⟩,\n    { obtain h|h := multiset.mem_add.1 hx,\n      { exact hp x h },\n      { exact irreducible_of_factor _ h } },\n    { rw [eqc, multiset.prod_add],\n      congr,\n      refine associated_iff_eq.mp (factors_prod (λ hc, _)).symm,\n      refine not_irreducible_zero (hq _ _),\n      rw [←prod_eq_zero_iff, eqc, hc, mul_zero] }\n  end\n  prod_le_prod\n\nvariables [dec : decidable_eq α] [dec' : decidable_eq (associates α)]\ninclude dec\n\n/-- This returns the multiset of irreducible factors as a `factor_set`,\n  a multiset of irreducible associates `with_top`. -/\nnoncomputable def factors' (a : α) :\n  multiset { a : associates α // irreducible a } :=\n(factors a).pmap (λa ha, ⟨associates.mk a, (irreducible_mk _).2 ha⟩)\n  (irreducible_of_factor)\n\n@[simp] theorem map_subtype_coe_factors' {a : α} :\n  (factors' a).map coe = (factors a).map associates.mk :=\nby simp [factors', multiset.map_pmap, multiset.pmap_eq_map]\n\ntheorem factors'_cong {a b : α} (h : a ~ᵤ b) :\n  factors' a = factors' b :=\nbegin\n  obtain rfl|hb := eq_or_ne b 0,\n  { rw associated_zero_iff_eq_zero at h, rw h },\n  have ha : a ≠ 0,\n  { contrapose! hb with ha,\n    rw [←associated_zero_iff_eq_zero, ←ha],\n    exact h.symm },\n  rw [←multiset.map_eq_map subtype.coe_injective, map_subtype_coe_factors',\n    map_subtype_coe_factors', ←rel_associated_iff_map_eq_map],\n  exact factors_unique irreducible_of_factor irreducible_of_factor\n    ((factors_prod ha).trans $ h.trans $ (factors_prod hb).symm),\nend\n\ninclude dec'\n\n/-- This returns the multiset of irreducible factors of an associate as a `factor_set`,\n  a multiset of irreducible associates `with_top`. -/\nnoncomputable def factors (a : associates α) :\n  factor_set α :=\nbegin\n  refine (if h : a = 0 then ⊤ else\n    quotient.hrec_on a (λx h, some $ factors' x) _ h),\n  assume a b hab,\n  apply function.hfunext,\n  { have : a ~ᵤ 0 ↔ b ~ᵤ 0, from\n      iff.intro (assume ha0, hab.symm.trans ha0) (assume hb0, hab.trans hb0),\n    simp only [associated_zero_iff_eq_zero] at this,\n    simp only [quotient_mk_eq_mk, this, mk_eq_zero] },\n  exact (assume ha hb eq, heq_of_eq $ congr_arg some $ factors'_cong hab)\nend\n\n@[simp] theorem factors_0 : (0 : associates α).factors = ⊤ :=\ndif_pos rfl\n\n@[simp] theorem factors_mk (a : α) (h : a ≠ 0) :\n  (associates.mk a).factors = factors' a :=\nby { classical, apply dif_neg, apply (mt mk_eq_zero.1 h) }\n\n@[simp]\ntheorem factors_prod (a : associates α) : a.factors.prod = a :=\nquotient.induction_on a $ assume a, decidable.by_cases\n  (assume : associates.mk a = 0, by simp [quotient_mk_eq_mk, this])\n  (assume : associates.mk a ≠ 0,\n    have a ≠ 0, by simp * at *,\n    by simp [this, quotient_mk_eq_mk, prod_mk,\n      mk_eq_mk_iff_associated.2 (factors_prod this)])\n\ntheorem prod_factors [nontrivial α] (s : factor_set α) : s.prod.factors = s :=\nfactor_set.unique $ factors_prod _\n\n@[nontriviality] lemma factors_subsingleton [subsingleton α] {a : associates α} :\n  a.factors = option.none :=\nby { convert factors_0; apply_instance }\n\nlemma factors_eq_none_iff_zero {a : associates α} :\n  a.factors = option.none ↔ a = 0 :=\nbegin\n  nontriviality α,\n  exact ⟨λ h, by rwa [← factors_prod a, factor_set.prod_eq_zero_iff], λ h, h.symm ▸ factors_0⟩\nend\n\nlemma factors_eq_some_iff_ne_zero {a : associates α} :\n  (∃ (s : multiset {p : associates α // irreducible p}), a.factors = some s) ↔ a ≠ 0 :=\nby rw [← option.is_some_iff_exists, ← option.ne_none_iff_is_some, ne.def, ne.def,\n  factors_eq_none_iff_zero]\n\ntheorem eq_of_factors_eq_factors {a b : associates α} (h : a.factors = b.factors) : a = b :=\nhave a.factors.prod = b.factors.prod, by rw h,\nby rwa [factors_prod, factors_prod] at this\n\nomit dec dec'\n\ntheorem eq_of_prod_eq_prod [nontrivial α] {a b : factor_set α} (h : a.prod = b.prod) : a = b :=\nbegin\n  classical,\n  have : a.prod.factors = b.prod.factors, by rw h,\n  rwa [prod_factors, prod_factors] at this\nend\n\ninclude dec dec' dec_irr\n\ntheorem eq_factors_of_eq_counts {a b : associates α} (ha : a ≠ 0) (hb : b ≠ 0)\n  (h : ∀ (p : associates α) (hp : irreducible p), p.count a.factors = p.count b.factors) :\n  a.factors = b.factors :=\nbegin\n  obtain ⟨sa, h_sa⟩ := factors_eq_some_iff_ne_zero.mpr ha,\n  obtain ⟨sb, h_sb⟩ := factors_eq_some_iff_ne_zero.mpr hb,\n  rw [h_sa, h_sb] at h ⊢,\n  rw option.some_inj,\n  have h_count : ∀ (p : associates α) (hp : irreducible p), sa.count ⟨p, hp⟩ = sb.count ⟨p, hp⟩,\n  { intros p hp, rw [← count_some, ← count_some, h p hp] },\n  apply multiset.to_finsupp.injective,\n  ext ⟨p, hp⟩,\n  rw [multiset.to_finsupp_apply, multiset.to_finsupp_apply, h_count p hp]\nend\n\ntheorem eq_of_eq_counts {a b : associates α} (ha : a ≠ 0) (hb  : b ≠ 0)\n  (h : ∀ (p : associates α), irreducible p → p.count a.factors = p.count b.factors) : a = b :=\neq_of_factors_eq_factors (eq_factors_of_eq_counts ha hb h)\n\nlemma count_le_count_of_factors_le {a b p : associates α} (hb : b ≠ 0)\n  (hp : irreducible p) (h : a.factors ≤ b.factors) : p.count a.factors ≤ p.count b.factors :=\nbegin\n  by_cases ha : a = 0,\n  { simp [*] at *, },\n  obtain ⟨sa, h_sa⟩ := factors_eq_some_iff_ne_zero.mpr ha,\n  obtain ⟨sb, h_sb⟩ := factors_eq_some_iff_ne_zero.mpr hb,\n  rw [h_sa, h_sb] at h ⊢,\n  rw [count_some hp, count_some hp], rw with_top.some_le_some at h,\n  exact multiset.count_le_of_le _ h\nend\n\nomit dec_irr\n\n@[simp] theorem factors_mul (a b : associates α) :\n  (a * b).factors = a.factors + b.factors :=\nbegin\n  casesI subsingleton_or_nontrivial α,\n  { simp [subsingleton.elim a 0], },\n  refine (eq_of_prod_eq_prod (eq_of_factors_eq_factors _)),\n  rw [prod_add, factors_prod, factors_prod, factors_prod],\nend\n\ntheorem factors_mono : ∀{a b : associates α}, a ≤ b → a.factors ≤ b.factors\n| s t ⟨d, rfl⟩ := by rw [factors_mul] ; exact le_add_of_nonneg_right bot_le\n\ntheorem factors_le {a b : associates α} : a.factors ≤ b.factors ↔ a ≤ b :=\niff.intro\n  (assume h, have a.factors.prod ≤ b.factors.prod, from prod_mono h,\n    by rwa [factors_prod, factors_prod] at this)\n  factors_mono\n\ninclude dec_irr\n\nlemma count_le_count_of_le {a b p : associates α} (hb : b ≠ 0)\n  (hp : irreducible p) (h : a ≤ b) : p.count a.factors ≤ p.count b.factors :=\ncount_le_count_of_factors_le hb hp $ factors_mono h\n\nomit dec dec' dec_irr\n\ntheorem prod_le [nontrivial α] {a b : factor_set α} : a.prod ≤ b.prod ↔ a ≤ b :=\nbegin\n  classical,\n  exact iff.intro\n  (assume h, have a.prod.factors ≤ b.prod.factors, from factors_mono h,\n    by rwa [prod_factors, prod_factors] at this)\n  prod_mono\nend\n\ninclude dec dec'\n\nnoncomputable instance : has_sup (associates α) := ⟨λa b, (a.factors ⊔ b.factors).prod⟩\nnoncomputable instance : has_inf (associates α) := ⟨λa b, (a.factors ⊓ b.factors).prod⟩\n\nnoncomputable instance : lattice (associates α) :=\n{ sup          := (⊔),\n  inf          := (⊓),\n  sup_le       :=\n    assume a b c hac hbc, factors_prod c ▸ prod_mono (sup_le (factors_mono hac) (factors_mono hbc)),\n  le_sup_left  := assume a b,\n    le_trans (le_of_eq (factors_prod a).symm) $ prod_mono $ le_sup_left,\n  le_sup_right := assume a b,\n    le_trans (le_of_eq (factors_prod b).symm) $ prod_mono $ le_sup_right,\n  le_inf :=\n    assume a b c hac hbc, factors_prod a ▸ prod_mono (le_inf (factors_mono hac) (factors_mono hbc)),\n  inf_le_left  := assume a b,\n    le_trans (prod_mono inf_le_left) (le_of_eq (factors_prod a)),\n  inf_le_right := assume a b,\n    le_trans (prod_mono inf_le_right) (le_of_eq (factors_prod b)),\n  .. associates.partial_order }\n\nlemma sup_mul_inf (a b : associates α) : (a ⊔ b) * (a ⊓ b) = a * b :=\nshow (a.factors ⊔ b.factors).prod * (a.factors ⊓ b.factors).prod = a * b,\nbegin\n  nontriviality α,\n  refine eq_of_factors_eq_factors _,\n  rw [← prod_add, prod_factors, factors_mul, factor_set.sup_add_inf_eq_add]\nend\n\ninclude dec_irr\n\nlemma dvd_of_mem_factors {a p : associates α} {hp : irreducible p}\n  (hm : p ∈ factors a) : p ∣ a :=\nbegin\n  by_cases ha0 : a = 0, { rw ha0, exact dvd_zero p },\n  obtain ⟨a0, nza, ha'⟩ := exists_non_zero_rep ha0,\n  rw [← associates.factors_prod a],\n  rw [← ha', factors_mk a0 nza] at hm ⊢,\n  erw prod_coe,\n  apply multiset.dvd_prod, apply multiset.mem_map.mpr,\n  exact ⟨⟨p, hp⟩, mem_factor_set_some.mp hm, rfl⟩\nend\n\nomit dec'\n\nlemma dvd_of_mem_factors' {a : α} {p : associates α} {hp : irreducible p} {hz : a ≠ 0}\n  (h_mem : subtype.mk p hp ∈ factors' a) : p ∣ associates.mk a :=\nby { haveI := classical.dec_eq (associates α),\n  apply @dvd_of_mem_factors _ _ _ _ _ _ _ _ hp,\n  rw factors_mk _ hz,\n  apply mem_factor_set_some.2 h_mem }\n\nomit dec_irr\n\nlemma mem_factors'_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) (hd : p ∣ a) :\n  subtype.mk (associates.mk p) ((irreducible_mk _).2 hp) ∈ factors' a :=\nbegin\n  obtain ⟨q, hq, hpq⟩ := exists_mem_factors_of_dvd ha0 hp hd,\n  apply multiset.mem_pmap.mpr, use q, use hq,\n  exact subtype.eq (eq.symm (mk_eq_mk_iff_associated.mpr hpq))\nend\n\ninclude dec_irr\n\nlemma mem_factors'_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) :\n  subtype.mk (associates.mk p) ((irreducible_mk _).2 hp) ∈ factors' a ↔ p ∣ a :=\nbegin\n  split,\n  { rw ← mk_dvd_mk, apply dvd_of_mem_factors', apply ha0 },\n  { apply mem_factors'_of_dvd ha0 }\nend\n\ninclude dec'\n\nlemma mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) (hd : p ∣ a) :\n  (associates.mk p) ∈ factors (associates.mk a) :=\nbegin\n  rw factors_mk _ ha0, exact mem_factor_set_some.mpr (mem_factors'_of_dvd ha0 hp hd)\nend\n\nlemma mem_factors_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) :\n  (associates.mk p) ∈ factors (associates.mk a) ↔ p ∣ a :=\nbegin\n  split,\n  { rw ← mk_dvd_mk, apply dvd_of_mem_factors, exact (irreducible_mk p).mpr hp },\n  { apply mem_factors_of_dvd ha0 hp }\nend\n\nlemma exists_prime_dvd_of_not_inf_one {a b : α}\n  (ha : a ≠ 0) (hb : b ≠ 0) (h : (associates.mk a) ⊓ (associates.mk b) ≠ 1)  :\n  ∃ (p : α), prime p ∧ p ∣ a ∧ p ∣ b :=\nbegin\n  have hz : (factors (associates.mk a)) ⊓ (factors (associates.mk b)) ≠ 0,\n  { contrapose! h with hf,\n    change ((factors (associates.mk a)) ⊓ (factors (associates.mk b))).prod = 1,\n    rw hf,\n    exact multiset.prod_zero },\n  rw [factors_mk a ha, factors_mk b hb, ← with_top.coe_inf] at hz,\n  obtain ⟨⟨p0, p0_irr⟩, p0_mem⟩ := multiset.exists_mem_of_ne_zero ((mt with_top.coe_eq_coe.mpr) hz),\n  rw multiset.inf_eq_inter at p0_mem,\n  obtain ⟨p, rfl⟩ : ∃ p, associates.mk p = p0 := quot.exists_rep p0,\n  refine ⟨p, _, _, _⟩,\n  { rw [← irreducible_iff_prime, ← irreducible_mk],\n    exact p0_irr },\n  { apply dvd_of_mk_le_mk,\n    apply dvd_of_mem_factors' (multiset.mem_inter.mp p0_mem).left,\n    apply ha, },\n  { apply dvd_of_mk_le_mk,\n    apply dvd_of_mem_factors' (multiset.mem_inter.mp p0_mem).right,\n    apply hb }\nend\n\ntheorem coprime_iff_inf_one {a b : α} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :\n  (associates.mk a) ⊓ (associates.mk b) = 1 ↔ ∀ {d : α}, d ∣ a → d ∣ b → ¬ prime d :=\nbegin\n  split,\n  { intros hg p ha hb hp,\n    refine ((associates.prime_mk _).mpr hp).not_unit (is_unit_of_dvd_one _ _),\n    rw ← hg,\n    exact le_inf (mk_le_mk_of_dvd ha) (mk_le_mk_of_dvd hb) },\n  { contrapose,\n    intros hg hc,\n    obtain ⟨p, hp, hpa, hpb⟩ := exists_prime_dvd_of_not_inf_one ha0 hb0 hg,\n    exact hc hpa hpb hp }\nend\n\nomit dec_irr\n\ntheorem factors_self [nontrivial α] {p : associates α}  (hp : irreducible p) :\n  p.factors = some ({⟨p, hp⟩}) :=\neq_of_prod_eq_prod (by rw [factors_prod, factor_set.prod, map_singleton, prod_singleton,\n                            subtype.coe_mk])\n\ntheorem factors_prime_pow [nontrivial α] {p : associates α} (hp : irreducible p)\n  (k : ℕ) : factors (p ^ k) = some (multiset.repeat ⟨p, hp⟩ k) :=\neq_of_prod_eq_prod (by rw [associates.factors_prod, factor_set.prod, multiset.map_repeat,\n                           multiset.prod_repeat, subtype.coe_mk])\n\ninclude dec_irr\n\ntheorem prime_pow_dvd_iff_le [nontrivial α] {m p : associates α} (h₁ : m ≠ 0)\n  (h₂ : irreducible p) {k : ℕ} : p ^ k ≤ m ↔ k ≤ count p m.factors :=\nbegin\n  obtain ⟨a, nz, rfl⟩ := associates.exists_non_zero_rep h₁,\n  rw [factors_mk _ nz, ← with_top.some_eq_coe, count_some, multiset.le_count_iff_repeat_le,\n      ← factors_le, factors_prime_pow h₂, factors_mk _ nz],\n  exact with_top.coe_le_coe\nend\n\ntheorem le_of_count_ne_zero {m p : associates α} (h0 : m ≠ 0)\n  (hp : irreducible p) : count p m.factors ≠ 0 → p ≤ m :=\nbegin\n  nontriviality α,\n  rw [← pos_iff_ne_zero],\n  intro h,\n  rw [← pow_one p],\n  apply (prime_pow_dvd_iff_le h0 hp).2,\n  simpa only\nend\n\ntheorem count_ne_zero_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : irreducible p) :\n  (associates.mk p).count (associates.mk a).factors ≠ 0 ↔ p ∣ a :=\nbegin\n  nontriviality α,\n  rw ← associates.mk_le_mk_iff_dvd_iff,\n  refine ⟨λ h, associates.le_of_count_ne_zero (associates.mk_ne_zero.mpr ha0)\n    ((associates.irreducible_mk p).mpr hp) h, λ h, _⟩,\n  { rw [← pow_one (associates.mk p), associates.prime_pow_dvd_iff_le\n      (associates.mk_ne_zero.mpr ha0) ((associates.irreducible_mk p).mpr hp)] at h,\n    exact (zero_lt_one.trans_le h).ne' }\nend\n\ntheorem count_self [nontrivial α] {p : associates α} (hp : irreducible p) :\n  p.count p.factors = 1 :=\nby simp [factors_self hp, associates.count_some hp]\n\nlemma count_eq_zero_of_ne {p q : associates α} (hp : irreducible p) (hq : irreducible q)\n  (h : p ≠ q) : p.count q.factors = 0 :=\nnot_ne_iff.mp $ λ h', h $ associated_iff_eq.mp $ hp.associated_of_dvd hq $\nby { nontriviality α, exact le_of_count_ne_zero hq.ne_zero hp h' }\n\ntheorem count_mul {a : associates α} (ha : a ≠ 0) {b : associates α} (hb : b ≠ 0)\n  {p : associates α} (hp : irreducible p) :\n  count p (factors (a * b)) = count p a.factors + count p b.factors :=\nbegin\n  obtain ⟨a0, nza, ha'⟩ := exists_non_zero_rep ha,\n  obtain ⟨b0, nzb, hb'⟩ := exists_non_zero_rep hb,\n  rw [factors_mul, ← ha', ← hb', factors_mk a0 nza, factors_mk b0 nzb, ← factor_set.coe_add,\n      ← with_top.some_eq_coe, ← with_top.some_eq_coe, ← with_top.some_eq_coe, count_some hp,\n      multiset.count_add, count_some hp, count_some hp]\nend\n\ntheorem count_of_coprime {a : associates α} (ha : a ≠ 0) {b : associates α}\n  (hb : b ≠ 0)\n  (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) {p : associates α} (hp : irreducible p) :\n  count p a.factors = 0 ∨ count p b.factors = 0 :=\nbegin\n  rw [or_iff_not_imp_left, ← ne.def],\n  intro hca,\n  contrapose! hab with hcb,\n  exact ⟨p, le_of_count_ne_zero ha hp hca, le_of_count_ne_zero hb hp hcb,\n    (irreducible_iff_prime.mp hp)⟩,\nend\n\ntheorem count_mul_of_coprime {a : associates α} {b : associates α}\n  (hb : b ≠ 0)\n  {p : associates α} (hp : irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) :\n  count p a.factors = 0 ∨ count p a.factors = count p (a * b).factors :=\nbegin\n  by_cases ha : a = 0,\n  { simp [ha], },\n  cases count_of_coprime ha hb hab hp with hz hb0, { tauto },\n  apply or.intro_right,\n  rw [count_mul ha hb hp, hb0, add_zero]\nend\n\ntheorem count_mul_of_coprime' {a b : associates α}\n  {p : associates α} (hp : irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) :\n  count p (a * b).factors = count p a.factors\n  ∨ count p (a * b).factors = count p b.factors :=\nbegin\n  by_cases ha : a = 0, { simp [ha], },\n  by_cases hb : b = 0, { simp [hb], },\n  rw [count_mul ha hb hp],\n  cases count_of_coprime ha hb hab hp with ha0 hb0,\n  { apply or.intro_right, rw [ha0, zero_add] },\n  { apply or.intro_left, rw [hb0, add_zero] }\nend\n\ntheorem dvd_count_of_dvd_count_mul {a b : associates α} (hb : b ≠ 0)\n  {p : associates α} (hp : irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d)\n  {k : ℕ} (habk : k ∣ count p (a * b).factors) : k ∣ count p a.factors :=\nbegin\n  by_cases ha : a = 0, { simpa [*] using habk, },\n  cases count_of_coprime ha hb hab hp with hz h,\n  { rw hz, exact dvd_zero k },\n  { rw [count_mul ha hb hp, h] at habk, exact habk }\nend\n\nomit dec_irr\n\n@[simp] lemma factors_one [nontrivial α] : factors (1 : associates α) = 0 :=\nbegin\n  apply eq_of_prod_eq_prod,\n  rw associates.factors_prod,\n  exact multiset.prod_zero,\nend\n\n@[simp] theorem pow_factors [nontrivial α] {a : associates α} {k : ℕ} :\n  (a ^ k).factors = k • a.factors :=\nbegin\n  induction k with n h,\n  { rw [zero_nsmul, pow_zero], exact factors_one },\n  { rw [pow_succ, succ_nsmul, factors_mul, h] }\nend\n\ninclude dec_irr\n\nlemma count_pow [nontrivial α] {a : associates α} (ha : a ≠ 0) {p : associates α}\n  (hp : irreducible p)\n  (k : ℕ) : count p (a ^ k).factors = k * count p a.factors :=\nbegin\n  induction k with n h,\n  { rw [pow_zero, factors_one, zero_mul, count_zero hp] },\n  { rw [pow_succ, count_mul ha (pow_ne_zero _ ha) hp, h, nat.succ_eq_add_one], ring }\nend\n\ntheorem dvd_count_pow [nontrivial α] {a : associates α} (ha : a ≠ 0) {p : associates α}\n  (hp : irreducible p)\n  (k : ℕ) : k ∣ count p (a ^ k).factors := by { rw count_pow ha hp, apply dvd_mul_right }\n\ntheorem is_pow_of_dvd_count [nontrivial α] {a : associates α} (ha : a ≠ 0) {k : ℕ}\n  (hk : ∀ (p : associates α) (hp : irreducible p), k ∣ count p a.factors) :\n  ∃ (b : associates α), a = b ^ k :=\nbegin\n  obtain ⟨a0, hz, rfl⟩ := exists_non_zero_rep ha,\n  rw [factors_mk a0 hz] at hk,\n  have hk' : ∀ p, p ∈ (factors' a0) → k ∣ (factors' a0).count p,\n  { rintros p -,\n    have pp : p = ⟨p.val, p.2⟩, { simp only [subtype.coe_eta, subtype.val_eq_coe] },\n    rw [pp, ← count_some p.2], exact hk p.val p.2 },\n  obtain ⟨u, hu⟩ := multiset.exists_smul_of_dvd_count _ hk',\n  use (u : factor_set α).prod,\n  apply eq_of_factors_eq_factors,\n  rw [pow_factors, prod_factors, factors_mk a0 hz, ← with_top.some_eq_coe, hu],\n  exact with_bot.coe_nsmul u k\nend\n\n/-- The only divisors of prime powers are prime powers. See `eq_pow_find_of_dvd_irreducible_pow`\nfor an explicit expression as a p-power (without using `count`). -/\ntheorem eq_pow_count_factors_of_dvd_pow {p a : associates α} (hp : irreducible p)\n  {n : ℕ} (h : a ∣ p ^ n) : a = p ^ p.count a.factors :=\nbegin\n  nontriviality α,\n  have hph := pow_ne_zero n hp.ne_zero,\n  have ha := ne_zero_of_dvd_ne_zero hph h,\n  apply eq_of_eq_counts ha (pow_ne_zero _ hp.ne_zero),\n  have eq_zero_of_ne : ∀ (q : associates α), irreducible q → q ≠ p → _ = 0 :=\n  λ q hq h', nat.eq_zero_of_le_zero $ by\n  { convert count_le_count_of_le hph hq h, symmetry,\n    rw [count_pow hp.ne_zero hq, count_eq_zero_of_ne hq hp h', mul_zero] },\n  intros q hq,\n  rw count_pow hp.ne_zero hq,\n  by_cases h : q = p,\n  { rw [h, count_self hp, mul_one] },\n  { rw [count_eq_zero_of_ne hq hp h, mul_zero, eq_zero_of_ne q hq h] }\nend\n\nlemma count_factors_eq_find_of_dvd_pow {a p : associates α} (hp : irreducible p)\n  [∀ n : ℕ, decidable (a ∣ p ^ n)] {n : ℕ} (h : a ∣ p ^ n) : nat.find ⟨n, h⟩ = p.count a.factors :=\nbegin\n  apply le_antisymm,\n  { refine nat.find_le ⟨1, _⟩, rw mul_one, symmetry, exact eq_pow_count_factors_of_dvd_pow hp h },\n  { have hph := pow_ne_zero (nat.find ⟨n, h⟩) hp.ne_zero,\n    casesI (subsingleton_or_nontrivial α) with hα hα,\n    { simpa using hph, },\n    convert count_le_count_of_le hph hp (nat.find_spec ⟨n, h⟩),\n    rw [count_pow hp.ne_zero hp, count_self hp, mul_one] }\nend\n\nomit dec\nomit dec_irr\nomit dec'\n\ntheorem eq_pow_of_mul_eq_pow [nontrivial α] {a b c : associates α} (ha : a ≠ 0) (hb : b ≠ 0)\n  (hab : ∀ d, d ∣ a → d ∣ b → ¬ prime d) {k : ℕ} (h : a * b = c ^ k) :\n  ∃ (d : associates α), a = d ^ k :=\nbegin\n  classical,\n  by_cases hk0 : k = 0,\n  { use 1,\n    rw [hk0, pow_zero] at h ⊢,\n    apply (mul_eq_one_iff.1 h).1 },\n  { refine is_pow_of_dvd_count ha _,\n    intros p hp,\n    apply dvd_count_of_dvd_count_mul hb hp hab,\n    rw h,\n    apply dvd_count_pow _ hp,\n    rintros rfl,\n    rw zero_pow' _ hk0 at h,\n    cases mul_eq_zero.mp h; contradiction }\nend\n\n/-- The only divisors of prime powers are prime powers. -/\ntheorem eq_pow_find_of_dvd_irreducible_pow {a p : associates α} (hp : irreducible p)\n  [∀ n : ℕ, decidable (a ∣ p ^ n)] {n : ℕ} (h : a ∣ p ^ n) : a = p ^ nat.find ⟨n, h⟩ :=\nby { classical, rw [count_factors_eq_find_of_dvd_pow hp, ← eq_pow_count_factors_of_dvd_pow hp h] }\n\nend associates\n\nsection\nopen associates unique_factorization_monoid\n\nlemma associates.quot_out {α : Type*} [comm_monoid α] (a : associates α):\nassociates.mk (quot.out (a)) = a :=\nby rw [←quot_mk_eq_mk, quot.out_eq]\n\n/-- `to_gcd_monoid` constructs a GCD monoid out of a unique factorization domain. -/\nnoncomputable def unique_factorization_monoid.to_gcd_monoid\n  (α : Type*) [cancel_comm_monoid_with_zero α] [unique_factorization_monoid α]\n  [decidable_eq (associates α)] [decidable_eq α] : gcd_monoid α :=\n{ gcd := λa b, quot.out (associates.mk a ⊓ associates.mk b : associates α),\n  lcm := λa b, quot.out (associates.mk a ⊔ associates.mk b : associates α),\n  gcd_dvd_left := λ a b, by\n  { rw [←mk_dvd_mk, (associates.mk a ⊓ associates.mk b).quot_out, dvd_eq_le],\n    exact inf_le_left },\n  gcd_dvd_right := λ a b, by\n  { rw [←mk_dvd_mk, (associates.mk a ⊓ associates.mk b).quot_out, dvd_eq_le],\n    exact inf_le_right },\n  dvd_gcd := λ a b c hac hab, by\n  { rw [←mk_dvd_mk, (associates.mk c ⊓ associates.mk b).quot_out, dvd_eq_le,\n      le_inf_iff, mk_le_mk_iff_dvd_iff, mk_le_mk_iff_dvd_iff],\n    exact ⟨hac, hab⟩ },\n  lcm_zero_left := λ a, by\n  { have : associates.mk (0 : α) = ⊤ := rfl,\n    rw [this, top_sup_eq, ←this, ←associated_zero_iff_eq_zero, ←mk_eq_mk_iff_associated,\n      ←associated_iff_eq, associates.quot_out] },\n  lcm_zero_right := λ a, by\n  { have : associates.mk (0 : α) = ⊤ := rfl,\n    rw [this, sup_top_eq, ←this, ←associated_zero_iff_eq_zero, ←mk_eq_mk_iff_associated,\n      ←associated_iff_eq, associates.quot_out] },\n  gcd_mul_lcm := λ a b, by\n  { rw [←mk_eq_mk_iff_associated, ←associates.mk_mul_mk, ←associated_iff_eq, associates.quot_out,\n      associates.quot_out, mul_comm, sup_mul_inf, associates.mk_mul_mk] } }\n\n/-- `to_normalized_gcd_monoid` constructs a GCD monoid out of a normalization on a\n  unique factorization domain. -/\nnoncomputable def unique_factorization_monoid.to_normalized_gcd_monoid\n  (α : Type*) [cancel_comm_monoid_with_zero α] [unique_factorization_monoid α]\n  [normalization_monoid α] [decidable_eq (associates α)] [decidable_eq α] :\n  normalized_gcd_monoid α :=\n{ gcd := λa b, (associates.mk a ⊓ associates.mk b).out,\n  lcm := λa b, (associates.mk a ⊔ associates.mk b).out,\n  gcd_dvd_left := assume a b, (out_dvd_iff a (associates.mk a ⊓ associates.mk b)).2 $ inf_le_left,\n  gcd_dvd_right := assume a b, (out_dvd_iff b (associates.mk a ⊓ associates.mk b)).2 $ inf_le_right,\n  dvd_gcd := assume a b c hac hab, show a ∣ (associates.mk c ⊓ associates.mk b).out,\n    by rw [dvd_out_iff, le_inf_iff, mk_le_mk_iff_dvd_iff, mk_le_mk_iff_dvd_iff]; exact ⟨hac, hab⟩,\n  lcm_zero_left := assume a, show (⊤ ⊔ associates.mk a).out = 0, by simp,\n  lcm_zero_right := assume a, show (associates.mk a ⊔ ⊤).out = 0, by simp,\n  gcd_mul_lcm := assume a b, by\n  { rw [← out_mul, mul_comm, sup_mul_inf, mk_mul_mk, out_mk],\n    exact normalize_associated (a * b) },\n  normalize_gcd := assume a b, by convert normalize_out _,\n  normalize_lcm := assume a b, by convert normalize_out _,\n  .. ‹normalization_monoid α› }\n\nend\n\nnamespace unique_factorization_monoid\n\n/-- If `y` is a nonzero element of a unique factorization monoid with finitely\nmany units (e.g. `ℤ`, `ideal (ring_of_integers K)`), it has finitely many divisors. -/\nnoncomputable def fintype_subtype_dvd {M : Type*} [cancel_comm_monoid_with_zero M]\n  [unique_factorization_monoid M] [fintype Mˣ]\n  (y : M) (hy : y ≠ 0) :\n  fintype {x // x ∣ y} :=\nbegin\n  haveI : nontrivial M := ⟨⟨y, 0, hy⟩⟩,\n  haveI : normalization_monoid M := unique_factorization_monoid.normalization_monoid,\n  haveI := classical.dec_eq M,\n  haveI := classical.dec_eq (associates M),\n  -- We'll show `λ (u : Mˣ) (f ⊆ factors y) → u * Π f` is injective\n  -- and has image exactly the divisors of `y`.\n  refine fintype.of_finset\n    (((normalized_factors y).powerset.to_finset.product (finset.univ : finset Mˣ)).image\n      (λ s, (s.snd : M) * s.fst.prod))\n    (λ x, _),\n  simp only [exists_prop, finset.mem_image, finset.mem_product, finset.mem_univ, and_true,\n    multiset.mem_to_finset, multiset.mem_powerset, exists_eq_right, multiset.mem_map],\n  split,\n  { rintros ⟨s, hs, rfl⟩,\n    have prod_s_ne : s.fst.prod ≠ 0,\n    { intro hz,\n      apply hy (eq_zero_of_zero_dvd _),\n      have hz := (@multiset.prod_eq_zero_iff M _ _ _ s.fst).mp hz,\n      rw ← (normalized_factors_prod hy).dvd_iff_dvd_right,\n      exact multiset.dvd_prod (multiset.mem_of_le hs hz) },\n    show (s.snd : M) * s.fst.prod ∣ y,\n    rw [(unit_associated_one.mul_right s.fst.prod).dvd_iff_dvd_left, one_mul,\n        ← (normalized_factors_prod hy).dvd_iff_dvd_right],\n    exact multiset.prod_dvd_prod_of_le hs },\n  { rintro (h : x ∣ y),\n    have hx : x ≠ 0, { refine mt (λ hx, _) hy, rwa [hx, zero_dvd_iff] at h },\n    obtain ⟨u, hu⟩ := normalized_factors_prod hx,\n    refine ⟨⟨normalized_factors x, u⟩, _, (mul_comm _ _).trans hu⟩,\n    exact (dvd_iff_normalized_factors_le_normalized_factors hx hy).mp h }\nend\n\nend unique_factorization_monoid\n\nsection finsupp\nvariables [cancel_comm_monoid_with_zero α] [unique_factorization_monoid α]\nvariables [normalization_monoid α] [decidable_eq α]\n\nopen unique_factorization_monoid\n\n/-- This returns the multiset of irreducible factors as a `finsupp` -/\nnoncomputable def factorization (n : α) : α →₀ ℕ := (normalized_factors n).to_finsupp\n\nlemma factorization_eq_count {n p : α} :\n  factorization n p = multiset.count p (normalized_factors n) :=\nby simp [factorization]\n\n@[simp] lemma factorization_zero : factorization (0 : α) = 0 := by simp [factorization]\n\n@[simp] lemma factorization_one : factorization (1 : α) = 0 := by simp [factorization]\n\n/-- The support of `factorization n` is exactly the finset of normalized factors -/\n@[simp] lemma support_factorization {n : α} :\n  (factorization n).support = (normalized_factors n).to_finset :=\nby simp [factorization, multiset.to_finsupp_support]\n\n/-- For nonzero `a` and `b`, the power of `p` in `a * b` is the sum of the powers in `a` and `b` -/\n@[simp] lemma factorization_mul {a b : α} (ha : a ≠ 0) (hb : b ≠ 0) :\n  factorization (a * b) = factorization a + factorization b :=\nby simp [factorization, normalized_factors_mul ha hb]\n\n/-- For any `p`, the power of `p` in `x^n` is `n` times the power in `x` -/\nlemma factorization_pow {x : α} {n : ℕ} :\n  factorization (x^n) = n • factorization x :=\nby { ext, simp [factorization] }\n\nlemma associated_of_factorization_eq (a b: α) (ha: a ≠ 0) (hb: b ≠ 0)\n  (h: factorization a = factorization b) : associated a b :=\nbegin\n  simp only [factorization, add_equiv.apply_eq_iff_eq] at h,\n  have ha' := normalized_factors_prod ha,\n  rw h at ha',\n  exact associated.trans ha'.symm (normalized_factors_prod hb),\nend\n\nend finsupp\n", "meta": {"author": "lean-forward", "repo": "class-number-journal", "sha": "34d5872618d289ca3982bd9bc0c6e06af678909a", "save_path": "github-repos/lean/lean-forward-class-number-journal", "path": "github-repos/lean/lean-forward-class-number-journal/class-number-journal-34d5872618d289ca3982bd9bc0c6e06af678909a/src/unique_factorization_domain.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4813417747217647}}
{"text": "import tactic.interactive\nimport data.nat.basic\n\nvariables (p : ℕ → Prop) (a b : ℕ)\n\nexample (h : p (a + b)) : p (b + a) :=\nbegin\n  rw add_comm,\n  -- `guard_target` fails because the instances don't match\n  success_if_fail { guard_target p (a + b) },\n  guard_target_mod_implicit p (a + b),\n  assumption\nend\n\nexample (h : p (b + a)) : p (a + b) :=\nbegin\n  rw add_comm at h,\n  -- `guard_hyp` fails because the instances don't match\n  success_if_fail { guard_hyp h : p (a + b) },\n  guard_hyp_mod_implicit h : p (a + b),\n  assumption\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/mod_implicit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.4813417582477522}}
{"text": "/-\nCopyright (c) 2022 Youjack. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Youjack\n-/\nimport data.real.nnreal\nimport data.finsupp.basic\n\n/-!\n# Some math lemmas\n\n## Notations\n\nThis file defines the notation `ℝ₊` for positive real numbers `{c : ℝ // 0 < c}`.\n-/\n\nsection real\n\n@[reducible] def posreal := {c : ℝ // 0 < c}\nnotation `ℝ₊` := posreal\nnamespace posreal\ninstance coe_nnreal : has_coe ℝ₊ nnreal := ⟨λ c, ⟨c.val, le_of_lt c.property⟩⟩\nlemma ne_zero (c : ℝ₊) : (c:ℝ) ≠ 0 := by { rw ←subtype.val_eq_coe, exact ne_of_gt c.property }\nend posreal\n\nlemma real.max_mul_nonneg_zero (c x : ℝ) (hc : 0 ≤ c) : max (c * x) 0 = c * (max x 0) :=\n  if hx : 0 ≤ x then by {\n    have : max (c * x) 0 = c * x, from max_eq_left (mul_nonneg hc hx), rw this,\n    have : max      x  0 =     x, from max_eq_left hx                , rw this, }\n  else by {\n    have hx := le_of_lt (not_le.elim_left hx),\n    have : max (c * x) 0 = 0, from\n      max_eq_right (mul_nonpos_iff.elim_right (or.inl ⟨hc, hx⟩)), rw this,\n    have : max      x  0 = 0, from max_eq_right hx, rw this,\n    rw mul_zero, }\n--\n\nend real\n\nnamespace finsupp\nopen finset\n\nvariables {α : Type*} [decidable_eq α]\nvariables {R : Type*} [decidable_eq R] [semiring R] [no_zero_smul_divisors R R]\nvariables {f g : α →₀ R}\n\n@[reducible] def sum_image (f : α →₀ R) := f.support.sum f\nlemma extend_support_sum_iamge {s : finset α}\n  (s_extend_supp : f.support ⊆ s) : s.sum f = f.sum_image := by {\n  rw ←sum_sdiff s_extend_supp,\n  simp only [sum_image],\n  suffices : (s \\ f.support).sum f = 0,\n    rw [this, zero_add],\n  apply sum_eq_zero, assume x hx,\n  simp only [mem_sdiff, mem_support_iff, not_not] at hx,\n  exact hx.elim_right, }\nlemma sum_image_add : (f + g).sum_image = f.sum_image + g.sum_image := by {\n  let s := f.support ∪ g.support,\n  have : (f + g).support ⊆ s, from support_add           , rw ←extend_support_sum_iamge this,\n  have :  f     .support ⊆ s, from subset_union_left  _ _, rw ←extend_support_sum_iamge this,\n  have :      g .support ⊆ s, from subset_union_right _ _, rw ←extend_support_sum_iamge this,\n  exact finset.sum_add_distrib, }\nlemma sum_image_smul {c : R} : (c • f).sum_image = c • f.sum_image :=\n  if hc : c = 0 then by\n    simp [hc, sum_image]\n  else by {\n    unfold sum_image,\n    have : (c • f).support = f.support, from support_smul_eq hc, rw this,\n    simp [finset.smul_sum], }\n--\n\nlemma support_add_exact {supp : finset α}\n  (non_zero_on_supp   : ∀ x ∈ supp                           , f x + g x ≠ 0)\n  (zero_on_sdiff_supp : ∀ x ∈ (f.support ∪ g.support) \\ supp, f x + g x = 0) :\n  (f + g).support = supp := by {\n  ext x, split,\n  { apply function.mtr,\n    assume hx_supp,\n    exact if hx_union : x ∈ (f.support ∪ g.support) then by {\n      simp only [mem_support_iff, coe_add, pi.add_apply, not_not],\n      exact zero_on_sdiff_supp x (mem_sdiff.elim_right ⟨hx_union, hx_supp⟩), }\n    else by {\n      have : (f + g).support ⊆ (f.support ∪ g.support), from support_add,\n      exact not_mem_mono this hx_union, } },\n  { simp only [mem_support_iff, coe_add, pi.add_apply],\n    exact non_zero_on_supp x, } }\n--\n\nlemma support_smul_exact {c : R} {supp : finset α}\n  (supp_is_supp : f.support = supp)\n  (non_zero_smul : c ≠ 0) :\n  (c • f).support = supp := by {\n  rw ←supp_is_supp,\n  exact support_smul_eq non_zero_smul, }\n--\n\nend finsupp\n", "meta": {"author": "Youjack", "repo": "thermodynamics.lean", "sha": "4af0748a97e6cb89aef0c87425872d1a901e8c55", "save_path": "github-repos/lean/Youjack-thermodynamics.lean", "path": "github-repos/lean/Youjack-thermodynamics.lean/thermodynamics.lean-4af0748a97e6cb89aef0c87425872d1a901e8c55/src/math_lemma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584174871563662, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.48134175230567255}}
{"text": "/-\nCopyright (c) 2014 Robert Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn\n\n! This file was ported from Lean 3 source module algebra.order.field.power\n! leanprover-community/mathlib commit acb3d204d4ee883eb686f45d486a2a6811a01329\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Parity\nimport Mathbin.Algebra.CharZero.Lemmas\nimport Mathbin.Algebra.GroupWithZero.Power\nimport Mathbin.Algebra.Order.Field.Basic\n\n/-!\n# Lemmas about powers in ordered fields.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nvariable {α : Type _}\n\nopen Function\n\nsection LinearOrderedSemifield\n\nvariable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ}\n\n/-! ### Integer powers -/\n\n\n#print zpow_le_of_le /-\ntheorem zpow_le_of_le (ha : 1 ≤ a) (h : m ≤ n) : a ^ m ≤ a ^ n :=\n  by\n  have ha₀ : 0 < a := one_pos.trans_le ha\n  lift n - m to ℕ using sub_nonneg.2 h with k hk\n  calc\n    a ^ m = a ^ m * 1 := (mul_one _).symm\n    _ ≤ a ^ m * a ^ k :=\n      (mul_le_mul_of_nonneg_left (one_le_pow_of_one_le ha _) (zpow_nonneg ha₀.le _))\n    _ = a ^ n := by rw [← zpow_ofNat, ← zpow_add₀ ha₀.ne', hk, add_sub_cancel'_right]\n    \n#align zpow_le_of_le zpow_le_of_le\n-/\n\n#print zpow_le_one_of_nonpos /-\ntheorem zpow_le_one_of_nonpos (ha : 1 ≤ a) (hn : n ≤ 0) : a ^ n ≤ 1 :=\n  (zpow_le_of_le ha hn).trans_eq <| zpow_zero _\n#align zpow_le_one_of_nonpos zpow_le_one_of_nonpos\n-/\n\n#print one_le_zpow_of_nonneg /-\ntheorem one_le_zpow_of_nonneg (ha : 1 ≤ a) (hn : 0 ≤ n) : 1 ≤ a ^ n :=\n  (zpow_zero _).symm.trans_le <| zpow_le_of_le ha hn\n#align one_le_zpow_of_nonneg one_le_zpow_of_nonneg\n-/\n\n/- warning: nat.zpow_pos_of_pos -> Nat.zpow_pos_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) a) -> (forall (n : Int), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) a) n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) a) -> (forall (n : Int), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) a) n))\nCase conversion may be inaccurate. Consider using '#align nat.zpow_pos_of_pos Nat.zpow_pos_of_posₓ'. -/\nprotected theorem Nat.zpow_pos_of_pos {a : ℕ} (h : 0 < a) (n : ℤ) : 0 < (a : α) ^ n :=\n  by\n  apply zpow_pos_of_pos\n  exact_mod_cast h\n#align nat.zpow_pos_of_pos Nat.zpow_pos_of_pos\n\n/- warning: nat.zpow_ne_zero_of_pos -> Nat.zpow_ne_zero_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) a) -> (forall (n : Int), Ne.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) a) n) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) a) -> (forall (n : Int), Ne.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) a) n) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align nat.zpow_ne_zero_of_pos Nat.zpow_ne_zero_of_posₓ'. -/\ntheorem Nat.zpow_ne_zero_of_pos {a : ℕ} (h : 0 < a) (n : ℤ) : (a : α) ^ n ≠ 0 :=\n  (Nat.zpow_pos_of_pos h n).ne'\n#align nat.zpow_ne_zero_of_pos Nat.zpow_ne_zero_of_pos\n\n#print one_lt_zpow /-\ntheorem one_lt_zpow (ha : 1 < a) : ∀ n : ℤ, 0 < n → 1 < a ^ n\n  | (n : ℕ), h => (zpow_ofNat _ _).symm.subst (one_lt_pow ha <| Int.coe_nat_ne_zero.mp h.ne')\n  | -[n+1], h => ((Int.negSucc_not_pos _).mp h).elim\n#align one_lt_zpow one_lt_zpow\n-/\n\n#print zpow_strictMono /-\ntheorem zpow_strictMono (hx : 1 < a) : StrictMono ((· ^ ·) a : ℤ → α) :=\n  strictMono_int_of_lt_succ fun n =>\n    have xpos : 0 < a := zero_lt_one.trans hx\n    calc\n      a ^ n < a ^ n * a := lt_mul_of_one_lt_right (zpow_pos_of_pos xpos _) hx\n      _ = a ^ (n + 1) := (zpow_add_one₀ xpos.ne' _).symm\n      \n#align zpow_strict_mono zpow_strictMono\n-/\n\n/- warning: zpow_strict_anti -> zpow_strictAnti is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))))))) -> (StrictAnti.{0, u1} Int α (PartialOrder.toPreorder.{0} Int (OrderedAddCommGroup.toPartialOrder.{0} Int (StrictOrderedRing.toOrderedAddCommGroup.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing))))) (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) -> (StrictAnti.{0, u1} Int α (PartialOrder.toPreorder.{0} Int (StrictOrderedRing.toPartialOrder.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing)))) (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) ((fun (x._@.Mathlib.Algebra.Order.Field.Power._hyg.671 : α) (x._@.Mathlib.Algebra.Order.Field.Power._hyg.673 : Int) => HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x._@.Mathlib.Algebra.Order.Field.Power._hyg.671 x._@.Mathlib.Algebra.Order.Field.Power._hyg.673) a))\nCase conversion may be inaccurate. Consider using '#align zpow_strict_anti zpow_strictAntiₓ'. -/\ntheorem zpow_strictAnti (h₀ : 0 < a) (h₁ : a < 1) : StrictAnti ((· ^ ·) a : ℤ → α) :=\n  strictAnti_int_of_succ_lt fun n =>\n    calc\n      a ^ (n + 1) = a ^ n * a := zpow_add_one₀ h₀.ne' _\n      _ < a ^ n * 1 := ((mul_lt_mul_left <| zpow_pos_of_pos h₀ _).2 h₁)\n      _ = a ^ n := mul_one _\n      \n#align zpow_strict_anti zpow_strictAnti\n\n#print zpow_lt_iff_lt /-\n@[simp]\ntheorem zpow_lt_iff_lt (hx : 1 < a) : a ^ m < a ^ n ↔ m < n :=\n  (zpow_strictMono hx).lt_iff_lt\n#align zpow_lt_iff_lt zpow_lt_iff_lt\n-/\n\n#print zpow_le_iff_le /-\n@[simp]\ntheorem zpow_le_iff_le (hx : 1 < a) : a ^ m ≤ a ^ n ↔ m ≤ n :=\n  (zpow_strictMono hx).le_iff_le\n#align zpow_le_iff_le zpow_le_iff_le\n-/\n\n/- warning: div_pow_le -> div_pow_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) b) -> (forall (k : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) b k)) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (forall (k : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) b k)) a)\nCase conversion may be inaccurate. Consider using '#align div_pow_le div_pow_leₓ'. -/\n@[simp]\ntheorem div_pow_le (ha : 0 ≤ a) (hb : 1 ≤ b) (k : ℕ) : a / b ^ k ≤ a :=\n  div_le_self ha <| one_le_pow_of_one_le hb _\n#align div_pow_le div_pow_le\n\n/- warning: zpow_injective -> zpow_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) a) -> (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))))))) -> (Function.Injective.{1, succ u1} Int α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) -> (Function.Injective.{1, succ u1} Int α ((fun (x._@.Mathlib.Algebra.Order.Field.Power._hyg.925 : α) (x._@.Mathlib.Algebra.Order.Field.Power._hyg.927 : Int) => HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x._@.Mathlib.Algebra.Order.Field.Power._hyg.925 x._@.Mathlib.Algebra.Order.Field.Power._hyg.927) a))\nCase conversion may be inaccurate. Consider using '#align zpow_injective zpow_injectiveₓ'. -/\ntheorem zpow_injective (h₀ : 0 < a) (h₁ : a ≠ 1) : Injective ((· ^ ·) a : ℤ → α) :=\n  by\n  rcases h₁.lt_or_lt with (H | H)\n  · exact (zpow_strictAnti h₀ H).Injective\n  · exact (zpow_strictMono H).Injective\n#align zpow_injective zpow_injective\n\n/- warning: zpow_inj -> zpow_inj is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {m : Int} {n : Int}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) a) -> (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))))))) -> (Iff (Eq.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a m) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a n)) (Eq.{1} Int m n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {m : Int} {n : Int}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) -> (Iff (Eq.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a m) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a n)) (Eq.{1} Int m n))\nCase conversion may be inaccurate. Consider using '#align zpow_inj zpow_injₓ'. -/\n@[simp]\ntheorem zpow_inj (h₀ : 0 < a) (h₁ : a ≠ 1) : a ^ m = a ^ n ↔ m = n :=\n  (zpow_injective h₀ h₁).eq_iff\n#align zpow_inj zpow_inj\n\n/- warning: zpow_le_max_of_min_le -> zpow_le_max_of_min_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {x : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) x) -> (forall {a : Int} {b : Int} {c : Int}, (LE.le.{0} Int Int.hasLe (LinearOrder.min.{0} Int Int.linearOrder a b) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg c)) (LinearOrder.max.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg a)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg b)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {x : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x) -> (forall {a : Int} {b : Int} {c : Int}, (LE.le.{0} Int Int.instLEInt (Min.min.{0} Int Int.instMinInt a b) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt c)) (Max.max.{u1} α (LinearOrderedCommSemiring.toMax.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt a)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt b)))))\nCase conversion may be inaccurate. Consider using '#align zpow_le_max_of_min_le zpow_le_max_of_min_leₓ'. -/\ntheorem zpow_le_max_of_min_le {x : α} (hx : 1 ≤ x) {a b c : ℤ} (h : min a b ≤ c) :\n    x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) :=\n  haveI : Antitone fun n : ℤ => x ^ (-n) := fun m n h => zpow_le_of_le hx (neg_le_neg h)\n  (this h).trans_eq this.map_min\n#align zpow_le_max_of_min_le zpow_le_max_of_min_le\n\n/- warning: zpow_le_max_iff_min_le -> zpow_le_max_iff_min_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {x : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) x) -> (forall {a : Int} {b : Int} {c : Int}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg c)) (LinearOrder.max.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg a)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg b)))) (LE.le.{0} Int Int.hasLe (LinearOrder.min.{0} Int Int.linearOrder a b) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {x : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x) -> (forall {a : Int} {b : Int} {c : Int}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt c)) (Max.max.{u1} α (LinearOrderedCommSemiring.toMax.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt a)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt b)))) (LE.le.{0} Int Int.instLEInt (Min.min.{0} Int Int.instMinInt a b) c))\nCase conversion may be inaccurate. Consider using '#align zpow_le_max_iff_min_le zpow_le_max_iff_min_leₓ'. -/\ntheorem zpow_le_max_iff_min_le {x : α} (hx : 1 < x) {a b c : ℤ} :\n    x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) ↔ min a b ≤ c := by\n  simp_rw [le_max_iff, min_le_iff, zpow_le_iff_le hx, neg_le_neg_iff]\n#align zpow_le_max_iff_min_le zpow_le_max_iff_min_le\n\nend LinearOrderedSemifield\n\nsection LinearOrderedField\n\nvariable [LinearOrderedField α] {a b c d : α} {n : ℤ}\n\n/-! ### Lemmas about powers to numerals. -/\n\n\n/- warning: zpow_bit0_nonneg -> zpow_bit0_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α) (n : Int), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.hasAdd n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α) (n : Int), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.instAddInt n))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_nonneg zpow_bit0_nonnegₓ'. -/\ntheorem zpow_bit0_nonneg (a : α) (n : ℤ) : 0 ≤ a ^ bit0 n :=\n  (mul_self_nonneg _).trans_eq <| (zpow_bit0 _ _).symm\n#align zpow_bit0_nonneg zpow_bit0_nonneg\n\n/- warning: zpow_two_nonneg -> zpow_two_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)))\nCase conversion may be inaccurate. Consider using '#align zpow_two_nonneg zpow_two_nonnegₓ'. -/\ntheorem zpow_two_nonneg (a : α) : 0 ≤ a ^ (2 : ℤ) :=\n  zpow_bit0_nonneg _ _\n#align zpow_two_nonneg zpow_two_nonneg\n\n/- warning: zpow_neg_two_nonneg -> zpow_neg_two_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (Neg.neg.{0} Int Int.hasNeg (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (Neg.neg.{0} Int Int.instNegInt (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))))\nCase conversion may be inaccurate. Consider using '#align zpow_neg_two_nonneg zpow_neg_two_nonnegₓ'. -/\ntheorem zpow_neg_two_nonneg (a : α) : 0 ≤ a ^ (-2 : ℤ) :=\n  zpow_bit0_nonneg _ (-1)\n#align zpow_neg_two_nonneg zpow_neg_two_nonneg\n\n/- warning: zpow_bit0_pos -> zpow_bit0_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) -> (forall (n : Int), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.hasAdd n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (forall (n : Int), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.instAddInt n)))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_pos zpow_bit0_posₓ'. -/\ntheorem zpow_bit0_pos (h : a ≠ 0) (n : ℤ) : 0 < a ^ bit0 n :=\n  (zpow_bit0_nonneg a n).lt_of_ne (zpow_ne_zero _ h).symm\n#align zpow_bit0_pos zpow_bit0_pos\n\n/- warning: zpow_two_pos_of_ne_zero -> zpow_two_pos_of_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))))\nCase conversion may be inaccurate. Consider using '#align zpow_two_pos_of_ne_zero zpow_two_pos_of_ne_zeroₓ'. -/\ntheorem zpow_two_pos_of_ne_zero (h : a ≠ 0) : 0 < a ^ (2 : ℤ) :=\n  zpow_bit0_pos h _\n#align zpow_two_pos_of_ne_zero zpow_two_pos_of_ne_zero\n\n/- warning: zpow_bit0_pos_iff -> zpow_bit0_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.hasAdd n))) (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.instAddInt n))) (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_pos_iff zpow_bit0_pos_iffₓ'. -/\n@[simp]\ntheorem zpow_bit0_pos_iff (hn : n ≠ 0) : 0 < a ^ bit0 n ↔ a ≠ 0 :=\n  ⟨by\n    rintro h rfl\n    refine' (zero_zpow _ _).not_gt h\n    rwa [bit0_ne_zero], fun h => zpow_bit0_pos h _⟩\n#align zpow_bit0_pos_iff zpow_bit0_pos_iff\n\n/- warning: zpow_bit1_neg_iff -> zpow_bit1_neg_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_neg_iff zpow_bit1_neg_iffₓ'. -/\n@[simp]\ntheorem zpow_bit1_neg_iff : a ^ bit1 n < 0 ↔ a < 0 :=\n  ⟨fun h => not_le.1 fun h' => not_le.2 h <| zpow_nonneg h' _, fun h => by\n    rw [bit1, zpow_add_one₀ h.ne] <;> exact mul_neg_of_pos_of_neg (zpow_bit0_pos h.ne _) h⟩\n#align zpow_bit1_neg_iff zpow_bit1_neg_iff\n\n/- warning: zpow_bit1_nonneg_iff -> zpow_bit1_nonneg_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a)\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_nonneg_iff zpow_bit1_nonneg_iffₓ'. -/\n@[simp]\ntheorem zpow_bit1_nonneg_iff : 0 ≤ a ^ bit1 n ↔ 0 ≤ a :=\n  le_iff_le_iff_lt_iff_lt.2 zpow_bit1_neg_iff\n#align zpow_bit1_nonneg_iff zpow_bit1_nonneg_iff\n\n/- warning: zpow_bit1_nonpos_iff -> zpow_bit1_nonpos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_nonpos_iff zpow_bit1_nonpos_iffₓ'. -/\n@[simp]\ntheorem zpow_bit1_nonpos_iff : a ^ bit1 n ≤ 0 ↔ a ≤ 0 := by\n  rw [le_iff_lt_or_eq, le_iff_lt_or_eq, zpow_bit1_neg_iff, zpow_eq_zero_iff (Int.bit1_ne_zero n)]\n#align zpow_bit1_nonpos_iff zpow_bit1_nonpos_iff\n\n/- warning: zpow_bit1_pos_iff -> zpow_bit1_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a)\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_pos_iff zpow_bit1_pos_iffₓ'. -/\n@[simp]\ntheorem zpow_bit1_pos_iff : 0 < a ^ bit1 n ↔ 0 < a :=\n  lt_iff_lt_of_le_iff_le zpow_bit1_nonpos_iff\n#align zpow_bit1_pos_iff zpow_bit1_pos_iff\n\n/- warning: even.zpow_nonneg -> Even.zpow_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {n : Int}, (Even.{0} Int Int.hasAdd n) -> (forall (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {n : Int}, (Even.{0} Int Int.instAddInt n) -> (forall (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n))\nCase conversion may be inaccurate. Consider using '#align even.zpow_nonneg Even.zpow_nonnegₓ'. -/\nprotected theorem Even.zpow_nonneg (hn : Even n) (a : α) : 0 ≤ a ^ n := by\n  obtain ⟨k, rfl⟩ := hn <;> exact zpow_bit0_nonneg _ _\n#align even.zpow_nonneg Even.zpow_nonneg\n\n/- warning: even.zpow_pos_iff -> Even.zpow_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Even.{0} Int Int.hasAdd n) -> (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n)) (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Even.{0} Int Int.instAddInt n) -> (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n)) (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align even.zpow_pos_iff Even.zpow_pos_iffₓ'. -/\ntheorem Even.zpow_pos_iff (hn : Even n) (h : n ≠ 0) : 0 < a ^ n ↔ a ≠ 0 := by\n  obtain ⟨k, rfl⟩ := hn <;> exact zpow_bit0_pos_iff (by rintro rfl <;> simpa using h)\n#align even.zpow_pos_iff Even.zpow_pos_iff\n\n/- warning: odd.zpow_neg_iff -> Odd.zpow_neg_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_neg_iff Odd.zpow_neg_iffₓ'. -/\ntheorem Odd.zpow_neg_iff (hn : Odd n) : a ^ n < 0 ↔ a < 0 := by\n  cases' hn with k hk <;> simpa only [hk, two_mul] using zpow_bit1_neg_iff\n#align odd.zpow_neg_iff Odd.zpow_neg_iff\n\n/- warning: odd.zpow_nonneg_iff -> Odd.zpow_nonneg_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_nonneg_iff Odd.zpow_nonneg_iffₓ'. -/\nprotected theorem Odd.zpow_nonneg_iff (hn : Odd n) : 0 ≤ a ^ n ↔ 0 ≤ a := by\n  cases' hn with k hk <;> simpa only [hk, two_mul] using zpow_bit1_nonneg_iff\n#align odd.zpow_nonneg_iff Odd.zpow_nonneg_iff\n\n/- warning: odd.zpow_nonpos_iff -> Odd.zpow_nonpos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_nonpos_iff Odd.zpow_nonpos_iffₓ'. -/\ntheorem Odd.zpow_nonpos_iff (hn : Odd n) : a ^ n ≤ 0 ↔ a ≤ 0 := by\n  cases' hn with k hk <;> simpa only [hk, two_mul] using zpow_bit1_nonpos_iff\n#align odd.zpow_nonpos_iff Odd.zpow_nonpos_iff\n\n/- warning: odd.zpow_pos_iff -> Odd.zpow_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_pos_iff Odd.zpow_pos_iffₓ'. -/\ntheorem Odd.zpow_pos_iff (hn : Odd n) : 0 < a ^ n ↔ 0 < a := by\n  cases' hn with k hk <;> simpa only [hk, two_mul] using zpow_bit1_pos_iff\n#align odd.zpow_pos_iff Odd.zpow_pos_iff\n\n/- warning: even.zpow_pos -> Even.zpow_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Even.{0} Int Int.hasAdd n) -> (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero)))) -> (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Even.{0} Int Int.instAddInt n) -> (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n))\nCase conversion may be inaccurate. Consider using '#align even.zpow_pos Even.zpow_posₓ'. -/\nalias Even.zpow_pos_iff ↔ _ Even.zpow_pos\n#align even.zpow_pos Even.zpow_pos\n\n/- warning: odd.zpow_neg -> Odd.zpow_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.semiring n) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_neg Odd.zpow_negₓ'. -/\nalias Odd.zpow_neg_iff ↔ _ Odd.zpow_neg\n#align odd.zpow_neg Odd.zpow_neg\n\n/- warning: odd.zpow_nonpos -> Odd.zpow_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.semiring n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a n) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_nonpos Odd.zpow_nonposₓ'. -/\nalias Odd.zpow_nonpos_iff ↔ _ Odd.zpow_nonpos\n#align odd.zpow_nonpos Odd.zpow_nonpos\n\n/- warning: even.zpow_abs -> Even.zpow_abs is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {p : Int}, (Even.{0} Int Int.hasAdd p) -> (forall (a : α), Eq.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a) p) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a p))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {p : Int}, (Even.{0} Int Int.instAddInt p) -> (forall (a : α), Eq.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) p) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a p))\nCase conversion may be inaccurate. Consider using '#align even.zpow_abs Even.zpow_absₓ'. -/\ntheorem Even.zpow_abs {p : ℤ} (hp : Even p) (a : α) : |a| ^ p = a ^ p := by\n  cases' abs_choice a with h h <;> simp only [h, hp.neg_zpow _]\n#align even.zpow_abs Even.zpow_abs\n\n/- warning: zpow_bit0_abs -> zpow_bit0_abs is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α) (p : Int), Eq.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a) (bit0.{0} Int Int.hasAdd p)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.hasAdd p))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α) (p : Int), Eq.{succ u1} α (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (bit0.{0} Int Int.instAddInt p)) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (bit0.{0} Int Int.instAddInt p))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_abs zpow_bit0_absₓ'. -/\n@[simp]\ntheorem zpow_bit0_abs (a : α) (p : ℤ) : |a| ^ bit0 p = a ^ bit0 p :=\n  (even_bit0 _).zpow_abs _\n#align zpow_bit0_abs zpow_bit0_abs\n\n/-! ### Miscellaneous lemmmas -/\n\n\n/- warning: nat.cast_le_pow_sub_div_sub -> Nat.cast_le_pow_sub_div_sub is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))) a) -> (forall (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))) n) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (Ring.toMonoid.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))) a n) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))) a) -> (forall (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) n) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) a n) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align nat.cast_le_pow_sub_div_sub Nat.cast_le_pow_sub_div_subₓ'. -/\n/-- Bernoulli's inequality reformulated to estimate `(n : α)`. -/\ntheorem Nat.cast_le_pow_sub_div_sub (H : 1 < a) (n : ℕ) : (n : α) ≤ (a ^ n - 1) / (a - 1) :=\n  (le_div_iff (sub_pos.2 H)).2 <|\n    le_sub_left_of_add_le <| one_add_mul_sub_le_pow ((neg_le_self zero_le_one).trans H.le) _\n#align nat.cast_le_pow_sub_div_sub Nat.cast_le_pow_sub_div_sub\n\n/- warning: nat.cast_le_pow_div_sub -> Nat.cast_le_pow_div_sub is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))) a) -> (forall (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))) n) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (Ring.toMonoid.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))) a n) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))) a) -> (forall (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) n) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) a n) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align nat.cast_le_pow_div_sub Nat.cast_le_pow_div_subₓ'. -/\n/-- For any `a > 1` and a natural `n` we have `n ≤ a ^ n / (a - 1)`. See also\n`nat.cast_le_pow_sub_div_sub` for a stronger inequality with `a ^ n - 1` in the numerator. -/\ntheorem Nat.cast_le_pow_div_sub (H : 1 < a) (n : ℕ) : (n : α) ≤ a ^ n / (a - 1) :=\n  (n.cast_le_pow_sub_div_sub H).trans <|\n    div_le_div_of_le (sub_nonneg.2 H.le) (sub_le_self _ zero_le_one)\n#align nat.cast_le_pow_div_sub Nat.cast_le_pow_div_sub\n\nend LinearOrderedField\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Field/Power.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.7122321720225278, "lm_q1q2_score": 0.48130129886133083}}
{"text": "import .basic\nimport function.misc function.bijection\n\nuniverse u\n\n@[reducible]\ndefinition is_free (th : theory) {α : Sort _} {β : Type _} [mb : model th β] (j : α → β) : Prop :=\n  ∀ {γ : Type u} [mc : model th γ] (f : α → γ), ∃! (g : @morphism th β γ mb.to_premodel mc.to_premodel), ∀ (a : α), g.val (j a) = f a\n\nlemma free_on_bijective_bases (th : theory) {α β : Sort _} {φ : Type _} [mb : model th φ] (u : bijection α β) (j : β → φ) : is_free.{u} th j → is_free.{u} th (j∘ u.to_fun) :=\n  begin\n    intros hfree,\n    intros ψ mpsi g,\n    cases @hfree ψ mpsi (g∘ u.inv) with g₁ hg₁,\n    existsi g₁,\n    dsimp [function.comp] at *,\n    split,\n    show ∀ (a : α), g₁.val (j (u.to_fun a)) = g a, {\n      intros a,\n      by calc\n        g₁.val (j (u.to_fun a))\n            = g (u.inv (u.to_fun a)) : hg₁.left (u.to_fun a)\n        ... = g a : by rw [u.left_inverse a]\n    },\n    show ∀ (g' : @morphism th φ ψ _ mpsi.to_premodel), (∀ a, g'.val (j (u.to_fun a)) = g a) → g' = g₁, {\n      intros g' hg',\n      apply hg₁.right g',\n      intros b,\n      by calc\n        g'.val (j b)\n            = g'.val (j (u.to_fun (u.inv b))) : by rw [u.right_inverse b]\n        ... = g (u.inv b) : hg' (u.inv b)\n    }\n  end\n\n#print axioms free_on_bijective_bases\n\n-- TO DO: define the free algebraic model using optree\n\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/algebra/theory/free.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.48124109148803573}}
{"text": "import ECTate.Algebra.EllipticCurve.TateInt\n\nopen Int Model ValidModel SurjVal\n\n/-! Following Shankar-Shankar-Wang, Large families of elliptic curves ordered by conductor\n-/\nvariable {p : ℕ} (hp : Nat.Prime p) (hn23 : p ≠ 2 ∧ p ≠ 3) (a b c : ℤ) (habc)\n\nlemma c4_abc : Model.c4 ⟨0, a, 0, b, c⟩ = 16 * a ^ 2 - 48 * b :=\nby\n  simp [c4, b2, b4]\n  ring\n\nlemma discr_abc :\n  Model.discr ⟨0, a, 0, b, c⟩ = -16*a^2*(4*a*c - b^2) + 288*a*b*c - 64*b^3 - 432*c^2 :=\nby\n  simp [discr, b8, b6, b2, b4]\n  ring\n\nlemma val_discr_abc :\n  val_discr_to_nat (primeEVR hp).valtn ⟨⟨0, a, 0, b, c⟩, habc⟩ =\n    nat_of_val (primeEVR hp).valtn (fun h => habc (by rwa [discr_abc]) : (-16*a^2*(4*a*c - b^2) + 288*a*b*c - 64*b^3 - 432*c^2) ≠ 0) :=\nby\n  rw [Enat.eq_ofN, ofN_val_discr_to_nat]\n  conv =>\n    lhs\n    rw [discr_abc]\n  simp [nat_of_val]\n\n-- lemma kodaira_I0 (hcon : (primeEVR hp).valtn (Model.discr ⟨0, a, 0, b, c⟩) = 0) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .I 0 :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   sorry\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 0\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--     sorry\n--   simp [valdisc']\n\n-- lemma kodaira_In (n : ℕ) (hn : n ≥ 1)\n--   (hcona : (primeEVR hp).valtn a = 0)\n--   (hconb : (primeEVR hp).valtn b ≥ ((n + 1)/2 : ℕ))\n--   (hconc : (primeEVR hp).valtn c = n) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .I n :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_II\n--   (hcona : (primeEVR hp).valtn a ≥ 1)\n--   (hconb : (primeEVR hp).valtn b ≥ 1)\n--   (hconc : (primeEVR hp).valtn c = 1) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .II :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_III\n--   (hcona : (primeEVR hp).valtn a ≥ 1)\n--   (hconb : (primeEVR hp).valtn b = 1)\n--   (hconc : (primeEVR hp).valtn c ≥ 2) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .III :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_IV\n--   (hcona : (primeEVR hp).valtn a ≥ 1)\n--   (hconb : (primeEVR hp).valtn b ≥ 2)\n--   (hconc : (primeEVR hp).valtn c = 2) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .IV :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_Is0 (hcon : (primeEVR hp).valtn (Model.discr ⟨0, a, 0, b, c⟩) < 7)\n--   (hcona : (primeEVR hp).valtn a ≥ 1)\n--   (hconb : (primeEVR hp).valtn b ≥ 2)\n--   (hconc : (primeEVR hp).valtn c ≥ 3) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .Is 0 :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_Is {n : ℕ} (hn : n ≥ 1)\n--   (hcona : (primeEVR hp).valtn a = 1)\n--   (hconb : (primeEVR hp).valtn b ≥ ((n + 1)/2 + 2 : ℕ))\n--   (hconc : (primeEVR hp).valtn c ≥ n + 3) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .Is n :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_IVs\n--   (hcona : (primeEVR hp).valtn a ≥ 2)\n--   (hconb : (primeEVR hp).valtn b ≥ 3)\n--   (hconc : (primeEVR hp).valtn c = 4) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .IVs :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_IIIs\n--   (hcona : (primeEVR hp).valtn a ≥ 2)\n--   (hconb : (primeEVR hp).valtn b ≥ 3)\n--   (hconc : (primeEVR hp).valtn c ≥ 5) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .IIIs :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_IIs\n--   (hcona : (primeEVR hp).valtn a ≥ 2)\n--   (hconb : (primeEVR hp).valtn b ≥ 4)\n--   (hconc : (primeEVR hp).valtn c = 5) :\n--   (tate_algorithm p hp ⟨⟨0, a, 0, b, c⟩, habc⟩).1 = .IIs :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (⟨⟨0,a,0,b,c⟩, _⟩ : ValidModel ℤ) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = ∞; simp [← h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [← h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n", "meta": {"author": "KisaraBlue", "repo": "ec-tate-lean", "sha": "2b1b26c2622fde0344feaadddc077caca73bd929", "save_path": "github-repos/lean/KisaraBlue-ec-tate-lean", "path": "github-repos/lean/KisaraBlue-ec-tate-lean/ec-tate-lean-2b1b26c2622fde0344feaadddc077caca73bd929/ECTate/Algebra/EllipticCurve/KodairaTable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.48106380924174424}}
{"text": "/-!\n# Basic Types and Helpers\n-/\n\n\n\nsection NoMathlib\n  --- Commutativity.\n  @[simp, inline]\n  def commutes (op : α → α → α) : Prop :=\n    ∀ a₁ a₂,\n      op a₁ a₂ = op a₂ a₁\n\n  class Zero (α : Type u) :=\n    zero : α\n  instance : Zero Nat := ⟨0⟩\n  instance : Zero Int := ⟨0⟩\n\n  open Zero (zero)\n\n  class One (α : Type u) :=\n    one : α\n  instance : One Nat := ⟨1⟩\n  instance : One Int := ⟨1⟩\n\n  open One (one)\nend NoMathlib\n\n\n\nsection Range\n  --- A range, inclusive on both ends.\n  abbrev Range α := α × α\n\n  infix:min \"··\" => (fun lb ub => ((lb, ub) : Range _))\n\n  --- Conversion from regular products to ranges.\n  instance : Coe (α × α) (Range α) where\n    coe := id\n  --- Conversion from ranges to regular products.\n  instance : Coe (Range α) (α × α) where\n    coe := id\n\n  --- Length of a range.\n  def Prod.len [Sub α] (self : Range α) : α :=\n    self.1 - self.2\n\n  --- `True` if the range is empty.\n  def Prod.isEmpty [LT α] (self : Range α) : Prop :=\n    self.2 < self.1\n  --- `Prod.isEmpty` is decidable.\n  instance\n    [inst : LT α] [decLt : DecidableRel inst.lt]\n    {self : Range α}\n    : Decidable self.isEmpty\n  :=\n    by apply decLt\n      \n\n  --- Inclusive range over naturals.\n  partial def Prod.fold\n    (range : Range Int)\n    (acc : α)\n    (fld : α → Int → α)\n    : α\n  :=\n    if range.1 ≤ range.2 then\n      let acc := fld acc range.1\n      let range := range.1 + 1 ·· range.2\n      range.fold acc fld\n    else\n      acc\nend Range\n\n\n\nsection Conv\n  --- Total conversion from `src` to `tgt`.\n  class Of (src: Type s) (tgt : Type t)where\n    of : src → tgt\n  \n  postfix:55 \" :>\" => Of.of\n\n  --- Conversion to self.\n  instance : Of α α where\n    of := id\n\n  --- `OfNat → Of Nat`\n  instance {conv : (n : Nat) → OfNat α n} : Of Nat α where\n    of val :=\n      conv val\n      |>.ofNat\n\n  --- `Of` is transitive.\n  instance instTransOf [ofαβ : Of α β] [ofβγ : Of β γ] : Of α γ where\n    of a :=\n      ofαβ.of a\n      |> ofβγ.of\nend Conv\n\n\n\nnamespace Int\n  /-!\n# Lemmas for `Int`\n\n`Int` is lacking in lemmas in that it has basically none.\n\nThe lemmas in this section are going to be useful \n  -/\n\n  --- Addition is commutative.\n  theorem add_comm :\n    ∀ (i₁ i₂ : Int), i₁ + i₂ = i₂ + i₁\n  := by\n    intros i₁ i₂\n    cases i₁\n    <;> cases i₂\n    <;> simp [HAdd.hAdd, Add.add, Int.add]\n    <;> rw [Nat.add_comm]\n\n  --- Multiplication is commutative.\n  theorem mul_comm :\n    ∀ (i₁ i₂ : Int), i₁ * i₂ = i₂ * i₁\n  := by\n    intros i₁ i₂\n    cases i₁\n    <;> cases i₂\n    <;> simp [HMul.hMul, Mul.mul, Int.mul, Nat.mul_comm]\n    <;> rw [Nat.mul_comm]\n\n  --- Zero is left-neutral for `+`.\n  theorem zero_add (i : Int) : 0 + i = i := by\n      simp [HAdd.hAdd, Add.add, Int.add]\n      cases i\n      <;> simp [subNatNat]\n\n  --- Zero is right-neutral for `+`.\n  theorem add_zero (i : Int) : i + 0 = i := by\n      rw [add_comm]\n      exact zero_add i\n\n  --- One is left-neutral for `*`.\n  theorem one_mul (i : Int) : 1 * i = i := by\n      simp [HMul.hMul, Mul.mul, Int.mul]\n      cases i\n      <;> simp [negOfNat]\n\n  --- One is right-neutral for `*`.\n  theorem mul_one (i : Int) : i * 1 = i := by\n      rw [mul_comm]\n      exact one_mul i\nend Int\n\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/fdlean/Fd/Init.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.4810022482717611}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.data.subtype.basic\nimport Mathlib.Lean3Lib.init.funext\n\nuniverses u v \n\nnamespace Mathlib\n\nnamespace classical\n\n\n/- the axiom -/\n\naxiom choice {α : Sort u} : Nonempty α → α\n\ntheorem indefinite_description {α : Sort u} (p : α → Prop) (h : ∃ (x : α), p x) :\n    Subtype fun (x : α) => p x :=\n  sorry\n\ndef some {α : Sort u} {p : α → Prop} (h : ∃ (x : α), p x) : α :=\n  subtype.val (indefinite_description p h)\n\ntheorem some_spec {α : Sort u} {p : α → Prop} (h : ∃ (x : α), p x) : p (some h) :=\n  subtype.property (indefinite_description p h)\n\n/- Diaconescu's theorem: using function extensionality and propositional extensionality,\n   we can get excluded middle from this. -/\n\n/- TODO(Leo): check why the code generator is not ignoring (some exU)\n   when we mark u as def. -/\n\ntheorem em (p : Prop) : p ∨ ¬p :=\n  or.elim (not_uv_or_p p) (fun (hne : u p ≠ v p) => Or.inr (mt (p_implies_uv p) hne)) Or.inl\n\ntheorem exists_true_of_nonempty {α : Sort u} : Nonempty α → ∃ (x : α), True :=\n  fun (ᾰ : Nonempty α) =>\n    nonempty.dcases_on ᾰ fun (ᾰ : α) => idRhs (∃ (x : α), True) (Exists.intro ᾰ trivial)\n\ndef inhabited_of_nonempty {α : Sort u} (h : Nonempty α) : Inhabited α :=\n  { default := Classical.choice h }\n\ndef inhabited_of_exists {α : Sort u} {p : α → Prop} (h : ∃ (x : α), p x) : Inhabited α :=\n  inhabited_of_nonempty sorry\n\n/- all propositions are decidable -/\n\ndef prop_decidable (a : Prop) : Decidable a := Classical.choice sorry\n\ndef decidable_inhabited (a : Prop) : Inhabited (Decidable a) := { default := prop_decidable a }\n\ndef type_decidable_eq (α : Sort u) : DecidableEq α := fun (x y : α) => prop_decidable (x = y)\n\ndef type_decidable (α : Sort u) : psum α (α → False) := sorry\n\ntheorem strong_indefinite_description {α : Sort u} (p : α → Prop) (h : Nonempty α) :\n    Subtype fun (x : α) => (∃ (y : α), p y) → p x :=\n  sorry\n\n/- the Hilbert epsilon function -/\n\ndef epsilon {α : Sort u} [h : Nonempty α] (p : α → Prop) : α :=\n  subtype.val (strong_indefinite_description p h)\n\ntheorem epsilon_spec_aux {α : Sort u} (h : Nonempty α) (p : α → Prop) :\n    (∃ (y : α), p y) → p (epsilon p) :=\n  subtype.property (strong_indefinite_description p h)\n\ntheorem epsilon_spec {α : Sort u} {p : α → Prop} (hex : ∃ (y : α), p y) : p (epsilon p) :=\n  epsilon_spec_aux (nonempty_of_exists hex) p hex\n\ntheorem epsilon_singleton {α : Sort u} (x : α) : (epsilon fun (y : α) => y = x) = x :=\n  epsilon_spec (Exists.intro x rfl)\n\n/- the axiom of choice -/\n\ntheorem axiom_of_choice {α : Sort u} {β : α → Sort v} {r : (x : α) → β x → Prop}\n    (h : ∀ (x : α), ∃ (y : β x), r x y) : ∃ (f : (x : α) → β x), ∀ (x : α), r x (f x) :=\n  Exists.intro (fun (x : α) => some (h x)) fun (x : α) => some_spec (h x)\n\ntheorem skolem {α : Sort u} {b : α → Sort v} {p : (x : α) → b x → Prop} :\n    (∀ (x : α), ∃ (y : b x), p x y) ↔ ∃ (f : (x : α) → b x), ∀ (x : α), p x (f x) :=\n  sorry\n\ntheorem prop_complete (a : Prop) : a = True ∨ a = False :=\n  or.elim (em a) (fun (t : a) => Or.inl (eq_true_intro t)) fun (f : ¬a) => Or.inr (eq_false_intro f)\n\ndef eq_true_or_eq_false (a : Prop) : a = True ∨ a = False := prop_complete\n\ntheorem cases_true_false (p : Prop → Prop) (h1 : p True) (h2 : p False) (a : Prop) : p a :=\n  or.elim (prop_complete a) (fun (ht : a = True) => Eq.symm ht ▸ h1)\n    fun (hf : a = False) => Eq.symm hf ▸ h2\n\ntheorem cases_on (a : Prop) {p : Prop → Prop} (h1 : p True) (h2 : p False) : p a :=\n  cases_true_false p h1 h2 a\n\n-- this supercedes by_cases in decidable\n\ndef by_cases {p : Prop} {q : Prop} (hpq : p → q) (hnpq : ¬p → q) : q := decidable.by_cases hpq hnpq\n\n-- this supercedes by_contradiction in decidable\n\ntheorem by_contradiction {p : Prop} (h : ¬p → False) : p := decidable.by_contradiction h\n\ntheorem eq_false_or_eq_true (a : Prop) : a = False ∨ a = True := or.symm (prop_complete a)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/classical_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.7154239836484144, "lm_q1q2_score": 0.4810022319541914}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Scott Morrison\n-/\nimport category_theory.limits.shapes.equalizers\nimport category_theory.limits.shapes.finite_products\nimport category_theory.limits.preserves.shapes.products\nimport category_theory.limits.preserves.shapes.equalizers\nimport category_theory.limits.preserves.finite\n\n/-!\n# Constructing limits from products and equalizers.\n\nIf a category has all products, and all equalizers, then it has all limits.\nSimilarly, if it has all finite products, and all equalizers, then it has all finite limits.\n\nIf a functor preserves all products and equalizers, then it preserves all limits.\nSimilarly, if it preserves all finite products and equalizers, then it preserves all finite limits.\n\n# TODO\n\nProvide the dual results.\nShow the analogous results for functors which reflect or create (co)limits.\n-/\n\nopen category_theory\nopen opposite\n\nnamespace category_theory.limits\n\nuniverses w v v₂ u u₂\nvariables {C : Type u} [category.{v} C]\n\nvariables {J : Type w} [small_category J]\n\n-- We hide the \"implementation details\" inside a namespace\nnamespace has_limit_of_has_products_of_has_equalizers\n\nvariables {F : J ⥤ C}\n          {c₁ : fan F.obj}\n          {c₂ : fan (λ f : (Σ p : J × J, p.1 ⟶ p.2), F.obj f.1.2)}\n          (s t : c₁.X ⟶ c₂.X)\n          (hs : ∀ (f : Σ p : J × J, p.1 ⟶ p.2), s ≫ c₂.π.app ⟨f⟩ = c₁.π.app ⟨f.1.1⟩ ≫ F.map f.2)\n          (ht : ∀ (f : Σ p : J × J, p.1 ⟶ p.2), t ≫ c₂.π.app ⟨f⟩ = c₁.π.app ⟨f.1.2⟩)\n          (i : fork s t)\n\ninclude hs ht\n/--\n(Implementation) Given the appropriate product and equalizer cones, build the cone for `F` which is\nlimiting if the given cones are also.\n-/\n@[simps]\ndef build_limit : cone F :=\n{ X := i.X,\n  π :=\n  { app := λ j, i.ι ≫ c₁.π.app ⟨_⟩,\n    naturality' := λ j₁ j₂ f, begin\n      dsimp,\n      rw [category.id_comp, category.assoc, ← hs ⟨⟨_, _⟩, f⟩, i.condition_assoc, ht],\n    end} }\n\nvariable {i}\n/--\n(Implementation) Show the cone constructed in `build_limit` is limiting, provided the cones used in\nits construction are.\n-/\ndef build_is_limit (t₁ : is_limit c₁) (t₂ : is_limit c₂) (hi : is_limit i) :\n  is_limit (build_limit s t hs ht i) :=\n{ lift := λ q,\n  begin\n    refine hi.lift (fork.of_ι _ _),\n    { refine t₁.lift (fan.mk _ (λ j, _)),\n      apply q.π.app j },\n    { apply t₂.hom_ext,\n      intro j, discrete_cases,\n      simp [hs, ht] },\n  end,\n  uniq' := λ q m w, hi.hom_ext (i.equalizer_ext (t₁.hom_ext\n    (λ j, by { cases j, simpa using w j }))) }\n\nend has_limit_of_has_products_of_has_equalizers\n\nopen has_limit_of_has_products_of_has_equalizers\n\n/--\nGiven the existence of the appropriate (possibly finite) products and equalizers,\nwe can construct a limit cone for `F`.\n(This assumes the existence of all equalizers, which is technically stronger than needed.)\n-/\nnoncomputable\ndef limit_cone_of_equalizer_and_product (F : J ⥤ C)\n  [has_limit (discrete.functor F.obj)]\n  [has_limit (discrete.functor (λ f : (Σ p : J × J, p.1 ⟶ p.2), F.obj f.1.2))]\n  [has_equalizers C] : limit_cone F :=\n{ cone := _,\n  is_limit :=\n    build_is_limit\n      (pi.lift (λ f, limit.π (discrete.functor F.obj) ⟨_⟩ ≫ F.map f.2))\n      (pi.lift (λ f, limit.π (discrete.functor F.obj) ⟨f.1.2⟩))\n      (by simp)\n      (by simp)\n      (limit.is_limit _)\n      (limit.is_limit _)\n      (limit.is_limit _) }\n\n/--\nGiven the existence of the appropriate (possibly finite) products and equalizers, we know a limit of\n`F` exists.\n(This assumes the existence of all equalizers, which is technically stronger than needed.)\n-/\nlemma has_limit_of_equalizer_and_product (F : J ⥤ C)\n  [has_limit (discrete.functor F.obj)]\n  [has_limit (discrete.functor (λ f : (Σ p : J × J, p.1 ⟶ p.2), F.obj f.1.2))]\n  [has_equalizers C] : has_limit F :=\nhas_limit.mk (limit_cone_of_equalizer_and_product F)\n\n/-- A limit can be realised as a subobject of a product. -/\nnoncomputable\ndef limit_subobject_product [has_limits_of_size.{w w} C] (F : J ⥤ C) :\n  limit F ⟶ ∏ (λ j, F.obj j) :=\n(limit.iso_limit_cone (limit_cone_of_equalizer_and_product F)).hom ≫ equalizer.ι _ _\n\ninstance limit_subobject_product_mono [has_limits_of_size.{w w} C] (F : J ⥤ C) :\n  mono (limit_subobject_product F) :=\nmono_comp _ _\n\n/--\nAny category with products and equalizers has all limits.\n\nSee <https://stacks.math.columbia.edu/tag/002N>.\n-/\nlemma limits_from_equalizers_and_products\n  [has_products.{w} C] [has_equalizers C] : has_limits_of_size.{w w} C :=\n{ has_limits_of_shape := λ J 𝒥,\n  { has_limit := λ F, by exactI has_limit_of_equalizer_and_product F } }\n\n/--\nAny category with finite products and equalizers has all finite limits.\n\nSee <https://stacks.math.columbia.edu/tag/002O>.\n-/\nlemma finite_limits_from_equalizers_and_finite_products\n  [has_finite_products C] [has_equalizers C] : has_finite_limits C :=\n⟨λ J _ _, { has_limit := λ F, by exactI has_limit_of_equalizer_and_product F }⟩\n\nvariables {D : Type u₂} [category.{v₂} D]\nnoncomputable theory\n\nsection\n\nvariables [has_limits_of_shape (discrete J) C]\n          [has_limits_of_shape (discrete (Σ p : J × J, p.1 ⟶ p.2)) C]\n          [has_equalizers C]\nvariables (G : C ⥤ D)\n          [preserves_limits_of_shape walking_parallel_pair G]\n          [preserves_limits_of_shape (discrete.{w} J) G]\n          [preserves_limits_of_shape (discrete.{w} (Σ p : J × J, p.1 ⟶ p.2)) G]\n\n/-- If a functor preserves equalizers and the appropriate products, it preserves limits. -/\ndef preserves_limit_of_preserves_equalizers_and_product :\n  preserves_limits_of_shape J G :=\n{ preserves_limit := λ K,\n  begin\n    let P := ∏ K.obj,\n    let Q := ∏ (λ (f : (Σ (p : J × J), p.fst ⟶ p.snd)), K.obj f.1.2),\n    let s : P ⟶ Q := pi.lift (λ f, limit.π (discrete.functor K.obj) ⟨_⟩ ≫ K.map f.2),\n    let t : P ⟶ Q := pi.lift (λ f, limit.π (discrete.functor K.obj) ⟨f.1.2⟩),\n    let I := equalizer s t,\n    let i : I ⟶ P := equalizer.ι s t,\n    apply preserves_limit_of_preserves_limit_cone\n      (build_is_limit s t (by simp) (by simp)\n        (limit.is_limit _)\n        (limit.is_limit _)\n        (limit.is_limit _)),\n    refine is_limit.of_iso_limit (build_is_limit _ _ _ _ _ _ _) _,\n    { exact fan.mk _ (λ j, G.map (pi.π _ j)) },\n    { exact fan.mk (G.obj Q) (λ f, G.map (pi.π _ f)) },\n    { apply G.map s },\n    { apply G.map t },\n    { intro f,\n      dsimp,\n      simp only [←G.map_comp, limit.lift_π, fan.mk_π_app] },\n    { intro f,\n      dsimp,\n      simp only [←G.map_comp, limit.lift_π, fan.mk_π_app] },\n    { apply fork.of_ι (G.map i) _,\n      simp only [← G.map_comp, equalizer.condition] },\n    { apply is_limit_of_has_product_of_preserves_limit },\n    { apply is_limit_of_has_product_of_preserves_limit },\n    { apply is_limit_fork_map_of_is_limit,\n      apply equalizer_is_equalizer },\n    refine cones.ext (iso.refl _) _,\n    intro j,\n    dsimp,\n    simp, -- See note [dsimp, simp].\n  end }\nend\n\n/-- If G preserves equalizers and finite products, it preserves finite limits. -/\ndef preserves_finite_limits_of_preserves_equalizers_and_finite_products\n  [has_equalizers C] [has_finite_products C]\n  (G : C ⥤ D) [preserves_limits_of_shape walking_parallel_pair G]\n  [∀ (J : Type) [fintype J], preserves_limits_of_shape (discrete J) G] :\n  preserves_finite_limits G :=\n⟨λ _ _ _, by exactI preserves_limit_of_preserves_equalizers_and_product G⟩\n\n/-- If G preserves equalizers and products, it preserves all limits. -/\ndef preserves_limits_of_preserves_equalizers_and_products\n  [has_equalizers C] [has_products.{w} C]\n  (G : C ⥤ D) [preserves_limits_of_shape walking_parallel_pair G]\n  [∀ J, preserves_limits_of_shape (discrete.{w} J) G] :\npreserves_limits_of_size.{w w} G :=\n{ preserves_limits_of_shape := λ J 𝒥,\n  by exactI preserves_limit_of_preserves_equalizers_and_product G }\n\n/-!\nWe now dualize the above constructions, resorting to copy-paste.\n-/\n\n-- We hide the \"implementation details\" inside a namespace\nnamespace has_colimit_of_has_coproducts_of_has_coequalizers\n\nvariables {F : J ⥤ C}\n          {c₁ : cofan (λ f : (Σ p : J × J, p.1 ⟶ p.2), F.obj f.1.1)}\n          {c₂ : cofan F.obj}\n          (s t : c₁.X ⟶ c₂.X)\n          (hs : ∀ (f : Σ p : J × J, p.1 ⟶ p.2), c₁.ι.app ⟨f⟩ ≫ s = F.map f.2 ≫ c₂.ι.app ⟨f.1.2⟩)\n          (ht : ∀ (f : Σ p : J × J, p.1 ⟶ p.2), c₁.ι.app ⟨f⟩ ≫ t = c₂.ι.app ⟨f.1.1⟩)\n          (i : cofork s t)\n\ninclude hs ht\n/--\n(Implementation) Given the appropriate coproduct and coequalizer cocones,\nbuild the cocone for `F` which is colimiting if the given cocones are also.\n-/\n@[simps]\ndef build_colimit : cocone F :=\n{ X := i.X,\n  ι :=\n  { app := λ j, c₂.ι.app ⟨_⟩ ≫ i.π,\n    naturality' := λ j₁ j₂ f, begin\n      dsimp,\n      rw [category.comp_id, ←reassoc_of (hs ⟨⟨_, _⟩, f⟩), i.condition, ←category.assoc, ht],\n    end} }\n\nvariable {i}\n/--\n(Implementation) Show the cocone constructed in `build_colimit` is colimiting,\nprovided the cocones used in its construction are.\n-/\ndef build_is_colimit (t₁ : is_colimit c₁) (t₂ : is_colimit c₂) (hi : is_colimit i) :\n  is_colimit (build_colimit s t hs ht i) :=\n{ desc := λ q,\n  begin\n    refine hi.desc (cofork.of_π _ _),\n    { refine t₂.desc (cofan.mk _ (λ j, _)),\n      apply q.ι.app j },\n    { apply t₁.hom_ext,\n      intro j, discrete_cases,\n      simp [reassoc_of hs, reassoc_of ht] },\n  end,\n  uniq' := λ q m w, hi.hom_ext (i.coequalizer_ext (t₂.hom_ext\n    (λ j, by { cases j, simpa using w j }))) }\n\nend has_colimit_of_has_coproducts_of_has_coequalizers\n\nopen has_colimit_of_has_coproducts_of_has_coequalizers\n\n/--\nGiven the existence of the appropriate (possibly finite) coproducts and coequalizers,\nwe can construct a colimit cocone for `F`.\n(This assumes the existence of all coequalizers, which is technically stronger than needed.)\n-/\nnoncomputable\ndef colimit_cocone_of_coequalizer_and_coproduct (F : J ⥤ C)\n  [has_colimit (discrete.functor F.obj)]\n  [has_colimit (discrete.functor (λ f : (Σ p : J × J, p.1 ⟶ p.2), F.obj f.1.1))]\n  [has_coequalizers C] : colimit_cocone F :=\n{ cocone := _,\n  is_colimit :=\n    build_is_colimit\n      (sigma.desc (λ f, F.map f.2 ≫ colimit.ι (discrete.functor F.obj) ⟨f.1.2⟩))\n      (sigma.desc (λ f, colimit.ι (discrete.functor F.obj) ⟨f.1.1⟩))\n      (by simp)\n      (by simp)\n      (colimit.is_colimit _)\n      (colimit.is_colimit _)\n      (colimit.is_colimit _) }\n\n\n/--\nGiven the existence of the appropriate (possibly finite) coproducts and coequalizers,\nwe know a colimit of `F` exists.\n(This assumes the existence of all coequalizers, which is technically stronger than needed.)\n-/\nlemma has_colimit_of_coequalizer_and_coproduct (F : J ⥤ C)\n  [has_colimit (discrete.functor F.obj)]\n  [has_colimit (discrete.functor (λ f : (Σ p : J × J, p.1 ⟶ p.2), F.obj f.1.1))]\n  [has_coequalizers C] : has_colimit F :=\nhas_colimit.mk (colimit_cocone_of_coequalizer_and_coproduct F)\n\n/-- A colimit can be realised as a quotient of a coproduct. -/\nnoncomputable\ndef colimit_quotient_coproduct [has_colimits_of_size.{w w} C] (F : J ⥤ C) :\n  ∐ (λ j, F.obj j) ⟶ colimit F :=\ncoequalizer.π _ _ ≫ (colimit.iso_colimit_cocone (colimit_cocone_of_coequalizer_and_coproduct F)).inv\n\ninstance colimit_quotient_coproduct_epi [has_colimits_of_size.{w w} C] (F : J ⥤ C) :\n  epi (colimit_quotient_coproduct F) :=\nepi_comp _ _\n\n/--\nAny category with coproducts and coequalizers has all colimits.\n\nSee <https://stacks.math.columbia.edu/tag/002P>.\n-/\nlemma colimits_from_coequalizers_and_coproducts\n  [has_coproducts.{w} C] [has_coequalizers C] : has_colimits_of_size.{w w} C :=\n{ has_colimits_of_shape := λ J 𝒥,\n  { has_colimit := λ F, by exactI has_colimit_of_coequalizer_and_coproduct F } }\n\n/--\nAny category with finite coproducts and coequalizers has all finite colimits.\n\nSee <https://stacks.math.columbia.edu/tag/002Q>.\n-/\nlemma finite_colimits_from_coequalizers_and_finite_coproducts\n  [has_finite_coproducts C] [has_coequalizers C] : has_finite_colimits C :=\n⟨λ J _ _, { has_colimit := λ F, by exactI has_colimit_of_coequalizer_and_coproduct F }⟩\n\nnoncomputable theory\n\nsection\n\nvariables [has_colimits_of_shape (discrete.{w} J) C]\n          [has_colimits_of_shape (discrete.{w} (Σ p : J × J, p.1 ⟶ p.2)) C]\n          [has_coequalizers C]\nvariables (G : C ⥤ D)\n          [preserves_colimits_of_shape walking_parallel_pair G]\n          [preserves_colimits_of_shape (discrete.{w} J) G]\n          [preserves_colimits_of_shape (discrete.{w} (Σ p : J × J, p.1 ⟶ p.2)) G]\n\n/-- If a functor preserves coequalizers and the appropriate coproducts, it preserves colimits. -/\ndef preserves_colimit_of_preserves_coequalizers_and_coproduct :\n  preserves_colimits_of_shape J G :=\n{ preserves_colimit := λ K,\n  begin\n    let P := ∐ K.obj,\n    let Q := ∐ (λ (f : (Σ (p : J × J), p.fst ⟶ p.snd)), K.obj f.1.1),\n    let s : Q ⟶ P := sigma.desc (λ f, K.map f.2 ≫ colimit.ι (discrete.functor K.obj) ⟨_⟩),\n    let t : Q ⟶ P := sigma.desc (λ f, colimit.ι (discrete.functor K.obj) ⟨f.1.1⟩),\n    let I := coequalizer s t,\n    let i : P ⟶ I := coequalizer.π s t,\n    apply preserves_colimit_of_preserves_colimit_cocone\n      (build_is_colimit s t (by simp) (by simp)\n        (colimit.is_colimit _)\n        (colimit.is_colimit _)\n        (colimit.is_colimit _)),\n    refine is_colimit.of_iso_colimit (build_is_colimit _ _ _ _ _ _ _) _,\n    { exact cofan.mk (G.obj Q) (λ j, G.map (sigma.ι _ j)) },\n    { exact cofan.mk _ (λ f, G.map (sigma.ι _ f)) },\n    { apply G.map s },\n    { apply G.map t },\n    { intro f,\n      dsimp,\n      simp only [←G.map_comp, colimit.ι_desc, cofan.mk_ι_app] },\n    { intro f,\n      dsimp,\n      simp only [←G.map_comp, colimit.ι_desc, cofan.mk_ι_app] },\n    { apply cofork.of_π (G.map i) _,\n      simp only [← G.map_comp, coequalizer.condition] },\n    { apply is_colimit_of_has_coproduct_of_preserves_colimit },\n    { apply is_colimit_of_has_coproduct_of_preserves_colimit },\n    { apply is_colimit_cofork_map_of_is_colimit,\n      apply coequalizer_is_coequalizer },\n    refine cocones.ext (iso.refl _) _,\n    intro j,\n    dsimp,\n    simp, -- See note [dsimp, simp].\n  end }\nend\n\n/-- If G preserves coequalizers and finite coproducts, it preserves finite colimits. -/\ndef preserves_finite_colimits_of_preserves_coequalizers_and_finite_coproducts\n  [has_coequalizers C] [has_finite_coproducts C]\n  (G : C ⥤ D) [preserves_colimits_of_shape walking_parallel_pair G]\n  [∀ J [fintype J], preserves_colimits_of_shape (discrete.{0} J) G] :\n  preserves_finite_colimits G :=\n⟨λ _ _ _, by exactI preserves_colimit_of_preserves_coequalizers_and_coproduct G⟩\n\n/-- If G preserves coequalizers and coproducts, it preserves all colimits. -/\ndef preserves_colimits_of_preserves_coequalizers_and_coproducts\n  [has_coequalizers C] [has_coproducts.{w} C]\n  (G : C ⥤ D) [preserves_colimits_of_shape walking_parallel_pair G]\n  [∀ J, preserves_colimits_of_shape (discrete.{w} J) G] :\npreserves_colimits_of_size.{w} G :=\n{ preserves_colimits_of_shape := λ J 𝒥,\n  by exactI preserves_colimit_of_preserves_coequalizers_and_coproduct G }\n\nend category_theory.limits\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/category_theory/limits/constructions/limits_of_products_and_equalizers.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.48100222540388965}}
{"text": "import Kenny_comm_alg.ideal_lattice\n\nnoncomputable theory\nlocal attribute [instance] classical.prop_decidable\n\nuniverse u\n\nnamespace is_ideal\n\nsection avoid_powers\n\nparameters {α : Type u} [comm_ring α]\nparameters (f : α) (P : set α) [hp : is_ideal P]\nparameters (hf : ∀ n : ℕ, f^n ∉ P)\ninclude hp hf\n\nprivate def avoid_powers_aux :\n  ∃ (M : {S : set α // is_ideal S ∧ P ⊆ S ∧ ∀ n, f ^ n ∉ S}),\n  ∀ x, M ≤ x → x = M :=\n@@zorn.zorn' {S // is_ideal S ∧ P ⊆ S ∧ ∀ n, f^n ∉ S} _ ⟨⟨P, hp, set.subset.refl P, hf⟩⟩ $\nλ c x hx hc, ⟨⟨{y | ∃ S : {S // is_ideal S ∧ P ⊆ S ∧ ∀ n, f^n ∉ S}, S ∈ c ∧ y ∈ S.val},\n  { zero_ := ⟨x, hx, @@is_ideal.zero _ x.1 x.2.1⟩,\n    add_  := λ x y ⟨Sx, hxc, hx⟩ ⟨Sy, hyc, hy⟩,\n      or.cases_on (hc Sx Sy hxc hyc)\n        (λ hxy, ⟨Sy, hyc, @@is_ideal.add _ Sy.2.1 (hxy hx) hy⟩)\n        (λ hyx, ⟨Sx, hxc, @@is_ideal.add _ Sx.2.1 hx (hyx hy)⟩),\n    smul  := λ x y ⟨Sy, hyc, hy⟩,\n      ⟨Sy, hyc, @@is_ideal.mul_left _ Sy.2.1 hy⟩ },\n  λ z hz, ⟨x, hx, x.2.2.1 hz⟩,\n  λ n ⟨S, hsc, hfns⟩, S.2.2.2 n hfns⟩,\nλ S hsc z hzs, ⟨S, hsc, hzs⟩⟩\n\ndef avoid_powers : set α :=\n(classical.some avoid_powers_aux).1\n\ntheorem avoid_powers.contains : P ⊆ avoid_powers :=\n(classical.some avoid_powers_aux).2.2.1\n\ntheorem avoid_powers.avoid_powers : ∀ n : ℕ, f^n ∉ avoid_powers :=\n(classical.some avoid_powers_aux).2.2.2\n\ndef avoid_powers.is_prime_ideal : is_prime_ideal avoid_powers :=\n{ ne_univ := λ h,\n    have h1 : (1:α) ∈ (set.univ:set α), from show true, by trivial,\n    have h2 : (1:α) ∈ avoid_powers, by rwa h,\n    avoid_powers.avoid_powers 0 h2,\n  mem_or_mem_of_mul_mem := λ x y hxy,\n    have h1 : ∀ x, classical.some avoid_powers_aux ≤ x → x = classical.some avoid_powers_aux,\n      from classical.some_spec avoid_powers_aux,\n    have hax : avoid_powers ⊆ span (insert x avoid_powers),\n      from set.subset.trans (set.subset_insert x _) subset_span,\n    have hay : avoid_powers ⊆ span (insert y avoid_powers),\n      from set.subset.trans (set.subset_insert y _) subset_span,\n    have hax2 : P ⊆ span (insert x avoid_powers),\n      from set.subset.trans avoid_powers.contains hax,\n    have hay2 : P ⊆ span (insert y avoid_powers),\n      from set.subset.trans avoid_powers.contains hay,\n    have hnx : (¬∃ n, f^n ∈ span (insert x avoid_powers)) → x ∈ avoid_powers,\n      from λ h,\n      have h2 : _ := h1 ⟨_, is_ideal_span, hax2, λ n hnfs, h ⟨n, hnfs⟩⟩ hax,\n      suffices x ∈ span (insert x avoid_powers),\n        by unfold avoid_powers; rw ← h2; exact this,\n      subset_span $ set.mem_insert x _,\n    have hny : (¬∃ n, f^n ∈ span (insert y avoid_powers)) → y ∈ avoid_powers,\n      from λ h,\n      have h2 : _ := h1 ⟨_, is_ideal_span, hay2, λ n hnfs, h ⟨n, hnfs⟩⟩ hay,\n      suffices y ∈ span (insert y avoid_powers),\n        by unfold avoid_powers; rw ← h2; exact this,\n      subset_span $ set.mem_insert y _,\n    begin\n      haveI ha : is_submodule (avoid_powers f P hf) :=\n        (classical.some (avoid_powers_aux f P hf)).2.1.to_is_submodule,\n      by_cases hx : ∃ m : ℕ, f^m ∈ span (insert x (avoid_powers f P hf)),\n      { by_cases hy : ∃ n : ℕ, f^n ∈ span (insert y (avoid_powers f P hf)),\n        { exfalso,\n          cases hx with m hx,\n          cases hy with n hy,\n          rw span_insert at hx hy,\n          rcases hx with ⟨x1, x2, hx2, hx⟩,\n          rcases hy with ⟨y1, y2, hy2, hy⟩,\n          haveI ha : is_submodule (avoid_powers f P hf) :=\n            (classical.some (avoid_powers_aux f P hf)).2.1.to_is_submodule,\n          rw span_eq_of_is_submodule ha at hx2 hy2,\n          apply avoid_powers.avoid_powers f P hf (m+n),\n          exact calc\n          f ^ (m + n) = (x1 • x + x2) * (y1 • y + y2) : by rw [pow_add, hx, hy]\n                  ... = (x1 * x + x2) * (y1 * y + y2) : rfl\n                  ... = (x1 * y1) * (x * y) + (x1 * x) * y2 + (y1 * y) * x2 + x2 * y2 : by ring\n                  ... ∈ avoid_powers f P hf :\n            is_submodule.add\n              (is_submodule.add\n                 (is_submodule.add\n                    (is_submodule.smul _ hxy)\n                    (is_submodule.smul _ hy2))\n                 (is_submodule.smul _ hx2))\n              (is_submodule.smul _ hy2) },\n        { right,\n          exact hny hy } },\n      { left,\n        exact hnx hx }\n    end,\n  .. (classical.some avoid_powers_aux).2.1 }\n\nend avoid_powers\n\nend is_ideal", "meta": {"author": "kbuzzard", "repo": "lean-stacks-project", "sha": "b57be17aa917f1c3a23c59db5ee37b1aa21112c2", "save_path": "github-repos/lean/kbuzzard-lean-stacks-project", "path": "github-repos/lean/kbuzzard-lean-stacks-project/lean-stacks-project-b57be17aa917f1c3a23c59db5ee37b1aa21112c2/src/Kenny_comm_alg/avoid_powers.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4809779452467098}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport .chunk\nimport .energy\n\n/-!\n# Increment\n-/\n\nuniverses u v\n\nopen finset fintype simple_graph\nopen_locale big_operators classical\n\nvariables {α : Type*} [fintype α] {P : finpartition (univ : finset α)} (hP : P.is_equipartition)\n  (G : simple_graph α) (ε : ℝ)\n\nlocal notation `m` := (card α/exp_bound P.parts.card : ℕ)\n\nnamespace finpartition\n\n/-- The work-horse of SRL. This says that if we have an equipartition which is *not* uniform, then\nwe can make a (much bigger) equipartition with a slightly higher energy. This is helpful since the\nenergy is bounded by a constant (see `energy_le_one`), so this process eventually terminates and\nyields a not-too-big uniform equipartition. -/\nnoncomputable def is_equipartition.increment : finpartition (univ : finset α) :=\nP.bind (λ U, hP.chunk_increment G ε)\n\nopen finpartition finpartition.is_equipartition\n\nvariables {hP G ε}\n\nlemma card_increment (hPα : P.parts.card * 16^P.parts.card ≤ card α) (hPG : ¬P.is_uniform G ε) :\n  (hP.increment G ε).parts.card = exp_bound P.parts.card :=\nbegin\n  have hPα' : exp_bound P.parts.card ≤ card α :=\n    (nat.mul_le_mul_of_nonneg_left $ nat.pow_le_pow_of_le_left (by norm_num) _).trans hPα,\n  have hPpos : 0 < exp_bound P.parts.card :=\n    exp_bound_pos.2 (nonempty_of_not_uniform hPG).card_pos,\n  rw [is_equipartition, finset.equitable_on_iff] at hP,\n  rw [increment, card_bind],\n  simp_rw [finpartition.is_equipartition.chunk_increment, apply_dite finpartition.parts,\n    apply_dite card],\n  rw [sum_dite, sum_const_nat, sum_const_nat, card_attach, card_attach], rotate,\n  exact λ x hx, finpartition.equitabilise.parts_card (nat.div_pos hPα' hPpos) _,\n  exact λ x hx, finpartition.equitabilise.parts_card (nat.div_pos hPα' hPpos) _,\n  rw [nat.sub_add_cancel a_add_one_le_four_pow_parts_card, nat.sub_add_cancel ((nat.le_succ _).trans\n    a_add_one_le_four_pow_parts_card), ←add_mul],\n  congr,\n  rw [filter_card_add_filter_neg_card_eq_card, card_attach],\nend\n\nlemma increment_is_equipartition (hP : P.is_equipartition) (G : simple_graph α) (ε : ℝ) :\n  (hP.increment G ε).is_equipartition :=\nbegin\n  rw [is_equipartition, set.equitable_on_iff_exists_eq_eq_add_one],\n  refine ⟨m, λ A hA, _⟩,\n  rw [mem_coe, increment, mem_bind] at hA,\n  obtain ⟨U, hU, hA⟩ := hA,\n  exact card_eq_of_mem_parts_chunk_increment hA,\nend\n\nlemma distinct_pairs_increment :\n  P.parts.off_diag.attach.bUnion\n    (λ UV, (hP.chunk_increment G ε ((mem_off_diag _ _).1 UV.2).1).parts.product\n      (hP.chunk_increment G ε ((mem_off_diag _ _).1 UV.2).2.1).parts)\n  ⊆ (hP.increment G ε).parts.off_diag :=\nbegin\n  rintro ⟨Ui, Vj⟩,\n  simp only [finpartition.is_equipartition.increment, mem_off_diag, bind_parts, mem_bUnion,\n    prod.exists, exists_and_distrib_left, exists_prop, mem_product, mem_attach, true_and,\n    subtype.exists, and_imp, mem_off_diag, forall_exists_index, bex_imp_distrib, ne.def],\n  rintro U V hUV hUi hVj,\n  refine ⟨⟨_, hUV.1, hUi⟩, ⟨_, hUV.2.1, hVj⟩, _⟩,\n  rintro rfl,\n  obtain ⟨i, hi⟩ := nonempty_of_mem_parts _ hUi,\n  apply hUV.2.2 (P.disjoint.elim_finset hUV.1 hUV.2.1 i (finpartition.le _ hUi hi)\n    (finpartition.le _ hVj hi)),\nend\n\n/-- The contribution to `energy` of a pair of distinct parts of a finpartition. -/\nnoncomputable def pair_contrib (G : simple_graph α) (ε : ℝ) (hP : P.is_equipartition)\n  (x : {x // x ∈ P.parts.off_diag}) :=\n(∑ i in\n  (hP.chunk_increment G ε ((mem_off_diag _ _).1 x.2).1).parts.product\n    (hP.chunk_increment G ε ((mem_off_diag _ _).1 x.2).2.1).parts,\n  G.edge_density i.fst i.snd ^ 2)\n\nlemma off_diag_pairs_le_increment_energy :\n  ∑ x in P.parts.off_diag.attach, pair_contrib G ε hP x / (hP.increment G ε).parts.card ^ 2 ≤\n    (hP.increment G ε).energy G :=\nbegin\n  simp_rw [pair_contrib, ←sum_div],\n  refine div_le_div_of_le_of_nonneg _ (sq_nonneg _),\n  rw ←sum_bUnion,\n  { exact sum_le_sum_of_subset_of_nonneg distinct_pairs_increment (λ i _ _, sq_nonneg _) },\n  rintro ⟨⟨s₁, s₂⟩, hs⟩ _ ⟨⟨t₁, t₂⟩, ht⟩ _ hst ⟨u, v⟩ huv,\n  simp only [inf_eq_inter, mem_inter, mem_product] at huv,\n  rw mem_off_diag at hs ht,\n  obtain ⟨a, ha⟩ := finpartition.nonempty_of_mem_parts _ huv.1.1,\n  obtain ⟨b, hb⟩ := finpartition.nonempty_of_mem_parts _ huv.1.2,\n  exact hst (subtype.ext_val $ prod.ext\n    (P.disjoint.elim_finset hs.1 ht.1 a\n      (finpartition.le _ huv.1.1 ha) (finpartition.le _ huv.2.1 ha))\n    (P.disjoint.elim_finset hs.2.1 ht.2.1 b\n      (finpartition.le _ huv.1.2 hb) (finpartition.le _ huv.2.2 hb))),\nend\n\nlemma pair_contrib_lower_bound [nonempty α] (x : {i // i ∈ P.parts.off_diag}) (hε₁ : ε ≤ 1)\n  (hPα : P.parts.card * 16^P.parts.card ≤ card α) (hPε : 100 ≤ 4^P.parts.card * ε^5) :\n  G.edge_density x.1.1 x.1.2^2 - ε^5/25 + (if G.is_uniform ε x.1.1 x.1.2 then 0 else ε^4/3) ≤\n    pair_contrib G ε hP x / (16^P.parts.card) :=\nbegin\n  split_ifs,\n  { rw add_zero,\n    exact sq_density_sub_eps_le_sum_sq_density_div_card hPα hPε _ _ },\n  { apply sq_density_sub_eps_le_sum_sq_density_div_card_of_nonuniform hPα hPε hε₁ _ h,\n    exact ((mem_off_diag _ _).1 x.2).2.2 }\nend\n\nlemma uniform_add_nonuniform_eq_off_diag_pairs [nonempty α] (hε₁ : ε ≤ 1) (hP₇ : 7 ≤ P.parts.card)\n  (hPα : P.parts.card * 16^P.parts.card ≤ card α) (hPε : 100 ≤ 4^P.parts.card * ε^5)\n  (hPG : ¬P.is_uniform G ε) :\n  (∑ x in P.parts.off_diag, G.edge_density x.1 x.2 ^ 2 + P.parts.card^2 * (ε ^ 5 / 4))\n    / P.parts.card ^ 2\n      ≤ ∑ x in P.parts.off_diag.attach, pair_contrib G ε hP x / (hP.increment G ε).parts.card ^ 2 :=\nbegin\n  conv_rhs\n  { rw [←sum_div, card_increment hPα hPG, exp_bound, ←nat.cast_pow, mul_pow, pow_right_comm,\n      nat.cast_mul, mul_comm, ←div_div_eq_div_mul, (show 4^2 = 16, by norm_num), sum_div] },\n  rw [←nat.cast_pow, nat.cast_pow 16],\n  refine div_le_div_of_le_of_nonneg _ (nat.cast_nonneg _),\n  norm_num,\n  suffices : _ ≤ ∑ x in P.parts.off_diag.attach,\n      (G.edge_density x.1.1 x.1.2^2 - ε^5/25 + if G.is_uniform ε x.1.1 x.1.2 then 0 else ε^4/3),\n  { apply le_trans this (sum_le_sum (λ i hi, pair_contrib_lower_bound i hε₁ hPα hPε)) },\n  have : ∑ x in P.parts.off_diag.attach,\n    (G.edge_density x.1.1 x.1.2^2 - ε^5/25 + if G.is_uniform ε x.1.1 x.1.2 then 0 else ε^4/3) =\n    ∑ x in P.parts.off_diag,\n      (G.edge_density x.1 x.2^2 - ε^5/25 + if G.is_uniform ε x.1 x.2 then 0 else ε^4/3),\n  { convert sum_attach, refl },\n  rw [this, sum_add_distrib, sum_sub_distrib, sum_const, nsmul_eq_mul, sum_ite, sum_const_zero,\n    zero_add, sum_const, nsmul_eq_mul, ←finpartition.non_uniform_pairs],\n  rw finpartition.is_uniform at hPG,\n  simp only [not_le] at hPG,\n  apply le_trans _ (add_le_add_left (mul_le_mul_of_nonneg_right hPG.le _) _),\n  { conv_rhs { congr, congr, skip, rw [off_diag_card], congr, congr,\n      conv { congr, skip, rw ←mul_one P.parts.card }, rw ←nat.mul_sub_left_distrib },\n    simp_rw [mul_assoc, sub_add_eq_add_sub, add_sub_assoc, ←mul_sub_left_distrib, mul_div_assoc' ε,\n      ←pow_succ, div_eq_mul_one_div (ε^5), ←mul_sub_left_distrib],\n    rw [mul_left_comm, mul_left_comm _ (ε^5), sq, mul_assoc, nat.cast_mul, mul_assoc],\n    apply add_le_add_left,\n    apply mul_le_mul_of_nonneg_left _ (eps_pow_five_pos hPε).le,\n    apply mul_le_mul_of_nonneg_left _ (nat.cast_nonneg _),\n    rw [nat.cast_sub (P.parts_nonempty $ univ_nonempty.ne_empty).card_pos, mul_sub_right_distrib,\n      nat.cast_one, one_mul, le_sub, ←mul_sub_left_distrib,\n      ←div_le_iff (show (0:ℝ) < 1/3 - 1/25 - 1/4, by norm_num)],\n    refine le_trans (show _ ≤ (7:ℝ), by norm_num) (by exact_mod_cast hP₇) },\n  exact div_nonneg (pow_bit0_nonneg _ _) (by norm_num),\nend\n\nlemma energy_increment [nonempty α] (hP : P.is_equipartition) (hP₇ : 7 ≤ P.parts.card)\n  (hε : 100 < 4^P.parts.card * ε^5) (hPα : P.parts.card * 16^P.parts.card ≤ card α)\n  (hPG : ¬P.is_uniform G ε) (hε₁ : ε ≤ 1) :\n  P.energy G + ε^5 / 4 ≤ (hP.increment G ε).energy G :=\nbegin\n  have h := uniform_add_nonuniform_eq_off_diag_pairs hε₁ hP₇ hPα hε.le hPG,\n  rw [add_div, mul_div_cancel_left] at h,\n  exact h.trans off_diag_pairs_le_increment_energy,\n  refine (sq_pos_of_ne_zero _ $ _).ne',\n  norm_cast,\n  linarith,\nend\n\nend finpartition\n", "meta": {"author": "b-mehta", "repo": "regularity-lemma", "sha": "cf26082b0c88fa54276e6fdc3338c15e607c52c6", "save_path": "github-repos/lean/b-mehta-regularity-lemma", "path": "github-repos/lean/b-mehta-regularity-lemma/regularity-lemma-cf26082b0c88fa54276e6fdc3338c15e607c52c6/src/increment.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4809041008745788}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Fabian Glöckle\n-/\nimport linear_algebra.finite_dimensional\nimport linear_algebra.projection\nimport linear_algebra.sesquilinear_form\nimport ring_theory.finiteness\nimport linear_algebra.free_module.finite.rank\n\n/-!\n# Dual vector spaces\n\nThe dual space of an R-module M is the R-module of linear maps `M → R`.\n\n## Main definitions\n\n* `dual R M` defines the dual space of M over R.\n* Given a basis for an `R`-module `M`, `basis.to_dual` produces a map from `M` to `dual R M`.\n* Given families of vectors `e` and `ε`, `dual_pair e ε` states that these families have the\n  characteristic properties of a basis and a dual.\n* `dual_annihilator W` is the submodule of `dual R M` where every element annihilates `W`.\n\n## Main results\n\n* `to_dual_equiv` : the linear equivalence between the dual module and primal module,\n  given a finite basis.\n* `dual_pair.basis` and `dual_pair.eq_dual`: if `e` and `ε` form a dual pair, `e` is a basis and\n  `ε` is its dual basis.\n* `quot_equiv_annihilator`: the quotient by a subspace is isomorphic to its dual annihilator.\n\n## Notation\n\nWe sometimes use `V'` as local notation for `dual K V`.\n\n## TODO\n\nErdös-Kaplansky theorem about the dimension of a dual vector space in case of infinite dimension.\n-/\n\nnoncomputable theory\n\nnamespace module\n\nvariables (R : Type*) (M : Type*)\nvariables [comm_semiring R] [add_comm_monoid M] [module R M]\n\n/-- The dual space of an R-module M is the R-module of linear maps `M → R`. -/\n@[derive [add_comm_monoid, module R]] def dual := M →ₗ[R] R\n\ninstance {S : Type*} [comm_ring S] {N : Type*} [add_comm_group N] [module S N] :\n  add_comm_group (dual S N) := linear_map.add_comm_group\n\ninstance : linear_map_class (dual R M) R M R :=\nlinear_map.semilinear_map_class\n\n/-- The canonical pairing of a vector space and its algebraic dual. -/\ndef dual_pairing (R M) [comm_semiring R] [add_comm_monoid M] [module R M] :\n  module.dual R M →ₗ[R] M →ₗ[R] R := linear_map.id\n\n@[simp] lemma dual_pairing_apply (v x) : dual_pairing R M v x = v x := rfl\n\nnamespace dual\n\ninstance : inhabited (dual R M) := linear_map.inhabited\n\ninstance : has_coe_to_fun (dual R M) (λ _, M → R) := ⟨linear_map.to_fun⟩\n\n/-- Maps a module M to the dual of the dual of M. See `module.erange_coe` and\n`module.eval_equiv`. -/\ndef eval : M →ₗ[R] (dual R (dual R M)) := linear_map.flip linear_map.id\n\n@[simp] lemma eval_apply (v : M) (a : dual R M) : eval R M v a = a v :=\nbegin\n  dunfold eval,\n  rw [linear_map.flip_apply, linear_map.id_apply]\nend\n\nvariables {R M} {M' : Type*} [add_comm_monoid M'] [module R M']\n\n/-- The transposition of linear maps, as a linear map from `M →ₗ[R] M'` to\n`dual R M' →ₗ[R] dual R M`. -/\ndef transpose : (M →ₗ[R] M') →ₗ[R] (dual R M' →ₗ[R] dual R M) :=\n(linear_map.llcomp R M M' R).flip\n\nlemma transpose_apply (u : M →ₗ[R] M') (l : dual R M') : transpose u l = l.comp u := rfl\n\nvariables {M'' : Type*} [add_comm_monoid M''] [module R M'']\n\nlemma transpose_comp (u : M' →ₗ[R] M'') (v : M →ₗ[R] M') :\n  transpose (u.comp v) = (transpose v).comp (transpose u) := rfl\n\nend dual\n\nend module\n\nnamespace basis\n\nuniverses u v w\n\nopen module module.dual submodule linear_map cardinal function\nopen_locale big_operators\n\nvariables {R M K V ι : Type*}\n\nsection comm_semiring\n\nvariables [comm_semiring R] [add_comm_monoid M] [module R M] [decidable_eq ι]\nvariables (b : basis ι R M)\n\n/-- The linear map from a vector space equipped with basis to its dual vector space,\ntaking basis elements to corresponding dual basis elements. -/\ndef to_dual : M →ₗ[R] module.dual R M :=\nb.constr ℕ $ λ v, b.constr ℕ $ λ w, if w = v then (1 : R) else 0\n\nlemma to_dual_apply (i j : ι) :\n  b.to_dual (b i) (b j) = if i = j then 1 else 0 :=\nby { erw [constr_basis b, constr_basis b], ac_refl }\n\n@[simp] lemma to_dual_total_left (f : ι →₀ R) (i : ι) :\n  b.to_dual (finsupp.total ι M R b f) (b i) = f i :=\nbegin\n  rw [finsupp.total_apply, finsupp.sum, linear_map.map_sum, linear_map.sum_apply],\n  simp_rw [linear_map.map_smul, linear_map.smul_apply, to_dual_apply, smul_eq_mul,\n           mul_boole, finset.sum_ite_eq'],\n  split_ifs with h,\n  { refl },\n  { rw finsupp.not_mem_support_iff.mp h }\nend\n\n@[simp] lemma to_dual_total_right (f : ι →₀ R) (i : ι) :\n  b.to_dual (b i) (finsupp.total ι M R b f) = f i :=\nbegin\n  rw [finsupp.total_apply, finsupp.sum, linear_map.map_sum],\n  simp_rw [linear_map.map_smul, to_dual_apply, smul_eq_mul, mul_boole, finset.sum_ite_eq],\n  split_ifs with h,\n  { refl },\n  { rw finsupp.not_mem_support_iff.mp h }\nend\n\nlemma to_dual_apply_left (m : M) (i : ι) : b.to_dual m (b i) = b.repr m i :=\nby rw [← b.to_dual_total_left, b.total_repr]\n\nlemma to_dual_apply_right (i : ι) (m : M) : b.to_dual (b i) m = b.repr m i :=\nby rw [← b.to_dual_total_right, b.total_repr]\n\nlemma coe_to_dual_self (i : ι) : b.to_dual (b i) = b.coord i :=\nby { ext, apply to_dual_apply_right }\n\n/-- `h.to_dual_flip v` is the linear map sending `w` to `h.to_dual w v`. -/\ndef to_dual_flip (m : M) : (M →ₗ[R] R) := b.to_dual.flip m\n\nlemma to_dual_flip_apply (m₁ m₂ : M) : b.to_dual_flip m₁ m₂ = b.to_dual m₂ m₁ := rfl\n\nlemma to_dual_eq_repr (m : M) (i : ι) : b.to_dual m (b i) = b.repr m i :=\nb.to_dual_apply_left m i\n\nlemma to_dual_eq_equiv_fun [fintype ι] (m : M) (i : ι) : b.to_dual m (b i) = b.equiv_fun m i :=\nby rw [b.equiv_fun_apply, to_dual_eq_repr]\n\nlemma to_dual_inj (m : M) (a : b.to_dual m = 0) : m = 0 :=\nbegin\n  rw [← mem_bot R, ← b.repr.ker, mem_ker, linear_equiv.coe_coe],\n  apply finsupp.ext,\n  intro b,\n  rw [← to_dual_eq_repr, a],\n  refl\nend\n\ntheorem to_dual_ker : b.to_dual.ker = ⊥ :=\nker_eq_bot'.mpr b.to_dual_inj\n\ntheorem to_dual_range [fin : fintype ι] : b.to_dual.range = ⊤ :=\nbegin\n  rw eq_top_iff',\n  intro f,\n  rw linear_map.mem_range,\n  let lin_comb : ι →₀ R := finsupp.on_finset fin.elems (λ i, f.to_fun (b i)) _,\n  { use finsupp.total ι M R b lin_comb,\n    apply b.ext,\n    { intros i,\n      rw [b.to_dual_eq_repr _ i, repr_total b],\n      { refl } } },\n  { intros a _,\n    apply fin.complete }\nend\n\nend comm_semiring\n\nsection\n\nvariables [comm_semiring R] [add_comm_monoid M] [module R M] [fintype ι]\nvariables (b : basis ι R M)\n\n@[simp] lemma sum_dual_apply_smul_coord (f : module.dual R M) : ∑ x, f (b x) • b.coord x = f :=\nbegin\n  ext m,\n  simp_rw [linear_map.sum_apply, linear_map.smul_apply, smul_eq_mul, mul_comm (f _), ←smul_eq_mul,\n    ←f.map_smul, ←f.map_sum, basis.coord_apply, basis.sum_repr],\nend\n\nend\n\nsection comm_ring\n\nvariables [comm_ring R] [add_comm_group M] [module R M] [decidable_eq ι]\nvariables (b : basis ι R M)\n\n/-- A vector space is linearly equivalent to its dual space. -/\n@[simps]\ndef to_dual_equiv [fintype ι] : M ≃ₗ[R] (dual R M) :=\nlinear_equiv.of_bijective b.to_dual\n  (ker_eq_bot.mp b.to_dual_ker) (range_eq_top.mp b.to_dual_range)\n\n/-- Maps a basis for `V` to a basis for the dual space. -/\ndef dual_basis [fintype ι] : basis ι R (dual R M) :=\nb.map b.to_dual_equiv\n\n-- We use `j = i` to match `basis.repr_self`\nlemma dual_basis_apply_self [fintype ι] (i j : ι) :\n  b.dual_basis i (b j) = if j = i then 1 else 0 :=\nby { convert b.to_dual_apply i j using 2, rw @eq_comm _ j i }\n\nlemma total_dual_basis [fintype ι] (f : ι →₀ R) (i : ι) :\n  finsupp.total ι (dual R M) R b.dual_basis f (b i) = f i :=\nbegin\n  rw [finsupp.total_apply, finsupp.sum_fintype, linear_map.sum_apply],\n  { simp_rw [linear_map.smul_apply, smul_eq_mul, dual_basis_apply_self, mul_boole,\n      finset.sum_ite_eq, if_pos (finset.mem_univ i)] },\n  { intro, rw zero_smul },\nend\n\nlemma dual_basis_repr [fintype ι] (l : dual R M) (i : ι) :\n  b.dual_basis.repr l i = l (b i) :=\nby rw [← total_dual_basis b, basis.total_repr b.dual_basis l]\n\nlemma dual_basis_equiv_fun [fintype ι] (l : dual R M) (i : ι) :\n  b.dual_basis.equiv_fun l i = l (b i) :=\nby rw [basis.equiv_fun_apply, dual_basis_repr]\n\nlemma dual_basis_apply [fintype ι] (i : ι) (m : M) : b.dual_basis i m = b.repr m i :=\nb.to_dual_apply_right i m\n\n@[simp] lemma coe_dual_basis [fintype ι] :\n  ⇑b.dual_basis = b.coord :=\nby { ext i x, apply dual_basis_apply }\n\n@[simp] lemma to_dual_to_dual [fintype ι] :\n  b.dual_basis.to_dual.comp b.to_dual = dual.eval R M :=\nbegin\n  refine b.ext (λ i, b.dual_basis.ext (λ j, _)),\n  rw [linear_map.comp_apply, to_dual_apply_left, coe_to_dual_self, ← coe_dual_basis,\n      dual.eval_apply, basis.repr_self, finsupp.single_apply, dual_basis_apply_self]\nend\n\ntheorem eval_ker {ι : Type*} (b : basis ι R M) :\n  (dual.eval R M).ker = ⊥ :=\nbegin\n  rw ker_eq_bot',\n  intros m hm,\n  simp_rw [linear_map.ext_iff, dual.eval_apply, zero_apply] at hm,\n  exact (basis.forall_coord_eq_zero_iff _).mp (λ i, hm (b.coord i))\nend\n\nlemma eval_range {ι : Type*} [fintype ι] (b : basis ι R M) :\n  (eval R M).range = ⊤ :=\nbegin\n  classical,\n  rw [← b.to_dual_to_dual, range_comp, b.to_dual_range, map_top, to_dual_range _],\n  apply_instance\nend\n\n/-- A module with a basis is linearly equivalent to the dual of its dual space. -/\ndef eval_equiv  {ι : Type*} [fintype ι] (b : basis ι R M) : M ≃ₗ[R] dual R (dual R M) :=\nlinear_equiv.of_bijective (eval R M)\n  (ker_eq_bot.mp b.eval_ker) (range_eq_top.mp b.eval_range)\n\n@[simp] lemma eval_equiv_to_linear_map {ι : Type*} [fintype ι] (b : basis ι R M) :\n  (b.eval_equiv).to_linear_map = dual.eval R M := rfl\n\nsection\n\nopen_locale classical\n\nvariables [finite R M] [free R M] [nontrivial R]\n\ninstance dual_free : free R (dual R M) := free.of_basis (free.choose_basis R M).dual_basis\n\ninstance dual_finite : finite R (dual R M) := finite.of_basis (free.choose_basis R M).dual_basis\n\nend\n\nend comm_ring\n\n/-- `simp` normal form version of `total_dual_basis` -/\n@[simp] lemma total_coord [comm_ring R] [add_comm_group M] [module R M] [fintype ι]\n  (b : basis ι R M) (f : ι →₀ R) (i : ι) :\n  finsupp.total ι (dual R M) R b.coord f (b i) = f i :=\nby { haveI := classical.dec_eq ι, rw [← coe_dual_basis, total_dual_basis] }\n\n-- TODO(jmc): generalize to rings, once `module.rank` is generalized\ntheorem dual_dim_eq [field K] [add_comm_group V] [module K V] [fintype ι] (b : basis ι K V) :\n  cardinal.lift (module.rank K V) = module.rank K (dual K V) :=\nbegin\n  classical,\n  have := linear_equiv.lift_dim_eq b.to_dual_equiv,\n  simp only [cardinal.lift_umax] at this,\n  rw [this, ← cardinal.lift_umax],\n  apply cardinal.lift_id,\nend\n\nend basis\n\nnamespace module\n\nvariables {K V : Type*}\nvariables [field K] [add_comm_group V] [module K V]\nopen module module.dual submodule linear_map cardinal basis finite_dimensional\n\ntheorem eval_ker : (eval K V).ker = ⊥ :=\nby { classical, exact (basis.of_vector_space K V).eval_ker }\n\n-- TODO(jmc): generalize to rings, once `module.rank` is generalized\ntheorem dual_dim_eq [finite_dimensional K V] :\n  cardinal.lift (module.rank K V) = module.rank K (dual K V) :=\n(basis.of_vector_space K V).dual_dim_eq\n\nlemma erange_coe [finite_dimensional K V] : (eval K V).range = ⊤ :=\nbegin\n  letI : is_noetherian K V := is_noetherian.iff_fg.2 infer_instance,\n  exact (basis.of_vector_space K V).eval_range\nend\n\nvariables (K V)\n\n/-- A vector space is linearly equivalent to the dual of its dual space. -/\ndef eval_equiv [finite_dimensional K V] : V ≃ₗ[K] dual K (dual K V) :=\nlinear_equiv.of_bijective (eval K V)\n  (ker_eq_bot.mp eval_ker) (range_eq_top.mp erange_coe)\n\nvariables {K V}\n\n@[simp] lemma eval_equiv_to_linear_map [finite_dimensional K V] :\n  (eval_equiv K V).to_linear_map = dual.eval K V := rfl\n\nend module\n\nsection dual_pair\n\nopen module\n\nvariables {R M ι : Type*}\nvariables [comm_semiring R] [add_comm_monoid M] [module R M] [decidable_eq ι]\n\n/-- `e` and `ε` have characteristic properties of a basis and its dual -/\n@[nolint has_inhabited_instance]\nstructure dual_pair (e : ι → M) (ε : ι → (dual R M)) :=\n(eval : ∀ i j : ι, ε i (e j) = if i = j then 1 else 0)\n(total : ∀ {m : M}, (∀ i, ε i m = 0) → m = 0)\n[finite : ∀ m : M, fintype {i | ε i m ≠ 0}]\n\nend dual_pair\n\nnamespace dual_pair\n\nopen module module.dual linear_map function\n\nvariables {R M ι : Type*}\nvariables [comm_ring R] [add_comm_group M] [module R M]\nvariables {e : ι → M} {ε : ι → dual R M}\n\n/-- The coefficients of `v` on the basis `e` -/\ndef coeffs [decidable_eq ι] (h : dual_pair e ε) (m : M) : ι →₀ R :=\n{ to_fun := λ i, ε i m,\n  support := by { haveI := h.finite m, exact {i : ι | ε i m ≠ 0}.to_finset },\n  mem_support_to_fun := by {intro i, rw set.mem_to_finset, exact iff.rfl } }\n\n@[simp] \n\n/-- linear combinations of elements of `e`.\nThis is a convenient abbreviation for `finsupp.total _ M R e l` -/\ndef lc {ι} (e : ι → M) (l : ι →₀ R) : M := l.sum (λ (i : ι) (a : R), a • (e i))\n\nlemma lc_def (e : ι → M) (l : ι →₀ R) : lc e l = finsupp.total _ _ _ e l := rfl\n\nvariables [decidable_eq ι] (h : dual_pair e ε)\ninclude h\n\nlemma dual_lc (l : ι →₀ R) (i : ι) : ε i (dual_pair.lc e l) = l i :=\nbegin\n  erw linear_map.map_sum,\n  simp only [h.eval, map_smul, smul_eq_mul],\n  rw finset.sum_eq_single i,\n  { simp },\n  { intros q q_in q_ne,\n    simp [q_ne.symm] },\n  { intro p_not_in,\n    simp [finsupp.not_mem_support_iff.1 p_not_in] },\nend\n\n@[simp]\nlemma coeffs_lc (l : ι →₀ R) : h.coeffs (dual_pair.lc e l) = l :=\nby { ext i, rw [h.coeffs_apply, h.dual_lc] }\n\n/-- For any m : M n, \\sum_{p ∈ Q n} (ε p m) • e p = m -/\n@[simp]\nlemma lc_coeffs (m : M) : dual_pair.lc e (h.coeffs m) = m :=\nbegin\n  refine eq_of_sub_eq_zero (h.total _),\n  intros i,\n  simp [-sub_eq_add_neg, linear_map.map_sub, h.dual_lc, sub_eq_zero]\nend\n\n/-- `(h : dual_pair e ε).basis` shows the family of vectors `e` forms a basis. -/\n@[simps]\ndef basis : basis ι R M :=\nbasis.of_repr\n{ to_fun := coeffs h,\n  inv_fun := lc e,\n  left_inv := lc_coeffs h,\n  right_inv := coeffs_lc h,\n  map_add' := λ v w, by { ext i, exact (ε i).map_add v w },\n  map_smul' := λ c v, by { ext i, exact (ε i).map_smul c v } }\n\n@[simp] lemma coe_basis : ⇑h.basis = e :=\nby { ext i, rw basis.apply_eq_iff, ext j,\n     rw [h.basis_repr_apply, coeffs_apply, h.eval, finsupp.single_apply],\n     convert if_congr eq_comm rfl rfl } -- `convert` to get rid of a `decidable_eq` mismatch\n\nlemma mem_of_mem_span {H : set ι} {x : M} (hmem : x ∈ submodule.span R (e '' H)) :\n  ∀ i : ι, ε i x ≠ 0 → i ∈ H :=\nbegin\n  intros i hi,\n  rcases (finsupp.mem_span_image_iff_total _).mp hmem with ⟨l, supp_l, rfl⟩,\n  apply not_imp_comm.mp ((finsupp.mem_supported' _ _).mp supp_l i),\n  rwa [← lc_def, h.dual_lc] at hi\nend\n\nlemma coe_dual_basis [fintype ι] : ⇑h.basis.dual_basis = ε :=\nfunext (λ i, h.basis.ext (λ j, by rw [h.basis.dual_basis_apply_self, h.coe_basis, h.eval,\n                                      if_congr eq_comm rfl rfl]))\n\nend dual_pair\n\nnamespace submodule\n\nuniverses u v w\n\nvariables {R : Type u} {M : Type v} [comm_semiring R] [add_comm_monoid M] [module R M]\nvariable {W : submodule R M}\n\n/-- The `dual_restrict` of a submodule `W` of `M` is the linear map from the\n  dual of `M` to the dual of `W` such that the domain of each linear map is\n  restricted to `W`. -/\ndef dual_restrict (W : submodule R M) :\n  module.dual R M →ₗ[R] module.dual R W :=\nlinear_map.dom_restrict' W\n\n@[simp] lemma dual_restrict_apply\n  (W : submodule R M) (φ : module.dual R M) (x : W) :\n  W.dual_restrict φ x = φ (x : M) := rfl\n\n/-- The `dual_annihilator` of a submodule `W` is the set of linear maps `φ` such\n  that `φ w = 0` for all `w ∈ W`. -/\ndef dual_annihilator {R : Type u} {M : Type v} [comm_semiring R] [add_comm_monoid M]\n  [module R M] (W : submodule R M) : submodule R $ module.dual R M :=\nW.dual_restrict.ker\n\n@[simp] lemma mem_dual_annihilator (φ : module.dual R M) :\n  φ ∈ W.dual_annihilator ↔ ∀ w ∈ W, φ w = 0 :=\nbegin\n  refine linear_map.mem_ker.trans _,\n  simp_rw [linear_map.ext_iff, dual_restrict_apply],\n  exact ⟨λ h w hw, h ⟨w, hw⟩, λ h w, h w.1 w.2⟩\nend\n\nlemma dual_restrict_ker_eq_dual_annihilator (W : submodule R M) :\n  W.dual_restrict.ker = W.dual_annihilator :=\nrfl\n\nlemma dual_annihilator_sup_eq_inf_dual_annihilator (U V : submodule R M) :\n  (U ⊔ V).dual_annihilator = U.dual_annihilator ⊓ V.dual_annihilator :=\nbegin\n  ext φ,\n  rw [mem_inf, mem_dual_annihilator, mem_dual_annihilator, mem_dual_annihilator],\n  split; intro h,\n  { refine ⟨_, _⟩;\n    intros x hx,\n    exact h x (mem_sup.2 ⟨x, hx, 0, zero_mem _, add_zero _⟩),\n    exact h x (mem_sup.2 ⟨0, zero_mem _, x, hx, zero_add _⟩) },\n  { simp_rw mem_sup,\n    rintro _ ⟨x, hx, y, hy, rfl⟩,\n    rw [linear_map.map_add, h.1 _ hx, h.2 _ hy, add_zero] }\nend\n\n/-- The pullback of a submodule in the dual space along the evaluation map. -/\ndef dual_annihilator_comap (Φ : submodule R (module.dual R M)) : submodule R M :=\nΦ.dual_annihilator.comap (module.dual.eval R M)\n\nlemma mem_dual_annihilator_comap_iff {Φ : submodule R (module.dual R M)} (x : M) :\n  x ∈ Φ.dual_annihilator_comap ↔ ∀ φ ∈ Φ, (φ x : R) = 0 :=\nby simp_rw [dual_annihilator_comap, mem_comap, mem_dual_annihilator, module.dual.eval_apply]\n\nend submodule\n\nnamespace subspace\n\nopen submodule linear_map\n\nuniverses u v w\n\n-- We work in vector spaces because `exists_is_compl` only hold for vector spaces\nvariables {K : Type u} {V : Type v} [field K] [add_comm_group V] [module K V]\n\n/-- Given a subspace `W` of `V` and an element of its dual `φ`, `dual_lift W φ` is\nthe natural extension of `φ` to an element of the dual of `V`.\nThat is, `dual_lift W φ` sends `w ∈ W` to `φ x` and `x` in the complement of `W` to `0`. -/\nnoncomputable def dual_lift (W : subspace K V) :\n  module.dual K W →ₗ[K] module.dual K V :=\nlet h := classical.indefinite_description _ W.exists_is_compl in\n  (linear_map.of_is_compl_prod h.2).comp (linear_map.inl _ _ _)\n\nvariable {W : subspace K V}\n\n@[simp] lemma dual_lift_of_subtype {φ : module.dual K W} (w : W) :\n  W.dual_lift φ (w : V) = φ w :=\nby { erw of_is_compl_left_apply _ w, refl }\n\nlemma dual_lift_of_mem {φ : module.dual K W} {w : V} (hw : w ∈ W) :\n  W.dual_lift φ w = φ ⟨w, hw⟩ :=\nby convert dual_lift_of_subtype ⟨w, hw⟩\n\n@[simp] lemma dual_restrict_comp_dual_lift (W : subspace K V) :\n  W.dual_restrict.comp W.dual_lift = 1 :=\nby { ext φ x, simp }\n\nlemma dual_restrict_left_inverse (W : subspace K V) :\n  function.left_inverse W.dual_restrict W.dual_lift :=\nλ x, show W.dual_restrict.comp W.dual_lift x = x,\n  by { rw [dual_restrict_comp_dual_lift], refl }\n\nlemma dual_lift_right_inverse (W : subspace K V) :\n  function.right_inverse W.dual_lift W.dual_restrict :=\nW.dual_restrict_left_inverse\n\nlemma dual_restrict_surjective :\n  function.surjective W.dual_restrict :=\nW.dual_lift_right_inverse.surjective\n\nlemma dual_lift_injective : function.injective W.dual_lift :=\nW.dual_restrict_left_inverse.injective\n\n/-- The quotient by the `dual_annihilator` of a subspace is isomorphic to the\n  dual of that subspace. -/\nnoncomputable def quot_annihilator_equiv (W : subspace K V) :\n  (module.dual K V ⧸ W.dual_annihilator) ≃ₗ[K] module.dual K W :=\n(quot_equiv_of_eq _ _ W.dual_restrict_ker_eq_dual_annihilator).symm.trans $\n  W.dual_restrict.quot_ker_equiv_of_surjective dual_restrict_surjective\n\n/-- The natural isomorphism forom the dual of a subspace `W` to `W.dual_lift.range`. -/\nnoncomputable def dual_equiv_dual (W : subspace K V) :\n  module.dual K W ≃ₗ[K] W.dual_lift.range :=\nlinear_equiv.of_injective _ dual_lift_injective\n\nlemma dual_equiv_dual_def (W : subspace K V) :\n  W.dual_equiv_dual.to_linear_map = W.dual_lift.range_restrict := rfl\n\n@[simp] lemma dual_equiv_dual_apply (φ : module.dual K W) :\n  W.dual_equiv_dual φ = ⟨W.dual_lift φ, mem_range.2 ⟨φ, rfl⟩⟩ := rfl\n\nsection\n\nopen_locale classical\n\nopen finite_dimensional\n\nvariables {V₁ : Type*} [add_comm_group V₁] [module K V₁]\n\ninstance [H : finite_dimensional K V] : finite_dimensional K (module.dual K V) :=\nby apply_instance\n\nvariables [finite_dimensional K V] [finite_dimensional K V₁]\n\n@[simp] lemma dual_finrank_eq :\n  finrank K (module.dual K V) = finrank K V :=\nlinear_equiv.finrank_eq (basis.of_vector_space K V).to_dual_equiv.symm\n\n/-- The quotient by the dual is isomorphic to its dual annihilator.  -/\nnoncomputable def quot_dual_equiv_annihilator (W : subspace K V) :\n  (module.dual K V ⧸ W.dual_lift.range) ≃ₗ[K] W.dual_annihilator :=\nlinear_equiv.quot_equiv_of_quot_equiv $\n  linear_equiv.trans W.quot_annihilator_equiv W.dual_equiv_dual\n\n/-- The quotient by a subspace is isomorphic to its dual annihilator. -/\nnoncomputable def quot_equiv_annihilator (W : subspace K V) :\n  (V ⧸ W) ≃ₗ[K] W.dual_annihilator :=\nbegin\n  refine _ ≪≫ₗ W.quot_dual_equiv_annihilator,\n  refine linear_equiv.quot_equiv_of_equiv _ (basis.of_vector_space K V).to_dual_equiv,\n  exact (basis.of_vector_space K W).to_dual_equiv.trans W.dual_equiv_dual\nend\n\nopen finite_dimensional\n\n@[simp]\nlemma finrank_dual_annihilator_comap_eq {Φ : subspace K (module.dual K V)} :\n  finrank K Φ.dual_annihilator_comap = finrank K Φ.dual_annihilator :=\nbegin\n  rw [submodule.dual_annihilator_comap, ← module.eval_equiv_to_linear_map],\n  exact linear_equiv.finrank_eq (linear_equiv.of_submodule' _ _),\nend\n\nlemma finrank_add_finrank_dual_annihilator_comap_eq\n  (W : subspace K (module.dual K V)) :\n  finrank K W + finrank K W.dual_annihilator_comap = finrank K V :=\nbegin\n  rw [finrank_dual_annihilator_comap_eq, W.quot_equiv_annihilator.finrank_eq.symm, add_comm,\n      submodule.finrank_quotient_add_finrank, subspace.dual_finrank_eq],\nend\n\nend\n\nend subspace\n\nopen module\n\nsection dual_map\nvariables {R : Type*} [comm_semiring R] {M₁ : Type*} {M₂ : Type*}\nvariables [add_comm_monoid M₁] [module R M₁] [add_comm_monoid M₂] [module R M₂]\n\n/-- Given a linear map `f : M₁ →ₗ[R] M₂`, `f.dual_map` is the linear map between the dual of\n`M₂` and `M₁` such that it maps the functional `φ` to `φ ∘ f`. -/\ndef linear_map.dual_map (f : M₁ →ₗ[R] M₂) : dual R M₂ →ₗ[R] dual R M₁ :=\nlinear_map.lcomp R R f\n\n@[simp] lemma linear_map.dual_map_apply (f : M₁ →ₗ[R] M₂) (g : dual R M₂) (x : M₁) :\n  f.dual_map g x = g (f x) :=\nlinear_map.lcomp_apply f g x\n\n@[simp] lemma linear_map.dual_map_id :\n  (linear_map.id : M₁ →ₗ[R] M₁).dual_map = linear_map.id :=\nby { ext, refl }\n\nlemma linear_map.dual_map_comp_dual_map {M₃ : Type*} [add_comm_group M₃] [module R M₃]\n  (f : M₁ →ₗ[R] M₂) (g : M₂ →ₗ[R] M₃) :\n  f.dual_map.comp g.dual_map = (g.comp f).dual_map :=\nrfl\n\n/-- The `linear_equiv` version of `linear_map.dual_map`. -/\ndef linear_equiv.dual_map (f : M₁ ≃ₗ[R] M₂) : dual R M₂ ≃ₗ[R] dual R M₁ :=\n{ inv_fun := f.symm.to_linear_map.dual_map,\n  left_inv :=\n    begin\n      intro φ, ext x,\n      simp only [linear_map.dual_map_apply, linear_equiv.coe_to_linear_map,\n                 linear_map.to_fun_eq_coe, linear_equiv.apply_symm_apply]\n    end,\n  right_inv :=\n    begin\n      intro φ, ext x,\n      simp only [linear_map.dual_map_apply, linear_equiv.coe_to_linear_map,\n                 linear_map.to_fun_eq_coe, linear_equiv.symm_apply_apply]\n    end,\n  .. f.to_linear_map.dual_map }\n\n@[simp] lemma linear_equiv.dual_map_apply (f : M₁ ≃ₗ[R] M₂) (g : dual R M₂) (x : M₁) :\n  f.dual_map g x = g (f x) :=\nlinear_map.lcomp_apply f g x\n\n@[simp] lemma linear_equiv.dual_map_refl :\n  (linear_equiv.refl R M₁).dual_map = linear_equiv.refl R (dual R M₁) :=\nby { ext, refl }\n\n@[simp] lemma linear_equiv.dual_map_symm {f : M₁ ≃ₗ[R] M₂} :\n  (linear_equiv.dual_map f).symm = linear_equiv.dual_map f.symm := rfl\n\nlemma linear_equiv.dual_map_trans {M₃ : Type*} [add_comm_group M₃] [module R M₃]\n  (f : M₁ ≃ₗ[R] M₂) (g : M₂ ≃ₗ[R] M₃) :\n  g.dual_map.trans f.dual_map = (f.trans g).dual_map :=\nrfl\n\nend dual_map\n\nnamespace linear_map\nvariables {R : Type*} [comm_semiring R] {M₁ : Type*} {M₂ : Type*}\nvariables [add_comm_monoid M₁] [module R M₁] [add_comm_monoid M₂] [module R M₂]\n\nvariable (f : M₁ →ₗ[R] M₂)\n\nlemma ker_dual_map_eq_dual_annihilator_range :\n  f.dual_map.ker = f.range.dual_annihilator :=\nbegin\n  ext φ, split; intro hφ,\n  { rw mem_ker at hφ,\n    rw submodule.mem_dual_annihilator,\n    rintro y ⟨x, rfl⟩,\n    rw [← dual_map_apply, hφ, zero_apply] },\n  { ext x,\n    rw dual_map_apply,\n    rw submodule.mem_dual_annihilator at hφ,\n    exact hφ (f x) ⟨x, rfl⟩ }\nend\n\nlemma range_dual_map_le_dual_annihilator_ker :\n  f.dual_map.range ≤ f.ker.dual_annihilator :=\nbegin\n  rintro _ ⟨ψ, rfl⟩,\n  simp_rw [submodule.mem_dual_annihilator, mem_ker],\n  rintro x hx,\n  rw [dual_map_apply, hx, map_zero]\nend\n\nsection finite_dimensional\n\nvariables {K : Type*} [field K] {V₁ : Type*} {V₂ : Type*}\nvariables [add_comm_group V₁] [module K V₁] [add_comm_group V₂] [module K V₂]\n\nopen finite_dimensional\n\nvariable [finite_dimensional K V₂]\n\n@[simp] lemma finrank_range_dual_map_eq_finrank_range (f : V₁ →ₗ[K] V₂) :\n  finrank K f.dual_map.range = finrank K f.range :=\nbegin\n  have := submodule.finrank_quotient_add_finrank f.range,\n  rw [(subspace.quot_equiv_annihilator f.range).finrank_eq,\n      ← ker_dual_map_eq_dual_annihilator_range] at this,\n  conv_rhs at this { rw ← subspace.dual_finrank_eq },\n  refine add_left_injective (finrank K f.dual_map.ker) _,\n  change _ + _ = _ + _,\n  rw [finrank_range_add_finrank_ker f.dual_map, add_comm, this],\nend\n\nlemma range_dual_map_eq_dual_annihilator_ker [finite_dimensional K V₁] (f : V₁ →ₗ[K] V₂) :\n  f.dual_map.range = f.ker.dual_annihilator :=\nbegin\n  refine eq_of_le_of_finrank_eq f.range_dual_map_le_dual_annihilator_ker _,\n  have := submodule.finrank_quotient_add_finrank f.ker,\n  rw (subspace.quot_equiv_annihilator f.ker).finrank_eq at this,\n  refine add_left_injective (finrank K f.ker) _,\n  simp_rw [this, finrank_range_dual_map_eq_finrank_range],\n  exact finrank_range_add_finrank_ker f,\nend\n\nend finite_dimensional\n\nsection field\n\nvariables {K V : Type*}\nvariables [field K] [add_comm_group V] [module K V]\n\nlemma dual_pairing_nondegenerate : (dual_pairing K V).nondegenerate :=\nbegin\n  refine ⟨separating_left_iff_ker_eq_bot.mpr ker_id, _⟩,\n  intros x,\n  contrapose,\n  rintros hx : x ≠ 0,\n  rw [not_forall],\n  let f : V →ₗ[K] K := classical.some (linear_pmap.mk_span_singleton x 1 hx).to_fun.exists_extend,\n  use [f],\n  refine ne_zero_of_eq_one _,\n  have h : f.comp (K ∙ x).subtype = (linear_pmap.mk_span_singleton x 1 hx).to_fun :=\n    classical.some_spec (linear_pmap.mk_span_singleton x (1 : K) hx).to_fun.exists_extend,\n  exact (fun_like.congr_fun h _).trans (linear_pmap.mk_span_singleton_apply _ hx _),\nend\n\nend field\n\nend linear_map\n\nnamespace tensor_product\n\nvariables (R : Type*) (M : Type*) (N : Type*)\n\nvariables {ι κ : Type*}\nvariables [decidable_eq ι] [decidable_eq κ]\nvariables [fintype ι] [fintype κ]\n\nopen_locale big_operators\nopen_locale tensor_product\n\nlocal attribute [ext] tensor_product.ext\n\nopen tensor_product\nopen linear_map\n\nsection\nvariables [comm_semiring R] [add_comm_monoid M] [add_comm_monoid N]\nvariables [module R M] [module R N]\n\n/--\nThe canonical linear map from `dual M ⊗ dual N` to `dual (M ⊗ N)`,\nsending `f ⊗ g` to the composition of `tensor_product.map f g` with\nthe natural isomorphism `R ⊗ R ≃ R`.\n-/\ndef dual_distrib : (dual R M) ⊗[R] (dual R N) →ₗ[R] dual R (M ⊗[R] N) :=\n(comp_right ↑(tensor_product.lid R R)) ∘ₗ hom_tensor_hom_map R M N R R\n\nvariables {R M N}\n\n@[simp]\nlemma dual_distrib_apply (f : dual R M) (g : dual R N) (m : M) (n : N) :\n  dual_distrib R M N (f ⊗ₜ g) (m ⊗ₜ n) = f m * g n :=\nby simp only [dual_distrib, coe_comp, function.comp_app, hom_tensor_hom_map_apply,\n  comp_right_apply, linear_equiv.coe_coe, map_tmul, lid_tmul, algebra.id.smul_eq_mul]\n\nend\n\nvariables {R M N}\nvariables [comm_ring R] [add_comm_group M] [add_comm_group N]\nvariables [module R M] [module R N]\n\n/--\nAn inverse to `dual_tensor_dual_map` given bases.\n-/\nnoncomputable\ndef dual_distrib_inv_of_basis (b : basis ι R M) (c : basis κ R N) :\n  dual R (M ⊗[R] N) →ₗ[R] (dual R M) ⊗[R] (dual R N) :=\n∑ i j, (ring_lmap_equiv_self R ℕ _).symm (b.dual_basis i ⊗ₜ c.dual_basis j)\n    ∘ₗ applyₗ (c j) ∘ₗ applyₗ (b i) ∘ₗ (lcurry R M N R)\n\n@[simp]\nlemma dual_distrib_inv_of_basis_apply (b : basis ι R M) (c : basis κ R N)\n  (f : dual R (M ⊗[R] N)) : dual_distrib_inv_of_basis b c f =\n  ∑ i j, (f (b i ⊗ₜ c j)) • (b.dual_basis i ⊗ₜ c.dual_basis j) :=\nby simp [dual_distrib_inv_of_basis]\n\n/--\nA linear equivalence between `dual M ⊗ dual N` and `dual (M ⊗ N)` given bases for `M` and `N`.\nIt sends `f ⊗ g` to the composition of `tensor_product.map f g` with the natural\nisomorphism `R ⊗ R ≃ R`.\n-/\n@[simps]\nnoncomputable def dual_distrib_equiv_of_basis (b : basis ι R M) (c : basis κ R N) :\n  (dual R M) ⊗[R] (dual R N) ≃ₗ[R] dual R (M ⊗[R] N) :=\nbegin\n  refine linear_equiv.of_linear\n    (dual_distrib R M N) (dual_distrib_inv_of_basis b c) _ _,\n  { ext f m n,\n    have h : ∀ (r s : R), r • s = s • r := is_commutative.comm,\n    simp only [compr₂_apply, mk_apply, comp_apply, id_apply, dual_distrib_inv_of_basis_apply,\n      linear_map.map_sum, map_smul, sum_apply, smul_apply, dual_distrib_apply, h (f _) _,\n      ← f.map_smul, ←f.map_sum, ←smul_tmul_smul, ←tmul_sum, ←sum_tmul, basis.coe_dual_basis,\n      basis.coord_apply, basis.sum_repr] },\n  { ext f g,\n    simp only [compr₂_apply, mk_apply, comp_apply, id_apply, dual_distrib_inv_of_basis_apply,\n      dual_distrib_apply, ←smul_tmul_smul, ←tmul_sum, ←sum_tmul, basis.coe_dual_basis,\n      basis.sum_dual_apply_smul_coord] }\nend\n\nvariables (R M N)\nvariables [module.finite R M] [module.finite R N] [module.free R M] [module.free R N]\nvariables [nontrivial R]\n\nopen_locale classical\n\n/--\nA linear equivalence between `dual M ⊗ dual N` and `dual (M ⊗ N)` when `M` and `N` are finite free\nmodules. It sends `f ⊗ g` to the composition of `tensor_product.map f g` with the natural\nisomorphism `R ⊗ R ≃ R`.\n-/\n@[simp]\nnoncomputable\ndef dual_distrib_equiv : (dual R M) ⊗[R] (dual R N) ≃ₗ[R] dual R (M ⊗[R] N) :=\ndual_distrib_equiv_of_basis (module.free.choose_basis R M) (module.free.choose_basis R N)\n\nend tensor_product\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/linear_algebra/dual.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676284, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4809040938494333}}
{"text": "import category_theory.limits.shapes.comm_sq\n\nnamespace category_theory\n\nopen limits\n\nvariables {C : Type*} [category C]\nvariables {W X Y Z : C} {f : W ⟶ X} {g : W ⟶ Y} {h : X ⟶ Z} {i : Y ⟶ Z} \n\nlemma is_pullback.is_iso_right (H : is_pullback f g h i) [is_iso h] : is_iso g :=\nbegin\n  have : _ ≫ 𝟙 _ = g := H.is_limit.cone_point_unique_up_to_iso_hom_comp\n    (pullback_cone_of_left_iso_is_limit h i) walking_cospan.right,\n  rw ← this,\n  apply_instance\nend\n\nlemma is_pullback.is_iso_left (H : is_pullback f g h i) [is_iso i] : is_iso f :=\nH.flip.is_iso_right\n\nlemma is_pullback.mono_left (H : is_pullback f g h i) [mono i] : mono f :=\npullback_cone.mono_fst_of_is_pullback_of_mono H.is_limit\n\nlemma is_pullback.mono_right (H : is_pullback f g h i) [mono h] : mono g :=\npullback_cone.mono_snd_of_is_pullback_of_mono H.is_limit\n\nend category_theory", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/for_mathlib/pullback_mono.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950868503681, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4808958527570626}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Jakob von Raumer\n-/\nimport algebra.big_operators.basic\nimport algebra.hom.group\nimport algebra.module.basic\nimport category_theory.endomorphism\nimport category_theory.limits.shapes.kernels\n\n/-!\n# Preadditive categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that\ncomposition of morphisms is linear in both variables.\n\nThis file contains a definition of preadditive category that directly encodes the definition given\nabove. The definition could also be phrased as follows: A preadditive category is a category\nenriched over the category of Abelian groups. Once the general framework to state this in Lean is\navailable, the contents of this file should become obsolete.\n\n## Main results\n\n* Definition of preadditive categories and basic properties\n* In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all\n  composable `g`.\n* A preadditive category with kernels has equalizers.\n\n## Implementation notes\n\nThe simp normal form for negation and composition is to push negations as far as possible to\nthe outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)`\nis simplified to `f ≫ g`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n\n## Tags\n\nadditive, preadditive, Hom group, Ab-category, Ab-enriched\n-/\n\nuniverses v u\n\nopen category_theory.limits\n\nopen_locale big_operators\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is\n    linear in both variables. -/\nclass preadditive :=\n(hom_group : Π P Q : C, add_comm_group (P ⟶ Q) . tactic.apply_instance)\n(add_comp' : ∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R),\n  (f + f') ≫ g = f ≫ g + f' ≫ g . obviously)\n(comp_add' : ∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R),\n  f ≫ (g + g') = f ≫ g + f ≫ g' . obviously)\n\nattribute [instance] preadditive.hom_group\nrestate_axiom preadditive.add_comp'\nrestate_axiom preadditive.comp_add'\nattribute [simp,reassoc] preadditive.add_comp\nattribute [reassoc] preadditive.comp_add -- (the linter doesn't like `simp` on this lemma)\nattribute [simp] preadditive.comp_add\n\nend category_theory\n\nopen category_theory\n\nnamespace category_theory\nnamespace preadditive\n\nsection preadditive\nopen add_monoid_hom\nvariables {C : Type u} [category.{v} C] [preadditive C]\n\nsection induced_category\nuniverses u'\nvariables {C} {D : Type u'} (F : D → C)\n\ninstance induced_category : preadditive.{v} (induced_category C F) :=\n{ hom_group := λ P Q, @preadditive.hom_group C _ _ (F P) (F Q),\n  add_comp' := λ P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := λ P Q R f g g', comp_add' _ _ _ _ _ _, }\n\nend induced_category\n\ninstance full_subcategory (Z : C → Prop) : preadditive.{v} (full_subcategory Z) :=\n{ hom_group := λ P Q, @preadditive.hom_group C _ _ P.obj Q.obj,\n  add_comp' := λ P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := λ P Q R f g g', comp_add' _ _ _ _ _ _, }\n\ninstance (X : C) : add_comm_group (End X) := by { dsimp [End], apply_instance, }\n\ninstance (X : C) : ring (End X) :=\n{ left_distrib := λ f g h, preadditive.add_comp X X X g h f,\n  right_distrib := λ f g h, preadditive.comp_add X X X h f g,\n  ..(infer_instance : add_comm_group (End X)),\n  ..(infer_instance : monoid (End X)) }\n\n/-- Composition by a fixed left argument as a group homomorphism -/\ndef left_comp {P Q : C} (R : C) (f : P ⟶ Q) : (Q ⟶ R) →+ (P ⟶ R) :=\nmk' (λ g, f ≫ g) $ λ g g', by simp\n\n/-- Composition by a fixed right argument as a group homomorphism -/\ndef right_comp (P : C) {Q R : C} (g : Q ⟶ R) : (P ⟶ Q) →+ (P ⟶ R) :=\nmk' (λ f, f ≫ g) $ λ f f', by simp\n\nvariables {P Q R : C} (f f' : P ⟶ Q) (g g' : Q ⟶ R)\n\n/-- Composition as a bilinear group homomorphism -/\ndef comp_hom : (P ⟶ Q) →+ (Q ⟶ R) →+ (P ⟶ R) :=\nadd_monoid_hom.mk' (λ f, left_comp _ f) $\n  λ f₁ f₂, add_monoid_hom.ext $ λ g, (right_comp _ g).map_add f₁ f₂\n\n@[simp, reassoc] lemma sub_comp :\n  (f - f') ≫ g = f ≫ g - f' ≫ g :=\nmap_sub (right_comp P g) f f'\n\n-- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma.\n@[reassoc, simp] lemma comp_sub :\n  f ≫ (g - g') = f ≫ g - f ≫ g' :=\nmap_sub (left_comp R f) g g'\n\n@[simp, reassoc] lemma neg_comp : (-f) ≫ g = -(f ≫ g) :=\nmap_neg (right_comp P g) f\n\n/- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma. -/\n@[reassoc, simp] lemma comp_neg : f ≫ (-g) = -(f ≫ g) :=\nmap_neg (left_comp R f) g\n\n@[reassoc] lemma neg_comp_neg : (-f) ≫ (-g) = f ≫ g :=\nby simp\n\nlemma nsmul_comp (n : ℕ) : (n • f) ≫ g = n • (f ≫ g) :=\nmap_nsmul (right_comp P g) n f\n\nlemma comp_nsmul (n : ℕ) : f ≫ (n • g) = n • (f ≫ g) :=\nmap_nsmul (left_comp R f) n g\n\nlemma zsmul_comp (n : ℤ) : (n • f) ≫ g = n • (f ≫ g) :=\nmap_zsmul (right_comp P g) n f\n\nlemma comp_zsmul (n : ℤ) : f ≫ (n • g) = n • (f ≫ g) :=\nmap_zsmul (left_comp R f) n g\n\n@[reassoc] lemma comp_sum {P Q R : C} {J : Type*} (s : finset J) (f : P ⟶ Q) (g : J → (Q ⟶ R)) :\n  f ≫ ∑ j in s, g j = ∑ j in s, f ≫ g j :=\nmap_sum (left_comp R f) _ _\n\n@[reassoc] lemma sum_comp {P Q R : C} {J : Type*} (s : finset J) (f : J → (P ⟶ Q)) (g : Q ⟶ R) :\n  (∑ j in s, f j) ≫ g  = ∑ j in s, f j ≫ g :=\nmap_sum (right_comp P g) _ _\n\ninstance {P Q : C} {f : P ⟶ Q} [epi f] : epi (-f) :=\n⟨λ R g g' H, by rwa [neg_comp, neg_comp, ←comp_neg, ←comp_neg, cancel_epi, neg_inj] at H⟩\n\ninstance {P Q : C} {f : P ⟶ Q} [mono f] : mono (-f) :=\n⟨λ R g g' H, by rwa [comp_neg, comp_neg, ←neg_comp, ←neg_comp, cancel_mono, neg_inj] at H⟩\n\n@[priority 100]\ninstance preadditive_has_zero_morphisms : has_zero_morphisms C :=\n{ has_zero := infer_instance,\n  comp_zero' := λ P Q f R, show left_comp R f 0 = 0, from map_zero _,\n  zero_comp' := λ P Q R f, show right_comp P f 0 = 0, from map_zero _ }\n\ninstance module_End_right {X Y : C} : module (End Y) (X ⟶ Y) :=\n{ smul_add := λ r f g, add_comp _ _ _ _ _ _,\n  smul_zero := λ r, zero_comp,\n  add_smul := λ r s f, comp_add _ _ _ _ _ _,\n  zero_smul := λ r, comp_zero }\n\nlemma mono_of_cancel_zero {Q R : C} (f : Q ⟶ R) (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) :\n  mono f :=\n⟨λ P g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (right_comp P f) g g').trans $ sub_eq_zero.2 hg⟩\n\nlemma mono_iff_cancel_zero {Q R : C} (f : Q ⟶ R) :\n  mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 :=\n⟨λ m P g, by exactI zero_of_comp_mono _, mono_of_cancel_zero f⟩\n\nlemma mono_of_kernel_zero {X Y : C} {f : X ⟶ Y} [has_limit (parallel_pair f 0)]\n  (w : kernel.ι f = 0) : mono f :=\nmono_of_cancel_zero f (λ P g h, by rw [←kernel.lift_ι f g h, w, limits.comp_zero])\n\nlemma epi_of_cancel_zero {P Q : C} (f : P ⟶ Q) (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) :\n  epi f :=\n⟨λ R g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (left_comp R f) g g').trans $ sub_eq_zero.2 hg⟩\n\nlemma epi_iff_cancel_zero {P Q : C} (f : P ⟶ Q) :\n  epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 :=\n⟨λ e R g, by exactI zero_of_epi_comp _, epi_of_cancel_zero f⟩\n\n\n\nnamespace is_iso\n\n@[simp] lemma comp_left_eq_zero [is_iso f] :\n  f ≫ g = 0 ↔ g = 0 :=\nby rw [← is_iso.eq_inv_comp, limits.comp_zero]\n\n@[simp] lemma comp_right_eq_zero [is_iso g] :\n  f ≫ g = 0 ↔ f = 0 :=\nby rw [← is_iso.eq_comp_inv, limits.zero_comp]\n\nend is_iso\n\nopen_locale zero_object\nvariables [has_zero_object C]\n\nlemma mono_of_kernel_iso_zero {X Y : C} {f : X ⟶ Y} [has_limit (parallel_pair f 0)]\n  (w : kernel f ≅ 0) : mono f :=\nmono_of_kernel_zero (zero_of_source_iso_zero _ w)\n\nlemma epi_of_cokernel_iso_zero {X Y : C} {f : X ⟶ Y} [has_colimit (parallel_pair f 0)]\n  (w : cokernel f ≅ 0) : epi f :=\nepi_of_cokernel_zero (zero_of_target_iso_zero _ w)\n\nend preadditive\n\nsection equalizers\nvariables {C : Type u} [category.{v} C] [preadditive C]\n\nsection\nvariables {X Y : C} {f : X ⟶ Y} {g : X ⟶ Y}\n\n/-- Map a kernel cone on the difference of two morphisms to the equalizer fork. -/\n@[simps X]\ndef fork_of_kernel_fork (c : kernel_fork (f - g)) : fork f g :=\nfork.of_ι c.ι $ by rw [← sub_eq_zero, ← comp_sub, c.condition]\n\n@[simp] lemma fork_of_kernel_fork_ι (c : kernel_fork (f - g)) :\n  (fork_of_kernel_fork c).ι = c.ι := rfl\n\n/-- Map any equalizer fork to a cone on the difference of the two morphisms. -/\ndef kernel_fork_of_fork (c : fork f g) : kernel_fork (f - g) :=\nfork.of_ι c.ι $ by rw [comp_sub, comp_zero, sub_eq_zero, c.condition]\n\n@[simp] lemma kernel_fork_of_fork_ι (c : fork f g) : (kernel_fork_of_fork c).ι = c.ι := rfl\n\n@[simp] lemma kernel_fork_of_fork_of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) :\n  (kernel_fork_of_fork (fork.of_ι ι w)) = kernel_fork.of_ι ι (by simp [w]) := rfl\n\n/-- A kernel of `f - g` is an equalizer of `f` and `g`. -/\ndef is_limit_fork_of_kernel_fork {c : kernel_fork (f - g)} (i : is_limit c) :\n  is_limit (fork_of_kernel_fork c) :=\nfork.is_limit.mk' _ $ λ s,\n  ⟨i.lift (kernel_fork_of_fork s), i.fac _ _,\n   λ m h, by apply fork.is_limit.hom_ext i; tidy⟩\n\n@[simp]\nlemma is_limit_fork_of_kernel_fork_lift {c : kernel_fork (f - g)} (i : is_limit c) (s : fork f g) :\n  (is_limit_fork_of_kernel_fork i).lift s = i.lift (kernel_fork_of_fork s) := rfl\n\n/-- An equalizer of `f` and `g` is a kernel of `f - g`. -/\ndef is_limit_kernel_fork_of_fork {c : fork f g} (i : is_limit c) :\n  is_limit (kernel_fork_of_fork c) :=\nfork.is_limit.mk' _ $ λ s,\n  ⟨i.lift (fork_of_kernel_fork s), i.fac _ _,\n    λ m h, by apply fork.is_limit.hom_ext i; tidy⟩\n\nvariables (f g)\n\n/-- A preadditive category has an equalizer for `f` and `g` if it has a kernel for `f - g`. -/\nlemma has_equalizer_of_has_kernel [has_kernel (f - g)] : has_equalizer f g :=\nhas_limit.mk { cone := fork_of_kernel_fork _,\n  is_limit := is_limit_fork_of_kernel_fork (equalizer_is_equalizer (f - g) 0) }\n\n/-- A preadditive category has a kernel for `f - g` if it has an equalizer for `f` and `g`. -/\nlemma has_kernel_of_has_equalizer [has_equalizer f g] : has_kernel (f - g) :=\nhas_limit.mk { cone := kernel_fork_of_fork (equalizer.fork f g),\n  is_limit := is_limit_kernel_fork_of_fork (limit.is_limit (parallel_pair f g)) }\n\nvariables {f g}\n\n/-- Map a cokernel cocone on the difference of two morphisms to the coequalizer cofork. -/\n@[simps X]\ndef cofork_of_cokernel_cofork (c : cokernel_cofork (f - g)) : cofork f g :=\ncofork.of_π c.π $ by rw [← sub_eq_zero, ← sub_comp, c.condition]\n\n@[simp] lemma cofork_of_cokernel_cofork_π (c : cokernel_cofork (f - g)) :\n  (cofork_of_cokernel_cofork c).π = c.π := rfl\n\n/-- Map any coequalizer cofork to a cocone on the difference of the two morphisms. -/\ndef cokernel_cofork_of_cofork (c : cofork f g) : cokernel_cofork (f - g) :=\ncofork.of_π c.π $ by rw [sub_comp, zero_comp, sub_eq_zero, c.condition]\n\n@[simp] lemma cokernel_cofork_of_cofork_π (c : cofork f g) :\n  (cokernel_cofork_of_cofork c).π = c.π := rfl\n\n@[simp] lemma cokernel_cofork_of_cofork_of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) :\n  (cokernel_cofork_of_cofork (cofork.of_π π w)) = cokernel_cofork.of_π π (by simp [w]) := rfl\n\n/-- A cokernel of `f - g` is a coequalizer of `f` and `g`. -/\ndef is_colimit_cofork_of_cokernel_cofork {c : cokernel_cofork (f - g)} (i : is_colimit c) :\n  is_colimit (cofork_of_cokernel_cofork c) :=\ncofork.is_colimit.mk' _ $ λ s,\n  ⟨i.desc (cokernel_cofork_of_cofork s), i.fac _ _,\n    λ m h, by apply cofork.is_colimit.hom_ext i; tidy⟩\n\n@[simp]\nlemma is_colimit_cofork_of_cokernel_cofork_desc {c : cokernel_cofork (f - g)}\n  (i : is_colimit c) (s : cofork f g) :\n  (is_colimit_cofork_of_cokernel_cofork i).desc s = i.desc (cokernel_cofork_of_cofork s) := rfl\n\n/-- A coequalizer of `f` and `g` is a cokernel of `f - g`. -/\ndef is_colimit_cokernel_cofork_of_cofork {c : cofork f g} (i : is_colimit c) :\n  is_colimit (cokernel_cofork_of_cofork c) :=\ncofork.is_colimit.mk' _ $ λ s,\n  ⟨i.desc (cofork_of_cokernel_cofork s), i.fac _ _,\n    λ m h, by apply cofork.is_colimit.hom_ext i; tidy⟩\n\nvariables (f g)\n\n/-- A preadditive category has a coequalizer for `f` and `g` if it has a cokernel for `f - g`. -/\nlemma has_coequalizer_of_has_cokernel [has_cokernel (f - g)] : has_coequalizer f g :=\nhas_colimit.mk { cocone := cofork_of_cokernel_cofork _,\n  is_colimit := is_colimit_cofork_of_cokernel_cofork (coequalizer_is_coequalizer (f - g) 0) }\n\n/-- A preadditive category has a cokernel for `f - g` if it has a coequalizer for `f` and `g`. -/\nlemma has_cokernel_of_has_coequalizer [has_coequalizer f g] : has_cokernel (f - g) :=\nhas_colimit.mk { cocone := cokernel_cofork_of_cofork (coequalizer.cofork f g),\n  is_colimit := is_colimit_cokernel_cofork_of_cofork (colimit.is_colimit (parallel_pair f g)) }\n\nend\n\n/-- If a preadditive category has all kernels, then it also has all equalizers. -/\nlemma has_equalizers_of_has_kernels [has_kernels C] : has_equalizers C :=\n@has_equalizers_of_has_limit_parallel_pair _ _ (λ _ _ f g, has_equalizer_of_has_kernel f g)\n\n\n/-- If a preadditive category has all cokernels, then it also has all coequalizers. -/\nlemma has_coequalizers_of_has_cokernels [has_cokernels C] : has_coequalizers C :=\n@has_coequalizers_of_has_colimit_parallel_pair _ _ (λ _ _ f g, has_coequalizer_of_has_cokernel f g)\n\nend equalizers\n\nend preadditive\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/preadditive/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.629774621301746, "lm_q1q2_score": 0.4808227048408179}}
{"text": "\nexample (p q r : Prop) (hp : p) : q ∨ p ∨ r :=\n  by repeat (first |apply Or.inl; assumption | apply Or.inr | assumption)\n example (p q r : Prop) (hp : p)\n         : (p ∨ q ∨ r) ∧ (q ∨ p ∨ r) ∧ (q ∨ r ∨ p) := by\n  repeat(any_goals (first | apply And.intro | apply Or.inl; assumption | apply Or.inr | assumption))\n \nvariable (x y : Nat)\n\ndef double := x + x\n#eval Lean.versionString\n\n#check double y\n#check Nat.succ_ne_zero\n\ninductive Weekday where \n  | sunday\n  | monday\n  | tuesday\n  | wednesday\n  | thursday\n  | friday\n  | saturday\n  deriving Repr\n\nopen Weekday\n\n#eval sunday\n\ndef next (d : Weekday) : Weekday :=\n  match d with\n  | sunday    => monday\n  | monday    => tuesday\n  | tuesday   => wednesday\n  | wednesday => thursday\n  | thursday  => friday\n  | friday    => saturday\n  | saturday  => sunday\n\ndef previous (d : Weekday) : Weekday :=\n  match d with\n  | sunday    => saturday\n  | monday    => sunday\n  | tuesday   => monday\n  | wednesday => tuesday\n  | thursday  => wednesday\n  | friday    => thursday\n  | saturday  => friday\n\n#eval next (next tuesday)      -- Weekday.thursday\n#eval next (previous tuesday)  -- Weekday.tuesday\n\nexample : next (previous tuesday) = tuesday :=\n  rfl \ndef next_previous (d : Weekday) : next (previous d) = d := by \n  cases d <;> rfl\n\ndef and1 ( a b : Bool) : Bool := \n  match a with \n  | true => b\n  | false => false\n\ndef prod_example (p : Bool × Nat) : Nat :=\n  Prod.casesOn (motive := fun _ => Nat ) p (fun b n => cond b (2 * n) (2*n + 1))\n\n#eval prod_example (true, 3)\n#eval prod_example (false, 3)\n\ndef fst {α : Type u} {β : Type v} {p : Prod α β} : α := \n  match p with \n  | Prod.mk a b => a\n\ndef snd {α : Type u} {β : Type v} (p : Prod α β ) : β := \n  match p with \n  | Prod.mk a b => b\n\ndef sum_example (s : Sum Nat Nat) : Nat := \nSum.casesOn (motive := fun _ => Nat) s\n    (fun n => 2 * n)\n    (fun n => 2 * n + 1)\n\n#eval sum_example (Sum.inl 3)\n#eval sum_example (Sum.inr 3)\nnamespace Hidden \nstructure Prod (α : Type u) (β : Type v) where\n  mk :: (fst : α) (snd : β)\ninductive Sigma {α : Type u} ( β : α → Type v) where \n  | mk : (a : α) → β a → Sigma β \ninductive Option (α : Type u) where \n  | none : Option α \n  | some : α → Option α \n\ninductive False : Prop\nend Hidden\n\nstructure Color where \n  (red : Nat) (green : Nat) (blue : Nat)\n  deriving Repr\n\ndef yellow := Color.mk 255 255 0\n#eval Color.red yellow\n\nstructure semigroup where\n  carrier : Type u\n  mul : carrier → carrier → carrier\n  mul_assoc : ∀ a b c, mul (mul a b) c = mul a (mul b c)\n\nnamespace Hidden\nopen Nat\n\ntheorem zero_add (n : Nat) : 0 + n = n :=\n  Nat.recOn (motive := fun x => 0 + x = x)\n   n\n   (show 0 + 0 = 0 from rfl)\n   (fun (n : Nat) (ih : 0 + n = n) =>\n    show 0 + succ n = succ n from\n    calc\n       0 + succ n = succ (0 + n) := rfl\n                _ = succ n       := by rw [ih])\ntheorem add_assoc ( m n k : Nat) : m + n + k = m + (n + k) := \n  Nat.recOn (motive := fun k => m + n + k = m + (n + k) ) k \n    rfl \n    (fun k ih => by simp [Nat.add_succ, ih])\n\nend Hidden\n\nopen Nat \ntheorem zero_add (n : Nat) : 0 + n = n := \n  Nat.recOn (motive := fun x => 0 + x = x) n\n  rfl \n  (fun n ih => by simp [add_succ, ih])\nnamespace hidden\ntheorem succ_add (m n : Nat) : succ n + m = succ (n + m) := \n  Nat.recOn (motive := fun x => succ n + x = succ (n + x)) m\n    rfl \n    (fun m ih => by simp only [add_succ, ih])\n\ntheorem add_comm (m n : Nat) : m + n = n + m :=\n  Nat.recOn (motive := fun x => m + x = x + m) n\n    (by simp)\n    (fun m ih => by simp only [add_succ, succ_add, ih])\nend hidden\n\nnamespace Hidden\ninductive List (α : Type u) where\n| nil : List α \n| cons : α → List α → List α \n\nnamespace List\ndef append (as bs : List α) : List α := \n  match as with \n  | nil => bs \n  | cons a as => cons a (append as bs)\ntheorem nil_append (as : List α) : append nil as = as := \n  rfl \n\ntheorem cons_append (a : α) (as bs : List α)\n          : append (cons a as) bs = cons a (append as bs) := \n          rfl \n#check @List.recOn\ntheorem append_nil (as : List α) : append as nil = as := \n  List.recOn  (motive := fun x => append x nil = x) as\n    rfl \n    (fun a as ih => by simp [cons_append, ih]\n    )\n#print append_nil\ntheorem append_assoc (as bs cs : List α)\n        : append (append as bs) cs = append as (append bs cs) :=\n  List.recOn (motive := fun as => append (append as bs) cs = append as (append bs cs)) as\n    rfl \n    (fun a as ih => by simp [cons_append, ih]) \ndef length (as : List α) : Nat := \n  match as with\n  | nil => 0\n  | cons a as => 1 + length as\n\nattribute [simp] append_nil\nattribute [simp] append_assoc\nattribute [simp] cons_append\n\ntheorem length_sum (as bs : List α) : length (append as bs) = length as + length bs :=\n  List.recOn (motive := fun as => length (append as bs) = length as + length bs) as \n    (show length (append nil bs) = length nil + length bs from \n      calc length (append nil bs) = length bs := rfl\n              _ = 0 + length bs := by rw[ Nat.zero_add]\n              _ = length nil + length bs := rfl\n    ) \n    (fun a as ih =>\n    calc length (append (cons a as) bs) = length (cons a (append as bs)) := by rw[cons_append]\n          _ = 1 + length ( append as bs) := rfl\n          _ = 1 + (length as + length bs) := by simp[ih] \n          _ = (1 + length as) + length bs := by simp[Nat.add_assoc]\n          _ = length (cons a as) + length bs := rfl\n    )\ninductive BinaryTree where \n  | leaf : BinaryTree\n  | node : BinaryTree → BinaryTree → BinaryTree\n\ninductive CBTree where\nend List\nend Hidden \n\nexample (p : Nat → Prop) (hz : p 0) (hs : ∀ n, p (Nat.succ n)) : ∀ n, p n := by\n  intro n\n  cases n\n  . exact hz  -- goal is p 0\n  . apply hs  -- goal is a : ℕ ⊢ p (succ a)\n\nexample (n : Nat) (h : n ≠  0) : succ (pred n) = n := by \n  cases n with \n  | zero =>\n    apply absurd rfl h \n  | succ m => \n  rfl\n\ndef f (n : Nat) : Nat := by\n  cases n; exact 3; exact 7\n\nexample : f 0 = 3 := rfl\nexample : f 5 = 7 := rfl\n\ndef Tuple (α : Type) (n : Nat) := \n{ as : List α // as.length = n}\ndef fr {n :Nat} {t : Tuple α n} : Nat := by \n  cases n ; exact 3; exact 7\n\ndef myTuple : Tuple Nat 3 :=\n⟨ [0,1,2], rfl ⟩ \n\ninductive Foo where \n| bar1 : Nat → Nat → Foo\n| bar2 : Nat → Nat → Nat → Foo\n\ndef silly (x : Foo) : Nat := by \n  cases x with \n  | bar2 c d e => exact e\n  | bar1 a b => exact b\n\nopen Nat \nexample (p : Nat → Prop) (hz : p 0) (hs : ∀ n , p (succ n)) (m k : Nat) : p (m + 3 * k) := by \n  generalize m + 3 * k = n \n  cases n \n  exact hz \n  apply hs\n\nexample (p : Prop) (m n : Nat) (h₁ : m < n → p) (h₂ : m ≥ n → p) : p := by \n  cases Nat.lt_or_ge m n \n  case inl hlt => exact h₁ hlt \n  case inr glt => exact h₂ glt\n\n  #check Nat.sub_self\n  example (m n : Nat) : m - n = 0 ∨ m ≠ n := by \n    cases Decidable.em (m = n) with \n    | inl heq => rw [heq] ; apply Or.inl; exact Nat.sub_self n \n    | inr hne => apply Or.inr; exact hne \nnamespace Hidden1\ntheorem zero_add (n : Nat) : 0 + n = n := by\n  induction n\n  case zero => rfl\n  case succ n ih => rw [Nat.add_succ, ih]\nend Hidden1\n\nexample (x : Nat) {y : Nat} (h : y > 0) : x % y < y := by \n  induction x, y using Nat.mod.inductionOn with \n  | ind x y h₁ ih =>\n    rw [Nat.mod_eq_sub_mod h₁.2]\n    exact ih h\n  | base x y h₁ =>\n    have : ¬ 0 < y ∨ ¬ y ≤ x := Iff.mp (Decidable.not_and_iff_or_not ..) h₁\n    match this with \n    | Or.inl h₁ => exact absurd h h₁ \n    | Or.inr h₁ => \n      have hgt : y > x := Nat.gt_of_not_le h₁ \n      rw [← Nat.mod_eq_of_lt hgt] at hgt\n      assumption\n\n", "meta": {"author": "Shraze97", "repo": "lean-4", "sha": "1500213bd98a211c1a62e95d14e8e200a151a2cf", "save_path": "github-repos/lean/Shraze97-lean-4", "path": "github-repos/lean/Shraze97-lean-4/lean-4-1500213bd98a211c1a62e95d14e8e200a151a2cf/Practice2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.4807710162729502}}
{"text": "import data.set\n\nimport .formula\nimport .derivations\nimport .tactics\nimport .logics\nimport .consistency\nimport .enumeration\n\nopen_locale classical\n\nreserve prefix `□⁻¹` :40\nreserve prefix `◇⁻¹` :40\n\nnotation □⁻¹Γ := {a | (□a) ∈ Γ}\nnotation ◇⁻¹Γ := {a | (◇a) ∈ Γ}\nnotation □Γ := {(□a) | a ∈ Γ}\nnotation ◇Γ := {(◇a) | a ∈ Γ}\n\n/-- As set `s` is complete if, for any formula `x`, either `x` or `¬x` is contained in `s`. -/\ndef set.complete (s : set formula) := ∀x, x ∈ s ∨ (¬x) ∈ s\n\n/-- As set `s` is complete `Σ`-consistent if it is complete and `Σ`-consistent. -/\ndef set.complete_consistent (s : set formula) (axms) := s.consistent axms ∧ s.complete\n\n@[simp] lemma set.complete_consistent.not_mem_iff {axms : set formula} {Γ : set formula} (hcc : Γ.complete_consistent axms) {a : formula} :\n  a ∉ Γ ↔ (¬a) ∈ Γ :=\nbegin\n  apply iff.intro,\n  { intro h,\n    cases hcc with _ hc,\n    rw set.complete at hc,\n    apply or.resolve_left (hc a) h, },\n  { intro h,\n    cases hcc with hc _,\n    rw set.consistent at hc,\n    by_contradiction ha,\n    apply hc,\n    have hdna := derivable.reflexivity h,\n    apply derivable.from.mp a,\n    { apply derivable.from.mp ¬a,\n      { derive_taut, },\n      { exact hdna, }, },\n    apply derivable.reflexivity ha, },\nend\n\nlemma set.complete_consistent.deductive_closure {axms : set formula} {Γ : set formula} (hcc : Γ.complete_consistent axms) (a : formula) :\n  (Γ ⊢[axms] a) → a ∈ Γ :=\nbegin\n  intro ha,\n  by_contradiction,\n  rw set.complete_consistent.not_mem_iff at h,\n  { cases hcc with h₁ h₂,\n    apply h₁,\n    apply derivable.from.mp a,\n    { apply derivable.from.mp ¬a,\n      { derive_taut, },\n      { apply derivable.reflexivity,\n        assumption, }, },\n    assumption, },\n  assumption,\nend\n\nlemma set.complete_consistent.not_mem_bot {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) :\n  formula.bottom ∉ Γ :=\nbegin\n  by_contradiction,\n  apply hΓ.elim_left,\n  exact derivable.reflexivity h,\nend\n\nlemma set.complete_consistent.mem_top {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) :\n  formula.top ∈ Γ :=\nbegin\n  apply set.complete_consistent.deductive_closure hΓ,\n  derive_taut,\nend\n\nlemma set.complete_consistent.mem_and {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) {a b : formula} :\n  (a ∧ b) ∈ Γ ↔ a ∈ Γ ∧ b ∈ Γ :=\nbegin\n  apply iff.intro,\n  { intro h,\n    split,\n    repeat {\n      apply set.complete_consistent.deductive_closure hΓ,\n      apply derivable.from.mp (a ∧ b) _ _ (derivable.reflexivity h),\n      derive_taut,\n    }, },\n  { intro h,\n    apply set.complete_consistent.deductive_closure hΓ,\n    apply derivable.from.mp a,\n    apply derivable.from.mp b,\n    derive_taut,\n    exact derivable.reflexivity (and.elim_right h),\n    exact derivable.reflexivity (and.elim_left h), },\nend\n\nlemma set.complete_consistent.mem_or {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) {a b : formula} :\n  (a ∨ b) ∈ Γ ↔ a ∈ Γ ∨ b ∈ Γ :=\nbegin\n  apply iff.intro,\n  { intro h,\n    { by_contradiction h',\n      apply not.elim _ h,\n      rw set.complete_consistent.not_mem_iff hΓ,\n      apply set.complete_consistent.deductive_closure hΓ,\n      apply derivable.from.mp (¬a),\n      apply derivable.from.mp (¬b),\n      derive_taut,\n      repeat {\n        apply derivable.reflexivity,\n        rw ←set.complete_consistent.not_mem_iff hΓ,\n        tauto,\n      }, }, },\n  { intro h,\n    apply set.complete_consistent.deductive_closure hΓ,\n    cases h,\n    { apply derivable.from.mp _ _ _ (derivable.reflexivity h),\n      derive_taut, },\n    { apply derivable.from.mp _ _ _ (derivable.reflexivity h),\n      derive_taut, }, },\nend\n\nlemma set.complete_consistent.mem_imp {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) {a b : formula} :\n  (a ⟶ b) ∈ Γ ↔ a ∈ Γ → b ∈ Γ :=\nbegin\n  apply iff.intro,\n  { intro h,\n    { by_contradiction h',\n      apply not.elim _ h,\n      rw set.complete_consistent.not_mem_iff hΓ,\n      apply set.complete_consistent.deductive_closure hΓ,\n      apply derivable.from.mp a,\n      apply derivable.from.mp (¬b),\n      derive_taut,\n      { apply derivable.reflexivity,\n        rw ←set.complete_consistent.not_mem_iff hΓ,\n        tauto, },\n      { apply derivable.reflexivity,\n        tauto, }, }, },\n  { intro h,\n    apply set.complete_consistent.deductive_closure hΓ,\n    have h := not_or_of_imp h,\n    cases h,\n    { rw set.complete_consistent.not_mem_iff hΓ at h_1,\n      apply derivable.from.mp _ _ _ (derivable.reflexivity h_1),\n      derive_taut, },\n    { apply derivable.from.mp _ _ _ (derivable.reflexivity h_1),\n      derive_taut, }, },\nend\n\nlemma set.complete_consistent.mem_iff {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) {a b : formula} :\n  (a ↔ b) ∈ Γ ↔ (a ∈ Γ ↔ b ∈ Γ) :=\nbegin\n  apply iff.intro,\n  { intro h,\n    apply iff.intro,\n    repeat {\n      intro h',\n      apply set.complete_consistent.deductive_closure hΓ,\n      apply derivable.from.mp _ _ _ (derivable.reflexivity h'),\n      apply derivable.from.mp _ _ _ (derivable.reflexivity h),\n      derive_taut,\n    }, },\n  { intro h,\n    apply set.complete_consistent.deductive_closure hΓ,\n    by_cases ha : a ∈ Γ,\n    { apply derivable.from.mp _ _ _ (derivable.reflexivity ha),\n      apply derivable.from.mp _ _ _ (derivable.reflexivity (h.mp ha)),\n      derive_taut, },\n    { have hna := (set.complete_consistent.not_mem_iff hΓ).mp ha,\n      have hnb := (set.complete_consistent.not_mem_iff hΓ).mp ((iff_false_left ha).mp h),\n      apply derivable.from.mp _ _ _ (derivable.reflexivity hna),\n      apply derivable.from.mp _ _ _ (derivable.reflexivity hnb),\n      derive_taut, }, },\nend\n\nlemma derive_imp_derive_box {axms} {Γ : set formula} {a : formula} :\n  (Γ ⊢[axms] a) → (□Γ ⊢[axms] □a) :=\nbegin\n  intro hda,\n  cases hda with xs hxs,\n  cases hxs with hxs hda,\n  apply exists.intro (xs.map (λa, □a)),\n  split,\n  { intros x hx,\n    simp * at *,\n    cases hx with a ha,\n    apply exists.intro a,\n    simp *, },\n  { exact derivable.RK hda, },\nend\n\nlemma debox_derive_imp_derive_box {axms} {Γ : set formula} {a : formula} :\n  (□⁻¹Γ ⊢[axms] a) → (Γ ⊢[axms] □a) :=\nbegin\n  intro hda,\n  cases hda with xs hxs,\n  cases hxs with hxs hda,\n  apply exists.intro (xs.map (λa, □a)),\n  split,\n  { intros x hx,\n    simp * at *,\n    cases hx with a ha,\n    rw ←ha.elim_right,\n    apply hxs,\n    exact ha.elim_left, },\n  { exact derivable.RK hda, },\nend\n\ndef ccₙ (s axms : set formula) : ℕ → set formula\n| 0 := s\n| (n + 1) := if (ccₙ n ∪ {enumerate n}).consistent axms\n  then ccₙ n ∪ {enumerate n}\n  else ccₙ n ∪ {¬enumerate n}\n\n/-- `cc s Σ` constructs a complete, `Σ`-consistent set built upon `s`. -/\ndef cc (s : set formula) (axms) : set formula := ⋃n, ccₙ s axms n\n\nlemma ccₙ_sub_cc (s) (axms) (n : ℕ) : ccₙ s axms n ⊆ cc s axms :=\nbegin\n  intros x hn,\n  rw cc,\n  rw set.mem_Union,\n  apply exists.intro n,\n  assumption,\nend\n\nlemma ccₙ_sub_ccₘ' (s axms) (n m) : ccₙ s axms n ⊆ ccₙ s axms (n + m) :=\nbegin\n  intros x hn,\n  induction m,\n  { assumption, },\n  { rw nat.add_succ,\n    rw ccₙ,\n    by_cases (ccₙ s axms (n + m_n) ∪ {enumerate (n + m_n)}).consistent axms,\n    { simp [h, m_ih], },\n    { simp [h, m_ih], }, },\nend\n\nlemma ccₙ_sub_ccₘ (s axms) (n m : ℕ) (hm : m ≥ n) : ccₙ s axms n ⊆ ccₙ s axms m :=\nbegin\n  have h := ccₙ_sub_ccₘ' s axms n (m - n),\n  simp [nat.add_sub_of_le hm] at h,\n  assumption,\nend\n\nlemma ccₙ_consistent (s axms : set formula) (n : ℕ) (h₀ : s.consistent axms) :\n  (ccₙ s axms n).consistent axms :=\nbegin\n  induction n,\n  { simp [ccₙ, h₀], },\n  { rw ccₙ,\n    by_cases (ccₙ s axms n_n ∪ {enumerate n_n}).consistent axms;\n    have h' := consistent_extensible (ccₙ s axms n_n) axms n_ih (enumerate n_n),\n    { simp [h] at *,\n      assumption, },\n    { simp [h] at *,\n      exact or.resolve_left h' h, }, },\nend\n\nlemma minimal_ccₙ (s axms : set formula) (xs : list formula) (hxs : ∀x ∈ xs, x ∈ cc s axms) :\n  ∃n, ∀x ∈ xs, x ∈ ccₙ s axms n :=\nbegin\n  induction xs with _ _ ih,\n  { simp, },\n  { have hxs' : ∀ (x : formula), x ∈ xs_tl → x ∈ cc s axms := begin\n      intros x hx,\n      apply hxs,\n      apply or.intro_right,\n      exact hx,\n    end,\n    apply exists.elim (ih hxs'),\n    intros n hn,\n    have hx := hxs xs_hd (or.intro_left _ (by refl)),\n    rw [cc, set.mem_Union] at hx,\n    apply exists.elim hx,\n    intros n' hn',\n    apply exists.intro (max n n'),\n    intros a ha,\n    cases ha,\n    { apply ccₙ_sub_ccₘ s axms n' _,\n      { simp, },\n      { simp [ha, hn'], }, },\n    { apply ccₙ_sub_ccₘ s axms n _,\n      { simp },\n      { apply hn,\n        exact ha, }, }, },\nend\n\nlemma cc_consistent (s axms : set formula) (h₀ : s.consistent axms) :\n  (cc s axms).consistent axms :=\nbegin\n  by_contradiction,\n  simp [set.consistent] at h,\n  apply exists.elim h,\n  intros xs hxs,\n  clear h,\n  cases hxs with hxs hdb,\n  have h := minimal_ccₙ s axms xs hxs,\n  apply exists.elim h,\n  intros n hn,\n  have hnc := ccₙ_consistent s axms n h₀,\n  apply not.elim hnc,\n  apply exists.intro xs,\n  split,\n  assumption',\nend\n\n/-- For any `Σ` consistent set `s`, there exists a complete, `Σ`-consistent set built upon `s`. -/\ntheorem lindenbaum {axms : set formula} {s : set formula} (hcc : s.consistent axms) :\n  ∃s' ⊇ s, s'.complete_consistent axms :=\nbegin\n  apply exists.intro (cc s axms),\n  split,\n  { intros x hx,\n    rw [cc, set.mem_Union],\n    apply exists.intro 0,\n    rw ccₙ,\n    assumption, },\n  { split,\n    { exact cc_consistent s axms hcc, },\n    { rw set.complete,\n      intros x,\n      apply exists.elim (enumerate.complete x),\n      intros n hn,\n      rw [cc, set.mem_Union, set.mem_Union],\n      cases classical.em (((ccₙ s axms n) ∪ {x}).consistent axms),\n      { apply or.intro_left,\n        apply exists.intro (n + 1),\n        simp at h,\n        simp [ccₙ, hn, h], },\n      { apply or.intro_right,\n        apply exists.intro (n + 1),\n        simp at h,\n        simp [ccₙ, hn, h], }, }, },\nend\n\nlemma derivable_iff_mem_cc (axms Γ : set formula) (a : formula) :\n  (Γ ⊢[axms] a) ↔ (∀Δ ⊇ Γ, Δ.complete_consistent axms → a ∈ Δ) :=\nbegin\n  apply iff.intro,\n  { intros hda Δ hΔ hcc,\n    by_contradiction,\n    cases hcc with hconsistent hcomplete,\n    apply hconsistent,\n    apply derivable.from.mp a,\n    { apply derivable.from.mp ¬a,\n      { derive_taut, },\n      { rw set.complete at hcomplete,\n        apply derivable.reflexivity,\n        exact or.resolve_left (hcomplete a) h, }, },\n    { exact derivable.monotonicity Γ Δ hΔ hda, }, },\n  { intros h,\n    by_contradiction hnc,\n    rw [derivable_iff_not_consistent, not_not] at hnc,\n    cases lindenbaum hnc with Δ hΔ,\n    cases hΔ with hΔ hΔcc,\n    apply @not.elim (a ∈ Δ),\n    { rw set.complete_consistent.not_mem_iff hΔcc,\n      apply set.mem_of_subset_of_mem hΔ,\n      simp, },\n    { refine h Δ _ hΔcc,\n      intros x hx,\n      exact hΔ (or.intro_left _ hx), }, },\nend\n\nlemma set.complete_consistent.mem_box {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) {a : formula} :\n  (□a) ∈ Γ ↔ ∀Δ : set formula, Δ.complete_consistent axms → (□⁻¹Γ) ⊆ Δ → a ∈ Δ :=\nbegin\n  apply iff.intro,\n  { intros hba Δ hΔcc hΔ,\n    apply hΔ,\n    exact hba, },\n  { contrapose,\n    intros hnba h,\n    have hndba : ¬(Γ ⊢[axms] □a) := begin\n      by_contradiction,\n      apply hnba,\n      exact set.complete_consistent.deductive_closure hΓ _ h,\n    end,\n    have hndba' : ¬(□⁻¹Γ ⊢[axms] a) := begin\n      by_contradiction,\n      apply hndba,\n      exact debox_derive_imp_derive_box h,\n    end,\n    have hnc := (iff_false_left hndba').mp derivable_iff_not_consistent,\n    rw not_not at hnc,\n    cases lindenbaum hnc with Δ hΔ,\n    cases hΔ with hΔ hΔcc, \n    apply not.elim,\n    { change a ∉ Δ,\n      intro ha,\n      apply hΔcc.elim_left,\n      apply derivable.from.mp a _ _ (derivable.reflexivity ha),\n      apply derivable.from.mp ¬a,\n      derive_taut,\n      apply derivable.reflexivity,\n      apply hΔ,\n      simp, },\n    { apply h Δ hΔcc,\n      intros x hx,\n      apply hΔ,\n      exact or.intro_left _ hx, }, },\nend\n\nlemma set.complete_consistent.debox_subset_iff {axms} {Γ Δ : set formula}\n    (hΓ : Γ.complete_consistent axms) (hΔ : Δ.complete_consistent axms) :\n  (□⁻¹Γ) ⊆ Δ ↔ (◇Δ) ⊆ Γ :=\nbegin\n  apply iff.intro,\n  { intros h x hx,\n    cases hx with a ha,\n    cases ha with ha hx,\n    rw ←hx at *,\n    clear hx x,\n    apply set.complete_consistent.deductive_closure hΓ,\n    apply derivable.from.mp ¬□¬a,\n    { apply derivable.from.mp (dual a),\n      { derive_taut, },\n      { ignore_premises,\n        apply derivable.dual, }, },\n    { apply derivable.reflexivity,\n      apply (hΓ.elim_right _).resolve_left,\n      by_contradiction h',\n      apply not.elim _ ha,\n      rw set.complete_consistent.not_mem_iff hΔ,\n      exact h h', }, },\n  { intros h a,\n    simp at h,\n    contrapose,\n    intro ha,\n    change (□a) ∉ Γ,\n    rw set.complete_consistent.not_mem_iff hΓ,\n    apply set.complete_consistent.deductive_closure hΓ,\n    { rw derivable.from.not_box_iff_diamond_not,\n      apply derivable.reflexivity,\n      rw set.complete_consistent.not_mem_iff hΔ at ha,\n      apply h,\n      simp,\n      exact ha, }, },\nend\n\nlemma set.complete_consistent.mem_diamond {axms} {Γ : set formula} (hΓ : Γ.complete_consistent axms) {a : formula} :\n  (◇a) ∈ Γ ↔ ∃Δ : set formula, Δ.complete_consistent axms ∧ (◇Δ) ⊆ Γ ∧ a ∈ Δ :=\nbegin\n  -- have h₁ : (◇a) ∈ Γ ↔ (¬□¬a) ∈ Γ := sorry,\n  -- have h₂ : (¬□¬a) ∈ Γ ↔ (□¬a) ∉ Γ := sorry,\n  -- have h₃ := set.complete_consistent.mem_box hΓ,\n  sorry\nend\n\ndef set.canonical_model (axms : set formula) : model :=\n{\n  world := set formula,\n  w := {Δ | Δ.complete_consistent axms},\n  r := λΔ Δ', (□⁻¹Δ) ⊆ Δ',\n  v := λp, {Δ | formula.symbol p ∈ Δ},\n}\n\n@[simp] lemma set.canonical_model.w (axms : set formula) : axms.canonical_model.w = {Δ | Δ.complete_consistent axms} :=\nby refl\n\n@[simp] lemma set.canonical_model.world (axms : set formula) : axms.canonical_model.world = set formula :=\nby refl\n\n@[simp] lemma set.canonical_model.v {axms : set formula} : axms.canonical_model.v = λp : symbol, {Δ : set formula | formula.symbol p ∈ Δ} :=\nby refl\n\n@[simp] lemma set.canonical_model.r {axms : set formula} : axms.canonical_model.r = λΔ Δ' : set formula, (□⁻¹Δ) ⊆ Δ' :=\nby refl\n\n/-- The Truth Lemma: a world `Δ` in the canonical model of a system makes a formula true\n    iff the formula is contained in `Δ`. -/\ntheorem truth_lemma {axms : set formula} {Δ : set formula} {hΔ : Δ ∈ axms.canonical_model.w} :\n  ∀a, (⟨axms.canonical_model, Δ⟩ ⊩ a) ↔ a ∈ Δ :=\nbegin\n  intros a,\n  simp * at *,\n  induction a generalizing Δ,\n  { simp,\n    exact set.complete_consistent.not_mem_bot hΔ, },\n  { simp,\n    exact set.complete_consistent.mem_top hΔ, },\n  { simp, exact iff.rfl, },\n  { simp * at *,\n    apply set.complete_consistent.not_mem_iff hΔ, },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_and hΔ), },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_or hΔ), },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_imp hΔ), },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_iff hΔ), },\n  { apply iff.intro,\n    { intro hba,\n      simp at hba,\n      apply (set.complete_consistent.mem_box hΔ).mpr,\n      intros Δ' hΔ'cc hΔ',\n      rw ←a_ih hΔ'cc,\n      exact hba Δ' hΔ'cc hΔ', },\n    { intro hba,\n      intros Δ' hΔ' hrΔ',\n      rw a_ih hΔ',\n      apply hrΔ',\n      exact hba, }, },\n  { apply iff.intro,\n    { intro hda,\n      simp at hda,\n      apply (set.complete_consistent.mem_diamond hΔ).mpr,\n      cases hda with Δ' hΔ',\n      cases hΔ' with hΔ'cc hΔ',\n      cases hΔ' with hΔ' hΔ'a,\n      apply exists.intro Δ',\n      split,\n      exact hΔ'cc,\n      split,\n      { intros x hx,\n        rw set.complete_consistent.debox_subset_iff hΔ hΔ'cc at hΔ',\n        apply hΔ',\n        exact hx, },\n      { rw ←a_ih hΔ'cc,\n        exact hΔ'a, }, },\n    { contrapose,\n      intro hnda,\n      rw set.complete_consistent.not_mem_iff hΔ,\n      have hbna : ⟨axms.canonical_model, Δ⟩ ⊩ □¬a_a := begin\n        intros Δ' hΔ' hΔ'r,\n        by_contradiction,\n        apply hnda,\n        apply exists.intro Δ',\n        apply exists.intro hΔ',\n        split,\n        exact hΔ'r,\n        simp at h,\n        exact h,\n      end,\n      apply set.complete_consistent.deductive_closure hΔ,\n      sorry }, },\nend\n\n/-- Determination: the canonical model for `Σ` satisfies a formula iff the formula is `Σ`-derivable. -/\ntheorem determination (axms : set formula) : ∀a, (axms.canonical_model ⊩ a) ↔ (axms ⊢ a) :=\nbegin\n  intro a,\n  apply iff.intro,\n  { intro ha,\n    rw [←derivable.from.no_premises, derivable_iff_mem_cc],\n    intros s _ hs,\n    rw ←truth_lemma,\n    apply ha,\n    assumption', },\n  { intros h w hw,\n    rw truth_lemma,\n    apply set.complete_consistent.deductive_closure,\n    { simp at hw,\n      exact hw, },\n    { apply derivable.monotonicity ∅,\n      { tauto, },\n      { rw derivable.from.no_premises,\n        assumption, }, },\n    assumption, },\nend\n\n/-- A system `Σ` is complete for a set `𝒞` of models iff for any formula `a`, `𝒞 ⊨ a → Σ ⊢ a`. -/\nclass complete (axms : set formula) (𝒞 : set model) :=\n(complete : ∀a, (𝒞 ⊨ a) → (axms ⊢ a))\n\n/-- The normal modal logic `K` is complete with respect to the set of all models. -/\ninstance logic.k.complete : complete logic.k set.univ :=\n{ complete :=\n  begin\n    intro a,\n    contrapose,\n    rw ←determination,\n    intro h,\n    tautology,\n  end }", "meta": {"author": "max-heller", "repo": "cs1951x-final-project", "sha": "5c71e2c87289e208ed8513c10a0d480c79a07894", "save_path": "github-repos/lean/max-heller-cs1951x-final-project", "path": "github-repos/lean/max-heller-cs1951x-final-project/cs1951x-final-project-5c71e2c87289e208ed8513c10a0d480c79a07894/src/completeness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342972, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.48077101132824995}}
{"text": "import tactic\nimport ssyt\n\n/-\n\nDefining \"row_bump_step\": one step of row insertion\n\nGiven an ssyt T and natural numbers i, k, we \"bump\" k into row i\nwhile preserving semistandardness. In particular k goes after any existing k's\nand either replaces the leftmost larger entry, or if there are no entries > k, it is\nadded at the end of the row.\n\nAn assumption is necessary (to preserve column strictness) for this to be legal.\n  [ssyt.rbs_cert]\n  [ssyt.rbs_cert.legal_of_cert]\n\nThe bump position is defined using nat.find.\n  [ssyt.rbc]\n  \nThe bump itself is either ssyt.legal.replace or ssyt.legal.add.\n  [ssyt.rbs]\n  [ssyt.rbs_end]\n\nTwo key lemmas are:\n  1. The removed entry from row i is itself legal for bumping into row i+1.\n    [ssyt.rbs_cert.next_cert]\n  2. If so, the (i+1)st row bump column is ≤ the ith row bump column.\n    [ssyt.rbs_cert.next_rbc_le]\n  3. If we insert k, followed by k' ≥ k, in the same row, the k' bump column is \n    *strictly* to the right (larger) than the k column, and the bumped-out\n    entry is weakly larger than the first bumped-out entry.\n    [ssyt.rbs_cert.rbc_lt_rbc]\n    [ssyt.rbs_cert.rbc_out_le_rbc_out]\nLemma 2 is proven in more generality. Lemmas 1-2 are used to define\nrow insertion by successive row bump steps.\nLemma 3 is used to prove that the recording tableau is semistandard,\nwhich is currently a hard proof (see [row_bump.lean/ssyt.rbs_cert.rbwf_pieri]).\n\nVarious independence lemmas are shown for later use:\n * the insertion only affects row i\n    [ssyt.rbs_entry_eq_of_ne_row]\n    [ssyt.rbs_cert.rbs_end_shape_eq_of_ne_row]\n    [ssyt.rbs_cert.rbs_end_entry_eq_of_ne_row]\n * the insertion column only depends on row i\n    [ssyt.rbc_eq_of_eq_row]\n * the extra assumption for column-strictness only depends on rows ≤ i\n    [ssyt.rbs_cert.copy]\n    [ssyt.rbs_cert.copy']\n * commutativity of two rbs steps in different rows: \n    [ssyt.rbs_cert.rbs_comm]\n   Note: this is _not_ currently used anywhere, but it might be possible to\n    use it to golf [row_bump.lean/ssyt.rbs_cert.rbwf_pieri].\n\nFinally, auxiliary facts are shown about the size and weight of the tableau.\n  [ssyt.rbs_cert.rbs_wt]\n  [ssyt.rbs_cert.rbs_end_size]\n  [ssyt.rbs_cert.rbs_end_wt]\n-/\n\nsection row_bump_column\n\nlemma ssyt.rbc_aux {μ : young_diagram} (T : ssyt μ) (i val : ℕ) :\n  ∃ j, (i, j) ∈ μ → val < T i j :=\nby { obtain ⟨j, hj⟩ := μ.row_len_aux i, use j }\n\ndef ssyt.rbc {μ : young_diagram} (T : ssyt μ) (i val : ℕ) : ℕ :=\n  nat.find $ T.rbc_aux i val\n\nlemma ssyt.lt_rbc_iff {μ : young_diagram} (T : ssyt μ) {i j val: ℕ} :\n  j < T.rbc i val ↔ (i, j) ∈ μ ∧ T i j ≤ val :=\nbegin\n  rw [ssyt.rbc, nat.lt_find_iff], push_neg,\n  exact ⟨λ h, h _ (le_refl _),\n         λ h _ hm, ⟨μ.nw_of (le_refl _) hm h.1, (T.row_weak' hm h.1).trans h.2⟩⟩\nend\n\nlemma ssyt.rbc_le_iff {μ : young_diagram} (T : ssyt μ) {i j val: ℕ} :\n  T.rbc i val ≤ j ↔ (i, j) ∈ μ → val < T i j :=\nbegin\n  rw ← not_iff_not, push_neg, apply ssyt.lt_rbc_iff\nend\n\nlemma ssyt.rbc_not_cell_or_val_lt {μ : young_diagram} (T : ssyt μ) (i val: ℕ) :\n  (i, T.rbc i val) ∈ μ → val < T i (T.rbc i val) :=\nnat.find_spec (T.rbc_aux i val)\n\nlemma ssyt.rbc_eq_iff {μ : young_diagram} (T : ssyt μ) {i j val: ℕ} :\n  T.rbc i val = j ↔\n  ((i, j) ∈ μ → val < T i j) ∧ (∀ j' < j, (i, j') ∈ μ ∧ T i j' ≤ val) :=\nbegin\n  convert nat.find_eq_iff (T.rbc_aux i val), push_neg, refl,\nend\n\nlemma ssyt.rbc_eq_of_eq_row \n  {μ ν : young_diagram} (T : ssyt μ) (T' : ssyt ν) {i val : ℕ}\n  (eq_cell : ∀ {j}, (i, j) ∈ μ ↔ (i, j) ∈ ν)\n  (eq_row : ∀ {j}, T i j = T' i j) :\n  T.rbc i val = T'.rbc i val :=\nbegin\n  rw T.rbc_eq_iff,\n  -- change first statement\n  rw [eq_cell, eq_row],\n  -- change second statement\n  simp_rw [eq_cell, eq_row],\n  rw ← T'.rbc_eq_iff,\nend\n\n-- section old_rbc\n\n-- lemma ssyt.rbc_aux {μ : young_diagram} (T : ssyt μ) (i val : ℕ) :\n--   ∃ j, (i, j) ∉ μ ∨ val < T i j :=\n-- exists_or_distrib.mpr $ or.inl $ μ.row_len_aux i\n\n-- def ssyt.rbc {μ : young_diagram} (T : ssyt μ) (i val : ℕ) : ℕ :=\n--   nat.find $ T.rbc_aux i val\n\n-- lemma ssyt.lt_rbc_iff {μ : young_diagram} (T : ssyt μ) {i j val: ℕ} :\n--   j < T.rbc i val ↔ (i, j) ∈ μ ∧ T i j ≤ val :=\n-- begin\n--   rw [ssyt.rbc, nat.lt_find_iff], push_neg,\n--   exact ⟨λ h, h _ (le_refl _),\n--          λ h _ hm, ⟨μ.nw_of (le_refl _) hm h.1, (T.row_weak' hm h.1).trans h.2⟩⟩\n-- end\n\n-- lemma ssyt.rbc_le_iff {μ : young_diagram} (T : ssyt μ) {i j val: ℕ} :\n--   T.rbc i val ≤ j ↔ (i, j) ∉ μ ∨ val < T i j :=\n-- begin\n--   rw ← not_iff_not, push_neg, apply ssyt.lt_rbc_iff\n-- end\n\n-- lemma ssyt.rbc_not_cell_or_val_lt {μ : young_diagram} (T : ssyt μ) (i val: ℕ) :\n--   (i, T.rbc i val) ∉ μ ∨ val < T i (T.rbc i val) :=\n-- nat.find_spec (T.rbc_aux i val)\n\n-- lemma ssyt.rbc_eq_iff {μ : young_diagram} (T : ssyt μ) {i j val: ℕ} :\n--   T.rbc i val = j ↔\n--   ((i, j) ∉ μ ∨ val < T i j) ∧ (∀ j' < j, (i, j') ∈ μ ∧ T i j' ≤ val) :=\n-- begin\n--   convert nat.find_eq_iff (T.rbc_aux i val), push_neg, refl,\n-- end\n\n-- lemma ssyt.rbc_eq_of_eq_row \n--   {μ ν : young_diagram} (T : ssyt μ) (T' : ssyt ν) {i val : ℕ}\n--   (eq_cell : ∀ {j}, (i, j) ∈ μ ↔ (i, j) ∈ ν)\n--   (eq_row : ∀ {j}, T i j = T' i j) :\n--   T.rbc i val = T'.rbc i val :=\n-- begin\n--   rw T.rbc_eq_iff,\n--   -- change first statement\n--   rw [eq_cell, eq_row],\n--   -- change second statement\n--   simp_rw [eq_cell, eq_row],\n--   rw ← T'.rbc_eq_iff,\n-- end\n\n-- end old_rbc\n\nend row_bump_column\n\nsection row_bump_step\n\nsection rbs_cert\n\nstructure ssyt.rbs_cert {μ : young_diagram} (T : ssyt μ) :=\n  (i val : ℕ)\n  (cell_up : ∀ {i'} (hi' : i' < i), (i', T.rbc i val) ∈ μ)\n  (up : ∀ {i'} (hi' : i' < i), T i' (T.rbc i val) < val)\n\ndef ssyt.rbs_start_cert {μ : young_diagram} (T : ssyt μ) (val : ℕ) : T.rbs_cert :=\n{ i := 0,\n  val := val,\n  cell_up := λ _ h, false.rec _ $ nat.not_lt_zero _ h,\n  up := λ _ h, false.rec _ $ nat.not_lt_zero _ h,\n}\n\n@[reducible]\ndef ssyt.rbs_cert.j {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert) : ℕ :=\n  T.rbc h.i h.val\n\n@[reducible]\ndef ssyt.rbs_cert.out {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert) : ℕ :=\n  T h.i h.j\n\nlemma ssyt.rbs_cert.val_lt_out\n  {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (cell : (h.i, h.j) ∈ μ) : h.val < h.out :=\nT.rbc_not_cell_or_val_lt _ _ cell\n\n@[simps]\ndef ssyt.rbs_cert.legal_of_cert {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert) : \n  T.legal :=\n{ i := h.i,\n  j := h.j,\n  val := h.val,\n  cell_up := h.cell_up,\n  cell_left := λ j' hj', (T.lt_rbc_iff.mp hj').1,\n  left := λ j' hj', (T.lt_rbc_iff.mp hj').2,\n  right := λ j' hj' hcell',\n    le_of_lt $ T.rbc_le_iff.mp (le_of_lt hj') hcell',\n  up := h.up,\n  down := λ i' hi' hcell', begin\n    apply (h.val_lt_out _).trans,\n    exact T.col_strict hi' hcell',\n    exact μ.nw_of (le_of_lt hi') (by refl) hcell',\n  end,\n}\n\n@[simps]\ndef ssyt.rbs_cert.copy {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  {ν : young_diagram} (T' : ssyt ν)\n  (eq_cell : ∀ i j (hi : i ≤ h.i), (i, j) ∈ μ ↔ (i, j) ∈ ν)\n  (eq_le_row : ∀ i j (hi : i ≤ h.i), T i j = T' i j) : T'.rbs_cert :=\n{ i := h.i,\n  val := h.val,\n  cell_up := λ i' hi', begin\n    rw [← eq_cell _ _ (le_of_lt hi'),\n        ← T.rbc_eq_of_eq_row T' \n          (λ j, eq_cell _ _ (le_refl _)) (λ j, eq_le_row _ _ (le_refl _))],\n    exact h.cell_up hi',\n  end,\n  up := λ i' hi', begin\n    rw [← eq_le_row _ _ (le_of_lt hi'),\n        ← T.rbc_eq_of_eq_row T' \n          (λ j, eq_cell _ _ (le_refl _)) (λ j, eq_le_row _ _ (le_refl _))],\n    exact h.up hi',\n  end,\n}\n\nlemma ssyt.rbs_cert.copy_j {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  {ν : young_diagram} (T' : ssyt ν)\n  (eq_cell : ∀ i j (hi : i ≤ h.i), (i, j) ∈ μ ↔ (i, j) ∈ ν)\n  (eq_le_row : ∀ i j (hi : i ≤ h.i), T i j = T' i j) :\n  (h.copy T' eq_cell eq_le_row).j = h.j :=\nbegin\n  apply ssyt.rbc_eq_of_eq_row,\n  intro j, rw eq_cell, refl,\n  intro j, rw eq_le_row, refl\nend\n\nlemma ssyt.rbs_cert.copy_out {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  {ν : young_diagram} (T' : ssyt ν)\n  (eq_cell : ∀ i j (hi : i ≤ h.i), (i, j) ∈ μ ↔ (i, j) ∈ ν)\n  (eq_le_row : ∀ i j (hi : i ≤ h.i), T i j = T' i j) :\n  (h.copy T' eq_cell eq_le_row).out = h.out :=\nbegin\n  rw [ssyt.rbs_cert.out, ssyt.rbs_cert.out],\n  rw ssyt.rbs_cert.copy_j,\n  rw eq_le_row; refl\nend\n\n@[simps]\ndef ssyt.rbs_cert.copy' {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  {ν : young_diagram} (T' : ssyt ν)\n  (subset_cell_lt_row : ∀ i j (hi : i < h.i), (i, j) ∈ μ → (i, j) ∈ ν)\n  (eq_cell_row : ∀ j, (h.i, j) ∈ μ ↔ (h.i, j) ∈ ν)\n  (le_lt_row : ∀ i j (hi : i < h.i), T' i j ≤ T i j)\n  (eq_eq_row : ∀ j, T h.i j = T' h.i j) : T'.rbs_cert :=\n{ i := h.i,\n  val := h.val,\n  cell_up := λ i' hi', begin\n    apply subset_cell_lt_row _ _ hi',\n    rw [← T.rbc_eq_of_eq_row T' eq_cell_row eq_eq_row],\n    exact h.cell_up hi',\n  end,\n  up := λ i' hi', begin\n    apply lt_of_le_of_lt (le_lt_row _ _ hi'),\n    rw [← T.rbc_eq_of_eq_row T' eq_cell_row eq_eq_row],\n    exact h.up hi',\n  end,\n}\n\nlemma ssyt.rbs_cert.copy'_j {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  {ν : young_diagram} (T' : ssyt ν)\n  (subset_cell_lt_row : ∀ i j (hi : i < h.i), (i, j) ∈ μ → (i, j) ∈ ν)\n  (eq_cell_row : ∀ j, (h.i, j) ∈ μ ↔ (h.i, j) ∈ ν)\n  (le_lt_row : ∀ i j (hi : i < h.i), T' i j ≤ T i j)\n  (eq_eq_row : ∀ j, T h.i j = T' h.i j) :\n(h.copy' T' subset_cell_lt_row eq_cell_row le_lt_row eq_eq_row).j = h.j :=\nbegin\n  symmetry, apply ssyt.rbc_eq_of_eq_row,\n  intro j, rw eq_cell_row,\n  intro j, rw eq_eq_row,\nend\n\nlemma ssyt.rbs_cert.copy'_out {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  {ν : young_diagram} (T' : ssyt ν)\n  (subset_cell_lt_row : ∀ i j (hi : i < h.i), (i, j) ∈ μ → (i, j) ∈ ν)\n  (eq_cell_row : ∀ j, (h.i, j) ∈ μ ↔ (h.i, j) ∈ ν)\n  (le_lt_row : ∀ i j (hi : i < h.i), T' i j ≤ T i j)\n  (eq_eq_row : ∀ j, T h.i j = T' h.i j) :\n(h.copy' T' subset_cell_lt_row eq_cell_row le_lt_row eq_eq_row).out = h.out :=\nbegin\n  rw [ssyt.rbs_cert.out, ssyt.rbs_cert.out],\n  rw ssyt.rbs_cert.copy'_j,\n  rw eq_eq_row; refl\nend\n\nend rbs_cert\n\nsection rbs\n\ndef ssyt.rbs_cert.rbs {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (cell : (h.i, h.j) ∈ μ) : ssyt μ := h.legal_of_cert.replace cell\n\ndef ssyt.rbs_cert.rbs_end {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) ∉ μ) := h.legal_of_cert.add not_cell\n\n@[reducible]\ndef ssyt.rbs_cert.rbs_end_corner {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) ∉ μ) : μ.outer_corner := (h.legal_of_cert.to_outer not_cell)\n@[reducible]\ndef ssyt.rbs_cert.rbs_end_shape {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) ∉ μ) : young_diagram := (h.rbs_end_corner not_cell).add\n\nlemma ssyt.rbs_cert.rbs_end_shape_eq_of_ne_row {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (not_cell : (h.i, h.j) ∉ μ) {i j : ℕ} (h_ne : i ≠ h.i) :\n(i, j) ∈ h.rbs_end_shape not_cell ↔ (i, j) ∈ μ := \nbegin\n  rw young_diagram.outer_corner.mem_add,\n  apply or_iff_right,\n  rw prod.mk.inj_iff, exact λ h_eq, h_ne h_eq.1,\nend\n\nlemma ssyt.rbs_cert.rbs_entry {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (cell : (h.i, h.j) ∈ μ) {i j : ℕ} :\nh.rbs cell i j = ite ((i, j) = (h.i, h.j)) h.val (T i j) := rfl\n\nlemma ssyt.rbs_cert.rbs_end_entry {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) ∉ μ) {i j : ℕ} :\nh.rbs_end not_cell i j = ite ((i, j) = (h.i, h.j)) h.val (T i j) := rfl\n\nlemma ssyt.rbs_cert.rbs_entry_eq_of_ne_row {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) {i j : ℕ} (h_ne : i ≠ h.i) :\nh.rbs cell i j = T i j := \nbegin\n  rw [h.rbs_entry, if_neg], rintro ⟨⟩, exact h_ne rfl\nend\n\nlemma ssyt.rbs_cert.rbs_end_entry_eq_of_ne_row {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (not_cell : (h.i, h.j) ∉ μ) {i j : ℕ} (h_ne : i ≠ h.i) :\nh.rbs_end not_cell i j = T i j := \nbegin\n  rw [h.rbs_end_entry, if_neg], rintro ⟨rfl, _⟩, exact h_ne rfl\nend\n\nlemma ssyt.rbs_cert.rbs_entry_le {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) {i j : ℕ} :\nh.rbs cell i j ≤ T i j := \nbegin\n  rw h.rbs_entry, split_ifs,\n  cases h_1,\n  exact le_of_lt (h.val_lt_out cell),\n  refl\nend\n\nlemma ssyt.rbs_cert.next_rbc_le {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) :\n (h.rbs cell).rbc h.i.succ h.out ≤ h.j :=\nbegin\n  rw ssyt.rbc_le_iff, intro cell',\n  rw [h.rbs_entry_eq_of_ne_row _ (nat.succ_ne_self _)],\n  apply T.col_strict (lt_add_one _) cell',\nend\n\nlemma ssyt.rbs_cert.next_cert_cell_up {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) :\nlet j' := (h.rbs cell).rbc h.i.succ h.out in\n∀ i' (hi' : i' < h.i.succ), (i', j') ∈ μ :=\nbegin\n  intros j' i' hi',\n  rw nat.lt_succ_iff at hi',\n  apply μ.nw_of hi' (h.next_rbc_le _) cell,\nend\n\nlemma ssyt.rbs_cert.next_cert_up {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) :\nlet j' := (h.rbs cell).rbc h.i.succ h.out in\n∀ i' (hi' : i' < h.i.succ), (h.rbs cell) i' j' < h.out :=\nbegin\n  intros j' i' hi',\n  rw nat.lt_succ_iff at hi',\n  rw h.rbs_entry,\n  split_ifs with h1,\n  { exact h.val_lt_out cell },\n    cases lt_or_eq_of_le hi',\n    { calc T i' j' < T h.i j'  : T.col_strict ‹i' < h.i› _\n      ...          ≤ T h.i h.j : T.row_weak' (h.next_rbc_le cell) cell,\n      exact μ.nw_of (le_refl _) (h.next_rbc_le cell) cell },\n    { subst i', rw [prod.mk.inj_iff, eq_self_iff_true, true_and] at h1,\n      calc T h.i j' ≤ h.val : (T.lt_rbc_iff.mp _).2\n      ...           < h.out : h.val_lt_out cell,\n      exact lt_of_le_of_ne (h.next_rbc_le cell) ‹j' ≠ h.j› }\nend\n\n@[simps]\ndef ssyt.rbs_cert.next_cert {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) : (h.rbs cell).rbs_cert :=\n{ i := h.i.succ,\n  val := h.out,\n  cell_up := h.next_cert_cell_up cell,\n  up := h.next_cert_up cell,\n}\n\n-- if we bump in an equal or larger value into the same row,\n-- the resulting column is strictly further to the right\nlemma ssyt.rbs_cert.rbc_lt_rbc {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ)\n  {val' : ℕ} (hval : h.val ≤ val') :\nh.j < (h.rbs cell).rbc h.i val' :=\nbegin\n  rw ssyt.lt_rbc_iff, split, exact cell,\n  rw [h.rbs_entry, if_pos rfl], exact hval,\nend\n\n-- if we bump in an equal or larger value into the same row,\n-- the resulting output entry is weakly larger\nlemma ssyt.rbs_cert.rbc_out_le_rbc_out {μ : young_diagram} {T : ssyt μ} \n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ)\n  {val' : ℕ} (hval : h.val ≤ val') \n  (cell' : (h.i, (h.rbs cell).rbc h.i val') ∈ μ) :\nh.out ≤ (h.rbs cell) h.i ((h.rbs cell).rbc h.i val') :=\nbegin\n  rw [ssyt.rbs_cert.out, h.rbs_entry, if_neg],\n  exact T.row_weak (h.rbc_lt_rbc cell hval) cell',\n  rw [prod.mk.inj_iff, eq_self_iff_true, true_and],\n  exact ne_of_gt (h.rbc_lt_rbc cell hval),\nend\n\nend rbs\n\nsection size_wt\n\nlemma ssyt.rbs_cert.rbs_end_size {μ : young_diagram} {T : ssyt μ} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) ∉ μ) : \n  (h.legal_of_cert.to_outer not_cell).add.size = μ.size + 1 :=\nby apply young_diagram.outer_corner.add_size\n\nlemma ssyt.rbs_cert.rbs_wt {μ : young_diagram} (T : ssyt μ) (val : ℕ)\n  (h : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) :\n  (h.rbs cell).wt val + ite (val = T h.i h.j) 1 0 =\n  T.wt val + ite (val = h.val) 1 0 :=\nby apply ssyt.wt_replace\n\nlemma ssyt.rbs_cert.rbs_end_wt {μ : young_diagram} (T : ssyt μ) (val : ℕ)\n  (h : T.rbs_cert) (not_cell : (h.i, h.j) ∉ μ) :\n  (h.rbs_end not_cell).wt val = T.wt val + ite (val = h.val) 1 0 :=\nby apply ssyt.wt_add\n\nend size_wt\n\nend row_bump_step\n\nsection commutativity\n\n/-\nCommutativity:\n\nT  →h1  T1\n↓h      ↓h'\nT' →h1' Tf\n\ngives the same result, assuming the bumps are in different rows.\n-/\nlemma ssyt.rbs_cert.rbs_comm {μ : young_diagram}\n  {T : ssyt μ} (h h1 : T.rbs_cert) (cell : (h.i, h.j) ∈ μ) (cell1 : (h1.i, h1.j) ∈ μ)\n  (h_h1_i : h1.i ≠ h.i)\n  (h' : (h1.rbs cell1).rbs_cert) (hi : h'.i = h.i) (hval : h'.val = h.val)\n  (h1' : (h.rbs cell).rbs_cert) (h1i : h1'.i = h1.i) (h1val : h1'.val = h1.val)\n  (cell' : (h'.i, h'.j) ∈ μ := by {\n    rwa [hi, (_ : h'.j = h.j)],\n    rw [ssyt.rbs_cert.j, hi, hval, ssyt.rbc_eq_of_eq_row],\n    exact λ _, iff.rfl,\n    intro j, rw h1.rbs_entry_eq_of_ne_row, exact h_h1_i.symm }) \n  (cell1' : (h1'.i, h1'.j) ∈ μ := by {\n    rwa [h1i, (_ : h1'.j = h1.j)],\n    rw [ssyt.rbs_cert.j, h1i, h1val, ssyt.rbc_eq_of_eq_row],\n    exact λ _, iff.rfl,\n    intro j, rw h.rbs_entry_eq_of_ne_row, exact h_h1_i })\n  (i j : ℕ) : h1'.rbs cell1' i j = h'.rbs cell' i j :=\nbegin\n  have hj : h'.j = h.j := by {\n    rw [ssyt.rbs_cert.j, hi, hval, ssyt.rbc_eq_of_eq_row],\n    exact λ _, iff.rfl,\n    intro j, rw h1.rbs_entry_eq_of_ne_row, exact h_h1_i.symm },\n  have h1j : h1'.j = h1.j := by {\n    rw [ssyt.rbs_cert.j, h1i, h1val, ssyt.rbc_eq_of_eq_row],\n    exact λ _, iff.rfl,\n    intro j, rw h.rbs_entry_eq_of_ne_row, exact h_h1_i },\n  cases ne_or_eq i h.i,\n    rw h'.rbs_entry_eq_of_ne_row,\n    rw [h1'.rbs_entry, h1i, h1val, h1j, h.rbs_entry_eq_of_ne_row], refl,\n    exact h_1, rwa hi,\n  cases h_1,\n    rw h1'.rbs_entry_eq_of_ne_row,\n    rw [h'.rbs_entry, hi, hval, hj, h1.rbs_entry_eq_of_ne_row], refl,\n    exact h_h1_i.symm, rw h1i, exact h_h1_i.symm,\nend\n\nend commutativity\n\nsection examples\n\n-- #eval (μ5331.lowest_ssyt.rbs_start_cert 0).rbs sorry\n-- #eval (μ5331.lowest_ssyt.rbs_start_cert 2).rbs sorry\n-- #eval (μ5331.lowest_ssyt.rbs_start_cert 4).rbs_end sorry\n\nend examples", "meta": {"author": "jakelev", "repo": "lean-rsk", "sha": "dbd97f8fe9fc2ba13d080d37e298ae87d03ff541", "save_path": "github-repos/lean/jakelev-lean-rsk", "path": "github-repos/lean/jakelev-lean-rsk/lean-rsk-dbd97f8fe9fc2ba13d080d37e298ae87d03ff541/src/row_insertion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4807710059794102}}
{"text": "/-\nCopyright (c) 2019 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Floris van Doorn\n\n! This file was ported from Lean 3 source module tactic.lift\n! leanprover-community/mathlib commit 801c013fed96f0d3d9c15e23fe3ddad4481960a8\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.Rcases\n\n/-!\n# lift tactic\n\nThis file defines the `lift` tactic, allowing the user to lift elements from one type to another\nunder a specified condition.\n\n## Tags\n\nlift, tactic\n-/\n\n\n#print CanLift /-\n/-- A class specifying that you can lift elements from `α` to `β` assuming `cond` is true.\n  Used by the tactic `lift`. -/\nclass CanLift (α β : Sort _) (coe : outParam <| β → α) (cond : outParam <| α → Prop) where\n  prf : ∀ x : α, cond x → ∃ y : β, coe y = x\n#align can_lift CanLift\n-/\n\ninstance : CanLift ℤ ℕ coe ((· ≤ ·) 0) :=\n  ⟨fun n hn => ⟨n.natAbs, Int.natAbs_of_nonneg hn⟩⟩\n\n#print Pi.canLift /-\n/-- Enable automatic handling of pi types in `can_lift`. -/\ninstance Pi.canLift (ι : Sort _) (α β : ι → Sort _) (coe : ∀ i, β i → α i) (P : ∀ i, α i → Prop)\n    [∀ i : ι, CanLift (α i) (β i) (coe i) (P i)] :\n    CanLift (∀ i : ι, α i) (∀ i : ι, β i) (fun f i => coe i (f i)) fun f => ∀ i, P i (f i)\n    where prf f hf :=\n    ⟨fun i => Classical.choose (CanLift.prf (f i) (hf i)),\n      funext fun i => Classical.choose_spec (CanLift.prf (f i) (hf i))⟩\n#align pi.can_lift Pi.canLift\n-/\n\n/- warning: subtype.exists_pi_extension -> Subtype.exists_pi_extension is a dubious translation:\nlean 3 declaration is\n  forall {ι : Sort.{u1}} {α : ι -> Sort.{u2}} [ne : forall (i : ι), Nonempty.{u2} (α i)] {p : ι -> Prop} (f : forall (i : Subtype.{u1} ι p), α ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} ι p) ι (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} ι p) ι (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} ι p) ι (coeBase.{max 1 u1, u1} (Subtype.{u1} ι p) ι (coeSubtype.{u1} ι (fun (x : ι) => p x))))) i)), Exists.{imax u1 u2} (forall (i : ι), α i) (fun (g : forall (i : ι), α i) => Eq.{imax (max 1 u1) u2} (forall (i : Subtype.{u1} ι p), α ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} ι p) ι (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} ι p) ι (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} ι p) ι (coeBase.{max 1 u1, u1} (Subtype.{u1} ι p) ι (coeSubtype.{u1} ι (fun (x : ι) => p x))))) i)) (fun (i : Subtype.{u1} ι p) => g ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} ι p) ι (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} ι p) ι (CoeTCₓ.coe.{max 1 u1, u1} (Subtype.{u1} ι p) ι (coeBase.{max 1 u1, u1} (Subtype.{u1} ι p) ι (coeSubtype.{u1} ι (fun (x : ι) => p x))))) i)) f)\nbut is expected to have type\n  forall {ι : Sort.{u2}} {α : ι -> Sort.{u1}} [ne : forall (i : ι), Nonempty.{u1} (α i)] {p : ι -> Prop} (f : forall (i : Subtype.{u2} ι p), α (Subtype.val.{u2} ι p i)), Exists.{imax u2 u1} (forall (i : ι), α i) (fun (g : forall (i : ι), α i) => Eq.{imax (max 1 u2) u1} (forall (i : Subtype.{u2} ι p), α (Subtype.val.{u2} ι p i)) (fun (i : Subtype.{u2} ι p) => g (Subtype.val.{u2} ι p i)) f)\nCase conversion may be inaccurate. Consider using '#align subtype.exists_pi_extension Subtype.exists_pi_extensionₓ'. -/\ntheorem Subtype.exists_pi_extension {ι : Sort _} {α : ι → Sort _} [ne : ∀ i, Nonempty (α i)]\n    {p : ι → Prop} (f : ∀ i : Subtype p, α i) :\n    ∃ g : ∀ i : ι, α i, (fun i : Subtype p => g i) = f := by\n  classical\n    refine' ⟨fun i => if hi : p i then f ⟨i, hi⟩ else Classical.choice (Ne i), funext _⟩\n    rintro ⟨i, hi⟩\n    exact dif_pos hi\n#align subtype.exists_pi_extension Subtype.exists_pi_extension\n\n#print PiSubtype.canLift /-\ninstance PiSubtype.canLift (ι : Sort _) (α : ι → Sort _) [ne : ∀ i, Nonempty (α i)] (p : ι → Prop) :\n    CanLift (∀ i : Subtype p, α i) (∀ i, α i) (fun f i => f i) fun _ => True\n    where prf f _ := Subtype.exists_pi_extension f\n#align pi_subtype.can_lift PiSubtype.canLift\n-/\n\n#print PiSubtype.canLift' /-\ninstance PiSubtype.canLift' (ι : Sort _) (α : Sort _) [ne : Nonempty α] (p : ι → Prop) :\n    CanLift (Subtype p → α) (ι → α) (fun f i => f i) fun _ => True :=\n  PiSubtype.canLift ι (fun _ => α) p\n#align pi_subtype.can_lift' PiSubtype.canLift'\n-/\n\n#print Subtype.canLift /-\ninstance Subtype.canLift {α : Sort _} (p : α → Prop) : CanLift α { x // p x } coe p\n    where prf a ha := ⟨⟨a, ha⟩, rfl⟩\n#align subtype.can_lift Subtype.canLift\n-/\n\nopen Tactic\n\nnamespace Tactic\n\n/-- Construct the proof of `cond x` in the lift tactic.\n*  `e` is the expression being lifted and `h` is the specified proof of `can_lift.cond e`.\n*  `old_tp` and `new_tp` are the arguments to `can_lift` and `inst` is the `can_lift`-instance.\n*  `s` and `to_unfold` contain the information of the simp set used to simplify.\n\nIf the proof was specified, we check whether it has the correct type.\nIf it doesn't have the correct type, we display an error message.\n\nIf the proof was not specified, we create assert it as a local constant.\n(The name of this local constant doesn't matter, since `lift` will remove it from the context.)\n-/\nunsafe def get_lift_prf (h : Option pexpr) (e P : expr) : tactic (expr × Bool) := do\n  let expected_prf_ty := P.app e\n  let expected_prf_ty ← simp_lemmas.mk.dsimplify [] expected_prf_ty { failIfUnchanged := false }\n  match h with\n    | some h => do\n      let e ← decorate_error \"lift tactic failed.\" (i_to_expr ``(($(h) : $(expected_prf_ty))))\n      return (e, tt)\n    | none => do\n      let prf_nm ← get_unused_name\n      let prf ← assert prf_nm expected_prf_ty\n      swap\n      return (prf, ff)\n#align tactic.get_lift_prf tactic.get_lift_prf\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/--\n      Lift the expression `p` to the type `t`, with proof obligation given by `h`.\n        The list `n` is used for the two newly generated names, and to specify whether `h` should\n        remain in the local context. See the doc string of `tactic.interactive.lift` for more information.\n        -/\n    unsafe\n  def\n    lift\n    ( p : pexpr ) ( t : pexpr ) ( h : Option pexpr ) ( n : List Name ) : tactic Unit\n    :=\n      do\n        propositional_goal\n            <|>\n            fail \"lift tactic failed. Tactic is only applicable when the target is a proposition.\"\n          let e ← i_to_expr p\n          let old_tp ← infer_type e\n          let new_tp ← i_to_expr ` `( ( $ ( t ) : Sort _ ) )\n          let coe ← i_to_expr ` `( $ ( new_tp ) → $ ( old_tp ) ) >>= mk_meta_var\n          let P ← i_to_expr ` `( $ ( old_tp ) → Prop ) >>= mk_meta_var\n          let inst_type ← mk_app ` ` CanLift [ old_tp , new_tp , coe , P ]\n          let\n            inst\n              ←\n              mk_instance inst_type\n                <|>\n                (\n                    f!\n                      \"Failed to find a lift from {\n                        ( ← old_tp )\n                        } to {\n                        ( ← new_tp )\n                        }. Provide an instance of\n                          { ← inst_type }\"\n                    )\n                  >>=\n                  fail\n          let inst ← instantiate_mvars inst\n          let coe ← instantiate_mvars coe\n          let P ← instantiate_mvars P\n          let ( prf_cond , b ) ← get_lift_prf h e P\n          let prf_nm := if prf_cond . is_local_constant then some prf_cond . local_pp_name else none\n          let prf_ex0 ← mk_mapp `can_lift.prf [ old_tp , new_tp , coe , P , inst , e ]\n          let prf_ex := prf_ex0 prf_cond\n          let\n            new_nm\n              ←\n              if\n                n ≠ [ ]\n                then\n                return n . headI\n                else\n                if e . is_local_constant then return e . local_pp_name else get_unused_name\n          let\n            eq_nm\n              ←\n              if\n                hn\n                :\n                1 < n . length\n                then\n                return ( n . nthLe 1 hn )\n                else\n                if e . is_local_constant then return `rfl else get_unused_name `h\n          let temp_nm ← get_unused_name\n          let temp_e ← note temp_nm none prf_ex\n          dsimp_hyp temp_e none [ ] { failIfUnchanged := ff }\n          rcases none ( pexpr.of_expr temp_e )\n            <|\n            rcases_patt.tuple ( [ new_nm , eq_nm ] . map rcases_patt.one )\n          when\n            ( ¬ e )\n              (\n                get_local eq_nm\n                  >>=\n                  fun\n                    e\n                      =>\n                      interactive.rw\n                        ⟨ [ ⟨ ⟨ 0 , 0 ⟩ , tt , pexpr.of_expr e ⟩ ] , none ⟩ Interactive.Loc.wildcard\n                )\n          if\n            h_prf_nm\n            :\n            prf_nm ∧ n 2 ≠ prf_nm\n            then\n            get_local ( Option.get h_prf_nm . 1 ) >>= clear\n            else\n            skip\n          if b then skip else swap\n#align tactic.lift tactic.lift\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `parser.optional -/\n/-- Parses an optional token \"using\" followed by a trailing `pexpr`. -/\nunsafe def using_texpr :=\n  parser.optional (tk \"using\" *> texpr)\n#align tactic.using_texpr tactic.using_texpr\n\n/-- Parses a token \"to\" followed by a trailing `pexpr`. -/\nunsafe def to_texpr :=\n  tk \"to\" *> texpr\n#align tactic.to_texpr tactic.to_texpr\n\nnamespace Interactive\n\n/-- Lift an expression to another type.\n* Usage: `'lift' expr 'to' expr ('using' expr)? ('with' id (id id?)?)?`.\n* If `n : ℤ` and `hn : n ≥ 0` then the tactic `lift n to ℕ using hn` creates a new\n  constant of type `ℕ`, also named `n` and replaces all occurrences of the old variable `(n : ℤ)`\n  with `↑n` (where `n` in the new variable). It will remove `n` and `hn` from the context.\n  + So for example the tactic `lift n to ℕ using hn` transforms the goal\n    `n : ℤ, hn : n ≥ 0, h : P n ⊢ n = 3` to `n : ℕ, h : P ↑n ⊢ ↑n = 3`\n    (here `P` is some term of type `ℤ → Prop`).\n* The argument `using hn` is optional, the tactic `lift n to ℕ` does the same, but also creates a\n  new subgoal that `n ≥ 0` (where `n` is the old variable).\n  This subgoal will be placed at the top of the goal list.\n  + So for example the tactic `lift n to ℕ` transforms the goal\n    `n : ℤ, h : P n ⊢ n = 3` to two goals\n    `n : ℤ, h : P n ⊢ n ≥ 0` and `n : ℕ, h : P ↑n ⊢ ↑n = 3`.\n* You can also use `lift n to ℕ using e` where `e` is any expression of type `n ≥ 0`.\n* Use `lift n to ℕ with k` to specify the name of the new variable.\n* Use `lift n to ℕ with k hk` to also specify the name of the equality `↑k = n`. In this case, `n`\n  will remain in the context. You can use `rfl` for the name of `hk` to substitute `n` away\n  (i.e. the default behavior).\n* You can also use `lift e to ℕ with k hk` where `e` is any expression of type `ℤ`.\n  In this case, the `hk` will always stay in the context, but it will be used to rewrite `e` in\n  all hypotheses and the target.\n  + So for example the tactic `lift n + 3 to ℕ using hn with k hk` transforms the goal\n    `n : ℤ, hn : n + 3 ≥ 0, h : P (n + 3) ⊢ n + 3 = 2 * n` to the goal\n    `n : ℤ, k : ℕ, hk : ↑k = n + 3, h : P ↑k ⊢ ↑k = 2 * n`.\n* The tactic `lift n to ℕ using h` will remove `h` from the context. If you want to keep it,\n  specify it again as the third argument to `with`, like this: `lift n to ℕ using h with n rfl h`.\n* More generally, this can lift an expression from `α` to `β` assuming that there is an instance\n  of `can_lift α β`. In this case the proof obligation is specified by `can_lift.cond`.\n* Given an instance `can_lift β γ`, it can also lift `α → β` to `α → γ`; more generally, given\n  `β : Π a : α, Type*`, `γ : Π a : α, Type*`, and `[Π a : α, can_lift (β a) (γ a)]`, it\n  automatically generates an instance `can_lift (Π a, β a) (Π a, γ a)`.\n\n`lift` is in some sense dual to the `zify` tactic. `lift (z : ℤ) to ℕ` will change the type of an\ninteger `z` (in the supertype) to `ℕ` (the subtype), given a proof that `z ≥ 0`;\npropositions concerning `z` will still be over `ℤ`. `zify` changes propositions about `ℕ` (the\nsubtype) to propositions about `ℤ` (the supertype), without changing the type of any variable.\n-/\nunsafe def lift (p : parse texpr) (t : parse to_texpr) (h : parse using_texpr)\n    (n : parse with_ident_list) : tactic Unit :=\n  tactic.lift p t h n\n#align tactic.interactive.lift tactic.interactive.lift\n\nadd_tactic_doc\n  { Name := \"lift\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.lift]\n    tags := [\"coercions\"] }\n\nend Interactive\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/Lift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.4807710048442702}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.lie.basic\nimport ring_theory.noetherian\n\n/-!\n# Lie subalgebras\n\nThis file defines Lie subalgebras of a Lie algebra and provides basic related definitions and\nresults.\n\n## Main definitions\n\n  * `lie_subalgebra`\n  * `lie_subalgebra.incl`\n  * `lie_subalgebra.map`\n  * `lie_hom.range`\n  * `lie_equiv.of_injective`\n  * `lie_equiv.of_eq`\n  * `lie_equiv.of_subalgebra`\n  * `lie_equiv.of_subalgebras`\n\n## Tags\n\nlie algebra, lie subalgebra\n-/\n\nuniverses u v w w₁ w₂\n\nsection lie_subalgebra\n\nvariables (R : Type u) (L : Type v) [comm_ring R] [lie_ring L] [lie_algebra R L]\n\n/-- A Lie subalgebra of a Lie algebra is submodule that is closed under the Lie bracket.\nThis is a sufficient condition for the subset itself to form a Lie algebra. -/\nstructure lie_subalgebra extends submodule R L :=\n(lie_mem' : ∀ {x y}, x ∈ carrier → y ∈ carrier → ⁅x, y⁆ ∈ carrier)\n\nattribute [nolint doc_blame] lie_subalgebra.to_submodule\n\n/-- The zero algebra is a subalgebra of any Lie algebra. -/\ninstance : has_zero (lie_subalgebra R L) :=\n⟨{ lie_mem' := λ x y hx hy, by { rw [((submodule.mem_bot R).1 hx), zero_lie],\n                                exact submodule.zero_mem (0 : submodule R L), },\n   ..(0 : submodule R L) }⟩\n\ninstance : inhabited (lie_subalgebra R L) := ⟨0⟩\ninstance : has_coe (lie_subalgebra R L) (submodule R L) := ⟨lie_subalgebra.to_submodule⟩\n\nnamespace lie_subalgebra\n\ninstance : set_like (lie_subalgebra R L) L :=\n{ coe := λ L', L',\n  coe_injective' := λ L' L'' h, by { rcases L' with ⟨⟨⟩⟩, rcases L'' with ⟨⟨⟩⟩, congr' } }\n\ninstance : add_subgroup_class (lie_subalgebra R L) L :=\n{ add_mem := λ L', L'.add_mem',\n  zero_mem := λ L', L'.zero_mem',\n  neg_mem := λ L' x hx, show -x ∈ (L' : submodule R L), from neg_mem hx }\n\n/-- A Lie subalgebra forms a new Lie ring. -/\ninstance (L' : lie_subalgebra R L) : lie_ring L' :=\n{ bracket      := λ x y, ⟨⁅x.val, y.val⁆, L'.lie_mem' x.property y.property⟩,\n  lie_add      := by { intros, apply set_coe.ext, apply lie_add, },\n  add_lie      := by { intros, apply set_coe.ext, apply add_lie, },\n  lie_self     := by { intros, apply set_coe.ext, apply lie_self, },\n  leibniz_lie  := by { intros, apply set_coe.ext, apply leibniz_lie, } }\n\nsection\n\nvariables {R₁ : Type*} [semiring R₁]\n\n/-- A Lie subalgebra inherits module structures from `L`. -/\ninstance [has_scalar R₁ R] [module R₁ L] [is_scalar_tower R₁ R L]\n  (L' : lie_subalgebra R L) : module R₁ L' :=\nL'.to_submodule.module'\n\ninstance [has_scalar R₁ R] [has_scalar R₁ᵐᵒᵖ R] [module R₁ L] [module R₁ᵐᵒᵖ L]\n  [is_scalar_tower R₁ R L] [is_scalar_tower R₁ᵐᵒᵖ R L] [is_central_scalar R₁ L]\n  (L' : lie_subalgebra R L) : is_central_scalar R₁ L' :=\nL'.to_submodule.is_central_scalar\n\ninstance [has_scalar R₁ R] [module R₁ L] [is_scalar_tower R₁ R L]\n  (L' : lie_subalgebra R L) : is_scalar_tower R₁ R L' :=\nL'.to_submodule.is_scalar_tower\n\nend\n\n/-- A Lie subalgebra forms a new Lie algebra. -/\ninstance (L' : lie_subalgebra R L) : lie_algebra R L' :=\n{ lie_smul := by { intros, apply set_coe.ext, apply lie_smul } }\n\nvariables {R L} (L' : lie_subalgebra R L)\n\n@[simp] protected lemma zero_mem : (0 : L) ∈ L' := zero_mem L'\nprotected lemma add_mem {x y : L} : x ∈ L' → y ∈ L' → (x + y : L) ∈ L' := add_mem\nprotected lemma sub_mem {x y : L} : x ∈ L' → y ∈ L' → (x - y : L) ∈ L' := sub_mem\n\nlemma smul_mem (t : R) {x : L} (h : x ∈ L') : t • x ∈ L' := (L' : submodule R L).smul_mem t h\n\nlemma lie_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (⁅x, y⁆ : L) ∈ L' := L'.lie_mem' hx hy\n\n@[simp] lemma mem_carrier {x : L} : x ∈ L'.carrier ↔ x ∈ (L' : set L) := iff.rfl\n\n@[simp] lemma mem_mk_iff (S : set L) (h₁ h₂ h₃ h₄) {x : L} :\n  x ∈ (⟨⟨S, h₁, h₂, h₃⟩, h₄⟩ : lie_subalgebra R L) ↔ x ∈ S :=\niff.rfl\n\n@[simp] lemma mem_coe_submodule {x : L} : x ∈ (L' : submodule R L) ↔ x ∈ L' := iff.rfl\n\nlemma mem_coe {x : L} : x ∈ (L' : set L) ↔ x ∈ L' := iff.rfl\n\n@[simp, norm_cast] lemma coe_bracket (x y : L') : (↑⁅x, y⁆ : L) = ⁅(↑x : L), ↑y⁆ := rfl\n\nlemma ext_iff (x y : L') : x = y ↔ (x : L) = y := subtype.ext_iff\n\nlemma coe_zero_iff_zero (x : L') : (x : L) = 0 ↔ x = 0 := (ext_iff L' x 0).symm\n\n@[ext] lemma ext (L₁' L₂' : lie_subalgebra R L) (h : ∀ x, x ∈ L₁' ↔ x ∈ L₂') :\n  L₁' = L₂' :=\nset_like.ext h\n\nlemma ext_iff' (L₁' L₂' : lie_subalgebra R L) : L₁' = L₂' ↔ ∀ x, x ∈ L₁' ↔ x ∈ L₂' :=\nset_like.ext_iff\n\n@[simp] lemma mk_coe (S : set L) (h₁ h₂ h₃ h₄) :\n  ((⟨⟨S, h₁, h₂, h₃⟩, h₄⟩ : lie_subalgebra R L) : set L) = S := rfl\n\n@[simp] lemma coe_to_submodule_mk (p : submodule R L) (h) :\n  (({lie_mem' := h, ..p} : lie_subalgebra R L) : submodule R L) = p :=\nby { cases p, refl, }\n\nlemma coe_injective : function.injective (coe : lie_subalgebra R L → set L) :=\nset_like.coe_injective\n\n@[norm_cast] theorem coe_set_eq (L₁' L₂' : lie_subalgebra R L) :\n  (L₁' : set L) = L₂' ↔ L₁' = L₂' := set_like.coe_set_eq\n\nlemma to_submodule_injective :\n  function.injective (coe : lie_subalgebra R L → submodule R L) :=\nλ L₁' L₂' h, by { rw set_like.ext'_iff at h, rw ← coe_set_eq, exact h, }\n\n@[simp] lemma coe_to_submodule_eq_iff (L₁' L₂' : lie_subalgebra R L) :\n  (L₁' : submodule R L) = (L₂' : submodule R L) ↔ L₁' = L₂' :=\nto_submodule_injective.eq_iff\n\n@[norm_cast]\nlemma coe_to_submodule : ((L' : submodule R L) : set L) = L' := rfl\n\nsection lie_module\n\nvariables {M : Type w} [add_comm_group M] [lie_ring_module L M]\nvariables {N : Type w₁} [add_comm_group N] [lie_ring_module L N] [module R N] [lie_module R L N]\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie ring module\n`M` of `L`, we may regard `M` as a Lie ring module of `L'` by restriction. -/\ninstance : lie_ring_module L' M :=\n{ bracket     := λ x m, ⁅(x : L), m⁆,\n  add_lie     := λ x y m, add_lie x y m,\n  lie_add     := λ x y m, lie_add x y m,\n  leibniz_lie := λ x y m, leibniz_lie x y m, }\n\n@[simp] lemma coe_bracket_of_module (x : L') (m : M) : ⁅x, m⁆ = ⁅(x : L), m⁆ := rfl\n\nvariables [module R M] [lie_module R L M]\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie module `M` of\n`L`, we may regard `M` as a Lie module of `L'` by restriction. -/\ninstance : lie_module R L' M :=\n{ smul_lie := λ t x m, by simp only [coe_bracket_of_module, smul_lie, submodule.coe_smul_of_tower],\n  lie_smul := λ t x m, by simp only [coe_bracket_of_module, lie_smul], }\n\n/-- An `L`-equivariant map of Lie modules `M → N` is `L'`-equivariant for any Lie subalgebra\n`L' ⊆ L`. -/\ndef _root_.lie_module_hom.restrict_lie (f : M →ₗ⁅R,L⁆ N) (L' : lie_subalgebra R L) : M →ₗ⁅R,L'⁆ N :=\n{ map_lie' := λ x m, f.map_lie ↑x m,\n  .. (f : M →ₗ[R] N)}\n\n@[simp] lemma _root_.lie_module_hom.coe_restrict_lie (f : M →ₗ⁅R,L⁆ N) :\n  ⇑(f.restrict_lie L') = f :=\nrfl\n\nend lie_module\n\n/-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie algebras. -/\ndef incl : L' →ₗ⁅R⁆ L :=\n{ map_lie' := λ x y, by { simp only [linear_map.to_fun_eq_coe, submodule.subtype_apply], refl, },\n  .. (L' : submodule R L).subtype, }\n\n@[simp] lemma coe_incl : ⇑L'.incl = coe := rfl\n\n/-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie modules. -/\ndef incl' : L' →ₗ⁅R,L'⁆ L :=\n{ map_lie' := λ x y, by simp only [coe_bracket_of_module, linear_map.to_fun_eq_coe,\n    submodule.subtype_apply, coe_bracket],\n  .. (L' : submodule R L).subtype, }\n\n@[simp] lemma coe_incl' : ⇑L'.incl' = coe := rfl\n\nend lie_subalgebra\n\nvariables {R L} {L₂ : Type w} [lie_ring L₂] [lie_algebra R L₂]\nvariables (f : L →ₗ⁅R⁆ L₂)\n\nnamespace lie_hom\n\n/-- The range of a morphism of Lie algebras is a Lie subalgebra. -/\ndef range : lie_subalgebra R L₂ :=\n{ lie_mem' := λ x y,\n    show x ∈ f.to_linear_map.range → y ∈ f.to_linear_map.range → ⁅x, y⁆ ∈ f.to_linear_map.range,\n    by { repeat { rw linear_map.mem_range }, rintros ⟨x', hx⟩ ⟨y', hy⟩, refine ⟨⁅x', y'⁆, _⟩,\n         rw [←hx, ←hy], change f ⁅x', y'⁆ = ⁅f x', f y'⁆, rw map_lie, },\n  ..(f : L →ₗ[R] L₂).range }\n\n@[simp] lemma range_coe : (f.range : set L₂) = set.range f :=\nlinear_map.range_coe ↑f\n\n@[simp] lemma mem_range (x : L₂) : x ∈ f.range ↔ ∃ (y : L), f y = x := linear_map.mem_range\n\nlemma mem_range_self (x : L) : f x ∈ f.range := linear_map.mem_range_self f x\n\n/-- We can restrict a morphism to a (surjective) map to its range. -/\ndef range_restrict : L →ₗ⁅R⁆ f.range :=\n{ map_lie' := λ x y, by { apply subtype.ext, exact f.map_lie x y, },\n  ..(f : L →ₗ[R] L₂).range_restrict, }\n\n@[simp] lemma range_restrict_apply (x : L) : f.range_restrict x = ⟨f x, f.mem_range_self x⟩ := rfl\n\nlemma surjective_range_restrict : function.surjective (f.range_restrict) :=\nbegin\n  rintros ⟨y, hy⟩,\n  erw mem_range at hy, obtain ⟨x, rfl⟩ := hy,\n  use x,\n  simp only [subtype.mk_eq_mk, range_restrict_apply],\nend\n\n/-- A Lie algebra is equivalent to its range under an injective Lie algebra morphism. -/\nnoncomputable def equiv_range_of_injective (h : function.injective f) : L ≃ₗ⁅R⁆ f.range :=\nlie_equiv.of_bijective f.range_restrict (λ x y hxy,\nbegin\n  simp only [subtype.mk_eq_mk, range_restrict_apply] at hxy,\n  exact h hxy,\nend) f.surjective_range_restrict\n\n@[simp] lemma equiv_range_of_injective_apply (h : function.injective f) (x : L) :\n  f.equiv_range_of_injective h x = ⟨f x, mem_range_self f x⟩ :=\nrfl\n\nend lie_hom\n\nlemma submodule.exists_lie_subalgebra_coe_eq_iff (p : submodule R L) :\n  (∃ (K : lie_subalgebra R L), ↑K = p) ↔ ∀ (x y : L), x ∈ p → y ∈ p → ⁅x, y⁆ ∈ p :=\nbegin\n  split,\n  { rintros ⟨K, rfl⟩, exact K.lie_mem', },\n  { intros h, use { lie_mem' := h, ..p }, exact lie_subalgebra.coe_to_submodule_mk p _, },\nend\n\nnamespace lie_subalgebra\n\nvariables (K K' : lie_subalgebra R L) (K₂ : lie_subalgebra R L₂)\n\n@[simp] lemma incl_range : K.incl.range = K :=\nby { rw ← coe_to_submodule_eq_iff, exact (K : submodule R L).range_subtype, }\n\n/-- The image of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the\ncodomain. -/\ndef map : lie_subalgebra R L₂ :=\n{ lie_mem' := λ x y hx hy, by\n  { erw submodule.mem_map at hx, rcases hx with ⟨x', hx', hx⟩, rw ←hx,\n    erw submodule.mem_map at hy, rcases hy with ⟨y', hy', hy⟩, rw ←hy,\n    erw submodule.mem_map,\n    exact ⟨⁅x', y'⁆, K.lie_mem hx' hy', f.map_lie x' y'⟩, },\n..((K : submodule R L).map (f : L →ₗ[R] L₂)) }\n\n@[simp] lemma mem_map (x : L₂) : x ∈ K.map f ↔ ∃ (y : L), y ∈ K ∧ f y = x := submodule.mem_map\n\n-- TODO Rename and state for homs instead of equivs.\n@[simp] lemma mem_map_submodule (e : L ≃ₗ⁅R⁆ L₂) (x : L₂) :\n  x ∈ K.map (e : L →ₗ⁅R⁆ L₂) ↔ x ∈ (K : submodule R L).map (e : L →ₗ[R] L₂) :=\niff.rfl\n\n/-- The preimage of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the\ndomain. -/\ndef comap : lie_subalgebra R L :=\n{ lie_mem' := λ x y hx hy, by\n    { suffices : ⁅f x, f y⁆ ∈ K₂, by { simp [this], }, exact K₂.lie_mem hx hy, },\n  ..((K₂ : submodule R L₂).comap (f : L →ₗ[R] L₂)), }\n\nsection lattice_structure\n\nopen set\n\ninstance : partial_order (lie_subalgebra R L) :=\n{ le := λ N N', ∀ ⦃x⦄, x ∈ N → x ∈ N', -- Overriding `le` like this gives a better defeq.\n  ..partial_order.lift (coe : lie_subalgebra R L → set L) coe_injective }\n\nlemma le_def : K ≤ K' ↔ (K : set L) ⊆ K' := iff.rfl\n\n@[simp, norm_cast] lemma coe_submodule_le_coe_submodule : (K : submodule R L) ≤ K' ↔ K ≤ K' :=\niff.rfl\n\ninstance : has_bot (lie_subalgebra R L) := ⟨0⟩\n\n@[simp] lemma bot_coe : ((⊥ : lie_subalgebra R L) : set L) = {0} := rfl\n\n@[simp] lemma bot_coe_submodule : ((⊥ : lie_subalgebra R L) : submodule R L) = ⊥ := rfl\n\n@[simp] lemma mem_bot (x : L) : x ∈ (⊥ : lie_subalgebra R L) ↔ x = 0 := mem_singleton_iff\n\ninstance : has_top (lie_subalgebra R L) :=\n⟨{ lie_mem' := λ x y hx hy, mem_univ ⁅x, y⁆,\n   ..(⊤ : submodule R L) }⟩\n\n@[simp] lemma top_coe : ((⊤ : lie_subalgebra R L) : set L) = univ := rfl\n\n@[simp] lemma top_coe_submodule : ((⊤ : lie_subalgebra R L) : submodule R L) = ⊤ := rfl\n\n@[simp] lemma mem_top (x : L) : x ∈ (⊤ : lie_subalgebra R L) := mem_univ x\n\nlemma _root_.lie_hom.range_eq_map : f.range = map f ⊤ :=\nby { ext, simp }\n\ninstance : has_inf (lie_subalgebra R L) :=\n⟨λ K K', { lie_mem' := λ x y hx hy, mem_inter (K.lie_mem hx.1 hy.1) (K'.lie_mem hx.2 hy.2),\n            ..(K ⊓ K' : submodule R L) }⟩\n\ninstance : has_Inf (lie_subalgebra R L) :=\n⟨λ S, { lie_mem' := λ x y hx hy, by\n        { simp only [submodule.mem_carrier, mem_Inter, submodule.Inf_coe, mem_set_of_eq,\n            forall_apply_eq_imp_iff₂, exists_imp_distrib] at *,\n          intros K hK, exact K.lie_mem (hx K hK) (hy K hK), },\n        ..Inf {(s : submodule R L) | s ∈ S} }⟩\n\n@[simp] theorem inf_coe : (↑(K ⊓ K') : set L) = K ∩ K' := rfl\n\n@[simp] lemma Inf_coe_to_submodule (S : set (lie_subalgebra R L)) :\n  (↑(Inf S) : submodule R L) = Inf {(s : submodule R L) | s ∈ S} := rfl\n\n@[simp] lemma Inf_coe (S : set (lie_subalgebra R L)) : (↑(Inf S) : set L) = ⋂ s ∈ S, (s : set L) :=\nbegin\n  rw [← coe_to_submodule, Inf_coe_to_submodule, submodule.Inf_coe],\n  ext x,\n  simpa only [mem_Inter, mem_set_of_eq, forall_apply_eq_imp_iff₂, exists_imp_distrib],\nend\n\nlemma Inf_glb (S : set (lie_subalgebra R L)) : is_glb S (Inf S) :=\nbegin\n  have h : ∀ (K K' : lie_subalgebra R L), (K : set L) ≤ K' ↔ K ≤ K', { intros, exact iff.rfl, },\n  apply is_glb.of_image h,\n  simp only [Inf_coe],\n  exact is_glb_binfi\nend\n\n/-- The set of Lie subalgebras of a Lie algebra form a complete lattice.\n\nWe provide explicit values for the fields `bot`, `top`, `inf` to get more convenient definitions\nthan we would otherwise obtain from `complete_lattice_of_Inf`. -/\ninstance : complete_lattice (lie_subalgebra R L) :=\n{ bot          := ⊥,\n  bot_le       := λ N _ h, by { rw mem_bot at h, rw h, exact N.zero_mem', },\n  top          := ⊤,\n  le_top       := λ _ _ _, trivial,\n  inf          := (⊓),\n  le_inf       := λ N₁ N₂ N₃ h₁₂ h₁₃ m hm, ⟨h₁₂ hm, h₁₃ hm⟩,\n  inf_le_left  := λ _ _ _, and.left,\n  inf_le_right := λ _ _ _, and.right,\n  ..complete_lattice_of_Inf _ Inf_glb }\n\ninstance : add_comm_monoid (lie_subalgebra R L) :=\n{ add       := (⊔),\n  add_assoc := λ _ _ _, sup_assoc,\n  zero      := ⊥,\n  zero_add  := λ _, bot_sup_eq,\n  add_zero  := λ _, sup_bot_eq,\n  add_comm  := λ _ _, sup_comm, }\n\ninstance : canonically_ordered_add_monoid (lie_subalgebra R L) :=\n{ add_le_add_left := λ a b, sup_le_sup_left,\n  exists_add_of_le := λ a b h, ⟨b, (sup_eq_right.2 h).symm⟩,\n  le_self_add := λ a b, le_sup_left,\n  ..lie_subalgebra.add_comm_monoid,\n  ..lie_subalgebra.complete_lattice }\n\n@[simp] lemma add_eq_sup : K + K' = K ⊔ K' := rfl\n\n@[norm_cast, simp] lemma inf_coe_to_submodule :\n  (↑(K ⊓ K') : submodule R L) = (K : submodule R L) ⊓ (K' : submodule R L) := rfl\n\n@[simp] lemma mem_inf (x : L) : x ∈ K ⊓ K' ↔ x ∈ K ∧ x ∈ K' :=\nby rw [← mem_coe_submodule, ← mem_coe_submodule, ← mem_coe_submodule, inf_coe_to_submodule,\n  submodule.mem_inf]\n\nlemma eq_bot_iff : K = ⊥ ↔ ∀ (x : L), x ∈ K → x = 0 :=\nby { rw eq_bot_iff, exact iff.rfl, }\n\n-- TODO[gh-6025]: make this an instance once safe to do so\nlemma subsingleton_of_bot : subsingleton (lie_subalgebra R ↥(⊥ : lie_subalgebra R L)) :=\nbegin\n  apply subsingleton_of_bot_eq_top,\n  ext ⟨x, hx⟩, change x ∈ ⊥ at hx, rw submodule.mem_bot at hx, subst hx,\n  simp only [true_iff, eq_self_iff_true, submodule.mk_eq_zero, mem_bot],\nend\n\nlemma subsingleton_bot : subsingleton ↥(⊥ : lie_subalgebra R L) :=\nshow subsingleton ((⊥ : lie_subalgebra R L) : set L), by simp\n\nvariables (R L)\n\nlemma well_founded_of_noetherian [is_noetherian R L] :\n  well_founded ((>) : lie_subalgebra R L → lie_subalgebra R L → Prop) :=\n  let f : ((>) : lie_subalgebra R L → lie_subalgebra R L → Prop) →r\n          ((>) : submodule R L → submodule R L → Prop) :=\n  { to_fun       := coe,\n    map_rel' := λ N N' h, h, }\nin rel_hom_class.well_founded f (is_noetherian_iff_well_founded.mp infer_instance)\n\nvariables {R L K K' f}\n\nsection nested_subalgebras\n\nvariables (h : K ≤ K')\n\n/-- Given two nested Lie subalgebras `K ⊆ K'`, the inclusion `K ↪ K'` is a morphism of Lie\nalgebras. -/\ndef hom_of_le : K →ₗ⁅R⁆ K' :=\n{ map_lie' := λ x y, rfl,\n  ..submodule.of_le h }\n\n@[simp] lemma coe_hom_of_le (x : K) : (hom_of_le h x : L) = x := rfl\n\nlemma hom_of_le_apply (x : K) : hom_of_le h x = ⟨x.1, h x.2⟩ := rfl\n\nlemma hom_of_le_injective : function.injective (hom_of_le h) :=\nλ x y, by simp only [hom_of_le_apply, imp_self, subtype.mk_eq_mk, set_like.coe_eq_coe,\n  subtype.val_eq_coe]\n\n/-- Given two nested Lie subalgebras `K ⊆ K'`, we can view `K` as a Lie subalgebra of `K'`,\nregarded as Lie algebra in its own right. -/\ndef of_le : lie_subalgebra R K' := (hom_of_le h).range\n\n@[simp] lemma mem_of_le (x : K') : x ∈ of_le h ↔ (x : L) ∈ K :=\nbegin\n  simp only [of_le, hom_of_le_apply, lie_hom.mem_range],\n  split,\n  { rintros ⟨y, rfl⟩, exact y.property, },\n  { intros h, use ⟨(x : L), h⟩, simp, },\nend\n\nlemma of_le_eq_comap_incl : of_le h = K.comap K'.incl :=\nby { ext, rw mem_of_le, refl, }\n\n@[simp] lemma coe_of_le : (of_le h : submodule R K') = (submodule.of_le h).range := rfl\n\n/-- Given nested Lie subalgebras `K ⊆ K'`, there is a natural equivalence from `K` to its image in\n`K'`.  -/\nnoncomputable def equiv_of_le : K ≃ₗ⁅R⁆ of_le h :=\n(hom_of_le h).equiv_range_of_injective (hom_of_le_injective h)\n\n@[simp] \n\nend nested_subalgebras\n\nlemma map_le_iff_le_comap {K : lie_subalgebra R L} {K' : lie_subalgebra R L₂} :\n  map f K ≤ K' ↔ K ≤ comap f K' := set.image_subset_iff\n\nlemma gc_map_comap : galois_connection (map f) (comap f) := λ K K', map_le_iff_le_comap\n\nend lattice_structure\n\nsection lie_span\n\nvariables (R L) (s : set L)\n\n/-- The Lie subalgebra of a Lie algebra `L` generated by a subset `s ⊆ L`. -/\ndef lie_span : lie_subalgebra R L := Inf {N | s ⊆ N}\n\nvariables {R L s}\n\nlemma mem_lie_span {x : L} : x ∈ lie_span R L s ↔ ∀ K : lie_subalgebra R L, s ⊆ K → x ∈ K :=\nby { change x ∈ (lie_span R L s : set L) ↔ _, erw Inf_coe, exact set.mem_Inter₂, }\n\nlemma subset_lie_span : s ⊆ lie_span R L s :=\nby { intros m hm, erw mem_lie_span, intros K hK, exact hK hm, }\n\nlemma submodule_span_le_lie_span : submodule.span R s ≤ lie_span R L s :=\nby { rw submodule.span_le, apply subset_lie_span, }\n\nlemma lie_span_le {K} : lie_span R L s ≤ K ↔ s ⊆ K :=\nbegin\n  split,\n  { exact set.subset.trans subset_lie_span, },\n  { intros hs m hm, rw mem_lie_span at hm, exact hm _ hs, },\nend\n\nlemma lie_span_mono {t : set L} (h : s ⊆ t) : lie_span R L s ≤ lie_span R L t :=\nby { rw lie_span_le, exact set.subset.trans h subset_lie_span, }\n\nlemma lie_span_eq : lie_span R L (K : set L) = K :=\nle_antisymm (lie_span_le.mpr rfl.subset) subset_lie_span\n\nlemma coe_lie_span_submodule_eq_iff {p : submodule R L} :\n  (lie_span R L (p : set L) : submodule R L) = p ↔ ∃ (K : lie_subalgebra R L), ↑K = p :=\nbegin\n  rw p.exists_lie_subalgebra_coe_eq_iff, split; intros h,\n  { intros x m hm, rw [← h, mem_coe_submodule], exact lie_mem _ (subset_lie_span hm), },\n  { rw [← coe_to_submodule_mk p h, coe_to_submodule, coe_to_submodule_eq_iff, lie_span_eq], },\nend\n\nvariables (R L)\n\n/-- `lie_span` forms a Galois insertion with the coercion from `lie_subalgebra` to `set`. -/\nprotected def gi : galois_insertion (lie_span R L : set L → lie_subalgebra R L) coe :=\n{ choice    := λ s _, lie_span R L s,\n  gc        := λ s t, lie_span_le,\n  le_l_u    := λ s, subset_lie_span,\n  choice_eq := λ s h, rfl }\n\n@[simp] lemma span_empty : lie_span R L (∅ : set L) = ⊥ :=\n(lie_subalgebra.gi R L).gc.l_bot\n\n@[simp] lemma span_univ : lie_span R L (set.univ : set L) = ⊤ :=\neq_top_iff.2 $ set_like.le_def.2 $ subset_lie_span\n\nvariables {L}\n\nlemma span_union (s t : set L) : lie_span R L (s ∪ t) = lie_span R L s ⊔ lie_span R L t :=\n(lie_subalgebra.gi R L).gc.l_sup\n\nlemma span_Union {ι} (s : ι → set L) : lie_span R L (⋃ i, s i) = ⨆ i, lie_span R L (s i) :=\n(lie_subalgebra.gi R L).gc.l_supr\n\nend lie_span\n\nend lie_subalgebra\n\nend lie_subalgebra\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w}\nvariables [comm_ring R] [lie_ring L₁] [lie_ring L₂] [lie_algebra R L₁] [lie_algebra R L₂]\n\n/-- An injective Lie algebra morphism is an equivalence onto its range. -/\nnoncomputable def of_injective (f : L₁ →ₗ⁅R⁆ L₂) (h : function.injective f) :\n  L₁ ≃ₗ⁅R⁆ f.range :=\n{ map_lie' := λ x y, by { apply set_coe.ext, simpa },\n  .. linear_equiv.of_injective (f : L₁ →ₗ[R] L₂) $ by rwa [lie_hom.coe_to_linear_map] }\n\n@[simp] lemma of_injective_apply (f : L₁ →ₗ⁅R⁆ L₂) (h : function.injective f) (x : L₁) :\n  ↑(of_injective f h x) = f x := rfl\n\nvariables (L₁' L₁'' : lie_subalgebra R L₁) (L₂' : lie_subalgebra R L₂)\n\n/-- Lie subalgebras that are equal as sets are equivalent as Lie algebras. -/\ndef of_eq (h : (L₁' : set L₁) = L₁'') : L₁' ≃ₗ⁅R⁆ L₁'' :=\n{ map_lie' := λ x y, by { apply set_coe.ext, simp, },\n  ..(linear_equiv.of_eq ↑L₁' ↑L₁''\n      (by {ext x, change x ∈ (L₁' : set L₁) ↔ x ∈ (L₁'' : set L₁), rw h, } )) }\n\n@[simp] lemma of_eq_apply (L L' : lie_subalgebra R L₁) (h : (L : set L₁) = L') (x : L) :\n  (↑(of_eq L L' h x) : L₁) = x := rfl\n\nvariables (e : L₁ ≃ₗ⁅R⁆ L₂)\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef lie_subalgebra_map : L₁'' ≃ₗ⁅R⁆ (L₁''.map e : lie_subalgebra R L₂) :=\n{ map_lie' := λ x y, by { apply set_coe.ext, exact lie_hom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y, }\n  ..(linear_equiv.submodule_map (e : L₁ ≃ₗ[R] L₂) ↑L₁'') }\n\n@[simp] lemma lie_subalgebra_map_apply (x : L₁'') : ↑(e.lie_subalgebra_map _  x) = e x := rfl\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef of_subalgebras (h : L₁'.map ↑e = L₂') : L₁' ≃ₗ⁅R⁆ L₂' :=\n{ map_lie' := λ x y, by { apply set_coe.ext, exact lie_hom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y, },\n  ..(linear_equiv.of_submodules (e : L₁ ≃ₗ[R] L₂) ↑L₁' ↑L₂' (by { rw ←h, refl, })) }\n\n@[simp] lemma of_subalgebras_apply (h : L₁'.map ↑e = L₂') (x : L₁') :\n  ↑(e.of_subalgebras _ _ h x) = e x := rfl\n\n@[simp] lemma of_subalgebras_symm_apply (h : L₁'.map ↑e = L₂') (x : L₂') :\n  ↑((e.of_subalgebras _ _ h).symm x) = e.symm x := rfl\n\nend lie_equiv\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/lie/subalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710233, "lm_q2_score": 0.7341195327172401, "lm_q1q2_score": 0.48077100257398947}}
{"text": "\nimport data.real.basic\nimport data.real.cau_seq\nimport computability.halting\nimport computability.partrec_code\nimport computability.primrec\nimport data.nat.gcd\nimport data.int.cast\nimport data.equiv.encodable.basic\nopen_locale classical\n\ndef nnseqR := {u : ℕ → ℝ // ∀ (n : ℕ), u n ≥ 0}\ndef nnseqQ := {u : ℕ → ℚ // ∀ (n : ℕ), u n ≥ 0}\n\ndef RoC (φ: ℕ  → ℕ ) (α : nnseqR) := ∀ k > (0 : ℕ ), ∀ n m ≥ φ k , abs((α.1 m) - (α.1 n)) < (1/k) \n\n\ndef temp: ∀ ε>(0:ℝ), ∃ k > (0: ℕ ) , (1/k :ℝ) < ε:=\nbegin\nintros,\nuse  nat.ceil(1 / ε) + 1,\nhave h₁: (1/ε)< nat.ceil(1 / ε) + 1,\n  calc (1/ε) ≤ nat.ceil(1 / ε): by exact nat.le_ceil (1/ε)\n  ... < nat.ceil(1 / ε) + 1: by exact lt_add_one (nat.ceil(1 / ε)),\nhave h₂ : 0 < (nat.ceil(1 / ε):ℝ ) + 1,\n  calc 0 < (1/ε) :by exact one_div_pos.mpr H\n  ... < nat.ceil(1 / ε) + 1 : by exact h₁,\nsimp at h₁,\nsplit,\nnorm_num,\nsimp,\nexact inv_lt_of_inv_lt H h₁,\nend\ndef tempQ: ∀ ε>(0:ℚ), ∃ k > (0: ℕ ) , (1/k :ℚ) < ε:=\nbegin\nintros,\nuse  nat.ceil(1 / ε) + 1,\nhave h₁: (1/ε) < (nat.ceil(1 / ε):ℚ) + 1,\n  calc (1/ε) ≤ nat.ceil(1 / ε): by exact nat.le_ceil (1/ε)\n  ... < nat.ceil(1 / ε) + 1: by exact lt_add_one (nat.ceil(1 / ε)),\nhave h₂ : 0 < (nat.ceil(1 / ε):ℚ)  + 1,\n  calc 0 < (1/ε) :by exact one_div_pos.mpr H\n  ... < nat.ceil(1 / ε) + 1 : by exact h₁,\nsimp at h₁,\nsplit,\nnorm_num,\nsimp,\nexact inv_lt_of_inv_lt H h₁,\nend\n\ndef RoM (φ: ℕ → (ℕ → ℕ) → ℕ )(α : nnseqR) := ∀ k > (0 : ℕ), ∀ (g: ℕ → ℕ), ∃ n <φ k g, ∀ i ∈  {i :ℕ  | i ≥  n ∧ i ≤  (n  + (g n))}, ∀ j ∈  {i :ℕ  | i ≥  n ∧ i ≤  (n  + (g n))} , abs((α.1 i) - (α.1 j)) < (1/k)\n\ntheorem RoC_implies_cauchy {α : nnseqR} (h: ∃ (φ: ℕ → ℕ ), RoC φ α) : (is_cau_seq abs α.1) := \nbegin\nintros ε h₁,\ncases h with φ h₂,\nhave h₄ :∃ k > (0 : ℕ) , (1/k :ℝ) < ε,\nexact temp ε h₁,\ncases h₄ with k h₅,\ncases h₅ with h₆ h₇,\nuse φ k,\nspecialize h₂ k h₆ (φ k),\nintros j h₃,\nhave h₈ : |α.val j - α.val (φ k)| < (1/k),\nexact h₂ j (by norm_num) h₃,\ncalc |α.val j - α.val (φ k)| < (1/k) : by exact h₈\n... < ε : by exact h₇,\nend\n\ntheorem RoM_implies_cauchy {α : nnseqR} (h: ∃ (φ: ℕ  → (ℕ → ℕ) → ℕ ), RoM φ α) : (is_cau_seq abs α.1) :=\nbegin\nintros ε h₁,\ncases h with φ h₂,\nintros,\nby_contradiction h₃,\npush_neg at h₃,\ncases classical.axiom_of_choice h₃ with f h₄,\nlet g : ℕ → ℕ  := λ x, f x - x,\nhave h₅ :∃ k > (0 : ℕ) , (1/k :ℝ) < ε,\nexact temp ε h₁,\ncases h₅ with k h₆,\ncases h₆ with h₇ q,\nspecialize h₂ k h₇ g,\ncases h₂ with n h₅,\ncases h₅ with h₆ h₇,\nhave h₈ : n ∈  {i :ℕ  | i ≥  n ∧ i ≤  (n  + (g n))},\nsimp,\nhave h₉ : f n ∈  {i :ℕ  | i ≥  n ∧ i ≤  (n  + (g n))},\nsimp,\nsplit,\nexact (h₄ n).1,\nrw ←  nat.add_sub_assoc (h₄ n).1,\nrw add_comm n (f n),\nrw nat.add_sub_assoc,\nsimp,\nspecialize h₇ n h₈ (f n) h₉,\nspecialize h₄ n,\nrw abs_sub_comm at h₇,\nhave p : ¬ |α.val (f n) - α.val n| < ε,\npush_neg,\nexact h₄.2,\nhave p :|α.val (f n) - α.val n| < ε,\ncalc |α.val (f n) - α.val n| < 1 / ↑k : by exact h₇\n... < ε : by exact q,\ncontradiction,\nend\n\nopen computable part nat.partrec (code) nat.partrec.code\n\ndef  s_prop(n :ℕ ) : ℕ → Prop:= (λ (m : ℕ),\n       m ≤ n ∧\n         (∃ (x : ℕ), evaln n (of_nat_code m) 0 = some x) ∧\n           ∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code m) 0 = some w)\n\n@[instance] def s_decideable (n :ℕ) :decidable_pred (s_prop n) :=\nbegin\nunfold decidable_pred,\nintros,\nhave h₁: decidable (a ≤ n),\nexact nat.decidable_le a n,\nhave h₂ : ∀ o : option ℕ, decidable( ∃ x, o = some x),\n--exact option.decidable_forall_mem,\nintros,\napply option.rec_on o, simp, \nexact decidable.false, intros, simp, exact decidable.true,\nspecialize h₂ (evaln n (of_nat_code a) 0),\nhave h₃ : decidable(∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code a) 0 = some w),\nlet P : fin n → Prop := λ l, ∀ (w : ℕ), ¬evaln l (of_nat_code a) 0 = some w,\nhave h₄ : decidable_pred P,\nunfold decidable_pred,\nintros l,\nsimp[P],\nhave h₅ : ∀ o : option ℕ, decidable( ∀ (w : ℕ), ¬ o =some w),\nintros,\napply option.rec_on o, simp, exact decidable.true, intros, simp,\nhave p₁: ¬ ∀ (w : ℕ), ¬val = w,\npush_neg, use val, exact is_false p₁,\nexact h₅ (evaln l (of_nat_code a) 0),\nhave h₆ : decidable(∀ l : fin n, P l),\nexact @nat.decidable_forall_fin n P h₄,\nsimp[P] at h₆,\ndsimp[ fin] at h₆,\nhave h₇: ∀ Q : ℕ → Prop, (∀ l : fin n, Q l) ↔ (∀ l < n, Q l),\nintros,split,intros Q₁ l Q₂, exact Q₁ ⟨ l, Q₂⟩, intros Q₁ l, exact Q₁ l.1 l.2,\nspecialize h₇ (λl, ∀ (w : ℕ), ¬evaln l (of_nat_code a) 0 = some w), simp at h₇,\nexact  decidable_of_decidable_of_iff h₆ h₇,\nhave h₈ : decidable ((∃ x, (evaln n (of_nat_code a) 0) = some x) ∧  (∀ l < n,  ∀ w, ¬ (evaln l (of_nat_code a) 0) = some w)),\nexact @and.decidable (∃ x, (evaln n (of_nat_code a) 0) = some x)  (∀ l < n,  ∀ w, ¬ (evaln l (of_nat_code a) 0) = some w) h₂ h₃,\nexact @and.decidable (a ≤ n) ((∃ x, (evaln n (of_nat_code a) 0) = some x) ∧ ∀ l < n,  ∀ w, ¬ (evaln l (of_nat_code a) 0) = some w) h₁ h₈,\n\nend\n\n@[instance] def s_exist_decidable (n : ℕ ): decidable (∃ (m : ℕ), s_prop n m):= \nbegin\nunfold s_prop,\nlet P : ℕ → Prop:= λ m, (∃ (x : ℕ), evaln n (of_nat_code m) 0 = some x) ∧ ∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code m) 0 = some w,\nhave h₁ : decidable_pred P,\nunfold decidable_pred,\nintros,\nsimp[P],\nhave h₂ : ∀ o : option ℕ, decidable( ∃ x, o = some x),\nintros,\napply option.rec_on o, simp, \nexact decidable.false, intros, simp, exact decidable.true,\nspecialize h₂ (evaln n (of_nat_code a) 0),\nhave h₃ : decidable(∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code a) 0 = some w),\nlet P : fin n → Prop := λ l, ∀ (w : ℕ), ¬evaln l (of_nat_code a) 0 = some w,\nhave h₄ : decidable_pred P,\nunfold decidable_pred,\nintros l,\nsimp[P],\nhave h₅ : ∀ o : option ℕ, decidable( ∀ (w : ℕ), ¬ o =some w),\nintros,\napply option.rec_on o, simp, exact decidable.true, intros, simp,\nhave p₁: ¬ ∀ (w : ℕ), ¬val = w,\npush_neg, use val, exact is_false p₁,\nexact h₅ (evaln l (of_nat_code a) 0),\nhave h₆ : decidable(∀ l : fin n, P l),\nexact @nat.decidable_forall_fin n P h₄,\nsimp[P] at h₆,\ndsimp[ fin] at h₆,\nhave h₇: ∀ Q : ℕ → Prop, (∀ l : fin n, Q l) ↔ (∀ l < n, Q l),\nintros,split,intros Q₁ l Q₂, exact Q₁ ⟨ l, Q₂⟩, intros Q₁ l, exact Q₁ l.1 l.2,\nspecialize h₇ (λl, ∀ (w : ℕ), ¬evaln l (of_nat_code a) 0 = some w), simp at h₇,\nexact  decidable_of_decidable_of_iff h₆ h₇,\nhave h₈ : decidable ((∃ x, (evaln n (of_nat_code a) 0) = some x) ∧  (∀ l < n,  ∀ w, ¬ (evaln l (of_nat_code a) 0) = some w)),\nexact @and.decidable (∃ x, (evaln n (of_nat_code a) 0) = some x)  (∀ l < n,  ∀ w, ¬ (evaln l (of_nat_code a) 0) = some w) h₂ h₃,\nexact h₈,\nhave h₂ : decidable_pred(λx, ∃ (m : ℕ), m < x ∧ P m ),\nexact @nat.decidable_exists_lt P h₁,\nsimp[decidable_pred] at h₂, specialize h₂ (n+1), simp[P] at h₂,\nhave h₃ : (∃ m , m < (n + 1) ∧ (∃ (x : ℕ), evaln n (of_nat_code m) 0 = some x) ∧ \n∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code m) 0 = some w) ↔ \n(∃ (m : ℕ), m ≤ n  ∧ (∃ (x : ℕ), evaln n (of_nat_code m) 0 = some x) ∧ \n∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code m) 0 = some w),\nsplit, intro H, cases H with m H, use m, split, rw ← nat.lt_add_one_iff, exact H.1, exact H.2,\nintro H, cases H with m H, use m, split, rw  nat.lt_add_one_iff, exact H.1, exact H.2,\nexact  decidable_of_decidable_of_iff h₂ h₃,\nend\ndef Specker_seq (α: nnseqR):= ∀ φ: ℕ → ℕ, (RoC φ α) → ¬ computable(φ)\n@[reducible]\ndef s (α: nnseqQ): ℕ → ℚ := \nλ n, if h: ∃ m : ℕ, s_prop n m then α.1 (nat.find h) else 0\n\ntheorem s_converges (α: nnseqQ)(h₁ : ∀ n m, n < m → α.1 n > α.1 m)(h₂: ∀ ε > (0 :ℝ), ∃ N : ℕ, ∀n≥N, (α.1 n: ℝ) < ε ): ∀ ε > (0 :ℝ), ∃ N : ℕ, ∀n≥N, (s α n : ℝ) < ε := \nbegin\nintros,\nspecialize h₂ ε H ,\ncases h₂  with N h₃,\nby_cases ∃ i < N, ∃ x,  x ∈ (eval (of_nat_code i) 0),\ncases h with i h₄, cases h₄ with  h₄ h₅,\nlet S := {j ∈ finset.range N | ∃ x, x ∈ (eval ( of_nat_code j) 0)},\nhave p₁: finset.nonempty S,\nunfold finset.nonempty,use i,simp[S],split,exact h₄,exact h₅,\nlet f : ℕ → ℕ := λj, if r : ∃ k: ℕ,  ∃ x, x ∈ (evaln k (of_nat_code j) 0) then (nat.find r) else 0,let S₁ := S.image f,\nhave p₂: finset.nonempty S₁,\nsimp,exact p₁,\nhave p₃ : ∃ x, x ∈ S₁.max,\nexact finset.max_of_nonempty p₂,\ncases p₃ with k k_h,\nuse k + 1,\nintros,\nunfold s,\nsplit_ifs,\nswap, simp,\nexact H,\nlet z := nat.find h,\nhave p₄ : N ≤ z,\nby_contradiction q,\npush_neg at q,\nhave p₅ : z ∈ S,\nsimp[S],\nsplit,\nuse z,\nsplit,\nexact q,\nexact nat.find_spec h,\nhave h' : z ≤ n ∧  (∃ (x : ℕ), evaln n (of_nat_code z) 0 = some x) ∧ ∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code z) 0 = some w, \nexact nat.find_spec h, \ncases h' with bounded h',\ncases h' with h'₁ h'₂,\ncases h'₁ with x h'₁,\nuse x,\nhave h''₁ : ∃ k, x ∈ evaln k (of_nat_code z) 0,\nuse n,\nexact h'₁,\nrw evaln_complete,\nexact h''₁,\nhave p₆ : f z ∈ S₁,\nsimp[S₁],\nuse z,\nsplit,\nexact p₅, simp,\nhave p₇: f z ≤ k,\nexact finset.le_max_of_mem p₆ k_h,\nhave p₈ : n ≤ f z,\nby_contradiction q₁,\npush_neg at q₁,\nhave h' : z ≤ n ∧ (∃ (x : ℕ), evaln n (of_nat_code z) 0 = some x) ∧ ∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code z) 0 = some w, \nexact nat.find_spec h, \ncases h' with bounded h',\nhave h'₁ :  ∀(l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code z) 0 = some w,\nexact h'.2,\nspecialize h'₁ (f z),\nhave q₂ :∃ (w : ℕ), evaln (f z) (of_nat_code z) 0 = some w,\nsimp[f],\nsplit_ifs,\nhave h_1': ∃ (a_2 : ℕ), evaln (nat.find h_1) (of_nat_code z) 0 = some a_2,\nexact nat.find_spec h_1,\nexact h_1',\nhave h_1_contra : ∃ (a a_1 : ℕ), evaln a (of_nat_code z) 0 = some a_1,\nuse n, exact h'.1,\ncontradiction,\nhave h'₁_contra : ¬ ∃ (w : ℕ), evaln (f z) (of_nat_code z) 0 = some w,\npush_neg,\nexact h'₁ q₁, \ncontradiction,\nhave q₃ : k + 1 ≤ k,\ncalc k + 1 ≤ n : by exact H_1\n... ≤ f z : by exact p₈\n... ≤ k : by exact p₇,\nhave q₃' : ¬  k + 1 ≤ k,\npush_neg,\nexact lt_add_one k,\ncontradiction,\nexact h₃ z p₄,\npush_neg at h,\nuse 0,\nintros,\nunfold s,\nsplit_ifs, \nswap,simp, exact H,\nlet z := nat.find h_1,\nhave h_1' :  z ≤ n ∧ (∃ (x : ℕ), evaln n (of_nat_code z) 0 = some x) ∧ ∀ (l : ℕ), l < n → ∀ (w : ℕ), ¬evaln l (of_nat_code z) 0 = some w,\nexact nat.find_spec h_1,\nhave q : ¬ z < N,\nby_contradiction q,\nspecialize h z,\nhave q₁ :∀ (x : ℕ), ¬  x ∈ eval (of_nat_code z) 0 ,\nexact h q,\nhave q₂ : ∃ (x : ℕ), evaln n (of_nat_code z) 0 = some x,\nexact h_1'.2.1,\ncases q₂ with x q₂,\nspecialize q₁ x,\nhave q₃ : x ∈ evaln n (of_nat_code z) 0,\nsimp,\nexact q₂,\nhave q₃': ∃ k, x ∈ evaln k (of_nat_code z) 0,\nuse n, exact q₃,\nrw ← evaln_complete at q₃',\ncontradiction,\npush_neg at q,\nexact h₃ z q,\n\nend\n\ntheorem bound (n: ℕ) {P : ℕ → Prop} [decidable_pred P] (hP: primrec_pred P): \nprimrec_pred(λ x :ℕ , ∀ x ≤ n, P x):=\nbegin\nunfold primrec_pred,\n\nend\n\n --def coprime_prim: ∀ n : ℕ , primrec_pred(λ d, n.coprime d):= \n\ninstance : primcodable ℚ := primcodable.of_equiv (Σ n : ℤ, {d : ℕ // 0 < d ∧ n.nat_abs.coprime d})\n  ⟨λ ⟨a, b, c, d⟩, ⟨a, b, c, d⟩, λ⟨a, b, c, d⟩, ⟨a, b, c, d⟩,\n   λ ⟨a, b, c, d⟩, rfl, λ⟨a, b, c, d⟩, rfl⟩\n\ninstance PrimcodeQ : primcodable ℚ:= sorry\n\ntheorem s_specker (α: nnseqQ)(h₀: computable α.1)(h₁ : ∀ n m, n < m → α.1 n > α.1 m)(h₂: ∀ ε > (0 :ℝ), ∃ N : ℕ, ∀n≥N, (α.1 n :ℝ) < ε ):\n ∀ φ: ℚ → ℕ, (∀ ε  > (0 : ℚ), ∀ n > φ ε , ((s α) n) < ε ) → ¬ computable(φ) :=\n begin\n intros φ h₃,\n by_contradiction, \n have h₄ : ∀ n, α.1 n > 0,\nintros,\nby_contradiction p,\npush_neg at p,\nhave p₁: α.1 (n + 1) < 0,\ncalc α.1 (n + 1) < α.1 n : by exact h₁ n (n+1) (lt_add_one n)\n...  ≤ 0 : by exact p,\nhave p₂ : ¬ α.1 (n + 1) < 0,\npush_neg,\nexact (α.2(n +1)),\ncontradiction,\n--have h₅: ∀ n, ∃ k > (0: ℕ ) , (1/k :ℚ) < α.1 n,\n--intro, exact tempQ (α.1 n) (h₄ n),\n--let r := λn, nat.find (h₅ n),\nlet max_halt: ℕ → ℕ  := λ n, max_default n (φ (α.1 (n + 1))),\nhave h₆ : ∀ n, (∃ x, x ∈ evaln (max_halt n) (of_nat_code n) 0) ↔ (∃ x, x ∈ eval (of_nat_code n) 0), \nintros n, split,swap, intro p₁,\ncases p₁ with x,\nhave p₂ : ∃ k, x ∈ evaln k (of_nat_code n) 0,\nrw ←  evaln_complete, exact p₁_h,\nhave p₂': ∃ k, ∃ x, x ∈ evaln k (of_nat_code n) 0,\ncases p₂ with k, use k, use x, exact p₂_h,\nlet k:= nat.find p₂',\nhave p₃ : k ≤ max_halt n,\nby_contradiction p₃, push_neg at p₃,\nhave p₄: n ≤ max_halt n,\nsimp[max_halt], unfold max_default, split_ifs, simp, simp at h_1, exact le_of_lt h_1,\nhave p₅: n < k,\ncalc n ≤ max_halt n : by exact p₄\n... < k: by exact p₃,\nhave p₆:s_prop k n,\nunfold s_prop,split,exact le_of_lt p₅,split, exact nat.find_spec p₂',\nintro,\nhave min: l < k → ¬∃(w : ℕ),evaln l (of_nat_code n) 0 = some w,\nexact nat.find_min p₂',push_neg at min, exact min,\nhave p₇: s α k ≥ α.1 n,\nunfold s, split_ifs,\nhave p₈: nat.find h_1 ≤ n, exact nat.find_min' h_1 p₆,\nhave p₈': nat.find h_1 < n ∨ nat.find h_1 = n,\nexact lt_or_eq_of_le p₈, cases p₈',\nexact le_of_lt (h₁ (nat.find h_1) n p₈'), exact (congr_arg α.val p₈').ge,\npush_neg at h_1,specialize h_1 n, contradiction,\nhave p₈ : α.val n > α.val (n + 1),\nexact h₁ n (n+1) (lt_add_one n),\nhave p₉ : s α k > α.val (n + 1),\ncalc s α k ≥ α.1 n : by exact p₇\n... > α.val (n + 1) : by exact p₈,\nhave q₁ : φ (α.1 (n + 1)) ≤ max_halt n,\nsimp[max_halt], unfold max_default, split_ifs, exact  h_1, simp,\nhave q₂:  φ (α.1 (n + 1)) < k,\ncalc φ (α.1 (n + 1)) ≤ max_halt n : by exact q₁\n...< k : by exact p₃,\nrw ← gt_iff_lt at q₂,\nhave h₉': s α k < α.val (n + 1),\nexact h₃ (α.1 (n+1)) (h₄ (n + 1)) k q₂,\nhave h₉'': ¬ s α k < α.val (n + 1),\npush_neg, exact le_of_lt p₉, contradiction,\nhave spec: ∃ x, x ∈ evaln k (of_nat_code n) 0,\nexact nat.find_spec p₂',\ncases spec with x,\nuse x, exact evaln_mono p₃ spec_h,\nintro h₅,cases h₅ with x,\nuse x,\nhave h₆ : ∃ k, x ∈ evaln k (of_nat_code n) 0,\nuse (max_halt n), exact h₅_h,\nrw evaln_complete, exact h₆,\nhave p₁ : computable (λ n, φ ( α.1 (n+1))),\nexact computable.comp h (computable.comp h₀ computable.succ),\nhave p₂ : computable(λn, max_halt n),\nsimp[max_halt], exact computable₂.comp primrec.nat_max.to_comp computable.id p₁,\nhave p₃ : computable(λ n, of_nat_code n),\nrw ← of_nat_code_eq, exact computable.of_nat code,\nlet evalnmap:= λ (a : (ℕ × code) × ℕ), evaln a.1.1 a.1.2 a.2,\nhave p₄ : computable(evalnmap),\nexact evaln_prim.to_comp,\nlet evalnmap':= λ (a : ℕ × code) , evalnmap (⟨ a, 0⟩),\nhave p₅ : computable(evalnmap'),\nexact computable.comp p₄ (computable.pair computable.id (primrec.to_comp (primrec₂.const 0))),\nlet E:= λ n, evalnmap' (((max_halt n), (of_nat_code n))),\nhave p₆ : computable E,\nsimp[E], exact computable.comp p₅ (computable.pair p₂ p₃),\nsimp[E] at p₆,simp[evalnmap'] at p₆, simp[evalnmap] at p₆, simp at p₆,\nhave p₇ : computable_pred (λ n, option.is_some (evaln (max_halt n) (of_nat_code n) 0)),\nsimp[computable_pred],\nrefine ⟨by apply_instance, _⟩,\nexact computable.comp primrec.option_is_some.to_comp p₆,\nhave p₈ : ∀ n,option.is_some (evaln (max_halt n) (of_nat_code n) 0) ↔ (∃ x, x ∈ evaln (max_halt n) (of_nat_code n) 0) ,\nintros,exact option.is_some_iff_exists,\nhave p₉ : computable_pred(λn, ∃ x, x ∈ evaln (max_halt n) (of_nat_code n) 0),\nexact computable_pred.of_eq p₇ p₈,\nhave q₁: computable_pred(λ n, ∃ (x : ℕ), x ∈ (of_nat_code n).eval 0),\nexact computable_pred.of_eq p₉ h₆,\nhave q₂ : ∀ n ,(∃ (x : ℕ), x ∈ (of_nat_code n).eval 0) ↔ ((of_nat_code n).eval 0).dom,\nintros, rw ←  dom_iff_mem,\nhave q₃ : computable_pred( λ n, ((of_nat_code n).eval 0).dom),\nexact computable_pred.of_eq q₁ q₂,\nhave q₄ : computable_pred(λ c : code, ((eval (of_nat_code (encode_code c))) 0).dom),\ncasesI q₃,\nrefine ⟨by apply_instance, _⟩,\nrw ← encode_code_eq,\nexact computable.comp q₃_h computable.encode,\nrw ← encode_code_eq at q₄,rw ← of_nat_code_eq at q₄, simp at q₄,\nexact (computable_pred.halting_problem 0) q₄,\nend \n\n", "meta": {"author": "Kejineri", "repo": "Proof-mining-", "sha": "dfcd71b7dddfad4b625fda344b5813da8569610d", "save_path": "github-repos/lean/Kejineri-Proof-mining-", "path": "github-repos/lean/Kejineri-Proof-mining-/Proof-mining--dfcd71b7dddfad4b625fda344b5813da8569610d/Specker.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4806814722388682}}
{"text": "import tactic --hide\n\n/-\nIf you're sad that the game is over, here is some bonus content to keep you going.\n-/\n\n\n/-Lemma \nA long chain of implications.\n-/\nlemma lemma_6 (P Q R S T : Prop) : (P → R) → (S → Q) → (R → T) → (Q → R) → S → T :=\nbegin\n  intros hPR hSQ hRT hQR hS,\n  apply hRT,\n  apply hQR,\n  apply hSQ,\n  exact hS,\n\n\n\nend", "meta": {"author": "CBirkbeck", "repo": "logic_projic", "sha": "0b029af0fbfc0ac6eafae47401d5bbf8e641d7d2", "save_path": "github-repos/lean/CBirkbeck-logic_projic", "path": "github-repos/lean/CBirkbeck-logic_projic/logic_projic-0b029af0fbfc0ac6eafae47401d5bbf8e641d7d2/src/logic_1/logic8.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.4806814620456157}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport group_theory.perm.support\nimport data.fintype.basic\nimport group_theory.order_of_element\nimport tactic.norm_swap\nimport data.finset.sort\n\n/-!\n# Sign of a permutation\n\nThe main definition of this file is `equiv.perm.sign`, associating a `ℤˣ` sign with a\npermutation.\n\nThis file also contains miscellaneous lemmas about `equiv.perm` and `equiv.swap`, building on top\nof those in `data/equiv/basic` and other files in `group_theory/perm/*`.\n\n-/\n\nuniverses u v\nopen equiv function fintype finset\nopen_locale big_operators\nvariables {α : Type u} {β : Type v}\n\nnamespace equiv.perm\n\n/--\n`mod_swap i j` contains permutations up to swapping `i` and `j`.\n\nWe use this to partition permutations in `matrix.det_zero_of_row_eq`, such that each partition\nsums up to `0`.\n-/\ndef mod_swap [decidable_eq α] (i j : α) : setoid (perm α) :=\n⟨λ σ τ, σ = τ ∨ σ = swap i j * τ,\n λ σ, or.inl (refl σ),\n λ σ τ h, or.cases_on h (λ h, or.inl h.symm) (λ h, or.inr (by rw [h, swap_mul_self_mul])),\n λ σ τ υ hστ hτυ, by cases hστ; cases hτυ; try {rw [hστ, hτυ, swap_mul_self_mul]}; simp [hστ, hτυ] ⟩\n\ninstance {α : Type*} [fintype α] [decidable_eq α] (i j : α) : decidable_rel (mod_swap i j).r :=\nλ σ τ, or.decidable\n\nlemma perm_inv_on_of_perm_on_finset {s : finset α} {f : perm α}\n  (h : ∀ x ∈ s, f x ∈ s) {y : α} (hy : y ∈ s) : f⁻¹ y ∈ s :=\nbegin\n  have h0 : ∀ y ∈ s, ∃ x (hx : x ∈ s), y = (λ i (hi : i ∈ s), f i) x hx :=\n    finset.surj_on_of_inj_on_of_card_le (λ x hx, (λ i hi, f i) x hx)\n    (λ a ha, h a ha) (λ a₁ a₂ ha₁ ha₂ heq, (equiv.apply_eq_iff_eq f).mp heq) rfl.ge,\n  obtain ⟨y2, hy2, heq⟩ := h0 y hy,\n  convert hy2,\n  rw heq,\n  simp only [inv_apply_self]\nend\n\nlemma perm_inv_maps_to_of_maps_to (f : perm α) {s : set α} [fintype s]\n  (h : set.maps_to f s s) : set.maps_to (f⁻¹ : _) s s :=\nλ x hx, set.mem_to_finset.mp $\n  perm_inv_on_of_perm_on_finset\n   (λ a ha, set.mem_to_finset.mpr (h (set.mem_to_finset.mp ha)))\n   (set.mem_to_finset.mpr hx)\n\n@[simp] lemma perm_inv_maps_to_iff_maps_to {f : perm α} {s : set α} [fintype s] :\n  set.maps_to (f⁻¹ : _) s s ↔ set.maps_to f s s :=\n⟨perm_inv_maps_to_of_maps_to f⁻¹, perm_inv_maps_to_of_maps_to f⟩\n\nlemma perm_inv_on_of_perm_on_fintype {f : perm α} {p : α → Prop} [fintype {x // p x}]\n  (h : ∀ x, p x → p (f x)) {x : α} (hx : p x) : p (f⁻¹ x) :=\nbegin\n  letI : fintype ↥(show set α, from p) := ‹fintype {x // p x}›,\n  exact perm_inv_maps_to_of_maps_to f h hx\nend\n\n/-- If the permutation `f` maps `{x // p x}` into itself, then this returns the permutation\n  on `{x // p x}` induced by `f`. Note that the `h` hypothesis is weaker than for\n  `equiv.perm.subtype_perm`. -/\nabbreviation subtype_perm_of_fintype (f : perm α) {p : α → Prop} [fintype {x // p x}]\n  (h : ∀ x, p x → p (f x)) : perm {x // p x} :=\nf.subtype_perm (λ x, ⟨h x, λ h₂, f.inv_apply_self x ▸ perm_inv_on_of_perm_on_fintype h h₂⟩)\n\n@[simp] lemma subtype_perm_of_fintype_apply (f : perm α) {p : α → Prop} [fintype {x // p x}]\n  (h : ∀ x, p x → p (f x)) (x : {x // p x}) : subtype_perm_of_fintype f h x = ⟨f x, h x x.2⟩ := rfl\n\n@[simp] lemma subtype_perm_of_fintype_one (p : α → Prop) [fintype {x // p x}]\n  (h : ∀ x, p x → p ((1 : perm α) x)) : @subtype_perm_of_fintype α 1 p _ h = 1 :=\nequiv.ext $ λ ⟨_, _⟩, rfl\n\nlemma perm_maps_to_inl_iff_maps_to_inr {m n : Type*} [fintype m] [fintype n]\n  (σ : equiv.perm (m ⊕ n)) :\n  set.maps_to σ (set.range sum.inl) (set.range sum.inl) ↔\n  set.maps_to σ (set.range sum.inr) (set.range sum.inr) :=\nbegin\n  split; id\n  { intros h,\n    classical,\n    rw ←perm_inv_maps_to_iff_maps_to at h,\n    intro x,\n    cases hx : σ x with l r, },\n  { rintros ⟨a, rfl⟩,\n    obtain ⟨y, hy⟩ := h ⟨l, rfl⟩,\n    rw [←hx, σ.inv_apply_self] at hy,\n    exact absurd hy sum.inl_ne_inr},\n  { rintros ⟨a, ha⟩, exact ⟨r, rfl⟩, },\n  { rintros ⟨a, ha⟩, exact ⟨l, rfl⟩, },\n  { rintros ⟨a, rfl⟩,\n    obtain ⟨y, hy⟩ := h ⟨r, rfl⟩,\n    rw [←hx, σ.inv_apply_self] at hy,\n    exact absurd hy sum.inr_ne_inl},\nend\n\nlemma mem_sum_congr_hom_range_of_perm_maps_to_inl {m n : Type*} [fintype m] [fintype n]\n  {σ : perm (m ⊕ n)} (h : set.maps_to σ (set.range sum.inl) (set.range sum.inl)) :\n  σ ∈ (sum_congr_hom m n).range :=\nbegin\n  classical,\n  have h1 : ∀ (x : m ⊕ n), (∃ (a : m), sum.inl a = x) → (∃ (a : m), sum.inl a = σ x),\n  { rintros x ⟨a, ha⟩, apply h, rw ← ha, exact ⟨a, rfl⟩ },\n  have h3 : ∀ (x : m ⊕ n), (∃ (b : n), sum.inr b = x) → (∃ (b : n), sum.inr b = σ x),\n  { rintros x ⟨b, hb⟩,\n    apply (perm_maps_to_inl_iff_maps_to_inr σ).mp h,\n    rw ← hb, exact ⟨b, rfl⟩ },\n  let σ₁' := subtype_perm_of_fintype σ h1,\n  let σ₂' := subtype_perm_of_fintype σ h3,\n  let σ₁ := perm_congr (equiv.of_injective _ sum.inl_injective).symm σ₁',\n  let σ₂ := perm_congr (equiv.of_injective _ sum.inr_injective).symm σ₂',\n  rw [monoid_hom.mem_range, prod.exists],\n  use [σ₁, σ₂],\n  rw [perm.sum_congr_hom_apply],\n  ext,\n  cases x with a b,\n  { rw [equiv.sum_congr_apply, sum.map_inl, perm_congr_apply, equiv.symm_symm,\n        apply_of_injective_symm sum.inl_injective],\n    erw subtype_perm_apply,\n    rw [of_injective_apply, subtype.coe_mk, subtype.coe_mk] },\n  { rw [equiv.sum_congr_apply, sum.map_inr, perm_congr_apply, equiv.symm_symm,\n        apply_of_injective_symm sum.inr_injective],\n    erw subtype_perm_apply,\n    rw [of_injective_apply, subtype.coe_mk, subtype.coe_mk] }\nend\n\nlemma disjoint.order_of {σ τ : perm α} (hστ : disjoint σ τ) :\n  order_of (σ * τ) = nat.lcm (order_of σ) (order_of τ) :=\nbegin\n  have h : ∀ n : ℕ, (σ * τ) ^ n = 1 ↔ σ ^ n = 1 ∧ τ ^ n = 1 :=\n  λ n, by rw [hστ.commute.mul_pow, disjoint.mul_eq_one_iff (hστ.pow_disjoint_pow n n)],\n  exact nat.dvd_antisymm hστ.commute.order_of_mul_dvd_lcm (nat.lcm_dvd\n    (order_of_dvd_of_pow_eq_one ((h (order_of (σ * τ))).mp (pow_order_of_eq_one (σ * τ))).1)\n    (order_of_dvd_of_pow_eq_one ((h (order_of (σ * τ))).mp (pow_order_of_eq_one (σ * τ))).2)),\nend\n\nlemma disjoint.extend_domain {α : Type*} {p : β → Prop} [decidable_pred p]\n  (f : α ≃ subtype p) {σ τ : perm α} (h : disjoint σ τ) :\n  disjoint (σ.extend_domain f) (τ.extend_domain f) :=\nbegin\n  intro b,\n  by_cases pb : p b,\n  { refine (h (f.symm ⟨b, pb⟩)).imp _ _;\n    { intro h,\n      rw [extend_domain_apply_subtype _ _ pb, h, apply_symm_apply, subtype.coe_mk] } },\n  { left,\n    rw [extend_domain_apply_not_subtype _ _ pb] }\nend\n\nvariable [decidable_eq α]\n\nsection fintype\nvariable [fintype α]\n\nlemma support_pow_coprime {σ : perm α} {n : ℕ} (h : nat.coprime n (order_of σ)) :\n  (σ ^ n).support = σ.support :=\nbegin\n  obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime h,\n  exact le_antisymm (support_pow_le σ n) (le_trans (ge_of_eq (congr_arg support hm))\n    (support_pow_le (σ ^ n) m)),\nend\n\nend fintype\n\n/-- Given a list `l : list α` and a permutation `f : perm α` such that the nonfixed points of `f`\n  are in `l`, recursively factors `f` as a product of transpositions. -/\ndef swap_factors_aux : Π (l : list α) (f : perm α), (∀ {x}, f x ≠ x → x ∈ l) →\n  {l : list (perm α) // l.prod = f ∧ ∀ g ∈ l, is_swap g}\n| []       := λ f h, ⟨[], equiv.ext $ λ x, by { rw [list.prod_nil],\n    exact (not_not.1 (mt h (list.not_mem_nil _))).symm }, by simp⟩\n| (x :: l) := λ f h,\nif hfx : x = f x\nthen swap_factors_aux l f\n  (λ y hy, list.mem_of_ne_of_mem (λ h : y = x, by simpa [h, hfx.symm] using hy) (h hy))\nelse let m := swap_factors_aux l (swap x (f x) * f)\n      (λ y hy, have f y ≠ y ∧ y ≠ x, from ne_and_ne_of_swap_mul_apply_ne_self hy,\n        list.mem_of_ne_of_mem this.2 (h this.1)) in\n  ⟨swap x (f x) :: m.1,\n  by rw [list.prod_cons, m.2.1, ← mul_assoc,\n    mul_def (swap x (f x)), swap_swap, ← one_def, one_mul],\n  λ g hg, ((list.mem_cons_iff _ _ _).1 hg).elim (λ h, ⟨x, f x, hfx, h⟩) (m.2.2 _)⟩\n\n/-- `swap_factors` represents a permutation as a product of a list of transpositions.\nThe representation is non unique and depends on the linear order structure.\nFor types without linear order `trunc_swap_factors` can be used. -/\ndef swap_factors [fintype α] [linear_order α] (f : perm α) :\n  {l : list (perm α) // l.prod = f ∧ ∀ g ∈ l, is_swap g} :=\nswap_factors_aux ((@univ α _).sort (≤)) f (λ _ _, (mem_sort _).2 (mem_univ _))\n\n/-- This computably represents the fact that any permutation can be represented as the product of\n  a list of transpositions. -/\ndef trunc_swap_factors [fintype α] (f : perm α) :\n  trunc {l : list (perm α) // l.prod = f ∧ ∀ g ∈ l, is_swap g} :=\nquotient.rec_on_subsingleton (@univ α _).1\n  (λ l h, trunc.mk (swap_factors_aux l f h))\n  (show ∀ x, f x ≠ x → x ∈ (@univ α _).1, from λ _ _, mem_univ _)\n\n/-- An induction principle for permutations. If `P` holds for the identity permutation, and\nis preserved under composition with a non-trivial swap, then `P` holds for all permutations. -/\n@[elab_as_eliminator] lemma swap_induction_on [fintype α] {P : perm α → Prop} (f : perm α) :\n  P 1 → (∀ f x y, x ≠ y → P f → P (swap x y * f)) → P f :=\nbegin\n  cases (trunc_swap_factors f).out with l hl,\n  induction l with g l ih generalizing f,\n  { simp only [hl.left.symm, list.prod_nil, forall_true_iff] {contextual := tt} },\n  { assume h1 hmul_swap,\n    rcases hl.2 g (by simp) with ⟨x, y, hxy⟩,\n    rw [← hl.1, list.prod_cons, hxy.2],\n    exact hmul_swap _ _ _ hxy.1\n      (ih _ ⟨rfl, λ v hv, hl.2 _ (list.mem_cons_of_mem _ hv)⟩ h1 hmul_swap) }\nend\n\nlemma closure_is_swap [fintype α] : subgroup.closure {σ : perm α | is_swap σ} = ⊤ :=\nbegin\n  refine eq_top_iff.mpr (λ x hx, _),\n  obtain ⟨h1, h2⟩ := subtype.mem (trunc_swap_factors x).out,\n  rw ← h1,\n  exact subgroup.list_prod_mem _ (λ y hy, subgroup.subset_closure (h2 y hy)),\nend\n\n/-- Like `swap_induction_on`, but with the composition on the right of `f`.\n\nAn induction principle for permutations. If `P` holds for the identity permutation, and\nis preserved under composition with a non-trivial swap, then `P` holds for all permutations. -/\n@[elab_as_eliminator] lemma swap_induction_on' [fintype α] {P : perm α → Prop} (f : perm α) :\n  P 1 → (∀ f x y, x ≠ y → P f → P (f * swap x y)) → P f :=\nλ h1 IH, inv_inv f ▸ swap_induction_on f⁻¹ h1 (λ f, IH f⁻¹)\n\nlemma is_conj_swap {w x y z : α} (hwx : w ≠ x) (hyz : y ≠ z) : is_conj (swap w x) (swap y z) :=\nis_conj_iff.2 (have h : ∀ {y z : α}, y ≠ z → w ≠ z →\n      (swap w y * swap x z) * swap w x * (swap w y * swap x z)⁻¹ = swap y z :=\n    λ y z hyz hwz, by rw [mul_inv_rev, swap_inv, swap_inv, mul_assoc (swap w y),\n      mul_assoc (swap w y), ← mul_assoc _ (swap x z), swap_mul_swap_mul_swap hwx hwz,\n      ← mul_assoc, swap_mul_swap_mul_swap hwz.symm hyz.symm],\n  if hwz : w = z\n  then have hwy : w ≠ y, by cc,\n    ⟨swap w z * swap x y, by rw [swap_comm y z, h hyz.symm hwy]⟩\n  else ⟨swap w y * swap x z, h hyz hwz⟩)\n\n/-- set of all pairs (⟨a, b⟩ : Σ a : fin n, fin n) such that b < a -/\ndef fin_pairs_lt (n : ℕ) : finset (Σ a : fin n, fin n) :=\n(univ : finset (fin n)).sigma (λ a, (range a).attach_fin\n  (λ m hm, (mem_range.1 hm).trans a.2))\n\nlemma mem_fin_pairs_lt {n : ℕ} {a : Σ a : fin n, fin n} :\n  a ∈ fin_pairs_lt n ↔ a.2 < a.1 :=\nby simp only [fin_pairs_lt, fin.lt_iff_coe_lt_coe, true_and, mem_attach_fin, mem_range, mem_univ,\n  mem_sigma]\n\n/-- `sign_aux σ` is the sign of a permutation on `fin n`, defined as the parity of the number of\n  pairs `(x₁, x₂)` such that `x₂ < x₁` but `σ x₁ ≤ σ x₂` -/\ndef sign_aux {n : ℕ} (a : perm (fin n)) : ℤˣ :=\n∏ x in fin_pairs_lt n, if a x.1 ≤ a x.2 then -1 else 1\n\n@[simp] lemma sign_aux_one (n : ℕ) : sign_aux (1 : perm (fin n)) = 1 :=\nbegin\n  unfold sign_aux,\n  conv { to_rhs, rw ← @finset.prod_const_one ℤˣ _\n    (fin_pairs_lt n) },\n  exact finset.prod_congr rfl (λ a ha, if_neg (mem_fin_pairs_lt.1 ha).not_le)\nend\n\n/-- `sign_bij_aux f ⟨a, b⟩` returns the pair consisting of `f a` and `f b` in decreasing order. -/\ndef sign_bij_aux {n : ℕ} (f : perm (fin n)) (a : Σ a : fin n, fin n) :\n  Σ a : fin n, fin n :=\nif hxa : f a.2 < f a.1 then ⟨f a.1, f a.2⟩ else ⟨f a.2, f a.1⟩\n\nlemma sign_bij_aux_inj {n : ℕ} {f : perm (fin n)} : ∀ a b : Σ a : fin n, fin n,\n   a ∈ fin_pairs_lt n → b ∈ fin_pairs_lt n →\n   sign_bij_aux f a = sign_bij_aux f b → a = b :=\nλ ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ha hb h, begin\n  unfold sign_bij_aux at h,\n  rw mem_fin_pairs_lt at *,\n  have : ¬b₁ < b₂ := hb.le.not_lt,\n  split_ifs at h;\n  simp only [*, (equiv.injective f).eq_iff, eq_self_iff_true, and_self, heq_iff_eq] at *,\nend\n\nlemma sign_bij_aux_surj {n : ℕ} {f : perm (fin n)} : ∀ a ∈ fin_pairs_lt n,\n  ∃ b ∈ fin_pairs_lt n, a = sign_bij_aux f b :=\nλ ⟨a₁, a₂⟩ ha,\nif hxa : f⁻¹ a₂ < f⁻¹ a₁\nthen ⟨⟨f⁻¹ a₁, f⁻¹ a₂⟩, mem_fin_pairs_lt.2 hxa,\n  by { dsimp [sign_bij_aux],\n    rw [apply_inv_self, apply_inv_self, if_pos (mem_fin_pairs_lt.1 ha)] }⟩\nelse ⟨⟨f⁻¹ a₂, f⁻¹ a₁⟩, mem_fin_pairs_lt.2 $ (le_of_not_gt hxa).lt_of_ne $ λ h,\n    by simpa [mem_fin_pairs_lt, (f⁻¹).injective h, lt_irrefl] using ha,\n  by { dsimp [sign_bij_aux],\n    rw [apply_inv_self, apply_inv_self, if_neg (mem_fin_pairs_lt.1 ha).le.not_lt] }⟩\n\nlemma sign_bij_aux_mem {n : ℕ} {f : perm (fin n)} : ∀ a : Σ a : fin n, fin n,\n  a ∈ fin_pairs_lt n → sign_bij_aux f a ∈ fin_pairs_lt n :=\nλ ⟨a₁, a₂⟩ ha, begin\n  unfold sign_bij_aux,\n  split_ifs with h,\n  { exact mem_fin_pairs_lt.2 h },\n  { exact mem_fin_pairs_lt.2\n    ((le_of_not_gt h).lt_of_ne (λ h, (mem_fin_pairs_lt.1 ha).ne (f.injective h.symm))) }\nend\n\n@[simp] lemma sign_aux_inv {n : ℕ} (f : perm (fin n)) : sign_aux f⁻¹ = sign_aux f :=\nprod_bij (λ a ha, sign_bij_aux f⁻¹ a)\n  sign_bij_aux_mem\n  (λ ⟨a, b⟩ hab, if h : f⁻¹ b < f⁻¹ a\n    then by rw [sign_bij_aux, dif_pos h, if_neg h.not_le, apply_inv_self,\n      apply_inv_self, if_neg (mem_fin_pairs_lt.1 hab).not_le]\n    else by rw [sign_bij_aux, if_pos (le_of_not_gt h), dif_neg h, apply_inv_self,\n      apply_inv_self, if_pos (mem_fin_pairs_lt.1 hab).le])\n  sign_bij_aux_inj\n  sign_bij_aux_surj\n\nlemma sign_aux_mul {n : ℕ} (f g : perm (fin n)) :\n  sign_aux (f * g) = sign_aux f * sign_aux g :=\nbegin\n  rw ← sign_aux_inv g,\n  unfold sign_aux,\n  rw ← prod_mul_distrib,\n  refine prod_bij (λ a ha, sign_bij_aux g a) sign_bij_aux_mem _ sign_bij_aux_inj sign_bij_aux_surj,\n  rintros ⟨a, b⟩ hab,\n  rw [sign_bij_aux, mul_apply, mul_apply],\n  rw mem_fin_pairs_lt at hab,\n  by_cases h : g b < g a,\n  { rw dif_pos h,\n    simp only [not_le_of_gt hab, mul_one, perm.inv_apply_self, if_false] },\n  { rw [dif_neg h, inv_apply_self, inv_apply_self, if_pos hab.le],\n    by_cases h₁ : f (g b) ≤ f (g a),\n    { have : f (g b) ≠ f (g a),\n      { rw [ne.def, f.injective.eq_iff, g.injective.eq_iff],\n        exact ne_of_lt hab },\n      rw [if_pos h₁, if_neg (h₁.lt_of_ne this).not_le],\n      refl },\n    { rw [if_neg h₁, if_pos (lt_of_not_ge h₁).le],\n      refl } }\nend\n\nprivate lemma sign_aux_swap_zero_one' (n : ℕ) :\n  sign_aux (swap (0 : fin (n + 2)) 1) = -1 :=\nshow _ = ∏ x : Σ a : fin (n + 2), fin (n + 2) in {(⟨1, 0⟩ : Σ a : fin (n + 2), fin (n + 2))},\n  if (equiv.swap 0 1) x.1 ≤ swap 0 1 x.2 then (-1 : ℤˣ) else 1,\nbegin\n  refine eq.symm (prod_subset (λ ⟨x₁, x₂⟩,\n    by simp [mem_fin_pairs_lt, fin.one_pos] {contextual := tt}) (λ a ha₁ ha₂, _)),\n  rcases a with ⟨a₁, a₂⟩,\n  replace ha₁ : a₂ < a₁ := mem_fin_pairs_lt.1 ha₁,\n  dsimp only,\n  rcases a₁.zero_le.eq_or_lt with rfl|H,\n  { exact absurd a₂.zero_le ha₁.not_le },\n  rcases a₂.zero_le.eq_or_lt with rfl|H',\n  { simp only [and_true, eq_self_iff_true, heq_iff_eq, mem_singleton] at ha₂,\n    have : 1 < a₁ := lt_of_le_of_ne (nat.succ_le_of_lt ha₁) (ne.symm ha₂),\n    have h01 : equiv.swap (0 : fin (n + 2)) 1 0 = 1, by simp, -- TODO : fix properly\n    norm_num [swap_apply_of_ne_of_ne (ne_of_gt H) ha₂, this.not_le, h01] },\n  { have le : 1 ≤ a₂ := nat.succ_le_of_lt H',\n    have lt : 1 < a₁ := le.trans_lt ha₁,\n    have h01 : equiv.swap (0 : fin (n + 2)) 1 1 = 0, by simp, -- TODO\n    rcases le.eq_or_lt with rfl|lt',\n    { norm_num [swap_apply_of_ne_of_ne H.ne' lt.ne', H.not_le, h01] },\n    { norm_num [swap_apply_of_ne_of_ne (ne_of_gt H) (ne_of_gt lt),\n        swap_apply_of_ne_of_ne (ne_of_gt H') (ne_of_gt lt'), ha₁.not_le] } }\nend\n\nprivate lemma sign_aux_swap_zero_one {n : ℕ} (hn : 2 ≤ n) :\n  sign_aux (swap (⟨0, lt_of_lt_of_le dec_trivial hn⟩ : fin n)\n  ⟨1, lt_of_lt_of_le dec_trivial hn⟩) = -1 :=\nbegin\n  rcases n with _|_|n,\n  { norm_num at hn },\n  { norm_num at hn },\n  { exact sign_aux_swap_zero_one' n }\nend\n\nlemma sign_aux_swap : ∀ {n : ℕ} {x y : fin n} (hxy : x ≠ y),\n  sign_aux (swap x y) = -1\n| 0 := dec_trivial\n| 1 := dec_trivial\n| (n+2) := λ x y hxy,\nhave h2n : 2 ≤ n + 2 := dec_trivial,\nby { rw [← is_conj_iff_eq, ← sign_aux_swap_zero_one h2n],\n  exact (monoid_hom.mk' sign_aux sign_aux_mul).map_is_conj (is_conj_swap hxy dec_trivial) }\n\n/-- When the list `l : list α` contains all nonfixed points of the permutation `f : perm α`,\n  `sign_aux2 l f` recursively calculates the sign of `f`. -/\ndef sign_aux2 : list α → perm α → ℤˣ\n| []     f := 1\n| (x::l) f := if x = f x then sign_aux2 l f else -sign_aux2 l (swap x (f x) * f)\n\nlemma sign_aux_eq_sign_aux2 {n : ℕ} : ∀ (l : list α) (f : perm α) (e : α ≃ fin n)\n  (h : ∀ x, f x ≠ x → x ∈ l), sign_aux ((e.symm.trans f).trans e) = sign_aux2 l f\n| []     f e h := have f = 1, from equiv.ext $\n  λ y, not_not.1 (mt (h y) (list.not_mem_nil _)),\nby rw [this, one_def, equiv.trans_refl, equiv.symm_trans_self, ← one_def,\n  sign_aux_one, sign_aux2]\n| (x::l) f e h := begin\n  rw sign_aux2,\n  by_cases hfx : x = f x,\n  { rw if_pos hfx,\n    exact sign_aux_eq_sign_aux2 l f _ (λ y (hy : f y ≠ y), list.mem_of_ne_of_mem\n      (λ h : y = x, by simpa [h, hfx.symm] using hy) (h y hy) ) },\n  { have hy : ∀ y : α, (swap x (f x) * f) y ≠ y → y ∈ l, from λ y hy,\n      have f y ≠ y ∧ y ≠ x, from ne_and_ne_of_swap_mul_apply_ne_self hy,\n      list.mem_of_ne_of_mem this.2 (h _ this.1),\n    have : (e.symm.trans (swap x (f x) * f)).trans e =\n      (swap (e x) (e (f x))) * (e.symm.trans f).trans e,\n      by ext; simp [← equiv.symm_trans_swap_trans, mul_def],\n    have hefx : e x ≠ e (f x), from mt e.injective.eq_iff.1 hfx,\n    rw [if_neg hfx, ← sign_aux_eq_sign_aux2 _ _ e hy, this, sign_aux_mul, sign_aux_swap hefx],\n    simp only [units.neg_neg, one_mul, units.neg_mul]}\nend\n\n/-- When the multiset `s : multiset α` contains all nonfixed points of the permutation `f : perm α`,\n  `sign_aux2 f _` recursively calculates the sign of `f`. -/\ndef sign_aux3 [fintype α] (f : perm α) {s : multiset α} : (∀ x, x ∈ s) → ℤˣ :=\nquotient.hrec_on s (λ l h, sign_aux2 l f)\n  (trunc.induction_on (fintype.trunc_equiv_fin α)\n    (λ e l₁ l₂ h, function.hfunext\n      (show (∀ x, x ∈ l₁) = ∀ x, x ∈ l₂, by simp only [h.mem_iff])\n      (λ h₁ h₂ _, by rw [← sign_aux_eq_sign_aux2 _ _ e (λ _ _, h₁ _),\n        ← sign_aux_eq_sign_aux2 _ _ e (λ _ _, h₂ _)])))\n\nlemma sign_aux3_mul_and_swap [fintype α] (f g : perm α) (s : multiset α) (hs : ∀ x, x ∈ s) :\n  sign_aux3 (f * g) hs = sign_aux3 f hs * sign_aux3 g hs ∧ ∀ x y, x ≠ y →\n  sign_aux3 (swap x y) hs = -1 :=\nlet ⟨l, hl⟩ := quotient.exists_rep s in\nlet e := equiv_fin α in\nbegin\n  clear _let_match,\n  subst hl,\n  show sign_aux2 l (f * g) = sign_aux2 l f * sign_aux2 l g ∧\n    ∀ x y, x ≠ y → sign_aux2 l (swap x y) = -1,\n  have hfg : (e.symm.trans (f * g)).trans e = (e.symm.trans f).trans e * (e.symm.trans g).trans e,\n    from equiv.ext (λ h, by simp [mul_apply]),\n  split,\n  { rw [← sign_aux_eq_sign_aux2 _ _ e (λ _ _, hs _), ← sign_aux_eq_sign_aux2 _ _ e (λ _ _, hs _),\n      ← sign_aux_eq_sign_aux2 _ _ e (λ _ _, hs _), hfg, sign_aux_mul] },\n  { assume x y hxy,\n    have hexy : e x ≠ e y, from mt e.injective.eq_iff.1 hxy,\n    rw [← sign_aux_eq_sign_aux2 _ _ e (λ _ _, hs _), symm_trans_swap_trans, sign_aux_swap hexy] }\nend\n\n/-- `sign` of a permutation returns the signature or parity of a permutation, `1` for even\npermutations, `-1` for odd permutations. It is the unique surjective group homomorphism from\n`perm α` to the group with two elements.-/\ndef sign [fintype α] : perm α →* ℤˣ := monoid_hom.mk'\n(λ f, sign_aux3 f mem_univ) (λ f g, (sign_aux3_mul_and_swap f g _ mem_univ).1)\n\nsection sign\n\nvariable [fintype α]\n\n@[simp] lemma sign_mul (f g : perm α) : sign (f * g) = sign f * sign g :=\nmonoid_hom.map_mul sign f g\n\n@[simp] lemma sign_trans (f g : perm α) : sign (f.trans g) = sign g * sign f :=\nby rw [←mul_def, sign_mul]\n\n@[simp] lemma sign_one : (sign (1 : perm α)) = 1 :=\nmonoid_hom.map_one sign\n\n@[simp] lemma sign_refl : sign (equiv.refl α) = 1 :=\nmonoid_hom.map_one sign\n\n@[simp] lemma sign_inv (f : perm α) : sign f⁻¹ = sign f :=\nby rw [monoid_hom.map_inv sign f, int.units_inv_eq_self]\n\n@[simp] lemma sign_symm (e : perm α) : sign e.symm = sign e :=\nsign_inv e\n\nlemma sign_swap {x y : α} (h : x ≠ y) : sign (swap x y) = -1 :=\n(sign_aux3_mul_and_swap 1 1 _ mem_univ).2 x y h\n\n@[simp] lemma sign_swap' {x y : α} :\n  (swap x y).sign = if x = y then 1 else -1 :=\nif H : x = y then by simp [H, swap_self] else\nby simp [sign_swap H, H]\n\nlemma is_swap.sign_eq {f : perm α} (h : f.is_swap) : sign f = -1 :=\nlet ⟨x, y, hxy⟩ := h in hxy.2.symm ▸ sign_swap hxy.1\n\n\n\n@[simp] lemma sign_symm_trans_trans [decidable_eq β] [fintype β] (f : perm α) (e : α ≃ β) :\n  sign ((e.symm.trans f).trans e) = sign f :=\nsign_aux3_symm_trans_trans f e mem_univ mem_univ\n\n@[simp] lemma sign_trans_trans_symm [decidable_eq β] [fintype β] (f : perm β) (e : α ≃ β) :\n  sign ((e.trans f).trans e.symm) = sign f :=\nsign_symm_trans_trans f e.symm\n\nlemma sign_prod_list_swap {l : list (perm α)}\n  (hl : ∀ g ∈ l, is_swap g) : sign l.prod = (-1) ^ l.length :=\nhave h₁ : l.map sign = list.repeat (-1) l.length :=\n  list.eq_repeat.2 ⟨by simp, λ u hu,\n  let ⟨g, hg⟩ := list.mem_map.1 hu in\n  hg.2 ▸ (hl _ hg.1).sign_eq⟩,\nby rw [← list.prod_repeat, ← h₁, list.prod_hom _ (@sign α _ _)]\n\nvariable (α)\n\nlemma sign_surjective [nontrivial α] : function.surjective (sign : perm α → ℤˣ) :=\nλ a, (int.units_eq_one_or a).elim\n  (λ h, ⟨1, by simp [h]⟩)\n  (λ h, let ⟨x, y, hxy⟩ := exists_pair_ne α in\n    ⟨swap x y, by rw [sign_swap hxy, h]⟩ )\n\nvariable {α}\n\nlemma eq_sign_of_surjective_hom {s : perm α →* ℤˣ} (hs : surjective s) : s = sign :=\nhave ∀ {f}, is_swap f → s f = -1 :=\n  λ f ⟨x, y, hxy, hxy'⟩, hxy'.symm ▸ by_contradiction (λ h,\n    have ∀ f, is_swap f → s f = 1 := λ f ⟨a, b, hab, hab'⟩,\n      by { rw [← is_conj_iff_eq, ← or.resolve_right (int.units_eq_one_or _) h, hab'],\n        exact s.map_is_conj (is_conj_swap hab hxy) },\n  let ⟨g, hg⟩ := hs (-1) in\n  let ⟨l, hl⟩ := (trunc_swap_factors g).out in\n  have ∀ a ∈ l.map s, a = (1 : ℤˣ) := λ a ha,\n    let ⟨g, hg⟩ := list.mem_map.1 ha in hg.2 ▸ this _ (hl.2 _ hg.1),\n  have s l.prod = 1,\n    by rw [← l.prod_hom s, list.eq_repeat'.2 this, list.prod_repeat, one_pow],\n  by { rw [hl.1, hg] at this,\n    exact absurd this dec_trivial }),\nmonoid_hom.ext $ λ f,\nlet ⟨l, hl₁, hl₂⟩ := (trunc_swap_factors f).out in\nhave hsl : ∀ a ∈ l.map s, a = (-1 : ℤˣ) := λ a ha,\n  let ⟨g, hg⟩ := list.mem_map.1 ha in hg.2 ▸  this (hl₂ _ hg.1),\nby rw [← hl₁, ← l.prod_hom s, list.eq_repeat'.2 hsl, list.length_map,\n     list.prod_repeat, sign_prod_list_swap hl₂]\n\nlemma sign_subtype_perm (f : perm α) {p : α → Prop} [decidable_pred p]\n  (h₁ : ∀ x, p x ↔ p (f x)) (h₂ : ∀ x, f x ≠ x → p x) : sign (subtype_perm f h₁) = sign f :=\nlet l := (trunc_swap_factors (subtype_perm f h₁)).out in\nhave hl' : ∀ g' ∈ l.1.map of_subtype, is_swap g' :=\n  λ g' hg',\n  let ⟨g, hg⟩ := list.mem_map.1 hg' in\n  hg.2 ▸ (l.2.2 _ hg.1).of_subtype_is_swap,\nhave hl'₂ : (l.1.map of_subtype).prod = f,\n  by rw [l.1.prod_hom of_subtype, l.2.1, of_subtype_subtype_perm _ h₂],\nby { conv { congr, rw ← l.2.1, skip, rw ← hl'₂ },\n  rw [sign_prod_list_swap l.2.2, sign_prod_list_swap hl', list.length_map] }\n\n@[simp] lemma sign_of_subtype {p : α → Prop} [decidable_pred p]\n  (f : perm (subtype p)) : sign (of_subtype f) = sign f :=\nhave ∀ x, of_subtype f x ≠ x → p x, from λ x, not_imp_comm.1 (of_subtype_apply_of_not_mem f),\nby conv {to_rhs, rw [← subtype_perm_of_subtype f, sign_subtype_perm _ _ this]}\n\nlemma sign_eq_sign_of_equiv [decidable_eq β] [fintype β] (f : perm α) (g : perm β)\n  (e : α ≃ β) (h : ∀ x, e (f x) = g (e x)) : sign f = sign g :=\nhave hg : g = (e.symm.trans f).trans e, from equiv.ext $ by simp [h],\nby rw [hg, sign_symm_trans_trans]\n\nlemma sign_bij [decidable_eq β] [fintype β]\n  {f : perm α} {g : perm β} (i : Π x : α, f x ≠ x → β)\n  (h : ∀ x hx hx', i (f x) hx' = g (i x hx))\n  (hi : ∀ x₁ x₂ hx₁ hx₂, i x₁ hx₁ = i x₂ hx₂ → x₁ = x₂)\n  (hg : ∀ y, g y ≠ y → ∃ x hx, i x hx = y) :\n  sign f = sign g :=\ncalc sign f = sign (@subtype_perm _ f (λ x, f x ≠ x) (by simp)) :\n  (sign_subtype_perm _ _ (λ _, id)).symm\n... = sign (@subtype_perm _ g (λ x, g x ≠ x) (by simp)) :\n  sign_eq_sign_of_equiv _ _\n    (equiv.of_bijective (λ x : {x // f x ≠ x},\n        (⟨i x.1 x.2, have f (f x) ≠ f x, from mt (λ h, f.injective h) x.2,\n          by { rw [← h _ x.2 this], exact mt (hi _ _ this x.2) x.2 }⟩ : {y // g y ≠ y}))\n        ⟨λ ⟨x, hx⟩ ⟨y, hy⟩ h, subtype.eq (hi _ _ _ _ (subtype.mk.inj h)),\n          λ ⟨y, hy⟩, let ⟨x, hfx, hx⟩ := hg y hy in ⟨⟨x, hfx⟩, subtype.eq hx⟩⟩)\n      (λ ⟨x, _⟩, subtype.eq (h x _ _))\n... = sign g : sign_subtype_perm _ _ (λ _, id)\n\n/-- If we apply `prod_extend_right a (σ a)` for all `a : α` in turn,\nwe get `prod_congr_right σ`. -/\nlemma prod_prod_extend_right {α : Type*} [decidable_eq α] (σ : α → perm β)\n  {l : list α} (hl : l.nodup) (mem_l : ∀ a, a ∈ l) :\n  (l.map (λ a, prod_extend_right a (σ a))).prod = prod_congr_right σ :=\nbegin\n  ext ⟨a, b⟩ : 1,\n  -- We'll use induction on the list of elements,\n  -- but we have to keep track of whether we already passed `a` in the list.\n  suffices : (a ∈ l ∧ (l.map (λ a, prod_extend_right a (σ a))).prod (a, b) = (a, σ a b)) ∨\n             (a ∉ l ∧ (l.map (λ a, prod_extend_right a (σ a))).prod (a, b) = (a, b)),\n  { obtain ⟨_, prod_eq⟩ := or.resolve_right this (not_and.mpr (λ h _, h (mem_l a))),\n    rw [prod_eq, prod_congr_right_apply] },\n  clear mem_l,\n\n  induction l with a' l ih,\n  { refine or.inr ⟨list.not_mem_nil _, _⟩,\n    rw [list.map_nil, list.prod_nil, one_apply] },\n\n  rw [list.map_cons, list.prod_cons, mul_apply],\n  rcases ih (list.nodup_cons.mp hl).2 with ⟨mem_l, prod_eq⟩ | ⟨not_mem_l, prod_eq⟩; rw prod_eq,\n  { refine or.inl ⟨list.mem_cons_of_mem _ mem_l, _⟩,\n    rw prod_extend_right_apply_ne _ (λ (h : a = a'), (list.nodup_cons.mp hl).1 (h ▸ mem_l)) },\n  by_cases ha' : a = a',\n  { rw ← ha' at *,\n    refine or.inl ⟨l.mem_cons_self a, _⟩,\n    rw prod_extend_right_apply_eq },\n  { refine or.inr ⟨λ h, not_or ha' not_mem_l ((list.mem_cons_iff _ _ _).mp h), _⟩,\n    rw prod_extend_right_apply_ne _ ha' },\nend\n\nsection congr\n\nvariables [decidable_eq β] [fintype β]\n\n@[simp] lemma sign_prod_extend_right (a : α) (σ : perm β) :\n  (prod_extend_right a σ).sign = σ.sign :=\nsign_bij (λ (ab : α × β) _, ab.snd)\n  (λ ⟨a', b⟩ hab hab', by simp [eq_of_prod_extend_right_ne hab])\n  (λ ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ hab₁ hab₂ h,\n    by simpa [eq_of_prod_extend_right_ne hab₁, eq_of_prod_extend_right_ne hab₂] using h)\n  (λ y hy, ⟨(a, y), by simpa, by simp⟩)\n\nlemma sign_prod_congr_right (σ : α → perm β) :\n  sign (prod_congr_right σ) = ∏ k, (σ k).sign :=\nbegin\n  obtain ⟨l, hl, mem_l⟩ := fintype.exists_univ_list α,\n  have l_to_finset : l.to_finset = finset.univ,\n  { apply eq_top_iff.mpr,\n    intros b _,\n    exact list.mem_to_finset.mpr (mem_l b) },\n  rw [← prod_prod_extend_right σ hl mem_l, sign.map_list_prod,\n      list.map_map, ← l_to_finset, list.prod_to_finset _ hl],\n  simp_rw ← λ a, sign_prod_extend_right a (σ a)\nend\n\nlemma sign_prod_congr_left (σ : α → perm β) :\n  sign (prod_congr_left σ) = ∏ k, (σ k).sign :=\nbegin\n  refine (sign_eq_sign_of_equiv _ _ (prod_comm β α) _).trans (sign_prod_congr_right σ),\n  rintro ⟨b, α⟩,\n  refl\nend\n\n@[simp] lemma sign_perm_congr (e : α ≃ β) (p : perm α) :\n  (e.perm_congr p).sign = p.sign :=\nsign_eq_sign_of_equiv _ _ e.symm (by simp)\n\n@[simp] lemma sign_sum_congr (σa : perm α) (σb : perm β) :\n  (sum_congr σa σb).sign = σa.sign * σb.sign :=\nbegin\n  suffices : (sum_congr σa (1 : perm β)).sign = σa.sign ∧\n             (sum_congr (1 : perm α) σb).sign = σb.sign,\n  { rw [←this.1, ←this.2, ←sign_mul, sum_congr_mul, one_mul, mul_one], },\n  split,\n  { apply σa.swap_induction_on _ (λ σa' a₁ a₂ ha ih, _),\n    { simp },\n    { rw [←one_mul (1 : perm β), ←sum_congr_mul, sign_mul, sign_mul, ih, sum_congr_swap_one,\n          sign_swap ha, sign_swap (sum.inl_injective.ne_iff.mpr ha)], }, },\n  { apply σb.swap_induction_on _ (λ σb' b₁ b₂ hb ih, _),\n    { simp },\n    { rw [←one_mul (1 : perm α), ←sum_congr_mul, sign_mul, sign_mul, ih, sum_congr_one_swap,\n          sign_swap hb, sign_swap (sum.inr_injective.ne_iff.mpr hb)], }, }\nend\n\n@[simp] lemma sign_subtype_congr {p : α → Prop} [decidable_pred p]\n  (ep : perm {a // p a}) (en : perm {a // ¬ p a}) :\n  (ep.subtype_congr en).sign = ep.sign * en.sign :=\nby simp [subtype_congr]\n\n@[simp] lemma sign_extend_domain (e : perm α)\n  {p : β → Prop} [decidable_pred p] (f : α ≃ subtype p) :\n  equiv.perm.sign (e.extend_domain f) = equiv.perm.sign e :=\nby simp [equiv.perm.extend_domain]\n\nend congr\n\nend sign\n\nend equiv.perm\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/group_theory/perm/sign.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.48065360440394095}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.lie.nilpotent\n\n/-!\n# Cartan subalgebras\n\nCartan subalgebras are one of the most important concepts in Lie theory. We define them here.\nThe standard example is the set of diagonal matrices in the Lie algebra of matrices.\n\n## Main definitions\n\n  * `lie_subalgebra.normalizer`\n  * `lie_subalgebra.le_normalizer_of_ideal`\n  * `lie_subalgebra.is_cartan_subalgebra`\n\n## Tags\n\nlie subalgebra, normalizer, idealizer, cartan subalgebra\n-/\n\nuniverses u v w w₁ w₂\n\nvariables {R : Type u} {L : Type v}\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L] (H : lie_subalgebra R L)\n\nnamespace lie_subalgebra\n\n/-- The normalizer of a Lie subalgebra `H` is the set of elements of the Lie algebra whose bracket\nwith any element of `H` lies in `H`. It is the Lie algebra equivalent of the group-theoretic\nnormalizer (see `subgroup.normalizer`) and is an idealizer in the sense of abstract algebra. -/\ndef normalizer : lie_subalgebra R L :=\n{ carrier   := { x : L | ∀ (y : L), (y ∈ H) → ⁅x, y⁆ ∈ H },\n  zero_mem' := λ y hy, by { rw zero_lie y, exact H.zero_mem, },\n  add_mem'  := λ z₁ z₂ h₁ h₂ y hy, by { rw add_lie, exact H.add_mem (h₁ y hy) (h₂ y hy), },\n  smul_mem' := λ t y hy z hz, by { rw smul_lie, exact H.smul_mem t (hy z hz), },\n  lie_mem'  := λ z₁ z₂ h₁ h₂ y hy, by\n    { rw lie_lie, exact H.sub_mem (h₁ _ (h₂ y hy)) (h₂ _ (h₁ y hy)), }, }\n\nlemma mem_normalizer_iff (x : L) : x ∈ H.normalizer ↔ ∀ (y : L), (y ∈ H) → ⁅x, y⁆ ∈ H := iff.rfl\n\nlemma mem_normalizer_iff' (x : L) : x ∈ H.normalizer ↔ ∀ (y : L), (y ∈ H) → ⁅y, x⁆ ∈ H :=\nforall₂_congr $ λ y hy, by rw [← lie_skew, H.neg_mem_iff]\n\nlemma le_normalizer : H ≤ H.normalizer :=\nλ x hx, show ∀ (y : L), y ∈ H → ⁅x,y⁆ ∈ H, from λ y, H.lie_mem hx\n\nvariables {H}\n\nlemma lie_mem_sup_of_mem_normalizer {x y z : L} (hx : x ∈ H.normalizer)\n  (hy : y ∈ (R ∙ x) ⊔ ↑H) (hz : z ∈ (R ∙ x) ⊔ ↑H) : ⁅y, z⁆ ∈ (R ∙ x) ⊔ ↑H :=\nbegin\n  rw submodule.mem_sup at hy hz,\n  obtain ⟨u₁, hu₁, v, hv : v ∈ H, rfl⟩ := hy,\n  obtain ⟨u₂, hu₂, w, hw : w ∈ H, rfl⟩ := hz,\n  obtain ⟨t, rfl⟩ := submodule.mem_span_singleton.mp hu₁,\n  obtain ⟨s, rfl⟩ := submodule.mem_span_singleton.mp hu₂,\n  apply submodule.mem_sup_right,\n  simp only [lie_subalgebra.mem_coe_submodule, smul_lie, add_lie, zero_add, lie_add, smul_zero,\n    lie_smul, lie_self],\n  refine H.add_mem (H.smul_mem s _) (H.add_mem (H.smul_mem t _) (H.lie_mem hv hw)),\n  exacts [(H.mem_normalizer_iff' x).mp hx v hv, (H.mem_normalizer_iff x).mp hx w hw],\nend\n\n/-- A Lie subalgebra is an ideal of its normalizer. -/\nlemma ideal_in_normalizer : ∀ {x y : L}, x ∈ H.normalizer → y ∈ H → ⁅x,y⁆ ∈ H :=\nλ x y h, h y\n\n/-- A Lie subalgebra `H` is an ideal of any Lie subalgebra `K` containing `H` and contained in the\nnormalizer of `H`. -/\nlemma exists_nested_lie_ideal_of_le_normalizer\n  {K : lie_subalgebra R L} (h₁ : H ≤ K) (h₂ : K ≤ H.normalizer) :\n  ∃ (I : lie_ideal R K), (I : lie_subalgebra R K) = of_le h₁ :=\nbegin\n  rw exists_nested_lie_ideal_coe_eq_iff,\n  exact λ x y hx hy, ideal_in_normalizer (h₂ hx) hy,\nend\n\n/-- The normalizer of a Lie subalgebra `H` is the maximal Lie subalgebra in which `H` is a Lie\nideal. -/\nlemma le_normalizer_of_ideal {N : lie_subalgebra R L}\n  (h : ∀ (x y : L), x ∈ N → y ∈ H → ⁅x,y⁆ ∈ H) : N ≤ H.normalizer :=\nλ x hx y, h x y hx\n\nvariables (H)\n\nlemma normalizer_eq_self_iff :\n  H.normalizer = H ↔ (lie_module.max_triv_submodule R H $ L ⧸ H.to_lie_submodule) = ⊥ :=\nbegin\n  rw lie_submodule.eq_bot_iff,\n  refine ⟨λ h, _, λ h, le_antisymm (λ x hx, _) H.le_normalizer⟩,\n  { rintros ⟨x⟩ hx,\n    suffices : x ∈ H, by simpa,\n    rw [← h, H.mem_normalizer_iff'],\n    intros y hy,\n    replace hx : ⁅_, lie_submodule.quotient.mk' _ x⁆ = 0 := hx ⟨y, hy⟩,\n    rwa [← lie_module_hom.map_lie, lie_submodule.quotient.mk_eq_zero] at hx, },\n  { let y := lie_submodule.quotient.mk' H.to_lie_submodule x,\n    have hy : y ∈ lie_module.max_triv_submodule R H (L ⧸ H.to_lie_submodule),\n    { rintros ⟨z, hz⟩,\n      rw [← lie_module_hom.map_lie, lie_submodule.quotient.mk_eq_zero, coe_bracket_of_module,\n        submodule.coe_mk, mem_to_lie_submodule],\n      exact (H.mem_normalizer_iff' x).mp hx z hz, },\n    simpa using h y hy, },\nend\n\n/-- A Cartan subalgebra is a nilpotent, self-normalizing subalgebra. -/\nclass is_cartan_subalgebra : Prop :=\n(nilpotent        : lie_algebra.is_nilpotent R H)\n(self_normalizing : H.normalizer = H)\n\nend lie_subalgebra\n\n@[simp] lemma lie_ideal.normalizer_eq_top {R : Type u} {L : Type v}\n  [comm_ring R] [lie_ring L] [lie_algebra R L] (I : lie_ideal R L) :\n  (I : lie_subalgebra R L).normalizer = ⊤ :=\nbegin\n  ext x,\n  simpa only [lie_subalgebra.mem_normalizer_iff, lie_subalgebra.mem_top, iff_true]\n    using λ y hy, I.lie_mem hy\nend\n\nopen lie_ideal\n\n/-- A nilpotent Lie algebra is its own Cartan subalgebra. -/\ninstance lie_algebra.top_is_cartan_subalgebra_of_nilpotent [lie_algebra.is_nilpotent R L] :\n  lie_subalgebra.is_cartan_subalgebra (⊤ : lie_subalgebra R L) :=\n{ nilpotent        := infer_instance,\n  self_normalizing :=\n    by { rw [← top_coe_lie_subalgebra, normalizer_eq_top, top_coe_lie_subalgebra], }, }\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/lie/cartan_subalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4806535996607852}}
{"text": "import fundamental_groupoid_product\n\nnoncomputable theory\n\nvariables {X : Type*} {Y : Type*} [topological_space X] [topological_space Y] {f g : C(X, Y)}\n          (H : continuous_map.homotopy f g)\n\nnamespace continuous_map.homotopy\n\ndef to_path (x : X) : path (f x) (g x) :=\n{ to_fun := λ t, H (t, x),\n  source' := by simp only [continuous_map.homotopy.apply_zero],\n  target' := by simp only [continuous_map.homotopy.apply_one], }\n\nend continuous_map.homotopy\n\nopen_locale unit_interval\n\nnamespace path.homotopic\n\nlocal attribute [instance] path.homotopic.setoid\n\nsection cast\n\nvariables {x₀ x₁ x₂ x₃ : X}\n\nprotected def cast (p₀ : x₀ = x₁) (p₁ : x₂ = x₃) (P : path.homotopic.quotient x₁ x₃) : \n  (path.homotopic.quotient x₀ x₂) := by rwa [p₀, p₁]\n\n@[simp] lemma cast_of_eq (P : path.homotopic.quotient x₀ x₁) : path.homotopic.cast rfl rfl P = P := rfl \n\nlemma cast_lift (p₀ : x₀ = x₁) (p₁ : x₂ = x₃) (P₀ : path x₁ x₃) : ⟦P₀.cast p₀ p₁⟧ = path.homotopic.cast p₀ p₁ ⟦P₀⟧ := \nby { subst_vars, rw cast_of_eq, congr, ext, rw path.cast_coe, }\n\nlemma path_heq_cast (p₀ : x₀ = x₁) (p₁ : x₂ = x₃) (P : path x₁ x₃) : P.cast p₀ p₁ == P :=\nby { subst_vars, rw heq_iff_eq, ext, rw path.cast_coe, }\n\nlemma path.homotopic.heq_cast (p₀ : x₀ = x₁) (p₁ : x₂ = x₃) (P : path.homotopic.quotient x₁ x₃) : \npath.homotopic.cast p₀ p₁ P == P := by { subst_vars, refl, }\n\nend cast\n\nvariables (x₀ x₁ : X) (p : path.homotopic.quotient x₀ x₁)\n\ndef straight_path : path (0 : I) (1 : I) := { to_fun := id, source' := rfl, target' := rfl }\n\ndef diagonal_path : path.homotopic.quotient (H (0, x₀)) (H (1, x₁)) :=\n(path.homotopic.prod ⟦straight_path⟧ p).map_fn H.to_continuous_map\n\ndef diagonal_path' : path.homotopic.quotient (f x₀) (g x₁) :=  \npath.homotopic.cast (H.apply_zero x₀).symm (H.apply_one x₁).symm (diagonal_path H x₀ x₁ p)\n\nlemma up_is_f : (p.map_fn f) = path.homotopic.cast (H.apply_zero x₀).symm (H.apply_zero x₁).symm ((path.homotopic.prod ⟦path.refl (0 : I)⟧ p).map_fn H.to_continuous_map) :=\nbegin\n  apply quotient.induction_on p,\n  intro p',\n  rw [path.homotopic.prod_lift, ← path.homotopic.map_lift, ← path.homotopic.map_lift, ← cast_lift],\n  congr, ext, simp,\nend\n\nlemma down_is_g : p.map_fn g = path.homotopic.cast (H.apply_one x₀).symm (H.apply_one x₁).symm ((path.homotopic.prod ⟦path.refl (1 : I)⟧ p).map_fn H.to_continuous_map) :=\nbegin\n  apply quotient.induction_on p,\n  intro p',\n  rw [path.homotopic.prod_lift, ← path.homotopic.map_lift, ← path.homotopic.map_lift, ← cast_lift],\n  congr, ext, simp,\nend\n\nlemma H_to_path (x : X) : ⟦H.to_path x⟧ =\n  path.homotopic.cast (H.apply_zero x).symm (H.apply_one x).symm ((path.homotopic.prod ⟦straight_path⟧ ⟦path.refl x⟧).map_fn H.to_continuous_map) :=\nby { rw [prod_lift, ← map_lift, ← cast_lift], refl, }\n\nlemma up_right_is_diag : (p.map_fn f).comp ⟦H.to_path x₁⟧ = diagonal_path' H x₀ x₁ p :=\nbegin\n  rw up_is_f H x₀ x₁ p,\n  sorry,\nend \n\nend path.homotopic", "meta": {"author": "prakol16", "repo": "lean-fundamental-groupoid", "sha": "cf1b62f2c89d476fee80699f836694370f3c560c", "save_path": "github-repos/lean/prakol16-lean-fundamental-groupoid", "path": "github-repos/lean/prakol16-lean-fundamental-groupoid/lean-fundamental-groupoid-cf1b62f2c89d476fee80699f836694370f3c560c/src/fun_groupoid_preserves_homotopic_2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4805232553900527}}
{"text": "import Saturn.Prover\nimport Saturn.FinSeq\nimport Saturn.Vector\nimport Saturn.Clause \nimport Saturn.Containment\nimport Saturn.Solverstep\nimport Saturn.Resolution\nimport Saturn.PosRestClause\nimport Saturn.PrependClause\nimport Saturn.SatSolution\nimport Saturn.LiftSolution\nopen Nat\nopen FinSeq\n\n/-\nThe DPLL algorithm with proofs. Here we implement:\n  - restricting to a branch.\n  - the simple cases of having contradictions or no clauses.\n  - the base case: length one clauses in our implementation\n  - lifting of proofs from branches and combining them if necessary\n-/\n\ninstance {n: Nat} : DecidableEq (Clause n) := \n  fun c1 c2 =>\n  match decEq c1.coords c2.coords with\n  | isTrue pf => isTrue (coords_eq_implies_vec_eq pf)\n  | isFalse contra => isFalse (\n      fun hyp =>\n        contra (congrArg Vector.coords hyp)\n  )\n\n/-\nWe map to branches inductively. The main work is done earlier.\n-/\ndef prependResData{dom n: Nat}(branch: Bool)(focus: Nat)(focusLt : focus < n + 1)\n    (clauses: Vector (Clause (n + 1)) dom): \n        (rd : ReductionData branch focus focusLt clauses) → \n           (head : Clause (n + 1)) → \n        ReductionData branch focus focusLt (head +: clauses) := \n        fun rd  head => \n          if c : head.coords focus focusLt = some branch then\n            PosResClause.prependResData branch focus focusLt clauses head c rd\n          else\n            PrependClause.prependResData branch focus focusLt clauses head c rd\n\ndef restrictionDataAux{domHead domAccum dom n: Nat}(branch: Bool)\n    (focus: Nat)(focusLt : focus < n + 1):\n    (clausesHead: Vector (Clause (n + 1)) domHead) → \n    (clausesAccum: Vector (Clause (n + 1)) domAccum) → \n    (s : domHead + domAccum = dom) → \n    (restAcum : ReductionData branch focus focusLt clausesAccum) → \n    (clauses: Vector (Clause (n + 1)) dom) →\n    (clsEq : concatSeqAux s clausesHead.coords clausesAccum.coords = clauses.coords) →    \n        ReductionData branch focus focusLt clauses := \n    match domHead with\n    | zero =>  \n      by\n        intro clausesHead clausesAccum s restAccum clauses clsEq\n        have ss : dom = domAccum := by \n          rw [← s]\n          apply Nat.zero_add\n          done\n        have sf : FinSeq dom (Clause (n + 1))  = FinSeq domAccum (Clause (n + 1)):= by\n          rw [ss]\n        have clSeq : clauses = clauses.coords.vec := by \n          apply coords_eq_implies_vec_eq\n          rw [seq_to_vec_coords]\n        have resolve : concatSeqAux s clausesHead.coords clausesAccum.coords = \n            Eq.mpr sf clausesAccum.coords := by rfl        \n        rw [clSeq]\n        rw [← clsEq]\n        rw [resolve] \n        match dom , domAccum, ss, sf, clausesAccum, restAccum with\n        | d, .(d), rfl, rfl, cls,  ra => \n          have sm : FinSeq.vec (cls.coords) = cls := by \n            apply coords_eq_implies_vec_eq\n            rw [seq_to_vec_coords]\n          rw [← sm] at ra\n          exact ra\n    | k + 1 => fun clausesHead clausesAccum s restAccum clauses clsEq => \n      let ss : k + (domAccum + 1)  = dom := \n        by\n          rw [← s]\n          rw [(Nat.add_comm domAccum 1)]\n          rw [(Nat.add_assoc k 1 domAccum)]\n          done\n      let resolve : concatSeqAux s clausesHead.coords clausesAccum.coords = \n        concatSeqAux ss (clausesHead.coords.init) ((clausesHead.coords.last) +| clausesAccum.coords) := rfl\n      let recRestAccum := \n        prependResData branch focus focusLt clausesAccum restAccum (last clausesHead.coords)\n      restrictionDataAux branch focus focusLt (FinSeq.vec (init clausesHead.coords)) \n          ((last clausesHead.coords) +: clausesAccum) ss recRestAccum clauses \n          (by \n            have sm : (FinSeq.vec (init clausesHead.coords)).coords =\n                init (clausesHead.coords) := by rw [seq_to_vec_coords]\n            rw [sm,\n               (cons_commutes (last (clausesHead.coords)) clausesAccum),\n               ← resolve,\n               clsEq]\n            done)\n    \n\ndef restrictionData{dom n: Nat}(branch: Bool)(focus: Nat)(focusLt : focus < n + 1):\n    (clauses: Vector (Clause (n + 1)) dom) →   \n        ReductionData branch focus focusLt clauses := \n        fun clauses =>\n          let rc : ReductionClauses branch focus focusLt Vector.nil := \n              ⟨0, Vector.nil, Vector.nil,\n                fun k w => nomatch w, \n                Vector.nil, fun k w => nomatch w⟩\n          let rd : ReductionData branch focus focusLt Vector.nil := ⟨rc,\n            ⟨fun k w => nomatch w⟩,\n            ⟨fun k w => nomatch w⟩,\n            ⟨fun k w => nomatch w⟩, \n            ⟨(by\n                intro k kw\n                have eq0 : rc.codom = 0 := by rfl\n                rw [eq0] at kw\n                have contra := not_lt_zero _ kw\n                exact False.elim contra\n            )⟩⟩\n          restrictionDataAux branch focus focusLt clauses Vector.nil \n              (Nat.add_zero dom) rd clauses (concat_empty_seq_id clauses.coords)\n\n/-\nThe simple cases: having a contradiction or having no clauses.\n-/\n\ndef contraSol{n dom: Nat}{clauses : Vector (Clause (n + 1)) dom}{j : Nat}{jw : j < dom}\n                (eqn : clauses.coords j jw = contradiction (n + 1)): SatSolution clauses :=\n                  SatSolution.unsat (ResolutionTree.assumption j jw _ eqn) \n                \ndef emptySol{n: Nat}(clauses : Vector (Clause (n + 1)) zero) : SatSolution clauses :=\n        SatSolution.sat (FinSeq.vec (fun k kw => true))  (fun k kw => nomatch kw)\n\n/-\nSolution for length one clauses\n-/\ndef lengthOneEqual{cl1 cl2 : Clause 1}(eql : cl1.coords zero (zero_lt_succ zero) = cl2.coords zero (zero_lt_succ zero)) : \n                          cl1 = cl2 :=\n                            coords_eq_implies_vec_eq \n                            (funext (fun j =>\n                                    match j with\n                                    | zero => funext (fun jw => eql)\n                                    | i + 1 => funext (fun jw => nomatch jw)\n                                    ))\n\ndef lengthOneUnit{cl: Clause 1}{b : Bool}(eql : cl.coords zero (zero_lt_succ zero) = some b):\n                                cl = unitClause zero b zero (zero_lt_succ zero) := \n                                let lem1 :  \n                                  (unitClause zero b zero (zero_lt_succ zero)).coords zero (zero_lt_succ zero) = \n                                    some b :=\n                                          by\n                                            apply unitDiag\n                                let lem2 : cl.coords zero (zero_lt_succ zero) = \n                                    (unitClause zero b zero (zero_lt_succ zero)).coords \n                                      zero (zero_lt_succ zero) \n                                      := \n                                          by\n                                            rw [eql]\n                                            exact Eq.symm lem1\n                                            done  \n                                lengthOneEqual lem2\n\ndef lengthOneContra{cl: Clause 1}(eql : cl.coords zero (zero_lt_succ zero) = none):\n                              cl = contradiction 1 := lengthOneEqual eql\n\ndef lengthOneSolution{dom : Nat}: (clauses : Vector (Clause 1) dom) →  SatSolution clauses :=\n    match dom with\n    | zero => fun cls => emptySol cls\n    | l + 1 =>\n      fun cls =>\n      match searchElem cls.coords (contradiction 1) with\n      | ExistsElem.exsts index bound eqn => contraSol eqn\n      | ExistsElem.notExst noContra =>\n        let head := cls.coords (zero) (zero_lt_succ l) \n        if c : head.coords zero (zero_lt_succ zero) = none then   \n          let eqn := lengthOneContra c     \n          contraSol eqn\n        else \n          if ct : head.coords zero (zero_lt_succ zero) = some true then\n              match searchElem cls.coords (unitClause zero false zero (zero_lt_succ zero)) with\n              | ExistsElem.exsts index bound eqn => \n                  let treePf2 := unitProof eqn \n                  let treePf1 : \n                    ResolutionTree cls (unitClause zero true zero (zero_lt_succ zero)) :=\n                    ResolutionTree.assumption zero (zero_lt_succ l) _ (lengthOneUnit ct)\n                  let tree := mergeAlignUnitTrees treePf1 treePf2\n                  SatSolution.unsat tree\n              | ExistsElem.notExst noNeg => \n                 SatSolution.sat (FinSeq.vec (fun _ _ => true)) \n                    fun k kw =>\n                      let lem1 : Not ((cls.coords k kw).coords zero (zero_lt_succ zero) = some false) :=\n                        fun hyp => noNeg k kw (lengthOneUnit hyp)\n                      let lem2 : Not ((cls.coords k kw).coords zero (zero_lt_succ zero) = none) :=\n                        fun hyp => noContra k kw (lengthOneContra hyp)\n                      let lem : (cls.coords k kw).coords zero (zero_lt_succ zero) = some true :=\n                        match (cls.coords k kw).coords zero (zero_lt_succ zero), lem1, lem2 with\n                        | some true, l1, l2 => rfl\n                        | some false, l1, l2 => absurd (l1 rfl) id\n                        | none, l1, l2 => absurd (l2 rfl) id \n                      ⟨zero, zero_lt_succ _, lem⟩                      \n          else \n            if cf : head.coords zero (zero_lt_succ zero) = some false then\n              match searchElem cls.coords (unitClause zero true zero (zero_lt_succ zero)) with\n              | ExistsElem.exsts index bound eqn => \n                  let treePf2 := unitProof eqn \n                  let treePf1 : \n                    ResolutionTree cls (unitClause zero false zero (zero_lt_succ zero)) :=\n                    ResolutionTree.assumption zero (zero_lt_succ l) _ (lengthOneUnit cf)\n                  let tree := mergeAlignUnitTrees treePf1 treePf2\n                  SatSolution.unsat tree\n              | ExistsElem.notExst noNeg => \n                 SatSolution.sat (FinSeq.vec (fun _ _ => false)) \n                    fun k kw =>\n                      let lem1 : Not ((cls.coords k kw).coords zero (zero_lt_succ zero) = some true) :=\n                        fun hyp => noNeg k kw (lengthOneUnit hyp)\n                      let lem2 : Not ((cls.coords k kw).coords zero (zero_lt_succ zero) = none) :=\n                        fun hyp => noContra k kw (lengthOneContra hyp)\n                      let lem : (cls.coords k kw).coords zero (zero_lt_succ zero) = some false :=\n                        match (cls.coords k kw).coords zero (zero_lt_succ zero), lem1, lem2 with\n                        | some false, l1, l2 => rfl\n                        | some true, l1, l2 => False.elim (l1 rfl) \n                        | none, l1, l2 => False.elim (l2 rfl)  \n                      ⟨zero, zero_lt_succ _, lem⟩\n            else \n                match head.coords zero (zero_lt_succ zero), c, ct, cf with\n                | some true, l1, l2, l3 => False.elim (l2 rfl)\n                | some false, l1, l2, l3 => False.elim (l3 rfl)\n                | none, l1, l2, l3 => False.elim (l1 rfl)\n\n-- a helper\ntheorem notpure_cases(b: Bool): (x : Option Bool) → x = none ∨  x = some b  → \n        Not (x = some (not b)) :=\n  fun x eqn  =>\n     match b, eqn  with\n     | true, Or.inr pf => \n            fun hyp =>\n              let lem1 : some true = some false := by\n                rw [← pf]\n                rw [hyp]\n                rfl\n                done\n              let lem2 : true = false := by \n                  injection lem1\n                  assumption\n              Bool.noConfusion lem2\n     | false, Or.inr pf => \n              fun hyp =>\n              let lem1 : some true = some false := by\n                rw [← pf]\n                rw [hyp]\n                rfl\n                done\n              let lem2 : true = false := by \n                  injection lem1\n                  assumption\n              Bool.noConfusion lem2\n     | _ , Or.inl pf => fun hyp =>\n        let w := Eq.trans (Eq.symm pf) hyp\n        Option.noConfusion w\n\n/-\nLifting under containment and from branches and putting together lifts\n-/\ndef containmentLift{dom n: Nat}(clauses : Vector (Clause (n + 1)) dom)\n    (cntn : Containment clauses):\n          SatSolution (cntn.imageSeq) → SatSolution clauses := \n          fun sol =>\n          match sol with\n          | SatSolution.sat val pf => \n              SatSolution.sat val (\n                fun k kw => \n                        let ⟨ind, bd, w⟩ := cntn.forward k kw\n                        let ev := pf ind bd\n                        let lem := containsSat (clauses.coords k kw) (cntn.imageSeq.coords ind bd) w val\n                        lem ev)\n              \n          | SatSolution.unsat tree => \n                let tree := \n                  transportResTree cntn.imageSeq clauses cntn.reverse (contradiction (n + 1))\n                    tree \n                SatSolution.unsat tree \n\n\ndef solveSAT{n dom : Nat}: (clauses : Vector (Clause (n + 1)) dom) →  SatSolution clauses :=\n      match n with\n      | zero => fun clauses => lengthOneSolution clauses\n      | m + 1 =>\n        fun clauses =>\n        let posCount  := clauses.map (parityCount true)\n        let negCount  := clauses.map (parityCount false)\n        match findElem? clauses.coords (contradiction (m + 2)) with\n        | some z => contraSol z.equation \n        | none =>     \n          let cntn := simplifiedContainment clauses posCount negCount\n          let cls := cntn.imageSeq\n          let posCount  := cls.map (parityCount true)\n          let negCount  := cls.map (parityCount false)\n          let solution : SatSolution cls :=\n              match someUnitClause cls.coords posCount negCount with\n              | some ⟨i, iw, index, bd, par, eql⟩ => \n                  let rd := restrictionData par index bd cls\n                  let subCls := rd.restrictionClauses.restClauses\n                  let subSol := solveSAT subCls\n                  match subSol with\n                  | SatSolution.sat valuation pf => \n                    let pb :=  pullBackSolution par index bd cls \n                        rd.restrictionClauses rd.droppedProof rd.forwardRelation valuation pf\n                    let valuationN := insert par _ index bd valuation.coords\n                    SatSolution.sat valuationN.vec pb\n                  | SatSolution.unsat tree  => \n                      let liftedProof :=\n                        pullBackResTree  par index bd cls \n                            rd.restrictionClauses rd.nonPosReverse rd.reverseRelation \n                            tree\n                      match liftedProof with\n                      | LiftedResTree.contra pf => \n                          SatSolution.unsat pf\n                      | LiftedResTree.unit tree => \n                          let tree1 := unitProof eql\n                          let merged := mergeAlignUnitTrees tree1 tree\n                          SatSolution.unsat merged \n              | none => \n                match hasPure cls with \n                | some ⟨index, bd, par, evid⟩=> \n                  let rd := restrictionData par index bd cls\n                  let subCls := rd.restrictionClauses.restClauses\n                  let subSol := solveSAT subCls\n                  match subSol with\n                  | SatSolution.sat valuation pf => \n                    let pb :=  pullBackSolution par index bd cls \n                        rd.restrictionClauses rd.droppedProof rd.forwardRelation valuation pf\n                    let valuationN := insert par _ index bd valuation.coords\n                    SatSolution.sat valuationN.vec pb\n                  | SatSolution.unsat tree => \n                      let liftedProof :=\n                        pullBackResTree  par index bd cls \n                            rd.restrictionClauses rd.nonPosReverse rd.reverseRelation \n                            tree\n                      match liftedProof with\n                      | LiftedResTree.contra pf => \n                          SatSolution.unsat pf\n                      | LiftedResTree.unit tree => \n                          let base : (j : Nat) → (lt : j < cntn.codom) → \n                              Not ((cls.coords j lt).coords index bd = some (not par)) := \n                                fun j jw => \n                                  notpure_cases par ((cls.coords j jw).coords index bd) (evid j jw)\n                          let pure :=\n                            trees_preserve_notsomebranch (not par) index bd base\n                                   (unitClause (m + 1) (!par) index bd)\n                                   tree\n                          let impure := unitDiag (m + 1) (not par) index bd \n                          absurd impure pure\n                | none =>  \n                  let index := zero\n                  let bd := zero_lt_succ (m + 1)\n                  let rd : ReductionData false zero bd cls := \n                      restrictionData false index bd cls\n                  let subCls := rd.restrictionClauses.restClauses\n                  let subSol: SatSolution subCls := solveSAT subCls\n                  match subSol with\n                  | SatSolution.sat valuation pf => \n                    let pb :=  pullBackSolution false index bd cls \n                        rd.restrictionClauses rd.droppedProof rd.forwardRelation valuation pf\n                    let valuationN := insert false _ index bd valuation.coords\n                    SatSolution.sat valuationN.vec pb\n                  | SatSolution.unsat tree => \n                      let liftedProof : LiftedResTree false zero bd cls :=\n                        pullBackResTree  false index bd cls \n                            rd.restrictionClauses rd.nonPosReverse rd.reverseRelation \n                            tree\n                      match liftedProof with\n                      | LiftedResTree.contra pf => \n                          SatSolution.unsat pf\n                      | LiftedResTree.unit tree1 => \n                          let rd : ReductionData true zero bd cls \n                              := restrictionData true index bd cls\n                          let subCls := rd.restrictionClauses.restClauses\n                          let subSol := solveSAT subCls\n                          match subSol with\n                          | SatSolution.sat valuation pf => \n                            let pb :=  pullBackSolution true index bd cls \n                                rd.restrictionClauses rd.droppedProof rd.forwardRelation valuation pf\n                            let valuationN := insert true _ index bd valuation.coords\n                            SatSolution.sat valuationN.vec pb\n                          | SatSolution.unsat tree  => \n                              let liftedProof :=\n                                pullBackResTree  true index bd cls \n                                    rd.restrictionClauses rd.nonPosReverse rd.reverseRelation \n                                    tree\n                              match liftedProof with\n                              | LiftedResTree.contra pf => \n                                  SatSolution.unsat pf\n                              | LiftedResTree.unit tree2 => \n                                  let merged := mergeUnitTrees index bd tree2 tree1\n                                  SatSolution.unsat merged\n        containmentLift clauses cntn solution\n\n/-\nDecidability and convenience functions.\n-/\ninstance {dom n: Nat}{clauses : Vector (Clause (n + 1)) dom}\n                 : Prover (SatSolution clauses) where\n      statement := fun sol => solutionProp sol \n      proof := fun sol => solutionProof sol\n\ndef proveOrDisprove{n dom : Nat}(clauses : Vector (Clause (n + 1)) dom) :=\n            getProof (solveSAT clauses)\n\ninstance {n dom : Nat}{clauses : Vector (Clause (n + 1)) dom} :\n    Decidable (isSat clauses) := \n    match solveSAT clauses with\n      | SatSolution.sat valuation evidence =>\n          isTrue ⟨valuation, evidence⟩\n      | SatSolution.unsat tree => isFalse $ fun hyp => \n            not_sat_and_unsat clauses hyp $ tree_unsat clauses tree\n\ninstance {n dom : Nat}{clauses : Vector (Clause (n + 1)) dom} :\n    Decidable (isUnSat clauses) := \n    match solveSAT clauses with\n      | SatSolution.sat valuation evidence => isFalse $ fun hyp => \n        not_sat_and_unsat clauses ⟨valuation, evidence⟩ hyp    \n      | SatSolution.unsat tree =>\n        isTrue $ tree_unsat clauses tree\n", "meta": {"author": "siddhartha-gadgil", "repo": "Saturn", "sha": "4e451333411dc0f381ade5aa4569e1acfea5be0b", "save_path": "github-repos/lean/siddhartha-gadgil-Saturn", "path": "github-repos/lean/siddhartha-gadgil-Saturn/Saturn-4e451333411dc0f381ade5aa4569e1acfea5be0b/Saturn/DPLL.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.6224593382055109, "lm_q1q2_score": 0.48044119939674673}}
{"text": "import data.hash_map .atom\n\nnamespace nominal\nopen list\n\ninductive exp : Type\n| var : atom → exp\n| const : ℕ → exp\n| abs : atom → exp → exp\n| app : exp → exp → exp\n\nopen exp\n\ndef fvs : exp → list atom\n| (var v)     := [v]\n| (const n)   := []\n| (abs v e)   := remove_all (fvs e) [v]\n| (app e₁ e₂) := fvs e₁ ∪ fvs e₂\n\ndef swap_var (x y z : atom) : atom :=\n  if z = x then y else if z = y then x else z.\n\ndef swap (x y : atom) : exp → exp\n| (var z)     := var (swap_var x y z)\n| (const n)   := const n\n| (abs z e)   := abs (swap_var x y z) (swap e)\n| (app e₁ e₂) := app (swap e₁) (swap e₂)\n\n@[reducible] def heap := hash_map atom (λ x, exp)\nstructure frame := (val : exp)\ndef stack := list frame\n\nstructure config := (hp : heap) (t : exp) (stk : stack)\n\ninductive step (α : Type) : Type\n| error {}  : step\n| done  {}  : exp → step\n| take      : α → step\n\ndef machine_step (avoid : list atom) : config → step config\n| ⟨hp, abs x e, []⟩ := step.done (abs x e)\n\n| ⟨hp, abs x e, (⟨val⟩ :: stk)⟩ :=\n if x ∈ hp ∨ x ∈ avoid\n then let y := atom.fresh (hp^.keys ∪ avoid) in step.take ⟨hp^.insert y val, swap x y e, stk⟩\n else step.take ⟨hp^.insert x val, e, stk⟩\n\n| ⟨hp, var x, stk⟩ := match hp^.find x with\n                     | some e := step.take ⟨hp, e, stk⟩\n                     | none   := step.error\n                     end\n\n| ⟨hp, app f a, stk⟩ := step.take ⟨hp, f, ⟨a⟩ :: stk⟩\n\n\n| ⟨hp, const n, stk⟩ := step.done (const n)\n\ndef init_config (t : exp) : config := ⟨mk_hash_map (λ a : atom, a^.id), t, []⟩\n\ndef is_val : exp → Prop\n| (abs _ _) := true\n| _         := false\n\nlemma values_are_done (avoid : list atom) : ∀ (t : exp), is_val t → machine_step avoid (init_config t) = step.done t\n| (abs x e) _ := rfl\n| (const n) _ := rfl\n| (var v) H_contra := false.rec _ H_contra\n| (app f a) H_contra := false.rec _ H_contra\n\ndef size : exp → ℕ\n| (var x) := 1\n| (const n) := 1\n| (abs x e) := 1 + size e\n| (app f a) := 1 + size f + size a\n\nlemma swap_size_eq (x y : atom) : ∀ t, size (swap x y t) = size t :=\nbegin\nintro t,\ninduction t,\nreflexivity,\nall_goals { simp [swap, size], try { cc } }\nend\n\n/-\ninductive exp : Type\n| var : atom → exp\n| const : ℕ → exp\n| abs : atom → exp → exp\n| app : exp → exp → exp\n-/\nopen exp\n\ninductive result : Type\n| error   : string → result\n| done    : exp → result\n| nofuel  : exp → result\n\ndef reduce (avoid : list atom) : ℕ → config → result\n| 0     ⟨hp, e, stk⟩       := result.nofuel e\n| (t+1) ⟨hp, abs x e, []⟩  := result.done (abs x e)\n| (t+1) ⟨hp, const n, stk⟩ := result.done (const n)\n\n| (t+1) ⟨hp, abs x e, (⟨val⟩ :: stk)⟩ :=\n if x ∈ hp ∨ x ∈ avoid\n then let y := atom.fresh (hp^.keys ∪ avoid) in reduce t ⟨hp^.insert y val, swap x y e, stk⟩\n else reduce t ⟨hp^.insert x val, e, stk⟩\n\n| (t+1) ⟨hp, var x, stk⟩ :=\n match hp^.find x with\n | some e := reduce t ⟨hp, e, stk⟩\n | none   := result.error \"variable not found\"\n end\n\n| (t+1) ⟨hp, app f a, stk⟩ := reduce t ⟨hp, f, ⟨a⟩ :: stk⟩\n\nexample : reduce [] 10 (init_config $ app (abs ⟨0⟩ (var ⟨0⟩)) (const 5)) = result.done (const 5) :=\nbegin\nsimp [reduce, init_config, hash_map.not_contains_empty, has_mem.mem, list.mem, hash_map.find_insert],\nend\n\n\n\nend nominal\n", "meta": {"author": "dselsam", "repo": "unrealistic_compiler", "sha": "70514de492a6a1ed705ad247333ae5b3f8455a83", "save_path": "github-repos/lean/dselsam-unrealistic_compiler", "path": "github-repos/lean/dselsam-unrealistic_compiler/unrealistic_compiler-70514de492a6a1ed705ad247333ae5b3f8455a83/nominal_machine.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6224593382055109, "lm_q1q2_score": 0.48044119286313713}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\nimport algebraic_geometry.properties\n\n/-!\n# Function field of integral schemes\n\nWe define the function field of an irreducible scheme as the stalk of the generic point.\nThis is a field when the scheme is integral.\n\n## Main definition\n* `algebraic_geometry.Scheme.function_field`: The function field of an integral scheme.\n* `algebraic_geometry.germ_to_function_field`: The canonical map from a component into the function\n  field. This map is injective.\n-/\n\nuniverses u v\n\nopen topological_space opposite category_theory category_theory.limits Top\n\nnamespace algebraic_geometry\n\nvariable (X : Scheme)\n\n/-- The function field of an irreducible scheme is the local ring at its generic point.\nDespite the name, this is a field only when the scheme is integral. -/\nnoncomputable\nabbreviation Scheme.function_field [irreducible_space X.carrier] : CommRing :=\nX.presheaf.stalk (generic_point X.carrier)\n\n/-- The restriction map from a component to the function field. -/\nnoncomputable\nabbreviation Scheme.germ_to_function_field [irreducible_space X.carrier] (U : opens X.carrier)\n  [h : nonempty U] : X.presheaf.obj (op U) ⟶ X.function_field :=\nX.presheaf.germ ⟨generic_point X.carrier,\n  ((generic_point_spec X.carrier).mem_open_set_iff U.is_open).mpr (by simpa using h)⟩\n\nnoncomputable\ninstance [irreducible_space X.carrier] (U : opens X.carrier) [nonempty U] :\n  algebra (X.presheaf.obj (op U)) X.function_field :=\n(X.germ_to_function_field U).to_algebra\n\nnoncomputable\ninstance [is_integral X] : field X.function_field :=\nbegin\n  apply field_of_is_unit_or_eq_zero,\n  intro a,\n  obtain ⟨U, m, s, rfl⟩ := Top.presheaf.germ_exist _ _ a,\n  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero],\n  intro ha,\n  replace ha := ne_of_apply_ne _ ha,\n  have hs : generic_point X.carrier ∈ RingedSpace.basic_open _ s,\n  { rw [← set_like.mem_coe, (generic_point_spec X.carrier).mem_open_set_iff, set.top_eq_univ,\n      set.univ_inter, set.nonempty_iff_ne_empty, ne.def, ← opens.coe_bot,\n      ← set_like.ext'_iff],\n    erw basic_open_eq_bot_iff,\n    exacts [ha, (RingedSpace.basic_open _ _).is_open] },\n  have := (X.presheaf.germ ⟨_, hs⟩).is_unit_map (RingedSpace.is_unit_res_basic_open _ s),\n  rwa Top.presheaf.germ_res_apply at this\nend\n\nlemma germ_injective_of_is_integral [is_integral X] {U : opens X.carrier} (x : U) :\n  function.injective (X.presheaf.germ x) :=\nbegin\n  rw injective_iff_map_eq_zero,\n  intros y hy,\n  rw ← (X.presheaf.germ x).map_zero at hy,\n  obtain ⟨W, hW, iU, iV, e⟩ := X.presheaf.germ_eq _ x.prop x.prop _ _ hy,\n  cases (show iU = iV, from subsingleton.elim _ _),\n  haveI : nonempty W := ⟨⟨_, hW⟩⟩,\n  exact map_injective_of_is_integral X iU e\nend\n\nlemma Scheme.germ_to_function_field_injective [is_integral X] (U : opens X.carrier)\n  [nonempty U] : function.injective (X.germ_to_function_field U) :=\ngerm_injective_of_is_integral _ _\n\nlemma generic_point_eq_of_is_open_immersion {X Y : Scheme} (f : X ⟶ Y) [H : is_open_immersion f]\n  [hX : irreducible_space X.carrier] [irreducible_space Y.carrier] :\n    f.1.base (generic_point X.carrier : _) = (generic_point Y.carrier : _) :=\nbegin\n  apply ((generic_point_spec _).eq _).symm,\n  show t0_space Y.carrier, by apply_instance,\n  convert (generic_point_spec X.carrier).image (show continuous f.1.base, by continuity),\n  symmetry,\n  rw [eq_top_iff, set.top_eq_univ, set.top_eq_univ],\n  convert subset_closure_inter_of_is_preirreducible_of_is_open _ H.base_open.open_range _,\n  rw [set.univ_inter, set.image_univ],\n  apply_with preirreducible_space.is_preirreducible_univ { instances := ff },\n  show preirreducible_space Y.carrier, by apply_instance,\n  exact ⟨_, trivial, set.mem_range_self hX.2.some⟩,\nend\n\nnoncomputable\ninstance stalk_function_field_algebra [irreducible_space X.carrier] (x : X.carrier) :\n  algebra (X.presheaf.stalk x) X.function_field :=\nbegin\n  apply ring_hom.to_algebra,\n  exact X.presheaf.stalk_specializes ((generic_point_spec X.carrier).specializes trivial)\nend\n\ninstance function_field_is_scalar_tower [irreducible_space X.carrier] (U : opens X.carrier) (x : U)\n  [nonempty U] :\n  is_scalar_tower (X.presheaf.obj $ op U) (X.presheaf.stalk x) X.function_field :=\nbegin\n  apply is_scalar_tower.of_algebra_map_eq',\n  simp_rw [ring_hom.algebra_map_to_algebra],\n  change _ = X.presheaf.germ x ≫ _,\n  rw X.presheaf.germ_stalk_specializes,\n  refl\nend\n\nnoncomputable\ninstance (R : CommRing) [is_domain R] : algebra R (Scheme.Spec.obj $ op R).function_field :=\nring_hom.to_algebra $ by { change CommRing.of R ⟶ _, apply structure_sheaf.to_stalk }\n\n@[simp] lemma generic_point_eq_bot_of_affine (R : CommRing) [is_domain R] :\n  generic_point (Scheme.Spec.obj $ op R).carrier = (⟨0, ideal.bot_prime⟩ : prime_spectrum R) :=\nbegin\n  apply (generic_point_spec (Scheme.Spec.obj $ op R).carrier).eq,\n  simp [is_generic_point_def, ← prime_spectrum.zero_locus_vanishing_ideal_eq_closure]\nend\n\ninstance function_field_is_fraction_ring_of_affine (R : CommRing.{u}) [is_domain R] :\n  is_fraction_ring R (Scheme.Spec.obj $ op R).function_field :=\nbegin\n  convert structure_sheaf.is_localization.to_stalk R _,\n  delta is_fraction_ring is_localization.at_prime,\n  congr' 1,\n  rw generic_point_eq_bot_of_affine,\n  ext,\n  exact mem_non_zero_divisors_iff_ne_zero\nend\n\ninstance {X : Scheme} [is_integral X] {U : opens X.carrier} [hU : nonempty U] :\n  is_integral (X.restrict U.open_embedding) :=\nbegin\n  haveI : nonempty (X.restrict U.open_embedding).carrier := hU,\n  exact is_integral_of_open_immersion (X.of_restrict U.open_embedding)\nend\n\nlemma is_affine_open.prime_ideal_of_generic_point {X : Scheme} [is_integral X]\n  {U : opens X.carrier} (hU : is_affine_open U) [h : nonempty U] :\n  hU.prime_ideal_of ⟨generic_point X.carrier,\n    ((generic_point_spec X.carrier).mem_open_set_iff U.is_open).mpr (by simpa using h)⟩ =\n  generic_point (Scheme.Spec.obj $ op $ X.presheaf.obj $ op U).carrier :=\nbegin\n  haveI : is_affine _ := hU,\n  have e : U.open_embedding.is_open_map.functor.obj ⊤ = U,\n  { ext1, exact set.image_univ.trans subtype.range_coe },\n  delta is_affine_open.prime_ideal_of,\n  rw ← Scheme.comp_val_base_apply,\n  convert (generic_point_eq_of_is_open_immersion ((X.restrict U.open_embedding).iso_Spec.hom ≫\n    Scheme.Spec.map (X.presheaf.map (eq_to_hom e).op).op)),\n  ext1,\n  exact (generic_point_eq_of_is_open_immersion (X.of_restrict U.open_embedding)).symm\nend\n\nlemma function_field_is_fraction_ring_of_is_affine_open [is_integral X] (U : opens X.carrier)\n  (hU : is_affine_open U) [hU' : nonempty U] :\n  is_fraction_ring (X.presheaf.obj $ op U) X.function_field :=\nbegin\n  haveI : is_affine _ := hU,\n  haveI : nonempty (X.restrict U.open_embedding).carrier := hU',\n  haveI : is_integral (X.restrict U.open_embedding) := @@is_integral_of_is_affine_is_domain _ _ _\n    (by { dsimp, rw opens.open_embedding_obj_top, apply_instance }),\n  have e : U.open_embedding.is_open_map.functor.obj ⊤ = U,\n  { ext1, exact set.image_univ.trans subtype.range_coe },\n  delta is_fraction_ring Scheme.function_field,\n  convert hU.is_localization_stalk ⟨generic_point X.carrier, _⟩ using 1,\n  rw [hU.prime_ideal_of_generic_point, generic_point_eq_bot_of_affine],\n  ext, exact mem_non_zero_divisors_iff_ne_zero\nend\n\ninstance (x : X.carrier) : is_affine (X.affine_cover.obj x) :=\nalgebraic_geometry.Spec_is_affine _\n\ninstance [h : is_integral X] (x : X.carrier) :\n  is_fraction_ring (X.presheaf.stalk x) X.function_field :=\nbegin\n  let U : opens X.carrier := ⟨set.range (X.affine_cover.map x).1.base,\n    PresheafedSpace.is_open_immersion.base_open.open_range⟩,\n  haveI : nonempty U := ⟨⟨_, X.affine_cover.covers x⟩⟩,\n  have hU : is_affine_open U := range_is_affine_open_of_open_immersion (X.affine_cover.map x),\n  exact @@is_fraction_ring.is_fraction_ring_of_is_domain_of_is_localization _ _ _ _ _ _ _ _ _ _ _\n    (hU.is_localization_stalk ⟨x, X.affine_cover.covers x⟩)\n      (function_field_is_fraction_ring_of_is_affine_open X U hU)\nend\n\nend algebraic_geometry\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_geometry/function_field.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303236047049, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.48037616229065655}}
{"text": "import seplog.f_assertions\n\nsection axiomatic_semantics\n  open TypeDecl\n\n  /-\n   - update the store used in an assertion using the value of an expr\n   -/\n\tdef update_store2 {α: TypeDecl} (x: Var α) (e: Expr α) (P: Assert)\n                    : Assert :=\n    λ s h, (eval e s).elim ⊤ (λ v, P (s.update v x.name) h).\n\n  /-\n   - update the store used in an assertion using the value held in a heap\n   -/\n\tdef lookup2 {α: TypeDecl} (x: Var α) (e: Expr (gPtr α)) (P: Assert)\n              : Assert :=\n\t  λ s h,\n\t    ∃ p, val2loc (eval e s) = some p ∧\n\t      ∃ (z: Val α), h.lookup p = some z ∧\n\t        P (s.update z x.name) h.\n\n\t/-\n   - update the heap used in an assertion\n   -/\n\tdef update_heap2 {α: TypeDecl} (e:Expr (gPtr α)) (e':Expr α) (P:Assert)\n                  : Assert :=\n\t  λ s h ,\n      (eval e' s).elim ⊤ (λ v, -- 2nd expr being an error gives trivial Assert\n\t    ∃ p, val2loc (eval e s) = some p ∧\n\t      ∃ (z: Val α), h.lookup p = some z ∧\n\t        P s (h.update v p)).\n\n  open cmd\n\n\tinductive semax: Assert -> cmd -> Assert -> Prop\n\t  | semax_skip: ∀ P, semax P skip P\n\t  | semax_assign: ∀ {α: TypeDecl} (P: Assert) (x: Var α) (e: Expr α),\n\t    semax (update_store2 x e P) (x ⇐ e) P\n\t  | semax_lookup: ∀ {α: TypeDecl} (P: Assert) (x: Var α) (e: Expr (gPtr α)),\n\t    semax (lookup2 x e P) (x ↩ e) P\n\t  | semax_mutation: ∀ {α: TypeDecl} (P: Assert) (e: Expr (gPtr α))\n                        (e': Expr α),\n\t    semax (update_heap2 e e' P) (e ≪ e') P\n\n\t  | semax_seq: ∀ P Q R c d,\n\t    semax P c Q -> semax Q d R -> semax P (c ∣ d) R\n\t  | semax_while: ∀ (P: Assert) (b: Expr gBool) c,\n\t    semax (λ s h, (P s h ∧ eval b s = some tt)) c P ->\n\t    semax P (while b c) (λ s h, P s h ∧ eval b s = some ff)\n\t  | semax_conseq: ∀ (P P' Q Q':Assert) c,\n\t    (Q' ⟹ Q) -> (P ⟹ P') ->\n\t    semax P' c Q' -> semax P c Q\n\t  | semax_ifte: ∀ (P Q: Assert) (b: Expr gBool) c d,\n\t    semax (λ s h, P s h ∧ eval b s = some tt) c Q ->\n\t    semax (λ s h, P s h ∧ eval b s = some ff) d Q ->\n\t    semax P (ifte b c d) Q.\n\n  notation `{{ ` P ` }} ` c ` {{` Q `}} `   := (semax P c Q)\n\n\t/- axiomatic semantic lemmas -/\n\n\tlemma semax_weaken_post : ∀ (P Q Q': Assert) c,\n\t  (Q' ⟹ Q) -> {{ P }} c {{ Q' }} -> {{ P }} c {{ Q }} := sorry.\n\n  lemma semax_strengthen_pre : ∀ (P P':Assert) Q c,\n  \t  (P ⟹ P') -> {{ P' }} c {{ Q }} -> {{ P }} c {{ Q }} := sorry.\n\n    /- link to operational sematnics-/\n  def semax' (P:Assert) (c:cmd) (Q:Assert) : Prop :=\n        ∀ s h, (P s h -> ¬(exec (some (s, h)) c none)) ∧\n          (∀ s' h', P s h -> (exec (some (s, h)) c  (some (s', h'))) -> Q s' h')\n\n\tlemma semax_sound : ∀ P Q c,\n\t  {{ P }} c {{ Q }} -> semax' P c Q\n    := sorry.\n\n  /-\n   - Class-definition-dependent assertions\n   -/\n  def Assert' := Decls → Assert\n\n\n  def wp_semantics (c: cmd) (Q: Assert'): Assert' :=\n      λ d s h,\n        ¬ (exec (some (s, h, d))  c none) ∧\n        ∀ s' h',\n          exec (some (s, h, d)) c  (some (s', h', d)) -> Q d s' h'\n          .\n\n\tlemma exec_lookup_not_None:\n    ∀ {α: TypeDecl} (s: Store) (h: Heap) (d: Decls) (v: Var α)\n      (e: Expr (gPtr α)),\n        ¬ (exec (some (s, h, d)) (v ↩ e) none) ->\n          ∃ p : Address,\n            val2loc (eval e s) = some p ∧\n            (∃ z: Val α, h.lookup p = some z)\n            := sorry.\n\n  lemma exec_mutation_not_None:\n    ∀ {α: TypeDecl} (s: Store) (h: Heap) (d: Decls) (e: Expr (gPtr α))\n      (e0: Expr α),\n        ¬ exec (some (s, h, d)) (e ≪ e0) none ->\n        ∃ p : Address,\n          val2loc (eval e s) = some p ∧\n          (∃ z: Val α, h.lookup p = some z)\n          := sorry.\n\n  lemma exec_seq1_not_None: ∀ (s: Store) (h: Heap) (c1 c2: cmd),\n      ¬ exec (some (s, h))  (c1 ∣ c2)  none ->\n      ¬ exec (some (s, h)) c1 none\n      := sorry.\n\n  lemma exec_seq2_not_None:\n    ∀ (s: Store) (h: Heap) (c1 c2: cmd) (s': Store) (h': Heap),\n      ¬ exec (some (s, h)) (c1 ∣ c2) none ->\n      exec (some (s, h)) c1 (some (s',h')) ->\n      ¬ exec (some (s', h')) c2 none\n      := sorry.\n\n  lemma exec_ifte1_not_None: ∀ s h c1 c2 e,\n      ¬ exec (some (s, h))  (ifte e  c1  c2)  none ->\n      eval e s = some tt ->\n      ¬ exec (some (s, h)) c1  none\n      := sorry.\n\n  lemma exec_ifte2_not_None: ∀ s h c1 c2 e,\n      ¬ exec (some (s, h))  (ifte e  c1  c2)  none ->\n      eval e s = some ff ->\n      ¬ exec (some (s, h)) c2  none\n      := sorry.\n\n  lemma exec_while1_not_None: ∀ s h e c,\n        ¬ exec (some (s, h)) (while e c) none ->\n        eval e s = some tt ->\n        ¬ exec (some (s, h)) c none\n        := sorry.\n\n  lemma exec_while2_not_None: ∀ s h e c s' h',\n        ¬ exec (some (s, h)) (while e c) none ->\n        eval e s = some tt ->\n        exec (some (s, h)) c (some (s', h')) ->\n      ¬ exec (some (s', h')) (while e c)  none\n      := sorry.\n\n  lemma wp_semantics_sound: ∀ c Q,\n      {{wp_semantics c Q}} c {{Q}} := sorry.\n\n  lemma semax_complete : ∀ P Q c,\n      semax' P c Q -> {{ P }} c {{ Q }} := sorry.\n\n  def semax_alternative (P:Assert) (c:cmd) (Q:Assert) : Prop :=\n      ∀ s h, P s h ->\n        (∀ s' h', exec (some (s, h))  c  (some (s', h')) -> (Q s' h')).\n\n  lemma semax_sound_alternative : ∀ P Q c,\n    {{ P }} c {{ Q }} -> semax_alternative P c Q := sorry.\n\n  /- Derived reynolds' axioms-/\n  lemma semax_lookup_backwards:\n    ∀{α: TypeDecl} (x : Var α) (e: Expr (gPtr α)) (P: Assert),\n      {{ λ s h, ∃ e0, (e ↦ e0 ∗ (e ↦ e0 ⊸ update_store2 x e0 P)) s h }}\n       (x ↩ e) {{ P }} := sorry.\n\n  lemma semax_lookup_backwards_alternative :\n    ∀{α: TypeDecl} (x : Var ( α)) (e: Expr (gPtr α)) (P: Assert) (e0: Expr α),\n      {{ ((e ↦ e0) ∗ ((e ↦ e0) ⊸ (update_store2 x e0 P))) }} (x ↩ e) {{ P }}\n      := sorry.\n\n  lemma semax_mutation_local: ∀{α: TypeDecl} (x : Expr (gPtr α)) v v',\n        {{ (x ↦ v) }} (x ≪ v') {{ (x ↦ v') }} := sorry.\n\n  /-\n   - Frame rule\n   -/\n\n  /-\n   - Get list of variables that are modified by a program\n   -/\n  def modified_cmd_var: cmd → list (Σ α: TypeDecl, Var α)\n    | skip              := list.nil\n    | (assign x e)      := [⟨_, x⟩]\n    | (lookup x e)      := [⟨_, x⟩]\n    | (mutation e f)    := list.nil\n    | (seq c1 c2)       := modified_cmd_var c1 ++ modified_cmd_var c2\n    | (ifte a c1 c2)    := modified_cmd_var c1 ++ modified_cmd_var c2\n    | (while a c1)      := modified_cmd_var c1\n    | (declare x)       := [⟨_, x⟩]\n    | (new x)           := [⟨_, x⟩]\n    | (call _ _ _ vars) := vars\n\n  lemma inde_seq : ∀ R (c d: cmd),\n\t  inde (modified_cmd_var (c ∣ d)) R ->\n\t  inde (modified_cmd_var c) R ∧ inde (modified_cmd_var d) R := sorry.\n\n  lemma inde_ifte : ∀ R b c d,\n      inde (modified_cmd_var (ifte b  c  d)) R →\n      inde (modified_cmd_var c) R ∧ inde (modified_cmd_var d) R := sorry.\n\n  lemma frame_rule : ∀ (P: Assert) (c: cmd) (Q: Assert),\n      {{P}} c {{Q}} ->\n      ∀ (R: Assert) ,\n        (inde (modified_cmd_var c) R ->\n          {{ (P ∗ R) }} c {{ (Q ∗ R) }}) := sorry.\n\n  /-\n  - More reynolds axioms\n  -/\n\n\tlemma semax_mutation_global :\n    ∀ {α: TypeDecl} (P: Assert) (e: Expr (gPtr α)) e',\n\t  {{((λ s' h', ∃ e'', (((e ↦ e'') s' h'))) ∗ P) }} (e ≪ e') {{((e ↦ e')∗P)}}\n    := sorry.\n\n  lemma semax_mutation_global_alternative :\n    ∀ {α: TypeDecl} (P: Assert) (e: Expr (gPtr α)) e' e'',\n      {{ ((e ↦ e'') ∗ P) }} (e ≪ e') {{ ((e ↦ e') ∗ P) }} := sorry.\n\n  lemma semax_mutation_backwards :\n    ∀ {α: TypeDecl} (P: Assert) (e: Expr (gPtr α)) e',\n      {{λ s h, ∃ e'', ((e ↦ e'')∗(e ↦ e' ⊸ P)) s h}} (e ≪ e') {{P}} := sorry.\n\n\n\tlemma semax_mutation_backwards_alternative :\n   ∀ {α: TypeDecl} (P: Assert) (e: Expr (gPtr α)) e' e'',\n\t  {{ ((e ↦ e'') ∗ ((e ↦ e') ⊸ P)) }} (e ≪ e') {{ P }} := sorry.\n\n\nend axiomatic_semantics\n", "meta": {"author": "google", "repo": "soong_verification", "sha": "a6311e81a9d099e00c1cc37aa790fc45c45ff51f", "save_path": "github-repos/lean/google-soong_verification", "path": "github-repos/lean/google-soong_verification/soong_verification-a6311e81a9d099e00c1cc37aa790fc45c45ff51f/src/seplog/g_frame_rule.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303087996143, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.48037615329414823}}
{"text": "import topology.category.Profinite\n\nnamespace Profinite\n\n-- A surjective map of compact Hausdorff spaces is a quotient map\n-- TODO: This certainly belongs in mathlib, if not already there...\nlemma quotient_map {X Y : Profinite} (f : X ⟶ Y) (hf : function.surjective f) :\n  quotient_map f :=\nbegin\n  rw quotient_map_iff,\n  refine ⟨hf,_⟩,\n  intro S,\n  refine ⟨λ hS, hS.preimage f.continuous, λ hS, _⟩,\n  rw ← is_closed_compl_iff at *,\n  rw ← set.preimage_compl at hS,\n  have : Sᶜ = f '' (f ⁻¹' Sᶜ),\n  { ext,\n    split,\n    { intro h,\n      obtain ⟨y,rfl⟩ := hf x,\n      refine ⟨y,h,rfl⟩ },\n    { rintro ⟨y,h,rfl⟩,\n      exact h } },\n  rw this,\n  exact Profinite.is_closed_map f (⇑f ⁻¹' Sᶜ) hS\nend\n\nend Profinite\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/Profinite/quotient_map.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.810478926981208, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.48034378998837535}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.functor.fully_faithful\nimport category_theory.full_subcategory\nimport category_theory.whiskering\nimport category_theory.essential_image\nimport tactic.slice\n\n/-!\n# Equivalence of categories\n\nAn equivalence of categories `C` and `D` is a pair of functors `F : C ⥤ D` and `G : D ⥤ C` such\nthat `η : 𝟭 C ≅ F ⋙ G` and `ε : G ⋙ F ≅ 𝟭 D`. In many situations, equivalences are a better\nnotion of \"sameness\" of categories than the stricter isomorphims of categories.\n\nRecall that one way to express that two functors `F : C ⥤ D` and `G : D ⥤ C` are adjoint is using\ntwo natural transformations `η : 𝟭 C ⟶ F ⋙ G` and `ε : G ⋙ F ⟶ 𝟭 D`, called the unit and the\ncounit, such that the compositions `F ⟶ FGF ⟶ F` and `G ⟶ GFG ⟶ G` are the identity. Unfortunately,\nit is not the case that the natural isomorphisms `η` and `ε` in the definition of an equivalence\nautomatically give an adjunction. However, it is true that\n* if one of the two compositions is the identity, then so is the other, and\n* given an equivalence of categories, it is always possible to refine `η` in such a way that the\n  identities are satisfied.\n\nFor this reason, in mathlib we define an equivalence to be a \"half-adjoint equivalence\", which is\na tuple `(F, G, η, ε)` as in the first paragraph such that the composite `F ⟶ FGF ⟶ F` is the\nidentity. By the remark above, this already implies that the tuple is an \"adjoint equivalence\",\ni.e., that the composite `G ⟶ GFG ⟶ G` is also the identity.\n\nWe also define essentially surjective functors and show that a functor is an equivalence if and only\nif it is full, faithful and essentially surjective.\n\n## Main definitions\n\n* `equivalence`: bundled (half-)adjoint equivalences of categories\n* `is_equivalence`: type class on a functor `F` containing the data of the inverse `G` as well as\n  the natural isomorphisms `η` and `ε`.\n* `ess_surj`: type class on a functor `F` containing the data of the preimages and the isomorphisms\n  `F.obj (preimage d) ≅ d`.\n\n## Main results\n\n* `equivalence.mk`: upgrade an equivalence to a (half-)adjoint equivalence\n* `is_equivalence.equiv_of_iso`: when `F` and `G` are isomorphic functors, `F` is an equivalence\niff `G` is.\n* `equivalence.of_fully_faithfully_ess_surj`: a fully faithful essentially surjective functor is an\n  equivalence.\n\n## Notations\n\nWe write `C ≌ D` (`\\backcong`, not to be confused with `≅`/`\\cong`) for a bundled equivalence.\n\n-/\n\nnamespace category_theory\nopen category_theory.functor nat_iso category\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\n/-- We define an equivalence as a (half)-adjoint equivalence, a pair of functors with\n  a unit and counit which are natural isomorphisms and the triangle law `Fη ≫ εF = 1`, or in other\n  words the composite `F ⟶ FGF ⟶ F` is the identity.\n\n  In `unit_inverse_comp`, we show that this is actually an adjoint equivalence, i.e., that the\n  composite `G ⟶ GFG ⟶ G` is also the identity.\n\n  The triangle equation is written as a family of equalities between morphisms, it is more\n  complicated if we write it as an equality of natural transformations, because then we would have\n  to insert natural transformations like `F ⟶ F1`.\n\nSee https://stacks.math.columbia.edu/tag/001J\n-/\nstructure equivalence (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D] :=\nmk' ::\n(functor : C ⥤ D)\n(inverse : D ⥤ C)\n(unit_iso   : 𝟭 C ≅ functor ⋙ inverse)\n(counit_iso : inverse ⋙ functor ≅ 𝟭 D)\n(functor_unit_iso_comp' : ∀(X : C), functor.map ((unit_iso.hom : 𝟭 C ⟶ functor ⋙ inverse).app X) ≫\n  counit_iso.hom.app (functor.obj X) = 𝟙 (functor.obj X) . obviously)\n\nrestate_axiom equivalence.functor_unit_iso_comp'\n\ninfixr ` ≌ `:10  := equivalence\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\nnamespace equivalence\n\n/-- The unit of an equivalence of categories. -/\nabbreviation unit (e : C ≌ D) : 𝟭 C ⟶ e.functor ⋙ e.inverse := e.unit_iso.hom\n/-- The counit of an equivalence of categories. -/\nabbreviation counit (e : C ≌ D) : e.inverse ⋙ e.functor ⟶ 𝟭 D := e.counit_iso.hom\n/-- The inverse of the unit of an equivalence of categories. -/\nabbreviation unit_inv (e : C ≌ D) : e.functor ⋙ e.inverse ⟶ 𝟭 C := e.unit_iso.inv\n/-- The inverse of the counit of an equivalence of categories. -/\nabbreviation counit_inv (e : C ≌ D) : 𝟭 D ⟶ e.inverse ⋙ e.functor := e.counit_iso.inv\n\n/- While these abbreviations are convenient, they also cause some trouble,\npreventing structure projections from unfolding. -/\n@[simp] lemma equivalence_mk'_unit (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit = unit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit = counit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_unit_inv (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit_inv = unit_iso.inv := rfl\n@[simp] lemma equivalence_mk'_counit_inv (functor inverse unit_iso counit_iso f) :\n  (⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit_inv = counit_iso.inv := rfl\n\n@[simp] lemma functor_unit_comp (e : C ≌ D) (X : C) :\n  e.functor.map (e.unit.app X) ≫ e.counit.app (e.functor.obj X) = 𝟙 (e.functor.obj X) :=\ne.functor_unit_iso_comp X\n\n@[simp] lemma counit_inv_functor_comp (e : C ≌ D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) ≫ e.functor.map (e.unit_inv.app X) = 𝟙 (e.functor.obj X) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.functor.map_iso (e.unit_iso.app X) ≪≫ e.counit_iso.app (e.functor.obj X)) (iso.refl _)],\n  exact e.functor_unit_comp X\nend\n\nlemma counit_inv_app_functor (e : C ≌ D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) = e.functor.map (e.unit.app X) :=\nby { symmetry, erw [←iso.comp_hom_eq_id (e.counit_iso.app _), functor_unit_comp], refl }\n\nlemma counit_app_functor (e : C ≌ D) (X : C) :\n  e.counit.app (e.functor.obj X) = e.functor.map (e.unit_inv.app X) :=\nby { erw [←iso.hom_comp_eq_id (e.functor.map_iso (e.unit_iso.app X)), functor_unit_comp], refl }\n\n/-- The other triangle equality. The proof follows the following proof in Globular:\n  http://globular.science/1905.001 -/\n@[simp] lemma unit_inverse_comp (e : C ≌ D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) ≫ e.inverse.map (e.counit.app Y) = 𝟙 (e.inverse.obj Y) :=\nbegin\n  rw [←id_comp (e.inverse.map _), ←map_id e.inverse, ←counit_inv_functor_comp, map_comp,\n      ←iso.hom_inv_id_assoc (e.unit_iso.app _) (e.inverse.map (e.functor.map _)),\n      app_hom, app_inv],\n  slice_lhs 2 3 { erw [e.unit.naturality] },\n  slice_lhs 1 2 { erw [e.unit.naturality] },\n  slice_lhs 4 4\n  { rw [←iso.hom_inv_id_assoc (e.inverse.map_iso (e.counit_iso.app _)) (e.unit_inv.app _)] },\n  slice_lhs 3 4 { erw [←map_comp e.inverse, e.counit.naturality],\n    erw [(e.counit_iso.app _).hom_inv_id, map_id] }, erw [id_comp],\n  slice_lhs 2 3 { erw [←map_comp e.inverse, e.counit_iso.inv.naturality, map_comp] },\n  slice_lhs 3 4 { erw [e.unit_inv.naturality] },\n  slice_lhs 4 5 { erw [←map_comp (e.functor ⋙ e.inverse), (e.unit_iso.app _).hom_inv_id, map_id] },\n  erw [id_comp],\n  slice_lhs 3 4 { erw [←e.unit_inv.naturality] },\n  slice_lhs 2 3 { erw [←map_comp e.inverse, ←e.counit_iso.inv.naturality,\n    (e.counit_iso.app _).hom_inv_id, map_id] }, erw [id_comp, (e.unit_iso.app _).hom_inv_id], refl\nend\n\n@[simp] lemma inverse_counit_inv_comp (e : C ≌ D) (Y : D) :\n  e.inverse.map (e.counit_inv.app Y) ≫ e.unit_inv.app (e.inverse.obj Y) = 𝟙 (e.inverse.obj Y) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.unit_iso.app (e.inverse.obj Y) ≪≫ e.inverse.map_iso (e.counit_iso.app Y)) (iso.refl _)],\n  exact e.unit_inverse_comp Y\nend\n\nlemma unit_app_inverse (e : C ≌ D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counit_inv.app Y) :=\nby { erw [←iso.comp_hom_eq_id (e.inverse.map_iso (e.counit_iso.app Y)), unit_inverse_comp], refl }\n\nlemma unit_inv_app_inverse (e : C ≌ D) (Y : D) :\n  e.unit_inv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) :=\nby { symmetry, erw [←iso.hom_comp_eq_id (e.unit_iso.app _), unit_inverse_comp], refl }\n\n@[simp] lemma fun_inv_map (e : C ≌ D) (X Y : D) (f : X ⟶ Y) :\n  e.functor.map (e.inverse.map f) = e.counit.app X ≫ f ≫ e.counit_inv.app Y :=\n(nat_iso.naturality_2 (e.counit_iso) f).symm\n\n@[simp] lemma inv_fun_map (e : C ≌ D) (X Y : C) (f : X ⟶ Y) :\n  e.inverse.map (e.functor.map f) = e.unit_inv.app X ≫ f ≫ e.unit.app Y :=\n(nat_iso.naturality_1 (e.unit_iso) f).symm\n\nsection\n-- In this section we convert an arbitrary equivalence to a half-adjoint equivalence.\nvariables {F : C ⥤ D} {G : D ⥤ C} (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D)\n\n/-- If `η : 𝟭 C ≅ F ⋙ G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it\nto a refined natural isomorphism `adjointify_η η : 𝟭 C ≅ F ⋙ G` which exhibits the properties\nrequired for a half-adjoint equivalence. See `equivalence.mk`. -/\ndef adjointify_η : 𝟭 C ≅ F ⋙ G :=\ncalc\n  𝟭 C ≅ F ⋙ G               : η\n  ... ≅ F ⋙ (𝟭 D ⋙ G)      : iso_whisker_left F (left_unitor G).symm\n  ... ≅ F ⋙ ((G ⋙ F) ⋙ G) : iso_whisker_left F (iso_whisker_right ε.symm G)\n  ... ≅ F ⋙ (G ⋙ (F ⋙ G)) : iso_whisker_left F (associator G F G)\n  ... ≅ (F ⋙ G) ⋙ (F ⋙ G) : (associator F G (F ⋙ G)).symm\n  ... ≅ 𝟭 C ⋙ (F ⋙ G)      : iso_whisker_right η.symm (F ⋙ G)\n  ... ≅ F ⋙ G               : left_unitor (F ⋙ G)\n\nlemma adjointify_η_ε (X : C) :\n  F.map ((adjointify_η η ε).hom.app X) ≫ ε.hom.app (F.obj X) = 𝟙 (F.obj X) :=\nbegin\n  dsimp [adjointify_η], simp,\n  have := ε.hom.naturality (F.map (η.inv.app X)), dsimp at this, rw [this], clear this,\n  rw [←assoc _ _ (F.map _)],\n  have := ε.hom.naturality (ε.inv.app $ F.obj X), dsimp at this, rw [this], clear this,\n  have := (ε.app $ F.obj X).hom_inv_id, dsimp at this, rw [this], clear this,\n  rw [id_comp], have := (F.map_iso $ η.app X).hom_inv_id, dsimp at this, rw [this]\nend\n\nend\n\n/-- Every equivalence of categories consisting of functors `F` and `G` such that `F ⋙ G` and\n    `G ⋙ F` are naturally isomorphic to identity functors can be transformed into a half-adjoint\n    equivalence without changing `F` or `G`. -/\nprotected definition mk (F : C ⥤ D) (G : D ⥤ C)\n  (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : C ≌ D :=\n⟨F, G, adjointify_η η ε, ε, adjointify_η_ε η ε⟩\n\n/-- Equivalence of categories is reflexive. -/\n@[refl, simps] def refl : C ≌ C :=\n⟨𝟭 C, 𝟭 C, iso.refl _, iso.refl _, λ X, category.id_comp _⟩\n\ninstance : inhabited (C ≌ C) :=\n⟨refl⟩\n\n/-- Equivalence of categories is symmetric. -/\n@[symm, simps] def symm (e : C ≌ D) : D ≌ C :=\n⟨e.inverse, e.functor, e.counit_iso.symm, e.unit_iso.symm, e.inverse_counit_inv_comp⟩\n\nvariables {E : Type u₃} [category.{v₃} E]\n\n/-- Equivalence of categories is transitive. -/\n@[trans, simps] def trans (e : C ≌ D) (f : D ≌ E) : C ≌ E :=\n{ functor := e.functor ⋙ f.functor,\n  inverse := f.inverse ⋙ e.inverse,\n  unit_iso :=\n  begin\n    refine iso.trans e.unit_iso _,\n    exact iso_whisker_left e.functor (iso_whisker_right f.unit_iso e.inverse) ,\n  end,\n  counit_iso :=\n  begin\n    refine iso.trans _ f.counit_iso,\n    exact iso_whisker_left f.inverse (iso_whisker_right e.counit_iso f.functor)\n  end,\n  -- We wouldn't have needed to give this proof if we'd used `equivalence.mk`,\n  -- but we choose to avoid using that here, for the sake of good structure projection `simp`\n  -- lemmas.\n  functor_unit_iso_comp' := λ X,\n  begin\n    dsimp,\n    rw [← f.functor.map_comp_assoc, e.functor.map_comp, ←counit_inv_app_functor, fun_inv_map,\n        iso.inv_hom_id_app_assoc, assoc, iso.inv_hom_id_app, counit_app_functor,\n        ← functor.map_comp],\n    erw [comp_id, iso.hom_inv_id_app, functor.map_id],\n  end }\n\n/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic\nfunctor. -/\ndef fun_inv_id_assoc (e : C ≌ D) (F : C ⥤ E) : e.functor ⋙ e.inverse ⋙ F ≅ F :=\n(functor.associator _ _ _).symm ≪≫ iso_whisker_right e.unit_iso.symm F ≪≫ F.left_unitor\n\n@[simp] lemma fun_inv_id_assoc_hom_app (e : C ≌ D) (F : C ⥤ E) (X : C) :\n  (fun_inv_id_assoc e F).hom.app X = F.map (e.unit_inv.app X) :=\nby { dsimp [fun_inv_id_assoc], tidy }\n\n@[simp] lemma fun_inv_id_assoc_inv_app (e : C ≌ D) (F : C ⥤ E) (X : C) :\n  (fun_inv_id_assoc e F).inv.app X = F.map (e.unit.app X) :=\nby { dsimp [fun_inv_id_assoc], tidy }\n\n/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic\nfunctor. -/\ndef inv_fun_id_assoc (e : C ≌ D) (F : D ⥤ E) : e.inverse ⋙ e.functor ⋙ F ≅ F :=\n(functor.associator _ _ _).symm ≪≫ iso_whisker_right e.counit_iso F ≪≫ F.left_unitor\n\n@[simp] lemma inv_fun_id_assoc_hom_app (e : C ≌ D) (F : D ⥤ E) (X : D) :\n  (inv_fun_id_assoc e F).hom.app X = F.map (e.counit.app X) :=\nby { dsimp [inv_fun_id_assoc], tidy }\n\n@[simp] lemma inv_fun_id_assoc_inv_app (e : C ≌ D) (F : D ⥤ E) (X : D) :\n  (inv_fun_id_assoc e F).inv.app X = F.map (e.counit_inv.app X) :=\nby { dsimp [inv_fun_id_assoc], tidy }\n\n/-- If `C` is equivalent to `D`, then `C ⥤ E` is equivalent to `D ⥤ E`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_left (e : C ≌ D) : (C ⥤ E) ≌ (D ⥤ E) :=\nequivalence.mk\n  ((whiskering_left _ _ _).obj e.inverse)\n  ((whiskering_left _ _ _).obj e.functor)\n  (nat_iso.of_components (λ F, (e.fun_inv_id_assoc F).symm) (by tidy))\n  (nat_iso.of_components (λ F, e.inv_fun_id_assoc F) (by tidy))\n\n/-- If `C` is equivalent to `D`, then `E ⥤ C` is equivalent to `E ⥤ D`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_right (e : C ≌ D) : (E ⥤ C) ≌ (E ⥤ D) :=\nequivalence.mk\n  ((whiskering_right _ _ _).obj e.functor)\n  ((whiskering_right _ _ _).obj e.inverse)\n  (nat_iso.of_components\n    (λ F, F.right_unitor.symm ≪≫ iso_whisker_left F e.unit_iso ≪≫ functor.associator _ _ _)\n    (by tidy))\n  (nat_iso.of_components\n    (λ F, functor.associator _ _ _ ≪≫ iso_whisker_left F e.counit_iso ≪≫ F.right_unitor)\n    (by tidy))\n\nsection cancellation_lemmas\nvariables (e : C ≌ D)\n\n/- We need special forms of `cancel_nat_iso_hom_right(_assoc)` and\n`cancel_nat_iso_inv_right(_assoc)` for units and counits, because neither `simp` or `rw` will apply\nthose lemmas in this setting without providing `e.unit_iso` (or similar) as an explicit argument.\nWe also provide the lemmas for length four compositions, since they're occasionally useful.\n(e.g. in proving that equivalences take monos to monos) -/\n\n@[simp] lemma cancel_unit_right {X Y : C}\n  (f f' : X ⟶ Y) :\n  f ≫ e.unit.app Y = f' ≫ e.unit.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_inv_right {X Y : C}\n  (f f' : X ⟶ e.inverse.obj (e.functor.obj Y))   :\n  f ≫ e.unit_inv.app Y = f' ≫ e.unit_inv.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_right {X Y : D}\n  (f f' : X ⟶ e.functor.obj (e.inverse.obj Y))   :\n  f ≫ e.counit.app Y = f' ≫ e.counit.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right {X Y : D}\n  (f f' : X ⟶ Y) :\n  f ≫ e.counit_inv.app Y = f' ≫ e.counit_inv.app Y ↔ f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc {W X X' Y : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) :\n  f ≫ g ≫ e.unit.app Y = f' ≫ g' ≫ e.unit.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right_assoc {W X X' Y : D}\n  (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) :\n  f ≫ g ≫ e.counit_inv.app Y = f' ≫ g' ≫ e.counit_inv.app Y ↔ f ≫ g = f' ≫ g' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc' {W X X' Y Y' Z : C}\n  (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z) (f' : W ⟶ X') (g' : X' ⟶ Y') (h' : Y' ⟶ Z) :\n  f ≫ g ≫ h ≫ e.unit.app Z = f' ≫ g' ≫ h' ≫ e.unit.app Z ↔ f ≫ g ≫ h = f' ≫ g' ≫ h' :=\nby simp only [←category.assoc, cancel_mono]\n\n@[simp] \n\nend cancellation_lemmas\n\nsection\n\n-- There's of course a monoid structure on `C ≌ C`,\n-- but let's not encourage using it.\n-- The power structure is nevertheless useful.\n\n/-- Natural number powers of an auto-equivalence.  Use `(^)` instead. -/\ndef pow_nat (e : C ≌ C) : ℕ → (C ≌ C)\n| 0 := equivalence.refl\n| 1 := e\n| (n+2) := e.trans (pow_nat (n+1))\n\n/-- Powers of an auto-equivalence.  Use `(^)` instead. -/\ndef pow (e : C ≌ C) : ℤ → (C ≌ C)\n| (int.of_nat n) := e.pow_nat n\n| (int.neg_succ_of_nat n) := e.symm.pow_nat (n+1)\n\ninstance : has_pow (C ≌ C) ℤ := ⟨pow⟩\n\n@[simp] lemma pow_zero (e : C ≌ C) : e^(0 : ℤ) = equivalence.refl := rfl\n@[simp] lemma pow_one (e : C ≌ C) : e^(1 : ℤ) = e := rfl\n@[simp] lemma pow_neg_one (e : C ≌ C) : e^(-1 : ℤ) = e.symm := rfl\n\n-- TODO as necessary, add the natural isomorphisms `(e^a).trans e^b ≅ e^(a+b)`.\n-- At this point, we haven't even defined the category of equivalences.\n\nend\n\nend equivalence\n\n\n/-- A functor that is part of a (half) adjoint equivalence -/\nclass is_equivalence (F : C ⥤ D) :=\nmk' ::\n(inverse    : D ⥤ C)\n(unit_iso   : 𝟭 C ≅ F ⋙ inverse)\n(counit_iso : inverse ⋙ F ≅ 𝟭 D)\n(functor_unit_iso_comp' : ∀ (X : C), F.map ((unit_iso.hom : 𝟭 C ⟶ F ⋙ inverse).app X) ≫\n  counit_iso.hom.app (F.obj X) = 𝟙 (F.obj X) . obviously)\n\nrestate_axiom is_equivalence.functor_unit_iso_comp'\n\nattribute [simp, reassoc] is_equivalence.functor_unit_iso_comp\n\nnamespace is_equivalence\n\ninstance of_equivalence (F : C ≌ D) : is_equivalence F.functor :=\n{ ..F }\n\ninstance of_equivalence_inverse (F : C ≌ D) : is_equivalence F.inverse :=\nis_equivalence.of_equivalence F.symm\n\nopen equivalence\n/-- To see that a functor is an equivalence, it suffices to provide an inverse functor `G` such that\n    `F ⋙ G` and `G ⋙ F` are naturally isomorphic to identity functors. -/\nprotected definition mk {F : C ⥤ D} (G : D ⥤ C)\n  (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : is_equivalence F :=\n⟨G, adjointify_η η ε, ε, adjointify_η_ε η ε⟩\n\nend is_equivalence\n\n\nnamespace functor\n\n/-- Interpret a functor that is an equivalence as an equivalence. -/\ndef as_equivalence (F : C ⥤ D) [is_equivalence F] : C ≌ D :=\n⟨F, is_equivalence.inverse F, is_equivalence.unit_iso, is_equivalence.counit_iso,\n  is_equivalence.functor_unit_iso_comp⟩\n\ninstance is_equivalence_refl : is_equivalence (𝟭 C) :=\nis_equivalence.of_equivalence equivalence.refl\n\n/-- The inverse functor of a functor that is an equivalence. -/\ndef inv (F : C ⥤ D) [is_equivalence F] : D ⥤ C :=\nis_equivalence.inverse F\n\ninstance is_equivalence_inv (F : C ⥤ D) [is_equivalence F] : is_equivalence F.inv :=\nis_equivalence.of_equivalence F.as_equivalence.symm\n\n@[simp] lemma as_equivalence_functor (F : C ⥤ D) [is_equivalence F] :\n  F.as_equivalence.functor = F := rfl\n\n@[simp] lemma as_equivalence_inverse (F : C ⥤ D) [is_equivalence F] :\n  F.as_equivalence.inverse = inv F := rfl\n\n@[simp] lemma as_equivalence_unit {F : C ⥤ D} [h : is_equivalence F] :\n  F.as_equivalence.unit_iso = @@is_equivalence.unit_iso _ _ h := rfl\n\n@[simp] lemma as_equivalence_counit {F : C ⥤ D} [is_equivalence F] :\n  F.as_equivalence.counit_iso = is_equivalence.counit_iso := rfl\n\n@[simp] lemma inv_inv (F : C ⥤ D) [is_equivalence F] :\n  inv (inv F) = F := rfl\n\nvariables {E : Type u₃} [category.{v₃} E]\n\ninstance is_equivalence_trans (F : C ⥤ D) (G : D ⥤ E) [is_equivalence F] [is_equivalence G] :\n  is_equivalence (F ⋙ G) :=\nis_equivalence.of_equivalence (equivalence.trans (as_equivalence F) (as_equivalence G))\n\nend functor\n\nnamespace equivalence\n\n@[simp]\nlemma functor_inv (E : C ≌ D) : E.functor.inv = E.inverse := rfl\n\n@[simp]\nlemma inverse_inv (E : C ≌ D) : E.inverse.inv = E.functor := rfl\n\n@[simp]\nlemma functor_as_equivalence (E : C ≌ D) : E.functor.as_equivalence = E :=\nby { cases E, congr, }\n\n@[simp]\nlemma inverse_as_equivalence (E : C ≌ D) : E.inverse.as_equivalence = E.symm :=\nby { cases E, congr, }\n\nend equivalence\n\nnamespace is_equivalence\n\n@[simp] lemma fun_inv_map (F : C ⥤ D) [is_equivalence F] (X Y : D) (f : X ⟶ Y) :\n  F.map (F.inv.map f) = F.as_equivalence.counit.app X ≫ f ≫ F.as_equivalence.counit_inv.app Y :=\nbegin\n  erw [nat_iso.naturality_2],\n  refl\nend\n@[simp] lemma inv_fun_map (F : C ⥤ D) [is_equivalence F] (X Y : C) (f : X ⟶ Y) :\n  F.inv.map (F.map f) = F.as_equivalence.unit_inv.app X ≫ f ≫ F.as_equivalence.unit.app Y :=\nbegin\n  erw [nat_iso.naturality_1],\n  refl\nend\n\n/-- When a functor `F` is an equivalence of categories, and `G` is isomorphic to `F`, then\n`G` is also an equivalence of categories. -/\n@[simps]\ndef of_iso {F G : C ⥤ D} (e : F ≅ G) (hF : is_equivalence F) : is_equivalence G :=\n{ inverse := hF.inverse,\n  unit_iso := hF.unit_iso ≪≫ nat_iso.hcomp e (iso.refl hF.inverse),\n  counit_iso := nat_iso.hcomp (iso.refl hF.inverse) e.symm ≪≫ hF.counit_iso,\n  functor_unit_iso_comp' := λ X, begin\n    dsimp [nat_iso.hcomp],\n    erw [id_comp, F.map_id, comp_id],\n    apply (cancel_epi (e.hom.app X)).mp,\n    slice_lhs 1 2 { rw ← e.hom.naturality, },\n    slice_lhs 2 3 { rw [← nat_trans.vcomp_app', e.hom_inv_id], },\n    simp only [nat_trans.id_app, id_comp, comp_id, F.map_comp, assoc],\n    erw hF.counit_iso.hom.naturality,\n    slice_lhs 1 2 { rw functor_unit_iso_comp, },\n    simp only [functor.id_map, id_comp],\n  end }\n\n/-- Compatibility of `of_iso` with the composition of isomorphisms of functors -/\nlemma of_iso_trans {F G H : C ⥤ D} (e : F ≅ G) (e' : G ≅ H) (hF : is_equivalence F) :\n  (of_iso e' (of_iso e hF)) = of_iso (e ≪≫ e') hF :=\nbegin\n  dsimp [of_iso],\n  congr' 1; ext X; dsimp [nat_iso.hcomp],\n  { simp only [id_comp, assoc, functor.map_comp], },\n  { simp only [functor.map_id, comp_id, id_comp, assoc], },\nend\n\n/-- Compatibility of `of_iso` with identity isomorphisms of functors -/\nlemma of_iso_refl (F : C ⥤ D) (hF : is_equivalence F) : of_iso (iso.refl F) hF = hF :=\nbegin\n  unfreezingI { rcases hF with ⟨Finv, Funit, Fcounit, Fcomp⟩, },\n  dsimp [of_iso],\n  congr' 1; ext X; dsimp [nat_iso.hcomp],\n  { simp only [comp_id, map_id], },\n  { simp only [id_comp, map_id], },\nend\n\n/-- When `F` and `G` are two isomorphic functors, then `F` is an equivalence iff `G` is. -/\n@[simps]\ndef equiv_of_iso {F G : C ⥤ D} (e : F ≅ G) : is_equivalence F ≃ is_equivalence G :=\n{ to_fun := of_iso e,\n  inv_fun := of_iso e.symm,\n  left_inv := λ hF, by rw [of_iso_trans, iso.self_symm_id, of_iso_refl],\n  right_inv := λ hF, by rw [of_iso_trans, iso.symm_self_id, of_iso_refl], }\n\n/-- If `G` and `F ⋙ G` are equivalence of categories, then `F` is also an equivalence. -/\n@[simp]\ndef cancel_comp_right {E : Type*} [category E]\n  (F : C ⥤ D) (G : D ⥤ E) (hG : is_equivalence G) (hGF : is_equivalence (F ⋙ G)) :\n  is_equivalence F :=\nof_iso ((functor.associator F G G.inv) ≪≫ nat_iso.hcomp (iso.refl F) hG.unit_iso.symm ≪≫\n  right_unitor F) (functor.is_equivalence_trans (F ⋙ G) (G.inv))\n\n/-- If `F` and `F ⋙ G` are equivalence of categories, then `G` is also an equivalence. -/\n@[simp]\ndef cancel_comp_left {E : Type*} [category E]\n  (F : C ⥤ D) (G : D ⥤ E) (hF : is_equivalence F) (hGF : is_equivalence (F ⋙ G)) :\n  is_equivalence G :=\nof_iso ((functor.associator F.inv F G).symm ≪≫ nat_iso.hcomp hF.counit_iso (iso.refl G) ≪≫\n  left_unitor G) (functor.is_equivalence_trans F.inv (F ⋙ G))\n\nend is_equivalence\n\nnamespace equivalence\n\n/--\nAn equivalence is essentially surjective.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\nlemma ess_surj_of_equivalence (F : C ⥤ D) [is_equivalence F] : ess_surj F :=\n⟨λ Y, ⟨F.inv.obj Y, ⟨F.as_equivalence.counit_iso.app Y⟩⟩⟩\n\n/--\nAn equivalence is faithful.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\n@[priority 100] -- see Note [lower instance priority]\ninstance faithful_of_equivalence (F : C ⥤ D) [is_equivalence F] : faithful F :=\n{ map_injective' := λ X Y f g w,\n  begin\n    have p := congr_arg (@category_theory.functor.map _ _ _ _ F.inv _ _) w,\n    simpa only [cancel_epi, cancel_mono, is_equivalence.inv_fun_map] using p\n  end }.\n\n/--\nAn equivalence is full.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\n@[priority 100] -- see Note [lower instance priority]\ninstance full_of_equivalence (F : C ⥤ D) [is_equivalence F] : full F :=\n{ preimage := λ X Y f, F.as_equivalence.unit.app X ≫ F.inv.map f ≫ F.as_equivalence.unit_inv.app Y,\n  witness' := λ X Y f, F.inv.map_injective $\n  by simpa only [is_equivalence.inv_fun_map, assoc, iso.inv_hom_id_app_assoc, iso.inv_hom_id_app]\n    using comp_id _ }\n\n@[simps] private noncomputable def equivalence_inverse (F : C ⥤ D) [full F] [faithful F]\n  [ess_surj F] : D ⥤ C :=\n{ obj  := λ X, F.obj_preimage X,\n  map := λ X Y f, F.preimage ((F.obj_obj_preimage_iso X).hom ≫ f ≫ (F.obj_obj_preimage_iso Y).inv),\n  map_id' := λ X, begin apply F.map_injective, tidy end,\n  map_comp' := λ X Y Z f g, by apply F.map_injective; simp }\n\n/--\nA functor which is full, faithful, and essentially surjective is an equivalence.\n\nSee https://stacks.math.columbia.edu/tag/02C3.\n-/\nnoncomputable def of_fully_faithfully_ess_surj\n  (F : C ⥤ D) [full F] [faithful F] [ess_surj F] : is_equivalence F :=\nis_equivalence.mk (equivalence_inverse F)\n  (nat_iso.of_components\n    (λ X, (preimage_iso $ F.obj_obj_preimage_iso $ F.obj X).symm)\n    (λ X Y f, by { apply F.map_injective, obviously }))\n  (nat_iso.of_components F.obj_obj_preimage_iso (by tidy))\n\n@[simp] lemma functor_map_inj_iff (e : C ≌ D) {X Y : C} (f g : X ⟶ Y) :\n  e.functor.map f = e.functor.map g ↔ f = g :=\n⟨λ h, e.functor.map_injective h, λ h, h ▸ rfl⟩\n\n@[simp] lemma inverse_map_inj_iff (e : C ≌ D) {X Y : D} (f g : X ⟶ Y) :\n  e.inverse.map f = e.inverse.map g ↔ f = g :=\nfunctor_map_inj_iff e.symm f g\n\ninstance ess_surj_induced_functor {C' : Type*} (e : C' ≃ D) : ess_surj (induced_functor e) :=\n{ mem_ess_image := λ Y, ⟨e.symm Y, by simp⟩, }\n\nnoncomputable\ninstance induced_functor_of_equiv {C' : Type*} (e : C' ≃ D) : is_equivalence (induced_functor e) :=\nequivalence.of_fully_faithfully_ess_surj _\n\nnoncomputable\ninstance fully_faithful_to_ess_image (F : C ⥤ D) [full F] [faithful F] :\n  is_equivalence F.to_ess_image :=\nof_fully_faithfully_ess_surj F.to_ess_image\n\nend equivalence\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/equivalence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.480255553350542}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Johannes Hölzl, Yury Kudryashov\n-/\nimport algebra.category.Group.basic\nimport data.equiv.ring\n\n/-!\n# Category instances for semiring, ring, comm_semiring, and comm_ring.\n\nWe introduce the bundled categories:\n* `SemiRing`\n* `Ring`\n* `CommSemiRing`\n* `CommRing`\nalong with the relevant forgetful functors between them.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of semirings. -/\ndef SemiRing : Type (u+1) := bundled semiring\n\nnamespace SemiRing\n\ninstance bundled_hom : bundled_hom @ring_hom :=\n⟨@ring_hom.to_fun, @ring_hom.id, @ring_hom.comp, @ring_hom.coe_inj⟩\n\nattribute [derive [has_coe_to_sort, large_category, concrete_category]] SemiRing\n\n/-- Construct a bundled SemiRing from the underlying type and typeclass. -/\ndef of (R : Type u) [semiring R] : SemiRing := bundled.of R\n\ninstance : inhabited SemiRing := ⟨of punit⟩\n\ninstance (R : SemiRing) : semiring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [semiring R] : (SemiRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_Mon : has_forget₂ SemiRing Mon :=\nbundled_hom.mk_has_forget₂\n  (λ R hR, @monoid_with_zero.to_monoid R (@semiring.to_monoid_with_zero R hR))\n  (λ R₁ R₂, ring_hom.to_monoid_hom) (λ _ _ _, rfl)\n\ninstance has_forget_to_AddCommMon : has_forget₂ SemiRing AddCommMon :=\n-- can't use bundled_hom.mk_has_forget₂, since AddCommMon is an induced category\n{ forget₂ :=\n  { obj := λ R, AddCommMon.of R,\n    map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }\n\nend SemiRing\n\n/-- The category of rings. -/\ndef Ring : Type (u+1) := bundled ring\n\nnamespace Ring\n\ninstance : bundled_hom.parent_projection @ring.to_semiring := ⟨⟩\n\nattribute [derive [has_coe_to_sort, large_category, concrete_category]] Ring\n\n/-- Construct a bundled Ring from the underlying type and typeclass. -/\ndef of (R : Type u) [ring R] : Ring := bundled.of R\n\ninstance : inhabited Ring := ⟨of punit⟩\n\ninstance (R : Ring) : ring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [ring R] : (Ring.of R : Type u) = R := rfl\n\ninstance has_forget_to_SemiRing : has_forget₂ Ring SemiRing := bundled_hom.forget₂ _ _\ninstance has_forget_to_AddCommGroup : has_forget₂ Ring AddCommGroup :=\n-- can't use bundled_hom.mk_has_forget₂, since AddCommGroup is an induced category\n{ forget₂ :=\n  { obj := λ R, AddCommGroup.of R,\n    map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }\n\nend Ring\n\n/-- The category of commutative semirings. -/\ndef CommSemiRing : Type (u+1) := bundled comm_semiring\n\nnamespace CommSemiRing\n\ninstance : bundled_hom.parent_projection @comm_semiring.to_semiring := ⟨⟩\n\nattribute [derive [has_coe_to_sort, large_category, concrete_category]] CommSemiRing\n\n/-- Construct a bundled CommSemiRing from the underlying type and typeclass. -/\ndef of (R : Type u) [comm_semiring R] : CommSemiRing := bundled.of R\n\ninstance : inhabited CommSemiRing := ⟨of punit⟩\n\ninstance (R : CommSemiRing) : comm_semiring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [comm_semiring R] : (CommSemiRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_SemiRing : has_forget₂ CommSemiRing SemiRing := bundled_hom.forget₂ _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommMon : has_forget₂ CommSemiRing CommMon :=\nhas_forget₂.mk'\n  (λ R : CommSemiRing, CommMon.of R) (λ R, rfl)\n  (λ R₁ R₂ f, f.to_monoid_hom) (by tidy)\n\nend CommSemiRing\n\n/-- The category of commutative rings. -/\ndef CommRing : Type (u+1) := bundled comm_ring\n\nnamespace CommRing\n\ninstance : bundled_hom.parent_projection @comm_ring.to_ring := ⟨⟩\n\nattribute [derive [has_coe_to_sort, large_category, concrete_category]] CommRing\n\n/-- Construct a bundled CommRing from the underlying type and typeclass. -/\ndef of (R : Type u) [comm_ring R] : CommRing := bundled.of R\n\ninstance : inhabited CommRing := ⟨of punit⟩\n\ninstance (R : CommRing) : comm_ring R := R.str\n\n@[simp] lemma coe_of (R : Type u) [comm_ring R] : (CommRing.of R : Type u) = R := rfl\n\ninstance has_forget_to_Ring : has_forget₂ CommRing Ring := bundled_hom.forget₂ _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommSemiRing : has_forget₂ CommRing CommSemiRing :=\nhas_forget₂.mk' (λ R : CommRing, CommSemiRing.of R) (λ R, rfl) (λ R₁ R₂ f, f) (by tidy)\n\ninstance : full (forget₂ CommRing CommSemiRing) :=\n{ preimage := λ X Y f, f, }\n\nend CommRing\n\n-- This example verifies an improvement possible in Lean 3.8.\n-- Before that, to have `add_ring_hom.map_zero` usable by `simp` here,\n-- we had to mark all the concrete category `has_coe_to_sort` instances reducible.\n-- Now, it just works.\nexample {R S : CommRing} (i : R ⟶ S) (r : R) (h : r = 0) : i r = 0 :=\nby simp [h]\n\nnamespace ring_equiv\n\nvariables {X Y : Type u}\n\n/-- Build an isomorphism in the category `Ring` from a `ring_equiv` between `ring`s. -/\n@[simps] def to_Ring_iso [ring X] [ring Y] (e : X ≃+* Y) : Ring.of X ≅ Ring.of Y :=\n{ hom := e.to_ring_hom,\n  inv := e.symm.to_ring_hom }\n\n/-- Build an isomorphism in the category `CommRing` from a `ring_equiv` between `comm_ring`s. -/\n@[simps] def to_CommRing_iso [comm_ring X] [comm_ring Y] (e : X ≃+* Y) :\n  CommRing.of X ≅ CommRing.of Y :=\n{ hom := e.to_ring_hom,\n  inv := e.symm.to_ring_hom }\n\nend ring_equiv\n\nnamespace category_theory.iso\n\n/-- Build a `ring_equiv` from an isomorphism in the category `Ring`. -/\ndef Ring_iso_to_ring_equiv {X Y : Ring} (i : X ≅ Y) : X ≃+* Y :=\n{ to_fun    := i.hom,\n  inv_fun   := i.inv,\n  left_inv  := by tidy,\n  right_inv := by tidy,\n  map_add'  := by tidy,\n  map_mul'  := by tidy }.\n\n/-- Build a `ring_equiv` from an isomorphism in the category `CommRing`. -/\ndef CommRing_iso_to_ring_equiv {X Y : CommRing} (i : X ≅ Y) : X ≃+* Y :=\n{ to_fun    := i.hom,\n  inv_fun   := i.inv,\n  left_inv  := by tidy,\n  right_inv := by tidy,\n  map_add'  := by tidy,\n  map_mul'  := by tidy }.\n\nend category_theory.iso\n\n/-- Ring equivalences between `ring`s are the same as (isomorphic to) isomorphisms in `Ring`. -/\ndef ring_equiv_iso_Ring_iso {X Y : Type u} [ring X] [ring Y] :\n  (X ≃+* Y) ≅ (Ring.of X ≅ Ring.of Y) :=\n{ hom := λ e, e.to_Ring_iso,\n  inv := λ i, i.Ring_iso_to_ring_equiv, }\n\n/-- Ring equivalences between `comm_ring`s are the same as (isomorphic to) isomorphisms\nin `CommRing`. -/\ndef ring_equiv_iso_CommRing_iso {X Y : Type u} [comm_ring X] [comm_ring Y] :\n  (X ≃+* Y) ≅ (CommRing.of X ≅ CommRing.of Y) :=\n{ hom := λ e, e.to_CommRing_iso,\n  inv := λ i, i.CommRing_iso_to_ring_equiv, }\n\ninstance Ring.forget_reflects_isos : reflects_isomorphisms (forget Ring.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Ring).map f),\n    let e : X ≃+* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Ring_iso).1⟩,\n  end }\n\ninstance CommRing.forget_reflects_isos : reflects_isomorphisms (forget CommRing.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommRing).map f),\n    let e : X ≃+* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommRing_iso).1⟩,\n  end }\n\nexample : reflects_isomorphisms (forget₂ Ring AddCommGroup) := by apply_instance\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/category/CommRing/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105587468141, "lm_q2_score": 0.721743200312399, "lm_q1q2_score": 0.4802555461915872}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\n\nimport data.prod.tprod\nimport group_theory.coset\nimport logic.equiv.fin\nimport measure_theory.measurable_space_def\nimport order.filter.small_sets\nimport order.liminf_limsup\nimport measure_theory.tactic\n\n/-!\n# Measurable spaces and measurable functions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides properties of measurable spaces and the functions and isomorphisms\nbetween them. The definition of a measurable space is in `measure_theory.measurable_space_def`.\n\nA measurable space is a set equipped with a σ-algebra, a collection of\nsubsets closed under complementation and countable union. A function\nbetween measurable spaces is measurable if the preimage of each\nmeasurable subset is measurable.\n\nσ-algebras on a fixed set `α` form a complete lattice. Here we order\nσ-algebras by writing `m₁ ≤ m₂` if every set which is `m₁`-measurable is\nalso `m₂`-measurable (that is, `m₁` is a subset of `m₂`). In particular, any\ncollection of subsets of `α` generates a smallest σ-algebra which\ncontains all of them. A function `f : α → β` induces a Galois connection\nbetween the lattices of σ-algebras on `α` and `β`.\n\nA measurable equivalence between measurable spaces is an equivalence\nwhich respects the σ-algebras, that is, for which both directions of\nthe equivalence are measurable functions.\n\nWe say that a filter `f` is measurably generated if every set `s ∈ f` includes a measurable\nset `t ∈ f`. This property is useful, e.g., to extract a measurable witness of `filter.eventually`.\n\n## Notation\n\n* We write `α ≃ᵐ β` for measurable equivalences between the measurable spaces `α` and `β`.\n  This should not be confused with `≃ₘ` which is used for diffeomorphisms between manifolds.\n\n## Implementation notes\n\nMeasurability of a function `f : α → β` between measurable spaces is\ndefined in terms of the Galois connection induced by f.\n\n## References\n\n* <https://en.wikipedia.org/wiki/Measurable_space>\n* <https://en.wikipedia.org/wiki/Sigma-algebra>\n* <https://en.wikipedia.org/wiki/Dynkin_system>\n\n## Tags\n\nmeasurable space, σ-algebra, measurable function, measurable equivalence, dynkin system,\nπ-λ theorem, π-system\n-/\n\nopen set encodable function equiv\nopen_locale filter measure_theory\n\n\nvariables {α β γ δ δ' : Type*} {ι : Sort*} {s t u : set α}\n\n\nnamespace measurable_space\n\nsection functors\nvariables {m m₁ m₂ : measurable_space α} {m' : measurable_space β} {f : α → β} {g : β → α}\n\n/-- The forward image of a measurable space under a function. `map f m` contains the sets\n  `s : set β` whose preimage under `f` is measurable. -/\nprotected def map (f : α → β) (m : measurable_space α) : measurable_space β :=\n{ measurable_set'      := λ s, measurable_set[m] $ f ⁻¹' s,\n  measurable_set_empty := m.measurable_set_empty,\n  measurable_set_compl := assume s hs, m.measurable_set_compl _ hs,\n  measurable_set_Union := assume f hf, by { rw preimage_Union, exact m.measurable_set_Union _ hf }}\n\n@[simp] lemma map_id : m.map id = m :=\nmeasurable_space.ext $ assume s, iff.rfl\n\n@[simp] lemma map_comp {f : α → β} {g : β → γ} : (m.map f).map g = m.map (g ∘ f) :=\nmeasurable_space.ext $ assume s, iff.rfl\n\n/-- The reverse image of a measurable space under a function. `comap f m` contains the sets\n  `s : set α` such that `s` is the `f`-preimage of a measurable set in `β`. -/\nprotected def comap (f : α → β) (m : measurable_space β) : measurable_space α :=\n{ measurable_set'      := λ s, ∃s', measurable_set[m] s' ∧ f ⁻¹' s' = s,\n  measurable_set_empty := ⟨∅, m.measurable_set_empty, rfl⟩,\n  measurable_set_compl := assume s ⟨s', h₁, h₂⟩, ⟨s'ᶜ, m.measurable_set_compl _ h₁, h₂ ▸ rfl⟩,\n  measurable_set_Union := assume s hs,\n    let ⟨s', hs'⟩ := classical.axiom_of_choice hs in\n    ⟨⋃ i, s' i, m.measurable_set_Union _ (λ i, (hs' i).left), by simp [hs'] ⟩ }\n\nlemma comap_eq_generate_from (m : measurable_space β) (f : α → β) :\n  m.comap f = generate_from {t | ∃ s, measurable_set s ∧ f ⁻¹' s = t} :=\nby convert generate_from_measurable_set.symm\n\n@[simp] lemma comap_id : m.comap id = m :=\nmeasurable_space.ext $ assume s, ⟨assume ⟨s', hs', h⟩, h ▸ hs', assume h, ⟨s, h, rfl⟩⟩\n\n@[simp] lemma comap_comp {f : β → α} {g : γ → β} : (m.comap f).comap g = m.comap (f ∘ g) :=\nmeasurable_space.ext $ assume s,\n  ⟨assume ⟨t, ⟨u, h, hu⟩, ht⟩, ⟨u, h, ht ▸ hu ▸ rfl⟩, assume ⟨t, h, ht⟩, ⟨f ⁻¹' t, ⟨_, h, rfl⟩, ht⟩⟩\n\nlemma comap_le_iff_le_map {f : α → β} : m'.comap f ≤ m ↔ m' ≤ m.map f :=\n⟨assume h s hs, h _ ⟨_, hs, rfl⟩, assume h s ⟨t, ht, heq⟩, heq ▸ h _ ht⟩\n\nlemma gc_comap_map (f : α → β) :\n  galois_connection (measurable_space.comap f) (measurable_space.map f) :=\nassume f g, comap_le_iff_le_map\n\nlemma map_mono (h : m₁ ≤ m₂) : m₁.map f ≤ m₂.map f := (gc_comap_map f).monotone_u h\nlemma monotone_map : monotone (measurable_space.map f) := assume a b h, map_mono h\nlemma comap_mono (h : m₁ ≤ m₂) : m₁.comap g ≤ m₂.comap g := (gc_comap_map g).monotone_l h\nlemma monotone_comap : monotone (measurable_space.comap g) := assume a b h, comap_mono h\n\n@[simp] lemma comap_bot : (⊥ : measurable_space α).comap g = ⊥ := (gc_comap_map g).l_bot\n@[simp] lemma comap_sup : (m₁ ⊔ m₂).comap g = m₁.comap g ⊔ m₂.comap g := (gc_comap_map g).l_sup\n@[simp] lemma comap_supr {m : ι → measurable_space α} : (⨆i, m i).comap g = (⨆i, (m i).comap g) :=\n(gc_comap_map g).l_supr\n\n@[simp] lemma map_top : (⊤ : measurable_space α).map f = ⊤ := (gc_comap_map f).u_top\n@[simp] lemma map_inf : (m₁ ⊓ m₂).map f = m₁.map f ⊓ m₂.map f := (gc_comap_map f).u_inf\n@[simp] lemma map_infi {m : ι → measurable_space α} : (⨅i, m i).map f = (⨅i, (m i).map f) :=\n(gc_comap_map f).u_infi\n\nlemma comap_map_le : (m.map f).comap f ≤ m := (gc_comap_map f).l_u_le _\nlemma le_map_comap : m ≤ (m.comap g).map g := (gc_comap_map g).le_u_l _\n\nend functors\n\nlemma comap_generate_from {f : α → β} {s : set (set β)} :\n  (generate_from s).comap f = generate_from (preimage f '' s) :=\nle_antisymm\n  (comap_le_iff_le_map.2 $ generate_from_le $ assume t hts,\n    generate_measurable.basic _ $ mem_image_of_mem _ $ hts)\n  (generate_from_le $ assume t ⟨u, hu, eq⟩, eq ▸ ⟨u, generate_measurable.basic _ hu, rfl⟩)\n\nend measurable_space\n\nsection measurable_functions\nopen measurable_space\n\nlemma measurable_iff_le_map {m₁ : measurable_space α} {m₂ : measurable_space β} {f : α → β} :\n  measurable f ↔ m₂ ≤ m₁.map f :=\niff.rfl\n\nalias measurable_iff_le_map ↔ measurable.le_map measurable.of_le_map\n\nlemma measurable_iff_comap_le {m₁ : measurable_space α} {m₂ : measurable_space β} {f : α → β} :\n  measurable f ↔ m₂.comap f ≤ m₁ :=\ncomap_le_iff_le_map.symm\n\nalias measurable_iff_comap_le ↔ measurable.comap_le measurable.of_comap_le\n\nlemma comap_measurable {m : measurable_space β} (f : α → β) :\n  measurable[m.comap f] f :=\nλ s hs, ⟨s, hs, rfl⟩\n\nlemma measurable.mono {ma ma' : measurable_space α} {mb mb' : measurable_space β} {f : α → β}\n  (hf : @measurable α β ma mb f) (ha : ma ≤ ma') (hb : mb' ≤ mb) :\n  @measurable α β ma' mb' f :=\nλ t ht, ha _ $ hf $ hb _ ht\n\n@[measurability]\nlemma measurable_from_top [measurable_space β] {f : α → β} : measurable[⊤] f :=\nλ s hs, trivial\n\nlemma measurable_generate_from [measurable_space α] {s : set (set β)} {f : α → β}\n  (h : ∀ t ∈ s, measurable_set (f ⁻¹' t)) : @measurable _ _ _ (generate_from s) f :=\nmeasurable.of_le_map $ generate_from_le h\n\nvariables {f g : α → β}\n\nsection typeclass_measurable_space\nvariables [measurable_space α] [measurable_space β] [measurable_space γ]\n\n@[nontriviality, measurability]\nlemma subsingleton.measurable [subsingleton α] : measurable f :=\nλ s hs, @subsingleton.measurable_set α _ _ _\n\n@[nontriviality, measurability]\nlemma measurable_of_subsingleton_codomain [subsingleton β] (f : α → β) :\n  measurable f :=\nλ s hs, subsingleton.set_cases measurable_set.empty measurable_set.univ s\n\n@[to_additive]\nlemma measurable_one [has_one α] : measurable (1 : β → α) := @measurable_const _ _ _ _ 1\n\nlemma measurable_of_empty [is_empty α] (f : α → β) : measurable f :=\nsubsingleton.measurable\n\nlemma measurable_of_empty_codomain [is_empty β] (f : α → β) : measurable f :=\nby { haveI := function.is_empty f, exact measurable_of_empty f }\n\n/-- A version of `measurable_const` that assumes `f x = f y` for all `x, y`. This version works\nfor functions between empty types. -/\nlemma measurable_const' {f : β → α} (hf : ∀ x y, f x = f y) : measurable f :=\nbegin\n  casesI is_empty_or_nonempty β,\n  { exact measurable_of_empty f },\n  { convert measurable_const, exact funext (λ x, hf x h.some) }\nend\n\nlemma measurable_of_finite [finite α] [measurable_singleton_class α] (f : α → β) : measurable f :=\nλ s hs, (f ⁻¹' s).to_finite.measurable_set\n\nlemma measurable_of_countable [countable α] [measurable_singleton_class α] (f : α → β) :\n  measurable f :=\nλ s hs, (f ⁻¹' s).to_countable.measurable_set\n\nend typeclass_measurable_space\n\nvariables {m : measurable_space α}\ninclude m\n\n@[measurability] lemma measurable.iterate {f : α → α} (hf : measurable f) : ∀ n, measurable (f^[n])\n| 0 := measurable_id\n| (n+1) := (measurable.iterate n).comp hf\n\nvariables {mβ : measurable_space β}\ninclude mβ\n\n@[measurability]\nlemma measurable_set_preimage {t : set β} (hf : measurable f) (ht : measurable_set t) :\n  measurable_set (f ⁻¹' t) :=\nhf ht\n\n@[measurability]\nlemma measurable.piecewise {_ : decidable_pred (∈ s)} (hs : measurable_set s)\n  (hf : measurable f) (hg : measurable g) :\n  measurable (piecewise s f g) :=\nbegin\n  intros t ht,\n  rw piecewise_preimage,\n  exact hs.ite (hf ht) (hg ht)\nend\n\n/-- this is slightly different from `measurable.piecewise`. It can be used to show\n`measurable (ite (x=0) 0 1)` by\n`exact measurable.ite (measurable_set_singleton 0) measurable_const measurable_const`,\nbut replacing `measurable.ite` by `measurable.piecewise` in that example proof does not work. -/\nlemma measurable.ite {p : α → Prop} {_ : decidable_pred p}\n  (hp : measurable_set {a : α | p a}) (hf : measurable f) (hg : measurable g) :\n  measurable (λ x, ite (p x) (f x) (g x)) :=\nmeasurable.piecewise hp hf hg\n\n@[measurability]\nlemma measurable.indicator [has_zero β] (hf : measurable f) (hs : measurable_set s) :\n  measurable (s.indicator f) :=\nhf.piecewise hs measurable_const\n\n@[measurability, to_additive] lemma measurable_set_mul_support [has_one β]\n  [measurable_singleton_class β] (hf : measurable f) :\n  measurable_set (mul_support f) :=\nhf (measurable_set_singleton 1).compl\n\n/-- If a function coincides with a measurable function outside of a countable set, it is\nmeasurable. -/\nlemma measurable.measurable_of_countable_ne [measurable_singleton_class α]\n  (hf : measurable f) (h : set.countable {x | f x ≠ g x}) : measurable g :=\nbegin\n  assume t ht,\n  have : g ⁻¹' t = (g ⁻¹' t ∩ {x | f x = g x}ᶜ) ∪ (g ⁻¹' t ∩ {x | f x = g x}),\n    by simp [← inter_union_distrib_left],\n  rw this,\n  apply measurable_set.union (h.mono (inter_subset_right _ _)).measurable_set,\n  have : g ⁻¹' t ∩ {x : α | f x = g x} = f ⁻¹' t ∩ {x : α | f x = g x},\n    by { ext x, simp {contextual := tt} },\n  rw this,\n  exact (hf ht).inter h.measurable_set.of_compl,\nend\n\nend measurable_functions\n\nsection constructions\n\ninstance : measurable_space empty := ⊤\ninstance : measurable_space punit := ⊤ -- this also works for `unit`\ninstance : measurable_space bool := ⊤\ninstance : measurable_space ℕ := ⊤\ninstance : measurable_space ℤ := ⊤\ninstance : measurable_space ℚ := ⊤\n\ninstance : measurable_singleton_class empty := ⟨λ _, trivial⟩\ninstance : measurable_singleton_class punit := ⟨λ _, trivial⟩\ninstance : measurable_singleton_class bool := ⟨λ _, trivial⟩\ninstance : measurable_singleton_class ℕ := ⟨λ _, trivial⟩\ninstance : measurable_singleton_class ℤ := ⟨λ _, trivial⟩\ninstance : measurable_singleton_class ℚ := ⟨λ _, trivial⟩\n\nlemma measurable_to_countable [measurable_space α] [countable α] [measurable_space β] {f : β → α}\n  (h : ∀ y, measurable_set (f ⁻¹' {f y})) :\n  measurable f :=\nbegin\n  assume s hs,\n  rw [← bUnion_preimage_singleton],\n  refine measurable_set.Union (λ y, measurable_set.Union $ λ hy, _),\n  by_cases hyf : y ∈ range f,\n  { rcases hyf with ⟨y, rfl⟩,\n    apply h },\n  { simp only [preimage_singleton_eq_empty.2 hyf, measurable_set.empty] }\nend\n\n@[measurability] lemma measurable_unit [measurable_space α] (f : unit → α) : measurable f :=\nmeasurable_from_top\n\nsection nat\nvariables [measurable_space α]\n\n@[measurability] lemma measurable_from_nat {f : ℕ → α} : measurable f :=\nmeasurable_from_top\n\nlemma measurable_to_nat {f : α → ℕ} : (∀ y, measurable_set (f ⁻¹' {f y})) → measurable f :=\nmeasurable_to_countable\n\nlemma measurable_find_greatest' {p : α → ℕ → Prop} [∀ x, decidable_pred (p x)]\n  {N : ℕ} (hN : ∀ k ≤ N, measurable_set {x | nat.find_greatest (p x) N = k}) :\n  measurable (λ x, nat.find_greatest (p x) N) :=\nmeasurable_to_nat $ λ x, hN _ N.find_greatest_le\n\nlemma measurable_find_greatest {p : α → ℕ → Prop} [∀ x, decidable_pred (p x)]\n  {N} (hN : ∀ k ≤ N, measurable_set {x | p x k}) :\n  measurable (λ x, nat.find_greatest (p x) N) :=\nbegin\n  refine measurable_find_greatest' (λ k hk, _),\n  simp only [nat.find_greatest_eq_iff, set_of_and, set_of_forall, ← compl_set_of],\n  repeat { apply_rules [measurable_set.inter, measurable_set.const, measurable_set.Inter,\n    measurable_set.compl, hN]; try { intros } }\nend\n\nlemma measurable_find {p : α → ℕ → Prop} [∀ x, decidable_pred (p x)]\n  (hp : ∀ x, ∃ N, p x N) (hm : ∀ k, measurable_set {x | p x k}) :\n  measurable (λ x, nat.find (hp x)) :=\nbegin\n  refine measurable_to_nat (λ x, _),\n  rw [preimage_find_eq_disjointed],\n  exact measurable_set.disjointed hm _\nend\n\nend nat\n\nsection quotient\nvariables [measurable_space α] [measurable_space β]\n\ninstance {α} {r : α → α → Prop} [m : measurable_space α] : measurable_space (quot r) :=\nm.map (quot.mk r)\n\ninstance {α} {s : setoid α} [m : measurable_space α] : measurable_space (quotient s) :=\nm.map quotient.mk'\n\n@[to_additive]\ninstance _root_.quotient_group.measurable_space {G} [group G] [measurable_space G]\n  (S : subgroup G) : measurable_space (G ⧸ S) :=\nquotient.measurable_space\n\nlemma measurable_set_quotient {s : setoid α} {t : set (quotient s)} :\n  measurable_set t ↔ measurable_set (quotient.mk' ⁻¹' t) :=\niff.rfl\n\nlemma measurable_from_quotient {s : setoid α} {f : quotient s → β} :\n  measurable f ↔ measurable (f ∘ quotient.mk') :=\niff.rfl\n\n@[measurability] lemma measurable_quotient_mk [s : setoid α] :\n  measurable (quotient.mk : α → quotient s) :=\nλ s, id\n\n@[measurability] lemma measurable_quotient_mk' {s : setoid α} :\n  measurable (quotient.mk' : α → quotient s) :=\nλ s, id\n\n@[measurability] lemma measurable_quot_mk {r : α → α → Prop} :\n  measurable (quot.mk r) :=\nλ s, id\n\n@[to_additive] lemma quotient_group.measurable_coe {G} [group G] [measurable_space G]\n  {S : subgroup G} : measurable (coe : G → G ⧸ S) :=\nmeasurable_quotient_mk'\n\nattribute [measurability] quotient_group.measurable_coe quotient_add_group.measurable_coe\n\n@[to_additive] lemma quotient_group.measurable_from_quotient {G} [group G] [measurable_space G]\n  {S : subgroup G} {f : G ⧸ S → α} :\n  measurable f ↔ measurable (f ∘ (coe : G → G ⧸ S)) :=\nmeasurable_from_quotient\n\nend quotient\n\nsection subtype\n\ninstance {α} {p : α → Prop} [m : measurable_space α] : measurable_space (subtype p) :=\nm.comap (coe : _ → α)\n\nsection\nvariables [measurable_space α]\n\n@[measurability] lemma measurable_subtype_coe {p : α → Prop} : measurable (coe : subtype p → α) :=\nmeasurable_space.le_map_comap\n\ninstance {p : α → Prop} [measurable_singleton_class α] : measurable_singleton_class (subtype p) :=\n{ measurable_set_singleton := λ x,\n  begin\n    have : measurable_set {(x : α)} := measurable_set_singleton _,\n    convert @measurable_subtype_coe α _ p _ this,\n    ext y,\n    simp [subtype.ext_iff],\n  end }\n\nend\n\nvariables {m : measurable_space α} {mβ : measurable_space β}\n\ninclude m\n\nlemma measurable_set.subtype_image {s : set α} {t : set s}\n  (hs : measurable_set s) : measurable_set t → measurable_set ((coe : s → α) '' t)\n| ⟨u, (hu : measurable_set u), (eq : coe ⁻¹' u = t)⟩ :=\n  begin\n    rw [← eq, subtype.image_preimage_coe],\n    exact hu.inter hs\n  end\n\ninclude mβ\n\n@[measurability] lemma measurable.subtype_coe {p : β → Prop} {f : α → subtype p}\n  (hf : measurable f) :\n  measurable (λ a : α, (f a : β)) :=\nmeasurable_subtype_coe.comp hf\n\n@[measurability]\nlemma measurable.subtype_mk {p : β → Prop} {f : α → β} (hf : measurable f) {h : ∀ x, p (f x)} :\n  measurable (λ x, (⟨f x, h x⟩ : subtype p)) :=\nλ t ⟨s, hs⟩, hs.2 ▸ by simp only [← preimage_comp, (∘), subtype.coe_mk, hf hs.1]\n\nlemma measurable_of_measurable_union_cover\n  {f : α → β} (s t : set α) (hs : measurable_set s) (ht : measurable_set t) (h : univ ⊆ s ∪ t)\n  (hc : measurable (λ a : s, f a)) (hd : measurable (λ a : t, f a)) :\n  measurable f :=\nbegin\n  intros u hu,\n  convert (hs.subtype_image (hc hu)).union (ht.subtype_image (hd hu)),\n  change f ⁻¹' u = coe '' (coe ⁻¹' (f ⁻¹' u) : set s) ∪ coe '' (coe ⁻¹' (f ⁻¹' u) : set t),\n  rw [image_preimage_eq_inter_range, image_preimage_eq_inter_range, subtype.range_coe,\n      subtype.range_coe, ← inter_distrib_left, univ_subset_iff.1 h, inter_univ],\nend\n\nlemma measurable_of_restrict_of_restrict_compl {f : α → β} {s : set α}\n  (hs : measurable_set s) (h₁ : measurable (s.restrict f)) (h₂ : measurable (sᶜ.restrict f)) :\n  measurable f :=\nmeasurable_of_measurable_union_cover s sᶜ hs hs.compl (union_compl_self s).ge h₁ h₂\n\nlemma measurable.dite [∀ x, decidable (x ∈ s)] {f : s → β} (hf : measurable f)\n  {g : sᶜ → β} (hg : measurable g) (hs : measurable_set s) :\n  measurable (λ x, if hx : x ∈ s then f ⟨x, hx⟩ else g ⟨x, hx⟩) :=\nmeasurable_of_restrict_of_restrict_compl hs (by simpa) (by simpa)\n\nlemma measurable_of_measurable_on_compl_finite [measurable_singleton_class α]\n  {f : α → β} (s : set α) (hs : s.finite) (hf : measurable (sᶜ.restrict f)) :\n  measurable f :=\nbegin\n  letI : fintype s := finite.fintype hs,\n  exact measurable_of_restrict_of_restrict_compl hs.measurable_set\n    (measurable_of_finite _) hf\nend\n\nlemma measurable_of_measurable_on_compl_singleton [measurable_singleton_class α]\n  {f : α → β} (a : α) (hf : measurable ({x | x ≠ a}.restrict f)) :\n  measurable f :=\nmeasurable_of_measurable_on_compl_finite {a} (finite_singleton a) hf\n\n\nend subtype\n\nsection prod\n\n/-- A `measurable_space` structure on the product of two measurable spaces. -/\ndef measurable_space.prod {α β} (m₁ : measurable_space α) (m₂ : measurable_space β) :\n  measurable_space (α × β) :=\nm₁.comap prod.fst ⊔ m₂.comap prod.snd\n\ninstance {α β} [m₁ : measurable_space α] [m₂ : measurable_space β] : measurable_space (α × β) :=\nm₁.prod m₂\n\n@[measurability] lemma measurable_fst {ma : measurable_space α} {mb : measurable_space β} :\n  measurable (prod.fst : α × β → α) :=\nmeasurable.of_comap_le le_sup_left\n\n@[measurability] lemma measurable_snd {ma : measurable_space α} {mb : measurable_space β} :\n  measurable (prod.snd : α × β → β) :=\nmeasurable.of_comap_le le_sup_right\n\nvariables {m : measurable_space α} {mβ : measurable_space β} {mγ : measurable_space γ}\n\ninclude m mβ mγ\n\nlemma measurable.fst {f : α → β × γ} (hf : measurable f) :\n  measurable (λ a : α, (f a).1) :=\nmeasurable_fst.comp hf\n\nlemma measurable.snd {f : α → β × γ} (hf : measurable f) :\n  measurable (λ a : α, (f a).2) :=\nmeasurable_snd.comp hf\n\n@[measurability] lemma measurable.prod {f : α → β × γ}\n  (hf₁ : measurable (λ a, (f a).1)) (hf₂ : measurable (λ a, (f a).2)) : measurable f :=\nmeasurable.of_le_map $ sup_le\n  (by { rw [measurable_space.comap_le_iff_le_map, measurable_space.map_comp], exact hf₁ })\n  (by { rw [measurable_space.comap_le_iff_le_map, measurable_space.map_comp], exact hf₂ })\n\nlemma measurable.prod_mk {β γ} {mβ : measurable_space β}\n  {mγ : measurable_space γ} {f : α → β} {g : α → γ} (hf : measurable f) (hg : measurable g) :\n  measurable (λ a : α, (f a, g a)) :=\nmeasurable.prod hf hg\n\nlemma measurable.prod_map [measurable_space δ] {f : α → β} {g : γ → δ} (hf : measurable f)\n  (hg : measurable g) : measurable (prod.map f g) :=\n(hf.comp measurable_fst).prod_mk (hg.comp measurable_snd)\n\nomit mγ\n\nlemma measurable_prod_mk_left {x : α} : measurable (@prod.mk _ β x) :=\nmeasurable_const.prod_mk measurable_id\n\nlemma measurable_prod_mk_right {y : β} : measurable (λ x : α, (x, y)) :=\nmeasurable_id.prod_mk measurable_const\n\ninclude mγ\n\nlemma measurable.of_uncurry_left {f : α → β → γ} (hf : measurable (uncurry f)) {x : α} :\n  measurable (f x) :=\nhf.comp measurable_prod_mk_left\n\nlemma measurable.of_uncurry_right {f : α → β → γ} (hf : measurable (uncurry f)) {y : β} :\n  measurable (λ x, f x y) :=\nhf.comp measurable_prod_mk_right\n\nlemma measurable_prod {f : α → β × γ} : measurable f ↔\n  measurable (λ a, (f a).1) ∧ measurable (λ a, (f a).2) :=\n⟨λ hf, ⟨measurable_fst.comp hf, measurable_snd.comp hf⟩, λ h, measurable.prod h.1 h.2⟩\n\nomit mγ\n\n@[measurability] lemma measurable_swap :\n  measurable (prod.swap : α × β → β × α) :=\nmeasurable.prod measurable_snd measurable_fst\n\nlemma measurable_swap_iff {mγ : measurable_space γ} {f : α × β → γ} :\n  measurable (f ∘ prod.swap) ↔ measurable f :=\n⟨λ hf, by { convert hf.comp measurable_swap, ext ⟨x, y⟩, refl }, λ hf, hf.comp measurable_swap⟩\n\n@[measurability]\nlemma measurable_set.prod {s : set α} {t : set β} (hs : measurable_set s) (ht : measurable_set t) :\n  measurable_set (s ×ˢ t) :=\nmeasurable_set.inter (measurable_fst hs) (measurable_snd ht)\n\nlemma measurable_set_prod_of_nonempty {s : set α} {t : set β} (h : (s ×ˢ t).nonempty) :\n  measurable_set (s ×ˢ t) ↔ measurable_set s ∧ measurable_set t :=\nbegin\n  rcases h with ⟨⟨x, y⟩, hx, hy⟩,\n  refine ⟨λ hst, _, λ h, h.1.prod h.2⟩,\n  have : measurable_set ((λ x, (x, y)) ⁻¹' s ×ˢ t) := measurable_prod_mk_right hst,\n  have : measurable_set (prod.mk x ⁻¹' s ×ˢ t) := measurable_prod_mk_left hst,\n  simp * at *\nend\n\nlemma measurable_set_prod {s : set α} {t : set β} :\n  measurable_set (s ×ˢ t) ↔ (measurable_set s ∧ measurable_set t) ∨ s = ∅ ∨ t = ∅ :=\nbegin\n  cases (s ×ˢ t).eq_empty_or_nonempty with h h,\n  { simp [h, prod_eq_empty_iff.mp h] },\n  { simp [←not_nonempty_iff_eq_empty, prod_nonempty_iff.mp h, measurable_set_prod_of_nonempty h] }\nend\n\nlemma measurable_set_swap_iff {s : set (α × β)} :\n  measurable_set (prod.swap ⁻¹' s) ↔ measurable_set s :=\n⟨λ hs, by { convert measurable_swap hs, ext ⟨x, y⟩, refl }, λ hs, measurable_swap hs⟩\n\ninstance [measurable_singleton_class α] [measurable_singleton_class β] :\n  measurable_singleton_class (α × β) :=\n⟨λ ⟨a, b⟩, @singleton_prod_singleton _ _ a b ▸\n  (measurable_set_singleton a).prod (measurable_set_singleton b)⟩\n\nlemma measurable_from_prod_countable [countable β] [measurable_singleton_class β]\n  {mγ : measurable_space γ} {f : α × β → γ} (hf : ∀ y, measurable (λ x, f (x, y))) :\n  measurable f :=\nbegin\n  intros s hs,\n  have : f ⁻¹' s = ⋃ y, ((λ x, f (x, y)) ⁻¹' s) ×ˢ ({y} : set β),\n  { ext1 ⟨x, y⟩,\n    simp [and_assoc, and.left_comm] },\n  rw this,\n  exact measurable_set.Union (λ y, (hf y hs).prod (measurable_set_singleton y))\nend\n\n/-- A piecewise function on countably many pieces is measurable if all the data is measurable. -/\n@[measurability]\nlemma measurable.find {m : measurable_space α}\n  {f : ℕ → α → β} {p : ℕ → α → Prop} [∀ n, decidable_pred (p n)]\n  (hf : ∀ n, measurable (f n)) (hp : ∀ n, measurable_set {x | p n x}) (h : ∀ x, ∃ n, p n x) :\n  measurable (λ x, f (nat.find (h x)) x) :=\nbegin\n  have : measurable (λ (p : α × ℕ), f p.2 p.1) := measurable_from_prod_countable (λ n, hf n),\n  exact this.comp (measurable.prod_mk measurable_id (measurable_find h hp)),\nend\n\n/-- Given countably many disjoint measurable sets `t n` and countably many measurable\nfunctions `g n`, one can construct a measurable function that coincides with `g n` on `t n`. -/\nlemma exists_measurable_piecewise_nat {m : measurable_space α} (t : ℕ → set β)\n  (t_meas : ∀ n, measurable_set (t n)) (t_disj : pairwise (disjoint on t))\n  (g : ℕ → β → α) (hg : ∀ n, measurable (g n)) :\n  ∃ f : β → α, measurable f ∧ (∀ n x, x ∈ t n → f x = g n x) :=\nbegin\n  classical,\n  let p : ℕ → β → Prop := λ n x, x ∈ t n ∪ (⋃ k, t k)ᶜ,\n  have M : ∀ n, measurable_set {x | p n x} :=\n    λ n, (t_meas n).union (measurable_set.compl (measurable_set.Union t_meas)),\n  have P : ∀ x, ∃ n, p n x,\n  { assume x,\n    by_cases H : ∀ (i : ℕ), x ∉ t i,\n    { exact ⟨0, or.inr (by simpa only [mem_Inter, compl_Union] using H)⟩ },\n    { simp only [not_forall, not_not_mem] at H,\n      rcases H with ⟨n, hn⟩,\n      exact ⟨n, or.inl hn⟩ } },\n  refine ⟨λ x, g (nat.find (P x)) x, measurable.find hg M P, _⟩,\n  assume n x hx,\n  have : x ∈ t (nat.find (P x)),\n  { have B : x ∈ t (nat.find (P x)) ∪ (⋃ k, t k)ᶜ := nat.find_spec (P x),\n    have B' : (∀ (i : ℕ), x ∉ t i) ↔ false,\n    { simp only [iff_false, not_forall, not_not_mem], exact ⟨n, hx⟩ },\n    simpa only [B', mem_union, mem_Inter, or_false, compl_Union, mem_compl_iff] using B },\n  congr,\n  by_contra h,\n  exact (t_disj (ne.symm h)).le_bot ⟨hx, this⟩\nend\n\nend prod\n\nsection pi\n\nvariables {π : δ → Type*} [measurable_space α]\n\ninstance measurable_space.pi [m : Π a, measurable_space (π a)] : measurable_space (Π a, π a) :=\n⨆ a, (m a).comap (λ b, b a)\n\nvariables [Π a, measurable_space (π a)] [measurable_space γ]\n\nlemma measurable_pi_iff {g : α → Π a, π a} :\n  measurable g ↔ ∀ a, measurable (λ x, g x a) :=\nby simp_rw [measurable_iff_comap_le, measurable_space.pi, measurable_space.comap_supr,\n    measurable_space.comap_comp, function.comp, supr_le_iff]\n\n@[measurability]\nlemma measurable_pi_apply (a : δ) : measurable (λ f : Π a, π a, f a) :=\nmeasurable.of_comap_le $ le_supr _ a\n\n@[measurability]\nlemma measurable.eval {a : δ} {g : α → Π a, π a}\n  (hg : measurable g) : measurable (λ x, g x a) :=\n(measurable_pi_apply a).comp hg\n\n@[measurability]\nlemma measurable_pi_lambda (f : α → Π a, π a) (hf : ∀ a, measurable (λ c, f c a)) :\n  measurable f :=\nmeasurable_pi_iff.mpr hf\n\n/-- The function `update f a : π a → Π a, π a` is always measurable.\n  This doesn't require `f` to be measurable.\n  This should not be confused with the statement that `update f a x` is measurable. -/\n@[measurability]\nlemma measurable_update (f : Π (a : δ), π a) {a : δ} [decidable_eq δ] : measurable (update f a) :=\nbegin\n  apply measurable_pi_lambda,\n  intro x, by_cases hx : x = a,\n  { cases hx, convert measurable_id, ext, simp },\n  simp_rw [update_noteq hx], apply measurable_const,\nend\n\n/- Even though we cannot use projection notation, we still keep a dot to be consistent with similar\n  lemmas, like `measurable_set.prod`. -/\n@[measurability]\nlemma measurable_set.pi {s : set δ} {t : Π i : δ, set (π i)} (hs : s.countable)\n  (ht : ∀ i ∈ s, measurable_set (t i)) :\n  measurable_set (s.pi t) :=\nby { rw [pi_def], exact measurable_set.bInter hs (λ i hi, measurable_pi_apply _ (ht i hi)) }\n\nlemma measurable_set.univ_pi [countable δ] {t : Π i : δ, set (π i)}\n  (ht : ∀ i, measurable_set (t i)) : measurable_set (pi univ t) :=\nmeasurable_set.pi (to_countable _) (λ i _, ht i)\n\nlemma measurable_set_pi_of_nonempty\n  {s : set δ} {t : Π i, set (π i)} (hs : s.countable)\n  (h : (pi s t).nonempty) : measurable_set (pi s t) ↔ ∀ i ∈ s, measurable_set (t i) :=\nbegin\n  classical,\n  rcases h with ⟨f, hf⟩, refine ⟨λ hst i hi, _, measurable_set.pi hs⟩,\n  convert measurable_update f hst, rw [update_preimage_pi hi], exact λ j hj _, hf j hj\nend\n\nlemma measurable_set_pi {s : set δ} {t : Π i, set (π i)} (hs : s.countable) :\n  measurable_set (pi s t) ↔ (∀ i ∈ s, measurable_set (t i)) ∨ pi s t = ∅ :=\nbegin\n  cases (pi s t).eq_empty_or_nonempty with h h,\n  { simp [h] },\n  { simp [measurable_set_pi_of_nonempty hs, h, ← not_nonempty_iff_eq_empty] }\nend\n\ninstance [countable δ] [Π a, measurable_singleton_class (π a)] :\n  measurable_singleton_class (Π a, π a) :=\n⟨λ f, univ_pi_singleton f ▸ measurable_set.univ_pi (λ t, measurable_set_singleton (f t))⟩\n\nvariable (π)\n\n@[measurability]\nlemma measurable_pi_equiv_pi_subtype_prod_symm (p : δ → Prop) [decidable_pred p] :\n  measurable (equiv.pi_equiv_pi_subtype_prod p π).symm :=\nbegin\n  apply measurable_pi_iff.2 (λ j, _),\n  by_cases hj : p j,\n  { simp only [hj, dif_pos, equiv.pi_equiv_pi_subtype_prod_symm_apply],\n    have : measurable (λ (f : (Π (i : {x // p x}), π ↑i)), f ⟨j, hj⟩) :=\n      measurable_pi_apply ⟨j, hj⟩,\n    exact measurable.comp this measurable_fst },\n  { simp only [hj, equiv.pi_equiv_pi_subtype_prod_symm_apply, dif_neg, not_false_iff],\n    have : measurable (λ (f : (Π (i : {x // ¬ p x}), π ↑i)), f ⟨j, hj⟩) :=\n      measurable_pi_apply ⟨j, hj⟩,\n    exact measurable.comp this measurable_snd }\nend\n\n@[measurability]\nlemma measurable_pi_equiv_pi_subtype_prod (p : δ → Prop) [decidable_pred p] :\n  measurable (equiv.pi_equiv_pi_subtype_prod p π) :=\nbegin\n  refine measurable_prod.2 _,\n  split;\n  { apply measurable_pi_iff.2 (λ j, _),\n    simp only [pi_equiv_pi_subtype_prod_apply, measurable_pi_apply] }\nend\n\nend pi\n\ninstance tprod.measurable_space (π : δ → Type*) [∀ x, measurable_space (π x)] :\n  ∀ (l : list δ), measurable_space (list.tprod π l)\n| []        := punit.measurable_space\n| (i :: is) := @prod.measurable_space _ _ _ (tprod.measurable_space is)\n\nsection tprod\n\nopen list\n\nvariables {π : δ → Type*} [∀ x, measurable_space (π x)]\n\nlemma measurable_tprod_mk (l : list δ) : measurable (@tprod.mk δ π l) :=\nbegin\n  induction l with i l ih,\n  { exact measurable_const },\n  { exact (measurable_pi_apply i).prod_mk ih }\nend\n\nlemma measurable_tprod_elim [decidable_eq δ] : ∀ {l : list δ} {i : δ} (hi : i ∈ l),\n  measurable (λ (v : tprod π l), v.elim hi)\n| (i :: is) j hj := begin\n  by_cases hji : j = i,\n  { subst hji, simp [measurable_fst] },\n  { rw [funext $ tprod.elim_of_ne _ hji],\n    exact (measurable_tprod_elim (hj.resolve_left hji)).comp measurable_snd }\nend\n\nlemma measurable_tprod_elim' [decidable_eq δ] {l : list δ} (h : ∀ i, i ∈ l) :\n  measurable (tprod.elim' h : tprod π l → Π i, π i) :=\nmeasurable_pi_lambda _ (λ i, measurable_tprod_elim (h i))\n\nlemma measurable_set.tprod (l : list δ) {s : ∀ i, set (π i)} (hs : ∀ i, measurable_set (s i)) :\n  measurable_set (set.tprod l s) :=\nby { induction l with i l ih, exact measurable_set.univ, exact (hs i).prod ih }\n\nend tprod\n\ninstance {α β} [m₁ : measurable_space α] [m₂ : measurable_space β] : measurable_space (α ⊕ β) :=\nm₁.map sum.inl ⊓ m₂.map sum.inr\n\nsection sum\n\n@[measurability] lemma measurable_inl [measurable_space α] [measurable_space β] :\n  measurable (@sum.inl α β) :=\nmeasurable.of_le_map inf_le_left\n\n@[measurability] lemma measurable_inr [measurable_space α] [measurable_space β] :\n  measurable (@sum.inr α β) :=\nmeasurable.of_le_map inf_le_right\n\nvariables {m : measurable_space α} {mβ : measurable_space β}\n\ninclude m mβ\n\nlemma measurable_sum {mγ : measurable_space γ} {f : α ⊕ β → γ}\n  (hl : measurable (f ∘ sum.inl)) (hr : measurable (f ∘ sum.inr)) : measurable f :=\nmeasurable.of_comap_le $ le_inf\n  (measurable_space.comap_le_iff_le_map.2 $ hl)\n  (measurable_space.comap_le_iff_le_map.2 $ hr)\n\n@[measurability]\nlemma measurable.sum_elim {mγ : measurable_space γ} {f : α → γ} {g : β → γ}\n  (hf : measurable f) (hg : measurable g) :\n  measurable (sum.elim f g) :=\nmeasurable_sum hf hg\n\nlemma measurable_set.inl_image {s : set α} (hs : measurable_set s) :\n  measurable_set (sum.inl '' s : set (α ⊕ β)) :=\n⟨show measurable_set (sum.inl ⁻¹' _), by { rwa [preimage_image_eq], exact (λ a b, sum.inl.inj) },\n  have sum.inr ⁻¹' (sum.inl '' s : set (α ⊕ β)) = ∅ :=\n    eq_empty_of_subset_empty $ assume x ⟨y, hy, eq⟩, by contradiction,\n  show measurable_set (sum.inr ⁻¹' _), by { rw [this], exact measurable_set.empty }⟩\n\nlemma measurable_set_inr_image {s : set β} (hs : measurable_set s) :\n  measurable_set (sum.inr '' s : set (α ⊕ β)) :=\n⟨ have sum.inl ⁻¹' (sum.inr '' s : set (α ⊕ β)) = ∅ :=\n    eq_empty_of_subset_empty $ assume x ⟨y, hy, eq⟩, by contradiction,\n  show measurable_set (sum.inl ⁻¹' _), by { rw [this], exact measurable_set.empty },\n  show measurable_set (sum.inr ⁻¹' _), by { rwa [preimage_image_eq], exact λ a b, sum.inr.inj }⟩\n\nomit m\n\nlemma measurable_set_range_inl [measurable_space α] :\n  measurable_set (range sum.inl : set (α ⊕ β)) :=\nby { rw [← image_univ], exact measurable_set.univ.inl_image }\n\nlemma measurable_set_range_inr [measurable_space α] :\n  measurable_set (range sum.inr : set (α ⊕ β)) :=\nby { rw [← image_univ], exact measurable_set_inr_image measurable_set.univ }\n\nend sum\n\ninstance {α} {β : α → Type*} [m : Πa, measurable_space (β a)] : measurable_space (sigma β) :=\n⨅a, (m a).map (sigma.mk a)\n\nend constructions\n\n/-- A map `f : α → β` is called a *measurable embedding* if it is injective, measurable, and sends\nmeasurable sets to measurable sets. The latter assumption can be replaced with “`f` has measurable\ninverse `g : range f → α`”, see `measurable_embedding.measurable_range_splitting`,\n`measurable_embedding.of_measurable_inverse_range`, and\n`measurable_embedding.of_measurable_inverse`.\n\nOne more interpretation: `f` is a measurable embedding if it defines a measurable equivalence to its\nrange and the range is a measurable set. One implication is formalized as\n`measurable_embedding.equiv_range`; the other one follows from\n`measurable_equiv.measurable_embedding`, `measurable_embedding.subtype_coe`, and\n`measurable_embedding.comp`. -/\n@[protect_proj]\nstructure measurable_embedding {α β : Type*} [measurable_space α] [measurable_space β] (f : α → β) :\n  Prop :=\n(injective : injective f)\n(measurable : measurable f)\n(measurable_set_image' : ∀ ⦃s⦄, measurable_set s → measurable_set (f '' s))\n\nnamespace measurable_embedding\n\nvariables {mα : measurable_space α} [measurable_space β] [measurable_space γ]\n  {f : α → β} {g : β → γ}\n\ninclude mα\n\nlemma measurable_set_image (hf : measurable_embedding f) {s : set α} :\n  measurable_set (f '' s) ↔ measurable_set s :=\n⟨λ h, by simpa only [hf.injective.preimage_image] using hf.measurable h,\n  λ h, hf.measurable_set_image' h⟩\n\nlemma id : measurable_embedding (id : α → α) :=\n⟨injective_id, measurable_id, λ s hs, by rwa image_id⟩\n\nlemma comp (hg : measurable_embedding g) (hf : measurable_embedding f) :\n  measurable_embedding (g ∘ f) :=\n⟨hg.injective.comp hf.injective, hg.measurable.comp hf.measurable,\n  λ s hs, by rwa [← image_image, hg.measurable_set_image, hf.measurable_set_image]⟩\n\nlemma subtype_coe {s : set α} (hs : measurable_set s) : measurable_embedding (coe : s → α) :=\n{ injective := subtype.coe_injective,\n  measurable := measurable_subtype_coe,\n  measurable_set_image' := λ _, measurable_set.subtype_image hs }\n\nlemma measurable_set_range (hf : measurable_embedding f) : measurable_set (range f) :=\nby { rw ← image_univ, exact hf.measurable_set_image' measurable_set.univ }\n\nlemma measurable_set_preimage (hf : measurable_embedding f) {s : set β} :\n  measurable_set (f ⁻¹' s) ↔ measurable_set (s ∩ range f) :=\nby rw [← image_preimage_eq_inter_range, hf.measurable_set_image]\n\nlemma measurable_range_splitting (hf : measurable_embedding f) :\n  measurable (range_splitting f) :=\nλ s hs, by rwa [preimage_range_splitting hf.injective,\n  ← (subtype_coe hf.measurable_set_range).measurable_set_image, ← image_comp,\n  coe_comp_range_factorization, hf.measurable_set_image]\n\nlemma measurable_extend (hf : measurable_embedding f) {g : α → γ} {g' : β → γ}\n  (hg : measurable g) (hg' : measurable g') :\n  measurable (extend f g g') :=\nbegin\n  refine measurable_of_restrict_of_restrict_compl hf.measurable_set_range _ _,\n  { rw restrict_extend_range,\n    simpa only [range_splitting] using hg.comp hf.measurable_range_splitting },\n  { rw restrict_extend_compl_range, exact hg'.comp measurable_subtype_coe }\nend\n\nlemma exists_measurable_extend (hf : measurable_embedding f) {g : α → γ} (hg : measurable g)\n  (hne : β → nonempty γ) :\n  ∃ g' : β → γ, measurable g' ∧ g' ∘ f = g :=\n⟨extend f g (λ x, classical.choice (hne x)),\n  hf.measurable_extend hg (measurable_const' $ λ _ _, rfl),\n  funext $ λ x, hf.injective.extend_apply _ _ _⟩\n\nlemma measurable_comp_iff (hg : measurable_embedding g) : measurable (g ∘ f) ↔ measurable f :=\nbegin\n  refine ⟨λ H, _, hg.measurable.comp⟩,\n  suffices : measurable ((range_splitting g ∘ range_factorization g) ∘ f),\n    by rwa [(right_inverse_range_splitting hg.injective).comp_eq_id] at this,\n  exact hg.measurable_range_splitting.comp H.subtype_mk\nend\n\nend measurable_embedding\n\nlemma measurable_set.exists_measurable_proj {m : measurable_space α} {s : set α}\n  (hs : measurable_set s) (hne : s.nonempty) : ∃ f : α → s, measurable f ∧ ∀ x : s, f x = x :=\nlet ⟨f, hfm, hf⟩ := (measurable_embedding.subtype_coe hs).exists_measurable_extend\n  measurable_id (λ _, hne.to_subtype)\nin ⟨f, hfm, congr_fun hf⟩\n\n/-- Equivalences between measurable spaces. Main application is the simplification of measurability\nstatements along measurable equivalences. -/\nstructure measurable_equiv (α β : Type*) [measurable_space α] [measurable_space β] extends α ≃ β :=\n(measurable_to_fun : measurable to_equiv)\n(measurable_inv_fun : measurable to_equiv.symm)\n\ninfix ` ≃ᵐ `:25 := measurable_equiv\n\nnamespace measurable_equiv\n\nvariables (α β) [measurable_space α] [measurable_space β] [measurable_space γ] [measurable_space δ]\n\ninstance : has_coe_to_fun (α ≃ᵐ β) (λ _, α → β) := ⟨λ e, e.to_fun⟩\n\nvariables {α β}\n\n@[simp] lemma coe_to_equiv (e : α ≃ᵐ β) : (e.to_equiv : α → β) = e := rfl\n\n@[measurability]\nprotected lemma measurable (e : α ≃ᵐ β) : measurable (e : α → β) :=\ne.measurable_to_fun\n\n@[simp] lemma coe_mk (e : α ≃ β) (h1 : measurable e) (h2 : measurable e.symm) :\n  ((⟨e, h1, h2⟩ : α ≃ᵐ β) : α → β) = e := rfl\n\n/-- Any measurable space is equivalent to itself. -/\ndef refl (α : Type*) [measurable_space α] : α ≃ᵐ α :=\n{ to_equiv := equiv.refl α,\n  measurable_to_fun := measurable_id, measurable_inv_fun := measurable_id }\n\ninstance : inhabited (α ≃ᵐ α) := ⟨refl α⟩\n\n/-- The composition of equivalences between measurable spaces. -/\ndef trans (ab : α ≃ᵐ β) (bc : β ≃ᵐ γ) :\n  α ≃ᵐ γ :=\n{ to_equiv := ab.to_equiv.trans bc.to_equiv,\n  measurable_to_fun := bc.measurable_to_fun.comp ab.measurable_to_fun,\n  measurable_inv_fun := ab.measurable_inv_fun.comp bc.measurable_inv_fun }\n\n/-- The inverse of an equivalence between measurable spaces. -/\ndef symm (ab : α ≃ᵐ β) : β ≃ᵐ α :=\n{ to_equiv := ab.to_equiv.symm,\n  measurable_to_fun := ab.measurable_inv_fun,\n  measurable_inv_fun := ab.measurable_to_fun }\n\n@[simp] lemma coe_to_equiv_symm (e : α ≃ᵐ β) : (e.to_equiv.symm : β → α) = e.symm := rfl\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : α ≃ᵐ β) : α → β := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : α ≃ᵐ β) : β → α := h.symm\n\ninitialize_simps_projections measurable_equiv\n  (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply)\n\nlemma to_equiv_injective : injective (to_equiv : (α ≃ᵐ β) → (α ≃ β)) :=\nby { rintro ⟨e₁, _, _⟩ ⟨e₂, _, _⟩ (rfl : e₁ = e₂), refl }\n\n@[ext] lemma ext {e₁ e₂ : α ≃ᵐ β} (h : (e₁ : α → β) = e₂) : e₁ = e₂ :=\nto_equiv_injective $ equiv.coe_fn_injective h\n\n@[simp] lemma symm_mk (e : α ≃ β) (h1 : measurable e) (h2 : measurable e.symm) :\n  (⟨e, h1, h2⟩ : α ≃ᵐ β).symm = ⟨e.symm, h2, h1⟩ := rfl\n\nattribute [simps apply to_equiv] trans refl\n\n@[simp] lemma symm_refl (α : Type*) [measurable_space α] : (refl α).symm = refl α := rfl\n\n@[simp] theorem symm_comp_self (e : α ≃ᵐ β) : e.symm ∘ e = id := funext e.left_inv\n\n@[simp] theorem self_comp_symm (e : α ≃ᵐ β) : e ∘ e.symm = id := funext e.right_inv\n\n@[simp] theorem apply_symm_apply (e : α ≃ᵐ β) (y : β) : e (e.symm y) = y := e.right_inv y\n\n@[simp] theorem symm_apply_apply (e : α ≃ᵐ β) (x : α) : e.symm (e x) = x := e.left_inv x\n\n@[simp] theorem symm_trans_self (e : α ≃ᵐ β) : e.symm.trans e = refl β :=\next e.self_comp_symm\n\n@[simp] theorem self_trans_symm (e : α ≃ᵐ β) : e.trans e.symm = refl α :=\next e.symm_comp_self\n\nprotected theorem surjective (e : α ≃ᵐ β) : surjective e := e.to_equiv.surjective\nprotected theorem bijective (e : α ≃ᵐ β) : bijective e := e.to_equiv.bijective\nprotected theorem injective (e : α ≃ᵐ β) : injective e := e.to_equiv.injective\n\n@[simp] theorem symm_preimage_preimage (e : α ≃ᵐ β) (s : set β) : e.symm ⁻¹' (e ⁻¹' s) = s :=\ne.to_equiv.symm_preimage_preimage s\n\ntheorem image_eq_preimage (e : α ≃ᵐ β) (s : set α) : e '' s = e.symm ⁻¹' s :=\ne.to_equiv.image_eq_preimage s\n\n@[simp] theorem measurable_set_preimage (e : α ≃ᵐ β) {s : set β} :\n  measurable_set (e ⁻¹' s) ↔ measurable_set s :=\n⟨λ h, by simpa only [symm_preimage_preimage] using e.symm.measurable h, λ h, e.measurable h⟩\n\n@[simp] theorem measurable_set_image (e : α ≃ᵐ β) {s : set α} :\n  measurable_set (e '' s) ↔ measurable_set s :=\nby rw [image_eq_preimage, measurable_set_preimage]\n\n/-- A measurable equivalence is a measurable embedding. -/\nprotected lemma measurable_embedding (e : α ≃ᵐ β) : measurable_embedding e :=\n{ injective := e.injective,\n  measurable := e.measurable,\n  measurable_set_image' := λ s, e.measurable_set_image.2 }\n\n/-- Equal measurable spaces are equivalent. -/\nprotected def cast {α β} [i₁ : measurable_space α] [i₂ : measurable_space β]\n  (h : α = β) (hi : i₁ == i₂) : α ≃ᵐ β :=\n{ to_equiv := equiv.cast h,\n  measurable_to_fun  := by { substI h, substI hi, exact measurable_id },\n  measurable_inv_fun := by { substI h, substI hi, exact measurable_id }}\n\nprotected lemma measurable_comp_iff {f : β → γ} (e : α ≃ᵐ β) :\n  measurable (f ∘ e) ↔ measurable f :=\niff.intro\n  (assume hfe,\n    have measurable (f ∘ (e.symm.trans e).to_equiv) := hfe.comp e.symm.measurable,\n    by rwa [coe_to_equiv, symm_trans_self] at this)\n  (λ h, h.comp e.measurable)\n\n/-- Any two types with unique elements are measurably equivalent. -/\ndef of_unique_of_unique (α β : Type*) [measurable_space α] [measurable_space β]\n  [unique α] [unique β] : α ≃ᵐ β :=\n{ to_equiv := equiv_of_unique α β,\n  measurable_to_fun := subsingleton.measurable,\n  measurable_inv_fun := subsingleton.measurable }\n\n/-- Products of equivalent measurable spaces are equivalent. -/\ndef prod_congr (ab : α ≃ᵐ β) (cd : γ ≃ᵐ δ) : α × γ ≃ᵐ β × δ :=\n{ to_equiv := prod_congr ab.to_equiv cd.to_equiv,\n  measurable_to_fun := (ab.measurable_to_fun.comp measurable_id.fst).prod_mk\n    (cd.measurable_to_fun.comp measurable_id.snd),\n  measurable_inv_fun := (ab.measurable_inv_fun.comp measurable_id.fst).prod_mk\n    (cd.measurable_inv_fun.comp measurable_id.snd) }\n\n/-- Products of measurable spaces are symmetric. -/\ndef prod_comm : α × β ≃ᵐ β × α :=\n{ to_equiv := prod_comm α β,\n  measurable_to_fun  := measurable_id.snd.prod_mk measurable_id.fst,\n  measurable_inv_fun := measurable_id.snd.prod_mk measurable_id.fst }\n\n/-- Products of measurable spaces are associative. -/\ndef prod_assoc : (α × β) × γ ≃ᵐ α × (β × γ) :=\n{ to_equiv := prod_assoc α β γ,\n  measurable_to_fun  := measurable_fst.fst.prod_mk $ measurable_fst.snd.prod_mk measurable_snd,\n  measurable_inv_fun := (measurable_fst.prod_mk measurable_snd.fst).prod_mk measurable_snd.snd }\n\n/-- Sums of measurable spaces are symmetric. -/\ndef sum_congr (ab : α ≃ᵐ β) (cd : γ ≃ᵐ δ) : α ⊕ γ ≃ᵐ β ⊕ δ :=\n{ to_equiv := sum_congr ab.to_equiv cd.to_equiv,\n  measurable_to_fun :=\n    begin\n      cases ab with ab' abm, cases ab', cases cd with cd' cdm, cases cd',\n      refine measurable_sum (measurable_inl.comp abm) (measurable_inr.comp cdm)\n    end,\n  measurable_inv_fun :=\n    begin\n      cases ab with ab' _ abm, cases ab', cases cd with cd' _ cdm, cases cd',\n      refine measurable_sum (measurable_inl.comp abm) (measurable_inr.comp cdm)\n    end }\n\n/-- `s ×ˢ t ≃ (s × t)` as measurable spaces. -/\ndef set.prod (s : set α) (t : set β) : ↥(s ×ˢ t) ≃ᵐ s × t :=\n{ to_equiv := equiv.set.prod s t,\n  measurable_to_fun := measurable_id.subtype_coe.fst.subtype_mk.prod_mk\n    measurable_id.subtype_coe.snd.subtype_mk,\n  measurable_inv_fun := measurable.subtype_mk $ measurable_id.fst.subtype_coe.prod_mk\n    measurable_id.snd.subtype_coe }\n\n/-- `univ α ≃ α` as measurable spaces. -/\ndef set.univ (α : Type*) [measurable_space α] : (univ : set α) ≃ᵐ α :=\n{ to_equiv := equiv.set.univ α,\n  measurable_to_fun := measurable_id.subtype_coe,\n  measurable_inv_fun := measurable_id.subtype_mk }\n\n/-- `{a} ≃ unit` as measurable spaces. -/\ndef set.singleton (a : α) : ({a} : set α) ≃ᵐ unit :=\n{ to_equiv := equiv.set.singleton a,\n  measurable_to_fun := measurable_const,\n  measurable_inv_fun := measurable_const }\n\n/-- `α` is equivalent to its image in `α ⊕ β` as measurable spaces. -/\ndef set.range_inl : (range sum.inl : set (α ⊕ β)) ≃ᵐ α :=\n{ to_fun    := λ ab, match ab with\n    | ⟨sum.inl a, _⟩ := a\n    | ⟨sum.inr b, p⟩ := have false, by { cases p, contradiction }, this.elim\n    end,\n  inv_fun   := λ a, ⟨sum.inl a, a, rfl⟩,\n  left_inv  := by { rintro ⟨ab, a, rfl⟩, refl },\n  right_inv := assume a, rfl,\n  measurable_to_fun  := assume s (hs : measurable_set s),\n    begin\n      refine ⟨_, hs.inl_image, set.ext _⟩,\n      rintros ⟨ab, a, rfl⟩,\n      simp [set.range_inl._match_1]\n    end,\n  measurable_inv_fun := measurable.subtype_mk measurable_inl }\n\n/-- `β` is equivalent to its image in `α ⊕ β` as measurable spaces. -/\ndef set.range_inr : (range sum.inr : set (α ⊕ β)) ≃ᵐ β :=\n{ to_fun    := λ ab, match ab with\n    | ⟨sum.inr b, _⟩ := b\n    | ⟨sum.inl a, p⟩ := have false, by { cases p, contradiction }, this.elim\n    end,\n  inv_fun   := λ b, ⟨sum.inr b, b, rfl⟩,\n  left_inv  := by { rintro ⟨ab, b, rfl⟩, refl },\n  right_inv := assume b, rfl,\n  measurable_to_fun  := assume s (hs : measurable_set s),\n    begin\n      refine ⟨_, measurable_set_inr_image hs, set.ext _⟩,\n      rintros ⟨ab, b, rfl⟩,\n      simp [set.range_inr._match_1]\n    end,\n  measurable_inv_fun := measurable.subtype_mk measurable_inr }\n\n/-- Products distribute over sums (on the right) as measurable spaces. -/\ndef sum_prod_distrib (α β γ) [measurable_space α] [measurable_space β] [measurable_space γ] :\n  (α ⊕ β) × γ ≃ᵐ (α × γ) ⊕ (β × γ) :=\n{ to_equiv := sum_prod_distrib α β γ,\n  measurable_to_fun  :=\n  begin\n    refine measurable_of_measurable_union_cover\n      (range sum.inl ×ˢ (univ : set γ))\n      (range sum.inr ×ˢ (univ : set γ))\n      (measurable_set_range_inl.prod measurable_set.univ)\n      (measurable_set_range_inr.prod measurable_set.univ)\n      (by { rintro ⟨a|b, c⟩; simp [set.prod_eq] })\n      _\n      _,\n    { refine (set.prod (range sum.inl) univ).symm.measurable_comp_iff.1 _,\n      refine (prod_congr set.range_inl (set.univ _)).symm.measurable_comp_iff.1 _,\n      dsimp [(∘)],\n      convert measurable_inl,\n      ext ⟨a, c⟩, refl },\n    { refine (set.prod (range sum.inr) univ).symm.measurable_comp_iff.1 _,\n      refine (prod_congr set.range_inr (set.univ _)).symm.measurable_comp_iff.1 _,\n      dsimp [(∘)],\n      convert measurable_inr,\n      ext ⟨b, c⟩, refl }\n  end,\n  measurable_inv_fun :=\n    measurable_sum\n      ((measurable_inl.comp measurable_fst).prod_mk measurable_snd)\n      ((measurable_inr.comp measurable_fst).prod_mk measurable_snd) }\n\n/-- Products distribute over sums (on the left) as measurable spaces. -/\ndef prod_sum_distrib (α β γ) [measurable_space α] [measurable_space β] [measurable_space γ] :\n  α × (β ⊕ γ) ≃ᵐ (α × β) ⊕ (α × γ) :=\nprod_comm.trans $ (sum_prod_distrib _ _ _).trans $ sum_congr prod_comm prod_comm\n\n/-- Products distribute over sums as measurable spaces. -/\ndef sum_prod_sum (α β γ δ)\n  [measurable_space α] [measurable_space β] [measurable_space γ] [measurable_space δ] :\n  (α ⊕ β) × (γ ⊕ δ) ≃ᵐ ((α × γ) ⊕ (α × δ)) ⊕ ((β × γ) ⊕ (β × δ)) :=\n(sum_prod_distrib _ _ _).trans $ sum_congr (prod_sum_distrib _ _ _) (prod_sum_distrib _ _ _)\n\nvariables {π π' : δ' → Type*} [∀ x, measurable_space (π x)] [∀ x, measurable_space (π' x)]\n\n/-- A family of measurable equivalences `Π a, β₁ a ≃ᵐ β₂ a` generates a measurable equivalence\n  between  `Π a, β₁ a` and `Π a, β₂ a`. -/\ndef Pi_congr_right (e : Π a, π a ≃ᵐ π' a) : (Π a, π a) ≃ᵐ (Π a, π' a) :=\n{ to_equiv := Pi_congr_right (λ a, (e a).to_equiv),\n  measurable_to_fun :=\n    measurable_pi_lambda _ (λ i, (e i).measurable_to_fun.comp (measurable_pi_apply i)),\n  measurable_inv_fun :=\n    measurable_pi_lambda _ (λ i, (e i).measurable_inv_fun.comp (measurable_pi_apply i)) }\n\n/-- Pi-types are measurably equivalent to iterated products. -/\n@[simps {fully_applied := ff}]\ndef pi_measurable_equiv_tprod [decidable_eq δ']\n  {l : list δ'} (hnd : l.nodup) (h : ∀ i, i ∈ l) :\n  (Π i, π i) ≃ᵐ list.tprod π l :=\n{ to_equiv := list.tprod.pi_equiv_tprod hnd h,\n  measurable_to_fun := measurable_tprod_mk l,\n  measurable_inv_fun := measurable_tprod_elim' h }\n\n/-- If `α` has a unique term, then the type of function `α → β` is measurably equivalent to `β`. -/\n@[simps {fully_applied := ff}] def fun_unique (α β : Type*) [unique α] [measurable_space β] :\n  (α → β) ≃ᵐ β :=\n{ to_equiv := equiv.fun_unique α β,\n  measurable_to_fun := measurable_pi_apply _,\n  measurable_inv_fun := measurable_pi_iff.2 $ λ b, measurable_id }\n\n/-- The space `Π i : fin 2, α i` is measurably equivalent to `α 0 × α 1`. -/\n@[simps {fully_applied := ff}] def pi_fin_two (α : fin 2 → Type*) [∀ i, measurable_space (α i)] :\n  (Π i, α i) ≃ᵐ α 0 × α 1 :=\n{ to_equiv := pi_fin_two_equiv α,\n  measurable_to_fun := measurable.prod (measurable_pi_apply _) (measurable_pi_apply _),\n  measurable_inv_fun := measurable_pi_iff.2 $\n    fin.forall_fin_two.2 ⟨measurable_fst, measurable_snd⟩ }\n\n/-- The space `fin 2 → α` is measurably equivalent to `α × α`. -/\n@[simps {fully_applied := ff}] def fin_two_arrow : (fin 2 → α) ≃ᵐ α × α := pi_fin_two (λ _, α)\n\n/-- Measurable equivalence between `Π j : fin (n + 1), α j` and\n`α i × Π j : fin n, α (fin.succ_above i j)`. -/\n@[simps {fully_applied := ff}]\ndef pi_fin_succ_above_equiv {n : ℕ} (α : fin (n + 1) → Type*) [Π i, measurable_space (α i)]\n  (i : fin (n + 1)) :\n  (Π j, α j) ≃ᵐ α i × (Π j, α (i.succ_above j)) :=\n{ to_equiv := pi_fin_succ_above_equiv α i,\n  measurable_to_fun := (measurable_pi_apply i).prod_mk $ measurable_pi_iff.2 $\n    λ j, measurable_pi_apply _,\n  measurable_inv_fun := by simp [measurable_pi_iff, i.forall_iff_succ_above, measurable_fst,\n    (measurable_pi_apply _).comp measurable_snd]  }\n\nvariable (π)\n\n/-- Measurable equivalence between (dependent) functions on a type and pairs of functions on\n`{i // p i}` and `{i // ¬p i}`. See also `equiv.pi_equiv_pi_subtype_prod`. -/\n@[simps {fully_applied := ff}]\ndef pi_equiv_pi_subtype_prod (p : δ' → Prop) [decidable_pred p] :\n  (Π i, π i) ≃ᵐ ((Π i : subtype p, π i) × (Π i : {i // ¬p i}, π i)) :=\n{ to_equiv := pi_equiv_pi_subtype_prod p π,\n  measurable_to_fun := measurable_pi_equiv_pi_subtype_prod π p,\n  measurable_inv_fun := measurable_pi_equiv_pi_subtype_prod_symm π p }\n\n/-- If `s` is a measurable set in a measurable space, that space is equivalent\nto the sum of `s` and `sᶜ`.-/\ndef sum_compl {s : set α} [decidable_pred s] (hs : measurable_set s) : s ⊕ (sᶜ : set α) ≃ᵐ α :=\n{ to_equiv := sum_compl s,\n  measurable_to_fun := by {apply measurable.sum_elim; exact measurable_subtype_coe},\n  measurable_inv_fun :=  measurable.dite measurable_inl measurable_inr hs }\n\nend measurable_equiv\n\nnamespace measurable_embedding\n\nvariables [measurable_space α] [measurable_space β] [measurable_space γ] {f : α → β} {g : β → α}\n\n/-- A set is equivalent to its image under a function `f` as measurable spaces,\n  if `f` is a measurable embedding -/\nnoncomputable def equiv_image (s : set α) (hf : measurable_embedding f) :\n  s ≃ᵐ (f '' s) :=\n{ to_equiv := equiv.set.image f s hf.injective,\n  measurable_to_fun  := (hf.measurable.comp measurable_id.subtype_coe).subtype_mk,\n  measurable_inv_fun :=\n    begin\n      rintro t ⟨u, hu, rfl⟩, simp [preimage_preimage, set.image_symm_preimage hf.injective],\n      exact measurable_subtype_coe (hf.measurable_set_image' hu)\n    end }\n\n/-- The domain of `f` is equivalent to its range as measurable spaces,\n  if `f` is a measurable embedding -/\nnoncomputable def equiv_range (hf : measurable_embedding f) : α ≃ᵐ (range f) :=\n(measurable_equiv.set.univ _).symm.trans $\n  (hf.equiv_image univ).trans $\n  measurable_equiv.cast (by rw image_univ) (by rw image_univ)\n\nlemma of_measurable_inverse_on_range {g : range f → α} (hf₁ : measurable f)\n  (hf₂ : measurable_set (range f)) (hg : measurable g)\n  (H : left_inverse g (range_factorization f)) : measurable_embedding f :=\nbegin\n  set e : α ≃ᵐ range f :=\n    ⟨⟨range_factorization f, g, H, H.right_inverse_of_surjective surjective_onto_range⟩,\n      hf₁.subtype_mk, hg⟩,\n  exact (measurable_embedding.subtype_coe hf₂).comp e.measurable_embedding\nend\n\nlemma of_measurable_inverse (hf₁ : measurable f)\n  (hf₂ : measurable_set (range f)) (hg : measurable g)\n  (H : left_inverse g f) : measurable_embedding f :=\nof_measurable_inverse_on_range hf₁ hf₂ (hg.comp measurable_subtype_coe) H\n\nopen_locale classical\n\n/-- The **`measurable Schröder-Bernstein Theorem**: Given measurable embeddings\n`α → β` and `β → α`, we can find a measurable equivalence `α ≃ᵐ β`.-/\nnoncomputable\ndef schroeder_bernstein {f : α → β} {g : β → α}\n  (hf : measurable_embedding f)(hg : measurable_embedding g) : α ≃ᵐ β :=\nbegin\n  let F : set α → set α := λ A, (g '' (f '' A)ᶜ)ᶜ,\n  -- We follow the proof of the usual SB theorem in mathlib,\n  -- the crux of which is finding a fixed point of this F.\n  -- However, we must find this fixed point manually instead of invoking Knaster-Tarski\n  -- in order to make sure it is measurable.\n  suffices : Σ' A : set α, measurable_set A ∧ F A = A,\n  { rcases this with ⟨A, Ameas, Afp⟩,\n    let B := f '' A,\n    have Bmeas : measurable_set B := hf.measurable_set_image' Ameas,\n    refine (measurable_equiv.sum_compl Ameas).symm.trans\n      (measurable_equiv.trans _ (measurable_equiv.sum_compl Bmeas)),\n    apply measurable_equiv.sum_congr (hf.equiv_image _),\n    have : Aᶜ = g '' Bᶜ,\n    { apply compl_injective,\n      rw ← Afp,\n      simp, },\n    rw this,\n    exact (hg.equiv_image _).symm, },\n  have Fmono : ∀ {A B}, A ⊆ B → F A ⊆ F B := λ A B hAB,\n    compl_subset_compl.mpr $ set.image_subset _ $\n    compl_subset_compl.mpr $ set.image_subset _ hAB,\n  let X : ℕ → set α := λ n, F^[n] univ,\n  refine ⟨Inter X, _, _⟩,\n  { apply measurable_set.Inter,\n    intros n,\n    induction n with n ih,\n    { exact measurable_set.univ },\n    rw [function.iterate_succ', function.comp_apply],\n    exact (hg.measurable_set_image' (hf.measurable_set_image' ih).compl).compl, },\n  apply subset_antisymm,\n  { apply subset_Inter,\n    intros n,\n    cases n,\n    { exact subset_univ _ },\n    rw [function.iterate_succ', function.comp_apply],\n    exact Fmono (Inter_subset _ _ ), },\n  rintros x hx ⟨y, hy, rfl⟩,\n  rw mem_Inter at hx,\n  apply hy,\n  rw (inj_on_of_injective hf.injective _).image_Inter_eq,\n  swap, { apply_instance },\n  rw mem_Inter,\n  intro n,\n  specialize hx n.succ,\n  rw [function.iterate_succ', function.comp_apply] at hx,\n  by_contradiction h,\n  apply hx,\n  exact ⟨y, h, rfl⟩,\nend\n\nend measurable_embedding\n\nnamespace filter\n\nvariables [measurable_space α]\n\n/-- A filter `f` is measurably generates if each `s ∈ f` includes a measurable `t ∈ f`. -/\nclass is_measurably_generated (f : filter α) : Prop :=\n(exists_measurable_subset : ∀ ⦃s⦄, s ∈ f → ∃ t ∈ f, measurable_set t ∧ t ⊆ s)\n\ninstance is_measurably_generated_bot : is_measurably_generated (⊥ : filter α) :=\n⟨λ _ _, ⟨∅, mem_bot, measurable_set.empty, empty_subset _⟩⟩\n\ninstance is_measurably_generated_top : is_measurably_generated (⊤ : filter α) :=\n⟨λ s hs, ⟨univ, univ_mem, measurable_set.univ, λ x _, hs x⟩⟩\n\nlemma eventually.exists_measurable_mem {f : filter α} [is_measurably_generated f]\n  {p : α → Prop} (h : ∀ᶠ x in f, p x) :\n  ∃ s ∈ f, measurable_set s ∧ ∀ x ∈ s, p x :=\nis_measurably_generated.exists_measurable_subset h\n\nlemma eventually.exists_measurable_mem_of_small_sets {f : filter α} [is_measurably_generated f]\n  {p : set α → Prop} (h : ∀ᶠ s in f.small_sets, p s) :\n  ∃ s ∈ f, measurable_set s ∧ p s :=\nlet ⟨s, hsf, hs⟩ := eventually_small_sets.1 h,\n  ⟨t, htf, htm, hts⟩ := is_measurably_generated.exists_measurable_subset hsf\nin ⟨t, htf, htm, hs t hts⟩\n\ninstance inf_is_measurably_generated (f g : filter α) [is_measurably_generated f]\n  [is_measurably_generated g] :\n  is_measurably_generated (f ⊓ g) :=\nbegin\n  refine ⟨_⟩,\n  rintros t ⟨sf, hsf, sg, hsg, rfl⟩,\n  rcases is_measurably_generated.exists_measurable_subset hsf with ⟨s'f, hs'f, hmf, hs'sf⟩,\n  rcases is_measurably_generated.exists_measurable_subset hsg with ⟨s'g, hs'g, hmg, hs'sg⟩,\n  refine ⟨s'f ∩ s'g, inter_mem_inf hs'f hs'g, hmf.inter hmg, _⟩,\n  exact inter_subset_inter hs'sf hs'sg\nend\n\nlemma principal_is_measurably_generated_iff {s : set α} :\n  is_measurably_generated (𝓟 s) ↔ measurable_set s :=\nbegin\n  refine ⟨_, λ hs, ⟨λ t ht, ⟨s, mem_principal_self s, hs, ht⟩⟩⟩,\n  rintros ⟨hs⟩,\n  rcases hs (mem_principal_self s) with ⟨t, ht, htm, hts⟩,\n  have : t = s := subset.antisymm hts ht,\n  rwa ← this\nend\n\nalias principal_is_measurably_generated_iff ↔\n  _ _root_.measurable_set.principal_is_measurably_generated\n\ninstance infi_is_measurably_generated {f : ι → filter α} [∀ i, is_measurably_generated (f i)] :\n  is_measurably_generated (⨅ i, f i) :=\nbegin\n  refine ⟨λ s hs, _⟩,\n  rw [← equiv.plift.surjective.infi_comp, mem_infi] at hs,\n  rcases hs with ⟨t, ht, ⟨V, hVf, rfl⟩⟩,\n  choose U hUf hU using λ i, is_measurably_generated.exists_measurable_subset (hVf i),\n  refine ⟨⋂ i : t, U i, _, _, _⟩,\n  { rw [← equiv.plift.surjective.infi_comp, mem_infi],\n    refine ⟨t, ht, U, hUf, rfl⟩ },\n  { haveI := ht.countable.to_encodable,\n    exact measurable_set.Inter (λ i, (hU i).1) },\n  { exact Inter_mono (λ i, (hU i).2) }\nend\n\nend filter\n\n/-- We say that a collection of sets is countably spanning if a countable subset spans the\n  whole type. This is a useful condition in various parts of measure theory. For example, it is\n  a needed condition to show that the product of two collections generate the product sigma algebra,\n  see `generate_from_prod_eq`. -/\ndef is_countably_spanning (C : set (set α)) : Prop :=\n∃ (s : ℕ → set α), (∀ n, s n ∈ C) ∧ (⋃ n, s n) = univ\n\nlemma is_countably_spanning_measurable_set [measurable_space α] :\n  is_countably_spanning {s : set α | measurable_set s} :=\n⟨λ _, univ, λ _, measurable_set.univ, Union_const _⟩\n\nnamespace measurable_set\n\n/-!\n### Typeclasses on `subtype measurable_set`\n-/\n\nvariables [measurable_space α]\n\ninstance : has_mem α (subtype (measurable_set : set α → Prop)) :=\n⟨λ a s, a ∈ (s : set α)⟩\n\n@[simp] lemma mem_coe (a : α) (s : subtype (measurable_set : set α → Prop)) :\n  a ∈ (s : set α) ↔ a ∈ s := iff.rfl\n\ninstance : has_emptyc (subtype (measurable_set : set α → Prop)) :=\n⟨⟨∅, measurable_set.empty⟩⟩\n\n@[simp] lemma coe_empty : ↑(∅ : subtype (measurable_set : set α → Prop)) = (∅ : set α) := rfl\n\ninstance [measurable_singleton_class α] : has_insert α (subtype (measurable_set : set α → Prop)) :=\n⟨λ a s, ⟨has_insert.insert a s, s.prop.insert a⟩⟩\n\n@[simp] lemma coe_insert [measurable_singleton_class α] (a : α)\n  (s : subtype (measurable_set : set α → Prop)) :\n  ↑(has_insert.insert a s) = (has_insert.insert a s : set α) := rfl\n\ninstance : has_compl (subtype (measurable_set : set α → Prop)) :=\n⟨λ x, ⟨xᶜ, x.prop.compl⟩⟩\n\n@[simp] lemma coe_compl (s : subtype (measurable_set : set α → Prop)) : ↑(sᶜ) = (sᶜ : set α) := rfl\n\ninstance : has_union (subtype (measurable_set : set α → Prop)) :=\n⟨λ x y, ⟨x ∪ y, x.prop.union y.prop⟩⟩\n\n@[simp] lemma coe_union (s t : subtype (measurable_set : set α → Prop)) :\n  ↑(s ∪ t) = (s ∪ t : set α) := rfl\n\ninstance : has_inter (subtype (measurable_set : set α → Prop)) :=\n⟨λ x y, ⟨x ∩ y, x.prop.inter y.prop⟩⟩\n\n@[simp] lemma coe_inter (s t : subtype (measurable_set : set α → Prop)) :\n  ↑(s ∩ t) = (s ∩ t : set α) := rfl\n\ninstance : has_sdiff (subtype (measurable_set : set α → Prop)) :=\n⟨λ x y, ⟨x \\ y, x.prop.diff y.prop⟩⟩\n\n@[simp] lemma coe_sdiff (s t : subtype (measurable_set : set α → Prop)) :\n  ↑(s \\ t) = (s \\ t : set α) := rfl\n\ninstance : has_bot (subtype (measurable_set : set α → Prop)) :=\n⟨⟨⊥, measurable_set.empty⟩⟩\n\n@[simp] lemma coe_bot : ↑(⊥ : subtype (measurable_set : set α → Prop)) = (⊥ : set α) := rfl\n\ninstance : has_top (subtype (measurable_set : set α → Prop)) :=\n⟨⟨⊤, measurable_set.univ⟩⟩\n\n@[simp] lemma coe_top : ↑(⊤ : subtype (measurable_set : set α → Prop)) = (⊤ : set α) := rfl\n\ninstance : partial_order (subtype (measurable_set : set α → Prop)) :=\npartial_order.lift _ subtype.coe_injective\n\ninstance : distrib_lattice (subtype (measurable_set : set α → Prop)) :=\n{ sup := (∪),\n  le_sup_left := λ a b, show (a : set α) ≤ a ⊔ b, from le_sup_left,\n  le_sup_right := λ a b, show (b : set α) ≤ a ⊔ b, from le_sup_right,\n  sup_le := λ a b c ha hb, show (a ⊔ b : set α) ≤ c, from sup_le ha hb,\n  inf := (∩),\n  inf_le_left := λ a b, show (a ⊓ b : set α) ≤ a, from inf_le_left,\n  inf_le_right := λ a b, show (a ⊓ b : set α) ≤ b, from inf_le_right,\n  le_inf := λ a b c ha hb, show (a : set α) ≤ b ⊓ c, from le_inf ha hb,\n  le_sup_inf := λ x y z, show ((x ⊔ y) ⊓ (x ⊔ z) : set α) ≤ x ⊔ y ⊓ z, from le_sup_inf,\n  .. measurable_set.subtype.partial_order }\n\ninstance : bounded_order (subtype (measurable_set : set α → Prop)) :=\n{ top := ⊤,\n  le_top := λ a, show (a : set α) ≤ ⊤, from le_top,\n  bot := ⊥,\n  bot_le := λ a, show (⊥ : set α) ≤ a, from bot_le }\n\ninstance : boolean_algebra (subtype (measurable_set : set α → Prop)) :=\n{ sdiff := (\\),\n  compl := has_compl.compl,\n  inf_compl_le_bot := λ a, boolean_algebra.inf_compl_le_bot (a : set α),\n  top_le_sup_compl := λ a, boolean_algebra.top_le_sup_compl (a : set α),\n  sdiff_eq := λ a b, subtype.eq $ sdiff_eq,\n  .. measurable_set.subtype.bounded_order,\n  .. measurable_set.subtype.distrib_lattice }\n\n@[measurability] lemma measurable_set_blimsup {s : ℕ → set α} {p : ℕ → Prop}\n  (h : ∀ n, p n → measurable_set (s n)) :\n  measurable_set $ filter.blimsup s filter.at_top p :=\nbegin\n  simp only [filter.blimsup_eq_infi_bsupr_of_nat, supr_eq_Union, infi_eq_Inter],\n  exact measurable_set.Inter\n    (λ n, measurable_set.Union (λ m, measurable_set.Union $ λ hm, h m hm.1)),\nend\n\n@[measurability] lemma measurable_set_bliminf {s : ℕ → set α} {p : ℕ → Prop}\n  (h : ∀ n, p n → measurable_set (s n)) :\n  measurable_set $ filter.bliminf s filter.at_top p :=\nbegin\n  simp only [filter.bliminf_eq_supr_binfi_of_nat, infi_eq_Inter, supr_eq_Union],\n  exact measurable_set.Union\n    (λ n, measurable_set.Inter (λ m, measurable_set.Inter $ λ hm, h m hm.1)),\nend\n\n@[measurability] lemma measurable_set_limsup {s : ℕ → set α} (hs : ∀ n, measurable_set $ s n) :\n  measurable_set $ filter.limsup s filter.at_top :=\nbegin\n  convert measurable_set_blimsup (λ n h, hs n : ∀ n, true → measurable_set (s n)),\n  simp,\nend\n\n@[measurability] lemma measurable_set_liminf {s : ℕ → set α} (hs : ∀ n, measurable_set $ s n) :\n  measurable_set $ filter.liminf s filter.at_top :=\nbegin\n  convert measurable_set_bliminf (λ n h, hs n : ∀ n, true → measurable_set (s n)),\n  simp,\nend\n\nend measurable_set\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/measure_theory/measurable_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.48025554538531307}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\n! This file was ported from Lean 3 source module algebra.opposites\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Group.Defs\nimport Mathbin.Logic.Equiv.Defs\nimport Mathbin.Logic.Nontrivial\n\n/-!\n# Multiplicative opposite and algebraic operations on it\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we define `mul_opposite α = αᵐᵒᵖ` to be the multiplicative opposite of `α`. It inherits\nall additive algebraic structures on `α` (in other files), and reverses the order of multipliers in\nmultiplicative structures, i.e., `op (x * y) = op y * op x`, where `mul_opposite.op` is the\ncanonical map from `α` to `αᵐᵒᵖ`.\n\nWe also define `add_opposite α = αᵃᵒᵖ` to be the additive opposite of `α`. It inherits all\nmultiplicative algebraic structures on `α` (in other files), and reverses the order of summands in\nadditive structures, i.e. `op (x + y) = op y + op x`, where `add_opposite.op` is the canonical map\nfrom `α` to `αᵃᵒᵖ`.\n\n## Notation\n\n* `αᵐᵒᵖ = mul_opposite α`\n* `αᵃᵒᵖ = add_opposite α`\n\n## Tags\n\nmultiplicative opposite, additive opposite\n-/\n\n\nuniverse u v\n\nopen Function\n\n#print MulOpposite /-\n/-- Multiplicative opposite of a type. This type inherits all additive structures on `α` and\nreverses left and right in multiplication.-/\n@[to_additive\n      \"Additive opposite of a type. This type inherits all multiplicative structures on\\n`α` and reverses left and right in addition.\"]\ndef MulOpposite (α : Type u) : Type u :=\n  α\n#align mul_opposite MulOpposite\n#align add_opposite AddOpposite\n-/\n\n-- mathport name: «expr ᵐᵒᵖ»\npostfix:max \"ᵐᵒᵖ\" => MulOpposite\n\n-- mathport name: «expr ᵃᵒᵖ»\npostfix:max \"ᵃᵒᵖ\" => AddOpposite\n\nvariable {α : Type u}\n\nnamespace MulOpposite\n\n#print MulOpposite.op /-\n/-- The element of `mul_opposite α` that represents `x : α`. -/\n@[pp_nodot, to_additive \"The element of `αᵃᵒᵖ` that represents `x : α`.\"]\ndef op : α → αᵐᵒᵖ :=\n  id\n#align mul_opposite.op MulOpposite.op\n#align add_opposite.op AddOpposite.op\n-/\n\n#print MulOpposite.unop /-\n/-- The element of `α` represented by `x : αᵐᵒᵖ`. -/\n@[pp_nodot, to_additive \"The element of `α` represented by `x : αᵃᵒᵖ`.\"]\ndef unop : αᵐᵒᵖ → α :=\n  id\n#align mul_opposite.unop MulOpposite.unop\n#align add_opposite.unop AddOpposite.unop\n-/\n\nattribute [pp_nodot] AddOpposite.op AddOpposite.unop\n\n#print MulOpposite.unop_op /-\n@[simp, to_additive]\ntheorem unop_op (x : α) : unop (op x) = x :=\n  rfl\n#align mul_opposite.unop_op MulOpposite.unop_op\n#align add_opposite.unop_op AddOpposite.unop_op\n-/\n\n#print MulOpposite.op_unop /-\n@[simp, to_additive]\ntheorem op_unop (x : αᵐᵒᵖ) : op (unop x) = x :=\n  rfl\n#align mul_opposite.op_unop MulOpposite.op_unop\n#align add_opposite.op_unop AddOpposite.op_unop\n-/\n\n#print MulOpposite.op_comp_unop /-\n@[simp, to_additive]\ntheorem op_comp_unop : (op : α → αᵐᵒᵖ) ∘ unop = id :=\n  rfl\n#align mul_opposite.op_comp_unop MulOpposite.op_comp_unop\n#align add_opposite.op_comp_unop AddOpposite.op_comp_unop\n-/\n\n#print MulOpposite.unop_comp_op /-\n@[simp, to_additive]\ntheorem unop_comp_op : (unop : αᵐᵒᵖ → α) ∘ op = id :=\n  rfl\n#align mul_opposite.unop_comp_op MulOpposite.unop_comp_op\n#align add_opposite.unop_comp_op AddOpposite.unop_comp_op\n-/\n\n/- warning: mul_opposite.rec -> MulOpposite.rec' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {F : (MulOpposite.{u1} α) -> Sort.{u2}}, (forall (X : α), F (MulOpposite.op.{u1} α X)) -> (forall (X : MulOpposite.{u1} α), F X)\nbut is expected to have type\n  forall {α : Type.{u2}} {F : (MulOpposite.{u2} α) -> Sort.{u1}}, (forall (X : α), F (MulOpposite.op.{u2} α X)) -> (forall (X : MulOpposite.{u2} α), F X)\nCase conversion may be inaccurate. Consider using '#align mul_opposite.rec MulOpposite.rec'ₓ'. -/\n/-- A recursor for `mul_opposite`. Use as `induction x using mul_opposite.rec`. -/\n@[simp, to_additive \"A recursor for `add_opposite`. Use as `induction x using add_opposite.rec`.\"]\nprotected def rec' {F : ∀ X : αᵐᵒᵖ, Sort v} (h : ∀ X, F (op X)) : ∀ X, F X := fun X => h (unop X)\n#align mul_opposite.rec MulOpposite.rec'\n#align add_opposite.rec AddOpposite.rec'\n\n#print MulOpposite.opEquiv /-\n/-- The canonical bijection between `α` and `αᵐᵒᵖ`. -/\n@[to_additive \"The canonical bijection between `α` and `αᵃᵒᵖ`.\",\n  simps (config := { fullyApplied := false }) apply symm_apply]\ndef opEquiv : α ≃ αᵐᵒᵖ :=\n  ⟨op, unop, unop_op, op_unop⟩\n#align mul_opposite.op_equiv MulOpposite.opEquiv\n#align add_opposite.op_equiv AddOpposite.opEquiv\n-/\n\n#print MulOpposite.op_bijective /-\n@[to_additive]\ntheorem op_bijective : Bijective (op : α → αᵐᵒᵖ) :=\n  opEquiv.Bijective\n#align mul_opposite.op_bijective MulOpposite.op_bijective\n#align add_opposite.op_bijective AddOpposite.op_bijective\n-/\n\n#print MulOpposite.unop_bijective /-\n@[to_additive]\ntheorem unop_bijective : Bijective (unop : αᵐᵒᵖ → α) :=\n  opEquiv.symm.Bijective\n#align mul_opposite.unop_bijective MulOpposite.unop_bijective\n#align add_opposite.unop_bijective AddOpposite.unop_bijective\n-/\n\n#print MulOpposite.op_injective /-\n@[to_additive]\ntheorem op_injective : Injective (op : α → αᵐᵒᵖ) :=\n  op_bijective.Injective\n#align mul_opposite.op_injective MulOpposite.op_injective\n#align add_opposite.op_injective AddOpposite.op_injective\n-/\n\n#print MulOpposite.op_surjective /-\n@[to_additive]\ntheorem op_surjective : Surjective (op : α → αᵐᵒᵖ) :=\n  op_bijective.Surjective\n#align mul_opposite.op_surjective MulOpposite.op_surjective\n#align add_opposite.op_surjective AddOpposite.op_surjective\n-/\n\n#print MulOpposite.unop_injective /-\n@[to_additive]\ntheorem unop_injective : Injective (unop : αᵐᵒᵖ → α) :=\n  unop_bijective.Injective\n#align mul_opposite.unop_injective MulOpposite.unop_injective\n#align add_opposite.unop_injective AddOpposite.unop_injective\n-/\n\n#print MulOpposite.unop_surjective /-\n@[to_additive]\ntheorem unop_surjective : Surjective (unop : αᵐᵒᵖ → α) :=\n  unop_bijective.Surjective\n#align mul_opposite.unop_surjective MulOpposite.unop_surjective\n#align add_opposite.unop_surjective AddOpposite.unop_surjective\n-/\n\n#print MulOpposite.op_inj /-\n@[simp, to_additive]\ntheorem op_inj {x y : α} : op x = op y ↔ x = y :=\n  op_injective.eq_iff\n#align mul_opposite.op_inj MulOpposite.op_inj\n#align add_opposite.op_inj AddOpposite.op_inj\n-/\n\n#print MulOpposite.unop_inj /-\n@[simp, to_additive]\ntheorem unop_inj {x y : αᵐᵒᵖ} : unop x = unop y ↔ x = y :=\n  unop_injective.eq_iff\n#align mul_opposite.unop_inj MulOpposite.unop_inj\n#align add_opposite.unop_inj AddOpposite.unop_inj\n-/\n\nvariable (α)\n\n@[to_additive]\ninstance [Nontrivial α] : Nontrivial αᵐᵒᵖ :=\n  op_injective.Nontrivial\n\n@[to_additive]\ninstance [Inhabited α] : Inhabited αᵐᵒᵖ :=\n  ⟨op default⟩\n\n@[to_additive]\ninstance [Subsingleton α] : Subsingleton αᵐᵒᵖ :=\n  unop_injective.Subsingleton\n\n@[to_additive]\ninstance [Unique α] : Unique αᵐᵒᵖ :=\n  Unique.mk' _\n\n@[to_additive]\ninstance [IsEmpty α] : IsEmpty αᵐᵒᵖ :=\n  Function.isEmpty unop\n\ninstance [Zero α] : Zero αᵐᵒᵖ where zero := op 0\n\n@[to_additive]\ninstance [One α] : One αᵐᵒᵖ where one := op 1\n\ninstance [Add α] : Add αᵐᵒᵖ where add x y := op (unop x + unop y)\n\ninstance [Sub α] : Sub αᵐᵒᵖ where sub x y := op (unop x - unop y)\n\ninstance [Neg α] : Neg αᵐᵒᵖ where neg x := op <| -unop x\n\ninstance [InvolutiveNeg α] : InvolutiveNeg αᵐᵒᵖ :=\n  { MulOpposite.hasNeg α with neg_neg := fun a => unop_injective <| neg_neg _ }\n\n@[to_additive]\ninstance [Mul α] : Mul αᵐᵒᵖ where mul x y := op (unop y * unop x)\n\n@[to_additive]\ninstance [Inv α] : Inv αᵐᵒᵖ where inv x := op <| (unop x)⁻¹\n\n@[to_additive]\ninstance [InvolutiveInv α] : InvolutiveInv αᵐᵒᵖ :=\n  { MulOpposite.hasInv α with inv_inv := fun a => unop_injective <| inv_inv _ }\n\n@[to_additive]\ninstance (R : Type _) [SMul R α] : SMul R αᵐᵒᵖ where smul c x := op (c • unop x)\n\nsection\n\nvariable (α)\n\n#print MulOpposite.op_zero /-\n@[simp]\ntheorem op_zero [Zero α] : op (0 : α) = 0 :=\n  rfl\n#align mul_opposite.op_zero MulOpposite.op_zero\n-/\n\n#print MulOpposite.unop_zero /-\n@[simp]\ntheorem unop_zero [Zero α] : unop (0 : αᵐᵒᵖ) = 0 :=\n  rfl\n#align mul_opposite.unop_zero MulOpposite.unop_zero\n-/\n\n#print MulOpposite.op_one /-\n@[simp, to_additive]\ntheorem op_one [One α] : op (1 : α) = 1 :=\n  rfl\n#align mul_opposite.op_one MulOpposite.op_one\n#align add_opposite.op_zero AddOpposite.op_zero\n-/\n\n#print MulOpposite.unop_one /-\n@[simp, to_additive]\ntheorem unop_one [One α] : unop (1 : αᵐᵒᵖ) = 1 :=\n  rfl\n#align mul_opposite.unop_one MulOpposite.unop_one\n#align add_opposite.unop_zero AddOpposite.unop_zero\n-/\n\nvariable {α}\n\n#print MulOpposite.op_add /-\n@[simp]\ntheorem op_add [Add α] (x y : α) : op (x + y) = op x + op y :=\n  rfl\n#align mul_opposite.op_add MulOpposite.op_add\n-/\n\n#print MulOpposite.unop_add /-\n@[simp]\ntheorem unop_add [Add α] (x y : αᵐᵒᵖ) : unop (x + y) = unop x + unop y :=\n  rfl\n#align mul_opposite.unop_add MulOpposite.unop_add\n-/\n\n#print MulOpposite.op_neg /-\n@[simp]\ntheorem op_neg [Neg α] (x : α) : op (-x) = -op x :=\n  rfl\n#align mul_opposite.op_neg MulOpposite.op_neg\n-/\n\n#print MulOpposite.unop_neg /-\n@[simp]\ntheorem unop_neg [Neg α] (x : αᵐᵒᵖ) : unop (-x) = -unop x :=\n  rfl\n#align mul_opposite.unop_neg MulOpposite.unop_neg\n-/\n\n#print MulOpposite.op_mul /-\n@[simp, to_additive]\ntheorem op_mul [Mul α] (x y : α) : op (x * y) = op y * op x :=\n  rfl\n#align mul_opposite.op_mul MulOpposite.op_mul\n#align add_opposite.op_add AddOpposite.op_add\n-/\n\n#print MulOpposite.unop_mul /-\n@[simp, to_additive]\ntheorem unop_mul [Mul α] (x y : αᵐᵒᵖ) : unop (x * y) = unop y * unop x :=\n  rfl\n#align mul_opposite.unop_mul MulOpposite.unop_mul\n#align add_opposite.unop_add AddOpposite.unop_add\n-/\n\n#print MulOpposite.op_inv /-\n@[simp, to_additive]\ntheorem op_inv [Inv α] (x : α) : op x⁻¹ = (op x)⁻¹ :=\n  rfl\n#align mul_opposite.op_inv MulOpposite.op_inv\n#align add_opposite.op_neg AddOpposite.op_neg\n-/\n\n#print MulOpposite.unop_inv /-\n@[simp, to_additive]\ntheorem unop_inv [Inv α] (x : αᵐᵒᵖ) : unop x⁻¹ = (unop x)⁻¹ :=\n  rfl\n#align mul_opposite.unop_inv MulOpposite.unop_inv\n#align add_opposite.unop_neg AddOpposite.unop_neg\n-/\n\n#print MulOpposite.op_sub /-\n@[simp]\ntheorem op_sub [Sub α] (x y : α) : op (x - y) = op x - op y :=\n  rfl\n#align mul_opposite.op_sub MulOpposite.op_sub\n-/\n\n#print MulOpposite.unop_sub /-\n@[simp]\ntheorem unop_sub [Sub α] (x y : αᵐᵒᵖ) : unop (x - y) = unop x - unop y :=\n  rfl\n#align mul_opposite.unop_sub MulOpposite.unop_sub\n-/\n\n#print MulOpposite.op_smul /-\n@[simp, to_additive]\ntheorem op_smul {R : Type _} [SMul R α] (c : R) (a : α) : op (c • a) = c • op a :=\n  rfl\n#align mul_opposite.op_smul MulOpposite.op_smul\n#align add_opposite.op_vadd AddOpposite.op_vadd\n-/\n\n#print MulOpposite.unop_smul /-\n@[simp, to_additive]\ntheorem unop_smul {R : Type _} [SMul R α] (c : R) (a : αᵐᵒᵖ) : unop (c • a) = c • unop a :=\n  rfl\n#align mul_opposite.unop_smul MulOpposite.unop_smul\n#align add_opposite.unop_vadd AddOpposite.unop_vadd\n-/\n\nend\n\nvariable {α}\n\n#print MulOpposite.unop_eq_zero_iff /-\n@[simp]\ntheorem unop_eq_zero_iff [Zero α] (a : αᵐᵒᵖ) : a.unop = (0 : α) ↔ a = (0 : αᵐᵒᵖ) :=\n  unop_injective.eq_iff' rfl\n#align mul_opposite.unop_eq_zero_iff MulOpposite.unop_eq_zero_iff\n-/\n\n#print MulOpposite.op_eq_zero_iff /-\n@[simp]\ntheorem op_eq_zero_iff [Zero α] (a : α) : op a = (0 : αᵐᵒᵖ) ↔ a = (0 : α) :=\n  op_injective.eq_iff' rfl\n#align mul_opposite.op_eq_zero_iff MulOpposite.op_eq_zero_iff\n-/\n\n#print MulOpposite.unop_ne_zero_iff /-\ntheorem unop_ne_zero_iff [Zero α] (a : αᵐᵒᵖ) : a.unop ≠ (0 : α) ↔ a ≠ (0 : αᵐᵒᵖ) :=\n  not_congr <| unop_eq_zero_iff a\n#align mul_opposite.unop_ne_zero_iff MulOpposite.unop_ne_zero_iff\n-/\n\n#print MulOpposite.op_ne_zero_iff /-\ntheorem op_ne_zero_iff [Zero α] (a : α) : op a ≠ (0 : αᵐᵒᵖ) ↔ a ≠ (0 : α) :=\n  not_congr <| op_eq_zero_iff a\n#align mul_opposite.op_ne_zero_iff MulOpposite.op_ne_zero_iff\n-/\n\n#print MulOpposite.unop_eq_one_iff /-\n@[simp, to_additive]\ntheorem unop_eq_one_iff [One α] (a : αᵐᵒᵖ) : a.unop = 1 ↔ a = 1 :=\n  unop_injective.eq_iff' rfl\n#align mul_opposite.unop_eq_one_iff MulOpposite.unop_eq_one_iff\n#align add_opposite.unop_eq_zero_iff AddOpposite.unop_eq_zero_iff\n-/\n\n#print MulOpposite.op_eq_one_iff /-\n@[simp, to_additive]\ntheorem op_eq_one_iff [One α] (a : α) : op a = 1 ↔ a = 1 :=\n  op_injective.eq_iff' rfl\n#align mul_opposite.op_eq_one_iff MulOpposite.op_eq_one_iff\n#align add_opposite.op_eq_zero_iff AddOpposite.op_eq_zero_iff\n-/\n\nend MulOpposite\n\nnamespace AddOpposite\n\ninstance [One α] : One αᵃᵒᵖ where one := op 1\n\n#print AddOpposite.op_one /-\n@[simp]\ntheorem op_one [One α] : op (1 : α) = 1 :=\n  rfl\n#align add_opposite.op_one AddOpposite.op_one\n-/\n\n#print AddOpposite.unop_one /-\n@[simp]\ntheorem unop_one [One α] : unop 1 = (1 : α) :=\n  rfl\n#align add_opposite.unop_one AddOpposite.unop_one\n-/\n\n#print AddOpposite.op_eq_one_iff /-\n@[simp]\ntheorem op_eq_one_iff [One α] {a : α} : op a = 1 ↔ a = 1 :=\n  op_injective.eq_iff' op_one\n#align add_opposite.op_eq_one_iff AddOpposite.op_eq_one_iff\n-/\n\n#print AddOpposite.unop_eq_one_iff /-\n@[simp]\ntheorem unop_eq_one_iff [One α] {a : αᵃᵒᵖ} : unop a = 1 ↔ a = 1 :=\n  unop_injective.eq_iff' unop_one\n#align add_opposite.unop_eq_one_iff AddOpposite.unop_eq_one_iff\n-/\n\ninstance [Mul α] : Mul αᵃᵒᵖ where mul a b := op (unop a * unop b)\n\n#print AddOpposite.op_mul /-\n@[simp]\ntheorem op_mul [Mul α] (a b : α) : op (a * b) = op a * op b :=\n  rfl\n#align add_opposite.op_mul AddOpposite.op_mul\n-/\n\n#print AddOpposite.unop_mul /-\n@[simp]\ntheorem unop_mul [Mul α] (a b : αᵃᵒᵖ) : unop (a * b) = unop a * unop b :=\n  rfl\n#align add_opposite.unop_mul AddOpposite.unop_mul\n-/\n\ninstance [Inv α] : Inv αᵃᵒᵖ where inv a := op (unop a)⁻¹\n\ninstance [InvolutiveInv α] : InvolutiveInv αᵃᵒᵖ :=\n  { AddOpposite.hasInv with inv_inv := fun a => unop_injective <| inv_inv _ }\n\n#print AddOpposite.op_inv /-\n@[simp]\ntheorem op_inv [Inv α] (a : α) : op a⁻¹ = (op a)⁻¹ :=\n  rfl\n#align add_opposite.op_inv AddOpposite.op_inv\n-/\n\n#print AddOpposite.unop_inv /-\n@[simp]\ntheorem unop_inv [Inv α] (a : αᵃᵒᵖ) : unop a⁻¹ = (unop a)⁻¹ :=\n  rfl\n#align add_opposite.unop_inv AddOpposite.unop_inv\n-/\n\ninstance [Div α] : Div αᵃᵒᵖ where div a b := op (unop a / unop b)\n\n#print AddOpposite.op_div /-\n@[simp]\ntheorem op_div [Div α] (a b : α) : op (a / b) = op a / op b :=\n  rfl\n#align add_opposite.op_div AddOpposite.op_div\n-/\n\n#print AddOpposite.unop_div /-\n@[simp]\ntheorem unop_div [Div α] (a b : αᵃᵒᵖ) : unop (a / b) = unop a / unop b :=\n  rfl\n#align add_opposite.unop_div AddOpposite.unop_div\n-/\n\nend AddOpposite\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Opposites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.4801515689956198}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\nimport topology.order\nimport topology.nhds_set\n\n/-!\n# Specific classes of maps between topological spaces\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file introduces the following properties of a map `f : X → Y` between topological spaces:\n\n* `is_open_map f` means the image of an open set under `f` is open.\n* `is_closed_map f` means the image of a closed set under `f` is closed.\n\n(Open and closed maps need not be continuous.)\n\n* `inducing f` means the topology on `X` is the one induced via `f` from the topology on `Y`.\n  These behave like embeddings except they need not be injective. Instead, points of `X` which\n  are identified by `f` are also inseparable in the topology on `X`.\n* `embedding f` means `f` is inducing and also injective. Equivalently, `f` identifies `X` with\n  a subspace of `Y`.\n* `open_embedding f` means `f` is an embedding with open image, so it identifies `X` with an\n  open subspace of `Y`. Equivalently, `f` is an embedding and an open map.\n* `closed_embedding f` similarly means `f` is an embedding with closed image, so it identifies\n  `X` with a closed subspace of `Y`. Equivalently, `f` is an embedding and a closed map.\n\n* `quotient_map f` is the dual condition to `embedding f`: `f` is surjective and the topology\n  on `Y` is the one coinduced via `f` from the topology on `X`. Equivalently, `f` identifies\n  `Y` with a quotient of `X`. Quotient maps are also sometimes known as identification maps.\n\n## References\n\n* <https://en.wikipedia.org/wiki/Open_and_closed_maps>\n* <https://en.wikipedia.org/wiki/Embedding#General_topology>\n* <https://en.wikipedia.org/wiki/Quotient_space_(topology)#Quotient_map>\n\n## Tags\n\nopen map, closed map, embedding, quotient map, identification map\n\n-/\n\nopen set filter function\nopen_locale topology filter\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\n\nsection inducing\n\n/-- A function `f : α → β` between topological spaces is inducing if the topology on `α` is induced\nby the topology on `β` through `f`, meaning that a set `s : set α` is open iff it is the preimage\nunder `f` of some open set `t : set β`. -/\n@[mk_iff]\nstructure inducing [tα : topological_space α] [tβ : topological_space β] (f : α → β) : Prop :=\n(induced : tα = tβ.induced f)\n\nvariables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n\nlemma inducing_id : inducing (@id α) :=\n⟨induced_id.symm⟩\n\nprotected lemma inducing.comp {g : β → γ} {f : α → β} (hg : inducing g) (hf : inducing f) :\n  inducing (g ∘ f) :=\n⟨by rw [hf.induced, hg.induced, induced_compose]⟩\n\nlemma inducing_of_inducing_compose {f : α → β} {g : β → γ} (hf : continuous f) (hg : continuous g)\n  (hgf : inducing (g ∘ f)) : inducing f :=\n⟨le_antisymm\n    (by rwa ← continuous_iff_le_induced)\n    (by { rw [hgf.induced, ← continuous_iff_le_induced], apply hg.comp continuous_induced_dom })⟩\n\nlemma inducing_iff_nhds {f : α → β} : inducing f ↔ ∀ a, 𝓝 a = comap f (𝓝 (f a)) :=\n(inducing_iff _).trans (induced_iff_nhds_eq f)\n\nlemma inducing.nhds_eq_comap {f : α → β} (hf : inducing f) :\n  ∀ (a : α), 𝓝 a = comap f (𝓝 $ f a) :=\ninducing_iff_nhds.1 hf\n\nlemma inducing.nhds_set_eq_comap {f : α → β} (hf : inducing f) (s : set α) :\n  𝓝ˢ s = comap f (𝓝ˢ (f '' s)) :=\nby simp only [nhds_set, Sup_image, comap_supr, hf.nhds_eq_comap, supr_image]\n\nlemma inducing.map_nhds_eq {f : α → β} (hf : inducing f) (a : α) :\n  (𝓝 a).map f = 𝓝[range f] (f a) :=\nhf.induced.symm ▸ map_nhds_induced_eq a\n\nlemma inducing.map_nhds_of_mem {f : α → β} (hf : inducing f) (a : α) (h : range f ∈ 𝓝 (f a)) :\n  (𝓝 a).map f = 𝓝 (f a) :=\nhf.induced.symm ▸ map_nhds_induced_of_mem h\n\nlemma inducing.image_mem_nhds_within {f : α → β} (hf : inducing f) {a : α} {s : set α}\n  (hs : s ∈ 𝓝 a) : f '' s ∈ 𝓝[range f] (f a) :=\nhf.map_nhds_eq a ▸ image_mem_map hs\n\nlemma inducing.tendsto_nhds_iff {ι : Type*}\n  {f : ι → β} {g : β → γ} {a : filter ι} {b : β} (hg : inducing g) :\n  tendsto f a (𝓝 b) ↔ tendsto (g ∘ f) a (𝓝 (g b)) :=\nby rw [hg.nhds_eq_comap, tendsto_comap_iff]\n\nlemma inducing.continuous_at_iff {f : α → β} {g : β → γ} (hg : inducing g) {x : α} :\n  continuous_at f x ↔ continuous_at (g ∘ f) x :=\nby simp_rw [continuous_at, inducing.tendsto_nhds_iff hg]\n\nlemma inducing.continuous_iff {f : α → β} {g : β → γ} (hg : inducing g) :\n  continuous f ↔ continuous (g ∘ f) :=\nby simp_rw [continuous_iff_continuous_at, hg.continuous_at_iff]\n\nlemma inducing.continuous_at_iff' {f : α → β} {g : β → γ} (hf : inducing f) {x : α}\n  (h : range f ∈ 𝓝 (f x)) : continuous_at (g ∘ f) x ↔ continuous_at g (f x) :=\nby { simp_rw [continuous_at, filter.tendsto, ← hf.map_nhds_of_mem _ h, filter.map_map] }\n\nprotected lemma inducing.continuous {f : α → β} (hf : inducing f) : continuous f :=\nhf.continuous_iff.mp continuous_id\n\nprotected lemma inducing.inducing_iff {f : α → β} {g : β → γ} (hg : inducing g) :\n  inducing f ↔ inducing (g ∘ f) :=\nbegin\n  refine ⟨λ h, hg.comp h, λ hgf, inducing_of_inducing_compose _ hg.continuous hgf⟩,\n  rw hg.continuous_iff,\n  exact hgf.continuous\nend\n\nlemma inducing.closure_eq_preimage_closure_image {f : α → β} (hf : inducing f) (s : set α) :\n  closure s = f ⁻¹' closure (f '' s) :=\nby { ext x, rw [set.mem_preimage, ← closure_induced, hf.induced] }\n\nlemma inducing.is_closed_iff {f : α → β} (hf : inducing f) {s : set α} :\n  is_closed s ↔ ∃ t, is_closed t ∧ f ⁻¹' t = s :=\nby rw [hf.induced, is_closed_induced_iff]\n\nlemma inducing.is_closed_iff' {f : α → β} (hf : inducing f) {s : set α} :\n  is_closed s ↔ ∀ x, f x ∈ closure (f '' s) → x ∈ s :=\nby rw [hf.induced, is_closed_induced_iff']\n\nlemma inducing.is_closed_preimage {f : α → β} (h : inducing f) (s : set β) (hs : is_closed s) :\n  is_closed (f ⁻¹' s) :=\n(inducing.is_closed_iff h).mpr ⟨s, hs, rfl⟩\n\nlemma inducing.is_open_iff {f : α → β} (hf : inducing f) {s : set α} :\n  is_open s ↔ ∃ t, is_open t ∧ f ⁻¹' t = s :=\nby rw [hf.induced, is_open_induced_iff]\n\nlemma inducing.dense_iff {f : α → β} (hf : inducing f) {s : set α} :\n  dense s ↔ ∀ x, f x ∈ closure (f '' s) :=\nby simp only [dense, hf.closure_eq_preimage_closure_image, mem_preimage]\n\nend inducing\n\nsection embedding\n\n/-- A function between topological spaces is an embedding if it is injective,\n  and for all `s : set α`, `s` is open iff it is the preimage of an open set. -/\n@[mk_iff] structure embedding [tα : topological_space α] [tβ : topological_space β] (f : α → β)\n  extends inducing f : Prop :=\n(inj : injective f)\n\nlemma function.injective.embedding_induced [t : topological_space β]\n  {f : α → β} (hf : injective f) :\n  @_root_.embedding α β (t.induced f) t f :=\n{ induced := rfl,\n  inj := hf }\n\nvariables [topological_space α] [topological_space β] [topological_space γ]\n\nlemma embedding.mk' (f : α → β) (inj : injective f)\n  (induced : ∀ a, comap f (𝓝 (f a)) = 𝓝 a) : embedding f :=\n⟨inducing_iff_nhds.2 (λ a, (induced a).symm), inj⟩\n\nlemma embedding_id : embedding (@id α) :=\n⟨inducing_id, assume a₁ a₂ h, h⟩\n\nlemma embedding.comp {g : β → γ} {f : α → β} (hg : embedding g) (hf : embedding f) :\n  embedding (g ∘ f) :=\n{ inj:= assume a₁ a₂ h, hf.inj $ hg.inj h,\n  ..hg.to_inducing.comp hf.to_inducing }\n\nlemma embedding_of_embedding_compose {f : α → β} {g : β → γ} (hf : continuous f) (hg : continuous g)\n  (hgf : embedding (g ∘ f)) : embedding f :=\n{ induced := (inducing_of_inducing_compose hf hg hgf.to_inducing).induced,\n  inj := assume a₁ a₂ h, hgf.inj $ by simp [h, (∘)] }\n\nprotected lemma function.left_inverse.embedding {f : α → β} {g : β → α}\n  (h : left_inverse f g) (hf : continuous f) (hg : continuous g) :\n  embedding g :=\nembedding_of_embedding_compose hg hf $ h.comp_eq_id.symm ▸ embedding_id\n\nlemma embedding.map_nhds_eq {f : α → β} (hf : embedding f) (a : α) :\n  (𝓝 a).map f = 𝓝[range f] (f a) :=\nhf.1.map_nhds_eq a\n\nlemma embedding.map_nhds_of_mem {f : α → β}\n  (hf : embedding f) (a : α) (h : range f ∈ 𝓝 (f a)) : (𝓝 a).map f = 𝓝 (f a) :=\nhf.1.map_nhds_of_mem a h\n\nlemma embedding.tendsto_nhds_iff {ι : Type*}\n  {f : ι → β} {g : β → γ} {a : filter ι} {b : β} (hg : embedding g) :\n  tendsto f a (𝓝 b) ↔ tendsto (g ∘ f) a (𝓝 (g b)) :=\nhg.to_inducing.tendsto_nhds_iff\n\nlemma embedding.continuous_iff {f : α → β} {g : β → γ} (hg : embedding g) :\n  continuous f ↔ continuous (g ∘ f) :=\ninducing.continuous_iff hg.1\n\nlemma embedding.continuous {f : α → β} (hf : embedding f) : continuous f :=\ninducing.continuous hf.1\n\nlemma embedding.closure_eq_preimage_closure_image {e : α → β} (he : embedding e) (s : set α) :\n  closure s = e ⁻¹' closure (e '' s) :=\nhe.1.closure_eq_preimage_closure_image s\n\n/-- The topology induced under an inclusion `f : X → Y` from the discrete topological space `Y`\nis the discrete topology on `X`. -/\nlemma embedding.discrete_topology {X Y : Type*} [topological_space X] [tY : topological_space Y]\n  [discrete_topology Y] {f : X → Y} (hf : embedding f) : discrete_topology X :=\ndiscrete_topology_iff_nhds.2 $ λ x, by rw [hf.nhds_eq_comap, nhds_discrete, comap_pure,\n  ← image_singleton, hf.inj.preimage_image, principal_singleton]\n\nend embedding\n\n/-- A function between topological spaces is a quotient map if it is surjective,\n  and for all `s : set β`, `s` is open iff its preimage is an open set. -/\ndef quotient_map {α : Type*} {β : Type*} [tα : topological_space α] [tβ : topological_space β]\n  (f : α → β) : Prop :=\nsurjective f ∧ tβ = tα.coinduced f\n\nlemma quotient_map_iff {α β : Type*} [topological_space α] [topological_space β] {f : α → β} :\n  quotient_map f ↔ surjective f ∧ ∀ s : set β, is_open s ↔ is_open (f ⁻¹' s) :=\nand_congr iff.rfl topological_space_eq_iff\n\nnamespace quotient_map\n\nvariables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n  {g : β → γ} {f : α → β}\n\nprotected lemma id : quotient_map (@id α) :=\n⟨assume a, ⟨a, rfl⟩, coinduced_id.symm⟩\n\nprotected lemma comp (hg : quotient_map g) (hf : quotient_map f) :\n  quotient_map (g ∘ f) :=\n⟨hg.left.comp hf.left, by rw [hg.right, hf.right, coinduced_compose]⟩\n\nprotected lemma of_quotient_map_compose (hf : continuous f) (hg : continuous g)\n  (hgf : quotient_map (g ∘ f)) : quotient_map g :=\n⟨hgf.1.of_comp,\n  le_antisymm\n    (by { rw [hgf.right, ← continuous_iff_coinduced_le], apply continuous_coinduced_rng.comp hf })\n    (by rwa ← continuous_iff_coinduced_le)⟩\n\nlemma of_inverse {g : β → α} (hf : continuous f) (hg : continuous g) (h : left_inverse g f) :\n  quotient_map g :=\nquotient_map.of_quotient_map_compose hf hg $ h.comp_eq_id.symm ▸ quotient_map.id\n\nprotected lemma continuous_iff (hf : quotient_map f) :\n  continuous g ↔ continuous (g ∘ f) :=\nby rw [continuous_iff_coinduced_le, continuous_iff_coinduced_le, hf.right, coinduced_compose]\n\nprotected lemma continuous (hf : quotient_map f) : continuous f :=\nhf.continuous_iff.mp continuous_id\n\nprotected lemma surjective (hf : quotient_map f) : surjective f := hf.1\n\nprotected lemma is_open_preimage (hf : quotient_map f) {s : set β} :\n  is_open (f ⁻¹' s) ↔ is_open s :=\n((quotient_map_iff.1 hf).2 s).symm\n\nprotected \n\nend quotient_map\n\n/-- A map `f : α → β` is said to be an *open map*, if the image of any open `U : set α`\nis open in `β`. -/\ndef is_open_map [topological_space α] [topological_space β] (f : α → β) :=\n∀ U : set α, is_open U → is_open (f '' U)\n\nnamespace is_open_map\nvariables [topological_space α] [topological_space β] [topological_space γ] {f : α → β}\n\nprotected lemma id : is_open_map (@id α) := assume s hs, by rwa [image_id]\n\nprotected lemma comp\n  {g : β → γ} {f : α → β} (hg : is_open_map g) (hf : is_open_map f) : is_open_map (g ∘ f) :=\nby intros s hs; rw [image_comp]; exact hg _ (hf _ hs)\n\nlemma is_open_range (hf : is_open_map f) : is_open (range f) :=\nby { rw ← image_univ, exact hf _ is_open_univ }\n\nlemma image_mem_nhds (hf : is_open_map f) {x : α} {s : set α} (hx : s ∈ 𝓝 x) :\n  f '' s ∈ 𝓝 (f x) :=\nlet ⟨t, hts, ht, hxt⟩ := mem_nhds_iff.1 hx in\nmem_of_superset (is_open.mem_nhds (hf t ht) (mem_image_of_mem _ hxt)) (image_subset _ hts)\n\nlemma range_mem_nhds (hf : is_open_map f) (x : α) : range f ∈ 𝓝 (f x) :=\nhf.is_open_range.mem_nhds $ mem_range_self _\n\nlemma maps_to_interior (hf : is_open_map f) {s : set α} {t : set β} (h : maps_to f s t) :\n  maps_to f (interior s) (interior t) :=\nmaps_to'.2 $ interior_maximal (h.mono interior_subset subset.rfl).image_subset\n  (hf _ is_open_interior)\n\nlemma image_interior_subset (hf : is_open_map f) (s : set α) :\n  f '' interior s ⊆ interior (f '' s) :=\n(hf.maps_to_interior (maps_to_image f s)).image_subset\n\nlemma nhds_le (hf : is_open_map f) (a : α) : 𝓝 (f a) ≤ (𝓝 a).map f :=\nle_map $ λ s, hf.image_mem_nhds\n\nlemma of_nhds_le (hf : ∀ a, 𝓝 (f a) ≤ map f (𝓝 a)) : is_open_map f :=\nλ s hs, is_open_iff_mem_nhds.2 $ λ b ⟨a, has, hab⟩,\n  hab ▸ hf _ (image_mem_map $ is_open.mem_nhds hs has)\n\nlemma of_sections {f : α → β}\n  (h : ∀ x, ∃ g : β → α, continuous_at g (f x) ∧ g (f x) = x ∧ right_inverse g f) :\n  is_open_map f :=\nof_nhds_le $ λ x, let ⟨g, hgc, hgx, hgf⟩ := h x in\ncalc 𝓝 (f x) = map f (map g (𝓝 (f x))) : by rw [map_map, hgf.comp_eq_id, map_id]\n... ≤ map f (𝓝 (g (f x))) : map_mono hgc\n... = map f (𝓝 x) : by rw hgx\n\nlemma of_inverse {f : α → β} {f' : β → α}\n  (h : continuous f') (l_inv : left_inverse f f') (r_inv : right_inverse f f') :\n  is_open_map f :=\nof_sections $ λ x, ⟨f', h.continuous_at, r_inv _, l_inv⟩\n\n/-- A continuous surjective open map is a quotient map. -/\nlemma to_quotient_map {f : α → β}\n  (open_map : is_open_map f) (cont : continuous f) (surj : surjective f) :\n  quotient_map f :=\nquotient_map_iff.2 ⟨surj, λ s, ⟨λ h, h.preimage cont, λ h, surj.image_preimage s ▸ open_map _ h⟩⟩\n\nlemma interior_preimage_subset_preimage_interior (hf : is_open_map f) {s : set β} :\n  interior (f⁻¹' s) ⊆ f⁻¹' (interior s) :=\nhf.maps_to_interior (maps_to_preimage _ _)\n\nlemma preimage_interior_eq_interior_preimage (hf₁ : is_open_map f) (hf₂ : continuous f)\n  (s : set β) :\n  f⁻¹' (interior s) = interior (f⁻¹' s) :=\nsubset.antisymm\n  (preimage_interior_subset_interior_preimage hf₂)\n  (interior_preimage_subset_preimage_interior hf₁)\n\nlemma preimage_closure_subset_closure_preimage (hf : is_open_map f) {s : set β} :\n  f ⁻¹' (closure s) ⊆ closure (f ⁻¹' s) :=\nbegin\n  rw ← compl_subset_compl,\n  simp only [← interior_compl, ← preimage_compl, hf.interior_preimage_subset_preimage_interior]\nend\n\nlemma preimage_closure_eq_closure_preimage (hf : is_open_map f) (hfc : continuous f) (s : set β) :\n  f ⁻¹' (closure s) = closure (f ⁻¹' s) :=\nhf.preimage_closure_subset_closure_preimage.antisymm (hfc.closure_preimage_subset s)\n\nlemma preimage_frontier_subset_frontier_preimage (hf : is_open_map f) {s : set β} :\n  f ⁻¹' (frontier s) ⊆ frontier (f ⁻¹' s) :=\nby simpa only [frontier_eq_closure_inter_closure, preimage_inter]\n  using inter_subset_inter hf.preimage_closure_subset_closure_preimage\n    hf.preimage_closure_subset_closure_preimage\n\nlemma preimage_frontier_eq_frontier_preimage (hf : is_open_map f) (hfc : continuous f) (s : set β) :\n  f ⁻¹' (frontier s) = frontier (f ⁻¹' s) :=\nby simp only [frontier_eq_closure_inter_closure, preimage_inter, preimage_compl,\n  hf.preimage_closure_eq_closure_preimage hfc]\n\nend is_open_map\n\nlemma is_open_map_iff_nhds_le [topological_space α] [topological_space β] {f : α → β} :\n  is_open_map f ↔ ∀(a:α), 𝓝 (f a) ≤ (𝓝 a).map f :=\n⟨λ hf, hf.nhds_le, is_open_map.of_nhds_le⟩\n\nlemma is_open_map_iff_interior [topological_space α] [topological_space β] {f : α → β} :\n  is_open_map f ↔ ∀ s, f '' (interior s) ⊆ interior (f '' s) :=\n⟨is_open_map.image_interior_subset, λ hs u hu, subset_interior_iff_is_open.mp $\n  calc f '' u = f '' (interior u) : by rw hu.interior_eq\n          ... ⊆ interior (f '' u) : hs u⟩\n\n/-- An inducing map with an open range is an open map. -/\nprotected lemma inducing.is_open_map [topological_space α] [topological_space β] {f : α → β}\n  (hi : inducing f) (ho : is_open (range f)) :\n  is_open_map f :=\nis_open_map.of_nhds_le $ λ x, (hi.map_nhds_of_mem _ $ is_open.mem_nhds ho $ mem_range_self _).ge\n\nsection is_closed_map\nvariables [topological_space α] [topological_space β]\n\n/-- A map `f : α → β` is said to be a *closed map*, if the image of any closed `U : set α`\nis closed in `β`. -/\ndef is_closed_map (f : α → β) := ∀ U : set α, is_closed U → is_closed (f '' U)\n\nend is_closed_map\n\nnamespace is_closed_map\n\nvariables [topological_space α] [topological_space β] [topological_space γ]\nopen function\n\nprotected lemma id : is_closed_map (@id α) := assume s hs, by rwa image_id\n\nprotected lemma comp {g : β → γ} {f : α → β} (hg : is_closed_map g) (hf : is_closed_map f) :\n  is_closed_map (g ∘ f) :=\nby { intros s hs, rw image_comp, exact hg _ (hf _ hs) }\n\nlemma closure_image_subset {f : α → β} (hf : is_closed_map f) (s : set α) :\n  closure (f '' s) ⊆ f '' closure s :=\nclosure_minimal (image_subset _ subset_closure) (hf _ is_closed_closure)\n\nlemma of_inverse {f : α → β} {f' : β → α}\n  (h : continuous f') (l_inv : left_inverse f f') (r_inv : right_inverse f f') :\n  is_closed_map f :=\nassume s hs,\nhave f' ⁻¹' s = f '' s, by ext x; simp [mem_image_iff_of_inverse r_inv l_inv],\nthis ▸ hs.preimage h\n\nlemma of_nonempty {f : α → β} (h : ∀ s, is_closed s → s.nonempty → is_closed (f '' s)) :\n  is_closed_map f :=\nbegin\n  intros s hs, cases eq_empty_or_nonempty s with h2s h2s,\n  { simp_rw [h2s, image_empty, is_closed_empty] },\n  { exact h s hs h2s }\nend\n\nlemma closed_range {f : α → β} (hf : is_closed_map f) : is_closed (range f) :=\n@image_univ _ _ f ▸ hf _ is_closed_univ\n\nend is_closed_map\n\nlemma inducing.is_closed_map [topological_space α] [topological_space β]\n  {f : α → β} (hf : inducing f) (h : is_closed (range f)) : is_closed_map f :=\nbegin\n  intros s hs,\n  rcases hf.is_closed_iff.1 hs with ⟨t, ht, rfl⟩,\n  rw image_preimage_eq_inter_range,\n  exact ht.inter h\nend\n\nlemma is_closed_map_iff_closure_image [topological_space α] [topological_space β] {f : α → β} :\n  is_closed_map f ↔ ∀ s, closure (f '' s) ⊆ f '' closure s :=\n⟨is_closed_map.closure_image_subset, λ hs c hc, is_closed_of_closure_subset $\n  calc closure (f '' c) ⊆ f '' (closure c) : hs c\n                    ... = f '' c : by rw hc.closure_eq⟩\n\nsection open_embedding\nvariables [topological_space α] [topological_space β] [topological_space γ]\n\n/-- An open embedding is an embedding with open image. -/\n@[mk_iff]\nstructure open_embedding (f : α → β) extends _root_.embedding f : Prop :=\n(open_range : is_open $ range f)\n\nlemma open_embedding.is_open_map {f : α → β} (hf : open_embedding f) : is_open_map f :=\nhf.to_embedding.to_inducing.is_open_map hf.open_range\n\nlemma open_embedding.map_nhds_eq {f : α → β} (hf : open_embedding f) (a : α) :\n  map f (𝓝 a) = 𝓝 (f a) :=\nhf.to_embedding.map_nhds_of_mem _ $ hf.open_range.mem_nhds $ mem_range_self _\n\nlemma open_embedding.open_iff_image_open {f : α → β} (hf : open_embedding f)\n  {s : set α} : is_open s ↔ is_open (f '' s) :=\n⟨hf.is_open_map s,\n λ h, begin\n   convert ← h.preimage hf.to_embedding.continuous,\n   apply preimage_image_eq _ hf.inj\n end⟩\n\nlemma open_embedding.tendsto_nhds_iff {ι : Type*}\n  {f : ι → β} {g : β → γ} {a : filter ι} {b : β} (hg : open_embedding g) :\n  tendsto f a (𝓝 b) ↔ tendsto (g ∘ f) a (𝓝 (g b)) :=\nhg.to_embedding.tendsto_nhds_iff\n\nlemma open_embedding.continuous {f : α → β} (hf : open_embedding f) : continuous f :=\nhf.to_embedding.continuous\n\nlemma open_embedding.open_iff_preimage_open {f : α → β} (hf : open_embedding f)\n  {s : set β} (hs : s ⊆ range f) : is_open s ↔ is_open (f ⁻¹' s) :=\nbegin\n  convert ←hf.open_iff_image_open.symm,\n  rwa [image_preimage_eq_inter_range, inter_eq_self_of_subset_left]\nend\n\nlemma open_embedding_of_embedding_open {f : α → β} (h₁ : embedding f)\n  (h₂ : is_open_map f) : open_embedding f :=\n⟨h₁, h₂.is_open_range⟩\n\nlemma open_embedding_iff_embedding_open {f : α → β} :\n  open_embedding f ↔ embedding f ∧ is_open_map f :=\n⟨λ h, ⟨h.1, h.is_open_map⟩, λ h, open_embedding_of_embedding_open h.1 h.2⟩\n\nlemma open_embedding_of_continuous_injective_open {f : α → β} (h₁ : continuous f)\n  (h₂ : injective f) (h₃ : is_open_map f) : open_embedding f :=\nbegin\n  simp only [open_embedding_iff_embedding_open, embedding_iff, inducing_iff_nhds, *, and_true],\n  exact λ a, le_antisymm (h₁.tendsto _).le_comap\n    (@comap_map _ _ (𝓝 a) _ h₂ ▸ comap_mono (h₃.nhds_le _))\nend\n\nlemma open_embedding_iff_continuous_injective_open {f : α → β} :\n  open_embedding f ↔ continuous f ∧ injective f ∧ is_open_map f :=\n⟨λ h, ⟨h.continuous, h.inj, h.is_open_map⟩,\n  λ h, open_embedding_of_continuous_injective_open h.1 h.2.1 h.2.2⟩\n\nlemma open_embedding_id : open_embedding (@id α) :=\n⟨embedding_id, is_open_map.id.is_open_range⟩\n\nlemma open_embedding.comp {g : β → γ} {f : α → β}\n  (hg : open_embedding g) (hf : open_embedding f) : open_embedding (g ∘ f) :=\n⟨hg.1.comp hf.1, (hg.is_open_map.comp hf.is_open_map).is_open_range⟩\n\nlemma open_embedding.is_open_map_iff {g : β → γ} {f : α → β} (hg : open_embedding g) :\n  is_open_map f ↔ is_open_map (g ∘ f) :=\nby simp only [is_open_map_iff_nhds_le, ← @map_map _ _ _ _ f g, ← hg.map_nhds_eq,\n  map_le_map_iff hg.inj]\n\nlemma open_embedding.of_comp_iff (f : α → β) {g : β → γ} (hg : open_embedding g) :\n  open_embedding (g ∘ f) ↔ open_embedding f :=\nby simp only [open_embedding_iff_continuous_injective_open, ← hg.is_open_map_iff,\n  ← hg.1.continuous_iff, hg.inj.of_comp_iff]\n\nlemma open_embedding.of_comp (f : α → β) {g : β → γ} (hg : open_embedding g)\n  (h : open_embedding (g ∘ f)) : open_embedding f :=\n(open_embedding.of_comp_iff f hg).1 h\n\nend open_embedding\n\nsection closed_embedding\nvariables [topological_space α] [topological_space β] [topological_space γ]\n\n/-- A closed embedding is an embedding with closed image. -/\n@[mk_iff]\nstructure closed_embedding (f : α → β) extends _root_.embedding f : Prop :=\n(closed_range : is_closed $ range f)\n\nvariables {f : α → β}\n\nlemma closed_embedding.tendsto_nhds_iff {ι : Type*}\n  {g : ι → α} {a : filter ι} {b : α} (hf : closed_embedding f) :\n  tendsto g a (𝓝 b) ↔ tendsto (f ∘ g) a (𝓝 (f b)) :=\nhf.to_embedding.tendsto_nhds_iff\n\nlemma closed_embedding.continuous (hf : closed_embedding f) : continuous f :=\nhf.to_embedding.continuous\n\nlemma closed_embedding.is_closed_map (hf : closed_embedding f) : is_closed_map f :=\nhf.to_embedding.to_inducing.is_closed_map hf.closed_range\n\nlemma closed_embedding.closed_iff_image_closed (hf : closed_embedding f)\n  {s : set α} : is_closed s ↔ is_closed (f '' s) :=\n⟨hf.is_closed_map s,\n λ h, begin\n   convert ←continuous_iff_is_closed.mp hf.continuous _ h,\n   apply preimage_image_eq _ hf.inj\n end⟩\n\nlemma closed_embedding.closed_iff_preimage_closed (hf : closed_embedding f)\n  {s : set β} (hs : s ⊆ range f) : is_closed s ↔ is_closed (f ⁻¹' s) :=\nbegin\n  convert ←hf.closed_iff_image_closed.symm,\n  rwa [image_preimage_eq_inter_range, inter_eq_self_of_subset_left]\nend\n\nlemma closed_embedding_of_embedding_closed (h₁ : embedding f)\n  (h₂ : is_closed_map f) : closed_embedding f :=\n⟨h₁, by convert h₂ univ is_closed_univ; simp⟩\n\nlemma closed_embedding_of_continuous_injective_closed (h₁ : continuous f)\n  (h₂ : injective f) (h₃ : is_closed_map f) : closed_embedding f :=\nbegin\n  refine closed_embedding_of_embedding_closed ⟨⟨_⟩, h₂⟩ h₃,\n  apply le_antisymm (continuous_iff_le_induced.mp h₁) _,\n  intro s',\n  change is_open _ ≤ is_open _,\n  rw [←is_closed_compl_iff, ←is_closed_compl_iff],\n  generalize : s'ᶜ = s,\n  rw is_closed_induced_iff,\n  refine λ hs, ⟨f '' s, h₃ s hs, _⟩,\n  rw preimage_image_eq _ h₂\nend\n\nlemma closed_embedding_id : closed_embedding (@id α) :=\n⟨embedding_id, by convert is_closed_univ; apply range_id⟩\n\nlemma closed_embedding.comp {g : β → γ} {f : α → β}\n  (hg : closed_embedding g) (hf : closed_embedding f) : closed_embedding (g ∘ f) :=\n⟨hg.to_embedding.comp hf.to_embedding, show is_closed (range (g ∘ f)),\n by rw [range_comp, ←hg.closed_iff_image_closed]; exact hf.closed_range⟩\n\nlemma closed_embedding.closure_image_eq {f : α → β} (hf : closed_embedding f) (s : set α) :\n  closure (f '' s) = f '' closure s :=\n(hf.is_closed_map.closure_image_subset _).antisymm\n  (image_closure_subset_closure_image hf.continuous)\n\nend closed_embedding\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/maps.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.48015156147328}}
{"text": "/-\nCopyright (c) 2022 Antoine Labelle. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Labelle\n\n! This file was ported from Lean 3 source module representation_theory.basic\n! leanprover-community/mathlib commit c04bc6e93e23aa0182aba53661a2211e80b6feac\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Module.Basic\nimport Mathbin.Algebra.Module.LinearMap\nimport Mathbin.Algebra.MonoidAlgebra.Basic\nimport Mathbin.LinearAlgebra.Dual\nimport Mathbin.LinearAlgebra.Contraction\nimport Mathbin.RingTheory.TensorProduct\n\n/-!\n# Monoid representations\n\nThis file introduces monoid representations and their characters and defines a few ways to construct\nrepresentations.\n\n## Main definitions\n\n  * representation.representation\n  * representation.character\n  * representation.tprod\n  * representation.lin_hom\n  * represensation.dual\n\n## Implementation notes\n\nRepresentations of a monoid `G` on a `k`-module `V` are implemented as\nhomomorphisms `G →* (V →ₗ[k] V)`.\n-/\n\n\nopen MonoidAlgebra (lift of)\n\nopen LinearMap\n\nsection\n\nvariable (k G V : Type _) [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V]\n\n/-- A representation of `G` on the `k`-module `V` is an homomorphism `G →* (V →ₗ[k] V)`.\n-/\nabbrev Representation :=\n  G →* V →ₗ[k] V\n#align representation Representation\n\nend\n\nnamespace Representation\n\nsection trivial\n\nvariable (k : Type _) {G V : Type _} [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V]\n\n/-- The trivial representation of `G` on a `k`-module V.\n-/\ndef trivial : Representation k G V :=\n  1\n#align representation.trivial Representation.trivial\n\n@[simp]\ntheorem trivial_def (g : G) (v : V) : trivial k g v = v :=\n  rfl\n#align representation.trivial_def Representation.trivial_def\n\nend trivial\n\nsection MonoidAlgebra\n\nvariable {k G V : Type _} [CommSemiring k] [Monoid G] [AddCommMonoid V] [Module k V]\n\nvariable (ρ : Representation k G V)\n\n/-- A `k`-linear representation of `G` on `V` can be thought of as\nan algebra map from `monoid_algebra k G` into the `k`-linear endomorphisms of `V`.\n-/\nnoncomputable def asAlgebraHom : MonoidAlgebra k G →ₐ[k] Module.End k V :=\n  (lift k G _) ρ\n#align representation.as_algebra_hom Representation.asAlgebraHom\n\ntheorem asAlgebraHom_def : asAlgebraHom ρ = (lift k G _) ρ :=\n  rfl\n#align representation.as_algebra_hom_def Representation.asAlgebraHom_def\n\n@[simp]\ntheorem asAlgebraHom_single (g : G) (r : k) : asAlgebraHom ρ (Finsupp.single g r) = r • ρ g := by\n  simp only [as_algebra_hom_def, MonoidAlgebra.lift_single]\n#align representation.as_algebra_hom_single Representation.asAlgebraHom_single\n\ntheorem asAlgebraHom_single_one (g : G) : asAlgebraHom ρ (Finsupp.single g 1) = ρ g := by simp\n#align representation.as_algebra_hom_single_one Representation.asAlgebraHom_single_one\n\ntheorem asAlgebraHom_of (g : G) : asAlgebraHom ρ (of k G g) = ρ g := by\n  simp only [MonoidAlgebra.of_apply, as_algebra_hom_single, one_smul]\n#align representation.as_algebra_hom_of Representation.asAlgebraHom_of\n\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler module[module] (module.End[module.End] k V) -/\n/-- If `ρ : representation k G V`, then `ρ.as_module` is a type synonym for `V`,\nwhich we equip with an instance `module (monoid_algebra k G) ρ.as_module`.\n\nYou should use `as_module_equiv : ρ.as_module ≃+ V` to translate terms.\n-/\n@[nolint unused_arguments]\ndef AsModule (ρ : Representation k G V) :=\n  V deriving AddCommMonoid,\n  «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler module[module] (module.End[module.End] k V)»\n#align representation.as_module Representation.AsModule\n\ninstance : Inhabited ρ.AsModule :=\n  ⟨0⟩\n\n/-- A `k`-linear representation of `G` on `V` can be thought of as\na module over `monoid_algebra k G`.\n-/\nnoncomputable instance asModuleModule : Module (MonoidAlgebra k G) ρ.AsModule :=\n  Module.compHom V (asAlgebraHom ρ).toRingHom\n#align representation.as_module_module Representation.asModuleModule\n\n/-- The additive equivalence from the `module (monoid_algebra k G)` to the original vector space\nof the representative.\n\nThis is just the identity, but it is helpful for typechecking and keeping track of instances.\n-/\ndef asModuleEquiv : ρ.AsModule ≃+ V :=\n  AddEquiv.refl _\n#align representation.as_module_equiv Representation.asModuleEquiv\n\n@[simp]\ntheorem asModuleEquiv_map_smul (r : MonoidAlgebra k G) (x : ρ.AsModule) :\n    ρ.asModuleEquiv (r • x) = ρ.asAlgebraHom r (ρ.asModuleEquiv x) :=\n  rfl\n#align representation.as_module_equiv_map_smul Representation.asModuleEquiv_map_smul\n\n@[simp]\ntheorem asModuleEquiv_symm_map_smul (r : k) (x : V) :\n    ρ.asModuleEquiv.symm (r • x) = algebraMap k (MonoidAlgebra k G) r • ρ.asModuleEquiv.symm x :=\n  by\n  apply_fun ρ.as_module_equiv\n  simp\n#align representation.as_module_equiv_symm_map_smul Representation.asModuleEquiv_symm_map_smul\n\n@[simp]\ntheorem asModuleEquiv_symm_map_rho (g : G) (x : V) :\n    ρ.asModuleEquiv.symm (ρ g x) = MonoidAlgebra.of k G g • ρ.asModuleEquiv.symm x :=\n  by\n  apply_fun ρ.as_module_equiv\n  simp\n#align representation.as_module_equiv_symm_map_rho Representation.asModuleEquiv_symm_map_rho\n\n/-- Build a `representation k G M` from a `[module (monoid_algebra k G) M]`.\n\nThis version is not always what we want, as it relies on an existing `[module k M]`\ninstance, along with a `[is_scalar_tower k (monoid_algebra k G) M]` instance.\n\nWe remedy this below in `of_module`\n(with the tradeoff that the representation is defined\nonly on a type synonym of the original module.)\n-/\nnoncomputable def ofModule' (M : Type _) [AddCommMonoid M] [Module k M]\n    [Module (MonoidAlgebra k G) M] [IsScalarTower k (MonoidAlgebra k G) M] : Representation k G M :=\n  (MonoidAlgebra.lift k G (M →ₗ[k] M)).symm (Algebra.lsmul k M)\n#align representation.of_module' Representation.ofModule'\n\nsection\n\nvariable (k G) (M : Type _) [AddCommMonoid M] [Module (MonoidAlgebra k G) M]\n\n/-- Build a `representation` from a `[module (monoid_algebra k G) M]`.\n\nNote that the representation is built on `restrict_scalars k (monoid_algebra k G) M`,\nrather than on `M` itself.\n-/\nnoncomputable def ofModule : Representation k G (RestrictScalars k (MonoidAlgebra k G) M) :=\n  (MonoidAlgebra.lift k G\n        (RestrictScalars k (MonoidAlgebra k G) M →ₗ[k]\n          RestrictScalars k (MonoidAlgebra k G) M)).symm\n    (RestrictScalars.lsmul k (MonoidAlgebra k G) M)\n#align representation.of_module Representation.ofModule\n\n/-!\n## `of_module` and `as_module` are inverses.\n\nThis requires a little care in both directions:\nthis is a categorical equivalence, not an isomorphism.\n\nSee `Rep.equivalence_Module_monoid_algebra` for the full statement.\n\nStarting with `ρ : representation k G V`, converting to a module and back again\nwe have a `representation k G (restrict_scalars k (monoid_algebra k G) ρ.as_module)`.\nTo compare these, we use the composition of `restrict_scalars_add_equiv` and `ρ.as_module_equiv`.\n\nSimilarly, starting with `module (monoid_algebra k G) M`,\nafter we convert to a representation and back to a module,\nwe have `module (monoid_algebra k G) (restrict_scalars k (monoid_algebra k G) M)`.\n-/\n\n\n@[simp]\ntheorem ofModule_asAlgebraHom_apply_apply (r : MonoidAlgebra k G)\n    (m : RestrictScalars k (MonoidAlgebra k G) M) :\n    ((ofModule k G M).asAlgebraHom r) m =\n      (RestrictScalars.addEquiv _ _ _).symm (r • RestrictScalars.addEquiv _ _ _ m) :=\n  by\n  apply MonoidAlgebra.induction_on r\n  · intro g\n    simp only [one_smul, MonoidAlgebra.lift_symm_apply, MonoidAlgebra.of_apply,\n      Representation.asAlgebraHom_single, Representation.ofModule, AddEquiv.apply_eq_iff_eq,\n      RestrictScalars.lsmul_apply_apply]\n  · intro f g fw gw\n    simp only [fw, gw, map_add, add_smul, LinearMap.add_apply]\n  · intro r f w\n    simp only [w, AlgHom.map_smul, LinearMap.smul_apply,\n      RestrictScalars.addEquiv_symm_map_smul_smul]\n#align representation.of_module_as_algebra_hom_apply_apply Representation.ofModule_asAlgebraHom_apply_apply\n\n@[simp]\ntheorem ofModule_asModule_act (g : G) (x : RestrictScalars k (MonoidAlgebra k G) ρ.AsModule) :\n    ofModule k G ρ.AsModule g x =\n      (RestrictScalars.addEquiv _ _ _).symm\n        (ρ.asModuleEquiv.symm (ρ g (ρ.asModuleEquiv (RestrictScalars.addEquiv _ _ _ x)))) :=\n  by\n  apply_fun RestrictScalars.addEquiv _ _ ρ.as_module using\n    (RestrictScalars.addEquiv _ _ _).Injective\n  dsimp [of_module, RestrictScalars.lsmul_apply_apply]\n  simp\n#align representation.of_module_as_module_act Representation.ofModule_asModule_act\n\ntheorem smul_ofModule_asModule (r : MonoidAlgebra k G) (m : (ofModule k G M).AsModule) :\n    (RestrictScalars.addEquiv _ _ _) ((ofModule k G M).asModuleEquiv (r • m)) =\n      r • (RestrictScalars.addEquiv _ _ _) ((ofModule k G M).asModuleEquiv m) :=\n  by\n  dsimp\n  simp only [AddEquiv.apply_symm_apply, of_module_as_algebra_hom_apply_apply]\n#align representation.smul_of_module_as_module Representation.smul_ofModule_asModule\n\nend\n\nend MonoidAlgebra\n\nsection AddCommGroup\n\nvariable {k G V : Type _} [CommRing k] [Monoid G] [I : AddCommGroup V] [Module k V]\n\nvariable (ρ : Representation k G V)\n\ninstance : AddCommGroup ρ.AsModule :=\n  I\n\nend AddCommGroup\n\nsection MulAction\n\nvariable (k : Type _) [CommSemiring k] (G : Type _) [Monoid G] (H : Type _) [MulAction G H]\n\n/-- A `G`-action on `H` induces a representation `G →* End(k[H])` in the natural way. -/\nnoncomputable def ofMulAction : Representation k G (H →₀ k)\n    where\n  toFun g := Finsupp.lmapDomain k k ((· • ·) g)\n  map_one' := by\n    ext (x y)\n    dsimp\n    simp\n  map_mul' x y := by\n    ext (z w)\n    simp [mul_smul]\n#align representation.of_mul_action Representation.ofMulAction\n\nvariable {k G H}\n\ntheorem ofMulAction_def (g : G) : ofMulAction k G H g = Finsupp.lmapDomain k k ((· • ·) g) :=\n  rfl\n#align representation.of_mul_action_def Representation.ofMulAction_def\n\ntheorem ofMulAction_single (g : G) (x : H) (r : k) :\n    ofMulAction k G H g (Finsupp.single x r) = Finsupp.single (g • x) r :=\n  Finsupp.mapDomain_single\n#align representation.of_mul_action_single Representation.ofMulAction_single\n\nend MulAction\n\nsection Group\n\nvariable {k G V : Type _} [CommSemiring k] [Group G] [AddCommMonoid V] [Module k V]\n\nvariable (ρ : Representation k G V)\n\n@[simp]\ntheorem ofMulAction_apply {H : Type _} [MulAction G H] (g : G) (f : H →₀ k) (h : H) :\n    ofMulAction k G H g f h = f (g⁻¹ • h) :=\n  by\n  conv_lhs => rw [← smul_inv_smul g h]\n  let h' := g⁻¹ • h\n  change of_mul_action k G H g f (g • h') = f h'\n  have hg : Function.Injective ((· • ·) g : H → H) :=\n    by\n    intro h₁ h₂\n    simp\n  simp only [of_mul_action_def, Finsupp.lmapDomain_apply, Finsupp.mapDomain_apply, hg]\n#align representation.of_mul_action_apply Representation.ofMulAction_apply\n\ntheorem ofMulAction_self_smul_eq_mul (x : MonoidAlgebra k G) (y : (ofMulAction k G G).AsModule) :\n    x • y = (x * y : MonoidAlgebra k G) :=\n  x.inductionOn (fun g => by show as_algebra_hom _ _ _ = _ <;> ext <;> simp)\n    (fun x y hx hy => by simp only [hx, hy, add_mul, add_smul]) fun r x hx => by\n    show as_algebra_hom _ _ _ = _ <;> simpa [← hx]\n#align representation.of_mul_action_self_smul_eq_mul Representation.ofMulAction_self_smul_eq_mul\n\n/-- If we equip `k[G]` with the `k`-linear `G`-representation induced by the left regular action of\n`G` on itself, the resulting object is isomorphic as a `k[G]`-module to `k[G]` with its natural\n`k[G]`-module structure. -/\n@[simps]\nnoncomputable def ofMulActionSelfAsModuleEquiv :\n    (ofMulAction k G G).AsModule ≃ₗ[MonoidAlgebra k G] MonoidAlgebra k G :=\n  { asModuleEquiv _ with map_smul' := ofMulAction_self_smul_eq_mul }\n#align representation.of_mul_action_self_as_module_equiv Representation.ofMulActionSelfAsModuleEquiv\n\n/-- When `G` is a group, a `k`-linear representation of `G` on `V` can be thought of as\na group homomorphism from `G` into the invertible `k`-linear endomorphisms of `V`.\n-/\ndef asGroupHom : G →* Units (V →ₗ[k] V) :=\n  MonoidHom.toHomUnits ρ\n#align representation.as_group_hom Representation.asGroupHom\n\ntheorem asGroupHom_apply (g : G) : ↑(asGroupHom ρ g) = ρ g := by\n  simp only [as_group_hom, MonoidHom.coe_toHomUnits]\n#align representation.as_group_hom_apply Representation.asGroupHom_apply\n\nend Group\n\nsection TensorProduct\n\nvariable {k G V W : Type _} [CommSemiring k] [Monoid G]\n\nvariable [AddCommMonoid V] [Module k V] [AddCommMonoid W] [Module k W]\n\nvariable (ρV : Representation k G V) (ρW : Representation k G W)\n\nopen TensorProduct\n\n/-- Given representations of `G` on `V` and `W`, there is a natural representation of `G` on their\ntensor product `V ⊗[k] W`.\n-/\ndef tprod : Representation k G (V ⊗[k] W)\n    where\n  toFun g := TensorProduct.map (ρV g) (ρW g)\n  map_one' := by simp only [map_one, TensorProduct.map_one]\n  map_mul' g h := by simp only [map_mul, TensorProduct.map_mul]\n#align representation.tprod Representation.tprod\n\n-- mathport name: «expr ⊗ »\nlocal notation ρV \" ⊗ \" ρW => tprod ρV ρW\n\n@[simp]\ntheorem tprod_apply (g : G) : (ρV ⊗ ρW) g = TensorProduct.map (ρV g) (ρW g) :=\n  rfl\n#align representation.tprod_apply Representation.tprod_apply\n\ntheorem smul_tprod_one_asModule (r : MonoidAlgebra k G) (x : V) (y : W) :\n    (r • x ⊗ₜ y : (ρV.tprod 1).AsModule) = (r • x : ρV.AsModule) ⊗ₜ y :=\n  by\n  show as_algebra_hom _ _ _ = as_algebra_hom _ _ _ ⊗ₜ _\n  simp only [as_algebra_hom_def, MonoidAlgebra.lift_apply, tprod_apply, MonoidHom.one_apply,\n    LinearMap.finsupp_sum_apply, LinearMap.smul_apply, TensorProduct.map_tmul, LinearMap.one_apply]\n  simp only [Finsupp.sum, TensorProduct.sum_tmul]\n  rfl\n#align representation.smul_tprod_one_as_module Representation.smul_tprod_one_asModule\n\ntheorem smul_one_tprod_asModule (r : MonoidAlgebra k G) (x : V) (y : W) :\n    (r • x ⊗ₜ y : ((1 : Representation k G V).tprod ρW).AsModule) = x ⊗ₜ (r • y : ρW.AsModule) :=\n  by\n  show as_algebra_hom _ _ _ = _ ⊗ₜ as_algebra_hom _ _ _\n  simp only [as_algebra_hom_def, MonoidAlgebra.lift_apply, tprod_apply, MonoidHom.one_apply,\n    LinearMap.finsupp_sum_apply, LinearMap.smul_apply, TensorProduct.map_tmul, LinearMap.one_apply]\n  simp only [Finsupp.sum, TensorProduct.tmul_sum, TensorProduct.tmul_smul]\n#align representation.smul_one_tprod_as_module Representation.smul_one_tprod_asModule\n\nend TensorProduct\n\nsection LinearHom\n\nvariable {k G V W : Type _} [CommSemiring k] [Group G]\n\nvariable [AddCommMonoid V] [Module k V] [AddCommMonoid W] [Module k W]\n\nvariable (ρV : Representation k G V) (ρW : Representation k G W)\n\n/-- Given representations of `G` on `V` and `W`, there is a natural representation of `G` on the\nmodule `V →ₗ[k] W`, where `G` acts by conjugation.\n-/\ndef linHom : Representation k G (V →ₗ[k] W)\n    where\n  toFun g :=\n    { toFun := fun f => ρW g ∘ₗ f ∘ₗ ρV g⁻¹\n      map_add' := fun f₁ f₂ => by simp_rw [add_comp, comp_add]\n      map_smul' := fun r f => by simp_rw [RingHom.id_apply, smul_comp, comp_smul] }\n  map_one' :=\n    LinearMap.ext fun x => by\n      simp_rw [coe_mk, inv_one, map_one, one_apply, one_eq_id, comp_id, id_comp]\n  map_mul' g h :=\n    LinearMap.ext fun x => by\n      simp_rw [coe_mul, coe_mk, Function.comp_apply, mul_inv_rev, map_mul, mul_eq_comp, comp_assoc]\n#align representation.lin_hom Representation.linHom\n\n@[simp]\ntheorem linHom_apply (g : G) (f : V →ₗ[k] W) : (linHom ρV ρW) g f = ρW g ∘ₗ f ∘ₗ ρV g⁻¹ :=\n  rfl\n#align representation.lin_hom_apply Representation.linHom_apply\n\n/-- The dual of a representation `ρ` of `G` on a module `V`, given by `(dual ρ) g f = f ∘ₗ (ρ g⁻¹)`,\nwhere `f : module.dual k V`.\n-/\ndef dual : Representation k G (Module.Dual k V)\n    where\n  toFun g :=\n    { toFun := fun f => f ∘ₗ ρV g⁻¹\n      map_add' := fun f₁ f₂ => by simp only [add_comp]\n      map_smul' := fun r f => by\n        ext\n        simp only [coe_comp, Function.comp_apply, smul_apply, RingHom.id_apply] }\n  map_one' := by\n    ext\n    simp only [coe_comp, Function.comp_apply, map_one, inv_one, coe_mk, one_apply]\n  map_mul' g h := by\n    ext\n    simp only [coe_comp, Function.comp_apply, mul_inv_rev, map_mul, coe_mk, mul_apply]\n#align representation.dual Representation.dual\n\n@[simp]\ntheorem dual_apply (g : G) : (dual ρV) g = Module.Dual.transpose (ρV g⁻¹) :=\n  rfl\n#align representation.dual_apply Representation.dual_apply\n\n/-- Given $k$-modules $V, W$, there is a homomorphism $φ : V^* ⊗ W → Hom_k(V, W)$\n(implemented by `linear_algebra.contraction.dual_tensor_hom`).\nGiven representations of $G$ on $V$ and $W$,there are representations of $G$ on  $V^* ⊗ W$ and on\n$Hom_k(V, W)$.\nThis lemma says that $φ$ is $G$-linear.\n-/\ntheorem dualTensorHom_comm (g : G) :\n    dualTensorHom k V W ∘ₗ TensorProduct.map (ρV.dual g) (ρW g) =\n      (linHom ρV ρW) g ∘ₗ dualTensorHom k V W :=\n  by ext; simp [Module.Dual.transpose_apply]\n#align representation.dual_tensor_hom_comm Representation.dualTensorHom_comm\n\nend LinearHom\n\nend Representation\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RepresentationTheory/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.48015155525648323}}
{"text": "import data.nat.basic\nimport data.nat.pow\nimport data.int.basic\nimport data.real.basic\nimport data.list\n\n\n-- ### Exercise 2\n\nnamespace exercise_2\n\n-- Functions\ndef double : ℕ → ℕ := λ x, x + x\ndef square : ℕ → ℕ := λ x, x * x\ndef do_twice : (ℕ → ℕ) → (ℕ → ℕ) := λ f x, f (f x)\ndef Do_Twice : ((ℕ → ℕ) → (ℕ → ℕ)) → (ℕ → ℕ) → (ℕ → ℕ) := λ f g, (f (f g))\n#reduce Do_Twice do_twice double 2\n\ndef curry {α β γ : Type*} (f : α × β → γ) : α → β → γ := λ a b, f (a, b)\ndef uncurry {α β γ : Type*} (f : α → β → γ) : α × β → γ := λ ⟨a, b⟩, f a b\n\n-- \"Vector\" type former & related dependent functions\nuniverse u\nconstant vec : Type u → ℕ → Type u\n\nnamespace vec\n  constant empty : Π (α : Type u), vec α 0\n  constant cons : Π {α : Type u} {n : ℕ}, α → vec α n → vec α (n + 1)\n  constant append : Π {α : Type u} {n m : ℕ}, vec α m → vec α n → vec α (n + m)\n  constant add : Π {α : Type u} {n : ℕ}, vec α n → vec α n → vec α n\n  constant reverse : Π {α : Type u} {n : ℕ}, vec α n → vec α n\nend vec\n\n#check vec.empty ℕ\nnoncomputable def v0 := vec.empty ℕ -- TODO: what is `noncomputable`?\n#check v0\nnoncomputable def v1 := vec.cons 0 v0\n#check v1\nvariable v3 : vec ℕ 3\n#check vec.add v3 v3\n#check vec.reverse v3\n\n-- \"Matrix\" type former & related dependent functions\nconstant matrix : Type u → ℕ → ℕ → Type u\n\nnamespace matrix\n  constant add : Π {α : Type u} {n m : ℕ}, matrix α m n → matrix α m n → matrix α m n\n  constant mul : Π {α : Type u} {n m k : ℕ}, matrix α m k → matrix α k n → matrix α m n\n  constant mulvec : Π {α : Type u} {n m : ℕ}, matrix α m n → vec α n → vec α m\nend matrix\n\n#check matrix ℕ 5 3\nvariable m : matrix ℕ 5 3\nvariable m' : matrix ℕ 3 2\n#check matrix.mulvec m v3\n#check matrix.mul m m'\n\nend exercise_2\n\n\n-- ### Exercise 3\n\nnamespace exercise_3_1\n\nvariables p q r : Prop\n\n-- Commutativity of ∧ and ∨\nexample : p ∧ q ↔ q ∧ p :=\n  iff.intro\n    (λ ⟨hp, hq⟩, ⟨hq, hp⟩)\n    (λ ⟨hq, hp⟩, ⟨hp, hq⟩)\nexample : p ∨ q ↔ q ∨ p :=\n  iff.intro\n    (λ h, or.elim h (λ hp, or.inr hp) (λ hq, or.inl hq))\n    (λ h, or.elim h (λ hq, or.inr hq) (λ hp, or.inl hp))\n\n-- Associativity of ∧ and ∨\nexample : (p ∧ q) ∧ r ↔ p ∧ (q ∧ r) :=\n  iff.intro\n    (λ ⟨⟨hp, hq⟩, hr⟩, ⟨hp, ⟨hq, hr⟩⟩)\n    (λ ⟨hp, ⟨hq, hr⟩⟩, ⟨⟨hp, hq⟩, hr⟩)\nexample : (p ∨ q) ∨ r ↔ p ∨ (q ∨ r) :=\n  iff.intro\n    (λ h, h.elim\n      (λ hpq, hpq.elim or.inl (or.inr ∘ or.inl))\n      (or.inr ∘ or.inr))\n    (λ h, h.elim\n      (or.inl ∘ or.inl)\n      (λ hqr, hqr.elim (or.inl ∘ or.inr) or.inr))\n\n-- Distributivity\nexample : p ∧ (q ∨ r) ↔ (p ∧ q) ∨ (p ∧ r) :=\n  iff.intro\n    (λ ⟨hp, hqr⟩, hqr.elim (λ hq, or.inl ⟨hp, hq⟩) (λ hr, or.inr ⟨hp, hr⟩))\n    (λ h, h.elim (λ ⟨hp, hq⟩, ⟨hp, or.inl hq⟩) (λ ⟨hp, hr⟩, ⟨hp, or.inr hr⟩))\nexample : p ∨ (q ∧ r) ↔ (p ∨ q) ∧ (p ∨ r) :=\n  iff.intro\n    (λ h, h.elim (λ hp, ⟨or.inl hp, or.inl hp⟩) (λ ⟨hq, hr⟩, ⟨or.inr hq, or.inr hr⟩))\n    (λ ⟨hpq, hpr⟩, hpq.elim or.inl (λ hq, hpr.elim or.inl (λ hr, or.inr ⟨hq, hr⟩)))\n\n-- Other properties\nexample : (p → (q → r)) ↔ (p ∧ q → r) :=\n  iff.intro\n    (λ f ⟨hp, hq⟩, f hp hq)\n    (λ f hp hq, f ⟨hp, hq⟩)\nexample : ((p ∨ q) → r) ↔ (p → r) ∧ (q → r) :=\n  iff.intro\n    (λ h, ⟨h ∘ or.inl, h ∘ or.inr⟩)\n    (λ ⟨hpr, hqr⟩ hpq, hpq.elim hpr hqr)\nexample : ¬(p ∨ q) ↔ ¬p ∧ ¬q := \n  iff.intro\n    (λ h, ⟨h ∘ or.inl, h ∘ or.inr⟩)\n    (λ ⟨hnp, hnq⟩, (λ h, h.elim hnp hnq))\nexample : ¬p ∨ ¬q → ¬(p ∧ q) :=\n  (λ h ⟨hp, hq⟩, h.elim (λ hnp, hnp hp) (λ hnq, hnq hq))\nexample : ¬(p ∧ ¬p) := (λ ⟨hp, hnp⟩, hnp hp)\nexample : p ∧ ¬q → ¬(p → q) := (λ ⟨hp, hnq⟩ hpq, hnq (hpq hp))\nexample : ¬p → (p → q) := (λ hnp hp, (hnp hp).elim)\nexample : (¬p ∨ q) → (p → q) := (λ h, h.elim (λ hnp hp, (hnp hp).elim) (λ hq _, hq))\nexample : p ∨ false ↔ p := iff.intro (λ h, h.elim id false.elim) or.inl\nexample : p ∧ false ↔ false := iff.intro and.right false.elim\nexample : (p → q) → (¬q → ¬p) := (λ hpq hnq hp, hnq (hpq hp))\n\nend exercise_3_1\nnamespace exercise_3_2\n\n\nvariables p q r s : Prop\n\n-- These require classical reasoning.\nexample : (p → r ∨ s) → ((p → r) ∨ (p → s)) :=\n  (λ h, (em p).elim\n    (λ hp, (h hp).elim (λ hr, or.inl (λ _, hr)) (λ hs, or.inr (λ _, hs)))\n    (λ hnp, or.inl (λ hp, (hnp hp).elim)))\nexample : ¬(p ∧ q) → ¬p ∨ ¬q :=\n  (λ h, (em p).elim\n    (λ hp, or.inr (λ hq, h ⟨hp, hq⟩))\n    or.inl)\nexample : ¬(p → q) → p ∧ ¬q :=\n  (λ h, and.intro\n    ((em q).elim\n      (λ hq, (h (λ _, hq)).elim)\n      (λ hnq, (em p).elim id (λ hnp, (h (λ hp, (hnp hp).elim)).elim)))\n    (λ hq, h (λ _, hq)))\nexample : (p → q) → (¬p ∨ q) :=\n  (λ hpq, (em p).elim (or.inr ∘ hpq) or.inl)\nexample : (¬q → ¬p) → (p → q) :=\n  (λ h, (em q).elim (λ hq _, hq) (λ hnq hp, (h hnq hp).elim))\nexample : p ∨ ¬p := em p\nexample : (((p → q) → p) → p) :=\n  (em p).elim\n    (λ hp _, hp)\n    (λ hnp, (em q).elim\n      (λ hq h, h (λ _, hq))\n      (λ hnq h, h (λ hp, (hnp hp).elim)))\n\n-- Prove ¬(p ↔ ¬p) without using classical logic.\nexample : ¬(p ↔ ¬p) :=\n  (λ ⟨h₁, h₂⟩,\n    (λ hp, h₁ hp hp) -- \"Don't eliminate cuts!\" (will make the proof longer)\n      (h₂ (λ hp, h₁ hp hp)))\n\nend exercise_3_2\n\n\n-- ### Exercise 4\n\nnamespace exercise_4\n\nsection\n  variables (α : Type*) (p q : α → Prop)\n\n  example : (∀ x, p x ∧ q x) ↔ (∀ x, p x) ∧ (∀ x, q x) :=\n    iff.intro\n      (λ h, ⟨(λ x, (h x).left), (λ x, (h x).right)⟩)\n      (λ ⟨h₁, h₂⟩ x, ⟨h₁ x, h₂ x⟩)\n  example : (∀ x, p x → q x) → (∀ x, p x) → (∀ x, q x) :=\n    λ h₁ h₂ x, h₁ x (h₂ x)\n  example : (∀ x, p x) ∨ (∀ x, q x) → ∀ x, p x ∨ q x :=\n    λ h x, h.elim (λ h₁, or.inl (h₁ x)) (λ h₁, or.inr (h₁ x))\nend\n\nsection\n  variables (α : Type*) (p q : α → Prop)\n  variable r : Prop\n\n  -- One direction of the second of these requires classical logic\n  example : α → ((∀ x : α, r) ↔ r) :=\n    λ x, (iff.intro (λ h, h x) (λ h _, h))\n  example : (∀ x, p x ∨ r) ↔ (∀ x, p x) ∨ r :=\n    iff.intro\n      (λ h, (classical.em r).elim (or.inr) (λ hnr, or.inl (λ x, (h x).elim id (λ hr, (hnr hr).elim))))\n      (λ h, h.elim (λ h₁ x, or.inl (h₁ x)) (λ h₂ x, or.inr h₂))\n  example : (∀ x, r → p x) ↔ (r → ∀ x, p x) :=\n    iff.intro\n      (λ h hr x, h x hr)\n      (λ h x hr, h hr x)\nend\n\nsection\n  variables (men : Type*) (barber : men)\n  variable  (shaves : men → men → Prop)\n\n  example (h : ∀ x : men, shaves barber x ↔ ¬ shaves x x) : false :=\n    (h barber).elim\n      (λ (h₁ : shaves barber barber → ¬shaves barber barber) h₂,\n        (λ hs, h₁ hs hs) (h₂ (λ hs, h₁ hs hs)))\nend\n\n-- See: https://discord.com/channels/679792285910827018/707609591940382830/733322519112712362\nsection\n  def prime (n : ℕ) : Prop :=\n    ∀ (x : ℕ), (∃ y, n = x * y) → x = 1 ∨ x = n\n\n  def infinitely_many_primes : Prop :=\n    ∀ (x : ℕ), prime x → (∃ y, prime y ∧ x < y)\n\n  def Fermat_prime (n : ℕ) : Prop :=\n    prime n ∧ ∃ (x : ℕ), n = 2 ^ (2 ^ x) + 1\n\n  def infinitely_many_Fermat_primes : Prop :=\n    ∀ (x : ℕ), Fermat_prime x → (∃ y, Fermat_prime y ∧ x < y)\n\n  def goldbach_conjecture : Prop :=\n    ∀ (n : ℕ), even n → (2 < n) → (∃ p₁ p₂, prime p₁ ∧ prime p₂ ∧ n = p₁ + p₂)\n\n  def Goldbach's_weak_conjecture : Prop :=\n    ∀ (n : ℕ), odd n → (5 < n) → (∃ p₁ p₂ p₃, prime p₁ ∧ prime p₂ ∧ prime p₃ ∧ n = p₁ + p₂ + p₃)\n\n  def Fermat's_last_theorem : Prop :=\n    ∀ (n : ℕ), (2 < n) → ∀ (a b c : ℕ), 0 < a → 0 < b → a ^ n + b ^ n ≠ c ^ n\nend\n\nsection\n  variables (α : Type*) (p q : α → Prop)\n  variable r : Prop\n\n  example : (∃ x : α, r) → r :=\n    λ ⟨x, hx⟩, hx\n  example (a : α) : r → (∃ x : α, r) :=\n    λ h, ⟨a, h⟩\n  example : (∃ x, p x ∧ r) ↔ (∃ x, p x) ∧ r :=\n    iff.intro\n      (λ ⟨x, hx, hr⟩, ⟨⟨x, hx⟩, hr⟩)\n      (λ ⟨⟨x, hx⟩, hr⟩, ⟨x, ⟨hx, hr⟩⟩)\n  example : (∃ x, p x ∨ q x) ↔ (∃ x, p x) ∨ (∃ x, q x) :=\n    iff.intro\n      (λ ⟨x, hx⟩, hx.elim (λ hpx, or.inl ⟨x, hpx⟩) (λ hqx, or.inr ⟨x, hqx⟩))\n      (λ h, h.elim (λ ⟨x, hx⟩, ⟨x, or.inl hx⟩) (λ ⟨x, hx⟩, ⟨x, or.inr hx⟩))\n\n  example : (∀ x, p x) ↔ ¬ (∃ x, ¬ p x) :=\n    iff.intro\n      (λ h ⟨x, hx⟩, hx (h x))\n      (λ h x, by_contra (λ hx, h ⟨x, hx⟩))\n  example : (∃ x, p x) ↔ ¬ (∀ x, ¬ p x) :=\n    iff.intro\n      (λ ⟨x, hx⟩ h, h x hx)\n      (λ h, by_contra (λ h₁, h (λ x hx, h₁ ⟨x, hx⟩)))\n  example : (¬ ∃ x, p x) ↔ (∀ x, ¬ p x) :=\n    iff.intro\n      (λ h x hx, h ⟨x, hx⟩)\n      (λ h ⟨x, hx⟩, h x hx)\n  example : (¬ ∀ x, p x) ↔ (∃ x, ¬ p x) :=\n    iff.intro\n      (λ h, by_contra (λ h₁, h (λ x, by_contra (λ hx, h₁ ⟨x, hx⟩))))\n      (λ ⟨x, hx⟩ h, hx (h x))\n\n  example : (∀ x, p x → r) ↔ (∃ x, p x) → r :=\n    iff.intro\n      (λ h ⟨x, hx⟩, h x hx)\n      (λ h x hx, h ⟨x, hx⟩)\n  example (a : α) : (∃ x, p x → r) ↔ (∀ x, p x) → r :=\n    iff.intro\n      (λ ⟨x, hx⟩ h, hx (h x))\n      (λ h, (em (∀ x, p x)).elim\n        (λ h₁, ⟨a, λ _, h h₁⟩)\n        (λ h₁,\n          have h₂ : (∃ (x : α), ¬(p x)),\n          from by_contra\n            (λ h₂, h₁ (λ x, by_contra\n              (λ h₃, h₂ ⟨x, h₃⟩))),\n          let ⟨w, hw⟩ := h₂ in\n            ⟨w, (λ hw₁, (hw hw₁).elim)⟩))\n  example (a : α) : (∃ x, r → p x) ↔ (r → ∃ x, p x) :=\n    iff.intro\n      (λ ⟨x, hx⟩ h, ⟨x, hx h⟩)\n      (λ h, (em r).elim\n        (λ hr, exists.elim (h hr) (λ a ha, ⟨a, (λ _, ha)⟩))\n        (λ hnr, ⟨a, (λ hr, (hnr hr).elim)⟩))\nend\n\nsection\n  variables log exp    : ℝ → ℝ\n  variable  log_exp_eq : ∀ x, log (exp x) = x\n  variable  exp_log_eq : ∀ {x}, x > 0 → exp (log x) = x\n  variable  exp_pos    : ∀ x, exp x > 0\n  variable  exp_add    : ∀ x y, exp (x + y) = exp x * exp y\n\n  -- this ensures the assumptions are available in tactic proofs\n  include log_exp_eq exp_log_eq exp_pos exp_add\n\n  example (x y z : ℝ) : exp (x + y + z) = exp x * exp y * exp z :=\n  by rw [exp_add, exp_add]\n\n  example (y : real) (h : y > 0) : exp (log y) = y :=\n    exp_log_eq h\n\n  theorem log_mul {x y : real} (hx : x > 0) (hy : y > 0) :\n    log (x * y) = log x + log y :=\n  by calc log (x * y)\n        = log (exp (log x) * exp (log y)) : by rw [exp_log_eq hx, exp_log_eq hy]\n    ... = log (exp (log x + log y)) : by rw exp_add\n    ... = log x + log y : by rw log_exp_eq\nend\n\nsection\n  example (x : ℤ) : x * 0 = 0 :=\n  by calc x * 0\n        = x * 0 + x * 0 + -(x * 0) : by rw [add_assoc, add_neg_self, add_zero]\n    ... = x * (0 * 1 + 0 * 1) + -(x * 0) : by rw [mul_one, mul_add]\n    ... = x * 0 + -(x * 0) : by rw [mul_one, add_zero]\n    ... = 0 : by rw add_neg_self\nend\n\nend exercise_4\n\n\n-- ### Exercise 5\n\nnamespace exercise_5_1\n\nvariables p q r : Prop\n\n-- Commutativity of ∧ and ∨\nexample : p ∧ q ↔ q ∧ p :=\nbegin\n  split,\n  { intros h, exact let ⟨hp, hq⟩ := h in ⟨hq, hp⟩, },\n  { intros h, exact let ⟨hq, hp⟩ := h in ⟨hp, hq⟩, },\nend\nexample : p ∨ q ↔ q ∨ p :=\nbegin\n  apply iff.intro,\n  { exact (λ h, h.elim or.inr or.inl), },\n  { exact (λ h, h.elim or.inr or.inl), },\nend\n\n-- Associativity of ∧ and ∨\nexample : (p ∧ q) ∧ r ↔ p ∧ (q ∧ r) := by {\n  split,\n  { rintros ⟨⟨hp, hq⟩, hr⟩, exact ⟨hp, hq, hr⟩, },\n  { rintros ⟨hp, hq, hr⟩, exact ⟨⟨hp, hq⟩, hr⟩, },\n}\nexample : (p ∨ q) ∨ r ↔ p ∨ (q ∨ r) := by {\n  split,\n  { assume h,\n      cases h, cases h,\n        exacts [or.inl h, or.inr (or.inl h), or.inr (or.inr h)], },\n  { assume h,\n      cases h, swap, cases h,\n        exacts [or.inl (or.inr h), or.inr h, or.inl (or.inl h)], },\n}\n\n-- Distributivity\nexample : p ∧ (q ∨ r) ↔ (p ∧ q) ∨ (p ∧ r) := by {\n  split,\n  { rintros ⟨hp, hq | hr⟩,\n      left, exact ⟨hp, hq⟩,\n      right, exact ⟨hp, hr⟩, },\n  { rintros (⟨hp, hq⟩ | ⟨hp, hr⟩),\n      exact ⟨hp, or.inl hq⟩,\n      exact ⟨hp, or.inr hr⟩, },\n}\nexample : p ∨ (q ∧ r) ↔ (p ∨ q) ∧ (p ∨ r) := by {\n  split,\n  { rintros (hp | ⟨hq, hr⟩),\n      exacts [⟨or.inl hp, or.inl hp⟩, ⟨or.inr hq, or.inr hr⟩], },\n  { rintros ⟨hp | hq, hp | hr⟩,\n      exacts [or.inl hp, or.inl hp, or.inl hp, or.inr ⟨hq, hr⟩], },\n}\n\n-- Other properties\nexample : (p → (q → r)) ↔ (p ∧ q → r) := by {\n  split,\n  { rintros f ⟨hp, hq⟩, exact f hp hq, },\n  { rintros f hp hq, exact f ⟨hp, hq⟩, },\n}\nexample : ((p ∨ q) → r) ↔ (p → r) ∧ (q → r) := by {\n  split,\n  { intros f, split, exacts [f ∘ or.inl, f ∘ or.inr], },\n  { rintros ⟨f, g⟩ (hp | hq), exacts [f hp, g hq], },\n}\nexample : ¬(p ∨ q) ↔ ¬p ∧ ¬q := by sorry -- More examples to experiment on later\nexample : ¬p ∨ ¬q → ¬(p ∧ q) := by sorry\nexample : ¬(p ∧ ¬p) := by sorry\nexample : p ∧ ¬q → ¬(p → q) := by sorry\nexample : ¬p → (p → q) := by sorry\nexample : (¬p ∨ q) → (p → q) := by sorry\nexample : p ∨ false ↔ p := by sorry\nexample : p ∧ false ↔ false := by sorry\nexample : (p → q) → (¬q → ¬p) := by sorry\n\nend exercise_5_1\nnamespace exercise_5_2\n\n\nvariables p q r s : Prop\n\n-- These require classical reasoning.\nexample : (p → r ∨ s) → ((p → r) ∨ (p → s)) := by sorry\nexample : ¬(p ∧ q) → ¬p ∨ ¬q := by sorry\nexample : ¬(p → q) → p ∧ ¬q := by sorry\nexample : (p → q) → (¬p ∨ q) := by sorry\nexample : (¬q → ¬p) → (p → q) := by sorry\nexample : p ∨ ¬p := by sorry\nexample : (((p → q) → p) → p) := by sorry\n\n-- Prove ¬(p ↔ ¬p) without using classical logic.\nexample : ¬(p ↔ ¬p) := by {\n  rintros ⟨h₁, h₂⟩,\n  apply h₁,\n  { apply h₂, intros hp, exact h₁ hp hp, },\n  { apply h₂, intros hp, exact h₁ hp hp, },\n}\n\nend exercise_5_2\nnamespace exercise_5_3\n\nsection\n  variables (α : Type*) (p q : α → Prop)\n\n  example : (∀ x, p x ∧ q x) ↔ (∀ x, p x) ∧ (∀ x, q x) := by sorry -- More examples to experiment on later\n  example : (∀ x, p x → q x) → (∀ x, p x) → (∀ x, q x) := by sorry\n  example : (∀ x, p x) ∨ (∀ x, q x) → ∀ x, p x ∨ q x := by sorry\nend\n\nsection\n  variables (α : Type*) (p q : α → Prop)\n  variable r : Prop\n\n  -- One direction of the second of these requires classical logic\n  example : α → ((∀ x : α, r) ↔ r) := by sorry\n  example : (∀ x, p x ∨ r) ↔ (∀ x, p x) ∨ r := by sorry\n  example : (∀ x, r → p x) ↔ (r → ∀ x, p x) := by sorry\nend\n\nsection\n  variables (α : Type*) (p q : α → Prop)\n  variable r : Prop\n\n  example : (∃ x : α, r) → r := by sorry\n  example (a : α) : r → (∃ x : α, r) := by sorry\n  example : (∃ x, p x ∧ r) ↔ (∃ x, p x) ∧ r := by sorry\n  example : (∃ x, p x ∨ q x) ↔ (∃ x, p x) ∨ (∃ x, q x) := by sorry\n\n  example : (∀ x, p x) ↔ ¬ (∃ x, ¬ p x) := by sorry\n  example : (∃ x, p x) ↔ ¬ (∀ x, ¬ p x) := by sorry\n  example : (¬ ∃ x, p x) ↔ (∀ x, ¬ p x) := by sorry\n  example : (¬ ∀ x, p x) ↔ (∃ x, ¬ p x) := by sorry\n\n  example : (∀ x, p x → r) ↔ (∃ x, p x) → r := by sorry\n  example (a : α) : (∃ x, p x → r) ↔ (∀ x, p x) → r := by sorry\n  example (a : α) : (∃ x, r → p x) ↔ (r → ∃ x, p x) := by sorry\nend\n\nend exercise_5_3\n\n/-\nNote:\n  `tauto` (and `tauto!` for classical) seems to use sequent calculus (elim then intro);\n  `finish` seems to use SMT? (TODO: what is SMT...)\n  Both are complete for propositional logic...?\n-/\n\n\n-- ### Exercise 7\n\nnamespace exercise_7\n\ninductive myempty : Type\n\ninductive myunit : Type\n| star : myunit\n\ninductive mybool : Type\n| ff : mybool\n| tt : mybool\n\nnamespace mybool\n\n  def bnot : mybool → mybool :=\n    @mybool.rec (λ _, mybool) tt ff\n  \n  def band : mybool → mybool → mybool :=\n    λ a b, @mybool.rec (λ _, mybool) ff b a\n  \n  def bor : mybool → mybool → mybool :=\n    λ a b, @mybool.rec (λ _, mybool) b tt a\n\nend mybool\n\nuniverse u\n\n-- Standard definition for equality\ninductive myeq {α : Sort u} (l : α) : α → Prop\n| refl [] : myeq l\n\nnamespace myeq\n\n  lemma symm : Π {α : Sort u} {x y : α} (h : myeq x y), myeq y x :=\n    λ α x y h, @myeq.rec α x -- The subject is `myeq {α} x`\n      (λ r, myeq r x) -- Make a more general claim: given `myeq x r` then `myeq r x`\n      (myeq.refl x)   -- Now given `myeq x x` (implicit), prove `myeq x x`\n        y h           -- Then we could specialise `r` to `y`, and give a `myeq x y` to make `myeq y x`\n  \n  lemma trans : Π {α : Sort u} {x y z : α} (h₁ : myeq x y) (h₂ : myeq y z), myeq x z :=\n    λ α x y z h₁ h₂, @myeq.rec α y -- The subject is `myeq {α} y`\n      (λ r, myeq x r) -- Make a more general claim: given `myeq y r` then `myeq x r`\n      h₁              -- Now given `myeq y y` (implicit), prove `myeq x y`\n        z h₂          -- Then we could specialise `r` to `z`, and give a `myeq y z` to make `myeq x z`\n  \n  lemma congr : Π {α β : Sort u} {x y : α} (f : α → β) (h : myeq x y), myeq (f x) (f y) :=\n    λ α β x y f h, @myeq.rec α x\n      (λ r, myeq (f x) (f r))\n      (myeq.refl (f x))\n        y h\n  \n  lemma subst : Π {α : Sort u} {x y : α} (p : α → Prop) (h₁ : myeq x y) (h₂ : p x), p y :=\n    λ α x y p h₁ h₂, @myeq.rec α x\n      (λ r, p r)\n      h₂\n        y h₁\n  \n  -- Simplify by removing `@` and abbreviating arguments\n  lemma symm' {α : Sort u} {x y : α} (h : myeq x y) : myeq y x :=\n    myeq.rec (myeq.refl x) h\n  lemma trans' {α : Sort u} {x y z : α} (h₁ : myeq x y) (h₂ : myeq y z) : myeq x z :=\n    myeq.rec h₁ h₂\n  lemma congr' {α β : Sort u} {x y : α} (f : α → β) (h : myeq x y) : myeq (f x) (f y) :=\n    myeq.rec (myeq.refl (f x)) h\n  lemma subst' {α : Sort u} {x y : α} (p : α → Prop) (h₁ : myeq x y) (h₂ : p x) : p y :=\n    myeq.rec h₂ h₁\n\nend myeq\n\nnamespace mybool\n\n  lemma em : Π (a : mybool), myeq (bor a (bnot a)) tt :=\n    @mybool.rec\n      (λ x, myeq (bor x (bnot x)) tt)\n      (myeq.refl tt) -- Lean refers to definitions and does the calculation automatically\n      (myeq.refl tt) -- So `myeq (bor tt (bnot tt)) tt` unifies with `myeq tt tt`!\n  \n  lemma de_morgan : Π (a b : mybool), myeq (bnot (band a b)) (bor (bnot a) (bnot b)) :=\n    λ a b, @mybool.rec -- By cases on `a`\n      (λ a', myeq (bnot (band a' b)) (bor (bnot a') (bnot b)))\n      (@mybool.rec     -- By cases on `b`\n        (λ b', myeq (bnot (band ff b')) (bor (bnot ff) (bnot b')))\n        (myeq.refl tt)\n        (myeq.refl tt)\n          b)\n      (@mybool.rec     -- By cases on `b`\n        (λ b', myeq (bnot (band tt b')) (bor (bnot tt) (bnot b')))\n        (myeq.refl tt)\n        (myeq.refl ff)\n          b)\n        a\n  \n  -- Simplify by removing `@` and abbreviating arguments\n  lemma de_morgan' (a b : mybool) : myeq (bnot (band a b)) (bor (bnot a) (bnot b)) :=\n    mybool.rec_on b\n      (mybool.rec_on a (myeq.refl _) (myeq.refl _))\n      (mybool.rec_on a (myeq.refl _) (myeq.refl _))\n\nend mybool\n\ninductive maybe (α : Type u) : Type u\n| nothing :     maybe\n| just    : α → maybe\n\ninductive inhabited (α : Type u) : Type u\n| mk : α → inhabited\n\nnamespace maybe\n\n  -- The \"monad operation\"\n  def bind : Π {α β : Type u}, maybe α → (α → maybe β) → maybe β :=\n    λ α β ma f, @maybe.rec α\n      (λ _, maybe β)\n      (nothing)\n      (λ a, f a)\n        ma\n  \n  -- Partial function composition\n  def compose : Π {α β γ : Type u}, (β → maybe γ) → (α → maybe β) → α → maybe γ :=\n    λ α β γ g f a, @maybe.rec β\n      (λ _, maybe γ)\n      (nothing)\n      (λ b, g b)\n        (f a)\n  \n  -- Simplified versions\n  def bind' {α β : Type u} (ma : maybe α) (f : α → maybe β) : maybe β :=\n    maybe.rec nothing f ma\n  def compose' {α β γ : Type u} (g : β → maybe γ) (f : α → maybe β) (a : α) : maybe γ :=\n    maybe.rec nothing g (f a)\n  def compose'' {α β γ : Type u} (g : β → maybe γ) (f : α → maybe β) (a : α) : maybe γ :=\n    bind' (f a) g\n\nend maybe\n\nsection\n  def is_even (x : ℕ) : bool := nat.rec_on x tt (λ _, @bool.rec (λ _, bool) bool.tt bool.ff)\n  def filter (x : ℕ) : maybe ℕ := bool.cases_on (is_even x) (maybe.just x.succ) maybe.nothing\n  #reduce filter 3\n  #reduce (maybe.compose'' filter filter) 3\nend\n\nsection\n  #check inhabited      -- The type former\n  #check @inhabited.mk  -- The constructor\n\n  def inhabited_bool : inhabited bool := inhabited.mk tt\n  def inhabited_nat  : inhabited nat  := inhabited.mk 0\n\n  def inhabited_prod_of_inhabited : Π {α β : Type u}\n    (i₁ : inhabited α) (i₂ : inhabited β),\n    inhabited (prod α β) :=\n      λ α β i₁ i₂, inhabited.mk (inhabited.rec id i₁, inhabited.rec id i₂)\n  \n  def inhabited_of_function_to_inhabited : Π {α β : Type u}\n    (i : inhabited β),\n    inhabited (α → β) :=\n      λ α β i, inhabited.mk (λ _, inhabited.rec id i)\n   \n  def inhabited_of_function_to_inhabited' : Π {α : Type u} {τ : α → Type u}\n    (i : Π (a : α), inhabited (τ a)),\n    inhabited (Π (a : α), τ a) :=\n      λ α τ i, inhabited.mk (λ a, inhabited.rec id (i a))\nend\n\ninductive mylist (α : Type u) : Type u\n| nil  :              mylist\n| cons : α → mylist → mylist\n\nnamespace mylist\n  variable {α : Type u}\n\n  def append (s t : mylist α) : mylist α :=\n    mylist.rec_on s t (λ a _, λ st', cons a st')\n\n  local notation h :: t := cons h t -- ?\n  local notation s ++ t := append s t -- ?\n  local notation `[` l:(foldr `,` (h t, cons h t) nil) `]` := l -- ?????\n\n  section\n    open nat\n    #check [1, 2, 3, 4, 5]\n    #check ([1, 2, 3, 4, 5] : mylist int)\n  end\n\n  theorem nil_append (t : mylist α) : nil ++ t = t := eq.refl t\n  theorem cons_append (x : α) (s t : mylist α) : x::s ++ t = x::(s ++ t) := eq.refl _\n\n  -- Manual equational rewriting!\n  theorem append_nil (t : mylist α) : t ++ nil = t :=\n    @mylist.rec_on α\n      (λ l, l ++ nil = l) t\n      (eq.refl nil)\n      (λ a as, λ ih, (@eq.subst _ (λ x, a::as ++ nil = a::x) _ _ ih (eq.refl _)))\n  \n  -- Tip: have a notepad open, keep track of the current \"state\"...\n  theorem append_assoc (r s t : mylist α) : r ++ s ++ t = r ++ (s ++ t) :=\n    @mylist.rec_on α\n      (λ l, (l ++ s) ++ t = l ++ (s ++ t)) r\n      (eq.refl (s ++ t))\n      (λ a as, λ ih,\n        (@eq.subst _ (λ x, (a::as ++ s) ++ t = a::x) _ _ ih\n          (@eq.subst _ (λ x, (a::as ++ s) ++ t = x) _ _ (cons_append a (as ++ s) t)\n            (@eq.subst _ (λ x, (a::as ++ s) ++ t = x ++ t) _ _ (cons_append a as s)\n              (eq.refl ((a::as ++ s) ++ t)))))) -- Read bottom up\n  \n  -- Simplify by ignoring steps that can be completed by `rfl` (`eq.refl _`)\n  theorem append_assoc' (r s t : mylist α) : r ++ s ++ t = r ++ (s ++ t) :=\n    @mylist.rec_on α\n      (λ l, (l ++ s) ++ t = l ++ (s ++ t)) r\n      rfl\n      (λ a as, λ ih, (@eq.subst _ (λ x, (a::as ++ s) ++ t = a::x) _ _ ih rfl))\n\nend mylist\n\ninductive mynat : Type\n| zero :                mynat\n| succ : Π (n : mynat), mynat\n\nnamespace mynat\n  def one   : mynat := zero.succ\n  def two   : mynat := zero.succ.succ\n  def three : mynat := zero.succ.succ.succ\n\n  -- `mynat.rec` is primitive recursion!\n\n  def add : mynat → mynat → mynat :=\n    λ a, @mynat.rec\n      (λ r, mynat)\n      a\n      (λ r, λ ar, succ ar)\n\n  #reduce add one two\n\n  def mul : mynat → mynat → mynat :=\n    λ a, @mynat.rec\n      (λ r, mynat)\n      zero\n      (λ r, λ ar, add ar a)\n\n  #reduce mul two three\n  #reduce mul three two\n\n  def pred : mynat → mynat :=\n    @mynat.rec\n      (λ r, mynat)\n      zero\n      (λ r, λ predr, r)\n\n  #reduce pred zero\n  #reduce pred one\n  #reduce pred two\n  #reduce pred three\n\n  def monus : mynat → mynat → mynat :=\n    λ a, @mynat.rec\n      (λ r, mynat)\n      a\n      (λ r, λ ar, pred ar)\n\n  #reduce monus three two\n  #reduce monus two three\n\n  def pow : mynat → mynat → mynat :=\n    λ a, @mynat.rec\n      (λ _, mynat)\n      one\n      (λ r, λ ar, mul ar a)\n\n  #reduce pow two three\n  #reduce pow three two\n\n  lemma add_zero : Π (a : mynat), add a zero = a :=\n    λ a, rfl\n\n  lemma add_succ : Π (a b : mynat), add a (succ b) = succ (add a b) :=\n    λ a b, rfl\n\n  -- More manual equational rewriting...\n  lemma succ_add : Π (a b : mynat), add (succ a) b = succ (add a b) :=\n    λ a b, @mynat.rec_on\n      (λ n, add (succ a) n = succ (add a n)) b\n      rfl\n      (λ n, λ ih,\n        (@eq.subst _ (λ x, add (succ a) (succ n) = succ x) _ _ ih\n          (eq.refl (add (succ a) (succ n)))))\n\n  lemma zero_add : Π (a : mynat), add zero a = a :=\n    λ a, @mynat.rec_on\n      (λ n, add zero n = n) a\n      rfl\n      (λ n, λ ih,\n        (@eq.subst _ (λ x, succ (add zero n) = succ x) _ _ ih\n          (eq.refl (succ (add zero n)))))\n\n  lemma add_comm : Π (a b : mynat), add a b = add b a :=\n    λ a b, @mynat.rec_on\n      (λ n, add a n = add n a) b\n      (eq.symm (zero_add a))\n      (λ n, λ ih,\n        (@eq.subst _ (λ x, succ (add a n) = x) _ _ (eq.symm (succ_add n a))\n          (@eq.subst _ (λ x, succ (add a n) = succ x) _ _ ih\n            (eq.refl (succ (add a n))))))\n\n  -- See: https://leanprover.zulipchat.com/#narrow/streams/public/search/stupid.20triangle\n  #print notation ▸\n\n  -- `rw` is incredible...!\n  lemma add_comm' : Π (a b : mynat), add a b = add b a :=\n  begin\n    intros a b,\n    induction b with b ih,\n    { rw zero_add, refl, },\n    { rw [succ_add, ← ih], refl, },\n  end\n\n  -- This will lead to the Natural Number Game...\n  -- https://github.com/ImperialCollegeLondon/natural_number_game/\n  \n  -- Also see: Part 7 of *Logic and Structures* (van Dalen)\nend mynat\n\nnamespace mylist\n  variable {α : Type u}\n\n  local notation h :: t := cons h t -- ?\n  local notation s ++ t := append s t -- ?\n  local notation `[` l:(foldr `,` (h t, cons h t) nil) `]` := l -- ?????\n  \n  def length : mylist α → ℕ :=\n    λ l, mylist.rec 0 (λ _ _, λ (l' : ℕ), l'.succ) l\n  \n  def reverse : mylist α → mylist α :=\n    λ l, mylist.rec nil (λ a l, λ l', l' ++ (cons a nil)) l\n  \n  #reduce length [1, 2, 3, 4, 5]\n  #reduce reverse [1, 2, 3, 4, 5]\n\n  -- Even more manual equational rewriting...\n  -- (TODO: make clear about Lean's heuristics for second-order unification?)\n  lemma length_append : Π (s t : mylist α), length (s ++ t) = length s + length t :=\n    λ s t, @mylist.rec_on α\n      (λ l, length (l ++ t) = length l + length t) s\n      (eq.symm (nat.zero_add t.length))\n      (λ a l, λ ih,\n        (@eq.subst _ (λ x, length (a::l ++ t) = x) _ _ (eq.symm (nat.succ_add (length l) (length t)))\n          (@eq.subst _ (λ x, length (a::l ++ t) = nat.succ x) _ _ ih\n            (@eq.subst _ (λ x, length (a::l ++ t) = length x) _ _ (cons_append a l t)\n              (eq.refl (a::l ++ t).length)))))\n\n  lemma length_reverse : Π (t : mylist α), length (reverse t) = length t :=\n    λ t, @mylist.rec_on α\n      (λ l, length (reverse l) = length l) t\n      rfl\n      (λ a l, λ ih,\n        (@eq.subst _ (λ x, x = (a::l).length) _ _ (eq.symm (length_append l.reverse [a]))\n          (@eq.subst _ (λ x, nat.succ x = (a::l).length) _ _ (eq.symm ih)\n            (eq.refl (a::l).length))))\n\n  lemma append_reverse_eq_reverse_append : Π (s t : mylist α), reverse (s ++ t) = reverse t ++ reverse s :=\n    λ s t, @mylist.rec_on α\n      (λ x, reverse (x ++ t) = reverse t ++ reverse x) s\n      (@eq.subst _ (λ x, reverse t = x) _ _ (eq.symm (append_nil t.reverse)) (eq.refl t.reverse))\n      (λ a l, λ ih,\n        (@eq.subst _ (λ x, reverse (a::l ++ t) = x) _ _ (append_assoc t.reverse l.reverse [a])\n          (@eq.subst _ (λ x, reverse (a::l ++ t) = x ++ [a]) _ _ ih\n            (@eq.subst _ (λ x, reverse (a::l ++ t) = reverse x) _ _ (cons_append a l t)\n              (eq.refl (a::l ++ t).reverse)))))\n\n  lemma reverse_reverse_eq_self : Π (t : mylist α), reverse (reverse t) = t :=\n    λ t, @mylist.rec_on α\n      (λ x, reverse (reverse x) = x) t\n      rfl\n      (λ a l, λ ih,\n        (@eq.subst _ (λ x, (a::l).reverse.reverse = [a] ++ x) _ _ ih\n          (@eq.subst _ (λ x, (a::l).reverse.reverse = x) _ _ (append_reverse_eq_reverse_append l.reverse [a])\n            (eq.refl (a::l).reverse.reverse))))\n\nend mylist\n\ninductive arith_expr : Type\n| const : ℕ →                       arith_expr\n| var   : ℕ →                       arith_expr\n| plus  : arith_expr → arith_expr → arith_expr\n| times : arith_expr → arith_expr → arith_expr\n\nnamespace arith_expr\n  #check const 2\n  #check var 5\n  #check plus (const 2) (var 0)\n\n  def eval : (ℕ → ℕ) → arith_expr → ℕ :=\n    λ as e, @arith_expr.rec_on (λ _, ℕ) e\n      id\n      as\n      (λ e1 e2, λ v1 v2, v1 + v2)\n      (λ e1 e2, λ v1 v2, v1 * v2)\n\n  #reduce eval id (plus (const 2) (var 0))\n\nend arith_expr\n\ninductive boolean_expr : Type\n| const : bool →                        boolean_expr\n| var   : ℕ →                           boolean_expr\n| not   : boolean_expr →                boolean_expr\n| and   : boolean_expr → boolean_expr → boolean_expr\n| or    : boolean_expr → boolean_expr → boolean_expr\n\nnamespace boolean_expr\n  #check const tt\n  #check var 5\n  #check and (const ff) (var 0)\n\n  def eval : (ℕ → bool) → boolean_expr → bool :=\n    λ as e, @boolean_expr.rec_on (λ _, bool) e\n      id\n      as\n      (λ e', λ v', bnot v')\n      (λ e1 e2, λ v1 v2, band v1 v2)\n      (λ e1 e2, λ v1 v2, bor v1 v2)\n\n  def size : boolean_expr → ℕ :=\n    λ e, @boolean_expr.rec_on (λ _, ℕ) e\n      (λ _, 1)\n      (λ _, 1)\n      (λ e', λ ne', ne' + 1)\n      (λ e1 e2, λ ne1 ne2, ne1 + ne2 + 1)\n      (λ e1 e2, λ ne1 ne2, ne1 + ne2 + 1)\n\n  def depth : boolean_expr → ℕ :=\n    λ e, @boolean_expr.rec_on (λ _, ℕ) e\n      (λ _, 1)\n      (λ _, 1)\n      (λ e', λ ne', ne' + 1)\n      (λ e1 e2, λ ne1 ne2, max ne1 ne2 + 1)\n      (λ e1 e2, λ ne1 ne2, max ne1 ne2 + 1)\n  \n  #reduce size  (and (or (const tt) (not (var 0))) (not (var 2)))\n  #reduce depth (and (or (const tt) (not (var 0))) (not (var 2)))\n\n  def replace_all : boolean_expr → ℕ → boolean_expr → boolean_expr :=\n    λ sub ind e, @boolean_expr.rec_on (λ _, boolean_expr) e\n      (λ b, const b)\n      (λ v, ite (v = ind) sub (var v))\n      (λ _, λ e', not e')\n      (λ _ _, λ e1' e2', and e1' e2')\n      (λ _ _, λ e1' e2', or e1' e2')\n\n  #reduce replace_all\n    (const ff)\n    2\n    (and (or (const tt) (not (var 0))) (not (var 2)))\n\nend boolean_expr\n\ninductive even_odd : bool → ℕ → Prop\n| even_zero :                            even_odd ff 0\n| even_succ : Π {n : ℕ}, even_odd ff n → even_odd tt n.succ\n| odd_succ  : Π {n : ℕ}, even_odd tt n → even_odd ff n.succ\n\nnamespace even_odd\n  #check even_zero\n  #check even_succ even_zero\n  -- Does not typecheck\n  -- #check even_succ (even_succ even_zero)\n  -- Typechecks\n  #check odd_succ (even_succ even_zero)\n  #check (even_succ ∘ odd_succ ∘ even_succ ∘ odd_succ ∘ even_succ) even_zero\nend even_odd\n\nend exercise_7\n\n\n-- ### Exercise 8\n\nnamespace exercise_8\n\nsection\n  open function\n  #print surjective\n\n  universes u v w\n  variables {α : Type u} {β : Type v} {γ : Type w}\n  open function\n\n  lemma surjective_comp {g : β → γ} {f : α → β}\n    (hg : surjective g) (hf : surjective f) : surjective (g ∘ f) :=\n    λ c,\n      match hg c with (Exists.intro b hb) :=\n        match hf b with (Exists.intro a ha) :=\n          ⟨a, (ha.symm ▸ hb : g (f a) = c)⟩ end end\nend\n\nnamespace hidden\n  open nat\n\n  def add : ℕ → ℕ → ℕ\n  | a 0        := a\n  | a (succ b) := succ (add a b)\n\n  lemma zero_add : Π (a : ℕ), add 0 a = a\n  | 0        := rfl\n  | (succ b) := congr_arg succ (zero_add b)\n\n  lemma succ_add : Π (a b : ℕ), add (succ a) b = succ (add a b)\n  | a 0        := rfl\n  | a (succ b) := congr_arg succ (succ_add a b)\n\n  lemma add_comm : Π (a b : ℕ), add a b = add b a\n  | a 0        := (zero_add a).symm\n  | a (succ b) := eq.trans (@@congr_arg succ (add_comm a b)) (succ_add b a).symm\n\n  lemma add_assoc : Π (a b c : ℕ), add a (add b c) = add (add a b) c\n  | a b 0        := rfl\n  | a b (succ c) := congr_arg succ (add_assoc a b c)\n\nend hidden\n\nnamespace hidden\n  open list\n  variable {α : Type*}\n\n  def length : list α → ℕ\n  | []        := 0\n  | (x :: xs) := length xs + 1\n  \n  def reverse : list α → list α\n  | []        := []\n  | (x :: xs) := reverse xs ++ [x]\n  \n  lemma length_append : Π (s t : list α), length (s ++ t) = length s + length t\n  | []        t := (nat.zero_add _).symm\n  | (x :: xs) t :=\n    show length (xs ++ t) + 1 = length xs + 1 + length t,\n      by rw [nat.add_assoc, nat.add_comm 1, ← nat.add_assoc, length_append]\n\n  lemma length_reverse : Π (t : list α), length (reverse t) = length t\n  | []        := rfl\n  | (x :: xs) := \n    show length (reverse xs ++ [x]) = length xs + 1,\n      by rw [length_append, length_reverse]; refl\n\n  lemma append_reverse_eq_reverse_append : Π (s t : list α), reverse (s ++ t) = reverse t ++ reverse s\n  | [] t        := (append_nil (reverse t)).symm\n  | (x :: xs) t :=\n    show reverse (xs ++ t) ++ [x] = reverse t ++ (reverse xs ++ [x]),\n      by rw [append_reverse_eq_reverse_append, append_assoc]\n\n  lemma reverse_reverse_eq_self : Π (t : list α), reverse (reverse t) = t\n  | []        := rfl\n  | (x :: xs) :=\n    show reverse (reverse xs ++ [x]) = x :: xs,\n      by rw [append_reverse_eq_reverse_append, reverse_reverse_eq_self]; refl\n\nend hidden\n\nsection\n  #check @well_founded.fix\n\n  -- Structural recursion on `acc r`, given element `hwf.apply x`.\n  def well_founded.fix' {α : Sort*} {C : α → Sort*} {r : α → α → Prop}\n    (hwf : well_founded r) (R : Π (x : α), (Π (y : α), r y x → C y) → C x) :\n      Π (x : α), C x :=\n        λ x, @acc.rec_on α r C x (hwf.apply x) (λ x' hx', R x')\nend\n\ninductive vector (α : Type) : ℕ → Type\n| vnil  :                           vector 0\n| vcons : Π {n : ℕ}, α → vector n → vector n.succ\n\nnamespace vector\n  def vec1 := vcons 1 (vcons 2 (vcons 3 vnil))\n  def vec2 := vcons 4 (vcons 5 vnil)\n\n  -- Using EC\n  def tail {α : Type} {n : ℕ} : vector α (n + 1) → vector α n\n  | (vcons a as) := as\n  \n  -- Using recursor\n  -- (See: https://leanprover.github.io/theorem_proving_in_lean/induction_and_recursion.html#dependent-pattern-matching)\n  def tail_aux {α : Type*} {n n' : ℕ} (v : vector α n') : n' = n + 1 → vector α n :=\n    vector.cases_on v -- Cases on `v` first so you could use that equality\n      (λ (h : 0 = n + 1), nat.no_confusion h)\n      (λ n' (a : α) (as : vector α n') (h : n' + 1 = n + 1),\n        nat.no_confusion h (λ h₁ : n' = n, eq.rec_on h₁ as))\n\n  def tail' {α : Type*} {n : ℕ} (v : vector α (n + 1)) : vector α n :=\n    tail_aux v rfl\n\n  -- Using EC\n  def append {α : Type} : Π {m : ℕ} (u : vector α m) {n : ℕ} (v : vector α n), vector α (n + m)\n  | nat.zero      vnil         n v := v\n  | (nat.succ m') (vcons a as) n v := vcons a (append as v)\n\n  #reduce append vec1 vec2\n\n  -- Using recursor (without using an auxiliary function???)\n  def append' {α : Type} : Π {m : ℕ} (u : vector α m) {n : ℕ} (v : vector α n), vector α (n + m) :=\n    λ m u n v,\n      @vector.rec_on _ (λ m' _, vector α (n + m')) _ u\n        v\n        (λ m' a as acc, vcons a acc)\n\n  #reduce append' vec1 vec2\n\n  -- (TODO: the real challenge???)\n  -- (See: https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/more.20more.20basics/near/190957263)\nend vector\n\nsection\n  inductive aexpr : Type\n  | const : ℕ             → aexpr\n  | var   : ℕ             → aexpr\n  | plus  : aexpr → aexpr → aexpr\n  | times : aexpr → aexpr → aexpr\n\n  open aexpr\n\n  def sample_aexpr : aexpr := plus (times (var 0) (const 7)) (times (const 2) (var 1))\n  \n  def aeval (v : ℕ → ℕ) : aexpr → ℕ\n  | (const n)     := n\n  | (var n)       := v n\n  | (plus e₁ e₂)  := aeval e₁ + aeval e₂\n  | (times e₁ e₂) := aeval e₁ * aeval e₂\n\n  def sample_val : ℕ → ℕ\n  | 0 := 5\n  | 1 := 6\n  | _ := 0\n\n  #eval aeval sample_val sample_aexpr\n\n  def simp_const : aexpr → aexpr\n  | (plus (const n₁) (const n₂))  := const (n₁ + n₂)\n  | (times (const n₁) (const n₂)) := const (n₁ * n₂)\n  | e                             := e\n\n  def fuse : aexpr → aexpr\n  | (const n)     := (const n)\n  | (var n)       := (var n)\n  | (plus e₁ e₂)  := simp_const (plus (fuse e₁) (fuse e₂))\n  | (times e₁ e₂) := simp_const (times (fuse e₁) (fuse e₂))\n\n  theorem simp_const_eq (v : ℕ → ℕ) : ∀ e : aexpr, aeval v (simp_const e) = aeval v e\n  | (const n)     := rfl\n  | (var n)       := rfl\n  | (plus e₁ e₂)  := by { cases e₁; cases e₂; refl }\n  | (times e₁ e₂) := by { cases e₁; cases e₂; refl }\n\n  theorem fuse_eq (v : ℕ → ℕ) : ∀ e : aexpr, aeval v (fuse e) = aeval v e\n  | (const n)     := rfl\n  | (var n)       := rfl\n  | (plus e₁ e₂)  :=\n    show aeval v (simp_const (plus (fuse e₁) (fuse e₂))) = aeval v (plus e₁ e₂),\n      by { rw simp_const_eq, unfold aeval, rw [fuse_eq, fuse_eq] }\n  | (times e₁ e₂) :=\n    show aeval v (simp_const (times (fuse e₁) (fuse e₂))) = aeval v (times e₁ e₂),\n      by { rw simp_const_eq, unfold aeval, rw [fuse_eq, fuse_eq] }\n\nend\n\nend exercise_8\n\n\n\n", "meta": {"author": "bridgekat", "repo": "lean-notes", "sha": "18ee3dec74cfc52cb2dcd9cf33f30c4bba87c09d", "save_path": "github-repos/lean/bridgekat-lean-notes", "path": "github-repos/lean/bridgekat-lean-notes/lean-notes-18ee3dec74cfc52cb2dcd9cf33f30c4bba87c09d/src/theorem_proving_in_lean/exercises.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.4801515490396861}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.metric_space.baire\nimport Mathlib.analysis.normed_space.operator_norm\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Banach open mapping theorem\n\nThis file contains the Banach open mapping theorem, i.e., the fact that a bijective\nbounded linear map between Banach spaces has a bounded inverse.\n-/\n\n/--\nFirst step of the proof of the Banach open mapping theorem (using completeness of `F`):\nby Baire's theorem, there exists a ball in `E` whose image closure has nonempty interior.\nRescaling everything, it follows that any `y ∈ F` is arbitrarily well approached by\nimages of elements of norm at most `C * ∥y∥`.\nFor further use, we will only need such an element whose image\nis within distance `∥y∥/2` of `y`, to apply an iterative process. -/\ntheorem exists_approx_preimage_norm_le {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] (f : continuous_linear_map 𝕜 E F) [complete_space F] (surj : function.surjective ⇑f) : ∃ (C : ℝ), ∃ (H : C ≥ 0), ∀ (y : F), ∃ (x : E), dist (coe_fn f x) y ≤ 1 / bit0 1 * norm y ∧ norm x ≤ C * norm y := sorry\n\n/-- The Banach open mapping theorem: if a bounded linear map between Banach spaces is onto, then\nany point has a preimage with controlled norm. -/\ntheorem exists_preimage_norm_le {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] (f : continuous_linear_map 𝕜 E F) [complete_space F] [complete_space E] (surj : function.surjective ⇑f) : ∃ (C : ℝ), ∃ (H : C > 0), ∀ (y : F), ∃ (x : E), coe_fn f x = y ∧ norm x ≤ C * norm y := sorry\n\n/-- The Banach open mapping theorem: a surjective bounded linear map between Banach spaces is\nopen. -/\ntheorem open_mapping {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] (f : continuous_linear_map 𝕜 E F) [complete_space F] [complete_space E] (surj : function.surjective ⇑f) : is_open_map ⇑f := sorry\n\nnamespace linear_equiv\n\n\n/-- If a bounded linear map is a bijection, then its inverse is also a bounded linear map. -/\ntheorem continuous_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (e : linear_equiv 𝕜 E F) (h : continuous ⇑e) : continuous ⇑(symm e) := sorry\n\n/-- Associating to a linear equivalence between Banach spaces a continuous linear equivalence when\nthe direct map is continuous, thanks to the Banach open mapping theorem that ensures that the\ninverse map is also continuous. -/\ndef to_continuous_linear_equiv_of_continuous {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (e : linear_equiv 𝕜 E F) (h : continuous ⇑e) : continuous_linear_equiv 𝕜 E F :=\n  continuous_linear_equiv.mk (mk (to_fun e) sorry sorry (inv_fun e) sorry sorry)\n\n@[simp] theorem coe_fn_to_continuous_linear_equiv_of_continuous {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (e : linear_equiv 𝕜 E F) (h : continuous ⇑e) : ⇑(to_continuous_linear_equiv_of_continuous e h) = ⇑e :=\n  rfl\n\n@[simp] theorem coe_fn_to_continuous_linear_equiv_of_continuous_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (e : linear_equiv 𝕜 E F) (h : continuous ⇑e) : ⇑(continuous_linear_equiv.symm (to_continuous_linear_equiv_of_continuous e h)) = ⇑(symm e) :=\n  rfl\n\nend linear_equiv\n\n\nnamespace continuous_linear_equiv\n\n\n/-- Convert a bijective continuous linear map `f : E →L[𝕜] F` between two Banach spaces\nto a continuous linear equivalence. -/\ndef of_bijective {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (f : continuous_linear_map 𝕜 E F) (hinj : continuous_linear_map.ker f = ⊥) (hsurj : continuous_linear_map.range f = ⊤) : continuous_linear_equiv 𝕜 E F :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous (linear_equiv.of_bijective (↑f) hinj hsurj) sorry\n\n@[simp] theorem coe_fn_of_bijective {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (f : continuous_linear_map 𝕜 E F) (hinj : continuous_linear_map.ker f = ⊥) (hsurj : continuous_linear_map.range f = ⊤) : ⇑(of_bijective f hinj hsurj) = ⇑f :=\n  rfl\n\n@[simp] theorem of_bijective_symm_apply_apply {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (f : continuous_linear_map 𝕜 E F) (hinj : continuous_linear_map.ker f = ⊥) (hsurj : continuous_linear_map.range f = ⊤) (x : E) : coe_fn (continuous_linear_equiv.symm (of_bijective f hinj hsurj)) (coe_fn f x) = x :=\n  symm_apply_apply (of_bijective f hinj hsurj) x\n\n@[simp] theorem of_bijective_apply_symm_apply {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space F] [complete_space E] (f : continuous_linear_map 𝕜 E F) (hinj : continuous_linear_map.ker f = ⊥) (hsurj : continuous_linear_map.range f = ⊤) (y : F) : coe_fn f (coe_fn (continuous_linear_equiv.symm (of_bijective f hinj hsurj)) y) = y :=\n  apply_symm_apply (of_bijective f hinj hsurj) y\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/banach.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.48015154527851645}}
{"text": "/-\nCopyright (c) 2015 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Robert Y. Lewis\n\n! This file was ported from Lean 3 source module algebra.group_power.ring\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GroupPower.Basic\nimport Mathbin.Algebra.GroupWithZero.Commute\nimport Mathbin.Algebra.Hom.Ring\nimport Mathbin.Algebra.Ring.Commute\nimport Mathbin.Algebra.GroupWithZero.Divisibility\nimport Mathbin.Algebra.Ring.Divisibility\nimport Mathbin.Data.Nat.Order.Basic\n\n/-!\n# Power operations on monoids with zero, semirings, and rings\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides additional lemmas about the natural power operator on rings and semirings.\nFurther lemmas about ordered semirings and rings can be found in `algebra.group_power.lemmas`.\n\n-/\n\n\nvariable {R S M : Type _}\n\nsection MonoidWithZero\n\nvariable [MonoidWithZero M]\n\n/- warning: zero_pow -> zero_pow is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))) n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))) n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align zero_pow zero_powₓ'. -/\ntheorem zero_pow : ∀ {n : ℕ}, 0 < n → (0 : M) ^ n = 0\n  | n + 1, _ => by rw [pow_succ, MulZeroClass.zero_mul]\n#align zero_pow zero_pow\n\n/- warning: zero_pow' -> zero_pow' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] (n : Nat), (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))) n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] (n : Nat), (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))) n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align zero_pow' zero_pow'ₓ'. -/\n@[simp]\ntheorem zero_pow' : ∀ n : ℕ, n ≠ 0 → (0 : M) ^ n = 0\n  | 0, h => absurd rfl h\n  | k + 1, h => by\n    rw [pow_succ]\n    exact MulZeroClass.zero_mul _\n#align zero_pow' zero_pow'\n\n/- warning: zero_pow_eq -> zero_pow_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] (n : Nat), Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))) n) (ite.{succ u1} M (Eq.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) (Nat.decidableEq n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] (n : Nat), Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))) n) (ite.{succ u1} M (Eq.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (instDecidableEqNat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1)))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align zero_pow_eq zero_pow_eqₓ'. -/\ntheorem zero_pow_eq (n : ℕ) : (0 : M) ^ n = if n = 0 then 1 else 0 :=\n  by\n  split_ifs with h\n  · rw [h, pow_zero]\n  · rw [zero_pow (Nat.pos_of_ne_zero h)]\n#align zero_pow_eq zero_pow_eq\n\n/- warning: pow_eq_zero_of_le -> pow_eq_zero_of_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] {x : M} {n : Nat} {m : Nat}, (LE.le.{0} Nat Nat.hasLe n m) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x m) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] {x : M} {n : Nat} {m : Nat}, (LE.le.{0} Nat instLENat n m) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) -> (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x m) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align pow_eq_zero_of_le pow_eq_zero_of_leₓ'. -/\ntheorem pow_eq_zero_of_le {x : M} {n m : ℕ} (hn : n ≤ m) (hx : x ^ n = 0) : x ^ m = 0 := by\n  rw [← tsub_add_cancel_of_le hn, pow_add, hx, MulZeroClass.mul_zero]\n#align pow_eq_zero_of_le pow_eq_zero_of_le\n\n/- warning: pow_eq_zero -> pow_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))] {x : M} {n : Nat}, (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) -> (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MonoidWithZero.toZero.{u1} M _inst_1)] {x : M} {n : Nat}, (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) -> (Eq.{succ u1} M x (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align pow_eq_zero pow_eq_zeroₓ'. -/\ntheorem pow_eq_zero [NoZeroDivisors M] {x : M} {n : ℕ} (H : x ^ n = 0) : x = 0 :=\n  by\n  induction' n with n ih\n  · rw [pow_zero] at H\n    rw [← mul_one x, H, MulZeroClass.mul_zero]\n  · rw [pow_succ] at H\n    exact Or.cases_on (mul_eq_zero.1 H) id ih\n#align pow_eq_zero pow_eq_zero\n\n/- warning: pow_eq_zero_iff -> pow_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))] {a : M} {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MonoidWithZero.toZero.{u1} M _inst_1)] {a : M} {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align pow_eq_zero_iff pow_eq_zero_iffₓ'. -/\n@[simp]\ntheorem pow_eq_zero_iff [NoZeroDivisors M] {a : M} {n : ℕ} (hn : 0 < n) : a ^ n = 0 ↔ a = 0 :=\n  by\n  refine' ⟨pow_eq_zero, _⟩\n  rintro rfl\n  exact zero_pow hn\n#align pow_eq_zero_iff pow_eq_zero_iff\n\n/- warning: pow_eq_zero_iff' -> pow_eq_zero_iff' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))] [_inst_3 : Nontrivial.{u1} M] {a : M} {n : Nat}, Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) (And (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MonoidWithZero.toZero.{u1} M _inst_1)] [_inst_3 : Nontrivial.{u1} M] {a : M} {n : Nat}, Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) (And (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))\nCase conversion may be inaccurate. Consider using '#align pow_eq_zero_iff' pow_eq_zero_iff'ₓ'. -/\ntheorem pow_eq_zero_iff' [NoZeroDivisors M] [Nontrivial M] {a : M} {n : ℕ} :\n    a ^ n = 0 ↔ a = 0 ∧ n ≠ 0 := by cases (zero_le n).eq_or_gt <;> simp [*, ne_of_gt]\n#align pow_eq_zero_iff' pow_eq_zero_iff'\n\n/- warning: pow_ne_zero_iff -> pow_ne_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))] {a : M} {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Iff (Ne.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) (Ne.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MonoidWithZero.toZero.{u1} M _inst_1)] {a : M} {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Iff (Ne.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) (Ne.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align pow_ne_zero_iff pow_ne_zero_iffₓ'. -/\ntheorem pow_ne_zero_iff [NoZeroDivisors M] {a : M} {n : ℕ} (hn : 0 < n) : a ^ n ≠ 0 ↔ a ≠ 0 :=\n  (pow_eq_zero_iff hn).Not\n#align pow_ne_zero_iff pow_ne_zero_iff\n\n/- warning: ne_zero_pow -> ne_zero_pow is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] {a : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Ne.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) -> (Ne.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] {a : M} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Ne.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) -> (Ne.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align ne_zero_pow ne_zero_powₓ'. -/\ntheorem ne_zero_pow {a : M} {n : ℕ} (hn : n ≠ 0) : a ^ n ≠ 0 → a ≠ 0 :=\n  by\n  contrapose!\n  rintro rfl\n  exact zero_pow' n hn\n#align ne_zero_pow ne_zero_pow\n\n/- warning: pow_ne_zero -> pow_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))] {a : M} (n : Nat), (Ne.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) -> (Ne.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MonoidWithZero.toZero.{u1} M _inst_1)] {a : M} (n : Nat), (Ne.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) -> (Ne.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align pow_ne_zero pow_ne_zeroₓ'. -/\n@[field_simps]\ntheorem pow_ne_zero [NoZeroDivisors M] {a : M} (n : ℕ) (h : a ≠ 0) : a ^ n ≠ 0 :=\n  mt pow_eq_zero h\n#align pow_ne_zero pow_ne_zero\n\n/- warning: ne_zero.pow -> NeZero.pow is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))] {x : M} [_inst_3 : NeZero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) x] {n : Nat}, NeZero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x n)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MonoidWithZero.toZero.{u1} M _inst_1)] {x : M} [_inst_3 : NeZero.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1) x] {n : Nat}, NeZero.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) x n)\nCase conversion may be inaccurate. Consider using '#align ne_zero.pow NeZero.powₓ'. -/\ninstance NeZero.pow [NoZeroDivisors M] {x : M} [NeZero x] {n : ℕ} : NeZero (x ^ n) :=\n  ⟨pow_ne_zero n NeZero.out⟩\n#align ne_zero.pow NeZero.pow\n\n/- warning: sq_eq_zero_iff -> sq_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toHasMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))] {a : M}, Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : NoZeroDivisors.{u1} M (MulZeroClass.toMul.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))) (MonoidWithZero.toZero.{u1} M _inst_1)] {a : M}, Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align sq_eq_zero_iff sq_eq_zero_iffₓ'. -/\ntheorem sq_eq_zero_iff [NoZeroDivisors M] {a : M} : a ^ 2 = 0 ↔ a = 0 :=\n  pow_eq_zero_iff two_pos\n#align sq_eq_zero_iff sq_eq_zero_iff\n\n/- warning: zero_pow_eq_zero -> zero_pow_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : Nontrivial.{u1} M] {n : Nat}, Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1)))))) n) (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M _inst_1))))))) (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M] [_inst_2 : Nontrivial.{u1} M] {n : Nat}, Iff (Eq.{succ u1} M (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1))) n) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M _inst_1)))) (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n)\nCase conversion may be inaccurate. Consider using '#align zero_pow_eq_zero zero_pow_eq_zeroₓ'. -/\n@[simp]\ntheorem zero_pow_eq_zero [Nontrivial M] {n : ℕ} : (0 : M) ^ n = 0 ↔ 0 < n :=\n  by\n  constructor <;> intro h\n  · rw [pos_iff_ne_zero]\n    rintro rfl\n    simpa using h\n  · exact zero_pow' n h.ne.symm\n#align zero_pow_eq_zero zero_pow_eq_zero\n\n#print Ring.inverse_pow /-\ntheorem Ring.inverse_pow (r : M) : ∀ n : ℕ, Ring.inverse r ^ n = Ring.inverse (r ^ n)\n  | 0 => by rw [pow_zero, pow_zero, Ring.inverse_one]\n  | n + 1 => by\n    rw [pow_succ, pow_succ', Ring.mul_inverse_rev' ((Commute.refl r).pow_leftₓ n), Ring.inverse_pow]\n#align ring.inverse_pow Ring.inverse_pow\n-/\n\nend MonoidWithZero\n\nsection CommMonoidWithZero\n\nvariable [CommMonoidWithZero M] {n : ℕ} (hn : 0 < n)\n\ninclude M hn\n\n#print powMonoidWithZeroHom /-\n/-- We define `x ↦ x^n` (for positive `n : ℕ`) as a `monoid_with_zero_hom` -/\ndef powMonoidWithZeroHom : M →*₀ M :=\n  { powMonoidHom n with map_zero' := zero_pow hn }\n#align pow_monoid_with_zero_hom powMonoidWithZeroHom\n-/\n\n/- warning: coe_pow_monoid_with_zero_hom -> coe_powMonoidWithZeroHom is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoidWithZero.{u1} M] {n : Nat} (hn : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n), Eq.{succ u1} ((fun (_x : MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) => M -> M) (powMonoidWithZeroHom.{u1} M _inst_1 n hn)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (fun (_x : MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) => M -> M) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (powMonoidWithZeroHom.{u1} M _inst_1 n hn)) (fun (_x : M) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) _x n)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoidWithZero.{u1} M] {n : Nat} (hn : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n), Eq.{succ u1} (forall (a : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M M (MulOneClass.toMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) (MulOneClass.toMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))))) (powMonoidWithZeroHom.{u1} M _inst_1 n hn)) (fun (_x : M) => HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) _x n)\nCase conversion may be inaccurate. Consider using '#align coe_pow_monoid_with_zero_hom coe_powMonoidWithZeroHomₓ'. -/\n@[simp]\ntheorem coe_powMonoidWithZeroHom : (powMonoidWithZeroHom hn : M → M) = (· ^ n) :=\n  rfl\n#align coe_pow_monoid_with_zero_hom coe_powMonoidWithZeroHom\n\n/- warning: pow_monoid_with_zero_hom_apply -> powMonoidWithZeroHom_apply is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoidWithZero.{u1} M] {n : Nat} (hn : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) (a : M), Eq.{succ u1} M (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (fun (_x : MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) => M -> M) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (powMonoidWithZeroHom.{u1} M _inst_1 n hn) a) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) a n)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoidWithZero.{u1} M] {n : Nat} (hn : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) (a : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => M) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M M (MulOneClass.toMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) (MulOneClass.toMul.{u1} M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M M (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (MulZeroOneClass.toMulOneClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1))) M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} M M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)) (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))))) (powMonoidWithZeroHom.{u1} M _inst_1 n hn) a) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M _inst_1)))) a n)\nCase conversion may be inaccurate. Consider using '#align pow_monoid_with_zero_hom_apply powMonoidWithZeroHom_applyₓ'. -/\n@[simp]\ntheorem powMonoidWithZeroHom_apply (a : M) : powMonoidWithZeroHom hn a = a ^ n :=\n  rfl\n#align pow_monoid_with_zero_hom_apply powMonoidWithZeroHom_apply\n\nend CommMonoidWithZero\n\n/- warning: pow_dvd_pow_iff -> pow_dvd_pow_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} R] {x : R} {n : Nat} {m : Nat}, (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))))))) -> (Not (IsUnit.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))) x)) -> (Iff (Dvd.Dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (MonoidWithZero.toSemigroupWithZero.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))) x m)) (LE.le.{0} Nat Nat.hasLe n m))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} R] {x : R} {n : Nat} {m : Nat}, (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))) -> (Not (IsUnit.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))) x)) -> (Iff (Dvd.dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (MonoidWithZero.toSemigroupWithZero.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))) x n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (CommMonoidWithZero.toMonoidWithZero.{u1} R (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} R _inst_1))))) x m)) (LE.le.{0} Nat instLENat n m))\nCase conversion may be inaccurate. Consider using '#align pow_dvd_pow_iff pow_dvd_pow_iffₓ'. -/\ntheorem pow_dvd_pow_iff [CancelCommMonoidWithZero R] {x : R} {n m : ℕ} (h0 : x ≠ 0)\n    (h1 : ¬IsUnit x) : x ^ n ∣ x ^ m ↔ n ≤ m :=\n  by\n  constructor\n  · intro h\n    rw [← not_lt]\n    intro hmn\n    apply h1\n    have : x ^ m * x ∣ x ^ m * 1 := by\n      rw [← pow_succ', mul_one]\n      exact (pow_dvd_pow _ (Nat.succ_le_of_lt hmn)).trans h\n    rwa [mul_dvd_mul_iff_left, ← isUnit_iff_dvd_one] at this\n    apply pow_ne_zero m h0\n  · apply pow_dvd_pow\n#align pow_dvd_pow_iff pow_dvd_pow_iff\n\nsection Semiring\n\nvariable [Semiring R] [Semiring S]\n\n/- warning: ring_hom.map_pow -> RingHom.map_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] (f : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (a : R) (n : Nat), Eq.{succ u2} S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (fun (_x : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) f (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) a n)) (HPow.hPow.{u2, 0, u2} S Nat S (instHPow.{u2, 0} S Nat (Monoid.Pow.{u2} S (MonoidWithZero.toMonoid.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (fun (_x : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) f a) n)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : Semiring.{u1} S] (f : RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) (a : R) (n : Nat), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) (HPow.hPow.{u2, 0, u2} R Nat R (instHPow.{u2, 0} R Nat (Monoid.Pow.{u2} R (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R _inst_1)))) a n)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2))))) f (HPow.hPow.{u2, 0, u2} R Nat R (instHPow.{u2, 0} R Nat (Monoid.Pow.{u2} R (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R _inst_1)))) a n)) (HPow.hPow.{u1, 0, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) a) Nat ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) a) (instHPow.{u1, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) a) Nat (Monoid.Pow.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) a) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) a) (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) a) _inst_2)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2)) R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R _inst_1) (Semiring.toNonAssocSemiring.{u1} S _inst_2))))) f a) n)\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_pow RingHom.map_powₓ'. -/\nprotected theorem RingHom.map_pow (f : R →+* S) (a) : ∀ n : ℕ, f (a ^ n) = f a ^ n :=\n  map_pow f a\n#align ring_hom.map_pow RingHom.map_pow\n\n/- warning: min_pow_dvd_add -> min_pow_dvd_add is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {n : Nat} {m : Nat} {a : R} {b : R} {c : R}, (Dvd.Dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) c n) a) -> (Dvd.Dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) c m) b) -> (Dvd.Dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) c (LinearOrder.min.{0} Nat Nat.linearOrder n m)) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))) a b))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {n : Nat} {m : Nat} {a : R} {b : R} {c : R}, (Dvd.dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) c n) a) -> (Dvd.dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) c m) b) -> (Dvd.dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) c (Min.min.{0} Nat instMinNat n m)) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))) a b))\nCase conversion may be inaccurate. Consider using '#align min_pow_dvd_add min_pow_dvd_addₓ'. -/\ntheorem min_pow_dvd_add {n m : ℕ} {a b c : R} (ha : c ^ n ∣ a) (hb : c ^ m ∣ b) :\n    c ^ min n m ∣ a + b :=\n  by\n  replace ha := (pow_dvd_pow c (min_le_left n m)).trans ha\n  replace hb := (pow_dvd_pow c (min_le_right n m)).trans hb\n  exact dvd_add ha hb\n#align min_pow_dvd_add min_pow_dvd_add\n\nend Semiring\n\nsection CommSemiring\n\nvariable [CommSemiring R]\n\n/- warning: add_sq -> add_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) a b) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) a b) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (Semiring.toNatCast.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align add_sq add_sqₓ'. -/\ntheorem add_sq (a b : R) : (a + b) ^ 2 = a ^ 2 + 2 * a * b + b ^ 2 := by\n  simp only [sq, add_mul_self_eq]\n#align add_sq add_sq\n\n/- warning: add_sq' -> add_sq' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) a b) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))))) a) b))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) a b) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (Semiring.toNatCast.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b))\nCase conversion may be inaccurate. Consider using '#align add_sq' add_sq'ₓ'. -/\ntheorem add_sq' (a b : R) : (a + b) ^ 2 = a ^ 2 + b ^ 2 + 2 * a * b := by\n  rw [add_sq, add_assoc, add_comm _ (b ^ 2), add_assoc]\n#align add_sq' add_sq'\n\n/- warning: add_pow_two -> add_pow_two is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) a b) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) a b) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (Semiring.toNatCast.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align add_pow_two add_pow_twoₓ'. -/\nalias add_sq ← add_pow_two\n#align add_pow_two add_pow_two\n\nend CommSemiring\n\nsection HasDistribNeg\n\nvariable [Monoid R] [HasDistribNeg R]\n\nvariable (R)\n\n/- warning: neg_one_pow_eq_or -> neg_one_pow_eq_or is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (n : Nat), Or (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) n) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (n : Nat), Or (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) n) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align neg_one_pow_eq_or neg_one_pow_eq_orₓ'. -/\ntheorem neg_one_pow_eq_or : ∀ n : ℕ, (-1 : R) ^ n = 1 ∨ (-1 : R) ^ n = -1\n  | 0 => Or.inl (pow_zero _)\n  | n + 1 =>\n    (neg_one_pow_eq_or n).symm.imp (fun h => by rw [pow_succ, h, neg_one_mul, neg_neg]) fun h => by\n      rw [pow_succ, h, mul_one]\n#align neg_one_pow_eq_or neg_one_pow_eq_or\n\nvariable {R}\n\n/- warning: neg_pow -> neg_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) n) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) n) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) n) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a n))\nCase conversion may be inaccurate. Consider using '#align neg_pow neg_powₓ'. -/\ntheorem neg_pow (a : R) (n : ℕ) : (-a) ^ n = (-1) ^ n * a ^ n :=\n  neg_one_mul a ▸ (Commute.neg_one_left a).mul_pow n\n#align neg_pow neg_pow\n\n/- warning: neg_pow_bit0 -> neg_pow_bit0 is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (bit0.{0} Nat Nat.hasAdd n)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (bit0.{0} Nat Nat.hasAdd n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (bit0.{0} Nat instAddNat n)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (bit0.{0} Nat instAddNat n))\nCase conversion may be inaccurate. Consider using '#align neg_pow_bit0 neg_pow_bit0ₓ'. -/\n@[simp]\ntheorem neg_pow_bit0 (a : R) (n : ℕ) : (-a) ^ bit0 n = a ^ bit0 n := by\n  rw [pow_bit0', neg_mul_neg, pow_bit0']\n#align neg_pow_bit0 neg_pow_bit0\n\n/- warning: neg_pow_bit1 -> neg_pow_bit1 is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (bit1.{0} Nat Nat.hasOne Nat.hasAdd n)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (bit1.{0} Nat Nat.hasOne Nat.hasAdd n)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R) (n : Nat), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (bit1.{0} Nat (CanonicallyOrderedCommSemiring.toOne.{0} Nat Nat.canonicallyOrderedCommSemiring) instAddNat n)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (bit1.{0} Nat (CanonicallyOrderedCommSemiring.toOne.{0} Nat Nat.canonicallyOrderedCommSemiring) instAddNat n)))\nCase conversion may be inaccurate. Consider using '#align neg_pow_bit1 neg_pow_bit1ₓ'. -/\n@[simp]\ntheorem neg_pow_bit1 (a : R) (n : ℕ) : (-a) ^ bit1 n = -a ^ bit1 n := by\n  simp only [bit1, pow_succ, neg_pow_bit0, neg_mul_eq_neg_mul]\n#align neg_pow_bit1 neg_pow_bit1\n\n/- warning: neg_sq -> neg_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align neg_sq neg_sqₓ'. -/\n@[simp]\ntheorem neg_sq (a : R) : (-a) ^ 2 = a ^ 2 := by simp [sq]\n#align neg_sq neg_sq\n\n/- warning: neg_one_sq -> neg_one_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))], Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))], Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))\nCase conversion may be inaccurate. Consider using '#align neg_one_sq neg_one_sqₓ'. -/\n@[simp]\ntheorem neg_one_sq : (-1 : R) ^ 2 = 1 := by rw [neg_sq, one_pow]\n#align neg_one_sq neg_one_sq\n\n/- warning: neg_pow_two -> neg_pow_two is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))] (a : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) a) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align neg_pow_two neg_pow_twoₓ'. -/\nalias neg_sq ← neg_pow_two\n#align neg_pow_two neg_pow_two\n\n/- warning: neg_one_pow_two -> neg_one_pow_two is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))], Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toHasNeg.{u1} R (HasDistribNeg.toHasInvolutiveNeg.{u1} R (MulOneClass.toHasMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (MulOneClass.toHasOne.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Monoid.{u1} R] [_inst_2 : HasDistribNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1))], Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R _inst_1)) (Neg.neg.{u1} R (InvolutiveNeg.toNeg.{u1} R (HasDistribNeg.toInvolutiveNeg.{u1} R (MulOneClass.toMul.{u1} R (Monoid.toMulOneClass.{u1} R _inst_1)) _inst_2)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Monoid.toOne.{u1} R _inst_1)))\nCase conversion may be inaccurate. Consider using '#align neg_one_pow_two neg_one_pow_twoₓ'. -/\nalias neg_one_sq ← neg_one_pow_two\n#align neg_one_pow_two neg_one_pow_two\n\nend HasDistribNeg\n\nsection Ring\n\nvariable [Ring R] {a b : R}\n\n/- warning: commute.sq_sub_sq -> Commute.sq_sub_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} {b : R}, (Commute.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1)) a b) -> (Eq.{succ u1} R (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R _inst_1))) a b) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))) a b)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} {b : R}, (Commute.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))) a b) -> (Eq.{succ u1} R (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R _inst_1)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))) a b) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R _inst_1)) a b)))\nCase conversion may be inaccurate. Consider using '#align commute.sq_sub_sq Commute.sq_sub_sqₓ'. -/\nprotected theorem Commute.sq_sub_sq (h : Commute a b) : a ^ 2 - b ^ 2 = (a + b) * (a - b) := by\n  rw [sq, sq, h.mul_self_sub_mul_self_eq]\n#align commute.sq_sub_sq Commute.sq_sub_sq\n\n/- warning: neg_one_pow_mul_eq_zero_iff -> neg_one_pow_mul_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {n : Nat} {r : R}, Iff (Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))))) n) r) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))) (Eq.{succ u1} R r (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {n : Nat} {r : R}, Iff (Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) n) r) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) (Eq.{succ u1} R r (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align neg_one_pow_mul_eq_zero_iff neg_one_pow_mul_eq_zero_iffₓ'. -/\n@[simp]\ntheorem neg_one_pow_mul_eq_zero_iff {n : ℕ} {r : R} : (-1) ^ n * r = 0 ↔ r = 0 := by\n  rcases neg_one_pow_eq_or R n with ⟨⟩ <;> simp [h]\n#align neg_one_pow_mul_eq_zero_iff neg_one_pow_mul_eq_zero_iff\n\n/- warning: mul_neg_one_pow_eq_zero_iff -> mul_neg_one_pow_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {n : Nat} {r : R}, Iff (Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1))) r (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))))) n)) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))))))) (Eq.{succ u1} R r (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {n : Nat} {r : R}, Iff (Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))) r (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) n)) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))))) (Eq.{succ u1} R r (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align mul_neg_one_pow_eq_zero_iff mul_neg_one_pow_eq_zero_iffₓ'. -/\n@[simp]\ntheorem mul_neg_one_pow_eq_zero_iff {n : ℕ} {r : R} : r * (-1) ^ n = 0 ↔ r = 0 := by\n  rcases neg_one_pow_eq_or R n with ⟨⟩ <;> simp [h]\n#align mul_neg_one_pow_eq_zero_iff mul_neg_one_pow_eq_zero_iff\n\nvariable [NoZeroDivisors R]\n\n/- warning: commute.sq_eq_sq_iff_eq_or_eq_neg -> Commute.sq_eq_sq_iff_eq_or_eq_neg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} {b : R} [_inst_2 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1)) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))], (Commute.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1)) a b) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (Or (Eq.{succ u1} R a b) (Eq.{succ u1} R a (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))) b))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} {b : R} [_inst_2 : NoZeroDivisors.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))) (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))], (Commute.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))) a b) -> (Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (Or (Eq.{succ u1} R a b) (Eq.{succ u1} R a (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) b))))\nCase conversion may be inaccurate. Consider using '#align commute.sq_eq_sq_iff_eq_or_eq_neg Commute.sq_eq_sq_iff_eq_or_eq_negₓ'. -/\nprotected theorem Commute.sq_eq_sq_iff_eq_or_eq_neg (h : Commute a b) :\n    a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b := by\n  rw [← sub_eq_zero, h.sq_sub_sq, mul_eq_zero, add_eq_zero_iff_eq_neg, sub_eq_zero, or_comm']\n#align commute.sq_eq_sq_iff_eq_or_eq_neg Commute.sq_eq_sq_iff_eq_or_eq_neg\n\n/- warning: sq_eq_one_iff -> sq_eq_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} [_inst_2 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1)) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))], Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))))) (Or (Eq.{succ u1} R a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))))) (Eq.{succ u1} R a (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} [_inst_2 : NoZeroDivisors.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))) (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))], Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (Or (Eq.{succ u1} R a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (Eq.{succ u1} R a (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align sq_eq_one_iff sq_eq_one_iffₓ'. -/\n@[simp]\ntheorem sq_eq_one_iff : a ^ 2 = 1 ↔ a = 1 ∨ a = -1 := by\n  rw [← (Commute.one_right a).sq_eq_sq_iff_eq_or_eq_neg, one_pow]\n#align sq_eq_one_iff sq_eq_one_iff\n\n/- warning: sq_ne_one_iff -> sq_ne_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} [_inst_2 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R _inst_1)) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))], Iff (Ne.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R _inst_1))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))))) (And (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))))) (Ne.{succ u1} R a (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1))))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Ring.{u1} R] {a : R} [_inst_2 : NoZeroDivisors.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))) (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)))], Iff (Ne.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (And (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1))))) (Ne.{succ u1} R a (Neg.neg.{u1} R (Ring.toNeg.{u1} R _inst_1) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocRing.toOne.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align sq_ne_one_iff sq_ne_one_iffₓ'. -/\ntheorem sq_ne_one_iff : a ^ 2 ≠ 1 ↔ a ≠ 1 ∧ a ≠ -1 :=\n  sq_eq_one_iff.Not.trans not_or\n#align sq_ne_one_iff sq_ne_one_iff\n\nend Ring\n\nsection CommRing\n\nvariable [CommRing R]\n\n/- warning: sq_sub_sq -> sq_sub_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a b) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b))\nCase conversion may be inaccurate. Consider using '#align sq_sub_sq sq_sub_sqₓ'. -/\ntheorem sq_sub_sq (a b : R) : a ^ 2 - b ^ 2 = (a + b) * (a - b) :=\n  (Commute.all a b).sq_sub_sq\n#align sq_sub_sq sq_sub_sq\n\n/- warning: pow_two_sub_pow_two -> pow_two_sub_pow_two is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a b) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b))\nCase conversion may be inaccurate. Consider using '#align pow_two_sub_pow_two pow_two_sub_pow_twoₓ'. -/\nalias sq_sub_sq ← pow_two_sub_pow_two\n#align pow_two_sub_pow_two pow_two_sub_pow_two\n\n/- warning: sub_sq -> sub_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (NonAssocRing.toNatCast.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align sub_sq sub_sqₓ'. -/\ntheorem sub_sq (a b : R) : (a - b) ^ 2 = a ^ 2 - 2 * a * b + b ^ 2 := by\n  rw [sub_eq_add_neg, add_sq, neg_sq, mul_neg, ← sub_eq_add_neg]\n#align sub_sq sub_sq\n\n/- warning: sub_pow_two -> sub_pow_two is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (NonAssocRing.toNatCast.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align sub_pow_two sub_pow_twoₓ'. -/\nalias sub_sq ← sub_pow_two\n#align sub_pow_two sub_pow_two\n\n/- warning: sub_sq' -> sub_sq' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) a) b))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] (a : R) (b : R), Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (NonAssocRing.toNatCast.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) b))\nCase conversion may be inaccurate. Consider using '#align sub_sq' sub_sq'ₓ'. -/\ntheorem sub_sq' (a b : R) : (a - b) ^ 2 = a ^ 2 + b ^ 2 - 2 * a * b := by\n  rw [sub_eq_add_neg, add_sq', neg_sq, mul_neg, ← sub_eq_add_neg]\n#align sub_sq' sub_sq'\n\nvariable [NoZeroDivisors R] {a b : R}\n\n/- warning: sq_eq_sq_iff_eq_or_eq_neg -> sq_eq_sq_iff_eq_or_eq_neg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))] {a : R} {b : R}, Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (Or (Eq.{succ u1} R a b) (Eq.{succ u1} R a (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))] {a : R} {b : R}, Iff (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (Or (Eq.{succ u1} R a b) (Eq.{succ u1} R a (Neg.neg.{u1} R (Ring.toNeg.{u1} R (CommRing.toRing.{u1} R _inst_1)) b)))\nCase conversion may be inaccurate. Consider using '#align sq_eq_sq_iff_eq_or_eq_neg sq_eq_sq_iff_eq_or_eq_negₓ'. -/\ntheorem sq_eq_sq_iff_eq_or_eq_neg : a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b :=\n  (Commute.all a b).sq_eq_sq_iff_eq_or_eq_neg\n#align sq_eq_sq_iff_eq_or_eq_neg sq_eq_sq_iff_eq_or_eq_neg\n\n/- warning: eq_or_eq_neg_of_sq_eq_sq -> eq_or_eq_neg_of_sq_eq_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))] (a : R) (b : R), (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (Or (Eq.{succ u1} R a b) (Eq.{succ u1} R a (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))] (a : R) (b : R), (Eq.{succ u1} R (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (Or (Eq.{succ u1} R a b) (Eq.{succ u1} R a (Neg.neg.{u1} R (Ring.toNeg.{u1} R (CommRing.toRing.{u1} R _inst_1)) b)))\nCase conversion may be inaccurate. Consider using '#align eq_or_eq_neg_of_sq_eq_sq eq_or_eq_neg_of_sq_eq_sqₓ'. -/\ntheorem eq_or_eq_neg_of_sq_eq_sq (a b : R) : a ^ 2 = b ^ 2 → a = b ∨ a = -b :=\n  sq_eq_sq_iff_eq_or_eq_neg.1\n#align eq_or_eq_neg_of_sq_eq_sq eq_or_eq_neg_of_sq_eq_sq\n\n-- Copies of the above comm_ring lemmas for `units R`.\nnamespace Units\n\n/- warning: units.sq_eq_sq_iff_eq_or_eq_neg -> Units.sq_eq_sq_iff_eq_or_eq_neg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))] {a : Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))} {b : Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))}, Iff (Eq.{succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHPow.{u1, 0} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Monoid.Pow.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.group.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHPow.{u1, 0} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Monoid.Pow.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.group.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (Or (Eq.{succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b) (Eq.{succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) a (Neg.neg.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.hasNeg.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocRing.toHasDistribNeg.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) b)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))] {a : Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))} {b : Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))}, Iff (Eq.{succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (instHPow.{u1, 0} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Monoid.Pow.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Units.instGroupUnits.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (instHPow.{u1, 0} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Monoid.Pow.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Units.instGroupUnits.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (Or (Eq.{succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) a b) (Eq.{succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) a (Neg.neg.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Units.instNegUnits.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (NonUnitalNonAssocRing.toHasDistribNeg.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) b)))\nCase conversion may be inaccurate. Consider using '#align units.sq_eq_sq_iff_eq_or_eq_neg Units.sq_eq_sq_iff_eq_or_eq_negₓ'. -/\nprotected theorem sq_eq_sq_iff_eq_or_eq_neg {a b : Rˣ} : a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b := by\n  simp_rw [ext_iff, coe_pow, sq_eq_sq_iff_eq_or_eq_neg, Units.val_neg]\n#align units.sq_eq_sq_iff_eq_or_eq_neg Units.sq_eq_sq_iff_eq_or_eq_neg\n\n/- warning: units.eq_or_eq_neg_of_sq_eq_sq -> Units.eq_or_eq_neg_of_sq_eq_sq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (Ring.toDistrib.{u1} R (CommRing.toRing.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))))] (a : Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (b : Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))), (Eq.{succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHPow.{u1, 0} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Monoid.Pow.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.group.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (instHPow.{u1, 0} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) Nat (Monoid.Pow.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.group.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) b (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) -> (Or (Eq.{succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b) (Eq.{succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) a (Neg.neg.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1))) (Units.hasNeg.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)) (NonUnitalNonAssocRing.toHasDistribNeg.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) b)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] [_inst_2 : NoZeroDivisors.{u1} R (NonUnitalNonAssocRing.toMul.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))] (a : Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (b : Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))), (Eq.{succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (instHPow.{u1, 0} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Monoid.Pow.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Units.instGroupUnits.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) a (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{u1, 0, u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (instHPow.{u1, 0} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) Nat (Monoid.Pow.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (DivInvMonoid.toMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Group.toDivInvMonoid.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Units.instGroupUnits.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))))))) b (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) -> (Or (Eq.{succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) a b) (Eq.{succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) a (Neg.neg.{u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))))) (Units.instNegUnits.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))) (NonUnitalNonAssocRing.toHasDistribNeg.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))))) b)))\nCase conversion may be inaccurate. Consider using '#align units.eq_or_eq_neg_of_sq_eq_sq Units.eq_or_eq_neg_of_sq_eq_sqₓ'. -/\nprotected theorem eq_or_eq_neg_of_sq_eq_sq (a b : Rˣ) (h : a ^ 2 = b ^ 2) : a = b ∨ a = -b :=\n  Units.sq_eq_sq_iff_eq_or_eq_neg.1 h\n#align units.eq_or_eq_neg_of_sq_eq_sq Units.eq_or_eq_neg_of_sq_eq_sq\n\nend Units\n\nend CommRing\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/GroupPower/Ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6513548511303336, "lm_q1q2_score": 0.4801515452785163}}
{"text": "theorem t1 (p q : Prop) (hp : p) (hq : q) : p := hp\n\nvariables p q r s : Prop\n\n#check t1 p q\n#check t1 r s\n#check t1 (r → s) (s → r)\n\nvariable h : r → s\n#check t1 (r → s) (s → r) h\n\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0212.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.48012350982798696}}
{"text": "import signed_radon_nikodym\n\nnoncomputable theory\nopen_locale classical measure_theory nnreal ennreal\n\nvariables {α : Type*} {m n : measurable_space α} \nvariables {M : Type*} [add_comm_monoid M] [topological_space M]\n\nnamespace measure_theory\n\n-- namespace vector_measure\n\n-- include m n\n\n-- @[simps]\n-- def trim (v : vector_measure α M) (hle : m ≤ n) : @vector_measure α m M _ _ :=\n-- { measure_of' := λ i, if measurable_set[m] i then v i else 0,\n--   empty' := by rw [if_pos measurable_set.empty, v.empty],\n--   not_measurable' := λ i hi, by rw if_neg hi,\n--   m_Union' := λ f hf₁ hf₂,\n--   begin\n--     have hf₁' : ∀ k, measurable_set[n] (f k) := λ k, hle _ (hf₁ k),\n--     convert v.m_Union hf₁' hf₂,\n--     { ext n, rw if_pos (hf₁ n) },\n--     { rw if_pos (@measurable_set.Union _ _ m _ _ hf₁) }\n--   end }\n\n-- variables {v : vector_measure α M} (hle : m ≤ n)\n\n-- lemma trim_eq_self : v.trim le_rfl = v := \n-- begin\n--   ext1 i hi,\n--   exact if_pos hi,\n-- end\n\n-- lemma zero_trim (hle : m ≤ n) : (0 : vector_measure α M).trim hle = 0 :=\n-- begin\n--   ext1 i hi,\n--   exact if_pos hi,\n-- end\n\n-- lemma trim_measurable_set_eq {i : set α} (hle : m ≤ n) (hi : measurable_set[m] i) :\n--   v.trim hle i = v i :=\n-- if_pos hi\n\n-- end vector_measure\n\nnamespace signed_measure\n\nopen vector_measure\n\nlemma with_density_signed_measure_trim_eq_integral \n  {μ : measure α} (hle : m ≤ n) {f : α → ℝ} (hf : integrable f μ) \n  {i : set α} (hi : measurable_set[m] i) : \n  (μ.with_densityᵥ f).trim hle i = ∫ x in i, f x ∂μ :=\nby rw [vector_measure.trim_measurable_set_eq hle hi, \n       with_densityᵥ_apply hf (hle _ hi)]\n\nend signed_measure\n\nend measure_theory", "meta": {"author": "JasonKYi", "repo": "probability_theory", "sha": "01aa0e1372cb0311c90be59ea18944c5ef5f2293", "save_path": "github-repos/lean/JasonKYi-probability_theory", "path": "github-repos/lean/JasonKYi-probability_theory/probability_theory-01aa0e1372cb0311c90be59ea18944c5ef5f2293/archive/trim.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4801235098279869}}
{"text": "import .clause \n\nopen tactic\n\nmeta def trisect (m : nat) :  \n  list (list nat × term) → (list (list nat × term) × \n  list (list nat × term) × list (list nat × term)) \n| [] := ([],[],[])\n| ((p,t)::pts) := \n  let (neg,zero,pos) := trisect pts in \n  if t.snd.get m < 0 \n  then ((p,t)::neg,zero,pos)\n  else if t.snd.get m = 0 \n       then (neg,(p,t)::zero,pos)\n       else (neg,zero,(p,t)::pos)\n\nmeta def elim_var_aux (m : nat) : \n  ((list nat × term) × (list nat × term)) → tactic (list nat × term) \n| ((p1,t1), (p2,t2)) := \n  let n := int.nat_abs (t1.snd.get m) in\n  let o := int.nat_abs (t2.snd.get m) in\n  let lcm := (nat.lcm n o) in\n  let n' := lcm / n in\n  let o' := lcm / o in\n  return (list.add (n' *₁ p1) (o' *₁ p2), \n          term.add (t1.mul n') (t2.mul o'))\n\nmeta def elim_var (m) (neg pos : list (list nat × term)) : \n  tactic (list (list nat × term)) :=\nlet pairs := list.product neg pos in \nmonad.mapm (elim_var_aux m) pairs\n\nmeta def find_contra : list (list nat × term) → tactic (list nat)\n| []            := failed\n| ((π,⟨c,_⟩)::l) := if c < 0 then return π else find_contra l\n\nmeta def search_core : nat → list (list nat × term) → tactic (list nat) \n| 0 pts     := find_contra pts\n| (m+1) pts :=\n  let (neg,zero,pos) := trisect m pts in\n  do new ← elim_var m neg pos,\n     search_core m (new ++ zero)\n\nmeta def search (ts : list term) : tactic (list nat) :=\nsearch_core \n  (ts.map (λ t : term, t.snd.length)).max  \n  (ts.map_with_idx (λ m t, ([]{m ↦ 1}, t)))\n\n@[omega] def comb : list term → list nat → term \n| [] []     := ⟨0,[]⟩ \n| [] (_::_) := ⟨0,[]⟩ \n| (_::_) [] := ⟨0,[]⟩ \n| (t::ts) (n::ns) := term.add (t.mul ↑n) (comb ts ns)\n\nlemma comb_holds {v} :\n  ∀ {ts} ns, (∀ t ∈ ts, 0 ≤ term.val v t) → (0 ≤ (comb ts ns).val v) \n| [] []     h := by simp_omega\n| [] (_::_) h := by simp_omega\n| (_::_) [] h := by simp_omega\n| (t::ts) (n::ns) h :=\n  begin\n    simp_omega, apply add_nonneg, \n    { apply mul_nonneg,\n      apply int.coe_nat_nonneg,\n      apply h _ (or.inl rfl) },\n    { apply comb_holds, \n      apply list.forall_mem_of_forall_mem_cons h }\n  end\n\ndef unsat_comb (ts ns) : Prop :=\n(comb ts ns).fst < 0 ∧ ∀ x ∈ (comb ts ns).snd, x = (0 : int)\n\nlemma unsat_comb_of (ts ns) : \n(comb ts ns).fst < 0 → \n(∀ x ∈ (comb ts ns).snd, x = (0 : int)) → \nunsat_comb ts ns := \nbegin intros h1 h2, exact ⟨h1,h2⟩ end\n\nlemma unsat_of_unsat_comb (ns les) :\n  (unsat_comb les ns) → clause.unsat ([], les) :=\nbegin\n  intros h1 h2, cases h2 with v h2, \n  have h3 := comb_holds ns h2.right,\n  cases h1 with hl hr, \n  cases (comb les ns) with b as,\n  simp_omega at h3, \n  rw [coeffs.val_eq_zero hr, add_zero, ← not_lt] at h3,\n  apply h3 hl \nend\n\n#exit\nlemma unsat_of_unsat_comb' (ts : polytope) (ns : list nat) :\n  (unsat_comb' ts ns) → ts.unsat :=\nbegin\n  intro h1, apply unsat_of_unsat_comb ns,\n  simp only [unsat_comb'] at h1, \n  simp only [unsat_comb], \n  rw if_pos h1, trivial\nend", "meta": {"author": "skbaek", "repo": "omega", "sha": "715e384ed14e8eb177a326700066e7c98269e078", "save_path": "github-repos/lean/skbaek-omega", "path": "github-repos/lean/skbaek-omega/omega-715e384ed14e8eb177a326700066e7c98269e078/scalar.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127492339909, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4800496814261369}}
{"text": "import hilbert.wr.or\nimport hilbert.wr.or_bot\n\nnamespace clfrags\n    namespace hilbert\n        namespace wr\n            namespace or_bot\n                theorem  db₁_or {a b : Prop} (h₁ : or b (or a bot)) : or b a :=\n                    have h₂ : or (or b a) bot, from or.d₄ h₁,\n                    show or b a, from db₁ h₂\n\n                theorem  b₁ {a : Prop} (h₁ : bot) : a :=\n                    have h₂ : or bot a, from or.d₁ h₁,\n                    have h₃ : or a bot, from or.d₃ h₂,\n                    show a, from db₁ h₃\n            end or_bot\n        end wr\n    end hilbert\nend clfrags\n\n", "meta": {"author": "greati", "repo": "hilbert-classical-fragments", "sha": "18a21ac6b2e890060eb4ae65752fc0245394d226", "save_path": "github-repos/lean/greati-hilbert-classical-fragments", "path": "github-repos/lean/greati-hilbert-classical-fragments/hilbert-classical-fragments-18a21ac6b2e890060eb4ae65752fc0245394d226/clfrags/src/hilbert/wr/proofs/or_bot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8539127455162773, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4800496793361257}}
{"text": "import Cla.Parse\n\n\n\n/-! # `Com`mand types and helpers -/\n\nnamespace Cla\n\n\n\n/-! ## Building blocks -/\n\n\n\n/-- Validates some `In`put.\n\n- `σ` is the type of the state that the validator affects;\n- `α` is the output type, which is currently not used (set to [`Unit`]).\n-/\nabbrev Validator\n  (In : Type)\n  (σ : Type)\n  (α : Type)\n:=\n  In → EStateM String σ α\n\n\n\n/-- `M`ulti `Prod`uct, stores a `β` in `n` nested pairs, all with first elements in `α`.\n\nFor example, `MProd 3 Nat String` is `Nat × (Nat × (Nat × String))`.\n\nThis is used for flags that take *at least `n` arguments*, to a type that stores `n` strings (the\nfirst `n` mandatory arguments), followed by\n- nothing if the flag expects exactly `n` arguments;\n- `List String` (tail of arguments) if the flag expects at most `m` (`m > n`) arguments or expects\n  an unbounded number of arguments.\n-/\nabbrev MProd\n  (n : Nat)\n  (α β : Type)\n: Type :=\n  match n with\n  | 0 => β\n  | n + 1 => α × (MProd n α β)\n\nexample :\n  MProd 3 Nat String\n  =\n  (Nat × Nat × Nat × String)\n:=\n  rfl\n\n-- pattern matching works too :D\nexample : MProd 3 Nat String → String\n| (_i, _j, _k, s) => s\n\n\n/-- Builds a `μ (MProd min α β)` from `α` and `β` getters. -/\ndef MProd.build\n  {μ : Type → Type}\n  [Monad μ]\n  (getα : μ α)\n  (getβ : μ β)\n  (min : Nat)\n: μ <| MProd min α β :=\n  match min with\n  | 0 =>\n    getβ\n  | min + 1 =>\n    do\n      let a ← getα\n      let tail ← MProd.build getα getβ min\n      pure (a, tail)\n\n\n/-! ## Bounds, specify how many values a flag takes -/\n\n\n\n/-- An interval with a possibly infinite upper-bound.\n\nUpper-bound is infinite iff `max = none`.\n-/\nstructure ArgSpec.Bounds where\n  min : Nat\n  max : Option Nat\nderiving Repr, BEq\n\n\n\ninstance instToStringArgSpecBounds\n: ToString ArgSpec.Bounds where\n  toString self :=\n    let max :=\n      self.max.map\n        (s! \"{·}]\")\n      |>.getD\n        \"∞[\"\n    s! \"[{self.min}, {max}\"\n\nnamespace ArgSpec.Bounds\n  /-- The interval `[min, max]` with `min ≤ max`. -/\n  def between\n    (min max : Nat)\n    -- (_legal : min ≤ max := by simp)\n  : Bounds where\n    min := min\n    max := some max\n\n  example : s! \"{between 1 7}\" = \"[1, 7]\" := rfl\n  example : s! \"{between 3 3}\" = \"[3, 3]\" := rfl\n\n  /-- `[min, ∞[` -/\n  def atLeast\n    (min : Nat)\n  : Bounds where\n    min := min\n    max := none\n\n  example : s! \"{atLeast 0}\" = \"[0, ∞[\" := rfl\n  example : s! \"{atLeast 7}\" = \"[7, ∞[\" := rfl\n\n  /-- `[0, max]` -/\n  def atMost\n    (max : Nat)\n  : Bounds where\n    min := 0\n    max := some max\n\n  example : s! \"{atMost 0}\" = \"[0, 0]\" := rfl\n  example : s! \"{atMost 7}\" = \"[0, 7]\" := rfl\n\n  /-- `[n, n]` -/\n  def exact\n    (n : Nat)\n  :=\n    between n n\n\n  example : s! \"{exact 0}\" = \"[0, 0]\" := rfl\n  example : s! \"{exact 7}\" = \"[7, 7]\" := rfl\n\n  /-- `[0, 0]` -/\n  def default :=\n    exact 0\n\n  /-- `[0, 0]` -/\n  def zero :=\n    exact 0\n\n\n\n  /-! Simple DSL using `⟦` (`\\[[`), `⟧` (`\\[[`) and `∞` (`\\infty`). -/\n  namespace Dsl\n    local syntax \"⟦\" term \", \" term \"⟧\" : term\n    local syntax \"⟦\" term \", \" \"∞\" \"⟧\" : term\n    macro_rules\n    | `(⟦ $min, $max ⟧) =>\n      `(ArgSpec.Bounds.between $min $max)\n    | `(⟦ $min, ∞ ⟧) =>\n      `(ArgSpec.Bounds.atLeast $min)\n  end Dsl\n\n  open Dsl\n\n\n\n  protected abbrev MProd\n    (bounds : ArgSpec.Bounds)\n  : Type :=\n    if bounds.max == some bounds.min then\n      match bounds.min with\n      | 0 => Unit\n      | min + 1 => MProd min String String\n    else\n      MProd bounds.min String <| List String\n\n  example :\n    (Bounds.mk 0 (some 0) |>.MProd) = Unit\n  := rfl\n  example :\n    (Bounds.mk 0 none |>.MProd) = (MProd 0 String <| List String)\n  := rfl\n  example :\n    (Bounds.mk 0 (some 1) |>.MProd) = (MProd 0 String <| List String)\n  := rfl\n  example :\n    (Bounds.mk 7 (some 7) |>.MProd) = (MProd 6 String String)\n  := rfl\n  example :\n    (Bounds.mk 7 (some 8) |>.MProd) = (MProd 7 String <| List String)\n  := rfl\n\n\n  /-- Type for a validator that validates at least `min` and at most `max` arguments.\n\n  Number of arguments is unbounded if `max = none`. Accepts no argument at all if `max = 0` or `max =\n  some m` with `m < min`.\n  -/\n  protected abbrev Validator\n    (bounds : ArgSpec.Bounds)\n    (σ : Type)\n    (α : Type)\n  : Type :=\n    Validator bounds.MProd σ α\n\n\n\n\n  section MProdBuild\n    variable\n      (bounds : Bounds)\n      (getArg : IParseM String)\n      (getAll : IParseM <| List String)\n\n    protected def MProd.buildNone\n    : IParseM <| MProd 0 String Unit :=\n      by\n        dsimp [Bounds.MProd]\n        simp\n        apply pure ()\n\n    protected def MProd.buildExact\n      (minMinus1 : Nat)\n    : IParseM <| MProd minMinus1 String String :=\n      MProd.build getArg getArg minMinus1\n\n    protected def MProd.buildMinOnly\n      (min : Nat)\n    : IParseM <| MProd min String <| List String :=\n      MProd.build getArg getAll min\n\n\n\n    protected def MProdRun\n      {σ : outParam Type}\n    : (bounds.Validator σ Unit) → IParseM (EStateM String σ Unit) :=\n      by\n        simp [Bounds.MProd, Bounds.Validator, Validator]\n        cases bounds.max == some bounds.min with\n        | true =>\n          simp\n          cases bounds.min with\n          | zero =>\n            exact fun action =>\n              pure <| action ()\n          | succ min =>\n            simp\n            exact\n              fun action =>\n                do\n                  let input ←\n                    MProd.buildExact getArg min\n                  pure <| action input\n        | false =>\n          simp\n          exact\n            fun action =>\n              do\n                let input ←\n                  MProd.buildMinOnly getArg getAll bounds.min\n                pure <| action input\n  end MProdBuild\nend ArgSpec.Bounds\n\n\n\nstructure ArgSpec\n  (σ : Type)\nextends\n  ArgSpec.Bounds\nwhere\n  validator :\n    toBounds.Validator σ Unit\n\nsection ArgSpec\n  variable\n    {σ : Type}\n    (self : @&ArgSpec σ)\n\n  def ArgSpec.bounds :=\n    self.toBounds\n\n  /-- A user-friendly description of the number of arguments expected.\n\n  Designed to follow, typically, `\"expected ...\"`.\n  -/\n  def ArgSpec.descCountExpected : String :=\n    match (self.min, self.max) with\n    | (0, none) => \"any number of argument\"\n    | (min, none) => s! \"{min} argument{plural.s min} or more\"\n    | (_, some 0) => \"no argument\"\n    | (min, some max) =>\n      if min = max then\n        s! \"exactly {min} argument{plural.s min}\"\n      else\n        s! \"between {min} and {max} argument{plural.s max}\"\n\n  /-- Produces an error using [`ArgSpec.descCountExpected`]. -/\n  def ArgSpec.countBail! : IParseM α :=\n    do\n      bail! self.descCountExpected\nend ArgSpec\n\n\n\n/-! ## Building [`Flag`]s with session types -/\n\n\n\n/-- A description. -/\nstructure Flag0 (σ : Type) where\n  desc : String\nderiving Repr, BEq\n\n/-- Adds short and/or long names to [`Flag0`]. -/\nstructure Flag1 (σ : Type)\nextends Flag0 σ\nwhere\n  short : Option Char\n  long : Option String\nderiving Repr, BEq\n\n/-- Adds cardinality bounds to [`Flag1`]. -/\nstructure Flag2 (σ : Type)\nextends Flag1 σ\nwhere\n  bounds : ArgSpec.Bounds\nderiving Repr, BEq\n\n/-- Adds arguments specification to [`Flag1`], but **built** from [`Flag2`]. -/\nstructure Flag\n  (σ : Type)\n-- extends Flag1 σ\nwhere\n  desc : String\n  short : Option Char\n  long : Option String\n  args: ArgSpec σ\n\n\n\nnamespace Flag0\n  variable (self : Flag0 σ)\n\n  /-- Sets the flag's short name. -/\n  def withShort (short : Option Char) : Flag1 σ := {\n      self with\n        short\n        long := none\n  }\n\n  /-- Sets the flag's long name. -/\n  def withLong (long : Option String) : Flag1 σ := {\n    self with\n      short := none\n      long\n  }\nend Flag0\n\nnamespace Flag1\n  variable (self : Flag1 σ)\n\n  /-- Sets the flag's short name. -/\n  def withShort (short : Option Char) : Flag1 σ := {\n    self with short\n  }\n\n  /-- Sets the flag's long name. -/\n  def withLong (long : Option String) : Flag1 σ := {\n    self with long\n  }\n\n  /-- Specifies the number of arguments expected as an interval. -/\n  def argsIn (bounds : ArgSpec.Bounds) : Flag2 σ := {\n    self with bounds\n  }\n\n  /-- Specifies an arbitrary number of arguments greater than `min`. -/\n  def argsAtLeast (min : Nat) : Flag2 σ := {\n    self with\n      bounds := ArgSpec.Bounds.atLeast min\n  }\n\n  /-- Specifies an arbitrary number of arguments less than `max`. -/\n  def argsAtMost (max : Nat) : Flag2 σ := {\n    self with\n      bounds := ArgSpec.Bounds.atMost max\n  }\n\n  /-- Specifies a precise number of arguments. -/\n  def argsTake (n : Nat) : Flag2 σ := {\n    self with\n      bounds := ArgSpec.Bounds.exact n\n  }\n\n  def effect\n    (validator : ArgSpec.Bounds.zero.Validator σ Unit)\n  : Flag σ := {\n    self with\n      args := ⟨ArgSpec.Bounds.zero, validator⟩\n  }\nend Flag1\n\nnamespace Flag2\n  variable (self : Flag2 σ)\n\n  def effect\n    (validator : self.bounds.Validator σ Unit)\n  : Flag σ := {\n    self.toFlag1 with\n      args := ⟨self.bounds, validator⟩\n  }\nend Flag2\n\nnamespace Flag\n  def withDesc (desc : String) : Flag0 σ :=\n    ⟨desc⟩\n\n  -- def adapt\n  --   (self : Flag σ)\n  --   (adaptor : EStateM String σ Unit → EStateM String σ' Unit)\n  -- : Flag σ' :=\n  --   let validator : self.args.bounds.Validator σ' Unit :=\n  --     by\n  --       let validator :=\n  --         self.args.validator\n  --       simp [ArgSpec.Bounds.Validator]\n  --       simp [ArgSpec.Bounds.Validator] at validator\n  --       cases h_max : self.args.1.max\n  --       · simp [h_max] at validator\n  --         simp\n  --         intro input\n  --         apply adaptor\n  --         apply validator input\n  --       · simp [h_max] at validator\n  --         simp\n  --         sorry\n  --   let args : ArgSpec σ' :=\n  --     ⟨self.args.bounds, fun i =>\n  --       adaptor ∘ self.args.validator\n  --     ⟩\n  --   { self.toFlag1 with args := ⟨self.args.bounds, fun i => self.validator i |> adaptor⟩ }\nend Flag\n\n\n\nstructure Flags (σ : Type) where\nprotected innerMk ::\n  flags : Array (Flag σ)\n  /-- [`Char`] is not [`Hashable`] :( -/\n  short : HashMap String flags.Idx\n  long : HashMap String flags.Idx\n\nsection Flags\n  /-- Creates an empty `Flags`. -/\n  def Flags.empty : Flags σ :=\n    ⟨Array.empty, Std.mkHashMap 0, Std.mkHashMap 0⟩\n\n  def Flags.debug\n    (flags : Flags σ)\n  : IO Unit :=\n    do\n      IO.println \"shorts:\"\n      for (c, _) in flags.short.toList do\n        IO.println s! \"- `{c}`\"\n      IO.println \"longs:\"\n      for (l, _) in flags.long.toList do\n        IO.println s! \"- `{l}`\"\n\n  /-- Constructor. -/\n  def Flags.mk\n    (flags : Array (Flag σ))\n  : Except String <| Flags σ :=\n    do\n      let (short, long) ←\n        flags.foldlIdx! foldl init\n      pure ⟨flags, short, long⟩\n  where\n    init := (\n      Std.mkHashMap flags.size,\n      Std.mkHashMap flags.size\n    )\n    foldl (state : (HashMap _ _ × HashMap _ _)) idx (flag : Flag σ) :=\n      do\n        let (short, long) :=\n          state\n        let short ←\n          if let some c := flag.short then\n            let (short, notNew) :=\n              short.insert' s!\"{c}\" idx\n            if notNew then\n              throw s! \"two flags have the same short name `-{c}`\"\n            else\n              pure short\n          else\n            pure short\n        let long ←\n          if let some l := flag.long then\n            let (long, notNew) :=\n              long.insert' l idx\n            if notNew then\n              throw s! \"two flags have the same long name `--{l}`\"\n            else\n              pure long\n          else\n            pure long\n        pure (short, long)\n\n  def Flags.mkM\n    (flags : Array <| Except String <| Flag σ)\n  : Except String <| Flags σ :=\n    do\n      let flags ←\n        flags.mapM id\n      Flags.mk flags\nend Flags\n\n\n\n\n/-- Used to build [`Com.Builder`] and [`Com`].\n\nAbstract description of a command, there's no reason to use this directly.\n-/\nstructure Command\n  (F : Type u)\nwhere\n  name : String\n  flags : F\nderiving Inhabited\n\n\n\n/-- Stores a [`Flags`] structure.\n\nTo build a `Com` use the [`Com.Builder`], for instance using [`Com.mkBuilder`].\n-/\ndef Com\n  (σ : Type)\n:=\n  Command (Flags σ)\n\ndef Com.mk\n  {σ : Type}\n  (name : String)\n  (flags : Flags σ)\n: Com σ :=\n  ⟨name, flags⟩\n\ndef Com.mkM\n  {μ : Type → Type}\n  [Monad μ]\n  {σ : Type}\n  (name : String)\n  (flags : μ <| Flags σ)\n: μ <| Com σ :=\n  do\n    pure ⟨name, ←flags⟩\n\ninstance instInhabitedCom\n  [Inhabited σ]\n: Inhabited <| Com σ where\n  default := ⟨\"default\", Flags.empty⟩\n\n\n\nsection builder\n  /-- Stores an array of [`Flag`]s. -/\n  abbrev Com.Builder\n    (σ : Type)\n  :=\n    Command (Array <| Flag σ)\n\n  /-- Empty constructor. -/\n  def Com.Builder.empty\n    (σ : Type)\n    (name : String)\n  : Com.Builder σ :=\n    ⟨name, Array.empty⟩\n\n  /-- Pushes a flag. -/\n  def Com.Builder.withFlag\n    (self : Com.Builder σ)\n    (flag : Flag σ)\n  : Com.Builder σ :=\n    { self with\n      flags := self.flags.push flag\n    }\n\n  /-- Adds some flags. -/\n  def Com.Builder.withFlags\n    (self : Com.Builder σ)\n    (flags : List (Flag σ))\n  : Com.Builder σ :=\n    { self with\n      flags := self.flags ++ flags\n    }\n\n  /-- Turns the builder into an actual [`Com`]. -/\n  def Com.Builder.build\n    (self : Com.Builder σ)\n  : Except String <| Com σ :=\n    do\n      let flags ←\n        Flags.mk self.flags\n      pure ⟨self.name, flags⟩\n\n  /-- Type of flags accepted by a builder. -/\n  protected def Com.Builder.Flag\n    (_self : Com.Builder σ)\n  : Type :=\n    Flag σ\nend builder\n\n\n\nsection Com\n  /-- Constructor for [`Com.Builder`]. -/\n  def Com.mkBuilder\n    (σ : Type)\n    (name : String)\n  : Com.Builder σ :=\n    Com.Builder.empty σ name\n\n  variable\n    (self : Com σ)\n\n  def Com.shortOf\n    (short : String)\n    : IParseM (Flag σ)\n  :=\n    do\n      if let some idx := self.flags.short.find? short\n      then pure <| self.flags.flags.get idx\n      else throw \"unexpected short flag\"\n\n  def Com.longOf\n    (long : String)\n    : IParseM (Flag σ)\n  :=\n    do\n      if let some idx := self.flags.long.find? long\n      then pure <| self.flags.flags.get idx\n      else throw \"unexpected long flag\"\n\n  -- def Com.runShort (short : String) : IParseM σ :=\n  --   do\n  --     let flag ←\n  --       self.shortOf short\n      \n    \n\n  -- def Com.run\n  --   (self : Com σ)\n  --   (parser : Parse)\n  -- : ParseM σ :=\n  --   do\n  --     parser.nextDo\n  --       ()\n\n  -- def Com.parse\n  --   (args : List String)\nend Com\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/cla/Cla/Com.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.4799947499402371}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes Hölzl, Patrick Massot, Casper Putz\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.finite_dimensional\nimport Mathlib.linear_algebra.nonsingular_inverse\nimport Mathlib.linear_algebra.multilinear\nimport Mathlib.linear_algebra.dual\nimport Mathlib.PostPort\n\nuniverses u_1 u_3 u_4 u_2 u_6 u_5 u_7 w v u \n\nnamespace Mathlib\n\n/-!\n# Linear maps and matrices\n\nThis file defines the maps to send matrices to a linear map,\nand to send linear maps between modules with a finite bases\nto matrices. This defines a linear equivalence between linear maps\nbetween finite-dimensional vector spaces and matrices indexed by\nthe respective bases.\n\nIt also defines the trace of an endomorphism, and the determinant of a family of vectors with\nrespect to some basis.\n\nSome results are proved about the linear map corresponding to a\ndiagonal matrix (`range`, `ker` and `rank`).\n\n## Main definitions\n\nIn the list below, and in all this file, `R` is a commutative ring (semiring\nis sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite\ntypes used for indexing.\n\n * `linear_map.to_matrix`: given bases `v₁ : ι → M₁` and `v₂ : κ → M₂`,\n   the `R`-linear equivalence from `M₁ →ₗ[R] M₂` to `matrix κ ι R`\n * `matrix.to_lin`: the inverse of `linear_map.to_matrix`\n * `linear_map.to_matrix'`: the `R`-linear equivalence from `(n → R) →ₗ[R] (m → R)`\n   to `matrix n m R` (with the standard basis on `n → R` and `m → R`)\n * `matrix.to_lin'`: the inverse of `linear_map.to_matrix'`\n\n * `alg_equiv_matrix`: given a basis indexed by `n`, the `R`-algebra equivalence between\n   `R`-endomorphisms of `M` and `matrix n n R`\n * `matrix.trace`: the trace of a square matrix\n * `linear_map.trace`: the trace of an endomorphism\n * `is_basis.to_matrix`: the matrix whose columns are a given family of vectors in a given basis\n * `is_basis.to_matrix_equiv`: given a basis, the linear equivalence between families of vectors\n   and matrices arising from `is_basis.to_matrix`\n * `is_basis.det`: the determinant of a family of vectors with respect to a basis, as a multilinear\n   map\n\n## Tags\n\nlinear_map, matrix, linear_equiv, diagonal, det, trace\n\n-/\n\nprotected instance matrix.fintype {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq m] [DecidableEq n] (R : Type u_1) [fintype R] : fintype (matrix m n R) :=\n  eq.mpr sorry pi.fintype\n\n/-- `matrix.mul_vec M` is a linear map. -/\ndef matrix.mul_vec_lin {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] (M : matrix m n R) : linear_map R (n → R) (m → R) :=\n  linear_map.mk (matrix.mul_vec M) sorry sorry\n\n@[simp] theorem matrix.mul_vec_lin_apply {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] (M : matrix m n R) (v : n → R) : coe_fn (matrix.mul_vec_lin M) v = matrix.mul_vec M v :=\n  rfl\n\n@[simp] theorem matrix.mul_vec_std_basis {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] (M : matrix m n R) (i : m) (j : n) : matrix.mul_vec M (coe_fn (linear_map.std_basis R (fun (_x : n) => R) j) 1) i = M i j := sorry\n\n/-- Linear maps `(n → R) →ₗ[R] (m → R)` are linearly equivalent to `matrix m n R`. -/\ndef linear_map.to_matrix' {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] : linear_equiv R (linear_map R (n → R) (m → R)) (matrix m n R) :=\n  linear_equiv.mk\n    (fun (f : linear_map R (n → R) (m → R)) (i : m) (j : n) =>\n      coe_fn f (coe_fn (linear_map.std_basis R (fun (ᾰ : n) => R) j) 1) i)\n    sorry sorry matrix.mul_vec_lin sorry sorry\n\n/-- A `matrix m n R` is linearly equivalent to a linear map `(n → R) →ₗ[R] (m → R)`. -/\ndef matrix.to_lin' {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] : linear_equiv R (matrix m n R) (linear_map R (n → R) (m → R)) :=\n  linear_equiv.symm linear_map.to_matrix'\n\n@[simp] theorem linear_map.to_matrix'_symm {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] : linear_equiv.symm linear_map.to_matrix' = matrix.to_lin' :=\n  rfl\n\n@[simp] theorem matrix.to_lin'_symm {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] : linear_equiv.symm matrix.to_lin' = linear_map.to_matrix' :=\n  rfl\n\n@[simp] theorem linear_map.to_matrix'_to_lin' {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] (M : matrix m n R) : coe_fn linear_map.to_matrix' (coe_fn matrix.to_lin' M) = M :=\n  linear_equiv.apply_symm_apply linear_map.to_matrix' M\n\n@[simp] theorem matrix.to_lin'_to_matrix' {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] (f : linear_map R (n → R) (m → R)) : coe_fn matrix.to_lin' (coe_fn linear_map.to_matrix' f) = f :=\n  linear_equiv.apply_symm_apply matrix.to_lin' f\n\n@[simp] theorem linear_map.to_matrix'_apply {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] (f : linear_map R (n → R) (m → R)) (i : m) (j : n) : coe_fn linear_map.to_matrix' f i j = coe_fn f (fun (j' : n) => ite (j' = j) 1 0) i := sorry\n\n@[simp] theorem matrix.to_lin'_apply {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] (M : matrix m n R) (v : n → R) : coe_fn (coe_fn matrix.to_lin' M) v = matrix.mul_vec M v :=\n  rfl\n\n@[simp] theorem matrix.to_lin'_one {R : Type u_1} [comm_ring R] {n : Type u_4} [fintype n] [DecidableEq n] : coe_fn matrix.to_lin' 1 = linear_map.id := sorry\n\n@[simp] theorem linear_map.to_matrix'_id {R : Type u_1} [comm_ring R] {n : Type u_4} [fintype n] [DecidableEq n] : coe_fn linear_map.to_matrix' linear_map.id = 1 := sorry\n\n@[simp] theorem matrix.to_lin'_mul {R : Type u_1} [comm_ring R] {l : Type u_2} {m : Type u_3} {n : Type u_4} [fintype l] [fintype m] [fintype n] [DecidableEq n] [DecidableEq m] (M : matrix l m R) (N : matrix m n R) : coe_fn matrix.to_lin' (matrix.mul M N) = linear_map.comp (coe_fn matrix.to_lin' M) (coe_fn matrix.to_lin' N) := sorry\n\ntheorem linear_map.to_matrix'_comp {R : Type u_1} [comm_ring R] {l : Type u_2} {m : Type u_3} {n : Type u_4} [fintype l] [fintype m] [fintype n] [DecidableEq n] [DecidableEq l] (f : linear_map R (n → R) (m → R)) (g : linear_map R (l → R) (n → R)) : coe_fn linear_map.to_matrix' (linear_map.comp f g) =\n  matrix.mul (coe_fn linear_map.to_matrix' f) (coe_fn linear_map.to_matrix' g) := sorry\n\ntheorem linear_map.to_matrix'_mul {R : Type u_1} [comm_ring R] {m : Type u_3} [fintype m] [DecidableEq m] (f : linear_map R (m → R) (m → R)) (g : linear_map R (m → R) (m → R)) : coe_fn linear_map.to_matrix' (f * g) = matrix.mul (coe_fn linear_map.to_matrix' f) (coe_fn linear_map.to_matrix' g) :=\n  linear_map.to_matrix'_comp f g\n\n/-- Given bases of two modules `M₁` and `M₂` over a commutative ring `R`, we get a linear\nequivalence between linear maps `M₁ →ₗ M₂` and matrices over `R` indexed by the bases. -/\ndef linear_map.to_matrix {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) : linear_equiv R (linear_map R M₁ M₂) (matrix m n R) :=\n  linear_equiv.trans (linear_equiv.arrow_congr (is_basis.equiv_fun hv₁) (is_basis.equiv_fun hv₂)) linear_map.to_matrix'\n\n/-- Given bases of two modules `M₁` and `M₂` over a commutative ring `R`, we get a linear\nequivalence between matrices over `R` indexed by the bases and linear maps `M₁ →ₗ M₂`. -/\ndef matrix.to_lin {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) : linear_equiv R (matrix m n R) (linear_map R M₁ M₂) :=\n  linear_equiv.symm (linear_map.to_matrix hv₁ hv₂)\n\n@[simp] theorem linear_map.to_matrix_symm {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) : linear_equiv.symm (linear_map.to_matrix hv₁ hv₂) = matrix.to_lin hv₁ hv₂ :=\n  rfl\n\n@[simp] theorem matrix.to_lin_symm {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) : linear_equiv.symm (matrix.to_lin hv₁ hv₂) = linear_map.to_matrix hv₁ hv₂ :=\n  rfl\n\n@[simp] theorem matrix.to_lin_to_matrix {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (f : linear_map R M₁ M₂) : coe_fn (matrix.to_lin hv₁ hv₂) (coe_fn (linear_map.to_matrix hv₁ hv₂) f) = f := sorry\n\n@[simp] theorem linear_map.to_matrix_to_lin {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (M : matrix m n R) : coe_fn (linear_map.to_matrix hv₁ hv₂) (coe_fn (matrix.to_lin hv₁ hv₂) M) = M := sorry\n\ntheorem linear_map.to_matrix_apply {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (f : linear_map R M₁ M₂) (i : m) (j : n) : coe_fn (linear_map.to_matrix hv₁ hv₂) f i j = coe_fn (is_basis.equiv_fun hv₂) (coe_fn f (v₁ j)) i := sorry\n\ntheorem linear_map.to_matrix_transpose_apply {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (f : linear_map R M₁ M₂) (j : n) : matrix.transpose (coe_fn (linear_map.to_matrix hv₁ hv₂) f) j = coe_fn (is_basis.equiv_fun hv₂) (coe_fn f (v₁ j)) :=\n  funext fun (i : m) => linear_map.to_matrix_apply hv₁ hv₂ f i j\n\ntheorem linear_map.to_matrix_apply' {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (f : linear_map R M₁ M₂) (i : m) (j : n) : coe_fn (linear_map.to_matrix hv₁ hv₂) f i j = coe_fn (coe_fn (is_basis.repr hv₂) (coe_fn f (v₁ j))) i :=\n  linear_map.to_matrix_apply hv₁ hv₂ f i j\n\ntheorem linear_map.to_matrix_transpose_apply' {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (f : linear_map R M₁ M₂) (j : n) : matrix.transpose (coe_fn (linear_map.to_matrix hv₁ hv₂) f) j = ⇑(coe_fn (is_basis.repr hv₂) (coe_fn f (v₁ j))) :=\n  linear_map.to_matrix_transpose_apply hv₁ hv₂ f j\n\ntheorem matrix.to_lin_apply {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (M : matrix m n R) (v : M₁) : coe_fn (coe_fn (matrix.to_lin hv₁ hv₂) M) v =\n  finset.sum finset.univ fun (j : m) => matrix.mul_vec M (coe_fn (is_basis.equiv_fun hv₁) v) j • v₂ j := sorry\n\n@[simp] theorem matrix.to_lin_self {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) (M : matrix m n R) (i : n) : coe_fn (coe_fn (matrix.to_lin hv₁ hv₂) M) (v₁ i) = finset.sum finset.univ fun (j : m) => M j i • v₂ j := sorry\n\n@[simp] theorem linear_map.to_matrix_id {R : Type u_1} [comm_ring R] {n : Type u_4} [fintype n] [DecidableEq n] {M₁ : Type u_5} [add_comm_group M₁] [module R M₁] {v₁ : n → M₁} (hv₁ : is_basis R v₁) : coe_fn (linear_map.to_matrix hv₁ hv₁) linear_map.id = 1 := sorry\n\n@[simp] theorem matrix.to_lin_one {R : Type u_1} [comm_ring R] {n : Type u_4} [fintype n] [DecidableEq n] {M₁ : Type u_5} [add_comm_group M₁] [module R M₁] {v₁ : n → M₁} (hv₁ : is_basis R v₁) : coe_fn (matrix.to_lin hv₁ hv₁) 1 = linear_map.id := sorry\n\ntheorem linear_map.to_matrix_range {R : Type u_1} [comm_ring R] {m : Type u_3} {n : Type u_4} [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) [DecidableEq M₁] [DecidableEq M₂] (f : linear_map R M₁ M₂) (k : m) (i : n) : coe_fn (linear_map.to_matrix (is_basis.range hv₁) (is_basis.range hv₂)) f\n    { val := v₂ k, property := set.mem_range_self k } { val := v₁ i, property := set.mem_range_self i } =\n  coe_fn (linear_map.to_matrix hv₁ hv₂) f k i := sorry\n\ntheorem linear_map.to_matrix_comp {R : Type u_1} [comm_ring R] {l : Type u_2} {m : Type u_3} {n : Type u_4} [fintype l] [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) {M₃ : Type u_7} [add_comm_group M₃] [module R M₃] {v₃ : l → M₃} (hv₃ : is_basis R v₃) [DecidableEq m] (f : linear_map R M₂ M₃) (g : linear_map R M₁ M₂) : coe_fn (linear_map.to_matrix hv₁ hv₃) (linear_map.comp f g) =\n  matrix.mul (coe_fn (linear_map.to_matrix hv₂ hv₃) f) (coe_fn (linear_map.to_matrix hv₁ hv₂) g) := sorry\n\ntheorem linear_map.to_matrix_mul {R : Type u_1} [comm_ring R] {n : Type u_4} [fintype n] [DecidableEq n] {M₁ : Type u_5} [add_comm_group M₁] [module R M₁] {v₁ : n → M₁} (hv₁ : is_basis R v₁) (f : linear_map R M₁ M₁) (g : linear_map R M₁ M₁) : coe_fn (linear_map.to_matrix hv₁ hv₁) (f * g) =\n  matrix.mul (coe_fn (linear_map.to_matrix hv₁ hv₁) f) (coe_fn (linear_map.to_matrix hv₁ hv₁) g) := sorry\n\ntheorem matrix.to_lin_mul {R : Type u_1} [comm_ring R] {l : Type u_2} {m : Type u_3} {n : Type u_4} [fintype l] [fintype m] [fintype n] [DecidableEq n] {M₁ : Type u_5} {M₂ : Type u_6} [add_comm_group M₁] [add_comm_group M₂] [module R M₁] [module R M₂] {v₁ : n → M₁} (hv₁ : is_basis R v₁) {v₂ : m → M₂} (hv₂ : is_basis R v₂) {M₃ : Type u_7} [add_comm_group M₃] [module R M₃] {v₃ : l → M₃} (hv₃ : is_basis R v₃) [DecidableEq m] (A : matrix l m R) (B : matrix m n R) : coe_fn (matrix.to_lin hv₁ hv₃) (matrix.mul A B) =\n  linear_map.comp (coe_fn (matrix.to_lin hv₂ hv₃) A) (coe_fn (matrix.to_lin hv₁ hv₂) B) := sorry\n\n/-- From a basis `e : ι → M` and a family of vectors `v : ι' → M`, make the matrix whose columns\nare the vectors `v i` written in the basis `e`. -/\ndef is_basis.to_matrix {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) (v : ι' → M) : matrix ι ι' R :=\n  fun (i : ι) (j : ι') => coe_fn (is_basis.equiv_fun he) (v j) i\n\nnamespace is_basis\n\n\ntheorem to_matrix_apply {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) (v : ι' → M) (i : ι) (j : ι') : to_matrix he v i j = coe_fn (equiv_fun he) (v j) i :=\n  rfl\n\ntheorem to_matrix_transpose_apply {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) (v : ι' → M) (j : ι') : matrix.transpose (to_matrix he v) j = ⇑(coe_fn (repr he) (v j)) :=\n  funext fun (_x : ι) => rfl\n\ntheorem to_matrix_eq_to_matrix_constr {ι : Type u_1} [fintype ι] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) [DecidableEq ι] (v : ι → M) : to_matrix he v = coe_fn (linear_map.to_matrix he he) (constr he v) := sorry\n\n@[simp] theorem to_matrix_self {ι : Type u_1} [fintype ι] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) [DecidableEq ι] : to_matrix he e = 1 := sorry\n\ntheorem to_matrix_update {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) (v : ι' → M) (j : ι') [DecidableEq ι'] (x : M) : to_matrix he (function.update v j x) = matrix.update_column (to_matrix he v) j ⇑(coe_fn (repr he) x) := sorry\n\n@[simp] theorem sum_to_matrix_smul_self {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) (v : ι' → M) (j : ι') : (finset.sum finset.univ fun (i : ι) => to_matrix he v i j • e i) = v j := sorry\n\n@[simp] theorem to_lin_to_matrix {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) (v : ι' → M) [DecidableEq ι'] (hv : is_basis R v) : coe_fn (matrix.to_lin hv he) (to_matrix he v) = linear_map.id := sorry\n\n/-- From a basis `e : ι → M`, build a linear equivalence between families of vectors `v : ι → M`,\nand matrices, making the matrix whose columns are the vectors `v i` written in the basis `e`. -/\ndef to_matrix_equiv {ι : Type u_1} [fintype ι] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : ι → M} (he : is_basis R e) : linear_equiv R (ι → M) (matrix ι ι R) :=\n  linear_equiv.mk (to_matrix he) sorry sorry\n    (fun (m : matrix ι ι R) (j : ι) => finset.sum finset.univ fun (i : ι) => m i j • e i) sorry sorry\n\nend is_basis\n\n\n@[simp] theorem is_basis_to_matrix_mul_linear_map_to_matrix {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {N : Type u_5} [add_comm_group N] [module R N] {b' : ι' → M} {c : ι → N} {c' : ι' → N} (hb' : is_basis R b') (hc : is_basis R c) (hc' : is_basis R c') (f : linear_map R M N) [DecidableEq ι'] : matrix.mul (is_basis.to_matrix hc c') (coe_fn (linear_map.to_matrix hb' hc') f) = coe_fn (linear_map.to_matrix hb' hc) f := sorry\n\n@[simp] theorem linear_map_to_matrix_mul_is_basis_to_matrix {ι : Type u_1} {ι' : Type u_2} [fintype ι] [fintype ι'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {N : Type u_5} [add_comm_group N] [module R N] {b : ι → M} {b' : ι' → M} {c' : ι' → N} (hb : is_basis R b) (hb' : is_basis R b') (hc' : is_basis R c') (f : linear_map R M N) [DecidableEq ι] [DecidableEq ι'] : matrix.mul (coe_fn (linear_map.to_matrix hb' hc') f) (is_basis.to_matrix hb' b) = coe_fn (linear_map.to_matrix hb hc') f := sorry\n\ntheorem linear_equiv.is_unit_det {R : Type} [comm_ring R] {M : Type u_1} [add_comm_group M] [module R M] {M' : Type u_2} [add_comm_group M'] [module R M'] {ι : Type u_3} [DecidableEq ι] [fintype ι] {v : ι → M} {v' : ι → M'} (f : linear_equiv R M M') (hv : is_basis R v) (hv' : is_basis R v') : is_unit (matrix.det (coe_fn (linear_map.to_matrix hv hv') ↑f)) := sorry\n\n/-- Builds a linear equivalence from a linear map whose determinant in some bases is a unit. -/\ndef linear_equiv.of_is_unit_det {R : Type} [comm_ring R] {M : Type u_1} [add_comm_group M] [module R M] {M' : Type u_2} [add_comm_group M'] [module R M'] {ι : Type u_3} [DecidableEq ι] [fintype ι] {v : ι → M} {v' : ι → M'} {f : linear_map R M M'} {hv : is_basis R v} {hv' : is_basis R v'} (h : is_unit (matrix.det (coe_fn (linear_map.to_matrix hv hv') f))) : linear_equiv R M M' :=\n  linear_equiv.mk ⇑f sorry sorry ⇑(coe_fn (matrix.to_lin hv' hv) (coe_fn (linear_map.to_matrix hv hv') f⁻¹)) sorry sorry\n\n/-- The determinant of a family of vectors with respect to some basis, as an alternating\nmultilinear map. -/\ndef is_basis.det {R : Type} [comm_ring R] {M : Type u_1} [add_comm_group M] [module R M] {ι : Type u_3} [DecidableEq ι] [fintype ι] {e : ι → M} (he : is_basis R e) : alternating_map R M R ι :=\n  alternating_map.mk (fun (v : (i : ι) → (fun (i : ι) => M) i) => matrix.det (is_basis.to_matrix he v)) sorry sorry sorry\n\ntheorem is_basis.det_apply {R : Type} [comm_ring R] {M : Type u_1} [add_comm_group M] [module R M] {ι : Type u_3} [DecidableEq ι] [fintype ι] {e : ι → M} (he : is_basis R e) (v : ι → M) : coe_fn (is_basis.det he) v = matrix.det (is_basis.to_matrix he v) :=\n  rfl\n\ntheorem is_basis.det_self {R : Type} [comm_ring R] {M : Type u_1} [add_comm_group M] [module R M] {ι : Type u_3} [DecidableEq ι] [fintype ι] {e : ι → M} (he : is_basis R e) : coe_fn (is_basis.det he) e = 1 := sorry\n\ntheorem is_basis.iff_det {R : Type} [comm_ring R] {M : Type u_1} [add_comm_group M] [module R M] {ι : Type u_3} [DecidableEq ι] [fintype ι] {e : ι → M} (he : is_basis R e) {v : ι → M} : is_basis R v ↔ is_unit (coe_fn (is_basis.det he) v) := sorry\n\n@[simp] theorem linear_map.to_matrix_transpose {K : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {ι₁ : Type u_4} {ι₂ : Type u_5} [field K] [add_comm_group V₁] [vector_space K V₁] [add_comm_group V₂] [vector_space K V₂] [fintype ι₁] [fintype ι₂] [DecidableEq ι₁] [DecidableEq ι₂] {B₁ : ι₁ → V₁} (h₁ : is_basis K B₁) {B₂ : ι₂ → V₂} (h₂ : is_basis K B₂) (u : linear_map K V₁ V₂) : coe_fn (linear_map.to_matrix (is_basis.dual_basis_is_basis h₂) (is_basis.dual_basis_is_basis h₁))\n    (coe_fn module.dual.transpose u) =\n  matrix.transpose (coe_fn (linear_map.to_matrix h₁ h₂) u) := sorry\n\ntheorem linear_map.to_matrix_symm_transpose {K : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {ι₁ : Type u_4} {ι₂ : Type u_5} [field K] [add_comm_group V₁] [vector_space K V₁] [add_comm_group V₂] [vector_space K V₂] [fintype ι₁] [fintype ι₂] [DecidableEq ι₁] [DecidableEq ι₂] {B₁ : ι₁ → V₁} (h₁ : is_basis K B₁) {B₂ : ι₂ → V₂} (h₂ : is_basis K B₂) (M : matrix ι₁ ι₂ K) : coe_fn (linear_equiv.symm (linear_map.to_matrix (is_basis.dual_basis_is_basis h₁) (is_basis.dual_basis_is_basis h₂)))\n    (matrix.transpose M) =\n  coe_fn module.dual.transpose (coe_fn (matrix.to_lin h₂ h₁) M) := sorry\n\nnamespace matrix\n\n\n/--\nThe diagonal of a square matrix.\n-/\ndef diag (n : Type u_2) [fintype n] (R : Type v) (M : Type w) [semiring R] [add_comm_monoid M] [semimodule R M] : linear_map R (matrix n n M) (n → M) :=\n  linear_map.mk (fun (A : matrix n n M) (i : n) => A i i) sorry sorry\n\n@[simp] theorem diag_apply {n : Type u_2} [fintype n] {R : Type v} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (A : matrix n n M) (i : n) : coe_fn (diag n R M) A i = A i i :=\n  rfl\n\n@[simp] theorem diag_one {n : Type u_2} [fintype n] {R : Type v} [semiring R] [DecidableEq n] : coe_fn (diag n R R) 1 = fun (i : n) => 1 := sorry\n\n@[simp] theorem diag_transpose {n : Type u_2} [fintype n] {R : Type v} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (A : matrix n n M) : coe_fn (diag n R M) (transpose A) = coe_fn (diag n R M) A :=\n  rfl\n\n/--\nThe trace of a square matrix.\n-/\ndef trace (n : Type u_2) [fintype n] (R : Type v) (M : Type w) [semiring R] [add_comm_monoid M] [semimodule R M] : linear_map R (matrix n n M) M :=\n  linear_map.mk (fun (A : matrix n n M) => finset.sum finset.univ fun (i : n) => coe_fn (diag n R M) A i) sorry sorry\n\n@[simp] theorem trace_diag {n : Type u_2} [fintype n] {R : Type v} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (A : matrix n n M) : coe_fn (trace n R M) A = finset.sum finset.univ fun (i : n) => coe_fn (diag n R M) A i :=\n  rfl\n\n@[simp] theorem trace_one {n : Type u_2} [fintype n] {R : Type v} [semiring R] [DecidableEq n] : coe_fn (trace n R R) 1 = ↑(fintype.card n) := sorry\n\n@[simp] theorem trace_transpose {n : Type u_2} [fintype n] {R : Type v} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (A : matrix n n M) : coe_fn (trace n R M) (transpose A) = coe_fn (trace n R M) A :=\n  rfl\n\n@[simp] theorem trace_transpose_mul {m : Type u_1} [fintype m] {n : Type u_2} [fintype n] {R : Type v} [semiring R] (A : matrix m n R) (B : matrix n m R) : coe_fn (trace n R R) (matrix.mul (transpose A) (transpose B)) = coe_fn (trace m R R) (matrix.mul A B) :=\n  finset.sum_comm\n\ntheorem trace_mul_comm {m : Type u_1} [fintype m] {n : Type u_2} [fintype n] {S : Type v} [comm_ring S] (A : matrix m n S) (B : matrix n m S) : coe_fn (trace n S S) (matrix.mul B A) = coe_fn (trace m S S) (matrix.mul A B) := sorry\n\ntheorem proj_diagonal {n : Type u_1} [fintype n] [DecidableEq n] {R : Type v} [comm_ring R] (i : n) (w : n → R) : linear_map.comp (linear_map.proj i) (coe_fn to_lin' (diagonal w)) = w i • linear_map.proj i := sorry\n\ntheorem diagonal_comp_std_basis {n : Type u_1} [fintype n] [DecidableEq n] {R : Type v} [comm_ring R] (w : n → R) (i : n) : linear_map.comp (coe_fn to_lin' (diagonal w)) (linear_map.std_basis R (fun (ᾰ : n) => R) i) =\n  w i • linear_map.std_basis R (fun (ᾰ : n) => R) i := sorry\n\ntheorem diagonal_to_lin' {n : Type u_1} [fintype n] [DecidableEq n] {R : Type v} [comm_ring R] (w : n → R) : coe_fn to_lin' (diagonal w) = linear_map.pi fun (i : n) => w i • linear_map.proj i := sorry\n\n/-- An invertible matrix yields a linear equivalence from the free module to itself. -/\ndef to_linear_equiv {n : Type u_1} [fintype n] [DecidableEq n] {R : Type v} [comm_ring R] (P : matrix n n R) (h : is_unit P) : linear_equiv R (n → R) (n → R) :=\n  (fun (h' : is_unit (det P)) =>\n      linear_equiv.mk (linear_map.to_fun (coe_fn to_lin' P)) sorry sorry ⇑(coe_fn to_lin' (P⁻¹)) sorry sorry)\n    sorry\n\n@[simp] theorem to_linear_equiv_apply {n : Type u_1} [fintype n] [DecidableEq n] {R : Type v} [comm_ring R] (P : matrix n n R) (h : is_unit P) : ↑(to_linear_equiv P h) = coe_fn to_lin' P :=\n  rfl\n\n@[simp] theorem to_linear_equiv_symm_apply {n : Type u_1} [fintype n] [DecidableEq n] {R : Type v} [comm_ring R] (P : matrix n n R) (h : is_unit P) : ↑(linear_equiv.symm (to_linear_equiv P h)) = coe_fn to_lin' (P⁻¹) :=\n  rfl\n\ntheorem rank_vec_mul_vec {K : Type u} [field K] {m : Type u} {n : Type u} [fintype m] [fintype n] [DecidableEq n] (w : m → K) (v : n → K) : rank (coe_fn to_lin' (vec_mul_vec w v)) ≤ 1 := sorry\n\ntheorem ker_diagonal_to_lin' {m : Type u_1} [fintype m] {K : Type u} [field K] [DecidableEq m] (w : m → K) : linear_map.ker (coe_fn to_lin' (diagonal w)) =\n  supr\n    fun (i : m) =>\n      supr fun (H : i ∈ set_of fun (i : m) => w i = 0) => linear_map.range (linear_map.std_basis K (fun (ᾰ : m) => K) i) := sorry\n\ntheorem range_diagonal {m : Type u_1} [fintype m] {K : Type u} [field K] [DecidableEq m] (w : m → K) : linear_map.range (coe_fn to_lin' (diagonal w)) =\n  supr\n    fun (i : m) =>\n      supr fun (H : i ∈ set_of fun (i : m) => w i ≠ 0) => linear_map.range (linear_map.std_basis K (fun (ᾰ : m) => K) i) := sorry\n\ntheorem rank_diagonal {m : Type u_1} [fintype m] {K : Type u} [field K] [DecidableEq m] [DecidableEq K] (w : m → K) : rank (coe_fn to_lin' (diagonal w)) = ↑(fintype.card (Subtype fun (i : m) => w i ≠ 0)) := sorry\n\nprotected instance finite_dimensional {m : Type u_1} {n : Type u_2} [fintype m] [fintype n] {R : Type v} [field R] : finite_dimensional R (matrix m n R) :=\n  linear_equiv.finite_dimensional (linear_equiv.symm (linear_equiv.uncurry R m n))\n\n/--\nThe dimension of the space of finite dimensional matrices\nis the product of the number of rows and columns.\n-/\n@[simp] theorem findim_matrix {m : Type u_1} {n : Type u_2} [fintype m] [fintype n] {R : Type v} [field R] : finite_dimensional.findim R (matrix m n R) = fintype.card m * fintype.card n := sorry\n\n/-- The natural map that reindexes a matrix's rows and columns with equivalent types is an\nequivalence. -/\ndef reindex {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {m' : Type u_5} {n' : Type u_6} [fintype m'] [fintype n'] {R : Type v} (eₘ : m ≃ m') (eₙ : n ≃ n') : matrix m n R ≃ matrix m' n' R :=\n  equiv.mk (fun (M : matrix m n R) (i : m') (j : n') => M (coe_fn (equiv.symm eₘ) i) (coe_fn (equiv.symm eₙ) j))\n    (fun (M : matrix m' n' R) (i : m) (j : n) => M (coe_fn eₘ i) (coe_fn eₙ j)) sorry sorry\n\n@[simp] theorem reindex_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {m' : Type u_5} {n' : Type u_6} [fintype m'] [fintype n'] {R : Type v} (eₘ : m ≃ m') (eₙ : n ≃ n') (M : matrix m n R) : coe_fn (reindex eₘ eₙ) M = fun (i : m') (j : n') => M (coe_fn (equiv.symm eₘ) i) (coe_fn (equiv.symm eₙ) j) :=\n  rfl\n\n@[simp] theorem reindex_symm_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {m' : Type u_5} {n' : Type u_6} [fintype m'] [fintype n'] {R : Type v} (eₘ : m ≃ m') (eₙ : n ≃ n') (M : matrix m' n' R) : coe_fn (equiv.symm (reindex eₘ eₙ)) M = fun (i : m) (j : n) => M (coe_fn eₘ i) (coe_fn eₙ j) :=\n  rfl\n\n/-- The natural map that reindexes a matrix's rows and columns with equivalent types is a linear\nequivalence. -/\ndef reindex_linear_equiv {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {m' : Type u_5} {n' : Type u_6} [fintype m'] [fintype n'] {R : Type v} [semiring R] (eₘ : m ≃ m') (eₙ : n ≃ n') : linear_equiv R (matrix m n R) (matrix m' n' R) :=\n  linear_equiv.mk (equiv.to_fun (reindex eₘ eₙ)) sorry sorry (equiv.inv_fun (reindex eₘ eₙ)) sorry sorry\n\n@[simp] theorem reindex_linear_equiv_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {m' : Type u_5} {n' : Type u_6} [fintype m'] [fintype n'] {R : Type v} [semiring R] (eₘ : m ≃ m') (eₙ : n ≃ n') (M : matrix m n R) : coe_fn (reindex_linear_equiv eₘ eₙ) M = fun (i : m') (j : n') => M (coe_fn (equiv.symm eₘ) i) (coe_fn (equiv.symm eₙ) j) :=\n  rfl\n\n@[simp] theorem reindex_linear_equiv_symm_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {m' : Type u_5} {n' : Type u_6} [fintype m'] [fintype n'] {R : Type v} [semiring R] (eₘ : m ≃ m') (eₙ : n ≃ n') (M : matrix m' n' R) : coe_fn (linear_equiv.symm (reindex_linear_equiv eₘ eₙ)) M = fun (i : m) (j : n) => M (coe_fn eₘ i) (coe_fn eₙ j) :=\n  rfl\n\ntheorem reindex_mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {l' : Type u_4} {m' : Type u_5} {n' : Type u_6} [fintype l'] [fintype m'] [fintype n'] {R : Type v} [semiring R] (eₘ : m ≃ m') (eₙ : n ≃ n') (eₗ : l ≃ l') (M : matrix m n R) (N : matrix n l R) : matrix.mul (coe_fn (reindex_linear_equiv eₘ eₙ) M) (coe_fn (reindex_linear_equiv eₙ eₗ) N) =\n  coe_fn (reindex_linear_equiv eₘ eₗ) (matrix.mul M N) := sorry\n\n/-- For square matrices, the natural map that reindexes a matrix's rows and columns with equivalent\ntypes is an equivalence of algebras. -/\ndef reindex_alg_equiv {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {R : Type v} [comm_semiring R] [DecidableEq m] [DecidableEq n] (e : m ≃ n) : alg_equiv R (matrix m m R) (matrix n n R) :=\n  alg_equiv.mk (linear_equiv.to_fun (reindex_linear_equiv e e)) (linear_equiv.inv_fun (reindex_linear_equiv e e)) sorry\n    sorry sorry sorry sorry\n\n@[simp] theorem reindex_alg_equiv_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {R : Type v} [comm_semiring R] [DecidableEq m] [DecidableEq n] (e : m ≃ n) (M : matrix m m R) : coe_fn (reindex_alg_equiv e) M = fun (i j : n) => M (coe_fn (equiv.symm e) i) (coe_fn (equiv.symm e) j) :=\n  rfl\n\n@[simp] theorem reindex_alg_equiv_symm_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {R : Type v} [comm_semiring R] [DecidableEq m] [DecidableEq n] (e : m ≃ n) (M : matrix n n R) : coe_fn (alg_equiv.symm (reindex_alg_equiv e)) M = fun (i j : m) => M (coe_fn e i) (coe_fn e j) :=\n  rfl\n\ntheorem reindex_transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {m' : Type u_5} {n' : Type u_6} [fintype m'] [fintype n'] {R : Type v} (eₘ : m ≃ m') (eₙ : n ≃ n') (M : matrix m n R) : transpose (coe_fn (reindex eₘ eₙ) M) = coe_fn (reindex eₙ eₘ) (transpose M) :=\n  rfl\n\n/-- `simp` version of `det_reindex_self`\n\n`det_reindex_self` is not a good simp lemma because `reindex_apply` fires before.\nSo we have this lemma to continue from there. -/\n@[simp] theorem det_reindex_self' {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {R : Type v} [DecidableEq m] [DecidableEq n] [comm_ring R] (e : m ≃ n) (A : matrix m m R) : (det fun (i j : n) => A (coe_fn (equiv.symm e) i) (coe_fn (equiv.symm e) j)) = det A := sorry\n\n/-- Reindexing both indices along the same equivalence preserves the determinant.\n\nFor the `simp` version of this lemma, see `det_reindex_self'`.\n-/\ntheorem det_reindex_self {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {R : Type v} [DecidableEq m] [DecidableEq n] [comm_ring R] (e : m ≃ n) (A : matrix m m R) : det (coe_fn (reindex e e) A) = det A :=\n  det_reindex_self' e A\n\n/-- Reindexing both indices along the same equivalence preserves the determinant.\n\nFor the `simp` version of this lemma, see `det_reindex_self'`.\n-/\ntheorem det_reindex_linear_equiv_self {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {R : Type v} [DecidableEq m] [DecidableEq n] [comm_ring R] (e : m ≃ n) (A : matrix m m R) : det (coe_fn (reindex_linear_equiv e e) A) = det A :=\n  det_reindex_self' e A\n\n/-- Reindexing both indices along the same equivalence preserves the determinant.\n\nFor the `simp` version of this lemma, see `det_reindex_self'`.\n-/\ntheorem det_reindex_alg_equiv {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {R : Type v} [DecidableEq m] [DecidableEq n] [comm_ring R] (e : m ≃ n) (A : matrix m m R) : det (coe_fn (reindex_alg_equiv e) A) = det A :=\n  det_reindex_self' e A\n\nend matrix\n\n\nnamespace linear_map\n\n\n/-- The trace of an endomorphism given a basis. -/\ndef trace_aux (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] {ι : Type w} [DecidableEq ι] [fintype ι] {b : ι → M} (hb : is_basis R b) : linear_map R (linear_map R M M) R :=\n  comp (matrix.trace ι R R) ↑(to_matrix hb hb)\n\n@[simp] theorem trace_aux_def (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] {ι : Type w} [DecidableEq ι] [fintype ι] {b : ι → M} (hb : is_basis R b) (f : linear_map R M M) : coe_fn (trace_aux R hb) f = coe_fn (matrix.trace ι R R) (coe_fn (to_matrix hb hb) f) :=\n  rfl\n\ntheorem trace_aux_eq' (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] {ι : Type w} [DecidableEq ι] [fintype ι] {b : ι → M} (hb : is_basis R b) {κ : Type w} [DecidableEq κ] [fintype κ] {c : κ → M} (hc : is_basis R c) : trace_aux R hb = trace_aux R hc := sorry\n\ntheorem trace_aux_range (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] {ι : Type w} [DecidableEq ι] [fintype ι] {b : ι → M} (hb : is_basis R b) : trace_aux R (is_basis.range hb) = trace_aux R hb := sorry\n\n/-- where `ι` and `κ` can reside in different universes -/\ntheorem trace_aux_eq (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] {ι : Type u_1} [DecidableEq ι] [fintype ι] {b : ι → M} (hb : is_basis R b) {κ : Type u_2} [DecidableEq κ] [fintype κ] {c : κ → M} (hc : is_basis R c) : trace_aux R hb = trace_aux R hc := sorry\n\n/-- Trace of an endomorphism independent of basis. -/\ndef trace (R : Type u) [comm_ring R] (M : Type v) [add_comm_group M] [module R M] : linear_map R (linear_map R M M) R :=\n  dite (∃ (s : finset M), is_basis R fun (x : ↥↑s) => ↑x)\n    (fun (H : ∃ (s : finset M), is_basis R fun (x : ↥↑s) => ↑x) => trace_aux R sorry)\n    fun (H : ¬∃ (s : finset M), is_basis R fun (x : ↥↑s) => ↑x) => 0\n\ntheorem trace_eq_matrix_trace (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] {ι : Type w} [fintype ι] [DecidableEq ι] {b : ι → M} (hb : is_basis R b) (f : linear_map R M M) : coe_fn (trace R M) f = coe_fn (matrix.trace ι R R) (coe_fn (to_matrix hb hb) f) := sorry\n\ntheorem trace_mul_comm (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] (f : linear_map R M M) (g : linear_map R M M) : coe_fn (trace R M) (f * g) = coe_fn (trace R M) (g * f) := sorry\n\nprotected instance finite_dimensional {K : Type u_1} [field K] {V : Type u_2} [add_comm_group V] [vector_space K V] [finite_dimensional K V] {W : Type u_3} [add_comm_group W] [vector_space K W] [finite_dimensional K W] : finite_dimensional K (linear_map K V W) :=\n  Exists.dcases_on (finite_dimensional.exists_is_basis_finset K V)\n    fun (bV : finset V) (hbV : is_basis K coe) =>\n      Exists.dcases_on (finite_dimensional.exists_is_basis_finset K W)\n        fun (bW : finset W) (hbW : is_basis K coe) =>\n          linear_equiv.finite_dimensional (linear_equiv.symm (to_matrix hbV hbW))\n\n/--\nThe dimension of the space of linear transformations is the product of the dimensions of the\ndomain and codomain.\n-/\n@[simp] theorem findim_linear_map {K : Type u_1} [field K] {V : Type u_2} [add_comm_group V] [vector_space K V] [finite_dimensional K V] {W : Type u_3} [add_comm_group W] [vector_space K W] [finite_dimensional K W] : finite_dimensional.findim K (linear_map K V W) = finite_dimensional.findim K V * finite_dimensional.findim K W := sorry\n\nend linear_map\n\n\n/-- The natural equivalence between linear endomorphisms of finite free modules and square matrices\nis compatible with the algebra structures. -/\ndef alg_equiv_matrix' {R : Type v} [comm_ring R] {n : Type u_1} [fintype n] [DecidableEq n] : alg_equiv R (module.End R (n → R)) (matrix n n R) :=\n  alg_equiv.mk (linear_equiv.to_fun linear_map.to_matrix') (linear_equiv.inv_fun linear_map.to_matrix') sorry sorry sorry\n    sorry sorry\n\n/-- A linear equivalence of two modules induces an equivalence of algebras of their\nendomorphisms. -/\ndef linear_equiv.alg_conj {R : Type v} [comm_ring R] {M₁ : Type u_1} {M₂ : Type (max u_2 u_3)} [add_comm_group M₁] [module R M₁] [add_comm_group M₂] [module R M₂] (e : linear_equiv R M₁ M₂) : alg_equiv R (module.End R M₁) (module.End R M₂) :=\n  alg_equiv.mk (linear_equiv.to_fun (linear_equiv.conj e)) (linear_equiv.inv_fun (linear_equiv.conj e)) sorry sorry sorry\n    sorry sorry\n\n/-- A basis of a module induces an equivalence of algebras from the endomorphisms of the module to\nsquare matrices. -/\ndef alg_equiv_matrix {R : Type v} {M : Type w} {n : Type u_1} [fintype n] [comm_ring R] [add_comm_group M] [module R M] [DecidableEq n] {b : n → M} (h : is_basis R b) : alg_equiv R (module.End R M) (matrix n n R) :=\n  alg_equiv.trans (linear_equiv.alg_conj (is_basis.equiv_fun h)) alg_equiv_matrix'\n\n@[simp] theorem matrix.dot_product_std_basis_eq_mul {R : Type v} [semiring R] {n : Type w} [fintype n] [DecidableEq n] (v : n → R) (c : R) (i : n) : matrix.dot_product v (coe_fn (linear_map.std_basis R (fun (_x : n) => R) i) c) = v i * c := sorry\n\n@[simp] theorem matrix.dot_product_std_basis_one {R : Type v} [semiring R] {n : Type w} [fintype n] [DecidableEq n] (v : n → R) (i : n) : matrix.dot_product v (coe_fn (linear_map.std_basis R (fun (_x : n) => R) i) 1) = v i := sorry\n\ntheorem matrix.dot_product_eq {R : Type v} [semiring R] {n : Type w} [fintype n] (v : n → R) (w : n → R) (h : ∀ (u : n → R), matrix.dot_product v u = matrix.dot_product w u) : v = w := sorry\n\ntheorem matrix.dot_product_eq_iff {R : Type v} [semiring R] {n : Type w} [fintype n] {v : n → R} {w : n → R} : (∀ (u : n → R), matrix.dot_product v u = matrix.dot_product w u) ↔ v = w :=\n  { mp := fun (h : ∀ (u : n → R), matrix.dot_product v u = matrix.dot_product w u) => matrix.dot_product_eq v w h,\n    mpr := fun (h : v = w) (_x : n → R) => h ▸ rfl }\n\ntheorem matrix.dot_product_eq_zero {R : Type v} [semiring R] {n : Type w} [fintype n] (v : n → R) (h : ∀ (w : n → R), matrix.dot_product v w = 0) : v = 0 :=\n  matrix.dot_product_eq v 0 fun (u : n → R) => Eq.symm (h u) ▸ Eq.symm (matrix.zero_dot_product u)\n\ntheorem matrix.dot_product_eq_zero_iff {R : Type v} [semiring R] {n : Type w} [fintype n] {v : n → R} : (∀ (w : n → R), matrix.dot_product v w = 0) ↔ v = 0 :=\n  { mp := fun (h : ∀ (w : n → R), matrix.dot_product v w = 0) => matrix.dot_product_eq_zero v h,\n    mpr := fun (h : v = 0) (w : n → R) => Eq.symm h ▸ matrix.zero_dot_product w }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/matrix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.47999473945213567}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n\n! This file was ported from Lean 3 source module data.mv_polynomial.comap\n! leanprover-community/mathlib commit 932872382355f00112641d305ba0619305dc8642\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.MvPolynomial.Rename\n\n/-!\n# `comap` operation on `mv_polynomial`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the `comap` function on `mv_polynomial`.\n\n`mv_polynomial.comap` is a low-tech example of a map of \"algebraic varieties,\" modulo the fact that\n`mathlib` does not yet define varieties.\n\n## Notation\n\nAs in other polynomial files, we typically use the notation:\n\n+ `σ : Type*` (indexing the variables)\n\n+ `R : Type*` `[comm_semiring R]` (the coefficients)\n\n-/\n\n\nnamespace MvPolynomial\n\nvariable {σ : Type _} {τ : Type _} {υ : Type _} {R : Type _} [CommSemiring R]\n\n#print MvPolynomial.comap /-\n/-- Given an algebra hom `f : mv_polynomial σ R →ₐ[R] mv_polynomial τ R`\nand a variable evaluation `v : τ → R`,\n`comap f v` produces a variable evaluation `σ → R`.\n-/\nnoncomputable def comap (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) : (τ → R) → σ → R :=\n  fun x i => aeval x (f (X i))\n#align mv_polynomial.comap MvPolynomial.comap\n-/\n\n/- warning: mv_polynomial.comap_apply -> MvPolynomial.comap_apply is a dubious translation:\nlean 3 declaration is\n  forall {σ : Type.{u1}} {τ : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (x : τ -> R) (i : σ), Eq.{succ u3} R (MvPolynomial.comap.{u1, u2, u3} σ τ R _inst_1 f x i) (coeFn.{max (succ (max u2 u3)) (succ u3), max (succ (max u2 u3)) (succ u3)} (AlgHom.{u3, max u2 u3, u3} R (MvPolynomial.{u2, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) (fun (_x : AlgHom.{u3, max u2 u3, u3} R (MvPolynomial.{u2, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) => (MvPolynomial.{u2, u3} τ R _inst_1) -> R) ([anonymous].{u3, max u2 u3, u3} R (MvPolynomial.{u2, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) (MvPolynomial.aeval.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1) x) (coeFn.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u3)) (succ (max u2 u3))} (AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (fun (_x : AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) => (MvPolynomial.{u1, u3} σ R _inst_1) -> (MvPolynomial.{u2, u3} τ R _inst_1)) ([anonymous].{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) f (MvPolynomial.X.{u3, u1} R σ _inst_1 i)))\nbut is expected to have type\n  forall {σ : Type.{u2}} {τ : Type.{u1}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (x : τ -> R) (i : σ), Eq.{succ u3} R (MvPolynomial.comap.{u2, u1, u3} σ τ R _inst_1 f x i) (FunLike.coe.{max (succ u1) (succ u3), max (succ u1) (succ u3), succ u3} (AlgHom.{u3, max u3 u1, u3} R (MvPolynomial.{u1, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) (MvPolynomial.{u1, u3} τ R _inst_1) (fun (_x : MvPolynomial.{u1, u3} τ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} τ R _inst_1) => R) _x) (SMulHomClass.toFunLike.{max u1 u3, u3, max u1 u3, u3} (AlgHom.{u3, max u3 u1, u3} R (MvPolynomial.{u1, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) R (MvPolynomial.{u1, u3} τ R _inst_1) R (SMulZeroClass.toSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u3} R R (AddMonoid.toZero.{u3} R (AddCommMonoid.toAddMonoid.{u3} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (DistribSMul.toSMulZeroClass.{u3, u3} R R (AddMonoid.toAddZeroClass.{u3} R (AddCommMonoid.toAddMonoid.{u3} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (DistribMulAction.toDistribSMul.{u3, u3} R R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Module.toDistribMulAction.{u3, u3} R R (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (Algebra.toModule.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))))) (DistribMulActionHomClass.toSMulHomClass.{max u1 u3, u3, max u1 u3, u3} (AlgHom.{u3, max u3 u1, u3} R (MvPolynomial.{u1, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) R (MvPolynomial.{u1, u3} τ R _inst_1) R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u3} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u3} R R (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (Algebra.toModule.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u1 u3, u3, max u1 u3, u3} (AlgHom.{u3, max u3 u1, u3} R (MvPolynomial.{u1, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) R (MvPolynomial.{u1, u3} τ R _inst_1) R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u3} R R (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (Algebra.toModule.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u1 u3, u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1) (AlgHom.{u3, max u3 u1, u3} R (MvPolynomial.{u1, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) (AlgHom.algHomClass.{u3, max u1 u3, u3} R (MvPolynomial.{u1, u3} τ R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)))))) (MvPolynomial.aeval.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1) x) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (succ u2) (succ u3), max (succ u1) (succ u3)} (AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (MvPolynomial.{u2, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u2, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u3} σ R _inst_1) => MvPolynomial.{u1, u3} τ R _inst_1) _x) (SMulHomClass.toFunLike.{max (max u2 u1) u3, u3, max u2 u3, max u1 u3} (AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) (SMulZeroClass.toSMul.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (AddMonoid.toZero.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1))))) (Algebra.toModule.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u2 u1) u3, u3, max u2 u3, max u1 u3} (AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)))))) (Module.toDistribMulAction.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1))))) (Algebra.toModule.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u2 u1) u3, u3, max u2 u3, max u1 u3} (AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)))) (Module.toDistribMulAction.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1))))) (Algebra.toModule.{u3, max u2 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u2 u3, max u1 u3, max (max u2 u1) u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.algHomClass.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) f (MvPolynomial.X.{u3, u2} R σ _inst_1 i)))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_apply MvPolynomial.comap_applyₓ'. -/\n@[simp]\ntheorem comap_apply (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (x : τ → R) (i : σ) :\n    comap f x i = aeval x (f (X i)) :=\n  rfl\n#align mv_polynomial.comap_apply MvPolynomial.comap_apply\n\n/- warning: mv_polynomial.comap_id_apply -> MvPolynomial.comap_id_apply is a dubious translation:\nlean 3 declaration is\n  forall {σ : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] (x : σ -> R), Eq.{max (succ u1) (succ u2)} (σ -> R) (MvPolynomial.comap.{u1, u1, u2} σ σ R _inst_1 (AlgHom.id.{u2, max u1 u2} R (MvPolynomial.{u1, u2} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u1, u2} σ R _inst_1) (MvPolynomial.commSemiring.{u2, u1} R σ _inst_1)) (MvPolynomial.algebra.{u2, u2, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u2} R _inst_1))) x) x\nbut is expected to have type\n  forall {σ : Type.{u2}} {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (x : σ -> R), Eq.{max (succ u2) (succ u1)} (σ -> R) (MvPolynomial.comap.{u2, u2, u1} σ σ R _inst_1 (AlgHom.id.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1))) x) x\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_id_apply MvPolynomial.comap_id_applyₓ'. -/\n@[simp]\ntheorem comap_id_apply (x : σ → R) : comap (AlgHom.id R (MvPolynomial σ R)) x = x :=\n  by\n  funext i\n  simp only [comap, AlgHom.id_apply, id.def, aeval_X]\n#align mv_polynomial.comap_id_apply MvPolynomial.comap_id_apply\n\nvariable (σ R)\n\n/- warning: mv_polynomial.comap_id -> MvPolynomial.comap_id is a dubious translation:\nlean 3 declaration is\n  forall (σ : Type.{u1}) (R : Type.{u2}) [_inst_1 : CommSemiring.{u2} R], Eq.{max (succ u1) (succ u2)} ((σ -> R) -> σ -> R) (MvPolynomial.comap.{u1, u1, u2} σ σ R _inst_1 (AlgHom.id.{u2, max u1 u2} R (MvPolynomial.{u1, u2} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u1, u2} σ R _inst_1) (MvPolynomial.commSemiring.{u2, u1} R σ _inst_1)) (MvPolynomial.algebra.{u2, u2, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u2} R _inst_1)))) (id.{max (succ u1) (succ u2)} (σ -> R))\nbut is expected to have type\n  forall (σ : Type.{u2}) (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R], Eq.{max (succ u2) (succ u1)} ((σ -> R) -> σ -> R) (MvPolynomial.comap.{u2, u2, u1} σ σ R _inst_1 (AlgHom.id.{u1, max u1 u2} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)))) (id.{max (succ u2) (succ u1)} (σ -> R))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_id MvPolynomial.comap_idₓ'. -/\ntheorem comap_id : comap (AlgHom.id R (MvPolynomial σ R)) = id :=\n  by\n  funext x\n  exact comap_id_apply x\n#align mv_polynomial.comap_id MvPolynomial.comap_id\n\nvariable {σ R}\n\n/- warning: mv_polynomial.comap_comp_apply -> MvPolynomial.comap_comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {σ : Type.{u1}} {τ : Type.{u2}} {υ : Type.{u3}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u1 u4, max u2 u4} R (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u2 u4, max u3 u4} R (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u3, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (x : υ -> R), Eq.{max (succ u1) (succ u4)} (σ -> R) (MvPolynomial.comap.{u1, u3, u4} σ υ R _inst_1 (AlgHom.comp.{u4, max u1 u4, max u2 u4, max u3 u4} R (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u3, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) g f) x) (MvPolynomial.comap.{u1, u2, u4} σ τ R _inst_1 f (MvPolynomial.comap.{u2, u3, u4} τ υ R _inst_1 g x))\nbut is expected to have type\n  forall {σ : Type.{u3}} {τ : Type.{u2}} {υ : Type.{u1}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u4 u3, max u4 u2} R (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u4 u2, max u4 u1} R (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u1, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (x : υ -> R), Eq.{max (succ u3) (succ u4)} (σ -> R) (MvPolynomial.comap.{u3, u1, u4} σ υ R _inst_1 (AlgHom.comp.{u4, max u4 u3, max u2 u4, max u1 u4} R (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u1, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) g f) x) (MvPolynomial.comap.{u3, u2, u4} σ τ R _inst_1 f (MvPolynomial.comap.{u2, u1, u4} τ υ R _inst_1 g x))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_comp_apply MvPolynomial.comap_comp_applyₓ'. -/\ntheorem comap_comp_apply (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R)\n    (g : MvPolynomial τ R →ₐ[R] MvPolynomial υ R) (x : υ → R) :\n    comap (g.comp f) x = comap f (comap g x) :=\n  by\n  funext i\n  trans aeval x (aeval (fun i => g (X i)) (f (X i)))\n  · apply eval₂_hom_congr rfl rfl\n    rw [AlgHom.comp_apply]\n    suffices g = aeval fun i => g (X i) by rw [← this]\n    exact aeval_unique g\n  · simp only [comap, aeval_eq_eval₂_hom, map_eval₂_hom, AlgHom.comp_apply]\n    refine' eval₂_hom_congr _ rfl rfl\n    ext r\n    apply aeval_C\n#align mv_polynomial.comap_comp_apply MvPolynomial.comap_comp_apply\n\n/- warning: mv_polynomial.comap_comp -> MvPolynomial.comap_comp is a dubious translation:\nlean 3 declaration is\n  forall {σ : Type.{u1}} {τ : Type.{u2}} {υ : Type.{u3}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u1 u4, max u2 u4} R (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u2 u4, max u3 u4} R (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u3, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))), Eq.{max (max (succ u3) (succ u4)) (succ u1) (succ u4)} ((υ -> R) -> σ -> R) (MvPolynomial.comap.{u1, u3, u4} σ υ R _inst_1 (AlgHom.comp.{u4, max u1 u4, max u2 u4, max u3 u4} R (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u3, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) g f)) (Function.comp.{max (succ u3) (succ u4), max (succ u2) (succ u4), max (succ u1) (succ u4)} (υ -> R) (τ -> R) (σ -> R) (MvPolynomial.comap.{u1, u2, u4} σ τ R _inst_1 f) (MvPolynomial.comap.{u2, u3, u4} τ υ R _inst_1 g))\nbut is expected to have type\n  forall {σ : Type.{u3}} {τ : Type.{u2}} {υ : Type.{u1}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u4 u3, max u4 u2} R (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u4 u2, max u4 u1} R (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u1, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))), Eq.{max (max (succ u3) (succ u1)) (succ u4)} ((υ -> R) -> σ -> R) (MvPolynomial.comap.{u3, u1, u4} σ υ R _inst_1 (AlgHom.comp.{u4, max u4 u3, max u2 u4, max u1 u4} R (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.{u1, u4} υ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} σ R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} τ R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} υ R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R υ _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R υ _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) g f)) (Function.comp.{max (succ u4) (succ u1), max (succ u4) (succ u2), max (succ u4) (succ u3)} (υ -> R) (τ -> R) (σ -> R) (MvPolynomial.comap.{u3, u2, u4} σ τ R _inst_1 f) (MvPolynomial.comap.{u2, u1, u4} τ υ R _inst_1 g))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_comp MvPolynomial.comap_compₓ'. -/\ntheorem comap_comp (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R)\n    (g : MvPolynomial τ R →ₐ[R] MvPolynomial υ R) : comap (g.comp f) = comap f ∘ comap g :=\n  by\n  funext x\n  exact comap_comp_apply _ _ _\n#align mv_polynomial.comap_comp MvPolynomial.comap_comp\n\n#print MvPolynomial.comap_eq_id_of_eq_id /-\ntheorem comap_eq_id_of_eq_id (f : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) (hf : ∀ φ, f φ = φ)\n    (x : σ → R) : comap f x = x := by\n  convert comap_id_apply x\n  ext1 φ\n  rw [hf, AlgHom.id_apply]\n#align mv_polynomial.comap_eq_id_of_eq_id MvPolynomial.comap_eq_id_of_eq_id\n-/\n\n/- warning: mv_polynomial.comap_rename -> MvPolynomial.comap_rename is a dubious translation:\nlean 3 declaration is\n  forall {σ : Type.{u1}} {τ : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : σ -> τ) (x : τ -> R), Eq.{max (succ u1) (succ u3)} (σ -> R) (MvPolynomial.comap.{u1, u2, u3} σ τ R _inst_1 (MvPolynomial.rename.{u1, u2, u3} σ τ R _inst_1 f) x) (Function.comp.{succ u1, succ u2, succ u3} σ τ R x f)\nbut is expected to have type\n  forall {σ : Type.{u3}} {τ : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] (f : σ -> τ) (x : τ -> R), Eq.{max (succ u3) (succ u2)} (σ -> R) (MvPolynomial.comap.{u3, u1, u2} σ τ R _inst_1 (MvPolynomial.rename.{u3, u1, u2} σ τ R _inst_1 f) x) (Function.comp.{succ u3, succ u1, succ u2} σ τ R x f)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_rename MvPolynomial.comap_renameₓ'. -/\ntheorem comap_rename (f : σ → τ) (x : τ → R) : comap (rename f) x = x ∘ f :=\n  by\n  ext i\n  simp only [rename_X, comap_apply, aeval_X]\n#align mv_polynomial.comap_rename MvPolynomial.comap_rename\n\n#print MvPolynomial.comapEquiv /-\n/-- If two polynomial types over the same coefficient ring `R` are equivalent,\nthere is a bijection between the types of functions from their variable types to `R`.\n-/\nnoncomputable def comapEquiv (f : MvPolynomial σ R ≃ₐ[R] MvPolynomial τ R) : (τ → R) ≃ (σ → R)\n    where\n  toFun := comap f\n  invFun := comap f.symm\n  left_inv := by\n    intro x\n    rw [← comap_comp_apply]\n    apply comap_eq_id_of_eq_id\n    intro\n    simp only [AlgHom.id_apply, AlgEquiv.comp_symm]\n  right_inv := by\n    intro x\n    rw [← comap_comp_apply]\n    apply comap_eq_id_of_eq_id\n    intro\n    simp only [AlgHom.id_apply, AlgEquiv.symm_comp]\n#align mv_polynomial.comap_equiv MvPolynomial.comapEquiv\n-/\n\n/- warning: mv_polynomial.comap_equiv_coe -> MvPolynomial.comapEquiv_coe is a dubious translation:\nlean 3 declaration is\n  forall {σ : Type.{u1}} {τ : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))), Eq.{max (max (succ u2) (succ u3)) (succ u1) (succ u3)} ((fun (_x : Equiv.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (τ -> R) (σ -> R)) => (τ -> R) -> σ -> R) (MvPolynomial.comapEquiv.{u1, u2, u3} σ τ R _inst_1 f)) (coeFn.{max 1 (max (max (succ u2) (succ u3)) (succ u1) (succ u3)) (max (succ u1) (succ u3)) (succ u2) (succ u3), max (max (succ u2) (succ u3)) (succ u1) (succ u3)} (Equiv.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (τ -> R) (σ -> R)) (fun (_x : Equiv.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (τ -> R) (σ -> R)) => (τ -> R) -> σ -> R) (Equiv.hasCoeToFun.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (τ -> R) (σ -> R)) (MvPolynomial.comapEquiv.{u1, u2, u3} σ τ R _inst_1 f)) (MvPolynomial.comap.{u1, u2, u3} σ τ R _inst_1 ((fun (a : Sort.{max (succ (max u1 u3)) (succ (max u2 u3))}) (b : Sort.{max (succ (max u1 u3)) (succ (max u2 u3))}) [self : HasLiftT.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u3)) (succ (max u2 u3))} a b] => self.0) (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (HasLiftT.mk.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u3)) (succ (max u2 u3))} (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (CoeTCₓ.coe.{max (succ (max u1 u3)) (succ (max u2 u3)), max (succ (max u1 u3)) (succ (max u2 u3))} (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHomClass.coeTC.{u3, max u1 u3, max u2 u3, max (max u1 u3) u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgEquivClass.toAlgHomClass.{max (max u1 u3) u2 u3, u3, max u1 u3, max u2 u3} (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.algEquivClass.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) f))\nbut is expected to have type\n  forall {σ : Type.{u2}} {τ : Type.{u1}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))), Eq.{max (max (succ u2) (succ u1)) (succ u3)} (forall (a : τ -> R), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : τ -> R) => σ -> R) a) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (succ u1) (succ u3), max (succ u2) (succ u3)} (Equiv.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (τ -> R) (σ -> R)) (τ -> R) (fun (_x : τ -> R) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : τ -> R) => σ -> R) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (τ -> R) (σ -> R)) (MvPolynomial.comapEquiv.{u2, u1, u3} σ τ R _inst_1 f)) (MvPolynomial.comap.{u2, u1, u3} σ τ R _inst_1 (AlgHomClass.toAlgHom.{u3, max u2 u3, max u1 u3, max (max u2 u1) u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgEquivClass.toAlgHomClass.{max (max u2 u1) u3, u3, max u2 u3, max u1 u3} (AlgEquiv.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.instAlgEquivClassAlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) f))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_equiv_coe MvPolynomial.comapEquiv_coeₓ'. -/\n@[simp]\ntheorem comapEquiv_coe (f : MvPolynomial σ R ≃ₐ[R] MvPolynomial τ R) :\n    (comapEquiv f : (τ → R) → σ → R) = comap f :=\n  rfl\n#align mv_polynomial.comap_equiv_coe MvPolynomial.comapEquiv_coe\n\n/- warning: mv_polynomial.comap_equiv_symm_coe -> MvPolynomial.comapEquiv_symm_coe is a dubious translation:\nlean 3 declaration is\n  forall {σ : Type.{u1}} {τ : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))), Eq.{max (max (succ u1) (succ u3)) (succ u2) (succ u3)} ((fun (_x : Equiv.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (σ -> R) (τ -> R)) => (σ -> R) -> τ -> R) (Equiv.symm.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (τ -> R) (σ -> R) (MvPolynomial.comapEquiv.{u1, u2, u3} σ τ R _inst_1 f))) (coeFn.{max 1 (max (max (succ u1) (succ u3)) (succ u2) (succ u3)) (max (succ u2) (succ u3)) (succ u1) (succ u3), max (max (succ u1) (succ u3)) (succ u2) (succ u3)} (Equiv.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (σ -> R) (τ -> R)) (fun (_x : Equiv.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (σ -> R) (τ -> R)) => (σ -> R) -> τ -> R) (Equiv.hasCoeToFun.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (σ -> R) (τ -> R)) (Equiv.symm.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (τ -> R) (σ -> R) (MvPolynomial.comapEquiv.{u1, u2, u3} σ τ R _inst_1 f))) (MvPolynomial.comap.{u2, u1, u3} τ σ R _inst_1 ((fun (a : Sort.{max (succ (max u2 u3)) (succ (max u1 u3))}) (b : Sort.{max (succ (max u2 u3)) (succ (max u1 u3))}) [self : HasLiftT.{max (succ (max u2 u3)) (succ (max u1 u3)), max (succ (max u2 u3)) (succ (max u1 u3))} a b] => self.0) (AlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (HasLiftT.mk.{max (succ (max u2 u3)) (succ (max u1 u3)), max (succ (max u2 u3)) (succ (max u1 u3))} (AlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (CoeTCₓ.coe.{max (succ (max u2 u3)) (succ (max u1 u3)), max (succ (max u2 u3)) (succ (max u1 u3))} (AlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHomClass.coeTC.{u3, max u2 u3, max u1 u3, max (max u2 u3) u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgEquivClass.toAlgHomClass.{max (max u2 u3) u1 u3, u3, max u2 u3, max u1 u3} (AlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.algEquivClass.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (AlgEquiv.symm.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.{u2, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) f)))\nbut is expected to have type\n  forall {σ : Type.{u2}} {τ : Type.{u1}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))), Eq.{max (max (succ u2) (succ u1)) (succ u3)} (forall (a : σ -> R), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : σ -> R) => τ -> R) a) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (succ u2) (succ u3), max (succ u1) (succ u3)} (Equiv.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (σ -> R) (τ -> R)) (σ -> R) (fun (_x : σ -> R) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : σ -> R) => τ -> R) _x) (Equiv.instFunLikeEquiv.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (σ -> R) (τ -> R)) (Equiv.symm.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (τ -> R) (σ -> R) (MvPolynomial.comapEquiv.{u2, u1, u3} σ τ R _inst_1 f))) (MvPolynomial.comap.{u1, u2, u3} τ σ R _inst_1 (AlgHomClass.toAlgHom.{u3, max u1 u3, max u2 u3, max (max u2 u1) u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgEquivClass.toAlgHomClass.{max (max u2 u1) u3, u3, max u1 u3, max u2 u3} (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.instAlgEquivClassAlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.{u2, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (AlgEquiv.symm.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.{u1, u3} τ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R σ _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} τ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R τ _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R τ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) f)))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_equiv_symm_coe MvPolynomial.comapEquiv_symm_coeₓ'. -/\n@[simp]\ntheorem comapEquiv_symm_coe (f : MvPolynomial σ R ≃ₐ[R] MvPolynomial τ R) :\n    ((comapEquiv f).symm : (σ → R) → τ → R) = comap f.symm :=\n  rfl\n#align mv_polynomial.comap_equiv_symm_coe MvPolynomial.comapEquiv_symm_coe\n\nend MvPolynomial\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/MvPolynomial/Comap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.47999473776670387}}
{"text": "/-\n  Stalk of rings.\n\n  https://stacks.math.columbia.edu/tag/007L\n  (just says that the category of rings is a type of algebraic structure)\n\n  Author -- Ramon Fernandez Mir\n-/\n\nimport topology.basic\nimport sheaves.stalk\nimport sheaves.presheaf_of_rings\n\nuniverses u v w\n\nopen topological_space\n\nsection stalk_of_rings\n\nvariables {α : Type u} [topological_space α]\nvariables (F : presheaf_of_rings α) (x : α)\n\ndefinition stalk_of_rings := stalk F.to_presheaf x\n\nend stalk_of_rings\n\n-- Stalks are rings.\n\nsection stalk_of_rings_is_ring\n\nparameters {α : Type u} [topological_space α]\nparameters (F : presheaf_of_rings α) (x : α)\n\n-- Add.\n\nprivate def stalk_of_rings_add_aux :\nstalk.elem F.to_presheaf x →\nstalk.elem F.to_presheaf x →\nstalk F.to_presheaf x :=\nλ s t,\n⟦{U := s.U ∩ t.U,\nHxU := ⟨s.HxU, t.HxU⟩,\ns := F.res s.U _ (set.inter_subset_left _ _) s.s +\n     F.res t.U _ (set.inter_subset_right _ _) t.s}⟧\n\ninstance stalk_of_rings_has_add : has_add (stalk_of_rings F x) :=\n{ add := quotient.lift₂ (stalk_of_rings_add_aux) $\n  begin\n    intros a1 a2 b1 b2 H1 H2,\n    let F' := F.to_presheaf,\n    rcases H1 with ⟨U1, ⟨HxU1, ⟨HU1a1U, HU1b1U, HresU1⟩⟩⟩,\n    rcases H2 with ⟨U2, ⟨HxU2, ⟨HU2a2U, HU2b2U, HresU2⟩⟩⟩,\n    apply quotient.sound,\n    use [U1 ∩ U2, ⟨HxU1, HxU2⟩],\n    use [set.inter_subset_inter HU1a1U HU2a2U, set.inter_subset_inter HU1b1U HU2b2U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    have HresU1' :\n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res b1.U U1 HU1b1U) (b1.s)))\n    := by rw HresU1,\n    have HresU2' :\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw ←(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw ←(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw ←(presheaf.Hcomp' F') },\n    rw [HresU1', HresU2'],\n  end }\n\ninstance stalk_of_rings_add_semigroup : add_semigroup (stalk_of_rings F x) :=\n{ add := stalk_of_rings_has_add.add,\n  add_assoc :=\n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W)\n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩],\n    use [set.subset.refl _, HUVWsub],\n    dsimp,\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw ←presheaf.Hcomp' },\n    rw add_assoc,\n  end }\n\ninstance stalk_of_rings_add_comm_semigroup : add_comm_semigroup (stalk_of_rings F x) :=\n{ add_comm :=\n  begin\n    intros a b,\n    refine quotient.induction_on₂ a b _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩,\n    apply quotient.sound,\n    have HUVUV : U ∩ V ⊆ U ∩ V := λ x HxUV, HxUV,\n    have HUVVU : U ∩ V ⊆ V ∩ U := λ x ⟨HxU, HxV⟩, ⟨HxV, HxU⟩,\n    use [U ∩ V, ⟨HxU, HxV⟩, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    rw add_comm,\n  end,\n  ..stalk_of_rings_add_semigroup }\n\n-- Zero.\n\nprivate def stalk_of_rings_zero : stalk_of_rings F x :=\n⟦{U := opens.univ, HxU := trivial, s:= 0}⟧\n\ninstance stalk_of_rings_has_zero : has_zero (stalk_of_rings F x) :=\n{ zero := stalk_of_rings_zero }\n\ninstance stalk_of_rings_add_comm_monoid : add_comm_monoid (stalk_of_rings F x) :=\n{ zero := stalk_of_rings_zero,\n  zero_add :=\n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ opens.univ ∩ U := λ x HxU, ⟨trivial, HxU⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw zero_add,\n    refl,\n  end,\n  add_zero :=\n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ U ∩ opens.univ := λ x HxU, ⟨HxU, trivial⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw ←presheaf.Hcomp' },\n    dsimp,\n    erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw add_zero,\n    refl,\n  end,\n  ..stalk_of_rings_add_comm_semigroup }\n\n-- Neg.\n\nprivate def stalk_sub_aux :\nstalk.elem F.to_presheaf x →\nstalk F.to_presheaf x :=\nλ s, ⟦{U := s.U, HxU := s.HxU, s := -s.s}⟧\n\ninstance stalk_of_rings_has_neg : has_neg (stalk_of_rings F x) :=\n{ neg := quotient.lift stalk_sub_aux $\n  begin\n    intros a b H,\n    rcases H with ⟨U, ⟨HxU, ⟨HUaU, HUbU, HresU⟩⟩⟩,\n    apply quotient.sound,\n    use [U, HxU, HUaU, HUbU],\n    repeat { rw @is_ring_hom.map_neg _ _ _ _ _ (F.res_is_ring_hom _ _ _) },\n    rw HresU,\n  end }\n\ninstance stalk_of_rings_add_comm_group : add_comm_group (stalk_of_rings F x) :=\n{ neg := stalk_of_rings_has_neg.neg,\n  add_left_neg :=\n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUUU : U ⊆ U ∩ U := λ x HxU, ⟨HxU, HxU⟩,\n    have HUuniv : U ⊆ opens.univ := λ x HxU, trivial,\n    use [U, HxU, HUUU, HUuniv],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    erw (is_ring_hom.map_neg ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw add_left_neg,\n    erw (is_ring_hom.map_zero ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n  end,\n  ..stalk_of_rings_add_comm_monoid }\n\n-- Mul.\n\nprivate def stalk_of_rings_mul_aux :\nstalk.elem F.to_presheaf x →\nstalk.elem F.to_presheaf x →\nstalk F.to_presheaf x :=\nλ s t,\n⟦{U := s.U ∩ t.U,\nHxU := ⟨s.HxU, t.HxU⟩,\ns := F.res s.U _ (set.inter_subset_left _ _) s.s *\n     F.res t.U _ (set.inter_subset_right _ _) t.s}⟧\n\ninstance stalk_of_rings_has_mul : has_mul (stalk_of_rings F x) :=\n{ mul := quotient.lift₂ (stalk_of_rings_mul_aux) $\n  begin\n    intros a1 a2 b1 b2 H1 H2,\n    let F' := F.to_presheaf,\n    rcases H1 with ⟨U1, ⟨HxU1, ⟨HU1a1U, HU1b1U, HresU1⟩⟩⟩,\n    rcases H2 with ⟨U2, ⟨HxU2, ⟨HU2a2U, HU2b2U, HresU2⟩⟩⟩,\n    apply quotient.sound,\n    use [U1 ∩ U2, ⟨HxU1, HxU2⟩],\n    use [set.inter_subset_inter HU1a1U HU2a2U, set.inter_subset_inter HU1b1U HU2b2U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    have HresU1' :\n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 ∩ U2) (set.inter_subset_left _ _) ((F'.res b1.U U1 HU1b1U) (b1.s)))\n    := by rw HresU1,\n    have HresU2' :\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 ∩ U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw ←(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw ←(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw ←(presheaf.Hcomp' F') },\n    rw [HresU1', HresU2'],\n  end }\n\ninstance stalk_of_rings_mul_semigroup : semigroup (stalk_of_rings F x) :=\n{ mul := stalk_of_rings_has_mul.mul,\n  mul_assoc :=\n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W)\n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩],\n    use [set.subset.refl _, HUVWsub],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    rw mul_assoc,\n  end }\n\ninstance stalk_of_rings_mul_comm_semigroup : comm_semigroup (stalk_of_rings F x) :=\n{ mul_comm :=\n  begin\n    intros a b,\n    refine quotient.induction_on₂ a b _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩,\n    apply quotient.sound,\n    have HUVUV : U ∩ V ⊆ U ∩ V := λ x HxUV, HxUV,\n    have HUVVU : U ∩ V ⊆ V ∩ U := λ x ⟨HxU, HxV⟩, ⟨HxV, HxU⟩,\n    use [U ∩ V, ⟨HxU, HxV⟩, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    rw mul_comm,\n  end,\n  ..stalk_of_rings_mul_semigroup }\n\n-- One.\n\nprivate def stalk_of_rings_one : stalk_of_rings F x :=\n⟦{U := opens.univ, HxU := trivial, s:= 1}⟧\n\ninstance stalk_of_rings_has_one : has_one (stalk_of_rings F x) :=\n{ one := stalk_of_rings_one }\n\ninstance stalk_of_rings_mul_comm_monoid : comm_monoid (stalk_of_rings F x) :=\n{ one := stalk_of_rings_one,\n  one_mul :=\n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ opens.univ ∩ U := λ x HxU, ⟨trivial, HxU⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    erw (is_ring_hom.map_one ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw one_mul,\n    refl,\n  end,\n  mul_one :=\n  begin\n    intros a,\n    refine quotient.induction_on a _,\n    rintros ⟨U, HxU, sU⟩,\n    apply quotient.sound,\n    have HUsub : U ⊆ U ∩ opens.univ := λ x HxU, ⟨HxU, trivial⟩,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw ←presheaf.Hcomp' },\n    dsimp,\n    erw (is_ring_hom.map_one ((F.to_presheaf).res _ _ _));\n    try { apply_instance },\n    rw mul_one,\n    refl,\n  end,\n  ..stalk_of_rings_mul_comm_semigroup }\n\n-- Ring.\n\ninstance stalk_of_rings_is_comm_ring : comm_ring (stalk_of_rings F x) :=\n{ left_distrib :=\n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ (V ∩ W)\n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨HxU, ⟨HxV, HxW⟩⟩,\n    have HUVWsub2 : U ∩ V ∩ W ⊆ U ∩ V ∩ (U ∩ W)\n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨⟨HxU, HxV⟩, ⟨HxU, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩, HUVWsub, HUVWsub2],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    rw mul_add,\n  end,\n  right_distrib :=\n  begin\n    intros a b c,\n    refine quotient.induction_on₃ a b c _,\n    rintros ⟨U, HxU, sU⟩ ⟨V, HxV, sV⟩ ⟨W, HxW, sW⟩,\n    have HUVWrfl : U ∩ V ∩ W ⊆ U ∩ V ∩ W := λ x Hx, Hx,\n    have HUVWsub : U ∩ V ∩ W ⊆ U ∩ W ∩ (V ∩ W)\n    := λ x ⟨⟨HxU, HxV⟩, HxW⟩, ⟨⟨HxU, HxW⟩, ⟨HxV, HxW⟩⟩,\n    apply quotient.sound,\n    use [U ∩ V ∩ W, ⟨⟨HxU, HxV⟩, HxW⟩, HUVWrfl, HUVWsub],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw ←presheaf.Hcomp' },\n    rw add_mul,\n  end,\n  ..stalk_of_rings_add_comm_group,\n  ..stalk_of_rings_mul_comm_monoid }\n\nend stalk_of_rings_is_ring\n\n-- Stalks are colimits.\n\nsection stalk_colimit\n\nvariables {α : Type u} [topological_space α]\nvariables (F : presheaf_of_rings α) (x : α)\n\nvariables (S : Type w) [comm_ring S] [decidable_eq S]\nvariables (G : Π U, x ∈ U → F.F U → S) [HG : ∀ U, ∀ (h : x ∈ U), is_ring_hom (G U h)]\nvariables (hg : ∀ U V (H : U ⊆ V) r, ∀ (h : x ∈ U), G U h (F.res V U H r) = G V (H h) r)\n\ndef to_stalk (U : opens α) (HxU : x ∈ U) (s : F.F U) : stalk_of_rings F x\n:= ⟦{U := U, HxU := HxU, s := s}⟧\n\ninstance to_stalk.is_ring_hom (U) (HxU) : is_ring_hom (to_stalk F x U HxU) :=\n{ map_one := quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, trivial,\n    begin\n        erw (F.res_is_ring_hom _ _ _).map_one,\n        erw (F.res_is_ring_hom _ _ _).map_one,\n    end⟩,\n  map_add := λ y z, quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, ⟨Hx, Hx⟩,\n    begin\n        erw ←(F.res_is_ring_hom _ _ _).map_add,\n        erw presheaf.Hcomp',\n    end⟩,\n  map_mul := λ y z, quotient.sound $ ⟨U, HxU, set.subset.refl _, λ x Hx, ⟨Hx, Hx⟩,\n    begin\n        erw ←(F.res_is_ring_hom _ _ _).map_mul,\n        erw presheaf.Hcomp',\n    end⟩ }\n\ninclude hg\n\nprotected def to_stalk.rec (y : stalk_of_rings F x) : S :=\nquotient.lift_on' y (λ Us, G Us.1 Us.2 Us.3) $\nλ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩ ⟨W, HxW, HWU, HWV, Hres⟩,\nbegin\n    dsimp,\n    erw [←hg W U HWU s HxW, ←hg W V HWV t HxW, Hres],\nend\n/-\nto_stalk.rec : Π {α : Type u} [_inst_1 : topological_space α] (F : presheaf_of_rings α) (x : α) (S : Type w) [_inst_2 : comm_ring S] [_inst_3 : decidable_eq S] (G : Π (U : opens α), (F.to_presheaf).F U → S), (∀ (U V : opens α) (H : U ⊆ V) (r : (F.to_presheaf).F V), G U ((F.to_presheaf).res V U H r) = G V r) → stalk_of_rings F x → S\n-/\ntheorem to_stalk.rec_to_stalk (U HxU s)\n: to_stalk.rec F x S G hg (to_stalk F x U HxU s) = G U HxU s := rfl\n\ninclude HG\n\ninstance to_stalk.rec_is_ring_hom : is_ring_hom (to_stalk.rec F x S G hg) :=\n{ map_one := (HG opens.univ (set.mem_univ x)).map_one ▸ rfl,\n  map_add := λ y z, quotient.induction_on₂' y z $ λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩,\n    begin\n        have HxUV : x ∈ U ∩ V := ⟨HxU, HxV⟩,\n        show G (U ∩ V) HxUV (_ + _) = G _ _ _ + G _ _ _,\n        rw (HG (U ∩ V) HxUV).map_add,\n        erw ←hg (U ∩ V) U (set.inter_subset_left _ _),\n        erw ←hg (U ∩ V) V (set.inter_subset_right _ _),\n    end,\n  map_mul := λ y z, quotient.induction_on₂' y z $ λ ⟨U, HxU, s⟩ ⟨V, HxV, t⟩,\n    begin\n        have HxUV : x ∈ U ∩ V := ⟨HxU, HxV⟩,\n        show G (U ∩ V) HxUV (_ * _) = G _ _ _ * G _ _ _,\n        rw (HG (U ∩ V) HxUV).map_mul,\n        erw ←hg (U ∩ V) U (set.inter_subset_left _ _),\n        erw ←hg (U ∩ V) V (set.inter_subset_right _ _),\n    end }\n\nend stalk_colimit\n", "meta": {"author": "leanprover-community", "repo": "lean-perfectoid-spaces", "sha": "95a6520ce578b30a80b4c36e36ab2d559a842690", "save_path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces", "path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces/lean-perfectoid-spaces-95a6520ce578b30a80b4c36e36ab2d559a842690/src/sheaves/stalk_of_rings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.63341027059799, "lm_q1q2_score": 0.4799947377667038}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.limits.shapes.normal_mono.basic\nimport category_theory.limits.shapes.finite_products\n\n/-!\n# Normal mono categories with finite products and kernels have all equalizers.\n\nThis, and the dual result, are used in the development of abelian categories.\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nvariables {C : Type*} [category C] [has_zero_morphisms C]\n\nnamespace category_theory.normal_mono_category\n\nvariables [has_finite_products C] [has_kernels C] [normal_mono_category C]\n\n/-- The pullback of two monomorphisms exists. -/\n@[irreducible]\nlemma pullback_of_mono {X Y Z : C} (a : X ⟶ Z) (b : Y ⟶ Z) [mono a] [mono b] :\n  has_limit (cospan a b) :=\nlet ⟨P, f, haf, i⟩ := normal_mono_of_mono a in\nlet ⟨Q, g, hbg, i'⟩ := normal_mono_of_mono b in\nlet ⟨a', ha'⟩ := kernel_fork.is_limit.lift' i (kernel.ι (prod.lift f g)) $\n    calc kernel.ι (prod.lift f g) ≫ f\n        = kernel.ι (prod.lift f g) ≫ prod.lift f g ≫ limits.prod.fst : by rw prod.lift_fst\n    ... = (0 : kernel (prod.lift f g) ⟶ P ⨯ Q) ≫ limits.prod.fst : by rw kernel.condition_assoc\n    ... = 0 : zero_comp in\nlet ⟨b', hb'⟩ := kernel_fork.is_limit.lift' i' (kernel.ι (prod.lift f g)) $\n    calc kernel.ι (prod.lift f g) ≫ g\n        = kernel.ι (prod.lift f g) ≫ (prod.lift f g) ≫ limits.prod.snd : by rw prod.lift_snd\n    ... = (0 : kernel (prod.lift f g) ⟶ P ⨯ Q) ≫ limits.prod.snd : by rw kernel.condition_assoc\n    ... = 0 : zero_comp in\nhas_limit.mk { cone := pullback_cone.mk a' b' $ by { simp at ha' hb', rw [ha', hb'] },\n  is_limit := pullback_cone.is_limit.mk _\n    (λ s, kernel.lift (prod.lift f g) (pullback_cone.snd s ≫ b) $ prod.hom_ext\n      (calc ((pullback_cone.snd s ≫ b) ≫ prod.lift f g) ≫ limits.prod.fst\n            = pullback_cone.snd s ≫ b ≫ f : by simp only [prod.lift_fst, category.assoc]\n        ... = pullback_cone.fst s ≫ a ≫ f : by rw pullback_cone.condition_assoc\n        ... = pullback_cone.fst s ≫ 0 : by rw haf\n        ... = 0 ≫ limits.prod.fst :\n          by rw [comp_zero, zero_comp])\n      (calc ((pullback_cone.snd s ≫ b) ≫ prod.lift f g) ≫ limits.prod.snd\n            = pullback_cone.snd s ≫ b ≫ g : by simp only [prod.lift_snd, category.assoc]\n        ... = pullback_cone.snd s ≫ 0 : by rw hbg\n        ... = 0 ≫ limits.prod.snd :\n          by rw [comp_zero, zero_comp]))\n    (λ s, (cancel_mono a).1 $\n      by { rw kernel_fork.ι_of_ι at ha', simp [ha', pullback_cone.condition s] })\n    (λ s, (cancel_mono b).1 $\n      by { rw kernel_fork.ι_of_ι at hb', simp [hb'] })\n    (λ s m h₁ h₂, (cancel_mono (kernel.ι (prod.lift f g))).1 $ calc m ≫ kernel.ι (prod.lift f g)\n          = m ≫ a' ≫ a : by { congr, exact ha'.symm }\n      ... = pullback_cone.fst s ≫ a : by rw [←category.assoc, h₁]\n      ... = pullback_cone.snd s ≫ b : pullback_cone.condition s\n      ... = kernel.lift (prod.lift f g) (pullback_cone.snd s ≫ b) _ ≫ kernel.ι (prod.lift f g) :\n        by rw kernel.lift_ι) }\n\nsection\n\nlocal attribute [instance] pullback_of_mono\n\n/-- The pullback of `(𝟙 X, f)` and `(𝟙 X, g)` -/\nprivate abbreviation P {X Y : C} (f g : X ⟶ Y)\n  [mono (prod.lift (𝟙 X) f)] [mono (prod.lift (𝟙 X) g)] : C :=\npullback (prod.lift (𝟙 X) f) (prod.lift (𝟙 X) g)\n\n/-- The equalizer of `f` and `g` exists. -/\n@[irreducible]\nlemma has_limit_parallel_pair {X Y : C} (f g : X ⟶ Y) : has_limit (parallel_pair f g) :=\nhave huv : (pullback.fst : P f g ⟶ X) = pullback.snd, from\n  calc (pullback.fst : P f g ⟶ X) = pullback.fst ≫ 𝟙 _ : eq.symm $ category.comp_id _\n    ... = pullback.fst ≫ prod.lift (𝟙 X) f ≫ limits.prod.fst : by rw prod.lift_fst\n    ... = pullback.snd ≫ prod.lift (𝟙 X) g ≫ limits.prod.fst : by rw pullback.condition_assoc\n    ... = pullback.snd : by rw [prod.lift_fst, category.comp_id],\nhave hvu : (pullback.fst : P f g ⟶ X) ≫ f = pullback.snd ≫ g, from\n  calc (pullback.fst : P f g ⟶ X) ≫ f\n        = pullback.fst ≫ prod.lift (𝟙 X) f ≫ limits.prod.snd : by rw prod.lift_snd\n    ... = pullback.snd ≫ prod.lift (𝟙 X) g ≫ limits.prod.snd : by rw pullback.condition_assoc\n    ... = pullback.snd ≫ g : by rw prod.lift_snd,\nhave huu : (pullback.fst : P f g ⟶ X) ≫ f = pullback.fst ≫ g, by rw [hvu, ←huv],\nhas_limit.mk { cone := fork.of_ι pullback.fst huu,\n  is_limit := fork.is_limit.mk _\n  (λ s, pullback.lift (fork.ι s) (fork.ι s) $ prod.hom_ext\n    (by simp only [prod.lift_fst, category.assoc])\n    (by simp only [fork.app_zero_right, fork.app_zero_left, prod.lift_snd, category.assoc]))\n  (λ s, by simp only [fork.ι_of_ι, pullback.lift_fst])\n  (λ s m h, pullback.hom_ext\n    (by simpa only [pullback.lift_fst] using h walking_parallel_pair.zero)\n    (by simpa only [huv.symm, pullback.lift_fst] using h walking_parallel_pair.zero)) }\n\nend\n\nsection\nlocal attribute [instance] has_limit_parallel_pair\n\n/-- A `normal_mono_category` category with finite products and kernels has all equalizers. -/\n@[priority 100] instance has_equalizers : has_equalizers C :=\nhas_equalizers_of_has_limit_parallel_pair _\n\nend\n\n/-- If a zero morphism is a cokernel of `f`, then `f` is an epimorphism. -/\nlemma epi_of_zero_cokernel {X Y : C} (f : X ⟶ Y) (Z : C)\n  (l : is_colimit (cokernel_cofork.of_π (0 : Y ⟶ Z) (show f ≫ 0 = 0, by simp))) : epi f :=\n⟨λ P u v huv,\n begin\n  obtain ⟨W, w, hw, hl⟩ := normal_mono_of_mono (equalizer.ι u v),\n  obtain ⟨m, hm⟩ := equalizer.lift' f huv,\n  have hwf : f ≫ w = 0,\n  { rw [←hm, category.assoc, hw, comp_zero] },\n  obtain ⟨n, hn⟩ := cokernel_cofork.is_colimit.desc' l _ hwf,\n  rw [cofork.π_of_π, zero_comp] at hn,\n  haveI : is_iso (equalizer.ι u v),\n  { apply is_iso_limit_cone_parallel_pair_of_eq hn.symm hl },\n  apply (cancel_epi (equalizer.ι u v)).1,\n  exact equalizer.condition _ _\n end⟩\n\nsection\nvariables [has_zero_object C]\nopen_locale zero_object\n\n/-- If `f ≫ g = 0` implies `g = 0` for all `g`, then `g` is a monomorphism. -/\nlemma epi_of_zero_cancel {X Y : C} (f : X ⟶ Y)\n  (hf : ∀ (Z : C) (g : Y ⟶ Z) (hgf : f ≫ g = 0), g = 0) : epi f :=\nepi_of_zero_cokernel f 0 $ zero_cokernel_of_zero_cancel f hf\n\nend\n\nend category_theory.normal_mono_category\n\nnamespace category_theory.normal_epi_category\n\nvariables [has_finite_coproducts C] [has_cokernels C] [normal_epi_category C]\n\n/-- The pushout of two epimorphisms exists. -/\n@[irreducible]\nlemma pushout_of_epi {X Y Z : C} (a : X ⟶ Y) (b : X ⟶ Z) [epi a] [epi b] :\n  has_colimit (span a b) :=\nlet ⟨P, f, hfa, i⟩ := normal_epi_of_epi a in\nlet ⟨Q, g, hgb, i'⟩ := normal_epi_of_epi b in\nlet ⟨a', ha'⟩ := cokernel_cofork.is_colimit.desc' i (cokernel.π (coprod.desc f g)) $\n  calc f ≫ cokernel.π (coprod.desc f g)\n      = coprod.inl ≫ coprod.desc f g ≫ cokernel.π (coprod.desc f g) : by rw coprod.inl_desc_assoc\n  ... = coprod.inl ≫ (0 : P ⨿ Q ⟶ cokernel (coprod.desc f g)) : by rw cokernel.condition\n  ... = 0 : has_zero_morphisms.comp_zero _ _ in\nlet ⟨b', hb'⟩ := cokernel_cofork.is_colimit.desc' i' (cokernel.π (coprod.desc f g)) $\n  calc g ≫ cokernel.π (coprod.desc f g)\n      = coprod.inr ≫ coprod.desc f g ≫ cokernel.π (coprod.desc f g) : by rw coprod.inr_desc_assoc\n  ... = coprod.inr ≫ (0 : P ⨿ Q ⟶ cokernel (coprod.desc f g)) :  by rw cokernel.condition\n  ... = 0 : has_zero_morphisms.comp_zero _ _ in\nhas_colimit.mk\n{ cocone := pushout_cocone.mk a' b' $ by { simp only [cofork.π_of_π] at ha' hb', rw [ha', hb'] },\n  is_colimit := pushout_cocone.is_colimit.mk _\n  (λ s, cokernel.desc (coprod.desc f g) (b ≫ pushout_cocone.inr s) $ coprod.hom_ext\n    (calc coprod.inl ≫ coprod.desc f g ≫ b ≫ pushout_cocone.inr s\n          = f ≫ b ≫ pushout_cocone.inr s : by rw coprod.inl_desc_assoc\n      ... = f ≫ a ≫ pushout_cocone.inl s : by rw pushout_cocone.condition\n      ... = 0 ≫ pushout_cocone.inl s : by rw reassoc_of hfa\n      ... = coprod.inl ≫ 0 : by rw [comp_zero, zero_comp])\n    (calc coprod.inr ≫ coprod.desc f g ≫ b ≫ pushout_cocone.inr s\n          = g ≫ b ≫ pushout_cocone.inr s : by rw coprod.inr_desc_assoc\n      ... = 0 ≫ pushout_cocone.inr s : by rw reassoc_of hgb\n      ... = coprod.inr ≫ 0 : by rw [comp_zero, zero_comp]))\n  (λ s, (cancel_epi a).1 $\n    by { rw cokernel_cofork.π_of_π at ha', simp [reassoc_of ha', pushout_cocone.condition s] })\n  (λ s, (cancel_epi b).1 $ by { rw cokernel_cofork.π_of_π at hb', simp [reassoc_of hb'] })\n  (λ s m h₁ h₂, (cancel_epi (cokernel.π (coprod.desc f g))).1 $\n  calc cokernel.π (coprod.desc f g) ≫ m\n        = (a ≫ a') ≫ m : by { congr, exact ha'.symm }\n    ... = a ≫ pushout_cocone.inl s : by rw [category.assoc, h₁]\n    ... = b ≫ pushout_cocone.inr s : pushout_cocone.condition s\n    ... = cokernel.π (coprod.desc f g) ≫\n            cokernel.desc (coprod.desc f g) (b ≫ pushout_cocone.inr s) _ :\n      by rw cokernel.π_desc) }\n\n\n\nsection\nlocal attribute [instance] pushout_of_epi\n\n/-- The pushout of `(𝟙 Y, f)` and `(𝟙 Y, g)`. -/\nprivate abbreviation Q {X Y : C} (f g : X ⟶ Y)\n  [epi (coprod.desc (𝟙 Y) f)] [epi (coprod.desc (𝟙 Y) g)] : C :=\npushout (coprod.desc (𝟙 Y) f) (coprod.desc (𝟙 Y) g)\n\n/-- The coequalizer of `f` and `g` exists. -/\n@[irreducible]\nlemma has_colimit_parallel_pair {X Y : C} (f g : X ⟶ Y) : has_colimit (parallel_pair f g) :=\nhave huv : (pushout.inl : Y ⟶ Q f g) = pushout.inr, from\n  calc (pushout.inl : Y ⟶ Q f g) = 𝟙 _ ≫ pushout.inl : eq.symm $ category.id_comp _\n    ... = (coprod.inl ≫ coprod.desc (𝟙 Y) f) ≫ pushout.inl : by rw coprod.inl_desc\n    ... = (coprod.inl ≫ coprod.desc (𝟙 Y) g) ≫ pushout.inr :\n      by simp only [category.assoc, pushout.condition]\n    ... = pushout.inr : by rw [coprod.inl_desc, category.id_comp],\nhave hvu : f ≫ (pushout.inl : Y ⟶ Q f g) = g ≫ pushout.inr, from\n  calc f ≫ (pushout.inl : Y ⟶ Q f g)\n        = (coprod.inr ≫ coprod.desc (𝟙 Y) f) ≫ pushout.inl : by rw coprod.inr_desc\n    ... = (coprod.inr ≫ coprod.desc (𝟙 Y) g) ≫ pushout.inr :\n      by simp only [category.assoc, pushout.condition]\n    ... = g ≫ pushout.inr : by rw coprod.inr_desc,\nhave huu : f ≫ (pushout.inl : Y ⟶ Q f g) = g ≫ pushout.inl, by rw [hvu, huv],\nhas_colimit.mk { cocone := cofork.of_π pushout.inl huu,\n  is_colimit := cofork.is_colimit.mk _\n  (λ s, pushout.desc (cofork.π s) (cofork.π s) $ coprod.hom_ext\n    (by simp only [coprod.inl_desc_assoc])\n    (by simp only [cofork.right_app_one, coprod.inr_desc_assoc, cofork.left_app_one]))\n  (λ s, by simp only [pushout.inl_desc, cofork.π_of_π])\n  (λ s m h, pushout.hom_ext\n    (by simpa only [pushout.inl_desc] using h walking_parallel_pair.one)\n    (by simpa only [huv.symm, pushout.inl_desc] using h walking_parallel_pair.one)) }\n\nend\n\nsection\nlocal attribute [instance] has_colimit_parallel_pair\n\n/-- A `normal_epi_category` category with finite coproducts and cokernels has all coequalizers. -/\n@[priority 100] instance has_coequalizers : has_coequalizers C :=\nhas_coequalizers_of_has_colimit_parallel_pair _\n\nend\n\n/-- If a zero morphism is a kernel of `f`, then `f` is a monomorphism. -/\nlemma mono_of_zero_kernel {X Y : C} (f : X ⟶ Y) (Z : C)\n  (l : is_limit (kernel_fork.of_ι (0 : Z ⟶ X) (show 0 ≫ f = 0, by simp))) : mono f :=\n⟨λ P u v huv,\n begin\n  obtain ⟨W, w, hw, hl⟩ := normal_epi_of_epi (coequalizer.π u v),\n  obtain ⟨m, hm⟩ := coequalizer.desc' f huv,\n  have hwf : w ≫ f = 0,\n  { rw [←hm, reassoc_of hw, zero_comp] },\n  obtain ⟨n, hn⟩ := kernel_fork.is_limit.lift' l _ hwf,\n  rw [fork.ι_of_ι, has_zero_morphisms.comp_zero] at hn,\n  haveI : is_iso (coequalizer.π u v),\n  { apply is_iso_colimit_cocone_parallel_pair_of_eq hn.symm hl },\n  apply (cancel_mono (coequalizer.π u v)).1,\n  exact coequalizer.condition _ _\n end⟩\n\nsection\nvariables [has_zero_object C]\nopen_locale zero_object\n\n/-- If `g ≫ f = 0` implies `g = 0` for all `g`, then `f` is a monomorphism. -/\nlemma mono_of_cancel_zero {X Y : C} (f : X ⟶ Y)\n  (hf : ∀ (Z : C) (g : Z ⟶ X) (hgf : g ≫ f = 0), g = 0) : mono f :=\nmono_of_zero_kernel f 0 $ zero_kernel_of_cancel_zero f hf\n\nend\n\nend category_theory.normal_epi_category\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/limits/shapes/normal_mono/equalizers.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746407, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.47999473252265323}}
{"text": "import data.equiv.basic\n\nuniverses u v w\nvariables {α : Sort u} {β : Sort v} {γ : Sort w}\n\n-- A constructive version of `bijective`.\nstructure Is_equiv (f : α → β) :=\n(e : α ≃ β)\n(h : f = e)\n\ninstance (f : α → β) : subsingleton (Is_equiv f) :=\n⟨begin\n  intros e e',\n  cases e with ee eh, cases e' with e'e e'h,\n  have : ee = e'e, from equiv.coe_fn_injective (by cc),\n  cc\nend⟩\n\nlemma Is_equiv.bijective {f : α → β} (e : Is_equiv f) : function.bijective f :=\nby rw e.h; exact e.e.bijective\n\nlemma Is_equiv.cancel_left {f : α → β} (e : Is_equiv f) {a : α} :\n  e.e.inv_fun (f a) = a :=\nby rw [e.h] { occs := occurrences.pos [2] }; exact e.e.left_inv a\n\nlemma Is_equiv.cancel_right {f : α → β} (e : Is_equiv f) {b : β} :\n  f (e.e.inv_fun b) = b :=\nby rw [e.h] { occs := occurrences.pos [1] }; exact e.e.right_inv b\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/data/is_equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4799947325226532}}
{"text": "/-\nCopyright (c) 2021 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Aaron Anderson\n\n! This file was ported from Lean 3 source module data.finsupp.order\n! leanprover-community/mathlib commit fac369018417f980cec5fcdafc766a69f88d8cfe\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finsupp.Defs\n\n/-!\n# Pointwise order on finitely supported functions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file lifts order structures on `α` to `ι →₀ α`.\n\n## Main declarations\n\n* `finsupp.order_embedding_to_fun`: The order embedding from finitely supported functions to\n  functions.\n* `finsupp.order_iso_multiset`: The order isomorphism between `ℕ`-valued finitely supported\n  functions and multisets.\n-/\n\n\nnoncomputable section\n\nopen BigOperators\n\nopen Finset\n\nvariable {ι α : Type _}\n\nnamespace Finsupp\n\n/-! ### Order structures -/\n\n\nsection Zero\n\nvariable [Zero α]\n\nsection LE\n\nvariable [LE α]\n\ninstance : LE (ι →₀ α) :=\n  ⟨fun f g => ∀ i, f i ≤ g i⟩\n\n/- warning: finsupp.le_def -> Finsupp.le_def is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : LE.{u2} α] {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2) f g) (forall (i : ι), LE.le.{u2} α _inst_2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) g i))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : LE.{u1} α] {f : Finsupp.{u2, u1} ι α _inst_1} {g : Finsupp.{u2, u1} ι α _inst_1}, Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α _inst_1) (Finsupp.instLEFinsupp.{u2, u1} ι α _inst_1 _inst_2) f g) (forall (i : ι), LE.le.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) _inst_2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α _inst_1) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α _inst_1) g i))\nCase conversion may be inaccurate. Consider using '#align finsupp.le_def Finsupp.le_defₓ'. -/\ntheorem le_def {f g : ι →₀ α} : f ≤ g ↔ ∀ i, f i ≤ g i :=\n  Iff.rfl\n#align finsupp.le_def Finsupp.le_def\n\n#print Finsupp.orderEmbeddingToFun /-\n/-- The order on `finsupp`s over a partial order embeds into the order on functions -/\ndef orderEmbeddingToFun : (ι →₀ α) ↪o (ι → α)\n    where\n  toFun f := f\n  inj' f g h :=\n    Finsupp.ext fun i => by\n      dsimp at h\n      rw [h]\n  map_rel_iff' a b := (@le_def _ _ _ _ a b).symm\n#align finsupp.order_embedding_to_fun Finsupp.orderEmbeddingToFun\n-/\n\n/- warning: finsupp.order_embedding_to_fun_apply -> Finsupp.orderEmbeddingToFun_apply is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : LE.{u2} α] {f : Finsupp.{u1, u2} ι α _inst_1} {i : ι}, Eq.{succ u2} α (coeFn.{succ (max u1 u2), succ (max u1 u2)} (OrderEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2) (Pi.hasLe.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2))) (fun (_x : RelEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2)) (LE.le.{max u1 u2} (ι -> α) (Pi.hasLe.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)))) => (Finsupp.{u1, u2} ι α _inst_1) -> ι -> α) (RelEmbedding.hasCoeToFun.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.hasLe.{u1, u2} ι α _inst_1 _inst_2)) (LE.le.{max u1 u2} (ι -> α) (Pi.hasLe.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)))) (Finsupp.orderEmbeddingToFun.{u1, u2} ι α _inst_1 _inst_2) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i)\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : LE.{u1} α] {f : Finsupp.{u2, u1} ι α _inst_1} {i : ι}, Eq.{succ u1} α (FunLike.coe.{succ (max u1 u2), succ (max u1 u2), succ (max u1 u2)} (Function.Embedding.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α)) (Finsupp.{u2, u1} ι α _inst_1) (fun (_x : Finsupp.{u2, u1} ι α _inst_1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Finsupp.{u2, u1} ι α _inst_1) => ι -> α) _x) (EmbeddingLike.toFunLike.{succ (max u1 u2), succ (max u1 u2), succ (max u1 u2)} (Function.Embedding.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α)) (Finsupp.{u2, u1} ι α _inst_1) (ι -> α) (Function.instEmbeddingLikeEmbedding.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α))) (RelEmbedding.toEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Finsupp.{u2, u1} ι α _inst_1) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Finsupp.{u2, u1} ι α _inst_1) => LE.le.{max u1 u2} (Finsupp.{u2, u1} ι α _inst_1) (Finsupp.instLEFinsupp.{u2, u1} ι α _inst_1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : ι -> α) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : ι -> α) => LE.le.{max u2 u1} (ι -> α) (Pi.hasLe.{u2, u1} ι (fun (a._@.Mathlib.Data.Finsupp.Order._hyg.129 : ι) => α) (fun (i : ι) => _inst_2)) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Finsupp.orderEmbeddingToFun.{u2, u1} ι α _inst_1 _inst_2)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α _inst_1) f i)\nCase conversion may be inaccurate. Consider using '#align finsupp.order_embedding_to_fun_apply Finsupp.orderEmbeddingToFun_applyₓ'. -/\n@[simp]\ntheorem orderEmbeddingToFun_apply {f : ι →₀ α} {i : ι} : orderEmbeddingToFun f i = f i :=\n  rfl\n#align finsupp.order_embedding_to_fun_apply Finsupp.orderEmbeddingToFun_apply\n\nend LE\n\nsection Preorder\n\nvariable [Preorder α]\n\ninstance : Preorder (ι →₀ α) :=\n  { Finsupp.hasLe with\n    le_refl := fun f i => le_rfl\n    le_trans := fun f g h hfg hgh i => (hfg i).trans (hgh i) }\n\n/- warning: finsupp.monotone_to_fun -> Finsupp.monotone_toFun is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : Preorder.{u2} α], Monotone.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (ι -> α) (Finsupp.preorder.{u1, u2} ι α _inst_1 _inst_2) (Pi.preorder.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)) (Finsupp.toFun.{u1, u2} ι α _inst_1)\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : Zero.{u1} α] [_inst_2 : Preorder.{u1} α], Monotone.{max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α _inst_1) (ι -> α) (Finsupp.preorder.{u2, u1} ι α _inst_1 _inst_2) (Pi.preorder.{u2, u1} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2)) (Finsupp.toFun.{u2, u1} ι α _inst_1)\nCase conversion may be inaccurate. Consider using '#align finsupp.monotone_to_fun Finsupp.monotone_toFunₓ'. -/\ntheorem monotone_toFun : Monotone (Finsupp.toFun : (ι →₀ α) → ι → α) := fun f g h a => le_def.1 h a\n#align finsupp.monotone_to_fun Finsupp.monotone_toFun\n\nend Preorder\n\ninstance [PartialOrder α] : PartialOrder (ι →₀ α) :=\n  { Finsupp.preorder with le_antisymm := fun f g hfg hgf => ext fun i => (hfg i).antisymm (hgf i) }\n\ninstance [SemilatticeInf α] : SemilatticeInf (ι →₀ α) :=\n  { Finsupp.partialOrder with\n    inf := zipWith (· ⊓ ·) inf_idem\n    inf_le_left := fun f g i => inf_le_left\n    inf_le_right := fun f g i => inf_le_right\n    le_inf := fun f g i h1 h2 s => le_inf (h1 s) (h2 s) }\n\n/- warning: finsupp.inf_apply -> Finsupp.inf_apply is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeInf.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeInf.toHasInf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeInf.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Inf.inf.{u2} α (SemilatticeInf.toHasInf.{u2} α _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) g i))\nbut is expected to have type\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeInf.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeInf.toInf.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeInf.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Inf.inf.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (SemilatticeInf.toInf.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) f i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) g i))\nCase conversion may be inaccurate. Consider using '#align finsupp.inf_apply Finsupp.inf_applyₓ'. -/\n@[simp]\ntheorem inf_apply [SemilatticeInf α] {i : ι} {f g : ι →₀ α} : (f ⊓ g) i = f i ⊓ g i :=\n  rfl\n#align finsupp.inf_apply Finsupp.inf_apply\n\ninstance [SemilatticeSup α] : SemilatticeSup (ι →₀ α) :=\n  { Finsupp.partialOrder with\n    sup := zipWith (· ⊔ ·) sup_idem\n    le_sup_left := fun f g i => le_sup_left\n    le_sup_right := fun f g i => le_sup_right\n    sup_le := fun f g h hf hg i => sup_le (hf i) (hg i) }\n\n/- warning: finsupp.sup_apply -> Finsupp.sup_apply is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeSup.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeSup.toHasSup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeSup.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Sup.sup.{u2} α (SemilatticeSup.toHasSup.{u2} α _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α _inst_1) (fun (_x : Finsupp.{u1, u2} ι α _inst_1) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α _inst_1) g i))\nbut is expected to have type\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : Zero.{u2} α] [_inst_2 : SemilatticeSup.{u2} α] {i : ι} {f : Finsupp.{u1, u2} ι α _inst_1} {g : Finsupp.{u1, u2} ι α _inst_1}, Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (SemilatticeSup.toSup.{max u1 u2} (Finsupp.{u1, u2} ι α _inst_1) (Finsupp.semilatticeSup.{u1, u2} ι α _inst_1 _inst_2)) f g) i) (Sup.sup.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (SemilatticeSup.toSup.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) f i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} ι α _inst_1) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u1, u2} ι α _inst_1) g i))\nCase conversion may be inaccurate. Consider using '#align finsupp.sup_apply Finsupp.sup_applyₓ'. -/\n@[simp]\ntheorem sup_apply [SemilatticeSup α] {i : ι} {f g : ι →₀ α} : (f ⊔ g) i = f i ⊔ g i :=\n  rfl\n#align finsupp.sup_apply Finsupp.sup_apply\n\n#print Finsupp.lattice /-\ninstance lattice [Lattice α] : Lattice (ι →₀ α) :=\n  { Finsupp.semilatticeInf, Finsupp.semilatticeSup with }\n#align finsupp.lattice Finsupp.lattice\n-/\n\nend Zero\n\n/-! ### Algebraic order structures -/\n\n\ninstance [OrderedAddCommMonoid α] : OrderedAddCommMonoid (ι →₀ α) :=\n  { Finsupp.addCommMonoid, Finsupp.partialOrder with\n    add_le_add_left := fun a b h c s => add_le_add_left (h s) (c s) }\n\ninstance [OrderedCancelAddCommMonoid α] : OrderedCancelAddCommMonoid (ι →₀ α) :=\n  { Finsupp.orderedAddCommMonoid with\n    le_of_add_le_add_left := fun f g i h s => le_of_add_le_add_left (h s) }\n\ninstance [OrderedAddCommMonoid α] [ContravariantClass α α (· + ·) (· ≤ ·)] :\n    ContravariantClass (ι →₀ α) (ι →₀ α) (· + ·) (· ≤ ·) :=\n  ⟨fun f g h H x => le_of_add_le_add_left <| H x⟩\n\nsection CanonicallyOrderedAddMonoid\n\nvariable [CanonicallyOrderedAddMonoid α]\n\ninstance : OrderBot (ι →₀ α) where\n  bot := 0\n  bot_le := by simp only [le_def, coe_zero, Pi.zero_apply, imp_true_iff, zero_le]\n\n/- warning: finsupp.bot_eq_zero -> Finsupp.bot_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α], Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Bot.bot.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (OrderBot.toHasBot.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Finsupp.orderBot.{u1, u2} ι α _inst_1))) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α], Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Bot.bot.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (OrderBot.toBot.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.orderBot.{u2, u1} ι α _inst_1))) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align finsupp.bot_eq_zero Finsupp.bot_eq_zeroₓ'. -/\nprotected theorem bot_eq_zero : (⊥ : ι →₀ α) = 0 :=\n  rfl\n#align finsupp.bot_eq_zero Finsupp.bot_eq_zero\n\n/- warning: finsupp.add_eq_zero_iff -> Finsupp.add_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))), Iff (Eq.{succ (max u1 u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (HAdd.hAdd.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHAdd.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.add.{u1, u2} ι α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f g) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))) (And (Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))) (Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.zero.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))), Iff (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHAdd.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.add.{u2, u1} ι α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))) f g) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))) (And (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))) (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.zero.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align finsupp.add_eq_zero_iff Finsupp.add_eq_zero_iffₓ'. -/\n@[simp]\ntheorem add_eq_zero_iff (f g : ι →₀ α) : f + g = 0 ↔ f = 0 ∧ g = 0 := by simp [ext_iff, forall_and]\n#align finsupp.add_eq_zero_iff Finsupp.add_eq_zero_iff\n\n/- warning: finsupp.le_iff' -> Finsupp.le_iff' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) {s : Finset.{u1} ι}, (HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f) s) -> (Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f g) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) {s : Finset.{u2} ι}, (HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f) s) -> (Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f g) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (Preorder.toLE.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (PartialOrder.toPreorder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g i))))\nCase conversion may be inaccurate. Consider using '#align finsupp.le_iff' Finsupp.le_iff'ₓ'. -/\ntheorem le_iff' (f g : ι →₀ α) {s : Finset ι} (hf : f.support ⊆ s) : f ≤ g ↔ ∀ i ∈ s, f i ≤ g i :=\n  ⟨fun h s hs => h s, fun h s => by\n    classical exact\n        if H : s ∈ f.support then h s (hf H) else (not_mem_support_iff.1 H).symm ▸ zero_le (g s)⟩\n#align finsupp.le_iff' Finsupp.le_iff'\n\n/- warning: finsupp.le_iff -> Finsupp.le_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))), Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f g) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f)) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))), Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f g) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f)) -> (LE.le.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (Preorder.toLE.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (PartialOrder.toPreorder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) i) _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g i)))\nCase conversion may be inaccurate. Consider using '#align finsupp.le_iff Finsupp.le_iffₓ'. -/\ntheorem le_iff (f g : ι →₀ α) : f ≤ g ↔ ∀ i ∈ f.support, f i ≤ g i :=\n  le_iff' f g <| Subset.refl _\n#align finsupp.le_iff Finsupp.le_iff\n\n/- warning: finsupp.decidable_le -> Finsupp.decidableLE is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : DecidableRel.{succ u2} α (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))], DecidableRel.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : DecidableRel.{succ u2} α (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))], DecidableRel.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (LE.le.{max u2 u1} (Finsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Finsupp.instLEFinsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align finsupp.decidable_le Finsupp.decidableLEₓ'. -/\ninstance decidableLE [DecidableRel (@LE.le α _)] : DecidableRel (@LE.le (ι →₀ α) _) := fun f g =>\n  decidable_of_iff _ (le_iff f g).symm\n#align finsupp.decidable_le Finsupp.decidableLE\n\n/- warning: finsupp.single_le_iff -> Finsupp.single_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] {i : ι} {x : α} {f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))}, Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.hasLe.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i x) f) (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) x (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f i))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] {i : ι} {x : α} {f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))}, Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i x) f) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) x (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f i))\nCase conversion may be inaccurate. Consider using '#align finsupp.single_le_iff Finsupp.single_le_iffₓ'. -/\n@[simp]\ntheorem single_le_iff {i : ι} {x : α} {f : ι →₀ α} : single i x ≤ f ↔ x ≤ f i :=\n  (le_iff' _ _ support_single_subset).trans <| by simp\n#align finsupp.single_le_iff Finsupp.single_le_iff\n\nvariable [Sub α] [OrderedSub α] {f g : ι →₀ α} {i : ι} {a b : α}\n\n/- warning: finsupp.tsub -> Finsupp.tsub is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2], Sub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2], Sub.{max u2 u1} (Finsupp.{u1, u2} ι α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align finsupp.tsub Finsupp.tsubₓ'. -/\n/-- This is called `tsub` for truncated subtraction, to distinguish it with subtraction in an\nadditive group. -/\ninstance tsub : Sub (ι →₀ α) :=\n  ⟨zipWith (fun m n => m - n) (tsub_self 0)⟩\n#align finsupp.tsub Finsupp.tsub\n\ninstance : OrderedSub (ι →₀ α) :=\n  ⟨fun n m k => forall_congr' fun x => tsub_le_iff_right⟩\n\ninstance : CanonicallyOrderedAddMonoid (ι →₀ α) :=\n  { Finsupp.orderBot,\n    Finsupp.orderedAddCommMonoid with\n    exists_add_of_le := fun f g h => ⟨g - f, ext fun x => (add_tsub_cancel_of_le <| h x).symm⟩\n    le_self_add := fun f g x => le_self_add }\n\n/- warning: finsupp.coe_tsub -> Finsupp.coe_tsub is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))), Eq.{succ (max u1 u2)} (ι -> α) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f g)) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (ι -> α) (ι -> α) (ι -> α) (instHSub.{max u1 u2} (ι -> α) (Pi.instSub.{u1, u2} ι (fun (ᾰ : ι) => α) (fun (i : ι) => _inst_2))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : ι), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f g)) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (forall (ᾰ : ι), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) ᾰ) (forall (ᾰ : ι), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) ᾰ) (forall (ᾰ : ι), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) ᾰ) (instHSub.{max u2 u1} (forall (ᾰ : ι), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) ᾰ) (Pi.instSub.{u2, u1} ι (fun (ᾰ : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) ᾰ) (fun (i : ι) => _inst_2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.coe_tsub Finsupp.coe_tsubₓ'. -/\n@[simp]\ntheorem coe_tsub (f g : ι →₀ α) : ⇑(f - g) = f - g :=\n  rfl\n#align finsupp.coe_tsub Finsupp.coe_tsub\n\n/- warning: finsupp.tsub_apply -> Finsupp.tsub_apply is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (a : ι), Eq.{succ u2} α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f g) a) (HSub.hSub.{u2, u2, u2} α α α (instHSub.{u2} α _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (fun (_x : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) => ι -> α) (Finsupp.coeFun.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) g a))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (a : ι), Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f g) a) (HSub.hSub.{u1, u1, u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) a) ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) a) ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) a) (instHSub.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) a) _inst_2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) ι (fun (_x : ι) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : ι) => α) _x) (Finsupp.funLike.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) g a))\nCase conversion may be inaccurate. Consider using '#align finsupp.tsub_apply Finsupp.tsub_applyₓ'. -/\ntheorem tsub_apply (f g : ι →₀ α) (a : ι) : (f - g) a = f a - g a :=\n  rfl\n#align finsupp.tsub_apply Finsupp.tsub_apply\n\n/- warning: finsupp.single_tsub -> Finsupp.single_tsub is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] {i : ι} {a : α} {b : α}, Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i (HSub.hSub.{u2, u2, u2} α α α (instHSub.{u2} α _inst_2) a b)) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i a) (Finsupp.single.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) i b))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] {i : ι} {a : α} {b : α}, Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) a b)) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i a) (Finsupp.single.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) i b))\nCase conversion may be inaccurate. Consider using '#align finsupp.single_tsub Finsupp.single_tsubₓ'. -/\n@[simp]\ntheorem single_tsub : single i (a - b) = single i a - single i b :=\n  by\n  ext j\n  obtain rfl | h := eq_or_ne i j\n  · rw [tsub_apply, single_eq_same, single_eq_same, single_eq_same]\n  · rw [tsub_apply, single_eq_of_ne h, single_eq_of_ne h, single_eq_of_ne h, tsub_self]\n#align finsupp.single_tsub Finsupp.single_tsub\n\n/- warning: finsupp.support_tsub -> Finsupp.support_tsub is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] {f1 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))} {f2 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))}, HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f1 f2)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f1)\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] {f1 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))} {f2 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))}, HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f1 f2)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f1)\nCase conversion may be inaccurate. Consider using '#align finsupp.support_tsub Finsupp.support_tsubₓ'. -/\ntheorem support_tsub {f1 f2 : ι →₀ α} : (f1 - f2).support ⊆ f1.support := by\n  simp (config := { contextual := true }) only [subset_iff, tsub_eq_zero_iff_le, mem_support_iff,\n    Ne.def, coe_tsub, Pi.sub_apply, not_imp_not, zero_le, imp_true_iff]\n#align finsupp.support_tsub Finsupp.support_tsub\n\n/- warning: finsupp.subset_support_tsub -> Finsupp.subset_support_tsub is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} α] [_inst_2 : Sub.{u2} α] [_inst_3 : OrderedSub.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))) (AddZeroClass.toHasAdd.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) _inst_2] [_inst_4 : DecidableEq.{succ u1} ι] {f1 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))} {f2 : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))}, HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) (SDiff.sdiff.{u1} (Finset.{u1} ι) (Finset.hasSdiff.{u1} ι (fun (a : ι) (b : ι) => _inst_4 a b)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f1) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) f2)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α _inst_1)))))) (Finsupp.tsub.{u1, u2} ι α _inst_1 _inst_2 _inst_3)) f1 f2))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) _inst_2] [_inst_4 : DecidableEq.{succ u2} ι] {f1 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))} {f2 : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))}, HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) (SDiff.sdiff.{u2} (Finset.{u2} ι) (Finset.instSDiffFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_4 a b)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f1) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) f2)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1)))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α _inst_1))))) (Finsupp.tsub.{u2, u1} ι α _inst_1 _inst_2 _inst_3)) f1 f2))\nCase conversion may be inaccurate. Consider using '#align finsupp.subset_support_tsub Finsupp.subset_support_tsubₓ'. -/\ntheorem subset_support_tsub [DecidableEq ι] {f1 f2 : ι →₀ α} :\n    f1.support \\ f2.support ⊆ (f1 - f2).support := by\n  simp (config := { contextual := true }) [subset_iff]\n#align finsupp.subset_support_tsub Finsupp.subset_support_tsub\n\nend CanonicallyOrderedAddMonoid\n\nsection CanonicallyLinearOrderedAddMonoid\n\nvariable [CanonicallyLinearOrderedAddMonoid α]\n\n/- warning: finsupp.support_inf -> Finsupp.support_inf is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} α] [_inst_2 : DecidableEq.{succ u1} ι] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))), Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (SemilatticeInf.toHasInf.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (Finsupp.semilatticeInf.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (Lattice.toSemilatticeInf.{u2} α (LinearOrder.toLattice.{u2} α (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u2} α _inst_1))))) f g)) (Inter.inter.{u1} (Finset.{u1} ι) (Finset.hasInter.{u1} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) f) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) g))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} α] [_inst_2 : DecidableEq.{succ u2} ι] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))), Eq.{succ u2} (Finset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (Inf.inf.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Lattice.toInf.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Finsupp.lattice.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u1} α _inst_1))))) f g)) (Inter.inter.{u2} (Finset.{u2} ι) (Finset.instInterFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) f) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.support_inf Finsupp.support_infₓ'. -/\n@[simp]\ntheorem support_inf [DecidableEq ι] (f g : ι →₀ α) : (f ⊓ g).support = f.support ∩ g.support :=\n  by\n  ext\n  simp only [inf_apply, mem_support_iff, Ne.def, Finset.mem_union, Finset.mem_filter,\n    Finset.mem_inter]\n  simp only [inf_eq_min, ← nonpos_iff_eq_zero, min_le_iff, not_or]\n#align finsupp.support_inf Finsupp.support_inf\n\n/- warning: finsupp.support_sup -> Finsupp.support_sup is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} α] [_inst_2 : DecidableEq.{succ u1} ι] (f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))), Eq.{succ u1} (Finset.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (SemilatticeSup.toHasSup.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (Finsupp.semilatticeSup.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (CanonicallyLinearOrderedAddMonoid.semilatticeSup.{u2} α _inst_1))) f g)) (Union.union.{u1} (Finset.{u1} ι) (Finset.hasUnion.{u1} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) f) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) g))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} α] [_inst_2 : DecidableEq.{succ u2} ι] (f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))), Eq.{succ u2} (Finset.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (Sup.sup.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (SemilatticeSup.toSup.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Finsupp.semilatticeSup.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u1} α _inst_1)))))) f g)) (Union.union.{u2} (Finset.{u2} ι) (Finset.instUnionFinset.{u2} ι (fun (a : ι) (b : ι) => _inst_2 a b)) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) f) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.support_sup Finsupp.support_supₓ'. -/\n@[simp]\ntheorem support_sup [DecidableEq ι] (f g : ι →₀ α) : (f ⊔ g).support = f.support ∪ g.support :=\n  by\n  ext\n  simp only [Finset.mem_union, mem_support_iff, sup_apply, Ne.def, ← bot_eq_zero]\n  rw [_root_.sup_eq_bot_iff, not_and_or]\n#align finsupp.support_sup Finsupp.support_sup\n\n/- warning: finsupp.disjoint_iff -> Finsupp.disjoint_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} α] {f : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))} {g : Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))}, Iff (Disjoint.{max u1 u2} (Finsupp.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1))))))) (Finsupp.partialOrder.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) (OrderedAddCommMonoid.toPartialOrder.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))) (Finsupp.orderBot.{u1, u2} ι α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)) f g) (Disjoint.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι) (Finset.orderBot.{u1} ι) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) f) (Finsupp.support.{u1, u2} ι α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α (OrderedAddCommMonoid.toAddCommMonoid.{u2} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} α _inst_1)))))) g))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} α] {f : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))} {g : Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))}, Iff (Disjoint.{max u2 u1} (Finsupp.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))))) (Finsupp.partialorder.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) (OrderedAddCommMonoid.toPartialOrder.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)))) (Finsupp.orderBot.{u2, u1} ι α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1)) f g) (Disjoint.{u2} (Finset.{u2} ι) (Finset.partialOrder.{u2} ι) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} ι) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) f) (Finsupp.support.{u2, u1} ι α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} α (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} α _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.disjoint_iff Finsupp.disjoint_iffₓ'. -/\ntheorem disjoint_iff {f g : ι →₀ α} : Disjoint f g ↔ Disjoint f.support g.support := by\n  classical\n    rw [disjoint_iff, disjoint_iff, Finsupp.bot_eq_zero, ← Finsupp.support_eq_empty,\n      Finsupp.support_inf]\n    rfl\n#align finsupp.disjoint_iff Finsupp.disjoint_iff\n\nend CanonicallyLinearOrderedAddMonoid\n\n/-! ### Some lemmas about `ℕ` -/\n\n\nsection Nat\n\n#print Finsupp.sub_single_one_add /-\ntheorem sub_single_one_add {a : ι} {u u' : ι →₀ ℕ} (h : u a ≠ 0) :\n    u - single a 1 + u' = u + u' - single a 1 :=\n  tsub_add_eq_add_tsub <| single_le_iff.mpr <| Nat.one_le_iff_ne_zero.mpr h\n#align finsupp.sub_single_one_add Finsupp.sub_single_one_add\n-/\n\n#print Finsupp.add_sub_single_one /-\ntheorem add_sub_single_one {a : ι} {u u' : ι →₀ ℕ} (h : u' a ≠ 0) :\n    u + (u' - single a 1) = u + u' - single a 1 :=\n  (add_tsub_assoc_of_le (single_le_iff.mpr <| Nat.one_le_iff_ne_zero.mpr h) _).symm\n#align finsupp.add_sub_single_one Finsupp.add_sub_single_one\n-/\n\nend Nat\n\nend Finsupp\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finsupp/Order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.47999472896403406}}
{"text": "import ground_zero.types.unit ground_zero.types.coproduct\nopen ground_zero.types.unit\n\nhott theory\n\nnamespace ground_zero\n\nnamespace structures\nuniverses u v\n\ndef prop (α : Sort u) :=\nΠ (a b : α), a = b :> α\n\ndef hset (α : Sort u) :=\nΠ {a b : α} (p q : a = b :> α), p = q :> a = b :> α\n\nstructure contr (α : Sort u) :=\n(point : α) (intro : Π (a : α), point = a :> α)\n--  or we can write `idfun ~ λ _, point`\n\ndef LEM := Π (α : Type u), prop α → (α + ¬α)\ndef law_of_double_negation :=\nΠ (α : Type u), prop α → (¬¬α → α)\n\ndef LEM_inf := Π (α : Type u), α + ¬α\nnotation `LEM∞` := LEM_inf\n\ninductive homotopy_level\n| minus_two\n| succ : homotopy_level → homotopy_level\n\nnotation `−2` := homotopy_level.minus_two\nnotation `−1` := homotopy_level.succ −2\n\ninstance : has_zero homotopy_level := ⟨homotopy_level.succ −1⟩\n\ndef level_to_n : homotopy_level → ℕ\n| homotopy_level.minus_two := 0\n| (homotopy_level.succ n) := level_to_n n + 1\n\ndef n_to_level : ℕ → homotopy_level\n| 0 := homotopy_level.minus_two\n| (n + 1) := homotopy_level.succ (n_to_level n)\n\ndef is_n_type : Sort u → homotopy_level → Sort (max 1 u)\n| α homotopy_level.minus_two := contr α\n| α (homotopy_level.succ n) := Π (x y : α),\n  is_n_type (x = y :> α) n\n\ndef n_type (n : homotopy_level) :=\nΣ' (α : Sort u), is_n_type α n\nnotation n `-Type` := n_type n\n\ndef contr_impl_prop {α : Sort u} (h : contr α) : prop α :=\nλ a b, (h.intro a)⁻¹ ⬝ (h.intro b)\n\ndef empty_is_prop : prop empty :=\nbegin intros x, induction x end\n\ndef unit_is_prop : prop types.unit :=\nbegin intros x y, induction x, induction y, trivial end\n\ndef prop_impl_prop {α : Prop} : prop α :=\nbegin intros x y, trivial end\n\nsection\n  open types.equiv types.eq\n  def prop_is_set {α : Sort u} (r : prop α) : hset α := begin\n    intros x y p q, have g := r x,\n    transitivity, symmetry, apply rewrite_comp,\n    exact (apd g p)⁻¹ ⬝ transport_composition p (g x),\n    induction q, apply inv_comp\n  end\n\n  -- unsafe postulate, but it computes\n  def function_extensionality {α : Sort u} {β : α → Sort v}\n    {f g : Π x, β x} (h : f ~ g) : f = g :> Π x, β x :=\n  support.inclusion $ funext (λ x, support.truncation (h x))\n\n  def contr_is_prop {α : Sort u} : prop (contr α) := begin\n    intros x y, cases x with x u, cases y with y v,\n    have p := u y, induction p, apply types.eq.map,\n    apply function_extensionality, intro a,\n    apply prop_is_set (contr_impl_prop ⟨x, u⟩)\n  end\n\n  def prop_is_prop {α : Sort u} : prop (prop α) := begin\n    intros f g,\n    have p := λ a b, (prop_is_set f) (f a b) (g a b),\n    apply function_extensionality, intro a,\n    apply function_extensionality, intro b,\n    exact p a b\n  end\nend\n\ninductive squash (α : Sort u) : Prop\n| elem : α → squash\ndef squash.uniq {α : Sort u} (a b : squash α) : a = b :> squash α :=\ntypes.eq.rfl\n\ndef K (α : Sort u) :=\nΠ (a : α) (p : a = a :> α), p = types.eq.refl a :> a = a :> α\n\ntheorem K_iff_set (α : Sort u) : K α ↔ hset α := begin\n  split,\n  { intro h, intros x y p q,\n    induction q, apply h },\n  { intro h, unfold K,\n    intros, apply h }\nend\n\ndef lem_prop {α : Sort u} (h : α → prop α) : prop α :=\nλ a, h a a\n\ndef lem_contr {α : Sort u} (h : α → contr α) : prop α :=\nλ a, contr_impl_prop (h a) a\n\ndef is_contr_fiber {α : Sort u} {β : Sort v} (f : α → β) :=\nΠ (y : β), contr (types.fib f y)\n\nend structures\n\n-- http://www.cs.bham.ac.uk/~mhe/truncation-and-extensionality/tiny-library.html\n-- http://www.cs.bham.ac.uk/~mhe/truncation-and-extensionality/hsetfunext.html\nstructure {u} singl {α : Sort u} (a : α) :=\n(point : α) (intro : a = point :> α)\n\nnamespace singl\nuniverse u\n\ndef trivial_loop {α : Sort u} (a : α) : singl a :=\n⟨a, by reflexivity⟩\n\ndef path_from_trivial_loop {α : Sort u} {a b : α}\n  (r : a = b :> α) : (trivial_loop a) = ⟨b, r⟩ :> singl a :=\nbegin induction r, trivial end\n\ndef singl.eq {α : Sort u} {a : α} (t : singl a) :\n  { point := t.point, intro := t.intro } = t :> singl a :=\nbegin induction t, simp end\n\ndef signl_contr {α : Sort u} (a : α) : structures.contr (singl a) :=\n{ point := trivial_loop a,\n  intro := λ t, path_from_trivial_loop t.intro ⬝ singl.eq t }\n\ndef singl_prop {α : Sort u} (a : α) : structures.prop (singl a) :=\nstructures.contr_impl_prop (signl_contr a)\n\nend singl\n\nend ground_zero", "meta": {"author": "jfrancese", "repo": "lean", "sha": "06e7efaecce4093d97fb5ecc75479df2ef1dbbdb", "save_path": "github-repos/lean/jfrancese-lean", "path": "github-repos/lean/jfrancese-lean/lean-06e7efaecce4093d97fb5ecc75479df2ef1dbbdb/ground_zero/structures.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.47999472559317047}}
{"text": "-- Some simple programming language modeling, using lean4\n-- commit 4296e1d83e734b18b4787329e4195569c0518325 \n-- from Fri Mar 20 18:32:04 2020 -0700\nimport Init.Data.String\n\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- Data definitions\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\ndef Var := String\n\n-- Arithmetic unary operations\ninductive Ty : Type\n| int : Ty\n| bool : Ty\n--|sum : Ty → Ty → Ty\n\n-- Arithmetic binary operations\ninductive Const : Type\n| int : Int → Const\n| bool : Bool → Const\n--|left : Const → Ty → Const\n--|right : Ty → Const → Const\n\ninstance intToConst : HasCoe Int Const := ⟨Const.int⟩\ninstance boolToConst : HasCoe Bool Const := ⟨Const.bool⟩\n\ninductive UOp : Type\n| inc\n| dec\n| neg\n| zero?\n| not\n\ninductive BOp : Type\n| add\n| sub\n| mul\n  \n\n-- Arithmetic expressions\ninductive Exp : Type\n| var    : Var → Exp\n| const  : Const → Exp\n| uop    : UOp → Exp → Exp\n| bop    : BOp → Exp → Exp → Exp\n| cond   : Exp → Exp → Exp → Exp\n| letvar : Var → Exp → Exp → Exp\n--|left  : Exp → Ty → Exp\n--|right : Ty → Exp → Exp\n--|elim  : Exp → Ty → Ty → Var\n\n\nnamespace Exp\nopen UOp BOp Const\n\nprivate def ci := λ n => const $ int n\nprivate def cb := λ b => const $ bool b\n\ndef ex1 : Exp := (ci 42)\ndef ex2 : Exp := (cb true)\ndef ex3 : Exp := (uop inc (ci 41))\ndef ex4 : Exp := (uop dec (const (int 43)))\ndef ex5 : Exp := (uop neg (bop sub (ci 0) (ci 42)))\ndef ex6 : Exp := (uop zero? (ci 0))\ndef ex7 : Exp := (bop add (ci 41) (ci 1))\ndef ex8 : Exp := (bop sub (ci 43) (ci 1))\ndef ex9 : Exp := (bop mul (ci 21) (ci 2))\ndef ex10 : Exp := (uop not (uop zero? (ci 1)))\ndef ex11 : Exp := (cond (uop not (uop zero? (ci 42))) (ci 42) (ci 0))\ndef ex12 : Exp := (cond (uop not (uop zero? (ci 0))) (ci 0) (ci 42))\ndef ex13 : Exp := (letvar \"x\" (cb true)\n                    (cond (var \"x\") (ci 42) (ci 0)))\ndef ex14 : Exp := (letvar \"x\" (uop inc (ci 41))\n                    (cond (cb true) (var \"x\") (ci 0)))\ndef ex15 : Exp := (letvar \"x\" (uop inc (ci 39))\n                    (letvar \"x\" (uop inc (var \"x\"))\n                      (uop inc (var \"x\"))))\n\nend Exp\n\ndef Env : Type := Var → Option Const\n\nnamespace Env\n\ndef empty : Env := λ _ => none\ndef extend (ρ : Env) (x : Var) (c:Const) : Env :=\n  λ y => if x == y then some c else (ρ y)\n\nend Env\n\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- Interpreter\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\nnamespace UOp\n\ndef interp : UOp → Const → Option Const\n| inc,   (Const.int n)  => some $ Const.int $ n + 1\n| dec,   (Const.int n)  => some $ Const.int $ n - 1\n| neg,   (Const.int n)  => some $ Const.int $ 0 - n\n| zero?, (Const.int n)  => some $ Const.bool $ n == 0\n| not,   (Const.bool b) => some $ Const.bool $ ¬ b\n| _,_ => none\n\nend UOp\n\nnamespace BOp\n\ndef interp : BOp → Const → Const → Option Const\n| add, (Const.int x), (Const.int y)  => some $ Const.int $ x + y\n| sub, (Const.int x), (Const.int y)  => some $ Const.int $ x - y\n| mul, (Const.int x), (Const.int y)  => some $ Const.int $ x * y\n| _,_,_ => none\n\nend BOp\n\n\nnamespace Exp\n\ndef interp : Env → Exp → Option Const\n| ρ, var x => ρ x\n| ρ, const c => c\n| ρ, uop op e => do\n  v ← interp ρ e;\n  UOp.interp op v\n| ρ, bop op e₁ e₂ => do\n  v₁ ← interp ρ e₁;\n  v₂ ← interp ρ e₂;\n  BOp.interp op v₁ v₂\n| ρ, cond e₁ e₂ e₃ =>\n  match interp ρ e₁ with\n  | some (Const.bool true) => interp ρ e₂\n  | some (Const.bool false) => interp ρ e₃\n  | _ => none\n| ρ, letvar x e₁ e₂ => do\n  v₁ ← interp ρ e₁;\n  let ρ' := Env.extend ρ x v₁;\n  interp ρ' e₂\n\nend Exp\n\n\ndef TyEnv : Type := Var → Option Ty\n\nnamespace TyEnv\n\ndef empty : TyEnv := λ _ => none\ndef extend (Γ : TyEnv) (x : Var) (t:Ty) : TyEnv :=\n  λ y => if x == y then some t else (Γ y)\n\nend TyEnv\n\n\nnamespace Const\n\ndef typeof : Const → Ty\n| int _ => Ty.int\n| bool _ => Ty.bool\n\nend Const\n\n\nnamespace UOp\n\ndef typeof : UOp → (Ty × Ty)\n| inc   => (Ty.int, Ty.int)\n| dec   => (Ty.int, Ty.int)\n| neg   => (Ty.int, Ty.int)\n| zero? => (Ty.int, Ty.bool)\n| not   => (Ty.bool, Ty.bool)\nend UOp\n\n\nnamespace BOp\n\ndef typeof : BOp → (Ty × Ty × Ty)\n| add   => (Ty.int, Ty.int, Ty.int)\n| sub   => (Ty.int, Ty.int, Ty.int)\n| mul   => (Ty.int, Ty.int, Ty.int)\n\nend BOp\n\n\ninductive TypeOf : TyEnv → Exp → Ty → Prop\n| var (Γ:TyEnv) x t :\n  (Γ x) = (some t)\n  → TypeOf Γ (Exp.var x) t\n| const Γ c t :\n  Const.typeof c = t\n  → TypeOf Γ (Exp.const c) t\n| uop Γ op e t t' :\n  TypeOf Γ e t\n  → UOp.typeof op = (t, t')\n  → TypeOf Γ (Exp.uop op e) t'\n| bop Γ op e₁ e₂ t₁ t₂ t₃ :\n  TypeOf Γ e₁ t₁\n  → TypeOf Γ e₂ t₂\n  → BOp.typeof op = (t₁, t₂, t₃)\n  → TypeOf Γ (Exp.bop op e₁ e₂) t₃\n| cond Γ e₁ e₂ e₃ t :\n  TypeOf Γ e₁ Ty.bool\n  → TypeOf Γ e₂ t\n  → TypeOf Γ e₃ t\n  → TypeOf Γ (Exp.cond e₁ e₂ e₃) t\n| letvar Γ x e₁ e₂ t₁ t₂ :\n  TypeOf Γ e₁ t₁\n  → TypeOf (TyEnv.extend Γ x t₁) e₂ t₂\n  → TypeOf Γ (Exp.letvar x e₁ e₂) t₂\n\n-- In the given expression, substitute\n-- the constant for the variable.\ndef subst : Exp → Const → Var → Exp\n| Exp.var y, c, x => \n  if x == y then (Exp.const c) else Exp.var y\n| Exp.const c, _, _ => \n  Exp.const c\n| Exp.uop op e, c, x => \n  Exp.uop op (subst e c x)\n| Exp.bop op e₁ e₂, c, x => \n  Exp.bop op (subst e₁ c x) (subst e₂ c x)\n| Exp.cond e₁ e₂ e₃, c, x => \n  Exp.cond (subst e₁ c x) (subst e₂ c x) (subst e₃ c x)\n| Exp.letvar y e₁ e₂, c, x => \n  let e₁' := (subst e₁ c x);\n  if x == y then\n    Exp.letvar y e₁' e₂\n  else\n    Exp.letvar y e₁' (subst e₂ c x)\n\n-- A single reduction step.\ninductive Step : Exp → Exp → Prop \n| uop_red op c₁ c₂ :\n  UOp.interp op c₁ = some c₂\n  → Step (Exp.uop op (Exp.const c₁)) (Exp.const c₂)\n| bop_red op c₁ c₂ c₃ :\n  BOp.interp op c₁ c₂ = some c₃\n  → Step (Exp.bop op (Exp.const c₁) (Exp.const c₂)) (Exp.const c₃)\n| cond_congr e₁ e₁' e₂ e₃ :\n  Step e₁ e₁'\n  → Step (Exp.cond e₁ e₂ e₃) (Exp.cond e₁' e₂ e₃)\n| cond_red e₁ e₂ :\n  Step (Exp.cond (Exp.const true) e₁ e₂) e₁\n| letvar_congr x e₁ e₁' e₂ :\n  Step e₁ e₁'\n  → Step (Exp.letvar x e₁ e₂) (Exp.letvar x e₁' e₂)\n| letvar_red x c e :\n  Step (Exp.letvar x (Exp.const c) e) (subst e c x)\n\n\n-- | Zero or more steps of reduction.\ninductive Steps : Exp → Exp → Prop\n| nil e : \n  Steps e e\n| cons e₁ e₂ e₃ : \n  Step e₁ e₂\n  → Steps e₂ e₃\n  → Steps e₁ e₃\n\n\n\ndef env_sat (Γ:TyEnv) (ρ:Env) : Prop := forall x t, \n   (Γ x) = some t \n   → Exists (λ c => (ρ x) = some c ∧ Const.typeof c = t)\n\n\n\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- Theorems (N.B., seems like tactics have to\n-- come after `new_frontend`... need to look\n-- more into what it entails.)\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\n\n\nnew_frontend\n\nmacro try t:tactic : tactic => `($t <|> skip)\n\nsyntax \"repeat\" tactic : tactic\nmacro_rules\n| `(tactic| repeat $t) => `(tactic| try ($t; repeat $t))\n\n-- TODO there's got to be a way to just apply all\n-- the known constructors for a type, right?\n-- oooh, check out src/Init/Lean/Meta/Tactic\nmacro constr_TypeOf : tactic => \n`((apply TypeOf.var) <|>\n  (apply TypeOf.const) <|>\n  (apply TypeOf.uop) <|>\n  (apply TypeOf.bop) <|>\n  (apply TypeOf.cond) <|>\n  (apply TypeOf.letvar))\n\nmacro typecheck : tactic =>\n `(repeat (constr_TypeOf <|> (exact rfl)))\n  \n\n\nopen Exp\n\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- Example evaluation tests\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\ndef test_eval : Exp → Option Const := interp Env.empty\n\nprivate theorem test_ex1 : \n test_eval ex1 = some (Const.int 42) := \nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex2 :\n test_eval ex2 = some (Const.bool true) :=\nEq.refl (some (Const.bool true))\n\nprivate theorem test_ex3 :\n test_eval ex3 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex4 :\n test_eval ex4 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex5 :\n test_eval ex5 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex6 :\n test_eval ex6 = some (Const.bool true) :=\nEq.refl (some (Const.bool true))\n\nprivate theorem test_ex7 :\n test_eval ex7 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex8 :\n test_eval ex8 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex8 :\n test_eval ex8 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex9 :\n test_eval ex9 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex10 :\n test_eval ex10 = some (Const.bool true) :=\nEq.refl (some (Const.bool true))\n\nprivate theorem test_ex11 :\n test_eval ex11 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex12 :\n test_eval ex12 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex13 :\n test_eval ex13 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\nprivate theorem test_ex14 :\n test_eval ex14 = some (Const.int 42) :=\nEq.refl (some (Const.int 42))\n\ntheorem test_ex15 : \n test_eval ex15 = some (Const.int 42) :=\nbegin\n  exact rfl\nend\n\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- Example type checking tests\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\nnamespace Exp\nopen UOp BOp Const\n\n\ntheorem test_ex1 : \n TypeOf TyEnv.empty ex1 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex2 : \n TypeOf TyEnv.empty ex2 Ty.bool :=\nbegin\n  typecheck\nend\n\ntheorem test_ex3 : \n TypeOf TyEnv.empty ex3 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex4 : \n TypeOf TyEnv.empty ex4 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex5 : \n TypeOf TyEnv.empty ex5 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex6 : \n TypeOf TyEnv.empty ex6 Ty.bool :=\nbegin\n  typecheck\nend\n\ntheorem test_ex7 : \n TypeOf TyEnv.empty ex7 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex8 : \n TypeOf TyEnv.empty ex8 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex9 : \n TypeOf TyEnv.empty ex9 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex10 : \n TypeOf TyEnv.empty ex10 Ty.bool :=\nbegin\n  typecheck\nend\n\ntheorem test_ex11 : \n TypeOf TyEnv.empty ex11 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex12 : \n TypeOf TyEnv.empty ex12 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex13 : \n TypeOf TyEnv.empty ex13 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex14 : \n TypeOf TyEnv.empty ex14 Ty.int :=\nbegin\n  typecheck\nend\n\ntheorem test_ex15 : \n TypeOf TyEnv.empty ex15 Ty.int :=\nbegin\n  typecheck\nend\n\n\nend Exp\n\n\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- Type safety theorems\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\nnamespace UOp\nopen Const\n\ndef interp_safe : forall op t₁ t₂ c,\n typeof op = (t₁, t₂)\n → Const.typeof c = t₁\n → Exists (λ c' => interp op c = some c' ∧ Const.typeof c' = t₂) :=\nbegin\n  intros op t₁ t₂ c Hop Hc;\n  cases op; cases c;\n  apply (Exists.intro (Const.int $ a + 1));\n  apply And.intro;\n  exact rfl;\nend\n\nend UOp\n\n\n-- UOp.interp is type safe\n-- BOp.interp is type safe\n-- BOp.interp is type safe\n\n", "meta": {"author": "pnwamk", "repo": "misc-lean", "sha": "5b8807cfee8f22ab6f3b2c5d8ea678c02e67825b", "save_path": "github-repos/lean/pnwamk-misc-lean", "path": "github-repos/lean/pnwamk-misc-lean/misc-lean-5b8807cfee8f22ab6f3b2c5d8ea678c02e67825b/sf/imp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.47999472203455174}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Simon Hudon\n\n! This file was ported from Lean 3 source module data.qpf.multivariate.constructions.comp\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Pfunctor.Multivariate.Basic\nimport Mathbin.Data.Qpf.Multivariate.Basic\n\n/-!\n# The composition of QPFs is itself a QPF\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define composition between one `n`-ary functor and `n` `m`-ary functors\nand show that it preserves the QPF structure\n-/\n\n\nuniverse u\n\nnamespace MvQPF\n\nopen MvFunctor\n\nvariable {n m : ℕ} (F : TypeVec.{u} n → Type _) [fF : MvFunctor F] [q : MvQPF F]\n  (G : Fin2 n → TypeVec.{u} m → Type u) [fG : ∀ i, MvFunctor <| G i] [q' : ∀ i, MvQPF <| G i]\n\n#print MvQPF.Comp /-\n/-- Composition of an `n`-ary functor with `n` `m`-ary\nfunctors gives us one `m`-ary functor -/\ndef Comp (v : TypeVec.{u} m) : Type _ :=\n  F fun i : Fin2 n => G i v\n#align mvqpf.comp MvQPF.Comp\n-/\n\nnamespace Comp\n\nopen MvFunctor MvPFunctor\n\nvariable {F G} {α β : TypeVec.{u} m} (f : α ⟹ β)\n\ninstance [I : Inhabited (F fun i : Fin2 n => G i α)] : Inhabited (Comp F G α) :=\n  I\n\n#print MvQPF.Comp.mk /-\n/-- Constructor for functor composition -/\nprotected def mk (x : F fun i => G i α) : (Comp F G) α :=\n  x\n#align mvqpf.comp.mk MvQPF.Comp.mk\n-/\n\n#print MvQPF.Comp.get /-\n/-- Destructor for functor composition -/\nprotected def get (x : (Comp F G) α) : F fun i => G i α :=\n  x\n#align mvqpf.comp.get MvQPF.Comp.get\n-/\n\n/- warning: mvqpf.comp.mk_get -> MvQPF.Comp.mk_get is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u1} n) -> Type.{u2}} {G : (Fin2 n) -> (TypeVec.{u1} m) -> Type.{u1}} {α : TypeVec.{u1} m} (x : MvQPF.Comp.{u1, u2} n m F G α), Eq.{succ u2} (MvQPF.Comp.{u1, u2} n m F G α) (MvQPF.Comp.mk.{u1, u2} n m F G α (MvQPF.Comp.get.{u1, u2} n m F G α x)) x\nbut is expected to have type\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u2} n) -> Type.{u1}} {G : (Fin2 n) -> (TypeVec.{u2} m) -> Type.{u2}} {α : TypeVec.{u2} m} (x : MvQPF.Comp.{u2, u1} n m F G α), Eq.{succ u1} (MvQPF.Comp.{u2, u1} n m F (fun (i : Fin2 n) => G i) α) (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) α (MvQPF.Comp.get.{u2, u1} n m F G α x)) x\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.mk_get MvQPF.Comp.mk_getₓ'. -/\n@[simp]\nprotected theorem mk_get (x : (Comp F G) α) : Comp.mk (Comp.get x) = x :=\n  rfl\n#align mvqpf.comp.mk_get MvQPF.Comp.mk_get\n\n/- warning: mvqpf.comp.get_mk -> MvQPF.Comp.get_mk is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u1} n) -> Type.{u2}} {G : (Fin2 n) -> (TypeVec.{u1} m) -> Type.{u1}} {α : TypeVec.{u1} m} (x : F (fun (i : Fin2 n) => G i α)), Eq.{succ u2} (F (fun (i : Fin2 n) => G i α)) (MvQPF.Comp.get.{u1, u2} n m F G α (MvQPF.Comp.mk.{u1, u2} n m F G α x)) x\nbut is expected to have type\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u2} n) -> Type.{u1}} {G : (Fin2 n) -> (TypeVec.{u2} m) -> Type.{u2}} {α : TypeVec.{u2} m} (x : F (fun (i : Fin2 n) => G i α)), Eq.{succ u1} (F (fun (i : Fin2 n) => G i α)) (MvQPF.Comp.get.{u2, u1} n m F (fun (i : Fin2 n) => G i) α (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) α x)) x\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.get_mk MvQPF.Comp.get_mkₓ'. -/\n@[simp]\nprotected theorem get_mk (x : F fun i => G i α) : Comp.get (Comp.mk x) = x :=\n  rfl\n#align mvqpf.comp.get_mk MvQPF.Comp.get_mk\n\ninclude fG\n\n#print MvQPF.Comp.map' /-\n/-- map operation defined on a vector of functors -/\nprotected def map' : (fun i : Fin2 n => G i α) ⟹ fun i : Fin2 n => G i β := fun i => map f\n#align mvqpf.comp.map' MvQPF.Comp.map'\n-/\n\ninclude fF\n\n#print MvQPF.Comp.map /-\n/-- The composition of functors is itself functorial -/\nprotected def map : (Comp F G) α → (Comp F G) β :=\n  (map fun i => map f : (F fun i => G i α) → F fun i => G i β)\n#align mvqpf.comp.map MvQPF.Comp.map\n-/\n\ninstance : MvFunctor (Comp F G) where map α β := Comp.map\n\n/- warning: mvqpf.comp.map_mk -> MvQPF.Comp.map_mk is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u1} n) -> Type.{u2}} [fF : MvFunctor.{u1, u2} n F] {G : (Fin2 n) -> (TypeVec.{u1} m) -> Type.{u1}} [fG : forall (i : Fin2 n), MvFunctor.{u1, u1} m (G i)] {α : TypeVec.{u1} m} {β : TypeVec.{u1} m} (f : TypeVec.Arrow.{u1, u1} m α β) (x : F (fun (i : Fin2 n) => G i α)), Eq.{succ u2} (MvQPF.Comp.{u1, u2} n m F (fun (i : Fin2 n) {α : TypeVec.{u1} m} => G i α) β) (MvFunctor.map.{u1, u2} m (MvQPF.Comp.{u1, u2} n m F (fun (i : Fin2 n) {α : TypeVec.{u1} m} => G i α)) (MvQPF.Comp.mvfunctor.{u1, u2} n m F fF (fun (i : Fin2 n) {α : TypeVec.{u1} m} => G i α) (fun (i : Fin2 n) => fG i)) α β f (MvQPF.Comp.mk.{u1, u2} n m F (fun (i : Fin2 n) {α : TypeVec.{u1} m} => G i α) α x)) (MvQPF.Comp.mk.{u1, u2} n m F (fun (i : Fin2 n) {α : TypeVec.{u1} m} => G i α) β (MvFunctor.map.{u1, u2} n F fF (fun (i : Fin2 n) => G i α) (fun (i : Fin2 n) => G i β) (fun (i : Fin2 n) (x : G i α) => MvFunctor.map.{u1, u1} m (fun {α : TypeVec.{u1} m} => G i α) (fG i) α β f x) x))\nbut is expected to have type\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u2} n) -> Type.{u1}} [fF : MvFunctor.{u2, u1} n F] {G : (Fin2 n) -> (TypeVec.{u2} m) -> Type.{u2}} [fG : forall (i : Fin2 n), MvFunctor.{u2, u2} m (G i)] {α : TypeVec.{u2} m} {β : TypeVec.{u2} m} (f : TypeVec.Arrow.{u2, u2} m α β) (x : F (fun (i : Fin2 n) => G i α)), Eq.{succ u1} (MvQPF.Comp.{u2, u1} n m F (fun (i : Fin2 n) => G i) β) (MvFunctor.map.{u2, u1} m (MvQPF.Comp.{u2, u1} n m F (fun (i : Fin2 n) => G i)) (MvQPF.Comp.instMvFunctorComp.{u2, u1} n m F fF (fun (i : Fin2 n) => G i) (fun (i : Fin2 n) => fG i)) α β f (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) α x)) (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) β (MvFunctor.map.{u2, u1} n F fF (fun (i : Fin2 n) => G i α) (fun (i : Fin2 n) => G i β) (fun (i : Fin2 n) (x : G i α) => MvFunctor.map.{u2, u2} m (G i) (fG i) α β f x) x))\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.map_mk MvQPF.Comp.map_mkₓ'. -/\ntheorem map_mk (x : F fun i => G i α) :\n    f <$$> Comp.mk x = Comp.mk ((fun i (x : G i α) => f <$$> x) <$$> x) :=\n  rfl\n#align mvqpf.comp.map_mk MvQPF.Comp.map_mk\n\n/- warning: mvqpf.comp.get_map -> MvQPF.Comp.get_map is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u1} n) -> Type.{u2}} [fF : MvFunctor.{u1, u2} n F] {G : (Fin2 n) -> (TypeVec.{u1} m) -> Type.{u1}} [fG : forall (i : Fin2 n), MvFunctor.{u1, u1} m (G i)] {α : TypeVec.{u1} m} {β : TypeVec.{u1} m} (f : TypeVec.Arrow.{u1, u1} m α β) (x : MvQPF.Comp.{u1, u2} n m F G α), Eq.{succ u2} (F (fun (i : Fin2 n) => G i β)) (MvQPF.Comp.get.{u1, u2} n m F G β (MvFunctor.map.{u1, u2} m (MvQPF.Comp.{u1, u2} n m F G) (MvQPF.Comp.mvfunctor.{u1, u2} n m F fF G (fun (i : Fin2 n) => fG i)) α β f x)) (MvFunctor.map.{u1, u2} n F fF (fun (i : Fin2 n) => G i α) (fun (i : Fin2 n) => G i β) (fun (i : Fin2 n) (x : G i α) => MvFunctor.map.{u1, u1} m (fun {α : TypeVec.{u1} m} => G i α) (fG i) α β f x) (MvQPF.Comp.get.{u1, u2} n m F G α x))\nbut is expected to have type\n  forall {n : Nat} {m : Nat} {F : (TypeVec.{u2} n) -> Type.{u1}} [fF : MvFunctor.{u2, u1} n F] {G : (Fin2 n) -> (TypeVec.{u2} m) -> Type.{u2}} [fG : forall (i : Fin2 n), MvFunctor.{u2, u2} m (G i)] {α : TypeVec.{u2} m} {β : TypeVec.{u2} m} (f : TypeVec.Arrow.{u2, u2} m α β) (x : MvQPF.Comp.{u2, u1} n m F G α), Eq.{succ u1} (F (fun (i : Fin2 n) => G i β)) (MvQPF.Comp.get.{u2, u1} n m F G β (MvFunctor.map.{u2, u1} m (MvQPF.Comp.{u2, u1} n m F G) (MvQPF.Comp.instMvFunctorComp.{u2, u1} n m F fF G (fun (i : Fin2 n) => fG i)) α β f x)) (MvFunctor.map.{u2, u1} n F fF (fun (i : Fin2 n) => G i α) (fun (i : Fin2 n) => G i β) (fun (i : Fin2 n) (x : G i α) => MvFunctor.map.{u2, u2} m (G i) (fG i) α β f x) (MvQPF.Comp.get.{u2, u1} n m F (fun (i : Fin2 n) => G i) α x))\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.get_map MvQPF.Comp.get_mapₓ'. -/\ntheorem get_map (x : Comp F G α) :\n    Comp.get (f <$$> x) = (fun i (x : G i α) => f <$$> x) <$$> Comp.get x :=\n  rfl\n#align mvqpf.comp.get_map MvQPF.Comp.get_map\n\ninclude q q'\n\ninstance : MvQPF (Comp F G)\n    where\n  p := MvPFunctor.comp (p F) fun i => p <| G i\n  abs α := Comp.mk ∘ (map fun i => abs) ∘ abs ∘ MvPFunctor.comp.get\n  repr α :=\n    MvPFunctor.comp.mk ∘\n      repr ∘ (map fun i => (repr : G i α → (fun i : Fin2 n => Obj (p (G i)) α) i)) ∘ Comp.get\n  abs_repr := by\n    intros\n    simp [(· ∘ ·), MvFunctor.map_map, (· ⊚ ·), abs_repr]\n  abs_map := by\n    intros\n    simp [(· ∘ ·)]\n    rw [← abs_map]\n    simp [MvFunctor.id_map, (· ⊚ ·), map_mk, MvPFunctor.comp.get_map, abs_map, MvFunctor.map_map,\n      abs_repr]\n\nend Comp\n\nend MvQPF\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Qpf/Multivariate/Constructions/Comp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943603346811, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4799947203491199}}
{"text": "import EggTactic\n\ninductive EQ {α : Type} (a : α) : α → Type where\n  | refl : EQ a a\n\ndef EQ.trans (h₁ : EQ a b) (h₂ : EQ b c) : EQ a c := by\n  cases h₁; cases h₂; constructor\n\ninstance : Trans (@EQ α) (@EQ α) (@EQ α) where\n  trans := EQ.trans\n\ninfix:50 \" ≋ \" => EQ\n\nexample (h₁ : EQ a b) (h₂ : b = c) (h₃ : EQ c d) : EQ a d := by\n  calc a ≋ b := h₁\n       _ = c := h₂\n       _ ≋ d := h₃\n\nexample (h₁ : EQ a b) (h₂ : b = c) (h₃ : EQ c d) : EQ a d := by\n  eggxplosion [h₁, h₂, h₃]\n", "meta": {"author": "opencompl", "repo": "egg-tactic-code", "sha": "4c37f57478f88d5e11120051012e3d97264c338c", "save_path": "github-repos/lean/opencompl-egg-tactic-code", "path": "github-repos/lean/opencompl-egg-tactic-code/egg-tactic-code-4c37f57478f88d5e11120051012e3d97264c338c/Evaluation/GeneralizedRewriting.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.47999472034911983}}
{"text": "import algebra.module.submodule.basic\nimport algebra.group_power.basic\nimport .holomorphic_functions\nimport analysis.complex.upper_half_plane.basic\nimport linear_algebra.general_linear_group\nimport linear_algebra.special_linear_group\nimport algebra.direct_sum.ring\nimport number_theory.modular\nimport geometry.manifold.mfderiv\nimport .upper_half_plane_manifold\nimport .hol_bdd\nimport number_theory.modular_forms.slash_actions\nimport number_theory.modular_forms.slash_invariant_forms\nimport linear_algebra.general_linear_group\n\n\nopen complex\n\nopen_locale topological_space manifold\n\n\nnoncomputable theory\n\nopen modular_form\n\nopen_locale upper_half_plane\n\nlocal notation `ℍ'`:=(⟨upper_half_space , upper_half_plane_is_open⟩: open_subs)\n\nlocal notation `ℍ`:=upper_half_plane\n\ninstance : charted_space ℂ ℂ := infer_instance\n\ninstance : charted_space ℂ ℍ' := infer_instance\n\nlocal prefix `↑ₘ`:1024 := @coe _ (matrix (fin 2) (fin 2) _) _\n\nlocal notation `GL(` n `, ` R `)`⁺:= matrix.GL_pos (fin n) R\n\nlocal notation `SL(` n `, ` R `)`:= matrix.special_linear_group (fin n) R\n\nvariable (M : GL(2, ℝ)⁺)\n\nlemma auxmf2 (a b c : ℂ) : b⁻¹*c⁻¹*a=(b*c)⁻¹*a:=\nbegin\nfield_simp,\nend\n\nlemma aux1 (a b c d e: ℂ) (k : ℤ) : (e^k)⁻¹*a^(k-1) * (b^k)⁻¹ * c^(k -1) * d =\n( (b * e)^ k)⁻¹ * (c * a)^(k-1) * d:=\nbegin\nhave : (b^k)⁻¹ * ((e)^ k)⁻¹ * (c)^(k-1) * (a)^(k-1) * d = ( (b * e)^ k)⁻¹ * (c * a)^(k-1) * d ,\nby  {ring_exp, rw ← mul_assoc,\n have:  (b * e)^ k = b^k * e^k, by {exact mul_zpow b e k,},\nsimp_rw [mul_zpow],\nsimp_rw [mul_inv],ring,},\nrw ←this,\nring,\nend\n\nopen modular_form\nopen complex matrix matrix.special_linear_group upper_half_plane\nopen_locale upper_half_plane complex_conjugate\n\n\nvariables (Γ : subgroup SL(2,ℤ)) (C : GL(2, ℝ)⁺) (k: ℤ) (f : (ℍ → ℂ))\n\nlocalized \"notation  f  ` ∣[`:100 k `]`:0 γ :100 := slash k γ f\" in modular_form\n\n--Definition of modular forms:\ndef weakly_modular_weight_k (k : ℤ) (f : ℍ' → ℂ) :=\n    ∀ (γ : SL(2,ℤ)),  (f ∣[k] (γ : GL(2, ℝ)⁺)) = f\n\nlemma zero_weakly_modular (k : ℤ) : weakly_modular_weight_k k (0 : ℍ' → ℂ) :=\nbegin\nintro γ,\nsimp,\nsorry,\nend\n\ndef one_periodicity (f : ℍ' → ℂ) := ∀ (z : ℍ'), extend_by_zero f (z + 1) = extend_by_zero f (z)\n\ndef weakly_modular_submodule_weight_k (k : ℤ) : submodule ℂ (ℍ' → ℂ) := {\n  carrier := weakly_modular_weight_k k,\n  zero_mem' := by {exact zero_weakly_modular k},\n  add_mem' := by {\n    intros f g hf hg,\n    intro γ,\n    have hff:= hf γ,\n    have hgg:= hg γ,\n    rw slash_add k γ f g,\n    rw [hff, hgg],\n  },\n  smul_mem' := by {\n    intros c f hf,\n    intro γ,\n    have hff:= hf γ,\n    have : (c • f)  ∣[k] γ = c • (f  ∣[k] γ ),\n    by {apply smul_slash},\n    rw hff at this,\n    apply this,\n  },\n}\n\n\nclass modular_form_weight_k (k : ℤ) (f : ℍ' → ℂ) : Prop :=\n  (hol : f ∈ Holℍ)\n  (weak : weakly_modular_weight_k k f)\n\n\ndef space_of_modular_forms_weight_k (k : ℤ) : submodule ℂ (ℍ' → ℂ) := { \n  carrier := modular_form_weight_k k,\n  add_mem' := λ f g hf hg, ⟨Holℍ.add_mem' hf.hol hg.hol, (weakly_modular_submodule_weight_k k).add_mem' hf.weak hg.weak⟩,\n  zero_mem' := ⟨Holℍ.zero_mem', zero_weakly_modular k⟩,\n  smul_mem' := λ c f hf, ⟨⟨smul_hol _ _ hf.hol.diff, bounded_at_im_infty.smul _ hf.hol.bdd_at_infty⟩,\n    (weakly_modular_submodule_weight_k k).smul_mem' c hf.weak⟩,\n  }\n\n\n\n\n-- Definition of modular forms for congruence subgroups:\n\ndef weakly_modular_weight_k_subgroup (k : ℤ) (Γ : subgroup SL(2,ℤ)) (f : ℍ' → ℂ) :=\n  ∀ (γ : Γ),  (f ∣[k] (γ : GL(2, ℝ)⁺)) = f\n\n\nlemma zero_weakly_modular_subgroup (k : ℤ) (Γ : subgroup SL(2,ℤ)) : weakly_modular_weight_k_subgroup k Γ (0 : ℍ' → ℂ) :=\nbegin\nintro γ,\nsimp,\nsorry,\nend\n\n\ndef weakly_modular_submodule_weight_k_subgroup (k : ℤ) (Γ : subgroup SL(2,ℤ)) : submodule ℂ (ℍ' → ℂ) := {\n  carrier := weakly_modular_weight_k_subgroup k Γ,\n  zero_mem' := by {exact zero_weakly_modular_subgroup k Γ},\n  add_mem' := by {\n    intros f g hf hg,\n    intro γ,\n    have hff:= hf γ,\n    have hgg:= hg γ,\n    rw slash_add k γ f g,\n    rw [hff, hgg],\n  },\n  smul_mem' := by {\n    intros c f hf,\n    intro γ,\n    have hff:= hf γ,\n    have : (c • f)  ∣[k] γ = c • (f  ∣[k] γ ),\n    by {apply smul_slash},\n    rw hff at this,\n    apply this,\n  },\n}\n\n--instance : has_mem (ℍ' → ℂ) (submodule ℂ (ℍ' → ℂ)) := ⟨λ f V, f ∈ V⟩\n\n--Space of modular forms for congruence subgroups:\nclass modular_form_weight_k_subgroup (k : ℤ) (Γ : subgroup SL(2,ℤ)) (f : ℍ' → ℂ) : Prop :=\n  (hol : f ∈ Holℍ)\n  (weak : weakly_modular_weight_k_subgroup k Γ f)\n\ndef space_of_modular_forms_weight_k_subgroup (k : ℤ) (Γ : subgroup SL(2,ℤ)) : submodule ℂ (ℍ' → ℂ) := { \n  carrier := modular_form_weight_k_subgroup k Γ,\n  add_mem' := λ f g hf hg, ⟨Holℍ.add_mem' hf.hol hg.hol, (weakly_modular_submodule_weight_k_subgroup k Γ).add_mem' hf.weak hg.weak⟩,\n  zero_mem' := ⟨Holℍ.zero_mem', zero_weakly_modular_subgroup k Γ⟩,\n  smul_mem' := λ c f hf, ⟨⟨smul_hol _ _ hf.hol.diff, bounded_at_im_infty.smul _ hf.hol.bdd_at_infty⟩,\n    (weakly_modular_submodule_weight_k_subgroup k Γ).smul_mem' c hf.weak⟩,\n  }\n\n-- Definition of meromorphic modular forms:\ndef slash_mer_left (k : ℤ) (γ : SL(2,ℤ)) (f g : ℍ → ℂ) (z : ℍ) : ℂ :=\n  f(γ • z) * g(z) * (upper_half_plane.denom γ z)^(-k)\n\nlemma power_of_diff (k1 k2 : ℤ) (a : ℂ) : a^(k1-k2) = a^k1 * a^(-k2) :=\nbegin\n  \n  sorry,\nend\n\nlemma sep_slash_mer_left (k1 k2 : ℕ) (k : ℤ) (hk : k = k1-k2) (γ : SL(2,ℤ)) (f g : ℍ → ℂ) (z : ℍ) : \n  f(γ • z) * g(z) * (upper_half_plane.denom γ z)^(-k) = f(γ • z) * (upper_half_plane.denom γ z)^(-k1 : ℤ) * g(z) * (upper_half_plane.denom γ z)^(k2) :=\n  begin\n  rw hk,\n  simp only [neg_sub, pow_add],\n  have : (denom γ z)^((k2 : ℤ)-(k1:ℤ)) = (denom γ z)^(k2:ℤ) * (denom γ z)^(-k1 : ℤ),\n  {\n    simp,\n    sorry,\n  },\n  rw this,\n  simp only [of_real_int_cast, zpow_coe_nat, zpow_neg],\n  sorry,\n  end\n\ndef slash_mer_right (k : ℤ) (γ : SL(2,ℤ)) (f g : ℍ → ℂ) (z : ℍ) : ℂ :=\n  f(z) * g(γ • z)\n\ndef weakly_meromorphic_modular_weight_k (k : ℤ) (F : Merℍ) :=\n  ∀ (γ : SL(2,ℤ)), slash_mer_left k γ F.numerator.val F.denominator.val.val = slash_mer_right k γ F.numerator.val F.denominator.val.val\n\ninstance mem_mer : has_mem Merℍ (submodule ℂ (ℍ' → ℂ)) := ⟨λ F V, F.map ∈ V⟩\n\n--Meromorphic modular form subtype\n\ndef Merℍwm (k : ℤ) :=\n{F : Merℍ | weakly_meromorphic_modular_weight_k k F}\n\nlemma Merℍwm_mem (k : ℤ) (F : Merℍ) :\n  F ∈ (Merℍwm k) ↔  ∀ (γ : SL(2,ℤ)), slash_mer_left k γ F.numerator.val F.denominator.val.val = slash_mer_right k γ F.numerator.val F.denominator.val.val := \n  iff.rfl\n\n\nlemma Merℍ_ap (k : ℤ) (Γ : subgroup SL(2,ℤ)) (f : Holℍ) (g : non_zero_divisors Holℍ) : Merℍ :=\nbegin\nexact Merℍ.mk f g,\nend\n\nlemma modular_forms_of_Merℍwm (k1 k2 : ℤ) (hk : k = k1-k2)\n(f : Holℍ) (g : non_zero_divisors Holℍ) (hf : modular_form_weight_k k1 f) (hg : modular_form_weight_k k2 g)\n: Merℍ.mk f g ∈ Merℍwm (k) :=\nbegin\nrw Merℍwm_mem,\nintro γ,\n\nsorry,\nend\n\n\n\n/- def space_of_meromorphic_modular_forms_weight_k (k : ℤ) (Γ : subgroup SL(2,ℤ)) : submodule ℂ (ℍ' → ℂ) := {\n  carrier := Merℍ.map '' set.univ,\n  add_mem' := sorry,\n  zero_mem' := sorry,\n  smul_mem' := sorry,\n  }\n\n -/\n\n\n\n/- ---------\nlemma wmodular_mem (k : ℤ) (Γ : subgroup SL(2,ℤ)) (f : ℍ' → ℂ) :\n  f ∈ (weakly_modular_submodule_weight_k k Γ) ↔  ∀ (γ : Γ), (f ∣[k] (γ : GL(2, ℝ)⁺)) = f := iff.rfl\n\n/--A function `f:ℍ → ℂ` is modular, of level `Γ` and weight `k ∈ ℤ`, if for every matrix in\n `γ ∈  Γ` we have `f(γ  • z)= (c*z+d)^k f(z)` where `γ= ![![a, b], ![c, d]]`,\n and it acts on `ℍ` via Moebius trainsformations. -/\n@[simp] lemma wmodular_mem' (k : ℤ) (Γ : subgroup SL(2,ℤ)) (f : ℍ' → ℂ) :\n  f ∈ (weakly_modular_submodule_weight_k k Γ) ↔  ∀ γ : Γ, ∀ z : ℍ,\n  f ((γ : matrix.GL_pos (fin 2) ℝ) • z) = ((↑ₘγ 1 0 : ℝ) * z +(↑ₘγ 1 1 : ℝ))^k * f z :=\nbegin\n  simp only [wmodular_mem],\n  split,\n  intros h1 γ z,\n  have h2:= h1 γ,\n  have h3: (f ∣[k] γ) z = f z , by {simp_rw h2},\n  rw ← h3,\n  simp_rw slash,\n  rw mul_comm,\n  have h5:= upper_half_plane.denom_ne_zero (γ : GL(2, ℝ)⁺) z,\n  simp only [coe_fn_coe_base, ne.def, matrix.general_linear_group.coe_fn_eq_coe, coe_coe] at h5,\n  have pown := zpow_ne_zero k h5,\n  have h55:= inv_mul_cancel pown,\n  simp_rw upper_half_plane.denom at *,\n  simp only [coe_coe, matrix.special_linear_group.coe_GL_pos_coe_GL_coe_matrix,\n  matrix.special_linear_group.coe_matrix_coe, int.coe_cast_ring_hom,\n  matrix.map_apply, of_real_int_cast],\n  simp [matrix.special_linear_group.coe_GL_pos_coe_GL_coe_matrix] at h55,\n  rw mul_assoc,\n  simp_rw [h55],\n  simp,\n  simp_rw [←int.coe_cast_ring_hom],\n  simp_rw ←matrix.special_linear_group.coe_matrix_coe,\n  have := matrix.special_linear_group.det_coe ((γ : SL(2, ℤ) ) : SL(2, ℝ)),\n  rw this,\n  simp,\n  sorry,\n  intros hf γ,\n  simp_rw slash,\n  ext1,\n  have hff:= hf γ x,\n  rw hff,\n  rw mul_comm,\n  have h5:= upper_half_plane.denom_ne_zero (γ : GL(2, ℝ)⁺) x,\n  simp only [coe_fn_coe_base, ne.def, matrix.general_linear_group.coe_fn_eq_coe, coe_coe] at h5,\n  have pown := zpow_ne_zero k h5,\n  have h55:= inv_mul_cancel pown,\n  simp_rw upper_half_plane.denom at *,\n  simp [matrix.special_linear_group.coe_GL_pos_coe_GL_coe_matrix] at h55,\n  simp only [coe_coe, matrix.special_linear_group.coe_GL_pos_coe_GL_coe_matrix,\n  matrix.map_apply, of_real_int_cast],\n  have := matrix.special_linear_group.det_coe ((γ : SL(2, ℤ) ) : SL(2, ℝ)),\n  rw this,\n  simp,\n  rw ← mul_assoc,\n  simp_rw h55,\n  simp,\nend\n\nlemma mul_modular  (k_1 k_2 : ℤ) (Γ : subgroup SL(2,ℤ)) (f g : ℍ' → ℂ)\n  (hf : f ∈ weakly_modular_submodule_weight_k k_1 Γ)  (hg : g ∈ weakly_modular_submodule_weight_k k_2 Γ) :\n  f * g  ∈ weakly_modular_submodule_weight_k (k_1+k_2) Γ :=\nbegin\n  simp only [wmodular_mem', pi.mul_apply, coe_coe] at *,\n  intros γ z,\n  have hff:= hf γ z,\n  have hgg:= hg γ z,\n  rw [hff,hgg],\n  have h5:= upper_half_plane.denom_ne_zero (γ : GL(2, ℝ)⁺) z,\n  simp_rw upper_half_plane.denom at h5,\n  simp only [coe_fn_coe_base, ne.def, matrix.general_linear_group.coe_fn_eq_coe, coe_coe] at h5,\n  have pown := zpow_add₀ h5 k_1 k_2,\n  rw pown,\n  ring,\nend\n\n/--The extension of a function from `ℍ` to `ℍ'`-/\ndef hol_extn (f : ℍ → ℂ) : ℍ' → ℂ := λ (z : ℍ'), (f (z : ℍ) )\n\n\n-/\n", "meta": {"author": "ferrandf", "repo": "valenceformula", "sha": "c542edc32e3fc0ef142d69a0c897192f040e4b3e", "save_path": "github-repos/lean/ferrandf-valenceformula", "path": "github-repos/lean/ferrandf-valenceformula/valenceformula-c542edc32e3fc0ef142d69a0c897192f040e4b3e/src/mod_f.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583168, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.47998125794458724}}
{"text": "import data.optree\nimport data.vect\nimport data.finord\n\nuniverses u v\n\n-- Structure for algebraic theories\nstructure theory :=\n  mk :: (op : ℕ → Type) (rel : ℕ → Type)\n        (rel_lhs : ∀ {n : ℕ}, rel n → optree op (finord n))\n        (rel_rhs : ∀ {n : ℕ}, rel n → optree op (finord n))\n\n\n-- Pre-model of a theory; i.e. sets with structure maps which not necessarily satisfy the axioms.\nclass premodel (th : theory) (α : Type u) : Type u :=\n  mk :: (act : Π {n : ℕ}, th.op n → vect α n → α)\n\n-- Model of a theory\nclass model (th : theory) (α : Type u) extends premodel th α : Type u:=\n  mk :: (haxiom : ∀ {n : ℕ} (r : th.rel n) (var : finord n → α), (th.rel_lhs r).elim @act var = (th.rel_rhs r).elim @act var)\n\ninstance model_is_premodel(th : theory) (α : Type _) [ha : model th α] : premodel th α := ha.to_premodel\n\n\nnamespace premodel\n\ndefinition action (th : theory) (α : Type _) [premodel th α] : Π {n : ℕ}, th.op n → vect α n → α := @premodel.act th α _\n\nend premodel\n\n\nnamespace model\n\ndefinition axiom_eq (th : theory) (α : Type _) [model th α] : ∀ {n : ℕ} (r : th.rel n) (var : finord n → α), (th.rel_lhs r).elim (@premodel.act th α _) var = (th.rel_rhs r).elim (@premodel.act th α _) var := @model.haxiom th α _\n\n--- Trivial model; `unit` is always a model of any algebraic theory.\ninstance triv (th : theory) : model th unit :=\n{\n  act := λ _ _ _, (),\n  haxiom :=\n    begin\n      intros,\n      dsimp [premodel.act],\n      have : ∀ {x y: unit}, x=y,\n        by intros  x y; cases x; cases y; refl,\n      exact this\n    end\n}\n\n#print axioms model.triv\n\nend model\n\n\n/-*****************************\n - Morphisms of pre-models\n -*****************************-/\n\n@[reducible]\ndefinition is_morphism (th : theory) {α : Type u} {β : Type v} [premodel th α] [premodel th β] (f : α → β) : Prop := ∀ {n : ℕ} (μ : th.op n) (as : vect α n), f (@premodel.act th α _ _ μ as) = (@premodel.act th β _ _ μ (as.map f))\n\ndefinition morphism (th : theory) (α : Type _) (β : Type _) [premodel th α] [premodel th β] := {f : α → β // is_morphism th f}\n\nnamespace morphism\n\nprotected\ndefinition coe_to_fun {th : theory} (α : Type _) (β : Type _) [premodel th α] [premodel th β] : has_coe_to_fun (morphism th α β)  :=\n  {\n    F := λ_, α → β,\n    coe := subtype.val\n  }\n\nattribute [instance] morphism.coe_to_fun\n\n-- the identity morphism\ndefinition id {th : theory} {α : Type _} [premodel th α] : morphism th α α :=\n  ⟨id, by intros n u as; rw [vect.map_id]; refl⟩\n\n-- the composition of morphisms\ndefinition comp {th : theory} {α β γ : Type _} [premodel th α] [premodel th β] [premodel th γ] : morphism th β γ → morphism th α β → morphism th α γ :=\n  λ g f, ⟨g.val ∘ f.val, by intros n k cs; unfold function.comp; rw [vect.map_comp,f.property,g.property]⟩\n\n#print axioms morphism.comp\n\n-- Two morphisms equal to each other as soon as their underlying maps do\ntheorem morphism_eq {th : theory} {α β : Type _} [premodel th α] [premodel th β] {f g : morphism th α β} : f.val = g.val → f = g := subtype.eq\n\n#print axioms morphism_eq\n\n-- The image of every morphism is closed under operations\ntheorem image_act {th : theory} {α β : Type _} [premodel th α] [premodel th β] (f : morphism th α β) : ∀ {n : ℕ} {k : th.op n} {ys : vect {b // ∃ a, f.val a = b} n}, ∃ a, f.val a = (@premodel.act th β _ _ k) (vect.map subtype.val ys) :=\n  begin\n    intros,\n    apply exists.elim (vect.image ys),\n    intros as has,\n    existsi (@premodel.act th α _ _ k) as,\n    rw [f.property, has]\n  end\n\n#print axioms image_act\n\n-- The image of a morphism forms a premodel\ndefinition image_premodel {th : theory} {α β : Type _} [premodel th α] [premodel th β] (f : morphism th α β) : premodel th {b // ∃ a, f.val a = b} :=\n  {\n    act :=\n      λ n k xs, ⟨@premodel.act th β _ _ k (vect.map subtype.val xs), image_act f⟩\n  }\n\n-- The image of a morphism in a model forms a model\ndefinition image_model {th : theory} {α β : Type _} [premodel th α] [model th β] (f : morphism th α β) : model th {b // ∃ a, f.val a = b} :=\n  {\n    to_premodel := image_premodel f,\n    haxiom :=\n      begin\n        intros,\n        dsimp [image_premodel] at *,\n        apply subtype.eq,\n        rw [optree.elim_subtype,optree.elim_subtype],\n        rw [model.axiom_eq]\n      end\n  }\n\n#print axioms image_model\n\nend morphism\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/algebra/theory/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7490872243177519, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.47989212402126913}}
{"text": "import algebra.category.Group.biproducts\nimport algebra.category.Group.abelian\nimport algebra.direct_sum.basic\nimport category_theory.preadditive.yoneda\nimport for_mathlib.AddCommGroup.epi\n\nopen category_theory\nopen category_theory.limits\n\ndef dfinsupp.add_equiv_pi_on_fintype {α : Type*} [fintype α] (X : α → Type*)\n  [∀ i, add_comm_group (X i)] :\n  (Π₀ i, X i) ≃+ (Π i, X i) :=\n{ map_add' := λ x y, by { ext, simp, },\n  ..dfinsupp.equiv_fun_on_fintype }\n\nnamespace AddCommGroup\n\nuniverses v u\n\ndef pi_π {α : Type v} (X : α → AddCommGroup.{max v u}) (i) :\n  AddCommGroup.of (Π i, X i) ⟶ X i :=\npi.eval_add_monoid_hom _ _\n\ndef pi_fan {α : Type v} (X : α → AddCommGroup.{max v u}) : fan X :=\nfan.mk (AddCommGroup.of $ Π i, X i)\n(λ b, pi_π _ _)\n\ndef pi_lift {α : Type v} {Y : AddCommGroup.{max v u}} (X : α → AddCommGroup.{max v u})\n  (f : Π a, Y ⟶ X a) : Y ⟶ AddCommGroup.of (Π i, X i) :=\n{ to_fun := λ y i, f _ y,\n  map_zero' := by { ext, simp },\n  map_add' := λ x y, by { ext, simp } }\n\n@[simp, reassoc]\nlemma pi_lift_π {α : Type v} {Y : AddCommGroup.{max v u}} (X : α → AddCommGroup.{max v u})\n  (f : Π a, Y ⟶ X a) (i) :\n  pi_lift X f ≫ pi_π _ i = f _ := by { ext, refl }\n\nlemma pi_hom_ext {α : Type v} {Y : AddCommGroup.{max v u}} (X : α → AddCommGroup.{max v u})\n  (f g : Y ⟶ AddCommGroup.of (Π i, X i))\n  (h : ∀ i, f ≫ pi_π _ i = g ≫ pi_π _ i) : f = g :=\nby { ext y a, specialize h a, apply_fun (λ e, e y) at h, exact h }\n\ndef is_limit_pi_fan {α : Type v} (X : α → AddCommGroup.{max v u}) :\n  is_limit (pi_fan X) :=\n{ lift := λ S, pi_lift _ $ λ a, S.π.app ⟨_⟩,\n  fac' := begin\n    rintros S ⟨j⟩,\n    apply pi_lift_π,\n  end,\n  uniq' := begin\n    intros S m hm,\n    apply pi_hom_ext,\n    intros i,\n    erw [hm ⟨i⟩, pi_lift_π],\n  end }\n\nnoncomputable\ndef hom_product_comparison\n  {α : Type v}\n  (A : AddCommGroup.{max v u})\n  (X : α → AddCommGroup.{max v u}) :\n  AddCommGroup.of (A ⟶ ∏ X) ⟶ ∏ (λ i, AddCommGroup.of (A ⟶ (X i))) :=\nlimits.pi.lift $ λ a, (preadditive_yoneda.flip.obj (opposite.op A)).map (limits.pi.π _ _)\n\ninstance is_iso_hom_product_comparison\n  {α : Type v}\n  (A : AddCommGroup.{max v u})\n  (X : α → AddCommGroup.{max v u}) :\n  is_iso (hom_product_comparison A X) :=\nbegin\n  --haveI : balanced Ab.{max v u} := AddcommGroup.abelian\n  let t : (∏ λ (i : α), AddCommGroup.of (A ⟶ X i)) ≅ AddCommGroup.of\n    (Π i, AddCommGroup.of (A ⟶ X i)) :=\n    (limits.limit.is_limit _).cone_point_unique_up_to_iso\n    (is_limit_pi_fan (λ i, of (A ⟶ X i))),\n  suffices : is_iso (A.hom_product_comparison X ≫ t.hom),\n  { apply is_iso.of_is_iso_comp_right _ t.hom, exact this },\n  have ht : A.hom_product_comparison X ≫ t.hom =\n    (is_limit_pi_fan (λ i, of (A ⟶ X i))).lift\n    ⟨_, discrete.nat_trans $ λ i, (preadditive_yoneda.flip.obj (opposite.op A)).map\n      (limits.pi.π _ _)⟩,\n  { apply (is_limit_pi_fan _).hom_ext, intros j,\n    simp [hom_product_comparison] },\n  rw ht, clear ht,\n  apply_with is_iso_of_mono_of_epi { instances := ff },\n  apply_instance,\n  { rw mono_iff_injective,\n    intros f g h,\n    ext1 ⟨j⟩,\n    apply_fun (λ e, e j) at h,\n    exact h },\n  { rw epi_iff_surjective,\n    intros f,\n    use limits.pi.lift (λ i, f i),\n    dsimp [is_limit_pi_fan, pi_lift],\n    simp [pi_lift_π] }\nend\n\ndef direct_sum_π {α : Type v} (X : α → AddCommGroup.{max v u}) (i) :\n  AddCommGroup.of (direct_sum α (λ i, X i)) ⟶ X i :=\n{ to_fun := λ f, let e : Π₀ (i : α), (X i) := f in e i,\n  map_zero' := by simp,\n  map_add' := λ x y, by { dsimp, simp } }\n\ndef direct_sum_fan {α : Type v} (X : α → AddCommGroup.{max v u}) : fan X :=\nfan.mk (AddCommGroup.of (direct_sum α (λ i, X i)))\n(λ b, direct_sum_π _ _)\n\nopen_locale classical\n\ndef direct_sum_lift {α : Type v} [fintype α]\n  {Y : AddCommGroup.{max v u}} (X : α → AddCommGroup.{max v u})\n  (f : Π a, Y ⟶ X a) :\n  Y ⟶ AddCommGroup.of (direct_sum α (λ i, X i)) :=\n{ to_fun := λ y, (dfinsupp.add_equiv_pi_on_fintype _).symm $ λ i, f i y,\n  map_zero' := begin\n    simp_rw map_zero,\n    change ((dfinsupp.add_equiv_pi_on_fintype (λ (i : α), ↥(X i))).symm) 0 = _,\n    simp,\n  end,\n  map_add' := begin\n    intros x y,\n    simp_rw map_add,\n    change ((dfinsupp.add_equiv_pi_on_fintype (λ (i : α), ↥(X i))).symm)\n      ((λ (i : α), (f i) x) + (λ (i : α), (f i) y)) = _,\n    simp,\n  end }\n\n@[simp, reassoc]\nlemma direct_sum_lift_π {α : Type v} [fintype α]\n  {Y : AddCommGroup.{max v u}} (X : α → AddCommGroup.{max v u})\n  (f : Π a, Y ⟶ X a) (i) :\n  direct_sum_lift X f ≫ direct_sum_π _ i = f i :=\nby { ext, refl }\n\nlemma direct_sum_hom_ext {α : Type v} [fintype α]\n  {Y : AddCommGroup.{max v u}} (X : α → AddCommGroup.{max v u})\n  (f g : Y ⟶ AddCommGroup.of (direct_sum α (λ i, X i)))\n  (h : ∀ i, f ≫ direct_sum_π _ i = g ≫ direct_sum_π _ i) :\n  f = g :=\nbegin\n  ext,\n  specialize h i,\n  apply_fun (λ e, e x) at h, exact h\nend\n\ndef is_limit_direct_sum_fan {α : Type v} [fintype α]\n  (X : α → AddCommGroup.{max v u}) : is_limit (direct_sum_fan X) :=\n{ lift := λ S, direct_sum_lift _ $ λ a, S.π.app ⟨a⟩, -- S.π.app,\n  fac' := begin\n    rintros S ⟨j⟩,\n    apply direct_sum_lift_π,\n  end,\n  uniq' := begin\n    intros S m hm,\n    apply direct_sum_hom_ext,\n    intros i,\n    specialize hm ⟨i⟩,\n    erw [hm, direct_sum_lift_π],\n  end }\n\nnoncomputable theory\n\ndef to_direct_sum {α : Type v} (X : α → AddCommGroup.{max v u})\n  (i : α) : X i ⟶ AddCommGroup.of (direct_sum α (λ i, X i)) :=\ndirect_sum.of (λ i, X i) i\n\ndef direct_sum_punit_iso (A : AddCommGroup.{max v u}) :\n  AddCommGroup.of (direct_sum _ (λ i : punit.{v+1}, A)) ≅ A :=\n{ hom := direct_sum_π _ punit.star,\n  inv := to_direct_sum (λ i, A) punit.star,\n  hom_inv_id' := begin\n    ext ⟨⟩ ⟨⟩,\n    ext t ⟨⟩, -- WAT?\n    dsimp [direct_sum_π, to_direct_sum],\n    simp,\n  end,\n  inv_hom_id' := begin\n    ext a,\n    dsimp [direct_sum_π, to_direct_sum],\n    simp,\n  end }\n\ndef direct_sum_ι {α : Type v} (X : α → AddCommGroup.{max v u})\n  (i : α) : X i ⟶ AddCommGroup.of (direct_sum α (λ i, X i)) :=\ndirect_sum.of _ i\n\ndef direct_sum_desc {α : Type v} {Y : AddCommGroup.{max v u}} (X : α → AddCommGroup.{max v u})\n  (f : Π i, X i ⟶ Y) :\n  AddCommGroup.of (direct_sum α (λ i, X i)) ⟶ Y :=\ndirect_sum.to_add_monoid f\n\n@[simp, reassoc]\nlemma direct_sum_ι_desc {α : Type v} {Y : AddCommGroup.{max v u}}\n  (X : α → AddCommGroup.{max v u})\n  (f : Π i, X i ⟶ Y) (i) :\n  direct_sum_ι X i ≫ direct_sum_desc X f = f _ :=\nby { ext, dsimp [direct_sum_ι, direct_sum_desc], simp }\n\nlemma direct_sum_hom_ext' {α : Type v} {Y : AddCommGroup.{max v u}}\n  (X : α → AddCommGroup.{max v u})\n  (f g : AddCommGroup.of (direct_sum α (λ i, X i)) ⟶ Y)\n  (h : ∀ i, direct_sum_ι X i ≫ f = direct_sum_ι X i ≫ g) :\n  f = g :=\nbegin\n  have hf : f = direct_sum_desc X (λ i, direct_sum_ι X i ≫ f),\n  { ext t, apply direct_sum.to_add_monoid.unique },\n  have hg : g = direct_sum_desc X (λ i, direct_sum_ι X i ≫ g),\n  { ext t, apply direct_sum.to_add_monoid.unique },\n  rw [hf, hg],\n  congr' 1, ext i, rw h,\nend\n\ndef direct_sum_cofan {α : Type v}\n  (X : α → AddCommGroup.{max v u}) : cofan X :=\ncofan.mk _ (direct_sum_ι _)\n\ndef is_colimit_direct_sum_cofan {α : Type v}\n  (X : α → AddCommGroup.{max v u}) : is_colimit (direct_sum_cofan X) :=\n{ desc := λ S, direct_sum_desc X (λ a, S.ι.app ⟨a⟩), -- S.ι.app,\n  fac' := begin\n    rintros X ⟨j⟩,\n    apply direct_sum_ι_desc,\n  end,\n  uniq' := begin\n    intros S m hm,\n    apply direct_sum_hom_ext',\n    intros i,\n    specialize hm ⟨i⟩,\n    erw hm, rw direct_sum_ι_desc,\n  end }\n\nlemma direct_sum_ι_π {α : Type v} (X : α → AddCommGroup.{max v u}) (i : α) :\n  direct_sum_ι.{v u} X i ≫ direct_sum_π.{v u} X i = 𝟙 _ :=\nbegin\n  ext,\n  dsimp [direct_sum_ι, direct_sum_π, direct_sum.of],\n  simp only [comp_apply, dfinsupp.single_add_hom_apply, add_monoid_hom.coe_mk,\n    dfinsupp.single_apply],\n  split_ifs, refl, refl,\nend\n\nlemma direct_sum_ι_π_of_ne {α : Type v} (X : α → AddCommGroup.{max v u}) (i j : α) (h : i ≠ j):\n  direct_sum_ι.{v u} X i ≫ direct_sum_π.{v u} X j = 0 :=\nbegin\n  ext,\n  dsimp [direct_sum_ι, direct_sum_π, direct_sum.of],\n  simp only [comp_apply, dfinsupp.single_add_hom_apply, add_monoid_hom.coe_mk,\n    dfinsupp.single_apply],\n  split_ifs, contradiction, refl,\nend\n\n-- `bicone` is not sufficiently universe polymorphic.\ndef direct_sum_bicone {α : Type u} [fintype α]\n  (X : α → AddCommGroup.{u}) : bicone X :=\n{ X := AddCommGroup.of (direct_sum α (λ i, X i)),\n  π := direct_sum_π.{u u} _,\n  ι := direct_sum_ι.{u u} _,\n  ι_π := λ i j, begin\n    ext t,\n    dsimp [direct_sum_ι, direct_sum_π, direct_sum.of],\n    simp only [comp_apply, dfinsupp.single_add_hom_apply, add_monoid_hom.coe_mk,\n      dfinsupp.single_apply],\n    split_ifs, subst h, refl, refl,\n  end }\n\ndef is_bilimit_direct_sum_bicone {α : Type u} [fintype α]\n  (X : α → AddCommGroup.{u}) :\n  bicone.is_bilimit (direct_sum_bicone X) :=\n{ is_limit := is_limit_direct_sum_fan.{u u} X,\n  is_colimit := is_colimit_direct_sum_cofan.{u u} X }\n\nend AddCommGroup\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/AddCommGroup/explicit_products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.47989211994633113}}
{"text": "variables (f : ℕ → ℕ) (k : ℕ)\n\nexample (h₁ : f 0 = 0) (h₂ : k = 0) : f k = 0 :=\n  by rw [h₂, h₁]\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch5/ex0603.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.47989211684421024}}
{"text": "import data.int.parity data.int.modeq ring_theory.coprime.lemmas\n\n/-! # IMO 2015 N1 -/\n\nnamespace IMOSL\nnamespace IMO2015N1\n\nopen function\n\ndef f (n : ℤ) := n * (n / 2)\n\n/-- Final solution -/\ntheorem final_solution (n : ℤ) : (∃ k : ℕ, even (f^[k] n)) ↔ n ≠ 3 :=\nbegin\n  ---- Go for the contrapositive and prove the easy direction\n  rw [← not_iff_not, not_not, not_exists, iff.comm]; split,\n  rintros rfl,\n  suffices : ∀ x : ℕ, f^[x] 3 = 3,\n    intros x; rw this; norm_num,\n  intros x; induction x with x x_ih,\n  rw [iterate_zero, id.def],\n  rw [iterate_succ', comp_app, x_ih]; refl,\n\n  ---- Reduce to a more general result\n  revert n; suffices : ∀ {n c : ℤ},\n    c ≠ 0 → n ≡ 3 [ZMOD 2 * c] → f n ≡ 3 [ZMOD 2 * c] → n ≡ 3 [ZMOD 2 * (2 * c)],\n  { intros n h,\n    suffices : ∀ x k : ℕ, (f^[k] n) ≡ 3 [ZMOD 2 ^ x],\n    { obtain ⟨x, h0⟩ : ∃ x : ℕ, (n - 3).nat_abs < x :=\n        ⟨(n - 3).nat_abs.succ, nat.lt_succ_self _⟩,\n      replace this := (this x 0).symm,\n      rw [iterate_zero, id.def, int.modeq_iff_dvd] at this,\n      replace h0 := lt_trans h0 (nat.lt_two_pow x),\n      rw [← int.coe_nat_lt, nat.cast_pow, nat.cast_two, ← int.abs_eq_nat_abs] at h0,\n      rw ← sub_eq_zero; exact int.eq_zero_of_abs_lt_dvd this h0 },\n    intros x; cases x with _ x,\n    intros k; rw pow_zero; exact int.modeq_one,\n    induction x with x h0; intros k,\n    rw [pow_one, int.modeq_iff_dvd, ← even_iff_two_dvd, int.even_sub'],\n    norm_num; exact h k,\n    refine this (pow_ne_zero _ two_ne_zero) (h0 k) _,\n    convert h0 k.succ; rw iterate_succ' },\n\n  ---- Prove the general result\n  intros n c hc h h0,\n  replace h := h.symm,\n  rw int.modeq_iff_dvd at h; cases h with d h,\n  rw sub_eq_iff_eq_add at h; subst h,\n  symmetry; rw [int.modeq_iff_dvd, add_sub_cancel, mul_comm],\n  refine mul_dvd_mul_left (2 * c) _,\n  unfold f at h0,\n  replace h0 : 3 ≡ 3 * ((2 * c * d + 3) / 2) [ZMOD 2 * c] :=\n    h0.symm.trans (int.modeq.mul_right _ (by rw [int.modeq_iff_dvd, add_sub_cancel]; use d)).symm,\n  rw [int.modeq_iff_dvd, mul_assoc, add_comm, int.add_mul_div_left _ _ two_ne_zero] at h0,\n  norm_num at h0,\n  rwa [← mul_sub_one, add_sub_cancel', mul_comm c, ← mul_assoc, bit1,\n       mul_dvd_mul_iff_right hc, add_one_mul, dvd_add_right ⟨d, rfl⟩] at h0\nend\n\nend IMO2015N1\nend IMOSL\n", "meta": {"author": "mortarsanjaya", "repo": "imo-A-and-N", "sha": "645a924da7442f41d56ee6a0d96dc4d777b593a9", "save_path": "github-repos/lean/mortarsanjaya-imo-A-and-N", "path": "github-repos/lean/mortarsanjaya-imo-A-and-N/imo-A-and-N-645a924da7442f41d56ee6a0d96dc4d777b593a9/src/IMO2015/N1/N1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6619228825191871, "lm_q1q2_score": 0.47980823052782257}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport algebra.punit_instances\nimport linear_algebra.finsupp\nimport ring_theory.nilpotent\nimport ring_theory.localization.away\nimport ring_theory.ideal.prod\nimport ring_theory.ideal.over\nimport topology.sets.opens\nimport topology.sober\n\n/-!\n# Prime spectrum of a commutative ring\n\nThe prime spectrum of a commutative ring is the type of all prime ideals.\nIt is naturally endowed with a topology: the Zariski topology.\n\n(It is also naturally endowed with a sheaf of rings,\nwhich is constructed in `algebraic_geometry.structure_sheaf`.)\n\n## Main definitions\n\n* `prime_spectrum R`: The prime spectrum of a commutative ring `R`,\n  i.e., the set of all prime ideals of `R`.\n* `zero_locus s`: The zero locus of a subset `s` of `R`\n  is the subset of `prime_spectrum R` consisting of all prime ideals that contain `s`.\n* `vanishing_ideal t`: The vanishing ideal of a subset `t` of `prime_spectrum R`\n  is the intersection of points in `t` (viewed as prime ideals).\n\n## Conventions\n\nWe denote subsets of rings with `s`, `s'`, etc...\nwhereas we denote subsets of prime spectra with `t`, `t'`, etc...\n\n## Inspiration/contributors\n\nThe contents of this file draw inspiration from\n<https://github.com/ramonfmir/lean-scheme>\nwhich has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,\nand Chris Hughes (on an earlier repository).\n\n-/\n\nnoncomputable theory\nopen_locale classical\n\nuniverses u v\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The prime spectrum of a commutative ring `R`\nis the type of all prime ideals of `R`.\n\nIt is naturally endowed with a topology (the Zariski topology),\nand a sheaf of commutative rings (see `algebraic_geometry.structure_sheaf`).\nIt is a fundamental building block in algebraic geometry. -/\n@[nolint has_inhabited_instance]\ndef prime_spectrum := {I : ideal R // I.is_prime}\n\nvariable {R}\n\nnamespace prime_spectrum\n\n/-- A method to view a point in the prime spectrum of a commutative ring\nas an ideal of that ring. -/\nabbreviation as_ideal (x : prime_spectrum R) : ideal R := x.val\n\ninstance is_prime (x : prime_spectrum R) :\n  x.as_ideal.is_prime := x.2\n\n/--\nThe prime spectrum of the zero ring is empty.\n-/\nlemma punit (x : prime_spectrum punit) : false :=\nx.1.ne_top_iff_one.1 x.2.1 $ subsingleton.elim (0 : punit) 1 ▸ x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of\n    `R` and the prime spectrum of `S`. -/\nnoncomputable def prime_spectrum_prod :\n  prime_spectrum (R × S) ≃ prime_spectrum R ⊕ prime_spectrum S :=\nideal.prime_ideals_equiv R S\n\nvariables {R S}\n\n@[simp] lemma prime_spectrum_prod_symm_inl_as_ideal (x : prime_spectrum R) :\n  ((prime_spectrum_prod R S).symm (sum.inl x)).as_ideal = ideal.prod x.as_ideal ⊤ :=\nby { cases x, refl }\n@[simp] lemma prime_spectrum_prod_symm_inr_as_ideal (x : prime_spectrum S) :\n  ((prime_spectrum_prod R S).symm (sum.inr x)).as_ideal = ideal.prod ⊤ x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y ↔ x.as_ideal = y.as_ideal :=\nsubtype.ext_iff_val\n\n/-- The zero locus of a set `s` of elements of a commutative ring `R`\nis the set of all prime ideals of the ring that contain the set `s`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `zero_locus s` is exactly the subset of `prime_spectrum R`\nwhere all \"functions\" in `s` vanish simultaneously.\n-/\ndef zero_locus (s : set R) : set (prime_spectrum R) :=\n{x | s ⊆ x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x ∈ zero_locus s ↔ s ⊆ x.as_ideal := iff.rfl\n\n@[simp] lemma zero_locus_span (s : set R) :\n  zero_locus (ideal.span s : set R) = zero_locus s :=\nby { ext x, exact (submodule.gi R R).gc s x.as_ideal }\n\n/-- The vanishing ideal of a set `t` of points\nof the prime spectrum of a commutative ring `R`\nis the intersection of all the prime ideals in the set `t`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `vanishing_ideal t` is exactly the ideal of `R`\nconsisting of all \"functions\" that vanish on all of `t`.\n-/\ndef vanishing_ideal (t : set (prime_spectrum R)) : ideal R :=\n⨅ (x : prime_spectrum R) (h : x ∈ t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal} :=\nbegin\n  ext f,\n  rw [vanishing_ideal, set_like.mem_coe, submodule.mem_infi],\n  apply forall_congr, intro x,\n  rw [submodule.mem_infi],\nend\n\nlemma mem_vanishing_ideal (t : set (prime_spectrum R)) (f : R) :\n  f ∈ vanishing_ideal t ↔ ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal :=\nby rw [← set_like.mem_coe, coe_vanishing_ideal, set.mem_set_of_eq]\n\n@[simp] lemma vanishing_ideal_singleton (x : prime_spectrum R) :\n  vanishing_ideal ({x} : set (prime_spectrum R)) = x.as_ideal :=\nby simp [vanishing_ideal]\n\nlemma subset_zero_locus_iff_le_vanishing_ideal (t : set (prime_spectrum R)) (I : ideal R) :\n  t ⊆ zero_locus I ↔ I ≤ vanishing_ideal t :=\n⟨λ h f k, (mem_vanishing_ideal _ _).mpr (λ x j, (mem_zero_locus _ _).mpr (h j) k), λ h,\n  λ x j, (mem_zero_locus _ _).mpr (le_trans h (λ f h, ((mem_vanishing_ideal _ _).mp h) x j))⟩\n\nsection gc\nvariable (R)\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc : @galois_connection\n  (ideal R) (order_dual (set (prime_spectrum R))) _ _\n  (λ I, zero_locus I) (λ t, vanishing_ideal t) :=\nλ I t, subset_zero_locus_iff_le_vanishing_ideal t I\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc_set : @galois_connection\n  (set R) (order_dual (set (prime_spectrum R))) _ _\n  (λ s, zero_locus s) (λ t, vanishing_ideal t) :=\nhave ideal_gc : galois_connection (ideal.span) coe := (submodule.gi R R).gc,\nby simpa [zero_locus_span, function.comp] using ideal_gc.compose (gc R)\n\nlemma subset_zero_locus_iff_subset_vanishing_ideal (t : set (prime_spectrum R)) (s : set R) :\n  t ⊆ zero_locus s ↔ s ⊆ vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s ⊆ vanishing_ideal (zero_locus s) :=\n(gc_set R).le_u_l s\n\nlemma le_vanishing_ideal_zero_locus (I : ideal R) :\n  I ≤ vanishing_ideal (zero_locus I) :=\n(gc R).le_u_l I\n\n@[simp] lemma vanishing_ideal_zero_locus_eq_radical (I : ideal R) :\n  vanishing_ideal (zero_locus (I : set R)) = I.radical := ideal.ext $ λ f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact ⟨(λ h x hx, h ⟨x, hx.2⟩ hx.1), (λ h x hx, h x.1 ⟨hx, x.2⟩)⟩\nend\n\n@[simp] lemma zero_locus_radical (I : ideal R) : zero_locus (I.radical : set R) = zero_locus I :=\nvanishing_ideal_zero_locus_eq_radical I ▸ (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t ⊆ zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s ⊆ t) : zero_locus t ⊆ zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s ≤ t) :\n  zero_locus (t : set R) ⊆ zero_locus (s : set R) :=\n(gc R).monotone_l h\n\nlemma vanishing_ideal_anti_mono {s t : set (prime_spectrum R)} (h : s ⊆ t) :\n  vanishing_ideal t ≤ vanishing_ideal s :=\n(gc R).monotone_u h\n\nlemma zero_locus_subset_zero_locus_iff (I J : ideal R) :\n  zero_locus (I : set R) ⊆ zero_locus (J : set R) ↔ J ≤ I.radical :=\n⟨λ h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I ▸\n  vanishing_ideal_zero_locus_eq_radical J ▸ vanishing_ideal_anti_mono h),\nλ h, zero_locus_radical I ▸ zero_locus_anti_mono_ideal h⟩\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) ⊆ zero_locus {g} ↔ g ∈ (ideal.span ({f} : set R)).radical :=\nby rw [← zero_locus_span {f}, ← zero_locus_span {g}, zero_locus_subset_zero_locus_iff,\n    ideal.span_le, set.singleton_subset_iff, set_like.mem_coe]\n\nlemma zero_locus_bot :\n  zero_locus ((⊥ : ideal R) : set R) = set.univ :=\n(gc R).l_bot\n\n@[simp] lemma zero_locus_singleton_zero :\n  zero_locus ({0} : set R) = set.univ :=\nzero_locus_bot\n\n@[simp] lemma zero_locus_empty :\n  zero_locus (∅ : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (∅ : set (prime_spectrum R)) = ⊤ :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) ∈ s) :\n  zero_locus s = ∅ :=\nbegin\n  rw set.eq_empty_iff_forall_not_mem,\n  intros x hx,\n  rw mem_zero_locus at hx,\n  have x_prime : x.as_ideal.is_prime := by apply_instance,\n  have eq_top : x.as_ideal = ⊤, { rw ideal.eq_top_iff_one, exact hx h },\n  apply x_prime.ne_top eq_top,\nend\n\n@[simp] lemma zero_locus_singleton_one :\n  zero_locus ({1} : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_singleton (1 : R))\n\nlemma zero_locus_empty_iff_eq_top {I : ideal R} :\n  zero_locus (I : set R) = ∅ ↔ I = ⊤ :=\nbegin\n  split,\n  { contrapose!,\n    intro h,\n    apply set.ne_empty_iff_nonempty.mpr,\n    rcases ideal.exists_le_maximal I h with ⟨M, hM, hIM⟩,\n    exact ⟨⟨M, hM.is_prime⟩, hIM⟩ },\n  { rintro rfl, apply zero_locus_empty_of_one_mem, trivial }\nend\n\n@[simp] lemma zero_locus_univ :\n  zero_locus (set.univ : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I ⊔ J : ideal R) : set R) = zero_locus I ∩ zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s ∪ s') = zero_locus s ∩ zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t ∪ t') = vanishing_ideal t ⊓ vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {ι : Sort*} (I : ι → ideal R) :\n  zero_locus ((⨆ i, I i : ideal R) : set R) = (⋂ i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {ι : Sort*} (s : ι → set R) :\n  zero_locus (⋃ i, s i) = (⋂ i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (⋃ s' ∈ s, s' : set R) = ⋂ s' ∈ s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {ι : Sort*} (t : ι → set (prime_spectrum R)) :\n  vanishing_ideal (⋃ i, t i) = (⨅ i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I ⊓ J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s ∪ zero_locus s' = zero_locus ((ideal.span s) ⊓ (ideal.span s') : ideal R) :=\nby { rw zero_locus_inf, simp }\n\nlemma zero_locus_mul (I J : ideal R) :\n  zero_locus ((I * J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.mul_le\n\nlemma zero_locus_singleton_mul (f g : R) :\n  zero_locus ({f * g} : set R) = zero_locus {f} ∪ zero_locus {g} :=\nset.ext $ λ x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : ℕ} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) ▸ (I.radical_pow n hn).symm ▸ zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : ℕ) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ λ x, by simpa using x.2.pow_mem_iff_mem n hn\n\nlemma sup_vanishing_ideal_le (t t' : set (prime_spectrum R)) :\n  vanishing_ideal t ⊔ vanishing_ideal t' ≤ vanishing_ideal (t ∩ t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro ⟨f, hf, g, hg, rfl⟩ x ⟨hxt, hxt'⟩,\n  rw mem_vanishing_ideal at hf hg,\n  apply submodule.add_mem; solve_by_elim\nend\n\nlemma mem_compl_zero_locus_iff_not_mem {f : R} {I : prime_spectrum R} :\n  I ∈ (zero_locus {f} : set (prime_spectrum R))ᶜ ↔ f ∉ I.as_ideal :=\nby rw [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]; refl\n\n/-- The Zariski topology on the prime spectrum of a commutative ring\nis defined via the closed sets of the topology:\nthey are exactly those sets that are the zero locus of a subset of the ring. -/\ninstance zariski_topology : topological_space (prime_spectrum R) :=\ntopological_space.of_closed (set.range prime_spectrum.zero_locus)\n  (⟨set.univ, by simp⟩)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs → set R := λ i, classical.some (h i.2),\n    have hf : ∀ i : Zs, ↑i = zero_locus (f i) := λ i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact ⟨_, zero_locus_Union _⟩\n  end\n  (by { rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩, exact ⟨_, (union_zero_locus s t).symm⟩ })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U ↔ ∃ s, Uᶜ = zero_locus s :=\nby simp only [@eq_comm _ Uᶜ]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ s, Z = zero_locus s :=\nby rw [← is_open_compl_iff, is_open_iff, compl_compl]\n\nlemma is_closed_iff_zero_locus_ideal (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ (s : ideal R), Z = zero_locus s :=\n(is_closed_iff_zero_locus _).trans\n  ⟨λ x, ⟨_, x.some_spec.trans (zero_locus_span _).symm⟩, λ x, ⟨_, x.some_spec⟩⟩\n\nlemma is_closed_iff_zero_locus_radical_ideal (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ (s : ideal R), s.radical = s ∧ Z = zero_locus s :=\n(is_closed_iff_zero_locus_ideal _).trans\n  ⟨λ x, ⟨_, ideal.radical_idem _, x.some_spec.trans (zero_locus_radical _).symm⟩,\n    λ x, ⟨_, x.some_spec.2⟩⟩\n\nlemma is_closed_zero_locus (s : set R) :\n  is_closed (zero_locus s) :=\nby { rw [is_closed_iff_zero_locus], exact ⟨s, rfl⟩ }\n\nlemma is_closed_singleton_iff_is_maximal (x : prime_spectrum R) :\n  is_closed ({x} : set (prime_spectrum R)) ↔ x.as_ideal.is_maximal :=\nbegin\n  refine (is_closed_iff_zero_locus _).trans ⟨λ h, _, λ h, _⟩,\n  { obtain ⟨s, hs⟩ := h,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem] at hs,\n    refine ⟨⟨x.2.1, λ I hI, not_not.1 (mt (ideal.exists_le_maximal I) $\n      not_exists.2 (λ J, not_and.2 $ λ hJ hIJ,_))⟩⟩,\n    exact ne_of_lt (lt_of_lt_of_le hI hIJ) (symm $ congr_arg prime_spectrum.as_ideal\n      (hs.2 ⟨J, hJ.is_prime⟩ (λ r hr, hIJ (le_of_lt hI $ hs.1 hr)))) },\n  { refine ⟨x.as_ideal.1, _⟩,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem],\n    refine ⟨λ _ h, h, λ y hy, prime_spectrum.ext.2 (h.eq_of_le y.2.ne_top hy).symm⟩ }\nend\n\nlemma zero_locus_vanishing_ideal_eq_closure (t : set (prime_spectrum R)) :\n  zero_locus (vanishing_ideal t : set R) = closure t :=\nbegin\n  apply set.subset.antisymm,\n  { rintro x hx t' ⟨ht', ht⟩,\n    obtain ⟨fs, rfl⟩ : ∃ s, t' = zero_locus s,\n    by rwa [is_closed_iff_zero_locus] at ht',\n    rw [subset_zero_locus_iff_subset_vanishing_ideal] at ht,\n    exact set.subset.trans ht hx },\n  { rw (is_closed_zero_locus _).closure_subset_iff,\n    exact subset_zero_locus_vanishing_ideal t }\nend\n\nlemma vanishing_ideal_closure (t : set (prime_spectrum R)) :\n  vanishing_ideal (closure t) = vanishing_ideal t :=\nzero_locus_vanishing_ideal_eq_closure t ▸ (gc R).u_l_u_eq_u t\n\nlemma t1_space_iff_is_field [is_domain R] :\n  t1_space (prime_spectrum R) ↔ is_field R :=\nbegin\n  refine ⟨_, λ h, _⟩,\n  { introI h,\n    have hbot : ideal.is_prime (⊥ : ideal R) := ideal.bot_prime,\n    exact not_not.1 (mt (ring.ne_bot_of_is_maximal_of_not_is_field $\n      (is_closed_singleton_iff_is_maximal _).1 (t1_space.t1 ⟨⊥, hbot⟩)) (not_not.2 rfl)) },\n  { refine ⟨λ x, (is_closed_singleton_iff_is_maximal x).2 _⟩,\n    by_cases hx : x.as_ideal = ⊥,\n    { exact hx.symm ▸ @ideal.bot_is_maximal R (@field.to_division_ring _ h.to_field) },\n    { exact absurd h (ring.not_is_field_iff_exists_prime.2 ⟨x.as_ideal, ⟨hx, x.2⟩⟩) } }\nend\n\nlocal notation `Z(` a `)` := zero_locus (a : set R)\n\n\n\nlemma is_irreducible_zero_locus_iff (I : ideal R) :\n  is_irreducible (zero_locus (I : set R)) ↔ I.radical.is_prime :=\n(zero_locus_radical I) ▸ is_irreducible_zero_locus_iff_of_radical _ I.radical_idem\n\ninstance [is_domain R] : irreducible_space (prime_spectrum R) :=\nbegin\n  rw [irreducible_space_def, set.top_eq_univ, ← zero_locus_bot, is_irreducible_zero_locus_iff],\n  simpa using ideal.bot_prime\nend\n\ninstance : quasi_sober (prime_spectrum R) :=\nbegin\n  constructor,\n  intros S h₁ h₂,\n  rw [← h₂.closure_eq, ← zero_locus_vanishing_ideal_eq_closure,\n    is_irreducible_zero_locus_iff] at h₁,\n  use ⟨_, h₁⟩,\n  obtain ⟨s, hs, rfl⟩ := (is_closed_iff_zero_locus_radical_ideal _).mp h₂,\n  rw is_generic_point_iff_forall_closed h₂,\n  intros Z hZ hxZ,\n  obtain ⟨t, rfl⟩ := (is_closed_iff_zero_locus_ideal _).mp hZ,\n  exact zero_locus_anti_mono (by simpa [hs] using hxZ),\n  simp [hs]\nend\n\nsection comap\nvariables {S : Type v} [comm_ring S] {S' : Type*} [comm_ring S']\n\n\nlemma preimage_comap_zero_locus_aux (f : R →+* S) (s : set R) :\n  (λ y, ⟨ideal.comap f y.as_ideal, infer_instance⟩ :\n    prime_spectrum S → prime_spectrum R) ⁻¹' (zero_locus s) = zero_locus (f '' s) :=\nbegin\n  ext x,\n  simp only [mem_zero_locus, set.image_subset_iff],\n  refl\nend\n\n/-- The function between prime spectra of commutative rings induced by a ring homomorphism.\nThis function is continuous. -/\ndef comap (f : R →+* S) : C(prime_spectrum S, prime_spectrum R) :=\n{ to_fun := λ y, ⟨ideal.comap f y.as_ideal, infer_instance⟩,\n  continuous_to_fun :=\n    begin\n      simp only [continuous_iff_is_closed, is_closed_iff_zero_locus],\n      rintro _ ⟨s, rfl⟩,\n      exact ⟨_, preimage_comap_zero_locus_aux f s⟩\n    end }\n\nvariables (f : R →+* S)\n\n@[simp] lemma comap_as_ideal (y : prime_spectrum S) :\n  (comap f y).as_ideal = ideal.comap f y.as_ideal :=\nrfl\n\n@[simp] lemma comap_id : comap (ring_hom.id R) = continuous_map.id _ := by { ext, refl }\n\n@[simp] lemma comap_comp (f : R →+* S) (g : S →+* S') :\n  comap (g.comp f) = (comap f).comp (comap g) :=\nrfl\n\nlemma comap_comp_apply (f : R →+* S) (g : S →+* S') (x : prime_spectrum S') :\n  prime_spectrum.comap (g.comp f) x = (prime_spectrum.comap f) (prime_spectrum.comap g x) :=\nrfl\n\n@[simp] lemma preimage_comap_zero_locus (s : set R) :\n  (comap f) ⁻¹' (zero_locus s) = zero_locus (f '' s) :=\npreimage_comap_zero_locus_aux f s\n\nlemma comap_injective_of_surjective (f : R →+* S) (hf : function.surjective f) :\n  function.injective (comap f) :=\nλ x y h, prime_spectrum.ext.2 (ideal.comap_injective_of_surjective f hf\n  (congr_arg prime_spectrum.as_ideal h : (comap f x).as_ideal = (comap f y).as_ideal))\n\nlemma comap_singleton_is_closed_of_surjective (f : R →+* S) (hf : function.surjective f)\n  (x : prime_spectrum S) (hx : is_closed ({x} : set (prime_spectrum S))) :\n  is_closed ({comap f x} : set (prime_spectrum R)) :=\nbegin\n  haveI : x.as_ideal.is_maximal := (is_closed_singleton_iff_is_maximal x).1 hx,\n  exact (is_closed_singleton_iff_is_maximal _).2 (ideal.comap_is_maximal_of_surjective f hf)\nend\n\nlemma comap_singleton_is_closed_of_is_integral (f : R →+* S) (hf : f.is_integral)\n  (x : prime_spectrum S) (hx : is_closed ({x} : set (prime_spectrum S))) :\n  is_closed ({comap f x} : set (prime_spectrum R)) :=\n(is_closed_singleton_iff_is_maximal _).2 (ideal.is_maximal_comap_of_is_integral_of_is_maximal'\n  f hf x.as_ideal $ (is_closed_singleton_iff_is_maximal x).1 hx)\n\nvariable S\n\nlemma localization_comap_inducing [algebra R S] (M : submonoid R)\n  [is_localization M S] : inducing (comap (algebra_map R S)) :=\nbegin\n  constructor,\n  rw topological_space_eq_iff,\n  intro U,\n  simp_rw ← is_closed_compl_iff,\n  generalize : Uᶜ = Z,\n  simp_rw [is_closed_induced_iff, is_closed_iff_zero_locus],\n  split,\n  { rintro ⟨s, rfl⟩,\n    refine ⟨_,⟨(algebra_map R S) ⁻¹' (ideal.span s),rfl⟩,_⟩,\n    rw [preimage_comap_zero_locus, ← zero_locus_span, ← zero_locus_span s],\n    congr' 1,\n    exact congr_arg submodule.carrier (is_localization.map_comap M S (ideal.span s)) },\n  { rintro ⟨_, ⟨t, rfl⟩, rfl⟩, simp }\nend\n\nlemma localization_comap_injective [algebra R S] (M : submonoid R)\n  [is_localization M S] : function.injective (comap (algebra_map R S)) :=\nbegin\n  intros p q h,\n  replace h := congr_arg (λ (x : prime_spectrum R), ideal.map (algebra_map R S) x.as_ideal) h,\n  dsimp only at h,\n  erw [is_localization.map_comap M S, is_localization.map_comap M S] at h,\n  ext1,\n  exact h\nend\n\nlemma localization_comap_embedding [algebra R S] (M : submonoid R)\n  [is_localization M S] : embedding (comap (algebra_map R S)) :=\n⟨localization_comap_inducing S M, localization_comap_injective S M⟩\n\nlemma localization_comap_range [algebra R S] (M : submonoid R)\n  [is_localization M S] :\n  set.range (comap (algebra_map R S)) = { p | disjoint (M : set R) p.as_ideal } :=\nbegin\n  ext x,\n  split,\n  { rintro ⟨p, rfl⟩ x ⟨hx₁, hx₂⟩,\n    exact (p.2.1 : ¬ _)\n      (p.as_ideal.eq_top_of_is_unit_mem hx₂ (is_localization.map_units S ⟨x, hx₁⟩)) },\n  { intro h,\n    use ⟨x.as_ideal.map (algebra_map R S),\n      is_localization.is_prime_of_is_prime_disjoint M S _ x.2 h⟩,\n    ext1,\n    exact is_localization.comap_map_of_is_prime_disjoint M S _ x.2 h }\nend\n\nend comap\n\nsection basic_open\n\n/-- `basic_open r` is the open subset containing all prime ideals not containing `r`. -/\ndef basic_open (r : R) : topological_space.opens (prime_spectrum R) :=\n{ val := { x | r ∉ x.as_ideal },\n  property := ⟨{r}, set.ext $ λ x, set.singleton_subset_iff.trans $ not_not.symm⟩ }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x ∈ basic_open f ↔ f ∉ x.as_ideal := iff.rfl\n\nlemma is_open_basic_open {a : R} : is_open ((basic_open a) : set (prime_spectrum R)) :=\n(basic_open a).property\n\n@[simp] lemma basic_open_eq_zero_locus_compl (r : R) :\n  (basic_open r : set (prime_spectrum R)) = (zero_locus {r})ᶜ :=\nset.ext $ λ x, by simpa only [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]\n\n@[simp] lemma basic_open_one : basic_open (1 : R) = ⊤ :=\ntopological_space.opens.ext $ by simp\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = ⊥ :=\ntopological_space.opens.ext $ by simp\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f ≤ basic_open g ↔ f ∈ (ideal.span ({g} : set R)).radical :=\nby rw [topological_space.opens.le_def, basic_open_eq_zero_locus_compl,\n    basic_open_eq_zero_locus_compl, set.le_eq_subset, set.compl_subset_compl,\n    zero_locus_subset_zero_locus_singleton_iff]\n\nlemma basic_open_mul (f g : R) : basic_open (f * g) = basic_open f ⊓ basic_open g :=\ntopological_space.opens.ext $ by {simp [zero_locus_singleton_mul]}\n\nlemma basic_open_mul_le_left (f g : R) : basic_open (f * g) ≤ basic_open f :=\nby { rw basic_open_mul f g, exact inf_le_left }\n\nlemma basic_open_mul_le_right (f g : R) : basic_open (f * g) ≤ basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : ℕ) (hn : 0 < n) : basic_open (f ^ n) = basic_open f :=\ntopological_space.opens.ext $ by simpa using zero_locus_singleton_pow f n hn\n\nlemma is_topological_basis_basic_opens : topological_space.is_topological_basis\n  (set.range (λ (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ ⟨r, rfl⟩,\n    exact is_open_basic_open },\n  { rintros p U hp ⟨s, hs⟩,\n    rw [← compl_compl U, set.mem_compl_eq, ← hs, mem_zero_locus, set.not_subset] at hp,\n    obtain ⟨f, hfs, hfp⟩ := hp,\n    refine ⟨basic_open f, ⟨f, rfl⟩, hfp, _⟩,\n    rw [← set.compl_subset_compl, ← hs, basic_open_eq_zero_locus_compl, compl_compl],\n    exact zero_locus_anti_mono (set.singleton_subset_iff.mpr hfs) }\nend\n\nlemma is_basis_basic_opens :\n  topological_space.opens.is_basis (set.range (@basic_open R _)) :=\nbegin\n  unfold topological_space.opens.is_basis,\n  convert is_topological_basis_basic_opens,\n  rw ← set.range_comp,\nend\n\nlemma is_compact_basic_open (f : R) : is_compact (basic_open f : set (prime_spectrum R)) :=\nis_compact_of_finite_subfamily_closed $ λ ι Z hZc hZ,\nbegin\n  let I : ι → ideal R := λ i, vanishing_ideal (Z i),\n  have hI : ∀ i, Z i = zero_locus (I i) := λ i,\n    by simpa only [zero_locus_vanishing_ideal_eq_closure] using (hZc i).closure_eq.symm,\n  rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n      set.diff_eq_empty, funext hI, ← zero_locus_supr] at hZ,\n  obtain ⟨n, hn⟩ : f ∈ (⨆ (i : ι), I i).radical,\n  { rw ← vanishing_ideal_zero_locus_eq_radical,\n    apply vanishing_ideal_anti_mono hZ,\n    exact (subset_vanishing_ideal_zero_locus {f} (set.mem_singleton f)) },\n  rcases submodule.exists_finset_of_mem_supr I hn with ⟨s, hs⟩,\n  use s,\n  -- Using simp_rw here, because `hI` and `zero_locus_supr` need to be applied underneath binders\n  simp_rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n           set.diff_eq_empty, hI, ← zero_locus_supr],\n  rw ← zero_locus_radical, -- this one can't be in `simp_rw` because it would loop\n  apply zero_locus_anti_mono,\n  rw set.singleton_subset_iff,\n  exact ⟨n, hs⟩\nend\n\n@[simp]\nlemma basic_open_eq_bot_iff (f : R) :\n  basic_open f = ⊥ ↔ is_nilpotent f :=\nbegin\n  rw [← subtype.coe_injective.eq_iff, basic_open_eq_zero_locus_compl],\n  simp only [set.eq_univ_iff_forall, topological_space.opens.empty_eq, set.singleton_subset_iff,\n    topological_space.opens.coe_bot, nilpotent_iff_mem_prime, set.compl_empty_iff, mem_zero_locus,\n    set_like.mem_coe],\n  exact subtype.forall,\nend\n\nlemma localization_away_comap_range (S : Type v) [comm_ring S] [algebra R S] (r : R)\n  [is_localization.away r S] : set.range (comap (algebra_map R S)) = basic_open r :=\nbegin\n  rw localization_comap_range S (submonoid.powers r),\n  ext,\n  simp only [mem_zero_locus, basic_open_eq_zero_locus_compl, set_like.mem_coe, set.mem_set_of_eq,\n    set.singleton_subset_iff, set.mem_compl_eq],\n  split,\n  { intros h₁ h₂,\n    exact h₁ ⟨submonoid.mem_powers r, h₂⟩ },\n  { rintros h₁ _ ⟨⟨n, rfl⟩, h₃⟩,\n    exact h₁ (x.2.mem_of_pow_mem _ h₃) },\nend\n\nlemma localization_away_open_embedding (S : Type v) [comm_ring S] [algebra R S] (r : R)\n  [is_localization.away r S] : open_embedding (comap (algebra_map R S)) :=\n{ to_embedding := localization_comap_embedding S (submonoid.powers r),\n  open_range := by { rw localization_away_comap_range S r, exact is_open_basic_open } }\n\nend basic_open\n\n/-- The prime spectrum of a commutative ring is a compact topological space. -/\ninstance : compact_space (prime_spectrum R) :=\n{ compact_univ := by { convert is_compact_basic_open (1 : R), rw basic_open_one, refl } }\n\nsection order\n\n/-!\n## The specialization order\n\nWe endow `prime_spectrum R` with a partial order,\nwhere `x ≤ y` if and only if `y ∈ closure {x}`.\n-/\n\ninstance : partial_order (prime_spectrum R) :=\nsubtype.partial_order _\n\n@[simp] lemma as_ideal_le_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal ≤ y.as_ideal ↔ x ≤ y :=\nsubtype.coe_le_coe\n\n@[simp] lemma as_ideal_lt_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal < y.as_ideal ↔ x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x ≤ y ↔ y ∈ closure ({x} : set (prime_spectrum R)) :=\nby rw [← as_ideal_le_as_ideal, ← zero_locus_vanishing_ideal_eq_closure,\n    mem_zero_locus, vanishing_ideal_singleton, set_like.coe_subset_coe]\n\nlemma le_iff_specializes (x y : prime_spectrum R) :\n  x ≤ y ↔ x ⤳ y :=\nle_iff_mem_closure x y\n\ninstance : t0_space (prime_spectrum R) :=\nby { simp [t0_space_iff_or_not_mem_closure, ← le_iff_mem_closure,\n  ← not_and_distrib, ← le_antisymm_iff, eq_comm] }\n\nend order\n\n/-- If `x` specializes to `y`, then there is a natural map from the localization of `y` to\nthe localization of `x`. -/\ndef localization_map_of_specializes {x y : prime_spectrum R} (h : x ⤳ y) :\n  localization.at_prime y.as_ideal →+* localization.at_prime x.as_ideal :=\n@is_localization.lift _ _ _ _ _ _ _ _\n  localization.is_localization (algebra_map R (localization.at_prime x.as_ideal))\n  begin\n    rintro ⟨a, ha⟩,\n    rw [← prime_spectrum.le_iff_specializes, ← as_ideal_le_as_ideal, ← set_like.coe_subset_coe,\n      ← set.compl_subset_compl] at h,\n    exact (is_localization.map_units _ ⟨a, (show a ∈ x.as_ideal.prime_compl, from h ha)⟩ : _)\n  end\n\nend prime_spectrum\n\n\nnamespace local_ring\n\nvariables (R) [local_ring R]\n\n/--\nThe closed point in the prime spectrum of a local ring.\n-/\ndef closed_point : prime_spectrum R :=\n⟨maximal_ideal R, (maximal_ideal.is_maximal R).is_prime⟩\n\nvariable {R}\n\nlemma is_local_ring_hom_iff_comap_closed_point {S : Type v} [comm_ring S] [local_ring S]\n  (f : R →+* S) : is_local_ring_hom f ↔ prime_spectrum.comap f (closed_point S) = closed_point R :=\nby { rw [(local_hom_tfae f).out 0 4, subtype.ext_iff], refl }\n\n@[simp] lemma comap_closed_point {S : Type v} [comm_ring S] [local_ring S] (f : R →+* S)\n  [is_local_ring_hom f] : prime_spectrum.comap f (closed_point S) = closed_point R :=\n(is_local_ring_hom_iff_comap_closed_point f).mp infer_instance\n\nend local_ring\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebraic_geometry/prime_spectrum/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4798082226594431}}
{"text": "/-\nCopyright (c) 2020 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Floris van Doorn\n-/\nimport measure_theory.measure.giry_monad\nimport dynamics.ergodic.measure_preserving\nimport measure_theory.integral.set_integral\n\n/-!\n# The product measure\n\nIn this file we define and prove properties about the binary product measure. If `α` and `β` have\nσ-finite measures `μ` resp. `ν` then `α × β` can be equipped with a σ-finite measure `μ.prod ν` that\nsatisfies `(μ.prod ν) s = ∫⁻ x, ν {y | (x, y) ∈ s} ∂μ`.\nWe also have `(μ.prod ν) (s ×ˢ t) = μ s * ν t`, i.e. the measure of a rectangle is the product of\nthe measures of the sides.\n\nWe also prove Tonelli's theorem and Fubini's theorem.\n\n## Main definition\n\n* `measure_theory.measure.prod`: The product of two measures.\n\n## Main results\n\n* `measure_theory.measure.prod_apply` states `μ.prod ν s = ∫⁻ x, ν {y | (x, y) ∈ s} ∂μ`\n  for measurable `s`. `measure_theory.measure.prod_apply_symm` is the reversed version.\n* `measure_theory.measure.prod_prod` states `μ.prod ν (s ×ˢ t) = μ s * ν t` for measurable sets\n  `s` and `t`.\n* `measure_theory.lintegral_prod`: Tonelli's theorem. It states that for a measurable function\n  `α × β → ℝ≥0∞` we have `∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ`. The version\n  for functions `α → β → ℝ≥0∞` is reversed, and called `lintegral_lintegral`. Both versions have\n  a variant with `_symm` appended, where the order of integration is reversed.\n  The lemma `measurable.lintegral_prod_right'` states that the inner integral of the right-hand side\n  is measurable.\n* `measure_theory.integrable_prod_iff` states that a binary function is integrable iff both\n  * `y ↦ f (x, y)` is integrable for almost every `x`, and\n  * the function `x ↦ ∫ ∥f (x, y)∥ dy` is integrable.\n* `measure_theory.integral_prod`: Fubini's theorem. It states that for a integrable function\n  `α × β → E` (where `E` is a second countable Banach space) we have\n  `∫ z, f z ∂(μ.prod ν) = ∫ x, ∫ y, f (x, y) ∂ν ∂μ`. This theorem has the same variants as\n  Tonelli's theorem. The lemma `measure_theory.integrable.integral_prod_right` states that the\n  inner integral of the right-hand side is integrable.\n\n## Implementation Notes\n\nMany results are proven twice, once for functions in curried form (`α → β → γ`) and one for\nfunctions in uncurried form (`α × β → γ`). The former often has an assumption\n`measurable (uncurry f)`, which could be inconvenient to discharge, but for the latter it is more\ncommon that the function has to be given explicitly, since Lean cannot synthesize the function by\nitself. We name the lemmas about the uncurried form with a prime.\nTonelli's theorem and Fubini's theorem have a different naming scheme, since the version for the\nuncurried version is reversed.\n\n## Tags\n\nproduct measure, Fubini's theorem, Tonelli's theorem, Fubini-Tonelli theorem\n-/\n\nnoncomputable theory\nopen_locale classical topological_space ennreal measure_theory\nopen set function real ennreal\nopen measure_theory measurable_space measure_theory.measure\nopen topological_space (hiding generate_from)\nopen filter (hiding prod_eq map)\n\nvariables {α α' β β' γ E : Type*}\n\n/-- Rectangles formed by π-systems form a π-system. -/\nlemma is_pi_system.prod {C : set (set α)} {D : set (set β)} (hC : is_pi_system C)\n  (hD : is_pi_system D) : is_pi_system (image2 (×ˢ) C D) :=\nbegin\n  rintro _ ⟨s₁, t₁, hs₁, ht₁, rfl⟩ _ ⟨s₂, t₂, hs₂, ht₂, rfl⟩ hst,\n  rw [prod_inter_prod] at hst ⊢, rw [prod_nonempty_iff] at hst,\n  exact mem_image2_of_mem (hC _ hs₁ _ hs₂ hst.1) (hD _ ht₁ _ ht₂ hst.2)\nend\n\n/-- Rectangles of countably spanning sets are countably spanning. -/\nlemma is_countably_spanning.prod {C : set (set α)} {D : set (set β)}\n  (hC : is_countably_spanning C) (hD : is_countably_spanning D) :\n  is_countably_spanning (image2 (×ˢ) C D) :=\nbegin\n  rcases ⟨hC, hD⟩ with ⟨⟨s, h1s, h2s⟩, t, h1t, h2t⟩,\n  refine ⟨λ n, (s n.unpair.1) ×ˢ (t n.unpair.2), λ n, mem_image2_of_mem (h1s _) (h1t _), _⟩,\n  rw [Union_unpair_prod, h2s, h2t, univ_prod_univ]\nend\n\nvariables [measurable_space α] [measurable_space α'] [measurable_space β] [measurable_space β']\nvariables [measurable_space γ]\nvariables {μ : measure α} {ν : measure β} {τ : measure γ}\nvariables [normed_group E] [measurable_space E]\n\n/-! ### Measurability\n\nBefore we define the product measure, we can talk about the measurability of operations on binary\nfunctions. We show that if `f` is a binary measurable function, then the function that integrates\nalong one of the variables (using either the Lebesgue or Bochner integral) is measurable.\n-/\n\n/-- The product of generated σ-algebras is the one generated by rectangles, if both generating sets\n  are countably spanning. -/\nlemma generate_from_prod_eq {α β} {C : set (set α)} {D : set (set β)}\n  (hC : is_countably_spanning C) (hD : is_countably_spanning D) :\n  @prod.measurable_space _ _ (generate_from C) (generate_from D) =\n    generate_from (image2 (×ˢ) C D) :=\nbegin\n  apply le_antisymm,\n  { refine sup_le _ _; rw [comap_generate_from];\n      apply generate_from_le; rintro _ ⟨s, hs, rfl⟩,\n    { rcases hD with ⟨t, h1t, h2t⟩,\n      rw [← prod_univ, ← h2t, prod_Union],\n      apply measurable_set.Union,\n      intro n, apply measurable_set_generate_from,\n      exact ⟨s, t n, hs, h1t n, rfl⟩ },\n    { rcases hC with ⟨t, h1t, h2t⟩,\n      rw [← univ_prod, ← h2t, Union_prod_const],\n      apply measurable_set.Union,\n      rintro n, apply measurable_set_generate_from,\n      exact mem_image2_of_mem (h1t n) hs } },\n  { apply generate_from_le, rintro _ ⟨s, t, hs, ht, rfl⟩, rw [prod_eq],\n    apply (measurable_fst _).inter (measurable_snd _),\n    { exact measurable_set_generate_from hs },\n    { exact measurable_set_generate_from ht } }\nend\n\n/-- If `C` and `D` generate the σ-algebras on `α` resp. `β`, then rectangles formed by `C` and `D`\n  generate the σ-algebra on `α × β`. -/\nlemma generate_from_eq_prod {C : set (set α)} {D : set (set β)} (hC : generate_from C = ‹_›)\n  (hD : generate_from D = ‹_›) (h2C : is_countably_spanning C) (h2D : is_countably_spanning D) :\n    generate_from (image2 (×ˢ) C D) = prod.measurable_space :=\nby rw [← hC, ← hD, generate_from_prod_eq h2C h2D]\n\n/-- The product σ-algebra is generated from boxes, i.e. `s ×ˢ t` for sets `s : set α` and\n  `t : set β`. -/\nlemma generate_from_prod :\n  generate_from (image2 (×ˢ) {s : set α | measurable_set s} {t : set β | measurable_set t}) =\n  prod.measurable_space :=\ngenerate_from_eq_prod generate_from_measurable_set generate_from_measurable_set\n  is_countably_spanning_measurable_set is_countably_spanning_measurable_set\n\n/-- Rectangles form a π-system. -/\nlemma is_pi_system_prod :\n  is_pi_system (image2 (×ˢ) {s : set α | measurable_set s} {t : set β | measurable_set t}) :=\nis_pi_system_measurable_set.prod is_pi_system_measurable_set\n\n/-- If `ν` is a finite measure, and `s ⊆ α × β` is measurable, then `x ↦ ν { y | (x, y) ∈ s }` is\n  a measurable function. `measurable_measure_prod_mk_left` is strictly more general. -/\nlemma measurable_measure_prod_mk_left_finite [is_finite_measure ν] {s : set (α × β)}\n  (hs : measurable_set s) : measurable (λ x, ν (prod.mk x ⁻¹' s)) :=\nbegin\n  refine induction_on_inter generate_from_prod.symm is_pi_system_prod _ _ _ _ hs,\n  { simp [measurable_zero, const_def] },\n  { rintro _ ⟨s, t, hs, ht, rfl⟩, simp only [mk_preimage_prod_right_eq_if, measure_if],\n    exact measurable_const.indicator hs },\n  { intros t ht h2t,\n    simp_rw [preimage_compl, measure_compl (measurable_prod_mk_left ht) (measure_ne_top ν _)],\n    exact h2t.const_sub _ },\n  { intros f h1f h2f h3f, simp_rw [preimage_Union],\n    have : ∀ b, ν (⋃ i, prod.mk b ⁻¹' f i) = ∑' i, ν (prod.mk b ⁻¹' f i) :=\n      λ b, measure_Union (λ i j hij, disjoint.preimage _ (h1f i j hij))\n        (λ i, measurable_prod_mk_left (h2f i)),\n    simp_rw [this], apply measurable.ennreal_tsum h3f },\nend\n\n/-- If `ν` is a σ-finite measure, and `s ⊆ α × β` is measurable, then `x ↦ ν { y | (x, y) ∈ s }` is\n  a measurable function. -/\nlemma measurable_measure_prod_mk_left [sigma_finite ν] {s : set (α × β)}\n  (hs : measurable_set s) : measurable (λ x, ν (prod.mk x ⁻¹' s)) :=\nbegin\n  have : ∀ x, measurable_set (prod.mk x ⁻¹' s) := λ x, measurable_prod_mk_left hs,\n  simp only [← @supr_restrict_spanning_sets _ _ ν, this],\n  apply measurable_supr, intro i,\n  haveI := fact.mk (measure_spanning_sets_lt_top ν i),\n  exact measurable_measure_prod_mk_left_finite hs\nend\n\n/-- If `μ` is a σ-finite measure, and `s ⊆ α × β` is measurable, then `y ↦ μ { x | (x, y) ∈ s }` is\n  a measurable function. -/\nlemma measurable_measure_prod_mk_right {μ : measure α} [sigma_finite μ] {s : set (α × β)}\n  (hs : measurable_set s) : measurable (λ y, μ ((λ x, (x, y)) ⁻¹' s)) :=\nmeasurable_measure_prod_mk_left (measurable_set_swap_iff.mpr hs)\n\nlemma measurable.map_prod_mk_left [sigma_finite ν] : measurable (λ x : α, map (prod.mk x) ν) :=\nbegin\n  apply measurable_of_measurable_coe, intros s hs,\n  simp_rw [map_apply measurable_prod_mk_left hs],\n  exact measurable_measure_prod_mk_left hs\nend\n\nlemma measurable.map_prod_mk_right {μ : measure α} [sigma_finite μ] :\n  measurable (λ y : β, map (λ x : α, (x, y)) μ) :=\nbegin\n  apply measurable_of_measurable_coe, intros s hs,\n  simp_rw [map_apply measurable_prod_mk_right hs],\n  exact measurable_measure_prod_mk_right hs\nend\n\n/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)\n  Tonelli's theorem is measurable. -/\nlemma measurable.lintegral_prod_right' [sigma_finite ν] :\n  ∀ {f : α × β → ℝ≥0∞} (hf : measurable f), measurable (λ x, ∫⁻ y, f (x, y) ∂ν) :=\nbegin\n  have m := @measurable_prod_mk_left,\n  refine measurable.ennreal_induction _ _ _,\n  { intros c s hs, simp only [← indicator_comp_right],\n    suffices : measurable (λ x, c * ν (prod.mk x ⁻¹' s)),\n    { simpa [lintegral_indicator _ (m hs)] },\n    exact (measurable_measure_prod_mk_left hs).const_mul _ },\n  { rintro f g - hf hg h2f h2g, simp_rw [pi.add_apply, lintegral_add (hf.comp m) (hg.comp m)],\n    exact h2f.add h2g },\n  { intros f hf h2f h3f,\n    have := measurable_supr h3f,\n    have : ∀ x, monotone (λ n y, f n (x, y)) := λ x i j hij y, h2f hij (x, y),\n    simpa [lintegral_supr (λ n, (hf n).comp m), this] }\nend\n\n/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)\n  Tonelli's theorem is measurable.\n  This version has the argument `f` in curried form. -/\nlemma measurable.lintegral_prod_right [sigma_finite ν] {f : α → β → ℝ≥0∞}\n  (hf : measurable (uncurry f)) : measurable (λ x, ∫⁻ y, f x y ∂ν) :=\nhf.lintegral_prod_right'\n\n/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)\n  the symmetric version of Tonelli's theorem is measurable. -/\nlemma measurable.lintegral_prod_left' [sigma_finite μ] {f : α × β → ℝ≥0∞}\n  (hf : measurable f) : measurable (λ y, ∫⁻ x, f (x, y) ∂μ) :=\n(measurable_swap_iff.mpr hf).lintegral_prod_right'\n\n/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)\n  the symmetric version of Tonelli's theorem is measurable.\n  This version has the argument `f` in curried form. -/\nlemma measurable.lintegral_prod_left [sigma_finite μ] {f : α → β → ℝ≥0∞}\n  (hf : measurable (uncurry f)) : measurable (λ y, ∫⁻ x, f x y ∂μ) :=\nhf.lintegral_prod_left'\n\nlemma measurable_set_integrable [sigma_finite ν] [opens_measurable_space E] ⦃f : α → β → E⦄\n  (hf : measurable (uncurry f)) : measurable_set { x | integrable (f x) ν } :=\nbegin\n  simp_rw [integrable, hf.of_uncurry_left.ae_measurable, true_and],\n  exact measurable_set_lt (measurable.lintegral_prod_right hf.ennnorm) measurable_const\nend\n\nsection\nvariables [second_countable_topology E] [normed_space ℝ E]\n  [complete_space E] [borel_space E]\n\n/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)\n  Fubini's theorem is measurable.\n  This version has `f` in curried form. -/\nlemma measurable.integral_prod_right [sigma_finite ν] ⦃f : α → β → E⦄\n  (hf : measurable (uncurry f)) : measurable (λ x, ∫ y, f x y ∂ν) :=\nbegin\n  let s : ℕ → simple_func (α × β) E := simple_func.approx_on _ hf univ _ (mem_univ 0),\n  let s' : ℕ → α → simple_func β E := λ n x, (s n).comp (prod.mk x) measurable_prod_mk_left,\n  let f' : ℕ → α → E := λ n, {x | integrable (f x) ν}.indicator\n    (λ x, (s' n x).integral ν),\n  have hf' : ∀ n, measurable (f' n),\n  { intro n, refine measurable.indicator _ (measurable_set_integrable hf),\n    have : ∀ x, (s' n x).range.filter (λ x, x ≠ 0) ⊆ (s n).range,\n    { intros x, refine finset.subset.trans (finset.filter_subset _ _) _, intro y,\n      simp_rw [simple_func.mem_range], rintro ⟨z, rfl⟩, exact ⟨(x, z), rfl⟩ },\n    simp only [simple_func.integral_eq_sum_of_subset (this _)],\n    refine finset.measurable_sum _ (λ x _, _),\n    refine (measurable.ennreal_to_real _).smul_const _,\n    simp only [simple_func.coe_comp, preimage_comp] {single_pass := tt},\n    apply measurable_measure_prod_mk_left,\n    exact (s n).measurable_set_fiber x },\n  have h2f' : tendsto f' at_top (𝓝 (λ (x : α), ∫ (y : β), f x y ∂ν)),\n  { rw [tendsto_pi_nhds], intro x,\n    by_cases hfx : integrable (f x) ν,\n    { have : ∀ n, integrable (s' n x) ν,\n      { intro n, apply (hfx.norm.add hfx.norm).mono' (s' n x).measurable.ae_measurable,\n        apply eventually_of_forall, intro y,\n        simp_rw [s', simple_func.coe_comp], exact simple_func.norm_approx_on_zero_le _ _ (x, y) n },\n      simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,\n        mem_set_of_eq],\n      refine tendsto_integral_of_dominated_convergence (λ y, ∥f x y∥ + ∥f x y∥)\n        (λ n, (s' n x).ae_measurable) (hfx.norm.add hfx.norm) _ _,\n      { exact λ n, eventually_of_forall (λ y, simple_func.norm_approx_on_zero_le _ _ (x, y) n) },\n      { exact eventually_of_forall (λ y, simple_func.tendsto_approx_on _ _ (by simp)) } },\n    { simpa [f', hfx, integral_undef] using @tendsto_const_nhds _ _ _ (0 : E) _, } },\n  exact measurable_of_tendsto_metric hf' h2f'\nend\n\n/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)\n  Fubini's theorem is measurable. -/\nlemma measurable.integral_prod_right' [sigma_finite ν] ⦃f : α × β → E⦄\n  (hf : measurable f) : measurable (λ x, ∫ y, f (x, y) ∂ν) :=\nby { rw [← uncurry_curry f] at hf, exact hf.integral_prod_right }\n\n/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)\n  the symmetric version of Fubini's theorem is measurable.\n  This version has `f` in curried form. -/\nlemma measurable.integral_prod_left [sigma_finite μ] ⦃f : α → β → E⦄\n  (hf : measurable (uncurry f)) : measurable (λ y, ∫ x, f x y ∂μ) :=\n(hf.comp measurable_swap).integral_prod_right'\n\n/-- The Bochner integral is measurable. This shows that the integrand of (the right-hand-side of)\n  the symmetric version of Fubini's theorem is measurable. -/\nlemma measurable.integral_prod_left' [sigma_finite μ] ⦃f : α × β → E⦄\n  (hf : measurable f) : measurable (λ y, ∫ x, f (x, y) ∂μ) :=\n(hf.comp measurable_swap).integral_prod_right'\n\nend\n\n/-! ### The product measure -/\n\nnamespace measure_theory\n\nnamespace measure\n\n/-- The binary product of measures. They are defined for arbitrary measures, but we basically\n  prove all properties under the assumption that at least one of them is σ-finite. -/\n@[irreducible] protected def prod (μ : measure α) (ν : measure β) : measure (α × β) :=\nbind μ $ λ x : α, map (prod.mk x) ν\n\ninstance prod.measure_space {α β} [measure_space α] [measure_space β] : measure_space (α × β) :=\n{ volume := volume.prod volume }\n\nvariables {μ ν} [sigma_finite ν]\n\nlemma volume_eq_prod (α β) [measure_space α] [measure_space β] :\n  (volume : measure (α × β)) = (volume : measure α).prod (volume : measure β) :=\nrfl\n\nlemma prod_apply {s : set (α × β)} (hs : measurable_set s) :\n  μ.prod ν s = ∫⁻ x, ν (prod.mk x ⁻¹' s) ∂μ :=\nby simp_rw [measure.prod, bind_apply hs measurable.map_prod_mk_left,\n  map_apply measurable_prod_mk_left hs]\n\n/-- The product measure of the product of two sets is the product of their measures. Note that we\ndo not need the sets to be measurable. -/\n@[simp] lemma prod_prod (s : set α) (t : set β) : μ.prod ν (s ×ˢ t) = μ s * ν t :=\nbegin\n  apply le_antisymm,\n  { set ST := (to_measurable μ s) ×ˢ (to_measurable ν t),\n    have hSTm : measurable_set ST :=\n      (measurable_set_to_measurable _ _).prod (measurable_set_to_measurable _ _),\n    calc μ.prod ν (s ×ˢ t) ≤ μ.prod ν ST :\n      measure_mono $ set.prod_mono (subset_to_measurable _ _) (subset_to_measurable _ _)\n    ... = μ (to_measurable μ s) * ν (to_measurable ν t) :\n      by simp_rw [prod_apply hSTm, mk_preimage_prod_right_eq_if, measure_if,\n        lintegral_indicator _ (measurable_set_to_measurable _ _), lintegral_const,\n        restrict_apply_univ, mul_comm]\n    ... = μ s * ν t : by rw [measure_to_measurable, measure_to_measurable] },\n  { /- Formalization is based on https://mathoverflow.net/a/254134/136589 -/\n    set ST := to_measurable (μ.prod ν) (s ×ˢ t),\n    have hSTm : measurable_set ST := measurable_set_to_measurable _ _,\n    have hST : s ×ˢ t ⊆ ST := subset_to_measurable _ _,\n    set f : α → ℝ≥0∞ := λ x, ν (prod.mk x ⁻¹' ST),\n    have hfm : measurable f := measurable_measure_prod_mk_left hSTm,\n    set s' : set α := {x | ν t ≤ f x},\n    have hss' : s ⊆ s' := λ x hx, measure_mono (λ y hy, hST $ mk_mem_prod hx hy),\n    calc μ s * ν t ≤ μ s' * ν t : mul_le_mul_right' (measure_mono hss') _\n    ... = ∫⁻ x in s', ν t ∂μ    : by rw [set_lintegral_const, mul_comm]\n    ... ≤ ∫⁻ x in s', f x ∂μ    : set_lintegral_mono measurable_const hfm (λ x, id)\n    ... ≤ ∫⁻ x, f x ∂μ          : lintegral_mono' restrict_le_self le_rfl\n    ... = μ.prod ν ST           : (prod_apply hSTm).symm\n    ... = μ.prod ν (s ×ˢ t)     : measure_to_measurable _ }\nend\n\nlemma ae_measure_lt_top {s : set (α × β)} (hs : measurable_set s)\n  (h2s : (μ.prod ν) s ≠ ∞) : ∀ᵐ x ∂μ, ν (prod.mk x ⁻¹' s) < ∞ :=\nby { simp_rw [prod_apply hs] at h2s, refine ae_lt_top (measurable_measure_prod_mk_left hs) h2s }\n\nlemma integrable_measure_prod_mk_left {s : set (α × β)}\n  (hs : measurable_set s) (h2s : (μ.prod ν) s ≠ ∞) :\n  integrable (λ x, (ν (prod.mk x ⁻¹' s)).to_real) μ :=\nbegin\n  refine ⟨(measurable_measure_prod_mk_left hs).ennreal_to_real.ae_measurable, _⟩,\n  simp_rw [has_finite_integral, ennnorm_eq_of_real to_real_nonneg],\n  convert h2s.lt_top using 1, simp_rw [prod_apply hs], apply lintegral_congr_ae,\n  refine (ae_measure_lt_top hs h2s).mp _, apply eventually_of_forall, intros x hx,\n  rw [lt_top_iff_ne_top] at hx, simp [of_real_to_real, hx],\nend\n\n/-- Note: the assumption `hs` cannot be dropped. For a counterexample, see\n  Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/\nlemma measure_prod_null {s : set (α × β)}\n  (hs : measurable_set s) : μ.prod ν s = 0 ↔ (λ x, ν (prod.mk x ⁻¹' s)) =ᵐ[μ] 0 :=\nby simp_rw [prod_apply hs, lintegral_eq_zero_iff (measurable_measure_prod_mk_left hs)]\n\n/-- Note: the converse is not true without assuming that `s` is measurable. For a counterexample,\n  see Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/\nlemma measure_ae_null_of_prod_null {s : set (α × β)}\n  (h : μ.prod ν s = 0) : (λ x, ν (prod.mk x ⁻¹' s)) =ᵐ[μ] 0 :=\nbegin\n  obtain ⟨t, hst, mt, ht⟩ := exists_measurable_superset_of_null h,\n  simp_rw [measure_prod_null mt] at ht,\n  rw [eventually_le_antisymm_iff],\n  exact ⟨eventually_le.trans_eq\n    (eventually_of_forall $ λ x, (measure_mono (preimage_mono hst) : _)) ht,\n    eventually_of_forall $ λ x, zero_le _⟩\nend\n\n/-- Note: the converse is not true. For a counterexample, see\n  Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/\nlemma ae_ae_of_ae_prod {p : α × β → Prop} (h : ∀ᵐ z ∂μ.prod ν, p z) :\n  ∀ᵐ x ∂ μ, ∀ᵐ y ∂ ν, p (x, y) :=\nmeasure_ae_null_of_prod_null h\n\n/-- `μ.prod ν` has finite spanning sets in rectangles of finite spanning sets. -/\ndef finite_spanning_sets_in.prod {ν : measure β} {C : set (set α)} {D : set (set β)}\n  (hμ : μ.finite_spanning_sets_in C) (hν : ν.finite_spanning_sets_in D) :\n  (μ.prod ν).finite_spanning_sets_in (image2 (×ˢ) C D) :=\nbegin\n  haveI := hν.sigma_finite,\n  refine ⟨λ n, hμ.set n.unpair.1 ×ˢ hν.set n.unpair.2,\n    λ n, mem_image2_of_mem (hμ.set_mem _) (hν.set_mem _), λ n, _, _⟩,\n  { rw [prod_prod],\n    exact mul_lt_top (hμ.finite _).ne (hν.finite _).ne },\n  { simp_rw [Union_unpair_prod, hμ.spanning, hν.spanning, univ_prod_univ] }\nend\n\nlemma prod_fst_absolutely_continuous : map prod.fst (μ.prod ν) ≪ μ :=\nbegin\n  refine absolutely_continuous.mk (λ s hs h2s, _),\n  rw [map_apply measurable_fst hs, ← prod_univ, prod_prod, h2s, zero_mul],\nend\n\nlemma prod_snd_absolutely_continuous : map prod.snd (μ.prod ν) ≪ ν :=\nbegin\n  refine absolutely_continuous.mk (λ s hs h2s, _),\n  rw [map_apply measurable_snd hs, ← univ_prod, prod_prod, h2s, mul_zero]\nend\n\nvariables [sigma_finite μ]\n\ninstance prod.sigma_finite : sigma_finite (μ.prod ν) :=\n(μ.to_finite_spanning_sets_in.prod ν.to_finite_spanning_sets_in).sigma_finite\n\n/-- A measure on a product space equals the product measure if they are equal on rectangles\n  with as sides sets that generate the corresponding σ-algebras. -/\nlemma prod_eq_generate_from {μ : measure α} {ν : measure β} {C : set (set α)}\n  {D : set (set β)} (hC : generate_from C = ‹_›)\n  (hD : generate_from D = ‹_›) (h2C : is_pi_system C) (h2D : is_pi_system D)\n  (h3C : μ.finite_spanning_sets_in C) (h3D : ν.finite_spanning_sets_in D)\n  {μν : measure (α × β)}\n  (h₁ : ∀ (s ∈ C) (t ∈ D), μν (s ×ˢ t) = μ s * ν t) : μ.prod ν = μν :=\nbegin\n  refine (h3C.prod h3D).ext\n    (generate_from_eq_prod hC hD h3C.is_countably_spanning h3D.is_countably_spanning).symm\n    (h2C.prod h2D) _,\n  { rintro _ ⟨s, t, hs, ht, rfl⟩, haveI := h3D.sigma_finite,\n    rw [h₁ s hs t ht, prod_prod] }\nend\n\n/-- A measure on a product space equals the product measure if they are equal on rectangles. -/\nlemma prod_eq {μν : measure (α × β)}\n  (h : ∀ s t, measurable_set s → measurable_set t → μν (s ×ˢ t) = μ s * ν t) : μ.prod ν = μν :=\nprod_eq_generate_from generate_from_measurable_set generate_from_measurable_set\n  is_pi_system_measurable_set is_pi_system_measurable_set\n  μ.to_finite_spanning_sets_in ν.to_finite_spanning_sets_in (λ s hs t ht, h s t hs ht)\n\nlemma prod_swap : map prod.swap (μ.prod ν) = ν.prod μ :=\nbegin\n  refine (prod_eq _).symm,\n  intros s t hs ht,\n  simp_rw [map_apply measurable_swap (hs.prod ht), preimage_swap_prod, prod_prod, mul_comm]\nend\n\nlemma prod_apply_symm {s : set (α × β)} (hs : measurable_set s) :\n  μ.prod ν s = ∫⁻ y, μ ((λ x, (x, y)) ⁻¹' s) ∂ν :=\nby { rw [← prod_swap, map_apply measurable_swap hs],\n     simp only [prod_apply (measurable_swap hs)], refl }\n\nlemma prod_assoc_prod [sigma_finite τ] :\n  map measurable_equiv.prod_assoc ((μ.prod ν).prod τ) = μ.prod (ν.prod τ) :=\nbegin\n  refine (prod_eq_generate_from generate_from_measurable_set generate_from_prod\n    is_pi_system_measurable_set is_pi_system_prod μ.to_finite_spanning_sets_in\n    (ν.to_finite_spanning_sets_in.prod τ.to_finite_spanning_sets_in) _).symm,\n  rintro s hs _ ⟨t, u, ht, hu, rfl⟩, rw [mem_set_of_eq] at hs ht hu,\n  simp_rw [map_apply (measurable_equiv.measurable _) (hs.prod (ht.prod hu)),\n    measurable_equiv.prod_assoc, measurable_equiv.coe_mk, equiv.prod_assoc_preimage,\n    prod_prod, mul_assoc]\nend\n\n/-! ### The product of specific measures -/\n\nlemma prod_restrict (s : set α) (t : set β) :\n  (μ.restrict s).prod (ν.restrict t) = (μ.prod ν).restrict (s ×ˢ t) :=\nbegin\n  refine prod_eq (λ s' t' hs' ht', _),\n  rw [restrict_apply (hs'.prod ht'), prod_inter_prod, prod_prod, restrict_apply hs',\n    restrict_apply ht']\nend\n\nlemma restrict_prod_eq_prod_univ (s : set α) :\n  (μ.restrict s).prod ν = (μ.prod ν).restrict (s ×ˢ (univ : set β)) :=\nbegin\n  have : ν = ν.restrict set.univ := measure.restrict_univ.symm,\n  rwa [this, measure.prod_restrict, ← this],\nend\n\nlemma prod_dirac (y : β) : μ.prod (dirac y) = map (λ x, (x, y)) μ :=\nbegin\n  refine prod_eq (λ s t hs ht, _),\n  simp_rw [map_apply measurable_prod_mk_right (hs.prod ht), mk_preimage_prod_left_eq_if, measure_if,\n    dirac_apply' _ ht, ← indicator_mul_right _ (λ x, μ s), pi.one_apply, mul_one]\nend\n\nlemma dirac_prod (x : α) : (dirac x).prod ν = map (prod.mk x) ν :=\nbegin\n  refine prod_eq (λ s t hs ht, _),\n  simp_rw [map_apply measurable_prod_mk_left (hs.prod ht), mk_preimage_prod_right_eq_if, measure_if,\n    dirac_apply' _ hs, ← indicator_mul_left _ _ (λ x, ν t), pi.one_apply, one_mul]\nend\n\nlemma dirac_prod_dirac {x : α} {y : β} : (dirac x).prod (dirac y) = dirac (x, y) :=\nby rw [prod_dirac, map_dirac measurable_prod_mk_right]\n\nlemma prod_sum {ι : Type*} [fintype ι] (ν : ι → measure β) [∀ i, sigma_finite (ν i)] :\n  μ.prod (sum ν) = sum (λ i, μ.prod (ν i)) :=\nbegin\n  refine prod_eq (λ s t hs ht, _),\n  simp_rw [sum_apply _ (hs.prod ht), sum_apply _ ht, prod_prod, ennreal.tsum_mul_left]\nend\n\nlemma sum_prod {ι : Type*} [fintype ι] (μ : ι → measure α) [∀ i, sigma_finite (μ i)] :\n  (sum μ).prod ν = sum (λ i, (μ i).prod ν) :=\nbegin\n  refine prod_eq (λ s t hs ht, _),\n  simp_rw [sum_apply _ (hs.prod ht), sum_apply _ hs, prod_prod, ennreal.tsum_mul_right]\nend\n\nlemma prod_add (ν' : measure β) [sigma_finite ν'] : μ.prod (ν + ν') = μ.prod ν + μ.prod ν' :=\nby { refine prod_eq (λ s t hs ht, _), simp_rw [add_apply, prod_prod, left_distrib] }\n\nlemma add_prod (μ' : measure α) [sigma_finite μ'] : (μ + μ').prod ν = μ.prod ν + μ'.prod ν :=\nby { refine prod_eq (λ s t hs ht, _), simp_rw [add_apply, prod_prod, right_distrib] }\n\n@[simp] lemma zero_prod (ν : measure β) : (0 : measure α).prod ν = 0 :=\nby { rw measure.prod, exact bind_zero_left _ }\n\n@[simp] lemma prod_zero (μ : measure α) : μ.prod (0 : measure β) = 0 :=\nby simp [measure.prod]\n\nlemma map_prod_map {δ} [measurable_space δ] {f : α → β} {g : γ → δ}\n  {μa : measure α} {μc : measure γ} (hfa : sigma_finite (map f μa))\n  (hgc : sigma_finite (map g μc)) (hf : measurable f) (hg : measurable g) :\n  (map f μa).prod (map g μc) = map (prod.map f g) (μa.prod μc) :=\nbegin\n  haveI := hgc.of_map μc hg,\n  refine prod_eq (λ s t hs ht, _),\n  rw [map_apply (hf.prod_map hg) (hs.prod ht), map_apply hf hs, map_apply hg ht],\n  exact prod_prod (f ⁻¹' s) (g ⁻¹' t)\nend\n\nend measure\n\nnamespace measure_preserving\n\nopen measure\n\nvariables {δ : Type*} [measurable_space δ] {μa : measure α} {μb : measure β}\n  {μc : measure γ} {μd : measure δ}\n\nlemma skew_product [sigma_finite μb] [sigma_finite μd]\n  {f : α → β} (hf : measure_preserving f μa μb) {g : α → γ → δ}\n  (hgm : measurable (uncurry g)) (hg : ∀ᵐ x ∂μa, map (g x) μc = μd) :\n  measure_preserving (λ p : α × γ, (f p.1, g p.1 p.2)) (μa.prod μc) (μb.prod μd) :=\nbegin\n  classical,\n  have : measurable (λ p : α × γ, (f p.1, g p.1 p.2)) := (hf.1.comp measurable_fst).prod_mk hgm,\n  /- if `μa = 0`, then the lemma is trivial, otherwise we can use `hg`\n  to deduce `sigma_finite μc`. -/\n  rcases eq_or_ne μa 0 with (rfl|ha),\n  { rw [← hf.map_eq, zero_prod, (map f).map_zero, zero_prod],\n    exact ⟨this, (map _).map_zero⟩ },\n  haveI : sigma_finite μc,\n  { rcases (ae_ne_bot.2 ha).nonempty_of_mem hg with ⟨x, hx : map (g x) μc = μd⟩,\n    exact sigma_finite.of_map _ hgm.of_uncurry_left (by rwa hx) },\n  -- Thus we can apply `measure.prod_eq` to prove equality of measures.\n  refine ⟨this, (prod_eq $ λ s t hs ht, _).symm⟩,\n  rw [map_apply this (hs.prod ht)],\n  refine (prod_apply (this $ hs.prod ht)).trans _,\n  have : ∀ᵐ x ∂μa, μc ((λ y, (f x, g x y)) ⁻¹' (s ×ˢ t)) = indicator (f ⁻¹' s) (λ y, μd t) x,\n  { refine hg.mono (λ x hx, _), unfreezingI { subst hx },\n    simp only [mk_preimage_prod_right_fn_eq_if, indicator_apply, mem_preimage],\n    split_ifs,\n    exacts [(map_apply hgm.of_uncurry_left ht).symm, measure_empty] },\n  simp only [preimage_preimage],\n  rw [lintegral_congr_ae this, lintegral_indicator _ (hf.1 hs),\n    set_lintegral_const, hf.measure_preimage hs, mul_comm]\nend\n\n/-- If `f : α → β` sends the measure `μa` to `μb` and `g : γ → δ` sends the measure `μc` to `μd`,\nthen `prod.map f g` sends `μa.prod μc` to `μb.prod μd`. -/\nprotected lemma prod [sigma_finite μb] [sigma_finite μd] {f : α → β} {g : γ → δ}\n  (hf : measure_preserving f μa μb) (hg : measure_preserving g μc μd) :\n  measure_preserving (prod.map f g) (μa.prod μc) (μb.prod μd) :=\nhave measurable (uncurry $ λ _ : α, g), from (hg.1.comp measurable_snd),\nhf.skew_product this $ filter.eventually_of_forall $ λ _, hg.map_eq\n\nend measure_preserving\n\nend measure_theory\n\nopen measure_theory.measure\n\nsection\n\nlemma ae_measurable.prod_swap [sigma_finite μ] [sigma_finite ν] {f : β × α → γ}\n  (hf : ae_measurable f (ν.prod μ)) : ae_measurable (λ (z : α × β), f z.swap) (μ.prod ν) :=\nby { rw ← prod_swap at hf, exact hf.comp_measurable measurable_swap }\n\nlemma ae_measurable.fst [sigma_finite ν] {f : α → γ}\n  (hf : ae_measurable f μ) : ae_measurable (λ (z : α × β), f z.1) (μ.prod ν) :=\nhf.comp_measurable' measurable_fst prod_fst_absolutely_continuous\n\nlemma ae_measurable.snd [sigma_finite ν] {f : β → γ}\n  (hf : ae_measurable f ν) : ae_measurable (λ (z : α × β), f z.2) (μ.prod ν) :=\nhf.comp_measurable' measurable_snd prod_snd_absolutely_continuous\n\n/-- The Bochner integral is a.e.-measurable.\n  This shows that the integrand of (the right-hand-side of) Fubini's theorem is a.e.-measurable. -/\nlemma ae_measurable.integral_prod_right' [sigma_finite ν]\n  [second_countable_topology E] [normed_space ℝ E] [borel_space E] [complete_space E]\n  ⦃f : α × β → E⦄ (hf : ae_measurable f (μ.prod ν)) : ae_measurable (λ x, ∫ y, f (x, y) ∂ν) μ :=\n⟨λ x, ∫ y, hf.mk f (x, y) ∂ν, hf.measurable_mk.integral_prod_right',\n  by { filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ hx using integral_congr_ae hx }⟩\n\nlemma ae_measurable.prod_mk_left [sigma_finite ν] {f : α × β → γ}\n  (hf : ae_measurable f (μ.prod ν)) : ∀ᵐ x ∂μ, ae_measurable (λ y, f (x, y)) ν := by\n{ filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with x hx\n    using ⟨λ y, hf.mk f (x, y), hf.measurable_mk.comp measurable_prod_mk_left, hx⟩ }\n\nend\n\nnamespace measure_theory\n\n/-! ### The Lebesgue integral on a product -/\n\nvariables [sigma_finite ν]\n\nlemma lintegral_prod_swap [sigma_finite μ] (f : α × β → ℝ≥0∞)\n  (hf : ae_measurable f (μ.prod ν)) : ∫⁻ z, f z.swap ∂(ν.prod μ) = ∫⁻ z, f z ∂(μ.prod ν) :=\nby { rw ← prod_swap at hf, rw [← lintegral_map' hf measurable_swap, prod_swap] }\n\n/-- **Tonelli's Theorem**: For `ℝ≥0∞`-valued measurable functions on `α × β`,\n  the integral of `f` is equal to the iterated integral. -/\nlemma lintegral_prod_of_measurable :\n  ∀ (f : α × β → ℝ≥0∞) (hf : measurable f), ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ :=\nbegin\n  have m := @measurable_prod_mk_left,\n  refine measurable.ennreal_induction _ _ _,\n  { intros c s hs, simp only [← indicator_comp_right],\n    simp [lintegral_indicator, m hs, hs, lintegral_const_mul, measurable_measure_prod_mk_left hs,\n      prod_apply] },\n  { rintro f g - hf hg h2f h2g,\n    simp [lintegral_add, measurable.lintegral_prod_right', hf.comp m, hg.comp m,\n      hf, hg, h2f, h2g] },\n  { intros f hf h2f h3f,\n    have kf : ∀ x n, measurable (λ y, f n (x, y)) := λ x n, (hf n).comp m,\n    have k2f : ∀ x, monotone (λ n y, f n (x, y)) := λ x i j hij y, h2f hij (x, y),\n    have lf : ∀ n, measurable (λ x, ∫⁻ y, f n (x, y) ∂ν) := λ n, (hf n).lintegral_prod_right',\n    have l2f : monotone (λ n x, ∫⁻ y, f n (x, y) ∂ν) := λ i j hij x, lintegral_mono (k2f x hij),\n    simp only [lintegral_supr hf h2f, lintegral_supr (kf _), k2f, lintegral_supr lf l2f, h3f] },\nend\n\n/-- **Tonelli's Theorem**: For `ℝ≥0∞`-valued almost everywhere measurable functions on `α × β`,\n  the integral of `f` is equal to the iterated integral. -/\nlemma lintegral_prod (f : α × β → ℝ≥0∞) (hf : ae_measurable f (μ.prod ν)) :\n  ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ :=\nbegin\n  have A : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ z, hf.mk f z ∂(μ.prod ν) :=\n    lintegral_congr_ae hf.ae_eq_mk,\n  have B : ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ = ∫⁻ x, ∫⁻ y, hf.mk f (x, y) ∂ν ∂μ,\n  { apply lintegral_congr_ae,\n    filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ ha using lintegral_congr_ae ha, },\n  rw [A, B, lintegral_prod_of_measurable _ hf.measurable_mk],\n  apply_instance\nend\n\n/-- The symmetric verion of Tonelli's Theorem: For `ℝ≥0∞`-valued almost everywhere measurable\nfunctions on `α × β`,  the integral of `f` is equal to the iterated integral, in reverse order. -/\nlemma lintegral_prod_symm [sigma_finite μ] (f : α × β → ℝ≥0∞)\n  (hf : ae_measurable f (μ.prod ν)) : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ y, ∫⁻ x, f (x, y) ∂μ ∂ν :=\nby { simp_rw [← lintegral_prod_swap f hf], exact lintegral_prod _ hf.prod_swap }\n\n/-- The symmetric verion of Tonelli's Theorem: For `ℝ≥0∞`-valued measurable\nfunctions on `α × β`,  the integral of `f` is equal to the iterated integral, in reverse order. -/\nlemma lintegral_prod_symm' [sigma_finite μ] (f : α × β → ℝ≥0∞)\n  (hf : measurable f) : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ y, ∫⁻ x, f (x, y) ∂μ ∂ν :=\nlintegral_prod_symm f hf.ae_measurable\n\n/-- The reversed version of **Tonelli's Theorem**. In this version `f` is in curried form, which\nmakes it easier for the elaborator to figure out `f` automatically. -/\nlemma lintegral_lintegral ⦃f : α → β → ℝ≥0∞⦄\n  (hf : ae_measurable (uncurry f) (μ.prod ν)) :\n  ∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ z, f z.1 z.2 ∂(μ.prod ν) :=\n(lintegral_prod _ hf).symm\n\n/-- The reversed version of **Tonelli's Theorem** (symmetric version). In this version `f` is in\ncurried form, which makes it easier for the elaborator to figure out `f` automatically. -/\nlemma lintegral_lintegral_symm [sigma_finite μ] ⦃f : α → β → ℝ≥0∞⦄\n  (hf : ae_measurable (uncurry f) (μ.prod ν)) :\n  ∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ z, f z.2 z.1 ∂(ν.prod μ) :=\n(lintegral_prod_symm _ hf.prod_swap).symm\n\n/-- Change the order of Lebesgue integration. -/\nlemma lintegral_lintegral_swap [sigma_finite μ] ⦃f : α → β → ℝ≥0∞⦄\n  (hf : ae_measurable (uncurry f) (μ.prod ν)) :\n  ∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ y, ∫⁻ x, f x y ∂μ ∂ν :=\n(lintegral_lintegral hf).trans (lintegral_prod_symm _ hf)\n\nlemma lintegral_prod_mul {f : α → ℝ≥0∞} {g : β → ℝ≥0∞}\n  (hf : ae_measurable f μ) (hg : ae_measurable g ν) :\n  ∫⁻ z, f z.1 * g z.2 ∂(μ.prod ν) = ∫⁻ x, f x ∂μ * ∫⁻ y, g y ∂ν :=\nby simp [lintegral_prod _ (hf.fst.mul hg.snd), lintegral_lintegral_mul hf hg]\n\n/-! ### Integrability on a product -/\nsection\n\nvariables [opens_measurable_space E]\n\nlemma integrable.swap [sigma_finite μ] ⦃f : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) : integrable (f ∘ prod.swap) (ν.prod μ) :=\n⟨hf.ae_measurable.prod_swap,\n  (lintegral_prod_swap _ hf.ae_measurable.ennnorm : _).le.trans_lt hf.has_finite_integral⟩\n\nlemma integrable_swap_iff [sigma_finite μ] ⦃f : α × β → E⦄ :\n  integrable (f ∘ prod.swap) (ν.prod μ) ↔ integrable f (μ.prod ν) :=\n⟨λ hf, by { convert hf.swap, ext ⟨x, y⟩, refl }, λ hf, hf.swap⟩\n\nlemma has_finite_integral_prod_iff ⦃f : α × β → E⦄ (h1f : measurable f) :\n  has_finite_integral f (μ.prod ν) ↔ (∀ᵐ x ∂ μ, has_finite_integral (λ y, f (x, y)) ν) ∧\n    has_finite_integral (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=\nbegin\n  simp only [has_finite_integral, lintegral_prod_of_measurable _ h1f.ennnorm],\n  have : ∀ x, ∀ᵐ y ∂ν, 0 ≤ ∥f (x, y)∥ := λ x, eventually_of_forall (λ y, norm_nonneg _),\n  simp_rw [integral_eq_lintegral_of_nonneg_ae (this _)\n    (h1f.norm.comp measurable_prod_mk_left).ae_measurable,\n    ennnorm_eq_of_real to_real_nonneg, of_real_norm_eq_coe_nnnorm],\n  -- this fact is probably too specialized to be its own lemma\n  have : ∀ {p q r : Prop} (h1 : r → p), (r ↔ p ∧ q) ↔ (p → (r ↔ q)) :=\n  λ p q r h1, by rw [← and.congr_right_iff, and_iff_right_of_imp h1],\n  rw [this],\n  { intro h2f, rw lintegral_congr_ae,\n    refine h2f.mp _, apply eventually_of_forall, intros x hx, dsimp only,\n    rw [of_real_to_real], rw [← lt_top_iff_ne_top], exact hx },\n  { intro h2f, refine ae_lt_top _ h2f.ne, exact h1f.ennnorm.lintegral_prod_right' },\nend\n\nlemma has_finite_integral_prod_iff' ⦃f : α × β → E⦄ (h1f : ae_measurable f (μ.prod ν)) :\n  has_finite_integral f (μ.prod ν) ↔ (∀ᵐ x ∂ μ, has_finite_integral (λ y, f (x, y)) ν) ∧\n    has_finite_integral (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=\nbegin\n  rw [has_finite_integral_congr h1f.ae_eq_mk, has_finite_integral_prod_iff h1f.measurable_mk],\n  apply and_congr,\n  { apply eventually_congr,\n    filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm],\n    assume x hx,\n    exact has_finite_integral_congr hx },\n  { apply has_finite_integral_congr,\n    filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] with _ hx\n      using integral_congr_ae (eventually_eq.fun_comp hx _), },\n  { apply_instance, },\nend\n\n\n/-- A binary function is integrable if the function `y ↦ f (x, y)` is integrable for almost every\n  `x` and the function `x ↦ ∫ ∥f (x, y)∥ dy` is integrable. -/\nlemma integrable_prod_iff ⦃f : α × β → E⦄ (h1f : ae_measurable f (μ.prod ν)) :\n  integrable f (μ.prod ν) ↔\n    (∀ᵐ x ∂ μ, integrable (λ y, f (x, y)) ν) ∧ integrable (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=\nby simp [integrable, h1f, has_finite_integral_prod_iff', h1f.norm.integral_prod_right',\n         h1f.prod_mk_left]\n\n/-- A binary function is integrable if the function `x ↦ f (x, y)` is integrable for almost every\n  `y` and the function `y ↦ ∫ ∥f (x, y)∥ dx` is integrable. -/\nlemma integrable_prod_iff' [sigma_finite μ] ⦃f : α × β → E⦄ (h1f : ae_measurable f (μ.prod ν)) :\n  integrable f (μ.prod ν) ↔\n    (∀ᵐ y ∂ ν, integrable (λ x, f (x, y)) μ) ∧ integrable (λ y, ∫ x, ∥f (x, y)∥ ∂μ) ν :=\nby { convert integrable_prod_iff (h1f.prod_swap) using 1, rw [integrable_swap_iff] }\n\nlemma integrable.prod_left_ae [sigma_finite μ] ⦃f : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) : ∀ᵐ y ∂ ν, integrable (λ x, f (x, y)) μ :=\n((integrable_prod_iff' hf.ae_measurable).mp hf).1\n\nlemma integrable.prod_right_ae [sigma_finite μ] ⦃f : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) : ∀ᵐ x ∂ μ, integrable (λ y, f (x, y)) ν :=\nhf.swap.prod_left_ae\n\nlemma integrable.integral_norm_prod_left ⦃f : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) : integrable (λ x, ∫ y, ∥f (x, y)∥ ∂ν) μ :=\n((integrable_prod_iff hf.ae_measurable).mp hf).2\n\nlemma integrable.integral_norm_prod_right [sigma_finite μ] ⦃f : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) : integrable (λ y, ∫ x, ∥f (x, y)∥ ∂μ) ν :=\nhf.swap.integral_norm_prod_left\n\nend\n\nvariables [second_countable_topology E] [normed_space ℝ E]\n  [complete_space E] [borel_space E]\n\nlemma integrable.integral_prod_left ⦃f : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) : integrable (λ x, ∫ y, f (x, y) ∂ν) μ :=\nintegrable.mono hf.integral_norm_prod_left hf.ae_measurable.integral_prod_right' $\n  eventually_of_forall $ λ x, (norm_integral_le_integral_norm _).trans_eq $\n  (norm_of_nonneg $ integral_nonneg_of_ae $ eventually_of_forall $\n  λ y, (norm_nonneg (f (x, y)) : _)).symm\n\nlemma integrable.integral_prod_right [sigma_finite μ] ⦃f : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) : integrable (λ y, ∫ x, f (x, y) ∂μ) ν :=\nhf.swap.integral_prod_left\n\n/-! ### The Bochner integral on a product -/\n\nvariables [sigma_finite μ]\n\nlemma integral_prod_swap (f : α × β → E)\n  (hf : ae_measurable f (μ.prod ν)) : ∫ z, f z.swap ∂(ν.prod μ) = ∫ z, f z ∂(μ.prod ν) :=\nbegin\n  rw ← prod_swap at hf,\n  rw [← integral_map measurable_swap hf, prod_swap]\nend\n\nvariables {E' : Type*} [measurable_space E'] [normed_group E'] [borel_space E'] [complete_space E']\n  [normed_space ℝ E'] [second_countable_topology E']\n\n/-! Some rules about the sum/difference of double integrals. They follow from `integral_add`, but\n  we separate them out as separate lemmas, because they involve quite some steps. -/\n\n/-- Integrals commute with addition inside another integral. `F` can be any function. -/\nlemma integral_fn_integral_add ⦃f g : α × β → E⦄ (F : E → E')\n  (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :\n  ∫ x, F (∫ y, f (x, y) + g (x, y) ∂ν) ∂μ = ∫ x, F (∫ y, f (x, y) ∂ν + ∫ y, g (x, y) ∂ν) ∂μ :=\nbegin\n  refine integral_congr_ae _,\n  filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g,\n  simp [integral_add h2f h2g],\nend\n\n/-- Integrals commute with subtraction inside another integral.\n  `F` can be any measurable function. -/\nlemma integral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → E')\n  (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :\n  ∫ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ = ∫ x, F (∫ y, f (x, y) ∂ν - ∫ y, g (x, y) ∂ν) ∂μ :=\nbegin\n  refine integral_congr_ae _,\n  filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g,\n  simp [integral_sub h2f h2g],\nend\n\n/-- Integrals commute with subtraction inside a lower Lebesgue integral.\n  `F` can be any function. -/\nlemma lintegral_fn_integral_sub ⦃f g : α × β → E⦄\n  (F : E → ℝ≥0∞) (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :\n  ∫⁻ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ = ∫⁻ x, F (∫ y, f (x, y) ∂ν - ∫ y, g (x, y) ∂ν) ∂μ :=\nbegin\n  refine lintegral_congr_ae _,\n  filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g,\n  simp [integral_sub h2f h2g],\nend\n\n/-- Double integrals commute with addition. -/\nlemma integral_integral_add ⦃f g : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :\n  ∫ x, ∫ y, f (x, y) + g (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ + ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=\n(integral_fn_integral_add id hf hg).trans $\n  integral_add hf.integral_prod_left hg.integral_prod_left\n\n/-- Double integrals commute with addition. This is the version with `(f + g) (x, y)`\n  (instead of `f (x, y) + g (x, y)`) in the LHS. -/\nlemma integral_integral_add' ⦃f g : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :\n  ∫ x, ∫ y, (f + g) (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ + ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=\nintegral_integral_add hf hg\n\n/-- Double integrals commute with subtraction. -/\nlemma integral_integral_sub ⦃f g : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :\n  ∫ x, ∫ y, f (x, y) - g (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ - ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=\n(integral_fn_integral_sub id hf hg).trans $\n  integral_sub hf.integral_prod_left hg.integral_prod_left\n\n/-- Double integrals commute with subtraction. This is the version with `(f - g) (x, y)`\n  (instead of `f (x, y) - g (x, y)`) in the LHS. -/\nlemma integral_integral_sub' ⦃f g : α × β → E⦄\n  (hf : integrable f (μ.prod ν)) (hg : integrable g (μ.prod ν)) :\n  ∫ x, ∫ y, (f - g) (x, y) ∂ν ∂μ = ∫ x, ∫ y, f (x, y) ∂ν ∂μ - ∫ x, ∫ y, g (x, y) ∂ν ∂μ :=\nintegral_integral_sub hf hg\n\n/-- The map that sends an L¹-function `f : α × β → E` to `∫∫f` is continuous. -/\nlemma continuous_integral_integral :\n  continuous (λ (f : α × β →₁[μ.prod ν] E), ∫ x, ∫ y, f (x, y) ∂ν ∂μ) :=\nbegin\n  rw [continuous_iff_continuous_at], intro g,\n  refine tendsto_integral_of_L1 _ (L1.integrable_coe_fn g).integral_prod_left\n    (eventually_of_forall $ λ h, (L1.integrable_coe_fn h).integral_prod_left) _,\n  simp_rw [← lintegral_fn_integral_sub (λ x, (nnnorm x : ℝ≥0∞)) (L1.integrable_coe_fn _)\n    (L1.integrable_coe_fn g)],\n  refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds _ (λ i, zero_le _) _,\n  { exact λ i, ∫⁻ x, ∫⁻ y, nnnorm (i (x, y) - g (x, y)) ∂ν ∂μ },\n  swap, { exact λ i, lintegral_mono (λ x, ennnorm_integral_le_lintegral_ennnorm _) },\n  show tendsto (λ (i : α × β →₁[μ.prod ν] E),\n    ∫⁻ x, ∫⁻ (y : β), nnnorm (i (x, y) - g (x, y)) ∂ν ∂μ) (𝓝 g) (𝓝 0),\n  have : ∀ (i : α × β →₁[μ.prod ν] E), measurable (λ z, (nnnorm (i z - g z) : ℝ≥0∞)) :=\n  λ i, ((Lp.measurable i).sub (Lp.measurable g)).ennnorm,\n  simp_rw [← lintegral_prod_of_measurable _ (this _), ← L1.of_real_norm_sub_eq_lintegral,\n    ← of_real_zero],\n  refine (continuous_of_real.tendsto 0).comp _,\n  rw [← tendsto_iff_norm_tendsto_zero], exact tendsto_id\nend\n\n/-- **Fubini's Theorem**: For integrable functions on `α × β`,\n  the Bochner integral of `f` is equal to the iterated Bochner integral.\n  `integrable_prod_iff` can be useful to show that the function in question in integrable.\n  `measure_theory.integrable.integral_prod_right` is useful to show that the inner integral\n  of the right-hand side is integrable. -/\nlemma integral_prod : ∀ (f : α × β → E) (hf : integrable f (μ.prod ν)),\n  ∫ z, f z ∂(μ.prod ν) = ∫ x, ∫ y, f (x, y) ∂ν ∂μ :=\nbegin\n  apply integrable.induction,\n  { intros c s hs h2s,\n    simp_rw [integral_indicator hs, ← indicator_comp_right,\n      function.comp, integral_indicator (measurable_prod_mk_left hs),\n      set_integral_const, integral_smul_const,\n      integral_to_real (measurable_measure_prod_mk_left hs).ae_measurable\n      (ae_measure_lt_top hs h2s.ne), prod_apply hs] },\n  { intros f g hfg i_f i_g hf hg,\n    simp_rw [integral_add' i_f i_g, integral_integral_add' i_f i_g, hf, hg] },\n  { exact is_closed_eq continuous_integral continuous_integral_integral },\n  { intros f g hfg i_f hf, convert hf using 1,\n    { exact integral_congr_ae hfg.symm },\n    { refine integral_congr_ae _,\n      refine (ae_ae_of_ae_prod hfg).mp _,\n      apply eventually_of_forall, intros x hfgx,\n      exact integral_congr_ae (ae_eq_symm hfgx) } }\nend\n\n/-- Symmetric version of **Fubini's Theorem**: For integrable functions on `α × β`,\n  the Bochner integral of `f` is equal to the iterated Bochner integral.\n  This version has the integrals on the right-hand side in the other order. -/\nlemma integral_prod_symm (f : α × β → E) (hf : integrable f (μ.prod ν)) :\n  ∫ z, f z ∂(μ.prod ν) = ∫ y, ∫ x, f (x, y) ∂μ ∂ν :=\nby { simp_rw [← integral_prod_swap f hf.ae_measurable], exact integral_prod _ hf.swap }\n\n/-- Reversed version of **Fubini's Theorem**. -/\nlemma integral_integral {f : α → β → E} (hf : integrable (uncurry f) (μ.prod ν)) :\n  ∫ x, ∫ y, f x y ∂ν ∂μ = ∫ z, f z.1 z.2 ∂(μ.prod ν) :=\n(integral_prod _ hf).symm\n\n/-- Reversed version of **Fubini's Theorem** (symmetric version). -/\nlemma integral_integral_symm {f : α → β → E} (hf : integrable (uncurry f) (μ.prod ν)) :\n  ∫ x, ∫ y, f x y ∂ν ∂μ = ∫ z, f z.2 z.1 ∂(ν.prod μ) :=\n(integral_prod_symm _ hf.swap).symm\n\n/-- Change the order of Bochner integration. -/\nlemma integral_integral_swap ⦃f : α → β → E⦄ (hf : integrable (uncurry f) (μ.prod ν)) :\n  ∫ x, ∫ y, f x y ∂ν ∂μ = ∫ y, ∫ x, f x y ∂μ ∂ν :=\n(integral_integral hf).trans (integral_prod_symm _ hf)\n\n/-- **Fubini's Theorem** for set integrals. -/\nlemma set_integral_prod (f : α × β → E) {s : set α} {t : set β}\n  (hf : integrable_on f (s ×ˢ t) (μ.prod ν)) :\n  ∫ z in s ×ˢ t, f z ∂(μ.prod ν) = ∫ x in s, ∫ y in t, f (x, y) ∂ν ∂μ :=\nbegin\n  simp only [← measure.prod_restrict s t, integrable_on] at hf ⊢,\n  exact integral_prod f hf\nend\n\nend measure_theory\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/measure_theory/constructions/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.661922862511608, "lm_q1q2_score": 0.47980821602492296}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport category_theory.endomorphism\nimport category_theory.category.Cat\nimport algebra.category.Mon.basic\nimport combinatorics.quiver.single_obj\n\n/-!\n# Single-object category\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nSingle object category with a given monoid of endomorphisms.\nIt is defined to facilitate transfering some definitions and lemmas (e.g., conjugacy etc.)\nfrom category theory to monoids and groups.\n\n## Main definitions\n\nGiven a type `α` with a monoid structure, `single_obj α` is `unit` type with `category` structure\nsuch that `End (single_obj α).star` is the monoid `α`.  This can be extended to a functor `Mon ⥤\nCat`.\n\nIf `α` is a group, then `single_obj α` is a groupoid.\n\nAn element `x : α` can be reinterpreted as an element of `End (single_obj.star α)` using\n`single_obj.to_End`.\n\n## Implementation notes\n\n- `category_struct.comp` on `End (single_obj.star α)` is `flip (*)`, not `(*)`. This way\n  multiplication on `End` agrees with the multiplication on `α`.\n\n- By default, Lean puts instances into `category_theory` namespace instead of\n  `category_theory.single_obj`, so we give all names explicitly.\n-/\n\nuniverses u v w\n\nnamespace category_theory\n\n/--\nAbbreviation that allows writing `category_theory.single_obj` rather than `quiver.single_obj`.\n-/\nabbreviation single_obj := quiver.single_obj\n\nnamespace single_obj\n\nvariables (α : Type u)\n\n/-- One and `flip (*)` become `id` and `comp` for morphisms of the single object category. -/\ninstance category_struct [has_one α] [has_mul α] : category_struct (single_obj α) :=\n{ hom := λ _ _, α,\n  comp := λ _ _ _ x y, y * x,\n  id := λ _, 1 }\n\n/-- Monoid laws become category laws for the single object category. -/\ninstance category [monoid α] : category (single_obj α) :=\n{ comp_id' := λ _ _, one_mul,\n  id_comp' := λ _ _, mul_one,\n  assoc' := λ _ _ _ _ x y z, (mul_assoc z y x).symm }\n\nlemma id_as_one [monoid α] (x : single_obj α) : 𝟙 x = 1 := rfl\n\nlemma comp_as_mul [monoid α] {x y z : single_obj α} (f : x ⟶ y) (g : y ⟶ z) :\n  f ≫ g = g * f := rfl\n\n/--\nGroupoid structure on `single_obj α`.\n\nSee <https://stacks.math.columbia.edu/tag/0019>.\n-/\ninstance groupoid [group α] : groupoid (single_obj α) :=\n{ inv := λ _ _ x, x⁻¹,\n  inv_comp' := λ _ _, mul_right_inv,\n  comp_inv' := λ _ _, mul_left_inv }\n\n\n\n/--\nAbbreviation that allows writing `category_theory.single_obj.star` rather than\n`quiver.single_obj.star`.\n-/\nabbreviation star : single_obj α := quiver.single_obj.star α\n\n/-- The endomorphisms monoid of the only object in `single_obj α` is equivalent to the original\n     monoid α. -/\ndef to_End [monoid α] : α ≃* End (single_obj.star α) :=\n{ map_mul' := λ x y, rfl,\n  .. equiv.refl α }\n\nlemma to_End_def [monoid α] (x : α) : to_End α x = x := rfl\n\n/-- There is a 1-1 correspondence between monoid homomorphisms `α → β` and functors between the\n    corresponding single-object categories. It means that `single_obj` is a fully faithful\n    functor.\n\nSee <https://stacks.math.columbia.edu/tag/001F> --\nalthough we do not characterize when the functor is full or faithful.\n-/\ndef map_hom (α : Type u) (β : Type v) [monoid α] [monoid β] :\n  (α →* β) ≃ (single_obj α) ⥤ (single_obj β) :=\n{ to_fun := λ f,\n  { obj := id,\n    map := λ _ _, ⇑f,\n    map_id' := λ _, f.map_one,\n    map_comp' := λ _ _ _ x y, f.map_mul y x },\n  inv_fun := λ f,\n    { to_fun := @functor.map _ _ _ _ f (single_obj.star α) (single_obj.star α),\n      map_one' := f.map_id _,\n      map_mul' := λ x y, f.map_comp y x },\n  left_inv := λ ⟨f, h₁, h₂⟩, rfl,\n  right_inv := λ f, by cases f; obviously }\n\nlemma map_hom_id (α : Type u) [monoid α] : map_hom α α (monoid_hom.id α) = 𝟭 _ := rfl\n\nlemma map_hom_comp {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β)\n  {γ : Type w} [monoid γ] (g : β →* γ) :\n  map_hom α γ (g.comp f) = map_hom α β f ⋙ map_hom β γ g :=\nrfl\n\n/-- Given a function `f : C → G` from a category to a group, we get a functor\n    `C ⥤ G` sending any morphism `x ⟶ y` to `f y * (f x)⁻¹`. -/\n@[simps] def difference_functor {C G} [category C] [group G] (f : C → G) : C ⥤ single_obj G :=\n{ obj := λ _, (),\n  map := λ x y _, f y * (f x)⁻¹,\n  map_id' := by { intro, rw [single_obj.id_as_one, mul_right_inv] },\n  map_comp' := by { intros, rw [single_obj.comp_as_mul, ←mul_assoc,\n    mul_left_inj, mul_assoc, inv_mul_self, mul_one] } }\n\nend single_obj\n\nend category_theory\n\nopen category_theory\n\nnamespace monoid_hom\n\n/-- Reinterpret a monoid homomorphism `f : α → β` as a functor `(single_obj α) ⥤ (single_obj β)`.\nSee also `category_theory.single_obj.map_hom` for an equivalence between these types. -/\n@[reducible] def to_functor {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β) :\n  (single_obj α) ⥤ (single_obj β) :=\nsingle_obj.map_hom α β f\n\n@[simp] lemma id_to_functor (α : Type u) [monoid α] : (id α).to_functor = 𝟭 _ := rfl\n@[simp] lemma comp_to_functor {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β)\n  {γ : Type w} [monoid γ] (g : β →* γ) :\n  (g.comp f).to_functor = f.to_functor ⋙ g.to_functor :=\nrfl\n\nend monoid_hom\n\nnamespace units\n\nvariables (α : Type u) [monoid α]\n\n/--\nThe units in a monoid are (multiplicatively) equivalent to\nthe automorphisms of `star` when we think of the monoid as a single-object category. -/\ndef to_Aut : αˣ ≃* Aut (single_obj.star α) :=\n(units.map_equiv (single_obj.to_End α)).trans $\n  Aut.units_End_equiv_Aut _\n\n@[simp] lemma to_Aut_hom (x : αˣ) : (to_Aut α x).hom = single_obj.to_End α x := rfl\n@[simp] lemma to_Aut_inv (x : αˣ) :\n  (to_Aut α x).inv = single_obj.to_End α (x⁻¹ : αˣ) :=\nrfl\nend units\n\nnamespace Mon\n\nopen category_theory\n\n/-- The fully faithful functor from `Mon` to `Cat`. -/\ndef to_Cat : Mon ⥤ Cat :=\n{ obj := λ x, Cat.of (single_obj x),\n  map := λ x y f, single_obj.map_hom x y f }\n\ninstance to_Cat_full : full to_Cat :=\n{ preimage := λ x y, (single_obj.map_hom x y).inv_fun,\n  witness' := λ x y, by apply equiv.right_inv }\n\ninstance to_Cat_faithful : faithful to_Cat :=\n{ map_injective' := λ x y, by apply equiv.injective }\n\nend Mon\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/single_obj.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.4797949781299599}}
{"text": "import ..library.src_real_field_lemmas\nimport ..library.src_ordered_field_lemmas\nimport data.set.basic\nimport tactic\n\n/-\nThere are no explicit exercises in this file, though you may choose to prove examples yourself.\nThe aim of this file is to prove that there is a real number whose square is 2.\n-/\n\nnamespace mth1001\n\nnamespace myreal\n\nsection auxiliary\n\nopen myreal_field classical myordered_field\n\nopen_locale classical\n\nvariables {R : Type} [myreal_field R]\n\nlemma difference_of_two_squares (x y : R) : x*x - y*y = (x - y)*(x+y) :=\nbegin\n  rw mul_add,\n  repeat { rw sub_eq_add_neg' <|> rw add_mul },\n  rw [←neg_neg (x*y), neg_mul_eq_mul_neg x y, mul_comm x (-y), add_assoc, ←add_assoc (-y*x) _ _],\n  rw [add_neg', zero_add, neg_mul_eq_mul_neg, mul_comm y (-y)],\nend\n\nlemma square_le_square_iff_le_of_non_neg_of_non_neg (a b : R) (h₁ : 0 ≤ a) (h₂ : 0 ≤ b)\n: a*a ≤ b*b ↔ a ≤ b :=\nbegin\n  split,\n  { intro aalebb,\n    have h₃ : 0 ≤ b*b - a*a, linarith,\n    rw difference_of_two_squares b a at h₃,\n    rw non_neg_mul_iff_non_neg_and_non_neg_or_non_pos_and_non_pos at h₃,\n    cases h₃; linarith },\n  { intro aleb,\n    exact mul_le_mul aleb aleb h₁ h₂, },\nend\n\nlemma pos_mul_iff_pos_and_pos_or_neg_and_neg (a b : R)\n  : 0 < a * b ↔ (0 < a ∧ 0 < b) ∨ (a < 0 ∧ b < 0) :=\nbegin\n  split,\n  { intro h,\n    by_cases h₂ : 0 ≤ a,\n    { by_cases h₃ : a = 0,\n      { rw h₃ at h, linarith, },\n      { have h₄ : 0 < a, from or.elim h₂ id (λ aeq0, absurd aeq0.symm h₃), \n        have h₅ : 0 < b, from (zero_lt_mul_left h₄).mp h,\n        exact or.inl ⟨h₄, h₅⟩, }, },\n    { have h₄ : a < 0, linarith,\n      have h₅ : b < 0, \n      { by_contra p,\n        rw not_lt_iff_le at p,\n        rw ←neg_pos at h₄,\n        have h₅ : 0 ≤ (-a) * b, from (zero_le_mul_left h₄).mpr p,\n        have h₆ : -a * b = -(a*b),\n        { rw [mul_comm (-a), ←neg_mul_eq_mul_neg, mul_comm], },\n        rw h₆ at h₅,\n        linarith, },\n        exact or.inr ⟨h₄, h₅⟩, }, },\n  { rintro (⟨apos, bpos⟩ | ⟨aneg, bneg⟩),\n    { exact gt_zero_mul_of_gt_zero_of_gt_zero apos bpos },\n    { rw ←neg_mul_neg a b,\n      rw ←neg_pos at aneg bneg,\n      exact gt_zero_mul_of_gt_zero_of_gt_zero aneg bneg, }, },\nend\n\nlemma square_lt_square_iff_lt_of_pos_of_pos (a b : R) (h₁ : 0 < a) (h₂ : 0 < b)\n: a*a < b*b ↔ a < b :=\nbegin\n  split,\n  { intro aalebb,\n    have h₃ : 0 < b*b - a*a, linarith,\n    rw difference_of_two_squares b a at h₃,\n    rw pos_mul_iff_pos_and_pos_or_neg_and_neg at h₃,\n    rcases h₃ with ⟨h₃_left, h₃_right⟩ | ⟨h₃_left, h₃_right⟩,\n    { linarith, },\n    { have h₄ : a < -b, linarith,\n      have h₅ : -b < 0, linarith,\n      have h₆ : a < 0, from lt_trans h₄ h₅,\n      have : (0 : R) < 0, from lt_trans h₁ h₆, \n      linarith, }, },\n  { intro aleb,\n    apply mul_lt_mul,\n    { exact aleb, },\n    { exact le_of_lt aleb, },\n    { exact h₁ },\n    { exact le_of_lt h₂ }, },\nend\n\nlemma zero_eq_zero : (0 : R) = ↑0 := rfl\n\nlemma one_eq_one : ↑1 = (1 : R) :=\nby rw [coe_nat_succ, ←zero_eq_zero, zero_add]\n\nlemma pos_iff_gt_zero (x : R) : pos x ↔ 0 < x := \nby rw [lt_iff_pos_sub, sub_zero]\n\nlemma non_zero_of_pos {x : R} (h : 0 < x) : x ≠ 0 :=\nbegin\n  intro k,\n  rw k at h,\n  exact lt_irrefl h,\nend\n\nlemma coe_zero_inj {m : ℕ} (h : (m : R) = 0) : m = 0 :=\nbegin\n  by_contra k,\n  have h₂ : pos(m : R), from pos_nat m k,\n  rw [h, pos_iff_gt_zero (0 : R)] at h₂,\n  exact lt_irrefl h₂,\nend\n\nlemma coe_non_zero_of_non_zero {m : ℕ} (h : m ≠ 0) : (m : R) ≠ 0 :=\nbegin\n  contrapose! h,\n  exact coe_zero_inj h,\nend\n\nlemma gt_zero_of_ne_zero_nat (n : ℕ) (h : n ≠ 0) : (0 : R) < n :=\nbegin\n  rw [←pos_iff_gt_zero],\n  exact pos_nat n h,\nend\n\nlemma coe_pred (n : ℕ) (h : n ≠ 0) : (↑(n-1) : R) = ↑n - 1 :=\nbegin\n  induction n with k hk,\n  { exfalso, apply h, refl, },\n  { have : nat.succ k - 1 = k := rfl,\n    rw [this, coe_nat_succ, sub_eq_add_neg', add_assoc, add_neg', add_zero ], },\nend\n\nlemma coe_pred_eq_of_coe_succ_eq {x k : ℕ} (h : ↑x = ↑k + (1 : R)) : (↑(x-1) : R)= ↑k :=\nbegin\n  by_cases xeq0 : x = 0,\n  { exfalso, rw xeq0 at h, \n    change 0 = ↑k + (1:R) at h,\n    have h₂ : ↑k = -(1 : R),\n    { rw [←zero_add (-1: R), h, add_assoc, add_neg', add_zero], },\n    have h₃ : (0 : R) ≤ ↑k,\n    { rw le_iff_lt_or_eq,\n      by_cases h₄ : k = 0,\n      { rw h₄, right, refl, },\n      { left, rw ←pos_iff_gt_zero, exact pos_nat k h₄, }, },\n    rw h₂ at h₃,\n    linarith, },\n  { change x ≠ 0 at xeq0,\n    rw coe_pred _ xeq0,\n    linarith, }\nend\n\nlemma coe_inj (m n : ℕ) (h : (m : R) = (n : R)) : m = n :=\nbegin\n  revert m,\n  induction n with k hk,\n  { intro m, exact coe_zero_inj, },\n  { intros x hx,\n    rw coe_nat_succ at hx,\n    specialize hk (x-1),\n    by_cases h₂ : x = 0,\n    { rw [h₂, ←zero_eq_zero] at hx,\n      have h₂ : ↑k = -(1 : R),\n      { rw [←zero_add (-1: R), hx, add_assoc, add_neg', add_zero], },\n      have h₃ : (0 : R) ≤ ↑k,\n      { rw le_iff_lt_or_eq,\n        by_cases h₄ : k = 0,\n        { rw h₄, right, refl, },\n        { left, rw ←pos_iff_gt_zero, exact pos_nat k h₄, }, },\n      rw h₂ at h₃,\n      linarith, },\n    { rw coe_pred x h₂ at hk, \n      have h₃ : ↑x - (1 : R) = ↑k, linarith,\n      have h₄ : x - 1 = k, from hk h₃,\n      rw ←h₄,\n      cases nat.eq_zero_or_eq_succ_pred x with x0 xsp,\n      { exact absurd x0 h₂, },\n      { assumption, }, }, },\nend\n\nlemma coe_monotone (m n : ℕ) (h : m ≤ n) : (m : R) ≤ (n : R) :=\nbegin\n  revert n,\n  induction m with k hk,\n  { intros n h,\n    rw [←zero_eq_zero,le_iff_lt_or_eq],\n    by_cases h₂ : n = 0,\n    { right, rw [h₂, zero_eq_zero], },\n    { left, exact gt_zero_of_ne_zero_nat n h₂, }, },\n  { intros x hx,\n    specialize hk (x-1),\n    by_cases h₂ : x = 0,\n    { exfalso,\n      rw [h₂, ←not_lt] at hx,\n      exact hx (nat.succ_pos k), },\n    { rcases nat.exists_eq_succ_of_ne_zero h₂ with ⟨w, h⟩,\n      rw coe_nat_succ,\n      rw coe_pred x h₂ at hk,\n      rw h at hx hk,\n      suffices h₃ : ↑k ≤ ↑(nat.succ w) - (1 : R),\n      { rw h, linarith, },\n      have h₃ : nat.succ w - 1 = w := rfl,\n      rw h₃ at hk,\n      rw ←nat.pred_le_iff at hx,\n      change k ≤ w at hx,\n      exact hk hx, }, },\nend\n\nlemma coe_monotone' (m n : ℕ) (h : m < n) : (m : R) < (n : R) :=\nbegin\n  have h₂ : m ≤ n, linarith,\n  have h₃ : (m : R) ≤ n, from coe_monotone _ _ h₂,\n  rw le_iff_lt_or_eq at h₃,\n  cases h₃ with mltn meqn,\n  { exact mltn, },\n  { have h₃ : m = n, from coe_inj m n meqn, \n    linarith, },\nend\n\nlemma non_neg_of_non_neg (n : ℕ) (h : 0 ≤ n) : (0 : R) ≤ ↑n :=\nbegin\n  rw le_iff_lt_or_eq,\n  by_cases h₂ : n = 0,\n  { right, rw [h₂, zero_eq_zero], },\n  { left, exact gt_zero_of_ne_zero_nat n h₂, }\nend\n\nlemma ge_one_of_non_zero (k : ℕ) (h : k ≠ 0): (1 : R) ≤ k :=\nbegin\n  induction k with m hm,\n  { exfalso,\n    apply h, refl, },\n  { rw coe_nat_succ m,\n    conv {to_lhs, rw ←add_zero (1 : R)},\n    by_cases h₂ : m = 1,\n    { rw [h₂, add_zero, one_eq_one], \n      change (1 : R) ≤ 2,\n      rw le_iff_lt_or_eq,\n      left,\n      linarith, },\n    { rw add_comm,\n      apply add_le_add,\n      { rw le_iff_lt_or_eq,\n        by_cases h₃ : m = 0,\n        { right, rw h₃, refl, },\n        { left, exact gt_zero_of_ne_zero_nat m h₃, }, },\n      { exact le_refl 1, }, }, },\nend\n\nlemma pos_inv_nat_of_non_zero {n : ℕ} (h : n ≠ 0) : (0 : R) < (↑n)⁻¹ :=\nbegin\n  have h₂ : (0 : R) < ↑n, from gt_zero_of_ne_zero_nat n h,\n  have h₃ : ↑n ≠ (0 : R), from non_zero_of_pos h₂,\n  rwa inv_pos h₃,\nend\n\ntheorem inv_le_inv {a b : R} (h₁ : 0 < a) (h₂ : 0 < b) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a :=\nbegin\n  have k₁ : a ≠ (0 : R), from non_zero_of_pos h₁,\n  have k₂ : b ≠ 0, from non_zero_of_pos h₂,\n  repeat {rw le_iff_lt_or_eq },\n  split,\n  { rintro (hlt | heq),\n    { left,\n      rwa ←inv_lt_inv h₁ h₂, },\n    { right,\n      rw [←inv_inv' a k₁, ←inv_inv' b k₂, heq], }, },\n  { rintro (hlt | heq),\n    { left, \n      rwa inv_lt_inv h₁ h₂, },\n    { rw heq, right, refl, }, },\nend\n\nlemma pos_add_inv_nat_of_pos {u : R} {n : ℕ} (h : (0 : R) < u) (h₂ : n ≠ 0)\n: (0 : R) < u + (↑n)⁻¹ :=\nbegin\n  rw ←add_zero (0 : R),\n  apply add_lt_add h,\n  rw inv_pos (coe_non_zero_of_non_zero h₂),\n  exact gt_zero_of_ne_zero_nat n h₂,\nend\n\nlemma pos_sub_inv_nat_of_pos {u : R} {n : ℕ} (k₄ : (0 : R) < u) (ne0 : n ≠ 0) (k₅ : 2 < u*u)\n: (0 : R) < u - (↑n)⁻¹ :=\nbegin\n  by_contra p, \n  have : u ≤ (↑n)⁻¹, linarith,\n  have h₂ : (1 : R) ≤ (↑n), from ge_one_of_non_zero n ne0,\n  have h₃ : (0 : R) < ↑n, {rw ←pos_iff_gt_zero, exact pos_nat n ne0},\n  have h₄ : (↑n)⁻¹ ≤ (1 : R)⁻¹, { rwa inv_le_inv h₃ zero_lt_one, },\n  have h₅ : u ≤ (1 : R)⁻¹, linarith,\n  rw one_inv at h₅,\n  have : u * u ≤ 1 * 1, from mul_le_mul h₅ h₅ (le_of_lt k₄) zero_le_one,\n  linarith,\nend\n\n\nlemma lt_sub_inv_nat {u : R} {n : ℕ} (h₂ : n ≠ 0)\n: u - (↑n)⁻¹ < u:=\nbegin\n  rw [sub_eq_add_neg', add_lt_iff_neg_left, neg_lt_zero, inv_pos (coe_non_zero_of_non_zero h₂)],\n  exact gt_zero_of_ne_zero_nat n h₂,\nend\n\nend auxiliary\n\nnamespace sqrt_two\n\nopen myreal_field classical myordered_field\n\nopen_locale classical\n\nvariables {R : Type} [myreal_field R]\n\nlemma has_upper_bound_S : has_upper_bound ({x : R | (0 < x) ∧ (x*x < 2)} : set R) :=\nbegin\n  use (2 : R),\n  intros s hs,\n  cases hs with h₁ h₂, -- `h₁ : 0 < s`, `h₂ : s * s < 2`, \n  have h₄ : (2 : R) < 2 * 2, linarith,\n  have h₅ : s * s < 2*2,\n  { apply lt_trans h₂ h₄, },\n  have : s * s ≤ 2*2, from le_of_lt h₅,\n  have h₆ : 0 < (2 : R), linarith,\n  have h₇ : 0 ≤ (2 : R), from le_of_lt h₆,\n  rwa ←square_le_square_iff_le_of_non_neg_of_non_neg _ _ (le_of_lt h₁) h₇,\nend \n\nlemma one_in_S : (1 : R) ∈ {x : R | (0 < x) ∧ (x*x < 2)} :=\n⟨by linarith, by linarith⟩\n\nlemma non_empty_S : ({x : R | (0 < x) ∧ (x*x < 2)} : set R) ≠ ∅ :=\nbegin\n  have h : (1 : R) ∈ {x : R | (0 < x) ∧ (x*x < 2)}, from one_in_S,\n  intro h₂,\n  rw h₂ at h,\n  exact h,\nend\n\nlemma not_upper_bound_of_exists_nat {u : R} {S : set R} (h : ∃ n : ℕ, n ≠ 0 ∧ (u + (↑n)⁻¹ ∈ S))\n: ¬(upper_bound u S) :=\nbegin\n  rcases h with ⟨n, ne0, hn⟩,\n  unfold upper_bound,\n  push_neg,\n  use (u + (↑n)⁻¹),\n  apply and.intro hn,\n  suffices h : (0 : R) + u< (↑n)⁻¹ + u,\n  { rwa [zero_add, add_comm] at h,},\n  apply add_lt_add_iff_right_mpr,\n  have h₂ : (0 : R) < n, from gt_zero_of_ne_zero_nat n ne0,\n  rwa inv_pos (coe_non_zero_of_non_zero ne0),\nend\n\nlemma not_lub_of_exists_nat {u : R} {S : set R} (h : ∃ n : ℕ, n ≠ 0 ∧ (upper_bound (u - (↑n)⁻¹) S))\n: ¬(∀ v : R, upper_bound v S → u ≤ v) :=\nbegin\n  rcases h with ⟨n, ne0, hn⟩,\n  push_neg,\n  use (u - (↑n)⁻¹),\n  exact and.intro hn (lt_sub_inv_nat ne0),\nend\n\ndef S : set R := {x : R | (0 < x) ∧ (x*x < 2)}\n\nsection lemmas_for_ub_contra\n\nlemma pos_sub_inv_nat_of_pos {u : R} {n : ℕ} (k₄ : (0 : R) < u) (ne0 : n ≠ 0) (k₅ : 2 < u*u)\n: (0 : R) < u - (↑n)⁻¹ :=\nbegin\n  by_contra p, \n  have : u ≤ (↑n)⁻¹, linarith,\n  have h₂ : (1 : R) ≤ (↑n), from ge_one_of_non_zero n ne0,\n  have h₃ : (0 : R) < ↑n, {rw ←pos_iff_gt_zero, exact pos_nat n ne0},\n  have h₄ : (↑n)⁻¹ ≤ (1 : R)⁻¹, { rwa inv_le_inv h₃ zero_lt_one, },\n  have h₅ : u ≤ (1 : R)⁻¹, linarith,\n  rw one_inv at h₅,\n  have : u * u ≤ 1 * 1, from mul_le_mul h₅ h₅ (le_of_lt k₄) zero_le_one,\n  linarith,\nend\n\nlemma sq_add_inv_ub {u : R} {k : ℕ} (h : k ≠ 0)\n: (u + (↑k)⁻¹)*(u + (↑k)⁻¹) ≤ u*u + (2*u+1)*(↑k)⁻¹ :=\nbegin\n  rw [add_mul, add_mul, mul_add, mul_add, mul_comm (↑k)⁻¹ u, one_mul, add_assoc],\n  apply add_le_add (le_refl (u* u)),\n  rw [←add_assoc, ←two_mul, ←mul_assoc],\n  apply add_le_add (le_refl _),\n  have h₂ : (k : R) ≠ 0, from coe_non_zero_of_non_zero h,\n  suffices h : (↑k)⁻¹ * (↑k)⁻¹ ≤ (↑k)⁻¹ * (1 : R),\n  { rwa mul_one at h, },\n  have h₃ : (1 : R) ≤ (↑k), from ge_one_of_non_zero k h,\n  have h₄ : (↑k)⁻¹ ≤ (1 : R),\n  { rwa [←one_inv, inv_le_inv (gt_zero_of_ne_zero_nat k h) (zero_lt_one : (0 : R) < 1)], },\n  have h₅ : (0 : R) < (↑k)⁻¹, from pos_inv_nat_of_non_zero h,\n  exact mul_le_mul (le_refl (↑k)⁻¹) h₄ (le_of_lt h₅) (le_of_lt h₅),\nend\n\nlemma inequ1 {u : R} (h₁ : 0 < u) (h₂ : u*u < 2) : (0 : R) < (2*u + 1)⁻¹ * (2 - u*u) :=\nbegin\n  have h₃ : 0 < 2 - u * u, linarith,\n  have h₄ : 0 < 2 * u + 1, from add_pos (by linarith) (by linarith),\n  have h₅ : 2*u+ 1 ≠ 0, linarith,\n  have h₆ : 0 < (2*u + 1)⁻¹, from (inv_pos h₅).mpr h₄,\n  exact mul_pos _ _ h₆ h₃,\nend\n\nlemma inequ2 {u : R} {n : ℕ} (h₁ : 0 < u) (h₂ : (↑n)⁻¹ < (2 * u + 1)⁻¹ * (2 - u * u))\n: u * u +  (2 * u + 1) * (↑n)⁻¹ < 2:=\nbegin\n  suffices h : ((2 : R)*u+1) * (↑n)⁻¹ < (2- u * u), linarith,\n  have h₄ : 0 < 2 * u + 1, from add_pos (by linarith) (by linarith),\n  have h₅ : 2*u+ 1 ≠ 0, linarith,\n  suffices h : (2 * u + 1) * (↑n)⁻¹ < (2 * u + 1) * ((2*u + 1)⁻¹ * (2 - u * u)),\n  { rwa [←mul_assoc, mul_inv _ h₅, one_mul] at h, },\n  exact mul_lt_mul_left_mpr h₄ h₂,\nend\n\nlemma ub_contra {u : R} (k₃ : upper_bound u S) (k₄ : (0 : R) < u) (k₅ : u * u < 2) : u * u = 2 :=\nbegin\n  suffices h : ¬(upper_bound u S), from absurd k₃ h,\n  suffices h : ∃ n : ℕ, (n ≠ 0) ∧ u + (↑n)⁻¹ ∈ S, from not_upper_bound_of_exists_nat h,\n  suffices h : ∃ n : ℕ, (n ≠ 0) ∧ ((u + (n : R)⁻¹) * (u + (↑n)⁻¹) < 2),\n  { rcases h with ⟨n, ne0, hn⟩,\n    exact ⟨n, ne0, pos_add_inv_nat_of_pos k₄ ne0, hn⟩, },\n  suffices h : ∃ n : ℕ, n ≠ 0 ∧ (u*u + ((2 : R)*u + 1)*(↑n)⁻¹) < 2,\n  { rcases h with ⟨n, ne0, hn⟩,\n    exact ⟨n, ne0, (lt_of_le_of_lt) (sq_add_inv_ub ne0) hn⟩, },\n  have k₆ : (0 : R) < (2*u + 1)⁻¹ * (2 - u*u) := inequ1 k₄ k₅,\n  rcases (inv_lt_of_pos _ k₆) with ⟨n, ne0, h₂⟩,\n  exact ⟨n, ne0, (inequ2 k₄ h₂)⟩,\nend\n\nend  lemmas_for_ub_contra\n\nsection lemmas_for_lub_contra\n\nlemma sq_sub_inv_ub {u : R} {k : ℕ} (h₁ : 0 < u) (h₂ : k ≠ 0)\n: (u - (↑k)⁻¹) * (u - (↑k)⁻¹) > u*u - 2*u*(↑k)⁻¹ :=\nbegin\n  repeat {rw sub_eq_add_neg},\n  rw [mul_add, add_mul, add_mul, mul_comm (-(↑k)⁻¹) u, add_assoc],\n  apply add_lt_add_of_le_of_lt(le_refl (u* u)),\n  rw [←add_assoc, ←two_mul, neg_mul_eq_mul_neg, mul_assoc, lt_add_iff_pos_right, neg_mul_neg_self],\n  exact mul_pos _ _ (pos_inv_nat_of_non_zero h₂) (pos_inv_nat_of_non_zero h₂),\nend\n\nlemma lub_contra_subproof1 {u : R} (k₄ : (0 : R) < u) (k₅ : 2 < u * u)\n(h : ∃ n : ℕ, (n ≠ 0) ∧ (2 < (u - (n : R)⁻¹) * (u - (↑n)⁻¹))) \n: ∃ (n : ℕ), n ≠ 0 ∧ upper_bound (u - (↑n)⁻¹) S :=\nbegin\n  rcases h with ⟨n, ne0, hn⟩,\n  use n,\n  apply and.intro ne0,\n  intros x hx,\n  cases hx with xpos xsqlt2,\n  have h₃ : x * x < (u - (n : R)⁻¹) * (u - (↑n)⁻¹), from lt_trans xsqlt2 hn,\n  rw le_iff_lt_or_eq,\n  left,\n  exact (square_lt_square_iff_lt_of_pos_of_pos _ _ xpos (pos_sub_inv_nat_of_pos k₄ ne0 k₅)).mp h₃,\nend\n\nlemma inequ3 {u : R} {n : ℕ} (h₁ : 0 < u) (h₂ : (↑n)⁻¹ < (2*u)⁻¹ * (u*u - 2))\n: 2 < u * u - 2 * u * (↑n)⁻¹ :=\nbegin\n  suffices h : 2 * u * (↑n)⁻¹  < u * u - 2, linarith,\n  have h₄ : 0 < (2 * u), linarith,\n  have h₅ : 2 * u ≠ 0, linarith,\n  suffices h : (2 * u) * (↑n)⁻¹ < (2 * u) * ( (2*u)⁻¹ *(u*u -2)),\n  { rwa [←mul_assoc, mul_inv _ h₅, one_mul] at h, },\n  exact mul_lt_mul_left_mpr h₄ h₂,\nend\n\nlemma inequ4 {u : R} (h₁ : 0 < u) (h₂ : 2 < u * u) : 0 < (2*u)⁻¹ * (u * u - 2):=\nbegin\n  have h₃ : 0 < u * u - 2, linarith,\n  have h₄ : 0 < 2 * u, linarith,\n  have h₅ : 2*u  ≠ 0, linarith,\n  have h₆ : 0 < (2*u)⁻¹, from (inv_pos h₅).mpr h₄,\n  exact mul_pos _ _ h₆ h₃,\nend\n\nlemma lub_contra {u : R} (k₃ : ∀ v : R, upper_bound v S → u ≤ v) (k₄ : (0 : R) < u)\n(k₅ : 2 < u * u)\n: u * u = 2 :=\nbegin\n  suffices h : ¬(∀ v : R, upper_bound v S → u ≤ v), from absurd k₃ h,\n  suffices h : ∃ n : ℕ, n ≠ 0 ∧ (upper_bound (u - (↑n)⁻¹) S), from not_lub_of_exists_nat h,\n  suffices h : ∃ n : ℕ, (n ≠ 0) ∧ (2 < (u - (n : R)⁻¹) * (u - (↑n)⁻¹)),\n  from lub_contra_subproof1 k₄ k₅ h,\n  suffices h : ∃ n : ℕ, n ≠ 0 ∧ 2  < u * u - 2 * u * (↑n)⁻¹,\n  { rcases h with ⟨n, ne0, hn⟩,\n    exact ⟨n, ne0, lt_trans hn (sq_sub_inv_ub k₄ ne0)⟩ },\n  suffices h : ∃ n : ℕ, n ≠ 0 ∧ (↑n)⁻¹ < (2*u)⁻¹ * (u*u - 2),\n  { rcases h with ⟨n, ne0, hn⟩,\n    exact ⟨n, ne0, inequ3 k₄ hn⟩, },\n  have k₆ : 0 < (2*u)⁻¹ * (u * u - 2):= inequ4 k₄ k₅,\n  exact inv_lt_of_pos _ k₆,\nend\n\nend lemmas_for_lub_contra\n\nlemma sqrt_two_exists : (sup S)*(sup S) = (2 : R) :=\nbegin\n  have k₂ : ({x : R | (0 < x) ∧ (x*x < 2)} : set R) ≠ ∅, from non_empty_S,\n  have k₃ : is_sup (sup S) S, from  sup_is_sup has_upper_bound_S k₂,\n  have k₄ : ↑0 < sup S,\n  { suffices h : (1 : R) ≤ sup S,\n    { change (0 : R) < sup S,\n      exact lt_of_lt_of_le zero_lt_one h, },\n    exact k₃.left (1 : R) one_in_S, },\n  rcases trichotomy' ((sup S)*(sup S)) (2 : R) with ub | sq_eq | lub,\n  { exact ub_contra k₃.left k₄ ub.left, },\n  { exact sq_eq.right.left, },\n  { exact lub_contra k₃.right k₄ lub.right.right, },\nend\n\nend sqrt_two\n\nend myreal\n\nend mth1001\n", "meta": {"author": "gihanmarasingha", "repo": "mth1001_tutorial", "sha": "bb277eebd5013766e1418365b91416b406275130", "save_path": "github-repos/lean/gihanmarasingha-mth1001_tutorial", "path": "github-repos/lean/gihanmarasingha-mth1001_tutorial/mth1001_tutorial-bb277eebd5013766e1418365b91416b406275130/src/exercises/src_39_square_root_of_two.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4797949767924757}}
{"text": "/-\nCopyright (c) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\n-- NOTE: This file contains examples for, and therefore should be kept in sync\n-- with, the README.\n\nimport Aesop\n\nset_option aesop.check.all true\n\ninductive MyList (α : Type _)\n  | nil\n  | cons (hd : α) (tl : MyList α)\n\nnamespace MyList\n\nprotected def append : (_ _ : MyList α) → MyList α\n  | nil, ys => ys\n  | cons x xs, ys => cons x (MyList.append xs ys)\n\ninstance : Append (MyList α) :=\n  ⟨MyList.append⟩\n\n@[simp]\ntheorem nil_append : nil ++ xs = xs := rfl\n\n@[simp]\ntheorem cons_append : cons x xs ++ ys = cons x (xs ++ ys) := rfl\n\n@[aesop safe [constructors, cases]]\ninductive NonEmpty : MyList α → Prop\n  | cons : NonEmpty (cons x xs)\n\n@[aesop 50%]\ntheorem nonEmpty_append₁ {xs : MyList α} ys :\n    NonEmpty xs → NonEmpty (xs ++ ys) := by\n  aesop\n\ntheorem nonEmpty_append₁' {xs : MyList α} ys :\n    NonEmpty xs → NonEmpty (xs ++ ys) := by\n  -- This is the script generated by aesop?.\n  intro a\n  unhygienic aesop_cases a\n  simp_all only [cons_append]\n  apply MyList.NonEmpty.cons\n\nexample {α : Type _} {xs : MyList α} ys zs :\n    NonEmpty xs → NonEmpty (xs ++ ys ++ zs) := by\n  aesop\n\ntheorem nil_not_nonEmpty (xs : MyList α) : xs = nil → ¬ NonEmpty xs := by\n  aesop (add unsafe 10% cases MyList, norm simp Not)\n\n@[simp]\ntheorem append_nil {xs : MyList α} :\n    xs ++ nil = xs := by\n  induction xs <;> aesop\n\ntheorem append_assoc {xs ys zs : MyList α} :\n    (xs ++ ys) ++ zs = xs ++ (ys ++ zs) := by\n  induction xs <;> aesop\n\nend MyList\n", "meta": {"author": "JLimperg", "repo": "aesop", "sha": "c68fb1d5a9172498230d81d95c61f6461bea6722", "save_path": "github-repos/lean/JLimperg-aesop", "path": "github-repos/lean/JLimperg-aesop/aesop-c68fb1d5a9172498230d81d95c61f6461bea6722/tests/run/DocLists.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.4797529211953485}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport data.finset.locally_finite\nimport data.dfinsupp.order\n\n/-!\n# Finite intervals of finitely supported functions\n\nThis file provides the `locally_finite_order` instance for `Π₀ i, α i` when `α` itself is locally\nfinite and calculates the cardinality of its finite intervals.\n-/\n\nopen dfinsupp finset\nopen_locale big_operators pointwise\n\nvariables {ι : Type*} {α : ι → Type*}\n\nnamespace finset\nvariables [decidable_eq ι] [Π i, has_zero (α i)] {s : finset ι} {f : Π₀ i, α i}\n  {t : Π i, finset (α i)}\n\n/-- Finitely supported product of finsets. -/\ndef dfinsupp (s : finset ι) (t : Π i, finset (α i)) : finset (Π₀ i, α i) :=\n(s.pi t).map ⟨λ f, dfinsupp.mk s $ λ i, f i i.2, begin\n  refine (mk_injective _).comp (λ f g h, _),\n  ext i hi,\n  convert congr_fun h ⟨i, hi⟩,\n  end⟩\n\n@[simp] lemma card_dfinsupp (s : finset ι) (t : Π i, finset (α i)) :\n  (s.dfinsupp t).card = ∏ i in s, (t i).card :=\n(card_map _).trans $ card_pi _ _\n\nvariables [Π i, decidable_eq (α i)]\n\nlemma mem_dfinsupp_iff : f ∈ s.dfinsupp t ↔ f.support ⊆ s ∧ ∀ i ∈ s, f i ∈ t i :=\nbegin\n  refine mem_map.trans ⟨_, _⟩,\n  { rintro ⟨f, hf, rfl⟩,\n    refine ⟨support_mk_subset, λ i hi, _⟩,\n    convert mem_pi.1 hf i hi,\n    exact mk_of_mem hi },\n  { refine λ h, ⟨λ i _, f i, mem_pi.2 h.2, _⟩,\n    ext i,\n    dsimp,\n    exact ite_eq_left_iff.2 (λ hi, (not_mem_support_iff.1 $ λ H, hi $ h.1 H).symm) }\nend\n\n/-- When `t` is supported on `s`, `f ∈ s.dfinsupp t` precisely means that `f` is pointwise in `t`.\n-/\n@[simp] lemma mem_dfinsupp_iff_of_support_subset {t : Π₀ i, finset (α i)} (ht : t.support ⊆ s) :\n  f ∈ s.dfinsupp t ↔ ∀ i, f i ∈ t i :=\nbegin\n  refine mem_dfinsupp_iff.trans (forall_and_distrib.symm.trans $ forall_congr $ λ i, ⟨λ h, _,\n    λ h, ⟨λ hi, ht $ mem_support_iff.2 $ λ H, mem_support_iff.1 hi _, λ _, h⟩⟩),\n  { by_cases hi : i ∈ s,\n    { exact h.2 hi },\n    { rw [not_mem_support_iff.1 (mt h.1 hi), not_mem_support_iff.1 (not_mem_mono ht hi)],\n      exact zero_mem_zero } },\n  { rwa [H, mem_zero] at h }\nend\n\nend finset\n\nopen finset\n\nnamespace dfinsupp\nvariables [decidable_eq ι] [Π i, decidable_eq (α i)]\n\nsection bundled_singleton\nvariables [Π i, has_zero (α i)] {f : Π₀ i, α i} {i : ι} {a : α i}\n\n/-- Pointwise `finset.singleton` bundled as a `dfinsupp`. -/\ndef singleton (f : Π₀ i, α i) : Π₀ i, finset (α i) :=\n⟦{ to_fun := λ i, {f i},\n  pre_support := f.support.1,\n  zero := λ i, (ne_or_eq (f i) 0).imp mem_support_iff.2 (congr_arg _) }⟧\n\nlemma mem_singleton_apply_iff : a ∈ f.singleton i ↔ a = f i := mem_singleton\n\nend bundled_singleton\n\nsection bundled_Icc\nvariables [Π i, has_zero (α i)] [Π i, partial_order (α i)] [Π i, locally_finite_order (α i)]\n  {f g : Π₀ i, α i} {i : ι} {a : α i}\n\n/-- Pointwise `finset.Icc` bundled as a `dfinsupp`. -/\ndef range_Icc (f g : Π₀ i, α i) : Π₀ i, finset (α i) :=\n⟦{ to_fun := λ i, Icc (f i) (g i),\n  pre_support := f.support.1 + g.support.1,\n  zero := λ i, begin\n    refine or_iff_not_imp_left.2 (λ h, _),\n    rw [not_mem_support_iff.1 (multiset.not_mem_mono (multiset.le_add_right _ _).subset h),\n      not_mem_support_iff.1 (multiset.not_mem_mono (multiset.le_add_left _ _).subset h)],\n    exact Icc_self _,\n  end }⟧\n\n@[simp] lemma range_Icc_apply (f g : Π₀ i, α i) (i : ι) : f.range_Icc g i = Icc (f i) (g i) := rfl\n\nlemma mem_range_Icc_apply_iff : a ∈ f.range_Icc g i ↔ f i ≤ a ∧ a ≤ g i := mem_Icc\n\nlemma support_range_Icc_subset : (f.range_Icc g).support ⊆ f.support ∪ g.support :=\nbegin\n  refine λ x hx, _,\n  by_contra,\n  refine not_mem_support_iff.2 _ hx,\n  rw [range_Icc_apply,\n    not_mem_support_iff.1 (not_mem_mono (subset_union_left _ _) h),\n      not_mem_support_iff.1 (not_mem_mono (subset_union_right _ _) h)],\n  exact Icc_self _,\nend\n\n\nend bundled_Icc\n\nsection pi\nvariables [Π i, has_zero (α i)]\n\n/-- Given a finitely supported function `f : Π₀ i, finset (α i)`, one can define the finset\n`f.pi` of all finitely supported functions whose value at `i` is in `f i` for all `i`. -/\ndef pi (f : Π₀ i, finset (α i)) : finset (Π₀ i, α i) := f.support.dfinsupp f\n\n@[simp] lemma mem_pi {f : Π₀ i, finset (α i)} {g : Π₀ i, α i} : g ∈ f.pi ↔ ∀ i, g i ∈ f i :=\nmem_dfinsupp_iff_of_support_subset $ subset.refl _\n\n@[simp] lemma card_pi (f : Π₀ i, finset (α i)) : f.pi.card = f.prod (λ i, (f i).card) :=\nbegin\n  rw [pi, card_dfinsupp],\n  exact finset.prod_congr rfl (λ i _, by simp only [pi.nat_apply, nat.cast_id]),\nend\n\nend pi\n\nsection locally_finite\nvariables [Π i, partial_order (α i)] [Π i, has_zero (α i)] [Π i, locally_finite_order (α i)]\n\ninstance : locally_finite_order (Π₀ i, α i) :=\nlocally_finite_order.of_Icc (Π₀ i, α i)\n  (λ f g, (f.support ∪ g.support).dfinsupp $ f.range_Icc g)\n  (λ f g x, begin\n    refine (mem_dfinsupp_iff_of_support_subset $ support_range_Icc_subset).trans _,\n    simp_rw [mem_range_Icc_apply_iff, forall_and_distrib],\n    refl,\n  end)\n\nvariables (f g : Π₀ i, α i)\n\nlemma card_Icc : (Icc f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card :=\ncard_dfinsupp _ _\n\nlemma card_Ico : (Ico f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card - 1 :=\nby rw [card_Ico_eq_card_Icc_sub_one, card_Icc]\n\nlemma card_Ioc : (Ioc f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card - 1 :=\nby rw [card_Ioc_eq_card_Icc_sub_one, card_Icc]\n\n\n\nend locally_finite\nend dfinsupp\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/data/dfinsupp/interval.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.47975291240629153}}
{"text": "/-  An alternative take on the definition of a minor, where we take a quotient. Very much WIP. -/\n\nimport ftype.basic set_tactic.solver\nimport .rankfun .dual \n\n--noncomputable theory\nopen_locale classical\nnoncomputable theory \n\nopen ftype \n\nvariables {U₀ U V W: ftype}--[nonempty U₀]\n\n--def img (emb : U₀ ↪ U) :=\n--  λ (X : set U₀), emb.to_fun '' X \n\n/- given an injection emb, and a set equal to the range of emb, outputs an equivalence between the \ndomain and the subtype corresponding to the range. \ndef subtype_inv_inj (emb : U₀ ↪ U){E : set U} (hE : E = set.range emb) : E ≃ U₀ :=   \nlet h : Π (y : E), (∃ x : U₀, emb x = y) := \n  by {rintros ⟨y,hy⟩, rw [hE, set.mem_range] at hy, cases hy with x hx, from ⟨x, by simp [hx]⟩},\n desc : Π (y : E), {x : U₀ // emb x = y} :=   \n  λ y, classical.indefinite_description _ (h y) in \n{ \n  to_fun := λ y, (desc y).val, \n  inv_fun := λ x, ⟨emb x, by {rw [hE, set.mem_range], from ⟨x, rfl⟩} ⟩, \n  left_inv := by {intros y, simp_rw (desc y).property, simp}, \n  right_inv := λ x, by {cases emb with f h_inj, from h_inj (desc ⟨f x,_⟩).property},\n}\n-/\n\ndef subset_embed (X : set U) : X ↪ U := \n{ to_fun := λ x, x.val, \n  inj' := λ x y hxy, subtype.ext hxy}\n\ndef subset_to_subtype {X Y : set U} (hXY : X ⊆ Y) : set Y := \n  λ y, y.val ∈ X \n\n/-- (invisible) equivalence between the class of subsets of R and the class of \n sets in the ftype corresponding to R -/\ndef subset_equiv {R : set U} : {X : set U // X ⊆ R} ≃ set (⟨R⟩ : ftype) :=\n{ to_fun := λ X, {y | y.val ∈ X.val},\n  inv_fun := λ Y, ⟨coe '' Y,by {intros y hy, cases hy with x hx, rw ←hx.2, exact x.2,} ⟩,\n  left_inv := begin\n    intro X, ext x, simp only [set.mem_image, subtype.coe_mk],\n    refine ⟨λ h, _, λ h, ⟨⟨x,_⟩,⟨_,_⟩⟩⟩, \n    { rcases h with ⟨x',h₁,h₂⟩, rw ←h₂, convert h₁,}, \n    { cases X, tauto, }, \n    { tauto, }, \n    simp, \n  end,\n  right_inv := begin\n    intro X, ext x, cases x with x xp,  simp only [set.mem_set_of_eq], \n    refine ⟨λ h, _, λ h, _⟩, \n    {unfold_projs at h, rcases h with ⟨a,h1,h2⟩, simp_rw ←h2, convert h1, simp},\n    exact ⟨⟨x,xp⟩, ⟨h,by simp⟩⟩,   \n  end, }\n\n\n\n\n/-- bundled isomorphism between two matroids -/\nstructure isom (M : matroid U) (N : matroid V) := \n  (bij: U ≃ V)\n  (rank_preserving : M.r =  N.r ∘ (set.image bij))\n\ninstance coe_iso_to_fun {M : matroid U} {N : matroid V} : has_coe_to_fun (isom M N) := \n{F := λ (i : isom M N), (U → V), coe := λ i, i.bij}\n\n/-- inverse of a matroid isomorphism -/\ndef inv{M: matroid U} {N: matroid V} (iso : isom M N) : isom N M := \n{\n  bij := iso.bij.symm,\n  rank_preserving := \n  by {rw iso.rank_preserving, ext X, convert rfl, convert rfl, ext x, simp}, \n}\n\ndef compose {M : matroid U} {N : matroid V} {O : matroid W} (i₁ : isom M N) (i₂ : isom N O) : isom M O := \n{\n  bij := equiv.trans i₁.bij i₂.bij, \n  rank_preserving := \n  begin\n    ext X, rw [i₁.rank_preserving, i₂.rank_preserving],  \n    simp only [equiv.to_fun_as_coe, ftype.ftype_coe, function.comp_app, equiv.coe_trans], \n    apply congr_arg, ext x,  simp, \n  end\n}\n\n-- making a hash of this one! \n@[simp] lemma compose_inv_on_set {M: matroid U} {N: matroid V} (iso : isom M N) (X : set U) :\n  ((inv iso).bij '' (iso.bij '' X)) = X :=\nbegin\n  --unfold equiv.img, \n  convert rfl, ext, \n  rw set.mem_image, \n  refine ⟨λ h, ⟨iso.bij x,⟨_,_⟩⟩,λ h, _⟩, \n    {simp only [equiv.to_fun_as_coe, equiv.apply_eq_iff_eq, set.mem_image, exists_eq_right], from h },\n    {simp[inv]},\n    {rcases h with ⟨y,h1,h2⟩, rw set.mem_image at h1, rcases h1 with ⟨x', ⟨hx'1, hx'2⟩⟩, rw [←h2,←hx'2] , convert hx'1, rw inv, simp,}\nend\n\n\n\nvariable {M : matroid U}\n\n\n\n/-- structure describing a matroid and an embedding of its elements into U -/\n@[ext] structure emb_mat (U : ftype) := \n  {U₀ : ftype}\n  (mat : matroid U₀)\n  (emb : U₀ ↪ U)\n\nnamespace emb_mat \n\ndef groundset (N : emb_mat U) : set U := \n  set.range N.emb \n\ndef strongly_iso (N₁ N₂ : emb_mat U) : Prop := \n  (∃ (φ : isom (N₁.mat) (N₂.mat)), ∀ x, N₁.emb x = N₂.emb (φ x)) \n\nlemma strong_iso_equiv : \n  equivalence (λ (N₁ N₂ : emb_mat U), strongly_iso N₁ N₂) := \nbegin\n  refine ⟨λ N, _, λ N₁ N₂ hab, _, λ N₁ N₂ N₃ hab hbc, _⟩, \n    {refine ⟨⟨equiv.refl _,_⟩,λ X, _⟩, \n      {ext X, simp,},\n      {apply congr_arg, unfold_coes, simp} },\n    {cases hab with φ, refine ⟨inv φ, λ X, _⟩, rw [hab_h ((inv φ) X), inv], unfold_coes, simp},\n  cases hab with i₁ h₁, cases hbc with i₂ h₂, \n  from ⟨compose i₁ i₂, λ X, by {unfold_coes at *, simp [h₁,h₂,congr_arg, compose]}⟩,  \nend\n\nlemma strong_iso_same_groundset (N N' : emb_mat U) :\n  strongly_iso N N' → N.groundset = N'.groundset  := \nbegin\n  rintros ⟨h₁,h₂⟩, ext, \n  simp only [groundset, set.mem_range],\n  simp_rw h₂, \n  refine ⟨λ h, _, λ h, _⟩, \n    {cases h with y hy, from ⟨_, hy⟩},\n  cases h with y hy, use h₁.bij.inv_fun y, unfold_coes, simp [hy],\nend \n\n--def pullback_r (N : emb_mat U) : set (N.ground) → ℤ := \n--  λ X, N.mat.r ((N.emb.subtype_inv_inj (rfl : N.ground = set.range N.emb))'' X)\n\n/-- mapped rank function of N, but defined on all subsets of U (elements not in image are ignored)-/\ndef pullback_r (N : emb_mat U) : set U → ℤ := \n  λ X, N.mat.r ({x : N.U₀ | N.emb x ∈ X })\n\nlemma pullback_r_eq (N : emb_mat U) (X : set N.U₀) : \n  N.mat.r X = N.pullback_r (N.emb.to_fun '' X) :=\nbegin\n  unfold pullback_r, congr', ext x, \n  simp only [set.mem_image, function.embedding.to_fun_eq_coe, set.mem_set_of_eq],\n  refine ⟨λ h, _, λ h, _⟩, \n    {use x, simp, from h},\n  cases h with x' hx', \n  convert hx'.1,\n  from (N.emb.inj' hx'.2).symm,\nend\n  --ite (X ⊆ N.ground) (some 0 : option ℤ) (none : option ℤ) \n  \n  --N.mat.r ((N.emb.subtype_inv_inj (rfl : N.ground = set.range N.emb))'' X)\n\nlemma strong_iso_same_pullback_r (N N' : emb_mat U) :\n  strongly_iso N N' → N.pullback_r = N'.pullback_r :=\nbegin\n  rintros ⟨⟨φ,hφ₁⟩, hφ₂⟩, ext X, \n  unfold pullback_r, rw hφ₁, \n  dsimp, congr', ext x', \n  simp only [set.mem_image, set.mem_set_of_eq], \n  simp_rw hφ₂, \n  refine ⟨λ h, _, λ h, ⟨φ.inv_fun x',⟨_,by simp⟩⟩⟩, \n    {rcases h with ⟨x, ⟨hx₁,hx₂⟩⟩, rw ←hx₂, from hx₁,},\n  rw ←hφ₂, \n  convert h,  \n  rw hφ₂, \n  congr', unfold_coes, simp, \nend\n\n/-- if E is equal to the groundset of N, then there is a natural equivalence between E and U₀ -/\ndef groundset_equiv (N : emb_mat U){E : set U} (hE : N.groundset = E) : \n  N.U₀ ≃ (⟨E⟩ : ftype) := \n  ((equiv.set.range N.emb N.emb.inj').trans (equiv.set.of_eq hE))\n\n--def pullback_r' (N : emb_mat U){E : set U} (hE : N.ground = E) : set E → ℤ := \n\n\n\ninstance strong_iso_setoid (U : ftype) : setoid (emb_mat U) := ⟨strongly_iso, strong_iso_equiv⟩ \n\nend emb_mat \n\n/-- a matroid_in U is a matroid embedded into some set of ements of U, modulo the range of the embedding-/\ndef matroid_in (U : ftype) := quot (λ (N N' : emb_mat U), N.strongly_iso N')\n\nnamespace matroid_in \n\n/-- the groundset of N, viewed as a (set U)-/\ndef groundset : matroid_in U → set U := quotient.lift  \n  (λ (N : emb_mat U), N.groundset) emb_mat.strong_iso_same_groundset\n\n/-- the groundset of N, viewed as an ftype -/\ndef ground (N : matroid_in U) : ftype := ⟨N.groundset⟩\n\n/-- the rank function of N as a function on set U (elements outside the groundset of N \nare ignored)-/\ndef r : matroid_in U → (set U → ℤ) := quotient.lift \n  (λ (N : emb_mat U), N.pullback_r) emb_mat.strong_iso_same_pullback_r\n\n/-- the rank function of N as a function on sets of the ground ftype of N-/\ndef r_ftype (N : matroid_in U) : (set N.ground → ℤ) := \n  λ X, N.r ((λ x : N.ground, x.val)'' X )\n\n/-- an equivalence class representative for N -/\ndef rep_spec (N : matroid_in U) : {N₀ : emb_mat U // ⟦N₀⟧ = N} := \n  classical.indefinite_description _ (quot.exists_rep N)\n\n/-- the ground set of a representative is the ground set of a matroid_in -/\nlemma ground_rep {N : matroid_in U} {N₀ : emb_mat U} (h : ⟦N₀⟧ = N) : \n   N₀.groundset = N.groundset  := \nby {dsimp only [quotient.mk] at h, rw ←h, refl}\n\n\nlemma r_eq_r_inter_groundset (N : matroid_in U) (X : set U) : \n  N.r X = N.r (X ∩ N.groundset) := \nbegin\n  unfold matroid_in.groundset r emb_mat.pullback_r emb_mat.groundset, \n  rcases rep_spec N with ⟨N₀,h⟩,\n  simp [←h],\nend\n\nsection preimages \n\nvariables {N : matroid_in U} {N₀ : emb_mat U}\n\n/-- given an equivalence class representative N₀, pulls a set X back to the \nftype on which N₀ is defined -/\ndef rep_preimage (hN : ⟦N₀⟧ = N) (X : set N.ground) :=\n  N₀.groundset_equiv (ground_rep hN) ⁻¹' X\n\nlemma rep_preimage_on_size (hN : ⟦N₀⟧ = N) (X : set N.ground) : \n  size (rep_preimage hN X) = size X := \nby {apply size_preimage_equiv} \n\nlemma rep_preimage_on_subset (hN : ⟦N₀⟧ = N){X Y : set N.ground} :\n  X ⊆ Y → rep_preimage hN X ⊆ rep_preimage hN Y := \nλ h, set.preimage_mono h\n\n\nlemma r_rep (hN : ⟦N₀⟧ = N) (X : set N.ground) :\n  r_ftype N X = N₀.mat.r (rep_preimage hN X) :=\nbegin\n  unfold r_ftype r, \n  simp_rw ←hN, \n  simp only [quotient.lift_mk], \n  unfold emb_mat.pullback_r, apply congr_arg, ext x, \n  rw [rep_preimage], \n  simp only [set.mem_set_of_eq, emb_mat.groundset_equiv ], simp, \n  refine ⟨λ h, _, λ h, _⟩, \n  { rcases h with ⟨y,h,h'⟩, simp_rw ←h', convert h, simp,},\n  use N₀.emb x,\n  { unfold matroid_in.groundset, rw ←hN, simp only [quotient.lift_mk], unfold emb_mat.groundset, simp,},\n  exact ⟨h, by simp⟩, \nend \n\nend preimages \n\ndef as_matroid (N : matroid_in U) : matroid N.ground := \n{ \n  r := N.r_ftype,\n  R0 := λ X, let ⟨N₀,h⟩ := rep_spec N in by \n  {rw r_rep h X, apply N₀.mat.R0, },\n  R1 := λ X, let ⟨N₀,h⟩ := rep_spec N in by \n  {rw [r_rep h X, ←rep_preimage_on_size h], apply N₀.mat.R1,},\n  R2 := λ X Y hXY, let ⟨N₀,h⟩ := rep_spec N in by \n  {repeat {rw r_rep h}, apply N₀.mat.R2, exact (rep_preimage_on_subset _ hXY),} ,\n  R3 := λ X Y, let ⟨N₀,h⟩ := rep_spec N in by \n  {repeat {rw r_rep h}, apply N₀.mat.R3,  } \n}\n\nlemma as_matroid_r_eq (N : matroid_in U) : \n  ∀ X, N.r X = N.as_matroid.r (subset_equiv ⟨X ∩ N.groundset, by tidy⟩) :=\nbegin\n  intro X, \n  unfold matroid_in.as_matroid matroid_in.r_ftype subset_equiv, \n  simp only [equiv.coe_fn_mk, subtype.coe_mk], \n  rw r_eq_r_inter_groundset, congr', \n  ext x, simp only [set.mem_image, set.mem_inter_eq,set.mem_set_of_eq,subtype.coe_mk],\n  refine ⟨λ h, ⟨⟨x,h.2⟩,⟨⟨h.1,h.2⟩,by simp⟩⟩, λ h, _⟩,\n  rcases h with ⟨x',⟨h,rfl⟩⟩, \n  exact h,\nend\n\n/-- as_matroid is the canonical representative for a matroid_in -/\nlemma as_matroid_is_rep (M : matroid_in U) : \n  M = ⟦{mat := M.as_matroid, emb := function.embedding.subtype _ }⟧ := \nbegin\n  rcases M.rep_spec with ⟨M₀,h⟩, rw ←h, apply quotient.sound, \n  \n  simp only [has_equiv.equiv, setoid.r, emb_mat.strongly_iso, as_matroid, r_ftype], \n  dsimp only [ftype.ftype_coe],\n  refine ⟨⟨_,_⟩,λ x, _⟩, \n  { refine emb_mat.groundset_equiv _ _, refl, },\n  begin\n    ext X, simp only [function.comp_app, r, emb_mat.pullback_r], unfold emb_mat.groundset_equiv, congr', ext x,\n    simp only [set.mem_set_of_eq, set.image_congr, set.mem_image, exists_exists_and_eq_and, subtype.val_eq_coe],\n    refine ⟨λ h, ⟨x,h, by simp⟩, λ h, _⟩, \n    rcases h with ⟨a,ha,h⟩, simp at h, \n    rw ←M₀.emb.inj' h, exact ha, \n  end,\n  refl, \nend\n\n/- lemma as_matroid_r_eq_subset (N : matroid_in U) :\n  ∀ X : {X : set U // X ⊆ N.groundset}, N.r X.val = N.as_matroid.r (subset_equiv X) :=\nbegin\n  intro X, \n  convert as_matroid_r_eq N X.val, \n  \nend -/\n\n--lemma iso_to (M₀ : emb_mat U) : \n\ndef as_matroid_in (M : matroid U) : matroid_in U := \n  ⟦{U₀ := U, emb := function.embedding.refl U, mat := M}⟧\n\n\n\n\ninstance coe_to_matroid_in : has_coe (matroid U) (matroid_in U) := ⟨λ M, as_matroid_in M⟩\n\ndef embed (M : matroid_in U) : M.ground ↪ U := subset_embed M.groundset \n\ndef subset_embed {M : matroid_in U} {R : set U} (hR : R ⊆ M.groundset) : R ↪ M.ground :=\n{to_fun  := λ x, ⟨x.val, by {cases x, tauto}⟩,\n inj'    := λ x y hxy, by {simp only [subtype.mk_eq_mk] at hxy, exact subtype.eq hxy, } }\n\ndef nested_embed (M' M : matroid_in U) (hMM' : M'.groundset ⊆ M.groundset) : M'.ground ↪ M'.ground :=\n{to_fun  := λ x, ⟨x.val, by simp⟩,\n inj'    := λ x y hxy, by {convert hxy; simp,} }\n\n--set_option pp.proofs true\n\ndef matroid_in_ext (M M' : matroid_in U) :\n  M.groundset = M'.groundset → M.r = M'.r → M = M' :=\nbegin\n  intros h h', \n  rw [as_matroid_is_rep M, as_matroid_is_rep M', quotient.sound],  \n  refine ⟨⟨_,_⟩,λ x, _⟩, \n  {exact {to_fun := λ x, ⟨x.val, by {rw ←h, exact x.property,}⟩ , \n          inv_fun := λ x, ⟨x.val, by {rw h, exact x.property,}⟩, \n          left_inv := λ x, by {dsimp only, simp,}, \n          right_inv := λ x, by {dsimp only, simp,}}, },\n  begin\n    simp_rw h', \n    simp only [as_matroid, r_ftype], --simp_rw h', \n    ext X, simp only [set.image_congr, function.comp_app, subtype.val_eq_coe], rw h', \n    apply congr_arg, ext x, dsimp only [ftype.ftype_coe], \n    simp only [set.image_congr, set.mem_image, exists_exists_and_eq_and, subtype.val_eq_coe], \n    refine ⟨λ hx,_, λ hx, _⟩, \n    { rcases hx with ⟨y,h₁,rfl⟩, exact ⟨y,h₁, by simp⟩,  },\n    rcases hx with ⟨⟨y, hy⟩, hy', rfl⟩, refine ⟨⟨y,hy⟩,⟨hy',_⟩⟩, simp, \n  end,\n  refl, \nend\n\n\n\ndef from_matroid_on_subtype {E : set U} (M : matroid ⟨E⟩) :  matroid_in U := \n⟦{mat := M, emb := function.embedding.subtype _}⟧\n\nlemma groundset_correct {E : set U} (M : matroid ⟨E⟩) : \n  (from_matroid_on_subtype M).groundset = E :=\nby {unfold from_matroid_on_subtype groundset emb_mat.groundset, simp}\n\nlemma rank_correct {E : set U} (M : matroid ⟨E⟩) (X : set U) : \n  (from_matroid_on_subtype M).r X = M.r ((λ x, x.val) '' X) ∩ {e}   :=\nby {unfold from_matroid_on_subtype groundset emb_mat.groundset, simp}\n\n\n\nend matroid_in \n\nsection minor \n\n/-- minor relation between two matroid_in U-/\ndef is_minor (N M : matroid_in U) : Prop := \n  (N.groundset ⊆ M.groundset) ∧ \n  ∃ C ⊆ M.groundset \\ N.groundset, (∀ X ⊆ N.groundset, N.r X = M.r (X ∪ C) - M.r C)  \n\n/-- minor relation between a matroid_in U and a matroid U -/\ndef is_minor_of (N : matroid_in U) (M : matroid U) := \n  is_minor N M \n\n/-- N is isomorphic to a minor of M -/\ndef is_emb_minor (N : matroid U₀) (M : matroid U) := \n  ∃ emb : U₀ ↪ U, is_minor_of ⟦(⟨N,emb⟩:emb_mat U)⟧ M  \n\nlemma minor_trans: transitive (λ (M₁ M₂ : matroid_in U), is_minor M₁ M₂) :=\nbegin\n  rintros M₁ M₂ M₃ ⟨h1,⟨C₁,hC₁,h1'⟩⟩ ⟨h2,⟨C₂,hC₂,h2'⟩⟩, \n  refine ⟨subset.trans h1 h2,⟨C₁ ∪ C₂,⟨_,λ X hX, _⟩⟩⟩, \n  ----\n  { convert set.union_subset_union hC₁ hC₂, ext, \n    simp only [ftype.diff_eq, set.mem_inter_eq, set.mem_union_eq, set.mem_compl_eq], \n    tauto, },\n  -- set_solver should work for the goal above, but it is glacial\n  have hC₁M₂: C₁ ⊆ M₂.groundset := by \n  { intros x hx, simp only [ftype.diff_eq, set.subset_inter_iff] at hC₁, tauto,},\n  rw [h1' X hX, h2' (X ∪ C₁) _, h2' C₁ hC₁M₂, ←union_assoc],  ring,\n  exact union_of_subsets (subset.trans hX h1) hC₁M₂, \nend\n\n def contract_to_matroid (M : matroid_in U) (C : set U) : matroid ⟨(M.groundset \\ C : set U)⟩ :=\nlet mtype : ftype := ⟨(M.groundset \\ C : set U)⟩, \nφ : mtype → U := λ x, x.val  in  \n{ r := λ X, M.r (φ '' X ∪ C) - M.r C,\n  R0 := \n  begin\n    intro X, dsimp only, \n    repeat {rw matroid_in.as_matroid_r_eq}, \n    simp only [sub_nonneg], \n    apply M.as_matroid.R2, \n    unfold subset_equiv,\n    simp, tauto, \n  end,\n  R1 := \n  begin\n    sorry, \n  end,\n  R2 := sorry,\n  R3 := sorry } \n\ndef contract_to_matroid_in (M : matroid_in U) (C : set U) : matroid_in U := \n  matroid_in_from_matroid_on_subtype (contract_to_matroid M C)\n\ndef delete_to_matroid (M: matroid_in U) (D : set U) : matroid ⟨(M.groundset \\ D : set U)⟩  := \nlet mtype : ftype := ⟨(M.groundset \\ D : set U)⟩, \nφ : mtype → U := λ x, x.val  in  \n{ r := λ X, M.r (φ '' X),\n  R0 := sorry,\n  R1 := \n  begin\n    sorry, \n  end,\n  R2 := sorry,\n  R3 := sorry }\n\ndef delete_to_matroid_in (M : matroid_in U) (D : set U) : matroid_in U := \n  matroid_in_from_matroid_on_subtype (delete_to_matroid M D)\n\nlemma foo (M : matroid_in U){C D : set U} (hi : C ∩ D = ∅) (hu : C ∪ D ⊆ M.groundset) : \n  delete_to_matroid_in (contract_to_matroid_in M C) D =  contract_to_matroid_in (delete_to_matroid_in M D) C :=\nbegin\n  apply matroid_in.matroid_in_ext, \n  unfold delete_to_matroid_in contract_to_matroid_in, repeat {rw groundset_correct}, set_solver,  \n  --simp, sorry, \nend\n\n\n\n\n/-- returns the contraction of C in M as a minor on a subtype-/\ndef contract_to_emb (M : matroid_in U) (C : set M.ground) : emb_mat U := \n{ \n  U₀ := ⟨(Cᶜ : set M.ground)⟩,\n  mat := sorry,\n  emb := (function.embedding.subtype (λ x, x ∈ Cᶜ)).trans M.embed,  \n}\n\nend minor \n \n/- the rank function given by N when applied to a subset of the embedded ground set of N.  -/\n\n\n--def is_minor (N : emb_mat U) (M : matroid U) := \n  --∃ C, C ∩ N.ground = ∅ ∧ ∀ X : set U₀, N.mat.r \n\n\n--def is_minor {U : ftype} (N : emb_mat U) (M : matroid U) := \n--  ∃ C : set U, C ∩ N.ground = ∅ ∧ ∀ \n\n/-structure emb_minor' (M : matroid U) :=\n  {U₀ : ftype}\n  (mat : matroid U₀)\n  (emb : U₀ ↪ U)\n  (C : set U)\n  (C_disj : C ∩ set.range emb = ∅)\n  (minor_rank : mat.r = λ X, M.r (emb '' X ∪ C) - M.r C)-/\n\n\n/-\n\n/- the ground set of an emb_minor, expressed as a set of elements of M -/\ndef ground (N : emb_minor M) : set U := set.range N.emb\n\n--def C (N : emb_minor M) : set U := classical.some N.minor_rank\n\ndef D (N : emb_minor M) : set U := (N.ground ∪ N.C)ᶜ\n\nlemma def_ground (N : emb_minor M) : N.ground = set.range N.emb  := rfl \n\nlemma C_ground_inter_empty (N : emb_minor M) : \n  N.C ∩ N.ground = ∅ := \nby {rw ground, from N.C_disj,}\n\nlemma D_ground_inter_empty (N : emb_minor M) : \n  N.D ∩ N.ground = ∅ := \nby {rw [D], have := C_ground_inter_empty N, set_solver,}\n\nlemma C_D_inter_empty (N : emb_minor M) : \n  N.C ∩ N.D = ∅ := \nby {rw D, have := C_ground_inter_empty N, set_solver,} \n\nlemma C_union_D_eq_ground_compl (N : emb_minor M) : \n  (N.C ∪ N.D) = N.groundᶜ := \nby {rw [D], have := N.C_ground_inter_empty, set_solver,}\n\nlemma emb_minor_r (N : emb_minor M) (X : set N.U₀) : \n  N.mat.r X = M.r (N.emb '' X ∪ N.C) - M.r N.C := \nby rw N.minor_rank\n\n/- the rank function given by N when applied to a subset of the embedded ground set of N.  -/\ndef pullback_r (N : emb_minor M) : set (N.ground) → ℤ := \n  λ X, N.mat.r ((N.emb.subtype_inv_inj (rfl : N.ground = set.range N.emb))'' X)\n\n/- two embedded minors of M are strongly isomorphic if the associated matroids are related \nby an isomorphism that commutes with the respective embeddings into M. -/\ndef strongly_iso (N₁ N₂ : emb_minor M) : Prop := \n  (∃ (φ : isom (N₁.mat) (N₂.mat)), ∀ x, N₁.emb x = N₂.emb (φ x)) \n\n/- existence of a strong isomorphism is an equivalence relation on embedded minors of M.\n    Equivalence classes of this relation correspond to actual 'labelled' minors of M    -/\nlemma strong_iso_equiv : \n  equivalence (λ (N₁ N₂ : emb_minor M), strongly_iso N₁ N₂) := \nbegin\n  refine ⟨λ N, _, λ N₁ N₂ hab, _, λ N₁ N₂ N₃ hab hbc, _⟩, \n    {refine ⟨⟨equiv.refl _,_⟩,λ X, _⟩, \n      {simp [equiv.img], },\n      {apply congr_arg, unfold_coes, simp} },\n    {cases hab with φ, refine ⟨inv φ, λ X, _⟩, rw [hab_h ((inv φ) X), inv], unfold_coes, simp},\n  cases hab with i₁ h₁, cases hbc with i₂ h₂, \n  from ⟨compose i₁ i₂, λ X, by {unfold_coes at *, simp [h₁,h₂,congr_arg, compose]}⟩,  \nend\n\n/- the ground set is an invariant of equivalence classes under strong isomorphism -/\nlemma strong_iso_same_groundset (N N' : emb_minor M) :\n  strongly_iso N N' → N.ground = N'.ground  := \nbegin\n  rintros ⟨h₁,h₂⟩, ext, \n  simp only [ground, set.mem_range],\n  simp_rw h₂, \n  refine ⟨λ h, _, λ h, _⟩, \n    {cases h with y hy, from ⟨_, hy⟩},\n  cases h with y hy, use h₁.bij.inv_fun y, unfold_coes, simp [hy],\nend \n\n\ninstance strong_iso_setoid : setoid (emb_minor M) := ⟨strongly_iso, strong_iso_equiv⟩ \n\n\nend emb_minor\n\n\n--variables {M : matroid U} [setoid (emb_minor_of M)]\ndef minor (M : matroid U) := quot (λ (N N' : emb_minor M), N.strongly_iso N')\n\nnamespace minor \n\ndef emb_to_minor (M : matroid U) := @quotient.mk (emb_minor M) _\n\n/- returns the ground set of a minor of M (as a subset of the ftype for M) -/\ndef ground {M : matroid U} : minor M → set U := quotient.lift  \n  (λ (N : emb_minor M), N.ground )\n  (λ N N' hNN', emb_minor.strong_iso_same_groundset N N' hNN' )\n\nend minor \n\n-/\n", "meta": {"author": "apnelson1", "repo": "lean-matroids", "sha": "1880f5b4b9a99948368e35539672a9bf35cc09cc", "save_path": "github-repos/lean/apnelson1-lean-matroids", "path": "github-repos/lean/apnelson1-lean-matroids/lean-matroids-1880f5b4b9a99948368e35539672a9bf35cc09cc/src/old/old/minor'''.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4797529080117632}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Jeremy Avigad, Simon Hudon\n\n! This file was ported from Lean 3 source module data.pfun\n! leanprover-community/mathlib commit 207cfac9fcd06138865b5d04f7091e46d9320432\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Part\nimport Mathlib.Data.Rel\n\n/-!\n# Partial functions\n\nThis file defines partial functions. Partial functions are like functions, except they can also be\n\"undefined\" on some inputs. We define them as functions `α → Part β`.\n\n## Definitions\n\n* `PFun α β`: Type of partial functions from `α` to `β`. Defined as `α → Part β` and denoted\n  `α →. β`.\n* `PFun.Dom`: Domain of a partial function. Set of values on which it is defined. Not to be confused\n  with the domain of a function `α → β`, which is a type (`α` presently).\n* `PFun.fn`: Evaluation of a partial function. Takes in an element and a proof it belongs to the\n  partial function's `Dom`.\n* `PFun.asSubtype`: Returns a partial function as a function from its `Dom`.\n* `PFun.toSubtype`: Restricts the codomain of a function to a subtype.\n* `PFun.evalOpt`: Returns a partial function with a decidable `Dom` as a function `a → Option β`.\n* `PFun.lift`: Turns a function into a partial function.\n* `PFun.id`: The identity as a partial function.\n* `PFun.comp`: Composition of partial functions.\n* `PFun.restrict`: Restriction of a partial function to a smaller `Dom`.\n* `PFun.res`: Turns a function into a partial function with a prescribed domain.\n* `PFun.fix` : First return map of a partial function `f : α →. β ⊕ α`.\n* `PFun.fix_induction`: A recursion principle for `PFun.fix`.\n\n### Partial functions as relations\n\nPartial functions can be considered as relations, so we specialize some `Rel` definitions to `PFun`:\n* `PFun.image`: Image of a set under a partial function.\n* `PFun.ran`: Range of a partial function.\n* `PFun.preimage`: Preimage of a set under a partial function.\n* `PFun.core`: Core of a set under a partial function.\n* `PFun.graph`: Graph of a partial function `a →. β`as a `Set (α × β)`.\n* `PFun.graph'`: Graph of a partial function `a →. β`as a `Rel α β`.\n\n### `PFun α` as a monad\n\nMonad operations:\n* `PFun.pure`: The monad `pure` function, the constant `x` function.\n* `PFun.bind`: The monad `bind` function, pointwise `Part.bind`\n* `PFun.map`: The monad `map` function, pointwise `Part.map`.\n-/\n\n\nopen Function\n\n/-- `PFun α β`, or `α →. β`, is the type of partial functions from\n  `α` to `β`. It is defined as `α → part β`. -/\ndef PFun (α β : Type _) :=\n  α → Part β\n#align pfun PFun\n\n-- mathport name: «expr →. »\n/-- `α  →. β` is notation for the type `PFun α β` of partial functions from `α` to `β`.  -/\ninfixr:25 \" →. \" => PFun\n\nnamespace PFun\n\nvariable {α β γ δ ε ι : Type _}\n\ninstance : Inhabited (α →. β) :=\n  ⟨fun _ => Part.none⟩\n\n/-- The domain of a partial function -/\ndef Dom (f : α →. β) : Set α :=\n  { a | (f a).Dom }\n#align pfun.dom PFun.Dom\n\n@[simp]\ntheorem mem_dom (f : α →. β) (x : α) : x ∈ Dom f ↔ ∃ y, y ∈ f x := by simp [Dom, Part.dom_iff_mem]\n#align pfun.mem_dom PFun.mem_dom\n\n@[simp]\ntheorem dom_mk (p : α → Prop) (f : ∀ a, p a → β) : (PFun.Dom fun x => ⟨p x, f x⟩) = { x | p x } :=\n  rfl\n#align pfun.dom_mk PFun.dom_mk\n\ntheorem dom_eq (f : α →. β) : Dom f = { x | ∃ y, y ∈ f x } :=\n  Set.ext (mem_dom f)\n#align pfun.dom_eq PFun.dom_eq\n\n/-- Evaluate a partial function -/\ndef fn (f : α →. β) (a : α) : Dom f a → β :=\n  (f a).get\n#align pfun.fn PFun.fn\n\n@[simp]\ntheorem fn_apply (f : α →. β) (a : α) : f.fn a = (f a).get :=\n  rfl\n#align pfun.fn_apply PFun.fn_apply\n\n/-- Evaluate a partial function to return an `Option` -/\ndef evalOpt (f : α →. β) [D : DecidablePred (· ∈ Dom f)] (x : α) : Option β :=\n  @Part.toOption _ _ (D x)\n#align pfun.eval_opt PFun.evalOpt\n\n/-- Partial function extensionality -/\ntheorem ext' {f g : α →. β} (H1 : ∀ a, a ∈ Dom f ↔ a ∈ Dom g) (H2 : ∀ a p q, f.fn a p = g.fn a q) :\n    f = g :=\n  funext fun a => Part.ext' (H1 a) (H2 a)\n#align pfun.ext' PFun.ext'\n\ntheorem ext {f g : α →. β} (H : ∀ a b, b ∈ f a ↔ b ∈ g a) : f = g :=\n  funext fun a => Part.ext (H a)\n#align pfun.ext PFun.ext\n\n/-- Turns a partial function into a function out of its domain. -/\ndef asSubtype (f : α →. β) (s : f.Dom) : β :=\n  f.fn s s.2\n#align pfun.as_subtype PFun.asSubtype\n\n/-- The type of partial functions `α →. β` is equivalent to\nthe type of pairs `(p : α → Prop, f : subtype p → β)`. -/\ndef equivSubtype : (α →. β) ≃ Σp : α → Prop, Subtype p → β :=\n  ⟨fun f => ⟨fun a => (f a).Dom, asSubtype f⟩, fun f x => ⟨f.1 x, fun h => f.2 ⟨x, h⟩⟩, fun f =>\n    funext fun a => Part.eta _, fun ⟨p, f⟩ => by dsimp ; congr ⟩\n#align pfun.equiv_subtype PFun.equivSubtype\n\ntheorem asSubtype_eq_of_mem {f : α →. β} {x : α} {y : β} (fxy : y ∈ f x) (domx : x ∈ f.Dom) :\n    f.asSubtype ⟨x, domx⟩ = y :=\n  Part.mem_unique (Part.get_mem _) fxy\n#align pfun.as_subtype_eq_of_mem PFun.asSubtype_eq_of_mem\n\n/-- Turn a total function into a partial function. -/\nprotected def lift (f : α → β) : α →. β := fun a => Part.some (f a)\n#align pfun.lift PFun.lift\n\ninstance : Coe (α → β) (α →. β) :=\n  ⟨PFun.lift⟩\n\n@[simp]\ntheorem coe_val (f : α → β) (a : α) : (f : α →. β) a = Part.some (f a) :=\n  rfl\n#align pfun.coe_val PFun.coe_val\n\n@[simp]\ntheorem dom_coe (f : α → β) : (f : α →. β).Dom = Set.univ :=\n  rfl\n#align pfun.dom_coe PFun.dom_coe\n\ntheorem lift_injective : Injective (PFun.lift : (α → β) → α →. β) := fun _ _ h =>\n  funext fun a => Part.some_injective <| congr_fun h a\n#align pfun.coe_injective PFun.lift_injective\n\n/-- Graph of a partial function `f` as the set of pairs `(x, f x)` where `x` is in the domain of\n`f`. -/\ndef graph (f : α →. β) : Set (α × β) :=\n  { p | p.2 ∈ f p.1 }\n#align pfun.graph PFun.graph\n\n/-- Graph of a partial function as a relation. `x` and `y` are related iff `f x` is defined and\n\"equals\" `y`. -/\ndef graph' (f : α →. β) : Rel α β := fun x y => y ∈ f x\n#align pfun.graph' PFun.graph'\n\n/-- The range of a partial function is the set of values\n  `f x` where `x` is in the domain of `f`. -/\ndef ran (f : α →. β) : Set β :=\n  { b | ∃ a, b ∈ f a }\n#align pfun.ran PFun.ran\n\n/-- Restrict a partial function to a smaller domain. -/\ndef restrict (f : α →. β) {p : Set α} (H : p ⊆ f.Dom) : α →. β := fun x =>\n  (f x).restrict (x ∈ p) (@H x)\n#align pfun.restrict PFun.restrict\n\n@[simp]\ntheorem mem_restrict {f : α →. β} {s : Set α} (h : s ⊆ f.Dom) (a : α) (b : β) :\n    b ∈ f.restrict h a ↔ a ∈ s ∧ b ∈ f a := by simp [restrict]\n#align pfun.mem_restrict PFun.mem_restrict\n\n/-- Turns a function into a partial function with a prescribed domain. -/\ndef res (f : α → β) (s : Set α) : α →. β :=\n  (PFun.lift f).restrict s.subset_univ\n#align pfun.res PFun.res\n\ntheorem mem_res (f : α → β) (s : Set α) (a : α) (b : β) : b ∈ res f s a ↔ a ∈ s ∧ f a = b := by\n  simp [res, @eq_comm _ b]\n#align pfun.mem_res PFun.mem_res\n\ntheorem res_univ (f : α → β) : PFun.res f Set.univ = f :=\n  rfl\n#align pfun.res_univ PFun.res_univ\n\ntheorem dom_iff_graph (f : α →. β) (x : α) : x ∈ f.Dom ↔ ∃ y, (x, y) ∈ f.graph :=\n  Part.dom_iff_mem\n#align pfun.dom_iff_graph PFun.dom_iff_graph\n\ntheorem lift_graph {f : α → β} {a b} : (a, b) ∈ (f : α →. β).graph ↔ f a = b :=\n  show (∃ _ : True, f a = b) ↔ f a = b by simp\n#align pfun.lift_graph PFun.lift_graph\n\n/-- The monad `pure` function, the total constant `x` function -/\nprotected def pure (x : β) : α →. β := fun _ => Part.some x\n#align pfun.pure PFun.pure\n\n/-- The monad `bind` function, pointwise `part.bind` -/\ndef bind (f : α →. β) (g : β → α →. γ) : α →. γ := fun a => (f a).bind fun b => g b a\n#align pfun.bind PFun.bind\n\n@[simp]\ntheorem bind_apply (f : α →. β) (g : β → α →. γ) (a : α) : f.bind g a = (f a).bind fun b => g b a :=\n  rfl\n#align pfun.bind_apply PFun.bind_apply\n\n/-- The monad `map` function, pointwise `part.map` -/\ndef map (f : β → γ) (g : α →. β) : α →. γ := fun a => (g a).map f\n#align pfun.map PFun.map\n\ninstance : Monad (PFun α) where\n  pure := @PFun.pure _\n  bind := @PFun.bind _\n  map := @PFun.map _\n\ninstance : LawfulMonad (PFun α) := LawfulMonad.mk'\n  (bind_pure_comp := fun f x => funext fun a => Part.bind_some_eq_map _ _)\n  (id_map := fun f => by funext a ; dsimp [Functor.map, PFun.map] ; cases f a; rfl)\n  (pure_bind := fun x f => funext fun a => Part.bind_some _ (f x))\n  (bind_assoc := fun f g k => funext fun a => (f a).bind_assoc (fun b => g b a) fun b => k b a)\n\ntheorem pure_defined (p : Set α) (x : β) : p ⊆ (@PFun.pure α _ x).Dom :=\n  p.subset_univ\n#align pfun.pure_defined PFun.pure_defined\n\ntheorem bind_defined {α β γ} (p : Set α) {f : α →. β} {g : β → α →. γ} (H1 : p ⊆ f.Dom)\n    (H2 : ∀ x, p ⊆ (g x).Dom) : p ⊆ (f >>= g).Dom := fun a ha =>\n  (⟨H1 ha, H2 _ ha⟩ : (f >>= g).Dom a)\n#align pfun.bind_defined PFun.bind_defined\n\n/-- First return map. Transforms a partial function `f : α →. β ⊕ α` into the partial function\n`α →. β` which sends `a : α` to the first value in `β` it hits by iterating `f`, if such a value\nexists. By abusing notation to illustrate, either `f a` is in the `β` part of `β ⊕ α` (in which\ncase `f.fix a` returns `f a`), or it is undefined (in which case `f.fix a` is undefined as well), or\nit is in the `α` part of `β ⊕ α` (in which case we repeat the procedure, so `f.fix a` will return\n`f.fix (f a)`). -/\n-- Porting note: had to mark `noncomputable`\nnoncomputable def fix (f : α →. Sum β α) : α →. β := fun a =>\n  Part.assert (Acc (fun x y => Sum.inr x ∈ f y) a) $ fun h =>\n    @WellFounded.fixF _ (fun x y => Sum.inr x ∈ f y) _\n      (fun a IH =>\n        Part.assert (f a).Dom $ fun hf =>\n          match e : (f a).get hf with\n          | Sum.inl b => Part.some b\n          | Sum.inr a' => IH a' ⟨hf, e⟩)\n      a h\n#align pfun.fix PFun.fix\n\ntheorem dom_of_mem_fix {f : α →. Sum β α} {a : α} {b : β} (h : b ∈ f.fix a) : (f a).Dom := by\n  let ⟨h₁, h₂⟩ := Part.mem_assert_iff.1 h\n  rw [WellFounded.fixFEq] at h₂ ; exact h₂.fst.fst\n#align pfun.dom_of_mem_fix PFun.dom_of_mem_fix\n\ntheorem mem_fix_iff {f : α →. Sum β α} {a : α} {b : β} :\n    b ∈ f.fix a ↔ Sum.inl b ∈ f a ∨ ∃ a', Sum.inr a' ∈ f a ∧ b ∈ f.fix a' :=\n  ⟨fun h => by\n    let ⟨h₁, h₂⟩ := Part.mem_assert_iff.1 h\n    rw [WellFounded.fixFEq] at h₂\n    simp at h₂\n    cases' h₂ with h₂ h₃\n    split at h₃ <;> simp at h₃\n    next e => subst b; refine' Or.inl ⟨h₂, e⟩\n    next e => exact Or.inr ⟨_, ⟨_, e⟩, Part.mem_assert _ h₃⟩,\n   fun h => by\n    simp [fix]\n    rcases h with (⟨h₁, h₂⟩ | ⟨a', h, h₃⟩)\n    · refine' ⟨⟨_, fun y h' => _⟩, _⟩\n      · injection Part.mem_unique ⟨h₁, h₂⟩ h'\n      · rw [WellFounded.fixFEq]\n        -- Porting note: used to be simp [h₁, h₂]\n        apply Part.mem_assert h₁\n        split\n        next e =>\n          injection h₂.symm.trans e with h; simp [h]\n        next e =>\n          injection h₂.symm.trans e\n    · simp [fix] at h₃\n      cases' h₃ with h₃ h₄\n      refine' ⟨⟨_, fun y h' => _⟩, _⟩\n      · injection Part.mem_unique h h' with e\n        exact e ▸ h₃\n      · cases' h with h₁ h₂\n        rw [WellFounded.fixFEq]\n        -- Porting note: used to be simp [h₁, h₂, h₄]\n        apply Part.mem_assert h₁\n        split\n        next e =>\n          injection h₂.symm.trans e\n        next e =>\n          injection h₂.symm.trans e; subst a'; exact h₄⟩\n#align pfun.mem_fix_iff PFun.mem_fix_iff\n\n/-- If advancing one step from `a` leads to `b : β`, then `f.fix a = b` -/\ntheorem fix_stop {f : α →. Sum β α} {b : β} {a : α} (hb : Sum.inl b ∈ f a) : b ∈ f.fix a := by\n  rw [PFun.mem_fix_iff]\n  exact Or.inl hb\n#align pfun.fix_stop PFun.fix_stop\n\n/-- If advancing one step from `a` on `f` leads to `a' : α`, then `f.fix a = f.fix a'` -/\ntheorem fix_fwd_eq {f : α →. Sum β α} {a a' : α} (ha' : Sum.inr a' ∈ f a) : f.fix a = f.fix a' := by\n  ext b; constructor\n  · intro h\n    obtain h' | ⟨a, h', e'⟩ := mem_fix_iff.1 h <;> cases Part.mem_unique ha' h'\n    exact e'\n  · intro h\n    rw [PFun.mem_fix_iff]\n    exact Or.inr ⟨a', ha', h⟩\n#align pfun.fix_fwd_eq PFun.fix_fwd_eq\n\ntheorem fix_fwd {f : α →. Sum β α} {b : β} {a a' : α} (hb : b ∈ f.fix a) (ha' : Sum.inr a' ∈ f a) :\n    b ∈ f.fix a' := by rwa [← fix_fwd_eq ha']\n#align pfun.fix_fwd PFun.fix_fwd\n\n/-- A recursion principle for `PFun.fix`. -/\n-- Porting note: had to add `noncomputable`\n@[elab_as_elim]\nnoncomputable def fixInduction {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α} (h : b ∈ f.fix a)\n    (H : ∀ a', b ∈ f.fix a' → (∀ a'', Sum.inr a'' ∈ f a' → C a'') → C a') : C a := by\n  have h₂ := (Part.mem_assert_iff.1 h).snd;\n  -- Porting note: revert/intro trick required to address `generalize_proofs` bug\n  revert h₂\n  generalize_proofs h₁;\n  intro h₂; clear h\n  induction' h₁ with a ha IH\n  have h : b ∈ f.fix a := Part.mem_assert_iff.2 ⟨⟨a, ha⟩, h₂⟩\n  exact H a h fun a' fa' => IH a' fa' (Part.mem_assert_iff.1 (fix_fwd h fa')).snd\n#align pfun.fix_induction PFun.fixInduction\n\ntheorem fixInduction_spec {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α} (h : b ∈ f.fix a)\n    (H : ∀ a', b ∈ f.fix a' → (∀ a'', Sum.inr a'' ∈ f a' → C a'') → C a') :\n    @fixInduction _ _ C _ _ _ h H = H a h fun a' h' => fixInduction (fix_fwd h h') H := by\n  unfold fixInduction\n  -- Porting note: `generalize` required to address `generalize_proofs` bug\n  generalize (Part.mem_assert_iff.1 h).fst = ha\n  induction ha\n  rfl\n#align pfun.fix_induction_spec PFun.fixInduction_spec\n\n/-- Another induction lemma for `b ∈ f.fix a` which allows one to prove a predicate `P` holds for\n`a` given that `f a` inherits `P` from `a` and `P` holds for preimages of `b`.\n-/\n@[elab_as_elim]\nnoncomputable def fixInduction' {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α}\n    (h : b ∈ f.fix a) (hbase : ∀ a_final : α, Sum.inl b ∈ f a_final → C a_final)\n    (hind : ∀ a₀ a₁ : α, b ∈ f.fix a₁ → Sum.inr a₁ ∈ f a₀ → C a₁ → C a₀) : C a := by\n  refine' fixInduction h fun a' h ih => _\n  rcases e : (f a').get (dom_of_mem_fix h) with b' | a'' <;> replace e : _ ∈ f a' := ⟨_, e⟩\n  · apply hbase\n    convert e\n    exact Part.mem_unique h (fix_stop e)\n  · exact hind _ _ (fix_fwd h e) e (ih _ e)\n#align pfun.fix_induction' PFun.fixInduction'\n\ntheorem fixInduction'_stop {C : α → Sort _} {f : α →. Sum β α} {b : β} {a : α} (h : b ∈ f.fix a)\n    (fa : Sum.inl b ∈ f a) (hbase : ∀ a_final : α, Sum.inl b ∈ f a_final → C a_final)\n    (hind : ∀ a₀ a₁ : α, b ∈ f.fix a₁ → Sum.inr a₁ ∈ f a₀ → C a₁ → C a₀) :\n    @fixInduction' _ _ C _ _ _ h hbase hind = hbase a fa := by\n  unfold fixInduction'\n  rw [fixInduction_spec]\n  -- Porting note: the explicit motive required because `simp` behaves differently\n  refine' Eq.rec (motive := fun x e =>\n      Sum.casesOn (motive := fun y => (f a).get (dom_of_mem_fix h) = y → C a) x _ _\n      (Eq.trans (Part.get_eq_of_mem fa (dom_of_mem_fix h)) e) = hbase a fa) _\n    (Part.get_eq_of_mem fa (dom_of_mem_fix h)).symm\n  simp\n#align pfun.fix_induction'_stop PFun.fixInduction'_stop\n\ntheorem fixInduction'_fwd {C : α → Sort _} {f : α →. Sum β α} {b : β} {a a' : α} (h : b ∈ f.fix a)\n    (h' : b ∈ f.fix a') (fa : Sum.inr a' ∈ f a)\n    (hbase : ∀ a_final : α, Sum.inl b ∈ f a_final → C a_final)\n    (hind : ∀ a₀ a₁ : α, b ∈ f.fix a₁ → Sum.inr a₁ ∈ f a₀ → C a₁ → C a₀) :\n    @fixInduction' _ _ C _ _ _ h hbase hind = hind a a' h' fa (fixInduction' h' hbase hind) := by\n  unfold fixInduction'\n  rw [fixInduction_spec]\n  -- Porting note: the explicit motive required because `simp` behaves differently\n  refine' Eq.rec (motive := fun x e =>\n      Sum.casesOn (motive := fun y => (f a).get (dom_of_mem_fix h) = y → C a) x _ _\n      (Eq.trans (Part.get_eq_of_mem fa (dom_of_mem_fix h)) e) = _) _\n    (Part.get_eq_of_mem fa (dom_of_mem_fix h)).symm\n  simp\n#align pfun.fix_induction'_fwd PFun.fixInduction'_fwd\n\nvariable (f : α →. β)\n\n/-- Image of a set under a partial function. -/\ndef image (s : Set α) : Set β :=\n  f.graph'.image s\n#align pfun.image PFun.image\n\ntheorem image_def (s : Set α) : f.image s = { y | ∃ x ∈ s, y ∈ f x } :=\n  rfl\n#align pfun.image_def PFun.image_def\n\ntheorem mem_image (y : β) (s : Set α) : y ∈ f.image s ↔ ∃ x ∈ s, y ∈ f x :=\n  Iff.rfl\n#align pfun.mem_image PFun.mem_image\n\n\n\ntheorem image_inter (s t : Set α) : f.image (s ∩ t) ⊆ f.image s ∩ f.image t :=\n  Rel.image_inter _ s t\n#align pfun.image_inter PFun.image_inter\n\ntheorem image_union (s t : Set α) : f.image (s ∪ t) = f.image s ∪ f.image t :=\n  Rel.image_union _ s t\n#align pfun.image_union PFun.image_union\n\n/-- Preimage of a set under a partial function. -/\ndef preimage (s : Set β) : Set α :=\n  Rel.image (fun x y => x ∈ f y) s\n#align pfun.preimage PFun.preimage\n\ntheorem Preimage_def (s : Set β) : f.preimage s = { x | ∃ y ∈ s, y ∈ f x } :=\n  rfl\n#align pfun.preimage_def PFun.Preimage_def\n\n@[simp]\ntheorem mem_preimage (s : Set β) (x : α) : x ∈ f.preimage s ↔ ∃ y ∈ s, y ∈ f x :=\n  Iff.rfl\n#align pfun.mem_preimage PFun.mem_preimage\n\ntheorem preimage_subset_dom (s : Set β) : f.preimage s ⊆ f.Dom := fun _ ⟨y, _, fxy⟩ =>\n  Part.dom_iff_mem.mpr ⟨y, fxy⟩\n#align pfun.preimage_subset_dom PFun.preimage_subset_dom\n\ntheorem preimage_mono {s t : Set β} (h : s ⊆ t) : f.preimage s ⊆ f.preimage t :=\n  Rel.preimage_mono _ h\n#align pfun.preimage_mono PFun.preimage_mono\n\ntheorem preimage_inter (s t : Set β) : f.preimage (s ∩ t) ⊆ f.preimage s ∩ f.preimage t :=\n  Rel.preimage_inter _ s t\n#align pfun.preimage_inter PFun.preimage_inter\n\ntheorem preimage_union (s t : Set β) : f.preimage (s ∪ t) = f.preimage s ∪ f.preimage t :=\n  Rel.preimage_union _ s t\n#align pfun.preimage_union PFun.preimage_union\n\ntheorem preimage_univ : f.preimage Set.univ = f.Dom := by ext ; simp [mem_preimage, mem_dom]\n#align pfun.preimage_univ PFun.preimage_univ\n\ntheorem coe_preimage (f : α → β) (s : Set β) : (f : α →. β).preimage s = f ⁻¹' s := by ext ; simp\n#align pfun.coe_preimage PFun.coe_preimage\n\n/-- Core of a set `s : set β` with respect to a partial function `f : α →. β`. Set of all `a : α`\nsuch that `f a ∈ s`, if `f a` is defined. -/\ndef core (s : Set β) : Set α :=\n  f.graph'.core s\n#align pfun.core PFun.core\n\ntheorem core_def (s : Set β) : f.core s = { x | ∀ y, y ∈ f x → y ∈ s } :=\n  rfl\n#align pfun.core_def PFun.core_def\n\n@[simp]\ntheorem mem_core (x : α) (s : Set β) : x ∈ f.core s ↔ ∀ y, y ∈ f x → y ∈ s :=\n  Iff.rfl\n#align pfun.mem_core PFun.mem_core\n\ntheorem compl_dom_subset_core (s : Set β) : f.Domᶜ ⊆ f.core s := fun x hx y fxy =>\n  absurd ((mem_dom f x).mpr ⟨y, fxy⟩) hx\n#align pfun.compl_dom_subset_core PFun.compl_dom_subset_core\n\ntheorem core_mono {s t : Set β} (h : s ⊆ t) : f.core s ⊆ f.core t :=\n  Rel.core_mono _ h\n#align pfun.core_mono PFun.core_mono\n\ntheorem core_inter (s t : Set β) : f.core (s ∩ t) = f.core s ∩ f.core t :=\n  Rel.core_inter _ s t\n#align pfun.core_inter PFun.core_inter\n\ntheorem mem_core_res (f : α → β) (s : Set α) (t : Set β) (x : α) :\n    x ∈ (res f s).core t ↔ x ∈ s → f x ∈ t := by simp [mem_core, mem_res]\n#align pfun.mem_core_res PFun.mem_core_res\n\nsection\n\nopen Classical\n\ntheorem core_res (f : α → β) (s : Set α) (t : Set β) : (res f s).core t = sᶜ ∪ f ⁻¹' t := by\n  ext x\n  rw [mem_core_res]\n  by_cases h : x ∈ s <;> simp [h]\n#align pfun.core_res PFun.core_res\n\nend\n\ntheorem core_restrict (f : α → β) (s : Set β) : (f : α →. β).core s = s.preimage f := by\n  ext x ; simp [core_def]\n#align pfun.core_restrict PFun.core_restrict\n\ntheorem preimage_subset_core (f : α →. β) (s : Set β) : f.preimage s ⊆ f.core s :=\n  fun _ ⟨y, ys, fxy⟩ y' fxy' =>\n  have : y = y' := Part.mem_unique fxy fxy'\n  this ▸ ys\n#align pfun.preimage_subset_core PFun.preimage_subset_core\n\ntheorem preimage_eq (f : α →. β) (s : Set β) : f.preimage s = f.core s ∩ f.Dom :=\n  Set.eq_of_subset_of_subset (Set.subset_inter (f.preimage_subset_core s) (f.preimage_subset_dom s))\n    fun x ⟨xcore, xdom⟩ =>\n    let y := (f x).get xdom\n    have ys : y ∈ s := xcore _ (Part.get_mem _)\n    show x ∈ f.preimage s from ⟨(f x).get xdom, ys, Part.get_mem _⟩\n#align pfun.preimage_eq PFun.preimage_eq\n\ntheorem core_eq (f : α →. β) (s : Set β) : f.core s = f.preimage s ∪ f.Domᶜ := by\n  rw [preimage_eq, Set.union_distrib_right, Set.union_comm (Dom f), Set.compl_union_self,\n    Set.inter_univ, Set.union_eq_self_of_subset_right (f.compl_dom_subset_core s)]\n#align pfun.core_eq PFun.core_eq\n\ntheorem preimage_as_subtype (f : α →. β) (s : Set β) :\n    f.asSubtype ⁻¹' s = Subtype.val ⁻¹' f.preimage s := by\n  ext x\n  simp only [Set.mem_preimage, Set.mem_setOf_eq, PFun.asSubtype, PFun.mem_preimage]\n  show f.fn x.val _ ∈ s ↔ ∃ y ∈ s, y ∈ f x.val\n  exact\n    Iff.intro (fun h => ⟨_, h, Part.get_mem _⟩) fun ⟨y, ys, fxy⟩ =>\n      have : f.fn x.val x.property ∈ f x.val := Part.get_mem _\n      Part.mem_unique fxy this ▸ ys\n#align pfun.preimage_as_subtype PFun.preimage_as_subtype\n\n/-- Turns a function into a partial function to a subtype. -/\ndef toSubtype (p : β → Prop) (f : α → β) : α →. Subtype p := fun a => ⟨p (f a), Subtype.mk _⟩\n#align pfun.to_subtype PFun.toSubtype\n\n@[simp]\ntheorem dom_to_subtype (p : β → Prop) (f : α → β) : (toSubtype p f).Dom = { a | p (f a) } :=\n  rfl\n#align pfun.dom_to_subtype PFun.dom_to_subtype\n\n@[simp]\ntheorem to_subtype_apply (p : β → Prop) (f : α → β) (a : α) :\n    toSubtype p f a = ⟨p (f a), Subtype.mk _⟩ :=\n  rfl\n#align pfun.to_subtype_apply PFun.to_subtype_apply\n\ntheorem dom_to_subtype_apply_iff {p : β → Prop} {f : α → β} {a : α} :\n    (toSubtype p f a).Dom ↔ p (f a) :=\n  Iff.rfl\n#align pfun.dom_to_subtype_apply_iff PFun.dom_to_subtype_apply_iff\n\ntheorem mem_to_subtype_iff {p : β → Prop} {f : α → β} {a : α} {b : Subtype p} :\n    b ∈ toSubtype p f a ↔ ↑b = f a := by\n  rw [to_subtype_apply, Part.mem_mk_iff, exists_subtype_mk_eq_iff, eq_comm]\n#align pfun.mem_to_subtype_iff PFun.mem_to_subtype_iff\n\n/-- The identity as a partial function -/\nprotected def id (α : Type _) : α →. α :=\n  Part.some\n#align pfun.id PFun.id\n\n@[simp]\ntheorem coe_id (α : Type _) : ((id : α → α) : α →. α) = PFun.id α :=\n  rfl\n#align pfun.coe_id PFun.coe_id\n\n@[simp]\ntheorem id_apply (a : α) : PFun.id α a = Part.some a :=\n  rfl\n#align pfun.id_apply PFun.id_apply\n\n/-- Composition of partial functions as a partial function. -/\ndef comp (f : β →. γ) (g : α →. β) : α →. γ := fun a => (g a).bind f\n#align pfun.comp PFun.comp\n\n@[simp]\ntheorem comp_apply (f : β →. γ) (g : α →. β) (a : α) : f.comp g a = (g a).bind f :=\n  rfl\n#align pfun.comp_apply PFun.comp_apply\n\n@[simp]\ntheorem id_comp (f : α →. β) : (PFun.id β).comp f = f :=\n  ext fun _ _ => by simp\n#align pfun.id_comp PFun.id_comp\n\n@[simp]\ntheorem comp_id (f : α →. β) : f.comp (PFun.id α) = f :=\n  ext fun _ _ => by simp\n#align pfun.comp_id PFun.comp_id\n\n@[simp]\ntheorem dom_comp (f : β →. γ) (g : α →. β) : (f.comp g).Dom = g.preimage f.Dom := by\n  ext\n  simp_rw [mem_preimage, mem_dom, comp_apply, Part.mem_bind_iff, exists_prop, ← exists_and_right]\n  rw [exists_comm]\n  simp_rw [and_comm]\n#align pfun.dom_comp PFun.dom_comp\n\n@[simp]\ntheorem preimage_comp (f : β →. γ) (g : α →. β) (s : Set γ) :\n    (f.comp g).preimage s = g.preimage (f.preimage s) := by\n  ext\n  simp_rw [mem_preimage, comp_apply, Part.mem_bind_iff, exists_prop, ← exists_and_right, ←\n    exists_and_left]\n  rw [exists_comm]\n  simp_rw [and_assoc, and_comm]\n#align pfun.preimage_comp PFun.preimage_comp\n\n@[simp]\ntheorem Part.bind_comp (f : β →. γ) (g : α →. β) (a : Part α) :\n    a.bind (f.comp g) = (a.bind g).bind f := by\n  ext c\n  simp_rw [Part.mem_bind_iff, comp_apply, Part.mem_bind_iff, exists_prop, ← exists_and_right, ←\n    exists_and_left]\n  rw [exists_comm]\n  simp_rw [and_assoc]\n#align part.bind_comp PFun.Part.bind_comp\n\n@[simp]\ntheorem comp_assoc (f : γ →. δ) (g : β →. γ) (h : α →. β) : (f.comp g).comp h = f.comp (g.comp h) :=\n  ext fun _ _ => by simp only [comp_apply, Part.bind_comp]\n#align pfun.comp_assoc PFun.comp_assoc\n\n-- This can't be `simp`\ntheorem coe_comp (g : β → γ) (f : α → β) : ((g ∘ f : α → γ) : α →. γ) = (g : β →. γ).comp f :=\n  ext fun _ _ => by simp only [coe_val, comp_apply, Function.comp, Part.bind_some]\n#align pfun.coe_comp PFun.coe_comp\n\n/-- Product of partial functions. -/\ndef prodLift (f : α →. β) (g : α →. γ) : α →. β × γ := fun x =>\n  ⟨(f x).Dom ∧ (g x).Dom, fun h => ((f x).get h.1, (g x).get h.2)⟩\n#align pfun.prod_lift PFun.prodLift\n\n@[simp]\ntheorem dom_prodLift (f : α →. β) (g : α →. γ) :\n    (f.prodLift g).Dom = { x | (f x).Dom ∧ (g x).Dom } :=\n  rfl\n#align pfun.dom_prod_lift PFun.dom_prodLift\n\ntheorem get_prodLift (f : α →. β) (g : α →. γ) (x : α) (h) :\n    (f.prodLift g x).get h = ((f x).get h.1, (g x).get h.2) :=\n  rfl\n#align pfun.get_prod_lift PFun.get_prodLift\n\n@[simp]\ntheorem prodLift_apply (f : α →. β) (g : α →. γ) (x : α) :\n    f.prodLift g x = ⟨(f x).Dom ∧ (g x).Dom, fun h => ((f x).get h.1, (g x).get h.2)⟩ :=\n  rfl\n#align pfun.prod_lift_apply PFun.prodLift_apply\n\ntheorem mem_prodLift {f : α →. β} {g : α →. γ} {x : α} {y : β × γ} :\n    y ∈ f.prodLift g x ↔ y.1 ∈ f x ∧ y.2 ∈ g x := by\n  trans ∃ hp hq, (f x).get hp = y.1 ∧ (g x).get hq = y.2\n  · simp only [prodLift, Part.mem_mk_iff, And.exists, Prod.ext_iff]\n  -- Porting note: was just `[exists_and_left, exists_and_right]`\n  · simp only [exists_and_left, exists_and_right, (· ∈ ·), Part.Mem]\n#align pfun.mem_prod_lift PFun.mem_prodLift\n\n/-- Product of partial functions. -/\ndef prodMap (f : α →. γ) (g : β →. δ) : α × β →. γ × δ := fun x =>\n  ⟨(f x.1).Dom ∧ (g x.2).Dom, fun h => ((f x.1).get h.1, (g x.2).get h.2)⟩\n#align pfun.prod_map PFun.prodMap\n\n@[simp]\ntheorem dom_prodMap (f : α →. γ) (g : β →. δ) :\n    (f.prodMap g).Dom = { x | (f x.1).Dom ∧ (g x.2).Dom } :=\n  rfl\n#align pfun.dom_prod_map PFun.dom_prodMap\n\ntheorem get_prodMap (f : α →. γ) (g : β →. δ) (x : α × β) (h) :\n    (f.prodMap g x).get h = ((f x.1).get h.1, (g x.2).get h.2) :=\n  rfl\n#align pfun.get_prod_map PFun.get_prodMap\n\n@[simp]\ntheorem prodMap_apply (f : α →. γ) (g : β →. δ) (x : α × β) :\n    f.prodMap g x = ⟨(f x.1).Dom ∧ (g x.2).Dom, fun h => ((f x.1).get h.1, (g x.2).get h.2)⟩ :=\n  rfl\n#align pfun.prod_map_apply PFun.prodMap_apply\n\ntheorem mem_prodMap {f : α →. γ} {g : β →. δ} {x : α × β} {y : γ × δ} :\n    y ∈ f.prodMap g x ↔ y.1 ∈ f x.1 ∧ y.2 ∈ g x.2 := by\n  trans ∃ hp hq, (f x.1).get hp = y.1 ∧ (g x.2).get hq = y.2\n  · simp only [prodMap, Part.mem_mk_iff, And.exists, Prod.ext_iff]\n  · simp only [exists_and_left, exists_and_right, (· ∈ ·), Part.Mem]\n#align pfun.mem_prod_map PFun.mem_prodMap\n\n@[simp]\ntheorem prodLift_fst_comp_snd_comp (f : α →. γ) (g : β →. δ) :\n    prodLift (f.comp ((Prod.fst : α × β → α) : α × β →. α))\n        (g.comp ((Prod.snd : α × β → β) : α × β →. β)) =\n      prodMap f g :=\n  ext fun a => by simp\n#align pfun.prod_lift_fst_comp_snd_comp PFun.prodLift_fst_comp_snd_comp\n\n@[simp]\ntheorem prodMap_id_id : (PFun.id α).prodMap (PFun.id β) = PFun.id _ :=\n  ext fun _ _ => by simp [eq_comm]\n#align pfun.prod_map_id_id PFun.prodMap_id_id\n\n@[simp]\ntheorem prodMap_comp_comp (f₁ : α →. β) (f₂ : β →. γ) (g₁ : δ →. ε) (g₂ : ε →. ι) :\n    (f₂.comp f₁).prodMap (g₂.comp g₁) = (f₂.prodMap g₂).comp (f₁.prodMap g₁) := -- by\n  -- Porting note: was `by tidy`, below is a golf'd verson of the `tidy?` proof\n  ext $ λ ⟨_, _⟩ ⟨_, _⟩ =>\n  ⟨λ ⟨⟨⟨h1l1, h1l2⟩, ⟨h1r1, h1r2⟩⟩, h2⟩ => ⟨⟨⟨h1l1, h1r1⟩, ⟨h1l2, h1r2⟩⟩, h2⟩,\n   λ ⟨⟨⟨h1l1, h1r1⟩, ⟨h1l2, h1r2⟩⟩, h2⟩ => ⟨⟨⟨h1l1, h1l2⟩, ⟨h1r1, h1r2⟩⟩, h2⟩⟩\n#align pfun.prod_map_comp_comp PFun.prodMap_comp_comp\n\nend PFun\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/PFun.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.4797279956299224}}
{"text": "universe u v\n\n--\n-- Model of Dijkstra monads, which combine a base monad (usually representing code) with a second\n-- monad that is a predicate or prop/proof about the monad behavior.  This monad product is represented by\n-- \"MonadWithPredicate\"\n--\n\nstructure BaseMonad (α : Type) where\n  (output : α)\n\ninductive MonadResultIs {α : Type} : α → Type where\n| mk : (mz : BaseMonad α) → MonadResultIs (mz.output)\n\ndef MRret {α : Type} (a : α) := MonadResultIs.mk (BaseMonad.mk a)\n\ndef MRbind {α : Type} {a b : α} {ma mb : BaseMonad α} : MonadResultIs a → (α → MonadResultIs b) → MonadResultIs b :=\n  fun m1 m2 => match m1 with\n               | MonadResultIs.mk mz => m2 (mz.output)\n\ndef MRrun {α : Type} {z : α} {mz : BaseMonad α} (d : MonadResultIs z) : α :=\n  match d with\n  | MonadResultIs.mk mz => mz.output\n\n\n#check MRret 3\n#reduce MRrun (MRret 3)\n#reduce MRrun (MRbind (MRret 2) (fun _ => MRret 3))\n-- here we try to run the monad and enforce a return value (4) that is wrong (actually returns 3).  This should produce and error\n#check @MRrun Nat 4 _ (MRret 4)\n\n\ndef dPred (α : Type) : Type := α → Prop\n\ndef retEqPred {α : Type} (v : α) : dPred α := fun y => y = v\ndef retEqProof {α : Type} (v : α) : retEqPred v v := show v = v by rfl\n\ndef bindPred {α β : Type} (p : dPred α) (f : α → dPred β) : dPred β := fun b => ∃ (a:α), p a ∧ f a b\n\ninductive MonadWithPredicate (α : Type) : dPred α → Type where\n| mk : (mz : BaseMonad α) → (pf : p mz.output) → MonadWithPredicate α p\n\ndef retMW {α : Type} {p : dPred α} (v : α) (pf : p v) := MonadWithPredicate.mk (BaseMonad.mk v) pf\n\n-- bind that just uses the predicate of the most recent monad. All monads need to use the same predicate here.\ndef bindMW {α : Type} {p : dPred α} {a b : α} {ma mb : BaseMonad α} : MonadWithPredicate α p → (α → MonadWithPredicate α p) → MonadWithPredicate α p :=\n  fun m1 m2 => match m1 with\n               | MonadWithPredicate.mk mz1 pf1 => m2 mz1.output\n\n-- bind that combines (using AND) the predicates of both monads\ndef bindMWAnd {α : Type} {p₁ p₂ : dPred α} : MonadWithPredicate α p₁ → (α → MonadWithPredicate α p₂) → MonadWithPredicate α (fun b => ∃x, p₁ x ∧ (p₂ b)) :=\n  fun m1 m2 => match m1 with\n               | MonadWithPredicate.mk mz1 pf1 =>\n                 match (m2 mz1.output) with\n                 | MonadWithPredicate.mk mz2 pf2 =>\n                     MonadWithPredicate.mk mz2 (show ∃ x, p₁ x ∧ p₂ mz2.output from Exists.intro mz1.output (And.intro pf1 pf2))\n\ndef runPred {α : Type} (p : dPred α) (m : MonadWithPredicate α p) : ∃ x, p x :=\n  match m with\n  | MonadWithPredicate.mk b pf => Exists.intro b.output pf\n\n\n#check show ∃ x, x=3 from Exists.intro 3 (_ : 3=3)\n#reduce (retMW 3 _ : MonadWithPredicate Nat (retEqPred 3))\n#reduce (retMW 3 (retEqProof 3) : MonadWithPredicate Nat (retEqPred 3))\n#reduce (runPred (retEqPred 3) (retMW 3 _))\n#reduce (runPred _ (bindMW (retMW 3 (retEqProof 3)) (fun _ => retMW 3 (retEqProof 3))))\n#reduce (runPred _ (bindMWAnd (retMW 3 (retEqProof 3)) (fun _ => retMW 4 (retEqProof 4))))\n\ndef runProg := runPred (retEqPred 3) (retMW 3 (retEqProof 3))\ndef runProg2 := (runPred _ (bindMWAnd (retMW 3 (retEqProof 3)) (fun (x : Nat) => retMW 4 (retEqProof 4))))\n\n\n#check @runProg2\n#check Exists.intro 3 rfl\n#check (show (∃ x, x = 3) from (Exists.intro 3 rfl))\n#check (show (∀ a, a = 3 → retEqPred 3 3) from (fun a (_:a=3) => _))\n#check Exists.elim (show (∃ x, x = 3) from (Exists.intro 3 rfl)) (show (∀ a, a = 3 → retEqPred 3 3) from (fun a (_:a=3) => _))\n\n\nexample (h: ∃ x, retEqPred 3 x ∧ retEqPred 4 4) : retEqPred 3 3 := by\n  let hx : ∀ a, retEqPred 3 a ∧ retEqPred 4 4 → retEqPred 3 3 := show ∀a, retEqPred 3 a ∧ retEqPred 4 4 → retEqPred 3 3 from (fun a x => show _ from rfl)\n  apply Exists.elim h hx\n\n-- forward transforming predicate\n\ndef fPred (α : Type) : Type := Prop → α → Prop\n\ndef simpleFP {α : Type} (v : α) : fPred α := fun (pre:Prop) (a : α) => pre ∧ a = v\n\n\ninductive MonadFwdPredicate {α : Type} : Prop → fPred α → Type where\n| mk : (mz : BaseMonad α) → (pf : ∀ (hpre : pre), p pre mz.output) → MonadFwdPredicate pre p\n\n\ndef retFP {α : Type} (v : α) {pre :Prop} : MonadFwdPredicate pre (@simpleFP α v) :=\n  let bm := BaseMonad.mk v\n  MonadFwdPredicate.mk bm (fun (hpre : pre) => show simpleFP v pre bm.output from (And.intro hpre rfl))\n\ndef bindFP {α :Type} {pre1 : Prop} {p₁ p₂ : fPred α} :\n  MonadFwdPredicate pre1 p₁ → (α → MonadFwdPredicate (∃a, p₁ pre1 a) p₂) → MonadFwdPredicate pre1 (fun pre z => p₂ (∃a, p₁ pre a) z) :=\n    fun m f => match m with \n               | MonadFwdPredicate.mk z1 pf1 =>\n                   match (f z1.output) with\n                   | MonadFwdPredicate.mk z2 pf2 =>\n                       MonadFwdPredicate.mk z2 (fun pre => (pf2 (Exists.intro z1.output (pf1 pre))))\n\n\ndef runFP {α : Type} {pre1 :Prop} {p₁ : fPred α} (m : MonadFwdPredicate pre1 p₁) : pre1 → ∃ a, p₁ pre1 a :=\n  fun p1 => match m with \n            | MonadFwdPredicate.mk ma pf => Exists.intro ma.output (pf p1)\n\ndef sampleProg := runFP (bindFP (retFP 3) (fun _ => bindFP (retFP 5) (fun _ => retFP 4))) (rfl : 2=2)\n\n\n-- backward transforming predicate\n\ndef bPred (α : Type) : Type := (α → Prop) → Prop\n\n-- for backward transformers we need to map pointwise under the transformer when binding monads.\n-- This also restricts transformers to be monotonic\nclass MonoBackward (w : bPred α) where\n  monoMap {p₁ p₂ : α → Prop} : (∀ a , p₁ a → p₂ a) → w p₁ → w p₂\n\ndef simpleBP {α : Type} (v : α) : bPred α := fun (post : α → Prop) => post v\n\ninstance {α : Type} {v : α}: MonoBackward (simpleBP v) where\n  monoMap  {p₁ p₂ : α → Prop} :=  fun f wp1 => f v wp1\n\ninductive MonadBwdPredicate {α : Type} : bPred α → (α → Prop) → Type where\n| mk : (mz : BaseMonad α) → (pf : p post) → MonadBwdPredicate p post\n\n\n\ndef retBP {α : Type} (v : α) {post : α → Prop} {postpf: post v} : MonadBwdPredicate (@simpleBP α v) post:=\n  let bm := BaseMonad.mk v\n  MonadBwdPredicate.mk bm postpf\n\ndef bindBP {α : Type} {post1 post2 : α → Prop} {p₁ p₂ p₃ : bPred α} [MonoBackward p₁] :\n  MonadBwdPredicate p₁ post1 → (α → MonadBwdPredicate p₂ post2) → MonadBwdPredicate (fun (p : α → Prop) => p₁ (fun a => post1 a ∧ p₂ post2)) post2 :=\n    fun m f => match m with\n               | MonadBwdPredicate.mk z1 pf1 =>\n                 match (f z1.output) with\n                 | MonadBwdPredicate.mk z2 pf2 =>\n                     MonadBwdPredicate.mk z2 (let hx : ∀ a, post1 a → post1 a ∧ p₂ post2 := fun a p1 => And.intro p1 pf2\n                                              MonoBackward.monoMap hx pf1)\n\ndef runBP {α : Type} {post1 : α → Prop} {p₁ : bPred α} (m : MonadBwdPredicate p₁ post1) : p₁ post1 :=\n  match m with | MonadBwdPredicate.mk ma pf => pf\n\n#check retBP 3\n\ndef sampleBack := @runBP Nat (fun x => 3 = x → Eq 3 3) (simpleBP 3) (@retBP Nat 3 _ id)\ndef sampleBack2 : simpleBP 3 fun x => 3 = x → 3 = 3 := runBP (@retBP Nat 3 _ id)\n\n\n-- backward predicate for state monad\n\ndef Top {x : Type} : x → Prop  := fun _ => True\n\ndef bSPred (s α : Type) : Type := (α × s → Prop) → s → Prop\n\ndef StatePM (s : Type) (α : Type) : Type := s → (α × s)\n\ninductive MonadBwdState (s : Type) (α: Type) (p : bSPred s α) : Type where\n| mk : (ms : StatePM s α) → (pf : ∀ post s, p post s → post (ms s)) → MonadBwdState s α p\n\n\ndef retBS {s α : Type} (a : α) : MonadBwdState s α (fun post s0 => post ⟨a, s0⟩) :=\n  let md : StatePM s α := fun s => ⟨a,s⟩\n  MonadBwdState.mk md (fun post s_1 => by\n                          intro pst\n                          let (h : md s_1 = (a, s_1)) := by simp\n                          rw [h]\n                          assumption\n                       )\n\n-- monadic bind of backward state transformers\ndef bindWBS {s α β : Type} (wc : bSPred s α) (wf : α → bSPred s β) : bSPred s β :=\n  fun p s0 => wc (fun ⟨a,s1⟩ => wf a p s1) s0\n\n\ndef bindBS {s α β : Type} {wc : bSPred s α} {wf : α → bSPred s β} :\n           MonadBwdState s α wc → ((x : α) → MonadBwdState s β (wf x)) → MonadBwdState s β (bindWBS wc wf) :=\n  fun m1 f =>\n    match m1 with\n    | MonadBwdState.mk ms1 pf1 =>\n        let mm  := fun s₁ =>\n                        let mo1:= ms1 s₁\n                        let m2 := f mo1.1\n                        match m2 with\n                        | MonadBwdState.mk ms2 pf2 => ms2 mo1.2\n        let pf3 := fun post s₁ bindW =>\n                        let mo1 := ms1 s₁\n                        let m2 := f mo1.1\n                        let ms2 := m2.1\n                        let pf2 := m2.2\n                        let ⟨a₂,s₃⟩ := mm s₁  -- actual results from monad running\n                        let postX := fun (a,s) => wf a post s\n                        let postXrfl : postX = (fun (a,s) => wf a post s) := by simp\n                        let postT₁ := pf1 postX s₁\n                        let postT₂ := pf2 post mo1.2\n                        let hh : wc postX s₁ := by unfold bindWBS at bindW; assumption\n                        let pf12 := postT₁ hh\n                        let hpf12 : postX (ms1 s₁) = wf mo1.1 post mo1.2 := by simp\n                        let hh2 : wf mo1.1 post mo1.2 := by rw [hpf12] at pf12; assumption\n                        let pf3 := postT₂ hh2\n                        let hme : ms2 = (f (ms1 s₁).fst).1 := by simp\n                        let hh3 : ms2 mo1.2 = mm s₁:= by simp\n                        by rewrite [←hh3]; assumption\n        MonadBwdState.mk mm pf3\n\n", "meta": {"author": "Izzimach", "repo": "qinglong", "sha": "d2f4e4656d86fdbace9bbbdc94f8e1de1a67f97f", "save_path": "github-repos/lean/Izzimach-qinglong", "path": "github-repos/lean/Izzimach-qinglong/qinglong-d2f4e4656d86fdbace9bbbdc94f8e1de1a67f97f/src/QingLong/Logic/DijkstraMonad.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.47972797824237734}}
{"text": "import linear_algebra.matrix\nimport group_theory.free_abelian_group\nimport algebra.direct_sum.basic\nimport algebra.big_operators.finsupp\nimport data.matrix.dmatrix\n\nimport for_mathlib.free_abelian_group\nimport data.matrix.kronecker\n\nimport hacks_and_tricks.type_pow\nimport hacks_and_tricks.by_exactI_hack\n\n/-!\n# Breen-Deligne resolutions\n\nReference:\nhttps://www.math.uni-bonn.de/people/scholze/Condensed.pdf#section*.4\n(\"Appendix to Lecture IV\", p. 28)\n\nWe formalize the notion of `breen_deligne_data`.\nRoughly speaking, this is a collection of formal finite sums of matrices\nthat encode that data that rolls out of the Breen--Deligne resolution.\n\n## Main definitions\n\n- `breen_deligne.basic_universal_map` : the map corresponding to a matrix\n- `breen_deligne.universal_map` : a formal linear combination of basic universal maps.\n\n-/\nnoncomputable theory\n\n-- get some notation working:\nopen_locale big_operators direct_sum kronecker\n\nlocal attribute [instance] type_pow\nlocal notation `ℤ[` A `]` := free_abelian_group A\n\nnamespace breen_deligne\nopen free_abelian_group\n\n/-!\nSuppose you have an abelian group `A`.\nWhat data do you need to specify a \"universal\" map `f : ℤ[A^m] → ℤ[A^n]`?\nThat is, it should be functorial in `A`.\n\nWell, such a map is specified by what it does to `(a 1, a 2, a 3, ..., a m)`.\nIt can send this element to an arbitrary element of `ℤ[A^n]`,\nbut it has to be \"universal\".\n\nIn the end, this means that `f` will be a `ℤ`-linear combination of\n\"basic universal maps\", where a \"basic universal map\" is one that\nsends `(a 1, a 2, ..., a m)` to `(b 1, ..., b n)`,\nwhere `b i` is a `ℤ`-linear combination `c i 1 * a 1 + ... + c i m * a m`.\nSo a \"basic universal map\" is specified by the `n × m`-matrix `c`.\n-/\n\n/-- A `basic_universal_map m n` is an `n × m`-matrix.\nIt captures data for a homomorphism `ℤ[A^m] → ℤ[A^n]`\nfunctorial in the abelian group `A`.\n\nA general such homomorphism is a formal linear combination\nof `basic_universal_map`s, which we aptly call `universal_map`s. -/\n@[derive add_comm_group]\ndef basic_universal_map (m n : ℕ) := matrix (fin n) (fin m) ℤ\n\nnamespace basic_universal_map\n\nvariables (A : Type*) [add_comm_group A]\nvariables {k l m n : ℕ} (g : basic_universal_map m n) (f : basic_universal_map l m)\n\ndef pre_eval : basic_universal_map m n →+ A^m → A^n :=\nadd_monoid_hom.mk' (λ f x i, ∑ j, f i j • (x : fin _ → A) j)\nbegin\n  intros f₁ f₂,\n  ext x i,\n  simp only [pi.add_apply, dmatrix.add_apply, add_smul, finset.sum_add_distrib],\nend\n\nlemma pre_eval_apply : pre_eval A g = λ x i, ∑ j, g i j • (x : fin _ → A) j := rfl\n\n/-- `f.eval A` for a `f : basic_universal_map m n`\nis the homomorphism `ℤ[A^m] →+ ℤ[A^n]` induced by matrix multiplication. -/\ndef eval : ℤ[A^m] →+ ℤ[A^n] :=\nmap $ pre_eval A g\n\nlemma eval_of (x : A^m) :\n  g.eval A (of x) = (of $ pre_eval A g x) :=\nlift.of _ _\n\n/-- The composition of basic universal maps,\ndefined as matrix multiplication. -/\ndef comp : basic_universal_map m n →+ basic_universal_map l m →+ basic_universal_map l n :=\nadd_monoid_hom.mk' (λ g, add_monoid_hom.mk' (λ f, matrix.mul g f) $ matrix.mul_add _) $\n  λ g₁ g₂, by { ext1 f, apply matrix.add_mul }\n\nlemma eval_comp : (comp g f).eval A = (g.eval A).comp (f.eval A) :=\nbegin\n  ext1 x,\n  simp only [add_monoid_hom.coe_comp, function.comp_app, eval_of, pre_eval, comp, finset.smul_sum,\n    matrix.mul_apply, finset.sum_smul, mul_smul, add_monoid_hom.mk'_apply],\n  congr' 1,\n  ext1 i,\n  exact finset.sum_comm\nend\n\nlemma comp_assoc\n  (h : basic_universal_map m n) (g : basic_universal_map l m) (f : basic_universal_map k l) :\n  comp (comp h g) f = comp h (comp g f) :=\nmatrix.mul_assoc h g f\n\n/-- The identity `basic_universal_map`. -/\ndef id (n : ℕ) : basic_universal_map n n := (1 : matrix (fin n) (fin n) ℤ)\n\n@[simp] lemma id_comp : comp (id _) f = f :=\nmatrix.one_mul f\n\n@[simp] lemma comp_id : comp g (id _) = g :=\nmatrix.mul_one g\n\ndef mul (N : ℕ) : basic_universal_map m n →+ basic_universal_map (N * m) (N * n) :=\nadd_monoid_hom.mk'\n (λ f, matrix.reindex_linear_equiv ℕ _ fin_prod_fin_equiv fin_prod_fin_equiv (1 ⊗ₖ f))\nbegin\n  intros f g,\n  simp only [matrix.kronecker_add, matrix.reindex_linear_equiv_apply,\n    matrix.reindex_apply, matrix.submatrix_add, dmatrix.add_apply],\nend\n\nlemma mul_apply (N : ℕ) (f : basic_universal_map m n) :\n  mul N f = matrix.reindex_linear_equiv ℕ _ fin_prod_fin_equiv fin_prod_fin_equiv (1 ⊗ₖ f) :=\nrfl\n\nlemma mul_injective (N : ℕ) (hN : 0 < N) : function.injective (@mul m n N) :=\nbegin\n  intros f g H,\n  ext i j,\n  rw function.funext_iff at H,\n  specialize H (fin_prod_fin_equiv (⟨0, hN⟩, i)),\n  rw function.funext_iff at H,\n  specialize H (fin_prod_fin_equiv (⟨0, hN⟩, j)),\n  dsimp only [basic_universal_map.mul, matrix.kronecker_map, add_monoid_hom.mk'_apply,\n    matrix.reindex_linear_equiv_apply, matrix.reindex_apply, matrix.submatrix_apply] at H,\n  simpa only [one_mul, equiv.symm_apply_apply, matrix.one_apply_eq] using H,\nend\n\nlemma mul_comp (N : ℕ) (g : basic_universal_map m n) (f : basic_universal_map l m) :\n  mul N (comp g f) = comp (mul N g) (mul N f) :=\nbegin\n  ext1 i j,\n  dsimp only [mul, comp, add_monoid_hom.mk'_apply],\n  rw [matrix.reindex_linear_equiv_mul, ← matrix.mul_kronecker_mul, matrix.one_mul],\nend\n\ndef one_mul_hom (n) : basic_universal_map (1 * n) n :=\nmatrix.reindex_linear_equiv ℕ _\n  ((fin_one_equiv.prod_congr $ equiv.refl _).trans $ equiv.punit_prod _)\n  fin_prod_fin_equiv\n  (1 : matrix (fin 1 × fin n) _ ℤ)\n\ndef one_mul_inv (n) : basic_universal_map n (1 * n) :=\nmatrix.reindex_linear_equiv ℕ _\n  fin_prod_fin_equiv\n  ((fin_one_equiv.prod_congr $ equiv.refl _).trans $ equiv.punit_prod _)\n  (1 : matrix (fin 1 × fin n) _ ℤ)\n\nlemma one_mul_hom_inv : comp (one_mul_hom n) (one_mul_inv n) = id n :=\nbegin\n  dsimp only [comp, one_mul_hom, one_mul_inv, add_monoid_hom.mk'_apply, id],\n  rw [matrix.reindex_linear_equiv_mul, matrix.one_mul, matrix.reindex_linear_equiv_one],\nend\n\nlemma one_mul_inv_hom : comp (one_mul_inv n) (one_mul_hom n) = id _ :=\nbegin\n  dsimp only [comp, one_mul_hom, one_mul_inv, add_monoid_hom.mk'_apply, id],\n  rw [matrix.reindex_linear_equiv_mul, matrix.one_mul, matrix.reindex_linear_equiv_one],\nend\n\ndef mul_mul_hom (m n i : ℕ) : basic_universal_map (m * (n * i)) ((m * n) * i) :=\nmatrix.reindex_linear_equiv ℕ _\n  (((equiv.refl _).prod_congr fin_prod_fin_equiv.symm).trans $\n    (equiv.prod_assoc _ _ _).symm.trans $ (fin_prod_fin_equiv.prod_congr $ equiv.refl _).trans\n      fin_prod_fin_equiv)\n  fin_prod_fin_equiv\n  (1 : matrix (fin m × fin (n * i)) (fin m × fin (n * i)) ℤ)\n\ndef mul_mul_inv (m n i : ℕ) : basic_universal_map ((m * n) * i) (m * (n * i)) :=\nmatrix.reindex_linear_equiv ℕ _\n  fin_prod_fin_equiv\n  (((equiv.refl _).prod_congr fin_prod_fin_equiv.symm).trans $\n    (equiv.prod_assoc _ _ _).symm.trans $ (fin_prod_fin_equiv.prod_congr $ equiv.refl _).trans\n      fin_prod_fin_equiv)\n  (1 : matrix (fin m × fin (n * i)) (fin m × fin (n * i)) ℤ)\n\nlemma mul_mul_hom_inv {m n i : ℕ} : comp (mul_mul_hom m n i) (mul_mul_inv m n i) = id _ :=\nbegin\n  dsimp only [comp, mul_mul_hom, mul_mul_inv, add_monoid_hom.mk'_apply, id],\n  rw [matrix.reindex_linear_equiv_mul, matrix.one_mul, matrix.reindex_linear_equiv_one],\nend\n\nlemma mul_mul_inv_hom {m n i : ℕ} : comp (mul_mul_inv m n i) (mul_mul_hom m n i) = id _ :=\nbegin\n  dsimp only [comp, mul_mul_hom, mul_mul_inv, add_monoid_hom.mk'_apply, id],\n  rw [matrix.reindex_linear_equiv_mul, matrix.one_mul, matrix.reindex_linear_equiv_one],\nend\n\ndef proj_aux {N : ℕ} (k : fin N) : matrix punit.{1} (fin N) ℤ :=\nλ i j, if j = k then 1 else 0\n\ndef proj (n : ℕ) {N : ℕ} (k : fin N) : basic_universal_map (N * n) n :=\nmatrix.reindex_linear_equiv ℕ _ (equiv.punit_prod _) fin_prod_fin_equiv $\n(proj_aux k) ⊗ₖ 1\n\nlemma proj_comp_mul {N : ℕ} (k : fin N) (f : basic_universal_map m n) :\n  comp (proj n k) (mul N f) = comp f (proj m k) :=\nbegin\n  dsimp only [comp, proj, mul, add_monoid_hom.mk'_apply],\n  have : f = (matrix.reindex_linear_equiv\n  ℕ _   (equiv.punit_prod (fin n)) (equiv.punit_prod (fin m)))\n    ((1 : matrix punit.{1} punit.{1} ℤ) ⊗ₖ f),\n  { ext i j,\n    simp only [matrix.reindex_linear_equiv_apply, matrix.reindex_apply, matrix.submatrix_apply,\n      equiv.punit_prod_symm_apply, matrix.kronecker, matrix.kronecker_apply,\n      matrix.one_apply_eq, one_mul] },\n  conv_rhs { rw this },\n  rw [matrix.reindex_linear_equiv_mul, matrix.reindex_linear_equiv_mul],\n  simp only [←matrix.mul_kronecker_mul, matrix.kronecker, matrix.mul_one, matrix.one_mul],\nend\n\nlemma one_mul_hom_eq_proj : basic_universal_map.one_mul_hom n = basic_universal_map.proj n 0 :=\nbegin\n  dsimp only [basic_universal_map.one_mul_hom, basic_universal_map.proj],\n  rw [← linear_equiv.symm_apply_eq, matrix.reindex_linear_equiv_symm,\n    matrix.reindex_linear_equiv_comp_apply, equiv.self_trans_symm, equiv.trans_assoc,\n    equiv.self_trans_symm, equiv.trans_refl],\n  ext ⟨i, i'⟩ ⟨j, j'⟩ : 2,\n  change fin 1 at j,\n  dsimp only [matrix.reindex_linear_equiv_apply, matrix.kronecker],\n  dsimp [fin_one_equiv, equiv.prod_congr_left, basic_universal_map.proj_aux],\n  simp only [matrix.one_apply, prod.mk.inj_iff, @eq_comm _ _ j],\n  simp only [true_and, mul_boole, if_true, prod.mk.inj_iff,\n    eq_self_iff_true, eq_iff_true_of_subsingleton],\nend\n.\n\nlemma proj_aux_kronecker_proj_aux (a : fin m) (b : fin n) :\n  (proj_aux a) ⊗ₖ (proj_aux b) =\n  matrix.reindex_linear_equiv ℕ _ (equiv.prod_punit _).symm fin_prod_fin_equiv.symm\n    (proj_aux (fin_prod_fin_equiv (a,b))) :=\nbegin\n  ext ⟨i, i'⟩ ⟨j, j'⟩ : 2,\n  dsimp [matrix.reindex_linear_equiv_apply, matrix.kronecker, proj_aux],\n  simp only [equiv.apply_eq_iff_eq, boole_mul, prod.mk.inj_iff, ← ite_and],\nend\n\nlemma proj_aux_apply (a : fin m) (b : fin m) : proj_aux a punit.star b = ite (a = b) 1 0 :=\nbegin\n  by_cases h : a = b,\n  rw if_pos,\n  assumption',\n  all_goals { simp only [proj_aux, zero_ne_one, ite_eq_left_iff], finish },\nend\n\nlemma comp_proj_mul_proj (n N : ℕ) (j : fin (2 * 2 ^ N)) :\n  (comp (proj n ((fin_prod_fin_equiv.symm) j).fst)) (mul 2 (proj n ((fin_prod_fin_equiv.symm) j).snd)) =\n  (comp (proj n j)) (mul_mul_hom 2 (2 ^ N) n) :=\nbegin\n  dsimp only [mul_mul_hom, proj, comp, mul_apply, add_monoid_hom.mk'_apply],\n  rw [matrix.reindex_linear_equiv_mul, ← matrix.mul_kronecker_mul, matrix.one_mul,\n    matrix.mul_one, matrix.mul_reindex_linear_equiv_one],\n  simp only [matrix.reindex_linear_equiv_apply, matrix.reindex_apply, function.comp.right_id,\n    matrix.submatrix_submatrix, equiv.refl_symm, equiv.coe_refl],\n  ext x y,\n  dsimp [matrix.submatrix, - fin_prod_fin_equiv_symm_apply],\n  rw [matrix.one_apply, matrix.one_apply],\n  simp only [mul_boole, mul_ite, mul_zero, equiv.symm_apply_apply, mul_one],\n  congr' 2,\n  simp only [proj_aux_apply, boole_mul],\n  rw [← ite_and],\n  congr' 1,\n  rw [← prod.mk.inj_iff, prod.mk.eta, equiv.symm_apply_eq],\nend\n\nend basic_universal_map\n\n/-- A `universal_map m n` is a formal `ℤ`-linear combination\nof `basic_universal_map`s.\nIt captures the data for a homomorphism `ℤ[A^m] → ℤ[A^n]`. -/\n@[derive add_comm_group]\ndef universal_map (m n : ℕ) := ℤ[basic_universal_map m n]\n\nnamespace universal_map\nuniverse variable u\n\nvariables {k l m n : ℕ} (g : universal_map m n) (f : universal_map l m)\nvariables (A : Type u) [add_comm_group A]\n\n/-- `f.eval A` for a `f : universal_map m n`\nis the homomorphism `ℤ[A^m] →+ ℤ[A^n]` induced by matrix multiplication\nof the summands occurring in the formal linear combination `f`. -/\ndef eval : universal_map m n →+ ℤ[A^m] →+ ℤ[A^n] :=\nfree_abelian_group.lift $ λ (f : basic_universal_map m n), f.eval A\n\n@[simp] lemma eval_of (f : basic_universal_map m n) :\n  eval A (of f) = f.eval A :=\nlift.of _ _\n\n/-- The composition of `universal_map`s `g` and `f`,\ngiven by the formal linear combination of all compositions\nof summands occurring in `g` and `f`. -/\ndef comp : universal_map m n →+ universal_map l m →+ universal_map l n :=\nfree_abelian_group.lift $ λ (g : basic_universal_map m n), free_abelian_group.lift $ λ f,\nof $ basic_universal_map.comp g f\n\n@[simp] lemma comp_of (g : basic_universal_map m n) (f : basic_universal_map l m) :\n  comp (of g) (of f) = of (basic_universal_map.comp g f) :=\nby rw [comp, lift.of, lift.of]\n\nsection\nopen add_monoid_hom\n\nlemma eval_comp : eval A (comp g f) = (eval A g).comp (eval A f) :=\nshow comp_hom (comp_hom (@eval l n A _)) (comp) g f =\n  comp_hom (comp_hom (comp_hom.flip (@eval l m A _)) (comp_hom)) (@eval m n A _) g f,\nbegin\n  congr' 2, clear f g, ext g f : 2,\n  show eval A (comp (of g) (of f)) = (eval A (of g)).comp (eval A (of f)),\n  simp only [basic_universal_map.eval_comp, comp_of, eval_of]\nend\n\nlemma comp_assoc (h : universal_map m n) (g : universal_map l m) (f : universal_map k l) :\n  comp (comp h g) f = comp h (comp g f) :=\nshow comp_hom (comp_hom (@comp k l n)) (@comp l m n) h g f =\n     comp_hom (comp_hom (comp_hom.flip (@comp k l m)) (comp_hom)) (@comp k m n) h g f,\nbegin\n  congr' 3, clear h g f, ext h g f : 3,\n  show comp (comp (of h) (of g)) (of f) = comp (of h) (comp (of g) (of f)),\n  simp only [basic_universal_map.comp_assoc, comp_of]\nend\n\n/-- The identity `universal_map`. -/\ndef id (n : ℕ) : universal_map n n := of (basic_universal_map.id n)\n\n@[simp] lemma id_comp : comp (id _) f = f :=\nshow comp (id _) f = add_monoid_hom.id _ f,\nbegin\n  congr' 1, clear f, ext1 f,\n  simp only [id, comp_of, id_apply, basic_universal_map.id_comp]\nend\n\n@[simp] lemma comp_id : comp g (id _) = g :=\nshow (@comp m m n).flip (id _) g = add_monoid_hom.id _ g,\nbegin\n  congr' 1, clear g, ext1 g,\n  show comp (of g) (id _) = (of g),\n  simp only [id, comp_of, id_apply, basic_universal_map.comp_id]\nend\n\ndef bound : ℕ := ∑ g in f.support, (free_abelian_group.coeff g f).nat_abs\n\ndef bound_by (N : ℕ) : Prop := f.bound ≤ N\n\nlemma of_bound_by (f : basic_universal_map m n) : bound_by (of f) 1 :=\nbegin\n  simp only [bound_by, bound, coeff_of_self, int.nat_abs_one, finset.sum_singleton, support_of],\nend\n\nlemma zero_bound_by (N : ℕ) : (0 : universal_map m n).bound_by N :=\nby simp only [bound_by, bound, zero_le', finset.sum_const_zero,\n    add_monoid_hom.map_zero, int.nat_abs_zero]\n\nlemma zero_bound_by_zero : (0 : universal_map m n).bound_by 0 :=\nzero_bound_by _\n\nlemma bound_by.random_index {f : universal_map m n} {N : ℕ}\n  (hf : f.bound_by N) (s : finset (basic_universal_map m n)) :\n  ∑ g in s, (free_abelian_group.coeff g f).nat_abs ≤ N :=\nbegin\n  calc ∑ g in s, (free_abelian_group.coeff g f).nat_abs\n      = ∑ g in s ∩ f.support, (free_abelian_group.coeff g f).nat_abs +\n        ∑ g in s \\ f.support, (free_abelian_group.coeff g f).nat_abs : _\n  ... = ∑ g in s ∩ f.support, (free_abelian_group.coeff g f).nat_abs : _\n  ... ≤ ∑ g in f.support ∩ s, (free_abelian_group.coeff g f).nat_abs +\n        ∑ g in f.support \\ s, (free_abelian_group.coeff g f).nat_abs : _\n  ... ≤ ∑ g in f.support, (free_abelian_group.coeff g f).nat_abs : _\n  ... ≤ N : hf,\n  { rw finset.sum_inter_add_sum_diff },\n  { simp only [and_imp, add_right_eq_self, int.nat_abs_eq_zero, imp_self, imp_true_iff,\n      finset.mem_sdiff, finset.sum_eq_zero_iff, free_abelian_group.not_mem_support_iff] },\n  { rw finset.inter_comm, simp only [le_add_iff_nonneg_right, zero_le'], },\n  { rw finset.sum_inter_add_sum_diff },\nend\n\nlemma bound_by.add {f₁ f₂ : universal_map m n} {N₁ N₂ : ℕ}\n  (h₁ : f₁.bound_by N₁) (h₂ : f₂.bound_by N₂) :\n  (f₁ + f₂).bound_by (N₁ + N₂) :=\nbegin\n  calc (f₁ + f₂).bound ≤\n      ∑ (g : basic_universal_map m n) in support (f₁ + f₂),\n        ((coeff g f₁).nat_abs + (coeff g f₂).nat_abs) : finset.sum_le_sum _\n  ... ≤ N₁ + N₂ : _,\n  { intros g hg,\n    rw add_monoid_hom.map_add,\n    apply int.nat_abs_add_le },\n  { rw finset.sum_add_distrib,\n    exact add_le_add (h₁.random_index _) (h₂.random_index _) }\nend\n\nlemma bound_by_sum {ι : Type*} (s : finset ι) (f : ι → universal_map m n) (N : ι → ℕ)\n  (h : ∀ i ∈ s, (f i).bound_by (N i)) :\n  (∑ i in s, f i).bound_by (∑ i in s, N i) :=\nbegin\n  classical,\n  revert h,\n  apply finset.induction_on s; clear s,\n  { simp only [finset.not_mem_empty, is_empty.forall_iff, finset.sum_empty,\n      implies_true_iff, forall_true_left],\n    exact zero_bound_by_zero },\n  { intros i s his IH h,\n    simp only [finset.sum_insert his],\n    exact (h i $ s.mem_insert_self i).add (IH $ λ j hj, h j $ finset.mem_insert_of_mem hj) }\nend\n\nend\n\nsection mul\nopen add_monoid_hom\n\n/-\nTODO: refactor `mul` to be a functor\nTODO: put a monoidal structure on `FreeMat`, so that this is just `N ⊗ _`.\n-/\n\ndef mul (N : ℕ) : universal_map m n →+ universal_map (N * m) (N * n) :=\nmap (basic_universal_map.mul N)\n\nlemma mul_of (N : ℕ) (f : basic_universal_map m n) :\n  mul N (of f) = of (basic_universal_map.mul N f) :=\nmap_of_apply _\n\nlemma mul_comp (N : ℕ) (g : universal_map m n) (f : universal_map l m) :\n  mul N (comp g f) = comp (mul N g) (mul N f) :=\nbegin\n  simp only [← add_monoid_hom.comp_apply],\n  rw [← add_monoid_hom.comp_hom_apply_apply, ← add_monoid_hom.comp_hom_apply_apply,\n    ← add_monoid_hom.comp_hom_apply_apply,\n    ← add_monoid_hom.flip_apply _ _ (mul N)],\n  simp only [← add_monoid_hom.comp_apply],\n  rw [← add_monoid_hom.comp_hom_apply_apply, ← add_monoid_hom.comp_hom_apply_apply],\n  congr' 2, clear f g, ext g f,\n  show (mul N) ((comp (of g)) (of f)) = (comp ((mul N) (of g))) ((mul N) (of f)),\n  simp only [comp_of, mul_of, basic_universal_map.mul_comp],\nend\n\nlemma mem_support_mul (N : ℕ) (hN : 0 < N) (f : universal_map m n) (g) :\n  g ∈ (mul N f).support ↔ ∃ g', g' ∈ f.support ∧ g = basic_universal_map.mul N g' :=\nbegin\n  apply free_abelian_group.mem_support_map,\n  exact basic_universal_map.mul_injective N hN\nend\n\n@[simp]\nlemma coeff_mul (N : ℕ) (hN : 0 < N) (f : universal_map m n) (g : basic_universal_map m n) :\n  coeff (basic_universal_map.mul N g) (mul N f) = coeff g f :=\nbegin\n  simp only [← add_monoid_hom.comp_apply],\n  rw [← add_monoid_hom.comp_hom_apply_apply],\n  congr' 1, clear f, ext f,\n  simp only [comp_hom_apply_apply, function.comp_app, coe_comp, mul, coeff, to_finsupp_of,\n    map_of_apply, finsupp.apply_add_hom_apply, finsupp.single_apply,\n    (basic_universal_map.mul_injective N hN).eq_iff],\nend\n\nend mul\n\n/-\nTODO: refactor `sum` and `proj` to be natural transformations from `mul n` to `𝟭 _`.\n-/\n\ndef sum (n N : ℕ) : universal_map (N * n) n :=\nof (∑ i, basic_universal_map.proj n i)\n\ndef proj (n N : ℕ) : universal_map (N * n) n :=\n∑ i, of (basic_universal_map.proj n i)\n\nlemma sum_comp_mul (N : ℕ) (f : universal_map m n) :\n  comp (sum n N) (mul N f) = comp f (sum m N) :=\nbegin\n  simp only [← add_monoid_hom.comp_apply],\n  rw [← add_monoid_hom.comp_hom_apply_apply, ← add_monoid_hom.flip_apply _ _ (sum m N)],\n  simp only [← add_monoid_hom.comp_apply],\n  congr' 1, clear f, ext f,\n  show (comp (sum n N)) ((mul N) (of f)) = (comp (of f)) (sum m N),\n  simp only [sum, mul_of, comp_of, add_monoid_hom.map_sum,\n    add_monoid_hom.finset_sum_apply, basic_universal_map.proj_comp_mul],\nend\n\nlemma proj_comp_mul (N : ℕ) (f : universal_map m n) :\n  comp (proj n N) (mul N f) = comp f (proj m N) :=\nbegin\n  simp only [← add_monoid_hom.comp_apply],\n  rw [← add_monoid_hom.comp_hom_apply_apply, ← add_monoid_hom.flip_apply _ _ (proj m N)],\n  simp only [← add_monoid_hom.comp_apply],\n  congr' 1, clear f, ext f,\n  show (comp (proj n N)) ((mul N) (of f)) = (comp (of f)) (proj m N),\n  simp only [proj, mul_of, comp_of, add_monoid_hom.map_sum,\n    add_monoid_hom.finset_sum_apply, basic_universal_map.proj_comp_mul],\nend\n.\n\nlemma proj_bound_by (n N : ℕ) : (proj n N).bound_by N :=\nle_trans (bound_by_sum _ _ _ $ λ i _, of_bound_by _) $\nby simp only [finset.card_fin, mul_one, algebra.id.smul_eq_mul, finset.sum_const]\n\nend universal_map\n\nend breen_deligne\n\n-- #lint- only unused_arguments def_lemma doc_blame\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/breen_deligne/universal_map.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256591565729, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4797165838988436}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Nathaniel Thomas\n\nMore examples to test automation, stolen shamelessly by Jeremy from Nathaniel's \"tauto\".\n-/\nimport tactic.finish\nopen nat\n\nsection\n\nvariables (a b c d e f : Prop)\nvariable even : ℕ → Prop\nvariable P : ℕ → Prop\n\n-- these next five are things that tauto doesn't get\n\nexample : (∀ x, P x) ∧ b → (∀ y, P y) ∧ P 0 ∨ b ∧ P 0 := by finish\nexample : (∀ A, A ∨ ¬A) → ∀ x y : ℕ, x = y ∨ x ≠ y := by finish\nexample : ∀ b1 b2, b1 = b2 ↔ (b1 = tt ↔ b2 = tt) := begin intro b1, cases b1; finish [iff_def] end\n\nexample : ∀ (P Q : nat → Prop), (∀ n, Q n → P n) → (∀ n, Q n) → P 2 := by finish\nexample (a b c : Prop) : ¬ true ∨ false ∨ b ↔ b := by finish\n\nexample : true := by finish\n\nexample : false → a := by finish\nexample : a → a := by finish\nexample : (a → b) → a → b := by finish\nexample : ¬ a → ¬ a := by finish\nexample : a → (false ∨ a) := by finish\nexample : (a → b → c) → (a → b) → a → c := by finish\nexample : a → ¬ a → (a → b) → (a ∨ b) → (a ∧ b) → a → false := by finish\nexample : ((a ∧ b) ∧ c) → b := by finish\nexample : ((a → b) → c) → b → c := by finish\nexample : (a ∨ b) → (b ∨ a) := by finish\nexample : (a → b ∧ c) → (a → b) ∨ (a → c) := by finish\nexample : ∀ (x0 : a ∨ b) (x1 : b ∧ c), a → b := by finish\nexample : a → b → (c ∨ b) := by finish\nexample : (a ∧ b → c) → b → a → c := by finish\nexample : (a ∨ b → c) → a → c := by finish\nexample : (a ∨ b → c) → b → c := by finish\nexample : (a ∧ b) → (b ∧ a) := by finish\nexample : (a ↔ b) → a → b := by finish\nexample : a → ¬¬a := by finish\nexample : ¬¬(a ∨ ¬a) := by finish\nexample : ¬¬(a ∨ b → a ∨ b) := by finish\nexample : ¬¬((∀ n, even n) ∨ ¬(∀ m, even m)) := by finish\nexample : (¬¬b → b) → (a → b) → ¬¬a → b := by finish\nexample : (¬¬b → b) → (¬b → ¬ a) → ¬¬a → b := by finish\n\nexample : ((a → b → false) → false) → (b → false) → false := by finish\n\nexample : ((((c → false) → a) → ((b → false) → a) → false) → false) →\n            (((c → b → false) → false) → false) → ¬a → a := by finish\n\nexample (p q r : Prop) (a b : nat) : true → a = a → q → q → p → p := by finish\nexample : ∀ (F F' : Prop), F ∧ F' → F := by finish\nexample : ∀ (F1 F2 F3 : Prop), ((¬F1 ∧ F3) ∨ (F2 ∧ ¬F3)) → (F2 → F1) → (F2 → F3) →  ¬F2 := by finish\nexample : ∀ (f : nat → Prop), f 2 → ∃ x, f x := by finish\nexample : true ∧ true ∧ true ∧ true ∧ true ∧ true ∧ true := by finish\nexample : ∀ (P : nat → Prop), P 0 → (P 0 → P 1) → (P 1 → P 2) → (P 2) := by finish\nexample : ¬¬¬¬¬a → ¬¬¬¬¬¬¬¬a → false := by finish\nexample : ∀ n, ¬¬(even n ∨ ¬even n) := by finish\nexample : ∀ (p q r s : Prop) (a b : nat), r ∨ s → p ∨ q → a = b → q ∨ p := by finish\nexample : (∀ x, P x) → (∀ y, P y) := by finish\n\n/- TODO(Jeremy): reinstate after simp * at * bug is fixed.\nexample : ((a ↔ b) → (b ↔ c)) → ((b ↔ c) → (c ↔ a)) → ((c ↔ a) → (a ↔ b)) → (a ↔ b) :=\nby finish [iff_def]\n-/\n\nexample : ((¬a ∨ b) ∧ (¬b ∨ b) ∧ (¬a ∨ ¬b) ∧ (¬b ∨ ¬b) → false) → ¬((a → b) → b) → false := by finish\n\nexample : ¬((a → b) → b) → ((¬b ∨ ¬b) ∧ (¬b ∨ ¬a) ∧ (b ∨ ¬b) ∧ (b ∨ ¬a) → false) → false := by finish\nexample : (¬a ↔ b) → (¬b ↔ a) → (¬¬a ↔ a) := by finish\n\nexample : (¬ a ↔ b) → (¬ (c ∨ e) ↔ d ∧ f) → (¬ (c ∨ a ∨ e) ↔ d ∧ b ∧ f) := by finish\n\nexample {A : Type} (p q : A → Prop) (a b : A) : q a → p b → ∃ x, (p x ∧ x = b) ∨ q x := by finish\n\nexample {A : Type} (p q : A → Prop) (a b : A) : p b → ∃ x, q x ∨ (p x ∧ x = b) := by finish\n\nexample : ¬ a → b → a → c := by finish\nexample : a → b → b → ¬ a → c := by finish\nexample (a b : nat) : a = b → b = a := by finish\n\n-- good examples of things we don't get, even using the simplifier\nexample (a b c : nat) : a = b → a = c → b = c := by finish\nexample (p : nat → Prop) (a b c : nat) : a = b → a = c → p b → p c := by finish\n\nexample (p : Prop) (a b : nat) : a = b → p → p := by finish\n\n-- safe should look for contradictions with constructors\nexample (a : nat) : (0 : ℕ) = succ a → a = a → false := by finish\nexample (p : Prop) (a b c : nat) : [a, b, c] = [] → p := by finish\n\nexample (a b c : nat) : succ (succ a) = succ (succ b) → c = c := by finish\nexample (p : Prop) (a b : nat) : a = b → b ≠ a → p := by finish\nexample : (a ↔ b) → ((b ↔ a) ↔ (a ↔ b)) := by finish\nexample (a b c : nat) : b = c → (a = b ↔ c = a) := by finish [iff_def]\nexample : ¬¬¬¬¬¬¬¬a → ¬¬¬¬¬a → false := by finish\nexample (a b c : Prop) : a ∧ b ∧ c ↔ c ∧ b ∧ a := by finish\nexample (a b c : Prop) : a ∧ false ∧ c ↔ false := by finish\nexample (a b c : Prop) : a ∨ false ∨ b ↔ b ∨ a := by finish\nexample : a ∧ not a ↔ false := by finish\nexample : a ∧ b ∧ true → b ∧ a := by finish\nexample (A : Type) (a₁ a₂ : A) : a₁ = a₂ →\n  (λ (B : Type) (f : A → B), f a₁) = (λ (B : Type) (f : A → B), f a₂) := by finish\nexample (a : nat) : ¬ a = a → false := by finish\nexample (A : Type) (p : Prop) (a b c : A) : a = b → b ≠ a → p := by finish\nexample (p q r s : Prop) : r ∧ s → p ∧ q → q ∧ p := by finish\nexample (p q : Prop) : p ∧ p ∧ q ∧ q → q ∧ p := by finish\nexample (p : nat → Prop) (q : nat → nat → Prop) :\n  (∃ x y, p x ∧ q x y) → q 0 0 ∧ q 1 1 → (∃ x, p x) := by finish\nexample (p q r s : Prop) (a b : nat) : r ∨ s → p ∨ q → a = b → q ∨ p := by finish\nexample (p q r : Prop) (a b : nat) : true → a = a → q → q → p → p := by finish\nexample (a b : Prop) : a → b → a := by finish\nexample (p q : nat → Prop) (a b : nat) : p a → q b → ∃ x, p x := by finish\n\nexample : ∀ b1 b2, b1 && b2 = ff ↔ (b1 = ff ∨ b2 = ff) := by finish\nexample : ∀ b1 b2, b1 && b2 = tt ↔ (b1 = tt ∧ b2 = tt) := by finish\nexample : ∀ b1 b2, b1 || b2 = ff ↔ (b1 = ff ∧ b2 = ff) := by finish\nexample : ∀ b1 b2, b1 || b2 = tt ↔ (b1 = tt ∨ b2 = tt) := by finish\nexample : ∀ b, bnot b = tt ↔ b = ff := by finish\nexample : ∀ b, bnot b = ff ↔ b = tt := by finish\nexample : ∀ b c, b = c ↔ ¬ (b = bnot c) := by intros b c; cases b; cases c; finish [iff_def]\n\ninductive and3 (a b c : Prop) : Prop\n| mk : a → b → c → and3\n\nexample (h : and3 a b c) : and3 b c a := by cases h; split; finish\n\ninductive or3 (a b c : Prop) : Prop\n| in1 : a → or3\n| in2 : b → or3\n| in3 : c → or3\n\n/- TODO(Jeremy): write a tactic that tries all constructors\nexample (h : a) : or3 a b c := sorry\nexample (h : b) : or3 a b c := sorry\nexample (h : c) : or3 a b c := sorry\n-/\n\nvariables (A₁ A₂ A₃ A₄ B₁ B₂ B₃ B₄ : Prop)\n-- H first, all pos\n\nexample (H1 : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄)\n  (a1 : A₁) (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃) : B₄ := by finish\nexample (H1 : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄)\n  (a1 : A₁) (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₄) : B₃ := by finish\nexample (H1 : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄)\n  (a1 : A₁) (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n3 : ¬B₃) (n3 : ¬B₄) : B₂ := by finish\nexample (H1 : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄)\n  (a1 : A₁) (a2 : A₂) (a3 : A₃) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄) : B₁ := by finish\n\nexample (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄)\n  (a1 : A₁) (a2 : A₂) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄) : ¬A₃ := by finish\nexample (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄)\n  (a1 : A₁) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄) : ¬A₂ := by finish\nexample (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄)\n  (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄) : ¬A₁ := by finish\n\n-- H last, all pos\nexample (a1 : A₁) (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃)\n  (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄) : B₄ := by finish\nexample (a1 : A₁) (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₄)\n  (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄) : B₃ := by finish\nexample (a1 : A₁) (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n3 : ¬B₃) (n3 : ¬B₄)\n  (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄) : B₂ := by finish\nexample (a1 : A₁) (a2 : A₂) (a3 : A₃) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄)\n  (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄) : B₁ := by finish\n\nexample (a1 : A₁) (a2 : A₂) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄)\n  (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄) : ¬A₃ := by finish\nexample (a1 : A₁) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄)\n  (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄) : ¬A₂ := by finish\nexample (a2 : A₂) (a3 : A₃) (n1 : ¬B₁) (n2 : ¬B₂) (n3 : ¬B₃) (n3 : ¬B₄)\n  (H : A₁ → A₂ → A₃ → B₁ ∨ B₂ ∨ B₃ ∨ B₄) : ¬A₁ := by finish\n\n-- H first, all neg\nexample (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄)\n  (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b3 : B₃) : ¬B₄ := by finish\nexample (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄)\n  (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b4 : B₄) : ¬B₃ := by finish\nexample (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄)\n  (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b3 : B₃) (b4 : B₄) : ¬B₂ := by finish\nexample (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄)\n  (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b2 : B₂) (b3 : B₃) (b4 : B₄) : ¬B₁ := by finish\n\nexample (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄)\n  (n1 : ¬A₁) (n2 : ¬A₂) (b1 : B₁) (b2 : B₂) (b3 : B₃) (b4 : B₄) : ¬¬A₃ := by finish\nexample (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄)\n  (n1 : ¬A₁) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b3 : B₃) (b4 : B₄) : ¬¬A₂ := by finish\nexample (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄)\n  (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b3 : B₃) (b4 : B₄) : ¬¬A₁ := by finish\n\n-- H last, all neg\nexample (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b3 : B₃)\n  (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄) : ¬B₄ := by finish\nexample (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b4 : B₄)\n  (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄) : ¬B₃ := by finish\nexample (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b3 : B₃) (b4 : B₄)\n  (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄) : ¬B₂ := by finish\nexample (n1 : ¬A₁) (n2 : ¬A₂) (n3 : ¬A₃) (b2 : B₂) (b3 : B₃) (b4 : B₄)\n  (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄) : ¬B₁ := by finish\n\nexample (n1 : ¬A₁) (n2 : ¬A₂) (b1 : B₁) (b2 : B₂) (b3 : B₃) (b4 : B₄)\n  (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄) : ¬¬A₃ := by finish\nexample (n1 : ¬A₁) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b3 : B₃) (b4 : B₄)\n  (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄) : ¬¬A₂ := by finish\nexample (n2 : ¬A₂) (n3 : ¬A₃) (b1 : B₁) (b2 : B₂) (b3 : B₃) (b4 : B₄)\n  (H : ¬A₁ → ¬A₂ → ¬A₃ → ¬B₁ ∨ ¬B₂ ∨ ¬B₃ ∨ ¬B₄) : ¬¬A₁ := by finish\n\nsection club\nvariables Scottish RedSocks WearKilt Married GoOutSunday : Prop\ntheorem NoMember : (¬Scottish → RedSocks) → (WearKilt ∨ ¬RedSocks) → (Married → ¬GoOutSunday) →\n                 (GoOutSunday ↔ Scottish) → (WearKilt → Scottish ∧ Married) →\n                 (Scottish → WearKilt) → false := by finish\nend club\n\nend\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/tests/finish2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.47965319333641615}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module category_theory.category.Bipointed\n! leanprover-community/mathlib commit c8ab806ef73c20cab1d87b5157e43a82c205f28e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Category.Pointed\n\n/-!\n# The category of bipointed types\n\nThis defines `Bipointed`, the category of bipointed types.\n\n## TODO\n\nMonoidal structure\n-/\n\n\nopen CategoryTheory\n\nuniverse u\n\nvariable {α β : Type _}\n\nset_option linter.uppercaseLean3 false\n\n/-- The category of bipointed types. -/\nstructure Bipointed : Type (u + 1) where\n  X : Type u\n  toProd : X × X\n#align Bipointed Bipointed\n\nnamespace Bipointed\n\ninstance : CoeSort Bipointed (Type _) :=\n  ⟨X⟩\n\n-- porting note: protected attribute does not work\n-- attribute [protected] Bipointed.X\n\n/-- Turns a bipointing into a bipointed type. -/\ndef of {X : Type _} (to_prod : X × X) : Bipointed :=\n  ⟨X, to_prod⟩\n#align Bipointed.of Bipointed.of\n\n@[simp]\ntheorem coe_of {X : Type _} (to_prod : X × X) : ↥(of to_prod) = X :=\n  rfl\n#align Bipointed.coe_of Bipointed.coe_of\n\nalias of ← _root_.Prod.Bipointed\n#align prod.Bipointed Prod.Bipointed\n\ninstance : Inhabited Bipointed :=\n  ⟨of ((), ())⟩\n\n/-- Morphisms in `Bipointed`. -/\n@[ext]\nprotected structure Hom (X Y : Bipointed.{u}) : Type u where\n  toFun : X → Y\n  map_fst : toFun X.toProd.1 = Y.toProd.1\n  map_snd : toFun X.toProd.2 = Y.toProd.2\n#align Bipointed.hom Bipointed.Hom\n\nnamespace Hom\n\n/-- The identity morphism of `X : Bipointed`. -/\n@[simps]\nnonrec def id (X : Bipointed) : Bipointed.Hom X X :=\n  ⟨id, rfl, rfl⟩\n#align Bipointed.hom.id Bipointed.Hom.id\n\ninstance (X : Bipointed) : Inhabited (Bipointed.Hom X X) :=\n  ⟨id X⟩\n\n/-- Composition of morphisms of `Bipointed`. -/\n@[simps]\ndef comp {X Y Z : Bipointed.{u}} (f : Bipointed.Hom X Y) (g : Bipointed.Hom Y Z) :\n    Bipointed.Hom X Z :=\n  ⟨g.toFun ∘ f.toFun, by rw [Function.comp_apply, f.map_fst, g.map_fst], by\n    rw [Function.comp_apply, f.map_snd, g.map_snd]⟩\n#align Bipointed.hom.comp Bipointed.Hom.comp\n\nend Hom\n\ninstance largeCategory : LargeCategory Bipointed where\n  Hom := Bipointed.Hom\n  id := Hom.id\n  comp := @Hom.comp\n#align Bipointed.large_category Bipointed.largeCategory\n\ninstance concreteCategory : ConcreteCategory Bipointed where\n  Forget :=\n    { obj := Bipointed.X\n      map := @Hom.toFun }\n  forget_faithful := ⟨@Hom.ext⟩\n#align Bipointed.concrete_category Bipointed.concreteCategory\n\n/-- Swaps the pointed elements of a bipointed type. `Prod.swap` as a functor. -/\n@[simps]\ndef swap : Bipointed ⥤ Bipointed where\n  obj X := ⟨X, X.toProd.swap⟩\n  map f := ⟨f.toFun, f.map_snd, f.map_fst⟩\n#align Bipointed.swap Bipointed.swap\n\n/-- The equivalence between `Bipointed` and itself induced by `Prod.swap` both ways. -/\n@[simps!]\ndef swapEquiv : Bipointed ≌ Bipointed :=\n  CategoryTheory.Equivalence.mk swap swap\n    (NatIso.ofComponents\n      (fun X =>\n        { hom := ⟨id, rfl, rfl⟩\n          inv := ⟨id, rfl, rfl⟩ })\n      fun f => rfl)\n    (NatIso.ofComponents\n      (fun X =>\n        { hom := ⟨id, rfl, rfl⟩\n          inv := ⟨id, rfl, rfl⟩ })\n      fun f => rfl)\n#align Bipointed.swap_equiv Bipointed.swapEquiv\n\n@[simp]\ntheorem swapEquiv_symm : swapEquiv.symm = swapEquiv :=\n  rfl\n#align Bipointed.swap_equiv_symm Bipointed.swapEquiv_symm\n\nend Bipointed\n\n/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the second point. -/\ndef bipointedToPointedFst : Bipointed ⥤ Pointed where\n  obj X := ⟨X, X.toProd.1⟩\n  map f := ⟨f.toFun, f.map_fst⟩\n#align Bipointed_to_Pointed_fst bipointedToPointedFst\n\n/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the first point. -/\ndef bipointedToPointedSnd : Bipointed ⥤ Pointed where\n  obj X := ⟨X, X.toProd.2⟩\n  map f := ⟨f.toFun, f.map_snd⟩\n#align Bipointed_to_Pointed_snd bipointedToPointedSnd\n\n@[simp]\ntheorem bipointedToPointedFst_comp_forget :\n    bipointedToPointedFst ⋙ forget Pointed = forget Bipointed :=\n  rfl\n#align Bipointed_to_Pointed_fst_comp_forget bipointedToPointedFst_comp_forget\n\n@[simp]\ntheorem bipointedToPointedSnd_comp_forget :\n    bipointedToPointedSnd ⋙ forget Pointed = forget Bipointed :=\n  rfl\n#align Bipointed_to_Pointed_snd_comp_forget bipointedToPointedSnd_comp_forget\n\n@[simp]\ntheorem swap_comp_bipointedToPointedFst :\n    Bipointed.swap ⋙ bipointedToPointedFst = bipointedToPointedSnd :=\n  rfl\n#align swap_comp_Bipointed_to_Pointed_fst swap_comp_bipointedToPointedFst\n\n@[simp]\ntheorem swap_comp_bipointedToPointedSnd :\n    Bipointed.swap ⋙ bipointedToPointedSnd = bipointedToPointedFst :=\n  rfl\n#align swap_comp_Bipointed_to_Pointed_snd swap_comp_bipointedToPointedSnd\n\n/-- The functor from `Pointed` to `Bipointed` which bipoints the point. -/\ndef pointedToBipointed : Pointed.{u} ⥤ Bipointed where\n  obj X := ⟨X, X.point, X.point⟩\n  map f := ⟨f.toFun, f.map_point, f.map_point⟩\n#align Pointed_to_Bipointed pointedToBipointed\n\n/-- The functor from `Pointed` to `Bipointed` which adds a second point. -/\ndef pointedToBipointedFst : Pointed.{u} ⥤ Bipointed where\n  obj X := ⟨Option X, X.point, none⟩\n  map f := ⟨Option.map f.toFun, congr_arg _ f.map_point, rfl⟩\n  map_id _ := Bipointed.Hom.ext _ _ Option.map_id\n  map_comp f g := Bipointed.Hom.ext _ _ (Option.map_comp_map f.1 g.1).symm\n#align Pointed_to_Bipointed_fst pointedToBipointedFst\n\n/-- The functor from `Pointed` to `Bipointed` which adds a first point. -/\ndef pointedToBipointedSnd : Pointed.{u} ⥤ Bipointed where\n  obj X := ⟨Option X, none, X.point⟩\n  map f := ⟨Option.map f.toFun, rfl, congr_arg _ f.map_point⟩\n  map_id _ := Bipointed.Hom.ext _ _ Option.map_id\n  map_comp f g := Bipointed.Hom.ext _ _ (Option.map_comp_map f.1 g.1).symm\n#align Pointed_to_Bipointed_snd pointedToBipointedSnd\n\n@[simp]\ntheorem pointedToBipointedFst_comp_swap :\n    pointedToBipointedFst ⋙ Bipointed.swap = pointedToBipointedSnd :=\n  rfl\n#align Pointed_to_Bipointed_fst_comp_swap pointedToBipointedFst_comp_swap\n\n@[simp]\ntheorem pointedToBipointedSnd_comp_swap :\n    pointedToBipointedSnd ⋙ Bipointed.swap = pointedToBipointedFst :=\n  rfl\n#align Pointed_to_Bipointed_snd_comp_swap pointedToBipointedSnd_comp_swap\n\n/-- `BipointedToPointed_fst` is inverse to `PointedToBipointed`. -/\n@[simps!]\ndef pointedToBipointedCompBipointedToPointedFst :\n    pointedToBipointed ⋙ bipointedToPointedFst ≅ 𝟭 _ :=\n  NatIso.ofComponents\n    (fun X =>\n      { hom := ⟨id, rfl⟩\n        inv := ⟨id, rfl⟩ })\n    fun f => rfl\n#align Pointed_to_Bipointed_comp_Bipointed_to_Pointed_fst pointedToBipointedCompBipointedToPointedFst\n\n/-- `BipointedToPointed_snd` is inverse to `PointedToBipointed`. -/\n@[simps!]\ndef pointedToBipointedCompBipointedToPointedSnd :\n    pointedToBipointed ⋙ bipointedToPointedSnd ≅ 𝟭 _ :=\n  NatIso.ofComponents\n    (fun X =>\n      { hom := ⟨id, rfl⟩\n        inv := ⟨id, rfl⟩ })\n    fun f => rfl\n#align Pointed_to_Bipointed_comp_Bipointed_to_Pointed_snd pointedToBipointedCompBipointedToPointedSnd\n\n/-- The free/forgetful adjunction between `PointedToBipointed_fst` and `BipointedToPointed_fst`.\n-/\ndef pointedToBipointedFstBipointedToPointedFstAdjunction :\n    pointedToBipointedFst ⊣ bipointedToPointedFst :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_fst⟩\n          invFun := fun f => ⟨fun o => o.elim Y.toProd.2 f.toFun, f.map_point, rfl⟩\n          left_inv := fun f => by\n            apply Bipointed.Hom.ext\n            funext x\n            cases x\n            · exact f.map_snd.symm\n            · rfl\n          right_inv := fun f => Pointed.Hom.ext _ _ rfl }\n      homEquiv_naturality_left_symm := fun f g => by\n        apply Bipointed.Hom.ext\n        funext x\n        cases x <;> rfl }\n#align Pointed_to_Bipointed_fst_Bipointed_to_Pointed_fst_adjunction pointedToBipointedFstBipointedToPointedFstAdjunction\n\n/-- The free/forgetful adjunction between `PointedToBipointed_snd` and `BipointedToPointed_snd`.\n-/\ndef pointedToBipointedSndBipointedToPointedSndAdjunction :\n    pointedToBipointedSnd ⊣ bipointedToPointedSnd :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_snd⟩\n          invFun := fun f => ⟨fun o => o.elim Y.toProd.1 f.toFun, rfl, f.map_point⟩\n          left_inv := fun f => by\n            apply Bipointed.Hom.ext\n            funext x\n            cases x\n            · exact f.map_fst.symm\n            · rfl\n          right_inv := fun f => Pointed.Hom.ext _ _ rfl }\n      homEquiv_naturality_left_symm := fun f g => by\n        apply Bipointed.Hom.ext\n        funext x\n        cases x <;> rfl }\n#align Pointed_to_Bipointed_snd_Bipointed_to_Pointed_snd_adjunction pointedToBipointedSndBipointedToPointedSndAdjunction\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Category/Bipointed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4796531890373246}}
{"text": "/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n\n! This file was ported from Lean 3 source module data.fintype.fin\n! leanprover-community/mathlib commit 759575657f189ccb424b990164c8b1fa9f55cdfe\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Fin.Interval\n\n/-!\n# The structure of `fintype (fin n)`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains some basic results about the `fintype` instance for `fin`,\nespecially properties of `finset.univ : finset (fin n)`.\n-/\n\n\nopen Finset\n\nopen Fintype\n\nnamespace Fin\n\nvariable {α β : Type _} {n : ℕ}\n\n#print Fin.map_valEmbedding_univ /-\n-- TODO: replace `subtype` with `coe` in the name of this lemma and `fin.map_subtype_embedding_Iio`\ntheorem map_valEmbedding_univ : (Finset.univ : Finset (Fin n)).map Fin.valEmbedding = Iio n :=\n  by\n  ext\n  simp [order_iso_subtype.symm.surjective.exists, OrderIso.symm]\n#align fin.map_subtype_embedding_univ Fin.map_valEmbedding_univ\n-/\n\n/- warning: fin.Ioi_zero_eq_map -> Fin.Ioi_zero_eq_map is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat}, Eq.{1} (Finset.{0} (Fin (Nat.succ n))) (Finset.Ioi.{0} (Fin (Nat.succ n)) (PartialOrder.toPreorder.{0} (Fin (Nat.succ n)) (Fin.partialOrder (Nat.succ n))) (Fin.locallyFiniteOrderTop (Nat.succ n)) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (OfNat.mk.{0} (Fin (Nat.succ n)) 0 (Zero.zero.{0} (Fin (Nat.succ n)) (Fin.hasZeroOfNeZero (Nat.succ n) (NeZero.succ n)))))) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (Fin.succEmbedding n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))\nbut is expected to have type\n  forall {n : Nat}, Eq.{1} (Finset.{0} (Fin (Nat.succ n))) (Finset.Ioi.{0} (Fin (Nat.succ n)) (PartialOrder.toPreorder.{0} (Fin (Nat.succ n)) (Fin.instPartialOrderFin (Nat.succ n))) (instForAllNatLocallyFiniteOrderTopFinToPreorderInstPartialOrderFin (Nat.succ n)) (OfNat.ofNat.{0} (Fin (Nat.succ n)) 0 (Fin.instOfNatFin (Nat.succ n) 0 (NeZero.succ n)))) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succEmbedding n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))\nCase conversion may be inaccurate. Consider using '#align fin.Ioi_zero_eq_map Fin.Ioi_zero_eq_mapₓ'. -/\n@[simp]\ntheorem Ioi_zero_eq_map : Ioi (0 : Fin n.succ) = univ.map (Fin.succEmbedding _).toEmbedding :=\n  by\n  ext i\n  simp only [mem_Ioi, mem_map, mem_univ, Function.Embedding.coeFn_mk, exists_true_left]\n  constructor\n  · refine' cases _ _ i\n    · rintro ⟨⟨⟩⟩\n    · intro j _\n      exact ⟨j, rfl⟩\n  · rintro ⟨i, _, rfl⟩\n    exact succ_pos _\n#align fin.Ioi_zero_eq_map Fin.Ioi_zero_eq_map\n\n/- warning: fin.Iio_last_eq_map -> Fin.Iio_last_eq_map is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat}, Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.Iio.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Fin.locallyFiniteOrderBot (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.last n)) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Fin.castSucc n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))\nbut is expected to have type\n  forall {n : Nat}, Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Finset.Iio.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Fin.instPartialOrderFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (instLocallyFiniteOrderBotFinToPreorderInstPartialOrderFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Fin.last n)) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.castSucc n)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))\nCase conversion may be inaccurate. Consider using '#align fin.Iio_last_eq_map Fin.Iio_last_eq_mapₓ'. -/\n@[simp]\ntheorem Iio_last_eq_map : Iio (Fin.last n) = Finset.univ.map Fin.castSucc.toEmbedding :=\n  by\n  apply Finset.map_injective Fin.valEmbedding\n  rw [Finset.map_map, Fin.map_valEmbedding_Iio, Fin.val_last]\n  exact map_subtype_embedding_univ.symm\n#align fin.Iio_last_eq_map Fin.Iio_last_eq_map\n\n/- warning: fin.Ioi_succ -> Fin.Ioi_succ is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} (i : Fin n), Eq.{1} (Finset.{0} (Fin (Nat.succ n))) (Finset.Ioi.{0} (Fin (Nat.succ n)) (PartialOrder.toPreorder.{0} (Fin (Nat.succ n)) (Fin.partialOrder (Nat.succ n))) (Fin.locallyFiniteOrderTop (Nat.succ n)) (Fin.succ n i)) (Finset.map.{0, 0} (Fin n) (Fin (Nat.succ n)) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Preorder.toLE.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (Fin.succEmbedding n)) (Finset.Ioi.{0} (Fin n) (PartialOrder.toPreorder.{0} (Fin n) (Fin.partialOrder n)) (Fin.locallyFiniteOrderTop n) i))\nbut is expected to have type\n  forall {n : Nat} (i : Fin n), Eq.{1} (Finset.{0} (Fin (Nat.succ n))) (Finset.Ioi.{0} (Fin (Nat.succ n)) (PartialOrder.toPreorder.{0} (Fin (Nat.succ n)) (Fin.instPartialOrderFin (Nat.succ n))) (instForAllNatLocallyFiniteOrderTopFinToPreorderInstPartialOrderFin (Nat.succ n)) (Fin.succ n i)) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.succEmbedding n)) (Finset.Ioi.{0} (Fin n) (PartialOrder.toPreorder.{0} (Fin n) (Fin.instPartialOrderFin n)) (instForAllNatLocallyFiniteOrderTopFinToPreorderInstPartialOrderFin n) i))\nCase conversion may be inaccurate. Consider using '#align fin.Ioi_succ Fin.Ioi_succₓ'. -/\n@[simp]\ntheorem Ioi_succ (i : Fin n) : Ioi i.succ = (Ioi i).map (Fin.succEmbedding _).toEmbedding :=\n  by\n  ext i\n  simp only [mem_filter, mem_Ioi, mem_map, mem_univ, true_and_iff, Function.Embedding.coeFn_mk,\n    exists_true_left]\n  constructor\n  · refine' cases _ _ i\n    · rintro ⟨⟨⟩⟩\n    · intro i hi\n      refine' ⟨i, succ_lt_succ_iff.mp hi, rfl⟩\n  · rintro ⟨i, hi, rfl⟩\n    simpa\n#align fin.Ioi_succ Fin.Ioi_succ\n\n/- warning: fin.Iio_cast_succ -> Fin.Iio_castSucc is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} (i : Fin n), Eq.{1} (Finset.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Finset.Iio.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (PartialOrder.toPreorder.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.partialOrder (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Fin.locallyFiniteOrderBot (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (coeFn.{1, 1} (OrderEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe n) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (fun (_x : RelEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))) => (Fin n) -> (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (RelEmbedding.hasCoeToFun.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))))) (Fin.castSucc n) i)) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.hasLe (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))) (Fin.castSucc n)) (Finset.Iio.{0} (Fin n) (PartialOrder.toPreorder.{0} (Fin n) (Fin.partialOrder n)) (Fin.locallyFiniteOrderBot n) i))\nbut is expected to have type\n  forall {n : Nat} (i : Fin n), Eq.{1} (Finset.{0} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) i)) (Finset.Iio.{0} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) i) (PartialOrder.toPreorder.{0} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) i) (Fin.instPartialOrderFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (instLocallyFiniteOrderBotFinToPreorderInstPartialOrderFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.castSucc n)) i)) (Finset.map.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.680 x._@.Mathlib.Order.Hom.Basic._hyg.682) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.695 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => LE.le.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (instLEFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Fin.castSucc n)) (Finset.Iio.{0} (Fin n) (PartialOrder.toPreorder.{0} (Fin n) (Fin.instPartialOrderFin n)) (instLocallyFiniteOrderBotFinToPreorderInstPartialOrderFin n) i))\nCase conversion may be inaccurate. Consider using '#align fin.Iio_cast_succ Fin.Iio_castSuccₓ'. -/\n@[simp]\ntheorem Iio_castSucc (i : Fin n) : Iio (castSucc i) = (Iio i).map Fin.castSucc.toEmbedding :=\n  by\n  apply Finset.map_injective Fin.valEmbedding\n  rw [Finset.map_map, Fin.map_valEmbedding_Iio]\n  exact (Fin.map_valEmbedding_Iio i).symm\n#align fin.Iio_cast_succ Fin.Iio_castSucc\n\n/- warning: fin.card_filter_univ_succ' -> Fin.card_filter_univ_succ' is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} (p : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Prop) [_inst_1 : DecidablePred.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) p], Eq.{1} Nat (Finset.card.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.filter.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) p (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => _inst_1 a) (Finset.univ.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (ite.{1} Nat (p (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))) (_inst_1 (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) (Finset.card.{0} (Fin n) (Finset.filter.{0} (Fin n) (Function.comp.{1, 1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) Prop p (Fin.succ n)) (fun (a : Fin n) => _inst_1 (Fin.succ n a)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))))\nbut is expected to have type\n  forall {n : Nat} (p : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Prop) [_inst_1 : DecidablePred.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) p], Eq.{1} Nat (Finset.card.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Finset.filter.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) p (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => _inst_1 a) (Finset.univ.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (ite.{1} Nat (p (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) 0 (Fin.instOfNatFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) 0 (NeZero.succ n)))) (_inst_1 (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) 0 (Fin.instOfNatFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) 0 (NeZero.succ n)))) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (Finset.card.{0} (Fin n) (Finset.filter.{0} (Fin n) (Function.comp.{1, 1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) Prop p (Fin.succ n)) (fun (a : Fin n) => instDecidablePredCompProp.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) p (Fin.succ n) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => _inst_1 a) a) (Finset.univ.{0} (Fin n) (Fin.fintype n)))))\nCase conversion may be inaccurate. Consider using '#align fin.card_filter_univ_succ' Fin.card_filter_univ_succ'ₓ'. -/\ntheorem card_filter_univ_succ' (p : Fin (n + 1) → Prop) [DecidablePred p] :\n    (univ.filterₓ p).card = ite (p 0) 1 0 + (univ.filterₓ (p ∘ Fin.succ)).card :=\n  by\n  rw [Fin.univ_succ, filter_cons, card_disj_union, filter_map, card_map]\n  split_ifs <;> simp\n#align fin.card_filter_univ_succ' Fin.card_filter_univ_succ'\n\n/- warning: fin.card_filter_univ_succ -> Fin.card_filter_univ_succ is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} (p : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Prop) [_inst_1 : DecidablePred.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) p], Eq.{1} Nat (Finset.card.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Finset.filter.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) p (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => _inst_1 a) (Finset.univ.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) (ite.{1} Nat (p (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))) (_inst_1 (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (OfNat.mk.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) 0 (Zero.zero.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne))) (Fin.hasZeroOfNeZero (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (One.one.{0} Nat Nat.hasOne)) (NeZero.succ n)))))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{0} (Fin n) (Finset.filter.{0} (Fin n) (Function.comp.{1, 1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) Prop p (Fin.succ n)) (fun (a : Fin n) => _inst_1 (Fin.succ n a)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (Finset.card.{0} (Fin n) (Finset.filter.{0} (Fin n) (Function.comp.{1, 1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) Prop p (Fin.succ n)) (fun (a : Fin n) => _inst_1 (Fin.succ n a)) (Finset.univ.{0} (Fin n) (Fin.fintype n)))))\nbut is expected to have type\n  forall {n : Nat} (p : (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Prop) [_inst_1 : DecidablePred.{1} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) p], Eq.{1} Nat (Finset.card.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Finset.filter.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) p (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => _inst_1 a) (Finset.univ.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (Fin.fintype (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))))) (ite.{1} Nat (p (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) 0 (Fin.instOfNatFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) 0 (NeZero.succ n)))) (_inst_1 (OfNat.ofNat.{0} (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) 0 (Fin.instOfNatFin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) 0 (NeZero.succ n)))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{0} (Fin n) (Finset.filter.{0} (Fin n) (Function.comp.{1, 1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) Prop p (Fin.succ n)) (fun (a : Fin n) => instDecidablePredCompProp.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) p (Fin.succ n) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => _inst_1 a) a) (Finset.univ.{0} (Fin n) (Fin.fintype n)))) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Finset.card.{0} (Fin n) (Finset.filter.{0} (Fin n) (Function.comp.{1, 1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) Prop p (Fin.succ n)) (fun (a : Fin n) => instDecidablePredCompProp.{1, 1} (Fin n) (Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) p (Fin.succ n) (fun (a : Fin (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => _inst_1 a) a) (Finset.univ.{0} (Fin n) (Fin.fintype n)))))\nCase conversion may be inaccurate. Consider using '#align fin.card_filter_univ_succ Fin.card_filter_univ_succₓ'. -/\ntheorem card_filter_univ_succ (p : Fin (n + 1) → Prop) [DecidablePred p] :\n    (univ.filterₓ p).card =\n      if p 0 then (univ.filterₓ (p ∘ Fin.succ)).card + 1 else (univ.filterₓ (p ∘ Fin.succ)).card :=\n  (card_filter_univ_succ' p).trans (by split_ifs <;> simp [add_comm 1])\n#align fin.card_filter_univ_succ Fin.card_filter_univ_succ\n\n#print Fin.card_filter_univ_eq_vector_get_eq_count /-\ntheorem card_filter_univ_eq_vector_get_eq_count [DecidableEq α] (a : α) (v : Vector α n) :\n    (univ.filterₓ fun i => a = v.get? i).card = v.toList.count a :=\n  by\n  induction' v using Vector.inductionOn with n x xs hxs\n  · simp\n  ·\n    simp_rw [card_filter_univ_succ', Vector.get_cons_zero, Vector.toList_cons, Function.comp,\n      Vector.get_cons_succ, hxs, List.count_cons', add_comm (ite (a = x) 1 0)]\n#align fin.card_filter_univ_eq_vector_nth_eq_count Fin.card_filter_univ_eq_vector_get_eq_count\n-/\n\nend Fin\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Fintype/Fin.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.47965318473823304}}
{"text": "import defs.var\nimport util.option\nimport util.set\n\ntheorem lookup_uniq {t: Type} [decidable_eq t] {Γ: cx t} {x: var} {v v': t}:\n  cx.lookup Γ x v ->\n  cx.lookup Γ x v' ->\n  v = v' :=\nbegin\n  simp [cx.lookup],\n  intros la lb,\n  by_cases v = v',\n  exact h,\n  let a := cx_elem.mk x v,\n  let b := cx_elem.mk x v',\n  let a_ne_b: cx_elem.mk x v ≠ cx_elem.mk x v' := begin\n    intro h1,\n    simp at h1,\n    exact h h1,\n  end,\n  let hm := Γ.nodupkeys a b la lb a_ne_b,\n  simp [ne_var] at hm,\n  exfalso,\n  exact hm,\nend\n\ntheorem lookup_insert {t: Type} (Γ: cx t) (x: var) (v: t):\n  cx.lookup (cx.insert Γ x v) x v :=\nbegin\n  simp [cx.insert],\n  simp [cx.lookup],\n  left,\n  exact iff.elim_right mem_singleton_iff rfl,\nend\n\ntheorem useless_insert_ne {t: Type} {Γ: cx t} {x y: var} {vy v: t}:\n  x ≠ y ->\n  (cx.lookup (cx.insert Γ y vy) x v ↔ cx.lookup Γ x v) :=\nbegin\n  intro h_ne,\n  simp [cx.insert],\n  simp [cx.lookup],\n  split,\n  intro h,\n  cases h,\n  cases iff.elim_left mem_singleton_iff h,\n  exfalso,\n  exact h_ne rfl,\n  exact mem_pred h,\n  intro h,\n  right,\n  split,\n  exact h,\n  simp,\n  exact h_ne,\nend\n\ntheorem entries_same {t: Type} {Γ Γ': cx t}:\n  Γ.entries = Γ'.entries -> Γ = Γ' :=\nbegin\n  cases Γ,\n  cases Γ',\n  simp,\n  intro h,\n  exact h,\nend\n\ntheorem useless_insert_twice {t: Type}\n  (Γ: cx t) (x: var) (v v': t):\n  cx.insert (cx.insert Γ x v') x v = cx.insert Γ x v :=\nbegin\n  simp [cx.insert],\n  rw pred_distr_union,\n  let hm: (cx_elem.mk x v').x = x := by simp,\n  let hm': ¬ ¬ (cx_elem.mk x v').x = x := fun f, f hm,\n  rw @singleton_not_pred (cx_elem t) (cx_elem.mk x v') (fun e, e.x ≠ x) hm',\n  rw union_emp,\n  rw double_pred,\nend\n\ntheorem insert_comm' {t: Type}\n  {Γ: cx t} {x y: var} {vx vy: t} {a: cx_elem t}:\n  x ≠ y ->\n  a ∈ (cx.insert (cx.insert Γ y vy) x vx).entries ->\n  a ∈ (cx.insert (cx.insert Γ x vx) y vy).entries :=\nbegin\n  intro h_ne,\n  simp [cx.insert],\n  intro h,\n  cases h,\n  right,\n  split,\n  left,\n  exact h,\n  rw iff.elim_left mem_singleton_iff h,\n  simp,\n  exact h_ne,\n  cases h,\n  cases h_left,\n  left,\n  exact h_left,\n  right,\n  split,\n  right,\n  split,\n  exact mem_pred h_left,\n  simp,\n  exact h_right,\n  simp,\n  cases h_left,\n  exact h_left_right,\nend\n\ntheorem insert_comm {t: Type}\n  (Γ: cx t) (x y: var) (vx vy: t) (h: x ≠ y):\n  cx.insert (cx.insert Γ y vy) x vx =\n  cx.insert (cx.insert Γ x vx) y vy :=\nentries_same (set_ext begin\n  intro a,\n  split,\n  exact insert_comm' h,\n  let h' := fun x, h (symm x),\n  exact insert_comm' h',\nend)\n", "meta": {"author": "azdavis", "repo": "hatsugen", "sha": "a18f70f9ea4ce30c0baf0c40748aad5ccd176c60", "save_path": "github-repos/lean/azdavis-hatsugen", "path": "github-repos/lean/azdavis-hatsugen/hatsugen-a18f70f9ea4ce30c0baf0c40748aad5ccd176c60/src/lemmas/cx.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.47965318435784965}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n\nimport measure_theory.measure_space\n\n/-!\n# Sequence of measurable functions associated to a sequence of a.e.-measurable functions\n\nWe define here tools to prove statements about limits (infi, supr...) of sequences of\n`ae_measurable` functions.\nGiven a sequence of a.e.-measurable functions `f : ι → α → β` with hypothesis\n`hf : ∀ i, ae_measurable (f i) μ`, and a pointwise property `p : α → (ι → β) → Prop` such that we\nhave `hp : ∀ᵐ x ∂μ, p x (λ n, f n x)`, we define a sequence of measurable functions `ae_seq hf p`\nand a measurable set `ae_seq_set hf p`, such that\n* `μ (ae_seq_set hf p)ᶜ = 0`\n* `x ∈ ae_seq_set hf p → ∀ i : ι, ae_seq hf hp i x = f i x`\n* `x ∈ ae_seq_set hf p → p x (λ n, f n x)`\n-/\n\nopen measure_theory\nopen_locale classical\n\nvariables {α β γ ι : Type*} [measurable_space α] [measurable_space β]\n  {f : ι → α → β} {μ : measure α} {p : α → (ι → β) → Prop}\n\n/-- If we have the additional hypothesis `∀ᵐ x ∂μ, p x (λ n, f n x)`, this is a measurable set\nwhose complement has measure 0 such that for all `x ∈ ae_seq_set`, `f i x` is equal to\n`(hf i).mk (f i) x` for all `i` and we have the pointwise property `p x (λ n, f n x)`. -/\ndef ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) (p : α → (ι → β) → Prop) : set α :=\n(to_measurable μ {x | (∀ i, f i x = (hf i).mk (f i) x) ∧ p x (λ n, f n x)}ᶜ)ᶜ\n\n/-- A sequence of measurable functions that are equal to `f` and verify property `p` on the\nmeasurable set `ae_seq_set hf p`. -/\nnoncomputable\ndef ae_seq (hf : ∀ i, ae_measurable (f i) μ) (p : α → (ι → β) → Prop) : ι → α → β :=\nλ i x, ite (x ∈ ae_seq_set hf p) ((hf i).mk (f i) x) (⟨f i x⟩ : nonempty β).some\n\nnamespace ae_seq\n\nsection mem_ae_seq_set\n\nlemma mk_eq_fun_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) {x : α}\n  (hx : x ∈ ae_seq_set hf p) (i : ι) :\n  (hf i).mk (f i) x = f i x :=\nbegin\n  have h_ss : ae_seq_set hf p ⊆ {x | ∀ i, f i x = (hf i).mk (f i) x},\n  { rw [ae_seq_set, ←compl_compl {x | ∀ i, f i x = (hf i).mk (f i) x}, set.compl_subset_compl],\n    refine set.subset.trans (set.compl_subset_compl.mpr (λ x h, _)) (subset_to_measurable _ _),\n    exact h.1, },\n  exact (h_ss hx i).symm,\nend\n\nlemma ae_seq_eq_mk_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) {x : α}\n  (hx : x ∈ ae_seq_set hf p) (i : ι) :\n  ae_seq hf p i x = (hf i).mk (f i) x :=\nby simp only [ae_seq, hx, if_true]\n\nlemma ae_seq_eq_fun_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) {x : α}\n  (hx : x ∈ ae_seq_set hf p) (i : ι) :\n  ae_seq hf p i x = f i x :=\nby simp only [ae_seq_eq_mk_of_mem_ae_seq_set hf hx i, mk_eq_fun_of_mem_ae_seq_set hf hx i]\n\nlemma prop_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ)\n  {x : α} (hx : x ∈ ae_seq_set hf p) :\n  p x (λ n, ae_seq hf p n x) :=\nbegin\n  simp only [ae_seq, hx, if_true],\n  rw funext (λ n, mk_eq_fun_of_mem_ae_seq_set hf hx n),\n  have h_ss : ae_seq_set hf p ⊆ {x | p x (λ n, f n x)},\n  { rw [←compl_compl {x | p x (λ n, f n x)}, ae_seq_set, set.compl_subset_compl],\n    refine set.subset.trans (set.compl_subset_compl.mpr _) (subset_to_measurable _ _),\n    exact λ x hx, hx.2, },\n  have hx' := set.mem_of_subset_of_mem h_ss hx,\n  exact hx',\nend\n\nlemma fun_prop_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ)\n  {x : α} (hx : x ∈ ae_seq_set hf p) :\n  p x (λ n, f n x) :=\nbegin\n  have h_eq : (λ n, f n x) = λ n, ae_seq hf p n x,\n    from funext (λ n, (ae_seq_eq_fun_of_mem_ae_seq_set hf hx n).symm),\n  rw h_eq,\n  exact prop_of_mem_ae_seq_set hf hx,\nend\n\nend mem_ae_seq_set\n\nlemma ae_seq_set_measurable_set {hf : ∀ i, ae_measurable (f i) μ} :\n  measurable_set (ae_seq_set hf p) :=\n(measurable_set_to_measurable _ _).compl\n\nlemma measurable (hf : ∀ i, ae_measurable (f i) μ) (p : α → (ι → β) → Prop)\n  (i : ι) :\n  measurable (ae_seq hf p i) :=\nbegin\n  refine measurable.ite ae_seq_set_measurable_set (hf i).measurable_mk _,\n  by_cases hα : nonempty α,\n  { exact @measurable_const _ _ _ _ (⟨f i hα.some⟩ : nonempty β).some },\n  { exact measurable_of_not_nonempty hα _ }\nend\n\nlemma measure_compl_ae_seq_set_eq_zero [encodable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  μ (ae_seq_set hf p)ᶜ = 0 :=\nbegin\n  rw [ae_seq_set, compl_compl, measure_to_measurable],\n  have hf_eq := λ i, (hf i).ae_eq_mk,\n  simp_rw [filter.eventually_eq, ←ae_all_iff] at hf_eq,\n  exact filter.eventually.and hf_eq hp,\nend\n\nlemma ae_seq_eq_mk_ae [encodable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  ∀ᵐ (a : α) ∂μ, ∀ (i : ι), ae_seq hf p i a = (hf i).mk (f i) a :=\nbegin\n  have h_ss : ae_seq_set hf p ⊆ {a : α | ∀ i, ae_seq hf p i a = (hf i).mk (f i) a},\n    from λ x hx i, by simp only [ae_seq, hx, if_true],\n  exact le_antisymm (le_trans (measure_mono (set.compl_subset_compl.mpr h_ss))\n    (le_of_eq (measure_compl_ae_seq_set_eq_zero hf hp))) (zero_le _),\nend\n\nlemma ae_seq_eq_fun_ae [encodable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  ∀ᵐ (a : α) ∂μ, ∀ (i : ι), ae_seq hf p i a = f i a :=\nbegin\n  have h_ss : {a : α | ¬∀ (i : ι), ae_seq hf p i a = f i a} ⊆ (ae_seq_set hf p)ᶜ,\n    from λ x, mt (λ hx i, (ae_seq_eq_fun_of_mem_ae_seq_set hf hx i)),\n  exact measure_mono_null h_ss (measure_compl_ae_seq_set_eq_zero hf hp),\nend\n\nlemma ae_seq_n_eq_fun_n_ae [encodable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) (n : ι) :\n  ae_seq hf p n =ᵐ[μ] f n:=\nae_all_iff.mp (ae_seq_eq_fun_ae hf hp) n\n\nlemma supr [complete_lattice β] [encodable ι]\n  (hf : ∀ i, ae_measurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  (⨆ n, ae_seq hf p n) =ᵐ[μ] ⨆ n, f n :=\nbegin\n  simp_rw [filter.eventually_eq, ae_iff, supr_apply],\n  have h_ss : ae_seq_set hf p ⊆ {a : α | (⨆ (i : ι), ae_seq hf p i a) = ⨆ (i : ι), f i a},\n  { intros x hx,\n    congr,\n    exact funext (λ i, ae_seq_eq_fun_of_mem_ae_seq_set hf hx i), },\n  exact measure_mono_null (set.compl_subset_compl.mpr h_ss)\n    (measure_compl_ae_seq_set_eq_zero hf hp),\nend\n\nend ae_seq\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/measure_theory/ae_measurable_sequence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6859494421679929, "lm_q1q2_score": 0.4796531800587582}}
{"text": "--\n\nset_option tactic.hygienic false in\ntheorem ex1 {a p q r : Prop} : p → (p → q) → (q → r) → r := by\nintro _ h1 h2;\napply h2;\napply h1;\nexact a_1 -- Bad practice, using name generated by `intro`.\n\ntheorem ex2 {a p q r : Prop} : p → (p → q) → (q → r) → r := by\nintro _ h1 h2;\napply h2;\napply h1;\nexact a_1 -- error \"unknown identifier\"\n\ntheorem ex3 {a p q r : Prop} : p → (p → q) → (q → r) → r := by\nintro _ h1 h2;\napply h2;\napply h1;\nassumption\n\nexample {p q : Prop} (h₁ : p → q) (h₂ : p ∨ q) : q := by\n  cases h₂;\n  { apply h₁; exact h }; -- error \"unknown identifier\"\n  exact h\n\nset_option tactic.hygienic false in\nexample {p q : Prop} (h₁ : p → q) (h₂ : p ∨ q) : q := by\ncases h₂;\n{ apply h₁; exact h }; -- hygiene is disabled\nexact h\n\n-- Hygienic versions\nexample {p q : Prop} (h₁ : p → q) (h₂ : p ∨ q) : q := by\ncases h₂ with\n| inl h => apply h₁; exact h\n| inr h => exact h\n\nexample {p q : Prop} (h₁ : p → q) (h₂ : p ∨ q) : q := by\ncases h₂;\n{ apply h₁; assumption };\nassumption\n\nexample {p q : Prop} (h₁ : p → q) (h₂ : p ∨ q) : q := by\nmatch h₂ with\n| Or.inl _ => apply h₁; assumption\n| Or.inr h => exact h\n\nexample {p q : Prop} (h₁ : p → q) (h₂ : p ∨ q) : q := by unhygienic\n  cases h₂\n  { apply h₁; exact h } -- hygiene is disabled\n  exact h\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/hygienicIntro.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.47952856906431196}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.set.intervals.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Projection of a line onto a closed interval\n\nGiven a linearly ordered type `α`, in this file we define\n\n* `set.proj_Icc (a b : α) (h : a ≤ b)` to be the map `α → [a, b]` sending `(-∞, a]` to `a`, `[b, ∞)`\n  to `b`, and each point `x ∈ [a, b]` to itself;\n* `set.Icc_extend {a b : α} (h : a ≤ b) (f : Icc a b → β)` to be the extension of `f` to `α` defined\n  as `f ∘ proj_Icc a b h`.\n\nWe also prove some trivial properties of these maps.\n-/\n\nnamespace set\n\n\n/-- Projection of `α` to the closed interval `[a, b]`. -/\ndef proj_Icc {α : Type u_1} [linear_order α] (a : α) (b : α) (h : a ≤ b) (x : α) : ↥(Icc a b) :=\n  { val := max a (min b x), property := sorry }\n\ntheorem proj_Icc_of_le_left {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α}\n    (hx : x ≤ a) : proj_Icc a b h x = { val := a, property := iff.mpr left_mem_Icc h } :=\n  sorry\n\n@[simp] theorem proj_Icc_left {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) :\n    proj_Icc a b h a = { val := a, property := iff.mpr left_mem_Icc h } :=\n  proj_Icc_of_le_left h le_rfl\n\ntheorem proj_Icc_of_right_le {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α}\n    (hx : b ≤ x) : proj_Icc a b h x = { val := b, property := iff.mpr right_mem_Icc h } :=\n  sorry\n\n@[simp] theorem proj_Icc_right {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) :\n    proj_Icc a b h b = { val := b, property := iff.mpr right_mem_Icc h } :=\n  proj_Icc_of_right_le h le_rfl\n\ntheorem proj_Icc_of_mem {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α}\n    (hx : x ∈ Icc a b) : proj_Icc a b h x = { val := x, property := hx } :=\n  sorry\n\n@[simp] theorem proj_Icc_coe {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b)\n    (x : ↥(Icc a b)) : proj_Icc a b h ↑x = x :=\n  subtype.cases_on x fun (x_val : α) (x_property : x_val ∈ Icc a b) => proj_Icc_of_mem h x_property\n\ntheorem proj_Icc_surj_on {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) :\n    surj_on (proj_Icc a b h) (Icc a b) univ :=\n  fun (x : ↥(Icc a b)) (_x : x ∈ univ) =>\n    Exists.intro ↑x { left := subtype.property x, right := proj_Icc_coe h x }\n\ntheorem proj_Icc_surjective {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) :\n    function.surjective (proj_Icc a b h) :=\n  fun (x : ↥(Icc a b)) => Exists.intro (↑x) (proj_Icc_coe h x)\n\n@[simp] theorem range_proj_Icc {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) :\n    range (proj_Icc a b h) = univ :=\n  function.surjective.range_eq (proj_Icc_surjective h)\n\ntheorem monotone_proj_Icc {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) :\n    monotone (proj_Icc a b h) :=\n  fun (x y : α) (hxy : x ≤ y) => max_le_max le_rfl (min_le_min le_rfl hxy)\n\ntheorem strict_mono_incr_on_proj_Icc {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) :\n    strict_mono_incr_on (proj_Icc a b h) (Icc a b) :=\n  sorry\n\n/-- Extend a function `[a, b] → β` to a map `α → β`. -/\ndef Icc_extend {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b)\n    (f : ↥(Icc a b) → β) : α → β :=\n  f ∘ proj_Icc a b h\n\n@[simp] theorem Icc_extend_range {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α}\n    (h : a ≤ b) (f : ↥(Icc a b) → β) : range (Icc_extend h f) = range f :=\n  sorry\n\ntheorem Icc_extend_of_le_left {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α}\n    (h : a ≤ b) {x : α} (f : ↥(Icc a b) → β) (hx : x ≤ a) :\n    Icc_extend h f x = f { val := a, property := iff.mpr left_mem_Icc h } :=\n  congr_arg f (proj_Icc_of_le_left h hx)\n\n@[simp] theorem Icc_extend_left {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α}\n    (h : a ≤ b) (f : ↥(Icc a b) → β) :\n    Icc_extend h f a = f { val := a, property := iff.mpr left_mem_Icc h } :=\n  Icc_extend_of_le_left h f le_rfl\n\ntheorem Icc_extend_of_right_le {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α}\n    (h : a ≤ b) {x : α} (f : ↥(Icc a b) → β) (hx : b ≤ x) :\n    Icc_extend h f x = f { val := b, property := iff.mpr right_mem_Icc h } :=\n  congr_arg f (proj_Icc_of_right_le h hx)\n\n@[simp] theorem Icc_extend_right {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α}\n    (h : a ≤ b) (f : ↥(Icc a b) → β) :\n    Icc_extend h f b = f { val := b, property := iff.mpr right_mem_Icc h } :=\n  Icc_extend_of_right_le h f le_rfl\n\ntheorem Icc_extend_of_mem {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b)\n    {x : α} (f : ↥(Icc a b) → β) (hx : x ∈ Icc a b) :\n    Icc_extend h f x = f { val := x, property := hx } :=\n  congr_arg f (proj_Icc_of_mem h hx)\n\n@[simp] theorem Icc_extend_coe {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α}\n    (h : a ≤ b) (f : ↥(Icc a b) → β) (x : ↥(Icc a b)) : Icc_extend h f ↑x = f x :=\n  congr_arg f (proj_Icc_coe h x)\n\nend set\n\n\ntheorem monotone.Icc_extend {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β] {a : α}\n    {b : α} (h : a ≤ b) {f : ↥(set.Icc a b) → β} (hf : monotone f) :\n    monotone (set.Icc_extend h f) :=\n  monotone.comp hf (set.monotone_proj_Icc h)\n\ntheorem strict_mono.strict_mono_incr_on_Icc_extend {α : Type u_1} {β : Type u_2} [linear_order α]\n    [preorder β] {a : α} {b : α} (h : a ≤ b) {f : ↥(set.Icc a b) → β} (hf : strict_mono f) :\n    strict_mono_incr_on (set.Icc_extend h f) (set.Icc a b) :=\n  strict_mono.comp_strict_mono_incr_on hf (set.strict_mono_incr_on_proj_Icc h)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/set/intervals/proj_Icc_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.47948362766984803}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.eq_to_hom\nimport Mathlib.PostPort\n\nuniverses u₁ v₁ \n\nnamespace Mathlib\n\n/-#\nDisjoint unions of categories, functors, and natural transformations.\n-/\n\nnamespace category_theory\n\n\n/--\n`sum C D` gives the direct sum of two categories.\n-/\nprotected instance sum (C : Type u₁) [category C] (D : Type u₁) [category D] : category (C ⊕ D) :=\n  category.mk\n\n@[simp] theorem sum_comp_inl (C : Type u₁) [category C] (D : Type u₁) [category D] {P : C} {Q : C}\n    {R : C} (f : sum.inl P ⟶ sum.inl Q) (g : sum.inl Q ⟶ sum.inl R) : f ≫ g = f ≫ g :=\n  rfl\n\n@[simp] theorem sum_comp_inr (C : Type u₁) [category C] (D : Type u₁) [category D] {P : D} {Q : D}\n    {R : D} (f : sum.inr P ⟶ sum.inr Q) (g : sum.inr Q ⟶ sum.inr R) : f ≫ g = f ≫ g :=\n  rfl\n\nnamespace sum\n\n\n/-- `inl_` is the functor `X ↦ inl X`. -/\n-- Unfortunate naming here, suggestions welcome.\n\ndef inl_ (C : Type u₁) [category C] (D : Type u₁) [category D] : C ⥤ C ⊕ D :=\n  functor.mk (fun (X : C) => sum.inl X) fun (X Y : C) (f : X ⟶ Y) => f\n\n/-- `inr_` is the functor `X ↦ inr X`. -/\ndef inr_ (C : Type u₁) [category C] (D : Type u₁) [category D] : D ⥤ C ⊕ D :=\n  functor.mk (fun (X : D) => sum.inr X) fun (X Y : D) (f : X ⟶ Y) => f\n\n/-- The functor exchanging two direct summand categories. -/\ndef swap (C : Type u₁) [category C] (D : Type u₁) [category D] : C ⊕ D ⥤ D ⊕ C :=\n  functor.mk (fun (X : C ⊕ D) => sorry) fun (X Y : C ⊕ D) (f : X ⟶ Y) => sorry\n\n@[simp] theorem swap_obj_inl (C : Type u₁) [category C] (D : Type u₁) [category D] (X : C) :\n    functor.obj (swap C D) (sum.inl X) = sum.inr X :=\n  rfl\n\n@[simp] theorem swap_obj_inr (C : Type u₁) [category C] (D : Type u₁) [category D] (X : D) :\n    functor.obj (swap C D) (sum.inr X) = sum.inl X :=\n  rfl\n\n@[simp] theorem swap_map_inl (C : Type u₁) [category C] (D : Type u₁) [category D] {X : C} {Y : C}\n    {f : sum.inl X ⟶ sum.inl Y} : functor.map (swap C D) f = f :=\n  rfl\n\n@[simp] theorem swap_map_inr (C : Type u₁) [category C] (D : Type u₁) [category D] {X : D} {Y : D}\n    {f : sum.inr X ⟶ sum.inr Y} : functor.map (swap C D) f = f :=\n  rfl\n\nnamespace swap\n\n\n/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/\ndef equivalence (C : Type u₁) [category C] (D : Type u₁) [category D] : C ⊕ D ≌ D ⊕ C :=\n  equivalence.mk (swap C D) (swap D C)\n    (nat_iso.of_components (fun (X : C ⊕ D) => eq_to_iso sorry) sorry)\n    (nat_iso.of_components (fun (X : D ⊕ C) => eq_to_iso sorry) sorry)\n\nprotected instance is_equivalence (C : Type u₁) [category C] (D : Type u₁) [category D] :\n    is_equivalence (swap C D) :=\n  is_equivalence.of_equivalence (equivalence C D)\n\n/-- The double swap on `C ⊕ D` is naturally isomorphic to the identity functor. -/\ndef symmetry (C : Type u₁) [category C] (D : Type u₁) [category D] : swap C D ⋙ swap D C ≅ 𝟭 :=\n  iso.symm (equivalence.unit_iso (equivalence C D))\n\nend swap\n\n\nend sum\n\n\nnamespace functor\n\n\n/-- The sum of two functors. -/\ndef sum {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C]\n    {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) : A ⊕ C ⥤ B ⊕ D :=\n  mk (fun (X : A ⊕ C) => sorry) fun (X Y : A ⊕ C) (f : X ⟶ Y) => sorry\n\n@[simp] theorem sum_obj_inl {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁}\n    [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) (a : A) :\n    obj (sum F G) (sum.inl a) = sum.inl (obj F a) :=\n  rfl\n\n@[simp] theorem sum_obj_inr {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁}\n    [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) (c : C) :\n    obj (sum F G) (sum.inr c) = sum.inr (obj G c) :=\n  rfl\n\n@[simp] theorem sum_map_inl {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁}\n    [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) {a : A} {a' : A}\n    (f : sum.inl a ⟶ sum.inl a') : map (sum F G) f = map F f :=\n  rfl\n\n@[simp] theorem sum_map_inr {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁}\n    [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) {c : C} {c' : C}\n    (f : sum.inr c ⟶ sum.inr c') : map (sum F G) f = map G f :=\n  rfl\n\nend functor\n\n\nnamespace nat_trans\n\n\n/-- The sum of two natural transformations. -/\ndef sum {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C]\n    {D : Type u₁} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D} (α : F ⟶ G)\n    (β : H ⟶ I) : functor.sum F H ⟶ functor.sum G I :=\n  mk fun (X : A ⊕ C) => sorry\n\n@[simp] theorem sum_app_inl {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁}\n    [category C] {D : Type u₁} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D}\n    (α : F ⟶ G) (β : H ⟶ I) (a : A) : app (sum α β) (sum.inl a) = app α a :=\n  rfl\n\n@[simp] theorem sum_app_inr {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁}\n    [category C] {D : Type u₁} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D}\n    (α : F ⟶ G) (β : H ⟶ I) (c : C) : app (sum α β) (sum.inr c) = app β c :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/sums/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.47948361521130684}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.module.pi\n\n/-!\n# Bundled hom instances for module and multiplicative actions\n\nThis file defines instances for module, mul_action and related structures on bundled `_hom` types.\n\nThese are analogous to the instances in `algebra.module.pi`, but for bundled instead of unbundled\nfunctions.\n-/\n\nvariables {R S A B : Type*}\n\nnamespace add_monoid_hom\n\nsection\nvariables [monoid R] [monoid S] [add_monoid A] [add_comm_monoid B]\nvariables [distrib_mul_action R B] [distrib_mul_action S B]\n\ninstance : distrib_mul_action R (A →+ B) :=\n{ smul := λ r f,\n  { to_fun := r • f,\n    map_zero' := by simp,\n    map_add' := λ x y, by simp [smul_add] },\n  one_smul := λ f, by simp,\n  mul_smul := λ r s f, by simp [mul_smul],\n  smul_add := λ r f g, ext $ λ x, by simp [smul_add],\n  smul_zero := λ r, ext $ λ x, by simp [smul_zero] }\n\n@[simp] lemma coe_smul (r : R) (f : A →+ B) : ⇑(r • f) = r • f := rfl\nlemma smul_apply (r : R) (f : A →+ B) (x : A) : (r • f) x = r • f x := rfl\n\ninstance [smul_comm_class R S B] : smul_comm_class R S (A →+ B) :=\n⟨λ a b f, ext $ λ x, smul_comm _ _ _⟩\n\ninstance [has_scalar R S] [is_scalar_tower R S B] : is_scalar_tower R S (A →+ B) :=\n⟨λ a b f, ext $ λ x, smul_assoc _ _ _⟩\n\ninstance [distrib_mul_action Rᵐᵒᵖ B] [is_central_scalar R B] : is_central_scalar R (A →+ B) :=\n⟨λ a b, ext $ λ x, op_smul_eq_smul _ _⟩\n\nend\n\ninstance [semiring R] [add_monoid A] [add_comm_monoid B] [module R B] :\n  module R (A →+ B) :=\n{ add_smul := λ r s x, ext $ λ y, by simp [add_smul],\n  zero_smul := λ x, ext $ λ y, by simp [zero_smul],\n  ..add_monoid_hom.distrib_mul_action }\n\nend add_monoid_hom\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebra/module/hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.679178692681616, "lm_q1q2_score": 0.4793541525205992}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.fintype.card\nimport data.finset.prod\n\n/-!\n# fintype instance for the product of two fintypes.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n-/\n\nopen function\nopen_locale nat\n\nuniverses u v\n\nvariables {α β γ : Type*}\n\nopen finset function\n\nnamespace set\nvariables {s t : set α}\n\nlemma to_finset_prod (s : set α) (t : set β) [fintype s] [fintype t] [fintype (s ×ˢ t)] :\n  (s ×ˢ t).to_finset = s.to_finset ×ˢ t.to_finset :=\nby { ext, simp }\n\nlemma to_finset_off_diag {s : set α} [decidable_eq α] [fintype s] [fintype s.off_diag] :\n  s.off_diag.to_finset = s.to_finset.off_diag :=\nfinset.ext $ by simp\n\nend set\n\ninstance (α β : Type*) [fintype α] [fintype β] : fintype (α × β) :=\n⟨univ ×ˢ univ, λ ⟨a, b⟩, by simp⟩\n\n@[simp] lemma finset.univ_product_univ {α β : Type*} [fintype α] [fintype β] :\n  (univ : finset α) ×ˢ (univ : finset β) = univ :=\nrfl\n\n@[simp] theorem fintype.card_prod (α β : Type*) [fintype α] [fintype β] :\n  fintype.card (α × β) = fintype.card α * fintype.card β :=\ncard_product _ _\n\nsection\nopen_locale classical\n\n@[simp] lemma infinite_prod :\n  infinite (α × β) ↔ infinite α ∧ nonempty β ∨ nonempty α ∧ infinite β :=\nbegin\n  refine ⟨λ H, _, λ H, H.elim (and_imp.2 $ @prod.infinite_of_left α β)\n    (and_imp.2 $ @prod.infinite_of_right α β)⟩,\n  rw and.comm, contrapose! H, introI H',\n  rcases infinite.nonempty (α × β) with ⟨a, b⟩,\n  haveI := fintype_of_not_infinite (H.1 ⟨b⟩), haveI := fintype_of_not_infinite (H.2 ⟨a⟩),\n  exact H'.false\nend\n\ninstance pi.infinite_of_left {ι : Sort*} {π : ι → Sort*} [∀ i, nontrivial $ π i]\n  [infinite ι] : infinite (Π i : ι, π i) :=\nbegin\n  choose m n hm using λ i, exists_pair_ne (π i),\n  refine infinite.of_injective (λ i, m.update i (n i)) (λ x y h, not_not.1 $ λ hne, _),\n  simp_rw [update_eq_iff, update_noteq hne] at h,\n  exact (hm x h.1.symm).elim,\nend\n\n/-- If at least one `π i` is infinite and the rest nonempty, the pi type of all `π` is infinite. -/\nlemma pi.infinite_of_exists_right {ι : Type*} {π : ι → Type*} (i : ι)\n  [infinite $ π i] [∀ i, nonempty $ π i] :\n  infinite (Π i : ι, π i) :=\nlet ⟨m⟩ := @pi.nonempty ι π _ in infinite.of_injective _ (update_injective m i)\n\n/-- See `pi.infinite_of_exists_right` for the case that only one `π i` is infinite. -/\ninstance pi.infinite_of_right {ι : Sort*} {π : ι → Sort*} [∀ i, infinite $ π i] [nonempty ι] :\n  infinite (Π i : ι, π i) :=\npi.infinite_of_exists_right (classical.arbitrary ι)\n\n/-- Non-dependent version of `pi.infinite_of_left`. -/\ninstance function.infinite_of_left {ι π : Sort*} [nontrivial π]\n  [infinite ι] : infinite (ι → π) :=\npi.infinite_of_left\n\n/-- Non-dependent version of `pi.infinite_of_exists_right` and `pi.infinite_of_right`. -/\ninstance function.infinite_of_right {ι π : Sort*} [infinite π] [nonempty ι] :\n  infinite (ι → π) :=\npi.infinite_of_right\n\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/fintype/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.7057850278370111, "lm_q1q2_score": 0.47935414793738873}}
{"text": "/-\nCopyright (c) 2018 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis, Chris Hughes\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.associated\nimport Mathlib.algebra.big_operators.basic\nimport Mathlib.data.nat.enat\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-- `multiplicity a b` returns the largest natural number `n` such that\n  `a ^ n ∣ b`, as an `enat` or natural with infinity. If `∀ n, a ^ n ∣ b`,\n  then it returns `⊤`-/\ndef multiplicity {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] (a : α) (b : α) : enat :=\n  enat.find fun (n : ℕ) => ¬a ^ (n + 1) ∣ b\n\nnamespace multiplicity\n\n\n/-- `multiplicity.finite a b` indicates that the multiplicity of `a` in `b` is finite. -/\ndef finite {α : Type u_1} [comm_monoid α] (a : α) (b : α) :=\n  ∃ (n : ℕ), ¬a ^ (n + 1) ∣ b\n\ntheorem finite_iff_dom {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} : finite a b ↔ roption.dom (multiplicity a b) :=\n  iff.rfl\n\ntheorem finite_def {α : Type u_1} [comm_monoid α] {a : α} {b : α} : finite a b ↔ ∃ (n : ℕ), ¬a ^ (n + 1) ∣ b :=\n  iff.rfl\n\ntheorem int.coe_nat_multiplicity (a : ℕ) (b : ℕ) : multiplicity ↑a ↑b = multiplicity a b := sorry\n\ntheorem not_finite_iff_forall {α : Type u_1} [comm_monoid α] {a : α} {b : α} : ¬finite a b ↔ ∀ (n : ℕ), a ^ n ∣ b := sorry\n\ntheorem not_unit_of_finite {α : Type u_1} [comm_monoid α] {a : α} {b : α} (h : finite a b) : ¬is_unit a := sorry\n\ntheorem finite_of_finite_mul_left {α : Type u_1} [comm_monoid α] {a : α} {b : α} {c : α} : finite a (b * c) → finite a c := sorry\n\ntheorem finite_of_finite_mul_right {α : Type u_1} [comm_monoid α] {a : α} {b : α} {c : α} : finite a (b * c) → finite a b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (finite a (b * c) → finite a b)) (mul_comm b c))) finite_of_finite_mul_left\n\ntheorem pow_dvd_of_le_multiplicity {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {k : ℕ} : ↑k ≤ multiplicity a b → a ^ k ∣ b := sorry\n\ntheorem pow_multiplicity_dvd {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} (h : finite a b) : a ^ roption.get (multiplicity a b) h ∣ b :=\n  pow_dvd_of_le_multiplicity\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑(roption.get (multiplicity a b) h) ≤ multiplicity a b)) (enat.coe_get h)))\n      (le_refl (multiplicity a b)))\n\ntheorem is_greatest {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {m : ℕ} (hm : multiplicity a b < ↑m) : ¬a ^ m ∣ b := sorry\n\ntheorem is_greatest' {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {m : ℕ} (h : finite a b) (hm : roption.get (multiplicity a b) h < m) : ¬a ^ m ∣ b :=\n  is_greatest\n    (eq.mp (Eq._oldrec (Eq.refl (↑(roption.get (multiplicity a b) h) < ↑m)) (enat.coe_get h))\n      (eq.mp (Eq._oldrec (Eq.refl (roption.get (multiplicity a b) h < m)) (Eq.symm (propext enat.coe_lt_coe))) hm))\n\ntheorem unique {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {k : ℕ} (hk : a ^ k ∣ b) (hsucc : ¬a ^ (k + 1) ∣ b) : ↑k = multiplicity a b := sorry\n\ntheorem unique' {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {k : ℕ} (hk : a ^ k ∣ b) (hsucc : ¬a ^ (k + 1) ∣ b) : k = roption.get (multiplicity a b) (Exists.intro k hsucc) := sorry\n\ntheorem le_multiplicity_of_pow_dvd {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {k : ℕ} (hk : a ^ k ∣ b) : ↑k ≤ multiplicity a b :=\n  le_of_not_gt fun (hk' : ↑k > multiplicity a b) => is_greatest hk' hk\n\ntheorem pow_dvd_iff_le_multiplicity {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {k : ℕ} : a ^ k ∣ b ↔ ↑k ≤ multiplicity a b :=\n  { mp := le_multiplicity_of_pow_dvd, mpr := pow_dvd_of_le_multiplicity }\n\ntheorem multiplicity_lt_iff_neg_dvd {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {k : ℕ} : multiplicity a b < ↑k ↔ ¬a ^ k ∣ b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (multiplicity a b < ↑k ↔ ¬a ^ k ∣ b)) (propext pow_dvd_iff_le_multiplicity)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (multiplicity a b < ↑k ↔ ¬↑k ≤ multiplicity a b)) (propext not_le)))\n      (iff.refl (multiplicity a b < ↑k)))\n\ntheorem eq_some_iff {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {n : ℕ} : multiplicity a b = ↑n ↔ a ^ n ∣ b ∧ ¬a ^ (n + 1) ∣ b := sorry\n\ntheorem eq_top_iff {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} : multiplicity a b = ⊤ ↔ ∀ (n : ℕ), a ^ n ∣ b := sorry\n\ntheorem one_right {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} (ha : ¬is_unit a) : multiplicity a 1 = 0 := sorry\n\n@[simp] theorem get_one_right {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} (ha : finite a 1) : roption.get (multiplicity a 1) ha = 0 := sorry\n\n@[simp] theorem multiplicity_unit {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} (b : α) (ha : is_unit a) : multiplicity a b = ⊤ :=\n  iff.mpr eq_top_iff fun (_x : ℕ) => iff.mp is_unit_iff_forall_dvd (is_unit.pow _x ha) b\n\n@[simp] theorem one_left {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] (b : α) : multiplicity 1 b = ⊤ := sorry\n\ntheorem multiplicity_eq_zero_of_not_dvd {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} (ha : ¬a ∣ b) : multiplicity a b = 0 := sorry\n\ntheorem eq_top_iff_not_finite {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} : multiplicity a b = ⊤ ↔ ¬finite a b :=\n  roption.eq_none_iff'\n\ntheorem multiplicity_le_multiplicity_iff {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {c : α} {d : α} : multiplicity a b ≤ multiplicity c d ↔ ∀ (n : ℕ), a ^ n ∣ b → c ^ n ∣ d := sorry\n\ntheorem multiplicity_le_multiplicity_of_dvd {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} {c : α} (hdvd : a ∣ b) : multiplicity b c ≤ multiplicity a c :=\n  iff.mpr multiplicity_le_multiplicity_iff fun (n : ℕ) (h : b ^ n ∣ c) => dvd_trans (pow_dvd_pow_of_dvd hdvd n) h\n\ntheorem dvd_of_multiplicity_pos {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} (h : 0 < multiplicity a b) : a ∣ b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a ∣ b)) (Eq.symm (pow_one a))))\n    (pow_dvd_of_le_multiplicity (iff.mp enat.pos_iff_one_le h))\n\ntheorem dvd_iff_multiplicity_pos {α : Type u_1} [comm_monoid α] [DecidableRel has_dvd.dvd] {a : α} {b : α} : 0 < multiplicity a b ↔ a ∣ b := sorry\n\ntheorem finite_nat_iff {a : ℕ} {b : ℕ} : finite a b ↔ a ≠ 1 ∧ 0 < b := sorry\n\ntheorem ne_zero_of_finite {α : Type u_1} [comm_monoid_with_zero α] {a : α} {b : α} (h : finite a b) : b ≠ 0 := sorry\n\n@[simp] protected theorem zero {α : Type u_1} [comm_monoid_with_zero α] [DecidableRel has_dvd.dvd] (a : α) : multiplicity a 0 = ⊤ := sorry\n\n@[simp] theorem multiplicity_zero_eq_zero_of_ne_zero {α : Type u_1} [comm_monoid_with_zero α] [DecidableRel has_dvd.dvd] (a : α) (ha : a ≠ 0) : multiplicity 0 a = 0 :=\n  multiplicity_eq_zero_of_not_dvd (eq.mpr (id (Eq._oldrec (Eq.refl (¬0 ∣ a)) (propext zero_dvd_iff))) ha)\n\ntheorem min_le_multiplicity_add {α : Type u_1} [comm_semiring α] [DecidableRel has_dvd.dvd] {p : α} {a : α} {b : α} : min (multiplicity p a) (multiplicity p b) ≤ multiplicity p (a + b) := sorry\n\n@[simp] protected theorem neg {α : Type u_1} [comm_ring α] [DecidableRel has_dvd.dvd] (a : α) (b : α) : multiplicity a (-b) = multiplicity a b := sorry\n\ntheorem multiplicity_add_of_gt {α : Type u_1} [comm_ring α] [DecidableRel has_dvd.dvd] {p : α} {a : α} {b : α} (h : multiplicity p b < multiplicity p a) : multiplicity p (a + b) = multiplicity p b := sorry\n\ntheorem multiplicity_sub_of_gt {α : Type u_1} [comm_ring α] [DecidableRel has_dvd.dvd] {p : α} {a : α} {b : α} (h : multiplicity p b < multiplicity p a) : multiplicity p (a - b) = multiplicity p b := sorry\n\ntheorem multiplicity_add_eq_min {α : Type u_1} [comm_ring α] [DecidableRel has_dvd.dvd] {p : α} {a : α} {b : α} (h : multiplicity p a ≠ multiplicity p b) : multiplicity p (a + b) = min (multiplicity p a) (multiplicity p b) := sorry\n\ntheorem finite_mul_aux {α : Type u_1} [comm_cancel_monoid_with_zero α] {p : α} (hp : prime p) {n : ℕ} {m : ℕ} {a : α} {b : α} : ¬p ^ (n + 1) ∣ a → ¬p ^ (m + 1) ∣ b → ¬p ^ (n + m + 1) ∣ a * b := sorry\n\ntheorem finite_mul {α : Type u_1} [comm_cancel_monoid_with_zero α] {p : α} {a : α} {b : α} (hp : prime p) : finite p a → finite p b → finite p (a * b) := sorry\n\ntheorem finite_mul_iff {α : Type u_1} [comm_cancel_monoid_with_zero α] {p : α} {a : α} {b : α} (hp : prime p) : finite p (a * b) ↔ finite p a ∧ finite p b :=\n  { mp := fun (h : finite p (a * b)) => { left := finite_of_finite_mul_right h, right := finite_of_finite_mul_left h },\n    mpr := fun (h : finite p a ∧ finite p b) => finite_mul hp (and.left h) (and.right h) }\n\ntheorem finite_pow {α : Type u_1} [comm_cancel_monoid_with_zero α] {p : α} {a : α} (hp : prime p) {k : ℕ} (ha : finite p a) : finite p (a ^ k) := sorry\n\n@[simp] theorem multiplicity_self {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {a : α} (ha : ¬is_unit a) (ha0 : a ≠ 0) : multiplicity a a = 1 := sorry\n\n@[simp] theorem get_multiplicity_self {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {a : α} (ha : finite a a) : roption.get (multiplicity a a) ha = 1 := sorry\n\nprotected theorem mul' {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {p : α} {a : α} {b : α} (hp : prime p) (h : roption.dom (multiplicity p (a * b))) : roption.get (multiplicity p (a * b)) h =\n  roption.get (multiplicity p a) (and.left (iff.mp (finite_mul_iff hp) h)) +\n    roption.get (multiplicity p b) (and.right (iff.mp (finite_mul_iff hp) h)) := sorry\n\nprotected theorem mul {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {p : α} {a : α} {b : α} (hp : prime p) : multiplicity p (a * b) = multiplicity p a + multiplicity p b := sorry\n\ntheorem finset.prod {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {β : Type u_2} {p : α} (hp : prime p) (s : finset β) (f : β → α) : multiplicity p (finset.prod s fun (x : β) => f x) = finset.sum s fun (x : β) => multiplicity p (f x) := sorry\n\nprotected theorem pow' {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {p : α} {a : α} (hp : prime p) (ha : finite p a) {k : ℕ} : roption.get (multiplicity p (a ^ k)) (finite_pow hp ha) = k * roption.get (multiplicity p a) ha := sorry\n\ntheorem pow {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {p : α} {a : α} (hp : prime p) {k : ℕ} : multiplicity p (a ^ k) = k •ℕ multiplicity p a := sorry\n\ntheorem multiplicity_pow_self {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {p : α} (h0 : p ≠ 0) (hu : ¬is_unit p) (n : ℕ) : multiplicity p (p ^ n) = ↑n := sorry\n\ntheorem multiplicity_pow_self_of_prime {α : Type u_1} [comm_cancel_monoid_with_zero α] [DecidableRel has_dvd.dvd] {p : α} (hp : prime p) (n : ℕ) : multiplicity p (p ^ n) = ↑n :=\n  multiplicity_pow_self (prime.ne_zero hp) (prime.not_unit hp) n\n\nend multiplicity\n\n\ntheorem multiplicity_eq_zero_of_coprime {p : ℕ} {a : ℕ} {b : ℕ} (hp : p ≠ 1) (hle : multiplicity p a ≤ multiplicity p b) (hab : nat.coprime a b) : multiplicity p a = 0 := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/multiplicity.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.47935414411436733}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.natural_transformation\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ v₃ u₃ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\n`functor.category C D` gives the category structure on functors and natural transformations\nbetween categories `C` and `D`.\n\nNotice that if `C` and `D` are both small categories at the same universe level,\nthis is another small category at that level.\nHowever if `C` and `D` are both large categories at the same universe level,\nthis is a small category at the next higher level.\n-/\nprotected instance functor.category (C : Type u₁) [category C] (D : Type u₂) [category D] :\n    category (C ⥤ D) :=\n  category.mk\n\nnamespace nat_trans\n\n\n@[simp] theorem vcomp_eq_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} {H : C ⥤ D} (α : F ⟶ G) (β : G ⟶ H) : vcomp α β = α ≫ β :=\n  rfl\n\ntheorem vcomp_app' {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    {H : C ⥤ D} (α : F ⟶ G) (β : G ⟶ H) (X : C) : app (α ≫ β) X = app α X ≫ app β X :=\n  rfl\n\ntheorem congr_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    {α : F ⟶ G} {β : F ⟶ G} (h : α = β) (X : C) : app α X = app β X :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (app α X = app β X)) h)) (Eq.refl (app β X))\n\n@[simp] theorem id_app {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) (X : C) :\n    app 𝟙 X = 𝟙 :=\n  rfl\n\n@[simp] theorem comp_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} {H : C ⥤ D} (α : F ⟶ G) (β : G ⟶ H) (X : C) : app (α ≫ β) X = app α X ≫ app β X :=\n  rfl\n\ntheorem app_naturality {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {F : C ⥤ D ⥤ E} {G : C ⥤ D ⥤ E} (T : F ⟶ G) (X : C) {Y : D} {Z : D} (f : Y ⟶ Z) :\n    functor.map (functor.obj F X) f ≫ app (app T X) Z =\n        app (app T X) Y ≫ functor.map (functor.obj G X) f :=\n  naturality (app T X) f\n\ntheorem naturality_app {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {F : C ⥤ D ⥤ E} {G : C ⥤ D ⥤ E} (T : F ⟶ G) (Z : D) {X : C} {Y : C} (f : X ⟶ Y) :\n    app (functor.map F f) Z ≫ app (app T Y) Z = app (app T X) Z ≫ app (functor.map G f) Z :=\n  congr_fun (congr_arg app (naturality T f)) Z\n\n/-- A natural transformation is a monomorphism if each component is. -/\ntheorem mono_app_of_mono {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} (α : F ⟶ G) [∀ (X : C), mono (app α X)] : mono α :=\n  sorry\n\n/-- A natural transformation is an epimorphism if each component is. -/\ntheorem epi_app_of_epi {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    (α : F ⟶ G) [∀ (X : C), epi (app α X)] : epi α :=\n  sorry\n\n/-- `hcomp α β` is the horizontal composition of natural transformations. -/\ndef hcomp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E]\n    {F : C ⥤ D} {G : C ⥤ D} {H : D ⥤ E} {I : D ⥤ E} (α : F ⟶ G) (β : H ⟶ I) : F ⋙ H ⟶ G ⋙ I :=\n  mk fun (X : C) => app β (functor.obj F X) ≫ functor.map I (app α X)\n\ninfixl:80 \" ◫ \" => Mathlib.category_theory.nat_trans.hcomp\n\n@[simp] theorem hcomp_app {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {F : C ⥤ D} {G : C ⥤ D} {H : D ⥤ E} {I : D ⥤ E} (α : F ⟶ G) (β : H ⟶ I) (X : C) :\n    app (α ◫ β) X = app β (functor.obj F X) ≫ functor.map I (app α X) :=\n  rfl\n\n@[simp] theorem hcomp_id_app {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {F : C ⥤ D} {G : C ⥤ D} {H : D ⥤ E} (α : F ⟶ G) (X : C) :\n    app (α ◫ 𝟙) X = functor.map H (app α X) :=\n  sorry\n\ntheorem id_hcomp_app {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] {F : C ⥤ D} {G : C ⥤ D} {H : E ⥤ C} (α : F ⟶ G) (X : E) :\n    app (𝟙 ◫ α) X = app α (functor.obj H X) :=\n  sorry\n\n-- Note that we don't yet prove a `hcomp_assoc` lemma here: even stating it is painful, because we\n\n-- need to use associativity of functor composition. (It's true without the explicit associator,\n\n-- because functor composition is definitionally associative, but relying on the definitional equality\n\n-- causes bad problems with elaboration later.)\n\ntheorem exchange {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E]\n    {F : C ⥤ D} {G : C ⥤ D} {H : C ⥤ D} {I : D ⥤ E} {J : D ⥤ E} {K : D ⥤ E} (α : F ⟶ G) (β : G ⟶ H)\n    (γ : I ⟶ J) (δ : J ⟶ K) : (α ≫ β) ◫ (γ ≫ δ) = α ◫ γ ≫ β ◫ δ :=\n  sorry\n\nend nat_trans\n\n\nnamespace functor\n\n\n/-- Flip the arguments of a bifunctor. See also `currying.lean`. -/\nprotected def flip {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E]\n    (F : C ⥤ D ⥤ E) : D ⥤ C ⥤ E :=\n  mk\n    (fun (k : D) =>\n      mk (fun (j : C) => obj (obj F j) k) fun (j j' : C) (f : j ⟶ j') => nat_trans.app (map F f) k)\n    fun (c c' : D) (f : c ⟶ c') => nat_trans.mk fun (j : C) => map (obj F j) f\n\n@[simp] theorem flip_obj_obj {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] (F : C ⥤ D ⥤ E) (c : C) (d : D) :\n    obj (obj (functor.flip F) d) c = obj (obj F c) d :=\n  rfl\n\n@[simp] theorem flip_obj_map {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] (F : C ⥤ D ⥤ E) {c : C} {c' : C} (f : c ⟶ c') (d : D) :\n    map (obj (functor.flip F) d) f = nat_trans.app (map F f) d :=\n  rfl\n\n@[simp] theorem flip_map_app {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃}\n    [category E] (F : C ⥤ D ⥤ E) {d : D} {d' : D} (f : d ⟶ d') (c : C) :\n    nat_trans.app (map (functor.flip F) f) c = map (obj F c) f :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/functor_category_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4793117881898395}}
{"text": "theorem byCases_Bool_bind [Monad m] (x : m Bool) (f g : Bool → m β) (isTrue : f true = g true) (isFalse : f false = g false) : (x >>= f) = (x >>= g) := by\n  have : f = g := by\n    funext b; cases b <;> assumption\n  rw [this]\n\ntheorem eq_findM [Monad m] [LawfulMonad m] (p : α → m Bool) (xs : List α) :\n    (do for x in xs do\n          let b ← p x\n          if b then\n            return some x\n        return none)\n    =\n    xs.findM? p := by\n  induction xs with simp [List.findM?]\n  | cons x xs ih =>\n    rw [← ih]; simp\n    apply byCases_Bool_bind <;> simp\n\ntheorem eq_findSomeM_findM [Monad m] [LawfulMonad m] (p : α → m Bool) (xss : List (List α)) :\n    (do for xs in xss do\n           for x in xs do\n             let b ← p x\n             if b then\n               return some x\n        return none)\n    =\n    xss.findSomeM? (fun xs => xs.findM? p) := by\n  induction xss with simp [List.findSomeM?]\n  | cons xs xss ih =>\n    rw [← ih, ← eq_findM]\n    induction xs with simp\n    | cons x xs ih =>\n      apply byCases_Bool_bind <;> simp [ih]\n\ntheorem eq_findSomeM_findM' [Monad m] [LawfulMonad m] (p : α → m Bool) (xss : List (List α)) :\n    (do for xs in xss do\n           for x in xs do\n             let b ← p x\n             if b then\n               return some x\n        return none)\n    =\n    xss.findSomeM? (fun xs => xs.findM? p) := by\n  induction xss <;> simp [List.findSomeM?]\n  rename List α => xs\n  rename _ = _  => ih\n  rw [← ih, ← eq_findM]\n  induction xs <;> simp\n  rename _ = _ => ih\n  apply byCases_Bool_bind <;> simp [ih]\n\ntheorem z_add (x : Nat) : 0 + x = x := by\n  induction x\n  rfl\n  rename _ = _ => ih\n  show Nat.succ (0 + _) = _\n  rw [ih]\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/do_eqv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4793117804183136}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.algebra.tower\nimport Mathlib.algebra.invertible\nimport Mathlib.linear_algebra.basis\nimport Mathlib.ring_theory.adjoin\nimport Mathlib.PostPort\n\nuniverses u v w u₁ u_1 u_2 u_3 u_4 v₁ w₁ \n\nnamespace Mathlib\n\n/-!\n# Towers of algebras\n\nWe set up the basic theory of algebra towers.\nAn algebra tower A/S/R is expressed by having instances of `algebra A S`,\n`algebra R S`, `algebra R A` and `is_scalar_tower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nIn `field_theory/tower.lean` we use this to prove the tower law for finite extensions,\nthat if `R` and `S` are both fields, then `[A:R] = [A:S] [S:A]`.\n\nIn this file we prepare the main lemma:\nif `{bi | i ∈ I}` is an `R`-basis of `S` and `{cj | j ∈ J}` is a `S`-basis\nof `A`, then `{bi cj | i ∈ I, j ∈ J}` is an `R`-basis of `A`. This statement does not require the\nbase rings to be a field, so we also generalize the lemma to rings in this file.\n-/\n\nnamespace is_scalar_tower\n\n\nprotected instance polynomial (R : Type u) {S : Type v} {A : Type w} [comm_semiring R] [comm_semiring S] [semiring A] [algebra R S] [algebra S A] [algebra R A] [is_scalar_tower R S A] : is_scalar_tower R S (polynomial A) :=\n  of_algebra_map_eq fun (x : R) => congr_arg (⇑polynomial.C) (algebra_map_apply R S A x)\n\ntheorem aeval_apply (R : Type u) (S : Type v) (A : Type w) [comm_semiring R] [comm_semiring S] [semiring A] [algebra R S] [algebra S A] [algebra R A] [is_scalar_tower R S A] (x : A) (p : polynomial R) : coe_fn (polynomial.aeval x) p = coe_fn (polynomial.aeval x) (polynomial.map (algebra_map R S) p) := sorry\n\n/-- Suppose that `R -> S -> A` is a tower of algebras.\nIf an element `r : R` is invertible in `S`, then it is invertible in `A`. -/\ndef invertible.algebra_tower (R : Type u) (S : Type v) (A : Type w) [comm_semiring R] [comm_semiring S] [semiring A] [algebra R S] [algebra S A] [algebra R A] [is_scalar_tower R S A] (r : R) [invertible (coe_fn (algebra_map R S) r)] : invertible (coe_fn (algebra_map R A) r) :=\n  invertible.copy (invertible.map (↑(algebra_map S A)) (coe_fn (algebra_map R S) r)) (coe_fn (algebra_map R A) r) sorry\n\n/-- A natural number that is invertible when coerced to `R` is also invertible\nwhen coerced to any `R`-algebra. -/\ndef invertible_algebra_coe_nat (R : Type u) (A : Type w) [comm_semiring R] [semiring A] [algebra R A] (n : ℕ) [inv : invertible ↑n] : invertible ↑n :=\n  invertible.algebra_tower ℕ R A n\n\ntheorem algebra_map_aeval (R : Type u) (A : Type w) (B : Type u₁) [comm_semiring R] [comm_semiring A] [comm_semiring B] [algebra R A] [algebra A B] [algebra R B] [is_scalar_tower R A B] (x : A) (p : polynomial R) : coe_fn (algebra_map A B) (coe_fn (polynomial.aeval x) p) = coe_fn (polynomial.aeval (coe_fn (algebra_map A B) x)) p := sorry\n\ntheorem aeval_eq_zero_of_aeval_algebra_map_eq_zero (R : Type u) (A : Type w) (B : Type u₁) [comm_semiring R] [comm_semiring A] [comm_semiring B] [algebra R A] [algebra A B] [algebra R B] [is_scalar_tower R A B] {x : A} {p : polynomial R} (h : function.injective ⇑(algebra_map A B)) (hp : coe_fn (polynomial.aeval (coe_fn (algebra_map A B) x)) p = 0) : coe_fn (polynomial.aeval x) p = 0 := sorry\n\ntheorem aeval_eq_zero_of_aeval_algebra_map_eq_zero_field {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_semiring R] [field A] [comm_semiring B] [nontrivial B] [algebra R A] [algebra R B] [algebra A B] [is_scalar_tower R A B] {x : A} {p : polynomial R} (h : coe_fn (polynomial.aeval (coe_fn (algebra_map A B) x)) p = 0) : coe_fn (polynomial.aeval x) p = 0 :=\n  aeval_eq_zero_of_aeval_algebra_map_eq_zero R A B (ring_hom.injective (algebra_map A B)) h\n\nend is_scalar_tower\n\n\nnamespace algebra\n\n\ntheorem adjoin_algebra_map' {R : Type u} {S : Type v} {A : Type w} [comm_ring R] [comm_ring S] [comm_ring A] [algebra R S] [algebra S A] (s : set S) : adjoin R (⇑(algebra_map S (comap R S A)) '' s) = subalgebra.map (adjoin R s) (to_comap R S A) := sorry\n\ntheorem adjoin_algebra_map (R : Type u) (S : Type v) (A : Type w) [comm_ring R] [comm_ring S] [comm_ring A] [algebra R S] [algebra S A] [algebra R A] [is_scalar_tower R S A] (s : set S) : adjoin R (⇑(algebra_map S A) '' s) = subalgebra.map (adjoin R s) (is_scalar_tower.to_alg_hom R S A) := sorry\n\ntheorem adjoin_res (C : Type u_1) (D : Type u_2) (E : Type u_3) [comm_semiring C] [comm_semiring D] [comm_semiring E] [algebra C D] [algebra C E] [algebra D E] [is_scalar_tower C D E] (S : set E) : subalgebra.res C (adjoin D S) =\n  subalgebra.under (subalgebra.map ⊤ (is_scalar_tower.to_alg_hom C D E))\n    (adjoin (↥(subalgebra.map ⊤ (is_scalar_tower.to_alg_hom C D E))) S) := sorry\n\ntheorem adjoin_res_eq_adjoin_res (C : Type u_1) (D : Type u_2) (E : Type u_3) (F : Type u_4) [comm_semiring C] [comm_semiring D] [comm_semiring E] [comm_semiring F] [algebra C D] [algebra C E] [algebra C F] [algebra D F] [algebra E F] [is_scalar_tower C D F] [is_scalar_tower C E F] {S : set D} {T : set E} (hS : adjoin C S = ⊤) (hT : adjoin C T = ⊤) : subalgebra.res C (adjoin E (⇑(algebra_map D F) '' S)) = subalgebra.res C (adjoin D (⇑(algebra_map E F) '' T)) := sorry\n\nend algebra\n\n\nnamespace subalgebra\n\n\n@[simp] theorem aeval_coe (R : Type u) {A : Type w} [comm_semiring R] [comm_semiring A] [algebra R A] {S : subalgebra R A} {x : ↥S} {p : polynomial R} : coe_fn (polynomial.aeval ↑x) p = ↑(coe_fn (polynomial.aeval x) p) :=\n  Eq.symm (is_scalar_tower.algebra_map_aeval R (↥S) A x p)\n\nend subalgebra\n\n\ntheorem algebra.fg_trans' {R : Type u_1} {S : Type u_2} {A : Type u_3} [comm_ring R] [comm_ring S] [comm_ring A] [algebra R S] [algebra S A] [algebra R A] [is_scalar_tower R S A] (hRS : subalgebra.fg ⊤) (hSA : subalgebra.fg ⊤) : subalgebra.fg ⊤ := sorry\n\ntheorem linear_independent_smul {R : Type u} {S : Type v} {A : Type w} [comm_ring R] [ring S] [add_comm_group A] [algebra R S] [module S A] [module R A] [is_scalar_tower R S A] {ι : Type v₁} {b : ι → S} {ι' : Type w₁} {c : ι' → A} (hb : linear_independent R b) (hc : linear_independent S c) : linear_independent R fun (p : ι × ι') => b (prod.fst p) • c (prod.snd p) := sorry\n\ntheorem is_basis.smul {R : Type u} {S : Type v} {A : Type w} [comm_ring R] [ring S] [add_comm_group A] [algebra R S] [module S A] [module R A] [is_scalar_tower R S A] {ι : Type v₁} {b : ι → S} {ι' : Type w₁} {c : ι' → A} (hb : is_basis R b) (hc : is_basis S c) : is_basis R fun (p : ι × ι') => b (prod.fst p) • c (prod.snd p) := sorry\n\ntheorem is_basis.smul_repr {R : Type u} {S : Type v} {A : Type w} [comm_ring R] [ring S] [add_comm_group A] [algebra R S] [module S A] [module R A] [is_scalar_tower R S A] {ι : Type u_1} {ι' : Type u_2} {b : ι → S} {c : ι' → A} (hb : is_basis R b) (hc : is_basis S c) (x : A) (ij : ι × ι') : coe_fn (coe_fn (is_basis.repr (is_basis.smul hb hc)) x) ij =\n  coe_fn (coe_fn (is_basis.repr hb) (coe_fn (coe_fn (is_basis.repr hc) x) (prod.snd ij))) (prod.fst ij) := sorry\n\ntheorem is_basis.smul_repr_mk {R : Type u} {S : Type v} {A : Type w} [comm_ring R] [ring S] [add_comm_group A] [algebra R S] [module S A] [module R A] [is_scalar_tower R S A] {ι : Type u_1} {ι' : Type u_2} {b : ι → S} {c : ι' → A} (hb : is_basis R b) (hc : is_basis S c) (x : A) (i : ι) (j : ι') : coe_fn (coe_fn (is_basis.repr (is_basis.smul hb hc)) x) (i, j) =\n  coe_fn (coe_fn (is_basis.repr hb) (coe_fn (coe_fn (is_basis.repr hc) x) j)) i := sorry\n\ntheorem exists_subalgebra_of_fg (A : Type w) (B : Type u₁) (C : Type u_1) [comm_ring A] [comm_ring B] [comm_ring C] [algebra A B] [algebra B C] [algebra A C] [is_scalar_tower A B C] (hAC : subalgebra.fg ⊤) (hBC : submodule.fg ⊤) : ∃ (B₀ : subalgebra A B), subalgebra.fg B₀ ∧ submodule.fg ⊤ := sorry\n\n/-- Artin--Tate lemma: if A ⊆ B ⊆ C is a chain of subrings of commutative rings, and\nA is noetherian, and C is algebra-finite over A, and C is module-finite over B,\nthen B is algebra-finite over A.\n\nReferences: Atiyah--Macdonald Proposition 7.8; Stacks 00IS; Altman--Kleiman 16.17. -/\ntheorem fg_of_fg_of_fg (A : Type w) (B : Type u₁) (C : Type u_1) [comm_ring A] [comm_ring B] [comm_ring C] [algebra A B] [algebra B C] [algebra A C] [is_scalar_tower A B C] [is_noetherian_ring A] (hAC : subalgebra.fg ⊤) (hBC : submodule.fg ⊤) (hBCi : function.injective ⇑(algebra_map B C)) : subalgebra.fg ⊤ := sorry\n\n/-- Restrict the domain of an `alg_hom`. -/\ndef alg_hom.restrict_domain {A : Type w} (B : Type u₁) {C : Type u_1} {D : Type u_2} [comm_semiring A] [comm_semiring C] [comm_semiring D] [algebra A C] [algebra A D] (f : alg_hom A C D) [comm_semiring B] [algebra A B] [algebra B C] [is_scalar_tower A B C] : alg_hom A B D :=\n  alg_hom.comp f (is_scalar_tower.to_alg_hom A B C)\n\n/-- Extend the scalars of an `alg_hom`. -/\ndef alg_hom.extend_scalars {A : Type w} (B : Type u₁) {C : Type u_1} {D : Type u_2} [comm_semiring A] [comm_semiring C] [comm_semiring D] [algebra A C] [algebra A D] (f : alg_hom A C D) [comm_semiring B] [algebra A B] [algebra B C] [is_scalar_tower A B C] : alg_hom B C D :=\n  alg_hom.mk (alg_hom.to_fun f) sorry sorry sorry sorry sorry\n\n/-- `alg_hom`s from the top of a tower are equivalent to a pair of `alg_hom`s. -/\ndef alg_hom_equiv_sigma {A : Type w} {B : Type u₁} {C : Type u_1} {D : Type u_2} [comm_semiring A] [comm_semiring C] [comm_semiring D] [algebra A C] [algebra A D] [comm_semiring B] [algebra A B] [algebra B C] [is_scalar_tower A B C] : alg_hom A C D ≃ sigma fun (f : alg_hom A B D) => alg_hom B C D :=\n  equiv.mk (fun (f : alg_hom A C D) => sigma.mk (alg_hom.restrict_domain B f) (alg_hom.extend_scalars B f))\n    (fun (fg : sigma fun (f : alg_hom A B D) => alg_hom B C D) => is_scalar_tower.restrict_base A (sigma.snd fg)) sorry\n    sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/algebra_tower.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4793117804183135}}
{"text": "/-\nCopyright (c) 2014-15 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Floris van Doorn\n\nPartially ported from Coq HoTT\nTheorems about sigma-types (dependent sums)\n-/\nimport .prod\n\nuniverses u v w\nhott_theory\n\nnamespace hott\n\nopen hott.eq sigma hott.equiv hott.is_equiv function hott.is_trunc sum unit\n\n@[reducible, hott]\ndef dpair {α β} := @sigma.mk α β\n\nnamespace sigma\n  variables {A : Type _} {A' : Type _} {B : A → Type _} {B' : A' → Type _} {C : Πa, B a → Type _}\n            {D : Πa b, C a b → Type _}\n            {a a' a'' : A} {b b₁ b₂ : B a} {b' : B a'} {b'' : B a''} {u v w : Σa, B a}\n\n  @[hott] def destruct := @sigma.cases_on\n\n  /- Paths in a sigma-type -/\n\n  @[hott] protected def eta : Π (u : Σa, B a), (⟨u.1 , u.2⟩: sigma _) = u\n  | ⟨u₁, u₂⟩ := idp\n\n  @[hott] def eta2 : Π (u : Σa b, C a b), (⟨u.1, u.2.1, u.2.2⟩: Σ _ _, _) = u\n  | ⟨u₁, u₂, u₃⟩ := idp\n\n  @[hott] def eta3 : Π (u : Σa b c, D a b c), (⟨u.1, u.2.1, u.2.2.1, u.2.2.2⟩: Σ _ _ _, _) = u\n  | ⟨u₁, u₂, u₃, u₄⟩ := idp\n\n  @[hott] def dpair_eq_dpair (p : a = a') (q : b =[p] b') : (⟨a, b⟩: Σ _, _) = ⟨a', b'⟩ :=\n  apd011 sigma.mk p q\n\n  @[hott] def sigma_eq (p : u.1 = v.1) (q : u.2 =[p] v.2) : u = v :=\n  by induction u; induction v; exact (dpair_eq_dpair p q)\n\n  @[hott] def sigma_eq_right (q : b₁ = b₂) : (⟨a, b₁⟩: Σ _, _) = ⟨a, b₂⟩ :=\n  ap (dpair a) q\n\n  @[hott] def eq_fst (p : u = v) : u.1 = v.1 :=\n  ap fst p\n\n  postfix `..1`:(max+1) := eq_fst\n\n  @[hott] def eq_snd (p : u = v) : u.2 =[p..1] v.2 :=\n  by induction p; exact idpo\n\n  postfix `..2`:(max+1) := eq_snd\n\n  @[hott] def dpair_sigma_eq (p : u.1 = v.1) (q : u.2 =[p] v.2)\n    : (⟨(sigma_eq p q)..1, (sigma_eq p q)..2⟩: Σ p, u.2 =[p] v.2) = ⟨p, q⟩ :=\n  by induction u; induction v;dsimp at *;induction q;refl\n\n  @[hott] def sigma_eq_fst (p : u.1 = v.1) (q : u.2 =[p] v.2) : (sigma_eq p q)..1 = p :=\n  (dpair_sigma_eq p q)..1\n\n  @[hott] def sigma_eq_snd (p : u.1 = v.1) (q : u.2 =[p] v.2)\n    : (sigma_eq p q)..2 =[sigma_eq_fst p q; λ p, u.2 =[p] v.2] q :=\n  (dpair_sigma_eq p q)..2\n\n  @[hott] def sigma_eq_eta (p : u = v) : sigma_eq (p..1) (p..2) = p :=\n  by induction p; induction u; reflexivity\n\n  @[hott] def eq2_fst {p q : u = v} (r : p = q) : p..1 = q..1 :=\n  ap eq_fst r\n\n  @[hott] def eq2_snd {p q : u = v} (r : p = q) : p..2 =[eq2_fst r; λ x, u.2 =[x] v.2] q..2 :=\n  by apply pathover_ap; apply (apd eq_snd r)\n\n  @[hott] def tr_fst_sigma_eq {B' : A → Type _} (p : u.1 = v.1) (q : u.2 =[p] v.2)\n    : transport (λx : sigma _, B' x.1) (sigma_eq p q) = transport B' p :=\n  by induction u; induction v; dsimp at *;induction q; reflexivity\n\n  @[hott] protected def ap_fst (p : u = v) : ap (λx : sigma B, x.1) p = p..1 := idp\n\n  /- the uncurried version of sigma_eq. We will prove that this is an equivalence -/\n\n  @[hott] def sigma_eq_unc : Π (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2), u = v\n  | ⟨pq₁, pq₂⟩ := sigma_eq pq₁ pq₂\n\n  @[hott] def dpair_sigma_eq_unc : Π (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2),\n    (⟨(sigma_eq_unc pq)..1, (sigma_eq_unc pq)..2⟩: Σ p, u.2 =[p] v.2) = pq\n  | ⟨pq₁, pq₂⟩ := dpair_sigma_eq pq₁ pq₂\n\n  @[hott] def sigma_eq_fst_unc (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2)\n    : (sigma_eq_unc pq)..1 = pq.1 :=\n  (dpair_sigma_eq_unc pq)..1\n\n  @[hott] def sigma_eq_snd_unc (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2) :\n    (sigma_eq_unc pq)..2 =[sigma_eq_fst_unc pq; λ p, u.2 =[p] v.2] pq.2 :=\n  (dpair_sigma_eq_unc pq)..2\n\n  @[hott] def sigma_eq_eta_unc (p : u = v) : sigma_eq_unc ⟨p..1, p..2⟩ = p :=\n  sigma_eq_eta p\n\n  @[hott] def tr_sigma_eq_fst_unc {B' : A → Type _}\n    (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2)\n      : transport (λx:sigma _, B' x.1) (@sigma_eq_unc A B u v pq) = transport B' pq.1 :=\n  by apply destruct pq; apply tr_fst_sigma_eq\n\n  @[hott, instance] def is_equiv_sigma_eq (u v : Σa, B a)\n      : is_equiv (@sigma_eq_unc A B u v) :=\n  adjointify sigma_eq_unc\n             (λp, ⟨p..1, p..2⟩)\n             sigma_eq_eta_unc\n             dpair_sigma_eq_unc\n\n  @[hott] def sigma_eq_equiv (u v : Σa, B a)\n    : (u = v) ≃ (Σ(p : u.1 = v.1),  u.2 =[p] v.2) :=\n  (equiv.mk sigma_eq_unc (by apply_instance))⁻¹ᵉ\n\n  @[hott] def dpair_eq_dpair_con (p1 : a  = a' ) (q1 : b  =[p1] b' )\n                                (p2 : a' = a'') (q2 : b' =[p2] b'') :\n    dpair_eq_dpair (p1 ⬝ p2) (q1 ⬝o q2) = dpair_eq_dpair p1 q1 ⬝ dpair_eq_dpair  p2 q2 :=\n  by induction q1; induction q2; reflexivity\n\n  @[hott] def sigma_eq_con (p1 : u.1 = v.1) (q1 : u.2 =[p1] v.2)\n                          (p2 : v.1 = w.1) (q2 : v.2 =[p2] w.2) :\n    sigma_eq (p1 ⬝ p2) (q1 ⬝o q2) = sigma_eq p1 q1 ⬝ sigma_eq p2 q2 :=\n  by induction u; induction v; induction w; apply dpair_eq_dpair_con\n\n  @[hott] def dpair_eq_dpair_con_idp (p : a = a') (q : b =[p] b') :\n    dpair_eq_dpair p q = dpair_eq_dpair p (pathover_tr _ _) ⬝\n    dpair_eq_dpair idp (pathover_idp_of_eq _ (tr_eq_of_pathover q)) :=\n  by induction q; reflexivity\n\n  /- eq_fst commutes with the groupoid structure. -/\n\n  @[hott] def eq_fst_idp (u : Σa, B a)           : (idpath u) ..1 = refl (u.1)      := idp\n  @[hott] def eq_fst_con (p : u = v) (q : v = w) : (p ⬝ q)  ..1 = (p..1) ⬝ (q..1) := ap_con _ _ _\n  @[hott] def eq_fst_inv (p : u = v)             : p⁻¹      ..1 = (p..1)⁻¹        := ap_inv _ _\n\n  /- Applying dpair to one argument is the same as dpair_eq_dpair with reflexivity in the first place. -/\n\n  @[hott] def ap_dpair (q : b₁ = b₂) :\n    ap (sigma.mk a) q = dpair_eq_dpair idp (pathover_idp_of_eq _ q) :=\n  by induction q; reflexivity\n\n  /- Dependent transport is the same as transport along a sigma_eq. -/\n\n  @[hott] def transportD_eq_transport (p : a = a') (c : C a b) :\n      p ▸D c = transport (λu : sigma _, C (u.1) (u.2)) (dpair_eq_dpair p (pathover_tr _ _)) c :=\n  by induction p; reflexivity\n\n  @[hott] def sigma_eq_eq_sigma_eq {p1 q1 : a = a'} {p2 : b =[p1] b'} {q2 : b =[q1] b'}\n      (r : p1 = q1) (s : p2 =[r; λ p, b =[p] b'] q2) : @sigma_eq _ _ ⟨a,b⟩ ⟨a',b'⟩ p1 p2 = sigma_eq q1 q2 :=\n  by induction s; reflexivity\n\n  /- A path between paths in a total space is commonly shown component wise. -/\n  @[hott] def sigma_eq2 {p q : u = v} (r : p..1 = q..1) (s : p..2 =[r; λ p, u.2 =[p] v.2] q..2)\n    : p = q :=\n  begin\n    induction p, induction u with u1 u2,\n    transitivity sigma_eq q..1 q..2,\n      apply sigma_eq_eq_sigma_eq r s,\n      apply sigma_eq_eta,\n  end\n\n  @[hott] def sigma_eq2_unc {p q : u = v} (rs : Σ(r : p..1 = q..1), p..2 =[r; λ p, u.2 =[p] v.2] q..2) : p = q :=\n  by apply destruct rs; apply sigma_eq2\n\n  @[hott] def ap_dpair_eq_dpair (f : Πa, B a → A') (p : a = a') (q : b =[p] b')\n    : @ap _ A' (@sigma.rec _ _ (λ _, A') f) _ _ (dpair_eq_dpair p q) = apd011 f p q :=\n  by induction q; reflexivity\n\n  /- Transport -/\n\n  /- The concrete description of transport in sigmas (and also pis) is rather trickier than in the other types.  In particular, these cannot be described just in terms of transport in simpler types; they require also the dependent transport [transportD].\n\n  In particular, this indicates why `transport` alone cannot be fully defined by induction on the structure of types, although Id-elim/transportD can be (cf. Observational Type _ Theory).  A more thorough set of lemmas, along the lines of the present ones but dealing with Id-elim rather than just transport, might be nice to have eventually? -/\n\n  @[hott] def sigma_transport (p : a = a') (bc : Σ(b : B a), C a b)\n    : p ▸ bc = ⟨p ▸ bc.1, p ▸D bc.2⟩ :=\n  by induction p; induction bc; reflexivity\n\n  /- The special case when the second variable doesn't depend on the first is simpler. -/\n  @[hott] def sigma_transport_nondep {B : Type _} {C : A → B → Type _} (p : a = a')\n    (bc : Σ(b : B), C a b) : p ▸ bc = ⟨bc.1, transport (λ a, C a bc.1) p bc.2⟩ :=\n  by induction p; induction bc; reflexivity\n\n  /- Or if the second variable contains a first component that doesn't depend on the first. -/\n\n  @[hott] def sigma_transport2_nondep {C : A → Type _} {D : Π a:A, B a → C a → Type _} (p : a = a')\n      (bcd : Σ(b : B a) (c : C a), D a b c) : p ▸ bcd = ⟨p ▸ bcd.1, p ▸ bcd.2.1, p ▸D2 bcd.2.2⟩ :=\n  begin\n    induction p, induction bcd with b cd, induction cd, reflexivity\n  end\n\n  /- Pathovers -/\n\n  @[hott] def etao (p : a = a') (bc : Σ(b : B a), C a b)\n    : bc =[p; λ a, Σ b, C a b] ⟨p ▸ bc.1, p ▸D bc.2⟩ :=\n  by induction p; induction bc; apply idpo\n\n  -- TODO: interchange sigma_pathover and sigma_pathover'\n  @[hott] def sigma_pathover (p : a = a') (u : Σ(b : B a), C a b) (v : Σ(b : B a'), C a' b)\n    (r : u.1 =[p] v.1) (s : u.2 =[apd011 C p r; id] v.2) : u =[p; λ a, Σ b, C a b] v :=\n  begin\n    induction u, induction v, dsimp at *, induction r,\n    dsimp [apd011] at s, apply idp_rec_on s, apply idpo\n  end\n\n  @[hott] def sigma_pathover' (p : a = a') (u : Σ(b : B a), C a b) (v : Σ(b : B a'), C a' b)\n    (r : u.1 =[p] v.1) (s : @pathover (sigma _) ⟨a,u.1⟩ (λ x, C x.1 x.2) u.2 ⟨a',v.1⟩ (sigma_eq p r) v.2) :\n    u =[p; λ a, Σ b, C a b] v :=\n  begin\n    induction u, induction v, dsimp at *, induction r,\n    apply idp_rec_on s, apply idpo\n  end\n\n  @[hott] def sigma_pathover_nondep {B : Type _} {C : A → B → Type _} (p : a = a')\n    (u : Σ(b : B), C a b) (v : Σ(b : B), C a' b)\n    (r : u.1 = v.1) (s : @pathover (prod _ _) (a,u.1) (λx, C x.1 x.2) u.2 (a',v.1) (prod.prod_eq p r) v.2) :\n    u =[p; λ a, Σ b, C a b] v :=\n  begin\n    induction p, induction u, induction v, dsimp at *, induction r,\n    apply idp_rec_on s, apply idpo\n  end\n\n  @[hott] def pathover_fst {A : Type _} {B : A → Type _} {C : Πa, B a → Type _}\n    {a a' : A} {p : a = a'} {x : Σb, C a b} {x' : Σb', C a' b'}\n    (q : x =[p; λ a, Σb, C a b] x') : x.1 =[p] x'.1 :=\n  begin induction q, constructor end\n\n  @[hott] def sigma_pathover_equiv_of_is_prop {A : Type _} {B : A → Type _} (C : Πa, B a → Type _)\n    {a a' : A} (p : a = a') (x : Σb, C a b) (x' : Σb', C a' b')\n    [Πa b, is_prop (C a b)] : x =[p; λa, Σb, C a b] x' ≃ x.1 =[p] x'.1 :=\n  begin\n    fapply equiv.MK,\n    { exact pathover_fst },\n    { intro q, induction x with b c, induction x' with b' c', dsimp at q, induction q,\n      apply pathover_idp_of_eq, exact sigma_eq idp (is_prop.elimo _ _ _) },\n    { intro q, induction x with b c, induction x' with b' c', dsimp at q, induction q,\n      have: c = c', by apply is_prop.elim, induction this,\n      dsimp, rwr is_prop_elimo_self, },\n    { intro q, induction q, induction x with b c,\n      dsimp [pathover_fst], rwr is_prop_elimo_self }\n  end\n\n  /-\n    TODO:\n    * define the projections from the type u =[p] v\n    * show that the uncurried version of sigma_pathover is an equivalence\n  -/\n  /- Squares in a sigma type are characterized in cubical.squareover (to avoid circular imports) -/\n\n  /- Functorial action -/\n  variables (f : A → A') (g : Πa, B a → B' (f a))\n\n  @[hott] def sigma_functor (u : Σa, B a) : Σa', B' a' :=\n  ⟨f u.1, g u.1 u.2⟩\n\n  @[hott] def total {B' : A → Type _} (g : Πa, B a → B' a) : (Σa, B a) → (Σa, B' a) :=\n  sigma_functor id g\n\n  /- Equivalences -/\n  @[hott] def is_equiv_sigma_functor [H1 : is_equiv f] [H2 : Π a, is_equiv (g a)]\n      : is_equiv (sigma_functor f g) :=\n  adjointify (sigma_functor f g)\n             (sigma_functor f⁻¹ᶠ (λ(a' : A') (b' : B' a'),\n               ((g (f⁻¹ᶠ a'))⁻¹ᶠ (transport B' (right_inv f a')⁻¹ b'))))\n  begin abstract {\n    intro u', induction u' with a' b', fapply sigma_eq,\n    {apply right_inv f},\n    {dsimp [sigma_functor], rwr right_inv (g (f⁻¹ᶠ a')), apply tr_pathover}\n  } end\n  begin abstract {\n    intro u, induction u with a b, fapply sigma_eq,\n    {apply left_inv f},\n    {apply pathover_of_tr_eq, dsimp only [sigma_functor],\n      rwr [adj f, ← fn_tr_eq_tr_fn (left_inv f a) (λ a, (g a)⁻¹ᶠ),\n        tr_compose B', tr_inv_tr], dsimp, rwr left_inv }\n  } end\n\n  @[hott] def sigma_equiv_sigma_of_is_equiv\n    [H1 : is_equiv f] [H2 : Π a, is_equiv (g a)] : (Σa, B a) ≃ (Σa', B' a') :=\n  equiv.mk (sigma_functor f g) (is_equiv_sigma_functor _ _)\n\n  @[hott] def sigma_equiv_sigma (Hf : A ≃ A') (Hg : Π a, B a ≃ B' (Hf a)) :\n      (Σa, B a) ≃ (Σa', B' a') :=\n  sigma_equiv_sigma_of_is_equiv Hf (λ a, Hg a)\n\n  @[hott] def sigma_equiv_sigma_right {B' : A → Type _} (Hg : Π a, B a ≃ B' a)\n    : (Σa, B a) ≃ Σa, B' a :=\n  sigma_equiv_sigma equiv.rfl Hg\n\n  variable (B)\n  @[hott] def sigma_equiv_sigma_left (Hf : A ≃ A') :\n    (Σa, B a) ≃ (Σa', B (Hf⁻¹ᶠ a')) :=\n  sigma_equiv_sigma Hf (λ a, equiv_ap B (right_inv Hf⁻¹ᶠ a)⁻¹ᵖ)\n\n  @[hott] def sigma_equiv_sigma_left' (Hf : A' ≃ A) : (Σa, B (Hf a)) ≃ (Σa', B a') :=\n  sigma_equiv_sigma Hf (λa, erfl)\n  variable {B}\n\n  @[hott] def ap_sigma_functor_eq_dpair (p : a = a') (q : b =[p] b') :\n    ap (sigma_functor f g) (@sigma_eq _ _ ⟨a,b⟩ ⟨a',b'⟩ p q) =\n      sigma_eq (ap f p) (by exact pathover.rec_on q idpo) :=\n  by induction q; reflexivity\n\n  @[hott] def sigma_ua {A B : Type _} (C : A ≃ B → Type _) :\n    (Σ(p : A = B), C (equiv_of_eq p)) ≃ Σ(e : A ≃ B), C e :=\n  sigma_equiv_sigma_left' C (eq_equiv_equiv _ _)\n\n  -- @[hott] def ap_sigma_functor_eq (p : u.1 = v.1) (q : u.2 =[p] v.2)\n  --   : ap (sigma_functor f g) (sigma_eq p q) =\n  --     sigma_eq (ap f p)\n  --      ((tr_compose B' f p (g u.1 u.2))⁻¹ ⬝ (fn_tr_eq_tr_fn p g u.2)⁻¹ ⬝ ap (g v.1) q) :=\n  -- by induction u; induction v; apply ap_sigma_functor_eq_dpair\n\n  /- definition 3.11.9(i): Summing up a contractible family of types does nothing. -/\n\n  @[hott, instance] def is_equiv_fst (B : A → Type _) [H : Π a, is_contr (B a)]\n      : is_equiv (@fst A B) :=\n  adjointify fst\n             (λa, ⟨a, center _⟩)\n             (λa, idp)\n             (λu, sigma_eq idp (pathover_idp_of_eq _ (center_eq _)))\n\n  @[hott] def sigma_equiv_of_is_contr_right (B : A → Type _) [H : Π a, is_contr (B a)]\n    : (Σa, B a) ≃ A :=\n  equiv.mk fst (by apply_instance)\n\n  /- definition 3.11.9(ii): Dually, summing up over a contractible type does nothing. -/\n\n  @[hott] def sigma_equiv_of_is_contr_left (B : A → Type _) [H : is_contr A]\n    : (Σa, B a) ≃ B (center A) :=\n  equiv.MK\n    (λu, (center_eq u.1)⁻¹ ▸ u.2)\n    (λb, ⟨center _, b⟩)\n    begin abstract { intro b, change _ = idpath (center A) ▸ b,\n      apply ap (λx, x ▸ b), apply prop_eq_of_is_contr, } end\n    begin abstract { exact λu, sigma_eq (center_eq _) (tr_pathover _ _) } end\n\n  /- Associativity -/\n\n  --this proof is harder than in Coq because we don't have eta definitionally for sigma\n  @[hott] def sigma_assoc_equiv (C : (Σa, B a) → Type _)\n    : (Σa b, C ⟨a, b⟩) ≃ (Σu, C u) :=\n  equiv.mk _ (adjointify\n    (λav, ⟨⟨av.1, av.2.1⟩, av.2.2⟩)\n    (λuc, ⟨uc.1.1, uc.1.2, by rwr sigma.eta; exact uc.2⟩)\n    begin abstract { intro uc, induction uc with u c, induction u, reflexivity } end\n    begin abstract { intro av, induction av with a v, induction v, reflexivity } end)\n\n  open prod\n  @[hott] def assoc_equiv_prod (C : (A × A') → Type _) : (Σa a', C (a,a')) ≃ (Σu, C u) :=\n  equiv.mk _ (adjointify\n    (λav, ⟨(av.1, av.2.1), av.2.2⟩)\n    (λuc, ⟨(uc.1).1, (uc.1).2, by rwr prod.eta; exact uc.2⟩)\n    (λ ⟨⟨a,b⟩,c⟩, idp) (λ ⟨a,⟨b,c⟩⟩, idp))\n\n  /- Symmetry -/\n\n  @[hott] def comm_equiv_unc (C : A × A' → Type _) : (Σa a', C (a, a')) ≃ (Σa' a, C (a, a')) :=\n  calc\n    (Σa a', C (a, a')) ≃ Σu, C u          : assoc_equiv_prod _\n                   ... ≃ Σv, C (flip v)   : sigma_equiv_sigma (prod.prod_comm_equiv _ _)\n                                              (λ ⟨a,a'⟩, equiv.rfl)\n                   ... ≃ Σa' a, C (a, a') : by symmetry; exact assoc_equiv_prod (C ∘ prod.flip)\n\n  @[hott] def sigma_comm_equiv (C : A → A' → Type _)\n    : (Σa a', C a a') ≃ (Σa' a, C a a') :=\n  comm_equiv_unc (λu, C (fst u) (snd u))\n\n  @[hott] def equiv_prod (A B : Type _) : (Σ(a : A), B) ≃ A × B :=\n  equiv.mk _ (adjointify\n    (λs, (s.1, s.2))\n    (λp, ⟨fst p, snd p⟩)\n    (λ⟨a,b⟩, idp) (λ⟨a,b⟩, idp))\n\n  @[hott] def comm_equiv_nondep (A B : Type _) : (Σ(a : A), B) ≃ Σ(b : B), A :=\n  calc\n    (Σ(a : A), B) ≃ A × B       : by apply equiv_prod\n              ... ≃ B × A       : by apply prod.prod_comm_equiv\n              ... ≃ Σ(b : B), A : by symmetry; apply equiv_prod\n\n  @[hott] def sigma_assoc_comm_equiv {A : Type _} (B C : A → Type _)\n    : (Σ(v : Σa, B a), C v.1) ≃ (Σ(u : Σa, C a), B u.1) :=\n  calc    (Σ(v : Σa, B a), C v.1)\n        ≃ (Σa (b : B a), C a)     : by symmetry; apply sigma_assoc_equiv (C ∘ fst)\n    ... ≃ (Σa (c : C a), B a)     : by apply sigma_equiv_sigma_right; intro a; apply comm_equiv_nondep\n    ... ≃ (Σ(u : Σa, C a), B u.1) : by apply sigma_assoc_equiv (B ∘ fst)\n\n  /- Interaction with other type constructors -/\n\n  @[hott] def sigma_empty_left (B : empty → Type _) : (Σx, B x) ≃ empty :=\n  begin\n    fapply equiv.MK,\n    { intro v, induction v, cases v_fst},\n    { intro x, cases x},\n    { intro x, cases x},\n    { intro v, induction v, cases v_fst},\n  end\n\n  @[hott] def sigma_empty_right (A : Type _) : (Σ(a : A), empty) ≃ empty :=\n  begin\n    fapply equiv.MK,\n    { intro v, induction v, cases v_snd},\n    { intro x, cases x},\n    { intro x, cases x},\n    { intro v, induction v, cases v_snd},\n  end\n\n  @[hott] def sigma_unit_left (B : unit → Type _) : (Σx, B x) ≃ B star :=\n  sigma_equiv_of_is_contr_left _\n\n  @[hott] def sigma_unit_right (A : Type _) : (Σ(a : A), unit) ≃ A :=\n  sigma_equiv_of_is_contr_right _\n\n  @[hott] def sigma_sum_left (B : A ⊎ A' → Type _)\n    : (Σp, B p) ≃ (Σa, B (inl a)) ⊎ (Σa, B (inr a)) :=\n  begin\n    fapply equiv.MK,\n    { intro v,\n      induction v with p b,\n      induction p,\n      { apply inl, constructor, assumption },\n      { apply inr, constructor, assumption }},\n    { intro p, induction p with v v; induction v; constructor; assumption},\n    { intro p, induction p with v v; induction v; reflexivity},\n    { intro v, induction v with p b, induction p; reflexivity},\n  end\n\n  @[hott] def sigma_sum_right (B C : A → Type _)\n    : (Σa, B a ⊎ C a) ≃ (Σa, B a) ⊎ (Σa, C a) :=\n  begin\n    fapply equiv.MK,\n    { intro v,\n      induction v with a p,\n      induction p,\n      { apply inl, constructor, assumption},\n      { apply inr, constructor, assumption}},\n    { intro p,\n      induction p with v v,\n      { induction v, constructor, apply inl, assumption },\n      { induction v, constructor, apply inr, assumption }},\n    { intro p, induction p with v v; induction v; reflexivity},\n    { intro v, induction v with a p, induction p; reflexivity},\n  end\n\n  @[hott] def sigma_sigma_eq_right {A : Type _} (a : A) (P : Π(b : A), a = b → Type _)\n    : (Σ(b : A) (p : a = b), P b p) ≃ P a idp :=\n  calc\n    (Σ(b : A) (p : a = b), P b p) ≃ (Σ(v : Σ(b : A), a = b), P v.1 v.2) : by apply sigma_assoc_equiv (λ u, P u.fst u.snd)\n      ... ≃ P a idp : by apply sigma_equiv_of_is_contr_left (λ v : Σ b, a=b, P v.fst v.snd)\n\n  @[hott] def sigma_sigma_eq_left {A : Type _} (a : A) (P : Π(b : A), b = a → Type _)\n    : (Σ(b : A) (p : b = a), P b p) ≃ P a idp :=\n  calc\n    (Σ(b : A) (p : b = a), P b p) ≃ (Σ(v : Σ(b : A), b = a), P v.1 v.2) : by apply sigma_assoc_equiv (λ u : Σ b, b=a, P u.fst u.snd)\n      ... ≃ P a idp : by apply sigma_equiv_of_is_contr_left (λ v : Σ b, b=a, P v.fst v.snd)\n\n  /- ** Universal mapping properties -/\n  /- *** The positive universal property. -/\n\n  section\n  @[hott, instance] def is_equiv_sigma_rec (C : (Σa, B a) → Type _)\n    : is_equiv (sigma.rec : (Πa b, C ⟨a, b⟩) → Πab, C ab) :=\n  adjointify _ (λ g a b, g ⟨a, b⟩)\n               (λ g, eq_of_homotopy (λ⟨a,b⟩, idp))\n               (λ f, refl f)\n\n  @[hott] def equiv_sigma_rec (C : (Σa, B a) → Type _)\n    : (Π(a : A) (b: B a), C ⟨a, b⟩) ≃ (Πxy, C xy) :=\n  equiv.mk sigma.rec (by apply_instance)\n\n  /- *** The negative universal property. -/\n\n  @[hott] protected def coind_unc (fg : Σ(f : Πa, B a), Πa, C a (f a)) (a : A)\n    : Σ(b : B a), C a b :=\n  ⟨fg.1 a, fg.2 a⟩\n\n  @[hott] protected def coind (f : Π a, B a) (g : Π a, C a (f a)) (a : A) : Σ(b : B a), C a b :=\n  sigma.coind_unc ⟨f, g⟩ a\n\n  --is the instance below dangerous?\n  --in Coq this can be done without function extensionality\n  @[hott, instance] def is_equiv_coind (C : Πa, B a → Type _)\n    : is_equiv (@sigma.coind_unc _ _ C) :=\n  adjointify _ (λ h, ⟨λa, (h a).1, λa, (h a).2⟩)\n               (λ h, eq_of_homotopy (λu, sigma.eta _))\n               (λ⟨f,g⟩, idp)\n\n  variable (C)\n  @[hott] def sigma_pi_equiv_pi_sigma : (Σ(f : Πa, B a), Πa, C a (f a)) ≃ (Πa, Σb, C a b) :=\n  equiv.mk sigma.coind_unc (by apply_instance)\n  variable {C}\n  end\n\n  /- Subtypes (sigma types whose second components are props) -/\n\n  @[hott] def subtype {A : Type _} (P : A → Type _) [H : Πa, is_prop (P a)] :=\n  Σ(a : A), P a\n  notation [parsing_only] `{` binder `|` r:(scoped:1 P, subtype P) `}` := r\n\n  /- To prove equality in a subtype, we only need equality of the first component. -/\n  @[hott] def subtype_eq [H : Πa, is_prop (B a)] {u v : {a | B a}} :\n    u.1 = v.1 → u = v :=\n  sigma_eq_unc ∘ inv fst\n\n  @[hott] def is_equiv_subtype_eq [H : Πa, is_prop (B a)] (u v : {a | B a})\n      : is_equiv (subtype_eq : u.1 = v.1 → u = v) :=\n  is_equiv_compose _ _\n  local attribute [instance] is_equiv_subtype_eq\n\n  @[hott] def equiv_subtype [H : Πa, is_prop (B a)] (u v : {a | B a}) :\n    (u.1 = v.1) ≃ (u = v) :=\n  equiv.mk subtype_eq (by apply_instance)\n\n  @[hott] def subtype_eq_equiv [H : Πa, is_prop (B a)] (u v : {a | B a}) :\n    (u = v) ≃ (u.1 = v.1) :=\n  (equiv_subtype u v)⁻¹ᵉ\n\n  @[hott] def subtype_eq_inv {A : Type _} {B : A → Type _} [H : Πa, is_prop (B a)] (u v : Σa, B a)\n    : u = v → u.1 = v.1 :=\n  subtype_eq⁻¹ᶠ\n\n  @[hott] def is_equiv_subtype_eq_inv {A : Type _} {B : A → Type _} [H : Πa, is_prop (B a)]\n    (u v : Σa, B a) : is_equiv (subtype_eq_inv u v) :=\n  by delta subtype_eq_inv; apply_instance\n\n  /- truncatedness -/\n  @[hott] def is_trunc_sigma (B : A → Type _) (n : trunc_index)\n      [HA : is_trunc n A] [HB : Πa, is_trunc n (B a)] : is_trunc n (Σa, B a) :=\n  begin\n  unfreezeI, revert A B HA HB,\n  induction n with n IH; resetI,\n  { intros A B HA HB, apply is_trunc_equiv_closed_rev -2 (sigma_equiv_of_is_contr_left B) (HB _) },\n  { intros A B HA HB, apply is_trunc_succ_intro, intros u v,\n    apply is_trunc_equiv_closed_rev _ (sigma_eq_equiv _ _) (IH _);\n    apply_instance }\n  end\n\n  @[hott] theorem is_trunc_subtype (B : A → Prop) (n : trunc_index)\n      [HA : is_trunc (n.+1) A] : is_trunc (n.+1) (Σa, B a) :=\n  @is_trunc_sigma _ (λ a, B a) (n.+1) _ (λa, is_trunc_succ_of_is_prop _ _)\n\n  /- if the total space is a mere proposition, you can equate two points in the base type by\n     finding points in their fibers -/\n  @[hott] def eq_base_of_is_prop_sigma {A : Type _} (B : A → Type _) (H : is_prop (Σa, B a)) {a a' : A}\n    (b : B a) (b' : B a') : a = a' :=\n  (@is_prop.elim (Σa, B a) _ ⟨a, b⟩ ⟨a', b'⟩)..1\n\nend sigma\n\nattribute [instance] sigma.is_trunc_sigma\nattribute [instance] sigma.is_trunc_subtype\n\nnamespace sigma\n\n  /- pointed sigma type -/\n  open pointed\n\n  @[hott, instance] def pointed_sigma {A : Type _} (P : A → Type _) [G : pointed A]\n      [H : pointed (P pt)] : pointed (Σx, P x) :=\n  pointed.mk ⟨pt,pt⟩\n\n  @[hott] def psigma {A : Type*} (P : A → Type*) : Type* :=\n  pointed.mk' (Σa, P a)\n\n  notation `Σ*` binders `, ` r:(scoped P, psigma P) := r\n\n  @[hott] def pfst {A : Type*} {B : A → Type*} : (Σ*(x : A), B x) →* A :=\n  pmap.mk fst idp\n\n  @[hott] def psnd {A : Type*} {B : A → Type*} (v : (Σ*(x : A), B x)) : B (pfst.to_fun v) :=\n  snd v\n\n  @[hott] def ptsigma {n : ℕ₋₂} {A : n-Type*} (P : A → (n-Type*)) : n-Type* :=\n  ptrunctype.mk' n (Σa, P a)\n\nend sigma\n\nend hott", "meta": {"author": "gebner", "repo": "hott3", "sha": "7ead7a8a2503049eacd45cbff6587802bae2add2", "save_path": "github-repos/lean/gebner-hott3", "path": "github-repos/lean/gebner-hott3/hott3-7ead7a8a2503049eacd45cbff6587802bae2add2/src/hott/types/sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.47931177553894294}}
{"text": "/-\nCopyright (c) 2014 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad, Leonardo de Moura\n-/\nimport tactic.ext tactic.finish data.subtype tactic.interactive\nopen function\n\n\n/- set coercion to a type -/\nnamespace set\ninstance {α : Type*} : has_coe_to_sort (set α) := ⟨_, λ s, {x // x ∈ s}⟩\nend set\n\nsection set_coe\nuniverse u\nvariables {α : Type u}\ntheorem set.set_coe_eq_subtype (s : set α) :\n  coe_sort.{(u+1) (u+2)} s = {x // x ∈ s} := rfl\n\n@[simp] theorem set_coe.forall {s : set α} {p : s → Prop} :\n  (∀ x : s, p x) ↔ (∀ x (h : x ∈ s), p ⟨x, h⟩) :=\nsubtype.forall\n\n@[simp] theorem set_coe.exists {s : set α} {p : s → Prop} :\n  (∃ x : s, p x) ↔ (∃ x (h : x ∈ s), p ⟨x, h⟩) :=\nsubtype.exists\n\n@[simp] theorem set_coe_cast : ∀ {s t : set α} (H' : s = t) (H : @eq (Type u) s t) (x : s),\n  cast H x = ⟨x.1, H' ▸ x.2⟩\n| s _ rfl _ ⟨x, h⟩ := rfl\n\ntheorem set_coe.ext {s : set α} {a b : s} : (↑a : α) = ↑b → a = b :=\nsubtype.eq\n\ntheorem set_coe.ext_iff {s : set α} {a b : s} : (↑a : α) = ↑b ↔ a = b :=\niff.intro set_coe.ext (assume h, h ▸ rfl)\n\nend set_coe\n\nlemma subtype.mem {α : Type*} {s : set α} (p : s) : (p : α) ∈ s := p.property\n\nnamespace set\nuniverses u v w x\nvariables {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {a : α} {s t : set α}\n\ninstance : inhabited (set α) := ⟨∅⟩\n\n@[extensionality]\ntheorem ext {a b : set α} (h : ∀ x, x ∈ a ↔ x ∈ b) : a = b :=\nfunext (assume x, propext (h x))\n\ntheorem ext_iff (s t : set α) : s = t ↔ ∀ x, x ∈ s ↔ x ∈ t :=\n⟨λ h x, by rw h, ext⟩\n\n@[trans] theorem mem_of_mem_of_subset {α : Type u} {x : α} {s t : set α} (hx : x ∈ s) (h : s ⊆ t) : x ∈ t :=\nh hx\n\n/- mem and set_of -/\n\n@[simp] theorem mem_set_of_eq {a : α} {p : α → Prop} : a ∈ {a | p a} = p a := rfl\n\n@[simp] theorem nmem_set_of_eq {a : α} {P : α → Prop} : a ∉ {a : α | P a} = ¬ P a := rfl\n\n@[simp] theorem set_of_mem_eq {s : set α} : {x | x ∈ s} = s := rfl\n\ntheorem mem_def {a : α} {s : set α} : a ∈ s ↔ s a := iff.rfl\n\ninstance decidable_mem (s : set α) [H : decidable_pred s] : ∀ a, decidable (a ∈ s) := H\n\ninstance decidable_set_of (p : α → Prop) [H : decidable_pred p] : decidable_pred {a | p a} := H\n\n@[simp] theorem set_of_subset_set_of {p q : α → Prop} : {a | p a} ⊆ {a | q a} ↔ (∀a, p a → q a) := iff.rfl\n\n@[simp] lemma sep_set_of {α} {p q : α → Prop} : {a ∈ {a | p a } | q a} = {a | p a ∧ q a} :=\nrfl\n\n@[simp] lemma set_of_mem {α} {s : set α} : {a | a ∈ s} = s := rfl\n\n/- subset -/\n\n-- TODO(Jeremy): write a tactic to unfold specific instances of generic notation?\ntheorem subset_def {s t : set α} : (s ⊆ t) = ∀ x, x ∈ s → x ∈ t := rfl\n\n@[refl] theorem subset.refl (a : set α) : a ⊆ a := assume x, id\n\n@[trans] theorem subset.trans {a b c : set α} (ab : a ⊆ b) (bc : b ⊆ c) : a ⊆ c :=\nassume x h, bc (ab h)\n\n@[trans] theorem mem_of_eq_of_mem {α : Type u} {x y : α} {s : set α} (hx : x = y) (h : y ∈ s) : x ∈ s :=\nhx.symm ▸ h\n\ntheorem subset.antisymm {a b : set α} (h₁ : a ⊆ b) (h₂ : b ⊆ a) : a = b :=\next (λ x, iff.intro (λ ina, h₁ ina) (λ inb, h₂ inb))\n\ntheorem subset.antisymm_iff {a b : set α} : a = b ↔ a ⊆ b ∧ b ⊆ a :=\n⟨λ e, e ▸ ⟨subset.refl _, subset.refl _⟩,\n λ ⟨h₁, h₂⟩, subset.antisymm h₁ h₂⟩\n\n-- an alterantive name\ntheorem eq_of_subset_of_subset {a b : set α} (h₁ : a ⊆ b) (h₂ : b ⊆ a) : a = b :=\nsubset.antisymm h₁ h₂\n\ntheorem mem_of_subset_of_mem {s₁ s₂ : set α} {a : α} : s₁ ⊆ s₂ → a ∈ s₁ → a ∈ s₂ :=\nassume h₁ h₂, h₁ h₂\n\ntheorem not_subset : (¬ s ⊆ t) ↔ ∃a, a ∈ s ∧ a ∉ t :=\nby simp [subset_def, classical.not_forall]\n\n/- strict subset -/\n\n/-- `s ⊂ t` means that `s` is a strict subset of `t`, that is, `s ⊆ t` but `s ≠ t`. -/\ndef strict_subset (s t : set α) := s ⊆ t ∧ s ≠ t\n\ninstance : has_ssubset (set α) := ⟨strict_subset⟩\n\ntheorem ssubset_def : (s ⊂ t) = (s ⊆ t ∧ s ≠ t) := rfl\n\nlemma exists_of_ssubset {α : Type u} {s t : set α} (h : s ⊂ t) : (∃x∈t, x ∉ s) :=\nclassical.by_contradiction $ assume hn,\n  have t ⊆ s, from assume a hat, classical.by_contradiction $ assume has, hn ⟨a, hat, has⟩,\n  h.2 $ subset.antisymm h.1 this\n\nlemma ssubset_iff_subset_not_subset {s t : set α} : s ⊂ t ↔ s ⊆ t ∧ ¬ t ⊆ s :=\nby split; simp [set.ssubset_def, ne.def, set.subset.antisymm_iff] {contextual := tt}\n\ntheorem not_mem_empty (x : α) : ¬ (x ∈ (∅ : set α)) :=\nassume h : x ∈ ∅, h\n\n@[simp] theorem not_not_mem [decidable (a ∈ s)] : ¬ (a ∉ s) ↔ a ∈ s :=\nnot_not\n\n/- empty set -/\n\ntheorem empty_def : (∅ : set α) = {x | false} := rfl\n\n@[simp] theorem mem_empty_eq (x : α) : x ∈ (∅ : set α) = false := rfl\n\n@[simp] theorem set_of_false : {a : α | false} = ∅ := rfl\n\ntheorem eq_empty_iff_forall_not_mem {s : set α} : s = ∅ ↔ ∀ x, x ∉ s :=\nby simp [ext_iff]\n\ntheorem ne_empty_of_mem {s : set α} {x : α} (h : x ∈ s) : s ≠ ∅ :=\nby { intro hs, rw hs at h, apply not_mem_empty _ h }\n\n@[simp] theorem empty_subset (s : set α) : ∅ ⊆ s :=\nassume x, assume h, false.elim h\n\ntheorem subset_empty_iff {s : set α} : s ⊆ ∅ ↔ s = ∅ :=\nby simp [subset.antisymm_iff]\n\ntheorem eq_empty_of_subset_empty {s : set α} : s ⊆ ∅ → s = ∅ :=\nsubset_empty_iff.1\n\ntheorem ne_empty_iff_exists_mem {s : set α} : s ≠ ∅ ↔ ∃ x, x ∈ s :=\nby haveI := classical.prop_decidable;\n   simp [eq_empty_iff_forall_not_mem]\n\ntheorem exists_mem_of_ne_empty {s : set α} : s ≠ ∅ → ∃ x, x ∈ s :=\nne_empty_iff_exists_mem.1\n\ntheorem coe_nonempty_iff_ne_empty {s : set α} : nonempty s ↔ s ≠ ∅ :=\nnonempty_subtype.trans ne_empty_iff_exists_mem.symm\n\n-- TODO: remove when simplifier stops rewriting `a ≠ b` to `¬ a = b`\ntheorem not_eq_empty_iff_exists {s : set α} : ¬ (s = ∅) ↔ ∃ x, x ∈ s :=\nne_empty_iff_exists_mem\n\ntheorem subset_eq_empty {s t : set α} (h : t ⊆ s) (e : s = ∅) : t = ∅ :=\nsubset_empty_iff.1 $ e ▸ h\n\ntheorem subset_ne_empty {s t : set α} (h : t ⊆ s) : t ≠ ∅ → s ≠ ∅ :=\nmt (subset_eq_empty h)\n\ntheorem ball_empty_iff {p : α → Prop} :\n  (∀ x ∈ (∅ : set α), p x) ↔ true :=\nby simp [iff_def]\n\n/- universal set -/\n\ntheorem univ_def : @univ α = {x | true} := rfl\n\n@[simp] theorem mem_univ (x : α) : x ∈ @univ α := trivial\n\ntheorem empty_ne_univ [h : inhabited α] : (∅ : set α) ≠ univ :=\nby simp [ext_iff]\n\n@[simp] theorem subset_univ (s : set α) : s ⊆ univ := λ x H, trivial\n\ntheorem univ_subset_iff {s : set α} : univ ⊆ s ↔ s = univ :=\nby simp [subset.antisymm_iff]\n\ntheorem eq_univ_of_univ_subset {s : set α} : univ ⊆ s → s = univ :=\nuniv_subset_iff.1\n\ntheorem eq_univ_iff_forall {s : set α} : s = univ ↔ ∀ x, x ∈ s :=\nby simp [ext_iff]\n\ntheorem eq_univ_of_forall {s : set α} : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2\n\n@[simp] lemma univ_eq_empty_iff {α : Type*} : (univ : set α) = ∅ ↔ ¬ nonempty α :=\neq_empty_iff_forall_not_mem.trans ⟨λ H ⟨x⟩, H x trivial, λ H x _, H ⟨x⟩⟩\n\nlemma nonempty_iff_univ_ne_empty {α : Type*} : nonempty α ↔ (univ : set α) ≠ ∅ :=\nby classical; exact iff_not_comm.1 univ_eq_empty_iff\n\nlemma exists_mem_of_nonempty (α) : ∀ [nonempty α], ∃x:α, x ∈ (univ : set α)\n| ⟨x⟩ := ⟨x, trivial⟩\n\n@[simp] lemma univ_ne_empty {α} [h : nonempty α] : (univ : set α) ≠ ∅ :=\nλ e, univ_eq_empty_iff.1 e h\n\ninstance univ_decidable : decidable_pred (@set.univ α) :=\nλ x, is_true trivial\n\n/- union -/\n\ntheorem union_def {s₁ s₂ : set α} : s₁ ∪ s₂ = {a | a ∈ s₁ ∨ a ∈ s₂} := rfl\n\ntheorem mem_union_left {x : α} {a : set α} (b : set α) : x ∈ a → x ∈ a ∪ b := or.inl\n\ntheorem mem_union_right {x : α} {b : set α} (a : set α) : x ∈ b → x ∈ a ∪ b := or.inr\n\ntheorem mem_or_mem_of_mem_union {x : α} {a b : set α} (H : x ∈ a ∪ b) : x ∈ a ∨ x ∈ b := H\n\ntheorem mem_union.elim {x : α} {a b : set α} {P : Prop}\n    (H₁ : x ∈ a ∪ b) (H₂ : x ∈ a → P) (H₃ : x ∈ b → P) : P :=\nor.elim H₁ H₂ H₃\n\ntheorem mem_union (x : α) (a b : set α) : x ∈ a ∪ b ↔ x ∈ a ∨ x ∈ b := iff.rfl\n\n@[simp] theorem mem_union_eq (x : α) (a b : set α) : x ∈ a ∪ b = (x ∈ a ∨ x ∈ b) := rfl\n\n@[simp] theorem union_self (a : set α) : a ∪ a = a :=\next (assume x, or_self _)\n\n@[simp] theorem union_empty (a : set α) : a ∪ ∅ = a :=\next (assume x, or_false _)\n\n@[simp] theorem empty_union (a : set α) : ∅ ∪ a = a :=\next (assume x, false_or _)\n\ntheorem union_comm (a b : set α) : a ∪ b = b ∪ a :=\next (assume x, or.comm)\n\ntheorem union_assoc (a b c : set α) : (a ∪ b) ∪ c = a ∪ (b ∪ c) :=\next (assume x, or.assoc)\n\ninstance union_is_assoc : is_associative (set α) (∪) :=\n⟨union_assoc⟩\n\ninstance union_is_comm : is_commutative (set α) (∪) :=\n⟨union_comm⟩\n\ntheorem union_left_comm (s₁ s₂ s₃ : set α) : s₁ ∪ (s₂ ∪ s₃) = s₂ ∪ (s₁ ∪ s₃) :=\nby finish\n\ntheorem union_right_comm (s₁ s₂ s₃ : set α) : (s₁ ∪ s₂) ∪ s₃ = (s₁ ∪ s₃) ∪ s₂ :=\nby finish\n\ntheorem union_eq_self_of_subset_left {s t : set α} (h : s ⊆ t) : s ∪ t = t :=\nby finish [subset_def, ext_iff, iff_def]\n\ntheorem union_eq_self_of_subset_right {s t : set α} (h : t ⊆ s) : s ∪ t = s :=\nby finish [subset_def, ext_iff, iff_def]\n\n@[simp] theorem subset_union_left (s t : set α) : s ⊆ s ∪ t := λ x, or.inl\n\n@[simp] theorem subset_union_right (s t : set α) : t ⊆ s ∪ t := λ x, or.inr\n\ntheorem union_subset {s t r : set α} (sr : s ⊆ r) (tr : t ⊆ r) : s ∪ t ⊆ r :=\nby finish [subset_def, union_def]\n\n@[simp] theorem union_subset_iff {s t u : set α} : s ∪ t ⊆ u ↔ s ⊆ u ∧ t ⊆ u :=\nby finish [iff_def, subset_def]\n\ntheorem union_subset_union {s₁ s₂ t₁ t₂ : set α} (h₁ : s₁ ⊆ s₂) (h₂ : t₁ ⊆ t₂) : s₁ ∪ t₁ ⊆ s₂ ∪ t₂ :=\nby finish [subset_def]\n\ntheorem union_subset_union_left {s₁ s₂ : set α} (t) (h : s₁ ⊆ s₂) : s₁ ∪ t ⊆ s₂ ∪ t :=\nunion_subset_union h (by refl)\n\ntheorem union_subset_union_right (s) {t₁ t₂ : set α} (h : t₁ ⊆ t₂) : s ∪ t₁ ⊆ s ∪ t₂ :=\nunion_subset_union (by refl) h\n\n@[simp] theorem union_empty_iff {s t : set α} : s ∪ t = ∅ ↔ s = ∅ ∧ t = ∅ :=\n⟨by finish [ext_iff], by finish [ext_iff]⟩\n\n/- intersection -/\n\ntheorem inter_def {s₁ s₂ : set α} : s₁ ∩ s₂ = {a | a ∈ s₁ ∧ a ∈ s₂} := rfl\n\ntheorem mem_inter_iff (x : α) (a b : set α) : x ∈ a ∩ b ↔ x ∈ a ∧ x ∈ b := iff.rfl\n\n@[simp] theorem mem_inter_eq (x : α) (a b : set α) : x ∈ a ∩ b = (x ∈ a ∧ x ∈ b) := rfl\n\ntheorem mem_inter {x : α} {a b : set α} (ha : x ∈ a) (hb : x ∈ b) : x ∈ a ∩ b :=\n⟨ha, hb⟩\n\ntheorem mem_of_mem_inter_left {x : α} {a b : set α} (h : x ∈ a ∩ b) : x ∈ a :=\nh.left\n\ntheorem mem_of_mem_inter_right {x : α} {a b : set α} (h : x ∈ a ∩ b) : x ∈ b :=\nh.right\n\n@[simp] theorem inter_self (a : set α) : a ∩ a = a :=\next (assume x, and_self _)\n\n@[simp] theorem inter_empty (a : set α) : a ∩ ∅ = ∅ :=\next (assume x, and_false _)\n\n@[simp] theorem empty_inter (a : set α) : ∅ ∩ a = ∅ :=\next (assume x, false_and _)\n\ntheorem inter_comm (a b : set α) : a ∩ b = b ∩ a :=\next (assume x, and.comm)\n\ntheorem inter_assoc (a b c : set α) : (a ∩ b) ∩ c = a ∩ (b ∩ c) :=\next (assume x, and.assoc)\n\ninstance inter_is_assoc : is_associative (set α) (∩) :=\n⟨inter_assoc⟩\n\ninstance inter_is_comm : is_commutative (set α) (∩) :=\n⟨inter_comm⟩\n\ntheorem inter_left_comm (s₁ s₂ s₃ : set α) : s₁ ∩ (s₂ ∩ s₃) = s₂ ∩ (s₁ ∩ s₃) :=\nby finish\n\ntheorem inter_right_comm (s₁ s₂ s₃ : set α) : (s₁ ∩ s₂) ∩ s₃ = (s₁ ∩ s₃) ∩ s₂ :=\nby finish\n\n@[simp] theorem inter_subset_left (s t : set α) : s ∩ t ⊆ s := λ x H, and.left H\n\n@[simp] theorem inter_subset_right (s t : set α) : s ∩ t ⊆ t := λ x H, and.right H\n\ntheorem subset_inter {s t r : set α} (rs : r ⊆ s) (rt : r ⊆ t) : r ⊆ s ∩ t :=\nby finish [subset_def, inter_def]\n\n@[simp] theorem subset_inter_iff {s t r : set α} : r ⊆ s ∩ t ↔ r ⊆ s ∧ r ⊆ t :=\n⟨λ h, ⟨subset.trans h (inter_subset_left _ _), subset.trans h (inter_subset_right _ _)⟩,\n λ ⟨h₁, h₂⟩, subset_inter h₁ h₂⟩\n\n@[simp] theorem inter_univ (a : set α) : a ∩ univ = a :=\next (assume x, and_true _)\n\n@[simp] theorem univ_inter (a : set α) : univ ∩ a = a :=\next (assume x, true_and _)\n\ntheorem inter_subset_inter_left {s t : set α} (u : set α) (H : s ⊆ t) : s ∩ u ⊆ t ∩ u :=\nby finish [subset_def]\n\ntheorem inter_subset_inter_right {s t : set α} (u : set α) (H : s ⊆ t) : u ∩ s ⊆ u ∩ t :=\nby finish [subset_def]\n\ntheorem inter_subset_inter {s₁ s₂ t₁ t₂ : set α} (h₁ : s₁ ⊆ t₁) (h₂ : s₂ ⊆ t₂) : s₁ ∩ s₂ ⊆ t₁ ∩ t₂ :=\nby finish [subset_def]\n\ntheorem inter_eq_self_of_subset_left {s t : set α} (h : s ⊆ t) : s ∩ t = s :=\nby finish [subset_def, ext_iff, iff_def]\n\ntheorem inter_eq_self_of_subset_right {s t : set α} (h : t ⊆ s) : s ∩ t = t :=\nby finish [subset_def, ext_iff, iff_def]\n\ntheorem union_inter_cancel_left {s t : set α} : (s ∪ t) ∩ s = s :=\nby finish [ext_iff, iff_def]\n\ntheorem union_inter_cancel_right {s t : set α} : (s ∪ t) ∩ t = t :=\nby finish [ext_iff, iff_def]\n\n-- TODO(Mario): remove?\ntheorem nonempty_of_inter_nonempty_right {s t : set α} (h : s ∩ t ≠ ∅) : t ≠ ∅ :=\nby finish [ext_iff, iff_def]\n\ntheorem nonempty_of_inter_nonempty_left {s t : set α} (h : s ∩ t ≠ ∅) : s ≠ ∅ :=\nby finish [ext_iff, iff_def]\n\n/- distributivity laws -/\n\ntheorem inter_distrib_left (s t u : set α) : s ∩ (t ∪ u) = (s ∩ t) ∪ (s ∩ u) :=\next (assume x, and_or_distrib_left)\n\ntheorem inter_distrib_right (s t u : set α) : (s ∪ t) ∩ u = (s ∩ u) ∪ (t ∩ u) :=\next (assume x, or_and_distrib_right)\n\ntheorem union_distrib_left (s t u : set α) : s ∪ (t ∩ u) = (s ∪ t) ∩ (s ∪ u) :=\next (assume x, or_and_distrib_left)\n\ntheorem union_distrib_right (s t u : set α) : (s ∩ t) ∪ u = (s ∪ u) ∩ (t ∪ u) :=\next (assume x, and_or_distrib_right)\n\n/- insert -/\n\ntheorem insert_def (x : α) (s : set α) : insert x s = { y | y = x ∨ y ∈ s } := rfl\n\n@[simp] theorem insert_of_has_insert (x : α) (s : set α) : has_insert.insert x s = insert x s := rfl\n\n@[simp] theorem subset_insert (x : α) (s : set α) : s ⊆ insert x s :=\nassume y ys, or.inr ys\n\ntheorem mem_insert (x : α) (s : set α) : x ∈ insert x s :=\nor.inl rfl\n\ntheorem mem_insert_of_mem {x : α} {s : set α} (y : α) : x ∈ s → x ∈ insert y s := or.inr\n\ntheorem eq_or_mem_of_mem_insert {x a : α} {s : set α} : x ∈ insert a s → x = a ∨ x ∈ s := id\n\ntheorem mem_of_mem_insert_of_ne {x a : α} {s : set α} (xin : x ∈ insert a s) : x ≠ a → x ∈ s :=\nby finish [insert_def]\n\n@[simp] theorem mem_insert_iff {x a : α} {s : set α} : x ∈ insert a s ↔ (x = a ∨ x ∈ s) := iff.rfl\n\n@[simp] theorem insert_eq_of_mem {a : α} {s : set α} (h : a ∈ s) : insert a s = s :=\nby finish [ext_iff, iff_def]\n\ntheorem insert_subset : insert a s ⊆ t ↔ (a ∈ t ∧ s ⊆ t) :=\nby simp [subset_def, or_imp_distrib, forall_and_distrib]\n\ntheorem insert_subset_insert (h : s ⊆ t) : insert a s ⊆ insert a t :=\nassume a', or.imp_right (@h a')\n\ntheorem ssubset_insert {s : set α} {a : α} (h : a ∉ s) : s ⊂ insert a s :=\nby finish [ssubset_def, ext_iff]\n\ntheorem insert_comm (a b : α) (s : set α) : insert a (insert b s) = insert b (insert a s) :=\next $ by simp [or.left_comm]\n\ntheorem insert_union : insert a s ∪ t = insert a (s ∪ t) :=\next $ assume a, by simp [or.comm, or.left_comm]\n\n@[simp] theorem union_insert : s ∪ insert a t = insert a (s ∪ t) :=\next $ assume a, by simp [or.comm, or.left_comm]\n\n-- TODO(Jeremy): make this automatic\ntheorem insert_ne_empty (a : α) (s : set α) : insert a s ≠ ∅ :=\nby safe [ext_iff, iff_def]; have h' := a_1 a; finish\n\n-- useful in proofs by induction\ntheorem forall_of_forall_insert {P : α → Prop} {a : α} {s : set α} (h : ∀ x, x ∈ insert a s → P x) :\n  ∀ x, x ∈ s → P x :=\nby finish\n\ntheorem forall_insert_of_forall {P : α → Prop} {a : α} {s : set α} (h : ∀ x, x ∈ s → P x) (ha : P a) :\n  ∀ x, x ∈ insert a s → P x :=\nby finish\n\ntheorem ball_insert_iff {P : α → Prop} {a : α} {s : set α} :\n  (∀ x ∈ insert a s, P x) ↔ P a ∧ (∀x ∈ s, P x) :=\nby finish [iff_def]\n\n/- singletons -/\n\ntheorem singleton_def (a : α) : ({a} : set α) = insert a ∅ := rfl\n\n@[simp] theorem mem_singleton_iff {a b : α} : a ∈ ({b} : set α) ↔ a = b :=\nby finish [singleton_def]\n\nlemma set_of_eq_eq_singleton {a : α} : {n | n = a} = {a} := set.ext $ λ n, (set.mem_singleton_iff).symm\n\n-- TODO: again, annotation needed\n@[simp] theorem mem_singleton (a : α) : a ∈ ({a} : set α) := by finish\n\ntheorem eq_of_mem_singleton {x y : α} (h : x ∈ ({y} : set α)) : x = y :=\nby finish\n\n@[simp] theorem singleton_eq_singleton_iff {x y : α} : {x} = ({y} : set α) ↔ x = y :=\nby finish [ext_iff, iff_def]\n\ntheorem mem_singleton_of_eq {x y : α} (H : x = y) : x ∈ ({y} : set α) :=\nby finish\n\ntheorem insert_eq (x : α) (s : set α) : insert x s = ({x} : set α) ∪ s :=\nby finish [ext_iff, or_comm]\n\n@[simp] theorem pair_eq_singleton (a : α) : ({a, a} : set α) = {a} :=\nby finish\n\n@[simp] theorem singleton_ne_empty (a : α) : ({a} : set α) ≠ ∅ := insert_ne_empty _ _\n\n@[simp] theorem singleton_subset_iff {a : α} {s : set α} : {a} ⊆ s ↔ a ∈ s :=\n⟨λh, h (by simp), λh b e, by simp at e; simp [*]⟩\n\ntheorem set_compr_eq_eq_singleton {a : α} : {b | b = a} = {a} :=\next $ by simp\n\n@[simp] theorem union_singleton : s ∪ {a} = insert a s :=\nby simp [singleton_def]\n\n@[simp] theorem singleton_union : {a} ∪ s = insert a s :=\nby rw [union_comm, union_singleton]\n\ntheorem singleton_inter_eq_empty : {a} ∩ s = ∅ ↔ a ∉ s :=\nby simp [eq_empty_iff_forall_not_mem]\n\ntheorem inter_singleton_eq_empty : s ∩ {a} = ∅ ↔ a ∉ s :=\nby rw [inter_comm, singleton_inter_eq_empty]\n\n/- separation -/\n\ntheorem mem_sep {s : set α} {p : α → Prop} {x : α} (xs : x ∈ s) (px : p x) : x ∈ {x ∈ s | p x} :=\n⟨xs, px⟩\n\n@[simp] theorem mem_sep_eq {s : set α} {p : α → Prop} {x : α} : x ∈ {x ∈ s | p x} = (x ∈ s ∧ p x) := rfl\n\ntheorem mem_sep_iff {s : set α} {p : α → Prop} {x : α} : x ∈ {x ∈ s | p x} ↔ x ∈ s ∧ p x :=\niff.rfl\n\ntheorem eq_sep_of_subset {s t : set α} (ssubt : s ⊆ t) : s = {x ∈ t | x ∈ s} :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem sep_subset (s : set α) (p : α → Prop) : {x ∈ s | p x} ⊆ s :=\nassume x, and.left\n\ntheorem forall_not_of_sep_empty {s : set α} {p : α → Prop} (h : {x ∈ s | p x} = ∅) :\n  ∀ x ∈ s, ¬ p x :=\nby finish [ext_iff]\n\n@[simp] lemma sep_univ {α} {p : α → Prop} : {a ∈ (univ : set α) | p a} = {a | p a} :=\nset.ext $ by simp\n\n/- complement -/\n\ntheorem mem_compl {s : set α} {x : α} (h : x ∉ s) : x ∈ -s := h\n\nlemma compl_set_of {α} (p : α → Prop) : - {a | p a} = { a | ¬ p a } := rfl\n\ntheorem not_mem_of_mem_compl {s : set α} {x : α} (h : x ∈ -s) : x ∉ s := h\n\n@[simp] theorem mem_compl_eq (s : set α) (x : α) : x ∈ -s = (x ∉ s) := rfl\n\ntheorem mem_compl_iff (s : set α) (x : α) : x ∈ -s ↔ x ∉ s := iff.rfl\n\n@[simp] theorem inter_compl_self (s : set α) : s ∩ -s = ∅ :=\nby finish [ext_iff]\n\n@[simp] theorem compl_inter_self (s : set α) : -s ∩ s = ∅ :=\nby finish [ext_iff]\n\n@[simp] theorem compl_empty : -(∅ : set α) = univ :=\nby finish [ext_iff]\n\n@[simp] theorem compl_union (s t : set α) : -(s ∪ t) = -s ∩ -t :=\nby finish [ext_iff]\n\n@[simp] theorem compl_compl (s : set α) : -(-s) = s :=\nby finish [ext_iff]\n\n-- ditto\ntheorem compl_inter (s t : set α) : -(s ∩ t) = -s ∪ -t :=\nby finish [ext_iff]\n\n@[simp] theorem compl_univ : -(univ : set α) = ∅ :=\nby finish [ext_iff]\n\ntheorem union_eq_compl_compl_inter_compl (s t : set α) : s ∪ t = -(-s ∩ -t) :=\nby simp [compl_inter, compl_compl]\n\ntheorem inter_eq_compl_compl_union_compl (s t : set α) : s ∩ t = -(-s ∪ -t) :=\nby simp [compl_compl]\n\n@[simp] theorem union_compl_self (s : set α) : s ∪ -s = univ :=\nby finish [ext_iff]\n\n@[simp] theorem compl_union_self (s : set α) : -s ∪ s = univ :=\nby finish [ext_iff]\n\ntheorem compl_comp_compl : compl ∘ compl = @id (set α) :=\nfunext compl_compl\n\ntheorem compl_subset_comm {s t : set α} : -s ⊆ t ↔ -t ⊆ s :=\nby haveI := classical.prop_decidable; exact\nforall_congr (λ a, not_imp_comm)\n\nlemma compl_subset_compl {s t : set α} : -s ⊆ -t ↔ t ⊆ s :=\nby rw [compl_subset_comm, compl_compl]\n\ntheorem compl_subset_iff_union {s t : set α} : -s ⊆ t ↔ s ∪ t = univ :=\niff.symm $ eq_univ_iff_forall.trans $ forall_congr $ λ a,\nby haveI := classical.prop_decidable; exact or_iff_not_imp_left\n\ntheorem subset_compl_comm {s t : set α} : s ⊆ -t ↔ t ⊆ -s :=\nforall_congr $ λ a, imp_not_comm\n\ntheorem subset_compl_iff_disjoint {s t : set α} : s ⊆ -t ↔ s ∩ t = ∅ :=\niff.trans (forall_congr $ λ a, and_imp.symm) subset_empty_iff\n\ntheorem inter_subset (a b c : set α) : a ∩ b ⊆ c ↔ a ⊆ -b ∪ c :=\nbegin\n  haveI := classical.prop_decidable,\n  split,\n  { intros h x xa, by_cases h' : x ∈ b, simp [h ⟨xa, h'⟩], simp [h'] },\n  intros h x, rintro ⟨xa, xb⟩, cases h xa, contradiction, assumption\nend\n\n/- set difference -/\n\ntheorem diff_eq (s t : set α) : s \\ t = s ∩ -t := rfl\n\n@[simp] theorem mem_diff {s t : set α} (x : α) : x ∈ s \\ t ↔ x ∈ s ∧ x ∉ t := iff.rfl\n\ntheorem mem_diff_of_mem {s t : set α} {x : α} (h1 : x ∈ s) (h2 : x ∉ t) : x ∈ s \\ t :=\n⟨h1, h2⟩\n\ntheorem mem_of_mem_diff {s t : set α} {x : α} (h : x ∈ s \\ t) : x ∈ s :=\nh.left\n\ntheorem not_mem_of_mem_diff {s t : set α} {x : α} (h : x ∈ s \\ t) : x ∉ t :=\nh.right\n\ntheorem union_diff_cancel {s t : set α} (h : s ⊆ t) : s ∪ (t \\ s) = t :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem union_diff_cancel_left {s t : set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \\ s = t :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem union_diff_cancel_right {s t : set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \\ t = s :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem union_diff_left {s t : set α} : (s ∪ t) \\ s = t \\ s :=\nby finish [ext_iff, iff_def]\n\ntheorem union_diff_right {s t : set α} : (s ∪ t) \\ t = s \\ t :=\nby finish [ext_iff, iff_def]\n\ntheorem union_diff_distrib {s t u : set α} : (s ∪ t) \\ u = s \\ u ∪ t \\ u :=\ninter_distrib_right _ _ _\n\ntheorem inter_diff_assoc (a b c : set α) : (a ∩ b) \\ c = a ∩ (b \\ c) :=\ninter_assoc _ _ _\n\ntheorem inter_diff_self (a b : set α) : a ∩ (b \\ a) = ∅ :=\nby finish [ext_iff]\n\ntheorem inter_union_diff (s t : set α) : (s ∩ t) ∪ (s \\ t) = s :=\nby finish [ext_iff, iff_def]\n\ntheorem diff_subset (s t : set α) : s \\ t ⊆ s :=\nby finish [subset_def]\n\ntheorem diff_subset_diff {s₁ s₂ t₁ t₂ : set α} : s₁ ⊆ s₂ → t₂ ⊆ t₁ → s₁ \\ t₁ ⊆ s₂ \\ t₂ :=\nby finish [subset_def]\n\ntheorem diff_subset_diff_left {s₁ s₂ t : set α} (h : s₁ ⊆ s₂) : s₁ \\ t ⊆ s₂ \\ t :=\ndiff_subset_diff h (by refl)\n\ntheorem diff_subset_diff_right {s t u : set α} (h : t ⊆ u) : s \\ u ⊆ s \\ t :=\ndiff_subset_diff (subset.refl s) h\n\ntheorem compl_eq_univ_diff (s : set α) : -s = univ \\ s :=\nby finish [ext_iff]\n\n@[simp] lemma empty_diff {α : Type*} (s : set α) : (∅ \\ s : set α) = ∅ :=\neq_empty_of_subset_empty $ assume x ⟨hx, _⟩, hx\n\ntheorem diff_eq_empty {s t : set α} : s \\ t = ∅ ↔ s ⊆ t :=\n⟨assume h x hx, classical.by_contradiction $ assume : x ∉ t, show x ∈ (∅ : set α), from h ▸ ⟨hx, this⟩,\n  assume h, eq_empty_of_subset_empty $ assume x ⟨hx, hnx⟩, hnx $ h hx⟩\n\n@[simp] theorem diff_empty {s : set α} : s \\ ∅ = s :=\next $ assume x, ⟨assume ⟨hx, _⟩, hx, assume h, ⟨h, not_false⟩⟩\n\ntheorem diff_diff {u : set α} : s \\ t \\ u = s \\ (t ∪ u) :=\next $ by simp [not_or_distrib, and.comm, and.left_comm]\n\nlemma diff_subset_iff {s t u : set α} : s \\ t ⊆ u ↔ s ⊆ t ∪ u :=\n⟨assume h x xs, classical.by_cases or.inl (assume nxt, or.inr (h ⟨xs, nxt⟩)),\n assume h x ⟨xs, nxt⟩, or.resolve_left (h xs) nxt⟩\n\nlemma diff_subset_comm {s t u : set α} : s \\ t ⊆ u ↔ s \\ u ⊆ t :=\nby rw [diff_subset_iff, diff_subset_iff, union_comm]\n\n@[simp] theorem insert_diff (h : a ∈ t) : insert a s \\ t = s \\ t :=\next $ by intro; constructor; simp [or_imp_distrib, h] {contextual := tt}\n\ntheorem union_diff_self {s t : set α} : s ∪ (t \\ s) = s ∪ t :=\nby finish [ext_iff, iff_def]\n\ntheorem diff_union_self {s t : set α} : (s \\ t) ∪ t = s ∪ t :=\nby rw [union_comm, union_diff_self, union_comm]\n\ntheorem diff_inter_self {a b : set α} : (b \\ a) ∩ a = ∅ :=\next $ by simp [iff_def] {contextual:=tt}\n\ntheorem diff_eq_self {s t : set α} : s \\ t = s ↔ t ∩ s ⊆ ∅ :=\nby finish [ext_iff, iff_def, subset_def]\n\n@[simp] theorem diff_singleton_eq_self {a : α} {s : set α} (h : a ∉ s) : s \\ {a} = s :=\ndiff_eq_self.2 $ by simp [singleton_inter_eq_empty.2 h]\n\n@[simp] theorem insert_diff_singleton {a : α} {s : set α} :\n  insert a (s \\ {a}) = insert a s :=\nby simp [insert_eq, union_diff_self, -union_singleton, -singleton_union]\n\n@[simp] lemma diff_self {s : set α} : s \\ s = ∅ := ext $ by simp\n\n/- powerset -/\n\ntheorem mem_powerset {x s : set α} (h : x ⊆ s) : x ∈ powerset s := h\n\ntheorem subset_of_mem_powerset {x s : set α} (h : x ∈ powerset s) : x ⊆ s := h\n\ntheorem mem_powerset_iff (x s : set α) : x ∈ powerset s ↔ x ⊆ s := iff.rfl\n\n/- inverse image -/\n\n/-- The preimage of `s : set β` by `f : α → β`, written `f ⁻¹' s`,\n  is the set of `x : α` such that `f x ∈ s`. -/\ndef preimage {α : Type u} {β : Type v} (f : α → β) (s : set β) : set α := {x | f x ∈ s}\n\ninfix ` ⁻¹' `:80 := preimage\n\nsection preimage\nvariables {f : α → β} {g : β → γ}\n\n@[simp] theorem preimage_empty : f ⁻¹' ∅ = ∅ := rfl\n\n@[simp] theorem mem_preimage_eq {s : set β} {a : α} : (a ∈ f ⁻¹' s) = (f a ∈ s) := rfl\n\ntheorem preimage_mono {s t : set β} (h : s ⊆ t) : f ⁻¹' s ⊆ f ⁻¹' t :=\nassume x hx, h hx\n\n@[simp] theorem preimage_univ : f ⁻¹' univ = univ := rfl\n\n@[simp] theorem preimage_inter {s t : set β} : f ⁻¹' (s ∩ t) = f ⁻¹' s ∩ f ⁻¹' t := rfl\n\n@[simp] theorem preimage_union {s t : set β} : f ⁻¹' (s ∪ t) = f ⁻¹' s ∪ f ⁻¹' t := rfl\n\n@[simp] theorem preimage_compl {s : set β} : f ⁻¹' (- s) = - (f ⁻¹' s) := rfl\n\n@[simp] theorem preimage_diff (f : α → β) (s t : set β) :\n  f ⁻¹' (s \\ t) = f ⁻¹' s \\ f ⁻¹' t := rfl\n\n@[simp] theorem preimage_set_of_eq {p : α → Prop} {f : β → α} : f ⁻¹' {a | p a} = {a | p (f a)} :=\nrfl\n\ntheorem preimage_id {s : set α} : id ⁻¹' s = s := rfl\n\ntheorem preimage_comp {s : set γ} : (g ∘ f) ⁻¹' s = f ⁻¹' (g ⁻¹' s) := rfl\n\ntheorem eq_preimage_subtype_val_iff {p : α → Prop} {s : set (subtype p)} {t : set α} :\n  s = subtype.val ⁻¹' t ↔ (∀x (h : p x), (⟨x, h⟩ : subtype p) ∈ s ↔ x ∈ t) :=\n⟨assume s_eq x h, by rw [s_eq]; simp,\n assume h, ext $ assume ⟨x, hx⟩, by simp [h]⟩\n\nend preimage\n\n/- function image -/\n\nsection image\n\ninfix ` '' `:80 := image\n\n/-- Two functions `f₁ f₂ : α → β` are equal on `s`\n  if `f₁ x = f₂ x` for all `x ∈ a`. -/\n@[reducible] def eq_on (f1 f2 : α → β) (a : set α) : Prop :=\n∀ x ∈ a, f1 x = f2 x\n\n-- TODO(Jeremy): use bounded exists in image\n\ntheorem mem_image_iff_bex {f : α → β} {s : set α} {y : β} :\n  y ∈ f '' s ↔ ∃ x (_ : x ∈ s), f x = y := bex_def.symm\n\ntheorem mem_image_eq (f : α → β) (s : set α) (y: β) : y ∈ f '' s = ∃ x, x ∈ s ∧ f x = y := rfl\n\n@[simp] theorem mem_image (f : α → β) (s : set α) (y : β) : y ∈ f '' s ↔ ∃ x, x ∈ s ∧ f x = y := iff.rfl\n\ntheorem mem_image_of_mem (f : α → β) {x : α} {a : set α} (h : x ∈ a) : f x ∈ f '' a :=\n⟨_, h, rfl⟩\n\ntheorem mem_image_of_injective {f : α → β} {a : α} {s : set α} (hf : injective f) :\n  f a ∈ f '' s ↔ a ∈ s :=\niff.intro\n  (assume ⟨b, hb, eq⟩, (hf eq) ▸ hb)\n  (assume h, mem_image_of_mem _ h)\n\ntheorem ball_image_of_ball {f : α → β} {s : set α} {p : β → Prop}\n  (h : ∀ x ∈ s, p (f x)) : ∀ y ∈ f '' s, p y :=\nby finish [mem_image_eq]\n\n@[simp] theorem ball_image_iff {f : α → β} {s : set α} {p : β → Prop} :\n  (∀ y ∈ f '' s, p y) ↔ (∀ x ∈ s, p (f x)) :=\niff.intro\n  (assume h a ha, h _ $ mem_image_of_mem _ ha)\n  (assume h b ⟨a, ha, eq⟩, eq ▸ h a ha)\n\ntheorem mono_image {f : α → β} {s t : set α} (h : s ⊆ t) : f '' s ⊆ f '' t :=\nassume x ⟨y, hy, y_eq⟩, y_eq ▸ mem_image_of_mem _ $ h hy\n\ntheorem mem_image_elim {f : α → β} {s : set α} {C : β → Prop} (h : ∀ (x : α), x ∈ s → C (f x)) :\n ∀{y : β}, y ∈ f '' s → C y\n| ._ ⟨a, a_in, rfl⟩ := h a a_in\n\ntheorem mem_image_elim_on {f : α → β} {s : set α} {C : β → Prop} {y : β} (h_y : y ∈ f '' s)\n  (h : ∀ (x : α), x ∈ s → C (f x)) : C y :=\nmem_image_elim h h_y\n\n@[congr] lemma image_congr {f g : α → β} {s : set α}\n  (h : ∀a∈s, f a = g a) : f '' s = g '' s :=\nby safe [ext_iff, iff_def]\n\ntheorem image_eq_image_of_eq_on {f₁ f₂ : α → β} {s : set α} (heq : eq_on f₁ f₂ s) :\n  f₁ '' s = f₂ '' s :=\nimage_congr heq\n\ntheorem image_comp (f : β → γ) (g : α → β) (a : set α) : (f ∘ g) '' a = f '' (g '' a) :=\nsubset.antisymm\n  (ball_image_of_ball $ assume a ha, mem_image_of_mem _ $ mem_image_of_mem _ ha)\n  (ball_image_of_ball $ ball_image_of_ball $ assume a ha, mem_image_of_mem _ ha)\n/- Proof is removed as it uses generated names\nTODO(Jeremy): make automatic,\nbegin\n  safe [ext_iff, iff_def, mem_image, (∘)],\n  have h' := h_2 (g a_2),\n  finish\nend -/\n\ntheorem image_subset {a b : set α} (f : α → β) (h : a ⊆ b) : f '' a ⊆ f '' b :=\nby finish [subset_def, mem_image_eq]\n\ntheorem image_union (f : α → β) (s t : set α) :\n  f '' (s ∪ t) = f '' s ∪ f '' t :=\nby finish [ext_iff, iff_def, mem_image_eq]\n\n@[simp] theorem image_empty (f : α → β) : f '' ∅ = ∅ := ext $ by simp\n\ntheorem image_inter_on {f : α → β} {s t : set α} (h : ∀x∈t, ∀y∈s, f x = f y → x = y) :\n  f '' s ∩ f '' t = f '' (s ∩ t) :=\nsubset.antisymm\n  (assume b ⟨⟨a₁, ha₁, h₁⟩, ⟨a₂, ha₂, h₂⟩⟩,\n    have a₂ = a₁, from h _ ha₂ _ ha₁ (by simp *),\n    ⟨a₁, ⟨ha₁, this ▸ ha₂⟩, h₁⟩)\n  (subset_inter (mono_image $ inter_subset_left _ _) (mono_image $ inter_subset_right _ _))\n\ntheorem image_inter {f : α → β} {s t : set α} (H : injective f) :\n  f '' s ∩ f '' t = f '' (s ∩ t) :=\nimage_inter_on (assume x _ y _ h, H h)\n\ntheorem image_univ_of_surjective {ι : Type*} {f : ι → β} (H : surjective f) : f '' univ = univ :=\neq_univ_of_forall $ by simp [image]; exact H\n\n@[simp] theorem image_singleton {f : α → β} {a : α} : f '' {a} = {f a} :=\next $ λ x, by simp [image]; rw eq_comm\n\n@[simp] lemma image_eq_empty {α β} {f : α → β} {s : set α} : f '' s = ∅ ↔ s = ∅ :=\nby simp only [eq_empty_iff_forall_not_mem]; exact\n⟨λ H a ha, H _ ⟨_, ha, rfl⟩, λ H b ⟨_, ha, _⟩, H _ ha⟩\n\nlemma inter_singleton_ne_empty {α : Type*} {s : set α} {a : α} : s ∩ {a} ≠ ∅ ↔ a ∈ s :=\nby finish  [set.inter_singleton_eq_empty]\n\ntheorem fix_set_compl (t : set α) : compl t = - t := rfl\n\n-- TODO(Jeremy): there is an issue with - t unfolding to compl t\ntheorem mem_compl_image (t : set α) (S : set (set α)) :\n  t ∈ compl '' S ↔ -t ∈ S :=\nbegin\n  suffices : ∀ x, -x = t ↔ -t = x, {simp [fix_set_compl, this]},\n  intro x, split; { intro e, subst e, simp }\nend\n\n@[simp] theorem image_id (s : set α) : id '' s = s := ext $ by simp\n\ntheorem compl_compl_image (S : set (set α)) :\n  compl '' (compl '' S) = S :=\nby rw [← image_comp, compl_comp_compl, image_id]\n\ntheorem image_insert_eq {f : α → β} {a : α} {s : set α} :\n  f '' (insert a s) = insert (f a) (f '' s) :=\next $ by simp [and_or_distrib_left, exists_or_distrib, eq_comm, or_comm, and_comm]\n\ntheorem image_subset_preimage_of_inverse {f : α → β} {g : β → α}\n  (I : left_inverse g f) (s : set α) : f '' s ⊆ g ⁻¹' s :=\nλ b ⟨a, h, e⟩, e ▸ ((I a).symm ▸ h : g (f a) ∈ s)\n\ntheorem preimage_subset_image_of_inverse {f : α → β} {g : β → α}\n  (I : left_inverse g f) (s : set β) : f ⁻¹' s ⊆ g '' s :=\nλ b h, ⟨f b, h, I b⟩\n\ntheorem image_eq_preimage_of_inverse {f : α → β} {g : β → α}\n  (h₁ : left_inverse g f) (h₂ : right_inverse g f) :\n  image f = preimage g :=\nfunext $ λ s, subset.antisymm\n  (image_subset_preimage_of_inverse h₁ s)\n  (preimage_subset_image_of_inverse h₂ s)\n\ntheorem mem_image_iff_of_inverse {f : α → β} {g : β → α} {b : β} {s : set α}\n  (h₁ : left_inverse g f) (h₂ : right_inverse g f) :\n  b ∈ f '' s ↔ g b ∈ s :=\nby rw image_eq_preimage_of_inverse h₁ h₂; refl\n\ntheorem image_compl_subset {f : α → β} {s : set α} (H : injective f) : f '' -s ⊆ -(f '' s) :=\nsubset_compl_iff_disjoint.2 $ by simp [image_inter H]\n\ntheorem subset_image_compl {f : α → β} {s : set α} (H : surjective f) : -(f '' s) ⊆ f '' -s :=\ncompl_subset_iff_union.2 $\nby rw ← image_union; simp [image_univ_of_surjective H]\n\ntheorem image_compl_eq {f : α → β} {s : set α} (H : bijective f) : f '' -s = -(f '' s) :=\nsubset.antisymm (image_compl_subset H.1) (subset_image_compl H.2)\n\n/- image and preimage are a Galois connection -/\ntheorem image_subset_iff {s : set α} {t : set β} {f : α → β} :\n  f '' s ⊆ t ↔ s ⊆ f ⁻¹' t :=\nball_image_iff\n\ntheorem image_preimage_subset (f : α → β) (s : set β) :\n  f '' (f ⁻¹' s) ⊆ s :=\nimage_subset_iff.2 (subset.refl _)\n\ntheorem subset_preimage_image (f : α → β) (s : set α) :\n  s ⊆ f ⁻¹' (f '' s) :=\nλ x, mem_image_of_mem f\n\ntheorem preimage_image_eq {f : α → β} (s : set α) (h : injective f) : f ⁻¹' (f '' s) = s :=\nsubset.antisymm\n  (λ x ⟨y, hy, e⟩, h e ▸ hy)\n  (subset_preimage_image f s)\n\ntheorem image_preimage_eq {f : α → β} {s : set β} (h : surjective f) : f '' (f ⁻¹' s) = s :=\nsubset.antisymm\n  (image_preimage_subset f s)\n  (λ x hx, let ⟨y, e⟩ := h x in ⟨y, (e.symm ▸ hx : f y ∈ s), e⟩)\n\nlemma preimage_eq_preimage {f : β → α} (hf : surjective f) : f ⁻¹' s = preimage f t ↔ s = t :=\niff.intro\n  (assume eq, by rw [← @image_preimage_eq β α f s hf, ← @image_preimage_eq β α f t hf, eq])\n  (assume eq, eq ▸ rfl)\n\nlemma surjective_preimage {f : β → α} (hf : surjective f) : injective (preimage f) :=\nassume s t, (preimage_eq_preimage hf).1\n\ntheorem compl_image : image (@compl α) = preimage compl :=\nimage_eq_preimage_of_inverse compl_compl compl_compl\n\ntheorem compl_image_set_of {α : Type u} {p : set α → Prop} :\n  compl '' {x | p x} = {x | p (- x)} :=\ncongr_fun compl_image p\n\ntheorem inter_preimage_subset (s : set α) (t : set β) (f : α → β) :\n  s ∩ f ⁻¹' t ⊆ f ⁻¹' (f '' s ∩ t) :=\nλ x h, ⟨mem_image_of_mem _ h.left, h.right⟩\n\ntheorem union_preimage_subset (s : set α) (t : set β) (f : α → β) :\n  s ∪ f ⁻¹' t ⊆ f ⁻¹' (f '' s ∪ t) :=\nλ x h, or.elim h (λ l, or.inl $ mem_image_of_mem _ l) (λ r, or.inr r)\n\ntheorem subset_image_union (f : α → β) (s : set α) (t : set β) :\n  f '' (s ∪ f ⁻¹' t) ⊆ f '' s ∪ t :=\nimage_subset_iff.2 (union_preimage_subset _ _ _)\n\nlemma preimage_subset_iff {A : set α} {B : set β} {f : α → β} :\n  f⁻¹' B ⊆ A ↔ (∀ a : α, f a ∈ B → a ∈ A) := iff.rfl\n\nlemma image_eq_image {f : α → β} (hf : injective f) : f '' s = f '' t ↔ s = t :=\niff.symm $ iff.intro (assume eq, eq ▸ rfl) $ assume eq,\n  by rw [← preimage_image_eq s hf, ← preimage_image_eq t hf, eq]\n\nlemma image_subset_image_iff {f : α → β} (hf : injective f) : f '' s ⊆ f '' t ↔ s ⊆ t :=\nbegin\n  refine (iff.symm $ iff.intro (image_subset f) $ assume h, _),\n  rw [← preimage_image_eq s hf, ← preimage_image_eq t hf],\n  exact preimage_mono h\nend\n\nlemma injective_image {f : α → β} (hf : injective f) : injective (('') f) :=\nassume s t, (image_eq_image hf).1\n\nlemma prod_quotient_preimage_eq_image [s : setoid α] (g : quotient s → β) {h : α → β}\n  (Hh : h = g ∘ quotient.mk) (r : set (β × β)) :\n  {x : quotient s × quotient s | (g x.1, g x.2) ∈ r} =\n  (λ a : α × α, (⟦a.1⟧, ⟦a.2⟧)) '' ((λ a : α × α, (h a.1, h a.2)) ⁻¹' r) :=\nHh.symm ▸ set.ext (λ ⟨a₁, a₂⟩, ⟨quotient.induction_on₂ a₁ a₂\n  (λ a₁ a₂ h, ⟨(a₁, a₂), h, rfl⟩),\n  λ ⟨⟨b₁, b₂⟩, h₁, h₂⟩, show (g a₁, g a₂) ∈ r, from\n  have h₃ : ⟦b₁⟧ = a₁ ∧ ⟦b₂⟧ = a₂ := prod.ext_iff.1 h₂,\n    h₃.1 ▸ h₃.2 ▸ h₁⟩)\n\ndef image_factorization (f : α → β) (s : set α) : s → f '' s :=\nλ p, ⟨f p.1, mem_image_of_mem f p.2⟩\n\nlemma image_factorization_eq {f : α → β} {s : set α} :\n  subtype.val ∘ image_factorization f s = f ∘ subtype.val :=\nfunext $ λ p, rfl\n\nlemma surjective_onto_image {f : α → β} {s : set α} :\n  surjective (image_factorization f s) :=\nλ ⟨_, ⟨a, ha, rfl⟩⟩, ⟨⟨a, ha⟩, rfl⟩\n\nend image\n\ntheorem univ_eq_true_false : univ = ({true, false} : set Prop) :=\neq.symm $ eq_univ_of_forall $ classical.cases (by simp) (by simp)\n\nsection range\nvariables {f : ι → α}\nopen function\n\n/-- Range of a function.\n\nThis function is more flexible than `f '' univ`, as the image requires that the domain is in Type\nand not an arbitrary Sort. -/\ndef range (f : ι → α) : set α := {x | ∃y, f y = x}\n\n@[simp] theorem mem_range {x : α} : x ∈ range f ↔ ∃ y, f y = x := iff.rfl\n\ntheorem mem_range_self (i : ι) : f i ∈ range f := ⟨i, rfl⟩\n\ntheorem forall_range_iff {p : α → Prop} : (∀ a ∈ range f, p a) ↔ (∀ i, p (f i)) :=\n⟨assume h i, h (f i) (mem_range_self _), assume h a ⟨i, (hi : f i = a)⟩, hi ▸ h i⟩\n\ntheorem exists_range_iff {p : α → Prop} : (∃ a ∈ range f, p a) ↔ (∃ i, p (f i)) :=\n⟨assume ⟨a, ⟨i, eq⟩, h⟩, ⟨i, eq.symm ▸ h⟩, assume ⟨i, h⟩, ⟨f i, mem_range_self _, h⟩⟩\n\ntheorem range_iff_surjective : range f = univ ↔ surjective f :=\neq_univ_iff_forall\n\n@[simp] theorem range_id : range (@id α) = univ := range_iff_surjective.2 surjective_id\n\n@[simp] theorem image_univ {ι : Type*} {f : ι → β} : f '' univ = range f :=\next $ by simp [image, range]\n\ntheorem image_subset_range {ι : Type*} (f : ι → β) (s : set ι) : f '' s ⊆ range f :=\nby rw ← image_univ; exact image_subset _ (subset_univ _)\n\ntheorem range_comp {g : α → β} : range (g ∘ f) = g '' range f :=\nsubset.antisymm\n  (forall_range_iff.mpr $ assume i, mem_image_of_mem g (mem_range_self _))\n  (ball_image_iff.mpr $ forall_range_iff.mpr mem_range_self)\n\ntheorem range_subset_iff {ι : Type*} {f : ι → β} {s : set β} : range f ⊆ s ↔ ∀ y, f y ∈ s :=\nforall_range_iff\n\nlemma nonempty_of_nonempty_range {α : Type*} {β : Type*} {f : α → β} (H : ¬range f = ∅) : nonempty α :=\nbegin\n  cases exists_mem_of_ne_empty H with x h,\n  cases mem_range.1 h with y _,\n  exact ⟨y⟩\nend\n\n@[simp] lemma range_eq_empty {α : Type u} {β : Type v} {f : α → β} : range f = ∅ ↔ ¬ nonempty α :=\nby rw ← set.image_univ; simp [-set.image_univ]\n\ntheorem image_preimage_eq_inter_range {f : α → β} {t : set β} :\n  f '' (f ⁻¹' t) = t ∩ range f :=\next $ assume x, ⟨assume ⟨x, hx, heq⟩, heq ▸ ⟨hx, mem_range_self _⟩,\n  assume ⟨hx, ⟨y, h_eq⟩⟩, h_eq ▸ mem_image_of_mem f $\n    show y ∈ f ⁻¹' t, by simp [preimage, h_eq, hx]⟩\n\nlemma image_preimage_eq_of_subset {f : α → β} {s : set β} (hs : s ⊆ range f) :\n  f '' (f ⁻¹' s) = s :=\nby rw [image_preimage_eq_inter_range, inter_eq_self_of_subset_left hs]\n\ntheorem preimage_inter_range {f : α → β} {s : set β} : f ⁻¹' (s ∩ range f) = f ⁻¹' s :=\nset.ext $ λ x, and_iff_left ⟨x, rfl⟩\n\ntheorem preimage_image_preimage {f : α → β} {s : set β} :\n  f ⁻¹' (f '' (f ⁻¹' s)) = f ⁻¹' s :=\nby rw [image_preimage_eq_inter_range, preimage_inter_range]\n\n@[simp] theorem quot_mk_range_eq [setoid α] : range (λx : α, ⟦x⟧) = univ :=\nrange_iff_surjective.2 quot.exists_rep\n\nlemma range_const_subset {c : β} : range (λx:α, c) ⊆ {c} :=\nrange_subset_iff.2 $ λ x, or.inl rfl\n\n@[simp] lemma range_const [h : nonempty α] {c : β} : range (λx:α, c) = {c} :=\nbegin\n  refine subset.antisymm range_const_subset (λy hy, _),\n  rw set.mem_singleton_iff.1 hy,\n  rcases exists_mem_of_nonempty α with ⟨x, _⟩,\n  exact mem_range_self x\nend\n\ndef range_factorization (f : ι → β) : ι → range f :=\nλ i, ⟨f i, mem_range_self i⟩\n\nlemma range_factorization_eq {f : ι → β} :\n  subtype.val ∘ range_factorization f = f :=\nfunext $ λ i, rfl\n\nlemma surjective_onto_range : surjective (range_factorization f) :=\nλ ⟨_, ⟨i, rfl⟩⟩, ⟨i, rfl⟩\n\nend range\n\n/-- The set `s` is pairwise `r` if `r x y` for all *distinct* `x y ∈ s`. -/\ndef pairwise_on (s : set α) (r : α → α → Prop) := ∀ x ∈ s, ∀ y ∈ s, x ≠ y → r x y\n\ntheorem pairwise_on.mono {s t : set α} {r}\n  (h : t ⊆ s) (hp : pairwise_on s r) : pairwise_on t r :=\nλ x xt y yt, hp x (h xt) y (h yt)\n\ntheorem pairwise_on.mono' {s : set α} {r r' : α → α → Prop}\n  (H : ∀ a b, r a b → r' a b) (hp : pairwise_on s r) : pairwise_on s r' :=\nλ x xs y ys h, H _ _ (hp x xs y ys h)\n\nend set\n\n/- image and preimage on subtypes -/\n\nnamespace subtype\n\nvariable {α : Type*}\n\nlemma val_image {p : α → Prop} {s : set (subtype p)} :\n  subtype.val '' s = {x | ∃h : p x, (⟨x, h⟩ : subtype p) ∈ s} :=\nset.ext $ assume a,\n⟨assume ⟨⟨a', ha'⟩, in_s, h_eq⟩, h_eq ▸ ⟨ha', in_s⟩,\n  assume ⟨ha, in_s⟩, ⟨⟨a, ha⟩, in_s, rfl⟩⟩\n\n@[simp] lemma val_range {p : α → Prop} :\n  set.range (@subtype.val _ p) = {x | p x} :=\nby rw ← set.image_univ; simp [-set.image_univ, val_image]\ntheorem val_image_subset (s : set α) (t : set (subtype s)) : t.image val ⊆ s :=\nλ x ⟨y, yt, yvaleq⟩, by rw ←yvaleq; exact y.property\n\ntheorem val_image_univ (s : set α) : @val _ s '' set.univ = s :=\nset.eq_of_subset_of_subset (val_image_subset _ _) (λ x xs, ⟨⟨x, xs⟩, ⟨set.mem_univ _, rfl⟩⟩)\n\ntheorem image_preimage_val (s t : set α) :\n  (@subtype.val _ s) '' ((@subtype.val _ s) ⁻¹' t) = t ∩ s :=\nbegin\n  ext x, simp, split,\n  { rintros ⟨y, ys, yt, yx⟩, rw ←yx, exact ⟨yt, ys⟩ },\n  rintros ⟨xt, xs⟩, exact ⟨x, xs, xt, rfl⟩\nend\n\ntheorem preimage_val_eq_preimage_val_iff (s t u : set α) :\n  ((@subtype.val _ s) ⁻¹' t = (@subtype.val _ s) ⁻¹' u) ↔ (t ∩ s = u ∩ s) :=\nbegin\n  rw [←image_preimage_val, ←image_preimage_val],\n  split, { intro h, rw h },\n  intro h, exact set.injective_image (val_injective) h\nend\nend subtype\n\nnamespace set\n\nsection range\n\nvariable {α : Type*}\n\n@[simp] lemma subtype.val_range {p : α → Prop} :\n  range (@subtype.val _ p) = {x | p x} :=\nby rw ← image_univ; simp [-image_univ, subtype.val_image]\n\n@[simp] lemma range_coe_subtype (s : set α): range (coe : s → α) = s :=\nsubtype.val_range\n\nend range\n\nsection prod\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\nvariables {s s₁ s₂ : set α} {t t₁ t₂ : set β}\n\n/-- The cartesian product `prod s t` is the set of `(a, b)`\n  such that `a ∈ s` and `b ∈ t`. -/\nprotected def prod (s : set α) (t : set β) : set (α × β) :=\n{p | p.1 ∈ s ∧ p.2 ∈ t}\n\nlemma prod_eq (s : set α) (t : set β) : set.prod s t = prod.fst ⁻¹' s ∩ prod.snd ⁻¹' t := rfl\n\ntheorem mem_prod_eq {p : α × β} : p ∈ set.prod s t = (p.1 ∈ s ∧ p.2 ∈ t) := rfl\n\n@[simp] theorem mem_prod {p : α × β} : p ∈ set.prod s t ↔ p.1 ∈ s ∧ p.2 ∈ t := iff.rfl\n\nlemma mk_mem_prod {a : α} {b : β} (a_in : a ∈ s) (b_in : b ∈ t) : (a, b) ∈ set.prod s t := ⟨a_in, b_in⟩\n\n@[simp] theorem prod_empty {s : set α} : set.prod s ∅ = (∅ : set (α × β)) :=\next $ by simp [set.prod]\n\n@[simp] theorem empty_prod {t : set β} : set.prod ∅ t = (∅ : set (α × β)) :=\next $ by simp [set.prod]\n\ntheorem insert_prod {a : α} {s : set α} {t : set β} :\n  set.prod (insert a s) t = (prod.mk a '' t) ∪ set.prod s t :=\next begin simp [set.prod, image, iff_def, or_imp_distrib] {contextual := tt}; cc end\n\ntheorem prod_insert {b : β} {s : set α} {t : set β} :\n  set.prod s (insert b t) = ((λa, (a, b)) '' s) ∪ set.prod s t :=\next begin simp [set.prod, image, iff_def, or_imp_distrib] {contextual := tt}; cc end\n\ntheorem prod_preimage_eq {f : γ → α} {g : δ → β} :\n  set.prod (preimage f s) (preimage g t) = preimage (λp, (f p.1, g p.2)) (set.prod s t) := rfl\n\ntheorem prod_mono {s₁ s₂ : set α} {t₁ t₂ : set β} (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) :\n  set.prod s₁ t₁ ⊆ set.prod s₂ t₂ :=\nassume x ⟨h₁, h₂⟩, ⟨hs h₁, ht h₂⟩\n\ntheorem prod_inter_prod : set.prod s₁ t₁ ∩ set.prod s₂ t₂ = set.prod (s₁ ∩ s₂) (t₁ ∩ t₂) :=\nsubset.antisymm\n  (assume ⟨a, b⟩ ⟨⟨ha₁, hb₁⟩, ⟨ha₂, hb₂⟩⟩, ⟨⟨ha₁, ha₂⟩, ⟨hb₁, hb₂⟩⟩)\n  (subset_inter\n    (prod_mono (inter_subset_left _ _) (inter_subset_left _ _))\n    (prod_mono (inter_subset_right _ _) (inter_subset_right _ _)))\n\ntheorem image_swap_prod : (λp:β×α, (p.2, p.1)) '' set.prod t s = set.prod s t :=\next $ assume ⟨a, b⟩, by simp [mem_image_eq, set.prod, and_comm]; exact\n⟨ assume ⟨b', a', ⟨h_a, h_b⟩, h⟩, by subst a'; subst b'; assumption,\n  assume h, ⟨b, a, ⟨rfl, rfl⟩, h⟩⟩\n\ntheorem image_swap_eq_preimage_swap : image (@prod.swap α β) = preimage prod.swap :=\nimage_eq_preimage_of_inverse prod.swap_left_inverse prod.swap_right_inverse\n\ntheorem prod_image_image_eq {m₁ : α → γ} {m₂ : β → δ} :\n  set.prod (image m₁ s) (image m₂ t) = image (λp:α×β, (m₁ p.1, m₂ p.2)) (set.prod s t) :=\next $ by simp [-exists_and_distrib_right, exists_and_distrib_right.symm, and.left_comm, and.assoc, and.comm]\n\ntheorem prod_range_range_eq {α β γ δ} {m₁ : α → γ} {m₂ : β → δ} :\n  set.prod (range m₁) (range m₂) = range (λp:α×β, (m₁ p.1, m₂ p.2)) :=\next $ by simp [range]\n\n@[simp] theorem prod_singleton_singleton {a : α} {b : β} :\n  set.prod {a} {b} = ({(a, b)} : set (α×β)) :=\next $ by simp [set.prod]\n\ntheorem prod_neq_empty_iff {s : set α} {t : set β} :\n  set.prod s t ≠ ∅ ↔ (s ≠ ∅ ∧ t ≠ ∅) :=\nby simp [not_eq_empty_iff_exists]\n\ntheorem prod_eq_empty_iff {s : set α} {t : set β} :\n  set.prod s t = ∅ ↔ (s = ∅ ∨ t = ∅) :=\nsuffices (¬ set.prod s t ≠ ∅) ↔ (¬ s ≠ ∅ ∨ ¬ t ≠ ∅), by simpa only [(≠), classical.not_not],\nby classical; rw [prod_neq_empty_iff, not_and_distrib]\n\n@[simp] theorem prod_mk_mem_set_prod_eq {a : α} {b : β} {s : set α} {t : set β} :\n  (a, b) ∈ set.prod s t = (a ∈ s ∧ b ∈ t) := rfl\n\n@[simp] theorem univ_prod_univ : set.prod (@univ α) (@univ β) = univ :=\next $ assume ⟨a, b⟩, by simp\n\nlemma prod_sub_preimage_iff {W : set γ} {f : α × β → γ} :\n  set.prod s t ⊆ f ⁻¹' W ↔ ∀ a b, a ∈ s → b ∈ t → f (a, b) ∈ W :=\nby simp [subset_def]\n\nend prod\n\nsection pi\nvariables {α : Type*} {π : α → Type*}\n\ndef pi (i : set α) (s : Πa, set (π a)) : set (Πa, π a) := { f | ∀a∈i, f a ∈ s a }\n\n@[simp] lemma pi_empty_index (s : Πa, set (π a)) : pi ∅ s = univ := by ext; simp [pi]\n\n@[simp] lemma pi_insert_index (a : α) (i : set α) (s : Πa, set (π a)) :\n  pi (insert a i) s = ((λf, f a) ⁻¹' s a) ∩ pi i s :=\nby ext; simp [pi, or_imp_distrib, forall_and_distrib]\n\n@[simp] lemma pi_singleton_index (a : α) (s : Πa, set (π a)) :\n  pi {a} s = ((λf:(Πa, π a), f a) ⁻¹' s a) :=\nby ext; simp [pi]\n\nlemma pi_if {p : α → Prop} [h : decidable_pred p] (i : set α) (s t : Πa, set (π a)) :\n  pi i (λa, if p a then s a else t a) = pi {a ∈ i | p a} s ∩ pi {a ∈ i | ¬ p a} t :=\nbegin\n  ext f,\n  split,\n  { assume h, split; { rintros a ⟨hai, hpa⟩, simpa [*] using h a } },\n  { rintros ⟨hs, ht⟩ a hai,\n    by_cases p a; simp [*, pi] at * }\nend\n\nend pi\n\nend set\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/data/set/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175005616829, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.4793117755389428}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin and Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Robert Y. Lewis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.witt_vector.basic\nimport Mathlib.ring_theory.witt_vector.is_poly\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n\n# `init` and `tail`\n\nGiven a Witt vector `x`, we are sometimes interested\nin its components before and after an index `n`.\nThis file defines those operations, proves that `init` is polynomial,\nand shows how that polynomial interacts with `mv_polynomial.bind₁`.\n\n## Main declarations\n\n* `witt_vector.init n x`: the first `n` coefficients of `x`, as a Witt vector. All coefficients at\n  indices ≥ `n` are 0.\n* `witt_vector.tail n x`: the complementary part to `init`. All coefficients at indices < `n` are 0,\n  otherwise they are the same as in `x`.\n* `witt_vector.coeff_add_of_disjoint`: if `x` and `y` are Witt vectors such that for every `n`\n  the `n`-th coefficient of `x` or of `y` is `0`, then the coefficients of `x + y`\n  are just `x.coeff n + y.coeff n`.\n-/\n\nnamespace tactic\n\n\nnamespace interactive\n\n\n/--\n`init_ring` is an auxiliary tactic that discharges goals factoring `init` over ring operations.\n-/\nend interactive\n\n\nend tactic\n\n\nnamespace witt_vector\n\n\n/-- `witt_vector.select P x`, for a predicate `P : ℕ → Prop` is the Witt vector\nwhose `n`-th coefficient is `x.coeff n` if `P n` is true, and `0` otherwise.\n-/\ndef select {p : ℕ} {R : Type u_1} [comm_ring R] (P : ℕ → Prop) (x : witt_vector p R) :\n    witt_vector p R :=\n  mk p fun (n : ℕ) => ite (P n) (coeff x n) 0\n\n/-- The polynomial that witnesses that `witt_vector.select` is a polynomial function.\n`select_poly n` is `X n` if `P n` holds, and `0` otherwise. -/\ndef select_poly (P : ℕ → Prop) (n : ℕ) : mv_polynomial ℕ ℤ := ite (P n) (mv_polynomial.X n) 0\n\ntheorem coeff_select {p : ℕ} {R : Type u_1} [comm_ring R] (P : ℕ → Prop) (x : witt_vector p R)\n    (n : ℕ) : coeff (select P x) n = coe_fn (mv_polynomial.aeval (coeff x)) (select_poly P n) :=\n  sorry\n\ntheorem select_is_poly {p : ℕ} (P : ℕ → Prop) :\n    is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) (x : witt_vector p R) => select P x :=\n  Exists.intro (select_poly P)\n    (id\n      fun (R : Type u_1) (_Rcr : comm_ring R) (x : witt_vector p R) =>\n        funext fun (i : ℕ) => coeff_select P x i)\n\ntheorem select_add_select_not {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (P : ℕ → Prop) (x : witt_vector p R) : select P x + select (fun (i : ℕ) => ¬P i) x = x :=\n  sorry\n\ntheorem coeff_add_of_disjoint {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (h : ∀ (n : ℕ), coeff x n = 0 ∨ coeff y n = 0) :\n    coeff (x + y) n = coeff x n + coeff y n :=\n  sorry\n\n/-- `witt_vector.init n x` is the Witt vector of which the first `n` coefficients are those from `x`\nand all other coefficients are `0`.\nSee `witt_vector.tail` for the complementary part.\n-/\ndef init {p : ℕ} {R : Type u_1} [comm_ring R] (n : ℕ) : witt_vector p R → witt_vector p R :=\n  select fun (i : ℕ) => i < n\n\n/-- `witt_vector.tail n x` is the Witt vector of which the first `n` coefficients are `0`\nand all other coefficients are those from `x`.\nSee `witt_vector.init` for the complementary part. -/\ndef tail {p : ℕ} {R : Type u_1} [comm_ring R] (n : ℕ) : witt_vector p R → witt_vector p R :=\n  select fun (i : ℕ) => n ≤ i\n\n@[simp] theorem init_add_tail {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (n : ℕ) : init n x + tail n x = x :=\n  sorry\n\n@[simp] theorem init_init {p : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : ℕ) :\n    init n (init n x) = init n x :=\n  sorry\n\ntheorem init_add {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (n : ℕ) :\n    init n (x + y) = init n (init n x + init n y) :=\n  sorry\n\ntheorem init_mul {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (n : ℕ) :\n    init n (x * y) = init n (init n x * init n y) :=\n  sorry\n\ntheorem init_neg {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (n : ℕ) : init n (-x) = init n (-init n x) :=\n  sorry\n\ntheorem init_sub {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (n : ℕ) :\n    init n (x - y) = init n (init n x - init n y) :=\n  sorry\n\n/-- `witt_vector.init n x` is polynomial in the coefficients of `x`. -/\ntheorem init_is_poly (p : ℕ) (n : ℕ) :\n    is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => init n :=\n  select_is_poly fun (i : ℕ) => i < n\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/init_tail_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.47931177355172694}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\n\nuniverses u \n\nnamespace Mathlib\n\nnamespace rbnode\n\n\ninductive is_node_of {α : Type u} : rbnode α → rbnode α → α → rbnode α → Prop where\n| of_red : ∀ (l : rbnode α) (v : α) (r : rbnode α), is_node_of (red_node l v r) l v r\n| of_black : ∀ (l : rbnode α) (v : α) (r : rbnode α), is_node_of (black_node l v r) l v r\n\ndef lift {α : Type u} (lt : α → α → Prop) : Option α → Option α → Prop := sorry\n\ninductive is_searchable {α : Type u} (lt : α → α → Prop) : rbnode α → Option α → Option α → Prop\n    where\n| leaf_s : ∀ {lo hi : Option α}, lift lt lo hi → is_searchable lt leaf lo hi\n| red_s :\n    ∀ {l r : rbnode α} {v : α} {lo hi : Option α},\n      is_searchable lt l lo (some v) →\n        is_searchable lt r (some v) hi → is_searchable lt (red_node l v r) lo hi\n| black_s :\n    ∀ {l r : rbnode α} {v : α} {lo hi : Option α},\n      is_searchable lt l lo (some v) →\n        is_searchable lt r (some v) hi → is_searchable lt (black_node l v r) lo hi\n\ntheorem lo_lt_hi {α : Type u} {t : rbnode α} {lt : α → α → Prop} [is_trans α lt] {lo : Option α}\n    {hi : Option α} : is_searchable lt t lo hi → lift lt lo hi :=\n  sorry\n\ntheorem is_searchable_of_is_searchable_of_incomp {α : Type u} {lt : α → α → Prop} [DecidableRel lt]\n    [is_strict_weak_order α lt] {t : rbnode α} {lo : Option α} {hi : α} {hi' : α}\n    (hc : ¬lt hi' hi ∧ ¬lt hi hi') (hs : is_searchable lt t lo (some hi)) :\n    is_searchable lt t lo (some hi') :=\n  sorry\n\ntheorem is_searchable_of_incomp_of_is_searchable {α : Type u} {lt : α → α → Prop} [DecidableRel lt]\n    [is_strict_weak_order α lt] {t : rbnode α} {lo : α} {lo' : α} {hi : Option α}\n    (hc : ¬lt lo' lo ∧ ¬lt lo lo') (hs : is_searchable lt t (some lo) hi) :\n    is_searchable lt t (some lo') hi :=\n  sorry\n\ntheorem is_searchable_some_low_of_is_searchable_of_lt {α : Type u} {lt : α → α → Prop}\n    [DecidableRel lt] {t : rbnode α} [is_trans α lt] {lo : α} {hi : Option α} {lo' : α}\n    (hlt : lt lo' lo) (hs : is_searchable lt t (some lo) hi) : is_searchable lt t (some lo') hi :=\n  sorry\n\ntheorem is_searchable_none_low_of_is_searchable_some_low {α : Type u} {lt : α → α → Prop}\n    [DecidableRel lt] {t : rbnode α} {y : α} {hi : Option α}\n    (hlt : is_searchable lt t (some y) hi) : is_searchable lt t none hi :=\n  sorry\n\ntheorem is_searchable_some_high_of_is_searchable_of_lt {α : Type u} {lt : α → α → Prop}\n    [DecidableRel lt] {t : rbnode α} [is_trans α lt] {lo : Option α} {hi : α} {hi' : α}\n    (hlt : lt hi hi') (hs : is_searchable lt t lo (some hi)) : is_searchable lt t lo (some hi') :=\n  sorry\n\ntheorem is_searchable_none_high_of_is_searchable_some_high {α : Type u} {lt : α → α → Prop}\n    [DecidableRel lt] {t : rbnode α} {lo : Option α} {y : α}\n    (hlt : is_searchable lt t lo (some y)) : is_searchable lt t lo none :=\n  sorry\n\ntheorem range {α : Type u} {lt : α → α → Prop} [DecidableRel lt] [is_strict_weak_order α lt]\n    {t : rbnode α} {x : α} {lo : Option α} {hi : Option α} :\n    is_searchable lt t lo hi → mem lt x t → lift lt lo (some x) ∧ lift lt (some x) hi :=\n  sorry\n\ntheorem lt_of_mem_left {α : Type u} {lt : α → α → Prop} [DecidableRel lt]\n    [is_strict_weak_order α lt] {y : α} {t : rbnode α} {l : rbnode α} {r : rbnode α} {lo : Option α}\n    {hi : Option α} :\n    is_searchable lt t lo hi → is_node_of t l y r → ∀ {x : α}, mem lt x l → lt x y :=\n  sorry\n\ntheorem lt_of_mem_right {α : Type u} {lt : α → α → Prop} [DecidableRel lt]\n    [is_strict_weak_order α lt] {y : α} {t : rbnode α} {l : rbnode α} {r : rbnode α} {lo : Option α}\n    {hi : Option α} :\n    is_searchable lt t lo hi → is_node_of t l y r → ∀ {z : α}, mem lt z r → lt y z :=\n  sorry\n\ntheorem lt_of_mem_left_right {α : Type u} {lt : α → α → Prop} [DecidableRel lt]\n    [is_strict_weak_order α lt] {y : α} {t : rbnode α} {l : rbnode α} {r : rbnode α} {lo : Option α}\n    {hi : Option α} :\n    is_searchable lt t lo hi → is_node_of t l y r → ∀ {x z : α}, mem lt x l → mem lt z r → lt x z :=\n  sorry\n\ninductive is_red_black {α : Type u} : rbnode α → color → ℕ → Prop where\n| leaf_rb : is_red_black leaf color.black 0\n| red_rb :\n    ∀ {v : α} {l r : rbnode α} {n : ℕ},\n      is_red_black l color.black n →\n        is_red_black r color.black n → is_red_black (red_node l v r) color.red n\n| black_rb :\n    ∀ {v : α} {l r : rbnode α} {n : ℕ} {c₁ c₂ : color},\n      is_red_black l c₁ n →\n        is_red_black r c₂ n → is_red_black (black_node l v r) color.black (Nat.succ n)\n\ntheorem depth_min {α : Type u} {c : color} {n : ℕ} {t : rbnode α} :\n    is_red_black t c n → depth min t ≥ n :=\n  sorry\n\ntheorem depth_max' {α : Type u} {c : color} {n : ℕ} {t : rbnode α} :\n    is_red_black t c n → depth max t ≤ upper c n :=\n  sorry\n\ntheorem depth_max {α : Type u} {c : color} {n : ℕ} {t : rbnode α} (h : is_red_black t c n) :\n    depth max t ≤ bit0 1 * n + 1 :=\n  le_trans (depth_max' h) (upper_le c n)\n\ntheorem balanced {α : Type u} {c : color} {n : ℕ} {t : rbnode α} (h : is_red_black t c n) :\n    bit0 1 * depth min t + 1 ≥ depth max t :=\n  le_trans (depth_max h) (nat.succ_le_succ (nat.mul_le_mul_left (bit0 1) (depth_min h)))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/data/rbtree/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4792970424243505}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport topology.urysohns_lemma\nimport topology.continuous_function.bounded\n\n/-!\n# Metrizability of a normal topological space with second countable topology\n\nIn this file we define metrizable topological spaces, i.e., topological spaces for which there\nexists a metric space structure that generates the same topology.\n\nWe also show that a normal topological space with second countable topology `X` is metrizable.\n\nFirst we prove that `X` can be embedded into `l^∞`, then use this embedding to pull back the metric\nspace structure.\n-/\n\nopen set filter metric\nopen_locale bounded_continuous_function filter topological_space\n\nnamespace topological_space\n\n/-- A topological space is metrizable if there exists a metric space structure compatible with the\ntopology. To endow such a space with a compatible distance, use\n`letI : metric_space α := metrizable_space_metric α` -/\nclass metrizable_space (α : Type*) [t : topological_space α] : Prop :=\n(exists_metric : ∃ (m : metric_space α), m.to_uniform_space.to_topological_space = t)\n\n@[priority 100]\ninstance _root_.metric_space.to_metrizable_space {α : Type*} [m : metric_space α] :\n  metrizable_space α :=\n⟨⟨m, rfl⟩⟩\n\n/-- Construct on a metrizable space a metric compatible with the topology. -/\nnoncomputable def metrizable_space_metric\n  (α : Type*) [topological_space α] [h : metrizable_space α] :\n  metric_space α :=\nh.exists_metric.some.replace_topology h.exists_metric.some_spec.symm\n\n@[priority 100]\ninstance t2_space_of_metrizable_space\n  (α : Type*) [topological_space α] [metrizable_space α] : t2_space α :=\nby { letI : metric_space α := metrizable_space_metric α, apply_instance }\n\ninstance metrizable_space_prod (α : Type*) [topological_space α] [metrizable_space α]\n  (β : Type*) [topological_space β] [metrizable_space β] :\n  metrizable_space (α × β) :=\nbegin\n  letI : metric_space α := metrizable_space_metric α,\n  letI : metric_space β := metrizable_space_metric β,\n  apply_instance\nend\n\ninstance metrizable_space.subtype {α : Type*} [topological_space α] [metrizable_space α]\n  (s : set α) : metrizable_space s :=\nby { letI := metrizable_space_metric α, apply_instance }\n\n/-- Given an embedding of a topological space into a metrizable space, the source space is also\nmetrizable. -/\nlemma _root_.embedding.metrizable_space {α β : Type*} [topological_space α] [topological_space β]\n  [metrizable_space β] {f : α → β} (hf : embedding f) :\n  metrizable_space α :=\nbegin\n  letI : metric_space β := metrizable_space_metric β,\n  exact ⟨⟨hf.comap_metric_space f, rfl⟩⟩\nend\n\nvariables (X : Type*) [topological_space X] [normal_space X] [second_countable_topology X]\n\n/-- A normal topological space with second countable topology can be embedded into `l^∞ = ℕ →ᵇ ℝ`.\n-/\nlemma exists_embedding_l_infty : ∃ f : X → (ℕ →ᵇ ℝ), embedding f :=\nbegin\n  -- Choose a countable basis, and consider the set `s` of pairs of set `(U, V)` such that `U ∈ B`,\n  -- `V ∈ B`, and `closure U ⊆ V`.\n  rcases exists_countable_basis X with ⟨B, hBc, -, hB⟩,\n  set s : set (set X × set X) := {UV ∈ B ×ˢ B| closure UV.1 ⊆ UV.2},\n  -- `s` is a countable set.\n  haveI : encodable s := ((hBc.prod hBc).mono (inter_subset_left _ _)).to_encodable,\n  -- We don't have the space of bounded (possibly discontinuous) functions, so we equip `s`\n  -- with the discrete topology and deal with `s →ᵇ ℝ` instead.\n  letI : topological_space s := ⊥, haveI : discrete_topology s := ⟨rfl⟩,\n  suffices : ∃ f : X → (s →ᵇ ℝ), embedding f,\n  { rcases this with ⟨f, hf⟩,\n    exact ⟨λ x, (f x).extend (encodable.encode' s) 0, (bounded_continuous_function.isometry_extend\n      (encodable.encode' s) (0 : ℕ →ᵇ ℝ)).embedding.comp hf⟩ },\n  have hd : ∀ UV : s, disjoint (closure UV.1.1) (UV.1.2ᶜ) :=\n    λ UV, disjoint_compl_right.mono_right (compl_subset_compl.2 UV.2.2),\n  -- Choose a sequence of `εₙ > 0`, `n : s`, that is bounded above by `1` and tends to zero\n  -- along the `cofinite` filter.\n  obtain ⟨ε, ε01, hε⟩ : ∃ ε : s → ℝ, (∀ UV, ε UV ∈ Ioc (0 : ℝ) 1) ∧ tendsto ε cofinite (𝓝 0),\n  { rcases pos_sum_of_encodable zero_lt_one s with ⟨ε, ε0, c, hεc, hc1⟩,\n    refine ⟨ε, λ UV, ⟨ε0 UV, _⟩, hεc.summable.tendsto_cofinite_zero⟩,\n    exact (le_has_sum hεc UV $ λ _ _, (ε0 _).le).trans hc1 },\n  /- For each `UV = (U, V) ∈ s` we use Urysohn's lemma to choose a function `f UV` that is equal to\n  zero on `U` and is equal to `ε UV` on the complement to `V`. -/\n  have : ∀ UV : s, ∃ f : C(X, ℝ), eq_on f 0 UV.1.1 ∧ eq_on f (λ _, ε UV) UV.1.2ᶜ ∧\n    ∀ x, f x ∈ Icc 0 (ε UV),\n  { intro UV,\n    rcases exists_continuous_zero_one_of_closed is_closed_closure\n      (hB.is_open UV.2.1.2).is_closed_compl (hd UV) with ⟨f, hf₀, hf₁, hf01⟩,\n    exact ⟨ε UV • f, λ x hx, by simp [hf₀ (subset_closure hx)], λ x hx, by simp [hf₁ hx],\n      λ x, ⟨mul_nonneg (ε01 _).1.le (hf01 _).1, mul_le_of_le_one_right (ε01 _).1.le (hf01 _).2⟩⟩ },\n  choose f hf0 hfε hf0ε,\n  have hf01 : ∀ UV x, f UV x ∈ Icc (0 : ℝ) 1,\n    from λ UV x, Icc_subset_Icc_right (ε01 _).2 (hf0ε _ _),\n  /- The embedding is given by `F x UV = f UV x`. -/\n  set F : X → s →ᵇ ℝ := λ x, ⟨⟨λ UV, f UV x, continuous_of_discrete_topology⟩, 1, λ UV₁ UV₂,\n    real.dist_le_of_mem_Icc_01 (hf01 _ _) (hf01 _ _)⟩,\n  have hF : ∀ x UV, F x UV = f UV x := λ _ _, rfl,\n  refine ⟨F, embedding.mk' _ (λ x y hxy, _) (λ x, le_antisymm _ _)⟩,\n  { /- First we prove that `F` is injective. Indeed, if `F x = F y` and `x ≠ y`, then we can find\n    `(U, V) ∈ s` such that `x ∈ U` and `y ∉ V`, hence `F x UV = 0 ≠ ε UV = F y UV`. -/\n    refine not_not.1 (λ Hne, _), -- `by_contra Hne` timeouts\n    rcases hB.mem_nhds_iff.1 (is_open_ne.mem_nhds Hne) with ⟨V, hVB, hxV, hVy⟩,\n    rcases hB.exists_closure_subset (hB.mem_nhds hVB hxV) with ⟨U, hUB, hxU, hUV⟩,\n    set UV : ↥s := ⟨(U, V), ⟨hUB, hVB⟩, hUV⟩,\n    apply (ε01 UV).1.ne,\n    calc (0 : ℝ) = F x UV : (hf0 UV hxU).symm\n             ... = F y UV : by rw hxy\n             ... = ε UV   : hfε UV (λ h : y ∈ V, hVy h rfl) },\n  { /- Now we prove that each neighborhood `V` of `x : X` include a preimage of a neighborhood of\n    `F x` under `F`. Without loss of generality, `V` belongs to `B`. Choose `U ∈ B` such that\n    `x ∈ V` and `closure V ⊆ U`. Then the preimage of the `(ε (U, V))`-neighborhood of `F x`\n    is included by `V`. -/\n    refine ((nhds_basis_ball.comap _).le_basis_iff hB.nhds_has_basis).2 _,\n    rintro V ⟨hVB, hxV⟩,\n    rcases hB.exists_closure_subset (hB.mem_nhds hVB hxV) with ⟨U, hUB, hxU, hUV⟩,\n    set UV : ↥s := ⟨(U, V), ⟨hUB, hVB⟩, hUV⟩,\n    refine ⟨ε UV, (ε01 UV).1, λ y (hy : dist (F y) (F x) < ε UV), _⟩,\n    replace hy : dist (F y UV) (F x UV) < ε UV,\n      from (bounded_continuous_function.dist_coe_le_dist _).trans_lt hy,\n    contrapose! hy,\n    rw [hF, hF, hfε UV hy, hf0 UV hxU, pi.zero_apply, dist_zero_right],\n    exact le_abs_self _ },\n  { /- Finally, we prove that `F` is continuous. Given `δ > 0`, consider the set `T` of `(U, V) ∈ s`\n    such that `ε (U, V) ≥ δ`. Since `ε` tends to zero, `T` is finite. Since each `f` is continuous,\n    we can choose a neighborhood such that `dist (F y (U, V)) (F x (U, V)) ≤ δ` for any\n    `(U, V) ∈ T`. For `(U, V) ∉ T`, the same inequality is true because both `F y (U, V)` and\n    `F x (U, V)` belong to the interval `[0, ε (U, V)]`. -/\n    refine (nhds_basis_closed_ball.comap _).ge_iff.2 (λ δ δ0, _),\n    have h_fin : finite {UV : s | δ ≤ ε UV}, by simpa only [← not_lt] using hε (gt_mem_nhds δ0),\n    have : ∀ᶠ y in 𝓝 x, ∀ UV, δ ≤ ε UV → dist (F y UV) (F x UV) ≤ δ,\n    { refine (eventually_all_finite h_fin).2 (λ UV hUV, _),\n      exact (f UV).continuous.tendsto x (closed_ball_mem_nhds _ δ0) },\n    refine this.mono (λ y hy, (bounded_continuous_function.dist_le δ0.le).2 $ λ UV, _),\n    cases le_total δ (ε UV) with hle hle,\n    exacts [hy _ hle, (real.dist_le_of_mem_Icc (hf0ε _ _) (hf0ε _ _)).trans (by rwa sub_zero)] }\nend\n\n/-- A normal topological space with second countable topology `X` is metrizable: there exists a\nmetric space structure that generates the same topology. -/\nlemma metrizable_space_of_normal_second_countable : metrizable_space X :=\nlet ⟨f, hf⟩ := exists_embedding_l_infty X in hf.metrizable_space\n\ninstance : metrizable_space ennreal := metrizable_space_of_normal_second_countable ennreal\n\nend topological_space\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/metric_space/metrizable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4792970424243505}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.nat.upto\nimport Mathlib.data.stream.basic\nimport Mathlib.data.pfun\nimport Mathlib.PostPort\n\nuniverses u_3 l u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Fixed point\n\nThis module defines a generic `fix` operator for defining recursive\ncomputations that are not necessarily well-founded or productive.\nAn instance is defined for `roption`.\n\n## Main definition\n\n * class `has_fix`\n * `roption.fix`\n-/\n\n/-- `has_fix α` gives us a way to calculate the fixed point\nof function of type `α → α`. -/\nclass has_fix (α : Type u_3) \nwhere\n  fix : (α → α) → α\n\nnamespace roption\n\n\n/-- A series of successive, finite approximation of the fixed point of `f`, defined by\n`approx f n = f^[n] ⊥`. The limit of this chain is the fixed point of `f`. -/\ndef fix.approx {α : Type u_1} {β : α → Type u_2} (f : ((a : α) → roption (β a)) → (a : α) → roption (β a)) : stream ((a : α) → roption (β a)) :=\n  sorry\n\n/-- loop body for finding the fixed point of `f` -/\ndef fix_aux {α : Type u_1} {β : α → Type u_2} (f : ((a : α) → roption (β a)) → (a : α) → roption (β a)) {p : ℕ → Prop} (i : nat.upto p) (g : (j : nat.upto p) → i < j → (a : α) → roption (β a)) (a : α) : roption (β a) :=\n  f fun (x : α) => assert (¬p (subtype.val i)) fun (h : ¬p (subtype.val i)) => g (nat.upto.succ i h) sorry x\n\n/-- The least fixed point of `f`.\n\nIf `f` is a continuous function (according to complete partial orders),\nit satisfies the equations:\n\n  1. `fix f = f (fix f)`          (is a fixed point)\n  2. `∀ X, f X ≤ X → fix f ≤ X`   (least fixed point)\n-/\nprotected def fix {α : Type u_1} {β : α → Type u_2} (f : ((a : α) → roption (β a)) → (a : α) → roption (β a)) (x : α) : roption (β x) :=\n  assert (∃ (i : ℕ), dom sorry) fun (h : ∃ (i : ℕ), dom sorry) => well_founded.fix sorry (fix_aux f) nat.upto.zero x\n\nprotected theorem fix_def {α : Type u_1} {β : α → Type u_2} (f : ((a : α) → roption (β a)) → (a : α) → roption (β a)) {x : α} (h' : ∃ (i : ℕ), dom (fix.approx f i x)) : roption.fix f x = fix.approx f (Nat.succ (nat.find h')) x := sorry\n\ntheorem fix_def' {α : Type u_1} {β : α → Type u_2} (f : ((a : α) → roption (β a)) → (a : α) → roption (β a)) {x : α} (h' : ¬∃ (i : ℕ), dom (fix.approx f i x)) : roption.fix f x = none := sorry\n\nend roption\n\n\nnamespace roption\n\n\nprotected instance has_fix {α : Type u_1} : has_fix (roption α) :=\n  has_fix.mk fun (f : roption α → roption α) => roption.fix (fun (x : Unit → roption α) (u : Unit) => f (x u)) Unit.unit\n\nend roption\n\n\nnamespace pi\n\n\nprotected instance roption.has_fix {α : Type u_1} {β : Type u_2} : has_fix (α → roption β) :=\n  has_fix.mk roption.fix\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/control/fix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649232, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.47929704242435045}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport category_theory.abelian.basic\n\n/-!\n# Idempotent complete categories\n\nIn this file, we define the notion of idempotent complete categories\n(also known as Karoubian categories, or pseudoabelian in the case of\npreadditive categories).\n\n## Main definitions\n\n- `is_idempotent_complete C` expresses that `C` is idempotent complete, i.e.\nall idempotents in `C` split. Other characterisations of idempotent completeness are given\nby `is_idempotent_complete_iff_has_equalizer_of_id_and_idempotent` and\n`is_idempotent_complete_iff_idempotents_have_kernels`.\n- `is_idempotent_complete_of_abelian` expresses that abelian categories are\nidempotent complete.\n- `is_idempotent_complete_iff_of_equivalence` expresses that if two categories `C` and `D`\nare equivalent, then `C` is idempotent complete iff `D` is.\n- `is_idempotent_complete_iff_opposite` expresses that `Cᵒᵖ` is idempotent complete\niff `C` is.\n\n## References\n* [Stacks: Karoubian categories] https://stacks.math.columbia.edu/tag/09SF\n\n-/\n\nopen category_theory\nopen category_theory.category\nopen category_theory.limits\nopen category_theory.preadditive\nopen opposite\n\nnamespace category_theory\n\nvariables (C : Type*) [category C]\n\n/-- A category is idempotent complete iff all idempotent endomorphisms `p`\nsplit as a composition `p = e ≫ i` with `i ≫ e = 𝟙 _` -/\nclass is_idempotent_complete : Prop :=\n(idempotents_split : ∀ (X : C) (p : X ⟶ X), p ≫ p = p →\n  ∃ (Y : C) (i : Y ⟶ X) (e : X ⟶ Y), i ≫ e = 𝟙 Y ∧ e ≫ i = p)\n\nnamespace idempotents\n\n/-- A category is idempotent complete iff for all idempotent endomorphisms,\nthe equalizer of the identity and this idempotent exists. -/\nlemma is_idempotent_complete_iff_has_equalizer_of_id_and_idempotent :\n  is_idempotent_complete C ↔ ∀ (X : C) (p : X ⟶ X), p ≫ p = p → has_equalizer (𝟙 X) p :=\nbegin\n  split,\n  { introI,\n    intros X p hp,\n    rcases is_idempotent_complete.idempotents_split X p hp with ⟨Y, i, e, ⟨h₁, h₂⟩⟩,\n    exact ⟨nonempty.intro\n      { cone := fork.of_ι i\n          (show i ≫ 𝟙 X = i ≫ p, by rw [comp_id, ← h₂, ← assoc, h₁, id_comp]),\n        is_limit := begin\n          apply fork.is_limit.mk',\n          intro s,\n          refine ⟨s.ι ≫ e, _⟩,\n          split,\n          { erw [assoc, h₂, ← limits.fork.condition s, comp_id], },\n          { intros m hm,\n            rw fork.ι_of_ι at hm,\n            rw [← hm],\n            simp only [← hm, assoc, h₁],\n            exact (comp_id m).symm }\n        end }⟩, },\n  { intro h,\n    refine ⟨_⟩,\n    intros X p hp,\n    haveI := h X p hp,\n    use equalizer (𝟙 X) p,\n    use equalizer.ι (𝟙 X) p,\n    use equalizer.lift p (show p ≫ 𝟙 X = p ≫ p, by rw [hp, comp_id]),\n    split,\n    { ext,\n      rw [assoc, equalizer.lift_ι, id_comp],\n      conv { to_rhs, erw [← comp_id (equalizer.ι (𝟙 X) p)], },\n      exact (limits.fork.condition (equalizer.fork (𝟙 X) p)).symm, },\n    { rw [equalizer.lift_ι], }, }\nend\n\nvariables {C}\n\n/-- In a preadditive category, when `p : X ⟶ X` is idempotent,\nthen `𝟙 X - p` is also idempotent. -/\nlemma idem_of_id_sub_idem [preadditive C]\n  {X : C} (p : X ⟶ X) (hp : p ≫ p = p) :\n  (𝟙 _ - p) ≫ (𝟙 _ - p) = (𝟙 _ - p) :=\nby simp only [comp_sub, sub_comp, id_comp, comp_id, hp, sub_self, sub_zero]\n\nvariables (C)\n\n/-- A preadditive category is pseudoabelian iff all idempotent endomorphisms have a kernel. -/\nlemma is_idempotent_complete_iff_idempotents_have_kernels [preadditive C] :\n  is_idempotent_complete C ↔ ∀ (X : C) (p : X ⟶ X), p ≫ p = p → has_kernel p :=\nbegin\n  rw is_idempotent_complete_iff_has_equalizer_of_id_and_idempotent,\n  split,\n  { intros h X p hp,\n    haveI := h X (𝟙 _ - p) (idem_of_id_sub_idem p hp),\n    convert has_kernel_of_has_equalizer (𝟙 X) (𝟙 X - p),\n    rw [sub_sub_cancel], },\n  { intros h X p hp,\n    haveI : has_kernel (𝟙 _ - p) := h X (𝟙 _ - p) (idem_of_id_sub_idem p hp),\n    apply preadditive.has_equalizer_of_has_kernel, },\nend\n\n/-- An abelian category is idempotent complete. -/\n@[priority 100]\ninstance is_idempotent_complete_of_abelian (D : Type*) [category D] [abelian D] :\n  is_idempotent_complete D :=\nby { rw is_idempotent_complete_iff_idempotents_have_kernels, intros, apply_instance, }\n\nvariables {C}\n\nlemma split_imp_of_iso {X X' : C} (φ : X ≅ X') (p : X ⟶ X) (p' : X' ⟶ X')\n  (hpp' : p ≫ φ.hom = φ.hom ≫ p')\n  (h : ∃ (Y : C) (i : Y ⟶ X) (e : X ⟶ Y), i ≫ e = 𝟙 Y ∧ e ≫ i = p) :\n  (∃ (Y' : C) (i' : Y' ⟶ X') (e' : X' ⟶ Y'), i' ≫ e' = 𝟙 Y' ∧ e' ≫ i' = p') :=\nbegin\n  rcases h with ⟨Y, i, e, ⟨h₁, h₂⟩⟩,\n  use [Y, i ≫ φ.hom, φ.inv ≫ e],\n  split,\n  { slice_lhs 2 3 { rw φ.hom_inv_id, },\n    rw [id_comp, h₁], },\n  { slice_lhs 2 3 { rw h₂, },\n    rw [hpp', ← assoc, φ.inv_hom_id, id_comp], }\nend\n\nlemma split_iff_of_iso {X X' : C} (φ : X ≅ X') (p : X ⟶ X) (p' : X' ⟶ X')\n  (hpp' : p ≫ φ.hom = φ.hom ≫ p') :\n  (∃ (Y : C) (i : Y ⟶ X) (e : X ⟶ Y), i ≫ e = 𝟙 Y ∧ e ≫ i = p) ↔\n  (∃ (Y' : C) (i' : Y' ⟶ X') (e' : X' ⟶ Y'), i' ≫ e' = 𝟙 Y' ∧ e' ≫ i' = p') :=\nbegin\n  split,\n  { exact split_imp_of_iso φ p p' hpp', },\n  { apply split_imp_of_iso φ.symm p' p,\n    rw [← comp_id p, ← φ.hom_inv_id],\n    slice_rhs 2 3 { rw hpp', },\n    slice_rhs 1 2 { erw φ.inv_hom_id, },\n    simpa only [id_comp], },\nend\n\nlemma equivalence.is_idempotent_complete {D : Type*} [category D] (ε : C ≌ D)\n  (h : is_idempotent_complete C) : is_idempotent_complete D :=\nbegin\n  refine ⟨_⟩,\n  intros X' p hp,\n  let φ := ε.counit_iso.symm.app X',\n  erw split_iff_of_iso φ p (φ.inv ≫ p ≫ φ.hom)\n    (by { slice_rhs 1 2 { rw φ.hom_inv_id, }, rw id_comp,}),\n  rcases is_idempotent_complete.idempotents_split (ε.inverse.obj X') (ε.inverse.map p)\n    (by rw [← ε.inverse.map_comp, hp]) with ⟨Y, i, e, ⟨h₁,h₂⟩⟩,\n  use [ε.functor.obj Y, ε.functor.map i, ε.functor.map e],\n  split,\n  { rw [← ε.functor.map_comp, h₁, ε.functor.map_id], },\n  { simpa only [← ε.functor.map_comp, h₂, equivalence.fun_inv_map], },\nend\n\n/-- If `C` and `D` are equivalent categories, that `C` is idempotent complete iff `D` is. -/\nlemma is_idempotent_complete_iff_of_equivalence {D : Type*} [category D] (ε : C ≌ D) :\n  is_idempotent_complete C ↔ is_idempotent_complete D :=\nbegin\n  split,\n  { exact equivalence.is_idempotent_complete ε, },\n  { exact equivalence.is_idempotent_complete ε.symm, },\nend\n\nlemma is_idempotent_complete_of_is_idempotent_complete_opposite\n  (h : is_idempotent_complete Cᵒᵖ) : is_idempotent_complete C :=\nbegin\n  refine ⟨_⟩,\n  intros X p hp,\n  rcases is_idempotent_complete.idempotents_split (op X) p.op\n    (by rw [← op_comp, hp]) with ⟨Y, i, e, ⟨h₁, h₂⟩⟩,\n  use [Y.unop, e.unop, i.unop],\n  split,\n  { simpa only [← unop_comp, h₁], },\n  { simpa only [← unop_comp, h₂], },\nend\n\nlemma is_idempotent_complete_iff_opposite :\n  is_idempotent_complete Cᵒᵖ ↔ is_idempotent_complete C :=\nbegin\n  split,\n  { exact is_idempotent_complete_of_is_idempotent_complete_opposite, },\n  { intro h,\n    apply is_idempotent_complete_of_is_idempotent_complete_opposite,\n    rw is_idempotent_complete_iff_of_equivalence (op_op_equivalence C),\n    exact h, },\nend\n\ninstance [is_idempotent_complete C] : is_idempotent_complete (Cᵒᵖ) :=\nby rwa is_idempotent_complete_iff_opposite\n\nend idempotents\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/idempotents/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.4791300413167903}}
{"text": "import data.list algebra.ring tactic.omega defs\n\nlemma single_complete: almost_complete [●] := \nbegin\n  apply almost_complete.cmp_rule,\n  existsi ([]), \n  intros t h, \n  exfalso, apply h, apply grow_list.head_grow, \n  apply grow.single_grow\nend  \n\nlemma single_grow : ∀ t : bintree, (t ↣ ●) → t = ● := \nbegin\n  intros t H1,\n  destruct t,\n  begin intros, assumption end,\n  repeat { \n    intros a H2, \n    rewrite H2 at H1,\n    cases H1,\n  }, -- this proves the first two goals\n  begin\n    intros a a1 H2,\n    rewrite H2 at H1,\n    cases H1,\n  end -- this proves the last two goals\nend\n\n", "meta": {"author": "ljt12138", "repo": "Proof-of-Surreal", "sha": "6b92baf2382ac23dd0d700f5c958aa910ad4b754", "save_path": "github-repos/lean/ljt12138-Proof-of-Surreal", "path": "github-repos/lean/ljt12138-Proof-of-Surreal/Proof-of-Surreal-6b92baf2382ac23dd0d700f5c958aa910ad4b754/src/single.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4791300320571542}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport category_theory.endomorphism\nimport category_theory.category.Cat\nimport algebra.category.Mon.basic\n\n/-!\n# Single-object category\n\nSingle object category with a given monoid of endomorphisms.\nIt is defined to facilitate transfering some definitions and lemmas (e.g., conjugacy etc.)\nfrom category theory to monoids and groups.\n\n## Main definitions\n\nGiven a type `α` with a monoid structure, `single_obj α` is `unit` type with `category` structure\nsuch that `End (single_obj α).star` is the monoid `α`.  This can be extended to a functor `Mon ⥤\nCat`.\n\nIf `α` is a group, then `single_obj α` is a groupoid.\n\nAn element `x : α` can be reinterpreted as an element of `End (single_obj.star α)` using\n`single_obj.to_End`.\n\n## Implementation notes\n\n- `category_struct.comp` on `End (single_obj.star α)` is `flip (*)`, not `(*)`. This way\n  multiplication on `End` agrees with the multiplication on `α`.\n\n- By default, Lean puts instances into `category_theory` namespace instead of\n  `category_theory.single_obj`, so we give all names explicitly.\n-/\n\nuniverses u v w\n\nnamespace category_theory\n/-- Type tag on `unit` used to define single-object categories and groupoids. -/\n@[nolint unused_arguments has_inhabited_instance]\ndef single_obj (α : Type u) : Type := unit\n\nnamespace single_obj\n\nvariables (α : Type u)\n\n/-- One and `flip (*)` become `id` and `comp` for morphisms of the single object category. -/\ninstance category_struct [has_one α] [has_mul α] : category_struct (single_obj α) :=\n{ hom := λ _ _, α,\n  comp := λ _ _ _ x y, y * x,\n  id := λ _, 1 }\n\n/-- Monoid laws become category laws for the single object category. -/\ninstance category [monoid α] : category (single_obj α) :=\n{ comp_id' := λ _ _, one_mul,\n  id_comp' := λ _ _, mul_one,\n  assoc' := λ _ _ _ _ x y z, (mul_assoc z y x).symm }\n\nlemma id_as_one [monoid α] (x : single_obj α) : 𝟙 x = 1 := rfl\n\nlemma comp_as_mul [monoid α] {x y z : single_obj α} (f : x ⟶ y) (g : y ⟶ z) :\n  f ≫ g = g * f := rfl\n\n/--\nGroupoid structure on `single_obj α`.\n\nSee https://stacks.math.columbia.edu/tag/0019.\n-/\ninstance groupoid [group α] : groupoid (single_obj α) :=\n{ inv := λ _ _ x, x⁻¹,\n  inv_comp' := λ _ _, mul_right_inv,\n  comp_inv' := λ _ _, mul_left_inv }\n\n\n\n/-- The single object in `single_obj α`. -/\nprotected def star : single_obj α := unit.star\n\n/-- The endomorphisms monoid of the only object in `single_obj α` is equivalent to the original\n     monoid α. -/\ndef to_End [monoid α] : α ≃* End (single_obj.star α) :=\n{ map_mul' := λ x y, rfl,\n  .. equiv.refl α }\n\nlemma to_End_def [monoid α] (x : α) : to_End α x = x := rfl\n\n/-- There is a 1-1 correspondence between monoid homomorphisms `α → β` and functors between the\n    corresponding single-object categories. It means that `single_obj` is a fully faithful\n    functor.\n\nSee https://stacks.math.columbia.edu/tag/001F --\nalthough we do not characterize when the functor is full or faithful.\n-/\ndef map_hom (α : Type u) (β : Type v) [monoid α] [monoid β] :\n  (α →* β) ≃ (single_obj α) ⥤ (single_obj β) :=\n{ to_fun := λ f,\n  { obj := id,\n    map := λ _ _, ⇑f,\n    map_id' := λ _, f.map_one,\n    map_comp' := λ _ _ _ x y, f.map_mul y x },\n  inv_fun := λ f,\n    { to_fun := @functor.map _ _ _ _ f (single_obj.star α) (single_obj.star α),\n      map_one' := f.map_id _,\n      map_mul' := λ x y, f.map_comp y x },\n  left_inv := λ ⟨f, h₁, h₂⟩, rfl,\n  right_inv := λ f, by cases f; obviously }\n\nlemma map_hom_id (α : Type u) [monoid α] : map_hom α α (monoid_hom.id α) = 𝟭 _ := rfl\n\nlemma map_hom_comp {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β)\n  {γ : Type w} [monoid γ] (g : β →* γ) :\n  map_hom α γ (g.comp f) = map_hom α β f ⋙ map_hom β γ g :=\nrfl\n\n/-- Given a function `f : C → G` from a category to a group, we get a functor\n    `C ⥤ G` sending any morphism `x ⟶ y` to `f y * (f x)⁻¹`. -/\n@[simps] def difference_functor {C G} [category C] [group G] (f : C → G) : C ⥤ single_obj G :=\n{ obj := λ _, (),\n  map := λ x y _, f y * (f x)⁻¹,\n  map_id' := by { intro, rw [single_obj.id_as_one, mul_right_inv] },\n  map_comp' := by { intros, rw [single_obj.comp_as_mul, ←mul_assoc,\n    mul_left_inj, mul_assoc, inv_mul_self, mul_one] } }\n\nend single_obj\n\nend category_theory\n\nopen category_theory\n\nnamespace monoid_hom\n\n/-- Reinterpret a monoid homomorphism `f : α → β` as a functor `(single_obj α) ⥤ (single_obj β)`.\nSee also `category_theory.single_obj.map_hom` for an equivalence between these types. -/\n@[reducible] def to_functor {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β) :\n  (single_obj α) ⥤ (single_obj β) :=\nsingle_obj.map_hom α β f\n\n@[simp] lemma id_to_functor (α : Type u) [monoid α] : (id α).to_functor = 𝟭 _ := rfl\n@[simp] lemma comp_to_functor {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β)\n  {γ : Type w} [monoid γ] (g : β →* γ) :\n  (g.comp f).to_functor = f.to_functor ⋙ g.to_functor :=\nrfl\n\nend monoid_hom\n\nnamespace units\n\nvariables (α : Type u) [monoid α]\n\n/--\nThe units in a monoid are (multiplicatively) equivalent to\nthe automorphisms of `star` when we think of the monoid as a single-object category. -/\ndef to_Aut : units α ≃* Aut (single_obj.star α) :=\n(units.map_equiv (single_obj.to_End α)).trans $\n  Aut.units_End_equiv_Aut _\n\n@[simp] lemma to_Aut_hom (x : units α) : (to_Aut α x).hom = single_obj.to_End α x := rfl\n@[simp] lemma to_Aut_inv (x : units α) :\n  (to_Aut α x).inv = single_obj.to_End α (x⁻¹ : units α) :=\nrfl\nend units\n\nnamespace Mon\n\nopen category_theory\n\n/-- The fully faithful functor from `Mon` to `Cat`. -/\ndef to_Cat : Mon ⥤ Cat :=\n{ obj := λ x, Cat.of (single_obj x),\n  map := λ x y f, single_obj.map_hom x y f }\n\ninstance to_Cat_full : full to_Cat :=\n{ preimage := λ x y, (single_obj.map_hom x y).inv_fun,\n  witness' := λ x y, by apply equiv.right_inv }\n\ninstance to_Cat_faithful : faithful to_Cat :=\n{ map_injective' := λ x y, by apply equiv.injective }\n\nend Mon\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/single_obj.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.47906241251473314}}
{"text": "import tactic.tidy\nimport set_category.diagram_lemmas\nimport set_category.category_set\nimport help_functions\nimport set_category.limits.Equalizer\nimport set_category.limits.Product\nimport category_theory.types\n\n\n\n\n\nnamespace Pullback\n\nopen set \n     diagram_lemmas\n     classical\n     function\n     help_functions\n     Equalizer\n     Product\n     category_theory\n     category_set\n\n\nuniverses v u\n\nlocal notation f ` ⊚ `:80 g:80 := category_struct.comp g f\n\n\ndef is_pullback {X : Type v} [category X]\n    {A₁ A₂ B : X}\n    (f : A₁ ⟶ B) (g : A₂ ⟶ B)\n    {P : X} (p₁ : P ⟶ A₁) (p₂ : P ⟶ A₂): Prop :=\n    f ⊚ p₁ = g ⊚ p₂ ∧ \n    Π {Q : X} (q₁ : Q ⟶ A₁) (q₂ : Q ⟶ A₂),\n        f ⊚ q₁ = g ⊚ q₂ →\n            ∃! h : Q ⟶ P, q₁ = p₁ ⊚ h ∧ q₂ = p₂ ⊚ h\n\n\nlemma equalizer_product_is_pullback_cat \n    {X : Type u} [category X]\n    {A₁ A₂ B P E : X}\n    (f : A₁ ⟶ B) (g : A₂ ⟶ B)\n    (π₁ : P ⟶ A₁) (π₂ : P ⟶ A₂)\n    (pr : is_product A₁ A₂ π₁ π₂)\n    (e : E ⟶ P)\n    (eqauliz : is_equalizer (f ⊚ π₁) (g ⊚ π₂) e) :\n    is_pullback f g\n        (π₁ ⊚ e)\n        (π₂ ⊚ e) \n    := \n    ⟨ begin \n        tidy\n     end\n    ,\n    begin\n        intros Q q₁ q₂ fq₁_gq₂,\n        let p : Q ⟶ P := some (pr  Q q₁ q₂),\n        have spec_p : q₁ = π₁ ⊚ p ∧ q₂ = π₂ ⊚ p := (some_spec (pr Q q₁ q₂)).1,\n\n        have eq_comp : f ⊚ π₁ ⊚ p  = g ⊚ π₂ ⊚ p := \n            calc f ⊚ π₁ ⊚ p   = f ⊚ (π₁ ⊚ p)   : by tidy\n                    ...         = f ⊚ q₁         : by rw ← spec_p.1\n                    ...         = g ⊚ q₂         : fq₁_gq₂\n                    ...         = g ⊚ (π₂ ⊚ p)  : by rw spec_p.2\n                    ...         = g ⊚ π₂ ⊚ p    : by tidy,\n\n        let h : Q ⟶ E := some (eqauliz.2 p eq_comp),\n        have spec_h : p = e ⊚ h := (some_spec (eqauliz.2 p eq_comp)).1,\n        use h,\n        have h0 : q₁ = π₁ ⊚ e ⊚ h ∧ q₂ = π₂ ⊚ e ⊚ h :=\n            ⟨ \n                by simp [spec_h , spec_p.1]\n                ,  \n                by simp [spec_h , spec_p.2]\n            ⟩ ,\n        split, \n        exact h0,\n        assume (y : Q ⟶ E) (spec_y : q₁ = π₁ ⊚ e ⊚ y ∧ q₂ = π₂ ⊚ e ⊚ y),\n        have s0 : π₁ ⊚ (e ⊚ h) = π₁ ⊚ (e ⊚ y) := \n            calc π₁ ⊚ (e ⊚ h) = π₁ ⊚ e ⊚ h      : by tidy\n                ...            = q₁                : eq.symm h0.1\n                ...            = π₁ ⊚ e ⊚ y      : spec_y.1\n                ...            = π₁ ⊚ (e ⊚ y)    : by tidy,\n        have s1 : π₂ ⊚ (e ⊚ h) = π₂ ⊚ (e ⊚ y) := \n            calc π₂ ⊚ (e ⊚ h) = π₂ ⊚ e ⊚ h      : by tidy\n            ...                = q₂                : eq.symm h0.2\n            ...                = π₂ ⊚ e ⊚ y      : spec_y.2\n            ...                = π₂ ⊚ (e ⊚ y)    : by tidy,\n        have eh_ey : e ⊚ h = e ⊚ y := \n            jointly_mono A₁ A₂ P π₁ π₂ pr s0 s1,\n        \n        haveI m_e : mono e := equalizer_is_mono (f ⊚ π₁) (g ⊚ π₂) e eqauliz,\n        exact left_cancel e (eq.symm eh_ey)\n    end ⟩ \n\n\n\n\nvariables {A₁ A₂ B : Type u}\nvariables (f : A₁ ⟶ B) (g : A₂ ⟶ B)\n\nlemma equalizer_product_is_pullback :\n    let P := A₁ × A₂ in \n    let π₁ : P → A₁ := λ ab, ab.1 in\n    let π₂ : P → A₂ := λ ab, ab.2 in\n    let E := equalizer_set (f ∘ π₁) (g ∘ π₂) in\n    let e := E ↪ P in\n\n    is_pullback f g\n        (π₁ ∘ e)\n        (π₂ ∘ e) \n    := \n    let P := A₁ × A₂ in \n    let π₁ : P → A₁ := λ ab, ab.1 in\n    let π₂ : P → A₂ := λ ab, ab.2 in\n    let E := equalizer_set (f ∘ π₁) (g ∘ π₂) in\n    let e : E → P := E ↪ P in\n    ⟨ begin \n        tidy\n    end\n    ,\n    begin\n        intros Q q₁ q₂ fq₁_gq₂,\n        have eq := eqaulizer_set_is_equalizer (f ∘ π₁) (g ∘ π₂),\n        have pr := cartesian_product_is_product A₁ A₂ Q q₁ q₂,\n        let p : Q → P := some pr,\n        have spec_p : q₁ = π₁ ∘ p ∧ q₂ = π₂ ∘ p := (some_spec pr).1,\n\n        have eq_comp : f ∘ π₁ ∘ p = g ∘ π₂ ∘ p := \n            spec_p.2 ▸ (spec_p.1 ▸ fq₁_gq₂),\n\n        let h : Q → E := some (eq.2 p eq_comp),\n        have spec_h : p = e ∘ h := (some_spec (eq.2 p eq_comp)).1,\n        use h,\n        split, \n        have h0 : q₁ = π₁ ∘ e ∘ h ∧ q₂ = π₂ ∘ e ∘ h :=\n            ⟨ \n                by simp [spec_h , spec_p.1]\n                ,  \n                by simp [spec_h , spec_p.2]\n            ⟩ ,\n        exact h0,\n        assume (y : Q → E) (hy : q₁ = π₁ ∘ e ∘ y ∧ q₂ = π₂ ∘ e ∘ y),\n        have s0 : π₁ ∘ e ∘ h = π₁ ∘ e ∘ y := \n                spec_h ▸ (spec_p.1 ▸ hy.1),\n        have s1 : π₂ ∘ e ∘ h = π₂ ∘ e ∘ y := \n                spec_h ▸ (spec_p.2 ▸ hy.2),\n        have eh_ey : e ∘ h = e ∘ y := \n            jointly_mono A₁ A₂ (A₁ × A₂) prod.fst prod.snd \n                (cartesian_product_is_product A₁ A₂) s0 s1,\n        \n        have elements : ∀ q, y q = h q :=\n            assume q,\n            have e0 : (e ∘ y) q = (e ∘ h) q := \n                by rw eh_ey,\n            (inj_inclusion P E) e0,\n        exact funext elements\n            \n    end ⟩ \n\n\n\n\n\n\n\nend Pullback", "meta": {"author": "QaisHamarneh", "repo": "Coalgebra-in-Lean", "sha": "bd0452df98bc64b608e5dfd7babc42c301bb6a46", "save_path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean", "path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean/Coalgebra-in-Lean-bd0452df98bc64b608e5dfd7babc42c301bb6a46/src/set_category/limits/Pullback.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754471, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4790551744024527}}
{"text": "\nimport Mathlib\nimport Qpf.Util.Vec\n\nuniverse u v\n\n/-- A curried function of `n` arguments in `α`, resulting in `β`, i.e., `α → ... → α → β` -/\nabbrev CurriedFun (α : Type u) (β : Type v) : Nat → Type (max u v)\n  | 0   => PUnit.{u+1} → β\n  | 1   => α → β\n  | n+1 => α → CurriedFun α β n\n\n\n/-- A curried type function of `n` arguments, i.e., `Type u → Type u → ... → Type v` -/\nabbrev CurriedTypeFun : Nat → Type ((max u v) + 1)\n  := CurriedFun (Type u) (Type v)\n\n/-- An uncurried type function, all `n` arguments are collected into a single `TypeVec n` \n    Note that all arguments live in the same universe, but the result may be in a different universe\n-/\nabbrev TypeFun (n : Nat) : Type ((max u v) + 1) := \n  TypeVec.{u} n → Type v\n\nnamespace TypeFun\n  def reverseArgs : TypeFun n → TypeFun n :=\n    fun v α => v <| Vec.reverse α \n\n  @[simp]\n  theorem reverseArgs_involution (F : TypeFun n) :\n    F.reverseArgs.reverseArgs = F :=\n  by\n    simp only [reverseArgs, Vec.reverse_involution]\n\n\n  def curriedAux : {n : Nat} → TypeFun n → CurriedTypeFun n\n    | 0,    F => fun _ => F !![]\n    | 1,    F => fun a => F !![a] \n    | _+2,  F => fun a => curriedAux fun αs => F (αs ::: a)\n\n  def curried (F : TypeFun n) : CurriedTypeFun n\n    := curriedAux (F.reverseArgs)\n\n\n  def ofCurriedAux : {n : Nat} → CurriedTypeFun n → TypeFun n\n    | 0,    F, _ => F PUnit.unit\n    | 1,    F, α => F (α 0)\n    | n+2,  F, α => ofCurriedAux (F α.last) α.drop\n\n  def ofCurried (F : CurriedTypeFun n) : TypeFun n\n    := (ofCurriedAux F).reverseArgs\n\n\n\n  @[simp]\n  theorem curriedAux_ofCurriedAux_involution {F : CurriedTypeFun n} :\n    curriedAux (ofCurriedAux F) = F :=\n  by    \n    cases n\n    case zero => simp [curriedAux, ofCurriedAux]\n    case succ n => {\n      induction n\n      <;> simp [curriedAux, ofCurriedAux, Vec.append1]\n\n      case succ _ ih => {\n        funext a;\n        simp[reverseArgs_involution]\n        apply @ih (F a);\n      }\n    } \n\n  @[simp]\n  theorem curried_ofCurried_involution {F : CurriedTypeFun n} :\n    curried (ofCurried F) = F :=\n  by    \n    simp only [curried, ofCurried, reverseArgs_involution]\n    apply curriedAux_ofCurriedAux_involution\n\n\n\n  @[simp]\n  theorem ofCurriedAux_curriedAux_involution {F : TypeFun n} :\n    ofCurriedAux (curriedAux F) = F :=\n  by    \n    cases n\n    case zero => \n      funext x;\n      simp [curriedAux, ofCurriedAux, Matrix.vecEmpty]\n      congr\n      funext i\n      contradiction\n    case succ n => {\n      induction n;\n      case zero => {\n        funext x;\n        simp [curriedAux, ofCurriedAux];\n        apply congrArg;\n        funext i;\n        cases i;\n        . simp [Vec.append1, OfNat.ofNat]\n        . contradiction\n      }\n\n      case succ _ ih => {\n        funext x;\n        simp [ofCurriedAux, curriedAux];\n        let F' := fun α => F (α ::: x.last);\n        have : F x = F' x.drop;\n        . simp\n        rw [this]\n        rw [@ih F']\n      }\n    }\n\n  @[simp]\n  theorem ofCurried_curried_involution {F : TypeFun n} :\n    ofCurried (curried F) = F :=\n  by    \n    simp only [ofCurried, curried, ofCurriedAux_curriedAux_involution]\n    apply reverseArgs_involution\nend TypeFun", "meta": {"author": "alexkeizer", "repo": "qpf4", "sha": "980f97425b9d5a5e3897073df33794192b3b3124", "save_path": "github-repos/lean/alexkeizer-qpf4", "path": "github-repos/lean/alexkeizer-qpf4/qpf4-980f97425b9d5a5e3897073df33794192b3b3124/Qpf/Util/TypeFun.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125626441471, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.47905517060462083}}
{"text": "import category_theory.preadditive.functor_category\nimport algebra.homology.additive\nimport algebra.homology.homological_complex\nimport algebra.category.Group.limits\nimport analysis.normed.group.SemiNormedGroup.kernels\nimport analysis.normed.group.SemiNormedGroup.completion\n\nimport facts\n\nuniverse variables v u\nnoncomputable theory\nopen opposite category_theory\nopen_locale nnreal\n\n/-!\n\n# Systems of complexes of seminormed groups\n\nIn this file we define systems of complexes of seminormed groups,\nas in of Definition 9.3 of [Analytic].\n\n## Main declarations\n\n* `system_of_complexes`: a system of complexes of seminormed groups. See Definition 4.1\n  of the blueprint.\n* `admissible`: such a system is *admissible* if all maps that occur in the system\n    are norm-nonincreasing. See Definition 4.2 of the blueprint.\n* `is_bounded_exact`: an exactness criterion for such systems, See Definition 4.3 of the\n  blueprint. It asks for a suitable interplay between the norms and the algebraic properties\n  of the system.\n* `is_weak_bounded_exact` : another exactness criterion for such systems. See Definition 4.4\n   of the blueprint.\n\n## TODO\n\nIt seems a bit ridiculous that this file has to import `locally_constant.Vhat`.\n\n-/\n\n-- TODO: at some point we can abstract the following definition over `SemiNormedGroup` and `ℝ≥0`.\n-- But I don't think that is relevant for this project.\n\n/-- A system of complexes of seminormed groups, indexed by `ℝ≥0`.\nSee also Definition 9.3 of [Analytic]. -/\n@[derive [category_theory.category, category_theory.preadditive]]\ndef system_of_complexes : Type* := ℝ≥0ᵒᵖ ⥤ (cochain_complex SemiNormedGroup ℕ)\n\n-- instance : has_shift system_of_complexes := has_shift.mk $ (shift _).congr_right\n\nvariables {M M' N : system_of_complexes.{u}} (f : M ⟶ M') (g : M' ⟶ N)\n\ninstance : has_coe_to_fun system_of_complexes (λ C, ℝ≥0 → ℕ → SemiNormedGroup) :=\n⟨λ C c i, (C.obj $ op c).X i⟩\n\n/-- `f.apply c i` is application of the natural transformation `f`: $f_c^i : M_c^i ⟶ N_c^i$. -/\ndef quiver.hom.apply (f : M ⟶ N) {c : ℝ≥0} {i : ℕ} : M c i ⟶ N c i :=\n(f.app (op c)).f i\n\ninstance hom_to_fun : has_coe_to_fun (M ⟶ N) (λ f, Π {c : ℝ≥0} {i : ℕ}, M c i → N c i) :=\n⟨λ f {c} {i} x, f.apply x⟩\n\nlemma system_of_complexes.hom_apply (f : M ⟶ N) {c : ℝ≥0} {i : ℕ} (x : M c i) : f x = f.apply x :=\nrfl\n\nlemma system_of_complexes.map_sub (f : M ⟶ N) {c i} (m m' : M c i) : f (m-m') = f m - f m' :=\nmap_sub ((f.app (op c)).f i) m m'\n\n/-- `f.apply c i` is application of the natural isomorphism `f`: $f_c^i : M_c^i ≅ N_c^i$. -/\ndef category_theory.iso.apply (f : M ≅ N) {c : ℝ≥0} {i : ℕ} : M c i ≅ N c i :=\nhomological_complex.hom.iso_app (f.app (op c)) i\n\nnamespace system_of_complexes\n\nvariables (C C₁ C₂ : system_of_complexes.{u})\n\n/-- `res` is the restriction map `C c' i ⟶ C c i` for a system of complexes `C`,\nand nonnegative reals `c ≤ c'`. -/\ndef res {C : system_of_complexes} {c' c : ℝ≥0} {i : ℕ} [h : fact (c ≤ c')] : C c' i ⟶ C c i :=\n(C.map (hom_of_le h.out).op).f i\n\nvariables {c₁ c₂ c₃ : ℝ≥0} (i j : ℕ)\n\n@[simp] lemma res_comp_res (h₁ : fact (c₂ ≤ c₁)) (h₂ : fact (c₃ ≤ c₂)) :\n  @res C _ _ i h₁ ≫ @res C _ _ i h₂ = @res C _ _ i ⟨h₂.out.trans h₁.out⟩ :=\nbegin\n  have := (category_theory.functor.map_comp C (hom_of_le h₁.out).op (hom_of_le h₂.out).op),\n  rw [← op_comp] at this,\n  delta res,\n  erw this,\n  refl,\nend\n\n@[simp] lemma res_res (h₁ : fact (c₂ ≤ c₁)) (h₂ : fact (c₃ ≤ c₂)) (x : C c₁ i) :\n  @res C _ _ i h₂ (@res C _ _ i h₁ x) = @res C _ _ i ⟨h₂.out.trans h₁.out⟩ x :=\nby { rw ← (C.res_comp_res i h₁ h₂), refl }\n\n/-- `C.d` is the differential `C c i ⟶ C c (i+1)` for a system of complexes `C`. -/\ndef d (C : system_of_complexes) {c : ℝ≥0} (i j : ℕ) : C c i ⟶ C c j :=\n(C.obj $ op c).d i j\n\nlemma d_eq_zero (c : ℝ≥0) (h : i + 1 ≠ j) : (C.d i j : C c i ⟶ C c j) = 0 :=\n(C.obj $ op c).shape _ _ h\n\nlemma d_eq_zero_apply (c : ℝ≥0) (h : i + 1 ≠ j) (x : C c i) : (C.d i j x) = 0 :=\nby { rw [d_eq_zero C i j c h], refl }\n\n@[simp] lemma d_self_apply (c : ℝ≥0) (x : C c i) : (C.d i i x) = 0 :=\nd_eq_zero_apply _ _ _ _ i.succ_ne_self _\n\nlemma d_comp_d (c : ℝ≥0) (i j k : ℕ) : C.d i j ≫ (C.d j k : C c j ⟶ _) = 0 :=\n(C.obj $ op c).d_comp_d _ _ _\n\n@[simp] lemma d_d (c : ℝ≥0) (i j k : ℕ) (x : C c i) :\n  C.d j k (C.d i j x) = 0 :=\nshow ((C.d i j) ≫ C.d j k) x = 0, by { rw d_comp_d, refl }\n\nlemma d_comp_res (h : fact (c₂ ≤ c₁)) :\n  C.d i j ≫ @res C _ _ _ h = @res C _ _ _ _ ≫ C.d i j :=\n((C.map (hom_of_le h.out).op).comm _ _).symm\n\nlemma d_res (h : fact (c₂ ≤ c₁)) (x) :\n  C.d i j (@res C _ _ _ _ x) = @res C _ _ _ h (C.d i j x) :=\nshow (@res C _ _ _ _ ≫ C.d i j) x = (C.d i j ≫ @res C _ _ _ h) x,\nby rw d_comp_res\n\nsection iso\n\nvariables (ϕ : M ≅ N) (c : ℝ≥0) (i)\n\nlemma apply_hom_eq_hom_apply : (ϕ.apply.hom : M c i ⟶ N c i) = ϕ.hom.apply := rfl\n\nlemma apply_inv_eq_inv_apply : (ϕ.apply.inv : N c i ⟶ M c i) = ϕ.inv.apply := rfl\n\n@[simp] lemma hom_apply_comp_inv_apply :\n  (ϕ.hom.apply : M c i ⟶ N c i) ≫ ϕ.inv.apply = 𝟙 _ :=\nby rw [← apply_hom_eq_hom_apply, ← apply_inv_eq_inv_apply, iso.hom_inv_id]\n\n@[simp] lemma inv_apply_comp_hom_apply :\n  (ϕ.inv.apply : N c i ⟶ M c i) ≫ ϕ.hom.apply = 𝟙 _ :=\nby rw [← apply_hom_eq_hom_apply, ← apply_inv_eq_inv_apply, iso.inv_hom_id]\n\n@[simp] lemma inv_apply_hom_apply (x : M c i) :\n  ϕ.inv.apply (ϕ.hom.apply x) = x :=\nshow ((ϕ.hom.apply : M c i ⟶ N c i) ≫ ϕ.inv.apply) x = x,\nby simp only [hom_apply_comp_inv_apply, coe_id, id.def]\n\n@[simp] lemma hom_apply_inv_apply (x : N c i) :\n  ϕ.hom (ϕ.inv x) = x :=\nshow ((ϕ.inv.apply : N c i ⟶ M c i) ≫ ϕ.hom.apply) x = x,\nby simp only [inv_apply_comp_hom_apply, coe_id, id.def]\n\nend iso\n\n/-- Convenience definition:\nThe identity morphism of an object in the system of complexes\nwhen it is given by different indices that are not\ndefinitionally equal. -/\ndef congr {c c' : ℝ≥0} {i i' : ℕ} (hc : c = c') (hi : i = i') :\n  C c i ⟶ C c' i' :=\neq_to_hom $ by { subst hc, subst hi }\n\nvariables (M M' N)\n\nlemma d_apply (f : M ⟶ N) {c : ℝ≥0} {i j : ℕ} (m : M c i) :\n  N.d i j (f m) = f (M.d i j m) :=\nbegin\n  show (_ ≫ N.d i j) m = (M.d i j ≫ _) m,\n  congr' 1,\n  exact (f.app (op c)).comm i j\nend\n\nlemma res_comp_apply (f : M ⟶ N) (c c' : ℝ≥0) [h : fact (c ≤ c')] (i : ℕ) :\n  @res M c' c i _ ≫ f.apply = f.apply ≫ res :=\ncongr_fun (congr_arg homological_complex.hom.f (f.naturality (hom_of_le h.out).op)) i\n\nlemma res_apply (f : M ⟶ N) (c c' : ℝ≥0) [h : fact (c ≤ c')] {i : ℕ} (m : M c' i) :\n  @res N c' c _ _ (f m) = f (res m) :=\nshow (f.apply ≫ (@res N c' c _ _)) m = (@res M c' c _ _ ≫ (f.apply)) m,\nby rw res_comp_apply\n\n/-- A system of complexes is *admissible*\nif all the differentials and restriction maps are norm-nonincreasing.\n\nSee Definition 9.3 of [Analytic]. -/\nstructure admissible (C : system_of_complexes) : Prop :=\n(d_norm_noninc' : ∀ c i j (h : i + 1 = j), (C.d i j : C c i ⟶ C c j).norm_noninc)\n(res_norm_noninc : ∀ c' c i h, (@res C c' c i h).norm_noninc)\n\nlemma admissible.d_norm_noninc (hC : C.admissible) (c : ℝ≥0) (i j : ℕ) :\n  (C.d i j : C c i ⟶ _).norm_noninc :=\nbegin\n  by_cases h : i + 1 = j,\n  { exact hC.d_norm_noninc' c i j h },\n  { rw C.d_eq_zero i j c h, intro v, simp }\nend\n\nvariables {M M'}\n\nlemma admissible_of_isometry {f : M ⟶ M'} (hadm : M'.admissible)\n  (hiso : ∀ c i, @isometry (M c i) (M' c i) _ _ f.apply) :\n  M.admissible :=\nbegin\n  refine ⟨λ c i j h x, _, λ c' c i h x, _⟩,\n  { rw [← (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c i) _,\n      ← (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c j) _, ← system_of_complexes.hom_apply f,\n      ← d_apply],\n    exact hadm.d_norm_noninc _ _ _ _ _ },\n  { rw [← (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c i) _,\n      ← (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c' i) _, ← system_of_complexes.hom_apply f,\n      ← system_of_complexes.hom_apply f, ← res_apply],\n    exact hadm.res_norm_noninc _ _ _ _ _  }\nend\n\nvariables (M M')\n\n/-- `is_bounded_exact k K m c₀` is a predicate on systems of complexes.\n\nA system of complexes `C` is `(k,K)`-exact in degrees `≤ m` for `c ≥ c₀`*\nif the following condition is satisfied:\nFor all `c ≥ c₀` and all `x : C (k * c) i` with `i ≤ m` there is some `y : C c (i-1)`\n(which is defined to be `0` when `i = 0`) such that `∥(C.res x) - (C.d y)∥ ≤ K * ∥C.d x∥`.\n\nSee Definition 9.3 of [Analytic] (which coalesces the roles of `k` and `K`).\n\nImplementation details:\n* Because we have a differential `d i j : C c i ⟶ C c j` for all `i` and `j`,\n  and because `d 0 0 = 0` and `0 - 1 = 0` in Lean's natural numbers,\n  we automatically take care of the parenthetical condition about `i = 0`.\n* We phrase the condition in a somewhat roundabout way, as\n  ```\n  ∃ (i₀ j : ℕ) (hi₀ : i₀ = i - 1) (hj : i + 1 = j)\n    (y : C c i₀), ∥res x - C.d _ _ y∥ ≤ K * ∥C.d i j x∥\n  ```\n  This is a hack around an inconvenience known as dependent type theory hell. -/\ndef is_bounded_exact\n  (k K : ℝ≥0) (m : ℕ) [hk : fact (1 ≤ k)] (c₀ : ℝ≥0) : Prop :=\n∀ c (hc : fact (c₀ ≤ c)) i (hi : i ≤ m) (x : C (k * c) i),\n∃ (i₀ j : ℕ) (hi₀ : i₀ = i - 1) (hj : i + 1 = j)\n  (y : C c i₀), ∥res x - C.d _ _ y∥ ≤ K * ∥C.d i j x∥\n\n/-- Weak version of `is_bounded_exact`. -/\ndef is_weak_bounded_exact\n  (k K : ℝ≥0) (m : ℕ) [hk : fact (1 ≤ k)] (c₀ : ℝ≥0) : Prop :=\n∀ c (hc : fact (c₀ ≤ c)) i (hi : i ≤ m) (x : C (k * c) i) (ε : ℝ) (hε : 0 < ε),\n∃ (i₀ j : ℕ) (hi₀ : i₀ = i - 1) (hj : i + 1 = j)\n  (y : C c i₀), ∥res x - C.d _ _ y∥ ≤ K * ∥C.d i j x∥ + ε\n\nnamespace is_weak_bounded_exact\n\nvariables {C C₁ C₂}\nvariables {k k' K K' : ℝ≥0} {m m' : ℕ} {c₀ c₀' : ℝ≥0} [fact (1 ≤ k)] [fact (1 ≤ k')]\n\nlemma of_le (hC : C.is_weak_bounded_exact k K m c₀) (hC_adm : C.admissible)\n  (hk : fact (k ≤ k')) (hK : fact (K ≤ K')) (hm : m' ≤ m) (hc₀ : fact (c₀ ≤ c₀')) :\n  C.is_weak_bounded_exact k' K' m' c₀' :=\nbegin\n  intros c hc i hi x ε ε_pos,\n  haveI : fact (k ≤ k') := hk,\n  obtain ⟨i', j, hi', hj, y, hy⟩ := hC c ⟨hc₀.out.trans hc.out⟩ i (hi.trans hm) (res x) ε ε_pos,\n  use [i', j, hi', hj, y],\n  simp only [res_res] at hy,\n  refine le_trans hy _,\n  rw d_res,\n  apply add_le_add_right,\n  exact mul_le_mul hK.out (hC_adm.res_norm_noninc _ _ _ _ (C.d _ _ x))\n    (norm_nonneg _) ((zero_le K).trans hK.out)\nend\n\nlemma of_iso (h : C₁.is_weak_bounded_exact k K m c₀) (f : C₁ ≅ C₂)\n  (hf : ∀ c i, @isometry (C₁ c i) (C₂ c i) _ _ (f.hom.apply : C₁ c i ⟶ C₂ c i)) :\n  C₂.is_weak_bounded_exact k K m c₀ :=\nbegin\n  intros c hc i hi x ε hε,\n  obtain ⟨i', j, hi', hj, y, hy⟩ := h c hc i hi (f.inv.apply x) ε hε,\n  refine ⟨i', j, hi', hj, f.hom y, _⟩,\n  calc  ∥res x - C₂.d _ _ (f.hom y)∥\n      = ∥res x - f.hom (C₁.d _ _ y)∥ : by rw d_apply\n  ... = ∥f.hom (f.inv (res x)) - f.hom (C₁.d _ _ y)∥ : by rw hom_apply_inv_apply\n  ... = ∥f.hom (f.inv (res x) - C₁.d _ _ y)∥ : by congr ; exact (system_of_complexes.map_sub _ _ _).symm\n  ... = ∥f.inv (res x) - C₁.d _ _ y∥ : normed_add_group_hom.norm_eq_of_isometry (hf _ _) _\n  ... = ∥res (f.inv x) - C₁.d _ _ y∥ : by rw res_apply\n  ... ≤ K * ∥C₁.d _ _ (f.inv x)∥ + ε : hy\n  ... = K * ∥C₂.d _ _ x∥ + ε : _,\n  congr' 2,\n  calc  ∥C₁.d i j (f.inv x)∥\n      = ∥f.inv (C₂.d i j x)∥ : by rw d_apply\n  ... = ∥f.hom (f.inv (C₂.d _ _ x))∥ : (normed_add_group_hom.norm_eq_of_isometry (hf _ _) _).symm\n  ... = ∥C₂.d _ _ x∥ : by rw hom_apply_inv_apply\nend\n\nlemma iff_of_iso (f : C₁ ≅ C₂)\n  (hf : ∀ c i, @isometry (C₁ c i) (C₂ c i) _ _ (f.hom.apply : C₁ c i ⟶ C₂ c i)) :\n  C₁.is_weak_bounded_exact k K m c₀ ↔ C₂.is_weak_bounded_exact k K m c₀ :=\nbegin\n  refine ⟨λ h, h.of_iso f hf, λ h, h.of_iso f.symm _⟩,\n  -- TODO: factor this out into a lemma\n  intros c n,\n  apply add_monoid_hom_class.isometry_of_norm,\n  intro v,\n  rw ← normed_add_group_hom.norm_eq_of_isometry (hf c n),\n  simp only [←apply_hom_eq_hom_apply, ←apply_inv_eq_inv_apply, iso.symm_hom, iso.inv_hom_id_apply],\nend\n\nend is_weak_bounded_exact\n\nnamespace is_bounded_exact\n\nvariables {C C₁ C₂}\nvariables {k k' K K' : ℝ≥0} {m m' : ℕ} {c₀ c₀' : ℝ≥0} [fact (1 ≤ k)] [fact (1 ≤ k')]\n\nlemma of_le (hC : C.is_bounded_exact k K m c₀)\n  (hC_adm : C.admissible) (hk : k ≤ k') (hK : K ≤ K') (hm : m' ≤ m) (hc₀ : c₀ ≤ c₀') :\n  C.is_bounded_exact k' K' m' c₀' :=\nbegin\n  intros c hc i hi x,\n  haveI : fact (k ≤ k') := ⟨hk⟩,\n  obtain ⟨i', j, hi', hj, y, hy⟩ := hC c ⟨hc₀.trans hc.out⟩ i (hi.trans hm) (res x),\n  use [i', j, hi', hj, y],\n  simp only [res_res] at hy,\n  refine le_trans hy _,\n  rw d_res,\n  exact mul_le_mul hK (hC_adm.res_norm_noninc _ _ _ _ (C.d _ _ x)) (norm_nonneg _) ((zero_le K).trans hK)\nend\n\nlemma of_iso (h : C₁.is_bounded_exact k K m c₀) (f : C₁ ≅ C₂)\n  (hf : ∀ c i, @isometry (C₁ c i) (C₂ c i) _ _ (f.hom.apply : C₁ c i ⟶ C₂ c i)) :\n  C₂.is_bounded_exact k K m c₀ :=\nbegin\n  intros c hc i hi x,\n  obtain ⟨i', j, hi', hj, y, hy⟩ := h c hc i hi (f.inv.apply x),\n  refine ⟨i', j, hi', hj, f.hom y, _⟩,\n  calc  ∥res x - C₂.d _ _ (f.hom y)∥\n      = ∥res x - f.hom (C₁.d _ _ y)∥ : by rw d_apply\n  ... = ∥f.hom (f.inv (res x)) - f.hom (C₁.d _ _ y)∥ : by rw hom_apply_inv_apply\n  ... = ∥f.hom (f.inv (res x) - C₁.d _ _ y)∥ : by congr ; exact (system_of_complexes.map_sub _ _ _).symm\n  ... = ∥f.inv (res x) - C₁.d _ _ y∥ : normed_add_group_hom.norm_eq_of_isometry (hf _ _) _\n  ... = ∥res (f.inv x) - C₁.d _ _ y∥ : by rw res_apply\n  ... ≤ K * ∥C₁.d _ _ (f.inv x)∥ : hy\n  ... = K * ∥C₂.d _ _ x∥ : congr_arg _ _,\n  calc  ∥C₁.d i j (f.inv x)∥\n      = ∥f.inv (C₂.d i j x)∥ : by rw d_apply\n  ... = ∥f.hom (f.inv (C₂.d _ _ x))∥ : (normed_add_group_hom.norm_eq_of_isometry (hf _ _) _).symm\n  ... = ∥C₂.d _ _ x∥ : by rw hom_apply_inv_apply\nend\n\nend is_bounded_exact\n\nnamespace is_weak_bounded_exact\n\nvariables {C C₁ C₂}\nvariables {k k' K K' : ℝ≥0} {m m' : ℕ} {c₀ c₀' : ℝ≥0} [fact (1 ≤ k)] [fact (1 ≤ k')]\n\nlemma to_exact (hC : C.is_weak_bounded_exact k K m c₀)\n  [∀ c i, separated_space (C c i)]\n  {δ : ℝ≥0} (hδ : 0 < δ)\n  (H : ∀ c ≥ c₀, ∀ i ≤ m, ∀ x : C (k * c) i, ∀ j, i+1 = j →\n    C.d _ j x = 0 → ∃ (i₀ : ℕ) (hi₀ : i₀ = i - 1) (y : C c i₀), res x = C.d _ _ y) :\n  C.is_bounded_exact k (K + δ) m c₀ :=\nbegin\n  intros c hc i hi x,\n  by_cases hdx : C.d _ (i+1) x = 0,\n  { rcases H c hc.out i hi x _ rfl hdx with ⟨i₀, hi₀, y, hy⟩,\n    exact ⟨i₀, _, hi₀, rfl, y, by simp [hy, hdx]⟩ },\n  { obtain ⟨i', j, hi', rfl, y, hy⟩ :=\n      hC c hc _ hi x (δ*∥C.d _ (i+1) x∥) (mul_pos (by exact_mod_cast hδ) $ norm_pos_iff'.mpr hdx),\n    refine ⟨i', _, hi', rfl, y, _⟩,\n    have : ((K + δ : ℝ≥0) : ℝ) * ∥C.d _ (i+1) x∥\n      = K * ∥C.d _ (i+1) x∥ + δ * ∥C.d _ (i+1) x∥, apply_mod_cast add_mul,\n    rwa this },\nend\n\nend is_weak_bounded_exact\nsection quotient\n\nopen normed_add_group_hom\n\nvariables {M M'}\n\n/-- The quotient of a system of complexes. -/\ndef is_quotient (f : M ⟶ M') : Prop :=\n∀ c i, (f.apply : M c i ⟶ M' c i).is_quotient\n\n-- The next three lemmas restate lemmas about normed_add_group_hom.is_quotient in terms of the coercion\n-- of `M ⟶ M'` to functions.\n\nlemma is_quotient.surjective {f : M ⟶ M'} (h : is_quotient f) {c i} (m' : M' c i) :\n  ∃ m : M c i, f m = m' := (h c i).surjective m'\n\nlemma is_quotient.norm_lift {f : M ⟶ M'} (h : is_quotient f) {ε : ℝ} (hε : 0 < ε) {c i}\n  (n : M' c i) : ∃ (m : M c i), f m = n ∧ ∥m∥ < ∥n∥ + ε :=\n(h c i).norm_lift hε n\n\nlemma is_quotient.norm_le {f : M ⟶ M'} (h : is_quotient f) {c i} (m : M c i) : ∥f m∥ ≤ ∥m∥ :=\n(h c i).norm_le _\n\n/-- The quotient of an admissible system of complexes is admissible. -/\nlemma admissible_of_quotient {f : M ⟶ M'} (hquot : is_quotient f) (hadm : M.admissible) :\n  M'.admissible :=\nbegin\n  split,\n  { intros c i j h m',\n    refine le_of_forall_pos_le_add _,\n    intros ε hε,\n    obtain ⟨m, hm : f m = m' ∧ ∥m∥ < ∥m'∥ + ε⟩ := hquot.norm_lift hε m',\n    rw [← hm.1, d_apply],\n    calc ∥f (M.d _ _ m)∥ ≤ ∥M.d _ _ m∥ : hquot.norm_le _\n      ... ≤ ∥m∥ : hadm.d_norm_noninc _ _ _ _ m\n      ... ≤ ∥m'∥ + ε : le_of_lt hm.2\n      ... = ∥f m∥ + ε : by rw [hm.1] },\n  { intros c' c i hc m',\n    letI h := hc,\n    refine le_of_forall_pos_le_add _,\n    intros ε hε,\n    obtain ⟨m, hm⟩ := hquot.norm_lift hε m',\n    rw [← hm.1, res_apply],\n    calc ∥f (res m)∥ ≤ ∥res m∥ : hquot.norm_le _\n      ... ≤ ∥m∥ : hadm.res_norm_noninc c' c _ hc m\n      ... ≤ ∥m'∥ + ε : le_of_lt hm.2\n      ... = ∥f m∥ + ε : by rw [hm.1] }\nend\n\nend quotient\n\n-- move me\ninstance SemiNormedGroup.forget₂_Ab : has_forget₂ SemiNormedGroup Ab :=\n{ forget₂ :=\n  { obj := λ V, AddCommGroup.of V,\n    map := λ _ _ f, f.to_add_monoid_hom },\n  forget_comp := by tidy }\n\ninstance SemiNormedGroup.forget₂_Ab_additive : (forget₂ SemiNormedGroup Ab).additive := {}\n\ndef to_Ab (C : system_of_complexes) : ℝ≥0ᵒᵖ ⥤ cochain_complex Ab ℕ :=\nC ⋙ functor.map_homological_complex (forget₂ _ _) _\n\nend system_of_complexes\n\n-- #lint- only unused_arguments def_lemma doc_blame\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/system_of_complexes/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.47905516213934585}}
{"text": "import tactic\nimport for_mathlib -- gives us new theorem `alg_hom.eq_of_id`\n\n/-!\n\n# Formally smooth morphisms\n\nA ring morphism `A →+* B` between commutative rings `A` and `B` is *formally smooth*\nif for every surjective square-zero extension of A-algebras `R' →+* R`\n(meaning that the kernel I satisties I² = 0)\nthe natural map Hom_A(B,R') → Hom_A(B,R) is surjective.\n\n-/\n\n-- Let A and B be commutative rings\nvariables {A B : Type} [comm_ring A] [comm_ring B]\n\n/-- A ring homomorphism `f : A → B` is *formally smooth* if for every surjective square zero\nmorphism `φ : R → R'` of A-algebras, the natural map Hom_A(B,R') → Hom_A(B, R) is\na surjection. -/\ndef is_formally_smooth {A B : Type} [comm_ring A] [comm_ring B] (f : A →+* B) : Prop :=\n-- First let's make B into an A-algebra in the obvious way via f\nlet h : algebra A B := f.to_algebra in\n-- The condition is: For all A-algebras R and R'\n∀ {{R R' : Type}} [comm_ring R] [comm_ring R'], by exactI\n∀ [algebra A R] [algebra A R'], by exactI\n-- and for all A-algebra morphisms φ : R' → R with square zero\n∀ {φ : R' →ₐ[A] R} (hφ1 : ∀ r : R, ∃ r' : R', φ r' = r) \n  (hφ2 : ∀ x y : R', φ x = 0 → φ y = 0 → x * y = 0),\n-- composing with φ is a surjection Hom_A(B,R') → Hom_A(B, R)\nfunction.surjective (φ.comp : (B →ₐ[A] R') → (B →ₐ[A] R))\n\nlemma is_formally_smooth_id : is_formally_smooth (ring_hom.id A : A →+* A) :=\nλ R R' _ _ _ _ φ _ _ ψ, by resetI; exact ⟨algebra.of_id A R', subsingleton.elim _ _⟩\n\nvariables {C : Type} [comm_ring C]\n\nlemma is_formally_smooth_comp {φ : A →+* B} (hφ : is_formally_smooth φ)\n  {ψ : B →+* C} (hψ : is_formally_smooth ψ) : is_formally_smooth (ψ.comp φ) :=\nbegin\n  intros R R' _ _ _ _ f hf1 hf2 g,\n  resetI,\n  specialize hφ hf1 hf2,\n  letI : algebra A B := φ.to_algebra,\n  letI : algebra A C := (ψ.comp φ).to_algebra,\n  let ψ' : B →ₐ[A] C := \n  { commutes' := λ r, rfl, -- definitional abuse!\n    ..ψ },\n  let ρ := g.comp ψ',\n  unfold function.surjective at hφ,\n  specialize hφ ρ,\n  cases hφ with σ hσ,\n  -- last four lines can be done  with \n  --  obtain ⟨σ, hσ⟩ := hφ (g.comp ψ'),\n  -- use σ to make R' into a B-algebra\n  letI : algebra B R' := σ.to_ring_hom.to_algebra,\n  letI : algebra B R := ρ.to_ring_hom.to_algebra,\n  let f' : R' →ₐ[B] R :=\n  { commutes' := begin \n-- alternate proof:\n--      rw alg_hom.ext_iff at hσ,\n--      exact hσ,\n      intro r,\n      change _ = ρ r,\n      rw ← hσ,\n      refl,\n    end,\n    ..f.to_ring_hom, },\n  have hf1' : ∀ (r : R), ∃ (r' : R'), f' r' = r,\n  exact hf1,\n  have hf2' : ∀ (x y : R'), f x = 0 → f y = 0 → x * y = 0,\n  exact hf2,\n  specialize hψ hf1' hf2',\n  letI : algebra B C := ψ.to_algebra,\n  let g' : C →ₐ[B] R :=\n  { commutes' := begin \n    intro,\n    refl, end,\n    ..g },\n  obtain ⟨τ, hτ⟩ := hψ g',\n  let τ' : C →ₐ[A] R' :=\n  { commutes' := begin intro r,\n      convert τ.commutes (φ r),\n      suffices : algebra.of_id A R' = σ.comp (algebra.of_id A B),\n      { rw alg_hom.ext_iff at this,\n        apply this, },\n      apply subsingleton.elim,\n    end,\n    ..τ, },\n  use τ',\n  ext,\n  change _ = g' x,\n  rw ← hτ,\n  refl,\nend\n", "meta": {"author": "kbuzzard", "repo": "etale_experiments", "sha": "7d1f2f6f772f03ad553971103696ebc0654068f4", "save_path": "github-repos/lean/kbuzzard-etale_experiments", "path": "github-repos/lean/kbuzzard-etale_experiments/etale_experiments-7d1f2f6f772f03ad553971103696ebc0654068f4/src/formally_smooth.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.47905515695725015}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.monad.monadicity\n! leanprover-community/mathlib commit 4bd8c855d6ba8f0d5eefbf80c20fa00ee034dec9\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Preserves.Shapes.Equalizers\nimport Mathbin.CategoryTheory.Limits.Shapes.Reflexive\nimport Mathbin.CategoryTheory.Monad.Coequalizer\nimport Mathbin.CategoryTheory.Monad.Limits\n\n/-!\n# Monadicity theorems\n\nWe prove monadicity theorems which can establish a given functor is monadic. In particular, we\nshow three versions of Beck's monadicity theorem, and the reflexive (crude) monadicity theorem:\n\n`G` is a monadic right adjoint if it has a right adjoint, and:\n\n* `D` has, `G` preserves and reflects `G`-split coequalizers, see\n  `category_theory.monad.monadic_of_has_preserves_reflects_G_split_coequalizers`\n* `G` creates `G`-split coequalizers, see\n  `category_theory.monad.monadic_of_creates_G_split_coequalizers`\n  (The converse of this is also shown, see\n   `category_theory.monad.creates_G_split_coequalizers_of_monadic`)\n* `D` has and `G` preserves `G`-split coequalizers, and `G` reflects isomorphisms, see\n  `category_theory.monad.monadic_of_has_preserves_G_split_coequalizers_of_reflects_isomorphisms`\n* `D` has and `G` preserves reflexive coequalizers, and `G` reflects isomorphisms, see\n  `category_theory.monad.monadic_of_has_preserves_reflexive_coequalizers_of_reflects_isomorphisms`\n\n## Tags\n\nBeck, monadicity, descent\n\n## TODO\n\nDualise to show comonadicity theorems.\n-/\n\n\nuniverse v₁ v₂ u₁ u₂\n\nnamespace CategoryTheory\n\nnamespace Monad\n\nopen Limits\n\nnoncomputable section\n\n-- Hide the implementation details in this namespace.\nnamespace MonadicityInternal\n\nsection\n\n-- We use these parameters and notations to simplify the statements of internal constructions\n-- here.\nparameter {C : Type u₁}{D : Type u₂}\n\nparameter [Category.{v₁} C][Category.{v₁} D]\n\nparameter {G : D ⥤ C}[IsRightAdjoint G]\n\n-- mathport name: exprF\n-- An unfortunate consequence of the local notation is that it is only recognised if there is an\n-- extra space after the reference.\nlocal notation \"F\" => leftAdjoint G\n\n-- mathport name: expradj\nlocal notation \"adj\" => Adjunction.ofRightAdjoint G\n\n/-- The \"main pair\" for an algebra `(A, α)` is the pair of morphisms `(F α, ε_FA)`. It is always a\nreflexive pair, and will be used to construct the left adjoint to the comparison functor and show it\nis an equivalence.\n-/\ninstance main_pair_reflexive (A : adj.toMonad.Algebra) :\n    IsReflexivePair (F.map A.a) (adj.counit.app (F.obj A.A)) :=\n  by\n  apply is_reflexive_pair.mk' (F.map (adj.Unit.app _)) _ _\n  · rw [← F.map_comp, ← F.map_id]\n    exact congr_arg (fun _ => F.map _) A.unit\n  · rw [adj.left_triangle_components]\n    rfl\n#align category_theory.monad.monadicity_internal.main_pair_reflexive CategoryTheory.Monad.MonadicityInternal.main_pair_reflexive\n\n/-- The \"main pair\" for an algebra `(A, α)` is the pair of morphisms `(F α, ε_FA)`. It is always a\n`G`-split pair, and will be used to construct the left adjoint to the comparison functor and show it\nis an equivalence.\n-/\ninstance main_pair_G_split (A : adj.toMonad.Algebra) :\n    G.IsSplitPair (F.map A.a) (adj.counit.app (F.obj A.A))\n    where splittable := ⟨_, _, ⟨beckSplitCoequalizer A⟩⟩\n#align category_theory.monad.monadicity_internal.main_pair_G_split CategoryTheory.Monad.MonadicityInternal.main_pair_G_split\n\n/-- The object function for the left adjoint to the comparison functor. -/\ndef comparisonLeftAdjointObj (A : adj.toMonad.Algebra)\n    [HasCoequalizer (F.map A.a) (adj.counit.app _)] : D :=\n  coequalizer (F.map A.a) (adj.counit.app _)\n#align category_theory.monad.monadicity_internal.comparison_left_adjoint_obj CategoryTheory.Monad.MonadicityInternal.comparisonLeftAdjointObj\n\n/--\nWe have a bijection of homsets which will be used to construct the left adjoint to the comparison\nfunctor.\n-/\n@[simps]\ndef comparisonLeftAdjointHomEquiv (A : adj.toMonad.Algebra) (B : D)\n    [HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    (comparison_left_adjoint_obj A ⟶ B) ≃ (A ⟶ (comparison adj).obj B) :=\n  calc\n    (comparison_left_adjoint_obj A ⟶ B) ≃ { f : F.obj A.A ⟶ B // _ } :=\n      Cofork.IsColimit.homIso (colimit.isColimit _) B\n    _ ≃ { g : A.A ⟶ G.obj B // G.map (F.map g) ≫ G.map (adj.counit.app B) = A.a ≫ g } :=\n      by\n      refine' (adj.homEquiv _ _).subtypeEquiv _\n      intro f\n      rw [← (adj.homEquiv _ _).Injective.eq_iff, adjunction.hom_equiv_naturality_left,\n        adj.homEquiv_unit, adj.homEquiv_unit, G.map_comp]\n      dsimp\n      rw [adj.right_triangle_components_assoc, ← G.map_comp, F.map_comp, category.assoc,\n        adj.counit_naturality, adj.left_triangle_components_assoc]\n      apply eq_comm\n    _ ≃ (A ⟶ (comparison adj).obj B) :=\n      { toFun := fun g =>\n          { f := _\n            h' := g.Prop }\n        invFun := fun f => ⟨f.f, f.h⟩\n        left_inv := fun g => by ext; rfl\n        right_inv := fun f => by ext; rfl }\n    \n#align category_theory.monad.monadicity_internal.comparison_left_adjoint_hom_equiv CategoryTheory.Monad.MonadicityInternal.comparisonLeftAdjointHomEquiv\n\n/-- Construct the adjunction to the comparison functor.\n-/\ndef leftAdjointComparison\n    [∀ A : adj.toMonad.Algebra, HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    adj.toMonad.Algebra ⥤ D :=\n  by\n  refine'\n    @adjunction.left_adjoint_of_equiv _ _ _ _ (comparison adj)\n      (fun A => comparison_left_adjoint_obj A) (fun A B => _) _\n  · apply comparison_left_adjoint_hom_equiv\n  · intro A B B' g h\n    ext1\n    dsimp [comparison_left_adjoint_hom_equiv]\n    rw [← adj.homEquiv_naturality_right, category.assoc]\n#align category_theory.monad.monadicity_internal.left_adjoint_comparison CategoryTheory.Monad.MonadicityInternal.leftAdjointComparison\n\n/-- Provided we have the appropriate coequalizers, we have an adjunction to the comparison functor.\n-/\n@[simps counit]\ndef comparisonAdjunction\n    [∀ A : adj.toMonad.Algebra, HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    left_adjoint_comparison ⊣ comparison adj :=\n  Adjunction.adjunctionOfEquivLeft _ _\n#align category_theory.monad.monadicity_internal.comparison_adjunction CategoryTheory.Monad.MonadicityInternal.comparisonAdjunction\n\ntheorem comparisonAdjunction_unit_f_aux\n    [∀ A : adj.toMonad.Algebra, HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))]\n    (A : adj.toMonad.Algebra) :\n    (comparison_adjunction.Unit.app A).f =\n      adj.homEquiv A.A _ (coequalizer.π (F.map A.a) (adj.counit.app (F.obj A.A))) :=\n  congr_arg (adj.homEquiv _ _) (Category.comp_id _)\n#align category_theory.monad.monadicity_internal.comparison_adjunction_unit_f_aux CategoryTheory.Monad.MonadicityInternal.comparisonAdjunction_unit_f_aux\n\n/-- This is a cofork which is helpful for establishing monadicity: the morphism from the Beck\ncoequalizer to this cofork is the unit for the adjunction on the comparison functor.\n-/\n@[simps pt]\ndef unitCofork (A : adj.toMonad.Algebra) [HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    Cofork (G.map (F.map A.a)) (G.map (adj.counit.app (F.obj A.A))) :=\n  Cofork.ofπ (G.map (coequalizer.π (F.map A.a) (adj.counit.app (F.obj A.A))))\n    (by\n      change _ = G.map _ ≫ _\n      rw [← G.map_comp, coequalizer.condition, G.map_comp])\n#align category_theory.monad.monadicity_internal.unit_cofork CategoryTheory.Monad.MonadicityInternal.unitCofork\n\n@[simp]\ntheorem unitCofork_π (A : adj.toMonad.Algebra)\n    [HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    (unit_cofork A).π = G.map (coequalizer.π (F.map A.a) (adj.counit.app (F.obj A.A))) :=\n  rfl\n#align category_theory.monad.monadicity_internal.unit_cofork_π CategoryTheory.Monad.MonadicityInternal.unitCofork_π\n\ntheorem comparisonAdjunction_unit_f\n    [∀ A : adj.toMonad.Algebra, HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))]\n    (A : adj.toMonad.Algebra) :\n    (comparison_adjunction.Unit.app A).f = (beckCoequalizer A).desc (unit_cofork A) :=\n  by\n  apply limits.cofork.is_colimit.hom_ext (beck_coequalizer A)\n  rw [cofork.is_colimit.π_desc]\n  dsimp only [beck_cofork_π, unit_cofork_π]\n  rw [comparison_adjunction_unit_f_aux, ← adj.homEquiv_naturality_left A.a, coequalizer.condition,\n    adj.homEquiv_naturality_right, adj.homEquiv_unit, category.assoc]\n  apply adj.right_triangle_components_assoc\n#align category_theory.monad.monadicity_internal.comparison_adjunction_unit_f CategoryTheory.Monad.MonadicityInternal.comparisonAdjunction_unit_f\n\n/-- The cofork which describes the counit of the adjunction: the morphism from the coequalizer of\nthis pair to this morphism is the counit.\n-/\n@[simps]\ndef counitCofork (B : D) :\n    Cofork (F.map (G.map (adj.counit.app B))) (adj.counit.app (F.obj (G.obj B))) :=\n  Cofork.ofπ (adj.counit.app B) (adj.counit_naturality _)\n#align category_theory.monad.monadicity_internal.counit_cofork CategoryTheory.Monad.MonadicityInternal.counitCofork\n\n/-- The unit cofork is a colimit provided `G` preserves it.  -/\ndef unitColimitOfPreservesCoequalizer (A : adj.toMonad.Algebra)\n    [HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))]\n    [PreservesColimit (parallelPair (F.map A.a) (adj.counit.app (F.obj A.A))) G] :\n    IsColimit (unit_cofork A) :=\n  isColimitOfHasCoequalizerOfPreservesColimit G _ _\n#align category_theory.monad.monadicity_internal.unit_colimit_of_preserves_coequalizer CategoryTheory.Monad.MonadicityInternal.unitColimitOfPreservesCoequalizer\n\n/-- The counit cofork is a colimit provided `G` reflects it. -/\ndef counitCoequalizerOfReflectsCoequalizer (B : D)\n    [ReflectsColimit\n        (parallelPair (F.map (G.map (adj.counit.app B))) (adj.counit.app (F.obj (G.obj B)))) G] :\n    IsColimit (counit_cofork B) :=\n  isColimitOfIsColimitCoforkMap G _ (beckCoequalizer ((comparison adj).obj B))\n#align category_theory.monad.monadicity_internal.counit_coequalizer_of_reflects_coequalizer CategoryTheory.Monad.MonadicityInternal.counitCoequalizerOfReflectsCoequalizer\n\ntheorem comparisonAdjunction_counit_app\n    [∀ A : adj.toMonad.Algebra, HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] (B : D) :\n    comparison_adjunction.counit.app B = colimit.desc _ (counit_cofork B) :=\n  by\n  apply coequalizer.hom_ext\n  change\n    coequalizer.π _ _ ≫ coequalizer.desc ((adj.homEquiv _ B).symm (𝟙 _)) _ =\n      coequalizer.π _ _ ≫ coequalizer.desc _ _\n  simp\n#align category_theory.monad.monadicity_internal.comparison_adjunction_counit_app CategoryTheory.Monad.MonadicityInternal.comparisonAdjunction_counit_app\n\nend\n\nend MonadicityInternal\n\nopen CategoryTheory.Adjunction\n\nopen MonadicityInternal\n\nvariable {C : Type u₁} {D : Type u₂}\n\nvariable [Category.{v₁} C] [Category.{v₁} D]\n\nvariable (G : D ⥤ C)\n\n/--\nIf `G` is monadic, it creates colimits of `G`-split pairs. This is the \"boring\" direction of Beck's\nmonadicity theorem, the converse is given in `monadic_of_creates_G_split_coequalizers`.\n-/\ndef createsGSplitCoequalizersOfMonadic [MonadicRightAdjoint G] ⦃A B⦄ (f g : A ⟶ B)\n    [G.IsSplitPair f g] : CreatesColimit (parallelPair f g) G :=\n  by\n  apply monadic_creates_colimit_of_preserves_colimit _ _\n  infer_instance\n  · apply preserves_colimit_of_iso_diagram _ (diagramIsoParallelPair.{v₁} _).symm\n    dsimp\n    infer_instance\n  · apply preserves_colimit_of_iso_diagram _ (diagramIsoParallelPair.{v₁} _).symm\n    dsimp\n    infer_instance\n#align category_theory.monad.creates_G_split_coequalizers_of_monadic CategoryTheory.Monad.createsGSplitCoequalizersOfMonadic\n\nvariable [IsRightAdjoint G]\n\nsection BeckMonadicity\n\n/-- To show `G` is a monadic right adjoint, we can show it preserves and reflects `G`-split\ncoequalizers, and `C` has them.\n-/\ndef monadicOfHasPreservesReflectsGSplitCoequalizers\n    [∀ ⦃A B⦄ (f g : A ⟶ B) [G.IsSplitPair f g], HasCoequalizer f g]\n    [∀ ⦃A B⦄ (f g : A ⟶ B) [G.IsSplitPair f g], PreservesColimit (parallelPair f g) G]\n    [∀ ⦃A B⦄ (f g : A ⟶ B) [G.IsSplitPair f g], ReflectsColimit (parallelPair f g) G] :\n    MonadicRightAdjoint G :=\n  by\n  let L : (adjunction.of_right_adjoint G).toMonad.Algebra ⥤ D := left_adjoint_comparison\n  letI i : is_right_adjoint (comparison (of_right_adjoint G)) := ⟨_, comparison_adjunction⟩\n  constructor\n  let this :\n    ∀ X : (of_right_adjoint G).toMonad.Algebra,\n      is_iso ((of_right_adjoint (comparison (of_right_adjoint G))).Unit.app X) :=\n    by\n    intro X\n    apply is_iso_of_reflects_iso _ (monad.forget (of_right_adjoint G).toMonad)\n    · change is_iso (comparison_adjunction.unit.app X).f\n      rw [comparison_adjunction_unit_f]\n      change\n        is_iso\n          (is_colimit.cocone_point_unique_up_to_iso (beck_coequalizer X)\n              (unit_colimit_of_preserves_coequalizer X)).Hom\n      refine' is_iso.of_iso (is_colimit.cocone_point_unique_up_to_iso _ _)\n  let this : ∀ Y : D, is_iso ((of_right_adjoint (comparison (of_right_adjoint G))).counit.app Y) :=\n    by\n    intro Y\n    change is_iso (comparison_adjunction.counit.app Y)\n    rw [comparison_adjunction_counit_app]\n    change is_iso (is_colimit.cocone_point_unique_up_to_iso _ _).Hom\n    infer_instance\n    apply counit_coequalizer_of_reflects_coequalizer _\n    letI :\n      G.is_split_pair ((left_adjoint G).map (G.map ((adjunction.of_right_adjoint G).counit.app Y)))\n        ((adjunction.of_right_adjoint G).counit.app ((left_adjoint G).obj (G.obj Y))) :=\n      monadicity_internal.main_pair_G_split ((comparison (adjunction.of_right_adjoint G)).obj Y)\n    infer_instance\n  exact adjunction.is_right_adjoint_to_is_equivalence\n#align category_theory.monad.monadic_of_has_preserves_reflects_G_split_coequalizers CategoryTheory.Monad.monadicOfHasPreservesReflectsGSplitCoequalizers\n\n/--\nBeck's monadicity theorem. If `G` has a right adjoint and creates coequalizers of `G`-split pairs,\nthen it is monadic.\nThis is the converse of `creates_G_split_of_monadic`.\n-/\ndef monadicOfCreatesGSplitCoequalizers\n    [∀ ⦃A B⦄ (f g : A ⟶ B) [G.IsSplitPair f g], CreatesColimit (parallelPair f g) G] :\n    MonadicRightAdjoint G :=\n  by\n  let this : ∀ ⦃A B⦄ (f g : A ⟶ B) [G.is_split_pair f g], has_colimit (parallel_pair f g ⋙ G) :=\n    by\n    intro A B f g i\n    apply has_colimit_of_iso (diagramIsoParallelPair.{v₁} _)\n    change has_coequalizer (G.map f) (G.map g)\n    infer_instance\n  apply monadic_of_has_preserves_reflects_G_split_coequalizers _\n  · infer_instance\n  · intro A B f g i\n    apply has_colimit_of_created (parallel_pair f g) G\n  · intro A B f g i\n    infer_instance\n  · intro A B f g i\n    infer_instance\n#align category_theory.monad.monadic_of_creates_G_split_coequalizers CategoryTheory.Monad.monadicOfCreatesGSplitCoequalizers\n\n/-- An alternate version of Beck's monadicity theorem. If `G` reflects isomorphisms, preserves\ncoequalizers of `G`-split pairs and `C` has coequalizers of `G`-split pairs, then it is monadic.\n-/\ndef monadicOfHasPreservesGSplitCoequalizersOfReflectsIsomorphisms [ReflectsIsomorphisms G]\n    [∀ ⦃A B⦄ (f g : A ⟶ B) [G.IsSplitPair f g], HasCoequalizer f g]\n    [∀ ⦃A B⦄ (f g : A ⟶ B) [G.IsSplitPair f g], PreservesColimit (parallelPair f g) G] :\n    MonadicRightAdjoint G :=\n  by\n  apply monadic_of_has_preserves_reflects_G_split_coequalizers _\n  · infer_instance\n  · assumption\n  · assumption\n  · intro A B f g i\n    apply reflects_colimit_of_reflects_isomorphisms\n#align category_theory.monad.monadic_of_has_preserves_G_split_coequalizers_of_reflects_isomorphisms CategoryTheory.Monad.monadicOfHasPreservesGSplitCoequalizersOfReflectsIsomorphisms\n\nend BeckMonadicity\n\nsection ReflexiveMonadicity\n\nvariable [HasReflexiveCoequalizers D] [ReflectsIsomorphisms G]\n\nvariable [∀ ⦃A B⦄ (f g : A ⟶ B) [IsReflexivePair f g], PreservesColimit (parallelPair f g) G]\n\n/-- Reflexive (crude) monadicity theorem. If `G` has a right adjoint, `D` has and `G` preserves\nreflexive coequalizers and `G` reflects isomorphisms, then `G` is monadic.\n-/\ndef monadicOfHasPreservesReflexiveCoequalizersOfReflectsIsomorphisms : MonadicRightAdjoint G :=\n  by\n  let L : (adjunction.of_right_adjoint G).toMonad.Algebra ⥤ D := left_adjoint_comparison\n  letI i : is_right_adjoint (comparison (adjunction.of_right_adjoint G)) :=\n    ⟨_, comparison_adjunction⟩\n  constructor\n  let this :\n    ∀ X : (adjunction.of_right_adjoint G).toMonad.Algebra,\n      is_iso\n        ((adjunction.of_right_adjoint (comparison (adjunction.of_right_adjoint G))).Unit.app X) :=\n    by\n    intro X\n    apply is_iso_of_reflects_iso _ (monad.forget (adjunction.of_right_adjoint G).toMonad)\n    · change is_iso (comparison_adjunction.unit.app X).f\n      rw [comparison_adjunction_unit_f]\n      change\n        is_iso\n          (is_colimit.cocone_point_unique_up_to_iso (beck_coequalizer X)\n              (unit_colimit_of_preserves_coequalizer X)).Hom\n      apply is_iso.of_iso (is_colimit.cocone_point_unique_up_to_iso _ _)\n  let this :\n    ∀ Y : D,\n      is_iso ((of_right_adjoint (comparison (adjunction.of_right_adjoint G))).counit.app Y) :=\n    by\n    intro Y\n    change is_iso (comparison_adjunction.counit.app Y)\n    rw [comparison_adjunction_counit_app]\n    change is_iso (is_colimit.cocone_point_unique_up_to_iso _ _).Hom\n    infer_instance\n    apply counit_coequalizer_of_reflects_coequalizer _\n    apply reflects_colimit_of_reflects_isomorphisms\n  exact adjunction.is_right_adjoint_to_is_equivalence\n#align category_theory.monad.monadic_of_has_preserves_reflexive_coequalizers_of_reflects_isomorphisms CategoryTheory.Monad.monadicOfHasPreservesReflexiveCoequalizersOfReflectsIsomorphisms\n\nend ReflexiveMonadicity\n\nend Monad\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Monad/Monadicity.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.47905515695725015}}
{"text": "import .expr_base\nimport ...phys.time.time\n\nnamespace lang.time\n\nuniverses u\nvariables \n  (K : Type u) [field K] [inhabited K] \n  {f : fm K TIME} {sp : spc K f} \n\n/-\nDuration\n-/\nstructure duration_var {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f) extends var \n\n/-\nTime\n-/\nstructure time_var {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f) extends var\n\nmutual inductive duration_expr, time_expr {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f) \nwith duration_expr : Type u\n| lit (v : duration sp) : duration_expr\n| var (v : duration_var sp) : duration_expr\n| add_dur_dur (d1 : duration_expr) (d2 : duration_expr) : duration_expr\n| neg_dur (d : duration_expr) : duration_expr\n| sub_dur_dur (d1 : duration_expr) (d2 : duration_expr) : duration_expr\n| sub_time_time (t1 : time_expr) (t2 : time_expr) : duration_expr\n| smul_dur (k : K) (d : duration_expr) : duration_expr\nwith time_expr : Type u\n| lit (p : time sp) : time_expr\n| var (v : time_var sp) : time_expr\n| add_dur_time (d : duration_expr) (t : time_expr) : time_expr\n\n\nabbreviation duration_env {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f) := \n  duration_var sp → duration sp\n\nabbreviation duration_eval {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f)  := \n  duration_env sp → duration_expr sp → duration sp\n\nabbreviation time_env {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f)  := \n  time_var sp → time sp\n\nabbreviation time_eval {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f)  := \n  time_env sp → time_expr sp → time sp\n\n/-\nANDREW:\n\nFUNCTION_NAME' (added ') is the suggested implementation version discussed earlier.\n\n-/\n\ndef add_dur_expr_dur_expr (v1 v2 : duration_expr sp) : duration_expr sp := \n  duration_expr.add_dur_dur v1 v2\n/-\nFROM TUESDAY - REMOVE SOON\n\ndef add_dur_expr_dur_expr' {ev : duration_env sp} (v1 v2 : duration_expr sp) : duration_expr sp := \n  begin\n    cases v1,\n    { \n      cases v2,\n      {\n        exact (duration_expr.lit (v1 +ᵥ v2))\n      },\n      {\n        exact (duration_expr.lit ((ev v2) +ᵥ v1))\n      }\n    },\n    { \n      cases v2,\n      {\n        exact (duration_expr.lit ((ev v1) +ᵥ v2))\n      },\n      {\n        exact (duration_expr.lit ((ev v1) +ᵥ (ev v2)))\n      }\n    }\n\n  end\ndef smul_dur_expr' {ev : duration_env sp} (k : K) (v : duration_expr sp) : duration_expr sp := \n  begin\n    intros,\n    induction v,\n    case duration_expr.lit : l {\n      exact duration_expr.lit(k•l)\n    },\n    case duration_expr.var : v {\n      exact duration_expr.lit(ev v)\n    }\n\n  end-/\ndef smul_dur_expr (k : K) (v : duration_expr sp) : duration_expr sp := \n    duration_expr.smul_dur k v\n\ndef neg_dur_expr (v : duration_expr sp) : duration_expr sp := \n    duration_expr.neg_dur v\n/-\ndef neg_dur_expr' {ev : duration_env sp} (v : duration_expr sp) : duration_expr sp := \nbegin\n    intros,\n    induction v,\n    case duration_expr.lit : l {\n      exact duration_expr.lit(-l)\n    },\n    case duration_expr.var : v {\n      exact duration_expr.lit(-ev v)\n    }\n\nend\n-/\ndef sub_dur_expr_dur_expr (v1 v2 : duration_expr sp) : duration_expr sp :=    -- v1-v2\n    duration_expr.sub_dur_dur v1 v2\n/-\ndef sub_dur_expr_dur_expr' {ev : duration_env sp} (v1 v2 : duration_expr sp) : duration_expr sp :=    -- v1-v2\nbegin\n    intros,\n    cases v1,\n    {\n      cases v2,\n      {\n        exact (duration_expr.lit (v1 -ᵥ v2))\n      },\n      {\n        exact (duration_expr.lit (v1 -ᵥ ev v2))\n      }\n    },\n    { \n      cases v2,\n      {\n        exact (duration_expr.lit ((ev v1) -ᵥ v2))\n      },\n      {\n        exact (duration_expr.lit ((ev v1) -ᵥ (ev v2)))\n      }\n    }\n\nend-/\n-- See unframed file for template for proving vector_space\n\ninstance has_add_dur_expr : has_add (duration_expr sp) := ⟨ add_dur_expr_dur_expr K ⟩\nlemma add_assoc_dur_expr : ∀ a b c : duration_expr sp, a + b + c = a + (b + c) := sorry\ninstance add_semigroup_dur_expr : add_semigroup (duration_expr sp) := ⟨ add_dur_expr_dur_expr K, add_assoc_dur_expr K⟩ \n\ndef dur_expr_zero  := duration_expr.lit (mk_duration sp 0)\ninstance has_zero_dur_expr : has_zero (duration_expr sp) := ⟨dur_expr_zero K⟩\n\nlemma zero_add_dur_expr : ∀ a : duration_expr sp, 0 + a = a := sorry\nlemma add_zero_dur_expr : ∀ a : duration_expr sp, a + 0 = a := sorry\ninstance add_monoid_dur_expr : add_monoid (duration_expr sp) := ⟨ \n    -- add_semigroup\n    add_dur_expr_dur_expr K, \n    add_assoc_dur_expr K, \n    -- has_zero\n    dur_expr_zero K,\n    -- new structure \n    @zero_add_dur_expr K _ _ f sp, \n    add_zero_dur_expr K\n⟩\n\ninstance has_neg_dur_expr : has_neg (duration_expr sp) := ⟨neg_dur_expr K⟩\ninstance has_sub_dur_expr : has_sub (duration_expr sp) := ⟨ sub_dur_expr_dur_expr K⟩ \nlemma sub_eq_add_neg_dur_expr : ∀ a b : duration_expr sp, a - b = a + -b := sorry\ninstance sub_neg_monoid_dur_expr : sub_neg_monoid (duration_expr sp) := ⟨ \n    add_dur_expr_dur_expr K, add_assoc_dur_expr K, dur_expr_zero K, \n    zero_add_dur_expr K, \n    add_zero_dur_expr K, -- add_monoid\n    neg_dur_expr K,                                                                  -- has_neg\n    sub_dur_expr_dur_expr K,                                                              -- has_sub\n    sub_eq_add_neg_dur_expr K,                                                       -- new\n⟩ \n\nlemma add_left_neg_dur_expr : ∀ a : duration_expr sp, -a + a = 0 := sorry\ninstance : add_group (duration_expr sp) := ⟨\n    -- sub_neg_monoid\n    add_dur_expr_dur_expr K, add_assoc_dur_expr K, dur_expr_zero K, zero_add_dur_expr K, add_zero_dur_expr K, -- add_monoid\n    neg_dur_expr K,                                                                  -- has_neg\n    sub_dur_expr_dur_expr K,                                                              -- has_sub\n    sub_eq_add_neg_dur_expr K, \n    -- new\n    add_left_neg_dur_expr K,\n⟩ \n\nlemma add_comm_dur_expr : ∀ a b : duration_expr sp, a + b = b + a := sorry\ninstance add_comm_semigroup_dur_expr : add_comm_semigroup (duration_expr sp) := ⟨\n    -- add_semigroup\n    add_dur_expr_dur_expr K, \n    add_assoc_dur_expr K,\n    add_comm_dur_expr K,\n⟩\n\ninstance add_comm_monoid_dur_expr : add_comm_monoid (duration_expr sp) := ⟨\n-- add_monoid\n    -- add_semigroup\n    add_dur_expr_dur_expr K, \n    add_assoc_dur_expr K, \n    -- has_zero\n    dur_expr_zero K,\n    -- new structure \n    zero_add_dur_expr K, \n    add_zero_dur_expr K,\n-- add_comm_semigroup (minus repeats)\n    add_comm_dur_expr K,\n⟩\n\ninstance has_scalar_dur_expr : has_scalar K (duration_expr sp) := ⟨\nsmul_dur_expr K,\n⟩\n\nlemma one_smul_dur_expr : ∀ b : duration_expr sp, (1 : K) • b = b := sorry\nlemma mul_smul_dur_expr : ∀ (x y : K) (b : duration_expr sp), (x * y) • b = x • y • b := sorry\ninstance mul_action_dur_expr : mul_action K (duration_expr sp) := ⟨\none_smul_dur_expr K,\nmul_smul_dur_expr K,\n⟩ \n\nlemma smul_add_dur_expr : ∀(r : K) (x y : duration_expr sp), r • (x + y) = r • x + r • y := sorry\nlemma smul_zero_dur_expr : ∀(r : K), r • (0 : duration_expr sp) = 0 := sorry\ninstance distrib_mul_action_K_dur_exprKx : distrib_mul_action K (duration_expr sp) := ⟨\nsmul_add_dur_expr K,\nsmul_zero_dur_expr K,\n⟩ \n\n-- renaming vs template due to clash with name \"s\" for prevailing variable\nlemma add_smul_dur_expr : ∀ (a b : K) (x : duration_expr sp), (a + b) • x = a • x + b • x := sorry\nlemma zero_smul_dur_expr : ∀ (x : duration_expr sp), (0 : K) • x = 0 := sorry\ninstance semimodule_K_durationK : semimodule K (duration_expr sp) := ⟨ add_smul_dur_expr K, zero_smul_dur_expr  K⟩ \n\ninstance add_comm_group_dur_expr : add_comm_group (duration_expr sp) := ⟨\n-- add_group\n    add_dur_expr_dur_expr K, add_assoc_dur_expr K, dur_expr_zero K, zero_add_dur_expr K, add_zero_dur_expr K, -- add_monoid\n    neg_dur_expr K,                                                                  -- has_neg\n    sub_dur_expr_dur_expr K,                                                              -- has_sub\n    sub_eq_add_neg_dur_expr K, \n    add_left_neg_dur_expr K,\n-- commutativity\n    add_comm_dur_expr K,\n⟩\n\n\ninstance : vector_space K (duration_expr sp) := sorry\n\n\n/-\n    ********************\n    *** Affine space ***\n    ********************\n-/\n\n\n/-\nAffine operations\n-/\ninstance : has_add (duration_expr sp) := ⟨add_dur_expr_dur_expr K⟩\ninstance : has_zero (duration_expr sp) := ⟨dur_expr_zero K⟩\ninstance : has_neg (duration_expr sp) := ⟨neg_dur_expr K⟩\n\n/-\nLemmas needed to implement affine space API\n-/\n/-\nkernel failed to type check declaration 'sub_time_expr_time_expr' this is usually due to a \nbuggy tactic or a bug in the builtin elaborator\n\nANDREW - THIS LOOKS VERY BAD!\n-/\n\ndef sub_time_expr_time_expr {f : fm K TIME} {sp : spc K f } (p1 p2 : time_expr sp) : duration_expr sp := \n    sorry--duration_expr.sub_time_time p1 p2\ndef add_time_expr_dur_expr {f : fm K TIME} {sp : spc K f } (p : time_expr sp) (v : duration_expr sp) : time_expr sp := \n    time_expr.add_dur_time v p\ndef add_dur_expr_time_expr {f : fm K TIME} {sp : spc K f } (v : duration_expr sp) (p : time_expr sp) : time_expr sp := \n    time_expr.add_dur_time v p\n\ndef aff_dur_expr_group_action : duration_expr sp → time_expr sp → time_expr sp := add_dur_expr_time_expr K\ninstance : has_vadd (duration_expr sp) (time_expr sp) := ⟨aff_dur_expr_group_action K⟩\n\nlemma zero_dur_expr_vadd'_a1 : ∀ p : time_expr sp, (0 : duration_expr sp) +ᵥ p = p := sorry\nlemma dur_expr_add_assoc'_a1 : ∀ (g1 g2 : duration_expr sp) (p : time_expr sp), g1 +ᵥ (g2 +ᵥ p) = (g1 + g2) +ᵥ p := sorry\ninstance dur_expr_add_action: add_action (duration_expr sp) (time_expr sp) := \n⟨ aff_dur_expr_group_action K, zero_dur_expr_vadd'_a1 K, dur_expr_add_assoc'_a1  K⟩ \n\ndef aff_time_expr_group_sub : time_expr sp → time_expr sp → duration_expr sp := sub_time_expr_time_expr K\ninstance time_expr_has_vsub : has_vsub (duration_expr sp) (time_expr sp) := ⟨ aff_time_expr_group_sub K ⟩ \n\ninstance : nonempty (time_expr sp) := ⟨time_expr.lit (mk_time sp  0)⟩\n\nlemma time_expr_vsub_vadd_a1 : ∀ (p1 p2 : (time_expr sp)), (p1 -ᵥ p2) +ᵥ p2 = p1 := sorry\nlemma time_expr_vadd_vsub_a1 : ∀ (g : duration_expr sp) (p : time_expr sp), g +ᵥ p -ᵥ p = g := sorry\ninstance aff_time_expr_torsor : add_torsor (duration_expr sp) (time_expr sp) := \n⟨ \n    aff_dur_expr_group_action K,\n    zero_dur_expr_vadd'_a1 K,    -- add_action\n    dur_expr_add_assoc'_a1 K,   -- add_action\n    aff_time_expr_group_sub K,    -- has_vsub\n    time_expr_vsub_vadd_a1 K,     -- add_torsor\n    time_expr_vadd_vsub_a1 K,     -- add_torsor\n⟩\n\n\n/-\nTransform\n-/\nstructure transform_var {K : Type u} [field K] [inhabited K] \n  {f1 : fm K TIME} {f2 : fm K TIME} (sp1 : spc K f1) (sp2 : spc K f2) extends var\n\ninductive transform_expr {K : Type u} [field K] [inhabited K] \n  {f1 : fm K TIME} {f2 : fm K TIME} (sp1 : spc K f1) (sp2 : spc K f2) : Type u\n| lit (p : time_transform sp1 sp2) : transform_expr\n| var (v : transform_var sp1 sp2) : transform_expr\n\nabbreviation transform_env {K : Type u} [field K] [inhabited K] \n  {f1 : fm K TIME} {f2 : fm K TIME} (sp1 : spc K f1) (sp2 : spc K f2)  := \n  transform_var sp1 sp2 → time_transform sp1 sp2\n\nabbreviation transform_eval  {K : Type u} [field K] [inhabited K] \n  {f1 : fm K TIME} {f2 : fm K TIME} (sp1 : spc K f1) (sp2 : spc K f2) := \n  transform_env sp1 sp2 → transform_expr sp1 sp2 → time_transform sp1 sp2\n\n\n/-\nWe need a notation of a space \nexpression, rooted at TIME but\nenabling the imposition of any\naffine coordinatization on it,\nthese rooted at TIME.std_frame.\nThus we also need a notation of\nframes.\n-/\n\n/-\nTIME\nstd_space [TIME]\nFRAME [ TIME ], STD_FRAME [ TIME ]\nSPACE [ FRAME [ TIME ] ]\nPoint_lit [acspace] coord\nDuration_lit [acspace] coord\nPoint_var [acspace] pvar\nDuration_var [acspace] dvar\n\n+  : d s -> d s -> d s\n•  : K -> d s -> d s\n+ᵥ : d s -> t s -> t s \n-ᵥ : t s -> t s -> d s\n\nHere s is an affine coordinate \nspace on TIME. Otherwise we've\ngot time points and durations,\nwithin, but not across, spaces.\n-/\n\n\n\n\n\n\n\n\n\n\n/-\nOverall environment\n\n--omitting transforms from environment for now, which will make\n--env.env, cmd, and etc. , even more complicated in terms of types\n--TODO: Go ahead and complete the environment. Thanks! --Kevin\n-/\n\nvariables {f2 : fm K TIME} (sp2 : spc K f2)\n\nstructure env {K : Type u} [field K] [inhabited K] \n        {f : fm K TIME} (sp : spc K f) {f2 : fm K TIME} {sp2 : spc K f2} :=\n  (d : duration_env sp )\n  (t : time_env sp )\n  (tr : transform_env sp sp2)\n\n#check sp.tr sp2\n\nopen time\n\n\ndef env.init : env sp :=\n  ⟨\n    (λv, ⟨mk_vectr sp 1⟩),\n    (λv, ⟨mk_point sp 0⟩),\n    (λv, sp.time_tr sp2)\n  ⟩\n\nstructure eval {K : Type u} [field K] [inhabited K] {f : fm K TIME} (sp : spc K f) {f2 : fm K TIME} {sp2 : spc K f2} :=\n  (d : duration_eval sp )\n  (t : time_eval sp )\n  (tr : transform_eval sp sp2)\n\ndef eval.init : eval sp := \n  ⟨ \n    (λenv_,λexpr_, ⟨mk_vectr sp 1⟩),\n    (λenv_,λexpr_, ⟨mk_point sp 0⟩),\n    (λenv_,λexpr_, sp.time_tr sp2),\n  ⟩\nend lang.time\n", "meta": {"author": "kevinsullivan", "repo": "lang", "sha": "e9d869bff94fb13ad9262222a6f3c4aafba82d5e", "save_path": "github-repos/lean/kevinsullivan-lang", "path": "github-repos/lean/kevinsullivan-lang/lang-e9d869bff94fb13ad9262222a6f3c4aafba82d5e/old/time_expr_old.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738152021788, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4790394855983983}}
{"text": "import .basic\nopen pfun topological_space set\nnoncomputable theory\nuniverses u v w\n\nvariables {k : ℕ∞} {E : euclidean_space.{u}}\n\n/- topological manifolds -/\nstructure chart (X : Top) (E : euclidean_space) :=\n  (iso : X ≃ₜ. E.to_Top)\n  (h1 : is_open iso.to_fun.dom)\n  (h2 : is_open iso.inv_fun.dom)\n\nnamespace chart\nvariable {X : Top}\ndef to_fun (c : chart X E) : X →. E := c.iso.to_fun\ndef inv_fun (c : chart X E) : E →. X := c.iso.inv_fun\ndef domain (c : chart X E) : set X := dom c.to_fun\ndef codomain (c : chart X E) : set E := dom c.inv_fun\n\ndef restrict {s : set X} (hs : is_open s) (c : chart X E) : chart (X.restrict s) E :=\n⟨(phomeo.restrict_phomeo s).trans c.iso, omitted, omitted⟩\n\nend chart\n\ndef compatible_charts {X : Top} (k : ℕ∞) (c₁ c₂ : chart X E) : Prop :=\nis_smooth k (c₂.to_fun ∘. c₁.inv_fun) ∧ \nis_smooth k (c₁.to_fun ∘. c₂.inv_fun)\n\nstructure topological_manifold (E : euclidean_space) :=\n  (carrier : Top)\n  (struct2 : t2_space carrier)\n  (struct3 : second_countable_topology carrier)\n  (charts : set (chart carrier E))\n  (cover : ⋃₀ (chart.domain '' charts) = univ)\n\nnamespace topological_manifold\ninstance : has_coe (topological_manifold E) Top :=\n⟨topological_manifold.carrier⟩\n\ndef restrict (X : topological_manifold E) {s : set X} (hs : is_open s) : \n  topological_manifold E :=\n⟨X.carrier.restrict s, omitted, omitted, chart.restrict hs '' X.charts, omitted⟩ \n\nend topological_manifold\n\nstructure differentiable_manifold (k : ℕ∞) (E : euclidean_space) extends topological_manifold E :=\n  (compatible : ∀{{c₁ c₂}}, c₁ ∈ charts → c₂ ∈ charts → compatible_charts k c₁ c₂)\n\nnamespace euclidean_space\n\n  def to_differentiable_manifold (E : euclidean_space) (k : ℕ∞) : differentiable_manifold k E :=\n  ⟨⟨E.to_Top, omitted, omitted, {⟨phomeo.rfl, is_open_univ, is_open_univ⟩}, omitted⟩, omitted⟩\n\nend euclidean_space\n\nnamespace differentiable_manifold\n\ninstance : has_coe (differentiable_manifold k E) Top :=\n⟨λX, X.to_topological_manifold.carrier⟩\n\n/- a maximal atlas is a set of charts which is compatible with all charts of X -/\ndef max_atlas (X : differentiable_manifold k E) : set (chart X.carrier E) :=\n{ c | ∀c' ∈ X.charts, compatible_charts k c c' }\n\n/- examples and constructions -/\ndef restrict (X : differentiable_manifold k E) {s : set X} (hs : is_open s) : \n  differentiable_manifold k E :=\n⟨X.to_topological_manifold.restrict hs, omitted⟩ \n\n\ndef sphere (n : ℕ) : differentiable_manifold ⊤ (euclidean_space.standard_euclidean_space n) :=\nsorry --⟨⟨⟨subtype _, _⟩, _, _, _, _⟩, omitted⟩\n\n/- smooth maps-/\nvariables {X : differentiable_manifold k E} {Y : differentiable_manifold k E} {Z : differentiable_manifold k E}\n\ndef respects_charts (f : X → Y) (A : set (chart X.carrier E)) (B : set (chart Y.carrier E)) : Prop := \n∀(c ∈ A) (c' ∈ B), is_smooth k (chart.to_fun c' ∘. pfun.lift f ∘. chart.inv_fun c)\n\nstructure smooth_map (X Y : differentiable_manifold k E) :=\n  (map : X → Y)\n  (smooth : respects_charts map X.max_atlas Y.max_atlas)\n\ninfix ` →ₛ `:25 := smooth_map\n\ndef incl (X : differentiable_manifold k E) {s : set X} (hs : is_open s) :\n  restrict X hs →ₛ X :=\n⟨subtype.val, omitted⟩\n\nlemma respects_charts_local (f : X → Y) (A : set (chart X.carrier E)) (B : set (chart Y.carrier E))\n  (h : ∀x : X, ∃(s : set X) (hs : is_open s), x ∈ s ∧ \n    respects_charts (f ∘ (incl X hs).map) (chart.restrict hs '' A) B) : respects_charts f A B :=\nomitted\n\nlemma respects_charts_subset (f : X → Y) (A A' : set (chart X.carrier E)) (B B' : set (chart Y.carrier E))\n  (hA : ⋃₀ (chart.domain '' A') ⊆ ⋃₀ (chart.domain '' A)) (hB : ⋃₀ (chart.domain '' B') ⊆ ⋃₀ (chart.domain '' B))\n  (h : respects_charts f A B) : respects_charts f A' B' :=\nomitted\n\nnamespace smooth_map\n\ndef id : X →ₛ X := ⟨id, omitted⟩\ndef comp (g : Y →ₛ Z) (f : X →ₛ Y) : X →ₛ Z := ⟨g.map ∘ f.map, omitted⟩\n\nend smooth_map\n\n\n\nend differentiable_manifold\n", "meta": {"author": "formalabstracts", "repo": "formalabstracts", "sha": "b0173da1af45421239d44492eeecd54bf65ee0f6", "save_path": "github-repos/lean/formalabstracts-formalabstracts", "path": "github-repos/lean/formalabstracts-formalabstracts/formalabstracts-b0173da1af45421239d44492eeecd54bf65ee0f6/src/analysis/manifolds/manifold.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.47903947435845035}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nEvaluate expressions in the language of (semi-)rings.\nBased on http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf .\n-/\nimport algebra.group_power tactic.norm_num\n\nnamespace tactic\nnamespace ring\n\ndef horner {α} [comm_semiring α] (a x : α) (n : ℕ) (b : α) := a * x ^ n + b\n\nmeta structure cache :=\n(α : expr)\n(univ : level)\n(comm_semiring_inst : expr)\n\nmeta def mk_cache (e : expr) : tactic cache :=\ndo α ← infer_type e,\n   c ← mk_app ``comm_semiring [α] >>= mk_instance,\n   u ← mk_meta_univ,\n   infer_type α >>= unify (expr.sort (level.succ u)),\n   u ← get_univ_assignment u,\n   return ⟨α, u, c⟩\n\nmeta def cache.cs_app (c : cache) (n : name) : list expr → expr :=\n(@expr.const tt n [c.univ] c.α c.comm_semiring_inst).mk_app\n\nmeta def cache.mk_app (c : cache) (n inst : name) (l : list expr) : tactic expr :=\ndo m ← mk_instance ((expr.const inst [c.univ] : expr) c.α),\n   return $ (@expr.const tt n [c.univ] c.α m).mk_app l\n\nmeta inductive horner_expr : Type\n| const (e : expr) : horner_expr\n| xadd (e : expr) (a : horner_expr) (x : expr) (n : expr × ℕ) (b : horner_expr) : horner_expr\n\nmeta def horner_expr.e : horner_expr → expr\n| (horner_expr.const e) := e\n| (horner_expr.xadd e _ _ _ _) := e\n\nmeta instance : has_coe horner_expr expr := ⟨horner_expr.e⟩\n\nmeta def horner_expr.xadd' (c : cache) (a : horner_expr) (x : expr) (n : expr × ℕ) (b : horner_expr): horner_expr :=\nhorner_expr.xadd (c.cs_app ``horner [a, x, n.1, b]) a x n b\n\nopen horner_expr\n\nmeta def horner_expr.to_string : horner_expr → string\n| (const e) := to_string e\n| (xadd e a x (_, n) b) :=\n    \"(\" ++ a.to_string ++ \") * (\" ++ to_string x ++ \")^\"\n        ++ to_string n ++ \" + \" ++ b.to_string\n\nmeta def horner_expr.pp : horner_expr → tactic format\n| (const e) := pp e\n| (xadd e a x (_, n) b) := do\n  pa ← a.pp, pb ← b.pp, px ← pp x,\n  return $ \"(\" ++ pa ++ \") * (\" ++ px ++ \")^\" ++ to_string n ++ \" + \" ++ pb\n\nmeta instance : has_to_tactic_format horner_expr := ⟨horner_expr.pp⟩\n\nmeta def horner_expr.refl_conv (e : horner_expr) : tactic (horner_expr × expr) :=\ndo p ← mk_eq_refl e, return (e, p)\n\ntheorem zero_horner {α} [comm_semiring α] (x n b) :\n  @horner α _ 0 x n b = b :=\nby simp [horner]\n\ntheorem horner_horner {α} [comm_semiring α] (a₁ x n₁ n₂ b n')\n  (h : n₁ + n₂ = n') :\n  @horner α _ (horner a₁ x n₁ 0) x n₂ b = horner a₁ x n' b :=\nby simp [h.symm, horner, pow_add, mul_assoc]\n\nmeta def eval_horner (c : cache) : horner_expr → expr → expr × ℕ → horner_expr → tactic (horner_expr × expr)\n| ha@(const a) x n b :=\n  if a.to_nat = some 0 then\n    return (b, c.cs_app ``zero_horner [x, n.1, b])\n  else (xadd' c ha x n b).refl_conv\n| ha@(xadd a a₁ x₁ n₁ b₁) x n b :=\n  if x₁ = x ∧ b₁.e.to_nat = some 0 then do\n    (n', h) ← mk_app ``has_add.add [n₁.1, n.1] >>= norm_num,\n    return (xadd' c a₁ x (n', n₁.2 + n.2) b,\n      c.cs_app ``horner_horner [a₁, x, n₁.1, n.1, b, n', h])\n  else (xadd' c ha x n b).refl_conv\n\ntheorem const_add_horner {α} [comm_semiring α] (k a x n b b') (h : k + b = b') :\n  k + @horner α _ a x n b = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_const {α} [comm_semiring α] (a x n b k b') (h : b + k = b') :\n  @horner α _ a x n b + k = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_horner_lt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b')\n  (h₁ : n₁ + k = n₂) (h₂ : (a₁ + horner a₂ x k 0 : α) = a') (h₃ : b₁ + b₂ = b') :\n  @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₁ b' :=\nby simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_gt {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ b₂ k a' b')\n  (h₁ : n₂ + k = n₁) (h₂ : (horner a₁ x k 0 + a₂ : α) = a') (h₃ : b₁ + b₂ = b') :\n  @horner α _ a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₂ b' :=\nby simp [h₂.symm, h₃.symm, h₁.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_eq {α} [comm_semiring α] (a₁ x n b₁ a₂ b₂ a' b' t)\n  (h₁ : a₁ + a₂ = a') (h₂ : b₁ + b₂ = b') (h₃ : horner a' x n b' = t) :\n  @horner α _ a₁ x n b₁ + horner a₂ x n b₂ = t :=\nby simp [h₃.symm, h₂.symm, h₁.symm, horner, add_mul, mul_comm]\n\nmeta def eval_add (c : cache) : horner_expr → horner_expr → tactic (horner_expr × expr)\n| (const e₁) (const e₂) := do\n  (e, p) ← mk_app ``has_add.add [e₁, e₂] >>= norm_num,\n  return (const e, p)\n| he₁@(const e₁) he₂@(xadd e₂ a x n b) :=\n  if e₁.to_nat = some 0 then  do\n    p ← mk_app ``zero_add [e₂],\n    return (he₂, p)\n  else do\n    (b', h) ← eval_add he₁ b,\n    return (xadd' c a x n b',\n      c.cs_app ``const_add_horner [e₁, a, x, n.1, b, b', h])\n| he₁@(xadd e₁ a x n b) he₂@(const e₂) :=\n  if e₂.to_nat = some 0 then do\n    p ← mk_app ``add_zero [e₁],\n    return (he₁, p)\n  else do\n    (b', h) ← eval_add b he₂,\n    return (xadd' c a x n b',\n      c.cs_app ``horner_add_const [a, x, n.1, b, e₂, b', h])\n| he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) :=\n  if expr.lex_lt x₁ x₂ then do\n    (b', h) ← eval_add b₁ he₂,\n    return (xadd' c a₁ x₁ n₁ b',\n      c.cs_app ``horner_add_const [a₁, x₁, n₁.1, b₁, e₂, b', h])\n  else if x₁ ≠ x₂ then do\n    (b', h) ← eval_add he₁ b₂,\n    return (xadd' c a₂ x₂ n₂ b',\n      c.cs_app ``const_add_horner [e₁, a₂, x₂, n₂.1, b₂, b', h])\n  else if n₁.2 < n₂.2 then do\n    let k := n₂.2 - n₁.2,\n    ek ← expr.of_nat (expr.const `nat []) k,\n    (_, h₁) ← mk_app ``has_add.add [n₁.1, ek] >>= norm_num,\n    α0 ← expr.of_nat c.α 0,\n    (a', h₂) ← eval_add a₁ (xadd' c a₂ x₁ (ek, k) (const α0)),\n    (b', h₃) ← eval_add b₁ b₂,\n    return (xadd' c a' x₁ n₁ b',\n      c.cs_app ``horner_add_horner_lt [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃])\n  else if n₁ ≠ n₂ then do\n    let k := n₁.2 - n₂.2,\n    ek ← expr.of_nat (expr.const `nat []) k,\n    (_, h₁) ← mk_app ``has_add.add [n₂.1, ek] >>= norm_num,\n    α0 ← expr.of_nat c.α 0,\n    (a', h₂) ← eval_add (xadd' c a₁ x₁ (ek, k) (const α0)) a₂,\n    (b', h₃) ← eval_add b₁ b₂,\n    return (xadd' c a' x₁ n₂ b',\n      c.cs_app ``horner_add_horner_gt [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, ek, a', b', h₁, h₂, h₃])\n  else do\n    (a', h₁) ← eval_add a₁ a₂,\n    (b', h₂) ← eval_add b₁ b₂,\n    (t, h₃) ← eval_horner c a' x₁ n₁ b',\n    return (t, c.cs_app ``horner_add_horner_eq\n      [a₁, x₁, n₁.1, b₁, a₂, b₂, a', b', t, h₁, h₂, h₃])\n\ntheorem horner_neg {α} [comm_ring α] (a x n b a' b')\n  (h₁ : -a = a') (h₂ : -b = b') :\n  -@horner α _ a x n b = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner]\n\nmeta def eval_neg (c : cache) : horner_expr → tactic (horner_expr × expr)\n| (const e) := do\n  (e', p) ← mk_app ``has_neg.neg [e] >>= norm_num,\n  return (const e', p)\n| (xadd e a x n b) := do\n  (a', h₁) ← eval_neg a,\n  (b', h₂) ← eval_neg b,\n  p ← c.mk_app ``horner_neg ``comm_ring [a, x, n.1, b, a', b', h₁, h₂],\n  return (xadd' c a' x n b', p)\n\ntheorem horner_const_mul {α} [comm_semiring α] (c a x n b a' b')\n  (h₁ : c * a = a') (h₂ : c * b = b') :\n  c * @horner α _ a x n b = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner, mul_add, mul_assoc]\n\ntheorem horner_mul_const {α} [comm_semiring α] (a x n b c a' b')\n  (h₁ : a * c = a') (h₂ : b * c = b') :\n  @horner α _ a x n b * c = horner a' x n b' :=\nby simp [h₂.symm, h₁.symm, horner, add_mul, mul_right_comm]\n\nmeta def eval_const_mul (c : cache) (k : expr) :\n  horner_expr → tactic (horner_expr × expr)\n| (const e) := do\n  (e', p) ← mk_app ``has_mul.mul [k, e] >>= norm_num,\n  return (const e', p)\n| (xadd e a x n b) := do\n  (a', h₁) ← eval_const_mul a,\n  (b', h₂) ← eval_const_mul b,\n  return (xadd' c a' x n b',\n    c.cs_app ``horner_const_mul [k, a, x, n.1, b, a', b', h₁, h₂])\n\ntheorem horner_mul_horner_zero {α} [comm_semiring α] (a₁ x n₁ b₁ a₂ n₂ aa t)\n  (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa)\n  (h₂ : horner aa x n₂ 0 = t) :\n  horner a₁ x n₁ b₁ * horner a₂ x n₂ 0 = t :=\nby rw [← h₂, ← h₁];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\ntheorem horner_mul_horner {α} [comm_semiring α]\n  (a₁ x n₁ b₁ a₂ n₂ b₂ aa haa ab bb t)\n  (h₁ : @horner α _ a₁ x n₁ b₁ * a₂ = aa)\n  (h₂ : horner aa x n₂ 0 = haa)\n  (h₃ : a₁ * b₂ = ab) (h₄ : b₁ * b₂ = bb)\n  (H : haa + horner ab x n₁ bb = t) :\n  horner a₁ x n₁ b₁ * horner a₂ x n₂ b₂ = t :=\nby rw [← H, ← h₂, ← h₁, ← h₃, ← h₄];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\nmeta def eval_mul (c : cache) : horner_expr → horner_expr → tactic (horner_expr × expr)\n| (const e₁) (const e₂) := do\n  (e', p) ← mk_app ``has_mul.mul [e₁, e₂] >>= norm_num,\n  return (const e', p)\n| (const e₁) e₂ :=\n  match e₁.to_nat with\n  | (some 0) := do\n    α0 ← expr.of_nat c.α 0,\n    p ← mk_app ``zero_mul [e₂],\n    return (const α0, p)\n  | (some 1) := do\n    p ← mk_app ``one_mul [e₂],\n    return (e₂, p)\n  | _ := eval_const_mul c e₁ e₂\n  end\n| e₁ he₂@(const e₂) := do\n  p₁ ← mk_app ``mul_comm [e₁, e₂],\n  (e', p₂) ← eval_mul he₂ e₁,\n  p ← mk_eq_trans p₁ p₂, return (e', p)\n| he₁@(xadd e₁ a₁ x₁ n₁ b₁) he₂@(xadd e₂ a₂ x₂ n₂ b₂) :=\n  if expr.lex_lt x₁ x₂ then do\n    (a', h₁) ← eval_mul a₁ he₂,\n    (b', h₂) ← eval_mul b₁ he₂,\n    return (xadd' c a' x₁ n₁ b',\n      c.cs_app ``horner_mul_const [a₁, x₁, n₁.1, b₁, e₂, a', b', h₁, h₂])\n  else if x₁ ≠ x₂ then do\n    (a', h₁) ← eval_mul he₁ a₂,\n    (b', h₂) ← eval_mul he₁ b₂,\n    return (xadd' c a' x₂ n₂ b',\n      c.cs_app ``horner_const_mul [e₁, a₂, x₂, n₂.1, b₂, a', b', h₁, h₂])\n  else do\n    (aa, h₁) ← eval_mul he₁ a₂,\n    α0 ← expr.of_nat c.α 0,\n    (haa, h₂) ← eval_horner c aa x₁ n₂ (const α0),\n    if b₂.e.to_nat = some 0 then\n      return (haa, c.cs_app ``horner_mul_horner_zero\n        [a₁, x₁, n₁.1, b₁, a₂, n₂.1, aa, haa, h₁, h₂])\n    else do\n      (ab, h₃) ← eval_mul a₁ b₂,\n      (bb, h₄) ← eval_mul b₁ b₂,\n      (t, H) ← eval_add c haa (xadd' c ab x₁ n₁ bb),\n      return (t, c.cs_app ``horner_mul_horner\n        [a₁, x₁, n₁.1, b₁, a₂, n₂.1, b₂, aa, haa, ab, bb, t, h₁, h₂, h₃, h₄, H])\n\ntheorem horner_pow {α} [comm_semiring α] (a x n m n' a')\n  (h₁ : n * m = n') (h₂ : a ^ m = a') :\n  @horner α _ a x n 0 ^ m = horner a' x n' 0 :=\nby simp [h₁.symm, h₂.symm, horner, mul_pow, pow_mul]\n\nmeta def eval_pow (c : cache) : horner_expr → expr × ℕ → tactic (horner_expr × expr)\n| e (_, 0) := do\n  α1 ← expr.of_nat c.α 1,\n  p ← mk_app ``pow_zero [e],\n  return (const α1, p)\n| e (_, 1) := do\n  p ← mk_app ``pow_one [e],\n  return (e, p)\n| (const e) (e₂, m) := do\n  (e', p) ← mk_app ``monoid.pow [e, e₂] >>= norm_num.derive,\n  return (const e', p)\n| he@(xadd e a x n b) m :=\n  let N : expr := expr.const `nat [] in\n  match b.e.to_nat with\n  | some 0 := do\n    (n', h₁) ← mk_app ``has_mul.mul [n.1, m.1] >>= norm_num,\n    (a', h₂) ← eval_pow a m,\n    α0 ← expr.of_nat c.α 0,\n    return (xadd' c a' x (n', n.2 * m.2) (const α0),\n      c.cs_app ``horner_pow [a, x, n.1, m.1, n', a', h₁, h₂])\n  | _ := do\n    e₂ ← expr.of_nat N (m.2-1),\n    l ← mk_app ``monoid.pow [e, e₂],\n    (tl, hl) ← eval_pow he (e₂, m.2-1),\n    (t, p₂) ← eval_mul c tl he,\n    hr ← mk_eq_refl e,\n    p₂ ← c.mk_app ``norm_num.subst_into_prod ``has_mul [l, e, tl, e, t, hl, hr, p₂],\n    p₁ ← mk_app ``pow_succ' [e, e₂],\n    p ← mk_eq_trans p₁ p₂,\n    return (t, p)\n  end\n\ntheorem horner_atom {α} [comm_semiring α] (x : α) : x = horner 1 x 1 0 :=\nby simp [horner]\n\nmeta def eval_atom (c : cache) (e : expr) : tactic (horner_expr × expr) :=\ndo α0 ← expr.of_nat c.α 0,\n   α1 ← expr.of_nat c.α 1,\n   n1 ← expr.of_nat (expr.const `nat []) 1,\n   return (xadd' c (const α1) e (n1, 1) (const α0), c.cs_app ``horner_atom [e])\n\nlemma subst_into_pow {α} [monoid α] (l r tl tr t)\n  (prl : (l : α) = tl) (prr : (r : ℕ) = tr) (prt : tl ^ tr = t) : l ^ r = t :=\nby simp [prl, prr, prt]\n\nlemma unfold_sub {α} [add_group α] (a b c : α)\n  (h : a + -b = c) : a - b = c := h\n\nlemma unfold_div {α} [division_ring α] (a b c : α)\n  (h : a * b⁻¹ = c) : a / b = c := h\n\nmeta def eval (c : cache) : expr → tactic (horner_expr × expr)\n| `(%%e₁ + %%e₂) := do\n  (e₁', p₁) ← eval e₁,\n  (e₂', p₂) ← eval e₂,\n  (e', p') ← eval_add c e₁' e₂',\n  p ← c.mk_app ``norm_num.subst_into_sum ``has_add [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n  return (e', p)\n| `(%%e₁ - %%e₂) := do\n  e₂' ← mk_app ``has_neg.neg [e₂],\n  e ← mk_app ``has_add.add [e₁, e₂'],\n  (e', p) ← eval e,\n  p' ← c.mk_app ``unfold_sub ``add_group [e₁, e₂, e', p],\n  return (e', p')\n| `(- %%e) := do\n  (e₁, p₁) ← eval e,\n  (e₂, p₂) ← eval_neg c e₁,\n  p ← c.mk_app ``norm_num.subst_into_neg ``has_neg [e, e₁, e₂, p₁, p₂],\n  return (e₂, p)\n| `(%%e₁ * %%e₂) := do\n  (e₁', p₁) ← eval e₁,\n  (e₂', p₂) ← eval e₂,\n  (e', p') ← eval_mul c e₁' e₂',\n  p ← c.mk_app ``norm_num.subst_into_prod ``has_mul [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n  return (e', p)\n| e@`(has_inv.inv %%_) := (do\n    (e', p) ← norm_num.derive e,\n    e'.to_rat,\n    return (const e', p)) <|> eval_atom c e\n| `(%%e₁ / %%e₂) := do\n  e₂' ← mk_app ``has_inv.inv [e₂],\n  e ← mk_app ``has_mul.mul [e₁, e₂'],\n  (e', p) ← eval e,\n  p' ← c.mk_app ``unfold_div ``division_ring [e₁, e₂, e', p],\n  return (e', p')\n| e@`(@has_pow.pow _ _ %%P %%e₁ %%e₂) := do\n  (e₂', p₂) ← eval e₂,\n  match e₂'.e.to_nat, P with\n  | some k, `(monoid.has_pow) := do\n    (e₁', p₁) ← eval e₁,\n    (e', p') ← eval_pow c e₁' (e₂, k),\n    p ← c.mk_app ``subst_into_pow ``monoid [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n    return (e', p)\n  | some k, `(nat.has_pow) := do\n    (e₁', p₁) ← eval e₁,\n    (e', p') ← eval_pow c e₁' (e₂, k),\n    p₃ ← c.mk_app ``subst_into_pow ``monoid [e₁, e₂, e₁', e₂', e', p₁, p₂, p'],\n    p₄ ← mk_app ``nat.pow_eq_pow [e₁, e₂] >>= mk_eq_symm,\n    p ← mk_eq_trans p₄ p₃,\n    return (e', p)\n  | _, _ := eval_atom c e\n  end\n| e := match e.to_nat with\n  | some n := (const e).refl_conv\n  | none := eval_atom c e\n  end\n\nmeta def eval' (c : cache) (e : expr) : tactic (expr × expr) :=\ndo (e', p) ← eval c e, return (e', p)\n\ntheorem horner_def' {α} [comm_semiring α] (a x n b) : @horner α _ a x n b = x ^ n * a + b :=\nby simp [horner, mul_comm]\n\ntheorem mul_assoc_rev {α} [semigroup α] (a b c : α) : a * (b * c) = a * b * c :=\nby simp [mul_assoc]\n\ntheorem pow_add_rev {α} [monoid α] (a b : α) (m n : ℕ) : a ^ m * a ^ n = a ^ (m + n) :=\nby simp [pow_add]\n\ntheorem pow_add_rev_right {α} [monoid α] (a b : α) (m n : ℕ) : b * a ^ m * a ^ n = b * a ^ (m + n) :=\nby simp [pow_add, mul_assoc]\n\ntheorem add_neg_eq_sub {α} [add_group α] (a b : α) : a + -b = a - b := rfl\n\n@[derive has_reflect]\ninductive normalize_mode | raw | SOP | horner\n\nmeta def normalize (mode := normalize_mode.horner) (e : expr) : tactic (expr × expr) := do\npow_lemma ← simp_lemmas.mk.add_simp ``pow_one,\nlet lemmas := match mode with\n| normalize_mode.SOP :=\n  [``horner_def', ``add_zero, ``mul_one, ``mul_add, ``mul_sub,\n   ``mul_assoc_rev, ``pow_add_rev, ``pow_add_rev_right,\n   ``mul_neg_eq_neg_mul_symm, ``add_neg_eq_sub]\n| normalize_mode.horner :=\n  [``horner.equations._eqn_1, ``add_zero, ``one_mul, ``pow_one,\n   ``neg_mul_eq_neg_mul_symm, ``add_neg_eq_sub]\n| _ := []\nend,\nlemmas ← lemmas.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n(_, e', pr) ← ext_simplify_core () {}\n  simp_lemmas.mk (λ _, failed) (λ _ _ _ _ e, do\n    c ← mk_cache e,\n    (new_e, pr) ← match mode with\n    | normalize_mode.raw := eval' c\n    | normalize_mode.horner := trans_conv (eval' c) (simplify lemmas [])\n    | normalize_mode.SOP :=\n      trans_conv (eval' c) $\n      trans_conv (simplify lemmas []) $\n      simp_bottom_up' (λ e, norm_num e <|> pow_lemma.rewrite e)\n    end e,\n    guard (¬ new_e =ₐ e),\n    return ((), new_e, some pr, ff))\n   (λ _ _ _ _ _, failed) `eq e,\nreturn (e', pr)\n\nend ring\n\nnamespace interactive\nopen interactive interactive.types lean.parser\nopen tactic.ring\n\nlocal postfix `?`:9001 := optional\n\n/-- Tactic for solving equations in the language of rings.\n  This version of `ring` fails if the target is not an equality\n  that is provable by the axioms of commutative (semi)rings. -/\nmeta def ring1 : tactic unit :=\ndo `(%%e₁ = %%e₂) ← target,\n  c ← mk_cache e₁,\n  (e₁', p₁) ← eval c e₁,\n  (e₂', p₂) ← eval c e₂,\n  is_def_eq e₁' e₂',\n  p ← mk_eq_symm p₂ >>= mk_eq_trans p₁,\n  tactic.exact p\n\nmeta def ring.mode : lean.parser ring.normalize_mode :=\nwith_desc \"(SOP|raw|horner)?\" $\ndo mode ← ident?, match mode with\n| none         := return ring.normalize_mode.horner\n| some `horner := return ring.normalize_mode.horner\n| some `SOP    := return ring.normalize_mode.SOP\n| some `raw    := return ring.normalize_mode.raw\n| _            := failed\nend\n\n/-- Tactic for solving equations in the language of rings.\n  Attempts to prove the goal outright if there is no `at`\n  specifier and the target is an equality, but if this\n  fails it falls back to rewriting all ring expressions\n  into a normal form. When writing a normal form,\n  `ring SOP` will use sum-of-products form instead of horner form. -/\nmeta def ring (SOP : parse ring.mode) (loc : parse location) : tactic unit :=\nmatch loc with\n| interactive.loc.ns [none] := ring1\n| _ := failed\nend <|>\ndo ns ← loc.get_locals,\n   tt ← tactic.replace_at (normalize SOP) ns loc.include_goal\n      | fail \"ring failed to simplify\",\n   when loc.include_goal $ try tactic.reflexivity\n\nend interactive\nend tactic\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/tactic/ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.4790384782813798}}
{"text": "import Smt\n\ntheorem hypothetical_syllogism (p q r : Prop) : (p → q) → (q → r) → p → r := by\n  smt\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Test/Prop/HypotheticalSyllogism.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4789819314375911}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport deprecated.subgroup\nimport deprecated.group\nimport ring_theory.subring.basic\n\n/-!\n# Unbundled subrings (deprecated)\n\nThis file is deprecated, and is no longer imported by anything in mathlib other than other\ndeprecated files, and test files. You should not need to import it.\n\nThis file defines predicates for unbundled subrings. Instead of using this file, please use\n`subring`, defined in `ring_theory.subring.basic`, for subrings of rings.\n\n## Main definitions\n\n`is_subring (S : set R) : Prop` : the predicate that `S` is the underlying set of a subring\nof the ring `R`. The bundled variant `subring R` should be used in preference to this.\n\n## Tags\n\nis_subring\n-/\nuniverses u v\n\nopen group\n\nvariables {R : Type u} [ring R]\n\n/-- `S` is a subring: a set containing 1 and closed under multiplication, addition and additive\ninverse. -/\nstructure is_subring (S : set R) extends is_add_subgroup S, is_submonoid S : Prop.\n\n/-- Construct a `subring` from a set satisfying `is_subring`. -/\ndef is_subring.subring {S : set R} (hs : is_subring S) : subring R :=\n{ carrier := S,\n  one_mem' := hs.one_mem,\n  mul_mem' := hs.mul_mem,\n  zero_mem' := hs.zero_mem,\n  add_mem' := hs.add_mem,\n  neg_mem' := hs.neg_mem }\n\nnamespace ring_hom\n\nlemma is_subring_preimage {R : Type u} {S : Type v} [ring R] [ring S]\n  (f : R →+* S) {s : set S} (hs : is_subring s) : is_subring (f ⁻¹' s) :=\n{ ..is_add_group_hom.preimage f.to_is_add_group_hom hs.to_is_add_subgroup,\n  ..is_submonoid.preimage f.to_is_monoid_hom hs.to_is_submonoid, }\n\nlemma is_subring_image {R : Type u} {S : Type v} [ring R] [ring S]\n  (f : R →+* S) {s : set R} (hs : is_subring s) : is_subring (f '' s) :=\n{ ..is_add_group_hom.image_add_subgroup f.to_is_add_group_hom hs.to_is_add_subgroup,\n  ..is_submonoid.image f.to_is_monoid_hom hs.to_is_submonoid, }\n\nlemma is_subring_set_range {R : Type u} {S : Type v} [ring R] [ring S]\n  (f : R →+* S) : is_subring (set.range f) :=\n{ ..is_add_group_hom.range_add_subgroup f.to_is_add_group_hom,\n  ..range.is_submonoid f.to_is_monoid_hom, }\n\nend ring_hom\n\nvariables {cR : Type u} [comm_ring cR]\n\nlemma is_subring.inter {S₁ S₂ : set R} (hS₁ : is_subring S₁) (hS₂ : is_subring S₂) :\n  is_subring (S₁ ∩ S₂) :=\n{ ..is_add_subgroup.inter hS₁.to_is_add_subgroup hS₂.to_is_add_subgroup,\n  ..is_submonoid.inter hS₁.to_is_submonoid hS₂.to_is_submonoid }\n\nlemma is_subring.Inter {ι : Sort*} {S : ι → set R} (h : ∀ y : ι, is_subring (S y)) :\n  is_subring (set.Inter S) :=\n{ ..is_add_subgroup.Inter (λ i, (h i).to_is_add_subgroup),\n  ..is_submonoid.Inter (λ i, (h i).to_is_submonoid) }\n\nlemma is_subring_Union_of_directed {ι : Type*} [hι : nonempty ι]\n  {s : ι → set R} (h : ∀ i, is_subring (s i))\n  (directed : ∀ i j, ∃ k, s i ⊆ s k ∧ s j ⊆ s k) :\n  is_subring (⋃i, s i) :=\n{ to_is_add_subgroup := is_add_subgroup_Union_of_directed\n    (λ i, (h i).to_is_add_subgroup) directed,\n  to_is_submonoid := is_submonoid_Union_of_directed (λ i, (h i).to_is_submonoid) directed }\n\nnamespace ring\n\n/-- The smallest subring containing a given subset of a ring, considered as a set. This function\nis deprecated; use `subring.closure`. -/\ndef closure (s : set R) := add_group.closure (monoid.closure s)\n\nvariable {s : set R}\n\nlocal attribute [reducible] closure\n\ntheorem exists_list_of_mem_closure {a : R} (h : a ∈ closure s) :\n  (∃ L : list (list R), (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = (-1:R)) ∧ (L.map list.prod).sum = a) :=\nadd_group.in_closure.rec_on h\n  (λ x hx, match x, monoid.exists_list_of_mem_closure hx with\n    | _, ⟨L, h1, rfl⟩ := ⟨[L], list.forall_mem_singleton.2 (λ r hr, or.inl (h1 r hr)), zero_add _⟩\n    end)\n  ⟨[], list.forall_mem_nil _, rfl⟩\n  (λ b _ ih, match b, ih with\n    | _, ⟨L1, h1, rfl⟩ := ⟨L1.map (list.cons (-1)),\n      λ L2 h2, match L2, list.mem_map.1 h2 with\n        | _, ⟨L3, h3, rfl⟩ := list.forall_mem_cons.2 ⟨or.inr rfl, h1 L3 h3⟩\n        end,\n      by simp only [list.map_map, (∘), list.prod_cons, neg_one_mul];\n      exact list.rec_on L1 neg_zero.symm (λ hd tl ih,\n        by rw [list.map_cons, list.sum_cons, ih, list.map_cons, list.sum_cons, neg_add])⟩\n    end)\n  (λ r1 r2 hr1 hr2 ih1 ih2, match r1, r2, ih1, ih2 with\n    | _, _, ⟨L1, h1, rfl⟩, ⟨L2, h2, rfl⟩ := ⟨L1 ++ L2, list.forall_mem_append.2 ⟨h1, h2⟩,\n      by rw [list.map_append, list.sum_append]⟩\n    end)\n\n@[elab_as_eliminator]\nprotected theorem in_closure.rec_on {C : R → Prop} {x : R} (hx : x ∈ closure s)\n  (h1 : C 1) (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n))\n  (ha : ∀ {x y}, C x → C y → C (x + y)) : C x :=\nbegin\n  have h0 : C 0 := add_neg_self (1:R) ▸ ha h1 hneg1,\n  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩, clear hx,\n  induction L with hd tl ih, { exact h0 },\n  rw list.forall_mem_cons at HL,\n  suffices : C (list.prod hd),\n  { rw [list.map_cons, list.sum_cons],\n    exact ha this (ih HL.2) },\n  replace HL := HL.1, clear ih tl,\n  suffices : ∃ L : list R,\n    (∀ x ∈ L, x ∈ s) ∧ (list.prod hd = list.prod L ∨ list.prod hd = -list.prod L),\n  { rcases this with ⟨L, HL', HP | HP⟩,\n    { rw HP, clear HP HL hd, induction L with hd tl ih, { exact h1 },\n      rw list.forall_mem_cons at HL',\n      rw list.prod_cons,\n      exact hs _ HL'.1 _ (ih HL'.2) },\n    rw HP, clear HP HL hd, induction L with hd tl ih, { exact hneg1 },\n    rw [list.prod_cons, neg_mul_eq_mul_neg],\n    rw list.forall_mem_cons at HL',\n    exact hs _ HL'.1 _ (ih HL'.2) },\n  induction hd with hd tl ih,\n  { exact ⟨[], list.forall_mem_nil _, or.inl rfl⟩ },\n  rw list.forall_mem_cons at HL,\n  rcases ih HL.2 with ⟨L, HL', HP | HP⟩; cases HL.1 with hhd hhd,\n  { exact ⟨hd :: L, list.forall_mem_cons.2 ⟨hhd, HL'⟩, or.inl $\n      by rw [list.prod_cons, list.prod_cons, HP]⟩ },\n  { exact ⟨L, HL', or.inr $ by rw [list.prod_cons, hhd, neg_one_mul, HP]⟩ },\n  { exact ⟨hd :: L, list.forall_mem_cons.2 ⟨hhd, HL'⟩, or.inr $\n      by rw [list.prod_cons, list.prod_cons, HP, neg_mul_eq_mul_neg]⟩ },\n  { exact ⟨L, HL', or.inl $ by rw [list.prod_cons, hhd, HP, neg_one_mul, neg_neg]⟩ }\nend\n\nlemma closure.is_subring : is_subring (closure s) :=\n{ one_mem := add_group.mem_closure $ is_submonoid.one_mem $ monoid.closure.is_submonoid _,\n  mul_mem := λ a b ha hb, add_group.in_closure.rec_on hb\n    ( λ c hc, add_group.in_closure.rec_on ha\n      ( λ d hd, add_group.subset_closure ((monoid.closure.is_submonoid _).mul_mem hd hc))\n      ( (zero_mul c).symm ▸ (add_group.closure.is_add_subgroup _).zero_mem)\n      ( λ d hd hdc, neg_mul_eq_neg_mul d c ▸ (add_group.closure.is_add_subgroup _).neg_mem hdc)\n      ( λ d e hd he hdc hec, (add_mul d e c).symm ▸\n        ((add_group.closure.is_add_subgroup _).add_mem hdc hec)))\n    ( (mul_zero a).symm ▸ (add_group.closure.is_add_subgroup _).zero_mem)\n    ( λ c hc hac, neg_mul_eq_mul_neg a c ▸ (add_group.closure.is_add_subgroup _).neg_mem hac)\n    ( λ c d hc hd hac had, (mul_add a c d).symm ▸\n      (add_group.closure.is_add_subgroup _).add_mem hac had),\n  ..add_group.closure.is_add_subgroup _}\n\ntheorem mem_closure {a : R} : a ∈ s → a ∈ closure s :=\nadd_group.mem_closure ∘ @monoid.subset_closure _ _ _ _\n\ntheorem subset_closure : s ⊆ closure s :=\nλ _, mem_closure\n\ntheorem closure_subset {t : set R} (ht : is_subring t) : s ⊆ t → closure s ⊆ t :=\n(add_group.closure_subset ht.to_is_add_subgroup) ∘ (monoid.closure_subset ht.to_is_submonoid)\n\ntheorem closure_subset_iff {s t : set R} (ht : is_subring t) : closure s ⊆ t ↔ s ⊆ t :=\n(add_group.closure_subset_iff ht.to_is_add_subgroup).trans\n  ⟨set.subset.trans monoid.subset_closure, monoid.closure_subset ht.to_is_submonoid⟩\n\ntheorem closure_mono {s t : set R} (H : s ⊆ t) : closure s ⊆ closure t :=\nclosure_subset closure.is_subring $ set.subset.trans H subset_closure\n\nlemma image_closure {S : Type*} [ring S] (f : R →+* S) (s : set R) :\n  f '' closure s = closure (f '' s) :=\nle_antisymm\n  begin\n    rintros _ ⟨x, hx, rfl⟩,\n    apply in_closure.rec_on hx; intros,\n    { rw [f.map_one], apply closure.is_subring.to_is_submonoid.one_mem },\n    { rw [f.map_neg, f.map_one],\n      apply closure.is_subring.to_is_add_subgroup.neg_mem,\n      apply closure.is_subring.to_is_submonoid.one_mem },\n    { rw [f.map_mul],\n      apply closure.is_subring.to_is_submonoid.mul_mem;\n      solve_by_elim [subset_closure, set.mem_image_of_mem] },\n    { rw [f.map_add], apply closure.is_subring.to_is_add_submonoid.add_mem, assumption' },\n  end\n  (closure_subset (ring_hom.is_subring_image _ closure.is_subring) $\n    set.image_subset _ subset_closure)\n\nend ring\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/deprecated/subring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.47898193143759105}}
{"text": "import group_theory.perm.basic\n\nvariables {α β γ : Type*}\n\nnamespace equiv\n\n@[simp] lemma symm_trans (f : α ≃ β) (g : β ≃ γ) : (f.trans g).symm = (g.symm).trans f.symm := rfl\n\nend equiv\n", "meta": {"author": "leanprover-community", "repo": "con-nf", "sha": "f0b66bd73ca5d3bd8b744985242c4c0b5464913f", "save_path": "github-repos/lean/leanprover-community-con-nf", "path": "github-repos/lean/leanprover-community-con-nf/con-nf-f0b66bd73ca5d3bd8b744985242c4c0b5464913f/src/mathlib/equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8080672043084051, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.47891444251185306}}
{"text": "/-\nCopyright (c) Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.shapes.equivalence\n! leanprover-community/mathlib commit ea74dc9f981009c33b9971f3389509a88c95cf07\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Adjunction.Limits\nimport Mathlib.CategoryTheory.Limits.Shapes.Terminal\n\n/-!\n# Transporting existence of specific limits across equivalences\n\nFor now, we only treat the case of initial and terminal objects, but other special shapes can be\nadded in the future.\n-/\n\n\nopen CategoryTheory CategoryTheory.Limits\n\nnamespace CategoryTheory\n\nuniverse v₁ v₂ u₁ u₂\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]\n\ntheorem hasInitial_of_equivalence (e : D ⥤ C) [IsEquivalence e] [HasInitial C] : HasInitial D :=\n  Adjunction.hasColimitsOfShape_of_equivalence e\n#align category_theory.has_initial_of_equivalence CategoryTheory.hasInitial_of_equivalence\n\ntheorem Equivalence.hasInitial_iff (e : C ≌ D) : HasInitial C ↔ HasInitial D :=\n  ⟨fun (_ : HasInitial C) => hasInitial_of_equivalence e.inverse,\n    fun (_ : HasInitial D) => hasInitial_of_equivalence e.functor⟩\n#align category_theory.equivalence.has_initial_iff CategoryTheory.Equivalence.hasInitial_iff\n\ntheorem hasTerminal_of_equivalence (e : D ⥤ C) [IsEquivalence e] [HasTerminal C] : HasTerminal D :=\n  Adjunction.hasLimitsOfShape_of_equivalence e\n#align category_theory.has_terminal_of_equivalence CategoryTheory.hasTerminal_of_equivalence\n\ntheorem Equivalence.hasTerminal_iff (e : C ≌ D) : HasTerminal C ↔ HasTerminal D :=\n  ⟨fun (_ : HasTerminal C) => hasTerminal_of_equivalence e.inverse,\n    fun (_ : HasTerminal D) => hasTerminal_of_equivalence e.functor⟩\n#align category_theory.equivalence.has_terminal_iff CategoryTheory.Equivalence.hasTerminal_iff\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Limits/Shapes/Equivalence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6723317123102955, "lm_q1q2_score": 0.47885629220535886}}
{"text": "namespace SciLean\n\n-- opaque definitions\nopaque vec_impl (X : Type) : Type\nopaque smooth_impl (f : X → Y) : Prop\nopaque ℝ : Type\n\n-- Vec Type\nclass Vec (X : Type) extends OfNat X 0, Add X, Sub X, Neg X, HMul ℝ X X where impl : vec_impl X\ninstance : Vec ℝ := sorry\ninstance {X Y} [Vec X] [Vec Y] : Vec (X×Y) := sorry\ninstance {α : Type} [Vec X] : Vec (α→X) := sorry\n\ninstance {X} [Vec X] : OfNat X 0 := Vec.toOfNat\n\n\n-- IsSmooth predicate\nclass IsSmooth {X Y : Type} [Vec X] [Vec Y] (f : X → Y) : Prop where impl : smooth_impl f\nclass IsSmooth2 {X Y Z : Type} [Vec X] [Vec Y] [Vec Z] (f : X → Y → Z) extends IsSmooth λ (x,y) => f x y\n\n\n-- Differential\nopaque differential (f : X → Y) : X → X → Y := sorry\n\nprefix:max \" ∂ \" => differential\n\n\n-- SmoothMap\nstructure SmoothMap (X Y) [Vec X] [Vec Y] where\n  val : X → Y\n  [property : IsSmooth val]\n\ninfix:25 \" ⟿ \" => SmoothMap\n\ninstance {X Y} [Vec X] [Vec Y] : Vec (X ⟿ Y) := sorry\ninstance {X Y} [Vec X] [Vec Y] : CoeFun (X ⟿ Y) (λ _ => X → Y) := ⟨λ f => f.val⟩\n\ninstance SmoothMap.val.arg_fx.isSmooth {X Y} [Vec X] [Vec Y]\n  : IsSmooth2 (λ (f : X⟿Y) (x : X) => f x) := sorry\n\n\n-- Lambda notation\nopen Lean.TSyntax.Compat in\nmacro \"λ\"   xs:Lean.explicitBinders \" ⟿ \" b:term : term =>\n  Lean.expandExplicitBinders `SciLean.SmoothMap.mk xs b\n\n\nvariable {X Y Z W W'} [Vec X] [Vec Y] [Vec Z] [Vec W] [Vec W'] {α : Type}\n\n--------------------------------------------------------------------------------\n-- IsSmooth rules\n--------------------------------------------------------------------------------\n\n-- Core I,K,S,C,C' rules for IsSmooth\ninstance IsSmooth_rule_I : IsSmooth (λ x : X => x) := sorry\ninstance IsSmooth_rule_K (x : X) : IsSmooth (λ y : Y => x) := sorry\ninstance IsSmooth_rule_S (f : X → Y → Z) (g : X → Y) [IsSmooth2 f] [IsSmooth g]\n  : IsSmooth (λ x => f x (g x)) := sorry\n\ninstance IsSmooth_rule_C  (f : α → X → Y) [∀ a, IsSmooth (f a)]\n  : IsSmooth λ x a => f a x := sorry\ninstance IsSmooth_rule_C' (f : X → α → Y) [IsSmooth f] (a : α)\n  : IsSmooth λ x => f x a := sorry\n\n-- Curry and uncurry for IsSmooth\ninstance IsSmooth_curry (f : X → Y → Z)\n  [∀ x, IsSmooth (f x)] [IsSmooth λ x => λ y ⟿ f x y]\n  : IsSmooth2 f := IsSmooth2.mk (toIsSmooth := sorry)\n\ninstance IsSmooth_uncurry_y (f : X → Y → Z) [IsSmooth2 f] (x : X)\n  : IsSmooth (λ y => f x y) := sorry\ninstance IsSmooth_uncurry_x (f : X → Y → Z) [IsSmooth2 f]\n  : IsSmooth (λ x => λ y ⟿ f x y) := sorry\n\n-- These two rules are suficient for what we do in this file but are not sufficient in general\ninstance IsSmooth_uncurry_x_comp (f : X → Y → Z) [IsSmooth2 f]\n  (g : W → X) [IsSmooth g]\n  : IsSmooth (λ w => λ y ⟿ f (g w) y) := sorry\ninstance IsSmooth_uncurry_x_const (f : X → Z) [IsSmooth f] \n  : IsSmooth (λ (x : X) => λ (y : Y) ⟿ f x) := sorry\n\n--------------------------------------------------------------------------------\n-- Differential rules\n--------------------------------------------------------------------------------\n\n@[simp]\ntheorem differential_rule_I\n  : ∂ (λ x : X => x)\n    =\n    λ x dx => dx := sorry\n\n@[simp]\ntheorem differential_rule_K (x : X)\n  : ∂ (λ y : Y => x)\n    =\n    λ y Y => 0 := sorry\n\n@[simp]\ntheorem differential_rule_S\n  (f : X → Y → Z) (g : X → Y) [IsSmooth2 f] [IsSmooth g]\n  : ∂ (λ x => f x (g x))\n    =\n    λ x dx =>\n      ∂ f x dx (g x)\n      +\n      ∂ (f x) (g x) (∂ g x dx) := sorry\n\n@[simp]\ntheorem differential_rule_C (f : α → X → Y) [∀ a, IsSmooth (f a)]\n  : ∂ (λ x a => f a x)\n    =\n    λ x dx a => ∂ (f a) x dx := sorry\n\n@[simp]\ntheorem differential_rule_C' (f : X → α → Y) [IsSmooth f] (a : α)\n  : ∂ (λ x => f x a)\n    =\n    λ x dx => ∂ f x dx a := sorry\n\n\n\n-- Some basic properties of addition, multiplication and zero\ninstance : IsSmooth2 (λ x y : X => x + y) := sorry\n@[simp] theorem HAdd.hAdd.arg_x.diff_simp : ∂ (λ x y : X => x + y) = λ x dx y => dx := sorry\n@[simp] theorem HAdd.hAdd.arg_y.diff_simp (x : X) : ∂ (λ y : X => x + y) = λ y dy => dy := sorry\n\ninstance : IsSmooth2 (λ (x : ℝ) (y : X) => x * y) := sorry\n@[simp] theorem HMul.hMul.arg_x.diff_simp : ∂ (λ (x : ℝ) (y : X) => x * y) = λ x dx y => dx * y := sorry\n@[simp] theorem HMul.hMul.arg_y.diff_simp (x : ℝ) : ∂ (λ y : X => x * y) = λ y dy : X => x * dy := sorry\n\n\n@[simp] theorem add_zero (x : X) : x + 0 = x := sorry\n@[simp] theorem zero_add (x : X) : 0 + x = x := sorry\n@[simp] theorem mul_zero (x : X) : (0:ℝ) * x = (0:X) := sorry\n\n@[simp] theorem zero_app (a : α) : (0 : α → X) a = (0 : X) := sorry\n@[simp] theorem differential_zero (f : X → Y) [IsSmooth f] (x : X): ∂ f x 0 = 0 := sorry\n\n\n@[simp high] -- prefer this over S rule\ntheorem chain_rule\n  (f : Y → Z) (g : X → Y) [IsSmooth f] [IsSmooth g]\n  : ∂ (λ x => f (g x))\n    =\n    λ x dx => ∂ f (g x) (∂ g x dx) := by simp\n\n@[simp high] -- prefer this over S rule\ntheorem binop_chain_rule {Y₁ Y₂} [Vec Y₁] [Vec Y₂]\n  (f : Y₁ → Y₂ → Z) [IsSmooth2 f] \n  (g₁ : X → Y₁) [IsSmooth g₁]\n  (g₂ : X → Y₂) [IsSmooth g₂]\n  : ∂ (λ x => f (g₁ x) (g₂ x))\n    =\n    λ x dx => \n      ∂ f (g₁ x) (∂ g₁ x dx) (g₂ x)\n      +\n      ∂ (f (g₁ x)) (g₂ x) (∂ g₂ x dx) := \nby \n  funext x dx\n  rw[differential_rule_S (λ x y => f (g₁ x) y) g₂]; dsimp\n  rw[differential_rule_C]; dsimp\n  rw[differential_rule_S (λ _ x' => f x' (g₂ x)) g₁]\n  simp\n  done\n\n\n--------------------------------------------------------------------------------\n-- Tests\n--------------------------------------------------------------------------------\n\nnamespace maintests\n\n  variable {α β γ : Type}\n\n  variable (f : Y → Z) (g : X → Y) [IsSmooth f] [IsSmooth g] (h : X → X) [IsSmooth h] (h' : Y → Y) [IsSmooth h']\n  variable (a : α) (b : β)\n  variable (F : Y → α → X) [IsSmooth F]\n  variable (G : X → α → β → Y) [IsSmooth G]\n  variable (G' : X → Z → W → Y) (z : Z) (w : W) [IsSmooth G']\n  variable (H : α → X → β → Y) [IsSmooth (H a)]\n  variable (H': α → β → X → Y) [IsSmooth (H' a b)]\n\n  example : IsSmooth (λ x => g x) := by infer_instance\n  example : IsSmooth (λ x => f (g x)) := by infer_instance\n  example : IsSmooth (λ x => f (g (h (h x)))) := by infer_instance\n  example : IsSmooth (λ (g' : X → Y) => f ∘ g') := by unfold Function.comp; infer_instance\n  example : IsSmooth (λ (x : X) => F (g (h x)) a) := by infer_instance\n  example : IsSmooth (f ∘ g) := by unfold Function.comp; infer_instance\n  example : IsSmooth (λ (f : Y → Z) (x : X) => (f (g x))) := by infer_instance\n  example : IsSmooth (λ (h'' : X → X) (x : X) => h (h (h (h'' ((h ∘ h) (h x)))))) := by infer_instance\n  example : IsSmooth (λ (x : X) => G (h x) a b) := by infer_instance\n  example : IsSmooth (λ (x : X) => H a (h x) b) := by infer_instance\n  example : IsSmooth (λ (x : X) => H' a b (h x)) := by infer_instance\n  example (f : β → Y → Z) [∀ b, IsSmooth (f b)] : IsSmooth (λ (g : α → Y) (b : β) (a : α) => f b (g a)) := by infer_instance\n  example (f : X → X → Y) [IsSmooth2 f]: IsSmooth (λ x => f x x) := by infer_instance\n  example (f : X → X → Y) [IsSmooth2 f]: IsSmooth (λ x => f (h x) x) := by infer_instance\n  example (f : X → X → Y) [IsSmooth2 f] : IsSmooth (λ x => f x (h x)) := by infer_instance\n  example : IsSmooth (λ (h : X → X) (x : X) => H' a b (h x)) := by infer_instance\n  example (f : Y → Z) (g : X → Y) [IsSmooth f] [IsSmooth g] : IsSmooth (f ∘ g) := by unfold Function.comp; infer_instance\n  example (g : α → β) : IsSmooth (λ (f : β → Z) (a : α) => (f (g a))) := by infer_instance\n  example (f : Y → β → Z) (g : X → Y) (b : β) [IsSmooth f] [IsSmooth g] : IsSmooth (λ x => f (g x) d) := by infer_instance\n  example (f : Y → β → Z) (g : X → Y) (h : X → X) (b : β) [IsSmooth f] [IsSmooth g] [IsSmooth h] : IsSmooth (λ x => f (g (h (h x))) d) := by infer_instance\n  example (f : α → Y → Z) [∀ a, IsSmooth (f a)] : IsSmooth (λ y a => f a y) := by infer_instance\n  example (f : α → β → X → Y) [∀ a b, IsSmooth (f a b)] : IsSmooth (λ x b a => f a b x) := by infer_instance\n  example (f : α → β → X → Y) [∀ a b, IsSmooth (f a b)] : IsSmooth (λ x a b => f a b x) := by infer_instance\n  example (f : α → β → γ → X → Y) [∀ a b c, IsSmooth (f a b c)] : IsSmooth (λ x a b c => f a b c x) := by infer_instance\n  example (f : X → X) [IsSmooth f] : IsSmooth (λ (g : X → X) x => f (f (g x))) := by infer_instance\n  example (f : X → X → β → Y) [IsSmooth2 f] : IsSmooth (λ x b => f x x b) := by infer_instance\n  example : IsSmooth (λ (g : X → Y) (x : X) => F (g (h x)) a) := by infer_instance\n  example : IsSmooth (λ (x : X) => G' (h x) z w) := by infer_instance\n  example (f : X → X → β → Y) [IsSmooth2 f]  (b) : IsSmooth (λ x => f x x b) := by infer_instance\n  example : IsSmooth (λ (h : X → X) (x : X) => G (h x)) := by infer_instance\n\n  example : IsSmooth (λ (h : X → X) (x : X) => G (h x) a b) := by infer_instance\n  example : IsSmooth (λ (h : X → X) (x : X) => H a (h x) b) := by infer_instance\n  example : IsSmooth (λ (x : X) => h (F (h' ((h' ∘ g) (h x))) a)) := by unfold Function.comp; infer_instance\n  set_option synthInstance.maxSize 200 in\n  example : IsSmooth (λ (h'' : X → X) (x : X) => (h ∘ h ∘ h) (h (h'' (h ((h ∘ h) x))))) := by unfold Function.comp; infer_instance\n\nend maintests\n\n\nnamespace foldtest\n\nvariable {α β γ : Type} \nvariable {X : Type} {Y : Type} {Z : Type} [Vec X] [Vec Y] [Vec Z]\n\nvariable (f : X → X) [IsSmooth f]\n\n\nexample : IsSmooth (λ x => f x) := by infer_instance\nexample : IsSmooth (λ x => x |> f) := by infer_instance\nexample : IsSmooth (λ x => x |> f |> f) := by infer_instance\nexample : IsSmooth (λ (g : X → X) x => f (g x)) := by infer_instance\nexample : IsSmooth (λ (g : X → X) x => g (f x)) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> g |> g) := by infer_instance\nexample : IsSmooth (λ (g : X → X) x => f (f (g x))) := by infer_instance\nexample : IsSmooth (λ (g : X → X) x => f (g (f x))) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> g |> g |> f) := by infer_instance\nexample : IsSmooth (λ (g : X → X)  x => g (f (f x))) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> g |> f |> g) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> f |> g |> g) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> g |> g |> g) := by infer_instance\nexample : IsSmooth (λ (g : X → X)  x => x |> g |> f |> f |> f) := by infer_instance\nexample : IsSmooth (λ (g : X → X)  x => x |> f |> g |> f |> f) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> g |> g |> f |> f) := by infer_instance\nexample : IsSmooth (λ (g : X → X)  x => x |> f |> f |> g |> f) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> g |> f |> g |> f) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> f |> g |> g |> f) := by infer_instance\nexample : IsSmooth (λ (g : X ⟿ X) x => x |> g |> g |> g |> f) := by infer_instance\nexample : IsSmooth (λ (g : X → X)  x => x |> f |> f |> f |> g) := by infer_instance\n\nend foldtest\n\n\nsection differentiation_tests\n\nvariable {α β γ : Type}\nvariable {X Y Z W : Type} [Vec X] [Vec Y] [Vec Z] [Vec W]\nvariable {Y₁ Y₂ : Type} [Vec Y₁] [Vec Y₂]\n\n\nexample (f : Y → Z) [IsSmooth f] (g : X → Y) [IsSmooth g]\n  : ∂ (λ x => f (g x)) = λ x dx => ∂ f (g x) (∂ g x dx) := by simp\n\n\nexample (a : α) (f : Y → α → Z) [IsSmooth f] (g : X → Y) [IsSmooth g]\n  : ∂ (λ x => f (g x) a) = λ x dx => ∂ f (g x) (∂ g x dx) a := by simp\n\nexample (f : Y → Z) [IsSmooth f]\n  : ∂ (λ (g : α → Y) (a : α) => f (g a)) = λ g dg a => ∂ f (g a) (dg a) := by simp\n\nexample\n  : ∂ (λ (f : β → Z) (g : α → β) (a : α) => f (g a)) = λ f df (g : α → β) a => df (g a) := by simp\n\nexample (f : Y → β → Z) (g : X → Y) [IsSmooth f] [IsSmooth g] (b) \n  : ∂ (λ x => f (g x) b) = λ x dx => ∂ f (g x) (∂ g x dx) b := by simp\n\nexample (f : Y → β → Z) [IsSmooth f] (b)\n  : ∂ (λ (g : α → Y) a => f (g a) b) = λ g dg a => ∂ f (g a) (dg a) b := by simp\n\nexample (f : β → Y → Z) (g : β → X → Y) [∀ b, IsSmooth (f b)] [∀ b, IsSmooth (g b)]\n  : ∂ (λ x b => f b (g b x)) = λ x dx b => ∂ (f b) (g b x) (∂ (g b) x dx) := by simp\n\nexample (f : Y → β → Z) (g : X → Y) [IsSmooth f] [IsSmooth g]\n  : ∂ (λ x b => f (g x) b) = λ x dx b => ∂ f (g x) (∂ g x dx) b := by simp\n\nset_option synthInstance.maxSize 300 in\nexample (f : Y → β → Z) [IsSmooth f]\n  : ∂ (λ (g : α → Y) a b => f (g a) b) = λ g dg a b => ∂ f (g a) (dg a) b := by simp\n\nexample (f : Y₁ → β2 → Z) (g2 : α → β2) [IsSmooth f] (g dg)\n  : ∂ (λ  (g1 : α → Y₁) a => f (g1 a) (g2 a)) g dg = λ a => ∂ f (g a) (dg a) (g2 a) := by simp\n\nexample (f : β1 → Y₂ → Z) (g1 : α → β1) [∀ y1, IsSmooth (f y1)] \n  : ∂ (λ (g2 : α → Y₂) a => f (g1 a) (g2 a)) = λ g dg a => ∂ (f (g1 a)) (g a) (dg a) := by simp\n\n\nvariable (f : Y → Z) [IsSmooth f]\nvariable (g : X → Y) [IsSmooth g]\nvariable (f1 : X → X) [IsSmooth f1]\nvariable (f2 : Y → Y) [IsSmooth f2]\nvariable (f3 : Z → Z) [IsSmooth f3]\nvariable (F : X → Y → Z) [IsSmooth2 F]\nvariable (G : X × Y → Z) [IsSmooth G]\n\nvariable (x dx : X) (y dy : Y) (z dz : Z)\n\nexample : ∂ (λ x => f (g (f1 x))) x dx = ∂ f (g (f1 x)) (∂ g (f1 x) (∂ f1 x dx)) := by simp\n\nexample : ∂ (λ (x : X) => F x (g x)) x dx = ∂ F x dx (g x) + ∂ (F x) (g x) (∂ g x dx) := by simp\nexample : ∂ (λ (x : X) => f3 (F x (g x))) x dx = ∂ f3 (F x (g x)) (∂ F x dx (g x) + ∂ (F x) (g x) (∂ g x dx)) := by simp\nexample g dg x : ∂ (λ (g : X → Y) => f (g x)) g dg = ∂ f (g x) (dg x) := by simp\nexample g dg x : ∂ (λ (g : X → Y) (x : X) => F x (g x)) g dg x = ∂ (F x) (g x) (dg x) := by simp\n\n\n-- The following tests rely on `binop_chain_rule`\n\nexample g dg x : ∂ (λ (g : X → X) (y : Y) => F (g x) y) g dg y = ∂ F (g x) (dg x) y := by simp\nexample g dg y : ∂ (λ (g : X → X) (x : X) => F (g x) y) g dg x = ∂ F (g x) (dg x) y := by simp\n\nexample (r dr : ℝ) : ∂ (λ x : ℝ => x*x) r dr = dr * r + r * dr := by simp\nexample (r dr : ℝ) : ∂ (λ x : ℝ => x*x + x) r dr = dr * r + r * dr + dr := by simp\nexample (r dr : ℝ) : ∂ (λ x : ℝ => x*x*x + x) r dr = (dr * r + r * dr) * r + r * r * dr + dr := by simp\n\nexample (f : X → α → Y) [IsSmooth f] (a : α) (y : Y)\n  : ∂ (fun (x : X) => (f x a) + y)\n    =\n    λ x dx => ∂ f x dx a := by simp\n\nexample (f g : X → α → Y) [IsSmooth f] [IsSmooth g]\n  : ∂ (λ x a => f x a + g x a) \n    =\n    λ x dx a => ∂ f x dx a + ∂ g x dx a := by simp\n\nend differentiation_tests\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/StandaloneSymbolicDifferentiation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6723317123102955, "lm_q1q2_score": 0.47885629220535886}}
{"text": "/-\nCopyright (c) 2014 Robert Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn\n\n! This file was ported from Lean 3 source module algebra.order.field.basic\n! leanprover-community/mathlib commit acb3d204d4ee883eb686f45d486a2a6811a01329\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Bounds.OrderIso\nimport Mathbin.Algebra.Field.Basic\nimport Mathbin.Algebra.Order.Field.Defs\nimport Mathbin.Algebra.GroupPower.Order\n\n/-!\n# Lemmas about linear ordered (semi)fields\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n-/\n\n\nopen Function OrderDual\n\nvariable {ι α β : Type _}\n\nsection LinearOrderedSemifield\n\nvariable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ}\n\n/- warning: order_iso.mul_left₀ -> OrderIso.mulLeft₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (OrderIso.{u1, u1} α α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (OrderIso.{u1, u1} α α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align order_iso.mul_left₀ OrderIso.mulLeft₀ₓ'. -/\n/-- `equiv.mul_left₀` as an order_iso. -/\n@[simps (config := { simpRhs := true })]\ndef OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α :=\n  { Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := fun _ _ => mul_le_mul_left ha }\n#align order_iso.mul_left₀ OrderIso.mulLeft₀\n\n/- warning: order_iso.mul_right₀ -> OrderIso.mulRight₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (OrderIso.{u1, u1} α α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (OrderIso.{u1, u1} α α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align order_iso.mul_right₀ OrderIso.mulRight₀ₓ'. -/\n/-- `equiv.mul_right₀` as an order_iso. -/\n@[simps (config := { simpRhs := true })]\ndef OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α :=\n  { Equiv.mulRight₀ a ha.ne' with map_rel_iff' := fun _ _ => mul_le_mul_right ha }\n#align order_iso.mul_right₀ OrderIso.mulRight₀\n\n/-!\n### Lemmas about pos, nonneg, nonpos, neg\n-/\n\n\n/- warning: inv_pos -> inv_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align inv_pos inv_posₓ'. -/\n@[simp]\ntheorem inv_pos : 0 < a⁻¹ ↔ 0 < a :=\n  suffices ∀ a : α, 0 < a → 0 < a⁻¹ from ⟨fun h => inv_inv a ▸ this _ h, this a⟩\n  fun a ha => flip lt_of_mul_lt_mul_left ha.le <| by simp [ne_of_gt ha, zero_lt_one]\n#align inv_pos inv_pos\n\n/- warning: inv_pos_of_pos -> inv_pos_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align inv_pos_of_pos inv_pos_of_posₓ'. -/\nalias inv_pos ↔ _ inv_pos_of_pos\n#align inv_pos_of_pos inv_pos_of_pos\n\n/- warning: inv_nonneg -> inv_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align inv_nonneg inv_nonnegₓ'. -/\n@[simp]\ntheorem inv_nonneg : 0 ≤ a⁻¹ ↔ 0 ≤ a := by simp only [le_iff_eq_or_lt, inv_pos, zero_eq_inv]\n#align inv_nonneg inv_nonneg\n\n/- warning: inv_nonneg_of_nonneg -> inv_nonneg_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align inv_nonneg_of_nonneg inv_nonneg_of_nonnegₓ'. -/\nalias inv_nonneg ↔ _ inv_nonneg_of_nonneg\n#align inv_nonneg_of_nonneg inv_nonneg_of_nonneg\n\n/- warning: inv_lt_zero -> inv_lt_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align inv_lt_zero inv_lt_zeroₓ'. -/\n@[simp]\ntheorem inv_lt_zero : a⁻¹ < 0 ↔ a < 0 := by simp only [← not_le, inv_nonneg]\n#align inv_lt_zero inv_lt_zero\n\n/- warning: inv_nonpos -> inv_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align inv_nonpos inv_nonposₓ'. -/\n@[simp]\ntheorem inv_nonpos : a⁻¹ ≤ 0 ↔ a ≤ 0 := by simp only [← not_lt, inv_pos]\n#align inv_nonpos inv_nonpos\n\n/- warning: one_div_pos -> one_div_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align one_div_pos one_div_posₓ'. -/\ntheorem one_div_pos : 0 < 1 / a ↔ 0 < a :=\n  inv_eq_one_div a ▸ inv_pos\n#align one_div_pos one_div_pos\n\n/- warning: one_div_neg -> one_div_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_div_neg one_div_negₓ'. -/\ntheorem one_div_neg : 1 / a < 0 ↔ a < 0 :=\n  inv_eq_one_div a ▸ inv_lt_zero\n#align one_div_neg one_div_neg\n\n/- warning: one_div_nonneg -> one_div_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align one_div_nonneg one_div_nonnegₓ'. -/\ntheorem one_div_nonneg : 0 ≤ 1 / a ↔ 0 ≤ a :=\n  inv_eq_one_div a ▸ inv_nonneg\n#align one_div_nonneg one_div_nonneg\n\n/- warning: one_div_nonpos -> one_div_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_div_nonpos one_div_nonposₓ'. -/\ntheorem one_div_nonpos : 1 / a ≤ 0 ↔ a ≤ 0 :=\n  inv_eq_one_div a ▸ inv_nonpos\n#align one_div_nonpos one_div_nonpos\n\n/- warning: div_pos -> div_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_pos div_posₓ'. -/\ntheorem div_pos (ha : 0 < a) (hb : 0 < b) : 0 < a / b :=\n  by\n  rw [div_eq_mul_inv]\n  exact mul_pos ha (inv_pos.2 hb)\n#align div_pos div_pos\n\n/- warning: div_nonneg -> div_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_nonneg div_nonnegₓ'. -/\ntheorem div_nonneg (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a / b :=\n  by\n  rw [div_eq_mul_inv]\n  exact mul_nonneg ha (inv_nonneg.2 hb)\n#align div_nonneg div_nonneg\n\n/- warning: div_nonpos_of_nonpos_of_nonneg -> div_nonpos_of_nonpos_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align div_nonpos_of_nonpos_of_nonneg div_nonpos_of_nonpos_of_nonnegₓ'. -/\ntheorem div_nonpos_of_nonpos_of_nonneg (ha : a ≤ 0) (hb : 0 ≤ b) : a / b ≤ 0 :=\n  by\n  rw [div_eq_mul_inv]\n  exact mul_nonpos_of_nonpos_of_nonneg ha (inv_nonneg.2 hb)\n#align div_nonpos_of_nonpos_of_nonneg div_nonpos_of_nonpos_of_nonneg\n\n/- warning: div_nonpos_of_nonneg_of_nonpos -> div_nonpos_of_nonneg_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align div_nonpos_of_nonneg_of_nonpos div_nonpos_of_nonneg_of_nonposₓ'. -/\ntheorem div_nonpos_of_nonneg_of_nonpos (ha : 0 ≤ a) (hb : b ≤ 0) : a / b ≤ 0 :=\n  by\n  rw [div_eq_mul_inv]\n  exact mul_nonpos_of_nonneg_of_nonpos ha (inv_nonpos.2 hb)\n#align div_nonpos_of_nonneg_of_nonpos div_nonpos_of_nonneg_of_nonpos\n\n/- warning: zpow_nonneg -> zpow_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall (n : Int), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (forall (n : Int), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a n))\nCase conversion may be inaccurate. Consider using '#align zpow_nonneg zpow_nonnegₓ'. -/\ntheorem zpow_nonneg (ha : 0 ≤ a) : ∀ n : ℤ, 0 ≤ a ^ n\n  | (n : ℕ) => by\n    rw [zpow_ofNat]\n    exact pow_nonneg ha _\n  | -[n+1] => by\n    rw [zpow_negSucc]\n    exact inv_nonneg.2 (pow_nonneg ha _)\n#align zpow_nonneg zpow_nonneg\n\n/- warning: zpow_pos_of_pos -> zpow_pos_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall (n : Int), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (forall (n : Int), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Int α (instHPow.{u1, 0} α Int (DivInvMonoid.Pow.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a n))\nCase conversion may be inaccurate. Consider using '#align zpow_pos_of_pos zpow_pos_of_posₓ'. -/\ntheorem zpow_pos_of_pos (ha : 0 < a) : ∀ n : ℤ, 0 < a ^ n\n  | (n : ℕ) => by\n    rw [zpow_ofNat]\n    exact pow_pos ha _\n  | -[n+1] => by\n    rw [zpow_negSucc]\n    exact inv_pos.2 (pow_pos ha _)\n#align zpow_pos_of_pos zpow_pos_of_pos\n\n/-!\n### Relating one division with another term.\n-/\n\n\n/- warning: le_div_iff -> le_div_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a c) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align le_div_iff le_div_iffₓ'. -/\ntheorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b :=\n  ⟨fun h => div_mul_cancel b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h =>\n    calc\n      a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm\n      _ ≤ b * (1 / c) := (mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le)\n      _ = b / c := (div_eq_mul_one_div b c).symm\n      ⟩\n#align le_div_iff le_div_iff\n\n/- warning: le_div_iff' -> le_div_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c a) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align le_div_iff' le_div_iff'ₓ'. -/\ntheorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc]\n#align le_div_iff' le_div_iff'\n\n/- warning: div_le_iff -> div_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align div_le_iff div_le_iffₓ'. -/\ntheorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b :=\n  ⟨fun h =>\n    calc\n      a = a / b * b := by rw [div_mul_cancel _ (ne_of_lt hb).symm]\n      _ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le\n      ,\n    fun h =>\n    calc\n      a / b = a * (1 / b) := div_eq_mul_one_div a b\n      _ ≤ c * b * (1 / b) := (mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le)\n      _ = c * b / b := (div_eq_mul_one_div (c * b) b).symm\n      _ = c := by refine' (div_eq_iff (ne_of_gt hb)).mpr rfl\n      ⟩\n#align div_le_iff div_le_iff\n\n/- warning: div_le_iff' -> div_le_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align div_le_iff' div_le_iff'ₓ'. -/\ntheorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb]\n#align div_le_iff' div_le_iff'\n\n/- warning: lt_div_iff -> lt_div_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a c) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff lt_div_iffₓ'. -/\ntheorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b :=\n  lt_iff_lt_of_le_iff_le <| div_le_iff hc\n#align lt_div_iff lt_div_iff\n\n/- warning: lt_div_iff' -> lt_div_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c a) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff' lt_div_iff'ₓ'. -/\ntheorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by rw [mul_comm, lt_div_iff hc]\n#align lt_div_iff' lt_div_iff'\n\n/- warning: div_lt_iff -> div_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a c)))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff div_lt_iffₓ'. -/\ntheorem div_lt_iff (hc : 0 < c) : b / c < a ↔ b < a * c :=\n  lt_iff_lt_of_le_iff_le (le_div_iff hc)\n#align div_lt_iff div_lt_iff\n\n/- warning: div_lt_iff' -> div_lt_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c a)))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff' div_lt_iff'ₓ'. -/\ntheorem div_lt_iff' (hc : 0 < c) : b / c < a ↔ b < c * a := by rw [mul_comm, div_lt_iff hc]\n#align div_lt_iff' div_lt_iff'\n\n/- warning: inv_mul_le_iff -> inv_mul_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_le_iff inv_mul_le_iffₓ'. -/\ntheorem inv_mul_le_iff (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ b * c :=\n  by\n  rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div]\n  exact div_le_iff' h\n#align inv_mul_le_iff inv_mul_le_iff\n\n/- warning: inv_mul_le_iff' -> inv_mul_le_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_le_iff' inv_mul_le_iff'ₓ'. -/\ntheorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by rw [inv_mul_le_iff h, mul_comm]\n#align inv_mul_le_iff' inv_mul_le_iff'\n\n/- warning: mul_inv_le_iff -> mul_inv_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_le_iff mul_inv_le_iffₓ'. -/\ntheorem mul_inv_le_iff (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ b * c := by rw [mul_comm, inv_mul_le_iff h]\n#align mul_inv_le_iff mul_inv_le_iff\n\n/- warning: mul_inv_le_iff' -> mul_inv_le_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) c) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_le_iff' mul_inv_le_iff'ₓ'. -/\ntheorem mul_inv_le_iff' (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ c * b := by rw [mul_comm, inv_mul_le_iff' h]\n#align mul_inv_le_iff' mul_inv_le_iff'\n\n/- warning: div_self_le_one -> div_self_le_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align div_self_le_one div_self_le_oneₓ'. -/\ntheorem div_self_le_one (a : α) : a / a ≤ 1 :=\n  if h : a = 0 then by simp [h] else by simp [h]\n#align div_self_le_one div_self_le_one\n\n/- warning: inv_mul_lt_iff -> inv_mul_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_lt_iff inv_mul_lt_iffₓ'. -/\ntheorem inv_mul_lt_iff (h : 0 < b) : b⁻¹ * a < c ↔ a < b * c :=\n  by\n  rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div]\n  exact div_lt_iff' h\n#align inv_mul_lt_iff inv_mul_lt_iff\n\n/- warning: inv_mul_lt_iff' -> inv_mul_lt_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_lt_iff' inv_mul_lt_iff'ₓ'. -/\ntheorem inv_mul_lt_iff' (h : 0 < b) : b⁻¹ * a < c ↔ a < c * b := by rw [inv_mul_lt_iff h, mul_comm]\n#align inv_mul_lt_iff' inv_mul_lt_iff'\n\n/- warning: mul_inv_lt_iff -> mul_inv_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_lt_iff mul_inv_lt_iffₓ'. -/\ntheorem mul_inv_lt_iff (h : 0 < b) : a * b⁻¹ < c ↔ a < b * c := by rw [mul_comm, inv_mul_lt_iff h]\n#align mul_inv_lt_iff mul_inv_lt_iff\n\n/- warning: mul_inv_lt_iff' -> mul_inv_lt_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_lt_iff' mul_inv_lt_iff'ₓ'. -/\ntheorem mul_inv_lt_iff' (h : 0 < b) : a * b⁻¹ < c ↔ a < c * b := by rw [mul_comm, inv_mul_lt_iff' h]\n#align mul_inv_lt_iff' mul_inv_lt_iff'\n\n/- warning: inv_pos_le_iff_one_le_mul -> inv_pos_le_iff_one_le_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b a)))\nCase conversion may be inaccurate. Consider using '#align inv_pos_le_iff_one_le_mul inv_pos_le_iff_one_le_mulₓ'. -/\ntheorem inv_pos_le_iff_one_le_mul (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ b * a :=\n  by\n  rw [inv_eq_one_div]\n  exact div_le_iff ha\n#align inv_pos_le_iff_one_le_mul inv_pos_le_iff_one_le_mul\n\n/- warning: inv_pos_le_iff_one_le_mul' -> inv_pos_le_iff_one_le_mul' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a b)))\nCase conversion may be inaccurate. Consider using '#align inv_pos_le_iff_one_le_mul' inv_pos_le_iff_one_le_mul'ₓ'. -/\ntheorem inv_pos_le_iff_one_le_mul' (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ a * b :=\n  by\n  rw [inv_eq_one_div]\n  exact div_le_iff' ha\n#align inv_pos_le_iff_one_le_mul' inv_pos_le_iff_one_le_mul'\n\n/- warning: inv_pos_lt_iff_one_lt_mul -> inv_pos_lt_iff_one_lt_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b a)))\nCase conversion may be inaccurate. Consider using '#align inv_pos_lt_iff_one_lt_mul inv_pos_lt_iff_one_lt_mulₓ'. -/\ntheorem inv_pos_lt_iff_one_lt_mul (ha : 0 < a) : a⁻¹ < b ↔ 1 < b * a :=\n  by\n  rw [inv_eq_one_div]\n  exact div_lt_iff ha\n#align inv_pos_lt_iff_one_lt_mul inv_pos_lt_iff_one_lt_mul\n\n/- warning: inv_pos_lt_iff_one_lt_mul' -> inv_pos_lt_iff_one_lt_mul' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a b)))\nCase conversion may be inaccurate. Consider using '#align inv_pos_lt_iff_one_lt_mul' inv_pos_lt_iff_one_lt_mul'ₓ'. -/\ntheorem inv_pos_lt_iff_one_lt_mul' (ha : 0 < a) : a⁻¹ < b ↔ 1 < a * b :=\n  by\n  rw [inv_eq_one_div]\n  exact div_lt_iff' ha\n#align inv_pos_lt_iff_one_lt_mul' inv_pos_lt_iff_one_lt_mul'\n\n/- warning: div_le_of_nonneg_of_le_mul -> div_le_of_nonneg_of_le_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) c)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) c)\nCase conversion may be inaccurate. Consider using '#align div_le_of_nonneg_of_le_mul div_le_of_nonneg_of_le_mulₓ'. -/\n/-- One direction of `div_le_iff` where `b` is allowed to be `0` (but `c` must be nonnegative) -/\ntheorem div_le_of_nonneg_of_le_mul (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ c * b) : a / b ≤ c :=\n  by\n  rcases eq_or_lt_of_le hb with (rfl | hb')\n  simp [hc]\n  rwa [div_le_iff hb']\n#align div_le_of_nonneg_of_le_mul div_le_of_nonneg_of_le_mul\n\n/- warning: mul_le_of_nonneg_of_le_div -> mul_le_of_nonneg_of_le_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a c) b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a c) b)\nCase conversion may be inaccurate. Consider using '#align mul_le_of_nonneg_of_le_div mul_le_of_nonneg_of_le_divₓ'. -/\n/-- One direction of `div_le_iff` where `c` is allowed to be `0` (but `b` must be nonnegative) -/\ntheorem mul_le_of_nonneg_of_le_div (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ b / c) : a * c ≤ b :=\n  by\n  obtain rfl | hc := hc.eq_or_lt\n  · simpa using hb\n  · rwa [le_div_iff hc] at h\n#align mul_le_of_nonneg_of_le_div mul_le_of_nonneg_of_le_div\n\n/- warning: div_le_one_of_le -> div_le_one_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align div_le_one_of_le div_le_one_of_leₓ'. -/\ntheorem div_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a / b ≤ 1 :=\n  div_le_of_nonneg_of_le_mul hb zero_le_one <| by rwa [one_mul]\n#align div_le_one_of_le div_le_one_of_le\n\n/-!\n### Bi-implications of inequalities using inversions\n-/\n\n\n/- warning: inv_le_inv_of_le -> inv_le_inv_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align inv_le_inv_of_le inv_le_inv_of_leₓ'. -/\ntheorem inv_le_inv_of_le (ha : 0 < a) (h : a ≤ b) : b⁻¹ ≤ a⁻¹ := by\n  rwa [← one_div a, le_div_iff' ha, ← div_eq_mul_inv, div_le_iff (ha.trans_le h), one_mul]\n#align inv_le_inv_of_le inv_le_inv_of_le\n\n/- warning: inv_le_inv -> inv_le_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_le_inv inv_le_invₓ'. -/\n/-- See `inv_le_inv_of_le` for the implication from right-to-left with one fewer assumption. -/\ntheorem inv_le_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := by\n  rw [← one_div, div_le_iff ha, ← div_eq_inv_mul, le_div_iff hb, one_mul]\n#align inv_le_inv inv_le_inv\n\n/- warning: inv_le -> inv_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_le inv_leₓ'. -/\n/-- In a linear ordered field, for positive `a` and `b` we have `a⁻¹ ≤ b ↔ b⁻¹ ≤ a`.\nSee also `inv_le_of_inv_le` for a one-sided implication with one fewer assumption. -/\ntheorem inv_le (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by\n  rw [← inv_le_inv hb (inv_pos.2 ha), inv_inv]\n#align inv_le inv_le\n\n/- warning: inv_le_of_inv_le -> inv_le_of_inv_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a)\nCase conversion may be inaccurate. Consider using '#align inv_le_of_inv_le inv_le_of_inv_leₓ'. -/\ntheorem inv_le_of_inv_le (ha : 0 < a) (h : a⁻¹ ≤ b) : b⁻¹ ≤ a :=\n  (inv_le ha ((inv_pos.2 ha).trans_le h)).1 h\n#align inv_le_of_inv_le inv_le_of_inv_le\n\n/- warning: le_inv -> le_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align le_inv le_invₓ'. -/\ntheorem le_inv (ha : 0 < a) (hb : 0 < b) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by\n  rw [← inv_le_inv (inv_pos.2 hb) ha, inv_inv]\n#align le_inv le_inv\n\n/- warning: inv_lt_inv -> inv_lt_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_inv inv_lt_invₓ'. -/\n/-- See `inv_lt_inv_of_lt` for the implication from right-to-left with one fewer assumption. -/\ntheorem inv_lt_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b⁻¹ ↔ b < a :=\n  lt_iff_lt_of_le_iff_le (inv_le_inv hb ha)\n#align inv_lt_inv inv_lt_inv\n\n/- warning: inv_lt_inv_of_lt -> inv_lt_inv_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b))\nCase conversion may be inaccurate. Consider using '#align inv_lt_inv_of_lt inv_lt_inv_of_ltₓ'. -/\ntheorem inv_lt_inv_of_lt (hb : 0 < b) (h : b < a) : a⁻¹ < b⁻¹ :=\n  (inv_lt_inv (hb.trans h) hb).2 h\n#align inv_lt_inv_of_lt inv_lt_inv_of_lt\n\n/- warning: inv_lt -> inv_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt inv_ltₓ'. -/\n/-- In a linear ordered field, for positive `a` and `b` we have `a⁻¹ < b ↔ b⁻¹ < a`.\nSee also `inv_lt_of_inv_lt` for a one-sided implication with one fewer assumption. -/\ntheorem inv_lt (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b ↔ b⁻¹ < a :=\n  lt_iff_lt_of_le_iff_le (le_inv hb ha)\n#align inv_lt inv_lt\n\n/- warning: inv_lt_of_inv_lt -> inv_lt_of_inv_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b) a)\nCase conversion may be inaccurate. Consider using '#align inv_lt_of_inv_lt inv_lt_of_inv_ltₓ'. -/\ntheorem inv_lt_of_inv_lt (ha : 0 < a) (h : a⁻¹ < b) : b⁻¹ < a :=\n  (inv_lt ha ((inv_pos.2 ha).trans h)).1 h\n#align inv_lt_of_inv_lt inv_lt_of_inv_lt\n\n/- warning: lt_inv -> lt_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align lt_inv lt_invₓ'. -/\ntheorem lt_inv (ha : 0 < a) (hb : 0 < b) : a < b⁻¹ ↔ b < a⁻¹ :=\n  lt_iff_lt_of_le_iff_le (inv_le hb ha)\n#align lt_inv lt_inv\n\n/- warning: inv_lt_one -> inv_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align inv_lt_one inv_lt_oneₓ'. -/\ntheorem inv_lt_one (ha : 1 < a) : a⁻¹ < 1 := by\n  rwa [inv_lt (zero_lt_one.trans ha) zero_lt_one, inv_one]\n#align inv_lt_one inv_lt_one\n\n/- warning: one_lt_inv -> one_lt_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align one_lt_inv one_lt_invₓ'. -/\ntheorem one_lt_inv (h₁ : 0 < a) (h₂ : a < 1) : 1 < a⁻¹ := by rwa [lt_inv zero_lt_one h₁, inv_one]\n#align one_lt_inv one_lt_inv\n\n/- warning: inv_le_one -> inv_le_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align inv_le_one inv_le_oneₓ'. -/\ntheorem inv_le_one (ha : 1 ≤ a) : a⁻¹ ≤ 1 := by\n  rwa [inv_le (zero_lt_one.trans_le ha) zero_lt_one, inv_one]\n#align inv_le_one inv_le_one\n\n/- warning: one_le_inv -> one_le_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align one_le_inv one_le_invₓ'. -/\ntheorem one_le_inv (h₁ : 0 < a) (h₂ : a ≤ 1) : 1 ≤ a⁻¹ := by rwa [le_inv zero_lt_one h₁, inv_one]\n#align one_le_inv one_le_inv\n\n/- warning: inv_lt_one_iff_of_pos -> inv_lt_one_iff_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_one_iff_of_pos inv_lt_one_iff_of_posₓ'. -/\ntheorem inv_lt_one_iff_of_pos (h₀ : 0 < a) : a⁻¹ < 1 ↔ 1 < a :=\n  ⟨fun h₁ => inv_inv a ▸ one_lt_inv (inv_pos.2 h₀) h₁, inv_lt_one⟩\n#align inv_lt_one_iff_of_pos inv_lt_one_iff_of_pos\n\n/- warning: inv_lt_one_iff -> inv_lt_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (Or (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (Or (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_one_iff inv_lt_one_iffₓ'. -/\ntheorem inv_lt_one_iff : a⁻¹ < 1 ↔ a ≤ 0 ∨ 1 < a :=\n  by\n  cases' le_or_lt a 0 with ha ha\n  · simp [ha, (inv_nonpos.2 ha).trans_lt zero_lt_one]\n  · simp only [ha.not_le, false_or_iff, inv_lt_one_iff_of_pos ha]\n#align inv_lt_one_iff inv_lt_one_iff\n\n/- warning: one_lt_inv_iff -> one_lt_inv_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align one_lt_inv_iff one_lt_inv_iffₓ'. -/\ntheorem one_lt_inv_iff : 1 < a⁻¹ ↔ 0 < a ∧ a < 1 :=\n  ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans h), inv_inv a ▸ inv_lt_one h⟩, and_imp.2 one_lt_inv⟩\n#align one_lt_inv_iff one_lt_inv_iff\n\n/- warning: inv_le_one_iff -> inv_le_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (Or (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (Or (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align inv_le_one_iff inv_le_one_iffₓ'. -/\ntheorem inv_le_one_iff : a⁻¹ ≤ 1 ↔ a ≤ 0 ∨ 1 ≤ a :=\n  by\n  rcases em (a = 1) with (rfl | ha)\n  · simp [le_rfl]\n  · simp only [Ne.le_iff_lt (Ne.symm ha), Ne.le_iff_lt (mt inv_eq_one.1 ha), inv_lt_one_iff]\n#align inv_le_one_iff inv_le_one_iff\n\n/- warning: one_le_inv_iff -> one_le_inv_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align one_le_inv_iff one_le_inv_iffₓ'. -/\ntheorem one_le_inv_iff : 1 ≤ a⁻¹ ↔ 0 < a ∧ a ≤ 1 :=\n  ⟨fun h => ⟨inv_pos.1 (zero_lt_one.trans_le h), inv_inv a ▸ inv_le_one h⟩, and_imp.2 one_le_inv⟩\n#align one_le_inv_iff one_le_inv_iff\n\n/-!\n### Relating two divisions.\n-/\n\n\n/- warning: div_le_div_of_le -> div_le_div_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align div_le_div_of_le div_le_div_of_leₓ'. -/\n@[mono]\ntheorem div_le_div_of_le (hc : 0 ≤ c) (h : a ≤ b) : a / c ≤ b / c :=\n  by\n  rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c]\n  exact mul_le_mul_of_nonneg_right h (one_div_nonneg.2 hc)\n#align div_le_div_of_le div_le_div_of_le\n\n/- warning: div_le_div_of_le_left -> div_le_div_of_le_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) c b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) c b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c))\nCase conversion may be inaccurate. Consider using '#align div_le_div_of_le_left div_le_div_of_le_leftₓ'. -/\n-- Not a `mono` lemma b/c `div_le_div` is strictly more general\ntheorem div_le_div_of_le_left (ha : 0 ≤ a) (hc : 0 < c) (h : c ≤ b) : a / b ≤ a / c :=\n  by\n  rw [div_eq_mul_inv, div_eq_mul_inv]\n  exact mul_le_mul_of_nonneg_left ((inv_le_inv (hc.trans_le h) hc).mpr h) ha\n#align div_le_div_of_le_left div_le_div_of_le_left\n\n/- warning: div_le_div_of_le_of_nonneg -> div_le_div_of_le_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align div_le_div_of_le_of_nonneg div_le_div_of_le_of_nonnegₓ'. -/\ntheorem div_le_div_of_le_of_nonneg (hab : a ≤ b) (hc : 0 ≤ c) : a / c ≤ b / c :=\n  div_le_div_of_le hc hab\n#align div_le_div_of_le_of_nonneg div_le_div_of_le_of_nonneg\n\n/- warning: div_lt_div_of_lt -> div_lt_div_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_of_lt div_lt_div_of_ltₓ'. -/\ntheorem div_lt_div_of_lt (hc : 0 < c) (h : a < b) : a / c < b / c :=\n  by\n  rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c]\n  exact mul_lt_mul_of_pos_right h (one_div_pos.2 hc)\n#align div_lt_div_of_lt div_lt_div_of_lt\n\n/- warning: div_le_div_right -> div_le_div_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_le_div_right div_le_div_rightₓ'. -/\ntheorem div_le_div_right (hc : 0 < c) : a / c ≤ b / c ↔ a ≤ b :=\n  ⟨le_imp_le_of_lt_imp_lt <| div_lt_div_of_lt hc, div_le_div_of_le <| hc.le⟩\n#align div_le_div_right div_le_div_right\n\n/- warning: div_lt_div_right -> div_lt_div_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_right div_lt_div_rightₓ'. -/\ntheorem div_lt_div_right (hc : 0 < c) : a / c < b / c ↔ a < b :=\n  lt_iff_lt_of_le_iff_le <| div_le_div_right hc\n#align div_lt_div_right div_lt_div_right\n\n/- warning: div_lt_div_left -> div_lt_div_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) c b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) c b))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_left div_lt_div_leftₓ'. -/\ntheorem div_lt_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b < a / c ↔ c < b := by\n  simp only [div_eq_mul_inv, mul_lt_mul_left ha, inv_lt_inv hb hc]\n#align div_lt_div_left div_lt_div_left\n\n/- warning: div_le_div_left -> div_le_div_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) c b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) c b))\nCase conversion may be inaccurate. Consider using '#align div_le_div_left div_le_div_leftₓ'. -/\ntheorem div_le_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b ≤ a / c ↔ c ≤ b :=\n  le_iff_le_iff_lt_iff_lt.2 (div_lt_div_left ha hc hb)\n#align div_le_div_left div_le_div_left\n\n/- warning: div_lt_div_iff -> div_lt_div_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) d) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c d)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) d) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c d)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_iff div_lt_div_iffₓ'. -/\ntheorem div_lt_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b < c / d ↔ a * d < c * b := by\n  rw [lt_div_iff d0, div_mul_eq_mul_div, div_lt_iff b0]\n#align div_lt_div_iff div_lt_div_iff\n\n/- warning: div_le_div_iff -> div_le_div_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) d) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c d)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) d) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c d)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align div_le_div_iff div_le_div_iffₓ'. -/\ntheorem div_le_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b ≤ c / d ↔ a * d ≤ c * b := by\n  rw [le_div_iff d0, div_mul_eq_mul_div, div_le_iff b0]\n#align div_le_div_iff div_le_div_iff\n\n/- warning: div_le_div -> div_le_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) d) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) d b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c d))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) d) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) d b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c d))\nCase conversion may be inaccurate. Consider using '#align div_le_div div_le_divₓ'. -/\n@[mono]\ntheorem div_le_div (hc : 0 ≤ c) (hac : a ≤ c) (hd : 0 < d) (hbd : d ≤ b) : a / b ≤ c / d :=\n  by\n  rw [div_le_div_iff (hd.trans_le hbd) hd]\n  exact mul_le_mul hac hbd hd.le hc\n#align div_le_div div_le_div\n\n/- warning: div_lt_div -> div_lt_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) d b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) d) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c d))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) d b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) d) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c d))\nCase conversion may be inaccurate. Consider using '#align div_lt_div div_lt_divₓ'. -/\ntheorem div_lt_div (hac : a < c) (hbd : d ≤ b) (c0 : 0 ≤ c) (d0 : 0 < d) : a / b < c / d :=\n  (div_lt_div_iff (d0.trans_le hbd) d0).2 (mul_lt_mul hac hbd d0 c0)\n#align div_lt_div div_lt_div\n\n/- warning: div_lt_div' -> div_lt_div' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) d b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) d) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c d))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) d b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) d) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c d))\nCase conversion may be inaccurate. Consider using '#align div_lt_div' div_lt_div'ₓ'. -/\ntheorem div_lt_div' (hac : a ≤ c) (hbd : d < b) (c0 : 0 < c) (d0 : 0 < d) : a / b < c / d :=\n  (div_lt_div_iff (d0.trans hbd) d0).2 (mul_lt_mul' hac hbd d0.le c0)\n#align div_lt_div' div_lt_div'\n\n/- warning: div_lt_div_of_lt_left -> div_lt_div_of_lt_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c b))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_of_lt_left div_lt_div_of_lt_leftₓ'. -/\ntheorem div_lt_div_of_lt_left (hc : 0 < c) (hb : 0 < b) (h : b < a) : c / a < c / b :=\n  (div_lt_div_left hc (hb.trans h) hb).mpr h\n#align div_lt_div_of_lt_left div_lt_div_of_lt_left\n\n/-!\n### Relating one division and involving `1`\n-/\n\n\n/- warning: div_le_self -> div_le_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) a)\nCase conversion may be inaccurate. Consider using '#align div_le_self div_le_selfₓ'. -/\ntheorem div_le_self (ha : 0 ≤ a) (hb : 1 ≤ b) : a / b ≤ a := by\n  simpa only [div_one] using div_le_div_of_le_left ha zero_lt_one hb\n#align div_le_self div_le_self\n\n/- warning: div_lt_self -> div_lt_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) a)\nCase conversion may be inaccurate. Consider using '#align div_lt_self div_lt_selfₓ'. -/\ntheorem div_lt_self (ha : 0 < a) (hb : 1 < b) : a / b < a := by\n  simpa only [div_one] using div_lt_div_of_lt_left ha zero_lt_one hb\n#align div_lt_self div_lt_self\n\n/- warning: le_div_self -> le_div_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align le_div_self le_div_selfₓ'. -/\ntheorem le_div_self (ha : 0 ≤ a) (hb₀ : 0 < b) (hb₁ : b ≤ 1) : a ≤ a / b := by\n  simpa only [div_one] using div_le_div_of_le_left ha hb₀ hb₁\n#align le_div_self le_div_self\n\n/- warning: one_le_div -> one_le_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_le_div one_le_divₓ'. -/\ntheorem one_le_div (hb : 0 < b) : 1 ≤ a / b ↔ b ≤ a := by rw [le_div_iff hb, one_mul]\n#align one_le_div one_le_div\n\n/- warning: div_le_one -> div_le_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_le_one div_le_oneₓ'. -/\ntheorem div_le_one (hb : 0 < b) : a / b ≤ 1 ↔ a ≤ b := by rw [div_le_iff hb, one_mul]\n#align div_le_one div_le_one\n\n/- warning: one_lt_div -> one_lt_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_lt_div one_lt_divₓ'. -/\ntheorem one_lt_div (hb : 0 < b) : 1 < a / b ↔ b < a := by rw [lt_div_iff hb, one_mul]\n#align one_lt_div one_lt_div\n\n/- warning: div_lt_one -> div_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_lt_one div_lt_oneₓ'. -/\ntheorem div_lt_one (hb : 0 < b) : a / b < 1 ↔ a < b := by rw [div_lt_iff hb, one_mul]\n#align div_lt_one div_lt_one\n\n/- warning: one_div_le -> one_div_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_le one_div_leₓ'. -/\ntheorem one_div_le (ha : 0 < a) (hb : 0 < b) : 1 / a ≤ b ↔ 1 / b ≤ a := by simpa using inv_le ha hb\n#align one_div_le one_div_le\n\n/- warning: one_div_lt -> one_div_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt one_div_ltₓ'. -/\ntheorem one_div_lt (ha : 0 < a) (hb : 0 < b) : 1 / a < b ↔ 1 / b < a := by simpa using inv_lt ha hb\n#align one_div_lt one_div_lt\n\n/- warning: le_one_div -> le_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a)))\nCase conversion may be inaccurate. Consider using '#align le_one_div le_one_divₓ'. -/\ntheorem le_one_div (ha : 0 < a) (hb : 0 < b) : a ≤ 1 / b ↔ b ≤ 1 / a := by simpa using le_inv ha hb\n#align le_one_div le_one_div\n\n/- warning: lt_one_div -> lt_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a)))\nCase conversion may be inaccurate. Consider using '#align lt_one_div lt_one_divₓ'. -/\ntheorem lt_one_div (ha : 0 < a) (hb : 0 < b) : a < 1 / b ↔ b < 1 / a := by simpa using lt_inv ha hb\n#align lt_one_div lt_one_div\n\n/-!\n### Relating two divisions, involving `1`\n-/\n\n\n/- warning: one_div_le_one_div_of_le -> one_div_le_one_div_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_div_le_one_div_of_le one_div_le_one_div_of_leₓ'. -/\ntheorem one_div_le_one_div_of_le (ha : 0 < a) (h : a ≤ b) : 1 / b ≤ 1 / a := by\n  simpa using inv_le_inv_of_le ha h\n#align one_div_le_one_div_of_le one_div_le_one_div_of_le\n\n/- warning: one_div_lt_one_div_of_lt -> one_div_lt_one_div_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_one_div_of_lt one_div_lt_one_div_of_ltₓ'. -/\ntheorem one_div_lt_one_div_of_lt (ha : 0 < a) (h : a < b) : 1 / b < 1 / a := by\n  rwa [lt_div_iff' ha, ← div_eq_mul_one_div, div_lt_one (ha.trans h)]\n#align one_div_lt_one_div_of_lt one_div_lt_one_div_of_lt\n\n/- warning: le_of_one_div_le_one_div -> le_of_one_div_le_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a)\nCase conversion may be inaccurate. Consider using '#align le_of_one_div_le_one_div le_of_one_div_le_one_divₓ'. -/\ntheorem le_of_one_div_le_one_div (ha : 0 < a) (h : 1 / a ≤ 1 / b) : b ≤ a :=\n  le_imp_le_of_lt_imp_lt (one_div_lt_one_div_of_lt ha) h\n#align le_of_one_div_le_one_div le_of_one_div_le_one_div\n\n/- warning: lt_of_one_div_lt_one_div -> lt_of_one_div_lt_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b)) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b)) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a)\nCase conversion may be inaccurate. Consider using '#align lt_of_one_div_lt_one_div lt_of_one_div_lt_one_divₓ'. -/\ntheorem lt_of_one_div_lt_one_div (ha : 0 < a) (h : 1 / a < 1 / b) : b < a :=\n  lt_imp_lt_of_le_imp_le (one_div_le_one_div_of_le ha) h\n#align lt_of_one_div_lt_one_div lt_of_one_div_lt_one_div\n\n/- warning: one_div_le_one_div -> one_div_le_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_div_le_one_div one_div_le_one_divₓ'. -/\n/-- For the single implications with fewer assumptions, see `one_div_le_one_div_of_le` and\n  `le_of_one_div_le_one_div` -/\ntheorem one_div_le_one_div (ha : 0 < a) (hb : 0 < b) : 1 / a ≤ 1 / b ↔ b ≤ a :=\n  div_le_div_left zero_lt_one ha hb\n#align one_div_le_one_div one_div_le_one_div\n\n/- warning: one_div_lt_one_div -> one_div_lt_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_one_div one_div_lt_one_divₓ'. -/\n/-- For the single implications with fewer assumptions, see `one_div_lt_one_div_of_lt` and\n  `lt_of_one_div_lt_one_div` -/\ntheorem one_div_lt_one_div (ha : 0 < a) (hb : 0 < b) : 1 / a < 1 / b ↔ b < a :=\n  div_lt_div_left zero_lt_one ha hb\n#align one_div_lt_one_div one_div_lt_one_div\n\n/- warning: one_lt_one_div -> one_lt_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_lt_one_div one_lt_one_divₓ'. -/\ntheorem one_lt_one_div (h1 : 0 < a) (h2 : a < 1) : 1 < 1 / a := by\n  rwa [lt_one_div zero_lt_one h1, one_div_one]\n#align one_lt_one_div one_lt_one_div\n\n/- warning: one_le_one_div -> one_le_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_le_one_div one_le_one_divₓ'. -/\ntheorem one_le_one_div (h1 : 0 < a) (h2 : a ≤ 1) : 1 ≤ 1 / a := by\n  rwa [le_one_div zero_lt_one h1, one_div_one]\n#align one_le_one_div one_le_one_div\n\n/-!\n### Results about halving.\n\nThe equalities also hold in semifields of characteristic `0`.\n-/\n\n\n/- warning: add_halves -> add_halves is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))))) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), Eq.{succ u1} α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) a\nCase conversion may be inaccurate. Consider using '#align add_halves add_halvesₓ'. -/\n/- TODO: Unify `add_halves` and `add_halves'` into a single lemma about\n`division_semiring` + `char_zero` -/\ntheorem add_halves (a : α) : a / 2 + a / 2 = a := by\n  rw [div_add_div_same, ← two_mul, mul_div_cancel_left a two_ne_zero]\n#align add_halves add_halves\n\n/- warning: add_self_div_two -> add_self_div_two is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), Eq.{succ u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a a) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (a : α), Eq.{succ u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a a) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) a\nCase conversion may be inaccurate. Consider using '#align add_self_div_two add_self_div_twoₓ'. -/\n-- TODO: Generalize to `division_semiring`\ntheorem add_self_div_two (a : α) : (a + a) / 2 = a := by\n  rw [← mul_two, mul_div_cancel a two_ne_zero]\n#align add_self_div_two add_self_div_two\n\n/- warning: half_pos -> half_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))\nCase conversion may be inaccurate. Consider using '#align half_pos half_posₓ'. -/\ntheorem half_pos (h : 0 < a) : 0 < a / 2 :=\n  div_pos h zero_lt_two\n#align half_pos half_pos\n\n/- warning: one_half_pos -> one_half_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))\nCase conversion may be inaccurate. Consider using '#align one_half_pos one_half_posₓ'. -/\ntheorem one_half_pos : (0 : α) < 1 / 2 :=\n  half_pos zero_lt_one\n#align one_half_pos one_half_pos\n\n/- warning: div_two_lt_of_pos -> div_two_lt_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) a)\nCase conversion may be inaccurate. Consider using '#align div_two_lt_of_pos div_two_lt_of_posₓ'. -/\ntheorem div_two_lt_of_pos (h : 0 < a) : a / 2 < a :=\n  by\n  rw [div_lt_iff (zero_lt_two' α)]\n  exact lt_mul_of_one_lt_right h one_lt_two\n#align div_two_lt_of_pos div_two_lt_of_pos\n\n/- warning: half_lt_self -> half_lt_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) a)\nCase conversion may be inaccurate. Consider using '#align half_lt_self half_lt_selfₓ'. -/\ntheorem half_lt_self : 0 < a → a / 2 < a :=\n  div_two_lt_of_pos\n#align half_lt_self half_lt_self\n\n/- warning: half_le_self -> half_le_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) a)\nCase conversion may be inaccurate. Consider using '#align half_le_self half_le_selfₓ'. -/\ntheorem half_le_self (ha_nonneg : 0 ≤ a) : a / 2 ≤ a :=\n  by\n  by_cases h0 : a = 0\n  · simp [h0]\n  · rw [← Ne.def] at h0\n    exact (half_lt_self (lt_of_le_of_ne ha_nonneg h0.symm)).le\n#align half_le_self half_le_self\n\n/- warning: one_half_lt_one -> one_half_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_half_lt_one one_half_lt_oneₓ'. -/\ntheorem one_half_lt_one : (1 / 2 : α) < 1 :=\n  half_lt_self zero_lt_one\n#align one_half_lt_one one_half_lt_one\n\n/- warning: two_inv_lt_one -> two_inv_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align two_inv_lt_one two_inv_lt_oneₓ'. -/\ntheorem two_inv_lt_one : (2⁻¹ : α) < 1 :=\n  (one_div _).symm.trans_lt one_half_lt_one\n#align two_inv_lt_one two_inv_lt_one\n\n/- warning: left_lt_add_div_two -> left_lt_add_div_two is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b)\nCase conversion may be inaccurate. Consider using '#align left_lt_add_div_two left_lt_add_div_twoₓ'. -/\ntheorem left_lt_add_div_two : a < (a + b) / 2 ↔ a < b := by simp [lt_div_iff, mul_two]\n#align left_lt_add_div_two left_lt_add_div_two\n\n/- warning: add_div_two_lt_right -> add_div_two_lt_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) a b)\nCase conversion may be inaccurate. Consider using '#align add_div_two_lt_right add_div_two_lt_rightₓ'. -/\ntheorem add_div_two_lt_right : (a + b) / 2 < b ↔ a < b := by simp [div_lt_iff, mul_two]\n#align add_div_two_lt_right add_div_two_lt_right\n\n/-!\n### Miscellaneous lemmas\n-/\n\n\n/- warning: mul_le_mul_of_mul_div_le -> mul_le_mul_of_mul_div_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) d) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) d c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) d) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) d c))\nCase conversion may be inaccurate. Consider using '#align mul_le_mul_of_mul_div_le mul_le_mul_of_mul_div_leₓ'. -/\ntheorem mul_le_mul_of_mul_div_le (h : a * (b / c) ≤ d) (hc : 0 < c) : b * a ≤ d * c :=\n  by\n  rw [← mul_div_assoc] at h\n  rwa [mul_comm b, ← div_le_iff hc]\n#align mul_le_mul_of_mul_div_le mul_le_mul_of_mul_div_le\n\n/- warning: div_mul_le_div_mul_of_div_le_div -> div_mul_le_div_mul_of_div_le_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α} {e : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c d)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) e) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b e)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) d e)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {c : α} {d : α} {e : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c d)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) e) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b e)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) c (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) d e)))\nCase conversion may be inaccurate. Consider using '#align div_mul_le_div_mul_of_div_le_div div_mul_le_div_mul_of_div_le_divₓ'. -/\ntheorem div_mul_le_div_mul_of_div_le_div (h : a / b ≤ c / d) (he : 0 ≤ e) :\n    a / (b * e) ≤ c / (d * e) :=\n  by\n  rw [div_mul_eq_div_mul_one_div, div_mul_eq_div_mul_one_div]\n  exact mul_le_mul_of_nonneg_right h (one_div_nonneg.2 he)\n#align div_mul_le_div_mul_of_div_le_div div_mul_le_div_mul_of_div_le_div\n\n/- warning: exists_pos_mul_lt -> exists_pos_mul_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall (b : α), Exists.{succ u1} α (fun (c : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b c) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (forall (b : α), Exists.{succ u1} α (fun (c : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b c) a)))\nCase conversion may be inaccurate. Consider using '#align exists_pos_mul_lt exists_pos_mul_ltₓ'. -/\ntheorem exists_pos_mul_lt {a : α} (h : 0 < a) (b : α) : ∃ c : α, 0 < c ∧ b * c < a :=\n  by\n  have : 0 < a / max (b + 1) 1 := div_pos h (lt_max_iff.2 (Or.inr zero_lt_one))\n  refine' ⟨a / max (b + 1) 1, this, _⟩\n  rw [← lt_div_iff this, div_div_cancel' h.ne']\n  exact lt_max_iff.2 (Or.inl <| lt_add_one _)\n#align exists_pos_mul_lt exists_pos_mul_lt\n\n/- warning: exists_pos_lt_mul -> exists_pos_lt_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall (b : α), Exists.{succ u1} α (fun (c : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) c a))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (forall (b : α), Exists.{succ u1} α (fun (c : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) c a))))\nCase conversion may be inaccurate. Consider using '#align exists_pos_lt_mul exists_pos_lt_mulₓ'. -/\ntheorem exists_pos_lt_mul {a : α} (h : 0 < a) (b : α) : ∃ c : α, 0 < c ∧ b < c * a :=\n  let ⟨c, hc₀, hc⟩ := exists_pos_mul_lt h b\n  ⟨c⁻¹, inv_pos.2 hc₀, by rwa [← div_eq_inv_mul, lt_div_iff hc₀]⟩\n#align exists_pos_lt_mul exists_pos_lt_mul\n\n/- warning: monotone.div_const -> Monotone.div_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {β : Type.{u2}} [_inst_2 : Preorder.{u2} β] {f : β -> α}, (Monotone.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) f) -> (forall {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (Monotone.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (x : β) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (f x) c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {β : Type.{u2}} [_inst_2 : Preorder.{u2} β] {f : β -> α}, (Monotone.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) f) -> (forall {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (Monotone.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (x : β) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (f x) c)))\nCase conversion may be inaccurate. Consider using '#align monotone.div_const Monotone.div_constₓ'. -/\ntheorem Monotone.div_const {β : Type _} [Preorder β] {f : β → α} (hf : Monotone f) {c : α}\n    (hc : 0 ≤ c) : Monotone fun x => f x / c :=\n  by\n  haveI := @LinearOrder.decidableLe α _\n  simpa only [div_eq_mul_inv] using (monotone_mul_right_of_nonneg (inv_nonneg.2 hc)).comp hf\n#align monotone.div_const Monotone.div_const\n\n/- warning: strict_mono.div_const -> StrictMono.div_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {β : Type.{u2}} [_inst_2 : Preorder.{u2} β] {f : β -> α}, (StrictMono.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) f) -> (forall {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (StrictMono.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (x : β) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (f x) c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {β : Type.{u2}} [_inst_2 : Preorder.{u2} β] {f : β -> α}, (StrictMono.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) f) -> (forall {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (StrictMono.{u2, u1} β α _inst_2 (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (x : β) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (f x) c)))\nCase conversion may be inaccurate. Consider using '#align strict_mono.div_const StrictMono.div_constₓ'. -/\ntheorem StrictMono.div_const {β : Type _} [Preorder β] {f : β → α} (hf : StrictMono f) {c : α}\n    (hc : 0 < c) : StrictMono fun x => f x / c := by\n  simpa only [div_eq_mul_inv] using hf.mul_const (inv_pos.2 hc)\n#align strict_mono.div_const StrictMono.div_const\n\n-- see Note [lower instance priority]\ninstance (priority := 100) LinearOrderedSemifield.to_denselyOrdered : DenselyOrdered α\n    where dense a₁ a₂ h :=\n    ⟨(a₁ + a₂) / 2,\n      calc\n        a₁ = (a₁ + a₁) / 2 := (add_self_div_two a₁).symm\n        _ < (a₁ + a₂) / 2 := div_lt_div_of_lt zero_lt_two (add_lt_add_left h _)\n        ,\n      calc\n        (a₁ + a₂) / 2 < (a₂ + a₂) / 2 := div_lt_div_of_lt zero_lt_two (add_lt_add_right h _)\n        _ = a₂ := add_self_div_two a₂\n        ⟩\n#align linear_ordered_semifield.to_densely_ordered LinearOrderedSemifield.to_denselyOrdered\n\n/- warning: min_div_div_right -> min_div_div_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (forall (a : α) (b : α), Eq.{succ u1} α (LinearOrder.min.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (LinearOrder.min.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))) a b) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (forall (a : α) (b : α), Eq.{succ u1} α (Min.min.{u1} α (LinearOrderedCommSemiring.toMin.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (Min.min.{u1} α (LinearOrderedCommSemiring.toMin.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)) a b) c))\nCase conversion may be inaccurate. Consider using '#align min_div_div_right min_div_div_rightₓ'. -/\ntheorem min_div_div_right {c : α} (hc : 0 ≤ c) (a b : α) : min (a / c) (b / c) = min a b / c :=\n  Eq.symm <| Monotone.map_min fun x y => div_le_div_of_le hc\n#align min_div_div_right min_div_div_right\n\n/- warning: max_div_div_right -> max_div_div_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) c) -> (forall (a : α) (b : α), Eq.{succ u1} α (LinearOrder.max.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (LinearOrder.max.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))) a b) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) c) -> (forall (a : α) (b : α), Eq.{succ u1} α (Max.max.{u1} α (LinearOrderedCommSemiring.toMax.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (Max.max.{u1} α (LinearOrderedCommSemiring.toMax.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)) a b) c))\nCase conversion may be inaccurate. Consider using '#align max_div_div_right max_div_div_rightₓ'. -/\ntheorem max_div_div_right {c : α} (hc : 0 ≤ c) (a b : α) : max (a / c) (b / c) = max a b / c :=\n  Eq.symm <| Monotone.map_max fun x y => div_le_div_of_le hc\n#align max_div_div_right max_div_div_right\n\n/- warning: one_div_strict_anti_on -> one_div_strictAntiOn is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], StrictAntiOn.{u1, u1} α α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (x : α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) x) (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], StrictAntiOn.{u1, u1} α α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (x : α) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) x) (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_div_strict_anti_on one_div_strictAntiOnₓ'. -/\ntheorem one_div_strictAntiOn : StrictAntiOn (fun x : α => 1 / x) (Set.Ioi 0) := fun x x1 y y1 xy =>\n  (one_div_lt_one_div (Set.mem_Ioi.mp y1) (Set.mem_Ioi.mp x1)).mpr xy\n#align one_div_strict_anti_on one_div_strictAntiOn\n\n/- warning: one_div_pow_le_one_div_pow_of_le -> one_div_pow_le_one_div_pow_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nCase conversion may be inaccurate. Consider using '#align one_div_pow_le_one_div_pow_of_le one_div_pow_le_one_div_pow_of_leₓ'. -/\ntheorem one_div_pow_le_one_div_pow_of_le (a1 : 1 ≤ a) {m n : ℕ} (mn : m ≤ n) :\n    1 / a ^ n ≤ 1 / a ^ m := by\n  refine' (one_div_le_one_div _ _).mpr (pow_le_pow a1 mn) <;>\n    exact pow_pos (zero_lt_one.trans_le a1) _\n#align one_div_pow_le_one_div_pow_of_le one_div_pow_le_one_div_pow_of_le\n\n/- warning: one_div_pow_lt_one_div_pow_of_lt -> one_div_pow_lt_one_div_pow_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat Nat.hasLt m n) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat instLTNat m n) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nCase conversion may be inaccurate. Consider using '#align one_div_pow_lt_one_div_pow_of_lt one_div_pow_lt_one_div_pow_of_ltₓ'. -/\ntheorem one_div_pow_lt_one_div_pow_of_lt (a1 : 1 < a) {m n : ℕ} (mn : m < n) :\n    1 / a ^ n < 1 / a ^ m := by\n  refine' (one_div_lt_one_div _ _).mpr (pow_lt_pow a1 mn) <;> exact pow_pos (trans zero_lt_one a1) _\n#align one_div_pow_lt_one_div_pow_of_lt one_div_pow_lt_one_div_pow_of_lt\n\n/- warning: one_div_pow_anti -> one_div_pow_anti is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (Antitone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (Antitone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align one_div_pow_anti one_div_pow_antiₓ'. -/\ntheorem one_div_pow_anti (a1 : 1 ≤ a) : Antitone fun n : ℕ => 1 / a ^ n := fun m n =>\n  one_div_pow_le_one_div_pow_of_le a1\n#align one_div_pow_anti one_div_pow_anti\n\n/- warning: one_div_pow_strict_anti -> one_div_pow_strictAnti is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (StrictAnti.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (StrictAnti.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align one_div_pow_strict_anti one_div_pow_strictAntiₓ'. -/\ntheorem one_div_pow_strictAnti (a1 : 1 < a) : StrictAnti fun n : ℕ => 1 / a ^ n := fun m n =>\n  one_div_pow_lt_one_div_pow_of_lt a1\n#align one_div_pow_strict_anti one_div_pow_strictAnti\n\n/- warning: inv_strict_anti_on -> inv_strictAntiOn is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], StrictAntiOn.{u1, u1} α α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (x : α) => Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) x) (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α], StrictAntiOn.{u1, u1} α α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (x : α) => Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) x) (Set.Ioi.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align inv_strict_anti_on inv_strictAntiOnₓ'. -/\ntheorem inv_strictAntiOn : StrictAntiOn (fun x : α => x⁻¹) (Set.Ioi 0) := fun x hx y hy xy =>\n  (inv_lt_inv hy hx).2 xy\n#align inv_strict_anti_on inv_strictAntiOn\n\n/- warning: inv_pow_le_inv_pow_of_le -> inv_pow_le_inv_pow_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nCase conversion may be inaccurate. Consider using '#align inv_pow_le_inv_pow_of_le inv_pow_le_inv_pow_of_leₓ'. -/\ntheorem inv_pow_le_inv_pow_of_le (a1 : 1 ≤ a) {m n : ℕ} (mn : m ≤ n) : (a ^ n)⁻¹ ≤ (a ^ m)⁻¹ := by\n  convert one_div_pow_le_one_div_pow_of_le a1 mn <;> simp\n#align inv_pow_le_inv_pow_of_le inv_pow_le_inv_pow_of_le\n\n/- warning: inv_pow_lt_inv_pow_of_lt -> inv_pow_lt_inv_pow_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat Nat.hasLt m n) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat instLTNat m n) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)) (Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a m))))\nCase conversion may be inaccurate. Consider using '#align inv_pow_lt_inv_pow_of_lt inv_pow_lt_inv_pow_of_ltₓ'. -/\ntheorem inv_pow_lt_inv_pow_of_lt (a1 : 1 < a) {m n : ℕ} (mn : m < n) : (a ^ n)⁻¹ < (a ^ m)⁻¹ := by\n  convert one_div_pow_lt_one_div_pow_of_lt a1 mn <;> simp\n#align inv_pow_lt_inv_pow_of_lt inv_pow_lt_inv_pow_of_lt\n\n/- warning: inv_pow_anti -> inv_pow_anti is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (Antitone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (n : Nat) => Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (Antitone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (n : Nat) => Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align inv_pow_anti inv_pow_antiₓ'. -/\ntheorem inv_pow_anti (a1 : 1 ≤ a) : Antitone fun n : ℕ => (a ^ n)⁻¹ := fun m n =>\n  inv_pow_le_inv_pow_of_le a1\n#align inv_pow_anti inv_pow_anti\n\n/- warning: inv_pow_strict_anti -> inv_pow_strictAnti is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (StrictAnti.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (fun (n : Nat) => Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) a) -> (StrictAnti.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (fun (n : Nat) => Inv.inv.{u1} α (LinearOrderedSemifield.toInv.{u1} α _inst_1) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align inv_pow_strict_anti inv_pow_strictAntiₓ'. -/\ntheorem inv_pow_strictAnti (a1 : 1 < a) : StrictAnti fun n : ℕ => (a ^ n)⁻¹ := fun m n =>\n  inv_pow_lt_inv_pow_of_lt a1\n#align inv_pow_strict_anti inv_pow_strictAnti\n\n/-! ### Results about `is_lub` and `is_glb` -/\n\n\n/- warning: is_glb.mul_left -> IsGLB.mul_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) s b) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) s b) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a b) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) a b))\nCase conversion may be inaccurate. Consider using '#align is_glb.mul_left IsGLB.mul_leftₓ'. -/\ntheorem IsGLB.mul_left {s : Set α} (ha : 0 ≤ a) (hs : IsGLB s b) :\n    IsGLB ((fun b => a * b) '' s) (a * b) :=\n  by\n  rcases lt_or_eq_of_le ha with (ha | rfl)\n  · exact (OrderIso.mulLeft₀ _ ha).isGLB_image'.2 hs\n  · simp_rw [MulZeroClass.zero_mul]\n    rw [hs.nonempty.image_const]\n    exact isGLB_singleton\n#align is_glb.mul_left IsGLB.mul_left\n\n/- warning: is_glb.mul_right -> IsGLB.mul_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))))) a) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) s b) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b a) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) a) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) s b) -> (IsGLB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b a) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))))) b a))\nCase conversion may be inaccurate. Consider using '#align is_glb.mul_right IsGLB.mul_rightₓ'. -/\ntheorem IsGLB.mul_right {s : Set α} (ha : 0 ≤ a) (hs : IsGLB s b) :\n    IsGLB ((fun b => b * a) '' s) (b * a) := by simpa [mul_comm] using hs.mul_left ha\n#align is_glb.mul_right IsGLB.mul_right\n\nend LinearOrderedSemifield\n\nsection\n\nvariable [LinearOrderedField α] {a b c d : α} {n : ℤ}\n\n/-! ### Lemmas about pos, nonneg, nonpos, neg -/\n\n\n/- warning: div_pos_iff -> div_pos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b)) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b)) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align div_pos_iff div_pos_iffₓ'. -/\ntheorem div_pos_iff : 0 < a / b ↔ 0 < a ∧ 0 < b ∨ a < 0 ∧ b < 0 := by\n  simp [division_def, mul_pos_iff]\n#align div_pos_iff div_pos_iff\n\n/- warning: div_neg_iff -> div_neg_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b)))\nCase conversion may be inaccurate. Consider using '#align div_neg_iff div_neg_iffₓ'. -/\ntheorem div_neg_iff : a / b < 0 ↔ 0 < a ∧ b < 0 ∨ a < 0 ∧ 0 < b := by\n  simp [division_def, mul_neg_iff]\n#align div_neg_iff div_neg_iff\n\n/- warning: div_nonneg_iff -> div_nonneg_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b)) (Or (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b)) (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b)) (Or (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b)) (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align div_nonneg_iff div_nonneg_iffₓ'. -/\ntheorem div_nonneg_iff : 0 ≤ a / b ↔ 0 ≤ a ∧ 0 ≤ b ∨ a ≤ 0 ∧ b ≤ 0 := by\n  simp [division_def, mul_nonneg_iff]\n#align div_nonneg_iff div_nonneg_iff\n\n/- warning: div_nonpos_iff -> div_nonpos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (Or (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))) (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (Or (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))) (And (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b)))\nCase conversion may be inaccurate. Consider using '#align div_nonpos_iff div_nonpos_iffₓ'. -/\ntheorem div_nonpos_iff : a / b ≤ 0 ↔ 0 ≤ a ∧ b ≤ 0 ∨ a ≤ 0 ∧ 0 ≤ b := by\n  simp [division_def, mul_nonpos_iff]\n#align div_nonpos_iff div_nonpos_iff\n\n/- warning: div_nonneg_of_nonpos -> div_nonneg_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_nonneg_of_nonpos div_nonneg_of_nonposₓ'. -/\ntheorem div_nonneg_of_nonpos (ha : a ≤ 0) (hb : b ≤ 0) : 0 ≤ a / b :=\n  div_nonneg_iff.2 <| Or.inr ⟨ha, hb⟩\n#align div_nonneg_of_nonpos div_nonneg_of_nonpos\n\n/- warning: div_pos_of_neg_of_neg -> div_pos_of_neg_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_pos_of_neg_of_neg div_pos_of_neg_of_negₓ'. -/\ntheorem div_pos_of_neg_of_neg (ha : a < 0) (hb : b < 0) : 0 < a / b :=\n  div_pos_iff.2 <| Or.inr ⟨ha, hb⟩\n#align div_pos_of_neg_of_neg div_pos_of_neg_of_neg\n\n/- warning: div_neg_of_neg_of_pos -> div_neg_of_neg_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align div_neg_of_neg_of_pos div_neg_of_neg_of_posₓ'. -/\ntheorem div_neg_of_neg_of_pos (ha : a < 0) (hb : 0 < b) : a / b < 0 :=\n  div_neg_iff.2 <| Or.inr ⟨ha, hb⟩\n#align div_neg_of_neg_of_pos div_neg_of_neg_of_pos\n\n/- warning: div_neg_of_pos_of_neg -> div_neg_of_pos_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align div_neg_of_pos_of_neg div_neg_of_pos_of_negₓ'. -/\ntheorem div_neg_of_pos_of_neg (ha : 0 < a) (hb : b < 0) : a / b < 0 :=\n  div_neg_iff.2 <| Or.inl ⟨ha, hb⟩\n#align div_neg_of_pos_of_neg div_neg_of_pos_of_neg\n\n/-! ### Relating one division with another term -/\n\n\n/- warning: div_le_iff_of_neg -> div_le_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a c) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align div_le_iff_of_neg div_le_iff_of_negₓ'. -/\ntheorem div_le_iff_of_neg (hc : c < 0) : b / c ≤ a ↔ a * c ≤ b :=\n  ⟨fun h => div_mul_cancel b (ne_of_lt hc) ▸ mul_le_mul_of_nonpos_right h hc.le, fun h =>\n    calc\n      a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc)\n      _ ≥ b * (1 / c) := (mul_le_mul_of_nonpos_right h (one_div_neg.2 hc).le)\n      _ = b / c := (div_eq_mul_one_div b c).symm\n      ⟩\n#align div_le_iff_of_neg div_le_iff_of_neg\n\n/- warning: div_le_iff_of_neg' -> div_le_iff_of_neg' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c a) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c) a) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align div_le_iff_of_neg' div_le_iff_of_neg'ₓ'. -/\ntheorem div_le_iff_of_neg' (hc : c < 0) : b / c ≤ a ↔ c * a ≤ b := by\n  rw [mul_comm, div_le_iff_of_neg hc]\n#align div_le_iff_of_neg' div_le_iff_of_neg'\n\n/- warning: le_div_iff_of_neg -> le_div_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a c)))\nCase conversion may be inaccurate. Consider using '#align le_div_iff_of_neg le_div_iff_of_negₓ'. -/\ntheorem le_div_iff_of_neg (hc : c < 0) : a ≤ b / c ↔ b ≤ a * c := by\n  rw [← neg_neg c, mul_neg, div_neg, le_neg, div_le_iff (neg_pos.2 hc), neg_mul]\n#align le_div_iff_of_neg le_div_iff_of_neg\n\n/- warning: le_div_iff_of_neg' -> le_div_iff_of_neg' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c a)))\nCase conversion may be inaccurate. Consider using '#align le_div_iff_of_neg' le_div_iff_of_neg'ₓ'. -/\ntheorem le_div_iff_of_neg' (hc : c < 0) : a ≤ b / c ↔ b ≤ c * a := by\n  rw [mul_comm, le_div_iff_of_neg hc]\n#align le_div_iff_of_neg' le_div_iff_of_neg'\n\n/- warning: div_lt_iff_of_neg -> div_lt_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a c) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff_of_neg div_lt_iff_of_negₓ'. -/\ntheorem div_lt_iff_of_neg (hc : c < 0) : b / c < a ↔ a * c < b :=\n  lt_iff_lt_of_le_iff_le <| le_div_iff_of_neg hc\n#align div_lt_iff_of_neg div_lt_iff_of_neg\n\n/- warning: div_lt_iff_of_neg' -> div_lt_iff_of_neg' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c a) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff_of_neg' div_lt_iff_of_neg'ₓ'. -/\ntheorem div_lt_iff_of_neg' (hc : c < 0) : b / c < a ↔ c * a < b := by\n  rw [mul_comm, div_lt_iff_of_neg hc]\n#align div_lt_iff_of_neg' div_lt_iff_of_neg'\n\n/- warning: lt_div_iff_of_neg -> lt_div_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a c)))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff_of_neg lt_div_iff_of_negₓ'. -/\ntheorem lt_div_iff_of_neg (hc : c < 0) : a < b / c ↔ b < a * c :=\n  lt_iff_lt_of_le_iff_le <| div_le_iff_of_neg hc\n#align lt_div_iff_of_neg lt_div_iff_of_neg\n\n/- warning: lt_div_iff_of_neg' -> lt_div_iff_of_neg' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c a)))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff_of_neg' lt_div_iff_of_neg'ₓ'. -/\ntheorem lt_div_iff_of_neg' (hc : c < 0) : a < b / c ↔ b < c * a := by\n  rw [mul_comm, lt_div_iff_of_neg hc]\n#align lt_div_iff_of_neg' lt_div_iff_of_neg'\n\n/-! ### Bi-implications of inequalities using inversions -/\n\n\n/- warning: inv_le_inv_of_neg -> inv_le_inv_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) a) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) a) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_le_inv_of_neg inv_le_inv_of_negₓ'. -/\ntheorem inv_le_inv_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := by\n  rw [← one_div, div_le_iff_of_neg ha, ← div_eq_inv_mul, div_le_iff_of_neg hb, one_mul]\n#align inv_le_inv_of_neg inv_le_inv_of_neg\n\n/- warning: inv_le_of_neg -> inv_le_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_le_of_neg inv_le_of_negₓ'. -/\ntheorem inv_le_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by\n  rw [← inv_le_inv_of_neg hb (inv_lt_zero.2 ha), inv_inv]\n#align inv_le_of_neg inv_le_of_neg\n\n/- warning: le_inv_of_neg -> le_inv_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align le_inv_of_neg le_inv_of_negₓ'. -/\ntheorem le_inv_of_neg (ha : a < 0) (hb : b < 0) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by\n  rw [← inv_le_inv_of_neg (inv_lt_zero.2 hb) ha, inv_inv]\n#align le_inv_of_neg le_inv_of_neg\n\n/- warning: inv_lt_inv_of_neg -> inv_lt_inv_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) a) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) a) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_inv_of_neg inv_lt_inv_of_negₓ'. -/\ntheorem inv_lt_inv_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ < b⁻¹ ↔ b < a :=\n  lt_iff_lt_of_le_iff_le (inv_le_inv_of_neg hb ha)\n#align inv_lt_inv_of_neg inv_lt_inv_of_neg\n\n/- warning: inv_lt_of_neg -> inv_lt_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_of_neg inv_lt_of_negₓ'. -/\ntheorem inv_lt_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ < b ↔ b⁻¹ < a :=\n  lt_iff_lt_of_le_iff_le (le_inv_of_neg hb ha)\n#align inv_lt_of_neg inv_lt_of_neg\n\n/- warning: lt_inv_of_neg -> lt_inv_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align lt_inv_of_neg lt_inv_of_negₓ'. -/\ntheorem lt_inv_of_neg (ha : a < 0) (hb : b < 0) : a < b⁻¹ ↔ b < a⁻¹ :=\n  lt_iff_lt_of_le_iff_le (inv_le_of_neg hb ha)\n#align lt_inv_of_neg lt_inv_of_neg\n\n/-! ### Relating two divisions -/\n\n\n/- warning: div_le_div_of_nonpos_of_le -> div_le_div_of_nonpos_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align div_le_div_of_nonpos_of_le div_le_div_of_nonpos_of_leₓ'. -/\ntheorem div_le_div_of_nonpos_of_le (hc : c ≤ 0) (h : b ≤ a) : a / c ≤ b / c :=\n  by\n  rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c]\n  exact mul_le_mul_of_nonpos_right h (one_div_nonpos.2 hc)\n#align div_le_div_of_nonpos_of_le div_le_div_of_nonpos_of_le\n\n/- warning: div_lt_div_of_neg_of_lt -> div_lt_div_of_neg_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_of_neg_of_lt div_lt_div_of_neg_of_ltₓ'. -/\ntheorem div_lt_div_of_neg_of_lt (hc : c < 0) (h : b < a) : a / c < b / c :=\n  by\n  rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c]\n  exact mul_lt_mul_of_neg_right h (one_div_neg.2 hc)\n#align div_lt_div_of_neg_of_lt div_lt_div_of_neg_of_lt\n\n/- warning: div_le_div_right_of_neg -> div_le_div_right_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_le_div_right_of_neg div_le_div_right_of_negₓ'. -/\ntheorem div_le_div_right_of_neg (hc : c < 0) : a / c ≤ b / c ↔ b ≤ a :=\n  ⟨le_imp_le_of_lt_imp_lt <| div_lt_div_of_neg_of_lt hc, div_le_div_of_nonpos_of_le <| hc.le⟩\n#align div_le_div_right_of_neg div_le_div_right_of_neg\n\n/- warning: div_lt_div_right_of_neg -> div_lt_div_right_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_right_of_neg div_lt_div_right_of_negₓ'. -/\ntheorem div_lt_div_right_of_neg (hc : c < 0) : a / c < b / c ↔ b < a :=\n  lt_iff_lt_of_le_iff_le <| div_le_div_right_of_neg hc\n#align div_lt_div_right_of_neg div_lt_div_right_of_neg\n\n/-! ### Relating one division and involving `1` -/\n\n\n/- warning: one_le_div_of_neg -> one_le_div_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align one_le_div_of_neg one_le_div_of_negₓ'. -/\ntheorem one_le_div_of_neg (hb : b < 0) : 1 ≤ a / b ↔ a ≤ b := by rw [le_div_iff_of_neg hb, one_mul]\n#align one_le_div_of_neg one_le_div_of_neg\n\n/- warning: div_le_one_of_neg -> div_le_one_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_le_one_of_neg div_le_one_of_negₓ'. -/\ntheorem div_le_one_of_neg (hb : b < 0) : a / b ≤ 1 ↔ b ≤ a := by rw [div_le_iff_of_neg hb, one_mul]\n#align div_le_one_of_neg div_le_one_of_neg\n\n/- warning: one_lt_div_of_neg -> one_lt_div_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align one_lt_div_of_neg one_lt_div_of_negₓ'. -/\ntheorem one_lt_div_of_neg (hb : b < 0) : 1 < a / b ↔ a < b := by rw [lt_div_iff_of_neg hb, one_mul]\n#align one_lt_div_of_neg one_lt_div_of_neg\n\n/- warning: div_lt_one_of_neg -> div_lt_one_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_lt_one_of_neg div_lt_one_of_negₓ'. -/\ntheorem div_lt_one_of_neg (hb : b < 0) : a / b < 1 ↔ b < a := by rw [div_lt_iff_of_neg hb, one_mul]\n#align div_lt_one_of_neg div_lt_one_of_neg\n\n/- warning: one_div_le_of_neg -> one_div_le_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_le_of_neg one_div_le_of_negₓ'. -/\ntheorem one_div_le_of_neg (ha : a < 0) (hb : b < 0) : 1 / a ≤ b ↔ 1 / b ≤ a := by\n  simpa using inv_le_of_neg ha hb\n#align one_div_le_of_neg one_div_le_of_neg\n\n/- warning: one_div_lt_of_neg -> one_div_lt_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_of_neg one_div_lt_of_negₓ'. -/\ntheorem one_div_lt_of_neg (ha : a < 0) (hb : b < 0) : 1 / a < b ↔ 1 / b < a := by\n  simpa using inv_lt_of_neg ha hb\n#align one_div_lt_of_neg one_div_lt_of_neg\n\n/- warning: le_one_div_of_neg -> le_one_div_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a)))\nCase conversion may be inaccurate. Consider using '#align le_one_div_of_neg le_one_div_of_negₓ'. -/\ntheorem le_one_div_of_neg (ha : a < 0) (hb : b < 0) : a ≤ 1 / b ↔ b ≤ 1 / a := by\n  simpa using le_inv_of_neg ha hb\n#align le_one_div_of_neg le_one_div_of_neg\n\n/- warning: lt_one_div_of_neg -> lt_one_div_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a)))\nCase conversion may be inaccurate. Consider using '#align lt_one_div_of_neg lt_one_div_of_negₓ'. -/\ntheorem lt_one_div_of_neg (ha : a < 0) (hb : b < 0) : a < 1 / b ↔ b < 1 / a := by\n  simpa using lt_inv_of_neg ha hb\n#align lt_one_div_of_neg lt_one_div_of_neg\n\n/- warning: one_lt_div_iff -> one_lt_div_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b)) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b)) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b)))\nCase conversion may be inaccurate. Consider using '#align one_lt_div_iff one_lt_div_iffₓ'. -/\ntheorem one_lt_div_iff : 1 < a / b ↔ 0 < b ∧ b < a ∨ b < 0 ∧ a < b :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  · simp [hb, hb.not_lt, one_lt_div_of_neg]\n  · simp [lt_irrefl, zero_le_one]\n  · simp [hb, hb.not_lt, one_lt_div]\n#align one_lt_div_iff one_lt_div_iff\n\n/- warning: one_le_div_iff -> one_le_div_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b)) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b)) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a)) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b)))\nCase conversion may be inaccurate. Consider using '#align one_le_div_iff one_le_div_iffₓ'. -/\ntheorem one_le_div_iff : 1 ≤ a / b ↔ 0 < b ∧ b ≤ a ∨ b < 0 ∧ a ≤ b :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  · simp [hb, hb.not_lt, one_le_div_of_neg]\n  · simp [lt_irrefl, zero_lt_one.not_le, zero_lt_one]\n  · simp [hb, hb.not_lt, one_le_div]\n#align one_le_div_iff one_le_div_iff\n\n/- warning: div_lt_one_iff -> div_lt_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b)) (Or (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b)) (Or (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))))\nCase conversion may be inaccurate. Consider using '#align div_lt_one_iff div_lt_one_iffₓ'. -/\ntheorem div_lt_one_iff : a / b < 1 ↔ 0 < b ∧ a < b ∨ b = 0 ∨ b < 0 ∧ b < a :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  · simp [hb, hb.not_lt, hb.ne, div_lt_one_of_neg]\n  · simp [zero_lt_one]\n  · simp [hb, hb.not_lt, div_lt_one, hb.ne.symm]\n#align div_lt_one_iff div_lt_one_iff\n\n/- warning: div_le_one_iff -> div_le_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b)) (Or (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (Or (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b)) (Or (Eq.{succ u1} α b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))))\nCase conversion may be inaccurate. Consider using '#align div_le_one_iff div_le_one_iffₓ'. -/\ntheorem div_le_one_iff : a / b ≤ 1 ↔ 0 < b ∧ a ≤ b ∨ b = 0 ∨ b < 0 ∧ b ≤ a :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  · simp [hb, hb.not_lt, hb.ne, div_le_one_of_neg]\n  · simp [zero_le_one]\n  · simp [hb, hb.not_lt, div_le_one, hb.ne.symm]\n#align div_le_one_iff div_le_one_iff\n\n/-! ### Relating two divisions, involving `1` -/\n\n\n/- warning: one_div_le_one_div_of_neg_of_le -> one_div_le_one_div_of_neg_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_div_le_one_div_of_neg_of_le one_div_le_one_div_of_neg_of_leₓ'. -/\ntheorem one_div_le_one_div_of_neg_of_le (hb : b < 0) (h : a ≤ b) : 1 / b ≤ 1 / a := by\n  rwa [div_le_iff_of_neg' hb, ← div_eq_mul_one_div, div_le_one_of_neg (h.trans_lt hb)]\n#align one_div_le_one_div_of_neg_of_le one_div_le_one_div_of_neg_of_le\n\n/- warning: one_div_lt_one_div_of_neg_of_lt -> one_div_lt_one_div_of_neg_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_one_div_of_neg_of_lt one_div_lt_one_div_of_neg_of_ltₓ'. -/\ntheorem one_div_lt_one_div_of_neg_of_lt (hb : b < 0) (h : a < b) : 1 / b < 1 / a := by\n  rwa [div_lt_iff_of_neg' hb, ← div_eq_mul_one_div, div_lt_one_of_neg (h.trans hb)]\n#align one_div_lt_one_div_of_neg_of_lt one_div_lt_one_div_of_neg_of_lt\n\n/- warning: le_of_neg_of_one_div_le_one_div -> le_of_neg_of_one_div_le_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a)\nCase conversion may be inaccurate. Consider using '#align le_of_neg_of_one_div_le_one_div le_of_neg_of_one_div_le_one_divₓ'. -/\ntheorem le_of_neg_of_one_div_le_one_div (hb : b < 0) (h : 1 / a ≤ 1 / b) : b ≤ a :=\n  le_imp_le_of_lt_imp_lt (one_div_lt_one_div_of_neg_of_lt hb) h\n#align le_of_neg_of_one_div_le_one_div le_of_neg_of_one_div_le_one_div\n\n/- warning: lt_of_neg_of_one_div_lt_one_div -> lt_of_neg_of_one_div_lt_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b)) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b)) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a)\nCase conversion may be inaccurate. Consider using '#align lt_of_neg_of_one_div_lt_one_div lt_of_neg_of_one_div_lt_one_divₓ'. -/\ntheorem lt_of_neg_of_one_div_lt_one_div (hb : b < 0) (h : 1 / a < 1 / b) : b < a :=\n  lt_imp_lt_of_le_imp_le (one_div_le_one_div_of_neg_of_le hb) h\n#align lt_of_neg_of_one_div_lt_one_div lt_of_neg_of_one_div_lt_one_div\n\n/- warning: one_div_le_one_div_of_neg -> one_div_le_one_div_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_div_le_one_div_of_neg one_div_le_one_div_of_negₓ'. -/\n/-- For the single implications with fewer assumptions, see `one_div_lt_one_div_of_neg_of_lt` and\n  `lt_of_one_div_lt_one_div` -/\ntheorem one_div_le_one_div_of_neg (ha : a < 0) (hb : b < 0) : 1 / a ≤ 1 / b ↔ b ≤ a := by\n  simpa [one_div] using inv_le_inv_of_neg ha hb\n#align one_div_le_one_div_of_neg one_div_le_one_div_of_neg\n\n/- warning: one_div_lt_one_div_of_neg -> one_div_lt_one_div_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_one_div_of_neg one_div_lt_one_div_of_negₓ'. -/\n/-- For the single implications with fewer assumptions, see `one_div_lt_one_div_of_lt` and\n  `lt_of_one_div_lt_one_div` -/\ntheorem one_div_lt_one_div_of_neg (ha : a < 0) (hb : b < 0) : 1 / a < 1 / b ↔ b < a :=\n  lt_iff_lt_of_le_iff_le (one_div_le_one_div_of_neg hb ha)\n#align one_div_lt_one_div_of_neg one_div_lt_one_div_of_neg\n\n/- warning: one_div_lt_neg_one -> one_div_lt_neg_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Neg.neg.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) a) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (Neg.neg.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_neg_one one_div_lt_neg_oneₓ'. -/\ntheorem one_div_lt_neg_one (h1 : a < 0) (h2 : -1 < a) : 1 / a < -1 :=\n  suffices 1 / a < 1 / -1 by rwa [one_div_neg_one_eq_neg_one] at this\n  one_div_lt_one_div_of_neg_of_lt h1 h2\n#align one_div_lt_neg_one one_div_lt_neg_one\n\n/- warning: one_div_le_neg_one -> one_div_le_neg_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a) (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Neg.neg.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (Neg.neg.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align one_div_le_neg_one one_div_le_neg_oneₓ'. -/\ntheorem one_div_le_neg_one (h1 : a < 0) (h2 : -1 ≤ a) : 1 / a ≤ -1 :=\n  suffices 1 / a ≤ 1 / -1 by rwa [one_div_neg_one_eq_neg_one] at this\n  one_div_le_one_div_of_neg_of_le h1 h2\n#align one_div_le_neg_one one_div_le_neg_one\n\n/-! ### Results about halving -/\n\n\n/- warning: sub_self_div_two -> sub_self_div_two is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))\nCase conversion may be inaccurate. Consider using '#align sub_self_div_two sub_self_div_twoₓ'. -/\ntheorem sub_self_div_two (a : α) : a - a / 2 = a / 2 :=\n  by\n  suffices a / 2 + a / 2 - a / 2 = a / 2 by rwa [add_halves] at this\n  rw [add_sub_cancel]\n#align sub_self_div_two sub_self_div_two\n\n/- warning: div_two_sub_self -> div_two_sub_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) a) (Neg.neg.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) a) (Neg.neg.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))\nCase conversion may be inaccurate. Consider using '#align div_two_sub_self div_two_sub_selfₓ'. -/\ntheorem div_two_sub_self (a : α) : a / 2 - a = -(a / 2) :=\n  by\n  suffices a / 2 - (a / 2 + a / 2) = -(a / 2) by rwa [add_halves] at this\n  rw [sub_add_eq_sub_sub, sub_self, zero_sub]\n#align div_two_sub_self div_two_sub_self\n\n/- warning: add_sub_div_two_lt -> add_sub_div_two_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) b a) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))) b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) a b) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) a (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) b)\nCase conversion may be inaccurate. Consider using '#align add_sub_div_two_lt add_sub_div_two_ltₓ'. -/\ntheorem add_sub_div_two_lt (h : a < b) : a + (b - a) / 2 < b := by\n  rwa [← div_sub_div_same, sub_eq_add_neg, add_comm (b / 2), ← add_assoc, ← sub_eq_add_neg, ←\n    lt_sub_iff_add_lt, sub_self_div_two, sub_self_div_two, div_lt_div_right (zero_lt_two' α)]\n#align add_sub_div_two_lt add_sub_div_two_lt\n\n/- warning: sub_one_div_inv_le_two -> sub_one_div_inv_le_two is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a))) (OfNat.ofNat.{u1} α 2 (OfNat.mk.{u1} α 2 (bit0.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a))) (OfNat.ofNat.{u1} α 2 (instOfNat.{u1} α 2 (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))\nCase conversion may be inaccurate. Consider using '#align sub_one_div_inv_le_two sub_one_div_inv_le_twoₓ'. -/\n/-- An inequality involving `2`. -/\ntheorem sub_one_div_inv_le_two (a2 : 2 ≤ a) : (1 - 1 / a)⁻¹ ≤ 2 :=\n  by\n  -- Take inverses on both sides to obtain `2⁻¹ ≤ 1 - 1 / a`\n  refine' (inv_le_inv_of_le (inv_pos.2 <| zero_lt_two' α) _).trans_eq (inv_inv (2 : α))\n  -- move `1 / a` to the left and `1 - 1 / 2 = 1 / 2` to the right to obtain `1 / a ≤ ⅟ 2`\n  refine' (le_sub_iff_add_le.2 (_ : _ + 2⁻¹ = _).le).trans ((sub_le_sub_iff_left 1).2 _)\n  ·-- show 2⁻¹ + 2⁻¹ = 1\n    exact (two_mul _).symm.trans (mul_inv_cancel two_ne_zero)\n  ·-- take inverses on both sides and use the assumption `2 ≤ a`.\n    exact (one_div a).le.trans (inv_le_inv_of_le zero_lt_two a2)\n#align sub_one_div_inv_le_two sub_one_div_inv_le_two\n\n/-! ### Results about `is_lub` and `is_glb` -/\n\n\n/- warning: is_lub.mul_left -> IsLUB.mul_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) s b) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) s b) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a b) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a b))\nCase conversion may be inaccurate. Consider using '#align is_lub.mul_left IsLUB.mul_leftₓ'. -/\n-- TODO: Generalize to `linear_ordered_semifield`\ntheorem IsLUB.mul_left {s : Set α} (ha : 0 ≤ a) (hs : IsLUB s b) :\n    IsLUB ((fun b => a * b) '' s) (a * b) :=\n  by\n  rcases lt_or_eq_of_le ha with (ha | rfl)\n  · exact (OrderIso.mulLeft₀ _ ha).isLUB_image'.2 hs\n  · simp_rw [MulZeroClass.zero_mul]\n    rw [hs.nonempty.image_const]\n    exact isLUB_singleton\n#align is_lub.mul_left IsLUB.mul_left\n\n/- warning: is_lub.mul_right -> IsLUB.mul_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) s b) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {s : Set.{u1} α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) s b) -> (IsLUB.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (Set.image.{u1, u1} α α (fun (b : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b a) s) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b a))\nCase conversion may be inaccurate. Consider using '#align is_lub.mul_right IsLUB.mul_rightₓ'. -/\n-- TODO: Generalize to `linear_ordered_semifield`\ntheorem IsLUB.mul_right {s : Set α} (ha : 0 ≤ a) (hs : IsLUB s b) :\n    IsLUB ((fun b => b * a) '' s) (b * a) := by simpa [mul_comm] using hs.mul_left ha\n#align is_lub.mul_right IsLUB.mul_right\n\n/-! ### Miscellaneous lemmmas -/\n\n\n/- warning: mul_sub_mul_div_mul_neg_iff -> mul_sub_mul_div_mul_neg_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c d)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b d)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c d)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b d)))\nCase conversion may be inaccurate. Consider using '#align mul_sub_mul_div_mul_neg_iff mul_sub_mul_div_mul_neg_iffₓ'. -/\ntheorem mul_sub_mul_div_mul_neg_iff (hc : c ≠ 0) (hd : d ≠ 0) :\n    (a * d - b * c) / (c * d) < 0 ↔ a / c < b / d := by\n  rw [mul_comm b c, ← div_sub_div _ _ hc hd, sub_lt_zero]\n#align mul_sub_mul_div_mul_neg_iff mul_sub_mul_div_mul_neg_iff\n\n/- warning: mul_sub_mul_div_mul_nonpos_iff -> mul_sub_mul_div_mul_nonpos_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c d)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b d)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Iff (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c d)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b d)))\nCase conversion may be inaccurate. Consider using '#align mul_sub_mul_div_mul_nonpos_iff mul_sub_mul_div_mul_nonpos_iffₓ'. -/\ntheorem mul_sub_mul_div_mul_nonpos_iff (hc : c ≠ 0) (hd : d ≠ 0) :\n    (a * d - b * c) / (c * d) ≤ 0 ↔ a / c ≤ b / d := by\n  rw [mul_comm b c, ← div_sub_div _ _ hc hd, sub_nonpos]\n#align mul_sub_mul_div_mul_nonpos_iff mul_sub_mul_div_mul_nonpos_iff\n\n/- warning: div_lt_div_of_mul_sub_mul_div_neg -> div_lt_div_of_mul_sub_mul_div_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c d)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b d))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c d)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b d))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_of_mul_sub_mul_div_neg div_lt_div_of_mul_sub_mul_div_negₓ'. -/\n/- warning: mul_sub_mul_div_mul_neg -> mul_sub_mul_div_mul_neg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b d)) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c d)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b d)) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c d)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align mul_sub_mul_div_mul_neg mul_sub_mul_div_mul_negₓ'. -/\nalias mul_sub_mul_div_mul_neg_iff ↔ div_lt_div_of_mul_sub_mul_div_neg mul_sub_mul_div_mul_neg\n#align div_lt_div_of_mul_sub_mul_div_neg div_lt_div_of_mul_sub_mul_div_neg\n#align mul_sub_mul_div_mul_neg mul_sub_mul_div_mul_neg\n\n/- warning: div_le_div_of_mul_sub_mul_div_nonpos -> div_le_div_of_mul_sub_mul_div_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c d)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b d))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c d)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b d))\nCase conversion may be inaccurate. Consider using '#align div_le_div_of_mul_sub_mul_div_nonpos div_le_div_of_mul_sub_mul_div_nonposₓ'. -/\n/- warning: mul_sub_mul_div_mul_nonpos -> mul_sub_mul_div_mul_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b d)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c d)) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α} {c : α} {d : α}, (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (Ne.{succ u1} α d (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b d)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) c d)) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align mul_sub_mul_div_mul_nonpos mul_sub_mul_div_mul_nonposₓ'. -/\nalias mul_sub_mul_div_mul_nonpos_iff ↔\n  div_le_div_of_mul_sub_mul_div_nonpos mul_sub_mul_div_mul_nonpos\n#align div_le_div_of_mul_sub_mul_div_nonpos div_le_div_of_mul_sub_mul_div_nonpos\n#align mul_sub_mul_div_mul_nonpos mul_sub_mul_div_mul_nonpos\n\n/- warning: exists_add_lt_and_pos_of_lt -> exists_add_lt_and_pos_of_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a) -> (Exists.{succ u1} α (fun (c : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a) -> (Exists.{succ u1} α (fun (c : α) => And (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) b c) a) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) c)))\nCase conversion may be inaccurate. Consider using '#align exists_add_lt_and_pos_of_lt exists_add_lt_and_pos_of_ltₓ'. -/\ntheorem exists_add_lt_and_pos_of_lt (h : b < a) : ∃ c, b + c < a ∧ 0 < c :=\n  ⟨(a - b) / 2, add_sub_div_two_lt h, div_pos (sub_pos_of_lt h) zero_lt_two⟩\n#align exists_add_lt_and_pos_of_lt exists_add_lt_and_pos_of_lt\n\n/- warning: le_of_forall_sub_le -> le_of_forall_sub_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (forall (ε : α), (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) ε (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (SubNegMonoid.toHasSub.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))) b ε) a)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (forall (ε : α), (GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) ε (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α (Ring.toSub.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b ε) a)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) b a)\nCase conversion may be inaccurate. Consider using '#align le_of_forall_sub_le le_of_forall_sub_leₓ'. -/\ntheorem le_of_forall_sub_le (h : ∀ ε > 0, b - ε ≤ a) : b ≤ a :=\n  by\n  contrapose! h\n  simpa only [and_comm' ((0 : α) < _), lt_sub_iff_add_lt, gt_iff_lt] using\n    exists_add_lt_and_pos_of_lt h\n#align le_of_forall_sub_le le_of_forall_sub_le\n\n/- warning: mul_self_inj_of_nonneg -> mul_self_inj_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) b) -> (Iff (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b b)) (Eq.{succ u1} α a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {a : α} {b : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))) b) -> (Iff (Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a a) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b b)) (Eq.{succ u1} α a b))\nCase conversion may be inaccurate. Consider using '#align mul_self_inj_of_nonneg mul_self_inj_of_nonnegₓ'. -/\ntheorem mul_self_inj_of_nonneg (a0 : 0 ≤ a) (b0 : 0 ≤ b) : a * a = b * b ↔ a = b :=\n  mul_self_eq_mul_self_iff.trans <|\n    or_iff_left_of_imp fun h => by\n      subst a\n      have : b = 0 := le_antisymm (neg_nonneg.1 a0) b0\n      rw [this, neg_zero]\n#align mul_self_inj_of_nonneg mul_self_inj_of_nonneg\n\n/- warning: min_div_div_right_of_nonpos -> min_div_div_right_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (forall (a : α) (b : α), Eq.{succ u1} α (LinearOrder.min.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (LinearOrder.max.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) a b) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (forall (a : α) (b : α), Eq.{succ u1} α (Min.min.{u1} α (LinearOrderedRing.toMin.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (Max.max.{u1} α (LinearOrderedRing.toMax.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) a b) c))\nCase conversion may be inaccurate. Consider using '#align min_div_div_right_of_nonpos min_div_div_right_of_nonposₓ'. -/\ntheorem min_div_div_right_of_nonpos (hc : c ≤ 0) (a b : α) : min (a / c) (b / c) = max a b / c :=\n  Eq.symm <| Antitone.map_max fun x y => div_le_div_of_nonpos_of_le hc\n#align min_div_div_right_of_nonpos min_div_div_right_of_nonpos\n\n/- warning: max_div_div_right_of_nonpos -> max_div_div_right_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))))) -> (forall (a : α) (b : α), Eq.{succ u1} α (LinearOrder.max.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (LinearOrder.min.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) a b) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] {c : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (CommMonoidWithZero.toZero.{u1} α (CommGroupWithZero.toCommMonoidWithZero.{u1} α (Semifield.toCommGroupWithZero.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))))) -> (forall (a : α) (b : α), Eq.{succ u1} α (Max.max.{u1} α (LinearOrderedRing.toMax.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (Min.min.{u1} α (LinearOrderedRing.toMin.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))) a b) c))\nCase conversion may be inaccurate. Consider using '#align max_div_div_right_of_nonpos max_div_div_right_of_nonposₓ'. -/\ntheorem max_div_div_right_of_nonpos (hc : c ≤ 0) (a b : α) : max (a / c) (b / c) = min a b / c :=\n  Eq.symm <| Antitone.map_min fun x y => div_le_div_of_nonpos_of_le hc\n#align max_div_div_right_of_nonpos max_div_div_right_of_nonpos\n\n/- warning: abs_inv -> abs_inv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) a)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) a)) (Inv.inv.{u1} α (LinearOrderedField.toInv.{u1} α _inst_1) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a))\nCase conversion may be inaccurate. Consider using '#align abs_inv abs_invₓ'. -/\ntheorem abs_inv (a : α) : |a⁻¹| = (|a|)⁻¹ :=\n  map_inv₀ (absHom : α →*₀ α) a\n#align abs_inv abs_inv\n\n/- warning: abs_div -> abs_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α) (b : α), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) a b)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α) (b : α), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) a b)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) b))\nCase conversion may be inaccurate. Consider using '#align abs_div abs_divₓ'. -/\ntheorem abs_div (a b : α) : |a / b| = |a| / |b| :=\n  map_div₀ (absHom : α →*₀ α) a b\n#align abs_div abs_div\n\n/- warning: abs_one_div -> abs_one_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) a)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (a : α), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a))\nCase conversion may be inaccurate. Consider using '#align abs_one_div abs_one_divₓ'. -/\ntheorem abs_one_div (a : α) : |1 / a| = 1 / |a| := by rw [abs_div, abs_one]\n#align abs_one_div abs_one_div\n\nend\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Field/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4788562781768672}}
{"text": "import Lean\nsyntax (name := test) \"test%\" ident : command\n\nopen Lean.Elab\nopen Lean.Elab.Command\n\n@[command_elab test] def elabTest : CommandElab := fun stx => do\n  let id ← resolveGlobalConstNoOverloadWithInfo stx[1]\n  liftTermElabM none do\n    Lean.Meta.Match.mkEquationsFor id\n  return ()\n\ndef f (xs ys : List String) : Nat :=\n  match xs, ys with\n  | [], []      => 0\n  | _,  [\"abc\"] => 1\n  | _, x::xs    => xs.length\n  | _,  _       => 2\n\n\ndef h (x y : Nat) : Nat :=\n  match x, y with\n  | 10000, _ => 0\n  | 10001, _ => 5\n  | _, 20000 => 4\n  | x+1, _   => 3\n  | Nat.zero, y+1 => 44\n  | _, _     => 1\n\ntheorem ex1 : h 10000 1 = 0 := rfl\ntheorem ex2 : h 10002 1 = 3 := rfl\n\n-- set_option trace.Meta.debug true\n-- set_option pp.proofs true\n-- set_option trace.Meta.debug truen\nset_option trace.Meta.Match.matchEqs true in\ntest% f.match_1\n#check @f.match_1.eq_1\n#check @f.match_1.eq_2\n#check @f.match_1.eq_3\n#check @f.match_1.eq_4\n#check @f.match_1.splitter\n\ntest% h.match_1\n#check @h.match_1.eq_1\n#check @h.match_1.eq_2\n#check @h.match_1.eq_3\n#check @h.match_1.eq_4\n#check @h.match_1.eq_5\n#check @h.match_1.eq_6\n#check @h.match_1.splitter\n\ndef g (xs ys : List (Nat × String)) : Nat :=\n  match xs, ys with\n  | _,  [(a,b)] => 0\n  | [(c, d)], _ => 1\n  | _,  _       => 2\n\nset_option pp.analyze false\nset_option pp.proofs true\nset_option trace.Meta.Match.matchEqs true in\ntest% g.match_1\n#check @g.match_1.eq_1\n#check @g.match_1.eq_2\n#check @g.match_1.eq_3\n#check @g.match_1.splitter\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/playground/matchEqs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.4788562693939605}}
{"text": "universes u v\n\ninductive Foo (α : Type u)\n| leaf (a : α) : Foo\n| node (left : Foo) (right : Foo) : Foo\n| cons (head : α) (tail : Foo) : Foo\n\ndef Foo.elim {α : Type u} (C : Foo α → Foo α → Sort v) (x y : Foo α)\n  (h₁ : forall (a₁ a₂ : α), C (Foo.leaf a₁) (Foo.leaf a₂))\n  (h₂ : forall (l₁ r₁ l₂ r₂ : Foo α), C (Foo.node l₁ r₁) (Foo.node l₂ r₂))\n  (h₃ : forall (h₁ t₁ h₂ t₂), C (Foo.cons h₁ t₁) (Foo.cons h₂ t₂))\n  (h₄ : forall (x y), C x y)\n  : C x y :=\nFoo.casesOn x\n  (fun a₁ => Foo.casesOn y\n    (fun a₂ => h₁ a₁ a₂)\n    (fun l₂ r₂ => h₄ (Foo.leaf a₁) (Foo.node l₂ r₂))\n    (fun h₂ t₂ => h₄ (Foo.leaf a₁) (Foo.cons h₂ t₂)))\n  (fun l₁ r₁ => Foo.casesOn y\n    (fun a₂    => h₄ (Foo.node l₁ r₁) (Foo.leaf a₂))\n    (fun l₂ r₂ => h₂ l₁ r₁ l₂ r₂)\n    (fun h₂ t₂ => h₄ (Foo.node l₁ r₁) (Foo.cons h₂ t₂)))\n  (fun h₁ t₁ => Foo.casesOn y\n    (fun a₂    => h₄ (Foo.cons h₁ t₁) (Foo.leaf a₂))\n    (fun l₂ r₂ => h₄ (Foo.cons h₁ t₁) (Foo.node l₂ r₂))\n    (fun h₂ t₂ => h₃ h₁ t₁ h₂ t₂))\n\ndef f : List Nat → List Nat → List Nat\n| x::xs, _   => []\n| _,     []  => []\n| xs,    ys  => xs ++ ys\n\ndef List.elim (C : List Nat → List Nat → Sort v) (xs ys : List Nat)\n  (h₁ : forall x xs ys, C (x::xs) ys)\n  (h₂ : forall xs,      C xs [])\n  (h₃ : forall xs ys,   C xs ys)\n  : C xs ys :=\nList.casesOn xs\n  (List.casesOn ys\n     (h₂ [])\n     (fun y ys => h₃ [] (y::ys)))\n  (fun x xs => h₁ x xs ys)\n\ntheorem List.elim.eq1 (C : List Nat → List Nat → Sort v)\n  (h₁ : forall x xs ys, C (x::xs) ys)\n  (h₂ : forall xs,      C xs [])\n  (h₃ : forall xs ys,   C xs ys)\n  (x : Nat) (xs ys : List Nat)\n  : List.elim C (x::xs) ys h₁ h₂ h₃ = h₁ x xs ys :=\nrfl\n\ntheorem List.elim.eq2 (C : List Nat → List Nat → Sort v)\n  (h₁ : forall x xs ys, C (x::xs) ys)\n  (h₂ : forall xs,      C xs [])\n  (h₃ : forall xs ys,   C xs ys)\n  (xs : List Nat)\n  : (forall x' xs', xs = x'::xs' → False) → List.elim C xs [] h₁ h₂ h₃ = h₂ xs :=\nList.casesOn xs\n  (fun _      => rfl)\n  (fun x xs h => False.elim (h x xs rfl))\n\ntheorem List.elim.eq3 (C : List Nat → List Nat → Sort v)\n  (h₁ : forall x xs ys, C (x::xs) ys)\n  (h₂ : forall xs,      C xs [])\n  (h₃ : forall xs ys,   C xs ys)\n  (xs : List Nat) (ys : List Nat)\n  : (forall x' xs', xs = x'::xs' → False) → (ys = [] → False) → List.elim C xs ys h₁ h₂ h₃ = h₃ xs ys :=\nList.casesOn xs\n  (List.casesOn ys\n     (fun _ h => False.elim (h rfl))\n     (fun y ys _ _ => rfl))\n  (fun x xs h _ => False.elim (h x xs rfl))\n\ntheorem List.elim.eq3.a (C : List Nat → List Nat → Sort v)\n  (h₁ : forall x xs ys, C (x::xs) ys)\n  (h₂ : forall xs,      C xs [])\n  (h₃ : forall xs ys,   C xs ys)\n  (y : Nat) (ys : List Nat)\n  : List.elim C [] (y::ys) h₁ h₂ h₃ = h₃ [] (y::ys) :=\nrfl\n\ndef List.elim2 (C : List Nat → List Nat → Sort v) (xs ys : List Nat)\n  (h₁ : forall x xs ys, C (x::xs) ys)\n  (h₂ : forall xs,    (forall (x' : Nat) (xs' : List Nat), xs = x' :: xs' → False) → C xs [])\n  (h₃ : forall xs ys, (forall (x' : Nat) (xs' : List Nat), xs = x' :: xs' → False) → (ys = [] → False) → C xs ys)\n  : C xs ys :=\nList.casesOn xs\n  (List.casesOn ys\n     (h₂ [] (fun _ _ h => List.noConfusion h))\n     (fun y ys => h₃ [] (y::ys) (fun _ _ h => List.noConfusion h) (fun h => List.noConfusion h)))\n  (fun x xs => h₁ x xs ys)\n\ndef List.elim3 (C : List Nat → List Nat → List Nat → Sort v) (xs ys zs : List Nat)\n  (h₁ : forall zs,       C [] [] zs)\n  (h₂ : forall xs ys,    C xs ys [])\n  (h₃ : forall xs ys zs, C xs ys zs)\n  : C xs ys zs :=\nList.casesOn xs\n  (List.casesOn ys\n     (h₁ zs)\n     (fun y ys => List.casesOn zs\n        (h₃ [] (y::ys) [])\n        (fun z zs => h₃ [] (y::ys) (z::zs))))\n  (fun x xs =>\n    (List.casesOn zs\n      (h₂ (x::xs) ys)\n      (fun z zs => h₃ (x::xs) ys (z::zs))))\n\ntheorem List.elim3.eq (C : List Nat → List Nat → List Nat → Sort v)\n  (h₁ : forall zs,       C [] [] zs)\n  (h₂ : forall xs ys,    C xs ys [])\n  (h₃ : forall xs ys zs, C xs ys zs)\n  (xs ys zs : List Nat)\n  : (xs = [] → ys = [] → False) → (zs = [] → False) → List.elim3 C xs ys zs h₁ h₂ h₃ = h₃ xs ys zs :=\nList.casesOn xs\n  (List.casesOn ys\n    (fun h _  => False.elim (h rfl rfl))\n    (fun y ys => List.casesOn zs\n      (fun _ h => False.elim (h rfl))\n      (fun z zs _ _ => rfl)))\n  (fun x xs =>\n    List.casesOn zs\n      (fun _ h => False.elim (h rfl))\n      (fun z zs _ _ => rfl))\n\ntheorem List.elim3.eq.a (C : List Nat → List Nat → List Nat → Sort v)\n  (h₁ : forall zs,       C [] [] zs)\n  (h₂ : forall xs ys,    C xs ys [])\n  (h₃ : forall xs ys zs, C xs ys zs)\n  (y : Nat) (ys : List Nat) (z : Nat) (zs : List Nat)\n  : List.elim3 C [] (y::ys) (z::zs) h₁ h₂ h₃ = h₃ [] (y::ys) (z::zs) :=\nrfl\n\ntheorem List.elim3.eq.b (C : List Nat → List Nat → List Nat → Sort v)\n  (h₁ : forall zs,       C [] [] zs)\n  (h₂ : forall xs ys,    C xs ys [])\n  (h₃ : forall xs ys zs, C xs ys zs)\n  (x : Nat) (xs : List Nat) (y : Nat) (ys : List Nat) (z : Nat) (zs : List Nat)\n  : List.elim3 C (x::xs) (y::ys) (z::zs) h₁ h₂ h₃ = h₃ (x::xs) (y::ys) (z::zs) :=\nrfl\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tmp/eqns/elim1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.4788562652872177}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Anne Baanen\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.algebraic\nimport Mathlib.ring_theory.localization\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Ideals over/under ideals\n\nThis file concerns ideals lying over other ideals.\nLet `f : R →+* S` be a ring homomorphism (typically a ring extension), `I` an ideal of `R` and\n`J` an ideal of `S`. We say `J` lies over `I` (and `I` under `J`) if `I` is the `f`-preimage of `J`.\nThis is expressed here by writing `I = J.comap f`.\n\n## Implementation notes\n\nThe proofs of the `comap_ne_bot` and `comap_lt_comap` families use an approach\nspecific for their situation: we construct an element in `I.comap f` from the\ncoefficients of a minimal polynomial.\nOnce mathlib has more material on the localization at a prime ideal, the results\ncan be proven using more general going-up/going-down theory.\n-/\n\nnamespace ideal\n\n\ntheorem coeff_zero_mem_comap_of_root_mem_of_eval_mem {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [comm_ring S] {f : R →+* S} {I : ideal S} {r : S} (hr : r ∈ I) {p : polynomial R}\n    (hp : polynomial.eval₂ f r p ∈ I) : polynomial.coeff p 0 ∈ comap f I :=\n  sorry\n\ntheorem coeff_zero_mem_comap_of_root_mem {R : Type u_1} [comm_ring R] {S : Type u_2} [comm_ring S]\n    {f : R →+* S} {I : ideal S} {r : S} (hr : r ∈ I) {p : polynomial R}\n    (hp : polynomial.eval₂ f r p = 0) : polynomial.coeff p 0 ∈ comap f I :=\n  coeff_zero_mem_comap_of_root_mem_of_eval_mem hr (Eq.symm hp ▸ ideal.zero_mem I)\n\ntheorem exists_coeff_ne_zero_mem_comap_of_non_zero_divisor_root_mem {R : Type u_1} [comm_ring R]\n    {S : Type u_2} [comm_ring S] {f : R →+* S} {I : ideal S} {r : S}\n    (r_non_zero_divisor : ∀ {x : S}, x * r = 0 → x = 0) (hr : r ∈ I) {p : polynomial R}\n    (p_ne_zero : p ≠ 0) (hp : polynomial.eval₂ f r p = 0) :\n    ∃ (i : ℕ), polynomial.coeff p i ≠ 0 ∧ polynomial.coeff p i ∈ comap f I :=\n  sorry\n\ntheorem exists_coeff_ne_zero_mem_comap_of_root_mem {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] {f : R →+* S} {I : ideal S} {r : S} (r_ne_zero : r ≠ 0) (hr : r ∈ I)\n    {p : polynomial R} (p_ne_zero : p ≠ 0) (hp : polynomial.eval₂ f r p = 0) :\n    ∃ (i : ℕ), polynomial.coeff p i ≠ 0 ∧ polynomial.coeff p i ∈ comap f I :=\n  exists_coeff_ne_zero_mem_comap_of_non_zero_divisor_root_mem\n    (fun (_x : S) (h : _x * r = 0) => or.resolve_right (iff.mp mul_eq_zero h) r_ne_zero) hr\n\ntheorem exists_coeff_mem_comap_sdiff_comap_of_root_mem_sdiff {R : Type u_1} [comm_ring R]\n    {S : Type u_2} [integral_domain S] {f : R →+* S} {I : ideal S} {J : ideal S} [is_prime I]\n    (hIJ : I ≤ J) {r : S} (hr : r ∈ ↑J \\ ↑I) {p : polynomial R}\n    (p_ne_zero : polynomial.map (quotient.mk (comap f I)) p ≠ 0)\n    (hpI : polynomial.eval₂ f r p ∈ I) :\n    ∃ (i : ℕ), polynomial.coeff p i ∈ ↑(comap f J) \\ ↑(comap f I) :=\n  sorry\n\ntheorem comap_ne_bot_of_root_mem {R : Type u_1} [comm_ring R] {S : Type u_2} [integral_domain S]\n    {f : R →+* S} {I : ideal S} {r : S} (r_ne_zero : r ≠ 0) (hr : r ∈ I) {p : polynomial R}\n    (p_ne_zero : p ≠ 0) (hp : polynomial.eval₂ f r p = 0) : comap f I ≠ ⊥ :=\n  sorry\n\ntheorem comap_lt_comap_of_root_mem_sdiff {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] {f : R →+* S} {I : ideal S} {J : ideal S} [is_prime I] (hIJ : I ≤ J) {r : S}\n    (hr : r ∈ ↑J \\ ↑I) {p : polynomial R}\n    (p_ne_zero : polynomial.map (quotient.mk (comap f I)) p ≠ 0) (hp : polynomial.eval₂ f r p ∈ I) :\n    comap f I < comap f J :=\n  sorry\n\ntheorem comap_ne_bot_of_algebraic_mem {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] {I : ideal S} [algebra R S] {x : S} (x_ne_zero : x ≠ 0) (x_mem : x ∈ I)\n    (hx : is_algebraic R x) : comap (algebra_map R S) I ≠ ⊥ :=\n  sorry\n\ntheorem comap_ne_bot_of_integral_mem {R : Type u_1} [comm_ring R] {S : Type u_2} [integral_domain S]\n    {I : ideal S} [algebra R S] [nontrivial R] {x : S} (x_ne_zero : x ≠ 0) (x_mem : x ∈ I)\n    (hx : is_integral R x) : comap (algebra_map R S) I ≠ ⊥ :=\n  comap_ne_bot_of_algebraic_mem x_ne_zero x_mem (is_integral.is_algebraic R hx)\n\ntheorem eq_bot_of_comap_eq_bot {R : Type u_1} [comm_ring R] {S : Type u_2} [integral_domain S]\n    {I : ideal S} [algebra R S] [nontrivial R] (hRS : algebra.is_integral R S)\n    (hI : comap (algebra_map R S) I = ⊥) : I = ⊥ :=\n  sorry\n\ntheorem mem_of_one_mem {S : Type u_2} [integral_domain S] {I : ideal S} (h : 1 ∈ I) (x : S) :\n    x ∈ I :=\n  Eq.symm (iff.mpr (eq_top_iff_one I) h) ▸ submodule.mem_top\n\ntheorem comap_lt_comap_of_integral_mem_sdiff {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] {I : ideal S} {J : ideal S} [algebra R S] [hI : is_prime I] (hIJ : I ≤ J)\n    {x : S} (mem : x ∈ ↑J \\ ↑I) (integral : is_integral R x) :\n    comap (algebra_map R S) I < comap (algebra_map R S) J :=\n  sorry\n\ntheorem is_maximal_of_is_integral_of_is_maximal_comap {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] (hRS : algebra.is_integral R S) (I : ideal S) [is_prime I]\n    (hI : is_maximal (comap (algebra_map R S) I)) : is_maximal I :=\n  sorry\n\ntheorem is_maximal_of_is_integral_of_is_maximal_comap' {R : Type u_1} {S : Type u_2} [comm_ring R]\n    [integral_domain S] (f : R →+* S) (hf : ring_hom.is_integral f) (I : ideal S) [hI' : is_prime I]\n    (hI : is_maximal (comap f I)) : is_maximal I :=\n  is_maximal_of_is_integral_of_is_maximal_comap hf I hI\n\ntheorem is_maximal_comap_of_is_integral_of_is_maximal {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] (hRS : algebra.is_integral R S) (I : ideal S)\n    [hI : is_maximal I] : is_maximal (comap (algebra_map R S) I) :=\n  sorry\n\ntheorem is_maximal_comap_of_is_integral_of_is_maximal' {R : Type u_1} {S : Type u_2} [comm_ring R]\n    [integral_domain S] (f : R →+* S) (hf : ring_hom.is_integral f) (I : ideal S)\n    (hI : is_maximal I) : is_maximal (comap f I) :=\n  is_maximal_comap_of_is_integral_of_is_maximal hf I\n\ntheorem integral_closure.comap_ne_bot {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] [nontrivial R] {I : ideal ↥(integral_closure R S)}\n    (I_ne_bot : I ≠ ⊥) : comap (algebra_map R ↥(integral_closure R S)) I ≠ ⊥ :=\n  sorry\n\ntheorem integral_closure.eq_bot_of_comap_eq_bot {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] [nontrivial R] {I : ideal ↥(integral_closure R S)} :\n    comap (algebra_map R ↥(integral_closure R S)) I = ⊥ → I = ⊥ :=\n  imp_of_not_imp_not (comap (algebra_map R ↥(integral_closure R S)) I = ⊥) (I = ⊥)\n    integral_closure.comap_ne_bot\n\ntheorem integral_closure.comap_lt_comap {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] {I : ideal ↥(integral_closure R S)}\n    {J : ideal ↥(integral_closure R S)} [is_prime I] (I_lt_J : I < J) :\n    comap (algebra_map R ↥(integral_closure R S)) I <\n        comap (algebra_map R ↥(integral_closure R S)) J :=\n  sorry\n\ntheorem integral_closure.is_maximal_of_is_maximal_comap {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] (I : ideal ↥(integral_closure R S)) [is_prime I]\n    (hI : is_maximal (comap (algebra_map R ↥(integral_closure R S)) I)) : is_maximal I :=\n  is_maximal_of_is_integral_of_is_maximal_comap\n    (fun (x : ↥(integral_closure R S)) => integral_closure.is_integral x) I hI\n\n/-- `comap (algebra_map R S)` is a surjection from the prime spec of `R` to prime spec of `S`.\n`hP : (algebra_map R S).ker ≤ P` is a slight generalization of the extension being injective -/\ntheorem exists_ideal_over_prime_of_is_integral' {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] (H : algebra.is_integral R S) (P : ideal R) [is_prime P]\n    (hP : ring_hom.ker (algebra_map R S) ≤ P) :\n    ∃ (Q : ideal S), is_prime Q ∧ comap (algebra_map R S) Q = P :=\n  sorry\n\n/-- More general going-up theorem than `exists_ideal_over_prime_of_is_integral'`.\nTODO: Version of going-up theorem with arbitrary length chains (by induction on this)?\n  Not sure how best to write an ascending chain in Lean -/\ntheorem exists_ideal_over_prime_of_is_integral {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] (H : algebra.is_integral R S) (P : ideal R) [is_prime P]\n    (I : ideal S) [is_prime I] (hIP : comap (algebra_map R S) I ≤ P) :\n    ∃ (Q : ideal S), ∃ (H : Q ≥ I), is_prime Q ∧ comap (algebra_map R S) Q = P :=\n  sorry\n\n/-- `comap (algebra_map R S)` is a surjection from the max spec of `S` to max spec of `R`.\n`hP : (algebra_map R S).ker ≤ P` is a slight generalization of the extension being injective -/\ntheorem exists_ideal_over_maximal_of_is_integral {R : Type u_1} [comm_ring R] {S : Type u_2}\n    [integral_domain S] [algebra R S] (H : algebra.is_integral R S) (P : ideal R)\n    [P_max : is_maximal P] (hP : ring_hom.ker (algebra_map R S) ≤ P) :\n    ∃ (Q : ideal S), is_maximal Q ∧ comap (algebra_map R S) Q = P :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/ideal/over_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225279, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.478856261749896}}
{"text": "/-\nCopyright (c) 2022 Flemming Hermansen. \nReleased under Apache 2.0 license as described in \nhttps://www.apache.org/licenses/LICENSE-2.0\nAuthors: Flemming Hermansen\n-/\n\nimport data.polynomial.basic\nimport data.polynomial.eval\nimport tactic\nimport tactic.basic\nimport ring_theory.algebraic\nimport ring_theory.ideal.quotient\nimport field_theory.separable\nimport field_theory.minpoly\nimport field_theory.splitting_field\nimport algebra.algebra.basic\nimport algebra.algebra.subalgebra.basic\nimport algebra.algebra.tower\nimport algebra.ring.basic\nimport data.finset.basic\nimport algebra.big_operators.basic\n\nimport ideals_rel_inv\n\nvariables {K : Type*} [hK : field K] \n{A : Type*} [hA : comm_ring A] [h_alg : algebra K A] \n  [h_fin : finite_dimensional K A] [h_sep : is_separable K A] (P : polynomial K)\n {finprod_fields : Type*} [hF : comm_ring finprod_fields] [h_alg_f : algebra K finprod_fields]\n------------------\nuniverses u \n\ndef Ka {K : Type*} {A : Type*} [hK : field K] \n [hA : comm_ring A] [h_alg : algebra K A] (a: A) := \n -- The problem is that a field (hK) is not accepted.\n -- An explicit comm_ring is required.\nalgebra.adjoin K ({a} : set A)\n\n/- -- Remove this line in order to see the errors\n-- Lean can not convert properly between fields and commutaative semirings.\n-- The unfold should work, but it is confused about these types:\nnoncomputable\nlemma Ka_eqv' {K : Type*} [hK : field K] \n{A : Type*} [hA : comm_ring A] [h_alg : algebra K A] (a : A) \n[h_fin : finite_dimensional K A] [h_sep : is_separable K A]: \n((@Ka K A hK hA h_alg a) : subalgebra K A ) ≃ₐ[K] \n(polynomial K ⧸ (ideal.span {minpoly K a} : ideal (polynomial K))) := \nbegin\n  -- Does not work: \n  unfold Ka,\n  sorry\nend\n\n@[priority 100] \ninstance field.to_comm_semiring' [s : field K] : comm_semiring K :=\n{ mul_zero := mul_zero, zero_mul := zero_mul, ..s }\n\ndef Ka' {K : Type*} {A : Type*} [hK : field K] \n [hA : comm_ring A] [h_alg : algebra K A] (a: A) := \n -- Does not work: \n @algebra.adjoin K A hK hA h_alg ({a} : set A).\n -- The problem is that a field (hK) is not accepted.\n -- An explicit comm_ring is required.\n\n#check Ka.\n#check adjoin_root.\n#check algebra.adjoin.\n-- -/\n\n\nnoncomputable\nlemma Ka_eqv {K : Type*} [hK : field K] \n{A : Type*} [hA : comm_ring A] [h_alg : algebra K A] \n(a : A) :\nalgebra.adjoin K ({a} : set A) ≃ₐ[K] \n(polynomial K ⧸ (ideal.span {minpoly K a} : ideal (polynomial K))) := \nbegin\n  exact @alg_equiv.adjoin_singleton_equiv_adjoin_root_minpoly K hK A hA h_alg a,\nend\n\n/-\nWe have the following lemmas:\n\nlemma Ka_eqv {K : Type*} [hK : field K] \n{A : Type*} [hA : comm_ring A] [h_alg : algebra K A] \n(a : A) :\nalgebra.adjoin K ({a} : set A) ≃ₐ[K] \n(polynomial K ⧸ (ideal.span {minpoly K a} : ideal (polynomial K))) \n\nlemma product_all_rel_inv {A : Type*} [comm_semigroup A] {A' : Type*} [comm_semigroup A']  \n  : ( all_rel_inv A) → ( all_rel_inv A')  → all_rel_inv (A × A')\n\nlemma field_all_rel_inv {A : Type} [field A] : all_rel_inv A\n\nnoncomputable def ideal.quotient_inf_ring_equiv_pi_quotient {R : Type*} [comm_ring R] \n {ι : Type v} [finite ι] (f : ι → ideal R) (hf : ∀ (i j : ι), i ≠ j → f i ⊔ f j = ⊤) :\n(R ⧸ ⨅ (i : ι), f i) ≃+* Π (i : ι), R ⧸ f i\n\nWe could however not combine these lemmas, because of errors in Lean. \n\nTherefore, we will just state the following lemma\n\nlemma from_chinese_lemma {K : Type*} [hK : field K] \n{A : Type*} [hA : comm_ring A] [h_alg : algebra K A]\n(h_sep : is_separable K A)\n(a : A) (h_algebraic : is_algebraic K a)\n: ∃ (b : A), is_rel_inv a b\n-/\n\nlemma from_chinese_lemma {K : Type*} [hK : field K] \n{A : Type*} [hA : comm_ring A] [h_alg : algebra K A]\n(h_sep : is_separable K A) (h_algebraic : algebra.is_algebraic K A)\n(a : A) \n: ∃ (b : A), is_rel_inv a b :=\nbegin\n  sorry\nend\n\nlemma all_rel_inv_of_alg_sep {K : Type*} [hK : field K] \n{A : Type*} [hA : comm_ring A] [h_alg : algebra K A]\n(h_sep : is_separable K A) (h_algebraic : algebra.is_algebraic K A) :\nall_rel_inv A :=\nbegin\n  unfold all_rel_inv,\n  intros a,\n  exact from_chinese_lemma h_sep h_algebraic a,\nend\n\n/-\nWe have proved the following theorems:\nThis theorem states that if e is an atom then e is the one-element in the ideal,\nand each non-zero element in the ideal has an inverse within the ideal. \nThis means that an ideal generated by an atom is a field.\nlemma field_from_atom {A : Type*} [hA : comm_ring A]  (h_inv : all_rel_inv A)\n{e a : A} (hnz_a : a ≠ 0) (hcov : covers_0 e) (ha_in_span : a ∈ ((ideal.span {e} : ideal A)) ) : \na * e = a ∧ \n( ∃ (b : A), b ∈ ((ideal.span {e} : ideal A)) ∧ a * b = e)\n\n-- This theorem states that a finite dimensional algebra has a \n-- finite set of atoms with sup = ⊤:\ntheorem ex_fin_atomset_of_finite_dimensional (K : Type*) \n[hK : field K] {A : Type*} \n  [h_comm_A : comm_ring A] [h_alg : algebra K A] (h_fin : finite_dimensional K A) : \n∃ (s : finset (idempotent_cri A)), (∀ e ∈ s, ⊥ ⋖ e) ∧ boolean_algebra_finset_sup s = ⊤ \n\nAtoms are pairwise disjoint. Therefore, boolean_algebra_finset_sup s = ⊤ means\nthat their sum is 1. \n\nWe have the direct sum decomposition of elements (a:A): a = a * 1 = a * Σ a * ei,\nwhere ei are the atoms. This decomposition is unique, because ei ≠ ej implies ei * ej = 0.\nThis means that A = Π (ideal generated by ei).\nEach of these ideals are isomorphic to field extensions of the scalar field.\n\nThis means that a finite dimensional separable commutative unital algebra is an\nEtale algebra.\n-/\n", "meta": {"author": "fhermansen", "repo": "Relative_inverses", "sha": "ef6682ab72c243dd829fe1cd7c1c96f003a075fa", "save_path": "github-repos/lean/fhermansen-Relative_inverses", "path": "github-repos/lean/fhermansen-Relative_inverses/Relative_inverses-ef6682ab72c243dd829fe1cd7c1c96f003a075fa/etale_algebras.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.4788562570737321}}
{"text": "import data.real.basic\nimport order.locally_finite\nimport data.fin.basic\nimport algebra.big_operators.ring\nimport data.nat.interval\nimport algebra.big_operators.intervals\nimport group_theory.group_action.basic\n\nvariables (d : ℕ) (x y : ℕ → ℝ)\n\nopen_locale big_operators\n\n-- finset.range j = finset.Ico 0 j = [0,j)\n\ndef majorizes_le : Prop :=\n  ∀ j < d, ∑ (i : ℕ) in finset.Ico 1 (j.succ), y i ≤ ∑ (i : ℕ) in finset.Ico 1 (j.succ), x i\n\ndef majorizes_eq : Prop :=\n  ∑ (i : ℕ) in finset.Ico 1 (d.succ), y i = ∑ (i : ℕ) in finset.Ico 1 (d.succ), x i\n\ndef T := ∑ (j : ℕ) in finset.Ico 1 (d.succ), j • (y j - x j)\n\nlemma T_one (x y : ℕ → ℝ) (h_maj : majorizes_eq d x y) :\n  T d x y = ∑ (i : ℕ) in finset.Ico 1 (d.succ), ∑ (j : ℕ) in finset.Ico 1 i, (x j - y j) :=\nbegin\n  rw T,\n  have : ∀ (j : ℕ), j • (y j - x j) = ∑ (i : ℕ) in finset.Ico 1 (j.succ), (y j - x j) :=\n  λ (j : ℕ), by simp only [tsub_zero, finset.sum_sub_distrib, nat.succ_sub_succ_eq_sub,\n    finset.sum_const, nsmul_eq_mul, nat.card_Ico],\n  simp only [this],\n  clear this,\n  have : ∑ (j : ℕ) in finset.Ico 1 (d.succ), ∑ (i : ℕ) in finset.Ico 1 (j.succ), (y j - x j)\n    = ∑ (i : ℕ) in finset.Ico 1 (d.succ), ∑ (j : ℕ) in finset.Ico i (d.succ), (y j - x j),\n  rw finset.sum_Ico_Ico_comm,\n  rw this,\n  clear this,\n  apply finset.sum_congr,\n  simp only [eq_self_iff_true],\n  intros i hi,\n  rw finset.mem_Ico at hi,\n  simp only [finset.sum_sub_distrib],\n  rw [sub_eq_iff_eq_add, add_comm, ← add_sub_assoc],\n  symmetry,\n  rw sub_eq_iff_eq_add,\n  rw add_comm,\n  rw finset.sum_Ico_consecutive _ hi.1 (le_of_lt hi.2),\n  rw add_comm,\n  rw finset.sum_Ico_consecutive _ hi.1 (le_of_lt hi.2),\n  rw majorizes_eq at h_maj,\n  symmetry,\n  exact h_maj,\nend\n\nlemma T_two (x y : ℕ → ℝ) (h_maj : majorizes_eq d x y) :\n  T d x y = ∑ (i : ℕ) in finset.Ico 1 (d.succ), ∑ (j : ℕ) in finset.Ico 1 i.succ, (x j - y j) :=\nbegin\n  rw T_one d x y h_maj,\n  have : ∑ (i : ℕ) in finset.Ico 1 d.succ, ∑ (j : ℕ) in finset.Ico 1 i.succ, (x j - y j) = \n    ∑ (i : ℕ) in finset.Ico 1 d.succ, (∑ (j : ℕ) in finset.Ico 1 i, (x j - y j) + (x i - y i)) :=\n  begin\n    apply finset.sum_congr,\n    simp only [eq_self_iff_true],\n    intros i hi,\n    rw finset.mem_Ico at hi,\n    rw finset.sum_Ico_succ_top hi.1,\n  end,\n  rw this,\n  rw finset.sum_add_distrib,\n  simp only [finset.sum_sub_distrib, self_eq_add_right, finset.sum_congr],\n  rw majorizes_eq at h_maj,\n  rw h_maj,\n  simp only [eq_self_iff_true, sub_self],\nend\n\nlemma T_three (x y : ℕ → ℝ) (h_d : 1 ≤ d) (h_maj : majorizes_eq d x y) :\n  T d x y = ∑ (i : ℕ) in finset.Ico 1 d, ∑ (j : ℕ) in finset.Ico 1 i.succ, (x j - y j) :=\nbegin\n  rw T_two d x y h_maj,\n  rw finset.sum_Ico_succ_top h_d,\n  simp only [add_right_eq_self, finset.sum_sub_distrib, finset.sum_congr],\n  rw majorizes_eq at h_maj,\n  rw h_maj,\n  simp only [eq_self_iff_true, sub_self],\nend\n\nlemma T_four (x y : ℕ → ℝ) (h_d : 1 ≤ d) (h_maj : majorizes_eq d x y) :\n  2 • (T d x y) = ∑ (i : ℕ) in finset.Ico 1 d, 2 • ∑ (j : ℕ) in finset.Ico 1 i.succ, (x j - y j) :=\nbegin\n  rw T_three _ _ _ h_d h_maj,\n  rw finset.smul_sum,\nend\n\nlemma norm_one (x y : ℕ → ℝ) (h_d : 1 ≤ d) :\n  ∑ (j : ℕ) in finset.Ico 1 d.succ, |x j - y j| = ∑ (j : ℕ) in finset.Ico 1 d, |x j - y j| + | x d - y d| :=\nbegin\n  rw finset.sum_Ico_succ_top h_d,\nend\n\nlemma norm_two (x y : ℕ → ℝ) (h_d : 1 ≤ d) (h_maj : majorizes_eq d x y) (h_majle : majorizes_le d x y):\n  |x d - y d| = ∑ (j : ℕ) in finset.Ico 1 d, (x j - y j) :=\nbegin\n  have : ∑ (j : ℕ) in finset.Ico 1 d.succ, (x j - y j) = 0 :=\n  begin\n    rw majorizes_eq at h_maj,\n    rw finset.sum_sub_distrib,\n    rw h_maj,\n    simp only [eq_self_iff_true, sub_self],\n  end,\n  have : x d - y d = ∑ (j : ℕ) in finset.Ico 1 d, (y j - x j) :=\n  begin\n    rw finset.sum_Ico_succ_top at this,\n    rw add_eq_zero_iff_neg_eq at this,\n    rw ← this,\n    norm_num,\n    exact h_d,\n  end,\n  rw this,\n  have : ∑ (j : ℕ) in finset.Ico 1 d, (x j - y j) = - ∑ (j : ℕ) in finset.Ico 1 d, (y j - x j) :=\n  begin\n    simp only [finset.sum_sub_distrib, eq_self_iff_true, neg_sub, sub_left_inj],\n  end,\n  rw this,\n  rw abs_eq_neg_self,\n  rw majorizes_le at h_majle,\n  specialize h_majle (d - 1),\n  simp only [finset.sum_sub_distrib, sub_nonpos],\n  simp at h_majle,\n  apply h_majle,\n  linarith,\nend\n\nlemma norm_three (x y : ℕ → ℝ) (h_d : 1 ≤ d) (h_maj : majorizes_eq d x y) (h_majle : majorizes_le d x y) :\n  ∑ (j : ℕ) in finset.Ico 1 d.succ, |x j - y j| = ∑ (j : ℕ) in finset.Ico 1 d, (|x j - y j| + (x j - y j)) :=\nbegin\n  rw norm_one _ _ _ h_d,\n  rw norm_two _ _ _ h_d h_maj h_majle,\n  rw finset.sum_add_distrib,\nend\n\nlemma norm_le_2T (x y : ℕ → ℝ) (h_d : 1 ≤ d) (h_majle : majorizes_le d x y) (h_maj : majorizes_eq d x y):\n  ∑ (j : ℕ) in finset.Ico 1 d, (|x j - y j| + (x j - y j)) ≤ 2 • (T d x y) :=\nbegin\n  rw T_four d x y h_d h_maj,\n  apply finset.sum_le_sum,\n  intros i hi,\n  by_cases (0 ≤ x i - y i),\n  have : |x i - y i| = x i - y i :=\n  begin\n    rw abs_eq_self,\n    exact h,\n  end,\n  rw this,\n  clear this,\n  rw finset.sum_Ico_succ_top,\n  simp only [finset.sum_sub_distrib, nat.cast_bit0, nsmul_eq_mul, nat.cast_one],\n  rw left_distrib,\n  have : x i - y i + (x i - y i) = 2 * (x i - y i),\n  ring,\n  rw this,\n  apply le_add_of_nonneg_left,\n  rw finset.mem_Ico at hi,\n  rw majorizes_le at h_majle,\n  specialize h_majle (i - 1),\n  rw zero_le_mul_left,\n  simp only [sub_nonneg],\n  have : i - 1 < d,\n  linarith,\n  apply h_majle this,\n  norm_num,\n  rw finset.mem_Ico at hi,\n  exact hi.1,\n  have : |x i - y i| = -(x i - y i) :=\n  begin\n    rw abs_eq_neg_self,\n    simp only [sub_nonpos],\n    simp at h,\n    exact le_of_lt h,\n  end,\n  rw this,\n  simp only [finset.sum_sub_distrib, sub_nonneg, nat.cast_bit0, zero_le_mul_left, nsmul_eq_mul,\n    neg_sub, nat.cast_one, sub_add_sub_cancel', sub_self],\n  rw majorizes_le at h_majle,\n  specialize h_majle i,\n  rw zero_le_mul_left,\n  rw sub_nonneg,\n  rw finset.mem_Ico at hi,\n  apply h_majle hi.2,\n  linarith,\nend", "meta": {"author": "Daniel-Packer", "repo": "paulsen-made-simple", "sha": "64f0b91375c6f9dfb959e47f347fa8a87b395e9a", "save_path": "github-repos/lean/Daniel-Packer-paulsen-made-simple", "path": "github-repos/lean/Daniel-Packer-paulsen-made-simple/paulsen-made-simple-64f0b91375c6f9dfb959e47f347fa8a87b395e9a/src/majorization.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.47879676795458176}}
{"text": "import Mathlib.Tactic.Basic\n\n-- For imperfect residue fields of characteristic 2 or 3 ther are new types:\n-- Z1, Z2, X1, X2, Y1, Y2, Y3, K n (n ≥ 2), K' n (even n ≥ 2), T n (n ≥ 1)\n\ninductive Kodaira where\n  | I     : Nat → Kodaira --for both I0 and In with n > 0\n  | II    : Kodaira\n  | III   : Kodaira\n  | IV    : Kodaira\n  | Is    : Nat → Kodaira\n  | IIs   : Kodaira\n  | IIIs  : Kodaira\n  | IVs   : Kodaira\n  | Z1    : Kodaira\n  | Z2    : Kodaira\n  | X1    : Kodaira\n  | X2    : Kodaira\n  | Y1    : Kodaira\n  | Y2    : Kodaira\n  | Y3    : Kodaira\n  | K     : Nat → Kodaira -- only occurs for n ≥ 2\n  | K'    : Nat → Kodaira -- only occurs for even n ≥ 2\n  | T     : Nat → Kodaira -- only occurs for n ≥ 1\n\nderiving DecidableEq, Inhabited\n\nopen Kodaira\n\ninstance : Repr Kodaira where\n  reprPrec\n    | I m, _   => \"I\" ++ repr m\n    | II, _    => \"II\"\n    | III, _   => \"III\"\n    | IV, _    => \"IV\"\n    | Is m, _  => \"I*\" ++ repr m\n    | IIs, _   => \"II*\"\n    | IIIs, _  => \"III*\"\n    | IVs, _   => \"IV*\"\n    | Z1, _    => \"Z1\"\n    | Z2, _    => \"Z2\"\n    | X1, _    => \"X1\"\n    | X2, _    => \"X2\"\n    | Y1, _    => \"Y1\"\n    | Y2, _    => \"Y2\"\n    | Y3, _    => \"Y3\"\n    | K m, _   => \"K\" ++ repr m\n    | K' m, _   => \"K'\" ++ repr m\n    | T m, _   => \"T\" ++ repr m\n\nlemma eq_I_Nat (m n : Nat) : m = n ↔ I m = I n := by\n  apply Iff.intro\n  intro h\n  exact congrArg I h\n  intro h\n  cases h\n  rfl\n\nlemma eq_Is_Nat (m n : Nat) : m = n ↔ Is m = Is n := by\n  apply Iff.intro\n  intro h\n  exact congrArg Is h\n  intro h\n  cases h\n  rfl\n\ninductive ReductionType\n  | Good\n  | SplitMultiplicative\n  | NonSplitMultiplicative\n  | Additive\nderiving DecidableEq, Repr, Inhabited\n\ndef ReductionType.to_lmfdb : ReductionType → Int\n  | Good                   => unreachable! -- LMFDB has no code for good reduction\n  | SplitMultiplicative    => 1\n  | NonSplitMultiplicative => -1\n  | Additive               => 0\n", "meta": {"author": "KisaraBlue", "repo": "ec-tate-lean", "sha": "2b1b26c2622fde0344feaadddc077caca73bd929", "save_path": "github-repos/lean/KisaraBlue-ec-tate-lean", "path": "github-repos/lean/KisaraBlue-ec-tate-lean/ec-tate-lean-2b1b26c2622fde0344feaadddc077caca73bd929/ECTate/Algebra/EllipticCurve/KodairaTypes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.47879676795458165}}
{"text": "\nimport category.basic\nimport util.data.functor\n\nuniverse variables u v w u' v' w'\n\nattribute [norm] seq_assoc pure_seq_eq_map map_pure\n\nclass applicative_pair (f : Type u → Type v) (g : Type u' → Type v') extends functor_pair f g :=\n (f_appl : applicative f)\n (g_appl : applicative g)\n (map_pure_comm : ∀ {α β}\n            (hp : α → β)\n            (x : α),\n    map hp (pure x) = pure (hp x))\n (map_seq_comm : ∀ {α β : Type u} {α' β' : Type u'}\n            (h : β → β')\n            (hx : (α → β) → (α' → β'))\n            (hy : α → α')\n            (x : f (α → β))\n            (y : f α),\n    (∀ F y, hx F (hy y) = h (F y)) →\n    map h (x <*> y) = map hx x <*> map hy y)\n\nsection lemmas\n\nvariables {α β γ : Type u}\nvariables {f : Type u → Type v}\nvariables [applicative f] [is_lawful_applicative f]\n\nopen function applicative is_lawful_applicative\n\nsection\n\nvariables (g : β → γ)\nvariables (x : f (α → β)) (y : f α)\n\nlemma  applicative.map_seq_assoc\n: @functor.map f _ _ _ g (x <*> y) = comp g <$> x <*> y :=\nby rw [← pure_seq_eq_map\n      ,seq_assoc\n      ,map_pure\n      ,pure_seq_eq_map]\n\nend\n\nsection\n\nopen is_lawful_functor\n\nvariables (g : α → β)\nvariables (x : f (β → γ)) (y : f α)\n\nlemma applicative.seq_map_comm\n: x <*> g <$> y = flip comp g <$> x <*> y :=\nbegin\n  rw [← pure_seq_eq_map _ y,seq_assoc,seq_pure,← comp_map],\n  refl,\nend\n\n-- lemma d\n-- : (has_seq.seq ∘ functor.map comp : f (α → β) → f (γ → α) → f (γ → β)) = _ :=\n-- begin\n--   apply funext, intro x,\n--   apply funext, intro y,\n--   unfold comp functor.map,\n--   rw [← right_id comp,functor.map_comp],\n-- end\n\nend\n\nattribute [norm] map_seq\n\n@[norm]\nlemma seq_map {β γ σ : Type u} (h : σ → β) (x : f (β → γ)) (y : f σ) :\n  x <*> (h <$> y) = (flip comp h) <$> x <*> y :=\nbegin\n  rw [← pure_seq_eq_map,← pure_seq_eq_map,seq_assoc] ,\n  simp with norm,refl\nend\n\nend lemmas\n\n/- identity applicative instance -/\n\nnamespace identity\n\nopen function\n\nvariables {α : Type u} {β : Type v} {γ : Type u'}\n\ndef pure : α → identity α := identity.mk\n\ndef seq : identity (α → β) → identity α → identity β\n  | ⟨ f ⟩ ⟨ x ⟩ := ⟨ f x ⟩\n\nlocal infix <$> := map\nlocal infix <*> := seq\n\nprotected lemma pure_seq_eq_map (g : α → β) : ∀ (x : identity α), pure g <*> x = g <$> x\n  | ⟨ x ⟩ := rfl\n\nprotected lemma map_pure (g : α → β) (x : α)\n: g <$> pure x = pure (g x) :=\nrfl\n\nprotected lemma seq_pure : ∀ (g : identity (α → β)) (x : α),\n  g <*> pure x = (λ g : α → β, g x) <$> g\n  | ⟨ g ⟩ x := rfl\n\nprotected lemma seq_assoc : ∀ (x : identity α) (g : identity (α → β)) (h : identity (β → γ)),\n  h <*> (g <*> x) = (@comp α β γ <$> h) <*> g <*> x\n| ⟨ x ⟩ ⟨ g ⟩ ⟨ h ⟩ := rfl\n\nend identity\n\ninstance applicative_identity : applicative identity :=\n{ map := @identity.map\n, seq := @identity.seq\n, pure := @identity.pure }\n\ninstance lawful_applicative_identity : is_lawful_applicative identity :=\n{ id_map := @identity.id_map\n, pure_seq_eq_map := @identity.pure_seq_eq_map\n, map_pure := @identity.map_pure\n, seq_pure := @identity.seq_pure\n, seq_assoc := @identity.seq_assoc }\n\n@[norm]\nlemma identity.mk_eq_pure {α : Type v} (x : α)\n: identity.mk x = pure x := rfl\n\nlemma identity.seq_mk {α β : Type v}  (f : α → β) (x : α)\n: identity.mk f <*> identity.mk x = identity.mk (f x) := rfl\n\ninstance : applicative_pair identity identity :=\n{ (by apply_instance : functor_pair identity identity) with\n  f_appl := by apply_instance\n, g_appl := by apply_instance\n, map_pure_comm :=\n  by { intros, refl }\n, map_seq_comm :=\n  begin\n    intros α β α' β',\n    intros h hx hy x y H,\n    cases x with x,\n    cases y with y,\n    unfold has_seq.seq identity.seq functor_pair.map identity.map,\n    rw H,\n  end }\n\n/- compose applicative instance -/\n\nnamespace compose\n\nopen function is_lawful_functor is_lawful_applicative\n\nsection applicative\n\nvariables {f : Type u → Type u'} {g : Type v → Type u}\n\nvariables [applicative f] [applicative g]\nsection\nvariables {α β γ : Type v}\n\ndef seq : compose f g (α → β) → compose f g α → compose f g β\n  | ⟨ h ⟩ ⟨ x ⟩ := ⟨ has_seq.seq <$> h <*> x ⟩\n\ndef pure : α → compose f g α := compose.mk ∘ has_pure.pure ∘ has_pure.pure\nend\n\nvariables [is_lawful_applicative f] [is_lawful_applicative g]\nvariables {α β γ : Type v}\n\nlocal infix ` <$> ` := map\nlocal infix ` <*> ` := seq\n\nprotected lemma map_pure (h : α → β) (x : α) : (h <$> pure x : compose f g β) = pure (h x) :=\nbegin\n  unfold compose.pure comp compose.map,\n  apply congr_arg,\n  rw [map_pure,map_pure],\nend\n\nprotected lemma seq_pure (h : compose f g (α → β)) (x : α)\n: h <*> pure x = (λ g : α → β, g x) <$> h :=\nbegin\n  cases h with h,\n  simp!  with norm,\n  apply congr_fun, apply congr_arg, funext,\n  simp with norm,\nend\n\nprotected lemma seq_assoc : ∀ (x : compose f g α) (h₀ : compose f g (α → β)) (h₁ : compose f g (β → γ)),\n   h₁ <*> (h₀ <*> x) = (@comp α β γ <$> h₁) <*> h₀ <*> x\n| ⟨ x ⟩ ⟨ h₀ ⟩ ⟨ h₁ ⟩ :=\nby { simp! [comp,flip] with norm, }\n\nlemma pure_seq_eq_map (h : α → β) : ∀ (x : compose f g α), pure h <*> x = h <$> x\n  | ⟨ x ⟩ :=\nbegin\n  simp!  with norm,\n  congr, funext, simp with norm,\nend\n\nend applicative\n\nend compose\n\ninstance applicative_compose\n  {f : Type u → Type u'} {g : Type v → Type u}\n  [applicative f] [applicative g]\n: applicative (compose f g) :=\n{ map := @compose.map f g _ _\n, seq := @compose.seq f g _ _\n, pure := @compose.pure f g _ _ }\n\ninstance lawful_applicative_compose\n  {f : Type u → Type u'} {g : Type v → Type u}\n  [applicative f] [applicative g]\n  [is_lawful_applicative f] [is_lawful_applicative g]\n: is_lawful_applicative (compose f g) :=\n{ id_map := @is_lawful_functor.id_map _ _ _\n, comp_map := @is_lawful_functor.comp_map _ _ _\n, pure_seq_eq_map := @compose.pure_seq_eq_map f g _ _ _ _\n, map_pure := @compose.map_pure f g _ _ _ _\n, seq_pure := @compose.seq_pure f g _ _ _ _\n, seq_assoc := @compose.seq_assoc f g _ _ _ _ }\n\n@[norm]\nlemma compose.seq_mk {α β : Type u'}\n  {f : Type u → Type v} {g : Type u' → Type u}\n  [applicative f] [applicative g]\n  (h : f (g (α → β))) (x : f (g α))\n: compose.mk h <*> compose.mk x = compose.mk (has_seq.seq <$> h <*> x) := rfl\n\nnamespace compose\n\nsection applicative_pair\n\nparameters {f :  Type v  → Type w}  {g  : Type u  → Type v}\nparameters {f' : Type v' → Type w'} {g' : Type u' → Type v'}\nparameters [applicative_pair f f'] [applicative_pair g g']\nparameters {α β : Type u} {α' β' : Type u'}\n\ninstance applicative_f : applicative f := applicative_pair.f_appl f f'\ninstance applicative_g : applicative g := applicative_pair.f_appl g g'\ninstance applicative_f' : applicative f' := applicative_pair.g_appl f f'\ninstance applicative_g' : applicative g' := applicative_pair.g_appl g g'\n\nlemma map_pure_comm (hp : α → β') (x : α)\n:   functor_pair.map (compose f' g') hp (compose.pure x : compose f g α)\n  = compose.pure (hp x) :=\nbegin\n  unfold compose.pure function.comp functor_pair.map map_pair,\n  apply congr_arg,\n  rw applicative_pair.map_pure_comm,\n  rw applicative_pair.map_pure_comm,\nend\n\nlemma map_seq_comm (h : β → β') (hx : (α → β) → α' → β') (hy : α → α')\n                   (x : compose f g (α → β)) (y : compose f g α)\n                   (H : ∀ (F : α → β) (y : α), hx F (hy y) = h (F y))\n:   functor_pair.map (compose f' g') h (x <*> y)\n  = functor_pair.map (compose f' g') hx x <*> functor_pair.map (compose f' g') hy y  :=\nbegin\n  cases x with x,\n  cases y with y,\n  unfold has_seq.seq compose.seq functor_pair.map map_pair,\n  apply congr_arg,\n  let x' : f (g α → g β) := functor.map has_seq.seq x,\n  let h' : g β → g' β' := (functor_pair.map g' h),\n  let hx' : (g α → g β) → g' α' → g' β' := λ F i, functor_pair.map _ h (F sorry),\n  let hy' : g α → g' α' := functor_pair.map _ hy,\n  let hh := @functor_pair.map g g' _ _ _ h,\n  have H' : (∀ (F : g α → g β) (y : g α), hx' F (hy' y) = h' (F y)) := sorry,\n  rw @applicative_pair.map_seq_comm f f' _ (g α) (g β) (g' α') (g' β')\n        h' hx' hy' x' y H',\n  admit,\nend\n\nend applicative_pair\n\nend compose\n\ninstance\n  {f :  Type v  → Type w}  {g  : Type u  → Type v}\n  {f' : Type v' → Type w'} {g' : Type u' → Type v'}\n  [applicative_pair f f'] [applicative_pair g g']\n: applicative_pair (compose f g) (compose f' g') :=\n{ (by apply_instance : functor_pair (compose f g) (compose f' g')) with\n  f_appl := by apply applicative_compose\n, g_appl := by apply applicative_compose\n, map_pure_comm := @compose.map_pure_comm f g f' g' _ _\n, map_seq_comm := @compose.map_seq_comm f g f' g' _ _ }\n\nnamespace applicative\n\ndef lift {m : Type u → Type v} [functor m] {α φ : Type u} (f : α → φ) (ma : m α) : m φ :=\nf <$> ma\n\nvariables {m : Type u → Type v} [applicative m]\ndef lift₂\n  {α₁ α₂ φ : Type u}\n  (f : α₁ → α₂ → φ)\n  (ma₁ : m α₁) (ma₂: m α₂) : m φ :=\nf <$> ma₁ <*> ma₂\n\ndef mmap₂\n  {α₁ α₂ φ : Type u}\n  (f : α₁ → α₂ → m φ)\n: Π (ma₁ : list α₁) (ma₂: list α₂), m (list φ)\n | (x :: xs) (y :: ys) := (::) <$> f x y <*> mmap₂ xs ys\n | _ _ := pure []\n\n\ndef lift₃\n  {α₁ α₂ α₃ φ : Type u}\n  (f : α₁ → α₂ → α₃ → φ)\n  (ma₁ : m α₁) (ma₂: m α₂) (ma₃ : m α₃) : m φ :=\nf <$> ma₁ <*> ma₂ <*> ma₃\n\ndef lift₄\n  {α₁ α₂ α₃ α₄ φ : Type u}\n  (f : α₁ → α₂ → α₃ → α₄ → φ)\n  (ma₁ : m α₁) (ma₂: m α₂) (ma₃ : m α₃) (ma₄ : m α₄) : m φ :=\nf <$> ma₁ <*> ma₂ <*> ma₃ <*> ma₄\n\ndef lift₅\n  {α₁ α₂ α₃ α₄ α₅ φ : Type u}\n  (f : α₁ → α₂ → α₃ → α₄ → α₅ → φ)\n  (ma₁ : m α₁) (ma₂: m α₂) (ma₃ : m α₃) (ma₄ : m α₄) (ma₅ : m α₅) : m φ :=\nf <$> ma₁ <*> ma₂ <*> ma₃ <*> ma₄ <*> ma₅\n\nopen nat\nvariables {α : Type u}\nvariables {β : Type v}\nvariables {γ : Type w}\n\ndef replicate : ℕ → m α → m (list α)\n | 0 _ := pure []\n | (succ n) m := (::) <$> m <*> replicate n m\n\ndef replicate' : ℕ → m α → m punit\n | 0 _ := pure punit.star\n | (succ n) m := m *> replicate' n m\n\ndef mapp (f : γ → β → α) : list (γ × β) → list α\n | [ ] := [ ]\n | ((x,y) :: xs) := f x y :: mapp xs\n\ndef mmapp (f : γ → β → m α) : list (γ × β) → m (list α)\n | [ ] := pure [ ]\n | ((x,y) :: xs) := (::) <$> f x y <*> mmapp xs\n\ndef mmapp' (f : γ → β → m α) : list (γ × β) → m punit\n | [ ] := pure punit.star\n | ((x,y) :: xs) := f x y *> mmapp' xs\n\nend applicative\n", "meta": {"author": "unitb", "repo": "lean-lib", "sha": "439b80e606b4ebe4909a08b1d77f4f5c0ee3dee9", "save_path": "github-repos/lean/unitb-lean-lib", "path": "github-repos/lean/unitb-lean-lib/lean-lib-439b80e606b4ebe4909a08b1d77f4f5c0ee3dee9/src/util/control/applicative.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.478767489485639}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Johan Commelin, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.linear_ordered_comm_group_with_zero\nimport Mathlib.algebra.group_power.default\nimport Mathlib.ring_theory.ideal.operations\nimport Mathlib.algebra.punit_instances\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n\n# The basics of valuation theory.\n\nThe basic theory of valuations (non-archimedean norms) on a commutative ring,\nfollowing T. Wedhorn's unpublished notes “Adic Spaces” ([wedhorn_adic]).\n\nThe definition of a valuation we use here is Definition 1.22 of [wedhorn_adic].\nA valuation on a ring `R` is a monoid homomorphism `v` to a linearly ordered\ncommutative group with zero, that in addition satisfies the following two axioms:\n * `v 0 = 0`\n * `∀ x y, v (x + y) ≤ max (v x) (v y)`\n\n`valuation R Γ₀`is the type of valuations `R → Γ₀`, with a coercion to the underlying\nfunction. If `v` is a valuation from `R` to `Γ₀` then the induced group\nhomomorphism `units(R) → Γ₀` is called `unit_map v`.\n\nThe equivalence \"relation\" `is_equiv v₁ v₂ : Prop` defined in 1.27 of [wedhorn_adic] is not strictly\nspeaking a relation, because `v₁ : valuation R Γ₁` and `v₂ : valuation R Γ₂` might\nnot have the same type. This corresponds in ZFC to the set-theoretic difficulty\nthat the class of all valuations (as `Γ₀` varies) on a ring `R` is not a set.\nThe \"relation\" is however reflexive, symmetric and transitive in the obvious\nsense. Note that we use 1.27(iii) of [wedhorn_adic] as the definition of equivalence.\n\nThe support of a valuation `v : valuation R Γ₀` is `supp v`. If `J` is an ideal of `R`\nwith `h : J ⊆ supp v` then the induced valuation\non R / J = `ideal.quotient J` is `on_quot v h`.\n\n## Main definitions\n\n* `valuation R Γ₀`, the type of valuations on `R` with values in `Γ₀`\n* `valuation.is_equiv`, the heterogeneous equivalence relation on valuations\n* `valuation.supp`, the support of a valuation\n\n-/\n\n-- universes u u₀ u₁ u₂ -- v is used for valuations\n\n/-- The type of Γ₀-valued valuations on R. -/\nstructure valuation (R : Type u_1) (Γ₀ : Type u_2) [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    extends monoid_with_zero_hom R Γ₀ where\n  map_add' : ∀ (x y : R), to_fun (x + y) ≤ max (to_fun x) (to_fun y)\n\n/-- The `monoid_with_zero_hom` underlying a valuation. -/\nnamespace valuation\n\n\n/-- A valuation is coerced to the underlying function R → Γ₀. -/\nprotected instance has_coe_to_fun (R : Type u_1) (Γ₀ : Type u_2)\n    [linear_ordered_comm_group_with_zero Γ₀] [ring R] : has_coe_to_fun (valuation R Γ₀) :=\n  has_coe_to_fun.mk (fun (_x : valuation R Γ₀) => R → Γ₀) to_fun\n\n/-- A valuation is coerced to a monoid morphism R → Γ₀. -/\nprotected instance monoid_with_zero_hom.has_coe (R : Type u_1) (Γ₀ : Type u_2)\n    [linear_ordered_comm_group_with_zero Γ₀] [ring R] :\n    has_coe (valuation R Γ₀) (monoid_with_zero_hom R Γ₀) :=\n  has_coe.mk to_monoid_with_zero_hom\n\n@[simp] theorem coe_coe {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) : ⇑↑v = ⇑v :=\n  rfl\n\n@[simp] theorem map_zero {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) : coe_fn v 0 = 0 :=\n  map_zero' v\n\n@[simp] theorem map_one {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) : coe_fn v 1 = 1 :=\n  map_one' v\n\n@[simp] theorem map_mul {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) (x : R) (y : R) : coe_fn v (x * y) = coe_fn v x * coe_fn v y :=\n  map_mul' v\n\n@[simp] theorem map_add {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) (x : R) (y : R) :\n    coe_fn v (x + y) ≤ max (coe_fn v x) (coe_fn v y) :=\n  map_add' v\n\ntheorem map_add_le {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) {x : R} {y : R} {g : Γ₀} (hx : coe_fn v x ≤ g) (hy : coe_fn v y ≤ g) :\n    coe_fn v (x + y) ≤ g :=\n  le_trans (map_add v x y) (max_le hx hy)\n\ntheorem map_add_lt {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) {x : R} {y : R} {g : Γ₀} (hx : coe_fn v x < g) (hy : coe_fn v y < g) :\n    coe_fn v (x + y) < g :=\n  lt_of_le_of_lt (map_add v x y) (max_lt hx hy)\n\ntheorem map_sum_le {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) {ι : Type u_3} {s : finset ι} {f : ι → R} {g : Γ₀}\n    (hf : ∀ (i : ι), i ∈ s → coe_fn v (f i) ≤ g) : coe_fn v (finset.sum s fun (i : ι) => f i) ≤ g :=\n  sorry\n\ntheorem map_sum_lt {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) {ι : Type u_3} {s : finset ι} {f : ι → R} {g : Γ₀} (hg : g ≠ 0)\n    (hf : ∀ (i : ι), i ∈ s → coe_fn v (f i) < g) : coe_fn v (finset.sum s fun (i : ι) => f i) < g :=\n  sorry\n\ntheorem map_sum_lt' {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) {ι : Type u_3} {s : finset ι} {f : ι → R} {g : Γ₀} (hg : 0 < g)\n    (hf : ∀ (i : ι), i ∈ s → coe_fn v (f i) < g) : coe_fn v (finset.sum s fun (i : ι) => f i) < g :=\n  map_sum_lt v (ne_of_gt hg) hf\n\n@[simp] theorem map_pow {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) (x : R) (n : ℕ) : coe_fn v (x ^ n) = coe_fn v x ^ n :=\n  monoid_hom.map_pow (monoid_with_zero_hom.to_monoid_hom (to_monoid_with_zero_hom v))\n\ntheorem ext {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    {v₁ : valuation R Γ₀} {v₂ : valuation R Γ₀} (h : ∀ (r : R), coe_fn v₁ r = coe_fn v₂ r) :\n    v₁ = v₂ :=\n  sorry\n\ntheorem ext_iff {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    {v₁ : valuation R Γ₀} {v₂ : valuation R Γ₀} : v₁ = v₂ ↔ ∀ (r : R), coe_fn v₁ r = coe_fn v₂ r :=\n  { mp := fun (h : v₁ = v₂) (r : R) => congr_arg (fun {v₁ : valuation R Γ₀} => coe_fn v₁ r) h,\n    mpr := ext }\n\n-- The following definition is not an instance, because we have more than one `v` on a given `R`.\n\n-- In addition, type class inference would not be able to infer `v`.\n\n/-- A valuation gives a preorder on the underlying ring. -/\ndef to_preorder {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) : preorder R :=\n  preorder.lift ⇑v\n\n/-- If `v` is a valuation on a division ring then `v(x) = 0` iff `x = 0`. -/\n@[simp] theorem zero_iff {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] {K : Type u_1}\n    [division_ring K] (v : valuation K Γ₀) {x : K} : coe_fn v x = 0 ↔ x = 0 :=\n  monoid_with_zero_hom.map_eq_zero (to_monoid_with_zero_hom v)\n\ntheorem ne_zero_iff {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] {K : Type u_1}\n    [division_ring K] (v : valuation K Γ₀) {x : K} : coe_fn v x ≠ 0 ↔ x ≠ 0 :=\n  monoid_with_zero_hom.map_ne_zero (to_monoid_with_zero_hom v)\n\n@[simp] theorem map_inv {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] {K : Type u_1}\n    [division_ring K] (v : valuation K Γ₀) {x : K} : coe_fn v (x⁻¹) = (coe_fn v x⁻¹) :=\n  monoid_with_zero_hom.map_inv' (to_monoid_with_zero_hom v) x\n\ntheorem map_units_inv {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) (x : units R) : coe_fn v ↑(x⁻¹) = (coe_fn v ↑x⁻¹) :=\n  monoid_hom.map_units_inv (monoid_with_zero_hom.to_monoid_hom (to_monoid_with_zero_hom v)) x\n\ntheorem unit_map_eq {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) (u : units R) : ↑(coe_fn (units.map ↑v) u) = coe_fn v ↑u :=\n  rfl\n\n@[simp] theorem map_neg {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) (x : R) : coe_fn v (-x) = coe_fn v x :=\n  monoid_hom.map_neg (monoid_with_zero_hom.to_monoid_hom (to_monoid_with_zero_hom v)) x\n\ntheorem map_sub_swap {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) (x : R) (y : R) : coe_fn v (x - y) = coe_fn v (y - x) :=\n  monoid_hom.map_sub_swap (monoid_with_zero_hom.to_monoid_hom (to_monoid_with_zero_hom v)) x y\n\ntheorem map_sub_le_max {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) (x : R) (y : R) :\n    coe_fn v (x - y) ≤ max (coe_fn v x) (coe_fn v y) :=\n  sorry\n\ntheorem map_add_of_distinct_val {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [ring R] (v : valuation R Γ₀) {x : R} {y : R}\n    (h : coe_fn v x ≠ coe_fn v y) : coe_fn v (x + y) = max (coe_fn v x) (coe_fn v y) :=\n  sorry\n\ntheorem map_eq_of_sub_lt {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) {x : R} {y : R} (h : coe_fn v (y - x) < coe_fn v x) :\n    coe_fn v y = coe_fn v x :=\n  sorry\n\n/-- A ring homomorphism S → R induces a map valuation R Γ₀ → valuation S Γ₀ -/\ndef comap {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    {S : Type u_3} [ring S] (f : S →+* R) (v : valuation R Γ₀) : valuation S Γ₀ :=\n  mk (⇑v ∘ ⇑f) sorry sorry sorry sorry\n\n@[simp] theorem comap_id {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [ring R] (v : valuation R Γ₀) : comap (ring_hom.id R) v = v :=\n  ext fun (r : R) => rfl\n\ntheorem comap_comp {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    (v : valuation R Γ₀) {S₁ : Type u_3} {S₂ : Type u_4} [ring S₁] [ring S₂] (f : S₁ →+* S₂)\n    (g : S₂ →+* R) : comap (ring_hom.comp g f) v = comap f (comap g v) :=\n  ext fun (r : S₁) => rfl\n\n/-- A ≤-preserving group homomorphism Γ₀ → Γ'₀ induces a map valuation R Γ₀ → valuation R Γ'₀. -/\ndef map {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] {Γ'₀ : Type u_3}\n    [linear_ordered_comm_group_with_zero Γ'₀] [ring R] (f : monoid_with_zero_hom Γ₀ Γ'₀)\n    (hf : monotone ⇑f) (v : valuation R Γ₀) : valuation R Γ'₀ :=\n  mk (⇑f ∘ ⇑v) sorry sorry sorry sorry\n\n/-- Two valuations on R are defined to be equivalent if they induce the same preorder on R. -/\ndef is_equiv {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    {Γ'₀ : Type u_3} [linear_ordered_comm_group_with_zero Γ'₀] [ring R] (v₁ : valuation R Γ₀)\n    (v₂ : valuation R Γ'₀) :=\n  ∀ (r s : R), coe_fn v₁ r ≤ coe_fn v₁ s ↔ coe_fn v₂ r ≤ coe_fn v₂ s\n\nnamespace is_equiv\n\n\ntheorem refl {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    {v : valuation R Γ₀} : is_equiv v v :=\n  fun (_x _x_1 : R) => iff.refl (coe_fn v _x ≤ coe_fn v _x_1)\n\ntheorem symm {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    {Γ'₀ : Type u_3} [linear_ordered_comm_group_with_zero Γ'₀] [ring R] {v₁ : valuation R Γ₀}\n    {v₂ : valuation R Γ'₀} (h : is_equiv v₁ v₂) : is_equiv v₂ v₁ :=\n  fun (_x _x_1 : R) => iff.symm (h _x _x_1)\n\ntheorem trans {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    {Γ'₀ : Type u_3} [linear_ordered_comm_group_with_zero Γ'₀] {Γ''₀ : Type u_4}\n    [linear_ordered_comm_group_with_zero Γ''₀] [ring R] {v₁ : valuation R Γ₀} {v₂ : valuation R Γ'₀}\n    {v₃ : valuation R Γ''₀} (h₁₂ : is_equiv v₁ v₂) (h₂₃ : is_equiv v₂ v₃) : is_equiv v₁ v₃ :=\n  fun (_x _x_1 : R) => iff.trans (h₁₂ _x _x_1) (h₂₃ _x _x_1)\n\ntheorem of_eq {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] [ring R]\n    {v : valuation R Γ₀} {v' : valuation R Γ₀} (h : v = v') : is_equiv v v' :=\n  Eq._oldrec refl h\n\ntheorem map {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀] {Γ'₀ : Type u_3}\n    [linear_ordered_comm_group_with_zero Γ'₀] [ring R] {v : valuation R Γ₀} {v' : valuation R Γ₀}\n    (f : monoid_with_zero_hom Γ₀ Γ'₀) (hf : monotone ⇑f) (inf : function.injective ⇑f)\n    (h : is_equiv v v') : is_equiv (map f hf v) (map f hf v') :=\n  sorry\n\n/-- `comap` preserves equivalence. -/\ntheorem comap {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    {Γ'₀ : Type u_3} [linear_ordered_comm_group_with_zero Γ'₀] [ring R] {v₁ : valuation R Γ₀}\n    {v₂ : valuation R Γ'₀} {S : Type u_4} [ring S] (f : S →+* R) (h : is_equiv v₁ v₂) :\n    is_equiv (comap f v₁) (comap f v₂) :=\n  fun (r s : S) => h (coe_fn f r) (coe_fn f s)\n\ntheorem val_eq {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    {Γ'₀ : Type u_3} [linear_ordered_comm_group_with_zero Γ'₀] [ring R] {v₁ : valuation R Γ₀}\n    {v₂ : valuation R Γ'₀} (h : is_equiv v₁ v₂) {r : R} {s : R} :\n    coe_fn v₁ r = coe_fn v₁ s ↔ coe_fn v₂ r = coe_fn v₂ s :=\n  sorry\n\ntheorem ne_zero {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    {Γ'₀ : Type u_3} [linear_ordered_comm_group_with_zero Γ'₀] [ring R] {v₁ : valuation R Γ₀}\n    {v₂ : valuation R Γ'₀} (h : is_equiv v₁ v₂) {r : R} : coe_fn v₁ r ≠ 0 ↔ coe_fn v₂ r ≠ 0 :=\n  eq.mp (Eq._oldrec (Eq.refl (coe_fn v₁ r ≠ 0 ↔ coe_fn v₂ r ≠ coe_fn v₂ 0)) (map_zero v₂))\n    (eq.mp\n      (Eq._oldrec (Eq.refl (coe_fn v₁ r ≠ coe_fn v₁ 0 ↔ coe_fn v₂ r ≠ coe_fn v₂ 0)) (map_zero v₁))\n      (not_iff_not_of_iff (val_eq h)))\n\ntheorem Mathlib.valuation.is_equiv_of_map_strict_mono {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] {Γ'₀ : Type u_3}\n    [linear_ordered_comm_group_with_zero Γ'₀] [ring R] {v : valuation R Γ₀}\n    (f : monoid_with_zero_hom Γ₀ Γ'₀) (H : strict_mono ⇑f) :\n    is_equiv (map f (strict_mono.monotone H) v) v :=\n  fun (x y : R) =>\n    { mp := iff.mp (strict_mono.le_iff_le H),\n      mpr := fun (h : coe_fn v x ≤ coe_fn v y) => strict_mono.monotone H h }\n\ntheorem Mathlib.valuation.is_equiv_of_val_le_one {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] {Γ'₀ : Type u_3}\n    [linear_ordered_comm_group_with_zero Γ'₀] {K : Type u_1} [division_ring K] (v : valuation K Γ₀)\n    (v' : valuation K Γ'₀) (h : ∀ {x : K}, coe_fn v x ≤ 1 ↔ coe_fn v' x ≤ 1) : is_equiv v v' :=\n  sorry\n\n/-- The support of a valuation `v : R → Γ₀` is the ideal of `R` where `v` vanishes. -/\ndef Mathlib.valuation.supp {R : Type u_1} {Γ₀ : Type u_2} [linear_ordered_comm_group_with_zero Γ₀]\n    [comm_ring R] (v : valuation R Γ₀) : ideal R :=\n  submodule.mk (set_of fun (x : R) => coe_fn v x = 0) sorry sorry sorry\n\n-- @[simp] lemma mem_supp_iff' (x : R) : x ∈ (supp v : set R) ↔ v x = 0 := iff.rfl\n\n@[simp] theorem Mathlib.valuation.mem_supp_iff {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) (x : R) :\n    x ∈ supp v ↔ coe_fn v x = 0 :=\n  iff.rfl\n\n/-- The support of a valuation is a prime ideal. -/\nprotected instance Mathlib.valuation.supp.ideal.is_prime {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) :\n    ideal.is_prime (supp v) :=\n  { left :=\n      fun (h : supp v = ⊤) =>\n        one_ne_zero\n          ((fun (this : 1 = 0) => this)\n            (Eq.trans (Eq.symm (map_one v))\n              ((fun (this : 1 ∈ supp v) => this)\n                (eq.mpr (id (Eq._oldrec (Eq.refl (1 ∈ supp v)) h)) trivial)))),\n    right :=\n      fun (x y : R) (hxy : x * y ∈ supp v) =>\n        id\n          (id\n            (fun (hxy : coe_fn v (x * y) = 0) =>\n              eq_zero_or_eq_zero_of_mul_eq_zero\n                (eq.mp (Eq._oldrec (Eq.refl (coe_fn v (x * y) = 0)) (map_mul v x y)) hxy))\n            hxy) }\n\ntheorem Mathlib.valuation.map_add_supp {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) (a : R) {s : R}\n    (h : s ∈ supp v) : coe_fn v (a + s) = coe_fn v a :=\n  sorry\n\n/-- If `hJ : J ⊆ supp v` then `on_quot_val hJ` is the induced function on R/J as a function.\nNote: it's just the function; the valuation is `on_quot hJ`. -/\ndef Mathlib.valuation.on_quot_val {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) {J : ideal R}\n    (hJ : J ≤ supp v) : ideal.quotient J → Γ₀ :=\n  fun (q : ideal.quotient J) => quotient.lift_on' q ⇑v sorry\n\n/-- The extension of valuation v on R to valuation on R/J if J ⊆ supp v -/\ndef Mathlib.valuation.on_quot {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) {J : ideal R}\n    (hJ : J ≤ supp v) : valuation (ideal.quotient J) Γ₀ :=\n  mk (on_quot_val v hJ) sorry sorry sorry sorry\n\n@[simp] theorem Mathlib.valuation.on_quot_comap_eq {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) {J : ideal R}\n    (hJ : J ≤ supp v) : comap (ideal.quotient.mk J) (on_quot v hJ) = v :=\n  sorry\n\ntheorem Mathlib.valuation.comap_supp {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) {S : Type u_3}\n    [comm_ring S] (f : S →+* R) : supp (comap f v) = ideal.comap f (supp v) :=\n  sorry\n\ntheorem Mathlib.valuation.self_le_supp_comap {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (J : ideal R)\n    (v : valuation (ideal.quotient J) Γ₀) : J ≤ supp (comap (ideal.quotient.mk J) v) :=\n  sorry\n\n@[simp] theorem Mathlib.valuation.comap_on_quot_eq {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (J : ideal R)\n    (v : valuation (ideal.quotient J) Γ₀) :\n    on_quot (comap (ideal.quotient.mk J) v) (self_le_supp_comap J v) = v :=\n  sorry\n\n/-- The quotient valuation on R/J has support supp(v)/J if J ⊆ supp v. -/\ntheorem Mathlib.valuation.supp_quot {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) {J : ideal R}\n    (hJ : J ≤ supp v) : supp (on_quot v hJ) = ideal.map (ideal.quotient.mk J) (supp v) :=\n  sorry\n\ntheorem Mathlib.valuation.supp_quot_supp {R : Type u_1} {Γ₀ : Type u_2}\n    [linear_ordered_comm_group_with_zero Γ₀] [comm_ring R] (v : valuation R Γ₀) :\n    supp (on_quot v (le_refl (supp v))) = 0 :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (supp (on_quot v (le_refl (supp v))) = 0))\n        (supp_quot v (le_refl (supp v)))))\n    (ideal.map_quotient_self (supp v))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/valuation/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4787674894856389}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebraic_geometry.presheafed_space\nimport topology.category.Top.limits\nimport topology.sheaves.limits\n\n/-!\n# `PresheafedSpace C` has colimits.\n\nIf `C` has limits, then the category `PresheafedSpace C` has colimits,\nand the forgetful functor to `Top` preserves these colimits.\n\nWhen restricted to a diagram where the underlying continuous maps are open embeddings,\nthis says that we can glue presheaved spaces.\n\nGiven a diagram `F : J ⥤ PresheafedSpace C`,\nwe first build the colimit of the underlying topological spaces,\nas `colimit (F ⋙ PresheafedSpace.forget C)`. Call that colimit space `X`.\n\nOur strategy is to push each of the presheaves `F.obj j`\nforward along the continuous map `colimit.ι (F ⋙ PresheafedSpace.forget C) j` to `X`.\nSince pushforward is functorial, we obtain a diagram `J ⥤ (presheaf C X)ᵒᵖ`\nof presheaves on a single space `X`.\n(Note that the arrows now point the other direction,\nbecause this is the way `PresheafedSpace C` is set up.)\n\nThe limit of this diagram then constitutes the colimit presheaf.\n-/\n\nnoncomputable theory\n\nuniverses v' u' v u\n\nopen category_theory\nopen Top\nopen Top.presheaf\nopen topological_space\nopen opposite\nopen category_theory.category\nopen category_theory.limits\nopen category_theory.functor\n\nvariables {J : Type u'} [category.{v'} J]\nvariables {C : Type u} [category.{v} C]\n\n\nnamespace algebraic_geometry\n\nnamespace PresheafedSpace\n\nlocal attribute [simp] eq_to_hom_map\nlocal attribute [tidy] tactic.auto_cases_opens\n\n@[simp]\nlemma map_id_c_app (F : J ⥤ PresheafedSpace.{v} C) (j) (U) :\n  (F.map (𝟙 j)).c.app (op U) =\n    (pushforward.id (F.obj j).presheaf).inv.app (op U) ≫\n      (pushforward_eq (by { simp, refl }) (F.obj j).presheaf).hom.app (op U) :=\nbegin\n  cases U,\n  dsimp,\n  simp [PresheafedSpace.congr_app (F.map_id j)],\n  refl,\nend\n\n@[simp]\n\n\n/--\nGiven a diagram of `PresheafedSpace C`s, its colimit is computed by pushing the sheaves onto\nthe colimit of the underlying spaces, and taking componentwise limit.\nThis is the componentwise diagram for an open set `U` of the colimit of the underlying spaces.\n-/\n@[simps]\ndef componentwise_diagram (F : J ⥤ PresheafedSpace.{v} C)\n  [has_colimit F] (U : opens (limits.colimit F).carrier) : Jᵒᵖ ⥤ C :=\n{ obj := λ j, (F.obj (unop j)).presheaf.obj (op ((opens.map (colimit.ι F (unop j)).base).obj U)),\n  map := λ j k f, (F.map f.unop).c.app _ ≫ (F.obj (unop k)).presheaf.map\n    (eq_to_hom (by { rw [← colimit.w F f.unop, comp_base], refl })),\n  map_comp' := λ i j k f g,\n  begin\n    cases U,\n    dsimp,\n    simp_rw [map_comp_c_app, category.assoc],\n    congr' 1,\n    rw [Top.presheaf.pushforward.comp_inv_app, Top.presheaf.pushforward_eq_hom_app,\n      category_theory.nat_trans.naturality_assoc, Top.presheaf.pushforward_map_app],\n    congr' 1,\n    rw [category.id_comp, ← (F.obj (unop k)).presheaf.map_comp],\n    erw ← (F.obj (unop k)).presheaf.map_comp,\n    congr\n  end }\n\nvariable [has_colimits_of_shape J Top.{v}]\n\n/--\nGiven a diagram of presheafed spaces,\nwe can push all the presheaves forward to the colimit `X` of the underlying topological spaces,\nobtaining a diagram in `(presheaf C X)ᵒᵖ`.\n-/\n@[simps]\ndef pushforward_diagram_to_colimit (F : J ⥤ PresheafedSpace.{v} C) :\n  J ⥤ (presheaf C (colimit (F ⋙ PresheafedSpace.forget C)))ᵒᵖ :=\n{ obj := λ j, op ((colimit.ι (F ⋙ PresheafedSpace.forget C) j) _* (F.obj j).presheaf),\n  map := λ j j' f,\n  (pushforward_map (colimit.ι (F ⋙ PresheafedSpace.forget C) j') (F.map f).c ≫\n    (pushforward.comp (F.obj j).presheaf ((F ⋙ PresheafedSpace.forget C).map f)\n      (colimit.ι (F ⋙ PresheafedSpace.forget C) j')).inv ≫\n    (pushforward_eq (colimit.w (F ⋙ PresheafedSpace.forget C) f) (F.obj j).presheaf).hom).op,\n  map_id' := λ j,\n  begin\n    apply (op_equiv _ _).injective,\n    ext U,\n    induction U using opposite.rec,\n    cases U,\n    dsimp, simp, dsimp, simp,\n  end,\n  map_comp' := λ j₁ j₂ j₃ f g,\n  begin\n    apply (op_equiv _ _).injective,\n    ext U,\n    dsimp,\n    simp only [map_comp_c_app, id.def, eq_to_hom_op, pushforward_map_app, eq_to_hom_map, assoc,\n      id_comp, pushforward.comp_inv_app, pushforward_eq_hom_app],\n    dsimp,\n    simp only [eq_to_hom_trans, id_comp],\n    congr' 1,\n    -- The key fact is `(F.map f).c.congr`,\n    -- which allows us in rewrite in the argument of `(F.map f).c.app`.\n    rw (F.map f).c.congr,\n    -- Now we pick up the pieces. First, we say what we want to replace that open set by:\n    swap 3,\n    refine op ((opens.map (colimit.ι (F ⋙ PresheafedSpace.forget C) j₂)).obj (unop U)),\n    -- Now we show the open sets are equal.\n    swap 2,\n    { apply unop_injective,\n      rw ←opens.map_comp_obj,\n      congr,\n      exact colimit.w (F ⋙ PresheafedSpace.forget C) g, },\n    -- Finally, the original goal is now easy:\n    swap 2,\n    { simp, refl, },\n  end, }\n\nvariables [∀ X : Top.{v}, has_limits_of_shape Jᵒᵖ (X.presheaf C)]\n\n/--\nAuxiliary definition for `PresheafedSpace.has_colimits`.\n-/\ndef colimit (F : J ⥤ PresheafedSpace.{v} C) : PresheafedSpace C :=\n{ carrier := colimit (F ⋙ PresheafedSpace.forget C),\n  presheaf := limit (pushforward_diagram_to_colimit F).left_op, }\n\n@[simp] lemma colimit_carrier (F : J ⥤ PresheafedSpace.{v} C) :\n  (colimit F).carrier = limits.colimit (F ⋙ PresheafedSpace.forget C) := rfl\n\n@[simp] lemma colimit_presheaf (F : J ⥤ PresheafedSpace.{v} C) :\n  (colimit F).presheaf = limit (pushforward_diagram_to_colimit F).left_op := rfl\n\n/--\nAuxiliary definition for `PresheafedSpace.has_colimits`.\n-/\n@[simps]\ndef colimit_cocone (F : J ⥤ PresheafedSpace.{v} C) : cocone F :=\n{ X := colimit F,\n  ι :=\n  { app := λ j,\n    { base := colimit.ι (F ⋙ PresheafedSpace.forget C) j,\n      c := limit.π _ (op j), },\n    naturality' := λ j j' f,\n    begin\n      fapply PresheafedSpace.ext,\n      { ext x,\n        exact colimit.w_apply (F ⋙ PresheafedSpace.forget C) f x, },\n      { ext U,\n        induction U using opposite.rec,\n        cases U,\n        dsimp,\n        simp only [PresheafedSpace.id_c_app, eq_to_hom_op, eq_to_hom_map, assoc,\n          pushforward.comp_inv_app],\n        rw ← congr_arg nat_trans.app (limit.w (pushforward_diagram_to_colimit F).left_op f.op),\n        dsimp,\n        simp only [eq_to_hom_op, eq_to_hom_map, assoc, id_comp, pushforward.comp_inv_app],\n        congr,\n        dsimp,\n        simp only [id_comp],\n        simpa, }\n    end, }, }\n\nvariables [has_limits_of_shape Jᵒᵖ C]\n\nnamespace colimit_cocone_is_colimit\n\n/--\nAuxiliary definition for `PresheafedSpace.colimit_cocone_is_colimit`.\n-/\ndef desc_c_app (F : J ⥤ PresheafedSpace.{v} C) (s : cocone F) (U : (opens ↥(s.X.carrier))ᵒᵖ) :\n  s.X.presheaf.obj U ⟶\n    (colimit.desc (F ⋙ PresheafedSpace.forget C)\n         ((PresheafedSpace.forget C).map_cocone s) _*\n       limit (pushforward_diagram_to_colimit F).left_op).obj\n      U :=\nbegin\n  refine\n    limit.lift _ { X := s.X.presheaf.obj U, π := { app := λ j, _, naturality' := λ j j' f, _, }} ≫\n      (limit_obj_iso_limit_comp_evaluation _ _).inv,\n  -- We still need to construct the `app` and `naturality'` fields omitted above.\n  { refine (s.ι.app (unop j)).c.app U ≫ (F.obj (unop j)).presheaf.map (eq_to_hom _),\n    dsimp,\n    rw ←opens.map_comp_obj,\n    simp, },\n  { rw (PresheafedSpace.congr_app (s.w f.unop).symm U),\n    dsimp,\n    have w := functor.congr_obj (congr_arg opens.map\n      (colimit.ι_desc ((PresheafedSpace.forget C).map_cocone s) (unop j))) (unop U),\n    simp only [opens.map_comp_obj_unop] at w,\n    replace w := congr_arg op w,\n    have w' := nat_trans.congr (F.map f.unop).c w,\n    rw w',\n    dsimp, simp, dsimp, simp, },\nend\n\nlemma desc_c_naturality (F : J ⥤ PresheafedSpace.{v} C) (s : cocone F)\n  {U V : (opens ↥(s.X.carrier))ᵒᵖ} (i : U ⟶ V) :\n  s.X.presheaf.map i ≫ desc_c_app F s V =\n  desc_c_app F s U ≫ (colimit.desc (F ⋙ forget C)\n    ((forget C).map_cocone s) _* (colimit_cocone F).X.presheaf).map i :=\nbegin\n  dsimp [desc_c_app],\n  ext,\n  simp only [limit.lift_π, nat_trans.naturality, limit.lift_π_assoc, eq_to_hom_map, assoc,\n    pushforward_obj_map, nat_trans.naturality_assoc, op_map,\n    limit_obj_iso_limit_comp_evaluation_inv_π_app_assoc,\n    limit_obj_iso_limit_comp_evaluation_inv_π_app],\n  dsimp,\n  have w := functor.congr_hom (congr_arg opens.map\n    (colimit.ι_desc ((PresheafedSpace.forget C).map_cocone s) (unop j))) (i.unop),\n  simp only [opens.map_comp_map] at w,\n  replace w := congr_arg quiver.hom.op w,\n  rw w,\n  dsimp, simp,\nend\n\n/--\nAuxiliary definition for `PresheafedSpace.colimit_cocone_is_colimit`.\n-/\ndef desc (F : J ⥤ PresheafedSpace.{v} C) (s : cocone F) : colimit F ⟶ s.X :=\n{ base := colimit.desc (F ⋙ PresheafedSpace.forget C) ((PresheafedSpace.forget C).map_cocone s),\n  c :=\n  { app := λ U, desc_c_app F s U,\n    naturality' := λ U V i, desc_c_naturality F s i } }\n\nlemma desc_fac  (F : J ⥤ PresheafedSpace.{v} C) (s : cocone F) (j : J) :\n  (colimit_cocone F).ι.app j ≫ desc F s = s.ι.app j :=\nbegin\n  fapply PresheafedSpace.ext,\n  { simp [desc] },\n  { ext,\n    dsimp [desc, desc_c_app],\n    simpa }\nend\n\nend colimit_cocone_is_colimit\n\nopen colimit_cocone_is_colimit\n\n/--\nAuxiliary definition for `PresheafedSpace.has_colimits`.\n-/\ndef colimit_cocone_is_colimit (F : J ⥤ PresheafedSpace.{v} C) : is_colimit (colimit_cocone F) :=\n{ desc := λ s, desc F s,\n  fac' := λ s, desc_fac F s,\n  uniq' := λ s m w,\n  begin\n    -- We need to use the identity on the continuous maps twice, so we prepare that first:\n    have t : m.base = colimit.desc (F ⋙ PresheafedSpace.forget C)\n                        ((PresheafedSpace.forget C).map_cocone s),\n    { apply category_theory.limits.colimit.hom_ext, intros j,\n      apply continuous_map.ext, intros x,\n      dsimp,\n      simp only [colimit.ι_desc_apply, map_cocone_ι_app],\n      rw ← w j,\n      simp, },\n    fapply PresheafedSpace.ext, -- could `ext` please not reorder goals?\n    { exact t, },\n    { ext U j, dsimp [desc, desc_c_app],\n      simp only [limit.lift_π, eq_to_hom_op, eq_to_hom_map, assoc,\n        limit_obj_iso_limit_comp_evaluation_inv_π_app],\n      rw PresheafedSpace.congr_app (w (unop j)).symm U,\n      dsimp,\n      have w := congr_arg op (functor.congr_obj (congr_arg opens.map t) (unop U)),\n      rw nat_trans.congr (limit.π (pushforward_diagram_to_colimit F).left_op j) w,\n      simp }\n  end, }\n\ninstance : has_colimits_of_shape J (PresheafedSpace.{v} C) :=\n{ has_colimit := λ F, has_colimit.mk\n  { cocone     := colimit_cocone F,\n    is_colimit := colimit_cocone_is_colimit F } }\n\ninstance : preserves_colimits_of_shape J (PresheafedSpace.forget C) :=\n{ preserves_colimit := λ F, preserves_colimit_of_preserves_colimit_cocone\n  (colimit_cocone_is_colimit F)\n  begin\n    apply is_colimit.of_iso_colimit (colimit.is_colimit _),\n    fapply cocones.ext,\n    { refl, },\n    { intro j, dsimp, simp, }\n  end }\n\n/--\nWhen `C` has limits, the category of presheaved spaces with values in `C` itself has colimits.\n-/\ninstance [has_limits C] : has_colimits (PresheafedSpace.{v} C) :=\n{ has_colimits_of_shape := λ J 𝒥, by exactI\n  { has_colimit := λ F, has_colimit.mk\n    { cocone     := colimit_cocone F,\n      is_colimit := colimit_cocone_is_colimit F } } }\n\n/--\nThe underlying topological space of a colimit of presheaved spaces is\nthe colimit of the underlying topological spaces.\n-/\ninstance forget_preserves_colimits [has_limits C] : preserves_colimits (PresheafedSpace.forget C) :=\n{ preserves_colimits_of_shape := λ J 𝒥, by exactI\n  { preserves_colimit := λ F, preserves_colimit_of_preserves_colimit_cocone\n    (colimit_cocone_is_colimit F)\n    begin\n      apply is_colimit.of_iso_colimit (colimit.is_colimit _),\n      fapply cocones.ext,\n      { refl, },\n      { intro j, dsimp, simp, }\n    end } }\n\n/--\nThe components of the colimit of a diagram of `PresheafedSpace C` is obtained\nvia taking componentwise limits.\n-/\ndef colimit_presheaf_obj_iso_componentwise_limit (F : J ⥤ PresheafedSpace.{v} C) [has_colimit F]\n  (U : opens (limits.colimit F).carrier) :\n  (limits.colimit F).presheaf.obj (op U) ≅ limit (componentwise_diagram F U) :=\nbegin\n  refine ((sheaf_iso_of_iso (colimit.iso_colimit_cocone\n    ⟨_, colimit_cocone_is_colimit F⟩).symm).app (op U)).trans _,\n  refine (limit_obj_iso_limit_comp_evaluation _ _).trans (limits.lim.map_iso _),\n  fapply nat_iso.of_components,\n  { intro X,\n    refine ((F.obj (unop X)).presheaf.map_iso (eq_to_iso _)),\n    simp only [functor.op_obj, unop_op, op_inj_iff, opens.map_coe, set_like.ext'_iff,\n      set.preimage_preimage],\n    simp_rw ← comp_app,\n    congr' 2,\n    exact ι_preserves_colimits_iso_inv (forget C) F (unop X) },\n  { intros X Y f,\n    change ((F.map f.unop).c.app _ ≫ _ ≫ _) ≫ (F.obj (unop Y)).presheaf.map _ = _ ≫ _,\n    rw Top.presheaf.pushforward.comp_inv_app,\n    erw category.id_comp,\n    rw category.assoc,\n    erw [← (F.obj (unop Y)).presheaf.map_comp, (F.map f.unop).c.naturality_assoc,\n      ← (F.obj (unop Y)).presheaf.map_comp],\n    congr }\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_inv_ι_app (F : J ⥤ PresheafedSpace.{v} C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n  (colimit_presheaf_obj_iso_componentwise_limit F U).inv ≫ (colimit.ι F j).c.app (op U) =\n    limit.π _ (op j) :=\nbegin\n  delta colimit_presheaf_obj_iso_componentwise_limit,\n  rw [iso.trans_inv, iso.trans_inv, iso.app_inv, sheaf_iso_of_iso_inv, pushforward_to_of_iso_app,\n    congr_app (iso.symm_inv _)],\n  simp_rw category.assoc,\n  rw [← functor.map_comp_assoc, nat_trans.naturality],\n  erw ← comp_c_app_assoc,\n  rw congr_app (colimit.iso_colimit_cocone_ι_hom _ _),\n  simp_rw category.assoc,\n  erw [limit_obj_iso_limit_comp_evaluation_inv_π_app_assoc, lim_map_π_assoc],\n  convert category.comp_id _,\n  erw ← (F.obj j).presheaf.map_id,\n  iterate 2 { erw ← (F.obj j).presheaf.map_comp },\n  congr\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_hom_π (F : J ⥤ PresheafedSpace.{v} C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n    (colimit_presheaf_obj_iso_componentwise_limit F U).hom ≫ limit.π _ (op j) =\n      (colimit.ι F j).c.app (op U) :=\nby rw [← iso.eq_inv_comp, colimit_presheaf_obj_iso_componentwise_limit_inv_ι_app]\n\nend PresheafedSpace\n\nend algebraic_geometry\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_geometry/presheafed_space/has_colimits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6442251133170356, "lm_q1q2_score": 0.47876748723281665}}
{"text": "/-\nCopyright (c) 2021 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport analysis.special_functions.integrals\nimport topology.metric_space.contracting\n\n/-!\n# Picard-Lindelöf (Cauchy-Lipschitz) Theorem\n\nIn this file we prove that an ordinary differential equation $\\dot x=v(t, x)$ such that $v$ is\nLipschitz continuous in $x$ and continuous in $t$ has a local solution, see\n`exists_forall_deriv_within_Icc_eq_of_lipschitz_of_continuous`.\n\n## Implementation notes\n\nIn order to split the proof into small lemmas, we introduce a structure `picard_lindelof` that holds\nall assumptions of the main theorem. This structure and lemmas in the `picard_lindelof` namespace\nshould be treated as private implementation details.\n\nWe only prove existence of a solution in this file. For uniqueness see `ODE_solution_unique` and\nrelated theorems in `analysis.ODE.gronwall`.\n\n## Tags\n\ndifferential equation\n-/\n\nopen filter function set metric topological_space interval_integral measure_theory\nopen measure_theory.measure_space (volume)\nopen_locale filter topological_space nnreal ennreal nat interval\n\nnoncomputable theory\n\nvariables {E : Type*} [normed_group E] [normed_space ℝ E]\n\n/-- This structure holds arguments of the Picard-Lipschitz (Cauchy-Lipschitz) theorem. Unless you\nwant to use one of the auxiliary lemmas, use\n`exists_forall_deriv_within_Icc_eq_of_lipschitz_of_continuous` instead of using this structure. -/\nstructure picard_lindelof (E : Type*) [normed_group E] [normed_space ℝ E] :=\n(to_fun : ℝ → E → E)\n(t_min t_max : ℝ)\n(t₀ : Icc t_min t_max)\n(x₀ : E)\n(C R L : ℝ≥0)\n(lipschitz' : ∀ t ∈ Icc t_min t_max, lipschitz_on_with L (to_fun t) (closed_ball x₀ R))\n(cont : ∀ x ∈ closed_ball x₀ R, continuous_on (λ t, to_fun t x) (Icc t_min t_max))\n(norm_le' : ∀ (t ∈ Icc t_min t_max) (x ∈ closed_ball x₀ R), ∥to_fun t x∥ ≤ C)\n(C_mul_le_R : (C : ℝ) * max (t_max - t₀) (t₀ - t_min) ≤ R)\n\nnamespace picard_lindelof\n\nvariables (v : picard_lindelof E)\n\ninstance : has_coe_to_fun (picard_lindelof E) (λ _, ℝ → E → E) := ⟨to_fun⟩\n\ninstance : inhabited (picard_lindelof E) :=\n⟨⟨0, 0, 0, ⟨0, le_rfl, le_rfl⟩, 0, 0, 0, 0, λ t ht, (lipschitz_with.const 0).lipschitz_on_with _,\n  λ _ _, by simpa only [pi.zero_apply] using continuous_on_const, λ t ht x hx, norm_zero.le,\n  (zero_mul _).le⟩⟩\n\nlemma t_min_le_t_max : v.t_min ≤ v.t_max := v.t₀.2.1.trans v.t₀.2.2\n\nprotected lemma nonempty_Icc : (Icc v.t_min v.t_max).nonempty := nonempty_Icc.2 v.t_min_le_t_max\n\nprotected \n\nprotected lemma continuous_on :\n  continuous_on (uncurry v) ((Icc v.t_min v.t_max).prod (closed_ball v.x₀ v.R)) :=\nhave continuous_on (uncurry (flip v)) ((closed_ball v.x₀ v.R).prod (Icc v.t_min v.t_max)),\n  from continuous_on_prod_of_continuous_on_lipschitz_on _ v.L v.cont v.lipschitz',\nthis.comp continuous_swap.continuous_on preimage_swap_prod.symm.subset\n\nlemma norm_le {t : ℝ} (ht : t ∈ Icc v.t_min v.t_max) {x : E} (hx : x ∈ closed_ball v.x₀ v.R) :\n  ∥v t x∥ ≤ v.C :=\nv.norm_le' _ ht _ hx\n\n/-- The maximum of distances from `t₀` to the endpoints of `[t_min, t_max]`. -/\ndef t_dist : ℝ := max (v.t_max - v.t₀) (v.t₀ - v.t_min)\n\nlemma t_dist_nonneg : 0 ≤ v.t_dist := le_max_iff.2 $ or.inl $ sub_nonneg.2 v.t₀.2.2\n\nlemma dist_t₀_le (t : Icc v.t_min v.t_max) : dist t v.t₀ ≤ v.t_dist :=\nbegin\n  rw [subtype.dist_eq, real.dist_eq],\n  cases le_total t v.t₀ with ht ht,\n  { rw [abs_of_nonpos (sub_nonpos.2 $ subtype.coe_le_coe.2 ht), neg_sub],\n    exact (sub_le_sub_left t.2.1 _).trans (le_max_right _ _) },\n  { rw [abs_of_nonneg (sub_nonneg.2 $ subtype.coe_le_coe.2 ht)],\n    exact (sub_le_sub_right t.2.2 _).trans (le_max_left _ _) }\nend\n\n/-- Projection $ℝ → [t_{\\min}, t_{\\max}]$ sending $(-∞, t_{\\min}]$ to $t_{\\min}$ and $[t_{\\max}, ∞)$\nto $t_{\\max}$. -/\ndef proj : ℝ → Icc v.t_min v.t_max := proj_Icc v.t_min v.t_max v.t_min_le_t_max\n\nlemma proj_coe (t : Icc v.t_min v.t_max) : v.proj t = t := proj_Icc_coe _ _\n\nlemma proj_of_mem {t : ℝ} (ht : t ∈ Icc v.t_min v.t_max) : ↑(v.proj t) = t :=\nby simp only [proj, proj_Icc_of_mem _ ht, subtype.coe_mk]\n\n@[continuity] lemma continuous_proj : continuous v.proj := continuous_proj_Icc\n\n/-- The space of curves $γ \\colon [t_{\\min}, t_{\\max}] \\to E$ such that $γ(t₀) = x₀$ and $γ$ is\nLipschitz continuous with constant $C$. The map sending $γ$ to\n$\\mathbf Pγ(t)=x₀ + ∫_{t₀}^{t} v(τ, γ(τ))\\,dτ$ is a contracting map on this space, and its fixed\npoint is a solution of the ODE $\\dot x=v(t, x)$. -/\nstructure fun_space :=\n(to_fun : Icc v.t_min v.t_max → E)\n(map_t₀' : to_fun v.t₀ = v.x₀)\n(lipschitz' : lipschitz_with v.C to_fun)\n\nnamespace fun_space\n\nvariables {v} (f : fun_space v)\n\ninstance : has_coe_to_fun (fun_space v) (λ _, Icc v.t_min v.t_max → E) := ⟨to_fun⟩\n\ninstance : inhabited v.fun_space :=\n⟨⟨λ _, v.x₀, rfl, (lipschitz_with.const _).weaken (zero_le _)⟩⟩\n\nprotected lemma lipschitz : lipschitz_with v.C f := f.lipschitz'\n\nprotected lemma continuous : continuous f := f.lipschitz.continuous\n\n/-- Each curve in `picard_lindelof.fun_space` is continuous. -/\ndef to_continuous_map : v.fun_space ↪ C(Icc v.t_min v.t_max, E) :=\n⟨λ f, ⟨f, f.continuous⟩, λ f g h, by { cases f, cases g, simpa using h }⟩\n\ninstance : metric_space v.fun_space :=\nmetric_space.induced to_continuous_map to_continuous_map.injective infer_instance\n\nlemma uniform_inducing_to_continuous_map : uniform_inducing (@to_continuous_map _ _ _ v) := ⟨rfl⟩\n\nlemma range_to_continuous_map :\n  range to_continuous_map =\n    {f : C(Icc v.t_min v.t_max, E) | f v.t₀ = v.x₀ ∧ lipschitz_with v.C f} :=\nbegin\n  ext f, split,\n  { rintro ⟨⟨f, hf₀, hf_lip⟩, rfl⟩, exact ⟨hf₀, hf_lip⟩ },\n  { rcases f with ⟨f, hf⟩, rintro ⟨hf₀, hf_lip⟩, exact ⟨⟨f, hf₀, hf_lip⟩, rfl⟩ }\nend\n\nlemma map_t₀ : f v.t₀ = v.x₀ := f.map_t₀'\n\nprotected lemma mem_closed_ball (t : Icc v.t_min v.t_max) : f t ∈ closed_ball v.x₀ v.R :=\ncalc dist (f t) v.x₀ = dist (f t) (f.to_fun v.t₀) : by rw f.map_t₀'\n                 ... ≤ v.C * dist t v.t₀          : f.lipschitz.dist_le_mul _ _\n                 ... ≤ v.C * v.t_dist             : mul_le_mul_of_nonneg_left (v.dist_t₀_le _) v.C.2\n                 ... ≤ v.R                        : v.C_mul_le_R\n\n/-- Given a curve $γ \\colon [t_{\\min}, t_{\\max}] → E$, `v_comp` is the function\n$F(t)=v(π t, γ(π t))$, where `π` is the projection $ℝ → [t_{\\min}, t_{\\max}]$. The integral of this\nfunction is the image of `γ` under the contracting map we are going to define below. -/\ndef v_comp (t : ℝ) : E := v (v.proj t) (f (v.proj t))\n\nlemma v_comp_apply_coe (t : Icc v.t_min v.t_max) : f.v_comp t = v t (f t) :=\nby simp only [v_comp, proj_coe]\n\nlemma continuous_v_comp : continuous f.v_comp :=\nbegin\n  have := (continuous_subtype_coe.prod_mk f.continuous).comp v.continuous_proj,\n  refine continuous_on.comp_continuous v.continuous_on this (λ x, _),\n  exact ⟨(v.proj x).2, f.mem_closed_ball _⟩\nend\n\nlemma norm_v_comp_le (t : ℝ) : ∥f.v_comp t∥ ≤ v.C :=\nv.norm_le (v.proj t).2 $ f.mem_closed_ball _\n\nlemma dist_apply_le_dist (f₁ f₂ : fun_space v) (t : Icc v.t_min v.t_max) :\n  dist (f₁ t) (f₂ t) ≤ dist f₁ f₂ :=\n@continuous_map.dist_apply_le_dist _ _ _ _ _ f₁.to_continuous_map f₂.to_continuous_map _\n\nlemma dist_le_of_forall {f₁ f₂ : fun_space v} {d : ℝ} (h : ∀ t, dist (f₁ t) (f₂ t) ≤ d) :\n  dist f₁ f₂ ≤ d :=\n(@continuous_map.dist_le_iff_of_nonempty _ _ _ _ _ f₁.to_continuous_map f₂.to_continuous_map _\n  v.nonempty_Icc.to_subtype).2 h\n\ninstance [complete_space E] : complete_space v.fun_space :=\nbegin\n  refine (complete_space_iff_is_complete_range\n    uniform_inducing_to_continuous_map).2 (is_closed.is_complete _),\n  rw [range_to_continuous_map, set_of_and],\n  refine (is_closed_eq (continuous_map.continuous_evalx _) continuous_const).inter _,\n  have : is_closed {f : Icc v.t_min v.t_max → E | lipschitz_with v.C f} :=\n    is_closed_set_of_lipschitz_with v.C,\n  exact this.preimage continuous_map.continuous_coe\nend\n\nvariables [measurable_space E] [borel_space E]\n\nlemma interval_integrable_v_comp (t₁ t₂ : ℝ) :\n  interval_integrable f.v_comp volume t₁ t₂ :=\n(f.continuous_v_comp).interval_integrable _ _\n\nvariables [second_countable_topology E] [complete_space E]\n\n/-- The Picard-Lindelöf operator. This is a contracting map on `picard_lindelof.fun_space v` such\nthat the fixed point of this map is the solution of the corresponding ODE.\n\nMore precisely, some iteration of this map is a contracting map. -/\ndef next (f : fun_space v) : fun_space v :=\n{ to_fun := λ t, v.x₀ + ∫ τ : ℝ in v.t₀..t, f.v_comp τ,\n  map_t₀' := by rw [integral_same, add_zero],\n  lipschitz' := lipschitz_with.of_dist_le_mul $ λ t₁ t₂,\n    begin\n      rw [dist_add_left, dist_eq_norm,\n        integral_interval_sub_left (f.interval_integrable_v_comp _ _)\n          (f.interval_integrable_v_comp _ _)],\n      exact norm_integral_le_of_norm_le_const (λ t ht, f.norm_v_comp_le _),\n    end }\n\nlemma next_apply (t : Icc v.t_min v.t_max) : f.next t = v.x₀ + ∫ τ : ℝ in v.t₀..t, f.v_comp τ := rfl\n\nlemma has_deriv_within_at_next (t : Icc v.t_min v.t_max) :\n  has_deriv_within_at (f.next ∘ v.proj) (v t (f t)) (Icc v.t_min v.t_max) t :=\nbegin\n  haveI : fact ((t : ℝ) ∈ Icc v.t_min v.t_max) := ⟨t.2⟩,\n  simp only [(∘), next_apply],\n  refine has_deriv_within_at.const_add _ _,\n  have : has_deriv_within_at (λ t : ℝ, ∫ τ in v.t₀..t, f.v_comp τ) (f.v_comp t)\n    (Icc v.t_min v.t_max) t,\n    from integral_has_deriv_within_at_right (f.interval_integrable_v_comp _ _)\n      (f.continuous_v_comp.measurable_at_filter _ _) f.continuous_v_comp.continuous_within_at,\n  rw v_comp_apply_coe at this,\n  refine this.congr_of_eventually_eq_of_mem _ t.coe_prop,\n  filter_upwards [self_mem_nhds_within],\n  intros t' ht',\n  rw v.proj_of_mem ht'\nend\n\nlemma dist_next_apply_le_of_le {f₁ f₂ : fun_space v} {n : ℕ} {d : ℝ}\n  (h : ∀ t, dist (f₁ t) (f₂ t) ≤ (v.L * |t - v.t₀|) ^ n / n! * d) (t : Icc v.t_min v.t_max) :\n  dist (next f₁ t) (next f₂ t) ≤ (v.L * |t - v.t₀|) ^ (n + 1) / (n + 1)! * d :=\nbegin\n  simp only [dist_eq_norm, next_apply, add_sub_add_left_eq_sub,\n    ← interval_integral.integral_sub (interval_integrable_v_comp _ _ _)\n      (interval_integrable_v_comp _ _ _), norm_integral_eq_norm_integral_Ioc] at *,\n  calc ∥∫ τ in Ι (v.t₀ : ℝ) t, f₁.v_comp τ - f₂.v_comp τ∥\n      ≤ ∫ τ in Ι (v.t₀ : ℝ) t, v.L * ((v.L * |τ - v.t₀|) ^ n / n! * d) :\n    begin\n      refine norm_integral_le_of_norm_le (continuous.integrable_on_interval_oc _) _,\n      { continuity },\n      { refine (ae_restrict_mem measurable_set_Ioc).mono (λ τ hτ, _),\n        refine (v.lipschitz_on_with (v.proj τ).2).norm_sub_le_of_le\n          (f₁.mem_closed_ball _) (f₂.mem_closed_ball _) ((h _).trans_eq _),\n        rw v.proj_of_mem,\n        exact (interval_subset_Icc v.t₀.2 t.2 $ Ioc_subset_Icc_self hτ) }\n    end\n  ... = (v.L * |t - v.t₀|) ^ (n + 1) / (n + 1)! * d : _,\n  simp_rw [mul_pow, div_eq_mul_inv, mul_assoc, measure_theory.integral_mul_left,\n    measure_theory.integral_mul_right, integral_pow_abs_sub_interval_oc, div_eq_mul_inv,\n    pow_succ (v.L : ℝ), nat.factorial_succ, nat.cast_mul, nat.cast_succ, mul_inv₀, mul_assoc]\nend\n\nlemma dist_iterate_next_apply_le (f₁ f₂ : fun_space v) (n : ℕ) (t : Icc v.t_min v.t_max) :\n  dist (next^[n] f₁ t) (next^[n] f₂ t) ≤ (v.L * |t - v.t₀|) ^ n / n! * dist f₁ f₂ :=\nbegin\n  induction n with n ihn generalizing t,\n  { rw [pow_zero, nat.factorial_zero, nat.cast_one, div_one, one_mul],\n    exact dist_apply_le_dist f₁ f₂ t },\n  { rw [iterate_succ_apply', iterate_succ_apply'],\n    exact dist_next_apply_le_of_le ihn _ }\nend\n\nlemma dist_iterate_next_le (f₁ f₂ : fun_space v) (n : ℕ) :\n  dist (next^[n] f₁) (next^[n] f₂) ≤ (v.L * v.t_dist) ^ n / n! * dist f₁ f₂ :=\nbegin\n  refine dist_le_of_forall (λ t, (dist_iterate_next_apply_le _ _ _ _).trans _),\n  have : 0 ≤ dist f₁ f₂ := dist_nonneg,\n  have : |(t - v.t₀ : ℝ)| ≤ v.t_dist := v.dist_t₀_le t,\n  mono*; simp only [nat.cast_nonneg, mul_nonneg, nnreal.coe_nonneg, abs_nonneg, *]\nend\n\nend fun_space\n\nvariables [second_countable_topology E] [complete_space E]\n\nsection\nvariables [measurable_space E] [borel_space E]\n\nlemma exists_contracting_iterate :\n  ∃ (N : ℕ) K, contracting_with K ((fun_space.next : v.fun_space → v.fun_space)^[N]) :=\nbegin\n  rcases ((real.tendsto_pow_div_factorial_at_top (v.L * v.t_dist)).eventually\n    (gt_mem_nhds zero_lt_one)).exists with ⟨N, hN⟩,\n  have : (0 : ℝ) ≤ (v.L * v.t_dist) ^ N / N!,\n    from div_nonneg (pow_nonneg (mul_nonneg v.L.2 v.t_dist_nonneg) _) (nat.cast_nonneg _),\n  exact ⟨N, ⟨_, this⟩, hN,\n    lipschitz_with.of_dist_le_mul (λ f g, fun_space.dist_iterate_next_le f g N)⟩\nend\n\nlemma exists_fixed : ∃ f : v.fun_space, f.next = f :=\nlet ⟨N, K, hK⟩ := exists_contracting_iterate v in ⟨_, hK.is_fixed_pt_fixed_point_iterate⟩\n\nend\n\n/-- Picard-Lindelöf (Cauchy-Lipschitz) theorem. -/\nlemma exists_solution :\n  ∃ f : ℝ → E, f v.t₀ = v.x₀ ∧ ∀ t ∈ Icc v.t_min v.t_max,\n    has_deriv_within_at f (v t (f t)) (Icc v.t_min v.t_max) t :=\nbegin\n  letI : measurable_space E := borel E, haveI : borel_space E := ⟨rfl⟩,\n  rcases v.exists_fixed with ⟨f, hf⟩,\n  refine ⟨f ∘ v.proj, _, λ t ht, _⟩,\n  { simp only [(∘), proj_coe, f.map_t₀] },\n  { simp only [(∘), v.proj_of_mem ht],\n    lift t to Icc v.t_min v.t_max using ht,\n    simpa only [hf, v.proj_coe] using f.has_deriv_within_at_next t }\nend\n\nend picard_lindelof\n\n/-- Picard-Lindelöf (Cauchy-Lipschitz) theorem. -/\nlemma exists_forall_deriv_within_Icc_eq_of_lipschitz_of_continuous\n  [complete_space E] [second_countable_topology E]\n  {v : ℝ → E → E} {t_min t₀ t_max : ℝ} (ht₀ : t₀ ∈ Icc t_min t_max)\n  (x₀ : E) {C R : ℝ} (hR : 0 ≤ R) {L : ℝ≥0}\n  (Hlip : ∀ t ∈ Icc t_min t_max, lipschitz_on_with L (v t) (closed_ball x₀ R))\n  (Hcont : ∀ x ∈ closed_ball x₀ R, continuous_on (λ t, v t x) (Icc t_min t_max))\n  (Hnorm : ∀ (t ∈ Icc t_min t_max) (x ∈ closed_ball x₀ R), ∥v t x∥ ≤ C)\n  (Hmul_le : C * max (t_max - t₀) (t₀ - t_min) ≤ R) :\n  ∃ f : ℝ → E, f t₀ = x₀ ∧ ∀ t ∈ Icc t_min t_max,\n    has_deriv_within_at f (v t (f t)) (Icc t_min t_max) t :=\nbegin\n  lift C to ℝ≥0 using ((norm_nonneg _).trans $ Hnorm t₀ ht₀ x₀ (mem_closed_ball_self hR)),\n  lift R to ℝ≥0 using hR,\n  lift t₀ to Icc t_min t_max using ht₀,\n  exact picard_lindelof.exists_solution\n    ⟨v, t_min, t_max, t₀, x₀, C, R, L, Hlip, Hcont, Hnorm, Hmul_le⟩\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/ODE/picard_lindelof.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.47876748215648435}}
{"text": "/-\nCopyright (c) 2020 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Rémy Degenne.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.measure_theory.ess_sup\nimport Mathlib.measure_theory.l1_space\nimport Mathlib.analysis.mean_inequalities\nimport Mathlib.PostPort\n\nuniverses u_1 u_3 u_2 u_4 \n\nnamespace Mathlib\n\n/-!\n# ℒp space and Lp space\n\nThis file describes properties of almost everywhere measurable functions with finite seminorm,\ndenoted by `snorm f p μ` and defined for `p:ennreal` as `0` if `p=0`, `(∫ ∥f a∥^p ∂μ) ^ (1/p)` for\n`0 < p < ∞` and `ess_sup ∥f∥ μ` for `p=∞`.\n\nThe Prop-valued `mem_ℒp f p μ` states that a function `f : α → E` has finite seminorm.\nThe space `Lp α E p μ` is the subtype of elements of `α →ₘ[μ] E` (see ae_eq_fun) such that\n`snorm f p μ` is finite. For `1 ≤ p`, `snorm` defines a norm and Lp is a metric space.\n\nTODO: prove that Lp is complete.\n\n## Main definitions\n\n* `snorm' f p μ` : `(∫ ∥f a∥^p ∂μ) ^ (1/p)` for `f : α → F` and `p : ℝ`, where `α` is a  measurable\n  space and `F` is a normed group.\n* `snorm_ess_sup f μ` : seminorm in `ℒ∞`, equal to the essential supremum `ess_sup ∥f∥ μ`.\n* `snorm f p μ` : for `p : ennreal`, seminorm in `ℒp`, equal to `0` for `p=0`, to `snorm' f p μ`\n  for `0 < p < ∞` and to `snorm_ess_sup f μ` for `p = ∞`.\n\n* `mem_ℒp f p μ` : property that the function `f` is almost everywhere measurable and has finite\n  p-seminorm for measure `μ` (`snorm f p μ < ∞`)\n* `Lp E p μ` : elements of `α →ₘ[μ] E` (see ae_eq_fun) such that `snorm f p μ` is finite. Defined\n  as an `add_subgroup` of `α →ₘ[μ] E`.\n\n-/\n\nnamespace measure_theory\n\n\n/-- `(∫ ∥f a∥^p ∂μ) ^ (1/p)`, which is a seminorm on the space of measurable functions for which\nthis quantity is finite -/\ndef snorm' {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] (f : α → F) (p : ℝ)\n    (μ : measure α) : ennreal :=\n  (lintegral μ fun (a : α) => ↑(nnnorm (f a)) ^ p) ^ (1 / p)\n\n/-- seminorm for `ℒ∞`, equal to the essential supremum of `∥f∥`. -/\ndef snorm_ess_sup {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] (f : α → F)\n    (μ : measure α) : ennreal :=\n  ess_sup (fun (x : α) => ↑(nnnorm (f x))) μ\n\n/-- `ℒp` seminorm, equal to `0` for `p=0`, to `(∫ ∥f a∥^p ∂μ) ^ (1/p)` for `0 < p < ∞` and to\n`ess_sup ∥f∥ μ` for `p = ∞`. -/\ndef snorm {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] (f : α → F)\n    (q : ennreal) (μ : measure α) : ennreal :=\n  ite (q = 0) 0 (ite (q = ⊤) (snorm_ess_sup f μ) (snorm' f (ennreal.to_real q) μ))\n\ntheorem snorm_eq_snorm' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {q : ennreal} (hq_ne_zero : q ≠ 0) (hq_ne_top : q ≠ ⊤) {f : α → F} :\n    snorm f q μ = snorm' f (ennreal.to_real q) μ :=\n  sorry\n\n@[simp] theorem snorm_exponent_top {α : Type u_1} {F : Type u_3} [measurable_space α]\n    {μ : measure α} [normed_group F] {f : α → F} : snorm f ⊤ μ = snorm_ess_sup f μ :=\n  sorry\n\n/-- The property that `f:α→E` is ae_measurable and `(∫ ∥f a∥^p ∂μ)^(1/p)` is finite -/\ndef mem_ℒp {α : Type u_1} {E : Type u_2} [measurable_space α] [measurable_space E] [normed_group E]\n    (f : α → E) (p : ennreal) (μ : measure α) :=\n  ae_measurable f ∧ snorm f p μ < ⊤\n\ntheorem lintegral_rpow_nnnorm_eq_rpow_snorm' {α : Type u_1} {F : Type u_3} [measurable_space α]\n    {μ : measure α} [normed_group F] {p : ℝ} {f : α → F} (hp0_lt : 0 < p) :\n    (lintegral μ fun (a : α) => ↑(nnnorm (f a)) ^ p) = snorm' f p μ ^ p :=\n  sorry\n\ntheorem mem_ℒp_one_iff_integrable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {f : α → E} : mem_ℒp f 1 μ ↔ integrable f :=\n  sorry\n\ntheorem mem_ℒp.snorm_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} (hfp : mem_ℒp f q μ) :\n    snorm f q μ < ⊤ :=\n  and.right hfp\n\ntheorem mem_ℒp.snorm_ne_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} (hfp : mem_ℒp f q μ) :\n    snorm f q μ ≠ ⊤ :=\n  ne_of_lt (and.right hfp)\n\ntheorem lintegral_rpow_nnnorm_lt_top_of_snorm'_lt_top {α : Type u_1} {F : Type u_3}\n    [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} {f : α → F} (hp0_lt : 0 < p)\n    (hfp : snorm' f p μ < ⊤) : (lintegral μ fun (a : α) => ↑(nnnorm (f a)) ^ p) < ⊤ :=\n  sorry\n\n@[simp] theorem snorm'_exponent_zero {α : Type u_1} {F : Type u_3} [measurable_space α]\n    {μ : measure α} [normed_group F] {f : α → F} : snorm' f 0 μ = 1 :=\n  sorry\n\n@[simp] theorem snorm_exponent_zero {α : Type u_1} {F : Type u_3} [measurable_space α]\n    {μ : measure α} [normed_group F] {f : α → F} : snorm f 0 μ = 0 :=\n  sorry\n\ntheorem mem_ℒp_zero_iff_ae_measurable {α : Type u_1} {E : Type u_2} [measurable_space α]\n    {μ : measure α} [measurable_space E] [normed_group E] {f : α → E} :\n    mem_ℒp f 0 μ ↔ ae_measurable f :=\n  sorry\n\n@[simp] theorem snorm'_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} (hp0_lt : 0 < p) : snorm' 0 p μ = 0 :=\n  sorry\n\n@[simp] theorem snorm'_zero' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} (hp0_ne : p ≠ 0) (hμ : μ ≠ 0) : snorm' 0 p μ = 0 :=\n  sorry\n\n@[simp] theorem snorm_ess_sup_zero {α : Type u_1} {F : Type u_3} [measurable_space α]\n    {μ : measure α} [normed_group F] : snorm_ess_sup 0 μ = 0 :=\n  sorry\n\n@[simp] theorem snorm_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {q : ennreal} : snorm 0 q μ = 0 :=\n  sorry\n\ntheorem zero_mem_ℒp {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} : mem_ℒp 0 q μ :=\n  { left := measurable.ae_measurable measurable_zero,\n    right := eq.mpr (id (Eq._oldrec (Eq.refl (snorm 0 q μ < ⊤)) snorm_zero)) ennreal.coe_lt_top }\n\ntheorem snorm'_measure_zero_of_pos {α : Type u_1} {F : Type u_3} [measurable_space α]\n    [normed_group F] {p : ℝ} {f : α → F} (hp_pos : 0 < p) : snorm' f p 0 = 0 :=\n  sorry\n\ntheorem snorm'_measure_zero_of_exponent_zero {α : Type u_1} {F : Type u_3} [measurable_space α]\n    [normed_group F] {f : α → F} : snorm' f 0 0 = 1 :=\n  sorry\n\ntheorem snorm'_measure_zero_of_neg {α : Type u_1} {F : Type u_3} [measurable_space α]\n    [normed_group F] {p : ℝ} {f : α → F} (hp_neg : p < 0) : snorm' f p 0 = ⊤ :=\n  sorry\n\n@[simp] theorem snorm_ess_sup_measure_zero {α : Type u_1} {F : Type u_3} [measurable_space α]\n    [normed_group F] {f : α → F} : snorm_ess_sup f 0 = 0 :=\n  sorry\n\n@[simp] theorem snorm_measure_zero {α : Type u_1} {F : Type u_3} [measurable_space α]\n    [normed_group F] {q : ennreal} {f : α → F} : snorm f q 0 = 0 :=\n  sorry\n\ntheorem snorm'_const {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} (c : F) (hp_pos : 0 < p) :\n    snorm' (fun (x : α) => c) p μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / p) :=\n  sorry\n\ntheorem snorm'_const' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} [finite_measure μ] (c : F) (hc_ne_zero : c ≠ 0) (hp_ne_zero : p ≠ 0) :\n    snorm' (fun (x : α) => c) p μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / p) :=\n  sorry\n\ntheorem snorm_ess_sup_const {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] (c : F) (hμ : μ ≠ 0) : snorm_ess_sup (fun (x : α) => c) μ = ↑(nnnorm c) :=\n  sorry\n\ntheorem snorm'_const_of_probability_measure {α : Type u_1} {F : Type u_3} [measurable_space α]\n    {μ : measure α} [normed_group F] {p : ℝ} (c : F) (hp_pos : 0 < p) [probability_measure μ] :\n    snorm' (fun (x : α) => c) p μ = ↑(nnnorm c) :=\n  sorry\n\ntheorem snorm_const {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {q : ennreal} (c : F) (h0 : q ≠ 0) (hμ : μ ≠ 0) :\n    snorm (fun (x : α) => c) q μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / ennreal.to_real q) :=\n  sorry\n\ntheorem snorm_const' {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {q : ennreal} (c : F) (h0 : q ≠ 0) (h_top : q ≠ ⊤) :\n    snorm (fun (x : α) => c) q μ = ↑(nnnorm c) * coe_fn μ set.univ ^ (1 / ennreal.to_real q) :=\n  sorry\n\ntheorem mem_ℒp_const {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} (c : E) [finite_measure μ] :\n    mem_ℒp (fun (a : α) => c) q μ :=\n  sorry\n\ntheorem snorm'_congr_ae {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} {f : α → F} {g : α → F}\n    (hfg : filter.eventually_eq (measure.ae μ) f g) : snorm' f p μ = snorm' g p μ :=\n  sorry\n\ntheorem snorm_ess_sup_congr_ae {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {f : α → F} {g : α → F} (hfg : filter.eventually_eq (measure.ae μ) f g) :\n    snorm_ess_sup f μ = snorm_ess_sup g μ :=\n  sorry\n\ntheorem snorm_congr_ae {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {q : ennreal} {f : α → F} {g : α → F}\n    (hfg : filter.eventually_eq (measure.ae μ) f g) : snorm f q μ = snorm g q μ :=\n  sorry\n\ntheorem mem_ℒp.ae_eq {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} {g : α → E}\n    (hfg : filter.eventually_eq (measure.ae μ) f g) (hf_Lp : mem_ℒp f q μ) : mem_ℒp g q μ :=\n  sorry\n\ntheorem mem_ℒp_congr_ae {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : α → E} {g : α → E}\n    (hfg : filter.eventually_eq (measure.ae μ) f g) : mem_ℒp f q μ ↔ mem_ℒp g q μ :=\n  { mp := fun (h : mem_ℒp f q μ) => mem_ℒp.ae_eq hfg h,\n    mpr := fun (h : mem_ℒp g q μ) => mem_ℒp.ae_eq (filter.eventually_eq.symm hfg) h }\n\ntheorem snorm'_eq_zero_of_ae_zero {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} {f : α → F} (hp0_lt : 0 < p)\n    (hf_zero : filter.eventually_eq (measure.ae μ) f 0) : snorm' f p μ = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p μ = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p μ = 0)) (snorm'_zero hp0_lt))) (Eq.refl 0))\n\ntheorem snorm'_eq_zero_of_ae_zero' {α : Type u_1} {F : Type u_3} [measurable_space α]\n    {μ : measure α} [normed_group F] {p : ℝ} (hp0_ne : p ≠ 0) (hμ : μ ≠ 0) {f : α → F}\n    (hf_zero : filter.eventually_eq (measure.ae μ) f 0) : snorm' f p μ = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p μ = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p μ = 0)) (snorm'_zero' hp0_ne hμ))) (Eq.refl 0))\n\ntheorem ae_eq_zero_of_snorm'_eq_zero {α : Type u_1} {E : Type u_2} [measurable_space α]\n    {μ : measure α} [measurable_space E] [normed_group E] {p : ℝ} [opens_measurable_space E]\n    {f : α → E} (hp0 : 0 ≤ p) (hf : ae_measurable f) (h : snorm' f p μ = 0) :\n    filter.eventually_eq (measure.ae μ) f 0 :=\n  sorry\n\ntheorem snorm'_eq_zero_iff {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {p : ℝ} [opens_measurable_space E] (hp0_lt : 0 < p)\n    {f : α → E} (hf : ae_measurable f) :\n    snorm' f p μ = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 :=\n  { mp := ae_eq_zero_of_snorm'_eq_zero (le_of_lt hp0_lt) hf,\n    mpr := snorm'_eq_zero_of_ae_zero hp0_lt }\n\ntheorem coe_nnnorm_ae_le_snorm_ess_sup {α : Type u_1} {F : Type u_3} [measurable_space α]\n    [normed_group F] (f : α → F) (μ : measure α) :\n    filter.eventually (fun (x : α) => ↑(nnnorm (f x)) ≤ snorm_ess_sup f μ) (measure.ae μ) :=\n  ennreal.ae_le_ess_sup fun (x : α) => ↑(nnnorm (f x))\n\ntheorem snorm_ess_sup_eq_zero_iff {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {f : α → F} :\n    snorm_ess_sup f μ = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 :=\n  sorry\n\ntheorem snorm_eq_zero_iff {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} [opens_measurable_space E] {f : α → E}\n    (hf : ae_measurable f) (h0 : q ≠ 0) :\n    snorm f q μ = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 :=\n  sorry\n\n@[simp] theorem snorm'_neg {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} {f : α → F} : snorm' (-f) p μ = snorm' f p μ :=\n  sorry\n\n@[simp] theorem snorm_neg {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {q : ennreal} {f : α → F} : snorm (-f) q μ = snorm f q μ :=\n  sorry\n\ntheorem mem_ℒp.neg {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E}\n    (hf : mem_ℒp f q μ) : mem_ℒp (-f) q μ :=\n  sorry\n\ntheorem snorm'_le_snorm'_mul_rpow_measure_univ {α : Type u_1} {E : Type u_2} [measurable_space α]\n    {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] {p : ℝ} {q : ℝ}\n    (hp0_lt : 0 < p) (hpq : p ≤ q) {f : α → E} (hf : ae_measurable f) :\n    snorm' f p μ ≤ snorm' f q μ * coe_fn μ set.univ ^ (1 / p - 1 / q) :=\n  sorry\n\ntheorem snorm'_le_snorm_ess_sup_mul_rpow_measure_univ {α : Type u_1} {F : Type u_3}\n    [measurable_space α] {μ : measure α} [normed_group F] {p : ℝ} (hp_pos : 0 < p) {f : α → F} :\n    snorm' f p μ ≤ snorm_ess_sup f μ * coe_fn μ set.univ ^ (1 / p) :=\n  sorry\n\ntheorem snorm'_le_snorm'_of_exponent_le {α : Type u_1} {E : Type u_2} [measurable_space α]\n    [measurable_space E] [normed_group E] [borel_space E] {p : ℝ} {q : ℝ} (hp0_lt : 0 < p)\n    (hpq : p ≤ q) (μ : measure α) [probability_measure μ] {f : α → E} (hf : ae_measurable f) :\n    snorm' f p μ ≤ snorm' f q μ :=\n  sorry\n\ntheorem snorm'_le_snorm_ess_sup {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} (hp_pos : 0 < p) {f : α → F} [probability_measure μ] :\n    snorm' f p μ ≤ snorm_ess_sup f μ :=\n  sorry\n\ntheorem snorm_le_snorm_of_exponent_le {α : Type u_1} {E : Type u_2} [measurable_space α]\n    {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal}\n    {q : ennreal} (hpq : p ≤ q) [probability_measure μ] {f : α → E} (hf : ae_measurable f) :\n    snorm f p μ ≤ snorm f q μ :=\n  sorry\n\ntheorem snorm'_lt_top_of_snorm'_lt_top_of_exponent_le {α : Type u_1} {E : Type u_2}\n    [measurable_space α] {μ : measure α} [measurable_space E] [normed_group E] [borel_space E]\n    {p : ℝ} {q : ℝ} [finite_measure μ] {f : α → E} (hf : ae_measurable f)\n    (hfq_lt_top : snorm' f q μ < ⊤) (hp_nonneg : 0 ≤ p) (hpq : p ≤ q) : snorm' f p μ < ⊤ :=\n  sorry\n\ntheorem mem_ℒp.mem_ℒp_of_exponent_le {α : Type u_1} {E : Type u_2} [measurable_space α]\n    {μ : measure α} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal}\n    {q : ennreal} [finite_measure μ] {f : α → E} (hfq : mem_ℒp f q μ) (hpq : p ≤ q) :\n    mem_ℒp f p μ :=\n  sorry\n\ntheorem mem_ℒp.integrable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] (hq1 : 1 ≤ q) {f : α → E}\n    [finite_measure μ] (hfq : mem_ℒp f q μ) : integrable f :=\n  iff.mp mem_ℒp_one_iff_integrable (mem_ℒp.mem_ℒp_of_exponent_le hfq hq1)\n\ntheorem snorm'_add_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {p : ℝ} [borel_space E] {f : α → E} {g : α → E}\n    (hf : ae_measurable f) (hg : ae_measurable g) (hp1 : 1 ≤ p) :\n    snorm' (f + g) p μ ≤ snorm' f p μ + snorm' g p μ :=\n  sorry\n\ntheorem snorm_ess_sup_add_le {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {f : α → F} {g : α → F} :\n    snorm_ess_sup (f + g) μ ≤ snorm_ess_sup f μ + snorm_ess_sup g μ :=\n  sorry\n\ntheorem snorm_add_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E} {g : α → E}\n    (hf : ae_measurable f) (hg : ae_measurable g) (hq1 : 1 ≤ q) :\n    snorm (f + g) q μ ≤ snorm f q μ + snorm g q μ :=\n  sorry\n\ntheorem snorm_add_lt_top_of_one_le {α : Type u_1} {E : Type u_2} [measurable_space α]\n    {μ : measure α} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E}\n    {g : α → E} (hf : mem_ℒp f q μ) (hg : mem_ℒp g q μ) (hq1 : 1 ≤ q) : snorm (f + g) q μ < ⊤ :=\n  lt_of_le_of_lt (snorm_add_le (and.left hf) (and.left hg) hq1)\n    (iff.mpr ennreal.add_lt_top { left := and.right hf, right := and.right hg })\n\ntheorem snorm'_add_lt_top_of_le_one {α : Type u_1} {E : Type u_2} [measurable_space α]\n    {μ : measure α} [measurable_space E] [normed_group E] {p : ℝ} [borel_space E] {f : α → E}\n    {g : α → E} (hf : ae_measurable f) (hg : ae_measurable g) (hf_snorm : snorm' f p μ < ⊤)\n    (hg_snorm : snorm' g p μ < ⊤) (hp_pos : 0 < p) (hp1 : p ≤ 1) : snorm' (f + g) p μ < ⊤ :=\n  sorry\n\ntheorem snorm_add_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : α → E} {g : α → E}\n    (hf : mem_ℒp f q μ) (hg : mem_ℒp g q μ) : snorm (f + g) q μ < ⊤ :=\n  sorry\n\ntheorem mem_ℒp.add {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E]\n    [topological_space.second_countable_topology E] {f : α → E} {g : α → E} (hf : mem_ℒp f q μ)\n    (hg : mem_ℒp g q μ) : mem_ℒp (f + g) q μ :=\n  { left := ae_measurable.add (and.left hf) (and.left hg), right := snorm_add_lt_top hf hg }\n\ntheorem mem_ℒp.sub {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E]\n    [topological_space.second_countable_topology E] {f : α → E} {g : α → E} (hf : mem_ℒp f q μ)\n    (hg : mem_ℒp g q μ) : mem_ℒp (f - g) q μ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (mem_ℒp (f - g) q μ)) (sub_eq_add_neg f g)))\n    (mem_ℒp.add hf (mem_ℒp.neg hg))\n\ntheorem snorm'_const_smul {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {p : ℝ} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 F] {f : α → F} (c : 𝕜)\n    (hp0_lt : 0 < p) : snorm' (c • f) p μ = ↑(nnnorm c) * snorm' f p μ :=\n  sorry\n\ntheorem snorm_ess_sup_const_smul {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 F] {f : α → F} (c : 𝕜) :\n    snorm_ess_sup (c • f) μ = ↑(nnnorm c) * snorm_ess_sup f μ :=\n  sorry\n\ntheorem snorm_const_smul {α : Type u_1} {F : Type u_3} [measurable_space α] {μ : measure α}\n    [normed_group F] {q : ennreal} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 F] {f : α → F}\n    (c : 𝕜) : snorm (c • f) q μ = ↑(nnnorm c) * snorm f q μ :=\n  sorry\n\ntheorem mem_ℒp.const_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {q : ennreal} {𝕜 : Type u_4} [normed_field 𝕜]\n    [normed_space 𝕜 E] [borel_space E] {f : α → E} (hf : mem_ℒp f q μ) (c : 𝕜) :\n    mem_ℒp (c • f) q μ :=\n  { left := ae_measurable.const_smul (and.left hf) c,\n    right :=\n      lt_of_le_of_lt (le_of_eq (snorm_const_smul c))\n        (ennreal.mul_lt_top ennreal.coe_lt_top (and.right hf)) }\n\ntheorem snorm'_smul_le_mul_snorm' {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {p : ℝ} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E]\n    [opens_measurable_space E] [measurable_space 𝕜] [opens_measurable_space 𝕜] {q : ℝ} {r : ℝ}\n    {f : α → E} (hf : ae_measurable f) {φ : α → 𝕜} (hφ : ae_measurable φ) (hp0_lt : 0 < p)\n    (hpq : p < q) (hpqr : 1 / p = 1 / q + 1 / r) :\n    snorm' (φ • f) p μ ≤ snorm' φ q μ * snorm' f r μ :=\n  sorry\n\n/-! ### Lp space\n\nThe space of equivalence classes of measurable functions for which `snorm f p μ < ⊤`.\n-/\n\n@[simp] theorem snorm_ae_eq_fun {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {p : ennreal} {f : α → E} (hf : ae_measurable f) :\n    snorm (⇑(ae_eq_fun.mk f hf)) p μ = snorm f p μ :=\n  snorm_congr_ae (ae_eq_fun.coe_fn_mk f hf)\n\ntheorem mem_ℒp.snorm_mk_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] {p : ennreal} {f : α → E} (hfp : mem_ℒp f p μ) :\n    snorm (⇑(ae_eq_fun.mk f (and.left hfp))) p μ < ⊤ :=\n  sorry\n\n/-- Lp space -/\ndef Lp {α : Type u_1} (E : Type u_2) [measurable_space α] [measurable_space E] [normed_group E]\n    [borel_space E] [topological_space.second_countable_topology E] (p : ennreal) (μ : measure α) :\n    add_subgroup (ae_eq_fun α E μ) :=\n  add_subgroup.mk (set_of fun (f : ae_eq_fun α E μ) => snorm (⇑f) p μ < ⊤) sorry sorry sorry\n\n/-- make an element of Lp from a function verifying `mem_ℒp` -/\ndef mem_ℒp.to_Lp {α : Type u_1} {E : Type u_2} [measurable_space α] [measurable_space E]\n    [normed_group E] [borel_space E] [topological_space.second_countable_topology E] (f : α → E)\n    {p : ennreal} {μ : measure α} (h_mem_ℒp : mem_ℒp f p μ) : ↥(Lp E p μ) :=\n  { val := ae_eq_fun.mk f sorry, property := mem_ℒp.snorm_mk_lt_top h_mem_ℒp }\n\ntheorem mem_ℒp.coe_fn_to_Lp {α : Type u_1} {E : Type u_2} [measurable_space α] [measurable_space E]\n    [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {μ : measure α}\n    {p : ennreal} {f : α → E} (hf : mem_ℒp f p μ) :\n    filter.eventually_eq (measure.ae μ) (⇑(mem_ℒp.to_Lp f hf)) f :=\n  ae_eq_fun.coe_fn_mk f (mem_ℒp.to_Lp._proof_1 f hf)\n\nnamespace Lp\n\n\ntheorem mem_Lp_iff_snorm_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun α E μ} :\n    f ∈ Lp E p μ ↔ snorm (⇑f) p μ < ⊤ :=\n  iff.refl (f ∈ Lp E p μ)\n\ntheorem antimono {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] [finite_measure μ] {p : ennreal} {q : ennreal}\n    (hpq : p ≤ q) : Lp E q μ ≤ Lp E p μ :=\n  fun (f : ae_eq_fun α E μ) (hf : f ∈ Lp E q μ) =>\n    and.right (mem_ℒp.mem_ℒp_of_exponent_le { left := ae_eq_fun.ae_measurable f, right := hf } hpq)\n\ntheorem coe_fn_mk {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun α E μ}\n    (hf : snorm (⇑f) p μ < ⊤) :\n    filter.eventually_eq (measure.ae μ) ⇑{ val := f, property := hf } ⇑f :=\n  sorry\n\ntheorem snorm_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) :\n    snorm (⇑f) p μ < ⊤ :=\n  subtype.prop f\n\ntheorem snorm_ne_top {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) :\n    snorm (⇑f) p μ ≠ ⊤ :=\n  has_lt.lt.ne (snorm_lt_top f)\n\ntheorem measurable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) :\n    measurable ⇑f :=\n  ae_eq_fun.measurable (subtype.val f)\n\ntheorem ae_measurable {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) :\n    ae_measurable ⇑f :=\n  ae_eq_fun.ae_measurable (subtype.val f)\n\ntheorem mem_ℒp {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) :\n    mem_ℒp (⇑f) p μ :=\n  { left := ae_measurable f, right := subtype.prop f }\n\ntheorem coe_fn_zero {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} :\n    filter.eventually_eq (measure.ae μ) (⇑0) 0 :=\n  ae_eq_fun.coe_fn_zero\n\ntheorem coe_fn_neg {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} :\n    filter.eventually_eq (measure.ae μ) (⇑(-f)) (-⇑f) :=\n  ae_eq_fun.coe_fn_neg ↑f\n\ntheorem coe_fn_add {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)}\n    {g : ↥(Lp E p μ)} : filter.eventually_eq (measure.ae μ) (⇑(f + g)) (⇑f + ⇑g) :=\n  ae_eq_fun.coe_fn_add (subtype.val f) (subtype.val g)\n\ntheorem coe_fn_sub {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)}\n    {g : ↥(Lp E p μ)} : filter.eventually_eq (measure.ae μ) (⇑(f - g)) (⇑f - ⇑g) :=\n  ae_eq_fun.coe_fn_sub ↑f ↑g\n\ntheorem mem_Lp_const {E : Type u_2} [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (α : Type u_1)\n    [measurable_space α] (μ : measure α) (c : E) [finite_measure μ] :\n    ae_eq_fun.const α c ∈ Lp E p μ :=\n  mem_ℒp.snorm_mk_lt_top (mem_ℒp_const c)\n\nprotected instance has_norm {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} : has_norm ↥(Lp E p μ) :=\n  has_norm.mk fun (f : ↥(Lp E p μ)) => ennreal.to_real (snorm (⇑f) p μ)\n\ntheorem norm_def {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : ↥(Lp E p μ)) :\n    norm f = ennreal.to_real (snorm (⇑f) p μ) :=\n  rfl\n\n@[simp] theorem norm_zero {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} : norm 0 = 0 :=\n  sorry\n\ntheorem norm_eq_zero_iff {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} (hp : 0 < p) :\n    norm f = 0 ↔ f = 0 :=\n  sorry\n\n@[simp] theorem norm_neg {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ↥(Lp E p μ)} :\n    norm (-f) = norm f :=\n  sorry\n\nprotected instance normed_group {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} [hp : fact (1 ≤ p)] :\n    normed_group ↥(Lp E p μ) :=\n  normed_group.of_core ↥(Lp E p μ) sorry\n\ntheorem mem_Lp_const_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜]\n    [normed_space 𝕜 E] (c : 𝕜) (f : ↥(Lp E p μ)) : c • ↑f ∈ Lp E p μ :=\n  sorry\n\nprotected instance has_scalar {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜]\n    [normed_space 𝕜 E] : has_scalar 𝕜 ↥(Lp E p μ) :=\n  has_scalar.mk\n    fun (c : 𝕜) (f : ↥(Lp E p μ)) => { val := c • ↑f, property := mem_Lp_const_smul c f }\n\ntheorem coe_fn_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜]\n    [normed_space 𝕜 E] {f : ↥(Lp E p μ)} {c : 𝕜} :\n    filter.eventually_eq (measure.ae μ) (⇑(c • f)) (c • ⇑f) :=\n  ae_eq_fun.coe_fn_smul c ↑f\n\nprotected instance semimodule {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜]\n    [normed_space 𝕜 E] : semimodule 𝕜 ↥(Lp E p μ) :=\n  semimodule.mk sorry sorry\n\ntheorem norm_const_smul {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜]\n    [normed_space 𝕜 E] (c : 𝕜) (f : ↥(Lp E p μ)) : norm (c • f) = norm c * norm f :=\n  sorry\n\nprotected instance normed_space {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure α}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {𝕜 : Type u_4} [normed_field 𝕜]\n    [normed_space 𝕜 E] [fact (1 ≤ p)] : normed_space 𝕜 ↥(Lp E p μ) :=\n  normed_space.mk sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/measure_theory/lp_space_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.478766414689903}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.preserves.shapes.zero\n! leanprover-community/mathlib commit bbe25d4d92565a5fd773e52e041a90387eee3c93\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Limits.Preserves.Shapes.Terminal\nimport Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms\n\n/-!\n# Preservation of zero objects and zero morphisms\n\nWe define the class `PreservesZeroMorphisms` and show basic properties.\n\n## Main results\n\nWe provide the following results:\n* Left adjoints and right adjoints preserve zero morphisms;\n* full functors preserve zero morphisms;\n* if both categories involved have a zero object, then a functor preserves zero morphisms if and\n  only if it preserves the zero object;\n* functors which preserve initial or terminal objects preserve zero morphisms.\n\n-/\n\n\nuniverse v₁ v₂ u₁ u₂\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]\n\nsection ZeroMorphisms\n\nvariable [HasZeroMorphisms C] [HasZeroMorphisms D]\n\n/-- A functor preserves zero morphisms if it sends zero morphisms to zero morphisms. -/\nclass PreservesZeroMorphisms (F : C ⥤ D) : Prop where\n  /-- For any pair objects `F (0: X ⟶  Y) = (0 : F X ⟶  F Y)` -/\n  map_zero : ∀ X Y : C, F.map (0 : X ⟶ Y) = 0 := by aesop\n#align category_theory.functor.preserves_zero_morphisms CategoryTheory.Functor.PreservesZeroMorphisms\n\n@[simp]\nprotected theorem map_zero (F : C ⥤ D) [PreservesZeroMorphisms F] (X Y : C) :\n    F.map (0 : X ⟶ Y) = 0 :=\n  PreservesZeroMorphisms.map_zero _ _\n#align category_theory.functor.map_zero CategoryTheory.Functor.map_zero\n\ntheorem zero_of_map_zero (F : C ⥤ D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} (f : X ⟶ Y)\n    (h : F.map f = 0) : f = 0 :=\n  F.map_injective <| h.trans <| Eq.symm <| F.map_zero _ _\n#align category_theory.functor.zero_of_map_zero CategoryTheory.Functor.zero_of_map_zero\n\ntheorem map_eq_zero_iff (F : C ⥤ D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} {f : X ⟶ Y} :\n    F.map f = 0 ↔ f = 0 :=\n  ⟨F.zero_of_map_zero _, by\n    rintro rfl\n    exact F.map_zero _ _⟩\n#align category_theory.functor.map_eq_zero_iff CategoryTheory.Functor.map_eq_zero_iff\n\ninstance (priority := 100) preservesZeroMorphisms_of_isLeftAdjoint (F : C ⥤ D) [IsLeftAdjoint F] :\n    PreservesZeroMorphisms F where\n  map_zero X Y := by\n    let adj := Adjunction.ofLeftAdjoint F\n    dsimp\n    calc\n      F.map (0 : X ⟶ Y) = F.map 0 ≫ F.map (adj.unit.app Y) ≫ adj.counit.app (F.obj Y) := ?_\n      _ = F.map 0 ≫ F.map ((rightAdjoint F).map (0 : F.obj X ⟶ _)) ≫ adj.counit.app (F.obj Y) := ?_\n      _ = 0 := ?_\n    · rw [Adjunction.left_triangle_components]\n      exact (Category.comp_id _).symm\n    · simp only [← Category.assoc, ← F.map_comp, zero_comp]\n    · simp only [Adjunction.counit_naturality, comp_zero]\n#align category_theory.functor.preserves_zero_morphisms_of_is_left_adjoint CategoryTheory.Functor.preservesZeroMorphisms_of_isLeftAdjoint\n\ninstance (priority := 100) preservesZeroMorphisms_of_isRightAdjoint (G : C ⥤ D) [IsRightAdjoint G] :\n    PreservesZeroMorphisms G where\n  map_zero X Y := by\n    let adj := Adjunction.ofRightAdjoint G\n    calc\n      G.map (0 : X ⟶ Y) = adj.unit.app (G.obj X) ≫ G.map (adj.counit.app X) ≫ G.map 0 := ?_\n      _ = adj.unit.app (G.obj X) ≫ G.map ((leftAdjoint G).map (0 : _ ⟶ G.obj X)) ≫ G.map 0 := ?_\n      _ = 0 := ?_\n    · rw [Adjunction.right_triangle_components_assoc]; simp only [id_obj,Category.id_comp]\n    · simp only [← G.map_comp, comp_zero]\n    · simp only [Adjunction.unit_naturality_assoc, zero_comp]\n#align category_theory.functor.preserves_zero_morphisms_of_is_right_adjoint CategoryTheory.Functor.preservesZeroMorphisms_of_isRightAdjoint\n\ninstance (priority := 100) preservesZeroMorphisms_of_full (F : C ⥤ D) [Full F] :\n    PreservesZeroMorphisms F where\n  map_zero X Y :=\n    calc\n      F.map (0 : X ⟶ Y) = F.map (0 ≫ F.preimage (0 : F.obj Y ⟶ F.obj Y)) := by rw [zero_comp]\n      _ = 0 := by rw [F.map_comp, F.image_preimage, comp_zero]\n#align category_theory.functor.preserves_zero_morphisms_of_full CategoryTheory.Functor.preservesZeroMorphisms_of_full\n\nend ZeroMorphisms\n\nsection ZeroObject\n\nvariable [HasZeroObject C] [HasZeroObject D]\n\nopen ZeroObject\n\nvariable [HasZeroMorphisms C] [HasZeroMorphisms D] (F : C ⥤ D)\n\n/-- A functor that preserves zero morphisms also preserves the zero object. -/\n@[simps]\ndef mapZeroObject [PreservesZeroMorphisms F] : F.obj 0 ≅ 0 where\n  hom := 0\n  inv := 0\n  hom_inv_id := by rw [← F.map_id, id_zero, F.map_zero, zero_comp]\n  inv_hom_id := by rw [id_zero, comp_zero]\n#align category_theory.functor.map_zero_object CategoryTheory.Functor.mapZeroObject\n\nvariable {F}\n\ntheorem preservesZeroMorphisms_of_map_zero_object (i : F.obj 0 ≅ 0) : PreservesZeroMorphisms F where\n  map_zero X Y :=\n    calc\n      F.map (0 : X ⟶ Y) = F.map (0 : X ⟶ 0) ≫ F.map 0 := by rw [← Functor.map_comp, comp_zero]\n      _ = F.map 0 ≫ (i.hom ≫ i.inv) ≫ F.map 0 := by rw [Iso.hom_inv_id, Category.id_comp]\n      _ = 0 := by simp only [zero_of_to_zero i.hom, zero_comp, comp_zero]\n#align category_theory.functor.preserves_zero_morphisms_of_map_zero_object CategoryTheory.Functor.preservesZeroMorphisms_of_map_zero_object\n\ninstance (priority := 100) preservesZeroMorphisms_of_preserves_initial_object\n    [PreservesColimit (Functor.empty.{0} C) F] : PreservesZeroMorphisms F :=\n  preservesZeroMorphisms_of_map_zero_object <|\n    F.mapIso HasZeroObject.zeroIsoInitial ≪≫\n      PreservesInitial.iso F ≪≫ HasZeroObject.zeroIsoInitial.symm\n#align category_theory.functor.preserves_zero_morphisms_of_preserves_initial_object CategoryTheory.Functor.preservesZeroMorphisms_of_preserves_initial_object\n\ninstance (priority := 100) preservesZeroMorphisms_of_preserves_terminal_object\n    [PreservesLimit (Functor.empty.{0} C) F] : PreservesZeroMorphisms F :=\n  preservesZeroMorphisms_of_map_zero_object <|\n    F.mapIso HasZeroObject.zeroIsoTerminal ≪≫\n      PreservesTerminal.iso F ≪≫ HasZeroObject.zeroIsoTerminal.symm\n#align category_theory.functor.preserves_zero_morphisms_of_preserves_terminal_object CategoryTheory.Functor.preservesZeroMorphisms_of_preserves_terminal_object\n\nvariable (F)\n\n/-- Preserving zero morphisms implies preserving terminal objects. -/\ndef preservesTerminalObjectOfPreservesZeroMorphisms [PreservesZeroMorphisms F] :\n    PreservesLimit (Functor.empty C) F :=\n  preservesTerminalOfIso F <|\n    F.mapIso HasZeroObject.zeroIsoTerminal.symm ≪≫ mapZeroObject F ≪≫ HasZeroObject.zeroIsoTerminal\n#align category_theory.functor.preserves_terminal_object_of_preserves_zero_morphisms CategoryTheory.Functor.preservesTerminalObjectOfPreservesZeroMorphisms\n\n/-- Preserving zero morphisms implies preserving terminal objects. -/\ndef preservesInitialObjectOfPreservesZeroMorphisms [PreservesZeroMorphisms F] :\n    PreservesColimit (Functor.empty C) F :=\n  preservesInitialOfIso F <|\n    HasZeroObject.zeroIsoInitial.symm ≪≫\n      (mapZeroObject F).symm ≪≫ (F.mapIso HasZeroObject.zeroIsoInitial.symm).symm\n#align category_theory.functor.preserves_initial_object_of_preserves_zero_morphisms CategoryTheory.Functor.preservesInitialObjectOfPreservesZeroMorphisms\n\nend ZeroObject\n\nend CategoryTheory.Functor\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.47876640976582}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.shapes.equalizers\nimport category_theory.limits.shapes.kernel_pair\n\n/-!\n# Reflexive coequalizers\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define reflexive pairs as a pair of morphisms which have a common section. We say a category has\nreflexive coequalizers if it has coequalizers of all reflexive pairs.\nReflexive coequalizers often enjoy nicer properties than general coequalizers, and feature heavily\nin some versions of the monadicity theorem.\n\nWe also give some examples of reflexive pairs: for an adjunction `F ⊣ G` with counit `ε`, the pair\n`(FGε_B, ε_FGB)` is reflexive. If a pair `f,g` is a kernel pair for some morphism, then it is\nreflexive.\n\n# TODO\n* If `C` has binary coproducts and reflexive coequalizers, then it has all coequalizers.\n* If `T` is a monad on cocomplete category `C`, then `algebra T` is cocomplete iff it has reflexive\n  coequalizers.\n* If `C` is locally cartesian closed and has reflexive coequalizers, then it has images: in fact\n  regular epi (and hence strong epi) images.\n-/\n\nnamespace category_theory\n\nuniverses v v₂ u u₂\n\nvariables {C : Type u} [category.{v} C]\nvariables {D : Type u₂} [category.{v₂} D]\nvariables {A B : C} {f g : A ⟶ B}\n\n/--\nThe pair `f g : A ⟶ B` is reflexive if there is a morphism `B ⟶ A` which is a section for both.\n-/\nclass is_reflexive_pair (f g : A ⟶ B) : Prop :=\n(common_section [] : ∃ (s : B ⟶ A), s ≫ f = 𝟙 B ∧ s ≫ g = 𝟙 B)\n\n/--\nThe pair `f g : A ⟶ B` is coreflexive if there is a morphism `B ⟶ A` which is a retraction for both.\n-/\nclass is_coreflexive_pair (f g : A ⟶ B) : Prop :=\n(common_retraction [] : ∃ (s : B ⟶ A), f ≫ s = 𝟙 A ∧ g ≫ s = 𝟙 A)\n\nlemma is_reflexive_pair.mk' (s : B ⟶ A) (sf : s ≫ f = 𝟙 B) (sg : s ≫ g = 𝟙 B) :\n  is_reflexive_pair f g :=\n⟨⟨s, sf, sg⟩⟩\n\nlemma is_coreflexive_pair.mk' (s : B ⟶ A) (fs : f ≫ s = 𝟙 A) (gs : g ≫ s = 𝟙 A) :\n  is_coreflexive_pair f g :=\n⟨⟨s, fs, gs⟩⟩\n\n/-- Get the common section for a reflexive pair. -/\nnoncomputable def common_section (f g : A ⟶ B) [is_reflexive_pair f g] : B ⟶ A :=\n(is_reflexive_pair.common_section f g).some\n\n@[simp, reassoc]\nlemma section_comp_left (f g : A ⟶ B) [is_reflexive_pair f g] :\n  common_section f g ≫ f = 𝟙 B :=\n(is_reflexive_pair.common_section f g).some_spec.1\n\n@[simp, reassoc]\nlemma section_comp_right (f g : A ⟶ B) [is_reflexive_pair f g] :\n  common_section f g ≫ g = 𝟙 B :=\n(is_reflexive_pair.common_section f g).some_spec.2\n\n/-- Get the common retraction for a coreflexive pair. -/\nnoncomputable def common_retraction (f g : A ⟶ B) [is_coreflexive_pair f g] :\n  B ⟶ A :=\n(is_coreflexive_pair.common_retraction f g).some\n\n@[simp, reassoc]\nlemma left_comp_retraction (f g : A ⟶ B) [is_coreflexive_pair f g] :\n  f ≫ common_retraction f g = 𝟙 A :=\n(is_coreflexive_pair.common_retraction f g).some_spec.1\n\n@[simp, reassoc]\nlemma right_comp_retraction (f g : A ⟶ B) [is_coreflexive_pair f g] :\n  g ≫ common_retraction f g = 𝟙 A :=\n(is_coreflexive_pair.common_retraction f g).some_spec.2\n\n/-- If `f,g` is a kernel pair for some morphism `q`, then it is reflexive. -/\nlemma is_kernel_pair.is_reflexive_pair {R : C} {f g : R ⟶ A} {q : A ⟶ B}\n  (h : is_kernel_pair q f g) :\n  is_reflexive_pair f g :=\nis_reflexive_pair.mk' _ (h.lift' _ _ rfl).2.1 (h.lift' _ _ _).2.2\n\n/-- If `f,g` is reflexive, then `g,f` is reflexive. -/\n-- This shouldn't be an instance as it would instantly loop.\nlemma is_reflexive_pair.swap [is_reflexive_pair f g] :\n  is_reflexive_pair g f :=\nis_reflexive_pair.mk' _ (section_comp_right f g) (section_comp_left f g)\n\n/-- If `f,g` is coreflexive, then `g,f` is coreflexive. -/\n-- This shouldn't be an instance as it would instantly loop.\nlemma is_coreflexive_pair.swap [is_coreflexive_pair f g] :\n  is_coreflexive_pair g f :=\nis_coreflexive_pair.mk' _ (right_comp_retraction f g) (left_comp_retraction f g)\n\nvariables {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G)\n\n/-- For an adjunction `F ⊣ G` with counit `ε`, the pair `(FGε_B, ε_FGB)` is reflexive. -/\ninstance (B : D) :\n  is_reflexive_pair (F.map (G.map (adj.counit.app B))) (adj.counit.app (F.obj (G.obj B))) :=\nis_reflexive_pair.mk'\n  (F.map (adj.unit.app (G.obj B)))\n  (by { rw [← F.map_comp, adj.right_triangle_components], apply F.map_id })\n  adj.left_triangle_components\n\nnamespace limits\n\nvariables (C)\n\n/-- `C` has reflexive coequalizers if it has coequalizers for every reflexive pair. -/\nclass has_reflexive_coequalizers : Prop :=\n(has_coeq : ∀ ⦃A B : C⦄ (f g : A ⟶ B) [is_reflexive_pair f g], has_coequalizer f g)\n\n/-- `C` has coreflexive equalizers if it has equalizers for every coreflexive pair. -/\nclass has_coreflexive_equalizers : Prop :=\n(has_eq : ∀ ⦃A B : C⦄ (f g : A ⟶ B) [is_coreflexive_pair f g], has_equalizer f g)\n\nattribute [instance, priority 1] has_reflexive_coequalizers.has_coeq\nattribute [instance, priority 1] has_coreflexive_equalizers.has_eq\n\nlemma has_coequalizer_of_common_section [has_reflexive_coequalizers C]\n  {A B : C} {f g : A ⟶ B} (r : B ⟶ A)\n  (rf : r ≫ f = 𝟙 _) (rg : r ≫ g = 𝟙 _) :\n  has_coequalizer f g :=\nbegin\n  letI := is_reflexive_pair.mk' r rf rg,\n  apply_instance\nend\n\nlemma has_equalizer_of_common_retraction [has_coreflexive_equalizers C]\n  {A B : C} {f g : A ⟶ B} (r : B ⟶ A)\n  (fr : f ≫ r = 𝟙 _) (gr : g ≫ r = 𝟙 _) :\n  has_equalizer f g :=\nbegin\n  letI := is_coreflexive_pair.mk' r fr gr,\n  apply_instance\nend\n\n/-- If `C` has coequalizers, then it has reflexive coequalizers. -/\n@[priority 100]\ninstance has_reflexive_coequalizers_of_has_coequalizers [has_coequalizers C] :\n  has_reflexive_coequalizers C :=\n{ has_coeq := λ A B f g i, by apply_instance }\n\n/-- If `C` has equalizers, then it has coreflexive equalizers. -/\n@[priority 100]\ninstance has_coreflexive_equalizers_of_has_equalizers [has_equalizers C] :\n  has_coreflexive_equalizers C :=\n{ has_eq := λ A B f g i, by apply_instance }\n\nend limits\n\nopen limits\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/shapes/reflexive.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.731058578630005, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.47876640976582}}
{"text": "import Geo.Background.Real\nimport Geo.Background.List\nimport Geo.Background.Vec\nimport Geo.Background.Set\nimport Geo.Background.Tuple\nimport Geo.Geo.Analytic\n\n/-\nCurrently, we do not require NDGs in the constructions.\nWe will experiment with requiring them only for the theorems about the constructions,\nand perhaps auto-generating them from the theorem statements.\n\nSo far I have found the `HasOn` typeclass to be convenient because of all the helper functions,\nbut so far the other typeclasses have mostly just preempted the ⟨⟩ notation without much benefit.\n-/\n\nnamespace Geo\n\nclass HasOn (α : Type) := (on : Point → α → Prop)\ndef on {α : Type} [HasOn α] : Point → α → Prop := HasOn.on\n\nclass HasInOrderOn (α : Type) := (inOrderOn: List Point → α → Prop)\ndef inOrderOn {α : Type} [HasInOrderOn α] : List Point → α → Prop := HasInOrderOn.inOrderOn\n\nsection\nvariables {α β : Type} [HasOn α] [HasOn β]\n\ndef allOn (ps : List Point) (x : α) : Prop := ps.allP (flip on x)\n\ndef intersectAt (x : α) (y : β) : Set Point := λ p => on p x ∧ on p y\ndef intersectAt₂ (x : α) (y : β) (p₁ p₂ : Point) : Prop :=\nintersectAt x y p₁ ∧ intersectAt x y p₂ ∧ p₁ ≠ p₂\ndef intersect (x : α) (y : β) : Prop := Exists (intersectAt x y)\n\ndef allIntersectAt (xs : List α) : Set Point := λ p => xs.allP (on p)\ndef allIntersect (xs : List α) : Prop := Exists (allIntersectAt xs)\n\ndef allIntersectAt₂ (xs : List α) (ys : List β) : Set Point :=\nλ p => xs.allP (on p) ∧ ys.allP (on p)\ndef allIntersect₂ (xs : List α) (ys : List β) : Prop :=\nExists (allIntersectAt₂ xs ys)\n\ndef intersectAtMany (x : α) (y : β) (ps : List Point) : Prop :=\nps.allP (λ p => intersectAt x y p)\n\ndef tangentAt (x : α) (y : β) : Set Point := unique (intersectAt x y)\ndef tangent (x : α) (y : β) : Prop := Exists (tangentAt x y)\n\nend\n\nclass HasInside (α : Type) := (inside : Point → α → Prop)\ndef inside {α : Type} [HasInside α] : Point → α → Prop := HasInside.inside\n\nclass HasReflect (α β : Type) : Type := (reflect : α → β → α)\ndef reflect {α β : Type} [HasReflect α β] : α → β → α := HasReflect.reflect\n\nclass HasUnsignedArea (α : Type) : Type := (uarea : α → ℝ≥)\ndef uarea {α : Type} [HasUnsignedArea α] : α → ℝ≥ := HasUnsignedArea.uarea\n\nclass HasSignedArea (α : Type) : Type := (sarea : α → ℝ)\ndef sarea {α : Type} [HasSignedArea α] : α → ℝ  := HasSignedArea.sarea\n\nclass HasLength (α : Type) := (ulen : α → ℝ≥)\ndef ulen {α : Type} [HasLength α] : α → ℝ≥ := HasLength.ulen\n\nstructure Line : Type := (p₁ p₂ : Point)\n\nnamespace Line\n\ndef same (l₁ l₂ : Line) : Prop := WIP\n\ndef wf : Line → Prop\n| ⟨a, b⟩ => a ≠ b\n\nprotected def on (p : Point) : Line → Prop\n| ⟨a, b⟩ => a ≠ b ∧ Analytic.coll p a b -- TODO: bundle NDGs like this?\ninstance : HasOn Line := ⟨Line.on⟩\n\nprotected def inOrderOn (ps : List Point) : Line → Prop := WIP\ninstance : HasInOrderOn Line := ⟨Line.inOrderOn⟩\n\nnoncomputable def reflectPL (p : Point) (l : Line) : Point := WIP -- ARITH\nnoncomputable def reflectLL (l₁ l₂ : Line) : Line := WIP -- ARITH\nnoncomputable instance ReflectPL : HasReflect Point Line := ⟨reflectPL⟩\nnoncomputable instance ReflectLL : HasReflect Line Line := ⟨reflectLL⟩\n\nnoncomputable def buildPara (p : Point) (l : Line) : Line := WIP -- build a line passing through p parallel to l\n\nend Line\n\nnoncomputable def coll : Point → Point → Point → Prop := Analytic.coll\nnoncomputable def foot (p : Point) (l : Line) : Point := WIP -- ARITH\nnoncomputable def perpTo (p q : Point) : Point := WIP -- ARITH\n\ndef para (l₁ l₂ : Line) : Prop :=\nl₁.wf ∧ l₂.wf ∧ Analytic.para l₁.p₁ l₁.p₂ l₂.p₁ l₂.p₂\n\ndef perp (l₁ l₂ : Line) : Prop :=\nl₁.wf ∧ l₂.wf ∧ Analytic.perp l₁.p₁ l₁.p₂ l₂.p₁ l₂.p₂\n\nstructure Seg : Type := (src dst : Point)\n\nnamespace Seg\n\nprotected def on (p : Point) (l : Seg) : Prop := WIP -- (on line & btw, including endpoints)\ninstance : HasOn Seg := ⟨Seg.on⟩\n\ndef strictlyBtw (p₁ p₂ p₃ : Point) : Prop :=\non p₁ (Seg.mk p₂ p₃) ∧ p₁ ≠ p₂ ∧ p₁ ≠ p₃\n\nprotected def inOrderOn (ps : List Point) : Seg → Prop := WIP\ninstance : HasInOrderOn Seg := ⟨Seg.inOrderOn⟩\n\nprotected noncomputable def ulen (l : Seg) : ℝ≥ :=\n⟨Analytic.dist l.src l.dst, Analytic.distGe0 _ _⟩\n\nnoncomputable instance : HasLength Seg := ⟨Seg.ulen⟩\n\nprotected noncomputable def midp (l : Seg) : Point := Analytic.midp l.src l.dst\nprotected def isMidpoint (p : Point) (l : Seg) : Prop := p = l.midp\n\ndef cong (l₁ l₂ : Seg) : Prop := ulen l₁ = ulen l₂\n\nend Seg\n\nnoncomputable def perpBis (l : Seg) : Line := ⟨Seg.midp l, perpTo (Seg.midp l) l.dst⟩\ndef isPerpBis (l : Line) (s : Seg) : Prop := Line.same l (perpBis s)\n\nstructure Ray : Type := (src dst : Point)\n\nnamespace Ray\n\n-- `Ray.buildBeyond x beyond` builds the ray `Ray.mk beyond (reflect x beyond)`\nnoncomputable def buildBeyond (x beyond : Point) : Ray := WIP\n\nprotected def on (p : Point) (l : Ray) : Prop := WIP\ninstance : HasOn Ray := ⟨Ray.on⟩\n\nprotected def inOrderOn (ps : List Point) : Ray → Prop := WIP\ninstance : HasInOrderOn Ray := ⟨Ray.inOrderOn⟩\n\ndef toLine (l : Ray) : Line := ⟨l.src, l.dst⟩\ninstance : HasCoe Ray Line := ⟨toLine⟩\n\nend Ray\n\nstructure Circle : Type := (origin : Point) (radius : ℝ₊)\n\nnamespace Circle\n\nprotected def on (p : Point) (Γ : Circle) : Prop :=\nΓ.radius = ⟨Analytic.dist p Γ.origin, Analytic.distGe0 _ _⟩\n\ninstance : HasOn Circle := ⟨Circle.on⟩\n\nprotected def inOrderOn (ps : List Point) : Circle → Prop := WIP\ninstance : HasInOrderOn Circle := ⟨Circle.inOrderOn⟩\n\nprotected def inside (p : Point) (Γ : Circle) : Prop :=\nΓ.radius > ⟨Analytic.dist p Γ.origin, Analytic.distGe0 _ _⟩\n\ninstance : HasInside Circle := ⟨Circle.inside⟩\n\nnoncomputable def diameter (Γ : Circle) : ℝ₊ := Γ.radius * 2\ndef isDiameter (p₁ p₂ : Point) (Γ : Circle) : Prop :=\non p₁ Γ ∧ on p₂ Γ ∧ Seg.isMidpoint (Γ.origin) ⟨p₁, p₂⟩\n\nprotected noncomputable def uarea (Γ : Circle) : ℝ≥ :=\nπ * Γ.radius^2\n\nnoncomputable instance : HasUnsignedArea Circle := ⟨Circle.uarea⟩\n\nnoncomputable def lineTangentAtP (Γ : Circle) (p : Point) : Line := WIP\n\nprotected noncomputable def buildOP (origin p : Point) : Circle := WIP\nprotected noncomputable def buildPPP (p₁ p₂ p₃ : Point) : Circle := WIP\nprotected noncomputable def buildDiam (p₁ p₂ : Point) : Circle :=\nCircle.buildOP (Seg.midp ⟨p₁, p₂⟩) p₁\n\ndef isOrigin (p : Point) (Γ : Circle) : Prop := p = Γ.origin\n\nend Circle\n\nnoncomputable def cycl (ps : List Point) : Prop :=\nExists (λ (Γ : Circle) => allOn ps Γ)\n\nstructure Arc (Γ : Circle) : Type := (src dst avoid : Point)\n\nnamespace Arc\n\nvariable {Γ : Circle}\n\nprotected def on (p : Point) (arc : Arc Γ) : Prop := WIP -- ARITH\ninstance: HasOn (Arc Γ) := ⟨Arc.on⟩\n\nprotected noncomputable def ulen (arc : Arc Γ) : ℝ≥ := WIP -- ARITH\nnoncomputable instance : HasLength (Arc Γ) := ⟨Arc.ulen⟩\n\nnoncomputable def buildMinor (Γ : Circle) : Point → Point → Arc Γ := WIP\nnoncomputable def buildMajor (Γ : Circle) : Point → Point → Arc Γ := WIP\n\nprotected noncomputable def midp (a : Arc Γ) : Point := WIP\nprotected def isMidpoint (p : Point) (a : Arc Γ) : Prop := p = a.midp\n\nend Arc\n\ndef isChord (Γ : Circle) (l : Seg) : Prop := on l.src Γ ∧ on l.dst Γ\n\nopen Triple (cmap any all)\n\ndef Angle : Type := Triple Point\n\nnoncomputable def uangle : Angle → ℝ2π := WIP\nnoncomputable def dangle : Angle → ℝπ  := WIP\n\nnamespace Angle\n\nnoncomputable def bisector : Angle → Line := WIP\ndef isBisector (l : Line) (ang : Angle) : Prop := WIP\n\ndef isRight : Angle → Prop := WIP\n\nend Angle\n\ndef Triangle : Type := Triple Point\n\nnamespace Triangle\n\nprotected def mk (A B C : Point) : Triangle := ⟨A, B, C⟩\n\nprotected noncomputable def buildLLL (ls : Triple Line) : Triangle := WIP\n\nprotected def on : Point → Triangle → Prop := WIP\n\ninstance : HasOn Triangle := ⟨Triangle.on⟩\n\nprotected def inside : Point → Triangle → Prop := WIP\ninstance : HasInside Triangle := ⟨Triangle.inside⟩\n\nprotected noncomputable def uarea : Triangle → ℝ₊ := WIP\nnoncomputable instance : HasUnsignedArea Triangle := ⟨Triangle.uarea⟩\n\nprotected noncomputable def sarea : Triangle → ℝ := WIP\nnoncomputable instance : HasSignedArea Triangle := ⟨Triangle.sarea⟩\n\ndef sides : Triangle → Triple Seg\n| ⟨A, B, C⟩ => ⟨⟨B, C⟩, ⟨C, A⟩, ⟨A, B⟩⟩\n\ndef vertices : Triangle → Triple Point\n| ⟨A, B, C⟩ => ⟨A, B, C⟩\n\nnoncomputable def sideLengths (tri : Triangle) : Triple ℝ≥ :=\nulen <$> sides tri\n\ndef esides : Triangle → Triple Line\n| ⟨A, B, C⟩ => ⟨⟨B, C⟩, ⟨C, A⟩, ⟨A, B⟩⟩\n\n-- RK: note that tri.cycles returns angles in the following order [B, C, A]\nnoncomputable def angles (tri : Triangle) : Triple Angle :=\nmatch tri.cycles with ⟨B, C, A⟩ => ⟨A, B, C⟩\n\ndef isRight (tri : Triangle) : Prop :=\nTriple.any Angle.isRight tri.angles\n\nnoncomputable def uangles (tri : Triangle) : Triple ℝ2π :=\nuangle <$> tri.angles\n\nnoncomputable def dangles (tri : Triangle) : Triple ℝπ  :=\ndangle <$> tri.angles\n\nnoncomputable def altitudes : Triangle → Triple Seg :=\ncmap $ λ tri => ⟨tri.A, foot tri.A ⟨tri.B, tri.C⟩⟩\n\nnoncomputable def medians : Triangle → Triple Seg :=\ncmap $ λ tri => ⟨tri.A, Seg.midp ⟨tri.B, tri.C⟩⟩\n\nnoncomputable def circumcenter  : Triangle → Point := WIP\nnoncomputable def incenter      : Triangle → Point := WIP\nnoncomputable def orthocenter   : Triangle → Point := WIP\nnoncomputable def centroid      : Triangle → Point := WIP\nnoncomputable def excenters     : Triangle → Triple Point := WIP\n\ndef isIncenter (p : Point) (tri : Triangle) : Prop := p = tri.incenter\n\nprotected noncomputable def circumcircle  : Triangle → Circle := WIP\n-- ryankrue: excircles.A ought to be the excircle across from X in a triangle ⟨X, Y, Z⟩\nnoncomputable def excircles     : Triangle → Triple Circle := WIP\nnoncomputable def incircle      : Triangle → Circle := WIP\n\n/-\nSee the following link for formula in Trilinear coordinates:\n\nen.wikipedia.org/wiki/Incircle_and_excircles_of_a_triangle#Gergonne_triangle_and_point\n\nIMO 2000 P6 requires this. There are notes there for more general ways to accomplish this.\n\nChen also has an easy way to get this.\n-/\n-- Points ordered as ⟨Ta, Tb, Tc⟩\nnoncomputable def gergonneTriangle : Triangle → Triangle := WIP\n\nnoncomputable def circumradius   : Triangle → ℝ₊ := WIP\nnoncomputable def inradius       : Triangle → ℝ₊ := WIP\nnoncomputable def exradii        : Triangle → Triple ℝ₊ := WIP\n\nnoncomputable def pedalTriangle  : Triangle → Point → Triangle := WIP\n\nnoncomputable def orthicTriangle (tri : Triangle) : Triangle :=\npedalTriangle tri tri.orthocenter\n\nnoncomputable def medialTriangle (tri : Triangle) : Triangle :=\npedalTriangle tri tri.circumcenter\n\nnoncomputable def ceviansThrough (tri : Triangle) (p : Point) : Triple Line := WIP\n\n-- Awkward\ndef cevian (tri : Triangle) (l : Seg) : Prop :=\nany (λ (tri : Triangle) => tri.A = l.src ∧ on l.dst tri.esides.A) tri.cycles\n\ndef acute (tri : Triangle)       : Prop := WIP\ndef scalene (tri : Triangle)     : Prop := WIP\ndef isosceles (tri : Triangle)   : Prop := WIP\ndef equilateral (tri : Triangle) : Prop := WIP\n\nend Triangle\n\nopen Quadruple (cmap any all)\n\nabbrev Quadrilateral : Type := Quadruple Point\n\nnamespace Quadrilateral\n\nprotected def mk (A B C D : Point) : Quadrilateral := ⟨A, B, C, D⟩\n\nprotected def on : Point → Quadrilateral → Prop := WIP\n\ninstance : HasOn Quadrilateral := ⟨Quadrilateral.on⟩\n\nprotected def inside : Point → Quadrilateral → Prop := WIP\ninstance : HasInside Quadrilateral := ⟨Quadrilateral.inside⟩\n\nprotected noncomputable def uarea : Quadrilateral → ℝ₊ := WIP\nnoncomputable instance : HasUnsignedArea Quadrilateral := ⟨Quadrilateral.uarea⟩\n\nprotected noncomputable def sarea : Quadrilateral → ℝ := WIP\nnoncomputable instance : HasSignedArea Quadrilateral := ⟨Quadrilateral.sarea⟩\n\ndef sides : Quadrilateral → Quadruple Seg\n| ⟨A, B, C, D⟩ => ⟨⟨A, B⟩, ⟨B, C⟩, ⟨C, D⟩, ⟨D, A⟩⟩\n\nnoncomputable def sideLengths (quad : Quadrilateral) : Quadruple ℝ≥ :=\nulen <$> sides quad\n\ndef esides : Quadrilateral → Quadruple Line\n| ⟨A, B, C, D⟩ => ⟨⟨A, B⟩, ⟨B, C⟩, ⟨C, D⟩, ⟨D, A⟩⟩\n\nnoncomputable def angles : Quadrilateral → Quadruple Angle\n| ⟨A, B, C, D⟩ => ⟨⟨D, A, B⟩, ⟨A, B, C⟩, ⟨B, C, D⟩, ⟨C, D, A⟩⟩\n\nnoncomputable def uangles (quad : Quadrilateral) : Quadruple ℝ2π :=\nuangle <$> quad.angles\n\nnoncomputable def dangles (quad : Quadrilateral) : Quadruple ℝπ  :=\ndangle <$> quad.angles\n\n-- could either be that there exists a circle with all points on it,\n-- or could define a circle with three of the points and ensure that the other two are on it\n-- (this way we don't have an existential)\ndef cyclic   : Quadrilateral → Prop\n| ⟨A, B, C, D⟩ => on D (Circle.buildPPP A B C)\ndef convex   : Quadrilateral → Prop := WIP\ndef regular  : Quadrilateral → Prop := WIP\ndef harmonic : Quadrilateral → Prop := WIP\n\ndef parallelogram (quad : Quadrilateral) : Prop :=\nconvex quad ∧ para quad.esides.A quad.esides.C ∧ para quad.esides.B quad.esides.D\n\ndef trapezoid (quad : Quadrilateral) : Prop :=\nconvex quad ∧ (para quad.esides.A quad.esides.C ∨ para quad.esides.B quad.esides.D)\n\nprotected noncomputable def circumcircle (quad : Quadrilateral) (cyclicPf : cyclic quad) : Circle :=\nCircle.buildPPP quad.A quad.B quad.C\n\nend Quadrilateral\n\nopen Triangle Quadrilateral\n\n/-\nTriangle and Quadrilateral could be made Polygons.\nFor now, we keep it this way for convienence,\nand only use Polygon for n ≥ 5.\n-/\nstructure Polygon (n : Nat) : Type := (ps : Vec Point n)\n\nnamespace Polygon\n\nvariables {n : Nat}\n\nnoncomputable def buildPs (ps : List Point) : Polygon (ps.length) := WIP\n\ndef vertices (pgon : Polygon n) : Vec Point n := pgon.ps\n\nnoncomputable def sides (pgon : Polygon n)  : Vec Seg n := WIP\nnoncomputable def sideLengths (pgon : Polygon n)  : Vec ℝ≥ n := WIP\ndef equalSides (pgon : Polygon n) : Prop := pgon.sideLengths.allEq\nnoncomputable def esides (pgon : Polygon n) : Vec Line n := WIP\nnoncomputable def angles (pgon : Polygon n) : Vec Angle n := WIP\n\ndef convex : Polygon n → Prop := WIP\ndef regular : Polygon n → Prop := WIP\n\n-- TODO: Vec.zip (pgon.sides.take half) (pgon.sides.drop half)\nnoncomputable def oppoSides {n} (pgon : Polygon n) (pgonEven : n % 2 = 0)\n: Vec (Seg × Seg) (n / 2) := WIP\n\nend Polygon\n\n/- UNCOMMENT for >2 types intersecting\nnamespace WithInst\n\ndef ListWithInst (ϕ : ∀ (α : Type), Type) : Type 1 := List (Sigma (λ γ => ϕ γ × γ))\ndef allIntersectAt₂ (xs : ListWithInst HasOn) : Set Point :=\nλ p => xs.allP (λ ⟨α, ⟨inst, x⟩⟩ => on p x)\ndef allIntersect₂ (xs : ListWithInst HasOn) : Prop := Exists (allIntersectAt₂ xs)\n\ndef intersectElem {α : Type} [inst : HasOn α] (x : α) : Sigma (λ γ => HasOn γ × γ) := ⟨α, ⟨inst, x⟩⟩\n--def examplePolymorphicSpec (a b c : Point) : Prop :=\nallIntersect₂ [intersectElem $ Seg.mk a b, intersectElem $ Line.mk a c]\n\nend WithInst\n-/\n\nend Geo\n", "meta": {"author": "rkruegs123", "repo": "geometry", "sha": "3dd128e4eec8008764bb94e18b932f9ffd66e6b3", "save_path": "github-repos/lean/rkruegs123-geometry", "path": "github-repos/lean/rkruegs123-geometry/geometry-3dd128e4eec8008764bb94e18b932f9ffd66e6b3/src/Geo/Core.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.47876640976581997}}
{"text": "/-\nCopyright (c) 2022 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport measure_theory.integral.periodic\nimport data.zmod.quotient\n\n/-!\n# Measure-theoretic results about the additive circle\n\nThe file is a place to collect measure-theoretic results about the additive circle.\n\n## Main definitions:\n\n * `add_circle.closed_ball_ae_eq_ball`: open and closed balls in the additive circle are almost\n   equal\n * `add_circle.is_add_fundamental_domain_of_ae_ball`: a ball is a fundamental domain for rational\n   angle rotation in the additive circle\n\n-/\n\nopen set function filter measure_theory measure_theory.measure metric\nopen_locale measure_theory pointwise big_operators topology ennreal\n\nnamespace add_circle\n\nvariables {T : ℝ} [hT : fact (0 < T)]\ninclude hT\n\nlemma closed_ball_ae_eq_ball {x : add_circle T} {ε : ℝ} :\n  closed_ball x ε =ᵐ[volume] ball x ε :=\nbegin\n  cases le_or_lt ε 0 with hε hε,\n  { rw [ball_eq_empty.mpr hε, ae_eq_empty, volume_closed_ball,\n      min_eq_right (by linarith [hT.out] : 2 * ε ≤ T), ennreal.of_real_eq_zero],\n    exact mul_nonpos_of_nonneg_of_nonpos zero_le_two hε, },\n  { suffices : volume (closed_ball x ε) ≤ volume (ball x ε),\n    { exact (ae_eq_of_subset_of_measure_ge ball_subset_closed_ball this measurable_set_ball\n        (measure_ne_top _ _)).symm, },\n    have : tendsto (λ δ, volume (closed_ball x δ)) (𝓝[<] ε) (𝓝 $ volume (closed_ball x ε)),\n    { simp_rw volume_closed_ball,\n      refine ennreal.tendsto_of_real (tendsto.min tendsto_const_nhds $ tendsto.const_mul _ _),\n      convert (@monotone_id ℝ _).tendsto_nhds_within_Iio ε,\n      simp, },\n    refine le_of_tendsto this (mem_nhds_within_Iio_iff_exists_Ioo_subset.mpr ⟨0, hε, λ r hr, _⟩),\n    exact measure_mono (closed_ball_subset_ball hr.2), },\nend\n\n/-- Let `G` be the subgroup of `add_circle T` generated by a point `u` of finite order `n : ℕ`. Then\nany set `I` that is almost equal to a ball of radius `T / 2n` is a fundamental domain for the action\nof `G` on `add_circle T` by left addition. -/\nlemma is_add_fundamental_domain_of_ae_ball (I : set $ add_circle T)\n  (u x : add_circle T) (hu : is_of_fin_add_order u)\n  (hI : I =ᵐ[volume] ball x (T / (2 * add_order_of u))) :\n  is_add_fundamental_domain (add_subgroup.zmultiples u) I :=\nbegin\n  set G := add_subgroup.zmultiples u,\n  set n := add_order_of u,\n  set B := ball x (T / (2 * n)),\n  have hn : 1 ≤ (n : ℝ), { norm_cast, linarith [add_order_of_pos' hu], },\n  refine is_add_fundamental_domain.mk_of_measure_univ_le _ _ _ _,\n  { -- `null_measurable_set I volume`\n    exact (measurable_set_ball.null_measurable_set.congr hI.symm), },\n  { -- `∀ (g : G), g ≠ 0 → ae_disjoint volume (g +ᵥ I) I`\n    rintros ⟨g, hg⟩ hg',\n    replace hg' : g ≠ 0, by simpa only [ne.def, add_subgroup.mk_eq_zero_iff] using hg',\n    change ae_disjoint volume (g +ᵥ I) I,\n    refine ae_disjoint.congr (disjoint.ae_disjoint _)\n      ((quasi_measure_preserving_add_left volume (-g)).vadd_ae_eq_of_ae_eq g hI) hI,\n    have hBg : g +ᵥ B = ball (g + x) (T / (2 * n)),\n    { rw [add_comm g x, ← singleton_add_ball _ x g, add_ball, thickening_singleton], },\n    rw hBg,\n    apply ball_disjoint_ball,\n    rw [dist_eq_norm, add_sub_cancel, div_mul_eq_div_div, ← add_div, ← add_div, add_self_div_two,\n      div_le_iff' (by positivity : 0 < (n : ℝ)), ← nsmul_eq_mul],\n    refine (le_add_order_smul_norm_of_is_of_fin_add_order (hu.of_mem_zmultiples hg) hg').trans\n      (nsmul_le_nsmul (norm_nonneg g) _),\n    exact nat.le_of_dvd (add_order_of_pos_iff.mpr hu) (add_order_of_dvd_of_mem_zmultiples hg), },\n  { -- `∀ (g : G), quasi_measure_preserving (has_vadd.vadd g) volume volume`\n    exact (λ g, quasi_measure_preserving_add_left volume g), },\n  { -- `volume univ ≤ ∑' (g : G), volume (g +ᵥ I)`\n    replace hI : I =ᵐ[volume] closed_ball x (T / (2 * ↑n)) :=\n      hI.trans closed_ball_ae_eq_ball.symm,\n    haveI : fintype G := @fintype.of_finite _ hu.finite_zmultiples,\n    have hG_card : (finset.univ : finset G).card = n,\n    { show _ = add_order_of u, rw [add_order_eq_card_zmultiples', nat.card_eq_fintype_card], refl },\n    simp_rw [measure_vadd],\n    rw [add_circle.measure_univ, tsum_fintype, finset.sum_const, measure_congr hI,\n      volume_closed_ball, ← ennreal.of_real_nsmul, mul_div, mul_div_mul_comm,\n      div_self (@two_ne_zero ℝ _ _ _ _), one_mul, min_eq_right (div_le_self hT.out.le hn), hG_card,\n      nsmul_eq_mul, mul_div_cancel' T (lt_of_lt_of_le zero_lt_one hn).ne.symm],\n    exact le_refl _, },\nend\n\nlemma volume_of_add_preimage_eq (s I : set $ add_circle T) (u x : add_circle T)\n  (hu : is_of_fin_add_order u) (hs : (u +ᵥ s : set $ add_circle T) =ᵐ[volume] s)\n  (hI : I =ᵐ[volume] ball x (T / (2 * add_order_of u))) :\n  volume s = add_order_of u • volume (s ∩ I) :=\nbegin\n  let G := add_subgroup.zmultiples u,\n  haveI : fintype G := @fintype.of_finite _ hu.finite_zmultiples,\n  have hsG : ∀ (g : G), (g +ᵥ s : set $ add_circle T) =ᵐ[volume] s,\n  { rintros ⟨y, hy⟩, exact (vadd_ae_eq_self_of_mem_zmultiples hs hy : _), },\n  rw [(is_add_fundamental_domain_of_ae_ball I u x hu hI).measure_eq_card_smul_of_vadd_ae_eq_self\n    s hsG, add_order_eq_card_zmultiples' u, nat.card_eq_fintype_card],\nend\n\nend add_circle\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/measure_theory/group/add_circle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.47876640976581997}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.functor_category\nimport Mathlib.category_theory.isomorphism\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ u₃ v₃ \n\nnamespace Mathlib\n\n/-!\n# Natural isomorphisms\n\nFor the most part, natural isomorphisms are just another sort of isomorphism.\n\nWe provide some special support for extracting components:\n* if `α : F ≅ G`, then `a.app X : F.obj X ≅ G.obj X`,\nand building natural isomorphisms from components:\n*\n```\nnat_iso.of_components\n  (app : ∀ X : C, F.obj X ≅ G.obj X)\n  (naturality : ∀ {X Y : C} (f : X ⟶ Y), F.map f ≫ (app Y).hom = (app X).hom ≫ G.map f) :\nF ≅ G\n```\nonly needing to check naturality in one direction.\n\n## Implementation\n\nNote that `nat_iso` is a namespace without a corresponding definition;\nwe put some declarations that are specifically about natural isomorphisms in the `iso`\nnamespace so that they are available using dot notation.\n-/\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\n\nnamespace category_theory\n\n\nnamespace iso\n\n\n/-- The application of a natural isomorphism to an object. We put this definition in a different\nnamespace, so that we can use `α.app` -/\n@[simp] theorem app_hom {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} (α : F ≅ G) (X : C) : hom (app α X) = nat_trans.app (hom α) X :=\n  Eq.refl (hom (app α X))\n\n@[simp] theorem hom_inv_id_app_assoc {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) {X' : D} (f' : functor.obj F X ⟶ X') :\n    nat_trans.app (hom α) X ≫ nat_trans.app (inv α) X ≫ f' = f' :=\n  sorry\n\n@[simp] theorem inv_hom_id_app_assoc {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) {X' : D} (f' : functor.obj G X ⟶ X') :\n    nat_trans.app (inv α) X ≫ nat_trans.app (hom α) X ≫ f' = f' :=\n  sorry\n\nend iso\n\n\nnamespace nat_iso\n\n\n@[simp] theorem trans_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} {H : C ⥤ D} (α : F ≅ G) (β : G ≅ H) (X : C) :\n    iso.app (α ≪≫ β) X = iso.app α X ≪≫ iso.app β X :=\n  rfl\n\ntheorem app_hom {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    (α : F ≅ G) (X : C) : iso.hom (iso.app α X) = nat_trans.app (iso.hom α) X :=\n  rfl\n\ntheorem app_inv {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    (α : F ≅ G) (X : C) : iso.inv (iso.app α X) = nat_trans.app (iso.inv α) X :=\n  rfl\n\nprotected instance hom_app_is_iso {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} (α : F ≅ G) (X : C) : is_iso (nat_trans.app (iso.hom α) X) :=\n  is_iso.mk (nat_trans.app (iso.inv α) X)\n\nprotected instance inv_app_is_iso {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} (α : F ≅ G) (X : C) : is_iso (nat_trans.app (iso.inv α) X) :=\n  is_iso.mk (nat_trans.app (iso.hom α) X)\n\n/-!\nUnfortunately we need a separate set of cancellation lemmas for components of natural isomorphisms,\nbecause the `simp` normal form is `α.hom.app X`, rather than `α.app.hom X`.\n\n(With the later, the morphism would be visibly part of an isomorphism, so general lemmas about\nisomorphisms would apply.)\n\nIn the future, we should consider a redesign that changes this simp norm form,\nbut for now it breaks too many proofs.\n-/\n\n@[simp] theorem cancel_nat_iso_hom_left {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : C} {Z : D} (g : functor.obj G X ⟶ Z)\n    (g' : functor.obj G X ⟶ Z) :\n    nat_trans.app (iso.hom α) X ≫ g = nat_trans.app (iso.hom α) X ≫ g' ↔ g = g' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_inv_left {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : C} {Z : D} (g : functor.obj F X ⟶ Z)\n    (g' : functor.obj F X ⟶ Z) :\n    nat_trans.app (iso.inv α) X ≫ g = nat_trans.app (iso.inv α) X ≫ g' ↔ g = g' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_hom_right {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : D} {Y : C} (f : X ⟶ functor.obj F Y)\n    (f' : X ⟶ functor.obj F Y) :\n    f ≫ nat_trans.app (iso.hom α) Y = f' ≫ nat_trans.app (iso.hom α) Y ↔ f = f' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_inv_right {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : D} {Y : C} (f : X ⟶ functor.obj G Y)\n    (f' : X ⟶ functor.obj G Y) :\n    f ≫ nat_trans.app (iso.inv α) Y = f' ≫ nat_trans.app (iso.inv α) Y ↔ f = f' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_hom_right_assoc {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {W : D} {X : D} {X' : D} {Y : C} (f : W ⟶ X)\n    (g : X ⟶ functor.obj F Y) (f' : W ⟶ X') (g' : X' ⟶ functor.obj F Y) :\n    f ≫ g ≫ nat_trans.app (iso.hom α) Y = f' ≫ g' ≫ nat_trans.app (iso.hom α) Y ↔ f ≫ g = f' ≫ g' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_inv_right_assoc {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {W : D} {X : D} {X' : D} {Y : C} (f : W ⟶ X)\n    (g : X ⟶ functor.obj G Y) (f' : W ⟶ X') (g' : X' ⟶ functor.obj G Y) :\n    f ≫ g ≫ nat_trans.app (iso.inv α) Y = f' ≫ g' ≫ nat_trans.app (iso.inv α) Y ↔ f ≫ g = f' ≫ g' :=\n  sorry\n\ntheorem naturality_1 {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    {X : C} {Y : C} (α : F ≅ G) (f : X ⟶ Y) :\n    nat_trans.app (iso.inv α) X ≫ functor.map F f ≫ nat_trans.app (iso.hom α) Y = functor.map G f :=\n  sorry\n\ntheorem naturality_2 {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    {X : C} {Y : C} (α : F ≅ G) (f : X ⟶ Y) :\n    nat_trans.app (iso.hom α) X ≫ functor.map G f ≫ nat_trans.app (iso.inv α) Y = functor.map F f :=\n  sorry\n\n/--\nA natural transformation is an isomorphism if all its components are isomorphisms.\n-/\n-- Making this an instance would cause a typeclass inference loop with `is_iso_app_of_is_iso`.\n\ndef is_iso_of_is_iso_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} (α : F ⟶ G) [(X : C) → is_iso (nat_trans.app α X)] : is_iso α :=\n  is_iso.mk (nat_trans.mk fun (X : C) => inv (nat_trans.app α X))\n\n/--\nThe components of a natural isomorphism are isomorphisms.\n-/\nprotected instance is_iso_app_of_is_iso {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (α : F ⟶ G) [is_iso α] (X : C) : is_iso (nat_trans.app α X) :=\n  is_iso.mk (nat_trans.app (inv α) X)\n\n/--\nConstruct a natural isomorphism between functors by giving object level isomorphisms,\nand checking naturality only in the forward direction.\n-/\ndef of_components {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D}\n    (app : (X : C) → functor.obj F X ≅ functor.obj G X)\n    (naturality :\n      ∀ {X Y : C} (f : X ⟶ Y),\n        functor.map F f ≫ iso.hom (app Y) = iso.hom (app X) ≫ functor.map G f) :\n    F ≅ G :=\n  iso.mk (nat_trans.mk fun (X : C) => iso.hom (app X))\n    (inv (nat_trans.mk fun (X : C) => iso.hom (app X)))\n\n@[simp] theorem of_components.app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : C ⥤ D} (app' : (X : C) → functor.obj F X ≅ functor.obj G X)\n    (naturality :\n      ∀ {X Y : C} (f : X ⟶ Y),\n        functor.map F f ≫ iso.hom (app' Y) = iso.hom (app' X) ≫ functor.map G f)\n    (X : C) : iso.app (of_components app' naturality) X = app' X :=\n  iso.ext (Eq.refl (iso.hom (iso.app (of_components app' naturality) X)))\n\n@[simp] theorem of_components.hom_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (app : (X : C) → functor.obj F X ≅ functor.obj G X)\n    (naturality :\n      ∀ {X Y : C} (f : X ⟶ Y),\n        functor.map F f ≫ iso.hom (app Y) = iso.hom (app X) ≫ functor.map G f)\n    (X : C) : nat_trans.app (iso.hom (of_components app naturality)) X = iso.hom (app X) :=\n  rfl\n\n@[simp] theorem of_components.inv_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : C ⥤ D} (app : (X : C) → functor.obj F X ≅ functor.obj G X)\n    (naturality :\n      ∀ {X Y : C} (f : X ⟶ Y),\n        functor.map F f ≫ iso.hom (app Y) = iso.hom (app X) ≫ functor.map G f)\n    (X : C) : nat_trans.app (iso.inv (of_components app naturality)) X = iso.inv (app X) :=\n  rfl\n\n/-- Horizontal composition of natural isomorphisms. -/\ndef hcomp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E]\n    {F : C ⥤ D} {G : C ⥤ D} {H : D ⥤ E} {I : D ⥤ E} (α : F ≅ G) (β : H ≅ I) : F ⋙ H ≅ G ⋙ I :=\n  iso.mk (iso.hom α ◫ iso.hom β) (iso.inv α ◫ iso.inv β)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/natural_isomorphism_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300048, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.47876640976581986}}
{"text": "/-\nCopyright (c) 2021 Bryan Gin-ge Chen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bryan Gin-ge Chen, Yury Kudryashov\n\n! This file was ported from Lean 3 source module algebra.group.ext\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Hom.Group\n\n/-!\n# Extensionality lemmas for monoid and group structures\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we prove extensionality lemmas for `monoid` and higher algebraic structures with one\nbinary operation. Extensionality lemmas for structures that are lower in the hierarchy can be found\nin `algebra.group.defs`.\n\n## Implementation details\n\nTo get equality of `npow` etc, we define a monoid homomorphism between two monoid structures on the\nsame type, then apply lemmas like `monoid_hom.map_div`, `monoid_hom.map_pow` etc.\n\n## Tags\nmonoid, group, extensionality\n-/\n\n\nuniverse u\n\n/- warning: monoid.ext -> Monoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {{m₁ : Monoid.{u1} M}} {{m₂ : Monoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Monoid.mul.{u1} M m₁) (Monoid.mul.{u1} M m₂)) -> (Eq.{succ u1} (Monoid.{u1} M) m₁ m₂)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m₁ : Monoid.{u1} M}} {{m₂ : Monoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M m₁))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M m₂)))) -> (Eq.{succ u1} (Monoid.{u1} M) m₁ m₂)\nCase conversion may be inaccurate. Consider using '#align monoid.ext Monoid.extₓ'. -/\n@[ext, to_additive]\ntheorem Monoid.ext {M : Type u} ⦃m₁ m₂ : Monoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\n  by\n  have h₁ : (@Monoid.toMulOneClass _ m₁).one = (@Monoid.toMulOneClass _ m₂).one :=\n    congr_arg (@MulOneClass.one M) (MulOneClass.ext h_mul)\n  set f : @MonoidHom M M (@Monoid.toMulOneClass _ m₁) (@Monoid.toMulOneClass _ m₂) :=\n    { toFun := id\n      map_one' := h₁\n      map_mul' := fun x y => congr_fun (congr_fun h_mul x) y }\n  have hpow : m₁.npow = m₂.npow := by\n    ext (n x)\n    exact @MonoidHom.map_pow M M m₁ m₂ f x n\n  cases m₁\n  cases m₂\n  congr <;> assumption\n#align monoid.ext Monoid.ext\n#align add_monoid.ext AddMonoid.ext\n\n#print CommMonoid.toMonoid_injective /-\n@[to_additive]\ntheorem CommMonoid.toMonoid_injective {M : Type u} : Function.Injective (@CommMonoid.toMonoid M) :=\n  by\n  rintro ⟨⟩ ⟨⟩ h\n  congr <;> injection h\n#align comm_monoid.to_monoid_injective CommMonoid.toMonoid_injective\n#align add_comm_monoid.to_add_monoid_injective AddCommMonoid.toAddMonoid_injective\n-/\n\n/- warning: comm_monoid.ext -> CommMonoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {{m₁ : CommMonoid.{u1} M}} {{m₂ : CommMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (CommMonoid.mul.{u1} M m₁) (CommMonoid.mul.{u1} M m₂)) -> (Eq.{succ u1} (CommMonoid.{u1} M) m₁ m₂)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m₁ : CommMonoid.{u1} M}} {{m₂ : CommMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M (CommMonoid.toMonoid.{u1} M m₁)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M (CommMonoid.toMonoid.{u1} M m₂))))) -> (Eq.{succ u1} (CommMonoid.{u1} M) m₁ m₂)\nCase conversion may be inaccurate. Consider using '#align comm_monoid.ext CommMonoid.extₓ'. -/\n@[ext, to_additive]\ntheorem CommMonoid.ext {M : Type _} ⦃m₁ m₂ : CommMonoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\n  CommMonoid.toMonoid_injective <| Monoid.ext h_mul\n#align comm_monoid.ext CommMonoid.ext\n#align add_comm_monoid.ext AddCommMonoid.ext\n\n#print LeftCancelMonoid.toMonoid_injective /-\n@[to_additive]\ntheorem LeftCancelMonoid.toMonoid_injective {M : Type u} :\n    Function.Injective (@LeftCancelMonoid.toMonoid M) :=\n  by\n  rintro ⟨⟩ ⟨⟩ h\n  congr <;> injection h\n#align left_cancel_monoid.to_monoid_injective LeftCancelMonoid.toMonoid_injective\n#align add_left_cancel_monoid.to_add_monoid_injective AddLeftCancelMonoid.toAddMonoid_injective\n-/\n\n/- warning: left_cancel_monoid.ext -> LeftCancelMonoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {{m₁ : LeftCancelMonoid.{u1} M}} {{m₂ : LeftCancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (LeftCancelMonoid.mul.{u1} M m₁) (LeftCancelMonoid.mul.{u1} M m₂)) -> (Eq.{succ u1} (LeftCancelMonoid.{u1} M) m₁ m₂)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m₁ : LeftCancelMonoid.{u1} M}} {{m₂ : LeftCancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M m₁)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M m₂))))) -> (Eq.{succ u1} (LeftCancelMonoid.{u1} M) m₁ m₂)\nCase conversion may be inaccurate. Consider using '#align left_cancel_monoid.ext LeftCancelMonoid.extₓ'. -/\n@[ext, to_additive]\ntheorem LeftCancelMonoid.ext {M : Type u} ⦃m₁ m₂ : LeftCancelMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :\n    m₁ = m₂ :=\n  LeftCancelMonoid.toMonoid_injective <| Monoid.ext h_mul\n#align left_cancel_monoid.ext LeftCancelMonoid.ext\n#align add_left_cancel_monoid.ext AddLeftCancelMonoid.ext\n\n#print RightCancelMonoid.toMonoid_injective /-\n@[to_additive]\ntheorem RightCancelMonoid.toMonoid_injective {M : Type u} :\n    Function.Injective (@RightCancelMonoid.toMonoid M) :=\n  by\n  rintro ⟨⟩ ⟨⟩ h\n  congr <;> injection h\n#align right_cancel_monoid.to_monoid_injective RightCancelMonoid.toMonoid_injective\n#align add_right_cancel_monoid.to_add_monoid_injective AddRightCancelMonoid.toAddMonoid_injective\n-/\n\n/- warning: right_cancel_monoid.ext -> RightCancelMonoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {{m₁ : RightCancelMonoid.{u1} M}} {{m₂ : RightCancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (RightCancelMonoid.mul.{u1} M m₁) (RightCancelMonoid.mul.{u1} M m₂)) -> (Eq.{succ u1} (RightCancelMonoid.{u1} M) m₁ m₂)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m₁ : RightCancelMonoid.{u1} M}} {{m₂ : RightCancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (RightCancelSemigroup.toSemigroup.{u1} M (RightCancelMonoid.toRightCancelSemigroup.{u1} M m₁)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (RightCancelSemigroup.toSemigroup.{u1} M (RightCancelMonoid.toRightCancelSemigroup.{u1} M m₂))))) -> (Eq.{succ u1} (RightCancelMonoid.{u1} M) m₁ m₂)\nCase conversion may be inaccurate. Consider using '#align right_cancel_monoid.ext RightCancelMonoid.extₓ'. -/\n@[ext, to_additive]\ntheorem RightCancelMonoid.ext {M : Type u} ⦃m₁ m₂ : RightCancelMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :\n    m₁ = m₂ :=\n  RightCancelMonoid.toMonoid_injective <| Monoid.ext h_mul\n#align right_cancel_monoid.ext RightCancelMonoid.ext\n#align add_right_cancel_monoid.ext AddRightCancelMonoid.ext\n\n#print CancelMonoid.toLeftCancelMonoid_injective /-\n@[to_additive]\ntheorem CancelMonoid.toLeftCancelMonoid_injective {M : Type u} :\n    Function.Injective (@CancelMonoid.toLeftCancelMonoid M) :=\n  by\n  rintro ⟨⟩ ⟨⟩ h\n  congr <;> injection h\n#align cancel_monoid.to_left_cancel_monoid_injective CancelMonoid.toLeftCancelMonoid_injective\n#align add_cancel_monoid.to_left_cancel_add_monoid_injective AddCancelMonoid.toAddLeftCancelMonoid_injective\n-/\n\n/- warning: cancel_monoid.ext -> CancelMonoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {{m₁ : CancelMonoid.{u1} M}} {{m₂ : CancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (CancelMonoid.mul.{u1} M m₁) (CancelMonoid.mul.{u1} M m₂)) -> (Eq.{succ u1} (CancelMonoid.{u1} M) m₁ m₂)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m₁ : CancelMonoid.{u1} M}} {{m₂ : CancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M (CancelMonoid.toLeftCancelMonoid.{u1} M m₁))))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M (CancelMonoid.toLeftCancelMonoid.{u1} M m₂)))))) -> (Eq.{succ u1} (CancelMonoid.{u1} M) m₁ m₂)\nCase conversion may be inaccurate. Consider using '#align cancel_monoid.ext CancelMonoid.extₓ'. -/\n@[ext, to_additive]\ntheorem CancelMonoid.ext {M : Type _} ⦃m₁ m₂ : CancelMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :\n    m₁ = m₂ :=\n  CancelMonoid.toLeftCancelMonoid_injective <| LeftCancelMonoid.ext h_mul\n#align cancel_monoid.ext CancelMonoid.ext\n#align add_cancel_monoid.ext AddCancelMonoid.ext\n\n#print CancelCommMonoid.toCommMonoid_injective /-\n@[to_additive]\ntheorem CancelCommMonoid.toCommMonoid_injective {M : Type u} :\n    Function.Injective (@CancelCommMonoid.toCommMonoid M) :=\n  by\n  rintro ⟨⟩ ⟨⟩ h\n  congr <;> injection h\n#align cancel_comm_monoid.to_comm_monoid_injective CancelCommMonoid.toCommMonoid_injective\n#align add_cancel_comm_monoid.to_add_comm_monoid_injective AddCancelCommMonoid.toAddCommMonoid_injective\n-/\n\n/- warning: cancel_comm_monoid.ext -> CancelCommMonoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {{m₁ : CancelCommMonoid.{u1} M}} {{m₂ : CancelCommMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (CancelCommMonoid.mul.{u1} M m₁) (CancelCommMonoid.mul.{u1} M m₂)) -> (Eq.{succ u1} (CancelCommMonoid.{u1} M) m₁ m₂)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m₁ : CancelCommMonoid.{u1} M}} {{m₂ : CancelCommMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M (CancelCommMonoid.toLeftCancelMonoid.{u1} M m₁))))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M (CancelCommMonoid.toLeftCancelMonoid.{u1} M m₂)))))) -> (Eq.{succ u1} (CancelCommMonoid.{u1} M) m₁ m₂)\nCase conversion may be inaccurate. Consider using '#align cancel_comm_monoid.ext CancelCommMonoid.extₓ'. -/\n@[ext, to_additive]\ntheorem CancelCommMonoid.ext {M : Type _} ⦃m₁ m₂ : CancelCommMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :\n    m₁ = m₂ :=\n  CancelCommMonoid.toCommMonoid_injective <| CommMonoid.ext h_mul\n#align cancel_comm_monoid.ext CancelCommMonoid.ext\n#align add_cancel_comm_monoid.ext AddCancelCommMonoid.ext\n\n/- warning: div_inv_monoid.ext -> DivInvMonoid.ext is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {{m₁ : DivInvMonoid.{u1} M}} {{m₂ : DivInvMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (DivInvMonoid.mul.{u1} M m₁) (DivInvMonoid.mul.{u1} M m₂)) -> (Eq.{succ u1} (M -> M) (DivInvMonoid.inv.{u1} M m₁) (DivInvMonoid.inv.{u1} M m₂)) -> (Eq.{succ u1} (DivInvMonoid.{u1} M) m₁ m₂)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m₁ : DivInvMonoid.{u1} M}} {{m₂ : DivInvMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M (DivInvMonoid.toMonoid.{u1} M m₁)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M (DivInvMonoid.toMonoid.{u1} M m₂))))) -> (Eq.{succ u1} (M -> M) (Inv.inv.{u1} M (DivInvMonoid.toInv.{u1} M m₁)) (Inv.inv.{u1} M (DivInvMonoid.toInv.{u1} M m₂))) -> (Eq.{succ u1} (DivInvMonoid.{u1} M) m₁ m₂)\nCase conversion may be inaccurate. Consider using '#align div_inv_monoid.ext DivInvMonoid.extₓ'. -/\n@[ext, to_additive]\ntheorem DivInvMonoid.ext {M : Type _} ⦃m₁ m₂ : DivInvMonoid M⦄ (h_mul : m₁.mul = m₂.mul)\n    (h_inv : m₁.inv = m₂.inv) : m₁ = m₂ :=\n  by\n  have h₁ : (@DivInvMonoid.toMonoid _ m₁).one = (@DivInvMonoid.toMonoid _ m₂).one :=\n    congr_arg (@Monoid.one M) (Monoid.ext h_mul)\n  set f : @MonoidHom M M (by letI := m₁ <;> infer_instance) (by letI := m₂ <;> infer_instance) :=\n    { toFun := id\n      map_one' := h₁\n      map_mul' := fun x y => congr_fun (congr_fun h_mul x) y }\n  have hpow : (@DivInvMonoid.toMonoid _ m₁).npow = (@DivInvMonoid.toMonoid _ m₂).npow :=\n    congr_arg (@Monoid.npow M) (Monoid.ext h_mul)\n  have hzpow : m₁.zpow = m₂.zpow := by\n    ext (m x)\n    exact @MonoidHom.map_zpow' M M m₁ m₂ f (congr_fun h_inv) x m\n  have hdiv : m₁.div = m₂.div := by\n    ext (a b)\n    exact @map_div' M M _ m₁ m₂ _ f (congr_fun h_inv) a b\n  cases m₁\n  cases m₂\n  congr\n  exacts[h_mul, h₁, hpow, h_inv, hdiv, hzpow]\n#align div_inv_monoid.ext DivInvMonoid.ext\n#align sub_neg_monoid.ext SubNegMonoid.ext\n\n/- warning: group.ext -> Group.ext is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {{g₁ : Group.{u1} G}} {{g₂ : Group.{u1} G}}, (Eq.{succ u1} (G -> G -> G) (Group.mul.{u1} G g₁) (Group.mul.{u1} G g₂)) -> (Eq.{succ u1} (Group.{u1} G) g₁ g₂)\nbut is expected to have type\n  forall {G : Type.{u1}} {{g₁ : Group.{u1} G}} {{g₂ : Group.{u1} G}}, (Eq.{succ u1} (G -> G -> G) (Mul.mul.{u1} G (Semigroup.toMul.{u1} G (Monoid.toSemigroup.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G g₁))))) (Mul.mul.{u1} G (Semigroup.toMul.{u1} G (Monoid.toSemigroup.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G g₂)))))) -> (Eq.{succ u1} (Group.{u1} G) g₁ g₂)\nCase conversion may be inaccurate. Consider using '#align group.ext Group.extₓ'. -/\n@[ext, to_additive]\ntheorem Group.ext {G : Type _} ⦃g₁ g₂ : Group G⦄ (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ :=\n  by\n  set f :=\n    @MonoidHom.mk' G G (by letI := g₁ <;> infer_instance) g₂ id fun a b =>\n      congr_fun (congr_fun h_mul a) b\n  exact\n    Group.toDivInvMonoid_injective\n      (DivInvMonoid.ext h_mul\n        (funext <| @MonoidHom.map_inv G G g₁ (@Group.toDivisionMonoid _ g₂) f))\n#align group.ext Group.ext\n#align add_group.ext AddGroup.ext\n\n/- warning: comm_group.ext -> CommGroup.ext is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {{g₁ : CommGroup.{u1} G}} {{g₂ : CommGroup.{u1} G}}, (Eq.{succ u1} (G -> G -> G) (CommGroup.mul.{u1} G g₁) (CommGroup.mul.{u1} G g₂)) -> (Eq.{succ u1} (CommGroup.{u1} G) g₁ g₂)\nbut is expected to have type\n  forall {G : Type.{u1}} {{g₁ : CommGroup.{u1} G}} {{g₂ : CommGroup.{u1} G}}, (Eq.{succ u1} (G -> G -> G) (Mul.mul.{u1} G (Semigroup.toMul.{u1} G (Monoid.toSemigroup.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G g₁)))))) (Mul.mul.{u1} G (Semigroup.toMul.{u1} G (Monoid.toSemigroup.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G (CommGroup.toGroup.{u1} G g₂))))))) -> (Eq.{succ u1} (CommGroup.{u1} G) g₁ g₂)\nCase conversion may be inaccurate. Consider using '#align comm_group.ext CommGroup.extₓ'. -/\n@[ext, to_additive]\ntheorem CommGroup.ext {G : Type _} ⦃g₁ g₂ : CommGroup G⦄ (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ :=\n  CommGroup.toGroup_injective <| Group.ext h_mul\n#align comm_group.ext CommGroup.ext\n#align add_comm_group.ext AddCommGroup.ext\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Group/Ext.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7310585727705127, "lm_q1q2_score": 0.47876640592846936}}
{"text": "\nimport for_mathlib.short_exact\nimport for_mathlib.derived.defs\n\nnoncomputable theory\n\nopen category_theory category_theory.limits\n\nvariables {A : Type*} [category A] [abelian A] [enough_projectives A]\nvariables {X Y Z : cochain_complex A ℤ} (f : X ⟶ Y) (g : Y ⟶ Z)\n\n-- this files exists to save these lemmas from a file that will probably get nuked\n\n-- move me\nlemma biprod.lift_desc_comm {X₁ X₂ Y₁ Y₂ : A}\n  (f₁₁ : X₁ ⟶ Y₁) (f₁₂ : X₁ ⟶ Y₂) (f₂₁ : X₂ ⟶ Y₁) (f₂₂ : X₂ ⟶ Y₂) :\n  biprod.lift (biprod.desc f₁₁ f₂₁) (biprod.desc f₁₂ f₂₂) =\n  biprod.desc (biprod.lift f₁₁ f₁₂) (biprod.lift f₂₁ f₂₂) :=\nby ext; simp only [category.assoc,\n  biprod.lift_fst, biprod.lift_snd, biprod.inl_desc, biprod.inr_desc]\n\n-- move me\nlemma biprod.comp_lift {W X Y Z : A} (f : W ⟶ X) (g : X ⟶ Y) (h : X ⟶ Z) :\n  f ≫ biprod.lift g h = biprod.lift (f ≫ g) (f ≫ h) :=\nby ext; simp only [category.assoc, biprod.lift_fst, biprod.lift_snd]\n\n-- move me\n@[reassoc]\nlemma comp_factor_thru_image_eq_zero {X Y Z : A} (f : X ⟶ Y) (g : Y ⟶ Z) (w : f ≫ g = 0) :\n  f ≫ factor_thru_image g = 0 :=\nby rw [← cancel_mono (limits.image.ι g), category.assoc, limits.image.fac, w, zero_comp]\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/random_homological_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4787211700076092}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport data.stream.defs\nimport tactic.ext\nimport logic.function.basic\n\n/-!\n# Streams a.k.a. infinite lists a.k.a. infinite sequences\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file used to be in the core library. It was moved to `mathlib` and renamed to `init` to avoid\nname clashes.  -/\n\nopen nat function option\n\nuniverses u v w\n\nnamespace stream\nvariables {α : Type u} {β : Type v} {δ : Type w}\n\ninstance {α} [inhabited α] : inhabited (stream α) :=\n⟨stream.const default⟩\n\nprotected theorem eta (s : stream α) : head s :: tail s = s :=\nfunext (λ i, begin cases i; refl end)\n\n@[simp] theorem nth_zero_cons (a : α) (s : stream α) : nth (a :: s) 0 = a := rfl\n\ntheorem head_cons (a : α) (s : stream α) : head (a :: s) = a := rfl\n\ntheorem tail_cons (a : α) (s : stream α) : tail (a :: s) = s := rfl\n\ntheorem tail_drop (n : nat) (s : stream α) : tail (drop n s) = drop n (tail s) :=\nfunext (λ i, begin unfold tail drop, simp [nth, nat.add_comm, nat.add_left_comm] end)\n\ntheorem nth_drop (n m : nat) (s : stream α) : nth (drop m s) n = nth s (n + m) := rfl\n\ntheorem tail_eq_drop (s : stream α) : tail s = drop 1 s := rfl\n\ntheorem drop_drop (n m : nat) (s : stream α) : drop n (drop m s) = drop (n+m) s :=\nfunext (λ i, begin unfold drop, rw nat.add_assoc end)\n\ntheorem nth_succ (n : nat) (s : stream α) : nth s (succ n) = nth (tail s) n := rfl\n\n@[simp] lemma nth_succ_cons (n : nat) (s : stream α) (x : α) : nth (x :: s) n.succ = nth s n := rfl\n\ntheorem drop_succ (n : nat) (s : stream α) : drop (succ n) s = drop n (tail s) := rfl\n\n@[simp] lemma head_drop {α} (a : stream α) (n : ℕ) : (a.drop n).head = a.nth n :=\nby simp only [drop, head, nat.zero_add, stream.nth]\n\n@[ext] protected theorem ext {s₁ s₂ : stream α} : (∀ n, nth s₁ n = nth s₂ n) → s₁ = s₂ :=\nassume h, funext h\n\nlemma cons_injective2 : function.injective2 (cons : α → stream α → stream α) :=\nλ x y s t h, ⟨by rw [←nth_zero_cons x s, h, nth_zero_cons],\n  stream.ext (λ n, by rw [←nth_succ_cons n _ x, h, nth_succ_cons])⟩\n\nlemma cons_injective_left (s : stream α) : function.injective (λ x, cons x s) :=\ncons_injective2.left _\n\nlemma cons_injective_right (x : α) : function.injective (cons x) :=\ncons_injective2.right _\n\ntheorem all_def (p : α → Prop) (s : stream α) : all p s = ∀ n, p (nth s n) := rfl\n\ntheorem any_def (p : α → Prop) (s : stream α) : any p s = ∃ n, p (nth s n) := rfl\n\ntheorem mem_cons (a : α) (s : stream α) : a ∈ (a::s) :=\nexists.intro 0 rfl\n\ntheorem mem_cons_of_mem {a : α} {s : stream α} (b : α) : a ∈ s → a ∈ b :: s :=\nassume ⟨n, h⟩,\nexists.intro (succ n) (by rw [nth_succ, tail_cons, h])\n\ntheorem eq_or_mem_of_mem_cons {a b : α} {s : stream α} : a ∈ b::s → a = b ∨ a ∈ s :=\nassume ⟨n, h⟩,\nbegin\n  cases n with n',\n  { left, exact h },\n  { right, rw [nth_succ, tail_cons] at h, exact ⟨n', h⟩ }\nend\n\ntheorem mem_of_nth_eq {n : nat} {s : stream α} {a : α} : a = nth s n → a ∈ s :=\nassume h, exists.intro n h\n\nsection map\nvariable (f : α → β)\n\ntheorem drop_map (n : nat) (s : stream α) : drop n (map f s) = map f (drop n s) :=\nstream.ext (λ i, rfl)\n\ntheorem nth_map (n : nat) (s : stream α) : nth (map f s) n = f (nth s n) := rfl\n\ntheorem tail_map (s : stream α) : tail (map f s) = map f (tail s) :=\nbegin rw tail_eq_drop, refl end\n\ntheorem head_map (s : stream α) : head (map f s) = f (head s) := rfl\n\ntheorem map_eq (s : stream α) : map f s = f (head s) :: map f (tail s) :=\nby rw [← stream.eta (map f s), tail_map, head_map]\n\ntheorem map_cons (a : α) (s : stream α) : map f (a :: s) = f a :: map f s :=\nbegin rw [← stream.eta (map f (a :: s)), map_eq], refl end\n\ntheorem map_id (s : stream α) : map id s = s := rfl\n\ntheorem map_map (g : β → δ) (f : α → β) (s : stream α) : map g (map f s) = map (g ∘ f) s := rfl\n\ntheorem map_tail (s : stream α) : map f (tail s) = tail (map f s) := rfl\n\ntheorem mem_map {a : α} {s : stream α} : a ∈ s → f a ∈ map f s :=\nassume ⟨n, h⟩,\nexists.intro n (by rw [nth_map, h])\n\ntheorem exists_of_mem_map {f} {b : β} {s : stream α} : b ∈ map f s → ∃ a, a ∈ s ∧ f a = b :=\nassume ⟨n, h⟩, ⟨nth s n, ⟨n, rfl⟩, h.symm⟩\nend map\n\nsection zip\nvariable (f : α → β → δ)\n\ntheorem drop_zip (n : nat) (s₁ : stream α) (s₂ : stream β) :\n  drop n (zip f s₁ s₂) = zip f (drop n s₁) (drop n s₂) :=\nstream.ext (λ i, rfl)\n\ntheorem nth_zip (n : nat) (s₁ : stream α) (s₂ : stream β) :\n  nth (zip f s₁ s₂) n = f (nth s₁ n) (nth s₂ n) := rfl\n\ntheorem head_zip (s₁ : stream α) (s₂ : stream β) : head (zip f s₁ s₂) = f (head s₁) (head s₂) := rfl\n\ntheorem tail_zip (s₁ : stream α) (s₂ : stream β) :\n  tail (zip f s₁ s₂) = zip f (tail s₁) (tail s₂) := rfl\n\ntheorem zip_eq (s₁ : stream α) (s₂ : stream β) :\n  zip f s₁ s₂ = f (head s₁) (head s₂) :: zip f (tail s₁) (tail s₂) :=\nbegin rw [← stream.eta (zip f s₁ s₂)], refl end\n\n@[simp] lemma nth_enum (s : stream α) (n : ℕ) : nth (enum s) n = (n, s.nth n) := rfl\n\nlemma enum_eq_zip (s : stream α) : enum s = zip prod.mk nats s := rfl\n\nend zip\n\ntheorem mem_const (a : α) : a ∈ const a :=\nexists.intro 0 rfl\n\ntheorem const_eq (a : α) : const a = a :: const a :=\nbegin\n  apply stream.ext, intro n,\n  cases n; refl\nend\n\ntheorem tail_const (a : α) : tail (const a) = const a :=\nsuffices tail (a :: const a) = const a, by rwa [← const_eq] at this, rfl\n\ntheorem map_const (f : α → β) (a : α) : map f (const a) = const (f a) := rfl\n\ntheorem nth_const (n : nat) (a : α) : nth (const a) n = a := rfl\n\ntheorem drop_const (n : nat) (a : α) : drop n (const a) = const a :=\nstream.ext (λ i, rfl)\n\ntheorem head_iterate (f : α → α) (a : α) : head (iterate f a) = a := rfl\n\ntheorem tail_iterate (f : α → α) (a : α) : tail (iterate f a) = iterate f (f a) :=\nbegin\n  funext n,\n  induction n with n' ih,\n  { refl },\n  { unfold tail iterate,\n    unfold tail iterate at ih,\n    rw add_one at ih, dsimp at ih,\n    rw add_one, dsimp, rw ih }\nend\n\ntheorem iterate_eq (f : α → α) (a : α) : iterate f a = a :: iterate f (f a) :=\nbegin\n  rw [← stream.eta (iterate f a)],\n  rw tail_iterate, refl\nend\n\ntheorem nth_zero_iterate (f : α → α) (a : α) : nth (iterate f a) 0 = a := rfl\n\ntheorem nth_succ_iterate (n : nat) (f : α → α) (a : α) :\n  nth (iterate f a) (succ n) = nth (iterate f (f a)) n :=\nby rw [nth_succ, tail_iterate]\n\nsection bisim\n  variable (R : stream α → stream α → Prop)\n  local infix ` ~ `:50 := R\n\n  def is_bisimulation := ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → head s₁ = head s₂ ∧ tail s₁ ~ tail s₂\n\n  theorem nth_of_bisim (bisim : is_bisimulation R) :\n    ∀ {s₁ s₂} n, s₁ ~ s₂ → nth s₁ n = nth s₂ n ∧ drop (n+1) s₁ ~ drop (n+1) s₂\n  | s₁ s₂ 0     h := bisim h\n  | s₁ s₂ (n+1) h :=\n    match bisim h with\n    | ⟨h₁, trel⟩ := nth_of_bisim n trel\n    end\n\n  -- If two streams are bisimilar, then they are equal\n  theorem eq_of_bisim (bisim : is_bisimulation R) : ∀ {s₁ s₂}, s₁ ~ s₂ → s₁ = s₂ :=\n  λ s₁ s₂ r, stream.ext (λ n, and.elim_left (nth_of_bisim R bisim n r))\nend bisim\n\ntheorem bisim_simple (s₁ s₂ : stream α) :\n  head s₁ = head s₂ → s₁ = tail s₁ → s₂ = tail s₂ → s₁ = s₂ :=\nassume hh ht₁ ht₂, eq_of_bisim\n  (λ s₁ s₂, head s₁ = head s₂ ∧ s₁ = tail s₁ ∧ s₂ = tail s₂)\n  (λ s₁ s₂ ⟨h₁, h₂, h₃⟩,\n    begin\n      constructor, exact h₁, rw [← h₂, ← h₃], repeat { constructor }; assumption\n    end)\n  (and.intro hh (and.intro ht₁ ht₂))\n\ntheorem coinduction {s₁ s₂ : stream α} :\n  head s₁ = head s₂ → (∀ (β : Type u) (fr : stream α → β), fr s₁ = fr s₂ →\n    fr (tail s₁) = fr (tail s₂)) → s₁ = s₂ :=\nassume hh ht,\n  eq_of_bisim\n    (λ s₁ s₂, head s₁ = head s₂ ∧ ∀ (β : Type u) (fr : stream α → β), fr s₁ = fr s₂ →\n      fr (tail s₁) = fr (tail s₂))\n    (λ s₁ s₂ h,\n      have h₁ : head s₁ = head s₂,               from and.elim_left h,\n      have h₂ : head (tail s₁) = head (tail s₂), from and.elim_right h α (@head α) h₁,\n      have h₃ : ∀ (β : Type u) (fr : stream α → β),\n        fr (tail s₁) = fr (tail s₂) → fr (tail (tail s₁)) = fr (tail (tail s₂)),\n      from λ β fr, and.elim_right h β (λ s, fr (tail s)),\n      and.intro h₁ (and.intro h₂ h₃))\n    (and.intro hh ht)\n\ntheorem iterate_id (a : α) : iterate id a = const a :=\ncoinduction\n  rfl\n  (λ β fr ch, begin rw [tail_iterate, tail_const], exact ch end)\n\nlocal attribute [reducible] stream\ntheorem map_iterate (f : α → α) (a : α) : iterate f (f a) = map f (iterate f a) :=\nbegin\n  funext n,\n  induction n with n' ih,\n  { refl },\n  { unfold map iterate nth, dsimp,\n    unfold map iterate nth at ih, dsimp at ih,\n    rw ih }\nend\n\nsection corec\ntheorem corec_def (f : α → β) (g : α → α) (a : α) : corec f g a = map f (iterate g a) := rfl\n\ntheorem corec_eq (f : α → β) (g : α → α) (a : α) : corec f g a = f a :: corec f g (g a) :=\nbegin rw [corec_def, map_eq, head_iterate, tail_iterate], refl end\n\ntheorem corec_id_id_eq_const (a : α) : corec id id a = const a :=\nby rw [corec_def, map_id, iterate_id]\n\ntheorem corec_id_f_eq_iterate (f : α → α) (a : α) : corec id f a = iterate f a := rfl\nend corec\n\nsection corec'\n\ntheorem corec'_eq (f : α → β × α) (a : α) : corec' f a = (f a).1 :: corec' f (f a).2 :=\ncorec_eq _ _ _\n\nend corec'\n\ntheorem unfolds_eq (g : α → β) (f : α → α) (a : α) : unfolds g f a = g a :: unfolds g f (f a) :=\nbegin unfold unfolds, rw [corec_eq] end\n\ntheorem nth_unfolds_head_tail : ∀ (n : nat) (s : stream α), nth (unfolds head tail s) n = nth s n :=\nbegin\n  intro n, induction n with n' ih,\n  { intro s, refl },\n  { intro s, rw [nth_succ, nth_succ, unfolds_eq, tail_cons, ih] }\nend\n\ntheorem unfolds_head_eq : ∀ (s : stream α), unfolds head tail s = s :=\nλ s, stream.ext (λ n, nth_unfolds_head_tail n s)\n\ntheorem interleave_eq (s₁ s₂ : stream α) : s₁ ⋈ s₂ = head s₁ :: head s₂ :: (tail s₁ ⋈ tail s₂) :=\nbegin\n  unfold interleave corec_on, rw corec_eq, dsimp, rw corec_eq, refl\nend\n\ntheorem tail_interleave (s₁ s₂ : stream α) : tail (s₁ ⋈ s₂) = s₂ ⋈ (tail s₁) :=\nbegin unfold interleave corec_on, rw corec_eq, refl end\n\ntheorem interleave_tail_tail (s₁ s₂ : stream α) : tail s₁ ⋈ tail s₂ = tail (tail (s₁ ⋈ s₂)) :=\nbegin rw [interleave_eq s₁ s₂], refl end\n\ntheorem nth_interleave_left : ∀ (n : nat) (s₁ s₂ : stream α), nth (s₁ ⋈ s₂) (2 * n) = nth s₁ n\n| 0        s₁ s₂ := rfl\n| (succ n) s₁ s₂ :=\n  begin\n    change nth (s₁ ⋈ s₂) (succ (succ (2*n))) = nth s₁ (succ n),\n    rw [nth_succ, nth_succ, interleave_eq, tail_cons, tail_cons, nth_interleave_left],\n    refl\n  end\n\ntheorem nth_interleave_right : ∀ (n : nat) (s₁ s₂ : stream α), nth (s₁ ⋈ s₂) (2*n+1) = nth s₂ n\n| 0        s₁ s₂ := rfl\n| (succ n) s₁ s₂ :=\n  begin\n    change nth (s₁ ⋈ s₂) (succ (succ (2*n+1))) = nth s₂ (succ n),\n    rw [nth_succ, nth_succ, interleave_eq, tail_cons, tail_cons, nth_interleave_right],\n    refl\n  end\n\ntheorem mem_interleave_left {a : α} {s₁ : stream α} (s₂ : stream α) : a ∈ s₁ → a ∈ s₁ ⋈ s₂ :=\nassume ⟨n, h⟩,\nexists.intro (2*n) (by rw [h, nth_interleave_left])\n\ntheorem mem_interleave_right {a : α} {s₁ : stream α} (s₂ : stream α) : a ∈ s₂ → a ∈ s₁ ⋈ s₂ :=\nassume ⟨n, h⟩,\nexists.intro (2*n+1) (by rw [h, nth_interleave_right])\n\ntheorem odd_eq (s : stream α) : odd s = even (tail s) := rfl\n\ntheorem head_even (s : stream α) : head (even s) = head s := rfl\n\ntheorem tail_even (s : stream α) : tail (even s) = even (tail (tail s)) :=\nbegin unfold even, rw corec_eq, refl end\n\ntheorem even_cons_cons (a₁ a₂ : α) (s : stream α) : even (a₁ :: a₂ :: s) = a₁ :: even s :=\nbegin unfold even, rw corec_eq, refl end\n\ntheorem even_tail (s : stream α) : even (tail s) = odd s := rfl\n\ntheorem even_interleave (s₁ s₂ : stream α) : even (s₁ ⋈ s₂) = s₁ :=\neq_of_bisim\n  (λ s₁' s₁, ∃ s₂, s₁' = even (s₁ ⋈ s₂))\n  (λ s₁' s₁ ⟨s₂, h₁⟩,\n    begin\n      rw h₁,\n      constructor,\n       {refl},\n       {exact ⟨tail s₂, by rw [interleave_eq, even_cons_cons, tail_cons]⟩}\n    end)\n  (exists.intro s₂ rfl)\n\ntheorem interleave_even_odd (s₁ : stream α) : even s₁ ⋈ odd s₁ = s₁ :=\neq_of_bisim\n  (λ s' s, s' = even s ⋈ odd s)\n  (λ s' s (h : s' = even s ⋈ odd s),\n    begin\n      rw h, constructor,\n       {refl},\n       {simp [odd_eq, odd_eq, tail_interleave, tail_even]}\n    end)\n  rfl\n\ntheorem nth_even : ∀ (n : nat) (s : stream α), nth (even s) n = nth s (2*n)\n| 0        s := rfl\n| (succ n) s :=\n  begin\n    change nth (even s) (succ n) = nth s (succ (succ (2 * n))),\n    rw [nth_succ, nth_succ, tail_even, nth_even], refl\n  end\n\ntheorem nth_odd : ∀ (n : nat) (s : stream α), nth (odd s) n = nth s (2 * n + 1) :=\nλ n s, begin rw [odd_eq, nth_even], refl end\n\ntheorem mem_of_mem_even (a : α) (s : stream α) : a ∈ even s → a ∈ s :=\nassume ⟨n, h⟩,\nexists.intro (2*n) (by rw [h, nth_even])\n\ntheorem mem_of_mem_odd (a : α) (s : stream α) : a ∈ odd s → a ∈ s :=\nassume ⟨n, h⟩,\nexists.intro (2*n+1) (by rw [h, nth_odd])\n\ntheorem nil_append_stream (s : stream α) : append_stream [] s = s := rfl\n\ntheorem cons_append_stream (a : α) (l : list α) (s : stream α) :\n  append_stream (a::l) s = a :: append_stream l s := rfl\n\ntheorem append_append_stream :\n  ∀ (l₁ l₂ : list α) (s : stream α), (l₁ ++ l₂) ++ₛ s = l₁ ++ₛ (l₂ ++ₛ s)\n| []               l₂ s := rfl\n| (list.cons a l₁) l₂ s := by rw [list.cons_append, cons_append_stream, cons_append_stream,\n                                  append_append_stream]\n\ntheorem map_append_stream (f : α → β) :\n  ∀ (l : list α) (s : stream α), map f (l ++ₛ s) = list.map f l ++ₛ map f s\n| []              s := rfl\n| (list.cons a l) s := by rw [cons_append_stream, list.map_cons, map_cons, cons_append_stream,\n                              map_append_stream]\n\ntheorem drop_append_stream : ∀ (l : list α) (s : stream α), drop l.length (l ++ₛ s) = s\n| []              s := by refl\n| (list.cons a l) s := by rw [list.length_cons, add_one, drop_succ, cons_append_stream, tail_cons,\n                              drop_append_stream]\n\ntheorem append_stream_head_tail (s : stream α) : [head s] ++ₛ tail s = s :=\nby rw [cons_append_stream, nil_append_stream, stream.eta]\n\ntheorem mem_append_stream_right : ∀ {a : α} (l : list α) {s : stream α}, a ∈ s → a ∈ l ++ₛ s\n| a []              s h := h\n| a (list.cons b l) s h :=\n  have ih : a ∈ l ++ₛ s, from mem_append_stream_right l h,\n  mem_cons_of_mem _ ih\n\ntheorem mem_append_stream_left : ∀ {a : α} {l : list α} (s : stream α), a ∈ l → a ∈ l ++ₛ s\n| a []     s h := absurd h (list.not_mem_nil _)\n| a (list.cons b l) s h :=\n  or.elim (list.eq_or_mem_of_mem_cons h)\n    (λ (aeqb : a = b), exists.intro 0 aeqb)\n    (λ (ainl : a ∈ l), mem_cons_of_mem b (mem_append_stream_left s ainl))\n\n@[simp] theorem take_zero (s : stream α) : take 0 s = [] := rfl\n\n@[simp] theorem take_succ (n : nat) (s : stream α) :\n  take (succ n) s = head s :: take n (tail s) := rfl\n\n@[simp] theorem length_take (n : ℕ) (s : stream α) : (take n s).length = n :=\nby induction n generalizing s; simp *\n\ntheorem nth_take_succ : ∀ (n : nat) (s : stream α), list.nth (take (succ n) s) n = some (nth s n)\n| 0     s := rfl\n| (n+1) s := begin rw [take_succ, add_one, list.nth, nth_take_succ], refl end\n\ntheorem append_take_drop :\n  ∀ (n : nat) (s : stream α), append_stream (take n s) (drop n s) = s :=\nbegin\n  intro n,\n  induction n with n' ih,\n  { intro s, refl },\n  { intro s, rw [take_succ, drop_succ, cons_append_stream, ih (tail s), stream.eta] }\nend\n\n-- Take theorem reduces a proof of equality of infinite streams to an\n-- induction over all their finite approximations.\ntheorem take_theorem (s₁ s₂ : stream α) : (∀ (n : nat), take n s₁ = take n s₂) → s₁ = s₂ :=\nbegin\n  intro h, apply stream.ext, intro n,\n  induction n with n ih,\n  { have aux := h 1, simp [take] at aux, exact aux },\n  { have h₁ : some (nth s₁ (succ n)) = some (nth s₂ (succ n)),\n    { rw [← nth_take_succ, ← nth_take_succ, h (succ (succ n))] },\n    injection h₁ }\nend\n\nprotected lemma cycle_g_cons (a : α) (a₁ : α) (l₁ : list α) (a₀ : α) (l₀ : list α) :\n              stream.cycle_g (a, a₁::l₁, a₀, l₀) = (a₁, l₁, a₀, l₀) := rfl\n\ntheorem cycle_eq : ∀ (l : list α) (h : l ≠ []), cycle l h = l ++ₛ cycle l h\n| []              h := absurd rfl h\n| (list.cons a l) h :=\n  have gen : ∀ l' a', corec stream.cycle_f stream.cycle_g (a', l', a, l) =\n    (a' :: l') ++ₛ corec stream.cycle_f stream.cycle_g (a, l, a, l),\n    begin\n      intro l',\n      induction l' with a₁ l₁ ih,\n        {intros, rw [corec_eq], refl},\n        {intros, rw [corec_eq, stream.cycle_g_cons, ih a₁], refl}\n    end,\n  gen l a\n\ntheorem mem_cycle {a : α} {l : list α} : ∀ (h : l ≠ []), a ∈ l → a ∈ cycle l h :=\nassume h ainl, begin rw [cycle_eq], exact mem_append_stream_left _ ainl end\n\ntheorem cycle_singleton (a : α) (h : [a] ≠ []) : cycle [a] h = const a :=\ncoinduction\n  rfl\n  (λ β fr ch, by rwa [cycle_eq, const_eq])\n\ntheorem tails_eq (s : stream α) : tails s = tail s :: tails (tail s) :=\nby unfold tails; rw [corec_eq]; refl\n\ntheorem nth_tails : ∀ (n : nat) (s : stream α), nth (tails s) n = drop n (tail s) :=\nbegin\n  intro n, induction n with n' ih,\n  { intros, refl },\n  { intro s, rw [nth_succ, drop_succ, tails_eq, tail_cons, ih] }\nend\n\ntheorem tails_eq_iterate (s : stream α) : tails s = iterate tail (tail s) := rfl\n\ntheorem inits_core_eq (l : list α) (s : stream α) :\n  inits_core l s = l :: inits_core (l ++ [head s]) (tail s) :=\nbegin unfold inits_core corec_on, rw [corec_eq], refl end\n\ntheorem tail_inits (s : stream α) :\n  tail (inits s) = inits_core [head s, head (tail s)] (tail (tail s)) :=\nbegin unfold inits, rw inits_core_eq, refl end\n\ntheorem inits_tail (s : stream α) :\n  inits (tail s) = inits_core [head (tail s)] (tail (tail s)) := rfl\n\n\n\ntheorem nth_inits : ∀ (n : nat) (s : stream α), nth (inits s) n = take (succ n) s  :=\nbegin\n  intro n, induction n with n' ih,\n  { intros, refl },\n  { intros, rw [nth_succ, take_succ, ← ih, tail_inits, inits_tail, cons_nth_inits_core] }\nend\n\ntheorem inits_eq (s : stream α) : inits s = [head s] :: map (list.cons (head s)) (inits (tail s)) :=\nbegin\n  apply stream.ext, intro n,\n  cases n,\n  { refl },\n  { rw [nth_inits, nth_succ, tail_cons, nth_map, nth_inits], refl }\nend\n\ntheorem zip_inits_tails (s : stream α) : zip append_stream (inits s) (tails s) = const s :=\nbegin\n  apply stream.ext, intro n,\n  rw [nth_zip, nth_inits, nth_tails, nth_const, take_succ,\n      cons_append_stream, append_take_drop, stream.eta]\nend\n\ntheorem identity (s : stream α) : pure id ⊛ s = s := rfl\ntheorem composition (g : stream (β → δ)) (f : stream (α → β)) (s : stream α) :\n  pure comp ⊛ g ⊛ f ⊛ s = g ⊛ (f ⊛ s) := rfl\ntheorem homomorphism (f : α → β) (a : α) : pure f ⊛ pure a = pure (f a) := rfl\ntheorem interchange (fs : stream (α → β)) (a : α) :\n  fs ⊛ pure a = pure (λ f : α → β, f a) ⊛ fs := rfl\ntheorem map_eq_apply (f : α → β) (s : stream α) : map f s = pure f ⊛ s := rfl\n\ntheorem nth_nats (n : nat) : nth nats n = n := rfl\n\ntheorem nats_eq : nats = 0 :: map succ nats :=\nbegin\n  apply stream.ext, intro n,\n  cases n, refl, rw [nth_succ], refl\nend\n\nend stream\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/stream/init.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945416, "lm_q2_score": 0.76908023177796, "lm_q1q2_score": 0.4787211559403288}}
{"text": "-- $ cd divseq2\n-- $ code .\n\nimport «Divseq2»\n\nopen Nat\n\nnamespace divseq2\n  theorem h₀₃ (m : Nat) : 18 * (2 * m) + 13 = succ (succ (succ (succ ((succ ((succ (m * 3 * 2)) * 2)) * 3)))) := by linarith\n  theorem h₀₄ (m : Nat) : 9 * (4 * m + 1) + 16 = succ (succ (succ (succ ((succ ((succ ((succ (m * 3)) * 2)) * 2)) * 3)))) := by linarith\n  --theorem h₀₅1 (m : Nat) : 36 * m + 37 = succ (succ (succ (succ ((succ ((succ ((succ (succ (m * 3))) * 2)) * 2)) * 3)))) := by linarith\n  axiom   h₀₅ (m : Nat) : (9 * (8 * m + 7) + 11) / 2 = succ (succ (succ (succ ((succ ((succ ((succ (succ (m * 3))) * 2)) * 2)) * 3))))\n  axiom   h₀₆ (l : Nat) : (16 * l + 3) + (16 * l + 3 - 3) / 8 + 1 = succ (succ (succ (succ (l * 3 * 2 * 3))))\n  axiom   h₀₇ (l : Nat) : 8 * l + 4 + (8 * l + 4 - 4) / 4 * 5 + 6 = succ (succ (succ (succ (((succ (l * 3)) * 2) * 3))))\n  axiom   h₀₈ (l : Nat) : 4 * (4 * l + 3) + (4 * l + 3 - 3) / 2 + 4 = succ (succ (succ (succ (((succ (succ (l * 3))) * 2) * 3))))\n  theorem h₁₂ (l : Nat) : 9 * (2 * l) + 6 = succ (succ (succ ((succ (l * 3 * 2)) * 3))) := by linarith\n  axiom   h₁₃ (l : Nat) : (9 * (4 * l + 1) + 15) / 2 = succ (succ (succ ((succ ((succ (l * 3)) * 2)) * 3)))\n  axiom   h₁₄ (l : Nat) : (9 * (8 * l + 7) + 9) / 4 = succ (succ (succ ((succ ((succ (succ (l * 3))) * 2)) * 3)))\n  -- 十分条件\n  theorem singleToExts (n : Nat) (p : SingleLimited n) : ExtsLimited n := match p with\n    | SingleLimited.is02 _ p2 => match p2 with\n      | ExtsLimited.is _ _ p3 _ _ _ _ _ _ _ _ _ _ _ => p3\n    | SingleLimited.is03 m p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ p3 _ _ _ _ _ _ _ _ => have p4 := Eq.subst (h₀₃ m) p3; p4\n    | SingleLimited.is04 m p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ p3 _ _ _ => have p4 := Eq.subst (h₀₄ m) p3; p4\n    | SingleLimited.is05 m p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ _ p3 _ _ => have p4 := Eq.subst (h₀₅ m) p3; p4\n    | SingleLimited.is06 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ p3 _ _ _ _ _ _ => have p4 := Eq.subst (h₀₆ l) p3; p4\n    | SingleLimited.is07 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ p3 _ _ _ _ _ => have p4 := Eq.subst (h₀₇ l) p3; p4\n    | SingleLimited.is08 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ p3 _ _ _ _ => have p4 := Eq.subst (h₀₈ l) p3; p4\n    | SingleLimited.is09 _ p2 => match p2 with\n      | ExtsLimited.is _ _ _ p3 _ _ _ _ _ _ _ _ _ _ => p3\n    | SingleLimited.is11 _ p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ p3 _ _ _ _ _ _ _ _ _ => p3\n    | SingleLimited.is12 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ p3 _ _ _ _ _ _ _ => have p4 := Eq.subst (h₁₂ l) p3; p4\n    | SingleLimited.is13 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ _ _ p3 _ => have p4 := Eq.subst (h₁₃ l) p3; p4\n    | SingleLimited.is14 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ _ _ _ p3 => have p4 := Eq.subst (h₁₄ l) p3; p4\n\n  theorem m₀₂₁ (l : Nat) : l < succ (succ (succ (succ (succ (l * 2 * 2) * 3)))) := by linarith\n  theorem m₀₃₁ (m : Nat) : 2 * m < succ (succ (succ (succ (succ (succ (m * 3 * 2) * 2) * 3)))) := by linarith\n  theorem m₀₄₁ (m : Nat) : 4 * m + 1 < succ (succ (succ (succ (succ (succ (succ (m * 3) * 2) * 2) * 3)))) := by linarith\n  theorem m₀₅₁ (m : Nat) : 8 * m + 7 < succ (succ (succ (succ (succ (succ (succ (succ (m * 3)) * 2) * 2) * 3)))) := by linarith\n  theorem m₀₆₁ (l : Nat) : 16 * l + 3 < succ (succ (succ (succ (l * 3 * 2 * 3)))) := by linarith\n  theorem m₀₇₁ (l : Nat) : 8 * l + 4 < succ (succ (succ (succ (succ (l * 3) * 2 * 3)))) := by linarith\n  theorem m₀₈₁ (l : Nat) : 4 * l + 3 < succ (succ (succ (succ (succ (succ (l * 3)) * 2 * 3)))) := by linarith\n  theorem m₀₉₁ (j : Nat) : j < succ (succ (j * 3)) := by linarith\n  theorem m₁₁₁ (k : Nat) : k < succ (succ (succ (k * 2 * 3))) := by linarith\n  theorem m₁₂₁ (l : Nat) : 2 * l < succ (succ (succ (succ (l * 3 * 2) * 3))) := by linarith\n  theorem m₁₃₁ (l : Nat) : 4 * l + 1 < succ (succ (succ (succ (succ (l * 3) * 2) * 3))) := by linarith\n  theorem m₁₄₁ (l : Nat) : 8 * l + 7 < succ (succ (succ (succ (succ (succ (l * 3)) * 2) * 3))) := by linarith\n  def makeLimitedDivSeq (x : Nat) (rs : ∀ x₁, x₁ < x → SingleLimited x₁) : SingleLimited x := match x with\n    | 0             => is10 -- 6*<0>+3 = 3\n    | 1             => is01 -- 6*<1>+3 = 9\n    | succ (succ x) => by have rs := rs; cases (mod3 x) with\n      -- 6 mod 9\n      | threeZero j =>\n          have sin := rs j (m₀₉₁ j); have ext := singleToExts j sin;\n          exact SingleLimited.is09 j ext;\n      -- 3 mod 9\n      | threeOne j  => cases (parity j) with\n        | even k =>\n            have sin := rs k (m₁₁₁ k); have ext := singleToExts k sin;\n            exact SingleLimited.is11 k ext;\n        | odd k  => cases (mod3 k) with\n          | threeZero l =>\n              have sin := rs (2 * l) (m₁₂₁ l); have ext := singleToExts (2 * l) sin;\n              exact SingleLimited.is12 l ext;\n          | threeOne l  =>\n              have sin := rs (4 * l + 1) (m₁₃₁ l); have ext := singleToExts (4 * l + 1) sin;\n              exact SingleLimited.is13 l ext;\n          | threeTwo l  =>\n              have sin := rs (8 * l + 7) (m₁₄₁ l); have ext := singleToExts (8 * l + 7) sin;\n              exact SingleLimited.is14 l ext;\n      -- 0 mod 9\n      | threeTwo j  => cases (parity j) with\n        | even k => cases (mod3 k) with\n          | threeZero l =>\n              have sin := rs (16 * l + 3) (m₀₆₁ l); have ext := singleToExts (16 * l + 3) sin;\n              exact SingleLimited.is06 l ext;\n          | threeOne l  =>\n              have sin := rs (8 * l + 4) (m₀₇₁ l); have ext := singleToExts (8 * l + 4) sin;\n              exact SingleLimited.is07 l ext;\n          | threeTwo l  =>\n              have sin := rs (4 * l + 3) (m₀₈₁ l); have ext := singleToExts (4 * l + 3) sin;\n              exact SingleLimited.is08 l ext;\n        | odd k  => cases (parity k) with\n          | even l =>\n              have sin := rs l (m₀₂₁ l); have ext := singleToExts l sin;\n              exact SingleLimited.is02 l ext;\n          | odd l  => cases (mod3 l) with\n            | threeZero m =>\n                have sin := rs (2 * m) (m₀₃₁ m); have ext := singleToExts (2 * m) sin;\n                exact SingleLimited.is03 m ext;\n            | threeOne m  =>\n                have sin := rs (4 * m + 1) (m₀₄₁ m); have ext := singleToExts (4 * m + 1) sin;\n                exact SingleLimited.is04 m ext;\n            | threeTwo m  =>\n                have sin := rs (8 * m + 7) (m₀₅₁ m); have ext := singleToExts (8 * m + 7) sin;\n                exact SingleLimited.is05 m ext;\n  -- 最終的な定理\n  def LimitedDivSeq (n : Nat) : SingleLimited n := WellFounded.fix' (measure id).wf makeLimitedDivSeq n\nend divseq2\n\n\n\ndef main : IO Unit :=\n  IO.println s!\"Hello,\"\n\n\n\n", "meta": {"author": "righ1113", "repo": "divseq2", "sha": "76223bb7edc52d94caee9f628e4c817365f30cc0", "save_path": "github-repos/lean/righ1113-divseq2", "path": "github-repos/lean/righ1113-divseq2/divseq2-76223bb7edc52d94caee9f628e4c817365f30cc0/Main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673223709251, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.47868873090058917}}
{"text": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Chris Hughes\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.zsqrtd.basic\nimport Mathlib.data.complex.basic\nimport Mathlib.ring_theory.principal_ideal_domain\nimport Mathlib.number_theory.quadratic_reciprocity\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n# Gaussian integers\n\nThe Gaussian integers are complex integer, complex numbers whose real and imaginary parts are both\nintegers.\n\n## Main definitions\n\nThe Euclidean domain structure on `ℤ[i]` is defined in this file.\n\nThe homomorphism `to_complex` into the complex numbers is also defined in this file.\n\n## Main statements\n\n`prime_iff_mod_four_eq_three_of_nat_prime`\nA prime natural number is prime in `ℤ[i]` if and only if it is `3` mod `4`\n\n## Notations\n\nThis file uses the local notation `ℤ[i]` for `gaussian_int`\n\n## Implementation notes\n\nGaussian integers are implemented using the more general definition `zsqrtd`, the type of integers\nadjoined a square root of `d`, in this case `-1`. The definition is reducible, so that properties\nand definitions about `zsqrtd` can easily be used.\n-/\n\ndef gaussian_int := ℤ√(-1)\n\nnamespace gaussian_int\n\n\nprotected instance has_repr : has_repr gaussian_int :=\n  has_repr.mk\n    fun (x : gaussian_int) =>\n      string.str string.empty\n                (char.of_nat\n                  (bit0\n                    (bit0\n                      (bit0\n                        (bit1\n                          (bit0 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit0 (bit0 1)))))))))))))) ++\n              repr (zsqrtd.re x) ++\n            string.str (string.str string.empty (char.of_nat (bit0 (bit0 (bit1 (bit1 (bit0 1)))))))\n              (char.of_nat (bit0 (bit0 (bit0 (bit0 (bit0 1)))))) ++\n          repr (zsqrtd.im x) ++\n        string.str string.empty\n          (char.of_nat\n            (bit1\n              (bit0\n                (bit0 (bit1 (bit0 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit0 (bit0 1))))))))))))))\n\nprotected instance comm_ring : comm_ring gaussian_int := zsqrtd.comm_ring\n\n/-- The embedding of the Gaussian integers into the complex numbers, as a ring homomorphism. -/\ndef to_complex : gaussian_int →+* ℂ := coe_fn zsqrtd.lift { val := complex.I, property := sorry }\n\nprotected instance complex.has_coe : has_coe gaussian_int ℂ := has_coe.mk ⇑to_complex\n\ntheorem to_complex_def (x : gaussian_int) : ↑x = ↑(zsqrtd.re x) + ↑(zsqrtd.im x) * complex.I := rfl\n\ntheorem to_complex_def' (x : ℤ) (y : ℤ) : ↑(zsqrtd.mk x y) = ↑x + ↑y * complex.I := sorry\n\ntheorem to_complex_def₂ (x : gaussian_int) : ↑x = complex.mk ↑(zsqrtd.re x) ↑(zsqrtd.im x) := sorry\n\n@[simp] theorem to_real_re (x : gaussian_int) : ↑(zsqrtd.re x) = complex.re ↑x := sorry\n\n@[simp] theorem to_real_im (x : gaussian_int) : ↑(zsqrtd.im x) = complex.im ↑x := sorry\n\n@[simp] theorem to_complex_re (x : ℤ) (y : ℤ) : complex.re ↑(zsqrtd.mk x y) = ↑x := sorry\n\n@[simp] theorem to_complex_im (x : ℤ) (y : ℤ) : complex.im ↑(zsqrtd.mk x y) = ↑y := sorry\n\n@[simp] theorem to_complex_add (x : gaussian_int) (y : gaussian_int) : ↑(x + y) = ↑x + ↑y :=\n  ring_hom.map_add to_complex x y\n\n@[simp] theorem to_complex_mul (x : gaussian_int) (y : gaussian_int) : ↑(x * y) = ↑x * ↑y :=\n  ring_hom.map_mul to_complex x y\n\n@[simp] theorem to_complex_one : ↑1 = 1 := ring_hom.map_one to_complex\n\n@[simp] theorem to_complex_zero : ↑0 = 0 := ring_hom.map_zero to_complex\n\n@[simp] theorem to_complex_neg (x : gaussian_int) : ↑(-x) = -↑x := ring_hom.map_neg to_complex x\n\n@[simp] theorem to_complex_sub (x : gaussian_int) (y : gaussian_int) : ↑(x - y) = ↑x - ↑y :=\n  ring_hom.map_sub to_complex x y\n\n@[simp] theorem to_complex_inj {x : gaussian_int} {y : gaussian_int} : ↑x = ↑y ↔ x = y := sorry\n\n@[simp] theorem to_complex_eq_zero {x : gaussian_int} : ↑x = 0 ↔ x = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (↑x = 0 ↔ x = 0)) (Eq.symm to_complex_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑x = ↑0 ↔ x = 0)) (propext to_complex_inj)))\n      (iff.refl (x = 0)))\n\n@[simp] theorem nat_cast_real_norm (x : gaussian_int) :\n    ↑(zsqrtd.norm x) = coe_fn complex.norm_sq ↑x :=\n  sorry\n\n@[simp] theorem nat_cast_complex_norm (x : gaussian_int) :\n    ↑(zsqrtd.norm x) = ↑(coe_fn complex.norm_sq ↑x) :=\n  sorry\n\ntheorem norm_nonneg (x : gaussian_int) : 0 ≤ zsqrtd.norm x :=\n  zsqrtd.norm_nonneg\n    (eq.mpr (id (eq_true_intro (neg_nonpos_of_nonneg (norm_num.nonneg_pos 1 zero_lt_one'))))\n      trivial)\n    x\n\n@[simp] theorem norm_eq_zero {x : gaussian_int} : zsqrtd.norm x = 0 ↔ x = 0 := sorry\n\ntheorem norm_pos {x : gaussian_int} : 0 < zsqrtd.norm x ↔ x ≠ 0 := sorry\n\n@[simp] theorem coe_nat_abs_norm (x : gaussian_int) :\n    ↑(int.nat_abs (zsqrtd.norm x)) = zsqrtd.norm x :=\n  int.nat_abs_of_nonneg (norm_nonneg x)\n\n@[simp] theorem nat_cast_nat_abs_norm {α : Type u_1} [ring α] (x : gaussian_int) :\n    ↑(int.nat_abs (zsqrtd.norm x)) = ↑(zsqrtd.norm x) :=\n  sorry\n\ntheorem nat_abs_norm_eq (x : gaussian_int) :\n    int.nat_abs (zsqrtd.norm x) =\n        int.nat_abs (zsqrtd.re x) * int.nat_abs (zsqrtd.re x) +\n          int.nat_abs (zsqrtd.im x) * int.nat_abs (zsqrtd.im x) :=\n  sorry\n\nprotected def div (x : gaussian_int) (y : gaussian_int) : gaussian_int :=\n  let n : ℚ := rat.of_int (zsqrtd.norm y)⁻¹;\n  let c : ℤ√(-1) := zsqrtd.conj y;\n  zsqrtd.mk (round (rat.of_int (zsqrtd.re (x * c)) * n))\n    (round (rat.of_int (zsqrtd.im (x * c)) * n))\n\nprotected instance has_div : Div gaussian_int := { div := gaussian_int.div }\n\ntheorem div_def (x : gaussian_int) (y : gaussian_int) :\n    x / y =\n        zsqrtd.mk (round (↑(zsqrtd.re (x * zsqrtd.conj y)) / ↑(zsqrtd.norm y)))\n          (round (↑(zsqrtd.im (x * zsqrtd.conj y)) / ↑(zsqrtd.norm y))) :=\n  sorry\n\ntheorem to_complex_div_re (x : gaussian_int) (y : gaussian_int) :\n    complex.re ↑(x / y) = ↑(round (complex.re (↑x / ↑y))) :=\n  sorry\n\ntheorem to_complex_div_im (x : gaussian_int) (y : gaussian_int) :\n    complex.im ↑(x / y) = ↑(round (complex.im (↑x / ↑y))) :=\n  sorry\n\ntheorem norm_sq_le_norm_sq_of_re_le_of_im_le {x : ℂ} {y : ℂ}\n    (hre : abs (complex.re x) ≤ abs (complex.re y))\n    (him : abs (complex.im x) ≤ abs (complex.im y)) :\n    coe_fn complex.norm_sq x ≤ coe_fn complex.norm_sq y :=\n  sorry\n\ntheorem norm_sq_div_sub_div_lt_one (x : gaussian_int) (y : gaussian_int) :\n    coe_fn complex.norm_sq (↑x / ↑y - ↑(x / y)) < 1 :=\n  sorry\n\nprotected def mod (x : gaussian_int) (y : gaussian_int) : gaussian_int := x - y * (x / y)\n\nprotected instance has_mod : Mod gaussian_int := { mod := gaussian_int.mod }\n\ntheorem mod_def (x : gaussian_int) (y : gaussian_int) : x % y = x - y * (x / y) := rfl\n\ntheorem norm_mod_lt (x : gaussian_int) {y : gaussian_int} (hy : y ≠ 0) :\n    zsqrtd.norm (x % y) < zsqrtd.norm y :=\n  sorry\n\ntheorem nat_abs_norm_mod_lt (x : gaussian_int) {y : gaussian_int} (hy : y ≠ 0) :\n    int.nat_abs (zsqrtd.norm (x % y)) < int.nat_abs (zsqrtd.norm y) :=\n  sorry\n\ntheorem norm_le_norm_mul_left (x : gaussian_int) {y : gaussian_int} (hy : y ≠ 0) :\n    int.nat_abs (zsqrtd.norm x) ≤ int.nat_abs (zsqrtd.norm (x * y)) :=\n  sorry\n\nprotected instance nontrivial : nontrivial gaussian_int :=\n  nontrivial.mk (Exists.intro 0 (Exists.intro 1 (of_as_true trivial)))\n\nprotected instance euclidean_domain : euclidean_domain gaussian_int :=\n  euclidean_domain.mk comm_ring.add comm_ring.add_assoc comm_ring.zero comm_ring.zero_add\n    comm_ring.add_zero comm_ring.neg comm_ring.sub comm_ring.add_left_neg comm_ring.add_comm\n    comm_ring.mul comm_ring.mul_assoc comm_ring.one comm_ring.one_mul comm_ring.mul_one\n    comm_ring.left_distrib comm_ring.right_distrib comm_ring.mul_comm nontrivial.exists_pair_ne\n    Div.div sorry Mod.mod sorry (measure (int.nat_abs ∘ zsqrtd.norm)) sorry nat_abs_norm_mod_lt\n    sorry\n\ntheorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : fact (nat.prime p)] (hpi : prime ↑p) :\n    p % bit0 (bit0 1) = bit1 1 :=\n  sorry\n\ntheorem sum_two_squares_of_nat_prime_of_not_irreducible (p : ℕ) [hp : fact (nat.prime p)]\n    (hpi : ¬irreducible ↑p) : ∃ (a : ℕ), ∃ (b : ℕ), a ^ bit0 1 + b ^ bit0 1 = p :=\n  sorry\n\ntheorem prime_of_nat_prime_of_mod_four_eq_three (p : ℕ) [hp : fact (nat.prime p)]\n    (hp3 : p % bit0 (bit0 1) = bit1 1) : prime ↑p :=\n  sorry\n\n/-- A prime natural number is prime in `ℤ[i]` if and only if it is `3` mod `4` -/\ntheorem prime_iff_mod_four_eq_three_of_nat_prime (p : ℕ) [hp : fact (nat.prime p)] :\n    prime ↑p ↔ p % bit0 (bit0 1) = bit1 1 :=\n  { mp := mod_four_eq_three_of_nat_prime_of_prime p,\n    mpr := prime_of_nat_prime_of_mod_four_eq_three p }\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/zsqrtd/gaussian_int_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4785329919699888}}
{"text": "/- 2018-10-12T21:52:34 Locally nameless formulas, built off Floris' preterms\n---Jesse\n\nI wanted to avoid the headache over shifts (at the cost of needing to define a well-formedness predicate on terms); my implementation of locally nameless formulas is based off Chargueraud's paper (thanks for the pointer Jeremy!).\n\nTODO:\n - finish writing the coercion for variable lists\n - finish writing the substitution functions\n - add a well-formedness predicate\n-/\n\nstructure Language := \n(relations : Π n : nat, Type) (functions : Π  n : nat, Type)\nsection\nparameter L : Language\n\n/- preterm n is a partially applied term. if applied to n terms, it becomes a term -/\ninductive preterm  : ℕ → Type \n| bvar : ℕ → preterm 0\n| fvar : string → preterm 0\n| func : ∀ {n : nat}, L.functions n → preterm n\n| apply : ∀ {n : nat}, preterm (n + 1) → preterm 0 → preterm n\n\nopen preterm\ndef term := preterm 0\n\n-- /- raise_depth_term _ t n m raises variables in t which are at least m by n -/\n-- def raise_depth_term : ∀ {l}, preterm l → ℕ → ℕ → preterm l\n-- | _ (var L k) n m := if m ≤ k then var (k+m) else var k\n-- | _ (func f) n m := func f\n-- | _ (apply t1 t2) n m := apply (raise_depth_term t1 n m) (raise_depth_term t2 n m)\n\n-- /- substitute_term t s n substitutes s for (var n) and reduces the level of all variables above n by 1 -/\n-- def substitute_term : ∀ {l}, preterm l → term → ℕ → preterm l\n-- | _ (var L k) s n := if k < n then var k else if k > n then var (k-1) else s\n-- | _ (func f) s n := func f\n-- | _ (apply t1 t2) s n := apply (substitute_term t1 s n) (substitute_term t2 s n)\n\n/-- Given a preterm, return a list of free variables which occur in it--/\ndef free_vars_preterm : Π n : ℕ, preterm n → list string\n| _ (bvar L k) := []\n| _ (fvar L s) := [s]\n| _ (@func L _ f) := []\n| _ (@apply L n t1 t2) := (free_vars_preterm (n+1) t1 ∪ free_vars_preterm 0 t2)\n\ndef free_vars_term : term → list string := free_vars_preterm 0\n\nlemma free_var_preterm_coercionl (n : ℕ) (t1 : preterm (n+1)) (t2 : term) : {x : string // x ∈ (free_vars_preterm (n+1) t1)} → {x : string // x ∈ (free_vars_preterm n (apply t1 t2))} := sorry\n\ndef substitute_preterm : Π n : ℕ, Π (t : preterm n), term → {x : string // x ∈ (free_vars_preterm n t)} → preterm n\n| _ (bvar L k) t x := (bvar k)\n| _ (fvar L s) t x := sorry\n| _ (@func L _ f) t x := (func f)\n| _ (@apply L n t1 t2) t x := sorry\nend\n\nsection\n\nparameter L : Language\n/- preformula n is a partially applied formula. if applied to n terms, it becomes a formula -/\ninductive preformula : ℕ → Type \n| true : preformula 0\n| false : preformula 0\n| equal : (term L)  → (term L) → preformula 0\n| rel : ∀ {n : nat}, L.relations n → preformula n\n| apprel : ∀ {n : nat}, preformula (n + 1) → (term L) → preformula n\n| imp : preformula 0 → preformula 0 → preformula 0\n| all : preformula 0 → preformula 0\nopen preformula\ndef formula := preformula 0\n\ndef free_vars_preformula : Π n : ℕ, preformula n → list string\n| _ (true L) := []\n| _ (false L) := []\n| _ (equal t1 t2) := free_vars_term L t1 ∪ free_vars_term L t2\n| _ (@rel L n R) := []\n| _ (@apprel L n ψ t) := free_vars_preformula _ ψ ∪ free_vars_term L t\n| _ (imp ϕ ψ) := free_vars_preformula _ ϕ ∪ free_vars_preformula _ ψ\n| _ (all ψ) := free_vars_preformula _ ψ\n\ndef free_vars_formula : formula → list string := free_vars_preformula 0\n\n-- def raise_depth_formula : ∀ {l}, preformula l → ℕ → ℕ → preformula l\n-- | _ (true L) n m := true\n-- | _ (false L) n m := false\n-- | _ (equal t1 t2) n m := equal (raise_depth_term t1 n m) (raise_depth_term t2 n m)\n-- | _ (rel R) n m := rel R\n-- | _ (apprel f t) n m := apprel (raise_depth_formula f n m) (raise_depth_term t n m)\n-- | _ (imp f1 f2) n m := imp (raise_depth_formula f1 n m) (raise_depth_formula f2 n m)\n-- | _ (all f) n m := all (raise_depth_formula f n (m+1))\n\ndef substitute_formula : ∀ {l}, preformula l → (term L) → ℕ → preformula l\n| _ (true L) s n := true\n| _ (false L) s n := false\n| _ (equal t1 t2) s n := equal (substitute_term L t1 s n) (substitute_term L t2 s n)\n| _ (rel R) s n := rel R\n| _ (apprel f t) s n := apprel (substitute_formula f s n) (substitute_term t s n)\n| _ (imp f1 f2) s n := imp (substitute_formula f1 s n) (substitute_formula f2 s n)\n| _ (all f) s n := all (substitute_formula f s (n+1))\n\n\ndef substitute_preformula : Π n : ℕ, Π (ψ : preformula n), term → {x : string // x ∈ (free_vars_preformula _ ψ)} → preformula n\n| _ (true L) t x := true\n| _ (false L) t x := false\n| _ (equal t1 t2) := equal (substitute_preformula _ _ _ _ t1) (substitute_preformula _ _ _ _ t2)\nend\n", "meta": {"author": "flypitch", "repo": "flypitch", "sha": "aea5800db1f4cce53fc4a113711454b27388ecf8", "save_path": "github-repos/lean/flypitch-flypitch", "path": "github-repos/lean/flypitch-flypitch/flypitch-aea5800db1f4cce53fc4a113711454b27388ecf8/old/language_term_ln.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.4785329899028737}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison\n-/\nimport tactic.reassoc_axiom\nimport tactic.monotonicity\nimport category_theory.category.basic\n\n/-!\n# Functors\n\nDefines a functor between categories, extending a `prefunctor` between quivers.\n\nIntroduces notation `C ⥤ D` for the type of all functors from `C` to `D`.\n(Unfortunately the `⇒` arrow (`\\functor`) is taken by core, \nbut in mathlib4 we should switch to this.)\n-/\n\nnamespace category_theory\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\n\nsection\n\nset_option old_structure_cmd true\n\n/--\n`functor C D` represents a functor between categories `C` and `D`.\n\nTo apply a functor `F` to an object use `F.obj X`, and to a morphism use `F.map f`.\n\nThe axiom `map_id` expresses preservation of identities, and\n`map_comp` expresses functoriality.\n\nSee https://stacks.math.columbia.edu/tag/001B.\n-/\nstructure functor (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D]\n  extends prefunctor C D : Type (max v₁ v₂ u₁ u₂) :=\n(map_id'   : ∀ (X : C), map (𝟙 X) = 𝟙 (obj X) . obviously)\n(map_comp' : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = (map f) ≫ (map g) . obviously)\n\n/-- The prefunctor between the underlying quivers. -/\nadd_decl_doc functor.to_prefunctor\n\nend\n\n-- A functor is basically a function, so give ⥤ a similar precedence to → (25).\n-- For example, `C × D ⥤ E` should parse as `(C × D) ⥤ E` not `C × (D ⥤ E)`.\ninfixr ` ⥤ `:26 := functor       -- type as \\func --\n\nrestate_axiom functor.map_id'\nattribute [simp] functor.map_id\nrestate_axiom functor.map_comp'\nattribute [reassoc, simp] functor.map_comp\n\nnamespace functor\n\nsection\nvariables (C : Type u₁) [category.{v₁} C]\n\n/-- `𝟭 C` is the identity functor on a category `C`. -/\nprotected def id : C ⥤ C :=\n{ obj := λ X, X,\n  map := λ _ _ f, f }\n\nnotation `𝟭` := functor.id -- Type this as `\\sb1`\n\ninstance : inhabited (C ⥤ C) := ⟨functor.id C⟩\n\nvariable {C}\n\n@[simp] lemma id_obj (X : C) : (𝟭 C).obj X = X := rfl\n@[simp] lemma id_map {X Y : C} (f : X ⟶ Y) : (𝟭 C).map f = f := rfl\nend\n\nsection\nvariables {C : Type u₁} [category.{v₁} C]\n          {D : Type u₂} [category.{v₂} D]\n          {E : Type u₃} [category.{v₃} E]\n\n/--\n`F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp (F : C ⥤ D) (G : D ⥤ E) : C ⥤ E :=\n{ obj := λ X, G.obj (F.obj X),\n  map := λ _ _ f, G.map (F.map f) }\n\ninfixr ` ⋙ `:80 := comp\n\n@[simp] lemma comp_obj (F : C ⥤ D) (G : D ⥤ E) (X : C) : (F ⋙ G).obj X = G.obj (F.obj X) := rfl\n@[simp] lemma comp_map (F : C ⥤ D) (G : D ⥤ E) {X Y : C} (f : X ⟶ Y) :\n  (F ⋙ G).map f = G.map (F.map f) := rfl\n\n-- These are not simp lemmas because rewriting along equalities between functors\n-- is not necessarily a good idea.\n-- Natural isomorphisms are also provided in `whiskering.lean`.\nprotected lemma comp_id (F : C ⥤ D) : F ⋙ (𝟭 D) = F := by cases F; refl\nprotected lemma id_comp (F : C ⥤ D) : (𝟭 C) ⋙ F = F := by cases F; refl\n\n@[simp] lemma map_dite (F : C ⥤ D) {X Y : C} {P : Prop} [decidable P]\n  (f : P → (X ⟶ Y)) (g : ¬P → (X ⟶ Y)) :\n  F.map (if h : P then f h else g h) = if h : P then F.map (f h) else F.map (g h) :=\nby { split_ifs; refl, }\n\nend\n\nend functor\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6688802603710085, "lm_q1q2_score": 0.47853298857531684}}
{"text": "import .ops\nopen subtype nnf tmodel list\n\nsection\nvariables (φ ψ : nnf) (Γ₁ Γ₂ Δ Λ: list nnf) {st : Type}\nvariables (k : S4 st) (s : st)\nopen list\n\ntheorem sat_subset (h₁ : Γ₁ ⊆ Γ₂) (h₂ : sat k s Γ₂) : sat k s Γ₁ :=\nλ x hx, h₂ _ (h₁ hx)\n\ntheorem sat_sublist (h₁ : Γ₁ <+ Γ₂) (h₂ :sat k s Γ₂) : sat k s Γ₁ := \nsat_subset _ _ _ _ (sublist.subset h₁) h₂\n\ntheorem sat_append (h₁ : sat k s Γ₁) (h₂ : sat k s Γ₂) : sat k s (Γ₁ ++ Γ₂) :=\nbegin\n  intros φ h, rw mem_append at h, cases h,\n  apply h₁ _ h, apply h₂ _ h\nend\n\ntheorem unsat_contra  {Δ n} : var n ∈ Δ →  neg n ∈ Δ →  unsatisfiable Δ:= \nbegin\n  intros h₁ h₂, intros v hsat, intros s hsat,\n  have := hsat _ h₁, have := hsat _ h₂, simpa\nend\n\ntheorem unsat_contra_seqt {Δ : sseqt} {n} : var n ∈ Δ.m →  neg n ∈ Δ.m →  unsatisfiable (Δ.m ++ Δ.b):= \nbegin\n  intros h₁ h₂, intros st m, intros s hsat,\n  have := unsat_contra h₁ h₂,\n  have := this _ m s,\n  apply this,\n  apply sat_subset _ _ _ _ _ hsat, \n  simp\nend\n\ntheorem sat_of_and : force k s (and φ ψ) ↔ (force k s φ) ∧ (force k s ψ) := \nby split; {intro, simpa}\n\ntheorem sat_of_sat_erase (h₁ : sat k s $ Δ.erase φ) (h₂ : force k s φ) : sat k s Δ := \nbegin\n  intro ψ, intro h,\n  by_cases (ψ = φ),\n  {rw h, assumption},\n  {have : ψ ∈ Δ.erase φ,\n   rw mem_erase_of_ne, assumption, exact h,\n   apply h₁, assumption}\nend\n\ntheorem unsat_and_of_unsat_split \n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : unsatisfiable $ φ :: ψ :: Δ.erase (and φ ψ)) : \n        unsatisfiable Δ :=\nbegin\n  intro st, intros, intro h,\n  apply h₂, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ h₁, rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ h₁, rw sat_of_and at this, exact this.2}, \n    {have := h _ h₁, apply h, apply mem_of_mem_erase he} }\nend\n\ntheorem unsat_and_of_unsat_split_seqt {Γ}\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : unsatisfiable $ (φ :: ψ :: Δ.erase (and φ ψ)++Γ)) : \n        unsatisfiable (Δ++Γ) :=\nbegin\n  intro st, intros, intro h,\n  apply h₂, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ (mem_append_left _ h₁), rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ (mem_append_left _ h₁), rw sat_of_and at this, exact this.2},\n    {have := h _ (mem_append_left _ h₁), apply h, apply mem_of_mem_erase, rw erase_append_left, exact he, exact h₁} }\nend\n\ntheorem sat_and_of_sat_split\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : sat k s $ φ :: ψ :: Δ.erase (and φ ψ)) : \n        sat k s Δ := \nbegin\n  intro e, intro he,\n  by_cases (e = and φ ψ),\n  { rw h, dsimp, split, repeat {apply h₂, simp} },\n  { have : e ∈ Δ.erase (and φ ψ),\n      { rw mem_erase_of_ne, repeat { assumption } },\n    apply h₂, simp [this] }\nend\n\ntheorem sat_and_of_sat_split_seqt {Γ}\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : sat k s $ (φ :: ψ :: Δ.erase (and φ ψ)++Γ)) : \n        sat k s (Δ++Γ) := \nbegin\n  intro e, intro he,\n  by_cases (e = and φ ψ),\n  { rw h, dsimp, split, repeat {apply h₂, simp} },\n  { have : e ∈ Δ.erase (and φ ψ) ++ Γ,\n      { rw ←erase_append_left, rw mem_erase_of_ne, repeat {assumption} },\n    apply h₂, simp [this] }\nend\n\ntheorem sat_split_of_sat_and_seqt {Γ}\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : sat k s (Δ++Γ)) : \n        sat k s $ (φ :: ψ :: Δ.erase (and φ ψ)++Γ) := \nbegin\n  intros e he, rw mem_append at he, cases he,\n  have : force k s (and φ ψ), {apply h₂, simp [h₁]}, rw sat_of_and at this, \n  {cases he, \n  {rw he, exact this.left}, \n  {cases he, rw he, exact this.right, apply h₂, rw mem_append, left, apply mem_of_mem_erase he}\n  },\n  {apply h₂, rw mem_append, right, exact he}\nend\n\ntheorem unsat_or_of_unsat_split_seqt {Γ}\n        (h : or φ ψ ∈ Δ) \n        (h₁ : unsatisfiable $ (φ :: Δ.erase (nnf.or φ ψ)++Γ)) \n        (h₂ : unsatisfiable $ (ψ :: Δ.erase (nnf.or φ ψ)++Γ)) : \n        unsatisfiable $ (Δ++Γ) := \nbegin\n  intro, intros, intro hsat,\n  have := hsat _ (mem_append_left _ h),\n  dsimp at this,\n  cases this,\n  {apply h₁, swap 3, exact k, swap, exact s, intro e, intro he, \n   cases he, rw he, exact this, apply hsat, \napply mem_of_mem_erase, rw erase_append_left, exact he, exact h},\n  {apply h₂, swap 3, exact k, swap, exact s, intro e, intro he, \n   cases he, rw he, exact this, apply hsat, apply mem_of_mem_erase, rw erase_append_left, exact he, exact h}\nend\n\ntheorem sat_or_of_sat_split_left \n        (h : or φ ψ ∈ Δ) \n        (hl : sat k s $ φ :: Δ.erase (nnf.or φ ψ)) :\n        sat k s Δ := \nbegin\n  intros e he,\n  by_cases (e = or φ ψ),\n  { rw h, dsimp, left, apply hl, simp},\n  {have : e ∈ Δ.erase (or φ ψ),\n     { rw mem_erase_of_ne, repeat { assumption } },\n   apply hl, simp [this]}\nend\n\ntheorem sat_or_of_sat_split_right\n        (h : or φ ψ ∈ Δ) \n        (hl : sat k s $ ψ :: Δ.erase (nnf.or φ ψ)) :\n        sat k s Δ := \nbegin\n  intros e he,\n  by_cases (e = or φ ψ),\n  { rw h, dsimp, right, apply hl, simp},\n  { have : e ∈ Δ.erase (or φ ψ),\n      { rw mem_erase_of_ne, repeat { assumption } },\n    apply hl, simp [this] }\nend\n\n/- S4-specific lemmas -/\n\ntheorem force_of_force_box (h : force k s $ box φ) : force k s φ \n:= by apply h; apply k.refl\n\ntheorem force_box_box_of_force_box : force k s (box φ) → force k s (box (box φ)) :=\nby intros h s₁ rs₁ s₂ rs₂; apply h; apply k.trans rs₁ rs₂\n\ntheorem unsat_of_unsat_box_new\n        (h₁ : box φ ∈ Δ) \n        (h₂ : unsatisfiable $ (φ :: Δ.erase (box φ)) ++ box φ :: Λ) : \n        unsatisfiable (Δ ++ Λ) :=\nbegin\n  intros st k s h,\n  apply h₂, swap 3, exact k, swap, exact s,\n  intros e he,\n  rw [mem_append] at he,\n  cases he,\n  {cases he, \n    {rw he, apply force_of_force_box, apply h (box φ), simp [h₁]},\n    {apply h, rw mem_append, left, apply mem_of_mem_erase he }},\n  {cases he, \n    {rw ←he at h₁, apply h, rw mem_append, left, exact h₁},\n    {apply h, rw mem_append, right, assumption}}\nend\n\ntheorem sat_copy_of_sat_box_new\n        (h₁ : box φ ∈ Δ) \n        (h₂ : sat k s $ (φ :: Δ.erase (box φ)) ++ box φ :: Λ) : \n        sat k s (Δ ++ Λ) :=\nbegin\n  intros ψ hφ,\n  rw mem_append at hφ,\n  cases hφ,\n  {by_cases heq : ψ = box φ, \n    {rw heq, apply h₂ (box φ), simp}, \n    {have := mem_erase_of_ne heq, rw ←this at hφ, apply h₂, simp, right, left, exact hφ}},\n  {apply h₂, simp, repeat {right}, exact hφ}\nend\n\ntheorem unsat_of_unsat_box_dup\n        (h₁ : box φ ∈ Δ)\n        (h₃ : unsatisfiable $ (φ :: Δ.erase (box φ)) ++ Λ) : \n        unsatisfiable (Δ ++ Λ) :=\nbegin\n  intros st k s h,\n  apply h₃, swap 3, exact k, swap, exact s,\n  intros e he,\n  cases he,\n  {rw he, apply force_of_force_box, apply h (box φ), simp [h₁]},\n  {have := mem_append.1 he, cases this, \n   {apply h, apply mem_append_left, apply mem_of_mem_erase this},\n   {apply h, apply mem_append_right, exact this}}\nend\n\nend\n\ndef unmodal_seqt (Γ : sseqt) : list sseqt :=\n@list.pmap _ _ (λ φ, φ ∉ Γ.h ∧ dia φ ∈ Γ.m)\n(λ d h,\n({s := some {d := d, b := Γ.b},\na := {d := d, b := Γ.b} :: Γ.a,\nh := d :: Γ.h,\nm := d :: Γ.b,\nndh := begin rw list.nodup_cons, split, exact h.1, exact Γ.ndh end,\nsph := begin apply list.cons_subperm_of_mem, apply Γ.ndh, exact h.1, apply mem_closure_dia, apply Γ.sbm, exact h.2,  exact Γ.sph end,\nsbm := begin rw list.cons_subset, split, apply mem_closure_dia, apply Γ.sbm, exact h.2, apply list.subperm.subset, exact Γ.spb end,\nha  := begin intros φ h, cases h with l r, rw l, simp, right, apply Γ.ha, exact r end,\nps₁ := begin simp [dsig] end,\nps₂ := begin simp [bsig] end,\n.. Γ} : sseqt))\n(filter_undia Γ.h Γ.m)\n(begin\nintros φ hmem,split, \n{apply mem_filter_dia_right, exact hmem},\n{apply mem_filter_dia_right_aux, exact hmem}\nend)\n\ndef unmodal_seqt_size (Γ : sseqt) : ∀ (i : sseqt),  i ∈ unmodal_seqt Γ → (prod.measure_lex' sseqt_size i Γ) := \nlist.pmapp _ _ \nbegin \nintros φ h hmem,\nright, left,\napply length_sub_lt_of_nodup_subperm,\n{apply Γ.sph},\n{apply mem_closure_dia, apply Γ.sbm, exact h.2},\n{exact h.1},\n{exact Γ.ndh}\nend \n_\n\ndef sat_unmodal_of_sat {Γ : sseqt} : ∀ (i : sseqt),  i ∈ unmodal_seqt Γ → \n(∀ {st : Type} (k : S4 st) s, \nsat k s (Γ.m ++ Γ.b) → ∃ s', sat k s' (i.m ++ i.b)) :=\nlist.pmapp _ _\nbegin\nintros φ hninh hmem st k s h,\nhave hd : force k s (dia φ), \n  { apply h, rw mem_append, left, exact hninh.2 }, \nhave hb : ∀ φ ∈ Γ.b, force k s (box φ), \n  { intros γ hγ, \n    have := box_only_ex Γ.hb hγ, cases this with w hw,\n    rw hw, apply force_box_box_of_force_box,\n    have := h _ (mem_append_right _ hγ), rw hw at this, exact this},\nrcases hd with ⟨w, hrw, hfw⟩,\nsplit, swap, exact w,\nintros ψ hψ, simp at hψ, cases hψ,\n{rw hψ, exact hfw},\n{apply hb, exact hψ, exact hrw}\nend\n_\n\ndef unsat_of_unsat_unmodal {Γ : sseqt} (i : sseqt) : i ∈ unmodal_seqt Γ ∧ unsatisfiable (i.m ++ i.b) → unsatisfiable (Γ.m ++ Γ.b) := \nbegin\n  intro hex, intros st k s h,\n  have := sat_unmodal_of_sat i hex.1 k s h,\n  cases this with w hw,\n  have := hex.2,\n  exact this _ _ _ hw\nend\n\ndef unmodal_mem_box (Γ : sseqt) : ∀ (i : sseqt),  i ∈ unmodal_seqt Γ → (∀ φ, box φ ∈ Γ.b → box φ ∈ i.m) := \nlist.pmapp _ _ begin intros φ h hmem ψ hψ, right, exact hψ end _\n\ndef mem_unmodal_seqt (Γ : sseqt) (φ) (h : φ ∉ Γ.h ∧ dia φ ∈ Γ.m) : ∃ (i : sseqt), i ∈ unmodal_seqt Γ ∧ φ ∈ i.m := \nbegin\nsplit, swap,\n{exact \n({s := some {d := φ, b := Γ.b},\na := {d := φ, b := Γ.b} :: Γ.a,\nh := φ :: Γ.h,\nm := φ :: Γ.b,\nndh := begin rw list.nodup_cons, split, exact h.1, exact Γ.ndh end,\nsph := begin apply list.cons_subperm_of_mem, apply Γ.ndh, exact h.1, apply mem_closure_dia, apply Γ.sbm, exact h.2,  exact Γ.sph end,\nsbm := begin rw list.cons_subset, split, apply mem_closure_dia, apply Γ.sbm, exact h.2, apply list.subperm.subset, exact Γ.spb end,\nha  := begin intros φ h, cases h with l r, rw l, simp, right, apply Γ.ha, exact r end,\nps₁ := begin intro, simp [dsig] end,\nps₂ := begin intro, simp [bsig] end,\n.. Γ} : sseqt)},\n{ dsimp [unmodal_seqt], split,\n  {let mf := (λ (d : nnf) (h : d ∉ Γ.h ∧ dia d ∈ Γ.m),\n      ({s := some {d := d, b := Γ.b},\n       a := {d := d, b := Γ.b} :: Γ.a,\n       h := d :: Γ.h,\n       m := d :: Γ.b,\n       ndh := begin rw list.nodup_cons, split, exact h.1, exact Γ.ndh end,\n       sph := begin apply list.cons_subperm_of_mem, apply Γ.ndh, exact h.1, apply mem_closure_dia, apply Γ.sbm, exact h.2,  exact Γ.sph end,\n       sbm := begin rw list.cons_subset, split, apply mem_closure_dia, apply Γ.sbm, exact h.2, apply list.subperm.subset, exact Γ.spb end,\n       ha  := begin intros φ h, cases h with l r, rw l, simp, right, apply Γ.ha, exact r end,\n       ps₁ := begin simp [dsig] end,\n       ps₂ := begin simp [bsig] end,\n       .. Γ} :sseqt)),\n  have hmem := mem_filter_undia_left _ _ _ h.2 h.1,\n  have hf : ∀ (y : nnf), y ∈ filter_undia (Γ.h) (Γ.m) → y ∉ Γ.h ∧ dia y ∈ Γ.m, \n    {intros h hy, split, {apply mem_filter_dia_right, exact hy}, {apply mem_filter_dia_right_aux, exact hy}},\n  exact mem_pmap_of_mem mf hmem hf},\n{ simp } }\nend\n\ntheorem unmodal_sig (Γ : sseqt) : ∀ (i : sseqt),  i ∈ unmodal_seqt Γ → (∀ a, a ∈ i.a → some a = i.s ∨ a ∈ Γ.a) := \nlist.pmapp _ _ \nbegin \nintros φ h hmem a ha, simp at ha,\ncases ha,\n{left, simp, exact ha},\n{right, exact ha}\nend \n_\n\n\ntheorem unsat_of_closed_and {Γ Δ} (i : and_instance Γ Δ) (h : unsatisfiable Δ) : unsatisfiable Γ := \nby cases i; { apply unsat_and_of_unsat_split, repeat {assumption} }\n\ntheorem unsat_of_closed_and_seqt {Γ Δ} (i : and_instance_seqt Γ Δ) (h : unsatisfiable (Δ.m++Δ.b)) : unsatisfiable (Γ.m++Γ.b) := \nby cases i; {apply unsat_and_of_unsat_split_seqt, repeat {assumption} }\n\ntheorem unsat_of_closed_or_seqt {Γ₁ Γ₂ Δ : sseqt} (i : or_instance_seqt Δ Γ₁ Γ₂) \n(h₁ : unsatisfiable (Γ₁.m++Γ₁.b)) \n(h₂ : unsatisfiable (Γ₂.m++Γ₂.b)) : \nunsatisfiable (Δ.m++Δ.b) :=\nby cases i; {apply unsat_or_of_unsat_split_seqt, repeat { assumption }}\n\ntheorem unsat_of_closed_box_new {Γ Δ} (i : box_new_instance_seqt Γ Δ) (h : unsatisfiable $ (Δ.m++Δ.b)) : unsatisfiable (Γ.m++Γ.b) := \nby cases i; { apply unsat_of_unsat_box_new, repeat { assumption } }\n\ntheorem unsat_of_closed_box_dup {Γ Δ} (i : box_dup_instance_seqt Γ Δ) (h : unsatisfiable $ (Δ.m++Δ.b)) : unsatisfiable (Γ.m++Γ.b) := \nby cases i; { apply unsat_of_unsat_box_dup, repeat { assumption } }\n", "meta": {"author": "minchaowu", "repo": "ModalTab", "sha": "9bb0bf17faf0554d907ef7bdd639648742889178", "save_path": "github-repos/lean/minchaowu-ModalTab", "path": "github-repos/lean/minchaowu-ModalTab/ModalTab-9bb0bf17faf0554d907ef7bdd639648742889178/src/S4/semantics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6688802603710085, "lm_q1q2_score": 0.47853298857531684}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Markus Himmel, Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.wide_pullbacks\nimport Mathlib.category_theory.limits.shapes.binary_products\nimport Mathlib.PostPort\n\nuniverses v u_1 u u₂ \n\nnamespace Mathlib\n\n/-!\n# Pullbacks\n\nWe define a category `walking_cospan` (resp. `walking_span`), which is the index category\nfor the given data for a pullback (resp. pushout) diagram. Convenience methods `cospan f g`\nand `span f g` construct functors from the walking (co)span, hitting the given morphisms.\n\nWe define `pullback f g` and `pushout f g` as limits and colimits of such functors.\n\n## References\n* [Stacks: Fibre products](https://stacks.math.columbia.edu/tag/001U)\n* [Stacks: Pushouts](https://stacks.math.columbia.edu/tag/0025)\n-/\n\nnamespace category_theory.limits\n\n\n/--\nThe type of objects for the diagram indexing a pullback, defined as a special case of\n`wide_pullback_shape`.\n-/\ndef walking_cospan := wide_pullback_shape walking_pair\n\n/-- The left point of the walking cospan. -/\n/-- The right point of the walking cospan. -/\ndef walking_cospan.left : walking_cospan := some walking_pair.left\n\n/-- The central point of the walking cospan. -/\ndef walking_cospan.right : walking_cospan := some walking_pair.right\n\ndef walking_cospan.one : walking_cospan := none\n\n/--\nThe type of objects for the diagram indexing a pushout, defined as a special case of\n`wide_pushout_shape`.\n-/\ndef walking_span := wide_pushout_shape walking_pair\n\n/-- The left point of the walking span. -/\n/-- The right point of the walking span. -/\ndef walking_span.left : walking_span := some walking_pair.left\n\n/-- The central point of the walking span. -/\ndef walking_span.right : walking_span := some walking_pair.right\n\ndef walking_span.zero : walking_span := none\n\nnamespace walking_cospan\n\n\n/-- The type of arrows for the diagram indexing a pullback. -/\ndef hom : walking_cospan → walking_cospan → Type v := wide_pullback_shape.hom\n\n/-- The left arrow of the walking cospan. -/\n/-- The right arrow of the walking cospan. -/\ndef hom.inl : left ⟶ one := wide_pullback_shape.hom.term walking_pair.left\n\n/-- The identity arrows of the walking cospan. -/\ndef hom.inr : right ⟶ one := wide_pullback_shape.hom.term walking_pair.right\n\ndef hom.id (X : walking_cospan) : X ⟶ X := wide_pullback_shape.hom.id X\n\nprotected instance category_theory.has_hom.hom.subsingleton (X : walking_cospan)\n    (Y : walking_cospan) : subsingleton (X ⟶ Y) :=\n  subsingleton.intro\n    fun (a b : X ⟶ Y) => eq.mpr (id (propext (eq_iff_true_of_subsingleton a b))) trivial\n\nend walking_cospan\n\n\nnamespace walking_span\n\n\n/-- The type of arrows for the diagram indexing a pushout. -/\ndef hom : walking_span → walking_span → Type v := wide_pushout_shape.hom\n\n/-- The left arrow of the walking span. -/\n/-- The right arrow of the walking span. -/\ndef hom.fst : zero ⟶ left := wide_pushout_shape.hom.init walking_pair.left\n\n/-- The identity arrows of the walking span. -/\ndef hom.snd : zero ⟶ right := wide_pushout_shape.hom.init walking_pair.right\n\ndef hom.id (X : walking_span) : X ⟶ X := wide_pushout_shape.hom.id X\n\nprotected instance category_theory.has_hom.hom.subsingleton (X : walking_span) (Y : walking_span) :\n    subsingleton (X ⟶ Y) :=\n  subsingleton.intro\n    fun (a b : X ⟶ Y) => eq.mpr (id (propext (eq_iff_true_of_subsingleton a b))) trivial\n\nend walking_span\n\n\n/-- `cospan f g` is the functor from the walking cospan hitting `f` and `g`. -/\ndef cospan {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n    walking_cospan ⥤ C :=\n  wide_pullback_shape.wide_cospan Z (fun (j : walking_pair) => walking_pair.cases_on j X Y)\n    fun (j : walking_pair) => walking_pair.cases_on j f g\n\n/-- `span f g` is the functor from the walking span hitting `f` and `g`. -/\ndef span {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :\n    walking_span ⥤ C :=\n  wide_pushout_shape.wide_span X (fun (j : walking_pair) => walking_pair.cases_on j Y Z)\n    fun (j : walking_pair) => walking_pair.cases_on j f g\n\n@[simp] theorem cospan_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z)\n    (g : Y ⟶ Z) : functor.obj (cospan f g) walking_cospan.left = X :=\n  rfl\n\n@[simp] theorem span_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    (g : X ⟶ Z) : functor.obj (span f g) walking_span.left = Y :=\n  rfl\n\n@[simp] theorem cospan_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z)\n    (g : Y ⟶ Z) : functor.obj (cospan f g) walking_cospan.right = Y :=\n  rfl\n\n@[simp] theorem span_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    (g : X ⟶ Z) : functor.obj (span f g) walking_span.right = Z :=\n  rfl\n\n@[simp] theorem cospan_one {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z)\n    (g : Y ⟶ Z) : functor.obj (cospan f g) walking_cospan.one = Z :=\n  rfl\n\n@[simp] theorem span_zero {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    (g : X ⟶ Z) : functor.obj (span f g) walking_span.zero = X :=\n  rfl\n\n@[simp] theorem cospan_map_inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z)\n    (g : Y ⟶ Z) : functor.map (cospan f g) walking_cospan.hom.inl = f :=\n  rfl\n\n@[simp] theorem span_map_fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    (g : X ⟶ Z) : functor.map (span f g) walking_span.hom.fst = f :=\n  rfl\n\n@[simp] theorem cospan_map_inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z)\n    (g : Y ⟶ Z) : functor.map (cospan f g) walking_cospan.hom.inr = g :=\n  rfl\n\n@[simp] theorem span_map_snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    (g : X ⟶ Z) : functor.map (span f g) walking_span.hom.snd = g :=\n  rfl\n\ntheorem cospan_map_id {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n    (w : walking_cospan) : functor.map (cospan f g) (walking_cospan.hom.id w) = 𝟙 :=\n  rfl\n\ntheorem span_map_id {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z)\n    (w : walking_span) : functor.map (span f g) (walking_span.hom.id w) = 𝟙 :=\n  rfl\n\n/-- Every diagram indexing an pullback is naturally isomorphic (actually, equal) to a `cospan` -/\ndef diagram_iso_cospan {C : Type u} [category C] (F : walking_cospan ⥤ C) :\n    F ≅ cospan (functor.map F walking_cospan.hom.inl) (functor.map F walking_cospan.hom.inr) :=\n  nat_iso.of_components (fun (j : walking_cospan) => eq_to_iso sorry) sorry\n\n/-- Every diagram indexing a pushout is naturally isomorphic (actually, equal) to a `span` -/\ndef diagram_iso_span {C : Type u} [category C] (F : walking_span ⥤ C) :\n    F ≅ span (functor.map F walking_span.hom.fst) (functor.map F walking_span.hom.snd) :=\n  nat_iso.of_components (fun (j : walking_span) => eq_to_iso sorry) sorry\n\n/-- A pullback cone is just a cone on the cospan formed by two morphisms `f : X ⟶ Z` and\n    `g : Y ⟶ Z`.-/\ndef pullback_cone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :=\n  cone (cospan f g)\n\nnamespace pullback_cone\n\n\n/-- The first projection of a pullback cone. -/\ndef fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    (t : pullback_cone f g) : cone.X t ⟶ X :=\n  nat_trans.app (cone.π t) walking_cospan.left\n\n/-- The second projection of a pullback cone. -/\ndef snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    (t : pullback_cone f g) : cone.X t ⟶ Y :=\n  nat_trans.app (cone.π t) walking_cospan.right\n\n/-- This is a slightly more convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content -/\ndef is_limit_aux {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    (t : pullback_cone f g) (lift : (s : cone (cospan f g)) → cone.X s ⟶ cone.X t)\n    (fac_left : ∀ (s : pullback_cone f g), lift s ≫ fst t = fst s)\n    (fac_right : ∀ (s : pullback_cone f g), lift s ≫ snd t = snd s)\n    (uniq :\n      ∀ (s : pullback_cone f g) (m : cone.X s ⟶ cone.X t),\n        (∀ (j : walking_cospan), m ≫ nat_trans.app (cone.π t) j = nat_trans.app (cone.π s) j) →\n          m = lift s) :\n    is_limit t :=\n  is_limit.mk lift\n\n/-- This is another convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef is_limit_aux' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    (t : pullback_cone f g)\n    (create :\n      (s : pullback_cone f g) →\n        Subtype\n          fun (l : cone.X s ⟶ cone.X t) =>\n            l ≫ fst t = fst s ∧\n              l ≫ snd t = snd s ∧\n                ∀ {m : cone.X s ⟶ cone.X t}, m ≫ fst t = fst s → m ≫ snd t = snd s → m = l) :\n    is_limit t :=\n  is_limit_aux t (fun (s : cone (cospan f g)) => subtype.val (create s)) sorry sorry sorry\n\n/-- A pullback cone on `f` and `g` is determined by morphisms `fst : W ⟶ X` and `snd : W ⟶ Y`\n    such that `fst ≫ f = snd ≫ g`. -/\n@[simp] theorem mk_π_app {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) (j : walking_cospan) :\n    nat_trans.app (cone.π (mk fst snd eq)) j =\n        option.cases_on j (fst ≫ f) fun (j' : walking_pair) => walking_pair.cases_on j' fst snd :=\n  Eq.refl (nat_trans.app (cone.π (mk fst snd eq)) j)\n\n@[simp] theorem mk_π_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z}\n    {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    nat_trans.app (cone.π (mk fst snd eq)) walking_cospan.left = fst :=\n  rfl\n\n@[simp] theorem mk_π_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z}\n    {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    nat_trans.app (cone.π (mk fst snd eq)) walking_cospan.right = snd :=\n  rfl\n\n@[simp] theorem mk_π_app_one {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z}\n    {g : Y ⟶ Z} {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    nat_trans.app (cone.π (mk fst snd eq)) walking_cospan.one = fst ≫ f :=\n  rfl\n\n@[simp] theorem mk_fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : fst (mk fst snd eq) = fst :=\n  rfl\n\n@[simp] theorem mk_snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : snd (mk fst snd eq) = snd :=\n  rfl\n\ntheorem condition_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    (t : pullback_cone f g) {X' : C} (f' : Z ⟶ X') : fst t ≫ f ≫ f' = snd t ≫ g ≫ f' :=\n  sorry\n\n/-- To check whether a morphism is equalized by the maps of a pullback cone, it suffices to check\n  it for `fst t` and `snd t` -/\ntheorem equalizer_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    (t : pullback_cone f g) {W : C} {k : W ⟶ cone.X t} {l : W ⟶ cone.X t}\n    (h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) (j : walking_cospan) :\n    k ≫ nat_trans.app (cone.π t) j = l ≫ nat_trans.app (cone.π t) j :=\n  sorry\n\ntheorem is_limit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    {t : pullback_cone f g} (ht : is_limit t) {W : C} {k : W ⟶ cone.X t} {l : W ⟶ cone.X t}\n    (h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) : k = l :=\n  is_limit.hom_ext ht (equalizer_ext t h₀ h₁)\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W ⟶ X` and `k : W ⟶ Y` are such that\n    `h ≫ f = k ≫ g`, then we have `l : W ⟶ t.X` satisfying `l ≫ fst t = h` and `l ≫ snd t = k`.\n    -/\ndef is_limit.lift' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    {t : pullback_cone f g} (ht : is_limit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) :\n    Subtype fun (l : W ⟶ cone.X t) => l ≫ fst t = h ∧ l ≫ snd t = k :=\n  { val := is_limit.lift ht (mk h k w), property := sorry }\n\n/--\nThis is a more convenient formulation to show that a `pullback_cone` constructed using\n`pullback_cone.mk` is a limit cone.\n-/\ndef is_limit.mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C}\n    {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g)\n    (lift : (s : pullback_cone f g) → cone.X s ⟶ W)\n    (fac_left : ∀ (s : pullback_cone f g), lift s ≫ fst = fst s)\n    (fac_right : ∀ (s : pullback_cone f g), lift s ≫ snd = snd s)\n    (uniq :\n      ∀ (s : pullback_cone f g) (m : cone.X s ⟶ W),\n        m ≫ fst = fst s → m ≫ snd = snd s → m = lift s) :\n    is_limit (mk fst snd eq) :=\n  is_limit_aux (mk fst snd eq) lift fac_left fac_right sorry\n\n/-- The flip of a pullback square is a pullback square. -/\ndef flip_is_limit {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} {W : C}\n    {h : W ⟶ X} {k : W ⟶ Y} {comm : h ≫ f = k ≫ g} (t : is_limit (mk k h flip_is_limit._proof_1)) :\n    is_limit (mk h k comm) :=\n  is_limit_aux' (mk h k comm)\n    fun (s : pullback_cone f g) =>\n      { val := subtype.val (is_limit.lift' t (snd s) (fst s) sorry), property := sorry }\n\n/--\nThe pullback cone `(𝟙 X, 𝟙 X)` for the pair `(f, f)` is a limit if `f` is a mono. The converse is\nshown in `mono_of_pullback_is_id`.\n-/\ndef is_limit_mk_id_id {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [mono f] :\n    is_limit (mk 𝟙 𝟙 (is_limit_mk_id_id._proof_1 f)) :=\n  is_limit.mk sorry (fun (s : pullback_cone f f) => fst s) sorry sorry sorry\n\n/--\n`f` is a mono if the pullback cone `(𝟙 X, 𝟙 X)` is a limit for the pair `(f, f)`. The converse is\ngiven in `pullback_cone.is_id_of_mono`.\n-/\ntheorem mono_of_is_limit_mk_id_id {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    (t : is_limit (mk 𝟙 𝟙 rfl)) : mono f :=\n  sorry\n\nend pullback_cone\n\n\n/-- A pushout cocone is just a cocone on the span formed by two morphisms `f : X ⟶ Y` and\n    `g : X ⟶ Z`.-/\ndef pushout_cocone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :=\n  cocone (span f g)\n\nnamespace pushout_cocone\n\n\n/-- The first inclusion of a pushout cocone. -/\ndef inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    (t : pushout_cocone f g) : Y ⟶ cocone.X t :=\n  nat_trans.app (cocone.ι t) walking_span.left\n\n/-- The second inclusion of a pushout cocone. -/\ndef inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    (t : pushout_cocone f g) : Z ⟶ cocone.X t :=\n  nat_trans.app (cocone.ι t) walking_span.right\n\n/-- This is a slightly more convenient method to verify that a pushout cocone is a colimit cocone.\n    It only asks for a proof of facts that carry any mathematical content -/\ndef is_colimit_aux {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    (t : pushout_cocone f g) (desc : (s : pushout_cocone f g) → cocone.X t ⟶ cocone.X s)\n    (fac_left : ∀ (s : pushout_cocone f g), inl t ≫ desc s = inl s)\n    (fac_right : ∀ (s : pushout_cocone f g), inr t ≫ desc s = inr s)\n    (uniq :\n      ∀ (s : pushout_cocone f g) (m : cocone.X t ⟶ cocone.X s),\n        (∀ (j : walking_span), nat_trans.app (cocone.ι t) j ≫ m = nat_trans.app (cocone.ι s) j) →\n          m = desc s) :\n    is_colimit t :=\n  is_colimit.mk desc\n\n/-- This is another convenient method to verify that a pushout cocone is a colimit cocone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef is_colimit_aux' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    (t : pushout_cocone f g)\n    (create :\n      (s : pushout_cocone f g) →\n        Subtype\n          fun (l : cocone.X t ⟶ cocone.X s) =>\n            inl t ≫ l = inl s ∧\n              inr t ≫ l = inr s ∧\n                ∀ {m : cocone.X t ⟶ cocone.X s}, inl t ≫ m = inl s → inr t ≫ m = inr s → m = l) :\n    is_colimit t :=\n  is_colimit_aux t (fun (s : pushout_cocone f g) => subtype.val (create s)) sorry sorry sorry\n\n/-- A pushout cocone on `f` and `g` is determined by morphisms `inl : Y ⟶ W` and `inr : Z ⟶ W` such\n    that `f ≫ inl = g ↠ inr`. -/\ndef mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C}\n    (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : pushout_cocone f g :=\n  cocone.mk W\n    (nat_trans.mk\n      fun (j : walking_span) =>\n        option.cases_on j (f ≫ inl) fun (j' : walking_pair) => walking_pair.cases_on j' inl inr)\n\n@[simp] theorem mk_ι_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y}\n    {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    nat_trans.app (cocone.ι (mk inl inr eq)) walking_span.left = inl :=\n  rfl\n\n@[simp] theorem mk_ι_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y}\n    {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    nat_trans.app (cocone.ι (mk inl inr eq)) walking_span.right = inr :=\n  rfl\n\n@[simp] theorem mk_ι_app_zero {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y}\n    {g : X ⟶ Z} {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    nat_trans.app (cocone.ι (mk inl inr eq)) walking_span.zero = f ≫ inl :=\n  rfl\n\n@[simp] theorem mk_inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : inl (mk inl inr eq) = inl :=\n  rfl\n\n@[simp] theorem mk_inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : inr (mk inl inr eq) = inr :=\n  rfl\n\ntheorem condition_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    (t : pushout_cocone f g) {X' : C} (f' : cocone.X t ⟶ X') : f ≫ inl t ≫ f' = g ≫ inr t ≫ f' :=\n  sorry\n\n/-- To check whether a morphism is coequalized by the maps of a pushout cocone, it suffices to check\n  it for `inl t` and `inr t` -/\ntheorem coequalizer_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    (t : pushout_cocone f g) {W : C} {k : cocone.X t ⟶ W} {l : cocone.X t ⟶ W}\n    (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) (j : walking_span) :\n    nat_trans.app (cocone.ι t) j ≫ k = nat_trans.app (cocone.ι t) j ≫ l :=\n  sorry\n\ntheorem is_colimit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    {t : pushout_cocone f g} (ht : is_colimit t) {W : C} {k : cocone.X t ⟶ W} {l : cocone.X t ⟶ W}\n    (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) : k = l :=\n  is_colimit.hom_ext ht (coequalizer_ext t h₀ h₁)\n\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y ⟶ W` and `k : Z ⟶ W` are\n    morphisms satisfying `f ≫ h = g ≫ k`, then we have a factorization `l : t.X ⟶ W` such that\n    `inl t ≫ l = h` and `inr t ≫ l = k`. -/\ndef is_colimit.desc' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    {t : pushout_cocone f g} (ht : is_colimit t) {W : C} (h : Y ⟶ W) (k : Z ⟶ W)\n    (w : f ≫ h = g ≫ k) : Subtype fun (l : cocone.X t ⟶ W) => inl t ≫ l = h ∧ inr t ≫ l = k :=\n  { val := is_colimit.desc ht (mk h k w), property := sorry }\n\n/--\nThis is a more convenient formulation to show that a `pushout_cocone` constructed using\n`pushout_cocone.mk` is a colimit cocone.\n-/\ndef is_colimit.mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z} {W : C}\n    {inl : Y ⟶ W} {inr : Z ⟶ W} (eq : f ≫ inl = g ≫ inr)\n    (desc : (s : pushout_cocone f g) → W ⟶ cocone.X s)\n    (fac_left : ∀ (s : pushout_cocone f g), inl ≫ desc s = inl s)\n    (fac_right : ∀ (s : pushout_cocone f g), inr ≫ desc s = inr s)\n    (uniq :\n      ∀ (s : pushout_cocone f g) (m : W ⟶ cocone.X s),\n        inl ≫ m = inl s → inr ≫ m = inr s → m = desc s) :\n    is_colimit (mk inl inr eq) :=\n  is_colimit_aux (mk inl inr eq) desc fac_left fac_right sorry\n\n/-- The flip of a pushout square is a pushout square. -/\ndef flip_is_colimit {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    {W : C} {h : Y ⟶ W} {k : Z ⟶ W} {comm : f ≫ h = g ≫ k}\n    (t : is_colimit (mk k h flip_is_colimit._proof_1)) : is_colimit (mk h k comm) :=\n  is_colimit_aux' (mk h k comm)\n    fun (s : pushout_cocone f g) =>\n      { val := subtype.val (is_colimit.desc' t (inr s) (inl s) sorry), property := sorry }\n\nend pushout_cocone\n\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pullbacks. Given `F : walking_cospan ⥤ C`, which is really the same as\n    `cospan (F.map inl) (F.map inr)`, and a pullback cone on `F.map inl` and `F.map inr`, we\n    get a cone on `F`.\n\n    If you're thinking about using this, have a look at `has_pullbacks_of_has_limit_cospan`,\n    which you may find to be an easier way of achieving your goal. -/\n@[simp] theorem cone.of_pullback_cone_π {C : Type u} [category C] {F : walking_cospan ⥤ C}\n    (t :\n      pullback_cone (functor.map F walking_cospan.hom.inl) (functor.map F walking_cospan.hom.inr)) :\n    cone.π (cone.of_pullback_cone t) = cone.π t ≫ iso.inv (diagram_iso_cospan F) :=\n  Eq.refl (cone.π (cone.of_pullback_cone t))\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pushout. Given `F : walking_span ⥤ C`, which is really the same as\n    `span (F.map fst) (F.mal snd)`, and a pushout cocone on `F.map fst` and `F.map snd`,\n    we get a cocone on `F`.\n\n    If you're thinking about using this, have a look at `has_pushouts_of_has_colimit_span`, which\n    you may find to be an easiery way of achieving your goal.  -/\n@[simp] theorem cocone.of_pushout_cocone_X {C : Type u} [category C] {F : walking_span ⥤ C}\n    (t : pushout_cocone (functor.map F walking_span.hom.fst) (functor.map F walking_span.hom.snd)) :\n    cocone.X (cocone.of_pushout_cocone t) = cocone.X t :=\n  Eq.refl (cocone.X (cocone.of_pushout_cocone t))\n\n/-- Given `F : walking_cospan ⥤ C`, which is really the same as `cospan (F.map inl) (F.map inr)`,\n    and a cone on `F`, we get a pullback cone on `F.map inl` and `F.map inr`. -/\n@[simp] theorem pullback_cone.of_cone_X {C : Type u} [category C] {F : walking_cospan ⥤ C}\n    (t : cone F) : cone.X (pullback_cone.of_cone t) = cone.X t :=\n  Eq.refl (cone.X (pullback_cone.of_cone t))\n\n/-- Given `F : walking_span ⥤ C`, which is really the same as `span (F.map fst) (F.map snd)`,\n    and a cocone on `F`, we get a pushout cocone on `F.map fst` and `F.map snd`. -/\ndef pushout_cocone.of_cocone {C : Type u} [category C] {F : walking_span ⥤ C} (t : cocone F) :\n    pushout_cocone (functor.map F walking_span.hom.fst) (functor.map F walking_span.hom.snd) :=\n  cocone.mk (cocone.X t) (iso.inv (diagram_iso_span F) ≫ cocone.ι t)\n\n/--\n`has_pullback f g` represents a particular choice of limiting cone\nfor the pair of morphisms `f : X ⟶ Z` and `g : Y ⟶ Z`.\n-/\n/--\ndef has_pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :=\n  has_limit (cospan f g)\n\n`has_pushout f g` represents a particular choice of colimiting cocone\nfor the pair of morphisms `f : X ⟶ Y` and `g : X ⟶ Z`.\n-/\ndef has_pushout {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :=\n  has_colimit (span f g)\n\n/-- `pullback f g` computes the pullback of a pair of morphisms with the same target. -/\ndef pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n    [has_pullback f g] : C :=\n  limit (cospan f g)\n\n/-- `pushout f g` computes the pushout of a pair of morphisms with the same source. -/\ndef pushout {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : X ⟶ Z)\n    [has_pushout f g] : C :=\n  colimit (span f g)\n\n/-- The first projection of the pullback of `f` and `g`. -/\ndef pullback.fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    [has_pullback f g] : pullback f g ⟶ X :=\n  limit.π (cospan f g) walking_cospan.left\n\n/-- The second projection of the pullback of `f` and `g`. -/\ndef pullback.snd {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    [has_pullback f g] : pullback f g ⟶ Y :=\n  limit.π (cospan f g) walking_cospan.right\n\n/-- The first inclusion into the pushout of `f` and `g`. -/\ndef pushout.inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    [has_pushout f g] : Y ⟶ pushout f g :=\n  colimit.ι (span f g) walking_span.left\n\n/-- The second inclusion into the pushout of `f` and `g`. -/\ndef pushout.inr {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    [has_pushout f g] : Z ⟶ pushout f g :=\n  colimit.ι (span f g) walking_span.right\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `pullback.lift : W ⟶ pullback f g`. -/\ndef pullback.lift {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : W ⟶ pullback f g :=\n  limit.lift (cospan f g) (pullback_cone.mk h k w)\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `pushout.desc : pushout f g ⟶ W`. -/\ndef pushout.desc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout f g ⟶ W :=\n  colimit.desc (span f g) (pushout_cocone.mk h k w)\n\n@[simp] theorem pullback.lift_fst_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C}\n    {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) {X' : C}\n    (f' : X ⟶ X') : pullback.lift h k w ≫ pullback.fst ≫ f' = h ≫ f' :=\n  sorry\n\n@[simp] theorem pullback.lift_snd_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C}\n    {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) {X' : C}\n    (f' : Y ⟶ X') : pullback.lift h k w ≫ pullback.snd ≫ f' = k ≫ f' :=\n  sorry\n\n@[simp] theorem pushout.inl_desc_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C}\n    {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) {X' : C}\n    (f' : W ⟶ X') : pushout.inl ≫ pushout.desc h k w ≫ f' = h ≫ f' :=\n  sorry\n\n@[simp] theorem pushout.inr_desc_assoc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C}\n    {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) {X' : C}\n    (f' : W ⟶ X') : pushout.inr ≫ pushout.desc h k w ≫ f' = k ≫ f' :=\n  sorry\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `l : W ⟶ pullback f g` such that `l ≫ pullback.fst = h` and `l ≫ pullback.snd = k`. -/\ndef pullback.lift' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    [has_pullback f g] (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) :\n    Subtype fun (l : W ⟶ pullback f g) => l ≫ pullback.fst = h ∧ l ≫ pullback.snd = k :=\n  { val := pullback.lift h k w, property := sorry }\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `l : pushout f g ⟶ W` such that `pushout.inl ≫ l = h` and `pushout.inr ≫ l = k`. -/\ndef pullback.desc' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    [has_pushout f g] (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) :\n    Subtype fun (l : pushout f g ⟶ W) => pushout.inl ≫ l = h ∧ pushout.inr ≫ l = k :=\n  { val := pushout.desc h k w, property := sorry }\n\ntheorem pullback.condition {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    [has_pullback f g] : pullback.fst ≫ f = pullback.snd ≫ g :=\n  pullback_cone.condition (limit.cone (cospan f g))\n\ntheorem pushout.condition_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y}\n    {g : X ⟶ Z} [has_pushout f g] {X' : C} (f' : pushout f g ⟶ X') :\n    f ≫ pushout.inl ≫ f' = g ≫ pushout.inr ≫ f' :=\n  sorry\n\n/-- Two morphisms into a pullback are equal if their compositions with the pullback morphisms are\n    equal -/\ntheorem pullback.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}\n    [has_pullback f g] {W : C} {k : W ⟶ pullback f g} {l : W ⟶ pullback f g}\n    (h₀ : k ≫ pullback.fst = l ≫ pullback.fst) (h₁ : k ≫ pullback.snd = l ≫ pullback.snd) : k = l :=\n  limit.hom_ext (pullback_cone.equalizer_ext (limit.cone (cospan f g)) h₀ h₁)\n\n/-- The pullback cone built from the pullback projections is a pullback. -/\ndef pullback_is_pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n    [has_pullback f g] : is_limit (pullback_cone.mk pullback.fst pullback.snd pullback.condition) :=\n  pullback_cone.is_limit.mk pullback.condition\n    (fun (s : pullback_cone f g) =>\n      pullback.lift (pullback_cone.fst s) (pullback_cone.snd s) (pullback_cone.condition s))\n    sorry sorry sorry\n\n/-- The pullback of a monomorphism is a monomorphism -/\nprotected instance pullback.fst_of_mono {C : Type u} [category C] {X : C} {Y : C} {Z : C}\n    {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] [mono g] : mono pullback.fst :=\n  sorry\n\n/-- The pullback of a monomorphism is a monomorphism -/\nprotected instance pullback.snd_of_mono {C : Type u} [category C] {X : C} {Y : C} {Z : C}\n    {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] [mono f] : mono pullback.snd :=\n  sorry\n\n/-- Two morphisms out of a pushout are equal if their compositions with the pushout morphisms are\n    equal -/\ntheorem pushout.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : X ⟶ Z}\n    [has_pushout f g] {W : C} {k : pushout f g ⟶ W} {l : pushout f g ⟶ W}\n    (h₀ : pushout.inl ≫ k = pushout.inl ≫ l) (h₁ : pushout.inr ≫ k = pushout.inr ≫ l) : k = l :=\n  colimit.hom_ext (pushout_cocone.coequalizer_ext (colimit.cocone (span f g)) h₀ h₁)\n\n/-- The pushout of an epimorphism is an epimorphism -/\nprotected instance pushout.inl_of_epi {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y}\n    {g : X ⟶ Z} [has_pushout f g] [epi g] : epi pushout.inl :=\n  epi.mk\n    fun (W : C) (u v : pushout f g ⟶ W) (h : pushout.inl ≫ u = pushout.inl ≫ v) =>\n      pushout.hom_ext h\n        (iff.mp (cancel_epi g)\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : X ⟶ W) (e_1 : a = a_1) (ᾰ ᾰ_1 : X ⟶ W) (e_2 : ᾰ = ᾰ_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (g ≫ pushout.inr ≫ u) (f ≫ pushout.inl ≫ v)\n                  (Eq.trans (Eq.symm (pushout.condition_assoc u))\n                    ((fun (ᾰ ᾰ_1 : X ⟶ Y) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : Y ⟶ W) (e_2 : ᾰ_2 = ᾰ_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      f f (Eq.refl f) (pushout.inl ≫ u) (pushout.inl ≫ v) h))\n                  (g ≫ pushout.inr ≫ v) (f ≫ pushout.inl ≫ v) (Eq.symm (pushout.condition_assoc v)))\n                (propext (eq_self_iff_true (f ≫ pushout.inl ≫ v)))))\n            trivial))\n\n/-- The pushout of an epimorphism is an epimorphism -/\nprotected instance pushout.inr_of_epi {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y}\n    {g : X ⟶ Z} [has_pushout f g] [epi f] : epi pushout.inr :=\n  epi.mk\n    fun (W : C) (u v : pushout f g ⟶ W) (h : pushout.inr ≫ u = pushout.inr ≫ v) =>\n      pushout.hom_ext\n        (iff.mp (cancel_epi f)\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : X ⟶ W) (e_1 : a = a_1) (ᾰ ᾰ_1 : X ⟶ W) (e_2 : ᾰ = ᾰ_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (f ≫ pushout.inl ≫ u) (g ≫ pushout.inr ≫ v)\n                  (Eq.trans (pushout.condition_assoc u)\n                    ((fun (ᾰ ᾰ_1 : X ⟶ Z) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : Z ⟶ W) (e_2 : ᾰ_2 = ᾰ_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      g g (Eq.refl g) (pushout.inr ≫ u) (pushout.inr ≫ v) h))\n                  (f ≫ pushout.inl ≫ v) (g ≫ pushout.inr ≫ v) (pushout.condition_assoc v))\n                (propext (eq_self_iff_true (g ≫ pushout.inr ≫ v)))))\n            trivial))\n        h\n\n/--\nThe comparison morphism for the pullback of `f,g`.\nThis is an isomorphism iff `G` preserves the pullback of `f,g`; see\n`category_theory/limits/preserves/shapes/pullbacks.lean`\n-/\ndef pullback_comparison {C : Type u} [category C] {X : C} {Y : C} {Z : C} {D : Type u₂} [category D]\n    (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] :\n    functor.obj G (pullback f g) ⟶ pullback (functor.map G f) (functor.map G g) :=\n  pullback.lift (functor.map G pullback.fst) (functor.map G pullback.snd) sorry\n\n@[simp] theorem pullback_comparison_comp_fst_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C}\n    {D : Type u₂} [category D] (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G X ⟶ X') :\n    pullback_comparison G f g ≫ pullback.fst ≫ f' = functor.map G pullback.fst ≫ f' :=\n  sorry\n\n@[simp] theorem pullback_comparison_comp_snd_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C}\n    {D : Type u₂} [category D] (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G Y ⟶ X') :\n    pullback_comparison G f g ≫ pullback.snd ≫ f' = functor.map G pullback.snd ≫ f' :=\n  sorry\n\n@[simp] theorem map_lift_pullback_comparison_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C}\n    {D : Type u₂} [category D] (G : C ⥤ D) (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] {W : C} {h : W ⟶ X} {k : W ⟶ Y}\n    (w : h ≫ f = k ≫ g) {X' : D} (f' : pullback (functor.map G f) (functor.map G g) ⟶ X') :\n    functor.map G (pullback.lift h k w) ≫ pullback_comparison G f g ≫ f' =\n        pullback.lift (functor.map G h) (functor.map G k)\n            (eq.mpr\n              (id\n                ((fun (a a_1 : functor.obj G W ⟶ functor.obj G Z) (e_1 : a = a_1)\n                    (ᾰ ᾰ_1 : functor.obj G W ⟶ functor.obj G Z) (e_2 : ᾰ = ᾰ_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (functor.map G h ≫ functor.map G f) (functor.map G (k ≫ g))\n                  (Eq.trans (Eq.symm (functor.map_comp G h f))\n                    ((fun (c : C ⥤ D) {X Y : C} (ᾰ ᾰ_1 : X ⟶ Y) (e_4 : ᾰ = ᾰ_1) =>\n                        congr_arg (functor.map c) e_4)\n                      G (h ≫ f) (k ≫ g) w))\n                  (functor.map G k ≫ functor.map G g) (functor.map G (k ≫ g))\n                  (Eq.symm (functor.map_comp G k g))))\n              (Eq.refl (functor.map G (k ≫ g)))) ≫\n          f' :=\n  sorry\n\n/--\n`has_pullbacks` represents a choice of pullback for every pair of morphisms\n\nSee https://stacks.math.columbia.edu/tag/001W.\n-/\ndef has_pullbacks (C : Type u) [category C] := has_limits_of_shape walking_cospan C\n\n/-- `has_pushouts` represents a choice of pushout for every pair of morphisms -/\ndef has_pushouts (C : Type u) [category C] := has_colimits_of_shape walking_span C\n\n/-- If `C` has all limits of diagrams `cospan f g`, then it has all pullbacks -/\ntheorem has_pullbacks_of_has_limit_cospan (C : Type u) [category C]\n    [∀ {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}, has_limit (cospan f g)] : has_pullbacks C :=\n  has_limits_of_shape.mk\n    fun (F : walking_cospan ⥤ C) => has_limit_of_iso (iso.symm (diagram_iso_cospan F))\n\n/-- If `C` has all colimits of diagrams `span f g`, then it has all pushouts -/\ntheorem has_pushouts_of_has_colimit_span (C : Type u) [category C]\n    [∀ {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z}, has_colimit (span f g)] : has_pushouts C :=\n  has_colimits_of_shape.mk fun (F : walking_span ⥤ C) => has_colimit_of_iso (diagram_iso_span F)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/shapes/pullbacks_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.4785329872477594}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module order.category.BddLat\n! leanprover-community/mathlib commit e8ac6315bcfcbaf2d19a046719c3b553206dac75\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Category.BddOrd\nimport Mathbin.Order.Category.Lat\nimport Mathbin.Order.Category.Semilat\n\n/-!\n# The category of bounded lattices\n\nThis file defines `BddLat`, the category of bounded lattices.\n\nIn literature, this is sometimes called `Lat`, the category of lattices, because being a lattice is\nunderstood to entail having a bottom and a top element.\n-/\n\n\nuniverse u\n\nopen CategoryTheory\n\n/-- The category of bounded lattices with bounded lattice morphisms. -/\nstructure BddLat where\n  toLat : Lat\n  [isBoundedOrder : BoundedOrder to_Lat]\n#align BddLat BddLat\n\nnamespace BddLat\n\ninstance : CoeSort BddLat (Type _) :=\n  ⟨fun X => X.toLat⟩\n\ninstance (X : BddLat) : Lattice X :=\n  X.toLat.str\n\nattribute [instance] BddLat.isBoundedOrder\n\n/-- Construct a bundled `BddLat` from `lattice` + `bounded_order`. -/\ndef of (α : Type _) [Lattice α] [BoundedOrder α] : BddLat :=\n  ⟨⟨α⟩⟩\n#align BddLat.of BddLat.of\n\n@[simp]\ntheorem coe_of (α : Type _) [Lattice α] [BoundedOrder α] : ↥(of α) = α :=\n  rfl\n#align BddLat.coe_of BddLat.coe_of\n\ninstance : Inhabited BddLat :=\n  ⟨of PUnit⟩\n\ninstance : LargeCategory.{u} BddLat\n    where\n  Hom X Y := BoundedLatticeHom X Y\n  id X := BoundedLatticeHom.id X\n  comp X Y Z f g := g.comp f\n  id_comp' X Y := BoundedLatticeHom.comp_id\n  comp_id' X Y := BoundedLatticeHom.id_comp\n  assoc' W X Y Z _ _ _ := BoundedLatticeHom.comp_assoc _ _ _\n\ninstance : ConcreteCategory BddLat\n    where\n  forget := ⟨coeSort, fun X Y => coeFn, fun X => rfl, fun X Y Z f g => rfl⟩\n  forget_faithful := ⟨fun X Y => by convert FunLike.coe_injective⟩\n\ninstance hasForgetToBddOrd : HasForget₂ BddLat BddOrd\n    where forget₂ :=\n    { obj := fun X => BddOrd.of X\n      map := fun X Y => BoundedLatticeHom.toBoundedOrderHom }\n#align BddLat.has_forget_to_BddOrd BddLat.hasForgetToBddOrd\n\ninstance hasForgetToLat : HasForget₂ BddLat Lat\n    where forget₂ :=\n    { obj := fun X => ⟨X⟩\n      map := fun X Y => BoundedLatticeHom.toLatticeHom }\n#align BddLat.has_forget_to_Lat BddLat.hasForgetToLat\n\ninstance hasForgetToSemilatSup : HasForget₂ BddLat SemilatSup\n    where forget₂ :=\n    { obj := fun X => ⟨X⟩\n      map := fun X Y => BoundedLatticeHom.toSupBotHom }\n#align BddLat.has_forget_to_SemilatSup BddLat.hasForgetToSemilatSup\n\ninstance hasForgetToSemilatInf : HasForget₂ BddLat SemilatInf\n    where forget₂ :=\n    { obj := fun X => ⟨X⟩\n      map := fun X Y => BoundedLatticeHom.toInfTopHom }\n#align BddLat.has_forget_to_SemilatInf BddLat.hasForgetToSemilatInf\n\n@[simp]\ntheorem coe_forget_to_bddOrd (X : BddLat) : ↥((forget₂ BddLat BddOrd).obj X) = ↥X :=\n  rfl\n#align BddLat.coe_forget_to_BddOrd BddLat.coe_forget_to_bddOrd\n\n@[simp]\ntheorem coe_forget_to_lat (X : BddLat) : ↥((forget₂ BddLat Lat).obj X) = ↥X :=\n  rfl\n#align BddLat.coe_forget_to_Lat BddLat.coe_forget_to_lat\n\n@[simp]\ntheorem coe_forget_to_semilatSup (X : BddLat) : ↥((forget₂ BddLat SemilatSup).obj X) = ↥X :=\n  rfl\n#align BddLat.coe_forget_to_SemilatSup BddLat.coe_forget_to_semilatSup\n\n@[simp]\ntheorem coe_forget_to_semilatInf (X : BddLat) : ↥((forget₂ BddLat SemilatInf).obj X) = ↥X :=\n  rfl\n#align BddLat.coe_forget_to_SemilatInf BddLat.coe_forget_to_semilatInf\n\ntheorem forget_lat_partOrd_eq_forget_bddOrd_partOrd :\n    forget₂ BddLat Lat ⋙ forget₂ Lat PartOrd = forget₂ BddLat BddOrd ⋙ forget₂ BddOrd PartOrd :=\n  rfl\n#align BddLat.forget_Lat_PartOrd_eq_forget_BddOrd_PartOrd BddLat.forget_lat_partOrd_eq_forget_bddOrd_partOrd\n\ntheorem forget_semilatSup_partOrd_eq_forget_bddOrd_partOrd :\n    forget₂ BddLat SemilatSup ⋙ forget₂ SemilatSup PartOrd =\n      forget₂ BddLat BddOrd ⋙ forget₂ BddOrd PartOrd :=\n  rfl\n#align BddLat.forget_SemilatSup_PartOrd_eq_forget_BddOrd_PartOrd BddLat.forget_semilatSup_partOrd_eq_forget_bddOrd_partOrd\n\ntheorem forget_semilatInf_partOrd_eq_forget_bddOrd_partOrd :\n    forget₂ BddLat SemilatInf ⋙ forget₂ SemilatInf PartOrd =\n      forget₂ BddLat BddOrd ⋙ forget₂ BddOrd PartOrd :=\n  rfl\n#align BddLat.forget_SemilatInf_PartOrd_eq_forget_BddOrd_PartOrd BddLat.forget_semilatInf_partOrd_eq_forget_bddOrd_partOrd\n\n/-- Constructs an equivalence between bounded lattices from an order isomorphism\nbetween them. -/\n@[simps]\ndef Iso.mk {α β : BddLat.{u}} (e : α ≃o β) : α ≅ β\n    where\n  Hom := e\n  inv := e.symm\n  hom_inv_id' := by\n    ext\n    exact e.symm_apply_apply _\n  inv_hom_id' := by\n    ext\n    exact e.apply_symm_apply _\n#align BddLat.iso.mk BddLat.Iso.mk\n\n/-- `order_dual` as a functor. -/\n@[simps]\ndef dual : BddLat ⥤ BddLat where\n  obj X := of Xᵒᵈ\n  map X Y := BoundedLatticeHom.dual\n#align BddLat.dual BddLat.dual\n\n/-- The equivalence between `BddLat` and itself induced by `order_dual` both ways. -/\n@[simps Functor inverse]\ndef dualEquiv : BddLat ≌ BddLat :=\n  Equivalence.mk dual dual\n    (NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun X Y f => rfl)\n    (NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun X Y f => rfl)\n#align BddLat.dual_equiv BddLat.dualEquiv\n\nend BddLat\n\ntheorem bddLat_dual_comp_forget_to_bddOrd :\n    BddLat.dual ⋙ forget₂ BddLat BddOrd = forget₂ BddLat BddOrd ⋙ BddOrd.dual :=\n  rfl\n#align BddLat_dual_comp_forget_to_BddOrd bddLat_dual_comp_forget_to_bddOrd\n\ntheorem bddLat_dual_comp_forget_to_lat :\n    BddLat.dual ⋙ forget₂ BddLat Lat = forget₂ BddLat Lat ⋙ Lat.dual :=\n  rfl\n#align BddLat_dual_comp_forget_to_Lat bddLat_dual_comp_forget_to_lat\n\ntheorem bddLat_dual_comp_forget_to_semilatSup :\n    BddLat.dual ⋙ forget₂ BddLat SemilatSup = forget₂ BddLat SemilatInf ⋙ SemilatInf.dual :=\n  rfl\n#align BddLat_dual_comp_forget_to_SemilatSup bddLat_dual_comp_forget_to_semilatSup\n\ntheorem bddLat_dual_comp_forget_to_semilatInf :\n    BddLat.dual ⋙ forget₂ BddLat SemilatInf = forget₂ BddLat SemilatSup ⋙ SemilatSup.dual :=\n  rfl\n#align BddLat_dual_comp_forget_to_SemilatInf bddLat_dual_comp_forget_to_semilatInf\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Category/BddLat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.47853298451686616}}
{"text": "import Kenny_comm_alg.ideal_lattice\n\nnoncomputable theory\nlocal attribute [instance] classical.prop_decidable\n\nuniverse u\n\nnamespace is_ideal\n\nsection minimal_prime_ideal\n\nparameters {α : Type u} [comm_ring α]\nparameters (I : set α) [hi : is_ideal I]\nparameters (P : set α) [hp : is_prime_ideal P]\nparameters (hip : I ⊆ P)\ninclude hi hp hip\n\nprivate theorem find_minimal_prime_ideal_aux :\n  ∃ (M : {S // I ⊆ S ∧ S ⊆ P ∧ is_prime_ideal S}), ∀ x, x ≤ M → x = M :=\n@@zorn.zorn' (order_dual {S // I ⊆ S ∧ S ⊆ P ∧ is_prime_ideal S})\n_\n⟨⟨P, hip, set.subset.refl P, hp⟩⟩ $\nλ c x hxc hc, ⟨⟨{y | ∀ S : {S // I ⊆ S ∧ S ⊆ P ∧ is_prime_ideal S}, S ∈ c → y ∈ S.val},\n  λ z hz S hsc, S.2.1 hz,\n  λ z hz, x.2.2.1 $ hz x hxc,\n  { zero_ := λ S hsc, @@is_ideal.zero _ S.1\n      S.2.2.2.to_is_proper_ideal.to_is_ideal,\n    add_ := λ x y hx hy S hsc, @@is_ideal.add _\n      S.2.2.2.to_is_proper_ideal.to_is_ideal\n      (hx S hsc) (hy S hsc),\n    smul := λ x y hy S hsc, @@is_ideal.mul_left _\n      S.2.2.2.to_is_proper_ideal.to_is_ideal\n      (hy S hsc),\n    ne_univ := λ h, @is_proper_ideal.ne_univ α _ x.1 x.2.2.2.1 $\n      @is_submodule.univ_of_one_mem α _ x.1 x.2.2.2.1.1.1 $\n      by rw set.eq_univ_iff_forall at h;\n      exact h 1 x hxc,\n    mem_or_mem_of_mul_mem := λ x y hxy,\n      or_iff_not_and_not.2 $ λ ⟨hx, hy⟩,\n      let ⟨Sx, hsx⟩ := not_forall.1 hx in\n      let ⟨hxc, hxs⟩ := not_imp.1 hsx in\n      let ⟨Sy, hsy⟩ := not_forall.1 hy in\n      let ⟨hyc, hys⟩ := not_imp.1 hsy in\n      or.cases_on (hc Sx Sy hxc hyc)\n        (λ hSxy, hxs $ hSxy $ or.resolve_right\n           (@@is_prime_ideal.mem_or_mem_of_mul_mem _ Sy.2.2.2 $ hxy Sy hyc)\n           hys)\n        (λ hSyx, hys $ hSyx $ or.resolve_left\n           (@@is_prime_ideal.mem_or_mem_of_mul_mem _ Sx.2.2.2 $ hxy Sx hxc)\n           hxs) }⟩,\nλ S hsc z hz, hz S hsc⟩\n\ndef find_minimal_prime_ideal : set α :=\n(classical.some find_minimal_prime_ideal_aux).1\n\ntheorem find_minimal_prime_ideal.ideal_contains : I ⊆ find_minimal_prime_ideal :=\n(classical.some find_minimal_prime_ideal_aux).2.1\n\ntheorem find_minimal_prime_ideal.contains_prime : find_minimal_prime_ideal ⊆ P :=\n(classical.some find_minimal_prime_ideal_aux).2.2.1\n\ndef find_minimal_prime_ideal.is_prime_ideal :\n  is_prime_ideal find_minimal_prime_ideal :=\n(classical.some find_minimal_prime_ideal_aux).2.2.2\n\ndef find_minimal_prime_ideal.minimal (S : set α) [hs : is_prime_ideal S]\n  (his : I ⊆ S) (hsm : S ⊆ find_minimal_prime_ideal) :\n  S = find_minimal_prime_ideal :=\ncongr_arg subtype.val $\nclassical.some_spec\n  find_minimal_prime_ideal_aux\n  ⟨S, his, set.subset.trans hsm find_minimal_prime_ideal.contains_prime, hs⟩ hsm\n\nprivate theorem find_minimal_prime_ideal_aux' :\n  ∃ (M : {S // I ⊆ S ∧ is_prime_ideal S}), ∀ x, x ≤ M → x = M :=\n@@zorn.zorn' (order_dual {S // I ⊆ S ∧ is_prime_ideal S})\n_\n⟨⟨P, hip, hp⟩⟩ $\nλ c x hxc hc, ⟨⟨{y | ∀ S : {S // I ⊆ S ∧ is_prime_ideal S}, S ∈ c → y ∈ S.val},\n  λ z hz S hsc, S.2.1 hz,\n  { zero_ := λ S hsc, @@is_ideal.zero _ S.1\n      S.2.2.to_is_proper_ideal.to_is_ideal,\n    add_ := λ x y hx hy S hsc, @@is_ideal.add _\n      S.2.2.to_is_proper_ideal.to_is_ideal\n      (hx S hsc) (hy S hsc),\n    smul := λ x y hy S hsc, @@is_ideal.mul_left _\n      S.2.2.to_is_proper_ideal.to_is_ideal\n      (hy S hsc),\n    ne_univ := λ h, @is_proper_ideal.ne_univ α _ x.1 x.2.2.1 $\n      @is_submodule.univ_of_one_mem α _ x.1 x.2.2.1.1.1 $\n      by rw set.eq_univ_iff_forall at h;\n      exact h 1 x hxc,\n    mem_or_mem_of_mul_mem := λ x y hxy,\n      or_iff_not_and_not.2 $ λ ⟨hx, hy⟩,\n      let ⟨Sx, hsx⟩ := not_forall.1 hx in\n      let ⟨hxc, hxs⟩ := not_imp.1 hsx in\n      let ⟨Sy, hsy⟩ := not_forall.1 hy in\n      let ⟨hyc, hys⟩ := not_imp.1 hsy in\n      or.cases_on (hc Sx Sy hxc hyc)\n        (λ hSxy, hxs $ hSxy $ or.resolve_right\n           (@@is_prime_ideal.mem_or_mem_of_mul_mem _ Sy.2.2 $ hxy Sy hyc)\n           hys)\n        (λ hSyx, hys $ hSyx $ or.resolve_left\n           (@@is_prime_ideal.mem_or_mem_of_mul_mem _ Sx.2.2 $ hxy Sx hxc)\n           hxs) }⟩,\nλ S hsc z hz, hz S hsc⟩\n\ndef find_minimal_prime_ideal' : set α :=\n(classical.some find_minimal_prime_ideal_aux').1\n\ntheorem find_minimal_prime_ideal'.ideal_contains : I ⊆ find_minimal_prime_ideal' :=\n(classical.some find_minimal_prime_ideal_aux').2.1\n\ndef find_minimal_prime_ideal'.is_prime_ideal :\n  is_prime_ideal find_minimal_prime_ideal' :=\n(classical.some find_minimal_prime_ideal_aux').2.2\n\ndef find_minimal_prime_ideal'.minimal (S : set α) [hs : is_prime_ideal S]\n  (his : I ⊆ S) (hsm : S ⊆ find_minimal_prime_ideal') :\n  S = find_minimal_prime_ideal' :=\ncongr_arg subtype.val $\nclassical.some_spec\n  find_minimal_prime_ideal_aux'\n  ⟨S, his, hs⟩ hsm\n\nend minimal_prime_ideal\n\nend is_ideal", "meta": {"author": "kbuzzard", "repo": "lean-stacks-project", "sha": "b57be17aa917f1c3a23c59db5ee37b1aa21112c2", "save_path": "github-repos/lean/kbuzzard-lean-stacks-project", "path": "github-repos/lean/kbuzzard-lean-stacks-project/lean-stacks-project-b57be17aa917f1c3a23c59db5ee37b1aa21112c2/src/Kenny_comm_alg/minimal_prime_ideal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.47850573700425797}}
{"text": "import cnf.literal\nimport cnf.assignment\nimport cnf.cnf\nimport cnf.encoding\n\nimport cardinality.direct_amo\nimport cardinality.sinz_amo\nimport cardinality.distinct\nimport cardinality.alk\nimport cardinality.amk\n\nimport data.nat.basic\nimport data.list.basic\nimport data.list.range\n\nimport logic.equiv.fin\n\nopen nat\nopen list\nopen function\nopen literal\nopen encoding\nopen clause cnf\nopen assignment\nopen alk amk distinct\nopen direct_amo\nopen sinz_amo\n\n@[derive decidable_eq]\nstructure graph := {n : ℕ} (p₁ : 0 < n) (p₂ : n < 5) (w : fin n → fin n → ℤ) (a : ∀ x y, w x y = - w y x) (u : ∀ a b c d, a ≠ b → w a b = w c d → (a = c ∧ b = d)) (id: ℕ)\n\n@[derive decidable_eq]\nstructure pointed_graph := (g : graph) (v : fin g.n)\n\ninstance pointed_graph_inhabited : inhabited pointed_graph := \n  inhabited.mk ⟨⟨nat.zero_lt_one, dec_trivial, λ x y, 0, dec_trivial, dec_trivial, 0⟩ , 0⟩\n\nstructure graph_embedding := (g₁ : graph) (g₂ : graph) (f : fin g₁.n → fin g₂.n) (x : fin g₂.n) (p : finset.univ \\ finset.image f finset.univ = {x}) (e : ∀ a b, g₁.w a b = g₂.w (f a) (f b))\n\ndef special1 (e : graph_embedding) (v : fin e.g₁.n) (p : e.g₂.w (e.f v) e.x ≠ 0) : graph := \n  ⟨zero_lt_two, dec_trivial,\n    ![![0, |e.g₂.w (e.f v) e.x|], ![-|e.g₂.w (e.f v) e.x|, 0]],\n      by simp [fin.forall_fin_two],\n      by simp [fin.forall_fin_two, p, eq_neg_self_iff, neg_eq_self_iff],\n      int.nat_abs (|e.g₂.w (e.f v) e.x|.div2 - 1)⟩\n\ndef special2 (e : graph_embedding) (v : fin e.g₁.n) : fin 2 := \n  (ite (e.g₂.w (e.f v) e.x > 0) 0 1)\n\ndef encoding (D : list graph) (E : list graph_embedding) : cnf pointed_graph := \n  -- at least one literal selected for each graph\n  (D.map (λ g: graph, list.of_fn (λ v, Pos ⟨g, v⟩))) ++ \n  -- at most one literal selected for each graph\n  join (D.map (λ g: graph, direct_amo (list.of_fn (λ v, Pos ⟨g, v⟩)))) ++\n  -- binary gamma for each embedding\n  join (E.map (λ e, (list.reduce_option (list.of_fn (λ v, (dite (e.g₂.w (e.f v) e.x = 0) (λ _, none) (λ _x, some [Neg ⟨special1 e v _x, special2 e v⟩, Neg ⟨e.g₁, v⟩, Pos ⟨e.g₂, e.f v⟩])))) )))\n\n--#eval (encoding [⟨1, nat.zero_lt_one, λ x y, 0⟩] nil)\n\ndef binary_gamma (E : list graph_embedding) (f : Π g : graph, fin g.n) := ∀ e : graph_embedding, e ∈ E → (∀ x : (e.g₂.w (e.f (f e.g₁)) e.x ≠ 0), (f (special1 e (f e.g₁) x)) = (special2 e (f e.g₁)) → (f e.g₂ = e.f (f e.g₁)))\n\nlemma lemma1 {n : ℕ} (a : ¬ n = 1) (b : ¬ n ≥ 2) : n = 0 := by omega\n\ntheorem encodes_binary_gamma : ∀ D E f, binary_gamma E f → (((encoding D E).eval (λ ⟨g, v⟩, f g = v)) = tt) := \nbegin\n  intros D E f bg,\n  rw eval_tt_iff_forall_clause_eval_tt,\n  intros cl hcl,\n  simp [encoding] at hcl,\n  rcases hcl with (⟨g, gd, h⟩ | ⟨g, gd, hcl⟩ | ⟨e, ee, h⟩),\n  {\n    subst h,\n    simp [eval_tt_iff_exists_literal_eval_tt, list.mem_of_fn],\n    use f g,\n    simp [literal.eval],\n  },\n  {\n    by_cases (length (list.of_fn (λ v, Pos (pointed_graph.mk g v)))) ≥ 2,\n    {\n      rcases exists_double_flip_eq_of_mem h hcl with ⟨lit₁, lit₂, rfl⟩,\n      rcases distinct_iff_mem.mpr hcl with ⟨i, j, hi, hj, hij, rfl, rfl⟩,\n      rw eval_tt_iff_exists_literal_eval_tt,\n      simp [eval_flip, literal.flip],\n      by_contradiction,\n      simp [literal.eval] at h,\n      cases h with h1 h2,\n      rw h1 at h2,\n      exact (eq.not_lt (fin.veq_of_eq h2)) hij,\n    },\n    let h2 := h,\n    by_cases (length (list.of_fn (λ v, Pos (pointed_graph.mk g v)))) = 1,\n    {\n      rw list.length_eq_one at h,\n      cases h with a h,\n      rw h at hcl,\n      rw direct_amo_singleton at hcl,\n      exfalso,\n      exact list.not_mem_nil cl hcl,\n    },\n    let h3 := lemma1 h h2,\n    {\n      rw list.length_eq_zero at h3,\n      rw h3 at hcl,\n      rw direct_amo_nil at hcl,\n      exfalso,\n      exact list.not_mem_nil cl hcl,\n    },\n  },\n  {\n    rw list.reduce_option_mem_iff at h,\n    rw list.mem_of_fn at h,\n    rw set.mem_range at h,\n    cases h with y h2,\n    by_cases (e.g₂.w (e.f y) e.x = 0),\n    rw dite_eq_left_iff.mpr (λ nP, by_contra (λ _, nP h)) at h2,\n    simp at h2,\n    exfalso,\n    exact h2,\n    change (dite (e.g₂.w (e.f y) e.x = 0) (λ _, none) (λ (_x : ¬e.g₂.w (e.f y) e.x = 0), some [Neg (pointed_graph.mk (special1 e y h) (special2 e y)), Neg ⟨e.g₁, y⟩, Pos ⟨e.g₂, e.f y⟩])) = some cl at h2,\n    \n    rw dite_eq_right_iff.mpr (λ P, by_contra (λ _, h P)) at h2,\n    simp at h2,\n    let h3 := h,\n\n    subst h2,\n    simp [eval_tt_iff_exists_literal_eval_tt],\n    simp [literal.eval],\n    \n    apply not_or_of_imp,\n    intro sp,\n    apply not_or_of_imp,\n    intro veq,\n\n\n    \n    unfold binary_gamma at bg,\n    rw <-veq at h,\n    specialize bg e ee,\n    rw veq at bg,\n    rw veq at h,\n    specialize bg h,\n    specialize bg sp,\n    exact bg,\n  }\nend", "meta": {"author": "chasenorman", "repo": "verified-encodings-social-choice", "sha": "72f88c5a31ce30df5a04a99f726244c327b9a6f6", "save_path": "github-repos/lean/chasenorman-verified-encodings-social-choice", "path": "github-repos/lean/chasenorman-verified-encodings-social-choice/verified-encodings-social-choice-72f88c5a31ce30df5a04a99f726244c327b9a6f6/src/demos/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744673038222, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.47836376446655826}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# modular equivalence for submodule\n-/\n\n/-- A predicate saying two elements of a module are equivalent modulo a submodule. -/\ndef smodeq {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] (U : submodule R M) (x : M) (y : M) :=\n  submodule.quotient.mk x = submodule.quotient.mk y\n\nprotected theorem smodeq.def {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x : M} {y : M} : smodeq U x y ↔ submodule.quotient.mk x = submodule.quotient.mk y :=\n  iff.rfl\n\nnamespace smodeq\n\n\n@[simp] theorem top {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {x : M} {y : M} : smodeq ⊤ x y :=\n  iff.mpr (submodule.quotient.eq ⊤) submodule.mem_top\n\n@[simp] theorem bot {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {x : M} {y : M} : smodeq ⊥ x y ↔ x = y := sorry\n\ntheorem mono {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U₁ : submodule R M} {U₂ : submodule R M} {x : M} {y : M} (HU : U₁ ≤ U₂) (hxy : smodeq U₁ x y) : smodeq U₂ x y :=\n  iff.mpr (submodule.quotient.eq U₂) (HU (iff.mp (submodule.quotient.eq U₁) hxy))\n\ntheorem refl {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x : M} : smodeq U x x :=\n  Eq.refl (submodule.quotient.mk x)\n\ntheorem symm {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x : M} {y : M} (hxy : smodeq U x y) : smodeq U y x :=\n  Eq.symm hxy\n\ntheorem trans {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x : M} {y : M} {z : M} (hxy : smodeq U x y) (hyz : smodeq U y z) : smodeq U x z :=\n  Eq.trans hxy hyz\n\ntheorem add {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x₁ : M} {x₂ : M} {y₁ : M} {y₂ : M} (hxy₁ : smodeq U x₁ y₁) (hxy₂ : smodeq U x₂ y₂) : smodeq U (x₁ + x₂) (y₁ + y₂) := sorry\n\ntheorem smul {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x : M} {y : M} (hxy : smodeq U x y) (c : R) : smodeq U (c • x) (c • y) := sorry\n\ntheorem zero {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x : M} : smodeq U x 0 ↔ x ∈ U := sorry\n\ntheorem map {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U : submodule R M} {x : M} {y : M} {N : Type u_3} [add_comm_group N] [module R N] (hxy : smodeq U x y) (f : linear_map R M N) : smodeq (submodule.map f U) (coe_fn f x) (coe_fn f y) :=\n  iff.mpr (submodule.quotient.eq (submodule.map f U))\n    (Eq.subst (linear_map.map_sub f x y) submodule.mem_map_of_mem (iff.mp (submodule.quotient.eq U) hxy))\n\ntheorem comap {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {x : M} {y : M} {N : Type u_3} [add_comm_group N] [module R N] (V : submodule R N) {f : linear_map R M N} (hxy : smodeq V (coe_fn f x) (coe_fn f y)) : smodeq (submodule.comap f V) x y :=\n  iff.mpr (submodule.quotient.eq (submodule.comap f V))\n    ((fun (this : coe_fn f (x - y) ∈ V) => this)\n      (Eq.symm (linear_map.map_sub f x y) ▸ iff.mp (submodule.quotient.eq V) hxy))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/smodeq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6513548714339144, "lm_q1q2_score": 0.4781723300611948}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport analysis.specific_limits.basic\nimport topology.metric_space.isometry\nimport topology.instances.ennreal\n\n/-!\n# Hausdorff distance\n\nThe Hausdorff distance on subsets of a metric (or emetric) space.\n\nGiven two subsets `s` and `t` of a metric space, their Hausdorff distance is the smallest `d`\nsuch that any point `s` is within `d` of a point in `t`, and conversely. This quantity\nis often infinite (think of `s` bounded and `t` unbounded), and therefore better\nexpressed in the setting of emetric spaces.\n\n## Main definitions\n\nThis files introduces:\n* `inf_edist x s`, the infimum edistance of a point `x` to a set `s` in an emetric space\n* `Hausdorff_edist s t`, the Hausdorff edistance of two sets in an emetric space\n* Versions of these notions on metric spaces, called respectively `inf_dist` and `Hausdorff_dist`\n* `thickening δ s`, the open thickening by radius `δ` of a set `s` in a pseudo emetric space.\n* `cthickening δ s`, the closed thickening by radius `δ` of a set `s` in a pseudo emetric space.\n-/\nnoncomputable theory\nopen_locale classical nnreal ennreal topological_space\nuniverses u v w\n\nopen classical set function topological_space filter\n\nnamespace emetric\n\nsection inf_edist\n\nvariables {α : Type u} {β : Type v} [pseudo_emetric_space α] [pseudo_emetric_space β] {x y : α}\n{s t : set α} {Φ : α → β}\n\n/-! ### Distance of a point to a set as a function into `ℝ≥0∞`. -/\n\n/-- The minimal edistance of a point to a set -/\ndef inf_edist (x : α) (s : set α) : ℝ≥0∞ := ⨅ y ∈ s, edist x y\n\n@[simp] lemma inf_edist_empty : inf_edist x ∅ = ∞ := infi_emptyset\n\nlemma le_inf_edist {d} : d ≤ inf_edist x s ↔ ∀ y ∈ s, d ≤ edist x y :=\nby simp only [inf_edist, le_infi_iff]\n\n/-- The edist to a union is the minimum of the edists -/\n@[simp] lemma inf_edist_union : inf_edist x (s ∪ t) = inf_edist x s ⊓ inf_edist x t :=\ninfi_union\n\n/-- The edist to a singleton is the edistance to the single point of this singleton -/\n@[simp] lemma inf_edist_singleton : inf_edist x {y} = edist x y :=\ninfi_singleton\n\n/-- The edist to a set is bounded above by the edist to any of its points -/\nlemma inf_edist_le_edist_of_mem (h : y ∈ s) : inf_edist x s ≤ edist x y := infi₂_le _ h\n\n/-- If a point `x` belongs to `s`, then its edist to `s` vanishes -/\nlemma inf_edist_zero_of_mem (h : x ∈ s) : inf_edist x s = 0 :=\nnonpos_iff_eq_zero.1 $ @edist_self _ _ x ▸ inf_edist_le_edist_of_mem h\n\n/-- The edist is monotonous with respect to inclusion -/\nlemma inf_edist_le_inf_edist_of_subset (h : s ⊆ t) : inf_edist x t ≤ inf_edist x s :=\ninfi_le_infi_of_subset h\n\n/-- The edist to a set is `< r` iff there exists a point in the set at edistance `< r` -/\nlemma inf_edist_lt_iff {r : ℝ≥0∞} : inf_edist x s < r ↔ ∃ y ∈ s, edist x y < r :=\nby simp_rw [inf_edist, infi_lt_iff]\n\n/-- The edist of `x` to `s` is bounded by the sum of the edist of `y` to `s` and\nthe edist from `x` to `y` -/\nlemma inf_edist_le_inf_edist_add_edist : inf_edist x s ≤ inf_edist y s + edist x y :=\ncalc (⨅ z ∈ s, edist x z) ≤ ⨅ z ∈ s, edist y z + edist x y :\n  infi₂_mono $ λ z hz, (edist_triangle _ _ _).trans_eq (add_comm _ _)\n... = (⨅ z ∈ s, edist y z) + edist x y : by simp only [ennreal.infi_add]\n\n/-- The edist to a set depends continuously on the point -/\n@[continuity]\nlemma continuous_inf_edist : continuous (λx, inf_edist x s) :=\ncontinuous_of_le_add_edist 1 (by simp) $\n  by simp only [one_mul, inf_edist_le_inf_edist_add_edist, forall_2_true_iff]\n\n/-- The edist to a set and to its closure coincide -/\nlemma inf_edist_closure : inf_edist x (closure s) = inf_edist x s :=\nbegin\n  refine le_antisymm (inf_edist_le_inf_edist_of_subset subset_closure) _,\n  refine ennreal.le_of_forall_pos_le_add (λε εpos h, _),\n  have ε0 : 0 < (ε / 2 : ℝ≥0∞) := by simpa [pos_iff_ne_zero] using εpos,\n  have : inf_edist x (closure s) < inf_edist x (closure s) + ε/2,\n    from ennreal.lt_add_right h.ne ε0.ne',\n  rcases inf_edist_lt_iff.mp this with ⟨y, ycs, hy⟩,\n  -- y : α,  ycs : y ∈ closure s,  hy : edist x y < inf_edist x (closure s) + ↑ε / 2\n  rcases emetric.mem_closure_iff.1 ycs (ε/2) ε0 with ⟨z, zs, dyz⟩,\n  -- z : α,  zs : z ∈ s,  dyz : edist y z < ↑ε / 2\n  calc inf_edist x s ≤ edist x z : inf_edist_le_edist_of_mem zs\n        ... ≤ edist x y + edist y z : edist_triangle _ _ _\n        ... ≤ (inf_edist x (closure s) + ε / 2) + (ε/2) : add_le_add (le_of_lt hy) (le_of_lt dyz)\n        ... = inf_edist x (closure s) + ↑ε : by rw [add_assoc, ennreal.add_halves]\nend\n\n/-- A point belongs to the closure of `s` iff its infimum edistance to this set vanishes -/\nlemma mem_closure_iff_inf_edist_zero : x ∈ closure s ↔ inf_edist x s = 0 :=\n⟨λ h, by { rw ← inf_edist_closure, exact inf_edist_zero_of_mem h },\nλ h, emetric.mem_closure_iff.2 $ λ ε εpos, inf_edist_lt_iff.mp $ by rwa h⟩\n\n/-- Given a closed set `s`, a point belongs to `s` iff its infimum edistance to this set vanishes -/\nlemma mem_iff_inf_edist_zero_of_closed (h : is_closed s) : x ∈ s ↔ inf_edist x s = 0 :=\nbegin\n  convert ← mem_closure_iff_inf_edist_zero,\n  exact h.closure_eq\nend\n\nlemma disjoint_closed_ball_of_lt_inf_edist {r : ℝ≥0∞} (h : r < inf_edist x s) :\n  disjoint (closed_ball x r) s :=\nbegin\n  rw disjoint_left,\n  assume y hy h'y,\n  apply lt_irrefl (inf_edist x s),\n  calc inf_edist x s ≤ edist x y : inf_edist_le_edist_of_mem h'y\n  ... ≤ r : by rwa [mem_closed_ball, edist_comm] at hy\n  ... < inf_edist x s : h\nend\n\n/-- The infimum edistance is invariant under isometries -/\nlemma inf_edist_image (hΦ : isometry Φ) :\n  inf_edist (Φ x) (Φ '' t) = inf_edist x t :=\nby simp only [inf_edist, infi_image, hΦ.edist_eq]\n\nlemma _root_.is_open.exists_Union_is_closed {U : set α} (hU : is_open U) :\n  ∃ F : ℕ → set α, (∀ n, is_closed (F n)) ∧ (∀ n, F n ⊆ U) ∧ ((⋃ n, F n) = U) ∧ monotone F :=\nbegin\n  obtain ⟨a, a_pos, a_lt_one⟩ : ∃ (a : ℝ≥0∞), 0 < a ∧ a < 1 := exists_between (ennreal.zero_lt_one),\n  let F := λ (n : ℕ), (λ x, inf_edist x Uᶜ) ⁻¹' (Ici (a^n)),\n  have F_subset : ∀ n, F n ⊆ U,\n  { assume n x hx,\n    have : inf_edist x Uᶜ ≠ 0 := ((ennreal.pow_pos a_pos _).trans_le hx).ne',\n    contrapose! this,\n    exact inf_edist_zero_of_mem this },\n  refine ⟨F, λ n, is_closed.preimage continuous_inf_edist is_closed_Ici, F_subset, _, _⟩,\n  show monotone F,\n  { assume m n hmn x hx,\n    simp only [mem_Ici, mem_preimage] at hx ⊢,\n    apply le_trans (ennreal.pow_le_pow_of_le_one a_lt_one.le hmn) hx },\n  show (⋃ n, F n) = U,\n  { refine subset.antisymm (by simp only [Union_subset_iff, F_subset, forall_const]) (λ x hx, _),\n    have : ¬(x ∈ Uᶜ), by simpa using hx,\n    rw mem_iff_inf_edist_zero_of_closed hU.is_closed_compl at this,\n    have B : 0 < inf_edist x Uᶜ, by simpa [pos_iff_ne_zero] using this,\n    have : filter.tendsto (λ n, a^n) at_top (𝓝 0) :=\n      ennreal.tendsto_pow_at_top_nhds_0_of_lt_1 a_lt_one,\n    rcases ((tendsto_order.1 this).2 _ B).exists with ⟨n, hn⟩,\n    simp only [mem_Union, mem_Ici, mem_preimage],\n    exact ⟨n, hn.le⟩ },\nend\n\nlemma _root_.is_compact.exists_inf_edist_eq_edist (hs : is_compact s) (hne : s.nonempty) (x : α) :\n  ∃ y ∈ s, inf_edist x s = edist x y :=\nbegin\n  have A : continuous (λ y, edist x y) := continuous_const.edist continuous_id,\n  obtain ⟨y, ys, hy⟩ : ∃ y ∈ s, ∀ z, z ∈ s → edist x y ≤ edist x z :=\n    hs.exists_forall_le hne A.continuous_on,\n  exact ⟨y, ys, le_antisymm (inf_edist_le_edist_of_mem ys) (by rwa le_inf_edist)⟩\nend\n\nend inf_edist --section\n\n/-! ### The Hausdorff distance as a function into `ℝ≥0∞`. -/\n\n/-- The Hausdorff edistance between two sets is the smallest `r` such that each set\nis contained in the `r`-neighborhood of the other one -/\n@[irreducible] def Hausdorff_edist {α : Type u} [pseudo_emetric_space α] (s t : set α) : ℝ≥0∞ :=\n(⨆ x ∈ s, inf_edist x t) ⊔ (⨆ y ∈ t, inf_edist y s)\n\nlemma Hausdorff_edist_def {α : Type u} [pseudo_emetric_space α] (s t : set α) :\n  Hausdorff_edist s t = (⨆ x ∈ s, inf_edist x t) ⊔ (⨆ y ∈ t, inf_edist y s) :=\nby rw Hausdorff_edist\n\nsection Hausdorff_edist\n\nvariables {α : Type u} {β : Type v} [pseudo_emetric_space α] [pseudo_emetric_space β]\n          {x y : α} {s t u : set α} {Φ : α → β}\n\n/-- The Hausdorff edistance of a set to itself vanishes -/\n@[simp] lemma Hausdorff_edist_self : Hausdorff_edist s s = 0 :=\nbegin\n  simp only [Hausdorff_edist_def, sup_idem, ennreal.supr_eq_zero],\n  exact λ x hx, inf_edist_zero_of_mem hx\nend\n\n/-- The Haudorff edistances of `s` to `t` and of `t` to `s` coincide -/\nlemma Hausdorff_edist_comm : Hausdorff_edist s t = Hausdorff_edist t s :=\nby unfold Hausdorff_edist; apply sup_comm\n\n/-- Bounding the Hausdorff edistance by bounding the edistance of any point\nin each set to the other set -/\nlemma Hausdorff_edist_le_of_inf_edist {r : ℝ≥0∞}\n  (H1 : ∀x ∈ s, inf_edist x t ≤ r) (H2 : ∀x ∈ t, inf_edist x s ≤ r) :\n  Hausdorff_edist s t ≤ r :=\nbegin\n  simp only [Hausdorff_edist, sup_le_iff, supr_le_iff],\n  exact ⟨H1, H2⟩\nend\n\n/-- Bounding the Hausdorff edistance by exhibiting, for any point in each set,\nanother point in the other set at controlled distance -/\nlemma Hausdorff_edist_le_of_mem_edist {r : ℝ≥0∞}\n  (H1 : ∀x ∈ s, ∃y ∈ t, edist x y ≤ r) (H2 : ∀x ∈ t, ∃y ∈ s, edist x y ≤ r) :\n  Hausdorff_edist s t ≤ r :=\nbegin\n  refine Hausdorff_edist_le_of_inf_edist _ _,\n  { assume x xs,\n    rcases H1 x xs with ⟨y, yt, hy⟩,\n    exact le_trans (inf_edist_le_edist_of_mem yt) hy },\n  { assume x xt,\n    rcases H2 x xt with ⟨y, ys, hy⟩,\n    exact le_trans (inf_edist_le_edist_of_mem ys) hy }\nend\n\n/-- The distance to a set is controlled by the Hausdorff distance -/\nlemma inf_edist_le_Hausdorff_edist_of_mem (h : x ∈ s) : inf_edist x t ≤ Hausdorff_edist s t :=\nbegin\n  rw Hausdorff_edist_def,\n  refine le_trans _ le_sup_left,\n  exact le_supr₂ x h\nend\n\n/-- If the Hausdorff distance is `<r`, then any point in one of the sets has\na corresponding point at distance `<r` in the other set -/\nlemma exists_edist_lt_of_Hausdorff_edist_lt {r : ℝ≥0∞} (h : x ∈ s)\n  (H : Hausdorff_edist s t < r) : ∃ y ∈ t, edist x y < r :=\ninf_edist_lt_iff.mp $ calc\n  inf_edist x t ≤ Hausdorff_edist s t : inf_edist_le_Hausdorff_edist_of_mem h\n  ... < r : H\n\n/-- The distance from `x` to `s` or `t` is controlled in terms of the Hausdorff distance\nbetween `s` and `t` -/\nlemma inf_edist_le_inf_edist_add_Hausdorff_edist :\n  inf_edist x t ≤ inf_edist x s + Hausdorff_edist s t :=\nennreal.le_of_forall_pos_le_add $ λε εpos h, begin\n  have ε0 : (ε / 2 : ℝ≥0∞) ≠ 0 := by simpa [pos_iff_ne_zero] using εpos,\n  have : inf_edist x s < inf_edist x s + ε/2 :=\n    ennreal.lt_add_right (ennreal.add_lt_top.1 h).1.ne ε0,\n  rcases inf_edist_lt_iff.mp this with ⟨y, ys, dxy⟩,\n  -- y : α,  ys : y ∈ s,  dxy : edist x y < inf_edist x s + ↑ε / 2\n  have : Hausdorff_edist s t < Hausdorff_edist s t + ε/2 :=\n    ennreal.lt_add_right (ennreal.add_lt_top.1 h).2.ne ε0,\n  rcases exists_edist_lt_of_Hausdorff_edist_lt ys this with ⟨z, zt, dyz⟩,\n  -- z : α,  zt : z ∈ t,  dyz : edist y z < Hausdorff_edist s t + ↑ε / 2\n  calc inf_edist x t ≤ edist x z : inf_edist_le_edist_of_mem zt\n    ... ≤ edist x y + edist y z : edist_triangle _ _ _\n    ... ≤ (inf_edist x s + ε/2) + (Hausdorff_edist s t + ε/2) : add_le_add dxy.le dyz.le\n    ... = inf_edist x s + Hausdorff_edist s t + ε :\n      by simp [ennreal.add_halves, add_comm, add_left_comm]\nend\n\n/-- The Hausdorff edistance is invariant under eisometries -/\nlemma Hausdorff_edist_image (h : isometry Φ) :\n  Hausdorff_edist (Φ '' s) (Φ '' t) = Hausdorff_edist s t :=\nby simp only [Hausdorff_edist_def, supr_image, inf_edist_image h]\n\n/-- The Hausdorff distance is controlled by the diameter of the union -/\nlemma Hausdorff_edist_le_ediam (hs : s.nonempty) (ht : t.nonempty) :\n  Hausdorff_edist s t ≤ diam (s ∪ t) :=\nbegin\n  rcases hs with ⟨x, xs⟩,\n  rcases ht with ⟨y, yt⟩,\n  refine Hausdorff_edist_le_of_mem_edist _ _,\n  { intros z hz,\n    exact ⟨y, yt, edist_le_diam_of_mem (subset_union_left _ _ hz) (subset_union_right _ _ yt)⟩ },\n  { intros z hz,\n    exact ⟨x, xs, edist_le_diam_of_mem (subset_union_right _ _ hz) (subset_union_left _ _ xs)⟩ }\nend\n\n/-- The Hausdorff distance satisfies the triangular inequality -/\nlemma Hausdorff_edist_triangle : Hausdorff_edist s u ≤ Hausdorff_edist s t + Hausdorff_edist t u :=\nbegin\n  rw Hausdorff_edist_def,\n  simp only [sup_le_iff, supr_le_iff],\n  split,\n  show ∀x ∈ s, inf_edist x u ≤ Hausdorff_edist s t + Hausdorff_edist t u, from λx xs, calc\n    inf_edist x u ≤ inf_edist x t + Hausdorff_edist t u : inf_edist_le_inf_edist_add_Hausdorff_edist\n    ... ≤ Hausdorff_edist s t + Hausdorff_edist t u :\n      add_le_add_right (inf_edist_le_Hausdorff_edist_of_mem  xs) _,\n  show ∀x ∈ u, inf_edist x s ≤ Hausdorff_edist s t + Hausdorff_edist t u, from λx xu, calc\n    inf_edist x s ≤ inf_edist x t + Hausdorff_edist t s : inf_edist_le_inf_edist_add_Hausdorff_edist\n    ... ≤ Hausdorff_edist u t + Hausdorff_edist t s :\n      add_le_add_right (inf_edist_le_Hausdorff_edist_of_mem xu) _\n    ... = Hausdorff_edist s t + Hausdorff_edist t u : by simp [Hausdorff_edist_comm, add_comm]\nend\n\n/-- Two sets are at zero Hausdorff edistance if and only if they have the same closure -/\nlemma Hausdorff_edist_zero_iff_closure_eq_closure :\n  Hausdorff_edist s t = 0 ↔ closure s = closure t :=\ncalc Hausdorff_edist s t = 0 ↔ s ⊆ closure t ∧ t ⊆ closure s :\n  by simp only [Hausdorff_edist_def, ennreal.sup_eq_zero, ennreal.supr_eq_zero,\n    ← mem_closure_iff_inf_edist_zero, subset_def]\n... ↔ closure s = closure t :\n  ⟨λ h, subset.antisymm (closure_minimal h.1 is_closed_closure)\n     (closure_minimal h.2 is_closed_closure),\n   λ h, ⟨h ▸ subset_closure, h.symm ▸ subset_closure⟩⟩\n\n/-- The Hausdorff edistance between a set and its closure vanishes -/\n@[simp, priority 1100]\nlemma Hausdorff_edist_self_closure : Hausdorff_edist s (closure s) = 0 :=\nby rw [Hausdorff_edist_zero_iff_closure_eq_closure, closure_closure]\n\n/-- Replacing a set by its closure does not change the Hausdorff edistance. -/\n@[simp] lemma Hausdorff_edist_closure₁ : Hausdorff_edist (closure s) t = Hausdorff_edist s t :=\nbegin\n  refine le_antisymm _ _,\n  { calc  _ ≤ Hausdorff_edist (closure s) s + Hausdorff_edist s t : Hausdorff_edist_triangle\n    ... = Hausdorff_edist s t : by simp [Hausdorff_edist_comm] },\n  { calc _ ≤ Hausdorff_edist s (closure s) + Hausdorff_edist (closure s) t :\n      Hausdorff_edist_triangle\n    ... = Hausdorff_edist (closure s) t : by simp }\nend\n\n/-- Replacing a set by its closure does not change the Hausdorff edistance. -/\n@[simp] lemma Hausdorff_edist_closure₂ : Hausdorff_edist s (closure t) = Hausdorff_edist s t :=\nby simp [@Hausdorff_edist_comm _ _ s _]\n\n/-- The Hausdorff edistance between sets or their closures is the same -/\n@[simp] lemma Hausdorff_edist_closure :\n  Hausdorff_edist (closure s) (closure t) = Hausdorff_edist s t :=\nby simp\n\n/-- Two closed sets are at zero Hausdorff edistance if and only if they coincide -/\nlemma Hausdorff_edist_zero_iff_eq_of_closed (hs : is_closed s) (ht : is_closed t) :\n  Hausdorff_edist s t = 0 ↔ s = t :=\nby rw [Hausdorff_edist_zero_iff_closure_eq_closure, hs.closure_eq, ht.closure_eq]\n\n/-- The Haudorff edistance to the empty set is infinite -/\nlemma Hausdorff_edist_empty (ne : s.nonempty) : Hausdorff_edist s ∅ = ∞ :=\nbegin\n  rcases ne with ⟨x, xs⟩,\n  have : inf_edist x ∅ ≤ Hausdorff_edist s ∅ := inf_edist_le_Hausdorff_edist_of_mem xs,\n  simpa using this,\nend\n\n/-- If a set is at finite Hausdorff edistance of a nonempty set, it is nonempty -/\nlemma nonempty_of_Hausdorff_edist_ne_top (hs : s.nonempty) (fin : Hausdorff_edist s t ≠ ⊤) :\n  t.nonempty :=\nt.eq_empty_or_nonempty.elim (λ ht, (fin $ ht.symm ▸ Hausdorff_edist_empty hs).elim) id\n\nlemma empty_or_nonempty_of_Hausdorff_edist_ne_top (fin : Hausdorff_edist s t ≠ ⊤) :\n  s = ∅ ∧ t = ∅ ∨ s.nonempty ∧ t.nonempty :=\nbegin\n  cases s.eq_empty_or_nonempty with hs hs,\n  { cases t.eq_empty_or_nonempty with ht ht,\n    { exact or.inl ⟨hs, ht⟩ },\n    { rw Hausdorff_edist_comm at fin,\n      exact or.inr ⟨nonempty_of_Hausdorff_edist_ne_top ht fin, ht⟩ } },\n  { exact or.inr ⟨hs, nonempty_of_Hausdorff_edist_ne_top hs fin⟩ }\nend\n\nend Hausdorff_edist -- section\nend emetric --namespace\n\n\n/-! Now, we turn to the same notions in metric spaces. To avoid the difficulties related to\n`Inf` and `Sup` on `ℝ` (which is only conditionally complete), we use the notions in `ℝ≥0∞`\nformulated in terms of the edistance, and coerce them to `ℝ`.\nThen their properties follow readily from the corresponding properties in `ℝ≥0∞`,\nmodulo some tedious rewriting of inequalities from one to the other. -/\n\nnamespace metric\nsection\nvariables {α : Type u} {β : Type v} [pseudo_metric_space α] [pseudo_metric_space β]\n  {s t u : set α} {x y : α} {Φ : α → β}\nopen emetric\n\n/-! ### Distance of a point to a set as a function into `ℝ`. -/\n\n/-- The minimal distance of a point to a set -/\ndef inf_dist (x : α) (s : set α) : ℝ := ennreal.to_real (inf_edist x s)\n\n/-- the minimal distance is always nonnegative -/\nlemma inf_dist_nonneg : 0 ≤ inf_dist x s := by simp [inf_dist]\n\n/-- the minimal distance to the empty set is 0 (if you want to have the more reasonable\nvalue ∞ instead, use `inf_edist`, which takes values in ℝ≥0∞) -/\n@[simp] lemma inf_dist_empty : inf_dist x ∅ = 0 :=\nby simp [inf_dist]\n\n/-- In a metric space, the minimal edistance to a nonempty set is finite -/\nlemma inf_edist_ne_top (h : s.nonempty) : inf_edist x s ≠ ⊤ :=\nbegin\n  rcases h with ⟨y, hy⟩,\n  apply lt_top_iff_ne_top.1,\n  calc inf_edist x s ≤ edist x y : inf_edist_le_edist_of_mem hy\n       ... < ⊤ : lt_top_iff_ne_top.2 (edist_ne_top _ _)\nend\n\n/-- The minimal distance of a point to a set containing it vanishes -/\nlemma inf_dist_zero_of_mem (h : x ∈ s) : inf_dist x s = 0 :=\nby simp [inf_edist_zero_of_mem h, inf_dist]\n\n/-- The minimal distance to a singleton is the distance to the unique point in this singleton -/\n@[simp] lemma inf_dist_singleton : inf_dist x {y} = dist x y :=\nby simp [inf_dist, inf_edist, dist_edist]\n\n/-- The minimal distance to a set is bounded by the distance to any point in this set -/\nlemma inf_dist_le_dist_of_mem (h : y ∈ s) : inf_dist x s ≤ dist x y :=\nbegin\n  rw [dist_edist, inf_dist,\n    ennreal.to_real_le_to_real (inf_edist_ne_top ⟨_, h⟩) (edist_ne_top _ _)],\n  exact inf_edist_le_edist_of_mem h\nend\n\n/-- The minimal distance is monotonous with respect to inclusion -/\nlemma inf_dist_le_inf_dist_of_subset (h : s ⊆ t) (hs : s.nonempty) :\n  inf_dist x t ≤ inf_dist x s :=\nbegin\n  have ht : t.nonempty := hs.mono h,\n  rw [inf_dist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ht) (inf_edist_ne_top hs)],\n  exact inf_edist_le_inf_edist_of_subset h\nend\n\n/-- The minimal distance to a set is `< r` iff there exists a point in this set at distance `< r` -/\nlemma inf_dist_lt_iff {r : ℝ} (hs : s.nonempty) :\n  inf_dist x s < r ↔ ∃ y ∈ s, dist x y < r :=\nby simp_rw [inf_dist, ← ennreal.lt_of_real_iff_to_real_lt (inf_edist_ne_top hs), inf_edist_lt_iff,\n    ennreal.lt_of_real_iff_to_real_lt (edist_ne_top _ _), ← dist_edist]\n\n/-- The minimal distance from `x` to `s` is bounded by the distance from `y` to `s`, modulo\nthe distance between `x` and `y` -/\nlemma inf_dist_le_inf_dist_add_dist : inf_dist x s ≤ inf_dist y s + dist x y :=\nbegin\n  cases s.eq_empty_or_nonempty with hs hs,\n  { simp [hs, dist_nonneg] },\n  { rw [inf_dist, inf_dist, dist_edist,\n        ← ennreal.to_real_add (inf_edist_ne_top hs) (edist_ne_top _ _),\n        ennreal.to_real_le_to_real (inf_edist_ne_top hs)],\n    { exact inf_edist_le_inf_edist_add_edist },\n    { simp [ennreal.add_eq_top, inf_edist_ne_top hs, edist_ne_top] }}\nend\n\nlemma not_mem_of_dist_lt_inf_dist (h : dist x y < inf_dist x s) : y ∉ s :=\nλ hy, h.not_le $ inf_dist_le_dist_of_mem hy\n\nlemma disjoint_ball_inf_dist : disjoint (ball x (inf_dist x s)) s :=\ndisjoint_left.2 $ λ y hy, not_mem_of_dist_lt_inf_dist $\n  calc dist x y = dist y x : dist_comm _ _\n  ... < inf_dist x s : hy\n\nlemma disjoint_closed_ball_of_lt_inf_dist {r : ℝ} (h : r < inf_dist x s) :\n  disjoint (closed_ball x r) s :=\ndisjoint_ball_inf_dist.mono_left $ closed_ball_subset_ball h\n\nvariable (s)\n\n/-- The minimal distance to a set is Lipschitz in point with constant 1 -/\nlemma lipschitz_inf_dist_pt : lipschitz_with 1 (λx, inf_dist x s) :=\nlipschitz_with.of_le_add $ λ x y, inf_dist_le_inf_dist_add_dist\n\n/-- The minimal distance to a set is uniformly continuous in point -/\n\n\n/-- The minimal distance to a set is continuous in point -/\n@[continuity]\nlemma continuous_inf_dist_pt : continuous (λx, inf_dist x s) :=\n(uniform_continuous_inf_dist_pt s).continuous\n\nvariable {s}\n\n/-- The minimal distance to a set and its closure coincide -/\nlemma inf_dist_eq_closure : inf_dist x (closure s) = inf_dist x s :=\nby simp [inf_dist, inf_edist_closure]\n\n/-- If a point belongs to the closure of `s`, then its infimum distance to `s` equals zero.\nThe converse is true provided that `s` is nonempty, see `mem_closure_iff_inf_dist_zero`. -/\nlemma inf_dist_zero_of_mem_closure (hx : x ∈ closure s) : inf_dist x s = 0 :=\nby { rw ← inf_dist_eq_closure, exact inf_dist_zero_of_mem hx }\n\n/-- A point belongs to the closure of `s` iff its infimum distance to this set vanishes -/\nlemma mem_closure_iff_inf_dist_zero (h : s.nonempty) : x ∈ closure s ↔ inf_dist x s = 0 :=\nby simp [mem_closure_iff_inf_edist_zero, inf_dist, ennreal.to_real_eq_zero_iff, inf_edist_ne_top h]\n\n/-- Given a closed set `s`, a point belongs to `s` iff its infimum distance to this set vanishes -/\nlemma _root_.is_closed.mem_iff_inf_dist_zero (h : is_closed s) (hs : s.nonempty) :\n  x ∈ s ↔ inf_dist x s = 0 :=\nby rw [←mem_closure_iff_inf_dist_zero hs, h.closure_eq]\n\n/-- Given a closed set `s`, a point belongs to `s` iff its infimum distance to this set vanishes -/\nlemma _root_.is_closed.not_mem_iff_inf_dist_pos (h : is_closed s) (hs : s.nonempty) :\n  x ∉ s ↔ 0 < inf_dist x s :=\nbegin\n  rw ← not_iff_not,\n  push_neg,\n  simp [h.mem_iff_inf_dist_zero hs, le_antisymm_iff, inf_dist_nonneg],\nend\n\n/-- The infimum distance is invariant under isometries -/\nlemma inf_dist_image (hΦ : isometry Φ) :\n  inf_dist (Φ x) (Φ '' t) = inf_dist x t :=\nby simp [inf_dist, inf_edist_image hΦ]\n\nlemma inf_dist_inter_closed_ball_of_mem (h : y ∈ s) :\n  inf_dist x (s ∩ closed_ball x (dist y x)) = inf_dist x s :=\nbegin\n  replace h : y ∈ s ∩ closed_ball x (dist y x) := ⟨h, mem_closed_ball.2 le_rfl⟩,\n  refine le_antisymm _ (inf_dist_le_inf_dist_of_subset (inter_subset_left _ _) ⟨y, h⟩),\n  refine not_lt.1 (λ hlt, _),\n  rcases (inf_dist_lt_iff ⟨y, h.1⟩).mp hlt with ⟨z, hzs, hz⟩,\n  cases le_or_lt (dist z x) (dist y x) with hle hlt,\n  { exact hz.not_le (inf_dist_le_dist_of_mem ⟨hzs, hle⟩) },\n  { rw [dist_comm z, dist_comm y] at hlt,\n    exact (hlt.trans hz).not_le (inf_dist_le_dist_of_mem h) }\nend\n\nlemma _root_.is_compact.exists_inf_dist_eq_dist (h : is_compact s) (hne : s.nonempty) (x : α) :\n  ∃ y ∈ s, inf_dist x s = dist x y :=\nlet ⟨y, hys, hy⟩ := h.exists_inf_edist_eq_edist hne x\nin ⟨y, hys, by rw [inf_dist, dist_edist, hy]⟩\n\nlemma _root_.is_closed.exists_inf_dist_eq_dist [proper_space α]\n  (h : is_closed s) (hne : s.nonempty) (x : α) :\n  ∃ y ∈ s, inf_dist x s = dist x y :=\nbegin\n  rcases hne with ⟨z, hz⟩,\n  rw ← inf_dist_inter_closed_ball_of_mem hz,\n  set t := s ∩ closed_ball x (dist z x),\n  have htc : is_compact t := (is_compact_closed_ball x (dist z x)).inter_left h,\n  have htne : t.nonempty := ⟨z, hz, mem_closed_ball.2 le_rfl⟩,\n  obtain ⟨y, ⟨hys, hyx⟩, hyd⟩ : ∃ y ∈ t, inf_dist x t = dist x y :=\n    htc.exists_inf_dist_eq_dist htne x,\n  exact ⟨y, hys, hyd⟩\nend\n\nlemma exists_mem_closure_inf_dist_eq_dist [proper_space α] (hne : s.nonempty) (x : α) :\n  ∃ y ∈ closure s, inf_dist x s = dist x y :=\nby simpa only [inf_dist_eq_closure] using is_closed_closure.exists_inf_dist_eq_dist hne.closure x\n\n/-! ### Distance of a point to a set as a function into `ℝ≥0`. -/\n\n/-- The minimal distance of a point to a set as a `ℝ≥0` -/\ndef inf_nndist (x : α) (s : set α) : ℝ≥0 := ennreal.to_nnreal (inf_edist x s)\n@[simp] lemma coe_inf_nndist : (inf_nndist x s : ℝ) = inf_dist x s := rfl\n\n/-- The minimal distance to a set (as `ℝ≥0`) is Lipschitz in point with constant 1 -/\nlemma lipschitz_inf_nndist_pt (s : set α) : lipschitz_with 1 (λx, inf_nndist x s) :=\nlipschitz_with.of_le_add $ λ x y, inf_dist_le_inf_dist_add_dist\n\n/-- The minimal distance to a set (as `ℝ≥0`) is uniformly continuous in point -/\nlemma uniform_continuous_inf_nndist_pt (s : set α) :\n  uniform_continuous (λx, inf_nndist x s) :=\n(lipschitz_inf_nndist_pt s).uniform_continuous\n\n/-- The minimal distance to a set (as `ℝ≥0`) is continuous in point -/\nlemma continuous_inf_nndist_pt (s : set α) : continuous (λx, inf_nndist x s) :=\n(uniform_continuous_inf_nndist_pt s).continuous\n\n/-! ### The Hausdorff distance as a function into `ℝ`. -/\n\n/-- The Hausdorff distance between two sets is the smallest nonnegative `r` such that each set is\nincluded in the `r`-neighborhood of the other. If there is no such `r`, it is defined to\nbe `0`, arbitrarily -/\ndef Hausdorff_dist (s t : set α) : ℝ := ennreal.to_real (Hausdorff_edist s t)\n\n/-- The Hausdorff distance is nonnegative -/\nlemma Hausdorff_dist_nonneg : 0 ≤ Hausdorff_dist s t :=\nby simp [Hausdorff_dist]\n\n/-- If two sets are nonempty and bounded in a metric space, they are at finite Hausdorff\nedistance. -/\nlemma Hausdorff_edist_ne_top_of_nonempty_of_bounded (hs : s.nonempty) (ht : t.nonempty)\n  (bs : bounded s) (bt : bounded t) : Hausdorff_edist s t ≠ ⊤ :=\nbegin\n  rcases hs with ⟨cs, hcs⟩,\n  rcases ht with ⟨ct, hct⟩,\n  rcases (bounded_iff_subset_ball ct).1 bs with ⟨rs, hrs⟩,\n  rcases (bounded_iff_subset_ball cs).1 bt with ⟨rt, hrt⟩,\n  have : Hausdorff_edist s t ≤ ennreal.of_real (max rs rt),\n  { apply Hausdorff_edist_le_of_mem_edist,\n    { assume x xs,\n      existsi [ct, hct],\n      have : dist x ct ≤ max rs rt := le_trans (hrs xs) (le_max_left _ _),\n      rwa [edist_dist, ennreal.of_real_le_of_real_iff],\n      exact le_trans dist_nonneg this },\n    { assume x xt,\n      existsi [cs, hcs],\n      have : dist x cs ≤ max rs rt := le_trans (hrt xt) (le_max_right _ _),\n      rwa [edist_dist, ennreal.of_real_le_of_real_iff],\n      exact le_trans dist_nonneg this }},\n  exact ne_top_of_le_ne_top ennreal.of_real_ne_top this\nend\n\n/-- The Hausdorff distance between a set and itself is zero -/\n@[simp] lemma Hausdorff_dist_self_zero : Hausdorff_dist s s = 0 :=\nby simp [Hausdorff_dist]\n\n/-- The Hausdorff distance from `s` to `t` and from `t` to `s` coincide -/\nlemma Hausdorff_dist_comm : Hausdorff_dist s t = Hausdorff_dist t s :=\nby simp [Hausdorff_dist, Hausdorff_edist_comm]\n\n/-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable\nvalue ∞ instead, use `Hausdorff_edist`, which takes values in ℝ≥0∞) -/\n@[simp] lemma Hausdorff_dist_empty : Hausdorff_dist s ∅ = 0 :=\nbegin\n  cases s.eq_empty_or_nonempty with h h,\n  { simp [h] },\n  { simp [Hausdorff_dist, Hausdorff_edist_empty h] }\nend\n\n/-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable\nvalue ∞ instead, use `Hausdorff_edist`, which takes values in ℝ≥0∞) -/\n@[simp] lemma Hausdorff_dist_empty' : Hausdorff_dist ∅ s = 0 :=\nby simp [Hausdorff_dist_comm]\n\n/-- Bounding the Hausdorff distance by bounding the distance of any point\nin each set to the other set -/\nlemma Hausdorff_dist_le_of_inf_dist {r : ℝ} (hr : 0 ≤ r)\n  (H1 : ∀x ∈ s, inf_dist x t ≤ r) (H2 : ∀x ∈ t, inf_dist x s ≤ r) :\n  Hausdorff_dist s t ≤ r :=\nbegin\n  by_cases h1 : Hausdorff_edist s t = ⊤,\n  { rwa [Hausdorff_dist, h1, ennreal.top_to_real] },\n  cases s.eq_empty_or_nonempty with hs hs,\n  { rwa [hs, Hausdorff_dist_empty'] },\n  cases t.eq_empty_or_nonempty with ht ht,\n  { rwa [ht, Hausdorff_dist_empty] },\n  have : Hausdorff_edist s t ≤ ennreal.of_real r,\n  { apply Hausdorff_edist_le_of_inf_edist _ _,\n    { assume x hx,\n      have I := H1 x hx,\n      rwa [inf_dist, ← ennreal.to_real_of_real hr,\n           ennreal.to_real_le_to_real (inf_edist_ne_top ht) ennreal.of_real_ne_top] at I },\n    { assume x hx,\n      have I := H2 x hx,\n      rwa [inf_dist, ← ennreal.to_real_of_real hr,\n           ennreal.to_real_le_to_real (inf_edist_ne_top hs) ennreal.of_real_ne_top] at I }},\n  rwa [Hausdorff_dist, ← ennreal.to_real_of_real hr,\n       ennreal.to_real_le_to_real h1 ennreal.of_real_ne_top]\nend\n\n/-- Bounding the Hausdorff distance by exhibiting, for any point in each set,\nanother point in the other set at controlled distance -/\nlemma Hausdorff_dist_le_of_mem_dist {r : ℝ} (hr : 0 ≤ r)\n  (H1 : ∀x ∈ s, ∃y ∈ t, dist x y ≤ r) (H2 : ∀x ∈ t, ∃y ∈ s, dist x y ≤ r) :\n  Hausdorff_dist s t ≤ r :=\nbegin\n  apply Hausdorff_dist_le_of_inf_dist hr,\n  { assume x xs,\n    rcases H1 x xs with ⟨y, yt, hy⟩,\n    exact le_trans (inf_dist_le_dist_of_mem yt) hy },\n  { assume x xt,\n    rcases H2 x xt with ⟨y, ys, hy⟩,\n    exact le_trans (inf_dist_le_dist_of_mem ys) hy }\nend\n\n/-- The Hausdorff distance is controlled by the diameter of the union -/\nlemma Hausdorff_dist_le_diam (hs : s.nonempty) (bs : bounded s) (ht : t.nonempty) (bt : bounded t) :\n  Hausdorff_dist s t ≤ diam (s ∪ t) :=\nbegin\n  rcases hs with ⟨x, xs⟩,\n  rcases ht with ⟨y, yt⟩,\n  refine Hausdorff_dist_le_of_mem_dist diam_nonneg _ _,\n  { exact  λz hz, ⟨y, yt, dist_le_diam_of_mem (bounded_union.2 ⟨bs, bt⟩)\n      (subset_union_left _ _ hz) (subset_union_right _ _ yt)⟩ },\n  { exact λz hz, ⟨x, xs, dist_le_diam_of_mem (bounded_union.2 ⟨bs, bt⟩)\n      (subset_union_right _ _ hz) (subset_union_left _ _ xs)⟩ }\nend\n\n/-- The distance to a set is controlled by the Hausdorff distance -/\nlemma inf_dist_le_Hausdorff_dist_of_mem (hx : x ∈ s) (fin : Hausdorff_edist s t ≠ ⊤) :\n  inf_dist x t ≤ Hausdorff_dist s t :=\nbegin\n  have ht : t.nonempty := nonempty_of_Hausdorff_edist_ne_top ⟨x, hx⟩ fin,\n  rw [Hausdorff_dist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ht) fin],\n  exact inf_edist_le_Hausdorff_edist_of_mem hx\nend\n\n/-- If the Hausdorff distance is `<r`, then any point in one of the sets is at distance\n`<r` of a point in the other set -/\nlemma exists_dist_lt_of_Hausdorff_dist_lt {r : ℝ} (h : x ∈ s) (H : Hausdorff_dist s t < r)\n  (fin : Hausdorff_edist s t ≠ ⊤) : ∃y∈t, dist x y < r :=\nbegin\n  have r0 : 0 < r := lt_of_le_of_lt (Hausdorff_dist_nonneg) H,\n  have : Hausdorff_edist s t < ennreal.of_real r,\n  { rwa [Hausdorff_dist, ← ennreal.to_real_of_real (le_of_lt r0),\n      ennreal.to_real_lt_to_real fin (ennreal.of_real_ne_top)] at H },\n  rcases exists_edist_lt_of_Hausdorff_edist_lt h this with ⟨y, hy, yr⟩,\n  rw [edist_dist, ennreal.of_real_lt_of_real_iff r0] at yr,\n  exact ⟨y, hy, yr⟩\nend\n\n/-- If the Hausdorff distance is `<r`, then any point in one of the sets is at distance\n`<r` of a point in the other set -/\nlemma exists_dist_lt_of_Hausdorff_dist_lt' {r : ℝ} (h : y ∈ t) (H : Hausdorff_dist s t < r)\n  (fin : Hausdorff_edist s t ≠ ⊤) : ∃x∈s, dist x y < r :=\nbegin\n  rw Hausdorff_dist_comm at H,\n  rw Hausdorff_edist_comm at fin,\n  simpa [dist_comm] using exists_dist_lt_of_Hausdorff_dist_lt h H fin\nend\n\n/-- The infimum distance to `s` and `t` are the same, up to the Hausdorff distance\nbetween `s` and `t` -/\nlemma inf_dist_le_inf_dist_add_Hausdorff_dist (fin : Hausdorff_edist s t ≠ ⊤) :\n  inf_dist x t ≤ inf_dist x s + Hausdorff_dist s t :=\nbegin\n  rcases empty_or_nonempty_of_Hausdorff_edist_ne_top fin with ⟨hs,ht⟩|⟨hs,ht⟩,\n  { simp only [hs, ht, Hausdorff_dist_empty, inf_dist_empty, zero_add] },\n  rw [inf_dist, inf_dist, Hausdorff_dist, ← ennreal.to_real_add (inf_edist_ne_top hs) fin,\n      ennreal.to_real_le_to_real (inf_edist_ne_top ht)],\n  { exact inf_edist_le_inf_edist_add_Hausdorff_edist },\n  { exact ennreal.add_ne_top.2 ⟨inf_edist_ne_top hs, fin⟩ }\nend\n\n/-- The Hausdorff distance is invariant under isometries -/\nlemma Hausdorff_dist_image (h : isometry Φ) :\n  Hausdorff_dist (Φ '' s) (Φ '' t) = Hausdorff_dist s t :=\nby simp [Hausdorff_dist, Hausdorff_edist_image h]\n\n/-- The Hausdorff distance satisfies the triangular inequality -/\nlemma Hausdorff_dist_triangle (fin : Hausdorff_edist s t ≠ ⊤) :\n  Hausdorff_dist s u ≤ Hausdorff_dist s t + Hausdorff_dist t u :=\nbegin\n  by_cases Hausdorff_edist s u = ⊤,\n  { calc Hausdorff_dist s u = 0 + 0 : by simp [Hausdorff_dist, h]\n         ... ≤ Hausdorff_dist s t + Hausdorff_dist t u :\n           add_le_add (Hausdorff_dist_nonneg) (Hausdorff_dist_nonneg) },\n  { have Dtu : Hausdorff_edist t u < ⊤ := calc\n      Hausdorff_edist t u ≤ Hausdorff_edist t s + Hausdorff_edist s u : Hausdorff_edist_triangle\n      ... = Hausdorff_edist s t + Hausdorff_edist s u : by simp [Hausdorff_edist_comm]\n      ... < ⊤ : lt_top_iff_ne_top.mpr $ ennreal.add_ne_top.mpr ⟨fin, h⟩,\n    rw [Hausdorff_dist, Hausdorff_dist, Hausdorff_dist,\n        ← ennreal.to_real_add fin Dtu.ne, ennreal.to_real_le_to_real h],\n    { exact Hausdorff_edist_triangle },\n    { simp [ennreal.add_eq_top, lt_top_iff_ne_top.1 Dtu, fin] }}\nend\n\n/-- The Hausdorff distance satisfies the triangular inequality -/\nlemma Hausdorff_dist_triangle' (fin : Hausdorff_edist t u ≠ ⊤) :\n  Hausdorff_dist s u ≤ Hausdorff_dist s t + Hausdorff_dist t u :=\nbegin\n  rw Hausdorff_edist_comm at fin,\n  have I : Hausdorff_dist u s ≤ Hausdorff_dist u t + Hausdorff_dist t s :=\n    Hausdorff_dist_triangle fin,\n  simpa [add_comm, Hausdorff_dist_comm] using I\nend\n\n/-- The Hausdorff distance between a set and its closure vanish -/\n@[simp, priority 1100]\nlemma Hausdorff_dist_self_closure : Hausdorff_dist s (closure s) = 0 :=\nby simp [Hausdorff_dist]\n\n/-- Replacing a set by its closure does not change the Hausdorff distance. -/\n@[simp] lemma Hausdorff_dist_closure₁ : Hausdorff_dist (closure s) t = Hausdorff_dist s t :=\nby simp [Hausdorff_dist]\n\n/-- Replacing a set by its closure does not change the Hausdorff distance. -/\n@[simp] lemma Hausdorff_dist_closure₂ : Hausdorff_dist s (closure t) = Hausdorff_dist s t :=\nby simp [Hausdorff_dist]\n\n/-- The Hausdorff distance between two sets and their closures coincide -/\n@[simp] lemma Hausdorff_dist_closure :\n  Hausdorff_dist (closure s) (closure t) = Hausdorff_dist s t :=\nby simp [Hausdorff_dist]\n\n/-- Two sets are at zero Hausdorff distance if and only if they have the same closures -/\nlemma Hausdorff_dist_zero_iff_closure_eq_closure (fin : Hausdorff_edist s t ≠ ⊤) :\n  Hausdorff_dist s t = 0 ↔ closure s = closure t :=\nby simp [Hausdorff_edist_zero_iff_closure_eq_closure.symm, Hausdorff_dist,\n         ennreal.to_real_eq_zero_iff, fin]\n\n/-- Two closed sets are at zero Hausdorff distance if and only if they coincide -/\nlemma _root_.is_closed.Hausdorff_dist_zero_iff_eq (hs : is_closed s) (ht : is_closed t)\n  (fin : Hausdorff_edist s t ≠ ⊤) : Hausdorff_dist s t = 0 ↔ s = t :=\nby simp [←Hausdorff_edist_zero_iff_eq_of_closed hs ht, Hausdorff_dist,\n         ennreal.to_real_eq_zero_iff, fin]\n\nend --section\n\nsection thickening\n\nvariables {α : Type u} [pseudo_emetric_space α]\n\nopen emetric\n\n/-- The (open) `δ`-thickening `thickening δ E` of a subset `E` in a pseudo emetric space consists\nof those points that are at distance less than `δ` from some point of `E`. -/\ndef thickening (δ : ℝ) (E : set α) : set α := {x : α | inf_edist x E < ennreal.of_real δ}\n\n/-- The (open) thickening equals the preimage of an open interval under `inf_edist`. -/\nlemma thickening_eq_preimage_inf_edist (δ : ℝ) (E : set α) :\n  thickening δ E = (λ x, inf_edist x E) ⁻¹' (Iio (ennreal.of_real δ)) := rfl\n\n/-- The (open) thickening is an open set. -/\nlemma is_open_thickening {δ : ℝ} {E : set α} : is_open (thickening δ E) :=\ncontinuous.is_open_preimage continuous_inf_edist _ is_open_Iio\n\n/-- The (open) thickening of the empty set is empty. -/\n@[simp] lemma thickening_empty (δ : ℝ) : thickening δ (∅ : set α) = ∅ :=\nby simp only [thickening, set_of_false, inf_edist_empty, not_top_lt]\n\n/-- The (open) thickening `thickening δ E` of a fixed subset `E` is an increasing function of the\nthickening radius `δ`. -/\nlemma thickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : set α) :\n  thickening δ₁ E ⊆ thickening δ₂ E :=\npreimage_mono (Iio_subset_Iio (ennreal.of_real_le_of_real hle))\n\n/-- The (open) thickening `thickening δ E` with a fixed thickening radius `δ` is\nan increasing function of the subset `E`. -/\nlemma thickening_subset_of_subset (δ : ℝ) {E₁ E₂ : set α} (h : E₁ ⊆ E₂) :\n  thickening δ E₁ ⊆ thickening δ E₂ :=\nλ _ hx, lt_of_le_of_lt (inf_edist_le_inf_edist_of_subset h) hx\n\nlemma mem_thickening_iff_exists_edist_lt {δ : ℝ} (E : set α) (x : α) :\n  x ∈ thickening δ E ↔ ∃ z ∈ E, edist x z < ennreal.of_real δ :=\ninf_edist_lt_iff\n\nvariables {X : Type u} [pseudo_metric_space X]\n\n/-- A point in a metric space belongs to the (open) `δ`-thickening of a subset `E` if and only if\nit is at distance less than `δ` from some point of `E`. -/\nlemma mem_thickening_iff {δ : ℝ} (E : set X) (x : X) :\n  x ∈ thickening δ E ↔ (∃ z ∈ E, dist x z < δ) :=\nbegin\n  have key_iff : ∀ (z : X), edist x z < ennreal.of_real δ ↔ dist x z < δ,\n  { intros z,\n    rw dist_edist,\n    have d_lt_top : edist x z < ∞, by simp only [edist_dist, ennreal.of_real_lt_top],\n    have key := (@ennreal.of_real_lt_of_real_iff_of_nonneg\n                ((edist x z).to_real) δ (ennreal.to_real_nonneg)),\n    rwa ennreal.of_real_to_real d_lt_top.ne at key, },\n  simp_rw [mem_thickening_iff_exists_edist_lt, key_iff],\nend\n\n@[simp] lemma thickening_singleton (δ : ℝ) (x : X) :\n  thickening δ ({x} : set X) = ball x δ :=\nby { ext, simp [mem_thickening_iff] }\n\n/-- The (open) `δ`-thickening `thickening δ E` of a subset `E` in a metric space equals the\nunion of balls of radius `δ` centered at points of `E`. -/\nlemma thickening_eq_bUnion_ball {δ : ℝ} {E : set X} :\n  thickening δ E = ⋃ x ∈ E, ball x δ :=\nby { ext x, rw mem_Union₂, exact mem_thickening_iff E x, }\n\nlemma bounded.thickening {δ : ℝ} {E : set X} (h : bounded E) :\n  bounded (thickening δ E) :=\nbegin\n  refine bounded_iff_mem_bounded.2 (λ x hx, _),\n  rcases h.subset_ball x with ⟨R, hR⟩,\n  refine (bounded_iff_subset_ball x).2 ⟨R + δ, _⟩,\n  assume y hy,\n  rcases (mem_thickening_iff _ _).1 hy with ⟨z, zE, hz⟩,\n  calc dist y x ≤ dist z x + dist y z : by { rw add_comm, exact dist_triangle _ _ _ }\n  ... ≤ R + δ : add_le_add (hR zE) hz.le\nend\n\nend thickening --section\n\nsection cthickening\n\nvariables {α : Type*} [pseudo_emetric_space α]\n\nopen emetric\n\n/-- The closed `δ`-thickening `cthickening δ E` of a subset `E` in a pseudo emetric space consists\nof those points that are at infimum distance at most `δ` from `E`. -/\ndef cthickening (δ : ℝ) (E : set α) : set α := {x : α | inf_edist x E ≤ ennreal.of_real δ}\n\nlemma mem_cthickening_of_edist_le (x y : α) (δ : ℝ) (E : set α) (h : y ∈ E)\n  (h' : edist x y ≤ ennreal.of_real δ) :\n  x ∈ cthickening δ E :=\n(inf_edist_le_edist_of_mem h).trans h'\n\nlemma mem_cthickening_of_dist_le {α : Type*} [pseudo_metric_space α]\n  (x y : α) (δ : ℝ) (E : set α) (h : y ∈ E) (h' : dist x y ≤ δ) :\n  x ∈ cthickening δ E :=\nbegin\n  apply mem_cthickening_of_edist_le x y δ E h,\n  rw edist_dist,\n  exact ennreal.of_real_le_of_real h',\nend\n\nlemma cthickening_eq_preimage_inf_edist (δ : ℝ) (E : set α) :\n  cthickening δ E = (λ x, inf_edist x E) ⁻¹' (Iic (ennreal.of_real δ)) := rfl\n\n/-- The closed thickening is a closed set. -/\nlemma is_closed_cthickening {δ : ℝ} {E : set α} : is_closed (cthickening δ E) :=\nis_closed.preimage continuous_inf_edist is_closed_Iic\n\n/-- The closed thickening of the empty set is empty. -/\n@[simp] lemma cthickening_empty (δ : ℝ) : cthickening δ (∅ : set α) = ∅ :=\nby simp only [cthickening, ennreal.of_real_ne_top, set_of_false, inf_edist_empty, top_le_iff]\n\nlemma cthickening_of_nonpos {δ : ℝ} (hδ : δ ≤ 0) (E : set α) :\n  cthickening δ E = closure E :=\nby { ext x, simp [mem_closure_iff_inf_edist_zero, cthickening, ennreal.of_real_eq_zero.2 hδ] }\n\n/-- The closed thickening with radius zero is the closure of the set. -/\n@[simp] lemma cthickening_zero (E : set α) : cthickening 0 E = closure E :=\ncthickening_of_nonpos le_rfl E\n\n/-- The closed thickening `cthickening δ E` of a fixed subset `E` is an increasing function of\nthe thickening radius `δ`. -/\nlemma cthickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : set α) :\n  cthickening δ₁ E ⊆ cthickening δ₂ E :=\npreimage_mono (Iic_subset_Iic.mpr (ennreal.of_real_le_of_real hle))\n\n@[simp] lemma cthickening_singleton {α : Type*} [pseudo_metric_space α]\n  (x : α) {δ : ℝ} (hδ : 0 ≤ δ) :\n  cthickening δ ({x} : set α) = closed_ball x δ :=\nby { ext y, simp [cthickening, edist_dist, ennreal.of_real_le_of_real_iff hδ] }\n\nlemma closed_ball_subset_cthickening_singleton {α : Type*} [pseudo_metric_space α]\n  (x : α) (δ : ℝ) :\n  closed_ball x δ ⊆ cthickening δ ({x} : set α) :=\nbegin\n  rcases lt_or_le δ 0 with hδ|hδ,\n  { simp only [closed_ball_eq_empty.mpr hδ, empty_subset] },\n  { simp only [cthickening_singleton x hδ] }\nend\n\n/-- The closed thickening `cthickening δ E` with a fixed thickening radius `δ` is\nan increasing function of the subset `E`. -/\nlemma cthickening_subset_of_subset (δ : ℝ) {E₁ E₂ : set α} (h : E₁ ⊆ E₂) :\n  cthickening δ E₁ ⊆ cthickening δ E₂ :=\nλ _ hx, le_trans (inf_edist_le_inf_edist_of_subset h) hx\n\nlemma cthickening_subset_thickening {δ₁ : ℝ≥0} {δ₂ : ℝ} (hlt : (δ₁ : ℝ) < δ₂) (E : set α) :\n  cthickening δ₁ E ⊆ thickening δ₂ E :=\nλ _ hx, lt_of_le_of_lt hx ((ennreal.of_real_lt_of_real_iff (lt_of_le_of_lt δ₁.prop hlt)).mpr hlt)\n\n/-- The closed thickening `cthickening δ₁ E` is contained in the open thickening `thickening δ₂ E`\nif the radius of the latter is positive and larger. -/\nlemma cthickening_subset_thickening' {δ₁ δ₂ : ℝ} (δ₂_pos : 0 < δ₂) (hlt : δ₁ < δ₂) (E : set α) :\n  cthickening δ₁ E ⊆ thickening δ₂ E :=\nλ _ hx, lt_of_le_of_lt hx ((ennreal.of_real_lt_of_real_iff δ₂_pos).mpr hlt)\n\n/-- The open thickening `thickening δ E` is contained in the closed thickening `cthickening δ E`\nwith the same radius. -/\nlemma thickening_subset_cthickening (δ : ℝ) (E : set α) :\n  thickening δ E ⊆ cthickening δ E :=\nby { intros x hx, rw [thickening, mem_set_of_eq] at hx, exact hx.le, }\n\nlemma thickening_subset_cthickening_of_le {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : set α) :\n  thickening δ₁ E ⊆ cthickening δ₂ E :=\n(thickening_subset_cthickening δ₁ E).trans (cthickening_mono hle E)\n\nlemma bounded.cthickening {α : Type*} [pseudo_metric_space α] {δ : ℝ} {E : set α} (h : bounded E) :\n  bounded (cthickening δ E) :=\nbegin\n  have : bounded (thickening (max (δ + 1) 1) E) := h.thickening,\n  apply bounded.mono _ this,\n  exact cthickening_subset_thickening' (zero_lt_one.trans_le (le_max_right _ _))\n    ((lt_add_one _).trans_le (le_max_left _ _)) _\nend\n\nlemma thickening_subset_interior_cthickening (δ : ℝ) (E : set α) :\n  thickening δ E ⊆ interior (cthickening δ E) :=\n(subset_interior_iff_open.mpr (is_open_thickening)).trans\n  (interior_mono (thickening_subset_cthickening δ E))\n\nlemma closure_thickening_subset_cthickening (δ : ℝ) (E : set α) :\n  closure (thickening δ E) ⊆ cthickening δ E :=\n(closure_mono (thickening_subset_cthickening δ E)).trans is_closed_cthickening.closure_subset\n\n/-- The closed thickening of a set contains the closure of the set. -/\nlemma closure_subset_cthickening (δ : ℝ) (E : set α) :\n  closure E ⊆ cthickening δ E :=\nby { rw ← cthickening_of_nonpos (min_le_right δ 0), exact cthickening_mono (min_le_left δ 0) E, }\n\n/-- The (open) thickening of a set contains the closure of the set. -/\nlemma closure_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : set α) :\n  closure E ⊆ thickening δ E :=\nby { rw ← cthickening_zero, exact cthickening_subset_thickening' δ_pos δ_pos E, }\n\n/-- A set is contained in its own (open) thickening. -/\nlemma self_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : set α) :\n  E ⊆ thickening δ E :=\n(@subset_closure _ _ E).trans (closure_subset_thickening δ_pos E)\n\n/-- A set is contained in its own closed thickening. -/\nlemma self_subset_cthickening {δ : ℝ} (E : set α) :\n  E ⊆ cthickening δ E :=\nsubset_closure.trans (closure_subset_cthickening δ E)\n\nlemma cthickening_eq_Inter_cthickening' {δ : ℝ}\n  (s : set ℝ) (hsδ : s ⊆ Ioi δ) (hs : ∀ ε, δ < ε → (s ∩ (Ioc δ ε)).nonempty) (E : set α) :\n  cthickening δ E = ⋂ ε ∈ s, cthickening ε E :=\nbegin\n  apply subset.antisymm,\n  { exact subset_Inter₂ (λ _ hε, cthickening_mono (le_of_lt (hsδ hε)) E), },\n  { unfold thickening cthickening,\n    intros x hx,\n    simp only [mem_Inter, mem_set_of_eq] at *,\n    apply ennreal.le_of_forall_pos_le_add,\n    intros η η_pos _,\n    rcases hs (δ + η) (lt_add_of_pos_right _ (nnreal.coe_pos.mpr η_pos)) with ⟨ε, ⟨hsε, hε⟩⟩,\n    apply ((hx ε hsε).trans (ennreal.of_real_le_of_real hε.2)).trans,\n    rw ennreal.coe_nnreal_eq η,\n    exact ennreal.of_real_add_le, },\nend\n\nlemma cthickening_eq_Inter_cthickening {δ : ℝ} (E : set α) :\n  cthickening δ E = ⋂ (ε : ℝ) (h : δ < ε), cthickening ε E :=\nbegin\n  apply cthickening_eq_Inter_cthickening' (Ioi δ) rfl.subset,\n  simp_rw inter_eq_right_iff_subset.mpr Ioc_subset_Ioi_self,\n  exact λ _ hε, nonempty_Ioc.mpr hε,\nend\n\nlemma cthickening_eq_Inter_thickening' {δ : ℝ} (δ_nn : 0 ≤ δ)\n  (s : set ℝ) (hsδ : s ⊆ Ioi δ) (hs : ∀ ε, δ < ε → (s ∩ (Ioc δ ε)).nonempty) (E : set α) :\n  cthickening δ E = ⋂ ε ∈ s, thickening ε E :=\nbegin\n  refine (subset_Inter₂ $ λ ε hε, _).antisymm _,\n  { obtain ⟨ε', hsε', hε'⟩ := hs ε (hsδ hε),\n    have ss := cthickening_subset_thickening' (lt_of_le_of_lt δ_nn hε'.1) hε'.1 E,\n    exact ss.trans (thickening_mono hε'.2 E), },\n  { rw cthickening_eq_Inter_cthickening' s hsδ hs E,\n    exact Inter₂_mono (λ ε hε, thickening_subset_cthickening ε E) }\nend\n\nlemma cthickening_eq_Inter_thickening {δ : ℝ} (δ_nn : 0 ≤ δ) (E : set α) :\n  cthickening δ E = ⋂ (ε : ℝ) (h : δ < ε), thickening ε E :=\nbegin\n  apply cthickening_eq_Inter_thickening' δ_nn (Ioi δ) rfl.subset,\n  simp_rw inter_eq_right_iff_subset.mpr Ioc_subset_Ioi_self,\n  exact λ _ hε, nonempty_Ioc.mpr hε,\nend\n\n/-- The closure of a set equals the intersection of its closed thickenings of positive radii\naccumulating at zero. -/\nlemma closure_eq_Inter_cthickening' (E : set α)\n  (s : set ℝ) (hs : ∀ ε, 0 < ε → (s ∩ (Ioc 0 ε)).nonempty) :\n  closure E = ⋂ δ ∈ s, cthickening δ E :=\nbegin\n  by_cases hs₀ : s ⊆ Ioi 0,\n  { rw ← cthickening_zero, apply cthickening_eq_Inter_cthickening' _ hs₀ hs, },\n  obtain ⟨δ, hδs, δ_nonpos⟩ := not_subset.mp hs₀,\n  rw [set.mem_Ioi, not_lt] at δ_nonpos,\n  apply subset.antisymm,\n  { exact subset_Inter₂ (λ ε _, closure_subset_cthickening ε E), },\n  { rw ← cthickening_of_nonpos δ_nonpos E,\n    exact bInter_subset_of_mem hδs, },\nend\n\n/-- The closure of a set equals the intersection of its closed thickenings of positive radii. -/\nlemma closure_eq_Inter_cthickening (E : set α) :\n  closure E = ⋂ (δ : ℝ) (h : 0 < δ), cthickening δ E :=\nby { rw ← cthickening_zero, exact cthickening_eq_Inter_cthickening E, }\n\n/-- The closure of a set equals the intersection of its open thickenings of positive radii\naccumulating at zero. -/\nlemma closure_eq_Inter_thickening' (E : set α)\n  (s : set ℝ) (hs₀ : s ⊆ Ioi 0) (hs : ∀ ε, 0 < ε → (s ∩ (Ioc 0 ε)).nonempty) :\n  closure E = ⋂ δ ∈ s, thickening δ E :=\nby { rw ← cthickening_zero, apply cthickening_eq_Inter_thickening' le_rfl _ hs₀ hs, }\n\n/-- The closure of a set equals the intersection of its (open) thickenings of positive radii. -/\nlemma closure_eq_Inter_thickening (E : set α) :\n  closure E = ⋂ (δ : ℝ) (h : 0 < δ), thickening δ E :=\nby { rw ← cthickening_zero, exact cthickening_eq_Inter_thickening rfl.ge E, }\n\n/-- The frontier of the (open) thickening of a set is contained in an `inf_edist` level set. -/\nlemma frontier_thickening_subset (E : set α) {δ : ℝ} (δ_pos : 0 < δ) :\n  frontier (thickening δ E) ⊆ {x : α | inf_edist x E = ennreal.of_real δ} :=\nbegin\n  have singleton_preim :\n    {x : α | inf_edist x E = ennreal.of_real δ } = (λ x , inf_edist x E) ⁻¹' {ennreal.of_real δ},\n  { simp only [preimage, mem_singleton_iff] },\n  rw [thickening_eq_preimage_inf_edist, singleton_preim,\n      ← (frontier_Iio' ⟨(0 : ℝ≥0∞), ennreal.of_real_pos.mpr δ_pos⟩)],\n  exact continuous_inf_edist.frontier_preimage_subset (Iio (ennreal.of_real δ)),\nend\n\n/-- The frontier of the closed thickening of a set is contained in an `inf_edist` level set. -/\nlemma frontier_cthickening_subset (E : set α) {δ : ℝ} :\n  frontier (cthickening δ E) ⊆ {x : α | inf_edist x E = ennreal.of_real δ} :=\nbegin\n  have singleton_preim :\n    {x : α | inf_edist x E = ennreal.of_real δ } = (λ x , inf_edist x E) ⁻¹' {ennreal.of_real δ},\n  { simp only [preimage, mem_singleton_iff] },\n  rw [cthickening_eq_preimage_inf_edist, singleton_preim,\n      ← frontier_Iic' ⟨∞, ennreal.of_real_lt_top⟩],\n  exact continuous_inf_edist.frontier_preimage_subset (Iic (ennreal.of_real δ)),\nend\n\n/-- The closed ball of radius `δ` centered at a point of `E` is included in the closed\nthickening of `E`. -/\nlemma closed_ball_subset_cthickening {α : Type*} [pseudo_metric_space α]\n  {x : α} {E : set α} (hx : x ∈ E) (δ : ℝ) :\n  closed_ball x δ ⊆ cthickening δ E :=\nbegin\n  refine (closed_ball_subset_cthickening_singleton _ _).trans (cthickening_subset_of_subset _ _),\n  simpa using hx,\nend\n\n/-- The closed thickening of a compact set `E` is the union of the balls `closed_ball x δ` over\n`x ∈ E`. -/\nlemma _root_.is_compact.cthickening_eq_bUnion_closed_ball\n  {α : Type*} [pseudo_metric_space α] {δ : ℝ} {E : set α} (hE : is_compact E) (hδ : 0 ≤ δ) :\n  cthickening δ E = ⋃ x ∈ E, closed_ball x δ :=\nbegin\n  rcases eq_empty_or_nonempty E with rfl|hne,\n  { simp only [cthickening_empty, Union_false, Union_empty] },\n  refine subset.antisymm (λ x hx, _) (Union₂_subset $ λ x hx, closed_ball_subset_cthickening hx _),\n  obtain ⟨y, yE, hy⟩ : ∃ y ∈ E, emetric.inf_edist x E = edist x y :=\n    hE.exists_inf_edist_eq_edist hne _,\n  have D1 : edist x y ≤ ennreal.of_real δ := (le_of_eq hy.symm).trans hx,\n  have D2 : dist x y ≤ δ,\n  { rw edist_dist at D1,\n    exact (ennreal.of_real_le_of_real_iff hδ).1 D1 },\n  exact mem_bUnion yE D2,\nend\n\nend cthickening --section\n\nend metric --namespace\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/topology/metric_space/hausdorff_distance.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.47817232273387644}}
{"text": "namespace tactic\n  open expr\n\n  /-- Given a fully applied structure type `ty` with fields `f1`...`fn`, synthesize the proof\n      `∀ x : ty, ty.mk x.f1 ... x.fn = x`.\n      The proof can be extracted into a new definition using\n\n      ```\n      def ty.eta := by mk_struct_eta ```(ty) >>= exact\n      ``` -/\n  meta def mk_struct_eta (ty : expr) : tactic expr :=\n  do (const n ls) ← pure ty.get_app_fn | fail \"not a structure\",\n     env ← get_env,\n     fields ← env.structure_fields n <|> fail \"not a structre\",\n     [ctor] ← pure $ env.constructors_of n,\n     let proof_ty := pi `_x binder_info.default ty $ app (const ``eq [])\n       (expr.mk_app (const ctor []) $ fields.map $ λ f, (pexpr.mk_field_macro (pexpr.of_raw_expr $ var 0) f).to_raw_expr)\n       (var 0),\n     proof_ty ← to_expr (pexpr.of_raw_expr proof_ty),\n     prod.snd <$> solve_aux proof_ty (do x ← intro `_, cases x, reflexivity)\nend tactic\n\nnamespace tactic.interactive\n  open expr tactic\n\n  private meta def common_app_prefix : expr → expr → tactic expr\n  | (app e₁ e₁') (app e₂ e₂') := (is_def_eq e₁ e₂ *> pure e₁) <|> common_app_prefix e₁ e₂\n  | e₁           e₂           := fail \"no common head symbol\"\n\n  /-- Given a goal of form `f a₁ ... aₙ == f a₁' ... aₙ'`, this tactic breaks it down to subgoals\n      `a₁ == a₁'`, ...\n      Subgoals provable by reflexivity are dispensed automatically.\n      The goal can also be a homogenous equality. New subgoals will use homogenous equalities where possible. -/\n  meta def congr_args : tactic unit :=\n  do tgt ← target,\n     (lhs, rhs) ← match tgt with\n     | ```(%%lhs = %%rhs) := pure (lhs, rhs)\n     | ```(%%lhs == %%rhs) := pure (lhs, rhs)\n     | _ := fail \"goal is not an equality\"\n     end,\n     pre ← common_app_prefix lhs rhs,\n     l ← mk_hcongr_lemma pre,\n     tactic.apply l.proof,\n     all_goals $ try refl\n\n  /-- Given a goal that equates two structure values, this tactic breaks it down to subgoals equating each\n      pair of fields. -/\n  meta def congr_struct : tactic unit :=\n  do ```(%%lhs = %%rhs) ← target | fail \"goal is not an equality\",\n     ty ← infer_type lhs,\n     eta ← mk_struct_eta ty,\n     apply ``(@eq.rec _ _ (λ lhs, lhs = %%rhs) _ _ %%(app eta lhs)),\n     ```(%%new_lhs = %%rhs) ← target,\n     apply ``(@eq.rec _ _ (λ rhs, %%new_lhs = rhs) _ _ %%(app eta rhs)),\n     congr_args\nend tactic.interactive\n\nstructure X { a : Type } ( b : a × a ) := ( c : nat ) \n\ndef foo ( x y : X (1, 1) ) : x = y :=\nbegin\n  congr_struct\nend", "meta": {"author": "semorrison", "repo": "proof", "sha": "5ee398aa239a379a431190edbb6022b1a0aa2c70", "save_path": "github-repos/lean/semorrison-proof", "path": "github-repos/lean/semorrison-proof/proof-5ee398aa239a379a431190edbb6022b1a0aa2c70/lean/20170429-congr_struct.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.47817232248325775}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\n\nimport geometric_algebra.from_mathlib.fold\nimport linear_algebra.clifford_algebra.grading\nimport linear_algebra.clifford_algebra.conjugation\nimport linear_algebra.clifford_algebra.contraction\nimport linear_algebra.exterior_algebra.basic\n\n/-!\n# Contraction in Clifford Algebras\n\nMost of the results are now\n[upstream in `linear_algebra.clifford_algebra.contraction`](https://leanprover-community.github.io/mathlib_docs/linear_algebra/clifford_algebra/contraction.html)\nas of https://github.com/leanprover-community/mathlib/pull/11468.\n-/\n\nuniverses u1 u2 u3\n\nvariables {R : Type u1} [comm_ring R]\nvariables {M : Type u2} [add_comm_group M] [module R M]\nvariables (Q : quadratic_form R M)\n\nnamespace clifford_algebra\n\nvariables (d d' : module.dual R M)\n\nlocal infix `⌋`:70 := contract_left\n\nvariables {Q}\n\nvariables {Q' Q'' : quadratic_form R M} {B B' : bilin_form R M}\nvariables (h : B.to_quadratic_form = Q' - Q) (h' : B'.to_quadratic_form = Q'' - Q')\n\n/-- Theorem 24 -/\nlemma change_form_reverse (d : module.dual R M) (x : clifford_algebra Q) :\n  change_form h (reverse x) = reverse (change_form h x) :=\nbegin\n  apply clifford_algebra.left_induction _ (λ r, _) (λ x y hx hy, _) (λ x m hx, _) x,\n  { simp_rw [change_form_algebra_map, reverse.commutes, change_form_algebra_map] },\n  { rw [map_add, map_add, map_add, map_add, hx, hy] },\n  { simp_rw [reverse.map_mul, change_form_ι_mul, map_sub, reverse.map_mul, reverse_ι],\n    rw ←hx,\n    rw ←change_form_contract_left,\n    sorry }\nend\n\nvariables {Q}\n\n/-- The wedge product of the clifford algebra. -/\ndef wedge [invertible (2 : R)] (x y : clifford_algebra Q) : clifford_algebra Q :=\n(equiv_exterior Q).symm (equiv_exterior Q x * equiv_exterior Q y)\n\ninfix (name := clifford_algebra.wedge) ` ⋏ `:70 := wedge\n\nend clifford_algebra\n", "meta": {"author": "pygae", "repo": "lean-ga", "sha": "5e8b22b2f25c7037723ad811faa312660eeb6775", "save_path": "github-repos/lean/pygae-lean-ga", "path": "github-repos/lean/pygae-lean-ga/lean-ga-5e8b22b2f25c7037723ad811faa312660eeb6775/src/geometric_algebra/from_mathlib/contract.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4781708956620527}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module control.traversable.lemmas\n! leanprover-community/mathlib commit 3342d1b2178381196f818146ff79bc0e7ccd9e2d\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Control.Applicative\nimport Mathlib.Control.Traversable.Basic\n\n/-!\n# Traversing collections\n\nThis file proves basic properties of traversable and applicative functors and defines\n`PureTransformation F`, the natural applicative transformation from the identity functor to `F`.\n\n## References\n\nInspired by [The Essence of the Iterator Pattern][gibbons2009].\n-/\n\n\nuniverse u\n\nopen IsLawfulTraversable\n\nopen Function hiding comp\n\nopen Functor\n\nattribute [functor_norm] IsLawfulTraversable.naturality\n\nattribute [simp] IsLawfulTraversable.id_traverse\n\nnamespace Traversable\n\nvariable {t : Type u → Type u}\n\nvariable [Traversable t] [IsLawfulTraversable t]\n\nvariable (F G : Type u → Type u)\n\nvariable [Applicative F] [LawfulApplicative F]\n\nvariable [Applicative G] [LawfulApplicative G]\n\nvariable {α β γ : Type u}\n\nvariable (g : α → F β)\n\nvariable (h : β → G γ)\n\nvariable (f : β → γ)\n\n/-- The natural applicative transformation from the identity functor\nto `F`, defined by `pure : Π {α}, α → F α`. -/\ndef PureTransformation :\n    ApplicativeTransformation Id F where\n  app := @pure F _\n  preserves_pure' x := rfl\n  preserves_seq' f x := by\n    simp only [map_pure, seq_pure]\n    rfl\n#align traversable.pure_transformation Traversable.PureTransformation\n\n@[simp]\ntheorem pureTransformation_apply {α} (x : id α) : PureTransformation F x = pure x :=\n  rfl\n#align traversable.pure_transformation_apply Traversable.pureTransformation_apply\n\nvariable {F G} (x : t β)\n\n-- Porting note: need to specify `m/F/G := Id` because `id` no longer has a `Monad` instance\ntheorem map_eq_traverse_id : map (f := t) f = traverse (m := Id) (pure ∘ f) :=\n  funext fun y => (traverse_eq_map_id f y).symm\n#align traversable.map_eq_traverse_id Traversable.map_eq_traverse_id\n\ntheorem map_traverse (x : t α) : map f <$> traverse g x = traverse (map f ∘ g) x := by\n  rw [map_eq_traverse_id f]\n  refine' (comp_traverse (pure ∘ f) g x).symm.trans _\n  congr ; apply Comp.applicative_comp_id\n#align traversable.map_traverse Traversable.map_traverse\n\ntheorem traverse_map (f : β → F γ) (g : α → β) (x : t α) :\n    traverse f (g <$> x) = traverse (f ∘ g) x := by\n  rw [@map_eq_traverse_id t _ _ _ _ g]\n  refine' (comp_traverse (G := Id) f (pure ∘ g) x).symm.trans _\n  congr ; apply Comp.applicative_id_comp\n#align traversable.traverse_map Traversable.traverse_map\n\ntheorem pure_traverse (x : t α) : traverse pure x = (pure x : F (t α)) := by\n  have : traverse pure x = pure (traverse (m := Id) pure x) :=\n      (naturality (PureTransformation F) pure x).symm\n  rwa [id_traverse] at this\n#align traversable.pure_traverse Traversable.pure_traverse\n\ntheorem id_sequence (x : t α) : sequence (f := Id) (pure <$> x) = pure x := by\n  simp [sequence, traverse_map, id_traverse]\n#align traversable.id_sequence Traversable.id_sequence\n\ntheorem comp_sequence (x : t (F (G α))) :\n    sequence (Comp.mk <$> x) = Comp.mk (sequence <$> sequence x) := by\n  simp [sequence, traverse_map]; rw [← comp_traverse]; simp [map_id]\n#align traversable.comp_sequence Traversable.comp_sequence\n\ntheorem naturality' (η : ApplicativeTransformation F G) (x : t (F α)) :\n    η (sequence x) = sequence (@η _ <$> x) := by simp [sequence, naturality, traverse_map]\n#align traversable.naturality' Traversable.naturality'\n\n@[functor_norm]\ntheorem traverse_id : traverse pure = (pure : t α → Id (t α)) := by\n  ext\n  exact id_traverse _\n#align traversable.traverse_id Traversable.traverse_id\n\n@[functor_norm]\ntheorem traverse_comp (g : α → F β) (h : β → G γ) :\n    traverse (Comp.mk ∘ map h ∘ g) =\n      (Comp.mk ∘ map (traverse h) ∘ traverse g : t α → Comp F G (t γ)) := by\n  ext\n  exact comp_traverse _ _ _\n#align traversable.traverse_comp Traversable.traverse_comp\n\ntheorem traverse_eq_map_id' (f : β → γ) :\n  traverse (m := Id) (pure ∘ f) = pure ∘ (map f : t β → t γ) := by\n  ext\n  exact traverse_eq_map_id _ _\n#align traversable.traverse_eq_map_id' Traversable.traverse_eq_map_id'\n\n-- @[functor_norm]\ntheorem traverse_map' (g : α → β) (h : β → G γ) :\n    traverse (h ∘ g) = (traverse h ∘ map g : t α → G (t γ)) := by\n  ext\n  rw [comp_apply, traverse_map]\n#align traversable.traverse_map' Traversable.traverse_map'\n\ntheorem map_traverse' (g : α → G β) (h : β → γ) :\n    traverse (map h ∘ g) = (map (map h) ∘ traverse g : t α → G (t γ)) := by\n  ext\n  rw [comp_apply, map_traverse]\n#align traversable.map_traverse' Traversable.map_traverse'\n\ntheorem naturality_pf (η : ApplicativeTransformation F G) (f : α → F β) :\n    traverse (@η _ ∘ f) = @η _ ∘ (traverse f : t α → F (t β)) := by\n  ext\n  rw [comp_apply, naturality]\n#align traversable.naturality_pf Traversable.naturality_pf\n\nend Traversable\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Control/Traversable/Lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.7549149758396752, "lm_q1q2_score": 0.47817089390095896}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module group_theory.submonoid.pointwise\n! leanprover-community/mathlib commit 2bbc7e3884ba234309d2a43b19144105a753292e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Pointwise.Smul\nimport Mathbin.GroupTheory.Submonoid.Membership\nimport Mathbin.Order.WellFoundedSet\n\n/-! # Pointwise instances on `submonoid`s and `add_submonoid`s\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides:\n\n* `submonoid.has_inv`\n* `add_submonoid.has_neg`\n\nand the actions\n\n* `submonoid.pointwise_mul_action`\n* `add_submonoid.pointwise_mul_action`\n\nwhich matches the action of `mul_action_set`.\n\nThese are all available in the `pointwise` locale.\n\nAdditionally, it provides various degrees of monoid structure:\n* `add_submonoid.has_one`\n* `add_submonoid.has_mul`\n* `add_submonoid.mul_one_class`\n* `add_submonoid.semigroup`\n* `add_submonoid.monoid`\nwhich is available globally to match the monoid structure implied by `submodule.idem_semiring`.\n\n## Implementation notes\n\nMost of the lemmas in this file are direct copies of lemmas from `algebra/pointwise.lean`.\nWhile the statements of these lemmas are defeq, we repeat them here due to them not being\nsyntactically equal. Before adding new lemmas here, consider if they would also apply to the action\non `set`s.\n\n-/\n\n\nopen Set\n\nvariable {α : Type _} {G : Type _} {M : Type _} {R : Type _} {A : Type _}\n\nvariable [Monoid M] [AddMonoid A]\n\n/-! Some lemmas about pointwise multiplication and submonoids. Ideally we put these in\n  `group_theory.submonoid.basic`, but currently we cannot because that file is imported by this. -/\n\n\nnamespace Submonoid\n\nopen Pointwise\n\nvariable {s t u : Set M}\n\n/- warning: submonoid.mul_subset -> Submonoid.mul_subset is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {s : Set.{u1} M} {t : Set.{u1} M} {S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) S)) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) t ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) S)) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) s t) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) S))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {s : Set.{u1} M} {t : Set.{u1} M} {S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) S)) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) t (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) S)) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) s t) (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.mul_subset Submonoid.mul_subsetₓ'. -/\n@[to_additive]\ntheorem mul_subset {S : Submonoid M} (hs : s ⊆ S) (ht : t ⊆ S) : s * t ⊆ S :=\n  by\n  rintro _ ⟨p, q, hp, hq, rfl⟩\n  exact Submonoid.mul_mem _ (hs hp) (ht hq)\n#align submonoid.mul_subset Submonoid.mul_subset\n#align add_submonoid.add_subset AddSubmonoid.add_subset\n\n/- warning: submonoid.mul_subset_closure -> Submonoid.mul_subset_closure is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {s : Set.{u1} M} {t : Set.{u1} M} {u : Set.{u1} M}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) s u) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) t u) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.hasSubset.{u1} M) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) s t) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) u)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {s : Set.{u1} M} {t : Set.{u1} M} {u : Set.{u1} M}, (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) s u) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) t u) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) s t) (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) u)))\nCase conversion may be inaccurate. Consider using '#align submonoid.mul_subset_closure Submonoid.mul_subset_closureₓ'. -/\n@[to_additive]\ntheorem mul_subset_closure (hs : s ⊆ u) (ht : t ⊆ u) : s * t ⊆ Submonoid.closure u :=\n  mul_subset (Subset.trans hs Submonoid.subset_closure) (Subset.trans ht Submonoid.subset_closure)\n#align submonoid.mul_subset_closure Submonoid.mul_subset_closure\n#align add_submonoid.add_subset_closure AddSubmonoid.add_subset_closure\n\n/- warning: submonoid.coe_mul_self_eq -> Submonoid.coe_mul_self_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (s : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), Eq.{succ u1} (Set.{u1} M) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) s) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) s)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (s : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), Eq.{succ u1} (Set.{u1} M) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) s) (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) s)) (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) s)\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_mul_self_eq Submonoid.coe_mul_self_eqₓ'. -/\n@[to_additive]\ntheorem coe_mul_self_eq (s : Submonoid M) : (s : Set M) * s = s :=\n  by\n  ext x\n  refine' ⟨_, fun h => ⟨x, 1, h, s.one_mem, mul_one x⟩⟩\n  rintro ⟨a, b, ha, hb, rfl⟩\n  exact s.mul_mem ha hb\n#align submonoid.coe_mul_self_eq Submonoid.coe_mul_self_eq\n#align add_submonoid.coe_add_self_eq AddSubmonoid.coe_add_self_eq\n\n/- warning: submonoid.closure_mul_le -> Submonoid.closure_mul_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Set.{u1} M) (T : Set.{u1} M), LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) S T)) (Sup.sup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SemilatticeSup.toHasSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.completeLattice.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) S) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) T))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Set.{u1} M) (T : Set.{u1} M), LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) S T)) (Sup.sup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SemilatticeSup.toSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) S) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_mul_le Submonoid.closure_mul_leₓ'. -/\n@[to_additive]\ntheorem closure_mul_le (S T : Set M) : closure (S * T) ≤ closure S ⊔ closure T :=\n  infₛ_le fun x ⟨s, t, hs, ht, hx⟩ =>\n    hx ▸\n      (closure S ⊔ closure T).mul_mem (SetLike.le_def.mp le_sup_left <| subset_closure hs)\n        (SetLike.le_def.mp le_sup_right <| subset_closure ht)\n#align submonoid.closure_mul_le Submonoid.closure_mul_le\n#align add_submonoid.closure_add_le AddSubmonoid.closure_add_le\n\n/- warning: submonoid.sup_eq_closure -> Submonoid.sup_eq_closure is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (H : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (K : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Sup.sup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SemilatticeSup.toHasSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.completeLattice.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) H K) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) H) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Set.{u1} M) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) K)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (H : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (K : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Sup.sup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SemilatticeSup.toSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) H K) (Submonoid.closure.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) (HMul.hMul.{u1, u1, u1} (Set.{u1} M) (Set.{u1} M) (Set.{u1} M) (instHMul.{u1} (Set.{u1} M) (Set.mul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) H) (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) K)))\nCase conversion may be inaccurate. Consider using '#align submonoid.sup_eq_closure Submonoid.sup_eq_closureₓ'. -/\n@[to_additive]\ntheorem sup_eq_closure (H K : Submonoid M) : H ⊔ K = closure (H * K) :=\n  le_antisymm\n    (sup_le (fun h hh => subset_closure ⟨h, 1, hh, K.one_mem, mul_one h⟩) fun k hk =>\n      subset_closure ⟨1, k, H.one_mem, hk, one_mul k⟩)\n    (by conv_rhs => rw [← closure_eq H, ← closure_eq K] <;> apply closure_mul_le)\n#align submonoid.sup_eq_closure Submonoid.sup_eq_closure\n#align add_submonoid.sup_eq_closure AddSubmonoid.sup_eq_closure\n\n/- warning: submonoid.pow_smul_mem_closure_smul -> Submonoid.pow_smul_mem_closure_smul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {N : Type.{u2}} [_inst_3 : CommMonoid.{u2} N] [_inst_4 : MulAction.{u1, u2} M N _inst_1] [_inst_5 : IsScalarTower.{u1, u2, u2} M N N (MulAction.toHasSmul.{u1, u2} M N _inst_1 _inst_4) (Mul.toSMul.{u2} N (MulOneClass.toHasMul.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)))) (MulAction.toHasSmul.{u1, u2} M N _inst_1 _inst_4)] (r : M) (s : Set.{u2} N) {x : N}, (Membership.Mem.{u2, u2} N (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) N (Submonoid.setLike.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)))) x (Submonoid.closure.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)) s)) -> (Exists.{1} Nat (fun (n : Nat) => Membership.Mem.{u2, u2} N (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) N (Submonoid.setLike.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)))) (SMul.smul.{u1, u2} M N (MulAction.toHasSmul.{u1, u2} M N _inst_1 _inst_4) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) r n) x) (Submonoid.closure.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)) (SMul.smul.{u1, u2} M (Set.{u2} N) (Set.smulSet.{u1, u2} M N (MulAction.toHasSmul.{u1, u2} M N _inst_1 _inst_4)) r s))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {N : Type.{u2}} [_inst_3 : CommMonoid.{u2} N] [_inst_4 : MulAction.{u1, u2} M N _inst_1] [_inst_5 : IsScalarTower.{u1, u2, u2} M N N (MulAction.toSMul.{u1, u2} M N _inst_1 _inst_4) (MulAction.toSMul.{u2, u2} N N (CommMonoid.toMonoid.{u2} N _inst_3) (Monoid.toMulAction.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) (MulAction.toSMul.{u1, u2} M N _inst_1 _inst_4)] (r : M) (s : Set.{u2} N) {x : N}, (Membership.mem.{u2, u2} N (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) N (Submonoid.instSetLikeSubmonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)))) x (Submonoid.closure.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)) s)) -> (Exists.{1} Nat (fun (n : Nat) => Membership.mem.{u2, u2} N (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3))) N (Submonoid.instSetLikeSubmonoid.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)))) (HSMul.hSMul.{u1, u2, u2} M N N (instHSMul.{u1, u2} M N (MulAction.toSMul.{u1, u2} M N _inst_1 _inst_4)) (HPow.hPow.{u1, 0, u1} M Nat M (instHPow.{u1, 0} M Nat (Monoid.Pow.{u1} M _inst_1)) r n) x) (Submonoid.closure.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_3)) (HSMul.hSMul.{u1, u2, u2} M (Set.{u2} N) (Set.{u2} N) (instHSMul.{u1, u2} M (Set.{u2} N) (Set.smulSet.{u1, u2} M N (MulAction.toSMul.{u1, u2} M N _inst_1 _inst_4))) r s))))\nCase conversion may be inaccurate. Consider using '#align submonoid.pow_smul_mem_closure_smul Submonoid.pow_smul_mem_closure_smulₓ'. -/\n@[to_additive]\ntheorem pow_smul_mem_closure_smul {N : Type _} [CommMonoid N] [MulAction M N] [IsScalarTower M N N]\n    (r : M) (s : Set N) {x : N} (hx : x ∈ closure s) : ∃ n : ℕ, r ^ n • x ∈ closure (r • s) :=\n  by\n  apply @closure_induction N _ s (fun x : N => ∃ n : ℕ, r ^ n • x ∈ closure (r • s)) _ hx\n  · intro x hx\n    exact ⟨1, subset_closure ⟨_, hx, by rw [pow_one]⟩⟩\n  · exact ⟨0, by simpa using one_mem _⟩\n  · rintro x y ⟨nx, hx⟩ ⟨ny, hy⟩\n    use nx + ny\n    convert mul_mem hx hy\n    rw [pow_add, smul_mul_assoc, mul_smul, mul_comm, ← smul_mul_assoc, mul_comm]\n#align submonoid.pow_smul_mem_closure_smul Submonoid.pow_smul_mem_closure_smul\n#align add_submonoid.nsmul_vadd_mem_closure_vadd AddSubmonoid.nsmul_vadd_mem_closure_vadd\n\nvariable [Group G]\n\nopen Pointwise\n\n#print Submonoid.inv /-\n/-- The submonoid with every element inverted. -/\n@[to_additive \" The additive submonoid with every element negated. \"]\nprotected def inv : Inv (Submonoid G)\n    where inv S :=\n    { carrier := (S : Set G)⁻¹\n      one_mem' :=\n        show (1 : G)⁻¹ ∈ S by\n          rw [inv_one]\n          exact S.one_mem\n      mul_mem' := fun a b (ha : a⁻¹ ∈ S) (hb : b⁻¹ ∈ S) =>\n        show (a * b)⁻¹ ∈ S by\n          rw [mul_inv_rev]\n          exact S.mul_mem hb ha }\n#align submonoid.has_inv Submonoid.inv\n#align add_submonoid.has_neg AddSubmonoid.neg\n-/\n\nscoped[Pointwise] attribute [instance] Submonoid.inv\n\nopen Pointwise\n\n/- warning: submonoid.coe_inv -> Submonoid.coe_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Eq.{succ u1} (Set.{u1} G) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Set.{u1} G) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Set.{u1} G) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Set.{u1} G) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S)) (Inv.inv.{u1} (Set.{u1} G) (Set.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Set.{u1} G) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Set.{u1} G) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Set.{u1} G) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))) S))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Eq.{succ u1} (Set.{u1} G) (SetLike.coe.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.instSetLikeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S)) (Inv.inv.{u1} (Set.{u1} G) (Set.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_3))))) (SetLike.coe.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.instSetLikeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_inv Submonoid.coe_invₓ'. -/\n@[simp, to_additive]\ntheorem coe_inv (S : Submonoid G) : ↑S⁻¹ = (S : Set G)⁻¹ :=\n  rfl\n#align submonoid.coe_inv Submonoid.coe_inv\n#align add_submonoid.coe_neg AddSubmonoid.coe_neg\n\n/- warning: submonoid.mem_inv -> Submonoid.mem_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] {g : G} {S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))}, Iff (Membership.Mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) g (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S)) (Membership.Mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)) g) S)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] {g : G} {S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))}, Iff (Membership.mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.instSetLikeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) g (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S)) (Membership.mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.instSetLikeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_3)))) g) S)\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_inv Submonoid.mem_invₓ'. -/\n@[simp, to_additive]\ntheorem mem_inv {g : G} {S : Submonoid G} : g ∈ S⁻¹ ↔ g⁻¹ ∈ S :=\n  Iff.rfl\n#align submonoid.mem_inv Submonoid.mem_inv\n#align add_submonoid.mem_neg AddSubmonoid.mem_neg\n\n@[to_additive]\ninstance : InvolutiveInv (Submonoid G) :=\n  SetLike.coe_injective.InvolutiveInv _ fun _ => rfl\n\n/- warning: submonoid.inv_le_inv -> Submonoid.inv_le_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Iff (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T)) (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))) S T)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Iff (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T)) (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) S T)\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_le_inv Submonoid.inv_le_invₓ'. -/\n@[simp, to_additive]\ntheorem inv_le_inv (S T : Submonoid G) : S⁻¹ ≤ T⁻¹ ↔ S ≤ T :=\n  SetLike.coe_subset_coe.symm.trans Set.inv_subset_inv\n#align submonoid.inv_le_inv Submonoid.inv_le_inv\n#align add_submonoid.neg_le_neg AddSubmonoid.neg_le_neg\n\n/- warning: submonoid.inv_le -> Submonoid.inv_le is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Iff (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) T) (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))) S (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Iff (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) T) (LE.le.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) S (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_le Submonoid.inv_leₓ'. -/\n@[to_additive]\ntheorem inv_le (S T : Submonoid G) : S⁻¹ ≤ T ↔ S ≤ T⁻¹ :=\n  SetLike.coe_subset_coe.symm.trans Set.inv_subset\n#align submonoid.inv_le Submonoid.inv_le\n#align add_submonoid.neg_le AddSubmonoid.neg_le\n\n/- warning: submonoid.inv_order_iso -> Submonoid.invOrderIso is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G], OrderIso.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G], OrderIso.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) (Preorder.toLE.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))))))\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_order_iso Submonoid.invOrderIsoₓ'. -/\n/-- `submonoid.has_inv` as an order isomorphism. -/\n@[to_additive \" `add_submonoid.has_neg` as an order isomorphism \", simps]\ndef invOrderIso : Submonoid G ≃o Submonoid G\n    where\n  toEquiv := Equiv.inv _\n  map_rel_iff' := inv_le_inv\n#align submonoid.inv_order_iso Submonoid.invOrderIso\n#align add_submonoid.neg_order_iso AddSubmonoid.negOrderIso\n\n/- warning: submonoid.closure_inv -> Submonoid.closure_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (s : Set.{u1} G), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Inv.inv.{u1} (Set.{u1} G) (Set.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) s)) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) s))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (s : Set.{u1} G), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Inv.inv.{u1} (Set.{u1} G) (Set.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_3))))) s)) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) s))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_inv Submonoid.closure_invₓ'. -/\n@[to_additive]\ntheorem closure_inv (s : Set G) : closure s⁻¹ = (closure s)⁻¹ :=\n  by\n  apply le_antisymm\n  · rw [closure_le, coe_inv, ← Set.inv_subset, inv_inv]\n    exact subset_closure\n  · rw [inv_le, closure_le, coe_inv, ← Set.inv_subset]\n    exact subset_closure\n#align submonoid.closure_inv Submonoid.closure_inv\n#align add_submonoid.closure_neg AddSubmonoid.closure_neg\n\n/- warning: submonoid.inv_inf -> Submonoid.inv_inf is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Inf.inf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.hasInf.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) S T)) (Inf.inf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.hasInf.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Inf.inf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instInfSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) S T)) (Inf.inf.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instInfSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_inf Submonoid.inv_infₓ'. -/\n@[simp, to_additive]\ntheorem inv_inf (S T : Submonoid G) : (S ⊓ T)⁻¹ = S⁻¹ ⊓ T⁻¹ :=\n  SetLike.coe_injective Set.inter_inv\n#align submonoid.inv_inf Submonoid.inv_inf\n#align add_submonoid.neg_inf AddSubmonoid.neg_inf\n\n/- warning: submonoid.inv_sup -> Submonoid.inv_sup is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Sup.sup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SemilatticeSup.toHasSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.completeLattice.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) S T)) (Sup.sup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SemilatticeSup.toHasSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.completeLattice.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (T : Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Sup.sup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SemilatticeSup.toSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) S T)) (Sup.sup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SemilatticeSup.toSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Lattice.toSemilatticeSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) S) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_sup Submonoid.inv_supₓ'. -/\n@[simp, to_additive]\ntheorem inv_sup (S T : Submonoid G) : (S ⊔ T)⁻¹ = S⁻¹ ⊔ T⁻¹ :=\n  (invOrderIso : Submonoid G ≃o Submonoid G).map_sup S T\n#align submonoid.inv_sup Submonoid.inv_sup\n#align add_submonoid.neg_sup AddSubmonoid.neg_sup\n\n/- warning: submonoid.inv_bot -> Submonoid.inv_bot is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G], Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Bot.bot.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.hasBot.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) (Bot.bot.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.hasBot.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G], Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Bot.bot.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instBotSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) (Bot.bot.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instBotSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_bot Submonoid.inv_botₓ'. -/\n@[simp, to_additive]\ntheorem inv_bot : (⊥ : Submonoid G)⁻¹ = ⊥ :=\n  SetLike.coe_injective <| (Set.inv_singleton 1).trans <| congr_arg _ inv_one\n#align submonoid.inv_bot Submonoid.inv_bot\n#align add_submonoid.neg_bot AddSubmonoid.neg_bot\n\n/- warning: submonoid.inv_top -> Submonoid.inv_top is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G], Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Top.top.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.hasTop.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) (Top.top.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.hasTop.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G], Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (Top.top.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instTopSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) (Top.top.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instTopSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_top Submonoid.inv_topₓ'. -/\n@[simp, to_additive]\ntheorem inv_top : (⊤ : Submonoid G)⁻¹ = ⊤ :=\n  SetLike.coe_injective <| Set.inv_univ\n#align submonoid.inv_top Submonoid.inv_top\n#align add_submonoid.neg_top AddSubmonoid.neg_top\n\n#print Submonoid.inv_infᵢ /-\n@[simp, to_additive]\ntheorem inv_infᵢ {ι : Sort _} (S : ι → Submonoid G) : (⨅ i, S i)⁻¹ = ⨅ i, (S i)⁻¹ :=\n  (invOrderIso : Submonoid G ≃o Submonoid G).map_infᵢ _\n#align submonoid.inv_infi Submonoid.inv_infᵢ\n#align add_submonoid.neg_infi AddSubmonoid.neg_infᵢ\n-/\n\n/- warning: submonoid.inv_supr -> Submonoid.inv_supᵢ is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] {ι : Sort.{u2}} (S : ι -> (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (supᵢ.{u1, u2} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toHasSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.completeLattice.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) ι (fun (i : ι) => S i))) (supᵢ.{u1, u2} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toHasSup.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.completeLattice.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) ι (fun (i : ι) => Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (S i)))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] {ι : Sort.{u2}} (S : ι -> (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))), Eq.{succ u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (supᵢ.{u1, u2} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toSupSet.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) ι (fun (i : ι) => S i))) (supᵢ.{u1, u2} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (ConditionallyCompleteLattice.toSupSet.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.instCompleteLatticeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))))) ι (fun (i : ι) => Inv.inv.{u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (Submonoid.inv.{u1} G _inst_3) (S i)))\nCase conversion may be inaccurate. Consider using '#align submonoid.inv_supr Submonoid.inv_supᵢₓ'. -/\n@[simp, to_additive]\ntheorem inv_supᵢ {ι : Sort _} (S : ι → Submonoid G) : (⨆ i, S i)⁻¹ = ⨆ i, (S i)⁻¹ :=\n  (invOrderIso : Submonoid G ≃o Submonoid G).map_supᵢ _\n#align submonoid.inv_supr Submonoid.inv_supᵢ\n#align add_submonoid.neg_supr AddSubmonoid.neg_supᵢ\n\nend Submonoid\n\nnamespace Submonoid\n\nsection Monoid\n\nvariable [Monoid α] [MulDistribMulAction α M]\n\n#print Submonoid.pointwiseMulAction /-\n/-- The action on a submonoid corresponding to applying the action to every element.\n\nThis is available as an instance in the `pointwise` locale. -/\nprotected def pointwiseMulAction : MulAction α (Submonoid M)\n    where\n  smul a S := S.map (MulDistribMulAction.toMonoidEnd _ M a)\n  one_smul S := by\n    ext\n    simp\n  mul_smul a₁ a₂ S :=\n    (congr_arg (fun f : Monoid.End M => S.map f) (MonoidHom.map_mul _ _ _)).trans\n      (S.map_map _ _).symm\n#align submonoid.pointwise_mul_action Submonoid.pointwiseMulAction\n-/\n\nscoped[Pointwise] attribute [instance] Submonoid.pointwiseMulAction\n\nopen Pointwise\n\n/- warning: submonoid.coe_pointwise_smul -> Submonoid.coe_pointwise_smul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), Eq.{succ u2} (Set.{u2} M) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Set.{u2} M) (HasLiftT.mk.{succ u2, succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Set.{u2} M) (CoeTCₓ.coe.{succ u2, succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Set.{u2} M) (SetLike.Set.hasCoeT.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) a S)) (SMul.smul.{u1, u2} α (Set.{u2} M) (Set.smulSet.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} α M _inst_3 _inst_1 _inst_4))) a ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Set.{u2} M) (HasLiftT.mk.{succ u2, succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Set.{u2} M) (CoeTCₓ.coe.{succ u2, succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Set.{u2} M) (SetLike.Set.hasCoeT.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) S))\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), Eq.{succ u2} (Set.{u2} M) (SetLike.coe.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4))) a S)) (HSMul.hSMul.{u1, u2, u2} α (Set.{u2} M) (Set.{u2} M) (instHSMul.{u1, u2} α (Set.{u2} M) (Set.smulSet.{u1, u2} α M (MulAction.toSMul.{u1, u2} α M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} α M _inst_3 _inst_1 _inst_4)))) a (SetLike.coe.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.coe_pointwise_smul Submonoid.coe_pointwise_smulₓ'. -/\n@[simp]\ntheorem coe_pointwise_smul (a : α) (S : Submonoid M) : ↑(a • S) = a • (S : Set M) :=\n  rfl\n#align submonoid.coe_pointwise_smul Submonoid.coe_pointwise_smul\n\n/- warning: submonoid.smul_mem_pointwise_smul -> Submonoid.smul_mem_pointwise_smul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (m : M) (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) m S) -> (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} α M _inst_3 _inst_1 _inst_4)) a m) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) a S))\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (m : M) (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) m S) -> (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (HSMul.hSMul.{u1, u2, u2} α M M (instHSMul.{u1, u2} α M (MulAction.toSMul.{u1, u2} α M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} α M _inst_3 _inst_1 _inst_4))) a m) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4))) a S))\nCase conversion may be inaccurate. Consider using '#align submonoid.smul_mem_pointwise_smul Submonoid.smul_mem_pointwise_smulₓ'. -/\ntheorem smul_mem_pointwise_smul (m : M) (a : α) (S : Submonoid M) : m ∈ S → a • m ∈ a • S :=\n  (Set.smul_mem_smul_set : _ → _ ∈ a • (S : Set M))\n#align submonoid.smul_mem_pointwise_smul Submonoid.smul_mem_pointwise_smul\n\n/- warning: submonoid.mem_smul_pointwise_iff_exists -> Submonoid.mem_smul_pointwise_iff_exists is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (m : M) (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), Iff (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) m (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) a S)) (Exists.{succ u2} M (fun (s : M) => And (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) s S) (Eq.{succ u2} M (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} α M _inst_3 _inst_1 _inst_4)) a s) m)))\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (m : M) (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), Iff (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) m (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4))) a S)) (Exists.{succ u2} M (fun (s : M) => And (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) s S) (Eq.{succ u2} M (HSMul.hSMul.{u1, u2, u2} α M M (instHSMul.{u1, u2} α M (MulAction.toSMul.{u1, u2} α M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} α M _inst_3 _inst_1 _inst_4))) a s) m)))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_smul_pointwise_iff_exists Submonoid.mem_smul_pointwise_iff_existsₓ'. -/\ntheorem mem_smul_pointwise_iff_exists (m : M) (a : α) (S : Submonoid M) :\n    m ∈ a • S ↔ ∃ s : M, s ∈ S ∧ a • s = m :=\n  (Set.mem_smul_set : m ∈ a • (S : Set M) ↔ _)\n#align submonoid.mem_smul_pointwise_iff_exists Submonoid.mem_smul_pointwise_iff_exists\n\n/- warning: submonoid.smul_bot -> Submonoid.smul_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (a : α), Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) a (Bot.bot.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.hasBot.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))) (Bot.bot.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.hasBot.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (a : α), Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4))) a (Bot.bot.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instBotSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))) (Bot.bot.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instBotSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))\nCase conversion may be inaccurate. Consider using '#align submonoid.smul_bot Submonoid.smul_botₓ'. -/\n@[simp]\ntheorem smul_bot (a : α) : a • (⊥ : Submonoid M) = ⊥ :=\n  map_bot _\n#align submonoid.smul_bot Submonoid.smul_bot\n\n/- warning: submonoid.smul_sup -> Submonoid.smul_sup is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) a (Sup.sup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SemilatticeSup.toHasSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Lattice.toSemilatticeSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.completeLattice.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) S T)) (Sup.sup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SemilatticeSup.toHasSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Lattice.toSemilatticeSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.completeLattice.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) a S) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) a T))\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] (a : α) (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)), Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4))) a (Sup.sup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SemilatticeSup.toSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Lattice.toSemilatticeSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) S T)) (Sup.sup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SemilatticeSup.toSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Lattice.toSemilatticeSup.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (ConditionallyCompleteLattice.toLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4))) a T))\nCase conversion may be inaccurate. Consider using '#align submonoid.smul_sup Submonoid.smul_supₓ'. -/\ntheorem smul_sup (a : α) (S T : Submonoid M) : a • (S ⊔ T) = a • S ⊔ a • T :=\n  map_sup _ _ _\n#align submonoid.smul_sup Submonoid.smul_sup\n\n#print Submonoid.smul_closure /-\ntheorem smul_closure (a : α) (s : Set M) : a • closure s = closure (a • s) :=\n  MonoidHom.map_mclosure _ _\n#align submonoid.smul_closure Submonoid.smul_closure\n-/\n\n/- warning: submonoid.pointwise_central_scalar -> Submonoid.pointwise_isCentralScalar is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M _inst_3 _inst_1] [_inst_5 : MulDistribMulAction.{u1, u2} (MulOpposite.{u1} α) M (MulOpposite.monoid.{u1} α _inst_3) _inst_1] [_inst_6 : IsCentralScalar.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} α M _inst_3 _inst_1 _inst_4)) (MulAction.toHasSmul.{u1, u2} (MulOpposite.{u1} α) M (MulOpposite.monoid.{u1} α _inst_3) (MulDistribMulAction.toMulAction.{u1, u2} (MulOpposite.{u1} α) M (MulOpposite.monoid.{u1} α _inst_3) _inst_1 _inst_5))], IsCentralScalar.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 _inst_3 _inst_4)) (MulAction.toHasSmul.{u1, u2} (MulOpposite.{u1} α) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulOpposite.monoid.{u1} α _inst_3) (Submonoid.pointwiseMulAction.{u1, u2} (MulOpposite.{u1} α) M _inst_1 (MulOpposite.monoid.{u1} α _inst_3) _inst_5))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : Monoid.{u2} α] [_inst_4 : MulDistribMulAction.{u2, u1} α M _inst_3 _inst_1] [_inst_5 : MulDistribMulAction.{u2, u1} (MulOpposite.{u2} α) M (MulOpposite.monoid.{u2} α _inst_3) _inst_1] [_inst_6 : IsCentralScalar.{u2, u1} α M (MulAction.toSMul.{u2, u1} α M _inst_3 (MulDistribMulAction.toMulAction.{u2, u1} α M _inst_3 _inst_1 _inst_4)) (MulAction.toSMul.{u2, u1} (MulOpposite.{u2} α) M (MulOpposite.monoid.{u2} α _inst_3) (MulDistribMulAction.toMulAction.{u2, u1} (MulOpposite.{u2} α) M (MulOpposite.monoid.{u2} α _inst_3) _inst_1 _inst_5))], IsCentralScalar.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 _inst_3 _inst_4)) (MulAction.toSMul.{u2, u1} (MulOpposite.{u2} α) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulOpposite.monoid.{u2} α _inst_3) (Submonoid.pointwiseMulAction.{u2, u1} (MulOpposite.{u2} α) M _inst_1 (MulOpposite.monoid.{u2} α _inst_3) _inst_5))\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_central_scalar Submonoid.pointwise_isCentralScalarₓ'. -/\ninstance pointwise_isCentralScalar [MulDistribMulAction αᵐᵒᵖ M] [IsCentralScalar α M] :\n    IsCentralScalar α (Submonoid M) :=\n  ⟨fun a S => (congr_arg fun f : Monoid.End M => S.map f) <| MonoidHom.ext <| op_smul_eq_smul _⟩\n#align submonoid.pointwise_central_scalar Submonoid.pointwise_isCentralScalar\n\nend Monoid\n\nsection Group\n\nvariable [Group α] [MulDistribMulAction α M]\n\nopen Pointwise\n\n/- warning: submonoid.smul_mem_pointwise_smul_iff -> Submonoid.smul_mem_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {x : M}, Iff (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1 _inst_4)) a x) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x S)\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {x : M}, Iff (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (HSMul.hSMul.{u1, u2, u2} α M M (instHSMul.{u1, u2} α M (MulAction.toSMul.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1 _inst_4))) a x) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x S)\nCase conversion may be inaccurate. Consider using '#align submonoid.smul_mem_pointwise_smul_iff Submonoid.smul_mem_pointwise_smul_iffₓ'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff {a : α} {S : Submonoid M} {x : M} : a • x ∈ a • S ↔ x ∈ S :=\n  smul_mem_smul_set_iff\n#align submonoid.smul_mem_pointwise_smul_iff Submonoid.smul_mem_pointwise_smul_iff\n\n/- warning: submonoid.mem_pointwise_smul_iff_inv_smul_mem -> Submonoid.mem_pointwise_smul_iff_inv_smul_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {x : M}, Iff (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1 _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) x) S)\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {x : M}, Iff (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (HSMul.hSMul.{u1, u2, u2} α M M (instHSMul.{u1, u2} α M (MulAction.toSMul.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1 _inst_4))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) x) S)\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_pointwise_smul_iff_inv_smul_mem Submonoid.mem_pointwise_smul_iff_inv_smul_memₓ'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem {a : α} {S : Submonoid M} {x : M} :\n    x ∈ a • S ↔ a⁻¹ • x ∈ S :=\n  mem_smul_set_iff_inv_smul_mem\n#align submonoid.mem_pointwise_smul_iff_inv_smul_mem Submonoid.mem_pointwise_smul_iff_inv_smul_mem\n\n/- warning: submonoid.mem_inv_pointwise_smul_iff -> Submonoid.mem_inv_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {x : M}, Iff (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) S)) (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1 _inst_4)) a x) S)\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {x : M}, Iff (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) S)) (Membership.mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.instMembership.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (HSMul.hSMul.{u1, u2, u2} α M M (instHSMul.{u1, u2} α M (MulAction.toSMul.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1 _inst_4))) a x) S)\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_inv_pointwise_smul_iff Submonoid.mem_inv_pointwise_smul_iffₓ'. -/\ntheorem mem_inv_pointwise_smul_iff {a : α} {S : Submonoid M} {x : M} : x ∈ a⁻¹ • S ↔ a • x ∈ S :=\n  mem_inv_smul_set_iff\n#align submonoid.mem_inv_pointwise_smul_iff Submonoid.mem_inv_pointwise_smul_iff\n\n/- warning: submonoid.pointwise_smul_le_pointwise_smul_iff -> Submonoid.pointwise_smul_le_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) S T)\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a T)) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) S T)\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_smul_le_pointwise_smul_iff Submonoid.pointwise_smul_le_pointwise_smul_iffₓ'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff {a : α} {S T : Submonoid M} : a • S ≤ a • T ↔ S ≤ T :=\n  set_smul_subset_set_smul_iff\n#align submonoid.pointwise_smul_le_pointwise_smul_iff Submonoid.pointwise_smul_le_pointwise_smul_iff\n\n/- warning: submonoid.pointwise_smul_subset_iff -> Submonoid.pointwise_smul_subset_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S) T) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) S (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) T))\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S) T) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) S (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_smul_subset_iff Submonoid.pointwise_smul_subset_iffₓ'. -/\ntheorem pointwise_smul_subset_iff {a : α} {S T : Submonoid M} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=\n  set_smul_subset_iff\n#align submonoid.pointwise_smul_subset_iff Submonoid.pointwise_smul_subset_iff\n\n/- warning: submonoid.subset_pointwise_smul_iff -> Submonoid.subset_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) S (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) S) T)\nbut is expected to have type\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_1] {a : α} {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) S (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a T)) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)))))) (HSMul.hSMul.{u1, u2, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) S) T)\nCase conversion may be inaccurate. Consider using '#align submonoid.subset_pointwise_smul_iff Submonoid.subset_pointwise_smul_iffₓ'. -/\ntheorem subset_pointwise_smul_iff {a : α} {S T : Submonoid M} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=\n  subset_set_smul_iff\n#align submonoid.subset_pointwise_smul_iff Submonoid.subset_pointwise_smul_iff\n\nend Group\n\nsection GroupWithZero\n\nvariable [GroupWithZero α] [MulDistribMulAction α M]\n\nopen Pointwise\n\n/- warning: submonoid.smul_mem_pointwise_smul_iff₀ -> Submonoid.smul_mem_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (x : M), Iff (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1 _inst_4)) a x) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x S))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : MulDistribMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (x : M), Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (HSMul.hSMul.{u2, u1, u1} α M M (instHSMul.{u2, u1} α M (MulAction.toSMul.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (MulDistribMulAction.toMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1 _inst_4))) a x) (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x S))\nCase conversion may be inaccurate. Consider using '#align submonoid.smul_mem_pointwise_smul_iff₀ Submonoid.smul_mem_pointwise_smul_iff₀ₓ'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : Submonoid M) (x : M) :\n    a • x ∈ a • S ↔ x ∈ S :=\n  smul_mem_smul_set_iff₀ ha (S : Set M) x\n#align submonoid.smul_mem_pointwise_smul_iff₀ Submonoid.smul_mem_pointwise_smul_iff₀\n\n/- warning: submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ -> Submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (x : M), Iff (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1 _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) x) S))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : MulDistribMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (x : M), Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (HSMul.hSMul.{u2, u1, u1} α M M (instHSMul.{u2, u1} α M (MulAction.toSMul.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (MulDistribMulAction.toMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1 _inst_4))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) x) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ Submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ₓ'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem₀ {a : α} (ha : a ≠ 0) (S : Submonoid M) (x : M) :\n    x ∈ a • S ↔ a⁻¹ • x ∈ S :=\n  mem_smul_set_iff_inv_smul_mem₀ ha (S : Set M) x\n#align submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ Submonoid.mem_pointwise_smul_iff_inv_smul_mem₀\n\n/- warning: submonoid.mem_inv_pointwise_smul_iff₀ -> Submonoid.mem_inv_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall (S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (x : M), Iff (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) x (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) S)) (Membership.Mem.{u2, u2} M (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.hasMem.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))) (SMul.smul.{u1, u2} α M (MulAction.toHasSmul.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1 _inst_4)) a x) S))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : MulDistribMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (x : M), Iff (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) S)) (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (HSMul.hSMul.{u2, u1, u1} α M M (instHSMul.{u2, u1} α M (MulAction.toSMul.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (MulDistribMulAction.toMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1 _inst_4))) a x) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_inv_pointwise_smul_iff₀ Submonoid.mem_inv_pointwise_smul_iff₀ₓ'. -/\ntheorem mem_inv_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : Submonoid M) (x : M) :\n    x ∈ a⁻¹ • S ↔ a • x ∈ S :=\n  mem_inv_smul_set_iff₀ ha (S : Set M) x\n#align submonoid.mem_inv_pointwise_smul_iff₀ Submonoid.mem_inv_pointwise_smul_iff₀\n\n/- warning: submonoid.pointwise_smul_le_pointwise_smul_iff₀ -> Submonoid.pointwise_smul_le_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) S T))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : MulDistribMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall {S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)} {T : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)}, Iff (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a T)) (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) S T))\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_smul_le_pointwise_smul_iff₀ Submonoid.pointwise_smul_le_pointwise_smul_iff₀ₓ'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : Submonoid M} :\n    a • S ≤ a • T ↔ S ≤ T :=\n  set_smul_subset_set_smul_iff₀ ha\n#align submonoid.pointwise_smul_le_pointwise_smul_iff₀ Submonoid.pointwise_smul_le_pointwise_smul_iff₀\n\n/- warning: submonoid.pointwise_smul_le_iff₀ -> Submonoid.pointwise_smul_le_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S) T) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) S (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) T)))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : MulDistribMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall {S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)} {T : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)}, Iff (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S) T) (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) S (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) T)))\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_smul_le_iff₀ Submonoid.pointwise_smul_le_iff₀ₓ'. -/\ntheorem pointwise_smul_le_iff₀ {a : α} (ha : a ≠ 0) {S T : Submonoid M} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=\n  set_smul_subset_iff₀ ha\n#align submonoid.pointwise_smul_le_iff₀ Submonoid.pointwise_smul_le_iff₀\n\n/- warning: submonoid.le_pointwise_smul_iff₀ -> Submonoid.le_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : MulDistribMulAction.{u1, u2} α M (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall {S : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)} {T : Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)}, Iff (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) S (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Preorder.toLE.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (PartialOrder.toPreorder.{u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SetLike.partialOrder.{u2, u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) M (Submonoid.setLike.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1))))) (SMul.smul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} α (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} α M _inst_1 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) S) T))\nbut is expected to have type\n  forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : MulDistribMulAction.{u2, u1} α M (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_1] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall {S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)} {T : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)}, Iff (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) S (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a T)) (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (HSMul.hSMul.{u2, u1, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} α (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} α M _inst_1 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) S) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.le_pointwise_smul_iff₀ Submonoid.le_pointwise_smul_iff₀ₓ'. -/\ntheorem le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : Submonoid M} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=\n  subset_set_smul_iff₀ ha\n#align submonoid.le_pointwise_smul_iff₀ Submonoid.le_pointwise_smul_iff₀\n\nend GroupWithZero\n\nopen Pointwise\n\n/- warning: submonoid.mem_closure_inv -> Submonoid.mem_closure_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Set.{u1} G) (x : G), Iff (Membership.Mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) x (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Inv.inv.{u1} (Set.{u1} G) (Set.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) S))) (Membership.Mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.setLike.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)) x) (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) S))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] (S : Set.{u1} G) (x : G), Iff (Membership.mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.instSetLikeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) x (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) (Inv.inv.{u1} (Set.{u1} G) (Set.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_3))))) S))) (Membership.mem.{u1, u1} G (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3)))) G (Submonoid.instSetLikeSubmonoid.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))))) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_3)))) x) (Submonoid.closure.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_3))) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_closure_inv Submonoid.mem_closure_invₓ'. -/\n@[to_additive]\ntheorem mem_closure_inv {G : Type _} [Group G] (S : Set G) (x : G) :\n    x ∈ Submonoid.closure S⁻¹ ↔ x⁻¹ ∈ Submonoid.closure S := by rw [closure_inv, mem_inv]\n#align submonoid.mem_closure_inv Submonoid.mem_closure_inv\n#align add_submonoid.mem_closure_neg AddSubmonoid.mem_closure_neg\n\nend Submonoid\n\nnamespace AddSubmonoid\n\nsection Monoid\n\nvariable [Monoid α] [DistribMulAction α A]\n\n#print AddSubmonoid.pointwiseMulAction /-\n/-- The action on an additive submonoid corresponding to applying the action to every element.\n\nThis is available as an instance in the `pointwise` locale. -/\nprotected def pointwiseMulAction : MulAction α (AddSubmonoid A)\n    where\n  smul a S := S.map (DistribMulAction.toAddMonoidEnd _ A a)\n  one_smul S :=\n    (congr_arg (fun f : AddMonoid.End A => S.map f) (MonoidHom.map_one _)).trans S.map_id\n  mul_smul a₁ a₂ S :=\n    (congr_arg (fun f : AddMonoid.End A => S.map f) (MonoidHom.map_mul _ _ _)).trans\n      (S.map_map _ _).symm\n#align add_submonoid.pointwise_mul_action AddSubmonoid.pointwiseMulAction\n-/\n\nscoped[Pointwise] attribute [instance] AddSubmonoid.pointwiseMulAction\n\nopen Pointwise\n\n/- warning: add_submonoid.coe_pointwise_smul -> AddSubmonoid.coe_pointwise_smul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), Eq.{succ u2} (Set.{u2} A) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Set.{u2} A) (HasLiftT.mk.{succ u2, succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Set.{u2} A) (CoeTCₓ.coe.{succ u2, succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Set.{u2} A) (SetLike.Set.hasCoeT.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a S)) (SMul.smul.{u1, u2} α (Set.{u2} A) (Set.smulSet.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4)))) a ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Set.{u2} A) (HasLiftT.mk.{succ u2, succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Set.{u2} A) (CoeTCₓ.coe.{succ u2, succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Set.{u2} A) (SetLike.Set.hasCoeT.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) S))\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), Eq.{succ u2} (Set.{u2} A) (SetLike.coe.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a S)) (HSMul.hSMul.{u1, u2, u2} α (Set.{u2} A) (Set.{u2} A) (instHSMul.{u1, u2} α (Set.{u2} A) (Set.smulSet.{u1, u2} α A (SMulZeroClass.toSMul.{u1, u2} α A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4))))) a (SetLike.coe.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) S))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.coe_pointwise_smul AddSubmonoid.coe_pointwise_smulₓ'. -/\n@[simp]\ntheorem coe_pointwise_smul (a : α) (S : AddSubmonoid A) : ↑(a • S) = a • (S : Set A) :=\n  rfl\n#align add_submonoid.coe_pointwise_smul AddSubmonoid.coe_pointwise_smul\n\n/- warning: add_submonoid.smul_mem_pointwise_smul -> AddSubmonoid.smul_mem_pointwise_smul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (m : A) (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) m S) -> (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4))) a m) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a S))\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (m : A) (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) m S) -> (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (HSMul.hSMul.{u1, u2, u2} α A A (instHSMul.{u1, u2} α A (SMulZeroClass.toSMul.{u1, u2} α A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4)))) a m) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a S))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_mem_pointwise_smul AddSubmonoid.smul_mem_pointwise_smulₓ'. -/\ntheorem smul_mem_pointwise_smul (m : A) (a : α) (S : AddSubmonoid A) : m ∈ S → a • m ∈ a • S :=\n  (Set.smul_mem_smul_set : _ → _ ∈ a • (S : Set A))\n#align add_submonoid.smul_mem_pointwise_smul AddSubmonoid.smul_mem_pointwise_smul\n\n/- warning: add_submonoid.mem_smul_pointwise_iff_exists -> AddSubmonoid.mem_smul_pointwise_iff_exists is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (m : A) (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), Iff (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) m (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a S)) (Exists.{succ u2} A (fun (s : A) => And (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) s S) (Eq.{succ u2} A (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4))) a s) m)))\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (m : A) (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), Iff (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) m (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a S)) (Exists.{succ u2} A (fun (s : A) => And (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) s S) (Eq.{succ u2} A (HSMul.hSMul.{u1, u2, u2} α A A (instHSMul.{u1, u2} α A (SMulZeroClass.toSMul.{u1, u2} α A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4)))) a s) m)))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_smul_pointwise_iff_exists AddSubmonoid.mem_smul_pointwise_iff_existsₓ'. -/\ntheorem mem_smul_pointwise_iff_exists (m : A) (a : α) (S : AddSubmonoid A) :\n    m ∈ a • S ↔ ∃ s : A, s ∈ S ∧ a • s = m :=\n  (Set.mem_smul_set : m ∈ a • (S : Set A) ↔ _)\n#align add_submonoid.mem_smul_pointwise_iff_exists AddSubmonoid.mem_smul_pointwise_iff_exists\n\n/- warning: add_submonoid.smul_bot -> AddSubmonoid.smul_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a (Bot.bot.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.hasBot.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))) (Bot.bot.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.hasBot.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a (Bot.bot.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instBotAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))) (Bot.bot.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instBotAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_bot AddSubmonoid.smul_botₓ'. -/\n@[simp]\ntheorem smul_bot (a : α) : a • (⊥ : AddSubmonoid A) = ⊥ :=\n  map_bot _\n#align add_submonoid.smul_bot AddSubmonoid.smul_bot\n\n/- warning: add_submonoid.smul_sup -> AddSubmonoid.smul_sup is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a (Sup.sup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SemilatticeSup.toHasSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Lattice.toSemilatticeSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (ConditionallyCompleteLattice.toLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.completeLattice.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) S T)) (Sup.sup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SemilatticeSup.toHasSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Lattice.toSemilatticeSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (ConditionallyCompleteLattice.toLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.completeLattice.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a S) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a T))\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α) (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a (Sup.sup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SemilatticeSup.toSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Lattice.toSemilatticeSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (ConditionallyCompleteLattice.toLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) S T)) (Sup.sup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SemilatticeSup.toSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Lattice.toSemilatticeSup.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (ConditionallyCompleteLattice.toLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_sup AddSubmonoid.smul_supₓ'. -/\ntheorem smul_sup (a : α) (S T : AddSubmonoid A) : a • (S ⊔ T) = a • S ⊔ a • T :=\n  map_sup _ _ _\n#align add_submonoid.smul_sup AddSubmonoid.smul_sup\n\n/- warning: add_submonoid.smul_closure -> AddSubmonoid.smul_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α) (s : Set.{u2} A), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) a (AddSubmonoid.closure.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2) s)) (AddSubmonoid.closure.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (SMul.smul.{u1, u2} α (Set.{u2} A) (Set.smulSet.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4)))) a s))\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] (a : α) (s : Set.{u2} A), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4))) a (AddSubmonoid.closure.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2) s)) (AddSubmonoid.closure.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (HSMul.hSMul.{u1, u2, u2} α (Set.{u2} A) (Set.{u2} A) (instHSMul.{u1, u2} α (Set.{u2} A) (Set.smulSet.{u1, u2} α A (SMulZeroClass.toSMul.{u1, u2} α A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4))))) a s))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_closure AddSubmonoid.smul_closureₓ'. -/\n@[simp]\ntheorem smul_closure (a : α) (s : Set A) : a • closure s = closure (a • s) :=\n  AddMonoidHom.map_mclosure _ _\n#align add_submonoid.smul_closure AddSubmonoid.smul_closure\n\n/- warning: add_submonoid.pointwise_central_scalar -> AddSubmonoid.pointwise_isCentralScalar is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A _inst_3 _inst_2] [_inst_5 : DistribMulAction.{u1, u2} (MulOpposite.{u1} α) A (MulOpposite.monoid.{u1} α _inst_3) _inst_2] [_inst_6 : IsCentralScalar.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A _inst_3 _inst_2 _inst_4))) (SMulZeroClass.toHasSmul.{u1, u2} (MulOpposite.{u1} α) A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} (MulOpposite.{u1} α) A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} (MulOpposite.{u1} α) A (MulOpposite.monoid.{u1} α _inst_3) _inst_2 _inst_5)))], IsCentralScalar.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 _inst_3 _inst_4)) (MulAction.toHasSmul.{u1, u2} (MulOpposite.{u1} α) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulOpposite.monoid.{u1} α _inst_3) (AddSubmonoid.pointwiseMulAction.{u1, u2} (MulOpposite.{u1} α) A _inst_2 (MulOpposite.monoid.{u1} α _inst_3) _inst_5))\nbut is expected to have type\n  forall {α : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : Monoid.{u2} α] [_inst_4 : DistribMulAction.{u2, u1} α A _inst_3 _inst_2] [_inst_5 : DistribMulAction.{u2, u1} (MulOpposite.{u2} α) A (MulOpposite.monoid.{u2} α _inst_3) _inst_2] [_inst_6 : IsCentralScalar.{u2, u1} α A (SMulZeroClass.toSMul.{u2, u1} α A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} α A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} α A _inst_3 _inst_2 _inst_4))) (SMulZeroClass.toSMul.{u2, u1} (MulOpposite.{u2} α) A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} (MulOpposite.{u2} α) A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} (MulOpposite.{u2} α) A (MulOpposite.monoid.{u2} α _inst_3) _inst_2 _inst_5)))], IsCentralScalar.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 _inst_3 _inst_4)) (MulAction.toSMul.{u2, u1} (MulOpposite.{u2} α) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulOpposite.monoid.{u2} α _inst_3) (AddSubmonoid.pointwiseMulAction.{u2, u1} (MulOpposite.{u2} α) A _inst_2 (MulOpposite.monoid.{u2} α _inst_3) _inst_5))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_central_scalar AddSubmonoid.pointwise_isCentralScalarₓ'. -/\ninstance pointwise_isCentralScalar [DistribMulAction αᵐᵒᵖ A] [IsCentralScalar α A] :\n    IsCentralScalar α (AddSubmonoid A) :=\n  ⟨fun a S =>\n    (congr_arg fun f : AddMonoid.End A => S.map f) <| AddMonoidHom.ext <| op_smul_eq_smul _⟩\n#align add_submonoid.pointwise_central_scalar AddSubmonoid.pointwise_isCentralScalar\n\nend Monoid\n\nsection Group\n\nvariable [Group α] [DistribMulAction α A]\n\nopen Pointwise\n\n/- warning: add_submonoid.smul_mem_pointwise_smul_iff -> AddSubmonoid.smul_mem_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {x : A}, Iff (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2 _inst_4))) a x) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x S)\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {x : A}, Iff (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (HSMul.hSMul.{u1, u2, u2} α A A (instHSMul.{u1, u2} α A (SMulZeroClass.toSMul.{u1, u2} α A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2 _inst_4)))) a x) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x S)\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_mem_pointwise_smul_iff AddSubmonoid.smul_mem_pointwise_smul_iffₓ'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff {a : α} {S : AddSubmonoid A} {x : A} : a • x ∈ a • S ↔ x ∈ S :=\n  smul_mem_smul_set_iff\n#align add_submonoid.smul_mem_pointwise_smul_iff AddSubmonoid.smul_mem_pointwise_smul_iff\n\n/- warning: add_submonoid.mem_pointwise_smul_iff_inv_smul_mem -> AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {x : A}, Iff (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2 _inst_4))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) x) S)\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {x : A}, Iff (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (HSMul.hSMul.{u1, u2, u2} α A A (instHSMul.{u1, u2} α A (SMulZeroClass.toSMul.{u1, u2} α A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2 _inst_4)))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) x) S)\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_pointwise_smul_iff_inv_smul_mem AddSubmonoid.mem_pointwise_smul_iff_inv_smul_memₓ'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem {a : α} {S : AddSubmonoid A} {x : A} :\n    x ∈ a • S ↔ a⁻¹ • x ∈ S :=\n  mem_smul_set_iff_inv_smul_mem\n#align add_submonoid.mem_pointwise_smul_iff_inv_smul_mem AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem\n\n/- warning: add_submonoid.mem_inv_pointwise_smul_iff -> AddSubmonoid.mem_inv_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {x : A}, Iff (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) S)) (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2 _inst_4))) a x) S)\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {x : A}, Iff (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) S)) (Membership.mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.instMembership.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (HSMul.hSMul.{u1, u2, u2} α A A (instHSMul.{u1, u2} α A (SMulZeroClass.toSMul.{u1, u2} α A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2 _inst_4)))) a x) S)\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_inv_pointwise_smul_iff AddSubmonoid.mem_inv_pointwise_smul_iffₓ'. -/\ntheorem mem_inv_pointwise_smul_iff {a : α} {S : AddSubmonoid A} {x : A} : x ∈ a⁻¹ • S ↔ a • x ∈ S :=\n  mem_inv_smul_set_iff\n#align add_submonoid.mem_inv_pointwise_smul_iff AddSubmonoid.mem_inv_pointwise_smul_iff\n\n/- warning: add_submonoid.pointwise_smul_le_pointwise_smul_iff -> AddSubmonoid.pointwise_smul_le_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) S T)\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a T)) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) S T)\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_smul_le_pointwise_smul_iff AddSubmonoid.pointwise_smul_le_pointwise_smul_iffₓ'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff {a : α} {S T : AddSubmonoid A} :\n    a • S ≤ a • T ↔ S ≤ T :=\n  set_smul_subset_set_smul_iff\n#align add_submonoid.pointwise_smul_le_pointwise_smul_iff AddSubmonoid.pointwise_smul_le_pointwise_smul_iff\n\n/- warning: add_submonoid.pointwise_smul_le_iff -> AddSubmonoid.pointwise_smul_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a S) T) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) S (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) T))\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a S) T) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) S (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_smul_le_iff AddSubmonoid.pointwise_smul_le_iffₓ'. -/\ntheorem pointwise_smul_le_iff {a : α} {S T : AddSubmonoid A} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=\n  set_smul_subset_iff\n#align add_submonoid.pointwise_smul_le_iff AddSubmonoid.pointwise_smul_le_iff\n\n/- warning: add_submonoid.le_pointwise_smul_iff -> AddSubmonoid.le_pointwise_smul_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) S (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) a) S) T)\nbut is expected to have type\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_2] {a : α} {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) S (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) a T)) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)))))) (HSMul.hSMul.{u1, u2, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_3)) _inst_4))) (Inv.inv.{u1} α (InvOneClass.toInv.{u1} α (DivInvOneMonoid.toInvOneClass.{u1} α (DivisionMonoid.toDivInvOneMonoid.{u1} α (Group.toDivisionMonoid.{u1} α _inst_3)))) a) S) T)\nCase conversion may be inaccurate. Consider using '#align add_submonoid.le_pointwise_smul_iff AddSubmonoid.le_pointwise_smul_iffₓ'. -/\ntheorem le_pointwise_smul_iff {a : α} {S T : AddSubmonoid A} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=\n  subset_set_smul_iff\n#align add_submonoid.le_pointwise_smul_iff AddSubmonoid.le_pointwise_smul_iff\n\nend Group\n\nsection GroupWithZero\n\nvariable [GroupWithZero α] [DistribMulAction α A]\n\nopen Pointwise\n\n/- warning: add_submonoid.smul_mem_pointwise_smul_iff₀ -> AddSubmonoid.smul_mem_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (x : A), Iff (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2 _inst_4))) a x) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x S))\nbut is expected to have type\n  forall {α : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : DistribMulAction.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall (S : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (x : A), Iff (Membership.mem.{u1, u1} A (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2))) (HSMul.hSMul.{u2, u1, u1} α A A (instHSMul.{u2, u1} α A (SMulZeroClass.toSMul.{u2, u1} α A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} α A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2 _inst_4)))) a x) (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u1, u1} A (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2))) x S))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_mem_pointwise_smul_iff₀ AddSubmonoid.smul_mem_pointwise_smul_iff₀ₓ'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : AddSubmonoid A) (x : A) :\n    a • x ∈ a • S ↔ x ∈ S :=\n  smul_mem_smul_set_iff₀ ha (S : Set A) x\n#align add_submonoid.smul_mem_pointwise_smul_iff₀ AddSubmonoid.smul_mem_pointwise_smul_iff₀\n\n/- warning: add_submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ -> AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (x : A), Iff (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S)) (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2 _inst_4))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) x) S))\nbut is expected to have type\n  forall {α : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : DistribMulAction.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall (S : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (x : A), Iff (Membership.mem.{u1, u1} A (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2))) x (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S)) (Membership.mem.{u1, u1} A (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2))) (HSMul.hSMul.{u2, u1, u1} α A A (instHSMul.{u2, u1} α A (SMulZeroClass.toSMul.{u2, u1} α A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} α A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2 _inst_4)))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) x) S))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem₀ₓ'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem₀ {a : α} (ha : a ≠ 0) (S : AddSubmonoid A) (x : A) :\n    x ∈ a • S ↔ a⁻¹ • x ∈ S :=\n  mem_smul_set_iff_inv_smul_mem₀ ha (S : Set A) x\n#align add_submonoid.mem_pointwise_smul_iff_inv_smul_mem₀ AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem₀\n\n/- warning: add_submonoid.mem_inv_pointwise_smul_iff₀ -> AddSubmonoid.mem_inv_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall (S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (x : A), Iff (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) x (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) S)) (Membership.Mem.{u2, u2} A (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.hasMem.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))) (SMul.smul.{u1, u2} α A (SMulZeroClass.toHasSmul.{u1, u2} α A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} α A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2 _inst_4))) a x) S))\nbut is expected to have type\n  forall {α : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : DistribMulAction.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall (S : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (x : A), Iff (Membership.mem.{u1, u1} A (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2))) x (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) S)) (Membership.mem.{u1, u1} A (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) A (AddSubmonoid.instSetLikeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2))) (HSMul.hSMul.{u2, u1, u1} α A A (instHSMul.{u2, u1} α A (SMulZeroClass.toSMul.{u2, u1} α A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} α A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2 _inst_4)))) a x) S))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_inv_pointwise_smul_iff₀ AddSubmonoid.mem_inv_pointwise_smul_iff₀ₓ'. -/\ntheorem mem_inv_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : AddSubmonoid A) (x : A) :\n    x ∈ a⁻¹ • S ↔ a • x ∈ S :=\n  mem_inv_smul_set_iff₀ ha (S : Set A) x\n#align add_submonoid.mem_inv_pointwise_smul_iff₀ AddSubmonoid.mem_inv_pointwise_smul_iff₀\n\n/- warning: add_submonoid.pointwise_smul_le_pointwise_smul_iff₀ -> AddSubmonoid.pointwise_smul_le_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) S T))\nbut is expected to have type\n  forall {α : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : DistribMulAction.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall {S : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)} {T : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)}, Iff (LE.le.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (Preorder.toLE.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)))))) (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a T)) (LE.le.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (Preorder.toLE.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)))))) S T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_smul_le_pointwise_smul_iff₀ AddSubmonoid.pointwise_smul_le_pointwise_smul_iff₀ₓ'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : AddSubmonoid A} :\n    a • S ≤ a • T ↔ S ≤ T :=\n  set_smul_subset_set_smul_iff₀ ha\n#align add_submonoid.pointwise_smul_le_pointwise_smul_iff₀ AddSubmonoid.pointwise_smul_le_pointwise_smul_iff₀\n\n/- warning: add_submonoid.pointwise_smul_le_iff₀ -> AddSubmonoid.pointwise_smul_le_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a S) T) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) S (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) T)))\nbut is expected to have type\n  forall {α : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : DistribMulAction.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall {S : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)} {T : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)}, Iff (LE.le.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (Preorder.toLE.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)))))) (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a S) T) (LE.le.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (Preorder.toLE.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)))))) S (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) T)))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_smul_le_iff₀ AddSubmonoid.pointwise_smul_le_iff₀ₓ'. -/\ntheorem pointwise_smul_le_iff₀ {a : α} (ha : a ≠ 0) {S T : AddSubmonoid A} :\n    a • S ≤ T ↔ S ≤ a⁻¹ • T :=\n  set_smul_subset_iff₀ ha\n#align add_submonoid.pointwise_smul_le_iff₀ AddSubmonoid.pointwise_smul_le_iff₀\n\n/- warning: add_submonoid.le_pointwise_smul_iff₀ -> AddSubmonoid.le_pointwise_smul_iff₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} α] [_inst_4 : DistribMulAction.{u1, u2} α A (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u1} α a (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)))))))) -> (forall {S : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)} {T : AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)}, Iff (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) S (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) a T)) (LE.le.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (Preorder.toLE.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (PartialOrder.toPreorder.{u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SetLike.partialOrder.{u2, u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) A (AddSubmonoid.setLike.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2))))) (SMul.smul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} α (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} α A _inst_2 (MonoidWithZero.toMonoid.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_3)) _inst_4)) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_3)) a) S) T))\nbut is expected to have type\n  forall {α : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} α] [_inst_4 : DistribMulAction.{u2, u1} α A (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_2] {a : α}, (Ne.{succ u2} α a (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MonoidWithZero.toZero.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3))))) -> (forall {S : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)} {T : AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)}, Iff (LE.le.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (Preorder.toLE.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)))))) S (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) a T)) (LE.le.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (Preorder.toLE.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)))))) (HSMul.hSMul.{u2, u1, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} α (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} α A _inst_2 (MonoidWithZero.toMonoid.{u2} α (GroupWithZero.toMonoidWithZero.{u2} α _inst_3)) _inst_4))) (Inv.inv.{u2} α (GroupWithZero.toInv.{u2} α _inst_3) a) S) T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.le_pointwise_smul_iff₀ AddSubmonoid.le_pointwise_smul_iff₀ₓ'. -/\ntheorem le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : AddSubmonoid A} :\n    S ≤ a • T ↔ a⁻¹ • S ≤ T :=\n  subset_set_smul_iff₀ ha\n#align add_submonoid.le_pointwise_smul_iff₀ AddSubmonoid.le_pointwise_smul_iff₀\n\nend GroupWithZero\n\nend AddSubmonoid\n\n/-! ### Elementwise monoid structure of additive submonoids\n\nThese definitions are a cut-down versions of the ones around `submodule.has_mul`, as that API is\nusually more useful. -/\n\n\nnamespace AddSubmonoid\n\nopen Pointwise\n\nsection AddMonoidWithOne\n\nvariable [AddMonoidWithOne R]\n\ninstance : One (AddSubmonoid R) :=\n  ⟨(Nat.castAddMonoidHom R).mrange⟩\n\n#print AddSubmonoid.one_eq_mrange /-\ntheorem one_eq_mrange : (1 : AddSubmonoid R) = (Nat.castAddMonoidHom R).mrange :=\n  rfl\n#align add_submonoid.one_eq_mrange AddSubmonoid.one_eq_mrange\n-/\n\n/- warning: add_submonoid.nat_cast_mem_one -> AddSubmonoid.natCast_mem_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : AddMonoidWithOne.{u1} R] (n : Nat), Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R _inst_3)))) n) (OfNat.ofNat.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) 1 (OfNat.mk.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) 1 (One.one.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (AddSubmonoid.hasOne.{u1} R _inst_3))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : AddMonoidWithOne.{u1} R] (n : Nat), Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3)))) (Nat.cast.{u1} R (AddMonoidWithOne.toNatCast.{u1} R _inst_3) n) (OfNat.ofNat.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) 1 (One.toOfNat1.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (AddSubmonoid.one.{u1} R _inst_3)))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.nat_cast_mem_one AddSubmonoid.natCast_mem_oneₓ'. -/\ntheorem natCast_mem_one (n : ℕ) : (n : R) ∈ (1 : AddSubmonoid R) :=\n  ⟨_, rfl⟩\n#align add_submonoid.nat_cast_mem_one AddSubmonoid.natCast_mem_one\n\n/- warning: add_submonoid.mem_one -> AddSubmonoid.mem_one is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : AddMonoidWithOne.{u1} R] {x : R}, Iff (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3)))) x (OfNat.ofNat.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) 1 (OfNat.mk.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) 1 (One.one.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (AddSubmonoid.hasOne.{u1} R _inst_3))))) (Exists.{1} Nat (fun (n : Nat) => Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R _inst_3)))) n) x))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : AddMonoidWithOne.{u1} R] {x : R}, Iff (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3)))) x (OfNat.ofNat.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) 1 (One.toOfNat1.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R _inst_3))) (AddSubmonoid.one.{u1} R _inst_3)))) (Exists.{1} Nat (fun (n : Nat) => Eq.{succ u1} R (Nat.cast.{u1} R (AddMonoidWithOne.toNatCast.{u1} R _inst_3) n) x))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_one AddSubmonoid.mem_oneₓ'. -/\n@[simp]\ntheorem mem_one {x : R} : x ∈ (1 : AddSubmonoid R) ↔ ∃ n : ℕ, ↑n = x :=\n  Iff.rfl\n#align add_submonoid.mem_one AddSubmonoid.mem_one\n\n#print AddSubmonoid.one_eq_closure /-\ntheorem one_eq_closure : (1 : AddSubmonoid R) = closure {1} :=\n  by\n  simp only [closure_singleton_eq, mul_one, one_eq_mrange]\n  congr 1 with n\n  simp\n#align add_submonoid.one_eq_closure AddSubmonoid.one_eq_closure\n-/\n\n#print AddSubmonoid.one_eq_closure_one_set /-\ntheorem one_eq_closure_one_set : (1 : AddSubmonoid R) = closure 1 :=\n  one_eq_closure\n#align add_submonoid.one_eq_closure_one_set AddSubmonoid.one_eq_closure_one_set\n-/\n\nend AddMonoidWithOne\n\nsection NonUnitalNonAssocSemiring\n\nvariable [NonUnitalNonAssocSemiring R]\n\n/-- Multiplication of additive submonoids of a semiring R. The additive submonoid `S * T` is the\nsmallest R-submodule of `R` containing the elements `s * t` for `s ∈ S` and `t ∈ T`. -/\ninstance : Mul (AddSubmonoid R) :=\n  ⟨fun M N => ⨆ s : M, N.map <| AddMonoidHom.mul s.1⟩\n\n/- warning: add_submonoid.mul_mem_mul -> AddSubmonoid.mul_mem_mul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {m : R} {n : R}, (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) m M) -> (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) n N) -> (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3))) m n) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M N))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {m : R} {n : R}, (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) m M) -> (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) n N) -> (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_3)) m n) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M N))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_mem_mul AddSubmonoid.mul_mem_mulₓ'. -/\ntheorem mul_mem_mul {M N : AddSubmonoid R} {m n : R} (hm : m ∈ M) (hn : n ∈ N) : m * n ∈ M * N :=\n  (le_supᵢ _ ⟨m, hm⟩ : _ ≤ M * N) ⟨n, hn, rfl⟩\n#align add_submonoid.mul_mem_mul AddSubmonoid.mul_mem_mul\n\n/- warning: add_submonoid.mul_le -> AddSubmonoid.mul_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, Iff (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M N) P) (forall (m : R), (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) m M) -> (forall (n : R), (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) n N) -> (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3))) m n) P)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, Iff (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M N) P) (forall (m : R), (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) m M) -> (forall (n : R), (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) n N) -> (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_3)) m n) P)))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_le AddSubmonoid.mul_leₓ'. -/\ntheorem mul_le {M N P : AddSubmonoid R} : M * N ≤ P ↔ ∀ m ∈ M, ∀ n ∈ N, m * n ∈ P :=\n  ⟨fun H m hm n hn => H <| mul_mem_mul hm hn, fun H =>\n    supᵢ_le fun ⟨m, hm⟩ => map_le_iff_le_comap.2 fun n hn => H m hm n hn⟩\n#align add_submonoid.mul_le AddSubmonoid.mul_le\n\n/- warning: add_submonoid.mul_induction_on -> AddSubmonoid.mul_induction_on is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {C : R -> Prop} {r : R}, (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) r (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M N)) -> (forall (m : R), (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) m M) -> (forall (n : R), (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) n N) -> (C (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3))) m n)))) -> (forall (x : R) (y : R), (C x) -> (C y) -> (C (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3))) x y))) -> (C r)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {C : R -> Prop} {r : R}, (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) r (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M N)) -> (forall (m : R), (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) m M) -> (forall (n : R), (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) n N) -> (C (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_3)) m n)))) -> (forall (x : R) (y : R), (C x) -> (C y) -> (C (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3))) x y))) -> (C r)\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_induction_on AddSubmonoid.mul_induction_onₓ'. -/\n@[elab_as_elim]\nprotected theorem mul_induction_on {M N : AddSubmonoid R} {C : R → Prop} {r : R} (hr : r ∈ M * N)\n    (hm : ∀ m ∈ M, ∀ n ∈ N, C (m * n)) (ha : ∀ x y, C x → C y → C (x + y)) : C r :=\n  (@mul_le _ _ _ _\n        ⟨C, ha, by simpa only [MulZeroClass.zero_mul] using hm _ (zero_mem _) _ (zero_mem _)⟩).2\n    hm hr\n#align add_submonoid.mul_induction_on AddSubmonoid.mul_induction_on\n\nopen Pointwise\n\n/- warning: add_submonoid.closure_mul_closure -> AddSubmonoid.closure_mul_closure is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (S : Set.{u1} R) (T : Set.{u1} R), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) S) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) T)) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) (HMul.hMul.{u1, u1, u1} (Set.{u1} R) (Set.{u1} R) (Set.{u1} R) (instHMul.{u1} (Set.{u1} R) (Set.mul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3)))) S T))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (S : Set.{u1} R) (T : Set.{u1} R), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) S) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) T)) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) (HMul.hMul.{u1, u1, u1} (Set.{u1} R) (Set.{u1} R) (Set.{u1} R) (instHMul.{u1} (Set.{u1} R) (Set.mul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_3))) S T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.closure_mul_closure AddSubmonoid.closure_mul_closureₓ'. -/\n-- this proof is copied directly from `submodule.span_mul_span`\ntheorem closure_mul_closure (S T : Set R) : closure S * closure T = closure (S * T) :=\n  by\n  apply le_antisymm\n  · rw [mul_le]\n    intro a ha b hb\n    apply closure_induction ha\n    on_goal 1 =>\n      intros ; apply closure_induction hb\n      on_goal 1 => intros ; exact subset_closure ⟨_, _, ‹_›, ‹_›, rfl⟩\n    all_goals intros ;\n      simp only [MulZeroClass.mul_zero, MulZeroClass.zero_mul, zero_mem, left_distrib,\n          right_distrib, mul_smul_comm, smul_mul_assoc] <;>\n        solve_by_elim (config :=\n          { max_depth := 4\n            discharger := tactic.interactive.apply_instance }) [add_mem _ _, zero_mem _]\n  · rw [closure_le]\n    rintro _ ⟨a, b, ha, hb, rfl⟩\n    exact mul_mem_mul (subset_closure ha) (subset_closure hb)\n#align add_submonoid.closure_mul_closure AddSubmonoid.closure_mul_closure\n\n/- warning: add_submonoid.mul_eq_closure_mul_set -> AddSubmonoid.mul_eq_closure_mul_set is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M N) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) (HMul.hMul.{u1, u1, u1} (Set.{u1} R) (Set.{u1} R) (Set.{u1} R) (instHMul.{u1} (Set.{u1} R) (Set.mul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) N)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M N) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))) (HMul.hMul.{u1, u1, u1} (Set.{u1} R) (Set.{u1} R) (Set.{u1} R) (instHMul.{u1} (Set.{u1} R) (Set.mul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_3))) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) M) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) N)))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_eq_closure_mul_set AddSubmonoid.mul_eq_closure_mul_setₓ'. -/\ntheorem mul_eq_closure_mul_set (M N : AddSubmonoid R) : M * N = closure (M * N) := by\n  rw [← closure_mul_closure, closure_eq, closure_eq]\n#align add_submonoid.mul_eq_closure_mul_set AddSubmonoid.mul_eq_closure_mul_set\n\n/- warning: add_submonoid.mul_bot -> AddSubmonoid.mul_bot is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (S : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) S (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasBot.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))) (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasBot.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (S : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) S (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instBotAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))) (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instBotAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_bot AddSubmonoid.mul_botₓ'. -/\n@[simp]\ntheorem mul_bot (S : AddSubmonoid R) : S * ⊥ = ⊥ :=\n  eq_bot_iff.2 <|\n    mul_le.2 fun m hm n hn => by rw [AddSubmonoid.mem_bot] at hn⊢ <;> rw [hn, MulZeroClass.mul_zero]\n#align add_submonoid.mul_bot AddSubmonoid.mul_bot\n\n/- warning: add_submonoid.bot_mul -> AddSubmonoid.bot_mul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (S : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasBot.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) S) (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasBot.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] (S : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instBotAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))) S) (Bot.bot.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instBotAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.bot_mul AddSubmonoid.bot_mulₓ'. -/\n@[simp]\ntheorem bot_mul (S : AddSubmonoid R) : ⊥ * S = ⊥ :=\n  eq_bot_iff.2 <|\n    mul_le.2 fun m hm n hn => by rw [AddSubmonoid.mem_bot] at hm⊢ <;> rw [hm, MulZeroClass.zero_mul]\n#align add_submonoid.bot_mul AddSubmonoid.bot_mul\n\n/- warning: add_submonoid.mul_le_mul -> AddSubmonoid.mul_le_mul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {Q : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) M P) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) N Q) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M N) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) P Q))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {Q : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) M P) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) N Q) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M N) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) P Q))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_le_mul AddSubmonoid.mul_le_mulₓ'. -/\n@[mono]\ntheorem mul_le_mul {M N P Q : AddSubmonoid R} (hmp : M ≤ P) (hnq : N ≤ Q) : M * N ≤ P * Q :=\n  mul_le.2 fun m hm n hn => mul_mem_mul (hmp hm) (hnq hn)\n#align add_submonoid.mul_le_mul AddSubmonoid.mul_le_mul\n\n/- warning: add_submonoid.mul_le_mul_left -> AddSubmonoid.mul_le_mul_left is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) M N) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M P) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) N P))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) M N) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M P) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) N P))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_le_mul_left AddSubmonoid.mul_le_mul_leftₓ'. -/\ntheorem mul_le_mul_left {M N P : AddSubmonoid R} (h : M ≤ N) : M * P ≤ N * P :=\n  mul_le_mul h (le_refl P)\n#align add_submonoid.mul_le_mul_left AddSubmonoid.mul_le_mul_left\n\n/- warning: add_submonoid.mul_le_mul_right -> AddSubmonoid.mul_le_mul_right is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) N P) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M N) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M P))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {P : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) N P) -> (LE.le.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Preorder.toLE.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M N) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M P))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_le_mul_right AddSubmonoid.mul_le_mul_rightₓ'. -/\ntheorem mul_le_mul_right {M N P : AddSubmonoid R} (h : N ≤ P) : M * N ≤ M * P :=\n  mul_le_mul (le_refl M) h\n#align add_submonoid.mul_le_mul_right AddSubmonoid.mul_le_mul_right\n\n/- warning: add_submonoid.mul_subset_mul -> AddSubmonoid.mul_subset_mul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) (HMul.hMul.{u1, u1, u1} (Set.{u1} R) (Set.{u1} R) (Set.{u1} R) (instHMul.{u1} (Set.{u1} R) (Set.mul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R _inst_3)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) N)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3))))))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.hasMul.{u1} R _inst_3)) M N))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocSemiring.{u1} R] {M : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))} {N : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (HMul.hMul.{u1, u1, u1} (Set.{u1} R) (Set.{u1} R) (Set.{u1} R) (instHMul.{u1} (Set.{u1} R) (Set.mul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R _inst_3))) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) M) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) N)) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (HMul.hMul.{u1, u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (instHMul.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R _inst_3)))) (AddSubmonoid.mul.{u1} R _inst_3)) M N))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mul_subset_mul AddSubmonoid.mul_subset_mulₓ'. -/\ntheorem mul_subset_mul {M N : AddSubmonoid R} : (↑M : Set R) * (↑N : Set R) ⊆ (↑(M * N) : Set R) :=\n  by\n  rintro _ ⟨i, j, hi, hj, rfl⟩\n  exact mul_mem_mul hi hj\n#align add_submonoid.mul_subset_mul AddSubmonoid.mul_subset_mul\n\nend NonUnitalNonAssocSemiring\n\nsection NonUnitalNonAssocRing\n\nvariable [NonUnitalNonAssocRing R]\n\n/- warning: add_submonoid.has_distrib_neg -> AddSubmonoid.hasDistribNeg is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocRing.{u1} R], HasDistribNeg.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (SubNegMonoid.toAddMonoid.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddCommGroup.toAddGroup.{u1} R (NonUnitalNonAssocRing.toAddCommGroup.{u1} R _inst_3)))))) (AddSubmonoid.hasMul.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R _inst_3))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : NonUnitalNonAssocRing.{u1} R], HasDistribNeg.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (SubNegMonoid.toAddMonoid.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddCommGroup.toAddGroup.{u1} R (NonUnitalNonAssocRing.toAddCommGroup.{u1} R _inst_3)))))) (AddSubmonoid.mul.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R _inst_3))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.has_distrib_neg AddSubmonoid.hasDistribNegₓ'. -/\n/-- `add_submonoid.has_pointwise_neg` distributes over multiplication.\n\nThis is available as an instance in the `pointwise` locale. -/\nprotected def hasDistribNeg : HasDistribNeg (AddSubmonoid R) :=\n  { AddSubmonoid.hasInvolutiveNeg with\n    neg := Neg.neg\n    neg_mul := fun x y =>\n      by\n      refine'\n          le_antisymm (mul_le.2 fun m hm n hn => _)\n            ((AddSubmonoid.neg_le _ _).2 <| mul_le.2 fun m hm n hn => _) <;>\n        simp only [AddSubmonoid.mem_neg, ← neg_mul] at *\n      · exact mul_mem_mul hm hn\n      · exact mul_mem_mul (neg_mem_neg.2 hm) hn\n    mul_neg := fun x y =>\n      by\n      refine'\n          le_antisymm (mul_le.2 fun m hm n hn => _)\n            ((AddSubmonoid.neg_le _ _).2 <| mul_le.2 fun m hm n hn => _) <;>\n        simp only [AddSubmonoid.mem_neg, ← mul_neg] at *\n      · exact mul_mem_mul hm hn\n      · exact mul_mem_mul hm (neg_mem_neg.2 hn) }\n#align add_submonoid.has_distrib_neg AddSubmonoid.hasDistribNeg\n\nscoped[Pointwise] attribute [instance] AddSubmonoid.hasDistribNeg\n\nend NonUnitalNonAssocRing\n\nsection NonAssocSemiring\n\nvariable [NonAssocSemiring R]\n\ninstance : MulOneClass (AddSubmonoid R) where\n  one := 1\n  mul := (· * ·)\n  one_mul M := by rw [one_eq_closure_one_set, ← closure_eq M, closure_mul_closure, one_mul]\n  mul_one M := by rw [one_eq_closure_one_set, ← closure_eq M, closure_mul_closure, mul_one]\n\nend NonAssocSemiring\n\nsection NonUnitalSemiring\n\nvariable [NonUnitalSemiring R]\n\ninstance : Semigroup (AddSubmonoid R) where\n  mul := (· * ·)\n  mul_assoc M N P :=\n    le_antisymm\n      (mul_le.2 fun mn hmn p hp =>\n        suffices M * N ≤ (M * (N * P)).comap (AddMonoidHom.mulRight p) from this hmn\n        mul_le.2 fun m hm n hn =>\n          show m * n * p ∈ M * (N * P) from\n            (mul_assoc m n p).symm ▸ mul_mem_mul hm (mul_mem_mul hn hp))\n      (mul_le.2 fun m hm np hnp =>\n        suffices N * P ≤ (M * N * P).comap (AddMonoidHom.mulLeft m) from this hnp\n        mul_le.2 fun n hn p hp =>\n          show m * (n * p) ∈ M * N * P from mul_assoc m n p ▸ mul_mem_mul (mul_mem_mul hm hn) hp)\n\nend NonUnitalSemiring\n\nsection Semiring\n\nvariable [Semiring R]\n\ninstance : Monoid (AddSubmonoid R) :=\n  { AddSubmonoid.semigroup,\n    AddSubmonoid.mulOneClass with\n    one := 1\n    mul := (· * ·) }\n\n/- warning: add_submonoid.closure_pow -> AddSubmonoid.closure_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : Semiring.{u1} R] (s : Set.{u1} R) (n : Nat), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (HPow.hPow.{u1, 0, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (instHPow.{u1, 0} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (Monoid.Pow.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (AddSubmonoid.monoid.{u1} R _inst_3))) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) s) n) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) (HPow.hPow.{u1, 0, u1} (Set.{u1} R) Nat (Set.{u1} R) (instHPow.{u1, 0} (Set.{u1} R) Nat (Set.NPow.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) s n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : Semiring.{u1} R] (s : Set.{u1} R) (n : Nat), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (HPow.hPow.{u1, 0, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (instHPow.{u1, 0} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (Monoid.Pow.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (AddSubmonoid.monoid.{u1} R _inst_3))) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) s) n) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) (HPow.hPow.{u1, 0, u1} (Set.{u1} R) Nat (Set.{u1} R) (instHPow.{u1, 0} (Set.{u1} R) Nat (Set.NPow.{u1} R (Semiring.toOne.{u1} R _inst_3) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) s n))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.closure_pow AddSubmonoid.closure_powₓ'. -/\ntheorem closure_pow (s : Set R) : ∀ n : ℕ, closure s ^ n = closure (s ^ n)\n  | 0 => by rw [pow_zero, pow_zero, one_eq_closure_one_set]\n  | n + 1 => by rw [pow_succ, pow_succ, closure_pow, closure_mul_closure]\n#align add_submonoid.closure_pow AddSubmonoid.closure_pow\n\n/- warning: add_submonoid.pow_eq_closure_pow_set -> AddSubmonoid.pow_eq_closure_pow_set is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : Semiring.{u1} R] (s : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (n : Nat), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (HPow.hPow.{u1, 0, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (instHPow.{u1, 0} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (Monoid.Pow.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (AddSubmonoid.monoid.{u1} R _inst_3))) s n) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) (HPow.hPow.{u1, 0, u1} (Set.{u1} R) Nat (Set.{u1} R) (instHPow.{u1, 0} (Set.{u1} R) Nat (Set.NPow.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))))))) s) n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : Semiring.{u1} R] (s : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (n : Nat), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (HPow.hPow.{u1, 0, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (instHPow.{u1, 0} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (Monoid.Pow.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (AddSubmonoid.monoid.{u1} R _inst_3))) s n) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) (HPow.hPow.{u1, 0, u1} (Set.{u1} R) Nat (Set.{u1} R) (instHPow.{u1, 0} (Set.{u1} R) Nat (Set.NPow.{u1} R (Semiring.toOne.{u1} R _inst_3) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) s) n))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pow_eq_closure_pow_set AddSubmonoid.pow_eq_closure_pow_setₓ'. -/\ntheorem pow_eq_closure_pow_set (s : AddSubmonoid R) (n : ℕ) : s ^ n = closure ((s : Set R) ^ n) :=\n  by rw [← closure_pow, closure_eq]\n#align add_submonoid.pow_eq_closure_pow_set AddSubmonoid.pow_eq_closure_pow_set\n\n/- warning: add_submonoid.pow_subset_pow -> AddSubmonoid.pow_subset_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_3 : Semiring.{u1} R] {s : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))} {n : Nat}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) (HPow.hPow.{u1, 0, u1} (Set.{u1} R) Nat (Set.{u1} R) (instHPow.{u1, 0} (Set.{u1} R) Nat (Set.NPow.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))))))) s) n) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))))))) (HPow.hPow.{u1, 0, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (instHPow.{u1, 0} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (Monoid.Pow.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (AddSubmonoid.monoid.{u1} R _inst_3))) s n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_3 : Semiring.{u1} R] {s : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))} {n : Nat}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) (HPow.hPow.{u1, 0, u1} (Set.{u1} R) Nat (Set.{u1} R) (instHPow.{u1, 0} (Set.{u1} R) Nat (Set.NPow.{u1} R (Semiring.toOne.{u1} R _inst_3) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) s) n) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (HPow.hPow.{u1, 0, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (instHPow.{u1, 0} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) Nat (Monoid.Pow.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))))) (AddSubmonoid.monoid.{u1} R _inst_3))) s n))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pow_subset_pow AddSubmonoid.pow_subset_powₓ'. -/\ntheorem pow_subset_pow {s : AddSubmonoid R} {n : ℕ} : (↑s : Set R) ^ n ⊆ ↑(s ^ n) :=\n  (pow_eq_closure_pow_set s n).symm ▸ subset_closure\n#align add_submonoid.pow_subset_pow AddSubmonoid.pow_subset_pow\n\nend Semiring\n\nend AddSubmonoid\n\nnamespace Set.IsPwo\n\nvariable [OrderedCancelCommMonoid α] {s : Set α}\n\n/- warning: set.is_pwo.submonoid_closure -> Set.IsPwo.submonoid_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_3 : OrderedCancelCommMonoid.{u1} α] {s : Set.{u1} α}, (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelCommMonoid.toPartialOrder.{u1} α _inst_3))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3))))))))) x)) -> (Set.IsPwo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelCommMonoid.toPartialOrder.{u1} α _inst_3)) s) -> (Set.IsPwo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelCommMonoid.toPartialOrder.{u1} α _inst_3)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3)))))) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3)))))) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3)))))) (Set.{u1} α) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3)))))) α (Submonoid.setLike.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3))))))))) (Submonoid.closure.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3))))) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_3 : OrderedCancelCommMonoid.{u1} α] {s : Set.{u1} α}, (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelCommMonoid.toPartialOrder.{u1} α _inst_3))) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (RightCancelMonoid.toOne.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3)))))) x)) -> (Set.IsPwo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelCommMonoid.toPartialOrder.{u1} α _inst_3)) s) -> (Set.IsPwo.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelCommMonoid.toPartialOrder.{u1} α _inst_3)) (SetLike.coe.{u1, u1} (Submonoid.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3)))))) α (Submonoid.instSetLikeSubmonoid.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3)))))) (Submonoid.closure.{u1} α (Monoid.toMulOneClass.{u1} α (RightCancelMonoid.toMonoid.{u1} α (CancelMonoid.toRightCancelMonoid.{u1} α (CancelCommMonoid.toCancelMonoid.{u1} α (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} α _inst_3))))) s)))\nCase conversion may be inaccurate. Consider using '#align set.is_pwo.submonoid_closure Set.IsPwo.submonoid_closureₓ'. -/\n@[to_additive]\ntheorem submonoid_closure (hpos : ∀ x : α, x ∈ s → 1 ≤ x) (h : s.IsPwo) :\n    IsPwo (Submonoid.closure s : Set α) :=\n  by\n  rw [Submonoid.closure_eq_image_prod]\n  refine' (h.partially_well_ordered_on_sublist_forall₂ (· ≤ ·)).image_of_monotone_on _\n  exact fun l1 hl1 l2 hl2 h12 => h12.prod_le_prod' fun x hx => hpos x <| hl2 x hx\n#align set.is_pwo.submonoid_closure Set.IsPwo.submonoid_closure\n#align set.is_pwo.add_submonoid_closure Set.IsPwo.addSubmonoid_closure\n\nend Set.IsPwo\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/GroupTheory/Submonoid/Pointwise.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4781603042931222}}
{"text": "/-= Chapter 7: Inductive types =-/\n\n/- Enumerated types -/\nnamespace enumerated_types\n\ninductive Weekday where\n| sunday : Weekday\n| monday : Weekday\n| tuesday : Weekday\n| wednesday : Weekday\n| thursday : Weekday\n| friday : Weekday\n| saturday : Weekday\n\n#check Weekday.sunday\n#check Weekday.monday\n\nsection\nopen Weekday\n\n#check sunday\n#check monday\nend\n\nnamespace omit_type\n\ninductive Weekday where\n| sunday\n| monday\n| tuesday\n| wednesday\n| thursday\n| friday\n| saturday\n\nend omit_type\n\nsection\nopen Weekday\ndef numberOfDay (d : Weekday) : Nat :=\n  match d with\n  | sunday => 1\n  | monday => 2\n  | tuesday => 3\n  | wednesday => 4\n  | thursday => 5\n  | friday => 6\n  | saturday => 7\nend\n\n#eval numberOfDay Weekday.sunday\n#eval numberOfDay Weekday.monday\n#eval numberOfDay Weekday.tuesday\n\nsection pretty_print\n\nset_option pp.all true\n#print numberOfDay\n#print numberOfDay.match_1\n#print Weekday.casesOn\n#check @Weekday.rec\n#print Weekday.rec\n\nend pretty_print\n\nnamespace repr\n\ninductive Weekday where\n| sunday\n| monday\n| tuesday\n| wednesday\n| thursday\n| friday\n| saturday\nderiving Repr\n\nopen Weekday\n\n#eval tuesday\n\nend repr\n\nnamespace add_to_namespace\n\ninductive Weekday where\n| sunday\n| monday\n| tuesday\n| wednesday\n| thursday\n| friday\n| saturday\nderiving Repr\n\nnamespace Weekday\n\ndef next (d : Weekday) : Weekday :=\n  match d with\n  | sunday => monday\n  | monday => tuesday\n  | tuesday => wednesday\n  | wednesday => thursday\n  | thursday => friday\n  | friday => saturday\n  | saturday => sunday\n\ndef previous (d : Weekday) : Weekday :=\n  match d with\n  | sunday => saturday\n  | monday => sunday\n  | tuesday => monday\n  | wednesday => tuesday\n  | thursday => wednesday\n  | friday => thursday\n  | saturday => friday\n\n#eval next (next tuesday)\n#eval next (previous tuesday)\n\nexample : next (previous tuesday) = tuesday :=\n  rfl\n\ndef next_previous (d : Weekday) : next (previous d) = d :=\n  match d with\n  | sunday => rfl\n  | monday => rfl\n  | tuesday => rfl\n  | wednesday => rfl\n  | thursday => rfl\n  | friday => rfl\n  | saturday => rfl\n\nnamespace tactic_version\n\ndef next_previous (d : Weekday) : next (previous d) = d := by\n  cases d <;> rfl\n\nend tactic_version\n\nend Weekday\n\nend add_to_namespace\n\nnamespace bool\n\ninductive Bool where\n| false\n| true\n\nnamespace Bool\n\ndef and (p q : Bool) : Bool :=\n  match p with\n  | true => q\n  | false => false\n\ndef or (p q : Bool) : Bool :=\n  match p with\n  | true => true\n  | false => q\n\ndef not (p : Bool) : Bool :=\n  match p with\n  | true => false\n  | false => true\n\nexample (p : Bool) : not (not p) = p := by\n  match p with\n  | true => rfl\n  | false => rfl\n\nexample (p q : Bool) : and p q = and q p := by\n  match p, q with\n  | true, true => rfl\n  | true, false => rfl\n  | false, true => rfl\n  | false, false => rfl\n\nend Bool\n\nend bool\n\nend enumerated_types\n\n/- Constructors with arguments -/\nnamespace constructors_with_arguments\n\nnamespace prod_and_sum\n\ninductive Prod (α : Type u) (β : Type v)\n| mk : α → β → Prod α β\n\ninductive Sum (α : Type u) (β : Type v) where\n| inl : α → Sum α β\n| inr : β → Sum α β\n\ndef fst {α : Type u} {β : Type v} (p : Prod α β) : α :=\n  match p with\n  | Prod.mk a b => a\n\ndef snd {α : Type u} {β : Type v} (p : Prod α β) : β :=\n  match p with\n  | Prod.mk a b => b\n\nend prod_and_sum\n\n#check Prod.casesOn\n\ndef prod_example (p : Bool × Nat) : Nat :=\n  Prod.casesOn (motive := λ _ => Nat) p (λ b n => cond b (2 * n) (2 * n + 1))\n\n#eval prod_example (true, 3)\n#eval prod_example (false, 3)\n\ndef sum_example (s : Sum Nat Nat) : Nat :=\n  Sum.casesOn (motive := λ _ => Nat) s (λ n => 2 * n) (λ n => 2 * n + 1)\n\n#eval sum_example (Sum.inl 3)\n#eval sum_example (Sum.inr 3)\n\nnamespace named_arguments\n\ninductive Prod (α : Type u) (β : Type v)\n| mk (fst : α) (snd : β) : Prod α β\n\ninductive Sum (α : Type u) (β : Type v)\n| inl (a : α) : Sum α β\n| inr (b : β) : Sum α β\n\nend named_arguments\n\nnamespace structures\n\nstructure Prod (α : Type u) (β : Type v) where\n  mk :: (fst : α) (snd : β)\n\nstructure Color where\n  (red : Nat) (green : Nat) (blue : Nat)\n  deriving Repr\n\ndef yellow := Color.mk 255 255 0\n\n#eval Color.red yellow\n#eval yellow\n\nnamespace fields\n\nstructure Color where\n  red : Nat\n  green : Nat\n  blue : Nat\n  deriving Repr\n\nend fields\n\nstructure Semigroup where\n  carrier : Type u\n  mul : carrier → carrier → carrier\n  mul_assoc : ∀ a b c, mul (mul a b) c = mul a (mul b c)\n\nend structures\n\nnamespace more_std_examples\n\ninductive Sigma {α : Type u} (β : α → Type v) where\n| mk : (a : α) → β a → Sigma β\n\ninductive Option (α : Type u) where\n| none : Option α\n| some : α → Option α\n\ninductive Inhabited (α : Type u) where\n| mk : α → Inhabited α\n\nend more_std_examples\n\n-- Exercises\n-- develop a notion of composition of partial functions\ndef compose\n    {α : Type u} {β : Type v} {γ : Type w}\n    (f : β → Option γ) (g : α → Option β) (x : α) : Option γ :=\n  match g x with\n  | some (y : β) => f y\n  | none => none\n\n-- show that it behaves as expected\ndef partial_id {α : Type u} : α → Option α := some\ndef partial_none {α : Type u} : α → Option α := λ _ => none\n\nexample : compose partial_id partial_none 3 = none := rfl\nexample : compose partial_none partial_id 3 = none := rfl\nexample : compose partial_id partial_id 3 = some 3 := rfl\n\n-- show that Bool and Nat are inhabited\nexample : Inhabited Bool := Inhabited.mk false\nexample : Inhabited Nat := Inhabited.mk 0\n\n-- the product of two inhabited types is inhabited\ntheorem prod_inhabited\n    {α : Type u} {β : Type v} (ia : Inhabited α) (ib : Inhabited β)\n    : Inhabited (α × β) :=\n  match ia, ib with\n  | Inhabited.mk a, Inhabited.mk b => Inhabited.mk (a, b)\n\n-- the type of functions to an inhabited type is inhabited\ntheorem fn_inhabited\n    {α : Type u} {β : Type v} (ib : Inhabited β)\n    : Inhabited (α → β) :=\n  let (Inhabited.mk b) := ib\n  Inhabited.mk (λ _ => b)\n\nend constructors_with_arguments\n\n/- Inductively defined propositions -/\nnamespace inductively_defined_propositions\n\ninductive False : Prop where\n\ninductive True : Prop where\n| intro : True\n\ninductive And (a b : Prop) : Prop where\n| intro : a → b → And a b\n\ninductive Or (a b : Prop) : Prop where\n| inl : a → Or a b\n| inr : b → Or a b\n\ninductive Exists {α : Type u} (q : α → Prop) : Prop where\n| intro : ∀ (a : α), q a → Exists q\n\ninductive Subtype {α : Type u} (p : α → Prop) where\n| mk : (x : α) → p x → Subtype p\n\nend inductively_defined_propositions\n\n/- Defining the natural numbers -/\nnamespace defining_the_natural_numbers\n\nnamespace my_nat\n\ninductive Nat where\n| zero : Nat\n| succ : Nat → Nat\nderiving Repr\n\n#check @Nat.rec\n#check @Nat.recOn\n\nnamespace Nat\n\ndef add (m n : Nat) : Nat :=\n  match n with\n  | Nat.zero => m\n  | Nat.succ n => Nat.succ (add m n)\n\n#eval add (succ (succ zero)) (succ zero)\n\ninstance : Add Nat where\n  add := add\n\ntheorem add_zero (m : Nat) : m + zero = m := rfl\ntheorem add_succ (m n : Nat) : m + succ n = succ (m + n) := rfl\n\nend Nat\n\nend my_nat\n\nopen Nat\n\ntheorem zero_add (n : Nat) : 0 + n = n :=\n  Nat.recOn (motive := λ x => 0 + x = x)\n    n\n    (show 0 + 0 = 0 from rfl)\n    (fun (n : Nat) (ih : 0 + n = n) =>\n      show 0 + succ n = succ n from\n      calc\n        _ = 0 + succ n   := rfl\n        _ = succ (0 + n) := rfl\n        _ = succ n       := by rw [ih])\n\ntheorem zero_add_tactics (n : Nat) : 0 + n = n :=\n  Nat.recOn (motive := λ x => 0 + x = x)\n    n\n    rfl\n    (λ n ih => by simp [add_succ, ih])\n\ntheorem add_assoc (m n k : Nat) : (m + n) + k = m + (n + k) := by\n  apply Nat.recOn (motive := λ k => (m + n) + k = m + (n + k)) k\n  · show (m + n) + 0 = m + (n + 0)\n    rfl\n  · intro k (ih : (m + n) + k = m + (n + k))\n    show (m + n) + succ k = m + (n + succ k)\n    calc\n      _ = (m + n) + succ k   := rfl\n      _ = succ ((m + n) + k) := rfl\n      _ = succ (m + (n + k)) := by rw [ih]\n      _ = m + succ (n + k)   := rfl\n      _ = m + (n + succ k)   := rfl\n\ntheorem add_assoc_short (m n k : Nat) : (m + n) + k = m + (n + k) := by\n  apply Nat.recOn (motive := λ k => (m + n) + k = m + (n + k)) k\n  · rfl\n  · intro k ih\n    simp [Nat.add_succ, ih]\n\ntheorem succ_add (n m : Nat) : succ n + m = succ (n + m) := by\n  apply Nat.recOn (motive := λ x => succ n + x = succ (n + x))\n  · show succ n + 0 = succ (n + 0)\n    rfl\n  · intro m (ih : succ n + m = succ (n + m))\n    show succ n + succ m = succ (n + succ m)\n    calc\n      _ = succ n + succ m     := rfl\n      _ = succ (succ n + m)   := rfl\n      _ = succ (succ (n + m)) := by rw [ih]\n      _ = succ (n + succ m)   := rfl\n\ntheorem add_comm (m n : Nat) : m + n = n + m := by\n  apply Nat.recOn (motive := λ x => m + x = x + m) n\n  · show m + 0 = 0 + m\n    rw [Nat.zero_add, Nat.add_zero]\n  · intro n (ih : m + n = n + m)\n    show m + succ n = succ n + m\n    calc\n      _ = m + succ n   := rfl\n      _ = succ (m + n) := rfl\n      _ = succ (n + m) := by rw [ih]\n      _ = succ n + m   := by rw [succ_add]\n\ntheorem succ_add_short (n m : Nat) : succ n + m = succ (n + m) := by\n  apply Nat.recOn (motive := λ x => succ n + x = succ (n + x))\n  · simp\n  · intro m ih\n    simp only [add_succ, ih]\n\ntheorem add_comm_short (m n : Nat) : m + n = n + m := by\n  apply Nat.recOn (motive := λ x => m + x = x + m) n\n  · simp\n  · intro n ih\n    simp only [add_succ, succ_add, ih]\n\nend defining_the_natural_numbers\n\n/- Other recursive data types -/\nnamespace other_recursive_data_types\n\ninductive List (α : Type u) where\n| nil : List α\n| cons : α → List α → List α\n\nnamespace List\n\ndef append (as bs : List α) : List α :=\n  match as with\n  | nil => bs\n  | cons a as => cons a (append as bs)\n\ntheorem nil_append (as : List α) : append nil as = as := rfl\n\ntheorem cons_append\n    (a : α) (as bs : List α) : append (cons a as) bs = cons a (append as bs) :=\n  rfl\n\ntheorem append_nil (as : List α) : append as nil = as := by\n  apply List.recOn (motive := λ xs => append xs nil = xs) as\n  · show append nil nil = nil\n    rfl\n  · intro a as (ih : append as nil = as)\n    show append (cons a as) nil = cons a as\n    calc\n      _ = append (cons a as) nil := rfl\n      _ = cons a (append as nil) := rfl\n      _ = cons a as              := by rw [ih]\n\ntheorem append_assoc\n    (as bs cs : List α)\n    : append (append as bs) cs = append as (append bs cs) := by\n  apply List.recOn\n      (motive := λ xs => append (append xs bs) cs = append xs (append bs cs))\n      as\n  · show append (append nil bs) cs = append nil (append bs cs)\n    rfl\n  · intro a as (ih : append (append as bs) cs = append as (append bs cs))\n    show append (append (cons a as) bs) cs = append (cons a as) (append bs cs)\n    calc\n      _ = append (append (cons a as) bs) cs := rfl\n      _ = append (cons a (append as bs)) cs := rfl\n      _ = cons a (append (append as bs) cs) := rfl\n      _ = cons a (append as (append bs cs)) := by rw [ih]\n      _ = append (cons a as) (append bs cs) := rfl\n\ndef length (as : List α) : Nat :=\n  match as with\n  | nil => 0\n  | cons _ as => Nat.succ (length as)\n\nexample : length (nil : List Nat) = 0 := rfl\nexample : length (cons 42 nil) = 1 := rfl\n\ntheorem length_append\n    (as bs : List α) : length (append as bs) = length as + length bs := by\n  apply List.recOn\n      (motive := λ xs => length (append xs bs) = length xs + length bs)\n      as\n  · show length (append nil bs) = length nil + length bs\n    calc\n      _ = length (append nil bs) := rfl\n      _ = length bs              := rfl\n      _ = 0 + length bs          := by rw [Nat.zero_add]\n      _ = length nil + length bs := rfl\n  · intro a as (ih : length (append as bs) = length as + length bs)\n    show length (append (cons a as) bs) = length (cons a as) + length bs\n    calc\n      _ = length (append (cons a as) bs)   := rfl\n      _ = length (cons a (append as bs))   := rfl\n      _ = Nat.succ (length (append as bs)) := rfl\n      _ = Nat.succ (length as + length bs) := by rw [ih]\n      _ = Nat.succ (length as) + length bs := by rw [←Nat.succ_add]\n      _ = length (cons a as) + length bs   := rfl\n\nend List\n\ninductive BinaryTree where\n| leaf : BinaryTree\n| node : BinaryTree → BinaryTree → BinaryTree\n\ninductive CBTree where\n| leaf : CBTree\n| sup : (Nat → CBTree) → CBTree\n\nnamespace CBTree\n\ndef succ (t : CBTree) : CBTree :=\n  sup (λ _ => t)\n\ndef toCBTree : Nat → CBTree\n| 0 => leaf\n| n+1 => succ (toCBTree n)\n\ndef omega : CBTree :=\n  sup toCBTree\n\nend CBTree\n\nend other_recursive_data_types\n\n/- Tactics for inductive types -/\nnamespace tactics_for_inductive_types\n\nexample (p : Nat → Prop) (hz : p 0) (hs : ∀ n, p (Nat.succ n)) : ∀ n, p n := by\n  intro n\n  cases n\n  · exact hz -- goal is p 0\n  · apply hs -- goal is a : ℕ ⊢ p (succ a)\n\nopen Nat\n\nexample (n : Nat) (h : n ≠ 0) : succ (pred n) = n := by\n  cases n with\n  | zero =>\n    -- goal: h : 0 ≠ 0 ⊢ succ (pred 0) = 0\n    apply absurd rfl h\n  | succ m =>\n    -- second goal: h : succ m ≠ 0 ⊢ succ (pred (succ m)) = succ m\n    rfl\n\nnamespace cases_data\n\ndef f (n : Nat) : Nat := by\n  cases n; exact 3; exact 7\n\nexample : f 0 = 3 := rfl\nexample : f 5 = 7 := rfl\n\nend cases_data\n\nnamespace cases_tuple\n\ndef Tuple (α : Type) (n : Nat) :=\n  { as : List α // as.length = n }\n\ndef f {n : Nat} (t : Tuple α n) : Nat := by\n  cases n; exact 3; exact 7\n\ndef myTuple : Tuple Nat 3 :=\n  ⟨[0, 1, 2], rfl⟩\n\nexample : f myTuple = 7 :=\n  rfl\n\nend cases_tuple\n\nnamespace cases_multi\n\ninductive Foo where\n| bar₁ : Nat → Nat → Foo\n| bar₂ : Nat → Nat → Nat → Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x with\n  | bar₁ a b => exact b\n  | bar₂ c d e => exact e\n\nend cases_multi\n\nnamespace cases_multi_swap\n\ninductive Foo where\n| bar₁ : Nat → Nat → Foo\n| bar₂ : Nat → Nat → Nat → Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x with\n  | bar₂ c d e => exact e\n  | bar₁ a b => exact b\n\nend cases_multi_swap\n\nnamespace case_tactic\n\ninductive Foo where\n| bar₁ : Nat → Nat → Foo\n| bar₂ : Nat → Nat → Nat → Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x\n  case bar₂ c d e => exact e\n  case bar₁ a b => exact b\n\nend case_tactic\n\nnamespace case_tactic_swap\n\ninductive Foo where\n| bar₁ : Nat → Nat → Foo\n| bar₂ : Nat → Nat → Nat → Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x\n  case bar₁ a b => exact b\n  case bar₂ c d e => exact e\n\nend case_tactic_swap\n\nexample\n    (p : Nat → Prop) (hz : p 0) (hs : ∀ n, p (succ n)) (m k : Nat)\n    : p (m + 3 * k) := by\n  cases m + 3 * k\n  exact hz -- goal is p 0\n  apply hs -- goal is a : ℕ ⊢ p (succ a)\n\nexample\n    (p : Nat → Prop) (hz : p 0) (hs : ∀ n, p (succ n)) (m k : Nat)\n    : p (m + 3 * k) := by\n  generalize m + 3 * k = n\n  cases n\n  exact hz\n  apply hs\n\nexample (p : Prop) (m n : Nat) (h₁ : m < n → p) (h₂ : m ≥ n → p) : p := by\n  cases Nat.lt_or_ge m n\n  case inl hlt => exact h₁ hlt\n  case inr hge => exact h₂ hge\n\nexample (p : Prop) (m n : Nat) (h₁ : m < n → p) (h₂ : m ≥ n → p) : p := by\n  have h : m < n ∨ m ≥ n := Nat.lt_or_ge m n\n  cases h\n  case inl hlt => exact h₁ hlt\n  case inr hge => exact h₂ hge\n\n#check Nat.sub_self\n\nexample (m n : Nat) : m - n = 0 ∨ m ≠ n := by\n  cases Decidable.em (m = n) with\n  | inl heq => rw [heq]; apply Or.inl; exact Nat.sub_self n\n  | inr hne => apply Or.inr; exact hne \n\ntheorem zero_add (n : Nat) : 0 + n = n := by\n  induction n with\n  | zero => rfl\n  | succ n ih => rw [Nat.add_succ, ih]\n\ntheorem zero_add_case (n : Nat) : 0 + n = n := by\n  induction n\n  case zero => rfl\n  case succ n ih => rw [Nat.add_succ, ih]\n\nnamespace induction_examples\n\ntheorem zero_add (n : Nat) : 0 + n = n := by\n  induction n <;> simp [*]\n\ntheorem succ_add (m n : Nat) : succ m + n = succ (m + n) := by\n  induction n <;> simp[*, add_zero, add_succ]\n\ntheorem add_comm (m n : Nat) : m + n = n + m := by\n  induction n <;> simp [*, add_succ, succ_add]\n\ntheorem add_assoc (m n k : Nat) : (m + n) + k = m + (n + k) := by\n  induction k <;> simp [*, add_zero, add_succ]\n\nend induction_examples\n\n#check @Nat.mod.inductionOn\n\nexample (x : Nat) {y : Nat} (h : y > 0) : x % y < y := by\n  induction x, y using Nat.mod.inductionOn with\n  | ind x y h₁ ih =>\n    rw [Nat.mod_eq_sub_mod h₁.2]\n    exact ih h\n  | base x y h₁ =>\n    have : ¬ 0 < y ∨ ¬ y ≤ x := Iff.mp (Decidable.not_and_iff_or_not ..) h₁\n    cases this with\n    | inl h₁ => exact absurd h h₁\n    | inr h₁ =>\n      have hgt : y > x := Nat.gt_of_not_le h₁\n      rw [← Nat.mod_eq_of_lt hgt] at hgt\n      assumption  \n\nexample :\n    (λ (x : Nat × Nat) (y : Nat × Nat) => x.1 + y.2) =\n    (λ (x : Nat × Nat) (z : Nat × Nat) => z.2 + x.1) := by\n  funext (a, b) (c, d)\n  show a + d = d + a\n  rw [Nat.add_comm]\n\nexample (m n k : Nat) (h : succ (succ m) = succ (succ n)) : n + k = m + k := by\n  injection h with h'\n  injection h' with h''\n  rw [h'']\n\nexample (m n : Nat) (h : succ m = 0) : n = n + 7 := by\n  injection h\n\nexample (m n : Nat) (h : succ m = 0) : n = n + 7 := by\n  contradiction\n\nexample (h : 7 = 4) : False := by\n  contradiction\n\nend tactics_for_inductive_types\n\n/- Inductive families -/\nnamespace inductive_families\n\ninductive Vector (α : Type u) : Nat → Type u where\n| nil : Vector α 0\n| cons : α → {n : Nat} → Vector α n → Vector α (n + 1)\n\ninductive Eq {α : Sort u} (a : α) : α → Prop where\n| refl {} : Eq a a\n\n#check @Eq.rec\n\ntheorem subst\n    {α : Type u} {a b : α} {p : α → Prop} (h₁ : Eq a b) (h₂ : p a) : p b :=\n  match h₁ with\n  | Eq.refl _ => h₂\n\nsection\nset_option pp.all true\n#print subst\n#print subst.match_1\n#print Eq.casesOn\nend\n\ntheorem symm {α : Type u} {a b : α} (h : Eq a b) : Eq b a :=\n  match h with\n  | Eq.refl _ => Eq.refl _\n\ntheorem trans {α : Type u} {a b c : α} (h₁ : Eq a b) (h₂ : Eq b c) : Eq a c := by\n  cases h₂ with\n  | refl => exact h₁\n  \ntheorem congr\n    {α β : Type u} {a b : α} (f : α → β) (h : Eq a b) : Eq (f a) (f b) := by\n  cases h with\n  | refl => exact Eq.refl (f a)\n\nend inductive_families\n\n/- Mutual and nested inductive types -/\nnamespace mutual_and_nested_inductive_types\n\nmutual\n  inductive Even : Nat → Prop where\n  | even_zero : Even 0\n  | even_succ : {n : Nat} → Odd n → Even (n + 1)\n\n  inductive Odd : Nat → Prop where\n  | odd_succ : {n : Nat} → Even n → Odd (n + 1)\nend\n\nmutual\n  inductive Tree (α : Type u) where\n  | node : α → TreeList α → Tree α\n\n  inductive TreeList (α : Type u) where\n  | nil : TreeList α\n  | cons : Tree α → TreeList α → TreeList α\nend\n\ninductive BetterTree (α : Type u) where\n| mk : α → List (BetterTree α) → BetterTree α\n\nend mutual_and_nested_inductive_types\n\n/- Exercises -/\nnamespace exercises\n\nnamespace ex_1\n\nopen Nat\n\ndef mul (n m : Nat) : Nat :=\n  match n with\n  | 0 => 0\n  | n+1 => m + (mul n m)\n\ntheorem zero_mul {n : Nat} : mul 0 n = 0 := rfl\n\ntheorem mul_zero {n : Nat} : mul n 0 = 0 := by\n  induction n\n  case zero =>\n    show mul 0 0 = 0\n    rfl\n  case succ n ih =>\n    have : mul n 0 = 0 := ih\n    show mul (succ n) 0 = 0\n    calc\n      _ = mul (succ n) 0 := rfl\n      _ = 0 + mul n 0    := rfl\n      _ = mul n 0        := by rw [Nat.zero_add]\n      _ = 0              := by rw [ih]\n\ntheorem succ_mul {n m : Nat} : mul (succ n) m = m + mul n m := rfl\n\ntheorem mul_succ {n m : Nat} : mul m (succ n) = m + mul m n := by\n  induction m\n  case zero =>\n    show mul 0 (succ n) = 0 + mul 0 n\n    simp only [zero_mul, Nat.zero_add]\n  case succ m ih =>\n    have : mul m (succ n) = m + mul m n := ih\n    show mul (succ m) (succ n) = succ m + mul (succ m) n\n    calc\n      _ = mul (succ m) (succ n)   := rfl\n      _ = succ n + mul m (succ n) := by rw [succ_mul]\n      _ = succ n + (m + mul m n)  := by rw [ih]\n      _ = (succ n + m) + mul m n  := by rw [Nat.add_assoc]\n      _ = succ (n + m) + mul m n  := by rw [Nat.succ_add]\n      _ = (n + succ m) + mul m n  := by rw [Nat.add_succ]\n      _ = (succ m + n) + mul m n  := by rw [Nat.add_comm n]\n      _ = succ m + (n + mul m n)  := by rw [Nat.add_assoc]\n      _ = succ m + mul (succ m) n := by rw [succ_mul]\n\ntheorem mul_comm {n m : Nat} : mul n m = mul m n := by\n  induction n\n  case zero =>\n    show mul 0 m = mul m 0\n    simp only [zero_mul, mul_zero]\n  case succ n ih =>\n    have : mul n m = mul m n := ih\n    show mul (succ n) m = mul m (succ n)\n    calc\n      _ = mul (succ n) m := rfl\n      _ = m + mul n m    := by rw [succ_mul]\n      _ = m + mul m n    := by rw [ih]\n      _ = mul m (succ n) := by rw [mul_succ]\n\ntheorem right_distrib {n m k : Nat} : mul (n + m) k = mul n k + mul m k := by\n  induction n\n  case zero =>\n    show mul (0 + m) k = mul 0 k + mul m k\n    calc\n      _ = mul (0 + m) k     := rfl\n      _ = mul m k           := by rw [Nat.zero_add]\n      _ = 0 + mul m k       := by rw [Nat.zero_add]\n      _ = mul 0 k + mul m k := by rw [zero_mul]\n  case succ n ih =>\n    have : mul (n + m) k = mul n k + mul m k := ih\n    show mul (succ n + m) k = mul (succ n) k + mul m k\n    calc\n      _ = mul (succ n + m) k       := rfl\n      _ = mul (succ (n + m)) k     := by rw [Nat.succ_add]\n      _ = k + mul (n + m) k        := by rw [succ_mul]\n      _ = k + (mul n k + mul m k)  := by rw [ih]\n      _ = (k + mul n k) + mul m k  := by rw [Nat.add_assoc]\n      _ = mul (succ n) k + mul m k := by rw [succ_mul]\n\ntheorem mul_assoc {n m k : Nat} : mul (mul n m) k = mul n (mul m k) := by\n  induction n\n  case zero =>\n    show mul (mul 0 m) k = mul 0 (mul m k)\n    calc\n      _ = mul (mul 0 m) k := rfl\n      _ = mul 0 k := by rw [zero_mul]\n      _ = 0 := by rw [zero_mul]\n      _ = mul 0 (mul m k) := by rw [zero_mul]\n  case succ n ih =>\n    have : mul (mul n m) k = mul n (mul m k) := ih\n    show mul (mul (succ n) m) k = mul (succ n) (mul m k)\n    calc\n      _ = mul (mul (succ n) m) k    := rfl\n      _ = mul (m + mul n m) k       := by rw [succ_mul]\n      _ = mul m k + mul (mul n m) k := by rw [right_distrib]\n      _ = mul m k + mul n (mul m k) := by rw [ih]\n      _ = mul (succ n) (mul m k)    := by rw [succ_mul]\n\ntheorem one_mul {m : Nat} : mul 1 m = m := by\n  calc\n    _ = mul 1 m        := rfl\n    _ = mul (succ 0) m := rfl\n    _ = m + mul 0 m    := by rw [succ_mul]\n    _ = m + 0          := by rw [zero_mul]\n    _ = m              := by rw [Nat.add_zero]\n\ndef pred (n : Nat) : Nat :=\n  match n with\n  | 0 => 0\n  | n+1 => n\n\ntheorem pred_succ {n : Nat} : pred (succ n) = n := by\n  cases n\n  case zero =>\n    show pred (succ 0) = 0\n    rfl\n  case succ n =>\n    show pred (succ (succ n)) = succ n\n    rfl\n\ndef sub (n m : Nat) : Nat :=\n  match n with\n  | 0 => 0\n  | n+1 => match m with\n    | 0 => n+1\n    | m+1 => sub n m\n\ntheorem zero_sub {n : Nat} : sub 0 n = 0 := rfl\n\ntheorem sub_zero {n : Nat} : sub n 0 = n := by\n  cases n\n  case zero =>\n    show sub 0 0 = 0\n    rfl\n  case succ n =>\n    show sub (succ n) 0 = succ n\n    rfl\n\ntheorem sub_same {n : Nat} : sub n n = 0 := by\n  induction n\n  case zero =>\n    show sub 0 0 = 0\n    rfl\n  case succ n ih =>\n    have : sub n n = 0 := ih\n    show sub (succ n) (succ n) = 0\n    calc\n      _ = sub (succ n) (succ n) := rfl\n      _ = sub n n               := rfl\n      _ = 0                     := by rw [ih]\n\ndef pow (n m : Nat) : Nat :=\n  match m with\n  | 0 => 1\n  | m+1 => mul n (pow n m)\n\ntheorem pow_zero {n : Nat} : pow n 0 = 1 := rfl\n\ntheorem pow_succ {n m : Nat} : pow n (succ m) = mul n (pow n m) := rfl\n\ntheorem zero_pow {m : Nat} : pow 0 (succ m) = 0 := rfl\n\ntheorem pow_add {n m k : Nat} : pow n (m + k) = mul (pow n m) (pow n k) := by\n  induction m\n  case zero =>\n    show pow n (0 + k) = mul (pow n 0) (pow n k)\n    calc\n      _ = pow n (0 + k)           := rfl\n      _ = pow n k                 := by rw [Nat.zero_add]\n      _ = mul 1 (pow n k)         := by rw [one_mul]\n      _ = mul (pow n 0) (pow n k) := by rw [pow_zero]\n  case succ m ih =>\n    have : pow n (m + k) = mul (pow n m) (pow n k) := ih\n    show pow n (succ m + k) = mul (pow n (succ m)) (pow n k)\n    calc\n      _ = pow n (succ m + k)              := rfl\n      _ = pow n (succ (m + k))            := by rw [Nat.succ_add]\n      _ = mul n (pow n (m + k))           := by rw [pow_succ]\n      _ = mul n (mul (pow n m) (pow n k)) := by rw [ih]\n      _ = mul (mul n (pow n m)) (pow n k) := by rw [mul_assoc]\n      _ = mul (pow n (succ m)) (pow n k)  := by rw [pow_succ]\n\ntheorem pow_pow {n m k : Nat} : pow (pow n m) k = pow n (mul m k) := by\n  induction k\n  case zero =>\n    show pow (pow n m) 0 = pow n (mul m 0)\n    calc\n      _ = pow (pow n m) 0 := rfl\n      _ = 1               := by rw [pow_zero]\n      _ = pow n 0         := by rw [pow_zero]\n      _ = pow n (mul m 0) := by rw [mul_zero]\n  case succ k ih =>\n    have : pow (pow n m) k = pow n (mul m k) := ih\n    show pow (pow n m) (succ k) = pow n (mul m (succ k))\n    calc\n      _ = pow (pow n m) (succ k)          := rfl\n      _ = mul (pow n m) (pow (pow n m) k) := by rw [pow_succ]\n      _ = mul (pow n m) (pow n (mul m k)) := by rw [ih]\n      _ = pow n (m + mul m k)             := by rw [pow_add]\n      _ = pow n (mul m (succ k))          := by rw [mul_succ]\n\nend ex_1\n\nnamespace ex_2\n\ndef length (xs : List α) : Nat :=\n  match xs with\n  | [] => 0\n  | x :: xs => 1 + length xs\n\ndef reverse_helper (xs : List α) (acc : List α) : List α :=\n  match xs with\n  | [] => acc\n  | x :: xs => reverse_helper xs (x :: acc)\n\ndef reverse (xs : List α) : List α :=\n  reverse_helper xs []\n\ntheorem length_nil : length ([] : List α) = 0 := rfl\n\ntheorem length_cons\n    {x : α} {xs : List α} : length (x :: xs) = 1 + length xs := rfl\n\ntheorem reverse_nil : reverse ([] : List α) = [] := rfl\n\ntheorem reverse_helper_append\n    {xs : List α} : ∀ ys, reverse_helper xs ys = reverse xs ++ ys := by\n  induction xs\n  case nil =>\n    show ∀ ys, reverse_helper [] ys = reverse [] ++ ys\n    intro ys\n    calc\n      _ = reverse_helper [] ys := rfl\n      _ = ys := rfl\n      _ = [] ++ ys := by rw [List.nil_append]\n      _ = reverse [] ++ ys := by rw [reverse_nil]\n  case cons x xs ih =>\n    have : ∀ ys, reverse_helper xs ys = reverse xs ++ ys := ih\n    show ∀ ys, reverse_helper (x :: xs) ys = reverse (x :: xs) ++ ys\n    intro ys\n    calc\n      _ = reverse_helper (x :: xs) ys       := rfl\n      _ = reverse_helper xs (x :: ys)       := rfl\n      _ = reverse xs ++ x :: ys             := by rw [ih]\n      _ = reverse xs ++ x :: ([] ++ ys)     := by rw [List.nil_append]\n      _ = reverse xs ++ ((x :: []) ++ ys)   := by rw [List.cons_append]\n      _ = (reverse xs ++ (x :: [])) ++ ys   := by rw [List.append_assoc]\n      _ = reverse_helper xs (x :: []) ++ ys := by rw [ih]\n      _ = reverse_helper (x :: xs) [] ++ ys := rfl\n      _ = reverse (x :: xs) ++ ys           := rfl\n\ntheorem reverse_cons_append\n    {x : α} {xs ys : List α}\n    : reverse (x :: xs) ++ ys = reverse xs ++ x :: ys := by\n  calc\n    _ = reverse (x :: xs) ++ ys           := rfl\n    _ = reverse_helper (x :: xs) [] ++ ys := rfl\n    _ = reverse_helper xs (x :: []) ++ ys := rfl\n    _ = (reverse xs ++ (x :: [])) ++ ys   := by rw [reverse_helper_append]\n    _ = reverse xs ++ ((x :: []) ++ ys)   := by rw [List.append_assoc]\n    _ = reverse xs ++ (x :: ([] ++ ys))   := by rw [List.cons_append]\n    _ = reverse xs ++ (x :: ys)           := by rw [List.nil_append]\n\ntheorem reverse_singleton {x : α} : reverse [x] = [x] := by\n  calc\n    _ = reverse [x]             := rfl\n    _ = reverse (x :: [])       := rfl\n    _ = reverse (x :: []) ++ [] := by rw [List.append_nil]\n    _ = reverse [] ++ (x :: []) := by rw [reverse_cons_append]\n    _ = [] ++ (x :: [])         := by rw [reverse_nil]\n    _ = x :: []                 := by rw [List.nil_append]\n    _ = [x]                     := rfl\n\ntheorem length_append\n    {xs ys : List α} : length (xs ++ ys) = length xs + length ys := by\n  induction xs\n  case nil =>\n    show length ([] ++ ys) = length [] + length ys\n    calc\n      _ = length ([] ++ ys)     := rfl\n      _ = length ys             := by rw [List.nil_append]\n      _ = 0 + length ys         := by rw [Nat.zero_add]\n      _ = length [] + length ys := by rw [length_nil]\n  case cons x xs ih =>\n    have : length (xs ++ ys) = length xs + length ys := ih\n    show length (x :: xs ++ ys) = length (x :: xs) + length ys\n    calc\n      _ = length (x :: xs ++ ys)       := rfl\n      _ = length (x :: (xs ++ ys))     := by rw [List.cons_append]\n      _ = 1 + length (xs ++ ys)        := by rw [length_cons]\n      _ = 1 + (length xs + length ys)  := by rw [ih]\n      _ = (1 + length xs) + length ys  := by rw [Nat.add_assoc]\n      _ = length (x :: xs) + length ys := by rw [length_cons]\n\ntheorem length_reverse {xs : List α} : length (reverse xs) = length xs := by\n  induction xs\n  case nil =>\n    show length (reverse []) = length []\n    calc\n      _ = length (reverse []) := rfl\n      _ = length [] := by rw [reverse_nil]\n  case cons x xs ih =>\n    have : length (reverse xs) = length xs := ih\n    show length (reverse (x :: xs)) = length (x :: xs)\n    calc\n      _ = length (reverse (x :: xs))       := rfl\n      _ = length (reverse (x :: xs) ++ []) := by rw [List.append_nil]\n      _ = length (reverse xs ++ (x :: [])) := by rw [reverse_cons_append]\n      _ = length (reverse xs) + length [x] := by rw [length_append]\n      _ = length [x] + length (reverse xs) := by rw [Nat.add_comm]\n      _ = length [x] + length xs           := by rw [ih]\n      _ = 1 + length xs                    := rfl\n      _ = length (x :: xs)                 := by rw [length_cons]\n\ntheorem reverse_append\n    {xs ys : List α} : reverse (xs ++ ys) = reverse ys ++ reverse xs := by\n  induction xs\n  case nil =>\n    show reverse ([] ++ ys) = reverse ys ++ reverse []\n    calc \n      _ = reverse ([] ++ ys)       := rfl\n      _ = reverse ys               := by rw [List.nil_append]\n      _ = reverse ys ++ []         := by rw [List.append_nil]\n      _ = reverse ys ++ reverse [] := by rw [reverse_nil]\n  case cons x xs ih =>\n    have : reverse (xs ++ ys) = reverse ys ++ reverse xs := ih\n    show reverse ((x :: xs) ++ ys) = reverse ys ++ reverse (x :: xs)\n    calc\n      _ = reverse ((x :: xs) ++ ys)               := rfl\n      _ = reverse (x :: (xs ++ ys))               := by rw [List.cons_append]\n      _ = reverse (x :: (xs ++ ys)) ++ []         := by rw [List.append_nil]\n      _ = reverse (xs ++ ys) ++ (x :: [])         := by rw [reverse_cons_append]\n      _ = (reverse ys ++ reverse xs) ++ (x :: []) := by rw [ih]\n      _ = reverse ys ++ (reverse xs ++ (x :: [])) := by rw [List.append_assoc]\n      _ = reverse ys ++ (reverse (x :: xs) ++ []) := by rw [reverse_cons_append]\n      _ = reverse ys ++ reverse (x :: xs)         := by rw [List.append_nil]\n\ntheorem reverse_reverse {xs : List α} : reverse (reverse xs) = xs := by\n  induction xs\n  case nil =>\n    show reverse (reverse []) = []\n    calc\n      _ = reverse (reverse []) := rfl\n      _ = reverse []           := rfl\n      _ = []                   := rfl\n  case cons x xs ih =>\n    have : reverse (reverse xs) = xs := ih\n    show reverse (reverse (x :: xs)) = x :: xs\n    calc\n      _ = reverse (reverse (x :: xs))               := rfl\n      _ = reverse (reverse (x :: xs) ++ [])         := by rw [List.append_nil]\n      _ = reverse (reverse xs ++ (x :: []))         := by rw [reverse_cons_append]\n      _ = reverse (x :: []) ++ reverse (reverse xs) := by rw [reverse_append]\n      _ = reverse (x :: []) ++ xs                   := by rw [ih]\n      _ = (x :: []) ++ xs                           := by rw [reverse_singleton]\n      _ = x :: ([] ++ xs)                           := by rw [List.cons_append]\n      _ = x :: xs                                   := by rw [List.nil_append]\n\nend ex_2\n\nnamespace ex_3\n\ninductive Term (V : Type u) where\n| const (n : Nat)\n| var (v : V)\n| plus (s t : Term V) : Term V\n| times (s t : Term V) : Term V\n\nnamespace Term\n\ndef eval {V : Type u} (varValue : V → Nat) (t : Term V) : Nat :=\n  match t with\n  | const n => n\n  | var v => varValue v\n  | plus s t => eval varValue s + eval varValue t\n  | times s t => eval varValue s * eval varValue t\n\ndef simpleTerm : Term String := times (plus (var \"x\") (const 3)) (var \"y\")\n\ndef simpleVars (s : String) : Nat :=\n  match s with\n  | \"x\" => 1\n  | \"y\" => 2\n  | _ => 0\n\nexample : eval simpleVars simpleTerm = 8 := rfl\n\nend Term\n\nend ex_3\n\nnamespace ex_4\n\ninductive BinOp where\n| And | Or | Implies | Iff\n\ninductive Formula (V : Type u) where\n| const (b : Bool)\n| var (v : V)\n| not (p : Formula V)\n| binOp (op : BinOp) (p q : Formula V)\n\nopen BinOp\nopen Formula\n\ndef and {V : Type u} (p q : Formula V) : Formula V := binOp And p q\ndef or {V : Type u} (p q : Formula V) : Formula V := binOp Or p q\ndef implies {V : Type u} (p q : Formula V) : Formula V := binOp Implies p q\ndef iff {V : Type u} (p q : Formula V) : Formula V := binOp Iff p q\n\ndef eval {V : Type u} (vars : V → Bool) (formula : Formula V) : Bool :=\n  match formula with\n  | const b => b\n  | var v => vars v\n  | Formula.not p => !(eval vars p)\n  | binOp op p q =>\n    let boolOp :=\n      match op with\n      | BinOp.And => (· && ·)\n      | BinOp.Or => (· || ·)\n      | BinOp.Implies => λ p q => p && !q\n      | BinOp.Iff => (· == ·)\n    boolOp (eval vars p) (eval vars q)\n\nexample : eval (λ _ : String => false) (const true) = true := rfl\nexample : eval (λ v => v == \"x\") (var \"x\") = true := rfl\nexample : eval (λ v => v == \"x\") (var \"y\") = false := rfl\nexample : eval (λ v => v == \"x\") (not (var \"x\")) = false := rfl\n\nexample \n  : eval (λ v => v == \"x\" || v == \"y\") (and (var \"x\") (var \"y\")) = true\n  := rfl\n\nexample\n  : eval (λ v => v == \"x\" || v != \"y\") (and (var \"x\") (var \"y\")) = false\n  := rfl\n\nexample\n  : eval (λ v => v != \"x\" || v == \"y\") (and (var \"x\") (var \"y\")) = false\n  := rfl\n\ndef node_count {V : Type u} (formula : Formula V) : Nat :=\n  let children_node_count := match formula with\n  | const _ => 0\n  | var _ => 0\n  | Formula.not p => node_count p\n  | binOp _ p q => node_count p + node_count q\n  1 + children_node_count\n\nexample : node_count (var \"x\") = 1 := rfl\nexample : node_count (or (const false) (var \"y\")) = 3 := rfl\n\ndef formula_vars {V : Type u} (formula : Formula V) : List V :=\n  match formula with\n  | const _ => []\n  | var v => [v]\n  | Formula.not p => formula_vars p\n  | binOp _ p q => formula_vars p ++ formula_vars q\n\ndef and_assoc : Formula String :=\n  let p := var \"p\"\n  let q := var \"q\"\n  let r := var \"r\"\n  iff (and (and p q) r) (and p (and q r))\n\nexample : (formula_vars and_assoc).contains \"p\" = true := rfl\nexample : (formula_vars and_assoc).contains \"q\" = true := rfl\nexample : (formula_vars and_assoc).contains \"r\" = true := rfl\nexample : (formula_vars and_assoc).contains \"s\" = false := rfl\nexample : (formula_vars and_assoc).contains \"t\" = false := rfl\n\ndef substitute\n    {V : Type u} [BEq V] (into : Formula V) (v : V) (formula : Formula V)\n    : Formula V :=\n  match into with\n  | const c => const c\n  | var w => if v == w then formula else var w\n  | Formula.not p => not (substitute p v formula)\n  | binOp op p q => binOp op (substitute p v formula) (substitute q v formula)\n\ndef lem : Formula String := or (var \"p\") (not (var \"p\"))\ndef qr : Formula String := and (var \"q\") (var \"r\")\nexample : substitute lem \"p\" qr = or qr (not qr) := rfl\n\nend ex_4\n\nend exercises\n", "meta": {"author": "cruhland", "repo": "theorem-proving-in-lean4", "sha": "d0cab851613b4ae416063cadebda3759761ed651", "save_path": "github-repos/lean/cruhland-theorem-proving-in-lean4", "path": "github-repos/lean/cruhland-theorem-proving-in-lean4/theorem-proving-in-lean4-d0cab851613b4ae416063cadebda3759761ed651/tpil/Ch7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.47816029627290074}}
{"text": "import RealsQuasiMorphisms.Basic\nimport Mathlib.Algebra.Order.Field.Defs\nimport RealsQuasiMorphisms.Algebra\nimport Mathlib.Algebra.Order.Ring.Cone\n\n\nvariable {G : Type _} [OrderedAddCommGroup G]\n\nnamespace AlmostHom\n\n/-- An almost-homomorphism `f : G → ℤ` is non-negative if the image (under `f`) of `G ≥ 0` is bounded below. -/\nprotected def nonneg (f : AlmostHom G) : Prop := ∃ a : ℤ , ∀ x : G, x ≥ 0 → f x ≥ a\n/-- An almost-homomorphism `f : G → ℤ` is non-positive if the image (under `f`) of `G ≥ 0` is bounded above (unused). -/\nprotected def nonpos (f : AlmostHom G) : Prop := ∃ b : ℤ , ∀ x : G, x ≥ 0 → f x ≤ b\n/-- `f ≤ g` is equivalent to stating `g - f` is non-negative. -/\nprotected def le (f g : AlmostHom G) : Prop := AlmostHom.nonneg (g - f)\n\n\n-- why exactly this is needed is well beyond me\nprivate lemma add_reduces_to_fun (f g : AlmostHom G) : toFun (f + g) = toFun f + toFun g := by rfl\nprivate lemma neg_reduces_to_fun (f : AlmostHom G) : toFun (-f) = - toFun f:= by rfl\nprivate lemma sub_reduces_to_fun (f g : AlmostHom G) : toFun (f - g) = toFun f - toFun g := by rfl\n\n\n/-- `AlmostHom.le` as defined  gives us a preorder on `AlmostHom G`. -/\ninstance : Preorder (AlmostHom G) where\n  le := AlmostHom.le\n  le_refl f := by\n                simp only [AlmostHom.le, AlmostHom.nonneg, sub_self]\n                use -1; intro x _\n                show -1 ≤ 0; simp only [Left.neg_nonpos_iff]\n  le_trans p q r:= by\n                    intro hpq hqr\n                    let ⟨a, hpq⟩ := hpq; let ⟨b, hqr⟩ := hqr\n                    use a+b; intro x hx\n                    simp only [sub_reduces_to_fun, Pi.sub_apply, ge_iff_le] at hpq hqr ⊢ \n                    let h := add_le_add (hpq x hx) (hqr x hx)\n                    rw [sub_add_sub_cancel'] at h\n                    apply h\n\n\n/- Adding a bounded function to any other can only change the image of\nany element by at most some bound. Thus any lower bound is preserved\nup to a shift in the bound. -/\nprivate lemma bounded_plus_nonneg_nonneg' (f : AlmostHom G)\n        ⦃g : AlmostHom G⦄ (h : ∃ bound : ℕ, Bounded g bound)\n    : f.nonneg → (f + g).nonneg := by\n  intro hf\n  let ⟨bound, hb⟩ := h\n  rw [Bounded] at hb\n  let ⟨a, ha⟩ := hf\n  use a - bound; intro x hx\n  have hb : -bound ≤ g.toFun x := by\n    simp only [←Int.ofNat_le, Int.coe_natAbs, abs_le] at hb\n    exact (hb x).left\n  exact add_le_add (ha x hx) hb\n\n/-- If `f` is a non-negative almost-homomorphism and `g` is bounded, then `f + g` is non-negative. -/\nprotected theorem bounded_plus_nonneg_nonneg {f : AlmostHom G} (g : boundedAlmostHoms G)\n    : f.nonneg → (f + g).nonneg := by\n  exact AlmostHom.bounded_plus_nonneg_nonneg' f g.property\n\n/-- The almost-homomorphism 0 is non-negative. -/\nprotected lemma zero_nonneg : (0 : AlmostHom G).nonneg := by\n  use -1; intro x _\n  show -1 ≤ 0; simp only [Left.neg_nonpos_iff]\n\n/-- If `f` and `g` are non-negative almost-homomorphisms then `f + g` is also non-negative. -/\nprotected lemma add_nonneg {f g : AlmostHom G} : f.nonneg → g.nonneg → (f + g).nonneg := by\n  intro hf hg\n  let ⟨a, ha⟩ := hf; let ⟨b, hb⟩ := hg\n  use a + b; intro x hx\n  exact add_le_add (ha x hx) (hb x hx)\n\n-- this might exist somewhere already\nprivate lemma neg_natAbs_le (a : ℤ) : -a.natAbs ≤ a := by\n  simp only [←Int.ofNat_le, Int.coe_natAbs]\n  exact neg_abs_le_self a\n\nprivate lemma neg_le_natAbs (a : ℤ) : -a ≤ a.natAbs := by\n  simp only [←Int.ofNat_le, Int.coe_natAbs]\n  exact neg_le_abs_self a\n\n\n-- this really need not be split up like this\nprivate lemma nonneg_and_neg_nonneg_bounded' {f : AlmostHom G}\n    : f.nonneg → (-f).nonneg → (∃ bound : ℕ, Bounded f bound) := by\n  intro hf hf'\n  let ⟨a, ha⟩ := hf; let ⟨b, hb⟩ := hf'\n  let ⟨bound, hf⟩ := f.almostAdditive\n  let y := f 0\n  let nb := a.natAbs + b.natAbs + bound + y.natAbs\n  use nb\n  rw [Bounded]\n  intro x\n  by_cases hx:(x ≥ 0)\n  · have h' : f x ≤ -b := by\n      rw [le_neg]\n      exact hb x hx\n    let h'' := ha x hx\n    simp only [←Int.ofNat_le, Int.coe_natAbs, abs_le]\n    apply And.intro\n    · have hga : a.natAbs ≤ nb := by\n        simp only [add_assoc, le_add_iff_nonneg_right, zero_le]\n      have hga : -nb ≤ -(↑a.natAbs : ℤ) := by\n        simp only [←Int.ofNat_le] at hga\n        simp only [neg_le_neg, hga]\n      linarith [neg_natAbs_le a]\n    · have hgb : Int.natAbs b ≤ Int.natAbs b + Int.natAbs a + bound + Int.natAbs (toFun f 0) := by\n        simp only [add_assoc, le_add_iff_nonneg_right, zero_le]\n      simp only [←Int.ofNat_le] at hgb\n      have nbe : ↑(Int.natAbs b + Int.natAbs a + bound + Int.natAbs (toFun f 0)) = (↑nb : ℤ)  := by\n        simp only [add_comm, Nat.cast_add, Int.coe_natAbs]\n      linarith [neg_natAbs_le b]\n  · sorry\n\n/-- If `f` is an almost-homomorphism such that both `f` and `-f` are non-negative, then `f` is bounded. -/\nprotected lemma nonneg_and_neg_nonneg_bounded {f : AlmostHom G}\n    : f.nonneg → (-f).nonneg → f ∈ boundedAlmostHoms G := by\n  intro hf hf'\n  let ⟨bound, hb⟩ := nonneg_and_neg_nonneg_bounded' (f := f) hf hf'\n  use bound\n  exact hb\n\n/- This is a somewhat non-trivial result and not proven yet. -/\n/-- If `f` is an almost-homomorphism, then at least one of `f` and `-f` must be non-negative. -/\nprotected lemma nonneg_total (f : AlmostHom G) : f.nonneg ∨ (-f).nonneg := by\n  sorry\n\nend AlmostHom\n\n\nnamespace QuasiHom\n\n/-- A quasi-morphism `f` is non-negative if any representative almost-homomorphism is non-negative.\n\nThis is well-defined by `bounded_plus_nonneg_nonneg`. -/\nprotected def nonneg (f : QuasiHom G) : Prop := Quot.liftOn f AlmostHom.nonneg (λ f g h ↦ by\n  rw [QuotientAddGroup.leftRel_apply] at h\n  let x : boundedAlmostHoms G := ⟨-f + g, h⟩\n  have h₁ : g = f + x := by\n    simp only [add_neg_cancel_left]\n  have h₂ : f = g + -x := by\n    simp only [neg_add_rev, neg_neg, add_neg_cancel_left]\n  apply propext\n  apply Iff.intro\n  · intro hf\n    rw [h₁]\n    apply AlmostHom.bounded_plus_nonneg_nonneg x hf\n  · intro hg\n    rw [h₂]\n    apply AlmostHom.bounded_plus_nonneg_nonneg (-x) hg\n  )\n\n\n/-- The quasi-morphism 0 is non-negative. -/\nprotected lemma zero_nonneg : QuasiHom.nonneg (0 : QuasiHom G) := by\n  apply AlmostHom.zero_nonneg\n\n/-- The sum of two non-negative quasi-morphisms is non-negative. -/\nprotected lemma add_nonneg {f g : QuasiHom G} : f.nonneg → g.nonneg → (f + g).nonneg := by\n  apply QuotientAddGroup.induction_on f\n  apply QuotientAddGroup.induction_on g\n  intro f g hf hg\n  apply AlmostHom.add_nonneg hf hg\n\n/-- If `f` and `-f` are both non-negative quasi-morphisms, then `f` must be `0`. -/\nprotected lemma nonneg_antisymm {f : QuasiHom G} : f.nonneg → (-f).nonneg → f = 0 := by\n  apply QuotientAddGroup.induction_on f\n  intro f hf hf'\n  rw [QuotientAddGroup.eq_zero_iff]\n  exact AlmostHom.nonneg_and_neg_nonneg_bounded hf hf'\n\n/- This depends on the corresponding result for almost-homomorphisms, which is not yet proved. -/\n/-- If `f` is a quasi-morphism, then at least one of `f` and `-f` must be non-negative. -/\nprotected lemma nonneg_total (f : QuasiHom G) : f.nonneg ∨ (-f).nonneg := by\n  apply QuotientAddGroup.induction_on f\n  intro f\n  exact AlmostHom.nonneg_total f\n\n\n/- The lemma used for `nonneg_total` is not yet proved. -/\n/-- The set of non-negative quasi-morphisms, as a 'total positive cone' (the\nconvenient way to construct ordered additive groups). -/\nnoncomputable def GP : AddCommGroup.TotalPositiveCone (QuasiHom G) where\n  nonneg := QuasiHom.nonneg\n  zero_nonneg := QuasiHom.zero_nonneg\n  add_nonneg := QuasiHom.add_nonneg\n  nonneg_antisymm := QuasiHom.nonneg_antisymm\n  nonneg_total := by simp only [QuasiHom.nonneg_total, forall_const]\n  nonnegDecidable := (Classical.dec ·.nonneg)\n\n-- instance : LinearOrder (QuasiHom G) where\n--   le := sorry\n--   le_refl := sorry\n--   le_trans := sorry\n--   le_antisymm := sorry\n--   le_total := sorry\n--   decidable_le := sorry -- how to even do this??\n--   decidable_eq := sorry -- again, HOW to do this??\n\n\n-- instance : LinearOrderedField (QuasiHom ℤ) where\n--   add_le_add_left := sorry\n--   zero_le_one := sorry\n--   mul_pos := sorry\n--   mul_comm := sorry\n--   mul_inv_cancel := sorry\n--   inv_zero := sorry\n--   le_total := sorry -- this one is already proved in LinearOrder right??\n--   decidable_le := sorry -- this one is already proved in LinearOrder right??\n  \n\nend QuasiHom\n", "meta": {"author": "Karthik-Dulam", "repo": "reals-quasi-morphisms", "sha": "0604e81bbae64fed54dbccf7bd39b17b8779050d", "save_path": "github-repos/lean/Karthik-Dulam-reals-quasi-morphisms", "path": "github-repos/lean/Karthik-Dulam-reals-quasi-morphisms/reals-quasi-morphisms-0604e81bbae64fed54dbccf7bd39b17b8779050d/RealsQuasiMorphisms/Order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4781602915049051}}
{"text": "import .arith_expr\n\nopen nat_var\nopen nat_expr\n\n\n-- variables\n\ndef X := Δ 0\ndef Y := Δ 1\ndef Z := Δ 2\ndef W := Δ 0  -- W and X are the same variable\n\n-- an interpretation\n\ndef init : nat_var → nat\n| v := nat.zero\n\n-- test interpretation override \n\nexample : init X = 0 := rfl\nexample : init Y = 0 := rfl\nexample : init Z = 0 := rfl\n\n-- \"assignment operation\"\n-- {X = 0, Y = 0, Z = 0}\ndef st_1 := override init X 2\n-- {X = 2, Y = 0, Z = 0}\n\nexample : st_1 X = 2 := rfl\nexample : st_1 Y = 0 := rfl\nexample : st_1 Z = 0 := rfl\n\n-- \"assignment operation\"\n-- {X = 2, Y = 0, Z = 0}\ndef st_2 := override (st_1) Z 5\n-- {X = 2, Y = 0, Z = 5}\n\nexample : st_2 X = 2 := rfl\nexample : st_2 Y = 0 := rfl\nexample : st_2 Z = 5 := rfl\n\n-- example expressions\n\ndef e1 := [0] -- overloaded []: literal\ndef e2 := e1 + e1\ndef e3 := e2++\ndef e4 := [X] + [Y] + [Z]   -- []: \"var\" expression\n\n-- test evaluation\n\nexample : eval e3 init = 1 := rfl\nexample : eval e4 st_2 = 7 := rfl", "meta": {"author": "kevinsullivan", "repo": "cs6501s22", "sha": "c55d342145b127e7b7bf396c660966034e80a944", "save_path": "github-repos/lean/kevinsullivan-cs6501s22", "path": "github-repos/lean/kevinsullivan-cs6501s22/cs6501s22-c55d342145b127e7b7bf396c660966034e80a944/src/assignments/hw5_expr_langs/arith_expr_test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.478107704702877}}
{"text": "import category_theory.category.Quiv\nimport category_theory.over\nimport algebra.category.CommRing\nimport mutation\n/-!\n# Cluster algebras\n\nThis file defines the upper cluster algebra and the cluter algebras associated with a seed.\n\nLet `N` be a ℤ-module equipped with a skew-symmetric form. A finite multiset \non `N` is called a seed in `N`. Let `K` be a field of fractions of the group algeba of \nthe dual module of `N`. For each seed `s`, we define `upper_cluster_algebra s` and\n`cluster_algebra s` as a subring of `K`.\n\n# Main definitions\n\n* `mutation_paths`: a category whose objects are the seeds in `N` and morphisms are the formal\n  compositions of seed mutatons.\n* `mutation_functor : paths (multiset N) ⥤ CommRingᵒᵖ`: a functor that maps seed mutations to\n  mutations.\n* `upper_cluster_algebra s`: the subring of `K` consisting of elements that are always \n  Laurent polynomials when the image of `mutation_functor` of any compositions of seed mutations\n  starting from `s` is applied. \n* `cluster_monomials s`: the set of elements in `K` that become monomials when \n  when the image of `mutation_functor` of some compositions of seed mutations starting from `s` \n  is applied. \n* `cluster_algebra s`: the subring of `K` generated by `cluster_monomials s`.\n\n## Future work\n\nProve that `cluster_monomials s` is contained in `upper_cluster_algebra s`. This is\ncalled the Laurent phenomenon of cluster algebras.\n\n-/\n\nnoncomputable theory\n\nopen category_theory opposite\n\nlocal attribute [class] is_integral_domain\n\nsection\n\nvariables \n(N : Type*) [add_comm_group N] [skew_symmetric_form N] [is_integral_domain (ring_of_function N)]\n(K : Type*) [field K] [algebra (ring_of_function N) K] [is_fraction_ring (ring_of_function N) K]\n\ninstance : algebra (ring_of_function N) ↥(CommRing.of K) := by {dsimp, apply_instance}\ninstance : is_fraction_ring (ring_of_function N) ↥(CommRing.of K) := by {dsimp, apply_instance}\ninstance : field ↥(CommRing.of K) := by {dsimp, apply_instance}\n\ndef laurent_subring : subring K := (algebra_map (ring_of_function N) K).range\n\nprivate def z \n{N : Type*} [add_comm_group N] [skew_symmetric_form N]\n{K : Type*} [field K] [algebra (ring_of_function N) K] \n[is_fraction_ring (ring_of_function N) K] (m : module.dual ℤ N) := \nalgebra_map (ring_of_function N) K (finsupp.single m 1)\n\ndef seeds : quiver (multiset N) :=\n{ hom := seed_mutation }\n\nlocal attribute [instance] seeds\n\ndef mutation_paths : category (paths (multiset N)) := \n(paths.category_paths (multiset N))\n\nlocal attribute [instance] mutation_paths\n\ndef mutation_prefunctor : prefunctor (multiset N) CommRingᵒᵖ :=\n{ obj := λ s,  op (CommRing.of K),\n  map := λ s s' μ, quiver.hom.op (ring_equiv.to_ring_hom (μ.field_equiv K))}\n\n@[simp] lemma mutation_prefunctor.obj_eq_ring (s : multiset N) : \n(mutation_prefunctor N K).obj s = op (CommRing.of K) := by refl\n\ndef mutation_functor : paths (multiset N) ⥤ CommRingᵒᵖ :=\n{ obj := λ s, (mutation_prefunctor N K).obj s,\n  map := λ s s' γ, compose_path ((mutation_prefunctor N K).map_path γ),\n  map_id' := λ γ, by refl,\n  map_comp' := by {rintros, simp} }\n\n@[simp] lemma mutation_functor.obj_eq_ring (γ : paths (multiset N)) : \n(mutation_functor N K).obj γ = op (CommRing.of K) := by refl\n\nend\n\nsection\nvariables \n{N : Type*} [add_comm_group N] [skew_symmetric_form N] [is_integral_domain (ring_of_function N)]\n{K : Type*} [field K] [algebra (ring_of_function N) K] [is_fraction_ring (ring_of_function N) K]\n\nlocal attribute [instance] seeds\nlocal attribute [instance] mutation_paths\n\nvariables (s : multiset N)\ninclude s\n\ndef field_hom_of_under_mutation_path (γ : @under _ (mutation_paths N) s) : K →+* K :=\nlet g := quiver.hom.unop ((under.post (mutation_functor N K)).obj γ).hom in by simpa using g\n\ndef upper_cluster_algebra := ⨅ γ, (laurent_subring N K).map (field_hom_of_under_mutation_path s γ)\n\ndef vector.is_monomial_at := { m : module.dual ℤ N | ∀ v ∈ s, m v ≥ 0 }\n\ndef is_monomial_at := { f : K | ∃ m : module.dual ℤ N, f = z m ∧ vector.is_monomial_at s m }\n\ndef cluster_monomials : set K := \n⋃ γ, field_hom_of_under_mutation_path s γ '' is_monomial_at (γ.right)\n\ndef cluster_algebra : subring K := subring.closure (cluster_monomials s)\n\ndef laurent_phenomenon : Prop := (cluster_algebra s : subring K) ≤ upper_cluster_algebra s\n\nend", "meta": {"author": "yuma-mizuno", "repo": "lean-cluster-algebra", "sha": "4a4fb128566305eda2b82aea068157cb43afdf18", "save_path": "github-repos/lean/yuma-mizuno-lean-cluster-algebra", "path": "github-repos/lean/yuma-mizuno-lean-cluster-algebra/lean-cluster-algebra-4a4fb128566305eda2b82aea068157cb43afdf18/src/cluster_algebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.478107704702877}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monoidal.braided\nimport Mathlib.category_theory.functor_category\nimport Mathlib.category_theory.const\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ \n\nnamespace Mathlib\n\n/-!\n# Monoidal structure on `C ⥤ D` when `D` is monoidal.\n\nWhen `C` is any category, and `D` is a monoidal category,\nthere is a natural \"pointwise\" monoidal structure on `C ⥤ D`.\n\nThe initial intended application is tensor product of presheaves.\n-/\n\nnamespace category_theory.monoidal\n\n\nnamespace functor_category\n\n\n/--\n(An auxiliary definition for `functor_category_monoidal`.)\nTensor product of functors `C ⥤ D`, when `D` is monoidal.\n -/\ndef tensor_obj {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] (F : C ⥤ D) (G : C ⥤ D) : C ⥤ D :=\n  functor.mk (fun (X : C) => functor.obj F X ⊗ functor.obj G X)\n    fun (X Y : C) (f : X ⟶ Y) => functor.map F f ⊗ functor.map G f\n\n/--\n(An auxiliary definition for `functor_category_monoidal`.)\nTensor product of natural transformations into `D`, when `D` is monoidal.\n-/\ndef tensor_hom {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {F' : C ⥤ D} {G' : C ⥤ D} (α : F ⟶ G) (β : F' ⟶ G') : tensor_obj F F' ⟶ tensor_obj G G' :=\n  nat_trans.mk fun (X : C) => nat_trans.app α X ⊗ nat_trans.app β X\n\nend functor_category\n\n\n/--\nWhen `C` is any category, and `D` is a monoidal category,\nthe functor category `C ⥤ D` has a natural pointwise monoidal structure,\nwhere `(F ⊗ G).obj X = F.obj X ⊗ G.obj X`.\n-/\nprotected instance functor_category_monoidal {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] : monoidal_category (C ⥤ D) :=\n  monoidal_category.mk (fun (F G : C ⥤ D) => functor_category.tensor_obj F G)\n    (fun (F G F' G' : C ⥤ D) (α : F ⟶ G) (β : F' ⟶ G') => functor_category.tensor_hom α β)\n    (functor.obj (functor.const C) 𝟙_) (fun (F G H : C ⥤ D) => nat_iso.of_components (fun (X : C) => α_) sorry)\n    (fun (F : C ⥤ D) => nat_iso.of_components (fun (X : C) => λ_) sorry)\n    fun (F : C ⥤ D) => nat_iso.of_components (fun (X : C) => ρ_) sorry\n\n@[simp] theorem tensor_unit_obj {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {X : C} : functor.obj 𝟙_ X = 𝟙_ :=\n  rfl\n\n@[simp] theorem tensor_unit_map {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {X : C} {Y : C} {f : X ⟶ Y} : functor.map 𝟙_ f = 𝟙 :=\n  rfl\n\n@[simp] theorem tensor_obj_obj {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {X : C} : functor.obj (F ⊗ G) X = functor.obj F X ⊗ functor.obj G X :=\n  rfl\n\n@[simp] theorem tensor_obj_map {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {X : C} {Y : C} {f : X ⟶ Y} : functor.map (F ⊗ G) f = functor.map F f ⊗ functor.map G f :=\n  rfl\n\n@[simp] theorem tensor_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {F' : C ⥤ D} {G' : C ⥤ D} {α : F ⟶ G} {β : F' ⟶ G'} {X : C} : nat_trans.app (α ⊗ β) X = nat_trans.app α X ⊗ nat_trans.app β X :=\n  rfl\n\n@[simp] theorem left_unitor_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.hom λ_) X = iso.hom λ_ :=\n  rfl\n\n@[simp] theorem left_unitor_inv_app {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.inv λ_) X = iso.inv λ_ :=\n  rfl\n\n@[simp] theorem right_unitor_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.hom ρ_) X = iso.hom ρ_ :=\n  rfl\n\n@[simp] theorem right_unitor_inv_app {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.inv ρ_) X = iso.inv ρ_ :=\n  rfl\n\n@[simp] theorem associator_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {H : C ⥤ D} {X : C} : nat_trans.app (iso.hom α_) X = iso.hom α_ :=\n  rfl\n\n@[simp] theorem associator_inv_app {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {H : C ⥤ D} {X : C} : nat_trans.app (iso.inv α_) X = iso.inv α_ :=\n  rfl\n\n/--\nWhen `C` is any category, and `D` is a braided monoidal category,\nthe natural pointwise monoidal structure on the functor category `C ⥤ D`\nis also braided.\n-/\nprotected instance functor_category_braided {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] [braided_category D] : braided_category (C ⥤ D) :=\n  braided_category.mk fun (F G : C ⥤ D) => nat_iso.of_components (fun (X : C) => β_) sorry\n\n/--\nWhen `C` is any category, and `D` is a symmetric monoidal category,\nthe natural pointwise monoidal structure on the functor category `C ⥤ D`\nis also symmetric.\n-/\nprotected instance functor_category_symmetric {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D] [symmetric_category D] : symmetric_category (C ⥤ D) :=\n  symmetric_category.mk\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.47810770470287695}}
{"text": "import for_mathlib.algebra.homology.mapping_cone\nimport algebra.homology.additive\nimport for_mathlib.category_theory.triangulated.pretriangulated_misc\nimport for_mathlib.category_theory.triangulated.shift_triangle\nimport for_mathlib.category_theory.preadditive.misc\n\nopen category_theory category_theory.pretriangulated category_theory.triangulated\n  category_theory.limits category_theory.category\n\nnoncomputable theory\n\nsection\n\nvariables {C ι : Type*} [category C] [preadditive C] {c : complex_shape ι}\n\ndef homotopy_category.lift {K L : homological_complex C c}\n  (φ : (homotopy_category.quotient _ _).obj K ⟶ (homotopy_category.quotient _ _).obj L) :\n  K ⟶ L := quot.out φ\n\ninstance [has_zero_object C] : has_zero_object (homotopy_category C c) :=\nby { change has_zero_object (category_theory.quotient _), apply_instance, }\n\ninstance : preadditive (homotopy_category C c) :=\nbegin\n  apply quotient.preadditive,\n  { rintros X Y f₁ g₁ f₂ g₂ ⟨h₁⟩ ⟨h₂⟩,\n    refine ⟨homotopy.add h₁ h₂⟩, },\n  { rintros X Y f g ⟨h⟩,\n    exact ⟨homotopy.equiv_sub_zero.symm\n      (by simpa only [neg_sub_neg] using homotopy.equiv_sub_zero h.symm)⟩, },\nend\n\ninstance homotopy_category.quotient_additive :\n  (homotopy_category.quotient C c).additive := quotient.functor_additive _ _ _\n\nlemma is_zero_of_homotopy_id_zero [has_zero_object C] (X : homological_complex C c)\n  (h : homotopy (𝟙 X) 0) :\n  is_zero ((homotopy_category.quotient C c).obj X) :=\nbegin\n  have eq := homotopy_category.eq_of_homotopy _ _ h,\n  simp only [category_theory.functor.map_id] at eq,\n  simp only [is_zero.iff_id_eq_zero, eq, functor.map_zero],\nend\n\nend\n\nvariables {C : Type*} [category C] [preadditive C] [has_zero_object C]\n  [has_binary_biproducts C]\n  {K L : cochain_complex C ℤ} (φ : K ⟶ L)\n\nnamespace cochain_complex\n\n@[simps mor₁ mor₂ mor₃]\ndef mapping_cone.triangle : triangle (cochain_complex C ℤ) :=\ntriangle.mk φ (mapping_cone.inr φ) (mapping_cone.δ φ)\n\nsection\nvariables {K₁ K₂ L₁ L₂ : cochain_complex C ℤ}\n  [∀ p, has_binary_biproduct (K₁.X (p+1-(0 : ℤ))) (L₁.X p)]\n  [∀ p, has_binary_biproduct (K₂.X (p+1-(0 : ℤ))) (L₂.X p)]\n  (f₁ : K₁ ⟶ L₁) (f₂ : K₂ ⟶ L₂) (τ₁ : K₁ ⟶ K₂) (τ₂ : L₁ ⟶ L₂) (comm : f₁ ≫ τ₂ = τ₁ ≫ f₂)\n\n@[simps]\ndef mapping_cone.triangle_map : mapping_cone.triangle f₁ ⟶ mapping_cone.triangle f₂ :=\n{ hom₁ := τ₁,\n  hom₂ := τ₂,\n  hom₃ := mapping_cone.map _ _ _ _ comm,\n  comm₁' := comm,\n  comm₂' := mapping_cone.inr_comp_map _ _ _ _ comm,\n  comm₃' := (mapping_cone.map_comp_δ _ _ _ _ comm).symm, }\n\n@[simps]\ndef mapping_cone.triangle_map_iso {D : Type*} [category D] [preadditive D] [has_zero_object D]\n  [has_binary_biproducts D]\n  (Φ : C ⥤ D) [Φ.additive]:\n  (functor.map_triangle (Φ.map_homological_complex (complex_shape.up ℤ))).obj\n    (mapping_cone.triangle φ) ≅ mapping_cone.triangle ((Φ.map_homological_complex _).map φ) :=\nbegin\n  refine triangle.mk_iso _ _ (iso.refl _) (iso.refl _) (mapping_cone.map_iso φ Φ) _ _ _,\n  { tidy, },\n  { ext n,\n    rw mapping_cone.to_ext_iff _ _ (n+1) rfl,\n    dsimp,\n    simp only [assoc, mapping_cone.lift_fst_f, hom_complex.cocycle.map_coe,\n      hom_complex.cochain.map_v, id_comp, mapping_cone.inr_fst,\n      mapping_cone.lift_snd_f, mapping_cone.inr_snd, ← Φ.map_comp, Φ.map_zero, Φ.map_id],\n    tauto, },\n  { ext n,\n    dsimp [mapping_cone.δ, mapping_cone.triangle],\n    simp only [assoc, hom_complex.cochain.right_shift_v _ 1 0\n        (zero_add 1).symm n n (add_zero n).symm _ rfl,\n      shift_functor_obj_X_iso, hom_complex.cochain.neg_v, homological_complex.X_iso_of_eq_refl,\n      preadditive.neg_comp, functor.map_neg, functor.map_comp, assoc, preadditive.comp_neg,\n      mapping_cone.lift_fst_f_assoc, hom_complex.cocycle.map_coe,\n      hom_complex.cochain.map_v, neg_inj],\n    dsimp [iso.refl],\n    erw [Φ.map_id, id_comp, comp_id, comp_id], },\nend\n\nend\n\nend cochain_complex\n\nopen cochain_complex\n\nnamespace homotopy_category\n\ndef mapping_cone_triangle' : triangle (homotopy_category C (complex_shape.up ℤ)) :=\ntriangle.mk ((homotopy_category.quotient _ _).map φ) (mapping_cone.ι' φ) (mapping_cone.δ' φ)\n\nvariable (C)\n\ndef distinguished_triangles : set (triangle (homotopy_category C (complex_shape.up ℤ))) :=\nλ T, ∃ (K L : cochain_complex C ℤ) (φ : K ⟶ L),\n  nonempty (T ≅ mapping_cone_triangle' φ)\n\nvariable {C}\n\nlemma mapping_cone_triangle'_distinguished :\n  mapping_cone_triangle' φ ∈ distinguished_triangles C :=\n⟨_, _, φ, nonempty.intro (iso.refl _)⟩\n\ninstance shift_functor_additive (n : ℤ) :\n  (category_theory.shift_functor (homotopy_category C (complex_shape.up ℤ)) n).additive := { }\n\nlemma isomorphic_distinguished\n  (T₁ : triangle (homotopy_category C (complex_shape.up ℤ)))\n  (h₁ : T₁ ∈ distinguished_triangles C)\n  (T₂ : triangle (homotopy_category C (complex_shape.up ℤ)))\n  (e : T₂ ≅ T₁) : T₂ ∈ distinguished_triangles C :=\nbegin\n  obtain ⟨K, L, φ, ⟨e'⟩⟩ := h₁,\n  exact ⟨K, L, φ, ⟨e ≪≫ e'⟩⟩,\nend\n\nlemma contractible_distinguished\n  (X : homotopy_category C (complex_shape.up ℤ)) :\n  contractible_triangle X ∈ distinguished_triangles C :=\nbegin\n  cases X,\n  refine ⟨_, _, 𝟙 X, ⟨_⟩⟩,\n  have h : is_zero ((homotopy_category.quotient _ _).obj (mapping_cone (𝟙 X))),\n  { refine is_zero_of_homotopy_id_zero _ _,\n    exact mapping_cone.desc_homotopy _ _ _ 0 (mapping_cone.inl (𝟙 X)) (by simp) (by simp), },\n  exact triangle.mk_iso _ _ (iso.refl _) (iso.refl _) (is_zero.iso_zero h).symm\n    (by tidy) (is_zero.eq_of_tgt h _ _) (by simp only [is_zero.eq_of_src h\n      ((mapping_cone_triangle' (𝟙 X)).mor₃) 0, contractible_triangle_mor₃, zero_comp, comp_zero]),\nend\n\nlemma distinguished_cocone_triangle\n  (X Y : homotopy_category C (complex_shape.up ℤ)) (f : X ⟶ Y) :\n  ∃ (Z : homotopy_category C (complex_shape.up ℤ)) (g : Y ⟶ Z)\n    (h : Z ⟶ X⟦(1 : ℤ)⟧), triangle.mk f g h ∈ distinguished_triangles C :=\nbegin\n  cases X,\n  cases Y,\n  obtain ⟨φ, rfl⟩ := quotient.functor_map_surjective _ _ f,\n  exact ⟨_ ,_ ,_ , mapping_cone_triangle'_distinguished φ⟩,\nend\n\nopen cochain_complex.hom_complex\n\nlemma complete_distinguished_triangle_morphism'\n  {K₁ L₁ K₂ L₂ : cochain_complex C ℤ} (φ₁ : K₁ ⟶ L₁) (φ₂ : K₂ ⟶ L₂)\n  (a : K₁ ⟶ K₂) (b : L₁ ⟶ L₂) (hab : homotopy (φ₁ ≫ b) (a ≫ φ₂)) :\n  ∃ (c : mapping_cone φ₁ ⟶ mapping_cone φ₂),\n    nonempty (homotopy (mapping_cone.inr φ₁ ≫ c) (b ≫ mapping_cone.inr φ₂)) ∧\n      nonempty (homotopy (mapping_cone.δ φ₁ ≫ a⟦1⟧') (c ≫ mapping_cone.δ φ₂)) :=\nbegin\n  obtain ⟨z, hz⟩ := (equiv_homotopy _ _) hab, clear hab,\n  refine ⟨_, _, _⟩,\n  refine mapping_cone.desc _\n    (z.comp (cochain.of_hom (mapping_cone.inr φ₂)) (add_zero _).symm +\n      (cochain.of_hom a).comp (mapping_cone.inl φ₂) (zero_add _).symm)\n    (b ≫ mapping_cone.inr φ₂) _,\n  { simp only [δ_comp_of_second_is_zero_cochain _ _ _ (neg_add_self 1),\n      cocycle.δ_cochain_of_hom, cochain.comp_zero, zero_add, ← assoc,\n      cochain.of_hom_comp (φ₁ ≫ b), hz, cochain.add_comp, δ_add, ← cochain.of_hom_comp],\n    simp only [add_zero, add_left_neg, δ_comp_of_first_is_zero_cochain, mapping_cone.δ_inl,\n      cochain.of_hom_comp, cocycle.δ_cochain_of_hom, cochain.zero_comp, smul_zero, assoc], },\n  { exact nonempty.intro (homotopy.of_eq (by simp)), },\n  { refine nonempty.intro (homotopy.of_eq ((cocycle.equiv_hom _ _).injective _)),\n    ext1,\n    simp only [mapping_cone.δ, cochain.of_hom_comp, cocycle.equiv_hom_apply, cocycle.of_hom_coe,\n      cocycle.cochain_of_hom_hom_of_eq_coe, cocycle.right_shift_coe,\n      mapping_cone.δ_as_cocycle_coe],\n    ext1,\n    simp only [cochain.comp_zero_cochain, cochain.of_hom_v,\n      cochain.right_shift_v _ 1 0 (zero_add 1).symm p p (add_zero p).symm _ rfl,\n      shift_functor_obj_X_iso, assoc, cochain.neg_v,\n      homological_complex.X_iso_of_eq_refl, preadditive.neg_comp, preadditive.comp_neg, neg_inj],\n    dsimp [iso.refl],\n    simp only [comp_id, id_comp, mapping_cone.from_ext_iff _ _ _ rfl],\n    split,\n    { simp only [zero_add, assoc, mapping_cone.inl_desc_v_assoc, cochain.add_v,\n        cochain.comp_zero_cochain, cochain.of_hom_v, cochain.zero_cochain_comp,\n        preadditive.add_comp, mapping_cone.inr_fst, comp_zero, mapping_cone.inl_fst, comp_id,\n        mapping_cone.inl_fst_assoc], },\n    { simp only [mapping_cone.inr_fst_assoc, mapping_cone.inr_fst, zero_comp, comp_zero,\n        assoc, mapping_cone.inr_desc_f_assoc, homological_complex.comp_f], }, },\nend\n\nlemma complete_distinguished_triangle_morphism\n  (T₁ T₂ : triangle (homotopy_category C (complex_shape.up ℤ)))\n  (h₁ : T₁ ∈ distinguished_triangles C) (h₂ : T₂ ∈ distinguished_triangles C)\n  (a : T₁.obj₁ ⟶ T₂.obj₁) (b : T₁.obj₂ ⟶ T₂.obj₂)\n  (comm₁ : T₁.mor₁ ≫ b = a ≫ T₂.mor₁) :\n  ∃ (c : T₁.obj₃ ⟶ T₂.obj₃), T₁.mor₂ ≫ c = b ≫ T₂.mor₂ ∧\n    T₁.mor₃ ≫ a⟦(1 : ℤ)⟧' = c ≫ T₂.mor₃ :=\nbegin\n  obtain ⟨K₁, L₁, φ₁, ⟨e₁⟩⟩ := h₁,\n  obtain ⟨K₂, L₂, φ₂, ⟨e₂⟩⟩ := h₂,\n  obtain ⟨c, ⟨h₁⟩, ⟨h₂⟩⟩ := complete_distinguished_triangle_morphism' φ₁ φ₂\n    (quot.out (e₁.inv.hom₁ ≫ a ≫ e₂.hom.hom₁)) (quot.out (e₁.inv.hom₂ ≫ b ≫ e₂.hom.hom₂))\n    (homotopy_of_eq _ _ begin\n      simp only [functor.map_comp, quotient_map_out, category.assoc],\n      erw [reassoc_of e₁.inv.comm₁, reassoc_of comm₁, e₂.hom.comm₁],\n      refl,\n    end),\n  replace h₁ := eq_of_homotopy _ _ h₁,\n  replace h₂ := eq_of_homotopy _ _ h₂,\n  refine ⟨e₁.hom.hom₃ ≫ (homotopy_category.quotient _ _).map c ≫ e₂.inv.hom₃, _, _⟩,\n  { simp only [functor.map_comp, quotient_map_out, category.assoc] at h₁,\n    erw [reassoc_of e₁.hom.comm₂, reassoc_of h₁, e₂.inv.comm₂],\n    simp only [triangle.hom_inv_id_hom₂_assoc], },\n  { erw [functor.map_comp, quotient_map_shift] at h₂,\n    simp only [quotient_map_out, functor.map_comp] at h₂,\n    simp only [category.assoc, ← e₂.inv.comm₃],\n    erw [← reassoc_of h₂, ← reassoc_of e₁.hom.comm₃],\n    simp only [← functor.map_comp, triangle.hom_inv_id_hom₁, category.comp_id,\n      triangle.hom_inv_id_hom₁_assoc], },\nend\n\n@[simps]\ndef rotate_distinguished_triangle_homotopy_equiv {K L : cochain_complex C ℤ} (φ : K ⟶ L) :\n  homotopy_equiv (K⟦(1 : ℤ)⟧) (mapping_cone (mapping_cone.inr φ)) :=\n{ hom := mapping_cone.lift _\n    (-cocycle.left_shift (cocycle.of_hom φ) 1 1 (zero_add 1).symm)\n    (-(mapping_cone.inl φ).left_shift 1 0 (neg_add_self 1).symm)\n    begin\n      simp only [δ_neg, mapping_cone.δ_inl, cochain.δ_left_shift\n        (mapping_cone.inl φ) 1 _ 0 _ (neg_add_self 1).symm (zero_add 1).symm,\n        ε_1, neg_smul, neg_neg, one_smul],\n      ext1 p q hpq,\n      simp only [cochain.add_v,\n        cochain.left_shift_v _ 1 1 (zero_add 1).symm p _ hpq _ hpq,\n        cochain.comp_zero_cochain, shift_functor_obj_X_iso, add_zero,\n        mul_one, sub_self, mul_zero, euclidean_domain.zero_div, ε_1, neg_smul,\n        homological_complex.X_iso_of_eq_refl, cochain.of_hom_comp, cochain.of_hom_v,\n        one_zsmul, add_subgroup.coe_neg, cocycle.left_shift_coe, cocycle.of_hom_coe,\n        cochain.neg_v, preadditive.neg_comp, cochain.zero_v, neg_neg, assoc,\n        neg_add_self],\n    end,\n  inv := mapping_cone.desc _ 0 (mapping_cone.δ φ)\n    (by simp only [δ_zero, mapping_cone.inr_δ, cochain.of_hom_zero]),\n  homotopy_hom_inv_id := homotopy.of_eq begin\n    ext n : 2,\n    simp only [homological_complex.comp_f, homological_complex.id_f,\n      mapping_cone.lift_desc_f _ _ _ _ _ _ _ _ _ rfl,\n      mapping_cone.δ, mapping_cone.δ_as_cocycle, zero_add, add_subgroup.coe_neg,\n      cochain.neg_v, cochain.zero_v, preadditive.neg_comp, comp_zero,\n      cocycle.hom_of_f, cocycle.right_shift_coe,\n      cochain.left_shift_v _ _ _ (neg_add_self 1).symm n n (by linarith) _ rfl,\n      cochain.right_shift_v _ _ _ (zero_add 1).symm n n (by linarith) _ rfl,\n      zero_add, mul_zero, sub_self, euclidean_domain.zero_div, ε_0, one_zsmul,\n      preadditive.comp_neg, assoc, mapping_cone.inl_fst_assoc, iso.hom_inv_id, neg_neg],\n  end,\n  homotopy_inv_hom_id := (equiv_homotopy _ _).symm begin\n    refine ⟨-(mapping_cone.snd (mapping_cone.inr φ)).comp ((mapping_cone.snd φ).comp\n      (mapping_cone.inl (mapping_cone.inr φ)) (zero_add (-1)).symm) (zero_add (-1)).symm, _⟩,\n    rw mapping_cone.cochain_ext _ _ (neg_add_self 1).symm,\n    split,\n    { simp only [cochain.of_hom_comp, ← cochain.comp_assoc_of_second_is_zero_cochain,\n        mapping_cone.inl_desc, cochain.zero_comp,\n        δ_comp_of_first_is_zero_cochain _ _ _ (neg_add_self 1),\n        mapping_cone.δ_inl, cochain.comp_add, ← cochain.comp_assoc_of_third_is_zero_cochain,\n        mapping_cone.inl_comp_snd, cochain.zero_comp, zero_add, cochain.comp_id,\n        δ_comp_of_first_is_zero_cochain _ _ _ (zero_add 1), ε_0, one_smul, ε_neg, ε_1,\n        neg_smul, cochain.comp_neg, cochain.add_comp, neg_zero, neg_neg,\n        ← cochain.comp_assoc _ _ _ (neg_add_self 1).symm (add_neg_self 1).symm\n        (show (-1 : ℤ) = -1+1+(-1), by linarith), mapping_cone.δ_snd, cochain.neg_comp,\n        mapping_cone.inl_comp_fst, cochain.id_comp,\n        mapping_cone.inr_comp_snd, δ_neg, add_left_neg], },\n    { ext1,\n      simp only [assoc, add_left_neg, eq_self_iff_true, neg_neg, cochain.of_hom_comp,\n        cochain.comp_zero_cochain, cochain.of_hom_v, mapping_cone.inr_desc_f_assoc, δ_neg,\n        δ_comp_of_first_is_zero_cochain, mapping_cone.δ_inl, mapping_cone.δ_snd, one_smul,\n        cochain.neg_comp, cochain.comp_assoc_of_second_is_zero_cochain, zsmul_neg', neg_smul,\n        cochain.comp_add, cochain.comp_neg, cochain.comp_zsmul, neg_add_rev, cochain.comp_id,\n        cochain.add_v, cochain.zsmul_v, mapping_cone.inr_snd_assoc, cochain.neg_v, ε_neg, ε_1,\n        mapping_cone.δ, mapping_cone.δ_as_cocycle, cocycle.hom_of_f,\n        cocycle.right_shift_coe, add_subgroup.coe_neg,\n        cochain.right_shift_v _ _ _ (zero_add 1).symm p p (by linarith) _ rfl,\n        shift_functor_obj_X_iso, homological_complex.X_iso_of_eq_refl,\n        mapping_cone.lift_f _ _ _ _ _ _ rfl, preadditive.comp_add,\n        cochain.left_shift_v _ _ _ (neg_add_self 1).symm _ _ _ _ rfl, mul_zero,\n        zero_add, one_mul, sub_self, euclidean_domain.zero_div, ε_0, cocycle.left_shift,\n        cocycle.of_hom_coe, preadditive.comp_neg, preadditive.neg_comp, add_subgroup.coe_mk,\n        cochain.left_shift_v _ _ _ (zero_add 1).symm _ _ _ _ rfl, add_zero,\n        cochain.comp_v _ _ (add_neg_self (1 : ℤ)).symm p _ p rfl (by linarith),\n        cochain.comp_v _ _ (zero_add (-1)).symm (p+1) (p+1) p (by linarith) (by linarith),\n        mapping_cone.inr_fst_assoc, zero_comp, zero_add, neg_zero,\n        iso.inv_hom_id_assoc, reassoc_of (eq_sub_of_add_eq (mapping_cone.id φ p _ rfl)),\n        preadditive.sub_comp, id_comp],\n      abel, },\n  end, }\n\nlemma rotate_distinguished_triangle₁ (T : triangle (homotopy_category C (complex_shape.up ℤ)))\n  (hT : T ∈ distinguished_triangles C) : T.rotate ∈ distinguished_triangles C :=\nbegin\n  obtain ⟨K, L, φ, ⟨e⟩⟩:= hT,\n  suffices : (mapping_cone_triangle' φ).rotate ∈ distinguished_triangles C,\n  { exact isomorphic_distinguished _ this _ ((rotate _).map_iso e), },\n  refine ⟨_,_, mapping_cone.inr φ, ⟨triangle.mk_iso _ _ (iso.refl _) (iso.refl _)\n    (iso_of_homotopy_equiv (rotate_distinguished_triangle_homotopy_equiv φ))\n    (by tidy) (eq_of_homotopy _ _ _) (eq_of_homotopy _ _ (homotopy.of_eq _))⟩⟩,\n  { rw id_comp,\n    symmetry,\n    equiv_rw equiv_homotopy  _ _,\n    refine ⟨(mapping_cone.snd φ).comp (mapping_cone.inl (mapping_cone.inr φ)) (zero_add _).symm,\n      _⟩,\n    simp only [δ_comp_of_first_is_zero_cochain _ _ _ (neg_add_self 1),\n      mapping_cone.δ_inl, cochain.of_hom_comp, mapping_cone.δ_snd,\n      subtype.val_eq_coe, mapping_cone.cochain_ext _ _ (neg_add_self 1).symm,\n      cochain.comp_add],\n    split,\n    { simp only [← cochain.comp_assoc_of_first_is_zero_cochain,\n        ← cochain.comp_assoc_of_second_is_zero_cochain,\n        ← cochain.comp_assoc_of_third_is_zero_cochain, cochain.comp_zsmul,\n        mapping_cone.inl_comp_snd, cochain.zero_comp, zero_add, cochain.neg_comp,\n        cochain.comp_neg, smul_neg, ε_neg, ε_1, neg_smul, neg_neg, one_smul,\n        ← cochain.comp_assoc _ _ _ (neg_add_self 1).symm (add_neg_self 1).symm\n        (show (-1 : ℤ) =-1+1+(-1), by linarith), mapping_cone.inl_comp_fst,\n        cochain.id_comp],\n      rw mapping_cone.cochain_ext' _ _ (neg_add_self 1).symm,\n      split,\n      { dsimp only [rotate_distinguished_triangle_homotopy_equiv],\n        simp only [cochain.add_comp, cochain.comp_assoc_of_first_is_zero_cochain,\n          cochain.comp_assoc_of_second_is_zero_cochain, mapping_cone.inr_comp_fst,\n          mapping_cone.inl_comp_fst, cochain.comp_id, cochain.comp_zero,\n          mapping_cone.lift_fst, add_subgroup.coe_neg, cocycle.left_shift_coe,\n          cocycle.of_hom_coe, cochain.comp_neg, mapping_cone.δ, mapping_cone.δ_as_cocycle,\n          cocycle.cochain_of_hom_hom_of_eq_coe, cocycle.right_shift_coe, add_subgroup.coe_neg],\n        ext n,\n        dsimp [mapping_cone_triangle'],\n        simp only [cochain.zero_v, cochain.add_v, cochain.of_hom_v, cochain.neg_v,\n          cochain.comp_v _ _ (neg_add_self 1).symm n (n-1) n (by linarith) (by linarith),\n          cochain.comp_v _ _ (zero_add 1).symm (n-1) (n-1) n (by linarith) (by linarith),\n          cochain.right_shift_v _ _ _ (zero_add 1).symm (n-1) (n-1) (by linarith) n (by linarith),\n          cochain.left_shift_v _ _ _ (zero_add 1).symm (n-1) n (by linarith) n (by linarith),\n          add_zero, neg_neg, shift_functor_obj_X_iso, preadditive.neg_comp, mul_one, sub_self,\n          mul_zero, euclidean_domain.zero_div, ε_1, neg_smul, one_zsmul, preadditive.comp_neg,\n          preadditive.neg_comp_assoc, assoc, homological_complex.X_iso_of_eq_inv_hom,\n          homological_complex.X_iso_of_eq_refl, iso.refl_hom, comp_id,\n          mapping_cone.inl_fst_assoc, add_right_neg], },\n      { dsimp only [rotate_distinguished_triangle_homotopy_equiv],\n        simp only [cochain.add_comp, cochain.comp_assoc_of_first_is_zero_cochain,\n          cochain.comp_assoc_of_third_is_zero_cochain, mapping_cone.lift_snd,\n          mapping_cone.inl_comp_snd, cochain.comp_zero, zero_add,\n          mapping_cone.inr_comp_snd, cochain.comp_id, mapping_cone.δ,\n          cocycle.cochain_of_hom_hom_of_eq_coe, cocycle.right_shift_coe,\n          mapping_cone.δ_as_cocycle_coe, cochain.comp_neg],\n        ext1 p q hpq,\n        simp only [cochain.neg_v, cochain.comp_zero_cochain,\n          cochain.left_shift_v _ _ _ (neg_add_self 1).symm q q (by linarith) p (by linarith),\n          cochain.right_shift_v _ _ _ (zero_add 1).symm q q (by linarith) p (by linarith),\n          zero_add, neg_neg, shift_functor_obj_X_iso, preadditive.neg_comp, mul_zero, sub_self,\n          euclidean_domain.zero_div, ε_0, one_zsmul, preadditive.neg_comp_assoc, assoc,\n          homological_complex.X_iso_of_eq_inv_hom, homological_complex.X_iso_of_eq_refl,\n          iso.refl_hom, comp_id, preadditive.comp_neg, mapping_cone.inl_fst_assoc],\n        dsimp only [mapping_cone_triangle'],\n        erw [iso.inv_hom_id_assoc], }, },\n    { simp only [← cochain.comp_assoc_of_first_is_zero_cochain, mapping_cone.inr_comp_snd,\n        cochain.id_comp, cochain.comp_zsmul, mapping_cone.δ,\n        ← cochain.comp_assoc_of_third_is_zero_cochain, cochain.comp_neg,\n        mapping_cone.inr_comp_fst, cochain.zero_comp, neg_zero, smul_zero, add_zero,\n        mapping_cone.δ_as_cocycle, self_eq_add_right, cocycle.right_shift_coe,\n        cocycle.cochain_of_hom_hom_of_eq_coe],\n      ext1 n,\n      simp only [add_subgroup.coe_neg, cochain.comp_assoc_of_third_is_zero_cochain,\n        cochain.comp_zero_cochain, cochain.of_hom_v, cochain.zero_v,\n        cochain.right_shift_v _ _ _ (zero_add 1).symm n n (by linarith) _ rfl, assoc,\n        cochain.neg_v, preadditive.neg_comp, preadditive.comp_neg,\n        mapping_cone.inr_fst_assoc, zero_comp, neg_zero], }, },\n  { ext n,\n    dsimp only [rotate_distinguished_triangle_homotopy_equiv],\n    simp only [category_theory.functor.map_id, preadditive.neg_comp,\n      homological_complex.neg_f_apply, homological_complex.comp_f,\n      cocycle.hom_of_f, cocycle.right_shift_coe, mapping_cone.δ_as_cocycle_coe,\n      shift_functor_map_f', mapping_cone.δ,\n      cochain.right_shift_v _ _ _ (zero_add 1).symm n n (by linarith) _ rfl,\n      shift_functor_obj_X_iso, cochain.neg_v, homological_complex.X_iso_of_eq_refl,\n      preadditive.comp_neg, neg_inj,\n      mapping_cone.lift_fst_f_assoc, add_subgroup.coe_neg,\n      cocycle.left_shift_coe, cocycle.of_hom_coe, cochain.neg_v,\n      cochain.left_shift_v _ _ _ (zero_add 1).symm _ _ rfl _ rfl,\n      mul_one, sub_self, mul_zero, euclidean_domain.zero_div, add_zero, ε_1,\n      homological_complex.X_iso_of_eq_refl, cochain.of_hom_v, neg_smul, one_zsmul, neg_neg],\n    erw [iso.refl_hom, iso.refl_inv, id_comp, comp_id], },\nend\n\n@[simps]\ndef triangle_shift (T : triangle (homotopy_category C (complex_shape.up ℤ))) (n : ℤ) :\n  triangle (homotopy_category C (complex_shape.up ℤ)) :=\ntriangle.mk (ε n • T.mor₁⟦n⟧') (ε n • T.mor₂⟦n⟧') (ε n • T.mor₃⟦n⟧' ≫ (shift_comm T.obj₁ 1 n).hom)\n\ninstance cochain_complex_shift_functor_additive (n : ℤ) :\n  (category_theory.shift_functor (cochain_complex C ℤ) n).additive := { }\n\ninstance has_comm_shift :\n  (homotopy_category.quotient C (complex_shape.up ℤ)).has_comm_shift ℤ :=\nquotient.functor_comm_shift _\n\ndef induced_triangle (T : triangle (cochain_complex C ℤ)) :\n  triangle (homotopy_category C (complex_shape.up ℤ)) :=\n(homotopy_category.quotient _ _).map_triangle.obj T\n\ndef mapping_cone_induced_triangle_iso :\n  induced_triangle (mapping_cone.triangle φ) ≅ mapping_cone_triangle' φ :=\ntriangle.mk_iso _ _ (iso.refl _) (iso.refl _) (iso.refl _) (by tidy) (by tidy) begin\n  simp only [iso.refl_hom, category_theory.functor.map_id, comp_id, id_comp],\n  apply eq_of_homotopy,\n  apply homotopy.of_eq,\n  apply comp_id,\nend\n\n@[simps]\ndef shift_mapping_cone_iso {K L : cochain_complex C ℤ} (φ : K ⟶ L) (n : ℤ) :\n  (mapping_cone φ)⟦n⟧ ≅ mapping_cone (φ⟦n⟧') :=\n{ hom := mapping_cone.lift _\n      (ε ((n*(n+1))/2) • cocycle.right_shift (cocycle.left_shift\n        (mapping_cone.fst φ) n (n+1) (by linarith)) n 1 (by linarith))\n      (ε ((n*(n+1))/2) • ((mapping_cone.snd φ).left_shift n n\n        (zero_add n).symm).right_shift n 0 (zero_add n).symm) begin\n    simp only [δ_zsmul, cochain.δ_right_shift _ n _ 0 1 (zero_add n).symm (add_comm n 1),\n      cochain.δ_left_shift _ n 1 n (n+1) (zero_add n).symm (add_comm n 1), cochain.zsmul_comp,\n      cochain.right_shift_smul, smul_smul, mul_ε_self, mul_one, mapping_cone.δ_snd,\n      add_subgroup.coe_zsmul, cocycle.right_shift_coe, cocycle.left_shift_coe],\n    ext1 p q hpq,\n    simp only [cochain.add_v, cochain.zsmul_v, cochain.comp_zero_cochain, cochain.neg_v,\n      cochain.right_shift_v _ n 1 (add_comm n 1) p q hpq (q+n) (by linarith),\n      cochain.left_shift_v _ n (n+1) (add_comm n 1) p (q+n) (by linarith) _ rfl, assoc,\n      shift_functor_obj_X_iso, homological_complex.X_iso_of_eq_refl, cochain.of_hom_v,\n      shift_functor_map_f', preadditive.zsmul_comp, smul_smul, preadditive.neg_comp,\n      preadditive.comp_neg, smul_neg, cochain.zero_v, neg_add_eq_zero],\n    dsimp [iso.refl],\n    simp only [id_comp, comp_id],\n  end,\n  inv := mapping_cone.desc _\n      (ε ((n*(n+1))/2) • ((mapping_cone.inl φ).left_shift n (n-1) (by linarith)).right_shift n (-1) (by linarith))\n      ((mapping_cone.inr φ)⟦n⟧') begin\n    simp only [δ_zsmul, cochain.of_hom_comp, cochain.δ_right_shift _ _ _ _ _ _ (zero_add n).symm,\n      cochain.δ_left_shift _ _ _ _ _ _ (zero_add n).symm, mapping_cone.δ_inl,\n      cochain.right_shift_smul, smul_smul, mul_ε_self, mul_one],\n    ext1 p,\n    simp only [cochain.zsmul_v, cochain.comp_zero_cochain, cochain.of_hom_v, shift_functor_map_f',\n      cochain.right_shift_v _ n 0 (zero_add n).symm p p (add_zero p).symm _ rfl,\n      cochain.left_shift_v _ n n (zero_add n).symm p _ rfl _ rfl, smul_smul, ε_add, ε_mul_self,\n      preadditive.zsmul_comp, shift_functor_obj_X_iso, homological_complex.X_iso_of_eq_refl,\n      mul_succ_div_two],\n    dsimp [iso.refl],\n    erw [id_comp, comp_id],\n    rw [mul_assoc, ← mul_assoc (ε n)],\n    simp only [mul_ε_self, one_mul, one_smul],\n  end,\n  hom_inv_id' := begin\n    ext p : 2,\n    simp only [homological_complex.comp_f, homological_complex.id_f, assoc,\n      preadditive.comp_zsmul, preadditive.zsmul_comp, cochain.zsmul_v,\n      mapping_cone.lift_desc_f _ _ _ _ _ _ _ _ _ rfl, shift_functor_map_f',\n      add_subgroup.coe_zsmul, cocycle.right_shift_coe, cocycle.left_shift_coe,\n      cochain.right_shift_v _ n (-1) (show n-1=(-1)+n, by linarith) (p+1) p (by linarith) (p+n) (by linarith),\n      cochain.left_shift_v _ n (n-1) (show n-1=(-1)+n, by linarith) (p+1) (p+n) (by linarith) _ rfl,\n      cochain.right_shift_v _ n 1 (add_comm n 1) p _ rfl (p+1+n) (by linarith),\n      cochain.left_shift_v _ n (n+1) (add_comm n 1) p (p+1+n) (by linarith) _ rfl,\n      cochain.right_shift_v _ n 0 (zero_add n).symm p p (add_zero p).symm _ rfl,\n      cochain.left_shift_v _ n n (zero_add n).symm p _ rfl _ rfl,\n      iso.inv_hom_id_assoc, shift_functor_obj_X_iso, homological_complex.X_iso_of_eq_refl, smul_smul],\n    dsimp [iso.refl],\n    erw [id_comp, id_comp, id_comp, comp_id, ← mapping_cone.id φ (p+n) (p+1+n) (by linarith)],\n    simp only [ε_add, ε_even _ (even_mul_pred n), ε_even _ (even_mul_succ n), one_mul],\n    congr' 1,\n    { conv_lhs { congr, rw mul_assoc, congr, skip, congr, skip, rw mul_comm, },\n      conv_lhs { congr, congr, skip, rw ← mul_assoc, },\n      simpa only [mul_ε_self, one_mul, one_smul], },\n    { simp only [mul_succ_div_two, ε_mul_self, ε_add],\n      conv_lhs { congr, rw [mul_assoc, ← mul_assoc (ε n)], },\n      simp only [mul_ε_self, one_mul, one_smul], },\n  end,\n  inv_hom_id' := begin\n    ext p : 2,\n    simp only [homological_complex.comp_f, homological_complex.id_f, assoc],\n    rw mapping_cone.to_ext_iff _ _ _ rfl,\n    split,\n    { simp only [assoc, mapping_cone.lift_fst_f, add_subgroup.coe_zsmul,\n        cocycle.right_shift_coe, cocycle.left_shift_coe, cochain.zsmul_v,\n        linear.comp_smul, id_comp,\n        cochain.right_shift_v _ n 1 (add_comm n 1) p _ rfl (p+1+n) (by linarith),\n        cochain.left_shift_v _ n (n+1) (add_comm n 1) p (p+1+n) (by linarith) _ rfl,\n        preadditive.zsmul_comp, preadditive.comp_zsmul],\n      rw mapping_cone.from_ext_iff _ _ _ rfl,\n      split,\n      { simp only [linear.comp_smul, mapping_cone.inl_desc_v_assoc, cochain.zsmul_v,\n          linear.smul_comp, mapping_cone.inl_fst,\n          cochain.right_shift_v _ n (-1) (show n-1 = -1+n, by linarith) (p+1) p (by linarith) (p+n) (by linarith),\n          cochain.left_shift_v _ n (n-1) (show n-1 = -1+n, by linarith) (p+1) (p+n) (by linarith) _ rfl,\n          shift_functor_obj_X_iso, ε_add, homological_complex.X_iso_of_eq_refl, assoc,\n          iso.inv_hom_id_assoc, mapping_cone.inl_fst_assoc, iso.hom_inv_id, smul_smul,\n          ε_even _ (even_mul_succ n), ε_even _ (even_mul_pred n), one_mul],\n        conv_lhs { congr, congr, skip, rw mul_comm, },\n        conv_lhs { congr, rw mul_assoc, congr, skip, rw ← mul_assoc, },\n        simp only [mul_ε_self, one_mul, one_smul], },\n      { simp only [preadditive.comp_zsmul, mapping_cone.inr_desc_f_assoc,\n          shift_functor_obj_X_iso, ε_add, shift_functor_map_f',\n          homological_complex.X_iso_of_eq_refl, mapping_cone.inr_fst],\n        dsimp [iso.refl],\n        erw [id_comp, comp_id],\n        simp only [mapping_cone.inr_fst, smul_zero], }, },\n    { simp only [assoc, mapping_cone.lift_snd_f, cochain.zsmul_v, linear.comp_smul, id_comp,\n        cochain.right_shift_v _ _ _ (zero_add n).symm p p (add_zero p).symm _ rfl,\n        cochain.left_shift_v _ _ _ (zero_add n).symm _ _ rfl _ rfl,\n        preadditive.zsmul_comp, preadditive.comp_zsmul],\n      rw mapping_cone.from_ext_iff _ _ _ rfl,\n      split,\n      { simp only [preadditive.comp_zsmul, mapping_cone.inl_desc_v_assoc, assoc,\n          mapping_cone.inl_snd, cochain.zsmul_v, preadditive.zsmul_comp, smul_zero,\n          cochain.right_shift_v _ n (-1) (show n-1 = -1+n, by linarith) (p+1) p (by linarith) (p+n) (by linarith),\n          cochain.left_shift_v _ n (n-1) (show n-1 = -1+n, by linarith) (p+1) (p+n) (by linarith) _ rfl,\n          iso.inv_hom_id_assoc, mapping_cone.inl_snd_assoc, zero_comp, comp_zero], },\n      { simp only [assoc, preadditive.comp_zsmul, preadditive.zsmul_comp,\n          mapping_cone.inr_desc_f_assoc, shift_functor_map_f', shift_functor_obj_X_iso,\n          homological_complex.X_iso_of_eq_refl, smul_smul],\n        dsimp only [iso.refl],\n        erw [id_comp, comp_id],\n        simp only [mapping_cone.inr_snd, ε_add, ε_mul_self, mul_succ_div_two, mul_assoc],\n        conv_lhs { congr, congr, skip, rw ← mul_assoc, },\n        simpa only [mul_ε_self, one_mul, one_smul], }, },\n  end, }\n\ndef shift_mapping_cone_triangle_iso {K L : cochain_complex C ℤ} (φ : K ⟶ L) (n : ℤ) :\n  (triangle.shift_functor _ n).obj (mapping_cone.triangle φ) ≅ mapping_cone.triangle (φ⟦n⟧') :=\nbegin\n  refine triangle.mk_iso _ _ (iso.refl _) (preadditive.mul_iso ((-1)^n) (iso.refl _))\n    (shift_mapping_cone_iso φ n) _ _ _,\n  { dsimp [triangle.shift_functor],\n    simp only [comp_id, id_comp, preadditive.comp_zsmul, smul_smul,\n      ← units.coe_mul, ← mul_zpow, neg_mul, mul_neg, one_mul, neg_neg,\n      one_zpow, units.coe_one, one_zsmul], },\n  { ext p : 2,\n    dsimp [triangle.shift_functor],\n    simp only [preadditive.zsmul_comp, preadditive.comp_zsmul, id_comp,\n      mapping_cone.lift_f _ _ _ _ _ _ rfl, preadditive.comp_add, cochain.zsmul_v,\n      add_subgroup.coe_zsmul, cocycle.right_shift_coe, cocycle.left_shift_coe,\n      cochain.right_shift_v _ n 1 (add_comm n 1) _ _ rfl _ rfl,\n      cochain.left_shift_v _ n (n+1) (add_comm n 1) _ _ rfl _ rfl,\n      cochain.right_shift_v _ _ _ (zero_add n).symm p p (add_zero p).symm _ rfl,\n      cochain.left_shift_v _ _ _(zero_add n).symm _ _ rfl _ rfl, smul_smul,\n      shift_functor_obj_X_iso, homological_complex.X_iso_of_eq_refl, assoc],\n    dsimp [iso.refl],\n    erw [id_comp, id_comp],\n    simp only [mapping_cone.inr_fst_assoc, zero_comp, smul_zero, zero_add,\n      mapping_cone.inr_snd_assoc, id_comp],\n    congr' 1,\n    convert one_mul _,\n    nth_rewrite 0 mul_comm,\n    simp only [mul_succ_div_two, ε_add, mul_assoc],\n    conv_lhs { congr, skip, rw [← mul_assoc, mul_ε_self, one_mul], },\n    rw [ε_mul_self, mul_ε_self], },\n  { ext p : 2,\n    dsimp [triangle.shift_functor, mapping_cone.triangle],\n    simp only [preadditive.zsmul_comp, mapping_cone.lift_f (φ⟦n⟧') _ _ _ p _ rfl,\n      mapping_cone.δ, cocycle.hom_of_f, shift_functor_add_comm_hom_app_f,\n      cocycle.right_shift_coe, mapping_cone.δ_as_cocycle_coe, assoc,\n      cocycle.left_shift_coe, preadditive.add_comp,\n      cochain.right_shift_v _ _ _ (zero_add 1).symm (p+n) (p+n) (by linarith) _ rfl,\n      shift_functor_obj_X_iso,\n      cochain.right_shift_v _ _ _ (zero_add 1).symm p p (by linarith) _ rfl,\n      cochain.neg_v, mapping_cone.inr_fst_assoc, mapping_cone.inl_fst_assoc,\n      preadditive.neg_comp, preadditive.comp_neg, zero_comp, comp_zero, add_zero,\n      smul_neg, neg_inj],\n    dsimp,\n    simp only [preadditive.zsmul_comp, smul_smul,\n      cochain.right_shift_v _ _ _ (add_comm n 1) p _ rfl (p+1+n) (by linarith),\n      cochain.left_shift_v _ _ _ (add_comm n 1) p (p+1+n) (by linarith) _ rfl],\n    dsimp,\n    simp only [homological_complex.X_iso_of_eq_refl],\n    dsimp [iso.refl],\n    erw [id_comp, comp_id, comp_id, comp_id, id_comp, cochain.v_comp_X_iso_of_eq_hom],\n    congr' 1,\n    nth_rewrite 0 mul_comm,\n    simpa only [mul_succ_div_two, ε_add, ε_even _ (even_mul_succ n), one_mul, ← mul_assoc,\n      mul_ε_self], },\nend\n\nlemma shift_distinguished_triangles (T : triangle (homotopy_category C (complex_shape.up ℤ)))\n  (hT : T ∈ distinguished_triangles C) (n : ℤ) :\n  (triangle.shift_functor _ n).obj T ∈ distinguished_triangles C :=\nbegin\n  obtain ⟨K, L, φ, ⟨e⟩⟩:= hT,\n  suffices : (triangle.shift_functor _ n).obj (mapping_cone_triangle' φ)\n    ∈ distinguished_triangles C,\n  { exact isomorphic_distinguished _ this _ (functor.map_iso _ e), },\n  exact ⟨K⟦n⟧, L⟦n⟧, φ⟦n⟧',\n    ⟨(triangle.shift_functor (homotopy_category C (complex_shape.up ℤ)) n).map_iso\n    (mapping_cone_induced_triangle_iso φ).symm ≪≫\n    ((triangle.shift_functor_comm\n      ((homotopy_category.quotient C (complex_shape.up ℤ))) n).app _).symm ≪≫\n    (homotopy_category.quotient _ _).map_triangle.map_iso (shift_mapping_cone_triangle_iso φ n) ≪≫\n    (mapping_cone_induced_triangle_iso _)⟩⟩,\nend\n\nlemma rotate_distinguished_triangle (T : triangle (homotopy_category C (complex_shape.up ℤ))) :\n  T ∈ distinguished_triangles C ↔ T.rotate ∈ distinguished_triangles C :=\nbegin\n  split,\n  { exact rotate_distinguished_triangle₁ T, },\n  { intro h,\n    replace h := rotate_distinguished_triangle₁ _ (rotate_distinguished_triangle₁ _ h),\n    replace h := shift_distinguished_triangles _ h (-1),\n    refine isomorphic_distinguished _ h _ _,\n    exact (triangle.shift_functor_zero _).symm.app T ≪≫\n      (triangle.shift_functor_iso_of_eq _ (by linarith)).app T ≪≫\n      (triangle.shift_functor_add _ 1 (-1)).app T ≪≫\n      (triangle.shift_functor _ (-1)).map_iso ((triangle.shift_functor_one_iso _).app T), },\nend\n\ninstance : pretriangulated (homotopy_category C (complex_shape.up ℤ)) :=\n{ distinguished_triangles := distinguished_triangles C,\n  isomorphic_distinguished := isomorphic_distinguished,\n  contractible_distinguished := contractible_distinguished,\n  distinguished_cocone_triangle := distinguished_cocone_triangle,\n  rotate_distinguished_triangle := rotate_distinguished_triangle,\n  complete_distinguished_triangle_morphism :=\n    complete_distinguished_triangle_morphism, }\n\n\nlemma triangle_distinguished_iff (T : triangle (homotopy_category C (complex_shape.up ℤ))) :\n  (T ∈ dist_triang (homotopy_category C (complex_shape.up ℤ)))\n  ↔ ∃ (K L : cochain_complex C ℤ) (φ : K ⟶ L),\n    nonempty (T ≅\n      (homotopy_category.quotient _ _).map_triangle.obj (mapping_cone.triangle φ)) :=\nbegin\n  split,\n  { rintros ⟨K, L, φ, ⟨e⟩⟩,\n    exact ⟨K, L, φ, ⟨e ≪≫ (mapping_cone_induced_triangle_iso φ).symm⟩⟩, },\n  { rintro ⟨K, L, φ, ⟨e⟩⟩,\n    exact ⟨K, L, φ, ⟨e ≪≫ (mapping_cone_induced_triangle_iso φ)⟩⟩, },\nend\n\nlemma triangle_distinguished_iff' (T : triangle (homotopy_category C (complex_shape.up ℤ))) :\n  (T ∈ dist_triang (homotopy_category C (complex_shape.up ℤ))) ↔\n  ∃ (K L : cochain_complex C ℤ) (φ : K ⟶ L), nonempty (T ≅\n      (homotopy_category.quotient _ _).map_triangle.obj (mapping_cone.triangle φ).rotate) :=\nbegin\n  split,\n  { intro hT,\n    replace hT := inv_rot_of_dist_triangle _ _ hT,\n    rw triangle_distinguished_iff at hT,\n    obtain ⟨K, L, φ, ⟨e⟩⟩ := hT,\n    exact ⟨K, L, φ, ⟨(triangle_rotation _).counit_iso.symm.app T ≪≫\n      (pretriangulated.rotate _).map_iso e ≪≫\n      (homotopy_category.quotient _ _).map_triangle_rotate.app _⟩⟩, },\n  { rintro ⟨K, L, φ, ⟨e⟩⟩,\n    suffices : T.inv_rotate ∈ dist_triang _,\n    { exact pretriangulated.isomorphic_distinguished _ (rot_of_dist_triangle _ _ this) _\n        ((triangle_rotation _).counit_iso.symm.app T), },\n    refine ⟨K, L, φ, ⟨(pretriangulated.inv_rotate _).map_iso e ≪≫ (inv_rotate _).map_iso\n        (((homotopy_category.quotient _ _).map_triangle_rotate).symm.app _ ≪≫\n        (rotate _).map_iso (mapping_cone_induced_triangle_iso φ)) ≪≫\n      (triangle_rotation _).unit_iso.symm.app _⟩⟩, },\nend\n\nend homotopy_category\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebra/homology/pretriangulated.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568417, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4781076983564931}}
{"text": "theorem USAJMO_Problems_Problem_1 :\n  forall f: pnat -> pnat,\n  (forall (a b: pnat), f(a*a + b*b) = f(a)* f(b) /\\ f(a*a) = f(a)*f(a))\n  -> forall n, f n = 1\n:= sorry\n", "meta": {"author": "ahayat16", "repo": "lean_exos", "sha": "682f2552d5b04a8c8eb9e4ab15f875a91b03845c", "save_path": "github-repos/lean/ahayat16-lean_exos", "path": "github-repos/lean/ahayat16-lean_exos/lean_exos-682f2552d5b04a8c8eb9e4ab15f875a91b03845c/src_icannos_totilas/aops/2021-USAJMO-Problem_1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.47806032672960863}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.limits.shapes.products\nimport category_theory.limits.preserves.basic\n\n/-!\n# Preserving products\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nConstructions to relate the notions of preserving products and reflecting products\nto concrete fans.\n\nIn particular, we show that `pi_comparison G f` is an isomorphism iff `G` preserves\nthe limit of `f`.\n-/\n\nnoncomputable theory\n\nuniverses w v₁ v₂ u₁ u₂\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u₁} [category.{v₁} C]\nvariables {D : Type u₂} [category.{v₂} D]\nvariables (G : C ⥤ D)\n\nnamespace category_theory.limits\n\nvariables {J : Type w} (f : J → C)\n\n/--\nThe map of a fan is a limit iff the fan consisting of the mapped morphisms is a limit. This\nessentially lets us commute `fan.mk` with `functor.map_cone`.\n-/\ndef is_limit_map_cone_fan_mk_equiv {P : C} (g : Π j, P ⟶ f j) :\n  is_limit (G.map_cone (fan.mk P g)) ≃\n  is_limit (fan.mk _ (λ j, G.map (g j)) : fan (λ j, G.obj (f j))) :=\nbegin\n  refine (is_limit.postcompose_hom_equiv _ _).symm.trans (is_limit.equiv_iso_limit _),\n  refine discrete.nat_iso (λ j, iso.refl (G.obj (f j.as))),\n  refine cones.ext (iso.refl _) (λ j, by { discrete_cases, dsimp, simp }),\nend\n\n/-- The property of preserving products expressed in terms of fans. -/\ndef is_limit_fan_mk_obj_of_is_limit [preserves_limit (discrete.functor f) G]\n  {P : C} (g : Π j, P ⟶ f j) (t : is_limit (fan.mk _ g)) :\n  is_limit (fan.mk (G.obj P) (λ j, G.map (g j)) : fan (λ j, G.obj (f j))) :=\nis_limit_map_cone_fan_mk_equiv _ _ _ (preserves_limit.preserves t)\n\n/-- The property of reflecting products expressed in terms of fans. -/\ndef is_limit_of_is_limit_fan_mk_obj [reflects_limit (discrete.functor f) G]\n  {P : C} (g : Π j, P ⟶ f j) (t : is_limit (fan.mk _ (λ j, G.map (g j)) : fan (λ j, G.obj (f j)))) :\n  is_limit (fan.mk P g) :=\nreflects_limit.reflects ((is_limit_map_cone_fan_mk_equiv _ _ _).symm t)\n\nsection\n\nvariables [has_product f]\n\n/--\nIf `G` preserves products and `C` has them, then the fan constructed of the mapped projection of a\nproduct is a limit.\n-/\ndef is_limit_of_has_product_of_preserves_limit [preserves_limit (discrete.functor f) G] :\n  is_limit (fan.mk _ (λ (j : J), G.map (pi.π f j)) : fan (λ j, G.obj (f j))) :=\nis_limit_fan_mk_obj_of_is_limit G f _ (product_is_product _)\n\nvariables [has_product (λ (j : J), G.obj (f j))]\n\n/-- If `pi_comparison G f` is an isomorphism, then `G` preserves the limit of `f`. -/\ndef preserves_product.of_iso_comparison [i : is_iso (pi_comparison G f)] :\n  preserves_limit (discrete.functor f) G :=\nbegin\n  apply preserves_limit_of_preserves_limit_cone (product_is_product f),\n  apply (is_limit_map_cone_fan_mk_equiv _ _ _).symm _,\n  apply is_limit.of_point_iso (limit.is_limit (discrete.functor (λ (j : J), G.obj (f j)))),\n  apply i,\nend\n\nvariable [preserves_limit (discrete.functor f) G]\n\n/--\nIf `G` preserves limits, we have an isomorphism from the image of a product to the product of the\nimages.\n-/\ndef preserves_product.iso : G.obj (∏ f) ≅ ∏ (λ j, G.obj (f j)) :=\nis_limit.cone_point_unique_up_to_iso\n  (is_limit_of_has_product_of_preserves_limit G f)\n  (limit.is_limit _)\n\n@[simp]\nlemma preserves_product.iso_hom : (preserves_product.iso G f).hom = pi_comparison G f :=\nrfl\n\ninstance : is_iso (pi_comparison G f) :=\nbegin\n  rw ← preserves_product.iso_hom,\n  apply_instance,\nend\n\nend\n\n/--\nThe map of a cofan is a colimit iff the cofan consisting of the mapped morphisms is a colimit.\nThis essentially lets us commute `cofan.mk` with `functor.map_cocone`.\n-/\ndef is_colimit_map_cocone_cofan_mk_equiv {P : C} (g : Π j, f j ⟶ P) :\n  is_colimit (G.map_cocone (cofan.mk P g)) ≃\n  is_colimit (cofan.mk _ (λ j, G.map (g j)) : cofan (λ j, G.obj (f j))) :=\nbegin\n  refine (is_colimit.precompose_hom_equiv _ _).symm.trans (is_colimit.equiv_iso_colimit _),\n  refine discrete.nat_iso (λ j, iso.refl (G.obj (f j.as))),\n  refine cocones.ext (iso.refl _) (λ j, by { discrete_cases, dsimp, simp }),\nend\n\n/-- The property of preserving coproducts expressed in terms of cofans. -/\ndef is_colimit_cofan_mk_obj_of_is_colimit [preserves_colimit (discrete.functor f) G]\n  {P : C} (g : Π j, f j ⟶ P) (t : is_colimit (cofan.mk _ g)) :\n  is_colimit (cofan.mk (G.obj P) (λ j, G.map (g j)) : cofan (λ j, G.obj (f j))) :=\nis_colimit_map_cocone_cofan_mk_equiv _ _ _ (preserves_colimit.preserves t)\n\n/-- The property of reflecting coproducts expressed in terms of cofans. -/\ndef is_colimit_of_is_colimit_cofan_mk_obj [reflects_colimit (discrete.functor f) G]\n  {P : C} (g : Π j, f j ⟶ P)\n  (t : is_colimit (cofan.mk _ (λ j, G.map (g j)) : cofan (λ j, G.obj (f j)))) :\n  is_colimit (cofan.mk P g) :=\nreflects_colimit.reflects ((is_colimit_map_cocone_cofan_mk_equiv _ _ _).symm t)\n\nsection\n\nvariables [has_coproduct f]\n\n/--\nIf `G` preserves coproducts and `C` has them,\nthen the cofan constructed of the mapped inclusion of a coproduct is a colimit.\n-/\ndef is_colimit_of_has_coproduct_of_preserves_colimit [preserves_colimit (discrete.functor f) G] :\n  is_colimit (cofan.mk _ (λ (j : J), G.map (sigma.ι f j)) : cofan (λ j, G.obj (f j))) :=\nis_colimit_cofan_mk_obj_of_is_colimit G f _ (coproduct_is_coproduct _)\n\nvariables [has_coproduct (λ (j : J), G.obj (f j))]\n\n/-- If `sigma_comparison G f` is an isomorphism, then `G` preserves the colimit of `f`. -/\ndef preserves_coproduct.of_iso_comparison [i : is_iso (sigma_comparison G f)] :\n  preserves_colimit (discrete.functor f) G :=\nbegin\n  apply preserves_colimit_of_preserves_colimit_cocone (coproduct_is_coproduct f),\n  apply (is_colimit_map_cocone_cofan_mk_equiv _ _ _).symm _,\n  apply is_colimit.of_point_iso (colimit.is_colimit (discrete.functor (λ (j : J), G.obj (f j)))),\n  apply i,\nend\n\nvariable [preserves_colimit (discrete.functor f) G]\n\n/--\nIf `G` preserves colimits,\nwe have an isomorphism from the image of a coproduct to the coproduct of the images.\n-/\ndef preserves_coproduct.iso : G.obj (∐ f) ≅ ∐ (λ j, G.obj (f j)) :=\nis_colimit.cocone_point_unique_up_to_iso\n  (is_colimit_of_has_coproduct_of_preserves_colimit G f)\n  (colimit.is_colimit _)\n\n@[simp]\nlemma preserves_coproduct.inv_hom : (preserves_coproduct.iso G f).inv = sigma_comparison G f :=\nrfl\n\ninstance : is_iso (sigma_comparison G f) :=\nbegin\n  rw ← preserves_coproduct.inv_hom,\n  apply_instance,\nend\n\nend\n\nend category_theory.limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/preserves/shapes/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.47803565393549774}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\n\nimport algebra.char_p.basic\nimport data.mv_polynomial.comm_ring\nimport data.mv_polynomial.equiv\nimport data.polynomial.field_division\nimport ring_theory.principal_ideal_domain\nimport ring_theory.polynomial.content\n\n/-!\n# Ring-theoretic supplement of data.polynomial.\n\n## Main results\n* `mv_polynomial.integral_domain`:\n  If a ring is an integral domain, then so is its polynomial ring over finitely many variables.\n* `polynomial.is_noetherian_ring`:\n  Hilbert basis theorem, that if a ring is noetherian then so is its polynomial ring.\n* `polynomial.wf_dvd_monoid`:\n  If an integral domain is a `wf_dvd_monoid`, then so is its polynomial ring.\n* `polynomial.unique_factorization_monoid`:\n  If an integral domain is a `unique_factorization_monoid`, then so is its polynomial ring.\n-/\n\nnoncomputable theory\nopen_locale classical big_operators\n\nuniverses u v w\n\nnamespace polynomial\n\ninstance {R : Type u} [semiring R] (p : ℕ) [h : char_p R p] : char_p (polynomial R) p :=\nlet ⟨h⟩ := h in ⟨λ n, by rw [← C.map_nat_cast, ← C_0, C_inj, h]⟩\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R (polynomial R) :=\n⨅ k : ℕ, ⨅ h : ↑k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : ℕ) : submodule R (polynomial R) :=\n⨅ k : ℕ, ⨅ h : k ≥ n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot ℕ} {f : polynomial R} :\n  f ∈ degree_le R n ↔ degree f ≤ n :=\nby simp only [degree_le, submodule.mem_infi, degree_le_iff_coeff_zero, linear_map.mem_ker]; refl\n\n@[mono] theorem degree_le_mono {m n : with_bot ℕ} (H : m ≤ n) :\n  degree_le R m ≤ degree_le R n :=\nλ f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : ℕ} :\n  degree_le R n = submodule.span R ↑((finset.range (n+1)).image (λ n, (X : polynomial R)^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [← finsupp.sum_single p, finsupp.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_le_coe.1 (finset.sup_le_iff.1 hp k hk),\n    rw [single_eq_C_mul_X, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_le.2,\n  exact (degree_X_pow_le _).trans\n    (with_bot.coe_le_coe.2 $ nat.le_of_lt_succ $ finset.mem_range.1 hk)\nend\n\ntheorem mem_degree_lt {n : ℕ} {f : polynomial R} :\n  f ∈ degree_lt R n ↔ degree f < n :=\nby { simp_rw [degree_lt, submodule.mem_infi, linear_map.mem_ker, degree,\n    finset.sup_lt_iff (with_bot.bot_lt_coe n), mem_support_iff, with_bot.some_eq_coe,\n    with_bot.coe_lt_coe, lt_iff_not_ge', ne, not_imp_not], refl }\n\n@[mono] theorem degree_lt_mono {m n : ℕ} (H : m ≤ n) :\n  degree_lt R m ≤ degree_lt R n :=\nλ f hf, mem_degree_lt.2 (lt_of_lt_of_le (mem_degree_lt.1 hf) $ with_bot.coe_le_coe.2 H)\n\ntheorem degree_lt_eq_span_X_pow {n : ℕ} :\n  degree_lt R n = submodule.span R ↑((finset.range n).image (λ n, X^n) : finset (polynomial R)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [← finsupp.sum_single p, finsupp.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_lt_coe.1 ((finset.sup_lt_iff $ with_bot.bot_lt_coe n).1 hp k hk),\n    rw [single_eq_C_mul_X, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 this, rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_lt.2,\n  exact lt_of_le_of_lt (degree_X_pow_le _) (with_bot.coe_lt_coe.2 $ finset.mem_range.1 hk)\nend\n\n/-- The first `n` coefficients on `degree_lt n` form a linear equivalence with `fin n → F`. -/\ndef degree_lt_equiv (F : Type*) [field F] (n : ℕ) : degree_lt F n ≃ₗ[F] (fin n → F) :=\n{ to_fun := λ p n, (↑p : polynomial F).coeff n,\n  inv_fun := λ f, ⟨∑ i : fin n, monomial i (f i),\n    (degree_lt F n).sum_mem (λ i _, mem_degree_lt.mpr (lt_of_le_of_lt\n      (degree_monomial_le i (f i)) (with_bot.coe_lt_coe.mpr i.is_lt)))⟩,\n  map_add' := λ p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := λ x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro ⟨p, hp⟩, ext1,\n    simp only [submodule.coe_mk],\n    by_cases hp0 : p = 0,\n    { subst hp0, simp only [coeff_zero, linear_map.map_zero, finset.sum_const_zero] },\n    rw [mem_degree_lt, degree_eq_nat_degree hp0, with_bot.coe_lt_coe] at hp,\n    conv_rhs { rw [p.as_sum_range' n hp, ← fin.sum_univ_eq_sum_range] },\n  end,\n  right_inv :=\n  begin\n    intro f, ext i,\n    simp only [finset_sum_coeff, submodule.coe_mk],\n    rw [finset.sum_eq_single i, coeff_monomial, if_pos rfl],\n    { rintro j - hji, rw [coeff_monomial, if_neg], rwa [← subtype.ext_iff] },\n    { intro h, exact (h (finset.mem_univ _)).elim }\n  end }\n\nlocal attribute [instance] subset.ring\n\n/-- Given a polynomial, return the polynomial whose coefficients are in\nthe ring closure of the original coefficients. -/\ndef restriction (p : polynomial R) : polynomial (ring.closure (↑p.frange : set R)) :=\n⟨p.support, λ i, ⟨p.to_fun i,\n  if H : p.to_fun i = 0 then H.symm ▸ is_add_submonoid.zero_mem\n  else ring.subset_closure $ finsupp.mem_frange.2 ⟨H, i, rfl⟩⟩,\nλ i, finsupp.mem_support_iff.trans (not_iff_not_of_iff ⟨λ H, subtype.eq H, subtype.mk.inj⟩)⟩\n\n@[simp] theorem coeff_restriction {p : polynomial R} {n : ℕ} :\n  ↑(coeff (restriction p) n) = coeff p n := rfl\n\n@[simp] theorem coeff_restriction' {p : polynomial R} {n : ℕ} :\n  (coeff (restriction p) n).1 = coeff p n := rfl\n\nsection\nlocal attribute [instance] algebra.of_is_subring subring.domain subset.comm_ring\n@[simp] theorem map_restriction (p : polynomial R) : p.restriction.map (algebra_map _ _) = p :=\next $ λ n, by rw [coeff_map, algebra.is_subring_algebra_map_apply, coeff_restriction]\nend\n\n@[simp] theorem degree_restriction {p : polynomial R} : (restriction p).degree = p.degree := rfl\n\n@[simp] theorem nat_degree_restriction {p : polynomial R} :\n  (restriction p).nat_degree = p.nat_degree := rfl\n\n@[simp] theorem monic_restriction {p : polynomial R} : monic (restriction p) ↔ monic p :=\n⟨λ H, congr_arg subtype.val H, λ H, subtype.eq H⟩\n\n@[simp] theorem restriction_zero : restriction (0 : polynomial R) = 0 := rfl\n\n@[simp] theorem restriction_one : restriction (1 : polynomial R) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables {S : Type v} [ring S] {f : R →+* S} {x : S}\n\ntheorem eval₂_restriction {p : polynomial R} :\n  eval₂ f x p = eval₂ (f.comp (is_subring.subtype _)) x p.restriction :=\nby { dsimp only [eval₂_eq_sum], refl, }\n\nsection to_subring\nvariables (p : polynomial R) (T : set R) [is_subring T]\n\n/-- Given a polynomial `p` and a subring `T` that contains the coefficients of `p`,\nreturn the corresponding polynomial whose coefficients are in `T. -/\ndef to_subring (hp : ↑p.frange ⊆ T) : polynomial T :=\n⟨p.support, λ i, ⟨p.to_fun i,\n  if H : p.to_fun i = 0 then H.symm ▸ is_add_submonoid.zero_mem\n  else hp $ finsupp.mem_frange.2 ⟨H, i, rfl⟩⟩,\nλ i, finsupp.mem_support_iff.trans (not_iff_not_of_iff ⟨λ H, subtype.eq H, subtype.mk.inj⟩)⟩\n\nvariables (hp : ↑p.frange ⊆ T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : ℕ} : ↑(coeff (to_subring p T hp) n) = coeff p n := rfl\n\n@[simp] theorem coeff_to_subring' {n : ℕ} : (coeff (to_subring p T hp) n).1 = coeff p n := rfl\n\n@[simp] theorem degree_to_subring : (to_subring p T hp).degree = p.degree := rfl\n\n@[simp] theorem nat_degree_to_subring : (to_subring p T hp).nat_degree = p.nat_degree := rfl\n\n@[simp] theorem monic_to_subring : monic (to_subring p T hp) ↔ monic p :=\n⟨λ H, congr_arg subtype.val H, λ H, subtype.eq H⟩\n\nomit hp\n\n@[simp] theorem to_subring_zero : to_subring (0 : polynomial R) T (set.empty_subset _) = 0 := rfl\n\n@[simp] theorem to_subring_one : to_subring (1 : polynomial R) T\n  (set.subset.trans (finset.coe_subset.2 finsupp.frange_single)\n    (finset.singleton_subset_set_iff.2 is_submonoid.one_mem)) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_to_subring', coeff_one, coeff_one]; split_ifs; refl\n\n@[simp] theorem map_to_subring : (p.to_subring T hp).map (is_subring.subtype T) = p :=\next $ λ n, coeff_map _ _\n\nend to_subring\n\nvariables (T : set R) [is_subring T]\n\n/-- Given a polynomial whose coefficients are in some subring, return\nthe corresponding polynomial whose coefificents are in the ambient ring. -/\ndef of_subring (p : polynomial T) : polynomial R :=\n⟨p.support, subtype.val ∘ p.to_fun,\nλ n, finsupp.mem_support_iff.trans (not_iff_not_of_iff\n  ⟨λ h, congr_arg subtype.val h, λ h, subtype.eq h⟩)⟩\n\n@[simp] theorem frange_of_subring {p : polynomial T} :\n  ↑(p.of_subring T).frange ⊆ T :=\nλ y H, let ⟨hy, x, hx⟩ := finsupp.mem_frange.1 H in hx ▸ (p.to_fun x).2\n\nend polynomial\n\nvariables {R : Type u} {σ : Type v} {M : Type w} [comm_ring R] [add_comm_group M] [module R M]\n\nnamespace ideal\nopen polynomial\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself -/\nlemma polynomial_mem_ideal_of_coeff_mem_ideal (I : ideal (polynomial R)) (p : polynomial R)\n  (hp : ∀ (n : ℕ), (p.coeff n) ∈ I.comap C) : p ∈ I :=\nsum_C_mul_X_eq p ▸ submodule.sum_mem I (λ n hn, I.mul_mem_right _ (hp n))\n\n/-- The push-forward of an ideal `I` of `R` to `polynomial R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : polynomial R} :\n  f ∈ (ideal.map C I : ideal (polynomial R)) ↔ ∀ n : ℕ, f.coeff n ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw ← sum_monomial_eq f,\n    refine (I.map C : ideal (polynomial R)).sum_mem (λ n hn, _),\n    simp [single_eq_C_mul_X],\n    rw mul_comm,\n    exact (I.map C : ideal (polynomial R)).mul_mem_left _ (mem_map_of_mem (hf n)) }\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} :\n  ∀ a ∈ I, ((quotient.mk (map C I : ideal (polynomial R))).comp C) a = 0 :=\nbegin\n  intros a ha,\n  rw [ring_hom.comp_apply, quotient.eq_zero_iff_mem],\n  exact mem_map_of_mem ha,\nend\n\nlemma eval₂_C_mk_eq_zero {I : ideal R} :\n  ∀ f ∈ (map C I : ideal (polynomial R)), eval₂_ring_hom (C.comp (quotient.mk I)) X f = 0 :=\nbegin\n  intros a ha,\n  rw ← sum_monomial_eq a,\n  dsimp,\n  rw eval₂_sum,\n  refine finset.sum_eq_zero (λ n hn, _),\n  dsimp,\n  rw eval₂_monomial (C.comp (quotient.mk I)) X,\n  refine mul_eq_zero_of_left (polynomial.ext (λ m, _)) (X ^ n),\n  erw coeff_C,\n  by_cases h : m = 0,\n  { simpa [h] using quotient.eq_zero_iff_mem.2 ((mem_map_C_iff.1 ha) n) },\n  { simp [h] }\nend\n\n/-- If `I` is an ideal of `R`, then the ring polynomials over the quotient ring `I.quotient` is\nisomorphic to the quotient of `polynomial R` by the ideal `map C I`,\nwhere `map C I` contains exactly the polynomials whose coefficients all lie in `I` -/\ndef polynomial_quotient_equiv_quotient_polynomial (I : ideal R) :\n  polynomial (I.quotient) ≃+* (map C I : ideal (polynomial R)).quotient :=\n{ to_fun := eval₂_ring_hom\n    (quotient.lift I ((quotient.mk (map C I : ideal (polynomial R))).comp C) quotient_map_C_eq_zero)\n    ((quotient.mk (map C I : ideal (polynomial R)) X)),\n  inv_fun := quotient.lift (map C I : ideal (polynomial R))\n    (eval₂_ring_hom (C.comp (quotient.mk I)) X) eval₂_C_mk_eq_zero,\n  map_mul' := λ f g, by simp,\n  map_add' := λ f g, by simp,\n  left_inv := begin\n    intro f,\n    apply polynomial.induction_on' f,\n    { simp_intros p q hp hq,\n      rw [hp, hq] },\n    { rintros n ⟨x⟩,\n      simp [monomial_eq_smul_X, C_mul'] }\n  end,\n  right_inv := begin\n    rintro ⟨f⟩,\n    apply polynomial.induction_on' f,\n    { simp_intros p q hp hq,\n      rw [hp, hq] },\n    { intros n a,\n      simp [monomial_eq_smul_X, ← C_mul' a (X ^ n)] },\n  end,\n}\n\n/-- If `P` is a prime ideal of `R`, then `R[x]/(P)` is an integral domain. -/\nlemma is_integral_domain_map_C_quotient {P : ideal R} (H : is_prime P) :\n  is_integral_domain (quotient (map C P : ideal (polynomial R))) :=\nring_equiv.is_integral_domain (polynomial (quotient P))\n  (integral_domain.to_is_integral_domain (polynomial (quotient P)))\n  (polynomial_quotient_equiv_quotient_polynomial P).symm\n\n/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/\nlemma is_prime_map_C_of_is_prime {P : ideal R} (H : is_prime P) :\n  is_prime (map C P : ideal (polynomial R)) :=\n(quotient.is_integral_domain_iff_prime (map C P : ideal (polynomial R))).mp\n  (is_integral_domain_map_C_quotient H)\n\n/-- Given any ring `R` and an ideal `I` of `polynomial R`, we get a map `R → R[x] → R[x]/I`.\n  If we let `R` be the image of `R` in `R[x]/I` then we also have a map `R[x] → R'[x]`.\n  In particular we can map `I` across this map, to get `I'` and a new map `R' → R'[x] → R'[x]/I`.\n  This theorem shows `I'` will not contain any non-zero constant polynomials\n  -/\nlemma eq_zero_of_polynomial_mem_map_range (I : ideal (polynomial R))\n  (x : ((quotient.mk I).comp C).range)\n  (hx : C x ∈ (I.map (polynomial.map_ring_hom ((quotient.mk I).comp C).range_restrict))) :\n  x = 0 :=\nbegin\n  let i := ((quotient.mk I).comp C).range_restrict,\n  have hi' : (polynomial.map_ring_hom i).ker ≤ I,\n  { refine λ f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (λ n, _),\n    rw [mem_comap, ← quotient.eq_zero_iff_mem, ← ring_hom.comp_apply],\n    rw [ring_hom.mem_ker, coe_map_ring_hom] at hf,\n    replace hf := congr_arg (λ (f : polynomial _), f.coeff n) hf,\n    simp only [coeff_map, coeff_zero] at hf,\n    rwa [subtype.ext_iff, ring_hom.coe_range_restrict] at hf },\n  obtain ⟨x, hx'⟩ := x,\n  obtain ⟨y, rfl⟩ := (ring_hom.mem_range).1 hx',\n  refine subtype.eq _,\n  simp only [ring_hom.comp_apply, quotient.eq_zero_iff_mem, subring.coe_zero, subtype.val_eq_coe],\n  suffices : C (i y) ∈ (I.map (polynomial.map_ring_hom i)),\n  { obtain ⟨f, hf⟩ := mem_image_of_mem_map_of_surjective (polynomial.map_ring_hom i)\n      (polynomial.map_surjective _ (((quotient.mk I).comp C).range_restrict_surjective)) this,\n    refine sub_add_cancel (C y) f ▸ I.add_mem (hi' _ : (C y - f) ∈ I) hf.1,\n    rw [ring_hom.mem_ker, ring_hom.map_sub, hf.2, sub_eq_zero, coe_map_ring_hom, map_C] },\n  exact hx,\nend\n\n/-- `polynomial R` is never a field for any ring `R`. -/\nlemma polynomial_not_is_field : ¬ is_field (polynomial R) :=\nbegin\n  by_contradiction hR,\n  by_cases hR' : ∃ (x y : R), x ≠ y,\n  { haveI : nontrivial R := let ⟨x, y, hxy⟩ := hR' in nontrivial_of_ne x y hxy,\n    obtain ⟨p, hp⟩ := hR.mul_inv_cancel X_ne_zero,\n    by_cases hp0 : p = 0,\n    { replace hp := congr_arg degree hp,\n      rw [hp0, mul_zero, degree_zero, degree_one] at hp,\n      contradiction },\n    { have : p.degree < (X * p).degree := (mul_comm p X) ▸ degree_lt_degree_mul_X hp0,\n      rw [congr_arg degree hp, degree_one, nat.with_bot.lt_zero_iff, degree_eq_bot] at this,\n      exact hp0 this } },\n  { push_neg at hR',\n    exact let ⟨x, y, hxy⟩ := hR.exists_pair_ne in hxy (polynomial.ext (λ n, hR' _ _)) }\nend\n\n/-- The only constant in a maximal ideal over a field is `0`. -/\nlemma eq_zero_of_constant_mem_of_maximal (hR : is_field R)\n  (I : ideal (polynomial R)) [hI : I.is_maximal] (x : R) (hx : C x ∈ I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (λ hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain ⟨y, hy⟩ := hR.mul_inv_cancel hx0,\n  convert I.smul_mem (C y) hx,\n  rw [smul_eq_mul, ← C.map_mul, mul_comm y x, hy, ring_hom.map_one],\nend\n\n/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/\ndef of_polynomial (I : ideal (polynomial R)) : submodule R (polynomial R) :=\n{ carrier := I.carrier,\n  zero_mem' := I.zero_mem,\n  add_mem' := λ _ _, I.add_mem,\n  smul_mem' := λ c x H, by { rw [← C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal (polynomial R)}\ntheorem mem_of_polynomial (x) : x ∈ I.of_polynomial ↔ x ∈ I := iff.rfl\nvariables (I)\n\n/-- Given an ideal `I` of `R[X]`, make the `R`-submodule of `I`\nconsisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R (polynomial R) :=\ndegree_le R n ⊓ I.of_polynomial\n\n/-- Given an ideal `I` of `R[X]`, make the ideal in `R` of\nleading coefficients of polynomials in `I` with degree ≤ `n`. -/\ndef leading_coeff_nth (n : ℕ) : ideal R :=\n(I.degree_le n).map $ lcoeff R n\n\ntheorem mem_leading_coeff_nth (n : ℕ) (x) :\n  x ∈ I.leading_coeff_nth n ↔ ∃ p ∈ I, degree p ≤ n ∧ leading_coeff p = x :=\nbegin\n  simp only [leading_coeff_nth, degree_le, submodule.mem_map, lcoeff_apply, submodule.mem_inf,\n    mem_degree_le],\n  split,\n  { rintro ⟨p, ⟨hpdeg, hpI⟩, rfl⟩,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine ⟨0, I.zero_mem, bot_le, _⟩,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine ⟨p, hpI, le_of_eq hpdeg, _⟩,\n      rw [leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro ⟨p, hpI, hpdeg, rfl⟩,\n    have : nat_degree p + (n - nat_degree p) = n,\n    { exact nat.add_sub_cancel' (nat_degree_le_of_degree_le hpdeg) },\n    refine ⟨p * X ^ (n - nat_degree p), ⟨_, I.mul_mem_right _ hpI⟩, _⟩,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [← with_bot.coe_add, this],\n      exact le_refl _ },\n    { rw [leading_coeff, ← coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x ∈ I.leading_coeff_nth 0 ↔ C x ∈ I :=\n(mem_leading_coeff_nth _ _ _).trans\n⟨λ ⟨p, hpI, hpdeg, hpx⟩, by rwa [← hpx, leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  ← eq_C_of_degree_le_zero hpdeg],\nλ hx, ⟨C x, hx, degree_C_le, leading_coeff_C x⟩⟩\n\ntheorem leading_coeff_nth_mono {m n : ℕ} (H : m ≤ n) :\n  I.leading_coeff_nth m ≤ I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr ⊢,\n  rcases hr with ⟨p, hpI, hpdeg, rfl⟩,\n  refine ⟨p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow⟩,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [← with_bot.coe_add, nat.add_sub_cancel' H],\n  exact le_refl _\nend\n\n/-- Given an ideal `I` in `R[X]`, make the ideal in `R` of the\nleading coefficients in `I`. -/\ndef leading_coeff : ideal R :=\n⨆ n : ℕ, I.leading_coeff_nth n\n\ntheorem mem_leading_coeff (x) :\n  x ∈ I.leading_coeff ↔ ∃ p ∈ I, polynomial.leading_coeff p = x :=\nbegin\n  rw [leading_coeff, submodule.mem_supr_of_directed],\n  simp only [mem_leading_coeff_nth],\n  { split, { rintro ⟨i, p, hpI, hpdeg, rfl⟩, exact ⟨p, hpI, rfl⟩ },\n    rintro ⟨p, hpI, rfl⟩, exact ⟨nat_degree p, p, hpI, degree_le_nat_degree, rfl⟩ },\n  intros i j, exact ⟨i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)⟩\nend\n\ntheorem is_fg_degree_le [is_noetherian_ring R] (n : ℕ) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  ⟨_, degree_le_eq_span_X_pow.symm⟩) _\n\nend ideal\n\nnamespace polynomial\n@[priority 100]\ninstance {R : Type*} [integral_domain R] [wf_dvd_monoid R] :\n  wf_dvd_monoid (polynomial R) :=\n{ well_founded_dvd_not_unit := begin\n    classical,\n    refine rel_hom.well_founded\n      ⟨λ p, (if p = 0 then ⊤ else ↑p.degree, p.leading_coeff), _⟩\n      (prod.lex_wf (with_top.well_founded_lt $ with_bot.well_founded_lt nat.lt_wf)\n        _inst_5.well_founded_dvd_not_unit),\n    rintros a b ⟨ane0, ⟨c, ⟨not_unit_c, rfl⟩⟩⟩,\n    rw [polynomial.degree_mul, if_neg ane0],\n    split_ifs with hac,\n    { rw [hac, polynomial.leading_coeff_zero],\n      apply prod.lex.left,\n      exact lt_of_le_of_ne le_top with_top.coe_ne_top },\n    have cne0 : c ≠ 0 := right_ne_zero_of_mul hac,\n    simp only [cne0, ane0, polynomial.leading_coeff_mul],\n    by_cases hdeg : c.degree = 0,\n    { simp only [hdeg, add_zero],\n      refine prod.lex.right _ ⟨_, ⟨c.leading_coeff, (λ unit_c, not_unit_c _), rfl⟩⟩,\n      { rwa [ne, polynomial.leading_coeff_eq_zero] },\n      rw [polynomial.is_unit_iff, polynomial.eq_C_of_degree_eq_zero hdeg],\n      use [c.leading_coeff, unit_c],\n      rw [polynomial.leading_coeff, polynomial.nat_degree_eq_of_degree_eq_some hdeg] },\n    { apply prod.lex.left,\n      rw polynomial.degree_eq_nat_degree cne0 at *,\n      rw [with_top.coe_lt_coe, polynomial.degree_eq_nat_degree ane0,\n          ← with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (λ h, hdeg (h.symm ▸ with_bot.coe_zero))) },\n  end }\n\nend polynomial\n\n/-- Hilbert basis theorem: a polynomial ring over a noetherian ring is a noetherian ring. -/\nprotected theorem polynomial.is_noetherian_ring [is_noetherian_ring R] :\n  is_noetherian_ring (polynomial R) :=\nis_noetherian_ring_iff.2 ⟨assume I : ideal (polynomial R),\nlet M := well_founded.min (is_noetherian_iff_well_founded.1 (by apply_instance))\n  (set.range I.leading_coeff_nth) ⟨_, ⟨0, rfl⟩⟩ in\nhave hm : M ∈ set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet ⟨N, HN⟩ := hm, ⟨s, hs⟩ := I.is_fg_degree_le N in\nhave hm2 : ∀ k, I.leading_coeff_nth k ≤ M := λ k, or.cases_on (le_or_lt k N)\n  (λ h, HN ▸ I.leading_coeff_nth_mono h)\n  (λ h x hx, classical.by_contradiction $ λ hxm,\n    have ¬M < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact ⟨k, rfl⟩,\n    this ⟨HN ▸ I.leading_coeff_nth_mono (le_of_lt h), λ H, hxm (H hx)⟩),\nhave hs2 : ∀ {x}, x ∈ I.degree_le N → x ∈ ideal.span (↑s : set (polynomial R)),\nfrom hs ▸ λ x hx, submodule.span_induction hx (λ _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (λ _ _, ideal.add_mem _) (λ c f hf, f.C_mul' c ▸ ideal.mul_mem_left _ _ hf),\n⟨s, le_antisymm\n  (ideal.span_le.2 $ λ x hx, have x ∈ I.degree_le N, from hs ▸ submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span (polynomial R) ↑s = ideal.span ↑s, by refl,\n  rw this,\n  intros p hp, generalize hn : p.nat_degree = k,\n  induction k using nat.strong_induction_on with k ih generalizing p,\n  cases le_or_lt k N,\n  { subst k, refine hs2 ⟨polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp⟩ },\n  { have hp0 : p ≠ 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) ≠ 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [← h, mul_zero], refl },\n    haveI : nontrivial R := ⟨⟨0, 1, this⟩⟩,\n    have : p.leading_coeff ∈ I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        ⟨_, hp, hn ▸ polynomial.degree_le_nat_degree, rfl⟩) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with ⟨q, hq, hdq, hlqp⟩,\n    have hq0 : q ≠ 0,\n    { intro H, rw [← polynomial.leading_coeff_eq_zero] at H,\n      rw [hlqp, polynomial.leading_coeff_eq_zero] at H, exact hp0 H },\n    have h1 : p.degree = (q * polynomial.X ^ (k - q.nat_degree)).degree,\n    { rw [polynomial.degree_mul', polynomial.degree_X_pow],\n      rw [polynomial.degree_eq_nat_degree hp0, polynomial.degree_eq_nat_degree hq0],\n      rw [← with_bot.coe_add, nat.add_sub_cancel', hn],\n      { refine le_trans (polynomial.nat_degree_le_of_degree_le hdq) (le_of_lt h) },\n      rw [polynomial.leading_coeff_X_pow, mul_one],\n      exact mt polynomial.leading_coeff_eq_zero.1 hq0 },\n    have h2 : p.leading_coeff = (q * polynomial.X ^ (k - q.nat_degree)).leading_coeff,\n    { rw [← hlqp, polynomial.leading_coeff_mul_X_pow] },\n    have := polynomial.degree_sub_lt h1 hp0 h2,\n    rw [polynomial.degree_eq_nat_degree hp0] at this,\n    rw ← sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span ↑s).add_mem _ ((ideal.span ↑s).mul_mem_right _ _),\n    { by_cases hpq : p - q * polynomial.X ^ (k - q.nat_degree) = 0,\n      { rw hpq, exact ideal.zero_mem _ },\n      refine ih _ _ (I.sub_mem hp (I.mul_mem_right _ hq)) rfl,\n      rwa [polynomial.degree_eq_nat_degree hpq, with_bot.coe_lt_coe, hn] at this },\n    exact hs2 ⟨polynomial.mem_degree_le.2 hdq, hq⟩ }\nend⟩⟩\n\nattribute [instance] polynomial.is_noetherian_ring\n\nnamespace polynomial\n\ntheorem exists_irreducible_of_degree_pos {R : Type u} [integral_domain R] [wf_dvd_monoid R]\n  {f : polynomial R} (hf : 0 < f.degree) : ∃ g, irreducible g ∧ g ∣ f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (λ huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (λ hf0, not_lt_of_lt hf $ hf0.symm ▸ (@degree_zero R _).symm ▸ with_bot.bot_lt_coe _)\n\ntheorem exists_irreducible_of_nat_degree_pos {R : Type u} [integral_domain R] [wf_dvd_monoid R]\n  {f : polynomial R} (hf : 0 < f.nat_degree) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_degree_pos $ by { contrapose! hf, exact nat_degree_le_of_degree_le hf }\n\ntheorem exists_irreducible_of_nat_degree_ne_zero {R : Type u} [integral_domain R] [wf_dvd_monoid R]\n  {f : polynomial R} (hf : f.nat_degree ≠ 0) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_eval₂\n  (f : M →ₗ[R] M) (v : M) :\n  linear_independent R (λ n : ℕ, (f ^ n) v)\n    ↔ ∀ (p : polynomial R), aeval f p v = 0 → p = 0 :=\nbegin\n  rw linear_independent_iff,\n  simp only [finsupp.total_apply, aeval_endomorphism],\n  refl\nend\n\nlemma disjoint_ker_aeval_of_coprime\n  (f : M →ₗ[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  disjoint (aeval f p).ker (aeval f q).ker :=\nbegin\n  intros v hv,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  simpa [linear_map.mem_ker.1 (submodule.mem_inf.1 hv).1,\n         linear_map.mem_ker.1 (submodule.mem_inf.1 hv).2]\n    using congr_arg (λ p : polynomial R, aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M →ₗ[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).range ⊔ (aeval f q).range = ⊤ :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 ⟨aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 ⟨aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (λ p : polynomial R, aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M →ₗ[R] M} {p q : polynomial R} :\n  (aeval f p).ker ⊔ (aeval f q).ker ≤ (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with ⟨x, hx, y, hy, hxy⟩,\n  have h_eval_x : aeval f (p * q) x = 0,\n  { rw [mul_comm, aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hx, linear_map.map_zero] },\n  have h_eval_y : aeval f (p * q) y = 0,\n  { rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hy, linear_map.map_zero] },\n  rw [linear_map.mem_ker, ←hxy, linear_map.map_add, h_eval_x, h_eval_y, add_zero],\nend\n\nlemma sup_ker_aeval_eq_ker_aeval_mul_of_coprime\n  (f : M →ₗ[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).ker ⊔ (aeval f q).ker = (aeval f (p * q)).ker :=\nbegin\n  apply le_antisymm sup_ker_aeval_le_ker_aeval_mul,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  have h_eval₂_qpp' := calc\n    aeval f (q * (p * p')) v = aeval f (p' * (p * q)) v :\n      by rw [mul_comm, mul_assoc, mul_comm, mul_assoc, mul_comm q p]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  have h_eval₂_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [←mul_assoc, mul_comm]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  rw aeval_mul at h_eval₂_qpp' h_eval₂_pqq',\n  refine ⟨aeval f (q * q') v, linear_map.mem_ker.1 h_eval₂_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval₂_qpp', _⟩,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa using congr_arg (λ p : polynomial R, aeval f p v) hpq'\nend\n\nend polynomial\n\nnamespace mv_polynomial\n\nlemma is_noetherian_ring_fin_0 [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial (fin 0) R) :=\nis_noetherian_ring_of_ring_equiv R\n  ((mv_polynomial.pempty_ring_equiv R).symm.trans\n   (rename_equiv R fin_zero_equiv'.symm).to_ring_equiv)\n\ntheorem is_noetherian_ring_fin [is_noetherian_ring R] :\n  ∀ {n : ℕ}, is_noetherian_ring (mv_polynomial (fin n) R)\n| 0 := is_noetherian_ring_fin_0\n| (n+1) :=\n  @is_noetherian_ring_of_ring_equiv (polynomial (mv_polynomial (fin n) R)) _ _ _\n    (mv_polynomial.fin_succ_equiv _ n).to_ring_equiv.symm\n    (@polynomial.is_noetherian_ring (mv_polynomial (fin n) R) _ (is_noetherian_ring_fin))\n\n/-- The multivariate polynomial ring in finitely many variables over a noetherian ring\nis itself a noetherian ring. -/\ninstance is_noetherian_ring [fintype σ] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial σ R) :=\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card σ)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin σ).symm).to_ring_equiv is_noetherian_ring_fin\n\nlemma is_integral_domain_fin_zero (R : Type u) [comm_ring R] (hR : is_integral_domain R) :\n  is_integral_domain (mv_polynomial (fin 0) R) :=\nring_equiv.is_integral_domain R hR\n  ((rename_equiv R fin_zero_equiv').to_ring_equiv.trans (mv_polynomial.pempty_ring_equiv R))\n\n/-- Auxilliary lemma:\nMultivariate polynomials over an integral domain\nwith variables indexed by `fin n` form an integral domain.\nThis fact is proven inductively,\nand then used to prove the general case without any finiteness hypotheses.\nSee `mv_polynomial.integral_domain` for the general case. -/\nlemma is_integral_domain_fin (R : Type u) [comm_ring R] (hR : is_integral_domain R) :\n  ∀ (n : ℕ), is_integral_domain (mv_polynomial (fin n) R)\n| 0 := is_integral_domain_fin_zero R hR\n| (n+1) :=\n  ring_equiv.is_integral_domain\n    (polynomial (mv_polynomial (fin n) R))\n    (is_integral_domain_fin n).polynomial\n    (mv_polynomial.fin_succ_equiv _ n).to_ring_equiv\n\nlemma is_integral_domain_fintype (R : Type u) (σ : Type v) [comm_ring R] [fintype σ]\n  (hR : is_integral_domain R) : is_integral_domain (mv_polynomial σ R) :=\n@ring_equiv.is_integral_domain _ (mv_polynomial (fin $ fintype.card σ) R) _ _\n  (mv_polynomial.is_integral_domain_fin _ hR _)\n  (rename_equiv R (fintype.equiv_fin σ)).to_ring_equiv\n\n/-- Auxilliary definition:\nMultivariate polynomials in finitely many variables over an integral domain form an integral domain.\nThis fact is proven by transport of structure from the `mv_polynomial.integral_domain_fin`,\nand then used to prove the general case without finiteness hypotheses.\nSee `mv_polynomial.integral_domain` for the general case. -/\ndef integral_domain_fintype (R : Type u) (σ : Type v) [integral_domain R] [fintype σ] :\n  integral_domain (mv_polynomial σ R) :=\n@is_integral_domain.to_integral_domain _ _ $ mv_polynomial.is_integral_domain_fintype R σ $\nintegral_domain.to_is_integral_domain R\n\nprotected theorem eq_zero_or_eq_zero_of_mul_eq_zero {R : Type u} [integral_domain R] {σ : Type v}\n  (p q : mv_polynomial σ R) (h : p * q = 0) : p = 0 ∨ q = 0 :=\nbegin\n  obtain ⟨s, p, rfl⟩ := exists_finset_rename p,\n  obtain ⟨t, q, rfl⟩ := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x ∈ s} → {x // x ∈ s ∪ t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x ∈ t} → {x // x ∈ s ∪ t}) q = 0,\n  { apply rename_injective _ subtype.val_injective, simpa using h },\n  letI := mv_polynomial.integral_domain_fintype R {x // x ∈ (s ∪ t)},\n  rw mul_eq_zero at this,\n  cases this; [left, right],\n  all_goals { simpa using congr_arg (rename subtype.val) this }\nend\n\n/-- The multivariate polynomial ring over an integral domain is an integral domain. -/\ninstance {R : Type u} {σ : Type v} [integral_domain R] :\n  integral_domain (mv_polynomial σ R) :=\n{ eq_zero_or_eq_zero_of_mul_eq_zero := mv_polynomial.eq_zero_or_eq_zero_of_mul_eq_zero,\n  exists_pair_ne := ⟨0, 1, λ H,\n  begin\n    have : eval₂ (ring_hom.id _) (λ s, (0:R)) (0 : mv_polynomial σ R) =\n      eval₂ (ring_hom.id _) (λ s, (0:R)) (1 : mv_polynomial σ R),\n    { congr, exact H },\n    simpa,\n  end⟩,\n  .. (by apply_instance : comm_ring (mv_polynomial σ R)) }\n\nlemma map_mv_polynomial_eq_eval₂ {S : Type*} [comm_ring S] [fintype σ]\n  (ϕ : mv_polynomial σ R →+* S) (p : mv_polynomial σ R) :\n  ϕ p = mv_polynomial.eval₂ (ϕ.comp mv_polynomial.C) (λ s, ϕ (mv_polynomial.X s)) p :=\nbegin\n  refine trans (congr_arg ϕ (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval₂_eq', ϕ.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, ϕ.map_pow, ϕ.map_prod, ϕ.comp_apply, ϕ.map_mul, finsupp.prod_pow],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} {i : R} (hi : i ∈ I) :\n  (ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial σ R))).comp C i = 0 :=\nbegin\n  simp only [function.comp_app, ring_hom.coe_comp, ideal.quotient.eq_zero_iff_mem],\n  exact ideal.mem_map_of_mem hi\nend\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself,\nmultivariate version. -/\nlemma mem_ideal_of_coeff_mem_ideal (I : ideal (mv_polynomial σ R)) (p : mv_polynomial σ R)\n  (hcoe : ∀ (m : σ →₀ ℕ), p.coeff m ∈ I.comap C) : p ∈ I :=\nbegin\n  rw as_sum p,\n  suffices : ∀ m ∈ p.support, monomial m (mv_polynomial.coeff m p) ∈ I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [← mul_one (coeff m p), ← C_mul_monomial],\n  suffices : C (coeff m p) ∈ I,\n  { exact ideal.mul_mem_right I (monomial m 1) this },\n  simpa [ideal.mem_comap] using hcoe m\nend\n\n/-- The push-forward of an ideal `I` of `R` to `mv_polynomial σ R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : mv_polynomial σ R} :\n  f ∈ (ideal.map C I : ideal (mv_polynomial σ R)) ↔ ∀ (m : σ →₀ ℕ), f.coeff m ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n   { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : ∀ m ∈ f.support, monomial m (coeff m f) ∈\n      (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [← mul_one (coeff m f), ← C_mul_monomial],\n    suffices : C (coeff m f) ∈ (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact ideal.mul_mem_right _ _ this },\n    apply ideal.mem_map_of_mem _,\n    exact hf m }\nend\n\nlemma eval₂_C_mk_eq_zero {I : ideal R} {a : mv_polynomial σ R}\n  (ha : a ∈ (ideal.map C I : ideal (mv_polynomial σ R))) :\n  eval₂_hom (C.comp (ideal.quotient.mk I)) X a = 0 :=\nbegin\n  rw as_sum a,\n  rw [coe_eval₂_hom, eval₂_sum],\n  refine finset.sum_eq_zero (λ n hn, _),\n  simp only [eval₂_monomial, function.comp_app, ring_hom.coe_comp],\n  refine mul_eq_zero_of_left _ _,\n  suffices : coeff n a ∈ I,\n  { rw [← @ideal.mk_ker R _ I, ring_hom.mem_ker] at this,\n    simp only [this, C_0] },\n  exact mem_map_C_iff.1 ha n\nend\n\n/-- If `I` is an ideal of `R`, then the ring `mv_polynomial σ I.quotient` is isomorphic as an\n`R`-algebra to the quotient of `mv_polynomial σ R` by the ideal generated by `I`. -/\ndef quotient_equiv_quotient_mv_polynomial (I : ideal R) :\n  mv_polynomial σ I.quotient ≃ₐ[R] (ideal.map C I : ideal (mv_polynomial σ R)).quotient :=\n{ to_fun := eval₂_hom (ideal.quotient.lift I ((ideal.quotient.mk (ideal.map C I : ideal\n    (mv_polynomial σ R))).comp C) (λ i hi, quotient_map_C_eq_zero hi))\n    (λ i, ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial σ R)) (X i)),\n  inv_fun := ideal.quotient.lift (ideal.map C I : ideal (mv_polynomial σ R))\n    (eval₂_hom (C.comp (ideal.quotient.mk I)) X) (λ a ha, eval₂_C_mk_eq_zero ha),\n  map_mul' := ring_hom.map_mul _,\n  map_add' := ring_hom.map_add _,\n  left_inv := begin\n    intro f,\n    apply induction_on f,\n    { rintro ⟨r⟩,\n      rw [coe_eval₂_hom, eval₂_C],\n      simp only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk,\n        ideal.quotient.mk_eq_mk, bind₂_C_right, ring_hom.coe_comp] },\n    { simp_intros p q hp hq only [ring_hom.map_add, mv_polynomial.coe_eval₂_hom, coe_eval₂_hom,\n        mv_polynomial.eval₂_add, mv_polynomial.eval₂_hom_eq_bind₂, eval₂_hom_eq_bind₂],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval₂_hom_eq_bind₂, coe_eval₂_hom],\n      simp only [hp, eval₂_hom_eq_bind₂, coe_eval₂_hom, ideal.quotient.lift_mk, bind₂_X_right,\n        eval₂_mul, ring_hom.map_mul, eval₂_X] }\n  end,\n  right_inv := begin\n    rintro ⟨f⟩,\n    apply induction_on f,\n    { intros r,\n      simp only [submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk,\n        ring_hom.coe_comp, eval₂_hom_C] },\n    { simp_intros p q hp hq only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, eval₂_add,\n        ring_hom.map_add, coe_eval₂_hom, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval₂_hom_eq_bind₂, submodule.quotient.quot_mk_eq_mk, coe_eval₂_hom,\n        ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk, bind₂_X_right, eval₂_mul, ring_hom.map_mul,\n        eval₂_X],\n      simp only [hp] }\n  end,\n  commutes' := λ r, eval₂_hom_C _ _ (ideal.quotient.mk I r) }\n\nend mv_polynomial\n\nnamespace polynomial\nopen unique_factorization_monoid\n\nvariables {D : Type u} [integral_domain D] [unique_factorization_monoid D]\n\n@[priority 100]\ninstance unique_factorization_monoid : unique_factorization_monoid (polynomial D) :=\nbegin\n  haveI := arbitrary (normalization_monoid D),\n  haveI := to_gcd_monoid D,\n  exact ufm_of_gcd_of_wf_dvd_monoid\nend\n\nend polynomial\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/ring_theory/polynomial/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.4780356539354977}}
{"text": "/-\nCopyright (c) 2019 Bruno Bentzen. All rights reserved.\nReleased under the Apache License 2.0 (see \"License\");\nAuthor: Bruno Bentzen\n-/\n\nimport ..core.path\n\nopen pathd interval\n\nnamespace path\n\nlemma ap {A B : Type} (f : A → B) {a b : A} :\n  path A a b → path B (f a) (f b) :=\nλ p, path.abs (λ i, f (p @@ i))\n(by rw app0) (by rw app1)\n\nlemma apd {A : Type} {B : A → Type} {f : Π x, B x} {a b : A} :\n  Π p : path A a b, pathd (λ i, B (p @@ i)) (f (p @@ i0)) (f (p @@ i1)) :=\nλ p, pathd.abs (λ i, f (p @@ i))\n(by rw app0) (by rw app1)\n\ntheorem funext {A B : Type} {f g : A → B} : \n  (∀ x, path B (f x) (g x)) → path (A → B) f g :=\nλ h, path.abs (λ i x, ((h x) @@ i))\n(funext (λ x, app0 (h x))) (funext (λ x, app1 (h x)))\n\nend path\n\n", "meta": {"author": "bbentzen", "repo": "cubicalean", "sha": "3b94cd2aefdfc2163c263bd3fc6f2086fef814b5", "save_path": "github-repos/lean/bbentzen-cubicalean", "path": "github-repos/lean/bbentzen-cubicalean/cubicalean-3b94cd2aefdfc2163c263bd3fc6f2086fef814b5/src/path/function.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.47803564328259984}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Yury Kudryashov\n\n! This file was ported from Lean 3 source module algebra.algebra.hom\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Basic\n\n/-!\n# Homomorphisms of `R`-algebras\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines bundled homomorphisms of `R`-algebras.\n\n## Main definitions\n\n* `alg_hom R A B`: the type of `R`-algebra morphisms from `A` to `B`.\n* `algebra.of_id R A : R →ₐ[R] A`: the canonical map from `R` to `A`, as an `alg_hom`.\n\n## Notations\n\n* `A →ₐ[R] B` : `R`-algebra homomorphism from `A` to `B`.\n-/\n\n\nopen BigOperators\n\nuniverse u v w u₁ v₁\n\n#print AlgHom /-\n/-- Defining the homomorphism in the category R-Alg. -/\n@[nolint has_nonempty_instance]\nstructure AlgHom (R : Type u) (A : Type v) (B : Type w) [CommSemiring R] [Semiring A] [Semiring B]\n  [Algebra R A] [Algebra R B] extends RingHom A B where\n  commutes' : ∀ r : R, to_fun (algebraMap R A r) = algebraMap R B r\n#align alg_hom AlgHom\n-/\n\nrun_cmd\n  tactic.add_doc_string `alg_hom.to_ring_hom \"Reinterpret an `alg_hom` as a `ring_hom`\"\n\n-- mathport name: «expr →ₐ »\ninfixr:25 \" →ₐ \" => AlgHom _\n\n-- mathport name: «expr →ₐ[ ] »\nnotation:25 A \" →ₐ[\" R \"] \" B => AlgHom R A B\n\n#print AlgHomClass /-\n/-- `alg_hom_class F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B`.  -/\nclass AlgHomClass (F : Type _) (R : outParam (Type _)) (A : outParam (Type _))\n  (B : outParam (Type _)) [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A]\n  [Algebra R B] extends RingHomClass F A B where\n  commutes : ∀ (f : F) (r : R), f (algebraMap R A r) = algebraMap R B r\n#align alg_hom_class AlgHomClass\n-/\n\n-- `R` becomes a metavariable but that's fine because it's an `out_param`\nattribute [nolint dangerous_instance] AlgHomClass.toRingHomClass\n\nattribute [simp] AlgHomClass.commutes\n\nnamespace AlgHomClass\n\nvariable {R : Type _} {A : Type _} {B : Type _} [CommSemiring R] [Semiring A] [Semiring B]\n  [Algebra R A] [Algebra R B]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) {F : Type _} [AlgHomClass F R A B] : LinearMapClass F R A B :=\n  { ‹AlgHomClass F R A B› with\n    map_smulₛₗ := fun f r x => by\n      simp only [Algebra.smul_def, map_mul, commutes, RingHom.id_apply] }\n\ninstance {F : Type _} [AlgHomClass F R A B] : CoeTC F (A →ₐ[R] B)\n    where coe f :=\n    { (f : A →+* B) with\n      toFun := f\n      commutes' := AlgHomClass.commutes f }\n\nend AlgHomClass\n\nnamespace AlgHom\n\nvariable {R : Type u} {A : Type v} {B : Type w} {C : Type u₁} {D : Type v₁}\n\nsection Semiring\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Semiring C] [Semiring D]\n\nvariable [Algebra R A] [Algebra R B] [Algebra R C] [Algebra R D]\n\ninstance : CoeFun (A →ₐ[R] B) fun _ => A → B :=\n  ⟨AlgHom.toFun⟩\n\ninitialize_simps_projections AlgHom (toFun → apply)\n\n/- warning: alg_hom.coe_coe -> AlgHom.coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] {F : Type.{u4}} [_inst_10 : AlgHomClass.{u4, u1, u2, u3} F R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7] (f : F), Eq.{max (succ u2) (succ u3)} (A -> B) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) ((fun (a : Type.{u4}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{succ u4, max (succ u2) (succ u3)} a b] => self.0) F (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (HasLiftT.mk.{succ u4, max (succ u2) (succ u3)} F (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CoeTCₓ.coe.{succ u4, max (succ u2) (succ u3)} F (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHomClass.coeTC.{u1, u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 F _inst_10))) f)) (coeFn.{succ u4, max (succ u2) (succ u3)} F (fun (_x : F) => A -> B) (FunLike.hasCoeToFun.{succ u4, succ u2, succ u3} F A (fun (_x : A) => B) (SMulHomClass.toFunLike.{u4, u1, u2, u3} F R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (DistribSMul.toSmulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (DistribSMul.toSmulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSmulHomClass.{u4, u1, u2, u3} F R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, u4} R A B F (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 F _inst_10))))) f)\nbut is expected to have type\n  forall {R : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Semiring.{u4} B] [_inst_6 : Algebra.{u2, u3} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u2, u4} R B _inst_1 _inst_3] {F : Type.{u1}} [_inst_10 : AlgHomClass.{u1, u2, u3, u4} F R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7] (f : F), Eq.{max (succ u3) (succ u4)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) ᾰ) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u3 u4} R A B (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, max u3 u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) (AlgHomClass.toAlgHom.{u2, u3, u4, u1} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 F _inst_10 f)) (FunLike.coe.{succ u1, succ u3, succ u4} F A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{u1, u2, u3, u4} F R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{u1, u2, u3, u4} F R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, u1} R A B F (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, u1} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 F _inst_10)))) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_coe AlgHom.coe_coeₓ'. -/\n@[simp, protected]\ntheorem coe_coe {F : Type _} [AlgHomClass F R A B] (f : F) : ⇑(f : A →ₐ[R] B) = f :=\n  rfl\n#align alg_hom.coe_coe AlgHom.coe_coe\n\n/- warning: alg_hom.to_fun_eq_coe -> AlgHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (A -> B) (AlgHom.toFun.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) f)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (A -> B) (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.toOneHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (RingHom.toMonoidHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHom.toRingHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f)))) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.to_fun_eq_coe AlgHom.toFun_eq_coeₓ'. -/\n@[simp]\ntheorem toFun_eq_coe (f : A →ₐ[R] B) : f.toFun = f :=\n  rfl\n#align alg_hom.to_fun_eq_coe AlgHom.toFun_eq_coe\n\ninstance : AlgHomClass (A →ₐ[R] B) R A B\n    where\n  coe := toFun\n  coe_injective' f g h := by\n    cases f\n    cases g\n    congr\n  map_add := map_add'\n  map_zero := map_zero'\n  map_mul := map_mul'\n  map_one := map_one'\n  commutes f := f.commutes'\n\n/- warning: alg_hom.coe_ring_hom -> AlgHom.coeOutRingHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], CoeOut.{max (succ u3) (succ u2), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_ring_hom AlgHom.coeOutRingHomₓ'. -/\ninstance coeOutRingHom : Coe (A →ₐ[R] B) (A →+* B) :=\n  ⟨AlgHom.toRingHom⟩\n#align alg_hom.coe_ring_hom AlgHom.coeOutRingHom\n\n/- warning: alg_hom.coe_monoid_hom -> AlgHom.coeOutMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], CoeOut.{max (succ u3) (succ u2), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_monoid_hom AlgHom.coeOutMonoidHomₓ'. -/\ninstance coeOutMonoidHom : Coe (A →ₐ[R] B) (A →* B) :=\n  ⟨fun f => ↑(f : A →+* B)⟩\n#align alg_hom.coe_monoid_hom AlgHom.coeOutMonoidHom\n\n/- warning: alg_hom.coe_add_monoid_hom -> AlgHom.coeOutAddMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], CoeOut.{max (succ u3) (succ u2), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))))\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_add_monoid_hom AlgHom.coeOutAddMonoidHomₓ'. -/\ninstance coeOutAddMonoidHom : Coe (A →ₐ[R] B) (A →+ B) :=\n  ⟨fun f => ↑(f : A →+* B)⟩\n#align alg_hom.coe_add_monoid_hom AlgHom.coeOutAddMonoidHom\n\n/- warning: alg_hom.coe_mk -> AlgHom.coe_mks is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] {f : A -> B} (h₁ : Eq.{succ u3} B (f (OfNat.ofNat.{u2} A 1 (OfNat.mk.{u2} A 1 (One.one.{u2} A (MulOneClass.toHasOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))) (OfNat.ofNat.{u3} B 1 (OfNat.mk.{u3} B 1 (One.one.{u3} B (MulOneClass.toHasOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))) (h₂ : forall (x : A) (y : A), Eq.{succ u3} B (f (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (MulOneClass.toHasMul.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) x y)) (HMul.hMul.{u3, u3, u3} B B B (instHMul.{u3} B (MulOneClass.toHasMul.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (f x) (f y))) (h₃ : Eq.{succ u3} B (f (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))))) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))))) (h₄ : forall (x : A) (y : A), Eq.{succ u3} B (f (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))))) x y)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toHasAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))))) (f x) (f y))) (h₅ : forall (r : R), Eq.{succ u3} B (f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_6) r)) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => R -> B) (RingHom.hasCoeToFun.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (algebraMap.{u1, u3} R B _inst_1 _inst_3 _inst_7) r)), Eq.{max (succ u2) (succ u3)} (A -> B) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.mk.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f h₁ h₂ h₃ h₄ h₅)) f\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] {f : A -> B} (h₁ : Eq.{succ u3} B (f (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))))) (OfNat.ofNat.{u3} B 1 (One.toOfNat1.{u3} B (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))))) (h₂ : forall (x : A) (y : A), Eq.{succ u3} B (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (MulOneClass.toMul.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) x y)) (HMul.hMul.{u3, u3, u3} B B B (instHMul.{u3} B (MulOneClass.toMul.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) x) (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) y))) (h₃ : Eq.{succ u3} B (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.toOneHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (MonoidHom.mk.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) h₂)) (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (AddZeroClass.toZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))))))) (OfNat.ofNat.{u3} B 0 (Zero.toOfNat0.{u3} B (AddZeroClass.toZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))))))) (h₄ : forall (x : A) (y : A), Eq.{succ u3} B (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.toOneHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (MonoidHom.mk.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) h₂)) (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))))) x y)) (HAdd.hAdd.{u3, u3, u3} B B B (instHAdd.{u3} B (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))))) (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.toOneHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (MonoidHom.mk.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) h₂)) x) (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.toOneHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (MonoidHom.mk.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) h₂)) y))) (h₅ : forall (r : R), Eq.{succ u3} B (OneHom.toFun.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.toOneHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (RingHom.toMonoidHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.mk.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (MonoidHom.mk.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) h₂) h₃ h₄))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (RingHom.instRingHomClassRingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_6) r)) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => B) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R B (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (algebraMap.{u1, u3} R B _inst_1 _inst_3 _inst_7) r)), Eq.{max (succ u2) (succ u3)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) ᾰ) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) (AlgHom.mk.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (RingHom.mk.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (MonoidHom.mk.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (OneHom.mk.{u2, u3} A B (MulOneClass.toOne.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toOne.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) f h₁) h₂) h₃ h₄) h₅)) f\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_mk AlgHom.coe_mksₓ'. -/\n@[simp, norm_cast]\ntheorem coe_mks {f : A → B} (h₁ h₂ h₃ h₄ h₅) : ⇑(⟨f, h₁, h₂, h₃, h₄, h₅⟩ : A →ₐ[R] B) = f :=\n  rfl\n#align alg_hom.coe_mk AlgHom.coe_mks\n\n/- warning: alg_hom.to_ring_hom_eq_coe -> AlgHom.toRingHom_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (AlgHom.toRingHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u2) (succ u3)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHom.hasCoeT.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) f)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (AlgHom.toRingHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f) (RingHomClass.toRingHom.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.to_ring_hom_eq_coe AlgHom.toRingHom_eq_coeₓ'. -/\n-- make the coercion the simp-normal form\n@[simp]\ntheorem toRingHom_eq_coe (f : A →ₐ[R] B) : f.toRingHom = f :=\n  rfl\n#align alg_hom.to_ring_hom_eq_coe AlgHom.toRingHom_eq_coe\n\n/- warning: alg_hom.coe_to_ring_hom -> AlgHom.coe_toRingHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (A -> B) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u2) (succ u3)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHom.hasCoeT.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) f)) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) f)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) ᾰ) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (RingHomClass.toRingHom.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)) f)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_to_ring_hom AlgHom.coe_toRingHomₓ'. -/\n@[simp, norm_cast]\ntheorem coe_toRingHom (f : A →ₐ[R] B) : ⇑(f : A →+* B) = f :=\n  rfl\n#align alg_hom.coe_to_ring_hom AlgHom.coe_toRingHom\n\n/- warning: alg_hom.coe_to_monoid_hom -> AlgHom.coe_toMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (A -> B) (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (fun (_x : MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) => A -> B) (MonoidHom.hasCoeToFun.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u3) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u3) (succ u2)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.hasCoeT.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (RingHomClass.toMonoidHomClass.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)))))) f)) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) f)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) ᾰ) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) A B (MulOneClass.toMul.{u2} A (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulOneClass.toMul.{u3} B (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHomClass.toMulHomClass.{max u2 u3, u2, u3} (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (MonoidHom.monoidHomClass.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MonoidHomClass.toMonoidHom.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (RingHomClass.toMonoidHomClass.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))) f)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_to_monoid_hom AlgHom.coe_toMonoidHomₓ'. -/\n@[simp, norm_cast]\ntheorem coe_toMonoidHom (f : A →ₐ[R] B) : ⇑(f : A →* B) = f :=\n  rfl\n#align alg_hom.coe_to_monoid_hom AlgHom.coe_toMonoidHom\n\n/- warning: alg_hom.coe_to_add_monoid_hom -> AlgHom.coe_toAddMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (A -> B) (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (fun (_x : AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) => A -> B) (AddMonoidHom.hasCoeToFun.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u3) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u3) (succ u2)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (AddMonoidHom.hasCoeT.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (SemilinearMapClass.addMonoidHomClass.{u1, u1, u2, u3, max u2 u3} R R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)))))) f)) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) f)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) ᾰ) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) _x) (AddHomClass.toFunLike.{max u2 u3, u2, u3} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) A B (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (AddZeroClass.toAdd.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u3, u2, u3} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (AddMonoidHom.addMonoidHomClass.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))) (AddMonoidHomClass.toAddMonoidHom.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulActionHomClass.toAddMonoidHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)))) f)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_to_add_monoid_hom AlgHom.coe_toAddMonoidHomₓ'. -/\n@[simp, norm_cast]\ntheorem coe_toAddMonoidHom (f : A →ₐ[R] B) : ⇑(f : A →+ B) = f :=\n  rfl\n#align alg_hom.coe_to_add_monoid_hom AlgHom.coe_toAddMonoidHom\n\nvariable (φ : A →ₐ[R] B)\n\n#print AlgHom.coe_fn_injective /-\ntheorem coe_fn_injective : @Function.Injective (A →ₐ[R] B) (A → B) coeFn :=\n  FunLike.coe_injective\n#align alg_hom.coe_fn_injective AlgHom.coe_fn_injective\n-/\n\n#print AlgHom.coe_fn_inj /-\ntheorem coe_fn_inj {φ₁ φ₂ : A →ₐ[R] B} : (φ₁ : A → B) = φ₂ ↔ φ₁ = φ₂ :=\n  FunLike.coe_fn_eq\n#align alg_hom.coe_fn_inj AlgHom.coe_fn_inj\n-/\n\n/- warning: alg_hom.coe_ring_hom_injective -> AlgHom.coe_ringHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Function.Injective.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u2) (succ u3)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHom.hasCoeT.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Function.Injective.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toRingHom.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_ring_hom_injective AlgHom.coe_ringHom_injectiveₓ'. -/\ntheorem coe_ringHom_injective : Function.Injective (coe : (A →ₐ[R] B) → A →+* B) := fun φ₁ φ₂ H =>\n  coe_fn_injective <| show ((φ₁ : A →+* B) : A → B) = ((φ₂ : A →+* B) : A → B) from congr_arg _ H\n#align alg_hom.coe_ring_hom_injective AlgHom.coe_ringHom_injective\n\n/- warning: alg_hom.coe_monoid_hom_injective -> AlgHom.coe_monoidHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Function.Injective.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u3) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u3) (succ u2)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHom.hasCoeT.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (RingHomClass.toMonoidHomClass.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Function.Injective.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MonoidHom.{u2, u3} A B (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (MonoidHomClass.toMonoidHom.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (MulZeroOneClass.toMulOneClass.{u2} A (NonAssocSemiring.toMulZeroOneClass.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (MulZeroOneClass.toMulOneClass.{u3} B (NonAssocSemiring.toMulZeroOneClass.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (RingHomClass.toMonoidHomClass.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_monoid_hom_injective AlgHom.coe_monoidHom_injectiveₓ'. -/\ntheorem coe_monoidHom_injective : Function.Injective (coe : (A →ₐ[R] B) → A →* B) :=\n  RingHom.coe_monoidHom_injective.comp coe_ringHom_injective\n#align alg_hom.coe_monoid_hom_injective AlgHom.coe_monoidHom_injective\n\n/- warning: alg_hom.coe_add_monoid_hom_injective -> AlgHom.coe_addMonoidHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Function.Injective.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u3) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u3) (succ u2)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (AddMonoidHom.hasCoeT.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (SemilinearMapClass.addMonoidHomClass.{u1, u1, u2, u3, max u2 u3} R R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3], Function.Injective.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (AddMonoidHomClass.toAddMonoidHom.{u2, u3, max u2 u3} A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (AddMonoid.toAddZeroClass.{u3} B (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulActionHomClass.toAddMonoidHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddMonoidWithOne.toAddMonoid.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)))))\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_add_monoid_hom_injective AlgHom.coe_addMonoidHom_injectiveₓ'. -/\ntheorem coe_addMonoidHom_injective : Function.Injective (coe : (A →ₐ[R] B) → A →+ B) :=\n  RingHom.coe_addMonoidHom_injective.comp coe_ringHom_injective\n#align alg_hom.coe_add_monoid_hom_injective AlgHom.coe_addMonoidHom_injective\n\n#print AlgHom.congr_fun /-\nprotected theorem congr_fun {φ₁ φ₂ : A →ₐ[R] B} (H : φ₁ = φ₂) (x : A) : φ₁ x = φ₂ x :=\n  FunLike.congr_fun H x\n#align alg_hom.congr_fun AlgHom.congr_fun\n-/\n\n#print AlgHom.congr_arg /-\nprotected theorem congr_arg (φ : A →ₐ[R] B) {x y : A} (h : x = y) : φ x = φ y :=\n  FunLike.congr_arg φ h\n#align alg_hom.congr_arg AlgHom.congr_arg\n-/\n\n#print AlgHom.ext /-\n@[ext]\ntheorem ext {φ₁ φ₂ : A →ₐ[R] B} (H : ∀ x, φ₁ x = φ₂ x) : φ₁ = φ₂ :=\n  FunLike.ext _ _ H\n#align alg_hom.ext AlgHom.ext\n-/\n\n#print AlgHom.ext_iff /-\ntheorem ext_iff {φ₁ φ₂ : A →ₐ[R] B} : φ₁ = φ₂ ↔ ∀ x, φ₁ x = φ₂ x :=\n  FunLike.ext_iff\n#align alg_hom.ext_iff AlgHom.ext_iff\n-/\n\n#print AlgHom.mk_coe /-\n@[simp]\ntheorem mk_coe {f : A →ₐ[R] B} (h₁ h₂ h₃ h₄ h₅) : (⟨f, h₁, h₂, h₃, h₄, h₅⟩ : A →ₐ[R] B) = f :=\n  ext fun _ => rfl\n#align alg_hom.mk_coe AlgHom.mk_coe\n-/\n\n#print AlgHom.commutes /-\n@[simp]\ntheorem commutes (r : R) : φ (algebraMap R A r) = algebraMap R B r :=\n  φ.commutes' r\n#align alg_hom.commutes AlgHom.commutes\n-/\n\n/- warning: alg_hom.comp_algebra_map -> AlgHom.comp_algebraMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHom.comp.{u1, u2, u3} R A B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u2) (succ u3)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHom.hasCoeT.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (algebraMap.{u1, u3} R B _inst_1 _inst_3 _inst_7)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHom.comp.{u1, u2, u3} R A B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHomClass.toRingHom.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)) φ) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (algebraMap.{u1, u3} R B _inst_1 _inst_3 _inst_7)\nCase conversion may be inaccurate. Consider using '#align alg_hom.comp_algebra_map AlgHom.comp_algebraMapₓ'. -/\ntheorem comp_algebraMap : (φ : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n  RingHom.ext <| φ.commutes\n#align alg_hom.comp_algebra_map AlgHom.comp_algebraMap\n\n#print AlgHom.map_add /-\nprotected theorem map_add (r s : A) : φ (r + s) = φ r + φ s :=\n  map_add _ _ _\n#align alg_hom.map_add AlgHom.map_add\n-/\n\n#print AlgHom.map_zero /-\nprotected theorem map_zero : φ 0 = 0 :=\n  map_zero _\n#align alg_hom.map_zero AlgHom.map_zero\n-/\n\n#print AlgHom.map_mul /-\nprotected theorem map_mul (x y) : φ (x * y) = φ x * φ y :=\n  map_mul _ _ _\n#align alg_hom.map_mul AlgHom.map_mul\n-/\n\n#print AlgHom.map_one /-\nprotected theorem map_one : φ 1 = 1 :=\n  map_one _\n#align alg_hom.map_one AlgHom.map_one\n-/\n\n#print AlgHom.map_pow /-\nprotected theorem map_pow (x : A) (n : ℕ) : φ (x ^ n) = φ x ^ n :=\n  map_pow _ _ _\n#align alg_hom.map_pow AlgHom.map_pow\n-/\n\n#print AlgHom.map_smul /-\n@[simp]\nprotected theorem map_smul (r : R) (x : A) : φ (r • x) = r • φ x :=\n  map_smul _ _ _\n#align alg_hom.map_smul AlgHom.map_smul\n-/\n\n/- warning: alg_hom.map_sum -> AlgHom.map_sum is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {ι : Type.{u4}} (f : ι -> A) (s : Finset.{u4} ι), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) φ (Finset.sum.{u2, u4} A ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) s (fun (x : ι) => f x))) (Finset.sum.{u3, u4} B ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) s (fun (x : ι) => coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) φ (f x)))\nbut is expected to have type\n  forall {R : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Semiring.{u4} B] [_inst_6 : Algebra.{u2, u3} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u2, u4} R B _inst_1 _inst_3] (φ : AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {ι : Type.{u1}} (f : ι -> A) (s : Finset.{u1} ι), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finset.sum.{u3, u1} A ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) s (fun (x : ι) => f x))) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u3 u4} R A B (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, max u3 u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ (Finset.sum.{u3, u1} A ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) s (fun (x : ι) => f x))) (Finset.sum.{u4, u1} B ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) s (fun (x : ι) => FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u3 u4} R A B (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, max u3 u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ (f x)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_sum AlgHom.map_sumₓ'. -/\nprotected theorem map_sum {ι : Type _} (f : ι → A) (s : Finset ι) :\n    φ (∑ x in s, f x) = ∑ x in s, φ (f x) :=\n  map_sum _ _ _\n#align alg_hom.map_sum AlgHom.map_sum\n\n/- warning: alg_hom.map_finsupp_sum -> AlgHom.map_finsupp_sum is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {α : Type.{u4}} [_inst_10 : Zero.{u4} α] {ι : Type.{u5}} (f : Finsupp.{u5, u4} ι α _inst_10) (g : ι -> α -> A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) φ (Finsupp.sum.{u5, u4, u2} ι α A _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) f g)) (Finsupp.sum.{u5, u4, u3} ι α B _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) f (fun (i : ι) (a : α) => coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) φ (g i a)))\nbut is expected to have type\n  forall {R : Type.{u3}} {A : Type.{u4}} {B : Type.{u5}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : Semiring.{u4} A] [_inst_3 : Semiring.{u5} B] [_inst_6 : Algebra.{u3, u4} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u3, u5} R B _inst_1 _inst_3] (φ : AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {α : Type.{u2}} [_inst_10 : Zero.{u2} α] {ι : Type.{u1}} (f : Finsupp.{u1, u2} ι α _inst_10) (g : ι -> α -> A), Eq.{succ u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finsupp.sum.{u1, u2, u4} ι α A _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) f g)) (FunLike.coe.{max (succ u4) (succ u5), succ u4, succ u5} (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u3, u4} R A (AddMonoid.toZero.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u3, u4} R A (AddMonoid.toAddZeroClass.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))))) (DistribMulAction.toDistribSMul.{u3, u4} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2)))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) (Algebra.toModule.{u3, u4} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u3, u5} R B (AddMonoid.toZero.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u3, u5} R B (AddMonoid.toAddZeroClass.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))))) (DistribMulAction.toDistribSMul.{u3, u5} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3)))) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) (Algebra.toModule.{u3, u5} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3)))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) (Algebra.toModule.{u3, u4} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) (Algebra.toModule.{u3, u5} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u3, u4, u5, max u4 u5} R A B (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) (Algebra.toModule.{u3, u4} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u3, u5} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u3, u4, u5, max u4 u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ (Finsupp.sum.{u1, u2, u4} ι α A _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) f g)) (Finsupp.sum.{u1, u2, u5} ι α B _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) f (fun (i : ι) (a : α) => FunLike.coe.{max (succ u4) (succ u5), succ u4, succ u5} (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u3, u4} R A (AddMonoid.toZero.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u3, u4} R A (AddMonoid.toAddZeroClass.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))))) (DistribMulAction.toDistribSMul.{u3, u4} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2)))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) (Algebra.toModule.{u3, u4} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u3, u5} R B (AddMonoid.toZero.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u3, u5} R B (AddMonoid.toAddZeroClass.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))))) (DistribMulAction.toDistribSMul.{u3, u5} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3)))) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) (Algebra.toModule.{u3, u5} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3)))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) (Algebra.toModule.{u3, u4} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) (Algebra.toModule.{u3, u5} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u3, u4, u5, max u4 u5} R A B (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) (Algebra.toModule.{u3, u4} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u3, u5} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u3, u4, u5, max u4 u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ (g i a)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_finsupp_sum AlgHom.map_finsupp_sumₓ'. -/\nprotected theorem map_finsupp_sum {α : Type _} [Zero α] {ι : Type _} (f : ι →₀ α) (g : ι → α → A) :\n    φ (f.Sum g) = f.Sum fun i a => φ (g i a) :=\n  map_finsupp_sum _ _ _\n#align alg_hom.map_finsupp_sum AlgHom.map_finsupp_sum\n\n#print AlgHom.map_bit0 /-\nprotected theorem map_bit0 (x) : φ (bit0 x) = bit0 (φ x) :=\n  map_bit0 _ _\n#align alg_hom.map_bit0 AlgHom.map_bit0\n-/\n\n#print AlgHom.map_bit1 /-\nprotected theorem map_bit1 (x) : φ (bit1 x) = bit1 (φ x) :=\n  map_bit1 _ _\n#align alg_hom.map_bit1 AlgHom.map_bit1\n-/\n\n/- warning: alg_hom.mk' -> AlgHom.mk' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)), (forall (c : R) (x : A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) f (SMul.smul.{u1, u2} R A (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) c x)) (SMul.smul.{u1, u3} R B (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) c (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) f x))) -> (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)), (forall (c : R) (x : A), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) (HSMul.hSMul.{u1, u2, u2} R A A (instHSMul.{u1, u2} R A (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_6)) c x)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) f (HSMul.hSMul.{u1, u2, u2} R A A (instHSMul.{u1, u2} R A (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_6)) c x)) (HSMul.hSMul.{u1, u3, u3} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (instHSMul.{u1, u3} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Algebra.toSMul.{u1, u3} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_7)) c (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) f x))) -> (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)\nCase conversion may be inaccurate. Consider using '#align alg_hom.mk' AlgHom.mk'ₓ'. -/\n/-- If a `ring_hom` is `R`-linear, then it is an `alg_hom`. -/\ndef mk' (f : A →+* B) (h : ∀ (c : R) (x), f (c • x) = c • f x) : A →ₐ[R] B :=\n  { f with\n    toFun := f\n    commutes' := fun c => by simp only [Algebra.algebraMap_eq_smul_one, h, f.map_one] }\n#align alg_hom.mk' AlgHom.mk'\n\n/- warning: alg_hom.coe_mk' -> AlgHom.coe_mk' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (h : forall (c : R) (x : A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) f (SMul.smul.{u1, u2} R A (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) c x)) (SMul.smul.{u1, u3} R B (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) c (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) f x))), Eq.{max (succ u2) (succ u3)} (A -> B) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.mk'.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f h)) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) f)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (h : forall (c : R) (x : A), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) (HSMul.hSMul.{u1, u2, u2} R A A (instHSMul.{u1, u2} R A (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_6)) c x)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) f (HSMul.hSMul.{u1, u2, u2} R A A (instHSMul.{u1, u2} R A (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_6)) c x)) (HSMul.hSMul.{u1, u3, u3} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (instHSMul.{u1, u3} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Algebra.toSMul.{u1, u3} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_7)) c (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) f x))), Eq.{max (succ u2) (succ u3)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) ᾰ) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) (AlgHom.mk'.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f h)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_mk' AlgHom.coe_mk'ₓ'. -/\n@[simp]\ntheorem coe_mk' (f : A →+* B) (h : ∀ (c : R) (x), f (c • x) = c • f x) : ⇑(mk' f h) = f :=\n  rfl\n#align alg_hom.coe_mk' AlgHom.coe_mk'\n\nsection\n\nvariable (R A)\n\n#print AlgHom.id /-\n/-- Identity map as an `alg_hom`. -/\nprotected def id : A →ₐ[R] A :=\n  { RingHom.id A with commutes' := fun _ => rfl }\n#align alg_hom.id AlgHom.id\n-/\n\n#print AlgHom.coe_id /-\n@[simp]\ntheorem coe_id : ⇑(AlgHom.id R A) = id :=\n  rfl\n#align alg_hom.coe_id AlgHom.coe_id\n-/\n\n/- warning: alg_hom.id_to_ring_hom -> AlgHom.id_toRingHom is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2], Eq.{succ u2} (RingHom.{u2, u2} A A (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) (RingHom.{u2, u2} A A (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (HasLiftT.mk.{succ u2, succ u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) (RingHom.{u2, u2} A A (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (CoeTCₓ.coe.{succ u2, succ u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) (RingHom.{u2, u2} A A (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (RingHom.hasCoeT.{u2, u2, u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) A A (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (AlgHomClass.toRingHomClass.{u2, u1, u2, u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6 (AlgHom.algHomClass.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6))))) (AlgHom.id.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (RingHom.id.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2], Eq.{succ u2} (RingHom.{u2, u2} A A (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (RingHomClass.toRingHom.{u2, u2, u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) A A (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (AlgHomClass.toRingHomClass.{u2, u1, u2, u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6 (AlgHom.algHomClass.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6)) (AlgHom.id.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (RingHom.id.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))\nCase conversion may be inaccurate. Consider using '#align alg_hom.id_to_ring_hom AlgHom.id_toRingHomₓ'. -/\n@[simp]\ntheorem id_toRingHom : (AlgHom.id R A : A →+* A) = RingHom.id _ :=\n  rfl\n#align alg_hom.id_to_ring_hom AlgHom.id_toRingHom\n\nend\n\n#print AlgHom.id_apply /-\ntheorem id_apply (p : A) : AlgHom.id R A p = p :=\n  rfl\n#align alg_hom.id_apply AlgHom.id_apply\n-/\n\n#print AlgHom.comp /-\n/-- Composition of algebra homeomorphisms. -/\ndef comp (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) : A →ₐ[R] C :=\n  { φ₁.toRingHom.comp ↑φ₂ with\n    commutes' := fun r : R => by rw [← φ₁.commutes, ← φ₂.commutes] <;> rfl }\n#align alg_hom.comp AlgHom.comp\n-/\n\n#print AlgHom.coe_comp /-\n@[simp]\ntheorem coe_comp (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) : ⇑(φ₁.comp φ₂) = φ₁ ∘ φ₂ :=\n  rfl\n#align alg_hom.coe_comp AlgHom.coe_comp\n-/\n\n#print AlgHom.comp_apply /-\ntheorem comp_apply (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) (p : A) : φ₁.comp φ₂ p = φ₁ (φ₂ p) :=\n  rfl\n#align alg_hom.comp_apply AlgHom.comp_apply\n-/\n\n/- warning: alg_hom.comp_to_ring_hom -> AlgHom.comp_toRingHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_4 : Semiring.{u4} C] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] [_inst_8 : Algebra.{u1, u4} R C _inst_1 _inst_4] (φ₁ : AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) (φ₂ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u2) (succ u4)} (RingHom.{u2, u4} A C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) ((fun (a : Sort.{max (succ u2) (succ u4)}) (b : Sort.{max (succ u2) (succ u4)}) [self : HasLiftT.{max (succ u2) (succ u4), max (succ u2) (succ u4)} a b] => self.0) (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8) (RingHom.{u2, u4} A C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) (HasLiftT.mk.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8) (RingHom.{u2, u4} A C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) (CoeTCₓ.coe.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8) (RingHom.{u2, u4} A C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) (RingHom.hasCoeT.{max u2 u4, u2, u4} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8) A C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u4} C _inst_4) (AlgHomClass.toRingHomClass.{max u2 u4, u1, u2, u4} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8) R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8 (AlgHom.algHomClass.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8))))) (AlgHom.comp.{u1, u2, u3, u4} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 _inst_8 φ₁ φ₂)) (RingHom.comp.{u2, u3, u4} A B C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (Semiring.toNonAssocSemiring.{u4} C _inst_4) ((fun (a : Sort.{max (succ u3) (succ u4)}) (b : Sort.{max (succ u3) (succ u4)}) [self : HasLiftT.{max (succ u3) (succ u4), max (succ u3) (succ u4)} a b] => self.0) (AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) (RingHom.{u3, u4} B C (Semiring.toNonAssocSemiring.{u3} B _inst_3) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) (HasLiftT.mk.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) (RingHom.{u3, u4} B C (Semiring.toNonAssocSemiring.{u3} B _inst_3) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) (CoeTCₓ.coe.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) (RingHom.{u3, u4} B C (Semiring.toNonAssocSemiring.{u3} B _inst_3) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) (RingHom.hasCoeT.{max u3 u4, u3, u4} (AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) B C (Semiring.toNonAssocSemiring.{u3} B _inst_3) (Semiring.toNonAssocSemiring.{u4} C _inst_4) (AlgHomClass.toRingHomClass.{max u3 u4, u1, u3, u4} (AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8 (AlgHom.algHomClass.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8))))) φ₁) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u2) (succ u3)} a b] => self.0) (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHom.hasCoeT.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ₂))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_4 : Semiring.{u4} C] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] [_inst_8 : Algebra.{u1, u4} R C _inst_1 _inst_4] (φ₁ : AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) (φ₂ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7), Eq.{max (succ u4) (succ u2)} (RingHom.{u2, u4} A C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u4} C _inst_4)) (RingHomClass.toRingHom.{max u4 u2, u2, u4} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8) A C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u4} C _inst_4) (AlgHomClass.toRingHomClass.{max u4 u2, u1, u2, u4} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8) R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8 (AlgHom.algHomClass.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_4 _inst_6 _inst_8)) (AlgHom.comp.{u1, u2, u3, u4} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 _inst_8 φ₁ φ₂)) (RingHom.comp.{u2, u3, u4} A B C (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (Semiring.toNonAssocSemiring.{u4} C _inst_4) (RingHomClass.toRingHom.{max u4 u3, u3, u4} (AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) B C (Semiring.toNonAssocSemiring.{u3} B _inst_3) (Semiring.toNonAssocSemiring.{u4} C _inst_4) (AlgHomClass.toRingHomClass.{max u4 u3, u1, u3, u4} (AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8 (AlgHom.algHomClass.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8)) φ₁) (RingHomClass.toRingHom.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u2} A _inst_2) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)) φ₂))\nCase conversion may be inaccurate. Consider using '#align alg_hom.comp_to_ring_hom AlgHom.comp_toRingHomₓ'. -/\ntheorem comp_toRingHom (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) :\n    (φ₁.comp φ₂ : A →+* C) = (φ₁ : B →+* C).comp ↑φ₂ :=\n  rfl\n#align alg_hom.comp_to_ring_hom AlgHom.comp_toRingHom\n\n#print AlgHom.comp_id /-\n@[simp]\ntheorem comp_id : φ.comp (AlgHom.id R A) = φ :=\n  ext fun x => rfl\n#align alg_hom.comp_id AlgHom.comp_id\n-/\n\n#print AlgHom.id_comp /-\n@[simp]\ntheorem id_comp : (AlgHom.id R B).comp φ = φ :=\n  ext fun x => rfl\n#align alg_hom.id_comp AlgHom.id_comp\n-/\n\n#print AlgHom.comp_assoc /-\ntheorem comp_assoc (φ₁ : C →ₐ[R] D) (φ₂ : B →ₐ[R] C) (φ₃ : A →ₐ[R] B) :\n    (φ₁.comp φ₂).comp φ₃ = φ₁.comp (φ₂.comp φ₃) :=\n  ext fun x => rfl\n#align alg_hom.comp_assoc AlgHom.comp_assoc\n-/\n\n#print AlgHom.toLinearMap /-\n/-- R-Alg ⥤ R-Mod -/\ndef toLinearMap : A →ₗ[R] B where\n  toFun := φ\n  map_add' := map_add _\n  map_smul' := map_smul _\n#align alg_hom.to_linear_map AlgHom.toLinearMap\n-/\n\n/- warning: alg_hom.to_linear_map_apply -> AlgHom.toLinearMap_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (p : A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) p) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) φ p)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (p : A), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) p) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) p) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ p)\nCase conversion may be inaccurate. Consider using '#align alg_hom.to_linear_map_apply AlgHom.toLinearMap_applyₓ'. -/\n@[simp]\ntheorem toLinearMap_apply (p : A) : φ.toLinearMap p = φ p :=\n  rfl\n#align alg_hom.to_linear_map_apply AlgHom.toLinearMap_apply\n\n#print AlgHom.toLinearMap_injective /-\ntheorem toLinearMap_injective : Function.Injective (toLinearMap : _ → A →ₗ[R] B) := fun φ₁ φ₂ h =>\n  ext <| LinearMap.congr_fun h\n#align alg_hom.to_linear_map_injective AlgHom.toLinearMap_injective\n-/\n\n#print AlgHom.comp_toLinearMap /-\n@[simp]\ntheorem comp_toLinearMap (f : A →ₐ[R] B) (g : B →ₐ[R] C) :\n    (g.comp f).toLinearMap = g.toLinearMap.comp f.toLinearMap :=\n  rfl\n#align alg_hom.comp_to_linear_map AlgHom.comp_toLinearMap\n-/\n\n#print AlgHom.toLinearMap_id /-\n@[simp]\ntheorem toLinearMap_id : toLinearMap (AlgHom.id R A) = LinearMap.id :=\n  LinearMap.ext fun _ => rfl\n#align alg_hom.to_linear_map_id AlgHom.toLinearMap_id\n-/\n\n/- warning: alg_hom.of_linear_map -> AlgHom.ofLinearMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)), (Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (OfNat.ofNat.{u2} A 1 (OfNat.mk.{u2} A 1 (One.one.{u2} A (AddMonoidWithOne.toOne.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))) (OfNat.ofNat.{u3} B 1 (OfNat.mk.{u3} B 1 (One.one.{u3} B (AddMonoidWithOne.toOne.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))) -> (forall (x : A) (y : A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (Distrib.toHasMul.{u2} A (NonUnitalNonAssocSemiring.toDistrib.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) x y)) (HMul.hMul.{u3, u3, u3} B B B (instHMul.{u3} B (Distrib.toHasMul.{u3} B (NonUnitalNonAssocSemiring.toDistrib.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f y))) -> (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)), (Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (OfNat.ofNat.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) 1 (One.toOfNat1.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (Semiring.toOne.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) _inst_3)))) -> (forall (x : A) (y : A), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (HMul.hMul.{u3, u3, u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (instHMul.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (NonUnitalNonAssocSemiring.toMul.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (Semiring.toNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) _inst_3)))) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f x) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f y))) -> (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7)\nCase conversion may be inaccurate. Consider using '#align alg_hom.of_linear_map AlgHom.ofLinearMapₓ'. -/\n/-- Promote a `linear_map` to an `alg_hom` by supplying proofs about the behavior on `1` and `*`. -/\n@[simps]\ndef ofLinearMap (f : A →ₗ[R] B) (map_one : f 1 = 1) (map_mul : ∀ x y, f (x * y) = f x * f y) :\n    A →ₐ[R] B :=\n  { f.toAddMonoidHom with\n    toFun := f\n    map_one' := map_one\n    map_mul' := map_mul\n    commutes' := fun c => by simp only [Algebra.algebraMap_eq_smul_one, f.map_smul, map_one] }\n#align alg_hom.of_linear_map AlgHom.ofLinearMap\n\n/- warning: alg_hom.of_linear_map_to_linear_map -> AlgHom.ofLinearMap_toLinearMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (map_one : Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) (OfNat.ofNat.{u2} A 1 (OfNat.mk.{u2} A 1 (One.one.{u2} A (AddMonoidWithOne.toOne.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))) (OfNat.ofNat.{u3} B 1 (OfNat.mk.{u3} B 1 (One.one.{u3} B (AddMonoidWithOne.toOne.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))) (map_mul : forall (x : A) (y : A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (Distrib.toHasMul.{u2} A (NonUnitalNonAssocSemiring.toDistrib.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) x y)) (HMul.hMul.{u3, u3, u3} B B B (instHMul.{u3} B (Distrib.toHasMul.{u3} B (NonUnitalNonAssocSemiring.toDistrib.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) y))), Eq.{max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.ofLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) map_one map_mul) φ\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (map_one : Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (OfNat.ofNat.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) 1 (One.toOfNat1.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (Semiring.toOne.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) _inst_3)))) (map_mul : forall (x : A) (y : A), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (HMul.hMul.{u3, u3, u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (instHMul.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (NonUnitalNonAssocSemiring.toMul.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (Semiring.toNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) _inst_3)))) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) x) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) y))), Eq.{max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.ofLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 φ) map_one map_mul) φ\nCase conversion may be inaccurate. Consider using '#align alg_hom.of_linear_map_to_linear_map AlgHom.ofLinearMap_toLinearMapₓ'. -/\n@[simp]\ntheorem ofLinearMap_toLinearMap (map_one) (map_mul) :\n    ofLinearMap φ.toLinearMap map_one map_mul = φ :=\n  by\n  ext\n  rfl\n#align alg_hom.of_linear_map_to_linear_map AlgHom.ofLinearMap_toLinearMap\n\n/- warning: alg_hom.to_linear_map_of_linear_map -> AlgHom.toLinearMap_ofLinearMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (map_one : Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (OfNat.ofNat.{u2} A 1 (OfNat.mk.{u2} A 1 (One.one.{u2} A (AddMonoidWithOne.toOne.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))) (OfNat.ofNat.{u3} B 1 (OfNat.mk.{u3} B 1 (One.one.{u3} B (AddMonoidWithOne.toOne.{u3} B (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} B (NonAssocSemiring.toAddCommMonoidWithOne.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))) (map_mul : forall (x : A) (y : A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (Distrib.toHasMul.{u2} A (NonUnitalNonAssocSemiring.toDistrib.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) x y)) (HMul.hMul.{u3, u3, u3} B B B (instHMul.{u3} B (Distrib.toHasMul.{u3} B (NonUnitalNonAssocSemiring.toDistrib.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) => A -> B) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f y))), Eq.{max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.ofLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f map_one map_mul)) f\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (map_one : Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (OfNat.ofNat.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) 1 (One.toOfNat1.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (Semiring.toOne.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) _inst_3)))) (map_mul : forall (x : A) (y : A), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (HMul.hMul.{u3, u3, u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (instHMul.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (NonUnitalNonAssocSemiring.toMul.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) (Semiring.toNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) x) _inst_3)))) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f x) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => B) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u3} R R A B (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f y))), Eq.{max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (AlgHom.toLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.ofLinearMap.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 f map_one map_mul)) f\nCase conversion may be inaccurate. Consider using '#align alg_hom.to_linear_map_of_linear_map AlgHom.toLinearMap_ofLinearMapₓ'. -/\n@[simp]\ntheorem toLinearMap_ofLinearMap (f : A →ₗ[R] B) (map_one) (map_mul) :\n    toLinearMap (ofLinearMap f map_one map_mul) = f :=\n  by\n  ext\n  rfl\n#align alg_hom.to_linear_map_of_linear_map AlgHom.toLinearMap_ofLinearMap\n\n/- warning: alg_hom.of_linear_map_id -> AlgHom.ofLinearMap_id is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] (map_one : Eq.{succ u2} A (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) => A -> A) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (OfNat.ofNat.{u2} A 1 (OfNat.mk.{u2} A 1 (One.one.{u2} A (AddMonoidWithOne.toOne.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))) (OfNat.ofNat.{u2} A 1 (OfNat.mk.{u2} A 1 (One.one.{u2} A (AddMonoidWithOne.toOne.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))) (map_mul : forall (x : A) (y : A), Eq.{succ u2} A (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) => A -> A) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (Distrib.toHasMul.{u2} A (NonUnitalNonAssocSemiring.toDistrib.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) x y)) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (Distrib.toHasMul.{u2} A (NonUnitalNonAssocSemiring.toDistrib.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) => A -> A) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) x) (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) => A -> A) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) y))), Eq.{succ u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) (AlgHom.ofLinearMap.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6 (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) map_one map_mul) (AlgHom.id.{u1, u2} R A _inst_1 _inst_2 _inst_6)\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] (map_one : Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (FunLike.coe.{succ u2, succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) (Semiring.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) (OfNat.ofNat.{u2} A 1 (One.toOfNat1.{u2} A (Semiring.toOne.{u2} A _inst_2)))) _inst_2)))) (map_mul : forall (x : A) (y : A), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (FunLike.coe.{succ u2, succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (HMul.hMul.{u2, u2, u2} A A A (instHMul.{u2} A (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) x y)) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) x) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) x) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) x) (NonUnitalNonAssocSemiring.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) x) _inst_2)))) (FunLike.coe.{succ u2, succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) x) (FunLike.coe.{succ u2, succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) A A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => A) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R A A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) y))), Eq.{succ u2} (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6) (AlgHom.ofLinearMap.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_6 _inst_6 (LinearMap.id.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) map_one map_mul) (AlgHom.id.{u1, u2} R A _inst_1 _inst_2 _inst_6)\nCase conversion may be inaccurate. Consider using '#align alg_hom.of_linear_map_id AlgHom.ofLinearMap_idₓ'. -/\n@[simp]\ntheorem ofLinearMap_id (map_one) (map_mul) :\n    ofLinearMap LinearMap.id map_one map_mul = AlgHom.id R A :=\n  ext fun _ => rfl\n#align alg_hom.of_linear_map_id AlgHom.ofLinearMap_id\n\n/- warning: alg_hom.map_smul_of_tower -> AlgHom.map_smul_of_tower is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {R' : Type.{u4}} [_inst_10 : SMul.{u4, u2} R' A] [_inst_11 : SMul.{u4, u3} R' B] [_inst_12 : LinearMap.CompatibleSMul.{u2, u3, u4, u1} A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) R' R (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) _inst_11 (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)] (r : R') (x : A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) φ (SMul.smul.{u4, u2} R' A _inst_10 r x)) (SMul.smul.{u4, u3} R' B _inst_11 r (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) φ x))\nbut is expected to have type\n  forall {R : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Semiring.{u4} B] [_inst_6 : Algebra.{u2, u3} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u2, u4} R B _inst_1 _inst_3] (φ : AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {R' : Type.{u1}} [_inst_10 : SMul.{u1, u3} R' A] [_inst_11 : SMul.{u1, u4} R' B] [_inst_12 : LinearMap.CompatibleSMul.{u3, u4, u1, u2} A B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) R' R (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6) _inst_11 (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7)] (r : R') (x : A), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (HSMul.hSMul.{u1, u3, u3} R' A A (instHSMul.{u1, u3} R' A _inst_10) r x)) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u3 u4} R A B (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, max u3 u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ (HSMul.hSMul.{u1, u3, u3} R' A A (instHSMul.{u1, u3} R' A _inst_10) r x)) (HSMul.hSMul.{u1, u4, u4} R' ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) x) ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) x) (instHSMul.{u1, u4} R' ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) x) _inst_11) r (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3)))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u3 u4} R A B (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u2, u4} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, max u3 u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) φ x))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_smul_of_tower AlgHom.map_smul_of_towerₓ'. -/\ntheorem map_smul_of_tower {R'} [SMul R' A] [SMul R' B] [LinearMap.CompatibleSMul A B R' R] (r : R')\n    (x : A) : φ (r • x) = r • φ x :=\n  φ.toLinearMap.map_smul_of_tower r x\n#align alg_hom.map_smul_of_tower AlgHom.map_smul_of_tower\n\n#print AlgHom.map_list_prod /-\ntheorem map_list_prod (s : List A) : φ s.Prod = (s.map φ).Prod :=\n  φ.toRingHom.map_list_prod s\n#align alg_hom.map_list_prod AlgHom.map_list_prod\n-/\n\n#print AlgHom.End /-\n@[simps (config := { attrs := [] }) mul one]\ninstance End : Monoid (A →ₐ[R] A) where\n  mul := comp\n  mul_assoc ϕ ψ χ := rfl\n  one := AlgHom.id R A\n  one_mul ϕ := ext fun x => rfl\n  mul_one ϕ := ext fun x => rfl\n#align alg_hom.End AlgHom.End\n-/\n\n#print AlgHom.one_apply /-\n@[simp]\ntheorem one_apply (x : A) : (1 : A →ₐ[R] A) x = x :=\n  rfl\n#align alg_hom.one_apply AlgHom.one_apply\n-/\n\n#print AlgHom.mul_apply /-\n@[simp]\ntheorem mul_apply (φ ψ : A →ₐ[R] A) (x : A) : (φ * ψ) x = φ (ψ x) :=\n  rfl\n#align alg_hom.mul_apply AlgHom.mul_apply\n-/\n\n/- warning: alg_hom.algebra_map_eq_apply -> AlgHom.algebraMap_eq_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {y : R} {x : A}, (Eq.{succ u2} A (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_6) y) x) -> (Eq.{succ u3} B (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => R -> B) (RingHom.hasCoeToFun.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (algebraMap.{u1, u3} R B _inst_1 _inst_3 _inst_7) y) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) f x))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_6 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_7 : Algebra.{u1, u3} R B _inst_1 _inst_3] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {y : R} {x : A}, (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) y) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (RingHom.instRingHomClassRingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_6) y) x) -> (Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => B) y) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => B) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R B (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3) (RingHom.instRingHomClassRingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (algebraMap.{u1, u3} R B _inst_1 _inst_3 _inst_7) y) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6)) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u2 u3} R A B (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_6) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_7) (AlgHomClass.linearMapClass.{u1, u2, u3, max u2 u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7 (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) (AlgHom.algHomClass.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7))))) f x))\nCase conversion may be inaccurate. Consider using '#align alg_hom.algebra_map_eq_apply AlgHom.algebraMap_eq_applyₓ'. -/\ntheorem algebraMap_eq_apply (f : A →ₐ[R] B) {y : R} {x : A} (h : algebraMap R A y = x) :\n    algebraMap R B y = f x :=\n  h ▸ (f.commutes _).symm\n#align alg_hom.algebra_map_eq_apply AlgHom.algebraMap_eq_apply\n\nend Semiring\n\nsection CommSemiring\n\nvariable [CommSemiring R] [CommSemiring A] [CommSemiring B]\n\nvariable [Algebra R A] [Algebra R B] (φ : A →ₐ[R] B)\n\n#print AlgHom.map_multiset_prod /-\nprotected theorem map_multiset_prod (s : Multiset A) : φ s.Prod = (s.map φ).Prod :=\n  map_multiset_prod _ _\n#align alg_hom.map_multiset_prod AlgHom.map_multiset_prod\n-/\n\n/- warning: alg_hom.map_prod -> AlgHom.map_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : CommSemiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3)] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) {ι : Type.{u4}} (f : ι -> A) (s : Finset.{u4} ι), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) φ (Finset.prod.{u2, u4} A ι (CommSemiring.toCommMonoid.{u2} A _inst_2) s (fun (x : ι) => f x))) (Finset.prod.{u3, u4} B ι (CommSemiring.toCommMonoid.{u3} B _inst_3) s (fun (x : ι) => coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) φ (f x)))\nbut is expected to have type\n  forall {R : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : CommSemiring.{u3} A] [_inst_3 : CommSemiring.{u4} B] [_inst_4 : Algebra.{u2, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2)] [_inst_5 : Algebra.{u2, u4} R B _inst_1 (CommSemiring.toSemiring.{u4} B _inst_3)] (φ : AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) {ι : Type.{u1}} (f : ι -> A) (s : Finset.{u1} ι), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finset.prod.{u3, u1} A ι (CommSemiring.toCommMonoid.{u3} A _inst_2) s (fun (x : ι) => f x))) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (Algebra.toModule.{u2, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3))))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))) (Algebra.toModule.{u2, u4} R B _inst_1 (CommSemiring.toSemiring.{u4} B _inst_3) _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3))))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (Algebra.toModule.{u2, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))) (Algebra.toModule.{u2, u4} R B _inst_1 (CommSemiring.toSemiring.{u4} B _inst_3) _inst_5)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u3 u4} R A B (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))) (Algebra.toModule.{u2, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4) (Algebra.toModule.{u2, u4} R B _inst_1 (CommSemiring.toSemiring.{u4} B _inst_3) _inst_5) (AlgHomClass.linearMapClass.{u2, u3, u4, max u3 u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5 (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) (AlgHom.algHomClass.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5))))) φ (Finset.prod.{u3, u1} A ι (CommSemiring.toCommMonoid.{u3} A _inst_2) s (fun (x : ι) => f x))) (Finset.prod.{u4, u1} B ι (CommSemiring.toCommMonoid.{u4} B _inst_3) s (fun (x : ι) => FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) R A B (SMulZeroClass.toSMul.{u2, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u2, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u2, u3} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (Algebra.toModule.{u2, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4))))) (SMulZeroClass.toSMul.{u2, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u2, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u2, u4} R B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3))))) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))) (Algebra.toModule.{u2, u4} R B _inst_1 (CommSemiring.toSemiring.{u4} B _inst_3) _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) R A B (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3))))) (Module.toDistribMulAction.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (Algebra.toModule.{u2, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4)) (Module.toDistribMulAction.{u2, u4} R B (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))) (Algebra.toModule.{u2, u4} R B _inst_1 (CommSemiring.toSemiring.{u4} B _inst_3) _inst_5)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u3 u4} R A B (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B (CommSemiring.toSemiring.{u4} B _inst_3)))) (Algebra.toModule.{u2, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4) (Algebra.toModule.{u2, u4} R B _inst_1 (CommSemiring.toSemiring.{u4} B _inst_3) _inst_5) (AlgHomClass.linearMapClass.{u2, u3, u4, max u3 u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5 (AlgHom.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5) (AlgHom.algHomClass.{u2, u3, u4} R A B _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) (CommSemiring.toSemiring.{u4} B _inst_3) _inst_4 _inst_5))))) φ (f x)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_prod AlgHom.map_prodₓ'. -/\nprotected theorem map_prod {ι : Type _} (f : ι → A) (s : Finset ι) :\n    φ (∏ x in s, f x) = ∏ x in s, φ (f x) :=\n  map_prod _ _ _\n#align alg_hom.map_prod AlgHom.map_prod\n\n/- warning: alg_hom.map_finsupp_prod -> AlgHom.map_finsupp_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : CommSemiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3)] (φ : AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) {α : Type.{u4}} [_inst_6 : Zero.{u4} α] {ι : Type.{u5}} (f : Finsupp.{u5, u4} ι α _inst_6) (g : ι -> α -> A), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) φ (Finsupp.prod.{u5, u4, u2} ι α A _inst_6 (CommSemiring.toCommMonoid.{u2} A _inst_2) f g)) (Finsupp.prod.{u5, u4, u3} ι α B _inst_6 (CommSemiring.toCommMonoid.{u3} B _inst_3) f (fun (i : ι) (a : α) => coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) (CommSemiring.toSemiring.{u3} B _inst_3) _inst_4 _inst_5) φ (g i a)))\nbut is expected to have type\n  forall {R : Type.{u3}} {A : Type.{u4}} {B : Type.{u5}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u4} A] [_inst_3 : CommSemiring.{u5} B] [_inst_4 : Algebra.{u3, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2)] [_inst_5 : Algebra.{u3, u5} R B _inst_1 (CommSemiring.toSemiring.{u5} B _inst_3)] (φ : AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) {α : Type.{u2}} [_inst_6 : Zero.{u2} α] {ι : Type.{u1}} (f : Finsupp.{u1, u2} ι α _inst_6) (g : ι -> α -> A), Eq.{succ u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finsupp.prod.{u1, u2, u4} ι α A _inst_6 (CommSemiring.toCommMonoid.{u4} A _inst_2) f g)) (FunLike.coe.{max (succ u4) (succ u5), succ u4, succ u5} (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) R A B (SMulZeroClass.toSMul.{u3, u4} R A (AddMonoid.toZero.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u3, u4} R A (AddMonoid.toAddZeroClass.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u3, u4} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (Algebra.toModule.{u3, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4))))) (SMulZeroClass.toSMul.{u3, u5} R B (AddMonoid.toZero.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u3, u5} R B (AddMonoid.toAddZeroClass.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u3, u5} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3))))) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))) (Algebra.toModule.{u3, u5} R B _inst_1 (CommSemiring.toSemiring.{u5} B _inst_3) _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) R A B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3))))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (Algebra.toModule.{u3, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4)) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))) (Algebra.toModule.{u3, u5} R B _inst_1 (CommSemiring.toSemiring.{u5} B _inst_3) _inst_5)) (SemilinearMapClass.distribMulActionHomClass.{u3, u4, u5, max u4 u5} R A B (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))) (Algebra.toModule.{u3, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4) (Algebra.toModule.{u3, u5} R B _inst_1 (CommSemiring.toSemiring.{u5} B _inst_3) _inst_5) (AlgHomClass.linearMapClass.{u3, u4, u5, max u4 u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5 (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) (AlgHom.algHomClass.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5))))) φ (Finsupp.prod.{u1, u2, u4} ι α A _inst_6 (CommSemiring.toCommMonoid.{u4} A _inst_2) f g)) (Finsupp.prod.{u1, u2, u5} ι α B _inst_6 (CommSemiring.toCommMonoid.{u5} B _inst_3) f (fun (i : ι) (a : α) => FunLike.coe.{max (succ u4) (succ u5), succ u4, succ u5} (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) R A B (SMulZeroClass.toSMul.{u3, u4} R A (AddMonoid.toZero.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u3, u4} R A (AddMonoid.toAddZeroClass.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u3, u4} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (Algebra.toModule.{u3, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4))))) (SMulZeroClass.toSMul.{u3, u5} R B (AddMonoid.toZero.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u3, u5} R B (AddMonoid.toAddZeroClass.{u5} B (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u3, u5} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3))))) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))) (Algebra.toModule.{u3, u5} R B _inst_1 (CommSemiring.toSemiring.{u5} B _inst_3) _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u5, u3, u4, u5} (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) R A B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))))) (AddCommMonoid.toAddMonoid.{u5} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3))))) (Module.toDistribMulAction.{u3, u4} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (Algebra.toModule.{u3, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4)) (Module.toDistribMulAction.{u3, u5} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))) (Algebra.toModule.{u3, u5} R B _inst_1 (CommSemiring.toSemiring.{u5} B _inst_3) _inst_5)) (SemilinearMapClass.distribMulActionHomClass.{u3, u4, u5, max u4 u5} R A B (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B (CommSemiring.toSemiring.{u5} B _inst_3)))) (Algebra.toModule.{u3, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4) (Algebra.toModule.{u3, u5} R B _inst_1 (CommSemiring.toSemiring.{u5} B _inst_3) _inst_5) (AlgHomClass.linearMapClass.{u3, u4, u5, max u4 u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5 (AlgHom.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5) (AlgHom.algHomClass.{u3, u4, u5} R A B _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) (CommSemiring.toSemiring.{u5} B _inst_3) _inst_4 _inst_5))))) φ (g i a)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_finsupp_prod AlgHom.map_finsupp_prodₓ'. -/\nprotected theorem map_finsupp_prod {α : Type _} [Zero α] {ι : Type _} (f : ι →₀ α) (g : ι → α → A) :\n    φ (f.Prod g) = f.Prod fun i a => φ (g i a) :=\n  map_finsupp_prod _ _ _\n#align alg_hom.map_finsupp_prod AlgHom.map_finsupp_prod\n\nend CommSemiring\n\nsection Ring\n\nvariable [CommSemiring R] [Ring A] [Ring B]\n\nvariable [Algebra R A] [Algebra R B] (φ : A →ₐ[R] B)\n\n#print AlgHom.map_neg /-\nprotected theorem map_neg (x) : φ (-x) = -φ x :=\n  map_neg _ _\n#align alg_hom.map_neg AlgHom.map_neg\n-/\n\n#print AlgHom.map_sub /-\nprotected theorem map_sub (x y) : φ (x - y) = φ x - φ y :=\n  map_sub _ _ _\n#align alg_hom.map_sub AlgHom.map_sub\n-/\n\nend Ring\n\nend AlgHom\n\nnamespace RingHom\n\nvariable {R S : Type _}\n\n#print RingHom.toNatAlgHom /-\n/-- Reinterpret a `ring_hom` as an `ℕ`-algebra homomorphism. -/\ndef toNatAlgHom [Semiring R] [Semiring S] (f : R →+* S) : R →ₐ[ℕ] S :=\n  { f with\n    toFun := f\n    commutes' := fun n => by simp }\n#align ring_hom.to_nat_alg_hom RingHom.toNatAlgHom\n-/\n\n/- warning: ring_hom.to_int_alg_hom -> RingHom.toIntAlgHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : Ring.{u2} S] [_inst_3 : Algebra.{0, u1} Int R Int.commSemiring (Ring.toSemiring.{u1} R _inst_1)] [_inst_4 : Algebra.{0, u2} Int S Int.commSemiring (Ring.toSemiring.{u2} S _inst_2)], (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) -> (AlgHom.{0, u1, u2} Int R S Int.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : Ring.{u2} S] [_inst_3 : Algebra.{0, u1} Int R Int.instCommSemiringInt (Ring.toSemiring.{u1} R _inst_1)] [_inst_4 : Algebra.{0, u2} Int S Int.instCommSemiringInt (Ring.toSemiring.{u2} S _inst_2)], (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (Ring.toSemiring.{u2} S _inst_2))) -> (AlgHom.{0, u1, u2} Int R S Int.instCommSemiringInt (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_int_alg_hom RingHom.toIntAlgHomₓ'. -/\n/-- Reinterpret a `ring_hom` as a `ℤ`-algebra homomorphism. -/\ndef toIntAlgHom [Ring R] [Ring S] [Algebra ℤ R] [Algebra ℤ S] (f : R →+* S) : R →ₐ[ℤ] S :=\n  { f with commutes' := fun n => by simp }\n#align ring_hom.to_int_alg_hom RingHom.toIntAlgHom\n\n#print RingHom.toRatAlgHom /-\n/-- Reinterpret a `ring_hom` as a `ℚ`-algebra homomorphism. This actually yields an equivalence,\nsee `ring_hom.equiv_rat_alg_hom`. -/\ndef toRatAlgHom [Ring R] [Ring S] [Algebra ℚ R] [Algebra ℚ S] (f : R →+* S) : R →ₐ[ℚ] S :=\n  { f with commutes' := f.map_rat_algebraMap }\n#align ring_hom.to_rat_alg_hom RingHom.toRatAlgHom\n-/\n\n/- warning: ring_hom.to_rat_alg_hom_to_ring_hom -> RingHom.toRatAlgHom_toRingHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : Ring.{u2} S] [_inst_3 : Algebra.{0, u1} Rat R Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1)] [_inst_4 : Algebra.{0, u2} Rat S Rat.commSemiring (Ring.toSemiring.{u2} S _inst_2)] (f : RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) (RingHom.hasCoeT.{max u1 u2, u1, u2} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2)) (AlgHomClass.toRingHomClass.{max u1 u2, 0, u1, u2} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4 (AlgHom.algHomClass.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4))))) (RingHom.toRatAlgHom.{u1, u2} R S _inst_1 _inst_2 _inst_3 _inst_4 f)) f\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : Ring.{u1} S] [_inst_3 : Algebra.{0, u2} Rat R Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1)] [_inst_4 : Algebra.{0, u1} Rat S Rat.commSemiring (Ring.toSemiring.{u1} S _inst_2)] (f : RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S (Ring.toSemiring.{u1} S _inst_2))), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} R S (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S (Ring.toSemiring.{u1} S _inst_2))) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (AlgHom.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4) R S (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S (Ring.toSemiring.{u1} S _inst_2)) (AlgHomClass.toRingHomClass.{max u2 u1, 0, u2, u1} (AlgHom.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4) Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4 (AlgHom.algHomClass.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4)) (RingHom.toRatAlgHom.{u2, u1} R S _inst_1 _inst_2 _inst_3 _inst_4 f)) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_rat_alg_hom_to_ring_hom RingHom.toRatAlgHom_toRingHomₓ'. -/\n@[simp]\ntheorem toRatAlgHom_toRingHom [Ring R] [Ring S] [Algebra ℚ R] [Algebra ℚ S] (f : R →+* S) :\n    ↑f.toRatAlgHom = f :=\n  RingHom.ext fun x => rfl\n#align ring_hom.to_rat_alg_hom_to_ring_hom RingHom.toRatAlgHom_toRingHom\n\nend RingHom\n\nsection\n\nvariable {R S : Type _}\n\n/- warning: alg_hom.to_ring_hom_to_rat_alg_hom -> AlgHom.toRingHom_toRatAlgHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : Ring.{u2} S] [_inst_3 : Algebra.{0, u1} Rat R Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1)] [_inst_4 : Algebra.{0, u2} Rat S Rat.commSemiring (Ring.toSemiring.{u2} S _inst_2)] (f : AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) (RingHom.toRatAlgHom.{u1, u2} R S _inst_1 _inst_2 _inst_3 _inst_4 ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) (RingHom.{u1, u2} R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2))) (RingHom.hasCoeT.{max u1 u2, u1, u2} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) R S (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{u2} S (Ring.toNonAssocRing.{u2} S _inst_2)) (AlgHomClass.toRingHomClass.{max u1 u2, 0, u1, u2} (AlgHom.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4) Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4 (AlgHom.algHomClass.{0, u1, u2} Rat R S Rat.commSemiring (Ring.toSemiring.{u1} R _inst_1) (Ring.toSemiring.{u2} S _inst_2) _inst_3 _inst_4))))) f)) f\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : Ring.{u1} S] [_inst_3 : Algebra.{0, u2} Rat R Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1)] [_inst_4 : Algebra.{0, u1} Rat S Rat.commSemiring (Ring.toSemiring.{u1} S _inst_2)] (f : AlgHom.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (AlgHom.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4) (RingHom.toRatAlgHom.{u2, u1} R S _inst_1 _inst_2 _inst_3 _inst_4 (RingHomClass.toRingHom.{max u2 u1, u2, u1} (AlgHom.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4) R S (Semiring.toNonAssocSemiring.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} S (Ring.toSemiring.{u1} S _inst_2)) (AlgHomClass.toRingHomClass.{max u2 u1, 0, u2, u1} (AlgHom.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4) Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4 (AlgHom.algHomClass.{0, u2, u1} Rat R S Rat.commSemiring (Ring.toSemiring.{u2} R _inst_1) (Ring.toSemiring.{u1} S _inst_2) _inst_3 _inst_4)) f)) f\nCase conversion may be inaccurate. Consider using '#align alg_hom.to_ring_hom_to_rat_alg_hom AlgHom.toRingHom_toRatAlgHomₓ'. -/\n@[simp]\ntheorem AlgHom.toRingHom_toRatAlgHom [Ring R] [Ring S] [Algebra ℚ R] [Algebra ℚ S] (f : R →ₐ[ℚ] S) :\n    (f : R →+* S).toRatAlgHom = f :=\n  AlgHom.ext fun x => rfl\n#align alg_hom.to_ring_hom_to_rat_alg_hom AlgHom.toRingHom_toRatAlgHom\n\n#print RingHom.equivRatAlgHom /-\n/-- The equivalence between `ring_hom` and `ℚ`-algebra homomorphisms. -/\n@[simps]\ndef RingHom.equivRatAlgHom [Ring R] [Ring S] [Algebra ℚ R] [Algebra ℚ S] : (R →+* S) ≃ (R →ₐ[ℚ] S)\n    where\n  toFun := RingHom.toRatAlgHom\n  invFun := AlgHom.toRingHom\n  left_inv := RingHom.toRatAlgHom_toRingHom\n  right_inv := AlgHom.toRingHom_toRatAlgHom\n#align ring_hom.equiv_rat_alg_hom RingHom.equivRatAlgHom\n-/\n\nend\n\nnamespace Algebra\n\nvariable (R : Type u) (A : Type v)\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\n#print Algebra.ofId /-\n/-- `algebra_map` as an `alg_hom`. -/\ndef ofId : R →ₐ[R] A :=\n  { algebraMap R A with commutes' := fun _ => rfl }\n#align algebra.of_id Algebra.ofId\n-/\n\nvariable {R}\n\n#print Algebra.ofId_apply /-\ntheorem ofId_apply (r) : ofId R A r = algebraMap R A r :=\n  rfl\n#align algebra.of_id_apply Algebra.ofId_apply\n-/\n\nend Algebra\n\nnamespace MulSemiringAction\n\nvariable {M G : Type _} (R A : Type _) [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [Monoid M] [MulSemiringAction M A] [SMulCommClass M R A]\n\n/- warning: mul_semiring_action.to_alg_hom -> MulSemiringAction.toAlgHom is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} (R : Type.{u2}) (A : Type.{u3}) [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u2, u3} R A _inst_1 _inst_2] [_inst_4 : Monoid.{u1} M] [_inst_5 : MulSemiringAction.{u1, u3} M A _inst_4 _inst_2] [_inst_6 : SMulCommClass.{u1, u2, u3} M R A (SMulZeroClass.toHasSmul.{u1, u3} M A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (DistribSMul.toSmulZeroClass.{u1, u3} M A (AddMonoid.toAddZeroClass.{u3} A (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u3} M A _inst_4 (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (MulSemiringAction.toDistribMulAction.{u1, u3} M A _inst_4 _inst_2 _inst_5)))) (SMulZeroClass.toHasSmul.{u2, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} R A (MulZeroClass.toHasZero.{u2} R (MulZeroOneClass.toMulZeroClass.{u2} R (MonoidWithZero.toMulZeroOneClass.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} R A (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (Module.toMulActionWithZero.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_3)))))], M -> (AlgHom.{u2, u3, u3} R A A _inst_1 _inst_2 _inst_2 _inst_3 _inst_3)\nbut is expected to have type\n  forall {M : Type.{u1}} (R : Type.{u2}) (A : Type.{u3}) [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u2, u3} R A _inst_1 _inst_2] [_inst_4 : Monoid.{u1} M] [_inst_5 : MulSemiringAction.{u1, u3} M A _inst_4 _inst_2] [_inst_6 : SMulCommClass.{u1, u2, u3} M R A (SMulZeroClass.toSMul.{u1, u3} M A (MonoidWithZero.toZero.{u3} A (Semiring.toMonoidWithZero.{u3} A _inst_2)) (DistribSMul.toSMulZeroClass.{u1, u3} M A (AddMonoid.toAddZeroClass.{u3} A (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u3} M A _inst_4 (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (MulSemiringAction.toDistribMulAction.{u1, u3} M A _inst_4 _inst_2 _inst_5)))) (Algebra.toSMul.{u2, u3} R A _inst_1 _inst_2 _inst_3)], M -> (AlgHom.{u2, u3, u3} R A A _inst_1 _inst_2 _inst_2 _inst_3 _inst_3)\nCase conversion may be inaccurate. Consider using '#align mul_semiring_action.to_alg_hom MulSemiringAction.toAlgHomₓ'. -/\n/-- Each element of the monoid defines a algebra homomorphism.\n\nThis is a stronger version of `mul_semiring_action.to_ring_hom` and\n`distrib_mul_action.to_linear_map`. -/\n@[simps]\ndef toAlgHom (m : M) : A →ₐ[R] A :=\n  {\n    MulSemiringAction.toRingHom _ _\n      m with\n    toFun := fun a => m • a\n    commutes' := smul_algebraMap _ }\n#align mul_semiring_action.to_alg_hom MulSemiringAction.toAlgHom\n\n/- warning: mul_semiring_action.to_alg_hom_injective -> MulSemiringAction.toAlgHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} (R : Type.{u2}) (A : Type.{u3}) [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u2, u3} R A _inst_1 _inst_2] [_inst_4 : Monoid.{u1} M] [_inst_5 : MulSemiringAction.{u1, u3} M A _inst_4 _inst_2] [_inst_6 : SMulCommClass.{u1, u2, u3} M R A (SMulZeroClass.toHasSmul.{u1, u3} M A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (DistribSMul.toSmulZeroClass.{u1, u3} M A (AddMonoid.toAddZeroClass.{u3} A (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u3} M A _inst_4 (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (MulSemiringAction.toDistribMulAction.{u1, u3} M A _inst_4 _inst_2 _inst_5)))) (SMulZeroClass.toHasSmul.{u2, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} R A (MulZeroClass.toHasZero.{u2} R (MulZeroOneClass.toMulZeroClass.{u2} R (MonoidWithZero.toMulZeroOneClass.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} R A (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (Module.toMulActionWithZero.{u2, u3} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u2, u3} R A _inst_1 _inst_2 _inst_3)))))] [_inst_7 : FaithfulSMul.{u1, u3} M A (SMulZeroClass.toHasSmul.{u1, u3} M A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))))) (DistribSMul.toSmulZeroClass.{u1, u3} M A (AddMonoid.toAddZeroClass.{u3} A (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u3} M A _inst_4 (AddMonoidWithOne.toAddMonoid.{u3} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} A (NonAssocSemiring.toAddCommMonoidWithOne.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (MulSemiringAction.toDistribMulAction.{u1, u3} M A _inst_4 _inst_2 _inst_5))))], Function.Injective.{succ u1, succ u3} M (AlgHom.{u2, u3, u3} R A A _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) (MulSemiringAction.toAlgHom.{u1, u2, u3} M R A _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)\nbut is expected to have type\n  forall {M : Type.{u3}} (R : Type.{u1}) (A : Type.{u2}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Monoid.{u3} M] [_inst_5 : MulSemiringAction.{u3, u2} M A _inst_4 _inst_2] [_inst_6 : SMulCommClass.{u3, u1, u2} M R A (SMulZeroClass.toSMul.{u3, u2} M A (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (DistribSMul.toSMulZeroClass.{u3, u2} M A (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u3, u2} M A _inst_4 (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulSemiringAction.toDistribMulAction.{u3, u2} M A _inst_4 _inst_2 _inst_5)))) (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3)] [_inst_7 : FaithfulSMul.{u3, u2} M A (SMulZeroClass.toSMul.{u3, u2} M A (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (DistribSMul.toSMulZeroClass.{u3, u2} M A (AddMonoid.toAddZeroClass.{u2} A (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u3, u2} M A _inst_4 (AddMonoidWithOne.toAddMonoid.{u2} A (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} A (NonAssocSemiring.toAddCommMonoidWithOne.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (MulSemiringAction.toDistribMulAction.{u3, u2} M A _inst_4 _inst_2 _inst_5))))], Function.Injective.{succ u3, succ u2} M (AlgHom.{u1, u2, u2} R A A _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) (MulSemiringAction.toAlgHom.{u3, u1, u2} M R A _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align mul_semiring_action.to_alg_hom_injective MulSemiringAction.toAlgHom_injectiveₓ'. -/\ntheorem toAlgHom_injective [FaithfulSMul M A] :\n    Function.Injective (MulSemiringAction.toAlgHom R A : M → A →ₐ[R] A) := fun m₁ m₂ h =>\n  eq_of_smul_eq_smul fun r => AlgHom.ext_iff.1 h r\n#align mul_semiring_action.to_alg_hom_injective MulSemiringAction.toAlgHom_injective\n\nend MulSemiringAction\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Algebra/Hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.47803564328259984}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module logic.equiv.transfer_instance\n! leanprover-community/mathlib commit ec1c7d810034d4202b0dd239112d1792be9f6fdc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Equiv\nimport Mathbin.Algebra.Field.Basic\nimport Mathbin.Logic.Equiv.Defs\n\n/-!\n# Transfer algebraic structures across `equiv`s\n\nIn this file we prove theorems of the following form: if `β` has a\ngroup structure and `α ≃ β` then `α` has a group structure, and\nsimilarly for monoids, semigroups, rings, integral domains, fields and\nso on.\n\nNote that most of these constructions can also be obtained using the `transport` tactic.\n\n### Implementation details\n\nWhen adding new definitions that transfer type-classes across an equivalence, please mark them\n`@[reducible]`. See note [reducible non-instances].\n\n## Tags\n\nequiv, group, ring, field, module, algebra\n-/\n\n\nuniverse u v\n\nvariable {α : Type u} {β : Type v}\n\nnamespace Equiv\n\nsection Instances\n\nvariable (e : α ≃ β)\n\n/-- Transfer `has_one` across an `equiv` -/\n@[reducible, to_additive \"Transfer `has_zero` across an `equiv`\"]\nprotected def hasOne [One β] : One α :=\n  ⟨e.symm 1⟩\n#align equiv.has_one Equiv.hasOne\n#align equiv.has_zero Equiv.hasZero\n\n@[to_additive]\ntheorem one_def [One β] : @One.one _ (Equiv.hasOne e) = e.symm 1 :=\n  rfl\n#align equiv.one_def Equiv.one_def\n#align equiv.zero_def Equiv.zero_def\n\n/-- Transfer `has_mul` across an `equiv` -/\n@[reducible, to_additive \"Transfer `has_add` across an `equiv`\"]\nprotected def hasMul [Mul β] : Mul α :=\n  ⟨fun x y => e.symm (e x * e y)⟩\n#align equiv.has_mul Equiv.hasMul\n#align equiv.has_add Equiv.hasAdd\n\n@[to_additive]\ntheorem mul_def [Mul β] (x y : α) : @Mul.mul _ (Equiv.hasMul e) x y = e.symm (e x * e y) :=\n  rfl\n#align equiv.mul_def Equiv.mul_def\n#align equiv.add_def Equiv.add_def\n\n/-- Transfer `has_div` across an `equiv` -/\n@[reducible, to_additive \"Transfer `has_sub` across an `equiv`\"]\nprotected def hasDiv [Div β] : Div α :=\n  ⟨fun x y => e.symm (e x / e y)⟩\n#align equiv.has_div Equiv.hasDiv\n#align equiv.has_sub Equiv.hasSub\n\n@[to_additive]\ntheorem div_def [Div β] (x y : α) : @Div.div _ (Equiv.hasDiv e) x y = e.symm (e x / e y) :=\n  rfl\n#align equiv.div_def Equiv.div_def\n#align equiv.sub_def Equiv.sub_def\n\n/-- Transfer `has_inv` across an `equiv` -/\n@[reducible, to_additive \"Transfer `has_neg` across an `equiv`\"]\nprotected def hasInv [Inv β] : Inv α :=\n  ⟨fun x => e.symm (e x)⁻¹⟩\n#align equiv.has_inv Equiv.hasInv\n#align equiv.has_neg Equiv.hasNeg\n\n@[to_additive]\ntheorem inv_def [Inv β] (x : α) : @Inv.inv _ (Equiv.hasInv e) x = e.symm (e x)⁻¹ :=\n  rfl\n#align equiv.inv_def Equiv.inv_def\n#align equiv.neg_def Equiv.neg_def\n\n/-- Transfer `has_smul` across an `equiv` -/\n@[reducible]\nprotected def hasSmul (R : Type _) [SMul R β] : SMul R α :=\n  ⟨fun r x => e.symm (r • e x)⟩\n#align equiv.has_smul Equiv.hasSmul\n\ntheorem smul_def {R : Type _} [SMul R β] (r : R) (x : α) :\n    @SMul.smul _ _ (e.SMul R) r x = e.symm (r • e x) :=\n  rfl\n#align equiv.smul_def Equiv.smul_def\n\n/-- Transfer `has_pow` across an `equiv` -/\n@[reducible, to_additive SMul]\nprotected def hasPow (N : Type _) [Pow β N] : Pow α N :=\n  ⟨fun x n => e.symm (e x ^ n)⟩\n#align equiv.has_pow Equiv.hasPow\n#align equiv.has_smul Equiv.hasSmul\n\ntheorem pow_def {N : Type _} [Pow β N] (n : N) (x : α) :\n    @Pow.pow _ _ (e.Pow N) x n = e.symm (e x ^ n) :=\n  rfl\n#align equiv.pow_def Equiv.pow_def\n\n/-- An equivalence `e : α ≃ β` gives a multiplicative equivalence `α ≃* β`\nwhere the multiplicative structure on `α` is\nthe one obtained by transporting a multiplicative structure on `β` back along `e`.\n-/\n@[to_additive\n      \"An equivalence `e : α ≃ β` gives a additive equivalence `α ≃+ β`\\nwhere the additive structure on `α` is\\nthe one obtained by transporting an additive structure on `β` back along `e`.\"]\ndef mulEquiv (e : α ≃ β) [Mul β] :\n    letI := Equiv.hasMul e\n    α ≃* β :=\n  by\n  intros\n  exact\n    { e with\n      map_mul' := fun x y => by\n        apply e.symm.injective\n        simp }\n#align equiv.mul_equiv Equiv.mulEquiv\n#align equiv.add_equiv Equiv.addEquiv\n\n@[simp, to_additive]\ntheorem mulEquiv_apply (e : α ≃ β) [Mul β] (a : α) : (mulEquiv e) a = e a :=\n  rfl\n#align equiv.mul_equiv_apply Equiv.mulEquiv_apply\n#align equiv.add_equiv_apply Equiv.add_equiv_apply\n\n@[to_additive]\ntheorem mulEquiv_symm_apply (e : α ≃ β) [Mul β] (b : β) :\n    letI := Equiv.hasMul e\n    (MulEquiv e).symm b = e.symm b :=\n  by intros ; rfl\n#align equiv.mul_equiv_symm_apply Equiv.mulEquiv_symm_apply\n#align equiv.add_equiv_symm_apply Equiv.add_equiv_symm_apply\n\n/-- An equivalence `e : α ≃ β` gives a ring equivalence `α ≃+* β`\nwhere the ring structure on `α` is\nthe one obtained by transporting a ring structure on `β` back along `e`.\n-/\ndef ringEquiv (e : α ≃ β) [Add β] [Mul β] :\n    by\n    letI := Equiv.hasAdd e\n    letI := Equiv.hasMul e\n    exact α ≃+* β := by\n  intros\n  exact\n    {\n      e with\n      map_add' := fun x y => by\n        apply e.symm.injective\n        simp\n      map_mul' := fun x y => by\n        apply e.symm.injective\n        simp }\n#align equiv.ring_equiv Equiv.ringEquiv\n\n@[simp]\ntheorem ringEquiv_apply (e : α ≃ β) [Add β] [Mul β] (a : α) : (ringEquiv e) a = e a :=\n  rfl\n#align equiv.ring_equiv_apply Equiv.ringEquiv_apply\n\ntheorem ringEquiv_symm_apply (e : α ≃ β) [Add β] [Mul β] (b : β) :\n    by\n    letI := Equiv.hasAdd e\n    letI := Equiv.hasMul e\n    exact (RingEquiv e).symm b = e.symm b := by intros ; rfl\n#align equiv.ring_equiv_symm_apply Equiv.ringEquiv_symm_apply\n\n/-- Transfer `semigroup` across an `equiv` -/\n@[reducible, to_additive \"Transfer `add_semigroup` across an `equiv`\"]\nprotected def semigroup [Semigroup β] : Semigroup α :=\n  by\n  let mul := e.Mul\n  skip <;> apply e.injective.semigroup _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.semigroup Equiv.semigroup\n#align equiv.add_semigroup Equiv.addSemigroup\n\n/-- Transfer `semigroup_with_zero` across an `equiv` -/\n@[reducible]\nprotected def semigroupWithZero [SemigroupWithZero β] : SemigroupWithZero α :=\n  by\n  let mul := e.Mul\n  let zero := e.Zero\n  skip <;> apply e.injective.semigroup_with_zero _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.semigroup_with_zero Equiv.semigroupWithZero\n\n/-- Transfer `comm_semigroup` across an `equiv` -/\n@[reducible, to_additive \"Transfer `add_comm_semigroup` across an `equiv`\"]\nprotected def commSemigroup [CommSemigroup β] : CommSemigroup α :=\n  by\n  let mul := e.Mul\n  skip <;> apply e.injective.comm_semigroup _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.comm_semigroup Equiv.commSemigroup\n#align equiv.add_comm_semigroup Equiv.addCommSemigroup\n\n/-- Transfer `mul_zero_class` across an `equiv` -/\n@[reducible]\nprotected def mulZeroClass [MulZeroClass β] : MulZeroClass α :=\n  by\n  let zero := e.Zero\n  let mul := e.Mul\n  skip <;> apply e.injective.mul_zero_class _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.mul_zero_class Equiv.mulZeroClass\n\n/-- Transfer `mul_one_class` across an `equiv` -/\n@[reducible, to_additive \"Transfer `add_zero_class` across an `equiv`\"]\nprotected def mulOneClass [MulOneClass β] : MulOneClass α :=\n  by\n  let one := e.One\n  let mul := e.Mul\n  skip <;> apply e.injective.mul_one_class _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.mul_one_class Equiv.mulOneClass\n#align equiv.add_zero_class Equiv.addZeroClass\n\n/-- Transfer `mul_zero_one_class` across an `equiv` -/\n@[reducible]\nprotected def mulZeroOneClass [MulZeroOneClass β] : MulZeroOneClass α :=\n  by\n  let zero := e.Zero\n  let one := e.One\n  let mul := e.Mul\n  skip <;> apply e.injective.mul_zero_one_class _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.mul_zero_one_class Equiv.mulZeroOneClass\n\n/-- Transfer `monoid` across an `equiv` -/\n@[reducible, to_additive \"Transfer `add_monoid` across an `equiv`\"]\nprotected def monoid [Monoid β] : Monoid α :=\n  by\n  let one := e.One\n  let mul := e.Mul\n  let pow := e.Pow ℕ\n  skip <;> apply e.injective.monoid _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.monoid Equiv.monoid\n#align equiv.add_monoid Equiv.addMonoid\n\n/-- Transfer `comm_monoid` across an `equiv` -/\n@[reducible, to_additive \"Transfer `add_comm_monoid` across an `equiv`\"]\nprotected def commMonoid [CommMonoid β] : CommMonoid α :=\n  by\n  let one := e.One\n  let mul := e.Mul\n  let pow := e.Pow ℕ\n  skip <;> apply e.injective.comm_monoid _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.comm_monoid Equiv.commMonoid\n#align equiv.add_comm_monoid Equiv.addCommMonoid\n\n/-- Transfer `group` across an `equiv` -/\n@[reducible, to_additive \"Transfer `add_group` across an `equiv`\"]\nprotected def group [Group β] : Group α :=\n  by\n  let one := e.One\n  let mul := e.Mul\n  let inv := e.Inv\n  let div := e.Div\n  let npow := e.Pow ℕ\n  let zpow := e.Pow ℤ\n  skip <;> apply e.injective.group _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.group Equiv.group\n#align equiv.add_group Equiv.addGroup\n\n/-- Transfer `comm_group` across an `equiv` -/\n@[reducible, to_additive \"Transfer `add_comm_group` across an `equiv`\"]\nprotected def commGroup [CommGroup β] : CommGroup α :=\n  by\n  let one := e.One\n  let mul := e.Mul\n  let inv := e.Inv\n  let div := e.Div\n  let npow := e.Pow ℕ\n  let zpow := e.Pow ℤ\n  skip <;> apply e.injective.comm_group _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.comm_group Equiv.commGroup\n#align equiv.add_comm_group Equiv.addCommGroup\n\n/-- Transfer `non_unital_non_assoc_semiring` across an `equiv` -/\n@[reducible]\nprotected def nonUnitalNonAssocSemiring [NonUnitalNonAssocSemiring β] :\n    NonUnitalNonAssocSemiring α := by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let nsmul := e.SMul ℕ\n  skip <;> apply e.injective.non_unital_non_assoc_semiring _ <;> intros <;>\n    exact e.apply_symm_apply _\n#align equiv.non_unital_non_assoc_semiring Equiv.nonUnitalNonAssocSemiring\n\n/-- Transfer `non_unital_semiring` across an `equiv` -/\n@[reducible]\nprotected def nonUnitalSemiring [NonUnitalSemiring β] : NonUnitalSemiring α :=\n  by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let nsmul := e.SMul ℕ\n  skip <;> apply e.injective.non_unital_semiring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.non_unital_semiring Equiv.nonUnitalSemiring\n\n/-- Transfer `add_monoid_with_one` across an `equiv` -/\n@[reducible]\nprotected def addMonoidWithOne [AddMonoidWithOne β] : AddMonoidWithOne α :=\n  { e.AddMonoid, e.One with\n    natCast := fun n => e.symm n\n    natCast_zero := show e.symm _ = _ by simp [zero_def]\n    natCast_succ := fun n => show e.symm _ = e.symm (e (e.symm _) + _) by simp [add_def, one_def] }\n#align equiv.add_monoid_with_one Equiv.addMonoidWithOne\n\n/-- Transfer `add_group_with_one` across an `equiv` -/\n@[reducible]\nprotected def addGroupWithOne [AddGroupWithOne β] : AddGroupWithOne α :=\n  { e.AddMonoidWithOne,\n    e.AddGroup with\n    intCast := fun n => e.symm n\n    intCast_ofNat := fun n => by rw [Int.cast_ofNat] <;> rfl\n    intCast_negSucc := fun n =>\n      congr_arg e.symm <| (Int.cast_negSucc _).trans <| congr_arg _ (e.apply_symm_apply _).symm }\n#align equiv.add_group_with_one Equiv.addGroupWithOne\n\n/-- Transfer `non_assoc_semiring` across an `equiv` -/\n@[reducible]\nprotected def nonAssocSemiring [NonAssocSemiring β] : NonAssocSemiring α :=\n  by\n  let mul := e.Mul\n  let add_monoid_with_one := e.AddMonoidWithOne\n  skip <;> apply e.injective.non_assoc_semiring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.non_assoc_semiring Equiv.nonAssocSemiring\n\n/-- Transfer `semiring` across an `equiv` -/\n@[reducible]\nprotected def semiring [Semiring β] : Semiring α :=\n  by\n  let mul := e.Mul\n  let add_monoid_with_one := e.AddMonoidWithOne\n  let npow := e.Pow ℕ\n  skip <;> apply e.injective.semiring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.semiring Equiv.semiring\n\n/-- Transfer `non_unital_comm_semiring` across an `equiv` -/\n@[reducible]\nprotected def nonUnitalCommSemiring [NonUnitalCommSemiring β] : NonUnitalCommSemiring α :=\n  by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let nsmul := e.SMul ℕ\n  skip <;> apply e.injective.non_unital_comm_semiring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.non_unital_comm_semiring Equiv.nonUnitalCommSemiring\n\n/-- Transfer `comm_semiring` across an `equiv` -/\n@[reducible]\nprotected def commSemiring [CommSemiring β] : CommSemiring α :=\n  by\n  let mul := e.Mul\n  let add_monoid_with_one := e.AddMonoidWithOne\n  let npow := e.Pow ℕ\n  skip <;> apply e.injective.comm_semiring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.comm_semiring Equiv.commSemiring\n\n/-- Transfer `non_unital_non_assoc_ring` across an `equiv` -/\n@[reducible]\nprotected def nonUnitalNonAssocRing [NonUnitalNonAssocRing β] : NonUnitalNonAssocRing α :=\n  by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let neg := e.Neg\n  let sub := e.Sub\n  let nsmul := e.SMul ℕ\n  let zsmul := e.SMul ℤ\n  skip <;> apply e.injective.non_unital_non_assoc_ring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.non_unital_non_assoc_ring Equiv.nonUnitalNonAssocRing\n\n/-- Transfer `non_unital_ring` across an `equiv` -/\n@[reducible]\nprotected def nonUnitalRing [NonUnitalRing β] : NonUnitalRing α :=\n  by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let neg := e.Neg\n  let sub := e.Sub\n  let nsmul := e.SMul ℕ\n  let zsmul := e.SMul ℤ\n  skip <;> apply e.injective.non_unital_ring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.non_unital_ring Equiv.nonUnitalRing\n\n/-- Transfer `non_assoc_ring` across an `equiv` -/\n@[reducible]\nprotected def nonAssocRing [NonAssocRing β] : NonAssocRing α :=\n  by\n  let add_group_with_one := e.AddGroupWithOne\n  let mul := e.Mul\n  skip <;> apply e.injective.non_assoc_ring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.non_assoc_ring Equiv.nonAssocRing\n\n/-- Transfer `ring` across an `equiv` -/\n@[reducible]\nprotected def ring [Ring β] : Ring α := by\n  let mul := e.Mul\n  let add_group_with_one := e.AddGroupWithOne\n  let npow := e.Pow ℕ\n  skip <;> apply e.injective.ring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.ring Equiv.ring\n\n/-- Transfer `non_unital_comm_ring` across an `equiv` -/\n@[reducible]\nprotected def nonUnitalCommRing [NonUnitalCommRing β] : NonUnitalCommRing α :=\n  by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let neg := e.Neg\n  let sub := e.Sub\n  let nsmul := e.SMul ℕ\n  let zsmul := e.SMul ℤ\n  skip <;> apply e.injective.non_unital_comm_ring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.non_unital_comm_ring Equiv.nonUnitalCommRing\n\n/-- Transfer `comm_ring` across an `equiv` -/\n@[reducible]\nprotected def commRing [CommRing β] : CommRing α :=\n  by\n  let mul := e.Mul\n  let add_group_with_one := e.AddGroupWithOne\n  let npow := e.Pow ℕ\n  skip <;> apply e.injective.comm_ring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.comm_ring Equiv.commRing\n\n/-- Transfer `nontrivial` across an `equiv` -/\n@[reducible]\nprotected theorem nontrivial [Nontrivial β] : Nontrivial α :=\n  e.Surjective.Nontrivial\n#align equiv.nontrivial Equiv.nontrivial\n\n/-- Transfer `is_domain` across an `equiv` -/\n@[reducible]\nprotected theorem isDomain [Ring α] [Ring β] [IsDomain β] (e : α ≃+* β) : IsDomain α :=\n  Function.Injective.isDomain e.toRingHom e.Injective\n#align equiv.is_domain Equiv.isDomain\n\n/-- Transfer `has_rat_cast` across an `equiv` -/\n@[reducible]\nprotected def hasRatCast [HasRatCast β] : HasRatCast α where ratCast n := e.symm n\n#align equiv.has_rat_cast Equiv.hasRatCast\n\n/-- Transfer `division_ring` across an `equiv` -/\n@[reducible]\nprotected def divisionRing [DivisionRing β] : DivisionRing α :=\n  by\n  let add_group_with_one := e.AddGroupWithOne\n  let mul := e.Mul\n  let inv := e.Inv\n  let div := e.Div\n  let mul := e.Mul\n  let npow := e.Pow ℕ\n  let zpow := e.Pow ℤ\n  let rat_cast := e.HasRatCast\n  let qsmul := e.SMul ℚ\n  skip <;> apply e.injective.division_ring _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.division_ring Equiv.divisionRing\n\n/-- Transfer `field` across an `equiv` -/\n@[reducible]\nprotected def field [Field β] : Field α :=\n  by\n  let add_group_with_one := e.AddGroupWithOne\n  let mul := e.Mul\n  let neg := e.Neg\n  let inv := e.Inv\n  let div := e.Div\n  let mul := e.Mul\n  let npow := e.Pow ℕ\n  let zpow := e.Pow ℤ\n  let rat_cast := e.HasRatCast\n  let qsmul := e.SMul ℚ\n  skip <;> apply e.injective.field _ <;> intros <;> exact e.apply_symm_apply _\n#align equiv.field Equiv.field\n\nsection R\n\nvariable (R : Type _)\n\ninclude R\n\nsection\n\nvariable [Monoid R]\n\n/-- Transfer `mul_action` across an `equiv` -/\n@[reducible]\nprotected def mulAction (e : α ≃ β) [MulAction R β] : MulAction R α :=\n  { e.SMul R with\n    one_smul := by simp [smul_def]\n    mul_smul := by simp [smul_def, mul_smul] }\n#align equiv.mul_action Equiv.mulAction\n\n/-- Transfer `distrib_mul_action` across an `equiv` -/\n@[reducible]\nprotected def distribMulAction (e : α ≃ β) [AddCommMonoid β] :\n    letI := Equiv.addCommMonoid e\n    ∀ [DistribMulAction R β], DistribMulAction R α :=\n  by\n  intros\n  letI := Equiv.addCommMonoid e\n  exact\n    ({ Equiv.mulAction R e with\n        smul_zero := by simp [zero_def, smul_def]\n        smul_add := by simp [add_def, smul_def, smul_add] } :\n      DistribMulAction R α)\n#align equiv.distrib_mul_action Equiv.distribMulAction\n\nend\n\nsection\n\nvariable [Semiring R]\n\n/-- Transfer `module` across an `equiv` -/\n@[reducible]\nprotected def module (e : α ≃ β) [AddCommMonoid β] :\n    letI := Equiv.addCommMonoid e\n    ∀ [Module R β], Module R α :=\n  by\n  intros\n  exact\n    ({\n        Equiv.distribMulAction R\n          e with\n        zero_smul := by simp [zero_def, smul_def]\n        add_smul := by simp [add_def, smul_def, add_smul] } :\n      Module R α)\n#align equiv.module Equiv.module\n\n/-- An equivalence `e : α ≃ β` gives a linear equivalence `α ≃ₗ[R] β`\nwhere the `R`-module structure on `α` is\nthe one obtained by transporting an `R`-module structure on `β` back along `e`.\n-/\ndef linearEquiv (e : α ≃ β) [AddCommMonoid β] [Module R β] :\n    by\n    letI := Equiv.addCommMonoid e\n    letI := Equiv.module R e\n    exact α ≃ₗ[R] β := by\n  intros\n  exact\n    { Equiv.addEquiv e with\n      map_smul' := fun r x => by\n        apply e.symm.injective\n        simp\n        rfl }\n#align equiv.linear_equiv Equiv.linearEquiv\n\nend\n\nsection\n\nvariable [CommSemiring R]\n\n/-- Transfer `algebra` across an `equiv` -/\n@[reducible]\nprotected def algebra (e : α ≃ β) [Semiring β] :\n    letI := Equiv.semiring e\n    ∀ [Algebra R β], Algebra R α :=\n  by\n  intros\n  fapply RingHom.toAlgebra'\n  · exact ((RingEquiv e).symm : β →+* α).comp (algebraMap R β)\n  · intro r x\n    simp only [Function.comp_apply, RingHom.coe_comp]\n    have p := ring_equiv_symm_apply e\n    dsimp at p\n    erw [p]\n    clear p\n    apply (RingEquiv e).Injective\n    simp only [(RingEquiv e).map_mul]\n    simp [Algebra.commutes]\n#align equiv.algebra Equiv.algebra\n\n/-- An equivalence `e : α ≃ β` gives an algebra equivalence `α ≃ₐ[R] β`\nwhere the `R`-algebra structure on `α` is\nthe one obtained by transporting an `R`-algebra structure on `β` back along `e`.\n-/\ndef algEquiv (e : α ≃ β) [Semiring β] [Algebra R β] :\n    by\n    letI := Equiv.semiring e\n    letI := Equiv.algebra R e\n    exact α ≃ₐ[R] β := by\n  intros\n  exact\n    { Equiv.ringEquiv e with\n      commutes' := fun r => by\n        apply e.symm.injective\n        simp\n        rfl }\n#align equiv.alg_equiv Equiv.algEquiv\n\nend\n\nend R\n\nend Instances\n\nend Equiv\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Logic/Equiv/TransferInstance.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.47800338439682544}}
{"text": "/- Author: E.W.Ayers © 2019 -/\nimport ..equate\nopen robot\nuniverse u\n\nattribute [equate] is_group_hom.mul\n\nsection additive_groups\n    variables {α : Type u} [add_comm_group α] {u v w x y z : α}\n    example : (x + y) + z = (z + x) + y :=\n    by equate\n    example : x + y + z = z + x + y :=\n    by equate\n    example : x + (y - z) = -z + y + x :=\n    by equate\n    example : x - (y + z) = x - y - z :=\n    by equate\n    example : - (x - y) = y + - x :=\n    by equate\n    example : - (x - y) = y - x :=\n    by equate\n    example : (x - y) = -(y - x) := -- [FIXME]\n    by equate\n    example : (x - y) = -(y + - x) := -- [FIXME]\n    by equate\n    example : (- - x) + - y = -(y - x) :=\n    by equate\n    example : (- - x) - y = -(y - x) := -- [FIXME]\n    by equate\n    example : (x + y) + (z + w) = (x + z) + (y + w) :=\n    by equate\n    example : v + u + (x + y) + (z + w) = (x + z) + (y + w) + v + u :=\n    by equate\n    lemma X1 : x + y + z + u + v + w = w + (x + y + z + u + v) :=\n    by equate\n    #print X1\n    lemma X2 : x + y + z + u + v + w = w + (x + y + z + u + v) :=\n    by (tactic.timetac \"ac_refl\" $ tactic.ac_refl)\n    #print X2\nend additive_groups\n\nsection powers\n    variables {M : Type u} [monoid M] {a : M} {n m : ℕ}\n\n    @[equate] lemma my_pow_mul_comm' : a^n * a = a * a^n :=\n    begin\n        induction n,\n        simp,\n        equate -- [FIXME]\n    end\n    @[equate] lemma my_pow_succ' : a^(nat.succ n) = a^n * a :=\n    by equate\n    -- set_option pp.notation false\n    @[equate] lemma my_pow_1 : a^1 = a := by equate -- [FIXME]\n    @[equate] lemma my_pow_2 : a^2 = a * a := by equate -- [FIXME]\n    @[equate] lemma my_pow_add : a^(m + n) = a^m * a^n :=\n    begin\n        induction m,\n        simp,\n        equate\n    end\n    @[equate] lemma my_one_pow : (1:M)^n = (1:M) :=\n    begin\n        induction n,\n        equate,\n        equate\n    end\n    @[equate] lemma my_pow_mul : (a^n)^m = a^(n * m) :=\n    begin\n        induction m,\n        equate,\n        equate\n    end\n    @[equate] lemma my_pow_mul_comm : (a^n) * (a^m) = (a^m) * (a^n)\n    := by equate\nend powers\n\nsection comm_monoid_powers\n    variables {M:Type u} [comm_monoid M] {a b c : M} {n m : ℕ}\n    @[equate] lemma my_mul_pow : (a * b)^n = a^n * b^n\n    := begin\n        induction n,\n        simp,\n        equate -- [FIXME]\n    end\nend comm_monoid_powers\n\nsection group_powers\n    variables {G : Type u} [group G] {a b c : G} {n m : ℕ}\n    @[equate] lemma my_inv_pow : (a⁻¹)^n = (a^n)⁻¹ :=\n    begin\n        induction n,\n        simp,\n        equate\n    end\nend group_powers\n\nsection group_homs1\n    variables {H G : Type u} [group H] [group G] {φ : H → G} {ψ : G → H} {x y z h : G}\n    example : (x * z) * (z⁻¹ * y) = x * y -- [FIXME] finds an overly long soln\n    := by equate\n    example : x * y = (x * z) * (z⁻¹ * y) -- [NOTE] this is an out-of-scope problem\n    := by equate\n    -- example : x * y = (x * z²) * (z⁻² * y)\n    -- := by equate\n    def conj (h x : G) := h * x * h ⁻¹\n    @[equate] lemma conj_def : conj h x = h * x * h ⁻¹ := rfl\n    example {h : G} : conj h (x) * conj h (y) = conj h (x * y) :=\n    by equate\n    example {h : G} : conj h (x * y) = conj h x * conj h y :=\n    by equate -- [FIXME]\n    example {h : G} : (conj h x)⁻¹ = conj h (x⁻¹):=\n    by equate\n    example {h : G} : (conj h x⁻¹) = (conj h x)⁻¹ :=\n    by equate -- [FIXME]\n    example : x * y⁻¹ = (y * x⁻¹)⁻¹\n    := by equate\n    example :  (y * x⁻¹)⁻¹ = x * y⁻¹\n    := by equate\n    example [is_group_hom φ] [is_group_hom ψ] {x y : G}\n        : is_group_hom (φ ∘ ψ) := ⟨λ x y, by equate⟩\n    example\n        [is_group_hom φ]\n        (i1 : ∀ x, φ(ψ x) = x)\n        (i2 : ∀ x, ψ(φ x) = x) {x y : G}\n        : is_group_hom ψ :=\n    ⟨λ a b, by equate⟩\nend group_homs1\n\nsection group_homs3\n    lemma is_group_hom_mul_2 {α β} [group α] [comm_group β]\n    (f g : α → β) [is_group_hom f] [is_group_hom g] :\n    is_group_hom (λa, f a * g a) :=\n    ⟨assume a b, by equate⟩\nend group_homs3\n\n\n\n\n", "meta": {"author": "EdAyers", "repo": "lean-subtask", "sha": "04ac5a6c3bc3bfd190af4d6dcce444ddc8914e4b", "save_path": "github-repos/lean/EdAyers-lean-subtask", "path": "github-repos/lean/EdAyers-lean-subtask/lean-subtask-04ac5a6c3bc3bfd190af4d6dcce444ddc8914e4b/src/examples/groups.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.640635841117624, "lm_q1q2_score": 0.47800337415810185}}
{"text": "import tactic\nimport data.real.basic\nimport measure_theory.function.locally_integrable\nimport measure_theory.measure.lebesgue\nimport measure_theory.integral.interval_integral\n\n/- \n  If some statement holds for almost all x and it always implies another statement\n  then the other statement also holds almost everywhere  \n -/\nlemma ae_of_implies_and_ae {p : ℝ → Prop} {q : ℝ → Prop} : \n  (∀ x, p x → q x) → (∀ᵐ x : ℝ, p x) → (∀ᵐ x : ℝ, q x) :=\nbegin\n  intros hpq hpae,\n  have h : {x | ¬ q x} ⊆ {x | ¬ p x} := begin\n    simp,\n    intro x,\n    specialize hpq x,\n    intro hnq,\n    intro hp,\n    apply hnq,\n    apply hpq,\n    assumption\n  end,\n  apply measure_theory.outer_measure.mono_null _ h (measure_theory.ae_iff.1 hpae),\nend\n\nlemma interval_integrable_of_locally_integrable (f: ℝ → ℝ) (a : ℝ) (b : ℝ) {μ : measure_theory.measure ℝ}:\n  measure_theory.locally_integrable f μ → interval_integrable f μ a b :=\nbegin\n  sorry,\nend\n\nlemma lebesgue_measure_translation_invariant {μ : measure_theory.outer_measure ℝ} (p : ℝ → Prop) {x : ℝ} :\n  μ {y : ℝ | p y} = μ {y : ℝ | p (y - x)} :=\nbegin\n  sorry,\nend", "meta": {"author": "GraffL", "repo": "DynamicFlowsInLean", "sha": "2365606db9c13771bd413de72d713d87196582d4", "save_path": "github-repos/lean/GraffL-DynamicFlowsInLean", "path": "github-repos/lean/GraffL-DynamicFlowsInLean/DynamicFlowsInLean-2365606db9c13771bd413de72d713d87196582d4/src/TechnicalStuff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.47800337415810173}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.norm_num\nimport Mathlib.data.int.range\nimport Mathlib.PostPort\n\nuniverses u_1 l \n\nnamespace Mathlib\n\n/-!\n# `ring`\n\nEvaluate expressions in the language of commutative (semi)rings.\nBased on <http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf> .\n-/\n\nnamespace tactic\n\n\nnamespace ring\n\n\n/-- The normal form that `ring` uses is mediated by the function `horner a x n b := a * x ^ n + b`.\nThe reason we use a definition rather than the (more readable) expression on the right is because\nthis expression contains a number of typeclass arguments in different positions, while `horner`\ncontains only one `comm_semiring` instance at the top level. See also `horner_expr` for a\ndescription of normal form. -/\ndef horner {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) : α :=\n  a * x ^ n + b\n\n/-- This cache contains data required by the `ring` tactic during execution. -/\n/-- The monad that `ring` works in. This is a reader monad containing a mutable cache (using `ref`\nfor mutability), as well as the list of atoms-up-to-defeq encountered thus far, used for atom\nsorting. -/\n/-- Get the `ring` data from the monad. -/\n/-- Get an already encountered atom by its index. -/\n/-- Get the index corresponding to an atomic expression, if it has already been encountered, or\nput it in the list of atoms and return the new index, otherwise. -/\n/-- Lift a tactic into the `ring_m` monad. -/\n/-- Run a `ring_m` tactic in the tactic monad. This version of `ring_m.run` uses an external\natoms ref, so that subexpressions can be named across multiple `ring_m` calls. -/\n/-- Run a `ring_m` tactic in the tactic monad. -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This version\nis abstract over the instance cache in question (either the ring `α`, or `ℕ` for exponents). -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to the ring `α`. -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to `ℕ`, which is used for computations in the exponent. -/\n/-- Apply a theorem that expects a `comm_semiring` instance. This is a special case of\n`ic_lift mk_app`, but it comes up often because `horner` and all its theorems have this assumption;\nit also does not require the tactic monad which improves access speed a bit. -/\n/-- Every expression in the language of commutative semirings can be viewed as a sum of monomials,\nwhere each monomial is a product of powers of atoms. We fix a global order on atoms (up to\ndefinitional equality), and then separate the terms according to their smallest atom. So the top\nlevel expression is `a * x^n + b` where `x` is the smallest atom and `n > 0` is a numeral, and\n`n` is maximal (so `a` contains at least one monomial not containing an `x`), and `b` contains no\nmonomials with an `x` (hence all atoms in `b` are larger than `x`).\n\nIf there is no `x` satisfying these constraints, then the expression must be a numeral. Even though\nwe are working over rings, we allow rational constants when these can be interpreted in the ring,\nso we can solve problems like `x / 3 = 1 / 3 * x` even though these are not technically in the\nlanguage of rings.\n\nThese constraints ensure that there is a unique normal form for each ring expression, and so the\nalgorithm is simply to calculate the normal form of each side and compare for equality.\n\nTo allow us to efficiently pattern match on normal forms, we maintain this inductive type that\nholds a normalized expression together with its structure. All the `expr`s in this type could be\nremoved without loss of information, and conversely the `horner_expr` structure and the `ℕ` and\n`ℚ` values can be recovered from the top level `expr`, but we keep both in order to keep proof\n producing normalization functions efficient. -/\n/-- Get the expression corresponding to a `horner_expr`. This can be calculated recursively from\nthe structure, but we cache the exprs in all subterms so that this function can be computed in\nconstant time. -/\n/-- Is this expr the constant `0`? -/\n/-- Construct a `xadd` node, generating the cached expr using the input cache. -/\n/-- Pretty printer for `horner_expr`. -/\n/-- Pretty printer for `horner_expr`. -/\n/-- Reflexivity conversion for a `horner_expr`. -/\ntheorem zero_horner {α : Type u_1} [comm_semiring α] (x : α) (n : ℕ) (b : α) : horner 0 x n b = b := sorry\n\ntheorem horner_horner {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (n₂ : ℕ) (b : α) (n' : ℕ) (h : n₁ + n₂ = n') : horner (horner a₁ x n₁ 0) x n₂ b = horner a₁ x n' b := sorry\n\n/-- Evaluate `horner a n x b` where `a` and `b` are already in normal form. -/\ntheorem const_add_horner {α : Type u_1} [comm_semiring α] (k : α) (a : α) (x : α) (n : ℕ) (b : α) (b' : α) (h : k + b = b') : k + horner a x n b = horner a x n b' := sorry\n\ntheorem horner_add_const {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) (k : α) (b' : α) (h : b + k = b') : horner a x n b + k = horner a x n b' := sorry\n\ntheorem horner_add_horner_lt {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α) (a₂ : α) (n₂ : ℕ) (b₂ : α) (k : ℕ) (a' : α) (b' : α) (h₁ : n₁ + k = n₂) (h₂ : a₁ + horner a₂ x k 0 = a') (h₃ : b₁ + b₂ = b') : horner a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₁ b' := sorry\n\ntheorem horner_add_horner_gt {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α) (a₂ : α) (n₂ : ℕ) (b₂ : α) (k : ℕ) (a' : α) (b' : α) (h₁ : n₂ + k = n₁) (h₂ : horner a₁ x k 0 + a₂ = a') (h₃ : b₁ + b₂ = b') : horner a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₂ b' := sorry\n\ntheorem horner_add_horner_eq {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n : ℕ) (b₁ : α) (a₂ : α) (b₂ : α) (a' : α) (b' : α) (t : α) (h₁ : a₁ + a₂ = a') (h₂ : b₁ + b₂ = b') (h₃ : horner a' x n b' = t) : horner a₁ x n b₁ + horner a₂ x n b₂ = t := sorry\n\n/-- Evaluate `a + b` where `a` and `b` are already in normal form. -/\ntheorem horner_neg {α : Type u_1} [comm_ring α] (a : α) (x : α) (n : ℕ) (b : α) (a' : α) (b' : α) (h₁ : -a = a') (h₂ : -b = b') : -horner a x n b = horner a' x n b' := sorry\n\n/-- Evaluate `-a` where `a` is already in normal form. -/\ntheorem horner_const_mul {α : Type u_1} [comm_semiring α] (c : α) (a : α) (x : α) (n : ℕ) (b : α) (a' : α) (b' : α) (h₁ : c * a = a') (h₂ : c * b = b') : c * horner a x n b = horner a' x n b' := sorry\n\ntheorem horner_mul_const {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) (c : α) (a' : α) (b' : α) (h₁ : a * c = a') (h₂ : b * c = b') : horner a x n b * c = horner a' x n b' := sorry\n\n/-- Evaluate `k * a` where `k` is a rational numeral and `a` is in normal form. -/\ntheorem horner_mul_horner_zero {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α) (a₂ : α) (n₂ : ℕ) (aa : α) (t : α) (h₁ : horner a₁ x n₁ b₁ * a₂ = aa) (h₂ : horner aa x n₂ 0 = t) : horner a₁ x n₁ b₁ * horner a₂ x n₂ 0 = t := sorry\n\ntheorem horner_mul_horner {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α) (a₂ : α) (n₂ : ℕ) (b₂ : α) (aa : α) (haa : α) (ab : α) (bb : α) (t : α) (h₁ : horner a₁ x n₁ b₁ * a₂ = aa) (h₂ : horner aa x n₂ 0 = haa) (h₃ : a₁ * b₂ = ab) (h₄ : b₁ * b₂ = bb) (H : haa + horner ab x n₁ bb = t) : horner a₁ x n₁ b₁ * horner a₂ x n₂ b₂ = t := sorry\n\n/-- Evaluate `a * b` where `a` and `b` are in normal form. -/\ntheorem horner_pow {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (m : ℕ) (n' : ℕ) (a' : α) (h₁ : n * m = n') (h₂ : a ^ m = a') : horner a x n 0 ^ m = horner a' x n' 0 := sorry\n\ntheorem pow_succ {α : Type u_1} [comm_semiring α] (a : α) (n : ℕ) (b : α) (c : α) (h₁ : a ^ n = b) (h₂ : b * a = c) : a ^ (n + 1) = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = c)) (Eq.symm h₂)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = b * a)) (Eq.symm h₁)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = a ^ n * a)) (pow_succ' a n))) (Eq.refl (a ^ n * a))))\n\n/-- Evaluate `a ^ n` where `a` is in normal form and `n` is a natural numeral. -/\ntheorem horner_atom {α : Type u_1} [comm_semiring α] (x : α) : x = horner 1 x 1 0 := sorry\n\n/-- Evaluate `a` where `a` is an atom. -/\ntheorem subst_into_pow {α : Type u_1} [monoid α] (l : α) (r : ℕ) (tl : α) (tr : ℕ) (t : α) (prl : l = tl) (prr : r = tr) (prt : tl ^ tr = t) : l ^ r = t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (l ^ r = t)) prl))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (tl ^ r = t)) prr))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (tl ^ tr = t)) prt)) (Eq.refl t)))\n\ntheorem unfold_sub {α : Type u_1} [add_group α] (a : α) (b : α) (c : α) (h : a + -b = c) : a - b = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a - b = c)) (sub_eq_add_neg a b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a + -b = c)) h)) (Eq.refl c))\n\ntheorem unfold_div {α : Type u_1} [division_ring α] (a : α) (b : α) (c : α) (h : a * (b⁻¹) = c) : a / b = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a / b = c)) (div_eq_mul_inv a b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a * (b⁻¹) = c)) h)) (Eq.refl c))\n\n/-- Evaluate a ring expression `e` recursively to normal form, together with a proof of\nequality. -/\n/-- Evaluate a ring expression `e` recursively to normal form, together with a proof of\nequality. -/\ntheorem horner_def' {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) : horner a x n b = x ^ n * a + b := sorry\n\ntheorem mul_assoc_rev {α : Type u_1} [semigroup α] (a : α) (b : α) (c : α) : a * (b * c) = a * b * c := sorry\n\ntheorem pow_add_rev {α : Type u_1} [monoid α] (a : α) (m : ℕ) (n : ℕ) : a ^ m * a ^ n = a ^ (m + n) := sorry\n\ntheorem pow_add_rev_right {α : Type u_1} [monoid α] (a : α) (b : α) (m : ℕ) (n : ℕ) : b * a ^ m * a ^ n = b * a ^ (m + n) := sorry\n\ntheorem add_neg_eq_sub {α : Type u_1} [add_group α] (a : α) (b : α) : a + -b = a - b :=\n  Eq.symm (sub_eq_add_neg a b)\n\n/-- If `ring` fails to close the goal, it falls back on normalizing the expression to a \"pretty\"\nform so that you can see why it failed. This setting adjusts the resulting form:\n\n  * `raw` is the form that `ring` actually uses internally, with iterated applications of `horner`.\n    Not very readable but useful if you don't want any postprocessing.\n    This results in terms like `horner (horner (horner 3 y 1 0) x 2 1) x 1 (horner 1 y 1 0)`.\n  * `horner` maintains the Horner form structure, but it unfolds the `horner` definition itself,\n    and tries to otherwise minimize parentheses.\n    This results in terms like `(3 * x ^ 2 * y + 1) * x + y`.\n  * `SOP` means sum of products form, expanding everything to monomials.\n    This results in terms like `3 * x ^ 3 * y + x + y`. -/\ninductive normalize_mode \nwhere\n| raw : normalize_mode\n| SOP : normalize_mode\n| horner : normalize_mode\n\nprotected instance normalize_mode.inhabited : Inhabited normalize_mode :=\n  { default := normalize_mode.horner }\n\n/-- A `ring`-based normalization simplifier that rewrites ring expressions into the specified mode.\n\n  * `raw` is the form that `ring` actually uses internally, with iterated applications of `horner`.\n    Not very readable but useful if you don't want any postprocessing.\n    This results in terms like `horner (horner (horner 3 y 1 0) x 2 1) x 1 (horner 1 y 1 0)`.\n  * `horner` maintains the Horner form structure, but it unfolds the `horner` definition itself,\n    and tries to otherwise minimize parentheses.\n    This results in terms like `(3 * x ^ 2 * y + 1) * x + y`.\n  * `SOP` means sum of products form, expanding everything to monomials.\n    This results in terms like `3 * x ^ 3 * y + x + y`. -/\nend ring\n\n\nnamespace interactive\n\n\n/-- Tactic for solving equations in the language of *commutative* (semi)rings.\n  This version of `ring` fails if the target is not an equality\n  that is provable by the axioms of commutative (semi)rings. -/\n/-- Parser for `ring`'s `mode` argument, which can only be the \"keywords\" `raw`, `horner` or `SOP`.\n(Because these are not actually keywords we use a name parser and postprocess the result.) -/\n/-- Tactic for solving equations in the language of *commutative* (semi)rings.\nAttempts to prove the goal outright if there is no `at`\nspecifier and the target is an equality, but if this\nfails it falls back to rewriting all ring expressions\ninto a normal form. When writing a normal form,\n`ring SOP` will use sum-of-products form instead of horner form.\n`ring!` will use a more aggressive reducibility setting to identify atoms.\n\nBased on [Proving Equalities in a Commutative Ring Done Right\nin Coq](http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf) by Benjamin Grégoire\nand Assia Mahboubi.\n-/\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.4779410776011818}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Mario Carneiro, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.adjunction.basic\nimport category_theory.limits.cones\nimport category_theory.reflects_isomorphisms\n\n/-!\n# Limits and colimits\n\nWe set up the general theory of limits and colimits in a category.\nIn this introduction we only describe the setup for limits;\nit is repeated, with slightly different names, for colimits.\n\nThe main structures defined in this file is\n* `is_limit c`, for `c : cone F`, `F : J ⥤ C`, expressing that `c` is a limit cone,\n\nSee also `category_theory.limits.limits` which further builds:\n* `limit_cone F`, which consists of a choice of cone for `F` and the fact it is a limit cone, and\n* `has_limit F`, asserting the mere existence of some limit cone for `F`.\n\n## Implementation\nAt present we simply say everything twice, in order to handle both limits and colimits.\nIt would be highly desirable to have some automation support,\ne.g. a `@[dualize]` attribute that behaves similarly to `@[to_additive]`.\n\n## References\n* [Stacks: Limits and colimits](https://stacks.math.columbia.edu/tag/002D)\n\n-/\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.functor opposite\n\nnamespace category_theory.limits\n\nuniverses v u u' u'' w -- declare the `v`'s first; see `category_theory.category` for an explanation\n\nvariables {J K : Type v} [small_category J] [small_category K]\nvariables {C : Type u} [category.{v} C]\n\nvariables {F : J ⥤ C}\n\n/--\nA cone `t` on `F` is a limit cone if each cone on `F` admits a unique\ncone morphism to `t`.\n\nSee https://stacks.math.columbia.edu/tag/002E.\n  -/\n@[nolint has_inhabited_instance]\nstructure is_limit (t : cone F) :=\n(lift  : Π (s : cone F), s.X ⟶ t.X)\n(fac'  : ∀ (s : cone F) (j : J), lift s ≫ t.π.app j = s.π.app j . obviously)\n(uniq' : ∀ (s : cone F) (m : s.X ⟶ t.X) (w : ∀ j : J, m ≫ t.π.app j = s.π.app j),\n  m = lift s . obviously)\n\nrestate_axiom is_limit.fac'\nattribute [simp, reassoc] is_limit.fac\nrestate_axiom is_limit.uniq'\n\nnamespace is_limit\n\ninstance subsingleton {t : cone F} : subsingleton (is_limit t) :=\n⟨by intros P Q; cases P; cases Q; congr; ext; solve_by_elim⟩\n\n/-- Given a natural transformation `α : F ⟶ G`, we give a morphism from the cone point\nof any cone over `F` to the cone point of a limit cone over `G`. -/\ndef map {F G : J ⥤ C} (s : cone F) {t : cone G} (P : is_limit t)\n  (α : F ⟶ G) : s.X ⟶ t.X :=\nP.lift ((cones.postcompose α).obj s)\n\n@[simp, reassoc] lemma map_π {F G : J ⥤ C} (c : cone F) {d : cone G} (hd : is_limit d)\n  (α : F ⟶ G) (j : J) : hd.map c α ≫ d.π.app j = c.π.app j ≫ α.app j :=\nfac _ _ _\n\nlemma lift_self {c : cone F} (t : is_limit c) : t.lift c = 𝟙 c.X :=\n(t.uniq _ _ (λ j, id_comp _)).symm\n\n/- Repackaging the definition in terms of cone morphisms. -/\n\n/-- The universal morphism from any other cone to a limit cone. -/\n@[simps]\ndef lift_cone_morphism {t : cone F} (h : is_limit t) (s : cone F) : s ⟶ t :=\n{ hom := h.lift s }\n\nlemma uniq_cone_morphism {s t : cone F} (h : is_limit t) {f f' : s ⟶ t} :\n  f = f' :=\nhave ∀ {g : s ⟶ t}, g = h.lift_cone_morphism s, by intro g; ext; exact h.uniq _ _ g.w,\nthis.trans this.symm\n\n/--\nAlternative constructor for `is_limit`,\nproviding a morphism of cones rather than a morphism between the cone points\nand separately the factorisation condition.\n-/\n@[simps]\ndef mk_cone_morphism {t : cone F}\n  (lift : Π (s : cone F), s ⟶ t)\n  (uniq' : ∀ (s : cone F) (m : s ⟶ t), m = lift s) : is_limit t :=\n{ lift := λ s, (lift s).hom,\n  uniq' := λ s m w,\n    have cone_morphism.mk m w = lift s, by apply uniq',\n    congr_arg cone_morphism.hom this }\n\n/-- Limit cones on `F` are unique up to isomorphism. -/\n@[simps]\ndef unique_up_to_iso {s t : cone F} (P : is_limit s) (Q : is_limit t) : s ≅ t :=\n{ hom := Q.lift_cone_morphism s,\n  inv := P.lift_cone_morphism t,\n  hom_inv_id' := P.uniq_cone_morphism,\n  inv_hom_id' := Q.uniq_cone_morphism }\n\n/-- Any cone morphism between limit cones is an isomorphism. -/\nlemma hom_is_iso {s t : cone F} (P : is_limit s) (Q : is_limit t) (f : s ⟶ t) : is_iso f :=\n⟨⟨P.lift_cone_morphism t, ⟨P.uniq_cone_morphism, Q.uniq_cone_morphism⟩⟩⟩\n\n/-- Limits of `F` are unique up to isomorphism. -/\ndef cone_point_unique_up_to_iso {s t : cone F} (P : is_limit s) (Q : is_limit t) : s.X ≅ t.X :=\n(cones.forget F).map_iso (unique_up_to_iso P Q)\n\n@[simp, reassoc] lemma cone_point_unique_up_to_iso_hom_comp {s t : cone F} (P : is_limit s)\n  (Q : is_limit t) (j : J) : (cone_point_unique_up_to_iso P Q).hom ≫ t.π.app j = s.π.app j :=\n(unique_up_to_iso P Q).hom.w _\n\n@[simp, reassoc] lemma cone_point_unique_up_to_iso_inv_comp {s t : cone F} (P : is_limit s)\n  (Q : is_limit t) (j : J) : (cone_point_unique_up_to_iso P Q).inv ≫ s.π.app j = t.π.app j :=\n(unique_up_to_iso P Q).inv.w _\n\n@[simp, reassoc] lemma lift_comp_cone_point_unique_up_to_iso_hom {r s t : cone F}\n  (P : is_limit s) (Q : is_limit t) :\n  P.lift r ≫ (cone_point_unique_up_to_iso P Q).hom = Q.lift r :=\nQ.uniq _ _ (by simp)\n\n@[simp, reassoc] lemma lift_comp_cone_point_unique_up_to_iso_inv {r s t : cone F}\n  (P : is_limit s) (Q : is_limit t) :\n  Q.lift r ≫ (cone_point_unique_up_to_iso P Q).inv = P.lift r :=\nP.uniq _ _ (by simp)\n\n/-- Transport evidence that a cone is a limit cone across an isomorphism of cones. -/\ndef of_iso_limit {r t : cone F} (P : is_limit r) (i : r ≅ t) : is_limit t :=\nis_limit.mk_cone_morphism\n  (λ s, P.lift_cone_morphism s ≫ i.hom)\n  (λ s m, by rw ←i.comp_inv_eq; apply P.uniq_cone_morphism)\n\n@[simp] lemma of_iso_limit_lift {r t : cone F} (P : is_limit r) (i : r ≅ t) (s) :\n  (P.of_iso_limit i).lift s = P.lift s ≫ i.hom.hom :=\nrfl\n\n/-- Isomorphism of cones preserves whether or not they are limiting cones. -/\ndef equiv_iso_limit {r t : cone F} (i : r ≅ t) : is_limit r ≃ is_limit t :=\n{ to_fun := λ h, h.of_iso_limit i,\n  inv_fun := λ h, h.of_iso_limit i.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\n@[simp] lemma equiv_iso_limit_apply {r t : cone F} (i : r ≅ t) (P : is_limit r) :\n  equiv_iso_limit i P = P.of_iso_limit i := rfl\n\n@[simp] lemma equiv_iso_limit_symm_apply {r t : cone F} (i : r ≅ t) (P : is_limit t) :\n  (equiv_iso_limit i).symm P = P.of_iso_limit i.symm := rfl\n\n/--\nIf the canonical morphism from a cone point to a limiting cone point is an iso, then the\nfirst cone was limiting also.\n-/\ndef of_point_iso {r t : cone F} (P : is_limit r) [i : is_iso (P.lift t)] : is_limit t :=\nof_iso_limit P\nbegin\n  haveI : is_iso (P.lift_cone_morphism t).hom := i,\n  haveI : is_iso (P.lift_cone_morphism t) := cones.cone_iso_of_hom_iso _,\n  symmetry,\n  apply as_iso (P.lift_cone_morphism t),\nend\n\nvariables {t : cone F}\n\nlemma hom_lift (h : is_limit t) {W : C} (m : W ⟶ t.X) :\n  m = h.lift { X := W, π := { app := λ b, m ≫ t.π.app b } } :=\nh.uniq { X := W, π := { app := λ b, m ≫ t.π.app b } } m (λ b, rfl)\n\n/-- Two morphisms into a limit are equal if their compositions with\n  each cone morphism are equal. -/\nlemma hom_ext (h : is_limit t) {W : C} {f f' : W ⟶ t.X}\n  (w : ∀ j, f ≫ t.π.app j = f' ≫ t.π.app j) : f = f' :=\nby rw [h.hom_lift f, h.hom_lift f']; congr; exact funext w\n\n/--\nGiven a right adjoint functor between categories of cones,\nthe image of a limit cone is a limit cone.\n-/\ndef of_right_adjoint {D : Type u'} [category.{v} D] {G : K ⥤ D}\n  (h : cone G ⥤ cone F) [is_right_adjoint h] {c : cone G} (t : is_limit c) :\n  is_limit (h.obj c) :=\nmk_cone_morphism\n  (λ s, (adjunction.of_right_adjoint h).hom_equiv s c (t.lift_cone_morphism _))\n  (λ s m, (adjunction.eq_hom_equiv_apply _ _ _).2 t.uniq_cone_morphism)\n\n/--\nGiven two functors which have equivalent categories of cones, we can transport a limiting cone\nacross the equivalence.\n-/\ndef of_cone_equiv {D : Type u'} [category.{v} D] {G : K ⥤ D}\n  (h : cone G ≌ cone F) {c : cone G} :\n  is_limit (h.functor.obj c) ≃ is_limit c :=\n{ to_fun := λ P, of_iso_limit (of_right_adjoint h.inverse P) (h.unit_iso.symm.app c),\n  inv_fun := of_right_adjoint h.functor,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\n@[simp] lemma of_cone_equiv_apply_desc {D : Type u'} [category.{v} D] {G : K ⥤ D}\n  (h : cone G ≌ cone F) {c : cone G} (P : is_limit (h.functor.obj c)) (s) :\n  (of_cone_equiv h P).lift s =\n    ((h.unit_iso.hom.app s).hom ≫\n      (h.functor.inv.map (P.lift_cone_morphism (h.functor.obj s))).hom) ≫\n      (h.unit_iso.inv.app c).hom :=\nrfl\n\n@[simp] \n\n/--\nA cone postcomposed with a natural isomorphism is a limit cone if and only if the original cone is.\n-/\ndef postcompose_hom_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cone F) :\n  is_limit ((cones.postcompose α.hom).obj c) ≃ is_limit c :=\nof_cone_equiv (cones.postcompose_equivalence α)\n\n/--\nA cone postcomposed with the inverse of a natural isomorphism is a limit cone if and only if\nthe original cone is.\n-/\ndef postcompose_inv_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cone G) :\n  is_limit ((cones.postcompose α.inv).obj c) ≃ is_limit c :=\npostcompose_hom_equiv α.symm c\n\n/--\nThe cone points of two limit cones for naturally isomorphic functors\nare themselves isomorphic.\n-/\n@[simps]\ndef cone_points_iso_of_nat_iso {F G : J ⥤ C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) : s.X ≅ t.X :=\n{ hom := Q.map s w.hom,\n  inv := P.map t w.inv,\n  hom_inv_id' := P.hom_ext (by tidy),\n  inv_hom_id' := Q.hom_ext (by tidy), }\n\n@[reassoc]\nlemma cone_points_iso_of_nat_iso_hom_comp {F G : J ⥤ C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).hom ≫ t.π.app j = s.π.app j ≫ w.hom.app j :=\nby simp\n\n@[reassoc]\nlemma cone_points_iso_of_nat_iso_inv_comp {F G : J ⥤ C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).inv ≫ s.π.app j = t.π.app j ≫ w.inv.app j :=\nby simp\n\n@[reassoc]\nlemma lift_comp_cone_points_iso_of_nat_iso_hom {F G : J ⥤ C} {r s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) :\n  P.lift r ≫ (cone_points_iso_of_nat_iso P Q w).hom = Q.map r w.hom :=\nQ.hom_ext (by simp)\n\nsection equivalence\nopen category_theory.equivalence\n\n/--\nIf `s : cone F` is a limit cone, so is `s` whiskered by an equivalence `e`.\n-/\ndef whisker_equivalence {s : cone F} (P : is_limit s) (e : K ≌ J) :\n  is_limit (s.whisker e.functor) :=\nof_right_adjoint (cones.whiskering_equivalence e).functor P\n\n/--\nWe can prove two cone points `(s : cone F).X` and `(t.cone F).X` are isomorphic if\n* both cones are limit cones\n* their indexing categories are equivalent via some `e : J ≌ K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor ⋙ G ≅ F`.\n\nThis is the most general form of uniqueness of cone points,\nallowing relabelling of both the indexing category (up to equivalence)\nand the functor (up to natural isomorphism).\n-/\n@[simps]\ndef cone_points_iso_of_equivalence {F : J ⥤ C} {s : cone F} {G : K ⥤ C} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (e : J ≌ K) (w : e.functor ⋙ G ≅ F) : s.X ≅ t.X :=\nlet w' : e.inverse ⋙ F ≅ G := (iso_whisker_left e.inverse w).symm ≪≫ inv_fun_id_assoc e G in\n{ hom := Q.lift ((cones.equivalence_of_reindexing e.symm w').functor.obj s),\n  inv := P.lift ((cones.equivalence_of_reindexing e w).functor.obj t),\n  hom_inv_id' :=\n  begin\n    apply hom_ext P, intros j,\n    dsimp,\n    simp only [limits.cone.whisker_π, limits.cones.postcompose_obj_π, fac, whisker_left_app,\n      assoc, id_comp, inv_fun_id_assoc_hom_app, fac_assoc, nat_trans.comp_app],\n    rw [counit_app_functor, ←functor.comp_map, w.hom.naturality],\n    simp,\n  end,\n  inv_hom_id' := by { apply hom_ext Q, tidy, }, }\n\nend equivalence\n\n/-- The universal property of a limit cone: a map `W ⟶ X` is the same as\n  a cone on `F` with vertex `W`. -/\ndef hom_iso (h : is_limit t) (W : C) : (W ⟶ t.X) ≅ ((const J).obj W ⟶ F) :=\n{ hom := λ f, (t.extend f).π,\n  inv := λ π, h.lift { X := W, π := π },\n  hom_inv_id' := by ext f; apply h.hom_ext; intro j; simp; dsimp; refl }\n\n@[simp] lemma hom_iso_hom (h : is_limit t) {W : C} (f : W ⟶ t.X) :\n  (is_limit.hom_iso h W).hom f = (t.extend f).π := rfl\n\n/-- The limit of `F` represents the functor taking `W` to\n  the set of cones on `F` with vertex `W`. -/\ndef nat_iso (h : is_limit t) : yoneda.obj t.X ≅ F.cones :=\nnat_iso.of_components (λ W, is_limit.hom_iso h (unop W)) (by tidy).\n\n/--\nAnother, more explicit, formulation of the universal property of a limit cone.\nSee also `hom_iso`.\n-/\ndef hom_iso' (h : is_limit t) (W : C) :\n  ((W ⟶ t.X) : Type v) ≅ { p : Π j, W ⟶ F.obj j // ∀ {j j'} (f : j ⟶ j'), p j ≫ F.map f = p j' } :=\nh.hom_iso W ≪≫\n{ hom := λ π,\n  ⟨λ j, π.app j, λ j j' f,\n   by convert ←(π.naturality f).symm; apply id_comp⟩,\n  inv := λ p,\n  { app := λ j, p.1 j,\n    naturality' := λ j j' f, begin dsimp, rw [id_comp], exact (p.2 f).symm end } }\n\n/-- If G : C → D is a faithful functor which sends t to a limit cone,\n  then it suffices to check that the induced maps for the image of t\n  can be lifted to maps of C. -/\ndef of_faithful {t : cone F} {D : Type u'} [category.{v} D] (G : C ⥤ D) [faithful G]\n  (ht : is_limit (G.map_cone t)) (lift : Π (s : cone F), s.X ⟶ t.X)\n  (h : ∀ s, G.map (lift s) = ht.lift (G.map_cone s)) : is_limit t :=\n{ lift := lift,\n  fac' := λ s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := λ s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cone s) _ (λ j, _),\n    convert ←congr_arg (λ f, G.map f) (w j),\n    apply G.map_comp\n  end }\n\n/--\nIf `F` and `G` are naturally isomorphic, then `F.map_cone c` being a limit implies\n`G.map_cone c` is also a limit.\n-/\ndef map_cone_equiv {D : Type u'} [category.{v} D] {K : J ⥤ C} {F G : C ⥤ D} (h : F ≅ G) {c : cone K}\n  (t : is_limit (F.map_cone c)) : is_limit (G.map_cone c) :=\nbegin\n  apply postcompose_inv_equiv (iso_whisker_left K h : _) (G.map_cone c) _,\n  apply t.of_iso_limit (postcompose_whisker_left_map_cone h.symm c).symm,\nend\n\n/--\nA cone is a limit cone exactly if\nthere is a unique cone morphism from any other cone.\n-/\ndef iso_unique_cone_morphism {t : cone F} :\n  is_limit t ≅ Π s, unique (s ⟶ t) :=\n{ hom := λ h s,\n  { default := h.lift_cone_morphism s,\n    uniq := λ _, h.uniq_cone_morphism },\n  inv := λ h,\n  { lift := λ s, (h s).default.hom,\n    uniq' := λ s f w, congr_arg cone_morphism.hom ((h s).uniq ⟨f, w⟩) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : yoneda.obj X ≅ F.cones)\n\n/-- If `F.cones` is represented by `X`, each morphism `f : Y ⟶ X` gives a cone with cone point\n`Y`. -/\ndef cone_of_hom {Y : C} (f : Y ⟶ X) : cone F :=\n{ X := Y, π := h.hom.app (op Y) f }\n\n/-- If `F.cones` is represented by `X`, each cone `s` gives a morphism `s.X ⟶ X`. -/\ndef hom_of_cone (s : cone F) : s.X ⟶ X := h.inv.app (op s.X) s.π\n\n@[simp] lemma cone_of_hom_of_cone (s : cone F) : cone_of_hom h (hom_of_cone h s) = s :=\nbegin\n  dsimp [cone_of_hom, hom_of_cone], cases s, congr, dsimp,\n  exact congr_fun (congr_fun (congr_arg nat_trans.app h.inv_hom_id) (op s_X)) s_π,\nend\n\n@[simp] lemma hom_of_cone_of_hom {Y : C} (f : Y ⟶ X) : hom_of_cone h (cone_of_hom h f) = f :=\ncongr_fun (congr_fun (congr_arg nat_trans.app h.hom_inv_id) (op Y)) f\n\n/-- If `F.cones` is represented by `X`, the cone corresponding to the identity morphism on `X`\nwill be a limit cone. -/\ndef limit_cone : cone F :=\ncone_of_hom h (𝟙 X)\n\n/-- If `F.cones` is represented by `X`, the cone corresponding to a morphism `f : Y ⟶ X` is\nthe limit cone extended by `f`. -/\nlemma cone_of_hom_fac {Y : C} (f : Y ⟶ X) :\ncone_of_hom h f = (limit_cone h).extend f :=\nbegin\n  dsimp [cone_of_hom, limit_cone, cone.extend],\n  congr' with j,\n  have t := congr_fun (h.hom.naturality f.op) (𝟙 X),\n  dsimp at t,\n  simp only [comp_id] at t,\n  rw congr_fun (congr_arg nat_trans.app t) j,\n  refl,\nend\n\n/-- If `F.cones` is represented by `X`, any cone is the extension of the limit cone by the\ncorresponding morphism. -/\nlemma cone_fac (s : cone F) : (limit_cone h).extend (hom_of_cone h s) = s :=\nbegin\n  rw ←cone_of_hom_of_cone h s,\n  conv_lhs { simp only [hom_of_cone_of_hom] },\n  apply (cone_of_hom_fac _ _).symm,\nend\n\nend of_nat_iso\n\nsection\nopen of_nat_iso\n\n/--\nIf `F.cones` is representable, then the cone corresponding to the identity morphism on\nthe representing object is a limit cone.\n-/\ndef of_nat_iso {X : C} (h : yoneda.obj X ≅ F.cones) :\n  is_limit (limit_cone h) :=\n{ lift := λ s, hom_of_cone h s,\n  fac' := λ s j,\n  begin\n    have h := cone_fac h s,\n    cases s,\n    injection h with h₁ h₂,\n    simp only [heq_iff_eq] at h₂,\n    conv_rhs { rw ← h₂ }, refl,\n  end,\n  uniq' := λ s m w,\n  begin\n    rw ←hom_of_cone_of_hom h m,\n    congr,\n    rw cone_of_hom_fac,\n    dsimp [cone.extend], cases s, congr' with j, exact w j,\n  end }\nend\n\nend is_limit\n\n/--\nA cocone `t` on `F` is a colimit cocone if each cocone on `F` admits a unique\ncocone morphism from `t`.\n\nSee https://stacks.math.columbia.edu/tag/002F.\n-/\n@[nolint has_inhabited_instance]\nstructure is_colimit (t : cocone F) :=\n(desc  : Π (s : cocone F), t.X ⟶ s.X)\n(fac'  : ∀ (s : cocone F) (j : J), t.ι.app j ≫ desc s = s.ι.app j . obviously)\n(uniq' : ∀ (s : cocone F) (m : t.X ⟶ s.X) (w : ∀ j : J, t.ι.app j ≫ m = s.ι.app j),\n  m = desc s . obviously)\n\nrestate_axiom is_colimit.fac'\nattribute [simp,reassoc] is_colimit.fac\nrestate_axiom is_colimit.uniq'\n\nnamespace is_colimit\n\ninstance subsingleton {t : cocone F} : subsingleton (is_colimit t) :=\n⟨by intros P Q; cases P; cases Q; congr; ext; solve_by_elim⟩\n\n/-- Given a natural transformation `α : F ⟶ G`, we give a morphism from the cocone point\nof a colimit cocone over `F` to the cocone point of any cocone over `G`. -/\ndef map {F G : J ⥤ C} {s : cocone F} (P : is_colimit s) (t : cocone G)\n  (α : F ⟶ G) : s.X ⟶ t.X :=\nP.desc ((cocones.precompose α).obj t)\n\n@[simp, reassoc]\nlemma ι_map {F G : J ⥤ C} {c : cocone F} (hc : is_colimit c) (d : cocone G) (α : F ⟶ G)\n  (j : J) : c.ι.app j ≫ is_colimit.map hc d α = α.app j ≫ d.ι.app j :=\nfac _ _ _\n\n@[simp]\nlemma desc_self {t : cocone F} (h : is_colimit t) : h.desc t = 𝟙 t.X :=\n(h.uniq _ _ (λ j, comp_id _)).symm\n\n/- Repackaging the definition in terms of cocone morphisms. -/\n\n/-- The universal morphism from a colimit cocone to any other cocone. -/\n@[simps]\ndef desc_cocone_morphism {t : cocone F} (h : is_colimit t) (s : cocone F) : t ⟶ s :=\n{ hom := h.desc s }\n\nlemma uniq_cocone_morphism {s t : cocone F} (h : is_colimit t) {f f' : t ⟶ s} :\n  f = f' :=\nhave ∀ {g : t ⟶ s}, g = h.desc_cocone_morphism s, by intro g; ext; exact h.uniq _ _ g.w,\nthis.trans this.symm\n\n/--\nAlternative constructor for `is_colimit`,\nproviding a morphism of cocones rather than a morphism between the cocone points\nand separately the factorisation condition.\n-/\n@[simps]\ndef mk_cocone_morphism {t : cocone F}\n  (desc : Π (s : cocone F), t ⟶ s)\n  (uniq' : ∀ (s : cocone F) (m : t ⟶ s), m = desc s) : is_colimit t :=\n{ desc := λ s, (desc s).hom,\n  uniq' := λ s m w,\n    have cocone_morphism.mk m w = desc s, by apply uniq',\n    congr_arg cocone_morphism.hom this }\n\n/-- Colimit cocones on `F` are unique up to isomorphism. -/\n@[simps]\ndef unique_up_to_iso {s t : cocone F} (P : is_colimit s) (Q : is_colimit t) : s ≅ t :=\n{ hom := P.desc_cocone_morphism t,\n  inv := Q.desc_cocone_morphism s,\n  hom_inv_id' := P.uniq_cocone_morphism,\n  inv_hom_id' := Q.uniq_cocone_morphism }\n\n/-- Any cocone morphism between colimit cocones is an isomorphism. -/\nlemma hom_is_iso {s t : cocone F} (P : is_colimit s) (Q : is_colimit t) (f : s ⟶ t) : is_iso f :=\n⟨⟨Q.desc_cocone_morphism s, ⟨P.uniq_cocone_morphism, Q.uniq_cocone_morphism⟩⟩⟩\n\n/-- Colimits of `F` are unique up to isomorphism. -/\ndef cocone_point_unique_up_to_iso {s t : cocone F} (P : is_colimit s) (Q : is_colimit t) :\n  s.X ≅ t.X :=\n(cocones.forget F).map_iso (unique_up_to_iso P Q)\n\n@[simp, reassoc] lemma comp_cocone_point_unique_up_to_iso_hom {s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) (j : J) : s.ι.app j ≫ (cocone_point_unique_up_to_iso P Q).hom = t.ι.app j :=\n(unique_up_to_iso P Q).hom.w _\n\n@[simp, reassoc] lemma comp_cocone_point_unique_up_to_iso_inv {s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) (j : J) : t.ι.app j ≫ (cocone_point_unique_up_to_iso P Q).inv = s.ι.app j :=\n(unique_up_to_iso P Q).inv.w _\n\n@[simp, reassoc] lemma cocone_point_unique_up_to_iso_hom_desc {r s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) : (cocone_point_unique_up_to_iso P Q).hom ≫ Q.desc r = P.desc r :=\nP.uniq _ _ (by simp)\n\n@[simp, reassoc] lemma cocone_point_unique_up_to_iso_inv_desc {r s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) : (cocone_point_unique_up_to_iso P Q).inv ≫ P.desc r = Q.desc r :=\nQ.uniq _ _ (by simp)\n\n/-- Transport evidence that a cocone is a colimit cocone across an isomorphism of cocones. -/\ndef of_iso_colimit {r t : cocone F} (P : is_colimit r) (i : r ≅ t) : is_colimit t :=\nis_colimit.mk_cocone_morphism\n  (λ s, i.inv ≫ P.desc_cocone_morphism s)\n  (λ s m, by rw i.eq_inv_comp; apply P.uniq_cocone_morphism)\n\n@[simp] lemma of_iso_colimit_desc {r t : cocone F} (P : is_colimit r) (i : r ≅ t) (s) :\n  (P.of_iso_colimit i).desc s = i.inv.hom ≫ P.desc s :=\nrfl\n\n/-- Isomorphism of cocones preserves whether or not they are colimiting cocones. -/\ndef equiv_iso_colimit {r t : cocone F} (i : r ≅ t) : is_colimit r ≃ is_colimit t :=\n{ to_fun := λ h, h.of_iso_colimit i,\n  inv_fun := λ h, h.of_iso_colimit i.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\n@[simp] lemma equiv_iso_colimit_apply {r t : cocone F} (i : r ≅ t) (P : is_colimit r) :\n  equiv_iso_colimit i P = P.of_iso_colimit i := rfl\n\n@[simp] lemma equiv_iso_colimit_symm_apply {r t : cocone F} (i : r ≅ t) (P : is_colimit t) :\n  (equiv_iso_colimit i).symm P = P.of_iso_colimit i.symm := rfl\n\n/--\nIf the canonical morphism to a cocone point from a colimiting cocone point is an iso, then the\nfirst cocone was colimiting also.\n-/\ndef of_point_iso {r t : cocone F} (P : is_colimit r) [i : is_iso (P.desc t)] : is_colimit t :=\nof_iso_colimit P\nbegin\n  haveI : is_iso (P.desc_cocone_morphism t).hom := i,\n  haveI : is_iso (P.desc_cocone_morphism t) := cocones.cocone_iso_of_hom_iso _,\n  apply as_iso (P.desc_cocone_morphism t),\nend\n\nvariables {t : cocone F}\n\nlemma hom_desc (h : is_colimit t) {W : C} (m : t.X ⟶ W) :\n  m = h.desc { X := W, ι := { app := λ b, t.ι.app b ≫ m,\n    naturality' := by intros; erw [←assoc, t.ι.naturality, comp_id, comp_id] } } :=\nh.uniq { X := W, ι := { app := λ b, t.ι.app b ≫ m, naturality' := _ } } m (λ b, rfl)\n\n/-- Two morphisms out of a colimit are equal if their compositions with\n  each cocone morphism are equal. -/\nlemma hom_ext (h : is_colimit t) {W : C} {f f' : t.X ⟶ W}\n  (w : ∀ j, t.ι.app j ≫ f = t.ι.app j ≫ f') : f = f' :=\nby rw [h.hom_desc f, h.hom_desc f']; congr; exact funext w\n\n/--\nGiven a left adjoint functor between categories of cocones,\nthe image of a colimit cocone is a colimit cocone.\n-/\ndef of_left_adjoint {D : Type u'} [category.{v} D] {G : K ⥤ D}\n  (h : cocone G ⥤ cocone F) [is_left_adjoint h] {c : cocone G} (t : is_colimit c) :\n  is_colimit (h.obj c) :=\nmk_cocone_morphism\n  (λ s, ((adjunction.of_left_adjoint h).hom_equiv c s).symm (t.desc_cocone_morphism _))\n  (λ s m, (adjunction.hom_equiv_apply_eq _ _ _).1 t.uniq_cocone_morphism)\n\n/--\nGiven two functors which have equivalent categories of cocones,\nwe can transport a colimiting cocone across the equivalence.\n-/\ndef of_cocone_equiv {D : Type u'} [category.{v} D] {G : K ⥤ D}\n  (h : cocone G ≌ cocone F) {c : cocone G} :\n  is_colimit (h.functor.obj c) ≃ is_colimit c :=\n{ to_fun := λ P, of_iso_colimit (of_left_adjoint h.inverse P) (h.unit_iso.symm.app c),\n  inv_fun := of_left_adjoint h.functor,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\n@[simp] lemma of_cocone_equiv_apply_desc {D : Type u'} [category.{v} D] {G : K ⥤ D}\n  (h : cocone G ≌ cocone F) {c : cocone G} (P : is_colimit (h.functor.obj c)) (s) :\n  (of_cocone_equiv h P).desc s =\n    (h.unit.app c).hom ≫\n    (h.inverse.map (P.desc_cocone_morphism (h.functor.obj s))).hom ≫\n    (h.unit_inv.app s).hom :=\nrfl\n\n@[simp] lemma of_cocone_equiv_symm_apply_desc {D : Type u'} [category.{v} D] {G : K ⥤ D}\n  (h : cocone G ≌ cocone F) {c : cocone G} (P : is_colimit c) (s) :\n  ((of_cocone_equiv h).symm P).desc s =\n    (h.functor.map (P.desc_cocone_morphism (h.inverse.obj s))).hom ≫ (h.counit.app s).hom :=\nrfl\n\n/--\nA cocone precomposed with a natural isomorphism is a colimit cocone\nif and only if the original cocone is.\n-/\ndef precompose_hom_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cocone G) :\n  is_colimit ((cocones.precompose α.hom).obj c) ≃ is_colimit c :=\nof_cocone_equiv (cocones.precompose_equivalence α)\n\n/--\nA cocone precomposed with the inverse of a natural isomorphism is a colimit cocone\nif and only if the original cocone is.\n-/\ndef precompose_inv_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cocone F) :\n  is_colimit ((cocones.precompose α.inv).obj c) ≃ is_colimit c :=\nprecompose_hom_equiv α.symm c\n\n/--\nThe cocone points of two colimit cocones for naturally isomorphic functors\nare themselves isomorphic.\n-/\n@[simps]\ndef cocone_points_iso_of_nat_iso {F G : J ⥤ C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) : s.X ≅ t.X :=\n{ hom := P.map t w.hom,\n  inv := Q.map s w.inv,\n  hom_inv_id' := P.hom_ext (by tidy),\n  inv_hom_id' := Q.hom_ext (by tidy) }\n\n@[reassoc]\nlemma comp_cocone_points_iso_of_nat_iso_hom {F G : J ⥤ C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) (j : J) :\n  s.ι.app j ≫ (cocone_points_iso_of_nat_iso P Q w).hom = w.hom.app j ≫ t.ι.app j :=\nby simp\n\n@[reassoc]\nlemma comp_cocone_points_iso_of_nat_iso_inv {F G : J ⥤ C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) (j : J) :\n  t.ι.app j ≫ (cocone_points_iso_of_nat_iso P Q w).inv = w.inv.app j ≫ s.ι.app j :=\nby simp\n\n@[reassoc]\nlemma cocone_points_iso_of_nat_iso_hom_desc {F G : J ⥤ C} {s : cocone F} {r t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) :\n  (cocone_points_iso_of_nat_iso P Q w).hom ≫ Q.desc r = P.map _ w.hom :=\nP.hom_ext (by simp)\n\nsection equivalence\nopen category_theory.equivalence\n\n/--\nIf `s : cone F` is a limit cone, so is `s` whiskered by an equivalence `e`.\n-/\ndef whisker_equivalence {s : cocone F} (P : is_colimit s) (e : K ≌ J) :\n  is_colimit (s.whisker e.functor) :=\nof_left_adjoint (cocones.whiskering_equivalence e).functor P\n\n/--\nWe can prove two cocone points `(s : cocone F).X` and `(t.cocone F).X` are isomorphic if\n* both cocones are colimit ccoones\n* their indexing categories are equivalent via some `e : J ≌ K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor ⋙ G ≅ F`.\n\nThis is the most general form of uniqueness of cocone points,\nallowing relabelling of both the indexing category (up to equivalence)\nand the functor (up to natural isomorphism).\n-/\n@[simps]\ndef cocone_points_iso_of_equivalence {F : J ⥤ C} {s : cocone F} {G : K ⥤ C} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (e : J ≌ K) (w : e.functor ⋙ G ≅ F) : s.X ≅ t.X :=\nlet w' : e.inverse ⋙ F ≅ G := (iso_whisker_left e.inverse w).symm ≪≫ inv_fun_id_assoc e G in\n{ hom := P.desc ((cocones.equivalence_of_reindexing e w).functor.obj t),\n  inv := Q.desc ((cocones.equivalence_of_reindexing e.symm w').functor.obj s),\n  hom_inv_id' :=\n  begin\n    apply hom_ext P, intros j,\n    dsimp,\n    simp only [limits.cocone.whisker_ι, fac, inv_fun_id_assoc_inv_app, whisker_left_app, assoc,\n      comp_id, limits.cocones.precompose_obj_ι, fac_assoc, nat_trans.comp_app],\n    rw [counit_inv_app_functor, ←functor.comp_map, ←w.inv.naturality_assoc],\n    dsimp,\n    simp,\n  end,\n  inv_hom_id' := by { apply hom_ext Q, tidy, }, }\n\nend equivalence\n\n/-- The universal property of a colimit cocone: a map `X ⟶ W` is the same as\n  a cocone on `F` with vertex `W`. -/\ndef hom_iso (h : is_colimit t) (W : C) : (t.X ⟶ W) ≅ (F ⟶ (const J).obj W) :=\n{ hom := λ f, (t.extend f).ι,\n  inv := λ ι, h.desc { X := W, ι := ι },\n  hom_inv_id' := by ext f; apply h.hom_ext; intro j; simp; dsimp; refl }\n\n@[simp] lemma hom_iso_hom (h : is_colimit t) {W : C} (f : t.X ⟶ W) :\n  (is_colimit.hom_iso h W).hom f = (t.extend f).ι := rfl\n\n/-- The colimit of `F` represents the functor taking `W` to\n  the set of cocones on `F` with vertex `W`. -/\ndef nat_iso (h : is_colimit t) : coyoneda.obj (op t.X) ≅ F.cocones :=\nnat_iso.of_components (is_colimit.hom_iso h) (by intros; ext; dsimp; rw ←assoc; refl)\n\n/--\nAnother, more explicit, formulation of the universal property of a colimit cocone.\nSee also `hom_iso`.\n-/\ndef hom_iso' (h : is_colimit t) (W : C) :\n  ((t.X ⟶ W) : Type v) ≅\n    { p : Π j, F.obj j ⟶ W // ∀ {j j' : J} (f : j ⟶ j'), F.map f ≫ p j' = p j } :=\nh.hom_iso W ≪≫\n{ hom := λ ι,\n  ⟨λ j, ι.app j, λ j j' f,\n   by convert ←(ι.naturality f); apply comp_id⟩,\n  inv := λ p,\n  { app := λ j, p.1 j,\n    naturality' := λ j j' f, begin dsimp, rw [comp_id], exact (p.2 f) end } }\n\n/-- If G : C → D is a faithful functor which sends t to a colimit cocone,\n  then it suffices to check that the induced maps for the image of t\n  can be lifted to maps of C. -/\ndef of_faithful {t : cocone F} {D : Type u'} [category.{v} D] (G : C ⥤ D) [faithful G]\n  (ht : is_colimit (G.map_cocone t)) (desc : Π (s : cocone F), t.X ⟶ s.X)\n  (h : ∀ s, G.map (desc s) = ht.desc (G.map_cocone s)) : is_colimit t :=\n{ desc := desc,\n  fac' := λ s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := λ s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cocone s) _ (λ j, _),\n    convert ←congr_arg (λ f, G.map f) (w j),\n    apply G.map_comp\n  end }\n\n/--\nIf `F` and `G` are naturally isomorphic, then `F.map_cone c` being a colimit implies\n`G.map_cone c` is also a colimit.\n-/\ndef map_cocone_equiv {D : Type u'} [category.{v} D] {K : J ⥤ C} {F G : C ⥤ D} (h : F ≅ G)\n  {c : cocone K} (t : is_colimit (F.map_cocone c)) : is_colimit (G.map_cocone c) :=\nbegin\n  apply is_colimit.of_iso_colimit _ (precompose_whisker_left_map_cocone h c),\n  apply (precompose_inv_equiv (iso_whisker_left K h : _) _).symm t,\nend\n\n/--\nA cocone is a colimit cocone exactly if\nthere is a unique cocone morphism from any other cocone.\n-/\ndef iso_unique_cocone_morphism {t : cocone F} :\n  is_colimit t ≅ Π s, unique (t ⟶ s) :=\n{ hom := λ h s,\n  { default := h.desc_cocone_morphism s,\n    uniq := λ _, h.uniq_cocone_morphism },\n  inv := λ h,\n  { desc := λ s, (h s).default.hom,\n    uniq' := λ s f w, congr_arg cocone_morphism.hom ((h s).uniq ⟨f, w⟩) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : coyoneda.obj (op X) ≅ F.cocones)\n\n/-- If `F.cocones` is corepresented by `X`, each morphism `f : X ⟶ Y` gives a cocone with cone\npoint `Y`. -/\ndef cocone_of_hom {Y : C} (f : X ⟶ Y) : cocone F :=\n{ X := Y, ι := h.hom.app Y f }\n\n/-- If `F.cocones` is corepresented by `X`, each cocone `s` gives a morphism `X ⟶ s.X`. -/\ndef hom_of_cocone (s : cocone F) : X ⟶ s.X := h.inv.app s.X s.ι\n\n@[simp] lemma cocone_of_hom_of_cocone (s : cocone F) : cocone_of_hom h (hom_of_cocone h s) = s :=\nbegin\n  dsimp [cocone_of_hom, hom_of_cocone], cases s, congr, dsimp,\n  exact congr_fun (congr_fun (congr_arg nat_trans.app h.inv_hom_id) s_X) s_ι,\nend\n\n@[simp] lemma hom_of_cocone_of_hom {Y : C} (f : X ⟶ Y) : hom_of_cocone h (cocone_of_hom h f) = f :=\ncongr_fun (congr_fun (congr_arg nat_trans.app h.hom_inv_id) Y) f\n\n/-- If `F.cocones` is corepresented by `X`, the cocone corresponding to the identity morphism on `X`\nwill be a colimit cocone. -/\ndef colimit_cocone : cocone F :=\ncocone_of_hom h (𝟙 X)\n\n/-- If `F.cocones` is corepresented by `X`, the cocone corresponding to a morphism `f : Y ⟶ X` is\nthe colimit cocone extended by `f`. -/\nlemma cocone_of_hom_fac {Y : C} (f : X ⟶ Y) :\ncocone_of_hom h f = (colimit_cocone h).extend f :=\nbegin\n  dsimp [cocone_of_hom, colimit_cocone, cocone.extend],\n  congr' with j,\n  have t := congr_fun (h.hom.naturality f) (𝟙 X),\n  dsimp at t,\n  simp only [id_comp] at t,\n  rw congr_fun (congr_arg nat_trans.app t) j,\n  refl,\nend\n\n/-- If `F.cocones` is corepresented by `X`, any cocone is the extension of the colimit cocone by the\ncorresponding morphism. -/\nlemma cocone_fac (s : cocone F) : (colimit_cocone h).extend (hom_of_cocone h s) = s :=\nbegin\n  rw ←cocone_of_hom_of_cocone h s,\n  conv_lhs { simp only [hom_of_cocone_of_hom] },\n  apply (cocone_of_hom_fac _ _).symm,\nend\n\nend of_nat_iso\n\nsection\nopen of_nat_iso\n\n/--\nIf `F.cocones` is corepresentable, then the cocone corresponding to the identity morphism on\nthe representing object is a colimit cocone.\n-/\ndef of_nat_iso {X : C} (h : coyoneda.obj (op X) ≅ F.cocones) :\n  is_colimit (colimit_cocone h) :=\n{ desc := λ s, hom_of_cocone h s,\n  fac' := λ s j,\n  begin\n    have h := cocone_fac h s,\n    cases s,\n    injection h with h₁ h₂,\n    simp only [heq_iff_eq] at h₂,\n    conv_rhs { rw ← h₂ }, refl,\n  end,\n  uniq' := λ s m w,\n  begin\n    rw ←hom_of_cocone_of_hom h m,\n    congr,\n    rw cocone_of_hom_fac,\n    dsimp [cocone.extend], cases s, congr' with j, exact w j,\n  end }\nend\n\nend is_colimit\n\nend category_theory.limits\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/is_limit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.721743206297598, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4777383387377017}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Yury Kudryashov\n\n! This file was ported from Lean 3 source module algebra.algebra.prod\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Hom\n\n/-!\n# The R-algebra structure on products of R-algebras\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe R-algebra structure on `Π i : I, A i` when each `A i` is an R-algebra.\n\n## Main defintions\n\n* `pi.algebra`\n* `pi.eval_alg_hom`\n* `pi.const_alg_hom`\n-/\n\n\nvariable {R A B C : Type _}\n\nvariable [CommSemiring R]\n\nvariable [Semiring A] [Algebra R A] [Semiring B] [Algebra R B] [Semiring C] [Algebra R C]\n\nnamespace Prod\n\nvariable (R A B)\n\nopen Algebra\n\n/- warning: prod.algebra -> Prod.algebra is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4], Algebra.{u1, max u2 u3} R (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4)\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4], Algebra.{u1, max u3 u2} R (Prod.{u2, u3} A B) _inst_1 (Prod.instSemiringProd.{u2, u3} A B _inst_2 _inst_4)\nCase conversion may be inaccurate. Consider using '#align prod.algebra Prod.algebraₓ'. -/\ninstance algebra : Algebra R (A × B) :=\n  { Prod.module,\n    RingHom.prod (algebraMap R A)\n      (algebraMap R\n        B) with\n    commutes' := by\n      rintro r ⟨a, b⟩\n      dsimp\n      rw [commutes r a, commutes r b]\n    smul_def' := by\n      rintro r ⟨a, b⟩\n      dsimp\n      rw [Algebra.smul_def r a, Algebra.smul_def r b] }\n#align prod.algebra Prod.algebra\n\nvariable {R A B}\n\n/- warning: prod.algebra_map_apply -> Prod.algebraMap_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] (r : R), Eq.{max (succ u2) (succ u3)} (Prod.{u2, u3} A B) (coeFn.{max (succ u1) (succ (max u2 u3)), max (succ u1) (succ (max u2 u3))} (RingHom.{u1, max u2 u3} R (Prod.{u2, u3} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u2, u3} A B) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4))) (fun (_x : RingHom.{u1, max u2 u3} R (Prod.{u2, u3} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u2, u3} A B) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4))) => R -> (Prod.{u2, u3} A B)) (RingHom.hasCoeToFun.{u1, max u2 u3} R (Prod.{u2, u3} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u2, u3} A B) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4))) (algebraMap.{u1, max u2 u3} R (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) r) (Prod.mk.{u2, u3} A B (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_3) r) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_4)) (fun (_x : RingHom.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_4)) => R -> B) (RingHom.hasCoeToFun.{u1, u3} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} B _inst_4)) (algebraMap.{u1, u3} R B _inst_1 _inst_4 _inst_5) r))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u3}} {B : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u1, u3} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u2} B] [_inst_5 : Algebra.{u1, u2} R B _inst_1 _inst_4] (r : R), Eq.{max (succ u3) (succ u2)} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Prod.{u3, u2} A B) r) (FunLike.coe.{max (max (succ u1) (succ u3)) (succ u2), succ u1, max (succ u3) (succ u2)} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Prod.{u3, u2} A B) _x) (MulHomClass.toFunLike.{max (max u1 u3) u2, u1, max u3 u2} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4))) R (Prod.{u3, u2} A B) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{max u3 u2} (Prod.{u3, u2} A B) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u2} (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4)))) (NonUnitalRingHomClass.toMulHomClass.{max (max u1 u3) u2, u1, max u3 u2} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4))) R (Prod.{u3, u2} A B) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u2} (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4))) (RingHomClass.toNonUnitalRingHomClass.{max (max u1 u3) u2, u1, max u3 u2} (RingHom.{u1, max u2 u3} R (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4))) R (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4)) (RingHom.instRingHomClassRingHom.{u1, max u3 u2} R (Prod.{u3, u2} A B) (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u3} (Prod.{u3, u2} A B) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4)))))) (algebraMap.{u1, max u2 u3} R (Prod.{u3, u2} A B) _inst_1 (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) r) (Prod.mk.{u3, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => B) r) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_2)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_2)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_2)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_2) (RingHom.instRingHomClassRingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (algebraMap.{u1, u3} R A _inst_1 _inst_2 _inst_3) r) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} B _inst_4)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => B) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} B _inst_4)) R B (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} B _inst_4)) R B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} B _inst_4)) R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} B _inst_4) (RingHom.instRingHomClassRingHom.{u1, u2} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} B _inst_4))))) (algebraMap.{u1, u2} R B _inst_1 _inst_4 _inst_5) r))\nCase conversion may be inaccurate. Consider using '#align prod.algebra_map_apply Prod.algebraMap_applyₓ'. -/\n@[simp]\ntheorem algebraMap_apply (r : R) : algebraMap R (A × B) r = (algebraMap R A r, algebraMap R B r) :=\n  rfl\n#align prod.algebra_map_apply Prod.algebraMap_apply\n\nend Prod\n\nnamespace AlgHom\n\nvariable (R A B)\n\n/- warning: alg_hom.fst -> AlgHom.fst is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4], AlgHom.{u1, max u2 u3, u2} R (Prod.{u2, u3} A B) A _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) _inst_2 (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) _inst_3\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4], AlgHom.{u1, max u3 u2, u2} R (Prod.{u2, u3} A B) A _inst_1 (Prod.instSemiringProd.{u2, u3} A B _inst_2 _inst_4) _inst_2 (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) _inst_3\nCase conversion may be inaccurate. Consider using '#align alg_hom.fst AlgHom.fstₓ'. -/\n/-- First projection as `alg_hom`. -/\ndef fst : A × B →ₐ[R] A :=\n  { RingHom.fst A B with commutes' := fun r => rfl }\n#align alg_hom.fst AlgHom.fst\n\n/- warning: alg_hom.snd -> AlgHom.snd is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4], AlgHom.{u1, max u2 u3, u3} R (Prod.{u2, u3} A B) B _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) _inst_4 (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) _inst_5\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4], AlgHom.{u1, max u3 u2, u3} R (Prod.{u2, u3} A B) B _inst_1 (Prod.instSemiringProd.{u2, u3} A B _inst_2 _inst_4) _inst_4 (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) _inst_5\nCase conversion may be inaccurate. Consider using '#align alg_hom.snd AlgHom.sndₓ'. -/\n/-- Second projection as `alg_hom`. -/\ndef snd : A × B →ₐ[R] B :=\n  { RingHom.snd A B with commutes' := fun r => rfl }\n#align alg_hom.snd AlgHom.snd\n\nvariable {R A B}\n\n/- warning: alg_hom.prod -> AlgHom.prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u4} C] [_inst_7 : Algebra.{u1, u4} R C _inst_1 _inst_6], (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) -> (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) -> (AlgHom.{u1, u2, max u3 u4} R A (Prod.{u3, u4} B C) _inst_1 _inst_2 (Prod.semiring.{u3, u4} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u4} C] [_inst_7 : Algebra.{u1, u4} R C _inst_1 _inst_6], (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) -> (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) -> (AlgHom.{u1, u2, max u4 u3} R A (Prod.{u3, u4} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u3, u4} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7))\nCase conversion may be inaccurate. Consider using '#align alg_hom.prod AlgHom.prodₓ'. -/\n/-- The `pi.prod` of two morphisms is a morphism. -/\n@[simps]\ndef prod (f : A →ₐ[R] B) (g : A →ₐ[R] C) : A →ₐ[R] B × C :=\n  { f.toRingHom.Prod g.toRingHom with\n    commutes' := fun r => by\n      simp only [to_ring_hom_eq_coe, RingHom.toFun_eq_coe, RingHom.prod_apply, coe_to_ring_hom,\n        commutes, Prod.algebraMap_apply] }\n#align alg_hom.prod AlgHom.prod\n\n/- warning: alg_hom.coe_prod -> AlgHom.coe_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u4} C] [_inst_7 : Algebra.{u1, u4} R C _inst_1 _inst_6] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (g : AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7), Eq.{max (succ u2) (succ (max u3 u4))} (A -> (Prod.{u3, u4} B C)) (coeFn.{max (succ u2) (succ (max u3 u4)), max (succ u2) (succ (max u3 u4))} (AlgHom.{u1, u2, max u3 u4} R A (Prod.{u3, u4} B C) _inst_1 _inst_2 (Prod.semiring.{u3, u4} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) (fun (_x : AlgHom.{u1, u2, max u3 u4} R A (Prod.{u3, u4} B C) _inst_1 _inst_2 (Prod.semiring.{u3, u4} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) => A -> (Prod.{u3, u4} B C)) ([anonymous].{u1, u2, max u3 u4} R A (Prod.{u3, u4} B C) _inst_1 _inst_2 (Prod.semiring.{u3, u4} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) (AlgHom.prod.{u1, u2, u3, u4} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f g)) (Pi.prod.{u2, u3, u4} A (fun (ᾰ : A) => B) (fun (ᾰ : A) => C) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (fun (_x : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) => A -> B) ([anonymous].{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) f) (coeFn.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) (fun (_x : AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) => A -> C) ([anonymous].{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) g))\nbut is expected to have type\n  forall {R : Type.{u4}} {A : Type.{u3}} {B : Type.{u2}} {C : Type.{u1}} [_inst_1 : CommSemiring.{u4} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u4, u3} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u2} B] [_inst_5 : Algebra.{u4, u2} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u1} C] [_inst_7 : Algebra.{u4, u1} R C _inst_1 _inst_6] (f : AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (g : AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7), Eq.{max (max (succ u3) (succ u2)) (succ u1)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => Prod.{u2, u1} B C) ᾰ) (FunLike.coe.{max (max (succ u3) (succ u2)) (succ u1), succ u3, max (succ u2) (succ u1)} (AlgHom.{u4, u3, max u1 u2} R A (Prod.{u2, u1} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => Prod.{u2, u1} B C) _x) (SMulHomClass.toFunLike.{max (max u3 u2) u1, u4, u3, max u2 u1} (AlgHom.{u4, u3, max u1 u2} R A (Prod.{u2, u1} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) R A (Prod.{u2, u1} B C) (SMulZeroClass.toSMul.{u4, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u4, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u4, u3} R A (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u4, u3} R A (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toSMul.{u4, max u2 u1} R (Prod.{u2, u1} B C) (AddMonoid.toZero.{max u2 u1} (Prod.{u2, u1} B C) (AddCommMonoid.toAddMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Semiring.toNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6)))))) (DistribSMul.toSMulZeroClass.{u4, max u2 u1} R (Prod.{u2, u1} B C) (AddMonoid.toAddZeroClass.{max u2 u1} (Prod.{u2, u1} B C) (AddCommMonoid.toAddMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Semiring.toNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6)))))) (DistribMulAction.toDistribSMul.{u4, max u2 u1} R (Prod.{u2, u1} B C) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Semiring.toNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6))))) (Module.toDistribMulAction.{u4, max u2 u1} R (Prod.{u2, u1} B C) (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Semiring.toNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6)))) (Algebra.toModule.{u4, max u2 u1} R (Prod.{u2, u1} B C) _inst_1 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u3 u2) u1, u4, u3, max u2 u1} (AlgHom.{u4, u3, max u1 u2} R A (Prod.{u2, u1} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) R A (Prod.{u2, u1} B C) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Semiring.toNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6))))) (Module.toDistribMulAction.{u4, u3} R A (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3)) (Module.toDistribMulAction.{u4, max u2 u1} R (Prod.{u2, u1} B C) (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Semiring.toNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6)))) (Algebra.toModule.{u4, max u2 u1} R (Prod.{u2, u1} B C) _inst_1 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7))) (SemilinearMapClass.distribMulActionHomClass.{u4, u3, max u2 u1, max (max u3 u2) u1} R A (Prod.{u2, u1} B C) (AlgHom.{u4, u3, max u1 u2} R A (Prod.{u2, u1} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (Prod.{u2, u1} B C) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Semiring.toNonAssocSemiring.{max u2 u1} (Prod.{u2, u1} B C) (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6)))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3) (Algebra.toModule.{u4, max u2 u1} R (Prod.{u2, u1} B C) _inst_1 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) (AlgHomClass.linearMapClass.{u4, u3, max u2 u1, max (max u3 u2) u1} R A (Prod.{u2, u1} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) (AlgHom.{u4, u3, max u1 u2} R A (Prod.{u2, u1} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)) (AlgHom.algHomClass.{u4, u3, max u2 u1} R A (Prod.{u2, u1} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7)))))) (AlgHom.prod.{u4, u3, u2, u1} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f g)) (Pi.prod.{u3, u2, u1} A (fun (ᾰ : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) ᾰ) (fun (ᾰ : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => C) ᾰ) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u3 u2, u4, u3, u2} (AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) R A B (SMulZeroClass.toSMul.{u4, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u4, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u4, u3} R A (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u4, u3} R A (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toSMul.{u4, u2} R B (AddMonoid.toZero.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4))))) (DistribSMul.toSMulZeroClass.{u4, u2} R B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4))))) (DistribMulAction.toDistribSMul.{u4, u2} R B (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4)))) (Module.toDistribMulAction.{u4, u2} R B (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4))) (Algebra.toModule.{u4, u2} R B _inst_1 _inst_4 _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u2, u4, u3, u2} (AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) R A B (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4)))) (Module.toDistribMulAction.{u4, u3} R A (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3)) (Module.toDistribMulAction.{u4, u2} R B (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4))) (Algebra.toModule.{u4, u2} R B _inst_1 _inst_4 _inst_5)) (SemilinearMapClass.distribMulActionHomClass.{u4, u3, u2, max u3 u2} R A B (AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_4))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3) (Algebra.toModule.{u4, u2} R B _inst_1 _inst_4 _inst_5) (AlgHomClass.linearMapClass.{u4, u3, u2, max u3 u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5 (AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (AlgHom.algHomClass.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5))))) f) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => C) _x) (SMulHomClass.toFunLike.{max u3 u1, u4, u3, u1} (AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) R A C (SMulZeroClass.toSMul.{u4, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u4, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))))) (DistribMulAction.toDistribSMul.{u4, u3} R A (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (Module.toDistribMulAction.{u4, u3} R A (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toSMul.{u4, u1} R C (AddMonoid.toZero.{u1} C (AddCommMonoid.toAddMonoid.{u1} C (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} C (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} C (Semiring.toNonAssocSemiring.{u1} C _inst_6))))) (DistribSMul.toSMulZeroClass.{u4, u1} R C (AddMonoid.toAddZeroClass.{u1} C (AddCommMonoid.toAddMonoid.{u1} C (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} C (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} C (Semiring.toNonAssocSemiring.{u1} C _inst_6))))) (DistribMulAction.toDistribSMul.{u4, u1} R C (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} C (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} C (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} C (Semiring.toNonAssocSemiring.{u1} C _inst_6)))) (Module.toDistribMulAction.{u4, u1} R C (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} C (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} C (Semiring.toNonAssocSemiring.{u1} C _inst_6))) (Algebra.toModule.{u4, u1} R C _inst_1 _inst_6 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u1, u4, u3, u1} (AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) R A C (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u1} C (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} C (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} C (Semiring.toNonAssocSemiring.{u1} C _inst_6)))) (Module.toDistribMulAction.{u4, u3} R A (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3)) (Module.toDistribMulAction.{u4, u1} R C (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} C (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} C (Semiring.toNonAssocSemiring.{u1} C _inst_6))) (Algebra.toModule.{u4, u1} R C _inst_1 _inst_6 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u4, u3, u1, max u3 u1} R A C (AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) (CommSemiring.toSemiring.{u4} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} C (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} C (Semiring.toNonAssocSemiring.{u1} C _inst_6))) (Algebra.toModule.{u4, u3} R A _inst_1 _inst_2 _inst_3) (Algebra.toModule.{u4, u1} R C _inst_1 _inst_6 _inst_7) (AlgHomClass.linearMapClass.{u4, u3, u1, max u3 u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7 (AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) (AlgHom.algHomClass.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7))))) g))\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_prod AlgHom.coe_prodₓ'. -/\ntheorem coe_prod (f : A →ₐ[R] B) (g : A →ₐ[R] C) : ⇑(f.Prod g) = Pi.prod f g :=\n  rfl\n#align alg_hom.coe_prod AlgHom.coe_prod\n\n/- warning: alg_hom.fst_prod -> AlgHom.fst_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u4} C] [_inst_7 : Algebra.{u1, u4} R C _inst_1 _inst_6] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (g : AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7), Eq.{max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (AlgHom.comp.{u1, u2, max u3 u4, u3} R A (Prod.{u3, u4} B C) B _inst_1 _inst_2 (Prod.semiring.{u3, u4} B C _inst_4 _inst_6) _inst_4 _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) _inst_5 (AlgHom.fst.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) (AlgHom.prod.{u1, u2, u3, u4} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f g)) f\nbut is expected to have type\n  forall {R : Type.{u4}} {A : Type.{u3}} {B : Type.{u2}} {C : Type.{u1}} [_inst_1 : CommSemiring.{u4} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u4, u3} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u2} B] [_inst_5 : Algebra.{u4, u2} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u1} C] [_inst_7 : Algebra.{u4, u1} R C _inst_1 _inst_6] (f : AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (g : AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7), Eq.{max (succ u3) (succ u2)} (AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (AlgHom.comp.{u4, u3, max u2 u1, u2} R A (Prod.{u2, u1} B C) B _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_4 _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) _inst_5 (AlgHom.fst.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) (AlgHom.prod.{u4, u3, u2, u1} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f g)) f\nCase conversion may be inaccurate. Consider using '#align alg_hom.fst_prod AlgHom.fst_prodₓ'. -/\n@[simp]\ntheorem fst_prod (f : A →ₐ[R] B) (g : A →ₐ[R] C) : (fst R B C).comp (prod f g) = f := by ext <;> rfl\n#align alg_hom.fst_prod AlgHom.fst_prod\n\n/- warning: alg_hom.snd_prod -> AlgHom.snd_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u4} C] [_inst_7 : Algebra.{u1, u4} R C _inst_1 _inst_6] (f : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (g : AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7), Eq.{max (succ u2) (succ u4)} (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) (AlgHom.comp.{u1, u2, max u3 u4, u4} R A (Prod.{u3, u4} B C) C _inst_1 _inst_2 (Prod.semiring.{u3, u4} B C _inst_4 _inst_6) _inst_6 _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) _inst_7 (AlgHom.snd.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) (AlgHom.prod.{u1, u2, u3, u4} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f g)) g\nbut is expected to have type\n  forall {R : Type.{u4}} {A : Type.{u3}} {B : Type.{u2}} {C : Type.{u1}} [_inst_1 : CommSemiring.{u4} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u4, u3} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u2} B] [_inst_5 : Algebra.{u4, u2} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u1} C] [_inst_7 : Algebra.{u4, u1} R C _inst_1 _inst_6] (f : AlgHom.{u4, u3, u2} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (g : AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7), Eq.{max (succ u3) (succ u1)} (AlgHom.{u4, u3, u1} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7) (AlgHom.comp.{u4, u3, max u2 u1, u1} R A (Prod.{u2, u1} B C) C _inst_1 _inst_2 (Prod.instSemiringProd.{u2, u1} B C _inst_4 _inst_6) _inst_6 _inst_3 (Prod.algebra.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) _inst_7 (AlgHom.snd.{u4, u2, u1} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7) (AlgHom.prod.{u4, u3, u2, u1} R A B C _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f g)) g\nCase conversion may be inaccurate. Consider using '#align alg_hom.snd_prod AlgHom.snd_prodₓ'. -/\n@[simp]\ntheorem snd_prod (f : A →ₐ[R] B) (g : A →ₐ[R] C) : (snd R B C).comp (prod f g) = g := by ext <;> rfl\n#align alg_hom.snd_prod AlgHom.snd_prod\n\n/- warning: alg_hom.prod_fst_snd -> AlgHom.prod_fst_snd is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4], Eq.{succ (max u2 u3)} (AlgHom.{u1, max u2 u3, max u2 u3} R (Prod.{u2, u3} A B) (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (AlgHom.prod.{u1, max u2 u3, u2, u3} R (Prod.{u2, u3} A B) A B _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) _inst_2 _inst_3 _inst_4 _inst_5 (AlgHom.fst.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (AlgHom.snd.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (OfNat.ofNat.{max u2 u3} (AlgHom.{u1, max u2 u3, max u2 u3} R (Prod.{u2, u3} A B) (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) 1 (OfNat.mk.{max u2 u3} (AlgHom.{u1, max u2 u3, max u2 u3} R (Prod.{u2, u3} A B) (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) 1 (One.one.{max u2 u3} (AlgHom.{u1, max u2 u3, max u2 u3} R (Prod.{u2, u3} A B) (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (MulOneClass.toHasOne.{max u2 u3} (AlgHom.{u1, max u2 u3, max u2 u3} R (Prod.{u2, u3} A B) (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (Monoid.toMulOneClass.{max u2 u3} (AlgHom.{u1, max u2 u3, max u2 u3} R (Prod.{u2, u3} A B) (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (AlgHom.End.{u1, max u2 u3} R (Prod.{u2, u3} A B) _inst_1 (Prod.semiring.{u2, u3} A B _inst_2 _inst_4) (Prod.algebra.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u3}} {B : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u3} A] [_inst_3 : Algebra.{u1, u3} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u2} B] [_inst_5 : Algebra.{u1, u2} R B _inst_1 _inst_4], Eq.{max (succ u3) (succ u2)} (AlgHom.{u1, max u3 u2, max u2 u3} R (Prod.{u3, u2} A B) (Prod.{u3, u2} A B) _inst_1 (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (AlgHom.prod.{u1, max u3 u2, u3, u2} R (Prod.{u3, u2} A B) A B _inst_1 (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) _inst_2 _inst_3 _inst_4 _inst_5 (AlgHom.fst.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (AlgHom.snd.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (OfNat.ofNat.{max u3 u2} (AlgHom.{u1, max u3 u2, max u2 u3} R (Prod.{u3, u2} A B) (Prod.{u3, u2} A B) _inst_1 (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) 1 (One.toOfNat1.{max u3 u2} (AlgHom.{u1, max u3 u2, max u2 u3} R (Prod.{u3, u2} A B) (Prod.{u3, u2} A B) _inst_1 (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (Monoid.toOne.{max u3 u2} (AlgHom.{u1, max u3 u2, max u2 u3} R (Prod.{u3, u2} A B) (Prod.{u3, u2} A B) _inst_1 (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)) (AlgHom.End.{u1, max u3 u2} R (Prod.{u3, u2} A B) _inst_1 (Prod.instSemiringProd.{u3, u2} A B _inst_2 _inst_4) (Prod.algebra.{u1, u3, u2} R A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5)))))\nCase conversion may be inaccurate. Consider using '#align alg_hom.prod_fst_snd AlgHom.prod_fst_sndₓ'. -/\n@[simp]\ntheorem prod_fst_snd : prod (fst R A B) (snd R A B) = 1 :=\n  FunLike.coe_injective Pi.prod_fst_snd\n#align alg_hom.prod_fst_snd AlgHom.prod_fst_snd\n\n/- warning: alg_hom.prod_equiv -> AlgHom.prodEquiv is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u4} C] [_inst_7 : Algebra.{u1, u4} R C _inst_1 _inst_6], Equiv.{max (succ (max u2 u3)) (succ (max u2 u4)), max (succ u2) (succ (max u3 u4))} (Prod.{max u2 u3, max u2 u4} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7)) (AlgHom.{u1, u2, max u3 u4} R A (Prod.{u3, u4} B C) _inst_1 _inst_2 (Prod.semiring.{u3, u4} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} {C : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : Semiring.{u3} B] [_inst_5 : Algebra.{u1, u3} R B _inst_1 _inst_4] [_inst_6 : Semiring.{u4} C] [_inst_7 : Algebra.{u1, u4} R C _inst_1 _inst_6], Equiv.{max (succ (max u4 u2)) (succ (max u3 u2)), max (succ (max u4 u3)) (succ u2)} (Prod.{max u3 u2, max u4 u2} (AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_4 _inst_3 _inst_5) (AlgHom.{u1, u2, u4} R A C _inst_1 _inst_2 _inst_6 _inst_3 _inst_7)) (AlgHom.{u1, u2, max u4 u3} R A (Prod.{u3, u4} B C) _inst_1 _inst_2 (Prod.instSemiringProd.{u3, u4} B C _inst_4 _inst_6) _inst_3 (Prod.algebra.{u1, u3, u4} R B C _inst_1 _inst_4 _inst_5 _inst_6 _inst_7))\nCase conversion may be inaccurate. Consider using '#align alg_hom.prod_equiv AlgHom.prodEquivₓ'. -/\n/-- Taking the product of two maps with the same domain is equivalent to taking the product of\ntheir codomains. -/\n@[simps]\ndef prodEquiv : (A →ₐ[R] B) × (A →ₐ[R] C) ≃ (A →ₐ[R] B × C)\n    where\n  toFun f := f.1.Prod f.2\n  invFun f := ((fst _ _ _).comp f, (snd _ _ _).comp f)\n  left_inv f := by ext <;> rfl\n  right_inv f := by ext <;> rfl\n#align alg_hom.prod_equiv AlgHom.prodEquiv\n\nend AlgHom\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Algebra/Prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.47773833873770166}}
{"text": "import o_minimal.definable\n\n-- Definability of order relations on definable types.\n\nnamespace o_minimal\n\nopen set\n\nvariables {R : Type*} (S : struc R)\nvariables {X : Type*} [has_coordinates R X] [is_definable S X]\nvariables {Y : Type*} [has_coordinates R Y] [is_definable S Y]\n\nvariables (X)\n\nclass is_definable_le [has_le X] : Prop :=\n(definable_le' : def_set S {p : X × X | p.1 ≤ p.2})\n\nvariables {S X}\n\nsection has_le\n\nvariables [has_le X] [is_definable_le S X]\n\nlemma definable_le' : def_set S {p : X × X | p.1 ≤ p.2} :=\nis_definable_le.definable_le'\n\nlemma definable_le {f : Y → X} (hf : def_fun S f) {g : Y → X} (hg : def_fun S g) :\n  def_set S {p : Y | f p ≤ g p} :=\n(hf.prod' hg).preimage definable_le'\n\nend has_le\n\n/-- In a partial order, `≤` is definable if `<` is. -/\nlemma is_definable_le_of_definable_lt [partial_order X] (h : def_set S {p : X × X | p.1 < p.2}) :\n  is_definable_le S X :=\nbegin\n  constructor,\n  simp_rw [le_iff_lt_or_eq],\n  exact h.union def_set_diag\nend\n\nsection preorder\n\nvariables [preorder X] [is_definable_le S X]\n\n-- In a definable preorder, `<` is also definable.\n\nlemma definable_lt' : def_set S {p : X × X | p.1 < p.2} :=\nbegin\n  simp_rw [lt_iff_le_not_le],\n  exact definable_le'.inter (definable_le def_fun.snd def_fun.fst).compl,\nend\n\nlemma definable_lt {f : Y → X} (hf : def_fun S f) {g : Y → X} (hg : def_fun S g) :\n  def_set S {p : Y | f p < g p} :=\n(hf.prod' hg).preimage definable_lt'\n\n-- Intervals are definable.\n-- For now we assume S has definable constants for simplicity.\n\nvariables [definable_constants S] (a b : X)\n\nlemma def_set.Iio : def_set S (Iio a) := definable_lt def_fun.id def_fun_const\nlemma def_set.Ioi : def_set S (Ioi a) := definable_lt def_fun_const def_fun.id\nlemma def_set.Iic : def_set S (Iic a) := definable_le def_fun.id def_fun_const\nlemma def_set.Ici : def_set S (Ici a) := definable_le def_fun_const def_fun.id\n\nlemma def_set.Ioo : def_set S (Ioo a b) := (def_set.Ioi a).inter (def_set.Iio b)\nlemma def_set.Ioc : def_set S (Ioc a b) := (def_set.Ioi a).inter (def_set.Iic b)\nlemma def_set.Ico : def_set S (Ico a b) := (def_set.Ici a).inter (def_set.Iio b)\nlemma def_set.Icc : def_set S (Icc a b) := (def_set.Ici a).inter (def_set.Iic b)\n\nend preorder\n\nend o_minimal\n\n\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/src/o_minimal/order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975978, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4777383387377016}}
{"text": "-- Copyright (c) 2017 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Stephen Morgan, Scott Morrison\n\nopen tactic\nopen smt_tactic\n\ndef pointwise_attribute : user_attribute := {\n  name := `pointwise,\n  descr := \"A lemma that proves things are equal using the fact they are pointwise equal.\"\n}\n\nrun_command attribute.register `pointwise_attribute\n\n/- Try to apply one of the given lemas, it succeeds if one of them succeeds. -/\nmeta def any_apply : list name → tactic unit\n| []      := failed\n| (c::cs) := (mk_const c >>= fapply) <|> any_apply cs\n\nmeta def smt   : tactic unit := using_smt $ intros >> add_lemmas_from_facts >> try ematch >> try simp\n\nmeta def pointwise (and_then : tactic unit) : tactic unit :=\ndo cs ← attribute.get_instances `pointwise,\n   try (any_apply cs >> and_then)\n\nattribute [pointwise] funext\n\nmeta def blast : tactic unit := smt >> pointwise (repeat_at_most 2 blast) -- pointwise equality of functors creates two goals\n\nnotation `♮` := by abstract { blast }\n\n@[pointwise] lemma {u v} pair_equality {α : Type u} {β : Type v} { X: α × β }: (X^.fst, X^.snd) = X := begin induction X, blast end\n@[pointwise] lemma {u v} pair_equality_1 {α : Type u} {β : Type v} { X: α × β } { A : α } ( p : A = X^.fst ) : (A, X^.snd) = X := begin induction X, blast end\n@[pointwise] lemma {u v} pair_equality_2 {α : Type u} {β : Type v} { X: α × β } { B : β } ( p : B = X^.snd ) : (X^.fst, B) = X := begin induction X, blast end\nattribute [pointwise] subtype.eq\n\ndef {u} auto_cast {α β : Type u} {h : α = β} (a : α) := cast h a\n@[simp] lemma {u} auto_cast_identity {α : Type u} (a : α) : @auto_cast α α ♮ a = a := ♮\nnotation `⟦` p `⟧` := @auto_cast _ _ ♮ p\n\nuniverse variables u v u1 v1 u2 v2\n\nstructure Category :=\n  (Obj : Type u)\n  (Hom : Obj → Obj → Type v) \n  (identity : Π X : Obj, Hom X X)\n  (compose  : Π { X Y Z : Obj }, Hom X Y → Hom Y Z → Hom X Z)\n\n  (left_identity  : ∀ { X Y : Obj } (f : Hom X Y), compose (identity _) f = f)\n  (right_identity : ∀ { X Y : Obj } (f : Hom X Y), compose f (identity _) = f)\n  (associativity  : ∀ { W X Y Z : Obj } (f : Hom W X) (g : Hom X Y) (h : Hom Y Z),\n    compose (compose f g) h = compose f (compose g h))\n\nattribute [simp] Category.left_identity\nattribute [simp] Category.right_identity\n\nstructure Functor (C : Category.{ u1 v1 }) (D : Category.{ u2 v2 }) :=\n  (onObjects   : C^.Obj → D^.Obj)\n  (onMorphisms : Π { X Y : C^.Obj },\n                C^.Hom X Y → D^.Hom (onObjects X) (onObjects Y))\n  (identities : ∀ (X : C^.Obj),\n    onMorphisms (C^.identity X) = D^.identity (onObjects X))\n  (functoriality : ∀ { X Y Z : C^.Obj } (f : C^.Hom X Y) (g : C^.Hom Y Z),\n    onMorphisms (C^.compose f g) = D^.compose (onMorphisms f) (onMorphisms g))\n\nattribute [simp] Functor.identities\nattribute [simp] Functor.functoriality\n\ninstance Functor_to_onObjects { C D : Category }: has_coe_to_fun (Functor C D) :=\n{ F   := λ f, C^.Obj -> D^.Obj,\n  coe := Functor.onObjects }\n\nstructure NaturalTransformation { C D : Category } ( F G : Functor C D ) :=\n  (components: Π X : C^.Obj, D^.Hom (F X) (G X))\n  (naturality: ∀ { X Y : C^.Obj } (f : C^.Hom X Y),\n     D^.compose (F^.onMorphisms f) (components Y) = D^.compose (components X) (G^.onMorphisms f))\n\ninstance NaturalTransformation_to_components { C D : Category } { F G : Functor C D } : has_coe_to_fun (NaturalTransformation F G) :=\n{ F   := λ f, Π X : C^.Obj, D^.Hom (F X) (G X),\n  coe := NaturalTransformation.components }\n\n@[reducible] definition vertical_composition_of_NaturalTransformations\n  { C D : Category }\n  { F G H : Functor C D }\n  ( α : NaturalTransformation F G )\n  ( β : NaturalTransformation G H ) : NaturalTransformation F H :=\n  {\n    components := λ X, D^.compose (α X) (β X),\n    naturality := begin\n                    blast,\n                    begin[smt]\n                      -- -- This doesn't work (\"invalid expression\"):\n                      eblast_using [ D^.associativity, α^.naturality, β^.naturality ]\n                      -- -- This does:\n                      -- eblast_using [ Category.associativity, NaturalTransformation.naturality ]\n                    end,\n                  end\n  }", "meta": {"author": "semorrison", "repo": "proof", "sha": "5ee398aa239a379a431190edbb6022b1a0aa2c70", "save_path": "github-repos/lean/semorrison-proof", "path": "github-repos/lean/semorrison-proof/proof-5ee398aa239a379a431190edbb6022b1a0aa2c70/lean/20170219-eblast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.47773833392425696}}
{"text": "/-\nCopyright (c) 2020 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport ring_theory.localization.away\nimport ring_theory.ideal.over\nimport ring_theory.jacobson_ideal\n\n/-!\n# Jacobson Rings\nThe following conditions are equivalent for a ring `R`:\n1. Every radical ideal `I` is equal to its Jacobson radical\n2. Every radical ideal `I` can be written as an intersection of maximal ideals\n3. Every prime ideal `I` is equal to its Jacobson radical\nAny ring satisfying any of these equivalent conditions is said to be Jacobson.\nSome particular examples of Jacobson rings are also proven.\n`is_jacobson_quotient` says that the quotient of a Jacobson ring is Jacobson.\n`is_jacobson_localization` says the localization of a Jacobson ring to a single element is Jacobson.\n`is_jacobson_polynomial_iff_is_jacobson` says polynomials over a Jacobson ring form a Jacobson ring.\n## Main definitions\nLet `R` be a commutative ring. Jacobson Rings are defined using the first of the above conditions\n* `is_jacobson R` is the proposition that `R` is a Jacobson ring. It is a class,\n  implemented as the predicate that for any ideal, `I.radical = I` implies `I.jacobson = I`.\n\n## Main statements\n* `is_jacobson_iff_prime_eq` is the equivalence between conditions 1 and 3 above.\n* `is_jacobson_iff_Inf_maximal` is the equivalence between conditions 1 and 2 above.\n* `is_jacobson_of_surjective` says that if `R` is a Jacobson ring and `f : R →+* S` is surjective,\n  then `S` is also a Jacobson ring\n* `is_jacobson_mv_polynomial` says that multi-variate polynomials over a Jacobson ring are Jacobson.\n## Tags\nJacobson, Jacobson Ring\n-/\n\nnamespace ideal\n\nopen polynomial\nopen_locale polynomial\n\nsection is_jacobson\nvariables {R S : Type*} [comm_ring R] [comm_ring S] {I : ideal R}\n\n/-- A ring is a Jacobson ring if for every radical ideal `I`,\n the Jacobson radical of `I` is equal to `I`.\n See `is_jacobson_iff_prime_eq` and `is_jacobson_iff_Inf_maximal` for equivalent definitions. -/\nclass is_jacobson (R : Type*) [comm_ring R] : Prop :=\n(out' : ∀ (I : ideal R), I.radical = I → I.jacobson = I)\n\ntheorem is_jacobson_iff {R} [comm_ring R] :\n  is_jacobson R ↔ ∀ (I : ideal R), I.radical = I → I.jacobson = I :=\n⟨λ h, h.1, λ h, ⟨h⟩⟩\n\ntheorem is_jacobson.out {R} [comm_ring R] :\n  is_jacobson R → ∀ {I : ideal R}, I.radical = I → I.jacobson = I := is_jacobson_iff.1\n\n/--  A ring is a Jacobson ring if and only if for all prime ideals `P`,\n the Jacobson radical of `P` is equal to `P`. -/\nlemma is_jacobson_iff_prime_eq : is_jacobson R ↔ ∀ P : ideal R, is_prime P → P.jacobson = P :=\nbegin\n  refine is_jacobson_iff.trans ⟨λ h I hI, h I (is_prime.radical hI), _⟩,\n  refine λ h I hI, le_antisymm (λ x hx, _) (λ x hx, mem_Inf.mpr (λ _ hJ, hJ.left hx)),\n  rw [← hI, radical_eq_Inf I, mem_Inf],\n  intros P hP,\n  rw set.mem_set_of_eq at hP,\n  erw mem_Inf at hx,\n  erw [← h P hP.right, mem_Inf],\n  exact λ J hJ, hx ⟨le_trans hP.left hJ.left, hJ.right⟩\nend\n\n/-- A ring `R` is Jacobson if and only if for every prime ideal `I`,\n `I` can be written as the infimum of some collection of maximal ideals.\n Allowing ⊤ in the set `M` of maximal ideals is equivalent, but makes some proofs cleaner. -/\nlemma is_jacobson_iff_Inf_maximal : is_jacobson R ↔\n  ∀ {I : ideal R}, I.is_prime → ∃ M : set (ideal R), (∀ J ∈ M, is_maximal J ∨ J = ⊤) ∧ I = Inf M :=\n⟨λ H I h, eq_jacobson_iff_Inf_maximal.1 (H.out (is_prime.radical h)),\n  λ H, is_jacobson_iff_prime_eq.2 (λ P hP, eq_jacobson_iff_Inf_maximal.2 (H hP))⟩\n\nlemma is_jacobson_iff_Inf_maximal' : is_jacobson R ↔\n  ∀ {I : ideal R}, I.is_prime → ∃ M : set (ideal R),\n  (∀ (J ∈ M) (K : ideal R), J < K → K = ⊤) ∧ I = Inf M :=\n⟨λ H I h, eq_jacobson_iff_Inf_maximal'.1 (H.out (is_prime.radical h)),\n  λ H, is_jacobson_iff_prime_eq.2 (λ P hP, eq_jacobson_iff_Inf_maximal'.2 (H hP))⟩\n\nlemma radical_eq_jacobson [H : is_jacobson R] (I : ideal R) : I.radical = I.jacobson :=\nle_antisymm (le_Inf (λ J ⟨hJ, hJ_max⟩, (is_prime.radical_le_iff hJ_max.is_prime).mpr hJ))\n            ((H.out (radical_idem I)) ▸ (jacobson_mono le_radical))\n\n/-- Fields have only two ideals, and the condition holds for both of them.  -/\n@[priority 100]\ninstance is_jacobson_field {K : Type*} [field K] : is_jacobson K :=\n⟨λ I hI, or.rec_on (eq_bot_or_top I)\n(λ h, le_antisymm\n  (Inf_le ⟨le_of_eq rfl, (eq.symm h) ▸ bot_is_maximal⟩)\n  ((eq.symm h) ▸ bot_le))\n(λ h, by rw [h, jacobson_eq_top_iff])⟩\n\ntheorem is_jacobson_of_surjective [H : is_jacobson R] :\n  (∃ (f : R →+* S), function.surjective f) → is_jacobson S :=\nbegin\n  rintros ⟨f, hf⟩,\n  rw is_jacobson_iff_Inf_maximal,\n  intros p hp,\n  use map f '' {J : ideal R | comap f p ≤ J ∧ J.is_maximal },\n  use λ j ⟨J, hJ, hmap⟩, hmap ▸ or.symm (map_eq_top_or_is_maximal_of_surjective f hf hJ.right),\n  have : p = map f ((comap f p).jacobson),\n  from (is_jacobson.out' (comap f p) (by rw [← comap_radical, is_prime.radical hp])).symm\n    ▸ (map_comap_of_surjective f hf p).symm,\n  exact eq.trans this (map_Inf hf (λ J ⟨hJ, _⟩, le_trans (ideal.ker_le_comap f) hJ)),\nend\n\n@[priority 100]\ninstance is_jacobson_quotient [is_jacobson R] : is_jacobson (R ⧸ I) :=\nis_jacobson_of_surjective ⟨quotient.mk I, (by rintro ⟨x⟩; use x; refl)⟩\n\nlemma is_jacobson_iso (e : R ≃+* S) : is_jacobson R ↔ is_jacobson S :=\n⟨λ h, @is_jacobson_of_surjective _ _ _ _ h ⟨(e : R →+* S), e.surjective⟩,\n  λ h, @is_jacobson_of_surjective _ _ _ _ h ⟨(e.symm : S →+* R), e.symm.surjective⟩⟩\n\nlemma is_jacobson_of_is_integral [algebra R S] (hRS : algebra.is_integral R S)\n  (hR : is_jacobson R) : is_jacobson S :=\nbegin\n  rw is_jacobson_iff_prime_eq,\n  introsI P hP,\n  by_cases hP_top : comap (algebra_map R S) P = ⊤,\n  { simp [comap_eq_top_iff.1 hP_top] },\n  { haveI : nontrivial (R ⧸ comap (algebra_map R S) P) := quotient.nontrivial hP_top,\n    rw jacobson_eq_iff_jacobson_quotient_eq_bot,\n    refine eq_bot_of_comap_eq_bot (is_integral_quotient_of_is_integral hRS) _,\n    rw [eq_bot_iff, ← jacobson_eq_iff_jacobson_quotient_eq_bot.1 ((is_jacobson_iff_prime_eq.1 hR)\n      (comap (algebra_map R S) P) (comap_is_prime _ _)), comap_jacobson],\n    refine Inf_le_Inf (λ J hJ, _),\n    simp only [true_and, set.mem_image, bot_le, set.mem_set_of_eq],\n    haveI : J.is_maximal, { simpa using hJ },\n    exact exists_ideal_over_maximal_of_is_integral (is_integral_quotient_of_is_integral hRS) J\n      (comap_bot_le_of_injective _ algebra_map_quotient_injective) }\nend\n\nlemma is_jacobson_of_is_integral' (f : R →+* S) (hf : f.is_integral)\n  (hR : is_jacobson R) : is_jacobson S :=\n@is_jacobson_of_is_integral _ _ _ _ f.to_algebra hf hR\n\nend is_jacobson\n\n\nsection localization\nopen is_localization submonoid\nvariables {R S : Type*} [comm_ring R] [comm_ring S] {I : ideal R}\nvariables (y : R) [algebra R S] [is_localization.away y S]\n\nlemma disjoint_powers_iff_not_mem (hI : I.radical = I) :\n  disjoint ((submonoid.powers y) : set R) ↑I ↔ y ∉ I.1 :=\nbegin\n  refine ⟨λ h, set.disjoint_left.1 h (mem_powers _), λ h, (disjoint_iff).mpr (eq_bot_iff.mpr _)⟩,\n  rintros x ⟨⟨n, rfl⟩, hx'⟩,\n  rw [← hI] at hx',\n  exact absurd (hI ▸ mem_radical_of_pow_mem hx' : y ∈ I.carrier) h\nend\n\nvariables (S)\n\n/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`\ncorrespond to maximal ideals in the original ring `R` that don't contain `y`.\nThis lemma gives the correspondence in the particular case of an ideal and its comap.\nSee `le_rel_iso_of_maximal` for the more general relation isomorphism -/\nlemma is_maximal_iff_is_maximal_disjoint [H : is_jacobson R] (J : ideal S) :\n  J.is_maximal ↔ (comap (algebra_map R S) J).is_maximal ∧ y ∉ ideal.comap (algebra_map R S) J :=\nbegin\n  split,\n  { refine λ h, ⟨_, λ hy, h.ne_top (ideal.eq_top_of_is_unit_mem _ hy\n      (map_units _ ⟨y, submonoid.mem_powers _⟩))⟩,\n    have hJ : J.is_prime := is_maximal.is_prime h,\n    rw is_prime_iff_is_prime_disjoint (submonoid.powers y) at hJ,\n    have : y ∉ (comap (algebra_map R S) J).1 :=\n      set.disjoint_left.1 hJ.right (submonoid.mem_powers _),\n    erw [← H.out (is_prime.radical hJ.left), mem_Inf] at this,\n    push_neg at this,\n    rcases this with ⟨I, hI, hI'⟩,\n    convert hI.right,\n    by_cases hJ : J = map (algebra_map R S) I,\n    { rw [hJ, comap_map_of_is_prime_disjoint (powers y) S I (is_maximal.is_prime hI.right)],\n      rwa disjoint_powers_iff_not_mem y (is_maximal.is_prime hI.right).radical },\n    { have hI_p : (map (algebra_map R S) I).is_prime,\n      { refine is_prime_of_is_prime_disjoint (powers y) _ I hI.right.is_prime _,\n        rwa disjoint_powers_iff_not_mem y (is_maximal.is_prime hI.right).radical },\n      have : J ≤ map (algebra_map R S) I :=\n        (map_comap (submonoid.powers y) S J) ▸ (map_mono hI.left),\n      exact absurd (h.1.2 _ (lt_of_le_of_ne this hJ)) hI_p.1 } },\n  { refine λ h, ⟨⟨λ hJ, h.1.ne_top (eq_top_iff.2 _), λ I hI, _⟩⟩,\n    { rwa [eq_top_iff, ← (is_localization.order_embedding (powers y) S).le_iff_le] at hJ },\n    { have := congr_arg (map (algebra_map R S)) (h.1.1.2 _ ⟨comap_mono (le_of_lt hI), _⟩),\n      rwa [map_comap (powers y) S I, map_top] at this,\n      refine λ hI', hI.right _,\n      rw [← map_comap (powers y) S I, ← map_comap (powers y) S J],\n      exact map_mono hI' } }\nend\n\nvariables {S}\n\n/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`\ncorrespond to maximal ideals in the original ring `R` that don't contain `y`.\nThis lemma gives the correspondence in the particular case of an ideal and its map.\nSee `le_rel_iso_of_maximal` for the more general statement, and the reverse of this implication -/\nlemma is_maximal_of_is_maximal_disjoint [is_jacobson R] (I : ideal R) (hI : I.is_maximal)\n  (hy : y ∉ I) : (map (algebra_map R S) I).is_maximal :=\nbegin\n  rw [is_maximal_iff_is_maximal_disjoint S y,\n    comap_map_of_is_prime_disjoint (powers y) S I (is_maximal.is_prime hI)\n    ((disjoint_powers_iff_not_mem y (is_maximal.is_prime hI).radical).2 hy)],\n  exact ⟨hI, hy⟩\nend\n\n/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`\ncorrespond to maximal ideals in the original ring `R` that don't contain `y` -/\ndef order_iso_of_maximal [is_jacobson R] :\n  {p : ideal S // p.is_maximal} ≃o {p : ideal R // p.is_maximal ∧ y ∉ p} :=\n{ to_fun := λ p,\n    ⟨ideal.comap (algebra_map R S) p.1, (is_maximal_iff_is_maximal_disjoint S y p.1).1 p.2⟩,\n  inv_fun := λ p,\n    ⟨ideal.map (algebra_map R S) p.1, is_maximal_of_is_maximal_disjoint y p.1 p.2.1 p.2.2⟩,\n  left_inv := λ J, subtype.eq (map_comap (powers y) S J),\n  right_inv := λ I, subtype.eq (comap_map_of_is_prime_disjoint _ _ I.1 (is_maximal.is_prime I.2.1)\n    ((disjoint_powers_iff_not_mem y I.2.1.is_prime.radical).2 I.2.2)),\n  map_rel_iff' := λ I I', ⟨λ h, (show I.val ≤ I'.val,\n    from (map_comap (powers y) S I.val) ▸ (map_comap (powers y) S I'.val) ▸ (ideal.map_mono h)),\n    λ h x hx, h hx⟩ }\n\ninclude y\n\n/-- If `S` is the localization of the Jacobson ring `R` at the submonoid generated by `y : R`, then\n`S` is Jacobson. -/\nlemma is_jacobson_localization [H : is_jacobson R] : is_jacobson S :=\nbegin\n  rw is_jacobson_iff_prime_eq,\n  refine λ P' hP', le_antisymm _ le_jacobson,\n  obtain ⟨hP', hPM⟩ := (is_localization.is_prime_iff_is_prime_disjoint (powers y) S P').mp hP',\n  have hP := H.out (is_prime.radical hP'),\n  refine (le_of_eq (is_localization.map_comap (powers y) S P'.jacobson).symm).trans\n    ((map_mono _).trans (le_of_eq (is_localization.map_comap (powers y) S P'))),\n  have : Inf { I : ideal R | comap (algebra_map R S) P' ≤ I ∧ I.is_maximal ∧ y ∉ I } ≤\n    comap (algebra_map R S) P',\n  { intros x hx,\n    have hxy : x * y ∈ (comap (algebra_map R S) P').jacobson,\n    { rw [ideal.jacobson, mem_Inf],\n      intros J hJ,\n      by_cases y ∈ J,\n      { exact J.mul_mem_left x h },\n      { exact J.mul_mem_right y ((mem_Inf.1 hx) ⟨hJ.left, ⟨hJ.right, h⟩⟩) } },\n    rw hP at hxy,\n    cases hP'.mem_or_mem hxy with hxy hxy,\n    { exact hxy },\n    { exact (hPM ⟨submonoid.mem_powers _, hxy⟩).elim } },\n  refine le_trans _ this,\n  rw [ideal.jacobson, comap_Inf', Inf_eq_infi],\n  refine infi_le_infi_of_subset (λ I hI, ⟨map (algebra_map R S) I, ⟨_, _⟩⟩),\n  { exact ⟨le_trans (le_of_eq ((is_localization.map_comap (powers y) S P').symm)) (map_mono hI.1),\n    is_maximal_of_is_maximal_disjoint y _ hI.2.1 hI.2.2⟩ },\n  { exact is_localization.comap_map_of_is_prime_disjoint _ S I (is_maximal.is_prime hI.2.1)\n    ((disjoint_powers_iff_not_mem y hI.2.1.is_prime.radical).2 hI.2.2) }\nend\n\nend localization\n\nnamespace polynomial\nopen polynomial\n\nsection comm_ring\nvariables {R S : Type*} [comm_ring R] [comm_ring S] [is_domain S]\nvariables {Rₘ Sₘ : Type*} [comm_ring Rₘ] [comm_ring Sₘ]\n\n/-- If `I` is a prime ideal of `polynomial R` and `pX ∈ I` is a non-constant polynomial,\n  then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leading_coeff`.\n  In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,\n  so integrality of the entire extension follows by closure under addition and multiplication. -/\nlemma is_integral_is_localization_polynomial_quotient\n  (P : ideal R[X]) (pX : R[X]) (hpX : pX ∈ P)\n  [algebra (R ⧸ P.comap (C : R →+* _)) Rₘ]\n  [is_localization.away (pX.map (quotient.mk (P.comap C))).leading_coeff Rₘ]\n  [algebra (R[X] ⧸ P) Sₘ]\n  [is_localization ((submonoid.powers (pX.map (quotient.mk (P.comap C))).leading_coeff).map\n    (quotient_map P C le_rfl) : submonoid (R[X] ⧸ P)) Sₘ] :\n  (is_localization.map Sₘ (quotient_map P C le_rfl)\n    ((submonoid.powers (pX.map (quotient.mk (P.comap C))).leading_coeff).le_comap_map) : Rₘ →+* _)\n    .is_integral :=\nbegin\n  let P' : ideal R := P.comap C,\n  let M : submonoid (R ⧸ P') :=\n  submonoid.powers (pX.map (quotient.mk (P.comap C))).leading_coeff,\n  let M' : submonoid (R[X] ⧸ P) :=\n  (submonoid.powers (pX.map (quotient.mk (P.comap C))).leading_coeff).map (quotient_map P C le_rfl),\n  let φ : R ⧸ P' →+* R[X] ⧸ P := quotient_map P C le_rfl,\n  let φ' := is_localization.map Sₘ φ M.le_comap_map,\n  have hφ' : φ.comp (quotient.mk P') = (quotient.mk P).comp C := rfl,\n  intro p,\n  obtain ⟨⟨p', ⟨q, hq⟩⟩, hp⟩ := is_localization.surj M' p,\n  suffices : φ'.is_integral_elem (algebra_map _ _ p'),\n  { obtain ⟨q', hq', rfl⟩ := hq,\n    obtain ⟨q'', hq''⟩ := is_unit_iff_exists_inv'.1 (is_localization.map_units Rₘ (⟨q', hq'⟩ : M)),\n    refine φ'.is_integral_of_is_integral_mul_unit p (algebra_map _ _ (φ q')) q'' _ (hp.symm ▸ this),\n    convert trans (trans (φ'.map_mul _ _).symm (congr_arg φ' hq'')) φ'.map_one using 2,\n    rw [← φ'.comp_apply, is_localization.map_comp, ring_hom.comp_apply, subtype.coe_mk] },\n  refine is_integral_of_mem_closure''\n    (((algebra_map _ Sₘ).comp (quotient.mk P)) '' (insert X {p | p.degree ≤ 0})) _ _ _,\n  { rintros x ⟨p, hp, rfl⟩,\n    refine hp.rec_on (λ hy, _) (λ hy, _),\n    { refine hy.symm ▸ (φ.is_integral_elem_localization_at_leading_coeff ((quotient.mk P) X)\n        (pX.map (quotient.mk P')) _ M ⟨1, pow_one _⟩),\n      rwa [eval₂_map, hφ', ← hom_eval₂, quotient.eq_zero_iff_mem, eval₂_C_X] },\n    { rw [set.mem_set_of_eq, degree_le_zero_iff] at hy,\n      refine hy.symm ▸ ⟨X - C (algebra_map _ _ ((quotient.mk P') (p.coeff 0))), monic_X_sub_C _, _⟩,\n      simp only [eval₂_sub, eval₂_C, eval₂_X],\n      rw [sub_eq_zero, ← φ'.comp_apply, is_localization.map_comp],\n      refl } },\n  { obtain ⟨p, rfl⟩ := quotient.mk_surjective p',\n    refine polynomial.induction_on p\n      (λ r, subring.subset_closure $ set.mem_image_of_mem _ (or.inr degree_C_le))\n      (λ _ _ h1 h2, _) (λ n _ hr, _),\n    { convert subring.add_mem _ h1 h2,\n      rw [ring_hom.map_add, ring_hom.map_add] },\n    { rw [pow_succ X n, mul_comm X, ← mul_assoc, ring_hom.map_mul, ring_hom.map_mul],\n      exact subring.mul_mem _ hr (subring.subset_closure (set.mem_image_of_mem _ (or.inl rfl))) } },\nend\n\n/-- If `f : R → S` descends to an integral map in the localization at `x`,\n  and `R` is a Jacobson ring, then the intersection of all maximal ideals in `S` is trivial -/\nlemma jacobson_bot_of_integral_localization\n  {R : Type*} [comm_ring R] [is_domain R] [is_jacobson R]\n  (Rₘ Sₘ : Type*) [comm_ring Rₘ] [comm_ring Sₘ]\n  (φ : R →+* S) (hφ : function.injective φ) (x : R) (hx : x ≠ 0)\n  [algebra R Rₘ] [is_localization.away x Rₘ]\n  [algebra S Sₘ] [is_localization ((submonoid.powers x).map φ : submonoid S) Sₘ]\n  (hφ' : ring_hom.is_integral\n    (is_localization.map Sₘ φ (submonoid.powers x).le_comap_map : Rₘ →+* Sₘ)) :\n  (⊥ : ideal S).jacobson = (⊥ : ideal S) :=\nbegin\n  have hM : ((submonoid.powers x).map φ : submonoid S) ≤ non_zero_divisors S :=\n    map_le_non_zero_divisors_of_injective φ hφ (powers_le_non_zero_divisors_of_no_zero_divisors hx),\n  letI : is_domain Sₘ := is_localization.is_domain_of_le_non_zero_divisors _ hM,\n  let φ' : Rₘ →+* Sₘ := is_localization.map _ φ (submonoid.powers x).le_comap_map,\n  suffices : ∀ I : ideal Sₘ, I.is_maximal → (I.comap (algebra_map S Sₘ)).is_maximal,\n  { have hϕ' : comap (algebra_map S Sₘ) (⊥ : ideal Sₘ) = (⊥ : ideal S),\n    { rw [← ring_hom.ker_eq_comap_bot, ← ring_hom.injective_iff_ker_eq_bot],\n      exact is_localization.injective Sₘ hM },\n    have hSₘ : is_jacobson Sₘ := is_jacobson_of_is_integral' φ' hφ' (is_jacobson_localization x),\n    refine eq_bot_iff.mpr (le_trans _ (le_of_eq hϕ')),\n    rw [← hSₘ.out radical_bot_of_is_domain, comap_jacobson],\n    exact Inf_le_Inf (λ j hj, ⟨bot_le, let ⟨J, hJ⟩ := hj in hJ.2 ▸ this J hJ.1.2⟩) },\n  introsI I hI,\n  -- Remainder of the proof is pulling and pushing ideals around the square and the quotient square\n  haveI : (I.comap (algebra_map S Sₘ)).is_prime := comap_is_prime _ I,\n  haveI : (I.comap φ').is_prime := comap_is_prime φ' I,\n  haveI : (⊥ : ideal (S ⧸ I.comap (algebra_map S Sₘ))).is_prime := bot_prime,\n  have hcomm: φ'.comp (algebra_map R Rₘ) = (algebra_map S Sₘ).comp φ := is_localization.map_comp _,\n  let f := quotient_map (I.comap (algebra_map S Sₘ)) φ le_rfl,\n  let g := quotient_map I (algebra_map S Sₘ) le_rfl,\n  have := is_maximal_comap_of_is_integral_of_is_maximal' φ' hφ' I\n    (by convert hI; casesI _inst_4; refl),\n  have := ((is_maximal_iff_is_maximal_disjoint Rₘ x _).1 this).left,\n  have : ((I.comap (algebra_map S Sₘ)).comap φ).is_maximal,\n  { rwa [comap_comap, hcomm, ← comap_comap] at this },\n  rw ← bot_quotient_is_maximal_iff at this ⊢,\n  refine is_maximal_of_is_integral_of_is_maximal_comap' f _ ⊥\n    ((eq_bot_iff.2 (comap_bot_le_of_injective f quotient_map_injective)).symm ▸ this),\n  exact f.is_integral_tower_bot_of_is_integral g quotient_map_injective\n    ((comp_quotient_map_eq_of_comp_eq hcomm I).symm ▸\n    (ring_hom.is_integral_trans _ _ (ring_hom.is_integral_of_surjective _\n      (is_localization.surjective_quotient_map_of_maximal_of_localization (submonoid.powers x) Rₘ\n      (by rwa [comap_comap, hcomm, ← bot_quotient_is_maximal_iff])))\n      (ring_hom.is_integral_quotient_of_is_integral _ hφ'))),\nend\n\n/-- Used to bootstrap the proof of `is_jacobson_polynomial_iff_is_jacobson`.\n  That theorem is more general and should be used instead of this one. -/\nprivate lemma is_jacobson_polynomial_of_domain\n  (R : Type*) [comm_ring R] [is_domain R] [hR : is_jacobson R]\n  (P : ideal R[X]) [is_prime P] (hP : ∀ (x : R), C x ∈ P → x = 0) :\n  P.jacobson = P :=\nbegin\n  by_cases Pb : P = ⊥,\n  { exact Pb.symm ▸ jacobson_bot_polynomial_of_jacobson_bot\n      (hR.out radical_bot_of_is_domain) },\n  { rw jacobson_eq_iff_jacobson_quotient_eq_bot,\n    haveI : (P.comap (C : R →+* R[X])).is_prime := comap_is_prime C P,\n    obtain ⟨p, pP, p0⟩ := exists_nonzero_mem_of_ne_bot Pb hP,\n    let x := (polynomial.map (quotient.mk (comap (C : R →+* _) P)) p).leading_coeff,\n    have hx : x ≠ 0 := by rwa [ne.def, leading_coeff_eq_zero],\n    refine jacobson_bot_of_integral_localization\n      (localization.away x)\n      (localization ((submonoid.powers x).map (P.quotient_map C le_rfl) :\n        submonoid (R[X] ⧸ P)))\n      (quotient_map P C le_rfl) quotient_map_injective\n      x hx\n      _,\n    -- `convert` is noticeably faster than `exact` here:\n    convert is_integral_is_localization_polynomial_quotient P p pP }\nend\n\nlemma is_jacobson_polynomial_of_is_jacobson (hR : is_jacobson R) :\n  is_jacobson R[X] :=\nbegin\n  refine is_jacobson_iff_prime_eq.mpr (λ I, _),\n  introI hI,\n  let R' : subring (R[X] ⧸ I) := ((quotient.mk I).comp C).range,\n  let i : R →+* R' := ((quotient.mk I).comp C).range_restrict,\n  have hi : function.surjective (i : R → R') := ((quotient.mk I).comp C).range_restrict_surjective,\n  have hi' : (polynomial.map_ring_hom i : R[X] →+* R'[X]).ker ≤ I,\n  { refine λ f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (λ n, _),\n    replace hf := congr_arg (λ (g : polynomial (((quotient.mk I).comp C).range)), g.coeff n) hf,\n    change (polynomial.map ((quotient.mk I).comp C).range_restrict f).coeff n = 0 at hf,\n    rw [coeff_map, subtype.ext_iff] at hf,\n    rwa [mem_comap, ← quotient.eq_zero_iff_mem, ← ring_hom.comp_apply], },\n  haveI := map_is_prime_of_surjective\n    (show function.surjective (map_ring_hom i), from map_surjective i hi) hi',\n  suffices : (I.map (polynomial.map_ring_hom i)).jacobson = (I.map (polynomial.map_ring_hom i)),\n  { replace this := congr_arg (comap (polynomial.map_ring_hom i)) this,\n    rw [← map_jacobson_of_surjective _ hi',\n      comap_map_of_surjective _ _, comap_map_of_surjective _ _] at this,\n    refine le_antisymm (le_trans (le_sup_of_le_left le_rfl)\n      (le_trans (le_of_eq this) (sup_le le_rfl hi'))) le_jacobson,\n    all_goals {exact polynomial.map_surjective i hi} },\n  exact @is_jacobson_polynomial_of_domain R' _ _ (is_jacobson_of_surjective ⟨i, hi⟩)\n    (map (map_ring_hom i) I) _ (eq_zero_of_polynomial_mem_map_range I),\nend\n\ntheorem is_jacobson_polynomial_iff_is_jacobson :\n  is_jacobson R[X] ↔ is_jacobson R :=\nbegin\n  refine ⟨_, is_jacobson_polynomial_of_is_jacobson⟩,\n  introI H,\n  exact is_jacobson_of_surjective ⟨eval₂_ring_hom (ring_hom.id _) 1, λ x,\n    ⟨C x, by simp only [coe_eval₂_ring_hom, ring_hom.id_apply, eval₂_C]⟩⟩,\nend\n\ninstance [is_jacobson R] : is_jacobson R[X] :=\nis_jacobson_polynomial_iff_is_jacobson.mpr ‹is_jacobson R›\n\nend comm_ring\n\nsection\nvariables {R : Type*} [comm_ring R] [is_jacobson R]\nvariables (P : ideal R[X]) [hP : P.is_maximal]\n\ninclude P hP\n\nlemma is_maximal_comap_C_of_is_maximal [nontrivial R] (hP' : ∀ (x : R), C x ∈ P → x = 0) :\n  is_maximal (comap C P : ideal R) :=\nbegin\n  haveI hp'_prime : (P.comap C : ideal R).is_prime := comap_is_prime C P,\n  obtain ⟨m, hm⟩ := submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_is_field),\n  have : (m : R[X]) ≠ 0, rwa [ne.def, submodule.coe_eq_zero],\n  let φ : R ⧸ P.comap C →+* R[X] ⧸ P := quotient_map P C le_rfl,\n  let M : submonoid (R ⧸ P.comap C) :=\n    submonoid.powers ((m : R[X]).map (quotient.mk (P.comap C : ideal R))).leading_coeff,\n  rw ← bot_quotient_is_maximal_iff,\n  have hp0 : ((m : R[X]).map (quotient.mk (P.comap C : ideal R))).leading_coeff ≠ 0 :=\n    λ hp0', this $ map_injective (quotient.mk (P.comap C : ideal R))\n      ((quotient.mk (P.comap C : ideal R)).injective_iff.2 (λ x hx,\n      by rwa [quotient.eq_zero_iff_mem, (by rwa eq_bot_iff : (P.comap C : ideal R) = ⊥)] at hx))\n      (by simpa only [leading_coeff_eq_zero, polynomial.map_zero] using hp0'),\n  have hM : (0 : R ⧸ P.comap C) ∉ M := λ ⟨n, hn⟩, hp0 (pow_eq_zero hn),\n  suffices : (⊥ : ideal (localization M)).is_maximal,\n  { rw ← is_localization.comap_map_of_is_prime_disjoint M (localization M) ⊥ bot_prime\n        (λ x hx, hM (hx.2 ▸ hx.1)),\n    refine ((is_maximal_iff_is_maximal_disjoint (localization M) _ _).mp (by rwa map_bot)).1,\n    swap, exact localization.is_localization },\n  let M' : submonoid (R[X] ⧸ P) := M.map φ,\n  have hM' : (0 : R[X] ⧸ P) ∉ M' :=\n    λ ⟨z, hz⟩, hM (quotient_map_injective (trans hz.2 φ.map_zero.symm) ▸ hz.1),\n  haveI : is_domain (localization M') :=\n    is_localization.is_domain_localization (le_non_zero_divisors_of_no_zero_divisors hM'),\n  suffices : (⊥ : ideal (localization M')).is_maximal,\n  { rw le_antisymm bot_le (comap_bot_le_of_injective _ (is_localization.map_injective_of_injective\n      M (localization M) (localization M')\n      quotient_map_injective (le_non_zero_divisors_of_no_zero_divisors hM'))),\n    refine is_maximal_comap_of_is_integral_of_is_maximal' _ _ ⊥ this,\n    apply is_integral_is_localization_polynomial_quotient P _ (submodule.coe_mem m) },\n  rw (map_bot.symm : (⊥ : ideal (localization M')) =\n                     map (algebra_map (R[X] ⧸ P) (localization M')) ⊥),\n  let bot_maximal := ((bot_quotient_is_maximal_iff _).mpr hP),\n  refine map.is_maximal (algebra_map _ _) (is_field.localization_map_bijective hM' _) bot_maximal,\n  rwa [← quotient.maximal_ideal_iff_is_field_quotient, ← bot_quotient_is_maximal_iff],\nend\n\n/-- Used to bootstrap the more general `quotient_mk_comp_C_is_integral_of_jacobson` -/\nprivate lemma quotient_mk_comp_C_is_integral_of_jacobson' [nontrivial R] (hR : is_jacobson R)\n  (hP' : ∀ (x : R), C x ∈ P → x = 0) :\n  ((quotient.mk P).comp C : R →+* R[X] ⧸ P).is_integral :=\nbegin\n  refine (is_integral_quotient_map_iff _).mp _,\n  let P' : ideal R := P.comap C,\n  obtain ⟨pX, hpX, hp0⟩ :=\n    exists_nonzero_mem_of_ne_bot (ne_of_lt (bot_lt_of_maximal P polynomial_not_is_field)).symm hP',\n  let M : submonoid (R ⧸ P') := submonoid.powers (pX.map (quotient.mk P')).leading_coeff,\n  let φ : R ⧸ P' →+* R[X] ⧸ P := quotient_map P C le_rfl,\n  haveI hp'_prime : P'.is_prime := comap_is_prime C P,\n  have hM : (0 : R ⧸ P') ∉ M := λ ⟨n, hn⟩, hp0 $ leading_coeff_eq_zero.mp (pow_eq_zero hn),\n  let M' : submonoid (R[X] ⧸ P) := M.map (quotient_map P C le_rfl),\n  refine ((quotient_map P C le_rfl).is_integral_tower_bot_of_is_integral\n    (algebra_map _ (localization M')) _ _),\n  { refine is_localization.injective (localization M')\n      (show M' ≤ _, from le_non_zero_divisors_of_no_zero_divisors (λ hM', hM _)),\n    exact (let ⟨z, zM, z0⟩ := hM' in (quotient_map_injective (trans z0 φ.map_zero.symm)) ▸ zM) },\n  { rw ← is_localization.map_comp M.le_comap_map,\n    refine ring_hom.is_integral_trans (algebra_map (R ⧸ P') (localization M))\n      (is_localization.map _ _ M.le_comap_map) _ _,\n    { exact (algebra_map (R ⧸ P') (localization M)).is_integral_of_surjective\n      (is_field.localization_map_bijective hM ((quotient.maximal_ideal_iff_is_field_quotient _).mp\n                                               (is_maximal_comap_C_of_is_maximal P hP'))).2 },\n    { -- `convert` here is faster than `exact`, and this proof is near the time limit.\n      convert is_integral_is_localization_polynomial_quotient P pX hpX } }\nend\n\n/-- If `R` is a Jacobson ring, and `P` is a maximal ideal of `polynomial R`,\n  then `R → R[X]/P` is an integral map. -/\nlemma quotient_mk_comp_C_is_integral_of_jacobson :\n  ((quotient.mk P).comp C : R →+* R[X] ⧸ P).is_integral :=\nbegin\n  let P' : ideal R := P.comap C,\n  haveI : P'.is_prime := comap_is_prime C P,\n  let f : R[X] →+* polynomial (R ⧸ P') := polynomial.map_ring_hom (quotient.mk P'),\n  have hf : function.surjective f := map_surjective (quotient.mk P') quotient.mk_surjective,\n  have hPJ : P = (P.map f).comap f,\n  { rw comap_map_of_surjective _ hf,\n    refine le_antisymm (le_sup_of_le_left le_rfl) (sup_le le_rfl _),\n    refine λ p hp, polynomial_mem_ideal_of_coeff_mem_ideal P p (λ n, quotient.eq_zero_iff_mem.mp _),\n    simpa only [coeff_map, coe_map_ring_hom] using (polynomial.ext_iff.mp hp) n },\n  refine ring_hom.is_integral_tower_bot_of_is_integral _ _ (injective_quotient_le_comap_map P) _,\n  rw ← quotient_mk_maps_eq,\n  refine ring_hom.is_integral_trans _ _\n    ((quotient.mk P').is_integral_of_surjective quotient.mk_surjective) _,\n  apply quotient_mk_comp_C_is_integral_of_jacobson' _ _ (λ x hx, _),\n  any_goals { exact ideal.is_jacobson_quotient },\n  { exact or.rec_on (map_eq_top_or_is_maximal_of_surjective f hf hP)\n    (λ h, absurd (trans (h ▸ hPJ : P = comap f ⊤) comap_top : P = ⊤) hP.ne_top) id },\n  { apply_instance, },\n  { obtain ⟨z, rfl⟩ := quotient.mk_surjective x,\n    rwa [quotient.eq_zero_iff_mem, mem_comap, hPJ, mem_comap, coe_map_ring_hom, map_C] }\nend\n\nlemma is_maximal_comap_C_of_is_jacobson :\n  (P.comap (C : R →+* R[X])).is_maximal :=\nbegin\n  rw [← @mk_ker _ _ P, ring_hom.ker_eq_comap_bot, comap_comap],\n  exact is_maximal_comap_of_is_integral_of_is_maximal' _\n    (quotient_mk_comp_C_is_integral_of_jacobson P) ⊥ ((bot_quotient_is_maximal_iff _).mpr hP),\nend\n\nomit P hP\n\nlemma comp_C_integral_of_surjective_of_jacobson\n  {S : Type*} [field S] (f : R[X] →+* S) (hf : function.surjective f) :\n  (f.comp C).is_integral :=\nbegin\n  haveI : (f.ker).is_maximal := f.ker_is_maximal_of_surjective hf,\n  let g : R[X] ⧸ f.ker →+* S := ideal.quotient.lift f.ker f (λ _ h, h),\n  have hfg : (g.comp (quotient.mk f.ker)) = f := ring_hom_ext' rfl rfl,\n  rw [← hfg, ring_hom.comp_assoc],\n  refine ring_hom.is_integral_trans _ g (quotient_mk_comp_C_is_integral_of_jacobson f.ker)\n    (g.is_integral_of_surjective _), --(quotient.lift_surjective f.ker f _ hf)),\n  rw [← hfg] at hf,\n  exact function.surjective.of_comp hf,\nend\n\nend\n\nend polynomial\n\nopen mv_polynomial ring_hom\n\nnamespace mv_polynomial\n\nlemma is_jacobson_mv_polynomial_fin {R : Type*} [comm_ring R] [H : is_jacobson R] :\n  ∀ (n : ℕ), is_jacobson (mv_polynomial (fin n) R)\n| 0 := ((is_jacobson_iso ((rename_equiv R\n  (equiv.equiv_pempty (fin 0))).to_ring_equiv.trans (is_empty_ring_equiv R pempty))).mpr H)\n| (n+1) := (is_jacobson_iso (fin_succ_equiv R n).to_ring_equiv).2\n  (polynomial.is_jacobson_polynomial_iff_is_jacobson.2 (is_jacobson_mv_polynomial_fin n))\n\n/-- General form of the nullstellensatz for Jacobson rings, since in a Jacobson ring we have\n  `Inf {P maximal | P ≥ I} = Inf {P prime | P ≥ I} = I.radical`. Fields are always Jacobson,\n  and in that special case this is (most of) the classical Nullstellensatz,\n  since `I(V(I))` is the intersection of maximal ideals containing `I`, which is then `I.radical` -/\ninstance {R : Type*} [comm_ring R] {ι : Type*} [fintype ι] [is_jacobson R] :\n  is_jacobson (mv_polynomial ι R) :=\nbegin\n  haveI := classical.dec_eq ι,\n  let e := fintype.equiv_fin ι,\n  rw is_jacobson_iso (rename_equiv R e).to_ring_equiv,\n  exact is_jacobson_mv_polynomial_fin _\nend\n\nvariables {n : ℕ}\n\nlemma quotient_mk_comp_C_is_integral_of_jacobson\n  {R : Type*} [comm_ring R] [is_jacobson R]\n  (P : ideal (mv_polynomial (fin n) R)) [P.is_maximal] :\n  ((quotient.mk P).comp mv_polynomial.C : R →+* mv_polynomial _ R ⧸ P).is_integral :=\nbegin\n  unfreezingI {induction n with n IH},\n  { refine ring_hom.is_integral_of_surjective _ (function.surjective.comp quotient.mk_surjective _),\n    exact C_surjective (fin 0) },\n  { rw [← fin_succ_equiv_comp_C_eq_C, ← ring_hom.comp_assoc, ← ring_hom.comp_assoc,\n      ← quotient_map_comp_mk le_rfl, ring_hom.comp_assoc (polynomial.C),\n      ← quotient_map_comp_mk le_rfl, ring_hom.comp_assoc, ring_hom.comp_assoc,\n      ← quotient_map_comp_mk le_rfl, ← ring_hom.comp_assoc (quotient.mk _)],\n    refine ring_hom.is_integral_trans _ _ _ _,\n    { refine ring_hom.is_integral_trans _ _ (is_integral_of_surjective _ quotient.mk_surjective) _,\n      refine ring_hom.is_integral_trans _ _ _ _,\n      { apply (is_integral_quotient_map_iff _).mpr (IH _),\n        apply polynomial.is_maximal_comap_C_of_is_jacobson _,\n        { exact mv_polynomial.is_jacobson_mv_polynomial_fin n },\n        { apply comap_is_maximal_of_surjective,\n          exact (fin_succ_equiv R n).symm.surjective } },\n      { refine (is_integral_quotient_map_iff _).mpr _,\n        rw ← quotient_map_comp_mk le_rfl,\n        refine ring_hom.is_integral_trans _ _ _ ((is_integral_quotient_map_iff _).mpr _),\n        { exact ring_hom.is_integral_of_surjective _ quotient.mk_surjective },\n        { apply polynomial.quotient_mk_comp_C_is_integral_of_jacobson _,\n          { exact mv_polynomial.is_jacobson_mv_polynomial_fin n },\n          { exact comap_is_maximal_of_surjective _ (fin_succ_equiv R n).symm.surjective } } } },\n    { refine (is_integral_quotient_map_iff _).mpr _,\n      refine ring_hom.is_integral_trans _ _ _ (is_integral_of_surjective _ quotient.mk_surjective),\n      exact ring_hom.is_integral_of_surjective _ (fin_succ_equiv R n).symm.surjective } }\nend\n\nlemma comp_C_integral_of_surjective_of_jacobson\n  {R : Type*} [comm_ring R] [is_jacobson R]\n  {σ : Type*} [fintype σ] {S : Type*} [field S] (f : mv_polynomial σ R →+* S)\n  (hf : function.surjective f) : (f.comp C).is_integral :=\nbegin\n  haveI := classical.dec_eq σ,\n  obtain ⟨e⟩ := fintype.trunc_equiv_fin σ,\n  let f' : mv_polynomial (fin _) R →+* S :=\n    f.comp (rename_equiv R e.symm).to_ring_equiv.to_ring_hom,\n  have hf' : function.surjective f' :=\n    ((function.surjective.comp hf (rename_equiv R e.symm).surjective)),\n  have : (f'.comp C).is_integral,\n  { haveI : (f'.ker).is_maximal := f'.ker_is_maximal_of_surjective hf',\n    let g : mv_polynomial _ R ⧸ f'.ker →+* S := ideal.quotient.lift f'.ker f' (λ _ h, h),\n    have hfg : (g.comp (quotient.mk f'.ker)) = f' := ring_hom_ext (λ r, rfl) (λ i, rfl),\n    rw [← hfg, ring_hom.comp_assoc],\n    refine ring_hom.is_integral_trans _ g (quotient_mk_comp_C_is_integral_of_jacobson f'.ker)\n      (g.is_integral_of_surjective _),\n    rw ← hfg at hf',\n    exact function.surjective.of_comp hf' },\n  rw ring_hom.comp_assoc at this,\n  convert this,\n  refine ring_hom.ext (λ x, _),\n  exact ((rename_equiv R e.symm).commutes' x).symm,\nend\n\nend mv_polynomial\n\nend ideal\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/ring_theory/jacobson.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.47773832911081215}}
{"text": "import tactic set_theory.ordinal order.bounded_lattice order.zorn data.set.intervals.ord_connected order.rel_iso data.finset.preimage\n\nopen_locale cardinal\n\nset_option old_structure_cmd true\n\n/-- A partial order with a least and greatest element. -/\nclass bounded_partial_order (α : Type*) extends order_top α, order_bot α\n\nnamespace bounded_partial_order\nsection\n\n  parameters {α : Type*} [bl : bounded_lattice α]\n\n  -- A bounded lattice is a bounded partial order.\n  instance of_top_bot : bounded_partial_order α :=\n  { ..bl }\n\nend\nend bounded_partial_order\n\n/-- A face `c` covers `a` whenever `a < c` and no face `b` exists such that `a < b < c`. -/\ndef covers {α : Type*} [preorder α] (a c : α) : Prop :=\na < c ∧ ¬ ∃ b, a < b ∧ b < c\n\n/-- A graded poset has a function from elements to naturals that's compatible\n    with the ordering, and consistent with the covering relation. -/\nclass graded (α : Type*) extends order_bot α :=\n(grade : α → ℕ)\n(grade_bot_eq_zero : grade ⊥ = 0)\n(lt_grade_of_lt : ∀ {a b : α}, a < b → grade a < grade b)\n(eq_p1_of_cover : ∀ {a b : α}, covers a b → grade a + 1 = grade b)\n\nnamespace graded\nsection\n\n  parameters {α : Type*} [graded α]\n\n  /-- If `a ≤ b`, then `grade a ≤ grade b`. -/\n  theorem le_grade_of_le : ∀ {a b : α}, a ≤ b → graded.grade a ≤ graded.grade b :=\n  begin\n    intros a b a_le_b,\n    cases lt_or_eq_of_le a_le_b with a_lt_b a_eq_b, {\n      exact le_of_lt (graded.lt_grade_of_lt a_lt_b),\n    },\n    exact (congr_arg grade (eq.symm a_eq_b)).ge,\n  end\n\n  /-- If `grade a = 0`, then `a = ⊥`. -/\n  theorem eq_bot_of_grade_eq_zero {a : α} : grade a = 0 → a = ⊥ :=\n  begin\n    contrapose,\n    intro a_ne_bot,\n    have h : grade a > grade (⊥ : α) :=  lt_grade_of_lt (lt_of_le_of_ne (bot_le a) (ne.symm a_ne_bot)),\n    rw grade_bot_eq_zero at h,\n    exact ne_of_gt h,\n  end\n\nend\nend graded\n\n/-- A graded, bounded partial order. -/\nclass graded_bounded_partial_order (α : Type*) extends bounded_partial_order α, graded α\n\nnamespace graded_bounded_partial_order\nsection\n\n  parameters {α : Type*} [graded_bounded_partial_order α] (a : α)\n\n  /-- If `grade a = grade ⊤`, then `a = ⊤`. -/\n  theorem eq_top_of_grade_eq_grade_top : graded.grade a = graded.grade (⊤ : α) → a = ⊤ :=\n  begin\n    contrapose,\n    intro a_ne_bot,\n    exact ne_of_lt ( lt_grade_of_lt (lt_of_le_of_ne (le_top a) a_ne_bot)),\n  end\n\n  /-- The grade of any face is in the interval `[0, grade ⊤]`. -/\n  theorem grade_mem_Iic : graded.grade a ∈ set.Iic (graded.grade (⊤ : α)) :=\n  graded.le_grade_of_le (le_top a)\n\n  /-- The grade of a face as a member of a finite set. -/\n  def fin_grade : α → fin (grade (⊤ : α) + 1) := \n  λ a, ⟨graded.grade a, nat.lt_succ_iff.mpr (graded.le_grade_of_le (le_top a))⟩\n\nend\nend graded_bounded_partial_order\n\nnamespace flag\nsection\n\n  variables {α : Type*} [graded_bounded_partial_order α] {f f' : set α}\n\n  /-- A flag is a maximal chain. -/\n  def is_flag (c : set α) : Prop := @zorn.is_max_chain _ (<) c\n\n  /-- Two flags are adjacent when they differ by exactly one element. -/\n  def flag_adj (f f' : set α) : Prop :=\n  is_flag f → is_flag f' → #(set.diff f f') = 1\n\n  /-- If one attempts to extend a flag `f` by an element `e` which is comparable to\n  --  all other faces of the flag, we obtain a contradiction. -/\n  lemma flag_extend (e : α) : is_flag f → e ∉ f → ¬(∀ a ∈ f, a ≠ e → a < e ∨ e < a) :=\n  begin\n    -- We define `f' = f ∪ {e}`.\n    intros ff e_nmem_f h,\n    let f' := f ∪ {e},\n    have hf' : ∀ a ∈ f', a ∈ f ∨ a = e := by simp,\n    apply ff.right,\n    use f',\n\n    -- `f` is not equal to `f'`.\n    have f_ne_f' : f ≠ f' := begin\n      intro f_eq_f',\n      rw f_eq_f' at e_nmem_f,\n      exact e_nmem_f (set.mem_union_right f rfl),\n    end,\n\n    -- We prove that `f'` is a superchain of `f`, a contradiction!\n    split, {\n      intros a a_mem_f' b b_mem_f' a_ne_b,\n\n      -- Cases depending on whether `a` or `b` equal `e`.\n      cases hf' a a_mem_f' with a_mem_f a_eq_t, {\n        cases hf' b b_mem_f' with b_mem_f b_eq_t, {\n          exact ff.left a a_mem_f b b_mem_f a_ne_b,\n        },\n        rw b_eq_t at *,\n        exact h a a_mem_f a_ne_b,\n      },\n      cases hf' b b_mem_f' with b_mem_f b_eq_t, {\n        rw a_eq_t at *,\n        exact or.swap (h b b_mem_f (ne.symm a_ne_b)),\n      },\n      rw b_eq_t at *,\n      exact false.elim (a_ne_b a_eq_t),\n    },\n\n    exact set.ssubset_iff_subset_ne.mpr ⟨set.subset_union_left f {e}, f_ne_f'⟩,\n  end\n\n  -- Any flag contains the bottom face `⊥`.\n  theorem bot_in_flag : is_flag f → ⊥ ∈ f :=\n  begin\n    -- We use the `flag_extend` lemma.\n    intro ff,\n    by_contra bot_nmem_f,\n    apply flag_extend ⊥ ff bot_nmem_f,\n\n    -- The bottom face is less or equal to any other.\n    intros a a_mem_f a_ne_bot,\n    exact or.inr (lt_of_le_of_ne bot_le (ne.symm a_ne_bot)),\n  end\n\n  -- Any flag contains the top face `⊤`.\n  theorem top_in_flag : is_flag f → ⊤ ∈ f :=\n  begin\n    -- We use the `flag_extend` lemma.\n    intro ff,\n    by_contra top_nmem_f,\n    apply flag_extend ⊤ ff top_nmem_f,\n\n    -- The top face is greater or equal to any other.\n    intros a a_mem_f a_ne_bot,\n    exact or.inl (lt_of_le_of_ne le_top (a_ne_bot)),\n  end\n\nend\nend flag\n\n-- The faces of a flag are merely its elements.\ndef flag_faces {α : Type*} [graded_bounded_partial_order α] {f : set α} (ff : flag.is_flag f) : Type* := f\n\nnamespace flag_faces\nsection\n\n  parameters {α : Type*} [graded_bounded_partial_order α] {f : set α} {ff : flag.is_flag f} (a b : flag_faces ff)\n\n  -- Subtyping preserves equality and viceversa.\n  @[simp] lemma eq_iff_subtype : a = b ↔ a.val = b.val := subtype.ext_iff_val\n\n  -- Subtyping preserves inequality and viceversa.\n  lemma ne_iff_subtype : a ≠ b ↔ a.val ≠ b.val := by simp\n\n  -- Flag faces form a partial order.\n  instance of_partial_order : partial_order (flag_faces ff) :=\n  {\n    le := λ a b, a.val ≤ b.val,\n    le_refl := λ a, le_refl a.val,\n    le_trans := λ _ _ _ a_le_b b_le_c, le_trans a_le_b b_le_c,\n    le_antisymm := λ _ _ a_le_b b_le_a, subtype.eq (le_antisymm a_le_b b_le_a),\n  }\n\n  -- Subtyping preserves order and viceversa.\n  @[simp] lemma lt_iff_subtype : a < b ↔ a.val < b.val := iff.symm lt_iff_le_not_le\n\n  -- Flag faces form a linear order.\n  noncomputable instance of_linear_order : linear_order (flag_faces ff) :=\n  {\n    le_total := begin\n      intros a b,\n\n      -- `a = b` is trivial.\n      by_cases a_eq_b : a = b, {\n        exact or.inl (eq.symm a_eq_b).ge,\n      },\n\n      -- If `a ≠ b`, then either `a < b`...\n      cases ff.left a.val (subtype.mem a) b.val (subtype.mem b) ((ne_iff_subtype a b).mp a_eq_b) with av_lt_bv bv_lt_av, {\n        exact or.inl (le_of_lt ((lt_iff_subtype a b).mpr av_lt_bv)),\n      },\n\n      -- ...or `b < a`.\n      exact or.inr (le_of_lt ((lt_iff_subtype b a).mpr bv_lt_av)),\n    end,\n\n    decidable_le := classical.dec_rel _,\n\n    ..of_partial_order\n  }\n\n  -- Flag faces form a graded bounded partial order.\n  instance of_graded_bounded_partial_order : graded_bounded_partial_order (flag_faces ff) :=\n  {\n    bot := ⟨⊥, flag.bot_in_flag ff⟩,\n    bot_le := λ _, bot_le,\n\n    top := ⟨⊤, flag.top_in_flag ff⟩,\n    le_top := λ _, @le_top α _ _,\n\n    grade := λ a, graded.grade a.val,\n    grade_bot_eq_zero := graded.grade_bot_eq_zero,\n\n    lt_grade_of_lt := begin\n      intros _ _ a_lt_b,\n      exact graded.lt_grade_of_lt ((lt_iff_subtype _ _).mp a_lt_b),\n    end,\n\n    eq_p1_of_cover := begin\n      -- It suffices to prove that `a` covers `c`.\n      rintros a c ⟨a_lt_c, hne⟩,\n      apply graded.eq_p1_of_cover,\n      use (lt_iff_subtype a c).mp a_lt_c,\n\n      -- To do this, we prove that any element between `a` and `c` must be in `f`.\n      by_contra he,\n      rcases he with ⟨bv, av_lt_bv, bv_lt_cv⟩,\n      apply hne,\n\n      -- To use the `flag_extend` lemma, we must prove that any `x ∈ f` is comparable to `b`.\n      have bv_mem_f : bv ∈ f := begin\n        by_contra b_nmem_f,\n        apply flag.flag_extend bv ff b_nmem_f,\n        intros xv x_mem_f _,\n        let x : flag_faces ff := ⟨xv, x_mem_f⟩,\n\n        -- `x` must be below `a` or above `c` (since there's no elements in between).\n        have x_le_a_or_c_le_x : x ≤ a ∨ c ≤ x := begin\n          by_cases x_le_a : x ≤ a, {\n            exact or.inl x_le_a,\n          },\n          by_cases c_le_x : c ≤ x, {\n            exact or.inr c_le_x,\n          },\n          exfalso,\n          exact hne ⟨x, not_le.mp x_le_a, not_le.mp c_le_x⟩,\n        end,\n\n        -- We finish by transitivity.\n        cases x_le_a_or_c_le_x with x_le_a c_le_x, {\n          exact or.inl (lt_of_le_of_lt x_le_a av_lt_bv),\n        },\n        exact or.inr (lt_of_lt_of_le bv_lt_cv c_le_x),\n      end,\n\n      let b : flag_faces ff := ⟨bv, bv_mem_f⟩,\n      exact ⟨b, (lt_iff_subtype a b).mpr av_lt_bv, (lt_iff_subtype b c).mpr bv_lt_cv⟩,\n    end,\n\n    ..of_partial_order,\n  }\n\nend\nend flag_faces\n\nnamespace flag\nsection\n\n  variables {α : Type*} [graded_bounded_partial_order α] {f f' : set α}\n\n  /-- Casts a flag into a set of its own faces. -/\n  def to_flag_faces (ff : is_flag f) : set (flag_faces ff) := subtype.val ⁻¹' f\n\n  /-- Every set of faces in a flag is a subset of the entire set. -/\n  lemma ssubset_flag_faces {ff : is_flag f} (s : set (flag_faces ff)) : s ⊆ to_flag_faces ff :=\n  λ s _, subtype.mem s\n\n  /-- If `s` contains all faces of a flag, it must be the set of all faces. -/\n  lemma eq_of_ssubset_flag_faces (ff : is_flag f) (s : set (flag_faces ff)) : to_flag_faces ff ⊆ s → s = to_flag_faces ff :=\n  begin\n    intro ff_subset_s,\n    refine set.eq_of_subset_of_subset _ ff_subset_s,\n    exact ssubset_flag_faces s,\n  end\n\n  /-- Applying `to_flag_faces` to a flag does not change the fact that it is a flag. -/\n  theorem to_flag_faces_is_flag (ff : is_flag f) : is_flag (to_flag_faces ff) :=\n  begin\n    split, {\n      intros _ _ _ _ a_ne_b,\n      exact ne.lt_or_lt a_ne_b,\n    },\n    by_contra h,\n    rcases h with ⟨ch, _, sch⟩,\n    rw set.ssubset_def at sch,\n    exact sch.right (ssubset_flag_faces ch),\n  end\n\n  /-- The subtypes of all elements of a flag form the original set. -/\n  lemma subtype_of_flag_faces_eq_flag (ff : is_flag f) : subtype.val '' to_flag_faces ff = f :=\n  begin\n    apply set.ext,\n    intro x,\n    split, {\n      intro h,\n      rcases h with ⟨_, a_mem_ff, av_eq_x⟩,\n      exact set.mem_of_eq_of_mem (eq.symm av_eq_x) a_mem_ff,\n    },\n    intro x_mem_f,\n    use ⟨x, x_mem_f⟩,\n    use x_mem_f,\n  end\n\n  /-- The set of grades of a flag. -/\n  def flag_grades (f : set α): set ℕ := {n | ∃ a ∈ f, graded.grade a = n}\n\n  /-- In a flag, `grade a < grade b` implies `a < b`. -/\n  theorem grade_lt_of_lt {ff : is_flag f} {a b : flag_faces ff} : graded.grade a < graded.grade b → a < b :=\n  begin\n    rintros ga_lt_gb,\n    cases lt_trichotomy a b with a_lt_b a_nlt_b, {\n      exact a_lt_b,\n    },\n    cases a_nlt_b with a_eq_b a_gt_b, {\n      rw a_eq_b at ga_lt_gb,\n      exact false.elim (nat.lt_asymm ga_lt_gb ga_lt_gb),\n    },\n    exact false.elim (nat.lt_asymm ga_lt_gb (graded.lt_grade_of_lt a_gt_b)),\n  end\n\n  /-- No two elements in a flag have the same grade. -/\n  theorem grade_eq_of_eq {ff : is_flag f} {a b : flag_faces ff} : graded.grade a = graded.grade b → a = b :=\n  begin\n    rintros ga_eq_gb,\n    cases lt_trichotomy a b with a_lt_b a_nlt_b, {\n      exact false.elim (ne_of_lt (graded.lt_grade_of_lt a_lt_b) ga_eq_gb),\n    },\n    cases a_nlt_b with a_eq_b a_gt_b, {\n      exact a_eq_b,\n    },\n    exact false.elim (ne_of_gt (graded.lt_grade_of_lt a_gt_b) ga_eq_gb),\n  end\n\n  /-- Flag grades on a flag are sent to the interval `[0, grade ⊤]`. -/\n  theorem flag_grades_maps_to (ff : is_flag f) : set.maps_to graded.grade f (set.Iic (graded.grade (⊤ : α))) :=\n  λ _ _,  graded.le_grade_of_le le_top\n\n  /-- Flag grades are injective on a flag. -/\n  theorem flag_grades_inj_on (ff : is_flag f) : set.inj_on graded.grade f :=\n  begin\n    intros a a_mem_f b b_mem_f ga_eq_gb,\n    apply (flag_faces.eq_iff_subtype ⟨a, a_mem_f⟩ ⟨b, b_mem_f⟩).mp,\n    apply grade_eq_of_eq,\n    exact ga_eq_gb,\n    exact ff,\n  end  \n\n  /-- `fin_grade` is an embedding from `flag_faces ff` into `fin (grade ⊤ + 1)`. -/\n  def fin_grade_inj (ff : is_flag f) : flag_faces ff ↪ fin (graded.grade (⊤ : α) + 1) := begin\n    use graded_bounded_partial_order.fin_grade,\n    intros a b fga_eq_fgb,\n    exact grade_eq_of_eq (fin.mk.inj_iff.mp fga_eq_fgb),\n  end\n\n  /-- Flag grades are injective on a flag. -/\n  theorem flag_grades_inj_on' (ff : is_flag f) : set.inj_on graded.grade (to_flag_faces ff) :=\n  begin\n    apply flag_grades_inj_on,\n    exact to_flag_faces_is_flag ff,\n  end\n\n  /-- The faces of a flag have a fintype, i.e. every flag is finite. -/\n  noncomputable theorem flag_fintype (ff : is_flag f) : fintype (flag_faces ff) := begin\n    -- We define the interval `[0, grade ⊤]` and its inverse image under `grade`, onto `f`.\n    let I := set.Iic (graded.grade (⊤ : α)),\n    let I_fin := set.finite_le_nat (graded.grade (⊤ : α)),\n    let f' : set (flag_faces ff) := graded.grade ⁻¹' I,\n    have f'_eq_to_flag_faces_ff : f' = to_flag_faces ff := begin\n      apply eq_of_ssubset_flag_faces,\n      intros a _,\n      exact graded_bounded_partial_order.grade_mem_Iic a,\n    end,\n\n    -- The `grade` function is injective on the flag.\n    have flag_grades_inj_on_ff : @set.inj_on (flag_faces ff) ℕ graded.grade f' := begin\n      rw f'_eq_to_flag_faces_ff,\n      apply flag_grades_inj_on',\n    end,\n\n    -- Since `I` is finite, so are `f'` and `f`.\n    have f'_fin : f'.finite := @set.finite.preimage (flag_faces ff) ℕ I graded.grade flag_grades_inj_on_ff I_fin,\n    rw f'_eq_to_flag_faces_ff at f'_fin,\n    have f_fin : f.finite := begin\n      have h := set.finite.image subtype.val f'_fin,\n      rw subtype_of_flag_faces_eq_flag at h,\n      exact h,\n    end,\n    exact set.finite.fintype f_fin,\n  end\n\n  /-- The assertion that a flag is finite. -/\n  def flag_finite (ff : is_flag f) : f.finite :=\n  ⟨flag_fintype ff⟩\n\n  /-- A flag contains faces of each grade up to the grade of its topmost face. -/\n  theorem flag_grades_Iic (ff : is_flag f) : flag_grades f = set.Iic (graded.grade (⊤ : α)) :=\n  begin\n    let G := flag_grades f,\n    let N := graded.grade (⊤ : α),\n    let I := set.Iic N,\n\n    -- Every flag grade is between `0` and `N`.\n    have G_in_I : G ⊆ I := begin\n      rintros _ ⟨_, a_mem_f, ga_eq_f⟩,\n      rw ←ga_eq_f,\n      exact flag_grades_maps_to ff a_mem_f,\n    end,\n\n    -- Every number between `0` and `N` is a flag grade.\n    have I_in_G : I ⊆ G := begin\n      -- We suppose, by contradiction, that we're missing a number `n`.\n      intros n n_mem_I,\n      by_contra n_nmem_G,\n\n      -- We build the intersection `[0, n] ∩ G` and prove that it's finite and non-empty.\n      let Sm := (set.Iic n) ∩ G,\n      let Sm_finite : Sm.finite := set.finite.inf_of_left (set.finite_le_nat n) G,\n      let Sm_finset := set.finite.to_finset Sm_finite,\n      have Sm_finset_non : Sm_finset.nonempty := begin\n        use 0,\n        rw set.finite.mem_to_finset,\n        exact ⟨zero_le n, ⟨⊥, bot_in_flag ff, graded.grade_bot_eq_zero⟩⟩,\n      end,\n\n      -- We build the largest grade in `G` that's lesser than `n`.\n      let m := Sm_finset.max' Sm_finset_non,\n      have m_mem_Sm := (set.finite.mem_to_finset Sm_finite).mp (Sm_finset.max'_mem Sm_finset_non),\n      cases m_mem_Sm with m_le_n m_mem_G,\n      have m_lt_n : m < n := begin\n        apply lt_of_le_of_ne,\n        apply m_le_n,\n        by_contra m_eq_n,\n        have h : m = n ↔ ¬ m ≠ n := not_not.symm,\n        rw ←h at m_eq_n,\n        rw ←m_eq_n at n_nmem_G,\n        exact n_nmem_G m_mem_G,\n      end,\n\n      -- We prove that no grades in `(m, n)` may appear in `G`.\n      have hm : ∀ k : ℕ, k ∈ set.Ioo m n → k ∉ G := begin\n        intros k k_mem_i,\n        by_contra k_mem_G,\n        have k_le_m : k ≤ m := begin\n          apply finset.le_max',\n          apply set.mem_to_finset.mpr,\n          exact set.mem_sep (set.mem_Iic.mpr (le_of_lt k_mem_i.right)) k_mem_G,\n        end,\n        exact false.elim (not_lt.mpr k_le_m k_mem_i.left),\n      end,\n\n      -- We build the intersection `[n, ∞] ∩ G`.\n      let SM := (set.Ici n) ∩ G,\n      have SM_non : SM.nonempty := ⟨N, set.mem_inter n_mem_I ⟨⊤, top_in_flag ff, rfl⟩⟩,\n\n      -- We build the smallest grade in `G` that's greater than `N`.\n      let M : ℕ := well_founded.min nat.lt_wf SM SM_non,\n      have M_mem_SM := nat.lt_wf.min_mem SM SM_non,\n      cases M_mem_SM with n_le_M M_mem_G,\n      have n_lt_M : n < M := begin\n        apply lt_of_le_of_ne,\n        apply n_le_M,\n        by_contra n_eq_M,\n        have h : n = M ↔ ¬ n ≠ M := not_not.symm,\n        rw ←h at n_eq_M,\n        rw n_eq_M at n_nmem_G,\n        exact n_nmem_G M_mem_G,\n      end,\n\n      -- We prove that no grades in `[n, M)` may appear in `G`.\n      have hM : ∀ k : ℕ, k ∈ set.Ico n M → k ∉ G := begin\n        intros k k_mem_i,\n        by_contra k_mem_G,\n        have k_ge_m : k ≥ M := begin\n          apply le_of_not_lt,\n          apply well_founded.not_lt_min nat.lt_wf SM SM_non,\n          exact set.mem_sep (set.mem_Ici.mpr k_mem_i.left) k_mem_G,\n        end,\n        exact false.elim (not_lt.mpr k_ge_m k_mem_i.right),\n      end,\n\n      -- `m < M`, obviously.\n      have m_lt_M : m < M := lt_trans m_lt_n n_lt_M,\n\n      -- We build faces `a` and `c` in the flag with grades `m` and `M`.\n      cases m_mem_G with a ea,\n      cases M_mem_G with c ec,\n      cases ea with a_mem_f ga_eq_m,\n      cases ec with c_mem_f gc_eq_M,\n      let a : flag_faces ff := ⟨a, a_mem_f⟩,\n      let c : flag_faces ff := ⟨c, c_mem_f⟩,\n\n      -- `a` must be less than `c`.\n      have ga_eq_m : graded.grade a = m := ga_eq_m,\n      have gc_eq_M : graded.grade c = M := gc_eq_M,\n      have a_lt_c : a < c := begin\n        rw ←ga_eq_m at m_lt_M,\n        rw ←gc_eq_M at m_lt_M,\n        exact grade_lt_of_lt m_lt_M,\n      end,\n\n      -- There can't exist any face in the flag that's between `a` and `c`.\n      have C : ¬ ∃ b, a < b ∧ b < c := begin\n        intro he,\n        cases he with b he,\n        cases he with a_lt_b b_lt_c,\n\n        let g := graded.grade b,\n        have m_lt_g : m < g := begin\n          rw ←ga_eq_m,\n          exact graded.lt_grade_of_lt a_lt_b,\n        end,\n        have g_lt_M : g < M := begin\n          rw ←gc_eq_M,\n          exact graded.lt_grade_of_lt b_lt_c,\n        end,\n        have g_mem_G : g ∈ G := ⟨b.val, subtype.mem b, rfl⟩,\n        by_cases g_lt_n : g < n, {\n          exact hm g (set.mem_inter m_lt_g g_lt_n) g_mem_G,\n        },\n        exact hM g (set.mem_inter (le_of_not_gt g_lt_n) g_lt_M) g_mem_G,\n      end,\n\n      -- As a consequence, `m + 1 = M`.\n      have ga_p1_eq_gc : graded.grade a + 1 = graded.grade c := graded.eq_p1_of_cover ⟨a_lt_c, C⟩,\n      have m_p1_eq_M : m + 1 = M := begin\n        rw ga_eq_m at ga_p1_eq_gc,\n        rw gc_eq_M at ga_p1_eq_gc,\n        exact ga_p1_eq_gc,\n      end,\n\n      -- But then, the existence of `n` such that `m < n < M` is impossible!\n      linarith,\n    end,\n\n    exact set.subset.antisymm G_in_I I_in_G,\n  end\n\n  /-- Flag grades are surjective from a flag onto `[0, grade ⊤]`. -/\n  theorem flag_grades_surj_on (ff : is_flag f) : set.surj_on graded.grade f (set.Iic (graded.grade (⊤ : α))) :=\n  begin\n    intros n n_mem_Iic,\n    have h : graded.grade '' f = flag_grades f := set.image_eq graded.grade f,\n    rw h,\n    rw flag_grades_Iic ff,\n    exact n_mem_Iic,\n  end\n\n  /-- Flag grades are surjective from a flag onto `[0, grade ⊤]`. -/\n  theorem flag_grades_surj_on' (ff : is_flag f) : set.surj_on graded.grade (to_flag_faces ff) (set.Iic (graded.grade (⊤ : α))) :=\n  begin\n    apply flag_grades_surj_on,\n    exact to_flag_faces_is_flag ff,\n  end\n\n  /-- Flag grades are bijective from a flag onto `[0, grade ⊤]`. -/\n  theorem flag_grades_bij_on (ff : is_flag f) : set.bij_on graded.grade f (set.Iic (graded.grade (⊤ : α))) :=\n  ⟨flag_grades_maps_to ff, flag_grades_inj_on ff, flag_grades_surj_on ff⟩\n\n  /-- Flag grades are bijective from a flag onto `[0, grade ⊤]`. -/\n  theorem flag_grades_bij_on' (ff : is_flag f) : set.bij_on graded.grade (to_flag_faces ff) (set.Iic (graded.grade (⊤ : α))) :=\n  begin\n    apply flag_grades_bij_on,\n    exact to_flag_faces_is_flag ff,\n  end\n\n  def fin_grade_inv (ff : is_flag f) : fin (graded.grade (⊤ : α) + 1) → flag_faces ff :=\n  begin\n    --have h := function.embedding.inv_of_mem_range graded_bounded_partial_order.fin_grade,\n    sorry,\n  end\n\n  def faces_equiv_grades (ff : is_flag f) : flag_faces ff ≃ fin (graded.grade (⊤ : α) + 1) :=\n  begin\n    use graded_bounded_partial_order.fin_grade,\n    sorry,\n    sorry,\n    sorry,\n  end\n\n  /-- The cardinality of a flag. -/\n  def flag_card (ff : is_flag f) [fintype (flag_faces ff)] : ℕ := fintype.card (flag_faces ff)\n\n  /-- Any flag's cardinality equals the grade of the top face, plus one. -/\n  theorem flag_card_eq_grade_top_p1 (ff : is_flag f) [fintype (flag_faces ff)] : flag_card ff = graded.grade (⊤ : α) + 1 :=\n  begin\n    let N := graded.grade (⊤ : α),\n    rw ←fintype.card_fin (N + 1),\n    apply fintype.card_congr,\n    split, rotate, rotate, {      \n      intro a,\n      use graded.grade a,\n    }, {\n      sorry,\n    }, {\n      sorry,\n    },\n    sorry,\n  end\n\n  /-- All flags have the same cardinality. -/\n  theorem all_flags_same_card (ff : is_flag f) (ff' : is_flag f') [fintype (flag_faces ff)] [fintype (flag_faces ff')] : flag_card ff = flag_card ff' :=\n  begin\n    have h₁ := flag_card_eq_grade_top_p1 ff,\n    rw ←(flag_card_eq_grade_top_p1 ff') at h₁,\n    exact h₁,\n  end\n\n  /-- Flag adjacency in an abstract polytope is commutative. -/\n  theorem flag_adj_comm : flag.is_flag f → flag.is_flag f' → flag.flag_adj f f' → flag.flag_adj f' f :=\n  begin\n    intros ff ff',\n    sorry,\n  end\n\nend\nend flag\n\nnamespace flag_faces\nsection\n\n  parameters {α : Type*} [graded_bounded_partial_order α] {f : set α} {ff : flag.is_flag f}\n\n  instance of_well_order : is_well_order (flag_faces ff) (<) :=\n  {\n    wf := begin\n      apply well_founded.intro,\n      have h : ∀ {n : ℕ} (a : flag_faces ff), graded.grade a ≤ n → acc (<) a := begin\n        intro n,\n        induction n with n hn, {\n          intros a ga_le_zero,\n          apply acc.intro,\n          intros y y_lt_a,\n          rw (graded.eq_bot_of_grade_eq_zero (nat.le_zero_iff.mp ga_le_zero)) at y_lt_a,\n          have bot_le_y : ⊥ ≤ y := bot_le,\n          exact false.elim ((not_lt.mpr bot_le_y) y_lt_a),\n        },\n        intros a ga_le_ns,\n        apply acc.intro,\n        intros y y_lt_a,\n        exact hn y (nat.lt_succ_iff.mp (lt_of_lt_of_le (graded.lt_grade_of_lt y_lt_a) ga_le_ns)),\n      end,\n      intro a,\n      exact h a rfl.ge,\n    end\n  }\n\nend\nend flag_faces\n\nset_option old_structure_cmd false\n\nclass abstract_polytope (α : Type*) extends (graded_bounded_partial_order α) :=\n(diamond : ∀ {a b : α}, grade a + 2 = grade b → #(set.Ioo a b) = 2)\n\nset_option old_structure_cmd true\n\nnamespace abstract_polytope\n\n  variables {α : Type*} [abstract_polytope α] {f f' : set α}\n\n  def grade : ℕ := graded.grade (⊤ : α)\n\n  -- Any nontrivial section contains a vertex.\n  theorem section_vertex (a b : α) : b < a → ∃ c ∈ set.Icc b a, covers b c :=\n  begin\n    -- Set up an induction on (grade a), which can almost certainly be done more elegantly\n    let m := nat.succ (graded.grade a),\n    have grade_a_m_succ : graded.grade a < m,\n    {\n      apply lt_add_one,\n    },\n    revert grade_a_m_succ,\n    generalize : m = n,\n    clear m,\n    revert a b,\n    induction n with n ih,\n    {\n      intros a b grade_a_lt_zero,\n      cases nat.not_lt_zero _ grade_a_lt_zero,\n    },\n    intros a b grade_a_n_succ b_lt_a,\n    -- Is there something between a and b?\n    by_cases ∃ c : α, b < c ∧ c < a,\n    {\n      -- Yes, try to find a cover between that and b.\n      cases h with c h,\n      cases h with b_lt_c c_lt_a,\n      have h : ∃ (d ∈ set.Icc b c), covers b d,\n      {\n        apply ih,\n        {\n          let grade_c_lt_grade_a := graded.lt_grade_of_lt c_lt_a,\n          have grade_a_le_n : graded.grade a ≤ n,\n          {\n            exact nat.le_of_lt_succ grade_a_n_succ,\n          },\n          exact nat.lt_of_lt_of_le grade_c_lt_grade_a grade_a_le_n,\n        },\n        exact b_lt_c,\n      },\n      cases h with d h,\n      use d,\n      cases h with d_between_b_a covers_b_d,\n      split,\n      {\n        rewrite set.mem_Icc,\n        rewrite set.mem_Icc at d_between_b_a,\n        cases d_between_b_a with b_le_d d_le_c,\n        split,\n        {\n          exact b_le_d,\n        },\n        exact le_trans d_le_c (le_of_lt c_lt_a),\n      },\n      exact covers_b_d,\n    },\n    -- No, so a is covering.\n    use a,\n    split,\n    {\n      rewrite set.mem_Icc,\n      split,\n      {\n        exact le_of_lt b_lt_a,\n      },\n      apply le_refl,\n    },\n    split,\n    {\n      exact b_lt_a,\n    },\n    exact h,\n  end\n\nend abstract_polytope\n\n#lint", "meta": {"author": "vihdzp", "repo": "polytope", "sha": "c2c6ed3ace5fa6af0fac0c923bdf44a2d8c76a49", "save_path": "github-repos/lean/vihdzp-polytope", "path": "github-repos/lean/vihdzp-polytope/polytope-c2c6ed3ace5fa6af0fac0c923bdf44a2d8c76a49/src/polytope.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4775592556722643}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin, Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Robert Y. Lewis\n-/\nimport data.mv_polynomial.rename\nimport data.mv_polynomial.variables\n\n/-!\n\n# Monad operations on `mv_polynomial`\n\nThis file defines two monadic operations on `mv_polynomial`. Given `p : mv_polynomial σ R`,\n\n* `mv_polynomial.bind₁` and `mv_polynomial.join₁` operate on the variable type `σ`.\n* `mv_polynomial.bind₂` and `mv_polynomial.join₂` operate on the coefficient type `R`.\n\n- `mv_polynomial.bind₁ f φ` with `f : σ → mv_polynomial τ R` and `φ : mv_polynomial σ R`,\n  is the polynomial `φ(f 1, ..., f i, ...) : mv_polynomial τ R`.\n- `mv_polynomial.join₁ φ` with `φ : mv_polynomial (mv_polynomial σ R) R` collapses `φ` to\n  a `mv_polynomial σ R`, by evaluating `φ` under the map `X f ↦ f` for `f : mv_polynomial σ R`.\n  In other words, if you have a polynomial `φ` in a set of variables indexed by a polynomial ring,\n  you evaluate the polynomial in these indexing polynomials.\n- `mv_polynomial.bind₂ f φ` with `f : R →+* mv_polynomial σ S` and `φ : mv_polynomial σ R`\n  is the `mv_polynomial σ S` obtained from `φ` by mapping the coefficients of `φ` through `f`\n  and considering the resulting polynomial as polynomial expression in `mv_polynomial σ R`.\n- `mv_polynomial.join₂ φ` with `φ : mv_polynomial σ (mv_polynomial σ R)` collapses `φ` to\n  a `mv_polynomial σ R`, by considering `φ` as polynomial expression in `mv_polynomial σ R`.\n\nThese operations themselves have algebraic structure: `mv_polynomial.bind₁`\nand `mv_polynomial.join₁` are algebra homs and\n`mv_polynomial.bind₂` and `mv_polynomial.join₂` are ring homs.\n\nThey interact in convenient ways with `mv_polynomial.rename`, `mv_polynomial.map`,\n`mv_polynomial.vars`, and other polynomial operations.\nIndeed, `mv_polynomial.rename` is the \"map\" operation for the (`bind₁`, `join₁`) pair,\nwhereas `mv_polynomial.map` is the \"map\" operation for the other pair.\n\n## Implementation notes\n\nWe add an `is_lawful_monad` instance for the (`bind₁`, `join₁`) pair.\nThe second pair cannot be instantiated as a `monad`,\nsince it is not a monad in `Type` but in `CommRing` (or rather `CommSemiRing`).\n\n-/\n\nopen_locale big_operators\nnoncomputable theory\nnamespace mv_polynomial\nopen finsupp\n\nvariables {σ : Type*} {τ : Type*}\nvariables {R S T : Type*} [comm_semiring R] [comm_semiring S] [comm_semiring T]\n\n/--\n`bind₁` is the \"left hand side\" bind operation on `mv_polynomial`, operating on the variable type.\nGiven a polynomial `p : mv_polynomial σ R` and a map `f : σ → mv_polynomial τ R` taking variables\nin `p` to polynomials in the variable type `τ`, `bind₁ f p` replaces each variable in `p` with\nits value under `f`, producing a new polynomial in `τ`. The coefficient type remains the same.\nThis operation is an algebra hom.\n-/\ndef bind₁ (f : σ → mv_polynomial τ R) : mv_polynomial σ R →ₐ[R] mv_polynomial τ R :=\naeval f\n\n/--\n`bind₂` is the \"right hand side\" bind operation on `mv_polynomial`,\noperating on the coefficient type.\nGiven a polynomial `p : mv_polynomial σ R` and\na map `f : R → mv_polynomial σ S` taking coefficients in `p` to polynomials over a new ring `S`,\n`bind₂ f p` replaces each coefficient in `p` with its value under `f`,\nproducing a new polynomial over `S`.\nThe variable type remains the same. This operation is a ring hom.\n-/\ndef bind₂ (f : R →+* mv_polynomial σ S) : mv_polynomial σ R →+* mv_polynomial σ S :=\neval₂_hom f X\n\n/--\n`join₁` is the monadic join operation corresponding to `mv_polynomial.bind₁`. Given a polynomial `p`\nwith coefficients in `R` whose variables are polynomials in `σ` with coefficients in `R`,\n`join₁ p` collapses `p` to a polynomial with variables in `σ` and coefficients in `R`.\nThis operation is an algebra hom.\n-/\ndef join₁ : mv_polynomial (mv_polynomial σ R) R →ₐ[R] mv_polynomial σ R :=\naeval id\n\n/--\n`join₂` is the monadic join operation corresponding to `mv_polynomial.bind₂`. Given a polynomial `p`\nwith variables in `σ` whose coefficients are polynomials in `σ` with coefficients in `R`,\n`join₂ p` collapses `p` to a polynomial with variables in `σ` and coefficients in `R`.\nThis operation is a ring hom.\n-/\ndef join₂ : mv_polynomial σ (mv_polynomial σ R) →+* mv_polynomial σ R :=\neval₂_hom (ring_hom.id _) X\n\n@[simp] lemma aeval_eq_bind₁ (f : σ → mv_polynomial τ R) :\n  aeval f = bind₁ f := rfl\n\n@[simp] lemma eval₂_hom_C_eq_bind₁ (f : σ → mv_polynomial τ R) :\n  eval₂_hom C f = bind₁ f := rfl\n\n@[simp] lemma eval₂_hom_eq_bind₂ (f : R →+* mv_polynomial σ S) :\n  eval₂_hom f X = bind₂ f := rfl\n\nsection\nvariables (σ R)\n@[simp] lemma aeval_id_eq_join₁ :\n  aeval id = @join₁ σ R _ := rfl\n\nlemma eval₂_hom_C_id_eq_join₁ (φ : mv_polynomial (mv_polynomial σ R) R) :\n  eval₂_hom C id φ = join₁ φ := rfl\n\n@[simp] lemma eval₂_hom_id_X_eq_join₂ :\n  eval₂_hom (ring_hom.id _) X = @join₂ σ R _ := rfl\n\nend\n\n-- In this file, we don't want to use these simp lemmas,\n-- because we first need to show how these new definitions interact\n-- and the proofs fall back on unfolding the definitions and call simp afterwards\n\nlocal attribute [-simp] aeval_eq_bind₁ eval₂_hom_C_eq_bind₁ eval₂_hom_eq_bind₂\n                        aeval_id_eq_join₁ eval₂_hom_id_X_eq_join₂\n\n@[simp]\nlemma bind₁_X_right (f : σ → mv_polynomial τ R) (i : σ) : bind₁ f (X i) = f i :=\naeval_X f i\n\n@[simp]\nlemma bind₂_X_right (f : R →+* mv_polynomial σ S) (i : σ) : bind₂ f (X i) = X i :=\neval₂_hom_X' f X i\n\n@[simp]\nlemma bind₁_X_left : bind₁ (X : σ → mv_polynomial σ R) = alg_hom.id R _ :=\nby { ext1 i, simp }\n\nvariable (f : σ → mv_polynomial τ R)\n\n@[simp]\nlemma bind₁_C_right (f : σ → mv_polynomial τ R) (x) : bind₁ f (C x) = C x :=\nby simp [bind₁, algebra_map_eq]\n\n@[simp]\nlemma bind₂_C_right (f : R →+* mv_polynomial σ S) (r : R) : bind₂ f (C r) = f r :=\neval₂_hom_C f X r\n\n@[simp]\nlemma bind₂_C_left : bind₂ (C : R →+* mv_polynomial σ R) = ring_hom.id _ :=\nby { ext : 2; simp }\n\n@[simp]\nlemma bind₂_comp_C (f : R →+* mv_polynomial σ S) :\n  (bind₂ f).comp C = f :=\nring_hom.ext $ bind₂_C_right _\n\n@[simp]\nlemma join₂_map (f : R →+* mv_polynomial σ S) (φ : mv_polynomial σ R) :\n  join₂ (map f φ) = bind₂ f φ :=\nby simp only [join₂, bind₂, eval₂_hom_map_hom, ring_hom.id_comp]\n\n@[simp]\nlemma join₂_comp_map (f : R →+* mv_polynomial σ S) :\n  join₂.comp (map f) = bind₂ f :=\nring_hom.ext $ join₂_map _\n\nlemma aeval_id_rename (f : σ → mv_polynomial τ R) (p : mv_polynomial σ R) :\n  aeval id (rename f p) = aeval f p :=\nby rw [aeval_rename, function.comp.left_id]\n\n@[simp]\nlemma join₁_rename (f : σ → mv_polynomial τ R) (φ : mv_polynomial σ R) :\n  join₁ (rename f φ) = bind₁ f φ :=\naeval_id_rename _ _\n\n@[simp]\nlemma bind₁_id : bind₁ (@id (mv_polynomial σ R)) = join₁ := rfl\n\n@[simp]\nlemma bind₂_id : bind₂ (ring_hom.id (mv_polynomial σ R)) = join₂ := rfl\n\nlemma bind₁_bind₁ {υ : Type*} (f : σ → mv_polynomial τ R) (g : τ → mv_polynomial υ R)\n  (φ : mv_polynomial σ R) :\n  (bind₁ g) (bind₁ f φ) = bind₁ (λ i, bind₁ g (f i)) φ :=\nby simp [bind₁, ← comp_aeval]\n\nlemma bind₁_comp_bind₁ {υ : Type*} (f : σ → mv_polynomial τ R) (g : τ → mv_polynomial υ R) :\n  (bind₁ g).comp (bind₁ f) = bind₁ (λ i, bind₁ g (f i)) :=\nby { ext1, apply bind₁_bind₁ }\n\nlemma bind₂_comp_bind₂ (f : R →+* mv_polynomial σ S) (g : S →+* mv_polynomial σ T) :\n  (bind₂ g).comp (bind₂ f) = bind₂ ((bind₂ g).comp f) :=\nby { ext : 2; simp }\n\nlemma bind₂_bind₂ (f : R →+* mv_polynomial σ S) (g : S →+* mv_polynomial σ T)\n  (φ : mv_polynomial σ R) :\n  (bind₂ g) (bind₂ f φ) = bind₂ ((bind₂ g).comp f) φ :=\nring_hom.congr_fun (bind₂_comp_bind₂ f g) φ\n\nlemma rename_comp_bind₁ {υ : Type*} (f : σ → mv_polynomial τ R) (g : τ → υ) :\n  (rename g).comp (bind₁ f) = bind₁ (λ i, rename g $ f i) :=\nby { ext1 i, simp }\n\nlemma rename_bind₁ {υ : Type*} (f : σ → mv_polynomial τ R) (g : τ → υ) (φ : mv_polynomial σ R) :\n  rename g (bind₁ f φ) = bind₁ (λ i, rename g $ f i) φ :=\nalg_hom.congr_fun (rename_comp_bind₁ f g) φ\n\nlemma map_bind₂ (f : R →+* mv_polynomial σ S) (g : S →+* T) (φ : mv_polynomial σ R) :\n  map g (bind₂ f φ) = bind₂ ((map g).comp f) φ :=\nbegin\n  simp only [bind₂, eval₂_comp_right, coe_eval₂_hom, eval₂_map],\n  congr' 1 with : 1,\n  simp only [function.comp_app, map_X]\nend\n\nlemma bind₁_comp_rename {υ : Type*} (f : τ → mv_polynomial υ R) (g : σ → τ) :\n  (bind₁ f).comp (rename g) = bind₁ (f ∘ g) :=\nby { ext1 i, simp }\n\nlemma bind₁_rename {υ : Type*} (f : τ → mv_polynomial υ R) (g : σ → τ) (φ : mv_polynomial σ R) :\n  bind₁ f (rename g φ) = bind₁ (f ∘ g) φ :=\nalg_hom.congr_fun (bind₁_comp_rename f g) φ\n\nlemma bind₂_map (f : S →+* mv_polynomial σ T) (g : R →+* S) (φ : mv_polynomial σ R) :\n  bind₂ f (map g φ) = bind₂ (f.comp g) φ :=\nby simp [bind₂]\n\n@[simp]\nlemma map_comp_C (f : R →+* S) : (map f).comp (C : R →+* mv_polynomial σ R) = C.comp f :=\nby { ext1, apply map_C }\n\n-- mixing the two monad structures\n\n\nlemma map_bind₁ (f : R →+* S) (g : σ → mv_polynomial τ R) (φ : mv_polynomial σ R) :\n  map f (bind₁ g φ) = bind₁ (λ (i : σ), (map f) (g i)) (map f φ) :=\nby { rw [hom_bind₁, map_comp_C, ← eval₂_hom_map_hom], refl }\n\n@[simp]\nlemma eval₂_hom_comp_C (f : R →+* S) (g : σ → S) :\n  (eval₂_hom f g).comp C = f :=\nby { ext1 r, exact eval₂_C f g r }\n\nlemma eval₂_hom_bind₁ (f : R →+* S) (g : τ → S) (h : σ → mv_polynomial τ R)\n  (φ : mv_polynomial σ R) :\n  eval₂_hom f g (bind₁ h φ) = eval₂_hom f (λ i, eval₂_hom f g (h i)) φ :=\nby rw [hom_bind₁, eval₂_hom_comp_C]\n\nlemma aeval_bind₁ [algebra R S] (f : τ → S) (g : σ → mv_polynomial τ R) (φ : mv_polynomial σ R) :\n  aeval f (bind₁ g φ) = aeval (λ i, aeval f (g i)) φ :=\neval₂_hom_bind₁ _ _ _ _\n\nlemma aeval_comp_bind₁ [algebra R S] (f : τ → S) (g : σ → mv_polynomial τ R) :\n  (aeval f).comp (bind₁ g) = aeval (λ i, aeval f (g i)) :=\nby { ext1, apply aeval_bind₁ }\n\nlemma eval₂_hom_comp_bind₂ (f : S →+* T) (g : σ → T) (h : R →+* mv_polynomial σ S) :\n  (eval₂_hom f g).comp (bind₂ h) = eval₂_hom ((eval₂_hom f g).comp h) g :=\nby { ext : 2; simp }\n\nlemma eval₂_hom_bind₂ (f : S →+* T) (g : σ → T) (h : R →+* mv_polynomial σ S)\n  (φ : mv_polynomial σ R) :\n  eval₂_hom f g (bind₂ h φ) = eval₂_hom ((eval₂_hom f g).comp h) g φ :=\nring_hom.congr_fun (eval₂_hom_comp_bind₂ f g h) φ\n\nlemma aeval_bind₂ [algebra S T] (f : σ → T) (g : R →+* mv_polynomial σ S) (φ : mv_polynomial σ R) :\n  aeval f (bind₂ g φ) = eval₂_hom ((↑(aeval f : _ →ₐ[S] _) : _ →+* _).comp g) f φ :=\neval₂_hom_bind₂ _ _ _ _\n\nlemma eval₂_hom_C_left (f : σ → mv_polynomial τ R) : eval₂_hom C f = bind₁ f := rfl\n\nlemma bind₁_monomial (f : σ → mv_polynomial τ R) (d : σ →₀ ℕ) (r : R) :\n  bind₁ f (monomial d r) = C r * ∏ i in d.support, f i ^ d i :=\nby simp only [monomial_eq, alg_hom.map_mul, bind₁_C_right, finsupp.prod,\n  alg_hom.map_prod, alg_hom.map_pow, bind₁_X_right]\n\nlemma bind₂_monomial (f : R →+* mv_polynomial σ S) (d : σ →₀ ℕ) (r : R) :\n  bind₂ f (monomial d r) = f r * monomial d 1 :=\nby simp only [monomial_eq, ring_hom.map_mul, bind₂_C_right, finsupp.prod,\n  ring_hom.map_prod, ring_hom.map_pow, bind₂_X_right, C_1, one_mul]\n\n@[simp]\nlemma bind₂_monomial_one (f : R →+* mv_polynomial σ S) (d : σ →₀ ℕ) :\n  bind₂ f (monomial d 1) = monomial d 1 :=\nby rw [bind₂_monomial, f.map_one, one_mul]\n\nsection\nopen_locale classical\n\nlemma vars_bind₁ (f : σ → mv_polynomial τ R) (φ : mv_polynomial σ R) :\n  (bind₁ f φ).vars ⊆ φ.vars.bUnion (λ i, (f i).vars) :=\nbegin\n  calc (bind₁ f φ).vars\n      = (φ.support.sum (λ (x : σ →₀ ℕ), (bind₁ f) (monomial x (coeff x φ)))).vars :\n        by { rw [← alg_hom.map_sum, ← φ.as_sum], }\n  ... ≤ φ.support.bUnion (λ (i : σ →₀ ℕ), ((bind₁ f) (monomial i (coeff i φ))).vars) :\n        vars_sum_subset _ _\n  ... = φ.support.bUnion (λ (d : σ →₀ ℕ), (C (coeff d φ) * ∏ i in d.support, f i ^ d i).vars) :\n        by simp only [bind₁_monomial]\n  ... ≤ φ.support.bUnion (λ (d : σ →₀ ℕ), d.support.bUnion (λ i, (f i).vars)) : _ -- proof below\n  ... ≤ φ.vars.bUnion (λ (i : σ), (f i).vars) : _, -- proof below\n  { apply finset.bUnion_mono,\n    intros d hd,\n    calc (C (coeff d φ) * ∏ (i : σ) in d.support, f i ^ d i).vars\n        ≤ (C (coeff d φ)).vars ∪ (∏ (i : σ) in d.support, f i ^ d i).vars : vars_mul _ _\n    ... ≤ (∏ (i : σ) in d.support, f i ^ d i).vars :\n      by simp only [finset.empty_union, vars_C, finset.le_iff_subset, finset.subset.refl]\n    ... ≤ d.support.bUnion (λ (i : σ), (f i ^ d i).vars) : vars_prod _\n    ... ≤ d.support.bUnion (λ (i : σ), (f i).vars) : _,\n    apply finset.bUnion_mono,\n    intros i hi,\n    apply vars_pow, },\n  { intro j,\n    simp_rw finset.mem_bUnion,\n    rintro ⟨d, hd, ⟨i, hi, hj⟩⟩,\n    exact ⟨i, (mem_vars _).mpr ⟨d, hd, hi⟩, hj⟩ }\nend\nend\n\nlemma mem_vars_bind₁ (f : σ → mv_polynomial τ R) (φ : mv_polynomial σ R) {j : τ}\n  (h : j ∈ (bind₁ f φ).vars) :\n  ∃ (i : σ), i ∈ φ.vars ∧ j ∈ (f i).vars :=\nby simpa only [exists_prop, finset.mem_bUnion, mem_support_iff, ne.def] using vars_bind₁ f φ h\n\ninstance monad : monad (λ σ, mv_polynomial σ R) :=\n{ map := λ α β f p, rename f p,\n  pure := λ _, X,\n  bind := λ _ _ p f, bind₁ f p }\n\ninstance is_lawful_functor : is_lawful_functor (λ σ, mv_polynomial σ R) :=\n{ id_map := by intros; simp [(<$>)],\n  comp_map := by intros; simp [(<$>)] }\n\ninstance is_lawful_monad : is_lawful_monad (λ σ, mv_polynomial σ R) :=\n{ pure_bind := by intros; simp [pure, bind],\n  bind_assoc := by intros; simp [bind, ← bind₁_comp_bind₁] }\n\n/-\nPossible TODO for the future:\nEnable the following definitions, and write a lot of supporting lemmas.\n\ndef bind (f : R →+* mv_polynomial τ S) (g : σ → mv_polynomial τ S) :\n  mv_polynomial σ R →+* mv_polynomial τ S :=\neval₂_hom f g\n\ndef join (f : R →+* S) : mv_polynomial (mv_polynomial σ R) S →ₐ[S] mv_polynomial σ S :=\naeval (map f)\n\ndef ajoin [algebra R S] : mv_polynomial (mv_polynomial σ R) S →ₐ[S] mv_polynomial σ S :=\njoin (algebra_map R S)\n\n-/\n\nend mv_polynomial\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/mv_polynomial/monad.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4775592556722643}}
{"text": "import Mathlib.Data.Nat.Basic\nimport Mathlib.Init.Algebra.Order\nimport Mathlib.Init.Data.Nat.Basic\nimport Mathlib.Init.Data.Nat.Lemmas\nimport Mathlib.Init.Data.Int.Basic\nimport Mathlib.Tactic.LibrarySearch\nimport Mathlib.Data.Equiv.Basic\nimport Mathlib.Init.Data.Int.Order\nimport Timelib.Date.Year\nimport Timelib.Date.Month\nimport Timelib.Date.ScalarDate\nimport Timelib.Date.OrdinalDate\nimport Timelib.Date.Ymd\nimport Timelib.Date.Convert\nimport Timelib.Util\nimport Timelib.Date.Lemmas.YmdOrdinalEquiv\n\ninstance : Equiv Ymd OrdinalDate where\n  toFun := Ymd.toOrdinalDate\n  invFun := OrdinalDate.toYmd\n  left_inv := Ymd.toOrdinalDate_left_inv\n  right_inv := OrdinalDate.toYmd_right_inv\n\ninstance : Equiv OrdinalDate ScalarDate where\n  toFun := OrdinalDate.toScalarDate\n  invFun := ScalarDate.toOrdinalDate\n  left_inv := sorry\n  right_inv := sorry\n\ninstance : Equiv Ymd ScalarDate := \n  Equiv.trans instEquivYmdOrdinalDate instEquivOrdinalDateScalarDate\n\ntheorem OrdinalDate.toYmd_monotonic {ω π : OrdinalDate} : ω <= π → ω.toYmd <= π.toYmd := sorry\n\ntheorem Ymd.toOrdinalDate_monotonic {d₁ d₂ : Ymd} : d₁ <= d₂ → d₁.toOrdinalDate <= d₂.toOrdinalDate := sorry\n\ntheorem OrdinalDate.toScalarDate_monotonic {ω π : OrdinalDate} : ω <= π → ω.toScalarDate <= π.toScalarDate := sorry\n\ntheorem ScalarDate.toOrdinalDate_monotonic {d1 d2 : ScalarDate} : d1 <= d2 → d1.toOrdinalDate <= d2.toOrdinalDate := sorry\n\ntheorem Ymd.toScalarDate_monotonic {y1 y2 : Ymd} : y1 <= y2 → y1.toScalarDate <= y2.toScalarDate := \n  OrdinalDate.toScalarDate_monotonic ∘ Ymd.toOrdinalDate_monotonic\n\ntheorem ScalarDate.toYmd_monotonic {d1 d2 : ScalarDate} : d1 <= d2 → d1.toYmd <= d2.toYmd :=\n  OrdinalDate.toYmd_monotonic ∘ ScalarDate.toOrdinalDate_monotonic\n", "meta": {"author": "ammkrn", "repo": "timelib", "sha": "185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15", "save_path": "github-repos/lean/ammkrn-timelib", "path": "github-repos/lean/ammkrn-timelib/timelib-185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15/Timelib/Date/Lemmas/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.47755924999901217}}
{"text": "import ring_theory.algebraic\n-- import data.finset\n-- import algebra.field\n-- import field_theory.subfield\nimport field_theory.algebraic_closure\n-- import order.zorn\nimport Rings.ToMathlib\n-- import data.mv_polynomial.equiv\n-- import data.equiv.fin\n\nopen classical\nlocal attribute [instance] prop_decidable\n\nuniverses u v v0\n\n\nsection nttn\n\n\n@[simp] def algebra.image\n  (K : Type u) (L : Type v) [comm_semiring K] [semiring L] [algebra K L] : set L :=\nset.range (algebra_map K L)\n\n@[simp] def subfield_generated\n  (K : Type u) {L : Type v} [field K] [field L] [algebra K L] (S : set L)\n  : subfield L :=\nsubfield.closure (S ∪ algebra.image K L)\n\nnamespace subfield_generated\n\nvariables\n  (K : Type*) {L : Type*} [field K] [field L] [algebra K L] (S : set L)\n\nlemma subset_closure_set : S ⊆ subfield_generated K S :=\nbegin\n  intros _ hs,\n  simp only [subfield_generated, set_like.mem_coe],\n  apply subfield.subset_closure,\n  left,\n  exact hs,\nend\n\nlemma subset_closure_base (a : K) : algebra_map K L a ∈ subfield_generated K S :=\nbegin\n  simp only [subfield_generated, set_like.mem_coe],\n  apply subfield.subset_closure,\n  right,\n  simp only [set.mem_range_self, algebra.image]\nend\n\n@[simp] def ring_hom : K →+* subfield_generated K S :=\n⟨\n  (λ a, ⟨ algebra_map K L a , subset_closure_base K S a⟩ ),\n  begin simp only [ring_hom.map_one], refl end,\n  begin intros, simp only [ring_hom.map_mul], refl end,\n  begin simp only [ring_hom.map_zero], refl end,\n  begin intros, simp only [ring_hom.map_add], refl end\n⟩\n\ninstance has_scalar : has_scalar K (subfield_generated K S) :=\n⟨ λ a r, (ring_hom K S a) * r ⟩\n-- #check algebra\n\n@[simp] instance algebra : algebra K (subfield_generated K S) :=\n⟨\n  ring_hom K S ,\n  λ r, field.mul_comm (ring_hom K S r),\n  (λ r x, rfl) ,\n⟩\n\n@[simp] noncomputable def eval {n : ℕ} (as : fin n → L) (has : Π k, as k ∈ S) :\n  mv_polynomial (fin n) K →+* subfield_generated K S :=\n  mv_polynomial.eval₂_hom (algebra_map K (subfield_generated K S))\n    (λ k, ⟨ as k , subfield_generated.subset_closure_set K S (has k) ⟩)\n\nlemma eval_proj {n : ℕ} (as : fin n → L) (has : Π k, as k ∈ S) (p : mv_polynomial (fin n) K) :\n  ((subfield_generated.eval K S as has) p).val\n    = mv_polynomial.eval as (p : mv_polynomial (fin n) L) :=\n-- lemma eval_proj {n : ℕ} (as : fin n → L) (has : Π k, as k ∈ S) (p : mv_polynomial (fin n) K) :\n--   ((subfield_generated.eval K S as has) p).val\n--     = mv_polynomial.eval as (mv_polynomial.map (algebra_map K L) p) :=\n-- mv_polynomial.induction_on p _ _ _\n\n@mv_polynomial.induction_on K (fin n) _\n  (λ q, ((subfield_generated.eval K S as has) q).val\n    = mv_polynomial.eval as (q : mv_polynomial (fin n) L))\n  p\n(begin\n  intro a,\n  simp only [eval, mv_polynomial.map_C, mv_polynomial.eval_C, ring_hom.to_fun_eq_coe,\n    mv_polynomial.eval₂_hom_C, subtype.val_eq_coe, algebra_map],\n  unfold_coes,\n  simpa,\nend)\n(begin\n  intros p q hp hq,\n  simp only [eval, mv_polynomial.coe_eval₂_hom, subfield.coe_add, ring_hom.to_fun_eq_coe,\n     mv_polynomial.eval₂_add, mv_polynomial.eval_map, subtype.val_eq_coe],\n  simp only [eval, mv_polynomial.coe_eval₂_hom, subfield.coe_add, ring_hom.to_fun_eq_coe,\n     mv_polynomial.eval₂_add, mv_polynomial.eval_map, subtype.val_eq_coe] at hp hq,\n  rw [hp, hq],\n  unfold_coes,\n  simp,\nend)\n(begin\n  intros p n hp,\n  unfold_coes,\n  simp only [mv_polynomial.eval_X, eval, subfield.coe_mul, ring_hom.to_fun_eq_coe,\n    mv_polynomial.coe_eval₂_hom, subfield_generated,\n    mv_polynomial.eval_map, subfield_generated.algebra,\n    subtype.coe_mk, mul_eq_mul_right_iff, mv_polynomial.eval₂_X,\n    ring_hom.map_mul, subtype.val_eq_coe, mv_polynomial.map_X],\n  left,\n  unfold_coes at hp,\n  simp only [eval, mv_polynomial.coe_eval₂_hom, ring_hom.to_fun_eq_coe,\n    mv_polynomial.eval_map, subtype.val_eq_coe] at hp,\n  exact hp,\nend)\n\nend subfield_generated\n\nend nttn\n\nnamespace transcendent\n\nvariables\n  (K : Type u) {L : Type u} [field K] [field L] [algebra K L]\n\ndef indep (S : set L) : Prop :=\nΠ (n : ℕ) (f : mv_polynomial (fin n) K) (as : fin n → L),\n(Π k, as k ∈ S) → mv_polynomial.eval as (f : mv_polynomial (fin n) L) = 0 → f = 0\n\nlemma indep_subset (S T : set L) (hST : S ⊆ T) : indep K T → indep K S :=\nbegin\n  intros hT _ f as has hf,\n  have has' : Π k, as k ∈ T := λ k, hST (has k),\n  exact hT _ f as has' hf,\nend\n\n\nlemma indep_empty : indep K (∅ : set L)\n| nat.zero f as has hf :=\nbegin\n  apply @mv_polynomial.map_injective K L (fin 0) _ _ (algebra_map K L) (ring_hom.injective _),\n  simp,\n  rw mv_polynomial.is_empty (fin.is_empty) (mv_polynomial.map (algebra_map K L) f) as,\n  rw ← mv_polynomial.C_0,\n  rw (mv_polynomial.C_inj L),\n  rw ← hf,\n  simp only [mv_polynomial.eval, mv_polynomial.eval_map],\n  unfold_coes,\nend\n| (nat.succ n) f as has hf :=\nbegin\n  exfalso,\n  rw ← set.mem_empty_eq (as 0),\n  {apply has},\nend\n\nlemma indep_sUnion_chain {c : set (set L)} (hchain : zorn.chain has_subset.subset c)\n  (h0 : c.nonempty)\n  (hc : Π (S : set L) (hS : S ∈ c), indep K S) :\n  indep K ⋃₀ c :=\nbegin\n  intros k f as has hf,\n  cases zorn.fin_range_sub_mem_chain_of_sub_union hchain h0 as has with S hS,\n  cases hS with hSc hS,\n  apply hc S hSc _ _ as _ hf,\n  exact hS,\nend\n\ndef basis (B : set L) : Prop := indep K B ∧ Π (S : set L), indep K S → B ⊆ S → S = B\n\nlemma extend_to_basis_aux (S : set L) (hindS : indep K S) :\n  ∃ (B : set L) (H : B ∈ {T : set L | S ⊆ T ∧ indep K T}),\n  S ⊆ B ∧ Π (T : set L), T ∈ {T : set L | S ⊆ T ∧ indep K T} → B ⊆ T → T = B :=\n(@zorn.zorn_subset_nonempty L { T : set L | S ⊆ T ∧ indep K T }\n  (λ c hcsub hchain hc0,\n    ⟨\n      -- the upper bound by taking union\n      ⋃₀ c ,\n      ⟨\n        let hScup : S ⊆ ⋃₀ c :=\n        begin\n          cases hc0 with T hT,\n          cases hcsub hT with hST hand,\n          have hTcup : T ⊆ ⋃₀ c := λ t ht , ⟨ T , hT , ht ⟩,\n          exact set.subset.trans hST hTcup,\n        end in\n        ⟨ -- the upper bound is in the set\n          hScup ,\n          indep_sUnion_chain K hchain hc0 (λ S hs, (hcsub hs).2)\n        ⟩ ,\n        (λ S hS s hs, ⟨ S , hS , hs ⟩) -- showing the maximal element is in the set\n      ⟩\n    ⟩\n  )\n  S -- give U for the set being non-empty\n  ⟨ set.subset.refl _ , hindS ⟩)\n\nlemma subfield_mem (a : L) (K : subfield L) (haK : a ∈ K) :\n  a = algebra_map K L (⟨ a , haK ⟩ : K) := rfl\n\nlemma is_algebraic_subfield {a : L} {K : subfield L} (haK : a ∈ K) : is_algebraic K a :=\n⟨\n  polynomial.X - polynomial.C (⟨ a , haK ⟩ : K) ,\n  polynomial.X_sub_C_ne_zero _ ,\n  begin\n    simp only [polynomial.aeval_X, polynomial.aeval_C, alg_hom.map_sub],\n    rw ← subfield_mem a K haK,\n    simp,\n  end\n⟩\n\n-- #check @mv_polynomial.map_injective\n-- -- mv_polynomial.eval₂ polynomial.C bs (⇑(mv_polynomial.map (subfield_generated.ring_hom K B)) f)\n\n-- #check @ring_hom.injective\n\n-- #check @mv_polynomial.eval₂\n\n-- #check mv_polynomial.eval₂_zero\n-- --\n-- #check polynomial.as_sum_range\n\nlemma mv_polynomial.zero_iff {K : Type u} {R : Type v} {σ : Type v0} [field K] [comm_semiring R]\n  [nontrivial R] (f : K →+* R) (p : mv_polynomial σ K) : p = 0 ↔ mv_polynomial.map f p = 0 :=\nbegin\n  split,\n  {intro hp, rw hp, simp,},\n  {\n    intro hp,\n    apply mv_polynomial.map_injective f (ring_hom.injective f),\n    simpa using hp,\n  },\nend\n\n-- #check mv_polynomial.fin_succ_equiv\n\n-- #check mv_polynomial.eval₂\n\n-- #check mv_polynomial.mv_polynomial_equiv_mv_polynomial\n\nlemma insert_dependent_to_is_algebraic_aux {n : ℕ} {S : set L} {a : L} :\n  (∃ (p : mv_polynomial (fin n.succ) K) (as : fin n.succ → L) (has : ∀ (k : fin n.succ), as k ∈ S ∪ {a})\n    (hp : (mv_polynomial.eval as) p = 0), p ≠ 0)\n  →\n  (∃ (p : polynomial (mv_polynomial (fin n) K)) (as : fin n → L)\n    (has : ∀ (k : fin n), as k ∈ S)\n    (hp : (polynomial.aeval a) (polynomial.map (subfield_generated.eval K S as has) p) = 0), p ≠ 0) :=\nsorry\n\n-- should really be iff\nlemma insert_dependent_to_is_algebraic (S : set L) (hS : indep K S) (a : L) :\n  ¬ indep K (S ∪ {a}) → is_algebraic (subfield_generated K S) a :=\nbegin\n  intro hdep,\n  simp only [indep, not_forall] at hdep,\n  cases hdep with n hdep,\n  cases n,\n  {\n    cases hdep with f hdep,\n    cases hdep with as hdep,\n    cases hdep with has hdep,\n    cases hdep with hf hf0,\n    exfalso,\n    apply hf0,\n    have h := mv_polynomial.is_empty fin.is_empty (f : mv_polynomial (fin 0) L) as,\n    rw (congr_arg (@mv_polynomial.C L (fin 0) _) hf) at h,\n    simp only [mv_polynomial.C_0] at h,\n    rw mv_polynomial.zero_iff (algebra_map K L) f,\n    exact h,\n  },\n  {\n    have hf := insert_dependent_to_is_algebraic_aux K hdep,\n    cases hf with f hf,\n    cases hf with as hf,\n    cases hf with has hf,\n    cases hf with hf hf0,\n    -- evaluate f at the terms in S to produce a polynomial in K(S)[X]\n    -- (subfield_generated.eval K S as has) : mv_polynomial (fin n) K →+* subfield_generated K S\n    use polynomial.map (subfield_generated.eval K S as has) f,\n    split,\n    {\n      intro hp,\n      apply hf0,\n      apply polynomial.ext,\n      intro m,\n      rw polynomial.coeff_zero,\n      rw polynomial.ext_iff at hp,\n      have hpm := hp m,\n      rw polynomial.coeff_zero at hpm,\n      rw polynomial.coeff_map at hpm,\n      -- we use that S is independent to show each `f.coeff m` is 0 ~ they evaluate to 0 via\n      -- elements of S\n      apply hS n (f.coeff m) as has,\n      -- it remains to show that evaluating at `as` in K(S) is the same as evaluating at `as` in L\n      rw ← subfield_generated.eval_proj K S as has (f.coeff m),\n      rw hpm,\n      simp only [subfield.coe_zero, subtype.val_eq_coe],\n    },\n    {exact hf,},\n  },\nend\n\n-- lemma insert_dependent_iff_is_algebraic (S : set L) (a : L) :\n--   ¬ indep K (S ∪ {a}) → is_algebraic (subfield_generated K S) a :=\n-- begin\n--   intro hdep,\n--   simp only [indep, not_forall] at hdep,\n--     cases hdep with n hdep,\n--     cases hdep with f hdep,\n--     cases hdep with as hdep,\n--     cases hdep with has hdep,\n--     cases hdep with hf hf0,\n--     let bs : fin n → polynomial (subfield_generated K S) :=\n--     λ k, @decidable.by_cases (as k ∈ S) (polynomial (subfield_generated K S)) _\n--       (λ h, polynomial.C\n--         (⟨ as k , subfield_generated.subset_closure_set K S h ⟩ : subfield_generated K S))\n--       (λ _, polynomial.X),\n--     let p : polynomial (subfield_generated K S) :=\n--       mv_polynomial.eval₂ polynomial.C bs\n--       (mv_polynomial.map (subfield_generated.ring_hom K S) f),\n--     use p,\n--     split,\n--     {\n--       intro hp,\n--       apply hf0,\n--       rw mv_polynomial.zero_iff (subfield_generated.ring_hom K S),\n\n--       sorry,\n--     },\n--     {\n--       simp only [p],\n--       rw ← hf,\n--       simp,\n--       sorry,\n--     },\n-- end\n\nlemma algebraic_over_basis (B : set L) (hB : basis K B) :\n  algebra.is_algebraic (subfield_generated K B) L :=\nbegin\n  intro x,\n  by_cases hind : indep K (B ∪ {x}),\n  {\n    -- if B ∪ {x} is independent then x ∈ B since B is a basis\n    have hBx := hB.2 (B ∪ {x}) hind (by simp),\n    -- hence x ∈ K(B) and is independent over K(B)\n    have hxBx : x ∈ subfield_generated K B,\n    {apply subfield.subset_closure, left, rw ← hBx, right, exact set.mem_singleton x},\n    apply is_algebraic_subfield hxBx,\n  },\n  {\n    apply insert_dependent_to_is_algebraic K B hB.1 x hind,\n  }\nend\n\nvariables (K) (L)\n\nlemma extend_to_basis (S : set L) (hindS : indep K S) :\n    ∃ (B : set L), S ⊆ B ∧ basis K B :=\nbegin\n  cases extend_to_basis_aux K S hindS with B hB,\n  cases hB with hmem hB,\n  cases hB with hSB hbasis,\n  use B,\n  split,\n  {exact hSB},\n  {\n    split,\n    {exact hmem.2},\n    {\n      intros T hindT hBT,\n      apply hbasis T _ hBT,\n      exact ⟨ set.subset.trans hSB hBT , hindT ⟩,\n    }\n  }\nend\n\nlemma basis_ex : ∃ (B : set L), basis K B :=\nbegin\n  cases extend_to_basis K L ∅ (indep_empty K) with B hB,\n  use B,\n  exact hB.2,\nend\n\nlemma basis_some : set L := @classical.some (set L) (λ S, basis K S) (basis_ex K L)\n\nlemma degree : cardinal.{u} := cardinal.mk (basis_some K L)\n\n\nend transcendent\n\n\nnamespace field_theory\n\nvariables\n  {K L0 L1 : Type u}\n  [field K] [field L0] [field L1]\n  [algebra K L0] [algebra K L1]\n\nopen transcendent algebra\n\nlemma iso_of_bij_indep (S0 : set L0) (S1 : set L1) :\n  indep K S0 → indep K S1 → equiv S0 S1 →\n  subfield_generated K S0 ≃+* subfield_generated K S1 :=\nsorry\n\nlemma iso_of_alg_closed_algebraic\n  {K0 K1 L0 L1: Type u} [field K0] [field K1] [field L0] [field L1]\n  [is_alg_closed L0] [is_alg_closed L1]\n  [algebra K0 L0] [algebra K1 L1] : K0 ≃+* K1 →\n  is_algebraic K0 L0 → is_algebraic K1 L1 → L0 ≃+* L1 := sorry\n\nlemma iso_of_alg_closed_of_eq_trans_deg [is_alg_closed L0] [is_alg_closed L1]\n  (B0 : set L0) (B1 : set L1) : transcendent.basis K B0 → transcendent.basis K B1 →\n  equiv B0 B1\n  → L0 ≃+* L1 :=\nbegin\n  intros hB0 hB1 htdeg,\n  apply iso_of_alg_closed_algebraic _\n  (algebraic_over_basis K B0 hB0)\n  (algebraic_over_basis K B1 hB1),\n  apply iso_of_bij_indep B0 B1 hB0.1 hB1.1 htdeg,\nend\n\n\n\nend field_theory\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/TranscendenceDegree.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4775447296089965}}
{"text": "import algebra\nimport data.real.basic\nimport data.vector\nimport tactic.explode\nimport tactic.find\nimport tactic.induction\nimport tactic.linarith\nimport tactic.rcases\nimport tactic.rewrite\nimport tactic.ring_exp\nimport tactic.tidy\nimport tactic.where\n\n\n/-! # LoVe Library\n\nThis files contains a few extensions on top of Lean's core libraries and\n`mathlib`. -/\n\n\nnamespace LoVe\n\n\n/-! ## Structured Proofs -/\n\nnotation `fix ` binders `, ` r:(scoped f, f) := r\n\n\n/-! ## Logical Connectives -/\n\nmeta def tactic.dec_trivial := `[exact dec_trivial]\n\nlemma not_def (a : Prop) :\n  ¬ a ↔ a → false :=\nby refl\n\n@[simp] lemma not_not_iff (a : Prop) [decidable a] :\n  ¬¬ a ↔ a :=\nby by_cases a; simp [h]\n\n@[simp] lemma and_imp_distrib (a b c : Prop) :\n  (a ∧ b → c) ↔ (a → b → c) :=\niff.intro\n  (assume h ha hb, h ⟨ha, hb⟩)\n  (assume h ⟨ha, hb⟩, h ha hb)\n\n@[simp] lemma or_imp_distrib {a b c : Prop} :\n  a ∨ b → c ↔ (a → c) ∧ (b → c) :=\niff.intro\n  (assume h,\n   ⟨assume ha, h (or.intro_left _ ha), assume hb, h (or.intro_right _ hb)⟩)\n  (assume ⟨ha, hb⟩ h, match h with or.inl h := ha h | or.inr h := hb h end)\n\n@[simp] lemma exists_imp_distrib {α : Sort*} {p : α → Prop} {a : Prop} :\n  ((∃x, p x) → a) ↔ (∀x, p x → a) :=\niff.intro\n  (assume h hp ha, h ⟨hp, ha⟩)\n  (assume h ⟨hp, ha⟩, h hp ha)\n\nlemma and_exists {α : Sort*} {p : α → Prop} {a : Prop} :\n  (a ∧ (∃x, p x)) ↔ (∃x, a ∧ p x) :=\niff.intro\n  (assume ⟨ha, x, hp⟩, ⟨x, ha, hp⟩)\n  (assume ⟨x, ha, hp⟩, ⟨ha, x, hp⟩)\n\n@[simp] lemma exists_false {α : Sort*} :\n  (∃x : α, false) ↔ false :=\niff.intro (assume ⟨a, f⟩, f) (assume h, h.elim)\n\n\n/-! ## Natural Numbers -/\n\nattribute [simp] nat.add\n\n\n/-! ## Integers -/\n\n@[simp] lemma int.neg_comp_neg :\n  int.neg ∘ int.neg = id :=\nbegin\n  apply funext,\n  apply neg_neg\nend\n\n\n/-! ## Reflexive Transitive Closure -/\n\nnamespace rtc\n\ninductive star {α : Sort*} (r : α → α → Prop) (a : α) : α → Prop\n| refl {}    : star a\n| tail {b c} : star b → r b c → star c\n\nattribute [refl] star.refl\n\nnamespace star\n\nvariables {α : Sort*} {r : α → α → Prop} {a b c d : α}\n\n@[trans] lemma trans (hab : star r a b) (hbc : star r b c) :\n  star r a c :=\nbegin\n  induction' hbc,\n  case refl {\n    assumption },\n  case tail : c d hbc hcd hac {\n    exact (tail (hac hab)) hcd }\nend\n\nlemma single (hab : r a b) :\n  star r a b :=\nrefl.tail hab\n\nlemma head (hab : r a b) (hbc : star r b c) :\n  star r a c :=\nbegin\n  induction' hbc,\n  case refl {\n    exact (tail refl) hab },\n  case tail : c d hbc hcd hac {\n    exact (tail (hac hab)) hcd }\nend\n\nlemma head_induction_on {α : Sort*} {r : α → α → Prop} {b : α}\n  {P : ∀a : α, star r a b → Prop} {a : α} (h : star r a b)\n  (refl : P b refl)\n  (head : ∀{a c} (h' : r a c) (h : star r c b), P c h → P a (h.head h')) :\n  P a h :=\nbegin\n  induction' h,\n  case refl {\n    exact refl },\n  case tail : b c hab hbc ih {\n    apply ih,\n    show P b _, from\n      head hbc _ refl,\n    show ∀a a', r a a' → star r a' b → P a' _ → P a _, from\n      assume a a' hab hbc, head hab _ }\nend\n\nlemma trans_induction_on {α : Sort*} {r : α → α → Prop}\n    {p : ∀{a b : α}, star r a b → Prop} {a b : α} (h : star r a b)\n    (ih₁ : ∀a, @p a a refl) (ih₂ : ∀{a b} (h : r a b), p (single h))\n    (ih₃ : ∀{a b c} (h₁ : star r a b) (h₂ : star r b c), p h₁ →\n       p h₂ → p (h₁.trans h₂)) :\n  p h :=\nbegin\n  induction' h,\n  case refl {\n    exact ih₁ a },\n  case tail : b c hab hbc ih {\n    exact ih₃ hab (single hbc) (ih ih₁ @ih₂ @ih₃) (ih₂ hbc) }\nend\n\nlemma lift {β : Sort*} {s : β → β → Prop} (f : α → β)\n  (h : ∀a b, r a b → s (f a) (f b)) (hab : star r a b) :\n  star s (f a) (f b) :=\nhab.trans_induction_on\n  (assume a, refl)\n  (assume a b, single ∘ h _ _)\n  (assume a b c _ _, trans)\n\nlemma mono {p : α → α → Prop} :\n  (∀a b, r a b → p a b) → star r a b → star p a b :=\nlift id\n\nlemma star_star_eq :\n  star (star r) = star r :=\nfunext\n  (assume a,\n   funext\n     (assume b,\n      propext (iff.intro\n        (assume h,\n         begin\n           induction' h,\n           { refl },\n           { transitivity;\n               assumption }\n         end)\n        (star.mono (assume a b,\n           single)))))\n\nend star\n\nend rtc\n\nexport rtc\n\n\n/-! ## States -/\n\ndef state : Type :=\nstring → ℕ\n\ndef state.update (name : string) (val : ℕ) (s : state) : state :=\nλname', if name' = name then val else s name'\n\nnotation s `{` name ` ↦ ` val `}` := state.update name val s\n\ninstance : has_emptyc state :=\n{ emptyc := λ_, 0 }\n\n@[simp] lemma update_apply (name : string) (val : ℕ) (s : state) :\n  s{name ↦ val} name = val :=\nif_pos rfl\n\n@[simp] lemma update_apply_ne (name name' : string) (val : ℕ) (s : state)\n    (h : name' ≠ name . tactic.dec_trivial) :\n  s{name ↦ val} name' = s name' :=\nif_neg h\n\n@[simp] lemma update_override (name : string) (val₁ val₂ : ℕ) (s : state) :\n  s{name ↦ val₂}{name ↦ val₁} = s{name ↦ val₁} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma update_swap (name₁ name₂ : string) (val₁ val₂ : ℕ) (s : state)\n    (h : name₁ ≠ name₂ . tactic.dec_trivial) :\n  s{name₂ ↦ val₂}{name₁ ↦ val₁} = s{name₁ ↦ val₁}{name₂ ↦ val₂} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name₁;\n    by_cases name' = name₂;\n    simp * at *\nend\n\n@[simp] lemma update_id (name : string) (s : state) :\n  s{name ↦ s name} = s :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp * at *\nend\n\n@[simp] lemma update_same_const (name : string) (val : ℕ) :\n  (λ_, val){name ↦ val} = (λ_, val) :=\nby apply funext; simp\n\nexample (s : state) :\n  s{\"a\" ↦ 0}{\"a\" ↦ 2} = s{\"a\" ↦ 2} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" ↦ 0}{\"b\" ↦ 2} = s{\"b\" ↦ 2}{\"a\" ↦ 0} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" ↦ s \"a\"}{\"b\" ↦ 0} = s{\"b\" ↦ 0} :=\nby simp\n\n\n/-! ## Relations -/\n\ndef Id {α : Type} : set (α × α) :=\n{ab | prod.snd ab = prod.fst ab}\n\n@[simp] lemma mem_Id {α : Type} (a b : α) :\n  (a, b) ∈ @Id α ↔ b = a :=\nby refl\n\ndef comp {α : Type} (r₁ r₂ : set (α × α)) : set (α × α) :=\n{ac | ∃b, (prod.fst ac, b) ∈ r₁ ∧ (b, prod.snd ac) ∈ r₂}\n\ninfixl ` ◯ ` : 90 := comp\n\n@[simp] lemma mem_comp {α : Type} (r₁ r₂ : set (α × α))\n    (a b : α) :\n  (a, b) ∈ r₁ ◯ r₂ ↔ (∃c, (a, c) ∈ r₁ ∧ (c, b) ∈ r₂) :=\nby refl\n\ndef restrict {α : Type} (r : set (α × α)) (p : α → Prop) :\n  set (α × α) :=\n{ab | ab ∈ r ∧ p (prod.fst ab)}\n\ninfixl ` ⇃ ` : 90 := restrict\n\n@[simp] lemma mem_restrict {α : Type} (r : set (α × α))\n    (p : α → Prop) (a b : α) :\n  (a, b) ∈ r ⇃ p ↔ (a, b) ∈ r ∧ p a :=\nby refl\n\n\n/-! ## Setoids -/\n\ndef equivalence_rel : Type → Type :=\nsetoid\n\nend LoVe\n", "meta": {"author": "blanchette", "repo": "logical_verification_2021", "sha": "23b469c79afd482fa66da82e4726a317e3a7b5d5", "save_path": "github-repos/lean/blanchette-logical_verification_2021", "path": "github-repos/lean/blanchette-logical_verification_2021/logical_verification_2021-23b469c79afd482fa66da82e4726a317e3a7b5d5/lean/lovelib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4775297491120711}}
{"text": "import quarterround\n\nimport category_theory.category.basic\n\nopen quarterround\n\nopen category_theory\n\nnamespace quarterround_examples\n\nvariable [category (bitvec params.word_len)]\n\n/-!\n  # Examples from the spec.\n\n  https://cr.yp.to/snuffle/spec.pdf\n-/\n\n/-!\n## Example 1 : \n\n> quarterround(0x00000000, 0x00000000, 0x00000000, 0x00000000) = (0x00000000, 0x00000000, 0x00000000, 0x00000000)\n-/\n\n/-- `quarterround (0, 0, 0, 0) = (0, 0, 0, 0)` -/\nlemma example1_quarterround : quarterround (0x00000000, 0x00000000, 0x00000000, 0x00000000) =\n    (0x000000000, 0x00000000, 0x00000000, 0x00000000) := by refl\n\n/-!\n## Example 2 : \n\n> quarterround(0x00000001, 0x00000000, 0x00000000, 0x00000000) = (0x08008145, 0x00000080, 0x00010200, 0x20500000)\n-/\n\n/-- `qr1 (1, 0, 0, 0) = 128` -/\nlemma example2_qr1 : qr1 0x00000001 0x00000000 0x00000000 0x00000000 = 0x00000080 :=\nbegin\n  rw [qr1, operations.operation, operations.operation_rhs, operations.xor, operations.mod,\n    operations.rotl, params.max_bitvec, params.mod, params.word_len, bitvec.of_nat,\n    bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num1,\n  refl,\nend\n\n/-- `qr2 (1, 0, 0, 0) = 66048` -/\nlemma example2_qr2 : qr2 0x00000001 0x00000000 0x00000000 0x00000000 = 0x00010200 :=\nbegin\n  rw [qr2, qr1],\n  repeat { \n    rw [operations.operation, operations.operation_rhs, operations.xor, operations.mod, operations.rotl] \n  },\n  rw [params.max_bitvec, params.mod, params.word_len, bitvec.of_nat, bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num,\n  refl,\nend\n\n/-- `qr3 (1, 0, 0, 0) = 542113792` -/\nlemma example2_qr3 : qr3 0x00000001 0x00000000 0x00000000 0x00000000 = 0x20500000 :=\nbegin\n  rw [qr3, qr1, qr2, qr1],\n  -- TODO: This is the same as `example2_qr2`\n  repeat { \n    rw [operations.operation, operations.operation_rhs, operations.xor, operations.mod, operations.rotl] \n  },\n  rw [params.max_bitvec, params.mod, params.word_len, bitvec.of_nat, bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num,\n  refl,\nend\n\n/-- `qr0 (1, 0, 0, 0) = 134250821` -/\nlemma example2_qr0 : qr0 0x00000001 0x00000000 0x00000000 0x00000000 = 0x08008145 :=\nbegin\n  rw [qr0, qr3, qr2, qr1],\n  -- TODO: This is the same as `example2_qr2`\n  repeat { \n    rw [operations.operation, operations.operation_rhs, operations.xor, operations.mod, operations.rotl] \n  },\n  rw [params.max_bitvec, params.mod, params.word_len, bitvec.of_nat, bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num,\n  refl,\nend\n\n/-- `quarterround (1, 0, 0, 0) = (134250821, 128, 66048, 542113792)` -/\nlemma example2_quarterround : quarterround (0x00000001, 0x00000000, 0x00000000, 0x00000000) =\n    (0x08008145, 0x00000080, 0x00010200, 0x20500000) :=\nbegin\n  rw [quarterround, example2_qr0, example2_qr1, example2_qr2, example2_qr3],\nend\n\n/-!\n## Example 3 : \n\n> quarterround(0x00000000, 0x00000001, 0x00000000, 0x00000000) = (0x88000100, 0x00000001, 0x00000200, 0x00402000)\n\n-/\n\n/-- `qr1 (0, 1, 0, 0) = 1` -/\nlemma example3_qr1 : qr1 0x00000000 0x00000001 0x00000000 0x00000000 = 0x00000001 :=\nbegin\n  -- TODO: this is the exact same proof as `example2_qr1`.\n  rw [qr1, operations.operation, operations.operation_rhs, operations.xor, operations.mod,\n    operations.rotl, params.max_bitvec, params.mod, params.word_len, bitvec.of_nat,\n    bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num1,\n  refl,\nend\n\n/-- `qr2 (0, 1, 0, 0) = 512` -/\nlemma example3_qr2 : qr2 0x00000000 0x00000001 0x00000000 0x00000000 = 0x00000200 :=\nbegin\n  -- TODO: this is the exact same proof as `example2_qr2`.\n  rw [qr2, qr1],\n  repeat { \n    rw [operations.operation, operations.operation_rhs, operations.xor, operations.mod, operations.rotl] \n  },\n  rw [params.max_bitvec, params.mod, params.word_len, bitvec.of_nat, bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num,\n  refl,\nend\n\n/-- `qr3 (0, 1, 0, 0) = 4202496` -/\nlemma example3_qr3 : qr3 0x00000000 0x00000001 0x00000000 0x00000000 = 0x00402000 :=\nbegin\n  -- TODO: this is the exact same proof as `example2_qr3`.\n  rw [qr3, qr1, qr2, qr1],\n  repeat { \n    rw [operations.operation, operations.operation_rhs, operations.xor, operations.mod, operations.rotl] \n  },\n  rw [params.max_bitvec, params.mod, params.word_len, bitvec.of_nat, bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num,\n  refl,\nend\n\n/-- `qr0 (0, 1, 0, 0) = 2281701632` -/\nlemma example3_qr0 : qr0 0x00000000 0x00000001 0x00000000 0x00000000 = 0x88000100 :=\nbegin\n  -- TODO: This is the same as `example2_qr0`\n  rw [qr0, qr3, qr2, qr1],\n  repeat { \n    rw [operations.operation, operations.operation_rhs, operations.xor, operations.mod, operations.rotl] \n  },\n  rw [params.max_bitvec, params.mod, params.word_len, bitvec.of_nat, bitvec.shl, bitvec.ushr, bitvec.fill_shr],\n  dunfold bitvec.of_nat,\n  norm_num,\n  refl,\nend\n\n/-- `quarterround (0, 1, 0, 0) = (2281701632, 1, 512, 4202496)` -/\nlemma example3_quarterround : quarterround (0x00000000, 0x00000001, 0x00000000, 0x00000000) =\n    (0x88000100, 0x00000001, 0x00000200, 0x00402000) :=\nbegin\n  rw [quarterround, example3_qr0, example3_qr1, example3_qr2, example3_qr3],\nend\n\n/-!\n  ## TODO\n\n  - find a way that can make this shorter.\n  - continue the examples from the spec.\n  - add inverse examples.\n-/\n\nend quarterround_examples\n", "meta": {"author": "oxarbitrage", "repo": "salsa20", "sha": "12d0ebb3c27801931e61d470fb2ed548a5562578", "save_path": "github-repos/lean/oxarbitrage-salsa20", "path": "github-repos/lean/oxarbitrage-salsa20/salsa20-12d0ebb3c27801931e61d470fb2ed548a5562578/src/examples/quarterround.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4775297366184481}}
{"text": "/-\nCopyright (c) 2022 Henrik Böving. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henrik Böving, Simon Hudon\n-/\n\nimport Mathlib.Data.Array.Basic\nimport Mathlib.Testing.SlimCheck.Sampleable\nimport Lean\n\n/-!\n# `Testable` Class\nTestable propositions have a procedure that can generate counter-examples\ntogether with a proof that they invalidate the proposition.\n\nThis is a port of the Haskell QuickCheck library.\n\n## Creating Customized Instances\nThe type classes `Testable`, `SampleableExt` and `Shrinkable` are the\nmeans by which `SlimCheck` creates samples and tests them. For instance,\nthe proposition `∀ i j : ℕ, i ≤ j` has a `Testable` instance because `ℕ`\nis sampleable and `i ≤ j` is decidable. Once `SlimCheck` finds the `Testable`\ninstance, it can start using the instance to repeatedly creating samples\nand checking whether they satisfy the property. Once it has found a\ncounter-example it will then use a `Shrinkable` instance to reduce the\nexample. This allows the user to create new instances and apply\n`SlimCheck` to new situations.\n\n### What do I do if I'm testing a property about my newly defined type?\nLet us consider a type made for a new formalization:\n```lean\nstructure MyType where\n  x : ℕ\n  y : ℕ\n  h : x ≤ y\n  deriving Repr\n```\nHow do we test a property about `MyType`? For instance, let us consider\n`Testable.check $ ∀ a b : MyType, a.y ≤ b.x → a.x ≤ b.y`. Writing this\nproperty as is will give us an error because we do not have an instance\nof `Shrinkable MyType` and `SampleableExt MyType`. We can define one as follows:\n```lean\ninstance : Shrinkable MyType where\n  shrink := λ ⟨x,y,h⟩ =>\n    let proxy := Shrinkable.shrink (x, y - x)\n    proxy.map (λ ⟨⟨fst, snd⟩, ha⟩ => ⟨⟨fst, fst + snd, sorry⟩, sorry⟩)\n\ninstance : SampleableExt MyType :=\n  SampleableExt.mkSelfContained do\n    let x ← SampleableExt.interpSample Nat\n    let xyDiff ← SampleableExt.interpSample Nat\n    pure $ ⟨x, x + xyDiff, sorry⟩\n```\nAgain, we take advantage of the fact that other types have useful\n`Shrinkable` implementations, in this case `Prod`. Note that the second\nproof is heavily based on `WellFoundedRelation` since its used for termination so\nthe first step you want to take is almost always to `simp_wf` in order to\nget through the `WellFoundedRelation`.\n\n## Main definitions\n  * `Testable` class\n  * `Testable.check`: a way to test a proposition using random examples\n\n## Tags\n\nrandom testing\n\n## References\n  * https://hackage.haskell.org/package/QuickCheck\n-/\n\nnamespace SlimCheck\n\n/-- Result of trying to disprove `p`\nThe constructors are:\n  *  `success : (PSum Unit p) → TestResult p`\n     succeed when we find another example satisfying `p`\n     In `success h`, `h` is an optional proof of the proposition.\n     Without the proof, all we know is that we found one example\n     where `p` holds. With a proof, the one test was sufficient to\n     prove that `p` holds and we do not need to keep finding examples.\n   * `gaveUp : ℕ → TestResult p`\n     give up when a well-formed example cannot be generated.\n     `gaveUp n` tells us that `n` invalid examples were tried.\n     Above 100, we give up on the proposition and report that we\n     did not find a way to properly test it.\n   * `failure : ¬ p → (List String) → ℕ → TestResult p`\n     a counter-example to `p`; the strings specify values for the relevant variables.\n     `failure h vs n` also carries a proof that `p` does not hold. This way, we can\n     guarantee that there will be no false positive. The last component, `n`,\n     is the number of times that the counter-example was shrunk.\n-/\ninductive TestResult (p : Prop) where\n  | success : PSum Unit p → TestResult p\n  | gaveUp : Nat → TestResult p\n  | failure : ¬ p → List String → Nat → TestResult p\n  deriving Inhabited\n\n/-- Configuration for testing a property. -/\nstructure Configuration where\n  numInst : Nat := 100\n  maxSize : Nat := 100\n  numRetries : Nat := 10\n  traceDiscarded : Bool := false\n  traceSuccesses : Bool := false\n  traceShrink : Bool := false\n  traceShrinkCandidates : Bool := false\n  randomSeed : Option Nat := none\n  quiet : Bool := false\n  deriving Inhabited\n\n/--\n`PrintableProp p` allows one to print a proposition so that\n`SlimCheck` can indicate how values relate to each other.\nIt's basically a poor man's delaborator.\n-/\nclass PrintableProp (p : Prop) where\n  printProp : String\n\nexport PrintableProp (printProp)\n\ninstance (priority := low) : PrintableProp p where\n  printProp := \"⋯\"\n\n/-- `Testable p` uses random examples to try to disprove `p`. -/\nclass Testable (p : Prop) where\n  run (cfg : Configuration) (minimize : Bool) : Gen (TestResult p)\n\n@[nolint unusedArguments]\ndef NamedBinder (_n : String) (p : Prop) : Prop := p\n\nnamespace TestResult\n\ndef toString : TestResult p → String\n| success (PSum.inl _) => \"success (no proof)\"\n| success (PSum.inr _) => \"success (proof)\"\n| gaveUp n => s!\"gave {n} times\"\n| failure _ counters _ => s!\"failed {counters}\"\n\ninstance : ToString (TestResult p) := ⟨toString⟩\n\n/-- Applicative combinator proof carrying test results. -/\ndef combine {p q : Prop} : PSum Unit (p → q) → PSum Unit p → PSum Unit q\n| PSum.inr f, PSum.inr proof => PSum.inr $ f proof\n| _, _ => PSum.inl ()\n\n/-- Combine the test result for properties `p` and `q` to create a test for their conjunction. -/\ndef and : TestResult p → TestResult q → TestResult (p ∧ q)\n| failure h xs n, _ => failure (λ h2 => h h2.left) xs n\n| _, failure h xs n => failure (λ h2 => h h2.right) xs n\n| success h1, success h2 => success $ combine (combine (PSum.inr And.intro) h1) h2\n| gaveUp n, gaveUp m => gaveUp $ n + m\n| gaveUp n, _ => gaveUp n\n| _, gaveUp n => gaveUp n\n\n/-- Combine the test result for properties `p` and `q` to create a test for their disjunction. -/\ndef or : TestResult p → TestResult q → TestResult (p ∨ q)\n| failure h1 xs n, failure h2 ys m =>\n  let h3 := λ h =>\n    match h with\n    | Or.inl h3 => h1 h3\n    | Or.inr h3 => h2 h3\n  failure h3 (xs ++ ys) (n + m)\n| success h, _ => success $ combine (PSum.inr Or.inl) h\n| _, success h => success $ combine (PSum.inr Or.inr) h\n| gaveUp n, gaveUp m => gaveUp $ n + m\n| gaveUp n, _ => gaveUp n\n| _, gaveUp n => gaveUp n\n\n/-- If `q → p`, then `¬ p → ¬ q` which means that testing `p` can allow us\nto find counter-examples to `q`. -/\ndef imp (h : q → p) (r : TestResult p)\n    (p : PSum Unit (p → q) := PSum.inl ()) : TestResult q :=\n  match r with\n  | failure h2 xs n => failure (mt h h2) xs n\n  | success h2 => success $ combine p h2\n  | gaveUp n => gaveUp n\n\n/-- Test `q` by testing `p` and proving the equivalence between the two. -/\ndef iff (h : q ↔ p) (r : TestResult p) : TestResult q :=\n  imp h.mp r (PSum.inr h.mpr)\n\n/-- When we assign a value to a universally quantified variable,\nwe record that value using this function so that our counter-examples\ncan be informative. -/\ndef addInfo (x : String) (h : q → p) (r : TestResult p)\n    (p : PSum Unit (p → q) := PSum.inl ()) : TestResult q :=\n  if let failure h2 xs n := r then\n    failure (mt h h2) (x :: xs) n\n  else\n    imp h r p\n\n/-- Add some formatting to the information recorded by `addInfo`. -/\ndef addVarInfo [Repr γ] (var : String) (x : γ) (h : q → p) (r : TestResult p)\n    (p : PSum Unit (p → q) := PSum.inl ()) : TestResult q  :=\n  addInfo s!\"{var} := {repr x}\" h r p\n\ndef isFailure : TestResult p → Bool\n| failure _ _ _ => true\n| _ => false\n\nend TestResult\n\nnamespace Configuration\n\n/-- A configuration with all the trace options enabled, useful for debugging. -/\ndef verbose : Configuration where\n  traceDiscarded := true\n  traceSuccesses := true\n  traceShrink := true\n  traceShrinkCandidates := true\n\nend Configuration\n\nnamespace Testable\n\nopen TestResult\n\ndef runProp (p : Prop) [Testable p] : Configuration → Bool → Gen (TestResult p) := Testable.run\n\n/-- A `dbgTrace` with special formatting -/\ndef slimTrace [Pure m] (s : String) : m PUnit := dbgTrace s!\"[SlimCheck: {s}]\" (λ _ => pure ())\n\ninstance andTestable [Testable p] [Testable q] : Testable (p ∧ q) where\n  run := λ cfg min => do\n    let xp ← runProp p cfg min\n    let xq ← runProp q cfg min\n    pure $ and xp xq\n\ninstance orTestable [Testable p] [Testable q] : Testable (p ∨ q) where\n  run := λ cfg min => do\n    let xp ← runProp p cfg min\n    -- As a little performance optimization we can just not run the second\n    -- test if the first succeeds\n    match xp with\n    | success (PSum.inl h) => pure $ success (PSum.inl h)\n    | success (PSum.inr h) => pure $ success (PSum.inr $ Or.inl h)\n    | _ =>\n      let xq ← runProp q cfg min\n      pure $ or xp xq\n\ninstance iffTestable [Testable ((p ∧ q) ∨ (¬ p ∧ ¬ q))] : Testable (p ↔ q) where\n  run := λ cfg min => do\n    let h ← runProp ((p ∧ q) ∨ (¬ p ∧ ¬ q)) cfg min\n    pure $ iff iff_iff_and_or_not_and_not h\n\ninstance decGuardTestable [PrintableProp p] [Decidable p] {β : p → Prop} [∀ h, Testable (β h)] :\n    Testable (NamedBinder var $ ∀ h, β h) where\n  run := λ cfg min => do\n    if h : p then\n      let res := (runProp (β h) cfg min)\n      let s := printProp p\n      (λ r => addInfo s!\"guard: {s}\" (· $ h) r (PSum.inr $ λ q _ => q)) <$> res\n    else if cfg.traceDiscarded || cfg.traceSuccesses then\n      let res := (λ _ => pure $ gaveUp 1)\n      let s := printProp p\n      slimTrace s!\"discard: Guard {s} does not hold\"; res\n    else\n      pure $ gaveUp 1\n\ninstance forallTypesTestable {f : Type → Prop} [Testable (f Int)] :\n    Testable (NamedBinder var $ ∀ x, f x) where\n  run := λ cfg min => do\n    let r ← runProp (f Int) cfg min\n    pure $ addVarInfo var \"ℤ\" (· $ Int) r\n\n/--\nFormat the counter-examples found in a test failure.\n-/\ndef formatFailure (s : String) (xs : List String) (n : Nat) : String :=\n  let counter := String.intercalate \"\\n\" xs\n  let parts := [\n    \"\\n===================\",\n    s,\n    counter,\n    s!\"({n} shrinks)\",\n    \"-------------------\"\n  ]\n  String.intercalate \"\\n\" parts\n\n/--\nIncrease the number of shrinking steps in a test result.\n-/\ndef addShrinks (n : Nat) : TestResult p → TestResult p\n| TestResult.failure p xs m => TestResult.failure p xs (m + n)\n| p => p\n\n/-- Shrink a counter-example `x` by using `Shrinkable.shrink x`, picking the first\ncandidate that falsifies a property and recursively shrinking that one.\nThe process is guaranteed to terminate because `shrink x` produces\na proof that all the values it produces are smaller (according to `SizeOf`)\nthan `x`. -/\ndef minimizeAux [SampleableExt α] {β : α → Prop} [∀ x, Testable (β x)] (cfg : Configuration)\n    (var : String) (x : SampleableExt.proxy α) (n : Nat) :\n    OptionT Gen (Σ x, TestResult (β (SampleableExt.interp x))) := do\n  let candidates := SampleableExt.shrink.shrink x\n  if cfg.traceShrinkCandidates then\n    slimTrace s!\"Candidates for {var} := {repr x}:\\n  {repr candidates}\"\n  for ⟨candidate, h⟩ in candidates do\n    if cfg.traceShrinkCandidates then\n      slimTrace s!\"Trying {var} := {repr candidate}\"\n    let res ← OptionT.lift $ Testable.runProp (β (SampleableExt.interp candidate)) cfg true\n    if res.isFailure then\n      if cfg.traceShrink then\n        slimTrace s!\"{var} shrunk to {repr candidate} from {repr x}\"\n      let currentStep := OptionT.lift $ pure $ Sigma.mk candidate (addShrinks (n + 1) res)\n      let nextStep := minimizeAux cfg var candidate (n + 1)\n      return ←(nextStep <|> currentStep)\n  if cfg.traceShrink then\n    slimTrace s!\"No shrinking possible for {var} := {repr x}\"\n  failure\n  termination_by minimizeAux cfg var x n => x\n\n/-- Once a property fails to hold on an example, look for smaller counter-examples\nto show the user. -/\ndef minimize [SampleableExt α] {β : α → Prop} [∀ x, Testable (β x)] (cfg : Configuration)\n    (var : String) (x : SampleableExt.proxy α) (r : TestResult (β $ SampleableExt.interp x)) :\n    Gen (Σ x, TestResult (β $ SampleableExt.interp x)) := do\n  if cfg.traceShrink then\n     slimTrace \"Shrink\"\n     slimTrace s!\"Attempting to shrink {var} := {repr x}\"\n  let res ← OptionT.run $ minimizeAux cfg var x 0\n  pure $ res.getD ⟨x, r⟩\n\n/-- Test a universal property by creating a sample of the right type and instantiating the\nbound variable with it. -/\ninstance varTestable [SampleableExt α] {β : α → Prop} [∀ x, Testable (β x)] :\n    Testable (NamedBinder var $ ∀ x : α, β x) where\n  run := λ cfg min => do\n    let x ← SampleableExt.sample\n    if cfg.traceSuccesses || cfg.traceDiscarded then\n      slimTrace s!\"{var} := {repr x}\"\n    let r ← Testable.runProp (β $ SampleableExt.interp x) cfg false\n    let ⟨finalX, finalR⟩ ←\n      if isFailure r then\n        if cfg.traceSuccesses then\n          slimTrace s!\"{var} := {repr x} is a failure\"\n        if min then\n          minimize cfg var x r\n        else\n          pure $ ⟨x, r⟩\n      else\n        pure $ ⟨x, r⟩\n    pure $ addVarInfo var finalX (· $ SampleableExt.interp finalX) finalR\n\n/-- Test a universal property about propositions -/\ninstance propVarTestable {β : Prop → Prop} [∀ b : Bool, Testable (β b)] :\n  Testable (NamedBinder var $ ∀ p : Prop, β p)\nwhere\n  run := λ cfg min =>\n    imp (λ h (b : Bool) => h b) <$> Testable.runProp (NamedBinder var $ ∀ b : Bool, β b) cfg min\n\ninstance (priority := high) unusedVarTestable [Nonempty α] [Testable β] :\n  Testable (NamedBinder var $ ∀ _x : α, β)\nwhere\n  run := λ cfg min => do\n    if cfg.traceDiscarded || cfg.traceSuccesses then\n      slimTrace s!\"{var} is unused\"\n    let r ← Testable.runProp β cfg min\n    let finalR := addInfo s!\"{var} is irrelevant (unused)\" id r\n    pure $ imp (· $ Classical.ofNonempty) finalR (PSum.inr $ λ x _ => x)\n\ninstance (priority := low) decidableTestable {p : Prop} [PrintableProp p] [Decidable p] :\n    Testable p where\n  run := λ _ _ =>\n    if h : p then\n      pure $ success (PSum.inr h)\n    else\n      let s := printProp p\n      pure $ failure h [s!\"issue: {s} does not hold\"] 0\n\nend Testable\n\nsection PrintableProp\n\ninstance Eq.printableProp [Repr α] {x y : α} : PrintableProp (x = y) where\n  printProp := s!\"{repr x} = {repr y}\"\n\ninstance Ne.printableProp [Repr α] {x y : α} : PrintableProp (x ≠ y) where\n  printProp := s!\"{repr x} ≠ {repr y}\"\n\ninstance LE.printableProp [Repr α] [LE α] {x y : α} : PrintableProp (x ≤ y) where\n  printProp := s!\"{repr x} ≤ {repr y}\"\n\ninstance LT.printableProp [Repr α] [LT α] {x y : α} : PrintableProp (x < y) where\n  printProp := s!\"{repr x} < {repr y}\"\n\ninstance And.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x ∧ y) where\n  printProp := s!\"{printProp x} ∧ {printProp y}\"\n\ninstance Or.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x ∨ y) where\n  printProp := s!\"{printProp x} ∨ {printProp y}\"\n\ninstance Iff.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x ↔ y) where\n  printProp := s!\"{printProp x} ↔ {printProp y}\"\n\ninstance Imp.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x → y) where\n  printProp := s!\"{printProp x} → {printProp y}\"\n\ninstance Not.printableProp [PrintableProp x] : PrintableProp (¬x) where\n  printProp := s!\"¬{printProp x}\"\n\ninstance True.printableProp : PrintableProp True where\n  printProp := \"True\"\n\ninstance False.printableProp : PrintableProp False where\n  printProp := \"False\"\n\ninstance Bool.printableProp {b : Bool} : PrintableProp b where\n  printProp := if b then \"true\" else \"false\"\n\nend PrintableProp\n\nsection IO\nopen TestResult\n\n/-- Execute `cmd` and repeat every time the result is `gave_up` (at most `n` times). -/\ndef retry (cmd : Rand (TestResult p)) : Nat → Rand (TestResult p)\n| 0 => pure $ TestResult.gaveUp 1\n| n+1 => do\n  let r ← cmd\n  match r with\n  | success hp => pure $ success hp\n  | TestResult.failure h xs n => pure $ failure h xs n\n  | gaveUp _ => retry cmd n\n\n/-- Count the number of times the test procedure gave up. -/\ndef giveUp (x : Nat) : TestResult p → TestResult p\n| success (PSum.inl ()) => gaveUp x\n| success (PSum.inr p) => success $ (PSum.inr p)\n| gaveUp n => gaveUp $ n + x\n| TestResult.failure h xs n => failure h xs n\n\n/-- Try `n` times to find a counter-example for `p`. -/\ndef Testable.runSuiteAux (p : Prop) [Testable p] (cfg : Configuration) :\n  TestResult p → Nat → Rand (TestResult p)\n| r, 0 => pure r\n| r, n+1 => do\n  let size := (cfg.numInst - n - 1) * cfg.maxSize / cfg.numInst\n  if cfg.traceSuccesses then\n    slimTrace s!\"New sample\"\n    slimTrace s!\"Retrying up to {cfg.numRetries} times until guards hold\"\n  let x ← retry (ReaderT.run (Testable.runProp p cfg true) ⟨size⟩) cfg.numRetries\n  match x with\n  | (success (PSum.inl ())) => runSuiteAux p cfg r n\n  | (gaveUp g) => runSuiteAux p cfg (giveUp g r) n\n  | _ => pure $ x\n\n/-- Try to find a counter-example of `p`. -/\ndef Testable.runSuite (p : Prop) [Testable p] (cfg : Configuration := {}) : Rand (TestResult p) :=\n  Testable.runSuiteAux p cfg (success $ PSum.inl ()) cfg.numInst\n\n/-- Run a test suite for `p` in `BaseIO` using the global RNG in `stdGenRef`. -/\ndef Testable.checkIO (p : Prop) [Testable p] (cfg : Configuration := {}) : BaseIO (TestResult p) :=\n  match cfg.randomSeed with\n  | none => IO.runRand (Testable.runSuite p cfg)\n  | some seed => IO.runRandWith seed (Testable.runSuite p cfg)\n\nend IO\n\nnamespace Decorations\n\nopen Lean\n\n/-- Traverse the syntax of a proposition to find universal quantifiers\nquantifiers and add `NamedBinder` annotations next to them. -/\npartial def addDecorations (e : Expr) : Expr :=\n  e.replace $ λ expr =>\n    match expr with\n    | Expr.forallE name type body data =>\n      let n := name.toString\n      let newType := addDecorations type\n      let newBody := addDecorations body\n      let rest := Expr.forallE name newType newBody data\n      some $ mkApp2 (mkConst `SlimCheck.NamedBinder) (mkStrLit n) rest\n    | _ => none\n\n/-- `DecorationsOf p` is used as a hint to `mk_decorations` to specify\nthat the goal should be satisfied with a proposition equivalent to `p`\nwith added annotations. -/\n@[nolint unusedArguments]\nabbrev DecorationsOf (_p : Prop) := Prop\n\nopen Elab.Tactic\nopen Meta\n\n/-- In a goal of the shape `⊢ DecorationsOf p`, `mk_decoration` examines\nthe syntax of `p` and adds `NamedBinder` around universal quantifications\nto improve error messages. This tool can be used in the declaration of a\nfunction as follows:\n```lean\ndef foo (p : Prop) (p' : Decorations.DecorationsOf p := by mk_decorations) [Testable p'] : ...\n```\n`p` is the parameter given by the user, `p'` is a definitionally equivalent\nproposition where the quantifiers are annotated with `NamedBinder`.\n-/\nscoped elab \"mk_decorations\" : tactic => do\n  let goal ← getMainGoal\n  let goalType ← goal.getType\n  if let .app (.const ``Decorations.DecorationsOf _) body := goalType then\n    closeMainGoal (addDecorations body)\n\nend Decorations\n\nopen Decorations in\n/-- Run a test suite for `p` and throw an exception if `p` does not not hold.-/\ndef Testable.check (p : Prop) (cfg : Configuration := {})\n    (p' : Decorations.DecorationsOf p := by mk_decorations) [Testable p'] : IO PUnit := do\n  match ← Testable.checkIO p' cfg with\n  | TestResult.success _ => if !cfg.quiet then IO.println \"Success\"\n  | TestResult.gaveUp n => if !cfg.quiet then IO.println s!\"Gave up {n} times\"\n  | TestResult.failure _ xs n => throw (IO.userError $ formatFailure \"Found problems!\" xs n)\n\n-- #eval Testable.check (∀ (x y z a : Nat) (h1 : 3 < x) (h2 : 3 < y), x - y = y - x)\n--   Configuration.verbose\n-- #eval Testable.check (∀ x : Nat, ∀ y : Nat, x + y = y + x) Configuration.verbose\n-- #eval Testable.check (∀ (x : (Nat × Nat)), x.fst - x.snd - 10 = x.snd - x.fst - 10)\n--   Configuration.verbose\n-- #eval Testable.check (∀ (x : Nat) (h : 10 < x), 5 < x) Configuration.verbose\n\nend SlimCheck\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Testing/SlimCheck/Testable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.4774420269845715}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.preadditive.projective\nimport algebra.homology.single\nimport algebra.homology.homotopy_category\n\n/-!\n# Projective resolutions\n\nA projective resolution `P : ProjectiveResolution Z` of an object `Z : C` consists of\na `ℕ`-indexed chain complex `P.complex` of projective objects,\nalong with a chain map `P.π` from `C` to the chain complex consisting just of `Z` in degree zero,\nso that the augmented chain complex is exact.\n\nWhen `C` is abelian, this exactness condition is equivalent to `π` being a quasi-isomorphism.\nIt turns out that this formulation allows us to set up the basic theory of derived functors\nwithout even assuming `C` is abelian.\n\n(Typically, however, to show `has_projective_resolutions C`\none will assume `enough_projectives C` and `abelian C`.\nThis construction appears in `category_theory.abelian.projectives`.)\n\nWe show that given `P : ProjectiveResolution X` and `Q : ProjectiveResolution Y`,\nany morphism `X ⟶ Y` admits a lift to a chain map `P.complex ⟶ Q.complex`.\n(It is a lift in the sense that\nthe projection maps `P.π` and `Q.π` intertwine the lift and the original morphism.)\n\nMoreover, we show that any two such lifts are homotopic.\n\nAs a consequence, if every object admits a projective resolution,\nwe can construct a functor `projective_resolutions C : C ⥤ homotopy_category C`.\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nuniverses v u\n\nnamespace category_theory\nvariables {C : Type u} [category.{v} C]\n\nopen projective\n\nsection\nvariables [has_zero_object C] [has_zero_morphisms C] [has_equalizers C] [has_images C]\n\n/--\nA `ProjectiveResolution Z` consists of a bundled `ℕ`-indexed chain complex of projective objects,\nalong with a quasi-isomorphism to the complex consisting of just `Z` supported in degree `0`.\n\n(We don't actually ask here that the chain map is a quasi-iso, just exactness everywhere:\nthat `π` is a quasi-iso is a lemma when the category is abelian.\nShould we just ask for it here?)\n\nExcept in situations where you want to provide a particular projective resolution\n(for example to compute a derived functor),\nyou will not typically need to use this bundled object, and will instead use\n* `projective_resolution Z`: the `ℕ`-indexed chain complex\n  (equipped with `projective` and `exact` instances)\n* `projective_resolution.π Z`: the chain map from `projective_resolution Z` to\n  `(single C _ 0).obj Z` (all the components are equipped with `epi` instances,\n  and when the category is `abelian` we will show `π` is a quasi-iso).\n-/\n@[nolint has_nonempty_instance]\nstructure ProjectiveResolution (Z : C) :=\n(complex : chain_complex C ℕ)\n(π : homological_complex.hom complex ((chain_complex.single₀ C).obj Z))\n(projective : ∀ n, projective (complex.X n) . tactic.apply_instance)\n(exact₀ : exact (complex.d 1 0) (π.f 0))\n(exact : ∀ n, exact (complex.d (n+2) (n+1)) (complex.d (n+1) n))\n(epi : epi (π.f 0) . tactic.apply_instance)\n\nattribute [instance] ProjectiveResolution.projective ProjectiveResolution.epi\n\n/--\nAn object admits a projective resolution.\n-/\nclass has_projective_resolution (Z : C) : Prop :=\n(out [] : nonempty (ProjectiveResolution Z))\n\nsection\nvariables (C)\n\n/--\nYou will rarely use this typeclass directly: it is implied by the combination\n`[enough_projectives C]` and `[abelian C]`.\nBy itself it's enough to set up the basic theory of derived functors.\n-/\nclass has_projective_resolutions : Prop :=\n(out : ∀ Z : C, has_projective_resolution Z)\n\nattribute [instance, priority 100] has_projective_resolutions.out\n\nend\n\nnamespace ProjectiveResolution\n\n@[simp] lemma π_f_succ {Z : C} (P : ProjectiveResolution Z) (n : ℕ) :\n  P.π.f (n+1) = 0 :=\nbegin\n  apply zero_of_target_iso_zero,\n  dsimp, refl,\nend\n\n@[simp] lemma complex_d_comp_π_f_zero {Z : C} (P : ProjectiveResolution Z) :\n  P.complex.d 1 0 ≫ P.π.f 0 = 0 :=\nP.exact₀.w\n\n@[simp] lemma complex_d_succ_comp {Z : C} (P : ProjectiveResolution Z) (n : ℕ) :\n  P.complex.d (n + 2) (n + 1) ≫ P.complex.d (n + 1) n = 0 :=\n(P.exact _).w\n\ninstance {Z : C} (P : ProjectiveResolution Z) (n : ℕ) : category_theory.epi (P.π.f n) :=\nby cases n; apply_instance\n\n/-- A projective object admits a trivial projective resolution: itself in degree 0. -/\ndef self (Z : C) [category_theory.projective Z] : ProjectiveResolution Z :=\n{ complex := (chain_complex.single₀ C).obj Z,\n  π := 𝟙 ((chain_complex.single₀ C).obj Z),\n  projective := λ n, begin\n    cases n,\n    { dsimp, apply_instance, },\n    { dsimp, apply_instance, },\n  end,\n  exact₀ := by { dsimp, exact exact_zero_mono _ },\n  exact := λ n, by { dsimp, exact exact_of_zero _ _ },\n  epi := by { dsimp, apply_instance, }, }\n\n/-- Auxiliary construction for `lift`. -/\ndef lift_f_zero {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  P.complex.X 0 ⟶ Q.complex.X 0 :=\nfactor_thru (P.π.f 0 ≫ f) (Q.π.f 0)\n\n/-- Auxiliary construction for `lift`. -/\ndef lift_f_one {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  P.complex.X 1 ⟶ Q.complex.X 1 :=\nexact.lift (P.complex.d 1 0 ≫ lift_f_zero f P Q) (Q.complex.d 1 0) (Q.π.f 0) Q.exact₀\n  (by simp [lift_f_zero, P.exact₀.w_assoc])\n\n/-- Auxiliary lemma for `lift`. -/\n@[simp] lemma lift_f_one_zero_comm\n  {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  lift_f_one f P Q ≫ Q.complex.d 1 0 = P.complex.d 1 0 ≫ lift_f_zero f P Q :=\nbegin\n  dsimp [lift_f_zero, lift_f_one],\n  simp,\nend\n\n/-- Auxiliary construction for `lift`. -/\ndef lift_f_succ {Y Z : C} (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z)\n  (n : ℕ) (g : P.complex.X n ⟶ Q.complex.X n) (g' : P.complex.X (n+1) ⟶ Q.complex.X (n+1))\n  (w : g' ≫ Q.complex.d (n+1) n = P.complex.d (n+1) n ≫ g) :\n  Σ' g'' : P.complex.X (n+2) ⟶ Q.complex.X (n+2),\n    g'' ≫ Q.complex.d (n+2) (n+1) = P.complex.d (n+2) (n+1) ≫ g' :=\n⟨exact.lift\n  (P.complex.d (n+2) (n+1) ≫ g') ((Q.complex.d (n+2) (n+1))) (Q.complex.d (n+1) n) (Q.exact _)\n  (by simp [w]), (by simp)⟩\n\n/-- A morphism in `C` lifts to a chain map between projective resolutions. -/\ndef lift {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  P.complex ⟶ Q.complex :=\nchain_complex.mk_hom _ _ (lift_f_zero f _ _) (lift_f_one f _ _) (lift_f_one_zero_comm f _ _)\n  (λ n ⟨g, g', w⟩, lift_f_succ P Q n g g' w)\n\n/-- The resolution maps intertwine the lift of a morphism and that morphism. -/\n@[simp, reassoc]\nlemma lift_commutes\n  {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  lift f P Q ≫ Q.π = P.π ≫ (chain_complex.single₀ C).map f :=\nby { ext, dsimp [lift, lift_f_zero], apply factor_thru_comp, }\n\n-- Now that we've checked this property of the lift,\n-- we can seal away the actual definition.\nattribute [irreducible] lift\n\nend ProjectiveResolution\n\nend\n\nnamespace ProjectiveResolution\n\nvariables [has_zero_object C] [preadditive C] [has_equalizers C] [has_images C]\n\n/-- An auxiliary definition for `lift_homotopy_zero`. -/\ndef lift_homotopy_zero_zero {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n  (f : P.complex ⟶ Q.complex)\n  (comm : f ≫ Q.π = 0) : P.complex.X 0 ⟶ Q.complex.X 1 :=\nexact.lift (f.f 0) (Q.complex.d 1 0) (Q.π.f 0) Q.exact₀\n  (congr_fun (congr_arg homological_complex.hom.f comm) 0)\n\n/-- An auxiliary definition for `lift_homotopy_zero`. -/\ndef lift_homotopy_zero_one {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n  (f : P.complex ⟶ Q.complex)\n  (comm : f ≫ Q.π = 0) : P.complex.X 1 ⟶ Q.complex.X 2 :=\nexact.lift\n  (f.f 1 - P.complex.d 1 0 ≫ lift_homotopy_zero_zero f comm) (Q.complex.d 2 1) (Q.complex.d 1 0)\n  (Q.exact _) (by simp [lift_homotopy_zero_zero])\n\n/-- An auxiliary definition for `lift_homotopy_zero`. -/\ndef lift_homotopy_zero_succ {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n  (f : P.complex ⟶ Q.complex) (n : ℕ)\n  (g : P.complex.X n ⟶ Q.complex.X (n + 1)) (g' : P.complex.X (n + 1) ⟶ Q.complex.X (n + 2))\n  (w : f.f (n + 1) = P.complex.d (n + 1) n ≫ g + g' ≫ Q.complex.d (n + 2) (n + 1)) :\n  P.complex.X (n + 2) ⟶ Q.complex.X (n + 3) :=\nexact.lift\n  (f.f (n+2) - P.complex.d (n+2) (n+1) ≫ g') (Q.complex.d (n+3) (n+2)) (Q.complex.d (n+2) (n+1))\n  (Q.exact _) (by simp [w])\n\n/-- Any lift of the zero morphism is homotopic to zero. -/\ndef lift_homotopy_zero {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n  (f : P.complex ⟶ Q.complex)\n  (comm : f ≫ Q.π = 0) :\n  homotopy f 0 :=\nhomotopy.mk_inductive _ (lift_homotopy_zero_zero f comm) (by simp [lift_homotopy_zero_zero])\n  (lift_homotopy_zero_one f comm) (by simp [lift_homotopy_zero_one])\n  (λ n ⟨g, g', w⟩, ⟨lift_homotopy_zero_succ f n g g' w, by simp [lift_homotopy_zero_succ, w]⟩)\n\n/-- Two lifts of the same morphism are homotopic. -/\ndef lift_homotopy {Y Z : C} (f : Y ⟶ Z) {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n  (g h : P.complex ⟶ Q.complex)\n  (g_comm : g ≫ Q.π = P.π ≫ (chain_complex.single₀ C).map f)\n  (h_comm : h ≫ Q.π = P.π ≫ (chain_complex.single₀ C).map f) :\n  homotopy g h :=\nhomotopy.equiv_sub_zero.inv_fun (lift_homotopy_zero _ (by simp [g_comm, h_comm]))\n\n/-- The lift of the identity morphism is homotopic to the identity chain map. -/\ndef lift_id_homotopy (X : C) (P : ProjectiveResolution X) :\n  homotopy (lift (𝟙 X) P P) (𝟙 P.complex) :=\nby { apply lift_homotopy (𝟙 X); simp, }\n\n/-- The lift of a composition is homotopic to the composition of the lifts. -/\ndef lift_comp_homotopy {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  (P : ProjectiveResolution X) (Q : ProjectiveResolution Y) (R : ProjectiveResolution Z) :\n  homotopy (lift (f ≫ g) P R) (lift f P Q ≫ lift g Q R) :=\nby { apply lift_homotopy (f ≫ g); simp, }\n\n-- We don't care about the actual definitions of these homotopies.\nattribute [irreducible] lift_homotopy_zero lift_homotopy lift_id_homotopy lift_comp_homotopy\n\n/-- Any two projective resolutions are homotopy equivalent. -/\ndef homotopy_equiv {X : C} (P Q : ProjectiveResolution X) :\n  homotopy_equiv P.complex Q.complex :=\n{ hom := lift (𝟙 X) P Q,\n  inv := lift (𝟙 X) Q P,\n  homotopy_hom_inv_id := begin\n    refine (lift_comp_homotopy (𝟙 X) (𝟙 X) P Q P).symm.trans _,\n    simp [category.id_comp],\n    apply lift_id_homotopy,\n  end,\n  homotopy_inv_hom_id := begin\n    refine (lift_comp_homotopy (𝟙 X) (𝟙 X) Q P Q).symm.trans _,\n    simp [category.id_comp],\n    apply lift_id_homotopy,\n  end, }\n\n@[simp, reassoc] lemma homotopy_equiv_hom_π {X : C} (P Q : ProjectiveResolution X) :\n  (homotopy_equiv P Q).hom ≫ Q.π = P.π :=\nby simp [homotopy_equiv]\n\n@[simp, reassoc] lemma homotopy_equiv_inv_π {X : C} (P Q : ProjectiveResolution X) :\n  (homotopy_equiv P Q).inv ≫ P.π = Q.π :=\nby simp [homotopy_equiv]\n\nend ProjectiveResolution\n\nsection\n\nvariables [has_zero_morphisms C] [has_zero_object C] [has_equalizers C] [has_images C]\n\n/-- An arbitrarily chosen projective resolution of an object. -/\nabbreviation projective_resolution (Z : C) [has_projective_resolution Z] : chain_complex C ℕ :=\n(has_projective_resolution.out Z).some.complex\n\n/-- The chain map from the arbitrarily chosen projective resolution `projective_resolution Z`\nback to the chain complex consisting of `Z` supported in degree `0`. -/\nabbreviation projective_resolution.π (Z : C) [has_projective_resolution Z] :\n  projective_resolution Z ⟶ (chain_complex.single₀ C).obj Z :=\n(has_projective_resolution.out Z).some.π\n\n/-- The lift of a morphism to a chain map between the arbitrarily chosen projective resolutions. -/\nabbreviation projective_resolution.lift {X Y : C} (f : X ⟶ Y)\n  [has_projective_resolution X] [has_projective_resolution Y] :\n  projective_resolution X ⟶ projective_resolution Y :=\nProjectiveResolution.lift f _ _\n\nend\n\nvariables (C) [preadditive C] [has_zero_object C] [has_equalizers C] [has_images C]\n  [has_projective_resolutions C]\n\n/--\nTaking projective resolutions is functorial,\nif considered with target the homotopy category\n(`ℕ`-indexed chain complexes and chain maps up to homotopy).\n-/\ndef projective_resolutions : C ⥤ homotopy_category C (complex_shape.down ℕ) :=\n{ obj := λ X, (homotopy_category.quotient _ _).obj (projective_resolution X),\n  map := λ X Y f, (homotopy_category.quotient _ _).map (projective_resolution.lift f),\n  map_id' := λ X, begin\n    rw ←(homotopy_category.quotient _ _).map_id,\n    apply homotopy_category.eq_of_homotopy,\n    apply ProjectiveResolution.lift_id_homotopy,\n  end,\n  map_comp' := λ X Y Z f g, begin\n    rw ←(homotopy_category.quotient _ _).map_comp,\n    apply homotopy_category.eq_of_homotopy,\n    apply ProjectiveResolution.lift_comp_homotopy,\n  end, }\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/preadditive/projective_resolution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.4774420181429049}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Mario Carneiro, Simon Hudon\n\n! This file was ported from Lean 3 source module control.functor.multivariate\n! leanprover-community/mathlib commit 4d392a6c9c4539cbeca399b3ee0afea398fbd2eb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Fin.Fin2\nimport Mathbin.Data.Typevec\n\n/-!\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n\nFunctors between the category of tuples of types, and the category Type\n\nFeatures:\n\n`mvfunctor n` : the type class of multivariate functors\n`f <$$> x`    : notation for map\n\n-/\n\n\nuniverse u v w\n\nopen MvFunctor\n\n#print MvFunctor /-\n/-- multivariate functors, i.e. functor between the category of type vectors\nand the category of Type -/\nclass MvFunctor {n : ℕ} (F : TypeVec n → Type _) where\n  map : ∀ {α β : TypeVec n}, α ⟹ β → F α → F β\n#align mvfunctor MvFunctor\n-/\n\n-- mathport name: mvfunctor.map\nscoped[MvFunctor] infixr:100 \" <$$> \" => MvFunctor.map\n\nvariable {n : ℕ}\n\nnamespace MvFunctor\n\nvariable {α β γ : TypeVec.{u} n} {F : TypeVec.{u} n → Type v} [MvFunctor F]\n\n#print MvFunctor.LiftP /-\n/-- predicate lifting over multivariate functors -/\ndef LiftP {α : TypeVec n} (p : ∀ i, α i → Prop) (x : F α) : Prop :=\n  ∃ u : F fun i => Subtype (p i), (fun i => @Subtype.val _ (p i)) <$$> u = x\n#align mvfunctor.liftp MvFunctor.LiftP\n-/\n\n#print MvFunctor.LiftR /-\n/-- relational lifting over multivariate functors -/\ndef LiftR {α : TypeVec n} (r : ∀ {i}, α i → α i → Prop) (x y : F α) : Prop :=\n  ∃ u : F fun i => { p : α i × α i // r p.fst p.snd },\n    (fun i (t : { p : α i × α i // r p.fst p.snd }) => t.val.fst) <$$> u = x ∧\n      (fun i (t : { p : α i × α i // r p.fst p.snd }) => t.val.snd) <$$> u = y\n#align mvfunctor.liftr MvFunctor.LiftR\n-/\n\n#print MvFunctor.supp /-\n/-- given `x : F α` and a projection `i` of type vector `α`, `supp x i` is the set\nof `α.i` contained in `x` -/\ndef supp {α : TypeVec n} (x : F α) (i : Fin2 n) : Set (α i) :=\n  { y : α i | ∀ ⦃p⦄, LiftP p x → p i y }\n#align mvfunctor.supp MvFunctor.supp\n-/\n\n#print MvFunctor.of_mem_supp /-\ntheorem of_mem_supp {α : TypeVec n} {x : F α} {p : ∀ ⦃i⦄, α i → Prop} (h : LiftP p x) (i : Fin2 n) :\n    ∀ y ∈ supp x i, p y := fun y hy => hy h\n#align mvfunctor.of_mem_supp MvFunctor.of_mem_supp\n-/\n\nend MvFunctor\n\n#print LawfulMvFunctor /-\n/-- laws for `mvfunctor` -/\nclass LawfulMvFunctor {n : ℕ} (F : TypeVec n → Type _) [MvFunctor F] : Prop where\n  id_map : ∀ {α : TypeVec n} (x : F α), TypeVec.id <$$> x = x\n  comp_map :\n    ∀ {α β γ : TypeVec n} (g : α ⟹ β) (h : β ⟹ γ) (x : F α), (h ⊚ g) <$$> x = h <$$> g <$$> x\n#align is_lawful_mvfunctor LawfulMvFunctor\n-/\n\nopen Nat TypeVec\n\nnamespace MvFunctor\n\nexport LawfulMvFunctor (comp_map)\n\nopen LawfulMvFunctor\n\nvariable {α β γ : TypeVec.{u} n}\n\nvariable {F : TypeVec.{u} n → Type v} [MvFunctor F]\n\nvariable (p : α ⟹ repeat n Prop) (r : α ⊗ α ⟹ repeat n Prop)\n\n#print MvFunctor.LiftP' /-\n/-- adapt `mvfunctor.liftp` to accept predicates as arrows -/\ndef LiftP' : F α → Prop :=\n  MvFunctor.LiftP fun i x => ofRepeat <| p i x\n#align mvfunctor.liftp' MvFunctor.LiftP'\n-/\n\n#print MvFunctor.LiftR' /-\n/-- adapt `mvfunctor.liftp` to accept relations as arrows -/\ndef LiftR' : F α → F α → Prop :=\n  MvFunctor.LiftR fun i x y => ofRepeat <| r i <| TypeVec.prod.mk _ x y\n#align mvfunctor.liftr' MvFunctor.LiftR'\n-/\n\nvariable [LawfulMvFunctor F]\n\n#print MvFunctor.id_map /-\n@[simp]\ntheorem id_map (x : F α) : TypeVec.id <$$> x = x :=\n  id_map x\n#align mvfunctor.id_map MvFunctor.id_map\n-/\n\n#print MvFunctor.id_map' /-\n@[simp]\ntheorem id_map' (x : F α) : (fun i a => a) <$$> x = x :=\n  id_map x\n#align mvfunctor.id_map' MvFunctor.id_map'\n-/\n\n#print MvFunctor.map_map /-\ntheorem map_map (g : α ⟹ β) (h : β ⟹ γ) (x : F α) : h <$$> g <$$> x = (h ⊚ g) <$$> x :=\n  Eq.symm <| comp_map _ _ _\n#align mvfunctor.map_map MvFunctor.map_map\n-/\n\nsection Liftp'\n\nvariable (F)\n\n#print MvFunctor.exists_iff_exists_of_mono /-\ntheorem exists_iff_exists_of_mono {p : F α → Prop} {q : F β → Prop} (f : α ⟹ β) (g : β ⟹ α)\n    (h₀ : f ⊚ g = id) (h₁ : ∀ u : F α, p u ↔ q (f <$$> u)) : (∃ u : F α, p u) ↔ ∃ u : F β, q u :=\n  by\n  constructor <;> rintro ⟨u, h₂⟩ <;> [use f <$$> u, use g <$$> u]\n  · apply (h₁ u).mp h₂\n  · apply (h₁ _).mpr _\n    simp only [MvFunctor.map_map, h₀, LawfulMvFunctor.id_map, h₂]\n#align mvfunctor.exists_iff_exists_of_mono MvFunctor.exists_iff_exists_of_mono\n-/\n\nvariable {F}\n\n#print MvFunctor.LiftP_def /-\ntheorem LiftP_def (x : F α) : LiftP' p x ↔ ∃ u : F (Subtype_ p), subtypeVal p <$$> u = x :=\n  exists_iff_exists_of_mono F _ _ (toSubtype_of_subtype p) (by simp [MvFunctor.map_map])\n#align mvfunctor.liftp_def MvFunctor.LiftP_def\n-/\n\n#print MvFunctor.LiftR_def /-\ntheorem LiftR_def (x y : F α) :\n    LiftR' r x y ↔\n      ∃ u : F (Subtype_ r),\n        (TypeVec.prod.fst ⊚ subtypeVal r) <$$> u = x ∧\n          (TypeVec.prod.snd ⊚ subtypeVal r) <$$> u = y :=\n  exists_iff_exists_of_mono _ _ _ (toSubtype'_of_subtype' r)\n    (by simp only [map_map, comp_assoc, subtype_val_to_subtype'] <;> simp [comp])\n#align mvfunctor.liftr_def MvFunctor.LiftR_def\n-/\n\nend Liftp'\n\nend MvFunctor\n\nopen Nat\n\nnamespace MvFunctor\n\nopen TypeVec\n\nsection LiftpLastPredIff\n\nvariable {F : TypeVec.{u} (n + 1) → Type _} [MvFunctor F] [LawfulMvFunctor F] {α : TypeVec.{u} n}\n\nvariable (p : α ⟹ repeat n Prop) (r : α ⊗ α ⟹ repeat n Prop)\n\nopen MvFunctor\n\nvariable {β : Type u}\n\nvariable (pp : β → Prop)\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def f :\n    ∀ n α,\n      (fun i : Fin2 (n + 1) => { p_1 // ofRepeat (PredLast' α pp i p_1) }) ⟹ fun i : Fin2 (n + 1) =>\n        { p_1 : (α ::: β) i // PredLast α pp p_1 }\n  | _, α, Fin2.fs i, x =>\n    ⟨x.val, cast (by simp only [pred_last] <;> erw [const_iff_true]) x.property⟩\n  | _, α, Fin2.fz, x => ⟨x.val, x.property⟩\n#align mvfunctor.f mvfunctor.f\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def g :\n    ∀ n α,\n      (fun i : Fin2 (n + 1) => { p_1 : (α ::: β) i // PredLast α pp p_1 }) ⟹ fun i : Fin2 (n + 1) =>\n        { p_1 // ofRepeat (PredLast' α pp i p_1) }\n  | _, α, Fin2.fs i, x =>\n    ⟨x.val, cast (by simp only [pred_last] <;> erw [const_iff_true]) x.property⟩\n  | _, α, Fin2.fz, x => ⟨x.val, x.property⟩\n#align mvfunctor.g mvfunctor.g\n\n/- warning: mvfunctor.liftp_last_pred_iff -> MvFunctor.LiftP_PredLast_iff is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {F : (TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Type.{u2}} [_inst_1 : MvFunctor.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) F] [_inst_2 : LawfulMvFunctor.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) F _inst_1] {α : TypeVec.{u1} n} {β : Type.{u1}} (p : β -> Prop) (x : F (TypeVec.append1.{u1} n α β)), Iff (MvFunctor.LiftP'.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α β) F _inst_1 (TypeVec.PredLast'.{u1} n α β p) x) (MvFunctor.LiftP.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) F _inst_1 (fun (i : Fin2 (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => TypeVec.append1.{u1} n α β i) (TypeVec.PredLast.{u1} n α β p) x)\nbut is expected to have type\n  forall {n : Nat} {F : (TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Type.{u1}} [_inst_1 : MvFunctor.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) F] [_inst_2 : LawfulMvFunctor.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) F _inst_1] {α : TypeVec.{u2} n} {β : Type.{u2}} (p : β -> Prop) (x : F (TypeVec.append1.{u2} n α β)), Iff (MvFunctor.LiftP'.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u2} n α β) F _inst_1 (TypeVec.PredLast'.{u2} n α β p) x) (MvFunctor.LiftP.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) F _inst_1 (fun (i : Fin2 (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) => TypeVec.append1.{u2} n α β i) (TypeVec.PredLast.{u2} n α β p) x)\nCase conversion may be inaccurate. Consider using '#align mvfunctor.liftp_last_pred_iff MvFunctor.LiftP_PredLast_iffₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem LiftP_PredLast_iff {β} (p : β → Prop) (x : F (α ::: β)) :\n    LiftP' (PredLast' _ p) x ↔ LiftP (PredLast _ p) x :=\n  by\n  dsimp only [liftp, liftp']\n  apply exists_iff_exists_of_mono F (f _ n α) (g _ n α)\n  · ext (i⟨x, _⟩)\n    cases i <;> rfl\n  · intros\n    rw [MvFunctor.map_map, (· ⊚ ·)]\n    congr <;> ext (i⟨x, _⟩) <;> cases i <;> rfl\n#align mvfunctor.liftp_last_pred_iff MvFunctor.LiftP_PredLast_iff\n\nopen Function\n\nvariable (rr : β → β → Prop)\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def f :\n    ∀ n α,\n      (fun i : Fin2 (n + 1) =>\n          { p_1 : _ × _ // ofRepeat (RelLast' α rr i (TypeVec.prod.mk _ p_1.fst p_1.snd)) }) ⟹\n        fun i : Fin2 (n + 1) => { p_1 : (α ::: β) i × _ // RelLast α rr p_1.fst p_1.snd }\n  | _, α, Fin2.fs i, x =>\n    ⟨x.val, cast (by simp only [rel_last] <;> erw [repeat_eq_iff_eq]) x.property⟩\n  | _, α, Fin2.fz, x => ⟨x.val, x.property⟩\n#align mvfunctor.f mvfunctor.f\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def g :\n    ∀ n α,\n      (fun i : Fin2 (n + 1) => { p_1 : (α ::: β) i × _ // RelLast α rr p_1.fst p_1.snd }) ⟹\n        fun i : Fin2 (n + 1) =>\n        { p_1 : _ × _ // ofRepeat (RelLast' α rr i (TypeVec.prod.mk _ p_1.1 p_1.2)) }\n  | _, α, Fin2.fs i, x =>\n    ⟨x.val, cast (by simp only [rel_last] <;> erw [repeat_eq_iff_eq]) x.property⟩\n  | _, α, Fin2.fz, x => ⟨x.val, x.property⟩\n#align mvfunctor.g mvfunctor.g\n\n/- warning: mvfunctor.liftr_last_rel_iff -> MvFunctor.LiftR_RelLast_iff is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {F : (TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> Type.{u2}} [_inst_1 : MvFunctor.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) F] [_inst_2 : LawfulMvFunctor.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) F _inst_1] {α : TypeVec.{u1} n} {β : Type.{u1}} (rr : β -> β -> Prop) (x : F (TypeVec.append1.{u1} n α β)) (y : F (TypeVec.append1.{u1} n α β)), Iff (MvFunctor.LiftR'.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (TypeVec.append1.{u1} n α β) F _inst_1 (TypeVec.RelLast'.{u1} n α β rr) x y) (MvFunctor.LiftR.{u1, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) F _inst_1 (fun (i : Fin2 (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) => TypeVec.append1.{u1} n α β i) (TypeVec.RelLast.{u1} n α β β rr) x y)\nbut is expected to have type\n  forall {n : Nat} {F : (TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> Type.{u1}} [_inst_1 : MvFunctor.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) F] [_inst_2 : LawfulMvFunctor.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) F _inst_1] {α : TypeVec.{u2} n} {β : Type.{u2}} (rr : β -> β -> Prop) (x : F (TypeVec.append1.{u2} n α β)) (y : F (TypeVec.append1.{u2} n α β)), Iff (MvFunctor.LiftR'.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (TypeVec.append1.{u2} n α β) F _inst_1 (TypeVec.RelLast'.{u2} n α β rr) x y) (MvFunctor.LiftR.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) F _inst_1 (fun {i : Fin2 (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} => TypeVec.append1.{u2} n α β i) (fun {i._@.Mathlib.Control.Functor.Multivariate._hyg.3418 : Fin2 (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} => TypeVec.RelLast.{u2} n α β β rr i._@.Mathlib.Control.Functor.Multivariate._hyg.3418) x y)\nCase conversion may be inaccurate. Consider using '#align mvfunctor.liftr_last_rel_iff MvFunctor.LiftR_RelLast_iffₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem LiftR_RelLast_iff (x y : F (α ::: β)) :\n    LiftR' (RelLast' _ rr) x y ↔ LiftR (RelLast _ rr) x y :=\n  by\n  dsimp only [liftr, liftr']\n  apply exists_iff_exists_of_mono F (f rr _ _) (g rr _ _)\n  · ext (i⟨x, _⟩) : 2\n    cases i <;> rfl\n  · intros\n    rw [MvFunctor.map_map, MvFunctor.map_map, (· ⊚ ·), (· ⊚ ·)]\n    congr <;> ext (i⟨x, _⟩) <;> cases i <;> rfl\n#align mvfunctor.liftr_last_rel_iff MvFunctor.LiftR_RelLast_iff\n\nend LiftpLastPredIff\n\nend MvFunctor\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Control/Functor/Multivariate.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.47744200939618386}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Patrick Massot\n\nPi instances for algebraic structures.\n-/\nimport order.basic\nimport algebra.module algebra.group\nimport data.finset\nimport tactic.pi_instances\n\nnamespace pi\nuniverses u v w\nvariable {I : Type u}     -- The indexing type\nvariable {f : I → Type v} -- The family of types already equiped with instances\nvariables (x y : Π i, f i) (i : I)\n\ninstance has_zero [∀ i, has_zero $ f i] : has_zero (Π i : I, f i) := ⟨λ i, 0⟩\n@[simp] lemma zero_apply [∀ i, has_zero $ f i] : (0 : Π i, f i) i = 0 := rfl\n\ninstance has_one [∀ i, has_one $ f i] : has_one (Π i : I, f i) := ⟨λ i, 1⟩\n@[simp] lemma one_apply [∀ i, has_one $ f i] : (1 : Π i, f i) i = 1 := rfl\n\nattribute [to_additive pi.has_zero] pi.has_one\nattribute [to_additive pi.zero_apply] pi.one_apply\n\ninstance has_add [∀ i, has_add $ f i] : has_add (Π i : I, f i) := ⟨λ x y, λ i, x i + y i⟩\n@[simp] lemma add_apply [∀ i, has_add $ f i] : (x + y) i = x i + y i := rfl\n\ninstance has_mul [∀ i, has_mul $ f i] : has_mul (Π i : I, f i) := ⟨λ x y, λ i, x i * y i⟩\n@[simp] lemma mul_apply [∀ i, has_mul $ f i] : (x * y) i = x i * y i := rfl\n\nattribute [to_additive pi.has_add] pi.has_mul\nattribute [to_additive pi.add_apply] pi.mul_apply\n\ninstance has_inv [∀ i, has_inv $ f i] : has_inv (Π i : I, f i) := ⟨λ x, λ i, (x i)⁻¹⟩\n@[simp] lemma inv_apply [∀ i, has_inv $ f i] : x⁻¹ i = (x i)⁻¹ := rfl\n\ninstance has_neg [∀ i, has_neg $ f i] : has_neg (Π i : I, f i) := ⟨λ x, λ i, -(x i)⟩\n@[simp] lemma neg_apply [∀ i, has_neg $ f i] : (-x) i = -x i := rfl\n\nattribute [to_additive pi.has_neg] pi.has_inv\nattribute [to_additive pi.neg_apply] pi.inv_apply\n\ninstance has_scalar {α : Type*} [∀ i, has_scalar α $ f i] : has_scalar α (Π i : I, f i) := ⟨λ s x, λ i, s • (x i)⟩\n@[simp] lemma smul_apply {α : Type*} [∀ i, has_scalar α $ f i] (s : α) : (s • x) i = s • x i := rfl\n\ninstance semigroup          [∀ i, semigroup          $ f i] : semigroup          (Π i : I, f i) := by pi_instance\ninstance comm_semigroup     [∀ i, comm_semigroup     $ f i] : comm_semigroup     (Π i : I, f i) := by pi_instance\ninstance monoid             [∀ i, monoid             $ f i] : monoid             (Π i : I, f i) := by pi_instance\ninstance comm_monoid        [∀ i, comm_monoid        $ f i] : comm_monoid        (Π i : I, f i) := by pi_instance\ninstance group              [∀ i, group              $ f i] : group              (Π i : I, f i) := by pi_instance\ninstance comm_group         [∀ i, comm_group         $ f i] : comm_group         (Π i : I, f i) := by pi_instance\ninstance add_semigroup      [∀ i, add_semigroup      $ f i] : add_semigroup      (Π i : I, f i) := by pi_instance\ninstance add_comm_semigroup [∀ i, add_comm_semigroup $ f i] : add_comm_semigroup (Π i : I, f i) := by pi_instance\ninstance add_monoid         [∀ i, add_monoid         $ f i] : add_monoid         (Π i : I, f i) := by pi_instance\ninstance add_comm_monoid    [∀ i, add_comm_monoid    $ f i] : add_comm_monoid    (Π i : I, f i) := by pi_instance\ninstance add_group          [∀ i, add_group          $ f i] : add_group          (Π i : I, f i) := by pi_instance\ninstance add_comm_group     [∀ i, add_comm_group     $ f i] : add_comm_group     (Π i : I, f i) := by pi_instance\ninstance ring               [∀ i, ring               $ f i] : ring               (Π i : I, f i) := by pi_instance\ninstance comm_ring          [∀ i, comm_ring          $ f i] : comm_ring          (Π i : I, f i) := by pi_instance\n\ninstance mul_action     (α) {m : monoid α}                                      [∀ i, mul_action α $ f i]     : mul_action α (Π i : I, f i) :=\n{ smul := λ c f i, c • f i,\n  mul_smul := λ r s f, funext $ λ i, mul_smul _ _ _,\n  one_smul := λ f, funext $ λ i, one_smul α _ }\n\ninstance distrib_mul_action (α) {m : monoid α}         [∀ i, add_monoid $ f i]      [∀ i, distrib_mul_action α $ f i] : distrib_mul_action α (Π i : I, f i) :=\n{ smul_zero := λ c, funext $ λ i, smul_zero _,\n  smul_add := λ c f g, funext $ λ i, smul_add _ _ _,\n  ..pi.mul_action _ }\n\nvariables (I f)\n\ninstance semimodule     (α) {r : semiring α}       [∀ i, add_comm_monoid $ f i] [∀ i, semimodule α $ f i]     : semimodule α (Π i : I, f i) :=\n{ add_smul := λ c f g, funext $ λ i, add_smul _ _ _,\n  zero_smul := λ f, funext $ λ i, zero_smul α _,\n  ..pi.distrib_mul_action _ }\n\nvariables {I f}\n\ninstance module         (α) {r : ring α}           [∀ i, add_comm_group $ f i]  [∀ i, module α $ f i]         : module α (Π i : I, f i)       := {..pi.semimodule I f α}\n\ninstance vector_space   (α) {r : discrete_field α} [∀ i, add_comm_group $ f i]  [∀ i, vector_space α $ f i]   : vector_space α (Π i : I, f i) := {..pi.module α}\n\ninstance left_cancel_semigroup [∀ i, left_cancel_semigroup $ f i] : left_cancel_semigroup (Π i : I, f i) :=\nby pi_instance\n\ninstance add_left_cancel_semigroup [∀ i, add_left_cancel_semigroup $ f i] : add_left_cancel_semigroup (Π i : I, f i) :=\nby pi_instance\n\ninstance right_cancel_semigroup [∀ i, right_cancel_semigroup $ f i] : right_cancel_semigroup (Π i : I, f i) :=\nby pi_instance\n\ninstance add_right_cancel_semigroup [∀ i, add_right_cancel_semigroup $ f i] : add_right_cancel_semigroup (Π i : I, f i) :=\nby pi_instance\n\ninstance ordered_cancel_comm_monoid [∀ i, ordered_cancel_comm_monoid $ f i] : ordered_cancel_comm_monoid (Π i : I, f i) :=\nby pi_instance\n\nattribute [to_additive pi.add_semigroup]              pi.semigroup\nattribute [to_additive pi.add_comm_semigroup]         pi.comm_semigroup\nattribute [to_additive pi.add_monoid]                 pi.monoid\nattribute [to_additive pi.add_comm_monoid]            pi.comm_monoid\nattribute [to_additive pi.add_group]                  pi.group\nattribute [to_additive pi.add_comm_group]             pi.comm_group\nattribute [to_additive pi.add_left_cancel_semigroup]  pi.left_cancel_semigroup\nattribute [to_additive pi.add_right_cancel_semigroup] pi.right_cancel_semigroup\n\n@[to_additive pi.list_sum_apply]\nlemma list_prod_apply {α : Type*} {β : α → Type*} [∀a, monoid (β a)] (a : α) :\n  ∀ (l : list (Πa, β a)), l.prod a = (l.map (λf:Πa, β a, f a)).prod\n| []       := rfl\n| (f :: l) := by simp [mul_apply f l.prod a, list_prod_apply l]\n\n@[to_additive pi.multiset_sum_apply]\nlemma multiset_prod_apply {α : Type*} {β : α → Type*} [∀a, comm_monoid (β a)] (a : α)\n  (s : multiset (Πa, β a)) : s.prod a = (s.map (λf:Πa, β a, f a)).prod :=\nquotient.induction_on s $ assume l, begin simp [list_prod_apply a l] end\n\n@[to_additive pi.finset_sum_apply]\nlemma finset_prod_apply {α : Type*} {β : α → Type*} {γ} [∀a, comm_monoid (β a)] (a : α)\n  (s : finset γ) (g : γ → Πa, β a) : s.prod g a = s.prod (λc, g c a) :=\nshow (s.val.map g).prod a = (s.val.map (λc, g c a)).prod,\n  by rw [multiset_prod_apply, multiset.map_map]\n\ndef is_ring_hom_pi\n  {α : Type u} {β : α → Type v} [R : Π a : α, ring (β a)]\n  {γ : Type w} [ring γ]\n  (f : Π a : α, γ → β a) [Rh : Π a : α, is_ring_hom (f a)] :\n  is_ring_hom (λ x b, f b x) :=\nbegin\n  dsimp at *,\n  split,\n  -- It's a pity that these can't be done using `simp` lemmas.\n  { ext, rw [is_ring_hom.map_one (f x)], refl, },\n  { intros x y, ext1 z, rw [is_ring_hom.map_mul (f z)], refl, },\n  { intros x y, ext1 z, rw [is_ring_hom.map_add (f z)], refl, }\nend\n\n\nend pi\n\nnamespace prod\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} {p q : α × β}\n\ninstance [has_add α] [has_add β] : has_add (α × β) :=\n⟨λp q, (p.1 + q.1, p.2 + q.2)⟩\n@[to_additive prod.has_add]\ninstance [has_mul α] [has_mul β] : has_mul (α × β) :=\n⟨λp q, (p.1 * q.1, p.2 * q.2)⟩\n\n@[simp, to_additive prod.fst_add]\nlemma fst_mul [has_mul α] [has_mul β] : (p * q).1 = p.1 * q.1 := rfl\n@[simp, to_additive prod.snd_add]\nlemma snd_mul [has_mul α] [has_mul β] : (p * q).2 = p.2 * q.2 := rfl\n@[simp, to_additive prod.mk_add_mk]\nlemma mk_mul_mk [has_mul α] [has_mul β] (a₁ a₂ : α) (b₁ b₂ : β) :\n  (a₁, b₁) * (a₂, b₂) = (a₁ * a₂, b₁ * b₂) := rfl\n\ninstance [has_zero α] [has_zero β] : has_zero (α × β) := ⟨(0, 0)⟩\n@[to_additive prod.has_zero]\ninstance [has_one α] [has_one β] : has_one (α × β) := ⟨(1, 1)⟩\n\n@[simp, to_additive prod.fst_zero]\nlemma fst_one [has_one α] [has_one β] : (1 : α × β).1 = 1 := rfl\n@[simp, to_additive prod.snd_zero]\nlemma snd_one [has_one α] [has_one β] : (1 : α × β).2 = 1 := rfl\n@[to_additive prod.zero_eq_mk]\nlemma one_eq_mk [has_one α] [has_one β] : (1 : α × β) = (1, 1) := rfl\n\ninstance [has_neg α] [has_neg β] : has_neg (α × β) := ⟨λp, (- p.1, - p.2)⟩\n@[to_additive prod.has_neg]\ninstance [has_inv α] [has_inv β] : has_inv (α × β) := ⟨λp, (p.1⁻¹, p.2⁻¹)⟩\n\n@[simp, to_additive prod.fst_neg]\nlemma fst_inv [has_inv α] [has_inv β] : (p⁻¹).1 = (p.1)⁻¹ := rfl\n@[simp, to_additive prod.snd_neg]\nlemma snd_inv [has_inv α] [has_inv β] : (p⁻¹).2 = (p.2)⁻¹ := rfl\n@[to_additive prod.neg_mk]\nlemma inv_mk [has_inv α] [has_inv β] (a : α) (b : β) : (a, b)⁻¹ = (a⁻¹, b⁻¹) := rfl\n\ninstance [add_semigroup α] [add_semigroup β] : add_semigroup (α × β) :=\n{ add_assoc := assume a b c, mk.inj_iff.mpr ⟨add_assoc _ _ _, add_assoc _ _ _⟩,\n  .. prod.has_add }\n@[to_additive prod.add_semigroup]\ninstance [semigroup α] [semigroup β] : semigroup (α × β) :=\n{ mul_assoc := assume a b c, mk.inj_iff.mpr ⟨mul_assoc _ _ _, mul_assoc _ _ _⟩,\n  .. prod.has_mul }\n\ninstance [add_monoid α] [add_monoid β] : add_monoid (α × β) :=\n{ zero_add := assume a, prod.rec_on a $ λa b, mk.inj_iff.mpr ⟨zero_add _, zero_add _⟩,\n  add_zero := assume a, prod.rec_on a $ λa b, mk.inj_iff.mpr ⟨add_zero _, add_zero _⟩,\n  .. prod.add_semigroup, .. prod.has_zero }\n@[to_additive prod.add_monoid]\ninstance [monoid α] [monoid β] : monoid (α × β) :=\n{ one_mul := assume a, prod.rec_on a $ λa b, mk.inj_iff.mpr ⟨one_mul _, one_mul _⟩,\n  mul_one := assume a, prod.rec_on a $ λa b, mk.inj_iff.mpr ⟨mul_one _, mul_one _⟩,\n  .. prod.semigroup, .. prod.has_one }\n\ninstance [add_group α] [add_group β] : add_group (α × β) :=\n{ add_left_neg := assume a, mk.inj_iff.mpr ⟨add_left_neg _, add_left_neg _⟩,\n  .. prod.add_monoid, .. prod.has_neg }\n@[to_additive prod.add_group]\ninstance [group α] [group β] : group (α × β) :=\n{ mul_left_inv := assume a, mk.inj_iff.mpr ⟨mul_left_inv _, mul_left_inv _⟩,\n  .. prod.monoid, .. prod.has_inv }\n\ninstance [add_comm_semigroup α] [add_comm_semigroup β] : add_comm_semigroup (α × β) :=\n{ add_comm := assume a b, mk.inj_iff.mpr ⟨add_comm _ _, add_comm _ _⟩,\n  .. prod.add_semigroup }\n@[to_additive prod.add_comm_semigroup]\ninstance [comm_semigroup α] [comm_semigroup β] : comm_semigroup (α × β) :=\n{ mul_comm := assume a b, mk.inj_iff.mpr ⟨mul_comm _ _, mul_comm _ _⟩,\n  .. prod.semigroup }\n\ninstance [add_comm_monoid α] [add_comm_monoid β] : add_comm_monoid (α × β) :=\n{ .. prod.add_comm_semigroup, .. prod.add_monoid }\n@[to_additive prod.add_comm_monoid]\ninstance [comm_monoid α] [comm_monoid β] : comm_monoid (α × β) :=\n{ .. prod.comm_semigroup, .. prod.monoid }\n\ninstance [add_comm_group α] [add_comm_group β] : add_comm_group (α × β) :=\n{ .. prod.add_comm_semigroup, .. prod.add_group }\n@[to_additive prod.add_comm_group]\ninstance [comm_group α] [comm_group β] : comm_group (α × β) :=\n{ .. prod.comm_semigroup, .. prod.group }\n\n@[to_additive fst.is_add_monoid_hom]\nlemma fst.is_monoid_hom [monoid α] [monoid β] : is_monoid_hom (prod.fst : α × β → α) :=\nby refine_struct {..}; simp\n@[to_additive snd.is_add_monoid_hom]\nlemma snd.is_monoid_hom [monoid α] [monoid β] : is_monoid_hom (prod.snd : α × β → β) :=\nby refine_struct {..}; simp\n\n@[to_additive fst.is_add_group_hom]\nlemma fst.is_group_hom [group α] [group β] : is_group_hom (prod.fst : α × β → α) :=\nby refine_struct {..}; simp\n@[to_additive snd.is_add_group_hom]\nlemma snd.is_group_hom [group α] [group β] : is_group_hom (prod.snd : α × β → β) :=\nby refine_struct {..}; simp\n\nattribute [instance] fst.is_monoid_hom fst.is_add_monoid_hom snd.is_monoid_hom snd.is_add_monoid_hom\nfst.is_group_hom fst.is_add_group_hom snd.is_group_hom snd.is_add_group_hom\n\n@[to_additive prod.fst_sum]\nlemma fst_prod [comm_monoid α] [comm_monoid β] {t : finset γ} {f : γ → α × β} :\n  (t.prod f).1 = t.prod (λc, (f c).1) :=\n(finset.prod_hom prod.fst).symm\n\n@[to_additive prod.snd_sum]\nlemma snd_prod [comm_monoid α] [comm_monoid β] {t : finset γ} {f : γ → α × β} :\n  (t.prod f).2 = t.prod (λc, (f c).2) :=\n(finset.prod_hom prod.snd).symm\n\ninstance [semiring α] [semiring β] : semiring (α × β) :=\n{ zero_mul := λ a, mk.inj_iff.mpr ⟨zero_mul _, zero_mul _⟩,\n  mul_zero := λ a, mk.inj_iff.mpr ⟨mul_zero _, mul_zero _⟩,\n  left_distrib := λ a b c, mk.inj_iff.mpr ⟨left_distrib _ _ _, left_distrib _ _ _⟩,\n  right_distrib := λ a b c, mk.inj_iff.mpr ⟨right_distrib _ _ _, right_distrib _ _ _⟩,\n  ..prod.add_comm_monoid, ..prod.monoid }\n\ninstance [ring α] [ring β] : ring (α × β) :=\n{ ..prod.add_comm_group, ..prod.semiring }\n\ninstance [comm_ring α] [comm_ring β] : comm_ring (α × β) :=\n{ ..prod.ring, ..prod.comm_monoid }\n\ninstance [nonzero_comm_ring α] [comm_ring β] : nonzero_comm_ring (α × β) :=\n{ zero_ne_one := mt (congr_arg prod.fst) zero_ne_one,\n  ..prod.comm_ring }\n\ninstance fst.is_semiring_hom [semiring α] [semiring β] : is_semiring_hom (prod.fst : α × β → α) :=\nby refine_struct {..}; simp\ninstance snd.is_semiring_hom [semiring α] [semiring β] : is_semiring_hom (prod.snd : α × β → β) :=\nby refine_struct {..}; simp\n\ninstance fst.is_ring_hom [ring α] [ring β] : is_ring_hom (prod.fst : α × β → α) :=\nby refine_struct {..}; simp\ninstance snd.is_ring_hom [ring α] [ring β] : is_ring_hom (prod.snd : α × β → β) :=\nby refine_struct {..}; simp\n\n/-- Left injection function for the inner product\nFrom a vector space (and also group and module) perspective the product is the same as the sum of\ntwo vector spaces. `inl` and `inr` provide the corresponding injection functions.\n-/\ndef inl [has_zero β] (a : α) : α × β := (a, 0)\n\n/-- Right injection function for the inner product -/\ndef inr [has_zero α] (b : β) : α × β := (0, b)\n\nlemma injective_inl [has_zero β] : function.injective (inl : α → α × β) :=\nassume x y h, (prod.mk.inj_iff.mp h).1\n\nlemma injective_inr [has_zero α] : function.injective (inr : β → α × β) :=\nassume x y h, (prod.mk.inj_iff.mp h).2\n\n@[simp] lemma inl_eq_inl [has_zero β] {a₁ a₂ : α} : (inl a₁ : α × β) = inl a₂ ↔ a₁ = a₂ :=\niff.intro (assume h, injective_inl h) (assume h, h ▸ rfl)\n\n@[simp] lemma inr_eq_inr [has_zero α] {b₁ b₂ : β} : (inr b₁ : α × β) = inr b₂ ↔ b₁ = b₂ :=\niff.intro (assume h, injective_inr h) (assume h, h ▸ rfl)\n\n@[simp] lemma inl_eq_inr [has_zero α] [has_zero β] {a : α} {b : β} :\n  inl a = inr b ↔ a = 0 ∧ b = 0 :=\nby constructor; simp [inl, inr] {contextual := tt}\n\n@[simp] lemma inr_eq_inl [has_zero α] [has_zero β] {a : α} {b : β} :\n  inr b = inl a ↔ a = 0 ∧ b = 0 :=\nby constructor; simp [inl, inr] {contextual := tt}\n\n@[simp] lemma fst_inl [has_zero β] (a : α) : (inl a : α × β).1 = a := rfl\n@[simp] lemma snd_inl [has_zero β] (a : α) : (inl a : α × β).2 = 0 := rfl\n@[simp] lemma fst_inr [has_zero α] (b : β) : (inr b : α × β).1 = 0 := rfl\n@[simp] lemma snd_inr [has_zero α] (b : β) : (inr b : α × β).2 = b := rfl\n\ninstance [has_scalar α β] [has_scalar α γ] : has_scalar α (β × γ) := ⟨λa p, (a • p.1, a • p.2)⟩\n\n@[simp] theorem smul_fst [has_scalar α β] [has_scalar α γ]\n  (a : α) (x : β × γ) : (a • x).1 = a • x.1 := rfl\n@[simp] theorem smul_snd [has_scalar α β] [has_scalar α γ]\n  (a : α) (x : β × γ) : (a • x).2 = a • x.2 := rfl\n@[simp] theorem smul_mk [has_scalar α β] [has_scalar α γ]\n  (a : α) (b : β) (c : γ) : a • (b, c) = (a • b, a • c) := rfl\n\ninstance {r : semiring α} [add_comm_monoid β] [add_comm_monoid γ]\n  [semimodule α β] [semimodule α γ] : semimodule α (β × γ) :=\n{ smul_add  := assume a p₁ p₂, mk.inj_iff.mpr ⟨smul_add _ _ _, smul_add _ _ _⟩,\n  add_smul  := assume a p₁ p₂, mk.inj_iff.mpr ⟨add_smul _ _ _, add_smul _ _ _⟩,\n  mul_smul  := assume a₁ a₂ p, mk.inj_iff.mpr ⟨mul_smul _ _ _, mul_smul _ _ _⟩,\n  one_smul  := assume ⟨b, c⟩, mk.inj_iff.mpr ⟨one_smul _ _, one_smul _ _⟩,\n  zero_smul := assume ⟨b, c⟩, mk.inj_iff.mpr ⟨zero_smul _ _, zero_smul _ _⟩,\n  smul_zero := assume a, mk.inj_iff.mpr ⟨smul_zero _, smul_zero _⟩,\n  .. prod.has_scalar }\n\ninstance {r : ring α} [add_comm_group β] [add_comm_group γ]\n  [module α β] [module α γ] : module α (β × γ) := {}\n\ninstance {r : discrete_field α} [add_comm_group β] [add_comm_group γ]\n  [vector_space α β] [vector_space α γ] : vector_space α (β × γ) := {}\n\nend prod\n\nnamespace finset\n\n@[to_additive finset.prod_mk_sum]\nlemma prod_mk_prod {α β γ : Type*} [comm_monoid α] [comm_monoid β] (s : finset γ)\n  (f : γ → α) (g : γ → β) : (s.prod f, s.prod g) = s.prod (λ x, (f x, g x)) :=\nby haveI := classical.dec_eq γ; exact\nfinset.induction_on s rfl (by simp [prod.ext_iff] {contextual := tt})\n\nend finset\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/algebra/pi_instances.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.4774420050702957}}
{"text": "/-\nCopyright (c) 2019 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\n\nimport algebra.group_power.identities\nimport data.zmod.basic\nimport field_theory.finite.basic\nimport data.int.parity\nimport data.fintype.big_operators\n\n/-!\n# Lagrange's four square theorem\n\nThe main result in this file is `sum_four_squares`,\na proof that every natural number is the sum of four square numbers.\n\n## Implementation Notes\n\nThe proof used is close to Lagrange's original proof.\n-/\n\nopen finset polynomial finite_field equiv\nopen_locale big_operators\n\nnamespace int\n\nlemma sq_add_sq_of_two_mul_sq_add_sq {m x y : ℤ} (h : 2 * m = x^2 + y^2) :\n  m = ((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2 :=\nhave even (x^2 + y^2), by simp [←h, even_mul],\nhave hxaddy : even (x + y), by simpa [sq] with parity_simps,\nhave hxsuby : even (x - y), by simpa [sq] with parity_simps,\n(mul_right_inj' (show (2*2 : ℤ) ≠ 0, from dec_trivial)).1 $\ncalc 2 * 2 * m = (x - y)^2 + (x + y)^2 : by rw [mul_assoc, h]; ring\n... = (2 * ((x - y) / 2))^2 + (2 * ((x + y) / 2))^2 :\n  by { rw even_iff_two_dvd at hxsuby hxaddy,\n    rw [int.mul_div_cancel' hxsuby, int.mul_div_cancel' hxaddy] }\n... = 2 * 2 * (((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2) :\n  by simp [mul_add, pow_succ, mul_comm, mul_assoc, mul_left_comm]\n\nlemma exists_sq_add_sq_add_one_eq_k (p : ℕ) [hp : fact p.prime] :\n  ∃ (a b : ℤ) (k : ℕ), a^2 + b^2 + 1 = k * p ∧ k < p :=\nhp.1.eq_two_or_odd.elim (λ hp2, hp2.symm ▸ ⟨1, 0, 1, rfl, dec_trivial⟩) $ λ hp1,\nlet ⟨a, b, hab⟩ := zmod.sq_add_sq p (-1) in\nhave hab' : (p : ℤ) ∣ a.val_min_abs ^ 2 + b.val_min_abs ^ 2 + 1,\n  from (char_p.int_cast_eq_zero_iff (zmod p) p _).1 $ by simpa [eq_neg_iff_add_eq_zero] using hab,\nlet ⟨k, hk⟩ := hab' in\nhave hk0 : 0 ≤ k, from nonneg_of_mul_nonneg_right\n  (by rw ← hk; exact (add_nonneg (add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_le_one))\n  (int.coe_nat_pos.2 hp.1.pos),\n⟨a.val_min_abs, b.val_min_abs, k.nat_abs,\n    by rw [hk, int.nat_abs_of_nonneg hk0, mul_comm],\n  lt_of_mul_lt_mul_left\n    (calc p * k.nat_abs = a.val_min_abs.nat_abs ^ 2 + b.val_min_abs.nat_abs ^ 2 + 1 :\n        by rw [← int.coe_nat_inj', int.coe_nat_add, int.coe_nat_add, int.coe_nat_pow,\n          int.coe_nat_pow, int.nat_abs_sq, int.nat_abs_sq,\n          int.coe_nat_one, hk, int.coe_nat_mul, int.nat_abs_of_nonneg hk0]\n      ... ≤ (p / 2) ^ 2 + (p / 2)^2 + 1 :\n        add_le_add\n          (add_le_add\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))\n          le_rfl\n      ... < (p / 2) ^ 2 + (p / 2)^ 2 + (p % 2)^2 + ((2 * (p / 2)^2 + (4 * (p / 2) * (p % 2)))) :\n        by rw [hp1, one_pow, mul_one];\n          exact (lt_add_iff_pos_right _).2\n            (add_pos_of_nonneg_of_pos (nat.zero_le _) (mul_pos dec_trivial\n              (nat.div_pos hp.1.two_le dec_trivial)))\n      ... = p * p : by { conv_rhs { rw [← nat.mod_add_div p 2] }, ring })\n    (show 0 ≤ p, from nat.zero_le _)⟩\n\nend int\n\nnamespace nat\n\nopen int\n\nopen_locale classical\n\nprivate lemma sum_four_squares_of_two_mul_sum_four_squares {m a b c d : ℤ}\n  (h : a^2 + b^2 + c^2 + d^2 = 2 * m) : ∃ w x y z : ℤ, w^2 + x^2 + y^2 + z^2 = m :=\nhave ∀ f : fin 4 → zmod 2, (f 0)^2 + (f 1)^2 + (f 2)^2 + (f 3)^2 = 0 →\n    ∃ i : (fin 4), (f i)^2 + f (swap i 0 1)^2 = 0 ∧ f (swap i 0 2)^2 + f (swap i 0 3)^2 = 0,\n  from dec_trivial,\nlet f : fin 4 → ℤ :=\n  vector.nth (a ::ᵥ b ::ᵥ c ::ᵥ d ::ᵥ vector.nil) in\nlet ⟨i, hσ⟩ := this (λ x, coe (f x)) (by rw [← @zero_mul (zmod 2) _ m,\n  ← show ((2 : ℤ) : zmod 2) = 0, from rfl,\n  ← int.cast_mul, ← h]; simp only [int.cast_add, int.cast_pow]; refl) in\nlet σ := swap i 0 in\nhave h01 : 2 ∣ f (σ 0) ^ 2 + f (σ 1) ^ 2,\n  from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $\n    by simpa only [int.cast_pow, int.cast_add, equiv.swap_apply_right, zmod.pow_card] using hσ.1,\nhave h23 : 2 ∣ f (σ 2) ^ 2 + f (σ 3) ^ 2,\n  from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $\n    by simpa only [int.cast_pow, int.cast_add, zmod.pow_card] using hσ.2,\nlet ⟨x, hx⟩ := h01 in let ⟨y, hy⟩ := h23 in\n⟨(f (σ 0) - f (σ 1)) / 2, (f (σ 0) + f (σ 1)) / 2, (f (σ 2) - f (σ 3)) / 2, (f (σ 2) + f (σ 3)) / 2,\n  begin\n    rw [← int.sq_add_sq_of_two_mul_sq_add_sq hx.symm, add_assoc,\n      ← int.sq_add_sq_of_two_mul_sq_add_sq hy.symm,\n      ← mul_right_inj' (show (2 : ℤ) ≠ 0, from dec_trivial), ← h, mul_add, ← hx, ← hy],\n    have : ∑ x, f (σ x)^2 = ∑ x, f x^2,\n    { conv_rhs { rw ←equiv.sum_comp σ } },\n    simpa only [fin.sum_univ_four, add_assoc] using this,\n  end⟩\n\nprivate lemma prime_sum_four_squares (p : ℕ) [hp : fact p.prime] :\n  ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = p :=\nhave hm : ∃ m < p, 0 < m ∧ ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = m * p,\n  from let ⟨a, b, k, hk⟩ := exists_sq_add_sq_add_one_eq_k p in\n  ⟨k, hk.2, nat.pos_of_ne_zero $\n    (λ hk0, by { rw [hk0, int.coe_nat_zero, zero_mul] at hk,\n      exact ne_of_gt (show a^2 + b^2 + 1 > 0, from add_pos_of_nonneg_of_pos\n        (add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_lt_one) hk.1 }),\n    a, b, 1, 0, by simpa only [zero_pow two_pos, one_pow, add_zero] using hk.1⟩,\nlet m := nat.find hm in\nlet ⟨a, b, c, d, (habcd : a^2 + b^2 + c^2 + d^2 = m * p)⟩ := (nat.find_spec hm).snd.2 in\nby haveI hm0 : ne_zero m := ne_zero.of_pos (nat.find_spec hm).snd.1; exact\nhave hmp : m < p, from (nat.find_spec hm).fst,\nm.mod_two_eq_zero_or_one.elim\n  (λ hm2 : m % 2 = 0,\n    let ⟨k, hk⟩ := nat.dvd_iff_mod_eq_zero.2 hm2 in\n    have hk0 : 0 < k, from nat.pos_of_ne_zero $\n      by { rintro rfl, rw mul_zero at hk, exact ne_zero.ne m hk },\n    have hkm : k < m, { rw [hk, two_mul], exact (lt_add_iff_pos_left _).2 hk0 },\n    false.elim $ nat.find_min hm hkm ⟨lt_trans hkm hmp, hk0,\n      sum_four_squares_of_two_mul_sum_four_squares\n        (show a^2 + b^2 + c^2 + d^2 = 2 * (k * p),\n          by { rw [habcd, hk, int.coe_nat_mul, mul_assoc], norm_num })⟩)\n  (λ hm2 : m % 2 = 1,\n    if hm1 : m = 1 then ⟨a, b, c, d, by simp only [hm1, habcd, int.coe_nat_one, one_mul]⟩\n    else\n      let w := (a : zmod m).val_min_abs, x := (b : zmod m).val_min_abs,\n          y := (c : zmod m).val_min_abs, z := (d : zmod m).val_min_abs in\n      have hnat_abs : w^2 + x^2 + y^2 + z^2 =\n          (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs ^2 + z.nat_abs ^ 2 : ℕ),\n        by { push_cast, simp_rw sq_abs, },\n      have hwxyzlt : w^2 + x^2 + y^2 + z^2 < m^2,\n        from calc w^2 + x^2 + y^2 + z^2\n            = (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs ^2 + z.nat_abs ^ 2 : ℕ) : hnat_abs\n        ... ≤ ((m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 : ℕ) :\n          int.coe_nat_le.2 $ add_le_add (add_le_add (add_le_add\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))\n            (nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)\n        ... = 4 * (m / 2 : ℕ) ^ 2 : by simp only [bit0_mul, one_mul, two_smul,\n                                                  nat.cast_add, nat.cast_pow, add_assoc]\n        ... < 4 * (m / 2 : ℕ) ^ 2 + ((4 * (m / 2) : ℕ) * (m % 2 : ℕ) + (m % 2 : ℕ)^2) :\n          (lt_add_iff_pos_right _).2 (by { rw [hm2, int.coe_nat_one, one_pow, mul_one],\n            exact add_pos_of_nonneg_of_pos (int.coe_nat_nonneg _) zero_lt_one })\n        ... = m ^ 2 : by { conv_rhs {rw [← nat.mod_add_div m 2]},\n          simp [-nat.mod_add_div, mul_add, add_mul, bit0, bit1, mul_comm, mul_assoc, mul_left_comm,\n            pow_add, add_comm, add_left_comm] },\n      have hwxyzabcd : ((w^2 + x^2 + y^2 + z^2 : ℤ) : zmod m) =\n          ((a^2 + b^2 + c^2 + d^2 : ℤ) : zmod m),\n        by push_cast,\n      have hwxyz0 : ((w^2 + x^2 + y^2 + z^2 : ℤ) : zmod m) = 0,\n        by rw [hwxyzabcd, habcd, int.cast_mul, cast_coe_nat, zmod.nat_cast_self, zero_mul],\n      let ⟨n, hn⟩ := ((char_p.int_cast_eq_zero_iff _ m _).1 hwxyz0) in\n      have hn0 : 0 < n.nat_abs, from int.nat_abs_pos_of_ne_zero (λ hn0,\n        have hwxyz0 : (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs^2 + z.nat_abs^2 : ℕ) = 0,\n          by { rw [← int.coe_nat_eq_zero, ← hnat_abs], rwa [hn0, mul_zero] at hn },\n        have habcd0 : (m : ℤ) ∣ a ∧ (m : ℤ) ∣ b ∧ (m : ℤ) ∣ c ∧ (m : ℤ) ∣ d,\n          by simpa only [add_eq_zero_iff, int.nat_abs_eq_zero, zmod.val_min_abs_eq_zero, and.assoc,\n                         pow_eq_zero_iff two_pos, char_p.int_cast_eq_zero_iff _ m _] using hwxyz0,\n        let ⟨ma, hma⟩ := habcd0.1,     ⟨mb, hmb⟩ := habcd0.2.1,\n            ⟨mc, hmc⟩ := habcd0.2.2.1, ⟨md, hmd⟩ := habcd0.2.2.2 in\n        have hmdvdp : m ∣ p,\n          from int.coe_nat_dvd.1 ⟨ma^2 + mb^2 + mc^2 + md^2,\n            (mul_right_inj' (show (m : ℤ) ≠ 0, from int.coe_nat_ne_zero.2 hm0.1)).1 $\n              by { rw [← habcd, hma, hmb, hmc, hmd], ring }⟩,\n        (hp.1.eq_one_or_self_of_dvd _ hmdvdp).elim hm1\n        (λ hmeqp, by simpa [lt_irrefl, hmeqp] using hmp)),\n      have hawbxcydz : ((m : ℕ) : ℤ) ∣ a * w + b * x + c * y + d * z,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $\n          by { rw [← hwxyz0], simp_rw [sq], push_cast },\n      have haxbwczdy : ((m : ℕ) : ℤ) ∣ a * x - b * w - c * z + d * y,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { push_cast, ring },\n      have haybzcwdx : ((m : ℕ) : ℤ) ∣ a * y + b * z - c * w - d * x,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { push_cast, ring },\n      have hazbycxdw : ((m : ℕ) : ℤ) ∣ a * z - b * y + c * x - d * w,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { push_cast, ring },\n      let ⟨s, hs⟩ := hawbxcydz, ⟨t, ht⟩ := haxbwczdy, ⟨u, hu⟩ := haybzcwdx, ⟨v, hv⟩ := hazbycxdw in\n      have hn_nonneg : 0 ≤ n,\n        from nonneg_of_mul_nonneg_right\n          (by { erw [← hn], repeat {try {refine add_nonneg _ _}, try {exact sq_nonneg _}} })\n          (int.coe_nat_pos.2 $ ne_zero.pos m),\n      have hnm : n.nat_abs < m,\n        from int.coe_nat_lt.1 (lt_of_mul_lt_mul_left\n          (by { rw [int.nat_abs_of_nonneg hn_nonneg, ← hn, ← sq], exact hwxyzlt })\n          (int.coe_nat_nonneg m)),\n      have hstuv : s^2 + t^2 + u^2 + v^2 = n.nat_abs * p,\n        from (mul_right_inj' (show (m^2 : ℤ) ≠ 0, from pow_ne_zero 2\n            (int.coe_nat_ne_zero.2 hm0.1))).1 $\n          calc (m : ℤ)^2 * (s^2 + t^2 + u^2 + v^2) = ((m : ℕ) * s)^2 + ((m : ℕ) * t)^2 +\n              ((m : ℕ) * u)^2 + ((m : ℕ) * v)^2 :\n            by { simp [mul_pow], ring }\n          ... = (w^2 + x^2 + y^2 + z^2) * (a^2 + b^2 + c^2 + d^2) :\n            by { simp only [hs.symm, ht.symm, hu.symm, hv.symm], ring }\n          ... = _ : by { rw [hn, habcd, int.nat_abs_of_nonneg hn_nonneg], dsimp [m], ring },\n      false.elim $ nat.find_min hm hnm ⟨lt_trans hnm hmp, hn0, s, t, u, v, hstuv⟩)\n\n/-- **Four squares theorem** -/\nlemma sum_four_squares : ∀ n : ℕ, ∃ a b c d : ℕ, a^2 + b^2 + c^2 + d^2 = n\n| 0 := ⟨0, 0, 0, 0, rfl⟩\n| 1 := ⟨1, 0, 0, 0, rfl⟩\n| n@(k+2) :=\nhave hm : fact (min_fac (k+2)).prime := ⟨min_fac_prime dec_trivial⟩,\nhave n / min_fac n < n := factors_lemma,\nlet ⟨a, b, c, d, h₁⟩ := show ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = min_fac n,\n  by exactI prime_sum_four_squares (min_fac (k+2)) in\nlet ⟨w, x, y, z, h₂⟩ := sum_four_squares (n / min_fac n) in\n⟨(a * w - b * x - c * y - d * z).nat_abs,\n (a * x + b * w + c * z - d * y).nat_abs,\n (a * y - b * z + c * w + d * x).nat_abs,\n (a * z + b * y - c * x + d * w).nat_abs,\n  begin\n    rw [← int.coe_nat_inj', ← nat.mul_div_cancel' (min_fac_dvd (k+2)), int.coe_nat_mul, ← h₁, ← h₂],\n    simp [sum_four_sq_mul_sum_four_sq],\n  end⟩\n\nend nat\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/number_theory/sum_four_squares.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.47744199622862943}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module algebraic_geometry.AffineScheme\n! leanprover-community/mathlib commit d39590fc8728fbf6743249802486f8c91ffe07bc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.AlgebraicGeometry.GammaSpecAdjunction\nimport Mathbin.AlgebraicGeometry.OpenImmersion\nimport Mathbin.CategoryTheory.Limits.Opposites\nimport Mathbin.RingTheory.Localization.InvSubmonoid\n\n/-!\n# Affine schemes\n\nWe define the category of `AffineScheme`s as the essential image of `Spec`.\nWe also define predicates about affine schemes and affine open sets.\n\n## Main definitions\n\n* `algebraic_geometry.AffineScheme`: The category of affine schemes.\n* `algebraic_geometry.is_affine`: A scheme is affine if the canonical map `X ⟶ Spec Γ(X)` is an\n  isomorphism.\n* `algebraic_geometry.Scheme.iso_Spec`: The canonical isomorphism `X ≅ Spec Γ(X)` for an affine\n  scheme.\n* `algebraic_geometry.AffineScheme.equiv_CommRing`: The equivalence of categories\n  `AffineScheme ≌ CommRingᵒᵖ` given by `AffineScheme.Spec : CommRingᵒᵖ ⥤ AffineScheme` and\n  `AffineScheme.Γ : AffineSchemeᵒᵖ ⥤ CommRing`.\n* `algebraic_geometry.is_affine_open`: An open subset of a scheme is affine if the open subscheme is\n  affine.\n* `algebraic_geometry.is_affine_open.from_Spec`: The immersion `Spec 𝒪ₓ(U) ⟶ X` for an affine `U`.\n\n-/\n\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace\n\nuniverse u\n\nnamespace AlgebraicGeometry\n\nopen Spec (structureSheaf)\n\n/-- The category of affine schemes -/\n@[nolint has_nonempty_instance]\ndef AffineScheme :=\n  Scheme.spec.EssImageSubcategory deriving Category\n#align algebraic_geometry.AffineScheme AlgebraicGeometry.AffineScheme\n\n/-- A Scheme is affine if the canonical map `X ⟶ Spec Γ(X)` is an isomorphism. -/\nclass IsAffine (X : Scheme) : Prop where\n  affine : IsIso (ΓSpec.adjunction.Unit.app X)\n#align algebraic_geometry.is_affine AlgebraicGeometry.IsAffine\n\nattribute [instance] is_affine.affine\n\n/-- The canonical isomorphism `X ≅ Spec Γ(X)` for an affine scheme. -/\ndef Scheme.isoSpec (X : Scheme) [IsAffine X] : X ≅ Scheme.spec.obj (op <| Scheme.Γ.obj <| op X) :=\n  asIso (ΓSpec.adjunction.Unit.app X)\n#align algebraic_geometry.Scheme.iso_Spec AlgebraicGeometry.Scheme.isoSpec\n\n/-- Construct an affine scheme from a scheme and the information that it is affine.\nAlso see `AffineScheme.of` for a typclass version. -/\n@[simps]\ndef AffineScheme.mk (X : Scheme) (h : IsAffine X) : AffineScheme :=\n  ⟨X, @mem_essImage_of_unit_isIso _ _ _ _ h.1⟩\n#align algebraic_geometry.AffineScheme.mk AlgebraicGeometry.AffineScheme.mk\n\n/-- Construct an affine scheme from a scheme. Also see `AffineScheme.mk` for a non-typeclass\nversion. -/\ndef AffineScheme.of (X : Scheme) [h : IsAffine X] : AffineScheme :=\n  AffineScheme.mk X h\n#align algebraic_geometry.AffineScheme.of AlgebraicGeometry.AffineScheme.of\n\n/-- Type check a morphism of schemes as a morphism in `AffineScheme`. -/\ndef AffineScheme.ofHom {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) :\n    AffineScheme.of X ⟶ AffineScheme.of Y :=\n  f\n#align algebraic_geometry.AffineScheme.of_hom AlgebraicGeometry.AffineScheme.ofHom\n\ntheorem mem_spec_essImage (X : Scheme) : X ∈ Scheme.spec.essImage ↔ IsAffine X :=\n  ⟨fun h => ⟨Functor.essImage.unit_isIso h⟩, fun h => @mem_essImage_of_unit_isIso _ _ _ X h.1⟩\n#align algebraic_geometry.mem_Spec_ess_image AlgebraicGeometry.mem_spec_essImage\n\ninstance isAffineAffineScheme (X : AffineScheme.{u}) : IsAffine X.obj :=\n  ⟨Functor.essImage.unit_isIso X.property⟩\n#align algebraic_geometry.is_affine_AffineScheme AlgebraicGeometry.isAffineAffineScheme\n\ninstance specIsAffine (R : CommRingCatᵒᵖ) : IsAffine (Scheme.spec.obj R) :=\n  AlgebraicGeometry.isAffineAffineScheme ⟨_, Scheme.spec.obj_mem_essImage R⟩\n#align algebraic_geometry.Spec_is_affine AlgebraicGeometry.specIsAffine\n\ntheorem isAffineOfIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] [h : IsAffine Y] : IsAffine X :=\n  by\n  rw [← mem_Spec_ess_image] at h⊢\n  exact functor.ess_image.of_iso (as_iso f).symm h\n#align algebraic_geometry.is_affine_of_iso AlgebraicGeometry.isAffineOfIso\n\nnamespace AffineScheme\n\n/-- The `Spec` functor into the category of affine schemes. -/\ndef spec : CommRingCatᵒᵖ ⥤ AffineScheme :=\n  Scheme.spec.toEssImage deriving Full, Faithful, EssSurj\n#align algebraic_geometry.AffineScheme.Spec AlgebraicGeometry.AffineScheme.spec\n\n/-- The forgetful functor `AffineScheme ⥤ Scheme`. -/\n@[simps]\ndef forgetToScheme : AffineScheme ⥤ Scheme :=\n  Scheme.spec.essImageInclusion deriving Full, Faithful\n#align algebraic_geometry.AffineScheme.forget_to_Scheme AlgebraicGeometry.AffineScheme.forgetToScheme\n\n/-- The global section functor of an affine scheme. -/\ndef Γ : AffineSchemeᵒᵖ ⥤ CommRingCat :=\n  forgetToScheme.op ⋙ Scheme.Γ\n#align algebraic_geometry.AffineScheme.Γ AlgebraicGeometry.AffineScheme.Γ\n\n/-- The category of affine schemes is equivalent to the category of commutative rings. -/\ndef equivCommRing : AffineScheme ≌ CommRingCatᵒᵖ :=\n  equivEssImageOfReflective.symm\n#align algebraic_geometry.AffineScheme.equiv_CommRing AlgebraicGeometry.AffineScheme.equivCommRing\n\ninstance ΓIsEquiv : IsEquivalence Γ.{u} :=\n  haveI : is_equivalence Γ.{u}.rightOp.op := is_equivalence.of_equivalence equiv_CommRing.op\n  (functor.is_equivalence_trans Γ.{u}.rightOp.op (op_op_equivalence _).Functor : _)\n#align algebraic_geometry.AffineScheme.Γ_is_equiv AlgebraicGeometry.AffineScheme.ΓIsEquiv\n\ninstance : HasColimits AffineScheme.{u} :=\n  haveI := Adjunction.has_limits_of_equivalence.{u} Γ.{u}\n  Adjunction.has_colimits_of_equivalence.{u} (op_op_equivalence AffineScheme.{u}).inverse\n\ninstance : HasLimits AffineScheme.{u} :=\n  by\n  haveI := adjunction.has_colimits_of_equivalence Γ.{u}\n  haveI : has_limits AffineScheme.{u}ᵒᵖᵒᵖ := limits.has_limits_op_of_has_colimits\n  exact adjunction.has_limits_of_equivalence (op_op_equivalence AffineScheme.{u}).inverse\n\nnoncomputable instance : PreservesLimits Γ.{u}.rightOp :=\n  @Adjunction.isEquivalencePreservesLimits _ _ Γ.rightOp (IsEquivalence.ofEquivalence equivCommRing)\n\nnoncomputable instance : PreservesLimits forgetToScheme :=\n  by\n  apply (config := { instances := false })\n    @preserves_limits_of_nat_iso _ _\n      (iso_whisker_right equiv_CommRing.unit_iso forget_to_Scheme).symm\n  change preserves_limits (equiv_CommRing.functor ⋙ Scheme.Spec)\n  infer_instance\n\nend AffineScheme\n\n/-- An open subset of a scheme is affine if the open subscheme is affine. -/\ndef IsAffineOpen {X : Scheme} (U : Opens X.carrier) : Prop :=\n  IsAffine (X.restrict U.OpenEmbedding)\n#align algebraic_geometry.is_affine_open AlgebraicGeometry.IsAffineOpen\n\n/-- The set of affine opens as a subset of `opens X.carrier`. -/\ndef Scheme.affineOpens (X : Scheme) : Set (Opens X.carrier) :=\n  { U : Opens X.carrier | IsAffineOpen U }\n#align algebraic_geometry.Scheme.affine_opens AlgebraicGeometry.Scheme.affineOpens\n\ntheorem range_isAffineOpen_of_open_immersion {X Y : Scheme} [IsAffine X] (f : X ⟶ Y)\n    [H : IsOpenImmersion f] : IsAffineOpen f.opensRange :=\n  by\n  refine' is_affine_of_iso (is_open_immersion.iso_of_range_eq f (Y.of_restrict _) _).inv\n  exact subtype.range_coe.symm\n  infer_instance\n#align algebraic_geometry.range_is_affine_open_of_open_immersion AlgebraicGeometry.range_isAffineOpen_of_open_immersion\n\ntheorem top_isAffineOpen (X : Scheme) [IsAffine X] : IsAffineOpen (⊤ : Opens X.carrier) :=\n  by\n  convert range_is_affine_open_of_open_immersion (𝟙 X)\n  ext1\n  exact set.range_id.symm\n#align algebraic_geometry.top_is_affine_open AlgebraicGeometry.top_isAffineOpen\n\ninstance Scheme.affineCoverIsAffine (X : Scheme) (i : X.affineCover.J) :\n    IsAffine (X.affineCover.obj i) :=\n  AlgebraicGeometry.specIsAffine _\n#align algebraic_geometry.Scheme.affine_cover_is_affine AlgebraicGeometry.Scheme.affineCoverIsAffine\n\ninstance Scheme.affineBasisCoverIsAffine (X : Scheme) (i : X.affineBasisCover.J) :\n    IsAffine (X.affineBasisCover.obj i) :=\n  AlgebraicGeometry.specIsAffine _\n#align algebraic_geometry.Scheme.affine_basis_cover_is_affine AlgebraicGeometry.Scheme.affineBasisCoverIsAffine\n\ntheorem isBasis_affine_open (X : Scheme) : Opens.IsBasis X.affineOpens :=\n  by\n  rw [opens.is_basis_iff_nbhd]\n  rintro U x (hU : x ∈ (U : Set X.carrier))\n  obtain ⟨S, hS, hxS, hSU⟩ := X.affine_basis_cover_is_basis.exists_subset_of_mem_open hU U.is_open\n  refine' ⟨⟨S, X.affine_basis_cover_is_basis.is_open hS⟩, _, hxS, hSU⟩\n  rcases hS with ⟨i, rfl⟩\n  exact range_is_affine_open_of_open_immersion _\n#align algebraic_geometry.is_basis_affine_open AlgebraicGeometry.isBasis_affine_open\n\n/-- The open immersion `Spec 𝒪ₓ(U) ⟶ X` for an affine `U`. -/\ndef IsAffineOpen.fromSpec {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U) :\n    Scheme.spec.obj (op <| X.Presheaf.obj <| op U) ⟶ X :=\n  by\n  haveI : is_affine (X.restrict U.open_embedding) := hU\n  have : U.open_embedding.is_open_map.functor.obj ⊤ = U :=\n    by\n    ext1\n    exact set.image_univ.trans Subtype.range_coe\n  exact\n    Scheme.Spec.map (X.presheaf.map (eq_to_hom this.symm).op).op ≫\n      (X.restrict U.open_embedding).isoSpec.inv ≫ X.of_restrict _\n#align algebraic_geometry.is_affine_open.from_Spec AlgebraicGeometry.IsAffineOpen.fromSpec\n\ninstance IsAffineOpen.isOpenImmersion_fromSpec {X : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) : IsOpenImmersion hU.fromSpec :=\n  by\n  delta is_affine_open.from_Spec\n  infer_instance\n#align algebraic_geometry.is_affine_open.is_open_immersion_from_Spec AlgebraicGeometry.IsAffineOpen.isOpenImmersion_fromSpec\n\ntheorem IsAffineOpen.fromSpec_range {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U) :\n    Set.range hU.fromSpec.1.base = (U : Set X.carrier) :=\n  by\n  delta is_affine_open.from_Spec\n  erw [← category.assoc, Scheme.comp_val_base]\n  rw [coe_comp, Set.range_comp, set.range_iff_surjective.mpr, Set.image_univ]\n  exact Subtype.range_coe\n  rw [← TopCat.epi_iff_surjective]\n  infer_instance\n#align algebraic_geometry.is_affine_open.from_Spec_range AlgebraicGeometry.IsAffineOpen.fromSpec_range\n\ntheorem IsAffineOpen.fromSpec_image_top {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U) :\n    hU.isOpenImmersion_fromSpec.base_open.IsOpenMap.Functor.obj ⊤ = U :=\n  by\n  ext1\n  exact set.image_univ.trans hU.from_Spec_range\n#align algebraic_geometry.is_affine_open.from_Spec_image_top AlgebraicGeometry.IsAffineOpen.fromSpec_image_top\n\ntheorem IsAffineOpen.isCompact {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U) :\n    IsCompact (U : Set X.carrier) :=\n  by\n  convert@IsCompact.image _ _ _ _ Set.univ hU.from_Spec.1.base PrimeSpectrum.compactSpace.1\n      (by continuity)\n  convert hU.from_Spec_range.symm\n  exact Set.image_univ\n#align algebraic_geometry.is_affine_open.is_compact AlgebraicGeometry.IsAffineOpen.isCompact\n\ntheorem IsAffineOpen.image_isOpenImmersion {X Y : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) (f : X ⟶ Y) [H : IsOpenImmersion f] :\n    IsAffineOpen (f.opensFunctor.obj U) :=\n  by\n  haveI : is_affine _ := hU\n  convert range_is_affine_open_of_open_immersion (X.of_restrict U.open_embedding ≫ f)\n  ext1\n  exact Set.image_eq_range _ _\n#align algebraic_geometry.is_affine_open.image_is_open_immersion AlgebraicGeometry.IsAffineOpen.image_isOpenImmersion\n\ntheorem isAffineOpen_iff_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]\n    (U : Opens X.carrier) : IsAffineOpen (H.openFunctor.obj U) ↔ IsAffineOpen U :=\n  by\n  refine' ⟨fun hU => @is_affine_of_iso _ _ hU, fun hU => hU.image_isOpenImmersion f⟩\n  refine' (is_open_immersion.iso_of_range_eq (X.of_restrict _ ≫ f) (Y.of_restrict _) _).Hom\n  · rw [Scheme.comp_val_base, coe_comp, Set.range_comp]\n    dsimp [opens.inclusion]\n    rw [Subtype.range_coe, Subtype.range_coe]\n    rfl\n  · infer_instance\n#align algebraic_geometry.is_affine_open_iff_of_is_open_immersion AlgebraicGeometry.isAffineOpen_iff_of_isOpenImmersion\n\ninstance Scheme.quasi_compact_of_affine (X : Scheme) [IsAffine X] : CompactSpace X.carrier :=\n  ⟨(top_isAffineOpen X).IsCompact⟩\n#align algebraic_geometry.Scheme.quasi_compact_of_affine AlgebraicGeometry.Scheme.quasi_compact_of_affine\n\ntheorem IsAffineOpen.fromSpec_base_preimage {X : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) : (Opens.map hU.fromSpec.val.base).obj U = ⊤ :=\n  by\n  ext1\n  change hU.from_Spec.1.base ⁻¹' (U : Set X.carrier) = Set.univ\n  rw [← hU.from_Spec_range, ← Set.image_univ]\n  exact Set.preimage_image_eq _ PresheafedSpace.is_open_immersion.base_open.inj\n#align algebraic_geometry.is_affine_open.from_Spec_base_preimage AlgebraicGeometry.IsAffineOpen.fromSpec_base_preimage\n\ntheorem Scheme.specMap_presheaf_map_eqToHom {X : Scheme} {U V : Opens X.carrier} (h : U = V) (W) :\n    (Scheme.spec.map (X.Presheaf.map (eqToHom h).op).op).val.c.app W =\n      eqToHom\n        (by\n          cases h\n          induction W using Opposite.rec\n          dsimp\n          simp\n          rfl) :=\n  by\n  have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by\n    rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]\n  cases h\n  refine' (Scheme.congr_app this _).trans _\n  erw [category.id_comp]\n  simpa [eq_to_hom_map]\n#align algebraic_geometry.Scheme.Spec_map_presheaf_map_eq_to_hom AlgebraicGeometry.Scheme.specMap_presheaf_map_eqToHom\n\ntheorem IsAffineOpen.specΓIdentity_hom_app_fromSpec {X : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) :\n    specΓIdentity.Hom.app (X.Presheaf.obj <| op U) ≫ hU.fromSpec.1.c.app (op U) =\n      (Scheme.spec.obj _).Presheaf.map (eqToHom hU.fromSpec_base_preimage).op :=\n  by\n  haveI : is_affine _ := hU\n  have e₁ := Spec_Γ_identity.hom.naturality (X.presheaf.map (eq_to_hom U.open_embedding_obj_top).op)\n  rw [← is_iso.comp_inv_eq] at e₁\n  have e₂ := Γ_Spec.adjunction_unit_app_app_top (X.restrict U.open_embedding)\n  erw [← e₂] at e₁\n  simp only [functor.id_map, Quiver.Hom.unop_op, functor.comp_map, ← functor.map_inv, ← op_inv,\n    LocallyRingedSpace.Γ_map, category.assoc, functor.right_op_map, inv_eq_to_hom] at e₁\n  delta is_affine_open.from_Spec Scheme.iso_Spec\n  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app, ← e₁]\n  simp_rw [category.assoc]\n  erw [← X.presheaf.map_comp_assoc]\n  rw [← op_comp]\n  have e₃ :\n    U.open_embedding.is_open_map.adjunction.counit.app U ≫ eq_to_hom U.open_embedding_obj_top.symm =\n      U.open_embedding.is_open_map.functor.map (eq_to_hom U.inclusion_map_eq_top) :=\n    Subsingleton.elim _ _\n  have e₄ : X.presheaf.map _ ≫ _ = _ :=\n    (as_iso (Γ_Spec.adjunction.unit.app (X.restrict U.open_embedding))).inv.1.c.naturality_assoc\n      (eq_to_hom U.inclusion_map_eq_top).op _\n  erw [e₃, e₄, ← Scheme.comp_val_c_app_assoc, iso.inv_hom_id]\n  simp only [eq_to_hom_map, eq_to_hom_op, Scheme.Spec_map_presheaf_map_eq_to_hom]\n  erw [Scheme.Spec_map_presheaf_map_eq_to_hom, category.id_comp]\n  simpa only [eq_to_hom_trans]\n#align algebraic_geometry.is_affine_open.Spec_Γ_identity_hom_app_from_Spec AlgebraicGeometry.IsAffineOpen.specΓIdentity_hom_app_fromSpec\n\n@[elementwise]\ntheorem IsAffineOpen.fromSpec_app_eq {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U) :\n    hU.fromSpec.1.c.app (op U) =\n      specΓIdentity.inv.app (X.Presheaf.obj <| op U) ≫\n        (Scheme.spec.obj _).Presheaf.map (eqToHom hU.fromSpec_base_preimage).op :=\n  by rw [← hU.Spec_Γ_identity_hom_app_from_Spec, iso.inv_hom_id_app_assoc]\n#align algebraic_geometry.is_affine_open.from_Spec_app_eq AlgebraicGeometry.IsAffineOpen.fromSpec_app_eq\n\ntheorem IsAffineOpen.basicOpen_is_affine {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (f : X.Presheaf.obj (op U)) : IsAffineOpen (X.basicOpen f) :=\n  by\n  convert range_is_affine_open_of_open_immersion\n      (Scheme.Spec.map\n          (CommRingCat.ofHom (algebraMap (X.presheaf.obj (op U)) (Localization.Away f))).op ≫\n        hU.from_Spec)\n  ext1\n  have :\n    hU.from_Spec.val.base '' (hU.from_Spec.val.base ⁻¹' (X.basic_open f : Set X.carrier)) =\n      (X.basic_open f : Set X.carrier) :=\n    by\n    rw [Set.image_preimage_eq_inter_range, Set.inter_eq_left_iff_subset, hU.from_Spec_range]\n    exact Scheme.basic_open_le _ _\n  rw [Scheme.hom.opens_range_coe, Scheme.comp_val_base, ← this, coe_comp, Set.range_comp]\n  congr 1\n  refine' (congr_arg coe <| Scheme.preimage_basic_open hU.from_Spec f).trans _\n  refine' Eq.trans _ (PrimeSpectrum.localization_away_comap_range (Localization.Away f) f).symm\n  congr 1\n  have : (opens.map hU.from_Spec.val.base).obj U = ⊤ :=\n    by\n    ext1\n    change hU.from_Spec.1.base ⁻¹' (U : Set X.carrier) = Set.univ\n    rw [← hU.from_Spec_range, ← Set.image_univ]\n    exact Set.preimage_image_eq _ PresheafedSpace.is_open_immersion.base_open.inj\n  refine' Eq.trans _ (basic_open_eq_of_affine f)\n  have lm : ∀ s, (opens.map hU.from_Spec.val.base).obj U ⊓ s = s := fun s => this.symm ▸ top_inf_eq\n  refine' Eq.trans _ (lm _)\n  refine'\n    Eq.trans _\n      ((Scheme.Spec.obj <| op <| X.presheaf.obj <| op U).basicOpen_res _ (eq_to_hom this).op)\n  rw [← comp_apply]\n  congr 2\n  rw [iso.eq_inv_comp]\n  erw [hU.Spec_Γ_identity_hom_app_from_Spec]\n#align algebraic_geometry.is_affine_open.basic_open_is_affine AlgebraicGeometry.IsAffineOpen.basicOpen_is_affine\n\ntheorem IsAffineOpen.map_restrict_basicOpen {X : Scheme} (r : X.Presheaf.obj (op ⊤))\n    {U : Opens X.carrier} (hU : IsAffineOpen U) :\n    IsAffineOpen ((Opens.map (X.of_restrict (X.basicOpen r).OpenEmbedding).1.base).obj U) :=\n  by\n  apply\n    (is_affine_open_iff_of_is_open_immersion (X.of_restrict (X.basic_open r).OpenEmbedding) _).mp\n  delta PresheafedSpace.is_open_immersion.open_functor\n  dsimp\n  erw [opens.functor_obj_map_obj, opens.open_embedding_obj_top, inf_comm, ←\n    Scheme.basic_open_res _ _ (hom_of_le le_top).op]\n  exact hU.basic_open_is_affine _\n#align algebraic_geometry.is_affine_open.map_restrict_basic_open AlgebraicGeometry.IsAffineOpen.map_restrict_basicOpen\n\ntheorem Scheme.map_prime_spectrum_basicOpen_of_affine (X : Scheme) [IsAffine X]\n    (f : Scheme.Γ.obj (op X)) :\n    (Opens.map X.isoSpec.Hom.1.base).obj (PrimeSpectrum.basicOpen f) = X.basicOpen f :=\n  by\n  rw [← basic_open_eq_of_affine]\n  trans\n    (opens.map X.iso_Spec.hom.1.base).obj\n      ((Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen\n        ((inv (X.iso_Spec.hom.1.c.app (op ((opens.map (inv X.iso_Spec.hom).val.base).obj ⊤))))\n          ((X.presheaf.map (eq_to_hom _)) f)))\n  congr\n  · rw [← is_iso.inv_eq_inv, is_iso.inv_inv, is_iso.iso.inv_inv, nat_iso.app_hom]\n    erw [← Γ_Spec.adjunction_unit_app_app_top]\n    rfl\n  · rw [eq_to_hom_map]\n    rfl\n  · dsimp\n    congr\n  · refine' (Scheme.preimage_basic_open _ _).trans _\n    rw [is_iso.inv_hom_id_apply, Scheme.basic_open_res_eq]\n#align algebraic_geometry.Scheme.map_prime_spectrum_basic_open_of_affine AlgebraicGeometry.Scheme.map_prime_spectrum_basicOpen_of_affine\n\ntheorem isBasis_basicOpen (X : Scheme) [IsAffine X] :\n    Opens.IsBasis (Set.range (X.basicOpen : X.Presheaf.obj (op ⊤) → Opens X.carrier)) :=\n  by\n  delta opens.is_basis\n  convert prime_spectrum.is_basis_basic_opens.inducing\n      (TopCat.homeoOfIso (Scheme.forget_to_Top.map_iso X.iso_Spec)).Inducing using\n    1\n  ext\n  simp only [Set.mem_image, exists_exists_eq_and]\n  constructor\n  · rintro ⟨_, ⟨x, rfl⟩, rfl⟩\n    refine' ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, _⟩\n    exact congr_arg opens.carrier (X.map_prime_spectrum_basic_open_of_affine x)\n  · rintro ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, rfl⟩\n    refine' ⟨_, ⟨x, rfl⟩, _⟩\n    exact congr_arg opens.carrier (X.map_prime_spectrum_basic_open_of_affine x).symm\n#align algebraic_geometry.is_basis_basic_open AlgebraicGeometry.isBasis_basicOpen\n\ntheorem IsAffineOpen.exists_basicOpen_le {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    {V : Opens X.carrier} (x : V) (h : ↑x ∈ U) :\n    ∃ f : X.Presheaf.obj (op U), X.basicOpen f ≤ V ∧ ↑x ∈ X.basicOpen f :=\n  by\n  haveI : is_affine _ := hU\n  obtain ⟨_, ⟨_, ⟨r, rfl⟩, rfl⟩, h₁, h₂⟩ :=\n    (is_basis_basic_open (X.restrict U.open_embedding)).exists_subset_of_mem_open _\n      ((opens.map U.inclusion).obj V).IsOpen\n  swap\n  exact ⟨x, h⟩\n  have :\n    U.open_embedding.is_open_map.functor.obj ((X.restrict U.open_embedding).basicOpen r) =\n      X.basic_open (X.presheaf.map (eq_to_hom U.open_embedding_obj_top.symm).op r) :=\n    by\n    refine' (Scheme.image_basic_open (X.of_restrict U.open_embedding) r).trans _\n    erw [← Scheme.basic_open_res_eq _ _ (eq_to_hom U.open_embedding_obj_top).op]\n    rw [← comp_apply, ← CategoryTheory.Functor.map_comp, ← op_comp, eq_to_hom_trans, eq_to_hom_refl,\n      op_id, CategoryTheory.Functor.map_id, Scheme.hom.inv_app]\n    erw [PresheafedSpace.is_open_immersion.of_restrict_inv_app]\n    congr\n  use X.presheaf.map (eq_to_hom U.open_embedding_obj_top.symm).op r\n  rw [← this]\n  exact ⟨set.image_subset_iff.mpr h₂, Set.mem_image_of_mem _ h₁⟩\n  exact x.prop\n#align algebraic_geometry.is_affine_open.exists_basic_open_le AlgebraicGeometry.IsAffineOpen.exists_basicOpen_le\n\ninstance {X : Scheme} {U : Opens X.carrier} (f : X.Presheaf.obj (op U)) :\n    Algebra (X.Presheaf.obj (op U)) (X.Presheaf.obj (op <| X.basicOpen f)) :=\n  (X.Presheaf.map (homOfLE <| RingedSpace.basicOpen_le _ f : _ ⟶ U).op).toAlgebra\n\ntheorem IsAffineOpen.opens_map_fromSpec_basicOpen {X : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) (f : X.Presheaf.obj (op U)) :\n    (Opens.map hU.fromSpec.val.base).obj (X.basicOpen f) =\n      RingedSpace.basicOpen _ (specΓIdentity.inv.app (X.Presheaf.obj <| op U) f) :=\n  by\n  erw [LocallyRingedSpace.preimage_basic_open]\n  refine'\n    Eq.trans _\n      (RingedSpace.basic_open_res_eq\n        (Scheme.Spec.obj <| op <| X.presheaf.obj (op U)).toLocallyRingedSpace.toRingedSpace\n        (eq_to_hom hU.from_Spec_base_preimage).op _)\n  congr\n  rw [← comp_apply]\n  congr\n  erw [← hU.Spec_Γ_identity_hom_app_from_Spec]\n  rw [iso.inv_hom_id_app_assoc]\n#align algebraic_geometry.is_affine_open.opens_map_from_Spec_basic_open AlgebraicGeometry.IsAffineOpen.opens_map_fromSpec_basicOpen\n\n/-- The canonical map `Γ(𝒪ₓ, D(f)) ⟶ Γ(Spec 𝒪ₓ(U), D(Spec_Γ_identity.inv f))`\nThis is an isomorphism, as witnessed by an `is_iso` instance. -/\ndef basicOpenSectionsToAffine {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (f : X.Presheaf.obj (op U)) :\n    X.Presheaf.obj (op <| X.basicOpen f) ⟶\n      (Scheme.spec.obj <| op <| X.Presheaf.obj (op U)).Presheaf.obj\n        (op <| Scheme.basicOpen _ <| specΓIdentity.inv.app (X.Presheaf.obj (op U)) f) :=\n  hU.fromSpec.1.c.app (op <| X.basicOpen f) ≫\n    (Scheme.spec.obj <| op <| X.Presheaf.obj (op U)).Presheaf.map\n      (eqToHom <| (hU.opens_map_fromSpec_basicOpen f).symm).op\n#align algebraic_geometry.basic_open_sections_to_affine AlgebraicGeometry.basicOpenSectionsToAffine\n\ninstance {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U) (f : X.Presheaf.obj (op U)) :\n    IsIso (basicOpenSectionsToAffine hU f) :=\n  by\n  delta basic_open_sections_to_affine\n  apply (config := { instances := false }) is_iso.comp_is_iso\n  · apply PresheafedSpace.is_open_immersion.is_iso_of_subset\n    rw [hU.from_Spec_range]\n    exact RingedSpace.basic_open_le _ _\n  infer_instance\n\ntheorem is_localization_basicOpen {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (f : X.Presheaf.obj (op U)) : IsLocalization.Away f (X.Presheaf.obj (op <| X.basicOpen f)) :=\n  by\n  apply\n    (IsLocalization.isLocalization_iff_of_ringEquiv (Submonoid.powers f)\n        (as_iso <|\n            basic_open_sections_to_affine hU f ≫\n              (Scheme.Spec.obj _).Presheaf.map\n                (eq_to_hom (basic_open_eq_of_affine _).symm).op).commRingIsoToRingEquiv).mpr\n  convert structure_sheaf.is_localization.to_basic_open _ f\n  change _ ≫ basic_open_sections_to_affine hU f ≫ _ = _\n  delta basic_open_sections_to_affine\n  erw [RingHom.algebraMap_toAlgebra]\n  simp only [Scheme.comp_val_c_app, category.assoc]\n  erw [hU.from_Spec.val.c.naturality_assoc]\n  rw [hU.from_Spec_app_eq]\n  dsimp\n  simp only [category.assoc, ← functor.map_comp, ← op_comp]\n  apply structure_sheaf.to_open_res\n#align algebraic_geometry.is_localization_basic_open AlgebraicGeometry.is_localization_basicOpen\n\ninstance {X : Scheme} [IsAffine X] (r : X.Presheaf.obj (op ⊤)) :\n    IsLocalization.Away r (X.Presheaf.obj (op <| X.basicOpen r)) :=\n  is_localization_basicOpen (top_isAffineOpen X) r\n\ntheorem is_localization_of_eq_basicOpen {X : Scheme} {U V : Opens X.carrier} (i : V ⟶ U)\n    (hU : IsAffineOpen U) (r : X.Presheaf.obj (op U)) (e : V = X.basicOpen r) :\n    @IsLocalization.Away _ r (X.Presheaf.obj (op V)) _ (X.Presheaf.map i.op).toAlgebra :=\n  by\n  subst e\n  convert is_localization_basic_open hU r using 3\n#align algebraic_geometry.is_localization_of_eq_basic_open AlgebraicGeometry.is_localization_of_eq_basicOpen\n\ninstance ΓRestrictAlgebra {X : Scheme} {Y : TopCat} {f : Y ⟶ X.carrier} (hf : OpenEmbedding f) :\n    Algebra (Scheme.Γ.obj (op X)) (Scheme.Γ.obj (op <| X.restrict hf)) :=\n  (Scheme.Γ.map (X.of_restrict hf).op).toAlgebra\n#align algebraic_geometry.Γ_restrict_algebra AlgebraicGeometry.ΓRestrictAlgebra\n\ninstance Γ_restrict_is_localization (X : Scheme.{u}) [IsAffine X] (r : Scheme.Γ.obj (op X)) :\n    IsLocalization.Away r (Scheme.Γ.obj (op <| X.restrict (X.basicOpen r).OpenEmbedding)) :=\n  is_localization_of_eq_basicOpen _ (top_isAffineOpen X) r (Opens.openEmbedding_obj_top _)\n#align algebraic_geometry.Γ_restrict_is_localization AlgebraicGeometry.Γ_restrict_is_localization\n\ntheorem basicOpen_basicOpen_is_basicOpen {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (f : X.Presheaf.obj (op U)) (g : X.Presheaf.obj (op <| X.basicOpen f)) :\n    ∃ f' : X.Presheaf.obj (op U), X.basicOpen f' = X.basicOpen g :=\n  by\n  haveI := is_localization_basic_open hU f\n  obtain ⟨x, ⟨_, n, rfl⟩, rfl⟩ := IsLocalization.surj' (Submonoid.powers f) g\n  use f * x\n  rw [Algebra.smul_def, Scheme.basic_open_mul, Scheme.basic_open_mul]\n  erw [Scheme.basic_open_res]\n  refine' (inf_eq_left.mpr _).symm\n  convert inf_le_left using 1\n  apply Scheme.basic_open_of_is_unit\n  apply\n    Submonoid.leftInv_le_isUnit _\n      (IsLocalization.toInvSubmonoid (Submonoid.powers f) (X.presheaf.obj (op <| X.basic_open f))\n          _).Prop\n#align algebraic_geometry.basic_open_basic_open_is_basic_open AlgebraicGeometry.basicOpen_basicOpen_is_basicOpen\n\ntheorem exists_basicOpen_le_affine_inter {X : Scheme} {U V : Opens X.carrier} (hU : IsAffineOpen U)\n    (hV : IsAffineOpen V) (x : X.carrier) (hx : x ∈ U ⊓ V) :\n    ∃ (f : X.Presheaf.obj <| op U)(g : X.Presheaf.obj <| op V),\n      X.basicOpen f = X.basicOpen g ∧ x ∈ X.basicOpen f :=\n  by\n  obtain ⟨f, hf₁, hf₂⟩ := hU.exists_basic_open_le ⟨x, hx.2⟩ hx.1\n  obtain ⟨g, hg₁, hg₂⟩ := hV.exists_basic_open_le ⟨x, hf₂⟩ hx.2\n  obtain ⟨f', hf'⟩ :=\n    basic_open_basic_open_is_basic_open hU f (X.presheaf.map (hom_of_le hf₁ : _ ⟶ V).op g)\n  replace hf' := (hf'.trans (RingedSpace.basic_open_res _ _ _)).trans (inf_eq_right.mpr hg₁)\n  exact ⟨f', g, hf', hf'.symm ▸ hg₂⟩\n#align algebraic_geometry.exists_basic_open_le_affine_inter AlgebraicGeometry.exists_basicOpen_le_affine_inter\n\n/-- The prime ideal of `𝒪ₓ(U)` corresponding to a point `x : U`. -/\nnoncomputable def IsAffineOpen.primeIdealOf {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (x : U) : PrimeSpectrum (X.Presheaf.obj <| op U) :=\n  (Scheme.spec.map\n          (X.Presheaf.map\n              (eqToHom <|\n                  show U.OpenEmbedding.IsOpenMap.Functor.obj ⊤ = U from\n                    Opens.ext (Set.image_univ.trans Subtype.range_coe)).op).op).1.base\n    ((@Scheme.isoSpec (X.restrict U.OpenEmbedding) hU).Hom.1.base x)\n#align algebraic_geometry.is_affine_open.prime_ideal_of AlgebraicGeometry.IsAffineOpen.primeIdealOf\n\ntheorem IsAffineOpen.fromSpec_primeIdealOf {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (x : U) : hU.fromSpec.val.base (hU.primeIdealOf x) = x.1 :=\n  by\n  dsimp only [is_affine_open.from_Spec, Subtype.coe_mk]\n  erw [← Scheme.comp_val_base_apply, ← Scheme.comp_val_base_apply]\n  simpa only [← functor.map_comp_assoc, ← functor.map_comp, ← op_comp, eq_to_hom_trans, op_id,\n    eq_to_hom_refl, CategoryTheory.Functor.map_id, category.id_comp, iso.hom_inv_id_assoc]\n#align algebraic_geometry.is_affine_open.from_Spec_prime_ideal_of AlgebraicGeometry.IsAffineOpen.fromSpec_primeIdealOf\n\ntheorem IsAffineOpen.is_localization_stalk_aux {X : Scheme} (U : Opens X.carrier)\n    [IsAffine (X.restrict U.OpenEmbedding)] :\n    (inv (ΓSpec.adjunction.Unit.app (X.restrict U.OpenEmbedding))).1.c.app\n        (op ((Opens.map U.inclusion).obj U)) =\n      X.Presheaf.map\n          (eqToHom <| by rw [opens.inclusion_map_eq_top] :\n              U.OpenEmbedding.IsOpenMap.Functor.obj ⊤ ⟶\n                U.OpenEmbedding.IsOpenMap.Functor.obj ((Opens.map U.inclusion).obj U)).op ≫\n        toSpecΓ (X.Presheaf.obj <| op (U.OpenEmbedding.IsOpenMap.Functor.obj ⊤)) ≫\n          (Scheme.spec.obj <| op <| X.Presheaf.obj <| _).Presheaf.map\n            (eqToHom\n                  (by\n                    rw [opens.inclusion_map_eq_top]\n                    rfl) :\n                unop _ ⟶ ⊤).op :=\n  by\n  have e :\n    (opens.map (inv (Γ_Spec.adjunction.unit.app (X.restrict U.open_embedding))).1.base).obj\n        ((opens.map U.inclusion).obj U) =\n      ⊤ :=\n    by\n    rw [opens.inclusion_map_eq_top]\n    rfl\n  rw [Scheme.inv_val_c_app, is_iso.comp_inv_eq, Scheme.app_eq _ e,\n    Γ_Spec.adjunction_unit_app_app_top]\n  simp only [category.assoc, eq_to_hom_op]\n  erw [← functor.map_comp_assoc]\n  rw [eq_to_hom_trans, eq_to_hom_refl, CategoryTheory.Functor.map_id, category.id_comp]\n  erw [Spec_Γ_identity.inv_hom_id_app_assoc]\n  simp only [eq_to_hom_map, eq_to_hom_trans]\n#align algebraic_geometry.is_affine_open.is_localization_stalk_aux AlgebraicGeometry.IsAffineOpen.is_localization_stalk_aux\n\ntheorem IsAffineOpen.is_localization_stalk {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (x : U) : IsLocalization.AtPrime (X.Presheaf.stalk x) (hU.primeIdealOf x).asIdeal :=\n  by\n  haveI : is_affine _ := hU\n  haveI : Nonempty U := ⟨x⟩\n  rcases x with ⟨x, hx⟩\n  let y := hU.prime_ideal_of ⟨x, hx⟩\n  have : hU.from_Spec.val.base y = x := hU.from_Spec_prime_ideal_of ⟨x, hx⟩\n  change IsLocalization y.as_ideal.prime_compl _\n  clear_value y\n  subst this\n  apply\n    (IsLocalization.isLocalization_iff_of_ringEquiv _\n        (as_iso <| PresheafedSpace.stalk_map hU.from_Spec.1 y).commRingIsoToRingEquiv).mpr\n  convert structure_sheaf.is_localization.to_stalk _ _ using 1\n  delta structure_sheaf.stalk_algebra\n  congr 1\n  rw [RingHom.algebraMap_toAlgebra]\n  refine' (PresheafedSpace.stalk_map_germ hU.from_Spec.1 _ ⟨_, _⟩).trans _\n  delta is_affine_open.from_Spec Scheme.iso_Spec structure_sheaf.to_stalk\n  simp only [Scheme.comp_val_c_app, category.assoc]\n  dsimp only [functor.op, as_iso_inv, unop_op]\n  erw [is_affine_open.is_localization_stalk_aux]\n  simp only [category.assoc]\n  conv_lhs => rw [← category.assoc]\n  erw [← X.presheaf.map_comp, Spec_Γ_naturality_assoc]\n  congr 1\n  simp only [← category.assoc]\n  trans _ ≫ (structure_sheaf (X.presheaf.obj <| op U)).Presheaf.germ ⟨_, _⟩\n  · rfl\n  convert(structure_sheaf (X.presheaf.obj <| op U)).Presheaf.germ_res (hom_of_le le_top)\n      ⟨_, _⟩ using\n    2\n  rw [category.assoc]\n  erw [nat_trans.naturality]\n  rw [← LocallyRingedSpace.Γ_map_op, ← LocallyRingedSpace.Γ.map_comp_assoc, ← op_comp]\n  erw [← Scheme.Spec.map_comp]\n  rw [← op_comp, ← X.presheaf.map_comp]\n  trans\n    LocallyRingedSpace.Γ.map (Quiver.Hom.op <| Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op) ≫ _\n  · congr\n  simp only [CategoryTheory.Functor.map_id, op_id]\n  erw [CategoryTheory.Functor.map_id]\n  rw [category.id_comp]\n  rfl\n#align algebraic_geometry.is_affine_open.is_localization_stalk AlgebraicGeometry.IsAffineOpen.is_localization_stalk\n\n/-- The basic open set of a section `f` on an an affine open as an `X.affine_opens`. -/\n@[simps]\ndef Scheme.affineBasicOpen (X : Scheme) {U : X.affineOpens} (f : X.Presheaf.obj <| op U) :\n    X.affineOpens :=\n  ⟨X.basicOpen f, U.Prop.basicOpen_is_affine f⟩\n#align algebraic_geometry.Scheme.affine_basic_open AlgebraicGeometry.Scheme.affineBasicOpen\n\n@[simp]\ntheorem IsAffineOpen.basicOpen_fromSpec_app {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (f : X.Presheaf.obj (op U)) :\n    @Scheme.basicOpen (Scheme.spec.obj <| op (X.Presheaf.obj <| op U))\n        ((Opens.map hU.fromSpec.1.base).obj U) (hU.fromSpec.1.c.app (op U) f) =\n      PrimeSpectrum.basicOpen f :=\n  by\n  rw [← Scheme.basic_open_res_eq _ _ (eq_to_hom hU.from_Spec_base_preimage.symm).op,\n    basic_open_eq_of_affine', is_affine_open.from_Spec_app_eq]\n  congr\n  rw [← comp_apply, ← comp_apply, category.assoc, ← functor.map_comp_assoc, eq_to_hom_op,\n    eq_to_hom_op, eq_to_hom_trans, eq_to_hom_refl, CategoryTheory.Functor.map_id, category.id_comp,\n    ← iso.app_inv, iso.inv_hom_id]\n  rfl\n#align algebraic_geometry.is_affine_open.basic_open_from_Spec_app AlgebraicGeometry.IsAffineOpen.basicOpen_fromSpec_app\n\ntheorem IsAffineOpen.fromSpec_map_basicOpen {X : Scheme} {U : Opens X.carrier} (hU : IsAffineOpen U)\n    (f : X.Presheaf.obj (op U)) :\n    (Opens.map hU.fromSpec.val.base).obj (X.basicOpen f) = PrimeSpectrum.basicOpen f := by simp\n#align algebraic_geometry.is_affine_open.from_Spec_map_basic_open AlgebraicGeometry.IsAffineOpen.fromSpec_map_basicOpen\n\ntheorem IsAffineOpen.basicOpen_union_eq_self_iff {X : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) (s : Set (X.Presheaf.obj <| op U)) :\n    (⨆ f : s, X.basicOpen (f : X.Presheaf.obj <| op U)) = U ↔ Ideal.span s = ⊤ :=\n  by\n  trans (⋃ i : s, (PrimeSpectrum.basicOpen i.1).1) = Set.univ\n  trans\n    hU.from_Spec.1.base ⁻¹' (⨆ f : s, X.basic_open (f : X.presheaf.obj <| op U)).1 =\n      hU.from_Spec.1.base ⁻¹' U.1\n  · refine' ⟨fun h => by rw [h], _⟩\n    intro h\n    apply_fun Set.image hU.from_Spec.1.base  at h\n    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.from_Spec_range] at\n      h\n    simp only [Set.inter_self, opens.carrier_eq_coe, Set.inter_eq_right_iff_subset] at h\n    ext1\n    refine' Set.Subset.antisymm _ h\n    simp only [Set.unionᵢ_subset_iff, SetCoe.forall, opens.coe_supr]\n    intro x hx\n    exact X.basic_open_le x\n  · simp only [opens.supr_def, Subtype.coe_mk, Set.preimage_unionᵢ, Subtype.val_eq_coe]\n    congr 3\n    · ext1 x\n      exact congr_arg opens.carrier (hU.from_Spec_map_basic_open _)\n    · exact congr_arg opens.carrier hU.from_Spec_base_preimage\n  · simp only [opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]\n    rw [← Set.compl_interᵢ, Set.compl_univ_iff, ← PrimeSpectrum.zeroLocus_unionᵢ, ←\n      PrimeSpectrum.zeroLocus_empty_iff_eq_top, PrimeSpectrum.zeroLocus_span]\n    simp only [Set.unionᵢ_singleton_eq_range, Subtype.range_val_subtype, Set.setOf_mem_eq]\n#align algebraic_geometry.is_affine_open.basic_open_union_eq_self_iff AlgebraicGeometry.IsAffineOpen.basicOpen_union_eq_self_iff\n\ntheorem IsAffineOpen.self_le_basicOpen_union_iff {X : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) (s : Set (X.Presheaf.obj <| op U)) :\n    (U ≤ ⨆ f : s, X.basicOpen (f : X.Presheaf.obj <| op U)) ↔ Ideal.span s = ⊤ :=\n  by\n  rw [← hU.basic_open_union_eq_self_iff, @comm _ Eq]\n  refine' ⟨fun h => le_antisymm h _, le_of_eq⟩\n  simp only [supᵢ_le_iff, SetCoe.forall]\n  intro x hx\n  exact X.basic_open_le x\n#align algebraic_geometry.is_affine_open.self_le_basic_open_union_iff AlgebraicGeometry.IsAffineOpen.self_le_basicOpen_union_iff\n\n/-- Let `P` be a predicate on the affine open sets of `X` satisfying\n1. If `P` holds on `U`, then `P` holds on the basic open set of every section on `U`.\n2. If `P` holds for a family of basic open sets covering `U`, then `P` holds for `U`.\n3. There exists an affine open cover of `X` each satisfying `P`.\n\nThen `P` holds for every affine open of `X`.\n\nThis is also known as the **Affine communication lemma** in [*The rising sea*][RisingSea]. -/\n@[elab_as_elim]\ntheorem of_affine_open_cover {X : Scheme} (V : X.affineOpens) (S : Set X.affineOpens)\n    {P : X.affineOpens → Prop}\n    (hP₁ : ∀ (U : X.affineOpens) (f : X.Presheaf.obj <| op U.1), P U → P (X.affineBasicOpen f))\n    (hP₂ :\n      ∀ (U : X.affineOpens) (s : Finset (X.Presheaf.obj <| op U))\n        (hs : Ideal.span (s : Set (X.Presheaf.obj <| op U)) = ⊤),\n        (∀ f : s, P (X.affineBasicOpen f.1)) → P U)\n    (hS : (⋃ i : S, i : Set X.carrier) = Set.univ) (hS' : ∀ U : S, P U) : P V := by\n  classical\n    have :\n      ∀ x : V, ∃ f : X.presheaf.obj <| op V.1, ↑x ∈ X.basic_open f ∧ P (X.affine_basic_open f) :=\n      by\n      intro x\n      have : ↑x ∈ (Set.univ : Set X.carrier) := trivial\n      rw [← hS] at this\n      obtain ⟨W, hW⟩ := set.mem_Union.mp this\n      obtain ⟨f, g, e, hf⟩ := exists_basic_open_le_affine_inter V.prop W.1.Prop x ⟨x.prop, hW⟩\n      refine' ⟨f, hf, _⟩\n      convert hP₁ _ g (hS' W) using 1\n      ext1\n      exact e\n    choose f hf₁ hf₂ using this\n    suffices Ideal.span (Set.range f) = ⊤\n      by\n      obtain ⟨t, ht₁, ht₂⟩ := (Ideal.span_eq_top_iff_finite _).mp this\n      apply hP₂ V t ht₂\n      rintro ⟨i, hi⟩\n      obtain ⟨x, rfl⟩ := ht₁ hi\n      exact hf₂ x\n    rw [← V.prop.self_le_basic_open_union_iff]\n    intro x hx\n    rw [supᵢ_range', opens.mem_supr]\n    exact ⟨_, hf₁ ⟨x, hx⟩⟩\n#align algebraic_geometry.of_affine_open_cover AlgebraicGeometry.of_affine_open_cover\n\nend AlgebraicGeometry\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/AlgebraicGeometry/AffineScheme.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203136, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4774419918077962}}
{"text": "/- The definition of environments, contexts and names within the continuous-π\n   calculus.\n\n   Names are represented as de Bruijn indicies for obvious reasons. We use the\n   same representation of names as [1], indexing them by the context that they\n   exist in. This ensures that names are always well formed, thus avoiding many\n   common pitfalls that occur when renaming and shuffling terms.\n\n   We have two kinds of names which, while sharing a context type, do have\n   rather different meanings:\n\n    - References to species definitions: The context here acts as a global\n      environment `ω', holding the definitions of species. Species invocations\n      `D(a̅)' index into this table.\n\n      Each reference within this environment is given an arity, holding the\n      arity of its corresponding definition.\n\n      Unlike other contexts, the environment should remain constant across a\n      whole series of processes.\n\n   - Names exist on the main π-calculus level, either introduced by the global\n     affinity network or locall bound by restrictions.\n\n     Each name also has an arity, representing the arity of the corresponding\n     affinity network. Names then index into that affinity network, using finite\n     number bounded by the arity.\n\n  [1]: Proof-relevant π-calculus: a constructive account of concurrency and\n       causality, Roly Perera, James Cheney\n-/\nimport data.fin data.vector data.vector2\n\nnamespace cpi\n\n/-- A context under which terms may be evaluated and names resolved.\n\n    Each level of the context holds the arity of the name defined at that point.\n-/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive context : Type\n| nil : context\n| extend : ℕ → context → context\n\n/-- A reference to a species definition within the global definition context. -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive reference : ℕ → context → Type\n| zero   {ω : context} (n : ℕ) : reference n (context.extend n ω)\n| extend {ω : context} {n m : ℕ} : reference n ω → reference n (context.extend m ω)\n\n/-- The set of names within the continuous π-calculus. -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive name : context → Type\n| zero   {Γ} {n : ℕ} : fin n → name (context.extend n Γ)\n| extend {Γ} {n : ℕ} : name Γ → name (context.extend n Γ)\n\n/-- The \"depth\" of a variable.\n\n    This is effectively a name, but without the index into the affinity network.\n    It is used to determine if the affinity network appears at all within a\n    term.\n\n    Technically this property could be defined as \"does any name of this level\n    appear\" - it may be worth seeing if that simplifies things in the future. -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive level : context → Type\n| zero   {Γ} {n} : level (context.extend n Γ)\n| extend {Γ} {n} : level Γ → level (context.extend n Γ)\n\n\n/-- Get the variable level/depth. This doesn't have much use aside for pretty-printing. -/\nprotected def reference.level : ∀ {Γ n}, reference Γ n → ℕ\n| Γ n (reference.zero _) := 0\n| Γ n (reference.extend r) := 1 + reference.level r\n\ninstance {Γ n} : has_repr (reference Γ n) := ⟨ λ x, repr (reference.level x) ⟩\n\nnamespace name\n  /-- Get the variable index. This doesn't have much use aside for pretty-printing. -/\n  protected def idx : ∀ {Γ}, name Γ → ℕ\n  | ._ (name.zero a) := a\n  | ._ (name.extend a) := idx a\n\n  /-- Get the variable level/depth. This doesn't have much use aside for pretty-printing. -/\n  protected def level : ∀ {Γ}, name Γ → ℕ\n  | ._ (name.zero a) := 0\n  | ._ (name.extend a) := 1 + level a\n\n  instance {Γ} : has_repr (name Γ) := ⟨ λ x, repr (name.level x) ++ \".\" ++ repr (name.idx x) ⟩\n\n  /-- Get the level of this name. -/\n  def to_level : ∀ {Γ}, name Γ → level Γ\n  | ._ (zero _) := level.zero\n  | ._ (extend a) := level.extend (to_level a)\n\n  section free\n    /-- Determine if this variable is on a specific level or depth.\n\n        This can be thought of as a determining if a given level is free within\n        this variable. -/\n    def at_level : ∀ {Γ}, level Γ → name Γ → Prop\n    | ._ level.zero (zero _) := true\n    | ._ (level.extend l) (extend a) := at_level l a\n\n    | ._ level.zero (extend _) := false\n    | ._ (level.extend _) (zero _) := false\n\n    instance {Γ} : has_mem (level Γ) (name Γ) := ⟨ at_level ⟩\n\n    private def at_level_decide :\n      ∀ {Γ} (l : level Γ) (a : name Γ), decidable (at_level l a)\n    | ._ level.zero (zero _) := decidable.true\n    | ._ (level.extend l) (extend a) := at_level_decide l a\n    | ._ level.zero (extend _) := decidable.false\n    | ._ (level.extend _) (zero _) := decidable.false\n\n    instance at_level.decidable {Γ} {l} {a : name Γ} : decidable (at_level l a)\n      := at_level_decide l a\n\n    /-- Any variable is always at the level provided by to_level. -/\n    theorem to_level_at : ∀ {Γ} (a : name Γ), name.to_level a ∈ a\n    | ._ (zero _) := by unfold to_level\n    | ._ (extend n) := to_level_at n\n  end free\n\n  /- Renaming applies a function to all variables in the current context,\n     mapping them to a new set of variables in a different (or the same)\n     context.\n\n     Our renaming code is pretty typical, though with some additional\n     complexities. The actual renaming function receives evidence that the\n     provided variable is used (typically, that it is free within the term\n     begin renamed).\n\n     While this may seem like an obvious fact, it is crucial to allow lowering\n     the level of names - if we know `name.zero ∉ A', then we can safely reduce\n     all variables by one, as we can show by contradiction that our renaming\n     function doesn't receive `name.zero'.\n\n     Any functions suffixed with `_with' use this more complex definition of\n     renaming - we also provide simpler ones which provide a simple\n     `name Γ → name Δ' interface (and a few additional guarantees). -/\n  section rename\n    /-- Wrap a renaming function, making it suitable for a nested context. -/\n    def ext_with {Γ Δ} {n}\n        (P : level (context.extend n Γ) → Prop)\n        (ρ : Π (x : name Γ), P (level.extend (name.to_level x)) → name Δ)\n      : Π (x : name (context.extend n Γ)), P (name.to_level x) → name (context.extend n Δ)\n    | (zero idx) p := zero idx\n    | (extend a) p := extend (ρ a p)\n\n    /-- Extending with `id' does nothing. -/\n    lemma ext_with_identity :\n      ∀ {Γ} {n : ℕ}\n        (P : level (context.extend n Γ) → Prop)\n        (a : name (context.extend n Γ)) (p : P (name.to_level a))\n      , ext_with P (λ x _, x) a p = a\n    | Γ n P (zero lt) _ := rfl\n    | Γ n P (extend a) _ := rfl\n\n    /-- Extending with `id' is equivalent to the identity function. -/\n    lemma ext_with_id {Γ} {n : ℕ} (P : level (context.extend n Γ) → Prop)\n      : ext_with P (λ x _, x) = λ x _, x\n      := funext $ λ a, funext (ext_with_identity P a)\n\n    /-- Wrap a simple renaming function, making it suitable for a nested\n        context. -/\n    @[reducible]\n    def ext {Γ Δ} {n} (ρ : name Γ → name Δ)\n      : name (context.extend n Γ) → name (context.extend n Δ)\n    | a := ext_with (λ _, true) (λ x p, ρ x) a true.intro\n\n    /-- Extending with the identity does nothing. -/\n    lemma ext_identity {Γ} {n : ℕ} (a : name (context.extend n Γ))\n      : ext id a = a\n      := ext_with_identity _ a _\n\n    /-- Extending with `id' is equivalent to the identity function. -/\n    lemma ext_id : ∀ {Γ} {n : ℕ}, @ext Γ Γ n id = id\n    | Γ n := funext ext_identity\n\n    /-- Composing extensions is equivalent extending a composition. -/\n    lemma ext_with_compose :\n      ∀ {Γ Δ η} {n : ℕ}\n        (P : level (context.extend n Γ) → Prop)\n        (ρ : Π (x : name Γ), P (level.extend (name.to_level x)) → name Δ)\n        (σ : name Δ → name η)\n        (a : name (context.extend n Γ)) (p : P (name.to_level a))\n      , ext σ (ext_with P ρ a p) = ext_with P (λ a p, σ (ρ a p)) a p\n    | Γ Δ η n P ρ σ (zero lt) _ := rfl\n    | Γ Δ η n P ρ σ (extend a) _ := rfl\n\n    /-- Composing extensions is equivalent extending a composition. -/\n    lemma ext_with_comp {Γ Δ η} {n : ℕ}\n        (P : level (context.extend n Γ) → Prop)\n        (ρ : Π (x : name Γ), P (level.extend (name.to_level x)) → name Δ)\n        (σ : name Δ → name η)\n      : (λ a p, ext σ (ext_with P ρ a p)) = ext_with P (λ a p, σ (ρ a p))\n      := funext $ λ a, funext (ext_with_compose P ρ σ a)\n\n    /-- Composing simple extensions is equivalent extending a composition. -/\n    lemma ext_compose {Γ Δ η} (ρ : name Γ → name Δ) (σ : name Δ → name η) {n : ℕ}\n        (a : name (context.extend n Γ))\n      : ext σ (ext ρ a) = ext (σ ∘ ρ) a\n      := ext_with_compose (λ _, true) (λ x _, ρ x) σ a true.intro\n\n    /-- Composing simple extensions is equivalent extending a composition. -/\n    lemma ext_comp {Γ Δ η} (ρ : name Γ → name Δ) (σ : name Δ → name η) {n : ℕ}\n      : (ext σ ∘ ext ρ) = @ext _ _ n (σ ∘ ρ)\n      := funext (ext_compose ρ σ)\n\n    /-- Extending then renaming with an extended function, is equivalent to\n        renaming then extending. -/\n    lemma ext_extend {Γ Δ} {n : ℕ} (ρ : name Γ → name Δ)\n      : (ext ρ ∘ extend) = (@extend Δ n ∘ ρ) := funext (λ x, rfl)\n\n    lemma ext_zero {Γ Δ} {n : ℕ} (ρ : name Γ → name Δ)\n      : (ext ρ ∘ zero) = (@zero Δ n) := funext (λ x, rfl)\n\n    /-- Rewrite one ext_with to another.\n\n        This is largely useful when proving renaming properties in more complex\n        types. -/\n    lemma ext_with_discard {Γ Δ} {n}\n        (P : level (context.extend n Γ) → Prop)\n        (ρ : name Γ → name Δ)\n      : (ext_with P (λ a _, ρ a))\n      = (λ a _, name.ext_with (λ _x, true) (λ x _, ρ x) a true.intro)\n      := funext $ λ a, funext $ λ free, by { cases a; from rfl }\n\n    lemma ext.inj {Γ Δ n} {ρ : name Γ → name Δ} (inj : function.injective ρ)\n      : function.injective (@ext Γ Δ n ρ)\n    | (name.zero i) (name.zero j) eq := by { cases eq, from rfl }\n    | (name.zero i) (name.extend b) eq := by contradiction\n    | (name.extend i) (name.zero j) eq := by contradiction\n    | (name.extend a) (name.extend b) eq := congr_arg extend (inj (extend.inj eq))\n  end rename\n\n  section swap\n    /-- Swap the two topmost variables. Used for exchange of ν(_) terms. -/\n    def swap {Γ} {M N : ℕ}\n      : name (context.extend M (context.extend N Γ))\n      → name (context.extend N (context.extend M Γ))\n    | (zero lt) := extend (zero lt)\n    | (extend (zero lt)) := zero lt\n    | (extend (extend n)) := extend (extend n)\n\n    /-- A twice-extended renaming function can be applied before or after a\n        swap. -/\n    lemma swap_ext_ext {Γ Δ} {ρ : name Γ → name Δ} {m n : ℕ}\n      : (ext (ext ρ) ∘ swap)\n      = (swap ∘ @ext _ _ n (@ext _ _ m ρ))\n      := funext $ λ α,\n        match α with\n        | zero p := rfl\n        | extend (zero lt) := rfl\n        | extend (extend _) := rfl\n        end\n\n    /-- Incrementing names and swapping, is just the same as incrementing\n        everything above 0. -/\n    lemma swap_comp_extend {Γ} {m n : ℕ}\n      : (@name.swap Γ m n ∘ name.extend) = (name.ext name.extend)\n      := funext $ λ a, by { cases a; from rfl }\n\n    /-- Incrementing all names above 0 and swapping is the same as just\n        incrementing everything. -/\n    lemma swap_comp_ext_extend {Γ} {m n : ℕ}\n      : (@name.swap Γ m n ∘ name.ext name.extend) = name.extend\n      := funext $ λ a, by { cases a; from rfl }\n\n    /-- Swapping twice does nothing. -/\n    lemma swap_swap_identity :\n      ∀ {Γ} {a b : ℕ} (a : name (context.extend b (context.extend a Γ)))\n      , name.swap (name.swap a) = a\n      | Γ a b (name.zero _) := rfl\n      | Γ a b (name.extend (name.zero _)) := rfl\n      | Γ a b (name.extend (name.extend _)) := rfl\n\n    /-- Swapping twice gives the identity. -/\n    lemma swap_swap :\n      ∀ {Γ} {a b : ℕ}\n      , (@name.swap Γ a b) ∘ name.swap = id\n      | Γ a b := funext swap_swap_identity\n  end swap\n\n  section application\n    /-- Given a list of names bs, construct a renaming function which renames\n        level-0 names to the corresponding names in bs.  -/\n    def mk_apply {Γ} {b} (bs : vector (name Γ) b)\n      : name (context.extend b Γ) → name Γ\n    | (zero idx) := vector.nth bs idx\n    | (extend e) := e\n\n    lemma mk_apply_rename\n        {Γ Δ} {b} (ρ : name Γ → name Δ) {bs : vector (name Γ) b}\n      : ρ ∘ mk_apply bs = mk_apply (vector.map ρ bs) ∘ name.ext ρ\n      := funext $ λ a,\n        by { cases a; simp only [mk_apply, ext, ext_with, vector.nth_map, function.comp] }\n\n    lemma mk_apply_ext {Γ} {b} {bs : vector (name Γ) b}\n      : mk_apply bs ∘ (@extend Γ b) = id\n      := funext $λ α, by { cases α; unfold mk_apply id function.comp }\n  end application\n\n  section drop\n    /-- Reduce the level of a variable by one, given a proof it's unused.  -/\n    def drop_var {Γ} {n}\n        (P : level (context.extend n Γ) → Prop) (p : (¬ P level.zero))\n      : Π a, P (name.to_level a) → name Γ\n    | (name.zero idx) q := by { unfold name.to_level at q, contradiction }\n    | (name.extend a) _ := a\n\n    /-- Show a renaming function which drops then extends is the identity. -/\n    lemma drop_var_compose {Γ} {n}\n      (P : level (context.extend n Γ) → Prop) (p : (¬ P level.zero))\n      : (λ a f, name.extend (drop_var P p a f)) = λ a _, a\n      := funext $ λ a, funext $ λ q, begin\n        cases a,\n        case name.zero { unfold name.to_level at q, contradiction },\n        case name.extend { from rfl }\n      end\n  end drop\n\n  /-- Get the index of a name in the singleton context . -/\n  def to_idx {n : ℕ} : name (context.extend n context.nil) → fin n\n  | (name.zero i) := i\n  | (name.extend a) := by cases a\nend name\n\nend cpi\n\n#lint-\n", "meta": {"author": "continuouspi", "repo": "lean-cpi", "sha": "443bf2cb236feadc45a01387099c236ab2b78237", "save_path": "github-repos/lean/continuouspi-lean-cpi", "path": "github-repos/lean/continuouspi-lean-cpi/lean-cpi-443bf2cb236feadc45a01387099c236ab2b78237/src/data/cpi/name.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4774264249701428}}
{"text": "import Mathlib.Data.Nat.Basic\nimport Mathlib.Init.Algebra.Order\nimport Mathlib.Init.Data.Nat.Basic\nimport Mathlib.Init.Data.Nat.Lemmas\nimport Mathlib.Init.Data.Int.Basic\nimport Mathlib.Data.String.Defs\nimport Mathlib.Data.String.Lemmas\nimport Mathlib.Data.Equiv.Basic\nimport Timelib.Util\nimport Timelib.Date.ScalarDate\nimport Timelib.Date.Convert\nimport Timelib.NanoPrecision.Duration.SignedDuration\nimport Timelib.NanoPrecision.Duration.UnsignedDuration\nimport Timelib.NanoPrecision.ClockTime.NaiveClockTime\n\n/--\nIf nonnegative, the number of nanoseconds since the epoch (midnight of 0001/Jan/01)\nIf negative, the number of nanoseconds until the epoch (midnight of 0001/Jan/01)\n-/\nstructure TaiDateTime where\n  nanos : Int\nderiving DecidableEq, Ord, Repr\n\ninstance : Inhabited TaiDateTime where\n  default := ⟨0⟩\n\n/-\nUsing `Int.fdiv`, because we have a positive denominator, and we want to round \ndown if `dt.nanos` is negative, up if it's nonnegative.\n-/\ndef TaiDateTime.toScalarDate (dt : TaiDateTime) : ScalarDate := ⟨(dt.nanos.fdiv oneDayNanos) + 1⟩\n\ndef TaiDateTime.dayOfWeek (dt : TaiDateTime) : Int := dt.toScalarDate.dayOfWeek\n\n/--\nThe `DateTime` as of midnight (00:00:00 uninterpreted) on the ymd. \nWe subtract one to account for the fact that `Date` is one day ahead of the zero-based `TaiDateTime`.\n-/\ndef TaiDateTime.fromYmd \n  (y : Year)\n  (m : Month)\n  (d : Nat)\n  (hd : 1 <= d ∧ d <= m.numDays y := by decide) : TaiDateTime := \n    ⟨oneDayNanos * ((Ymd.mk y m d hd.left hd.right).toScalarDate.day - 1)⟩ \n\ndef TaiDateTime.fromYmdsn \n  (y : Year) \n  (m : Month) \n  (d : Nat) \n  (s : Nat)\n  (n : Nat)\n  (hd : 1 <= d ∧ d <= m.numDays y := by decide) : TaiDateTime := \n    ⟨(TaiDateTime.fromYmd y m d hd).nanos + (oneSecondNanos * s) + n⟩ \n\ninstance : Equiv Int TaiDateTime where\n  toFun := TaiDateTime.mk\n  invFun := TaiDateTime.nanos\n  left_inv := by simp [Function.LeftInverse]\n  right_inv := by simp [Function.LeftInverse, Function.RightInverse]\n\ntheorem TaiDateTime.eq_of_val_eq : ∀ {d1 d2 : TaiDateTime} (h : d1.nanos = d2.nanos), d1 = d2\n| ⟨_⟩, _, rfl => rfl\n\ntheorem TaiDateTime.val_ne_of_ne : ∀ {d1 d2 : TaiDateTime} (h : d1 ≠ d2), d1.nanos ≠ d2.nanos\n| ⟨x⟩, ⟨y⟩, h => by intro hh; apply h; exact congrArg TaiDateTime.mk hh\n\ninstance : LT TaiDateTime where\n  lt := InvImage Int.lt TaiDateTime.nanos\n\ninstance : LE TaiDateTime where\n  le := InvImage Int.le TaiDateTime.nanos\n  \n@[simp] theorem TaiDateTime.le_def (d₁ d₂ : TaiDateTime) : (d₁ <= d₂) = (d₁.nanos <= d₂.nanos) := rfl\n@[simp] theorem TaiDateTime.lt_def (d₁ d₂ : TaiDateTime) : (d₁ < d₂) = (d₁.nanos < d₂.nanos) := rfl\n\ninstance instDecidableLETaiDateTime (d₁ d₂ : TaiDateTime) : Decidable (d₁ <= d₂) := inferInstanceAs (Decidable <| d₁.nanos <= d₂.nanos)\ninstance instDecidableLTTaiDateTime (d₁ d₂ : TaiDateTime) : Decidable (d₁ < d₂) := inferInstanceAs (Decidable <| d₁.nanos < d₂.nanos)\n\ninstance : LinearOrder TaiDateTime where\n  le_refl (a) := le_refl a.nanos\n  le_trans (a b c) := Int.le_trans\n  lt_iff_le_not_le (a b) := Int.lt_iff_le_not_le\n  le_antisymm (a b h1 h2) := by\n    apply TaiDateTime.eq_of_val_eq\n    exact le_antisymm h1 h2\n  le_total := by simp [TaiDateTime.le_def, le_total]\n  decidable_le := inferInstance\n\ndef TaiDateTime.seconds (d : TaiDateTime) : Int := d.nanos / oneSecondNanos\n\ndef TaiDateTime.fromNanos : Int → TaiDateTime := TaiDateTime.mk\n\ndef TaiDateTime.toYmd (d : TaiDateTime) : Ymd := d.toScalarDate.toYmd\n\ndef TaiDateTime.year (d : TaiDateTime) : Year := d.toScalarDate.year\n\ninstance : ToString TaiDateTime where\n  toString dt :=\n    let ⟨y, m, d, _, _⟩ := dt.toYmd\n    let t : String := ToString.toString <| NaiveClockTime.mk (Fin.ofInt'' (dt.nanos % (↑oneDayNanos)))\n    s!\"{y}/{m.toNat}/{d}; {t}\"\n\n@[reducible]\ndef TaiDateTime.dateEq : TaiDateTime → TaiDateTime → Prop\n| n₁, n₂ => n₁.toScalarDate = n₂.toScalarDate\n\ndef TaiDateTime.dateEq.Equivalence : Equivalence TaiDateTime.dateEq := {\n  refl := fun _ => rfl\n  symm := fun h => h.symm\n  trans := fun h h' => Eq.trans h h'\n}\n\ninstance instTaiDateTimeSetoid : Setoid TaiDateTime := \n  ⟨TaiDateTime.dateEq, TaiDateTime.dateEq.Equivalence⟩\n\ninstance (d₁ d₂ : TaiDateTime) : Decidable <| d₁.dateEq d₂ := inferInstance\n\ninstance {n : Nat} : OfNat TaiDateTime n where\n  ofNat := ⟨n⟩\n\ninstance : HAdd TaiDateTime SignedDuration TaiDateTime where\n  hAdd da du := ⟨da.nanos + du.val⟩\n\ninstance : HAdd SignedDuration TaiDateTime TaiDateTime where\n  hAdd du da := da + du\n\ntheorem TaiDateTime.hAdd_signed_def (d : TaiDateTime) (dur : SignedDuration) : d + dur = ⟨d.nanos + dur.val⟩ := rfl\ntheorem TaiDateTime.hAdd_signed_def_rev (d : TaiDateTime) (dur : SignedDuration) : dur + d = ⟨d.nanos + dur.val⟩ := rfl\n\ninstance : HSub TaiDateTime SignedDuration TaiDateTime where\n  hSub t dur := t + -dur\n\ntheorem TaiDateTime.hSub_signed_def (d : TaiDateTime) (dur : SignedDuration) : d - dur = d + -dur := rfl\n\ntheorem TaiDateTime.hAdd_signed_sub_cancel (t : TaiDateTime) (d : SignedDuration) : t + d - d = t := by\n  apply TaiDateTime.eq_of_val_eq\n  simp [TaiDateTime.hSub_signed_def, TaiDateTime.hAdd_signed_def]\n  apply Int.add_neg_cancel_right\n\ntheorem TaiDateTime.hAdd_signed_sub_add_cancel (t : TaiDateTime) (d : SignedDuration) : t - d + d = t := by\n  simp [TaiDateTime.hSub_signed_def, TaiDateTime.hAdd_signed_def]\n  exact TaiDateTime.eq_of_val_eq (Int.sub_add_cancel t.nanos d.val)\n\ntheorem TaiDateTime.hAdd_signed_comm (t : TaiDateTime) (d : SignedDuration) : t + d = d + t := by\n  simp [TaiDateTime.hAdd_signed_def, TaiDateTime.hAdd_signed_def_rev]\n\ninstance : HAdd TaiDateTime UnsignedDuration TaiDateTime where\n  hAdd da du := ⟨da.nanos + du.val⟩\n\ninstance : HAdd UnsignedDuration TaiDateTime TaiDateTime where\n  hAdd du da := da + du\n\ntheorem TaiDateTime.hAdd_unsigned_def (d : TaiDateTime) (dur : UnsignedDuration) : d + dur = ⟨d.nanos + dur.val⟩ := rfl\n\ninstance : HSub TaiDateTime UnsignedDuration TaiDateTime where\n  hSub da du := ⟨da.nanos - du.val⟩\n\ntheorem TaiDateTime.hSub_unsigned_def (d : TaiDateTime) (dur : UnsignedDuration) : d - dur = ⟨d.nanos - dur.val⟩ := rfl\n\ntheorem TaiDateTime.hAdd_unsigned_sub_cancel (t : TaiDateTime) (d : UnsignedDuration) : t + d - d = t := TaiDateTime.hAdd_signed_sub_cancel t d\n\ntheorem TaiDateTime.hAdd_unsigned_sub_add_cancel (t : TaiDateTime) (d : UnsignedDuration) : t - d + d = t := TaiDateTime.hAdd_signed_sub_add_cancel t d\n\ntheorem TaiDateTime.hAdd_unsigned_comm (t : TaiDateTime) (d : UnsignedDuration) : t + d = d + t := TaiDateTime.hAdd_signed_comm t d\n\n/--\nSet the clock time of the current day to `tgt`.\n-/\n@[reducible]\ndef TaiDateTime.setClockTime (t : TaiDateTime) (clockTime : NaiveClockTime) : TaiDateTime :=\n  let days := (t.nanos.fdiv oneDayNanos) * oneDayNanos\n  ⟨days + clockTime.nanos.val⟩\n\n", "meta": {"author": "ammkrn", "repo": "timelib", "sha": "185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15", "save_path": "github-repos/lean/ammkrn-timelib", "path": "github-repos/lean/ammkrn-timelib/timelib-185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15/Timelib/NanoPrecision/DateTime/TaiDateTime.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303087996143, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.47742641900929916}}
{"text": "import algebraic_geometry.points\n\nopen opposite topological_space category_theory category_theory.limits\n\nnoncomputable theory\n\nnamespace algebraic_geometry\n\nnamespace pullback\n\nuniverse u\n\nvariables {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z)\n\nstructure triplet :=\n(x : X.carrier)\n(y : Y.carrier)\n(z : Z.carrier)\n(hx : f.1.base x = z)\n(hy : g.1.base y = z)\n.\nvariables {f g} (T : triplet f g)\n\ndef triplet.residue_field_tensor : CommRing :=\npushout (Z.residue_field_of_eq T.hx ≫ f.map_residue_field T.x)\n        (Z.residue_field_of_eq T.hy ≫ g.map_residue_field T.y)\n.\ndef triplet.Spec_residue_field_tensor_to :\n  Scheme.Spec.obj (op T.residue_field_tensor) ⟶ pullback f g :=\npullback.lift (Scheme.Spec.map pushout.inl.op ≫ X.from_Spec_residue_field T.x)\n              (Scheme.Spec.map pushout.inr.op ≫ Y.from_Spec_residue_field T.y)\nbegin\n  have := @pushout.condition _ _ _ _ _ (Z.residue_field_of_eq T.hx ≫ f.map_residue_field T.x)\n    (Z.residue_field_of_eq T.hy ≫ g.map_residue_field T.y) _,\n  replace this := congr_arg (λ f, Z.residue_field_of_eq T.hx.symm ≫ f) this,\n  simp only [category.assoc, Scheme.residue_field_of_eq_trans_assoc,\n    Scheme.residue_field_of_eq_refl, category.id_comp] at this,\n  simp only [category.assoc, ← Scheme.hom.map_residue_field_from_Spec_residue_field,\n    ← Scheme.Spec.map_comp_assoc, ← op_comp, this],\n  rw [op_comp, functor.map_comp_assoc],\n  congr' 1,\n  generalize_proofs h,\n  revert h,\n  rw [T.hx, T.hy],\n  simp only [Scheme.residue_field_of_eq_refl, category.id_comp, op_id,\n    category_theory.functor.map_id, category.id_comp, eq_self_iff_true, forall_true_left]\nend\n\n@[simps]\ndef triplet_of_pullback (t : (pullback f g).carrier) : triplet f g :=\n{ x := (pullback.fst : pullback f g ⟶ X).1.base t,\n  y := (pullback.snd : pullback f g ⟶ Y).1.base t,\n  z := (limit.π _ walking_cospan.one : pullback f g ⟶ Z).1.base t,\n  hx := by { rw [limit.π, pullback_cone.condition_one (limit.cone (cospan f g))], refl },\n  hy := by { rw [limit.π, pullback_cone.condition_one (limit.cone (cospan f g)),\n    pullback_cone.condition], refl } }\n\n.\ndef residue_field_tensor_of_pullback_to (t : (pullback f g).carrier) :\n  (triplet_of_pullback t).residue_field_tensor ⟶ Scheme.residue_field _ t :=\npushout.desc\n  ((pullback.fst : pullback f g ⟶ _).map_residue_field t)\n  ((pullback.snd : pullback f g ⟶ _).map_residue_field t)\nbegin\n  dsimp only [triplet_of_pullback_x, triplet_of_pullback_y],\n  rw [category.assoc, category.assoc, ← Scheme.hom.map_residue_field_comp,\n    ← Scheme.hom.map_residue_field_comp, Scheme.hom.map_residue_field_congr pullback.condition,\n    Scheme.residue_field_of_eq_trans_assoc],\n  refl\nend\n\ndef residue_field_tensor_prime_ideal (t : (pullback f g).carrier) :\n  prime_spectrum (triplet_of_pullback t).residue_field_tensor :=\nprime_spectrum.comap (residue_field_tensor_of_pullback_to t) ⊥\n\nlemma Spec_residue_field_tensor_of_pullback_to_comp (t : (pullback f g).carrier) :\n  Scheme.Spec.map (residue_field_tensor_of_pullback_to t).op ≫\n    (triplet_of_pullback t).Spec_residue_field_tensor_to =\n    Scheme.from_Spec_residue_field _ t :=\nbegin\n  apply pullback.hom_ext,\n  { rw [category.assoc, triplet.Spec_residue_field_tensor_to, pullback.lift_fst,\n      ← functor.map_comp_assoc, ← op_comp, residue_field_tensor_of_pullback_to,\n      pushout.inl_desc, ← Scheme.hom.map_residue_field_from_Spec_residue_field], refl },\n  { rw [category.assoc, triplet.Spec_residue_field_tensor_to, pullback.lift_snd,\n      ← functor.map_comp_assoc, ← op_comp, residue_field_tensor_of_pullback_to,\n      pushout.inr_desc, ← Scheme.hom.map_residue_field_from_Spec_residue_field], refl }\nend\n\n\nlemma residue_field_tensor_to_prime_ideal (t : (pullback f g).carrier) :\n  (triplet_of_pullback t).Spec_residue_field_tensor_to.val.base\n    (residue_field_tensor_prime_ideal t) = t :=\nbegin\n  change (Scheme.Spec.map (residue_field_tensor_of_pullback_to t).op ≫\n    (triplet_of_pullback t).Spec_residue_field_tensor_to).1.base _ = t,\n  rw [Spec_residue_field_tensor_of_pullback_to_comp, Scheme.from_Spec_residue_field_base],\nend\n\n@[ext]\nlemma triplet_ext {T₁ T₂ : triplet f g}\n  (hx : T₁.x = T₂.x) (hy : T₁.y = T₂.y) : T₁ = T₂ :=\nbegin\n  cases T₁, cases T₂, dsimp only at hx hy, substs hx hy T₁_hx T₂_hx\nend\n\nlemma triplet_ext_iff {T₁ T₂ : triplet f g} :\n  T₁ = T₂ ↔ T₁.x = T₂.x ∧ T₁.y = T₂.y :=\nbegin\n  split, { rintro rfl, exact ⟨rfl, rfl⟩ }, { intro h, exact triplet_ext h.1 h.2 }\nend\n\ndef triplet.residue_field_tensor_of_eq {T₁ T₂ : triplet f g} (e : T₁ = T₂) :\n  T₁.residue_field_tensor ⟶ T₂.residue_field_tensor :=\npushout.map _ _ _ _\n  (X.residue_field_of_eq $ by subst e)\n  (Y.residue_field_of_eq $ by subst e)\n  (Z.residue_field_of_eq $ by subst e)\n  (by { subst e, simp })\n  (by { subst e, simp })\n.\nlemma triplet.residue_field_tensor_of_eq_eq_eq_to_hom\n  {T₁ T₂ : triplet f g} (e : T₁ = T₂) :\n  triplet.residue_field_tensor_of_eq e = eq_to_hom (by subst e) :=\nby { subst e, apply pushout.hom_ext; simpa [triplet.residue_field_tensor_of_eq, -category.comp_id]\n  using (category.comp_id _).symm }\n.\n@[simp, reassoc]\nlemma triplet.residue_field_tensor_of_eq_trans\n  {T₁ T₂ T₃ : triplet f g} (e : T₁ = T₂) (e' : T₂ = T₃) :\n  triplet.residue_field_tensor_of_eq e ≫ triplet.residue_field_tensor_of_eq e' =\n    triplet.residue_field_tensor_of_eq (e.trans e') :=\nby simp only [triplet.residue_field_tensor_of_eq_eq_eq_to_hom, eq_to_hom_trans]\n\n@[simp]\nlemma triplet.residue_field_tensor_of_eq_id {T : triplet f g} :\n  triplet.residue_field_tensor_of_eq (refl T) = 𝟙 _ :=\nby simp only [triplet.residue_field_tensor_of_eq_eq_eq_to_hom, eq_to_hom_refl]\n\n\nlemma triplet.of_pullback_tensor_to\n  (T : triplet f g) (p : prime_spectrum T.residue_field_tensor) :\n  triplet_of_pullback (T.Spec_residue_field_tensor_to.1.base p) = T :=\nbegin\n  ext; dsimp,\n  { rw [← Scheme.comp_val_base_apply, triplet.Spec_residue_field_tensor_to,\n      pullback.lift_fst, Scheme.comp_val_base_apply, Scheme.from_Spec_residue_field_base] },\n  { rw [← Scheme.comp_val_base_apply, triplet.Spec_residue_field_tensor_to,\n      pullback.lift_snd, Scheme.comp_val_base_apply, Scheme.from_Spec_residue_field_base] },\nend\n\n\nlemma triplet.eq_from_Spec_residue_field_aux (x : X.carrier) (p) :\n  Scheme.Spec.map (X.residue_field_of_eq (Scheme.from_Spec_residue_field_base x p) ≫\n    (X.from_Spec_residue_field x).map_residue_field p).op =\n  (Scheme.Spec.obj (op (X.residue_field x))).from_Spec_residue_field p :=\nbegin\n  rw ← cancel_mono (X.from_Spec_residue_field x),\n  rw [op_comp, functor.map_comp_assoc, Scheme.residue_field_of_eq_from_Spec,\n    Scheme.hom.map_residue_field_from_Spec_residue_field],\nend\n\nlemma triplet.eq_from_Spec_residue_field (T : triplet f g)\n  (p : prime_spectrum T.residue_field_tensor) :\n  Scheme.Spec.map (triplet.residue_field_tensor_of_eq (T.of_pullback_tensor_to p).symm ≫\n    residue_field_tensor_of_pullback_to _ ≫\n    T.Spec_residue_field_tensor_to.map_residue_field p).op =\n  Scheme.from_Spec_residue_field _ p :=\nbegin\n  refine eq.trans _ (Scheme.Spec.image_preimage _),\n  congr' 1,\n  apply quiver.hom.unop_inj,\n  apply pushout.hom_ext,\n  { have : T.Spec_residue_field_tensor_to ≫ pullback.fst = _ := pullback.lift_fst _ _ _,\n    simp only [residue_field_tensor_of_pullback_to,\n      triplet.residue_field_tensor_of_eq, quiver.hom.unop_op,\n      pushout.inl_desc_assoc, op_comp, category.assoc, unop_comp],\n    apply quiver.hom.op_inj,\n    apply Scheme.Spec.map_injective,\n    rw [← Scheme.hom.map_residue_field_comp, Scheme.hom.map_residue_field_congr this,\n      Scheme.residue_field_of_eq_trans_assoc],\n    conv_rhs { rw [op_comp, functor.map_comp] },\n    rw [quiver.hom.op_unop, functor.image_preimage],\n    refine eq.trans _ (Scheme.hom.map_residue_field_from_Spec_residue_field _ _),\n    rw [Scheme.hom.map_residue_field_comp, ← category.assoc, op_comp, functor.map_comp,\n      ← triplet.eq_from_Spec_residue_field_aux],\n    refl },\n  { have : T.Spec_residue_field_tensor_to ≫ pullback.snd = _ := pullback.lift_snd _ _ _,\n    simp only [residue_field_tensor_of_pullback_to,\n      triplet.residue_field_tensor_of_eq, quiver.hom.unop_op,\n      pushout.inr_desc_assoc, op_comp, category.assoc, unop_comp],\n    apply quiver.hom.op_inj,\n    apply Scheme.Spec.map_injective,\n    rw [← Scheme.hom.map_residue_field_comp, Scheme.hom.map_residue_field_congr this,\n      Scheme.residue_field_of_eq_trans_assoc],\n    conv_rhs { rw [op_comp, functor.map_comp] },\n    rw [quiver.hom.op_unop, functor.image_preimage],\n    refine eq.trans _ (Scheme.hom.map_residue_field_from_Spec_residue_field _ _),\n    rw [Scheme.hom.map_residue_field_comp, ← category.assoc, op_comp, functor.map_comp,\n      ← triplet.eq_from_Spec_residue_field_aux],\n    refl },\nend\n.\nlemma carrier_equiv_eq\n  {T₁ T₂ : Σ T : triplet f g, prime_spectrum T.residue_field_tensor} :\n  T₁ = T₂ ↔ ∃ e : T₁.1 = T₂.1, prime_spectrum.comap\n    (triplet.residue_field_tensor_of_eq e.symm) T₁.2 = T₂.2 :=\nbegin\n  split,\n  { rintro rfl, refine ⟨rfl, _⟩, rw triplet.residue_field_tensor_of_eq_id, ext, refl },\n  { cases T₁, cases T₂, dsimp, rintro ⟨rfl, rfl⟩, congr' 1,\n    rw triplet.residue_field_tensor_of_eq_id, ext, refl }\nend\n\nvariables (f g)\n\ndef carrier_equiv :\n  (pullback f g).carrier ≃ Σ T : triplet f g, prime_spectrum T.residue_field_tensor :=\n{ to_fun := λ t, ⟨_, residue_field_tensor_prime_ideal t⟩,\n  inv_fun := λ T, T.1.Spec_residue_field_tensor_to.1.base T.2,\n  left_inv := residue_field_tensor_to_prime_ideal,\n  right_inv :=\n  begin\n    rintro ⟨T, p⟩,\n    apply carrier_equiv_eq.mpr ⟨_, _⟩; dsimp,\n    { ext; dsimp only [triplet_of_pullback_x, triplet_of_pullback_y],\n      { rw [← Scheme.comp_val_base_apply, triplet.Spec_residue_field_tensor_to,\n          pullback.lift_fst, Scheme.comp_val_base_apply, Scheme.from_Spec_residue_field_base] },\n      { rw [← Scheme.comp_val_base_apply, triplet.Spec_residue_field_tensor_to,\n          pullback.lift_snd, Scheme.comp_val_base_apply, Scheme.from_Spec_residue_field_base] } },\n    { delta residue_field_tensor_prime_ideal,\n      have : prime_spectrum.comap (T.Spec_residue_field_tensor_to.map_residue_field p) ⊥ = ⊥ :=\n        subsingleton.elim _ _,\n      rw [← this, ← prime_spectrum.comap_comp_apply, ← prime_spectrum.comap_comp_apply],\n      convert_to\n        (Scheme.Spec.map (triplet.residue_field_tensor_of_eq _ ≫\n          residue_field_tensor_of_pullback_to _ ≫\n          T.Spec_residue_field_tensor_to.map_residue_field p).op).1.base _ = p,\n      rw [triplet.eq_from_Spec_residue_field, Scheme.from_Spec_residue_field_base] }\n  end }\n.\ninstance {K M N : Type*} [field K] [add_comm_group M] [add_comm_group N] [module K M] [module K N]\n  [nontrivial M] [nontrivial N] : nontrivial (tensor_product K M N) :=\nbegin\n  obtain ⟨v, ⟨hv⟩⟩ := basis.exists_basis K M,\n  obtain ⟨w, ⟨hw⟩⟩ := basis.exists_basis K N,\n  haveI := hv.index_nonempty,\n  haveI := hw.index_nonempty,\n  exact ⟨⟨_, _, (hv.tensor_product hw).ne_zero (classical.arbitrary _)⟩⟩\nend\n\nlemma CommRing.pushout_nontrivial {A B C : CommRing.{u}} (hA : is_field A) (f : A ⟶ B) (g : A ⟶ C)\n  [nontrivial B] [nontrivial C] : nontrivial.{u} (pushout f g : _) :=\nbegin\n  delta pushout,\n  apply_with (@@equiv.nontrivial (colimit.iso_colimit_cocone ⟨_, CommRing.pushout_cocone_is_colimit\n    f g⟩).CommRing_iso_to_ring_equiv.to_equiv) { instances := ff },\n  dsimp,\n  letI := hA.to_field, letI := f.to_algebra, letI := g.to_algebra,\n  apply_instance,\nend\n\ninstance {R : Type*} [comm_ring R] [nontrivial R] : nonempty (prime_spectrum R) :=\n⟨⟨_, (ideal.exists_maximal R).some_spec.is_prime⟩⟩\n\nvariables {f g}\n\nlemma triplet.exists_preimage (T : triplet f g) :\n  ∃ t : (pullback f g).carrier,\n    (pullback.fst : _ ⟶ X).1.base t = T.x ∧ (pullback.snd : _ ⟶ Y).1.base t = T.y :=\nbegin\n  haveI : nontrivial T.residue_field_tensor,\n  { delta triplet.residue_field_tensor,\n    exact CommRing.pushout_nontrivial (field.to_is_field (Z.residue_field T.z)) _ _ },\n  obtain ⟨t, ht⟩ := (carrier_equiv f g).surjective ⟨T, classical.arbitrary _⟩,\n  rw (show T = ((carrier_equiv f g) t).1, by rw ht),\n  exact ⟨t, rfl, rfl⟩,\nend\n\nlemma range_fst :\n  set.range (pullback.fst : pullback f g ⟶ X).1.base = f.1.base ⁻¹' set.range g.1.base :=\nbegin\n  apply le_antisymm,\n  { rintro _ ⟨y, rfl⟩,\n    refine ⟨(pullback.snd : pullback f g ⟶ Y).1.base y, _⟩,\n    rw [← Scheme.comp_val_base_apply, ← Scheme.comp_val_base_apply, pullback.condition] },\n  { rintro x ⟨y, hxy⟩,\n    obtain ⟨t, rfl : _ = x, -⟩ := triplet.exists_preimage ⟨x, y, _, hxy.symm, rfl⟩,\n    exact ⟨_, rfl⟩ }\nend\n\nlemma range_snd :\n  set.range (pullback.snd : pullback f g ⟶ Y).1.base = g.1.base ⁻¹' set.range f.1.base :=\nbegin\n  apply le_antisymm,\n  { rintro _ ⟨y, rfl⟩,\n    refine ⟨(pullback.fst : pullback f g ⟶ X).1.base y, _⟩,\n    rw [← Scheme.comp_val_base_apply, ← Scheme.comp_val_base_apply, pullback.condition] },\n  { rintro x ⟨y, hxy⟩,\n    obtain ⟨t, -, rfl : _ = x⟩ := triplet.exists_preimage ⟨y, x, _, hxy, rfl⟩,\n    exact ⟨_, rfl⟩ }\nend\n\nlemma range_to_base :\n    set.range (pullback.fst ≫ f : pullback f g ⟶ Z).1.base =\n      set.range f.1.base ∩ set.range g.1.base :=\nbegin\n  apply le_antisymm,\n  { rintro _ ⟨x, rfl⟩,\n    refine ⟨⟨_, rfl⟩, _⟩,\n    rw pullback.condition,\n    exact ⟨_, rfl⟩ },\n  { rintro z ⟨⟨x, hx⟩, ⟨y, hy⟩⟩,\n    obtain ⟨t, ht : _ = x, -⟩ := triplet.exists_preimage ⟨x, y, z, hx, hy⟩,\n    substs hx ht,\n    exact ⟨_, rfl⟩ }\nend\n\nlemma range_map {X Y S X' Y' S' : Scheme} (f : X ⟶ S) (g : Y ⟶ S) (f' : X' ⟶ S')\n  (g' : Y' ⟶ S') (i₁ : X ⟶ X') (i₂ : Y ⟶ Y') (i₃ : S ⟶ S') (e₁ : f ≫ i₃ = i₁ ≫ f')\n  (e₂ : g ≫ i₃ = i₂ ≫ g') [mono i₃] :\n  set.range (pullback.map f g f' g' i₁ i₂ i₃ e₁ e₂).1.base = \n  (pullback.fst : pullback f' g' ⟶ X').val.base ⁻¹' set.range i₁.val.base ∩\n  (pullback.snd : pullback f' g' ⟶ Y').val.base ⁻¹' set.range i₂.val.base :=\nbegin\n  simp only [pullback_map_eq_pullback_fst_fst_iso_inv, Scheme.comp_val_base, coe_comp],\n  rw [set.range_comp, set.range_iff_surjective.mpr _, set.image_comp, set.image_univ,\n    range_snd, set.image_preimage_eq_inter_range, range_fst, range_fst],\n  exact (as_iso $ (Scheme.forget_to_Top ⋙ forget Top).map\n    (pullback_fst_fst_iso f g f' g' i₁ i₂ i₃ e₁ e₂).inv).to_equiv.surjective,\nend\n\nend pullback\n\nend algebraic_geometry", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/algebraic_geometry/pullback_carrier.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267118068790619, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.47742223681704604}}
{"text": "import combinatorics.simple_graph.coloring\n\n\n--OUTPUT 1\ntheorem bipartite_graph_two_colorable {G : Type*} [graph G] : \n  (∃ (V1 V2 : set G), ∀ (v1 v2 : G), (v1,v2) ∈ G → (v1 ∈ V1 ∧ v2 ∈ V2) ∨ (v1 ∈ V2 ∧ v2 ∈ V1)) ↔ \n  (∃ (V1 V2 : set G), ∀ (v1 v2 : G), (v1,v2) ∈ G → (v1 ∈ V1 ∧ v2 ∈ V2) ∨ (v1 ∈ V2 ∧ v2 ∈ V1)) :=\nbegin\n  split,\n  assume h1 : ∃ (V1 V2 : set G), ∀ (v1 v2 : G), (v1,v2) ∈ G → (v1 ∈ V1 ∧ v2 ∈ V2) ∨ (v1 ∈ V2 ∧ v2 ∈ V1),\n  exact h1,\n  assume h2 : ∃ (V1 V2 : set G), ∀ (v1 v2 : G), (v1,v2) ∈ G → (v1 ∈ V1 ∧ v2 ∈ V2) ∨ (v1 ∈ V2 ∧ v2 ∈ V1),\n  exact h2,\nend\n\n--OUTPUT 2\ntheorem bipartite_iff_two_colorable {G : Type*} [graph G] : bipartite G ↔ two_colorable G :=\nbegin\n  -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n  have h1 : two_colorable G → bipartite G, from assume h2 : two_colorable G,\n    -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n    have h3 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ B → G.adj u v, from\n      -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n      have h4 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v, from\n        -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n        have h5 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v ∧ ∀ u v : G.vertex, G.adj u v → u ∈ A ∧ v ∈ B ∨ u ∈ B ∧ v ∈ A, from\n          -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n          have h6 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v, from\n            -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n            have h7 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v ∧ ∀ u v : G.vertex, G.adj u v → u ∈ A ∧ v ∈ B ∨ u ∈ B ∧ v ∈ A, from\n              -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n              have h8 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v, from\n                -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n                have h9 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v ∧ ∀ u v : G.vertex, G.adj u v → u ∈ A ∧ v ∈ B ∨ u ∈ B ∧ v ∈ A, from\n                  -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n                  have h10 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v, from\n                    -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n                    have h11 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v ∧ ∀ u v : G.vertex, G.adj u v → u ∈ A ∧ v ∈ B ∨ u ∈ B ∧ v ∈ A, from\n                      -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n                      have h12 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v, from\n                        -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n                        have h13 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v ∧ ∀ u v : G.vertex, G.adj u v → u ∈ A ∧ v ∈ B ∨ u ∈ B ∧ v ∈ A, from\n                          -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n                          have h14 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v, from\n                            -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n                            have h15 : ∃ A B : set G.vertex, ∀ v : G.vertex, v ∈ A ∨ v ∈ B ∧ ∀ u v : G.vertex, u ∈ A ∧ v ∈ A → ¬ G.adj u v ∧ ∀ u v : G.vertex, u ∈ B ∧ v ∈ B → ¬ G.adj u v ∧ ∀ u v : G.vertex, G\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem bipartite_graph_two_colorable {G : Type*} [graph G] : two_colorable G ↔ bipartite G :=\nbegin\n  -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n  have h1 : two_colorable G → ∀ (red : set G) (blue : set G), (∀ a : G, a ∈ red ∨ a ∈ blue) ∧ (∀ a b : G, a ∈ red ∧ b ∈ red → ¬ (a,b) ∈ G.edges) ∧ (∀ a b : G, a ∈ blue ∧ b ∈ blue → ¬ (a,b) ∈ G.edges) → bipartite G, from by {\n    assume h2colorable : two_colorable G,\n    assume (red : set G) (blue : set G),\n    assume hredblue : (∀ a : G, a ∈ red ∨ a ∈ blue) ∧ (∀ a b : G, a ∈ red ∧ b ∈ red → ¬ (a,b) ∈ G.edges) ∧ (∀ a b : G, a ∈ blue ∧ b ∈ blue → ¬ (a,b) ∈ G.edges),\n    -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n    have hred : ∀ a : G, a ∈ red → a ∈ G.vertices, from by {\n      assume a : G,\n      assume hreda : a ∈ red,\n      show a ∈ G.vertices, from by {\n        have hredbluea : a ∈ red ∨ a ∈ blue, from by {apply hredblue.left,exact a},\n        cases hredbluea,\n        exact hreda,\n        exact hredbluea,\n      },\n    },\n    have hblue : ∀ a : G, a ∈ blue → a ∈ G.vertices, from by {\n      assume a : G,\n      assume hbluea : a ∈ blue,\n      show a ∈ G.vertices, from by {\n        have hredbluea : a ∈ red ∨ a ∈ blue, from by {apply hredblue.left,exact a},\n        cases hredbluea,\n        exact hredbluea,\n        exact hbluea,\n      },\n    },\n    -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n    have hredred : ∀ a b : G, a ∈ red ∧ b ∈ red → ¬ (a,b) ∈ G.edges, from by {\n      assume a b : G,\n      assume hredred : a ∈ red ∧ b ∈ red,\n      show ¬ (a,b) ∈ G.edges, from by {\n        apply hredblue.right.left,\n        exact hredred,\n      },\n    },\n    have hblueblue : ∀ a b : G, a ∈ blue ∧ b ∈ blue → ¬ (a,b) ∈ G.edges, from by {\n      assume a b : G,\n      assume hblueblue : a ∈ blue ∧ b ∈ blue,\n      show ¬ (a,b) ∈ G.edges, from by {\n        apply hredblue.right.right,\n        exact hblueblue,\n      },\n    },\n    -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n    have hredblueedges : ∀ a b : G, (a,b) ∈ G.edges → a ∈ red ∧ b ∈ blue ∨ a ∈ blue ∧ b ∈ red, from by {\n      assume a b : G,\n      assume hredblueedges : (a,b) ∈ G.edges,\n      show a ∈ red ∧ b ∈ blue ∨ a ∈ blue ∧ b ∈ red, from by {\n        have hredbluea : a ∈ red ∨ a ∈ blue, from by {apply hredblue.left,exact a},\n        have hredblueb : b ∈ red ∨ b ∈ blue, from by {apply hredblue.left,exact b},\n        cases hredbluea,\n        cases hredblueb,\n        have hredred : a ∈ red ∧ b ∈ red, from by {split,exact hredbluea,exact hredblueb},\n        have hredrededges : ¬ (a,b) ∈ G.edges, from by {apply hredred,exact hredred},\n        contradiction,\n        right,\n        split,\n        exact hredbluea,\n        exact hredblueb,\n        cases hredblueb,\n        left,\n        split,\n        exact hredbluea,\n        exact hredblueb,\n        have hblueblue : a ∈ blue ∧ b ∈ blue, from by {split,exact hredbluea,exact hredblueb},\n        have hblueblueedges : ¬ (a,b) ∈ G.edges, from by {apply hblueblue,exact hblueblue},\n        contradiction,\n      },\n    },\n    show bipartite G, from by {\n      use red,\n      use blue,\n      split,\n      exact hred,\n      split,\n      exact hblue,\n      exact hredblueedges,\n    },\n  },\n\n  -- Conversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$.\n  have h2 : bipartite G → two_colorable G, from by {\n    assume hbipartite : bipartite G,\n    -- Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable.\n    have hredblue : ∀ a : G, a ∈ hbipartite.left ∨ a ∈ hbipartite.right, from by {\n      assume a : G,\n      show a ∈ hbipartite.left ∨ a ∈ hbipartite.right, from by {\n        have hredblueedges : ∀ a b : G, (a,b) ∈ G.edges → a ∈ hbipartite.left ∧ b ∈ hbipartite.right ∨ a ∈ hbipartite.right ∧ b ∈ hbipartite.left, from by {\n          assume a b : G,\n          assume hredblueedges : (a,b) ∈ G.edges,\n          show a ∈ hbipartite.left ∧ b ∈ hbipartite.right ∨ a ∈ hbipartite.right ∧ b ∈ hbipartite.left, from by {\n            apply hbipartite.right.right,\n            exact hredblueedges,\n          },\n        },\n        have hredbluea : a ∈ hbipartite.left ∨ a ∈ hbipartite.right, from by {\n          cases a,\n          have hredblueedges : (a,a) ∈ G.edges, from by {apply G.self_loop,exact a},\n          have hredbluea : a ∈ hbipartite.left ∧ a ∈ hbipartite.right ∨ a ∈ hbipartite.right ∧ a ∈ hbipartite.left, from by {apply hredblueedges,exact hredblueedges},\n          cases hredbluea,\n          left,\n          exact hredbluea.left,\n          right,\n          exact hredbluea.right,\n        },\n        exact hredbluea,\n      },\n    },\n    have hredred : ∀ a b : G, a ∈ hbipartite.left ∧ b ∈ hbipartite.left → ¬ (a,b) ∈ G.edges, from by\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by rw add_mul\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n    assume a b : G, use a⁻¹ * b, obviously, },\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n    assume a b : G, use b * a⁻¹, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n    exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n    (mul_one a),\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n    exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n        exists_unique.unique (h3 a) (hident a).right\n        (classical.some_spec (exists_unique.exists (h3 a))), \n      have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n        exists_unique.unique (h4 a) (hident a).left\n        (classical.some_spec (exists_unique.exists (h4 a))),\n      show e = (1 : G), from eq.trans (h9 e) (h6 _),     \n    },\n    exact ⟨by obviously, h7⟩,\n  }\nend\n\n/--`theorem`\nBipartite Graph is two colorable\nLet $G$ be a graph. Then $G$ is 2-colorable if and only if $G$ is bipartite.\n`proof`\nLet $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue. Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n\nConversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$. Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable.\n\nQED\n\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_with_comments-Natural-Language-Proof-Translation/lean_proof_with_comments-3_few_shot_temperature_0.2_max_tokens_2000_n_3/clean_files/Bipartite Graph is two colorable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357494949105, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.47739626985426525}}
{"text": "-- La_funcion_relacionP_es_inversa_por_la_derecha_de_la_funcion_cociente.lean\n-- La función relacionP es inversa por la derecha de la función cociente\n-- José A. Alonso Jiménez\n-- Sevilla, 14 de octubre de 2021\n-- ---------------------------------------------------------------------\n\n-- ---------------------------------------------------------------------\n-- Demostrar que relacionP es inversa por la derecha de cociente.\n-- ---------------------------------------------------------------------\n\nimport tactic\n\n@[ext] structure particion (A : Type) :=\n(Bloques    : set (set A))\n(Hno_vacios : ∀ X ∈ Bloques, (X : set A).nonempty)\n(Hrecubren  : ∀ a, ∃ X ∈ Bloques, a ∈ X)\n(Hdisjuntos : ∀ X Y ∈ Bloques, (X ∩ Y : set A).nonempty → X = Y)\n\nnamespace particion\n\nvariable  {A : Type}\nvariables {X Y : set A}\nvariable  {P : particion A}\nvariable  (R : A → A → Prop)\n\ndef clase (a : A) :=\n  {b : A | R b a}\n\ndef clases : (A → A → Prop) → set (set A) :=\n  λ R, {B : set A | ∃ x : A, B = clase R x}\n\nlemma pertenece_clase_syss\n  {a b : A}\n  : b ∈ clase R a ↔ R b a :=\nby refl\n\nlemma clases_no_vacias\n  (hR: equivalence R)\n  : ∀ (X : set A), X ∈ clases R → X.nonempty :=\nbegin\n  rintros _ ⟨a, rfl⟩,\n  use a,\n  rw pertenece_clase_syss,\n  apply hR.1,\nend\n\nlemma clases_recubren\n  (hR: equivalence R)\n  : ∀ a, ∃ X ∈ clases R, a ∈ X :=\nbegin\n  intro a,\n  use clase R a,\n  split,\n  { use a, },\n  { exact hR.1 a, },\nend\n\nlemma subclase_si_pertenece\n  {R : A → A → Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a ∈ clase R b → clase R a ⊆ clase R b :=\nλ hab z hza, hR.2.2 hza hab\n\nlemma clases_iguales_si_pertenece\n  {R : A → A → Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a ∈ clase R b → clase R a = clase R b :=\nλ hab, set.subset.antisymm\n        (subclase_si_pertenece hR hab)\n        (subclase_si_pertenece hR (hR.2.1 hab))\n\nlemma clases_disjuntas\n  (hR: equivalence R)\n  : ∀ X Y ∈ clases R, (X ∩ Y : set A).nonempty → X = Y :=\nbegin\n  rintros X ⟨a, rfl⟩ Y ⟨b, rfl⟩ ⟨c, hca, hcb⟩,\n  exact clases_iguales_si_pertenece hR (hR.2.2 (hR.2.1 hca) hcb),\nend\n\ndef cociente : {R : A → A → Prop // equivalence R} → particion A :=\n  λ R, { Bloques    := {B : set A | ∃ x : A, B = clase R.1 x},\n         Hno_vacios := clases_no_vacias R.1 R.2,\n         Hrecubren  := clases_recubren R.1 R.2,\n         Hdisjuntos := clases_disjuntas R.1 R.2, }\n\ndef relacion : (particion A) → (A → A → Prop) :=\n  λ P a b, ∀ X ∈ Bloques P, a ∈ X → b ∈ X\n\nlemma reflexiva\n  (P : particion A)\n  : reflexive (relacion P) :=\nλ a X hXC haX, haX\n\nlemma iguales_si_comun\n  (hX : X ∈ Bloques P)\n  (hY : Y ∈ Bloques P)\n  {a : A}\n  (haX : a ∈ X)\n  (haY : a ∈ Y)\n  : X = Y :=\nHdisjuntos P X hX Y hY ⟨a, haX, haY⟩\n\nlemma pertenece_si_pertenece\n  (hX : X ∈ Bloques P)\n  (hY : Y ∈ Bloques P)\n  {a b : A}\n  (haX : a ∈ X)\n  (haY : a ∈ Y)\n  (hbX : b ∈ X)\n  : b ∈ Y :=\nbegin\n  convert hbX,\n  exact iguales_si_comun hY hX haY haX,\nend\n\nlemma simetrica\n  (P : particion A)\n  : symmetric (relacion P) :=\nbegin\n  intros a b h X hX hbX,\n  obtain ⟨Y, hY, haY⟩ := Hrecubren P a,\n  specialize h Y hY haY,\n  exact pertenece_si_pertenece hY hX h hbX haY,\nend\n\nlemma transitiva\n  (P : particion A)\n  : transitive (relacion P) :=\nλ a b c hab hbc X hX haX, hbc X hX (hab X hX haX)\n\ndef relacionP : particion A → {R : A → A → Prop // equivalence R} :=\n  λ P, ⟨λ a b, ∀ X ∈ Bloques P, a ∈ X → b ∈ X,\n        ⟨reflexiva P, simetrica P, transitiva P⟩⟩\n\n-- 1ª demostración\nexample :\n  function.right_inverse relacionP (@cociente A) :=\nbegin\n  unfold function.right_inverse,\n  unfold function.left_inverse,\n  intro P,\n  ext X,\n  simp [cociente],\n  split,\n  { intro h,\n    cases h with a ha,\n    rw ha,\n    rcases Hrecubren P a with ⟨X, hX, haX⟩,\n    convert hX,\n    ext b,\n    rw pertenece_clase_syss,\n    split,\n    { intro hba,\n      rcases Hrecubren P b with ⟨Y, hY, hbY⟩,\n      specialize hba Y hY hbY,\n      convert hbY,\n      exact iguales_si_comun hX hY haX hba, },\n    { intros hbX Y hY hbY,\n      apply pertenece_si_pertenece hX hY hbX hbY haX, }},\n  { intro hX,\n    rcases Hno_vacios P X hX with ⟨a, ha⟩,\n    use a,\n    ext b,\n    split,\n    { intro hbX,\n      rw pertenece_clase_syss,\n      intros Y hY hbY,\n      exact pertenece_si_pertenece hX hY hbX hbY ha, },\n    { rw pertenece_clase_syss,\n      intro hba,\n      rcases Hrecubren P b with ⟨Y, hY, hbY⟩,\n      specialize hba Y hY hbY,\n      exact pertenece_si_pertenece hY hX hba ha hbY, }}\nend\n\n-- 2ª demostración\nlemma inversa_dcha :\n  function.right_inverse relacionP (@cociente A) :=\nbegin\n  intro P,\n  ext X,\n  show (∃ (a : A), X = clase _ a) ↔ X ∈ Bloques P,\n  split,\n  { rintro ⟨a, rfl⟩,\n    obtain ⟨X, hX, haX⟩ := Hrecubren P a,\n    convert hX,\n    ext b,\n    rw pertenece_clase_syss,\n    split,\n    { intro hba,\n      obtain ⟨Y, hY, hbY⟩ := Hrecubren P b,\n      specialize hba Y hY hbY,\n      convert hbY,\n      exact iguales_si_comun hX hY haX hba, },\n    { intros hbX Y hY hbY,\n      apply pertenece_si_pertenece hX hY hbX hbY haX, }},\n  { intro hX,\n    rcases Hno_vacios P X hX with ⟨a, ha⟩,\n    use a,\n    ext b,\n    split,\n    { intro hbX,\n      rw pertenece_clase_syss,\n      intros Y hY hbY,\n      exact pertenece_si_pertenece hX hY hbX hbY ha, },\n    { rw pertenece_clase_syss,\n      intro hba,\n      obtain ⟨Y, hY, hbY⟩ := Hrecubren P b,\n      specialize hba Y hY hbY,\n      exact pertenece_si_pertenece hY hX hba ha hbY, }}\nend\n\nend particion\n", "meta": {"author": "jaalonso", "repo": "Calculemus", "sha": "0fb664ab298c0e90b4b8034729a2cdad20503e18", "save_path": "github-repos/lean/jaalonso-Calculemus", "path": "github-repos/lean/jaalonso-Calculemus/Calculemus-0fb664ab298c0e90b4b8034729a2cdad20503e18/src/La_funcion_relacionP_es_inversa_por_la_derecha_de_la_funcion_cociente.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6859494678483918, "lm_q1q2_score": 0.47739225135279834}}
{"text": "import .lovelib\n\n\n/-! # LoVe Demo 6: Monads\n\nWe take a look at an important functional programming abstraction: monads.\nMonads generalize computation with side effects. Haskell has shown that monads\ncan be used very successful to write imperative programs. For us, they are\ninteresting in three ways:\n\n* They are a useful concept in their own right.\n\n* They provide a nice example of axiomatic reasoning.\n\n* They are useful for programming Lean itself (metaprogramming). -/\n\n\nset_option pp.beta true\n\nnamespace LoVe\n\n\n/-! ## Introductory Example\n\nConsider the following programming task:\n\n    Implement a function `sum_2_5_7 ns` that sums up the second, fifth, and\n    seventh items of a list `ns` of natural numbers. Use `option ℕ` for the\n    result so that if the list has fewer than seven elements, you can return\n    `option.none`.\n\nA straightforward solution follows: -/\n\ndef sum_2_5_7 (ns : list ℕ) : option ℕ :=\nmatch list.nth ns 1 with\n| option.none    := option.none\n| option.some n2 :=\n  match list.nth ns 4 with\n  | option.none    := option.none\n  | option.some n5 :=\n    match list.nth ns 6 with\n    | option.none    := option.none\n    | option.some n7 := option.some (n2 + n5 + n7)\n    end\n  end\nend\n\n/-! The code is ugly, because of all the pattern matching on options.\n\nWe can put all the ugliness in one function, which we call `bind_opt`: -/\n\ndef bind_opt {α : Type} {β : Type} :\n  option α → (α → option β) → option β\n| option.none     _ := option.none\n| (option.some a) f := f a\n\ndef sum_2_5_7₂ (ns : list ℕ) : option ℕ :=\nbind_opt (list.nth ns 1)\n  (λn2, bind_opt (list.nth ns 4)\n     (λn5, bind_opt (list.nth ns 6)\n        (λn7, option.some (n2 + n5 + n7))))\n\n/-! Instead of defining `bind_opt` ourselves, we can use Lean's predefined\ngeneral `bind` operation. We can also use `pure` instead of `option.some`: -/\n\n#check @bind\n\ndef sum_2_5_7₃ (ns : list ℕ) : option ℕ :=\nbind (list.nth ns 1)\n  (λn2, bind (list.nth ns 4)\n     (λn5, bind (list.nth ns 6)\n        (λn7, pure (n2 + n5 + n7))))\n\n/-! Syntactic sugar:\n\n    `ma >>= f` := `bind ma f` -/\n\n#check (>>=)\n\ndef sum_2_5_7₄ (ns : list ℕ) : option ℕ :=\nlist.nth ns 1 >>=\n  λn2, list.nth ns 4 >>=\n    λn5, list.nth ns 6 >>=\n      λn7, pure (n2 + n5 + n7)\n\n/-! Syntactic sugar:\n\n    `do a ← ma, t` := `ma >>= (λa, t)`\n    `do ma, t`     := `ma >>= (λ_, t)` -/\n\ndef sum_2_5_7₅ (ns : list ℕ) : option ℕ :=\ndo n2 ← list.nth ns 1,\n  do n5 ← list.nth ns 4,\n    do n7 ← list.nth ns 6,\n      pure (n2 + n5 + n7)\n\n/-! The `do`s can be combined: -/\n\ndef sum_2_5_7₆ (ns : list ℕ) : option ℕ :=\ndo\n  n2 ← list.nth ns 1,\n  n5 ← list.nth ns 4,\n  n7 ← list.nth ns 6,\n  pure (n2 + n5 + n7)\n\n/-! Although the notation has an imperative flavor, the function is a pure\nfunctional program.\n\n\n## Two Operations and Three Laws\n\nThe `option` type constructor is an example of a monad.\n\nIn general, a __monad__ is a type constructor `m` that depends on some type\nparameter `α` (i.e., `m α`) equipped with two distinguished operations:\n\n    `pure {α : Type} : α → m α`\n    `bind {α β : Type} : m α → (α → m β) → m β`\n\nFor `option`:\n\n    `pure` := `option.some`\n    `bind` := `bind_opt`\n\nIntuitively, we can think of a monad as a \"box\":\n\n* `pure` puts the data into the box.\n\n* `bind` allows us to access the data in the box and modify it (possibly even\n  changing its type, since the result is an `m β` monad, not a `m α` monad).\n\nThere is no general way to extract the data from the monad, i.e., to obtain an\n`α` from an `m α`.\n\nTo summarize, `pure a` provides no side effect and simply provides a box\ncontaining the the value `a`, whereas `bind ma f` (also written `ma >>= f`)\nexecutes `ma`, then executes `f` with the boxed result `a` of `ma`.\n\nThe option monad is only one instance among many.\n\nType         | Effect\n------------ | --------------------------------------------------------------\n`id α`       | no effect\n`option α`   | simple exceptions\n`σ → α × σ`  | threading through a state of type `σ`\n`set α`      | nondeterministic computation returning `α` values\n`t → α`      | reading elements of type `t` (e.g., a configuration)\n`ℕ × α`      | adjoining running time (e.g., to model algorithmic complexity)\n`string × α` | adjoining text output (e.g., for logging)\n`prob α`     | probability (e.g., using random number generators)\n`io α`       | interaction with the operating system\n`tactic α`   | interaction with the proof assistant\n\nAll of the above are type constructors `m` are parameterized by a type `α`.\n\nSome effects can be combined (e.g., `option (t → α)`).\n\nSome effects are not executable (e.g., `set α`, `prob α`). They are nonetheless\nuseful for modeling programs abstractly in the logic.\n\nSpecific monads may provide a way to extract the boxed value stored in the monad\nwithout `bind`'s requirement of putting it back in a monad.\n\nMonads have several benefits, including:\n\n* They provide the convenient and highly readable `do` notation.\n\n* They support generic operations, such as\n  `mmap {α β : Type} : (α → m β) → list α → m (list β)`, which work uniformly\n  across all monads.\n\nThe `bind` and `pure` operations are normally required to obey three laws,\ncalled the monad laws. Pure data as the first program can be simplified away:\n\n    do\n      a' ← pure a,\n      f a'\n  =\n    f a\n\nPure data as the second program can be simplified away:\n\n    do\n      a ← x,\n      pure a\n  =\n    x\n\nNested programs `x`, `f`, `g` can be linearized using this associativity rule:\n\n    do\n      b ← do {\n        a ← x,\n        f a },\n      g b\n  =\n    do\n      a ← x,\n      b ← f a,\n      g b\n\n\n## A Type Class of Monads\n\nMonads are a mathematical structure, so we use class to add them as a type class\n(lecture 12). We can think of a type class as a structure that is parameterized\nby a type—or here, by a type constructor `m : Type → Type`. -/\n\n@[class] structure lawful_monad (m : Type → Type)\n  extends has_bind m, has_pure m : Type 1 :=\n(pure_bind {α β : Type} (a : α) (f : α → m β) :\n   (pure a >>= f) = f a)\n(bind_pure {α : Type} (ma : m α) :\n   (ma >>= pure) = ma)\n(bind_assoc {α β γ : Type} (f : α → m β) (g : β → m γ)\n     (ma : m α) :\n   ((ma >>= f) >>= g) = (ma >>= (λa, f a >>= g)))\n\n#print monad\n#print is_lawful_monad\n\n\n/-! Step by step:\n\n* We are creating a structure parameterized by a unary type constructor `m`.\n\n* The structure inherits the fields, and any syntactic sugar, from structures\n  called `has_bind` and `has_pure`, which provide the `bind` and `pure`\n  operations on `m` and some syntactic sugar.\n\n* `Type 1` is necessary for reasons that will become clear in lecture 11.\n\n* The definition adds three fields to those already provided by `has_bind` and\n  `has_pure`, to store the proofs of the monad laws.\n\nTo instantiate this definition with a concrete monad, we must supply the type\nconstructor `m` (e.g., `option`), `bind` and `pure` operators, and\nproofs of the monad laws.\n\n(Lean's actual definition of monads is more complicated.)\n\n\n## Identity -/\n\n#check id\n\ndef id.pure {α : Type} : α → id α :=\nid\n\ndef id.bind {α β : Type} : id α → (α → id β) → id β\n| a f := f a\n\n@[instance] def id.lawful_monad : lawful_monad (@id Type) :=\n{ pure       := @id.pure,\n  bind       := @id.bind,\n  pure_bind  :=\n    begin\n      intros α β a f,\n      refl\n    end,\n  bind_pure  :=\n    begin\n      intros α m,\n      refl\n    end,\n  bind_assoc :=\n    begin\n      intros α β γ f g m,\n      refl\n    end\n}\n\n\n/-! ## Exceptions -/\n\ndef option.pure {α : Type} : α → option α :=\noption.some\n\ndef option.bind {α β : Type} :\n  option α → (α → option β) → option β\n| option.none     f := option.none\n| (option.some a) f := f a\n\n@[instance] def option.lawful_monad : lawful_monad option :=\n{ pure       := @option.pure,\n  bind       := @option.bind,\n  pure_bind  :=\n    begin\n      intros α β a f,\n      refl\n    end,\n  bind_pure  :=\n    begin\n      intros α m,\n      cases m,\n      { refl },\n      { refl }\n    end,\n  bind_assoc :=\n    begin\n      intros α β γ f g m,\n      cases m,\n      { refl },\n      { refl }\n    end }\n\ndef option.throw {α : Type} : option α :=\noption.none\n\ndef option.catch {α : Type} :\n  option α → option α → option α\n| option.none     ma' := ma'\n| (option.some a) _   := option.some a\n\n@[instance] def option.has_orelse : has_orelse option :=\n{ orelse := @option.catch }\n\n\n/-! ## Mutable State -/\n\ndef action (σ α : Type) :=\nσ → α × σ\n\ndef action.read {σ : Type} : action σ σ\n| s := (s, s)\n\ndef action.write {σ : Type} (s : σ) : action σ unit\n| _ := ((), s)\n\ndef action.pure {σ α : Type} (a : α) : action σ α\n| s := (a, s)\n\ndef action.bind {σ : Type} {α β : Type} (ma : action σ α)\n    (f : α → action σ β) :\n  action σ β\n| s :=\n  match ma s with\n  | (a, s') := f a s'\n  end\n\n@[instance] def action.lawful_monad {σ : Type} :\n  lawful_monad (action σ) :=\n{ pure       := @action.pure σ,\n  bind       := @action.bind σ,\n  pure_bind  :=\n    begin\n      intros α β a f,\n      apply funext,\n      intro s,\n      refl\n    end,\n  bind_pure  :=\n    begin\n      intros α m,\n      apply funext,\n      intro s,\n      simp [action.bind],\n      cases m s,\n      refl\n    end,\n  bind_assoc :=\n    begin\n      intros α β γ f g m,\n      apply funext,\n      intro s,\n      simp [action.bind],\n      cases m s,\n      refl\n    end }\n\ndef diff_list : list ℕ → action ℕ (list ℕ)\n| []        := pure []\n| (n :: ns) :=\n  do\n    prev ← action.read,\n    if n < prev then\n      diff_list ns\n    else\n      do\n        action.write n,\n        ns' ← diff_list ns,\n        pure (n :: ns')\n\n#eval diff_list [1, 2, 3, 2] 0\n#eval diff_list [1, 2, 3, 2, 4, 5, 2] 0\n\n\n/-! ## Nondeterminism -/\n\n#check set\n\ndef set.pure {α : Type} : α → set α\n| a := {a}\n\ndef set.bind {α β : Type} : set α → (α → set β) → set β\n| A f := {b | ∃a, a ∈ A ∧ b ∈ f a}\n\n@[instance] def set.lawful_monad : lawful_monad set :=\n{ pure       := @set.pure,\n  bind       := @set.bind,\n  pure_bind  :=\n    begin\n      intros α β a f,\n      simp [set.pure, set.bind]\n    end,\n  bind_pure  :=\n    begin\n      intros α m,\n      simp [set.pure, set.bind]\n    end,\n  bind_assoc :=\n    begin\n      intros α β γ f g m,\n      simp [set.pure, set.bind],\n      apply set.ext,\n      simp,\n      tautology\n    end }\n\n/-! `tautology` performs elimination of the logical symbols `∧`, `∨`, `↔`, and\n`∃` in hypotheses and introduction of `∧`, `↔`, and `∃` in the conclusion, until\nall the emerging subgoals can be trivially proved (e.g., by `refl`).\n\n\n## A Generic Algorithm: Iteration over a List -/\n\ndef mmap {m : Type → Type} [lawful_monad m] {α β : Type}\n    (f : α → m β) :\n  list α → m (list β)\n| []        := pure []\n| (a :: as) :=\n  do\n    b ← f a,\n    bs ← mmap as,\n    pure (b :: bs)\n\nlemma mmap_append {m : Type → Type} [lawful_monad m]\n    {α β : Type} (f : α → m β) :\n  ∀as as' : list α, mmap f (as ++ as') =\n    do\n      bs ← mmap f as,\n      bs' ← mmap f as',\n      pure (bs ++ bs')\n| []        _   :=\n  by simp [mmap, lawful_monad.bind_pure, lawful_monad.pure_bind]\n| (a :: as) as' :=\n  by simp [mmap, mmap_append as as', lawful_monad.pure_bind,\n    lawful_monad.bind_assoc]\n\ndef nths {α : Type} (xss : list (list α)) (n : ℕ) :\n  option (list α) :=\nmmap (λxs, list.nth xs n) xss\n\n#eval nths\n  [[11, 12, 13, 14],\n   [21, 22, 23],\n   [31, 32, 33]] 2\n\nend LoVe\n", "meta": {"author": "yizhou7", "repo": "learning-lean", "sha": "91fb366c624df6e56e19555b2e482ce767cd8224", "save_path": "github-repos/lean/yizhou7-learning-lean", "path": "github-repos/lean/yizhou7-learning-lean/learning-lean-91fb366c624df6e56e19555b2e482ce767cd8224/my_project/src/love06_monads_demo.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458153, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4773922468846766}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yaël Dillies\n-/\nimport order.partial_sups\n\n/-!\n# Consecutive differences of sets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the way to make a sequence of elements into a sequence of disjoint elements with\nthe same partial sups.\n\nFor a sequence `f : ℕ → α`, this new sequence will be `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 ⊔ f 1)`.\nIt is actually unique, as `disjointed_unique` shows.\n\n## Main declarations\n\n* `disjointed f`: The sequence `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 ⊔ f 1)`, ....\n* `partial_sups_disjointed`: `disjointed f` has the same partial sups as `f`.\n* `disjoint_disjointed`: The elements of `disjointed f` are pairwise disjoint.\n* `disjointed_unique`: `disjointed f` is the only pairwise disjoint sequence having the same partial\n  sups as `f`.\n* `supr_disjointed`: `disjointed f` has the same supremum as `f`. Limiting case of\n  `partial_sups_disjointed`.\n\nWe also provide set notation variants of some lemmas.\n\n## TODO\n\nFind a useful statement of `disjointed_rec_succ`.\n\nOne could generalize `disjointed` to any locally finite bot preorder domain, in place of `ℕ`.\nRelated to the TODO in the module docstring of `order.partial_sups`.\n-/\n\nvariables {α β : Type*}\n\nsection generalized_boolean_algebra\nvariables [generalized_boolean_algebra α]\n\n/-- If `f : ℕ → α` is a sequence of elements, then `disjointed f` is the sequence formed by\nsubtracting each element from the nexts. This is the unique disjoint sequence whose partial sups\nare the same as the original sequence. -/\ndef disjointed (f : ℕ → α) : ℕ → α\n| 0       := f 0\n| (n + 1) := f (n + 1) \\ (partial_sups f n)\n\n@[simp] lemma disjointed_zero (f : ℕ → α) : disjointed f 0 = f 0 := rfl\n\nlemma disjointed_succ (f : ℕ → α) (n : ℕ) :\n  disjointed f (n + 1) = f (n + 1) \\ (partial_sups f n) :=\nrfl\n\nlemma disjointed_le_id : disjointed ≤ (id : (ℕ → α) → ℕ → α) :=\nbegin\n  rintro f n,\n  cases n,\n  { refl },\n  { exact sdiff_le }\nend\n\nlemma disjointed_le (f : ℕ → α) : disjointed f ≤ f := disjointed_le_id f\n\nlemma disjoint_disjointed (f : ℕ → α) : pairwise (disjoint on disjointed f) :=\nbegin\n  refine (symmetric.pairwise_on disjoint.symm _).2 (λ m n h, _),\n  cases n,\n  { exact (nat.not_lt_zero _ h).elim },\n  exact disjoint_sdiff_self_right.mono_left ((disjointed_le f m).trans\n    (le_partial_sups_of_le f (nat.lt_add_one_iff.1 h))),\nend\n\n/-- An induction principle for `disjointed`. To define/prove something on `disjointed f n`, it's\nenough to define/prove it for `f n` and being able to extend through diffs. -/\ndef disjointed_rec {f : ℕ → α} {p : α → Sort*} (hdiff : ∀ ⦃t i⦄, p t → p (t \\ f i)) :\n  ∀ ⦃n⦄, p (f n) → p (disjointed f n)\n| 0       := id\n| (n + 1) := λ h,\n  begin\n    suffices H : ∀ k, p (f (n + 1) \\ partial_sups f k),\n    { exact H n },\n    rintro k,\n    induction k with k ih,\n    { exact hdiff h },\n    rw [partial_sups_succ, ←sdiff_sdiff_left],\n    exact hdiff ih,\n  end\n\n@[simp] lemma disjointed_rec_zero {f : ℕ → α} {p : α → Sort*} (hdiff : ∀ ⦃t i⦄, p t → p (t \\ f i))\n  (h₀ : p (f 0)) :\n  disjointed_rec hdiff h₀ = h₀ := rfl\n\n-- TODO: Find a useful statement of `disjointed_rec_succ`.\n\nlemma monotone.disjointed_eq {f : ℕ → α} (hf : monotone f) (n : ℕ) :\n  disjointed f (n + 1) = f (n + 1) \\ f n :=\nby rw [disjointed_succ, hf.partial_sups_eq]\n\n@[simp] lemma partial_sups_disjointed (f : ℕ → α) :\n  partial_sups (disjointed f) = partial_sups f :=\nbegin\n  ext n,\n  induction n with k ih,\n  { rw [partial_sups_zero, partial_sups_zero, disjointed_zero] },\n  { rw [partial_sups_succ, partial_sups_succ, disjointed_succ, ih, sup_sdiff_self_right] }\nend\n\n/-- `disjointed f` is the unique sequence that is pairwise disjoint and has the same partial sups\nas `f`. -/\nlemma disjointed_unique {f d : ℕ → α} (hdisj : pairwise (disjoint on d))\n  (hsups : partial_sups d = partial_sups f) : d = disjointed f :=\nbegin\n  ext n,\n  cases n,\n  { rw [←partial_sups_zero d, hsups, partial_sups_zero, disjointed_zero] },\n  suffices h : d n.succ = partial_sups d n.succ \\ partial_sups d n,\n  { rw [h, hsups, partial_sups_succ, disjointed_succ, sup_sdiff, sdiff_self, bot_sup_eq] },\n  rw [partial_sups_succ, sup_sdiff, sdiff_self, bot_sup_eq, eq_comm, sdiff_eq_self_iff_disjoint],\n  suffices h : ∀ m ≤ n, disjoint (partial_sups d m) (d n.succ),\n  { exact h n le_rfl },\n  rintro m hm,\n  induction m with m ih,\n  { exact hdisj (nat.succ_ne_zero _).symm },\n  rw [partial_sups_succ, disjoint_iff, inf_sup_right, sup_eq_bot_iff, ←disjoint_iff, ←disjoint_iff],\n  exact ⟨ih (nat.le_of_succ_le hm), hdisj (nat.lt_succ_of_le hm).ne⟩,\nend\n\nend generalized_boolean_algebra\n\nsection complete_boolean_algebra\nvariables [complete_boolean_algebra α]\n\nlemma supr_disjointed (f : ℕ → α) : (⨆ n, disjointed f n) = (⨆ n, f n) :=\nsupr_eq_supr_of_partial_sups_eq_partial_sups (partial_sups_disjointed f)\n\nlemma disjointed_eq_inf_compl (f : ℕ → α) (n : ℕ) :\n  disjointed f n = f n ⊓ (⨅ i < n, (f i)ᶜ) :=\nbegin\n  cases n,\n  { rw [disjointed_zero, eq_comm, inf_eq_left],\n    simp_rw le_infi_iff,\n    exact λ i hi, (i.not_lt_zero hi).elim },\n  simp_rw [disjointed_succ, partial_sups_eq_bsupr, sdiff_eq, compl_supr],\n  congr,\n  ext i,\n  rw nat.lt_succ_iff,\nend\n\nend complete_boolean_algebra\n\n/-! ### Set notation variants of lemmas -/\n\nlemma disjointed_subset (f : ℕ → set α) (n : ℕ) : disjointed f n ⊆ f n :=\ndisjointed_le f n\n\nlemma Union_disjointed {f : ℕ → set α} : (⋃ n, disjointed f n) = (⋃ n, f n) :=\nsupr_disjointed f\n\nlemma disjointed_eq_inter_compl (f : ℕ → set α) (n : ℕ) :\n  disjointed f n = f n ∩ (⋂ i < n, (f i)ᶜ) :=\ndisjointed_eq_inf_compl f n\n\nlemma preimage_find_eq_disjointed (s : ℕ → set α) (H : ∀ x, ∃ n, x ∈ s n)\n  [∀ x n, decidable (x ∈ s n)] (n : ℕ) :\n  (λ x, nat.find (H x)) ⁻¹' {n} = disjointed s n :=\nby { ext x, simp [nat.find_eq_iff, disjointed_eq_inter_compl] }\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/order/disjointed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494678483918, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.4773922427013549}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.field_theory.subfield\nimport Mathlib.field_theory.tower\nimport Mathlib.ring_theory.algebraic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 \n\nnamespace Mathlib\n\n/-!\n# Intermediate fields\n\nLet `L / K` be a field extension, given as an instance `algebra K L`.\nThis file defines the type of fields in between `K` and `L`, `intermediate_field K L`.\nAn `intermediate_field K L` is a subfield of `L` which contains (the image of) `K`,\ni.e. it is a `subfield L` and a `subalgebra K L`.\n\n## Main definitions\n\n * `intermediate_field K L` : the type of intermediate fields between `K` and `L`.\n\n * `subalgebra.to_intermediate_field`: turns a subalgebra closed under `⁻¹`\n   into an intermediate field\n\n * `subfield.to_intermediate_field`: turns a subfield containing the image of `K`\n   into an intermediate field\n\n* `intermediate_field.map`: map an intermediate field along an `alg_hom`\n\n## Implementation notes\n\nIntermediate fields are defined with a structure extending `subfield` and `subalgebra`.\nA `subalgebra` is closed under all operations except `⁻¹`,\n\n## Tags\nintermediate field, field extension\n-/\n\n/-- `S : intermediate_field K L` is a subset of `L` such that there is a field\ntower `L / S / K`. -/\nstructure intermediate_field (K : Type u_1) (L : Type u_2) [field K] [field L] [algebra K L] \nextends subalgebra K L, subfield L\nwhere\n\n/-- Reinterpret an `intermediate_field` as a `subalgebra`. -/\n/-- Reinterpret an `intermediate_field` as a `subfield`. -/\nnamespace intermediate_field\n\n\nprotected instance set.has_coe {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] : has_coe (intermediate_field K L) (set L) :=\n  has_coe.mk carrier\n\n@[simp] theorem coe_to_subalgebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : ↑(to_subalgebra S) = ↑S :=\n  rfl\n\n@[simp] theorem coe_to_subfield {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : ↑(to_subfield S) = ↑S :=\n  rfl\n\nprotected instance has_coe_to_sort {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] : has_coe_to_sort (intermediate_field K L) :=\n  has_coe_to_sort.mk (Type u_2) fun (S : intermediate_field K L) => ↥(carrier S)\n\nprotected instance has_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] : has_mem L (intermediate_field K L) :=\n  has_mem.mk fun (m : L) (S : intermediate_field K L) => m ∈ ↑S\n\n@[simp] theorem mem_mk {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (s : set L) (hK : ∀ (x : K), coe_fn (algebra_map K L) x ∈ s) (ho : 1 ∈ s) (hm : ∀ {a b : L}, a ∈ s → b ∈ s → a * b ∈ s) (hz : 0 ∈ s) (ha : ∀ {a b : L}, a ∈ s → b ∈ s → a + b ∈ s) (hn : ∀ {x : L}, x ∈ s → -x ∈ s) (hi : ∀ (x : L), x ∈ s → x⁻¹ ∈ s) (x : L) : x ∈ mk s ho hm hz ha hK hn hi ↔ x ∈ s :=\n  iff.rfl\n\n@[simp] theorem mem_coe {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (x : L) : x ∈ ↑S ↔ x ∈ S :=\n  iff.rfl\n\n@[simp] theorem mem_to_subalgebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (s : intermediate_field K L) (x : L) : x ∈ to_subalgebra s ↔ x ∈ s :=\n  iff.rfl\n\n@[simp] theorem mem_to_subfield {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (s : intermediate_field K L) (x : L) : x ∈ to_subfield s ↔ x ∈ s :=\n  iff.rfl\n\n/-- Two intermediate fields are equal if the underlying subsets are equal. -/\ntheorem ext' {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {s : intermediate_field K L} {t : intermediate_field K L} (h : ↑s = ↑t) : s = t := sorry\n\n/-- Two intermediate fields are equal if and only if the underlying subsets are equal. -/\nprotected theorem ext'_iff {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {s : intermediate_field K L} {t : intermediate_field K L} : s = t ↔ ↑s = ↑t :=\n  { mp := fun (h : s = t) => h ▸ rfl, mpr := fun (h : ↑s = ↑t) => ext' h }\n\n/-- Two intermediate fields are equal if they have the same elements. -/\ntheorem ext {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {S : intermediate_field K L} {T : intermediate_field K L} (h : ∀ (x : L), x ∈ S ↔ x ∈ T) : S = T :=\n  ext' (set.ext h)\n\n/-- An intermediate field contains the image of the smaller field. -/\ntheorem algebra_map_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (x : K) : coe_fn (algebra_map K L) x ∈ S :=\n  algebra_map_mem' S x\n\n/-- An intermediate field contains the ring's 1. -/\ntheorem one_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : 1 ∈ S :=\n  one_mem' S\n\n/-- An intermediate field contains the ring's 0. -/\ntheorem zero_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : 0 ∈ S :=\n  zero_mem' S\n\n/-- An intermediate field is closed under multiplication. -/\ntheorem mul_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} {y : L} : x ∈ S → y ∈ S → x * y ∈ S :=\n  mul_mem' S\n\n/-- An intermediate field is closed under scalar multiplication. -/\ntheorem smul_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {y : L} : y ∈ S → ∀ {x : K}, x • y ∈ S :=\n  subalgebra.smul_mem (to_subalgebra S)\n\n/-- An intermediate field is closed under addition. -/\ntheorem add_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} {y : L} : x ∈ S → y ∈ S → x + y ∈ S :=\n  add_mem' S\n\n/-- An intermediate field is closed under subtraction -/\ntheorem sub_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} {y : L} (hx : x ∈ S) (hy : y ∈ S) : x - y ∈ S :=\n  subfield.sub_mem (to_subfield S) hx hy\n\n/-- An intermediate field is closed under negation. -/\ntheorem neg_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} : x ∈ S → -x ∈ S :=\n  neg_mem' S\n\n/-- An intermediate field is closed under inverses. -/\ntheorem inv_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} : x ∈ S → x⁻¹ ∈ S :=\n  inv_mem' S\n\n/-- An intermediate field is closed under division. -/\ntheorem div_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} {y : L} (hx : x ∈ S) (hy : y ∈ S) : x / y ∈ S :=\n  subfield.div_mem (to_subfield S) hx hy\n\n/-- Product of a list of elements in an intermediate_field is in the intermediate_field. -/\ntheorem list_prod_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {l : List L} : (∀ (x : L), x ∈ l → x ∈ S) → list.prod l ∈ S :=\n  subfield.list_prod_mem (to_subfield S)\n\n/-- Sum of a list of elements in an intermediate field is in the intermediate_field. -/\ntheorem list_sum_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {l : List L} : (∀ (x : L), x ∈ l → x ∈ S) → list.sum l ∈ S :=\n  subfield.list_sum_mem (to_subfield S)\n\n/-- Product of a multiset of elements in an intermediate field is in the intermediate_field. -/\ntheorem multiset_prod_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (m : multiset L) : (∀ (a : L), a ∈ m → a ∈ S) → multiset.prod m ∈ S :=\n  subfield.multiset_prod_mem (to_subfield S) m\n\n/-- Sum of a multiset of elements in a `intermediate_field` is in the `intermediate_field`. -/\ntheorem multiset_sum_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (m : multiset L) : (∀ (a : L), a ∈ m → a ∈ S) → multiset.sum m ∈ S :=\n  subfield.multiset_sum_mem (to_subfield S) m\n\n/-- Product of elements of an intermediate field indexed by a `finset` is in the intermediate_field. -/\ntheorem prod_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {ι : Type u_3} {t : finset ι} {f : ι → L} (h : ∀ (c : ι), c ∈ t → f c ∈ S) : (finset.prod t fun (i : ι) => f i) ∈ S :=\n  subfield.prod_mem (to_subfield S) h\n\n/-- Sum of elements in a `intermediate_field` indexed by a `finset` is in the `intermediate_field`. -/\ntheorem sum_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {ι : Type u_3} {t : finset ι} {f : ι → L} (h : ∀ (c : ι), c ∈ t → f c ∈ S) : (finset.sum t fun (i : ι) => f i) ∈ S :=\n  subfield.sum_mem (to_subfield S) h\n\ntheorem pow_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} (hx : x ∈ S) (n : ℤ) : x ^ n ∈ S :=\n  int.cases_on n (fun (n : ℕ) => is_submonoid.pow_mem hx)\n    fun (n : ℕ) => subfield.inv_mem (to_subfield S) (is_submonoid.pow_mem hx)\n\ntheorem gsmul_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} (hx : x ∈ S) (n : ℤ) : n •ℤ x ∈ S :=\n  subfield.gsmul_mem (to_subfield S) hx n\n\ntheorem coe_int_mem {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (n : ℤ) : ↑n ∈ S := sorry\n\nend intermediate_field\n\n\n/-- Turn a subalgebra closed under inverses into an intermediate field -/\ndef subalgebra.to_intermediate_field {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : subalgebra K L) (inv_mem : ∀ (x : L), x ∈ S → x⁻¹ ∈ S) : intermediate_field K L :=\n  intermediate_field.mk (subalgebra.carrier S) sorry sorry sorry sorry sorry sorry inv_mem\n\n@[simp] theorem to_subalgebra_to_intermediate_field {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : subalgebra K L) (inv_mem : ∀ (x : L), x ∈ S → x⁻¹ ∈ S) : intermediate_field.to_subalgebra (subalgebra.to_intermediate_field S inv_mem) = S :=\n  subalgebra.ext\n    fun (x : L) => iff.refl (x ∈ intermediate_field.to_subalgebra (subalgebra.to_intermediate_field S inv_mem))\n\n@[simp] theorem to_intermediate_field_to_subalgebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (inv_mem : ∀ (x : L), x ∈ intermediate_field.to_subalgebra S → x⁻¹ ∈ S) : subalgebra.to_intermediate_field (intermediate_field.to_subalgebra S) inv_mem = S :=\n  intermediate_field.ext\n    fun (x : L) => iff.refl (x ∈ subalgebra.to_intermediate_field (intermediate_field.to_subalgebra S) inv_mem)\n\n/-- Turn a subfield of `L` containing the image of `K` into an intermediate field -/\ndef subfield.to_intermediate_field {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : subfield L) (algebra_map_mem : ∀ (x : K), coe_fn (algebra_map K L) x ∈ S) : intermediate_field K L :=\n  intermediate_field.mk (subfield.carrier S) (subfield.one_mem' S) (subfield.mul_mem' S) (subfield.zero_mem' S)\n    (subfield.add_mem' S) algebra_map_mem (subfield.neg_mem' S) (subfield.inv_mem' S)\n\nnamespace intermediate_field\n\n\n/-- An intermediate field inherits a field structure -/\nprotected instance to_field {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : field ↥S :=\n  subfield.to_field (to_subfield S)\n\n@[simp] theorem coe_add {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (x : ↥S) (y : ↥S) : ↑(x + y) = ↑x + ↑y :=\n  rfl\n\n@[simp] theorem coe_neg {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (x : ↥S) : ↑(-x) = -↑x :=\n  rfl\n\n@[simp] theorem coe_mul {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (x : ↥S) (y : ↥S) : ↑(x * y) = ↑x * ↑y :=\n  rfl\n\n@[simp] theorem coe_inv {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) (x : ↥S) : ↑(x⁻¹) = (↑x⁻¹) :=\n  rfl\n\n@[simp] theorem coe_zero {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : ↑0 = 0 :=\n  rfl\n\n@[simp] theorem coe_one {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : ↑1 = 1 :=\n  rfl\n\nprotected instance algebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : algebra K ↥S :=\n  subalgebra.algebra (to_subalgebra S)\n\nprotected instance to_algebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : algebra (↥S) L :=\n  subalgebra.to_algebra (to_subalgebra S)\n\nprotected instance is_scalar_tower {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : is_scalar_tower K (↥S) L :=\n  is_scalar_tower.subalgebra' K L L (to_subalgebra S)\n\n/-- If `f : L →+* L'` fixes `K`, `S.map f` is the intermediate field between `L'` and `K`\nsuch that `x ∈ S ↔ f x ∈ S.map f`. -/\ndef map {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {L' : Type u_3} [field L'] [algebra K L'] (f : alg_hom K L L') : intermediate_field K L' :=\n  mk (subalgebra.carrier (subalgebra.map (to_subalgebra S) f)) sorry sorry sorry sorry sorry sorry sorry\n\n/-- The embedding from an intermediate field of `L / K` to `L`. -/\ndef val {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : alg_hom K (↥S) L :=\n  subalgebra.val (to_subalgebra S)\n\n@[simp] theorem coe_val {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : ⇑(val S) = coe :=\n  rfl\n\n@[simp] theorem val_mk {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) {x : L} (hx : x ∈ S) : coe_fn (val S) { val := x, property := hx } = x :=\n  rfl\n\ntheorem to_subalgebra_injective {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {S : intermediate_field K L} {S' : intermediate_field K L} (h : to_subalgebra S = to_subalgebra S') : S = S' := sorry\n\nprotected instance partial_order {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] : partial_order (intermediate_field K L) :=\n  partial_order.mk (fun (S T : intermediate_field K L) => ↑S ⊆ ↑T)\n    (preorder.lt._default fun (S T : intermediate_field K L) => ↑S ⊆ ↑T) sorry sorry sorry\n\ntheorem set_range_subset {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : set.range ⇑(algebra_map K L) ⊆ ↑S :=\n  subalgebra.range_subset (to_subalgebra S)\n\ntheorem field_range_le {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (S : intermediate_field K L) : ring_hom.field_range (algebra_map K L) ≤ to_subfield S := sorry\n\n@[simp] theorem to_subalgebra_le_to_subalgebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {S : intermediate_field K L} {S' : intermediate_field K L} : to_subalgebra S ≤ to_subalgebra S' ↔ S ≤ S' :=\n  iff.rfl\n\n@[simp] theorem to_subalgebra_lt_to_subalgebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {S : intermediate_field K L} {S' : intermediate_field K L} : to_subalgebra S < to_subalgebra S' ↔ S < S' :=\n  iff.rfl\n\n/-- Lift an intermediate_field of an intermediate_field -/\ndef lift1 {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} (E : intermediate_field K ↥F) : intermediate_field K L :=\n  map E (val F)\n\n/-- Lift an intermediate_field of an intermediate_field -/\ndef lift2 {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} (E : intermediate_field (↥F) L) : intermediate_field K L :=\n  mk (carrier E) sorry sorry sorry sorry sorry sorry sorry\n\nprotected instance has_lift1 {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} : has_lift_t (intermediate_field K ↥F) (intermediate_field K L) :=\n  has_lift_t.mk lift1\n\nprotected instance has_lift2 {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} : has_lift_t (intermediate_field (↥F) L) (intermediate_field K L) :=\n  has_lift_t.mk lift2\n\n@[simp] theorem mem_lift2 {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field (↥F) L} {x : L} : x ∈ ↑E ↔ x ∈ E :=\n  iff.rfl\n\nprotected instance lift2_alg {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field (↥F) L} : algebra K ↥E :=\n  algebra.mk (ring_hom.mk ⇑(ring_hom.comp (algebra_map ↥F ↥E) (algebra_map K ↥F)) sorry sorry sorry sorry) sorry sorry\n\nprotected instance lift2_tower {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field (↥F) L} : is_scalar_tower K ↥F ↥E := sorry\n\n/-- `lift2` is isomorphic to the original `intermediate_field`. -/\ndef lift2_alg_equiv {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} (E : intermediate_field (↥F) L) : alg_equiv K ↥↑E ↥E :=\n  alg_equiv.mk (fun (x : ↥↑E) => x) (fun (x : ↥E) => x) sorry sorry sorry sorry sorry\n\nprotected instance finite_dimensional_left {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (F : intermediate_field K L) [finite_dimensional K L] : finite_dimensional K ↥F :=\n  finite_dimensional.finite_dimensional_submodule (subalgebra.to_submodule (to_subalgebra F))\n\nprotected instance finite_dimensional_right {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (F : intermediate_field K L) [finite_dimensional K L] : finite_dimensional (↥F) L :=\n  finite_dimensional.right K (↥F) L\n\n@[simp] theorem dim_eq_dim_subalgebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (F : intermediate_field K L) : vector_space.dim K ↥(to_subalgebra F) = vector_space.dim K ↥F :=\n  rfl\n\n@[simp] theorem findim_eq_findim_subalgebra {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (F : intermediate_field K L) : finite_dimensional.findim K ↥(to_subalgebra F) = finite_dimensional.findim K ↥F :=\n  rfl\n\n@[simp] theorem to_subalgebra_eq_iff {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field K L} : to_subalgebra F = to_subalgebra E ↔ F = E := sorry\n\ntheorem eq_of_le_of_findim_le {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field K L} [finite_dimensional K L] (h_le : F ≤ E) (h_findim : finite_dimensional.findim K ↥E ≤ finite_dimensional.findim K ↥F) : F = E := sorry\n\ntheorem eq_of_le_of_findim_eq {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field K L} [finite_dimensional K L] (h_le : F ≤ E) (h_findim : finite_dimensional.findim K ↥F = finite_dimensional.findim K ↥E) : F = E :=\n  eq_of_le_of_findim_le h_le (eq.ge h_findim)\n\ntheorem eq_of_le_of_findim_le' {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field K L} [finite_dimensional K L] (h_le : F ≤ E) (h_findim : finite_dimensional.findim (↥F) L ≤ finite_dimensional.findim (↥E) L) : F = E := sorry\n\ntheorem eq_of_le_of_findim_eq' {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] {F : intermediate_field K L} {E : intermediate_field K L} [finite_dimensional K L] (h_le : F ≤ E) (h_findim : finite_dimensional.findim (↥F) L = finite_dimensional.findim (↥E) L) : F = E :=\n  eq_of_le_of_findim_le' h_le (eq.le h_findim)\n\nend intermediate_field\n\n\n/-- If `L/K` is algebraic, the `K`-subalgebras of `L` are all fields.  -/\ndef subalgebra_equiv_intermediate_field {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (alg : algebra.is_algebraic K L) : subalgebra K L ≃o intermediate_field K L :=\n  rel_iso.mk\n    (equiv.mk (fun (S : subalgebra K L) => subalgebra.to_intermediate_field S sorry)\n      (fun (S : intermediate_field K L) => intermediate_field.to_subalgebra S) sorry sorry)\n    sorry\n\n@[simp] theorem mem_subalgebra_equiv_intermediate_field {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (alg : algebra.is_algebraic K L) {S : subalgebra K L} {x : L} : x ∈ coe_fn (subalgebra_equiv_intermediate_field alg) S ↔ x ∈ S :=\n  iff.rfl\n\n@[simp] theorem mem_subalgebra_equiv_intermediate_field_symm {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] (alg : algebra.is_algebraic K L) {S : intermediate_field K L} {x : L} : x ∈ coe_fn (order_iso.symm (subalgebra_equiv_intermediate_field alg)) S ↔ x ∈ S :=\n  iff.rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/field_theory/intermediate_field.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.47739223376511136}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module logic.equiv.option\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Control.EquivFunctor\nimport Mathbin.Data.Option.Basic\nimport Mathbin.Data.Subtype\nimport Mathbin.Logic.Equiv.Defs\n\n/-!\n# Equivalences for `option α`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n\nWe define\n* `equiv.option_congr`: the `option α ≃ option β` constructed from `e : α ≃ β` by sending `none` to\n  `none`, and applying a `e` elsewhere.\n* `equiv.remove_none`: the `α ≃ β` constructed from `option α ≃ option β` by removing `none` from\n  both sides.\n-/\n\n\nnamespace Equiv\n\nopen Option\n\nvariable {α β γ : Type _}\n\nsection OptionCongr\n\n#print Equiv.optionCongr /-\n/-- A universe-polymorphic version of `equiv_functor.map_equiv option e`. -/\n@[simps apply]\ndef optionCongr (e : α ≃ β) : Option α ≃ Option β\n    where\n  toFun := Option.map e\n  invFun := Option.map e.symm\n  left_inv x := (Option.map_map _ _ _).trans <| e.symm_comp_self.symm ▸ congr_fun Option.map_id x\n  right_inv x := (Option.map_map _ _ _).trans <| e.self_comp_symm.symm ▸ congr_fun Option.map_id x\n#align equiv.option_congr Equiv.optionCongr\n-/\n\n#print Equiv.optionCongr_refl /-\n@[simp]\ntheorem optionCongr_refl : optionCongr (Equiv.refl α) = Equiv.refl _ :=\n  ext <| congr_fun Option.map_id\n#align equiv.option_congr_refl Equiv.optionCongr_refl\n-/\n\n/- warning: equiv.option_congr_symm -> Equiv.optionCongr_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (e : Equiv.{succ u1, succ u2} α β), Eq.{max 1 (max (succ u2) (succ u1)) (succ u1) (succ u2)} (Equiv.{succ u2, succ u1} (Option.{u2} β) (Option.{u1} α)) (Equiv.symm.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β) (Equiv.optionCongr.{u1, u2} α β e)) (Equiv.optionCongr.{u2, u1} β α (Equiv.symm.{succ u1, succ u2} α β e))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (e : Equiv.{succ u2, succ u1} α β), Eq.{max (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} (Option.{u1} β) (Option.{u2} α)) (Equiv.symm.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β) (Equiv.optionCongr.{u2, u1} α β e)) (Equiv.optionCongr.{u1, u2} β α (Equiv.symm.{succ u2, succ u1} α β e))\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_symm Equiv.optionCongr_symmₓ'. -/\n@[simp]\ntheorem optionCongr_symm (e : α ≃ β) : (optionCongr e).symm = optionCongr e.symm :=\n  rfl\n#align equiv.option_congr_symm Equiv.optionCongr_symm\n\n/- warning: equiv.option_congr_trans -> Equiv.optionCongr_trans is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (e₁ : Equiv.{succ u1, succ u2} α β) (e₂ : Equiv.{succ u2, succ u3} β γ), Eq.{max 1 (max (succ u1) (succ u3)) (succ u3) (succ u1)} (Equiv.{succ u1, succ u3} (Option.{u1} α) (Option.{u3} γ)) (Equiv.trans.{succ u1, succ u2, succ u3} (Option.{u1} α) (Option.{u2} β) (Option.{u3} γ) (Equiv.optionCongr.{u1, u2} α β e₁) (Equiv.optionCongr.{u2, u3} β γ e₂)) (Equiv.optionCongr.{u1, u3} α γ (Equiv.trans.{succ u1, succ u2, succ u3} α β γ e₁ e₂))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (e₁ : Equiv.{succ u3, succ u2} α β) (e₂ : Equiv.{succ u2, succ u1} β γ), Eq.{max (succ u3) (succ u1)} (Equiv.{succ u3, succ u1} (Option.{u3} α) (Option.{u1} γ)) (Equiv.trans.{succ u3, succ u2, succ u1} (Option.{u3} α) (Option.{u2} β) (Option.{u1} γ) (Equiv.optionCongr.{u3, u2} α β e₁) (Equiv.optionCongr.{u2, u1} β γ e₂)) (Equiv.optionCongr.{u3, u1} α γ (Equiv.trans.{succ u3, succ u2, succ u1} α β γ e₁ e₂))\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_trans Equiv.optionCongr_transₓ'. -/\n@[simp]\ntheorem optionCongr_trans (e₁ : α ≃ β) (e₂ : β ≃ γ) :\n    (optionCongr e₁).trans (optionCongr e₂) = optionCongr (e₁.trans e₂) :=\n  ext <| Option.map_map _ _\n#align equiv.option_congr_trans Equiv.optionCongr_trans\n\n/- warning: equiv.option_congr_eq_equiv_function_map_equiv -> Equiv.optionCongr_eq_equivFunctor_mapEquiv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u1}} (e : Equiv.{succ u1, succ u1} α β), Eq.{succ u1} (Equiv.{succ u1, succ u1} (Option.{u1} α) (Option.{u1} β)) (Equiv.optionCongr.{u1, u1} α β e) (EquivFunctor.mapEquiv.{u1, u1} Option.{u1} (EquivFunctor.ofLawfulFunctor.{u1, u1} Option.{u1} (Applicative.toFunctor.{u1, u1} Option.{u1} (Monad.toApplicative.{u1, u1} Option.{u1} Option.monad.{u1})) (LawfulApplicative.to_lawfulFunctor.{u1, u1} Option.{u1} (Monad.toApplicative.{u1, u1} Option.{u1} Option.monad.{u1}) (LawfulMonad.to_lawfulApplicative.{u1, u1} Option.{u1} Option.monad.{u1} Option.lawfulMonad.{u1}))) α β e)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u1}} (e : Equiv.{succ u1, succ u1} α β), Eq.{succ u1} (Equiv.{succ u1, succ u1} (Option.{u1} α) (Option.{u1} β)) (Equiv.optionCongr.{u1, u1} α β e) (EquivFunctor.mapEquiv.{u1, u1} Option.{u1} (EquivFunctor.ofLawfulFunctor.{u1, u1} Option.{u1} instFunctorOption.{u1} instLawfulFunctorOptionInstFunctorOption.{u1}) α β e)\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_eq_equiv_function_map_equiv Equiv.optionCongr_eq_equivFunctor_mapEquivₓ'. -/\n/-- When `α` and `β` are in the same universe, this is the same as the result of\n`equiv_functor.map_equiv`. -/\ntheorem optionCongr_eq_equivFunctor_mapEquiv {α β : Type _} (e : α ≃ β) :\n    optionCongr e = EquivFunctor.mapEquiv Option e :=\n  rfl\n#align equiv.option_congr_eq_equiv_function_map_equiv Equiv.optionCongr_eq_equivFunctor_mapEquiv\n\nend OptionCongr\n\nsection RemoveNone\n\nvariable (e : Option α ≃ Option β)\n\nprivate def remove_none_aux (x : α) : β :=\n  if h : (e (some x)).isSome then Option.get h\n  else\n    Option.get <|\n      show (e none).isSome by\n        rw [← Option.ne_none_iff_isSome]\n        intro hn\n        rw [Option.not_isSome_iff_eq_none, ← hn] at h\n        simpa only using e.injective h\n#align equiv.remove_none_aux equiv.remove_none_aux\n\nprivate theorem remove_none_aux_some {x : α} (h : ∃ x', e (some x) = some x') :\n    some (removeNoneAux e x) = e (some x) := by\n  simp [remove_none_aux, option.is_some_iff_exists.mpr h]\n#align equiv.remove_none_aux_some equiv.remove_none_aux_some\n\nprivate theorem remove_none_aux_none {x : α} (h : e (some x) = none) :\n    some (removeNoneAux e x) = e none := by\n  simp [remove_none_aux, option.not_is_some_iff_eq_none.mpr h]\n#align equiv.remove_none_aux_none equiv.remove_none_aux_none\n\nprivate theorem remove_none_aux_inv (x : α) : removeNoneAux e.symm (removeNoneAux e x) = x :=\n  Option.some_injective _\n    (by\n      cases h1 : e.symm (some (remove_none_aux e x)) <;> cases h2 : e (some x)\n      · rw [remove_none_aux_none _ h1]\n        exact (e.eq_symm_apply.mpr h2).symm\n      · rw [remove_none_aux_some _ ⟨_, h2⟩] at h1\n        simpa using h1\n      · rw [remove_none_aux_none _ h2] at h1\n        simpa using h1\n      · rw [remove_none_aux_some _ ⟨_, h1⟩]\n        rw [remove_none_aux_some _ ⟨_, h2⟩]\n        simp)\n#align equiv.remove_none_aux_inv equiv.remove_none_aux_inv\n\n#print Equiv.removeNone /-\n/-- Given an equivalence between two `option` types, eliminate `none` from that equivalence by\nmapping `e.symm none` to `e none`. -/\ndef removeNone : α ≃ β where\n  toFun := removeNoneAux e\n  invFun := removeNoneAux e.symm\n  left_inv := removeNoneAux_inv e\n  right_inv := removeNoneAux_inv e.symm\n#align equiv.remove_none Equiv.removeNone\n-/\n\n/- warning: equiv.remove_none_symm -> Equiv.removeNone_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (e : Equiv.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β)), Eq.{max 1 (max (succ u2) (succ u1)) (succ u1) (succ u2)} (Equiv.{succ u2, succ u1} β α) (Equiv.symm.{succ u1, succ u2} α β (Equiv.removeNone.{u1, u2} α β e)) (Equiv.removeNone.{u2, u1} β α (Equiv.symm.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β) e))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (e : Equiv.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β)), Eq.{max (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} β α) (Equiv.symm.{succ u2, succ u1} α β (Equiv.removeNone.{u2, u1} α β e)) (Equiv.removeNone.{u1, u2} β α (Equiv.symm.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β) e))\nCase conversion may be inaccurate. Consider using '#align equiv.remove_none_symm Equiv.removeNone_symmₓ'. -/\n@[simp]\ntheorem removeNone_symm : (removeNone e).symm = removeNone e.symm :=\n  rfl\n#align equiv.remove_none_symm Equiv.removeNone_symm\n\n#print Equiv.removeNone_some /-\ntheorem removeNone_some {x : α} (h : ∃ x', e (some x) = some x') :\n    some (removeNone e x) = e (some x) :=\n  removeNoneAux_some e h\n#align equiv.remove_none_some Equiv.removeNone_some\n-/\n\n#print Equiv.removeNone_none /-\ntheorem removeNone_none {x : α} (h : e (some x) = none) : some (removeNone e x) = e none :=\n  removeNoneAux_none e h\n#align equiv.remove_none_none Equiv.removeNone_none\n-/\n\n/- warning: equiv.option_symm_apply_none_iff -> Equiv.option_symm_apply_none_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (e : Equiv.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β)), Iff (Eq.{succ u1} (Option.{u1} α) (coeFn.{max 1 (max (succ u2) (succ u1)) (succ u1) (succ u2), max (succ u2) (succ u1)} (Equiv.{succ u2, succ u1} (Option.{u2} β) (Option.{u1} α)) (fun (_x : Equiv.{succ u2, succ u1} (Option.{u2} β) (Option.{u1} α)) => (Option.{u2} β) -> (Option.{u1} α)) (Equiv.hasCoeToFun.{succ u2, succ u1} (Option.{u2} β) (Option.{u1} α)) (Equiv.symm.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β) e) (Option.none.{u2} β)) (Option.none.{u1} α)) (Eq.{succ u2} (Option.{u2} β) (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β)) (fun (_x : Equiv.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β)) => (Option.{u1} α) -> (Option.{u2} β)) (Equiv.hasCoeToFun.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β)) e (Option.none.{u1} α)) (Option.none.{u2} β))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (e : Equiv.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β)), Iff (Eq.{succ u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u1} β) => Option.{u2} α) (Option.none.{u1} β)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (Equiv.{succ u1, succ u2} (Option.{u1} β) (Option.{u2} α)) (Option.{u1} β) (fun (_x : Option.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u1} β) => Option.{u2} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u2} (Option.{u1} β) (Option.{u2} α)) (Equiv.symm.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β) e) (Option.none.{u1} β)) (Option.none.{u2} α)) (Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Option.{u1} β) (Option.none.{u2} α)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Equiv.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β)) (Option.{u2} α) (fun (_x : Option.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} α) => Option.{u1} β) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β)) e (Option.none.{u2} α)) (Option.none.{u1} β))\nCase conversion may be inaccurate. Consider using '#align equiv.option_symm_apply_none_iff Equiv.option_symm_apply_none_iffₓ'. -/\n@[simp]\ntheorem option_symm_apply_none_iff : e.symm none = none ↔ e none = none :=\n  ⟨fun h => by simpa using (congr_arg e h).symm, fun h => by simpa using (congr_arg e.symm h).symm⟩\n#align equiv.option_symm_apply_none_iff Equiv.option_symm_apply_none_iff\n\n#print Equiv.some_removeNone_iff /-\ntheorem some_removeNone_iff {x : α} : some (removeNone e x) = e none ↔ e.symm none = some x :=\n  by\n  cases' h : e (some x) with a\n  · rw [remove_none_none _ h]\n    simpa using (congr_arg e.symm h).symm\n  · rw [remove_none_some _ ⟨a, h⟩]\n    have := congr_arg e.symm h\n    rw [symm_apply_apply] at this\n    simp only [false_iff_iff, apply_eq_iff_eq]\n    simp [this]\n#align equiv.some_remove_none_iff Equiv.some_removeNone_iff\n-/\n\n/- warning: equiv.remove_none_option_congr -> Equiv.removeNone_optionCongr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (e : Equiv.{succ u1, succ u2} α β), Eq.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} α β) (Equiv.removeNone.{u1, u2} α β (Equiv.optionCongr.{u1, u2} α β e)) e\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (e : Equiv.{succ u2, succ u1} α β), Eq.{max (succ u2) (succ u1)} (Equiv.{succ u2, succ u1} α β) (Equiv.removeNone.{u2, u1} α β (Equiv.optionCongr.{u2, u1} α β e)) e\nCase conversion may be inaccurate. Consider using '#align equiv.remove_none_option_congr Equiv.removeNone_optionCongrₓ'. -/\n@[simp]\ntheorem removeNone_optionCongr (e : α ≃ β) : removeNone e.optionCongr = e :=\n  Equiv.ext fun x => Option.some_injective _ <| removeNone_some _ ⟨e x, by simp [EquivFunctor.map]⟩\n#align equiv.remove_none_option_congr Equiv.removeNone_optionCongr\n\nend RemoveNone\n\n/- warning: equiv.option_congr_injective -> Equiv.optionCongr_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}}, Function.Injective.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} α β) (Equiv.{succ u1, succ u2} (Option.{u1} α) (Option.{u2} β)) (Equiv.optionCongr.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (Equiv.{succ u2, succ u1} α β) (Equiv.{succ u2, succ u1} (Option.{u2} α) (Option.{u1} β)) (Equiv.optionCongr.{u2, u1} α β)\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_injective Equiv.optionCongr_injectiveₓ'. -/\ntheorem optionCongr_injective : Function.Injective (optionCongr : α ≃ β → Option α ≃ Option β) :=\n  Function.LeftInverse.injective removeNone_optionCongr\n#align equiv.option_congr_injective Equiv.optionCongr_injective\n\n#print Equiv.optionSubtype /-\n/-- Equivalences between `option α` and `β` that send `none` to `x` are equivalent to\nequivalences between `α` and `{y : β // y ≠ x}`. -/\ndef optionSubtype [DecidableEq β] (x : β) :\n    { e : Option α ≃ β // e none = x } ≃ (α ≃ { y : β // y ≠ x })\n    where\n  toFun e :=\n    { toFun := fun a => ⟨e a, ((EquivLike.injective _).ne_iff' e.property).2 (some_ne_none _)⟩\n      invFun := fun b =>\n        get\n          (ne_none_iff_isSome.1\n            (((EquivLike.injective _).ne_iff' ((apply_eq_iff_eq_symm_apply _).1 e.property).symm).2\n              b.property))\n      left_inv := fun a => by\n        rw [← some_inj, some_get, ← coe_def]\n        exact symm_apply_apply (e : Option α ≃ β) a\n      right_inv := fun b => by\n        ext\n        simp\n        exact apply_symm_apply _ _ }\n  invFun e :=\n    ⟨{  toFun := fun a => casesOn' a x (coe ∘ e)\n        invFun := fun b => if h : b = x then none else e.symm ⟨b, h⟩\n        left_inv := fun a => by\n          cases a; · simp\n          simp only [cases_on'_some, Function.comp_apply, Subtype.coe_eta, symm_apply_apply,\n            dite_eq_ite]\n          exact if_neg (e a).property\n        right_inv := fun b => by by_cases h : b = x <;> simp [h] }, rfl⟩\n  left_inv e := by\n    ext a\n    cases a\n    · simpa using e.property.symm\n    · simpa\n  right_inv e := by\n    ext a\n    rfl\n#align equiv.option_subtype Equiv.optionSubtype\n-/\n\n#print Equiv.optionSubtype_apply_apply /-\n@[simp]\ntheorem optionSubtype_apply_apply [DecidableEq β] (x : β) (e : { e : Option α ≃ β // e none = x })\n    (a : α) (h) : optionSubtype x e a = ⟨(e : Option α ≃ β) a, h⟩ :=\n  rfl\n#align equiv.option_subtype_apply_apply Equiv.optionSubtype_apply_apply\n-/\n\n#print Equiv.coe_optionSubtype_apply_apply /-\n@[simp]\ntheorem coe_optionSubtype_apply_apply [DecidableEq β] (x : β)\n    (e : { e : Option α ≃ β // e none = x }) (a : α) :\n    ↑(optionSubtype x e a) = (e : Option α ≃ β) a :=\n  rfl\n#align equiv.coe_option_subtype_apply_apply Equiv.coe_optionSubtype_apply_apply\n-/\n\n#print Equiv.optionSubtype_apply_symm_apply /-\n@[simp]\ntheorem optionSubtype_apply_symm_apply [DecidableEq β] (x : β)\n    (e : { e : Option α ≃ β // e none = x }) (b : { y : β // y ≠ x }) :\n    ↑((optionSubtype x e).symm b) = (e : Option α ≃ β).symm b :=\n  by\n  dsimp only [option_subtype]\n  simp\n#align equiv.option_subtype_apply_symm_apply Equiv.optionSubtype_apply_symm_apply\n-/\n\n#print Equiv.optionSubtype_symm_apply_apply_coe /-\n@[simp]\ntheorem optionSubtype_symm_apply_apply_coe [DecidableEq β] (x : β) (e : α ≃ { y : β // y ≠ x })\n    (a : α) : (optionSubtype x).symm e a = e a :=\n  rfl\n#align equiv.option_subtype_symm_apply_apply_coe Equiv.optionSubtype_symm_apply_apply_coe\n-/\n\n#print Equiv.optionSubtype_symm_apply_apply_some /-\n@[simp]\ntheorem optionSubtype_symm_apply_apply_some [DecidableEq β] (x : β) (e : α ≃ { y : β // y ≠ x })\n    (a : α) : (optionSubtype x).symm e (some a) = e a :=\n  rfl\n#align equiv.option_subtype_symm_apply_apply_some Equiv.optionSubtype_symm_apply_apply_some\n-/\n\n#print Equiv.optionSubtype_symm_apply_apply_none /-\n@[simp]\ntheorem optionSubtype_symm_apply_apply_none [DecidableEq β] (x : β) (e : α ≃ { y : β // y ≠ x }) :\n    (optionSubtype x).symm e none = x :=\n  rfl\n#align equiv.option_subtype_symm_apply_apply_none Equiv.optionSubtype_symm_apply_apply_none\n-/\n\n#print Equiv.optionSubtype_symm_apply_symm_apply /-\n@[simp]\ntheorem optionSubtype_symm_apply_symm_apply [DecidableEq β] (x : β) (e : α ≃ { y : β // y ≠ x })\n    (b : { y : β // y ≠ x }) : ((optionSubtype x).symm e : Option α ≃ β).symm b = e.symm b :=\n  by\n  simp only [option_subtype, coe_fn_symm_mk, Subtype.coe_mk, Subtype.coe_eta, dite_eq_ite,\n    ite_eq_right_iff]\n  exact fun h => False.elim (b.property h)\n#align equiv.option_subtype_symm_apply_symm_apply Equiv.optionSubtype_symm_apply_symm_apply\n-/\n\nend Equiv\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Logic/Equiv/Option.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.47729271004227386}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Jeremy Avigad, Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.filter.cofinite\nimport Mathlib.PostPort\n\nuniverses u_1 l u v \n\nnamespace Mathlib\n\n/-!\n# Ultrafilters\n\nAn ultrafilter is a minimal (maximal in the set order) proper filter.\nIn this file we define\n\n* `ultrafilter.of`: an ultrafilter that is less than or equal to a given filter;\n* `ultrafilter`: subtype of ultrafilters;\n* `ultrafilter.pure`: `pure x` as an `ultrafiler`;\n* `ultrafilter.map`, `ultrafilter.bind`, `ultrafilter.comap` : operations on ultrafilters;\n* `hyperfilter`: the ultrafilter extending the cofinite filter.\n-/\n\n/-- An ultrafilter is a minimal (maximal in the set order) proper filter. -/\nstructure ultrafilter (α : Type u_1) \nextends filter α\nwhere\n  ne_bot' : filter.ne_bot _to_filter\n  le_of_le : ∀ (g : filter α), filter.ne_bot g → g ≤ _to_filter → _to_filter ≤ g\n\nnamespace ultrafilter\n\n\nprotected instance filter.has_coe_t {α : Type u} : has_coe_t (ultrafilter α) (filter α) :=\n  has_coe_t.mk ultrafilter.to_filter\n\nprotected instance has_mem {α : Type u} : has_mem (set α) (ultrafilter α) :=\n  has_mem.mk fun (s : set α) (f : ultrafilter α) => s ∈ ↑f\n\ntheorem unique {α : Type u} (f : ultrafilter α) {g : filter α} (h : g ≤ ↑f) (hne : autoParam (filter.ne_bot g)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.tactic.apply_instance\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"tactic\") \"apply_instance\") [])) : g = ↑f :=\n  le_antisymm h (ultrafilter.le_of_le f g hne h)\n\nprotected instance ne_bot {α : Type u} (f : ultrafilter α) : filter.ne_bot ↑f :=\n  ultrafilter.ne_bot' f\n\n@[simp] theorem mem_coe {α : Type u} {f : ultrafilter α} {s : set α} : s ∈ ↑f ↔ s ∈ f :=\n  iff.rfl\n\ntheorem coe_injective {α : Type u} : function.injective coe := sorry\n\n@[simp] theorem coe_le_coe {α : Type u} {f : ultrafilter α} {g : ultrafilter α} : ↑f ≤ ↑g ↔ f = g :=\n  { mp := fun (h : ↑f ≤ ↑g) => coe_injective (unique g h), mpr := fun (h : f = g) => h ▸ le_rfl }\n\n@[simp] theorem coe_inj {α : Type u} {f : ultrafilter α} {g : ultrafilter α} : ↑f = ↑g ↔ f = g :=\n  function.injective.eq_iff coe_injective\n\ntheorem ext {α : Type u} {f : ultrafilter α} {g : ultrafilter α} (h : ∀ (s : set α), s ∈ f ↔ s ∈ g) : f = g :=\n  coe_injective (filter.ext h)\n\ntheorem le_of_inf_ne_bot {α : Type u} (f : ultrafilter α) {g : filter α} (hg : filter.ne_bot (↑f ⊓ g)) : ↑f ≤ g :=\n  le_of_inf_eq (unique f inf_le_left)\n\ntheorem le_of_inf_ne_bot' {α : Type u} (f : ultrafilter α) {g : filter α} (hg : filter.ne_bot (g ⊓ ↑f)) : ↑f ≤ g :=\n  le_of_inf_ne_bot f (eq.mpr (id (Eq._oldrec (Eq.refl (filter.ne_bot (↑f ⊓ g))) inf_comm)) hg)\n\n@[simp] theorem compl_not_mem_iff {α : Type u} {f : ultrafilter α} {s : set α} : ¬sᶜ ∈ f ↔ s ∈ f := sorry\n\n@[simp] theorem frequently_iff_eventually {α : Type u} {f : ultrafilter α} {p : α → Prop} : filter.frequently (fun (x : α) => p x) ↑f ↔ filter.eventually (fun (x : α) => p x) ↑f :=\n  compl_not_mem_iff\n\ntheorem Mathlib.filter.frequently.eventually {α : Type u} {f : ultrafilter α} {p : α → Prop} : filter.frequently (fun (x : α) => p x) ↑f → filter.eventually (fun (x : α) => p x) ↑f :=\n  iff.mp frequently_iff_eventually\n\ntheorem compl_mem_iff_not_mem {α : Type u} {f : ultrafilter α} {s : set α} : sᶜ ∈ f ↔ ¬s ∈ f :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (sᶜ ∈ f ↔ ¬s ∈ f)) (Eq.symm (propext compl_not_mem_iff))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (¬sᶜᶜ ∈ f ↔ ¬s ∈ f)) (compl_compl s))) (iff.refl (¬s ∈ f)))\n\n/-- If `sᶜ ∉ f ↔ s ∈ f`, then `f` is an ultrafilter. The other implication is given by\n`ultrafilter.compl_not_mem_iff`.  -/\ndef of_compl_not_mem_iff {α : Type u} (f : filter α) (h : ∀ (s : set α), ¬sᶜ ∈ f ↔ s ∈ f) : ultrafilter α :=\n  mk f sorry sorry\n\ntheorem nonempty_of_mem {α : Type u} {f : ultrafilter α} {s : set α} (hs : s ∈ f) : set.nonempty s :=\n  filter.nonempty_of_mem_sets hs\n\ntheorem ne_empty_of_mem {α : Type u} {f : ultrafilter α} {s : set α} (hs : s ∈ f) : s ≠ ∅ :=\n  set.nonempty.ne_empty (nonempty_of_mem hs)\n\n@[simp] theorem empty_not_mem {α : Type u} {f : ultrafilter α} : ¬∅ ∈ f :=\n  filter.empty_nmem_sets ↑f\n\ntheorem mem_or_compl_mem {α : Type u} (f : ultrafilter α) (s : set α) : s ∈ f ∨ sᶜ ∈ f :=\n  iff.mpr or_iff_not_imp_left (iff.mpr compl_mem_iff_not_mem)\n\nprotected theorem em {α : Type u} (f : ultrafilter α) (p : α → Prop) : filter.eventually (fun (x : α) => p x) ↑f ∨ filter.eventually (fun (x : α) => ¬p x) ↑f :=\n  mem_or_compl_mem f (set_of fun (x : α) => p x)\n\ntheorem eventually_or {α : Type u} {f : ultrafilter α} {p : α → Prop} {q : α → Prop} : filter.eventually (fun (x : α) => p x ∨ q x) ↑f ↔\n  filter.eventually (fun (x : α) => p x) ↑f ∨ filter.eventually (fun (x : α) => q x) ↑f := sorry\n\ntheorem union_mem_iff {α : Type u} {f : ultrafilter α} {s : set α} {t : set α} : s ∪ t ∈ f ↔ s ∈ f ∨ t ∈ f :=\n  eventually_or\n\ntheorem eventually_not {α : Type u} {f : ultrafilter α} {p : α → Prop} : filter.eventually (fun (x : α) => ¬p x) ↑f ↔ ¬filter.eventually (fun (x : α) => p x) ↑f :=\n  compl_mem_iff_not_mem\n\ntheorem eventually_imp {α : Type u} {f : ultrafilter α} {p : α → Prop} {q : α → Prop} : filter.eventually (fun (x : α) => p x → q x) ↑f ↔\n  filter.eventually (fun (x : α) => p x) ↑f → filter.eventually (fun (x : α) => q x) ↑f := sorry\n\ntheorem finite_sUnion_mem_iff {α : Type u} {f : ultrafilter α} {s : set (set α)} (hs : set.finite s) : ⋃₀s ∈ f ↔ ∃ (t : set α), ∃ (H : t ∈ s), t ∈ f := sorry\n\ntheorem finite_bUnion_mem_iff {α : Type u} {β : Type v} {f : ultrafilter α} {is : set β} {s : β → set α} (his : set.finite is) : (set.Union fun (i : β) => set.Union fun (H : i ∈ is) => s i) ∈ f ↔ ∃ (i : β), ∃ (H : i ∈ is), s i ∈ f := sorry\n\n/-- Pushforward for ultrafilters. -/\ndef map {α : Type u} {β : Type v} (m : α → β) (f : ultrafilter α) : ultrafilter β :=\n  of_compl_not_mem_iff (filter.map m ↑f) sorry\n\n@[simp] theorem coe_map {α : Type u} {β : Type v} (m : α → β) (f : ultrafilter α) : ↑(map m f) = filter.map m ↑f :=\n  rfl\n\n@[simp] theorem mem_map {α : Type u} {β : Type v} {m : α → β} {f : ultrafilter α} {s : set β} : s ∈ map m f ↔ m ⁻¹' s ∈ f :=\n  iff.rfl\n\n/-- The pullback of an ultrafilter along an injection whose range is large with respect to the given\nultrafilter. -/\ndef comap {α : Type u} {β : Type v} {m : α → β} (u : ultrafilter β) (inj : function.injective m) (large : set.range m ∈ u) : ultrafilter α :=\n  mk (filter.comap m ↑u) sorry sorry\n\n/-- The principal ultrafilter associated to a point `x`. -/\nprotected instance has_pure : Pure ultrafilter :=\n  { pure := fun (α : Type u_1) (a : α) => of_compl_not_mem_iff (pure a) sorry }\n\n@[simp] theorem mem_pure_sets {α : Type u} {a : α} {s : set α} : s ∈ pure a ↔ a ∈ s :=\n  iff.rfl\n\nprotected instance inhabited {α : Type u} [Inhabited α] : Inhabited (ultrafilter α) :=\n  { default := pure Inhabited.default }\n\n/-- Monadic bind for ultrafilters, coming from the one on filters\ndefined in terms of map and join.-/\ndef bind {α : Type u} {β : Type v} (f : ultrafilter α) (m : α → ultrafilter β) : ultrafilter β :=\n  of_compl_not_mem_iff (filter.bind ↑f fun (x : α) => ↑(m x)) sorry\n\nprotected instance ultrafilter.has_bind : Bind ultrafilter :=\n  { bind := bind }\n\nprotected instance ultrafilter.functor : Functor ultrafilter :=\n  { map := map, mapConst := fun (α β : Type u_1) => map ∘ function.const β }\n\nprotected instance ultrafilter.monad : Monad ultrafilter := sorry\n\nprotected instance ultrafilter.is_lawful_monad : is_lawful_monad ultrafilter :=\n  is_lawful_monad.mk\n    (fun (α β : Type u_1) (a : α) (f : α → ultrafilter β) => coe_injective (filter.pure_bind a (coe ∘ f)))\n    fun (α β γ : Type u_1) (f : ultrafilter α) (m₁ : α → ultrafilter β) (m₂ : β → ultrafilter γ) =>\n      coe_injective (filter.filter_eq rfl)\n\n/-- The ultrafilter lemma: Any proper filter is contained in an ultrafilter. -/\ntheorem exists_le {α : Type u} (f : filter α) [h : filter.ne_bot f] : ∃ (u : ultrafilter α), ↑u ≤ f := sorry\n\ntheorem Mathlib.filter.exists_ultrafilter_le {α : Type u} (f : filter α) [h : filter.ne_bot f] : ∃ (u : ultrafilter α), ↑u ≤ f :=\n  exists_le\n\n/-- Construct an ultrafilter extending a given filter.\n  The ultrafilter lemma is the assertion that such a filter exists;\n  we use the axiom of choice to pick one. -/\ndef of {α : Type u} (f : filter α) [filter.ne_bot f] : ultrafilter α :=\n  classical.some (exists_le f)\n\ntheorem of_le {α : Type u} (f : filter α) [filter.ne_bot f] : ↑(of f) ≤ f :=\n  classical.some_spec (exists_le f)\n\ntheorem of_coe {α : Type u} (f : ultrafilter α) : of ↑f = f :=\n  iff.mp coe_inj (unique f (of_le ↑f))\n\ntheorem exists_ultrafilter_of_finite_inter_nonempty {α : Type u} (S : set (set α)) (cond : ∀ (T : finset (set α)), ↑T ⊆ S → set.nonempty (⋂₀↑T)) : ∃ (F : ultrafilter α), S ⊆ filter.sets (ultrafilter.to_filter F) := sorry\n\nend ultrafilter\n\n\nnamespace filter\n\n\ntheorem mem_iff_ultrafilter {α : Type u} {s : set α} {f : filter α} : s ∈ f ↔ ∀ (g : ultrafilter α), ↑g ≤ f → s ∈ g := sorry\n\ntheorem le_iff_ultrafilter {α : Type u} {f₁ : filter α} {f₂ : filter α} : f₁ ≤ f₂ ↔ ∀ (g : ultrafilter α), ↑g ≤ f₁ → ↑g ≤ f₂ := sorry\n\n/-- A filter equals the intersection of all the ultrafilters which contain it. -/\ntheorem supr_ultrafilter_le_eq {α : Type u} (f : filter α) : (supr fun (g : ultrafilter α) => supr fun (hg : ↑g ≤ f) => ↑g) = f := sorry\n\n/-- The `tendsto` relation can be checked on ultrafilters. -/\ntheorem tendsto_iff_ultrafilter {α : Type u} {β : Type v} (f : α → β) (l₁ : filter α) (l₂ : filter β) : tendsto f l₁ l₂ ↔ ∀ (g : ultrafilter α), ↑g ≤ l₁ → tendsto f (↑g) l₂ := sorry\n\ntheorem exists_ultrafilter_iff {α : Type u} {f : filter α} : (∃ (u : ultrafilter α), ↑u ≤ f) ↔ ne_bot f := sorry\n\ntheorem forall_ne_bot_le_iff {α : Type u} {g : filter α} {p : filter α → Prop} (hp : monotone p) : (∀ (f : filter α), ne_bot f → f ≤ g → p f) ↔ ∀ (f : ultrafilter α), ↑f ≤ g → p ↑f := sorry\n\n/-- The ultrafilter extending the cofinite filter. -/\ndef hyperfilter (α : Type u) [infinite α] : ultrafilter α :=\n  ultrafilter.of cofinite\n\ntheorem hyperfilter_le_cofinite {α : Type u} [infinite α] : ↑(hyperfilter α) ≤ cofinite :=\n  ultrafilter.of_le cofinite\n\n@[simp] theorem bot_ne_hyperfilter {α : Type u} [infinite α] : ⊥ ≠ ↑(hyperfilter α) :=\n  ne.symm ((fun (this : ne_bot ↑(hyperfilter α)) => this) (ultrafilter.ne_bot (hyperfilter α)))\n\ntheorem nmem_hyperfilter_of_finite {α : Type u} [infinite α] {s : set α} (hf : set.finite s) : ¬s ∈ hyperfilter α :=\n  fun (hy : s ∈ hyperfilter α) => compl_not_mem_sets hy (hyperfilter_le_cofinite (set.finite.compl_mem_cofinite hf))\n\ntheorem Mathlib.set.finite.nmem_hyperfilter {α : Type u} [infinite α] {s : set α} (hf : set.finite s) : ¬s ∈ hyperfilter α :=\n  nmem_hyperfilter_of_finite\n\ntheorem compl_mem_hyperfilter_of_finite {α : Type u} [infinite α] {s : set α} (hf : set.finite s) : sᶜ ∈ hyperfilter α :=\n  iff.mpr ultrafilter.compl_mem_iff_not_mem (set.finite.nmem_hyperfilter hf)\n\ntheorem Mathlib.set.finite.compl_mem_hyperfilter {α : Type u} [infinite α] {s : set α} (hf : set.finite s) : sᶜ ∈ hyperfilter α :=\n  compl_mem_hyperfilter_of_finite\n\ntheorem mem_hyperfilter_of_finite_compl {α : Type u} [infinite α] {s : set α} (hf : set.finite (sᶜ)) : s ∈ hyperfilter α :=\n  compl_compl s ▸ set.finite.compl_mem_hyperfilter hf\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/order/filter/ultrafilter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.4772927060016125}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.multiset.antidiagonal\n! leanprover-community/mathlib commit e04043d6bf7264a3c84bc69711dc354958ca4516\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Multiset.Powerset\n\n/-!\n# The antidiagonal on a multiset.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe antidiagonal of a multiset `s` consists of all pairs `(t₁, t₂)`\nsuch that `t₁ + t₂ = s`. These pairs are counted with multiplicities.\n-/\n\n\nnamespace Multiset\n\nopen List\n\nvariable {α β : Type _}\n\n#print Multiset.antidiagonal /-\n/-- The antidiagonal of a multiset `s` consists of all pairs `(t₁, t₂)`\n    such that `t₁ + t₂ = s`. These pairs are counted with multiplicities. -/\ndef antidiagonal (s : Multiset α) : Multiset (Multiset α × Multiset α) :=\n  Quot.liftOn s (fun l => (revzip (powersetAux l) : Multiset (Multiset α × Multiset α)))\n    fun l₁ l₂ h => Quot.sound (revzip_powersetAux_perm h)\n#align multiset.antidiagonal Multiset.antidiagonal\n-/\n\n#print Multiset.antidiagonal_coe /-\ntheorem antidiagonal_coe (l : List α) : @antidiagonal α l = revzip (powersetAux l) :=\n  rfl\n#align multiset.antidiagonal_coe Multiset.antidiagonal_coe\n-/\n\n#print Multiset.antidiagonal_coe' /-\n@[simp]\ntheorem antidiagonal_coe' (l : List α) : @antidiagonal α l = revzip (powersetAux' l) :=\n  Quot.sound revzip_powersetAux_perm_aux'\n#align multiset.antidiagonal_coe' Multiset.antidiagonal_coe'\n-/\n\n#print Multiset.mem_antidiagonal /-\n/-- A pair `(t₁, t₂)` of multisets is contained in `antidiagonal s`\n    if and only if `t₁ + t₂ = s`. -/\n@[simp]\ntheorem mem_antidiagonal {s : Multiset α} {x : Multiset α × Multiset α} :\n    x ∈ antidiagonal s ↔ x.1 + x.2 = s :=\n  Quotient.inductionOn s fun l => by\n    simp [antidiagonal_coe]; refine' ⟨fun h => revzip_powerset_aux h, fun h => _⟩\n    haveI := Classical.decEq α\n    simp [revzip_powerset_aux_lemma l revzip_powerset_aux, h.symm]\n    cases' x with x₁ x₂\n    dsimp only\n    exact ⟨x₁, le_add_right _ _, by rw [add_tsub_cancel_left x₁ x₂]⟩\n#align multiset.mem_antidiagonal Multiset.mem_antidiagonal\n-/\n\n#print Multiset.antidiagonal_map_fst /-\n@[simp]\ntheorem antidiagonal_map_fst (s : Multiset α) : (antidiagonal s).map Prod.fst = powerset s :=\n  Quotient.inductionOn s fun l => by simp [powerset_aux']\n#align multiset.antidiagonal_map_fst Multiset.antidiagonal_map_fst\n-/\n\n#print Multiset.antidiagonal_map_snd /-\n@[simp]\ntheorem antidiagonal_map_snd (s : Multiset α) : (antidiagonal s).map Prod.snd = powerset s :=\n  Quotient.inductionOn s fun l => by simp [powerset_aux']\n#align multiset.antidiagonal_map_snd Multiset.antidiagonal_map_snd\n-/\n\n#print Multiset.antidiagonal_zero /-\n@[simp]\ntheorem antidiagonal_zero : @antidiagonal α 0 = {(0, 0)} :=\n  rfl\n#align multiset.antidiagonal_zero Multiset.antidiagonal_zero\n-/\n\n#print Multiset.antidiagonal_cons /-\n@[simp]\ntheorem antidiagonal_cons (a : α) (s) :\n    antidiagonal (a ::ₘ s) =\n      map (Prod.map id (cons a)) (antidiagonal s) + map (Prod.map (cons a) id) (antidiagonal s) :=\n  Quotient.inductionOn s fun l =>\n    by\n    simp only [revzip, reverse_append, quot_mk_to_coe, coe_eq_coe, powerset_aux'_cons, cons_coe,\n      coe_map, antidiagonal_coe', coe_add]\n    rw [← zip_map, ← zip_map, zip_append, (_ : _ ++ _ = _)]\n    · congr <;> simp; · simp\n#align multiset.antidiagonal_cons Multiset.antidiagonal_cons\n-/\n\n#print Multiset.antidiagonal_eq_map_powerset /-\ntheorem antidiagonal_eq_map_powerset [DecidableEq α] (s : Multiset α) :\n    s.antidiagonal = s.powerset.map fun t => (s - t, t) :=\n  by\n  induction' s using Multiset.induction_on with a s hs\n  · simp only [antidiagonal_zero, powerset_zero, zero_tsub, map_singleton]\n  · simp_rw [antidiagonal_cons, powerset_cons, map_add, hs, map_map, Function.comp, Prod.map_mk,\n      id.def, sub_cons, erase_cons_head]\n    rw [add_comm]\n    congr 1\n    refine' Multiset.map_congr rfl fun x hx => _\n    rw [cons_sub_of_le _ (mem_powerset.mp hx)]\n#align multiset.antidiagonal_eq_map_powerset Multiset.antidiagonal_eq_map_powerset\n-/\n\n/- warning: multiset.card_antidiagonal -> Multiset.card_antidiagonal is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Multiset.{u1} α), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.orderedCancelAddCommMonoid.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.orderedCancelAddCommMonoid.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.orderedCancelAddCommMonoid.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.antidiagonal.{u1} α s)) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) s))\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Multiset.{u1} α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) => Nat) (Multiset.antidiagonal.{u1} α s)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (fun (_x : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) (Multiset.antidiagonal.{u1} α s)) (HPow.hPow.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) => Nat) (Multiset.antidiagonal.{u1} α s)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) s) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) => Nat) (Multiset.antidiagonal.{u1} α s)) (instHPow.{0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) => Nat) (Multiset.antidiagonal.{u1} α s)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) s) instPowNat) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α))) => Nat) (Multiset.antidiagonal.{u1} α s)) 2 (instOfNatNat 2)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) s))\nCase conversion may be inaccurate. Consider using '#align multiset.card_antidiagonal Multiset.card_antidiagonalₓ'. -/\n@[simp]\ntheorem card_antidiagonal (s : Multiset α) : card (antidiagonal s) = 2 ^ card s := by\n  have := card_powerset s <;> rwa [← antidiagonal_map_fst, card_map] at this\n#align multiset.card_antidiagonal Multiset.card_antidiagonal\n\n/- warning: multiset.prod_map_add -> Multiset.prod_map_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CommSemiring.{u2} β] {s : Multiset.{u1} α} {f : α -> β} {g : α -> β}, Eq.{succ u2} β (Multiset.prod.{u2} β (CommSemiring.toCommMonoid.{u2} β _inst_1) (Multiset.map.{u1, u2} α β (fun (a : α) => HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β (Semiring.toNonAssocSemiring.{u2} β (CommSemiring.toSemiring.{u2} β _inst_1)))))) (f a) (g a)) s)) (Multiset.sum.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β (Semiring.toNonAssocSemiring.{u2} β (CommSemiring.toSemiring.{u2} β _inst_1)))) (Multiset.map.{u1, u2} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)) β (fun (p : Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)) => HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β (Semiring.toNonAssocSemiring.{u2} β (CommSemiring.toSemiring.{u2} β _inst_1)))))) (Multiset.prod.{u2} β (CommSemiring.toCommMonoid.{u2} β _inst_1) (Multiset.map.{u1, u2} α β f (Prod.fst.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) p))) (Multiset.prod.{u2} β (CommSemiring.toCommMonoid.{u2} β _inst_1) (Multiset.map.{u1, u2} α β g (Prod.snd.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) p)))) (Multiset.antidiagonal.{u1} α s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CommSemiring.{u2} β] {s : Multiset.{u1} α} {f : α -> β} {g : α -> β}, Eq.{succ u2} β (Multiset.prod.{u2} β (CommSemiring.toCommMonoid.{u2} β _inst_1) (Multiset.map.{u1, u2} α β (fun (a : α) => HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (Distrib.toAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β (Semiring.toNonAssocSemiring.{u2} β (CommSemiring.toSemiring.{u2} β _inst_1)))))) (f a) (g a)) s)) (Multiset.sum.{u2} β (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β (Semiring.toNonAssocSemiring.{u2} β (CommSemiring.toSemiring.{u2} β _inst_1)))) (Multiset.map.{u1, u2} (Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)) β (fun (p : Prod.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α)) => HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (NonUnitalNonAssocSemiring.toMul.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β (Semiring.toNonAssocSemiring.{u2} β (CommSemiring.toSemiring.{u2} β _inst_1))))) (Multiset.prod.{u2} β (CommSemiring.toCommMonoid.{u2} β _inst_1) (Multiset.map.{u1, u2} α β f (Prod.fst.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) p))) (Multiset.prod.{u2} β (CommSemiring.toCommMonoid.{u2} β _inst_1) (Multiset.map.{u1, u2} α β g (Prod.snd.{u1, u1} (Multiset.{u1} α) (Multiset.{u1} α) p)))) (Multiset.antidiagonal.{u1} α s)))\nCase conversion may be inaccurate. Consider using '#align multiset.prod_map_add Multiset.prod_map_addₓ'. -/\ntheorem prod_map_add [CommSemiring β] {s : Multiset α} {f g : α → β} :\n    prod (s.map fun a => f a + g a) =\n      sum ((antidiagonal s).map fun p => (p.1.map f).Prod * (p.2.map g).Prod) :=\n  by\n  refine' s.induction_on _ _\n  · simp\n  · intro a s ih\n    have := @sum_map_mul_left α β _\n    simp [ih, add_mul, mul_comm, mul_left_comm (f a), mul_left_comm (g a), mul_assoc,\n      sum_map_mul_left.symm]\n    cc\n#align multiset.prod_map_add Multiset.prod_map_add\n\nend Multiset\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Multiset/Antidiagonal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.4772927019609507}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang\n-/\nimport algebraic_geometry.projective_spectrum.topology\nimport topology.sheaves.local_predicate\nimport ring_theory.graded_algebra.homogeneous_localization\nimport algebraic_geometry.locally_ringed_space\n\n/-!\n# The structure sheaf on `projective_spectrum 𝒜`.\n\nIn `src/algebraic_geometry/topology.lean`, we have given a topology on `projective_spectrum 𝒜`; in\nthis file we will construct a sheaf on `projective_spectrum 𝒜`.\n\n## Notation\n- `R` is a commutative semiring;\n- `A` is a commutative ring and an `R`-algebra;\n- `𝒜 : ℕ → submodule R A` is the grading of `A`;\n- `U` is opposite object of some open subset of `projective_spectrum.Top`.\n\n## Main definitions and results\nWe define the structure sheaf as the subsheaf of all dependent function\n`f : Π x : U, homogeneous_localization 𝒜 x` such that `f` is locally expressible as ratio of two\nelements of the *same grading*, i.e. `∀ y ∈ U, ∃ (V ⊆ U) (i : ℕ) (a b ∈ 𝒜 i), ∀ z ∈ V, f z = a / b`.\n\n* `algebraic_geometry.projective_spectrum.structure_sheaf.is_locally_fraction`: the predicate that\n  a dependent function is locally expressible as a ratio of two elements of the same grading.\n* `algebraic_geometry.projective_spectrum.structure_sheaf.sections_subring`: the dependent functions\n  satisfying the above local property forms a subring of all dependent functions\n  `Π x : U, homogeneous_localization 𝒜 x`.\n* `algebraic_geometry.Proj.structure_sheaf`: the sheaf with `U ↦ sections_subring U` and natural\n  restriction map.\n\nThen we establish that `Proj 𝒜` is a `LocallyRingedSpace`:\n* `algebraic_geometry.Proj.stalk_iso'`: for any `x : projective_spectrum 𝒜`, the stalk of\n  `Proj.structure_sheaf` at `x` is isomorphic to `homogeneous_localization 𝒜 x`.\n* `algebraic_geometry.Proj.to_LocallyRingedSpace`: `Proj` as a locally ringed space.\n\n## References\n\n* [Robin Hartshorne, *Algebraic Geometry*][Har77]\n\n\n-/\n\nnoncomputable theory\n\nnamespace algebraic_geometry\n\nopen_locale direct_sum big_operators pointwise\nopen direct_sum set_like localization Top topological_space category_theory opposite\n\nvariables {R A: Type*}\nvariables [comm_ring R] [comm_ring A] [algebra R A]\nvariables (𝒜 : ℕ → submodule R A) [graded_algebra 𝒜]\n\nlocal notation `at ` x := homogeneous_localization.at_prime 𝒜 x.as_homogeneous_ideal.to_ideal\n\nnamespace projective_spectrum.structure_sheaf\n\nvariables {𝒜}\n\n/--\nThe predicate saying that a dependent function on an open `U` is realised as a fixed fraction\n`r / s` of *same grading* in each of the stalks (which are localizations at various prime ideals).\n-/\ndef is_fraction {U : opens (projective_spectrum.Top 𝒜)} (f : Π x : U, at x.1) : Prop :=\n∃ (i : ℕ) (r s : 𝒜 i),\n  ∀ x : U, ∃ (s_nin : s.1 ∉ x.1.as_homogeneous_ideal),\n  (f x) = quotient.mk' ⟨i, r, s, s_nin⟩\n\nvariables (𝒜)\n\n/--\nThe predicate `is_fraction` is \"prelocal\", in the sense that if it holds on `U` it holds on any open\nsubset `V` of `U`.\n-/\ndef is_fraction_prelocal : prelocal_predicate (λ (x : projective_spectrum.Top 𝒜), at x) :=\n{ pred := λ U f, is_fraction f,\n  res := by rintros V U i f ⟨j, r, s, w⟩; exact ⟨j, r, s, λ y, w (i y)⟩ }\n\n/--\nWe will define the structure sheaf as the subsheaf of all dependent functions in\n`Π x : U, homogeneous_localization 𝒜 x` consisting of those functions which can locally be expressed\nas a ratio of `A` of same grading.-/\ndef is_locally_fraction : local_predicate (λ (x : projective_spectrum.Top 𝒜), at x) :=\n(is_fraction_prelocal 𝒜).sheafify\n\nnamespace section_subring\nvariable {𝒜}\n\nopen submodule set_like.graded_monoid homogeneous_localization\n\nlemma zero_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) :\n  (is_locally_fraction 𝒜).pred (0 : Π x : unop U, at x.1) :=\nλ x, ⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨0, zero_mem _⟩, ⟨1, one_mem⟩, λ y, ⟨_, rfl⟩⟩⟩\n\nlemma one_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) :\n  (is_locally_fraction 𝒜).pred (1 : Π x : unop U, at x.1) :=\nλ x, ⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨1, one_mem⟩, ⟨1, one_mem⟩, λ y, ⟨_, rfl⟩⟩⟩\n\nlemma add_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ)\n  (a b : Π x : unop U, at x.1)\n  (ha : (is_locally_fraction 𝒜).pred a) (hb : (is_locally_fraction 𝒜).pred b) :\n  (is_locally_fraction 𝒜).pred (a + b) := λ x,\nbegin\n  rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, wa⟩,\n  rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, wb⟩,\n  refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ja + jb,\n    ⟨sb * ra + sa * rb, add_mem (add_comm jb ja ▸ mul_mem sb_mem ra_mem : sb * ra ∈ 𝒜 (ja + jb))\n      (mul_mem sa_mem rb_mem)⟩,\n    ⟨sa * sb, mul_mem sa_mem sb_mem⟩, λ y, ⟨λ h, _, _⟩⟩,\n  { cases (y : projective_spectrum.Top 𝒜).is_prime.mem_or_mem h with h h,\n    { obtain ⟨nin, -⟩ := (wa ⟨y, (opens.inf_le_left Va Vb y).2⟩), exact nin h },\n    { obtain ⟨nin, -⟩ := (wb ⟨y, (opens.inf_le_right Va Vb y).2⟩), exact nin h } },\n  { simp only [add_mul, map_add, pi.add_apply, ring_hom.map_mul, ext_iff_val, add_val],\n    obtain ⟨nin1, hy1⟩ := (wa (opens.inf_le_left Va Vb y)),\n    obtain ⟨nin2, hy2⟩ := (wb (opens.inf_le_right Va Vb y)),\n    dsimp only at hy1 hy2,\n    erw [hy1, hy2],\n    simpa only [val_mk', add_mk, ← subtype.val_eq_coe, add_comm, mul_comm sa sb], }\nend\n\n\n\nlemma mul_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ)\n  (a b : Π x : unop U, at x.1)\n  (ha : (is_locally_fraction 𝒜).pred a) (hb : (is_locally_fraction 𝒜).pred b) :\n  (is_locally_fraction 𝒜).pred (a * b) := λ x,\nbegin\n  rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, wa⟩,\n  rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, wb⟩,\n  refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ja + jb,\n    ⟨ra * rb, set_like.mul_mem_graded ra_mem rb_mem⟩,\n    ⟨sa * sb, set_like.mul_mem_graded sa_mem sb_mem⟩, λ y, ⟨λ h, _, _⟩⟩,\n  { cases (y : projective_spectrum.Top 𝒜).is_prime.mem_or_mem h with h h,\n    { choose nin hy using wa ⟨y, (opens.inf_le_left Va Vb y).2⟩, exact nin h },\n    { choose nin hy using wb ⟨y, (opens.inf_le_right Va Vb y).2⟩, exact nin h }, },\n  { simp only [pi.mul_apply, ring_hom.map_mul],\n    choose nin1 hy1 using wa (opens.inf_le_left Va Vb y),\n    choose nin2 hy2 using wb (opens.inf_le_right Va Vb y),\n    rw ext_iff_val at hy1 hy2 ⊢,\n    erw [mul_val, hy1, hy2],\n    simpa only [val_mk', mk_mul, ← subtype.val_eq_coe] }\nend\n\nend section_subring\n\nsection\n\nopen section_subring\n\nvariable {𝒜}\n/--The functions satisfying `is_locally_fraction` form a subring of all dependent functions\n`Π x : U, homogeneous_localization 𝒜 x`.-/\ndef sections_subring (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) : subring (Π x : unop U, at x.1) :=\n{ carrier := { f | (is_locally_fraction 𝒜).pred f },\n  zero_mem' := zero_mem' U,\n  one_mem' := one_mem' U,\n  add_mem' := add_mem' U,\n  neg_mem' := neg_mem' U,\n  mul_mem' := mul_mem' U }\n\nend\n\n/--The structure sheaf (valued in `Type`, not yet `CommRing`) is the subsheaf consisting of\nfunctions satisfying `is_locally_fraction`.-/\ndef structure_sheaf_in_Type : sheaf Type* (projective_spectrum.Top 𝒜):=\nsubsheaf_to_Types (is_locally_fraction 𝒜)\n\ninstance comm_ring_structure_sheaf_in_Type_obj (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) :\n  comm_ring ((structure_sheaf_in_Type 𝒜).1.obj U) := (sections_subring U).to_comm_ring\n\n/--The structure presheaf, valued in `CommRing`, constructed by dressing up the `Type` valued\nstructure presheaf.-/\n@[simps] def structure_presheaf_in_CommRing : presheaf CommRing (projective_spectrum.Top 𝒜) :=\n{ obj := λ U, CommRing.of ((structure_sheaf_in_Type 𝒜).1.obj U),\n  map := λ U V i,\n  { to_fun := ((structure_sheaf_in_Type 𝒜).1.map i),\n    map_zero' := rfl,\n    map_add' := λ x y, rfl,\n    map_one' := rfl,\n    map_mul' := λ x y, rfl, }, }\n\n/--Some glue, verifying that that structure presheaf valued in `CommRing` agrees with the `Type`\nvalued structure presheaf.-/\ndef structure_presheaf_comp_forget :\n  structure_presheaf_in_CommRing 𝒜 ⋙ (forget CommRing) ≅ (structure_sheaf_in_Type 𝒜).1 :=\nnat_iso.of_components (λ U, iso.refl _) (by tidy)\n\nend projective_spectrum.structure_sheaf\n\nnamespace projective_spectrum\n\nopen Top.presheaf projective_spectrum.structure_sheaf opens\n\n/--The structure sheaf on `Proj` 𝒜, valued in `CommRing`.-/\ndef Proj.structure_sheaf : sheaf CommRing (projective_spectrum.Top 𝒜) :=\n⟨structure_presheaf_in_CommRing 𝒜,\n  -- We check the sheaf condition under `forget CommRing`.\n  (is_sheaf_iff_is_sheaf_comp _ _).mpr\n    (is_sheaf_of_iso (structure_presheaf_comp_forget 𝒜).symm\n      (structure_sheaf_in_Type 𝒜).cond)⟩\n\nend projective_spectrum\n\nsection\n\nopen projective_spectrum projective_spectrum.structure_sheaf opens\n\n@[simp] lemma res_apply (U V : opens (projective_spectrum.Top 𝒜)) (i : V ⟶ U)\n  (s : (Proj.structure_sheaf 𝒜).1.obj (op U)) (x : V) :\n  ((Proj.structure_sheaf 𝒜).1.map i.op s).1 x = (s.1 (i x) : _) :=\nrfl\n\n/--`Proj` of a graded ring as a `SheafedSpace`-/\ndef Proj.to_SheafedSpace : SheafedSpace CommRing :=\n{ carrier := Top.of (projective_spectrum 𝒜),\n  presheaf := (Proj.structure_sheaf 𝒜).1,\n  is_sheaf := (Proj.structure_sheaf 𝒜).2 }\n\n/-- The ring homomorphism that takes a section of the structure sheaf of `Proj` on the open set `U`,\nimplemented as a subtype of dependent functions to localizations at homogeneous prime ideals, and\nevaluates the section on the point corresponding to a given homogeneous prime ideal. -/\ndef open_to_localization (U : opens (projective_spectrum.Top 𝒜)) (x : projective_spectrum.Top 𝒜)\n  (hx : x ∈ U) :\n  (Proj.structure_sheaf 𝒜).1.obj (op U) ⟶ CommRing.of (at x) :=\n{ to_fun := λ s, (s.1 ⟨x, hx⟩ : _),\n  map_one' := rfl,\n  map_mul' := λ _ _, rfl,\n  map_zero' := rfl,\n  map_add' := λ _ _, rfl }\n\n/-- The ring homomorphism from the stalk of the structure sheaf of `Proj` at a point corresponding\nto a homogeneous prime ideal `x` to the *homogeneous localization* at `x`,\nformed by gluing the `open_to_localization` maps. -/\ndef stalk_to_fiber_ring_hom (x : projective_spectrum.Top 𝒜) :\n  (Proj.structure_sheaf 𝒜).presheaf.stalk x ⟶ CommRing.of (at x) :=\nlimits.colimit.desc (((open_nhds.inclusion x).op) ⋙ (Proj.structure_sheaf 𝒜).1)\n  { X := _,\n    ι :=\n    { app := λ U, open_to_localization 𝒜 ((open_nhds.inclusion _).obj (unop U)) x (unop U).2, } }\n\n@[simp] lemma germ_comp_stalk_to_fiber_ring_hom (U : opens (projective_spectrum.Top 𝒜)) (x : U) :\n  (Proj.structure_sheaf 𝒜).presheaf.germ x ≫ stalk_to_fiber_ring_hom 𝒜 x =\n  open_to_localization 𝒜 U x x.2 :=\nlimits.colimit.ι_desc _ _\n\n@[simp] lemma stalk_to_fiber_ring_hom_germ' (U : opens (projective_spectrum.Top 𝒜))\n  (x : projective_spectrum.Top 𝒜) (hx : x ∈ U) (s : (Proj.structure_sheaf 𝒜).1.obj (op U)) :\n  stalk_to_fiber_ring_hom 𝒜 x\n    ((Proj.structure_sheaf 𝒜).presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=\nring_hom.ext_iff.1 (germ_comp_stalk_to_fiber_ring_hom 𝒜 U ⟨x, hx⟩ : _) s\n\n@[simp] lemma stalk_to_fiber_ring_hom_germ (U : opens (projective_spectrum.Top 𝒜)) (x : U)\n  (s : (Proj.structure_sheaf 𝒜).1.obj (op U)) :\n  stalk_to_fiber_ring_hom 𝒜 x ((Proj.structure_sheaf 𝒜).presheaf.germ x s) = s.1 x :=\nby { cases x, exact stalk_to_fiber_ring_hom_germ' 𝒜 U _ _ _ }\n\nlemma homogeneous_localization.mem_basic_open (x : projective_spectrum.Top 𝒜) (f : at x) :\n  x ∈ projective_spectrum.basic_open 𝒜 f.denom :=\nby { rw projective_spectrum.mem_basic_open, exact f.denom_mem }\n\nvariable (𝒜)\n\n/--Given a point `x` corresponding to a homogeneous prime ideal, there is a (dependent) function\nsuch that, for any `f` in the homogeneous localization at `x`, it returns the obvious section in the\nbasic open set `D(f.denom)`-/\ndef section_in_basic_open (x : projective_spectrum.Top 𝒜) :\n  Π (f : at x),\n    (Proj.structure_sheaf 𝒜).1.obj (op (projective_spectrum.basic_open 𝒜 f.denom)) :=\nλ f, ⟨λ y, quotient.mk' ⟨f.deg, ⟨f.num, f.num_mem_deg⟩, ⟨f.denom, f.denom_mem_deg⟩, y.2⟩,\n  λ y, ⟨projective_spectrum.basic_open 𝒜 f.denom, y.2,\n    ⟨𝟙 _, ⟨f.deg, ⟨⟨f.num, f.num_mem_deg⟩, ⟨f.denom, f.denom_mem_deg⟩,\n      λ z, ⟨z.2, rfl⟩⟩⟩⟩⟩⟩\n\n/--Given any point `x` and `f` in the homogeneous localization at `x`, there is an element in the\nstalk at `x` obtained by `section_in_basic_open`. This is the inverse of `stalk_to_fiber_ring_hom`.\n-/\ndef homogeneous_localization_to_stalk (x : projective_spectrum.Top 𝒜) :\n  (at x) → (Proj.structure_sheaf 𝒜).presheaf.stalk x :=\nλ f, (Proj.structure_sheaf 𝒜).presheaf.germ\n  (⟨x, homogeneous_localization.mem_basic_open _ x f⟩ : projective_spectrum.basic_open _ f.denom)\n  (section_in_basic_open _ x f)\n\n/--Using `homogeneous_localization_to_stalk`, we construct a ring isomorphism between stalk at `x`\nand homogeneous localization at `x` for any point `x` in `Proj`.-/\ndef Proj.stalk_iso' (x : projective_spectrum.Top 𝒜) :\n  (Proj.structure_sheaf 𝒜).presheaf.stalk x ≃+* CommRing.of (at x)  :=\nring_equiv.of_bijective (stalk_to_fiber_ring_hom _ x)\n⟨λ z1 z2 eq1, begin\n  obtain ⟨u1, memu1, s1, rfl⟩ := (Proj.structure_sheaf 𝒜).presheaf.germ_exist x z1,\n  obtain ⟨u2, memu2, s2, rfl⟩ := (Proj.structure_sheaf 𝒜).presheaf.germ_exist x z2,\n  obtain ⟨v1, memv1, i1, ⟨j1, ⟨a1, a1_mem⟩, ⟨b1, b1_mem⟩, hs1⟩⟩ := s1.2 ⟨x, memu1⟩,\n  obtain ⟨v2, memv2, i2, ⟨j2, ⟨a2, a2_mem⟩, ⟨b2, b2_mem⟩, hs2⟩⟩ := s2.2 ⟨x, memu2⟩,\n  obtain ⟨b1_nin_x, eq2⟩ := hs1 ⟨x, memv1⟩,\n  obtain ⟨b2_nin_x, eq3⟩ := hs2 ⟨x, memv2⟩,\n  dsimp only at eq1 eq2 eq3,\n  erw [stalk_to_fiber_ring_hom_germ 𝒜 u1 ⟨x, memu1⟩ s1,\n    stalk_to_fiber_ring_hom_germ 𝒜 u2 ⟨x, memu2⟩ s2] at eq1,\n  erw eq1 at eq2,\n  erw [eq2, quotient.eq] at eq3,\n  change localization.mk _ _ = localization.mk _ _ at eq3,\n  rw [localization.mk_eq_mk', is_localization.eq] at eq3,\n  obtain ⟨⟨c, hc⟩, eq3⟩ := eq3,\n  simp only [← subtype.val_eq_coe] at eq3,\n  have eq3' : ∀ (y : projective_spectrum.Top 𝒜)\n    (hy : y ∈ projective_spectrum.basic_open 𝒜 b1 ⊓\n      projective_spectrum.basic_open 𝒜 b2 ⊓\n      projective_spectrum.basic_open 𝒜 c),\n    (localization.mk a1\n      ⟨b1, show b1 ∉ y.as_homogeneous_ideal,\n        by rw ←projective_spectrum.mem_basic_open;\n          exact le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _) hy⟩ :\n            localization.at_prime y.1.to_ideal) =\n    localization.mk a2\n      ⟨b2, show b2 ∉ y.as_homogeneous_ideal,\n        by rw ←projective_spectrum.mem_basic_open;\n        exact le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_right _ _) hy⟩,\n  { intros y hy,\n    rw [localization.mk_eq_mk', is_localization.eq],\n    exact ⟨⟨c, show c ∉ y.as_homogeneous_ideal, by rw ←projective_spectrum.mem_basic_open;\n      exact le_of_hom (opens.inf_le_right _ _) hy⟩, eq3⟩ },\n  refine presheaf.germ_ext (Proj.structure_sheaf 𝒜).1\n    (projective_spectrum.basic_open _ b1 ⊓\n      projective_spectrum.basic_open _ b2 ⊓\n      projective_spectrum.basic_open _ c ⊓ v1 ⊓ v2)\n    ⟨⟨⟨⟨b1_nin_x, b2_nin_x⟩, hc⟩, memv1⟩, memv2⟩\n    (opens.inf_le_left _ _ ≫ opens.inf_le_right _ _ ≫ i1) (opens.inf_le_right _ _ ≫ i2) _,\n  rw subtype.ext_iff_val,\n  ext1 y,\n  simp only [res_apply],\n  obtain ⟨b1_nin_y, eq6⟩ := hs1 ⟨_, le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_right _ _) y.2⟩,\n  obtain ⟨b2_nin_y, eq7⟩ := hs2 ⟨_, le_of_hom (opens.inf_le_right _ _) y.2⟩,\n  simp only at eq6 eq7,\n  erw [eq6, eq7, quotient.eq],\n  change localization.mk _ _ = localization.mk _ _,\n  exact eq3' _ ⟨⟨le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _ ≫\n      opens.inf_le_left _ _ ≫ opens.inf_le_left _ _) y.2,\n    le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _ ≫\n      opens.inf_le_left _ _ ≫ opens.inf_le_right _ _) y.2⟩,\n    le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _ ≫\n      opens.inf_le_right _ _) y.2⟩,\nend, function.surjective_iff_has_right_inverse.mpr ⟨homogeneous_localization_to_stalk 𝒜 x,\n  λ f, begin\n    rw homogeneous_localization_to_stalk,\n    erw stalk_to_fiber_ring_hom_germ 𝒜\n      (projective_spectrum.basic_open 𝒜 f.denom) ⟨x, _⟩ (section_in_basic_open _ x f),\n    simp only [section_in_basic_open, subtype.ext_iff_val, homogeneous_localization.ext_iff_val,\n      homogeneous_localization.val_mk', f.eq_num_div_denom],\n    refl,\n  end⟩⟩\n\n/--`Proj` of a graded ring as a `LocallyRingedSpace`-/\ndef Proj.to_LocallyRingedSpace : LocallyRingedSpace :=\n{ local_ring := λ x, @@ring_equiv.local_ring _\n    (show local_ring (at x), from infer_instance) _\n    (Proj.stalk_iso' 𝒜 x).symm,\n  ..(Proj.to_SheafedSpace 𝒜) }\n\nend\n\nend algebraic_geometry\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_geometry/projective_spectrum/structure_sheaf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4772822254240681}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport control.functor\nimport data.sum.basic\n\n/-!\n# Functors with two arguments\n\nThis file defines bifunctors.\n\nA bifunctor is a function `F : Type* → Type* → Type*` along with a bimap which turns `F α β` into\n`F α' β'` given two functions `α → α'` and `β → β'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') ∘ (bimap f g) = bimap (f' ∘ f) (g' ∘ g)`\n\n## Main declarations\n\n* `bifunctor`: A typeclass for the bare bimap of a bifunctor.\n* `is_lawful_bifunctor`: A typeclass asserting this bimap respects the bifunctor laws.\n-/\n\nuniverses u₀ u₁ u₂ v₀ v₁ v₂\n\nopen function\n\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass bifunctor (F : Type u₀ → Type u₁ → Type u₂) :=\n(bimap : Π {α α' β β'}, (α → α') → (β → β') → F α β → F α' β')\nexport bifunctor ( bimap )\n\n/-- Bifunctor. This typeclass asserts that a lawless `bifunctor` is lawful. -/\nclass is_lawful_bifunctor (F : Type u₀ → Type u₁ → Type u₂) [bifunctor F] :=\n(id_bimap : Π {α β} (x : F α β), bimap id id x = x)\n(bimap_bimap : Π {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂)\n  (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀),\n  bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x)\n\nexport is_lawful_bifunctor (id_bimap bimap_bimap)\n\nattribute [higher_order bimap_id_id] id_bimap\nattribute [higher_order bimap_comp_bimap] bimap_bimap\n\nexport is_lawful_bifunctor (bimap_id_id bimap_comp_bimap)\nvariables {F : Type u₀ → Type u₁ → Type u₂} [bifunctor F]\n\nnamespace bifunctor\n\n/-- Left map of a bifunctor. -/\n@[reducible] def fst {α α' β} (f : α → α') : F α β → F α' β := bimap f id\n\n/-- Right map of a bifunctor. -/\n@[reducible] def snd {α β β'} (f : β → β') : F α β → F α β' := bimap id f\n\nvariable [is_lawful_bifunctor F]\n\n@[higher_order fst_id]\nlemma id_fst : Π {α β} (x : F α β), fst id x = x :=\n@id_bimap _ _ _\n\n@[higher_order snd_id]\nlemma id_snd : Π {α β} (x : F α β), snd id x = x :=\n@id_bimap _ _ _\n\n@[higher_order fst_comp_fst]\n\n\n@[higher_order fst_comp_snd]\nlemma fst_snd {α₀ α₁ β₀ β₁}\n  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n  fst f (snd f' x) = bimap f f' x :=\nby simp [fst,bimap_bimap]\n\n@[higher_order snd_comp_fst]\nlemma snd_fst {α₀ α₁ β₀ β₁}\n  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n  snd f' (fst f x) = bimap f f' x :=\nby simp [snd,bimap_bimap]\n\n@[higher_order snd_comp_snd]\nlemma comp_snd {α β₀ β₁ β₂}\n  (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α β₀) :\n  snd g' (snd g x) = snd (g' ∘ g) x :=\nby simp [snd,bimap_bimap]\n\nattribute [functor_norm] bimap_bimap comp_snd comp_fst\n  snd_comp_snd snd_comp_fst fst_comp_snd fst_comp_fst bimap_comp_bimap\n  bimap_id_id fst_id snd_id\n\nend bifunctor\nopen functor\ninstance : bifunctor prod :=\n{ bimap := @prod.map }\n\ninstance : is_lawful_bifunctor prod :=\nby refine { .. }; intros; cases x; refl\n\ninstance bifunctor.const : bifunctor const :=\n{ bimap := (λ α α' β β f _, f) }\n\ninstance is_lawful_bifunctor.const : is_lawful_bifunctor const  :=\nby refine { .. }; intros; refl\n\ninstance bifunctor.flip : bifunctor (flip F) :=\n{ bimap := (λ α α' β β' f f' x, (bimap f' f x : F β' α')) }\n\ninstance is_lawful_bifunctor.flip [is_lawful_bifunctor F] : is_lawful_bifunctor (flip F)  :=\nby refine { .. }; intros; simp [bimap] with functor_norm\n\ninstance : bifunctor sum :=\n{ bimap := @sum.map }\n\ninstance : is_lawful_bifunctor sum :=\nby refine { .. }; intros; cases x; refl\n\nopen bifunctor functor\n\n@[priority 10]\ninstance bifunctor.functor {α} : functor (F α) :=\n{ map := λ _ _, snd }\n\n@[priority 10]\ninstance bifunctor.is_lawful_functor [is_lawful_bifunctor F] {α} : is_lawful_functor (F α) :=\nby refine {..}; intros; simp [functor.map] with functor_norm\n\nsection bicompl\n\nvariables (G : Type* → Type u₀) (H : Type* → Type u₁) [functor G] [functor H]\n\ninstance : bifunctor (bicompl F G H) :=\n{ bimap := λ α α' β β' f f' x, (bimap (map f) (map f') x : F (G α') (H β')) }\n\ninstance [is_lawful_functor G]  [is_lawful_functor H] [is_lawful_bifunctor F] :\n  is_lawful_bifunctor (bicompl F G H) :=\nby constructor; intros; simp [bimap,map_id,map_comp_map] with functor_norm\n\nend bicompl\nsection bicompr\n\nvariables (G : Type u₂ → Type*) [functor G]\n\ninstance : bifunctor (bicompr G F) :=\n{ bimap := λ α α' β β' f f' x, (map (bimap f f') x : G (F α' β')) }\n\ninstance [is_lawful_functor G] [is_lawful_bifunctor F] :\n  is_lawful_bifunctor (bicompr G F) :=\nby constructor; intros; simp [bimap] with functor_norm\n\nend bicompr\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/control/bifunctor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.7248702761768248, "lm_q1q2_score": 0.4772672851889174}}
{"text": "import ftype.basic ftype.embed\nimport .rankfun .dual \n\nnamespace ftype \nnoncomputable theory \n\n@[simp] def restrict_subset {B : ftype} (R : set B) (rfun : rankfun B)  : rankfun (subftype R) := \n{ \n  r := λ X, rfun.r X,\n  R0 := λ X, rfun.R0 X,\n  R1 := λ X, by {simp only [subftype_coe_size], from rfun.R1 X},\n  R2 := λ X Y, by {intros H, simp, apply rfun.R2, simp at H, apply H,},\n  R3 := λ X Y, by {simp, from rfun.R3 X Y}\n}\n-- simp [-has_univ.univ]\n-- #check has_univ.univ\n\n-- def image (f : α → β) (s : set α) : set β :=\n-- {b | ∃ a, a ∈ s ∧ f a = b}\n\n--let f := (embed.from_subftype R).f in \n--⟨λ X, rfun.r X, λ X, rfun.R0 X, λ X, rfun.R1 X, λ X Y, rfun.R2 X Y, λ X Y, rfun.R3 X Y⟩ \n\n@[simp] def restrict_nested_pair {B : ftype} {R₀ R : set B} (h : R₀ ⊆ R) (rfun : rankfun (subftype R)) : rankfun (subftype R₀)  := \nlet f := embed.from_nested_pair h in \n{ \n  r := λ X, rfun.r (f.img X),\n  R0 := λ X, rfun.R0 (f.img X),\n  R1 := λ X, by {rw ←f.on_size, from rfun.R1 (f.img X)},\n  R2 := λ X Y hXY, rfun.R2 _ _ (f.on_subset hXY), \n  R3 := λ X Y, by {have := rfun.R3 (f.img X) (f.img Y), rw [←f.on_union, ←f.on_inter] at this, from this},\n}\n\n--⟨λ X, rfun.r (f X), λ X, rfun.R0 (f X), λ X, rfun.R1 (f X), λ X Y, rfun.R2 (f X) (f Y), λ X Y, rfun.R3 (f X) (f Y)⟩ \n@[simp] def corestrict_subset {U : ftype} (R : set U) (M : rankfun U)  : rankfun (subftype R) := \nlet C := Rᶜ, f := embed.from_subftype R in \n⟨ \n  λ X_foo, M.r ((X_foo : set U) ∪ C) - M.r C,\n  λ X, by {rw sub_nonneg, exact M.R2 C (X ∪ C) (subset_union_right X C)},\n  λ X, by {simp only, linarith [M.R0 (X ∩ C), M.R3 X C, M.R1 X, subftype_coe_size X]},\n  λ X Y hXY, by {simp only, linarith [M.R2 (X ∪ C) (Y ∪ C) (subset_union_subset_left _ _ C (f.on_subset hXY))]}, \n  λ X Y, by\n  {\n    suffices : M.r (coe (X ∪ Y) ∪ C) + M.r (coe (X ∩ Y) ∪ C) ≤ M.r (X ∪ C) + M.r (Y ∪ C), \n      by {simp only, linarith}, \n    simp only [subftype_coe_inter, subftype_coe_union], \n    have h := M.R3 (X ∪ C) (Y ∪ C), \n    rw [←union_distrib_right, ←union_distrib_union_left] at h,  \n    assumption,\n  },\n⟩ \n\n@[simp] def corestrict_nested_pair {B : ftype} {R₀ R₁ : set B} (h : R₀ ⊆ R₁) (M : rankfun (subftype R₁)) : rankfun (subftype R₀)  := \nlet \n  r := M.r, \n  f := (embed.from_nested_pair h),  \n  φ := f.img, \n  C := (φ (set.univ))ᶜ in \n⟨\n  λ X, r (φ X ∪ C) - r C, \n  λ X, by {rw sub_nonneg, exact M.R2 C (φ X ∪ C) (subset_union_right (φ X) C)}, \n  λ X, by {simp only, linarith [f.on_size X, M.R0 ((φ X) ∩ C), M.R3 (φ X) C, M.R1 (φ X)]}, \n  λ X Y hXY, by {simp only, linarith [M.R2 ((φ X) ∪ C) ((φ Y) ∪ C) (subset_union_subset_left _ _ C (f.on_subset hXY))]}, \n  λ X Y, by \n  {\n    simp only, \n    suffices : M.r (φ (X ∪ Y) ∪ C) + M.r (φ (X ∩ Y) ∪ C) ≤ M.r ((φ X) ∪ C) + M.r ((φ Y) ∪ C), by linarith, \n    have h := M.R3 ((f.img X) ∪ C) ((f.img Y) ∪ C), \n    rw [←union_distrib_right, ←union_distrib_union_left, ←f.on_inter, ←f.on_union] at h, \n    from h, \n  },\n⟩\n\n--- Below here still needs refactor\n\ndef matroid_on {U : ftype} (E : set U) := rankfun (subftype E)\n\nsection minor \n\nvariables {U : ftype}\n\ninductive minor_on : set U → Type\n| self                       : minor_on univ\n| restrict   (X : set U) {E : set U} : (X ⊆ E) → minor_on E → minor_on X\n| corestrict (X : set U) {E : set U} : (X ⊆ E) → minor_on E → minor_on X\nopen minor_on\n\n\ndef to_minor : Π {E : set U}, minor_on E → rankfun U → matroid_on E\n| _ self r := restrict_subset _ r\n| _ (restrict _ hE' expr) r := restrict_nested_pair hE' (to_minor expr r)\n| _ (corestrict _ hE' expr) r := corestrict_nested_pair hE' (to_minor expr r)\n\n/--simplified minor expression \\ corestrict to Z, then restrict to A -/\n\nlemma restrict_rank {M : rankfun U} (A : set U) (X : set (subftype A)) : \n  (to_minor (restrict A (subset_univ A) self) M).r X = M.r X :=\nby simp [to_minor]\n\nlemma corestrict_rank {M : rankfun U} (A : set U) (X : set (subftype A)) : \n  (to_minor (corestrict A (subset_univ A) self) M).r X = M.r (X ∪ (univ \\ A)) - M.r (univ \\ A) :=\nby simp [to_minor]\n\nlemma switch_restrict_corestrict {M : rankfun U} (A Z : set U) (hAZ : A ⊆ Z) : \n  to_minor (restrict A hAZ ((corestrict Z (subset_univ Z)) self)) M = to_minor (corestrict A (subset_union_left A Zᶜ) ((restrict (A ∪ Zᶜ) (subset_univ (A ∪ Zᶜ))) self)) M :=\n  let f := (embed.from_subftype A).f, hAZc := subset_union_left A Zᶜ, hAZc_univ := subset_univ (A ∪ Zᶜ) in \n  begin\n    \n    ext X, \n    have set_eq : (A ∪ Zᶜ) \\ A = univ \\ Z \n      := by {rw [diff_eq, inter_distrib_right, ←compl_union, union_comm Z, \n                subset_iff_union_eq_left.mp hAZ], simp},\n    set M' := (to_minor (corestrict A hAZc (restrict (A ∪ Zᶜ) hAZc_univ self)) M) with hM', \n\n    have RHS : M'.r X = M.r (X ∪ ((A ∪ Zᶜ) \\ A)) - M.r ((A ∪ Zᶜ) \\ A) := \n      by {rw hM',convert rfl; simp,},\n    \n    rw set_eq at RHS, \n    convert RHS.symm, \n    simp [to_minor],\n  end\n\n\nlemma dual_restrict_corestrict {M : rankfun U} (A Z : set U) (hAZ : A ⊆ Z) : \n  dual (to_minor (restrict A hAZ (corestrict Z (subset_univ Z) self)) M) = to_minor (corestrict A hAZ (restrict Z (subset_univ Z) self)) (dual M) := \n  let emb := embed.from_subftype A in \n  begin\n    rw switch_restrict_corestrict, ext X, apply eq.symm, \n    have hJ : ∀ (J : set U) (hJ : J ⊆ A), (J ∪ (Z\\A))ᶜ = (A \\ J) ∪ (univ \\ Z) := \n      λ J hJ, by rw [compl_union, univ_diff, compl_diff, diff_eq, inter_distrib_left, ←compl_union, subset_iff_union_eq_left.mp (subset.trans hJ hAZ), inter_comm, union_comm], \n    have hset : size ((X:set U) ∩ (Z \\ A)) = 0 := by \n    {\n      suffices : ((X:set U) ∩ (Z \\ A)) = ∅, \n      rw this, exact size_empty U,\n      have := coe_set_is_subset X, \n      tidy, \n    },\n    have hempty : (Z\\A)ᶜ = A ∪ (univ \\ Z) := \n      by {rw [←empty_union (Z\\A), hJ ∅ (empty_subset _), diff_empty]},\n    \n    \n    have := calc (to_minor (corestrict A hAZ (restrict Z (subset_univ Z) self)) (dual M)).r X\n           = (size ((X:set U) ∪ (Z\\A)) + M.r ((X ∪ (Z\\A))ᶜ) - M.r univ) - (size (Z\\A) + M.r (Z\\A)ᶜ - M.r univ )       \n            : by {simp [to_minor, dual], } \n       ... = size (X:set U) + M.r ((X ∪ (Z\\A))ᶜ) - M.r  (Z\\A)ᶜ                                                   \n            : by linarith [size_modular (X :set U) (Z\\A), hset, emb.on_size X]\n       ... = size (X:set U) + M.r ((A \\ X) ∪ (univ \\ Z)) - M.r (A ∪ (univ \\ Z))                                        \n            : by {congr', finish}\n       ... = size (X:set U) + (M.r ((A \\ X) ∪ (univ \\ Z)) - M.r (univ \\ Z)) - (M.r (A ∪ (univ \\ Z)) - M.r (univ \\ Z))        \n            : by linarith \n       ... = (dual (to_minor (restrict A hAZ (corestrict Z (subset_univ Z) self)) M)).r X                     \n            : by {simp [dual, to_minor],} , \n\n    rw ←switch_restrict_corestrict, assumption,         \n  end\n\nlemma dual_corestrict_restrict {M : rankfun U} (A Z : set U) (hAZ : A ⊆ Z) : \n  dual (to_minor (corestrict A hAZ (restrict Z (subset_univ Z) self)) M) = to_minor (restrict A hAZ (corestrict Z (subset_univ Z) self)) (dual M) := \n  by {nth_rewrite 0 ←(dual_dual M), rw [←dual_restrict_corestrict, dual_dual]}\n\n\nlemma restrict_univ (M : rankfun U){A : set U} (expr: minor_on A) : \n  to_minor (restrict A (subset_refl A) expr) M = to_minor expr M := \n  by {ext X, simp [to_minor], congr',    }-- cases X,refl}\n\nlemma corestrict_univ (M : rankfun U){A : set U} (expr: minor_on A) : \n  to_minor (corestrict A (subset_refl A) expr) M = to_minor expr M :=\nbegin\n  simp [to_minor],\n  set M' := to_minor expr M,\n  apply rankfun.ext, ext X, \n  simp only,\n  set f := (embed.from_nested_pair (subset_refl A)).f,\n  have : (embed.to_subftype A A _) = univ := rfl,\n  rw [this,  ftype.compl_univ, union_empty, rank_empty M'],\n  rw [(by cases X; refl: f X = X)],\n  linarith,\nend\n\nlemma dual_restrict (M: rankfun U) (A : set U) : \n  dual (to_minor (restrict A (subset_univ A) self) M) = to_minor (corestrict A (subset_univ A) self) (dual M) := \n    by rw [←(corestrict_univ _ (restrict A (subset_univ A) self)), dual_corestrict_restrict, restrict_univ]\n    \nlemma dual_corestrict (M: rankfun U) (A : set U) : \n  dual (to_minor (corestrict A (subset_univ A) self) M) = to_minor (restrict A (subset_univ A) self) (dual M) := \n    by rw [←(restrict_univ _ (corestrict A (subset_univ A) self)), dual_restrict_corestrict, corestrict_univ]\n\nlemma switch_corestrict_restrict (M : rankfun U) (A Z : set U) (hAZ : A ⊆ Z) : \n  to_minor (corestrict A hAZ ((restrict Z (subset_univ Z)) self)) M = to_minor (restrict A (subset_union_left A Zᶜ) ((corestrict (A ∪ Zᶜ) (subset_univ (A ∪ Zᶜ))) self)) M :=\n  by {nth_rewrite 0 ←(dual_dual M), rw [←dual_restrict_corestrict, switch_restrict_corestrict, dual_corestrict_restrict, dual_dual]}\n\n\nlemma restrict_restrict (M : rankfun U) (A Z : set U) (hAZ : A ⊆ Z) : \n  to_minor (restrict A hAZ (restrict Z (subset_univ Z) self)) M = to_minor (restrict A (subset_univ A) self) M :=\n  let f := (embed.from_subftype A).f in \n  by {ext X,calc _ = M.r (f X) : rfl ...= _ : rfl}\n     \n#check minor_on \n\n/-lemma corestrict_corestrict {M : rankfun U} (A Z : set U) (hAZ : A ⊆ Z) : \n  to_minor (corestrict A hAZ (corestrict Z (subset_univ Z) self)) M = to_minor (corestrict A (subset_univ A) self) M :=   \n  begin\n    nth_rewrite 0 ←(dual_dual M), \n    have := dual_restrict (dual M) A, \n    \n    --unfold to_minor at *,\n    \n    \n    \n    --←dual_restrict, \n    /-let U' := subftype Z, \n    let expr := ((corestrict univ (subset_refl univ) self) : minor_on (univ : set U')),\n    let M₀ := to_minor expr, \n    have := corestrict_univ M₀ expr-/\n    --have := @corestrict_univ (subftype Z) M₀ univ expr, \n    --nth_rewrite 0 ←(dual_dual M),\n    \n    \n    --have := \n    --calc  \n    sorry, \n  end-/\n\n@[simp] def reduced_expr  (A Z : set U) (hAZ : A ⊆ Z) : minor_on A := \n  restrict A hAZ ((corestrict Z (subset_univ Z)) self)\n\nlemma restriction_of_reduced  {M : rankfun U} (A Z A' : set U) (hA'A : A' ⊆ A) (hAZ : A ⊆ Z) : \n  to_minor (restrict A' hA'A (reduced_expr A Z hAZ)) M = to_minor (reduced_expr A' Z (subset.trans hA'A hAZ)) M := rfl\n\nlemma corestriction_of_reduced {M : rankfun U} (A Z Z' : set U) (hZ'A : Z' ⊆ A) (hAZ : A ⊆ Z) : \n  to_minor (corestrict Z' hZ'A (reduced_expr A Z hAZ) ) M = to_minor (reduced_expr Z' (Z' ∪ (Z \\ A)) (subset_union_left Z' _)) M := \n  let  J  := Z' ∪ (Z \\ A),\n       M' := to_minor (reduced_expr A Z hAZ) M, \n       N  := (to_minor (reduced_expr Z' J (subset_union_left _ _)) M) in \n  begin\n    ext, rename x X, \n    have equiv : (A \\ Z') ∪ (univ \\ Z) = (univ \\ J) := by \n    {\n      simp only [univ_diff, J, diff_eq, univ_inter],\n      rw [compl_union, compl_inter, inter_distrib_left, ←compl_union Z', \n          (subset_iff_union_eq_left.mp (subset.trans hZ'A hAZ)), compl_compl, union_comm Zᶜ, inter_comm A], \n    }, \n    have LHS := \n    calc     (to_minor (corestrict Z' hZ'A (reduced_expr A Z hAZ)) M).r X\n           = (corestrict_nested_pair hZ'A M').r X                                                   : rfl \n      ...  = M.r (X ∪ (A \\ Z') ∪ (univ \\ Z)) - M.r (univ \\ Z) - (M.r ((A \\ Z') ∪ (univ \\ Z)) - M.r (univ \\ Z)) : rfl  \n      ...  = M.r (X ∪ (A \\ Z') ∪ (univ \\ Z)) - M.r ((A \\ Z') ∪ (univ \\ Z))                                : by linarith\n      ...  = M.r (X ∪ (univ \\ J)) - M.r (univ \\ J)                                                        : by rw [union_assoc, equiv],\n\n    rw LHS, apply eq.symm, clear LHS, calc N.r X = _ : rfl, \n  end\n\n\n-- Every minor expression is equivalent to a reduced one. \n\nlemma has_reduced_expr {M : rankfun U} {E : set U} (expr : minor_on E) :\n  ∃ (Z : set U) (hZ : E ⊆ Z), \n  to_minor (reduced_expr E Z hZ) M = to_minor expr M := \nbegin\n  induction expr with X₁ E₁ hX₁E₁ minor_expr IH \n                    X₁ A₁ hX₁A₁ minor_expr IH,\n  /- self -/                  \n  { use univ,  use subset_refl univ, simp [reduced_expr], rw [restrict_univ, corestrict_univ] },\n  /-restrict-/\n  {\n    rcases IH with ⟨Z, ⟨hE₁Z, h⟩⟩,\n    use Z, use subset.trans hX₁E₁ hE₁Z, \n    rw ← restriction_of_reduced,\n    dunfold to_minor,\n    rw h,\n  },\n  /-corestrict-/\n  {\n    rcases IH with ⟨Z, ⟨hA₁Z, h⟩⟩,\n    use X₁ ∪ (Z \\ A₁), use subset_union_left X₁ _,\n    rw ←corestriction_of_reduced _ _ _ hX₁A₁ hA₁Z,\n    dunfold to_minor,\n    rw h, \n  }\nend\n\n/-lemma has_representation {M : rankfun U} {E : set U} (expr : minor_on E) :\n  (∃ (C D : set U) (hCD : C ∩ D = ∅),  \n    (C ∪ D)ᶜ = E \n    ∧ ((to_minor (contract_delete C D hCD) M) ≅ (to_minor expr M))) :=\nbegin\n  sorry, \nend-/\n\n\n/-lemma has_good_representation {M : rankfun U} {E : set U} (expr : minor_on E) :\n  (∃ (C D : set U) (hCD : C ∩ D = ∅),  \n    (C ∪ D)ᶜ = E ∧\n    is_indep M C ∧ is_coindep M D \n    ∧ ((to_minor (contract_delete C D hCD) M) ≅ (to_minor expr M))) := sorry-/\n  \nend minor \nend ftype \n\n\n\n\n-- A larger-rank set can be used to add a smaller-rank one. Old proof that takes a minor\n\n/-lemma rank_augment {M : rankfun U} {X Z : set U} : (M.r X < M.r Z) → \n  ∃ z, z ∈ Z ∧ M.r X < M.r (X ∪ z) := \nlet \n    hcr    : Z \\ X ⊆ X ∪ Z         := subset.trans (diff_subset Z X) (subset_union_right X Z),\n    hr     : X ∪ Z ⊆ univ             :=  subset_univ (X ∪ Z),  \n    hdiff  : (X ∪ Z) \\ (Z \\ X) = X := union_diff_diff _ _,\n    hunion : (Z \\ X) ∪ X = X ∪ Z   := by rw [union_comm _ X, union_diff] \nin \nbegin\n  intros hrXrZ, by_contradiction h, push_neg at h, \n  --pertinent minor M' : restrict to X ∪ Z then corestrict to Z-X\n  let M' := to_minor (corestrict (Z \\ X) hcr (restrict (X ∪ Z) hr self)) M, \n  -- simplified rank function of M' \n  have hrM' : ∀ (J : subftype (Z \\ X)), M'.r J = M.r (J ∪ X) - M.r (X) := \n    by {intros J, calc _  = M.r (J ∪ ((X ∪ Z) \\ (Z \\ X))) - M.r ((X ∪ Z) \\ (Z \\ X)) : rfl ... = _ : by rw hdiff}, \n\n  have hr'univ := hrM' univ, \n  rw [coe_univ (Z \\ X), hunion] at hr'univ, \n\n  have : M'.r univ ≠ 0 := by linarith [by calc M'.r univ = _ : hr'univ ... ≥ M.r Z - M.r X : by linarith [M.R2 Z (X ∪ Z) (subset_union_right X Z)]],\n\n  apply this, apply loopy_rank_zero, intros e he,\n  specialize h e (subset.trans ((e: subftype (Z \\ X)).property) (diff_subset _ _ )), \n  rw coe_single_subftype_compose at h, \n  rw [hrM' e, union_comm, coe_subftype_single_compose],\n  linarith [M.R2 _ _ (subset_union_left X e)],\nend\n-/", "meta": {"author": "apnelson1", "repo": "lean-matroids", "sha": "1880f5b4b9a99948368e35539672a9bf35cc09cc", "save_path": "github-repos/lean/apnelson1-lean-matroids", "path": "github-repos/lean/apnelson1-lean-matroids/lean-matroids-1880f5b4b9a99948368e35539672a9bf35cc09cc/src/old/old/minor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.72487026428967, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.47726726764509114}}
{"text": "\nuniverses u\n\ndef f {α : Type u} [BEq α] (xs : List α) (y : α) : α := do\nfor x in xs do\n  if x == y then\n    return x\nreturn y\n\nstructure S :=\n(key val : Nat)\n\ninstance : BEq S :=\n⟨fun a b => a.key == b.key⟩\n\ntheorem ex1 : f (α := S) [⟨1, 2⟩, ⟨3, 4⟩, ⟨5, 6⟩] ⟨3, 0⟩ = ⟨3, 4⟩ :=\nrfl\n\ntheorem ex2 : f (α := S) [⟨1, 2⟩, ⟨3, 4⟩, ⟨5, 6⟩] ⟨4, 10⟩ = ⟨4, 10⟩ :=\nrfl\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/run/forInUniv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4772396595524696}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.limits.shapes.finite_limits\n! leanprover-community/mathlib commit c3019c79074b0619edb4b27553a91b2e82242395\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.FinCategory\nimport Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts\nimport Mathlib.CategoryTheory.Limits.Shapes.Equalizers\nimport Mathlib.CategoryTheory.Limits.Shapes.WidePullbacks\nimport Mathlib.CategoryTheory.Limits.Shapes.Pullbacks\nimport Mathlib.Data.Fintype.Option\n\n/-!\n# Categories with finite limits.\n\nA typeclass for categories with all finite (co)limits.\n-/\n\n\nuniverse w' w v' u' v u\n\nnoncomputable section\n\nopen CategoryTheory\n\nnamespace CategoryTheory.Limits\n\nvariable (C : Type u) [Category.{v} C]\n\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\n/-- A category has all finite limits if every functor `J ⥤ C` with a `FinCategory J`\ninstance and `J : Type` has a limit.\n\nThis is often called 'finitely complete'.\n-/\nclass HasFiniteLimits : Prop where\n  /-- `C` has all limits over any type `J` whose objects and morphisms lie in the same universe\n  and which has `FinType` objects and morphisms-/\n  out (J : Type) [𝒥 : SmallCategory J] [@FinCategory J 𝒥] : @HasLimitsOfShape J 𝒥 C _\n#align category_theory.limits.has_finite_limits CategoryTheory.Limits.HasFiniteLimits\n\ninstance (priority := 100) hasLimitsOfShape_of_hasFiniteLimits (J : Type w) [SmallCategory J]\n    [FinCategory J] [HasFiniteLimits C] : HasLimitsOfShape J C := by\n  apply @hasLimitsOfShape_of_equivalence _ _ _ _ _ _ (FinCategory.equivAsType J) ?_\n  apply HasFiniteLimits.out\n#align category_theory.limits.has_limits_of_shape_of_has_finite_limits CategoryTheory.Limits.hasLimitsOfShape_of_hasFiniteLimits\n\ninstance (priority := 100) hasFiniteLimits_of_hasLimitsOfSize [HasLimitsOfSize.{v', u'} C] :\n    HasFiniteLimits C where\n  out := fun J hJ hJ' =>\n    haveI := hasLimitsOfSizeShrink.{0, 0} C\n    let F := @FinCategory.equivAsType J (@FinCategory.fintypeObj J hJ hJ') hJ hJ'\n    @hasLimitsOfShape_of_equivalence (@FinCategory.AsType J (@FinCategory.fintypeObj J hJ hJ'))\n    (@FinCategory.categoryAsType J (@FinCategory.fintypeObj J hJ hJ') hJ hJ') _ _ J hJ F _\n#align category_theory.limits.has_finite_limits_of_has_limits_of_size CategoryTheory.Limits.hasFiniteLimits_of_hasLimitsOfSize\n\n/-- If `C` has all limits, it has finite limits. -/\ninstance (priority := 100) hasFiniteLimits_of_hasLimits [HasLimits C] : HasFiniteLimits C :=\n  inferInstance\n#align category_theory.limits.has_finite_limits_of_has_limits CategoryTheory.Limits.hasFiniteLimits_of_hasLimits\n\n/-- We can always derive `HasFiniteLimits C` by providing limits at an\narbitrary universe. -/\ntheorem hasFiniteLimits_of_hasFiniteLimits_of_size\n    (h : ∀ (J : Type w) {𝒥 : SmallCategory J} (_ : @FinCategory J 𝒥), HasLimitsOfShape J C) :\n    HasFiniteLimits C where\n  out := fun J hJ hhJ => by\n    haveI := h (ULiftHom.{w} (ULift.{w} J)) <| @CategoryTheory.finCategoryUlift J hJ hhJ\n    have l :\n      @Equivalence J (ULiftHom (ULift J)) hJ (@ULiftHom.category (ULift J) (@uliftCategory J hJ))\n      := @ULiftHomULiftCategory.equiv J hJ\n    apply @hasLimitsOfShape_of_equivalence (ULiftHom (ULift J))\n      (@ULiftHom.category (ULift J) (@uliftCategory J hJ)) C _ J hJ\n      (@Equivalence.symm J hJ (ULiftHom (ULift J))\n      (@ULiftHom.category (ULift J) (@uliftCategory J hJ)) l) _\n    /- Porting note: tried to factor out (@instCategoryULiftHom (ULift J) (@uliftCategory J hJ)\n    but when doing that would then find the instance and say it was not definitionally equal to\n    to the provide one (the same thing factored out) -/\n#align category_theory.limits.has_finite_limits_of_has_finite_limits_of_size CategoryTheory.Limits.hasFiniteLimits_of_hasFiniteLimits_of_size\n\n/-- A category has all finite colimits if every functor `J ⥤ C` with a `FinCategory J`\ninstance and `J : Type` has a colimit.\n\nThis is often called 'finitely cocomplete'.\n-/\nclass HasFiniteColimits : Prop where\n  /-- `C` has all colimits over any type `J` whose objects and morphisms lie in the same universe\n  and which has `FinType` objects and morphisms-/\n  out (J : Type) [𝒥 : SmallCategory J] [@FinCategory J 𝒥] : @HasColimitsOfShape J 𝒥 C _\n#align category_theory.limits.has_finite_colimits CategoryTheory.Limits.HasFiniteColimits\n\ninstance (priority := 100) hasColimitsOfShape_of_hasFiniteColimits (J : Type w) [SmallCategory J]\n    [FinCategory J] [HasFiniteColimits C] : HasColimitsOfShape J C := by\n  refine @hasColimitsOfShape_of_equivalence _ _ _ _ _ _ (FinCategory.equivAsType J) ?_\n  apply HasFiniteColimits.out\n#align category_theory.limits.has_colimits_of_shape_of_has_finite_colimits CategoryTheory.Limits.hasColimitsOfShape_of_hasFiniteColimits\n\ninstance (priority := 100) hasFiniteColimits_of_hasColimitsOfSize [HasColimitsOfSize.{v', u'} C] :\n    HasFiniteColimits C where\n  out := fun J hJ hJ' =>\n    haveI := hasColimitsOfSize_shrink.{0, 0} C\n    let F := @FinCategory.equivAsType J (@FinCategory.fintypeObj J hJ hJ') hJ hJ'\n    @hasColimitsOfShape_of_equivalence (@FinCategory.AsType J (@FinCategory.fintypeObj J hJ hJ'))\n    (@FinCategory.categoryAsType J (@FinCategory.fintypeObj J hJ hJ') hJ hJ') _ _ J hJ F _\n#align category_theory.limits.has_finite_colimits_of_has_colimits_of_size CategoryTheory.Limits.hasFiniteColimits_of_hasColimitsOfSize\n\n/-- We can always derive `HasFiniteColimits C` by providing colimits at an\narbitrary universe. -/\ntheorem hasFiniteColimits_of_hasFiniteColimits_of_size\n    (h : ∀ (J : Type w) {𝒥 : SmallCategory J} (_ : @FinCategory J 𝒥), HasColimitsOfShape J C) :\n    HasFiniteColimits C where\n  out := fun J hJ hhJ => by\n    haveI := h (ULiftHom.{w} (ULift.{w} J)) <| @CategoryTheory.finCategoryUlift J hJ hhJ\n    have l :\n      @Equivalence J (ULiftHom (ULift J)) hJ (@ULiftHom.category (ULift J) (@uliftCategory J hJ))\n      := @ULiftHomULiftCategory.equiv J hJ\n    apply @hasColimitsOfShape_of_equivalence (ULiftHom (ULift J))\n      (@ULiftHom.category (ULift J) (@uliftCategory J hJ)) C _ J hJ\n      (@Equivalence.symm J hJ (ULiftHom (ULift J))\n      (@ULiftHom.category (ULift J) (@uliftCategory J hJ)) l) _\n#align category_theory.limits.has_finite_colimits_of_has_finite_colimits_of_size CategoryTheory.Limits.hasFiniteColimits_of_hasFiniteColimits_of_size\n\nsection\n\nopen WalkingParallelPair WalkingParallelPairHom\n\ninstance fintypeWalkingParallelPair : Fintype WalkingParallelPair where\n  elems := [WalkingParallelPair.zero, WalkingParallelPair.one].toFinset\n  complete x := by cases x <;> simp\n#align category_theory.limits.fintype_walking_parallel_pair CategoryTheory.Limits.fintypeWalkingParallelPair\n\n-- attribute [local tidy] tactic.case_bash Porting note: no tidy; no case_bash\n\ninstance (j j' : WalkingParallelPair) : Fintype (WalkingParallelPairHom j j') where\n  elems :=\n    WalkingParallelPair.recOn j\n      (WalkingParallelPair.recOn j' [WalkingParallelPairHom.id zero].toFinset\n        [left, right].toFinset)\n      (WalkingParallelPair.recOn j' ∅ [WalkingParallelPairHom.id one].toFinset)\n  complete := by\n    rintro (_|_) <;> simp\n    · cases j <;> simp\nend\n\ninstance : FinCategory WalkingParallelPair where\n  fintypeObj := fintypeWalkingParallelPair\n  fintypeHom := instFintypeWalkingParallelPairHom -- Porting note: could not be inferred\n\n/-- Equalizers are finite limits, so if `C` has all finite limits, it also has all equalizers -/\nexample [HasFiniteLimits C] : HasEqualizers C := by infer_instance\n\n/-- Coequalizers are finite colimits, of if `C` has all finite colimits, it also has all\n    coequalizers -/\nexample [HasFiniteColimits C] : HasCoequalizers C := by infer_instance\n\nvariable {J : Type v}\n\n-- attribute [local tidy] tactic.case_bash Porting note: no tidy; no case_bash\n\nnamespace WidePullbackShape\n\ninstance fintypeObj [Fintype J] : Fintype (WidePullbackShape J) := by\n  rw [WidePullbackShape]\n  infer_instance\n#align category_theory.limits.wide_pullback_shape.fintype_obj CategoryTheory.Limits.WidePullbackShape.fintypeObj\n\ninstance fintypeHom (j j' : WidePullbackShape J) : Fintype (j ⟶ j')\n    where\n  elems := by\n    cases' j' with j'\n    · cases' j with j\n      · exact {Hom.id none}\n      · exact {Hom.term j}\n    · by_cases some j' = j\n      · rw [h]\n        exact {Hom.id j}\n      · exact ∅\n  complete := by\n    rintro (_|_)\n    · cases j <;> simp\n    · simp\n#align category_theory.limits.wide_pullback_shape.fintype_hom CategoryTheory.Limits.WidePullbackShape.fintypeHom\n\nend WidePullbackShape\n\nnamespace WidePushoutShape\n\ninstance fintypeObj [Fintype J] : Fintype (WidePushoutShape J) := by\n  rw [WidePushoutShape]; infer_instance\n#align category_theory.limits.wide_pushout_shape.fintype_obj CategoryTheory.Limits.WidePushoutShape.fintypeObj\n\ninstance fintypeHom (j j' : WidePushoutShape J) : Fintype (j ⟶ j') where\n  elems := by\n    cases' j with j\n    · cases' j' with j'\n      · exact {Hom.id none}\n      · exact {Hom.init j'}\n    · by_cases some j = j'\n      · rw [h]\n        exact {Hom.id j'}\n      · exact ∅\n  complete := by\n    rintro (_|_)\n    · cases j <;> simp\n    · simp\n#align category_theory.limits.wide_pushout_shape.fintype_hom CategoryTheory.Limits.WidePushoutShape.fintypeHom\n\nend WidePushoutShape\n\ninstance finCategoryWidePullback [Fintype J] : FinCategory (WidePullbackShape J)\n    where fintypeHom := WidePullbackShape.fintypeHom\n#align category_theory.limits.fin_category_wide_pullback CategoryTheory.Limits.finCategoryWidePullback\n\ninstance finCategoryWidePushout [Fintype J] : FinCategory (WidePushoutShape J)\n    where fintypeHom := WidePushoutShape.fintypeHom\n#align category_theory.limits.fin_category_wide_pushout CategoryTheory.Limits.finCategoryWidePushout\n\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\n/-- `HasFiniteWidePullbacks` represents a choice of wide pullback\nfor every finite collection of morphisms\n-/\nclass HasFiniteWidePullbacks : Prop where\n  /-- `C` has all wide pullbacks any Fintype `J`-/\n  out (J : Type) [Fintype J] : HasLimitsOfShape (WidePullbackShape J) C\n#align category_theory.limits.has_finite_wide_pullbacks CategoryTheory.Limits.HasFiniteWidePullbacks\n\ninstance hasLimitsOfShape_widePullbackShape (J : Type) [Finite J] [HasFiniteWidePullbacks C] :\n    HasLimitsOfShape (WidePullbackShape J) C := by\n  cases nonempty_fintype J\n  haveI := @HasFiniteWidePullbacks.out C _ _ J\n  infer_instance\n#align category_theory.limits.has_limits_of_shape_wide_pullback_shape CategoryTheory.Limits.hasLimitsOfShape_widePullbackShape\n\n/-- `HasFiniteWidePushouts` represents a choice of wide pushout\nfor every finite collection of morphisms\n-/\nclass HasFiniteWidePushouts : Prop where\n  /-- `C` has all wide pushouts any Fintype `J`-/\n  out (J : Type) [Fintype J] : HasColimitsOfShape (WidePushoutShape J) C\n#align category_theory.limits.has_finite_wide_pushouts CategoryTheory.Limits.HasFiniteWidePushouts\n\ninstance hasColimitsOfShape_widePushoutShape (J : Type) [Finite J] [HasFiniteWidePushouts C] :\n    HasColimitsOfShape (WidePushoutShape J) C := by\n  cases nonempty_fintype J\n  haveI := @HasFiniteWidePushouts.out C _ _ J\n  infer_instance\n#align category_theory.limits.has_colimits_of_shape_wide_pushout_shape CategoryTheory.Limits.hasColimitsOfShape_widePushoutShape\n\n/-- Finite wide pullbacks are finite limits, so if `C` has all finite limits,\nit also has finite wide pullbacks\n-/\ntheorem hasFiniteWidePullbacks_of_hasFiniteLimits [HasFiniteLimits C] : HasFiniteWidePullbacks C :=\n  ⟨fun _ _ => HasFiniteLimits.out _⟩\n#align category_theory.limits.has_finite_wide_pullbacks_of_has_finite_limits CategoryTheory.Limits.hasFiniteWidePullbacks_of_hasFiniteLimits\n\n/-- Finite wide pushouts are finite colimits, so if `C` has all finite colimits,\nit also has finite wide pushouts\n-/\ntheorem hasFiniteWidePushouts_of_has_finite_limits [HasFiniteColimits C] :\n    HasFiniteWidePushouts C :=\n  ⟨fun _ _ => HasFiniteColimits.out _⟩\n#align category_theory.limits.has_finite_wide_pushouts_of_has_finite_limits CategoryTheory.Limits.hasFiniteWidePushouts_of_has_finite_limits\n\ninstance fintypeWalkingPair : Fintype WalkingPair where\n  elems := {WalkingPair.left, WalkingPair.right}\n  complete x := by cases x <;> simp\n#align category_theory.limits.fintype_walking_pair CategoryTheory.Limits.fintypeWalkingPair\n\n/-- Pullbacks are finite limits, so if `C` has all finite limits, it also has all pullbacks -/\nexample [HasFiniteWidePullbacks C] : HasPullbacks C := by infer_instance\n\n/-- Pushouts are finite colimits, so if `C` has all finite colimits, it also has all pushouts -/\nexample [HasFiniteWidePushouts C] : HasPushouts C := by infer_instance\n\nend CategoryTheory.Limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Limits/Shapes/FiniteLimits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.47723965792842127}}
{"text": "/-\nCopyright (c) 2022 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport computational_monads.simulation_semantics.simulate.basic\n\n/-!\n# Support of Simulations\n\nThis file contains more complex lemmas about the support of `simulate` and `simulate'`.\nIn particular it relates the `support` after `simulate` and `simulate'` to the original `support`,\nand gives lemmas for proving equalities between or properties of these `supports`.\n-/\n\nvariables {α β γ : Type} {spec spec' spec'' : oracle_spec} {S S' : Type}\n\nnamespace oracle_comp\n\nopen oracle_spec\n\nvariables (so : sim_oracle spec spec' S) (so' : sim_oracle spec spec'' S')\n  (a : α) (i : spec.ι) (t : spec.domain i) (oa oa' : oracle_comp spec α)\n  (ob ob' : α → oracle_comp spec β) (oc : β → oracle_comp spec γ) (s : S) (f : α → β)\n\nsection monad\n\nlemma support_simulate_map_bind (g : β → γ) : (simulate so (g <$> (oa >>= ob)) s).support =\n  ⋃ x ∈ (simulate so oa s).support, prod.map g id '' (simulate so (ob $ prod.fst x) x.2).support :=\nby simp only [support_simulate_map, support_simulate_bind, set.image_Union]\n\n-- TODO: can't be a simp lemma unless simulate doesn't auto unfold?\nlemma support_simulate_bind_map : (simulate so ((f <$> oa) >>= oc) s).support\n  = ⋃ x ∈ (simulate so oa s).support, (simulate so (oc (f $ prod.fst x)) x.2).support :=\nbegin\n  refine set.ext (λ z, _),\n  simp only [support_simulate_bind, support_simulate_map, set.mem_image, set.Union_exists,\n    set.Union_and, set.mem_Union],\n  exact ⟨λ h, let ⟨x, y, hy, hxy, hx⟩ := h in ⟨y, hy, by simpa only [← hxy] using hx⟩,\n    λ h, let ⟨x, hx, hz⟩ := h in ⟨(f x.1, x.2), x, hx, rfl, hz⟩⟩,\nend\n\nend monad\n\nsection induction\n\n/-- Lemma for inductively proving the support of a simulation is a specific function of the input.\nOften this is simpler than induction on the computation itself, especially the case of `bind`. -/\nlemma support_simulate_eq_induction {supp : Π (α : Type), oracle_comp spec α → S → set (α × S)}\n  (so : sim_oracle spec spec' S) (oa : oracle_comp spec α) (s : S)\n  (h_ret : ∀ α a s, supp α (return a) s = {(a, s)})\n  (h_bind : ∀ α β (oa : oracle_comp spec α) (ob : α → oracle_comp spec β) s,\n    supp β (oa >>= ob) s = ⋃ x ∈ (supp α oa s), supp β (ob $ prod.fst x) $ prod.snd x)\n  (h_query : ∀ i t s, supp (spec.range i) (query i t) s = (so i (t, s)).support) :\n  (simulate so oa s).support = supp α oa s :=\nbegin\n  induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t generalizing s,\n  { simp only [h_ret, simulate_return, support_return] },\n  { simp only [simulate_bind, support_bind, hoa, hob, h_bind] },\n  { simp only [h_query, simulate_query] }\nend\n\n/-- Slightly weaker version of `support_simulate_eq_induction` for `simulate'`. -/\nlemma support_simulate'_eq_induction {supp : Π (α : Type), oracle_comp spec α → S → set α}\n  (so : sim_oracle spec spec' S) (oa : oracle_comp spec α) (s : S)\n  (h_ret : ∀ α a s, supp α (return a) s = {a})\n  (h_bind : ∀ α β (oa : oracle_comp spec α) (ob : α → oracle_comp spec β) s,\n    supp β (oa >>= ob) s = ⋃ x ∈ (simulate so oa s).support, supp β (ob $ prod.fst x) $ prod.snd x)\n  (h_query : ∀ i t s, supp (spec.range i) (query i t) s = prod.fst '' (so i (t, s)).support) :\n  (simulate' so oa s).support = supp α oa s :=\nbegin\n  induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t generalizing s,\n  { simp only [h_ret, simulate'_return, support_map, support_return, set.image_singleton] },\n  { simp only [h_bind, ←hob, simulate'_bind, support_map_bind, support_simulate'] },\n  { simp only [h_query, simulate'_query, support_map] }\nend\n\n/-- Given a property `P` of oracle states, if any query call to the oracle preserves it,\nthen simulation of an entire computation with that oracle will also preserve it. -/\ntheorem support_state_simulate_induction (so : sim_oracle spec spec' S) (P : S → Prop)\n  (s : S) (hs : P s) (oa : oracle_comp spec α) (x : α × S) (hx : x ∈ (simulate so oa s).support)\n  (hso : ∀ i t s, ∀ x ∈ (so i (t, s)).support, P s → P (prod.snd x)) : P x.2 :=\nbegin\n  induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i' t' generalizing s,\n  { rw [support_simulate_return, set.mem_singleton_iff] at hx,\n    exact hx.symm ▸ hs },\n  { rw [mem_support_simulate_bind_iff] at hx,\n    obtain ⟨a, s', ha, ha'⟩ := hx,\n    exact hob a x s' (hoa (a, s') s hs ha) ha' },\n  { exact hso i' t' s x hx hs }\nend\n\nend induction\n\n/-- Since `support` assumes any possible query result, `simulate` will never reduce the support.\nIn particular the support of a simulation lies in the pullback of the original support. -/\ntheorem support_simulate_subset_preimage_support :\n  (simulate so oa s).support ⊆ prod.fst ⁻¹' oa.support :=\nbegin\n  rw [set.preimage],\n  induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t generalizing s,\n  { simp only [simulate_return, support_return, set.mem_singleton_iff,\n      set.singleton_subset_iff, set.mem_set_of_eq] },\n  { rw [support_simulate_bind],\n    refine set.Union_subset (λ x, set.Union_subset (λ hx, _)),\n    simp only [support_bind, set.mem_Union, exists_prop],\n    refine λ b hb, ⟨x.1, hoa s hx, hob x.1 x.2 hb⟩ },\n  { simp only [support_query, set.top_eq_univ, set.mem_univ, set.set_of_true, set.subset_univ] }\nend\n\n/-- Simulation only reduces the possible oracle outputs, so can't reduce the support. In particular\nthe first output of a simulation has support at most that of the original computation -/\nlemma support_simulate'_subset_support : (simulate' so oa s).support ⊆ oa.support :=\nbegin\n  refine (support_simulate' so oa s).symm ▸ λ x hx, _,\n  obtain ⟨y, hy, rfl⟩ := (set.mem_image prod.fst _ _).1 hx,\n  exact support_simulate_subset_preimage_support so oa s hy,\nend\n\nlemma mem_support_of_mem_support_simulate (x : α × S) (hx : x ∈ (simulate so oa s).support) :\n  x.1 ∈ oa.support := by simpa using (support_simulate_subset_preimage_support so oa s hx)\n\nlemma mem_support_of_mem_support_simulate' (x : α)\n  (hx : x ∈ (simulate' so oa s).support) : x ∈ oa.support :=\nsupport_simulate'_subset_support so oa s hx\n\n/-- If the first output of an oracle can take on any value (although the state might not),\nthen the first value of simulation has the same support as the original computation.\nFor example simulation with the identity oracle `idₛ` doesn't change the support,\n  and this also holds for something like a logging oracle that just records queries -/\ntheorem support_simulate'_eq_support (h : ∀ i t s, prod.fst '' (so i (t, s)).support = ⊤) :\n  (simulate' so oa s).support = oa.support :=\nbegin\n  refine set.eq_of_subset_of_subset (support_simulate'_subset_support so oa s) (λ x hx, _),\n  induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t generalizing s,\n  { simpa only [simulate'_return, support_map, support_return, set.image_singleton] using hx },\n  { simp only [support_simulate'_bind, support_bind, set.mem_Union] at hx ⊢,\n    obtain ⟨a, ha, hx⟩ := hx,\n    specialize hoa a ha s,\n    rw [support_simulate', set.mem_image] at hoa,\n    obtain ⟨⟨a', s'⟩, ha', ha''⟩ := hoa,\n    exact ⟨(a', s'), ha', hob a' x (let this : a = a' := ha''.symm in this ▸ hx) s'⟩ },\n  { simp only [support_simulate'_query, h i t s] }\nend\n\n/-- If the possible outputs of two oracles are the same for any inputs  regardless of their\ninternal states, then the `support` of `simulate'` with either oracle is the same.\nIntuitively the simulations *could* take the same branch at each oracle query, and while the\nprobabilities of divergence may vary, this doesn't affect the set of possible results. -/\ntheorem support_simulate'_eq_support_simulate'\n  {so : sim_oracle spec spec' S} {so' : sim_oracle spec spec'' S'}\n  (h : ∀ i t s s', prod.fst '' (so i (t, s)).support = prod.fst '' (so' i (t, s')).support)\n  (oa : oracle_comp spec α) (s : S) (s' : S') :\n  (simulate' so oa s).support = (simulate' so' oa s').support :=\nbegin\n  induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t generalizing s s',\n  { simp only [simulate'_return, support_map, support_return, set.image_singleton] },\n  { ext x,\n    simp_rw [support_simulate'_bind, set.mem_Union],\n    refine ⟨λ h, _, λ h, _⟩,\n    { obtain ⟨⟨a, t⟩, hoa', hob'⟩ := h,\n      have : ∃ u, (a, u) ∈ (simulate so oa s).support := ⟨t, hoa'⟩,\n      rw [← mem_support_simulate'_iff_exists_state, hoa s s',\n        mem_support_simulate'_iff_exists_state] at this,\n      obtain ⟨t', ht'⟩ := this,\n      exact ⟨(a, t'), ht', hob a t t' ▸ hob'⟩ },\n    { obtain ⟨⟨a, t⟩, hoa', hob'⟩ := h,\n      have : ∃ u, (a, u) ∈ (simulate so' oa s').support := ⟨t, hoa'⟩,\n      rw [← mem_support_simulate'_iff_exists_state, ← hoa s s',\n        mem_support_simulate'_iff_exists_state] at this,\n      obtain ⟨t', ht'⟩ := this,\n      exact ⟨(a, t'), ht', (hob a t' t).symm ▸ hob'⟩ } },\n  { simpa only [support_simulate'_query] using h i t s s' }\nend\n\nlemma support_simulate_eq_support_simulate\n  (so : sim_oracle spec spec' S) (so' : sim_oracle spec spec'' S)\n  (h : ∀ i t s s', (so i (t, s)).support = (so' i (t, s')).support) :\n  (simulate so oa s).support = (simulate so' oa s).support :=\nbegin\n  refine support_simulate_eq_induction so oa s _ (λ _ _ _ _ _, _) (λ _ _ _, _),\n  { simp only [simulate_return, support_return, eq_self_iff_true, forall_3_true_iff] },\n  { simp only [simulate_bind, support_bind, eq_self_iff_true] },\n  { rw [simulate_query, h]  }\nend\n\ntheorem support_simulate_simulate_eq_support_simulate (so so' : sim_oracle spec spec' S)\n  (h : ∀ i t s, (⋃ x ∈ (so i (t, s)).support, (so' i (t, prod.snd x)).support) =\n    (so i (t, s)).support) (s : S) (oa : oracle_comp spec α) :\n  (simulate so oa s >>= λ x, simulate so' oa x.2).support = (simulate so oa s).support :=\nbegin\n  refine symm (support_simulate_eq_induction so oa s (λ α a s, _) _ _),\n  { simp only [simulate_return, support_bind_return, support_return, set.image_singleton] },\n  { intros α β oa ob s,\n    ext x,\n\n    sorry },\n  { exact h }\nend\n\nend oracle_comp", "meta": {"author": "dtumad", "repo": "lean-crypto-formalization", "sha": "f975a9a9882120b509553a7ced9aa05b745ff154", "save_path": "github-repos/lean/dtumad-lean-crypto-formalization", "path": "github-repos/lean/dtumad-lean-crypto-formalization/lean-crypto-formalization-f975a9a9882120b509553a7ced9aa05b745ff154/src/computational_monads/simulation_semantics/simulate/support.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.7577943712746406, "lm_q1q2_score": 0.477239652662761}}
{"text": "import norm.norm_prime\nimport number_theory.cyclotomic.gal\nimport number_theory.cyclotomic.rat\n\nvariables {K : Type*} [field K] {ζ : K}\n\nopen_locale number_field\n\nopen polynomial algebra\n\nlocal notation `R` := 𝓞 K\n\nnamespace is_cyclotomic_extension.rat\n\nvariables {p : ℕ+} {k : ℕ} [hp : fact (p : ℕ).prime] [char_zero K]\n\ninclude hp\n\nlemma zeta_sub_one_prime [is_cyclotomic_extension {p ^ (k + 1)} ℚ K]\n  (hζ : is_primitive_root ζ ↑(p ^ (k + 1))) (hodd : p ≠ 2) :\n  prime (⟨ζ - 1, subalgebra.sub_mem _ (hζ.is_integral (p ^ _).pos) (subalgebra.one_mem _)⟩ : R) :=\nbegin\n  letI := is_cyclotomic_extension.number_field {p ^ (k + 1)} ℚ K,\n  letI := is_cyclotomic_extension.is_galois (p ^ (k + 1)) ℚ K,\n  rw [← hζ.sub_one_integral_power_basis_gen],\n  refine prime_of_norm_prime _,\n  rw [hζ.sub_one_integral_power_basis_gen],\n  simp only [ring_of_integers.norm, monoid_hom.restrict_apply, set_like.coe_mk,\n    monoid_hom.cod_restrict_apply, hζ.sub_one_norm_prime_ne_two\n    (cyclotomic.irreducible_rat (p ^ (k + 1)).pos) hodd],\n  rw [mul_equiv.prime_iff rat.ring_of_integers_equiv.to_mul_equiv],\n  simp only [coe_coe, ring_equiv.to_mul_equiv_eq_coe, ring_equiv.coe_to_mul_equiv],\n  convert nat.prime_iff_prime_int.1 hp.1,\n  refine equiv_like.injective rat.ring_of_integers_equiv.symm (subtype.ext _),\n  simp only [set_like.coe_mk, ring_equiv.symm_apply_apply],\n  norm_cast,\n  simp [← ring_equiv.coe_to_ring_hom]\nend\n\nlemma zeta_sub_one_prime' [h : is_cyclotomic_extension {p} ℚ K] (hζ : is_primitive_root ζ p)\n  (hodd : p ≠ 2) :\n  prime (⟨ζ - 1, subalgebra.sub_mem _ (hζ.is_integral p.pos) (subalgebra.one_mem _)⟩ : R) :=\nbegin\n  convert @zeta_sub_one_prime K _ _ p 0 _ _ (by { convert h, rw [zero_add, pow_one] }) _ hodd,\n  simpa,\nend\n\nend is_cyclotomic_extension.rat\n", "meta": {"author": "leanprover-community", "repo": "flt-regular", "sha": "1d0cecf99e8ab3f98b551e5932bf907042daa6ad", "save_path": "github-repos/lean/leanprover-community-flt-regular", "path": "github-repos/lean/leanprover-community-flt-regular/flt-regular-1d0cecf99e8ab3f98b551e5932bf907042daa6ad/src/number_theory/cyclotomic/zeta_sub_one_prime.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4772396352417319}}
{"text": "lemma contrapositive (P Q : Prop) : (P → Q) → (¬ Q → ¬ P) :=\nbegin\nrepeat {rw not_iff_imp_false},\nintros f g p,\napply g,\nexact f p,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/4-proposition-world/l8.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4771916328294449}}
{"text": "import tactic\nimport prefixes\nimport games\n\nopen list set\n\nnoncomputable theory\nopen_locale classical\n\n-- We need to assume α is nonempty to construct the strategy\nvariables {α β : Type*} [inhabited α] {G : game α β} (σ : quasi_strategy G)\n\ndef choice_map (f : β → set α) : β → α :=\nλ b, if h : (f b).nonempty then h.some else inhabited.default\n\nlemma choice_map_def (f : β → set α) : ∀ b, (f  b).nonempty → choice_map f b ∈ f b :=\nbegin\n  intros b hfb,\n  simp [choice_map, hfb],\n  exact hfb.some_mem,\nend\n\ndef strategy_map_of_quasi_strategy : list α → α :=\n  choice_map (λ t, {a | t.concat a ∈ σ.positions})\n\nlemma strategy_map_of_quasi_strategy_def :\n  ∀ t ∈ σ.positions, concat t (strategy_map_of_quasi_strategy σ t) ∈ σ.positions :=\nbegin\n  intros t tpos,\n  change strategy_map_of_quasi_strategy σ t ∈ {a | t.concat a ∈ σ.positions},\n  unfold strategy_map_of_quasi_strategy,\n  apply choice_map_def,\n  by_cases G.turn t = σ.player,\n  { exact (σ.is_quasi_strategy t tpos).1 h, },\n  use inhabited.default,\n  exact (σ.is_quasi_strategy t tpos).2 h inhabited.default,\nend\n\ndef level_by_level_subtree_of_quasi_strategy :\n  ℕ → set (list α)\n| 0     := λ t, t ∈ σ.positions ∧ t = nil\n| (n+1) := λ t, t ∈ σ.positions\n                ∧ (t.init ∈ σ.positions\n                    → t.init ∈ level_by_level_subtree_of_quasi_strategy n)\n                ∧ (t.init ∈ σ.positions → G.turn t.init = σ.player\n                    → t.ilast = strategy_map_of_quasi_strategy σ t.init)\n\ndef subtree_of_quasi_strategy : set (list α) :=\n  ⋃ n, level_by_level_subtree_of_quasi_strategy σ n\n\nlemma subtree_of_quasi_strategy_def {G : game α β} {σ : quasi_strategy G} {t : list α} :\n  t ∈ subtree_of_quasi_strategy σ ↔ t ∈ level_by_level_subtree_of_quasi_strategy σ t.length :=\nbegin\n  unfold subtree_of_quasi_strategy,\n  rw mem_Union,\n  refine ⟨_, λ h, ⟨t.length, h⟩⟩,\n  induction h : t.length generalizing t,\n  { rw eq_nil_of_length_eq_zero h,\n    rintros ⟨k, hk⟩,\n    cases k,\n    exact hk,\n    use [hk.1, rfl], },\n  rintros ⟨k, hk⟩,\n  cases k,\n  { rw hk.2 at h, contradiction, },\n  by_cases hinit : t.init ∈ σ.positions,\n  { have : t.init.length = n,\n    { change t.init.length = n.succ - 1,\n      rw ← h,\n      apply length_init, },\n    use hk.1,\n    split,\n    { intros _, exact ih this ⟨k, (hk.2.1 hinit)⟩, },\n    intros _ h, exact hk.2.2 hinit h, },\n  use hk.1,\n  split; intros contra; contradiction,\nend\n\nlemma position_of_position_subtree {t : list α} :\n  t ∈ subtree_of_quasi_strategy σ → t ∈ σ.positions :=\nbegin\n  rw subtree_of_quasi_strategy_def,\n  cases t with h t,\n  { exact λ h, h.1, },\n  exact λ h, h.1,\nend\n\nlemma list.init_concat : ∀ (l : list α) (a : α), (l.concat a).init = l\n| [] a := rfl\n| [x] a := rfl\n| (x :: y :: l) a := by simp [init]\n\nlemma list.ilast_concat : ∀ (l : list α) (a : α), (l.concat a).ilast = a\n| [] a := rfl\n| [x] a := rfl\n| [x, y] a := rfl\n| [x, y, z] a := rfl\n| (x :: y :: z :: l) a := by {  simp [ilast],\n                                rw [← cons_append, ← concat_append, append_nil],\n                                apply list.ilast_concat, }\n\nlemma list.nil_of_prefix_init {l : list α} : l <+: l.init → l = nil :=\nbegin\n  intros h,\n  apply eq_nil_of_length_eq_zero,\n  have := h.length_le,\n  rw l.length_init at this,\n  linarith,\nend\n\ninstance strategy_of_quasi_strategy : quasi_strategy G :=\n{ player := σ.player,\n  positions := subtree_of_quasi_strategy σ,\n  is_quasi_strategy :=\n  begin\n    intros t ht,\n    rw subtree_of_quasi_strategy_def at ht,\n    -- Didn't need induction, just two cases\n    cases h : t,\n    { rw h at ht,\n      split,\n      { intros turn,\n        use strategy_map_of_quasi_strategy σ nil,\n        rw subtree_of_quasi_strategy_def,\n        use strategy_map_of_quasi_strategy_def σ nil ht.1,\n        split,\n        { intros _,\n          change nil ∈ level_by_level_subtree_of_quasi_strategy σ 0,\n          use [ht.1, rfl], },\n        intros _ _,\n        exact rfl, },\n      intros turn a,\n      rw subtree_of_quasi_strategy_def,\n      use [(σ.is_quasi_strategy nil ht.1).2 turn a],\n      split,\n      { intros _,\n        change nil ∈ level_by_level_subtree_of_quasi_strategy σ 0,\n        use [ht.1, rfl], },\n      intros _ contra,\n      exfalso,\n      change game.turn nil = _ at contra,\n      exact turn contra, },\n    have hn : t.length = tl.length + 1,\n    { rw h, simp, },\n    rw ← h,\n    rw hn at ht,\n    rcases ht with ⟨ht, ⟨tinit, tplay⟩⟩,\n    split,\n    { intros turn,\n      use strategy_map_of_quasi_strategy σ t,\n      rw subtree_of_quasi_strategy_def,\n      simp only [length_concat],\n      use strategy_map_of_quasi_strategy_def σ t ht,\n      rw list.init_concat,\n      split,\n      { intros _,\n        rw hn,\n        unfold level_by_level_subtree_of_quasi_strategy,\n        use [ht, tinit, tplay], },\n      intros _ _,\n      rw list.ilast_concat, },\n    intros turn a,\n    rw subtree_of_quasi_strategy_def,\n    simp only [length_concat],\n    unfold level_by_level_subtree_of_quasi_strategy,\n    use [(σ.is_quasi_strategy t ht).2 turn a],\n    rw list.init_concat,\n    split,\n    { intros _,\n      rw hn,\n      unfold level_by_level_subtree_of_quasi_strategy,\n      use [ht, tinit, tplay], },\n    intros _ contra,\n    exfalso,\n    exact turn contra,\n  end }\n\ntheorem is_strategy_of_quasi_strategy :\n  is_strategy (strategy_of_quasi_strategy σ) :=\nbegin\n  intros t tpos tturn,\n  use strategy_map_of_quasi_strategy σ t,\n  split,\n  { change t.concat (strategy_map_of_quasi_strategy σ t) ∈ (subtree_of_quasi_strategy σ),\n    rw subtree_of_quasi_strategy_def,\n    simp only [length_concat],\n    split,\n    { apply strategy_map_of_quasi_strategy_def,\n      apply position_of_position_subtree,\n      exact tpos, },\n    split,\n    { intros _,\n      rw list.init_concat,\n      rw ← subtree_of_quasi_strategy_def,\n      exact tpos, },\n    intros _ _,\n    rw [list.ilast_concat, list.init_concat], },\n  intros a tapos,\n  change t.concat a ∈ subtree_of_quasi_strategy σ at tapos,\n  rw [subtree_of_quasi_strategy_def, length_concat] at tapos,\n  rcases tapos with ⟨_, ⟨_, h⟩⟩,\n  rw [list.init_concat, list.ilast_concat] at h,\n  exact h (position_of_position_subtree σ tpos) tturn,\nend\n\nlemma in_subtree_of_quasi_strategy (s : list α) :\n  s ∈ σ.positions ∧ (s ≠ nil → s.init ∉ σ.positions) → s ∈ subtree_of_quasi_strategy σ :=\nbegin\n  rintros ⟨hs, hsinit⟩,\n  rw subtree_of_quasi_strategy_def,\n  cases s,\n  { use hs, },\n  use hs,\n  have : s_hd :: s_tl ≠ nil,\n  { simp, },\n  have hsinit := hsinit this,\n  split,\n  { intros contra, contradiction, },\n  intros contra, contradiction,\nend\n\nlemma s_strategy_of_s_quasi_strategy (s : list α) :\n  s_quasi_strategy σ s → s_quasi_strategy (strategy_of_quasi_strategy σ) s :=\nbegin\n  intros hs,\n  split,\n  { apply in_subtree_of_quasi_strategy,\n    use hs.1,\n    contrapose!,\n    intros hsinit,\n    exact list.nil_of_prefix_init (hs.2 s.init hsinit), },\n  intros t tpos,\n  have : t ∈ σ.positions,\n  { apply position_of_position_subtree σ tpos, },\n  exact hs.2 t this,\nend\n\nvariables (X : (ℕ → α) → β)\n\ntheorem winning_strategy_of_winning_quasi_strategy :\n  winning σ X → winning (strategy_of_quasi_strategy σ) X :=\nbegin\n  intros winning,\n  intros f fplay,\n  change X f = σ.player,\n  apply winning f,\n  cases fplay with N hN,\n  use N,\n  intros n hn,\n  apply position_of_position_subtree,\n  exact hN n hn,\nend", "meta": {"author": "pglutz", "repo": "determinacy_in_lean", "sha": "bd5119aa016a0d3b00c7dd22e41c63e363f327a5", "save_path": "github-repos/lean/pglutz-determinacy_in_lean", "path": "github-repos/lean/pglutz-determinacy_in_lean/determinacy_in_lean-bd5119aa016a0d3b00c7dd22e41c63e363f327a5/src/strategy.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4771916153688993}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Gabriel Ebner\n\n! This file was ported from Lean 3 source module data.int.cast.basic\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Int.Cast.Defs\nimport Mathbin.Algebra.Group.Basic\n\n/-!\n# Cast of integers (additional theorems)\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves additional properties about the *canonical* homomorphism from\nthe integers into an additive group with a one (`int.cast`).\n\nThere is also `data.int.cast.lemmas`,\nwhich includes lemmas stated in terms of algebraic homomorphisms,\nand results involving the order structure of `ℤ`.\n\nBy contrast, this file's only import beyond `data.int.cast.defs` is `algebra.group.basic`.\n-/\n\n\nuniverse u\n\nnamespace Nat\n\nvariable {R : Type u} [AddGroupWithOne R]\n\n@[simp, norm_cast]\ntheorem cast_sub {m n} (h : m ≤ n) : ((n - m : ℕ) : R) = n - m :=\n  eq_sub_of_add_eq <| by rw [← cast_add, Nat.sub_add_cancel h]\n#align nat.cast_sub Nat.cast_subₓ\n\n/- warning: nat.cast_pred -> Nat.cast_pred is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1))))) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1))))) n) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Eq.{succ u1} R (Nat.cast.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (AddGroupWithOne.toSub.{u1} R _inst_1)) (Nat.cast.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) n) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align nat.cast_pred Nat.cast_predₓ'. -/\n@[simp, norm_cast]\ntheorem cast_pred : ∀ {n}, 0 < n → ((n - 1 : ℕ) : R) = n - 1\n  | 0, h => by cases h\n  | n + 1, h => by rw [cast_succ, add_sub_cancel] <;> rfl\n#align nat.cast_pred Nat.cast_pred\n\nend Nat\n\nopen Nat\n\nnamespace Int\n\nvariable {R : Type u} [AddGroupWithOne R]\n\n@[simp]\ntheorem cast_negSucc (n : ℕ) : (-[n+1] : R) = -(n + 1 : ℕ) :=\n  AddGroupWithOne.intCast_negSucc n\n#align int.cast_neg_succ_of_nat Int.cast_negSuccₓ\n\n@[simp, norm_cast]\ntheorem cast_zero : ((0 : ℤ) : R) = 0 :=\n  (cast_ofNat 0).trans Nat.cast_zero\n#align int.cast_zero Int.cast_zeroₓ\n\n@[simp, norm_cast]\ntheorem cast_ofNat (n : ℕ) : ((n : ℤ) : R) = n :=\n  cast_ofNat _\n#align int.cast_coe_nat Int.cast_ofNatₓ\n\n@[simp, norm_cast]\ntheorem cast_one : ((1 : ℤ) : R) = 1 :=\n  show (((1 : ℕ) : ℤ) : R) = 1 by simp\n#align int.cast_one Int.cast_oneₓ\n\n@[simp, norm_cast]\ntheorem cast_neg : ∀ n, ((-n : ℤ) : R) = -n\n  | (0 : ℕ) => by erw [cast_zero, neg_zero]\n  | (n + 1 : ℕ) => by erw [cast_of_nat, cast_neg_succ_of_nat] <;> rfl\n  | -[n+1] => by erw [cast_of_nat, cast_neg_succ_of_nat, neg_neg]\n#align int.cast_neg Int.cast_negₓ\n\n@[simp]\ntheorem cast_subNatNat (m n) : ((Int.subNatNat m n : ℤ) : R) = m - n :=\n  by\n  unfold sub_nat_nat; cases e : n - m\n  · simp only [sub_nat_nat, cast_of_nat]\n    simp [e, Nat.le_of_sub_eq_zero e]\n  ·\n    rw [sub_nat_nat, cast_neg_succ_of_nat, Nat.add_one, ← e,\n      Nat.cast_sub <| _root_.le_of_lt <| Nat.lt_of_sub_eq_succ e, neg_sub]\n#align int.cast_sub_nat_nat Int.cast_subNatNatₓ\n\n#print Int.negOfNat_eq /-\ntheorem negOfNat_eq (n : ℕ) : negOfNat n = -(n : ℤ) := by cases n <;> rfl\n#align int.neg_of_nat_eq Int.negOfNat_eq\n-/\n\n/- warning: int.cast_neg_of_nat -> Int.cast_negOfNat is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] (n : Nat), Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) (Int.negOfNat n)) (Neg.neg.{u1} R (SubNegMonoid.toHasNeg.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1))))) n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] (n : Nat), Eq.{succ u1} R (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) (Int.negOfNat n)) (Neg.neg.{u1} R (AddGroupWithOne.toNeg.{u1} R _inst_1) (Nat.cast.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) n))\nCase conversion may be inaccurate. Consider using '#align int.cast_neg_of_nat Int.cast_negOfNatₓ'. -/\n@[simp]\ntheorem cast_negOfNat (n : ℕ) : ((negOfNat n : ℤ) : R) = -n := by simp [neg_of_nat_eq]\n#align int.cast_neg_of_nat Int.cast_negOfNat\n\n@[simp, norm_cast]\ntheorem cast_add : ∀ m n, ((m + n : ℤ) : R) = m + n\n  | (m : ℕ), (n : ℕ) => by simp [← Int.ofNat_add]\n  | (m : ℕ), -[n+1] => by erw [cast_sub_nat_nat, cast_coe_nat, cast_neg_succ_of_nat, sub_eq_add_neg]\n  | -[m+1], (n : ℕ) => by\n    erw [cast_sub_nat_nat, cast_coe_nat, cast_neg_succ_of_nat, sub_eq_iff_eq_add, add_assoc,\n      eq_neg_add_iff_add_eq, ← Nat.cast_add, ← Nat.cast_add, Nat.add_comm]\n  | -[m+1], -[n+1] =>\n    show (-[m + n + 1+1] : R) = _ by\n      rw [cast_neg_succ_of_nat, cast_neg_succ_of_nat, cast_neg_succ_of_nat, ← neg_add_rev, ←\n        Nat.cast_add, Nat.add_right_comm m n 1, Nat.add_assoc, Nat.add_comm]\n#align int.cast_add Int.cast_addₓ\n\n@[simp, norm_cast]\ntheorem cast_sub (m n) : ((m - n : ℤ) : R) = m - n := by simp [Int.sub_eq_add_neg, sub_eq_add_neg]\n#align int.cast_sub Int.cast_subₓ\n\n#print Int.ofNat_bit0 /-\n@[simp, norm_cast]\ntheorem ofNat_bit0 (n : ℕ) : (↑(bit0 n) : ℤ) = bit0 ↑n :=\n  rfl\n#align int.coe_nat_bit0 Int.ofNat_bit0\n-/\n\n#print Int.ofNat_bit1 /-\n@[simp, norm_cast]\ntheorem ofNat_bit1 (n : ℕ) : (↑(bit1 n) : ℤ) = bit1 ↑n :=\n  rfl\n#align int.coe_nat_bit1 Int.ofNat_bit1\n-/\n\n/- warning: int.cast_bit0 -> Int.cast_bit0 is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] (n : Int), Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) (bit0.{0} Int Int.hasAdd n)) (bit0.{u1} R (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] (n : Int), Eq.{succ u1} R (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) (bit0.{0} Int Int.instAddInt n)) (bit0.{u1} R (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align int.cast_bit0 Int.cast_bit0ₓ'. -/\n@[simp, norm_cast]\ntheorem cast_bit0 (n : ℤ) : ((bit0 n : ℤ) : R) = bit0 n :=\n  cast_add _ _\n#align int.cast_bit0 Int.cast_bit0\n\n/- warning: int.cast_bit1 -> Int.cast_bit1 is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] (n : Int), Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) (bit1.{0} Int Int.hasOne Int.hasAdd n)) (bit1.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) n))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R] (n : Int), Eq.{succ u1} R (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) (bit1.{0} Int (One.ofOfNat1.{0} Int (instOfNatInt 1)) Int.instAddInt n)) (bit1.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) (AddZeroClass.toAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align int.cast_bit1 Int.cast_bit1ₓ'. -/\n@[simp, norm_cast]\ntheorem cast_bit1 (n : ℤ) : ((bit1 n : ℤ) : R) = bit1 n := by\n  rw [bit1, cast_add, cast_one, cast_bit0] <;> rfl\n#align int.cast_bit1 Int.cast_bit1\n\n/- warning: int.cast_two -> Int.cast_two is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R], Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R], Eq.{succ u1} R (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2))) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))\nCase conversion may be inaccurate. Consider using '#align int.cast_two Int.cast_twoₓ'. -/\ntheorem cast_two : ((2 : ℤ) : R) = 2 := by simp\n#align int.cast_two Int.cast_two\n\n/- warning: int.cast_three -> Int.cast_three is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R], Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) (OfNat.ofNat.{0} Int 3 (OfNat.mk.{0} Int 3 (bit1.{0} Int Int.hasOne Int.hasAdd (One.one.{0} Int Int.hasOne))))) (OfNat.ofNat.{u1} R 3 (OfNat.mk.{u1} R 3 (bit1.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R], Eq.{succ u1} R (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) (OfNat.ofNat.{0} Int 3 (instOfNatInt 3))) (OfNat.ofNat.{u1} R 3 (instOfNat.{u1} R 3 (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))))\nCase conversion may be inaccurate. Consider using '#align int.cast_three Int.cast_threeₓ'. -/\ntheorem cast_three : ((3 : ℤ) : R) = 3 := by simp\n#align int.cast_three Int.cast_three\n\n/- warning: int.cast_four -> Int.cast_four is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R], Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R _inst_1)))) (OfNat.ofNat.{0} Int 4 (OfNat.mk.{0} Int 4 (bit0.{0} Int Int.hasAdd (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))))) (OfNat.ofNat.{u1} R 4 (OfNat.mk.{u1} R 4 (bit0.{u1} R (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) (bit0.{u1} R (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : AddGroupWithOne.{u1} R], Eq.{succ u1} R (Int.cast.{u1} R (AddGroupWithOne.toIntCast.{u1} R _inst_1) (OfNat.ofNat.{0} Int 4 (instOfNatInt 4))) (OfNat.ofNat.{u1} R 4 (instOfNat.{u1} R 4 (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))))\nCase conversion may be inaccurate. Consider using '#align int.cast_four Int.cast_fourₓ'. -/\ntheorem cast_four : ((4 : ℤ) : R) = 4 := by simp\n#align int.cast_four Int.cast_four\n\nend Int\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Int/Cast/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.4771434680974715}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n\nA model of ZFC in Lean.\n-/\nimport data.set.basic\n\nuniverses u v\n\n/-- The type of `n`-ary functions `α → α → ... → α`. -/\ndef arity (α : Type u) : nat → Type u\n| 0     := α\n| (n+1) := α → arity n\n\n/-- The type of pre-sets in universe `u`. A pre-set\n  is a family of pre-sets indexed by a type in `Type u`.\n  The ZFC universe is defined as a quotient of this\n  to ensure extensionality. -/\ninductive pSet : Type (u+1)\n| mk (α : Type u) (A : α → pSet) : pSet\n\nnamespace pSet\n\n/-- The underlying type of a pre-set -/\ndef type : pSet → Type u\n| ⟨α, A⟩ := α\n\n/-- The underlying pre-set family of a pre-set -/\ndef func : Π (x : pSet), x.type → pSet\n| ⟨α, A⟩ := A\n\ntheorem mk_type_func : Π (x : pSet), mk x.type x.func = x\n| ⟨α, A⟩ := rfl\n\n/-- Two pre-sets are extensionally equivalent if every\n  element of the first family is extensionally equivalent to\n  some element of the second family and vice-versa. -/\ndef equiv (x y : pSet) : Prop :=\npSet.rec (λα z m ⟨β, B⟩, (∀a, ∃b, m a (B b)) ∧ (∀b, ∃a, m a (B b))) x y\n\ntheorem equiv.refl (x) : equiv x x :=\npSet.rec_on x $ λα A IH, ⟨λa, ⟨a, IH a⟩, λa, ⟨a, IH a⟩⟩\n\ntheorem equiv.euc {x} : Π {y z}, equiv x y → equiv z y → equiv x z :=\npSet.rec_on x $ λα A IH y, pSet.cases_on y $ λβ B ⟨γ, Γ⟩ ⟨αβ, βα⟩ ⟨γβ, βγ⟩,\n⟨λa, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, IH a ab bc⟩,\n  λc, let ⟨b, cb⟩ := γβ c, ⟨a, ba⟩ := βα b in ⟨a, IH a ba cb⟩⟩\n\ntheorem equiv.symm {x y} : equiv x y → equiv y x :=\nequiv.euc (equiv.refl y)\n\ntheorem equiv.trans {x y z} (h1 : equiv x y) (h2 : equiv y z) : equiv x z :=\nequiv.euc h1 (equiv.symm h2)\n\ninstance setoid : setoid pSet :=\n⟨pSet.equiv, equiv.refl, λx y, equiv.symm, λx y z, equiv.trans⟩\n\nprotected def subset : pSet → pSet → Prop\n| ⟨α, A⟩ ⟨β, B⟩ := ∀a, ∃b, equiv (A a) (B b)\n\ninstance : has_subset pSet := ⟨pSet.subset⟩\n\ntheorem equiv.ext : Π (x y : pSet), equiv x y ↔ (x ⊆ y ∧ y ⊆ x)\n| ⟨α, A⟩ ⟨β, B⟩ :=\n  ⟨λ⟨αβ, βα⟩, ⟨αβ, λb, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩,\n    λ⟨αβ, βα⟩, ⟨αβ, λb, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩⟩\n\ntheorem subset.congr_left : Π {x y z : pSet}, equiv x y → (x ⊆ z ↔ y ⊆ z)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=\n  ⟨λαγ b, let ⟨a, ba⟩ := βα b, ⟨c, ac⟩ := αγ a in ⟨c, equiv.trans (equiv.symm ba) ac⟩,\n    λβγ a, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, equiv.trans ab bc⟩⟩\n\ntheorem subset.congr_right : Π {x y z : pSet}, equiv x y → (z ⊆ x ↔ z ⊆ y)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=\n  ⟨λγα c, let ⟨a, ca⟩ := γα c, ⟨b, ab⟩ := αβ a in ⟨b, equiv.trans ca ab⟩,\n    λγβ c, let ⟨b, cb⟩ := γβ c, ⟨a, ab⟩ := βα b in ⟨a, equiv.trans cb (equiv.symm ab)⟩⟩\n\n/-- `x ∈ y` as pre-sets if `x` is extensionally equivalent to a member\n  of the family `y`. -/\ndef mem : pSet → pSet → Prop\n| x ⟨β, B⟩ := ∃b, equiv x (B b)\ninstance : has_mem pSet.{u} pSet.{u} := ⟨mem⟩\n\ntheorem mem.mk {α: Type u} (A : α → pSet) (a : α) : A a ∈ mk α A :=\nshow mem (A a) ⟨α, A⟩, from ⟨a, equiv.refl (A a)⟩\n\ntheorem mem.ext : Π {x y : pSet.{u}}, (∀w:pSet.{u}, w ∈ x ↔ w ∈ y) → equiv x y\n| ⟨α, A⟩ ⟨β, B⟩ h := ⟨λa, (h (A a)).1 (mem.mk A a),\n    λb, let ⟨a, ha⟩ := (h (B b)).2 (mem.mk B b) in ⟨a, equiv.symm ha⟩⟩\n\ntheorem mem.congr_right : Π {x y : pSet.{u}}, equiv x y → (∀{w:pSet.{u}}, w ∈ x ↔ w ∈ y)\n| ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩ w :=\n  ⟨λ⟨a, ha⟩, let ⟨b, hb⟩ := αβ a in ⟨b, equiv.trans ha hb⟩,\n    λ⟨b, hb⟩, let ⟨a, ha⟩ := βα b in ⟨a, equiv.euc hb ha⟩⟩\n\ntheorem equiv_iff_mem {x y : pSet.{u}} : equiv x y ↔ (∀{w:pSet.{u}}, w ∈ x ↔ w ∈ y) :=\n⟨mem.congr_right, match x, y with\n| ⟨α, A⟩, ⟨β, B⟩, h := ⟨λ a, h.1 (mem.mk A a), λ b,\n  let ⟨a, h⟩ := h.2 (mem.mk B b) in ⟨a, h.symm⟩⟩\nend⟩\n\ntheorem mem.congr_left : Π {x y : pSet.{u}}, equiv x y → (∀{w : pSet.{u}}, x ∈ w ↔ y ∈ w)\n| x y h ⟨α, A⟩ := ⟨λ⟨a, ha⟩, ⟨a, equiv.trans (equiv.symm h) ha⟩, λ⟨a, ha⟩, ⟨a, equiv.trans h ha⟩⟩\n\n/-- Convert a pre-set to a `set` of pre-sets. -/\ndef to_set (u : pSet.{u}) : set pSet.{u} := {x | x ∈ u}\n\n/-- Two pre-sets are equivalent iff they have the same members. -/\ntheorem equiv.eq {x y : pSet} : equiv x y ↔ to_set x = to_set y :=\nequiv_iff_mem.trans (set.ext_iff _ _).symm\n\ninstance : has_coe pSet (set pSet) := ⟨to_set⟩\n\n/-- The empty pre-set -/\nprotected def empty : pSet := ⟨ulift empty, λe, match e with end⟩\n\ninstance : has_emptyc pSet := ⟨pSet.empty⟩\n\ntheorem mem_empty (x : pSet.{u}) : x ∉ (∅:pSet.{u}) := λe, match e with end\n\n/-- Insert an element into a pre-set -/\nprotected def insert : pSet → pSet → pSet\n| u ⟨α, A⟩ := ⟨option α, λo, option.rec u A o⟩\n\ninstance : has_insert pSet pSet := ⟨pSet.insert⟩\n\n/-- The n-th von Neumann ordinal -/\ndef of_nat : ℕ → pSet\n| 0     := ∅\n| (n+1) := pSet.insert (of_nat n) (of_nat n)\n\n/-- The von Neumann ordinal ω -/\ndef omega : pSet := ⟨ulift ℕ, λn, of_nat n.down⟩\n\n/-- The separation operation `{x ∈ a | p x}` -/\nprotected def sep (p : set pSet) : pSet → pSet\n| ⟨α, A⟩ := ⟨{a // p (A a)}, λx, A x.1⟩\n\ninstance : has_sep pSet pSet := ⟨pSet.sep⟩\n\n/-- The powerset operator -/\ndef powerset : pSet → pSet\n| ⟨α, A⟩ := ⟨set α, λp, ⟨{a // p a}, λx, A x.1⟩⟩\n\ntheorem mem_powerset : Π {x y : pSet}, y ∈ powerset x ↔ y ⊆ x\n| ⟨α, A⟩ ⟨β, B⟩ := ⟨λ⟨p, e⟩, (subset.congr_left e).2 $ λ⟨a, pa⟩, ⟨a, equiv.refl (A a)⟩,\n  λβα, ⟨{a | ∃b, equiv (B b) (A a)}, λb, let ⟨a, ba⟩ := βα b in ⟨⟨a, b, ba⟩, ba⟩,\n    λ⟨a, b, ba⟩, ⟨b, ba⟩⟩⟩\n\n/-- The set union operator -/\ndef Union : pSet → pSet\n| ⟨α, A⟩ := ⟨Σx, (A x).type, λ⟨x, y⟩, (A x).func y⟩\n\ntheorem mem_Union : Π {x y : pSet.{u}}, y ∈ Union x ↔ ∃ z:pSet.{u}, ∃_:z ∈ x, y ∈ z\n| ⟨α, A⟩ y :=\n  ⟨λ⟨⟨a, c⟩, (e : equiv y ((A a).func c))⟩,\n    have func (A a) c ∈ mk (A a).type (A a).func, from mem.mk (A a).func c,\n    ⟨_, mem.mk _ _, (mem.congr_left e).2 (by rwa mk_type_func at this)⟩,\n  λ⟨⟨β, B⟩, ⟨a, (e:equiv (mk β B) (A a))⟩, ⟨b, yb⟩⟩,\n    by rw ←(mk_type_func (A a)) at e; exact\n    let ⟨βt, tβ⟩ := e, ⟨c, bc⟩ := βt b in ⟨⟨a, c⟩, equiv.trans yb bc⟩⟩\n\n/-- The image of a function -/\ndef image (f : pSet.{u} → pSet.{u}) : pSet.{u} → pSet\n| ⟨α, A⟩ := ⟨α, λa, f (A a)⟩\n\ntheorem mem_image {f : pSet.{u} → pSet.{u}} (H : ∀{x y}, equiv x y → equiv (f x) (f y)) :\n  Π {x y : pSet.{u}}, y ∈ image f x ↔ ∃z ∈ x, equiv y (f z)\n| ⟨α, A⟩ y := ⟨λ⟨a, ya⟩, ⟨A a, mem.mk A a, ya⟩, λ⟨z, ⟨a, za⟩, yz⟩, ⟨a, equiv.trans yz (H za)⟩⟩\n\n/-- Universe lift operation -/\nprotected def lift : pSet.{u} → pSet.{max u v}\n| ⟨α, A⟩ := ⟨ulift α, λ⟨x⟩, lift (A x)⟩\n\n/-- Embedding of one universe in another -/\ndef embed : pSet.{max (u+1) v} := ⟨ulift.{v u+1} pSet, λ⟨x⟩, pSet.lift.{u (max (u+1) v)} x⟩\n\ntheorem lift_mem_embed : Π (x : pSet.{u}), pSet.lift.{u (max (u+1) v)} x ∈ embed.{u v} :=\nλx, ⟨⟨x⟩, equiv.refl _⟩\n\n/-- Function equivalence is defined so that `f ~ g` iff\n  `∀ x y, x ~ y → f x ~ g y`. This extends to equivalence of n-ary\n  functions. -/\ndef arity.equiv : Π {n}, arity pSet.{u} n → arity pSet.{u} n → Prop\n| 0     a b := equiv a b\n| (n+1) a b := ∀ x y, equiv x y → arity.equiv (a x) (b y)\n\n/-- `resp n` is the collection of n-ary functions on `pSet` that respect\n  equivalence, i.e. when the inputs are equivalent the output is as well. -/\ndef resp (n) := { x : arity pSet.{u} n // arity.equiv x x }\n\ndef resp.f {n} (f : resp (n+1)) (x : pSet) : resp n :=\n⟨f.1 x, f.2 _ _ $ equiv.refl x⟩\n\ndef resp.equiv {n} (a b : resp n) : Prop := arity.equiv a.1 b.1\n\ntheorem resp.refl {n} (a : resp n) : resp.equiv a a := a.2\n\ntheorem resp.euc : Π {n} {a b c : resp n}, resp.equiv a b → resp.equiv c b → resp.equiv a c\n| 0     a b c hab hcb := equiv.euc hab hcb\n| (n+1) a b c hab hcb := by delta resp.equiv; simp [arity.equiv]; exact λx y h,\n  @resp.euc n (a.f x) (b.f y) (c.f y) (hab _ _ h) (hcb _ _ $ equiv.refl y)\n\ninstance resp.setoid {n} : setoid (resp n) :=\n⟨resp.equiv, resp.refl, λx y h, resp.euc (resp.refl y) h, λx y z h1 h2, resp.euc h1 $ resp.euc (resp.refl z) h2⟩\n\nend pSet\n\n/-- The ZFC universe of sets consists of the type of pre-sets,\n  quotiented by extensional equivalence. -/\ndef Set : Type (u+1) := quotient pSet.setoid.{u}\n\nnamespace pSet\n\nnamespace resp\n\ndef eval_aux : Π {n}, { f : resp n → arity Set.{u} n // ∀ (a b : resp n), resp.equiv a b → f a = f b }\n| 0     := ⟨λa, ⟦a.1⟧, λa b h, quotient.sound h⟩\n| (n+1) := let F : resp (n + 1) → arity Set (n + 1) := λa, @quotient.lift _ _ pSet.setoid\n    (λx, eval_aux.1 (a.f x)) (λb c h, eval_aux.2 _ _ (a.2 _ _ h)) in\n  ⟨F, λb c h, funext $ @quotient.ind _ _ (λq, F b q = F c q) $ λz,\n  eval_aux.2 (resp.f b z) (resp.f c z) (h _ _ (equiv.refl z))⟩\n\n/-- An equivalence-respecting function yields an n-ary Set function. -/\ndef eval (n) : resp n → arity Set.{u} n := eval_aux.1\n\n@[simp] theorem eval_val {n f x} : (@eval (n+1) f : Set → arity Set n) ⟦x⟧ = eval n (resp.f f x) := rfl\n\nend resp\n\n/-- A set function is \"definable\" if it is the image of some n-ary pre-set\n  function. This isn't exactly definability, but is useful as a sufficient\n  condition for functions that have a computable image. -/\n@[class] inductive definable (n) : arity Set.{u} n → Type (u+1)\n| mk (f) : definable (resp.eval _ f)\nattribute [instance] definable.mk\n\ndef definable.eq_mk {n} (f) : Π {s : arity Set.{u} n} (H : resp.eval _ f = s), definable n s\n| ._ rfl := ⟨f⟩\n\ndef definable.resp {n} : Π (s : arity Set.{u} n) [definable n s], resp n\n| ._ ⟨f⟩ := f\n\ntheorem definable.eq {n} : Π (s : arity Set.{u} n) [H : definable n s], (@definable.resp n s H).eval _ = s\n| ._ ⟨f⟩ := rfl\n\nend pSet\n\nnamespace classical\nopen pSet\n\nnoncomputable theorem all_definable : Π {n} (F : arity Set.{u} n), definable n F\n| 0     F := let p := @quotient.exists_rep pSet _ F in\n              definable.eq_mk ⟨some p, equiv.refl _⟩ (some_spec p)\n| (n+1) (F : arity Set.{u} (n + 1)) := begin\n    have I := λx, (all_definable (F x)),\n    refine definable.eq_mk ⟨λx:pSet, (@definable.resp _ _ (I ⟦x⟧)).1, _⟩ _,\n    { dsimp [arity.equiv],\n      introsI x y h,\n      rw @quotient.sound pSet _ _ _ h,\n      exact (definable.resp (F ⟦y⟧)).2 },\n    exact funext (λq, quotient.induction_on q $ λx,\n      by simp [resp.f]; exact @definable.eq _ (F ⟦x⟧) (I ⟦x⟧))\n  end\n\nend classical\n\nnamespace Set\nopen pSet\n\ndef mk : pSet → Set := quotient.mk\n\n@[simp] theorem mk_eq (x : pSet) : @eq Set ⟦x⟧ (mk x) := rfl\n\ndef mem : Set → Set → Prop :=\nquotient.lift₂ pSet.mem\n  (λx y x' y' hx hy, propext (iff.trans (mem.congr_left hx) (mem.congr_right hy)))\n\ninstance : has_mem Set Set := ⟨mem⟩\n\n/-- Convert a ZFC set into a `set` of sets -/\ndef to_set (u : Set.{u}) : set Set.{u} := {x | x ∈ u}\n\nprotected def subset (x y : Set.{u}) :=\n∀ ⦃z⦄, z ∈ x → z ∈ y\n\ninstance has_subset : has_subset Set :=\n⟨Set.subset⟩\n\ntheorem subset_iff : Π (x y : pSet), mk x ⊆ mk y ↔ x ⊆ y\n| ⟨α, A⟩ ⟨β, B⟩ := ⟨λh a, @h ⟦A a⟧ (mem.mk A a),\n  λh z, quotient.induction_on z (λz ⟨a, za⟩, let ⟨b, ab⟩ := h a in ⟨b, equiv.trans za ab⟩)⟩\n\ntheorem ext {x y : Set.{u}} : (∀z:Set.{u}, z ∈ x ↔ z ∈ y) → x = y :=\nquotient.induction_on₂ x y (λu v h, quotient.sound (mem.ext (λw, h ⟦w⟧)))\n\ntheorem ext_iff {x y : Set.{u}} : (∀z:Set.{u}, z ∈ x ↔ z ∈ y) ↔ x = y :=\n⟨ext, λh, by simp [h]⟩\n\n/-- The empty set -/\ndef empty : Set := mk ∅\ninstance : has_emptyc Set := ⟨empty⟩\ninstance : inhabited Set := ⟨∅⟩\n\n@[simp] theorem mem_empty (x) : x ∉ (∅:Set.{u}) :=\nquotient.induction_on x pSet.mem_empty\n\ntheorem eq_empty (x : Set.{u}) : x = ∅ ↔ ∀y:Set.{u}, y ∉ x :=\n⟨λh, by rw h; exact mem_empty,\nλh, ext (λy, ⟨λyx, absurd yx (h y), λy0, absurd y0 (mem_empty _)⟩)⟩\n\n/-- `insert x y` is the set `{x} ∪ y` -/\nprotected def insert : Set → Set → Set :=\nresp.eval 2 ⟨pSet.insert, λu v uv ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λo, match o with\n   | some a := let ⟨b, hb⟩ := αβ a in ⟨some b, hb⟩\n   | none := ⟨none, uv⟩\n   end, λo, match o with\n   | some b := let ⟨a, ha⟩ := βα b in ⟨some a, ha⟩\n   | none := ⟨none, uv⟩\n   end⟩⟩\n\ninstance : has_insert Set Set := ⟨Set.insert⟩\n\n@[simp] theorem mem_insert {x y z : Set.{u}} : x ∈ insert y z ↔ x = y ∨ x ∈ z :=\nquotient.induction_on₃ x y z\n (λx y ⟨α, A⟩, show x ∈ pSet.mk (option α) (λo, option.rec y A o) ↔\n    mk x = mk y ∨ x ∈ pSet.mk α A, from\n  ⟨λm, match m with\n  | ⟨some a, ha⟩ := or.inr ⟨a, ha⟩\n  | ⟨none, h⟩ := or.inl (quotient.sound h)\n  end, λm, match m with\n  | or.inr ⟨a, ha⟩ := ⟨some a, ha⟩\n  | or.inl h := ⟨none, quotient.exact h⟩\n  end⟩)\n\n@[simp] theorem mem_singleton {x y : Set.{u}} : x ∈ @singleton Set.{u} Set.{u} _ _ y ↔ x = y :=\niff.trans mem_insert ⟨λo, or.rec (λh, h) (λn, absurd n (mem_empty _)) o, or.inl⟩\n\n@[simp] theorem mem_singleton' {x y : Set.{u}} : x ∈ @insert Set.{u} Set.{u} _ y ∅ ↔ x = y := mem_singleton\n\n@[simp] theorem mem_pair {x y z : Set.{u}} : x ∈ ({y, z} : Set) ↔ x = y ∨ x = z :=\niff.trans mem_insert $ iff.trans or.comm $ let m := @mem_singleton x y in ⟨or.imp_left m.1, or.imp_left m.2⟩\n\n/-- `omega` is the first infinite von Neumann ordinal -/\ndef omega : Set := mk omega\n\n@[simp] theorem omega_zero : ∅ ∈ omega :=\nshow pSet.mem ∅ pSet.omega, from ⟨⟨0⟩, equiv.refl _⟩\n\n@[simp] theorem omega_succ {n} : n ∈ omega.{u} → insert n n ∈ omega.{u} :=\nquotient.induction_on n (λx ⟨⟨n⟩, h⟩, ⟨⟨n+1⟩,\n  have Set.insert ⟦x⟧ ⟦x⟧ = Set.insert ⟦of_nat n⟧ ⟦of_nat n⟧, by rw (@quotient.sound pSet _ _ _ h),\n  quotient.exact this⟩)\n\n/-- `{x ∈ a | p x}` is the set of elements in `a` satisfying `p` -/\nprotected def sep (p : Set → Prop) : Set → Set :=\nresp.eval 1 ⟨pSet.sep (λy, p ⟦y⟧), λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λ⟨a, pa⟩, let ⟨b, hb⟩ := αβ a in ⟨⟨b, by rwa ←(@quotient.sound pSet _ _ _ hb)⟩, hb⟩,\n   λ⟨b, pb⟩, let ⟨a, ha⟩ := βα b in ⟨⟨a, by rwa (@quotient.sound pSet _ _ _ ha)⟩, ha⟩⟩⟩\n\ninstance : has_sep Set Set := ⟨Set.sep⟩\n\n@[simp] theorem mem_sep {p : Set.{u} → Prop} {x y : Set.{u}} : y ∈ {y ∈ x | p y} ↔ y ∈ x ∧ p y :=\nquotient.induction_on₂ x y (λ⟨α, A⟩ y,\n  ⟨λ⟨⟨a, pa⟩, h⟩, ⟨⟨a, h⟩, by rw (@quotient.sound pSet _ _ _ h); exact pa⟩,\n  λ⟨⟨a, h⟩, pa⟩, ⟨⟨a, by rw ←(@quotient.sound pSet _ _ _ h); exact pa⟩, h⟩⟩)\n\n/-- The powerset operation, the collection of subsets of a set -/\ndef powerset : Set → Set :=\nresp.eval 1 ⟨powerset, λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨λp, ⟨{b | ∃a, p a ∧ equiv (A a) (B b)},\n    λ⟨a, pa⟩, let ⟨b, ab⟩ := αβ a in ⟨⟨b, a, pa, ab⟩, ab⟩,\n    λ⟨b, a, pa, ab⟩, ⟨⟨a, pa⟩, ab⟩⟩,\n   λq, ⟨{a | ∃b, q b ∧ equiv (A a) (B b)},\n    λ⟨a, b, qb, ab⟩, ⟨⟨b, qb⟩, ab⟩,\n    λ⟨b, qb⟩, let ⟨a, ab⟩ := βα b in ⟨⟨a, b, qb, ab⟩, ab⟩⟩⟩⟩\n\n@[simp] theorem mem_powerset {x y : Set} : y ∈ powerset x ↔ y ⊆ x :=\nquotient.induction_on₂ x y (λ⟨α, A⟩ ⟨β, B⟩,\n  show (⟨β, B⟩ : pSet) ∈ (pSet.powerset ⟨α, A⟩) ↔ _,\n    by simp [mem_powerset, subset_iff])\n\ntheorem Union_lem {α β : Type u} (A : α → pSet) (B : β → pSet)\n  (αβ : ∀a, ∃b, equiv (A a) (B b)) : ∀a, ∃b, (equiv ((Union ⟨α, A⟩).func a) ((Union ⟨β, B⟩).func b))\n| ⟨a, c⟩ := let ⟨b, hb⟩ := αβ a in\n  begin\n    induction ea : A a with γ Γ,\n    induction eb : B b with δ Δ,\n    rw [ea, eb] at hb,\n    cases hb with γδ δγ,\n    exact\n    let c : type (A a) := c, ⟨d, hd⟩ := γδ (by rwa ea at c) in\n    have equiv ((A a).func c) ((B b).func (eq.rec d (eq.symm eb))), from\n    match A a, B b, ea, eb, c, d, hd with ._, ._, rfl, rfl, x, y, hd := hd end,\n    ⟨⟨b, eq.rec d (eq.symm eb)⟩, this⟩\n  end\n\n/-- The union operator, the collection of elements of elements of a set -/\ndef Union : Set → Set :=\nresp.eval 1 ⟨pSet.Union, λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,\n  ⟨Union_lem A B αβ, λa, exists.elim (Union_lem B A (λb,\n    exists.elim (βα b) (λc hc, ⟨c, equiv.symm hc⟩)) a) (λb hb, ⟨b, equiv.symm hb⟩)⟩⟩\n\nnotation `⋃` := Union\n\n@[simp] theorem mem_Union {x y : Set.{u}} : y ∈ Union x ↔ ∃ z ∈ x, y ∈ z :=\nquotient.induction_on₂ x y (λx y, iff.trans mem_Union\n  ⟨λ⟨z, h⟩, ⟨⟦z⟧, h⟩, λ⟨z, h⟩, quotient.induction_on z (λz h, ⟨z, h⟩) h⟩)\n\n@[simp] theorem Union_singleton {x : Set.{u}} : Union {x} = x :=\next $ λy, by simp; exact ⟨λ⟨z, zx, yz⟩, by subst z; exact yz, λyx, ⟨x, by simp, yx⟩⟩\n\ntheorem singleton_inj {x y : Set.{u}} (H : ({x} : Set) = {y}) : x = y :=\nlet this := congr_arg Union H in by rwa [Union_singleton, Union_singleton] at this\n\n/-- The binary union operation -/\nprotected def union (x y : Set.{u}) : Set.{u} := ⋃ {x, y}\n\n/-- The binary intersection operation -/\nprotected def inter (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∈ y}\n\n/-- The set difference operation -/\nprotected def diff (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∉ y}\n\ninstance : has_union Set := ⟨Set.union⟩\ninstance : has_inter Set := ⟨Set.inter⟩\ninstance : has_sdiff Set := ⟨Set.diff⟩\n\n@[simp] theorem mem_union {x y z : Set.{u}} : z ∈ x ∪ y ↔ z ∈ x ∨ z ∈ y :=\niff.trans mem_Union\n ⟨λ⟨w, wxy, zw⟩, match mem_pair.1 wxy with\n  | or.inl wx := or.inl (by rwa ←wx)\n  | or.inr wy := or.inr (by rwa ←wy)\n  end, λzxy, match zxy with\n  | or.inl zx := ⟨x, mem_pair.2 (or.inl rfl), zx⟩\n  | or.inr zy := ⟨y, mem_pair.2 (or.inr rfl), zy⟩\n  end⟩\n\n@[simp] theorem mem_inter {x y z : Set.{u}} : z ∈ x ∩ y ↔ z ∈ x ∧ z ∈ y :=\n@@mem_sep (λz:Set.{u}, z ∈ y)\n\n@[simp] theorem mem_diff {x y z : Set.{u}} : z ∈ x \\ y ↔ z ∈ x ∧ z ∉ y :=\n@@mem_sep (λz:Set.{u}, z ∉ y)\n\ntheorem induction_on {p : Set → Prop} (x) (h : ∀x, (∀y ∈ x, p y) → p x) : p x :=\nquotient.induction_on x $ λu, pSet.rec_on u $ λα A IH, h _ $ λy,\nshow @has_mem.mem _ _ Set.has_mem y ⟦⟨α, A⟩⟧ → p y, from\nquotient.induction_on y (λv ⟨a, ha⟩, by rw (@quotient.sound pSet _ _ _ ha); exact IH a)\n\ntheorem regularity (x : Set.{u}) (h : x ≠ ∅) : ∃ y ∈ x, x ∩ y = ∅ :=\nclassical.by_contradiction $ λne, h $ (eq_empty x).2 $ λy,\ninduction_on y $ λz (IH : ∀w:Set.{u}, w ∈ z → w ∉ x), show z ∉ x, from λzx,\nne ⟨z, zx, (eq_empty _).2 (λw wxz, let ⟨wx, wz⟩ := mem_inter.1 wxz in IH w wz wx)⟩\n\n/-- The image of a (definable) set function -/\ndef image (f : Set → Set) [H : definable 1 f] : Set → Set :=\nlet r := @definable.resp 1 f _ in\nresp.eval 1 ⟨image r.1, λx y e, mem.ext $ λz,\n  iff.trans (mem_image r.2) $ iff.trans (by exact\n   ⟨λ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).1 h1, h2⟩,\n    λ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).2 h1, h2⟩⟩) $\n  iff.symm (mem_image r.2)⟩\n\ntheorem image.mk : Π (f : Set.{u} → Set.{u}) [H : definable 1 f] (x) {y} (h : y ∈ x), f y ∈ @image f H x\n| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ⟨α, A⟩ y ⟨a, ya⟩, ⟨a, F.2 _ _ ya⟩\n\n@[simp] theorem mem_image : Π {f : Set.{u} → Set.{u}} [H : definable 1 f] {x y : Set.{u}}, y ∈ @image f H x ↔ ∃z ∈ x, f z = y\n| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ⟨α, A⟩ y,\n  ⟨λ⟨a, ya⟩, ⟨⟦A a⟧, mem.mk A a, eq.symm $ quotient.sound ya⟩,\n  λ⟨z, hz, e⟩, e ▸ image.mk _ _ hz⟩\n\n/-- Kuratowski ordered pair -/\ndef pair (x y : Set.{u}) : Set.{u} := {{x}, {x, y}}\n\n/-- A subset of pairs `{(a, b) ∈ x × y | p a b}` -/\ndef pair_sep (p : Set.{u} → Set.{u} → Prop) (x y : Set.{u}) : Set.{u} :=\n{z ∈ powerset (powerset (x ∪ y)) | ∃a ∈ x, ∃b ∈ y, z = pair a b ∧ p a b}\n\n@[simp] theorem mem_pair_sep {p} {x y z : Set.{u}} : z ∈ pair_sep p x y ↔ ∃a ∈ x, ∃b ∈ y, z = pair a b ∧ p a b := by\nrefine iff.trans mem_sep ⟨and.right, λe, ⟨_, e⟩⟩; exact\nlet ⟨a, ax, b, bY, ze, pab⟩ := e in by rw ze; exact\nmem_powerset.2 (λu uz, mem_powerset.2 $ (mem_pair.1 uz).elim\n  (λua, by rw ua; exact λv vu, by rw mem_singleton.1 vu; exact mem_union.2 (or.inl ax))\n  (λuab, by rw uab; exact λv vu, (mem_pair.1 vu).elim\n    (λva, by rw va; exact mem_union.2 (or.inl ax))\n    (λvb, by rw vb; exact mem_union.2 (or.inr bY))))\n\ntheorem pair_inj {x y x' y' : Set.{u}} (H : pair x y = pair x' y') : x = x' ∧ y = y' := begin\n  have ae := ext_iff.2 H,\n  simp [pair] at ae,\n  have : x = x',\n  { cases (ae {x}).1 (by simp) with h h,\n    { exact singleton_inj h },\n    { have m : x' ∈ ({x} : Set),\n      { rw h, simp },\n      simp at m, simp [*] } },\n  subst x',\n  have he : y = x → y = y',\n  { intro yx, subst y,\n    cases (ae {x, y'}).2 (by simp) with xy'x xy'xx,\n    { have y'x : y' ∈ ({x} : Set) := by rw ← xy'x; simp,\n      simp at y'x, simp [*] },\n    { have yxx := (ext_iff.2 xy'xx y').1 (by simp),\n      simp at yxx, subst y' } },\n  have xyxy' := (ae {x, y}).1 (by simp),\n  cases xyxy' with xyx xyy',\n  { have yx := (ext_iff.2 xyx y).1 (by simp),\n    simp at yx, simp [he yx] },\n  { have yxy' := (ext_iff.2 xyy' y).1 (by simp),\n    simp at yxy',\n    cases yxy' with yx yy',\n    { simp [he yx] },\n    { simp [yy'] } }\nend\n\n/-- The cartesian product, `{(a, b) | a ∈ x, b ∈ y}` -/\ndef prod : Set.{u} → Set.{u} → Set.{u} := pair_sep (λa b, true)\n\n@[simp] theorem mem_prod {x y z : Set.{u}} : z ∈ prod x y ↔ ∃a ∈ x, ∃b ∈ y, z = pair a b :=\nby simp [prod]\n\n@[simp] theorem pair_mem_prod {x y a b : Set.{u}} : pair a b ∈ prod x y ↔ a ∈ x ∧ b ∈ y :=\n⟨λh, let ⟨a', a'x, b', b'y, e⟩ := mem_prod.1 h in\n  match a', b', pair_inj e, a'x, b'y with ._, ._, ⟨rfl, rfl⟩, ax, bY := ⟨ax, bY⟩ end,\nλ⟨ax, bY⟩, by simp; exact ⟨a, ax, b, bY, rfl⟩⟩\n\n/-- `is_func x y f` is the assertion `f : x → y` where `f` is a ZFC function\n  (a set of ordered pairs) -/\ndef is_func (x y f : Set.{u}) : Prop :=\nf ⊆ prod x y ∧ ∀z:Set.{u}, z ∈ x → ∃! w, pair z w ∈ f\n\n/-- `funs x y` is `y ^ x`, the set of all set functions `x → y` -/\ndef funs (x y : Set.{u}) : Set.{u} :=\n{f ∈ powerset (prod x y) | is_func x y f}\n\n@[simp] theorem mem_funs {x y f : Set.{u}} : f ∈ funs x y ↔ is_func x y f :=\nby simp [funs]; exact and_iff_right_of_imp and.left\n\n-- TODO(Mario): Prove this computably\nnoncomputable instance map_definable_aux (f : Set → Set) [H : definable 1 f] : definable 1 (λy, pair y (f y)) :=\n@classical.all_definable 1 _\n\n/-- Graph of a function: `map f x` is the ZFC function which maps `a ∈ x` to `f a` -/\nnoncomputable def map (f : Set → Set) [H : definable 1 f] : Set → Set :=\nimage (λy, pair y (f y))\n\n@[simp] theorem mem_map {f : Set → Set} [H : definable 1 f] {x y : Set} : y ∈ map f x ↔ ∃z ∈ x, pair z (f z) = y :=\nmem_image\n\ntheorem map_unique {f : Set.{u} → Set.{u}} [H : definable 1 f] {x z : Set.{u}} (zx : z ∈ x) : ∃! w, pair z w ∈ map f x :=\n⟨f z, image.mk _ _ zx, λy yx, let ⟨w, wx, we⟩ := mem_image.1 yx, ⟨wz, fy⟩ := pair_inj we in by rw[←fy, wz]⟩\n\n@[simp] theorem map_is_func {f : Set → Set} [H : definable 1 f] {x y : Set} : is_func x y (map f x) ↔ ∀z ∈ x, f z ∈ y :=\n⟨λ⟨ss, h⟩ z zx, let ⟨t, t1, t2⟩ := h z zx in by rw (t2 (f z) (image.mk _ _ zx)); exact (pair_mem_prod.1 (ss t1)).right,\nλh, ⟨λy yx, let ⟨z, zx, ze⟩ := mem_image.1 yx in by rw ←ze; exact pair_mem_prod.2 ⟨zx, h z zx⟩,\n     λz, map_unique⟩⟩\n\nend Set\n\ndef Class := set Set\n\nnamespace Class\n\ninstance : has_subset Class     := ⟨set.subset⟩\ninstance : has_sep Set Class    := ⟨set.sep⟩\ninstance : has_emptyc Class     := ⟨λ a, false⟩\ninstance : has_insert Set Class := ⟨set.insert⟩\ninstance : has_union Class      := ⟨set.union⟩\ninstance : has_inter Class      := ⟨set.inter⟩\ninstance : has_neg Class        := ⟨set.compl⟩\ninstance : has_sdiff Class      := ⟨set.diff⟩\n\n/-- Coerce a set into a class -/\ndef of_Set (x : Set.{u}) : Class.{u} := {y | y ∈ x}\ninstance : has_coe Set Class := ⟨of_Set⟩\n\n/-- The universal class -/\ndef univ : Class := set.univ\n\n/-- Assert that `A` is a set satisfying `p` -/\ndef to_Set (p : Set.{u} → Prop) (A : Class.{u}) : Prop := ∃x, ↑x = A ∧ p x\n\n/-- `A ∈ B` if `A` is a set which is a member of `B` -/\nprotected def mem (A B : Class.{u}) : Prop := to_Set.{u} B A\ninstance : has_mem Class Class := ⟨Class.mem⟩\n\ntheorem mem_univ {A : Class.{u}} : A ∈ univ.{u} ↔ ∃ x : Set.{u}, ↑x = A :=\nexists_congr $ λx, and_true _\n\n/-- Convert a conglomerate (a collection of classes) into a class -/\ndef Cong_to_Class (x : set Class.{u}) : Class.{u} := {y | ↑y ∈ x}\n\n/-- Convert a class into a conglomerate (a collection of classes) -/\ndef Class_to_Cong (x : Class.{u}) : set Class.{u} := {y | y ∈ x}\n\n/-- The power class of a class is the class of all subclasses that are sets -/\ndef powerset (x : Class) : Class := Cong_to_Class (set.powerset x)\n\n/-- The union of a class is the class of all members of sets in the class -/\ndef Union (x : Class) : Class := set.sUnion (Class_to_Cong x)\nnotation `⋃` := Union\n\ntheorem of_Set.inj {x y : Set.{u}} (h : (x : Class.{u}) = y) : x = y :=\nSet.ext $ λz, by change (x : Class.{u}) z ↔ (y : Class.{u}) z; simp [*]\n\n@[simp] theorem to_Set_of_Set (p : Set.{u} → Prop) (x : Set.{u}) : to_Set p x ↔ p x :=\n⟨λ⟨y, yx, py⟩, by rwa of_Set.inj yx at py, λpx, ⟨x, rfl, px⟩⟩\n\n@[simp] theorem mem_hom_left (x : Set.{u}) (A : Class.{u}) : (x : Class.{u}) ∈ A ↔ A x :=\nto_Set_of_Set _ _\n\n@[simp] theorem mem_hom_right (x y : Set.{u}) : (y : Class.{u}) x ↔ x ∈ y := iff.refl _\n\n@[simp] theorem subset_hom (x y : Set.{u}) : (x : Class.{u}) ⊆ y ↔ x ⊆ y := iff.refl _\n\n@[simp] theorem sep_hom (p : Set.{u} → Prop) (x : Set.{u}) : (↑{y ∈ x | p y} : Class.{u}) = {y ∈ x | p y} :=\nset.ext $ λy, Set.mem_sep\n\n@[simp] theorem empty_hom : ↑(∅ : Set.{u}) = (∅ : Class.{u}) :=\nset.ext $ λy, show _ ↔ false, by simp; exact Set.mem_empty y\n\n@[simp] theorem insert_hom (x y : Set.{u}) : (@insert Set.{u} Class.{u} _ x y) = ↑(insert x y) :=\nset.ext $ λz, iff.symm Set.mem_insert\n\n@[simp] theorem union_hom (x y : Set.{u}) : (x : Class.{u}) ∪ y = (x ∪ y : Set.{u}) :=\nset.ext $ λz, iff.symm Set.mem_union\n\n@[simp] theorem inter_hom (x y : Set.{u}) : (x : Class.{u}) ∩ y = (x ∩ y : Set.{u}) :=\nset.ext $ λz, iff.symm Set.mem_inter\n\n@[simp] theorem diff_hom (x y : Set.{u}) : (x : Class.{u}) \\ y = (x \\ y : Set.{u}) :=\nset.ext $ λz, iff.symm Set.mem_diff\n\n@[simp] theorem powerset_hom (x : Set.{u}) : powerset.{u} x = Set.powerset x :=\nset.ext $ λz, iff.symm Set.mem_powerset\n\n@[simp] theorem Union_hom (x : Set.{u}) : Union.{u} x = Set.Union x :=\nset.ext $ λz, by refine iff.trans _ (iff.symm Set.mem_Union); exact\n⟨λ⟨._, ⟨a, rfl, ax⟩, za⟩, ⟨a, ax, za⟩, λ⟨a, ax, za⟩, ⟨_, ⟨a, rfl, ax⟩, za⟩⟩\n\n/-- The definite description operator, which is {x} if `{a | p a} = {x}`\n  and ∅ otherwise -/\ndef iota (p : Set → Prop) : Class := Union {x | ∀y, p y ↔ y = x}\n\ntheorem iota_val (p : Set → Prop) (x : Set) (H : ∀y, p y ↔ y = x) : iota p = ↑x :=\nset.ext $ λy, ⟨λ⟨._, ⟨x', rfl, h⟩, yx'⟩, by rwa ←((H x').1 $ (h x').2 rfl), λyx, ⟨_, ⟨x, rfl, H⟩, yx⟩⟩\n\n/-- Unlike the other set constructors, the `iota` definite descriptor\n  is a set for any set input, but not constructively so, so there is no\n  associated `(Set → Prop) → Set` function. -/\ntheorem iota_ex (p) : iota.{u} p ∈ univ.{u} :=\nmem_univ.2 $ or.elim (classical.em $ ∃x, ∀y, p y ↔ y = x)\n (λ⟨x, h⟩, ⟨x, eq.symm $ iota_val p x h⟩)\n (λhn, ⟨∅, by simp; exact set.ext (λz, ⟨false.rec _, λ⟨._, ⟨x, rfl, H⟩, zA⟩, hn ⟨x, H⟩⟩)⟩)\n\n/-- Function value -/\ndef fval (F A : Class.{u}) : Class.{u} := iota (λy, to_Set (λx, F (Set.pair x y)) A)\ninfixl `′`:100 := fval\n\ntheorem fval_ex (F A : Class.{u}) : F ′ A ∈ univ.{u} := iota_ex _\n\nend Class\n\nnamespace Set\n\n@[simp] theorem map_fval {f : Set.{u} → Set.{u}} [H : pSet.definable 1 f] {x y : Set.{u}} (h : y ∈ x) :\n  (Set.map f x ′ y : Class.{u}) = f y :=\nClass.iota_val _ _ (λz, by simp; exact\n  ⟨λ⟨w, wz, pr⟩, let ⟨wy, fw⟩ := Set.pair_inj pr in by rw[←fw, wy],\n  λe, by cases e; exact ⟨_, h, rfl⟩⟩)\n\nvariables (x : Set.{u}) (h : ∅ ∉ x)\n\n/-- A choice function on the set of nonempty sets `x` -/\nnoncomputable def choice : Set := @map (λy, classical.epsilon (λz, z ∈ y)) (classical.all_definable _) x\n\ninclude h\ntheorem choice_mem_aux (y : Set.{u}) (yx : y ∈ x) : classical.epsilon (λz:Set.{u}, z ∈ y) ∈ y :=\n@classical.epsilon_spec _ (λz:Set.{u}, z ∈ y) $ classical.by_contradiction $ λn, h $\nby rwa ←((eq_empty y).2 $ λz zx, n ⟨z, zx⟩)\n\ntheorem choice_is_func : is_func x (Union x) (choice x) :=\n(@map_is_func _ (classical.all_definable _) _ _).2 $ λy yx, by simp; exact ⟨y, yx, choice_mem_aux x h y yx⟩\n\ntheorem choice_mem (y : Set.{u}) (yx : y ∈ x) : (choice x ′ y : Class.{u}) ∈ (y : Class.{u}) :=\nby delta choice; rw map_fval yx; simp [choice_mem_aux x h y yx]\n\nend Set\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/set_theory/zfc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.4771434505132897}}
{"text": "/-\nCopyright (c) 2019 The Flypitch Project. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n\nAuthors: Jesse Han, Floris van Doorn\n-/\nimport .to_mathlib .pSet_ordinal data.pfun\n-- local attribute [instance] classical.prop_decidable\n\n/- The Cohen poset of finite partial functions (2^(2^ω)) × ω → 2 -/\n\n/- The underlying type of the Cohen poset is the type of finite partial functions from (set $ set ω) × ω → Prop -/\nvariable {η : cardinal}\n\ndef cohen_poset := {f : ((pSet.ordinal.mk η.ord).type × ℕ) →. Prop | set.finite (pfun.dom f)}\n\n-- TODO replace all instances of set $ set ℕ with a generic \"B\"\nnoncomputable instance B_decidable_eq : decidable_eq (set $ set ℕ) := λ _ _, classical.prop_decidable _\n\nnamespace pfun\n/- Two partial functions are equal if their graphs are equal -/\nlemma ext_graph {α β : Type*} (f g : α →. β) (h_graph : f.graph = g.graph) : f = g :=\n  pfun.ext $ λ _ _, iff_of_eq (congr_fun h_graph (_,_))\n\nlemma graph_empty_iff_dom_empty {α β : Type*} (f : α →. β) : f.graph = ∅ ↔ f.dom = ∅ :=\nbegin\n  have := dom_iff_graph f,\n  split; intro; ext; safe, apply this, tidy\nend\n\n/- A functional graph is a univalent graph -/\ndef functional {α β : Type*} (Γ : set (α × β)) : Prop :=\n  ∀ a b₁ b₂, (a, b₁) ∈ Γ → (a, b₂) ∈ Γ → b₁ = b₂\n\nlemma congr_arg {α β : Type*} (f : α →. β) : ∀ {x} {y} (h₁ : x ∈ f.dom) (h₂ : y ∈ f.dom)\n  (h_eq : x = y), fn f x h₁ = fn f y h₂ :=\nby intros; congr; assumption\n\nlemma functional_subset {α β : Type*} (Γ Γ': set (α × β)) (h_Γ' : Γ' ⊆ Γ) (h_Γ : functional Γ) : functional Γ' :=\n  λ _ _ _ _ _, by apply h_Γ; tidy\n\n/-- The graph of a pfun is always functional -/\nlemma graph_functional {α β : Type*} (f : α →. β) : functional f.graph := by tidy\n\n/-- Given a partial functional relation, turn it into a pfun -/\nnoncomputable def of_graph {α β : Type*} (Γ : set (α × β)) (h_Γ : functional Γ) : α →. β :=\n  λ a, ⟨∃ c ∈ Γ, (prod.fst c) = a, λ h, @prod.snd α β $ (classical.indefinite_description _ h).val⟩\n\nlemma of_graph_property {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) (a : α) (h : ∃ c ∈ Γ, (prod.fst c) = a) : ∃ (H : Γ (classical.indefinite_description _ h)), (classical.indefinite_description _ h).val.fst = a :=\n  by apply (classical.indefinite_description _ h).property\n\nlemma of_graph_get {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) (a : α) : ∀ h,\n(of_graph Γ h_Γ a).get h = (classical.indefinite_description _ h).val.snd :=\n  by intro; refl\n\nlemma of_graph_val {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) (a : α) (h : ∃ c ∈ Γ, (prod.fst c) = a) (c' ∈ Γ) (h' : c'.1 = a) :\n  @prod.snd α β (classical.indefinite_description _ h).val = c'.snd :=\nbegin\n  let c'', swap, change (prod.snd c'' = c'.snd),\n  apply h_Γ a, swap, convert H, ext, rwa[h'], refl,\n  have := (classical.indefinite_description _ h).property,\n  cases this with this1 this2, rw[<-this2], convert this1, ext; refl\nend\n\n@[simp]lemma graph_of_graph {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) : (of_graph Γ h_Γ).graph = Γ :=\nbegin\n  ext, rcases x with ⟨a,b⟩, dsimp[graph],\n  split; intro H, {cases H, induction H_h, cases H_w, cases H_w_h, induction H_w_h_h,\n  convert H_w_h_w, ext, refl, rw[of_graph_get], apply of_graph_val; try{assumption}; refl},\n  fsplit, {tidy}, rw[of_graph_get], apply @of_graph_val _ _ Γ _ a _ (a,b) _;\n  try{assumption}; refl\nend\n\n@[simp]lemma of_graph_graph {α β : Type*} {f : α →. β} : of_graph (f.graph) (graph_functional f) = f :=\n  by apply ext_graph; rw[graph_of_graph]\n\n@[simp]lemma dom_of_graph {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) : (of_graph Γ h_Γ).dom = (prod.fst '' Γ) :=\nbegin\n ext, split; intros, {tidy},\n {cases a, cases a_h, cases a_w, induction a_h_right, dsimp at *, fsplit,\n work_on_goal 0 { fsplit }, work_on_goal 2 {fsplit,\n work_on_goal 0 { assumption }, refl }}\nend\n\n@[simp]lemma dom_of_graph_union {α β : Type*} (Γ : set $ α × β) (p : α × β) (h_Γ : functional Γ) (h_Γ' : functional $ Γ ∪ {p}) : (of_graph (Γ ∪ {p}) h_Γ').dom = (of_graph Γ h_Γ).dom ∪ {p.fst} :=\n  by simp[dom_of_graph, set.image_insert_eq]\n\nlemma in_dom_of_in_graph {α β : Type*} {f : α →. β} : ∀ {a} {b}, (a,b) ∈ f.graph → a ∈ f.dom :=\n  by {intros a b H, apply (pfun.dom_iff_graph _ a).mpr, exact ⟨b,H⟩}\n\nlemma lift_graph' {α β : Type*} {f : α →. β} {a : α} {b : β} (h_a : a ∈ f.dom) : (a,b) ∈ f.graph ↔ pfun.fn f a h_a = b := by tidy\n\nend pfun\n\n/- Partial order structure on the Cohen poset -/\ninstance partial_order_cohen_poset : partial_order (@cohen_poset η) :=\n{ le := λ f g, g.val.graph ⊆ f.val.graph,\n  lt := λ f g, g.val.graph ⊆ f.val.graph ∧ ¬ f.val.graph ⊆ g.val.graph,\n  le_refl := λ _, by unfold has_le.le,\n  le_trans := by {intros, apply set.subset.trans, exact a_2, assumption},\n  lt_iff_le_not_le := λ _ _, iff.refl _,\n  le_antisymm := λ a b h1 h2, by {have := @set.subset.antisymm _ _ _ h2 h1, cases a, cases b,\n                                       congr, apply pfun.ext_graph, exact this}}\n\ndef incompatible {α : Type*} [partial_order α] (a b : α) := ¬ ∃ c, c ≤ a ∧ c ≤ b\n\ndef antichain {α : Type*} [partial_order α] (s : set α) := ∀ x ∈ s, ∀ y ∈ s, (x ≠ y) → incompatible x y\n\nlemma antichain_subset {α : Type*} [partial_order α] {s s' : set α} {h : s' ⊆ s} {hs : antichain s} : antichain s' :=\nby {intros _ _ _ _, intro H, apply hs _ _ _ _, tidy}\n\ndef countable_chain_condition (α : Type*) [partial_order α] := ∀ s : set α, antichain s → set.countable s\n\n@[simp]lemma univ_singletons {α : Type*} :  set.Union (λ a, {a}) = (set.univ : set α) :=\nby tidy\n\nlemma set_is_union_of_fibers {α β : Type*} (f : α → β) (s : set α) : s = set.Union (λ b, f ⁻¹'{b} ∩ s) := by ext; simp\n\nlemma univ_is_union_of_fibers {α β : Type*} (f : α → β) : @set.univ α = set.Union (λ b, f⁻¹' {b}) :=\n  begin [smt] eblast_using [set.preimage_Union, @set.preimage_univ α β f, univ_singletons] end\n\nlemma countable_of_injection_to_countable {α β : Type*} {s : set α} {s' : set β} (f : s → s') {hf : function.injective f} (h' : set.countable s') : set.countable s :=\nbegin\n  have := set.countable_iff_exists_injective.mp h', apply set.countable_iff_exists_injective.mpr,\n  cases this, refine ⟨this_w ∘ f,_⟩, exact function.injective_comp (this_h) hf\nend\n\nlemma countable_of_bijection_with_countable {α β : Type*} {s : set α} {s' : set β} {f : s → s'}\n{hf : function.bijective f} {h' : set.countable s'} : set.countable s :=\nbegin\n  apply countable_of_injection_to_countable f, exact h', exact hf.left\nend\n\nlemma countable_of_equiv_with_countable {α β : Type*} {s : set α} {s' : set β}\n{h : equiv s s'} {h' : set.countable s'} : set.countable s :=\nby {apply countable_of_bijection_with_countable, apply h.bijective, exact h'}\n\nlemma equiv_set_set_univ {α : Type*} (s : set α) : equiv s (@set.univ s) :=\nby {refine ⟨λ x, ⟨x, (by trivial)⟩, λ x, x.val, _, _⟩, tidy}\n\n/- an (s : set α) is countable if (set.univ : set s) is countable -/\nlemma countable_of_countable_univ {α : Type*} (s : set α) : set.countable s ↔ set.countable (set.univ : set s) :=\nbegin\n  split; apply countable_of_equiv_with_countable, symmetry,\n  all_goals{apply equiv_set_set_univ}\nend\n\nlemma countable_of_countable_underlying_set {α : Type*} {s' : set α} {s : set α} {t : set s'} (h : s = (subtype.val '' t)) {h_ctbl : set.countable s} : set.countable t :=\nbegin\n  let f : t → s := λ x,\n    begin refine ⟨x.val, _⟩, rw[h], cases x, cases x_val, simp at *, fsplit; assumption end,\n  refine countable_of_injection_to_countable f (by assumption),\n    intros a₁ a₂ a, cases a₂, cases a₁, cases a₁_val, cases a₂_val, simp at *, assumption\nend\n\nlemma countable_of_countable_fibers {α β : Type*} (s : set α) (f : s → β) [encodable β] (H : ∀ b : β, set.countable (f ⁻¹' {b})) : set.countable s :=\nby simp[countable_of_countable_univ, univ_is_union_of_fibers f, set.countable_Union H]\n\nlemma countable_of_countable_fibers' {α β : Type*} (s : set α) (f : α → β) [encodable β] (H : ∀ b : β, set.countable ((f ⁻¹' {b}) ∩ s)) : set.countable s :=\nby {rw[set_is_union_of_fibers f s], exact set.countable_Union H}\n\nlemma countable_of_countable_fibers'' {α β : Type*} (s : set α) (f : s → β) [encodable β] (H : ∀ b : β, set.countable ((f ⁻¹' {b}))) : set.countable s :=\nby simp[countable_of_countable_univ, univ_is_union_of_fibers f, set.countable_Union H]\n\nlemma eq_true_of_provable {p : Prop} (h : p) : (p = true) := by simp[h]\n\nlemma eq_false_of_provable_neg {p : Prop} (h : ¬ p) : (p = false) := by finish\n\n@[reducible, simp]noncomputable def Prop_to_bool (p : Prop) : bool :=\nby {haveI := classical.prop_decidable p, by_cases p, exact true, exact false}\n\n@[simp]lemma Prop_to_bool_true : Prop_to_bool true = tt := by simp\n\n@[simp]lemma Prop_to_bool_false : Prop_to_bool false = ff := by simp\n\nnoncomputable lemma equiv_Prop_bool : equiv Prop bool :=\nbegin\n  refine ⟨Prop_to_bool,by {intro b, cases b, exact false, exact true},_,_⟩,\n  {unfold function.left_inverse, intro p, haveI := classical.prop_decidable p, by_cases p,\n  rw[eq_true_of_provable h, Prop_to_bool_true],\n  rw[eq_false_of_provable_neg h, Prop_to_bool_false],},\n  {intro x, cases x; finish}\nend\n\nnoncomputable instance Prop_encodable : encodable Prop :=\n @encodable.of_equiv _ _ (by apply_instance) equiv_Prop_bool\n\nnoncomputable def size_of_domain : (@cohen_poset η) → ℕ :=\n  λ p, finset.card $ set.finite.to_finset p.property\n\nlemma size_of_domain_fiber {n} {p : @cohen_poset η} (h : p ∈ @size_of_domain η ⁻¹' {n}) : size_of_domain p = n := by finish\n\n/-- The partial function p is defined at b and m if (b,m) is in the domain of p -/\ndef is_defined (p : (@cohen_poset η)) (b) (m) := (b,m) ∈ (pfun.dom p.val)\n\n/-- p is defined at m if there exists a b such that p is defined at b and m -/\ndef is_defined_at (m : ℕ) : set (@cohen_poset η) :=\n  {p : (@cohen_poset η) | ∃ b, is_defined p b m}\n\nnamespace finset\n\nlemma empty_of_empty {α : Type*} {s : set α} {h : set.finite s} : set.finite.to_finset h = ∅ → s = ∅ :=\nbegin\n  intro H, rw[set.eq_empty_iff_forall_not_mem], intros x Hx,\n  suffices : x ∈ set.finite.to_finset h, by rw[H] at this; cases this, simpa[finset.mem_coe]\nend\n\nend finset\n\nlemma empty_of_size_of_domain_0 {p : (@cohen_poset η)} (h : size_of_domain p = 0) : p.val.dom = ∅ :=\nbegin\n  have : set.finite.to_finset p.property = ∅, from finset.card_eq_zero.mp h,\n  exact finset.empty_of_empty this\nend\n\nlemma nonempty_of_size_of_domain_ne_zero {p : (@cohen_poset η)} (h : size_of_domain p ≠ 0) : nonempty p.val.dom :=\nbegin\n  have : set.finite.to_finset p.property ≠ ∅, by {intro h, suffices : (set.finite.to_finset p.property).card = 0,\n    by {apply (_root_.not_and_self ((set.finite.to_finset p.property).card = 0)).mp,refine ⟨(by assumption), this⟩},\n    exact finset.card_eq_zero.mpr h},\n  have := finset.exists_mem_of_ne_empty this, cases this, apply nonempty.intro,\n  refine ⟨this_w,_⟩, cases this_w, cases p, simp at this_h, assumption\nend\n\nlemma nonempty_domain_defined (p : (@cohen_poset η)) (h : 0 < size_of_domain p) : ∃ m,\n  is_defined_at m p :=\nbegin\n  suffices : nonempty p.val.dom, by {have := classical.choice this, cases this,\n  refine ⟨this_val.2, ⟨this_val.1,_⟩⟩, tidy}, apply nonempty_of_size_of_domain_ne_zero,\n  intro h', rw[h'] at h, cases h\nend\n\n-- def is_defined_at_covers {n} {h : 0 < n} : @size_of_domain η ⁻¹' {n} ⊆ ⋃ m, is_defined_at m :=\n-- begin\n--   intros p Hp, simp[set.mem_preimage_eq] at *,\n--   suffices : nonempty p.val.dom,\n--     by {have := classical.choice this, exact ⟨this.val.snd, ⟨this.val.fst, (by tidy)⟩⟩},\n--   apply nonempty_of_size_of_domain_ne_zero, intro H, have : 0 < 0, by cc, cases this\n-- end\n\ninstance size_of_domain_0_subsingleton : subsingleton $ @size_of_domain η ⁻¹' {0} :=\nbegin\n  refine ⟨λ a b, _⟩, rcases a with ⟨⟨p_a, H_f_a⟩, H_a⟩, rcases b with ⟨⟨p_b, H_f_b⟩, H_b⟩, congr,\n  have := (pfun.graph_empty_iff_dom_empty _).mpr (@empty_of_size_of_domain_0 η _\n                                          (by {simp[set.mem_preimage_eq] at H_b, exact H_b})),\n  have := (pfun.graph_empty_iff_dom_empty _).mpr (@empty_of_size_of_domain_0 η _\n                                          (by {simp[set.mem_preimage_eq] at H_a, exact H_a})),\n  exact pfun.ext_graph _ _ (by cc)\nend\n\nlemma subsingleton_of_subset_of_subsingleton {α : Type*} {s s' : set α} (h_sub : s ⊆ s') [subsingleton s'] : subsingleton s :=\nbegin\n  refine ⟨λ a b, _⟩, have : ∀ a b : s', a = b, by apply subsingleton.elim,\n  let f : s → s' := λ x, ⟨x.val, h_sub _⟩,\n  suffices : f a = f b, by tidy, apply this, exact x.property\nend\n\nlemma size_of_domain_0_inter_subsingleton : ∀ (a : set (@cohen_poset η)), subsingleton ↥((size_of_domain ⁻¹' {0}) ∩ a) :=\nλ a, subsingleton_of_subset_of_subsingleton\n     (by apply set.inter_subset_left : size_of_domain ⁻¹' {0} ∩ a ⊆ size_of_domain ⁻¹' {0})\n\nlemma countable_subsingleton {α : Type*} (s : set α) (h : subsingleton s) : set.countable s :=\n  set.countable_iff_exists_injective.mpr $ ⟨λ _, 0, λ _ _, dec_trivial⟩\n\n-- lemma cover_Union_eq {α ι : Type*} {s : set α} {t : ι → set α} {h : s ⊆ (⋃ (i : ι), t i)} :\n-- s = ⋃ i, s ∩ t i :=\n--   by {rw[<-set.inter_Union_left], ext, split; intros, exact ⟨a, h a⟩, exact a.left}\n\nlemma inter_subset_left' {α : Type*} {s t u : set α} {h : t ⊆ u} : s ∩ t ⊆ u :=\n  λ _ ⟨_,_⟩, by solve_by_elim\n\nlemma inter_subset_right' {α : Type*} {s t u : set α} {h : t ⊆ u} : t ∩ s ⊆ u :=\n  λ _ ⟨_,_⟩, by solve_by_elim\n\nsection one_point_restriction\n\n/- Given x : α, return the set λ a, a ≠ x -/\n@[simp, reducible]def not_x {α : Type*} (x : α) : set α := λ a, a ≠ x\n\ndef finite_of_inter_not_x {α : Type*} {s : set α} (h : set.finite s) {x : α} : set.finite $ s ∩ not_x x := by {apply set.finite_subset, exact h, apply inter_subset_right', trivial}\n\ndef roption_indicator {α : Type*} (s : set α) : α → roption α :=\n  λ x, ⟨x ∈ s, λ _, x⟩\n\ndef pfun.restriction {α β : Type*} (f : α →. β) (s : set α) : α →. β\n:= λ x, do y <- roption_indicator s x, f y\n\nlemma pfun.domain_restriction {α β : Type*} {f : α →. β} {s : set α} : (pfun.restriction f s).dom = f.dom ∩ s :=\n  by ext; split; intro a; cases a; fsplit; assumption\n\nend one_point_restriction\n-- def one_point_restriction (p : (@cohen_poset η)) : ∀(x), x ∈ p.val.dom → (@cohen_poset η) :=\n-- λ x H, ⟨pfun.restriction p.val (not_x x),\n--          by {change set.finite (pfun.restriction p.val (not_x x)).dom,\n--          rw[pfun.domain_restriction], apply finite_of_inter_not_x, apply p.property}⟩\n\n-- def one_point_restriction' (p : (@cohen_poset η)) : ∀ (x), (@cohen_poset η) :=\n-- λ x, ⟨pfun.restriction p.val (not_x x),\n--          by {change set.finite (pfun.restriction p.val (not_x x)).dom,\n--          rw[pfun.domain_restriction], apply finite_of_inter_not_x, apply p.property}⟩\n\n-- lemma one_point_restriction_domain {p : (@cohen_poset η)} {x} (h : x ∈ p.val.dom) : (one_point_restriction p x h).val.dom = p.val.dom ∩ not_x x :=\n-- begin\n--   ext, split; {intros a, auto_cases, fsplit; assumption}\n-- end\n\n-- lemma one_point_restriction_domain' {p : (@cohen_poset η)} {x} : (one_point_restriction' p x).val.dom = p.val.dom ∩ not_x x :=\n-- begin\n--   ext, split; {intros a, auto_cases, fsplit; assumption}\n-- end\n\n-- lemma one_point_restriction_graph {p : (@cohen_poset η)} {x} {h_x : x ∈ p.val.dom} : ∀ y, y ∈ (one_point_restriction p x h_x).val.graph ↔ (y ∈ p.val.graph ∧ (prod.fst y ≠ x)) := sorry\n\n-- -- lemma one_point_restriction_graph' {p : (@cohen_poset η)} {x} : (one_point_restriction' p x).val.graph = {y ∈ p.val.graph | y.fst ∈ not_x x} :=\n-- -- begin\n-- --   ext, split; intros,\n-- -- end\n\n-- @[simp]lemma in_one_point_restriction_of_in_dom_and_not_x {p : (@cohen_poset η)} {x} {h : x ∈ p.val.dom} {y} : y ∈ (one_point_restriction p x h).val.dom ↔ (y ∈ p.val.dom) ∧ y ≠ x :=\n--   by simp[one_point_restriction_domain, not_x]; finish\n\n-- @[simp]lemma in_one_point_restriction'_of_in_dom_and_not_x {p : (@cohen_poset η)} {x} {y} : y ∈ (one_point_restriction' p x ).val.dom ↔ (y ∈ p.val.dom) ∧ y ≠ x :=\n--   by simp[one_point_restriction_domain', not_x]; finish\n\n-- lemma one_point_restriction_domain'_subset {p : (@cohen_poset η)} {x} : (one_point_restriction' p x).val.dom ⊆ p.val.dom :=\n--   λ y, by finish\n\n-- lemma one_point_restriction_domain_subset {p : (@cohen_poset η)} {x} {h_x : x ∈ p.val.dom} : (one_point_restriction p x h_x).val.dom ⊆ p.val.dom :=\n--   λ y, by finish\n\n\n-- lemma one_point_restriction_domain_coe {p : (@cohen_poset η)} {x} {h : x ∈ p.val.dom} : p.val.dom = ↑(set.finite.to_finset p.property) := by simp\n\n-- lemma one_point_restriction_finset_rewrite {p : (@cohen_poset η)} {x} {h : x ∈ p.val.dom} : set.finite.to_finset (one_point_restriction p x h).property = set.finite.to_finset (by {apply finite_of_inter_not_x, exact p.property} : set.finite $ p.val.dom ∩ not_x x) := by simp[one_point_restriction_domain]\n\n-- lemma one_point_restriction_finset_rewrite_property {p : (@cohen_poset η)} {x} {h : x ∈ p.val.dom} : ∀ y, y ∈ set.finite.to_finset ((one_point_restriction p x h).property-- by {apply finite_of_inter_not_x, exact p.property} : set.finite $ p.val.dom ∩ not_x x\n-- ) ↔ y ≠ x ∧ y ∈ p.val.dom :=\n-- begin\n--   intro y, split; intros, rw[one_point_restriction_finset_rewrite] at a, split,\n--     {tidy, apply a_right, refl},\n--     {finish},\n--     {apply finset.mem_coe.mp, rw[<-one_point_restriction_domain_coe],\n--     rw[one_point_restriction_domain], refine ⟨a.right,_⟩, apply a.left, swap, exact y, simp*}\n-- end\n\n-- lemma one_point_restriction_erase {p : (@cohen_poset η)} {x} {h : x ∈ p.val.dom} : set.finite.to_finset (one_point_restriction p x h).property = finset.erase (set.finite.to_finset p.property) x :=\n-- begin\n--   ext, rw[one_point_restriction_finset_rewrite,finset.mem_erase], conv {to_rhs,rw[<-finset.mem_coe]}, split; intros, {rw[<-one_point_restriction_domain_coe], apply (one_point_restriction_finset_rewrite_property a).mp, show set (set ℕ) × ℕ, exact x, rw[one_point_restriction_finset_rewrite], repeat{assumption}},\n--   {rw[<-one_point_restriction_finset_rewrite],\n--   apply (one_point_restriction_finset_rewrite_property a).mpr,\n--   convert a_1, simp, assumption}\n-- end\n\n-- lemma one_point_restriction_decrease_size {n} (p : (@cohen_poset η)) (h : size_of_domain p = n + 1) (x) (h_x : x ∈ p.val.dom)  :\n-- size_of_domain (one_point_restriction p x h_x) = n :=\n-- begin\n--   unfold size_of_domain at *, have : n = nat.pred (n+1), by refl,\n--   rw[this, one_point_restriction_erase, <-h], apply finset.card_erase_of_mem,\n--   apply finset.mem_coe.mp, rwa[finset.coe_to_finset]\n-- end\n\n-- def aux_c'' {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} (h_t₁ : t₁ ∈ p₁.val.dom) (h_t₂ : t₂ ∈ p₂.val.dom) (q : Prop) (h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q) (h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q) (c : (@cohen_poset η)) : (@cohen_poset η) :=\n--   (one_point_restriction' (one_point_restriction' c t₁) t₂)\n\n-- lemma aux_c''_dom {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} {h_t₁ : t₁ ∈ p₁.val.dom} {h_t₂ : t₂ ∈ p₂.val.dom} {q : Prop} {h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q} {h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q} {c : (@cohen_poset η)} : ∀ (x), x ∈ (aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val.dom → x ≠ t₁ ∧ x ≠ t₂ :=\n-- λ x Hx, ⟨by {apply ((in_one_point_restriction'_of_in_dom_and_not_x).mp _).right, exact c,\n--             apply one_point_restriction_domain'_subset, swap, exact t₂, exact Hx},\n--          by {apply ((in_one_point_restriction'_of_in_dom_and_not_x).mp _).right, exact (one_point_restriction' c t₁), exact Hx}⟩\n\n-- lemma aux_c''_dom_of {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} {h_t₁ : t₁ ∈ p₁.val.dom} {h_t₂ : t₂ ∈ p₂.val.dom} {q : Prop} {h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q} {h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q} {c : (@cohen_poset η)} : ∀ (x), x ≠ t₁ ∧ x ≠ t₂ → x ∈ c.val.dom → x ∈ (aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val.dom :=\n-- begin\n--   intros x Hx H'x, rcases Hx with ⟨Hx_r, Hx_l⟩, dsimp[aux_c''],\n--   repeat{rw[one_point_restriction_domain']}, finish\n-- end\n\n-- lemma aux_c''_graph_of {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} {h_t₁ : t₁ ∈ p₁.val.dom} {h_t₂ : t₂ ∈ p₂.val.dom} {q : Prop} {h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q} {h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q} {c : (@cohen_poset η)} : ∀ x, (x ∈ c.val.graph ∧ (prod.fst x ≠ t₁ ) ∧ (prod.fst x ≠ t₂)) ↔ x ∈ (aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val.graph := sorry\n\n-- lemma aux_c''_dom_finite {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} {h_t₁ : t₁ ∈ p₁.val.dom} {h_t₂ : t₂ ∈ p₂.val.dom} {q : Prop} {h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q} {h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q} {c : (@cohen_poset η)} : set.finite (aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val.dom :=\n-- begin\n--   dsimp[aux_c''], repeat{rw[one_point_restriction_domain']}, repeat{apply finite_of_inter_not_x},\n--   exact c.property\n-- end\n-- -- λ x Hx, ⟨by {apply ((in_one_point_restriction'_of_in_dom_and_not_x).mp _).right, exact c,\n-- --             apply one_point_restriction_domain'_subset, swap, exact t₂, exact Hx},\n-- --          by {apply ((in_one_point_restriction'_of_in_dom_and_not_x).mp _).right, exact (one_point_restriction' c t₁), exact Hx}⟩\n\n-- /- Let p₁ and p₂ be two partial functions such that there is a point (b₁,m) for p₁ and a point (b₂, m) for p₂ where p₁ and p₂ have the same value.\n--     Suppose that the one-point restrictions of p₁ and p₂ with respect to (b₁,m) and (b₂,m) have a common refinement c.\n--     Then c (after making sure (b₁, m) and (b₂,m) are not in its domain) extended by (b₁,m) and (b₂,m) is a common refinement for p₁ and p₂. -/\n\n-- /-- the graph of the extension of c by (b₁,m) and (b₂,m) -/\n-- def one_point_restriction_refinement_extension_graph {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} (h_t₁ : t₁ ∈ p₁.val.dom) (h_t₂ : t₂ ∈ p₂.val.dom) (q : Prop) (h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q) (h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q) (c : (@cohen_poset η)) :=\n--   ((aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val.graph ∪ {(t₁,q)} ∪ {(t₂,q)})\n\n-- lemma one_point_restriction_refinement_extension_graph_functional {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} (h_t₁ : t₁ ∈ p₁.val.dom) (h_t₂ : t₂ ∈ p₂.val.dom) (q : Prop) (h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q) (h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q) (c : (@cohen_poset η)) (h_c_left : c ≤ (one_point_restriction p₁ t₁ h_t₁)) (h_c_right : c ≤ (one_point_restriction p₂ t₂ h_t₂)) :\n--   pfun.functional $ one_point_restriction_refinement_extension_graph h_t₁ h_t₂ q h_val₁ h_val₂ c :=\n-- begin\n--   intros x q₁ q₂ H₁ H₂, let c' := (aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c), cases H₁; cases H₂; cases H₁; cases H₂,\n--   apply pfun.graph_functional (aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val, exact H₁, exact H₂,\n--   {have : x ∈ c'.val.dom,\n--     by {apply (pfun.dom_iff_graph c'.val x).mpr, exact ⟨q₁, H₁⟩}, have := (aux_c''_dom x this).left, suffices : x = t₁, by contradiction, repeat{cases H₂}, refl},\n--   {repeat{cases H₁}, suffices : t₁ ≠ t₁, by contradiction, have : t₁ ∈ c'.val.dom,\n--    by {apply (pfun.dom_iff_graph c'.val t₁).mpr, exact ⟨q₂, H₂⟩},\n--    exact (aux_c''_dom t₁ this).left},\n--   {cases H₁; cases H₁; cases H₂; cases H₂, cc},\n--   {repeat{cases H₂}, suffices : t₂ ≠ t₂, by contradiction, have : t₂ ∈ c'.val.dom,\n--    by {apply (pfun.dom_iff_graph c'.val t₂).mpr, exact ⟨q₁, H₁⟩},\n--    exact (aux_c''_dom t₂ this).right},\n--   {cases H₂},\n--   {repeat{cases H₁}, cases H₂, refl},\n--   {cases H₂},\n--   {repeat{cases H₁}, suffices : t₂ ≠ t₂, by contradiction, have : t₂ ∈ c'.val.dom,\n--    by {apply (pfun.dom_iff_graph c'.val t₂).mpr, refine ⟨_,_⟩, exact q₂, exact H₂},\n--    exact (aux_c''_dom t₂ this).right}, {repeat{cases H₂}, cases H₁, refl},\n--   {cases H₁}, {cases H₁}, {cc}, {cases H₂}, {cases H₁}, {cases H₁},\n-- end\n\n-- /-- the graph of the extension of c by (b₁,m) and (b₂,m) contains the graphs of p₁ and p₂ -/\n-- lemma one_point_restriction_refinement_extension_graph_extends {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} (h_t₁ : t₁ ∈ p₁.val.dom) (h_t₂ : t₂ ∈ p₂.val.dom) (q : Prop) (h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q) (h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q) (c : (@cohen_poset η)) (h_c_left : c ≤ (one_point_restriction p₁ t₁ h_t₁)) (h_c_right : c ≤ (one_point_restriction p₂ t₂ h_t₂)) : p₁.val.graph ⊆ (one_point_restriction_refinement_extension_graph h_t₁ h_t₂ q h_val₁ h_val₂ c) ∧ p₂.val.graph ⊆ (one_point_restriction_refinement_extension_graph h_t₁ h_t₂ q h_val₁ h_val₂ c) :=\n-- begin\n--   split; intros x Hx; rcases x with ⟨x, q'⟩;\n--   dsimp[one_point_restriction_refinement_extension_graph],\n--   suffices : ((x, q') ∈ pfun.graph ((aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val)) ∨ ((x, q') ∈ {(t₁, q)} ∨\n--     (x, q') ∈ {(t₂, q)}), by rwa[or_assoc],\n--   let H, swap, change _ ∨ H, haveI : decidable H := by apply classical.prop_decidable _,\n--   by_cases H,\n--     {apply or.elim h, exact λ A, or.inr $ or.inl $ A,\n--                       exact λ A, or.inr $ or.inr $ A},\n--     {-- dsimp[H] at h, rw[not_or_distrib] at h, apply or.inl,\n--     repeat{sorry}\n\n--     -- apply (aux_c''_graph_of (x,q')).mp,\n--      -- refine ⟨_, _⟩,\n\n-- -- dsimp[H] at h, rw[not_or_distrib] at h,\n-- --      have Hx' : (x,q') ∈ (c.val).graph,\n-- --        by {apply h_c_left, apply (one_point_restriction_graph (x,q')).mpr,\n-- --        refine ⟨(by assumption), _⟩, change x ≠ t₁, cases h, intro hx, apply h_left, rw[hx], simp,\n-- --               apply (pfun.graph_functional p₁.val), exact Hx,\n-- --               rw[hx], apply (pfun.lift_graph' _).mpr, exact h_val₁},\n-- --      apply or.inl, have : x ∈ p₁.val.dom, by apply (pfun.dom_iff_graph _ x).mpr; exact ⟨q', Hx⟩,\n-- --      have : x ∈ ((aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val).dom,\n-- --        by {apply aux_c''_dom_of, {split, {change x ≠ t₁, cases h, intro hx,\n-- --           apply h_left, rw[hx], simp, apply (pfun.graph_functional p₁.val), exact Hx,\n-- --           rw[hx], apply (pfun.lift_graph' _).mpr, exact h_val₁}, {change x ≠ t₂, cases h, intro hx, apply h_right, rw[hx], simp, apply (pfun.graph_functional p₂.val), repeat{sorry} -- exact Hx, rw[hx], apply (pfun.lift_graph' _).mpr, exact h_val₂\n-- --               }}, {apply (pfun.dom_iff_graph _ x).mpr, exact ⟨q', Hx'⟩}},\n\n--     },\n--   -- by_cases H, repeat{sorry}\n--   -- have : ((x, q') ∈ {(t₁, q)} ∨ (x, q') ∈ {(t₂, q)}) → (x,q') ∉ pfun.graph ((aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val),\n--   -- by {intros H₁ H₂, have : x ∈ (aux_c'' h_t₁ h_t₂ q h_val₁ h_val₂ c).val.dom,\n--   --    by {apply (pfun.dom_iff_graph _ x).mpr, exact ⟨q', H₂⟩}, have := aux_c''_dom x this,\n--   --    cases H₁, have : (x,q') = (t₁, q), from set.eq_of_mem_singleton (by assumption), finish,\n--   --    have : (x,q') = (t₂, q), from set.eq_of_mem_singleton (by assumption), finish},\n--   repeat{sorry}\n\n-- end\n\n-- /-- the extension of c by (b₁, m) and (b₂,m) has finite domain -/\n-- lemma one_point_restriction_refinement_extension_finite {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} (h_t₁ : t₁ ∈ p₁.val.dom) (h_t₂ : t₂ ∈ p₂.val.dom) (q : Prop) (h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q) (h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q) (c : (@cohen_poset η)) (h_c_left : c ≤ (one_point_restriction p₁ t₁ h_t₁)) (h_c_right : c ≤ (one_point_restriction p₂ t₂ h_t₂)) : set.finite (pfun.of_graph (one_point_restriction_refinement_extension_graph h_t₁ h_t₂ q h_val₁ h_val₂ c) (by {apply one_point_restriction_refinement_extension_graph_functional, repeat{assumption}})).dom :=\n-- begin\n--   unfold one_point_restriction_refinement_extension_graph,\n--   rw[pfun.dom_of_graph_union], swap,\n--   apply pfun.functional_subset (one_point_restriction_refinement_extension_graph h_t₁ h_t₂ q h_val₁ h_val₂ c),\n--     by {unfold one_point_restriction_refinement_extension_graph, finish},\n--   apply one_point_restriction_refinement_extension_graph_functional, repeat{assumption},\n--   rw[pfun.dom_of_graph_union, pfun.of_graph_graph], simp only [set.union_singleton], repeat{apply set.finite_insert}, apply aux_c''_dom_finite\n-- end\n\n-- noncomputable def one_point_restriction_refinement_extension {p₁ p₂ : (@cohen_poset η)} {t₁ t₂ : (set $ set ℕ) × ℕ} (h_t₁ : t₁ ∈ p₁.val.dom) (h_t₂ : t₂ ∈ p₂.val.dom) (q : Prop) (h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q) (h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q) (c : (@cohen_poset η)) (h_c_left : c ≤ (one_point_restriction p₁ t₁ h_t₁)) (h_c_right : c ≤ (one_point_restriction p₂ t₂ h_t₂)) : (@cohen_poset η) :=\n--   ⟨pfun.of_graph (one_point_restriction_refinement_extension_graph h_t₁ h_t₂ q h_val₁ h_val₂ c) (by {apply one_point_restriction_refinement_extension_graph_functional, repeat{assumption}}),\n--    (by {apply one_point_restriction_refinement_extension_finite, repeat{assumption}})⟩\n\n-- lemma one_point_restriction_refinement_extension_spec (p₁ p₂ : (@cohen_poset η)) {t₁ t₂ : (set $ set ℕ) × ℕ} {h_t₁ : t₁ ∈ p₁.val.dom} {h_t₂ : t₂ ∈ p₂.val.dom} {q : Prop} {h_val₁ : pfun.fn p₁.val t₁ h_t₁ = q} {h_val₂ : pfun.fn p₂.val t₂ h_t₂ = q} {c : (@cohen_poset η)} (h_c_left : c ≤ (one_point_restriction p₁ t₁ h_t₁)) (h_c_right : c ≤ (one_point_restriction p₂ t₂ h_t₂)) : ∃ c' : (@cohen_poset η), c' ≤ p₁ ∧ c' ≤ p₂ :=\n-- begin\n--   refine ⟨by {fapply one_point_restriction_refinement_extension h_t₁ h_t₂ q h_val₁ h_val₂ c,\n--              repeat{assumption}}, _⟩,\n--   have := one_point_restriction_refinement_extension_graph_extends h_t₁ h_t₂ q h_val₁ h_val₂ c h_c_left h_c_right,\n--   convert this; convert rfl; simp[one_point_restriction_refinement_extension, one_point_restriction_refinement_extension_graph, pfun.graph_of_graph]\n-- end\n\n-- lemma wit_incompatible {p₁ p₂ : (@cohen_poset η)} (h_incompat : incompatible p₁ p₂) : ∃ w ∈ p₁.val.dom ∩ p₂.val.dom, pfun.fn (p₁.val) w (by exact H.left) ≠ pfun.fn (p₂.val) w H.right :=\n-- begin\n--   sorry\n--   -- let p, swap, change p, haveI : decidable p := by apply classical.prop_decidable _,\n--   -- by_contra, dsimp[p] at a, clear _inst p,\n--   -- simp at a, sorry\n-- end\n\n-- lemma wit_incompatible' {p₁ p₂ : (@cohen_poset η)} (h_incompat : incompatible p₁ p₂) : ∃ w q₁ q₂, (w,q₁) ∈ p₁.val.graph ∧ (w,q₂) ∈ p₂.val.graph ∧ q₁ ≠ q₂ := sorry\n\n-- end one_point_restriction\n\n-- lemma congr_neq {α β : Type*} {f : α → β} {x' y' : α} {x y : β} {h_x : f x' = x} {h_y : f y' = y} {h_neq : x ≠ y} : x' ≠ y' := λ _, by {cc}\n\n-- lemma coe_subtype_injective {α : Type*} {s : set α} {x y : s} : (↑x = (↑y : α)) → x = y :=\n--   λ h, by {cases x, cases y, dsimp at h, subst h}\n\n-- -- /- The Cohen poset has the countable chain condition -/\n-- -- lemma (@cohen_poset η)_ccc : countable_chain_condition (@cohen_poset η) :=\n-- -- begin\n-- --   intros a Ha, apply countable_of_countable_fibers' a size_of_domain,\n-- --   intro n, induction n with n ih generalizing a,\n-- --     {apply countable_subsingleton, apply size_of_domain_0_inter_subsingleton},\n-- --     {let A_n, swap, change set.countable A_n,\n-- --       have : A_n ⊆ ⋃ m, is_defined_at m, by {dsimp[A_n], apply inter_subset_right',\n-- --              apply is_defined_at_covers, apply nat.zero_lt_succ},\n-- --      rw[@cover_Union_eq _ _ A_n is_defined_at this], apply set.countable_Union,\n-- --      intro m, let A_n_m, swap, change set.countable A_n_m,\n-- --        have choice_aux : ∀ p : A_n_m, ∃ b : (set $ set ℕ), (b,m) ∈ (pfun.dom p.val.val),\n-- --          by {intros p, cases p, cases p_property, cases p_val, assumption},\n-- --        have := classical.axiom_of_choice choice_aux, cases this with wit wit_spec,\n-- --        let eval : A_n_m → Prop :=\n-- --              λ (p : ↥A_n_m), pfun.fn ((p.val).val) (wit p, m) (by apply wit_spec),\n-- --        apply countable_of_countable_fibers'' _ eval, intro q,\n-- --        let A_n_m_q, swap, change set.countable A_n_m_q,\n\n-- --          let red : A_n_m → (@cohen_poset η) :=\n-- --            λ X, one_point_restriction X.val (wit X, m) (by apply wit_spec),\n\n-- --          have h_anti : antichain (red '' A_n_m_q) :=\n-- --            by {intros x H_x y H_y H_neq H_compat, rcases H_compat with ⟨c, ⟨H_cx,H_cy⟩⟩,\n-- --                rcases H_x with ⟨x', H_x'⟩, rcases H_y with ⟨y', H_y'⟩,\n-- --                have h_neq : x' ≠ y',\n-- --                  by {apply congr_neq, exact H_x'.right, exact H_y'.right, exact H_neq},\n-- --                have : ↑x' ≠ ↑y', by {intro, apply h_neq, exact coe_subtype_injective a_1},\n-- --                have h_incompat := Ha x' (x'.property.left.right) y' (y'.property.left.right) this,\n-- --                have := wit_incompatible' h_incompat, rcases this with ⟨w,q₁,q₂, ⟨H₁,⟨H₂,H₃⟩⟩⟩,\n-- --                have w_not_t₁ : w ≠ (wit (x'), m),\n-- --                  by {intro H_eq, have := pfun.congr_arg (subtype.val (↑x'))\n-- --                                          (pfun.in_dom_of_in_graph (by assumption))\n-- --                                          (pfun.in_dom_of_in_graph (sorry)) H_eq, repeat{sorry}\n-- --                      },\n-- --                have w_not_t₂ : w.fst ≠ wit (y'), by sorry,\n-- --                have w_in_red_1 : (w,q₁) ∈ (x).val.graph, by sorry,\n-- --                have w_in_red_2 : (w,q₂) ∈ (y).val.graph, by sorry,\n-- --                have w_in_c_1 : (w,q₁) ∈ c.val.graph, from H_cx w_in_red_1,\n-- --                have w_in_c_2 : (w,q₂) ∈ c.val.graph, from H_cy w_in_red_2,\n-- --                suffices : q₁ = q₂, by contradiction,\n-- --                apply pfun.graph_functional c.val, exacts [w_in_c_1, w_in_c_2]\n-- --                },\n\n-- --          have ih_rewrite : size_of_domain ⁻¹' {n} ∩ red '' A_n_m_q = red '' A_n_m_q,\n-- --            by {apply set.inter_eq_self_of_subset_right, intros x H_x,\n-- --               simp only [set.mem_singleton_iff, set.mem_preimage_eq],\n-- --               dsimp[red] at H_x, cases H_x, rw[<-H_x_h.right],\n-- --               apply one_point_restriction_decrease_size,\n-- --               apply size_of_domain_fiber H_x_w.property.left.left},\n\n-- --          have h_inj : set.inj_on red A_n_m_q,\n-- --            by {intros x' y' H_x' H_y',\n-- --               haveI : decidable_eq ↥A_n_m := λ _ _, classical.prop_decidable _,\n-- --               by_cases x' = y', exact λ _, ‹x' = y'›, rename h h_neq,\n-- --               intro H, exfalso,\n-- --                refine Ha x' (x'.property.left.right) y' (y'.property.left.right)\n-- --                            (by {intro, apply h_neq, exact coe_subtype_injective a_1}) _,\n-- --               apply one_point_restriction_refinement_extension_spec (↑x') (↑y'),\n-- --               have : red x' ≤ red x', by {apply le_of_eq rfl},\n-- --               convert this, convert (le_of_eq H), exact q,\n-- --                cases H_x', convert H_x', cases H_x',\n-- --                cases H_y', convert H_y', cases H_y'},\n\n-- --          have ih' := ih (red '' A_n_m_q) h_anti,\n\n-- --          exact set.countable_of_injective_of_countable_image h_inj (by rwa[<-ih_rewrite])}\n-- end\n", "meta": {"author": "flypitch", "repo": "flypitch", "sha": "aea5800db1f4cce53fc4a113711454b27388ecf8", "save_path": "github-repos/lean/flypitch-flypitch", "path": "github-repos/lean/flypitch-flypitch/flypitch-aea5800db1f4cce53fc4a113711454b27388ecf8/old/cohen_poset.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4771434459512163}}
{"text": "import .syntax\n\nopen val bin_op exp instruction\n\ndef eval (n m : ℕ) : bin_op → val\n| PlusOp  := VNat (n + m)\n| MinusOp := VNat (n - m)\n| TimesOp := VNat (n * m)\n| ModOp   := VNat (n % m)\n| GeOp    := VBool (n ≥ m)\n| GtOp    := VBool (n > m)\n| LeOp    := VBool (n ≤ m)\n| LtOp    := VBool (n < m)\n| EqOp    := VBool (n = m)\n\ndef subst (v : val) (x : string) : exp → exp\n| (EVar y) := if x = y then (EVal v) else (EVar y)\n| (ELet y e body) :=\n      if x = y then ELet y (subst e) body\n      else ELet y (subst e) (subst body)\n| (EIf c t e) := EIf (subst c) (subst t) (subst e)\n| (EOp op e₁ e₂) := EOp op (subst e₁) (subst e₂)\n| (EVal v) := (EVal v)\n\ndef remove (name : string) : list (string × val) → list (string × val)\n| [] := []\n| ((x, v) :: nv') := if x = name then remove nv' else (x, v) :: remove nv'\n\ndef big_subst : list (string × val) → exp → exp\n| [] expr := expr\n| ((x, v) :: nv') e := big_subst nv' (subst v x e)\n\ninductive big_step : exp → val → Prop\n| RunVal {v} : big_step (EVal v) v\n| RunOp {op eₙ eₘ n m}\n    (_ : big_step eₙ (VNat n))\n    (_ : big_step eₘ (VNat m))\n  : big_step (EOp op eₙ eₘ) (eval n m op)\n| RunIfT {c t f : exp} {v : val}\n    (_ : big_step c (VBool tt))\n    (_ : big_step t v)\n  : big_step (EIf c t f) v\n| RunIfF {c t f : exp} {v : val}\n    (_ : big_step c (VBool ff))\n    (_ : big_step f v)\n  : big_step (EIf c t f) v\n| RunLet {e body : exp} {x : string} {v r : val}\n  (_ : big_step e v)\n  (_ : big_step (subst v x body) r)\n  : big_step (ELet x e body) r\n\ninfixr ` ⟹ ` : 30 := big_step\n\ndef at_least {α : Type} (n : ℕ) : list α → Prop\n| (l : list α) := l.length ≥ n\n\nlemma at_least_refl {α : Type} {l : list α} : at_least l.length l :=\nby rw [at_least]; exact nat.le_refl (l.length)\n\ninductive bound : string → val → list (string × val) → Prop\n| bhead {x v env}     : bound x v ((x, v) :: env)\n| btail {x y v u env} : x ≠ y → bound x v env → bound x v (⟨y, u⟩ :: env)\n\ninductive vm_big_step : \n  list (string × val) × list instruction × list val → list val → Prop\n| RunEmpty {env stack} : vm_big_step (env, [], stack) stack\n| RunPush {env instrs stack res v}\n    (_ : vm_big_step (env, instrs, v :: stack) res)\n  : vm_big_step (env, IPush v :: instrs, stack) res\n| RunOpInstr {env instrs stack res op} {n m : ℕ} \n    (_ : vm_big_step (env, instrs, eval n m op :: stack) res)\n  : vm_big_step (env, IOp op :: instrs, VNat n :: VNat m :: stack) res\n| RunTBranch {env instrs stack res n}\n    (_ : vm_big_step (env, instrs, stack) res)\n  : vm_big_step (env, IBranch n :: instrs, VBool tt :: stack) res\n| RunFBranch {env instrs stack res n}\n    (_ : at_least n instrs)\n    (_ : vm_big_step (env, instrs.drop n, stack) res)\n  : vm_big_step (env, IBranch n :: instrs, VBool ff :: stack) res\n| RunJump {env instrs stack res n}\n    (_ : at_least n instrs)\n    (_ : vm_big_step (env, instrs.drop n, stack) res)\n  : vm_big_step (env, IJump n :: instrs, stack) res\n| RunLookup {env x v instrs stack res}\n  (_ : bound x v env)\n  (_ : vm_big_step (env, instrs, v :: stack) res)\n : vm_big_step (env, ILookup x :: instrs, stack) res\n| RunOpenScope {env x v instrs stack res}\n  (_ : vm_big_step (⟨x, v⟩ :: env, instrs, stack) res)\n  : vm_big_step (env, IOpenScope x :: instrs, v :: stack) res\n| RunCloseScope {env x v instrs stack res}\n  (_ : vm_big_step (env, instrs, stack) res)\n  : vm_big_step (⟨x, v⟩ :: env, ICloseScope :: instrs, stack) res\n\ninfix ` ⟹ᵥₘ ` : 50 := vm_big_step\n\n-- big-step semantics including resulting environment\ninductive env_big_step :\n    list (string × val) × list instruction × list val \n  → list (string × val) × list val → Prop\n| ERunEmpty {env stack} : env_big_step (env, [], stack) (env, stack) \n| ERunPush {env instrs stack res v}\n    (_ : env_big_step (env, instrs, v :: stack) res)\n  : env_big_step (env, IPush v :: instrs, stack) res\n| ERunOpInstr {env instrs stack res op} {n m : ℕ} \n    (_ : env_big_step (env, instrs, eval n m op :: stack) res)\n  : env_big_step (env, IOp op :: instrs, VNat n :: VNat m :: stack) res\n| ERunTBranch {env instrs stack res n}\n    (_ : env_big_step (env, instrs, stack) res)\n  : env_big_step (env, IBranch n :: instrs, VBool tt :: stack) res\n| ERunFBranch {env instrs stack res n}\n    (_ : at_least n instrs)\n    (_ : env_big_step (env, instrs.drop n, stack) res)\n  : env_big_step (env, IBranch n :: instrs, VBool ff :: stack) res\n| ERunJump {env instrs stack res n}\n    (_ : at_least n instrs)\n    (_ : env_big_step (env, instrs.drop n, stack) res)\n  : env_big_step (env, IJump n :: instrs, stack) res\n| ERunLookup {env x v instrs stack res}\n  (_ : bound x v env)\n  (_ : env_big_step (env, instrs, v :: stack) res)\n : env_big_step (env, ILookup x :: instrs, stack) res\n| ERunOpenScope {env x v instrs stack res}\n  (_ : env_big_step (⟨x, v⟩ :: env, instrs, stack) res)\n  : env_big_step (env, IOpenScope x :: instrs, v :: stack) res\n| ERunCloseScope {env x v instrs stack res}\n  (_ : env_big_step (env, instrs, stack) res)\n  : env_big_step (⟨x, v⟩ :: env, ICloseScope :: instrs, stack) res\n\ninfix ` ⟹ₙᵥ ` : 50 := env_big_step", "meta": {"author": "sourceCode4", "repo": "VeriCompiler", "sha": "851ae7b178ffd801fafe9d6e0392f22555f89081", "save_path": "github-repos/lean/sourceCode4-VeriCompiler", "path": "github-repos/lean/sourceCode4-VeriCompiler/VeriCompiler-851ae7b178ffd801fafe9d6e0392f22555f89081/lean/semantics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324803738429, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.47699346521069846}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monoidal.braided\nimport Mathlib.category_theory.functor_category\nimport Mathlib.category_theory.const\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ \n\nnamespace Mathlib\n\n/-!\n# Monoidal structure on `C ⥤ D` when `D` is monoidal.\n\nWhen `C` is any category, and `D` is a monoidal category,\nthere is a natural \"pointwise\" monoidal structure on `C ⥤ D`.\n\nThe initial intended application is tensor product of presheaves.\n-/\n\nnamespace category_theory.monoidal\n\n\nnamespace functor_category\n\n\n/--\n(An auxiliary definition for `functor_category_monoidal`.)\nTensor product of functors `C ⥤ D`, when `D` is monoidal.\n -/\ndef tensor_obj {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D]\n    (F : C ⥤ D) (G : C ⥤ D) : C ⥤ D :=\n  functor.mk (fun (X : C) => functor.obj F X ⊗ functor.obj G X)\n    fun (X Y : C) (f : X ⟶ Y) => functor.map F f ⊗ functor.map G f\n\n/--\n(An auxiliary definition for `functor_category_monoidal`.)\nTensor product of natural transformations into `D`, when `D` is monoidal.\n-/\ndef tensor_hom {C : Type u₁} [category C] {D : Type u₂} [category D] [monoidal_category D]\n    {F : C ⥤ D} {G : C ⥤ D} {F' : C ⥤ D} {G' : C ⥤ D} (α : F ⟶ G) (β : F' ⟶ G') :\n    tensor_obj F F' ⟶ tensor_obj G G' :=\n  nat_trans.mk fun (X : C) => nat_trans.app α X ⊗ nat_trans.app β X\n\nend functor_category\n\n\n/--\nWhen `C` is any category, and `D` is a monoidal category,\nthe functor category `C ⥤ D` has a natural pointwise monoidal structure,\nwhere `(F ⊗ G).obj X = F.obj X ⊗ G.obj X`.\n-/\nprotected instance functor_category_monoidal {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] : monoidal_category (C ⥤ D) :=\n  monoidal_category.mk (fun (F G : C ⥤ D) => functor_category.tensor_obj F G)\n    (fun (F G F' G' : C ⥤ D) (α : F ⟶ G) (β : F' ⟶ G') => functor_category.tensor_hom α β)\n    (functor.obj (functor.const C) 𝟙_)\n    (fun (F G H : C ⥤ D) => nat_iso.of_components (fun (X : C) => α_) sorry)\n    (fun (F : C ⥤ D) => nat_iso.of_components (fun (X : C) => λ_) sorry)\n    fun (F : C ⥤ D) => nat_iso.of_components (fun (X : C) => ρ_) sorry\n\n@[simp] theorem tensor_unit_obj {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {X : C} : functor.obj 𝟙_ X = 𝟙_ :=\n  rfl\n\n@[simp] theorem tensor_unit_map {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {X : C} {Y : C} {f : X ⟶ Y} : functor.map 𝟙_ f = 𝟙 :=\n  rfl\n\n@[simp] theorem tensor_obj_obj {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {X : C} :\n    functor.obj (F ⊗ G) X = functor.obj F X ⊗ functor.obj G X :=\n  rfl\n\n@[simp] theorem tensor_obj_map {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {X : C} {Y : C} {f : X ⟶ Y} :\n    functor.map (F ⊗ G) f = functor.map F f ⊗ functor.map G f :=\n  rfl\n\n@[simp] theorem tensor_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {F' : C ⥤ D} {G' : C ⥤ D} {α : F ⟶ G}\n    {β : F' ⟶ G'} {X : C} : nat_trans.app (α ⊗ β) X = nat_trans.app α X ⊗ nat_trans.app β X :=\n  rfl\n\n@[simp] theorem left_unitor_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.hom λ_) X = iso.hom λ_ :=\n  rfl\n\n@[simp] theorem left_unitor_inv_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.inv λ_) X = iso.inv λ_ :=\n  rfl\n\n@[simp] theorem right_unitor_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.hom ρ_) X = iso.hom ρ_ :=\n  rfl\n\n@[simp] theorem right_unitor_inv_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {X : C} : nat_trans.app (iso.inv ρ_) X = iso.inv ρ_ :=\n  rfl\n\n@[simp] theorem associator_hom_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {H : C ⥤ D} {X : C} :\n    nat_trans.app (iso.hom α_) X = iso.hom α_ :=\n  rfl\n\n@[simp] theorem associator_inv_app {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] {F : C ⥤ D} {G : C ⥤ D} {H : C ⥤ D} {X : C} :\n    nat_trans.app (iso.inv α_) X = iso.inv α_ :=\n  rfl\n\n/--\nWhen `C` is any category, and `D` is a braided monoidal category,\nthe natural pointwise monoidal structure on the functor category `C ⥤ D`\nis also braided.\n-/\nprotected instance functor_category_braided {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] [braided_category D] : braided_category (C ⥤ D) :=\n  braided_category.mk fun (F G : C ⥤ D) => nat_iso.of_components (fun (X : C) => β_) sorry\n\n/--\nWhen `C` is any category, and `D` is a symmetric monoidal category,\nthe natural pointwise monoidal structure on the functor category `C ⥤ D`\nis also symmetric.\n-/\nprotected instance functor_category_symmetric {C : Type u₁} [category C] {D : Type u₂} [category D]\n    [monoidal_category D] [symmetric_category D] : symmetric_category (C ⥤ D) :=\n  symmetric_category.mk\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/functor_category_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4769866219351028}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nWithout loss of generality tactic.\n-/\nimport tactic.basic tactic.interactive data.list.perm\n\nopen expr tactic lean lean.parser\n\nlocal postfix `?`:9001 := optional\nlocal postfix *:9001 := many\n\nnamespace tactic\n\nprivate meta def update_pp_name : expr → name → expr\n| (local_const n _ bi d) pp := local_const n pp bi d\n| e n := e\n\nprivate meta def elim_or : ℕ → expr → tactic (list expr)\n| 0       h := fail \"zero cases\"\n| 1       h := return [h]\n| (n + 1) h := do\n  [(_, [hl], []), (_, [hr], [])] ← induction h, -- there should be no dependent terms\n  [gl, gr] ← get_goals,\n  set_goals [gr],\n  hsr ← elim_or n hr,\n  gsr ← get_goals,\n  set_goals (gl :: gsr),\n  return (hl :: hsr)\n\nprivate meta def dest_or : expr → tactic (list expr) | e := do\n  `(%%a ∨ %%b) ← whnf e | return [e],\n  lb ← dest_or b,\n  return (a :: lb)\n\nprivate meta def match_perms (pat : pattern) : expr → tactic (list $ list expr) | t :=\n  (do\n    m ← match_pattern pat t,\n    guard (m.2.all expr.is_local_constant),\n    return [m.2]) <|>\n  (do\n    `(%%l ∨ %%r) ← whnf t,\n    m ← match_pattern pat l,\n    rs ← match_perms r,\n    return (m.2 :: rs))\n\nprivate meta def update_type : expr → expr → expr\n| (local_const n pp bi d) t := local_const n pp bi t\n| e t := e\n\nprivate meta def intron' : ℕ → tactic (list expr)\n| 0       := return []\n| (i + 1) := do\n  n ← intro1,\n  ls ← intron' i,\n  return (n :: ls)\n\nmeta def wlog (vars' : list expr) (h_cases fst_case : expr) (perms : list (list expr)) :\n  tactic unit := do\n  guard h_cases.is_local_constant,\n\n  -- reorder s.t. context is Γ ⬝ vars ⬝ cases ⊢ ∀deps, …\n  nr ← revert_lst (vars' ++ [h_cases]),\n  vars ← intron' vars'.length,\n  h_cases ← intro h_cases.local_pp_name,\n\n  cases ← infer_type h_cases,\n  h_fst_case ←\n    mk_local_def h_cases.local_pp_name\n      (fst_case.instantiate_locals $ (vars'.zip vars).map $ λ⟨o, n⟩, (o.local_uniq_name, n)),\n  ((), pr) ← solve_aux cases (repeat $ exact h_fst_case <|> left >> skip),\n\n  t ← target,\n  fixed_vars ← vars.mmap (λv, do t ← infer_type v, return (update_type v t) ),\n  let t' := (instantiate_local h_cases.local_uniq_name pr t).pis (fixed_vars ++ [h_fst_case]),\n\n  (h, [g]) ← local_proof `this t' (do\n    clear h_cases,\n    vars.mmap clear,\n    intron nr),\n\n  h₀ :: hs ← elim_or perms.length h_cases,\n\n  solve1 (do\n    exact (h.mk_app $ vars ++ [h₀])),\n\n  focus ((hs.zip perms.tail).map $ λ⟨h_case, perm⟩, do\n    let p_v := (vars'.zip vars).map (λ⟨p, v⟩, (p.local_uniq_name, v)),\n    let p := perm.map (λp, p.instantiate_locals p_v),\n    note `this none (h.mk_app $ p ++ [h_case]),\n    clear h,\n    return ()),\n  gs ← get_goals,\n  set_goals (g :: gs)\n\nnamespace interactive\nopen interactive interactive.types expr\n\nprivate meta def parse_permutations : option (list (list name)) → tactic (list (list expr))\n| none                    := return []\n| (some [])               := return []\n| (some perms@(p₀ :: ps)) := do\n  (guard p₀.nodup <|>\n    fail \"No permutation `xs_i` in `using [xs_1, …, xs_n]` should contain the same variable twice.\"),\n  (guard (perms.all $ λp, p.perm p₀) <|>\n    fail \"The permutations `xs_i` in `using [xs_1, …, xs_n]` must be permutations of the same variables.\"),\n  perms.mmap (λp, p.mmap get_local)\n\n/-- Without loss of generality: reduces to one goal under variables permutations.\n\nGiven a goal of the form `g xs`, a predicate `p` over a set of variables, as well as variable\npermutations `xs_i`. Then `wlog` produces goals of the form\n\nThe case goal, i.e. the permutation `xs_i` covers all possible cases:\n  `⊢ p xs_0 ∨ ⋯ ∨ p xs_n`\nThe main goal, i.e. the goal reduced to `xs_0`:\n  `(h : p xs_0) ⊢ g xs_0`\nThe invariant goals, i.e. `g` is invariant under `xs_i`:\n  `(h : p xs_i) (this : g xs_0) ⊢ gs xs_i`\n\nEither the permutation is provided, or a proof of the disjunction is provided to compute the\npermutation. The disjunction need to be in assoc normal form, e.g. `p₀ ∨ (p₁ ∨ p₂)`. In many cases\nthe invariant goals can be solved by AC rewriting using `cc` etc.\n\nExample:\n  On a state `(n m : ℕ) ⊢ p n m` the tactic `wlog h : n ≤ m using [n m, m n]` produces the following\n  states:\n    `(n m : ℕ) ⊢ n ≤ m ∨ m ≤ n`\n    `(n m : ℕ) (h : n ≤ m) ⊢ p n m`\n    `(n m : ℕ) (h : m ≤ n) (this : p n m) ⊢ p m n`\n\n`wlog` supports different calling conventions. The name `h` is used to give a name to the introduced\ncase hypothesis. If the name is avoided, the default will be `case`.\n\n(1) `wlog : p xs0 using [xs0, …, xsn]`\n  Results in the case goal `p xs0 ∨ ⋯ ∨ ps xsn`, the main goal `(case : p xs0) ⊢ g xs0` and the\n  invariance goals `(case : p xsi) (this : g xs0) ⊢ g xsi`.\n\n(2) `wlog : p xs0 := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 ∨ ⋯ ∨ p xsi`, it is also used to compute the\n  variable permutations.\n\n(3) `wlog := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 ∨ ⋯ ∨ p xsi`, it is also used to compute the\n  variable permutations. This is not as stable as (2), for example `p` cannot be a disjunction.\n\n(4) `wlog : R x y using x y` and `wlog : R x y`\n  Produces the case `R x y ∨ R y x`. If `R` is ≤, then the disjunction discharged using linearity.\n  If `using x y` is avoided then `x` and `y` are the last two variables appearing in the\n  expression `R x y`. -/\nmeta def wlog\n  (h : parse ident?)\n  (pat : parse (tk \":\" *> texpr)?)\n  (cases : parse (tk \":=\" *> texpr)?)\n  (perms : parse (tk \"using\" *> (list_of (ident*) <|> (λx, [x]) <$> ident*))?)\n  (discharger : tactic unit :=\n    (solve_by_elim <|> tauto <|> using_smt (smt_tactic.intros >> smt_tactic.solve_goals))) :\n  tactic unit := do\nperms ← parse_permutations perms,\n(pat, cases_pr, cases_goal, vars, perms) ← (match cases with\n| some r := do\n  vars::_ ← return perms |\n    fail \"At least one set of variables expected, i.e. `using x y` or `using [x y, y x]`.\",\n  cases_pr ← to_expr r,\n  cases_pr ← (if cases_pr.is_local_constant\n    then return $ match h with some n := update_pp_name cases_pr n | none := cases_pr end\n    else do\n      note (h.get_or_else `case) none cases_pr),\n  cases ← infer_type cases_pr,\n  (pat, perms') ← match pat with\n  | some pat := do\n    pat ← to_expr pat,\n    let vars' := vars.filter $ λv, v.occurs pat,\n    case_pat ← mk_pattern [] vars' pat [] vars',\n    perms' ← match_perms case_pat cases,\n    return (pat, perms')\n  | none := do\n    (p :: ps) ← dest_or cases,\n    let vars' := vars.filter $ λv, v.occurs p,\n    case_pat ← mk_pattern [] vars' p [] vars',\n    perms' ← (p :: ps).mmap (λp, do m ← match_pattern case_pat p, return m.2),\n    return (p, perms')\n  end,\n  let vars_name := vars.map local_uniq_name,\n  guard (perms'.all $ λp, p.all $ λv, v.is_local_constant ∧ v.local_uniq_name ∈ vars_name) <|>\n    fail \"Cases contains variables not declared in `using x y z`\",\n  perms ← (if perms.length = 1\n    then do\n      return (perms'.map $ λp, p ++ vars.filter (λv, p.all (λv', v'.local_uniq_name ≠ v.local_uniq_name)))\n    else do\n      guard (perms.length = perms'.length) <|>\n        fail \"The provided permutation list has a different length then the provided cases.\",\n      return perms),\n  return (pat, cases_pr, @none expr, vars, perms)\n\n| none   := do\n  let name_h := h.get_or_else `case,\n  some pat ← return pat | fail \"Either specify cases or a pattern with permutations\",\n  pat ← to_expr pat,\n  (do\n    [x, y] ← match perms with\n    | []  := return pat.list_local_consts\n    | [l] := return l\n    | _   := failed\n    end,\n    let cases := mk_or_lst [pat, pat.instantiate_locals [(x.local_uniq_name, y), (y.local_uniq_name, x)]],\n    (do\n      `(%%x' ≤ %%y') ← return pat,\n      (cases_pr, []) ← local_proof name_h cases (exact ``(le_total %%x' %%y')),\n      return (pat, cases_pr, none, [x, y], [[x, y], [y, x]]))\n    <|>\n    (do\n      (cases_pr, [g]) ← local_proof name_h cases skip,\n      return (pat, cases_pr, some g, [x, y], [[x, y], [y, x]]))) <|>\n  (do\n    guard (perms.length ≥ 2) <|>\n      fail (\"To generate cases at least two permutations are required, i.e. `using [x y, y x]`\" ++\n        \" or exactly 0 or 2 variables\"),\n    (vars :: perms') ← return perms,\n    let names := vars.map local_uniq_name,\n    let cases := mk_or_lst (pat :: perms'.map (λp, pat.instantiate_locals (names.zip p))),\n    (cases_pr, [g]) ← local_proof name_h cases skip,\n    return (pat, cases_pr, some g, vars, perms))\nend),\nlet name_fn :=\n  (if perms.length = 2 then λi, `invariant else λi, mk_simple_name (\"invariant_\" ++ to_string (i + 1))),\nwith_enable_tags $ tactic.focus1 $ do\n  t ← get_main_tag,\n  tactic.wlog vars cases_pr pat perms,\n  tactic.focus (set_main_tag (mk_num_name `_case 0 :: `main :: t) ::\n    (list.range (perms.length - 1)).map (λi, do\n      set_main_tag (mk_num_name `_case 0 :: name_fn i :: t),\n      try discharger)),\n  match cases_goal with\n  | some g := do\n    set_tag g (mk_num_name `_case 0 :: `cases :: t),\n    gs ← get_goals,\n    set_goals (g :: gs)\n  | none := skip\n  end\n\nend interactive\n\nend tactic\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/tactic/wlog.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.47694455071417047}}
{"text": "/-\nCopyright (c) 2022 Henrik Böving. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henrik Böving, Simon Hudon\n-/\n\nimport LSpec.SlimCheck.Sampleable\nimport Lean\n\n/-!\n# `Checkable` Class\nCheckable propositions have a procedure that can generate counter-examples\ntogether with a proof that they invalidate the proposition.\nThis is a port of the Haskell QuickCheck library.\n## Creating Customized Instances\nThe type classes `Checkable`, `SampleableExt` and `Shrinkable` are the\nmeans by which `SlimCheck` creates samples and tests them. For instance,\nthe proposition `∀ i j : ℕ, i ≤ j` has a `Checkable` instance because `ℕ`\nis sampleable and `i ≤ j` is decidable. Once `SlimCheck` finds the `Checkable`\ninstance, it can start using the instance to repeatedly creating samples\nand checking whether they satisfy the property. Once it has found a\ncounter-example it will then use a `Shrinkable` instance to reduce the\nexample. This allows the user to create new instances and apply\n`SlimCheck` to new situations.\n### What do I do if I'm testing a property about my newly defined type?\nLet us consider a type made for a new formalization:\n```lean\nstructure MyType where\n  x : ℕ\n  y : ℕ\n  h : x ≤ y\n  deriving Repr\n```\nHow do we test a property about `MyType`? For instance, let us consider\n`Checkable.check $ ∀ a b : MyType, a.y ≤ b.x → a.x ≤ b.y`. Writing this\nproperty as is will give us an error because we do not have an instance\nof `Shrinkable MyType` and `SampleableExt MyType`. We can define one as follows:\n```lean\ninstance : Shrinkable MyType where\n  shrink := λ ⟨x,y,h⟩ =>\n    let proxy := Shrinkable.shrink (x, y - x)\n    proxy.map (λ ⟨⟨fst, snd⟩, ha⟩ => ⟨⟨fst, fst + snd, sorry⟩, sorry⟩)\ninstance : SampleableExt MyType :=\n  SampleableExt.mkSelfContained do\n    let x ← SampleableExt.interpSample Nat\n    let xyDiff ← SampleableExt.interpSample Nat\n    pure $ ⟨x, x + xyDiff, sorry⟩\n```\nAgain, we take advantage of the fact that other types have useful\n`Shrinkable` implementations, in this case `Prod`. Note that the second\nproof is heavily based on `WellFoundedRelation` since its used for termination so\nthe first step you want to take is almost always to `simp_wf` in order to\nget through the `WellFoundedRelation`.\n## Main definitions\n  * `Checkable` class\n  * `Checkable.check`: a way to test a proposition using random examples\n## Tags\nrandom testing\n## References\n  * https://hackage.haskell.org/package/QuickCheck\n-/\n\nnamespace SlimCheck\n\n/-- Result of trying to disprove `p`\nThe constructors are:\n  *  `success : (PSum Unit p) → TestResult p`\n     succeed when we find another example satisfying `p`\n     In `success h`, `h` is an optional proof of the proposition.\n     Without the proof, all we know is that we found one example\n     where `p` holds. With a proof, the one test was sufficient to\n     prove that `p` holds and we do not need to keep finding examples.\n   * `gaveUp : ℕ → TestResult p`\n     give up when a well-formed example cannot be generated.\n     `gaveUp n` tells us that `n` invalid examples were tried.\n     Above 100, we give up on the proposition and report that we\n     did not find a way to properly test it.\n   * `failure : ¬ p → (List String) → ℕ → TestResult p`\n     a counter-example to `p`; the strings specify values for the relevant variables.\n     `failure h vs n` also carries a proof that `p` does not hold. This way, we can\n     guarantee that there will be no false positive. The last component, `n`,\n     is the number of times that the counter-example was shrunk.\n-/\ninductive TestResult (p : Prop) where\n  | success : PSum Unit p → TestResult p\n  | gaveUp : Nat → TestResult p\n  | failure : ¬ p → List String → Nat → TestResult p\n  deriving Inhabited\n\n/-- Configuration for testing a property. -/\nstructure Configuration where\n  numInst : Nat := 100\n  maxSize : Nat := 100\n  numRetries : Nat := 10\n  traceDiscarded : Bool := false\n  traceSuccesses : Bool := false\n  traceShrink : Bool := false\n  traceShrinkCandidates : Bool := false\n  randomSeed : Option Nat := none\n  quiet : Bool := false\n  deriving Inhabited\n\n/--\n`PrintableProp p` allows one to print a proposition so that\n`SlimCheck` can indicate how values relate to each other.\nIt's basically a poor man's delaborator.\n-/\nclass PrintableProp (p : Prop) where\n  printProp : String\n\nexport PrintableProp (printProp)\n\ninstance (priority := low) : PrintableProp p where\n  printProp := \"⋯\"\n\n/-- `Checkable p` uses random examples to try to disprove `p`. -/\nclass Checkable (p : Prop) where\n  run (cfg : Configuration) (minimize : Bool) : Gen (TestResult p)\n\ndef NamedBinder (_n : String) (p : Prop) : Prop := p\n\nnamespace TestResult\n\ndef toString : TestResult p → String\n| success (PSum.inl _) => \"success (no proof)\"\n| success (PSum.inr _) => \"success (proof)\"\n| gaveUp n => s!\"gave {n} times\"\n| failure _ counters _ => s!\"failed {counters}\"\n\ninstance : ToString (TestResult p) := ⟨toString⟩\n\n/-- Applicative combinator proof carrying test results. -/\ndef combine {p q : Prop} : PSum Unit (p → q) → PSum Unit p → PSum Unit q\n| PSum.inr f, PSum.inr proof => PSum.inr $ f proof\n| _, _ => PSum.inl ()\n\n/-- Combine the test result for properties `p` and `q` to create a test for their conjunction. -/\ndef and : TestResult p → TestResult q → TestResult (p ∧ q)\n| failure h xs n, _ => failure (λ h2 => h h2.left) xs n\n| _, failure h xs n => failure (λ h2 => h h2.right) xs n\n| success h1, success h2 => success $ combine (combine (PSum.inr And.intro) h1) h2\n| gaveUp n, gaveUp m => gaveUp $ n + m\n| gaveUp n, _ => gaveUp n\n| _, gaveUp n => gaveUp n\n\n/-- Combine the test result for properties `p` and `q` to create a test for their disjunction. -/\ndef or : TestResult p → TestResult q → TestResult (p ∨ q)\n| failure h1 xs n, failure h2 ys m =>\n  let h3 := λ h =>\n    match h with\n    | Or.inl h3 => h1 h3\n    | Or.inr h3 => h2 h3\n  failure h3 (xs ++ ys) (n + m)\n| success h, _ => success $ combine (PSum.inr Or.inl) h\n| _, success h => success $ combine (PSum.inr Or.inr) h\n| gaveUp n, gaveUp m => gaveUp $ n + m\n| gaveUp n, _ => gaveUp n\n| _, gaveUp n => gaveUp n\n\n/-- If `q → p`, then `¬ p → ¬ q` which means that testing `p` can allow us\nto find counter-examples to `q`. -/\ndef imp (h : q → p) (r : TestResult p)\n    (p : PSum Unit (p → q) := PSum.inl ()) : TestResult q :=\n  match r with\n  | failure h2 xs n => failure (mt h h2) xs n\n  | success h2 => success $ combine p h2\n  | gaveUp n => gaveUp n\n\n/-- Test `q` by testing `p` and proving the equivalence between the two. -/\ndef iff (h : q ↔ p) (r : TestResult p) : TestResult q :=\n  imp h.mp r (PSum.inr h.mpr)\n\n/-- When we assign a value to a universally quantified variable,\nwe record that value using this function so that our counter-examples\ncan be informative. -/\ndef addInfo (x : String) (h : q → p) (r : TestResult p)\n    (p : PSum Unit (p → q) := PSum.inl ()) : TestResult q :=\n  if let failure h2 xs n := r then\n    failure (mt h h2) (x :: xs) n\n  else\n    imp h r p\n\n/-- Add some formatting to the information recorded by `addInfo`. -/\ndef addVarInfo [Repr γ] (var : String) (x : γ) (h : q → p) (r : TestResult p)\n    (p : PSum Unit (p → q) := PSum.inl ()) : TestResult q  :=\n  addInfo s!\"{var} := {repr x}\" h r p\n\ndef isFailure : TestResult p → Bool\n| failure _ _ _ => true\n| _ => false\n\nend TestResult\n\nnamespace Configuration\n\n/-- A configuration with all the trace options enabled, useful for debugging. -/\ndef verbose : Configuration where\n  traceDiscarded := true\n  traceSuccesses := true\n  traceShrink := true\n  traceShrinkCandidates := true\n\nend Configuration\n\nnamespace Checkable\n\nopen TestResult\n\ndef runProp (p : Prop) [Checkable p] : Configuration → Bool → Gen (TestResult p) := Checkable.run\n\n/-- A `dbgTrace` with special formatting -/\ndef slimTrace [Pure m] (s : String) : m PUnit := dbgTrace s!\"[SlimCheck: {s}]\" (λ _ => pure ())\n\ninstance andCheckable [Checkable p] [Checkable q] : Checkable (p ∧ q) where\n  run := λ cfg min => do\n    let xp ← runProp p cfg min\n    let xq ← runProp q cfg min\n    pure $ and xp xq\n\ninstance orCheckable [Checkable p] [Checkable q] : Checkable (p ∨ q) where\n  run := λ cfg min => do\n    let xp ← runProp p cfg min\n    -- As a little performance optimization we can just not run the second\n    -- test if the first succeeds\n    match xp with\n    | success (PSum.inl h) => pure $ success (PSum.inl h)\n    | success (PSum.inr h) => pure $ success (PSum.inr $ Or.inl h)\n    | _ =>\n      let xq ← runProp q cfg min\n      pure $ or xp xq\n\n-- TODO(Winston): Move\nprotected theorem key : (a ↔ b) ↔ (a ∧ b) ∨ (¬ a ∧ ¬ b) :=\nby constructor\n   · intro h; rw [h]\n     by_cases h : b\n     · exact Or.inl <| And.intro h h\n     · exact Or.inr <| And.intro h h\n   · intro h\n     match h with\n     | Or.inl h => exact Iff.intro (λ _ => h.2) (λ _ => h.1)\n     | Or.inr h => exact Iff.intro (λ a => False.elim $ h.1 a) (λ b => False.elim $ h.2 b)\n\ninstance iffCheckable [Checkable ((p ∧ q) ∨ (¬ p ∧ ¬ q))] : Checkable (p ↔ q) where\n  run := λ cfg min => do\n    let h ← runProp ((p ∧ q) ∨ (¬ p ∧ ¬ q)) cfg min\n    pure $ iff Checkable.key h\n\ninstance decGuardCheckable [PrintableProp p] [Decidable p] {β : p → Prop} [∀ h, Checkable (β h)] : Checkable (NamedBinder var $ ∀ h, β h) where\n  run := λ cfg min => do\n    if h : p then\n      let res := (runProp (β h) cfg min)\n      let s := printProp p\n      (λ r => addInfo s!\"guard: {s}\" (· $ h) r (PSum.inr $ λ q _ => q)) <$> res\n    else if cfg.traceDiscarded || cfg.traceSuccesses then\n      let res := (λ _ => pure $ gaveUp 1)\n      let s := printProp p\n      slimTrace s!\"discard: Guard {s} does not hold\"; res\n    else\n      pure $ gaveUp 1\n\ninstance forallTypesCheckable {f : Type → Prop} [Checkable (f Int)] : Checkable (NamedBinder var $ ∀ x, f x) where\n  run := λ cfg min => do\n    let r ← runProp (f Int) cfg min\n    pure $ addVarInfo var \"ℤ\" (· $ Int) r\n\n/--\nFormat the counter-examples found in a test failure.\n-/\ndef formatFailure (s : String) (xs : List String) (n : Nat) : String :=\n  let counter := \"\\n\".intercalate xs\n  let parts := [\n    \"\\n===================\",\n    s,\n    counter,\n    s!\"({n} shrinks)\",\n    \"-------------------\"\n  ]\n  \"\\n\".intercalate parts\n\n/--\nIncrease the number of shrinking steps in a test result.\n-/\ndef addShrinks (n : Nat) : TestResult p → TestResult p\n| TestResult.failure p xs m => TestResult.failure p xs (m + n)\n| p => p\n\n-- TODO(Winston): Move\ninstance [Inhabited (m (Option α))]: Inhabited (OptionT m α) where \n  default := .mk default\n\n/-- Shrink a counter-example `x` by using `Shrinkable.shrink x`, picking the first\ncandidate that falsifies a property and recursively shrinking that one.\nThe process is guaranteed to terminate because `shrink x` produces\na proof that all the values it produces are smaller (according to `SizeOf`)\nthan `x`. -/\npartial def minimizeAux [SampleableExt α] {β : α → Prop} [∀ x, Checkable (β x)] (cfg : Configuration) (var : String)\n    (x : SampleableExt.proxy α) (n : Nat) : OptionT Gen (Σ x, TestResult (β (SampleableExt.interp x))) := do\n  let candidates := SampleableExt.shrink.shrink x\n  if cfg.traceShrinkCandidates then\n    slimTrace s!\"Candidates for {var} := {repr x}:\\n  {repr candidates}\"\n  for candidate in candidates do\n    if cfg.traceShrinkCandidates then\n      slimTrace s!\"Trying {var} := {repr candidate}\"\n    let res ← OptionT.lift $ Checkable.runProp (β (SampleableExt.interp candidate)) cfg true\n    if res.isFailure then\n      if cfg.traceShrink then\n        slimTrace s!\"{var} shrunk to {repr candidate} from {repr x}\"\n      let currentStep := OptionT.lift $ pure $ Sigma.mk candidate (addShrinks (n + 1) res)\n      -- todo: `nextStep` is unused. Why is it here?\n      -- let nextStep := @minimizeAux α _ β _ cfg var candidate (n + 1)\n      return ← (currentStep)\n  if cfg.traceShrink then\n    slimTrace s!\"No shrinking possible for {var} := {repr x}\"\n  failure\n\n/-- Once a property fails to hold on an example, look for smaller counter-examples\nto show the user. -/\ndef minimize [SampleableExt α] {β : α → Prop} [∀ x, Checkable (β x)] (cfg : Configuration) (var : String)\n    (x : SampleableExt.proxy α) (r : TestResult (β $ SampleableExt.interp x)) : Gen (Σ x, TestResult (β $ SampleableExt.interp x)) := do\n  if cfg.traceShrink then\n     slimTrace \"Shrink\"\n     slimTrace s!\"Attempting to shrink {var} := {repr x}\"\n  let res ← OptionT.run $ minimizeAux cfg var x 0\n  pure $ res.getD ⟨x, r⟩\n\n/-- Test a universal property by creating a sample of the right type and instantiating the\nbound variable with it. -/\ninstance varCheckable [SampleableExt α] {β : α → Prop} [∀ x, Checkable (β x)] : Checkable (NamedBinder var $ ∀ x : α, β x) where\n  run := λ cfg min => do\n    let x ← SampleableExt.sample\n    if cfg.traceSuccesses || cfg.traceDiscarded then\n      slimTrace s!\"{var} := {repr x}\"\n    let r ← Checkable.runProp (β $ SampleableExt.interp x) cfg false\n    let ⟨finalX, finalR⟩ ← \n      if isFailure r then\n        if cfg.traceSuccesses then\n          slimTrace s!\"{var} := {repr x} is a failure\"\n        if min then\n          minimize cfg var x r\n        else\n          pure $ ⟨x, r⟩\n      else\n        pure $ ⟨x, r⟩\n    pure $ addVarInfo var finalX (· $ SampleableExt.interp finalX) finalR\n\n/-- Test a universal property about propositions -/\ninstance propVarCheckable {β : Prop → Prop} [∀ b : Bool, Checkable (β b)] :\n  Checkable (NamedBinder var $ ∀ p : Prop, β p)\nwhere\n  run := λ cfg min =>\n    imp (λ h (b : Bool) => h b) <$> Checkable.runProp (NamedBinder var $ ∀ b : Bool, β b) cfg min\n\ninstance (priority := high) unusedVarCheckable [Nonempty α] [Checkable β] :\n  Checkable (NamedBinder var $ ∀ _x : α, β)\nwhere\n  run := λ cfg min => do\n    if cfg.traceDiscarded || cfg.traceSuccesses then\n      slimTrace s!\"{var} is unused\"\n    let r ← Checkable.runProp β cfg min\n    let finalR := addInfo s!\"{var} is irrelevant (unused)\" id r\n    pure $ imp (· $ Classical.ofNonempty) finalR (PSum.inr $ λ x _ => x)\n\ninstance (priority := low) decidableCheckable {p : Prop} [PrintableProp p] [Decidable p] : Checkable p where\n  run := λ _ _ =>\n    if h : p then\n      pure $ success (PSum.inr h)\n    else\n      let s := printProp p\n      pure $ failure h [s!\"issue: {s} does not hold\"] 0\n\nend Checkable\n\nsection PrintableProp\n\ninstance Eq.printableProp [Repr α] {x y : α} : PrintableProp (x = y) where\n  printProp := s!\"{repr x} = {repr y}\"\n\ninstance Ne.printableProp [Repr α] {x y : α} : PrintableProp (x ≠ y) where\n  printProp := s!\"{repr x} ≠ {repr y}\"\n\ninstance LE.printableProp [Repr α] [LE α] {x y : α} : PrintableProp (x ≤ y) where\n  printProp := s!\"{repr x} ≤ {repr y}\"\n\ninstance LT.printableProp [Repr α] [LT α] {x y : α} : PrintableProp (x < y) where\n  printProp := s!\"{repr x} < {repr y}\"\n\ninstance And.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x ∧ y) where\n  printProp := s!\"{printProp x} ∧ {printProp y}\"\n\ninstance Or.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x ∨ y) where\n  printProp := s!\"{printProp x} ∨ {printProp y}\"\n\ninstance Iff.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x ↔ y) where\n  printProp := s!\"{printProp x} ↔ {printProp y}\"\n\ninstance Imp.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x → y) where\n  printProp := s!\"{printProp x} → {printProp y}\"\n\ninstance Not.printableProp [PrintableProp x] : PrintableProp (¬x) where\n  printProp := s!\"¬{printProp x}\"\n\ninstance True.printableProp : PrintableProp True where\n  printProp := \"True\"\n\ninstance False.printableProp : PrintableProp False where\n  printProp := \"False\"\n\ninstance Bool.printableProp {b : Bool} : PrintableProp b where\n  printProp := if b then \"true\" else \"false\"\n\nend PrintableProp\n\nsection IO\nopen TestResult\n\n/-- Execute `cmd` and repeat every time the result is `gave_up` (at most `n` times). -/\ndef retry (cmd : Rand (TestResult p)) : Nat → Rand (TestResult p)\n| 0 => pure $ TestResult.gaveUp 1\n| n+1 => do\n  let r ← cmd\n  match r with\n  | success hp => pure $ success hp\n  | TestResult.failure h xs n => pure $ failure h xs n\n  | gaveUp _ => retry cmd n\n\n/-- Count the number of times the test procedure gave up. -/\ndef giveUp (x : Nat) : TestResult p → TestResult p\n| success (PSum.inl ()) => gaveUp x\n| success (PSum.inr p) => success $ (PSum.inr p)\n| gaveUp n => gaveUp $ n + x\n| TestResult.failure h xs n => failure h xs n\n\n/-- Try `n` times to find a counter-example for `p`. -/\ndef Checkable.runSuiteAux (p : Prop) [Checkable p] (cfg : Configuration) : TestResult p → Nat → Rand (TestResult p)\n| r, 0 => pure r\n| r, n+1 => do\n  let size := (cfg.numInst - n - 1) * cfg.maxSize / cfg.numInst\n  if cfg.traceSuccesses then\n    slimTrace s!\"New sample\"\n    slimTrace s!\"Retrying up to {cfg.numRetries} times until guards hold\"\n  let x ← retry (ReaderT.run (Checkable.runProp p cfg true) ⟨size⟩) cfg.numRetries\n  match x with\n  | (success (PSum.inl ())) => runSuiteAux p cfg r n\n  | (gaveUp g) => runSuiteAux p cfg (giveUp g r) n\n  | _ => pure $ x\n\n/-- Try to find a counter-example of `p`. -/\ndef Checkable.runSuite (p : Prop) [Checkable p] (cfg : Configuration := {}) : Rand (TestResult p) :=\n  Checkable.runSuiteAux p cfg (success $ PSum.inl ()) cfg.numInst\n\n/-- Run a test suite for `p` in `BaseIO` using the global RNG in `stdGenRef`. -/\ndef Checkable.checkIO (p : Prop) [Checkable p] (cfg : Configuration := {}) : BaseIO (TestResult p) :=\n  match cfg.randomSeed with\n  | none => IO.runRand (Checkable.runSuite p cfg)\n  | some seed => IO.runRandWith seed (Checkable.runSuite p cfg)\n\nend IO\n\nnamespace Decorations\n\nopen Lean\n\n/-- Traverse the syntax of a proposition to find universal quantifiers\nquantifiers and add `NamedBinder` annotations next to them. -/\npartial def addDecorations (e : Expr) : Expr :=\n  e.replace $ λ expr =>\n    match expr with\n    | Expr.forallE name type body data =>\n      let n := name.toString\n      let newType := addDecorations type\n      let newBody := addDecorations body\n      let rest := Expr.forallE name newType newBody data\n      some $ mkApp2 (mkConst `SlimCheck.NamedBinder) (mkStrLit n) rest\n    | _ => none\n\n/-- `DecorationsOf p` is used as a hint to `mk_decorations` to specify\nthat the goal should be satisfied with a proposition equivalent to `p`\nwith added annotations. -/\nabbrev DecorationsOf (_p : Prop) := Prop\n\nopen Elab.Tactic\nopen Meta\n\n/-- In a goal of the shape `⊢ DecorationsOf p`, `mk_decoration` examines\nthe syntax of `p` and adds `NamedBinder` around universal quantifications\nto improve error messages. This tool can be used in the declaration of a\nfunction as follows:\n```lean\ndef foo (p : Prop) (p' : Decorations.DecorationsOf p := by mk_decorations) [Checkable p'] : ...\n```\n`p` is the parameter given by the user, `p'` is a definitionally equivalent\nproposition where the quantifiers are annotated with `NamedBinder`.\n-/\nscoped elab \"mk_decorations\" : tactic => do\n  let goalType ← (← getMainGoal).getType\n  if let Expr.app (.const ``Decorations.DecorationsOf ..) body := goalType then\n    closeMainGoal (addDecorations body)\n\nend Decorations\n\nopen Decorations in\n/-- Run a test suite for `p` and throw an exception if `p` does not not hold.-/\ndef Checkable.check (p : Prop) (cfg : Configuration := {}) (p' : Decorations.DecorationsOf p := by mk_decorations) [Checkable p'] : IO PUnit := do\n  let x ← Checkable.checkIO p' cfg\n  go p' x where /-- HACK: https://github.com/leanprover/lean4/issues/1247 -/ go p' (x : TestResult p') : IO PUnit := do\n  match x with\n  | TestResult.success _ => if !cfg.quiet then IO.println \"Success\" else pure ()\n  | TestResult.gaveUp n => if !cfg.quiet then IO.println s!\"Gave up {n} times\"\n  | TestResult.failure _ xs n => throw (IO.userError $ formatFailure \"Found problems!\" xs n)\n\n-- #eval Checkable.check (∀ (x y z a : Nat) (h1 : 3 < x) (h2 : 3 < y), x - y = y - x) Configuration.verbose\n-- #eval Checkable.check (∀ x : Nat, ∀ y : Nat, x + y = y + x) Configuration.verbose\n-- #eval Checkable.check (∀ (x : (Nat × Nat)), x.fst - x.snd - 10 = x.snd - x.fst - 10) Configuration.verbose\n-- #eval Checkable.check (∀ (x : Nat) (h : 10 < x), 5 < x) Configuration.verbose\n\nend SlimCheck\n", "meta": {"author": "lurk-lab", "repo": "LSpec", "sha": "88f7d23e56a061d32c7173cea5befa4b2c248b41", "save_path": "github-repos/lean/lurk-lab-LSpec", "path": "github-repos/lean/lurk-lab-LSpec/LSpec-88f7d23e56a061d32c7173cea5befa4b2c248b41/LSpec/SlimCheck/Checkable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6757646075489391, "lm_q1q2_score": 0.47694454235019496}}
{"text": "import tactic.find data.equiv algebra.group_power data.fintype data.set.finite set_theory.cardinal data.set.lattice\n\nnoncomputable theory\nlocal attribute [instance, priority 0] classical.prop_decidable classical.dec_pred\nlocal attribute [instance] set_fintype\nopen fintype\nlocal infix `^` := gpow\nuniverse u\n\n\ninstance {α : Type*} (p : α → Prop) [fintype α] : fintype {a // p a} :=\nset_fintype p\n\ninstance {α : Type*} [fintype α] (r : α → α → Prop) : fintype (quot r) :=\nof_surjective (quot.mk r) (λ x, quot.exists_rep _)\n\nlemma finset.sum_const {α β : Type*} [decidable_eq α] [add_comm_monoid β] \n    (s : finset α) (b : β) : finset.sum s (λ a, b) = add_monoid.smul b (finset.card s) :=\nfinset.induction_on s (by simp) $ λ a s h hi,\nby simp [finset.sum_insert h, finset.card_insert_of_not_mem h, hi, smul_succ]\n\ntheorem card_quot {α : Type*} [fintype α] (r : α → α → Prop) : \n    card α = (finset.univ : finset (quot r)).sum (λ x, card {a // quot.mk r a = x}) :=\ncard_sigma (λ x, {a // quot.mk r a = x}) ▸\ncard_congr ⟨λ x, ⟨quot.mk r x, ⟨x, rfl⟩⟩, λ x, x.2, λ _, rfl, λ ⟨_, _, ⟨_⟩⟩, rfl⟩\n\ninstance {α : Type*} [fintype α] (s : setoid α) : fintype (quotient s) := quot.fintype s.r\n\ntheorem card_quotient {α : Type*} [fintype α] (s : setoid α) :\n    card α = (finset.univ : finset (quotient s)).sum (λ x, card {a // ⟦a⟧ = x}) := card_quot s.r\n\ninstance {α : Type*} [fintype α] : fintype (set α) := pi.fintype\n\nsection\nvariable {α : Type*}\nopen function set finset\n\nset_option pp.implicit true\n#print eq.drec_on\nlemma set.card_eq_zero {α : Type*} {s : set α} [hf : fintype s] : card s = 0 ↔ s = ∅ :=\n⟨λ h, by_contradiction $ λ h₁, let ⟨x, hx⟩ := set.exists_mem_of_ne_empty h₁ in\nfinset.not_mem_empty (⟨x, hx⟩ : s) $ finset.card_eq_zero.1 h ▸ finset.mem_univ (⟨x, hx⟩ : s),\nλ h, by rw ← set.empty_card; congr; assumption⟩ \n\nlemma set.to_finset_union_distrib {α : Type*} (s t : set α) [hs : fintype s] [ht : fintype t] :\n@set.to_finset α (s ∪ t) (classical.choice $ set.finite_union ⟨hs⟩ ⟨ht⟩) = set.to_finset s ∪ set.to_finset t :=\nfinset.ext.2 $ λ x, by simp [set.mem_to_finset, finset.mem_union]\n\nlemma set.card_disjoint_union {α : Type*} {s t : set α} (hs : fintype s) (ht : fintype t) (hst : disjoint s t) :\n    @finset.card (s ∪ t : set α) (classical.choice $ set.finite_union ⟨hs⟩ ⟨ht⟩) = card s + card t :=\nbegin\n  have h := set.card_fintype_of_finset _ (@set.mem_to_finset _ s hs),\n  have h₁ : ∀ {s : set α} (hs : fintype s), @card s hs =  @card ↥s (@set.fintype_of_finset α s (@set.to_finset α s hs) (@set.mem_to_finset _ s hs)) := λ s hs, by congr,\n  have h₃ := set.card_fintype_of_finset _ (@set.mem_to_finset _ t ht),\n  have h₄ := set.card_fintype_of_finset _ (@set.mem_to_finset _ _ (classical.choice $ set.finite_union ⟨hs⟩ ⟨ht⟩)),\n  rw [h₁ hs, h₁ ht, h₁ (classical.choice $ set.finite_union ⟨hs⟩ ⟨ht⟩), h, h₃, h₄, set.to_finset_union_distrib],\n  rw finset.card_disjoint_union,\n  simp [finset.disjoint],\n  exact hst,\n\nend\n\nlemma blah {p q : Prop} (hp : p) (hq : q) : hp == hq := \n@eq.drec_on _ _ (λ r h₁, hp == (h₁ ▸ hp : r)) _\n(propext ⟨λ h, hq, λ h, hp⟩) (heq.refl _)\n\nclass subgroup {α : Type*} [group α] (s : set α) : Prop :=\n(one_mem : (1 : α) ∈ s)\n(mul_mem : ∀ {x y}, x ∈ s → y ∈ s → x * y ∈ s)\n(inv_mem : ∀ {x}, x ∈ s → x⁻¹ ∈ s)\nend\nnamespace subgroup\nvariables {α : Type*} [g : group α]\ninclude g\n\ninstance group (s : set α) [subgroup s] : group s :=\n{ mul := λ ⟨x, hx⟩ ⟨y, hy⟩, ⟨x * y, mul_mem hx hy⟩,\n  mul_assoc := λ ⟨x, hx⟩ ⟨y, hy⟩ ⟨z, hz⟩, subtype.eq $ mul_assoc _ _ _,\n  one := ⟨1, one_mem s⟩,\n  one_mul := λ ⟨x, hx⟩, subtype.eq $ one_mul _,\n  mul_one := λ ⟨x, hx⟩, subtype.eq $ mul_one _,\n  inv := λ ⟨x, hx⟩, ⟨x⁻¹, inv_mem hx⟩,\n  mul_left_inv := λ ⟨x, hx⟩, subtype.eq $ mul_left_inv _ }\n\n@[simp] lemma coe_one (S : set α) [subgroup S] : ((1 : S) : α) = 1 := rfl\n\n@[simp] lemma coe_mul {S : set α} [subgroup S] : ∀ a b : S, ((a * b : S) : α) = (a : α) * (b : α) :=\nλ ⟨a, ha⟩ ⟨b, hb⟩, rfl\n\n@[simp] lemma coe_inv {S : set α} [subgroup S] : ∀ a : S, ((a⁻¹ : S) : α) = (a : α)⁻¹ := \nλ ⟨a, ha⟩, rfl\n\n@[simp] lemma coe_pow {S : set α} [subgroup S] (a : S) (n : ℕ) : ((monoid.pow a n : S) : α) = monoid.pow a n := \nby induction n; simp[pow_succ, *]\n\n@[simp] lemma coe_gpow {S : set α} [subgroup S] (a : S) (i : ℤ) : ((gpow a i : S) : α) = gpow a i :=\nby cases i; simp\n\nend subgroup\n\nsection cyclic \n\nclass cyclic_group (α : Type*) extends group α :=\n(cyclic : ∃ a, ∀ b : α, ∃ i : ℤ, a^i = b)\n\ninstance cyclic_group.comm_group {α : Type*} [h : cyclic_group α] : comm_group α := \n{ mul_comm :=\n  λ x y, let ⟨a, ha⟩ := cyclic_group.cyclic α in\n         let ⟨i, hi⟩ := ha x in\n         let ⟨j, hj⟩ := ha y in\n         hi ▸ hj ▸ gpow_mul_comm a i j,\n  ..h }\n\nvariables {α : Type*} [group α]\n\ndef cycle (a : α) := {b : α | ∃ i : ℤ, a^i = b}\n\ninstance [fintype α] (a : α) : fintype (cycle a) := set_fintype _\n\ninstance (a : α) : subgroup (cycle a) := \n{ one_mem := ⟨0, by simp⟩,\n  inv_mem := λ b ⟨i, hi⟩, ⟨-i, hi ▸ gpow_neg _ _⟩,\n  mul_mem := λ b c ⟨i, hi⟩ ⟨j, hj⟩, ⟨i + j, hi ▸ (hj ▸ (gpow_add _ _ _))⟩ }\n\ninstance (a : α) : cyclic_group (cycle a) :=\n{ cyclic := ⟨⟨a, 1, pow_one _⟩, λ ⟨b, ⟨i, hi⟩⟩, \n⟨i, subtype.eq ((subgroup.coe_gpow (⟨a, _⟩ : cycle a) i).trans hi)⟩ ⟩ }\n\nlemma mem_cycle_self (a : α) [fintype (cycle a)] : a ∈ cycle a := ⟨1, by simp⟩\n\nlemma exists_int_pow_eq_one_of_finite_cycle (a : α) [fintype (cycle a)] : ∃ i : ℤ, i ≠ 0 ∧ a^i = 1 :=\nby_contradiction $ λ h, @not_injective_nat_fintype _ _ _ \n(λ n, (⟨a^(nat.succ n), ⟨int.nat_abs (nat.succ n), by rw [int.nat_abs_of_nat] ⟩ ⟩ : cycle a)) $\nhave h : ∀ i : ℤ, ¬(i ≠ 0 ∧ a^i = 1) := not_exists.mp h,\nhave h₁ : ∀ (i : ℤ), a^i = 1 → ¬i ≠ 0 := λ i, not_and'.mp (h i),\nλ m n hmn, have hmn' : a^(nat.succ m) =a^(nat.succ n) := subtype.mk.inj hmn,\nbegin \n  rw [← sub_add_cancel ((nat.succ m) : ℤ) (nat.succ n), gpow_add, ← mul_right_inj (a^nat.succ n)⁻¹,\n      mul_inv_self, mul_assoc, mul_inv_self, mul_one] at hmn',\n  exact nat.succ_inj (int.coe_nat_inj $ eq_of_sub_eq_zero $ not_not.mp $ h₁ _ hmn') \nend\n\nlemma exists_nat_pow_eq_one_of_finite_cycle (a : α) [fintype (cycle a)] :\n    ∃ n : ℕ, 0 < n ∧ monoid.pow a n = 1 :=\nlet ⟨i, hi⟩ := exists_int_pow_eq_one_of_finite_cycle a in\n⟨int.nat_abs i, ⟨int.nat_abs_pos_of_ne_zero hi.1,\nor.by_cases (int.nat_abs_eq i) \n(λ h, by rw h at hi; exact (gpow_coe_nat _ _).symm.trans hi.2) \n(λ h, by rw [h, gpow_neg] at hi; exact (gpow_coe_nat _ _).symm.trans (inv_eq_one.1 hi.2)) ⟩ ⟩\n\ndef ord (a : α) [fintype (cycle a)] := nat.find $ exists_nat_pow_eq_one_of_finite_cycle a\n\nvariables (a : α) [fintype (cycle a)]\n\n@[simp] lemma pow_ord : monoid.pow a (ord a) = 1 := (nat.find_spec $ exists_nat_pow_eq_one_of_finite_cycle a).2\n\nlemma ord_pos : 0 < ord a := (nat.find_spec $ exists_nat_pow_eq_one_of_finite_cycle a).1\n\nlemma ord_le {a : α} [fintype (cycle a)] {n : ℕ} (ha0 : 0 < n) (han : monoid.pow a n = 1) : ord a ≤ n :=\nnat.find_min' (exists_nat_pow_eq_one_of_finite_cycle a) ⟨ha0, han⟩\n\nlemma lt_ord {a : α} [fintype (cycle a)] {n : ℕ} (hn : n < ord a) : n = 0 ∨ monoid.pow a n ≠ 1 :=\nhave h : ¬0 < n ∨ ¬ monoid.pow a n = 1 := (decidable.not_and_iff_or_not _ _).1 (nat.find_min\n(exists_nat_pow_eq_one_of_finite_cycle a) hn), by rwa [nat.pos_iff_ne_zero', not_not] at h\n\nlemma ord_dvd_int_iff (i : ℤ) : (ord a : ℤ) ∣ i ↔ a^i = 1 :=\n⟨λ h₁, let ⟨k, hk⟩ := exists_eq_mul_right_of_dvd h₁ in by simp [hk, gpow_mul, pow_ord],\nλ h₁, by_contradiction $ λ h₂,\nbegin \n  rw int.dvd_iff_mod_eq_zero at h₂,\n  have h₃ : gpow a (i % ↑(ord a)) = 1,\n  { rw ← int.mod_add_div i (ord a) at h₁,\n    simp [gpow_add, gpow_mul] at h₁,\n    exact h₁ },\n  have hzc := int.coe_nat_ne_zero.2 (ne_of_lt (ord_pos a)).symm,\n  have h₄ : (int.nat_abs (i % ord a) : ℤ) = (i % ord a) := \n    int.nat_abs_of_nonneg (int.mod_nonneg _ hzc),\n  have h₅ : monoid.pow a (int.nat_abs (i % ↑(ord a))) = 1 := by rwa [← gpow_coe_nat, h₄],\n  have h₆ : (ord a : ℤ) ≤ (i % ↑(ord a)) := by rw [← h₄, int.coe_nat_le];\n    exact ord_le (int.nat_abs_pos_of_ne_zero h₂) h₅,\n  have h₇ := int.mod_lt i hzc,\n  rw abs_of_nonneg (int.coe_nat_le.2 (nat.zero_le _)) at h₇,\n  exact not_le_of_gt h₇ h₆,\nend⟩\n\nlemma ord_dvd_nat_iff (n : ℕ) : ord a ∣ n ↔ monoid.pow a n = 1 :=\nlet h := ord_dvd_int_iff a n in by simp [int.coe_nat_dvd] at h; assumption\n\nlemma fintype_cycle_of_pow_eq_one (i : ℤ) (a : α) (hi : i ≠ 0) (h : a^i = 1) : fintype (cycle a) :=\nfintype.of_surjective\n(λ n : fin (int.nat_abs i), (⟨monoid.pow a n.val, n.val, by simp⟩ : cycle a)) $\nλ ⟨b, j, hj⟩, have hji : 0 ≤ j % i := int.mod_nonneg _ hi,\n⟨⟨int.nat_abs (j % i), \nby rw [← int.coe_nat_lt, int.nat_abs_of_nonneg hji, ← int.abs_eq_nat_abs];\nexact int.mod_lt _ hi⟩, \nsubtype.eq $ show monoid.pow a (int.nat_abs (j % i)) = b,\nby rw [← gpow_coe_nat, int.nat_abs_of_nonneg hji, int.mod_def, sub_eq_add_neg, \n    gpow_add, gpow_neg, gpow_mul, h, hj]; simp⟩\n\n-- lemma ord_eq_cycle_card (a : α) [fintype (cycle a)] : ord a = card (cycle a) :=\n-- card_fin (ord a) ▸ card_congr\n-- ⟨λ (n : fin (ord a)), (⟨monoid.pow a n.val, ⟨n.val, by simp⟩⟩ : cycle a),\n-- λ ⟨b, hb⟩, have ho : (0 : ℤ) < ord a := int.coe_nat_lt.2 (ord_pos a),\n-- have h₁ : classical.some hb % ↑(ord a) ≥ 0 := int.mod_nonneg _ (ne_of_lt ho).symm,\n-- ⟨int.nat_abs (classical.some hb % (ord a : ℤ)),\n-- int.coe_nat_lt.1 ((int.nat_abs_of_nonneg h₁).symm ▸ int.mod_lt_of_pos _ ho)⟩,\n-- λ ⟨n, hn⟩, begin cases lt_ord hn with h h,\n-- simp [h],\n--  end,sorry⟩\n\n-- too long\n\nlemma ord_eq_cycle_card (a : α) [fintype (cycle a)] : ord a = fintype.card (cycle a) :=\nfintype.card_fin (ord a) ▸ (fintype.card_congr $ equiv.of_bijective $ \nshow function.bijective (λ (n : fin (ord a)), (⟨monoid.pow a n.val, ⟨n.val, by simp⟩⟩ : cycle a)), from\n⟨λ n m h, fin.eq_of_veq $ --injective proof\nbegin\n  cases n with n hn,\n  cases m with m hm,\n  wlog h : m ≤ n using m n,\n  { exact (this hm hn h_1.symm).symm },\n  replace h_1 : monoid.pow a n = monoid.pow a m := subtype.mk.inj h_1,\n  rw [← nat.sub_add_cancel h, ← one_mul (monoid.pow a m), pow_add, mul_right_inj] at h_1,\n  have h₁ := or.neg_resolve_right (lt_ord (lt_of_le_of_lt (nat.sub_le n m) hn)) h_1,\n  exact le_antisymm (nat.sub_eq_zero_iff_le.1 (or.neg_resolve_right (lt_ord \n    (lt_of_le_of_lt (nat.sub_le n m) hn)) h_1)) h,\nend, λ ⟨x, ⟨i, hi⟩ ⟩, -- surjective proof\nhave ho : (ord a : ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (ne_of_lt (ord_pos _)).symm,\nhave hio : (int.to_nat (i % ↑(ord a)) : ℤ) = i % ord a := int.to_nat_of_nonneg (int.mod_nonneg _ ho),\n⟨⟨int.to_nat (i % (ord a : ℤ)), int.coe_nat_lt.1 $ \nby rw [hio, ← abs_of_nonneg (int.coe_nat_le.2 (nat.zero_le (ord a))), int.mod_abs];\nexact int.mod_lt _ ho⟩,\nbegin\n  simp,\n  rw [← gpow_coe_nat, hio, int.mod_def],\n  simp [gpow_add, gpow_mul, gpow_neg, hi]\nend⟩⟩)\n#print ord_eq_cycle_card\nend cyclic\n\nsection coset\n\nopen subgroup\n\nvariables {α : Type*} [group α] (S : set α) [subgroup S]\n\ndef lcoset (b : α) := {a : α | ∃ s ∈ S, b * s = a}\n\ndef rcoset (b : α) := {a : α | ∃ s ∈ S, s * b = a}\n\nlemma lcoset_eq {S : set α} [subgroup S] {a b : α} : b ∈ lcoset S a → lcoset S a = lcoset S b :=\nλ ⟨sa, hSsa, hsa⟩, set.ext $ λ x, \n⟨λ ⟨sb, hSsb, hsb⟩, ⟨sa⁻¹ * sb, ⟨mul_mem (inv_mem hSsa) hSsb, hsa ▸ by simpa [mul_assoc] ⟩ ⟩,\nλ ⟨sb, hSsb, hsb⟩, ⟨sa * sb, ⟨mul_mem hSsa hSsb, mul_assoc a sa sb ▸ hsa.symm ▸ hsb ⟩ ⟩ ⟩ \n\nlemma rcoset_eq {S : set α} [subgroup S] {a b : α} : b ∈ rcoset S a → rcoset S a = rcoset S b :=\nλ ⟨sa, hSsa, hsa⟩, set.ext $ λ x, \n⟨λ ⟨sb, hSsb, hsb⟩, ⟨sb * sa⁻¹, ⟨mul_mem hSsb (inv_mem hSsa), hsa ▸ by simpa [mul_assoc] ⟩ ⟩,\nλ ⟨sb, hSsb, hsb⟩, ⟨sb * sa, ⟨mul_mem hSsb hSsa, (mul_assoc sb sa a).symm ▸ hsa.symm ▸ hsb ⟩ ⟩ ⟩ \n\n@[simp] lemma mem_lcoset_self (a : α) : a ∈ lcoset S a := ⟨1, one_mem _, mul_one _⟩\n\n@[simp] lemma mem_rcoset_self (a : α) : a ∈ rcoset S a := ⟨1, one_mem _, one_mul _⟩\n\nlemma lcoset_card [fintype α] (a : α) : card (lcoset S a) = fintype.card S :=\nfintype.card_congr $ @equiv.of_bijective (lcoset S a) S \n(λ x, ⟨a⁻¹ * x, let ⟨y, hyS, (hy : a * y = x)⟩ := x.2 in by rwa ← hy; simpa⟩) \n⟨λ x y h, by simp at h; exact subtype.eq h, λ x, ⟨ ⟨a * x, ⟨x, ⟨x.2, rfl⟩ ⟩ ⟩, by simp ⟩ ⟩\n\nlemma rcoset_card [fintype α] (a : α) : card (rcoset S a) = fintype.card S :=\nfintype.card_congr $ @equiv.of_bijective (rcoset S a) S \n(λ x, ⟨x * a⁻¹, let ⟨y, hyS, (hy : y *  a = x)⟩ := x.2 in by rwa ← hy; simpa⟩) \n⟨λ x y h, by simp at h; exact subtype.eq h, λ x, ⟨ ⟨x * a, ⟨x, ⟨x.2, rfl⟩ ⟩ ⟩, by simp ⟩ ⟩\n\ninstance lcoset_setoid : setoid α := \n{ r := λ a b, b ∈ lcoset S a,\n  iseqv := ⟨mem_lcoset_self S,\n  λ a b h, by rw ← lcoset_eq h; exact mem_lcoset_self S a,\n  λ a b c hab hbc, by rwa lcoset_eq hab⟩ }\n\ndef index [fintype α] := card (quotient (lcoset_setoid S))\n\ntheorem lagrange [fintype α] : card α = card S * index S :=\nhave h : (λ x : quotient (lcoset_setoid S), card {a // ⟦a⟧ = x}) = (λ x, card S) := \n  funext (λ x, begin\n    simp only [@eq_comm _ _ x],\n    rw [← quot.out_eq x, ← lcoset_card S (quot.out x)],\n    congr,\n    exact set.ext (λ y, quotient.eq)\n  end),\nby rw [card_quotient (lcoset_setoid S), h, finset.sum_const, nat.smul_eq_mul]; refl\n\nend coset\n\nlemma card_eq_ord_mul_index {α : Type*} [group α] [fintype α] (a : α) : card α = ord a * index (cycle a) :=\n(ord_eq_cycle_card a).symm ▸ lagrange _\n\n@[simp] lemma pow_card {α : Type*} [group α] [fintype α] (a : α) : monoid.pow a (card α) = 1 :=\n(ord_dvd_nat_iff _ _).1 $ (card_eq_ord_mul_index a).symm ▸ dvd_mul_right _ _\n\nopen equiv\n\nnamespace perm\nvariables {α : Type*}\n\nlemma mul_apply (a b : perm α) (x : α) : (a * b) x = (a (b x)) := rfl\n\n@[simp] lemma one_apply (x : α) : (1 : perm α) x = x := rfl\n\ninstance [decidable_eq α] (h : fintype α): fintype (perm α) := \nfintype.of_equiv {y : (α → α) × (α → α) // function.left_inverse y.2 y.1 ∧ function.right_inverse y.2 y.1}\n⟨λ x, ⟨x.1.1, x.1.2, x.2.1, x.2.2⟩, λ x, ⟨⟨x.1, x.2⟩, ⟨x.3, x.4⟩⟩, λ ⟨⟨_, _⟩, _, _⟩, rfl, λ ⟨_, _, _, _⟩, rfl⟩\n\ninstance perm.cycle.fintype [h : fintype α] (a : perm α) : fintype (cycle a) := @cycle.fintype (perm α) _ (perm.fintype h) a\n\ndef support (a : perm α) : set α := {x : α | a x ≠ x}\n\nexample (f g : perm α) : support (g * f * g⁻¹) = set.image g (support f) :=\nset.ext $ λ y, ⟨λ h : _ ≠ _, ⟨g⁻¹ y, λ h₁, by\n  rw [mul_apply, mul_apply, h₁, ← mul_apply, mul_inv_self] at h;\n  exact h rfl,\nshow (g * g⁻¹) y = y,by rw mul_inv_self; refl⟩, \nλ ⟨x, (hx : _ ≠ _ ∧ _)⟩, show _ ≠ _, from\nbegin \n  rw [mul_apply, ← hx.2, ← mul_apply, ← mul_apply, mul_assoc, inv_mul_self, mul_one, mul_apply], \n  assume h,\n  rw (equiv.bijective g).1 h at hx,\n  exact hx.1 rfl\nend⟩\n\ndef disjoint (a b : perm α) := _root_.disjoint (support a) (support b)\n\nlemma disjoint_or {a b : perm α} : disjoint a b ↔ ∀ x : α, a x = x ∨ b x = x :=\nhave h : disjoint a b ↔ ∀ x : α, ¬ (a x ≠ x ∧ b x ≠ x) := \n  ⟨λ (h : (λ x, a x ≠ x ∧ b x ≠ x : set α) = ∅) x, \n  show x ∉ {x : α | a x ≠ x ∧ b x ≠ x}, by rw h; simp, \nλ h, set.ext $ λ x, ⟨λ h₁, absurd h₁ (h x), λ h₁, absurd h₁ (set.not_mem_empty _)⟩⟩,\nby rw h; simp only [or_iff_not_and_not]\n\nlemma disjoint_comm {a b : perm α} (hd : disjoint a b) : a * b = b * a := \nequiv.ext _ _ $ λ x, show a (b x) = b (a x), from or.by_cases (disjoint_or.1 hd x) \n(λ h, h.symm ▸ or.by_cases (disjoint_or.1 hd $ b x) (λ h₁, h₁) (λ h₁, ((equiv.bijective b).1 h₁).symm ▸ h))\n(λ h, h.symm ▸ or.by_cases (disjoint_or.1 hd $ a x) (λ h₁, ((equiv.bijective a).1 h₁.symm) ▸ h.symm) (λ h₁, h₁.symm))\n\nlemma eq_one_of_support_eq_empty {a : perm α} [fintype (support a)] (h : support a = ∅) : a = 1 :=\next _ _ $ λ x, have hx : x ∉ support a := h.symm ▸ set.not_mem_empty x, not_not.1 hx\n\nlemma exists_mem_support_of_ne_one {a : perm α} (h : a ≠ 1) : ∃ x : α, x ∈ support a :=\nby_contradiction $ λ h₁, h $ ext _ _ $ by simp [support, *] at *\n\ndef same_cycle (a : perm α) (x y : α) := ∃ i : ℤ, (a^i) x = y\n\n@[refl] lemma same_cycle.refl {a : perm α} (x : α) : same_cycle a x x := ⟨0, by rw gpow_zero; refl⟩\n\n@[symm] lemma same_cycle.symm {a : perm α} {x y : α} (h : same_cycle a x y) : same_cycle a y x :=\nlet ⟨i, hi⟩ := h in ⟨-i, by rw [← hi, ←mul_apply, ← gpow_add, neg_add_self, gpow_zero, one_apply] ⟩ \n\n@[trans] lemma same_cycle.trans {a : perm α} {x y z : α} (hxy : same_cycle a x y) (hyz : same_cycle a y z)\n    : same_cycle a x z :=\nlet ⟨i, hi⟩ := hxy in let ⟨j, hj⟩ := hyz in ⟨j + i, begin rw [gpow_add, mul_apply, hi], simp [hi, hj] end⟩\n\nlemma same_cycle_apply {a : perm α} {x y : α} (h : same_cycle a x y) (i : ℤ) : same_cycle a ((a^i) x) y :=\nsame_cycle.trans (same_cycle.symm (⟨i, rfl⟩ : same_cycle a x ((a^i) x))) h\n\ndef cycle_of (a : perm α) (x : α) : perm α :=\n{ to_fun   := λ y, ite (same_cycle a x y) (a y) y,\n  inv_fun  := λ y, ite (same_cycle a x y) (a⁻¹ y) y,\n  left_inv := λ y, dite (same_cycle a x y)\n  (λ h, have h₁ : same_cycle a x (a y) := same_cycle.symm (same_cycle_apply (same_cycle.symm h) 1), \n    by simp [h, h₁]; rw [← mul_apply, inv_mul_self, one_apply]) \n  (λ h, by simp [h]),\n  right_inv := λ y, dite (same_cycle a x y) \n  (λ h, have h₁ : same_cycle a x (a⁻¹ y) := same_cycle.symm (same_cycle_apply (same_cycle.symm h) (-1)),\n    by simp [h, h₁]; rw [← mul_apply, mul_inv_self, one_apply]) \n  (λ h, by simp [h]) }\n\ndef is_cycle (a : perm α) := a ≠ 1 ∧ ∀ x y : α, x ∈ support a → y ∈ support a → same_cycle a x y\n\nlemma support_disjoint_mul {a b : perm α} (h : disjoint a b) : support (a * b) = support a ∪ support b :=\nset.ext $ λ x, or.by_cases (disjoint_or.1 h x) \n(λ h₁, ⟨λ h₂, or.inr (have h₂ : b (a x) ≠ x := by rw disjoint_comm h at h₂; exact h₂, by rw h₁ at h₂; exact h₂),\nλ h₂, by rw disjoint_comm h; exact show b (a x) ≠ x, by rw h₁; exact or.resolve_left h₂ (not_not.2 h₁)⟩) \n(λ h₁, ⟨λ (h₂ : a (b x) ≠ x), or.inl $ by rw h₁ at h₂; exact h₂,\nλ h₂, show a (b x) ≠ x, by rw h₁; exact or.resolve_right h₂ (not_not.2 h₁)⟩)\n\nlemma exists_disjoint_factors [fintype α] (a : perm α) (h : ¬ is_cycle a) (h₁ : a ≠ 1) :\n    ∃ b c : perm α, disjoint b c ∧ b * c = a ∧ card (support b) < card (support a) ∧ \n    card (support c) < card (support a) :=\nbegin\n  suffices : ∀ (n : ℕ) (a : perm α), ¬ is_cycle a → a ≠ 1 → card (support a) ≤ n → \n      ∃ b c : perm α, disjoint b c ∧ b * c = a ∧ card (support b) < card (support a) ∧ \n      card (support c) < card (support a),\n  exact this (card (support a)) a h h₁ (le_refl _),\n  assume n,\n  induction n with n hi,\n  { assume a h h₁ h₂,\n    exact absurd (eq_one_of_support_eq_empty (set.card_eq_zero.1 (nat.eq_zero_of_le_zero h₂))) h₁ },\n  { assume a h h₁ h₂,\n    cases exists_mem_support_of_ne_one h₁ with x hx,\n    \n     }\nend\n\n-- lemma product_disjoint [fintype α] (a : perm α) : ∃ l : list (perm α), (∀ b ∈ l, is_cycle b ∧ b ≠ 1) ∧ (∀ b c ∈ l, disjoint b c) ∧ list.prod l = a :=\n-- begin\n--   suffices : ∀ (n : ℕ) (a : perm α), ord a ≤ n → ∃ l : list (perm α), (∀ b ∈ l, is_cycle b ∧ b ≠ 1) ∧ (∀ b c ∈ l, disjoint b c) ∧ list.prod l = a,\n--   { exact this (ord a) a (le_refl _) },\n--   assume n,\n--   induction n with n hi,\n--   { exact λ a ha, absurd (lt_of_lt_of_le (ord_pos a) ha) dec_trivial },\n--   assume a ha,\n\n\n-- end\n\nend perm", "meta": {"author": "ChrisHughes24", "repo": "leanstuff", "sha": "9efa85f72efaccd1d540385952a6acc18fce8687", "save_path": "github-repos/lean/ChrisHughes24-leanstuff", "path": "github-repos/lean/ChrisHughes24-leanstuff/leanstuff-9efa85f72efaccd1d540385952a6acc18fce8687/gourp1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.47694453774149526}}
{"text": "inductive Palindrome : List α → Prop where\n  | nil      : Palindrome []\n  | single   : (a : α) → Palindrome [a]\n  | sandwish : (a : α) → Palindrome as → Palindrome ([a] ++ as ++ [a])\n\ntheorem palindrome_reverse (h : Palindrome as) : Palindrome as.reverse := by\n  induction h with\n  | nil => done\n  | single a => exact Palindrome.single a\n  | sandwish a h ih => simp; exact Palindrome.sandwish _ ih\n\n#check palindrome_reverse\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/autoImplicitChainNameIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.4769445339862193}}
{"text": "import tactic\n\nvariable { T : Type}\n\nlemma singleton_eq_append_implies_empty (a b: list T) (c d : T) : ([d] = a ++ [c] ++ b) → (a = [] ∧ b = [] ∧ c=d) := by\n  {\n    intro h,\n    have h1 : a=[] := by\n    {\n      rw [←list.length_eq_zero, ←le_zero_iff],\n      apply_fun list.length at h,\n      simp only [list.length_append, list.length_singleton, list.append_assoc, list.singleton_append] at h,\n      apply le_of_add_le_add_right,\n      rw [←h],\n      simp,\n    },\n    have h2 : b=[] := by\n    {\n      simp [h1] at h,\n      rw [eq_comm],\n      exact and.elim_right h,\n    },\n    have h3 : c=d := by\n    {\n      simp [h1, h2] at h,\n      simp [eq_comm, h],\n    },\n    exact and.intro h1 (and.intro h2 h3),\n  }", "meta": {"author": "Ramneet-Singh", "repo": "CfgCert", "sha": "b139987de989b3c1333b0d3f9e90ad48c9f6ead8", "save_path": "github-repos/lean/Ramneet-Singh-CfgCert", "path": "github-repos/lean/Ramneet-Singh-CfgCert/CfgCert-b139987de989b3c1333b0d3f9e90ad48c9f6ead8/src/Utils.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.47694453313279556}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Zhouhang Zhou, Yury Kudryashov\n-/\n\nimport measure_theory.function.l1_space\nimport analysis.normed_space.indicator_function\n\n/-! # Functions integrable on a set and at a filter\n\nWe define `integrable_on f s μ := integrable f (μ.restrict s)` and prove theorems like\n`integrable_on_union : integrable_on f (s ∪ t) μ ↔ integrable_on f s μ ∧ integrable_on f t μ`.\n\nNext we define a predicate `integrable_at_filter (f : α → E) (l : filter α) (μ : measure α)`\nsaying that `f` is integrable at some set `s ∈ l` and prove that a measurable function is integrable\nat `l` with respect to `μ` provided that `f` is bounded above at `l ⊓ μ.ae` and `μ` is finite\nat `l`.\n\n-/\n\nnoncomputable theory\nopen set filter topological_space measure_theory function\nopen_locale classical topological_space interval big_operators filter ennreal measure_theory\n\nvariables {α β E F : Type*} [measurable_space α]\n\nsection\n\nvariables [topological_space β] {l l' : filter α} {f g : α → β} {μ ν : measure α}\n\n/-- A function `f` is strongly measurable at a filter `l` w.r.t. a measure `μ` if it is\nae strongly measurable w.r.t. `μ.restrict s` for some `s ∈ l`. -/\ndef strongly_measurable_at_filter (f : α → β) (l : filter α) (μ : measure α . volume_tac) :=\n∃ s ∈ l, ae_strongly_measurable f (μ.restrict s)\n\n@[simp] lemma strongly_measurable_at_bot {f : α → β} : strongly_measurable_at_filter f ⊥ μ :=\n⟨∅, mem_bot, by simp⟩\n\nprotected lemma strongly_measurable_at_filter.eventually (h : strongly_measurable_at_filter f l μ) :\n  ∀ᶠ s in l.lift' powerset, ae_strongly_measurable f (μ.restrict s) :=\n(eventually_lift'_powerset' $ λ s t, ae_strongly_measurable.mono_set).2 h\n\nprotected lemma strongly_measurable_at_filter.filter_mono\n  (h : strongly_measurable_at_filter f l μ) (h' : l' ≤ l) :\n  strongly_measurable_at_filter f l' μ :=\nlet ⟨s, hsl, hs⟩ := h in ⟨s, h' hsl, hs⟩\n\nprotected lemma measure_theory.ae_strongly_measurable.strongly_measurable_at_filter\n  (h : ae_strongly_measurable f μ) :\n  strongly_measurable_at_filter f l μ :=\n⟨univ, univ_mem, by rwa measure.restrict_univ⟩\n\nlemma ae_strongly_measurable.strongly_measurable_at_filter_of_mem\n  {s} (h : ae_strongly_measurable f (μ.restrict s)) (hl : s ∈ l) :\n  strongly_measurable_at_filter f l μ :=\n⟨s, hl, h⟩\n\nprotected lemma measure_theory.strongly_measurable.strongly_measurable_at_filter\n  (h : strongly_measurable f) :\n  strongly_measurable_at_filter f l μ :=\nh.ae_strongly_measurable.strongly_measurable_at_filter\n\nend\n\nnamespace measure_theory\n\nsection normed_group\n\nlemma has_finite_integral_restrict_of_bounded [normed_group E] {f : α → E} {s : set α}\n  {μ : measure α} {C}  (hs : μ s < ∞) (hf : ∀ᵐ x ∂(μ.restrict s), ∥f x∥ ≤ C) :\n  has_finite_integral f (μ.restrict s) :=\nby haveI : is_finite_measure (μ.restrict s) := ⟨by rwa [measure.restrict_apply_univ]⟩;\n  exact has_finite_integral_of_bounded hf\n\nvariables [normed_group E] {f g : α → E} {s t : set α} {μ ν : measure α}\n\n/-- A function is `integrable_on` a set `s` if it is almost everywhere strongly measurable on `s`\nand if the integral of its pointwise norm over `s` is less than infinity. -/\ndef integrable_on (f : α → E) (s : set α) (μ : measure α . volume_tac) : Prop :=\nintegrable f (μ.restrict s)\n\nlemma integrable_on.integrable (h : integrable_on f s μ) :\n  integrable f (μ.restrict s) := h\n\n@[simp] lemma integrable_on_empty : integrable_on f ∅ μ :=\nby simp [integrable_on, integrable_zero_measure]\n\n@[simp] lemma integrable_on_univ : integrable_on f univ μ ↔ integrable f μ :=\nby rw [integrable_on, measure.restrict_univ]\n\nlemma integrable_on_zero : integrable_on (λ _, (0:E)) s μ := integrable_zero _ _ _\n\n@[simp] lemma integrable_on_const {C : E} : integrable_on (λ _, C) s μ ↔ C = 0 ∨ μ s < ∞ :=\nintegrable_const_iff.trans $ by rw [measure.restrict_apply_univ]\n\nlemma integrable_on.mono (h : integrable_on f t ν) (hs : s ⊆ t) (hμ : μ ≤ ν) :\n  integrable_on f s μ :=\nh.mono_measure $ measure.restrict_mono hs hμ\n\nlemma integrable_on.mono_set (h : integrable_on f t μ) (hst : s ⊆ t) :\n  integrable_on f s μ :=\nh.mono hst le_rfl\n\nlemma integrable_on.mono_measure (h : integrable_on f s ν) (hμ : μ ≤ ν) :\n  integrable_on f s μ :=\nh.mono (subset.refl _) hμ\n\nlemma integrable_on.mono_set_ae (h : integrable_on f t μ) (hst : s ≤ᵐ[μ] t) :\n  integrable_on f s μ :=\nh.integrable.mono_measure $ measure.restrict_mono_ae hst\n\nlemma integrable_on.congr_set_ae (h : integrable_on f t μ) (hst : s =ᵐ[μ] t) :\n  integrable_on f s μ :=\nh.mono_set_ae hst.le\n\nlemma integrable_on.congr_fun' (h : integrable_on f s μ) (hst : f =ᵐ[μ.restrict s] g) :\n  integrable_on g s μ :=\nintegrable.congr h hst\n\nlemma integrable_on.congr_fun (h : integrable_on f s μ) (hst : eq_on f g s)\n  (hs : measurable_set s) :\n  integrable_on g s μ :=\nh.congr_fun' ((ae_restrict_iff' hs).2 (eventually_of_forall hst))\n\nlemma integrable.integrable_on (h : integrable f μ) : integrable_on f s μ :=\nh.mono_measure $ measure.restrict_le_self\n\nlemma integrable.integrable_on' (h : integrable f (μ.restrict s)) : integrable_on f s μ :=\nh\n\nlemma integrable_on.restrict (h : integrable_on f s μ) (hs : measurable_set s) :\n  integrable_on f s (μ.restrict t) :=\nby { rw [integrable_on, measure.restrict_restrict hs], exact h.mono_set (inter_subset_left _ _) }\n\nlemma integrable_on.left_of_union (h : integrable_on f (s ∪ t) μ) : integrable_on f s μ :=\nh.mono_set $ subset_union_left _ _\n\nlemma integrable_on.right_of_union (h : integrable_on f (s ∪ t) μ) : integrable_on f t μ :=\nh.mono_set $ subset_union_right _ _\n\nlemma integrable_on.union (hs : integrable_on f s μ) (ht : integrable_on f t μ) :\n  integrable_on f (s ∪ t) μ :=\n(hs.add_measure ht).mono_measure $ measure.restrict_union_le _ _\n\n@[simp] lemma integrable_on_union :\n  integrable_on f (s ∪ t) μ ↔ integrable_on f s μ ∧ integrable_on f t μ :=\n⟨λ h, ⟨h.left_of_union, h.right_of_union⟩, λ h, h.1.union h.2⟩\n\n@[simp] lemma integrable_on_singleton_iff {x : α} [measurable_singleton_class α] :\n  integrable_on f {x} μ ↔ f x = 0 ∨ μ {x} < ∞ :=\nbegin\n  have : f =ᵐ[μ.restrict {x}] (λ y, f x),\n  { filter_upwards [ae_restrict_mem (measurable_set_singleton x)] with _ ha,\n    simp only [mem_singleton_iff.1 ha], },\n  rw [integrable_on, integrable_congr this, integrable_const_iff],\n  simp,\nend\n\n@[simp] lemma integrable_on_finite_Union {s : set β} (hs : finite s)\n  {t : β → set α} : integrable_on f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, integrable_on f (t i) μ :=\nbegin\n  apply hs.induction_on,\n  { simp },\n  { intros a s ha hs hf, simp [hf, or_imp_distrib, forall_and_distrib] }\nend\n\n@[simp] lemma integrable_on_finset_Union {s : finset β} {t : β → set α} :\n  integrable_on f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, integrable_on f (t i) μ :=\nintegrable_on_finite_Union s.finite_to_set\n\n@[simp] lemma integrable_on_fintype_Union [fintype β] {t : β → set α} :\n  integrable_on f (⋃ i, t i) μ ↔ ∀ i, integrable_on f (t i) μ :=\nby simpa using @integrable_on_finset_Union _ _ _ _ _ f μ finset.univ t\n\nlemma integrable_on.add_measure (hμ : integrable_on f s μ) (hν : integrable_on f s ν) :\n  integrable_on f s (μ + ν) :=\nby { delta integrable_on, rw measure.restrict_add, exact hμ.integrable.add_measure hν }\n\n@[simp] lemma integrable_on_add_measure :\n  integrable_on f s (μ + ν) ↔ integrable_on f s μ ∧ integrable_on f s ν :=\n⟨λ h, ⟨h.mono_measure (measure.le_add_right le_rfl),\n  h.mono_measure (measure.le_add_left le_rfl)⟩,\n  λ h, h.1.add_measure h.2⟩\n\nlemma _root_.measurable_embedding.integrable_on_map_iff [measurable_space β] {e : α → β}\n  (he : measurable_embedding e) {f : β → E} {μ : measure α} {s : set β} :\n  integrable_on f s (measure.map e μ) ↔ integrable_on (f ∘ e) (e ⁻¹' s) μ :=\nby simp only [integrable_on, he.restrict_map, he.integrable_map_iff]\n\nlemma integrable_on_map_equiv [measurable_space β] (e : α ≃ᵐ β) {f : β → E} {μ : measure α}\n  {s : set β} :\n  integrable_on f s (measure.map e μ) ↔ integrable_on (f ∘ e) (e ⁻¹' s) μ :=\nby simp only [integrable_on, e.restrict_map, integrable_map_equiv e]\n\nlemma measure_preserving.integrable_on_comp_preimage [measurable_space β] {e : α → β} {ν}\n  (h₁ : measure_preserving e μ ν) (h₂ : measurable_embedding e) {f : β → E} {s : set β} :\n  integrable_on (f ∘ e) (e ⁻¹' s) μ ↔ integrable_on f s ν :=\n(h₁.restrict_preimage_emb h₂ s).integrable_comp_emb h₂\n\nlemma measure_preserving.integrable_on_image [measurable_space β] {e : α → β} {ν}\n  (h₁ : measure_preserving e μ ν) (h₂ : measurable_embedding e) {f : β → E} {s : set α} :\n  integrable_on f (e '' s) ν ↔  integrable_on (f ∘ e) s μ :=\n((h₁.restrict_image_emb h₂ s).integrable_comp_emb h₂).symm\n\nlemma integrable_indicator_iff (hs : measurable_set s) :\n  integrable (indicator s f) μ ↔ integrable_on f s μ :=\nby simp [integrable_on, integrable, has_finite_integral, nnnorm_indicator_eq_indicator_nnnorm,\n  ennreal.coe_indicator, lintegral_indicator _ hs, ae_strongly_measurable_indicator_iff hs]\n\nlemma integrable_on.indicator (h : integrable_on f s μ) (hs : measurable_set s) :\n  integrable (indicator s f) μ :=\n(integrable_indicator_iff hs).2 h\n\nlemma integrable.indicator (h : integrable f μ) (hs : measurable_set s) :\n  integrable (indicator s f) μ :=\nh.integrable_on.indicator hs\n\nlemma integrable_indicator_const_Lp {E} [normed_group E]\n  {p : ℝ≥0∞} {s : set α} (hs : measurable_set s) (hμs : μ s ≠ ∞) (c : E) :\n  integrable (indicator_const_Lp p hs hμs c) μ :=\nbegin\n  rw [integrable_congr indicator_const_Lp_coe_fn, integrable_indicator_iff hs, integrable_on,\n    integrable_const_iff, lt_top_iff_ne_top],\n  right,\n  simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply] using hμs,\nend\n\nlemma integrable_on_iff_integable_of_support_subset {f : α → E} {s : set α}\n  (h1s : support f ⊆ s) (h2s : measurable_set s) :\n  integrable_on f s μ ↔ integrable f μ :=\nbegin\n  refine ⟨λ h, _, λ h, h.integrable_on⟩,\n  rwa [← indicator_eq_self.2 h1s, integrable_indicator_iff h2s]\nend\n\nlemma integrable_on_Lp_of_measure_ne_top {E} [normed_group E]\n  {p : ℝ≥0∞} {s : set α} (f : Lp E p μ) (hp : 1 ≤ p) (hμs : μ s ≠ ∞) :\n  integrable_on f s μ :=\nbegin\n  refine mem_ℒp_one_iff_integrable.mp _,\n  have hμ_restrict_univ : (μ.restrict s) set.univ < ∞,\n    by simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply, lt_top_iff_ne_top],\n  haveI hμ_finite : is_finite_measure (μ.restrict s) := ⟨hμ_restrict_univ⟩,\n  exact ((Lp.mem_ℒp _).restrict s).mem_ℒp_of_exponent_le hp,\nend\n\n/-- We say that a function `f` is *integrable at filter* `l` if it is integrable on some\nset `s ∈ l`. Equivalently, it is eventually integrable on `s` in `l.lift' powerset`. -/\ndef integrable_at_filter (f : α → E) (l : filter α) (μ : measure α . volume_tac) :=\n∃ s ∈ l, integrable_on f s μ\n\nvariables {l l' : filter α}\n\nprotected lemma integrable_at_filter.eventually (h : integrable_at_filter f l μ) :\n  ∀ᶠ s in l.lift' powerset, integrable_on f s μ :=\nby { refine (eventually_lift'_powerset' $ λ s t hst ht, _).2 h, exact ht.mono_set hst }\n\nlemma integrable_at_filter.filter_mono (hl : l ≤ l') (hl' : integrable_at_filter f l' μ) :\n  integrable_at_filter f l μ :=\nlet ⟨s, hs, hsf⟩ := hl' in ⟨s, hl hs, hsf⟩\n\nlemma integrable_at_filter.inf_of_left (hl : integrable_at_filter f l μ) :\n  integrable_at_filter f (l ⊓ l') μ :=\nhl.filter_mono inf_le_left\n\nlemma integrable_at_filter.inf_of_right (hl : integrable_at_filter f l μ) :\n  integrable_at_filter f (l' ⊓ l) μ :=\nhl.filter_mono inf_le_right\n\n@[simp] lemma integrable_at_filter.inf_ae_iff {l : filter α} :\n  integrable_at_filter f (l ⊓ μ.ae) μ ↔ integrable_at_filter f l μ :=\nbegin\n  refine ⟨_, λ h, h.filter_mono inf_le_left⟩,\n  rintros ⟨s, ⟨t, ht, u, hu, rfl⟩, hf⟩,\n  refine ⟨t, ht, _⟩,\n  refine hf.integrable.mono_measure (λ v hv, _),\n  simp only [measure.restrict_apply hv],\n  refine measure_mono_ae (mem_of_superset hu $ λ x hx, _),\n  exact λ ⟨hv, ht⟩, ⟨hv, ⟨ht, hx⟩⟩\nend\n\nalias integrable_at_filter.inf_ae_iff ↔ measure_theory.integrable_at_filter.of_inf_ae _\n\n/-- If `μ` is a measure finite at filter `l` and `f` is a function such that its norm is bounded\nabove at `l`, then `f` is integrable at `l`. -/\nlemma measure.finite_at_filter.integrable_at_filter {l : filter α} [is_measurably_generated l]\n  (hfm : strongly_measurable_at_filter f l μ) (hμ : μ.finite_at_filter l)\n  (hf : l.is_bounded_under (≤) (norm ∘ f)) :\n  integrable_at_filter f l μ :=\nbegin\n  obtain ⟨C, hC⟩ : ∃ C, ∀ᶠ s in (l.lift' powerset), ∀ x ∈ s, ∥f x∥ ≤ C,\n    from hf.imp (λ C hC, eventually_lift'_powerset.2 ⟨_, hC, λ t, id⟩),\n  rcases (hfm.eventually.and (hμ.eventually.and hC)).exists_measurable_mem_of_lift'\n    with ⟨s, hsl, hsm, hfm, hμ, hC⟩,\n  refine ⟨s, hsl, ⟨hfm, has_finite_integral_restrict_of_bounded hμ _⟩⟩,\n  exact C,\n  rw [ae_restrict_eq hsm, eventually_inf_principal],\n  exact eventually_of_forall hC\nend\n\nlemma measure.finite_at_filter.integrable_at_filter_of_tendsto_ae\n  {l : filter α} [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l μ)\n  (hμ : μ.finite_at_filter l) {b} (hf : tendsto f (l ⊓ μ.ae) (𝓝 b)) :\n  integrable_at_filter f l μ :=\n(hμ.inf_of_left.integrable_at_filter (hfm.filter_mono inf_le_left)\n  hf.norm.is_bounded_under_le).of_inf_ae\n\nalias measure.finite_at_filter.integrable_at_filter_of_tendsto_ae ←\n  filter.tendsto.integrable_at_filter_ae\n\nlemma measure.finite_at_filter.integrable_at_filter_of_tendsto {l : filter α}\n  [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l μ)\n  (hμ : μ.finite_at_filter l) {b} (hf : tendsto f l (𝓝 b)) :\n  integrable_at_filter f l μ :=\nhμ.integrable_at_filter hfm hf.norm.is_bounded_under_le\n\nalias measure.finite_at_filter.integrable_at_filter_of_tendsto ← filter.tendsto.integrable_at_filter\n\nlemma integrable_add_of_disjoint {f g : α → E}\n  (h : disjoint (support f) (support g)) (hf : strongly_measurable f) (hg : strongly_measurable g) :\n  integrable (f + g) μ ↔ integrable f μ ∧ integrable g μ :=\nbegin\n  refine ⟨λ hfg, ⟨_, _⟩, λ h, h.1.add h.2⟩,\n  { rw ← indicator_add_eq_left h, exact hfg.indicator hf.measurable_set_support },\n  { rw ← indicator_add_eq_right h, exact hfg.indicator hg.measurable_set_support }\nend\n\nend normed_group\n\nend measure_theory\n\nopen measure_theory\n\nvariables [normed_group E]\n\n/-- A function which is continuous on a set `s` is almost everywhere measurable with respect to\n`μ.restrict s`. -/\nlemma continuous_on.ae_measurable [topological_space α] [opens_measurable_space α]\n  [measurable_space β] [topological_space β] [borel_space β]\n  {f : α → β} {s : set α} {μ : measure α} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_measurable f (μ.restrict s) :=\nbegin\n  nontriviality α, inhabit α,\n  have : piecewise s f (λ _, f default) =ᵐ[μ.restrict s] f := piecewise_ae_eq_restrict hs,\n  refine ⟨piecewise s f (λ _, f default), _, this.symm⟩,\n  apply measurable_of_is_open,\n  assume t ht,\n  obtain ⟨u, u_open, hu⟩ : ∃ (u : set α), is_open u ∧ f ⁻¹' t ∩ s = u ∩ s :=\n    _root_.continuous_on_iff'.1 hf t ht,\n  rw [piecewise_preimage, set.ite, hu],\n  exact (u_open.measurable_set.inter hs).union ((measurable_const ht.measurable_set).diff hs)\nend\n\n/-- A function which is continuous on a separable set `s` is almost everywhere strongly measurable\nwith respect to `μ.restrict s`. -/\nlemma continuous_on.ae_strongly_measurable_of_is_separable\n  [topological_space α] [metrizable_space α] [opens_measurable_space α]\n  [topological_space β] [metrizable_space β]\n  {f : α → β} {s : set α} {μ : measure α} (hf : continuous_on f s) (hs : measurable_set s)\n  (h's : topological_space.is_separable s) :\n  ae_strongly_measurable f (μ.restrict s) :=\nbegin\n  letI := metrizable_space_metric α,\n  borelize β,\n  rw ae_strongly_measurable_iff_ae_measurable_separable,\n  refine ⟨hf.ae_measurable hs, f '' s, hf.is_separable_image h's, _⟩,\n  exact mem_of_superset (self_mem_ae_restrict hs) (subset_preimage_image _ _),\nend\n\n/-- A function which is continuous on a set `s` is almost everywhere strongly measurable with\nrespect to `μ.restrict s` when either the source space or the target space is second-countable. -/\nlemma continuous_on.ae_strongly_measurable\n  [topological_space α] [topological_space β] [h : second_countable_topology_either α β]\n  [opens_measurable_space α] [metrizable_space β]\n  {f : α → β} {s : set α} {μ : measure α} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_strongly_measurable f (μ.restrict s) :=\nbegin\n  borelize β,\n  refine ae_strongly_measurable_iff_ae_measurable_separable.2 ⟨hf.ae_measurable hs, f '' s, _,\n    mem_of_superset (self_mem_ae_restrict hs) (subset_preimage_image _ _)⟩,\n  casesI h.out,\n  { let f' : s → β := s.restrict f,\n    have A : continuous f' := continuous_on_iff_continuous_restrict.1 hf,\n    have B : is_separable (univ : set s) := is_separable_of_separable_space _,\n    convert is_separable.image B A using 1,\n    ext x,\n    simp },\n  { exact is_separable_of_separable_space _ }\nend\n\nlemma continuous_on.integrable_at_nhds_within_of_is_separable\n  [topological_space α] [metrizable_space α]\n  [opens_measurable_space α] {μ : measure α} [is_locally_finite_measure μ]\n  {a : α} {t : set α} {f : α → E} (hft : continuous_on f t) (ht : measurable_set t)\n  (h't : topological_space.is_separable t) (ha : a ∈ t) :\n  integrable_at_filter f (𝓝[t] a) μ :=\nbegin\n  haveI : (𝓝[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter ⟨_, self_mem_nhds_within,\n    hft.ae_strongly_measurable_of_is_separable ht h't⟩ (μ.finite_at_nhds_within _ _),\nend\n\nlemma continuous_on.integrable_at_nhds_within\n  [topological_space α] [second_countable_topology_either α E]\n  [opens_measurable_space α] {μ : measure α} [is_locally_finite_measure μ]\n  {a : α} {t : set α} {f : α → E} (hft : continuous_on f t) (ht : measurable_set t) (ha : a ∈ t) :\n  integrable_at_filter f (𝓝[t] a) μ :=\nbegin\n  haveI : (𝓝[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter ⟨_, self_mem_nhds_within, hft.ae_strongly_measurable ht⟩\n    (μ.finite_at_nhds_within _ _),\nend\n\n/-- If a function is continuous on an open set `s`, then it is strongly measurable at the filter\n`𝓝 x` for all `x ∈ s` if either the source space or the target space is second-countable. -/\nlemma continuous_on.strongly_measurable_at_filter [topological_space α]\n  [opens_measurable_space α] [topological_space β] [metrizable_space β]\n  [second_countable_topology_either α β] {f : α → β} {s : set α} {μ : measure α}\n  (hs : is_open s) (hf : continuous_on f s) :\n  ∀ x ∈ s, strongly_measurable_at_filter f (𝓝 x) μ :=\nλ x hx, ⟨s, is_open.mem_nhds hs hx, hf.ae_strongly_measurable hs.measurable_set⟩\n\nlemma continuous_at.strongly_measurable_at_filter\n  [topological_space α] [opens_measurable_space α] [second_countable_topology_either α E]\n  {f : α → E} {s : set α} {μ : measure α} (hs : is_open s) (hf : ∀ x ∈ s, continuous_at f x) :\n  ∀ x ∈ s, strongly_measurable_at_filter f (𝓝 x) μ :=\ncontinuous_on.strongly_measurable_at_filter hs $ continuous_at.continuous_on hf\n\nlemma continuous.strongly_measurable_at_filter [topological_space α] [opens_measurable_space α]\n  [topological_space β] [metrizable_space β] [second_countable_topology_either α β]\n  {f : α → β} (hf : continuous f) (μ : measure α) (l : filter α) :\n  strongly_measurable_at_filter f l μ :=\nhf.strongly_measurable.strongly_measurable_at_filter\n\n/-- If a function is continuous on a measurable set `s`, then it is measurable at the filter\n  `𝓝[s] x` for all `x`. -/\nlemma continuous_on.strongly_measurable_at_filter_nhds_within {α β : Type*} [measurable_space α]\n  [topological_space α] [opens_measurable_space α] [topological_space β] [metrizable_space β]\n  [second_countable_topology_either α β] {f : α → β} {s : set α} {μ : measure α}\n  (hf : continuous_on f s) (hs : measurable_set s) (x : α) :\n  strongly_measurable_at_filter f (𝓝[s] x) μ :=\n⟨s, self_mem_nhds_within, hf.ae_strongly_measurable hs⟩\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/measure_theory/integral/integrable_on.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.7057850154599563, "lm_q1q2_score": 0.4769445293775197}}
{"text": "import analysis.calculus.conformal\nimport analysis.normed_space.banach\nimport analysis.normed_space.dual\nimport similarity\nimport bilin_form_lemmas\nimport analysis.calculus.times_cont_diff\nimport analysis.calculus.fderiv_symmetric\n\nnoncomputable theory\n\nopen conformal_at set\nopen_locale classical real_inner_product_space filter topological_space\n\nsection quick\n\nlemma quick1 {F : Type*} [add_comm_group F] {a b c d e e' f : F} \n  (h : a + b + (c + d) + (e + f) = d + b + (c + a) + (e' + f)) : e = e' :=\nbegin\n  simp_rw [← add_assoc] at h,\n  rw [add_right_cancel_iff] at h,\n  nth_rewrite 1 add_comm at h,\n  simp_rw [← add_assoc] at h,\n  nth_rewrite 2 add_comm at h,\n  simp_rw [← add_assoc] at h,\n  nth_rewrite 3 add_comm at h,\n  nth_rewrite 4 add_assoc at h,\n  nth_rewrite 7 add_comm at h,\n  simpa [← add_assoc, add_left_cancel_iff] using h\nend\n\nend quick\n\nsection linear_conformal_prep\nopen submodule\n\nvariables {E F : Type*} [inner_product_space ℝ E] [inner_product_space ℝ F] {x : E}\n\nlemma eventually_is_conformal_map_of_eventually_conformal {f : E → F} \n  (hf : ∀ᶠ x' in 𝓝 x, conformal_at f x') : ∀ᶠ x' in 𝓝 x, is_conformal_map (fderiv ℝ f x') :=\nhf.mono (λ y hy, conformal_at_iff_is_conformal_map_fderiv.mp hy)\n\nlemma A {f' : E →L[ℝ] F} (h : is_conformal_map f') {u v : E} :\n  ⟪u, v⟫ = 0 ↔ ⟪f' u, f' v⟫ = 0 :=\nbegin\n  rcases (is_conformal_map_iff _).mp h with ⟨c, p, q⟩,\n  split,\n  { intros huv,\n    convert q u v,\n    rw [huv, mul_zero] },\n  { intros huv,\n    rw q u v at huv,\n    exact eq_zero_of_ne_zero_of_mul_left_eq_zero (ne_of_gt p) huv } \nend\n\nlemma A' {f' : E → (E →L[ℝ] F)} {u v : E} (huv : ⟪u, v⟫ = 0) \n  (h : ∀ᶠ x' in 𝓝 x, is_conformal_map $ f' x') :\n  (λ x, ⟪f' x u, f' x v⟫) =ᶠ[𝓝 x] λ x, (0 : ℝ) :=\nbegin\n  apply (filter.eventually_of_forall $ λ x, huv).mp,\n  simp only [congr_arg],\n  rcases filter.eventually_iff_exists_mem.mp h with ⟨s, hs, hys⟩,\n  exact filter.eventually_iff_exists_mem.mpr ⟨s, hs, λ y hy p, (A $ hys y hy).mp p⟩\nend\n\nlemma B {f' : E →L[ℝ] F} {K : submodule ℝ E} \n  (hf : function.surjective f') (h : is_conformal_map f') :\n  (Kᗮ).map (f' : E →ₗ[ℝ] F) = (K.map f')ᗮ :=\nbegin\n  ext1 y'',\n  simp only [mem_map, mem_orthogonal],\n  split,\n  { rintros ⟨u, hu, huy⟩,\n    intros v hv,\n    rcases hv with ⟨z, hz, hzv⟩,\n    rw [← huy, ← hzv, continuous_linear_map.coe_coe, ← A h],\n    exact hu z hz },\n  { intros H,\n    rcases hf y'' with ⟨y', hy'⟩,\n    refine ⟨y', λ u hu, _, hy'⟩,\n    rw [A h, hy'],\n    exact H (f' u) ⟨u, hu, rfl⟩ }\nend\n\nlemma C {f' : E →L[ℝ] F} (hf : function.surjective f') (h : is_conformal_map f') {u v : E} {w : F}\n  (H : ∀ (t : E), t ∈ (span ℝ ({u} ∪ {v} : set E))ᗮ → ⟪w, f' t⟫ = 0) :\n  w ∈ (span ℝ ({f' u} ∪ {f' v} : set F)) :=\nbegin\n  have triv₁ : {f' u} ∪ {f' v} = f' '' ({u} ∪ {v}) :=\n    by simp only [image_union, image_singleton],\n  rw [triv₁, ← continuous_linear_map.coe_coe, ← map_span],\n  have triv₂ : is_complete (span ℝ ({u} ∪ {v} : set E) : set E),\n  { haveI : finite_dimensional ℝ (span ℝ ({u} ∪ {v} : set E)) :=\n      finite_dimensional.span_of_finite ℝ ((finite_singleton _).union $ finite_singleton _),\n    exact complete_of_finite_dimensional _ },\n  haveI : complete_space (span ℝ ({u} ∪ {v} : set E)) := triv₂.complete_space_coe,\n  rw [← orthogonal_orthogonal (span ℝ ({u} ∪ {v} : set E)), B hf h, mem_orthogonal],\n  intros y hy,\n  rw [mem_map] at hy,\n  rcases hy with ⟨y', hy', Hy'⟩,\n  rw [real_inner_comm, ← Hy'],\n  exact H y' hy'\nend\n\nend linear_conformal_prep\n\nopen continuous_linear_map\nopen_locale topological_space filter\n\nsection diff_elementary\n\nlemma DD1 {E F : Type*} [normed_group E] [normed_space ℝ E] [normed_group F] [normed_space ℝ F] \n  {f : E → F} {f' : E → (E →L[ℝ] F)} {y u : E} (hf : ∀ᶠ (x : E) in 𝓝 y, has_fderiv_at f (f' x) x)\n  (hf' : differentiable_at ℝ f' y) : fderiv ℝ (λ x, f' x u) y = fderiv ℝ f' y u :=\nbegin\n  have : (λ x, f' x u) = λ x, ((apply ℝ _ _) ∘ f') x :=\n    by simp only [function.comp_app, apply_apply],\n  simp only [this, congr_arg],\n  rw fderiv.comp _ (apply ℝ F u).differentiable_at hf',\n  ext1 v,\n  simp only [(apply ℝ F u).fderiv, coe_comp', function.comp_app, apply_apply],\n  exact second_derivative_symmetric_of_eventually hf hf'.has_fderiv_at _ _\nend\n\nlemma DD1' {E F : Type*} [normed_group E] [normed_space ℝ E] [normed_group F] [normed_space ℝ F]  \n  {f' : E → E →L[ℝ] F} {f'' : E → (E →L[ℝ] E →L[ℝ] F)} {y u v w : E} \n  (hf : ∀ᶠ (x : E) in 𝓝 y, has_fderiv_at f' (f'' x) x) (hf' : differentiable_at ℝ f'' y) :\n  fderiv ℝ (λ x, f'' x u v) y w = fderiv ℝ f'' y w u v :=\nbegin\n  have triv : (λ x, f'' x u v) = λ x, ((apply ℝ _ _) ∘ \n    (λ x', f'' x' u)) x :=\n    by simp only [function.comp_app, apply_apply],\n  simp only [triv],\n  rw [fderiv.comp _ (apply ℝ F v).differentiable_at, DD1 hf hf'],\n  rw second_derivative_symmetric_of_eventually hf hf'.has_fderiv_at _ _,\n  simp only [congr_arg, coe_comp', (apply ℝ F v).fderiv, apply_apply, function.comp_app],\n  exact (apply ℝ (E →L[ℝ] F) u).differentiable_at.comp _ hf'\nend\n\nlemma is_open.is_const_of_fderiv_eq_zero {E F 𝕜 : Type*} [normed_group E] [normed_space ℝ E] \n  [is_R_or_C 𝕜] [normed_space 𝕜 E] [is_scalar_tower ℝ 𝕜 E] [normed_group F] [normed_space 𝕜 F] \n  {f : E → F} {s : set E} (hs : is_open s) (hs' : is_connected s) (hf : differentiable_on 𝕜 f s) \n  (h : ∀ x ∈ s, fderiv 𝕜 f x = 0) {x y : E} (hx : x ∈ s) (hy : y ∈ s) :\n  f x = f y :=\nbegin\n  rw is_connected_iff_connected_space at hs'; resetI,\n  let S : set s := {a : s | f a = f x},\n  have triv₁ : S.nonempty := ⟨⟨x, hx⟩, rfl⟩,\n  have triv₂ := continuous_on_iff_continuous_restrict.mp hf.continuous_on,\n  have minor₁ : is_closed S := is_closed_eq triv₂ continuous_const,\n  have minor₂ : is_open S :=\n  is_open_iff_forall_mem_open.mpr begin\n    intros t ht,\n    rcases metric.is_open_iff.mp hs t.1 t.2 with ⟨ε, hε, hball⟩,\n    have subminor₁ : ∀ (x' : E), x' ∈ metric.ball t.1 ε → \n      fderiv_within 𝕜 f (metric.ball t.1 ε) x' = 0 := \n    λ x' hx', begin\n      convert h x' (hball hx'),\n      exact fderiv_within_of_open metric.is_open_ball hx'\n    end,\n    have subminor₂ : coe⁻¹' (metric.ball t.1 ε) ⊆ S :=\n    λ a ha, begin\n      have := (convex_ball t.1 ε).is_const_of_fderiv_within_eq_zero (hf.mono hball) \n        subminor₁ ha (metric.mem_ball_self hε),\n      simp only [set.mem_set_of_eq] at ht,\n      rw [subtype.val_eq_coe, ht] at this,\n      exact this\n    end,\n    refine ⟨coe⁻¹' (metric.ball t.1 ε), subminor₂, \n      metric.is_open_ball.preimage continuous_subtype_coe, _⟩,\n    simp only [subtype.val_eq_coe],\n    exact metric.mem_ball_self hε\n  end,\n  have key : f y = f x := begin\n    suffices new : (⟨y, hy⟩ : s) ∈ S,\n    { exact new },\n    { rw eq_univ_of_nonempty_clopen triv₁ ⟨minor₂, minor₁⟩,\n      exact mem_univ _ }\n  end,\n  exact key.symm\nend\n\nlemma is_open.eq_sub_add_of_fderiv_eq_fderiv {E F 𝕜 : Type*} [normed_group E] [normed_space ℝ E] \n  [is_R_or_C 𝕜] [normed_space 𝕜 E] [is_scalar_tower ℝ 𝕜 E] [normed_group F] [normed_space 𝕜 F] \n  {f g : E → F} {s : set E} (hs : is_open s) (hs' : is_connected s) \n  (hf : differentiable_on 𝕜 f s) (hg : differentiable_on 𝕜 g s) \n  (h : ∀ x ∈ s, fderiv 𝕜 f x = fderiv 𝕜 g x) {x₀ : E} (hx₀ : x₀ ∈ s) :\n  ∀ x ∈ s, f x = g x - g x₀ + f x₀ :=\nbegin\n  refine λ x hx, sub_eq_zero.mp _,\n  rw [sub_add_eq_add_sub, ← add_sub],\n  have triv₁ : f x₀ - (g x₀ + (f x₀ - g x₀)) = 0 := by simp,\n  rw ← triv₁,\n  have triv₂ : differentiable_on 𝕜 (λ y, f y - (g y + (f x₀ - g x₀))) s := hf.sub (hg.add_const _),\n  refine hs.is_const_of_fderiv_eq_zero hs' triv₂ (λ y hy, _) hx hx₀,\n  rw [fderiv_sub ((hf y hy).differentiable_at $ hs.mem_nhds hy) \n      (((hg y hy).differentiable_at $ hs.mem_nhds hy).add_const _), \n      fderiv_add_const, h y hy, sub_self]\nend\n\n/-- Strangely the last statement cannot be simped... even if it's extremely simple -/\nlemma is_open.exists_of_fderiv_eq_fderiv {E F 𝕜 : Type*} [normed_group E] [normed_space ℝ E] \n  [is_R_or_C 𝕜] [normed_space 𝕜 E] [is_scalar_tower ℝ 𝕜 E] [normed_group F] [normed_space 𝕜 F] \n  {f g : E → F} {s : set E} (hs : is_open s) (hs' : is_connected s) \n  (hf : differentiable_on 𝕜 f s) (hg : differentiable_on 𝕜 g s) \n  (h : ∀ x ∈ s, fderiv 𝕜 f x = fderiv 𝕜 g x) :\n  ∃ y₀, ∀ x ∈ s, f x = g x - y₀ :=\nlet ⟨x₀, hx₀⟩ := hs'.nonempty in ⟨- (f x₀ - g x₀), λ x hx, \n  by simpa [sub_neg, sub_add] using hs.eq_sub_add_of_fderiv_eq_fderiv hs' hf hg h hx₀ x hx⟩\n\n-- lemma is_open.exists_of_fderiv_eq_fderiv_of_has_fderiv_at \n--   {E F 𝕜 : Type*} [normed_group E] [normed_space ℝ E] [is_R_or_C 𝕜] \n--   [normed_space 𝕜 E] [is_scalar_tower ℝ 𝕜 E] [normed_group F] [normed_space 𝕜 F] \n--   {f g : E → F} {f'} {s : set E} (hs : is_open s) (hs' : is_connected s) \n--   (hf : differentiable_on 𝕜 f s) (hg : differentiable_on 𝕜 g s) \n--   (h : ∀ x ∈ s, fderiv 𝕜 f x = fderiv 𝕜 g x) :\n--   ∃ x₀ ∈ s, ∀ x ∈ s, f x = g x - g x₀ + f x₀ :=\n-- begin\n\n-- end\n\nend diff_elementary\n\nsection diff_prep\n\nvariables {E F : Type*} [normed_group E] [normed_group F] \n  [normed_space ℝ E] [normed_space ℝ F] {f : E → F}\n\nlemma D21 {y : E} {n : ℕ} (hf : times_cont_diff_at ℝ n.succ f y) :\n  ∀ᶠ (x : E) in 𝓝 y, has_fderiv_at f (fderiv ℝ f x) x :=\nbegin\n  rcases times_cont_diff_at_succ_iff_has_fderiv_at.mp hf with ⟨f', ⟨s, hs, hxs⟩, hf'⟩,\n  have minor₁ : ∀ (x : E), x ∈ s → differentiable_at ℝ f x := λ x hx, ⟨f' x, hxs x hx⟩,\n  have minor₂ : ∀ (x : E), x ∈ s → has_fderiv_at f (fderiv ℝ f x) x := \n    λ x hx, (minor₁ x hx).has_fderiv_at,\n  rw filter.eventually_iff_exists_mem,\n  exact ⟨s, hs, minor₂⟩\nend\n\nlemma D22 {y : E} {n : ℕ} (hf : times_cont_diff_at ℝ n.succ f y) :\n  times_cont_diff_at ℝ n (fderiv ℝ f) y :=\nbegin\n  have triv₁ : (n : with_top ℕ) ≤ n + 1 := \n    by { apply with_top.coe_le_coe.mpr, exact nat.le_succ _ },\n  have triv₂ : (1 : with_top ℕ) ≤ n + 1 := \n    by { apply with_top.coe_le_coe.mpr, linarith },\n  rcases times_cont_diff_at_succ_iff_has_fderiv_at.mp hf with ⟨f', ⟨s, hs, hxs⟩, hf'⟩,\n  have minor₁ : ∀ (x : E), x ∈ s → differentiable_at ℝ f x := λ x hx, ⟨f' x, hxs x hx⟩,\n  have minor₂ : set.eq_on (fderiv ℝ f) f' s,\n  { intros x hxmem,\n    have := (hf.differentiable_at triv₂).has_fderiv_at,\n    exact (minor₁ x hxmem).has_fderiv_at.unique (hxs x hxmem) },\n  exact hf'.congr_of_eventually_eq (filter.eventually_eq_of_mem hs minor₂)\nend\n\nlemma D23 {y : E} {n : ℕ} (hn : 0 < n) (hf : times_cont_diff_at ℝ (n + 1) f y) :\n  differentiable_at ℝ (fderiv ℝ f) y :=\n(D22 hf).differentiable_at (with_top.coe_le_coe.mpr $ nat.succ_le_of_lt hn)\n\nlemma DD2 {y : E} {n : ℕ} (hn : 0 < n) (hf : times_cont_diff_at ℝ (n + 1) f y) (u : E) :\n  differentiable_at ℝ (λ x, fderiv ℝ f x u) y :=\n(apply ℝ F u).differentiable_at.comp _ (D23 hn hf)\n\nlemma third_order_symmetric {x u v w : E} (hf' : ∀ᶠ x' in 𝓝 x, times_cont_diff_at ℝ 3 f x') :\n  fderiv ℝ (fderiv ℝ $ fderiv ℝ f) x w u v = fderiv ℝ (fderiv ℝ $ fderiv ℝ f) x v u w :=\nbegin\n  have minor₁ : ∀ᶠ x' in 𝓝 x, has_fderiv_at ((apply ℝ _ u) ∘ (fderiv ℝ f)) \n    ((apply ℝ _ u).comp $ fderiv ℝ (fderiv ℝ f) x') x' :=\n    hf'.mono (λ y hy, (apply ℝ F u).has_fderiv_at.comp _ (D23 zero_lt_two hy).has_fderiv_at),\n  have minor₂ : (λ x', (apply ℝ _ u).comp $ fderiv ℝ (fderiv ℝ f) x') =ᶠ[𝓝 x] λ x',\n    (((apply ℝ (E →L[ℝ] F)) u) ∘ fderiv ℝ (fderiv ℝ f)) x' :=\n  hf'.mono (λ y hy, begin\n    ext1,\n    simp only [coe_comp', function.comp_app, apply_apply],\n    rw second_derivative_symmetric_of_eventually (D21 hy) (D23 zero_lt_two hy).has_fderiv_at\n  end),\n  have key := (apply ℝ (E →L[ℝ] F) u).has_fderiv_at.comp _\n    (D23 zero_lt_one $ D22 hf'.self_of_nhds).has_fderiv_at,\n  have := second_derivative_symmetric_of_eventually minor₁ (key.congr_of_eventually_eq minor₂) v w,\n  simp only [coe_comp', function.comp_app, apply_apply] at this,\n  rw this\nend\n\nend diff_prep\n\nsection tot_diff_eq\nopen submodule\n\nvariables {E F : Type*} [inner_product_space ℝ E] [inner_product_space ℝ F] {f : E → F}\n\nlemma D' (u v w : E) {y : E} {n : ℕ} (hn : 0 < n) (hf : times_cont_diff_at ℝ (n + 1) f y)  :\n  fderiv ℝ (λ x, ⟪fderiv ℝ f x u, fderiv ℝ f x v⟫) y w = \n  ⟪fderiv ℝ (fderiv ℝ f) y u w, fderiv ℝ f y v⟫ + \n  ⟪fderiv ℝ f y u, fderiv ℝ (fderiv ℝ f) y v w⟫ :=\nbegin\n  rw [fderiv_inner_apply (DD2 hn hf _) (DD2 hn hf _)],\n  simp only [congr_arg, DD1 (D21 hf) (D23 hn hf), congr_arg, add_comm]\nend\n\nvariables {x : E} (hf : ∀ᶠ x' in 𝓝 x, conformal_at f x') {f' : E → (E →L[ℝ] F)} \n  (Hf : ∀ (x' : E), is_conformal_map $ f' x') (Heven : fderiv ℝ f =ᶠ[𝓝 x] f')\n\nlocalized \"notation `conf_diff` := eventually_is_conformal_map_of_eventually_conformal hf\"\n  in liouville_do_not_use\nlocalized \"notation `conf_diff'` := \n  (eventually_is_conformal_map_of_eventually_conformal hf).self_of_nhds\" \n  in liouville_do_not_use\n\ninclude hf\n\nlemma D (hf' : times_cont_diff_at ℝ 2 f x) {u v w : E} \n  (huv : ⟪u, v⟫ = 0) (hwu : ⟪w, u⟫ = 0) (hwv : ⟪w, v⟫ = 0) :\n  ⟪fderiv ℝ (fderiv ℝ f) x u v, fderiv ℝ f x w⟫ = 0 :=\nbegin\n  rw real_inner_comm at hwv,\n  have m₁ := D' u v w zero_lt_one hf',\n  have m₂ := D' v w u zero_lt_one hf',\n  have m₃ := D' w u v zero_lt_one hf',\n  rw [(A' huv conf_diff).fderiv_eq] at m₁,\n  rw [(A' hwv conf_diff).fderiv_eq] at m₂,\n  rw [(A' hwu conf_diff).fderiv_eq] at m₃,\n  rw [fderiv_const, pi.zero_apply, continuous_linear_map.zero_apply] at m₁ m₂ m₃,\n  rw add_comm at m₁ m₃,\n  nth_rewrite 0 real_inner_comm at m₃ m₁,\n  nth_rewrite 1 real_inner_comm at m₁,\n  rw [second_derivative_symmetric_of_eventually (D21 hf') (D23 zero_lt_one hf').has_fderiv_at v u,\n      second_derivative_symmetric_of_eventually (D21 hf') (D23 zero_lt_one hf').has_fderiv_at w u] \n      at m₂,\n  rw [second_derivative_symmetric_of_eventually (D21 hf') (D23 zero_lt_one hf').has_fderiv_at w v] \n      at m₃,\n  have triv₂ : ∀ {a b c : ℝ}, a + b = 0 → b + c = 0 → a + c = 0 → a = 0 :=\n  λ a b c hab hbc hac, begin\n    rw [← hab, ← zero_add (a + b), ← hac, ← add_assoc, ← zero_add (b + c)] at hbc,\n    nth_rewrite 3 add_comm at hbc,\n    rw [add_assoc, add_assoc] at hbc,\n    nth_rewrite 1 ← add_assoc at hbc,\n    nth_rewrite 4 add_comm at hbc,\n    exact (add_self_eq_zero.mp $ add_right_cancel hbc.symm)\n  end,\n  exact triv₂ m₃.symm m₁.symm m₂.symm\nend\n\nlemma G'' (hf' : times_cont_diff_at ℝ 2 f x)\n  (h : function.surjective (fderiv ℝ f x)) {u v : E} (huv : ⟪u, v⟫ = 0) :\n  fderiv ℝ (fderiv ℝ f) x u v ∈ span ℝ ({fderiv ℝ f x u} ∪ {fderiv ℝ f x v} : set F) := \nbegin\n  refine C h conf_diff' (λ t ht, _),\n  rw mem_orthogonal at ht,\n  have triv₁ : u ∈ span ℝ ({u} ∪ {v} : set E) := subset_span (or.intro_left _ $ mem_singleton _),\n  have triv₂ : v ∈ span ℝ ({u} ∪ {v} : set E) := subset_span (or.intro_right _ $ mem_singleton _),\n  have minor₁ := ht u triv₁,\n  have minor₂ := ht v triv₂,\n  rw real_inner_comm at minor₁ minor₂,\n  exact D hf hf' huv minor₁ minor₂\nend\n\nlemma G' (hf' : times_cont_diff_at ℝ 2 f x) \n  (h : function.surjective (fderiv ℝ f x)) {u v : E} (huv : ⟪u, v⟫ = 0) : \n  fderiv ℝ (fderiv ℝ f) x u v = \n  (⟪fderiv ℝ f x u, fderiv ℝ (fderiv ℝ f) x u v⟫ / ↑∥fderiv ℝ f x u∥ ^ 2) • fderiv ℝ f x u +\n  (⟪fderiv ℝ f x v, fderiv ℝ (fderiv ℝ f) x u v⟫ / ↑∥fderiv ℝ f x v∥ ^ 2) • fderiv ℝ f x v :=\nbegin\n  rw [← orthogonal_projection_singleton, ← orthogonal_projection_singleton],\n  have := G'' hf hf' h huv,\n  rw [span_union, mem_sup] at this,\n  rcases this with ⟨p₁, hp₁, p₂, hp₂, hp₁p₂⟩,\n  have triv₁ : fderiv ℝ (fderiv ℝ f) x u v - p₂ = p₁ := \n    by rw [← hp₁p₂, ← add_sub, sub_self, add_zero],\n  have triv₂ : fderiv ℝ (fderiv ℝ f) x u v - p₁ = p₂ := \n    by { rw [← hp₁p₂, add_comm], rw [← add_sub, sub_self, add_zero] },\n  rcases mem_span_singleton.mp hp₁ with ⟨s₁, hs₁⟩,\n  rcases mem_span_singleton.mp hp₂ with ⟨s₂, hs₂⟩,\n  have key₁ : ∀ (w : F), w ∈  span ℝ ({fderiv ℝ f x u} : set F) →\n    ⟪fderiv ℝ (fderiv ℝ f) x u v - p₁, w⟫ = 0 :=\n  λ w hw, begin\n    rcases mem_span_singleton.mp hw with ⟨s', hs'⟩,\n    rw [← hs', triv₂, ← hs₂, real_inner_smul_left, real_inner_smul_right],\n    rw [real_inner_comm, A conf_diff'] at huv,\n    rw [huv, mul_zero, mul_zero]\n  end,\n  have key₂ : ∀ (w : F), w ∈  span ℝ ({fderiv ℝ f x v} : set F) →\n    ⟪fderiv ℝ (fderiv ℝ f) x u v - p₂, w⟫ = 0 :=\n  λ w hw, begin\n    rcases mem_span_singleton.mp hw with ⟨s', hs'⟩,\n    rw [← hs', triv₁, ← hs₁, real_inner_smul_left, real_inner_smul_right],\n    rw [A conf_diff'] at huv,\n    rw [huv, mul_zero, mul_zero]\n  end,\n  rw [eq_orthogonal_projection_of_mem_of_inner_eq_zero hp₁ key₁, \n      eq_orthogonal_projection_of_mem_of_inner_eq_zero hp₂ key₂],\n  exact hp₁p₂.symm\nend\n\ninclude Hf Heven\n\nlemma G [nontrivial E] (hf' : times_cont_diff_at ℝ 2 f x) (u v : E)  : \n  ⟪fderiv ℝ (fderiv ℝ f) x u v, fderiv ℝ f x u⟫ + \n  ⟪fderiv ℝ f x u, fderiv ℝ (fderiv ℝ f) x u v⟫ =\n  2 * ((similarity_factor_sqrt x conf_diff') * \n  (fderiv ℝ (λ y, similarity_factor_sqrt y $ Hf y) x v) * ⟪u, u⟫) :=\nbegin\n  rcases filter.eventually_eq_iff_exists_mem.mp Heven with ⟨s, hs, heq⟩,\n  rw ← D' u u v zero_lt_one hf',\n  have : (λ (y : E), ⟪fderiv ℝ f y u, fderiv ℝ f y u⟫) =ᶠ[𝓝 x] \n    (λ y, ⟪u, u⟫ * id y) ∘ (λ y, similarity_factor y $ Hf y),\n  { rw filter.eventually_eq_iff_exists_mem,\n    refine ⟨s, hs, _⟩,\n    intros z hz,\n    simp only [function.comp_app, congr_arg],\n    rw [mul_comm, heq hz],\n    exact (similarity_factor_prop z $ Hf z).2 u u },\n  have minor₁ := (D22 hf').congr_of_eventually_eq Heven.symm,\n  have minor₂ := (similarity_factor_times_cont_diff_at x Hf minor₁).differentiable_at \n    (le_of_eq rfl),\n  have minor₃ := (similarity_factor_sqrt_times_cont_diff_at x Hf minor₁).differentiable_at \n    (le_of_eq rfl),\n  rw [this.fderiv_eq, fderiv.comp _ (differentiable_at_id.const_mul _) minor₂, \n      fderiv_const_mul differentiable_at_id ⟪u, u⟫, fderiv_id],\n  rw ← similarity_factor_sqrt_eq Hf,\n  simp only [pow_two], \n  rw [fderiv_mul minor₃ minor₃, coe_comp'],\n  simp only [function.comp_app, coe_add', pi.add_apply, \n             continuous_linear_map.smul_apply, smul_eq_mul, coe_id'],\n  simp only [_root_.id],\n  rw similarity_factor_sqrt_eq_of_eq conf_diff' Heven.self_of_nhds,\n  ring\nend\n\nlemma GG' {u v : E} (hu : u ≠ 0) (hf' : times_cont_diff_at ℝ 2 f x) : \n  ⟪fderiv ℝ (fderiv ℝ f) x u v, fderiv ℝ f x u⟫ / ⟪u, u⟫ = \n  similarity_factor_sqrt x conf_diff' * (fderiv ℝ (λ y, similarity_factor_sqrt y $ Hf y) x v) :=\nbegin\n  haveI : nontrivial E := nontrivial_of_ne u 0 hu,\n  have key := G hf Hf Heven hf' u v,\n  rw [real_inner_comm, ← two_mul, real_inner_comm] at key,\n  have triv : ⟪u, u⟫ ≠ 0 := λ W, hu (inner_self_eq_zero.mp W),\n  rw div_eq_iff_mul_eq triv,\n  convert (mul_left_cancel' _ key).symm,\n  exact two_ne_zero  \nend\n\nlemma GG1 {u v : E} (hu : u ≠ 0) (hf' : times_cont_diff_at ℝ 2 f x) : \n  ⟪fderiv ℝ f x u, fderiv ℝ (fderiv ℝ f) x u v⟫ / ∥fderiv ℝ f x u∥ ^ 2 =\n  (fderiv ℝ (λ y, similarity_factor_sqrt y $ Hf y) x v) *\n  similarity_factor_sqrt_inv x conf_diff' :=\nbegin\n  rw [pow_two, ← real_inner_self_eq_norm_sq],\n  have triv₁ : ⟪u, u⟫ ≠ 0 := λ W, hu (inner_self_eq_zero.mp W),\n  rw [← div_mul_div_cancel _ triv₁,\n      (similarity_factor_sqrt_inv_prop x conf_diff').2,\n      real_inner_comm, GG' hf Hf Heven hu hf'],\n  simp only [similarity_factor_sqrt_inv, inv_inv', congr_arg],\n  field_simp [triv₁, (similarity_factor_sqrt_prop x conf_diff').1],\n  ring\nend\n\nlemma GG2 {u v : E} (hv : v ≠ 0) (hf' : times_cont_diff_at ℝ 2 f x) :\n  ⟪fderiv ℝ f x v, fderiv ℝ (fderiv ℝ f) x u v⟫ / ∥fderiv ℝ f x v∥ ^ 2 =\n  (fderiv ℝ (λ y, similarity_factor_sqrt y $ Hf y) x u) *\n  similarity_factor_sqrt_inv x conf_diff' :=\nbegin\n  rw second_derivative_symmetric_of_eventually (D21 hf') (D23 zero_lt_one hf').has_fderiv_at u v,\n  exact GG1 hf Hf Heven hv hf'\nend\n\nopen filter\nopen_locale filter\n\nlemma GGG_eventually_eq {u v : E} {s : set E} (hxs : x ∈ s) \n  (hs : is_open s) (hu : u ≠ 0) (hv : v ≠ 0) (huv : ⟪u, v⟫ = 0)\n  (hf' : ∀ y ∈ s, times_cont_diff_at ℝ 2 f y) (h : ∀ y ∈ s, function.surjective (fderiv ℝ f y)) : \n  (λ x', (similarity_factor_sqrt_inv x' $ Hf x') • (fderiv ℝ (fderiv ℝ f) x' u v) +\n  (fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x' v) • fderiv ℝ f x' u + \n  (fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x' u) • fderiv ℝ f x' v) =ᶠ[𝓝 x] \n  λ x', (0 : F) :=\nbegin\n  haveI : nontrivial E := nontrivial_of_ne u 0 hu,\n  rcases eventually_iff_exists_mem.mp hf with ⟨s₁, hs₁, hy₁⟩,\n  rcases eventually_eq_iff_exists_mem.mp Heven with ⟨s₂, hs₂, hy₂⟩,\n  have triv₁ : (s₁ ∩ s₂) ∩ s ∈ 𝓝 x := inter_mem (inter_mem hs₁ hs₂) \n    (hs.mem_nhds hxs),\n  rcases mem_nhds_iff.mp triv₁ with ⟨t, ht, hxt₁, hxt₂⟩,\n  refine eventually_eq_of_mem (hxt₁.mem_nhds hxt₂) (λ y hy, _),\n  have minor₁ : ∀ᶠ x' in 𝓝 y, conformal_at f x' :=\n    eventually_iff_exists_mem.mpr ⟨t, hxt₁.mem_nhds hy, λ y' hy', hy₁ y' (ht hy').1.1⟩,\n  have minor₂ : fderiv ℝ f =ᶠ[𝓝 y] f' :=\n    eventually_iff_exists_mem.mpr ⟨t, hxt₁.mem_nhds hy, λ y' hy', hy₂ (ht hy').1.2⟩,\n  simp only [congr_arg],\n  have key₁ := (hf' y (ht hy).2),\n  have key₂ := h y (ht hy).2,\n  have minor₃ := (D22 key₁).congr_of_eventually_eq minor₂.symm,\n  have key := similarity_factor_sqrt_inv_fderiv y Hf zero_lt_one minor₃,\n  rw [G' minor₁ key₁ key₂ huv, key],\n  simp only [is_R_or_C.coe_real_eq_id, _root_.id],\n  rw [GG1 minor₁ Hf minor₂ hu key₁, GG2 minor₁ Hf minor₂ hv key₁],\n  simp only [smul_add, smul_smul, pi.neg_apply, pi.mul_apply, congr_arg],\n  rw [← similarity_factor_sqrt_inv_eq', inv_pow', inv_inv', pow_two],\n  rw similarity_factor_sqrt_inv_eq_of_eq (Hf y) minor₂.symm.self_of_nhds,\n  nth_rewrite 1 add_comm,\n  simp only [← add_assoc, ← add_smul, add_assoc, ← add_smul],\n  rw [neg_mul_eq_neg_mul_symm, neg_add_eq_sub],\n  simp only [mul_assoc, mul_comm, sub_self, zero_smul],\n  simp\nend\n\nlemma J1 {u : E} (v w : E) (hu : u ≠ 0) (hf' : ∀ᶠ x' in 𝓝 x, times_cont_diff_at ℝ 3 f x') :\n  fderiv ℝ (λ x, (fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x v) • \n  fderiv ℝ f x u) x w = fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x w v • \n  fderiv ℝ f x u + fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x v • \n  fderiv ℝ (fderiv ℝ f) x w u :=\nbegin\n  haveI : nontrivial E := nontrivial_of_ne u 0 hu,\n  have minor₀ := similarity_factor_sqrt_inv_times_cont_diff_at x Hf \n    ((D22 hf'.self_of_nhds).congr_of_eventually_eq Heven.symm),\n  have minor₁ := hf.mono (λ x' hx', hx'.differentiable_at.has_fderiv_at),\n  have minor₂ := D23 zero_lt_two hf'.self_of_nhds,\n  have minor₃ : ∀ᶠ x' in 𝓝 x, times_cont_diff_at ℝ 2 (fderiv ℝ f) x' := hf'.mono (λ a ha, D22 ha),\n  have minor₄ : ∀ᶠ x' in 𝓝 x, has_fderiv_at (λ y, similarity_factor_sqrt_inv y $ Hf y) \n    (fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x') x' :=\n    D21 (similarity_factor_sqrt_inv_times_cont_diff_at _ Hf $\n    minor₃.self_of_nhds.congr_of_eventually_eq Heven.symm),\n  have minor₅ := D23 zero_lt_one minor₀,\n  rw fderiv_smul,\n  simp only [continuous_linear_map.add_apply, continuous_linear_map.smul_apply, \n             continuous_linear_map.smul_right_apply, congr_arg],\n  rw [DD1 minor₁ minor₂, DD1 minor₄ minor₅], \n  simp only [congr_arg],\n  rw [second_derivative_symmetric_of_eventually minor₁ minor₂.has_fderiv_at,\n      second_derivative_symmetric_of_eventually minor₄ minor₅.has_fderiv_at, add_comm],\n  exact DD2 zero_lt_one (similarity_factor_sqrt_inv_times_cont_diff_at _ \n    Hf $ minor₃.self_of_nhds.congr_of_eventually_eq Heven.symm) v,\n  exact DD2 zero_lt_two hf'.self_of_nhds u\nend\n\nlemma J2 {u : E} (v w : E) (hu : u ≠ 0) (hf' : times_cont_diff_at ℝ 4 f x) :\n  fderiv ℝ (λ x', (similarity_factor_sqrt_inv x' $ Hf x') • fderiv ℝ (fderiv ℝ f) x' u v) x w \n  = fderiv ℝ (λ x', similarity_factor_sqrt_inv x' $ Hf x') x w • \n  fderiv ℝ (fderiv ℝ f) x u v + similarity_factor_sqrt_inv x conf_diff' •\n  fderiv ℝ (fderiv ℝ $ fderiv ℝ f) x w u v :=\nbegin\n  haveI : nontrivial E := nontrivial_of_ne u 0 hu,\n  have := similarity_factor_sqrt_inv_times_cont_diff_at x Hf \n    ((D22 hf').congr_of_eventually_eq Heven.symm),\n  rw fderiv_smul,\n  simp only [add_apply, smul_apply, smul_right_apply, congr_arg],\n  rw [DD1' (D21 $ D22 hf') (D23 zero_lt_two $ D22 hf')],\n  simp only [add_comm, congr_arg],\n  rw similarity_factor_sqrt_inv_eq_of_eq _ Heven.self_of_nhds,\n  exact this.differentiable_at (with_top.coe_le_coe.mpr $ nat.succ_le_succ zero_le_two),\n  exact (apply ℝ F v).differentiable_at.comp _ \n    ((apply ℝ (E →L[ℝ] F) u).differentiable_at.comp _ $ D23 zero_lt_two $ D22 hf'),\nend\n\nlemma J2' {u : E} (v w : E) (hu : u ≠ 0) (hf' : ∀ᶠ x' in 𝓝 x, times_cont_diff_at ℝ 4 f x') :\n  fderiv ℝ (λ x', (similarity_factor_sqrt_inv x' $ Hf x') • fderiv ℝ (fderiv ℝ f) x' u v) x w \n  = fderiv ℝ (λ x', similarity_factor_sqrt_inv x' $ Hf x') x w • \n  fderiv ℝ (fderiv ℝ f) x u v + similarity_factor_sqrt_inv x conf_diff' •\n  fderiv ℝ (fderiv ℝ $ fderiv ℝ f) x v u w :=\nby rw [J2 hf Hf Heven v w hu hf'.self_of_nhds, \n       third_order_symmetric (hf'.mono $ λ a ha, ha.of_le $ \n       by { apply with_top.coe_le_coe.mpr, norm_num })]\n\nlemma tot1 {u v w : E}\n  (hw : w ≠ 0) (huv : ⟪u, v⟫ = 0) (huw : ⟪u, w⟫ = 0) (hwv : ⟪w, v⟫ = 0)\n  (hf' : ∀ᶠ x' in 𝓝 x, times_cont_diff_at ℝ 4 f x') \n  (h : ∀ᶠ x' in 𝓝 x , function.surjective (fderiv ℝ f x')) :\n  fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x v u = 0 :=\nbegin\n  by_cases hv : v ≠ 0; by_cases hu : u ≠ 0,\n  { have triv₁ : (2 : with_top ℕ) ≤ 4,\n    { apply with_top.coe_le_coe.mpr,\n      norm_num },\n    have triv₂ : (3 : with_top ℕ) ≤ 4,\n    { apply with_top.coe_le_coe.mpr,\n      norm_num },\n    have triv₃ : (1 : with_top ℕ) ≤ 3,\n    { apply with_top.coe_le_coe.mpr,\n      norm_num },\n    haveI : nontrivial E := nontrivial_of_ne u 0 hu,\n    have minor₁ := similarity_factor_sqrt_inv_times_cont_diff_at x Hf \n      ((D22 hf'.self_of_nhds).congr_of_eventually_eq Heven.symm),\n    have minor₂ := hf.mono (λ x' hx', hx'.differentiable_at.has_fderiv_at),\n    have minor₃ : ∀ᶠ x' in 𝓝 x, times_cont_diff_at ℝ 2 (fderiv ℝ f) x' := \n      hf'.mono (λ a ha, D22 $ ha.of_le triv₂),\n    have minor₄ : ∀ᶠ x' in 𝓝 x, has_fderiv_at (λ y, similarity_factor_sqrt_inv y $ Hf y) \n      (fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x') x' :=\n      D21 (similarity_factor_sqrt_inv_times_cont_diff_at _ Hf $\n      minor₃.self_of_nhds.congr_of_eventually_eq Heven.symm),\n    rcases eventually_iff_exists_mem.mp hf' with ⟨s₁, hs₁, hy₁⟩,\n    rcases eventually_iff_exists_mem.mp h with ⟨s₂, hs₂, hy₂⟩,\n    rcases mem_nhds_iff.mp (inter_mem hs₁ hs₂) with ⟨t, ht, Ht₁, Ht₂⟩,\n    have m₁ : fderiv ℝ _ _ w = (0 : F),\n    { rw (GGG_eventually_eq hf Hf Heven Ht₂ Ht₁ hu hv huv \n      (λ y' hy', (hy₁ y' (ht hy').1).of_le triv₁) $ λ y' hy', hy₂ y' (ht hy').2).fderiv_eq,\n      simp only [congr_arg, fderiv_const, pi.zero_apply, zero_apply] },\n    have m₂ : fderiv ℝ _ _ v = (0 : F),\n    { rw (GGG_eventually_eq hf Hf Heven Ht₂ Ht₁ hu hw huw\n      (λ y' hy', (hy₁ y' (ht hy').1).of_le triv₁) $ λ y' hy', hy₂ y' (ht hy').2).fderiv_eq,\n      simp only [congr_arg, fderiv_const, pi.zero_apply, zero_apply] },\n    rw ← m₂ at m₁,\n    have diff₁ := (apply ℝ ℝ u).differentiable_at.comp _ (D23 zero_lt_two minor₁),\n    have diff₁' := (apply ℝ ℝ v).differentiable_at.comp _ (D23 zero_lt_two minor₁),\n    have diff₁'' := (apply ℝ ℝ w).differentiable_at.comp _ (D23 zero_lt_two minor₁),\n    have diff₂ := (apply ℝ F v).differentiable_at.comp _ \n      ((D22 hf'.self_of_nhds).differentiable_at triv₃),\n    have diff₂' := (apply ℝ F u).differentiable_at.comp _ \n      ((D22 hf'.self_of_nhds).differentiable_at triv₃),\n    have diff₂'' := (apply ℝ F w).differentiable_at.comp _ \n      ((D22 hf'.self_of_nhds).differentiable_at triv₃),\n    have diff₃ := (apply ℝ F v).differentiable_at.comp _ \n      ((apply ℝ (E →L[ℝ] F) u).differentiable_at.comp _ $ D23 zero_lt_two $ D22 hf'.self_of_nhds),\n    have diff₃' := (apply ℝ F w).differentiable_at.comp _ \n      ((apply ℝ (E →L[ℝ] F) u).differentiable_at.comp _ $ D23 zero_lt_two $ D22 hf'.self_of_nhds),\n    have diff_mk₁ := diff₁.smul diff₂,\n    have diff_mk₁' := diff₁.smul diff₂'',\n    have diff_mk₂ := diff₁'.smul diff₂',\n    have diff_mk₂' := diff₁''.smul diff₂',\n    have diff_mk₃ := (minor₁.differentiable_at triv₃).smul diff₃,\n    have diff_mk₃' := (minor₁.differentiable_at triv₃).smul diff₃',\n    simp only [congr_arg, function.comp_app, apply_apply] at \n      diff_mk₁ diff_mk₁' diff_mk₂ diff_mk₂' diff_mk₃ diff_mk₃',\n    have times₁ := hf'.mono (λ a ha, ha.of_le triv₂), \n    rw [fderiv_add (diff_mk₃.add diff_mk₂) diff_mk₁, fderiv_add diff_mk₃ diff_mk₂,\n        fderiv_add (diff_mk₃'.add diff_mk₂') diff_mk₁', fderiv_add diff_mk₃' diff_mk₂'] at m₁,\n    simp only [add_apply] at m₁,\n    rw [J1 hf Hf Heven v w hu times₁, J1 hf Hf Heven u w hv times₁,\n        J1 hf Hf Heven w v hu times₁, J1 hf Hf Heven u v hw times₁] at m₁,\n    rw [J2' hf Hf Heven v w hu hf', J2 hf Hf Heven w v hu hf'.self_of_nhds] at m₁,\n    rw [second_derivative_symmetric_of_eventually (D21 hf'.self_of_nhds) \n        (D23 zero_lt_three hf'.self_of_nhds).has_fderiv_at w u, \n        second_derivative_symmetric_of_eventually (D21 hf'.self_of_nhds) \n        (D23 zero_lt_three hf'.self_of_nhds).has_fderiv_at u v,\n        second_derivative_symmetric_of_eventually (D21 hf'.self_of_nhds) \n        (D23 zero_lt_three hf'.self_of_nhds).has_fderiv_at w v] at m₁,\n    rw second_derivative_symmetric_of_eventually minor₄ \n      (D23 zero_lt_two minor₁).has_fderiv_at at m₁,\n    clear minor₁ minor₂ minor₃ minor₄ m₂ diff₁ diff₁' diff₁'' diff₂ diff₂' diff₂'' diff₃ \n      diff₃' diff_mk₁ diff_mk₁' diff_mk₂ diff_mk₂' diff_mk₃ diff_mk₃' times₁,\n    -- if I don't make a `quick1` lemma the there will be a time-out failure.\n    have key := quick1 m₁,\n    clear m₁,\n    have triv₄ : ⟪fderiv ℝ f x w, fderiv ℝ f x w⟫ ≠ 0 := \n      λ W, (hw $ inner_self_eq_zero.mp $ (A conf_diff').mpr W),\n    rw [← mul_div_cancel \n        (fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x v u) triv₄],\n    simp only [congr_arg] at key,\n    rw [← real_inner_smul_right, ← key, real_inner_smul_right, \n        (A conf_diff').mp hwv, mul_zero, zero_div] },\n  { rw not_not.mp hu,\n    simp only [continuous_linear_map.map_zero] },\n  { rw not_not.mp hv,\n    simp only [continuous_linear_map.map_zero, continuous_linear_map.zero_apply] },\n  { rw not_not.mp hu,\n    simp only [continuous_linear_map.map_zero] }\nend\n\nend tot_diff_eq\n\nsection bilin_form_and_local_prop \nopen continuous_linear_map filter\n\nvariables {E F : Type*} [inner_product_space ℝ E] [inner_product_space ℝ F] {f : E → F}\n  {s : set E} (hs : is_open s) (hfs : ∀ x ∈ s, conformal_at f x) \n  (hf's : ∀ x ∈ s, times_cont_diff_at ℝ 4 f x) \n  (hsurj : ∀ x ∈ s , function.surjective (fderiv ℝ f x))\n  {f' : E → (E →L[ℝ] F)} (Hf : ∀ (x' : E), is_conformal_map $ f' x')\n  (Hevens : ∀ x ∈ s, fderiv ℝ f x = f' x)\n\ndef to_sym_bilin_form (x : E) : bilin_form ℝ E :=\n{ bilin := λ u v, fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x v u,\n  bilin_add_left := λ x y z, by simp only [map_add],\n  bilin_smul_left := λ s x y, by simp only [map_smul, smul_eq_mul],\n  bilin_add_right := λ x y z, by simp only [map_add, add_apply],\n  bilin_smul_right := λ s x y, by simp only [map_smul, smul_apply, smul_eq_mul] }\n\ninclude hs Hevens hf's\n\nlemma is_sym_to_sym_bilin_form [nontrivial E] {x : E} (hx : x ∈ s) :\n  sym_bilin_form.is_sym (to_sym_bilin_form Hf x) :=\nλ u v, begin\n  have Heven := eventually_eq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx, λ a ha, Hevens a ha⟩,\n  have minor₁ := similarity_factor_sqrt_inv_times_cont_diff_at x Hf \n    ((D22 $ hf's x hx).congr_of_eventually_eq Heven.symm),\n  have minor₂ : ∀ᶠ x' in 𝓝 x, has_fderiv_at (λ y, similarity_factor_sqrt_inv y $ Hf y) \n    (fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x') x' :=\n    D21 (similarity_factor_sqrt_inv_times_cont_diff_at _ Hf $\n    (D22 $ hf's x hx).congr_of_eventually_eq Heven.symm),\n  rw [to_sym_bilin_form, bilin_form.coe_fn_mk, \n      second_derivative_symmetric_of_eventually minor₂ (D23 zero_lt_two minor₁).has_fderiv_at]\nend\n\ninclude hfs hsurj\n\nlemma hB (hrank3 : ∀ (u v : E), ∃ w, w ≠ 0 ∧ ⟪u, w⟫ = 0 ∧ ⟪w, v⟫ = 0) : \n  ∀ x' (hx' : x' ∈ s) u' v', ⟪u', v'⟫ = 0 → to_sym_bilin_form Hf x' u' v' = 0 :=\nλ x' hx' u' v' huv', begin\n  have hf := eventually_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx', λ a ha, hfs a ha⟩,\n  have Heven := eventually_eq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx', λ a ha, Hevens a ha⟩,\n  have hf' := eventually_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx', λ a ha, hf's a ha⟩,\n  have h := eventually_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx', λ a ha, hsurj a ha⟩,\n  simp only [to_sym_bilin_form],\n  rcases hrank3 u' v' with ⟨w', hw', huw', hwv'⟩,\n  exact tot1 hf Hf Heven hw' huv' huw' hwv' hf' h\nend\n\nvariables [complete_space E] [nontrivial E] \n  (hrank3 : ∀ (u v : E), ∃ w, w ≠ 0 ∧ ⟪u, w⟫ = 0 ∧ ⟪w, v⟫ = 0)\n\nlemma diff_bilin {x : E} (hx : x ∈ s) :\n  differentiable_at ℝ (λ x', bilin_form_factor (hB hs hfs hf's hsurj Hf Hevens hrank3) \n  (λ y hy, is_sym_to_sym_bilin_form hs hf's Hf Hevens hy) x') x :=\nbegin\n  rcases hrank3 0 0 with ⟨w₀, hw₀, _⟩,\n  have hb := hB hs hfs hf's hsurj Hf Hevens hrank3,\n  have hb' := λ y hy, is_sym_to_sym_bilin_form hs hf's Hf Hevens hy,\n  have triv₁ : ⟪w₀, w₀⟫ ≠ 0 := λ W, hw₀ (inner_self_eq_zero.mp W),\n  have minor₁ : (λ x', to_sym_bilin_form Hf x' w₀ w₀ / ⟪w₀, w₀⟫) =ᶠ[𝓝 x] \n    λ x', (bilin_form_factor hb hb' x'),\n  { refine eventually_eq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx, λ y hy, _⟩,\n    simp only [congr_arg, bilin_form_factor_prop hb hb' hy],\n    rw mul_div_cancel _ triv₁ },\n  simp only [to_sym_bilin_form, bilin_form.coe_fn_mk] at minor₁,\n  refine differentiable_at.congr_of_eventually_eq _ minor₁.symm,\n  simp only [div_eq_mul_inv, ← smul_eq_mul],\n  apply differentiable_at.smul_const,\n  have Heven := eventually_eq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx, λ a ha, Hevens a ha⟩,\n  have triv₂ : (λ x', fderiv ℝ (fderiv ℝ $ λ y, \n    similarity_factor_sqrt_inv y $ Hf y) x' w₀ w₀) = (apply ℝ _ w₀) ∘ \n    (λ x', fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x' w₀),\n  { ext1,\n    simp only [apply_apply, function.comp_app] },\n  rw triv₂,\n  refine (apply ℝ ℝ w₀).differentiable_at.comp _ (DD2 zero_lt_one (D22 _) w₀),\n  exact similarity_factor_sqrt_inv_times_cont_diff_at x Hf \n    ((D22 $ hf's x hx).congr_of_eventually_eq Heven.symm)\nend\n\nlocalized \"notation `H₁` := hB hs hfs hf's hsurj Hf Hevens hrank3\" in liouville_do_not_use\nlocalized \"notation `H₂` := λ y hy, is_sym_to_sym_bilin_form hs hf's Hf Hevens hy\" \n  in liouville_do_not_use\n\nlemma fderiv_fderiv_eq_bilin_form_factor_mul {x : E} (hx : x ∈ s) (u v : E) :\n  (λ x', fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x' v u) =ᶠ[𝓝 x] \n  λ x', (bilin_form_factor H₁ H₂ x') * ⟪u, v⟫ :=\neventually_eq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx, λ y hy,\n  by simpa [to_sym_bilin_form, bilin_form.coe_fn_congr] using bilin_form_factor_prop H₁ H₂ hy u v⟩\n\n/-- Not sure if `is_connected s` is a correct hypothesis. But it seems that this argument is used\n  to show that the `bilin_form_factor` is indeed a constant. -/\nlemma is_const_bilin_form_factor (hs' : is_connected s) :\n  ∃ (c : ℝ), ∀ x (hx : x ∈ s), bilin_form_factor H₁ H₂ x = c :=\nbegin\n  rcases hs'.nonempty with ⟨x₀, hx₀⟩,\n  refine ⟨bilin_form_factor H₁ H₂ x₀, λ x hx, _⟩,\n  have : ∀ y ∈ s, fderiv ℝ (λ x', bilin_form_factor H₁ H₂ x') y = 0 :=\n  λ y hy, begin\n    have triv₁ : ∀ᶠ x' in 𝓝 y, \n      times_cont_diff_at ℝ 3 (λ y, similarity_factor_sqrt_inv y $ Hf y) x' :=\n      eventually_iff_exists_mem.mpr ⟨s, hs.mem_nhds hy, λ x' hx', \n      similarity_factor_sqrt_inv_times_cont_diff_at x' Hf \n      ((D22 $ hf's x' hx').congr_of_eventually_eq \n      (eventually_eq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx', λ a ha, Hevens a ha⟩).symm)⟩,\n    have minor₁ := fderiv_fderiv_eq_bilin_form_factor_mul hs hfs hf's hsurj Hf Hevens hrank3 hy,\n    have minor₂ := diff_bilin hs hfs hf's hsurj Hf Hevens hrank3 hy,\n    have minor₃ : ∀ u v w, \n      fderiv ℝ (fderiv ℝ $ fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) y w u v =\n      fderiv ℝ (λ x', bilin_form_factor H₁ H₂ x') y w * ⟪u, v⟫ :=\n    λ u v w, begin\n      have Heven := eventually_eq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hy, λ a ha, Hevens a ha⟩,\n      have subkey₁ := D21 (D22 $ similarity_factor_sqrt_inv_times_cont_diff_at _ Hf $\n        (D22 $ hf's y hy).congr_of_eventually_eq Heven.symm),\n      rw [← DD1' subkey₁ (D23 zero_lt_one $ D22 triv₁.self_of_nhds), (minor₁ v u).fderiv_eq, \n          fderiv_mul_const minor₂, smul_apply, real_inner_comm, smul_eq_mul, mul_comm]\n    end,\n    ext1 v,\n    simp only [zero_apply],\n    rcases hrank3 v v with ⟨w, hw, hvw, _⟩,\n    have key_aux : fderiv ℝ (λ x', bilin_form_factor H₁ H₂ x') y w • v -\n      fderiv ℝ (λ x', bilin_form_factor H₁ H₂ x') y v • w = 0 :=\n    by rw [← inner_self_eq_zero, inner_sub_right, real_inner_smul_right, real_inner_smul_right,\n           ← minor₃, ← minor₃, third_order_symmetric triv₁, sub_self],\n    have key := eq_of_sub_eq_zero key_aux,\n    have minor₅ : (fderiv ℝ (λ x', bilin_form_factor H₁ H₂ x') y v) *\n      (fderiv ℝ (λ x', bilin_form_factor H₁ H₂ x') y v) * ⟪w, w⟫ = 0 :=\n    by rw [mul_assoc, ← real_inner_smul_left, ← key, \n           real_inner_smul_left, hvw, mul_zero, mul_zero],\n    exact mul_self_eq_zero.mp (eq_zero_of_ne_zero_of_mul_right_eq_zero \n      (λ W, hw $ inner_self_eq_zero.mp W) minor₅)\n  end,\n  exact hs.is_const_of_fderiv_eq_zero hs' (λ x' hx', \n    (diff_bilin hs hfs hf's hsurj Hf Hevens hrank3 hx').differentiable_within_at) this hx hx₀\nend\n\nend bilin_form_and_local_prop\n\nsection integrate\n\nopen continuous_linear_map filter\n\nvariables {E F : Type*} [inner_product_space ℝ E] [inner_product_space ℝ F] {f : E → F}\n  {s : set E} (hs : is_open s) (hs' : is_connected s) (hfs : ∀ x ∈ s, conformal_at f x) \n  (hf's : ∀ x ∈ s, times_cont_diff_at ℝ 4 f x) \n  (hsurj : ∀ x ∈ s , function.surjective (fderiv ℝ f x))\n  {f' : E → (E →L[ℝ] F)} (Hf : ∀ (x' : E), is_conformal_map $ f' x')\n  (Hevens : ∀ x ∈ s, fderiv ℝ f x = f' x)\n\nvariables [complete_space E] [nontrivial E] \n  (hrank3 : ∀ (u v : E), ∃ w, w ≠ 0 ∧ ⟪u, w⟫ = 0 ∧ ⟪w, v⟫ = 0)\n\nlocalized \"notation `H₁` := hB hs hfs hf's hsurj Hf Hevens hrank3\" in liouville_do_not_use\nlocalized \"notation `H₂` := λ y hy, is_sym_to_sym_bilin_form hs hf's Hf Hevens hy\" \n  in liouville_do_not_use\n\ninclude hs hs' hfs hf's hsurj Hf Hevens hrank3\n\nopen inner_product_space\n\nlemma similarity_factor_sqrt_inv_eq_const_mul_dist_add_const \n  (hnonzero : ∀ x ∈ s, bilin_form_factor H₁ H₂ x ≠ 0) :\n  ∃ (α β : ℝ) (hα : α ≠ 0) (x₀ : E), \n  ∀ x ∈ s, similarity_factor_sqrt_inv x (Hf x) = α * ∥x - x₀∥ ^ 2 + β :=\nbegin\n  rcases is_const_bilin_form_factor hs hfs hf's hsurj Hf Hevens hrank3 hs' with ⟨c, hc⟩,\n  have key₁ : ∀ x ∈ s, \n    fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x =\n    fderiv ℝ (λ y, c • to_dual y) x :=\n  λ x hx, begin\n    ext v u,\n    have triv₁ := (fderiv_fderiv_eq_bilin_form_factor_mul hs hfs hf's hsurj Hf \n      Hevens hrank3 hx u v).self_of_nhds,\n    simp only [congr_arg] at triv₁,\n    rw [fderiv_const_smul (continuous_linear_equiv.differentiable_at _), smul_apply, \n        smul_apply, continuous_linear_equiv.fderiv, to_dual.coe_coe, to_dual_apply, \n        triv₁, smul_eq_mul, real_inner_comm, hc x hx]\n  end,\n  have triv₁ := λ y (hy : y ∈ s), \n    (D23 zero_lt_two $ similarity_factor_sqrt_inv_times_cont_diff_at _ Hf\n    $ (D22 $ hf's y hy).congr_of_eventually_eq (eventually_eq_iff_exists_mem.mpr \n    ⟨s, hs.mem_nhds hy, λ a ha, Hevens a ha⟩).symm).differentiable_within_at,\n  rcases hs.exists_of_fderiv_eq_fderiv hs' triv₁ \n    (λ y hy, (continuous_linear_equiv.differentiable_within_at _).const_smul _) key₁ with ⟨map, h⟩,\n  simp only [congr_arg] at h,\n  have Hc : c ≠ 0 :=\n  λ W, begin\n    rcases hs'.nonempty with ⟨x', hx'⟩,\n    simp only [W] at hc,\n    have := hnonzero x' hx',\n    rw hc x' hx' at this,\n    exact this rfl\n  end,\n  let x₀ := to_dual.symm (c⁻¹ • map),\n  have triv₃ : c • to_dual x₀ = map := \n    by simp only [x₀, to_dual.apply_symm_apply, smul_inv_smul' Hc],\n  simp only [← triv₃, ← smul_sub, ← to_dual.map_sub] at h,\n  have key₂ : ∀ x ∈ s,\n    fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x = \n    fderiv ℝ (λ y, c / 2 * ⟪id y - x₀, id y⟫ - (c / 2) * to_dual x₀ (y - x₀)) x :=\n  λ x hx, begin\n    ext1 v,\n    rw [h x hx, fderiv_sub (((differentiable_at_id.sub_const x₀).inner \n        differentiable_at_id).const_mul _)]; \n        [skip, exact ((continuous_linear_map.differentiable_at _).comp _ \n        $ differentiable_at_id.sub_const _).const_mul (c / 2)],\n    rw [fderiv_const_mul ((differentiable_at_id.sub_const x₀).inner differentiable_at_id)],\n    rw [smul_apply, sub_apply, smul_apply, \n        fderiv_inner_apply (differentiable_at_id.sub_const x₀) differentiable_at_id],\n    rw [fderiv_sub_const],\n    simp only [fderiv_id], \n    simp only [id_apply, _root_.id],\n    rw [fderiv_const_mul]; [skip, exact ((continuous_linear_map.differentiable_at _).comp _ \n        $ differentiable_at_id.sub_const _)],\n    rw [fderiv.comp]; [skip, exact continuous_linear_map.differentiable_at _,\n        exact differentiable_at_id.sub_const _],\n    simp only [continuous_linear_map.fderiv, fderiv_sub_const, smul_apply, coe_comp',\n        function.comp_app, to_dual_apply, fderiv_id', id_apply, smul_add],\n    nth_rewrite 2 real_inner_comm,\n    simp only [inner_sub_left, smul_sub, smul_eq_mul],\n    ring\n  end,\n  have triv₄ := λ y hy, ((similarity_factor_sqrt_inv_times_cont_diff_at _ Hf\n    $ (D22 $ hf's y hy).congr_of_eventually_eq (eventually_eq_iff_exists_mem.mpr \n    ⟨s, hs.mem_nhds hy, λ a ha, Hevens a ha⟩).symm).differentiable_at\n    $ by apply with_top.coe_le_coe.mpr; norm_num).differentiable_within_at,\n  rcases hs.exists_of_fderiv_eq_fderiv hs' triv₄ _ key₂ with ⟨β, H⟩,\n  simp only [congr_arg, _root_.id] at H,\n  refine ⟨c / 2, -β, div_ne_zero Hc two_ne_zero, x₀, λ x hx, _⟩,\n  convert H x hx,\n  simp only [smul_eq_mul, to_dual_apply],\n  rw [real_inner_comm, ← mul_sub, ← inner_sub_left, real_inner_self_eq_norm_sq, pow_two],\n  intros y hy,\n  refine ((((differentiable_at_id.sub_const x₀).inner\n    differentiable_at_id).const_mul _).sub _).differentiable_within_at,\n  exact ((continuous_linear_map.differentiable_at _).comp _ \n    $ differentiable_at_id.sub_const _).const_mul (c / 2)  \nend\n\nlemma similarity_factor_sqrt_inv_eq_inner_add_const\n  (hzero : ∃ x ∈ s, bilin_form_factor H₁ H₂ x = 0) :\n  ∃ (β : ℝ) (x₀ : E), \n  ∀ x ∈ s, similarity_factor_sqrt_inv x (Hf x) = ⟪x, x₀⟫ + β :=\nbegin\n  rcases is_const_bilin_form_factor hs hfs hf's hsurj Hf Hevens hrank3 hs' with ⟨c, hc⟩,\n  have key₁ : ∀ x ∈ s, \n    fderiv ℝ (fderiv ℝ $ λ y, similarity_factor_sqrt_inv y $ Hf y) x =\n    fderiv ℝ (λ y, c • to_dual y) x :=\n  λ x hx, begin\n    ext v u,\n    have triv₁ := (fderiv_fderiv_eq_bilin_form_factor_mul hs hfs hf's hsurj Hf \n      Hevens hrank3 hx u v).self_of_nhds,\n    simp only [congr_arg] at triv₁,\n    rw [fderiv_const_smul (continuous_linear_equiv.differentiable_at _), smul_apply, \n        smul_apply, continuous_linear_equiv.fderiv, to_dual.coe_coe, to_dual_apply, \n        triv₁, smul_eq_mul, real_inner_comm, hc x hx]\n  end,\n  have triv₁ := λ y (hy : y ∈ s), \n    (D23 zero_lt_two $ similarity_factor_sqrt_inv_times_cont_diff_at _ Hf\n    $ (D22 $ hf's y hy).congr_of_eventually_eq (eventually_eq_iff_exists_mem.mpr \n    ⟨s, hs.mem_nhds hy, λ a ha, Hevens a ha⟩).symm).differentiable_within_at,\n  rcases hs.exists_of_fderiv_eq_fderiv hs' triv₁ \n    (λ y hy, (continuous_linear_equiv.differentiable_within_at _).const_smul _) key₁ with ⟨map, h⟩,\n  simp only [congr_arg] at h,\n  have Hc : c = 0 :=\n  begin\n    rcases hzero with ⟨x'', hx'', Hx''⟩,\n    rwa hc x'' hx'' at Hx'',\n  end,\n  simp only [Hc, zero_smul, zero_sub] at h,\n  have key₂ : ∀ x ∈ s,\n    fderiv ℝ (λ y, similarity_factor_sqrt_inv y $ Hf y) x =\n    fderiv ℝ (-map : E →L[ℝ] ℝ) x :=\n  λ x hx, by ext1 v; rw [h x hx, (-map).fderiv],\n  have triv₄ := λ y hy, ((similarity_factor_sqrt_inv_times_cont_diff_at _ Hf\n    $ (D22 $ hf's y hy).congr_of_eventually_eq (eventually_eq_iff_exists_mem.mpr \n    ⟨s, hs.mem_nhds hy, λ a ha, Hevens a ha⟩).symm).differentiable_at\n    $ by apply with_top.coe_le_coe.mpr; norm_num).differentiable_within_at,\n  rcases hs.exists_of_fderiv_eq_fderiv hs' triv₄ (continuous_linear_map.differentiable_on _) \n    key₂ with ⟨β, H⟩,\n  refine ⟨-β, to_dual.symm (-map), λ x hx, _⟩,\n  rw [real_inner_comm, ← to_dual_apply, to_dual.apply_symm_apply],\n  exact H x hx\nend\n\nend integrate\n\nsection conformality_of_local_inverse\n\nvariables {E : Type*} [inner_product_space ℝ E] [complete_space E] [nontrivial E] \n  -- {f' : E → (E →L[ℝ] F)} (Hf : ∀ (x' : E), is_conformal_map $ f' x')\n  -- (Hevens : ∀ x ∈ s, fderiv ℝ f x = f' x)\n\n-- def def_helper (f : E → E) (s : set E) (x : E) :=\n-- if x ∈ s then fderiv ℝ f x else id ℝ E\n\n-- lemma def_helper_eq (f : local_homeomorph E E) (s : set E) {x : E} (hx : x ∈ s) :\n--   fderiv ℝ f x = def_helper f s x :=\n-- by simp only [def_helper, if_pos hx]\n\nvariables {f : local_homeomorph E E} {s : set E} (hs : is_open s) \n  (hs' : is_connected s) (hs'' : s ⊆ f.source) (hfs : ∀ x ∈ s, conformal_at f x) \n  (hf's : ∀ x ∈ s, times_cont_diff_at ℝ 4 f x) \n  (hsurj : ∀ x ∈ s , function.surjective (fderiv ℝ f x))\n\n-- lemma def_helper_is_conformal_map {x : E} :\n--   is_conformal_map (def_helper f s x) :=\n-- begin\n--   simp only [def_helper],\n--   by_cases h : x ∈ s,\n--   { rw if_pos h,\n--     exact (conformal_at_iff_is_conformal_map_fderiv.mp $ hfs x h) },\n--   { rw if_neg h,\n--     exact is_conformal_map_id }\n-- end\n\ninclude hfs hsurj\n\ndef bijective_differentials {x : E} (hx : x ∈ s) : E ≃L[ℝ] E :=\ncontinuous_linear_equiv.of_bijective (fderiv ℝ f x) \n(linear_map.ker_eq_bot.mpr (conformal_at_iff_is_conformal_map_fderiv.mp $ hfs x hx).injective)\n(linear_map.range_eq_top.mpr $ hsurj x hx)\n\nlemma bijective_differentials1 {x : E} (hx : x ∈ s) :\n  (bijective_differentials hfs hsurj hx : E →L[ℝ] E) = fderiv ℝ f x :=\nby simp only [bijective_differentials, continuous_linear_equiv.coe_of_bijective]\n\nlemma bijective_differentials2 {x : E} (hx : x ∈ s) :\n  has_fderiv_at f (bijective_differentials hfs hsurj hx : E →L[ℝ] E) x :=\nbegin\n  rw bijective_differentials1 hfs hsurj hx,\n  exact (hfs x hx).differentiable_at.has_fderiv_at\nend\n\nend conformality_of_local_inverse\n\n-- h = u\n-- k = v\n-- l = w", "meta": {"author": "justadzr", "repo": "lean-2021", "sha": "dfc6b30de2f27bdba5fbc51183e2b84e73a920d1", "save_path": "github-repos/lean/justadzr-lean-2021", "path": "github-repos/lean/justadzr-lean-2021/lean-2021-dfc6b30de2f27bdba5fbc51183e2b84e73a920d1/src/liouville_theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541067, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.47687359851278366}}
{"text": "import polyhedral_lattice.basic\nimport normed_group.pseudo_normed_group\nimport pseudo_normed_group.with_Tinv\n\nimport topology.connected\n\nimport facts\n/-!\n\n# If M is a profinitely filtered pseudo-normed group with T⁻¹ then so is Hom(Λ, M)\n\nHere Λ is a polyhedral lattice, and the T⁻¹ is in the sense\nof `pseudo_normed_group.with_Tinv`.\n\n-/\n\nnoncomputable theory\nopen_locale nnreal big_operators\n\nopen pseudo_normed_group semi_normed_group\n\nlemma int.one_mem_filtration : (1 : ℤ) ∈ filtration ℤ 1 :=\nby simp only [nnnorm_one, mem_filtration_iff]\n\nsection\n\nvariables {Λ : Type*} [polyhedral_lattice Λ]\nvariables {M : Type*} [pseudo_normed_group M]\n\nlemma generates_norm.add_monoid_hom_mem_filtration_iff {ι : Type} [fintype ι]\n  {l : ι → Λ} (hl : generates_norm l) (x : Λ →+ M) (c : ℝ≥0) :\n  x ∈ filtration (Λ →+ M) c ↔ ∀ i, x (l i) ∈ filtration M (c * ∥l i∥₊) :=\nbegin\n  refine ⟨λ H i, H (le_refl ∥l i∥₊), _⟩,\n  intros H c' l' hl',\n  obtain ⟨cᵢ, h1, h2⟩ := hl.generates_nnnorm l',\n  rw [h1, x.map_sum],\n  refine filtration_mono _ (sum_mem_filtration _ (λ i, c * cᵢ i * ∥l i∥₊) _ _),\n  { calc ∑ i, c * cᵢ i * ∥l i∥₊\n        = c * ∑ i, cᵢ i * ∥l i∥₊ : by simp only [mul_assoc, ← finset.mul_sum]\n    ... = c * ∥l'∥₊ : by rw h2\n    ... ≤ c * c' : mul_le_mul' le_rfl hl' },\n  rintro i -,\n  rw [mul_assoc, mul_left_comm, x.map_nsmul],\n  exact pseudo_normed_group.nat_smul_mem_filtration (cᵢ i) _ _ (H i),\nend\n\nend\n\nnamespace polyhedral_lattice\n\nvariables (Λ : Type*) (r' : ℝ≥0) (M : Type*) [polyhedral_lattice Λ]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M]\n\ninclude r'\n\nnamespace add_monoid_hom\n\nvariables {Λ r' M} (c : ℝ≥0)\n\ndef incl (c : ℝ≥0) : filtration (Λ →+ M) c → Π l : Λ, filtration M (c * ∥l∥₊) :=\nλ f l, ⟨f l, f.2 $ mem_filtration_nnnorm _⟩\n\n@[simp] lemma coe_incl_apply (f : filtration (Λ →+ M) c) (l : Λ) :\n  (incl c f l : M) = f l :=\nrfl\n\nvariables (Λ r' M)\n\nlemma incl_injective : function.injective (@incl Λ r' M _ _ c) :=\nbegin\n  intros f g h,\n  ext l,\n  show (incl c f l : M) = incl c g l,\n  rw h\nend\n\ninstance : topological_space (filtration (Λ →+ M) c) :=\ntopological_space.induced (incl c) infer_instance\n\nlemma incl_embedding : embedding (@incl Λ r' M _ _ c) :=\n{ induced := rfl,\n  inj := incl_injective Λ r' M c }\n\nlemma incl_inducing : inducing (@incl Λ r' M _ _ c) := ⟨rfl⟩\n\nlemma incl_continuous : continuous (@incl Λ r' M _ _ c) :=\n(incl_inducing _ _ _ _).continuous\n\ninstance : t2_space (filtration (Λ →+ M) c) :=\n(incl_embedding Λ r' M c).t2_space\n\ninstance : totally_disconnected_space (filtration (Λ →+ M) c) :=\n{ is_totally_disconnected_univ := (incl_embedding Λ r' M c).is_totally_disconnected $\n    is_totally_disconnected_of_totally_disconnected_space _ }\n\nlemma incl_range_eq :\n  (set.range (@incl Λ r' M _ _ c)) =\n    ⋂ l₁ l₂, {f | (cast_le (f (l₁ + l₂)) : filtration M (c * (∥l₁∥₊ + ∥l₂∥₊))) =\n    cast_le (add' (f l₁, f l₂))} :=\nbegin\n  ext f,\n  simp only [set.mem_range, set.mem_Inter, coe_fn_coe_base, coe_incl_apply,\n    set.mem_set_of_eq, subtype.coe_mk, subtype.ext_iff],\n  split,\n  { rintro ⟨⟨f, hf⟩, rfl⟩ l₁ l₂,\n    exact f.map_add _ _ },\n  { intro h,\n    refine ⟨⟨add_monoid_hom.mk' (λ l, f l) h, _⟩, _⟩,\n    { intros c' l hl,\n      rw mem_filtration_iff at hl,\n      exact filtration_mono (mul_le_mul' le_rfl hl) (f l).2 },\n    { ext, refl } }\nend\n\nopen profinitely_filtered_pseudo_normed_group\n  comphaus_filtered_pseudo_normed_group\n\nlemma incl_range_is_closed : (is_closed (set.range (@incl Λ r' M _ _ c))) :=\nbegin\n  rw incl_range_eq,\n  apply is_closed_Inter,\n  intro l₁,\n  apply is_closed_Inter,\n  intro l₂,\n  apply is_closed_eq,\n  { exact (continuous_cast_le _ _).comp (continuous_apply (l₁ + l₂)) },\n  { exact (continuous_cast_le _ _).comp ((continuous_add' _ _).comp\n          ((continuous_apply l₁).prod_mk (continuous_apply l₂))) },\nend\n\ninstance : compact_space (filtration (Λ →+ M) c) :=\n{ compact_univ :=\n  begin\n    rw ← (incl_inducing Λ r' M c).is_compact_iff,\n    apply is_closed.is_compact,\n    rw set.image_univ,\n    exact incl_range_is_closed _ _ _ _\n  end }\n\nlemma continuous_iff {X : Type*} [topological_space X]\n  (ϕ : X → (filtration (Λ →+ M) c)) :\n  continuous ϕ ↔ ∀ l : Λ, continuous (λ x, incl c (ϕ x) l) :=\nbegin\n  rw (incl_inducing Λ r' M c).continuous_iff,\n  split,\n  { intros h l, exact (continuous_apply l).comp h },\n  { exact continuous_pi }\nend\n\ninstance profinitely_filtered_pseudo_normed_group :\n  profinitely_filtered_pseudo_normed_group (Λ →+ M) :=\n{ continuous_add' :=\n  begin\n    intros c₁ c₂,\n    rw continuous_iff,\n    intro l,\n    have step1 :=\n      ((continuous_apply l).comp (incl_continuous Λ r' M c₁)).prod_map\n      ((continuous_apply l).comp (incl_continuous Λ r' M c₂)),\n    have step2 := (continuous_add' (c₁ * ∥l∥₊) (c₂ * ∥l∥₊)),\n    have := step2.comp step1,\n    refine (@continuous_cast_le _ _ _ _ (id _)).comp this,\n    rw add_mul, exact ⟨le_rfl⟩\n  end,\n  continuous_neg' :=\n  begin\n    intro c,\n    rw continuous_iff,\n    intro l,\n    exact (continuous_neg' _).comp ((continuous_apply l).comp (incl_continuous Λ r' M c)),\n  end,\n  continuous_cast_le :=\n  begin\n    introsI c₁ c₂ h,\n    rw continuous_iff,\n    intro l,\n    exact (continuous_cast_le _ _).comp ((continuous_apply l).comp (incl_continuous Λ r' M c₁))\n  end,\n  .. add_monoid_hom.pseudo_normed_group }\n\nend add_monoid_hom\n\nvariables {Λ r' M}\n\nopen profinitely_filtered_pseudo_normed_group_with_Tinv\n\ndef Tinv' : (Λ →+ M) →+ (Λ →+ M) :=\nadd_monoid_hom.comp_hom\n  (@Tinv r' M _).to_add_monoid_hom\n\n@[simp] lemma Tinv'_apply (f : Λ →+ M) (l : Λ) :\n  Tinv' f l = Tinv (f l) := rfl\n\nlemma Tinv'_mem_filtration (c : ℝ≥0) (f : Λ →+ M) (hf : f ∈ filtration (Λ →+ M) c) :\n  Tinv' f ∈ filtration (Λ →+ M) (r'⁻¹ * c) :=\nbegin\n  intros x l hl,\n  rw [Tinv'_apply, mul_assoc],\n  apply Tinv_mem_filtration,\n  exact hf hl\nend\n\nvariables (Λ r' M)\n\nopen profinitely_filtered_pseudo_normed_group\nopen comphaus_filtered_pseudo_normed_group\nvariables [fact (0 < r')]\n\ndef Tinv : comphaus_filtered_pseudo_normed_group_hom (Λ →+ M) (Λ →+ M) :=\ncomphaus_filtered_pseudo_normed_group_hom.mk' Tinv'\nbegin\n  refine ⟨r'⁻¹, λ c, ⟨Tinv'_mem_filtration c, _⟩⟩,\n  rw add_monoid_hom.continuous_iff,\n  intro l,\n  haveI : ∀ a, fact (a ≤ r' * (r'⁻¹ * a)) :=\n    λ a, ⟨by simp [mul_inv_cancel_left₀ (ne_of_gt (fact.out _ : 0 < r'))]⟩,\n  refine (@continuous_cast_le _ _ _ _ (id _)).comp\n    ((@Tinv₀_continuous r' M _ (c * ∥l∥₊) (r'⁻¹ * (c * ∥l∥₊)) _).comp\n    ((continuous_apply l).comp (add_monoid_hom.incl_continuous Λ r' M c))),\n  rw mul_assoc, exact ⟨le_rfl⟩\nend\n\ninstance : profinitely_filtered_pseudo_normed_group_with_Tinv r' (Λ →+ M) :=\n{ Tinv := Tinv Λ r' M,\n  Tinv_mem_filtration := Tinv'_mem_filtration,\n  .. add_monoid_hom.profinitely_filtered_pseudo_normed_group Λ r' M }\n\n@[simp] lemma Tinv_apply (x : Λ →+ M) (l : Λ) :\n  (profinitely_filtered_pseudo_normed_group_with_Tinv.Tinv x) l =\n  profinitely_filtered_pseudo_normed_group_with_Tinv.Tinv (x l) := rfl\n\nend polyhedral_lattice\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/polyhedral_lattice/pseudo_normed_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4768389173148337}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module combinatorics.double_counting\n! leanprover-community/mathlib commit 1126441d6bccf98c81214a0780c73d499f6721fe\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.BigOperators.Order\n\n/-!\n# Double countings\n\nThis file gathers a few double counting arguments.\n\n## Bipartite graphs\n\nIn a bipartite graph (considered as a relation `r : α → β → Prop`), we can bound the number of edges\nbetween `s : Finset α` and `t : Finset β` by the minimum/maximum of edges over all `a ∈ s` times the\nthe size of `s`. Similarly for `t`. Combining those two yields inequalities between the sizes of `s`\nand `t`.\n\n* `bipartiteBelow`: `s.bipartiteBelow r b` are the elements of `s` below `b` wrt to `r`. Its size\n  is the number of edges of `b` in `s`.\n* `bipartiteAbove`: `t.bipartite_Above r a` are the elements of `t` above `a` wrt to `r`. Its size\n  is the number of edges of `a` in `t`.\n* `card_mul_le_card_mul`, `card_mul_le_card_mul'`: Double counting the edges of a bipartite graph\n  from below and from above.\n* `card_mul_eq_card_mul`: Equality combination of the previous.\n-/\n\n\nopen Finset Function Relator\n\nopen BigOperators\n\nvariable {α β : Type _}\n\n/-! ### Bipartite graph -/\n\n\nnamespace Finset\n\nsection Bipartite\n\nvariable (r : α → β → Prop) (s : Finset α) (t : Finset β) (a a' : α) (b b' : β)\n  [DecidablePred (r a)] [∀ a, Decidable (r a b)] {m n : ℕ}\n\n/-- Elements of `s` which are \"below\" `b` according to relation `r`. -/\ndef bipartiteBelow : Finset α := s.filter fun a ↦ r a b\n#align finset.bipartite_below Finset.bipartiteBelow\n\n/-- Elements of `t` which are \"above\" `a` according to relation `r`. -/\ndef bipartiteAbove : Finset β := t.filter (r a)\n#align finset.bipartite_above Finset.bipartiteAbove\n\ntheorem bipartiteBelow_swap : t.bipartiteBelow (swap r) a = t.bipartiteAbove r a := rfl\n#align finset.bipartite_below_swap Finset.bipartiteBelow_swap\n\ntheorem bipartiteAbove_swap : s.bipartiteAbove (swap r) b = s.bipartiteBelow r b := rfl\n#align finset.bipartite_above_swap Finset.bipartiteAbove_swap\n\n@[simp, norm_cast]\ntheorem coe_bipartiteBelow : (s.bipartiteBelow r b : Set α) = { a ∈ s | r a b } := coe_filter _ _\n#align finset.coe_bipartite_below Finset.coe_bipartiteBelow\n\n@[simp, norm_cast]\ntheorem coe_bipartiteAbove : (t.bipartiteAbove r a : Set β) = { b ∈ t | r a b } := coe_filter _ _\n#align finset.coe_bipartite_above Finset.coe_bipartiteAbove\n\nvariable {s t a a' b b'}\n\n@[simp]\ntheorem mem_bipartiteBelow {a : α} : a ∈ s.bipartiteBelow r b ↔ a ∈ s ∧ r a b := mem_filter\n#align finset.mem_bipartite_below Finset.mem_bipartiteBelow\n\n@[simp]\ntheorem mem_bipartiteAbove {b : β} : b ∈ t.bipartiteAbove r a ↔ b ∈ t ∧ r a b := mem_filter\n#align finset.mem_bipartite_above Finset.mem_bipartiteAbove\n\ntheorem sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow [∀ a b, Decidable (r a b)] :\n    (∑ a in s, (t.bipartiteAbove r a).card) = ∑ b in t, (s.bipartiteBelow r b).card := by\n  simp_rw [card_eq_sum_ones, bipartiteAbove, bipartiteBelow, sum_filter]\n  exact sum_comm\n#align finset.sum_card_bipartite_above_eq_sum_card_bipartite_below Finset.sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow\n\n/-- Double counting argument. Considering `r` as a bipartite graph, the LHS is a lower bound on the\nnumber of edges while the RHS is an upper bound. -/\ntheorem card_mul_le_card_mul [∀ a b, Decidable (r a b)]\n    (hm : ∀ a ∈ s, m ≤ (t.bipartiteAbove r a).card)\n    (hn : ∀ b ∈ t, (s.bipartiteBelow r b).card ≤ n) : s.card * m ≤ t.card * n :=\n  calc\n    _ ≤ ∑ a in s, (t.bipartiteAbove r a).card := s.card_nsmul_le_sum _ _ hm\n    _ = ∑ b in t, (s.bipartiteBelow r b).card :=\n      sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow _\n    _ ≤ _ := t.sum_le_card_nsmul _ _ hn\n\n#align finset.card_mul_le_card_mul Finset.card_mul_le_card_mul\n\ntheorem card_mul_le_card_mul' [∀ a b, Decidable (r a b)]\n    (hn : ∀ b ∈ t, n ≤ (s.bipartiteBelow r b).card)\n    (hm : ∀ a ∈ s, (t.bipartiteAbove r a).card ≤ m) : t.card * n ≤ s.card * m :=\n  card_mul_le_card_mul (swap r) hn hm\n#align finset.card_mul_le_card_mul' Finset.card_mul_le_card_mul'\n\ntheorem card_mul_eq_card_mul [∀ a b, Decidable (r a b)]\n    (hm : ∀ a ∈ s, (t.bipartiteAbove r a).card = m)\n    (hn : ∀ b ∈ t, (s.bipartiteBelow r b).card = n) : s.card * m = t.card * n :=\n  (card_mul_le_card_mul _ (fun a ha ↦ (hm a ha).ge) fun b hb ↦ (hn b hb).le).antisymm <|\n    card_mul_le_card_mul' _ (fun a ha ↦ (hn a ha).ge) fun b hb ↦ (hm b hb).le\n#align finset.card_mul_eq_card_mul Finset.card_mul_eq_card_mul\n\n\n\ntheorem card_le_card_of_forall_subsingleton' (ht : ∀ b ∈ t, ∃ a, a ∈ s ∧ r a b)\n    (hs : ∀ a ∈ s, ({ b ∈ t | r a b } : Set β).Subsingleton) : t.card ≤ s.card :=\n  card_le_card_of_forall_subsingleton (swap r) ht hs\n#align finset.card_le_card_of_forall_subsingleton' Finset.card_le_card_of_forall_subsingleton'\n\nend Bipartite\n\nend Finset\n\nopen Finset\n\nnamespace Fintype\n\nvariable [Fintype α] [Fintype β] {r : α → β → Prop}\n\ntheorem card_le_card_of_leftTotal_unique (h₁ : LeftTotal r) (h₂ : LeftUnique r) :\n    Fintype.card α ≤ Fintype.card β :=\n  card_le_card_of_forall_subsingleton r (by simpa using h₁) fun b _ a₁ ha₁ a₂ ha₂ ↦ h₂ ha₁.2 ha₂.2\n#align fintype.card_le_card_of_left_total_unique Fintype.card_le_card_of_leftTotal_unique\n\ntheorem card_le_card_of_rightTotal_unique (h₁ : RightTotal r) (h₂ : RightUnique r) :\n    Fintype.card β ≤ Fintype.card α :=\n  card_le_card_of_forall_subsingleton' r (by simpa using h₁) fun b _ a₁ ha₁ a₂ ha₂ ↦ h₂ ha₁.2 ha₂.2\n#align fintype.card_le_card_of_right_total_unique Fintype.card_le_card_of_rightTotal_unique\n\nend Fintype\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Combinatorics/DoubleCounting.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477015, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.4768389173148336}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.set.intervals.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Projection of a line onto a closed interval\n\nGiven a linearly ordered type `α`, in this file we define\n\n* `set.proj_Icc (a b : α) (h : a ≤ b)` to be the map `α → [a, b]` sending `(-∞, a]` to `a`, `[b, ∞)`\n  to `b`, and each point `x ∈ [a, b]` to itself;\n* `set.Icc_extend {a b : α} (h : a ≤ b) (f : Icc a b → β)` to be the extension of `f` to `α` defined\n  as `f ∘ proj_Icc a b h`.\n\nWe also prove some trivial properties of these maps.\n-/\n\nnamespace set\n\n\n/-- Projection of `α` to the closed interval `[a, b]`. -/\ndef proj_Icc {α : Type u_1} [linear_order α] (a : α) (b : α) (h : a ≤ b) (x : α) : ↥(Icc a b) :=\n  { val := max a (min b x), property := sorry }\n\ntheorem proj_Icc_of_le_left {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α} (hx : x ≤ a) : proj_Icc a b h x = { val := a, property := iff.mpr left_mem_Icc h } := sorry\n\n@[simp] theorem proj_Icc_left {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) : proj_Icc a b h a = { val := a, property := iff.mpr left_mem_Icc h } :=\n  proj_Icc_of_le_left h le_rfl\n\ntheorem proj_Icc_of_right_le {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α} (hx : b ≤ x) : proj_Icc a b h x = { val := b, property := iff.mpr right_mem_Icc h } := sorry\n\n@[simp] theorem proj_Icc_right {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) : proj_Icc a b h b = { val := b, property := iff.mpr right_mem_Icc h } :=\n  proj_Icc_of_right_le h le_rfl\n\ntheorem proj_Icc_of_mem {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α} (hx : x ∈ Icc a b) : proj_Icc a b h x = { val := x, property := hx } := sorry\n\n@[simp] theorem proj_Icc_coe {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) (x : ↥(Icc a b)) : proj_Icc a b h ↑x = x :=\n  subtype.cases_on x fun (x_val : α) (x_property : x_val ∈ Icc a b) => proj_Icc_of_mem h x_property\n\ntheorem proj_Icc_surj_on {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) : surj_on (proj_Icc a b h) (Icc a b) univ :=\n  fun (x : ↥(Icc a b)) (_x : x ∈ univ) => Exists.intro ↑x { left := subtype.property x, right := proj_Icc_coe h x }\n\ntheorem proj_Icc_surjective {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) : function.surjective (proj_Icc a b h) :=\n  fun (x : ↥(Icc a b)) => Exists.intro (↑x) (proj_Icc_coe h x)\n\n@[simp] theorem range_proj_Icc {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) : range (proj_Icc a b h) = univ :=\n  function.surjective.range_eq (proj_Icc_surjective h)\n\ntheorem monotone_proj_Icc {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) : monotone (proj_Icc a b h) :=\n  fun (x y : α) (hxy : x ≤ y) => max_le_max le_rfl (min_le_min le_rfl hxy)\n\ntheorem strict_mono_incr_on_proj_Icc {α : Type u_1} [linear_order α] {a : α} {b : α} (h : a ≤ b) : strict_mono_incr_on (proj_Icc a b h) (Icc a b) := sorry\n\n/-- Extend a function `[a, b] → β` to a map `α → β`. -/\ndef Icc_extend {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) (f : ↥(Icc a b) → β) : α → β :=\n  f ∘ proj_Icc a b h\n\n@[simp] theorem Icc_extend_range {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) (f : ↥(Icc a b) → β) : range (Icc_extend h f) = range f := sorry\n\ntheorem Icc_extend_of_le_left {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α} (f : ↥(Icc a b) → β) (hx : x ≤ a) : Icc_extend h f x = f { val := a, property := iff.mpr left_mem_Icc h } :=\n  congr_arg f (proj_Icc_of_le_left h hx)\n\n@[simp] theorem Icc_extend_left {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) (f : ↥(Icc a b) → β) : Icc_extend h f a = f { val := a, property := iff.mpr left_mem_Icc h } :=\n  Icc_extend_of_le_left h f le_rfl\n\ntheorem Icc_extend_of_right_le {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α} (f : ↥(Icc a b) → β) (hx : b ≤ x) : Icc_extend h f x = f { val := b, property := iff.mpr right_mem_Icc h } :=\n  congr_arg f (proj_Icc_of_right_le h hx)\n\n@[simp] theorem Icc_extend_right {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) (f : ↥(Icc a b) → β) : Icc_extend h f b = f { val := b, property := iff.mpr right_mem_Icc h } :=\n  Icc_extend_of_right_le h f le_rfl\n\ntheorem Icc_extend_of_mem {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) {x : α} (f : ↥(Icc a b) → β) (hx : x ∈ Icc a b) : Icc_extend h f x = f { val := x, property := hx } :=\n  congr_arg f (proj_Icc_of_mem h hx)\n\n@[simp] theorem Icc_extend_coe {α : Type u_1} {β : Type u_2} [linear_order α] {a : α} {b : α} (h : a ≤ b) (f : ↥(Icc a b) → β) (x : ↥(Icc a b)) : Icc_extend h f ↑x = f x :=\n  congr_arg f (proj_Icc_coe h x)\n\nend set\n\n\ntheorem monotone.Icc_extend {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β] {a : α} {b : α} (h : a ≤ b) {f : ↥(set.Icc a b) → β} (hf : monotone f) : monotone (set.Icc_extend h f) :=\n  monotone.comp hf (set.monotone_proj_Icc h)\n\ntheorem strict_mono.strict_mono_incr_on_Icc_extend {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β] {a : α} {b : α} (h : a ≤ b) {f : ↥(set.Icc a b) → β} (hf : strict_mono f) : strict_mono_incr_on (set.Icc_extend h f) (set.Icc a b) :=\n  strict_mono.comp_strict_mono_incr_on hf (set.strict_mono_incr_on_proj_Icc h)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/set/intervals/proj_Icc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.47683889981835004}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura, Jeremy Avigad, Haitao Zhang\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.data.prod\nimport Mathlib.Lean3Lib.init.funext\nimport Mathlib.Lean3Lib.init.logic\n\nuniverses u₁ u₂ u₃ u₄ \n\nnamespace Mathlib\n\n/-!\n# General operations on functions\n-/\n\nnamespace function\n\n\n/-- Composition of functions: `(f ∘ g) x = f (g x)`. -/\ndef comp {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} (f : β → φ) (g : α → β) : α → φ :=\n  fun (x : α) => f (g x)\n\n/-- Composition of dependent functions: `(f ∘' g) x = f (g x)`, where type of `g x` depends on `x`\nand type of `f (g x)` depends on `x` and `g x`. -/\ndef dcomp {α : Sort u₁} {β : α → Sort u₂} {φ : {x : α} → β x → Sort u₃}\n    (f : {x : α} → (y : β x) → φ y) (g : (x : α) → β x) (x : α) : φ (g x) :=\n  f (g x)\n\ninfixr:90 \" ∘ \" => Mathlib.function.comp\n\ninfixr:80 \" ∘' \" => Mathlib.function.dcomp\n\ndef comp_right {α : Sort u₁} {β : Sort u₂} (f : β → β → β) (g : α → β) : β → α → β :=\n  fun (b : β) (a : α) => f b (g a)\n\ndef comp_left {α : Sort u₁} {β : Sort u₂} (f : β → β → β) (g : α → β) : α → β → β :=\n  fun (a : α) (b : β) => f (g a) b\n\n/-- Given functions `f : β → β → φ` and `g : α → β`, produce a function `α → α → φ` that evaluates\n`g` on each argument, then applies `f` to the results. Can be used, e.g., to transfer a relation\nfrom `β` to `α`. -/\ndef on_fun {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} (f : β → β → φ) (g : α → β) : α → α → φ :=\n  fun (x y : α) => f (g x) (g y)\n\ndef combine {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} {δ : Sort u₄} {ζ : Sort u₁} (f : α → β → φ)\n    (op : φ → δ → ζ) (g : α → β → δ) : α → β → ζ :=\n  fun (x : α) (y : β) => op (f x y) (g x y)\n\n/-- Constant `λ _, a`. -/\ndef const {α : Sort u₁} (β : Sort u₂) (a : α) : β → α := fun (x : β) => a\n\ndef swap {α : Sort u₁} {β : Sort u₂} {φ : α → β → Sort u₃} (f : (x : α) → (y : β) → φ x y) (y : β)\n    (x : α) : φ x y :=\n  f x y\n\ndef app {α : Sort u₁} {β : α → Sort u₂} (f : (x : α) → β x) (x : α) : β x := f x\n\ninfixl:2 \" on \" => Mathlib.function.on_fun\n\ntheorem left_id {α : Sort u₁} {β : Sort u₂} (f : α → β) : id ∘ f = f := rfl\n\ntheorem right_id {α : Sort u₁} {β : Sort u₂} (f : α → β) : f ∘ id = f := rfl\n\n@[simp] theorem comp_app {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} (f : β → φ) (g : α → β) (a : α) :\n    comp f g a = f (g a) :=\n  rfl\n\ntheorem comp.assoc {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} {δ : Sort u₄} (f : φ → δ) (g : β → φ)\n    (h : α → β) : (f ∘ g) ∘ h = f ∘ g ∘ h :=\n  rfl\n\n@[simp] theorem comp.left_id {α : Sort u₁} {β : Sort u₂} (f : α → β) : id ∘ f = f := rfl\n\n@[simp] theorem comp.right_id {α : Sort u₁} {β : Sort u₂} (f : α → β) : f ∘ id = f := rfl\n\ntheorem comp_const_right {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} (f : β → φ) (b : β) :\n    f ∘ const α b = const α (f b) :=\n  rfl\n\n/-- A function `f : α → β` is called injective if `f x = f y` implies `x = y`. -/\ndef injective {α : Sort u₁} {β : Sort u₂} (f : α → β) := ∀ {a₁ a₂ : α}, f a₁ = f a₂ → a₁ = a₂\n\ntheorem injective.comp {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} {g : β → φ} {f : α → β}\n    (hg : injective g) (hf : injective f) : injective (g ∘ f) :=\n  fun (a₁ a₂ : α) (h : comp g f a₁ = comp g f a₂) => hf (hg h)\n\n/-- A function `f : α → β` is calles surjective if every `b : β` is equal to `f a`\nfor some `a : α`. -/\ndef surjective {α : Sort u₁} {β : Sort u₂} (f : α → β) := ∀ (b : β), ∃ (a : α), f a = b\n\ntheorem surjective.comp {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} {g : β → φ} {f : α → β}\n    (hg : surjective g) (hf : surjective f) : surjective (g ∘ f) :=\n  sorry\n\n/-- A function is called bijective if it is both injective and surjective. -/\ndef bijective {α : Sort u₁} {β : Sort u₂} (f : α → β) := injective f ∧ surjective f\n\ntheorem bijective.comp {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} {g : β → φ} {f : α → β} :\n    bijective g → bijective f → bijective (g ∘ f) :=\n  sorry\n\n/-- `left_inverse g f` means that g is a left inverse to f. That is, `g ∘ f = id`. -/\ndef left_inverse {α : Sort u₁} {β : Sort u₂} (g : β → α) (f : α → β) := ∀ (x : α), g (f x) = x\n\n/-- `has_left_inverse f` means that `f` has an unspecified left inverse. -/\ndef has_left_inverse {α : Sort u₁} {β : Sort u₂} (f : α → β) :=\n  ∃ (finv : β → α), left_inverse finv f\n\n/-- `right_inverse g f` means that g is a right inverse to f. That is, `f ∘ g = id`. -/\ndef right_inverse {α : Sort u₁} {β : Sort u₂} (g : β → α) (f : α → β) := left_inverse f g\n\n/-- `has_right_inverse f` means that `f` has an unspecified right inverse. -/\ndef has_right_inverse {α : Sort u₁} {β : Sort u₂} (f : α → β) :=\n  ∃ (finv : β → α), right_inverse finv f\n\ntheorem left_inverse.injective {α : Sort u₁} {β : Sort u₂} {g : β → α} {f : α → β} :\n    left_inverse g f → injective f :=\n  fun (h : left_inverse g f) (a b : α) (faeqfb : f a = f b) =>\n    Eq.trans (Eq.trans (Eq.symm (h a)) (congr_arg g faeqfb)) (h b)\n\ntheorem has_left_inverse.injective {α : Sort u₁} {β : Sort u₂} {f : α → β} :\n    has_left_inverse f → injective f :=\n  fun (h : has_left_inverse f) =>\n    exists.elim h fun (finv : β → α) (inv : left_inverse finv f) => left_inverse.injective inv\n\ntheorem right_inverse_of_injective_of_left_inverse {α : Sort u₁} {β : Sort u₂} {f : α → β}\n    {g : β → α} (injf : injective f) (lfg : left_inverse f g) : right_inverse f g :=\n  fun (x : α) => (fun (h : f (g (f x)) = f x) => injf h) (lfg (f x))\n\ntheorem right_inverse.surjective {α : Sort u₁} {β : Sort u₂} {f : α → β} {g : β → α}\n    (h : right_inverse g f) : surjective f :=\n  fun (y : β) => Exists.intro (g y) (h y)\n\ntheorem has_right_inverse.surjective {α : Sort u₁} {β : Sort u₂} {f : α → β} :\n    has_right_inverse f → surjective f :=\n  fun (ᾰ : has_right_inverse f) =>\n    Exists.dcases_on ᾰ\n      fun (ᾰ_w : β → α) (ᾰ_h : right_inverse ᾰ_w f) =>\n        idRhs (surjective f) (right_inverse.surjective ᾰ_h)\n\ntheorem left_inverse_of_surjective_of_right_inverse {α : Sort u₁} {β : Sort u₂} {f : α → β}\n    {g : β → α} (surjf : surjective f) (rfg : right_inverse f g) : left_inverse f g :=\n  fun (y : β) =>\n    exists.elim (surjf y)\n      fun (x : α) (hx : f x = y) => Eq.trans (Eq.trans (hx ▸ rfl) (Eq.symm (rfg x) ▸ rfl)) hx\n\ntheorem injective_id {α : Sort u₁} : injective id := fun (a₁ a₂ : α) (h : id a₁ = id a₂) => h\n\ntheorem surjective_id {α : Sort u₁} : surjective id := fun (a : α) => Exists.intro a rfl\n\ntheorem bijective_id {α : Sort u₁} : bijective id :=\n  { left := injective_id, right := surjective_id }\n\nend function\n\n\nnamespace function\n\n\n/-- Interpret a function on `α × β` as a function with two arguments. -/\ndef curry {α : Type u₁} {β : Type u₂} {φ : Type u₃} : (α × β → φ) → α → β → φ :=\n  fun (f : α × β → φ) (a : α) (b : β) => f (a, b)\n\n/-- Interpret a function with two arguments as a function on `α × β` -/\ndef uncurry {α : Type u₁} {β : Type u₂} {φ : Type u₃} : (α → β → φ) → α × β → φ :=\n  fun (f : α → β → φ) (a : α × β) => f (prod.fst a) (prod.snd a)\n\n@[simp] theorem curry_uncurry {α : Type u₁} {β : Type u₂} {φ : Type u₃} (f : α → β → φ) :\n    curry (uncurry f) = f :=\n  rfl\n\n@[simp] theorem uncurry_curry {α : Type u₁} {β : Type u₂} {φ : Type u₃} (f : α × β → φ) :\n    uncurry (curry f) = f :=\n  sorry\n\nprotected theorem left_inverse.id {α : Type u₁} {β : Type u₂} {g : β → α} {f : α → β}\n    (h : left_inverse g f) : g ∘ f = id :=\n  funext h\n\nprotected def right_inverse.id {α : Type u₁} {β : Type u₂} {g : β → α} {f : α → β}\n    (h : right_inverse g f) : f ∘ g = id :=\n  funext h\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/function_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250375, "lm_q2_score": 0.7401743563075447, "lm_q1q2_score": 0.47683889339894037}}
{"text": "#eval [1, 2, 3].map (·, 1)\n\n#eval (·, ·) 1 2\n\n#eval (·, ·, ·) 1 2 3\n\ntheorem ex1 : [1, 2, 3].map (·, 1) = [(1, 1), (2, 1), (3, 1)] :=\n  rfl\n\ntheorem ex2 : (·, ·) 1 2 = (1, 2) :=\n  rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/cdotTuple.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4767472941672343}}
{"text": "import .regular_open_algebra .pSet_ordinal\n\n/-\n  Defining the collapsing poset/topology/boolean algebra and proving properties about them\n-/\n\nuniverse variables u v\n\nlemma poset_yoneda_iff {β : Type*} [partial_order β] {a b : β} : (∀Γ : β, Γ ≤ a → Γ ≤ b) ↔ a ≤ b :=\n⟨ lattice.poset_yoneda, λ h Γ, lattice.poset_yoneda_inv Γ h⟩\n\nlemma poset_coyoneda_iff {β : Type*} [partial_order β] {a b : β} :\n  (∀Γ : β, a ≤ Γ → b ≤ Γ) ↔ b ≤ a :=\n⟨λ h, h a (le_refl a), λ h Γ h', le_trans h h'⟩\n\nnamespace set\n\ntheorem subset_Inter_iff {α β} {t : set β} {s : α → set β} : t ⊆ (⋂ i, s i) ↔ ∀ i, t ⊆ s i :=\nby { simp [subset_def], conv_rhs { rw [forall_swap] }, apply forall_congr, intro x, rw [forall_swap] }\n\nend set\nnamespace subtype\n\ndefinition val_eq_coe {α} {p : α → Prop} (x : subtype p) : x.val = x := by refl\n\nend subtype\n\nnamespace cardinal -- todo: move\nopen cardinal set\n\ntheorem sum_const_lift (ι : Type u) (a : cardinal.{max u v}) :\n  sum (λ _:ι, a) = lift.{_ v} (mk ι) * a :=\nquotient.induction_on a $ λ α, by simp; exact\n  quotient.sound ⟨(equiv.sigma_equiv_prod _ _).trans (equiv.prod_congr equiv.ulift.symm (by refl))⟩\n\ntheorem sum_le_sup_lift {ι : Type u} (f : ι → cardinal.{max u v}) :\n  sum f ≤ lift.{_ v} (mk ι) * sup f :=\nby rw ← sum_const_lift; exact sum_le_sum _ _ (le_sup _)\n\n-- TODO: replace mk_Union_le_sum_mk\ntheorem mk_Union_le_sum_mk' {ι : Type u} {α : Type (max u v)} {f : ι → set α} :\n  mk (set.Union f) ≤ sum (λ i, mk (f i)) :=\ncalc mk (set.Union f) ≤ mk (Σ i, f i) : mk_le_of_surjective (set.surjective_sigma_to_Union f)\n  ... = sum (λ i, mk (f i)) : (sum_mk _).symm\n\nlemma mk_Union_le_lift {ι : Type u} {α : Type (max u v)} (f : ι → set α) :\n  mk (set.Union f) ≤ lift.{_ v} (mk ι) * cardinal.sup (λ i, mk (f i)) :=\nle_trans mk_Union_le_sum_mk' (sum_le_sup_lift _)\n\nend cardinal\n\nnamespace ordinal\n\nopen cardinal\n\ntheorem sup_lt_ord_lift {ι : Type u} (f : ι → ordinal.{max u v}) {c : ordinal}\n  (H1 : cardinal.lift.{_ v} (mk ι) < c.cof) (H2 : ∀ i, f i < c) : sup f < c :=\nbegin\n  apply lt_of_le_of_ne,\n  { rw [sup_le], exact λ i, le_of_lt (H2 i) },\n  rintro h, apply not_le_of_lt H1,\n  simpa [sup_ord, H2, h] using cof_sup_le_lift.{u} f\nend\n\ntheorem sup_lt_lift {ι : Type u} (f : ι → cardinal.{max u v}) {c : cardinal.{max u v}}\n  (H1 : cardinal.lift.{_ v} (cardinal.mk ι) < c.ord.cof)\n  (H2 : ∀ i, f i < c) : cardinal.sup f < c :=\nby { rw [←ord_lt_ord, ←sup_ord], apply sup_lt_ord_lift _ H1, intro i, rw ord_lt_ord, apply H2 }\n\nend ordinal\n\nnamespace topological_space\n\nlemma mem_interior_of_is_topological_basis {α} [topological_space α] {B : set (set α)}\n  (hB : is_topological_basis B) {s : set α} {x : α} : x ∈ interior s ↔ ∃ t ⊆ s, t ∈ B ∧ x ∈ t :=\nbegin\n  rw [mem_interior], split,\n  { rintro ⟨t, h1t, h2t, h3t⟩,\n    rcases mem_basis_subset_of_mem_open hB h3t h2t with ⟨u, h1u, h2u, h3u⟩,\n    exact ⟨u, set.subset.trans h3u h1t, h1u, h2u⟩ },\n  { rintro ⟨t, h1t, h2t, h3t⟩, exact ⟨t, h1t, is_open_of_is_topological_basis hB h2t, h3t⟩ }\nend\n\nend topological_space\n\nopen lattice topological_space cardinal pSet\n\nnoncomputable theory\n\nlocal notation `ℵ₁` := (card_ex $ aleph 1 : pSet)\n\nlocal infix ` ⟹ `:65 := lattice.imp\n\nlocal infix ` ⇔ `:50 := lattice.biimp\n\nlocal attribute [instance, priority 0] classical.prop_decidable\n\nlocal prefix `#`:max := cardinal.mk\n\n/- to_mathlib -/\n@[simp] lemma iff_or_self_left {p q : Prop} : (p ↔ p ∨ q) ↔ (q → p) :=\n⟨ λ h hq, h.2 (or.inr hq), λ h, ⟨or.inl, λ h', h'.elim id h⟩⟩\n\n@[simp] lemma iff_or_self_right {p q : Prop} : (p ↔ q ∨ p) ↔ (q → p) :=\nby simp [or.comm]\n\n@[simp] lemma and_iff_self_right {p q : Prop} : (p ∧ q ↔ p) ↔ (p → q) :=\n⟨ λ h hp, (h.mpr hp).2, λ h, ⟨and.left, λ hp, ⟨hp, h hp⟩⟩⟩\n\n@[simp] lemma and_iff_self_left {p q : Prop} : (p ∧ q ↔ q) ↔ (q → p) :=\nby { rw [and.comm], exact and_iff_self_right }\n\nlemma and_or_and_not {p q r : Prop} : p ∧ (q ∨ (r ∧ ¬ p)) ↔ p ∧ q :=\nby simp [and_or_distrib_left, and.comm, and.assoc.symm]\n\nlemma or_and_iff_or {p q r : Prop} : (p ∨ (q ∧ r) ↔ p ∨ q) ↔ (q → p ∨ r) :=\n⟨ λ h hq, (h.2 (or.inr hq)).imp id and.right,\n  λ h, ⟨λ h', h'.imp id and.left, λ h', h'.elim or.inl $ λ hq, (h hq).imp id $ λ hr, ⟨hq, hr⟩⟩⟩\n\nlemma and_or_iff_and {p q r : Prop} : (p ∧ (q ∨ r) ↔ p ∧ r) ↔ (p → q → r) :=\n⟨ λ h hp hq, (h.mp ⟨hp, or.inl hq⟩).2,\n  λ h, ⟨λ h', ⟨h'.1, h'.2.elim (h h'.1) id⟩, and.imp id or.inr⟩⟩\n\nlemma or_not_iff (p q : Prop) [decidable q] : (p ∨ ¬ q) ↔ (q → p) :=\nby { rw [imp_iff_not_or, or_comm] }\n\nlemma eq_iff_eq_of_eq_left {α} {x y z : α} (h : x = y) : x = z ↔ y = z :=\nby rw [h]\n\nlemma eq_iff_eq_of_eq_right {α} {x y z : α} (h : x = y) : z = x ↔ z = y :=\nby rw [h]\n\nnamespace roption\n\nvariables {α : Type*} {o₁ o₂ : roption α} {x : α}\n/-- The intersection of two partial functions -/\ndef inter (o₁ o₂ : roption α) : roption α :=\n⟨ ∃(x : α), x ∈ o₁ ∧ x ∈ o₂,\n  λ h, o₁.get $ dom_iff_mem.2 $ let ⟨x, h1x, h2x⟩ := h in ⟨x, h1x⟩⟩\n\ninstance : has_inter (roption α) := ⟨roption.inter⟩\n\nlemma dom_inter : (o₁ ∩ o₂).dom ↔ ∃(x : α), x ∈ o₁ ∧ x ∈ o₂ := iff.refl _\nlemma get_inter (h : ∃(x : α), x ∈ o₁ ∧ x ∈ o₂) :\n  ∃(h' : o₁.dom), (o₁ ∩ o₂).get h = o₁.get h' := ⟨_, rfl⟩\n\n@[simp] lemma mem_inter : x ∈ o₁ ∩ o₂ ↔ x ∈ o₁ ∧ x ∈ o₂ :=\nbegin\n  split,\n  { intro h, rw [mem_eq] at h, rcases h with ⟨⟨x, h1x, h2x⟩, rfl⟩,\n    cases get_inter ⟨x, h1x, h2x⟩ with _h h2, rw [h2],\n    split, { apply get_mem },\n    rw [mem_eq] at h1x, rw [mem_eq] at h2x, cases h1x with _h2 h1x,\n    cases h2x with _h3 h2x, rw [h1x, ← h2x], apply get_mem },\n  { rintro ⟨h1, h2⟩, use ⟨x, h1, h2⟩,\n    cases get_inter ⟨x, h1, h2⟩ with _h h3, rw [h3],\n    rw [mem_eq] at h1, cases h1 with _h2 h1, exact h1 }\nend\n\nend roption\n\nnamespace pfun\n\nvariables {ι : Sort*} {α : Type*} {β : Type*} {f f₁ f₂ : α →. β}\n\nlemma mem_dom_iff_dom (f : α →. β) (x : α) : x ∈ dom f ↔ (f x).dom :=\nby simp [dom, set.mem_def]\n\nlemma mem_dom_of_mem {f : α →. β} {x : α} {y : β} (h : y ∈ f x) : x ∈ dom f :=\n(mem_dom f x).2 ⟨y, h⟩\n\nlemma some_fn {f : α →. β} {x : α} (h : x ∈ f.dom) : roption.some (f.fn x h) = f x :=\nroption.some_get h\n\nlemma fn_mem {f : α →. β} {x : α} (h : x ∈ f.dom) : f.fn x h ∈ f x :=\nroption.get_mem h\n\nlemma mem_iff_fn_eq {x : α} {y : β} : y ∈ f x ↔ ∃ h : x ∈ f.dom, f.fn x h = y :=\nby refl\n\nlemma fn_eq_iff_mem {x : α} {y : β} (h : x ∈ f.dom) : f.fn x h = y ↔ y ∈ f x :=\nby simp [mem_iff_fn_eq, h]\n\nlemma fn_eq_of_mem {x : α} {y : β} (h1 : y ∈ f x) (h2 : x ∈ f.dom) : f.fn x h2 = y :=\n(fn_eq_iff_mem h2).2 h1\n\n/- more on lift -/\n\nlemma mem_lift {f : α → β} {x : α} {y : β} : y ∈ (f : α →. β) x ↔ f x = y :=\nby simp [eq_comm]\n\nlemma lift_eq_some_iff {f : α → β} {x : α} {y : β} : (f : α →. β) x = roption.some y ↔ f x = y :=\nby simp\n\n@[simp] lemma fn_lift (f : α → β) (x : α) : (f : α →. β).fn x trivial = f x :=\nby simp [fn_eq_iff_mem]\n\n/-- The empty partial function -/\ndef empty : α →. β := λ x, roption.none\n\n@[simp] lemma dom_empty : (empty : α →. β).dom = ∅ := rfl\n@[simp] lemma empty_def (x : α) : (empty : α →. β) x = none := rfl\nlemma not_mem_empty (x : α) (y : β) : y ∉ (pfun.empty : α →. β) x := roption.not_mem_none _\n\n/- Two partial functions are equal if their graphs are equal -/\nlemma ext_graph {α β : Type*} (f g : α →. β) (h_graph : f.graph = g.graph) : f = g :=\n  pfun.ext $ λ _ _, iff_of_eq $ congr_fun h_graph (_,_)\n\nlemma graph_empty_iff_dom_empty {α β : Type*} (f : α →. β) : f.graph = ∅ ↔ f.dom = ∅ :=\nbegin\n  have := dom_iff_graph f,\n  split; intro; ext; safe, exact this _ _ ‹_›\nend\n\n/-- A functional graph is a univalent graph -/\ndef functional {α β : Type*} (Γ : set (α × β)) : Prop :=\n  ∀ a b₁ b₂, (a, b₁) ∈ Γ → (a, b₂) ∈ Γ → b₁ = b₂\n\nlemma congr_arg {α β : Type*} (f : α →. β) : ∀ {x} {y} (h₁ : x ∈ f.dom) (h₂ : y ∈ f.dom)\n  (h_eq : x = y), fn f x h₁ = fn f y h₂ :=\nby intros; congr; assumption\n\nlemma functional_subset {α β : Type*} (Γ Γ': set (α × β)) (h_Γ' : Γ' ⊆ Γ) (h_Γ : functional Γ) : functional Γ' :=\n  λ _ _ _ _ _, by apply h_Γ; tidy\n\n/-- The graph of a pfun is always functional -/\nlemma graph_functional {α β : Type*} (f : α →. β) : functional f.graph := by tidy\n\n/-- Given a partial functional relation, turn it into a pfun -/\nnoncomputable def of_graph {α β : Type*} (Γ : set (α × β)) (h_Γ : functional Γ) : α →. β :=\n  λ a, ⟨∃ c ∈ Γ, (prod.fst c) = a, λ h, @prod.snd α β $ (classical.indefinite_description _ h).val⟩\n\nlemma of_graph_property {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) (a : α) (h : ∃ c ∈ Γ, (prod.fst c) = a) : ∃ (H : Γ (classical.indefinite_description _ h)), (classical.indefinite_description _ h).val.fst = a :=\n  by apply (classical.indefinite_description _ h).property\n\nlemma of_graph_get {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) (a : α) : ∀ h,\n(of_graph Γ h_Γ a).get h = (classical.indefinite_description _ h).val.snd :=\n  by intro; refl\n\nlemma of_graph_val {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) (a : α) (h : ∃ c ∈ Γ, (prod.fst c) = a) (c' ∈ Γ) (h' : c'.1 = a) :\n  @prod.snd α β (classical.indefinite_description _ h).val = c'.snd :=\nbegin\n  let c'', swap, change (prod.snd c'' = c'.snd),\n  apply h_Γ a, swap, convert H, ext, rwa[h'], refl,\n  have := (classical.indefinite_description _ h).property,\n  cases this with this1 this2, rw [<-this2], convert this1, ext; refl\nend\n\n@[simp] lemma graph_of_graph {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) : (of_graph Γ h_Γ).graph = Γ :=\nbegin\n  ext, rcases x with ⟨a,b⟩, dsimp[graph],\n  split; intro H, {cases H, induction H_h, cases H_w, cases H_w_h, induction H_w_h_h,\n  convert H_w_h_w, ext, refl, rw [of_graph_get], apply of_graph_val; try{assumption}; refl},\n  fsplit, {tidy}, rw [of_graph_get], apply @of_graph_val _ _ Γ _ a _ (a,b) _;\n  try{assumption}; refl\nend\n\n@[simp] lemma of_graph_graph {α β : Type*} {f : α →. β} : of_graph (f.graph) (graph_functional f) = f :=\n  by apply ext_graph; rw [graph_of_graph]\n\n@[simp] lemma dom_of_graph {α β : Type*} (Γ : set $ α × β) (h_Γ : functional Γ) : (of_graph Γ h_Γ).dom = (prod.fst '' Γ) :=\nbegin\n ext, split; intros, {tidy},\n {cases a, cases a_h, cases a_w, induction a_h_right, dsimp at *, fsplit,\n work_on_goal 0 { fsplit }, work_on_goal 2 {fsplit,\n work_on_goal 0 { assumption }, refl }}\nend\n\n@[simp] lemma dom_of_graph_union {α β : Type*} (Γ : set $ α × β) (p : α × β) (h_Γ : functional Γ) (h_Γ' : functional $ Γ ∪ {p}) : (of_graph (Γ ∪ {p}) h_Γ').dom = (of_graph Γ h_Γ).dom ∪ {p.fst} :=\n  by simp[dom_of_graph, set.image_insert_eq]\n\nlemma in_dom_of_in_graph {α β : Type*} {f : α →. β} : ∀ {a} {b}, (a,b) ∈ f.graph → a ∈ f.dom :=\n  by {intros a b H, apply (pfun.dom_iff_graph _ a).mpr, exact ⟨b,H⟩}\n\nlemma lift_graph' {α β : Type*} {f : α →. β} {a : α} {b : β} (h_a : a ∈ f.dom) : (a,b) ∈ f.graph ↔ pfun.fn f a h_a = b := by tidy\n\n/-- The intersection of two partial functions -/\ndef inter (f₁ f₂ : α →. β) : α →. β :=\nλ x, f₁ x ∩ f₂ x\n\ninstance : has_inter (α →. β) := ⟨pfun.inter⟩\n\n@[simp] lemma mem_inter {x : α} {y : β} : y ∈ (f₁ ∩ f₂) x ↔ y ∈ f₁ x ∧ y ∈ f₂ x :=\nroption.mem_inter\n\n/-- f₁ is a subset, or subfunction of f₂: if `f₁ x = some y` then `f₂ x = some y` -/\ndef subfun (f₁ f₂ : α →. β) : Prop := ∀ x y, y ∈ f₁ x → y ∈ f₂ x\n\ninstance : partial_order (α →. β) :=\n{ le := subfun,\n  le_refl := λ f x y hy, hy,\n  le_trans := λ f g h hfg hgh x y hy, hgh x y (hfg x y hy),\n  le_antisymm := λ f g h1 h2, pfun.ext $ λ x y, ⟨h1 x y, h2 x y⟩ }\n\ninstance : semilattice_inf_bot (α →. β) :=\n{ le := subfun,\n  le_refl := λ f x y hy, hy,\n  le_trans := λ f g h hfg hgh x y hy, hgh x y (hfg x y hy),\n  le_antisymm := λ f g h1 h2, pfun.ext $ λ x y, ⟨h1 x y, h2 x y⟩,\n  bot := pfun.empty,\n  bot_le := λ f x y hy, false.elim $ roption.not_mem_none y hy,\n  inf := pfun.inter,\n  inf_le_left := λ f g x y hy, (mem_inter.1 hy).1,\n  inf_le_right := λ f g x y hy, (mem_inter.1 hy).2,\n  le_inf := λ f g h hfg hfh x y hf, mem_inter.2 ⟨hfg x y hf, hfh x y hf⟩ }\n\nlemma le_def : f₁ ≤ f₂ ↔ ∀ x y, y ∈ f₁ x → y ∈ f₂ x := by refl\n\nlemma dom_subset_dom_of_le (h : f₁ ≤ f₂) : f₁.dom ⊆ f₂.dom :=\nλ x hx, mem_dom_of_mem (h x (f₁.fn x hx) (fn_mem hx))\n\nlemma eq_some_of_subfun (h : f₁ ≤ f₂) {x : α} {y : β} (h1 : f₁ x = roption.some y) :\n  f₂ x = roption.some y :=\nby { rw [roption.eq_some_iff] at h1 ⊢, exact h x y h1 }\n\nlemma fn_eq_of_subfun (h : f₁ ≤ f₂) {x : α} {y : β} (h1 : x ∈ f₁.dom)\n  (h2 : f₁.fn x h1 = y) (h3 : x ∈ f₂.dom) : f₂.fn x h3 = y :=\nby { apply fn_eq_of_mem, apply h, rw [mem_iff_fn_eq], exact ⟨h1, h2⟩ }\n\nlemma le_lift {f : α →. β} {g : α → β} : f ≤ (g : α →. β) ↔ ∀ x y, y ∈ f x → g x = y :=\nby simp [le_def, eq_comm]\n\n/-- Two functions are compatible if they agree on the intersection of their domains. -/\ndef compatible (f₁ f₂ : α →. β) : Prop :=\n∀(x : α), x ∈ f₁.dom → x ∈ f₂.dom → f₁ x = f₂ x\n\nlemma compatible_def : compatible f₁ f₂ ↔ ∀(x : α), x ∈ f₁.dom → x ∈ f₂.dom → f₁ x = f₂ x :=\nby refl\n\nlemma mem_of_compatible (h : compatible f₁ f₂) {x : α} {y : β} (h1 : y ∈ f₁ x) (h2 : x ∈ f₂.dom) :\n  y ∈ f₂ x :=\nby { convert h1, symmetry, exact h x (mem_dom_of_mem h1) h2 }\n\n@[refl] lemma compatible_refl : compatible f f := λ x h1x h2x, rfl\n\nlemma compatible_comm : compatible f₁ f₂ ↔ compatible f₂ f₁ :=\nby { simp [compatible_def, eq_comm, imp.swap] }\n\nlemma compatible_of_le (h : f₁ ≤ f₂) : compatible f₁ f₂ :=\nbegin\n  intros x h1x h2x, apply roption.ext, intro y, split; intro hy, exact h x y hy,\n  have := h x (f₁.fn x h1x) (fn_mem h1x),\n  convert fn_mem h1x,\n  rw [← roption.some_inj, ← roption.eq_some_iff.2 hy, ← roption.eq_some_iff.2 this]\nend\n\n/-- The sup of two functions f₁ and f₂. Corresponds to the set-theoretic union of f₁ and f₂ as\n  long as f₁ and f₂ are compatible. If they are not compatible, the values of f₁ are chosen when\n  both functions are defined. We use classical logic, so that we can define a has_sup instance\n  (otherwise we would need to assume that `f₁.dom` is decidable). -/\ndef sup (f₁ f₂ : α →. β) : α →. β :=\nλ a, if a ∈ f₁.dom then f₁ a else f₂ a\n\ninstance : has_sup (α →. β) := ⟨pfun.sup⟩\n\n@[simp] lemma sup_eq_of_mem {x : α} (h : x ∈ f₁.dom) : (f₁ ⊔ f₂) x = f₁ x :=\nby { dsimp [pfun.lattice.has_sup, pfun.sup], simp [h] }\n\n@[simp] lemma sup_eq_of_nmem {x : α} (h : x ∉ f₁.dom) : (f₁ ⊔ f₂) x = f₂ x :=\nby { dsimp [pfun.lattice.has_sup, pfun.sup], simp [h] }\n\n@[simp] lemma dom_sup (f₁ f₂ : α →. β) : (f₁ ⊔ f₂).dom = f₁.dom ∪ f₂.dom :=\nby { ext x, by_cases hx : x ∈ f₁.dom; simp [mem_dom_iff_dom] at hx; simp [mem_dom_iff_dom, hx] }\n\nlemma subset_dom_sup_left (f₁ f₂ : α →. β) : f₁.dom ⊆ (f₁ ⊔ f₂).dom := by simp\nlemma subset_dom_sup_right (f₁ f₂ : α →. β) : f₂.dom ⊆ (f₁ ⊔ f₂).dom := by simp\n\nlemma mem_sup {x : α} {y : β} : y ∈ (f₁ ⊔ f₂) x ↔ y ∈ f₁ x ∨ (y ∈ f₂ x ∧ x ∉ f₁.dom) :=\nbegin\n  by_cases hx : x ∈ f₁.dom, { simp [hx] },\n  have := hx, rw [mem_dom] at this, push_neg at this, simp [hx, this]\nend\n\nlemma mem_sup_of_compatible {x : α} {y : β} (h : compatible f₁ f₂) :\n  y ∈ (f₁ ⊔ f₂) x ↔ y ∈ f₁ x ∨ y ∈ f₂ x :=\nbegin\n  rw [mem_sup, or_and_iff_or, or_not_iff],\n  intros hy hx, convert hy, exact h x hx (mem_dom_of_mem hy),\nend\n\nlemma sup_restrict_left {f₁ f₂ : α →. β} :\n  (f₁ ⊔ f₂).restrict (subset_dom_sup_left f₁ f₂) = f₁ :=\nbegin\n  apply pfun.ext, intros x y, simp [mem_sup, and_or_and_not],\n  show y ∈ f₁ x → x ∈ dom f₁, rw [mem_dom], intro hy, exact ⟨y, hy⟩\nend\n\nlemma sup_restrict_right {f₁ f₂ : α →. β} (h : compatible f₁ f₂) :\n  (f₁ ⊔ f₂).restrict (subset_dom_sup_right f₁ f₂) = f₂ :=\nbegin\n  apply pfun.ext, intros x y, simp [mem_sup_of_compatible h],\n  rw [and_or_iff_and.2, and_iff_self_left], apply mem_dom_of_mem,\n  intros hx hy, convert hy, symmetry, exact h x (mem_dom_of_mem hy) hx\nend\n\nlemma le_sup_left (f₁ f₂ : α →. β) : f₁ ≤ f₁ ⊔ f₂ :=\nby { intros x y hy, rw [mem_sup], exact or.inl hy }\n\nlemma le_sup_right (h : compatible f₁ f₂) : f₂ ≤ f₁ ⊔ f₂ :=\nby { intros x y hy, rw [mem_sup_of_compatible h], exact or.inr hy }\n\n/-- The indexed sup of a family of partial functions. This corresponds to the set-theoretic union\n  if the functions are pairwise compatible. Otherwise, the value of a function will be chosen using\n  classical.some. -/\ndef Sup (f : ι → α →. β) : α →. β :=\nλ x, if h : ∃ i, x ∈ dom (f i) then f (classical.some h) x else roption.none\n\n-- TODO: define Sup instance\n\nlemma Sup_helper {f : ι → α →. β} {x : α} :\n  (∃i, x ∈ (f i).dom) ↔ (∃i, x ∈ (f i).dom ∧ Sup f x = f i x) :=\n⟨λ h, ⟨classical.some h, classical.some_spec h, dif_pos h⟩, λ⟨i, h, _⟩, ⟨i, h⟩⟩\n\nlemma Sup_helper2 {f : ι → α →. β} {x : α} :\n  (∃i, x ∈ (f i).dom) ↔ (∃i (h : x ∈ (f i).dom), Sup f x = roption.some ((f i).fn x h)) :=\nbegin\n  rw [Sup_helper], apply exists_congr, intro i,\n  rw [← exists_prop], apply exists_congr, intro hi,\n  apply eq_iff_eq_of_eq_right, rw [some_fn hi]\nend\n\n@[simp] lemma dom_Sup (f : ι → α →. β) : (Sup f).dom = set.Union (λ (i : ι), (f i).dom) :=\nbegin\n  ext x, rw [set.mem_Union], by_cases hx : ∃i, x ∈ (f i).dom,\n  { simp only [hx, iff_true], rw [Sup_helper2] at hx, rcases hx with ⟨i, hx, h⟩,\n    rw [mem_dom_iff_dom, h], trivial },\n  { simp only [hx, iff_false], rw [mem_dom_iff_dom], dsimp [Sup], rw [dif_neg hx], exact id }\nend\n\nlemma subset_dom_Sup (f : ι → α →. β) (i : ι) : (f i).dom ⊆ (Sup f).dom :=\nby { rw [dom_Sup], apply set.subset_Union (λ i, (f i).dom) }\n\nlemma Sup_eq_of_mem {f : ι → α →. β} {x : α} {i : ι} (hf : ∀i j, compatible (f i) (f j))\n  (h : x ∈ (f i).dom) : Sup f x = f i x :=\nbegin\n  have : ∃ i, x ∈ (f i).dom := ⟨i, h⟩, rw [Sup_helper] at this, rcases this with ⟨j, hj, h2j⟩,\n  rw [h2j], exact hf j i x hj h\nend\n\nlemma Sup_eq_of_nmem {f : ι → α →. β} {x : α} (h : ∀ i, x ∉ (f i).dom) :\n  Sup f x = roption.none :=\nby { dsimp [pfun.Sup], simp [h] }\n\nlemma mem_Sup {f : ι → α →. β} {x : α} {y : β} (hf : ∀i j, compatible (f i) (f j)) :\n  y ∈ Sup f x ↔ ∃ i, y ∈ f i x :=\nbegin\n  split,\n  { intro hy, have := mem_dom_of_mem hy, rw [dom_Sup, set.mem_Union] at this,\n    cases this with i hi, use i, rwa [Sup_eq_of_mem hf hi] at hy },\n  { rintro ⟨i, hi⟩, rwa [Sup_eq_of_mem hf (mem_dom_of_mem hi)] }\nend\n\nlemma Sup_restrict {f : ι → α →. β} (hf : ∀i j, compatible (f i) (f j)) (i : ι) :\n  (Sup f).restrict (subset_dom_Sup f i) = f i :=\nbegin\n  apply pfun.ext, intros x y, simp [mem_Sup hf],\n  split,\n  { rintro ⟨hx, j, hj⟩, exact mem_of_compatible (hf j i) hj hx },\n  { intro hy, exact ⟨mem_dom_of_mem hy, i, hy⟩ }\nend\n\nlemma le_Sup {f : ι → α →. β} (hf : ∀i j, compatible (f i) (f j)) (i : ι) : f i ≤ Sup f :=\nby { intros x y hy, rw [mem_Sup hf], exact ⟨i, hy⟩ }\n\nlemma Sup_le {f : ι → α →. β} (hf : ∀i j, compatible (f i) (f j))\n  {g : α →. β} : Sup f ≤ g ↔ ∀i, f i ≤ g :=\nbegin\n  simp only [le_def, mem_Sup hf, exists_imp_distrib],\n  conv_rhs { rw [forall_swap] }, apply forall_congr, intro x, rw [forall_swap]\nend\n\nlemma fn_mem_ran {X Y} {f : X →. Y} {x : X} {Hx : x ∈ f.dom} :\n  (fn f x Hx) ∈ f.ran :=\nby use x; tidy\n\nlemma mk_ran_le_mk_dom {α β : Type u} (f : α →. β) : # f.ran ≤ # f.dom :=\nbegin\n  refine mk_le_of_surjective _,\n  { exact λ ⟨x,H⟩, ⟨fn f x H, by apply fn_mem_ran⟩},\n  { intros y, by_contra, push_neg at a,\n  /- `tidy` says -/ cases y, cases y_property, cases y_property_h,\n    induction y_property_h_h, simp at *, dsimp at *,\n    specialize a ‹_› ‹_›, finish }\nend\n\n/-- A partial function with one element in its domain.\n  Note, this is a component of `pequiv.single` in a newer version of mathlib\n  -/\ndef singleton (x : α) (y : β) : α →. β :=\nλ a, { dom := a = x, get := λ _, y }\n\n@[simp] lemma fn_singleton {x x' : α} {y : β} (H_a : x' = x) :\n  fn (singleton x y) x' H_a = y := by refl\n\n@[simp] lemma mem_singleton {x x' : α} {y y' : β} :\n  y' ∈ singleton x y x' ↔ x = x' ∧ y = y' :=\nbegin\n  split,\n  { intro h, rw [roption.mem_eq] at h, rcases h with ⟨h, rfl⟩, exact ⟨h.symm, rfl⟩ },\n  { rintro ⟨rfl, rfl⟩, exact ⟨rfl, rfl⟩ }\nend\n\n@[simp] lemma singleton_eq_some {x : α} {y : β} : singleton x y x = roption.some y :=\nby simp [roption.eq_some_iff]\n\n@[simp] lemma dom_singleton {x : α} {y : β} : (singleton x y).dom = {x} :=\nby { ext x', simp [singleton, mem_dom_iff_dom] }\n\nlemma mk_dom_singleton {x : α} {y : β} : # (singleton x y).dom = 1 := by simp\n\n/-- Extend `f` using `g` for all values where `f` is undefined -/\nnoncomputable def extend_via (f : α →. β) (g : α → β) : α → β :=\nλ x, if hx : x ∈ f.dom then f.fn x hx else g x\n\nlemma extend_via_pos {f : α →. β} {g : α → β} {x : α} (h : x ∈ f.dom) :\n  extend_via f g x = f.fn x h :=\nby simp [h, extend_via]\n\nlemma extend_via_neg {f : α →. β} {g : α → β} {x : α} (h : x ∉ f.dom) :\n  extend_via f g x = g x :=\nby simp [h, extend_via]\n\nlemma le_extend_via (f : α →. β) (g : α → β) : f ≤ ↑(extend_via f g) :=\nλ x y hy, by { simp [mem_dom_of_mem hy, extend_via], symmetry, rwa [fn_eq_iff_mem] }\n\n/--\nGiven a partial function f : X →. Y and a point y : Y, define an extension g of f to X such that g(x) = y whenever x ∉ f.dom\n-/\nnoncomputable def trivial_extension (f : α →. β) (y : β) : α → β :=\nextend_via f (λ _, y)\n\nlemma trivial_extension_pos {f : α →. β} {y : β} {x : α} (h : x ∈ f.dom) :\n  trivial_extension f y x = f.fn x h :=\nextend_via_pos h\n\nlemma trivial_extension_neg {f : α →. β} {y : β} {x : α} (h : x ∉ f.dom) :\n  trivial_extension f y x = y :=\nextend_via_neg h\n\nlemma le_trivial_extension (f : α →. β) (y : β) : f ≤ ↑(trivial_extension f y) :=\nle_extend_via _ _\n\nend pfun\n\nsection collapse_poset\n\nstructure collapse_poset (X Y : Type u) (κ : cardinal.{u}) : Type u :=\n(f        : X →. Y)\n(Hc       : #f.dom < κ)\n\ndef collapse_poset.empty {α β : Type u} {κ : cardinal} (h : 0 < κ) : collapse_poset α β κ :=\n{ f := pfun.empty,\n  Hc := by simp [h] }\n\nopen pfun\n\nvariables {X Y : Type u} {κ : cardinal.{u}}\n\nlemma collapse_poset.mk_ran_lt (p : collapse_poset X Y κ) : # p.f.ran < κ :=\nlt_of_le_of_lt (mk_ran_le_mk_dom p.f) p.Hc\n\ndef collapse_poset.inter (p₁ p₂ : collapse_poset X Y κ) : collapse_poset X Y κ :=\n{ f := p₁.f ⊓ p₂.f,\n  Hc := lt_of_le_of_lt (mk_le_mk_of_subset $ dom_subset_dom_of_le inf_le_left) p₁.Hc }\n\nnoncomputable def collapse_poset.union (p₁ p₂ : collapse_poset X Y κ) (h : omega ≤ κ) :\n  collapse_poset X Y κ :=\n{ f := p₁.f ⊔ p₂.f,\n  Hc := by { rw [dom_sup],\n             exact lt_of_le_of_lt cardinal.mk_union_le (cardinal.add_lt_of_lt h p₁.Hc p₂.Hc) } }\n\nlemma exists_mem_compl_dom_of_unctbl (p : collapse_poset X Y κ) (H_card : κ ≤ #X) :\n  ∃ x : X, x ∉ p.f.dom :=\nexists_mem_compl_of_mk_lt_mk _ $ lt_of_lt_of_le p.Hc H_card\n\nlemma exists_mem_compl_ran_of_unctbl (p : collapse_poset X Y κ) (H_card : κ ≤ #Y) :\n  ∃ y : Y, y ∉ p.f.ran :=\nexists_mem_compl_of_mk_lt_mk _ $ lt_of_lt_of_le (collapse_poset.mk_ran_lt p) H_card\n\ndef collapse_poset.principal_open (p : collapse_poset X Y κ) : set (X → Y) :=\n{f | p.f ≤ (f : X →. Y)}\n\n@[simp] lemma collapse_poset.principal_open_empty (h : 0 < κ) :\n  collapse_poset.principal_open (collapse_poset.empty h : collapse_poset X Y κ) = set.univ :=\nbegin\n  ext f, split; intro H,\n  { trivial },\n  { tidy }\nend\n\nlemma mem_principal_open_iff {p : collapse_poset X Y κ} {f : X → Y} :\n  f ∈ collapse_poset.principal_open p ↔ ∀ x y, y ∈ p.f x → f x = y :=\nle_lift\n\nlemma mem_principal_open_iff' {p : collapse_poset X Y κ} {f : X → Y} :\n  f ∈ collapse_poset.principal_open p ↔ ∀ (x : X) (H_x : x ∈ p.f.dom), f x = fn p.f x H_x :=\nbegin\n  rw [mem_principal_open_iff], apply forall_congr, intro x,\n  split,\n  { intros H Hx, apply H, apply fn_mem },\n  { intros H y hy, rw [H $ mem_dom_of_mem hy], apply fn_eq_of_mem hy }\nend\n\nlemma mem_compl_principal_open_iff {p : collapse_poset X Y κ} {f : X → Y} :\n  f ∈ - collapse_poset.principal_open p ↔ ∃x (H_x : x ∈ p.f.dom), f x ≠ fn p.f x H_x :=\nby { rw [set.mem_compl_iff, mem_principal_open_iff'], push_neg }\n\n@[simp] lemma mem_ran_of_mem_dom {p : collapse_poset X Y κ} {f : X → Y} {x : X}\n  (H : f ∈ collapse_poset.principal_open p) : x ∈ p.f.dom → f x ∈ p.f.ran :=\nby { intro H_mem, rw [mem_principal_open_iff] at H,\n     use x, rw [H x (p.f.fn x H_mem) (fn_mem _)], exact roption.get_mem H_mem }\n\ndef collapse_poset.Sup {ι : Type u} (p : ι → collapse_poset X Y κ) (h : #ι < (ord κ).cof)\n  (hκ : cardinal.omega ≤ κ) : collapse_poset X Y κ :=\n⟨Sup $ λ i, (p i).f,\n  begin\n    rw [dom_Sup], apply lt_of_le_of_lt (mk_Union_le _) _,\n    apply mul_lt_of_lt hκ (lt_of_lt_of_le h (ordinal.cof_ord_le κ)),\n    exact ordinal.sup_lt _ h (λ i, collapse_poset.Hc _)\n  end⟩\n\ndef collapse_poset.Sup_lift {ι : Type u} {X Y : Type (max u v)} {κ : cardinal.{max u v}}\n  (p : ι → collapse_poset X Y κ)\n  (h : cardinal.lift.{_ v} #ι < (ord κ).cof)\n  (hκ : cardinal.omega ≤ κ) : collapse_poset X Y κ :=\n⟨Sup $ λ i, (p i).f,\n  begin\n    rw [dom_Sup], apply lt_of_le_of_lt (mk_Union_le_lift.{u v} _) _,\n    apply mul_lt_of_lt hκ (lt_of_lt_of_le h (ordinal.cof_ord_le κ)),\n    refine ordinal.sup_lt_lift _ h (λ i, collapse_poset.Hc _)\n  end⟩\n\ndef collapse_space : topological_space (X → Y) :=\ngenerate_from $\n  (collapse_poset.principal_open : collapse_poset X Y cardinal.omega.succ → set (X → Y)) '' set.univ\n\nlocal attribute [instance, priority 9001, reducible] collapse_space\n\n@[simp] lemma collapse_poset.principal_open_is_open {p : collapse_poset X Y cardinal.omega.succ} :\n  is_open (collapse_poset.principal_open p) :=\ngenerate_open.basic _ $ set.mem_image_of_mem _ trivial\n\nlemma one_lt_omega_succ : 1 < cardinal.omega.succ :=\nlt_trans one_lt_omega (cardinal.lt_succ_self _)\n\nlemma zero_lt_omega_succ : 0 < cardinal.omega.succ :=\nlt_trans cardinal.zero_lt_one one_lt_omega_succ\n\nopen collapse_poset\n\ndef singleton_collapse_poset (x : X) (y : Y) (hκ : 1 < κ) : collapse_poset X Y κ :=\n{ f := singleton x y,\n  Hc := by simp [hκ] }\n\n@[simp] lemma singleton_collapse_poset_principal_open {x : X} {y : Y} {hκ : 1 < κ} :\n  principal_open (singleton_collapse_poset x y hκ) = {g : X → Y | g x = y} :=\nbegin\n  ext f, refine ⟨_,_⟩; intro H,\n    { rw mem_principal_open_iff at H,\n      apply H, finish[singleton_collapse_poset] },\n    { tidy }\nend\n\nlemma collapse_poset.compl_principal_open_is_Union (hκ : 1 < κ) (p : collapse_poset X Y κ) :\n  ∃ {ι : Type u} (s : ι → collapse_poset X Y κ),\n    set.Union (λ i : ι, principal_open $ s i) = - principal_open p :=\nbegin\n  use {pr : X × Y // ∃ H_mem : pr.1 ∈ p.f.dom, pr.2 ≠ fn p.f pr.1 H_mem },\n  use (λ s, singleton_collapse_poset s.1.1 s.1.2 hκ),\n  ext f, split; intro H,\n    { intro H_mem,\n      rcases H with ⟨P, ⟨⟨⟨x',y'⟩, ⟨H_mem₁, H_neq⟩⟩, rfl⟩, H_mem₂⟩,\n      dsimp at H_neq H_mem₂,\n      apply H_neq,\n      rw [← show f x' = y', by simpa using H_mem₂],\n      rw mem_principal_open_iff'.mp H_mem _ _ },\n    { rw [mem_compl_principal_open_iff] at H, rcases H with ⟨x, Hx, H_neq⟩,\n      suffices this : ∃ (a : X) (H_mem : (a, f a).fst ∈ dom (p.f)), ¬f a = fn (p.f) a H_mem,\n      { simp [this] },\n      exact ⟨_, by use ‹_›⟩ }\nend\n\n@[simp] lemma collapse_poset.principal_open_is_closed {p : collapse_poset X Y cardinal.omega.succ} :\n  is_closed (collapse_poset.principal_open p) :=\nby { rcases collapse_poset.compl_principal_open_is_Union one_lt_omega_succ p with ⟨ι, ⟨s, Hu⟩⟩,\n     rw [is_closed, ← Hu], simp [is_open_Union] }\n\n@[simp] lemma collapse_poset.is_regular_principal_open\n  (p : collapse_poset X Y cardinal.omega.succ) : is_regular (collapse_poset.principal_open p) :=\nby simp [is_clopen]\n\nlemma inter_principal_open (hκ : omega ≤ κ) {p₁ p₂ : collapse_poset X Y κ}\n  (H : compatible p₁.f p₂.f) :\n  principal_open p₁ ∩ principal_open p₂ = principal_open (p₁.union p₂ hκ) :=\nbegin\n  ext f,\n  simp [mem_principal_open_iff],\n  rw [← forall_and_distrib], apply forall_congr, intro x,\n  rw [← forall_and_distrib], apply forall_congr, intro y,\n  rw [union, mem_sup_of_compatible H, or_imp_distrib]\nend\n\nvariables (X Y)\ndef collapse_space_basis : set $ set (X → Y) :=\ninsert (∅ : set (X → Y))\n  (collapse_poset.principal_open '' (set.univ : set (collapse_poset X Y cardinal.omega.succ)))\n\nvariables {X Y}\ndef collapse_space_basis_spec : is_topological_basis (collapse_space_basis X Y) :=\nbegin\n  refine ⟨λ P HP P' HP' f H_mem_inter, _,_,_⟩,\n    { rw [collapse_space_basis] at HP HP',\n      cases HP; cases HP',\n\n      { suffices this : f ∈ (∅ : set $ X → Y),\n          by {cases this}, substs HP, cases H_mem_inter, exact ‹_› },\n      { suffices this : f ∈ (∅ : set $ X → Y),\n          by {cases this}, substs HP, cases H_mem_inter, exact ‹_› },\n      { suffices this : f ∈ (∅ : set $ X → Y),\n          by {cases this}, substs HP', cases H_mem_inter, exact ‹_› },\n\n      simp only [set.image_univ, set.mem_range] at HP HP',\n      cases HP with y Hy; cases HP' with y' Hy',\n\n      substs Hy Hy', use (principal_open y ∩ principal_open y'),\n      refine ⟨_,⟨‹_›,(by refl)⟩⟩,\n      { by_cases H_compat : compatible y.f y'.f,\n        { right, refine ⟨_,⟨trivial, _⟩⟩, exact y.union y' (le_of_lt (lt_succ_self _)),\n        rwa [inter_principal_open] },\n        { suffices this : principal_open y ∩ principal_open y' = ∅,\n            by {rw [this], exact or.inl rfl },\n          ext g; split; intro H,\n            { exfalso, cases H with H₁ H₂, rw [mem_principal_open_iff] at H₁ H₂,\n              rw [compatible] at H_compat,\n              push_neg at H_compat, rcases H_compat with ⟨x, Hx₁, Hx₂, Hx₃⟩,\n              apply Hx₃, rw [← some_fn Hx₁, ← some_fn Hx₂],\n              rw [← H₁ x _ (fn_mem Hx₁), ← H₂ x _ (fn_mem Hx₂)] },\n            { cases H }}}},\n\n    { refine le_antisymm (λ _ _, trivial) _,\n      intros f _a, refine ⟨_,_⟩,\n      { exact (principal_open (collapse_poset.empty zero_lt_omega_succ)) },\n      { refine ⟨by {rw [collapse_space_basis], right, exact set.mem_image_univ},_⟩, simp }},\n    { unfold collapse_space_basis collapse_space, refine le_antisymm _ _,\n      { intros T HT, induction HT,\n        { cases HT_H, subst HT_H, exact is_open_empty, constructor, exact ‹_› },\n        { exact is_open_univ },\n        { apply generate_open.inter, exact ‹_›, exact ‹_› },\n        { apply generate_open.sUnion, intros S HS, solve_by_elim }},\n      { refine generate_from_mono _, exact λ _ _, or.inr ‹_› }}\nend\n\n@[simp] lemma is_regular_singleton_regular_open {x : X} {y : Y} :\n  is_regular (principal_open (singleton_collapse_poset x y one_lt_omega_succ)) :=\ncollapse_poset.is_regular_principal_open _\n\n@[simp] lemma is_regular_singleton_regular_open' {x : X} {y : Y} :\n  is_regular {g : X → Y | g x = y} :=\nby {rw [<-singleton_collapse_poset_principal_open], exact is_regular_singleton_regular_open}\n\nlemma trivial_extension_mem_principal_open {p : collapse_poset X Y κ} {y : Y}\n  : (trivial_extension p.f y) ∈ collapse_poset.principal_open p :=\nby { rw [mem_principal_open_iff],\n     intros x y hy, simp [trivial_extension_pos, mem_dom_of_mem hy, fn_eq_of_mem hy] }\n\nend collapse_poset\n\nsection omega_closed_dense_subset\n\nvariables {α : Type*} [nontrivial_complete_boolean_algebra α]\n\n-- any ω-indexed downward chain in D has an intersection in D\ndef omega_closed (D : set α) : Prop :=\n∀ (s : ℕ → α) (s_sub_D : ∀n, s n ∈ D) (H_nonzero : ∀ n, ⊥ < s n) (H_chain : ∀ n, s (n+1) ≤ s n), (⨅n, s n) ∈ D\n\ndef dense_subset {α : Type*} [order_bot α] (D : set α) : Prop :=\n⊥ ∉ D ∧ ∀x, ⊥ < x → ∃ y ∈ D, y ≤ x\n\n@[reducible]def dense_omega_closed_subset (D : set α) : Prop :=\ndense_subset D ∧ omega_closed D\n\nvariable (α)\ndef has_dense_omega_closed_subset : Prop :=\n∃ D : set α, dense_omega_closed_subset D\n\nvariable {α}\n\nlemma nonzero_of_mem_dense_omega_closed_subset {x : α} {D : set α} (H : dense_omega_closed_subset D) (H_mem : x ∈ D) : ⊥ < x :=\nby {have := H.left.left, by_contra H', finish [le_bot_iff_not_bot_lt]}\n\nlemma nonzero_infi_of_mem_dense_omega_closed_subset {s : ℕ → α} {D : set α} (H : dense_omega_closed_subset D) (H_chain : ∀ n, s (n + 1) ≤ s n) (H_mem : ∀ n, s n ∈ D) : ⊥ < ⨅ n, s n :=\nbegin\n  apply nonzero_of_mem_dense_omega_closed_subset H, refine H.right s ‹_› _ ‹_›,\n  intro n, specialize H_mem n, from nonzero_of_mem_dense_omega_closed_subset H ‹_›\nend\n\nend omega_closed_dense_subset\n\n\nlocal attribute [instance, priority 9000] collapse_space\n\nsection collapse_algebra\nvariables X Y : Type u\n\ndef collapse_algebra : Type* := @regular_opens (X → Y) collapse_space\n\nvariables {X Y}\n\n@[instance, priority 9001] def collapse_algebra_boolean_algebra [nonempty (X → Y)] : nontrivial_complete_boolean_algebra (collapse_algebra X Y) :=\nregular_open_algebra\n\nend collapse_algebra\n\nsection collapse_poset_dense\nvariables {X Y : Type u}\n\ndef collapse_poset.inclusion (p : collapse_poset X Y cardinal.omega.succ) :\n  collapse_algebra X Y :=\n⟨collapse_poset.principal_open p, collapse_poset.is_regular_principal_open p⟩\n\nlocal notation `ι`:65 := collapse_poset.inclusion\n\nlemma collapse_poset_dense_basis : ∀ T ∈ collapse_space_basis X Y,\n  ∀ h_nonempty : T ≠ ∅, ∃ p : collapse_poset X Y cardinal.omega.succ, (ι p).val ⊆ T :=\nbegin\n  intros T H_mem_basis _,\n  refine or.elim H_mem_basis (λ _, (false.elim (absurd ‹T = ∅› ‹_›))) (λ H, _),\n  rcases H with ⟨_,⟨_,H₂⟩⟩, exact ⟨‹_›, by simp[H₂, collapse_poset.inclusion]⟩\nend\n\nlemma collapse_poset_dense [nonempty (X → Y)] {b : collapse_algebra X Y}\n  (H : ⊥ < b) : ∃ p : collapse_poset X Y cardinal.omega.succ, ι p ≤ b :=\nbegin\n  cases (classical.choice (classical.nonempty_of_not_empty _ H.right.symm)) with S_wit H_wit,\n  change ∃ p, (ι p).val ⊆ b.val,\n  have := mem_basis_subset_of_mem_open collapse_space_basis_spec H_wit (is_open_of_is_regular b.property),\n  rcases (mem_basis_subset_of_mem_open\n           collapse_space_basis_spec H_wit (is_open_of_is_regular b.property))\n         with ⟨v, Hv₁, Hv₂, Hv₃⟩,\n  have : v ≠ ∅, by {intro H, rw [H] at Hv₂, cases Hv₂},\n  cases (collapse_poset_dense_basis ‹_› ‹_› ‹_›) with p H_p, exact ⟨p, set.subset.trans H_p ‹_›⟩\nend\n\n/- note: the hypothesis in this lemma almost always implies that q.f ≤ p.f, except when `Y` is a singleton -/\ndef compatible_of_inclusion_le_inclusion [nonempty $ X → Y]\n  {p q : collapse_poset X Y cardinal.omega.succ} (h : ι p ≤ ι q) : p.f.compatible q.f :=\nbegin\n  simp [collapse_poset.inclusion, le_iff_subset, collapse_poset.principal_open] at h,\n  intros x px qx,\n  have := h _ (pfun.le_trivial_extension p.f (p.f.fn x px)) x (q.f.fn x qx) (pfun.fn_mem _),\n  simp [pfun.trivial_extension_pos px] at this,\n  rw [← pfun.some_fn px, ← pfun.some_fn qx, this]\nend\n\nlocal postfix `ᵖ`:80 := perp\n\nlemma principal_open_eq_infi_of_eq_inter [nonempty $ X → Y] {I : Type*} {s : I → collapse_algebra X Y}\n  {s_infty : collapse_algebra X Y} (H_eq_inter: s_infty.val = ⋂n, (s n).val)\n  : s_infty = ⨅ n, s n :=\nbegin\n  rw subtype.ext, rw fst_infi',\n  have s_infty_p_p : s_infty.val = s_infty.valᵖᵖ,\n    by {rw is_regular_eq_p_p, exact s_infty.property},\n  rw s_infty_p_p, simp*\nend\n\nlemma principal_opens_dense_omega_closed [nonempty $ X → Y] :\n  dense_omega_closed_subset (set.range ι : set (collapse_algebra X Y)) :=\nbegin\n  refine ⟨⟨_, _⟩, _⟩,\n  { rintro ⟨p, hp⟩, have := congr_arg subtype.val hp,\n    simp [collapse_poset.inclusion, collapse_poset.principal_open] at this,\n    erw [set.eq_empty_iff_forall_not_mem] at this,\n    have := _inst_1, cases this with g,\n    exact this (p.f.extend_via g) (p.f.le_extend_via g) },\n  { intros o ho,\n    have h2o : o.1 ≠ ∅ := ho.2.symm,\n    rcases nonempty_basis_subset collapse_space_basis_spec h2o (is_open_of_is_regular o.2)\n      with ⟨u, hu, h2u, h3u⟩,\n    rcases or.resolve_left hu h2u with ⟨u', hu', rfl⟩,\n    refine ⟨ι u', set.mem_range_self u', h3u⟩ },\n  { intros f hf h2f h3f, choose g hg using hf,\n    simp only [(hg _).symm] at h3f h2f ⊢, clear hg f,\n    let P : collapse_poset X Y _,\n    { refine collapse_poset.Sup_lift g _ _,\n      { simp [(succ_is_regular (by refl)).2],\n        simp only [cardinal.omega, (lift_succ _).symm, lift_lt, lt_succ_self] },\n      { apply le_of_lt (lt_succ_self _) } },\n    refine ⟨P, _⟩,\n    have : ∀ {{i j : ℕ}}, i ≤ j → ι (g j) ≤ ι (g i),\n    { intros i j h, induction h, exact le_refl _, exact le_trans (h3f _) h_ih },\n    have : ∀ (i j : ℕ), pfun.compatible ((g i).f) ((g j).f),\n    { intros, cases le_total i j with h h, rw [pfun.compatible_comm],\n      apply compatible_of_inclusion_le_inclusion (this h),\n      apply compatible_of_inclusion_le_inclusion (this h) },\n    simp [collapse_poset.inclusion, subtype.val_eq_coe],\n    apply principal_open_eq_infi_of_eq_inter, ext f,\n    refine ⟨_,_⟩; intro H,\n      { rw set.mem_Inter, intro k,\n        rw mem_principal_open_iff at H ⊢, intros x y Hy,\n        apply H, dsimp[P, collapse_poset.Sup_lift],\n        rw (pfun.mem_Sup ‹_›), use k, from ‹_›},\n      { rw mem_principal_open_iff, dsimp[P, collapse_poset.Sup_lift],\n        intros x y H_mem, rw set.mem_Inter at H, rw (pfun.mem_Sup ‹_›) at H_mem,\n        simp only [mem_principal_open_iff] at H, finish }}\nend\n\nend collapse_poset_dense\n\nlocal notation `𝔹` := collapse_algebra ((ℵ₁ : pSet).type) (powerset omega : pSet).type\n\ninstance nonempty_aleph_one_powerset_omega : nonempty $ ((ℵ₁).type) → (powerset omega).type :=\n⟨λ _, by {unfold pSet.omega, exact λ _, false}⟩\n\ndef collapse_boolean_algebra : nontrivial_complete_boolean_algebra 𝔹 :=\nby apply_instance\n", "meta": {"author": "flypitch", "repo": "flypitch", "sha": "aea5800db1f4cce53fc4a113711454b27388ecf8", "save_path": "github-repos/lean/flypitch-flypitch", "path": "github-repos/lean/flypitch-flypitch/flypitch-aea5800db1f4cce53fc4a113711454b27388ecf8/src/collapse.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4767472941672342}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebraic_geometry.sheafed_space\nimport Mathlib.algebra.category.CommRing.limits\nimport Mathlib.algebra.category.CommRing.colimits\nimport Mathlib.algebraic_geometry.stalks\nimport Mathlib.ring_theory.ideal.basic\nimport Mathlib.PostPort\n\nuniverses u_1 l u \n\nnamespace Mathlib\n\n/-!\n# The category of locally ringed spaces\n\nWe define (bundled) locally ringed spaces\n(as `SheafedSpace CommRing` along with the fact that the stalks are local rings),\nand morphisms between these (morphisms in `SheafedSpace` with `is_local_ring_hom` on the stalk maps).\n\n## Future work\n* Define the restriction along an open embedding\n-/\n\nnamespace algebraic_geometry\n\n\n/-- A `LocallyRingedSpace` is a topological space equipped with a sheaf of commutative rings\nsuch that all the stalks are local rings.\n\nA morphism of locally ringed spaces is a morphism of ringed spaces\nsuch that the morphims induced on stalks are local ring homomorphisms. -/\nstructure LocallyRingedSpace extends SheafedSpace CommRing where\n  local_ring :\n    ∀ (x : ↥(PresheafedSpace.carrier (SheafedSpace.to_PresheafedSpace _to_SheafedSpace))),\n      local_ring\n        ↥(Top.presheaf.stalk\n            (PresheafedSpace.presheaf (SheafedSpace.to_PresheafedSpace _to_SheafedSpace)) x)\n\nnamespace LocallyRingedSpace\n\n\n/-- The underlying topological space of a locally ringed space. -/\ndef to_Top (X : LocallyRingedSpace) : Top :=\n  PresheafedSpace.carrier (SheafedSpace.to_PresheafedSpace (to_SheafedSpace X))\n\nprotected instance has_coe_to_sort : has_coe_to_sort LocallyRingedSpace :=\n  has_coe_to_sort.mk (Type u) fun (X : LocallyRingedSpace) => ↥(to_Top X)\n\n-- PROJECT: how about a typeclass \"has_structure_sheaf\" to mediate the 𝒪 notation, rather\n\n-- than defining it over and over for PresheafedSpace, LRS, Scheme, etc.\n\n/-- The structure sheaf of a locally ringed space. -/\ndef 𝒪 (X : LocallyRingedSpace) : Top.sheaf CommRing (to_Top X) :=\n  SheafedSpace.sheaf (to_SheafedSpace X)\n\n/-- A morphism of locally ringed spaces is a morphism of ringed spaces\n such that the morphims induced on stalks are local ring homomorphisms. -/\ndef hom (X : LocallyRingedSpace) (Y : LocallyRingedSpace) :=\n  Subtype\n    fun (f : to_SheafedSpace X ⟶ to_SheafedSpace Y) =>\n      ∀ (x : ↥(SheafedSpace.to_PresheafedSpace (to_SheafedSpace X))),\n        is_local_ring_hom (PresheafedSpace.stalk_map f x)\n\nprotected instance category_theory.has_hom : category_theory.has_hom LocallyRingedSpace :=\n  category_theory.has_hom.mk hom\n\ntheorem hom_ext {X : LocallyRingedSpace} {Y : LocallyRingedSpace} (f : hom X Y) (g : hom X Y)\n    (w : subtype.val f = subtype.val g) : f = g :=\n  subtype.eq w\n\n/--\nThe stalk of a locally ringed space, just as a `CommRing`.\n-/\n-- TODO perhaps we should make a bundled `LocalRing` and return one here?\n\n-- TODO define `sheaf.stalk` so we can write `X.𝒪.stalk` here?\n\ndef stalk (X : LocallyRingedSpace) (x : ↥X) : CommRing :=\n  Top.presheaf.stalk\n    (PresheafedSpace.presheaf (SheafedSpace.to_PresheafedSpace (to_SheafedSpace X))) x\n\n/--\nA morphism of locally ringed spaces `f : X ⟶ Y` induces\na local ring homomorphism from `Y.stalk (f x)` to `X.stalk x` for any `x : X`.\n-/\ndef stalk_map {X : LocallyRingedSpace} {Y : LocallyRingedSpace} (f : X ⟶ Y) (x : ↥X) :\n    stalk Y (coe_fn (PresheafedSpace.hom.base (subtype.val f)) x) ⟶ stalk X x :=\n  PresheafedSpace.stalk_map (subtype.val f) x\n\nprotected instance stalk_map.is_local_ring_hom {X : LocallyRingedSpace} {Y : LocallyRingedSpace}\n    (f : X ⟶ Y) (x : ↥X) : is_local_ring_hom (stalk_map f x) :=\n  subtype.property f x\n\n/-- The identity morphism on a locally ringed space. -/\ndef id (X : LocallyRingedSpace) : hom X X := { val := 𝟙, property := sorry }\n\nprotected instance hom.inhabited (X : LocallyRingedSpace) : Inhabited (hom X X) :=\n  { default := id X }\n\n/-- Composition of morphisms of locally ringed spaces. -/\ndef comp {X : LocallyRingedSpace} {Y : LocallyRingedSpace} {Z : LocallyRingedSpace} (f : hom X Y)\n    (g : hom Y Z) : hom X Z :=\n  { val := subtype.val f ≫ subtype.val g, property := sorry }\n\n/-- The category of locally ringed spaces. -/\nprotected instance category_theory.category : category_theory.category LocallyRingedSpace :=\n  category_theory.category.mk\n\n/-- The forgetful functor from `LocallyRingedSpace` to `SheafedSpace CommRing`. -/\ndef forget_to_SheafedSpace : LocallyRingedSpace ⥤ SheafedSpace CommRing :=\n  category_theory.functor.mk (fun (X : LocallyRingedSpace) => to_SheafedSpace X)\n    fun (X Y : LocallyRingedSpace) (f : X ⟶ Y) => subtype.val f\n\nprotected instance forget_to_SheafedSpace.category_theory.faithful :\n    category_theory.faithful forget_to_SheafedSpace :=\n  category_theory.faithful.mk\n\n-- PROJECT: once we have `PresheafedSpace.restrict_stalk_iso`\n\n-- (that restriction doesn't change stalks) we can uncomment this.\n\n/-\ndef restrict {U : Top} (X : LocallyRingedSpace)\n  (f : U ⟶ X.to_Top) (h : open_embedding f) : LocallyRingedSpace :=\n{ local_ring :=\n  begin\n    intro x,\n    dsimp at *,\n    -- We show that the stalk of the restriction is isomorphic to the original stalk,\n    have := X.to_SheafedSpace.to_PresheafedSpace.restrict_stalk_iso f h x,\n    -- and then transfer `local_ring` across the ring equivalence.\n    apply (this.CommRing_iso_to_ring_equiv).local_ring, -- import data.equiv.transfer_instance\n    apply X.local_ring,\n  end,\n  .. X.to_SheafedSpace.restrict _ f h }\n-/\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : LocallyRingedSpaceᵒᵖ ⥤ CommRing :=\n  category_theory.functor.op forget_to_SheafedSpace ⋙ SheafedSpace.Γ\n\ntheorem Γ_def : Γ = category_theory.functor.op forget_to_SheafedSpace ⋙ SheafedSpace.Γ := rfl\n\n@[simp] theorem Γ_obj (X : LocallyRingedSpaceᵒᵖ) :\n    category_theory.functor.obj Γ X =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf\n            (SheafedSpace.to_PresheafedSpace (to_SheafedSpace (opposite.unop X))))\n          (opposite.op ⊤) :=\n  rfl\n\ntheorem Γ_obj_op (X : LocallyRingedSpace) :\n    category_theory.functor.obj Γ (opposite.op X) =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf (SheafedSpace.to_PresheafedSpace (to_SheafedSpace X)))\n          (opposite.op ⊤) :=\n  rfl\n\n@[simp] theorem Γ_map {X : LocallyRingedSpaceᵒᵖ} {Y : LocallyRingedSpaceᵒᵖ} (f : X ⟶ Y) :\n    category_theory.functor.map Γ f =\n        category_theory.nat_trans.app\n            (PresheafedSpace.hom.c (subtype.val (category_theory.has_hom.hom.unop f)))\n            (opposite.op ⊤) ≫\n          category_theory.functor.map\n            (PresheafedSpace.presheaf\n              (SheafedSpace.to_PresheafedSpace (to_SheafedSpace (opposite.unop Y))))\n            (category_theory.has_hom.hom.op\n              (topological_space.opens.le_map_top\n                (PresheafedSpace.hom.base (subtype.val (category_theory.has_hom.hom.unop f))) ⊤)) :=\n  rfl\n\ntheorem Γ_map_op {X : LocallyRingedSpace} {Y : LocallyRingedSpace} (f : X ⟶ Y) :\n    category_theory.functor.map Γ (category_theory.has_hom.hom.op f) =\n        category_theory.nat_trans.app (PresheafedSpace.hom.c (subtype.val f)) (opposite.op ⊤) ≫\n          category_theory.functor.map\n            (PresheafedSpace.presheaf (SheafedSpace.to_PresheafedSpace (to_SheafedSpace X)))\n            (category_theory.has_hom.hom.op\n              (topological_space.opens.le_map_top (PresheafedSpace.hom.base (subtype.val f)) ⊤)) :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebraic_geometry/locally_ringed_space_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6723317123102955, "lm_q1q2_score": 0.4766960482784942}}
{"text": "/-\nCopyright (c) 2021 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\nimport category_theory.sites.sheaf\nimport category_theory.limits.kan_extension\nimport category_theory.sites.cover_preserving\n\n/-!\n# Cover-lifting functors between sites.\n\nWe define cover-lifting functors between sites as functors that pull covering sieves back to\ncovering sieves. This concept is also known as *cocontinuous functors* or\n*cover-reflecting functors*, but we have chosen this name following [MM92] in order to avoid\npotential naming collision or confusion with the general definition of cocontinuous functors\nbetween categories as functors preserving small colimits.\n\nThe definition given here seems stronger than the definition found elsewhere,\nbut they are actually equivalent via `category_theory.grothendieck_topology.superset_covering`.\n(The precise statement is not formalized, but follows from it quite trivially).\n\n## Main definitions\n\n* `category_theory.sites.cover_lifting`: a functor between sites is cover-lifting if it\n  pulls back covering sieves to covering sieves\n* `category_theory.sites.copullback`: A cover-lifting functor `G : (C, J) ⥤ (D, K)` induces a\n  morphism of sites in the same direction as the functor.\n\n## Main results\n* `category_theory.sites.Ran_is_sheaf_of_cover_lifting`: If `G : C ⥤ D` is cover_lifting, then\n  `Ran G.op` (`ₚu`) as a functor `(Cᵒᵖ ⥤ A) ⥤ (Dᵒᵖ ⥤ A)` of presheaves maps sheaves to sheaves.\n* `category_theory.pullback_copullback_adjunction`: If `G : (C, J) ⥤ (D, K)` is cover-lifting,\n  cover-preserving, and compatible-preserving, then `pullback G` and `copullback G` are adjoint.\n\n## References\n\n* [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.3.\n* [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM92]\n* https://stacks.math.columbia.edu/tag/00XI\n\n-/\n\nuniverses w v v₁ v₂ v₃ u u₁ u₂ u₃\nnoncomputable theory\n\nopen category_theory\nopen opposite\nopen category_theory.presieve.family_of_elements\nopen category_theory.presieve\nopen category_theory.limits\n\nnamespace category_theory\nsection cover_lifting\nvariables {C : Type*} [category C] {D : Type*} [category D] {E : Type*} [category E]\nvariables (J : grothendieck_topology C) (K : grothendieck_topology D)\nvariables {L : grothendieck_topology E}\n\n/--\nA functor `G : (C, J) ⥤ (D, K)` between sites is called to have the cover-lifting property\nif for all covering sieves `R` in `D`, `R.pullback G` is a covering sieve in `C`.\n-/\n@[nolint has_nonempty_instance]\nstructure cover_lifting (G : C ⥤ D) : Prop :=\n(cover_lift : ∀ {U : C} {S : sieve (G.obj U)} (hS : S ∈ K (G.obj U)), S.functor_pullback G ∈ J U)\n\n/-- The identity functor on a site is cover-lifting. -/\nlemma id_cover_lifting : cover_lifting J J (𝟭 _) := ⟨λ _ _ h, by simpa using h⟩\n\nvariables {J K}\n\n/-- The composition of two cover-lifting functors are cover-lifting -/\nlemma comp_cover_lifting {F : C ⥤ D} (hu : cover_lifting J K F) {G : D ⥤ E}\n  (hv : cover_lifting K L G) : cover_lifting J L (F ⋙ G) :=\n⟨λ _ S h, hu.cover_lift (hv.cover_lift h)⟩\n\nend cover_lifting\n\n/-!\nWe will now prove that `Ran G.op` (`ₚu`) maps sheaves to sheaves if `G` is cover-lifting. This can\nbe found in <https://stacks.math.columbia.edu/tag/00XK>. However, the proof given here uses the\namalgamation definition of sheaves, and thus does not require that `C` or `D` has categorical\npullbacks.\n\nFor the following proof sketch, `⊆` denotes the homs on `C` and `D` as in the topological analogy.\nBy definition, the presheaf `𝒢 : Dᵒᵖ ⥤ A` is a sheaf if for every sieve `S` of `U : D`, and every\ncompatible family of morphisms `X ⟶ 𝒢(V)` for each `V ⊆ U : S` with a fixed source `X`,\nwe can glue them into a morphism `X ⟶ 𝒢(U)`.\n\nSince the presheaf `𝒢 := (Ran G.op).obj ℱ.val` is defined via `𝒢(U) = lim_{G(V) ⊆ U} ℱ(V)`, for\ngluing the family `x` into a `X ⟶ 𝒢(U)`, it suffices to provide a `X ⟶ ℱ(Y)` for each\n`G(Y) ⊆ U`. This can be done since `{ Y' ⊆ Y : G(Y') ⊆ U ∈ S}` is a covering sieve for `Y` on\n`C` (by the cover-lifting property of `G`). Thus the morphisms `X ⟶ 𝒢(G(Y')) ⟶ ℱ(Y')` can be\nglued into a morphism `X ⟶ ℱ(Y)`. This is done in `get_sections`.\n\nIn `glued_limit_cone`, we verify these obtained sections are indeed compatible, and thus we obtain\nA `X ⟶ 𝒢(U)`. The remaining work is to verify that this is indeed the amalgamation and is unique.\n-/\nvariables {C D : Type u} [category.{v} C] [category.{v} D]\nvariables {A : Type w} [category.{max u v} A] [has_limits A]\nvariables {J : grothendieck_topology C} {K : grothendieck_topology D}\n\nnamespace Ran_is_sheaf_of_cover_lifting\nvariables {G : C ⥤ D} (hu : cover_lifting J K G) (ℱ : Sheaf J A)\nvariables {X : A} {U : D} (S : sieve U) (hS : S ∈ K U)\n\ninstance (X : Dᵒᵖ) : has_limits_of_shape (structured_arrow X G.op) A :=\nbegin\n  haveI := limits.has_limits_of_size_shrink.{v (max u v) (max u v) (max u v)} A,\n  exact has_limits_of_size.has_limits_of_shape _\nend\n\nvariables (x : S.arrows.family_of_elements ((Ran G.op).obj ℱ.val ⋙ coyoneda.obj (op X)))\nvariables (hx : x.compatible)\n\n/-- The family of morphisms `X ⟶ 𝒢(G(Y')) ⟶ ℱ(Y')` defined on `{ Y' ⊆ Y : G(Y') ⊆ U ∈ S}`. -/\ndef pulledback_family (Y : structured_arrow (op U) G.op) :=\n(((x.pullback Y.hom.unop).functor_pullback G).comp_presheaf_map\n  (show _ ⟶ _, from whisker_right ((Ran.adjunction A G.op).counit.app ℱ.val)\n    (coyoneda.obj (op X))))\n\n@[simp] lemma pulledback_family_apply (Y : structured_arrow (op U) G.op) {W} {f : W ⟶ _} (Hf) :\n  pulledback_family ℱ S x Y f Hf =\n    x (G.map f ≫ Y.hom.unop) Hf ≫ ((Ran.adjunction A G.op).counit.app ℱ.val).app (op W) := rfl\n\nvariables {x} {S}\ninclude hu hS hx\n\n/-- Given a `G(Y) ⊆ U`, we can find a unique section `X ⟶ ℱ(Y)` that agrees with `x`. -/\ndef get_section (Y : structured_arrow (op U) G.op) : X ⟶ ℱ.val.obj Y.right :=\nbegin\n  let hom_sh := whisker_right ((Ran.adjunction A G.op).counit.app ℱ.val) (coyoneda.obj (op X)),\n  have S' := (K.pullback_stable Y.hom.unop hS),\n  have hs' := ((hx.pullback Y.3.unop).functor_pullback G).comp_presheaf_map hom_sh,\n  exact (ℱ.2 X _ (hu.cover_lift S')).amalgamate _ hs'\nend\n\nlemma get_section_is_amalgamation (Y : structured_arrow (op U) G.op) :\n  (pulledback_family ℱ S x Y).is_amalgamation (get_section hu ℱ hS hx Y) :=\nis_sheaf_for.is_amalgamation _ _\n\nlemma get_section_is_unique (Y : structured_arrow (op U) G.op)\n  {y} (H : (pulledback_family ℱ S x Y).is_amalgamation y) : y = get_section hu ℱ hS hx Y :=\nbegin\n  apply is_sheaf_for.is_separated_for _ (pulledback_family ℱ S x Y),\n  { exact H },\n  { apply get_section_is_amalgamation },\n  { exact ℱ.2 X _ (hu.cover_lift (K.pullback_stable Y.hom.unop hS)) }\nend\n\n@[simp] lemma get_section_commute {Y Z : structured_arrow (op U) G.op} (f : Y ⟶ Z) :\n  get_section hu ℱ hS hx Y ≫ ℱ.val.map f.right = get_section hu ℱ hS hx Z :=\nbegin\n  apply get_section_is_unique,\n  intros V' fV' hV',\n  have eq : Z.hom = Y.hom ≫ (G.map f.right.unop).op,\n  { convert f.w, erw category.id_comp },\n  rw eq at hV',\n  convert get_section_is_amalgamation hu ℱ hS hx Y (fV' ≫ f.right.unop) _ using 1,\n  { tidy },\n  { simp only [eq, quiver.hom.unop_op, pulledback_family_apply,\n    functor.map_comp, unop_comp, category.assoc] },\n  { change S (G.map _ ≫ Y.hom.unop),\n    simpa only [functor.map_comp, category.assoc] using hV' }\nend\n\n/-- The limit cone in order to glue the sections obtained via `get_section`. -/\ndef glued_limit_cone : limits.cone (Ran.diagram G.op ℱ.val (op U)) :=\n{ X := X, π := { app := λ Y, get_section hu ℱ hS hx Y, naturality' := λ Y Z f, by tidy } }\n\n@[simp] lemma glued_limit_cone_π_app (W) : (glued_limit_cone hu ℱ hS hx).π.app W =\n  get_section hu ℱ hS hx W := rfl\n\n/-- The section obtained by passing `glued_limit_cone` into `category_theory.limits.limit.lift`. -/\ndef glued_section : X ⟶ ((Ran G.op).obj ℱ.val).obj (op U) :=\nlimit.lift _ (glued_limit_cone hu ℱ hS hx)\n\n/--\nA helper lemma for the following two lemmas. Basically stating that if the section `y : X ⟶ 𝒢(V)`\ncoincides with `x` on `G(V')` for all `G(V') ⊆ V ∈ S`, then `X ⟶ 𝒢(V) ⟶ ℱ(W)` is indeed the\nsection obtained in `get_sections`. That said, this is littered with some more categorical jargon\nin order to be applied in the following lemmas easier.\n-/\nlemma helper {V} (f : V ⟶ U) (y : X ⟶ ((Ran G.op).obj ℱ.val).obj (op V)) (W)\n  (H : ∀ {V'} {fV : G.obj V' ⟶ V} (hV), y ≫ ((Ran G.op).obj ℱ.val).map fV.op = x (fV ≫ f) hV) :\n  y ≫ limit.π (Ran.diagram G.op ℱ.val (op V)) W =\n    (glued_limit_cone hu ℱ hS hx).π.app ((structured_arrow.map f.op).obj W) :=\nbegin\n  dsimp only [glued_limit_cone_π_app],\n  apply get_section_is_unique hu ℱ hS hx ((structured_arrow.map f.op).obj W),\n  intros V' fV' hV',\n  dsimp only [Ran.adjunction, Ran.equiv, pulledback_family_apply],\n  erw [adjunction.adjunction_of_equiv_right_counit_app],\n  have : y ≫ ((Ran G.op).obj ℱ.val).map (G.map fV' ≫ W.hom.unop).op =\n    x (G.map fV' ≫ W.hom.unop ≫ f) (by simpa only using hV'),\n  { convert H (show S ((G.map fV' ≫ W.hom.unop) ≫ f),\n      by simpa only [category.assoc] using hV') using 2,\n    simp only [category.assoc] },\n  simp only [quiver.hom.unop_op, equiv.symm_symm, structured_arrow.map_obj_hom, unop_comp,\n    equiv.coe_fn_mk, functor.comp_map, coyoneda_obj_map, category.assoc, ← this, op_comp,\n    Ran_obj_map, nat_trans.id_app],\n  erw [category.id_comp, limit.pre_π],\n  congr,\n  convert limit.w (Ran.diagram G.op ℱ.val (op V)) (structured_arrow.hom_mk' W fV'.op),\n  rw structured_arrow.map_mk,\n  erw category.comp_id,\n  simp only [quiver.hom.unop_op, functor.op_map, quiver.hom.op_unop]\nend\n\n/-- Verify that the `glued_section` is an amalgamation of `x`. -/\nlemma glued_section_is_amalgamation : x.is_amalgamation (glued_section hu ℱ hS hx) :=\nbegin\n  intros V fV hV,\n  ext W,\n  simp only [functor.comp_map, limit.lift_pre, coyoneda_obj_map, Ran_obj_map, glued_section],\n  erw limit.lift_π,\n  symmetry,\n  convert helper hu ℱ hS hx _ (x fV hV) _ _ using 1,\n  intros V' fV' hV',\n  convert hx (fV') (𝟙 _) hV hV' (by rw category.id_comp),\n  simp only [op_id, functor_to_types.map_id_apply]\nend\n\n/-- Verify that the amalgamation is indeed unique. -/\nlemma glued_section_is_unique (y) (hy: x.is_amalgamation y) : y = glued_section hu ℱ hS hx :=\nbegin\n  unfold glued_section limit.lift,\n  ext W,\n  erw limit.lift_π,\n  convert helper hu ℱ hS hx (𝟙 _) y W _,\n  { simp only [op_id, structured_arrow.map_id] },\n  { intros V' fV' hV',\n    convert hy fV' (by simpa only [category.comp_id] using hV'),\n    erw category.comp_id }\nend\n\nend Ran_is_sheaf_of_cover_lifting\n\n/--\nIf `G` is cover_lifting, then `Ran G.op` pushes sheaves to sheaves.\n\nThis result is basically https://stacks.math.columbia.edu/tag/00XK,\nbut without the condition that `C` or `D` has pullbacks.\n-/\ntheorem Ran_is_sheaf_of_cover_lifting {G : C ⥤ D} (hG : cover_lifting J K G) (ℱ : Sheaf J A) :\n  presheaf.is_sheaf K ((Ran G.op).obj ℱ.val) :=\nbegin\n  intros X U S hS x hx,\n  split, swap,\n  { apply Ran_is_sheaf_of_cover_lifting.glued_section hG ℱ hS hx },\n  split,\n  { apply Ran_is_sheaf_of_cover_lifting.glued_section_is_amalgamation },\n  { apply Ran_is_sheaf_of_cover_lifting.glued_section_is_unique }\nend\n\nvariable (A)\n\n/-- A cover-lifting functor induces a morphism of sites in the same direction as the functor. -/\ndef sites.copullback {G : C ⥤ D} (hG : cover_lifting J K G) :\n  Sheaf J A ⥤ Sheaf K A :=\n{ obj := λ ℱ, ⟨(Ran G.op).obj ℱ.val, Ran_is_sheaf_of_cover_lifting hG ℱ⟩,\n  map := λ _ _ f, ⟨(Ran G.op).map f.val⟩,\n  map_id' := λ ℱ, Sheaf.hom.ext _ _ $ (Ran G.op).map_id ℱ.val,\n  map_comp' := λ _ _ _ f g, Sheaf.hom.ext _ _ $ (Ran G.op).map_comp f.val g.val }\n\n/--\nGiven a functor between sites that is cover-preserving, cover-lifting, and compatible-preserving,\nthe pullback and copullback along `G` are adjoint to each other\n-/\n@[simps unit_app_val counit_app_val] noncomputable\ndef sites.pullback_copullback_adjunction {G : C ⥤ D} (Hp : cover_preserving J K G)\n  (Hl : cover_lifting J K G) (Hc : compatible_preserving K G) :\n  sites.pullback A Hc Hp ⊣ sites.copullback A Hl :=\n{ hom_equiv := λ X Y,\n  { to_fun := λ f, ⟨(Ran.adjunction A G.op).hom_equiv X.val Y.val f.val⟩,\n    inv_fun := λ f, ⟨((Ran.adjunction A G.op).hom_equiv X.val Y.val).symm f.val⟩,\n    left_inv := λ f, by { ext1, dsimp, rw [equiv.symm_apply_apply] },\n    right_inv := λ f, by { ext1, dsimp, rw [equiv.apply_symm_apply] } },\n  unit := { app := λ X, ⟨(Ran.adjunction A G.op).unit.app X.val⟩,\n    naturality' := λ _ _ f, Sheaf.hom.ext _ _ $ (Ran.adjunction A G.op).unit.naturality f.val },\n  counit := { app := λ X, ⟨(Ran.adjunction A G.op).counit.app X.val⟩,\n    naturality' := λ _ _ f, Sheaf.hom.ext _ _ $ (Ran.adjunction A G.op).counit.naturality f.val },\n  hom_equiv_unit' := λ X Y f, by { ext1, apply (Ran.adjunction A G.op).hom_equiv_unit },\n  hom_equiv_counit' := λ X Y f, by { ext1, apply (Ran.adjunction A G.op).hom_equiv_counit } }\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/sites/cover_lifting.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4766960343132887}}
{"text": "import data.real.basic\nimport tactic\n\n\nprivate meta def finish_proof_about_abs : tactic unit := `[\n  unfold abs,\n  simp,\n  exact le_of_lt h,\n  rw undo_abs at *,\n  split;\n  linarith\n]\n\nlemma eq_of_abs_sub_le_all_pos (x y : ℝ) : (∀ ε > 0, |x - y| ≤ ε) → x = y :=\nbegin\n  contrapose!,\n  intro ass,\n  use |x - y| / 2,\n  cases ne.lt_or_lt ass,\n  {\n    have undo_abs : |x - y| = y - x,\n    finish_proof_about_abs,\n  },\n  {\n    have undo_abs : |x - y| = x - y,\n    finish_proof_about_abs,\n  },\nend\n", "meta": {"author": "madvorak", "repo": "lean-showcase", "sha": "d405796deef7a7903befa438d5d7ac2873960a98", "save_path": "github-repos/lean/madvorak-lean-showcase", "path": "github-repos/lean/madvorak-lean-showcase/lean-showcase-d405796deef7a7903befa438d5d7ac2873960a98/src/resources.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.47660653016521465}}
{"text": "import Smt.Tactic.Concretize\n\ndef BitVec (w : Nat) := Fin (2^w)\n\nprotected def BitVec.zero (w : Nat) : BitVec w :=\n  ⟨0, Nat.pos_pow_of_pos _ <| by decide⟩\n\ninstance : Inhabited (BitVec w) := ⟨BitVec.zero w⟩\n\nopaque BitVec.xor {w : Nat} : BitVec w → BitVec w → BitVec w\n\ndef polyAdd {w : Nat} : BitVec w → BitVec w → BitVec w :=\n  BitVec.xor\ndef polyDouble {w : Nat} (x : BitVec w) : BitVec w :=\n  polyAdd x x\n\nexample (x y : BitVec 2) : polyDouble (polyAdd x y) = polyDouble (polyAdd y x) := by\n  concretize [polyDouble, polyAdd]\n  trace_state\n  sorry\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Test/Concretize/BitVec.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933271118222, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4766065250487512}}
{"text": "@[simp] axiom divSelf (x : Nat) : x ≠ 0 → x/x = 1\n\ntheorem ex (x : Nat) (h : x ≠ 0) : (if x/x = 1 then 0 else 1) = 0 := by\n  simp [h]\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/simpCondLemma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933183101078, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4766065199322874}}
{"text": "import mynat.definition\n\nlemma example3 (a b : mynat) (h : succ a = b) : succ(succ(a)) = succ(b) :=\nbegin\nrw ← h,\nrefl,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world01/level03.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256472515684, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.47648891974784274}}
{"text": "/-\nCopyright (c) 2022 Yuma Mizuno. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuma Mizuno\n\n! This file was ported from Lean 3 source module category_theory.bicategory.functor\n! leanprover-community/mathlib commit 369525b73f229ccd76a6ec0e0e0bf2be57599768\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Bicategory.Basic\n\n/-!\n# Oplax functors and pseudofunctors\n\nAn oplax functor `F` between bicategories `B` and `C` consists of\n* a function between objects `F.obj : B ⟶ C`,\n* a family of functions between 1-morphisms `F.map : (a ⟶ b) → (F.obj a ⟶ F.obj b)`,\n* a family of functions between 2-morphisms `F.map₂ : (f ⟶ g) → (F.map f ⟶ F.map g)`,\n* a family of 2-morphisms `F.mapId a : F.map (𝟙 a) ⟶ 𝟙 (F.obj a)`,\n* a family of 2-morphisms `F.mapComp f g : F.map (f ≫ g) ⟶ F.map f ≫ F.map g`, and\n* certain consistency conditions on them.\n\nA pseudofunctor is an oplax functor whose `mapId` and `mapComp` are isomorphisms. We provide\nseveral constructors for pseudofunctors:\n* `Pseudofunctor.mk` : the default constructor, which requires `map₂_whiskerLeft` and\n  `map₂_whiskerRight` instead of naturality of `mapComp`.\n* `Pseudofunctor.mkOfOplax` : construct a pseudofunctor from an oplax functor whose\n  `mapId` and `mapComp` are isomorphisms. This constructor uses `Iso` to describe isomorphisms.\n* `pseudofunctor.mkOfOplax'` : similar to `mkOfOplax`, but uses `IsIso` to describe\n  isomorphisms.\n\nThe additional constructors are useful when constructing a pseudofunctor where the construction\nof the oplax functor associated with it is already done. For example, the composition of\npseudofunctors can be defined by using the composition of oplax functors as follows:\n```lean\ndef comp (F : Pseudofunctor B C) (G : Pseudofunctor C D) : Pseudofunctor B D :=\nmkOfOplax ((F : OplaxFunctor B C).comp G)\n{ mapIdIso := λ a => (G.mapFunctor _ _).mapIso (F.mapId a) ≪≫ G.mapId (F.obj a),\n  mapCompIso := λ f g =>\n    (G.mapFunctor _ _).mapIso (F.mapComp f g) ≪≫ G.mapComp (F.map f) (F.map g) }\n```\nalthough the composition of pseudofunctors in this file is defined by using the default constructor\nbecause `obviously` wasn't smart enough in mathlib3 and the porter of this file was too lazy\nto investigage this issue further in mathlib4. Similarly, the composition is also defined by using\n`mkOfOplax'` after giving appropriate instances for `IsIso`. The former constructor\n`mkOfOplax` requires isomorphisms as data type `Iso`, and so it is useful if you don't want\nto forget the definitions of the inverses. On the other hand, the latter constructor\n`mkOfOplax'` is useful if you want to use propositional type class `IsIso`.\n\n## Main definitions\n\n* `CategoryTheory.OplaxFunctor B C` : an oplax functor between bicategories `B` and `C`\n* `CategoryTheory.OplaxFunctor.comp F G` : the composition of oplax functors\n* `CategoryTheory.Pseudofunctor B C` : a pseudofunctor between bicategories `B` and `C`\n* `CategoryTheory.Pseudofunctor.comp F G` : the composition of pseudofunctors\n\n## Future work\n\nThere are two types of functors between bicategories, called lax and oplax functors, depending on\nthe directions of `mapId` and `mapComp`. We may need both in mathlib in the future, but for\nnow we only define oplax functors.\n-/\n\n\nnamespace CategoryTheory\n\nopen Category Bicategory\n\nopen Bicategory\n\nuniverse w₁ w₂ w₃ v₁ v₂ v₃ u₁ u₂ u₃\n\nsection\n\nvariable {B : Type u₁} [Quiver.{v₁ + 1} B] [∀ a b : B, Quiver.{w₁ + 1} (a ⟶ b)]\n\nvariable {C : Type u₂} [Quiver.{v₂ + 1} C] [∀ a b : C, Quiver.{w₂ + 1} (a ⟶ b)]\n\nvariable {D : Type u₃} [Quiver.{v₃ + 1} D] [∀ a b : D, Quiver.{w₃ + 1} (a ⟶ b)]\n\n/-- A prelax functor between bicategories consists of functions between objects,\n1-morphisms, and 2-morphisms. This structure will be extended to define `OplaxFunctor`.\n-/\nstructure PrelaxFunctor (B : Type u₁) [Quiver.{v₁ + 1} B] [∀ a b : B, Quiver.{w₁ + 1} (a ⟶ b)]\n  (C : Type u₂) [Quiver.{v₂ + 1} C] [∀ a b : C, Quiver.{w₂ + 1} (a ⟶ b)] extends\n  Prefunctor B C where\n  map₂ {a b : B} {f g : a ⟶ b} : (f ⟶ g) → (map f ⟶ map g)\n#align category_theory.prelax_functor CategoryTheory.PrelaxFunctor\n\ninitialize_simps_projections PrelaxFunctor (+toPrefunctor, -obj, -map)\n\nattribute [nolint docBlame] CategoryTheory.PrelaxFunctor.map₂\n\n/-- The prefunctor between the underlying quivers. -/\nadd_decl_doc PrelaxFunctor.toPrefunctor\n\nnamespace PrelaxFunctor\n\nattribute [coe] CategoryTheory.PrelaxFunctor.toPrefunctor\n\ninstance hasCoeToPrefunctor : Coe (PrelaxFunctor B C) (Prefunctor B C) :=\n  ⟨toPrefunctor⟩\n#align category_theory.prelax_functor.has_coe_to_prefunctor\n  CategoryTheory.PrelaxFunctor.hasCoeToPrefunctor\n\nvariable (F : PrelaxFunctor B C)\n\n-- porting note: deleted syntactic tautologies `toPrefunctor_eq_coe : F.toPrefunctor = F`\n-- and `to_prefunctor_obj : (F : Prefunctor B C).obj = F.obj`\n-- and `to_prefunctor_map`\n#noalign category_theory.prelax_functor.to_prefunctor_eq_coe\n#noalign category_theory.prelax_functor.to_prefunctor_obj\n#noalign category_theory.prelax_functor.to_prefunctor_map\n\n/-- The identity prelax functor. -/\n@[simps]\ndef id (B : Type u₁) [Quiver.{v₁ + 1} B] [∀ a b : B, Quiver.{w₁ + 1} (a ⟶ b)] : PrelaxFunctor B B :=\n  { Prefunctor.id B with map₂ := fun η => η }\n#align category_theory.prelax_functor.id CategoryTheory.PrelaxFunctor.id\n\ninstance : Inhabited (PrelaxFunctor B B) :=\n  ⟨PrelaxFunctor.id B⟩\n\n-- porting note: `by exact` was not necessary in mathlib3\n/-- Composition of prelax functors. -/\n@[simps]\ndef comp (F : PrelaxFunctor B C) (G : PrelaxFunctor C D) : PrelaxFunctor B D :=\n  { (F : Prefunctor B C).comp ↑G with map₂ := fun η => by exact G.map₂ (F.map₂ η) }\n#align category_theory.prelax_functor.comp CategoryTheory.PrelaxFunctor.comp\n\nend PrelaxFunctor\n\nend\n\nsection\n\nvariable {B : Type u₁} [Bicategory.{w₁, v₁} B] {C : Type u₂} [Bicategory.{w₂, v₂} C]\n\nvariable {D : Type u₃} [Bicategory.{w₃, v₃} D]\n\n-- porting note: in Lean 3 the below auxiliary definition was only used once, in the definition\n-- of oplax functor, with a comment that it had to be used to fix a timeout. The timeout is\n-- not present in Lean 4, however Lean 4 is not as good at seeing through the definition,\n-- meaning that `simp` wasn't functioning as well as it should. I have hence removed\n-- the auxiliary definition.\n--@[simp]\n--def OplaxFunctor.Map₂AssociatorAux (obj : B → C) (map : ∀ {X Y : B}, (X ⟶ Y) → (obj X ⟶ obj Y))\n--    (map₂ : ∀ {a b : B} {f g : a ⟶ b}, (f ⟶ g) → (map f ⟶ map g))\n--    (map_comp : ∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c), map (f ≫ g) ⟶ map f ≫ map g) {a b c d : B}\n--    (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : Prop := ...\n\n#noalign category_theory.oplax_functor.map₂_associator_aux\n\n/-- An oplax functor `F` between bicategories `B` and `C` consists of a function between objects\n`F.obj`, a function between 1-morphisms `F.map`, and a function between 2-morphisms `F.map₂`.\n\nUnlike functors between categories, `F.map` do not need to strictly commute with the composition,\nand do not need to strictly preserve the identity. Instead, there are specified 2-morphisms\n`F.map (𝟙 a) ⟶ 𝟙 (F.obj a)` and `F.map (f ≫ g) ⟶ F.map f ≫ F.map g`.\n\n`F.map₂` strictly commute with compositions and preserve the identity. They also preserve the\nassociator, the left unitor, and the right unitor modulo some adjustments of domains and codomains\nof 2-morphisms.\n-/\nstructure OplaxFunctor (B : Type u₁) [Bicategory.{w₁, v₁} B] (C : Type u₂)\n  [Bicategory.{w₂, v₂} C] extends PrelaxFunctor B C where\n  mapId (a : B) : map (𝟙 a) ⟶ 𝟙 (obj a)\n  mapComp {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : map (f ≫ g) ⟶ map f ≫ map g\n  mapComp_naturality_left :\n    ∀ {a b c : B} {f f' : a ⟶ b} (η : f ⟶ f') (g : b ⟶ c),\n      map₂ (η ▷ g) ≫ mapComp f' g = mapComp f g ≫ map₂ η ▷ map g := by\n    aesop_cat\n  mapComp_naturality_right :\n    ∀ {a b c : B} (f : a ⟶ b) {g g' : b ⟶ c} (η : g ⟶ g'),\n      map₂ (f ◁ η) ≫ mapComp f g' = mapComp f g ≫ map f ◁ map₂ η := by\n    aesop_cat\n  map₂_id : ∀ {a b : B} (f : a ⟶ b), map₂ (𝟙 f) = 𝟙 (map f) := by aesop\n  map₂_comp :\n    ∀ {a b : B} {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h), map₂ (η ≫ θ) = map₂ η ≫ map₂ θ := by\n    aesop_cat\n  -- porting note: `map₂_associator_aux` was used here in lean 3, but this was a hack\n  -- to avoid a timeout; we revert this hack here (because it was causing other problems\n  -- and was not necessary in lean 4)\n  map₂_associator :\n    ∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d),\n      map₂ (α_ f g h).hom ≫ mapComp f (g ≫ h) ≫ map f ◁ mapComp g h =\n    mapComp (f ≫ g) h ≫ mapComp f g ▷ map h ≫ (α_ (map f) (map g) (map h)).hom := by\n    aesop_cat\n  map₂_leftUnitor :\n    ∀ {a b : B} (f : a ⟶ b),\n      map₂ (λ_ f).hom = mapComp (𝟙 a) f ≫ mapId a ▷ map f ≫ (λ_ (map f)).hom := by\n    aesop_cat\n  map₂_rightUnitor :\n    ∀ {a b : B} (f : a ⟶ b),\n      map₂ (ρ_ f).hom = mapComp f (𝟙 b) ≫ map f ◁ mapId b ≫ (ρ_ (map f)).hom := by\n    aesop_cat\n#align category_theory.oplax_functor CategoryTheory.OplaxFunctor\n#align category_theory.oplax_functor.map_id CategoryTheory.OplaxFunctor.mapId\n#align category_theory.oplax_functor.map_comp CategoryTheory.OplaxFunctor.mapComp\n#align category_theory.oplax_functor.map_comp_naturality_left' CategoryTheory.OplaxFunctor.mapComp_naturality_left\n#align category_theory.oplax_functor.map_comp_naturality_left CategoryTheory.OplaxFunctor.mapComp_naturality_left\n#align category_theory.oplax_functor.map_comp_naturality_right' CategoryTheory.OplaxFunctor.mapComp_naturality_right\n#align category_theory.oplax_functor.map_comp_naturality_right CategoryTheory.OplaxFunctor.mapComp_naturality_right\n#align category_theory.oplax_functor.map₂_id' CategoryTheory.OplaxFunctor.map₂_id\n#align category_theory.oplax_functor.map₂_comp' CategoryTheory.OplaxFunctor.map₂_comp\n#align category_theory.oplax_functor.map₂_associator' CategoryTheory.OplaxFunctor.map₂_associator\n#align category_theory.oplax_functor.map₂_left_unitor CategoryTheory.OplaxFunctor.map₂_leftUnitor\n#align category_theory.oplax_functor.map₂_left_unitor' CategoryTheory.OplaxFunctor.map₂_leftUnitor\n#align category_theory.oplax_functor.map₂_right_unitor CategoryTheory.OplaxFunctor.map₂_rightUnitor\n#align category_theory.oplax_functor.map₂_right_unitor' CategoryTheory.OplaxFunctor.map₂_rightUnitor\n\ninitialize_simps_projections OplaxFunctor (+toPrelaxFunctor, -obj, -map, -map₂)\n\nnamespace OplaxFunctor\n\n/- Porting note: removed primes from field names and remove `restate_axiom` since\nthat is no longer needed in Lean 4 -/\n\n-- porting note: more stuff was tagged `simp` here in lean 3 but `reassoc (attr := simp)`\n-- is doing this job a couple of lines below this.\nattribute [simp] map₂_id\n\n-- porting note: was auto-ported as `attribute [reassoc.1]` for some reason\nattribute [reassoc (attr := simp)]\n  mapComp_naturality_left mapComp_naturality_right map₂_associator\n\n-- the simpNF linter complains that `map₂_leftUnitor_assoc` etc can be\n-- proved with `simp` so I move them here\nattribute [reassoc] map₂_leftUnitor map₂_comp map₂_rightUnitor\nattribute [simp] map₂_leftUnitor map₂_comp map₂_rightUnitor\nsection\n\n/-- The prelax functor between the underlying quivers. -/\nadd_decl_doc OplaxFunctor.toPrelaxFunctor\n\nattribute [nolint docBlame] CategoryTheory.OplaxFunctor.mapId\n  CategoryTheory.OplaxFunctor.mapComp\n  CategoryTheory.OplaxFunctor.mapComp_naturality_left\n  CategoryTheory.OplaxFunctor.mapComp_naturality_right\n  CategoryTheory.OplaxFunctor.map₂_id\n  CategoryTheory.OplaxFunctor.map₂_comp\n  CategoryTheory.OplaxFunctor.map₂_associator\n  CategoryTheory.OplaxFunctor.map₂_leftUnitor\n  CategoryTheory.OplaxFunctor.map₂_rightUnitor\n\ninstance hasCoeToPrelax : Coe (OplaxFunctor B C) (PrelaxFunctor B C) :=\n  ⟨toPrelaxFunctor⟩\n#align category_theory.oplax_functor.has_coe_to_prelax CategoryTheory.OplaxFunctor.hasCoeToPrelax\n\nvariable (F : OplaxFunctor B C)\n\n-- porting note: `to_prelax_eq_coe` and `to_prelaxFunctor_obj` are\n-- syntactic tautologies in lean 4\n#noalign category_theory.oplax_functor.to_prelax_eq_coe\n#noalign category_theory.oplax_functor.to_prelax_functor_obj\n\n--porting note: removed lemma `to_prelaxFunctor_map` relating the now\n-- nonexistent `PrelaxFunctor.map` and `OplaxFunctor.map`\n#noalign CategoryTheory.OplaxFunctor.to_prelaxFunctor_map\n\n--porting note: removed lemma `to_prelaxFunctor_map₂` relating\n-- `PrelaxFunctor.map₂` to nonexistent `OplaxFunctor.map₂`\n#noalign category_theory.oplax_functor.to_prelax_functor_map₂\n\n/-- Function between 1-morphisms as a functor. -/\n@[simps]\ndef mapFunctor (a b : B) : (a ⟶ b) ⥤ (F.obj a ⟶ F.obj b)\n    where\n  obj f := F.map f\n  map η := F.map₂ η\n#align category_theory.oplax_functor.map_functor CategoryTheory.OplaxFunctor.mapFunctor\n\n/-- The identity oplax functor. -/\n@[simps]\ndef id (B : Type u₁) [Bicategory.{w₁, v₁} B] : OplaxFunctor B B :=\n  { PrelaxFunctor.id B with\n    mapId := fun a => 𝟙 (𝟙 a)\n    mapComp := fun f g => 𝟙 (f ≫ g)\n  }\n#align category_theory.oplax_functor.id CategoryTheory.OplaxFunctor.id\n\ninstance : Inhabited (OplaxFunctor B B) :=\n  ⟨id B⟩\n\n/-- Composition of oplax functors. -/\n--@[simps]\ndef comp (F : OplaxFunctor B C) (G : OplaxFunctor C D) : OplaxFunctor B D :=\n  {\n    (F : PrelaxFunctor B C).comp G with\n    mapId := fun a => by exact (G.mapFunctor _ _).map (F.mapId a) ≫ G.mapId (F.obj a)\n    mapComp := fun f g => by\n      exact (G.mapFunctor _ _).map (F.mapComp f g) ≫ G.mapComp (F.map f) (F.map g)\n    mapComp_naturality_left := fun η g =>\n      by\n      dsimp\n      rw [← map₂_comp_assoc, mapComp_naturality_left, map₂_comp_assoc, mapComp_naturality_left,\n        assoc]\n    mapComp_naturality_right := fun η =>\n      by\n      dsimp\n      intros\n      rw [← map₂_comp_assoc, mapComp_naturality_right, map₂_comp_assoc, mapComp_naturality_right,\n        assoc]\n    map₂_associator := fun f g h => by\n      dsimp\n      -- porting note: if you use the `map₂_associator_aux` hack in the definition of\n      -- `map₂_associator` then the `simp only` call below does not seem to apply `map₂_associator`\n      simp only [map₂_associator, ← map₂_comp_assoc, ← mapComp_naturality_right_assoc,\n        whiskerLeft_comp, assoc]\n      simp only [map₂_associator, map₂_comp, mapComp_naturality_left_assoc, comp_whiskerRight,\n        assoc]\n    map₂_leftUnitor := fun f => by\n      dsimp\n      simp only [map₂_leftUnitor, map₂_comp, mapComp_naturality_left_assoc, comp_whiskerRight,\n        assoc]\n    map₂_rightUnitor := fun f => by\n      dsimp\n      simp only [map₂_rightUnitor, map₂_comp, mapComp_naturality_right_assoc, whiskerLeft_comp,\n        assoc] }\n#align category_theory.oplax_functor.comp CategoryTheory.OplaxFunctor.comp\n\n/-- A structure on an oplax functor that promotes an oplax functor to a pseudofunctor.\nSee `Pseudofunctor.mkOfOplax`.\n-/\n-- porting note: removing no lint for nonempty_instance\n--@[nolint has_nonempty_instance]\n-- porting note: removing primes in structure name because\n-- my understanding is that they're no longer needed\nstructure PseudoCore (F : OplaxFunctor B C) where\n  mapIdIso (a : B) : F.map (𝟙 a) ≅ 𝟙 (F.obj a)\n  mapCompIso {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : F.map (f ≫ g) ≅ F.map f ≫ F.map g\n  mapIdIso_hom : ∀ {a : B}, (mapIdIso a).hom = F.mapId a := by aesop_cat\n  mapCompIso_hom :\n    ∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c), (mapCompIso f g).hom = F.mapComp f g := by aesop_cat\n#align category_theory.oplax_functor.pseudo_core CategoryTheory.OplaxFunctor.PseudoCore\n\nattribute [nolint docBlame] CategoryTheory.OplaxFunctor.PseudoCore.mapIdIso\n  CategoryTheory.OplaxFunctor.PseudoCore.mapCompIso\n  CategoryTheory.OplaxFunctor.PseudoCore.mapIdIso_hom\n  CategoryTheory.OplaxFunctor.PseudoCore.mapCompIso_hom\n\nattribute [simp] PseudoCore.mapIdIso_hom PseudoCore.mapCompIso_hom\n\nend\n\nend OplaxFunctor\n\n-- porting note: this auxiliary def was introduced in Lean 3 and only used once, in this file,\n-- to avoid a timeout. In Lean 4 the timeout isn't present and the definition causes other\n-- things to break (simp proofs) so I removed it.\n-- def Pseudofunctor.Map₂AssociatorAux (obj : B → C) (map : ∀ {X Y : B}, (X ⟶ Y) → (obj X ⟶ obj Y))\n--     (map₂ : ∀ {a b : B} {f g : a ⟶ b}, (f ⟶ g) → (map f ⟶ map g))\n--    (map_comp : ∀ {a b c : B} (f : a ⟶ b) (g : b ⟶ c), map (f ≫ g) ≅ map f ≫ map g) {a b c d : B}\n--     (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d) : Prop :=\n--   map₂ (α_ f g h).hom =\n--     (map_comp (f ≫ g) h).hom ≫\n--       (map_comp f g).hom ▷ map h ≫\n--        (α_ (map f) (map g) (map h)).hom ≫ map f ◁ (map_comp g h).inv ≫ (map_comp f (g ≫ h)).inv\n#noalign category_theory.pseudofunctor.map₂_associator_aux\n\n/-- A pseudofunctor `F` between bicategories `B` and `C` consists of a function between objects\n`F.obj`, a function between 1-morphisms `F.map`, and a function between 2-morphisms `F.map₂`.\n\nUnlike functors between categories, `F.map` do not need to strictly commute with the compositions,\nand do not need to strictly preserve the identity. Instead, there are specified 2-isomorphisms\n`F.map (𝟙 a) ≅ 𝟙 (F.obj a)` and `F.map (f ≫ g) ≅ F.map f ≫ F.map g`.\n\n`F.map₂` strictly commute with compositions and preserve the identity. They also preserve the\nassociator, the left unitor, and the right unitor modulo some adjustments of domains and codomains\nof 2-morphisms.\n-/\nstructure Pseudofunctor (B : Type u₁) [Bicategory.{w₁, v₁} B] (C : Type u₂)\n  [Bicategory.{w₂, v₂} C] extends PrelaxFunctor B C where\n  mapId (a : B) : map (𝟙 a) ≅ 𝟙 (obj a)\n  mapComp {a b c : B} (f : a ⟶ b) (g : b ⟶ c) : map (f ≫ g) ≅ map f ≫ map g\n  map₂_id : ∀ {a b : B} (f : a ⟶ b), map₂ (𝟙 f) = 𝟙 (map f) := by aesop_cat\n  map₂_comp :\n    ∀ {a b : B} {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h), map₂ (η ≫ θ) = map₂ η ≫ map₂ θ := by\n    aesop_cat\n  map₂_whisker_left :\n    ∀ {a b c : B} (f : a ⟶ b) {g h : b ⟶ c} (η : g ⟶ h),\n      map₂ (f ◁ η) = (mapComp f g).hom ≫ map f ◁ map₂ η ≫ (mapComp f h).inv := by\n    aesop_cat\n  map₂_whisker_right :\n    ∀ {a b c : B} {f g : a ⟶ b} (η : f ⟶ g) (h : b ⟶ c),\n      map₂ (η ▷ h) = (mapComp f h).hom ≫ map₂ η ▷ map h ≫ (mapComp g h).inv := by\n    aesop_cat\n  map₂_associator :\n    ∀ {a b c d : B} (f : a ⟶ b) (g : b ⟶ c) (h : c ⟶ d),\n      map₂ (α_ f g h).hom = (mapComp (f ≫ g) h).hom ≫ (mapComp f g).hom ▷ map h ≫\n      (α_ (map f) (map g) (map h)).hom ≫ map f ◁ (mapComp g h).inv ≫\n      (mapComp f (g ≫ h)).inv := by\n    aesop_cat\n  map₂_left_unitor :\n    ∀ {a b : B} (f : a ⟶ b),\n      map₂ (λ_ f).hom = (mapComp (𝟙 a) f).hom ≫ (mapId a).hom ▷ map f ≫ (λ_ (map f)).hom := by\n    aesop_cat\n  map₂_right_unitor :\n    ∀ {a b : B} (f : a ⟶ b),\n      map₂ (ρ_ f).hom = (mapComp f (𝟙 b)).hom ≫ map f ◁ (mapId b).hom ≫ (ρ_ (map f)).hom := by\n    aesop_cat\n#align category_theory.pseudofunctor CategoryTheory.Pseudofunctor\n\ninitialize_simps_projections Pseudofunctor (+toPrelaxFunctor, -obj, -map, -map₂)\n\nnamespace Pseudofunctor\n\n-- porting note: was `[reassoc.1]` for some reason?\nattribute [reassoc]\n  map₂_comp map₂_whisker_left map₂_whisker_right map₂_associator map₂_left_unitor map₂_right_unitor\n\nattribute [simp]\n  map₂_id map₂_comp map₂_whisker_left map₂_whisker_right map₂_associator map₂_left_unitor\n  map₂_right_unitor\n\nsection\n\nopen Iso\n\n/-- The prelax functor between the underlying quivers. -/\nadd_decl_doc Pseudofunctor.toPrelaxFunctor\n\n\nattribute [nolint docBlame] CategoryTheory.Pseudofunctor.mapId\n  CategoryTheory.Pseudofunctor.mapComp\n  CategoryTheory.Pseudofunctor.map₂_id\n  CategoryTheory.Pseudofunctor.map₂_comp\n  CategoryTheory.Pseudofunctor.map₂_whisker_left\n  CategoryTheory.Pseudofunctor.map₂_whisker_right\n  CategoryTheory.Pseudofunctor.map₂_associator\n  CategoryTheory.Pseudofunctor.map₂_left_unitor\n  CategoryTheory.Pseudofunctor.map₂_right_unitor\n\ninstance hasCoeToPrelaxFunctor : Coe (Pseudofunctor B C) (PrelaxFunctor B C) :=\n  ⟨toPrelaxFunctor⟩\n#align category_theory.pseudofunctor.has_coe_to_prelax_functor CategoryTheory.Pseudofunctor.hasCoeToPrelaxFunctor\n\nvariable (F : Pseudofunctor B C)\n\n-- porting note: `toPrelaxFunctor_eq_coe` and `to_prelaxFunctor_obj`\n-- are syntactic tautologies in lean 4\n#noalign category_theory.pseudofunctor.to_prelax_functor_eq_coe\n#noalign category_theory.pseudofunctor.to_prelax_functor_obj\n\n--porting note: removed lemma `to_prelaxFunctor_map` relating the now\n-- nonexistent `PrelaxFunctor.map` and the now nonexistent `Pseudofunctor.map`\n#noalign category_theory.pseudofunctor.to_prelax_functor_map\n\n--porting note: removed lemma `to_prelaxFunctor_map₂` relating\n-- `PrelaxFunctor.map₂` to nonexistent `Pseudofunctor.map₂`\n#noalign category_theory.pseudofunctor.to_prelax_functor_map₂\n\n/-- The oplax functor associated with a pseudofunctor. -/\ndef toOplax : OplaxFunctor B C :=\n  { (F : PrelaxFunctor B C) with\n    mapId := fun a => (F.mapId a).hom\n    mapComp := fun f g => (F.mapComp f g).hom }\n#align category_theory.pseudofunctor.to_oplax CategoryTheory.Pseudofunctor.toOplax\n\ninstance hasCoeToOplax : Coe (Pseudofunctor B C) (OplaxFunctor B C) :=\n  ⟨toOplax⟩\n#align category_theory.pseudofunctor.has_coe_to_oplax CategoryTheory.Pseudofunctor.hasCoeToOplax\n\n-- porting note: `toOplax_eq_coe` is a syntactic tautology in lean 4\n#noalign category_theory.pseudofunctor.to_oplax_eq_coe\n\n@[simp]\ntheorem to_oplax_obj : (F : OplaxFunctor B C).obj = F.obj :=\n  rfl\n#align category_theory.pseudofunctor.to_oplax_obj CategoryTheory.Pseudofunctor.to_oplax_obj\n\n-- porting note: to_oplax_map related `OplaxFunctor.map` to `Pseudofunctor.map` but neither\n-- of these exist\n#noalign category_theory.pseudofunctor.to_oplax_map\n\n-- porting note: to_oplax_map₂ related `OplaxFunctor.map₂` to `Pseudofunctor.map₂` but neither\n-- of these exist\n#noalign category_theory.pseudofunctor.to_oplax_map₂\n\n@[simp]\ntheorem to_oplax_mapId (a : B) : (F : OplaxFunctor B C).mapId a = (F.mapId a).hom :=\n  rfl\n#align category_theory.pseudofunctor.to_oplax_map_id CategoryTheory.Pseudofunctor.to_oplax_mapId\n\n@[simp]\ntheorem to_oplax_mapComp {a b c : B} (f : a ⟶ b) (g : b ⟶ c) :\n    (F : OplaxFunctor B C).mapComp f g = (F.mapComp f g).hom :=\n  rfl\n#align category_theory.pseudofunctor.to_oplax_map_comp CategoryTheory.Pseudofunctor.to_oplax_mapComp\n\n-- porting note: I changed `simps` to `simps!` without understanding what I was doing\n-- (lean 4 told me to do this)\n/-- Function on 1-morphisms as a functor. -/\n@[simps!]\ndef mapFunctor (a b : B) : (a ⟶ b) ⥤ (F.obj a ⟶ F.obj b) :=\n  (F : OplaxFunctor B C).mapFunctor a b\n#align category_theory.pseudofunctor.map_functor CategoryTheory.Pseudofunctor.mapFunctor\n\n/-- The identity pseudofunctor. -/\n@[simps]\ndef id (B : Type u₁) [Bicategory.{w₁, v₁} B] : Pseudofunctor B B :=\n  { PrelaxFunctor.id B with\n    mapId := fun a => Iso.refl (𝟙 a)\n    mapComp := fun f g => Iso.refl (f ≫ g) }\n#align category_theory.pseudofunctor.id CategoryTheory.Pseudofunctor.id\n\ninstance : Inhabited (Pseudofunctor B B) :=\n  ⟨id B⟩\n\n-- porting note: this is aesop_cat taking a long time auto-filling in fields\nset_option maxHeartbeats 500000 in\n/-- Composition of pseudofunctors. -/\n@[simps]\ndef comp (F : Pseudofunctor B C) (G : Pseudofunctor C D) : Pseudofunctor B D :=\n  {\n    (F : PrelaxFunctor B C).comp\n      (G : PrelaxFunctor C D) with\n    mapId := fun a => (G.mapFunctor _ _).mapIso (F.mapId a) ≪≫ G.mapId (F.obj a)\n    mapComp := fun f g =>\n      (G.mapFunctor _ _).mapIso (F.mapComp f g) ≪≫ G.mapComp (F.map f) (F.map g) }\n#align category_theory.pseudofunctor.comp CategoryTheory.Pseudofunctor.comp\n\n/-- Construct a pseudofunctor from an oplax functor whose `mapId` and `mapComp` are isomorphisms.\n-/\n@[simps]\ndef mkOfOplax (F : OplaxFunctor B C) (F' : F.PseudoCore) : Pseudofunctor B C :=\n  { (F : PrelaxFunctor B C) with\n    mapId := F'.mapIdIso\n    mapComp := F'.mapCompIso\n    map₂_whisker_left := fun f g h η => by\n      dsimp\n      rw [F'.mapCompIso_hom f g, ← F.mapComp_naturality_right_assoc, ← F'.mapCompIso_hom f h,\n        hom_inv_id, comp_id]\n    map₂_whisker_right := fun η h => by\n      dsimp\n      rw [F'.mapCompIso_hom _ h, ← F.mapComp_naturality_left_assoc, ← F'.mapCompIso_hom _ h,\n        hom_inv_id, comp_id]\n    map₂_associator := fun f g h => by\n      dsimp\n      rw [F'.mapCompIso_hom (f ≫ g) h, F'.mapCompIso_hom f g, ← F.map₂_associator_assoc, ←\n        F'.mapCompIso_hom f (g ≫ h), ← F'.mapCompIso_hom g h, hom_inv_whiskerLeft_assoc,\n        hom_inv_id, comp_id] }\n#align category_theory.pseudofunctor.mk_of_oplax CategoryTheory.Pseudofunctor.mkOfOplax\n\n/-- Construct a pseudofunctor from an oplax functor whose `mapId` and `mapComp` are isomorphisms.\n-/\n@[simps]\nnoncomputable def mkOfOplax' (F : OplaxFunctor B C) [∀ a, IsIso (F.mapId a)]\n    [∀ {a b c} (f : a ⟶ b) (g : b ⟶ c), IsIso (F.mapComp f g)] : Pseudofunctor B C :=\n  { (F : PrelaxFunctor B C) with\n    mapId := fun a => asIso (F.mapId a)\n    mapComp := fun f g => asIso (F.mapComp f g)\n    map₂_whisker_left := fun f g h η => by\n      dsimp\n      rw [← assoc, IsIso.eq_comp_inv, F.mapComp_naturality_right]\n    map₂_whisker_right := fun η h => by\n      dsimp\n      rw [← assoc, IsIso.eq_comp_inv, F.mapComp_naturality_left]\n    map₂_associator := fun f g h => by\n      dsimp\n      simp only [← assoc]\n      rw [IsIso.eq_comp_inv, ← inv_whiskerLeft, IsIso.eq_comp_inv]\n      simp only [assoc, F.map₂_associator] }\n#align category_theory.pseudofunctor.mk_of_oplax' CategoryTheory.Pseudofunctor.mkOfOplax'\n\nend\n\nend Pseudofunctor\n\nend\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Bicategory/Functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833893685269, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.47643683588505353}}
{"text": "/-\nCopyright (c) 2022 María Inés de Frutos-Fernández. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: María Inés de Frutos-Fernández\n-/\nimport ring_theory.dedekind_domain.ideal\nimport ring_theory.valuation.extend_to_localization\nimport ring_theory.valuation.valuation_subring\nimport ring_theory.polynomial.cyclotomic.basic\nimport topology.algebra.valued_field\n\n/-!\n# Adic valuations on Dedekind domains\nGiven a Dedekind domain `R` of Krull dimension 1 and a maximal ideal `v` of `R`, we define the\n`v`-adic valuation on `R` and its extension to the field of fractions `K` of `R`.\nWe prove several properties of this valuation, including the existence of uniformizers.\n\nWe define the completion of `K` with respect to the `v`-adic valuation, denoted\n`v.adic_completion`,and its ring of integers, denoted `v.adic_completion_integers`.\n\n## Main definitions\n - `is_dedekind_domain.height_one_spectrum.int_valuation v` is the `v`-adic valuation on `R`.\n - `is_dedekind_domain.height_one_spectrum.valuation v` is the `v`-adic valuation on `K`.\n - `is_dedekind_domain.height_one_spectrum.adic_completion v` is the completion of `K` with respect\n    to its `v`-adic valuation.\n - `is_dedekind_domain.height_one_spectrum.adic_completion_integers v` is the ring of integers of\n    `v.adic_completion`.\n\n## Main results\n- `is_dedekind_domain.height_one_spectrum.int_valuation_le_one` : The `v`-adic valuation on `R` is\n  bounded above by 1.\n- `is_dedekind_domain.height_one_spectrum.int_valuation_lt_one_iff_dvd` : The `v`-adic valuation of\n  `r ∈ R` is less than 1 if and only if `v` divides the ideal `(r)`.\n- `is_dedekind_domain.height_one_spectrum.int_valuation_le_pow_iff_dvd` : The `v`-adic valuation of\n  `r ∈ R` is less than or equal to `multiplicative.of_add (-n)` if and only if `vⁿ` divides the\n  ideal `(r)`.\n- `is_dedekind_domain.height_one_spectrum.int_valuation_exists_uniformizer` : There exists `π ∈ R`\n  with `v`-adic valuation `multiplicative.of_add (-1)`.\n- `is_dedekind_domain.height_one_spectrum.valuation_of_mk'` : The `v`-adic valuation of `r/s ∈ K`\n  is the valuation of `r` divided by the valuation of `s`.\n- `is_dedekind_domain.height_one_spectrum.valuation_of_algebra_map` : The `v`-adic valuation on `K`\n  extends the `v`-adic valuation on `R`.\n- `is_dedekind_domain.height_one_spectrum.valuation_exists_uniformizer` : There exists `π ∈ K` with\n  `v`-adic valuation `multiplicative.of_add (-1)`.\n\n## Implementation notes\nWe are only interested in Dedekind domains with Krull dimension 1.\n\n## References\n* [G. J. Janusz, *Algebraic Number Fields*][janusz1996]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]\n\n## Tags\ndedekind domain, dedekind ring, adic valuation\n-/\n\nnoncomputable theory\nopen_locale classical discrete_valuation\n\nopen multiplicative is_dedekind_domain\n\nvariables {R : Type*} [comm_ring R] [is_domain R] [is_dedekind_domain R] {K : Type*} [field K]\n  [algebra R K] [is_fraction_ring R K] (v : height_one_spectrum R)\n\nnamespace is_dedekind_domain.height_one_spectrum\n/-! ### Adic valuations on the Dedekind domain R -/\n\n/-- The additive `v`-adic valuation of `r ∈ R` is the exponent of `v` in the factorization of the\nideal `(r)`, if `r` is nonzero, or infinity, if `r = 0`. `int_valuation_def` is the corresponding\nmultiplicative valuation. -/\ndef int_valuation_def (r : R) : ℤₘ₀ :=\nif r = 0 then 0 else multiplicative.of_add\n  (-(associates.mk v.as_ideal).count (associates.mk (ideal.span {r} : ideal R)).factors : ℤ)\n\nlemma int_valuation_def_if_pos {r : R} (hr : r = 0) : v.int_valuation_def r = 0 := if_pos hr\n\nlemma int_valuation_def_if_neg {r : R} (hr : r ≠ 0) : v.int_valuation_def r = (multiplicative.of_add\n  (-(associates.mk v.as_ideal).count (associates.mk (ideal.span {r} : ideal R)).factors : ℤ)) :=\nif_neg hr\n\n/-- Nonzero elements have nonzero adic valuation. -/\nlemma int_valuation_ne_zero (x : R) (hx : x ≠ 0) : v.int_valuation_def x ≠ 0 :=\nbegin\n  rw [int_valuation_def, if_neg hx],\n  exact with_zero.coe_ne_zero,\nend\n\n/-- Nonzero divisors have nonzero valuation. -/\nlemma int_valuation_ne_zero' (x : non_zero_divisors R) : v.int_valuation_def x ≠ 0 :=\nv.int_valuation_ne_zero x (non_zero_divisors.coe_ne_zero x)\n\n/-- Nonzero divisors have valuation greater than zero. -/\nlemma int_valuation_zero_le (x : non_zero_divisors R) : 0 < v.int_valuation_def x :=\nbegin\n  rw [v.int_valuation_def_if_neg (non_zero_divisors.coe_ne_zero x)],\n  exact with_zero.zero_lt_coe _,\nend\n\n/-- The `v`-adic valuation on `R` is bounded above by 1. -/\nlemma int_valuation_le_one (x : R) : v.int_valuation_def x ≤ 1 :=\nbegin\n  rw int_valuation_def,\n  by_cases hx : x = 0,\n  { rw if_pos hx, exact with_zero.zero_le 1 },\n  { rw [if_neg hx, ← with_zero.coe_one, ← of_add_zero, with_zero.coe_le_coe, of_add_le,\n      right.neg_nonpos_iff],\n    exact int.coe_nat_nonneg _ }\nend\n\n/-- The `v`-adic valuation of `r ∈ R` is less than 1 if and only if `v` divides the ideal `(r)`. -/\nlemma int_valuation_lt_one_iff_dvd (r : R) :\n  v.int_valuation_def r < 1 ↔ v.as_ideal ∣ ideal.span {r} :=\nbegin\n  rw int_valuation_def,\n  split_ifs with hr,\n  { simpa [hr] using (with_zero.zero_lt_coe _) },\n  { rw [← with_zero.coe_one, ← of_add_zero, with_zero.coe_lt_coe, of_add_lt, neg_lt_zero,\n      ← int.coe_nat_zero, int.coe_nat_lt, zero_lt_iff],\n    have h : (ideal.span {r} : ideal R) ≠ 0,\n    { rw [ne.def, ideal.zero_eq_bot, ideal.span_singleton_eq_bot],\n      exact hr },\n    apply associates.count_ne_zero_iff_dvd h (by apply v.irreducible) }\nend\n\n/-- The `v`-adic valuation of `r ∈ R` is less than `multiplicative.of_add (-n)` if and only if\n`vⁿ` divides the ideal `(r)`. -/\nlemma int_valuation_le_pow_iff_dvd (r : R) (n : ℕ) :\n  v.int_valuation_def r ≤ multiplicative.of_add (-(n : ℤ)) ↔ v.as_ideal^n ∣ ideal.span {r} :=\nbegin\n  rw int_valuation_def,\n  split_ifs with hr,\n  { simp_rw [hr, ideal.dvd_span_singleton, zero_le', submodule.zero_mem], },\n  { rw [with_zero.coe_le_coe, of_add_le, neg_le_neg_iff, int.coe_nat_le, ideal.dvd_span_singleton,\n      ← associates.le_singleton_iff, associates.prime_pow_dvd_iff_le (associates.mk_ne_zero'.mpr hr)\n      (by apply v.associates_irreducible)] }\nend\n\n/-- The `v`-adic valuation of `0 : R` equals 0. -/\nlemma int_valuation.map_zero' : v.int_valuation_def 0 = 0 := v.int_valuation_def_if_pos (eq.refl 0)\n\n/-- The `v`-adic valuation of `1 : R` equals 1. -/\nlemma int_valuation.map_one' : v.int_valuation_def 1 = 1 :=\nby rw [v.int_valuation_def_if_neg (zero_ne_one.symm : (1 : R) ≠ 0), ideal.span_singleton_one,\n  ← ideal.one_eq_top, associates.mk_one, associates.factors_one, associates.count_zero\n  (by apply v.associates_irreducible), int.coe_nat_zero, neg_zero, of_add_zero, with_zero.coe_one]\n\n/-- The `v`-adic valuation of a product equals the product of the valuations. -/\nlemma int_valuation.map_mul' (x y : R) :\n  v.int_valuation_def (x * y) = v.int_valuation_def x * v.int_valuation_def y :=\nbegin\n  simp only [int_valuation_def],\n  by_cases hx : x = 0,\n  { rw [hx, zero_mul, if_pos (eq.refl _), zero_mul] },\n  { by_cases hy : y = 0,\n    { rw [hy, mul_zero, if_pos (eq.refl _), mul_zero] },\n    { rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), ← with_zero.coe_mul, with_zero.coe_inj,\n        ← of_add_add, ← ideal.span_singleton_mul_span_singleton, ← associates.mk_mul_mk, ← neg_add,\n        associates.count_mul (by apply associates.mk_ne_zero'.mpr hx)\n        (by apply associates.mk_ne_zero'.mpr hy) (by apply v.associates_irreducible)],\n      refl }}\nend\n\nlemma int_valuation.le_max_iff_min_le {a b c : ℕ} :  multiplicative.of_add(-c : ℤ) ≤\n  max (multiplicative.of_add(-a : ℤ)) (multiplicative.of_add(-b : ℤ)) ↔ min a b ≤ c :=\nby rw [le_max_iff, of_add_le, of_add_le, neg_le_neg_iff, neg_le_neg_iff, int.coe_nat_le,\n    int.coe_nat_le, ← min_le_iff]\n\n/-- The `v`-adic valuation of a sum is bounded above by the maximum of the valuations. -/\nlemma int_valuation.map_add_le_max' (x y : R) : v.int_valuation_def (x + y) ≤\n  max (v.int_valuation_def x) (v.int_valuation_def y) :=\nbegin\n  by_cases hx : x = 0,\n  { rw [hx, zero_add],\n    conv_rhs {rw [int_valuation_def, if_pos (eq.refl _)]},\n    rw max_eq_right (with_zero.zero_le (v.int_valuation_def y)),\n    exact le_refl _, },\n  { by_cases hy : y = 0,\n    { rw [hy, add_zero],\n      conv_rhs {rw [max_comm, int_valuation_def, if_pos (eq.refl _)]},\n      rw max_eq_right (with_zero.zero_le (v.int_valuation_def x)),\n      exact le_refl _ },\n    { by_cases hxy : x + y = 0,\n      { rw [int_valuation_def, if_pos hxy], exact zero_le',},\n      { rw [v.int_valuation_def_if_neg hxy, v.int_valuation_def_if_neg hx,\n          v.int_valuation_def_if_neg hy, with_zero.le_max_iff, int_valuation.le_max_iff_min_le],\n      set nmin := min\n        ((associates.mk v.as_ideal).count (associates.mk (ideal.span {x})).factors)\n        ((associates.mk v.as_ideal).count (associates.mk (ideal.span {y})).factors),\n      have h_dvd_x : x ∈ v.as_ideal ^ (nmin),\n      { rw [← associates.le_singleton_iff x nmin _,\n          associates.prime_pow_dvd_iff_le (associates.mk_ne_zero'.mpr hx) _],\n        exact min_le_left _ _,\n        apply v.associates_irreducible },\n      have h_dvd_y : y ∈ v.as_ideal ^ nmin,\n      { rw [← associates.le_singleton_iff y nmin _,\n          associates.prime_pow_dvd_iff_le (associates.mk_ne_zero'.mpr hy) _],\n        exact min_le_right _ _,\n        apply v.associates_irreducible },\n      have h_dvd_xy : associates.mk v.as_ideal^nmin ≤ associates.mk (ideal.span {x + y}),\n      { rw associates.le_singleton_iff,\n        exact ideal.add_mem (v.as_ideal^nmin) h_dvd_x h_dvd_y, },\n      rw (associates.prime_pow_dvd_iff_le (associates.mk_ne_zero'.mpr hxy) _) at h_dvd_xy,\n      exact h_dvd_xy,\n      apply v.associates_irreducible, }}}\nend\n\n/-- The `v`-adic valuation on `R`. -/\ndef int_valuation : valuation R ℤₘ₀ :=\n{ to_fun          := v.int_valuation_def,\n  map_zero'       := int_valuation.map_zero' v,\n  map_one'        := int_valuation.map_one' v,\n  map_mul'        := int_valuation.map_mul' v,\n  map_add_le_max' := int_valuation.map_add_le_max' v }\n\n/-- There exists `π ∈ R` with `v`-adic valuation `multiplicative.of_add (-1)`. -/\nlemma int_valuation_exists_uniformizer :\n  ∃ (π : R), v.int_valuation_def π = multiplicative.of_add (-1 : ℤ) :=\nbegin\n  have hv : _root_.irreducible (associates.mk v.as_ideal) := v.associates_irreducible,\n  have hlt : v.as_ideal^2 < v.as_ideal,\n  { rw ← ideal.dvd_not_unit_iff_lt,\n    exact ⟨v.ne_bot, v.as_ideal,\n     (not_congr ideal.is_unit_iff).mpr (ideal.is_prime.ne_top v.is_prime), sq v.as_ideal⟩ } ,\n  obtain ⟨π, mem, nmem⟩ := set_like.exists_of_lt hlt,\n  have hπ : associates.mk (ideal.span {π}) ≠ 0,\n  { rw associates.mk_ne_zero',\n    intro h,\n    rw h at nmem,\n    exact nmem (submodule.zero_mem (v.as_ideal^2)), },\n  use π,\n  rw [int_valuation_def, if_neg (associates.mk_ne_zero'.mp hπ), with_zero.coe_inj],\n  apply congr_arg,\n  rw [neg_inj, ← int.coe_nat_one, int.coe_nat_inj'],\n  rw [← ideal.dvd_span_singleton, ← associates.mk_le_mk_iff_dvd_iff] at mem nmem,\n  rw [← pow_one (associates.mk v.as_ideal), associates.prime_pow_dvd_iff_le hπ hv] at mem,\n  rw [associates.mk_pow, associates.prime_pow_dvd_iff_le hπ hv, not_le] at nmem,\n  exact nat.eq_of_le_of_lt_succ mem nmem,\nend\n\n/-! ### Adic valuations on the field of fractions `K` -/\n\n/-- The `v`-adic valuation of `x ∈ K` is the valuation of `r` divided by the valuation of `s`,\nwhere `r` and `s` are chosen so that `x = r/s`. -/\ndef valuation (v : height_one_spectrum R) : valuation K ℤₘ₀ :=\nv.int_valuation.extend_to_localization (λ r hr, set.mem_compl $ v.int_valuation_ne_zero' ⟨r, hr⟩) K\n\nlemma valuation_def (x : K) : v.valuation x = v.int_valuation.extend_to_localization\n  (λ r hr, set.mem_compl (v.int_valuation_ne_zero' ⟨r, hr⟩)) K x :=\nrfl\n\n/-- The `v`-adic valuation of `r/s ∈ K` is the valuation of `r` divided by the valuation of `s`. -/\nlemma valuation_of_mk' {r : R} {s : non_zero_divisors R} :\n  v.valuation (is_localization.mk' K r s) = v.int_valuation r / v.int_valuation s :=\nbegin\n  erw [valuation_def, (is_localization.to_localization_map (non_zero_divisors R) K).lift_mk',\n    div_eq_mul_inv, mul_eq_mul_left_iff],\n  left,\n  rw [units.coe_inv, inv_inj],\n  refl,\nend\n\n/-- The `v`-adic valuation on `K` extends the `v`-adic valuation on `R`. -/\nlemma valuation_of_algebra_map (r : R) :\n  v.valuation (algebra_map R K r) = v.int_valuation r :=\nby rw [valuation_def, valuation.extend_to_localization_apply_map_apply]\n\n/-- The `v`-adic valuation on `R` is bounded above by 1. -/\nlemma valuation_le_one (r : R) : v.valuation (algebra_map R K r) ≤ 1 :=\nby { rw valuation_of_algebra_map, exact v.int_valuation_le_one r }\n\n/-- The `v`-adic valuation of `r ∈ R` is less than 1 if and only if `v` divides the ideal `(r)`. -/\nlemma valuation_lt_one_iff_dvd (r : R) :\n  v.valuation (algebra_map R K r) < 1 ↔ v.as_ideal ∣ ideal.span {r} :=\nby { rw valuation_of_algebra_map, exact v.int_valuation_lt_one_iff_dvd r }\n\nvariable (K)\n/-- There exists `π ∈ K` with `v`-adic valuation `multiplicative.of_add (-1)`. -/\nlemma valuation_exists_uniformizer :\n  ∃ (π : K), v.valuation π = multiplicative.of_add (-1 : ℤ) :=\nbegin\n  obtain ⟨r, hr⟩ := v.int_valuation_exists_uniformizer,\n  use algebra_map R K r,\n  rw [valuation_def, valuation.extend_to_localization_apply_map_apply],\n  exact hr,\nend\n\n/-- Uniformizers are nonzero. -/\nlemma valuation_uniformizer_ne_zero :\n  (classical.some (v.valuation_exists_uniformizer K)) ≠ 0 :=\nbegin\n  have hu := classical.some_spec (v.valuation_exists_uniformizer K),\n  exact (valuation.ne_zero_iff _).mp (ne_of_eq_of_ne hu with_zero.coe_ne_zero),\nend\n\n/-! ### Completions with respect to adic valuations\n\nGiven a Dedekind domain `R` with field of fractions `K` and a maximal ideal `v` of `R`, we define\nthe completion of `K` with respect to its `v`-adic valuation, denoted `v.adic_completion`, and its\nring of integers, denoted `v.adic_completion_integers`. -/\n\nvariable {K}\n\n/-- `K` as a valued field with the `v`-adic valuation. -/\ndef adic_valued : valued K ℤₘ₀ := valued.mk' v.valuation\n\nlemma adic_valued_apply {x : K} : (v.adic_valued.v : _) x = v.valuation x := rfl\n\nvariables (K)\n\n/-- The completion of `K` with respect to its `v`-adic valuation. -/\ndef adic_completion := @uniform_space.completion K v.adic_valued.to_uniform_space\n\ninstance : field (v.adic_completion K) :=\n@uniform_space.completion.field K _ v.adic_valued.to_uniform_space _ _\n  v.adic_valued.to_uniform_add_group\n\ninstance : inhabited (v.adic_completion K) := ⟨0⟩\n\ninstance valued_adic_completion : valued (v.adic_completion K) ℤₘ₀ :=\n@valued.valued_completion _ _ _ _ v.adic_valued\n\nlemma valued_adic_completion_def {x : v.adic_completion K} :\n  valued.v x = @valued.extension K _ _ _ (adic_valued v) x := rfl\n\ninstance adic_completion_complete_space : complete_space (v.adic_completion K) :=\n@uniform_space.completion.complete_space K v.adic_valued.to_uniform_space\n\ninstance adic_completion.has_lift_t : has_lift_t K (v.adic_completion K) :=\n(infer_instance : has_lift_t K (@uniform_space.completion K v.adic_valued.to_uniform_space))\n\n/-- The ring of integers of `adic_completion`. -/\ndef adic_completion_integers : valuation_subring (v.adic_completion K) := valued.v.valuation_subring\n\ninstance : inhabited (adic_completion_integers K v) := ⟨0⟩\n\nvariables (R K)\n\nlemma mem_adic_completion_integers {x : v.adic_completion K} :\n  x ∈ v.adic_completion_integers K ↔ (valued.v x : ℤₘ₀) ≤ 1 :=\niff.rfl\n\nsection algebra_instances\n\n@[priority 100] instance adic_valued.has_uniform_continuous_const_smul' :\n  @has_uniform_continuous_const_smul R K v.adic_valued.to_uniform_space _ :=\n@has_uniform_continuous_const_smul_of_continuous_const_smul R K _ _ _\n    v.adic_valued.to_uniform_space _ _\n\ninstance adic_valued.has_uniform_continuous_const_smul :\n  @has_uniform_continuous_const_smul K K v.adic_valued.to_uniform_space _ :=\n@ring.has_uniform_continuous_const_smul K _ v.adic_valued.to_uniform_space _ _\n\ninstance adic_completion.algebra' : algebra R (v.adic_completion K) :=\n@uniform_space.completion.algebra K _ v.adic_valued.to_uniform_space _ _ R _ _\n  (adic_valued.has_uniform_continuous_const_smul' R K v)\n\n@[simp] lemma coe_smul_adic_completion (r : R) (x : K) :\n  (↑(r • x) : v.adic_completion K) = r • (↑x : v.adic_completion K) :=\n@uniform_space.completion.coe_smul R K v.adic_valued.to_uniform_space _ _ r x\n\ninstance : algebra K (v.adic_completion K) :=\n@uniform_space.completion.algebra' K _ v.adic_valued.to_uniform_space _ _\n\nlemma algebra_map_adic_completion' :\n  ⇑(algebra_map R $ v.adic_completion K) = coe ∘ algebra_map R K :=\nrfl\n\nlemma algebra_map_adic_completion :\n  ⇑(algebra_map K $ v.adic_completion K) = coe :=\nrfl\n\ninstance : is_scalar_tower R K (v.adic_completion K) :=\n@uniform_space.completion.is_scalar_tower R K K v.adic_valued.to_uniform_space _ _ _\n  (adic_valued.has_uniform_continuous_const_smul' R K v) _ _\n\ninstance : algebra R (v.adic_completion_integers K) :=\n{ smul      := λ r x, ⟨r • (x : v.adic_completion K), begin\n    have h : ((algebra_map R (adic_completion K v)) r) = (coe $ algebra_map R K r) := rfl,\n    rw algebra.smul_def,\n    refine valuation_subring.mul_mem _ _ _ _ x.2,\n    rw [mem_adic_completion_integers, h, valued.valued_completion_apply],\n    exact v.valuation_le_one _,\n  end⟩,\n  to_fun    := λ r, ⟨coe $ algebra_map R K r, by simpa only [mem_adic_completion_integers,\n    valued.valued_completion_apply] using v.valuation_le_one _⟩,\n  map_one'  := by simp only [map_one]; refl,\n  map_mul'  := λ x y,\n  begin\n    ext,\n    simp_rw [ring_hom.map_mul, subring.coe_mul, subtype.coe_mk, uniform_space.completion.coe_mul],\n  end,\n  map_zero' := by simp only [map_zero]; refl,\n  map_add'  := λ x y,\n  begin\n    ext,\n    simp_rw [ring_hom.map_add, subring.coe_add, subtype.coe_mk, uniform_space.completion.coe_add],\n  end,\n  commutes' := λ r x, by rw mul_comm,\n  smul_def' := λ r x, begin\n    ext,\n    simp only [subring.coe_mul, set_like.coe_mk, algebra.smul_def],\n    refl,\n  end }\n\n@[simp] lemma coe_smul_adic_completion_integers (r : R) (x : v.adic_completion_integers K) :\n  (↑(r • x) : v.adic_completion K) = r • (x : v.adic_completion K) :=\nrfl\n\ninstance : no_zero_smul_divisors R (v.adic_completion_integers K) :=\n{ eq_zero_or_eq_zero_of_smul_eq_zero := λ c x hcx,\n  begin\n    rw [algebra.smul_def, mul_eq_zero] at hcx,\n    refine hcx.imp_left (λ hc, _),\n    letI : uniform_space K := v.adic_valued.to_uniform_space,\n    rw ← map_zero (algebra_map R (v.adic_completion_integers K)) at hc,\n    exact (is_fraction_ring.injective R K\n      (uniform_space.completion.coe_injective K (subtype.ext_iff.mp hc)))\n  end }\n\ninstance adic_completion.is_scalar_tower' :\n  is_scalar_tower R (v.adic_completion_integers K) (v.adic_completion K) :=\n{ smul_assoc := λ x y z, by {simp only [algebra.smul_def], apply mul_assoc, }}\n\nend algebra_instances\n\nend is_dedekind_domain.height_one_spectrum\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/dedekind_domain/adic_valuation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4764368326843802}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Filippo A. E. Nuccio\n-/\nimport ring_theory.localization\nimport ring_theory.noetherian\nimport ring_theory.principal_ideal_domain\nimport tactic.field_simp\n\n/-!\n# Fractional ideals\n\nThis file defines fractional ideals of an integral domain and proves basic facts about them.\n\n## Main definitions\nLet `S` be a submonoid of an integral domain `R`, `P` the localization of `R` at `S`, and `f` the\nnatural ring hom from `R` to `P`.\n * `is_fractional` defines which `R`-submodules of `P` are fractional ideals\n * `fractional_ideal S P` is the type of fractional ideals in `P`\n * `has_coe_t (ideal R) (fractional_ideal S P)` instance\n * `comm_semiring (fractional_ideal S P)` instance:\n   the typical ideal operations generalized to fractional ideals\n * `lattice (fractional_ideal S P)` instance\n * `map` is the pushforward of a fractional ideal along an algebra morphism\n\nLet `K` be the localization of `R` at `R⁰ = R \\ {0}` (i.e. the field of fractions).\n * `fractional_ideal R⁰ K` is the type of fractional ideals in the field of fractions\n * `has_div (fractional_ideal R⁰ K)` instance:\n   the ideal quotient `I / J` (typically written $I : J$, but a `:` operator cannot be defined)\n\n## Main statements\n\n  * `mul_left_mono` and `mul_right_mono` state that ideal multiplication is monotone\n  * `prod_one_self_div_eq` states that `1 / I` is the inverse of `I` if one exists\n  * `is_noetherian` states that very fractional ideal of a noetherian integral domain is noetherian\n\n## Implementation notes\n\nFractional ideals are considered equal when they contain the same elements,\nindependent of the denominator `a : R` such that `a I ⊆ R`.\nThus, we define `fractional_ideal` to be the subtype of the predicate `is_fractional`,\ninstead of having `fractional_ideal` be a structure of which `a` is a field.\n\nMost definitions in this file specialize operations from submodules to fractional ideals,\nproving that the result of this operation is fractional if the input is fractional.\nExceptions to this rule are defining `(+) := (⊔)` and `⊥ := 0`,\nin order to re-use their respective proof terms.\nWe can still use `simp` to show `↑I + ↑J = ↑(I + J)` and `↑⊥ = ↑0`.\n\nMany results in fact do not need that `P` is a localization, only that `P` is an\n`R`-algebra. We omit the `is_localization` parameter whenever this is practical.\nSimilarly, we don't assume that the localization is a field until we need it to\ndefine ideal quotients. When this assumption is needed, we replace `S` with `R⁰`,\nmaking the localization a field.\n\n## References\n\n  * https://en.wikipedia.org/wiki/Fractional_ideal\n\n## Tags\n\nfractional ideal, fractional ideals, invertible ideal\n-/\n\nopen is_localization\nopen_locale pointwise\n\nopen_locale non_zero_divisors\n\nsection defs\n\nvariables {R : Type*} [comm_ring R] {S : submonoid R} {P : Type*} [comm_ring P]\nvariables [algebra R P]\n\nvariables (S)\n\n/-- A submodule `I` is a fractional ideal if `a I ⊆ R` for some `a ≠ 0`. -/\ndef is_fractional (I : submodule R P) :=\n∃ a ∈ S, ∀ b ∈ I, is_integer R (a • b)\n\nvariables (S P)\n\n/-- The fractional ideals of a domain `R` are ideals of `R` divided by some `a ∈ R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I ⊆ P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I ⊆ R`.\n-/\ndef fractional_ideal :=\n{I : submodule R P // is_fractional S I}\n\nend defs\n\nnamespace fractional_ideal\n\nopen set\nopen submodule\n\nvariables {R : Type*} [comm_ring R] {S : submonoid R} {P : Type*} [comm_ring P]\nvariables [algebra R P] [loc : is_localization S P]\n\n/-- Map a fractional ideal `I` to a submodule by forgetting that `∃ a, a I ⊆ R`.\n\nThis coercion is typically called `coe_to_submodule` in lemma names\n(or `coe` when the coercion is clear from the context),\nnot to be confused with `is_localization.coe_submodule : ideal R → submodule R P`\n(which we use to define `coe : ideal R → fractional_ideal S P`,\nreferred to as `coe_ideal` in theorem names).\n-/\ninstance : has_coe (fractional_ideal S P) (submodule R P) := ⟨λ I, I.val⟩\n\nprotected lemma is_fractional (I : fractional_ideal S P) :\n  is_fractional S (I : submodule R P) :=\nI.prop\n\nsection set_like\n\ninstance : set_like (fractional_ideal S P) P :=\n{ coe := λ I, ↑(I : submodule R P),\n  coe_injective' := set_like.coe_injective.comp subtype.coe_injective }\n\n@[simp] lemma mem_coe {I : fractional_ideal S P} {x : P} :\n  x ∈ (I : submodule R P) ↔ x ∈ I :=\niff.rfl\n\n@[ext] lemma ext {I J : fractional_ideal S P} : (∀ x, x ∈ I ↔ x ∈ J) → I = J := set_like.ext\n\n/-- Copy of a `fractional_ideal` with a new underlying set equal to the old one.\nUseful to fix definitional equalities. -/\nprotected def copy (p : fractional_ideal S P) (s : set P) (hs : s = ↑p) : fractional_ideal S P :=\n⟨submodule.copy p s hs, by { convert p.is_fractional, ext, simp only [hs], refl }⟩\n\nend set_like\n\n@[simp] lemma val_eq_coe (I : fractional_ideal S P) : I.val = I := rfl\n\n@[simp, norm_cast] lemma coe_mk (I : submodule R P) (hI : is_fractional S I) :\n  (subtype.mk I hI : submodule R P) = I := rfl\n\nlemma coe_to_submodule_injective :\n  function.injective (coe : fractional_ideal S P → submodule R P) :=\nsubtype.coe_injective\n\nlemma is_fractional_of_le_one (I : submodule R P) (h : I ≤ 1) :\n  is_fractional S I :=\nbegin\n  use [1, S.one_mem],\n  intros b hb,\n  rw one_smul,\n  obtain ⟨b', b'_mem, rfl⟩ := h hb,\n  exact set.mem_range_self b',\nend\n\nlemma is_fractional_of_le {I : submodule R P} {J : fractional_ideal S P}\n  (hIJ : I ≤ J) : is_fractional S I :=\nbegin\n  obtain ⟨a, a_mem, ha⟩ := J.is_fractional,\n  use [a, a_mem],\n  intros b b_mem,\n  exact ha b (hIJ b_mem)\nend\n\n/-- Map an ideal `I` to a fractional ideal by forgetting `I` is integral.\n\nThis is a bundled version of `is_localization.coe_submodule : ideal R → submodule R P`,\nwhich is not to be confused with the `coe : fractional_ideal S P → submodule R P`,\nalso called `coe_to_submodule` in theorem names.\n\nThis map is available as a ring hom, called `fractional_ideal.coe_ideal_hom`.\n-/\n-- Is a `coe_t` rather than `coe` to speed up failing inference, see library note [use has_coe_t]\ninstance coe_to_fractional_ideal : has_coe_t (ideal R) (fractional_ideal S P) :=\n⟨λ I, ⟨coe_submodule P I, is_fractional_of_le_one _\n  (by simpa using coe_submodule_mono P (le_top : I ≤ ⊤))⟩⟩\n\n@[simp, norm_cast] lemma coe_coe_ideal (I : ideal R) :\n  ((I : fractional_ideal S P) : submodule R P) = coe_submodule P I := rfl\n\nvariables (S)\n\n@[simp] lemma mem_coe_ideal {x : P} {I : ideal R} :\n  x ∈ (I : fractional_ideal S P) ↔ ∃ x', x' ∈ I ∧ algebra_map R P x' = x :=\nmem_coe_submodule _ _\n\nlemma mem_coe_ideal_of_mem {x : R} {I : ideal R} (hx : x ∈ I) :\n  algebra_map R P x ∈ (I : fractional_ideal S P) :=\n(mem_coe_ideal S).mpr ⟨x, hx, rfl⟩\n\nlemma coe_ideal_le_coe_ideal' [is_localization S P] (h : S ≤ non_zero_divisors R)\n  {I J : ideal R} : (I : fractional_ideal S P) ≤ J ↔ I ≤ J :=\ncoe_submodule_le_coe_submodule h\n\n@[simp] lemma coe_ideal_le_coe_ideal (K : Type*) [comm_ring K] [algebra R K] [is_fraction_ring R K]\n  {I J : ideal R} : (I : fractional_ideal R⁰ K) ≤ J ↔ I ≤ J :=\nis_fraction_ring.coe_submodule_le_coe_submodule\n\ninstance : has_zero (fractional_ideal S P) := ⟨(0 : ideal R)⟩\n\n@[simp] lemma mem_zero_iff {x : P} : x ∈ (0 : fractional_ideal S P) ↔ x = 0 :=\n⟨(λ ⟨x', x'_mem_zero, x'_eq_x⟩,\n   have x'_eq_zero : x' = 0 := x'_mem_zero,\n   by simp [x'_eq_x.symm, x'_eq_zero]),\n (λ hx, ⟨0, rfl, by simp [hx]⟩)⟩\n\nvariables {S}\n\n@[simp, norm_cast] lemma coe_zero : ↑(0 : fractional_ideal S P) = (⊥ : submodule R P) :=\nsubmodule.ext $ λ _, mem_zero_iff S\n\n@[simp, norm_cast] lemma coe_to_fractional_ideal_bot : ((⊥ : ideal R) : fractional_ideal S P) = 0 :=\nrfl\n\nvariables (P)\n\ninclude loc\n\n@[simp] lemma exists_mem_to_map_eq {x : R} {I : ideal R} (h : S ≤ non_zero_divisors R) :\n  (∃ x', x' ∈ I ∧ algebra_map R P x' = algebra_map R P x) ↔ x ∈ I :=\n⟨λ ⟨x', hx', eq⟩, is_localization.injective _ h eq ▸ hx', λ h, ⟨x, h, rfl⟩⟩\n\nvariables {P}\n\nlemma coe_to_fractional_ideal_injective (h : S ≤ non_zero_divisors R) :\n  function.injective (coe : ideal R → fractional_ideal S P) :=\nλ I J heq, have\n  ∀ (x : R), algebra_map R P x ∈ (I : fractional_ideal S P) ↔\n             algebra_map R P x ∈ (J : fractional_ideal S P) :=\nλ x, heq ▸ iff.rfl,\nideal.ext (by simpa only [mem_coe_ideal, exists_prop, exists_mem_to_map_eq P h] using this)\n\nlemma coe_to_fractional_ideal_eq_zero {I : ideal R} (hS : S ≤ non_zero_divisors R) :\n  (I : fractional_ideal S P) = 0 ↔ I = (⊥ : ideal R) :=\n⟨λ h, coe_to_fractional_ideal_injective hS h,\n λ h, by rw [h, coe_to_fractional_ideal_bot]⟩\n\nlemma coe_to_fractional_ideal_ne_zero {I : ideal R} (hS : S ≤ non_zero_divisors R) :\n  (I : fractional_ideal S P) ≠ 0 ↔ I ≠ (⊥ : ideal R) :=\nnot_iff_not.mpr (coe_to_fractional_ideal_eq_zero hS)\n\nomit loc\n\nlemma coe_to_submodule_eq_bot {I : fractional_ideal S P} :\n  (I : submodule R P) = ⊥ ↔ I = 0 :=\n⟨λ h, coe_to_submodule_injective (by simp [h]),\n λ h, by simp [h]⟩\n\nlemma coe_to_submodule_ne_bot {I : fractional_ideal S P} :\n  ↑I ≠ (⊥ : submodule R P) ↔ I ≠ 0 :=\nnot_iff_not.mpr coe_to_submodule_eq_bot\n\ninstance : inhabited (fractional_ideal S P) := ⟨0⟩\n\ninstance : has_one (fractional_ideal S P) :=\n⟨(⊤ : ideal R)⟩\n\nvariables (S)\n\n@[simp, norm_cast] lemma coe_ideal_top : ((⊤ : ideal R) : fractional_ideal S P) = 1 :=\nrfl\n\nlemma mem_one_iff {x : P} : x ∈ (1 : fractional_ideal S P) ↔ ∃ x' : R, algebra_map R P x' = x :=\niff.intro (λ ⟨x', _, h⟩, ⟨x', h⟩) (λ ⟨x', h⟩, ⟨x', ⟨⟩, h⟩)\n\nlemma coe_mem_one (x : R) : algebra_map R P x ∈ (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr ⟨x, rfl⟩\n\nlemma one_mem_one : (1 : P) ∈ (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr ⟨1, ring_hom.map_one _⟩\n\nvariables {S}\n\n/-- `(1 : fractional_ideal S P)` is defined as the R-submodule `f(R) ≤ P`.\n\nHowever, this is not definitionally equal to `1 : submodule R P`,\nwhich is proved in the actual `simp` lemma `coe_one`. -/\nlemma coe_one_eq_coe_submodule_top :\n  ↑(1 : fractional_ideal S P) = coe_submodule P (⊤ : ideal R) :=\nrfl\n\n@[simp, norm_cast] lemma coe_one :\n  (↑(1 : fractional_ideal S P) : submodule R P) = 1 :=\nby rw [coe_one_eq_coe_submodule_top, coe_submodule_top]\n\nsection lattice\n\n/-!\n### `lattice` section\n\nDefines the order on fractional ideals as inclusion of their underlying sets,\nand ports the lattice structure on submodules to fractional ideals.\n-/\n\n@[simp] lemma coe_le_coe {I J : fractional_ideal S P} :\n  (I : submodule R P) ≤ (J : submodule R P) ↔ I ≤ J :=\niff.rfl\n\nlemma zero_le (I : fractional_ideal S P) : 0 ≤ I :=\nbegin\n  intros x hx,\n  convert submodule.zero_mem _,\n  simpa using hx\nend\n\ninstance order_bot : order_bot (fractional_ideal S P) :=\n{ bot := 0,\n  bot_le := zero_le }\n\n@[simp] lemma bot_eq_zero : (⊥ : fractional_ideal S P) = 0 :=\nrfl\n\n@[simp] lemma le_zero_iff {I : fractional_ideal S P} : I ≤ 0 ↔ I = 0 :=\nle_bot_iff\n\nlemma eq_zero_iff {I : fractional_ideal S P} : I = 0 ↔ (∀ x ∈ I, x = (0 : P)) :=\n⟨ (λ h x hx, by simpa [h, mem_zero_iff] using hx),\n  (λ h, le_bot_iff.mp (λ x hx, (mem_zero_iff S).mpr (h x hx))) ⟩\n\nlemma fractional_sup (I J : fractional_ideal S P) : is_fractional S (I ⊔ J : submodule R P) :=\nbegin\n  rcases I.is_fractional with ⟨aI, haI, hI⟩,\n  rcases J.is_fractional with ⟨aJ, haJ, hJ⟩,\n  use aI * aJ,\n  use S.mul_mem haI haJ,\n  intros b hb,\n  rcases mem_sup.mp hb with ⟨bI, hbI, bJ, hbJ, rfl⟩,\n  rw smul_add,\n  apply is_integer_add,\n  { rw [mul_smul, smul_comm],\n    exact is_integer_smul (hI bI hbI), },\n  { rw mul_smul,\n    exact is_integer_smul (hJ bJ hbJ) }\nend\n\nlemma fractional_inf (I J : fractional_ideal S P) : is_fractional S (I ⊓ J : submodule R P) :=\nbegin\n  rcases I.is_fractional with ⟨aI, haI, hI⟩,\n  use aI,\n  use haI,\n  intros b hb,\n  rcases mem_inf.mp hb with ⟨hbI, hbJ⟩,\n  exact hI b hbI\nend\n\ninstance lattice : lattice (fractional_ideal S P) :=\n{ inf := λ I J, ⟨I ⊓ J, fractional_inf I J⟩,\n  sup := λ I J, ⟨I ⊔ J, fractional_sup I J⟩,\n  inf_le_left := λ I J, show (I ⊓ J : submodule R P) ≤ I, from inf_le_left,\n  inf_le_right := λ I J, show (I ⊓ J : submodule R P) ≤ J, from inf_le_right,\n  le_inf := λ I J K hIJ hIK, show (I : submodule R P) ≤ J ⊓ K, from le_inf hIJ hIK,\n  le_sup_left := λ I J, show (I : submodule R P) ≤ I ⊔ J, from le_sup_left,\n  le_sup_right := λ I J, show (J : submodule R P) ≤ I ⊔ J, from le_sup_right,\n  sup_le := λ I J K hIK hJK, show (I ⊔ J : submodule R P) ≤ K, from sup_le hIK hJK,\n  ..set_like.partial_order }\n\ninstance : semilattice_sup (fractional_ideal S P) :=\n{ ..fractional_ideal.lattice }\n\nend lattice\n\nsection semiring\n\ninstance : has_add (fractional_ideal S P) := ⟨(⊔)⟩\n\n@[simp]\nlemma sup_eq_add (I J : fractional_ideal S P) : I ⊔ J = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_add (I J : fractional_ideal S P) : (↑(I + J) : submodule R P) = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_ideal_sup (I J : ideal R) : ↑(I ⊔ J) = (I + J : fractional_ideal S P) :=\ncoe_to_submodule_injective $ coe_submodule_sup _ _ _\n\nlemma fractional_mul (I J : fractional_ideal S P) : is_fractional S (I * J : submodule R P) :=\nbegin\n  rcases I with ⟨I, aI, haI, hI⟩,\n  rcases J with ⟨J, aJ, haJ, hJ⟩,\n  use aI * aJ,\n  use S.mul_mem haI haJ,\n  intros b hb,\n  apply submodule.mul_induction_on hb,\n  { intros m hm n hn,\n    obtain ⟨n', hn'⟩ := hJ n hn,\n    rw [mul_smul, mul_comm m, ← smul_mul_assoc, ← hn', ← algebra.smul_def],\n    apply hI,\n    exact submodule.smul_mem _ _ hm },\n  { rw smul_zero,\n    exact ⟨0, ring_hom.map_zero _⟩ },\n  { intros x y hx hy,\n    rw smul_add,\n    apply is_integer_add hx hy },\n  { intros r x hx,\n    rw smul_comm,\n    exact is_integer_smul hx },\nend\n\n/-- `fractional_ideal.mul` is the product of two fractional ideals,\nused to define the `has_mul` instance.\n\nThis is only an auxiliary definition: the preferred way of writing `I.mul J` is `I * J`.\n\nElaborated terms involving `fractional_ideal` tend to grow quite large,\nso by making definitions irreducible, we hope to avoid deep unfolds.\n-/\n@[irreducible]\ndef mul (I J : fractional_ideal S P) : fractional_ideal S P :=\n⟨I * J, fractional_mul I J⟩\n\nlocal attribute [semireducible] mul\n\ninstance : has_mul (fractional_ideal S P) := ⟨λ I J, mul I J⟩\n\n@[simp] lemma mul_eq_mul (I J : fractional_ideal S P) : mul I J = I * J := rfl\n\n@[simp, norm_cast]\nlemma coe_mul (I J : fractional_ideal S P) : (↑(I * J) : submodule R P) = I * J := rfl\n\n@[simp, norm_cast]\nlemma coe_ideal_mul (I J : ideal R) : (↑(I * J) : fractional_ideal S P) = I * J :=\ncoe_to_submodule_injective $ coe_submodule_mul _ _ _\n\nlemma mul_left_mono (I : fractional_ideal S P) : monotone ((*) I) :=\nλ J J' h, mul_le.mpr (λ x hx y hy, mul_mem_mul hx (h hy))\n\nlemma mul_right_mono (I : fractional_ideal S P) : monotone (λ J, J * I) :=\nλ J J' h, mul_le.mpr (λ x hx y hy, mul_mem_mul (h hx) hy)\n\nlemma mul_mem_mul {I J : fractional_ideal S P} {i j : P} (hi : i ∈ I) (hj : j ∈ J) :\n  i * j ∈ I * J := submodule.mul_mem_mul hi hj\n\nlemma mul_le {I J K : fractional_ideal S P} :\n  I * J ≤ K ↔ (∀ (i ∈ I) (j ∈ J), i * j ∈ K) :=\nsubmodule.mul_le\n\n@[elab_as_eliminator] protected theorem mul_induction_on\n  {I J : fractional_ideal S P}\n  {C : P → Prop} {r : P} (hr : r ∈ I * J)\n  (hm : ∀ (i ∈ I) (j ∈ J), C (i * j))\n  (h0 : C 0) (ha : ∀ x y, C x → C y → C (x + y))\n  (hs : ∀ (r : R) x, C x → C (r • x)) : C r :=\nsubmodule.mul_induction_on hr hm h0 ha hs\n\ninstance comm_semiring : comm_semiring (fractional_ideal S P) :=\n{ add_assoc := λ I J K, sup_assoc,\n  add_comm := λ I J, sup_comm,\n  add_zero := λ I, sup_bot_eq,\n  zero_add := λ I, bot_sup_eq,\n  mul_assoc := λ I J K, coe_to_submodule_injective (submodule.mul_assoc _ _ _),\n  mul_comm := λ I J, coe_to_submodule_injective (submodule.mul_comm _ _),\n  mul_one := λ I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x hx y ⟨y', y'_mem_R, rfl⟩,\n      convert submodule.smul_mem _ y' hx,\n      rw [mul_comm, eq_comm],\n      exact algebra.smul_def y' x },\n    { have : x * 1 ∈ (I * 1) := mul_mem_mul h (one_mem_one _),\n      rwa [mul_one] at this }\n  end,\n  one_mul := λ I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x ⟨x', x'_mem_R, rfl⟩ y hy,\n      convert submodule.smul_mem _ x' hy,\n      rw eq_comm,\n      exact algebra.smul_def x' y },\n    { have : 1 * x ∈ (1 * I) := mul_mem_mul (one_mem_one _) h,\n      rwa one_mul at this }\n  end,\n  mul_zero := λ I, eq_zero_iff.mpr (λ x hx, submodule.mul_induction_on hx\n    (λ x hx y hy, by simp [(mem_zero_iff S).mp hy])\n    rfl\n    (λ x y hx hy, by simp [hx, hy])\n    (λ r x hx, by simp [hx])),\n  zero_mul := λ I, eq_zero_iff.mpr (λ x hx, submodule.mul_induction_on hx\n    (λ x hx y hy, by simp [(mem_zero_iff S).mp hx])\n    rfl\n    (λ x y hx hy, by simp [hx, hy])\n    (λ r x hx, by simp [hx])),\n  left_distrib := λ I J K, coe_to_submodule_injective (mul_add _ _ _),\n  right_distrib := λ I J K, coe_to_submodule_injective (add_mul _ _ _),\n  ..fractional_ideal.has_zero S,\n  ..fractional_ideal.has_add,\n  ..fractional_ideal.has_one,\n  ..fractional_ideal.has_mul }\n\nsection order\n\nlemma add_le_add_left {I J : fractional_ideal S P} (hIJ : I ≤ J) (J' : fractional_ideal S P) :\n  J' + I ≤ J' + J :=\nsup_le_sup_left hIJ J'\n\nlemma mul_le_mul_left {I J : fractional_ideal S P} (hIJ : I ≤ J) (J' : fractional_ideal S P) :\n  J' * I ≤ J' * J :=\nmul_le.mpr (λ k hk j hj, mul_mem_mul hk (hIJ hj))\n\nlemma le_self_mul_self {I : fractional_ideal S P} (hI: 1 ≤ I) : I ≤ I * I :=\nbegin\n  convert mul_left_mono I hI,\n  exact (mul_one I).symm\nend\n\nlemma mul_self_le_self {I : fractional_ideal S P} (hI: I ≤ 1) : I * I ≤ I :=\nbegin\n  convert mul_left_mono I hI,\n  exact (mul_one I).symm\nend\n\nlemma coe_ideal_le_one {I : ideal R} : (I : fractional_ideal S P) ≤ 1 :=\nλ x hx, let ⟨y, _, hy⟩ := (fractional_ideal.mem_coe_ideal S).mp hx\n  in (fractional_ideal.mem_one_iff S).mpr ⟨y, hy⟩\n\nlemma le_one_iff_exists_coe_ideal {J : fractional_ideal S P} :\n  J ≤ (1 : fractional_ideal S P) ↔ ∃ (I : ideal R), ↑I = J :=\nbegin\n  split,\n  { intro hJ,\n    refine ⟨⟨{x : R | algebra_map R P x ∈ J}, _, _, _⟩, _⟩,\n    { rw [mem_set_of_eq, ring_hom.map_zero],\n      exact J.val.zero_mem },\n    { intros a b ha hb,\n      rw [mem_set_of_eq, ring_hom.map_add],\n      exact J.val.add_mem ha hb },\n    { intros c x hx,\n      rw [smul_eq_mul, mem_set_of_eq, ring_hom.map_mul, ← algebra.smul_def],\n      exact J.val.smul_mem c hx },\n    { ext x,\n      split,\n      { rintros ⟨y, hy, eq_y⟩,\n        rwa ← eq_y },\n      { intro hx,\n        obtain ⟨y, eq_x⟩ := (fractional_ideal.mem_one_iff S).mp (hJ hx),\n        rw ← eq_x at *,\n        exact ⟨y, hx, rfl⟩ } } },\n  { rintro ⟨I, hI⟩,\n    rw ← hI,\n    apply coe_ideal_le_one },\nend\n\nvariables (S P)\n\n/-- `coe_ideal_hom (S : submonoid R) P` is `coe : ideal R → fractional_ideal S P` as a ring hom -/\n@[simps]\ndef coe_ideal_hom : ideal R →+* fractional_ideal S P :=\n{ to_fun := coe,\n  map_add' := coe_ideal_sup,\n  map_mul' := coe_ideal_mul,\n  map_one' := by rw [ideal.one_eq_top, coe_ideal_top],\n  map_zero' := coe_to_fractional_ideal_bot }\n\nend order\n\nvariables {P' : Type*} [comm_ring P'] [algebra R P'] [loc' : is_localization S P']\nvariables {P'' : Type*} [comm_ring P''] [algebra R P''] [loc'' : is_localization S P'']\n\nlemma fractional_map (g : P →ₐ[R] P') (I : fractional_ideal S P) :\n  is_fractional S (submodule.map g.to_linear_map I) :=\nbegin\n  rcases I with ⟨I, a, a_nonzero, hI⟩,\n  use [a, a_nonzero],\n  intros b hb,\n  obtain ⟨b', b'_mem, hb'⟩ := submodule.mem_map.mp hb,\n  obtain ⟨x, hx⟩ := hI b' b'_mem,\n  use x,\n  erw [←g.commutes, hx, g.map_smul, hb']\nend\n\n/-- `I.map g` is the pushforward of the fractional ideal `I` along the algebra morphism `g` -/\ndef map (g : P →ₐ[R] P') :\n  fractional_ideal S P → fractional_ideal S P' :=\nλ I, ⟨submodule.map g.to_linear_map I, fractional_map g I⟩\n\n@[simp, norm_cast] lemma coe_map (g : P →ₐ[R] P') (I : fractional_ideal S P) :\n  ↑(map g I) = submodule.map g.to_linear_map I := rfl\n\n@[simp] lemma mem_map {I : fractional_ideal S P} {g : P →ₐ[R] P'}\n  {y : P'} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y :=\nsubmodule.mem_map\n\nvariables (I J : fractional_ideal S P) (g : P →ₐ[R] P')\n\n@[simp] lemma map_id : I.map (alg_hom.id _ _) = I :=\ncoe_to_submodule_injective (submodule.map_id I)\n\n@[simp] lemma map_comp (g' : P' →ₐ[R] P'') :\n  I.map (g'.comp g) = (I.map g).map g' :=\ncoe_to_submodule_injective (submodule.map_comp g.to_linear_map g'.to_linear_map I)\n\n@[simp, norm_cast] lemma map_coe_ideal (I : ideal R) :\n  (I : fractional_ideal S P).map g = I :=\nbegin\n  ext x,\n  simp only [mem_coe_ideal],\n  split,\n  { rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩,\n    exact ⟨y, hy, (g.commutes y).symm⟩ },\n  { rintro ⟨y, hy, rfl⟩,\n    exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ },\nend\n\n@[simp] lemma map_one :\n  (1 : fractional_ideal S P).map g = 1 :=\nmap_coe_ideal g ⊤\n\n@[simp] lemma map_zero :\n  (0 : fractional_ideal S P).map g = 0 :=\nmap_coe_ideal g 0\n\n@[simp] lemma map_add : (I + J).map g = I.map g + J.map g :=\ncoe_to_submodule_injective (submodule.map_sup _ _ _)\n\n@[simp] lemma map_mul : (I * J).map g = I.map g * J.map g :=\ncoe_to_submodule_injective (submodule.map_mul _ _ _)\n\n@[simp] lemma map_map_symm (g : P ≃ₐ[R] P') :\n  (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I :=\nby rw [←map_comp, g.symm_comp, map_id]\n\n@[simp] lemma map_symm_map (I : fractional_ideal S P') (g : P ≃ₐ[R] P') :\n  (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I :=\nby rw [←map_comp, g.comp_symm, map_id]\n\nlemma map_mem_map {f : P →ₐ[R] P'} (h : function.injective f) {x : P} {I : fractional_ideal S P} :\n  f x ∈ map f I ↔ x ∈ I :=\nmem_map.trans ⟨λ ⟨x', hx', x'_eq⟩, h x'_eq ▸ hx', λ h, ⟨x, h, rfl⟩⟩\n\nlemma map_injective (f : P →ₐ[R] P') (h : function.injective f) :\n  function.injective (map f : fractional_ideal S P → fractional_ideal S P') :=\nλ I J hIJ, fractional_ideal.ext (λ x, (fractional_ideal.map_mem_map h).symm.trans\n  (hIJ.symm ▸ fractional_ideal.map_mem_map h))\n\n/-- If `g` is an equivalence, `map g` is an isomorphism -/\ndef map_equiv (g : P ≃ₐ[R] P') :\n  fractional_ideal S P ≃+* fractional_ideal S P' :=\n{ to_fun := map g,\n  inv_fun := map g.symm,\n  map_add' := λ I J, map_add I J _,\n  map_mul' := λ I J, map_mul I J _,\n  left_inv := λ I, by { rw [←map_comp, alg_equiv.symm_comp, map_id] },\n  right_inv := λ I, by { rw [←map_comp, alg_equiv.comp_symm, map_id] } }\n\n@[simp] lemma coe_fun_map_equiv (g : P ≃ₐ[R] P') :\n  (map_equiv g : fractional_ideal S P → fractional_ideal S P') = map g :=\nrfl\n\n@[simp] lemma map_equiv_apply (g : P ≃ₐ[R] P') (I : fractional_ideal S P) :\n  map_equiv g I = map ↑g I := rfl\n\n@[simp] lemma map_equiv_symm (g : P ≃ₐ[R] P') :\n  ((map_equiv g).symm : fractional_ideal S P' ≃+* _) = map_equiv g.symm := rfl\n\n@[simp] lemma map_equiv_refl :\n  map_equiv alg_equiv.refl = ring_equiv.refl (fractional_ideal S P) :=\nring_equiv.ext (λ x, by simp)\n\nlemma is_fractional_span_iff {s : set P} :\n  is_fractional S (span R s) ↔ ∃ a ∈ S, ∀ (b : P), b ∈ s → is_integer R (a • b) :=\n⟨λ ⟨a, a_mem, h⟩, ⟨a, a_mem, λ b hb, h b (subset_span hb)⟩,\n λ ⟨a, a_mem, h⟩, ⟨a, a_mem, λ b hb, span_induction hb\n   h\n   (by { rw smul_zero, exact is_integer_zero })\n   (λ x y hx hy, by { rw smul_add, exact is_integer_add hx hy })\n   (λ s x hx, by { rw smul_comm, exact is_integer_smul hx })⟩⟩\n\ninclude loc\n\nlemma is_fractional_of_fg {I : submodule R P} (hI : I.fg) :\n  is_fractional S I :=\nbegin\n  rcases hI with ⟨I, rfl⟩,\n  rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩,\n  rw is_fractional_span_iff,\n  exact ⟨s, hs1, hs⟩,\nend\n\nomit loc\n\nlemma mem_span_mul_finite_of_mem_mul {I J : fractional_ideal S P} {x : P} (hx : x ∈ I * J) :\n  ∃ (T T' : finset P), (T : set P) ⊆ I ∧ (T' : set P) ⊆ J ∧ x ∈ span R (T * T' : set P) :=\nsubmodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx)\n\nvariables (S)\n\nlemma coe_ideal_fg (inj : function.injective (algebra_map R P)) (I : ideal R) :\n  fg ((I : fractional_ideal S P) : submodule R P) ↔ fg I :=\ncoe_submodule_fg _ inj _\n\nvariables {S}\n\nlemma fg_unit (I : units (fractional_ideal S P)) :\n  fg (I : submodule R P) :=\nbegin\n  have : (1 : P) ∈ (I * ↑I⁻¹ : fractional_ideal S P),\n  { rw units.mul_inv, exact one_mem_one _ },\n  obtain ⟨T, T', hT, hT', one_mem⟩ := mem_span_mul_finite_of_mem_mul this,\n  refine ⟨T, submodule.span_eq_of_le _ hT _⟩,\n  rw [← one_mul ↑I, ← mul_one (span R ↑T)],\n  conv_rhs { rw [← fractional_ideal.coe_one, ← units.mul_inv I, fractional_ideal.coe_mul,\n                 mul_comm ↑↑I, ← mul_assoc] },\n  refine submodule.mul_le_mul_left\n    (le_trans _ (submodule.mul_le_mul_right (submodule.span_le.mpr hT'))),\n  rwa [submodule.one_le, submodule.span_mul_span]\nend\n\nlemma fg_of_is_unit (I : fractional_ideal S P) (h : is_unit I) :\n  fg (I : submodule R P) :=\nby { rcases h with ⟨I, rfl⟩, exact fg_unit I }\n\nlemma _root_.ideal.fg_of_is_unit (inj : function.injective (algebra_map R P))\n  (I : ideal R) (h : is_unit (I : fractional_ideal S P)) :\n  I.fg :=\nby { rw ← coe_ideal_fg S inj I, exact fg_of_is_unit I h }\n\nvariables (S P P')\n\ninclude loc loc'\n\n/-- `canonical_equiv f f'` is the canonical equivalence between the fractional\nideals in `P` and in `P'` -/\n@[irreducible]\nnoncomputable def canonical_equiv :\n  fractional_ideal S P ≃+* fractional_ideal S P' :=\nmap_equiv\n  { commutes' := λ r, ring_equiv_of_ring_equiv_eq _ _,\n    ..ring_equiv_of_ring_equiv P P' (ring_equiv.refl R)\n      (show S.map _ = S, by rw [ring_equiv.to_monoid_hom_refl, submonoid.map_id]) }\n\n@[simp] lemma mem_canonical_equiv_apply {I : fractional_ideal S P} {x : P'} :\n  x ∈ canonical_equiv S P P' I ↔\n    ∃ y ∈ I, is_localization.map P' (ring_hom.id R)\n      (λ y (hy : y ∈ S), show ring_hom.id R y ∈ S, from hy) (y : P) = x :=\nbegin\n  rw [canonical_equiv, map_equiv_apply, mem_map],\n  exact ⟨λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩, λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩⟩\nend\n\n@[simp] lemma canonical_equiv_symm :\n  (canonical_equiv S P P').symm = canonical_equiv S P' P :=\nring_equiv.ext $ λ I, set_like.ext_iff.mpr $ λ x,\nby { rw [mem_canonical_equiv_apply, canonical_equiv, map_equiv_symm, map_equiv,\n         ring_equiv.coe_mk, mem_map],\n    exact ⟨λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩, λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩⟩ }\n\n@[simp] lemma canonical_equiv_flip (I) :\n  canonical_equiv S P P' (canonical_equiv S P' P I) = I :=\nby rw [←canonical_equiv_symm, ring_equiv.symm_apply_apply]\n\nend semiring\n\nsection is_fraction_ring\n\n/-!\n### `is_fraction_ring` section\n\nThis section concerns fractional ideals in the field of fractions,\ni.e. the type `fractional_ideal R⁰ K` where `is_fraction_ring R K`.\n-/\n\nvariables {K K' : Type*} [field K] [field K']\nvariables [algebra R K] [is_fraction_ring R K] [algebra R K'] [is_fraction_ring R K']\nvariables {I J : fractional_ideal R⁰ K} (h : K →ₐ[R] K')\n\n/-- Nonzero fractional ideals contain a nonzero integer. -/\nlemma exists_ne_zero_mem_is_integer [nontrivial R] (hI : I ≠ 0) :\n  ∃ x ≠ (0 : R), algebra_map R K x ∈ I :=\nbegin\n  obtain ⟨y, y_mem, y_not_mem⟩ := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr hI),\n  have y_ne_zero : y ≠ 0 := by simpa using y_not_mem,\n  obtain ⟨z, ⟨x, hx⟩⟩ := exists_integer_multiple R⁰ y,\n  refine ⟨x, _, _⟩,\n  { rw [ne.def, ← @is_fraction_ring.to_map_eq_zero_iff R _ K, hx, algebra.smul_def],\n    exact mul_ne_zero (is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors z.2) y_ne_zero },\n  { rw hx,\n    exact smul_mem _ _ y_mem }\nend\n\nlemma map_ne_zero [nontrivial R] (hI : I ≠ 0) : I.map h ≠ 0 :=\nbegin\n  obtain ⟨x, x_ne_zero, hx⟩ := exists_ne_zero_mem_is_integer hI,\n  contrapose! x_ne_zero with map_eq_zero,\n  refine is_fraction_ring.to_map_eq_zero_iff.mp (eq_zero_iff.mp map_eq_zero _ (mem_map.mpr _)),\n  exact ⟨algebra_map R K x, hx, h.commutes x⟩,\nend\n\n@[simp] lemma map_eq_zero_iff [nontrivial R] : I.map h = 0 ↔ I = 0 :=\n⟨imp_of_not_imp_not _ _ (map_ne_zero _),\n λ hI, hI.symm ▸ map_zero h⟩\n\nlemma coe_ideal_injective :\n  function.injective (coe : ideal R → fractional_ideal R⁰ K) :=\ninjective_of_le_imp_le _ (λ _ _, (coe_ideal_le_coe_ideal _).mp)\n\n@[simp]\nlemma coe_ideal_eq_zero_iff\n  {I : ideal R} : (I : fractional_ideal R⁰ K) = 0 ↔ I = ⊥ :=\nby { rw ← coe_to_fractional_ideal_bot, exact coe_ideal_injective.eq_iff }\n\nlemma coe_ideal_ne_zero_iff\n  {I : ideal R} : (I : fractional_ideal R⁰ K) ≠ 0 ↔ I ≠ ⊥ :=\nnot_iff_not.mpr coe_ideal_eq_zero_iff\n\nlemma coe_ideal_ne_zero\n  {I : ideal R} (hI : I ≠ ⊥) : (I : fractional_ideal R⁰ K) ≠ 0 :=\ncoe_ideal_ne_zero_iff.mpr hI\n\nend is_fraction_ring\n\nsection quotient\n\n/-!\n### `quotient` section\n\nThis section defines the ideal quotient of fractional ideals.\n\nIn this section we need that each non-zero `y : R` has an inverse in\nthe localization, i.e. that the localization is a field. We satisfy this\nassumption by taking `S = non_zero_divisors R`, `R`'s localization at which\nis a field because `R` is a domain.\n-/\n\nopen_locale classical\n\nvariables {R₁ : Type*} [comm_ring R₁] {K : Type*} [field K]\nvariables [algebra R₁ K] [frac : is_fraction_ring R₁ K]\n\ninstance : nontrivial (fractional_ideal R₁⁰ K) :=\n⟨⟨0, 1, λ h,\n  have this : (1 : K) ∈ (0 : fractional_ideal R₁⁰ K) :=\n    by { rw ← (algebra_map R₁ K).map_one, simpa only [h] using coe_mem_one R₁⁰ 1 },\n  one_ne_zero ((mem_zero_iff _).mp this)⟩⟩\n\nlemma ne_zero_of_mul_eq_one (I J : fractional_ideal R₁⁰ K) (h : I * J = 1) : I ≠ 0 :=\nλ hI, @zero_ne_one (fractional_ideal R₁⁰ K) _ _ (by { convert h, simp [hI], })\n\nvariables [is_domain R₁]\n\ninclude frac\n\nlemma fractional_div_of_nonzero {I J : fractional_ideal R₁⁰ K} (h : J ≠ 0) :\n  is_fractional R₁⁰ (I / J : submodule R₁ K) :=\nbegin\n  rcases I with ⟨I, aI, haI, hI⟩,\n  rcases J with ⟨J, aJ, haJ, hJ⟩,\n  obtain ⟨y, mem_J, not_mem_zero⟩ := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr h),\n  obtain ⟨y', hy'⟩ := hJ y mem_J,\n  use (aI * y'),\n  split,\n  { apply (non_zero_divisors R₁).mul_mem haI (mem_non_zero_divisors_iff_ne_zero.mpr _),\n    intro y'_eq_zero,\n    have : algebra_map R₁ K aJ * y = 0,\n    { rw [← algebra.smul_def, ←hy', y'_eq_zero, ring_hom.map_zero] },\n    have y_zero := (mul_eq_zero.mp this).resolve_left\n      (mt ((algebra_map R₁ K).injective_iff.1 (is_fraction_ring.injective _ _) _)\n          (mem_non_zero_divisors_iff_ne_zero.mp haJ)),\n    exact not_mem_zero ((mem_zero_iff R₁⁰).mpr y_zero) },\n  intros b hb,\n  convert hI _ (hb _ (submodule.smul_mem _ aJ mem_J)) using 1,\n  rw [← hy', mul_comm b, ← algebra.smul_def, mul_smul]\nend\n\nnoncomputable instance fractional_ideal_has_div :\n  has_div (fractional_ideal R₁⁰ K) :=\n⟨ λ I J, if h : J = 0 then 0 else ⟨I / J, fractional_div_of_nonzero h⟩ ⟩\n\nvariables {I J : fractional_ideal R₁⁰ K} [ J ≠ 0 ]\n\n@[simp] lemma div_zero {I : fractional_ideal R₁⁰ K} :\n  I / 0 = 0 :=\ndif_pos rfl\n\nlemma div_nonzero {I J : fractional_ideal R₁⁰ K} (h : J ≠ 0) :\n  (I / J) = ⟨I / J, fractional_div_of_nonzero h⟩ :=\ndif_neg h\n\n@[simp] lemma coe_div {I J : fractional_ideal R₁⁰ K} (hJ : J ≠ 0) :\n  (↑(I / J) : submodule R₁ K) = ↑I / (↑J : submodule R₁ K) :=\nbegin\n  unfold has_div.div,\n  simp only [dif_neg hJ, coe_mk, val_eq_coe],\nend\n\n\n\nlemma mul_one_div_le_one {I : fractional_ideal R₁⁰ K} : I * (1 / I) ≤ 1 :=\nbegin\n  by_cases hI : I = 0,\n  { rw [hI, div_zero, mul_zero],\n    exact zero_le 1 },\n  { rw [← coe_le_coe, coe_mul, coe_div hI, coe_one],\n    apply submodule.mul_one_div_le_one },\nend\n\nlemma le_self_mul_one_div {I : fractional_ideal R₁⁰ K} (hI : I ≤ (1 : fractional_ideal R₁⁰ K)) :\n  I ≤ I * (1 / I) :=\nbegin\n  by_cases hI_nz : I = 0,\n  { rw [hI_nz, div_zero, mul_zero], exact zero_le 0 },\n  { rw [← coe_le_coe, coe_mul, coe_div hI_nz, coe_one],\n    rw [← coe_le_coe, coe_one] at hI,\n    exact submodule.le_self_mul_one_div hI },\nend\n\nlemma le_div_iff_of_nonzero {I J J' : fractional_ideal R₁⁰ K} (hJ' : J' ≠ 0) :\n  I ≤ J / J' ↔ ∀ (x ∈ I) (y ∈ J'), x * y ∈ J :=\n⟨ λ h x hx, (mem_div_iff_of_nonzero hJ').mp (h hx),\n  λ h x hx, (mem_div_iff_of_nonzero hJ').mpr (h x hx) ⟩\n\nlemma le_div_iff_mul_le {I J J' : fractional_ideal R₁⁰ K} (hJ' : J' ≠ 0) :\n  I ≤ J / J' ↔ I * J' ≤ J :=\nbegin\n  rw div_nonzero hJ',\n  convert submodule.le_div_iff_mul_le using 1,\n  rw [← coe_mul, coe_le_coe]\nend\n\n@[simp] lemma div_one {I : fractional_ideal R₁⁰ K} : I / 1 = I :=\nbegin\n  rw [div_nonzero (@one_ne_zero (fractional_ideal R₁⁰ K) _ _)],\n  ext,\n  split; intro h,\n  { simpa using mem_div_iff_forall_mul_mem.mp h 1\n      ((algebra_map R₁ K).map_one ▸ coe_mem_one R₁⁰ 1) },\n  { apply mem_div_iff_forall_mul_mem.mpr,\n    rintros y ⟨y', _, rfl⟩,\n    rw mul_comm,\n    convert submodule.smul_mem _ y' h,\n    exact (algebra.smul_def _ _).symm }\nend\n\ntheorem eq_one_div_of_mul_eq_one (I J : fractional_ideal R₁⁰ K) (h : I * J = 1) :\n  J = 1 / I :=\nbegin\n  have hI : I ≠ 0 := ne_zero_of_mul_eq_one I J h,\n  suffices h' : I * (1 / I) = 1,\n  { exact (congr_arg units.inv $\n      @units.ext _ _ (units.mk_of_mul_eq_one _ _ h) (units.mk_of_mul_eq_one _ _ h') rfl) },\n  apply le_antisymm,\n  { apply mul_le.mpr _,\n    intros x hx y hy,\n    rw mul_comm,\n    exact (mem_div_iff_of_nonzero hI).mp hy x hx },\n  rw ← h,\n  apply mul_left_mono I,\n  apply (le_div_iff_of_nonzero hI).mpr _,\n  intros y hy x hx,\n  rw mul_comm,\n  exact mul_mem_mul hx hy,\nend\n\ntheorem mul_div_self_cancel_iff {I : fractional_ideal R₁⁰ K} :\n  I * (1 / I) = 1 ↔ ∃ J, I * J = 1 :=\n⟨λ h, ⟨(1 / I), h⟩, λ ⟨J, hJ⟩, by rwa [← eq_one_div_of_mul_eq_one I J hJ]⟩\n\nvariables {K' : Type*} [field K'] [algebra R₁ K'] [is_fraction_ring R₁ K']\n\n@[simp] lemma map_div (I J : fractional_ideal R₁⁰ K) (h : K ≃ₐ[R₁] K') :\n  (I / J).map (h : K →ₐ[R₁] K') = I.map h / J.map h :=\nbegin\n  by_cases H : J = 0,\n  { rw [H, div_zero, map_zero, div_zero] },\n  { apply coe_to_submodule_injective,\n    simp [div_nonzero H, div_nonzero (map_ne_zero _ H), submodule.map_div] }\nend\n\n@[simp] lemma map_one_div (I : fractional_ideal R₁⁰ K) (h : K ≃ₐ[R₁] K') :\n  (1 / I).map (h : K →ₐ[R₁] K') = 1 / I.map h :=\nby rw [map_div, map_one]\n\nend quotient\n\nsection field\n\nvariables {R₁ K L : Type*} [comm_ring R₁] [is_domain R₁] [field K] [field L]\nvariables [algebra R₁ K] [is_fraction_ring R₁ K] [algebra K L] [is_fraction_ring K L]\n\nlemma eq_zero_or_one (I : fractional_ideal K⁰ L) : I = 0 ∨ I = 1 :=\nbegin\n  rw or_iff_not_imp_left,\n  intro hI,\n  simp_rw [@set_like.ext_iff _ _ _ I 1, fractional_ideal.mem_one_iff],\n  intro x,\n  split,\n  { intro x_mem,\n    obtain ⟨n, d, rfl⟩ := is_localization.mk'_surjective K⁰ x,\n    refine ⟨n / d, _⟩,\n    rw [ring_hom.map_div, is_fraction_ring.mk'_eq_div] },\n  { rintro ⟨x, rfl⟩,\n    obtain ⟨y, y_ne, y_mem⟩ := fractional_ideal.exists_ne_zero_mem_is_integer hI,\n    rw [← div_mul_cancel x y_ne, ring_hom.map_mul, ← algebra.smul_def],\n    exact submodule.smul_mem I _ y_mem }\nend\n\nlemma eq_zero_or_one_of_is_field (hF : is_field R₁) (I : fractional_ideal R₁⁰ K) : I = 0 ∨ I = 1 :=\nbegin\n  letI : field R₁ := hF.to_field R₁,\n  -- TODO can this be less ugly?\n  exact @eq_zero_or_one R₁ K _ _ _ (by { unfreezingI {cases _inst_4}, convert _inst_9 }) I\nend\n\nend field\n\nsection principal_ideal_ring\n\nvariables {R₁ : Type*} [comm_ring R₁] {K : Type*} [field K]\nvariables [algebra R₁ K] [is_fraction_ring R₁ K]\n\nopen_locale classical\n\nopen submodule submodule.is_principal\n\ninclude loc\n\nlemma is_fractional_span_singleton (x : P) : is_fractional S (span R {x} : submodule R P) :=\nlet ⟨a, ha⟩ := exists_integer_multiple S x in\nis_fractional_span_iff.mpr ⟨a, a.2, λ x' hx', (set.mem_singleton_iff.mp hx').symm ▸ ha⟩\n\nvariables (S)\n\n/-- `span_singleton x` is the fractional ideal generated by `x` if `0 ∉ S` -/\n@[irreducible]\ndef span_singleton (x : P) : fractional_ideal S P :=\n⟨span R {x}, is_fractional_span_singleton x⟩\n\nlocal attribute [semireducible] span_singleton\n\n@[simp] lemma coe_span_singleton (x : P) :\n  (span_singleton S x : submodule R P) = span R {x} := rfl\n\n@[simp] lemma mem_span_singleton {x y : P} :\n  x ∈ span_singleton S y ↔ ∃ (z : R), z • y = x :=\nsubmodule.mem_span_singleton\n\nlemma mem_span_singleton_self (x : P) :\n  x ∈ span_singleton S x :=\n(mem_span_singleton S).mpr ⟨1, one_smul _ _⟩\n\nvariables {S}\n\nlemma eq_span_singleton_of_principal (I : fractional_ideal S P)\n  [is_principal (I : submodule R P)] :\n  I = span_singleton S (generator (I : submodule R P)) :=\ncoe_to_submodule_injective (span_singleton_generator ↑I).symm\n\nlemma is_principal_iff (I : fractional_ideal S P) :\n  is_principal (I : submodule R P) ↔ ∃ x, I = span_singleton S x :=\n⟨λ h, ⟨@generator _ _ _ _ _ ↑I h, @eq_span_singleton_of_principal _ _ _ _ _ _ _ I h⟩,\n λ ⟨x, hx⟩, { principal := ⟨x, trans (congr_arg _ hx) (coe_span_singleton _ x)⟩ } ⟩\n\n@[simp] lemma span_singleton_zero : span_singleton S (0 : P) = 0 :=\nby { ext, simp [submodule.mem_span_singleton, eq_comm] }\n\nlemma span_singleton_eq_zero_iff {y : P} : span_singleton S y = 0 ↔ y = 0 :=\n⟨λ h, span_eq_bot.mp (by simpa using congr_arg subtype.val h : span R {y} = ⊥) y (mem_singleton y),\n λ h, by simp [h] ⟩\n\nlemma span_singleton_ne_zero_iff {y : P} : span_singleton S y ≠ 0 ↔ y ≠ 0 :=\nnot_congr span_singleton_eq_zero_iff\n\n@[simp] lemma span_singleton_one : span_singleton S (1 : P) = 1 :=\nbegin\n  ext,\n  refine (mem_span_singleton S).trans ((exists_congr _).trans (mem_one_iff S).symm),\n  intro x',\n  rw [algebra.smul_def, mul_one]\nend\n\n@[simp]\nlemma span_singleton_mul_span_singleton (x y : P) :\n  span_singleton S x * span_singleton S y = span_singleton S (x * y) :=\nbegin\n  apply coe_to_submodule_injective,\n  simp only [coe_mul, coe_span_singleton, span_mul_span, singleton_mul_singleton],\nend\n\n@[simp]\nlemma coe_ideal_span_singleton (x : R) :\n  (↑(ideal.span {x} : ideal R) : fractional_ideal S P) = span_singleton S (algebra_map R P x) :=\nbegin\n  ext y,\n  refine (mem_coe_ideal S).trans (iff.trans _ (mem_span_singleton S).symm),\n  split,\n  { rintros ⟨y', hy', rfl⟩,\n    obtain ⟨x', rfl⟩ := submodule.mem_span_singleton.mp hy',\n    use x',\n    rw [smul_eq_mul, ring_hom.map_mul, algebra.smul_def] },\n  { rintros ⟨y', rfl⟩,\n    refine ⟨y' * x, submodule.mem_span_singleton.mpr ⟨y', rfl⟩, _⟩,\n    rw [ring_hom.map_mul, algebra.smul_def] }\nend\n\n@[simp]\nlemma canonical_equiv_span_singleton {P'} [comm_ring P'] [algebra R P'] [is_localization S P']\n  (x : P) :\n  canonical_equiv S P P' (span_singleton S x) =\n    span_singleton S (is_localization.map P' (ring_hom.id R)\n      (λ y (hy : y ∈ S), show ring_hom.id R y ∈ S, from hy) x) :=\nbegin\n  apply set_like.ext_iff.mpr,\n  intro y,\n  split; intro h,\n  { rw mem_span_singleton,\n    obtain ⟨x', hx', rfl⟩ := (mem_canonical_equiv_apply _ _ _).mp h,\n    obtain ⟨z, rfl⟩ := (mem_span_singleton _).mp hx',\n    use z,\n    rw is_localization.map_smul,\n    refl },\n  { rw mem_canonical_equiv_apply,\n    obtain ⟨z, rfl⟩ := (mem_span_singleton _).mp h,\n    use z • x,\n    use (mem_span_singleton _).mpr ⟨z, rfl⟩,\n    simp [is_localization.map_smul] }\nend\n\nlemma mem_singleton_mul {x y : P} {I : fractional_ideal S P} :\n  y ∈ span_singleton S x * I ↔ ∃ y' ∈ I, y = x * y' :=\nbegin\n  split,\n  { intro h,\n    apply fractional_ideal.mul_induction_on h,\n    { intros x' hx' y' hy',\n      obtain ⟨a, ha⟩ := (mem_span_singleton S).mp hx',\n      use [a • y', submodule.smul_mem I a hy'],\n      rw [←ha, algebra.mul_smul_comm, algebra.smul_mul_assoc] },\n    { exact ⟨0, submodule.zero_mem I, (mul_zero x).symm⟩ },\n    { rintros _ _ ⟨y, hy, rfl⟩ ⟨y', hy', rfl⟩,\n      exact ⟨y + y', submodule.add_mem I hy hy', (mul_add _ _ _).symm⟩ },\n    { rintros r _ ⟨y', hy', rfl⟩,\n      exact ⟨r • y', submodule.smul_mem I r hy', (algebra.mul_smul_comm _ _ _).symm ⟩ } },\n  { rintros ⟨y', hy', rfl⟩,\n    exact mul_mem_mul ((mem_span_singleton S).mpr ⟨1, one_smul _ _⟩) hy' }\nend\n\nomit loc\n\nvariables (K)\n\nlemma mk'_mul_coe_ideal_eq_coe_ideal {I J : ideal R₁} {x y : R₁} (hy : y ∈ R₁⁰) :\n  span_singleton R₁⁰ (is_localization.mk' K x ⟨y, hy⟩) * I = (J : fractional_ideal R₁⁰ K) ↔\n  ideal.span {x} * I = ideal.span {y} * J :=\nbegin\n  have inj : function.injective (coe : ideal R₁ → fractional_ideal R₁⁰ K) :=\n    fractional_ideal.coe_ideal_injective,\n  have : span_singleton R₁⁰ (is_localization.mk' _ (1 : R₁) ⟨y, hy⟩) *\n           span_singleton R₁⁰ (algebra_map R₁ K y) = 1,\n  { rw [span_singleton_mul_span_singleton, mul_comm, ← is_localization.mk'_eq_mul_mk'_one,\n        is_localization.mk'_self, span_singleton_one] },\n  let y' : units (fractional_ideal R₁⁰ K) := units.mk_of_mul_eq_one _ _ this,\n  have coe_y' : ↑y' = span_singleton R₁⁰ (is_localization.mk' K (1 : R₁) ⟨y, hy⟩) := rfl,\n  refine iff.trans _ (y'.mul_right_inj.trans inj.eq_iff),\n  rw [coe_y', coe_ideal_mul, coe_ideal_span_singleton, coe_ideal_mul, coe_ideal_span_singleton,\n    ←mul_assoc, span_singleton_mul_span_singleton, ←mul_assoc, span_singleton_mul_span_singleton,\n    mul_comm (mk' _ _ _), ← is_localization.mk'_eq_mul_mk'_one,\n    mul_comm (mk' _ _ _), ← is_localization.mk'_eq_mul_mk'_one,\n    is_localization.mk'_self, span_singleton_one, one_mul],\nend\n\nvariables {K}\n\nlemma span_singleton_mul_coe_ideal_eq_coe_ideal {I J : ideal R₁} {z : K} :\n  span_singleton R₁⁰ z * (I : fractional_ideal R₁⁰ K) = J ↔\n  ideal.span {((is_localization.sec R₁⁰ z).1 : R₁)} * I =\n    ideal.span {(is_localization.sec R₁⁰ z).2} * J :=\n-- `erw` to deal with the distinction between `y` and `⟨y.1, y.2⟩`\nby erw [← mk'_mul_coe_ideal_eq_coe_ideal K (is_localization.sec R₁⁰ z).2.prop,\n        is_localization.mk'_sec K z]\n\nvariables [is_domain R₁]\n\nlemma one_div_span_singleton (x : K) :\n  1 / span_singleton R₁⁰ x = span_singleton R₁⁰ (x⁻¹) :=\nif h : x = 0 then by simp [h] else (eq_one_div_of_mul_eq_one _ _ (by simp [h])).symm\n\n@[simp] lemma div_span_singleton (J : fractional_ideal R₁⁰ K) (d : K) :\n  J / span_singleton R₁⁰ d = span_singleton R₁⁰ (d⁻¹) * J :=\nbegin\n  rw ← one_div_span_singleton,\n  by_cases hd : d = 0,\n  { simp only [hd, span_singleton_zero, div_zero, zero_mul] },\n  have h_spand : span_singleton R₁⁰ d ≠ 0 := mt span_singleton_eq_zero_iff.mp hd,\n  apply le_antisymm,\n  { intros x hx,\n    rw [← mem_coe, coe_div h_spand, submodule.mem_div_iff_forall_mul_mem] at hx,\n    specialize hx d (mem_span_singleton_self R₁⁰ d),\n    have h_xd : x = d⁻¹ * (x * d), { field_simp },\n    rw [← mem_coe, coe_mul, one_div_span_singleton, h_xd],\n    exact submodule.mul_mem_mul (mem_span_singleton_self R₁⁰ _) hx },\n  { rw [le_div_iff_mul_le h_spand, mul_assoc, mul_left_comm, one_div_span_singleton,\n    span_singleton_mul_span_singleton, inv_mul_cancel hd, span_singleton_one, mul_one],\n    exact le_refl J },\nend\n\nlemma exists_eq_span_singleton_mul (I : fractional_ideal R₁⁰ K) :\n  ∃ (a : R₁) (aI : ideal R₁), a ≠ 0 ∧ I = span_singleton R₁⁰ (algebra_map R₁ K a)⁻¹ * aI :=\nbegin\n  obtain ⟨a_inv, nonzero, ha⟩ := I.is_fractional,\n  have nonzero := mem_non_zero_divisors_iff_ne_zero.mp nonzero,\n  have map_a_nonzero : algebra_map R₁ K a_inv ≠ 0 :=\n    mt is_fraction_ring.to_map_eq_zero_iff.mp nonzero,\n  refine ⟨a_inv,\n          submodule.comap (algebra.linear_map R₁ K)\n            ↑(span_singleton R₁⁰ (algebra_map R₁ K a_inv) * I),\n          nonzero,\n          ext (λ x, iff.trans ⟨_, _⟩ mem_singleton_mul.symm)⟩,\n  { intro hx,\n    obtain ⟨x', hx'⟩ := ha x hx,\n    rw algebra.smul_def at hx',\n    refine ⟨algebra_map R₁ K x', (mem_coe_ideal _).mpr ⟨x', mem_singleton_mul.mpr _, rfl⟩, _⟩,\n    { exact ⟨x, hx, hx'⟩ },\n    { rw [hx', ← mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] } },\n  { rintros ⟨y, hy, rfl⟩,\n    obtain ⟨x', hx', rfl⟩ := (mem_coe_ideal _).mp hy,\n    obtain ⟨y', hy', hx'⟩ := mem_singleton_mul.mp hx',\n    rw algebra.linear_map_apply at hx',\n    rwa [hx', ←mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] }\nend\n\ninstance is_principal {R} [comm_ring R] [is_domain R] [is_principal_ideal_ring R]\n  [algebra R K] [is_fraction_ring R K]\n  (I : fractional_ideal R⁰ K) : (I : submodule R K).is_principal :=\nbegin\n  obtain ⟨a, aI, -, ha⟩ := exists_eq_span_singleton_mul I,\n  use (algebra_map R K a)⁻¹ * algebra_map R K (generator aI),\n  suffices : I = span_singleton R⁰ ((algebra_map R K a)⁻¹ * algebra_map R K (generator aI)),\n  { exact congr_arg subtype.val this },\n  conv_lhs { rw [ha, ←span_singleton_generator aI] },\n  rw [ideal.submodule_span_eq, coe_ideal_span_singleton (generator aI),\n      span_singleton_mul_span_singleton]\nend\n\ninclude loc\n\nlemma le_span_singleton_mul_iff {x : P} {I J : fractional_ideal S P} :\n  I ≤ span_singleton S x * J ↔ ∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI :=\nshow (∀ {zI} (hzI : zI ∈ I), zI ∈ span_singleton _ x * J) ↔ ∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI,\nby simp only [fractional_ideal.mem_singleton_mul, eq_comm]\n\nlemma span_singleton_mul_le_iff {x : P} {I J : fractional_ideal S P} :\n  span_singleton _ x * I ≤ J ↔ ∀ z ∈ I, x * z ∈ J :=\nbegin\n  simp only [fractional_ideal.mul_le, fractional_ideal.mem_singleton_mul,\n             fractional_ideal.mem_span_singleton],\n  split,\n  { intros h zI hzI,\n    exact h x ⟨1, one_smul _ _⟩ zI hzI },\n  { rintros h _ ⟨z, rfl⟩ zI hzI,\n    rw [algebra.smul_mul_assoc],\n    exact submodule.smul_mem J.1 _ (h zI hzI) },\nend\n\nlemma eq_span_singleton_mul {x : P} {I J : fractional_ideal S P} :\n  I = span_singleton _ x * J ↔ (∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI) ∧ ∀ z ∈ J, x * z ∈ I :=\nby simp only [le_antisymm_iff, fractional_ideal.le_span_singleton_mul_iff,\n              fractional_ideal.span_singleton_mul_le_iff]\n\nend principal_ideal_ring\n\nvariables {R₁ : Type*} [comm_ring R₁]\nvariables {K : Type*} [field K] [algebra R₁ K] [frac : is_fraction_ring R₁ K]\n\nlocal attribute [instance] classical.prop_decidable\n\nlemma is_noetherian_zero : is_noetherian R₁ (0 : fractional_ideal R₁⁰ K) :=\nis_noetherian_submodule.mpr (λ I (hI : I ≤ (0 : fractional_ideal R₁⁰ K)),\n  by { rw coe_zero at hI, rw le_bot_iff.mp hI, exact fg_bot })\n\nlemma is_noetherian_iff {I : fractional_ideal R₁⁰ K} :\n  is_noetherian R₁ I ↔ ∀ J ≤ I, (J : submodule R₁ K).fg :=\nis_noetherian_submodule.trans ⟨λ h J hJ, h _ hJ, λ h J hJ, h ⟨J, is_fractional_of_le hJ⟩ hJ⟩\n\nlemma is_noetherian_coe_to_fractional_ideal [_root_.is_noetherian_ring R₁] (I : ideal R₁) :\n  is_noetherian R₁ (I : fractional_ideal R₁⁰ K) :=\nbegin\n  rw is_noetherian_iff,\n  intros J hJ,\n  obtain ⟨J, rfl⟩ := le_one_iff_exists_coe_ideal.mp (le_trans hJ coe_ideal_le_one),\n  exact fg_map (is_noetherian.noetherian J),\nend\n\ninclude frac\nvariables [is_domain R₁]\n\nlemma is_noetherian_span_singleton_inv_to_map_mul (x : R₁) {I : fractional_ideal R₁⁰ K}\n  (hI : is_noetherian R₁ I) :\n  is_noetherian R₁ (span_singleton R₁⁰ (algebra_map R₁ K x)⁻¹ * I : fractional_ideal R₁⁰ K) :=\nbegin\n  by_cases hx : x = 0,\n  { rw [hx, ring_hom.map_zero, _root_.inv_zero, span_singleton_zero, zero_mul],\n    exact is_noetherian_zero },\n  have h_gx : algebra_map R₁ K x ≠ 0,\n    from mt ((algebra_map R₁ K).injective_iff.mp (is_fraction_ring.injective _ _) x) hx,\n  have h_spanx : span_singleton R₁⁰ (algebra_map R₁ K x) ≠ 0,\n    from span_singleton_ne_zero_iff.mpr h_gx,\n\n  rw is_noetherian_iff at ⊢ hI,\n  intros J hJ,\n  rw [← div_span_singleton, le_div_iff_mul_le h_spanx] at hJ,\n  obtain ⟨s, hs⟩ := hI _ hJ,\n  use s * {(algebra_map R₁ K x)⁻¹},\n  rw [finset.coe_mul, finset.coe_singleton, ← span_mul_span, hs, ← coe_span_singleton R₁⁰,\n      ← coe_mul, mul_assoc, span_singleton_mul_span_singleton, mul_inv_cancel h_gx,\n      span_singleton_one, mul_one],\nend\n\n/-- Every fractional ideal of a noetherian integral domain is noetherian. -/\ntheorem is_noetherian [_root_.is_noetherian_ring R₁] (I : fractional_ideal R₁⁰ K) :\n  is_noetherian R₁ I :=\nbegin\n  obtain ⟨d, J, h_nzd, rfl⟩ := exists_eq_span_singleton_mul I,\n  apply is_noetherian_span_singleton_inv_to_map_mul,\n  apply is_noetherian_coe_to_fractional_ideal,\nend\n\nsection adjoin\n\ninclude loc\nomit frac\n\nvariables {R P} (S) (x : P) (hx : is_integral R x)\n\n/-- `A[x]` is a fractional ideal for every integral `x`. -/\nlemma is_fractional_adjoin_integral :\n  is_fractional S (algebra.adjoin R ({x} : set P)).to_submodule :=\nis_fractional_of_fg (fg_adjoin_singleton_of_integral x hx)\n\n/-- `fractional_ideal.adjoin_integral (S : submonoid R) x hx` is `R[x]` as a fractional ideal,\nwhere `hx` is a proof that `x : P` is integral over `R`. -/\n@[simps]\ndef adjoin_integral : fractional_ideal S P :=\n⟨_, is_fractional_adjoin_integral S x hx⟩\n\nlemma mem_adjoin_integral_self :\n  x ∈ adjoin_integral S x hx :=\nalgebra.subset_adjoin (set.mem_singleton x)\n\nend adjoin\n\nend fractional_ideal\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/ring_theory/fractional_ideal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4764368326843802}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Yury Kudryashov\n-/\nimport algebra.algebra.basic\n\n/-!\n\n# The `restrict_scalars` type alias\n\nSee the documentation attached to the `restrict_scalars` definition for advice on how and when to\nuse this type alias. As described there, it is often a better choice to use the `is_scalar_tower`\ntypeclass instead.\n\n## Main definitions\n\n* `restrict_scalars R S M`: the `S`-module `M` viewed as an `R` module when `S` is an `R`-algebra.\n* `restrict_scalars.linear_equiv : restrict_scalars R S M ≃ₗ[S] M`: the equivalence as an\n  `S`-module between the restricted and origianl space.\n* `restrict_scalars.alg_equiv : restrict_scalars R S A ≃ₐ[S] A`: the equivalence as an `S`-algebra\n   between the restricted and original space.\n\n## See also\n\nThere are many similarly-named definitions elsewhere which do not refer to this type alias. These\nrefer to restricting the scalar type in a bundled type, such as from `A →ₗ[R] B` to `A →ₗ[S] B`:\n\n* `linear_map.restrict_scalars`\n* `linear_equiv.restrict_scalars`\n* `alg_hom.restrict_scalars`\n* `alg_equiv.restrict_scalars`\n* `submodule.restrict_scalars`\n* `subalgebra.restrict_scalars`\n-/\n\nvariables (R S M A : Type*)\n\n/-- If we put an `R`-algebra structure on a semiring `S`, we get a natural equivalence from the\ncategory of `S`-modules to the category of representations of the algebra `S` (over `R`). The type\nsynonym `restrict_scalars` is essentially this equivalence.\n\nWarning: use this type synonym judiciously! Consider an example where we want to construct an\n`R`-linear map from `M` to `S`, given:\n```lean\nvariables (R S M : Type*)\nvariables [comm_semiring R] [semiring S] [algebra R S] [add_comm_monoid M] [module S M]\n```\nWith the assumptions above we can't directly state our map as we have no `module R M` structure, but\n`restrict_scalars` permits it to be written as:\n```lean\n-- an `R`-module structure on `M` is provided by `restrict_scalars` which is compatible\nexample : restrict_scalars R S M →ₗ[R] S := sorry\n```\nHowever, it is usually better just to add this extra structure as an argument:\n```lean\n-- an `R`-module structure on `M` and proof of its compatibility is provided by the user\nexample [module R M] [is_scalar_tower R S M] : M →ₗ[R] S := sorry\n```\nThe advantage of the second approach is that it defers the duty of providing the missing typeclasses\n`[module R M] [is_scalar_tower R S M]`. If some concrete `M` naturally carries these (as is often\nthe case) then we have avoided `restrict_scalars` entirely. If not, we can pass\n`restrict_scalars R S M` later on instead of `M`.\n\nNote that this means we almost always want to state definitions and lemmas in the language of\n`is_scalar_tower` rather than `restrict_scalars`.\n\nAn example of when one might want to use `restrict_scalars` would be if one has a vector space\nover a field of characteristic zero and wishes to make use of the `ℚ`-algebra structure. -/\n@[nolint unused_arguments]\ndef restrict_scalars (R S M : Type*) : Type* := M\n\ninstance [I : inhabited M] : inhabited (restrict_scalars R S M) := I\n\ninstance [I : add_comm_monoid M] : add_comm_monoid (restrict_scalars R S M) := I\n\ninstance [I : add_comm_group M] : add_comm_group (restrict_scalars R S M) := I\n\ninstance restrict_scalars.module_orig [semiring S] [add_comm_monoid M] [I : module S M] :\n  module S (restrict_scalars R S M) := I\n\n/-- `restrict_scalars.linear_equiv` is an equivalence of modules over the semiring `S`. -/\ndef restrict_scalars.linear_equiv [semiring S] [add_comm_monoid M] [module S M] :\n  restrict_scalars R S M ≃ₗ[S] M :=\nlinear_equiv.refl S M\n\nsection module\nvariables [semiring S] [add_comm_monoid M] [comm_semiring R] [algebra R S] [module S M]\n\n/--\nWhen `M` is a module over a ring `S`, and `S` is an algebra over `R`, then `M` inherits a\nmodule structure over `R`.\n\nThe preferred way of setting this up is `[module R M] [module S M] [is_scalar_tower R S M]`.\n-/\ninstance : module R (restrict_scalars R S M) :=\nmodule.comp_hom M (algebra_map R S)\n\nlemma restrict_scalars_smul_def (c : R) (x : restrict_scalars R S M) :\n  c • x = ((algebra_map R S c) • x : M) := rfl\n\n@[simp] lemma restrict_scalars.linear_equiv_map_smul (t : R) (x : restrict_scalars R S M) :\n  restrict_scalars.linear_equiv R S M (t • x)\n  = (algebra_map R S t) • restrict_scalars.linear_equiv R S M x :=\nrfl\n\ninstance : is_scalar_tower R S (restrict_scalars R S M) :=\n⟨λ r S M, by { rw [algebra.smul_def, mul_smul], refl }⟩\n\nend module\n\nsection algebra\n\ninstance [I : semiring A] : semiring (restrict_scalars R S A) := I\ninstance [I : ring A] : ring (restrict_scalars R S A) := I\ninstance [I : comm_semiring A] : comm_semiring (restrict_scalars R S A) := I\ninstance [I : comm_ring A] : comm_ring (restrict_scalars R S A) := I\n\nvariables [comm_semiring S] [semiring A]\n\ninstance restrict_scalars.algebra_orig [I : algebra S A] : algebra S (restrict_scalars R S A) := I\n\nvariables [algebra S A]\n\n/-- Tautological `S`-algebra isomorphism `restrict_scalars R S A ≃ₐ[S] A`. -/\ndef restrict_scalars.alg_equiv : restrict_scalars R S A ≃ₐ[S] A := alg_equiv.refl\n\nvariables [comm_semiring R] [algebra R S]\n\n/-- `R ⟶ S` induces `S-Alg ⥤ R-Alg` -/\ninstance : algebra R (restrict_scalars R S A) :=\n{ smul := (•),\n  commutes' := λ r x, algebra.commutes _ _,\n  smul_def' := λ _ _, algebra.smul_def _ _,\n  .. (algebra_map S A).comp (algebra_map R S) }\n\nend algebra\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/algebra/restrict_scalars.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577158, "lm_q2_score": 0.6150878555160666, "lm_q1q2_score": 0.4764368262830333}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Eric Rodriguez\n\n! This file was ported from Lean 3 source module data.nat.choose.bounds\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GroupPower.Lemmas\nimport Mathbin.Algebra.Order.Field.Basic\nimport Mathbin.Data.Nat.Choose.Basic\n\n/-!\n# Inequalities for binomial coefficients\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves exponential bounds on binomial coefficients. We might want to add here the\nbounds `n^r/r^r ≤ n.choose r ≤ e^r n^r/r^r` in the future.\n\n## Main declarations\n\n* `nat.choose_le_pow`: `n.choose r ≤ n^r / r!`\n* `nat.pow_le_choose`: `(n + 1 - r)^r / r! ≤ n.choose r`. Beware of the fishy ℕ-subtraction.\n-/\n\n\nopen Nat\n\nvariable {α : Type _} [LinearOrderedSemifield α]\n\nnamespace Nat\n\n/- warning: nat.choose_le_pow -> Nat.choose_le_pow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (r : Nat) (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) (Nat.choose n r)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) n) r) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) (Nat.factorial r)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (r : Nat) (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) (Nat.choose n r)) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) n r)) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) (Nat.factorial r)))\nCase conversion may be inaccurate. Consider using '#align nat.choose_le_pow Nat.choose_le_powₓ'. -/\ntheorem choose_le_pow (r n : ℕ) : (n.choose r : α) ≤ n ^ r / r ! :=\n  by\n  rw [le_div_iff']\n  · norm_cast\n    rw [← Nat.descFactorial_eq_factorial_mul_choose]\n    exact n.desc_factorial_le_pow r\n  exact_mod_cast r.factorial_pos\n#align nat.choose_le_pow Nat.choose_le_pow\n\n/- warning: nat.pow_le_choose -> Nat.pow_le_choose is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (r : Nat) (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))) (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) r)) r) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) (Nat.factorial r))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))))))))) (Nat.choose n r))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} α] (r : Nat) (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedSemifield.toDiv.{u1} α _inst_1)) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) r) r)) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) (Nat.factorial r))) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (DivisionSemiring.toSemiring.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α _inst_1)))) (Nat.choose n r))\nCase conversion may be inaccurate. Consider using '#align nat.pow_le_choose Nat.pow_le_chooseₓ'. -/\n-- horrific casting is due to ℕ-subtraction\ntheorem pow_le_choose (r n : ℕ) : ((n + 1 - r : ℕ) ^ r : α) / r ! ≤ n.choose r :=\n  by\n  rw [div_le_iff']\n  · norm_cast\n    rw [← Nat.descFactorial_eq_factorial_mul_choose]\n    exact n.pow_sub_le_desc_factorial r\n  exact_mod_cast r.factorial_pos\n#align nat.pow_le_choose Nat.pow_le_choose\n\nend Nat\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Nat/Choose/Bounds.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577158, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.47643682628303324}}
{"text": "import Mathlib\n\n\n\n/-!\n# Useful helpers\n\nContains the actual category class `Cat`.\n-/\n\n\n\n/-! ## Constant combinator -/\n\nabbrev 𝕂\n  {α : Sort u}\n  {β : Sort v}\n  (val : β)\n: α → β :=\n  fun _ => val\n\n\n\n/-! ## Defining categories -/\n\n\n\n--- A category with objects of type `Object`.\n@[reducible]\nclass Cat\n  (Object : Sort o)\n  (OSem : outParam (Object → Sort osem))\n  (Arrow : Object → Object → Sort a)\n  (ASem : outParam (Object → Object → Sort asem))\nwhere\n  --- Arrow composition.\n  compose {α β γ} :\n    Arrow β γ → Arrow α β → Arrow α γ\n\n  --- Arrow concretization.\n  aConcrete :\n    (A : Arrow α β) → ASem α β\n\n  -- aConcrete_distributive\n  --   {α β γ}\n  --   (f : Arrow β γ)\n  --   (g : Arrow α β)\n  -- : aConcrete (compose f g) = compose (aConcrete f) (aConcrete g)\n\n  --- Arrow composition is associative.\n  compose_assoc {α β γ δ} (f : Arrow γ δ) (g : Arrow β γ) (h : Arrow α β) :\n    aConcrete (compose f (compose g h))\n    =\n    aConcrete (compose (compose f g) h)\n\n  --- Identity, careful not to shadow `id`.\n  protected id {α : outParam Object} :\n    Arrow α α\n  --- `id ∘ f` is `f`.\n  id_compose (f : Arrow α β) :\n    aConcrete (compose id f) = aConcrete f\n  --- `f ∘ id` is `f`.\n  compose_id (f : Arrow α β) :\n    aConcrete (compose f id) = aConcrete f\n\n\nclass Cat.Abstract\n  (Object : Sort o)\n  (Arrow : Object → Object → Sort a)\nextends\n  Cat Object (𝕂 Object) Arrow Arrow\nwhere\n  aConcrete a := a\n\n\n\n--- Nice notation for `Cat.Arrow`, enter `\\r=`.\ninfixr:80 \" ⇒ \" => Cat.Arrow\n--- Usual function composition.\ninfixr:80 \" ∘c \" => Cat.compose\n\n\n\n--- Category **0** with no objects and no arrows.\ndef Cat.zero : Cat.Abstract Empty (fun _ _ => Unit) where\n  id :=\n    by intros ; contradiction\n  compose :=\n    by intros ; contradiction\n  compose_assoc :=\n    by intros ; contradiction\n  id_compose :=\n    by intros ; contradiction\n  compose_id :=\n    by intros ; contradiction\n\n\n\n--- Category **1** with one object and its identity arrow.\ndef Cat.one : Cat.Abstract Unit (fun _ _ => Unit) where\n  compose _ _ :=\n    ()\n  compose_assoc _ _ _ :=\n    rfl\n  id :=\n    ()\n  id_compose _ :=\n    rfl\n  compose_id _ :=\n    rfl\n\n\n\n--- Empty structure that stores two booleans as type parameters.\n---\n--- This is going to be the arrow for category `Cat.two`.\n@[reducible]\nstructure Cat.two.Arrow (b₁ b₂ : Bool)\n\n--- Category **2** with two objects, two identity arrows, and an arrow from one object to the other.\ndef Cat.two : Cat.Abstract Bool two.Arrow where\n  compose _ _ := {}\n  compose_assoc _ _ _ :=\n    rfl\n  id := {}\n  id_compose _ :=\n    rfl\n  compose_id _ :=\n    rfl\n\n\n\n--- Objects of the category **3**.\ninductive Cat.three.Object\n| A\n| B\n| C\n\n--- Arrows of the category **3**.\nstructure Cat.three.Arrow (o₁ o₂ : Cat.three.Object)\n\n--- Category **3** with three objects `A`, `B` and `C`.\n---\n--- Besides the three identity arrows, we have `A → B`, `B → C`, and `C → A`.\ndef Cat.three : Cat.Abstract three.Object three.Arrow where\n  compose _ _ := {}\n  compose_assoc _ _ _ :=\n    rfl\n  id := {}\n  id_compose _ :=\n    rfl\n  compose_id _ :=\n    rfl\n\n\n\n--- Dual of a category.\ninstance Cat.Abstract.dual\n  (cat : Cat.Abstract Object Arrow)\n: Cat.Abstract Object (fun α β => Arrow β α) where\n  compose f g :=\n    cat.compose g f\n  compose_assoc f g h :=\n    by\n      simp\n      rw [cat.compose_assoc h g f]\n\n  id := cat.id\n  id_compose :=\n    cat.compose_id\n  compose_id :=\n    cat.id_compose\n\n--- Applying `Dual` two times yields the original.\ntheorem Cat.Abstract.dual_dual\n  (cat : Cat.Abstract Object Arrow)\n: cat.dual.dual = cat :=\n  rfl\n\n\n\ninstance Cat.Prod\n  (cat₁ : Cat O₁ OSem₁ A₁ ASem₁)\n  (cat₂ : Cat O₂ OSem₂ A₂ ASem₂)\n: Cat\n  (PProd O₁ O₂)\n  (fun ⟨o₁, o₂⟩ => OSem₁ o₁ × OSem₂ o₂)\n  (fun ⟨α₁, α₂⟩ ⟨β₁, β₂⟩ => PProd (A₁ α₁ β₁) (A₂ α₂ β₂))\n  (fun ⟨α₁, α₂⟩ ⟨β₁, β₂⟩ => PProd (ASem₁ α₁ β₁) (ASem₂ α₂ β₂))\nwhere\n  aConcrete a :=\n    ⟨cat₁.aConcrete a.1, cat₂.aConcrete a.2⟩\n  compose f g :=\n    ⟨cat₁.compose f.1 g.1, cat₂.compose f.2 g.2⟩\n  compose_assoc {α β γ δ} f g h :=\n    let res : _ ∧ _ :=\n      ⟨cat₁.compose_assoc f.1 g.1 h.1, cat₂.compose_assoc f.2 g.2 h.2⟩\n    by\n      simp [res]\n  id :=\n    ⟨cat₁.id, cat₂.id⟩\n  id_compose f :=\n    let res : _ ∧ _ :=\n      ⟨cat₁.id_compose f.1, cat₂.id_compose f.2⟩\n    by\n      simp [res]\n  compose_id f :=\n    let res : _ ∧ _ :=\n      ⟨cat₁.compose_id f.1, cat₂.compose_id f.2⟩\n    by\n      simp [res]\n\n\n\nnamespace Cat.UpArrow\n  universe\n    o osem\n    a asem\n\n  variable\n\n    {Object : Sort o}\n    {ASem : Object → Object → Sort asem}\n\n    (A : Object → Object → Sort a)\n\n\n\n  inductive Obj\n    (A : Object → Object → Sort a)\n  : Sort (max 1 o a)\n    | mk : A α β → Obj A\n\n  def Obj.dom : Obj A → Object\n    | @Obj.mk _ _ α _β _ =>\n      α\n  def Obj.cod : Obj A → Object\n    | @Obj.mk _ _ _α β _ =>\n      β\n  def Obj.get : Obj A → ((α : Object) ×' (β : Object) ×' A α β)\n    | @Obj.mk _ _ α β a =>\n      ⟨α, β, a⟩\n  def Obj.getFun : (self : Obj A) → A self.dom self.cod\n    | @Obj.mk _ _ _α _β a =>\n      a\n\n  def Obj.Concrete\n    (ASem : Object → Object → Sort asem)\n    (self : Obj A)\n  : Sort asem :=\n    ASem self.dom self.cod\n\n\n\n  variable\n    {OSem : Object → Sort osem}\n    (cat : Cat Object OSem A ASem)\n\n  structure Arrow\n    (α β : Obj A)\n  : Sort (max 1 o a)\n  where\n    a : A α.dom β.dom\n    b : A α.cod β.cod\n    legal :\n      let f :=\n        α.getFun\n      let f' :=\n        β.getFun\n      cat.compose f' a\n      =\n      cat.compose b f\n\n  def Arrow.Concrete\n    (ASem : Object → Object → Sort asem)\n    (α β : Obj A)\n  : Sort asem :=\n    ASem α.dom β.cod\n\n  def Arrow.concrete\n    (self : Arrow A (cat := cat) α β)\n  : ASem α.dom β.cod :=\n    let a :=\n      self.a (cat := cat)\n    let f' :=\n      β.getFun\n    cat.compose f' a\n    |> cat.aConcrete\n\n  def Arrow.compose\n    {α β γ}\n    (f : Arrow A cat β γ)\n    (g : Arrow A cat α β)\n  : Arrow A cat α γ where\n    a :=\n      cat.compose f.a g.a\n    b :=\n      cat.compose f.b g.b\n    legal :=\n      let legal_f := f.legal\n      let legal_g := g.legal\n      by\n        simp at legal_f\n        simp at legal_g\n        simp\n        sorry\nend Cat.UpArrow\n\n\n/-- Given `cat`, builds `cat⟶` (upperscript arrow, dunno how to unicode it). -/\ninstance Cat.UpArrow\n  [cat : Cat O OSem A ASem]\n: Cat\n  (UpArrow.Obj A)\n  (UpArrow.Obj.Concrete A ASem)\n  (UpArrow.Arrow A cat)\n  (UpArrow.Arrow.Concrete A ASem)\nwhere\n  aConcrete :=\n    UpArrow.Arrow.concrete A cat\n\n  compose :=\n    by sorry\n  compose_assoc :=\n    by sorry\n\n  id :=\n    by sorry\n  id_compose :=\n    by sorry\n  compose_id :=\n    by sorry\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/category/Category/Init.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577157, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.47643682628303313}}
{"text": "import ..list.map_accum_lemmas\nimport .zero_length_lemmas\n\nuniverse variables u\n\nnamespace vector\n\nvariable {α : Type u}\nvariable {n : ℕ}\n\nlocal infix `++`:65 := vector.append\n\n-- Simplify map_accumr₂ over empty lists\n@[simp]\ntheorem map_accumr₂_nil\n  {α β γ φ : Type}\n  (f : α → β → γ → γ × φ)\n  (x : vector α 0)\n  (y : vector β 0)\n  (i₀ : γ)\n: map_accumr₂ f x y i₀ = (i₀, nil) :=\nbegin\n  simp [length_zero_vector_is_nil x, length_zero_vector_is_nil y\n       , nil, map_accumr₂, list.map_accumr₂],\n  apply congr_arg,\n  apply vector.eq,\n  simp,\nend\n\n-- Simplify map_accumr₂ over appending single element to end of lists\n@[simp]\ntheorem map_accumr₂_append1\n  {n : ℕ}\n  {α β γ φ : Type}\n  (f : α → β → γ → γ × φ)\n  (x : vector α n) (a : α)\n  (y : vector β n) (b : β)\n  (c : γ)\n: map_accumr₂ f (x ++ cons a nil) (y ++ cons b nil) c =\n  let r := f a b c in\n  let z := map_accumr₂ f x y (r.fst) in\n  ⟨ z.fst, z.snd ++ cons r.snd nil⟩ :=\nbegin\n  -- Reduce to proof about list.map_accumr₂ and use corresponding theorem\n  cases x with xv xp,\n  cases y with yv yp,\n  have len_pr : xv^.length = yv^.length, { simp [xp, yp] },\n  simp [vector.cons, vector.nil, vector.append, map_accumr₂],\n  simp [list.map_accumr₂_append1 f _ _ len_pr],\nend\n\nend vector\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/vector/map_accum_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6688802735722128, "lm_q1q2_score": 0.47639805824068154}}
{"text": "/-\nCopyright (c) 2021 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport data.set.lattice\nimport order.directed\n/-!\n# Union lift\nThis file defines `set.Union_lift` to glue together functions defined on each of a collection of\nsets to make a function on the Union of those sets.\n\n## Main definitions\n\n* `set.Union_lift` -  Given a Union of sets `Union S`, define a function on any subset of the Union\n  by defining it on each component, and proving that it agrees on the intersections.\n* `set.lift_cover` - Version of `set.Union_lift` for the special case that the sets cover the\n  entire type.\n\n## Main statements\n\nThere are proofs of the obvious properties of `Union_lift`, i.e. what it does to elements of\neach of the sets in the `Union`, stated in different ways.\n\nThere are also three lemmas about `Union_lift` intended to aid with proving that `Union_lift` is a\nhomomorphism when defined on a Union of substructures. There is one lemma each to show that\nconstants, unary functions, or binary functions are preserved. These lemmas are:\n\n*`set.Union_lift_const`\n*`set.Union_lift_unary`\n*`set.Union_lift_binary`\n\n## Tags\n\ndirected union, directed supremum, glue, gluing\n-/\n\nvariables {α ι β : Type*}\n\nnamespace set\n\nsection Union_lift\n\n/- The unused argument `hf` is left in the definition so that the `simp` lemmas\n`Union_lift_inclusion` will work without the user having to provide `hf` explicitly to\nsimplify terms involving `Union_lift`. -/\n/-- Given a Union of sets `Union S`, define a function on the Union by defining\nit on each component, and proving that it agrees on the intersections. -/\n@[nolint unused_arguments]\nnoncomputable def Union_lift (S : ι → set α)\n  (f : Π i (x : S i), β)\n  (hf : ∀ i j (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩)\n  (T : set α) (hT : T ⊆ Union S) (x : T) : β :=\nlet i := classical.indefinite_description _ (mem_Union.1 (hT x.prop)) in\nf i ⟨x, i.prop⟩\n\nvariables\n  {S : ι → set α}\n  {f : Π i (x : S i), β}\n  {hf : ∀ i j (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩}\n  {T : set α} {hT : T ⊆ Union S} (hT' : T = Union S)\n\n@[simp] lemma Union_lift_mk\n  {i : ι} (x : S i) (hx : (x : α) ∈ T) :\n  Union_lift S f hf T hT ⟨x, hx⟩ = f i x :=\nlet j := classical.indefinite_description _ (mem_Union.1 (hT hx)) in\nby cases x with x hx; exact hf j i x j.2 _\n\n@[simp] lemma Union_lift_inclusion {i : ι} (x : S i)\n  (h : S i ⊆ T) : Union_lift S f hf T hT (set.inclusion h x) = f i x :=\nUnion_lift_mk x _\n\nlemma Union_lift_of_mem\n  (x : T) {i : ι} (hx : (x : α) ∈ S i) :\n  Union_lift S f hf T hT x = f i ⟨x, hx⟩ :=\nby cases x with x hx; exact hf _ _ _ _ _\n\n/-- `Union_lift_const` is useful for proving that `Union_lift` is a homomorphism\n  of algebraic structures when defined on the Union of algebraic subobjects.\n  For example, it could be used to prove that the lift of a collection\n  of group homomorphisms on a union of subgroups preserves `1`. -/\nlemma Union_lift_const (c : T) (ci : Π i, S i) (hci : ∀ i, (ci i : α) = c) (cβ : β)\n  (h : ∀ i, f i (ci i) = cβ) : Union_lift S f hf T hT c = cβ :=\nlet ⟨i, hi⟩ := set.mem_Union.1 (hT c.prop) in\nhave (ci i) = ⟨c, hi⟩, from subtype.ext (hci i),\nby rw [Union_lift_of_mem _ hi, ← this, h]\n\n/-- `Union_lift_unary` is useful for proving that `Union_lift` is a homomorphism\n  of algebraic structures when defined on the Union of algebraic subobjects.\n  For example, it could be used to prove that the lift of a collection\n  of linear_maps on a union of submodules preserves scalar multiplication. -/\nlemma Union_lift_unary (u : T → T) (ui : Π i, S i → S i)\n  (hui : ∀ i (x : S i), u (set.inclusion (show S i ⊆ T, from hT'.symm ▸ set.subset_Union S i) x)\n    = set.inclusion (show S i ⊆ T, from hT'.symm ▸ set.subset_Union S i) (ui i x))\n  (uβ : β → β)\n  (h : ∀ i (x : S i), (f i (ui i x)) = uβ (f i x))\n  (x : T) :\n  Union_lift S f hf T (le_of_eq hT') (u x) = uβ (Union_lift S f hf T (le_of_eq hT') x) :=\nbegin\n  subst hT',\n  cases set.mem_Union.1 x.prop with i hi,\n  rw [Union_lift_of_mem x hi, ← h i],\n  have : x = (set.inclusion (set.subset_Union S i) ⟨x, hi⟩), { cases x, refl },\n  have hx' : (set.inclusion (set.subset_Union S i) (ui i ⟨x, hi⟩) : α) ∈ S i,\n    from (ui i ⟨x, hi⟩).prop,\n  conv_lhs { rw [this, hui, Union_lift_inclusion] }\nend\n\n/-- `Union_lift_binary` is useful for proving that `Union_lift` is a homomorphism\n  of algebraic structures when defined on the Union of algebraic subobjects.\n  For example, it could be used to prove that the lift of a collection\n  of group homomorphisms on a union of subgroups preserves `*`. -/\nlemma Union_lift_binary (dir: directed (≤) S) (op : T → T → T) (opi : Π i, S i → S i → S i)\n  (hopi : ∀ i x y, set.inclusion (show S i ⊆ T, from hT'.symm ▸ set.subset_Union S i) (opi i x y) =\n    op (set.inclusion (show S i ⊆ T, from hT'.symm ▸ set.subset_Union S i) x)\n       (set.inclusion (show S i ⊆ T, from hT'.symm ▸ set.subset_Union S i) y))\n  (opβ : β → β → β)\n  (h : ∀ i (x y : S i), (f i (opi i x y)) = opβ (f i x) (f i y))\n  (x y : T) :\n  Union_lift S f hf T (le_of_eq hT') (op x y) =\n    opβ (Union_lift S f hf T (le_of_eq hT') x) (Union_lift S f hf T (le_of_eq hT') y) :=\nbegin\n  subst hT',\n  cases set.mem_Union.1 x.prop with i hi,\n  cases set.mem_Union.1 y.prop with j hj,\n  rcases dir i j with ⟨k, hik, hjk⟩,\n  rw [Union_lift_of_mem x (hik hi), Union_lift_of_mem y (hjk hj), ← h k],\n  have hx : x = (set.inclusion (set.subset_Union S k) ⟨x, hik hi⟩), { cases x, refl },\n  have hy : y = (set.inclusion (set.subset_Union S k) ⟨y, hjk hj⟩), { cases y, refl },\n  have hxy : (set.inclusion (set.subset_Union S k) (opi k ⟨x, hik hi⟩ ⟨y, hjk hj⟩) : α) ∈ S k,\n    from (opi k ⟨x, hik hi⟩ ⟨y, hjk hj⟩).prop,\n  conv_lhs { rw [hx, hy, ← hopi, Union_lift_of_mem _ hxy] },\n  simp only [coe_inclusion, subtype.coe_eta]\nend\n\nend Union_lift\n\nvariables\n  {S : ι → set α}\n  {f : Π i (x : S i), β}\n  {hf : ∀ i j (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩}\n  {hS : Union S = univ}\n\n/-- Glue together functions defined on each of a collection `S` of sets that cover a type. See\n  also `set.Union_lift`.   -/\nnoncomputable def lift_cover\n  (S : ι → set α)\n  (f : Π i (x : S i), β)\n  (hf : ∀ i j (x : α) (hxi : x ∈ S i) (hxj : x ∈ S j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩)\n  (hS : Union S = univ) (a : α) : β :=\nUnion_lift S f hf univ (hS ▸ set.subset.refl _) ⟨a, trivial⟩\n\n@[simp] lemma lift_cover_coe {i : ι} (x : S i) : lift_cover S f hf hS x = f i x :=\nUnion_lift_mk x _\n\nlemma lift_cover_of_mem {i : ι} {x : α} (hx : (x : α) ∈ S i) :\n  lift_cover S f hf hS x = f i ⟨x, hx⟩ :=\nUnion_lift_of_mem ⟨x, trivial⟩ hx\n\nattribute [irreducible] Union_lift lift_cover\n\nend set\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/set/Union_lift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.47639805824068154}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov, Abhimanyu Pallavi Sudhir\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.filter.basic\nimport Mathlib.algebra.module.pi\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 u_6 u_7 \n\nnamespace Mathlib\n\n/-!\n# Germ of a function at a filter\n\nThe germ of a function `f : α → β` at a filter `l : filter α` is the equivalence class of `f`\nwith respect to the equivalence relation `eventually_eq l`: `f ≈ g` means `∀ᶠ x in l, f x = g x`.\n\n## Main definitions\n\nWe define\n\n* `germ l β` to be the space of germs of functions `α → β` at a filter `l : filter α`;\n* coercion from `α → β` to `germ l β`: `(f : germ l β)` is the germ of `f : α → β`\n  at `l : filter α`; this coercion is declared as `has_coe_t`, so it does not require an explicit\n  up arrow `↑`;\n* coercion from `β` to `germ l β`: `(↑c : germ l β)` is the germ of the constant function\n  `λ x:α, c` at a filter `l`; this coercion is declared as `has_lift_t`, so it requires an explicit\n  up arrow `↑`, see [TPiL][TPiL_coe] for details.\n* `map (F : β → γ) (f : germ l β)` to be the composition of a function `F` and a germ `f`;\n* `map₂ (F : β → γ → δ) (f : germ l β) (g : germ l γ)` to be the germ of `λ x, F (f x) (g x)`\n  at `l`;\n* `f.tendsto lb`: we say that a germ `f : germ l β` tends to a filter `lb` if its representatives\n  tend to `lb` along `l`;\n* `f.comp_tendsto g hg` and `f.comp_tendsto' g hg`: given `f : germ l β` and a function\n  `g : γ → α` (resp., a germ `g : germ lc α`), if `g` tends to `l` along `lc`, then the composition\n  `f ∘ g` is a well-defined germ at `lc`;\n* `germ.lift_pred`, `germ.lift_rel`: lift a predicate or a relation to the space of germs:\n  `(f : germ l β).lift_pred p` means `∀ᶠ x in l, p (f x)`, and similarly for a relation.\n[TPiL_coe]: https://leanprover.github.io/theorem_proving_in_lean/type_classes.html#coercions-using-type-classes\n\nWe also define `map (F : β → γ) : germ l β → germ l γ` sending each germ `f` to `F ∘ f`.\n\nFor each of the following structures we prove that if `β` has this structure, then so does\n`germ l β`:\n\n* one-operation algebraic structures up to `comm_group`;\n* `mul_zero_class`, `distrib`, `semiring`, `comm_semiring`, `ring`, `comm_ring`;\n* `mul_action`, `distrib_mul_action`, `semimodule`;\n* `preorder`, `partial_order`, and `lattice` structures up to `bounded_lattice`;\n* `ordered_cancel_comm_monoid` and `ordered_cancel_add_comm_monoid`.\n\n## Tags\n\nfilter, germ\n-/\n\nnamespace filter\n\n\ntheorem const_eventually_eq' {α : Type u_1} {β : Type u_2} {l : filter α} [ne_bot l] {a : β} {b : β} : filter.eventually (fun (x : α) => a = b) l ↔ a = b :=\n  eventually_const\n\ntheorem const_eventually_eq {α : Type u_1} {β : Type u_2} {l : filter α} [ne_bot l] {a : β} {b : β} : (eventually_eq l (fun (_x : α) => a) fun (_x : α) => b) ↔ a = b :=\n  const_eventually_eq'\n\ntheorem eventually_eq.comp_tendsto {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} {f : α → β} {f' : α → β} (H : eventually_eq l f f') {g : γ → α} {lc : filter γ} (hg : tendsto g lc l) : eventually_eq lc (f ∘ g) (f' ∘ g) :=\n  tendsto.eventually hg H\n\n/-- Setoid used to define the space of germs. -/\ndef germ_setoid {α : Type u_1} (l : filter α) (β : Type u_2) : setoid (α → β) :=\n  setoid.mk (eventually_eq l) sorry\n\n/-- The space of germs of functions `α → β` at a filter `l`. -/\ndef germ {α : Type u_1} (l : filter α) (β : Type u_2) :=\n  quotient (germ_setoid l β)\n\nnamespace germ\n\n\nprotected instance has_coe_t {α : Type u_1} {β : Type u_2} {l : filter α} : has_coe_t (α → β) (germ l β) :=\n  has_coe_t.mk quotient.mk'\n\nprotected instance has_lift_t {α : Type u_1} {β : Type u_2} {l : filter α} : has_lift_t β (germ l β) :=\n  has_lift_t.mk fun (c : β) => ↑fun (x : α) => c\n\n@[simp] theorem quot_mk_eq_coe {α : Type u_1} {β : Type u_2} (l : filter α) (f : α → β) : Quot.mk setoid.r f = ↑f :=\n  rfl\n\n@[simp] theorem mk'_eq_coe {α : Type u_1} {β : Type u_2} (l : filter α) (f : α → β) : quotient.mk' f = ↑f :=\n  rfl\n\ntheorem induction_on {α : Type u_1} {β : Type u_2} {l : filter α} (f : germ l β) {p : germ l β → Prop} (h : ∀ (f : α → β), p ↑f) : p f :=\n  quotient.induction_on' f h\n\ntheorem induction_on₂ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (f : germ l β) (g : germ l γ) {p : germ l β → germ l γ → Prop} (h : ∀ (f : α → β) (g : α → γ), p ↑f ↑g) : p f g :=\n  quotient.induction_on₂' f g h\n\ntheorem induction_on₃ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {l : filter α} (f : germ l β) (g : germ l γ) (h : germ l δ) {p : germ l β → germ l γ → germ l δ → Prop} (H : ∀ (f : α → β) (g : α → γ) (h : α → δ), p ↑f ↑g ↑h) : p f g h :=\n  quotient.induction_on₃' f g h H\n\n/-- Given a map `F : (α → β) → (γ → δ)` that sends functions eventually equal at `l` to functions\neventually equal at `lc`, returns a map from `germ l β` to `germ lc δ`. -/\ndef map' {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {l : filter α} {lc : filter γ} (F : (α → β) → γ → δ) (hF : relator.lift_fun (eventually_eq l) (eventually_eq lc) F F) : germ l β → germ lc δ :=\n  quotient.map' F hF\n\n/-- Given a germ `f : germ l β` and a function `F : (α → β) → γ` sending eventually equal functions\nto the same value, returns the value `F` takes on functions having germ `f` at `l`. -/\ndef lift_on {α : Type u_1} {β : Type u_2} {l : filter α} {γ : Sort u_3} (f : germ l β) (F : (α → β) → γ) (hF : relator.lift_fun (eventually_eq l) Eq F F) : γ :=\n  quotient.lift_on' f F hF\n\n@[simp] theorem map'_coe {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {l : filter α} {lc : filter γ} (F : (α → β) → γ → δ) (hF : relator.lift_fun (eventually_eq l) (eventually_eq lc) F F) (f : α → β) : map' F hF ↑f = ↑(F f) :=\n  rfl\n\n@[simp] theorem coe_eq {α : Type u_1} {β : Type u_2} {l : filter α} {f : α → β} {g : α → β} : ↑f = ↑g ↔ eventually_eq l f g :=\n  quotient.eq'\n\ntheorem Mathlib.filter.eventually_eq.germ_eq {α : Type u_1} {β : Type u_2} {l : filter α} {f : α → β} {g : α → β} : eventually_eq l f g → ↑f = ↑g :=\n  iff.mpr coe_eq\n\n/-- Lift a function `β → γ` to a function `germ l β → germ l γ`. -/\ndef map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (op : β → γ) : germ l β → germ l γ :=\n  map' (function.comp op) sorry\n\n@[simp] theorem map_coe {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (op : β → γ) (f : α → β) : map op ↑f = ↑(op ∘ f) :=\n  rfl\n\n@[simp] theorem map_id {α : Type u_1} {β : Type u_2} {l : filter α} : map id = id :=\n  funext fun (x : germ l β) => quot.induction_on x fun (f : α → β) => Eq.refl (map id (Quot.mk setoid.r f))\n\ntheorem map_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {l : filter α} (op₁ : γ → δ) (op₂ : β → γ) (f : germ l β) : map op₁ (map op₂ f) = map (op₁ ∘ op₂) f :=\n  induction_on f fun (f : α → β) => rfl\n\n/-- Lift a binary function `β → γ → δ` to a function `germ l β → germ l γ → germ l δ`. -/\ndef map₂ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {l : filter α} (op : β → γ → δ) : germ l β → germ l γ → germ l δ :=\n  quotient.map₂' (fun (f : α → β) (g : α → γ) (x : α) => op (f x) (g x)) sorry\n\n@[simp] theorem map₂_coe {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {l : filter α} (op : β → γ → δ) (f : α → β) (g : α → γ) : map₂ op ↑f ↑g = ↑fun (x : α) => op (f x) (g x) :=\n  rfl\n\n/-- A germ at `l` of maps from `α` to `β` tends to `lb : filter β` if it is represented by a map\nwhich tends to `lb` along `l`. -/\nprotected def tendsto {α : Type u_1} {β : Type u_2} {l : filter α} (f : germ l β) (lb : filter β) :=\n  lift_on f (fun (f : α → β) => tendsto f l lb) sorry\n\n@[simp] theorem coe_tendsto {α : Type u_1} {β : Type u_2} {l : filter α} {f : α → β} {lb : filter β} : germ.tendsto (↑f) lb ↔ tendsto f l lb :=\n  iff.rfl\n\ntheorem Mathlib.filter.tendsto.germ_tendsto {α : Type u_1} {β : Type u_2} {l : filter α} {f : α → β} {lb : filter β} : tendsto f l lb → germ.tendsto (↑f) lb :=\n  iff.mpr coe_tendsto\n\n/-- Given two germs `f : germ l β`, and `g : germ lc α`, where `l : filter α`, if `g` tends to `l`,\nthen the composition `f ∘ g` is well-defined as a germ at `lc`. -/\ndef comp_tendsto' {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (f : germ l β) {lc : filter γ} (g : germ lc α) (hg : germ.tendsto g l) : germ lc β :=\n  lift_on f (fun (f : α → β) => map f g) sorry\n\n@[simp] theorem coe_comp_tendsto' {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (f : α → β) {lc : filter γ} {g : germ lc α} (hg : germ.tendsto g l) : comp_tendsto' (↑f) g hg = map f g :=\n  rfl\n\n/-- Given a germ `f : germ l β` and a function `g : γ → α`, where `l : filter α`, if `g` tends\nto `l` along `lc : filter γ`, then the composition `f ∘ g` is well-defined as a germ at `lc`. -/\ndef comp_tendsto {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (f : germ l β) {lc : filter γ} (g : γ → α) (hg : tendsto g lc l) : germ lc β :=\n  comp_tendsto' f (↑g) (tendsto.germ_tendsto hg)\n\n@[simp] theorem coe_comp_tendsto {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (f : α → β) {lc : filter γ} {g : γ → α} (hg : tendsto g lc l) : comp_tendsto (↑f) g hg = ↑(f ∘ g) :=\n  rfl\n\n@[simp] theorem comp_tendsto'_coe {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (f : germ l β) {lc : filter γ} {g : γ → α} (hg : tendsto g lc l) : comp_tendsto' f (↑g) (tendsto.germ_tendsto hg) = comp_tendsto f g hg :=\n  rfl\n\n@[simp] theorem const_inj {α : Type u_1} {β : Type u_2} {l : filter α} [ne_bot l] {a : β} {b : β} : ↑a = ↑b ↔ a = b :=\n  iff.trans coe_eq const_eventually_eq\n\n@[simp] theorem map_const {α : Type u_1} {β : Type u_2} {γ : Type u_3} (l : filter α) (a : β) (f : β → γ) : map f ↑a = ↑(f a) :=\n  rfl\n\n@[simp] theorem map₂_const {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (l : filter α) (b : β) (c : γ) (f : β → γ → δ) : map₂ f ↑b ↑c = ↑(f b c) :=\n  rfl\n\n@[simp] theorem const_comp_tendsto {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (b : β) {lc : filter γ} {g : γ → α} (hg : tendsto g lc l) : comp_tendsto (↑b) g hg = ↑b :=\n  rfl\n\n@[simp] theorem const_comp_tendsto' {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (b : β) {lc : filter γ} {g : germ lc α} (hg : germ.tendsto g l) : comp_tendsto' (↑b) g hg = ↑b :=\n  induction_on g (fun (_x : γ → α) (_x_1 : germ.tendsto (↑_x) l) => rfl) hg\n\n/-- Lift a predicate on `β` to `germ l β`. -/\ndef lift_pred {α : Type u_1} {β : Type u_2} {l : filter α} (p : β → Prop) (f : germ l β) :=\n  lift_on f (fun (f : α → β) => filter.eventually (fun (x : α) => p (f x)) l) sorry\n\n@[simp] theorem lift_pred_coe {α : Type u_1} {β : Type u_2} {l : filter α} {p : β → Prop} {f : α → β} : lift_pred p ↑f ↔ filter.eventually (fun (x : α) => p (f x)) l :=\n  iff.rfl\n\ntheorem lift_pred_const {α : Type u_1} {β : Type u_2} {l : filter α} {p : β → Prop} {x : β} (hx : p x) : lift_pred p ↑x :=\n  eventually_of_forall fun (y : α) => hx\n\n@[simp] theorem lift_pred_const_iff {α : Type u_1} {β : Type u_2} {l : filter α} [ne_bot l] {p : β → Prop} {x : β} : lift_pred p ↑x ↔ p x :=\n  eventually_const\n\n/-- Lift a relation `r : β → γ → Prop` to `germ l β → germ l γ → Prop`. -/\ndef lift_rel {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} (r : β → γ → Prop) (f : germ l β) (g : germ l γ) :=\n  quotient.lift_on₂' f g (fun (f : α → β) (g : α → γ) => filter.eventually (fun (x : α) => r (f x) (g x)) l) sorry\n\n@[simp] theorem lift_rel_coe {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} {r : β → γ → Prop} {f : α → β} {g : α → γ} : lift_rel r ↑f ↑g ↔ filter.eventually (fun (x : α) => r (f x) (g x)) l :=\n  iff.rfl\n\ntheorem lift_rel_const {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} {r : β → γ → Prop} {x : β} {y : γ} (h : r x y) : lift_rel r ↑x ↑y :=\n  eventually_of_forall fun (_x : α) => h\n\n@[simp] theorem lift_rel_const_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} {l : filter α} [ne_bot l] {r : β → γ → Prop} {x : β} {y : γ} : lift_rel r ↑x ↑y ↔ r x y :=\n  eventually_const\n\nprotected instance inhabited {α : Type u_1} {β : Type u_2} {l : filter α} [Inhabited β] : Inhabited (germ l β) :=\n  { default := ↑Inhabited.default }\n\nprotected instance has_add {α : Type u_1} {l : filter α} {M : Type u_5} [Add M] : Add (germ l M) :=\n  { add := map₂ Add.add }\n\n@[simp] theorem coe_add {α : Type u_1} {l : filter α} {M : Type u_5} [Add M] (f : α → M) (g : α → M) : ↑(f + g) = ↑f + ↑g :=\n  rfl\n\nprotected instance has_one {α : Type u_1} {l : filter α} {M : Type u_5} [HasOne M] : HasOne (germ l M) :=\n  { one := ↑1 }\n\n@[simp] theorem coe_zero {α : Type u_1} {l : filter α} {M : Type u_5} [HasZero M] : ↑0 = 0 :=\n  rfl\n\nprotected instance add_semigroup {α : Type u_1} {l : filter α} {M : Type u_5} [add_semigroup M] : add_semigroup (germ l M) :=\n  add_semigroup.mk Add.add sorry\n\nprotected instance add_comm_semigroup {α : Type u_1} {l : filter α} {M : Type u_5} [add_comm_semigroup M] : add_comm_semigroup (germ l M) :=\n  add_comm_semigroup.mk Add.add sorry sorry\n\nprotected instance left_cancel_semigroup {α : Type u_1} {l : filter α} {M : Type u_5} [left_cancel_semigroup M] : left_cancel_semigroup (germ l M) :=\n  left_cancel_semigroup.mk Mul.mul sorry sorry\n\nprotected instance right_cancel_semigroup {α : Type u_1} {l : filter α} {M : Type u_5} [right_cancel_semigroup M] : right_cancel_semigroup (germ l M) :=\n  right_cancel_semigroup.mk Mul.mul sorry sorry\n\nprotected instance monoid {α : Type u_1} {l : filter α} {M : Type u_5} [monoid M] : monoid (germ l M) :=\n  monoid.mk Mul.mul sorry 1 sorry sorry\n\n/-- coercion from functions to germs as a monoid homomorphism. -/\ndef coe_mul_hom {α : Type u_1} {M : Type u_5} [monoid M] (l : filter α) : (α → M) →* germ l M :=\n  monoid_hom.mk coe sorry sorry\n\n/-- coercion from functions to germs as an additive monoid homomorphism. -/\n@[simp] theorem coe_coe_mul_hom {α : Type u_1} {l : filter α} {M : Type u_5} [monoid M] : ⇑(coe_mul_hom l) = coe :=\n  rfl\n\nprotected instance add_comm_monoid {α : Type u_1} {l : filter α} {M : Type u_5} [add_comm_monoid M] : add_comm_monoid (germ l M) :=\n  add_comm_monoid.mk Add.add sorry 0 sorry sorry sorry\n\nprotected instance has_neg {α : Type u_1} {l : filter α} {G : Type u_6} [Neg G] : Neg (germ l G) :=\n  { neg := map Neg.neg }\n\n@[simp] theorem coe_neg {α : Type u_1} {l : filter α} {G : Type u_6} [Neg G] (f : α → G) : ↑(-f) = -↑f :=\n  rfl\n\nprotected instance has_div {α : Type u_1} {l : filter α} {M : Type u_5} [Div M] : Div (germ l M) :=\n  { div := map₂ Div.div }\n\n@[simp] theorem coe_div {α : Type u_1} {l : filter α} {M : Type u_5} [Div M] (f : α → M) (g : α → M) : ↑(f / g) = ↑f / ↑g :=\n  rfl\n\nprotected instance sub_neg_add_monoid {α : Type u_1} {l : filter α} {G : Type u_6} [sub_neg_monoid G] : sub_neg_monoid (germ l G) :=\n  sub_neg_monoid.mk add_monoid.add sorry add_monoid.zero sorry sorry Neg.neg Sub.sub\n\nprotected instance group {α : Type u_1} {l : filter α} {G : Type u_6} [group G] : group (germ l G) :=\n  group.mk Mul.mul sorry 1 sorry sorry div_inv_monoid.inv div_inv_monoid.div sorry\n\nprotected instance comm_group {α : Type u_1} {l : filter α} {G : Type u_6} [comm_group G] : comm_group (germ l G) :=\n  comm_group.mk Mul.mul sorry 1 sorry sorry has_inv.inv group.div sorry sorry\n\nprotected instance nontrivial {α : Type u_1} {l : filter α} {R : Type u_5} [nontrivial R] [ne_bot l] : nontrivial (germ l R) :=\n  sorry\n\nprotected instance mul_zero_class {α : Type u_1} {l : filter α} {R : Type u_5} [mul_zero_class R] : mul_zero_class (germ l R) :=\n  mul_zero_class.mk Mul.mul 0 sorry sorry\n\nprotected instance distrib {α : Type u_1} {l : filter α} {R : Type u_5} [distrib R] : distrib (germ l R) :=\n  distrib.mk Mul.mul Add.add sorry sorry\n\nprotected instance semiring {α : Type u_1} {l : filter α} {R : Type u_5} [semiring R] : semiring (germ l R) :=\n  semiring.mk add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry sorry monoid.mul sorry monoid.one sorry sorry\n    sorry sorry sorry sorry\n\n/-- Coercion `(α → R) → germ l R` as a `ring_hom`. -/\ndef coe_ring_hom {α : Type u_1} {R : Type u_5} [semiring R] (l : filter α) : (α → R) →+* germ l R :=\n  ring_hom.mk coe sorry sorry sorry sorry\n\n@[simp] theorem coe_coe_ring_hom {α : Type u_1} {l : filter α} {R : Type u_5} [semiring R] : ⇑(coe_ring_hom l) = coe :=\n  rfl\n\nprotected instance ring {α : Type u_1} {l : filter α} {R : Type u_5} [ring R] : ring (germ l R) :=\n  ring.mk add_comm_group.add sorry add_comm_group.zero sorry sorry add_comm_group.neg add_comm_group.sub sorry sorry\n    monoid.mul sorry monoid.one sorry sorry sorry sorry\n\nprotected instance comm_semiring {α : Type u_1} {l : filter α} {R : Type u_5} [comm_semiring R] : comm_semiring (germ l R) :=\n  comm_semiring.mk semiring.add sorry semiring.zero sorry sorry sorry semiring.mul sorry semiring.one sorry sorry sorry\n    sorry sorry sorry sorry\n\nprotected instance comm_ring {α : Type u_1} {l : filter α} {R : Type u_5} [comm_ring R] : comm_ring (germ l R) :=\n  comm_ring.mk ring.add sorry ring.zero sorry sorry ring.neg ring.sub sorry sorry ring.mul sorry ring.one sorry sorry\n    sorry sorry sorry\n\nprotected instance has_scalar {α : Type u_1} {β : Type u_2} {l : filter α} {M : Type u_5} [has_scalar M β] : has_scalar M (germ l β) :=\n  has_scalar.mk fun (c : M) => map (has_scalar.smul c)\n\nprotected instance has_scalar' {α : Type u_1} {β : Type u_2} {l : filter α} {M : Type u_5} [has_scalar M β] : has_scalar (germ l M) (germ l β) :=\n  has_scalar.mk (map₂ has_scalar.smul)\n\n@[simp] theorem coe_smul {α : Type u_1} {β : Type u_2} {l : filter α} {M : Type u_5} [has_scalar M β] (c : M) (f : α → β) : ↑(c • f) = c • ↑f :=\n  rfl\n\n@[simp] theorem coe_smul' {α : Type u_1} {β : Type u_2} {l : filter α} {M : Type u_5} [has_scalar M β] (c : α → M) (f : α → β) : ↑(c • f) = ↑c • ↑f :=\n  rfl\n\nprotected instance mul_action {α : Type u_1} {β : Type u_2} {l : filter α} {M : Type u_5} [monoid M] [mul_action M β] : mul_action M (germ l β) :=\n  mul_action.mk sorry sorry\n\nprotected instance mul_action' {α : Type u_1} {β : Type u_2} {l : filter α} {M : Type u_5} [monoid M] [mul_action M β] : mul_action (germ l M) (germ l β) :=\n  mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action {α : Type u_1} {l : filter α} {M : Type u_5} {N : Type u_6} [monoid M] [add_monoid N] [distrib_mul_action M N] : distrib_mul_action M (germ l N) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action' {α : Type u_1} {l : filter α} {M : Type u_5} {N : Type u_6} [monoid M] [add_monoid N] [distrib_mul_action M N] : distrib_mul_action (germ l M) (germ l N) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance semimodule {α : Type u_1} {l : filter α} {M : Type u_5} {R : Type u_7} [semiring R] [add_comm_monoid M] [semimodule R M] : semimodule R (germ l M) :=\n  semimodule.mk sorry sorry\n\nprotected instance semimodule' {α : Type u_1} {l : filter α} {M : Type u_5} {R : Type u_7} [semiring R] [add_comm_monoid M] [semimodule R M] : semimodule (germ l R) (germ l M) :=\n  semimodule.mk sorry sorry\n\nprotected instance has_le {α : Type u_1} {β : Type u_2} {l : filter α} [HasLessEq β] : HasLessEq (germ l β) :=\n  { LessEq := lift_rel LessEq }\n\n@[simp] theorem coe_le {α : Type u_1} {β : Type u_2} {l : filter α} {f : α → β} {g : α → β} [HasLessEq β] : ↑f ≤ ↑g ↔ eventually_le l f g :=\n  iff.rfl\n\ntheorem le_def {α : Type u_1} {β : Type u_2} {l : filter α} [HasLessEq β] : LessEq = lift_rel LessEq :=\n  rfl\n\ntheorem const_le {α : Type u_1} {β : Type u_2} {l : filter α} [HasLessEq β] {x : β} {y : β} (h : x ≤ y) : ↑x ≤ ↑y :=\n  lift_rel_const h\n\n@[simp] theorem const_le_iff {α : Type u_1} {β : Type u_2} {l : filter α} [HasLessEq β] [ne_bot l] {x : β} {y : β} : ↑x ≤ ↑y ↔ x ≤ y :=\n  lift_rel_const_iff\n\nprotected instance preorder {α : Type u_1} {β : Type u_2} {l : filter α} [preorder β] : preorder (germ l β) :=\n  preorder.mk LessEq (fun (a b : germ l β) => a ≤ b ∧ ¬b ≤ a) sorry sorry\n\nprotected instance partial_order {α : Type u_1} {β : Type u_2} {l : filter α} [partial_order β] : partial_order (germ l β) :=\n  partial_order.mk LessEq preorder.lt sorry sorry sorry\n\nprotected instance has_bot {α : Type u_1} {β : Type u_2} {l : filter α} [has_bot β] : has_bot (germ l β) :=\n  has_bot.mk ↑⊥\n\n@[simp] theorem const_bot {α : Type u_1} {β : Type u_2} {l : filter α} [has_bot β] : ↑⊥ = ⊥ :=\n  rfl\n\nprotected instance order_bot {α : Type u_1} {β : Type u_2} {l : filter α} [order_bot β] : order_bot (germ l β) :=\n  order_bot.mk ⊥ LessEq partial_order.lt sorry sorry sorry sorry\n\nprotected instance has_top {α : Type u_1} {β : Type u_2} {l : filter α} [has_top β] : has_top (germ l β) :=\n  has_top.mk ↑⊤\n\n@[simp] theorem const_top {α : Type u_1} {β : Type u_2} {l : filter α} [has_top β] : ↑⊤ = ⊤ :=\n  rfl\n\nprotected instance order_top {α : Type u_1} {β : Type u_2} {l : filter α} [order_top β] : order_top (germ l β) :=\n  order_top.mk ⊤ LessEq partial_order.lt sorry sorry sorry sorry\n\nprotected instance has_sup {α : Type u_1} {β : Type u_2} {l : filter α} [has_sup β] : has_sup (germ l β) :=\n  has_sup.mk (map₂ has_sup.sup)\n\n@[simp] theorem const_sup {α : Type u_1} {β : Type u_2} {l : filter α} [has_sup β] (a : β) (b : β) : ↑(a ⊔ b) = ↑a ⊔ ↑b :=\n  rfl\n\nprotected instance has_inf {α : Type u_1} {β : Type u_2} {l : filter α} [has_inf β] : has_inf (germ l β) :=\n  has_inf.mk (map₂ has_inf.inf)\n\n@[simp] theorem const_inf {α : Type u_1} {β : Type u_2} {l : filter α} [has_inf β] (a : β) (b : β) : ↑(a ⊓ b) = ↑a ⊓ ↑b :=\n  rfl\n\nprotected instance semilattice_sup {α : Type u_1} {β : Type u_2} {l : filter α} [semilattice_sup β] : semilattice_sup (germ l β) :=\n  semilattice_sup.mk has_sup.sup partial_order.le partial_order.lt sorry sorry sorry sorry sorry sorry\n\nprotected instance semilattice_inf {α : Type u_1} {β : Type u_2} {l : filter α} [semilattice_inf β] : semilattice_inf (germ l β) :=\n  semilattice_inf.mk has_inf.inf partial_order.le partial_order.lt sorry sorry sorry sorry sorry sorry\n\nprotected instance semilattice_inf_bot {α : Type u_1} {β : Type u_2} {l : filter α} [semilattice_inf_bot β] : semilattice_inf_bot (germ l β) :=\n  semilattice_inf_bot.mk order_bot.bot semilattice_inf.le semilattice_inf.lt sorry sorry sorry sorry semilattice_inf.inf\n    sorry sorry sorry\n\nprotected instance semilattice_sup_bot {α : Type u_1} {β : Type u_2} {l : filter α} [semilattice_sup_bot β] : semilattice_sup_bot (germ l β) :=\n  semilattice_sup_bot.mk order_bot.bot semilattice_sup.le semilattice_sup.lt sorry sorry sorry sorry semilattice_sup.sup\n    sorry sorry sorry\n\nprotected instance semilattice_inf_top {α : Type u_1} {β : Type u_2} {l : filter α} [semilattice_inf_top β] : semilattice_inf_top (germ l β) :=\n  semilattice_inf_top.mk order_top.top semilattice_inf.le semilattice_inf.lt sorry sorry sorry sorry semilattice_inf.inf\n    sorry sorry sorry\n\nprotected instance semilattice_sup_top {α : Type u_1} {β : Type u_2} {l : filter α} [semilattice_sup_top β] : semilattice_sup_top (germ l β) :=\n  semilattice_sup_top.mk order_top.top semilattice_sup.le semilattice_sup.lt sorry sorry sorry sorry semilattice_sup.sup\n    sorry sorry sorry\n\nprotected instance lattice {α : Type u_1} {β : Type u_2} {l : filter α} [lattice β] : lattice (germ l β) :=\n  lattice.mk semilattice_sup.sup semilattice_sup.le semilattice_sup.lt sorry sorry sorry sorry sorry sorry\n    semilattice_inf.inf sorry sorry sorry\n\nprotected instance bounded_lattice {α : Type u_1} {β : Type u_2} {l : filter α} [bounded_lattice β] : bounded_lattice (germ l β) :=\n  bounded_lattice.mk lattice.sup lattice.le lattice.lt sorry sorry sorry sorry sorry sorry lattice.inf sorry sorry sorry\n    order_top.top sorry order_bot.bot sorry\n\nprotected instance ordered_cancel_add_comm_monoid {α : Type u_1} {β : Type u_2} {l : filter α} [ordered_cancel_add_comm_monoid β] : ordered_cancel_add_comm_monoid (germ l β) :=\n  ordered_cancel_add_comm_monoid.mk add_comm_monoid.add sorry sorry add_comm_monoid.zero sorry sorry sorry sorry\n    partial_order.le partial_order.lt sorry sorry sorry sorry sorry\n\nprotected instance ordered_add_comm_group {α : Type u_1} {β : Type u_2} {l : filter α} [ordered_add_comm_group β] : ordered_add_comm_group (germ l β) :=\n  ordered_add_comm_group.mk add_comm_group.add sorry add_comm_group.zero sorry sorry add_comm_group.neg add_comm_group.sub\n    sorry sorry partial_order.le partial_order.lt sorry sorry sorry sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/order/filter/germ.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6688802471698041, "lm_q1q2_score": 0.4763980476073575}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module algebraic_geometry.morphisms.finite_type\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.AlgebraicGeometry.Morphisms.RingHomProperties\nimport Mathbin.RingTheory.RingHom.FiniteType\n\n/-!\n# Morphisms of finite type\n\nA morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and\n`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type.\n\nA morphism of schemes is of finite type if it is both locally of finite type and quasi-compact.\n\nWe show that these properties are local, and are stable under compositions.\n\n-/\n\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace\n\nuniverse v u\n\nnamespace AlgebraicGeometry\n\nvariable {X Y : Scheme.{u}} (f : X ⟶ Y)\n\n/-- A morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and\n`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type.\n-/\n@[mk_iff]\nclass LocallyOfFiniteType (f : X ⟶ Y) : Prop where\n  finiteType_of_affine_subset :\n    ∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ (Opens.map f.1.base).obj U.1),\n      (f.appLe e).FiniteType\n#align algebraic_geometry.locally_of_finite_type AlgebraicGeometry.LocallyOfFiniteType\n\ntheorem locallyOfFiniteType_eq : @LocallyOfFiniteType = affineLocally @RingHom.FiniteType :=\n  by\n  ext (X Y f)\n  rw [locally_of_finite_type_iff, affine_locally_iff_affine_opens_le]\n  exact RingHom.finiteType_respectsIso\n#align algebraic_geometry.locally_of_finite_type_eq AlgebraicGeometry.locallyOfFiniteType_eq\n\ninstance (priority := 900) locallyOfFiniteTypeOfIsOpenImmersion {X Y : Scheme} (f : X ⟶ Y)\n    [IsOpenImmersion f] : LocallyOfFiniteType f :=\n  locallyOfFiniteType_eq.symm ▸ RingHom.finiteType_is_local.affineLocally_of_isOpenImmersion f\n#align algebraic_geometry.locally_of_finite_type_of_is_open_immersion AlgebraicGeometry.locallyOfFiniteTypeOfIsOpenImmersion\n\ntheorem locallyOfFiniteType_stableUnderComposition :\n    MorphismProperty.StableUnderComposition @LocallyOfFiniteType :=\n  locallyOfFiniteType_eq.symm ▸ RingHom.finiteType_is_local.affineLocally_stableUnderComposition\n#align algebraic_geometry.locally_of_finite_type_stable_under_composition AlgebraicGeometry.locallyOfFiniteType_stableUnderComposition\n\ninstance locallyOfFiniteTypeComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)\n    [hf : LocallyOfFiniteType f] [hg : LocallyOfFiniteType g] : LocallyOfFiniteType (f ≫ g) :=\n  locallyOfFiniteType_stableUnderComposition f g hf hg\n#align algebraic_geometry.locally_of_finite_type_comp AlgebraicGeometry.locallyOfFiniteTypeComp\n\ntheorem locallyOfFiniteTypeOfComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)\n    [hf : LocallyOfFiniteType (f ≫ g)] : LocallyOfFiniteType f :=\n  by\n  revert hf\n  rw [locally_of_finite_type_eq]\n  apply ring_hom.finite_type_is_local.affine_locally_of_comp\n  introv H\n  exact RingHom.FiniteType.of_comp_finiteType H\n#align algebraic_geometry.locally_of_finite_type_of_comp AlgebraicGeometry.locallyOfFiniteTypeOfComp\n\ntheorem LocallyOfFiniteType.affine_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y)\n    (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]\n    (𝒰' : ∀ i, Scheme.OpenCover.{u} ((𝒰.pullbackCover f).obj i)) [∀ i j, IsAffine ((𝒰' i).obj j)] :\n    LocallyOfFiniteType f ↔ ∀ i j, (Scheme.Γ.map ((𝒰' i).map j ≫ pullback.snd).op).FiniteType :=\n  locallyOfFiniteType_eq.symm ▸ RingHom.finiteType_is_local.affine_openCover_iff f 𝒰 𝒰'\n#align algebraic_geometry.locally_of_finite_type.affine_open_cover_iff AlgebraicGeometry.LocallyOfFiniteType.affine_openCover_iff\n\ntheorem LocallyOfFiniteType.source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y)\n    (𝒰 : Scheme.OpenCover.{u} X) : LocallyOfFiniteType f ↔ ∀ i, LocallyOfFiniteType (𝒰.map i ≫ f) :=\n  locallyOfFiniteType_eq.symm ▸ RingHom.finiteType_is_local.source_openCover_iff f 𝒰\n#align algebraic_geometry.locally_of_finite_type.source_open_cover_iff AlgebraicGeometry.LocallyOfFiniteType.source_openCover_iff\n\ntheorem LocallyOfFiniteType.openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y)\n    (𝒰 : Scheme.OpenCover.{u} Y) :\n    LocallyOfFiniteType f ↔ ∀ i, LocallyOfFiniteType (pullback.snd : pullback f (𝒰.map i) ⟶ _) :=\n  locallyOfFiniteType_eq.symm ▸ RingHom.finiteType_is_local.isLocalAffineLocally.openCover_iff f 𝒰\n#align algebraic_geometry.locally_of_finite_type.open_cover_iff AlgebraicGeometry.LocallyOfFiniteType.openCover_iff\n\ntheorem locallyOfFiniteType_respectsIso : MorphismProperty.RespectsIso @LocallyOfFiniteType :=\n  locallyOfFiniteType_eq.symm ▸\n    targetAffineLocally_respectsIso (sourceAffineLocally_respectsIso RingHom.finiteType_respectsIso)\n#align algebraic_geometry.locally_of_finite_type_respects_iso AlgebraicGeometry.locallyOfFiniteType_respectsIso\n\nend AlgebraicGeometry\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/AlgebraicGeometry/Morphisms/FiniteType.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.47639804352169685}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\n\nimport algebra.module.pi\nimport data.polynomial.basic\nimport group_theory.group_action.prod\nimport group_theory.group_action.units\nimport data.complex.module\n\n/-! # Tests that instances do not form diamonds -/\n\n/-! ## Scalar action instances -/\nsection has_scalar\n\nexample :\n  (sub_neg_monoid.has_scalar_int : has_scalar ℤ ℂ) = (complex.has_scalar : has_scalar ℤ ℂ) :=\nrfl\n\nexample (α β : Type*) [add_monoid α] [add_monoid β] :\n  (prod.has_scalar : has_scalar ℕ (α × β)) = add_monoid.has_scalar_nat := rfl\n\nexample (α β : Type*) [sub_neg_monoid α] [sub_neg_monoid β] :\n  (prod.has_scalar : has_scalar ℤ (α × β)) = sub_neg_monoid.has_scalar_int := rfl\n\nexample (α : Type*) (β : α → Type*) [Π a, add_monoid (β a)] :\n  (pi.has_scalar : has_scalar ℕ (Π a, β a)) = add_monoid.has_scalar_nat := rfl\n\nexample (α : Type*) (β : α → Type*) [Π a, sub_neg_monoid (β a)] :\n  (pi.has_scalar : has_scalar ℤ (Π a, β a)) = sub_neg_monoid.has_scalar_int := rfl\n\nsection units\n\nexample (α : Type*) [monoid α] :\n  (units.mul_action : mul_action (units α) (α × α)) = prod.mul_action := rfl\n\nexample (R α : Type*) (β : α → Type*) [monoid R] [Π i, mul_action R (β i)] :\n  (units.mul_action : mul_action (units R) (Π i, β i)) = pi.mul_action _ := rfl\n\nexample (R α : Type*) (β : α → Type*) [monoid R] [semiring α] [distrib_mul_action R α] :\n  (units.distrib_mul_action : distrib_mul_action (units R) (polynomial α)) =\n    polynomial.distrib_mul_action :=\nrfl\n\n/-!\nTODO: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/units.2Emul_action'.20diamond/near/246402813\n```lean\nexample {α : Type*} [comm_monoid α] :\n  (units.mul_action' : mul_action (units α) (units α)) = monoid.to_mul_action _ :=\nrfl -- fails\n```\n-/\n\nend units\n\nend has_scalar\n\n/-! ## `with_top` (Type with point at infinity) instances -/\nsection with_top\n\nexample (R : Type*) [h : ordered_semiring R] :\n  (@with_top.add_comm_monoid R\n    (@non_unital_non_assoc_semiring.to_add_comm_monoid R\n      (@non_assoc_semiring.to_non_unital_non_assoc_semiring R\n        (@semiring.to_non_assoc_semiring R\n          (@ordered_semiring.to_semiring R h)))))\n        =\n  (@ordered_add_comm_monoid.to_add_comm_monoid (with_top R)\n    (@with_top.ordered_add_comm_monoid R\n      (@ordered_cancel_add_comm_monoid.to_ordered_add_comm_monoid R\n        (@ordered_semiring.to_ordered_cancel_add_comm_monoid R h)))) :=\nrfl\n\nend with_top\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/test/instance_diamonds.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4763324826342444}}
{"text": "import tactic.localized\nimport algebra.group_power.lemmas\n\nopen tactic\nlocal infix ` ⊹ `:59 := nat.mul\nlocal infix ` ↓ `:59 := pow\nlocal infix ` ⊖ `:59 := pow\nexample : 2 ⊹ 3 = 6 := rfl\nexample : 2 ↓ 3 = 8 := rfl\nexample : 2 ⊖ 3 = 8 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { success_if_fail { simp [h] }, exact le_of_lt h }\nsection\nlocalized \"infix (name := plus) ` ⊹ `:59 := nat.add\" in nat\nlocalized \"infix (name := down) ` ↓ `:59 := nat.mul\" in nat\nlocalized \"infix (name := minus) ` ⊖ `:59 := nat.mul\" in nat.mul\nlocalized \"attribute [simp] le_of_lt\" in le\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 6 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { simp [h] }\nend\n\nsection\nexample : 2 ⊹ 3 = 6 := rfl\nexample : 2 ↓ 3 = 8 := rfl\nexample : 2 ⊖ 3 = 8 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { success_if_fail { simp [h] }, exact le_of_lt h }\n\n-- test that `open_locale` will fail when given a nonexistent locale\nrun_cmd success_if_fail $ get_localized [`ceci_nest_pas_une_locale]\n\nopen_locale nat\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 8 := rfl\n\nopen_locale nat.mul\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 6 := rfl\nend\n\nsection\nopen_locale nat.mul nat nat.mul le\nexample : 2 ⊹ 3 = 5 := rfl\nexample : 2 ↓ 3 = 6 := rfl\nexample : 2 ⊖ 3 = 6 := rfl\nexample {n m : ℕ} (h : n < m) : n ≤ m := by { simp [h] }\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/localized/localized.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.47633247743020457}}
{"text": "import data.nat.basic\nimport tactic.basic\n\ndef foo : char → ℕ\n| 'A' := 1\n| 'B' := 2\n| _   := 3\n\n#print foo._main\n\ninductive data\n| const (n : ℕ) : data\n| var (n : ℕ) : data\n| plus s t : data\n| times s t : data\n\nopen data\n\ndef eval (v : list ℕ): data → option ℕ\n| (const n) := n\n| (var n) := v.nth n\n| (plus s t) := (eval s).bind (λ s, (eval t).map (λ t, s + t))\n| (times s t) := (eval s).bind (λ s, (eval t).map (λ t, s * t))\n\n#reduce eval [] (plus (const 1) (const 2))\n#reduce eval [2,3,5] (times (var 0) (plus (var 1) (var 2)))\n\nvariable {α : Type}\n\n/- this and the next makes simp way more powerful -/\nlocal attribute [simp]\ndef len : list α → ℕ\n| (x::xs) := 1 + len xs\n| _ := 0\n\nlocal attribute [simp]\ndef rev : list α → list α\n| (x::xs) := rev xs ++ [x]\n| _ := []\n\n@[simp]\ndef rev' : list α → list α → list α\n| [] r := r\n| (x::xs) r := rev' xs (x::r)\n\n@[simp]\ndef rev_tl (as : list α) : list α := rev' as []\n\n-- @[simp]\n-- lemma rev'_cons (a : α) (as : list α) (xs: list α):\n--   rev' (a :: as) xs = rev' as (a::xs) := by induction as; simp\n\nlemma rev'_app : ∀ as rs xs : list α,\n  rev' as rs ++ xs = rev' as (rs ++ xs)\n| [] _ _ := by simp\n| _ _ [] := by simp\n| (a::as) rs (x::xs) := by simp *\n\nlemma rev_rev' (as : list α) : rev as = rev' as [] :=\nbegin\n  induction as,\n    simp *,\n  unfold rev,\n  unfold rev',\n  rw as_ih,\n  rw rev'_app,\n  rw list.nil_append,\nend\n\ntheorem tl_same (as : list α) : rev as = rev_tl as :=\nby induction as; simp [rev_rev']\n\n#reduce rev [1,2,3]\n\nlocal attribute [simp]\ntheorem len_cons (x : α) (xs : list α) :\n  len (x::xs) = 1 + len xs := by simp\n\nlocal attribute [simp]\ntheorem len_app (s : list α) (t : list α) :\n  len (s ++ t) = len s + len t := by induction s; simp [*, add_assoc]\n\ntheorem len_rev : ∀ as : list α, len (rev as) = len as\n| (a::as) := by simp [*, add_comm]\n| [] := rfl\n\ntheorem len_rev' (as : list α) : len (rev as) = len as :=\n  by induction as; simp [*, add_comm]\n\nopen nat\n\ntheorem zero_add' : ∀ n, zero + n = n\n| zero     := rfl\n| (succ n) := congr_arg succ (zero_add' n)\n\n#print acc\n\ndef nat_to_bin : ℕ → list ℕ\n| 0       := [0]\n| 1       := [1]\n| (n + 2) :=\n  have (n + 2) / 2 < n + 2, from sorry,\n  nat_to_bin ((n + 2) / 2) ++ [n % 2]\n\n#eval nat_to_bin 1234567\n\nuniverse u\n\ninductive vector (α : Type u) : nat → Type u\n| nil {} : vector 0\n| cons   : Π {n}, α → vector n → vector (n+1)\n\nnamespace vector\nlocal notation h :: t := cons h t\n\n#check @vector.cases_on\n-- Π {α : Type}\n--   {C : Π (a : ℕ), vector α a → Type}\n--   {a : ℕ}\n--   (n : vector α a),\n--   (e1 : C 0 nil)\n--   (e2 : Π {n : ℕ} (a : α) (a_1 : vector α n),\n--           C (n + 1) (cons a a_1)),\n--   C a n\n\nlocal notation h :: t := cons h t\n\ndef tail_aux {α : Type} {n m : ℕ} (v : vector α m) :\n    m = n + 1 → vector α n :=\nvector.cases_on v\n  (assume H : 0 = n + 1, nat.no_confusion H)\n  (assume m (a : α) w : vector α m,\n    assume H : m + 1 = n + 1,\n      nat.no_confusion H (λ H1 : m = n, eq.rec_on H1 w))\n\ndef tail' {α : Type} {n : ℕ} (v : vector α (n+1)) :\n  vector α n :=\ntail_aux v rfl\n\ndef head {α : Type} : Π {n}, vector α (n+1) → α\n| n (h :: t) := h\n\ndef tail {α : Type} : Π {n}, vector α (n+1) → vector α n\n| n (h :: t) := t\n\nlemma eta {α : Type} :\n  ∀ {n} (v : vector α (n+1)), head v :: tail v = v\n| n (h :: t) := rfl\n\ndef map {α β γ : Type} (f : α → β → γ) :\n  Π {n}, vector α n → vector β n → vector γ n\n| 0     nil       nil       := nil\n| (n+1) (a :: va) (b :: vb) := f a b :: map va vb\n\n#print map\n#print map._main\n\ndef zip {α β : Type} :\n  Π {n}, vector α n → vector β n → vector (α × β) n\n| 0     nil       nil       := nil\n| (n+1) (a :: va) (b :: vb) := (a, b) :: zip va vb\n\nend vector\n\nvariable p : α → bool\n\ndef is_not_zero (m : ℕ) : bool :=\nmatch m with\n| 0     := ff\n| (n+1) := tt\nend\n\ndef filter : list α → list α\n| []       := []\n| (a :: l) :=\n  match p a with\n  |  tt := a :: filter l\n  |  ff := filter l\n  end\n\nexample : filter is_not_zero [1, 0, 0, 3, 0] = [1, 3] := rfl\n\ndef bar₁ : ℕ × ℕ → ℕ\n| (m, n) := m + n\n\ndef bar₂ (p : ℕ × ℕ) : ℕ :=\nmatch p with (m, n) := m + n end\n\ndef bar₃ : ℕ × ℕ → ℕ :=\nλ ⟨m, n⟩, m + n\n\ndef bar₄ (p : ℕ × ℕ) : ℕ :=\nlet ⟨m, n⟩ := p in m + n", "meta": {"author": "michens", "repo": "learn-lean", "sha": "f38fc342780ddff5a164a18e5482163dea506ccd", "save_path": "github-repos/lean/michens-learn-lean", "path": "github-repos/lean/michens-learn-lean/learn-lean-f38fc342780ddff5a164a18e5482163dea506ccd/tpil/induction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.752012562644147, "lm_q1q2_score": 0.4763324755934774}}
{"text": "theorem test1 :∀ y:ℕ, ∃ x:ℕ, x-2=y:=λ y,exists.intro (y+2) rfl\n#print classical.some\nnoncomputable def test2 : ℕ → ℕ :=λ y, classical.some (test1 y)\ntheorem test3 : ∀ y:ℕ,test2 y-2=y:=λ y,classical.some_spec (test1 y)\nSort hello \n#check test3 7", "meta": {"author": "ChrisHughes24", "repo": "leanstuff", "sha": "9efa85f72efaccd1d540385952a6acc18fce8687", "save_path": "github-repos/lean/ChrisHughes24-leanstuff", "path": "github-repos/lean/ChrisHughes24-leanstuff/leanstuff-9efa85f72efaccd1d540385952a6acc18fce8687/mods_and_fermat_little.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9099069962657176, "lm_q2_score": 0.523420348936324, "lm_q1q2_score": 0.4762638374850044}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport algebra.group.hom\nimport data.equiv.basic\n/-!\n# Type tags that turn additive structures into multiplicative, and vice versa\n\nWe define two type tags:\n\n* `additive α`: turns any multiplicative structure on `α` into the corresponding\n  additive structure on `additive α`;\n* `multiplicative α`: turns any additive structure on `α` into the corresponding\n  multiplicative structure on `multiplicative α`.\n\nWe also define instances `additive.*` and `multiplicative.*` that actually transfer the structures.\n-/\n\nuniverses u v\nvariables {α : Type u} {β : Type v}\n\n/-- If `α` carries some multiplicative structure, then `additive α` carries the corresponding\nadditive structure. -/\ndef additive (α : Type*) := α\n/-- If `α` carries some additive structure, then `multiplicative α` carries the corresponding\nmultiplicative structure. -/\ndef multiplicative (α : Type*) := α\n\nnamespace additive\n\n/-- Reinterpret `x : α` as an element of `additive α`. -/\ndef of_mul : α ≃ additive α := ⟨λ x, x, λ x, x, λ x, rfl, λ x, rfl⟩\n\n/-- Reinterpret `x : additive α` as an element of `α`. -/\ndef to_mul : additive α ≃ α := of_mul.symm\n\n@[simp] lemma of_mul_symm_eq : (@of_mul α).symm = to_mul := rfl\n\n@[simp] lemma to_mul_symm_eq : (@to_mul α).symm = of_mul := rfl\n\nend additive\n\nnamespace multiplicative\n\n/-- Reinterpret `x : α` as an element of `multiplicative α`. -/\ndef of_add : α ≃ multiplicative α := ⟨λ x, x, λ x, x, λ x, rfl, λ x, rfl⟩\n\n/-- Reinterpret `x : multiplicative α` as an element of `α`. -/\ndef to_add : multiplicative α ≃ α := of_add.symm\n\n@[simp] lemma of_add_symm_eq : (@of_add α).symm = to_add := rfl\n\n@[simp] \n\nend multiplicative\n\n@[simp] lemma to_add_of_add (x : α) : (multiplicative.of_add x).to_add = x := rfl\n@[simp] lemma of_add_to_add (x : multiplicative α) : multiplicative.of_add x.to_add = x := rfl\n\n@[simp] lemma to_mul_of_mul (x : α) : (additive.of_mul x).to_mul = x := rfl\n@[simp] lemma of_mul_to_mul (x : additive α) : additive.of_mul x.to_mul = x := rfl\n\ninstance [inhabited α] : inhabited (additive α) := ⟨additive.of_mul (default α)⟩\ninstance [inhabited α] : inhabited (multiplicative α) := ⟨multiplicative.of_add (default α)⟩\n\ninstance [nontrivial α] : nontrivial (additive α) :=\nadditive.of_mul.injective.nontrivial\n\ninstance [nontrivial α] : nontrivial (multiplicative α) :=\nmultiplicative.of_add.injective.nontrivial\n\ninstance additive.has_add [has_mul α] : has_add (additive α) :=\n{ add := λ x y, additive.of_mul (x.to_mul * y.to_mul) }\n\ninstance [has_add α] : has_mul (multiplicative α) :=\n{ mul := λ x y, multiplicative.of_add (x.to_add + y.to_add) }\n\n@[simp] lemma of_add_add [has_add α] (x y : α) :\n  multiplicative.of_add (x + y) = multiplicative.of_add x * multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_mul [has_add α] (x y : multiplicative α) :\n  (x * y).to_add = x.to_add + y.to_add :=\nrfl\n\n@[simp] lemma of_mul_mul [has_mul α] (x y : α) :\n  additive.of_mul (x * y) = additive.of_mul x + additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_add [has_mul α] (x y : additive α) :\n  (x + y).to_mul = x.to_mul * y.to_mul :=\nrfl\n\ninstance [semigroup α] : add_semigroup (additive α) :=\n{ add_assoc := @mul_assoc α _,\n  ..additive.has_add }\n\ninstance [add_semigroup α] : semigroup (multiplicative α) :=\n{ mul_assoc := @add_assoc α _,\n  ..multiplicative.has_mul }\n\ninstance [comm_semigroup α] : add_comm_semigroup (additive α) :=\n{ add_comm := @mul_comm _ _,\n  ..additive.add_semigroup }\n\ninstance [add_comm_semigroup α] : comm_semigroup (multiplicative α) :=\n{ mul_comm := @add_comm _ _,\n  ..multiplicative.semigroup }\n\ninstance [left_cancel_semigroup α] : add_left_cancel_semigroup (additive α) :=\n{ add_left_cancel := @mul_left_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_left_cancel_semigroup α] : left_cancel_semigroup (multiplicative α) :=\n{ mul_left_cancel := @add_left_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [right_cancel_semigroup α] : add_right_cancel_semigroup (additive α) :=\n{ add_right_cancel := @mul_right_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_right_cancel_semigroup α] : right_cancel_semigroup (multiplicative α) :=\n{ mul_right_cancel := @add_right_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [has_one α] : has_zero (additive α) := ⟨additive.of_mul 1⟩\n\n@[simp] lemma of_mul_one [has_one α] : @additive.of_mul α 1 = 0 := rfl\n\n@[simp] lemma of_mul_eq_zero {A : Type*} [has_one A] {x : A} :\n  additive.of_mul x = 0 ↔ x = 1 := iff.rfl\n\n@[simp] lemma to_mul_zero [has_one α] : (0 : additive α).to_mul = 1 := rfl\n\ninstance [has_zero α] : has_one (multiplicative α) := ⟨multiplicative.of_add 0⟩\n\n@[simp] lemma of_add_zero [has_zero α] : @multiplicative.of_add α 0 = 1 := rfl\n\n@[simp] lemma of_add_eq_one {A : Type*} [has_zero A] {x : A} :\n  multiplicative.of_add x = 1 ↔ x = 0 := iff.rfl\n\n@[simp] lemma to_add_one [has_zero α] : (1 : multiplicative α).to_add = 0 := rfl\n\ninstance [mul_one_class α] : add_zero_class (additive α) :=\n{ zero     := 0,\n  add      := (+),\n  zero_add := one_mul,\n  add_zero := mul_one }\n\ninstance [add_zero_class α] : mul_one_class (multiplicative α) :=\n{ one     := 1,\n  mul     := (*),\n  one_mul := zero_add,\n  mul_one := add_zero }\n\ninstance [h : monoid α] : add_monoid (additive α) :=\n{ zero     := 0,\n  add      := (+),\n  nsmul    := @npow α h,\n  nsmul_zero' := monoid.npow_zero',\n  nsmul_succ' := monoid.npow_succ',\n  ..additive.add_zero_class,\n  ..additive.add_semigroup }\n\ninstance [h : add_monoid α] : monoid (multiplicative α) :=\n{ one     := 1,\n  mul     := (*),\n  npow   := @nsmul α h,\n  npow_zero' := add_monoid.nsmul_zero',\n  npow_succ' := add_monoid.nsmul_succ',\n  ..multiplicative.mul_one_class,\n  ..multiplicative.semigroup }\n\ninstance [left_cancel_monoid α] : add_left_cancel_monoid (additive α) :=\n{ .. additive.add_monoid, .. additive.add_left_cancel_semigroup }\n\ninstance [add_left_cancel_monoid α] : left_cancel_monoid (multiplicative α) :=\n{ .. multiplicative.monoid, .. multiplicative.left_cancel_semigroup }\n\ninstance [right_cancel_monoid α] : add_right_cancel_monoid (additive α) :=\n{ .. additive.add_monoid, .. additive.add_right_cancel_semigroup }\n\ninstance [add_right_cancel_monoid α] : right_cancel_monoid (multiplicative α) :=\n{ .. multiplicative.monoid, .. multiplicative.right_cancel_semigroup }\n\ninstance [comm_monoid α] : add_comm_monoid (additive α) :=\n{ .. additive.add_monoid, .. additive.add_comm_semigroup }\n\ninstance [add_comm_monoid α] : comm_monoid (multiplicative α) :=\n{ ..multiplicative.monoid, .. multiplicative.comm_semigroup }\n\ninstance [has_inv α] : has_neg (additive α) := ⟨λ x, multiplicative.of_add x.to_mul⁻¹⟩\n\n@[simp] lemma of_mul_inv [has_inv α] (x : α) : additive.of_mul x⁻¹ = -(additive.of_mul x) := rfl\n\n@[simp] lemma to_mul_neg [has_inv α] (x : additive α) : (-x).to_mul = x.to_mul⁻¹ := rfl\n\ninstance [has_neg α] : has_inv (multiplicative α) := ⟨λ x, additive.of_mul (-x.to_add)⟩\n\n@[simp] lemma of_add_neg [has_neg α] (x : α) :\n  multiplicative.of_add (-x) = (multiplicative.of_add x)⁻¹ := rfl\n\n@[simp] lemma to_add_inv [has_neg α] (x : multiplicative α) :\n  (x⁻¹).to_add = -x.to_add := rfl\n\ninstance additive.has_sub [has_div α] : has_sub (additive α) :=\n{ sub := λ x y, additive.of_mul (x.to_mul / y.to_mul) }\n\ninstance multiplicative.has_div [has_sub α] : has_div (multiplicative α) :=\n{ div := λ x y, multiplicative.of_add (x.to_add - y.to_add) }\n\n@[simp] lemma of_add_sub [has_sub α] (x y : α) :\n  multiplicative.of_add (x - y) = multiplicative.of_add x / multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_div [has_sub α] (x y : multiplicative α) :\n  (x / y).to_add = x.to_add - y.to_add :=\nrfl\n\n@[simp] lemma of_mul_div [has_div α] (x y : α) :\n  additive.of_mul (x / y) = additive.of_mul x - additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_sub [has_div α] (x y : additive α) :\n  (x - y).to_mul = x.to_mul / y.to_mul :=\nrfl\n\ninstance [div_inv_monoid α] : sub_neg_monoid (additive α) :=\n{ sub_eq_add_neg := @div_eq_mul_inv α _,\n  gsmul := @gpow α _,\n  gsmul_zero' := div_inv_monoid.gpow_zero',\n  gsmul_succ' := div_inv_monoid.gpow_succ',\n  gsmul_neg' := div_inv_monoid.gpow_neg',\n  .. additive.has_neg, .. additive.has_sub, .. additive.add_monoid }\n\ninstance [sub_neg_monoid α] : div_inv_monoid (multiplicative α) :=\n{ div_eq_mul_inv := @sub_eq_add_neg α _,\n  gpow := @gsmul α _,\n  gpow_zero' := sub_neg_monoid.gsmul_zero',\n  gpow_succ' := sub_neg_monoid.gsmul_succ',\n  gpow_neg' := sub_neg_monoid.gsmul_neg',\n  .. multiplicative.has_inv, .. multiplicative.has_div, .. multiplicative.monoid }\n\ninstance [group α] : add_group (additive α) :=\n{ add_left_neg := @mul_left_inv α _,\n  .. additive.sub_neg_monoid }\n\ninstance [add_group α] : group (multiplicative α) :=\n{ mul_left_inv := @add_left_neg α _,\n  .. multiplicative.div_inv_monoid }\n\ninstance [comm_group α] : add_comm_group (additive α) :=\n{ .. additive.add_group, .. additive.add_comm_monoid }\n\ninstance [add_comm_group α] : comm_group (multiplicative α) :=\n{ .. multiplicative.group, .. multiplicative.comm_monoid }\n\n/-- Reinterpret `α →+ β` as `multiplicative α →* multiplicative β`. -/\ndef add_monoid_hom.to_multiplicative [add_zero_class α] [add_zero_class β] :\n  (α →+ β) ≃ (multiplicative α →* multiplicative β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `α →* β` as `additive α →+ additive β`. -/\ndef monoid_hom.to_additive [mul_one_class α] [mul_one_class β] :\n  (α →* β) ≃ (additive α →+ additive β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `additive α →+ β` as `α →* multiplicative β`. -/\ndef add_monoid_hom.to_multiplicative' [mul_one_class α] [add_zero_class β] :\n  (additive α →+ β) ≃ (α →* multiplicative β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `α →* multiplicative β` as `additive α →+ β`. -/\ndef monoid_hom.to_additive' [mul_one_class α] [add_zero_class β] :\n  (α →* multiplicative β) ≃ (additive α →+ β) :=\nadd_monoid_hom.to_multiplicative'.symm\n\n/-- Reinterpret `α →+ additive β` as `multiplicative α →* β`. -/\ndef add_monoid_hom.to_multiplicative'' [add_zero_class α] [mul_one_class β] :\n  (α →+ additive β) ≃ (multiplicative α →* β) :=\n⟨λ f, ⟨f.1, f.2, f.3⟩, λ f, ⟨f.1, f.2, f.3⟩, λ x, by { ext, refl, }, λ x, by { ext, refl, }⟩\n\n/-- Reinterpret `multiplicative α →* β` as `α →+ additive β`. -/\ndef monoid_hom.to_additive'' [add_zero_class α] [mul_one_class β] :\n  (multiplicative α →* β) ≃ (α →+ additive β) :=\nadd_monoid_hom.to_multiplicative''.symm\n\n/-- If `α` has some multiplicative structure and coerces to a function,\nthen `additive α` should also coerce to the same function.\n\nThis allows `additive` to be used on bundled function types with a multiplicative structure, which\nis often used for composition, without affecting the behavior of the function itself.\n-/\ninstance additive.has_coe_to_fun {α : Type*} [has_coe_to_fun α] :\n  has_coe_to_fun (additive α) :=\n⟨λ a, has_coe_to_fun.F a.to_mul, λ a, coe_fn a.to_mul⟩\n\n/-- If `α` has some additive structure and coerces to a function,\nthen `multiplicative α` should also coerce to the same function.\n\nThis allows `multiplicative` to be used on bundled function types with an additive structure, which\nis often used for composition, without affecting the behavior of the function itself.\n-/\ninstance multiplicative.has_coe_to_fun {α : Type*} [has_coe_to_fun α] :\n  has_coe_to_fun (multiplicative α) :=\n⟨λ a, has_coe_to_fun.F a.to_add, λ a, coe_fn a.to_add⟩\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/group/type_tags.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7606506526772884, "lm_q1q2_score": 0.47626176406573917}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.multiset.dedup\n! leanprover-community/mathlib commit f2f413b9d4be3a02840d0663dace76e8fe3da053\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Multiset.Nodup\n\n/-!\n# Erasing duplicates in a multiset.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nnamespace Multiset\n\nopen List\n\nvariable {α β : Type _} [DecidableEq α]\n\n/-! ### dedup -/\n\n\n#print Multiset.dedup /-\n/-- `dedup s` removes duplicates from `s`, yielding a `nodup` multiset. -/\ndef dedup (s : Multiset α) : Multiset α :=\n  Quot.liftOn s (fun l => (l.dedup : Multiset α)) fun s t p => Quot.sound p.dedup\n#align multiset.dedup Multiset.dedup\n-/\n\n#print Multiset.coe_dedup /-\n@[simp]\ntheorem coe_dedup (l : List α) : @dedup α _ l = l.dedup :=\n  rfl\n#align multiset.coe_dedup Multiset.coe_dedup\n-/\n\n#print Multiset.dedup_zero /-\n@[simp]\ntheorem dedup_zero : @dedup α _ 0 = 0 :=\n  rfl\n#align multiset.dedup_zero Multiset.dedup_zero\n-/\n\n#print Multiset.mem_dedup /-\n@[simp]\ntheorem mem_dedup {a : α} {s : Multiset α} : a ∈ dedup s ↔ a ∈ s :=\n  Quot.inductionOn s fun l => mem_dedup\n#align multiset.mem_dedup Multiset.mem_dedup\n-/\n\n#print Multiset.dedup_cons_of_mem /-\n@[simp]\ntheorem dedup_cons_of_mem {a : α} {s : Multiset α} : a ∈ s → dedup (a ::ₘ s) = dedup s :=\n  Quot.inductionOn s fun l m => @congr_arg _ _ _ _ coe <| dedup_cons_of_mem m\n#align multiset.dedup_cons_of_mem Multiset.dedup_cons_of_mem\n-/\n\n#print Multiset.dedup_cons_of_not_mem /-\n@[simp]\ntheorem dedup_cons_of_not_mem {a : α} {s : Multiset α} : a ∉ s → dedup (a ::ₘ s) = a ::ₘ dedup s :=\n  Quot.inductionOn s fun l m => congr_arg coe <| dedup_cons_of_not_mem m\n#align multiset.dedup_cons_of_not_mem Multiset.dedup_cons_of_not_mem\n-/\n\n/- warning: multiset.dedup_le -> Multiset.dedup_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Multiset.{u1} α), LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) s\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (s : Multiset.{u1} α), LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s) s\nCase conversion may be inaccurate. Consider using '#align multiset.dedup_le Multiset.dedup_leₓ'. -/\ntheorem dedup_le (s : Multiset α) : dedup s ≤ s :=\n  Quot.inductionOn s fun l => (dedup_sublist _).Subperm\n#align multiset.dedup_le Multiset.dedup_le\n\n#print Multiset.dedup_subset /-\ntheorem dedup_subset (s : Multiset α) : dedup s ⊆ s :=\n  subset_of_le <| dedup_le _\n#align multiset.dedup_subset Multiset.dedup_subset\n-/\n\n#print Multiset.subset_dedup /-\ntheorem subset_dedup (s : Multiset α) : s ⊆ dedup s := fun a => mem_dedup.2\n#align multiset.subset_dedup Multiset.subset_dedup\n-/\n\n#print Multiset.dedup_subset' /-\n@[simp]\ntheorem dedup_subset' {s t : Multiset α} : dedup s ⊆ t ↔ s ⊆ t :=\n  ⟨Subset.trans (subset_dedup _), Subset.trans (dedup_subset _)⟩\n#align multiset.dedup_subset' Multiset.dedup_subset'\n-/\n\n#print Multiset.subset_dedup' /-\n@[simp]\ntheorem subset_dedup' {s t : Multiset α} : s ⊆ dedup t ↔ s ⊆ t :=\n  ⟨fun h => Subset.trans h (dedup_subset _), fun h => Subset.trans h (subset_dedup _)⟩\n#align multiset.subset_dedup' Multiset.subset_dedup'\n-/\n\n#print Multiset.nodup_dedup /-\n@[simp]\ntheorem nodup_dedup (s : Multiset α) : Nodup (dedup s) :=\n  Quot.inductionOn s nodup_dedup\n#align multiset.nodup_dedup Multiset.nodup_dedup\n-/\n\n#print Multiset.dedup_eq_self /-\ntheorem dedup_eq_self {s : Multiset α} : dedup s = s ↔ Nodup s :=\n  ⟨fun e => e ▸ nodup_dedup s, Quot.inductionOn s fun l h => congr_arg coe h.dedup⟩\n#align multiset.dedup_eq_self Multiset.dedup_eq_self\n-/\n\nalias dedup_eq_self ↔ _ nodup.dedup\n#align multiset.nodup.dedup Multiset.Nodup.dedup\n\n#print Multiset.count_dedup /-\ntheorem count_dedup (m : Multiset α) (a : α) : m.dedup.count a = if a ∈ m then 1 else 0 :=\n  Quot.inductionOn m fun l => count_dedup _ _\n#align multiset.count_dedup Multiset.count_dedup\n-/\n\n#print Multiset.dedup_idempotent /-\n@[simp]\ntheorem dedup_idempotent {m : Multiset α} : m.dedup.dedup = m.dedup :=\n  Quot.inductionOn m fun l => @congr_arg _ _ _ _ coe dedup_idempotent\n#align multiset.dedup_idempotent Multiset.dedup_idempotent\n-/\n\n#print Multiset.dedup_bind_dedup /-\n@[simp]\ntheorem dedup_bind_dedup [DecidableEq β] (m : Multiset α) (f : α → Multiset β) :\n    (m.dedup.bind f).dedup = (m.bind f).dedup :=\n  by\n  ext x\n  simp_rw [count_dedup, mem_bind, mem_dedup]\n#align multiset.dedup_bind_dedup Multiset.dedup_bind_dedup\n-/\n\n#print Multiset.dedup_eq_zero /-\ntheorem dedup_eq_zero {s : Multiset α} : dedup s = 0 ↔ s = 0 :=\n  ⟨fun h => eq_zero_of_subset_zero <| h ▸ subset_dedup _, fun h => h.symm ▸ dedup_zero⟩\n#align multiset.dedup_eq_zero Multiset.dedup_eq_zero\n-/\n\n#print Multiset.dedup_singleton /-\n@[simp]\ntheorem dedup_singleton {a : α} : dedup ({a} : Multiset α) = {a} :=\n  (nodup_singleton _).dedup\n#align multiset.dedup_singleton Multiset.dedup_singleton\n-/\n\n/- warning: multiset.le_dedup -> Multiset.le_dedup is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α} {t : Multiset.{u1} α}, Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) s (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t)) (And (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) s t) (Multiset.Nodup.{u1} α s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α} {t : Multiset.{u1} α}, Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) s (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t)) (And (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) s t) (Multiset.Nodup.{u1} α s))\nCase conversion may be inaccurate. Consider using '#align multiset.le_dedup Multiset.le_dedupₓ'. -/\ntheorem le_dedup {s t : Multiset α} : s ≤ dedup t ↔ s ≤ t ∧ Nodup s :=\n  ⟨fun h => ⟨le_trans h (dedup_le _), nodup_of_le h (nodup_dedup _)⟩, fun ⟨l, d⟩ =>\n    (le_iff_subset d).2 <| Subset.trans (subset_of_le l) (subset_dedup _)⟩\n#align multiset.le_dedup Multiset.le_dedup\n\n/- warning: multiset.le_dedup_self -> Multiset.le_dedup_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α}, Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) s (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Multiset.Nodup.{u1} α s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α}, Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) s (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s)) (Multiset.Nodup.{u1} α s)\nCase conversion may be inaccurate. Consider using '#align multiset.le_dedup_self Multiset.le_dedup_selfₓ'. -/\ntheorem le_dedup_self {s : Multiset α} : s ≤ dedup s ↔ Nodup s := by\n  rw [le_dedup, and_iff_right le_rfl]\n#align multiset.le_dedup_self Multiset.le_dedup_self\n\n#print Multiset.dedup_ext /-\ntheorem dedup_ext {s t : Multiset α} : dedup s = dedup t ↔ ∀ a, a ∈ s ↔ a ∈ t := by simp [nodup.ext]\n#align multiset.dedup_ext Multiset.dedup_ext\n-/\n\n#print Multiset.dedup_map_dedup_eq /-\ntheorem dedup_map_dedup_eq [DecidableEq β] (f : α → β) (s : Multiset α) :\n    dedup (map f (dedup s)) = dedup (map f s) := by simp [dedup_ext]\n#align multiset.dedup_map_dedup_eq Multiset.dedup_map_dedup_eq\n-/\n\n/- warning: multiset.dedup_nsmul -> Multiset.dedup_nsmul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{succ u1} (Multiset.{u1} α) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (SMul.smul.{0, u1} Nat (Multiset.{u1} α) (AddMonoid.SMul.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) n s)) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{succ u1} (Multiset.{u1} α) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (HSMul.hSMul.{0, u1, u1} Nat (Multiset.{u1} α) (Multiset.{u1} α) (instHSMul.{0, u1} Nat (Multiset.{u1} α) (AddMonoid.SMul.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) n s)) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) s))\nCase conversion may be inaccurate. Consider using '#align multiset.dedup_nsmul Multiset.dedup_nsmulₓ'. -/\n@[simp]\ntheorem dedup_nsmul {s : Multiset α} {n : ℕ} (h0 : n ≠ 0) : (n • s).dedup = s.dedup :=\n  by\n  ext a\n  by_cases h : a ∈ s <;> simp [h, h0]\n#align multiset.dedup_nsmul Multiset.dedup_nsmul\n\n/- warning: multiset.nodup.le_dedup_iff_le -> Multiset.Nodup.le_dedup_iff_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α} {t : Multiset.{u1} α}, (Multiset.Nodup.{u1} α s) -> (Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) s (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t)) (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) s t))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Multiset.{u1} α} {t : Multiset.{u1} α}, (Multiset.Nodup.{u1} α s) -> (Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) s (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) t)) (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) s t))\nCase conversion may be inaccurate. Consider using '#align multiset.nodup.le_dedup_iff_le Multiset.Nodup.le_dedup_iff_leₓ'. -/\ntheorem Nodup.le_dedup_iff_le {s t : Multiset α} (hno : s.Nodup) : s ≤ t.dedup ↔ s ≤ t := by\n  simp [le_dedup, hno]\n#align multiset.nodup.le_dedup_iff_le Multiset.Nodup.le_dedup_iff_le\n\nend Multiset\n\n/- warning: multiset.nodup.le_nsmul_iff_le -> Multiset.Nodup.le_nsmul_iff_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Multiset.{u1} α} {t : Multiset.{u1} α} {n : Nat}, (Multiset.Nodup.{u1} α s) -> (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) s (SMul.smul.{0, u1} Nat (Multiset.{u1} α) (AddMonoid.SMul.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) n t)) (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α))) s t))\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Multiset.{u1} α} {t : Multiset.{u1} α} {n : Nat}, (Multiset.Nodup.{u1} α s) -> (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) s (HSMul.hSMul.{0, u1, u1} Nat (Multiset.{u1} α) (Multiset.{u1} α) (instHSMul.{0, u1} Nat (Multiset.{u1} α) (AddMonoid.SMul.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) n t)) (LE.le.{u1} (Multiset.{u1} α) (Preorder.toLE.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α))) s t))\nCase conversion may be inaccurate. Consider using '#align multiset.nodup.le_nsmul_iff_le Multiset.Nodup.le_nsmul_iff_leₓ'. -/\ntheorem Multiset.Nodup.le_nsmul_iff_le {α : Type _} {s t : Multiset α} {n : ℕ} (h : s.Nodup)\n    (hn : n ≠ 0) : s ≤ n • t ↔ s ≤ t := by\n  classical\n    rw [← h.le_dedup_iff_le, Iff.comm, ← h.le_dedup_iff_le]\n    simp [hn]\n#align multiset.nodup.le_nsmul_iff_le Multiset.Nodup.le_nsmul_iff_le\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Multiset/Dedup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.47617856154650484}}
{"text": "/-\nCopyright (c) 2018 Andreas Swerdlow. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andreas Swerdlow\n\n! This file was ported from Lean 3 source module deprecated.subfield\n! leanprover-community/mathlib commit bd9851ca476957ea4549eb19b40e7b5ade9428cc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Deprecated.Subring\n\n/-!\n# Unbundled subfields (deprecated)\n\nThis file is deprecated, and is no longer imported by anything in mathlib other than other\ndeprecated files, and test files. You should not need to import it.\n\nThis file defines predicates for unbundled subfields. Instead of using this file, please use\n`Subfield`, defined in `FieldTheory.Subfield`, for subfields of fields.\n\n## Main definitions\n\n`IsSubfield (S : Set F) : Prop` : the predicate that `S` is the underlying set of a subfield\nof the field `F`. The bundled variant `Subfield F` should be used in preference to this.\n\n## Tags\n\nis_subfield\n-/\n\n\nvariable {F : Type _} [Field F] (S : Set F)\n\n/-- `IsSubfield (S : Set F)` is the predicate saying that a given subset of a field is\nthe set underlying a subfield. This structure is deprecated; use the bundled variant\n`Subfield F` to model subfields of a field. -/\nstructure IsSubfield extends IsSubring S : Prop where\n  inv_mem : ∀ {x : F}, x ∈ S → x⁻¹ ∈ S\n#align is_subfield IsSubfield\n\ntheorem IsSubfield.div_mem {S : Set F} (hS : IsSubfield S) {x y : F} (hx : x ∈ S) (hy : y ∈ S) :\n    x / y ∈ S := by\n  rw [div_eq_mul_inv]\n  exact hS.toIsSubring.toIsSubmonoid.mul_mem hx (hS.inv_mem hy)\n#align is_subfield.div_mem IsSubfield.div_mem\n\ntheorem IsSubfield.pow_mem {a : F} {n : ℤ} {s : Set F} (hs : IsSubfield s) (h : a ∈ s) :\n    a ^ n ∈ s := by\n  cases' n with n n\n  · suffices a ^ (n : ℤ) ∈ s by exact this\n    rw [zpow_ofNat]\n    exact hs.toIsSubring.toIsSubmonoid.pow_mem h\n  · rw [zpow_negSucc]\n    exact hs.inv_mem (hs.toIsSubring.toIsSubmonoid.pow_mem h)\n#align is_subfield.pow_mem IsSubfield.pow_mem\n\ntheorem Univ.isSubfield : IsSubfield (@Set.univ F) :=\n  { Univ.isSubmonoid, IsAddSubgroup.univ_addSubgroup with\n    inv_mem := fun _ ↦ trivial }\n#align univ.is_subfield Univ.isSubfield\n\ntheorem Preimage.isSubfield {K : Type _} [Field K] (f : F →+* K) {s : Set K} (hs : IsSubfield s) :\n    IsSubfield (f ⁻¹' s) :=\n  { f.isSubring_preimage hs.toIsSubring with\n    inv_mem := fun {a} (ha : f a ∈ s) ↦ show f a⁻¹ ∈ s by\n      rw [map_inv₀]\n      exact hs.inv_mem ha }\n#align preimage.is_subfield Preimage.isSubfield\n\ntheorem Image.isSubfield {K : Type _} [Field K] (f : F →+* K) {s : Set F} (hs : IsSubfield s) :\n    IsSubfield (f '' s) :=\n  { f.isSubring_image hs.toIsSubring with\n    inv_mem := fun ⟨x, xmem, ha⟩ ↦ ⟨x⁻¹, hs.inv_mem xmem, ha ▸ map_inv₀ f x⟩ }\n#align image.is_subfield Image.isSubfield\n\ntheorem Range.isSubfield {K : Type _} [Field K] (f : F →+* K) : IsSubfield (Set.range f) := by\n  rw [← Set.image_univ]\n  apply Image.isSubfield _ Univ.isSubfield\n#align range.is_subfield Range.isSubfield\n\nnamespace Field\n\n/-- `Field.closure s` is the minimal subfield that includes `s`. -/\ndef closure : Set F :=\n  { x | ∃ y ∈ Ring.closure S, ∃ z ∈ Ring.closure S, y / z = x }\n#align field.closure Field.closure\n\nvariable {S}\n\ntheorem ring_closure_subset : Ring.closure S ⊆ closure S :=\n  fun x hx ↦ ⟨x, hx, 1, Ring.closure.isSubring.toIsSubmonoid.one_mem, div_one x⟩\n#align field.ring_closure_subset Field.ring_closure_subset\n\ntheorem closure.isSubmonoid : IsSubmonoid (closure S) :=\n  { mul_mem := by\n      rintro _ _ ⟨p, hp, q, hq, hq0, rfl⟩ ⟨r, hr, s, hs, hs0, rfl⟩\n      exact ⟨p * r, IsSubmonoid.mul_mem Ring.closure.isSubring.toIsSubmonoid hp hr, q * s,\n        IsSubmonoid.mul_mem Ring.closure.isSubring.toIsSubmonoid hq hs,\n        (div_mul_div_comm _ _ _ _).symm⟩\n    one_mem := ring_closure_subset <| IsSubmonoid.one_mem Ring.closure.isSubring.toIsSubmonoid }\n#align field.closure.is_submonoid Field.closure.isSubmonoid\n\ntheorem closure.isSubfield : IsSubfield (closure S) :=\n  { closure.isSubmonoid with\n    add_mem := by\n      intro a b ha hb\n      rcases id ha with ⟨p, hp, q, hq, rfl⟩\n      rcases id hb with ⟨r, hr, s, hs, rfl⟩\n      by_cases hq0 : q = 0\n      · rwa [hq0, div_zero, zero_add]\n      by_cases hs0 : s = 0\n      · rwa [hs0, div_zero, add_zero]\n      exact ⟨p * s + q * r,\n        IsAddSubmonoid.add_mem Ring.closure.isSubring.toIsAddSubgroup.toIsAddSubmonoid\n          (Ring.closure.isSubring.toIsSubmonoid.mul_mem hp hs)\n          (Ring.closure.isSubring.toIsSubmonoid.mul_mem hq hr),\n        q * s, Ring.closure.isSubring.toIsSubmonoid.mul_mem hq hs, (div_add_div p r hq0 hs0).symm⟩\n    zero_mem := ring_closure_subset Ring.closure.isSubring.toIsAddSubgroup.toIsAddSubmonoid.zero_mem\n    neg_mem := by\n      rintro _ ⟨p, hp, q, hq, rfl⟩\n      exact ⟨-p, Ring.closure.isSubring.toIsAddSubgroup.neg_mem hp, q, hq, neg_div q p⟩\n    inv_mem := by\n      rintro _ ⟨p, hp, q, hq, rfl⟩\n      exact ⟨q, hq, p, hp, (inv_div _ _).symm⟩ }\n#align field.closure.is_subfield Field.closure.isSubfield\n\ntheorem mem_closure {a : F} (ha : a ∈ S) : a ∈ closure S :=\n  ring_closure_subset <| Ring.mem_closure ha\n#align field.mem_closure Field.mem_closure\n\ntheorem subset_closure : S ⊆ closure S :=\n  fun _ ↦ mem_closure\n#align field.subset_closure Field.subset_closure\n\ntheorem closure_subset {T : Set F} (hT : IsSubfield T) (H : S ⊆ T) : closure S ⊆ T := by\n  rintro _ ⟨p, hp, q, hq, hq0, rfl⟩\n  exact hT.div_mem (Ring.closure_subset hT.toIsSubring H hp)\n    (Ring.closure_subset hT.toIsSubring H hq)\n#align field.closure_subset Field.closure_subset\n\ntheorem closure_subset_iff {s t : Set F} (ht : IsSubfield t) : closure s ⊆ t ↔ s ⊆ t :=\n  ⟨Set.Subset.trans subset_closure, closure_subset ht⟩\n#align field.closure_subset_iff Field.closure_subset_iff\n\ntheorem closure_mono {s t : Set F} (H : s ⊆ t) : closure s ⊆ closure t :=\n  closure_subset closure.isSubfield <| Set.Subset.trans H subset_closure\n#align field.closure_mono Field.closure_mono\n\nend Field\n\ntheorem isSubfield_unionᵢ_of_directed {ι : Type _} [Nonempty ι] {s : ι → Set F}\n    (hs : ∀ i, IsSubfield (s i)) (directed : ∀ i j, ∃ k, s i ⊆ s k ∧ s j ⊆ s k) :\n    IsSubfield (⋃ i, s i) :=\n  { inv_mem := fun hx ↦\n      let ⟨i, hi⟩ := Set.mem_unionᵢ.1 hx\n      Set.mem_unionᵢ.2 ⟨i, (hs i).inv_mem hi⟩\n    toIsSubring := isSubring_unionᵢ_of_directed (fun i ↦ (hs i).toIsSubring) directed }\n#align is_subfield_Union_of_directed isSubfield_unionᵢ_of_directed\n\ntheorem IsSubfield.inter {S₁ S₂ : Set F} (hS₁ : IsSubfield S₁) (hS₂ : IsSubfield S₂) :\n    IsSubfield (S₁ ∩ S₂) :=\n  { IsSubring.inter hS₁.toIsSubring hS₂.toIsSubring with\n    inv_mem := fun hx ↦ ⟨hS₁.inv_mem hx.1, hS₂.inv_mem hx.2⟩ }\n#align is_subfield.inter IsSubfield.inter\n\ntheorem IsSubfield.interᵢ {ι : Sort _} {S : ι → Set F} (h : ∀ y : ι, IsSubfield (S y)) :\n    IsSubfield (Set.interᵢ S) :=\n  { IsSubring.interᵢ fun y ↦ (h y).toIsSubring with\n    inv_mem := fun hx ↦ Set.mem_interᵢ.2 fun y ↦ (h y).inv_mem <| Set.mem_interᵢ.1 hx y }\n#align is_subfield.Inter IsSubfield.interᵢ\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Deprecated/Subfield.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.835483553488848, "lm_q2_score": 0.5698526514141572, "lm_q1q2_score": 0.4761025181685418}}
{"text": "import field_theory.algebraic_closure\nimport data.zmod.basic\nimport Rings.ToMathlib.char_p\n\nnamespace ulift.equiv\n\nvariables {k : Type*} [field k]\n\nopen ulift\n\ndef zero : ulift k := up 0\n\nlemma zero_add (a : ulift k) :\n  up (down (up 0) + down a) = a :=\nbegin\n  rw ← up_down a,\n  apply congr_arg up,\n  simp only [down_up, zero_add],\nend\n\nlemma add_zero (a : ulift k) :\n  up (down a + down (up 0)) = a :=\nbegin\n  rw ← up_down a,\n  apply congr_arg up,\n  simp only [down_up, add_zero],\nend\n\nlemma add_comm (a b : ulift k) :\n  up (down a + down b) = up (down b + down a) :=\ncongr_arg up (add_comm _ _)\n\nlemma add_assoc (a b c : ulift k) :\n  up (down (up (down a + down b)) + down c) =\n  up (down a + down (up (down b + down c))) :=\nbegin\n  apply congr_arg up,\n  simp only [down_up, add_assoc],\nend\n\nlemma add_left_neg (a : ulift k) :\n  up (down (up (- down a)) + down a) = up 0 :=\nbegin\n  apply congr_arg up,\n  simp only [down_up, add_left_neg],\nend\n\nlemma mul_one (a : ulift k) :\n  up (down a * down (up 1)) = a :=\nbegin\n  rw ← up_down a,\n  apply congr_arg up,\n  simp only [down_up, mul_one],\nend\n\nlemma one_mul (a : ulift k) :\n  up (down (up 1) * down a) = a :=\nbegin\n  rw ← up_down a,\n  apply congr_arg up,\n  simp only [down_up, one_mul],\nend\n\nlemma mul_comm (a b : ulift k) :\n  up (down a * down b) = up (down b * down a) :=\ncongr_arg up (mul_comm _ _)\n\nlemma mul_assoc (a b c : ulift k) :\n  up (down (up (down a * down b)) * down c) =\n  up (down a * down (up (down b * down c))) :=\nbegin\n  apply congr_arg up,\n  simp only [down_up, mul_assoc],\nend\n\nlemma left_distrib (a b c : ulift k) :\n  down a * (down b + down c)\n  = down a * down b + down a * down c :=\nbegin\n  sorry\nend\n\n\ndef field [field k] : field (ulift k) :=\nequiv.field (equiv.ulift)\n\n-- { zero             := up 0,\n--   add              := λ a b, up (down a + down b),\n--   neg              := λ a, up (- down a),\n--   one              := up 1,\n--   mul              := λ a b, up (down a * down b),\n--   inv              := λ a, up ((down a)⁻¹),\n--   zero_add         := zero_add,\n--   add_zero         := add_zero,\n--   add_comm         := add_comm,\n--   add_assoc        := add_assoc,\n--   add_left_neg     := add_left_neg,\n--   mul_one          := mul_one,\n--   one_mul          := one_mul,\n--   mul_comm         := mul_comm,\n--   mul_assoc        := mul_assoc,\n--   left_distrib     := sorry,\n--   right_distrib    := sorry,\n--   exists_pair_ne   := sorry,\n--   mul_inv_cancel   := sorry,\n--   inv_zero         := sorry }\n\nend ulift\n\nnamespace is_alg_closed\n\nopen polynomial\n\nlemma of_exists_root_nat_degree {k : Type*} [field k] (H : ∀ p : polynomial k, p.monic → irreducible p → nat_degree p ≠ 0 → ∃ x, p.eval x = 0) :\n  is_alg_closed k :=\nbegin\n  apply of_exists_root,\n  intros p hmonic hirr,\n  by_cases hdeg : nat_degree p = 0,\n  {\n    rw monic.degree_eq_zero_iff_eq_one hmonic at hdeg,\n    rw hdeg at hirr,\n    exfalso,\n    apply hirr.1,\n    exact ⟨ 1 , rfl ⟩,\n  },\n  apply H p hmonic hirr hdeg,\nend\n\nlemma of_nat_degree_ne_zero_exists_root {k : Type*} [field k]\n  (H : ∀ p : polynomial k, nat_degree p ≠ 0 → ∃ x, p.eval x = 0) :\n  is_alg_closed k :=\nof_exists_root_nat_degree $ λ _ _ hdeg, H _\n\nend is_alg_closed\n\nnamespace algebraic_closure\n\nsection zmod\n\nvariables (p : ℕ) [hp : fact (nat.prime p)]\n\ninclude hp\n\n@[reducible] def of_zmod := algebraic_closure (zmod p)\n\n-- noncomputable lemma of_zmod.field : field (of_zmod p) :=\n-- by apply_instance\n\n-- noncomputable lemma of_zmod_algebra : (zmod p) →+* (of_zmod p) :=\n-- algebra_map _ _\n\nlemma of_zmod.char_p :\n  char_p (of_zmod p) p :=\n(ring_hom.char_p_iff_char_p (algebra_map (zmod p) (of_zmod p)) p).1 $ zmod.char_p p\n\n\n@[reducible] def ulift_of_zmod : Type* := ulift (of_zmod p)\n\nend zmod\n\nend algebraic_closure\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/algebraic_closure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.47610007977544216}}
{"text": "/-\nCopyright (c) 2014 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.nat.cast.basic\n! leanprover-community/mathlib commit acebd8d49928f6ed8920e502a6c90674e75bd441\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.CharZero.Defs\nimport Mathbin.Algebra.GroupWithZero.Commute\nimport Mathbin.Algebra.Hom.Ring\nimport Mathbin.Algebra.Order.Group.Abs\nimport Mathbin.Algebra.Ring.Commute\nimport Mathbin.Data.Nat.Order.Basic\nimport Mathbin.Algebra.Group.Opposite\n\n/-!\n# Cast of natural numbers (additional theorems)\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves additional properties about the *canonical* homomorphism from\nthe natural numbers into an additive monoid with a one (`nat.cast`).\n\n## Main declarations\n\n* `cast_add_monoid_hom`: `cast` bundled as an `add_monoid_hom`.\n* `cast_ring_hom`: `cast` bundled as a `ring_hom`.\n-/\n\n\nvariable {α β : Type _}\n\nnamespace Nat\n\n#print Nat.castAddMonoidHom /-\n/-- `coe : ℕ → α` as an `add_monoid_hom`. -/\ndef castAddMonoidHom (α : Type _) [AddMonoidWithOne α] : ℕ →+ α\n    where\n  toFun := coe\n  map_add' := cast_add\n  map_zero' := cast_zero\n#align nat.cast_add_monoid_hom Nat.castAddMonoidHom\n-/\n\n/- warning: nat.coe_cast_add_monoid_hom -> Nat.coe_castAddMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : AddMonoidWithOne.{u1} α], Eq.{succ u1} ((fun (_x : AddMonoidHom.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) => Nat -> α) (Nat.castAddMonoidHom.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) (fun (_x : AddMonoidHom.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) => Nat -> α) (AddMonoidHom.hasCoeToFun.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) (Nat.castAddMonoidHom.{u1} α _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α _inst_1)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : AddMonoidWithOne.{u1} α], Eq.{succ u1} (forall (a : Nat), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => α) a) (FunLike.coe.{succ u1, 1, succ u1} (AddMonoidHom.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => α) _x) (AddHomClass.toFunLike.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) Nat α (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toAdd.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) (AddMonoidHomClass.toAddHomClass.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))) Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1)) (AddMonoidHom.addMonoidHomClass.{0, u1} Nat α (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α _inst_1))))) (Nat.castAddMonoidHom.{u1} α _inst_1)) (Nat.cast.{u1} α (AddMonoidWithOne.toNatCast.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align nat.coe_cast_add_monoid_hom Nat.coe_castAddMonoidHomₓ'. -/\n@[simp]\ntheorem coe_castAddMonoidHom [AddMonoidWithOne α] : (castAddMonoidHom α : ℕ → α) = coe :=\n  rfl\n#align nat.coe_cast_add_monoid_hom Nat.coe_castAddMonoidHom\n\n/- warning: nat.cast_mul -> Nat.cast_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (m : Nat) (n : Nat), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) m n)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))) m) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))) n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (m : Nat) (n : Nat), Eq.{succ u1} α (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) m n)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1) m) (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align nat.cast_mul Nat.cast_mulₓ'. -/\n@[simp, norm_cast]\ntheorem cast_mul [NonAssocSemiring α] (m n : ℕ) : ((m * n : ℕ) : α) = m * n := by\n  induction n <;> simp [mul_succ, mul_add, *]\n#align nat.cast_mul Nat.cast_mul\n\n#print Nat.castRingHom /-\n/-- `coe : ℕ → α` as a `ring_hom` -/\ndef castRingHom (α : Type _) [NonAssocSemiring α] : ℕ →+* α :=\n  { castAddMonoidHom α with\n    toFun := coe\n    map_one' := cast_one\n    map_mul' := cast_mul }\n#align nat.cast_ring_hom Nat.castRingHom\n-/\n\n/- warning: nat.coe_cast_ring_hom -> Nat.coe_castRingHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α], Eq.{succ u1} ((fun (_x : RingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) => Nat -> α) (Nat.castRingHom.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (RingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) (fun (_x : RingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) => Nat -> α) (RingHom.hasCoeToFun.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) (Nat.castRingHom.{u1} α _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α], Eq.{succ u1} (forall (a : Nat), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Nat) => α) a) (FunLike.coe.{succ u1, 1, succ u1} (RingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Nat) => α) _x) (MulHomClass.toFunLike.{u1, 0, u1} (RingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat α (NonUnitalNonAssocSemiring.toMul.{0} Nat (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring))) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (NonUnitalRingHomClass.toMulHomClass.{u1, 0, u1} (RingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1) (RingHomClass.toNonUnitalRingHomClass.{u1, 0, u1} (RingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1 (RingHom.instRingHomClassRingHom.{0, u1} Nat α (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1)))) (Nat.castRingHom.{u1} α _inst_1)) (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align nat.coe_cast_ring_hom Nat.coe_castRingHomₓ'. -/\n@[simp]\ntheorem coe_castRingHom [NonAssocSemiring α] : (castRingHom α : ℕ → α) = coe :=\n  rfl\n#align nat.coe_cast_ring_hom Nat.coe_castRingHom\n\n/- warning: nat.cast_commute -> Nat.cast_commute is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (n : Nat) (x : α), Commute.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))) n) x\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (n : Nat) (x : α), Commute.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1) n) x\nCase conversion may be inaccurate. Consider using '#align nat.cast_commute Nat.cast_commuteₓ'. -/\ntheorem cast_commute [NonAssocSemiring α] (n : ℕ) (x : α) : Commute (↑n) x :=\n  Nat.recOn n (by rw [cast_zero] <;> exact Commute.zero_left x) fun n ihn => by\n    rw [cast_succ] <;> exact ihn.add_left (Commute.one_left x)\n#align nat.cast_commute Nat.cast_commute\n\n/- warning: nat.cast_comm -> Nat.cast_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (n : Nat) (x : α), Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))) n) x) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)))) x ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))) n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (n : Nat) (x : α), Eq.{succ u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1) n) x) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) x (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align nat.cast_comm Nat.cast_commₓ'. -/\ntheorem cast_comm [NonAssocSemiring α] (n : ℕ) (x : α) : (n : α) * x = x * n :=\n  (cast_commute n x).Eq\n#align nat.cast_comm Nat.cast_comm\n\n/- warning: nat.commute_cast -> Nat.commute_cast is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (x : α) (n : Nat), Commute.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) x ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))) n)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] (x : α) (n : Nat), Commute.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) x (Nat.cast.{u1} α (NonAssocSemiring.toNatCast.{u1} α _inst_1) n)\nCase conversion may be inaccurate. Consider using '#align nat.commute_cast Nat.commute_castₓ'. -/\ntheorem commute_cast [NonAssocSemiring α] (x : α) (n : ℕ) : Commute x n :=\n  (n.cast_commute x).symm\n#align nat.commute_cast Nat.commute_cast\n\nsection OrderedSemiring\n\nvariable [OrderedSemiring α]\n\n#print Nat.mono_cast /-\n@[mono]\ntheorem mono_cast : Monotone (coe : ℕ → α) :=\n  monotone_nat_of_le_succ fun n => by\n    rw [Nat.cast_succ] <;> exact le_add_of_nonneg_right zero_le_one\n#align nat.mono_cast Nat.mono_cast\n-/\n\n/- warning: nat.cast_nonneg -> Nat.cast_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} α] (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α _inst_1)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))))) n)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} α] (n : Nat), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedSemiring.toPartialOrder.{u1} α _inst_1))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1))))) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)) n)\nCase conversion may be inaccurate. Consider using '#align nat.cast_nonneg Nat.cast_nonnegₓ'. -/\n@[simp]\ntheorem cast_nonneg (n : ℕ) : 0 ≤ (n : α) :=\n  @Nat.cast_zero α _ ▸ mono_cast (Nat.zero_le n)\n#align nat.cast_nonneg Nat.cast_nonneg\n\nsection Nontrivial\n\nvariable [Nontrivial α]\n\n/- warning: nat.cast_add_one_pos -> Nat.cast_add_one_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} α] [_inst_2 : Nontrivial.{u1} α] (n : Nat), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α _inst_1)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))))) n) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} α] [_inst_2 : Nontrivial.{u1} α] (n : Nat), LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedSemiring.toPartialOrder.{u1} α _inst_1))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1))))) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)) n) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (Semiring.toOne.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align nat.cast_add_one_pos Nat.cast_add_one_posₓ'. -/\ntheorem cast_add_one_pos (n : ℕ) : 0 < (n : α) + 1 :=\n  zero_lt_one.trans_le <| le_add_of_nonneg_left n.cast_nonneg\n#align nat.cast_add_one_pos Nat.cast_add_one_pos\n\n/- warning: nat.cast_pos -> Nat.cast_pos is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} α] [_inst_2 : Nontrivial.{u1} α] {n : Nat}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α _inst_1)))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)))))))) n)) (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} α] [_inst_2 : Nontrivial.{u1} α] {n : Nat}, Iff (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedSemiring.toPartialOrder.{u1} α _inst_1))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1))))) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (OrderedSemiring.toSemiring.{u1} α _inst_1)) n)) (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n)\nCase conversion may be inaccurate. Consider using '#align nat.cast_pos Nat.cast_posₓ'. -/\n@[simp]\ntheorem cast_pos {n : ℕ} : (0 : α) < n ↔ 0 < n := by cases n <;> simp [cast_add_one_pos]\n#align nat.cast_pos Nat.cast_pos\n\nend Nontrivial\n\nvariable [CharZero α] {m n : ℕ}\n\n#print Nat.strictMono_cast /-\ntheorem strictMono_cast : StrictMono (coe : ℕ → α) :=\n  mono_cast.strictMono_of_injective cast_injective\n#align nat.strict_mono_cast Nat.strictMono_cast\n-/\n\n#print Nat.castOrderEmbedding /-\n/-- `coe : ℕ → α` as an `order_embedding` -/\n@[simps (config := { fullyApplied := false })]\ndef castOrderEmbedding : ℕ ↪o α :=\n  OrderEmbedding.ofStrictMono coe Nat.strictMono_cast\n#align nat.cast_order_embedding Nat.castOrderEmbedding\n-/\n\n#print Nat.cast_le /-\n@[simp, norm_cast]\ntheorem cast_le : (m : α) ≤ n ↔ m ≤ n :=\n  strictMono_cast.le_iff_le\n#align nat.cast_le Nat.cast_le\n-/\n\n#print Nat.cast_lt /-\n@[simp, norm_cast, mono]\ntheorem cast_lt : (m : α) < n ↔ m < n :=\n  strictMono_cast.lt_iff_lt\n#align nat.cast_lt Nat.cast_lt\n-/\n\n#print Nat.one_lt_cast /-\n@[simp, norm_cast]\ntheorem one_lt_cast : 1 < (n : α) ↔ 1 < n := by rw [← cast_one, cast_lt]\n#align nat.one_lt_cast Nat.one_lt_cast\n-/\n\n#print Nat.one_le_cast /-\n@[simp, norm_cast]\ntheorem one_le_cast : 1 ≤ (n : α) ↔ 1 ≤ n := by rw [← cast_one, cast_le]\n#align nat.one_le_cast Nat.one_le_cast\n-/\n\n#print Nat.cast_lt_one /-\n@[simp, norm_cast]\ntheorem cast_lt_one : (n : α) < 1 ↔ n = 0 := by\n  rw [← cast_one, cast_lt, lt_succ_iff, ← bot_eq_zero, le_bot_iff]\n#align nat.cast_lt_one Nat.cast_lt_one\n-/\n\n#print Nat.cast_le_one /-\n@[simp, norm_cast]\ntheorem cast_le_one : (n : α) ≤ 1 ↔ n ≤ 1 := by rw [← cast_one, cast_le]\n#align nat.cast_le_one Nat.cast_le_one\n-/\n\nend OrderedSemiring\n\n/- warning: nat.cast_tsub -> Nat.cast_tsub is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1)))))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1))))))) _inst_2] [_inst_4 : ContravariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1))))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1)))))))] (m : Nat) (n : Nat), Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1)))))))))) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) m n)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1)))))))))) m) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1)))))))))) n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedSemiring.toPartialOrder.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1))))) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1))))))) _inst_2] [_inst_4 : ContravariantClass.{u1, u1} α α (fun (x._@.Mathlib.Data.Nat.Cast.Basic._hyg.923 : α) (x._@.Mathlib.Data.Nat.Cast.Basic._hyg.925 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (OrderedSemiring.toSemiring.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1)))))))) x._@.Mathlib.Data.Nat.Cast.Basic._hyg.923 x._@.Mathlib.Data.Nat.Cast.Basic._hyg.925) (fun (x._@.Mathlib.Data.Nat.Cast.Basic._hyg.938 : α) (x._@.Mathlib.Data.Nat.Cast.Basic._hyg.940 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedSemiring.toPartialOrder.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} α _inst_1))))) x._@.Mathlib.Data.Nat.Cast.Basic._hyg.938 x._@.Mathlib.Data.Nat.Cast.Basic._hyg.940)] (m : Nat) (n : Nat), Eq.{succ u1} α (Nat.cast.{u1} α (CanonicallyOrderedCommSemiring.toNatCast.{u1} α _inst_1) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) m n)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) (Nat.cast.{u1} α (CanonicallyOrderedCommSemiring.toNatCast.{u1} α _inst_1) m) (Nat.cast.{u1} α (CanonicallyOrderedCommSemiring.toNatCast.{u1} α _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align nat.cast_tsub Nat.cast_tsubₓ'. -/\n/-- A version of `nat.cast_sub` that works for `ℝ≥0` and `ℚ≥0`. Note that this proof doesn't work\nfor `ℕ∞` and `ℝ≥0∞`, so we use type-specific lemmas for these types. -/\n@[simp, norm_cast]\ntheorem cast_tsub [CanonicallyOrderedCommSemiring α] [Sub α] [OrderedSub α]\n    [ContravariantClass α α (· + ·) (· ≤ ·)] (m n : ℕ) : ↑(m - n) = (m - n : α) :=\n  by\n  cases' le_total m n with h h\n  · rw [tsub_eq_zero_of_le h, cast_zero, tsub_eq_zero_of_le]\n    exact mono_cast h\n  · rcases le_iff_exists_add'.mp h with ⟨m, rfl⟩\n    rw [add_tsub_cancel_right, cast_add, add_tsub_cancel_right]\n#align nat.cast_tsub Nat.cast_tsub\n\n/- warning: nat.cast_min -> Nat.cast_min is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} α] {a : Nat} {b : Nat}, Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))))))))) (LinearOrder.min.{0} Nat Nat.linearOrder a b)) (LinearOrder.min.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))))))))) a) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))))))))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} α] {a : Nat} {b : Nat}, Eq.{succ u1} α (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))) (Min.min.{0} Nat instMinNat a b)) (Min.min.{u1} α (LinearOrderedSemiring.toMin.{u1} α _inst_1) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))) a) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))) b))\nCase conversion may be inaccurate. Consider using '#align nat.cast_min Nat.cast_minₓ'. -/\n@[simp, norm_cast]\ntheorem cast_min [LinearOrderedSemiring α] {a b : ℕ} : (↑(min a b) : α) = min a b :=\n  (@mono_cast α _).map_min\n#align nat.cast_min Nat.cast_min\n\n/- warning: nat.cast_max -> Nat.cast_max is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} α] {a : Nat} {b : Nat}, Eq.{succ u1} α ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))))))))) (LinearOrder.max.{0} Nat Nat.linearOrder a b)) (LinearOrder.max.{u1} α (LinearOrderedAddCommMonoid.toLinearOrder.{u1} α (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} α _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))))))))) a) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))))))))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} α] {a : Nat} {b : Nat}, Eq.{succ u1} α (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))) (Max.max.{0} Nat Nat.instMaxNat a b)) (Max.max.{u1} α (LinearOrderedSemiring.toMax.{u1} α _inst_1) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))) a) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α _inst_1))) b))\nCase conversion may be inaccurate. Consider using '#align nat.cast_max Nat.cast_maxₓ'. -/\n@[simp, norm_cast]\ntheorem cast_max [LinearOrderedSemiring α] {a b : ℕ} : (↑(max a b) : α) = max a b :=\n  (@mono_cast α _).map_max\n#align nat.cast_max Nat.cast_max\n\n/- warning: nat.abs_cast -> Nat.abs_cast is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} α] (a : Nat), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α _inst_1))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α _inst_1))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α _inst_1))))))))) a)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α _inst_1))))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} α] (a : Nat), Eq.{succ u1} α (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α _inst_1))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α _inst_1)))))) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α _inst_1)))) a)) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α _inst_1)))) a)\nCase conversion may be inaccurate. Consider using '#align nat.abs_cast Nat.abs_castₓ'. -/\n@[simp, norm_cast]\ntheorem abs_cast [LinearOrderedRing α] (a : ℕ) : |(a : α)| = a :=\n  abs_of_nonneg (cast_nonneg a)\n#align nat.abs_cast Nat.abs_cast\n\n#print Nat.coe_nat_dvd /-\ntheorem coe_nat_dvd [Semiring α] {m n : ℕ} (h : m ∣ n) : (m : α) ∣ (n : α) :=\n  map_dvd (Nat.castRingHom α) h\n#align nat.coe_nat_dvd Nat.coe_nat_dvd\n-/\n\nalias coe_nat_dvd ← _root_.has_dvd.dvd.nat_cast\n#align has_dvd.dvd.nat_cast Dvd.Dvd.nat_cast\n\nend Nat\n\nsection AddMonoidHomClass\n\nvariable {A B F : Type _} [AddMonoidWithOne B]\n\n/- warning: ext_nat' -> ext_nat' is a dubious translation:\nlean 3 declaration is\n  forall {A : Type.{u1}} {F : Type.{u2}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : AddMonoidHomClass.{u2, 0, u1} F Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)] (f : F) (g : F), (Eq.{succ u1} A (coeFn.{succ u2, succ u1} F (fun (_x : F) => Nat -> A) (FunLike.hasCoeToFun.{succ u2, 1, succ u1} F Nat (fun (_x : Nat) => A) (AddHomClass.toFunLike.{u2, 0, u1} F Nat A (AddZeroClass.toHasAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toHasAdd.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddMonoidHomClass.toAddHomClass.{u2, 0, u1} F Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2) _inst_3))) f (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (coeFn.{succ u2, succ u1} F (fun (_x : F) => Nat -> A) (FunLike.hasCoeToFun.{succ u2, 1, succ u1} F Nat (fun (_x : Nat) => A) (AddHomClass.toFunLike.{u2, 0, u1} F Nat A (AddZeroClass.toHasAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toHasAdd.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddMonoidHomClass.toAddHomClass.{u2, 0, u1} F Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2) _inst_3))) g (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> (Eq.{succ u2} F f g)\nbut is expected to have type\n  forall {A : Type.{u2}} {F : Type.{u1}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : AddMonoidHomClass.{u1, 0, u2} F Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u2} A _inst_2)] (f : F) (g : F), (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => A) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (FunLike.coe.{succ u1, 1, succ u2} F Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => A) _x) (AddHomClass.toFunLike.{u1, 0, u2} F Nat A (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddMonoidHomClass.toAddHomClass.{u1, 0, u2} F Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u2} A _inst_2) _inst_3)) f (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (FunLike.coe.{succ u1, 1, succ u2} F Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => A) _x) (AddHomClass.toFunLike.{u1, 0, u2} F Nat A (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddMonoidHomClass.toAddHomClass.{u1, 0, u2} F Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u2} A _inst_2) _inst_3)) g (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> (Eq.{succ u1} F f g)\nCase conversion may be inaccurate. Consider using '#align ext_nat' ext_nat'ₓ'. -/\ntheorem ext_nat' [AddMonoid A] [AddMonoidHomClass F ℕ A] (f g : F) (h : f 1 = g 1) : f = g :=\n  FunLike.ext f g <| by\n    apply Nat.rec\n    · simp only [Nat.zero_eq, map_zero]\n    simp (config := { contextual := true }) [Nat.succ_eq_add_one, h]\n#align ext_nat' ext_nat'\n\n/- warning: add_monoid_hom.ext_nat -> AddMonoidHom.ext_nat is a dubious translation:\nlean 3 declaration is\n  forall {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] {f : AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)} {g : AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)}, (Eq.{succ u1} A (coeFn.{succ u1, succ u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (fun (_x : AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) => Nat -> A) (AddMonoidHom.hasCoeToFun.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) f (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (coeFn.{succ u1, succ u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (fun (_x : AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) => Nat -> A) (AddMonoidHom.hasCoeToFun.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) g (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) -> (Eq.{succ u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) f g)\nbut is expected to have type\n  forall {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] {f : AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)} {g : AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)}, (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => A) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (FunLike.coe.{succ u1, 1, succ u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => A) _x) (AddHomClass.toFunLike.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) Nat A (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toAdd.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddMonoidHomClass.toAddHomClass.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2) (AddMonoidHom.addMonoidHomClass.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)))) f (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (FunLike.coe.{succ u1, 1, succ u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => A) _x) (AddHomClass.toFunLike.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) Nat A (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toAdd.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddMonoidHomClass.toAddHomClass.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2) (AddMonoidHom.addMonoidHomClass.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)))) g (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) -> (Eq.{succ u1} (AddMonoidHom.{0, u1} Nat A (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} A _inst_2)) f g)\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.ext_nat AddMonoidHom.ext_natₓ'. -/\n@[ext]\ntheorem AddMonoidHom.ext_nat [AddMonoid A] : ∀ {f g : ℕ →+ A}, ∀ h : f 1 = g 1, f = g :=\n  ext_nat'\n#align add_monoid_hom.ext_nat AddMonoidHom.ext_nat\n\nvariable [AddMonoidWithOne A]\n\n#print eq_natCast' /-\n-- these versions are primed so that the `ring_hom_class` versions aren't\ntheorem eq_natCast' [AddMonoidHomClass F ℕ A] (f : F) (h1 : f 1 = 1) : ∀ n : ℕ, f n = n\n  | 0 => by simp\n  | n + 1 => by rw [map_add, h1, eq_natCast' n, Nat.cast_add_one]\n#align eq_nat_cast' eq_natCast'\n-/\n\n#print map_natCast' /-\ntheorem map_natCast' {A} [AddMonoidWithOne A] [AddMonoidHomClass F A B] (f : F) (h : f 1 = 1) :\n    ∀ n : ℕ, f n = n\n  | 0 => by simp\n  | n + 1 => by\n    rw [Nat.cast_add, map_add, Nat.cast_add, map_natCast', Nat.cast_one, h, Nat.cast_one]\n#align map_nat_cast' map_natCast'\n-/\n\nend AddMonoidHomClass\n\nsection MonoidWithZeroHomClass\n\nvariable {A F : Type _} [MulZeroOneClass A]\n\n#print ext_nat'' /-\n/-- If two `monoid_with_zero_hom`s agree on the positive naturals they are equal. -/\ntheorem ext_nat'' [MonoidWithZeroHomClass F ℕ A] (f g : F) (h_pos : ∀ {n : ℕ}, 0 < n → f n = g n) :\n    f = g := by\n  apply FunLike.ext\n  rintro (_ | n)\n  · simp\n  exact h_pos n.succ_pos\n#align ext_nat'' ext_nat''\n-/\n\n/- warning: monoid_with_zero_hom.ext_nat -> MonoidWithZeroHom.ext_nat is a dubious translation:\nlean 3 declaration is\n  forall {A : Type.{u1}} [_inst_1 : MulZeroOneClass.{u1} A] {f : MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1} {g : MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1}, (forall {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (Eq.{succ u1} A (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) (fun (_x : MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) => Nat -> A) (MonoidWithZeroHom.hasCoeToFun.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) f n) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) (fun (_x : MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) => Nat -> A) (MonoidWithZeroHom.hasCoeToFun.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) g n))) -> (Eq.{succ u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) f g)\nbut is expected to have type\n  forall {A : Type.{u1}} [_inst_1 : MulZeroOneClass.{u1} A] {f : MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1} {g : MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1}, (forall {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Nat) => A) n) (FunLike.coe.{succ u1, 1, succ u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Nat) => A) _x) (MulHomClass.toFunLike.{u1, 0, u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat A (MulOneClass.toMul.{0} Nat (MulZeroOneClass.toMulOneClass.{0} Nat (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)))) (MulOneClass.toMul.{u1} A (MulZeroOneClass.toMulOneClass.{u1} A _inst_1)) (MonoidHomClass.toMulHomClass.{u1, 0, u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat A (MulZeroOneClass.toMulOneClass.{0} Nat (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring))) (MulZeroOneClass.toMulOneClass.{u1} A _inst_1) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, 0, u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1 (MonoidWithZeroHom.monoidWithZeroHomClass.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1)))) f n) (FunLike.coe.{succ u1, 1, succ u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Nat) => A) _x) (MulHomClass.toFunLike.{u1, 0, u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat A (MulOneClass.toMul.{0} Nat (MulZeroOneClass.toMulOneClass.{0} Nat (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)))) (MulOneClass.toMul.{u1} A (MulZeroOneClass.toMulOneClass.{u1} A _inst_1)) (MonoidHomClass.toMulHomClass.{u1, 0, u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat A (MulZeroOneClass.toMulOneClass.{0} Nat (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring))) (MulZeroOneClass.toMulOneClass.{u1} A _inst_1) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, 0, u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1 (MonoidWithZeroHom.monoidWithZeroHomClass.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1)))) g n))) -> (Eq.{succ u1} (MonoidWithZeroHom.{0, u1} Nat A (NonAssocSemiring.toMulZeroOneClass.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) _inst_1) f g)\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.ext_nat MonoidWithZeroHom.ext_natₓ'. -/\n@[ext]\ntheorem MonoidWithZeroHom.ext_nat : ∀ {f g : ℕ →*₀ A}, (∀ {n : ℕ}, 0 < n → f n = g n) → f = g :=\n  ext_nat''\n#align monoid_with_zero_hom.ext_nat MonoidWithZeroHom.ext_nat\n\nend MonoidWithZeroHomClass\n\nsection RingHomClass\n\nvariable {R S F : Type _} [NonAssocSemiring R] [NonAssocSemiring S]\n\n#print eq_natCast /-\n@[simp]\ntheorem eq_natCast [RingHomClass F ℕ R] (f : F) : ∀ n, f n = n :=\n  eq_natCast' f <| map_one f\n#align eq_nat_cast eq_natCast\n-/\n\n/- warning: map_nat_cast -> map_natCast is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {F : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_3 : RingHomClass.{u3, u1, u2} F R S _inst_1 _inst_2] (f : F) (n : Nat), Eq.{succ u2} S (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => R -> S) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F R (fun (_x : R) => S) (MulHomClass.toFunLike.{u3, u1, u2} F R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F R S _inst_1 _inst_2 _inst_3)))) f ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) n)) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat S (HasLiftT.mk.{1, succ u2} Nat S (CoeTCₓ.coe.{1, succ u2} Nat S (Nat.castCoe.{u2} S (AddMonoidWithOne.toNatCast.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2)))))) n)\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u1}} {F : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u1} S] [_inst_3 : RingHomClass.{u3, u2, u1} F R S _inst_1 _inst_2] (f : F) (n : Nat), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) (Nat.cast.{u2} R (NonAssocSemiring.toNatCast.{u2} R _inst_1) n)) (FunLike.coe.{succ u3, succ u2, succ u1} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{u3, u2, u1} F R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{u3, u2, u1} F R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{u3, u2, u1} F R S _inst_1 _inst_2 _inst_3))) f (Nat.cast.{u2} R (NonAssocSemiring.toNatCast.{u2} R _inst_1) n)) (Nat.cast.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) (Nat.cast.{u2} R (NonAssocSemiring.toNatCast.{u2} R _inst_1) n)) (NonAssocSemiring.toNatCast.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) (Nat.cast.{u2} R (NonAssocSemiring.toNatCast.{u2} R _inst_1) n)) _inst_2) n)\nCase conversion may be inaccurate. Consider using '#align map_nat_cast map_natCastₓ'. -/\n@[simp]\ntheorem map_natCast [RingHomClass F R S] (f : F) : ∀ n : ℕ, f (n : R) = n :=\n  map_natCast' f <| map_one f\n#align map_nat_cast map_natCast\n\n#print ext_nat /-\ntheorem ext_nat [RingHomClass F ℕ R] (f g : F) : f = g :=\n  ext_nat' f g <| by simp only [map_one]\n#align ext_nat ext_nat\n-/\n\n/- warning: ne_zero.nat_of_injective -> NeZero.nat_of_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {F : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {n : Nat} [h : NeZero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) n)] [_inst_3 : RingHomClass.{u3, u1, u2} F R S _inst_1 _inst_2] {f : F}, (Function.Injective.{succ u1, succ u2} R S (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => R -> S) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F R (fun (_x : R) => S) (MulHomClass.toFunLike.{u3, u1, u2} F R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F R S _inst_1 _inst_2 _inst_3)))) f)) -> (NeZero.{u2} S (MulZeroClass.toHasZero.{u2} S (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat S (HasLiftT.mk.{1, succ u2} Nat S (CoeTCₓ.coe.{1, succ u2} Nat S (Nat.castCoe.{u2} S (AddMonoidWithOne.toNatCast.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2)))))) n))\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u1}} {F : Type.{u2}} [_inst_1 : NonAssocSemiring.{u3} R] [_inst_2 : NonAssocSemiring.{u1} S] {n : Nat} [h : NeZero.{u3} R (MulZeroOneClass.toZero.{u3} R (NonAssocSemiring.toMulZeroOneClass.{u3} R _inst_1)) (Nat.cast.{u3} R (NonAssocSemiring.toNatCast.{u3} R _inst_1) n)] [_inst_3 : RingHomClass.{u2, u3, u1} F R S _inst_1 _inst_2] {f : F}, (Function.Injective.{succ u3, succ u1} R S (FunLike.coe.{succ u2, succ u3, succ u1} F R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{u2, u3, u1} F R S (NonUnitalNonAssocSemiring.toMul.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{u2, u3, u1} F R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{u2, u3, u1} F R S _inst_1 _inst_2 _inst_3))) f)) -> (NeZero.{u1} S (MulZeroOneClass.toZero.{u1} S (NonAssocSemiring.toMulZeroOneClass.{u1} S _inst_2)) (Nat.cast.{u1} S (NonAssocSemiring.toNatCast.{u1} S _inst_2) n))\nCase conversion may be inaccurate. Consider using '#align ne_zero.nat_of_injective NeZero.nat_of_injectiveₓ'. -/\ntheorem NeZero.nat_of_injective {n : ℕ} [h : NeZero (n : R)] [RingHomClass F R S] {f : F}\n    (hf : Function.Injective f) : NeZero (n : S) :=\n  ⟨fun h => NeZero.natCast_ne n R <| hf <| by simpa only [map_natCast, map_zero] ⟩\n#align ne_zero.nat_of_injective NeZero.nat_of_injective\n\n/- warning: ne_zero.nat_of_ne_zero -> NeZero.nat_of_neZero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_3 : Semiring.{u1} R] [_inst_4 : Semiring.{u2} S] {F : Type.{u3}} [_inst_5 : RingHomClass.{u3, u1, u2} F R S (Semiring.toNonAssocSemiring.{u1} R _inst_3) (Semiring.toNonAssocSemiring.{u2} S _inst_4)], F -> (forall {n : Nat} [hn : NeZero.{u2} S (MulZeroClass.toHasZero.{u2} S (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_4)))) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat S (HasLiftT.mk.{1, succ u2} Nat S (CoeTCₓ.coe.{1, succ u2} Nat S (Nat.castCoe.{u2} S (AddMonoidWithOne.toNatCast.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_4))))))) n)], NeZero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_3))))))) n))\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u2}} [_inst_3 : Semiring.{u3} R] [_inst_4 : Semiring.{u2} S] {F : Type.{u1}} [_inst_5 : RingHomClass.{u1, u3, u2} F R S (Semiring.toNonAssocSemiring.{u3} R _inst_3) (Semiring.toNonAssocSemiring.{u2} S _inst_4)], F -> (forall {n : Nat} [hn : NeZero.{u2} S (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_4)) (Nat.cast.{u2} S (Semiring.toNatCast.{u2} S _inst_4) n)], NeZero.{u3} R (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R _inst_3)) (Nat.cast.{u3} R (Semiring.toNatCast.{u3} R _inst_3) n))\nCase conversion may be inaccurate. Consider using '#align ne_zero.nat_of_ne_zero NeZero.nat_of_neZeroₓ'. -/\ntheorem NeZero.nat_of_neZero {R S} [Semiring R] [Semiring S] {F} [RingHomClass F R S] (f : F)\n    {n : ℕ} [hn : NeZero (n : S)] : NeZero (n : R) :=\n  by\n  apply NeZero.of_map f\n  simp only [map_natCast, hn]\n#align ne_zero.nat_of_ne_zero NeZero.nat_of_neZero\n\nend RingHomClass\n\nnamespace RingHom\n\n#print RingHom.eq_natCast' /-\n/-- This is primed to match `eq_int_cast'`. -/\ntheorem eq_natCast' {R} [NonAssocSemiring R] (f : ℕ →+* R) : f = Nat.castRingHom R :=\n  RingHom.ext <| eq_natCast f\n#align ring_hom.eq_nat_cast' RingHom.eq_natCast'\n-/\n\nend RingHom\n\n#print Nat.cast_id /-\n@[simp, norm_cast]\ntheorem Nat.cast_id (n : ℕ) : ↑n = n :=\n  rfl\n#align nat.cast_id Nat.cast_id\n-/\n\n#print Nat.castRingHom_nat /-\n@[simp]\ntheorem Nat.castRingHom_nat : Nat.castRingHom ℕ = RingHom.id ℕ :=\n  rfl\n#align nat.cast_ring_hom_nat Nat.castRingHom_nat\n-/\n\n#print Nat.uniqueRingHom /-\n-- I don't think `ring_hom_class` is good here, because of the `subsingleton` TC slowness\ninstance Nat.uniqueRingHom {R : Type _} [NonAssocSemiring R] : Unique (ℕ →+* R)\n    where\n  default := Nat.castRingHom R\n  uniq := RingHom.eq_natCast'\n#align nat.unique_ring_hom Nat.uniqueRingHom\n-/\n\nnamespace Pi\n\nvariable {π : α → Type _} [∀ a, NatCast (π a)]\n\ninstance : NatCast (∀ a, π a) := by refine_struct { .. } <;> pi_instance_derive_field\n\n#print Pi.nat_apply /-\ntheorem nat_apply (n : ℕ) (a : α) : (n : ∀ a, π a) a = n :=\n  rfl\n#align pi.nat_apply Pi.nat_apply\n-/\n\n/- warning: pi.coe_nat -> Pi.coe_nat is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {π : α -> Type.{u2}} [_inst_1 : forall (a : α), NatCast.{u2} (π a)] (n : Nat), Eq.{max (succ u1) (succ u2)} (forall (a : α), π a) ((fun (a : Type) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{1, max (succ u1) (succ u2)} a b] => self.0) Nat (forall (a : α), π a) (HasLiftT.mk.{1, max (succ u1) (succ u2)} Nat (forall (a : α), π a) (CoeTCₓ.coe.{1, max (succ u1) (succ u2)} Nat (forall (a : α), π a) (Nat.castCoe.{max u1 u2} (forall (a : α), π a) (Pi.hasNatCast.{u1, u2} α (fun (a : α) => π a) (fun (a : α) => _inst_1 a))))) n) (fun (_x : α) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat (π _x) (HasLiftT.mk.{1, succ u2} Nat (π _x) (CoeTCₓ.coe.{1, succ u2} Nat (π _x) (Nat.castCoe.{u2} (π _x) (_inst_1 _x)))) n)\nbut is expected to have type\n  forall {α : Type.{u2}} {π : α -> Type.{u1}} [_inst_1 : forall (a : α), NatCast.{u1} (π a)] (n : Nat), Eq.{max (succ u2) (succ u1)} (forall (a : α), π a) (Nat.cast.{max u2 u1} (forall (a : α), π a) (Pi.natCast.{u2, u1} α (fun (a : α) => π a) (fun (a : α) => _inst_1 a)) n) (fun (_x : α) => Nat.cast.{u1} (π _x) (_inst_1 _x) n)\nCase conversion may be inaccurate. Consider using '#align pi.coe_nat Pi.coe_natₓ'. -/\n@[simp]\ntheorem coe_nat (n : ℕ) : (n : ∀ a, π a) = fun _ => n :=\n  rfl\n#align pi.coe_nat Pi.coe_nat\n\nend Pi\n\n/- warning: sum.elim_nat_cast_nat_cast -> Sum.elim_natCast_natCast is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : NatCast.{u3} γ] (n : Nat), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} α β) -> γ) (Sum.elim.{u1, u2, succ u3} α β γ ((fun (a : Type) (b : Sort.{max (succ u1) (succ u3)}) [self : HasLiftT.{1, max (succ u1) (succ u3)} a b] => self.0) Nat (α -> γ) (HasLiftT.mk.{1, max (succ u1) (succ u3)} Nat (α -> γ) (CoeTCₓ.coe.{1, max (succ u1) (succ u3)} Nat (α -> γ) (Nat.castCoe.{max u1 u3} (α -> γ) (Pi.hasNatCast.{u1, u3} α (fun (ᾰ : α) => γ) (fun (a : α) => _inst_1))))) n) ((fun (a : Type) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{1, max (succ u2) (succ u3)} a b] => self.0) Nat (β -> γ) (HasLiftT.mk.{1, max (succ u2) (succ u3)} Nat (β -> γ) (CoeTCₓ.coe.{1, max (succ u2) (succ u3)} Nat (β -> γ) (Nat.castCoe.{max u2 u3} (β -> γ) (Pi.hasNatCast.{u2, u3} β (fun (ᾰ : β) => γ) (fun (a : β) => _inst_1))))) n)) ((fun (a : Type) (b : Sort.{max (max (succ u1) (succ u2)) (succ u3)}) [self : HasLiftT.{1, max (max (succ u1) (succ u2)) (succ u3)} a b] => self.0) Nat ((Sum.{u1, u2} α β) -> γ) (HasLiftT.mk.{1, max (max (succ u1) (succ u2)) (succ u3)} Nat ((Sum.{u1, u2} α β) -> γ) (CoeTCₓ.coe.{1, max (max (succ u1) (succ u2)) (succ u3)} Nat ((Sum.{u1, u2} α β) -> γ) (Nat.castCoe.{max (max u1 u2) u3} ((Sum.{u1, u2} α β) -> γ) (Pi.hasNatCast.{max u1 u2, u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) => _inst_1))))) n)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : NatCast.{u1} γ] (n : Nat), Eq.{max (max (succ u3) (succ u2)) (succ u1)} ((Sum.{u3, u2} α β) -> γ) (Sum.elim.{u3, u2, succ u1} α β γ (Nat.cast.{max u3 u1} (α -> γ) (Pi.natCast.{u3, u1} α (fun (a._@.Mathlib.Data.Nat.Cast.Basic._hyg.2266 : α) => γ) (fun (a : α) => _inst_1)) n) (Nat.cast.{max u2 u1} (β -> γ) (Pi.natCast.{u2, u1} β (fun (a._@.Mathlib.Data.Nat.Cast.Basic._hyg.2273 : β) => γ) (fun (a : β) => _inst_1)) n)) (Nat.cast.{max (max u3 u2) u1} ((Sum.{u3, u2} α β) -> γ) (Pi.natCast.{max u3 u2, u1} (Sum.{u3, u2} α β) (fun (a._@.Mathlib.Data.Sum.Basic._hyg.1871 : Sum.{u3, u2} α β) => γ) (fun (a : Sum.{u3, u2} α β) => _inst_1)) n)\nCase conversion may be inaccurate. Consider using '#align sum.elim_nat_cast_nat_cast Sum.elim_natCast_natCastₓ'. -/\ntheorem Sum.elim_natCast_natCast {α β γ : Type _} [NatCast γ] (n : ℕ) :\n    Sum.elim (n : α → γ) (n : β → γ) = n :=\n  @Sum.elim_lam_const_lam_const α β γ n\n#align sum.elim_nat_cast_nat_cast Sum.elim_natCast_natCast\n\nnamespace Pi\n\nvariable {π : α → Type _} [∀ a, AddMonoidWithOne (π a)]\n\ninstance : AddMonoidWithOne (∀ a, π a) := by refine_struct { .. } <;> pi_instance_derive_field\n\nend Pi\n\n/-! ### Order dual -/\n\n\nopen OrderDual\n\ninstance [h : NatCast α] : NatCast αᵒᵈ :=\n  h\n\ninstance [h : AddMonoidWithOne α] : AddMonoidWithOne αᵒᵈ :=\n  h\n\ninstance [h : AddCommMonoidWithOne α] : AddCommMonoidWithOne αᵒᵈ :=\n  h\n\n#print toDual_natCast /-\n@[simp]\ntheorem toDual_natCast [NatCast α] (n : ℕ) : toDual (n : α) = n :=\n  rfl\n#align to_dual_nat_cast toDual_natCast\n-/\n\n#print ofDual_natCast /-\n@[simp]\ntheorem ofDual_natCast [NatCast α] (n : ℕ) : (ofDual n : α) = n :=\n  rfl\n#align of_dual_nat_cast ofDual_natCast\n-/\n\n/-! ### Lexicographic order -/\n\n\ninstance [h : NatCast α] : NatCast (Lex α) :=\n  h\n\ninstance [h : AddMonoidWithOne α] : AddMonoidWithOne (Lex α) :=\n  h\n\ninstance [h : AddCommMonoidWithOne α] : AddCommMonoidWithOne (Lex α) :=\n  h\n\n#print toLex_natCast /-\n@[simp]\ntheorem toLex_natCast [NatCast α] (n : ℕ) : toLex (n : α) = n :=\n  rfl\n#align to_lex_nat_cast toLex_natCast\n-/\n\n#print ofLex_natCast /-\n@[simp]\ntheorem ofLex_natCast [NatCast α] (n : ℕ) : (ofLex n : α) = n :=\n  rfl\n#align of_lex_nat_cast ofLex_natCast\n-/\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Nat/Cast/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.47610007248712155}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport category_theory.lifting_properties.basic\nimport category_theory.adjunction.basic\n\n/-!\n\n# Lifting properties and adjunction\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file, we obtain `adjunction.has_lifting_property_iff`, which states\nthat when we have an adjunction `adj : G ⊣ F` between two functors `G : C ⥤ D`\nand `F : D ⥤ C`, then a morphism of the form `G.map i` has the left lifting\nproperty in `D` with respect to a morphism `p` if and only the morphism `i`\nhas the left lifting property in `C` with respect to `F.map p`.\n\n-/\n\nnamespace category_theory\n\nopen category\n\nvariables {C D : Type*} [category C] [category D] {G : C ⥤ D} {F : D ⥤ C}\n\nnamespace comm_sq\n\nsection\nvariables {A B : C} {X Y : D} {i : A ⟶ B} {p : X ⟶ Y} {u : G.obj A ⟶ X} {v : G.obj B ⟶ Y}\n  (sq : comm_sq u (G.map i) p v) (adj : G ⊣ F)\n\ninclude sq\n\n/-- When we have an adjunction `G ⊣ F`, any commutative square where the left\nmap is of the form `G.map i` and the right map is `p` has an \"adjoint\" commutative\nsquare whose left map is `i` and whose right map is `F.map p`. -/\nlemma right_adjoint :\n  comm_sq (adj.hom_equiv _ _ u) i (F.map p) (adj.hom_equiv _ _ v) :=\n⟨begin\n  simp only [adjunction.hom_equiv_unit, assoc, ← F.map_comp, sq.w],\n  rw [F.map_comp, adjunction.unit_naturality_assoc],\nend⟩\n\n/-- The liftings of a commutative are in bijection with the liftings of its (right)\nadjoint square. -/\ndef right_adjoint_lift_struct_equiv :\n  sq.lift_struct ≃ (sq.right_adjoint adj).lift_struct :=\n{ to_fun := λ l,\n  { l := adj.hom_equiv _ _ l.l,\n    fac_left' := by rw [← adj.hom_equiv_naturality_left, l.fac_left],\n    fac_right' := by rw [← adjunction.hom_equiv_naturality_right, l.fac_right], },\n  inv_fun := λ l,\n  { l := (adj.hom_equiv _ _).symm l.l,\n    fac_left' := begin\n      rw [← adjunction.hom_equiv_naturality_left_symm, l.fac_left],\n      apply (adj.hom_equiv _ _).left_inv,\n    end,\n    fac_right' := begin\n      rw [← adjunction.hom_equiv_naturality_right_symm, l.fac_right],\n      apply (adj.hom_equiv _ _).left_inv,\n    end, },\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\n/-- A square has a lifting if and only if its (right) adjoint square has a lifting. -/\nlemma right_adjoint_has_lift_iff :\n  has_lift (sq.right_adjoint adj) ↔ has_lift sq :=\nbegin\n  simp only [has_lift.iff],\n  exact equiv.nonempty_congr (sq.right_adjoint_lift_struct_equiv adj).symm,\nend\n\ninstance [has_lift sq] : has_lift (sq.right_adjoint adj) :=\nby { rw right_adjoint_has_lift_iff, apply_instance, }\n\nend\n\nsection\nvariables {A B : C} {X Y : D} {i : A ⟶ B} {p : X ⟶ Y} {u : A ⟶ F.obj X} {v : B ⟶ F.obj Y}\n  (sq : comm_sq u i (F.map p) v) (adj : G ⊣ F)\n\ninclude sq\n\n/-- When we have an adjunction `G ⊣ F`, any commutative square where the left\nmap is of the form `i` and the right map is `F.map p` has an \"adjoint\" commutative\nsquare whose left map is `G.map i` and whose right map is `p`. -/\nlemma left_adjoint :\n  comm_sq ((adj.hom_equiv _ _).symm u) (G.map i) p\n    ((adj.hom_equiv _ _).symm v) :=\n⟨begin\n  simp only [adjunction.hom_equiv_counit, assoc,\n    ← G.map_comp_assoc, ← sq.w],\n  rw [G.map_comp, assoc, adjunction.counit_naturality],\nend⟩\n\n/-- The liftings of a commutative are in bijection with the liftings of its (left)\nadjoint square. -/\ndef left_adjoint_lift_struct_equiv :\n  sq.lift_struct ≃ (sq.left_adjoint adj).lift_struct :=\n{ to_fun := λ l,\n  { l := (adj.hom_equiv _ _).symm l.l,\n    fac_left' := by rw [← adj.hom_equiv_naturality_left_symm, l.fac_left],\n    fac_right' := by rw [← adj.hom_equiv_naturality_right_symm, l.fac_right], },\n  inv_fun := λ l,\n  { l := (adj.hom_equiv _ _) l.l,\n    fac_left' := begin\n      rw [← adj.hom_equiv_naturality_left, l.fac_left],\n      apply (adj.hom_equiv _ _).right_inv,\n    end,\n    fac_right' := begin\n      rw [← adj.hom_equiv_naturality_right, l.fac_right],\n      apply (adj.hom_equiv _ _).right_inv,\n    end, },\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\n/-- A (left) adjoint square has a lifting if and only if the original square has a lifting. -/\nlemma left_adjoint_has_lift_iff :\n  has_lift (sq.left_adjoint adj) ↔ has_lift sq :=\nbegin\n  simp only [has_lift.iff],\n  exact equiv.nonempty_congr (sq.left_adjoint_lift_struct_equiv adj).symm,\nend\n\ninstance [has_lift sq] : has_lift (sq.left_adjoint adj) :=\nby { rw left_adjoint_has_lift_iff, apply_instance, }\n\nend\n\nend comm_sq\n\nnamespace adjunction\n\nlemma has_lifting_property_iff (adj : G ⊣ F) {A B : C} {X Y : D} (i : A ⟶ B) (p : X ⟶ Y) :\n  has_lifting_property (G.map i) p ↔ has_lifting_property i (F.map p) :=\nbegin\n  split; introI; constructor; intros f g sq,\n  { rw ← sq.left_adjoint_has_lift_iff adj,\n    apply_instance, },\n  { rw ← sq.right_adjoint_has_lift_iff adj,\n    apply_instance, },\nend\n\nend adjunction\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/lifting_properties/adjunction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186787341014, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.47606505688065454}}
{"text": "/-\nCopyright (c) 2021 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport category_theory.preadditive.default\n\n/-!\n# Preadditive structure on functor categories\n\nIf `C` and `D` are categories and `D` is preadditive,\nthen `C ⥤ D` is also preadditive.\n\n-/\n\nopen_locale big_operators\n\nnamespace category_theory\nopen category_theory.limits preadditive\n\nvariables {C D : Type*} [category C] [category D] [preadditive D]\n\ninstance functor_category_preadditive : preadditive (C ⥤ D) :=\n{ hom_group := λ F G,\n  { add := λ α β,\n    { app := λ X, α.app X + β.app X,\n      naturality' := by { intros, rw [comp_add, add_comp, α.naturality, β.naturality] } },\n    zero := { app := λ X, 0, naturality' := by { intros, rw [zero_comp, comp_zero] } },\n    neg := λ α,\n    { app := λ X, -α.app X,\n      naturality' := by { intros, rw [comp_neg, neg_comp, α.naturality] } },\n    sub := λ α β,\n    { app := λ X, α.app X - β.app X,\n      naturality' := by { intros, rw [comp_sub, sub_comp, α.naturality, β.naturality] } },\n    add_assoc := by { intros, ext, apply add_assoc },\n    zero_add := by { intros, ext, apply zero_add },\n    add_zero := by { intros, ext, apply add_zero },\n    sub_eq_add_neg := by { intros, ext, apply sub_eq_add_neg },\n    add_left_neg := by { intros, ext, apply add_left_neg },\n    add_comm := by { intros, ext, apply add_comm } },\n  add_comp' := by { intros, ext, apply add_comp },\n  comp_add' := by { intros, ext, apply comp_add } }\n\nnamespace nat_trans\n\nvariables {F G : C ⥤ D}\n\n/-- Application of a natural transformation at a fixed object,\nas group homomorphism -/\n@[simps] def app_hom (X : C) : (F ⟶ G) →+ (F.obj X ⟶ G.obj X) :=\n{ to_fun := λ α, α.app X,\n  map_zero' := rfl,\n  map_add' := λ _ _, rfl }\n\n@[simp] lemma app_zero (X : C) : (0 : F ⟶ G).app X = 0 := rfl\n\n@[simp] \n\n@[simp] lemma app_sub (X : C) (α β : F ⟶ G) : (α - β).app X = α.app X - β.app X := rfl\n\n@[simp] lemma app_neg (X : C) (α : F ⟶ G) : (-α).app X = -α.app X := rfl\n\n@[simp] lemma app_nsmul (X : C) (α : F ⟶ G) (n : ℕ) : (n • α).app X = n • α.app X :=\n(app_hom X).map_nsmul α n\n\n@[simp] lemma app_zsmul (X : C) (α : F ⟶ G) (n : ℤ) : (n • α).app X = n • α.app X :=\n(app_hom X : (F ⟶ G) →+ (F.obj X ⟶ G.obj X)).map_zsmul α n\n\n@[simp] lemma app_sum {ι : Type*} (s : finset ι) (X : C) (α : ι → (F ⟶ G)) :\n  (∑ i in s, α i).app X = ∑ i in s, ((α i).app X) :=\nby { rw [← app_hom_apply, add_monoid_hom.map_sum], refl }\n\nend nat_trans\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/preadditive/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396211, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4760650511540655}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad, Mario Carneiro, Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.fin2\nimport Mathlib.logic.function.basic\nimport Mathlib.tactic.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n\n# Tuples of types, and their categorical structure.\n\n## Features\n\n* `typevec n` - n-tuples of types\n* `α ⟹ β`    - n-tuples of maps\n* `f ⊚ g`     - composition\n\nAlso, support functions for operating with n-tuples of types, such as:\n\n* `append1 α β`    - append type `β` to n-tuple `α` to obtain an (n+1)-tuple\n* `drop α`         - drops the last element of an (n+1)-tuple\n* `last α`         - returns the last element of an (n+1)-tuple\n* `append_fun f g` - appends a function g to an n-tuple of functions\n* `drop_fun f`     - drops the last function from an n+1-tuple\n* `last_fun f`     - returns the last function of a tuple.\n\nSince e.g. `append1 α.drop α.last` is propositionally equal to `α` but not definitionally equal\nto it, we need support functions and lemmas to mediate between constructions.\n-/\n\n/--\nn-tuples of types, as a category\n-/\ndef typevec (n : ℕ) := fin2 n → Type u_1\n\nprotected instance typevec.inhabited {n : ℕ} : Inhabited (typevec n) :=\n  { default := fun (_x : fin2 n) => PUnit }\n\nnamespace typevec\n\n\n/-- arrow in the category of `typevec` -/\ndef arrow {n : ℕ} (α : typevec n) (β : typevec n) := (i : fin2 n) → α i → β i\n\nprotected instance arrow.inhabited {n : ℕ} (α : typevec n) (β : typevec n)\n    [(i : fin2 n) → Inhabited (β i)] : Inhabited (arrow α β) :=\n  { default := fun (_x : fin2 n) (_x_1 : α _x) => Inhabited.default }\n\n/-- identity of arrow composition -/\ndef id {n : ℕ} {α : typevec n} : arrow α α := fun (i : fin2 n) (x : α i) => x\n\n/-- arrow composition in the category of `typevec` -/\ndef comp {n : ℕ} {α : typevec n} {β : typevec n} {γ : typevec n} (g : arrow β γ) (f : arrow α β) :\n    arrow α γ :=\n  fun (i : fin2 n) (x : α i) => g i (f i x)\n\n@[simp] theorem id_comp {n : ℕ} {α : typevec n} {β : typevec n} (f : arrow α β) : comp id f = f :=\n  rfl\n\n@[simp] theorem comp_id {n : ℕ} {α : typevec n} {β : typevec n} (f : arrow α β) : comp f id = f :=\n  rfl\n\ntheorem comp_assoc {n : ℕ} {α : typevec n} {β : typevec n} {γ : typevec n} {δ : typevec n}\n    (h : arrow γ δ) (g : arrow β γ) (f : arrow α β) : comp (comp h g) f = comp h (comp g f) :=\n  rfl\n\n/--\nSupport for extending a typevec by one element.\n-/\ndef append1 {n : ℕ} (α : typevec n) (β : Type u_1) : typevec (n + 1) := sorry\n\ninfixl:67 \" ::: \" => Mathlib.typevec.append1\n\n/-- retain only a `n-length` prefix of the argument -/\ndef drop {n : ℕ} (α : typevec (n + 1)) : typevec n := fun (i : fin2 n) => α (fin2.fs i)\n\n/-- take the last value of a `(n+1)-length` vector -/\ndef last {n : ℕ} (α : typevec (n + 1)) := α fin2.fz\n\nprotected instance last.inhabited {n : ℕ} (α : typevec (n + 1)) [Inhabited (α fin2.fz)] :\n    Inhabited (last α) :=\n  { default := Inhabited.default }\n\ntheorem drop_append1 {n : ℕ} {α : typevec n} {β : Type u_1} {i : fin2 n} : drop (α ::: β) i = α i :=\n  rfl\n\n@[simp] theorem drop_append1' {n : ℕ} {α : typevec n} {β : Type u_1} : drop (α ::: β) = α :=\n  funext fun (x : fin2 n) => drop_append1\n\ntheorem last_append1 {n : ℕ} {α : typevec n} {β : Type u_1} : last (α ::: β) = β := rfl\n\n@[simp] theorem append1_drop_last {n : ℕ} (α : typevec (n + 1)) : drop α ::: last α = α := sorry\n\n/-- cases on `(n+1)-length` vectors -/\ndef append1_cases {n : ℕ} {C : typevec (n + 1) → Sort u}\n    (H : (α : typevec n) → (β : Type u_1) → C (α ::: β)) (γ : typevec (n + 1)) : C γ :=\n  eq.mpr sorry (H (drop γ) (last γ))\n\n@[simp] theorem append1_cases_append1 {n : ℕ} {C : typevec (n + 1) → Sort u}\n    (H : (α : typevec n) → (β : Type u_1) → C (α ::: β)) (α : typevec n) (β : Type u_1) :\n    append1_cases H (α ::: β) = H α β :=\n  rfl\n\n/-- append an arrow and a function for arbitrary source and target\ntype vectors -/\ndef split_fun {n : ℕ} {α : typevec (n + 1)} {α' : typevec (n + 1)} (f : arrow (drop α) (drop α'))\n    (g : last α → last α') : arrow α α' :=\n  sorry\n\n/-- append an arrow and a function as well as their respective source\nand target types / typevecs -/\ndef append_fun {n : ℕ} {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2}\n    (f : arrow α α') (g : β → β') : arrow (α ::: β) (α' ::: β') :=\n  split_fun f g\n\ninfixl:67 \" ::: \" => Mathlib.typevec.append_fun\n\n/-- split off the prefix of an arrow -/\ndef drop_fun {n : ℕ} {α : typevec (n + 1)} {β : typevec (n + 1)} (f : arrow α β) :\n    arrow (drop α) (drop β) :=\n  fun (i : fin2 n) => f (fin2.fs i)\n\n/-- split off the last function of an arrow -/\ndef last_fun {n : ℕ} {α : typevec (n + 1)} {β : typevec (n + 1)} (f : arrow α β) :\n    last α → last β :=\n  f fin2.fz\n\n/-- arrow in the category of `0-length` vectors -/\ndef nil_fun {α : typevec 0} {β : typevec 0} : arrow α β := fun (i : fin2 0) => fin2.elim0 i\n\ntheorem eq_of_drop_last_eq {n : ℕ} {α : typevec (n + 1)} {β : typevec (n + 1)} {f : arrow α β}\n    {g : arrow α β} (h₀ : drop_fun f = drop_fun g) (h₁ : last_fun f = last_fun g) : f = g :=\n  sorry\n\n@[simp] theorem drop_fun_split_fun {n : ℕ} {α : typevec (n + 1)} {α' : typevec (n + 1)}\n    (f : arrow (drop α) (drop α')) (g : last α → last α') : drop_fun (split_fun f g) = f :=\n  rfl\n\n/-- turn an equality into an arrow -/\ndef arrow.mp {n : ℕ} {α : typevec n} {β : typevec n} (h : α = β) : arrow α β := sorry\n\n/-- turn an equality into an arrow, with reverse direction -/\ndef arrow.mpr {n : ℕ} {α : typevec n} {β : typevec n} (h : α = β) : arrow β α := sorry\n\n/-- decompose a vector into its prefix appended with its last element -/\ndef to_append1_drop_last {n : ℕ} {α : typevec (n + 1)} : arrow α (drop α ::: last α) :=\n  arrow.mpr (append1_drop_last α)\n\n/-- stitch two bits of a vector back together -/\ndef from_append1_drop_last {n : ℕ} {α : typevec (n + 1)} : arrow (drop α ::: last α) α :=\n  arrow.mp (append1_drop_last α)\n\n@[simp] theorem last_fun_split_fun {n : ℕ} {α : typevec (n + 1)} {α' : typevec (n + 1)}\n    (f : arrow (drop α) (drop α')) (g : last α → last α') : last_fun (split_fun f g) = g :=\n  rfl\n\n@[simp] theorem drop_fun_append_fun {n : ℕ} {α : typevec n} {α' : typevec n} {β : Type u_1}\n    {β' : Type u_2} (f : arrow α α') (g : β → β') : drop_fun (f ::: g) = f :=\n  rfl\n\n@[simp] theorem last_fun_append_fun {n : ℕ} {α : typevec n} {α' : typevec n} {β : Type u_1}\n    {β' : Type u_2} (f : arrow α α') (g : β → β') : last_fun (f ::: g) = g :=\n  rfl\n\ntheorem split_drop_fun_last_fun {n : ℕ} {α : typevec (n + 1)} {α' : typevec (n + 1)}\n    (f : arrow α α') : split_fun (drop_fun f) (last_fun f) = f :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem split_fun_inj {n : ℕ} {α : typevec (n + 1)} {α' : typevec (n + 1)}\n    {f : arrow (drop α) (drop α')} {f' : arrow (drop α) (drop α')} {g : last α → last α'}\n    {g' : last α → last α'} (H : split_fun f g = split_fun f' g') : f = f' ∧ g = g' :=\n  sorry\n\ntheorem append_fun_inj {n : ℕ} {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2}\n    {f : arrow α α'} {f' : arrow α α'} {g : β → β'} {g' : β → β'} :\n    f ::: g = f' ::: g' → f = f' ∧ g = g' :=\n  split_fun_inj\n\ntheorem split_fun_comp {n : ℕ} {α₀ : typevec (n + 1)} {α₁ : typevec (n + 1)} {α₂ : typevec (n + 1)}\n    (f₀ : arrow (drop α₀) (drop α₁)) (f₁ : arrow (drop α₁) (drop α₂)) (g₀ : last α₀ → last α₁)\n    (g₁ : last α₁ → last α₂) :\n    split_fun (comp f₁ f₀) (g₁ ∘ g₀) = comp (split_fun f₁ g₁) (split_fun f₀ g₀) :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem append_fun_comp_split_fun {n : ℕ} {α : typevec n} {γ : typevec n} {β : Type u_1}\n    {δ : Type u_2} {ε : typevec (n + 1)} (f₀ : arrow (drop ε) α) (f₁ : arrow α γ) (g₀ : last ε → β)\n    (g₁ : β → δ) : comp (f₁ ::: g₁) (split_fun f₀ g₀) = split_fun (comp f₁ f₀) (g₁ ∘ g₀) :=\n  Eq.symm (split_fun_comp f₀ f₁ g₀ g₁)\n\ntheorem append_fun_comp {n : ℕ} {α₀ : typevec n} {α₁ : typevec n} {α₂ : typevec n} {β₀ : Type u_1}\n    {β₁ : Type u_2} {β₂ : Type u_3} (f₀ : arrow α₀ α₁) (f₁ : arrow α₁ α₂) (g₀ : β₀ → β₁)\n    (g₁ : β₁ → β₂) : comp f₁ f₀ ::: g₁ ∘ g₀ = comp (f₁ ::: g₁) (f₀ ::: g₀) :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem append_fun_comp' {n : ℕ} {α₀ : typevec n} {α₁ : typevec n} {α₂ : typevec n} {β₀ : Type u_1}\n    {β₁ : Type u_2} {β₂ : Type u_3} (f₀ : arrow α₀ α₁) (f₁ : arrow α₁ α₂) (g₀ : β₀ → β₁)\n    (g₁ : β₁ → β₂) : comp (f₁ ::: g₁) (f₀ ::: g₀) = comp f₁ f₀ ::: g₁ ∘ g₀ :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem nil_fun_comp {α₀ : typevec 0} (f₀ : arrow α₀ fin2.elim0) : comp nil_fun f₀ = f₀ :=\n  funext fun (x : fin2 0) => fin2.elim0 x\n\ntheorem append_fun_comp_id {n : ℕ} {α : typevec n} {β₀ : Type u_1} {β₁ : Type u_1} {β₂ : Type u_1}\n    (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : id ::: g₁ ∘ g₀ = comp (id ::: g₁) (id ::: g₀) :=\n  eq_of_drop_last_eq rfl rfl\n\n@[simp] theorem drop_fun_comp {n : ℕ} {α₀ : typevec (n + 1)} {α₁ : typevec (n + 1)}\n    {α₂ : typevec (n + 1)} (f₀ : arrow α₀ α₁) (f₁ : arrow α₁ α₂) :\n    drop_fun (comp f₁ f₀) = comp (drop_fun f₁) (drop_fun f₀) :=\n  rfl\n\n@[simp] theorem last_fun_comp {n : ℕ} {α₀ : typevec (n + 1)} {α₁ : typevec (n + 1)}\n    {α₂ : typevec (n + 1)} (f₀ : arrow α₀ α₁) (f₁ : arrow α₁ α₂) :\n    last_fun (comp f₁ f₀) = last_fun f₁ ∘ last_fun f₀ :=\n  rfl\n\ntheorem append_fun_aux {n : ℕ} {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2}\n    (f : arrow (α ::: β) (α' ::: β')) : drop_fun f ::: last_fun f = f :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem append_fun_id_id {n : ℕ} {α : typevec n} {β : Type u_1} : id ::: id = id :=\n  eq_of_drop_last_eq rfl rfl\n\nprotected instance subsingleton0 : subsingleton (typevec 0) :=\n  subsingleton.intro fun (a b : typevec 0) => funext fun (a_1 : fin2 0) => fin2.elim0 a_1\n\n/-- cases distinction for 0-length type vector -/\nprotected def cases_nil {β : typevec 0 → Sort u_2} (f : β fin2.elim0) (v : typevec 0) : β v :=\n  cast sorry f\n\n/-- cases distinction for (n+1)-length type vector -/\nprotected def cases_cons (n : ℕ) {β : typevec (n + 1) → Sort u_2}\n    (f : (t : Type u_1) → (v : typevec n) → β (v ::: t)) (v : typevec (n + 1)) : β v :=\n  cast sorry (f (last v) (drop v))\n\nprotected theorem cases_nil_append1 {β : typevec 0 → Sort u_2} (f : β fin2.elim0) :\n    typevec.cases_nil f fin2.elim0 = f :=\n  rfl\n\nprotected theorem cases_cons_append1 (n : ℕ) {β : typevec (n + 1) → Sort u_2}\n    (f : (t : Type u_1) → (v : typevec n) → β (v ::: t)) (v : typevec n) (α : Type u_1) :\n    typevec.cases_cons n f (v ::: α) = f α v :=\n  rfl\n\n/-- cases distinction for an arrow in the category of 0-length type vectors -/\ndef typevec_cases_nil₃ {β : (v : typevec 0) → (v' : typevec 0) → arrow v v' → Sort u_3}\n    (f : β fin2.elim0 fin2.elim0 nil_fun) (v : typevec 0) (v' : typevec 0) (fs : arrow v v') :\n    β v v' fs :=\n  cast sorry f\n\n/-- cases distinction for an arrow in the category of (n+1)-length type vectors -/\ndef typevec_cases_cons₃ (n : ℕ)\n    {β : (v : typevec (n + 1)) → (v' : typevec (n + 1)) → arrow v v' → Sort u_3}\n    (F :\n      (t : Type u_1) →\n        (t' : Type u_2) →\n          (f : t → t') →\n            (v : typevec n) →\n              (v' : typevec n) → (fs : arrow v v') → β (v ::: t) (v' ::: t') (fs ::: f))\n    (v : typevec (n + 1)) (v' : typevec (n + 1)) (fs : arrow v v') : β v v' fs :=\n  eq.mpr sorry\n    (eq.mpr sorry\n      fun (fs : arrow (drop v ::: last v) (drop v' ::: last v')) =>\n        eq.mpr sorry (F (last v) (last v') (last_fun fs) (drop v) (drop v') (drop_fun fs)))\n\n/-- specialized cases distinction for an arrow in the category of 0-length type vectors -/\ndef typevec_cases_nil₂ {β : arrow fin2.elim0 fin2.elim0 → Sort u_3} (f : β nil_fun) :\n    (f : arrow fin2.elim0 fin2.elim0) → β f :=\n  fun (g : arrow fin2.elim0 fin2.elim0) => eq.mpr sorry f\n\n/-- specialized cases distinction for an arrow in the category of (n+1)-length type vectors -/\ndef typevec_cases_cons₂ (n : ℕ) (t : Type u_1) (t' : Type u_2) (v : typevec n) (v' : typevec n)\n    {β : arrow (v ::: t) (v' ::: t') → Sort u_3}\n    (F : (f : t → t') → (fs : arrow v v') → β (fs ::: f)) (fs : arrow (v ::: t) (v' ::: t')) :\n    β fs :=\n  eq.mpr sorry (F (last_fun fs) (drop_fun fs))\n\ntheorem typevec_cases_nil₂_append_fun {β : arrow fin2.elim0 fin2.elim0 → Sort u_3} (f : β nil_fun) :\n    typevec_cases_nil₂ f nil_fun = f :=\n  rfl\n\ntheorem typevec_cases_cons₂_append_fun (n : ℕ) (t : Type u_1) (t' : Type u_2) (v : typevec n)\n    (v' : typevec n) {β : arrow (v ::: t) (v' ::: t') → Sort u_3}\n    (F : (f : t → t') → (fs : arrow v v') → β (fs ::: f)) (f : t → t') (fs : arrow v v') :\n    typevec_cases_cons₂ n t t' v v' F (fs ::: f) = F f fs :=\n  rfl\n\n/- for lifting predicates and relations -/\n\n/-- `pred_last α p x` predicates `p` of the last element of `x : α.append1 β`. -/\ndef pred_last {n : ℕ} (α : typevec n) {β : Type u_1} (p : β → Prop) {i : fin2 (n + 1)} :\n    append1 α β i → Prop :=\n  sorry\n\n/-- `rel_last α r x y` says that `p` the last elements of `x y : α.append1 β` are related by `r` and\nall the other elements are equal. -/\ndef rel_last {n : ℕ} (α : typevec n) {β : Type u_1} {γ : Type u_1} (r : β → γ → Prop)\n    {i : fin2 (n + 1)} : append1 α β i → append1 α γ i → Prop :=\n  sorry\n\n/-- `repeat n t` is a `n-length` type vector that contains `n` occurences of `t` -/\ndef repeat (n : ℕ) (t : Type u_1) : typevec n := sorry\n\n/-- `prod α β` is the pointwise product of the components of `α` and `β` -/\ndef prod {n : ℕ} (α : typevec n) (β : typevec n) : typevec n := sorry\n\n/-- `const x α` is an arrow that ignores its source and constructs a `typevec` that\ncontains nothing but `x` -/\nprotected def const {β : Type u_1} (x : β) {n : ℕ} (α : typevec n) : arrow α (repeat n β) := sorry\n\n/-- vector of equality on a product of vectors -/\ndef repeat_eq {n : ℕ} (α : typevec n) : arrow (prod α α) (repeat n Prop) := sorry\n\ntheorem const_append1 {β : Type u_1} {γ : Type u_2} (x : γ) {n : ℕ} (α : typevec n) :\n    typevec.const x (α ::: β) = typevec.const x α ::: fun (_x : β) => x :=\n  sorry\n\ntheorem eq_nil_fun {α : typevec 0} {β : typevec 0} (f : arrow α β) : f = nil_fun := sorry\n\ntheorem id_eq_nil_fun {α : typevec 0} : id = nil_fun := sorry\n\ntheorem const_nil {β : Type u_1} (x : β) (α : typevec 0) : typevec.const x α = nil_fun := sorry\n\ntheorem repeat_eq_append1 {β : Type u_1} {n : ℕ} (α : typevec n) :\n    repeat_eq (α ::: β) = split_fun (repeat_eq α) (function.uncurry Eq) :=\n  sorry\n\ntheorem repeat_eq_nil (α : typevec 0) : repeat_eq α = nil_fun := sorry\n\n/-- predicate on a type vector to constrain only the last object -/\ndef pred_last' {n : ℕ} (α : typevec n) {β : Type u_1} (p : β → Prop) :\n    arrow (α ::: β) (repeat (n + 1) Prop) :=\n  split_fun (typevec.const True α) p\n\n/-- predicate on the product of two type vectors to constrain only their last object -/\ndef rel_last' {n : ℕ} (α : typevec n) {β : Type u_1} (p : β → β → Prop) :\n    arrow (prod (α ::: β) (α ::: β)) (repeat (n + 1) Prop) :=\n  split_fun (repeat_eq α) (function.uncurry p)\n\n/-- given `F : typevec.{u} (n+1) → Type u`, `curry F : Type u → typevec.{u} → Type u`,\ni.e. its first argument can be fed in separately from the rest of the vector of arguments -/\ndef curry {n : ℕ} (F : typevec (n + 1) → Type u_1) (α : Type u) (β : typevec n) := F (β ::: α)\n\nprotected instance curry.inhabited {n : ℕ} (F : typevec (n + 1) → Type u_1) (α : Type u)\n    (β : typevec n) [I : Inhabited (F (β ::: α))] : Inhabited (curry F α β) :=\n  I\n\n/-- arrow to remove one element of a `repeat` vector -/\ndef drop_repeat (α : Type u_1) {n : ℕ} : arrow (drop (repeat (Nat.succ n) α)) (repeat n α) := sorry\n\n/-- projection for a repeat vector -/\ndef of_repeat {α : Type u_1} {n : ℕ} {i : fin2 n} : repeat n α i → α := sorry\n\ntheorem const_iff_true {n : ℕ} {α : typevec n} {i : fin2 n} {x : α i} {p : Prop} :\n    of_repeat (typevec.const p α i x) ↔ p :=\n  sorry\n\n-- variables  {F : typevec.{u} n → Type*} [mvfunctor F]\n\n/-- left projection of a `prod` vector -/\ndef prod.fst {n : ℕ} {α : typevec n} {β : typevec n} : arrow (prod α β) α := sorry\n\n/-- right projection of a `prod` vector -/\ndef prod.snd {n : ℕ} {α : typevec n} {β : typevec n} : arrow (prod α β) β := sorry\n\n/-- introduce a product where both components are the same -/\ndef prod.diag {n : ℕ} {α : typevec n} : arrow α (prod α α) := sorry\n\n/-- constructor for `prod` -/\ndef prod.mk {n : ℕ} {α : typevec n} {β : typevec n} (i : fin2 n) : α i → β i → prod α β i := sorry\n\n@[simp] theorem prod_fst_mk {n : ℕ} {α : typevec n} {β : typevec n} (i : fin2 n) (a : α i)\n    (b : β i) : prod.fst i (prod.mk i a b) = a :=\n  sorry\n\n@[simp] theorem prod_snd_mk {n : ℕ} {α : typevec n} {β : typevec n} (i : fin2 n) (a : α i)\n    (b : β i) : prod.snd i (prod.mk i a b) = b :=\n  sorry\n\n/-- `prod` is functorial -/\nprotected def prod.map {n : ℕ} {α : typevec n} {α' : typevec n} {β : typevec n} {β' : typevec n} :\n    arrow α β → arrow α' β' → arrow (prod α α') (prod β β') :=\n  sorry\n\ntheorem fst_prod_mk {n : ℕ} {α : typevec n} {α' : typevec n} {β : typevec n} {β' : typevec n}\n    (f : arrow α β) (g : arrow α' β') : comp prod.fst (prod.map f g) = comp f prod.fst :=\n  sorry\n\ntheorem snd_prod_mk {n : ℕ} {α : typevec n} {α' : typevec n} {β : typevec n} {β' : typevec n}\n    (f : arrow α β) (g : arrow α' β') : comp prod.snd (prod.map f g) = comp g prod.snd :=\n  sorry\n\ntheorem fst_diag {n : ℕ} {α : typevec n} : comp prod.fst prod.diag = id := sorry\n\ntheorem snd_diag {n : ℕ} {α : typevec n} : comp prod.snd prod.diag = id := sorry\n\ntheorem repeat_eq_iff_eq {n : ℕ} {α : typevec n} {i : fin2 n} {x : α i} {y : α i} :\n    of_repeat (repeat_eq α i (prod.mk i x y)) ↔ x = y :=\n  sorry\n\n/-- given a predicate vector `p` over vector `α`, `subtype_ p` is the type of vectors\nthat contain an `α` that satisfies `p` -/\ndef subtype_ {n : ℕ} {α : typevec n} (p : arrow α (repeat n Prop)) : typevec n := sorry\n\n/-- projection on `subtype_` -/\ndef subtype_val {n : ℕ} {α : typevec n} (p : arrow α (repeat n Prop)) : arrow (subtype_ p) α :=\n  sorry\n\n/-- arrow that rearranges the type of `subtype_` to turn a subtype of vector into\na vector of subtypes -/\ndef to_subtype {n : ℕ} {α : typevec n} (p : arrow α (repeat n Prop)) :\n    arrow (fun (i : fin2 n) => Subtype fun (x : α i) => of_repeat (p i x)) (subtype_ p) :=\n  sorry\n\n/-- arrow that rearranges the type of `subtype_` to turn a vector of subtypes\ninto a subtype of vector -/\ndef of_subtype {n : ℕ} {α : typevec n} (p : arrow α (repeat n Prop)) :\n    arrow (subtype_ p) fun (i : fin2 n) => Subtype fun (x : α i) => of_repeat (p i x) :=\n  sorry\n\n/-- similar to `to_subtype` adapted to relations (i.e. predicate on product) -/\ndef to_subtype' {n : ℕ} {α : typevec n} (p : arrow (prod α α) (repeat n Prop)) :\n    arrow\n        (fun (i : fin2 n) =>\n          Subtype fun (x : α i × α i) => of_repeat (p i (prod.mk i (prod.fst x) (prod.snd x))))\n        (subtype_ p) :=\n  sorry\n\n/-- similar to `of_subtype` adapted to relations (i.e. predicate on product) -/\ndef of_subtype' {n : ℕ} {α : typevec n} (p : arrow (prod α α) (repeat n Prop)) :\n    arrow (subtype_ p)\n        fun (i : fin2 n) =>\n          Subtype fun (x : α i × α i) => of_repeat (p i (prod.mk i (prod.fst x) (prod.snd x))) :=\n  sorry\n\n/-- similar to `diag` but the target vector is a `subtype_`\nguaranteeing the equality of the components -/\ndef diag_sub {n : ℕ} {α : typevec n} : arrow α (subtype_ (repeat_eq α)) := sorry\n\ntheorem subtype_val_nil {α : typevec 0} (ps : arrow α (repeat 0 Prop)) : subtype_val ps = nil_fun :=\n  sorry\n\ntheorem diag_sub_val {n : ℕ} {α : typevec n} :\n    comp (subtype_val (repeat_eq α)) diag_sub = prod.diag :=\n  sorry\n\ntheorem prod_id {n : ℕ} {α : typevec n} {β : typevec n} : prod.map id id = id := sorry\n\ntheorem append_prod_append_fun {n : ℕ} {α : typevec n} {α' : typevec n} {β : typevec n}\n    {β' : typevec n} {φ : Type u} {φ' : Type u} {ψ : Type u} {ψ' : Type u} {f₀ : arrow α α'}\n    {g₀ : arrow β β'} {f₁ : φ → φ'} {g₁ : ψ → ψ'} :\n    prod.map f₀ g₀ ::: prod.map f₁ g₁ = prod.map (f₀ ::: f₁) (g₀ ::: g₁) :=\n  sorry\n\n@[simp] theorem drop_fun_diag {n : ℕ} {α : typevec (n + 1)} : drop_fun prod.diag = prod.diag :=\n  sorry\n\n@[simp] theorem drop_fun_subtype_val {n : ℕ} {α : typevec (n + 1)}\n    (p : arrow α (repeat (n + 1) Prop)) : drop_fun (subtype_val p) = subtype_val (drop_fun p) :=\n  rfl\n\n@[simp] theorem last_fun_subtype_val {n : ℕ} {α : typevec (n + 1)}\n    (p : arrow α (repeat (n + 1) Prop)) : last_fun (subtype_val p) = subtype.val :=\n  rfl\n\n@[simp] theorem drop_fun_to_subtype {n : ℕ} {α : typevec (n + 1)}\n    (p : arrow α (repeat (n + 1) Prop)) :\n    drop_fun (to_subtype p) = to_subtype fun (i : fin2 n) (x : α (fin2.fs i)) => p (fin2.fs i) x :=\n  sorry\n\n@[simp] theorem last_fun_to_subtype {n : ℕ} {α : typevec (n + 1)}\n    (p : arrow α (repeat (n + 1) Prop)) : last_fun (to_subtype p) = id :=\n  sorry\n\n@[simp] theorem drop_fun_of_subtype {n : ℕ} {α : typevec (n + 1)}\n    (p : arrow α (repeat (n + 1) Prop)) : drop_fun (of_subtype p) = of_subtype (drop_fun p) :=\n  sorry\n\n@[simp] theorem last_fun_of_subtype {n : ℕ} {α : typevec (n + 1)}\n    (p : arrow α (repeat (n + 1) Prop)) : last_fun (of_subtype p) = id :=\n  sorry\n\n@[simp] theorem drop_fun_rel_last {n : ℕ} {α : typevec n} {β : Type u_1} (R : β → β → Prop) :\n    drop_fun (rel_last' α R) = repeat_eq α :=\n  rfl\n\n@[simp] theorem drop_fun_prod {n : ℕ} {α : typevec (n + 1)} {α' : typevec (n + 1)}\n    {β : typevec (n + 1)} {β' : typevec (n + 1)} (f : arrow α β) (f' : arrow α' β') :\n    drop_fun (prod.map f f') = prod.map (drop_fun f) (drop_fun f') :=\n  sorry\n\n@[simp] theorem last_fun_prod {n : ℕ} {α : typevec (n + 1)} {α' : typevec (n + 1)}\n    {β : typevec (n + 1)} {β' : typevec (n + 1)} (f : arrow α β) (f' : arrow α' β') :\n    last_fun (prod.map f f') = prod.map (last_fun f) (last_fun f') :=\n  sorry\n\n@[simp] theorem drop_fun_from_append1_drop_last {n : ℕ} {α : typevec (n + 1)} :\n    drop_fun from_append1_drop_last = id :=\n  rfl\n\n@[simp] theorem last_fun_from_append1_drop_last {n : ℕ} {α : typevec (n + 1)} :\n    last_fun from_append1_drop_last = id :=\n  rfl\n\n@[simp] theorem drop_fun_id {n : ℕ} {α : typevec (n + 1)} : drop_fun id = id := rfl\n\n@[simp] theorem prod_map_id {n : ℕ} {α : typevec n} {β : typevec n} : prod.map id id = id := sorry\n\n@[simp] theorem subtype_val_diag_sub {n : ℕ} {α : typevec n} :\n    comp (subtype_val (repeat_eq α)) diag_sub = prod.diag :=\n  sorry\n\n@[simp] theorem to_subtype_of_subtype {n : ℕ} {α : typevec n} (p : arrow α (repeat n Prop)) :\n    comp (to_subtype p) (of_subtype p) = id :=\n  sorry\n\n@[simp] theorem subtype_val_to_subtype {n : ℕ} {α : typevec n} (p : arrow α (repeat n Prop)) :\n    comp (subtype_val p) (to_subtype p) = fun (_x : fin2 n) => subtype.val :=\n  sorry\n\n@[simp] theorem to_subtype_of_subtype_assoc {n : ℕ} {α : typevec n} {β : typevec n}\n    (p : arrow α (repeat n Prop)) (f : arrow β (subtype_ p)) :\n    comp (to_subtype p) (comp (of_subtype fun (i : fin2 n) (x : α i) => p i x) f) = f :=\n  sorry\n\n@[simp] theorem to_subtype'_of_subtype' {n : ℕ} {α : typevec n}\n    (r : arrow (prod α α) (repeat n Prop)) : comp (to_subtype' r) (of_subtype' r) = id :=\n  sorry\n\ntheorem subtype_val_to_subtype' {n : ℕ} {α : typevec n} (r : arrow (prod α α) (repeat n Prop)) :\n    comp (subtype_val r) (to_subtype' r) =\n        fun (i : fin2 n)\n          (x :\n          Subtype fun (x : α i × α i) => of_repeat (r i (prod.mk i (prod.fst x) (prod.snd x)))) =>\n          prod.mk i (prod.fst (subtype.val x)) (prod.snd (subtype.val x)) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/typevec_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834734, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.4760506855221188}}
{"text": "import «09_lib»\n\nset_option pp.beta true\nset_option pp.coercions false\n\n/-\nLe bouquet final\n\nCette feuille utilise tout le cours de Math 114 pour démontrer de nombreux\nthéorèmes parmi les plus subtils de Math 101 : la caractérisation\nséquentielle des bornes supérieures, l'équivalence entre continuité\nséquentielle et continuité, le fait que toute fonction continue sur un segment\nest majorée et atteint son maximum, et enfin le théorème des valeurs\nintermédiaires.\n\nIl est inutile d'aborder cette feuille sans être à l'aise avec les feuilles\nprécédentes (à l'exception de la feuille 7bis facultative). Réviser les\nfeuilles précédentes et poser des questions est toujours une bonne idée.\n\nOn commence par un échauffement, une variante du\n\n  lim_le (hu : limite_suite u x) (ineg : ∀ n, u n ≤ y) : x ≤ y\n\nde la feuille 8, avec l'autre inégalité et seulement à partir d'un certain rang.\n\nOn rappelle qu'on a la commande linarith' qui est une version légèrement\naméliorée de linarith (cf. feuille 8).\n\nOn pourra aussi utiliser les lemmes habituels :\n\n  abs_inferieur_ssi (x y : ℝ) : |x| ≤ y ↔ -y ≤ x ∧ x ≤ y\n\n  superieur_max_ssi (p q r) : r ≥ max p q  ↔ r ≥ p ∧ r ≥ q\n\n  inferieur_max_gauche p q : p ≤ max p q\n\n  inferieur_max_droite p q : q ≤ max p q\n\nainsi que le lemme\n\n  inferieur_si_inferieur_plus_eps : (∀ ε > 0, y ≤ x + ε) →  y ≤ x\n\ndémontré dans la feuille 8\n-/\n\n-- Si u tend vers x et y ≤ u_n pour n assez grand n alors y ≤ x.\nlemma le_lim {x y : ℝ} {u : ℕ → ℝ} (hu : limite_suite u x)\n  (ineg : ∃ N, ∀ n ≥ N, y ≤ u n) : y ≤ x :=\nbegin\n  sorry\nend\n\n/-\nLe premier objectif sérieux de cette feuille est de démontrer la caractérisation\nséquentielle des bornes supérieures. Pour cela, et pour les objectifs suivants,\nnous aurons besoin de pas mal de choses des feuilles précédentes, et de\nquelques extras.\n\nNous avons démontré dans la feuille 5 qu'une suite constante converge vers\nsa valeur :\n\n  lim_constante (x : ℝ) : limite_suite (λ n, x) x\n\net le théorème des gendarmes :\n\n  gendarmes (lim_u : limite_suite u l) (lim_w : limite_suite w l)\n    (hu : ∀ n, u n ≤ v n) (hw : ∀ n, v n ≤ w n)  : limite_suite v l\n\nDans la feuille 8, nous avons introduit les deux définitions :\n\n  Le réel x est un majorant de l'ensemble de réels A :\n  def majorant (A : set ℝ) (x : ℝ) := ∀ a ∈ A, a ≤ x\n\n  Le réel x est une  borne supérieure de l'ensemble de réels A :\n  def borne_sup (A : set ℝ) (x : ℝ) := majorant A x ∧ ∀ y, majorant A y → x ≤ y\n\net montré que si un réel x est borne supérieure d'un ensemble de réels A alors,\npour tout y, si y < x alors il existe a dans A strictement plus grand que y.\n\n  lt_sup (hx : borne_sup A x) : ∀ y, y < x → ∃ a ∈ A, y < a :=\n\nDans les exercices suivants, on pourra aussi utiliser les lemmes\n\n  inv_succ_pos : ∀ n : ℕ, 1/(n + 1 : ℝ) > 0\n\n  limite_inv_succ :  ∀ ε > 0, ∃ N : ℕ, ∀ n ≥ N, 1/(n + 1 : ℝ) ≤ ε\n\net les conséquences faciles suivantes de limite_inv_succ :\n\n  limite_si_inferieur_un_sur (h : ∀ n, |u n - x| ≤ 1/(n+1)) : limite_suite u x\n\n  lim_plus_un_sur (x : ℝ) : limite_suite (λ n, x + 1/(n+1)) x\n\n  lim_moins_un_sur (x : ℝ) : limite_suite (λ n, x - 1/(n+1)) x\n\nLa structure de la démonstration est offerte. Les accolades servent à\ndélimiter les objectifs intermédiaires, tout en faisant provisoirement\ndisparaître l'affichage des objectifs en attente. Il ne faut surtout pas\nles supprimer, sous peine de se perdre irrémédiablement.\n\nEnfin on notera l'apparition dans la structure de démonstration ci-dessous\nde la commande « choose ». Cette commande est décrite dans la dernière section\ndu chapitre 3 du cours, intitulée « Utilisation d'un ∀x, ∃y et axiome du choix »\n(qu'il convient donc de relire ou de lire), mais n'était pas encore apparue\ndans les exercices.\n-/\n\n-- Un réel x est borne supérieure d'un ensemble de réels A ssi il est\n-- majorant de A et il existe une suite d'éléments de A qui tend vers x.\nlemma borne_sup_ssi (A : set ℝ) (x : ℝ) :\n(borne_sup A x) ↔ (majorant A x ∧ ∃ u : ℕ → ℝ, limite_suite u x ∧ ∀ n, u n ∈ A ) :=\nbegin\n  split,\n  { intro h,\n    split,\n    {\n      sorry\n    },\n    { have : ∀ n : ℕ, ∃ a ∈ A, x - 1/(n+1) < a,\n      { intros n,\n        have : 1/(n+1 : ℝ) > 0,\n          exact inv_succ_pos n,\n        sorry\n      },\n      choose u hu using this,\n      sorry\n  } },\n  { rintro ⟨maj, u, limu, u_in⟩, -- Cette syntaxe regroupe intro et trois cases :\n  -- intro h, cases h with maj min, cases min with u hu, cases hu with limu u_in,\n    sorry\n  },\nend\n\n/-\nLes autres exercices de cette feuille utiliseront la définition de la\ncontinuité d'une fonction de ℝ dans ℝ en un point de ℝ.\n-/\n\n/-- La fonction `f` est continue en `x₀`. -/\ndef continue_en (f : ℝ → ℝ) (x₀ : ℝ) : Prop :=\n∀ ε > 0, ∃ δ > 0, ∀ x, |x - x₀| ≤ δ → |f x - f x₀| ≤ ε\n\n-- Dans la suite, f désignera une fonction de ℝ dans ℝ, x₀ un réel et u\n-- une suite de réels\nvariables {f : ℝ → ℝ} {x₀ : ℝ} {u : ℕ → ℝ}\n\n/-\nOn commence par un échauffement concernant définition de la continuité.\n-/\n\n/-- Une fonction continue en x₀ est séquentiellement continue en x₀ -/\nlemma seq_continue_si_continue (hf : continue_en f x₀)\n  (hu : limite_suite u x₀) : limite_suite (f ∘ u) (f x₀) :=\nbegin\n  sorry\nend\n\n/-\nLa réciproque de du lemme précédent est vraie aussi :\nLa continuité séquentielle en x₀ implique la continuité en x₀.\nMais la démonstration est moins courte. On pourra s'inspirer de\nla démonstration de borne_sup_ssi (et du poly de math 101 !).\n-/\nexample :\n  (∀ u : ℕ → ℝ, limite_suite u x₀ → limite_suite (f ∘ u) (f x₀)) →\n  continue_en f x₀ :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, étant donnés deux réels,\non utilise la notation habituelle [a, b] pour désigner le segment [a, b].\nAttention, si par malheur b < a alors ce segment est vide. C'est un peu\nune question de convention, mais notre définition d'un segment assure le\nlemme suivant (dont l'utilisation est rarement nécessaire vu qu'il ne fait que\ndéplier une définition).\n-/\n\nlemma dans_segment {a b x : ℝ}  : x ∈ [a, b] ↔ a ≤ x ∧ x ≤ b :=\niff.rfl -- cette ligne signifie : « C'est équivalent par définition. »\n\n/-\nNous avons vu dans la feuille 6 les définitions et le lemme :\n\nUne extraction est une fonction strictement croissante de ℕ dans ℕ :\n\n  def extraction (φ : ℕ → ℕ) := ∀ n m, n < m → φ n < φ m\n\nUn réel a est valeur d'adhérence d'une suite u s'il\nexiste une suite extraite de u qui tend vers a.\n\n  def valeur_adherence (u : ℕ → ℝ) (a : ℝ) :=\n    ∃ φ, extraction φ ∧ limite_suite (u ∘ φ) a\n\nToute extraction est supérieure à l'identité :\n\n  extraction_superieur_id : extraction φ → ∀ n, n ≤ φ n\n\nEt dans la feuille 8 la définition et le lemme :\n\nLa suite u tend vers +∞.\n\n  def limite_infinie_suite (u : ℕ → ℝ) := ∀ A, ∃ N, ∀ n ≥ N, u n ≥ A\n\nSi u tend vers +∞ alors u ne tend vers aucune limite finie\n\n  limite_infinie_pas_finie : limite_infinie_suite u → ∀ l, ¬ limite_suite u l\n-/\n\n-- Dans la suite, φ sera une fonction de ℕ dans ℕ\nvariables {φ : ℕ → ℕ}\n\n\n/-- Si `u` tend vers `+∞` alors toutes ses suites extraites tendent vers `+∞`. -/\nlemma limite_infinie_extraction_si_limite\n  (h : limite_infinie_suite u) (hφ : extraction φ) :\nlimite_infinie_suite (u ∘ φ) :=\nbegin\n  sorry\nend\n\nlemma limite_infinie_gendarme {u v : ℕ → ℝ} (hu : limite_infinie_suite u)\n(huv : ∀ n, u n ≤ v n) : limite_infinie_suite v :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, on pourra aussi utiliser le théorème de Bolzano-Weirstrass :\n\nToute suite à valeur dans un segment [a, b] admet une valeur d'adhérence\ndans [a, b].\n\n  bolzano_weierstrass (h : ∀ n, u n ∈ [a, b]) :\n    ∃ c ∈ [a, b], valeur_adherence u c\n\nCe théorème se démontre à partir du théorème de la borne supérieure, mais il\nfaut construire une suite par récurrence, ce que nous n'avons pas appris à\nfaire dans Lean.\n\nOn pourra utiliser aussi le lemme suivant, qui lui est évident\n\n  limite_suite_id : limite_infinie_suite (λ n, n)\n-/\n\n-- Toute fonction continue sur un segment y est majorée.\nlemma majoree_segment {f : ℝ → ℝ} {a b : ℝ} (hf : ∀ x ∈ [a, b], continue_en f x) :\n∃ M, ∀ x ∈ [a, b], f x ≤ M :=\nbegin\n  sorry\nend\n\n/-\nPour l'exercice suivant, on pourra utiliser le lemme\n\n  abs_neg x : |-x| = |x|\n-/\n\n-- Si f est continue en x₀ alors -f est aussi continue en x₀\nlemma continue_opposee {f : ℝ → ℝ} {x₀ : ℝ} (h : continue_en f x₀) :\n  continue_en (λ x, -f x) x₀ :=\nbegin\n  sorry\nend\n\n-- Toute fonction continue sur un segment y est minorée.\nlemma minoree_segment {f : ℝ → ℝ} {a b : ℝ} (hf : ∀ x ∈ [a, b], continue_en f x) :\n∃ m, ∀ x ∈ [a, b], m ≤ f x :=\nbegin\n  have : ∃ M, ∀ x ∈ [a, b], -f x ≤ M,\n  {\n    sorry\n  },\n  sorry\nend\n\n/-\nNous avons démontré dans la feuille 5 qu'une suite a au plus une limite :\n\n unicite_limite : limite_suite u l → limite_suite u l' → l = l'\n\net démontré dans la feuille 6 que,si u tend vers l alors toutes ses suites\nextraites tendent vers l :\n\n  limite_extraction_si_limite (h : limite_suite u l) (hφ : extraction φ) :\n    limite_suite (u ∘ φ) l\n\nOn admet une version du théorème de la borne supérieure (qu'on ne peut pas\ndémontrer sans construire les nombres réels ou admettre un autre théorème\naussi fort) :\n\nsup_segment {a b : ℝ} {A : set ℝ} (hnonvide : ∃ x, x ∈ A) (h : A ⊆ [a, b]) :\n  ∃ x ∈ [a, b], borne_sup A x\n\nDans l'exercice suivant, il peut être utile de démontrer une inclusion\nentre ensembles A et B de nombres réels.\nPar définition, A ⊆ B signifie : ∀ x, x ∈ A → x ∈ B.\nOn peut donc commencer la démonstration de A ⊆ B par « intros x x_dans_A »\nqui fait apparaître « x : ℝ » et « x_dans_A : x ∈ A  » dans le contexte,\npuis démontrer x ∈ B.\n\nOn remarquera aussi l'utilisation de la notation\n  {x | P x}\nqui désigne l'ensemble des x vérifiant le prédicat P.\nPar exemple, la définition du segment [a, b] est :\n[a, b] = { x | a ≤ x ∧ x ≤ b }\n\nAinsi l'énoncé x' ∈ { x | P x} signifie P x', par définition.\n\nLa structure de la démonstration suivante vous est offerte. On notera aussi\nau passage (mais sans nécessairement essayer de les retenir) l'apparition\nde plusieurs commandes Lean permettant de rassembler en une ligne une\nfastidieuse série de intros et cases. Toutes ces démonstrations peuvent\nse faire sans commande nouvelle, mais leur complexité justifie d'investir\ndans des raccourcis.\n-/\n\n/-- Toute fonction continue sur un segment non vide y admet un maximum. -/\nexample {a b : ℝ} (hab : a ≤ b) (hf : ∀ x ∈ [a, b], continue_en f x) :\n∃ x₀ ∈ [a, b], ∀ x ∈ [a, b], f x ≤ f x₀ :=\nbegin\n  cases minoree_segment hf with m hm,\n  cases majoree_segment hf with M hM,\n  let A := {y | ∃ x ∈ [a, b], y = f x}, -- A est l'image de [a, b] par f\n  -- La commande obtain n'est pas à retenir, c'est un raccourci\n  -- pour un have et deux cases\n  obtain ⟨y₀, y_dans, y_sup⟩ : ∃ y₀ ∈ [m, M], borne_sup A y₀,\n  {\n    sorry\n  }, -- Bien observer le contexte après ce obtain\n  rw borne_sup_ssi at y_sup,\n  -- encore un raccourci pour remplacer trois cases\n  rcases y_sup with ⟨y_maj, u, lim_u, u_dans⟩,\n  choose v hv using u_dans,\n  -- Et un dernier raccourci pour la route\n  cases forall_and_distrib.mp hv with v_dans hufv,\n  -- On reformule l'hypothèse hufv par une dernière commande exotique\n  replace hufv : u = f ∘ v := funext hufv,\n  sorry\nend\n\n-- Malheureusement linarith ne fait pas tout seul le lemme suivant\nlemma stupide {a b x : ℝ} (h : x ∈ [a, b]) (h' : x ≠ b) : x < b :=\nlt_of_le_of_ne h.right h'\n\n/-\nEt maintenant le boss final...\n-/\n\n/-- Le théorème des valeurs intermédiaires -/\nexample (f : ℝ → ℝ) (hf : ∀ x, continue_en f x) (h₀ : f 0 < 0) (h₁ : f 1 > 0) :\n∃ x₀ ∈ [0, 1], f x₀ = 0 :=\nbegin\n  let A := { x | x ∈ [0, 1] ∧ f x < 0},\n  have ex_x₀ : ∃ x₀ ∈ [0, 1], borne_sup A x₀,\n  {\n    sorry\n  },\n  rcases ex_x₀ with ⟨x₀, x₀_dans, x₀_sup⟩,\n  use [x₀, x₀_dans],\n  have : f x₀ ≤ 0,\n  {\n    sorry\n  },\n  have x₀_1: x₀ < 1,\n  {\n    sorry\n  },\n  have : f x₀ ≥ 0,\n  { have dans : ∃ N : ℕ, ∀ n ≥ N, x₀ + 1/(n+1) ∈ [0, 1],\n    { have : ∃ N : ℕ, ∀ n≥ N, 1/(n+1 : ℝ) ≤ (1-x₀)/2,\n      {\n        sorry\n      },\n      sorry\n    },\n    have pas_dans : ∀ n : ℕ, x₀ + 1/(n+1) ∉ A,\n    -- Par définition, x ∉ A signifie « non (x ∈ A) ».\n    {\n      sorry\n    },\n    dsimp [A] at pas_dans, -- il est inutile de retenir cette commande\n    sorry\n  },\n  linarith,\nend\n\n\n", "meta": {"author": "dEAduction", "repo": "dEAduction-lean", "sha": "4fe1d642078fc94f9081ccbed08e047e86a741fd", "save_path": "github-repos/lean/dEAduction-dEAduction-lean", "path": "github-repos/lean/dEAduction-dEAduction-lean/dEAduction-lean-4fe1d642078fc94f9081ccbed08e047e86a741fd/PM/09/exos/09_final.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.4760506774473224}}
{"text": "import tactic.induction\nimport data.nat.prime\nimport data.nat.modeq\nimport logic.function.iterate\n\nnoncomputable theory\nopen_locale classical\n\ndef get_some {α : Type} [inhabited α] (P : α → Prop) : α :=\nif h : ∃ (x : α), P x then h.some else default\n\ndef reduce {α : Type} [inhabited α] (f : α → α) (x : α) : α := get_some\n(λ (r : α), ∃ (n : ℕ), (f^[n]) x = r ∧ (f^[n + 1]) x = r)\n\ndef digits (n : ℕ) : list ℕ := get_some\n(λ (ds : list ℕ), (∀ (d ∈ ds), d ≤ 9) ∧ ds.foldl (λ a d, a * 10 + d) 0 = n)\n\ndef digits_sum (n : ℕ) : ℕ := (digits n).sum\ndef digital_root (n : ℕ) : ℕ := reduce digits_sum n\n\nlemma digital_root_eq {n : ℕ} :\n  digital_root n = ite (n % 9 = 0) 9 (n % 9) :=\nbegin\n  sorry\nend\n\nlemma num_3_dvd_of_mod_9_eq_3_or_6 {n : ℕ}\n  (h : n % 9 = 3 ∨ n % 9 = 6) : 3 ∣ n :=\nbegin\n  have h₁ : n % 9 % 3 = 0, { cases h; rw h; dec_trivial },\n  rw nat.mod_mod_of_dvd at h₁, swap, { dec_trivial },\n  exact nat.dvd_of_mod_eq_zero h₁,\nend\n\nlemma num_3_dvd_of_mod_9_eq_3 {n : ℕ} (h : n % 9 = 3) : 3 ∣ n :=\nnum_3_dvd_of_mod_9_eq_3_or_6 (or.inl h)\n\nlemma num_3_dvd_of_mod_9_eq_6 {n : ℕ} (h : n % 9 = 6) : 3 ∣ n :=\nnum_3_dvd_of_mod_9_eq_3_or_6 (or.inr h)\n\nlemma prime_mod_9 {n : ℕ}\n  (h₁ : 3 < n)\n  (h₂ : prime n) :\n  n % 9 ∈ ({1, 2, 4, 5, 7, 8} : set ℕ) :=\nbegin\n  rw ←nat.prime_iff at h₂, replace h₂ := h₂.2,\n  obtain ⟨n, rfl⟩ := nat.exists_eq_add_of_lt h₁,\n  let k := n + 4, replace h₁ : 3 + n + 1 = k, { rw [add_comm 3, add_assoc] },\n  generalize hm : k % 9 = m, rw h₁ at h₂ ⊢, rw hm, replace h₁ : m < 9,\n  { rw ←hm, exact nat.mod_lt _ dec_trivial }, cases m,\n  { specialize h₂ 3 (k / 3), have h₃ : 3 * 3 ∣ k := nat.dvd_of_mod_eq_zero hm,\n    have h₄ : k / 3 * 3 = k := nat.div_mul_cancel (dvd_of_mul_left_dvd h₃),\n    rw mul_comm at h₄, specialize h₂ h₄.symm, simp at h₂, rw h₂ at h₄,\n    rw ←h₄ at h₃, contrapose h₃, dec_trivial },\n  cases m, { simp }, cases m, { simp }, cases m,\n  { specialize h₂ 3 (k / 3), have h₃ : 3 ∣ k := num_3_dvd_of_mod_9_eq_3 hm,\n    have h₄ : k / 3 * 3 = k := nat.div_mul_cancel h₃, rw mul_comm at h₄,\n    specialize h₂ h₄.symm, simp at h₂, rw h₂ at h₄, cases h₄ },\n  cases m, { simp }, cases m, { simp }, cases m,\n  { specialize h₂ 3 (k / 3), have h₃ : 3 ∣ k := num_3_dvd_of_mod_9_eq_6 hm,\n    have h₄ : k / 3 * 3 = k := nat.div_mul_cancel h₃, rw mul_comm at h₄,\n    specialize h₂ h₄.symm, simp at h₂,rw h₂ at h₄, cases h₄ },\n  cases m, { simp }, cases m, { simp },\n  change m + 9 < 9 at h₁, contrapose! h₁, exact le_add_self,\nend\n\nexample {n : ℕ}\n  (h₁ : 3 < n)\n  (h₂ : prime n)\n  (h₃ : prime (n + 2)) :\n  digital_root (n * (n + 2)) = 8 :=\nbegin\n  rw digital_root_eq,\n  split_ifs with hx,\n  {\n    exfalso,\n    rw [nat.mul_mod, ←nat.dvd_iff_mod_eq_zero] at hx,\n    cases hx with x hx,\n    sorry\n  },\n  sorry;{ rw [nat.mul_mod, nat.add_mod],\n    have hn : 3 < n + 2 := lt_trans h₁ (lt_add_of_pos_right n dec_trivial),\n    replace h₂ := prime_mod_9 h₁ h₂, replace h₃ := prime_mod_9 hn h₃,\n    rw nat.add_mod at h₃, rcases h₂ with h | h | h | h | h | h; change _ = _ at h;\n    { rw h at h₃, contrapose h₃, simp, try { dec_trivial }} <|>\n    { rw h, dec_trivial }},\nend", "meta": {"author": "user7230724", "repo": "lean-projects", "sha": "ab9a83874775efd18f8c5b867e480bae4d596b31", "save_path": "github-repos/lean/user7230724-lean-projects", "path": "github-repos/lean/user7230724-lean-projects/lean-projects-ab9a83874775efd18f8c5b867e480bae4d596b31/src/other/twin_primes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738057795403, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.47601428864353057}}
{"text": "import combinatorics.simple_graph.coloring\n\n\n--OUTPUT 1\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n  have h1 : (G.colorable 2) → (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)), from\n  begin\n    assume h2 : (G.colorable 2),\n    -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n    have h3 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from\n    begin\n      -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n      have h4 : ∀ (A B : Type*) (h : (A ⊕ B) = V), (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) → (∀ (a b : A), ¬ (G.adj a b)), from\n      begin\n        assume (A B : Type*) (h : (A ⊕ B) = V) (h5 : (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B))),\n        assume (a b : A),\n        assume h6 : (G.adj a b),\n        have h7 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b, from by auto [h5, h6],\n        have h8 : (complete_bipartite_graph A B).adj a b, from by auto [h7],\n        have h9 : (complete_bipartite_graph A B).adj a b = ff, from by auto [h8],\n        have h10 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b = ff, from by auto [h9],\n        have h11 : (G.adj a b) = ff, from by auto [h10, h7],\n        show false, from by auto [h11, h6],\n      end,\n      have h12 : ∀ (A B : Type*) (h : (A ⊕ B) = V), (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) → (∀ (a b : B), ¬ (G.adj a b)), from\n      begin\n        assume (A B : Type*) (h : (A ⊕ B) = V) (h13 : (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B))),\n        assume (a b : B),\n        assume h14 : (G.adj a b),\n        have h15 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b, from by auto [h13, h14],\n        have h16 : (complete_bipartite_graph A B).adj a b, from by auto [h15],\n        have h17 : (complete_bipartite_graph A B).adj a b = ff, from by auto [h16],\n        have h18 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b = ff, from by auto [h17],\n        have h19 : (G.adj a b) = ff, from by auto [h18, h15],\n        show false, from by auto [h19, h14],\n      end,\n      -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n      have h20 : ∀ (A B : Type*) (h : (A ⊕ B) = V), (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) → (∀ (a b : A ⊕ B), (G.adj a b) → (∃ (a' b' : A ⊕ B), (a = a') ∧ (b = b') ∧ (a' ∈ A) ∧ (b' ∈ B))), from\n      begin\n        assume (A B : Type*) (h : (A ⊕ B) = V) (h21 : (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B))),\n        assume (a b : A ⊕ B),\n        assume h22 : (G.adj a b),\n        have h23 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b, from by auto [h21, h22],\n        have h24 : (complete_bipartite_graph A B).adj a b, from by auto [h23],\n        have h25 : (complete_bipartite_graph A B).adj a b = tt, from by auto [h24],\n        have h26 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b = tt, from by auto [h25],\n        have h27 : (G.adj a b) = tt, from by auto [h26, h23],\n        have h28 : (a ∈ A ⊕ B) ∧ (b ∈ A ⊕ B), from by auto [h22, h27],\n        have h29 : (a ∈ A) ∨ (a ∈ B), from by auto [h28.left],\n        have h30 : (b ∈ A) ∨ (b ∈ B), from by auto [h28.right],\n        have h31 : (a ∈ A) ∧ (b ∈ B), from by auto [h29, h30, h4, h12, h21],\n        have h32 : (a ∈ A) ∧ (b ∈ B) → (∃ (a' b' : A ⊕ B), (a = a') ∧ (b = b') ∧ (a' ∈ A) ∧ (b' ∈ B)), from by auto [h31],\n        show (∃ (a' b' : A ⊕ B), (a = a') ∧ (b = b') ∧ (a' ∈ A) ∧ (b' ∈ B)), from by auto [h32],\n      end,\n      have h33 : ∀ (A B : Type*) (h : (A ⊕ B) = V), (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) → (∀ (a b : A ⊕ B), (G.adj a b) → (∃ (a' b' : A ⊕ B), (a = a') ∧ (b = b') ∧ (a' ∈ B) ∧ (b' ∈ A))), from\n      begin\n        assume (A B : Type*) (h : (A ⊕ B) = V) (h34 : (G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B))),\n        assume (a b : A ⊕ B),\n        assume h35 : (G.adj a b),\n        have h36 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b, from by auto [h34, h35],\n        have h37 : (complete_bipartite_graph A B).adj a b, from by auto [h36],\n        have h38 : (complete_bipartite_graph A B).adj a b = tt, from by auto [h37],\n        have h39 : (cast (congr_arg _ h) (complete_bipartite_graph A B)).adj a b = tt, from by auto [h38],\n        have h40 : (G.adj a b) = tt, from by auto [h39, h36],\n        have h41 : (a ∈ A ⊕ B) ∧ (b ∈ A ⊕ B), from by auto [h35, h40],\n        have h42 : (a ∈ A) ∨ (a ∈ B\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\nBipartite Graph is two colorable\nLet $G$ be a graph. Then $G$ is 2-colorable if and only if $G$ is bipartite.\n`proof`\nLet $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue. Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n\nConversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$. Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable.\n\nQED\n\n-/\ntheorem  bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto_with_comments-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto_with_comments-3_few_shot_temperature_0_max_tokens_2000_n_1/clean_files/Bipartite Graph is two colorable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4760129654308149}}
{"text": "import topology.constructions\n\nopen topological_space\n\nlemma pi_induced_induced {ι : Sort*} {X Y : ι → Type*} [t : Π i : ι, topological_space $ Y i]\n (f : Π i, X i → Y i) : @Pi.topological_space ι X (λ i, induced (f i) (t i)) =\n  induced (λ (x : Π i, X i), (λ j,  f j (x j) : Π i, Y i)) Pi.topological_space :=\nbegin\n  dsimp [Pi.topological_space],\n  rw induced_infi,\n  simp [induced_compose]\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/pi_induced.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6001883592602049, "lm_q1q2_score": 0.4760129595606962}}
{"text": "import linear_algebra.span\n\nnamespace linear_map\nopen submodule\n\nvariables {R : Type*} {R₂ : Type*} [semiring R] [semiring R₂] {M : Type*} {M₂ : Type*}\n{τ₁₂ : R →+* R₂}\n\nsection comap\n\nvariables [add_comm_monoid M] [module R M] [add_comm_monoid M₂] [module R₂ M₂]\n(f : M →ₛₗ[τ₁₂] M₂) {p p' : submodule R M} {q q' : submodule R₂ M₂} \n\nlemma ker_eq_comap : f.ker = comap f ⊥ := rfl\n\nlemma ker_le_comap {f : M →ₛₗ[τ₁₂] M₂} : f.ker ≤ comap f q := comap_mono bot_le\n\nsection ring_hom_surjective\n\nvariable [ring_hom_surjective τ₁₂]\n\n-- This should not be primed (to match the map equivalent).\n\nlemma comap_le_comap_iff' : comap f q ≤ comap f q' ↔ f.range ⊓ q ≤ q' := \nby rw [← map_le_iff_le_comap, map_comap_eq]\n\nlemma comap_range : comap f (f.range) = ⊤ := submodule.eq_top_iff'.mpr (λ _, ⟨_, rfl⟩)\n\nlemma comap_eq_comap_range_inf : comap f q = comap f (f.range ⊓ q) :=\nby rw [comap_inf, comap_range, top_inf_eq]\n\nlemma comap_le_ker_iff : comap f q ≤ f.ker ↔ f.range ⊓ q = ⊥ :=\nby rw [ker_eq_comap, comap_le_comap_iff', le_bot_iff]\n\nlemma comap_eq_ker_iff : comap f q = f.ker ↔ f.range ⊓ q = ⊥ :=\n⟨ λ h, (comap_le_ker_iff _).mp (le_of_eq h),\n  λ h, le_antisymm ((comap_le_ker_iff _).mpr h) ker_le_comap⟩\n\nend ring_hom_surjective\n\n-- comap_map_eq and comap_map_eq_self are in the wrong file (should be in basic).\n\nend comap\n\nsection map\nvariables [ring_hom_surjective τ₁₂]\nsection monoids\n\nvariables [add_comm_monoid M] [module R M] [add_comm_monoid M₂] [module R₂ M₂]\n(f : M →ₛₗ[τ₁₂] M₂) {p p' : submodule R M} {q q' : submodule R₂ M₂}\n\nlemma map_ker : map f (f.ker) = ⊥ := (submodule.eq_bot_iff _).mpr\n(λ x h, by rcases (mem_map.mp h) with ⟨_, p, l⟩; exact l ▸ (mem_ker.mp p) )\n\nlemma map_eq_map_sup_ker : map f p = map f (p ⊔ f.ker) :=\nby rw [map_sup, map_ker, sup_bot_eq]\n\nend monoids\n\nsection group\nvariables [add_comm_group M] [module R M] [add_comm_group M₂] [module R₂ M₂]\n(f : M →ₛₗ[τ₁₂] M₂) {p p' : submodule R M} {q q' : submodule R₂ M₂}\n\nlemma range_le_map_iff : f.range ≤ map f p ↔ p ⊔ f.ker = ⊤ :=\nby rw [range_eq_map, linear_map.map_le_map_iff, top_le_iff]\n\n-- map_eq_top_iff is just a special case of this.\nlemma range_eq_map_iff : f.range = map f p ↔ p ⊔ f.ker = ⊤ :=\n⟨ λ h, (range_le_map_iff _).mp (le_of_eq h),\n  λ h, le_antisymm ((range_le_map_iff _).mpr h) map_le_range⟩\nend group\n\n-- map_le_map_iff and map_le_map_iff' should be in basic also.\n\nend map\n\nsection cmptble\nvariables \n[add_comm_monoid M] [add_comm_monoid M₂] [module R M] [module R₂ M₂] \n{f : M →ₛₗ[τ₁₂] M₂} (p p' : submodule R M) (q q' : submodule R₂ M₂) \n\ndef compatible (f : M →ₛₗ[τ₁₂] M₂) (p) (q) : Prop := p ≤ comap f q\n\nlemma cmptble_def {p q} : f.compatible p q ↔ p ≤ comap f q := by refl\n\nlemma cmptble_comap : f.compatible (comap f q) q := le_refl _\n\nlemma cmptble_bot_ker : f.compatible f.ker ⊥ := le_refl _\n\nlemma cmptble_of_cmptble_of_dom_le {p p' q}\n(hp : p' ≤ p) (hf : f.compatible p q) : f.compatible p' q := λ _ hx, hf (hp hx)\n\nlemma cmptble_of_cmptble_of_cod_le {p q q'}\n(hq : q ≤ q') (hf : f.compatible p q) : f.compatible p q' := λ _ hx, hq (hf hx)\n\nlemma cmptble_of_cmptble_of_dom_le_of_cod_le {p q p' q'}\n(hp : p' ≤ p) (hq : q ≤ q') (hf : f.compatible p q) : f.compatible p' q' := \ncmptble_of_cmptble_of_cod_le hq (cmptble_of_cmptble_of_dom_le hp hf)\n\nlemma cmptble_dom_cod_top : f.compatible ⊤ ⊤ := \ncmptble_of_cmptble_of_dom_le (le_refl _) (cmptble_comap ⊤)\n\nlemma cmptble_cod_top {p} : f.compatible p ⊤ :=\ncmptble_of_cmptble_of_dom_le le_top cmptble_dom_cod_top \n\nlemma cmptble_cod_bot_iff {p} : f.compatible p ⊥ ↔ p ≤ f.ker :=\nby rw cmptble_def; refl\n\nsection ring_hom_surjective\nvariables [ring_hom_surjective τ₁₂]\n\nlemma cmptble_def' {p q} : f.compatible p q ↔ map f p ≤ q := \n(gc_map_comap _ _ _).symm\n\nlemma cmptble_map : f.compatible p (map f p) :=\ncmptble_def'.mpr (le_refl _)\n\nlemma cmptble_top_range : f.compatible ⊤ f.range := \nby rw ←map_top; exact cmptble_of_cmptble_of_cod_le (le_refl _) (cmptble_map ⊤)\n\nlemma cmptble_dom_top_iff {q} : f.compatible ⊤ q ↔ f.range ≤ q :=\nby rw [cmptble_def', map_top f]\n\nend ring_hom_surjective\n\nlemma cmptble_iff_map_mem_of_mem {p q}: f.compatible p q ↔ ∀ x, x ∈ p → f x ∈ q := by refl\n\nlemma cmptble_dom_top_iff' {q} : f.compatible ⊤ q ↔ ∀ x, f x ∈ q :=\n⟨λ h _, h mem_top, λ h x _, h x⟩\n\nlemma cmptble_cod_bot_iff' {p} : f.compatible p ⊥ ↔ ∀ x ∈ p, f x = 0 :=\nby rw cmptble_cod_bot_iff; refl\n\n-- Should be equivalent to the existing restrict.\ndef restrict' (f : M →ₛₗ[τ₁₂] M₂) {p} {q} (hf : f.compatible p q) : p →ₛₗ[τ₁₂] q := { \n  to_fun := λ x, ⟨f x, hf x.2⟩,\n  map_add' := by { simp_rw [  subtype.ext_iff, submodule.coe_add,\n                              map_add, submodule.coe_mk], exact λ _ _, rfl},\n  map_smul' := by { simp_rw [ subtype.ext_iff, submodule.coe_smul,\n                              map_smulₛₗ, submodule.coe_mk], exact λ _ _, rfl} }\n\nlemma restrict'_apply {p} {q} {hf : f.compatible p q} {x} : (f.restrict' hf x : M₂) = f x := rfl\n\n-- Should be equivalent to the existing dom_restrict.\n-- Suggestion: linear version should be ldom_restrict? etc.\n\ndef dom_restrict'' (f : M →ₛₗ[τ₁₂] M₂) (p : submodule R M) : p →ₛₗ[τ₁₂] M₂ := \ntop_equiv.to_linear_map.comp (f.restrict' cmptble_cod_top)\n\nlemma dom_restrict''_apply {f : M →ₛₗ[τ₁₂] M₂} {p} {x} : f.dom_restrict'' p x = f x := rfl\n\nlemma dom_restrict''_cmptble_top_of_cmptble {p q} (hf : f.compatible p q) :\n(f.dom_restrict'' p).compatible ⊤ q :=\nby rw cmptble_dom_top_iff'; exact λ x, hf x.2\n\ndef cod_restrict' (f : M →ₛₗ[τ₁₂] M₂) {q} (hf : f.compatible ⊤ q) : M →ₛₗ[τ₁₂] q := \n(f.restrict' hf).comp top_equiv.symm.to_linear_map\n\nlemma cod_restrict'_apply {q} {hq : f.compatible ⊤ q} {x} : (f.cod_restrict' hq x : M₂) = f x := \nrfl\n\nlemma restrict'_eq_cod_restrict_dom_restrict' {p q} {hf : f.compatible p q} :\nf.restrict' hf = (f.dom_restrict'' p).cod_restrict' (dom_restrict''_cmptble_top_of_cmptble hf) := \nrfl\n\nlemma restrict'_eq_dom_restrict_cod_restrict' {p q} {hf : f.compatible ⊤ q} :\nf.restrict' (cmptble_of_cmptble_of_dom_le le_top hf) = (f.cod_restrict' hf).dom_restrict'' p := \nrfl\n\nend cmptble\n\n-- To add:\n/-\n(_ ⧸ (p ⊓ f.ker).comap p.subtype) ≃ₗ[R] p.map f\nrank f.range ⊔ q + rank q.comap f = rank M + rank q\n(?) corank q = corank q.comap f + corank (f.range ⊔ q)\n\nShould link \"compatible\" with the corresponding stuff in the quotient space.\n\n-/\n\nend linear_map", "meta": {"author": "linesthatinterlace", "repo": "goppadecoding", "sha": "294f31a0dd56ad9497f3a9585190cdd54f064d7f", "save_path": "github-repos/lean/linesthatinterlace-goppadecoding", "path": "github-repos/lean/linesthatinterlace-goppadecoding/goppadecoding-294f31a0dd56ad9497f3a9585190cdd54f064d7f/src/to_mathlib/linear_algebra/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4758918026784483}}
{"text": "import topology.basic\nimport topology.metric_space.basic\nimport topology.continuous_function.basic\nimport topology.homotopy.fundamental_groupoid\nimport analysis.normed_space.basic\nimport analysis.special_functions.trigonometric.basic\n\nimport .pointed_space\n\ndef disk : set (ℝ × ℝ) := metric.closed_ball (0 : ℝ × ℝ) 1\ndef circle : set (ℝ × ℝ) := metric.sphere (0 : ℝ × ℝ) 1\ndef pt : ℝ × ℝ := (1, 0)\n\nnoncomputable def disk.pointed_space : pointed_space disk :=\npointed_space.mk\n  (subtype.mk pt (by simp [pt, disk, norm]))\n\nnoncomputable def circle.pointed_space : pointed_space circle :=\npointed_space.mk\n  (subtype.mk pt (by simp [pt, circle, norm]))\n\ninstance inhabited.disk : inhabited disk :=\n⟨subtype.mk pt (by simp [pt, disk, norm])⟩\n\nlemma frontier_disk_eq_circle : frontier disk = circle :=\nbegin\n  simp [disk, circle],\n  rw frontier_closed_ball,\n  linarith,\nend\n\n/--\nDefines the identity homeomorphism between the boundary of the disk and the circle.\n-/\nnoncomputable def frontier_disk_homeo_circle : frontier disk ≃ₜ circle := {\n  to_fun := λx, subtype.mk (↑x) (begin rw ← frontier_disk_eq_circle, simp, end),\n  inv_fun := λx, subtype.mk (↑x) (begin rw frontier_disk_eq_circle, simp, end),\n  left_inv :=\n    begin\n      intro x,\n      simp,\n    end,\n  right_inv :=\n    begin\n      intro x,\n      simp,\n    end,\n}\n\nlemma frontier_subset_closed_set {α : Type} [topological_space α] (X : set α) :\n  is_closed X → frontier X ⊆ X :=\nbegin\n  intro hclosed,\n  have hfx_sub_fxd : frontier X ⊆ X \\ interior X :=\n    by rw is_closed.frontier_eq hclosed,\n  have hfxd_sub_x : X \\ interior X ⊆ X :=\n    set.diff_subset X (interior X),\n  apply has_subset.subset.trans hfx_sub_fxd hfxd_sub_x,\nend\n\nlemma frontier_disk_subset_disk :\n  frontier disk ⊆ disk :=\nfrontier_subset_closed_set disk metric.is_closed_ball\n\ninstance has_lift.frontier_disk : has_lift (frontier disk) (disk) := {\n  lift := begin\n    intro fd,\n    cases fd,\n    have fd_val_in_disk : fd_val ∈ disk :=\n      frontier_disk_subset_disk fd_property,\n    exact subtype.mk fd_val fd_val_in_disk,\n  end\n}\n\nnoncomputable def frontier_disk.pointed_space : pointed_space (frontier disk) :=\npointed_space.mk\n  (subtype.mk pt (by simp [pt, frontier_disk_eq_circle, circle, norm]))\n\ninstance disk.path_connected : path_connected_space disk := {\n  nonempty := nonempty_of_pointed_space disk.pointed_space,\n  joined :=\n    begin\n      intros x y,\n      apply @nonempty_of_exists _ (λ_, true),\n      apply exists.intro,\n      tautology,\n\n      sorry,\n      -- exact {\n      --   to_fun := sorry, --λt, (↑x) + t * (↑(x - y)),\n      --   source' := sorry,\n      --   target' := sorry,\n      -- }\n    end,\n}\n\ninstance circle.path_connected : path_connected_space circle := {\n  nonempty := nonempty_of_pointed_space circle.pointed_space,\n  joined :=\n    begin\n      intros x y,\n      apply @nonempty_of_exists _ (λ_, true),\n      apply exists.intro,\n      tautology,\n\n      let x_ang : ℝ := sorry,\n      let y_ang : ℝ := sorry,\n      exact {\n        to_fun := λt,\n          subtype.mk\n            (real.cos t, real.sin t)\n            sorry,\n        source' := sorry,\n        target' := sorry,\n      },\n    end,\n}\n\ninstance frontier_disk.path_connected : path_connected_space (frontier disk) :=\nbegin\n  rw frontier_disk_eq_circle,\n  exact circle.path_connected,\nend\n", "meta": {"author": "mlavrent", "repo": "brouwer-fp-formalization", "sha": "94a23ed613d5aa7224b48f17a4c67f52a3496251", "save_path": "github-repos/lean/mlavrent-brouwer-fp-formalization", "path": "github-repos/lean/mlavrent-brouwer-fp-formalization/brouwer-fp-formalization-94a23ed613d5aa7224b48f17a4c67f52a3496251/src/disk.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4758619935471687}}
{"text": "import algebraic_geometry.ringed_space\nimport algebra.homology.exact\nimport presheaf_of_module\nimport sheaf_has_zero_morphism\nimport presheaf_of_module_has_image\nimport sheaf_has_image\n\n----------------------------------------------------------------------------------------------------\n\n-- section free_presentation\n-- universe u\n-- open Module Module.has_limits category_theory\n-- open_locale zero_object\n\n-- variable {R : CommRing.{u}}\n\n\n-- structure free_presentation (M : Module R) :=\n-- (I J : Type u)\n-- (f : (∏ function.const I (⟨R⟩ : Module R)) ⟶ (∏ function.const J (⟨R⟩ : Module R)))\n-- (g : (∏ function.const J (⟨R⟩ : Module R) ⟶ M))\n-- [exact : exact f g]\n\n-- end free_presentation\n\n----------------------------------------------------------------------------------------------------\n\nsection quasicoherent\n\nopen algebraic_geometry Top topological_space category_theory opposite\nopen_locale zero_object\n\nuniverse u\nvariables (X : RingedSpace.{u}) -- (𝓕 : sheaf_of_module X.presheaf)\n\ndef sheaf_of_module.as_SheafedSpace {T : Top} {𝓞 : presheaf CommRing T} (𝓕 : sheaf_of_module 𝓞)\n  : SheafedSpace Ab :=\n{ carrier := T,\n  presheaf := 𝓕.self,\n  is_sheaf := 𝓕.is_sheaf }\n\ndef RingedSpace.sheaf : sheaf CommRing X.carrier := ⟨X.presheaf, X.is_sheaf⟩\ndef RingedSpace.sheaf_of_Ab : sheaf Ab X.carrier :=\n⟨{ obj := λ U, ⟨X.presheaf.obj U⟩,\n   map := λ U V inc, X.presheaf.map inc,\n   map_id' := sorry,\n   map_comp' := sorry }, sorry⟩.\n\ndef RingedSpace.SheafedSpace_of_Ab : SheafedSpace Ab :=\n{ carrier := X.carrier,\n  presheaf := (RingedSpace.sheaf_of_Ab X).1,\n  is_sheaf := (RingedSpace.sheaf_of_Ab X).2 }.\n\ndef sheaf_of_module.from_sheaf_of_ring {T : Top} (𝓞 : sheaf CommRing T) : sheaf_of_module 𝓞.1 :=\n{ self :=\n  { obj := λ V, ⟨𝓞.1.obj V⟩,\n    map := λ U V inc, 𝓞.1.map inc,\n    map_id' := λ V, sorry,\n    map_comp' := λ U V W incUV incVW, sorry },\n  is_sheaf := sorry,\n  compatible := λ U V inc r m, begin\n    simp only [smul_eq_mul],\n    erw ring_hom.map_mul,\n    refl,\n  end }.\n\n/--\nIf `𝓕` is an `𝓞`-module, then we say `𝓕` is quasicoherent if and only if for every `x : X`, there is\nan `x ∈ U : opens X` such that there is an exact sequence of sheaves of abelian group of the following:\n\n```\n⨁_{i : I} (𝓞|U) ⟶ ⨁_{j : J} (𝓞|U) ⟶ 𝓕|U ⟶ 0\n```\n-/\nvariable {X}\nstructure sheaf_of_module.free_presentation_at (𝓕 : sheaf_of_module X.presheaf) (x : X) :=\n(U : opens X)\n(mem : x ∈ U)\n(I J : Type u)\n(f : (∏ function.const I ((SheafedSpace.restrict (RingedSpace.SheafedSpace_of_Ab X) (opens.open_embedding U))).sheaf) ⟶ \n    (∏ function.const J ((SheafedSpace.restrict (RingedSpace.SheafedSpace_of_Ab X) (opens.open_embedding U))).sheaf))\n(g : (∏ function.const J ((SheafedSpace.restrict (RingedSpace.SheafedSpace_of_Ab X) (opens.open_embedding U))).sheaf) ⟶\n (SheafedSpace.restrict (𝓕.as_SheafedSpace) (opens.open_embedding U)).sheaf)\n[exact1 : exact f g]\n[exact2 : exact g (0 : _ ⟶ 0)].\n\ndef sheaf_of_module.is_quasicoherent (𝓕 : sheaf_of_module X.presheaf) : Prop :=\n∀ (x : X), nonempty (sheaf_of_module.free_presentation_at 𝓕 x).\n\nvariable (X)\nstructure quasicoherent_sheaf_of_module :=\n(sheaf : sheaf_of_module X.presheaf)\n(is_quasicoherent : sheaf.is_quasicoherent)\n\nnamespace quasicoherent_sheaf_of_module\n\ninstance : category (quasicoherent_sheaf_of_module X) :=\n{ hom := λ F1 F2, F1.sheaf ⟶ F2.sheaf,\n  id := λ F, 𝟙 _,\n  comp := λ F1 F2 F3 f12 f23, f12 ≫ f23,\n  id_comp' := λ F1 F2 f, by simp,\n  comp_id' := λ F1 F2 f, by simp,\n  assoc' := λ F1 F2 F3 F4 f12 f23 f34, by simp }.\n\nvariable {X}\ndef zero_morphism (F G : quasicoherent_sheaf_of_module X) : F ⟶ G := (0 : F.sheaf ⟶ G.sheaf)\n\ninstance : limits.has_zero_morphisms (quasicoherent_sheaf_of_module X) :=\n{ has_zero := λ F G, ⟨zero_morphism F G⟩,\n  comp_zero' := λ F G f H, begin\n    ext U x,\n    simp only [presheaf_of_module.zero, limits.zero_app, AddCommGroup.zero_apply],\n    change (f.1.app U ≫ 0) x = 0,\n    simp only [limits.comp_zero, AddCommGroup.zero_apply],\n  end,\n  zero_comp' := λ F G H f, begin\n    ext U x,\n    simp only [presheaf_of_module.zero, limits.zero_app, AddCommGroup.zero_apply],\n    change (0 ≫ f.1.app U) x = 0,\n    simp only [limits.zero_comp, AddCommGroup.zero_apply],\n  end }.\n\nlemma is_quasicoherent.zero : (0 : sheaf_of_module X.presheaf).is_quasicoherent := λ x, nonempty.intro\n{ U := ⊤,\n  mem := trivial,\n  I := punit,\n  J := punit,\n  f := 𝟙 _,\n  g := 0,\n  exact1 := ⟨by ext, ⟨λ F a b h, begin\n    refine (@@cancel_epi _ _ begin apply image_to_kernel_epi_of_epi_of_zero,\n    end).mp h,\n  end⟩⟩,\n  exact2 := infer_instance }.\n\n/--\n`R --f--> R^2 --g--> R ----> 0`\n`f a = (a, 0)`\n`g (a, b) = b`\n-/\nlemma is_quasicoherent.self : (sheaf_of_module.from_sheaf_of_ring ⟨X.presheaf, X.is_sheaf⟩).is_quasicoherent := λ x, nonempty.intro\n{ U := ⊤,\n  mem := trivial,\n  I := punit,\n  J := ulift bool,\n  f := category_theory.limits.pi.lift \n    (λ b, match (ulift.down b) with\n    | tt := category_theory.limits.pi.π _ (punit.star)\n    | ff := 0\n    end),\n  g := category_theory.limits.pi.π _ (ulift.up false),\n  exact1 := sorry,\n  exact2 := sorry, }.\n\n\nend quasicoherent_sheaf_of_module\n\nend quasicoherent\n", "meta": {"author": "jjaassoonn", "repo": "quasicoherent", "sha": "d96ccacf00364afd6d0de7958024f1da10e015da", "save_path": "github-repos/lean/jjaassoonn-quasicoherent", "path": "github-repos/lean/jjaassoonn-quasicoherent/quasicoherent-d96ccacf00364afd6d0de7958024f1da10e015da/src/quasicoherent_sheaf_of_module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4758619935471687}}
{"text": "/-\nCopyright (c) 2020 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport deprecated.group\n\n/-!\n# Unbundled semiring and ring homomorphisms (deprecated)\n\nThis file is deprecated, and is no longer imported by anything in mathlib other than other\ndeprecated files, and test files. You should not need to import it.\n\nThis file defines predicates for unbundled semiring and ring homomorphisms. Instead of using\nthis file, please use `ring_hom`, defined in `algebra.hom.ring`, with notation `→+*`, for\nmorphisms between semirings or rings. For example use `φ : A →+* B` to represent a\nring homomorphism.\n\n## Main Definitions\n\n`is_semiring_hom` (deprecated), `is_ring_hom` (deprecated)\n\n## Tags\n\nis_semiring_hom, is_ring_hom\n\n-/\n\nuniverses u v w\n\nvariable {α : Type u}\n\n/-- Predicate for semiring homomorphisms (deprecated -- use the bundled `ring_hom` version). -/\nstructure is_semiring_hom {α : Type u} {β : Type v} [semiring α] [semiring β] (f : α → β) : Prop :=\n(map_zero [] : f 0 = 0)\n(map_one [] : f 1 = 1)\n(map_add [] : ∀ {x y}, f (x + y) = f x + f y)\n(map_mul [] : ∀ {x y}, f (x * y) = f x * f y)\n\nnamespace is_semiring_hom\n\nvariables {β : Type v} [semiring α] [semiring β]\nvariables {f : α → β} (hf : is_semiring_hom f) {x y : α}\n\n/-- The identity map is a semiring homomorphism. -/\nlemma id : is_semiring_hom (@id α) := by refine {..}; intros; refl\n\n/-- The composition of two semiring homomorphisms is a semiring homomorphism. -/\nlemma comp (hf : is_semiring_hom f) {γ} [semiring γ] {g : β → γ} (hg : is_semiring_hom g) :\n  is_semiring_hom (g ∘ f) :=\n{ map_zero := by simpa [map_zero hf] using map_zero hg,\n  map_one := by simpa [map_one hf] using map_one hg,\n  map_add := λ x y, by simp [map_add hf, map_add hg],\n  map_mul := λ x y, by simp [map_mul hf, map_mul hg] }\n\n/-- A semiring homomorphism is an additive monoid homomorphism. -/\nlemma to_is_add_monoid_hom (hf : is_semiring_hom f) : is_add_monoid_hom f :=\n{ ..‹is_semiring_hom f› }\n\n/-- A semiring homomorphism is a monoid homomorphism. -/\nlemma to_is_monoid_hom (hf : is_semiring_hom f) : is_monoid_hom f :=\n{ ..‹is_semiring_hom f› }\n\nend is_semiring_hom\n\n/-- Predicate for ring homomorphisms (deprecated -- use the bundled `ring_hom` version). -/\nstructure is_ring_hom {α : Type u} {β : Type v} [ring α] [ring β] (f : α → β) : Prop :=\n(map_one [] : f 1 = 1)\n(map_mul [] : ∀ {x y}, f (x * y) = f x * f y)\n(map_add [] : ∀ {x y}, f (x + y) = f x + f y)\n\nnamespace is_ring_hom\n\nvariables {β : Type v} [ring α] [ring β]\n\n/-- A map of rings that is a semiring homomorphism is also a ring homomorphism. -/\nlemma of_semiring {f : α → β} (H : is_semiring_hom f) : is_ring_hom f := {..H}\n\nvariables {f : α → β} (hf : is_ring_hom f) {x y : α}\n\n/-- Ring homomorphisms map zero to zero. -/\nlemma map_zero (hf : is_ring_hom f) : f 0 = 0 :=\ncalc f 0 = f (0 + 0) - f 0 : by rw [hf.map_add]; simp\n     ... = 0 : by simp\n\n/-- Ring homomorphisms preserve additive inverses. -/\nlemma map_neg (hf : is_ring_hom f) : f (-x) = -f x :=\ncalc f (-x) = f (-x + x) - f x : by rw [hf.map_add]; simp\n        ... = -f x : by simp [hf.map_zero]\n\n/-- Ring homomorphisms preserve subtraction. -/\nlemma map_sub (hf : is_ring_hom f) : f (x - y) = f x - f y :=\nby simp [sub_eq_add_neg, hf.map_add, hf.map_neg]\n\n/-- The identity map is a ring homomorphism. -/\nlemma id : is_ring_hom (@id α) := by refine {..}; intros; refl\n\n/-- The composition of two ring homomorphisms is a ring homomorphism. -/\n-- see Note [no instance on morphisms]\nlemma comp (hf : is_ring_hom f) {γ} [ring γ] {g : β → γ} (hg : is_ring_hom g) :\n  is_ring_hom (g ∘ f) :=\n{ map_add := λ x y, by simp [map_add hf]; rw map_add hg; refl,\n  map_mul := λ x y, by simp [map_mul hf]; rw map_mul hg; refl,\n  map_one := by simp [map_one hf]; exact map_one hg }\n\n/-- A ring homomorphism is also a semiring homomorphism. -/\nlemma to_is_semiring_hom (hf : is_ring_hom f) : is_semiring_hom f :=\n{ map_zero := map_zero hf, ..‹is_ring_hom f› }\n\nlemma to_is_add_group_hom (hf : is_ring_hom f) : is_add_group_hom f := { map_add := hf.map_add }\n\nend is_ring_hom\n\nvariables {β : Type v} {γ : Type w} [rα : semiring α] [rβ : semiring β]\n\nnamespace ring_hom\n\nsection\ninclude rα rβ\n\n/-- Interpret `f : α → β` with `is_semiring_hom f` as a ring homomorphism. -/\ndef of {f : α → β} (hf : is_semiring_hom f) : α →+* β :=\n{ to_fun := f,\n  .. monoid_hom.of hf.to_is_monoid_hom,\n  .. add_monoid_hom.of hf.to_is_add_monoid_hom }\n\n@[simp] lemma coe_of {f : α → β} (hf : is_semiring_hom f) : ⇑(of hf) = f := rfl\n\nlemma to_is_semiring_hom (f : α →+* β) : is_semiring_hom f :=\n{ map_zero := f.map_zero,\n  map_one := f.map_one,\n  map_add := f.map_add,\n  map_mul := f.map_mul }\n\nend\n\nlemma to_is_ring_hom {α γ} [ring α] [ring γ] (g : α →+* γ) : is_ring_hom g :=\nis_ring_hom.of_semiring g.to_is_semiring_hom\n\nend ring_hom\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/deprecated/ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4758567318345003}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := begin\n    ext,\n    split,\n    {\n      assume h,\n      cases h with h1 h2,\n      rcases h2 with ⟨n, hn⟩,\n      use [n, hn],\n    },{\n      assume h,\n      cases h with h1 h2,\n      use 0,\n      unfold closure,\n      use {x : ℤ | (α * x) - ↑x},\n      use h2,\n      rw ← h1,\n      rw set.mem_Icc,\n      linarith,\n    }\nend\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j),\n  from\n    begin\n      assume i j hij,\n      assume h2 : int.fract (α * ↑i) = int.fract (α * ↑j),\n      have h3 : α * ↑i = α * ↑j, from by auto [int.fract_eq] using [h2],\n      have h4 : α = (↑i - ↑j)*⁻¹*(↑i - ↑j), from by auto using [h3, mul_eq_inv_mul_left, zero_ne_one, hα_irrat],\n      have h5 : α = (↑j - ↑i)*⁻¹*(↑j - ↑i), from by auto [h4],\n      have h6 : α = (↑j - ↑i)*⁻¹*(↑i - ↑j), from by auto [h5, mul_comm],\n      have h7 : α = (↑j - ↑i)*⁻¹*(↑i - ↑j), from by auto [h6, h4, mul_comm],\n      have h8 : α = (↑j - ↑i)*⁻¹, from by auto [h7, one_mul],\n      have h9 : α = (↑i - ↑j)*⁻¹, from by auto [h8, mul_comm],\n      have h10 : (↑j - ↑i)*⁻¹ = (↑i - ↑j)*⁻¹, from by auto [h9, h8],\n      have h11 : (↑j - ↑i) = (↑i - ↑j), from by auto using [inv_eq_inv],\n      rw h11 at hij,\n      exact absurd hij dec_trivial,\n    end,\n  have h2 : ∀ i j ∈ @set.univ ℤ, i ≠ j → int.fract (α * ↑ i) ≠ int.fract (α * ↑ j), from by auto [h1],\n  have h3 : ∀ i : ℤ, i ∈ @set.univ ℤ → i ≠ 0, from by auto [eq_zero_iff_iff_neg_eq_zero],\n  \n  have h4 : ∀ (x y : ℤ) (hx : x ∈ @set.univ ℤ) (hy : y ∈ @set.univ ℤ), ∃ (n : ℤ), n ≠ 0 ∧ int.fract (n * x) = int.fract (n * y),\n  from\n    begin\n      assume (x y : ℤ) (hx : x ∈ @set.univ ℤ) (hy : y ∈ @set.univ ℤ),\n      cases decidable.em (x = y) with hxey hyey,\n      { use 1,\n        have h2 : int.fract (1 * x) = int.fract (1 * y), from by auto [hxey],\n        rwa ← h2 at hxey, \n        from and.intro hxey dec_trivial,\n      },\n      { use 1,\n        have h2 : int.fract (1 * x) = int.fract (1 * y), from by auto [int.fract_mul, int.fract_mul],\n        rw h2 at hyey,\n        from and.intro hyey dec_trivial,\n      }\n    end,\n\n  have h5 : ∀ i ∈ @set.univ ℤ, ∃ n : ℕ, ∀ j ∈ @set.univ ℤ, j ≠ i → int.fract (↑ n * i) ≠ int.fract (↑ n * j),\n  from\n    begin\n      assume i hi,\n      cases nat.find (λ n, ∀ j ∈ @set.univ ℤ, j ≠ i → int.fract (↑n * i) ≠ int.fract (↑n * j)) with h6 h7,\n      use h6,\n      assume j hj,\n      assume h8 : j ≠ i,\n      have h9 : ∀ (x y : ℤ) (hx : x ∈ @set.univ ℤ) (hy : y ∈ @set.univ ℤ), ∃ (n : ℤ), n ≠ 0 ∧ int.fract (n * x) = int.fract (n * y), from by auto [h4],\n      have h10 : ∃ (n : ℤ), n ≠ 0 ∧ int.fract (n * i) = int.fract (n * j), from by auto [h9, hi, hj, h8],\n      cases h10 with n h11,\n      have h12 : n ≠ 0, from and.left h11,\n      have h13 : int.fract (n * i) = int.fract (n * j), from and.right h11,\n      have h14 : int.nat_abs n ≤ h6, from by auto [h12, nat.find_spec, h7, hj, hi, h13, h8],\n      rw h13 at h8,\n      exact absurd h8 dec_trivial,\n    end,\n\n  have h6 : ∀ i j ∈ @set.univ ℤ, i ≠ j → ∃ n : ℕ, ∀ k ∈ @set.univ ℤ, k ≠ i → k ≠ j → int.fract (↑ n * i) ≠ int.fract (↑ n * k),\n  from\n    begin\n      assume i j hi hj hi_ne_hj,\n      have h1 := h5 i hi,\n      have h2 := h5 j hj,\n      have h3 : (λ (k : ℕ), k^2) ∈ set.range (λ (n : ℕ), n^2), from by auto [pow_two],\n      have h4 : ∃ (n : ℕ), int.nat_abs (↑n * i - ↑n * j) < int.nat_abs (↑n * i),\n      from\n        begin\n          cases set.never_equal_to_this : (λ (n : ℕ), int.nat_abs (↑n * i - ↑n * j) < int.nat_abs (↑n * i)) with h5 h6,\n          { use 1,\n            rw h6,\n            have h7 : int.nat_abs (↑(1) * i - ↑(1) * j) < int.nat_abs (↑(1) * i), from by auto [hj, hi, hi_ne_hj, int.nat_abs_neg, int.nat_abs_of_nonneg, int.le_add_left],\n            rw int.nat_abs_of_nonneg (zero_le _) at h5,\n            have h8 : int.nat_abs (↑(1) * i - ↑(1) * j) < int.nat_abs (↑(1) * i), from by auto [hj, hi, hi_ne_hj, int.nat_abs_neg, int.nat_abs_of_nonneg, int.le_add_left],\n            rw int.nat_abs_of_nonneg (zero_le _) at h5,\n            exact h8,\n          },\n          { cases h4 with h5 h5,\n            have h6 : ∃ (n : ℕ), int.nat_abs (↑n * i - ↑n * j) < int.nat_abs (↑n * i), from by auto [h5],\n            exact h6,\n          }\n        end,\n      cases h4 with n h4,\n      use (n+1),\n      assume k hk,\n      assume h7,\n      have h8 : int.fract (↑(n+1) * i) ≠ int.fract (↑(n+1) * j),\n      from by auto [h1, h2, hk, hj, hi, h7],\n      have h9 : int.nat_abs (int.fract (↑(n+1) * i - int.fract (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have seq_limit : (ℤ → ℝ) → ℝ → Prop :=  λ (u : ℤ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε,\n\n  have h1 : set.Icc 0 1 = (closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ))) ∪ (set.Ioc 0 1), \n  from by auto [closure_eq_of_is_closed_compl, is_closed_Icc, is_open_Ioc, set.preimage_univ, compl_eq_univ_diff],\n  have h2 : set.Ioc 0 1 ⊆ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)),\n  from by auto [h1],\n\n  have h3 : closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)) ⊆ set.Icc 0 1,\n  from by auto [h1],\n\n  have h4 : ∀ (i j : ℤ),  i ≠ j → ((λ (m : ℤ), int.fract (α * ↑m)) i) ≠ ((λ (m : ℤ), int.fract (α * ↑m)) j),\n  from by auto [hα_irrat.uniq_diff_rat_of_irrat],\n\n  have h5 : ∀ (i j : ℤ),  i ≠ j → 0 ∉ ((λ (m : ℤ), int.fract (α * ↑m)) '' (set.Iio i j)),\n  from by auto [h4],\n\n  have h6 : ((λ (m : ℤ), int.fract (α * ↑m)) '' (set.Iio 0 1)) ⊆ ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)),\n  from by auto [fractional_parts_rational],\n\n  have h7 : 0 ∉ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (set.Iio 0 1)), \n  from by auto [h5, h6],\n\n  have h8 : ∀ {x : ℤ}, (int.fract (α * ↑x)) ∈ set.Iio 0 1, \n  from by auto [mul_nonneg, mul_nonpos, int.coe_nat_nonneg, int.coe_nat_nonneg],\n\n  have h9 : ∀ {x : ℤ}, (int.fract (α * ↑x)) ∈ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), \n  from by auto [h8, set.mem_closure_iff_nhds],\n\n  have h10 : ∀ {x : ℤ}, (int.fract (α * ↑x)) ∈ set.Ioc 0 1, \n  from by auto [h8, set.mem_Ioc_iff],\n\n  have h11 : ∀ {x : ℤ}, (int.fract (α * ↑x)) ∈ set.Icc 0 1, \n  from by auto [h10, set.mem_Icc_iff],\n\n  have h12 : ∀ {x : ℤ}, (int.fract (α * ↑x)) ∈ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), \n  from by auto [h11, h3],\n\n  have h13 : ∀ {x : ℤ}, (int.fract (α * ↑x)) ∈ set.Icc 0 1, \n  from by auto [h12, h3],\n\n  have h14 : closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)) ⊆ set.Icc 0 1,\n  from by auto [h13, set.subset.refl],\n\n  have h15 : set.Ioc 0 1 = set.Icc 0 1,\n  from by auto [set.Icc_eq_Ioc, h2, h3, set.eq_of_subset_of_subset],\n\n  show set.Icc 0 1 = closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), \n  from by auto [h13, h14, set.eq_of_subset_of_subset, set.eq_of_subset_of_subset, h15],\nend\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ m n, m ≠ n → (λ m : ℤ, int.fract (α * ↑m)) m ≠ (λ m : ℤ, int.fract (α * ↑m)) n, \n  from by auto [int.fract_def, irrational_iff_not_rat, irrational_iff_sqrt_not_rat] {precedence := decimal},\n\n  let S : set ℝ := (λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ),\n  have h2 : ∀ x : ℤ, (λ (m : ℤ), int.fract (α * ↑m)) x ∈ S := by auto [set.mem_image],\n  have h3 : ∃! e : S, ∀ a : S, e ∈ closure a → a ⊆ S := by auto [set.separation],\n\n  have h4 : ∀ x : ℤ, ∃ b : S, x ∈ b := by auto [set.mem_image],\n\n  have h5 : infinite S := by auto [set.finite_univ, h1, infinite],\n  have h6 : ∃ l : ℝ, is_limit_point S l := by auto [set.finite_univ, h1, is_limit_point.image, is_limit_point_iff_exists_sequence, is_limit_point_iff_exists_sequence_metric, set.mem_image, set.mem_univ],\n  have h7 : ∃ (l : ℝ), is_limit_point S l ∧ l ∈ set.Icc 0 1, from by auto [is_limit_point_iff_exists_sequence],\n  have h8 : ∃! l : ℝ, is_limit_point S l ∧ l ∈ set.Icc 0 1, from by auto [set.univ_mem_set_of_eq, set.mem_image, exists_unique.exists, exists_unique.unique, is_limit_point.image],\n\n  have h9 : ∀ y ∈ set.Icc 0 1, ∃ (ε : ℝ) > 0, ∀ x, x ∈ S → |x - y| < ε,  from by auto [set.mem_Icc, classical.em, set.mem_image, set.mem_univ, h4, is_limit_point.image, is_limit_point_iff_exists_sequence, is_limit_point_iff_exists_sequence_metric],\n\n  show closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1, from by auto [h6, is_limit_point_iff_exists_sequence, is_limit_point_iff_exists_sequence_metric, h8, h9]\n\nend\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h0 : ∀ m n : ℤ, m ≠ n → (int.fract (α*↑m)) ≠ (int.fract (α* ↑n)), from by {assume m n h1, assume h2, have h3 : (α*↑m-int.fract (α* ↑m)) ≠ (α* ↑n-int.fract (α* ↑n)), from by auto [int.fract_eq_iff_eq, h1, hα_irrat], linarith [h2]},\n  have h1 : ∀ x y : ℤ, (int.fract (α * ↑x)) = (int.fract (α * ↑y)) ↔ x = y, from by {auto [int.fract_eq_iff_eq, hα_irrat]},\n  have h2 : (set.Icc (0:ℝ) 1) ∩ ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = (λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ), from by auto [fract_bounded, int.fract_lt_one, int.fract_nonneg],\n  have h3 : (set.Icc (0:ℝ) 1) ⊆ (λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ), from by auto [fract_bounded, int.fract_lt_one, int.fract_nonneg],\n  have h4 : (λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ) ⊆  (set.Icc (0:ℝ) 1), from by auto [fract_bounded, int.fract_lt_one, int.fract_nonneg],\n  have h5 : (λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ) ⊆ closure (λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ), from by auto using [set.subset_closure],\n  have h6 : ∀₀ m : ℤ, 0 ≤ int.fract (α * ↑m), from by intros m hm;exact int.fract_nonneg (α * ↑m),\n  have h6' : ∀₀ m : ℤ, int.fract (α * ↑m) ≤ 1, from by intros m hm;exact int.fract_lt_one (α * ↑m),\n  have h7 : submodule.span ℝ (set.range (λ (m : ℤ), int.fract (α * ↑m))) = set.Icc 0 1, from by auto [set.range_subset_iff, h1, h0, h4, h2, h6, h6', int.fract_lt_one, int.fract_nonneg],\n  have h8 : closure (submodule.span ℝ (set.range (λ (m : ℤ), int.fract (α * ↑m)))) ⊆ closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)), from by auto using [set.subset_closure],\n  have h9 : closure (λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ) = closure (submodule.span ℝ (set.range (λ (m : ℤ), int.fract (α * ↑m)))), from by auto [closure_span,h7,h5,h8],\n  have h10 : closure (λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ) = set.Icc (0:ℝ) 1, from by auto [h9, closure_Icc],\n  show closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1, by auto [h10,h3] using [set.subset_closure]\nend\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := sorry\n\n/--`theorem`\nConvergence of a geometric progression\n$\\lim_{n\\to\\infty}a_n=\\frac{a_1}{1-q}$\n`proof`\nLet $\\epsilon>0$.\n\nSince $\\lim_{n\\to\\infty} a_n=\\frac{a_1}{1-q}$, there exists $N\\in\\mathbb{N}$ such that $|a_n-\\frac{a_1}{1-q}|<\\epsilon$ for all $n>N$.\n\nWe shall now prove that $|a_{n+1}-\\frac{a_1}{1-q}|<\\epsilon$ for $n>N$ by induction on $n$.\n\nIt is easy to see that $|a_{N+1}-\\frac{a_1}{1-q}|<\\epsilon$.\n\nNow suppose that $|a_n-\\frac{a_1}{1-q}|<\\epsilon$ for some $n>N$. Then we have\n$$\n|a_{n+1}-\\frac{a_1}{1-q}|=|qa_n+a_1-\\frac{a_1}{1-q}|=|\\frac{-a_1(1-q)}{1-q}+a_n(q-1)|=|a_n-\\frac{a_1}{1-q}|<\\epsilon,\n$$\nwhich establishes the inductive step.\n\nWe can now conclude that $|a_n-\\frac{a_1}{1-q}|<\\epsilon$ for all $n>N$.\n\nQED\n-/\ntheorem geometric_progression_converges {α : ℝ} (q : ℝ) :\n  let seq : ℕ → ℝ :=  λ (n : ℕ), (q ^ n)*α in\n  ∀ α, ∃ lim : ℝ, seq_limit seq lim :=\n  sorry\n\n/--`theorem`\nIf $x \\in \\mathbb{Q}$ and $x$ is algebraic, then $x$ is a root of unity.\n`proof`\nSuppose that $x=\\frac{p}{q}$.\n\nThen $qx=p$.\n\nThis means that $q \\neq 0$ and $x$ is algebraic. Thus $x$ is a root of unity by the theorem $x$ is algebraic implies $x$ is a root of unity.\n\nSince $x \\in \\mathbb{Q}$, $x$ must be rational.\n\nQED\n-/\ntheorem rational_algebraic_r-of-unity {α : ℝ} (hα_alg : algebraic α) : ∃ n : ℕ, α = n⁻¹ := by sorry\n\n/--`theorem`\nIf $x$ is a root of unity, then $x$ is algebraic\n`proof`\nSuppose that $x$ is a root of unity. Then there exists $n \\in \\mathbb{N} \\setminus \\{0\\}$ such that $x^n=1$.\n\nNow $1=(x-1)x^{n-1}$, which means that $x$ is a root of the polynomial $f(x)=x^n-1$. This means that $x$ is algebraic.\n\nQED\n-/\ntheorem r-of-unity_algebraic {α : ℝ} (hα_root_of_unity : is_root_of_unity α) : algebraic α := sorry\n\n/--`theorem`\nIf $x$ is a root of unity, then $x$ is rational\n`proof`\nSuppose that $x$ is a root of unity. Then there exists $n \\in \\mathbb{N} \\setminus \\{0\\}$ such that $x^n=1$.\n\nThen $\\frac{x+1}{1}=\\frac{x^2+x}{x}=\\frac{x^2+x+\\frac{1-x^n}{1-x}}{x}=\\frac{x^2+x+\\frac{x(1-x)^{n-1}}{1-x}}{x}=\\frac{x^2+x+x^{n-1}}{x}=\\frac{x(x+1)}{x}=x+1$, which means that $x$ is rational.\n\nQED\n-/\ntheorem r-of-unity_rational {α : ℝ} (hα_root_of_unity : is_root_of_unity α) : ∃ n : ℕ, α = n⁻¹ := by sorry\n\n/--`theorem`\nIf $x$ is a root of unity, then $x$ is transcendental\n`proof`\nSuppose that $x$ is a root of unity. Then there exists $n \\in \\mathbb{N} \\setminus \\{0\\}$ such that $x^n=1$.\n\nIf $x$ is not transcendental, then it is algebraic. This means that $x$ is algebraic by the theorem $x$ is a root of unity implies $x$ is algebraic. But this is a contradiction since algebraic numbers are roots of unity.\n\nQED\n-/\ntheorem r-of-unity_transcendental {α : ℝ} (hα_root_of_unity : is_root_of_unity α) : transcendental α := \nbegin\n  sorry\nend\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n    let S : set ℝ := (λ (n : ℤ), (int.fract (α * ↑n)) : ℤ → ℝ) '' (@set.univ ℤ),\n    have h1 : S.infinite, \n    from by auto [@set.infinite_of_nonempty ℤ] using [set.Ico_nonempty],\n    have h2 : ∃ ⦃a b : ℝ⦄, 0 < a ∧ a < b ∧ b < 1 ∧ ∀ ⦃x : ℝ⦄, a < x ∧ x < b → ∃ ⦃m : ℤ⦄, x ∈ S, \n    from exists_pair_in_interval_with_common_neighbours h1,\n    -- (⌊ x⌋ + 1 ≠ ⌊ b⌋ ∧ ⌊ x⌋ ≠ ⌊ b⌋) → \n    have h3 : ∀ (x : ℝ) ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs ((b : ℝ) - x) + 1) (int.nat_abs (((b : ℝ) - x) + 2) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < b - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from exists_int_in_set h2,\n    have h4 : ∀ (x : ℝ) (m1 : ℤ), (∃ ⦃m : ℤ⦄, 0 < m ∧ m < b - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) m1 ∈ S) \n    ↔ (0 < m1 ∧ (∃ ⦃n : ℤ⦄, 0 < n ∧ n < b - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) (m1 - n) ∈ S)), \n    from exists_neighbour h2,\n    have h5 : ∀ (x : ℝ) (m1 : ℤ), (∃ ⦃m : ℤ⦄, 0 < m ∧ m < 1 - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) m1 ∈ S) \n    ↔ (0 < m1 ∧ (∃ ⦃n : ℤ⦄, 0 < n ∧ n < 1 - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) (m1 - n) ∈ S)), \n    from exists_neighbour_1 h2,\n    have h6 : ∀ (x : ℝ) ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs (((1 : ℝ) - x) + 2) + 1) (int.nat_abs (((1 : ℝ) - x) + 1) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < 1 - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from exists_int_in_set_1 h2,\n    have h7 : ∀ (x : ℝ) (m1 : ℤ), (∃ ⦃m : ℤ⦄, 0 < m ∧ m < x ∧ (λ (m : ℤ), int.fract (α * ↑m)) m1 ∈ S) \n    ↔ (0 < m1 ∧ (∃ ⦃n : ℤ⦄, 0 < n ∧ n < x ∧ (λ (m : ℤ), int.fract (α * ↑m)) (m1 + n) ∈ S)), \n    from exists_neighbour_0 h2,\n    have h8 : ∀ (x : ℝ) ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs (x + 1) + 1) (int.nat_abs (x + 2) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from exists_int_in_set_0 h2,\n    have h9 : ∀ (x : ℝ) ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs ((b : ℝ) - x) + 1) (int.nat_abs (((b : ℝ) - x) + 1) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < b - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from exists_int_in_set_3 h2,\n    have h10 : ∀ ⦃x : ℝ⦄, x < b → ∀ ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs ((b - x) + 1) + 1) (int.nat_abs ((b - x) + 2) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < b - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from int_in_set_2 h2,\n    have h11 : ∃ ⦃x : ℝ⦄, 0 < x ∧ x < 1 ∧ ∀ ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs (x + 1) + 1) (int.nat_abs (x + 2) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from exists_x_int_in_set_3 h2,\n    have h12 : ∃ ⦃x : ℝ⦄, 0 < x ∧ x < 1 ∧ ∀ ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs (x + 1) + 1) (int.nat_abs (x + 2) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < 1 - x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from exists_x_int_in_set_4 h2,\n    have h13 : ∃ ⦃x : ℝ⦄, 0 < x ∧ x < 1 ∧ ∀ ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs ((x : ℝ) + 1) + 1) (int.nat_abs ((x : ℝ) + 2) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < x ∧ (λ (m : ℤ), int.fract (α * ↑m)) a ∈ S, \n    from exists_x_int_in_set_5 h2,\n    have h14 : ∃ ⦃x : ℝ⦄, 0 < x ∧ x < 1 ∧ ∀ ⦃a : ℤ⦄, a ∈ set.Ico (int.nat_abs ((x : ℝ) + 1) + 1) (int.nat_abs ((x : ℝ) + 2) + 1) \n    → ∃ ⦃n : ℤ⦄, 0 < n ∧ n < 1 - x ∧ (λ\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := \nbegin\n  have h1 : (∀ (n m : ℤ), n ≠ m → (int.fract (α * ↑n)) ≠ (int.fract (α * ↑m))),\n  from\n  begin\n    assume (n m : ℤ) (hnm : n ≠ m),\n    assume h1 : (int.fract (α * ↑n)) = (int.fract (α * ↑m)),\n    rw h1,\n    have h2 : α = (int.fract (α * ↑n)) + (int.fract (α * ↑m)),\n    from by linarith,\n    have h3 : α = (int.fract (α * ↑n)) + (int.fract (α * ↑n)),\n    from by linarith,\n    have h4 : α = n * α + (int.fract (α * ↑n)),\n    from by linarith,\n    have h5 : α = m * α + (int.fract (α * ↑n)),\n    from by linarith,\n    have h6 : α = n * α + m * α,\n    from by linarith,\n    have h7 : (n - m) * α = 0,\n    from by linarith,\n    have h8 : (n - m) = 0,\n    from by linarith,\n    contradiction,\n  end,\n\n  have h2 : ∃ (N : ℕ), ∀ (n : ℕ), n ≥ N → (int.fract (α^(n+1))) = 0,\n  from\n  begin\n    apply exists.intro (1),\n    assume (n : ℕ) (hn : n ≥ 1),\n    have h3 : ↑(n + 1) ∈ (set.range (succ)),\n    from set.mem_range_self _,\n    have h4 : ↑(n + 1) > 0,\n    from by linarith [hn],\n    have h5 : (int.fract (α^(↑(n + 1)))) = 0,\n    from by linarith [h4],\n    show (int.fract (α^(n+1))) = 0,\n    from by linarith,\n  end,\n\n  have h3 : ∃ (n : ℕ), n ≥ 1 ∧ (int.fract (α^(n+1))) = 0,\n  from exists.intro 1 (and.intro (nat.le_succ 1) (by linarith)),\n\n  have h4 : ∀ (n : ℕ), n ≥ 1 → (int.fract (α^(n+1))) = 0,\n  from \n  begin\n    assume (n : ℕ) (hn : n ≥ 1),\n    cases h2 with N h2,\n    cases h2 n with hnN h2,\n    show (int.fract (α^(n+1))) = 0,\n    from by linarith,\n  end,\n\n  have h5 : ∀ (n : ℕ), n ≥ 1 → ∃ (k : ℤ), (int.fract (α^(n+1))) = k,\n  from\n  begin\n    assume (n : ℕ) (hn : n ≥ 1),\n    have h6 : (int.fract (α^(n+1))) = 0,\n    from by linarith,\n    show ∃ (k : ℤ), (int.fract (α^(n+1))) = k,\n    from by linarith,\n  end,\n\n  have h6 : ∀ (n : ℕ), n ≥ 1 → ∀ (m : ℕ), m ≥ 1 → ∃ (k : ℤ), (int.fract (α^(n+1))) = k,\n  from\n  begin\n    assume (n m : ℕ) (hn : n ≥ 1) (hm : m ≥ 1),\n    have h4 : ∃ (k : ℤ), (int.fract (α^(n+1))) = k,\n    from by linarith,\n    show ∃ (k : ℤ), (int.fract (α^(n+1))) = k,\n    from by linarith [h4],\n  end,\n\n  have h7 : ∀ (n : ℕ), ∀ (m : ℕ), n ≥ 1 →  m ≥ 1 → ∃ (x y : ℤ), (int.fract (α^(n+1))) = x ∧ ((int.fract (α^(m+1))) = y),\n  from\n  begin\n    assume (n m : ℕ) (hn : n ≥ 1) (hm : m ≥ 1),\n    cases h4 n hn with x hx,\n    cases h4 m hm with y hy,\n    have h6 : ((int.fract (α^(n+1))) = x ∧ ((int.fract (α^(m+1))) = y)),\n    from by linarith,\n    show ∃ (x y : ℤ), (int.fract (α^(n+1))) = x ∧ ((int.fract (α^(m+1))) = y),\n    from by linarith [h6],\n  end,\n\n  have h8 : ∀ (n : ℕ), ∃ (x : ℤ), (int.fract (α^(n+1))) = x,\n  from\n  begin\n    assume (n : ℕ),\n    cases h7 n n (le_refl n) (le_refl n) with x hx,\n    show ∃ (x : ℤ), (int.fract (α^(n+1))) = x,\n    from by linarith [hx],\n  end,\n\n  have h9 : ∀ (n : ℕ), ∃ (x : ℤ), (int.fract (α^(n+1))) = x,\n  from by auto [h8],\n\n  have h10 : ∃ (N : ℕ), ∀ (n : ℕ), n ≥ N → (int.fract (α^(n+1))) = 0,\n  from by auto [h2],\n\n  have h11 : ∀ (n : ℕ), ∀ (m : ℕ), n ≥ 1 → m ≥ 1 → int.fract (α^(n+1)) ≤ int.fract (α^(m+1)),\n  from\n  begin\n    assume (n m : ℕ) (hn : n ≥ 1) (hm : m ≥ 1),\n    cases h10 with N h10,\n    cases h10 m with hmN h10,\n    cases h10 with k h10,\n    cases h7 n m hn hm with x hy,\n    cases hy with y hxhy,\n    cases h7 n m hn hm with x hx,\n    cases hx with y hxhy,\n    have h11 : int.fract (α^(n+1)) ≤ k,\n    from by linarith,\n    show int.fract (α^(n+1)) ≤ int.fract (α^(m+1)),\n    from by linarith [hmN, hmN],\n  end,\n\n  have h12 : ∀ (n : ℕ), ∃ (m : ℕ), (int.fract (α^(n+1))) = int.fract (α^(m+1)),\n  from\n  begin\n    assume (n : ℕ),\n    cases classical.em (n = 0) with hn hn,\n    show ∃ (m : ℕ), (int.fract (α^(n+1))) = int.fract (α^(m+1)),\n    from by linarith [hn],\n    assume hn : n ≠ 0,\n    cases h2 with N h2,\n    cases h2 n with hnN h2,\n    have h13 : int.fract (α^(n+1)) = 0,\n    from by linarith,\n    have h14 : n + 1 ≥ N + 1,\n    from by linarith [nat.succ_le_succ],\n    have h15 : int.fract (α^(n+1)) = int.fract ((α ^ (N+1))),\n    from by linarith,\n   \nend --Needs more than 2000 tokens!\n\n--OUTPUT 9\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := \nbegin\n   have h1 : real.sqrt(2) ∉ ℚ, from by simpa,\n\n   have h2 : irrational (real.sqrt 2) := by exact h1,\n\n   have h3 : ∃ a b, a ∈ (λ (m : ℤ), int.fract (sqrt 2 * ↑m)) '' set.univ ∧ \n   b ∈ (λ (m : ℤ), int.fract (sqrt 2 * ↑m)) '' set.univ ∧ a ≠ b,\n   from by auto [h2, int.fract_ne_zero],\n\n   have h4 : closure ((λ (m : ℤ), int.fract (sqrt 2 * ↑m)) '' (@set.univ ℤ)) ≠ ∅,\n   from by auto [set.mem_closure_iff, h3],\n\n   have h5 : (λ (m : ℤ), int.fract (sqrt 2 * ↑m)) '' (@set.univ ℤ) ⊆ set.Icc 0 1,\n   from by auto [int.fract_le_one],\n\n   have h6 : closure ((λ (m : ℤ), int.fract (sqrt 2 * ↑m)) '' (@set.univ ℤ)) ⊆ set.Icc 0 1,\n   from by auto [set.closure_mono],\n   \n   have h7 : set.Icc 0 1 ⊆ closure ((λ (m : ℤ), int.fract (sqrt 2 * ↑m)) '' (@set.univ ℤ)),\n   from by auto [set.mem_Icc, set.mem_closure_iff],\n\n   have h8 : set.Icc 0 1 = closure ((λ (m : ℤ), int.fract (sqrt 2 * ↑m)) '' (@set.univ ℤ)),\n   from by auto [set.subset_iff, h4, h5, h6, h7],\n\n   show closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1,\n   from by simp [h8, mul_comm],\nend\n\n--OUTPUT 10\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  refine le_antisymm _ (closure_subset_Icc _ _),\n  { exact closure_mono _ (set.image_subset_iff.mpr int.fract_int_subset) },\n  { apply dense_iff.mpr,\n    { exact dense_fractional_part_image_int },\n    {\n        assume x hx_in,\n        have hx_in_int : x ∈ univ, \n        from ⟨int.fract_int x, by simp [x]⟩,\n        obtain ⟨q₀, hq₀, hq₀_in⟩ : ∃ (q : ℤ), x < q + 1 ∧ q ∈ univ, from exists_nat_one_lt hx_in,\n        have hα_pos : 0 < α, from hx_in.2.1,\n        have hx_nonneg : 0 ≤ x, from hx_in.2.2,\n        obtain ⟨⟨q₁, hq₁_in, hq₁⟩, ⟨q₂, hq₂_in, hq₂⟩⟩ : ∃ (q₁ q₂ : ℤ), x < q₁ ∧ q₁ ∈ univ ∧ q₂ ≤ x ∧ q₂ ∈ univ, \n        from exists_nat_add_one_lt hq₀_in,\n        have hq₁_nat : 0 < q₁, from hq₁,\n        have hq₂_nat : 0 < q₂, from lt_of_le_of_lt hq₂.2 hq₂,\n        have hx_nat : 0 < x, from lt_of_le_of_lt hq₂.2 hq₂,\n        have hq_pos : 0 < (q₁ + q₂ : ℤ), from add_pos hq₁_nat hq₂_nat,\n        have hqpos_nat : 0 < ↑(q₁ + q₂), from hq_pos,\n        have hrecip : (↑(q₁ + q₂))⁻¹ > 0, from recip_pos hqpos_nat,\n        obtain ⟨N, hN⟩ : ∃ (N : ℕ), ∀ (n : ℕ), n ≥ N → |(↑(q₁ + q₂))⁻¹ * α - ↑(q₁ + q₂)⁻¹ * (q₁ + q₂ : ℤ) * ↑n| < 1, from exists_rational_neighbourhood hα_irrat hα_pos,\n        have h1 : |(↑(q₁ + q₂))⁻¹ * α - ↑(q₁ + q₂)⁻¹ * (q₁ + q₂ : ℤ) * ↑N| < 1, from hN N (le_refl N),\n        have h2 : |(↑(q₁ + q₂))⁻¹ * α - ↑(q₁ + q₂)⁻¹ * (q₁ + q₂ : ℤ) * ↑N| ≤ 1, from h1,\n        have h3 : 1 ≤ (↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂), from by {rw mul_one, exact le_refl _},\n        have h4 : ↑(q₁ + q₂)⁻¹ * ↑(q₁ + q₂) ≤ (↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂), from le_refl _,\n        have h5 : (↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂) ≤ 1, from le_of_le_of_ge h4 h3,\n        have h6 : (↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂) ≤ |(↑(q₁ + q₂))⁻¹ * α - ↑(q₁ + q₂)⁻¹ * (q₁ + q₂ : ℤ) * ↑N|, from le_of_le_of_ge h5 h2,\n        have h7 : -((↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂)) ≤ |(↑(q₁ + q₂))⁻¹ * α - ↑(q₁ + q₂)⁻¹ * (q₁ + q₂ : ℤ) * ↑N|, from le_of_le_of_ge (neg_le_neg_of_le h6) (neg_nonpos_of_nonneg hq_pos),\n        have h8 : -((↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂)) ≤ -1, from le_of_le_of_ge h7 h5,\n        have h9 : -((↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂)) ≤ -1, from h8,\n        have h10 : -1 ≤ (↑(q₁ + q₂))⁻¹ * ↑(q₁ + q₂), from le_of_le_of_ge h9 h3,\n        have h11 : -1 ≤ (↑(q₁ + q₂))⁻¹ * (q₁ + q₂), from by {rw mul_comm, exact h10},\n        have h12 : -((↑(q₁ + q₂))⁻¹) ≤ -((↑(q₁ + q₂))⁻¹ * (q₁ + q₂))⁻¹, from by {rw neg_inv_of_neg_of_pos hq_pos, exact h11},\n        have h13 : -((↑(q₁ + q₂))⁻¹) ≤ -((↑(q₁ + q₂))⁻¹ * (q₁ + q₂))⁻¹, from h12,\n        have h14 : -((↑(q₁ + q₂))⁻¹) * ((↑(q₁ + q₂))⁻¹ * (q₁ + q₂)) ≤ ((↑(q₁ + q₂))⁻¹ * (q₁ + q₂)) * (-((↑(q₁ + q₂))⁻¹)), from mul_le_mul_of_nonneg_left h13 (le_of_lt hrecip),\n        have h15 : -1 ≤ ((↑(q₁ + q₂))⁻¹ * (q₁ + q₂)) * (-((↑(q₁ + q₂))⁻¹)), from h14,\n        have h16 : -(↑(q₁ + q₂)⁻¹) ≤ ((↑(q₁ + q₂))⁻¹ * (q₁ + q₂)) * (-((↑(q₁ + q₂))⁻¹)), from h15,\n        have h17 : -(↑(q₁ + q₂)⁻¹) ≤ ((↑(q₁ + q₂))⁻¹ * (q₁ + q₂)) * (-1), from h16,\n        have h18 : -(↑(q₁ + q₂)⁻¹) ≤ (↑(q₁ + q₂\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n  have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n  show (A ∩ B) ∈  𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n  ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n  ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n  ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n  from by auto [abs_sub_lt_iff] using [linarith],\n  \n  assume (h7 : ε > 0),\n\n  cases h2 ε h7 with N1 h8,\n  cases h3 ε h7 with N2 h9,\n  let N := max N1 N2,\n  use N,\n\n  have h10 : ∀ n > N, n > N1 ∧ n > N2 := by auto [lt_of_le_of_lt, le_max_left, le_max_right],\n  \n  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n  from by auto [h8, h10, h5, h9],\n\n  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n  from by auto [h11] using [linarith],\n\n  show  ∀ (n : ℕ), n > N → |x n - l| < ε, \n  from by auto [h5, h15], \n\nend\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n\nTo show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n\nQED\n-/\ntheorem  irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto-4_few_shot_temperature_0.8_max_tokens_2000_n_10/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4758567318345001}}
{"text": "import dialectica \n\n\nopen formula \n\nsection \n\nparameters {ι : Type} {gri : ground_interpretation ι}\nlocal notation `𝔽` := formula ι gri\nlocal notation `𝕋` := type ι gri\n\n-- structure majorizability :=\n-- (𝕄 : 𝕋 → 𝕋)\n-- (𝕄_inh : ∀ {σ : 𝕋}, ∥𝕄 σ∥)\n-- (𝕄_𝕆 : 𝕄 𝕆 = 𝕆)\n-- (𝕄_app : ∀ (σ τ : 𝕋), 𝕄 (σ ↣ τ) = ((𝕄 σ) ↣ (𝕄 τ)))\n-- (majorizable : ∀ {σ : 𝕋}, ∥σ∥ → Prop)\n-- (majorizes : ∀ {σ : 𝕋}, ∥σ∥ → ∥𝕄 σ∥ → Prop)\n-- (majorizer : ∀ {σ : 𝕋} (x : ∥σ∥), {x' : ∥𝕄 σ∥ // majorizable x → majorizes x x'})\n-- (majorizer_app : ∀ (σ τ : 𝕋) (x : σ) (x' : 𝕄 σ) (y : σ ↣ τ) (y' : 𝕄 (σ ↣ τ)), majorizes x x' → majorizes y y' → majorizes (y x) (y' x'))\n\nclass maj_type (𝕄 : 𝕋 → 𝕋) :=\n(𝕄_𝕆 : 𝕄 𝕆 = 𝕆)\n(𝕄_app (σ τ : 𝕋) : 𝕄 (σ ↣ τ) = (𝕄 σ ↣ 𝕄 τ))\n\nattribute [simp] maj_type.𝕄_app\n\n@[simp]\nlemma l' {𝕄 : 𝕋 → 𝕋} [maj_type 𝕄] : ∥𝕄 𝕆∥ = ℕ := sorry\n\n@[simp]\nlemma l {𝕄 : 𝕋 → 𝕋} [maj_type 𝕄] {σ τ : 𝕋} : ∥𝕄 (σ ↣ τ)∥ = (∥𝕄 σ∥ → ∥𝕄 τ∥) := sorry\n\ninstance i {𝕄 : 𝕋 → 𝕋} [maj_type 𝕄] : linear_order ∥𝕄 𝕆∥ := by {\n  simp only [l'],\n  exact nat.linear_order,\n}\n\nstructure majorizability (𝕄 : 𝕋 → 𝕋) [maj_type 𝕄] :=\n(majorizes : ∀ {σ : 𝕋}, ∥σ∥ → ∥𝕄 σ∥ → Prop)\n(majorizes_le : ∀ {x : ∥𝕆∥} {x' : ∥𝕄 𝕆∥}, majorizes x x' → x ≤ type.cast (maj_type.𝕄_𝕆) x')\n(majorizes_app : ∀ {σ τ : 𝕋} (x : ∥σ∥) (x' : ∥𝕄 σ∥) (y : ∥σ ↣ τ∥) (y' : ∥𝕄 (σ ↣ τ)∥), \n  majorizes x x' → majorizes y y' → majorizes (y x) ((type.cast (maj_type.𝕄_app _ _) y') x'))\n(majorizer : Π {σ : 𝕋}, ∥σ∥ → ∥𝕄 σ∥)\n(majorizer_majorizes : ∀ {σ : 𝕋} (x : ∥σ∥), majorizes x (majorizer x))\n-- attribute [simp, reducible] majorizability.𝕄_𝕆\n\n\nend \n\n#check maj_type\n\n\n\n\n", "meta": {"author": "hcheval", "repo": "formalized-proof-mining", "sha": "216cc73fccd84900a1ba7eaae5f73732496d6afe", "save_path": "github-repos/lean/hcheval-formalized-proof-mining", "path": "github-repos/lean/hcheval-formalized-proof-mining/formalized-proof-mining-216cc73fccd84900a1ba7eaae5f73732496d6afe/src/majorizability.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311856832191, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4758567258195351}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker\n\n! This file was ported from Lean 3 source module data.polynomial.induction\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.RingTheory.Ideal.Basic\nimport Mathbin.Data.Polynomial.Basic\n\n/-!\n# Induction on polynomials\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains lemmas dealing with different flavours of induction on polynomials.\nSee also `data/polynomial/inductions.lean` (with an `s`!).\n\nThe main result is `polynomial.induction_on`.\n-/\n\n\nnoncomputable section\n\nopen Finsupp Finset\n\nnamespace Polynomial\n\nopen Polynomial\n\nuniverse u v w x y z\n\nvariable {R : Type u} {S : Type v} {T : Type w} {ι : Type x} {k : Type y} {A : Type z} {a b : R}\n  {m n : ℕ}\n\nsection Semiring\n\nvariable [Semiring R] {p q r : R[X]}\n\n/- warning: polynomial.induction_on -> Polynomial.induction_on is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {M : (Polynomial.{u1} R _inst_1) -> Prop} (p : Polynomial.{u1} R _inst_1), (forall (a : R), M (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (Polynomial.C.{u1} R _inst_1) a)) -> (forall (p : Polynomial.{u1} R _inst_1) (q : Polynomial.{u1} R _inst_1), (M p) -> (M q) -> (M (HAdd.hAdd.{u1, u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHAdd.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.add'.{u1} R _inst_1)) p q))) -> (forall (n : Nat) (a : R), (M (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHMul.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.mul'.{u1} R _inst_1)) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (Polynomial.C.{u1} R _inst_1) a) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R _inst_1) Nat (Polynomial.{u1} R _inst_1) (instHPow.{u1, 0} (Polynomial.{u1} R _inst_1) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R _inst_1) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))))) (Polynomial.X.{u1} R _inst_1) n))) -> (M (HMul.hMul.{u1, u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHMul.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.mul'.{u1} R _inst_1)) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (Polynomial.C.{u1} R _inst_1) a) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R _inst_1) Nat (Polynomial.{u1} R _inst_1) (instHPow.{u1, 0} (Polynomial.{u1} R _inst_1) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R _inst_1) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))))) (Polynomial.X.{u1} R _inst_1) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))))) -> (M p)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {M : (Polynomial.{u1} R _inst_1) -> Prop} (p : Polynomial.{u1} R _inst_1), (forall (a : R), M (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Polynomial.C.{u1} R _inst_1) a)) -> (forall (p : Polynomial.{u1} R _inst_1) (q : Polynomial.{u1} R _inst_1), (M p) -> (M q) -> (M (HAdd.hAdd.{u1, u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHAdd.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.add'.{u1} R _inst_1)) p q))) -> (forall (n : Nat) (a : R), (M (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) a) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) a) (Polynomial.mul'.{u1} R _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Polynomial.C.{u1} R _inst_1) a) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R _inst_1) Nat (Polynomial.{u1} R _inst_1) (instHPow.{u1, 0} (Polynomial.{u1} R _inst_1) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R _inst_1) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))))) (Polynomial.X.{u1} R _inst_1) n))) -> (M (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) a) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) a) (Polynomial.mul'.{u1} R _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Polynomial.C.{u1} R _inst_1) a) (HPow.hPow.{u1, 0, u1} (Polynomial.{u1} R _inst_1) Nat (Polynomial.{u1} R _inst_1) (instHPow.{u1, 0} (Polynomial.{u1} R _inst_1) Nat (Monoid.Pow.{u1} (Polynomial.{u1} R _inst_1) (MonoidWithZero.toMonoid.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toMonoidWithZero.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))))) (Polynomial.X.{u1} R _inst_1) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))))) -> (M p)\nCase conversion may be inaccurate. Consider using '#align polynomial.induction_on Polynomial.induction_onₓ'. -/\n@[elab_as_elim]\nprotected theorem induction_on {M : R[X] → Prop} (p : R[X]) (h_C : ∀ a, M (C a))\n    (h_add : ∀ p q, M p → M q → M (p + q))\n    (h_monomial : ∀ (n : ℕ) (a : R), M (C a * X ^ n) → M (C a * X ^ (n + 1))) : M p :=\n  by\n  have A : ∀ {n : ℕ} {a}, M (C a * X ^ n) := by\n    intro n a\n    induction' n with n ih\n    · simp only [pow_zero, mul_one, h_C]\n    · exact h_monomial _ _ ih\n  have B : ∀ s : Finset ℕ, M (s.Sum fun n : ℕ => C (p.coeff n) * X ^ n) :=\n    by\n    apply Finset.induction\n    · convert h_C 0\n      exact C_0.symm\n    · intro n s ns ih\n      rw [sum_insert ns]\n      exact h_add _ _ A ih\n  rw [← sum_C_mul_X_pow_eq p, Polynomial.sum]\n  exact B _\n#align polynomial.induction_on Polynomial.induction_on\n\n/- warning: polynomial.induction_on' -> Polynomial.induction_on' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {M : (Polynomial.{u1} R _inst_1) -> Prop} (p : Polynomial.{u1} R _inst_1), (forall (p : Polynomial.{u1} R _inst_1) (q : Polynomial.{u1} R _inst_1), (M p) -> (M q) -> (M (HAdd.hAdd.{u1, u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHAdd.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.add'.{u1} R _inst_1)) p q))) -> (forall (n : Nat) (a : R), M (coeFn.{succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R _inst_1) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) (fun (_x : LinearMap.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R _inst_1) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (LinearMap.hasCoeToFun.{u1, u1, u1, u1} R R R (Polynomial.{u1} R _inst_1) _inst_1 _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R _inst_1) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Polynomial.monomial.{u1} R _inst_1 n) a)) -> (M p)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {M : (Polynomial.{u1} R _inst_1) -> Prop} (p : Polynomial.{u1} R _inst_1), (forall (p : Polynomial.{u1} R _inst_1) (q : Polynomial.{u1} R _inst_1), (M p) -> (M q) -> (M (HAdd.hAdd.{u1, u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (instHAdd.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.add'.{u1} R _inst_1)) p q))) -> (forall (n : Nat) (a : R), M (FunLike.coe.{succ u1, succ u1, succ u1} (LinearMap.{u1, u1, u1, u1} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R _inst_1) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : R) => Polynomial.{u1} R _inst_1) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u1, u1} R R R (Polynomial.{u1} R _inst_1) _inst_1 _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R _inst_1) (Polynomial.module.{u1, u1} R _inst_1 R _inst_1 (Semiring.toModule.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Polynomial.monomial.{u1} R _inst_1 n) a)) -> (M p)\nCase conversion may be inaccurate. Consider using '#align polynomial.induction_on' Polynomial.induction_on'ₓ'. -/\n/-- To prove something about polynomials,\nit suffices to show the condition is closed under taking sums,\nand it holds for monomials.\n-/\n@[elab_as_elim]\nprotected theorem induction_on' {M : R[X] → Prop} (p : R[X]) (h_add : ∀ p q, M p → M q → M (p + q))\n    (h_monomial : ∀ (n : ℕ) (a : R), M (monomial n a)) : M p :=\n  Polynomial.induction_on p (h_monomial 0) h_add fun n a h =>\n    by\n    rw [C_mul_X_pow_eq_monomial]\n    exact h_monomial _ _\n#align polynomial.induction_on' Polynomial.induction_on'\n\nopen Submodule Polynomial Set\n\nvariable {f : R[X]} {I : Ideal R[X]}\n\n/- warning: polynomial.span_le_of_C_coeff_mem -> Polynomial.span_le_of_C_coeff_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {f : Polynomial.{u1} R _inst_1} {I : Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)}, (forall (i : Nat), Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)) I) -> (LE.le.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Preorder.toLE.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (PartialOrder.toPreorder.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.partialOrder.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Ideal.span.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (setOf.{u1} (Polynomial.{u1} R _inst_1) (fun (g : Polynomial.{u1} R _inst_1) => Exists.{1} Nat (fun (i : Nat) => Eq.{succ u1} (Polynomial.{u1} R _inst_1) g (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)))))) I)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {f : Polynomial.{u1} R _inst_1} {I : Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)}, (forall (i : Nat), Membership.mem.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)) I) -> (LE.le.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Preorder.toLE.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (PartialOrder.toPreorder.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (OmegaCompletePartialOrder.toPartialOrder.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Submodule.completeLattice.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))))))) (Ideal.span.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (setOf.{u1} (Polynomial.{u1} R _inst_1) (fun (g : Polynomial.{u1} R _inst_1) => Exists.{1} Nat (fun (i : Nat) => Eq.{succ u1} (Polynomial.{u1} R _inst_1) g (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)))))) I)\nCase conversion may be inaccurate. Consider using '#align polynomial.span_le_of_C_coeff_mem Polynomial.span_le_of_C_coeff_memₓ'. -/\n/-- If the coefficients of a polynomial belong to an ideal, then that ideal contains\nthe ideal spanned by the coefficients of the polynomial. -/\ntheorem span_le_of_C_coeff_mem (cf : ∀ i : ℕ, C (f.coeff i) ∈ I) :\n    Ideal.span { g | ∃ i, g = C (f.coeff i) } ≤ I :=\n  by\n  simp (config := { singlePass := true }) only [@eq_comm _ _ (C _)]\n  exact (ideal.span_le.trans range_subset_iff).mpr cf\n#align polynomial.span_le_of_C_coeff_mem Polynomial.span_le_of_C_coeff_mem\n\n/- warning: polynomial.mem_span_C_coeff -> Polynomial.mem_span_C_coeff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {f : Polynomial.{u1} R _inst_1}, Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) f (Ideal.span.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (setOf.{u1} (Polynomial.{u1} R _inst_1) (fun (g : Polynomial.{u1} R _inst_1) => Exists.{1} Nat (fun (i : Nat) => Eq.{succ u1} (Polynomial.{u1} R _inst_1) g (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {f : Polynomial.{u1} R _inst_1}, Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) f (Ideal.span.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (setOf.{u1} (Polynomial.{u1} R _inst_1) (fun (g : Polynomial.{u1} R _inst_1) => Exists.{1} Nat (fun (i : Nat) => Eq.{succ u1} (Polynomial.{u1} R _inst_1) g (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i))))))\nCase conversion may be inaccurate. Consider using '#align polynomial.mem_span_C_coeff Polynomial.mem_span_C_coeffₓ'. -/\ntheorem mem_span_C_coeff : f ∈ Ideal.span { g : R[X] | ∃ i : ℕ, g = C (coeff f i) } :=\n  by\n  let p := Ideal.span { g : R[X] | ∃ i : ℕ, g = C (coeff f i) }\n  nth_rw 1 [(sum_C_mul_X_pow_eq f).symm]\n  refine' Submodule.sum_mem _ fun n hn => _\n  dsimp\n  have : C (coeff f n) ∈ p := by\n    apply subset_span\n    simp\n  have : monomial n (1 : R) • C (coeff f n) ∈ p := p.smul_mem _ this\n  convert this using 1\n  simp only [monomial_mul_C, one_mul, smul_eq_mul]\n  rw [← C_mul_X_pow_eq_monomial]\n#align polynomial.mem_span_C_coeff Polynomial.mem_span_C_coeff\n\n/- warning: polynomial.exists_C_coeff_not_mem -> Polynomial.exists_C_coeff_not_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {f : Polynomial.{u1} R _inst_1} {I : Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)}, (Not (Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) f I)) -> (Exists.{1} Nat (fun (i : Nat) => Not (Membership.Mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.hasMem.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (fun (_x : RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) => R -> (Polynomial.{u1} R _inst_1)) (RingHom.hasCoeToFun.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)) I)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {f : Polynomial.{u1} R _inst_1} {I : Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)}, (Not (Membership.mem.{u1, u1} (Polynomial.{u1} R _inst_1) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) f I)) -> (Exists.{1} Nat (fun (i : Nat) => Not (Membership.mem.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)) (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (SetLike.instMembership.{u1, u1} (Ideal.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (Polynomial.{u1} R _inst_1) (Submodule.setLike.{u1, u1} (Polynomial.{u1} R _inst_1) (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Polynomial.{u1} R _inst_1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1))) R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u1} R (Polynomial.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R _inst_1) (Polynomial.semiring.{u1} R _inst_1)))))) (Polynomial.C.{u1} R _inst_1) (Polynomial.coeff.{u1} R _inst_1 f i)) I)))\nCase conversion may be inaccurate. Consider using '#align polynomial.exists_C_coeff_not_mem Polynomial.exists_C_coeff_not_memₓ'. -/\ntheorem exists_C_coeff_not_mem : f ∉ I → ∃ i : ℕ, C (coeff f i) ∉ I :=\n  Not.imp_symm fun cf => span_le_of_C_coeff_mem (not_exists_not.mp cf) mem_span_C_coeff\n#align polynomial.exists_C_coeff_not_mem Polynomial.exists_C_coeff_not_mem\n\nend Semiring\n\nend Polynomial\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Polynomial/Induction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311856832191, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4758567258195351}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson\n\n! This file was ported from Lean 3 source module analysis.special_functions.trigonometric.inverse_deriv\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.SpecialFunctions.Trigonometric.Inverse\nimport Mathbin.Analysis.SpecialFunctions.Trigonometric.Deriv\n\n/-!\n# derivatives of the inverse trigonometric functions\n\nDerivatives of `arcsin` and `arccos`.\n-/\n\n\nnoncomputable section\n\nopen Classical Topology Filter\n\nopen Set Filter\n\nopen Real\n\nnamespace Real\n\nsection Arcsin\n\ntheorem deriv_arcsin_aux {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) :\n    HasStrictDerivAt arcsin (1 / sqrt (1 - x ^ 2)) x ∧ ContDiffAt ℝ ⊤ arcsin x :=\n  by\n  cases' h₁.lt_or_lt with h₁ h₁\n  · have : 1 - x ^ 2 < 0 := by nlinarith [h₁]\n    rw [sqrt_eq_zero'.2 this.le, div_zero]\n    have : arcsin =ᶠ[𝓝 x] fun _ => -(π / 2) :=\n      (gt_mem_nhds h₁).mono fun y hy => arcsin_of_le_neg_one hy.le\n    exact\n      ⟨(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm,\n        cont_diff_at_const.congr_of_eventually_eq this⟩\n  cases' h₂.lt_or_lt with h₂ h₂\n  · have : 0 < sqrt (1 - x ^ 2) := sqrt_pos.2 (by nlinarith [h₁, h₂])\n    simp only [← cos_arcsin, one_div] at this⊢\n    exact\n      ⟨sin_local_homeomorph.has_strict_deriv_at_symm ⟨h₁, h₂⟩ this.ne' (has_strict_deriv_at_sin _),\n        sin_local_homeomorph.cont_diff_at_symm_deriv this.ne' ⟨h₁, h₂⟩ (has_deriv_at_sin _)\n          cont_diff_sin.cont_diff_at⟩\n  · have : 1 - x ^ 2 < 0 := by nlinarith [h₂]\n    rw [sqrt_eq_zero'.2 this.le, div_zero]\n    have : arcsin =ᶠ[𝓝 x] fun _ => π / 2 := (lt_mem_nhds h₂).mono fun y hy => arcsin_of_one_le hy.le\n    exact\n      ⟨(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm,\n        cont_diff_at_const.congr_of_eventually_eq this⟩\n#align real.deriv_arcsin_aux Real.deriv_arcsin_aux\n\ntheorem hasStrictDerivAt_arcsin {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) :\n    HasStrictDerivAt arcsin (1 / sqrt (1 - x ^ 2)) x :=\n  (deriv_arcsin_aux h₁ h₂).1\n#align real.has_strict_deriv_at_arcsin Real.hasStrictDerivAt_arcsin\n\ntheorem hasDerivAt_arcsin {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) :\n    HasDerivAt arcsin (1 / sqrt (1 - x ^ 2)) x :=\n  (hasStrictDerivAt_arcsin h₁ h₂).HasDerivAt\n#align real.has_deriv_at_arcsin Real.hasDerivAt_arcsin\n\ntheorem contDiffAt_arcsin {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) {n : ℕ∞} : ContDiffAt ℝ n arcsin x :=\n  (deriv_arcsin_aux h₁ h₂).2.of_le le_top\n#align real.cont_diff_at_arcsin Real.contDiffAt_arcsin\n\ntheorem hasDerivWithinAt_arcsin_Ici {x : ℝ} (h : x ≠ -1) :\n    HasDerivWithinAt arcsin (1 / sqrt (1 - x ^ 2)) (Ici x) x :=\n  by\n  rcases em (x = 1) with (rfl | h')\n  ·\n    convert(hasDerivWithinAt_const _ _ (π / 2)).congr _ _ <;>\n      simp (config := { contextual := true }) [arcsin_of_one_le]\n  · exact (has_deriv_at_arcsin h h').HasDerivWithinAt\n#align real.has_deriv_within_at_arcsin_Ici Real.hasDerivWithinAt_arcsin_Ici\n\ntheorem hasDerivWithinAt_arcsin_Iic {x : ℝ} (h : x ≠ 1) :\n    HasDerivWithinAt arcsin (1 / sqrt (1 - x ^ 2)) (Iic x) x :=\n  by\n  rcases em (x = -1) with (rfl | h')\n  ·\n    convert(hasDerivWithinAt_const _ _ (-(π / 2))).congr _ _ <;>\n      simp (config := { contextual := true }) [arcsin_of_le_neg_one]\n  · exact (has_deriv_at_arcsin h' h).HasDerivWithinAt\n#align real.has_deriv_within_at_arcsin_Iic Real.hasDerivWithinAt_arcsin_Iic\n\ntheorem differentiableWithinAt_arcsin_Ici {x : ℝ} :\n    DifferentiableWithinAt ℝ arcsin (Ici x) x ↔ x ≠ -1 :=\n  by\n  refine' ⟨_, fun h => (has_deriv_within_at_arcsin_Ici h).DifferentiableWithinAt⟩\n  rintro h rfl\n  have : sin ∘ arcsin =ᶠ[𝓝[≥] (-1 : ℝ)] id := by\n    filter_upwards [Icc_mem_nhdsWithin_Ici\n        ⟨le_rfl, neg_lt_self (zero_lt_one' ℝ)⟩]with x using sin_arcsin'\n  have := h.has_deriv_within_at.sin.congr_of_eventually_eq this.symm (by simp)\n  simpa using (uniqueDiffOn_Ici _ _ left_mem_Ici).eq_deriv _ this (hasDerivWithinAt_id _ _)\n#align real.differentiable_within_at_arcsin_Ici Real.differentiableWithinAt_arcsin_Ici\n\ntheorem differentiableWithinAt_arcsin_Iic {x : ℝ} :\n    DifferentiableWithinAt ℝ arcsin (Iic x) x ↔ x ≠ 1 :=\n  by\n  refine' ⟨fun h => _, fun h => (has_deriv_within_at_arcsin_Iic h).DifferentiableWithinAt⟩\n  rw [← neg_neg x, ← image_neg_Ici] at h\n  have := (h.comp (-x) differentiable_within_at_id.neg (maps_to_image _ _)).neg\n  simpa [(· ∘ ·), differentiable_within_at_arcsin_Ici] using this\n#align real.differentiable_within_at_arcsin_Iic Real.differentiableWithinAt_arcsin_Iic\n\ntheorem differentiableAt_arcsin {x : ℝ} : DifferentiableAt ℝ arcsin x ↔ x ≠ -1 ∧ x ≠ 1 :=\n  ⟨fun h =>\n    ⟨differentiableWithinAt_arcsin_Ici.1 h.DifferentiableWithinAt,\n      differentiableWithinAt_arcsin_Iic.1 h.DifferentiableWithinAt⟩,\n    fun h => (hasDerivAt_arcsin h.1 h.2).DifferentiableAt⟩\n#align real.differentiable_at_arcsin Real.differentiableAt_arcsin\n\n@[simp]\ntheorem deriv_arcsin : deriv arcsin = fun x => 1 / sqrt (1 - x ^ 2) :=\n  by\n  funext x\n  by_cases h : x ≠ -1 ∧ x ≠ 1\n  · exact (has_deriv_at_arcsin h.1 h.2).deriv\n  · rw [deriv_zero_of_not_differentiableAt (mt differentiable_at_arcsin.1 h)]\n    simp only [not_and_or, Ne.def, Classical.not_not] at h\n    rcases h with (rfl | rfl) <;> simp\n#align real.deriv_arcsin Real.deriv_arcsin\n\ntheorem differentiableOn_arcsin : DifferentiableOn ℝ arcsin ({-1, 1}ᶜ) := fun x hx =>\n  (differentiableAt_arcsin.2\n      ⟨fun h => hx (Or.inl h), fun h => hx (Or.inr h)⟩).DifferentiableWithinAt\n#align real.differentiable_on_arcsin Real.differentiableOn_arcsin\n\ntheorem contDiffOn_arcsin {n : ℕ∞} : ContDiffOn ℝ n arcsin ({-1, 1}ᶜ) := fun x hx =>\n  (contDiffAt_arcsin (mt Or.inl hx) (mt Or.inr hx)).ContDiffWithinAt\n#align real.cont_diff_on_arcsin Real.contDiffOn_arcsin\n\ntheorem contDiffAt_arcsin_iff {x : ℝ} {n : ℕ∞} : ContDiffAt ℝ n arcsin x ↔ n = 0 ∨ x ≠ -1 ∧ x ≠ 1 :=\n  ⟨fun h =>\n    or_iff_not_imp_left.2 fun hn =>\n      differentiableAt_arcsin.1 <| h.DifferentiableAt <| ENat.one_le_iff_ne_zero.2 hn,\n    fun h =>\n    h.elim (fun hn => hn.symm ▸ (contDiff_zero.2 continuous_arcsin).ContDiffAt) fun hx =>\n      contDiffAt_arcsin hx.1 hx.2⟩\n#align real.cont_diff_at_arcsin_iff Real.contDiffAt_arcsin_iff\n\nend Arcsin\n\nsection Arccos\n\ntheorem hasStrictDerivAt_arccos {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) :\n    HasStrictDerivAt arccos (-(1 / sqrt (1 - x ^ 2))) x :=\n  (hasStrictDerivAt_arcsin h₁ h₂).const_sub (π / 2)\n#align real.has_strict_deriv_at_arccos Real.hasStrictDerivAt_arccos\n\ntheorem hasDerivAt_arccos {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) :\n    HasDerivAt arccos (-(1 / sqrt (1 - x ^ 2))) x :=\n  (hasDerivAt_arcsin h₁ h₂).const_sub (π / 2)\n#align real.has_deriv_at_arccos Real.hasDerivAt_arccos\n\ntheorem contDiffAt_arccos {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) {n : ℕ∞} : ContDiffAt ℝ n arccos x :=\n  contDiffAt_const.sub (contDiffAt_arcsin h₁ h₂)\n#align real.cont_diff_at_arccos Real.contDiffAt_arccos\n\ntheorem hasDerivWithinAt_arccos_Ici {x : ℝ} (h : x ≠ -1) :\n    HasDerivWithinAt arccos (-(1 / sqrt (1 - x ^ 2))) (Ici x) x :=\n  (hasDerivWithinAt_arcsin_Ici h).const_sub _\n#align real.has_deriv_within_at_arccos_Ici Real.hasDerivWithinAt_arccos_Ici\n\ntheorem hasDerivWithinAt_arccos_Iic {x : ℝ} (h : x ≠ 1) :\n    HasDerivWithinAt arccos (-(1 / sqrt (1 - x ^ 2))) (Iic x) x :=\n  (hasDerivWithinAt_arcsin_Iic h).const_sub _\n#align real.has_deriv_within_at_arccos_Iic Real.hasDerivWithinAt_arccos_Iic\n\ntheorem differentiableWithinAt_arccos_Ici {x : ℝ} :\n    DifferentiableWithinAt ℝ arccos (Ici x) x ↔ x ≠ -1 :=\n  (differentiableWithinAt_const_sub_iff _).trans differentiableWithinAt_arcsin_Ici\n#align real.differentiable_within_at_arccos_Ici Real.differentiableWithinAt_arccos_Ici\n\ntheorem differentiableWithinAt_arccos_Iic {x : ℝ} :\n    DifferentiableWithinAt ℝ arccos (Iic x) x ↔ x ≠ 1 :=\n  (differentiableWithinAt_const_sub_iff _).trans differentiableWithinAt_arcsin_Iic\n#align real.differentiable_within_at_arccos_Iic Real.differentiableWithinAt_arccos_Iic\n\ntheorem differentiableAt_arccos {x : ℝ} : DifferentiableAt ℝ arccos x ↔ x ≠ -1 ∧ x ≠ 1 :=\n  (differentiableAt_const_sub_iff _).trans differentiableAt_arcsin\n#align real.differentiable_at_arccos Real.differentiableAt_arccos\n\n@[simp]\ntheorem deriv_arccos : deriv arccos = fun x => -(1 / sqrt (1 - x ^ 2)) :=\n  funext fun x => (deriv_const_sub _).trans <| by simp only [deriv_arcsin]\n#align real.deriv_arccos Real.deriv_arccos\n\ntheorem differentiableOn_arccos : DifferentiableOn ℝ arccos ({-1, 1}ᶜ) :=\n  differentiableOn_arcsin.const_sub _\n#align real.differentiable_on_arccos Real.differentiableOn_arccos\n\ntheorem contDiffOn_arccos {n : ℕ∞} : ContDiffOn ℝ n arccos ({-1, 1}ᶜ) :=\n  contDiffOn_const.sub contDiffOn_arcsin\n#align real.cont_diff_on_arccos Real.contDiffOn_arccos\n\ntheorem contDiffAt_arccos_iff {x : ℝ} {n : ℕ∞} : ContDiffAt ℝ n arccos x ↔ n = 0 ∨ x ≠ -1 ∧ x ≠ 1 :=\n  by\n  refine' Iff.trans ⟨fun h => _, fun h => _⟩ cont_diff_at_arcsin_iff <;>\n    simpa [arccos] using (@contDiffAt_const _ _ _ _ _ _ _ _ _ _ (π / 2)).sub h\n#align real.cont_diff_at_arccos_iff Real.contDiffAt_arccos_iff\n\nend Arccos\n\nend Real\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.4756540573152914}}
{"text": "import .convex set_theory.cardinal order.well_founded set_theory.cardinal_ordinal\n\nopen_locale cardinal\n\nsection\nuniverse u\nparameters {α : Type u} [has_betweenness α]\n\n@[reducible]\ndef generates (b : set α) (s : set α) (h : is_affine s) : Prop :=\naffine_hull b = s\n\ntheorem generates.of_span {s : set α} (h : is_affine s) : generates s s h :=\nh\n\n@[reducible]\ndef generators {s : set α} (h : is_affine s) : set (set α) :=\n{b | generates b s h}\n\nnamespace generators\n\ntheorem self_gens {s : set α} : ∀ h : is_affine s, s ∈ generators h :=\ngenerates.of_span\n\ntheorem is_nonempty {s : set α} (h : is_affine s) : (generators h).nonempty :=\n⟨s, self_gens h⟩\n\nend generators\n\n@[reducible]\ndef is_basis {s : set α} {h : is_affine s} (b : generators h) : Prop :=\n∀ b' ∈ generators h, #b ≤ #b'\n\n@[reducible]\ndef bases {s : set α} (h : is_affine s) : set (@generators s h) :=\nis_basis\n\nend\n\nprotected def {u} bases.univ (α : Type u) [has_betweenness α] : set (generators is_affine.univ) :=\n@bases α _ _ _\n\nsection\nuniverse u\n\ntheorem cardinal.le_mk_le_iff_ex_sub_right {α : Type u} {s t : set α} (h : #s ≤ #t) :\n  ∃ s' ⊆ t, #s' = #s :=\nbegin\n  rw cardinal.le_mk_iff_exists_subset at h,\n  rcases h with ⟨s', _, _⟩,\n  exact ⟨s', ‹_›, ‹_›⟩\nend\n\nparameters {α : Type u} [has_betweenness α]\n\nnamespace bases\n\ntheorem is_nonempty {s : set α} (h : is_affine s) : (bases h).nonempty :=\nbegin\n  have gne : (@set.univ $ generators h).nonempty,\n    { cases generators.is_nonempty h with w h, exact ⟨⟨w, h⟩, trivial⟩ },\n  let f := λ l r : generators h, #l < #r,\n  rcases well_founded.has_min (inv_image.wf _ cardinal.wf) _ gne with ⟨b, _, hb⟩,\n  refine ⟨b, λ b' hb', _⟩,\n  specialize hb ⟨b', hb'⟩ trivial,\n  change ¬ _ < _ at hb,\n  simp at hb,\n  assumption\nend\n\ninstance {s : set α} (h : is_affine s) : nonempty (bases h) :=\n⟨⟨(is_nonempty h).some, (is_nonempty h).some_mem⟩⟩\n\ndef basis_card {s : set α} (h : is_affine s) : cardinal :=\n#(nonempty h).some\n\ntheorem all_bases_same_card {s : set α} {h : is_affine s} (b : bases h) : #b = basis_card h :=\nbegin\n  rcases b with ⟨⟨g, hg⟩, hbg⟩,\n  let b' := (infer_instance : nonempty $ bases h).some,\n  change #g = #b',\n  exact le_antisymm (hbg b'.val b'.val.property) (b'.property g hg)\nend\n\n/-\ntheorem ex_union_basis_of_gen {s : set α} (hs : is_affine s) (g : generators _ hs) :\n  ∃ (s' : set α) (b : bases hs), s' ∪ b = g :=\nbegin\n  by_cases hg : is_basis _ _ g, { exact ⟨∅, ⟨g, hg⟩, by simp⟩ },\n  rw is_basis at hg, push_neg at hg,\n  rcases hg with ⟨b, hbg, ⟨hb : _ ≤ #g.val, hb' : ¬ (#g.val ≤ _)⟩⟩,\n  by_contra h,\n  push_neg at h,\n  specialize h b,\nend\n\n--theorem ex_subgen {s : set α} {hs : is_affine s} {g : generators _ hs} (h : )\n\ntheorem ex_basis_sub_gen {s : set α} (hs : is_affine s) (g : generators _ hs) :\n  ∃ b : bases hs, b.val.val ⊆ g.val :=\nbegin\n  by_cases hg : is_basis _ _ g, { exact ⟨⟨g, hg⟩, set.subset.rfl⟩ },\n  rw is_basis at hg, push_neg at hg,\n  rcases hg with ⟨b, hbg, ⟨hb : _ ≤ #g.val, hb' : ¬ (#g.val ≤ _)⟩⟩,\n  rw cardinal.le_mk_iff_exists_subset at hb hb',\n  rcases hb with ⟨w, hw, hw'⟩,\n  push_neg at hb',\n  refine ⟨⟨⟨w, _⟩, _⟩, hw⟩,\nend\n-/\n\nend bases\nend\n", "meta": {"author": "ocornoc", "repo": "geodude", "sha": "e63c87db67f1686c902e9bcd1863e74e1a29457f", "save_path": "github-repos/lean/ocornoc-geodude", "path": "github-repos/lean/ocornoc-geodude/geodude-e63c87db67f1686c902e9bcd1863e74e1a29457f/src/ordered/dimality.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.475609605880849}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.preserves.shapes.zero\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Preserves.Shapes.Terminal\nimport Mathbin.CategoryTheory.Limits.Shapes.ZeroMorphisms\n\n/-!\n# Preservation of zero objects and zero morphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define the class `preserves_zero_morphisms` and show basic properties.\n\n## Main results\n\nWe provide the following results:\n* Left adjoints and right adjoints preserve zero morphisms;\n* full functors preserve zero morphisms;\n* if both categories involved have a zero object, then a functor preserves zero morphisms if and\n  only if it preserves the zero object;\n* functors which preserve initial or terminal objects preserve zero morphisms.\n\n-/\n\n\nuniverse v₁ v₂ u₁ u₂\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]\n\nsection ZeroMorphisms\n\nvariable [HasZeroMorphisms C] [HasZeroMorphisms D]\n\n#print CategoryTheory.Functor.PreservesZeroMorphisms /-\n/-- A functor preserves zero morphisms if it sends zero morphisms to zero morphisms. -/\nclass PreservesZeroMorphisms (F : C ⥤ D) : Prop where\n  map_zero' : ∀ X Y : C, F.map (0 : X ⟶ Y) = 0 := by obviously\n#align category_theory.functor.preserves_zero_morphisms CategoryTheory.Functor.PreservesZeroMorphisms\n-/\n\n/- warning: category_theory.functor.map_zero -> CategoryTheory.Functor.map_zero is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y (OfNat.ofNat.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (OfNat.mk.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (Zero.zero.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) (CategoryTheory.Limits.HasZeroMorphisms.hasZero.{u1, u3} C _inst_1 _inst_3 X Y))))) (OfNat.ofNat.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) 0 (OfNat.mk.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) 0 (Zero.zero.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) (CategoryTheory.Limits.HasZeroMorphisms.hasZero.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)))))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y (OfNat.ofNat.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (Zero.toOfNat0.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) (CategoryTheory.Limits.HasZeroMorphisms.Zero.{u1, u3} C _inst_1 _inst_3 X Y)))) (OfNat.ofNat.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) 0 (Zero.toOfNat0.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) (CategoryTheory.Limits.HasZeroMorphisms.Zero.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y))))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_zero CategoryTheory.Functor.map_zeroₓ'. -/\n@[simp]\nprotected theorem map_zero (F : C ⥤ D) [PreservesZeroMorphisms F] (X Y : C) :\n    F.map (0 : X ⟶ Y) = 0 :=\n  PreservesZeroMorphisms.map_zero' _ _\n#align category_theory.functor.map_zero CategoryTheory.Functor.map_zero\n\n/- warning: category_theory.functor.zero_of_map_zero -> CategoryTheory.Functor.zero_of_map_zero is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f) (OfNat.ofNat.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) 0 (OfNat.mk.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) 0 (Zero.zero.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) (CategoryTheory.Limits.HasZeroMorphisms.hasZero.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)))))) -> (Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) f (OfNat.ofNat.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (OfNat.mk.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (Zero.zero.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) (CategoryTheory.Limits.HasZeroMorphisms.hasZero.{u1, u3} C _inst_1 _inst_3 X Y)))))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y), (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f) (OfNat.ofNat.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) 0 (Zero.toOfNat0.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) (CategoryTheory.Limits.HasZeroMorphisms.Zero.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y))))) -> (Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) f (OfNat.ofNat.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (Zero.toOfNat0.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) (CategoryTheory.Limits.HasZeroMorphisms.Zero.{u1, u3} C _inst_1 _inst_3 X Y))))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.zero_of_map_zero CategoryTheory.Functor.zero_of_map_zeroₓ'. -/\ntheorem zero_of_map_zero (F : C ⥤ D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} (f : X ⟶ Y)\n    (h : F.map f = 0) : f = 0 :=\n  F.map_injective <| h.trans <| Eq.symm <| F.map_zero _ _\n#align category_theory.functor.zero_of_map_zero CategoryTheory.Functor.zero_of_map_zero\n\n/- warning: category_theory.functor.map_eq_zero_iff -> CategoryTheory.Functor.map_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y}, Iff (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X Y f) (OfNat.ofNat.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) 0 (OfNat.mk.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) 0 (Zero.zero.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) (CategoryTheory.Limits.HasZeroMorphisms.hasZero.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)))))) (Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) f (OfNat.ofNat.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (OfNat.mk.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (Zero.zero.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) (CategoryTheory.Limits.HasZeroMorphisms.hasZero.{u1, u3} C _inst_1 _inst_3 X Y)))))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Faithful.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] {X : C} {Y : C} {f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y}, Iff (Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X Y f) (OfNat.ofNat.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) 0 (Zero.toOfNat0.{u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) (CategoryTheory.Limits.HasZeroMorphisms.Zero.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y))))) (Eq.{succ u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) f (OfNat.ofNat.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) 0 (Zero.toOfNat0.{u1} (Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X Y) (CategoryTheory.Limits.HasZeroMorphisms.Zero.{u1, u3} C _inst_1 _inst_3 X Y))))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_eq_zero_iff CategoryTheory.Functor.map_eq_zero_iffₓ'. -/\ntheorem map_eq_zero_iff (F : C ⥤ D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} {f : X ⟶ Y} :\n    F.map f = 0 ↔ f = 0 :=\n  ⟨F.zero_of_map_zero _, by\n    rintro rfl\n    exact F.map_zero _ _⟩\n#align category_theory.functor.map_eq_zero_iff CategoryTheory.Functor.map_eq_zero_iff\n\n#print CategoryTheory.Functor.preservesZeroMorphisms_of_isLeftAdjoint /-\ninstance (priority := 100) preservesZeroMorphisms_of_isLeftAdjoint (F : C ⥤ D) [IsLeftAdjoint F] :\n    PreservesZeroMorphisms F\n    where map_zero' X Y := by\n    let adj := Adjunction.ofLeftAdjoint F\n    calc\n      F.map (0 : X ⟶ Y) = F.map 0 ≫ F.map (adj.unit.app Y) ≫ adj.counit.app (F.obj Y) := _\n      _ = F.map 0 ≫ F.map ((right_adjoint F).map (0 : F.obj X ⟶ _)) ≫ adj.counit.app (F.obj Y) := _\n      _ = 0 := _\n      \n    · rw [adjunction.left_triangle_components]\n      exact (category.comp_id _).symm\n    · simp only [← category.assoc, ← F.map_comp, zero_comp]\n    · simp only [adjunction.counit_naturality, comp_zero]\n#align category_theory.functor.preserves_zero_morphisms_of_is_left_adjoint CategoryTheory.Functor.preservesZeroMorphisms_of_isLeftAdjoint\n-/\n\n#print CategoryTheory.Functor.preservesZeroMorphisms_of_isRightAdjoint /-\ninstance (priority := 100) preservesZeroMorphisms_of_isRightAdjoint (G : C ⥤ D) [IsRightAdjoint G] :\n    PreservesZeroMorphisms G\n    where map_zero' X Y := by\n    let adj := Adjunction.ofRightAdjoint G\n    calc\n      G.map (0 : X ⟶ Y) = adj.unit.app (G.obj X) ≫ G.map (adj.counit.app X) ≫ G.map 0 := _\n      _ = adj.unit.app (G.obj X) ≫ G.map ((left_adjoint G).map (0 : _ ⟶ G.obj X)) ≫ G.map 0 := _\n      _ = 0 := _\n      \n    · rw [adjunction.right_triangle_components_assoc]\n    · simp only [← G.map_comp, comp_zero]\n    · simp only [adjunction.unit_naturality_assoc, zero_comp]\n#align category_theory.functor.preserves_zero_morphisms_of_is_right_adjoint CategoryTheory.Functor.preservesZeroMorphisms_of_isRightAdjoint\n-/\n\n#print CategoryTheory.Functor.preservesZeroMorphisms_of_full /-\ninstance (priority := 100) preservesZeroMorphisms_of_full (F : C ⥤ D) [Full F] :\n    PreservesZeroMorphisms F\n    where map_zero' X Y :=\n    calc\n      F.map (0 : X ⟶ Y) = F.map (0 ≫ F.preimage (0 : F.obj Y ⟶ F.obj Y)) := by rw [zero_comp]\n      _ = 0 := by rw [F.map_comp, F.image_preimage, comp_zero]\n      \n#align category_theory.functor.preserves_zero_morphisms_of_full CategoryTheory.Functor.preservesZeroMorphisms_of_full\n-/\n\nend ZeroMorphisms\n\nsection ZeroObject\n\nvariable [HasZeroObject C] [HasZeroObject D]\n\nopen ZeroObject\n\nvariable [HasZeroMorphisms C] [HasZeroMorphisms D] (F : C ⥤ D)\n\n/- warning: category_theory.functor.map_zero_object -> CategoryTheory.Functor.mapZeroObject is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroObject.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroObject.{u2, u4} D _inst_2] [_inst_5 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_6 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_5 _inst_6 F], CategoryTheory.Iso.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (OfNat.ofNat.{u3} C 0 (OfNat.mk.{u3} C 0 (Zero.zero.{u3} C (CategoryTheory.Limits.HasZeroObject.zero'.{u1, u3} C _inst_1 _inst_3))))) (OfNat.ofNat.{u4} D 0 (OfNat.mk.{u4} D 0 (Zero.zero.{u4} D (CategoryTheory.Limits.HasZeroObject.zero'.{u2, u4} D _inst_2 _inst_4))))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroObject.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroObject.{u2, u4} D _inst_2] [_inst_5 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_6 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_5 _inst_6 F], CategoryTheory.Iso.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (OfNat.ofNat.{u3} C 0 (Zero.toOfNat0.{u3} C (CategoryTheory.Limits.HasZeroObject.zero'.{u1, u3} C _inst_1 _inst_3)))) (OfNat.ofNat.{u4} D 0 (Zero.toOfNat0.{u4} D (CategoryTheory.Limits.HasZeroObject.zero'.{u2, u4} D _inst_2 _inst_4)))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_zero_object CategoryTheory.Functor.mapZeroObjectₓ'. -/\n/-- A functor that preserves zero morphisms also preserves the zero object. -/\n@[simps]\ndef mapZeroObject [PreservesZeroMorphisms F] : F.obj 0 ≅ 0\n    where\n  Hom := 0\n  inv := 0\n  hom_inv_id' := by rw [← F.map_id, id_zero, F.map_zero, zero_comp]\n  inv_hom_id' := by rw [id_zero, comp_zero]\n#align category_theory.functor.map_zero_object CategoryTheory.Functor.mapZeroObject\n\nvariable {F}\n\n/- warning: category_theory.functor.preserves_zero_morphisms_of_map_zero_object -> CategoryTheory.Functor.preservesZeroMorphisms_of_map_zero_object is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroObject.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroObject.{u2, u4} D _inst_2] [_inst_5 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_6 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] {F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2}, (CategoryTheory.Iso.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (OfNat.ofNat.{u3} C 0 (OfNat.mk.{u3} C 0 (Zero.zero.{u3} C (CategoryTheory.Limits.HasZeroObject.zero'.{u1, u3} C _inst_1 _inst_3))))) (OfNat.ofNat.{u4} D 0 (OfNat.mk.{u4} D 0 (Zero.zero.{u4} D (CategoryTheory.Limits.HasZeroObject.zero'.{u2, u4} D _inst_2 _inst_4))))) -> (CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_5 _inst_6 F)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroObject.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroObject.{u2, u4} D _inst_2] [_inst_5 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_6 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] {F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2}, (CategoryTheory.Iso.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (OfNat.ofNat.{u3} C 0 (Zero.toOfNat0.{u3} C (CategoryTheory.Limits.HasZeroObject.zero'.{u1, u3} C _inst_1 _inst_3)))) (OfNat.ofNat.{u4} D 0 (Zero.toOfNat0.{u4} D (CategoryTheory.Limits.HasZeroObject.zero'.{u2, u4} D _inst_2 _inst_4)))) -> (CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_5 _inst_6 F)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.preserves_zero_morphisms_of_map_zero_object CategoryTheory.Functor.preservesZeroMorphisms_of_map_zero_objectₓ'. -/\ntheorem preservesZeroMorphisms_of_map_zero_object (i : F.obj 0 ≅ 0) : PreservesZeroMorphisms F :=\n  {\n    map_zero' := fun X Y =>\n      calc\n        F.map (0 : X ⟶ Y) = F.map (0 : X ⟶ 0) ≫ F.map 0 := by rw [← functor.map_comp, comp_zero]\n        _ = F.map 0 ≫ (i.Hom ≫ i.inv) ≫ F.map 0 := by rw [iso.hom_inv_id, category.id_comp]\n        _ = 0 := by simp only [zero_of_to_zero i.hom, zero_comp, comp_zero]\n         }\n#align category_theory.functor.preserves_zero_morphisms_of_map_zero_object CategoryTheory.Functor.preservesZeroMorphisms_of_map_zero_object\n\n#print CategoryTheory.Functor.preservesZeroMorphisms_of_preserves_initial_object /-\ninstance (priority := 100) preservesZeroMorphisms_of_preserves_initial_object\n    [PreservesColimit (Functor.empty.{0} C) F] : PreservesZeroMorphisms F :=\n  preservesZeroMorphisms_of_map_zero_object <|\n    F.mapIso HasZeroObject.zeroIsoInitial ≪≫\n      PreservesInitial.iso F ≪≫ HasZeroObject.zeroIsoInitial.symm\n#align category_theory.functor.preserves_zero_morphisms_of_preserves_initial_object CategoryTheory.Functor.preservesZeroMorphisms_of_preserves_initial_object\n-/\n\n#print CategoryTheory.Functor.preservesZeroMorphisms_of_preserves_terminal_object /-\ninstance (priority := 100) preservesZeroMorphisms_of_preserves_terminal_object\n    [PreservesLimit (Functor.empty.{0} C) F] : PreservesZeroMorphisms F :=\n  preservesZeroMorphisms_of_map_zero_object <|\n    F.mapIso HasZeroObject.zeroIsoTerminal ≪≫\n      PreservesTerminal.iso F ≪≫ HasZeroObject.zeroIsoTerminal.symm\n#align category_theory.functor.preserves_zero_morphisms_of_preserves_terminal_object CategoryTheory.Functor.preservesZeroMorphisms_of_preserves_terminal_object\n-/\n\nvariable (F)\n\n#print CategoryTheory.Functor.preservesTerminalObjectOfPreservesZeroMorphisms /-\n/-- Preserving zero morphisms implies preserving terminal objects. -/\ndef preservesTerminalObjectOfPreservesZeroMorphisms [PreservesZeroMorphisms F] :\n    PreservesLimit (Functor.empty C) F :=\n  preservesTerminalOfIso F <|\n    F.mapIso HasZeroObject.zeroIsoTerminal.symm ≪≫ mapZeroObject F ≪≫ HasZeroObject.zeroIsoTerminal\n#align category_theory.functor.preserves_terminal_object_of_preserves_zero_morphisms CategoryTheory.Functor.preservesTerminalObjectOfPreservesZeroMorphisms\n-/\n\n#print CategoryTheory.Functor.preservesInitialObjectOfPreservesZeroMorphisms /-\n/-- Preserving zero morphisms implies preserving terminal objects. -/\ndef preservesInitialObjectOfPreservesZeroMorphisms [PreservesZeroMorphisms F] :\n    PreservesColimit (Functor.empty C) F :=\n  preservesInitialOfIso F <|\n    HasZeroObject.zeroIsoInitial.symm ≪≫\n      (mapZeroObject F).symm ≪≫ (F.mapIso HasZeroObject.zeroIsoInitial.symm).symm\n#align category_theory.functor.preserves_initial_object_of_preserves_zero_morphisms CategoryTheory.Functor.preservesInitialObjectOfPreservesZeroMorphisms\n-/\n\nend ZeroObject\n\nend CategoryTheory.Functor\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Preserves/Shapes/Zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624890918021, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.47559516903082544}}
{"text": "import linear_algebra.adic_completion\nimport ring_theory.witt_vector.basic\nimport ring_theory.perfection\nimport Cp_def\n\nnoncomputable theory\n\nvariables (p : ℕ)  [fact p.prime]\n\n/- Fontaine period rings -/\n\nopen mv_polynomial\n\n@[derive comm_ring]\ndef Cp_x_y := mv_polynomial (fin 2) ℂ_[p]\n\ndef B_HT := (Cp_x_y  p) ⧸ (ideal.span {(X 0 * X 1 - 1)} : ideal (Cp_x_y  p))\n\n\ninstance O_C_p_mod_p.char_p : char_p (𝓞_ℂ_[p] ⧸ (ideal.span{p} : ideal 𝓞_ℂ_[p])) p := sorry\ndef E := ring.perfection (𝓞_ℂ_[p] ⧸ (ideal.span{p} : ideal 𝓞_ℂ_[p])) p\ninstance : comm_ring (E p) := perfection.comm_ring _ _\n\ndef A_inf := witt_vector p (E p)\n\ninstance : comm_ring (A_inf p) := witt_vector.comm_ring _ _\n\ndef B_inf_plus := localization.away (p : A_inf p)\ninstance : comm_ring (B_inf_plus p) := localization.comm_ring\n\n/- lemma theta : ring_hom (B_inf_plus p) ℂ_[p] := sorry\n\nlemma theta.surjective : function.surjective (theta p) := sorry\n\ndef B_dR_plus := adic_completion (theta p).ker (B_inf_plus p)\n\nnoncomputable! instance : comm_ring (B_dR_plus p) := sorry\n\ndef B_dR := fraction_ring (B_dR_plus p) -/\n\n\n\n\n\n", "meta": {"author": "mariainesdff", "repo": "local_fields", "sha": "53a20ab87cf8f6ab27eedef2d9da929898951d82", "save_path": "github-repos/lean/mariainesdff-local_fields", "path": "github-repos/lean/mariainesdff-local_fields/local_fields-53a20ab87cf8f6ab27eedef2d9da929898951d82/old_lean_files/Fontaine_period_rings.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8887587964389112, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.4755734354025399}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.preadditive.additive_functor\nimport category_theory.linear\n\n/-!\n# Linear Functors\n\nAn additive functor between two `R`-linear categories is called *linear*\nif the induced map on hom types is a morphism of `R`-modules.\n\n# Implementation details\n\n`functor.linear` is a `Prop`-valued class, defined by saying that\nfor every two objects `X` and `Y`, the map\n`F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)` is a morphism of `R`-modules.\n\n-/\n\nnamespace category_theory\n\nvariables (R : Type*) [semiring R]\n\n/-- An additive functor `F` is `R`-linear provided `F.map` is an `R`-module morphism. -/\nclass functor.linear {C D : Type*} [category C] [category D]\n  [preadditive C] [preadditive D] [linear R C] [linear R D] (F : C ⥤ D) [F.additive] : Prop :=\n(map_smul' : Π {X Y : C} {f : X ⟶ Y} {r : R}, F.map (r • f) = r • F.map f . obviously)\n\nsection linear\n\nnamespace functor\n\nsection\nvariables {R} {C D : Type*} [category C] [category D]\n  [preadditive C] [preadditive D] [category_theory.linear R C] [category_theory.linear R D]\n  (F : C ⥤ D) [additive F] [linear R F]\n\n@[simp]\nlemma map_smul {X Y : C} (r : R) (f : X ⟶ Y) : F.map (r • f) = r • F.map f :=\nfunctor.linear.map_smul'\n\ninstance : linear R (𝟭 C) :=\n{}\n\ninstance {E : Type*} [category E] [preadditive E] [category_theory.linear R E]\n  (G : D ⥤ E) [additive G] [linear R G]:\n  linear R (F ⋙ G) :=\n{}\n\nvariables (R)\n\n/-- `F.map_linear_map` is an `R`-linear map whose underlying function is `F.map`. -/\n@[simps]\ndef map_linear_map {X Y : C} : (X ⟶ Y) →ₗ[R] (F.obj X ⟶ F.obj Y) :=\n{ map_smul' := λ r f, F.map_smul r f,\n  ..F.map_add_hom }\n\nlemma coe_map_linear_map {X Y : C} : ⇑(F.map_linear_map R : (X ⟶ Y) →ₗ[R] _) = @map C _ D _ F X Y :=\nrfl\n\nend\n\nsection induced_category\nvariables {C : Type*} {D : Type*} [category D] [preadditive D] [category_theory.linear R D]\n   (F : C → D)\n\ninstance induced_functor_linear : functor.linear R (induced_functor F) := {}\n\nend induced_category\n\nsection\n\nvariables {R} {C D : Type*} [category C] [category D]\n  [preadditive C] [preadditive D]\n  (F : C ⥤ D) [additive F]\n\ninstance nat_linear : F.linear ℕ :=\n{ map_smul' := λ X Y f r, F.map_add_hom.map_nsmul f r, }\n\ninstance int_linear : F.linear ℤ :=\n{ map_smul' := λ X Y f r, F.map_add_hom.map_zsmul f r, }\n\nvariables [category_theory.linear ℚ C] [category_theory.linear ℚ D]\n\ninstance rat_linear : F.linear ℚ :=\n{ map_smul' := λ X Y f r, F.map_add_hom.to_rat_linear_map.map_smul r f, }\n\nend\n\nend functor\n\nnamespace equivalence\n\nvariables {C D : Type*} [category C] [category D]\n  [preadditive C] [linear R C] [preadditive D] [linear R D]\n\ninstance inverse_linear (e : C ≌ D) [e.functor.additive] [e.functor.linear R] :\n  e.inverse.linear R :=\n{ map_smul' := λ X Y r f, by { apply e.functor.map_injective, simp, }, }\n\nend equivalence\n\nend linear\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/linear/linear_functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4755613288263433}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport data.rat.order\nimport data.int.char_zero\n\n/-!\n# Casts for Rational Numbers\n\n## Summary\n\nWe define the canonical injection from ℚ into an arbitrary division ring and prove various\ncasting lemmas showing the well-behavedness of this injection.\n\n## Notations\n\n- `/.` is infix notation for `rat.mk`.\n\n## Tags\n\nrat, rationals, field, ℚ, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nnamespace rat\nvariable {α : Type*}\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring α]\n\n/-- Construct the canonical injection from `ℚ` into an arbitrary\n  division ring. If the field has positive characteristic `p`,\n  we define `1 / p = 1 / 0 = 0` for consistency with our\n  division by zero convention. -/\n-- see Note [coercion into rings]\n@[priority 900] instance cast_coe : has_coe_t ℚ α := ⟨λ r, r.1 / r.2⟩\n\n@[simp] theorem cast_of_int (n : ℤ) : (of_int n : α) = n :=\nshow (n / (1:ℕ) : α) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : ℤ) : ((n : ℚ) : α) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : ℕ) : ((n : ℚ) : α) = n := cast_coe_int n\n\n@[simp, norm_cast] theorem cast_zero : ((0 : ℚ) : α) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : ℚ) : α) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : ℚ) (a : α) : commute ↑r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : ℚ) (a : α) : (r : α) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : α) (r : ℚ) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : ℤ)\n  (b0 : (b:α) ≠ 0) : (a /. b : α) = a / b :=\nbegin\n  have b0' : b ≠ 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:α) ≠ 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:ℤ) ∣ b, by rwa e at dd) with k ke,\n    have : (b:α) = (d:α) * (k:α), {rw [ke, int.cast_mul], refl},\n    rw [d0, zero_mul] at this, contradiction },\n  rw [num_denom'] at e,\n  have := congr_arg (coe : ℤ → α) ((mk_eq b0' $ ne_of_gt $ int.coe_nat_pos.2 h).1 e),\n  rw [int.cast_mul, int.cast_mul, int.cast_coe_nat] at this,\n  symmetry, change (a / b : α) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      ← mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m + n : ℚ) : α) = m + n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', add_def d₁0' d₂0'],\n  suffices : (n₁ * (d₂ * (d₂⁻¹ * d₁⁻¹)) +\n    n₂ * (d₁ * d₂⁻¹) * d₁⁻¹ : α) = n₁ * d₁⁻¹ + n₂ * d₂⁻¹,\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, left_distrib, right_distrib, mul_inv_rev', d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [← mul_assoc (d₂:α), mul_inv_cancel d₂0, one_mul,\n      (nat.cast_commute _ _).eq], simp [d₁0, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : ∀ n, ((-n : ℚ) : α) = -n\n| ⟨n, d, h, c⟩ := show (↑-n / d : α) = -(n / d),\n  by rw [div_eq_mul_inv, div_eq_mul_inv, int.cast_neg, neg_mul_eq_neg_mul]\n\n@[norm_cast] theorem cast_sub_of_ne_zero {m n : ℚ}\n  (m0 : (m.denom : α) ≠ 0) (n0 : (n.denom : α) ≠ 0) : ((m - n : ℚ) : α) = m - n :=\nhave ((-n).denom : α) ≠ 0, by cases n; exact n0,\nby simp [sub_eq_add_neg, (cast_add_of_ne_zero m0 this)]\n\n@[norm_cast] theorem cast_mul_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m * n : ℚ) : α) = m * n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', mul_def d₁0' d₂0'],\n  suffices : (n₁ * ((n₂ * d₂⁻¹) * d₁⁻¹) : α) = n₁ * (d₁⁻¹ * (n₂ * d₂⁻¹)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_rev', d₁0, d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0]} },\n  rw [(d₁.commute_cast (_:α)).inv_right'.eq]\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : ∀ {n : ℚ},\n  (n.num : α) ≠ 0 → (n.denom : α) ≠ 0 → ((n⁻¹ : ℚ) : α) = n⁻¹\n| ⟨n, d, h, c⟩ := λ (n0 : (n:α) ≠ 0) (d0 : (d:α) ≠ 0), begin\n  have n0' : (n:ℤ) ≠ 0 := λ e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d0; exact d0 rfl),\n  rw [num_denom', inv_def],\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, inv_div];\n  simp [n0, d0]\nend\n\n@[norm_cast] theorem cast_div_of_ne_zero {m n : ℚ} (md : (m.denom : α) ≠ 0)\n  (nn : (n.num : α) ≠ 0) (nd : (n.denom : α) ≠ 0) : ((m / n : ℚ) : α) = m / n :=\nhave (n⁻¹.denom : ℤ) ∣ n.num,\nby conv in n⁻¹.denom { rw [←(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n⁻¹.denom : α) = 0 → (n.num : α) = 0, from\nλ h, let ⟨k, e⟩ := this in\n  by have := congr_arg (coe : ℤ → α) e;\n     rwa [int.cast_mul, int.cast_coe_nat, h, zero_mul] at this,\nby rw [division_def, cast_mul_of_ne_zero md (mt this nn), cast_inv_of_ne_zero nn nd, division_def]\n\n@[simp, norm_cast] theorem cast_inj [char_zero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := begin\n  refine ⟨λ h, _, congr_arg _⟩,\n  have d₁0 : d₁ ≠ 0 := ne_of_gt h₁,\n  have d₂0 : d₂ ≠ 0 := ne_of_gt h₂,\n  have d₁a : (d₁:α) ≠ 0 := nat.cast_ne_zero.2 d₁0,\n  have d₂a : (d₂:α) ≠ 0 := nat.cast_ne_zero.2 d₂0,\n  rw [num_denom', num_denom'] at h ⊢,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d₁0, d₂0] at h ⊢,\n  rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂:α)).inv_left'.eq,\n    ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm,\n    ← int.cast_coe_nat, ← int.cast_mul, ← int.cast_coe_nat, ← int.cast_mul,\n    int.cast_inj, ← mk_eq (int.coe_nat_ne_zero.2 d₁0) (int.coe_nat_ne_zero.2 d₂0)] at h\nend\n\ntheorem cast_injective [char_zero α] : function.injective (coe : ℚ → α)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 :=\nby rw [← cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero α] {n : ℚ} : (n : α) ≠ 0 ↔ n ≠ 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero α] (m n) :\n  ((m + n : ℚ) : α) = m + n :=\ncast_add_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_sub [char_zero α] (m n) :\n  ((m - n : ℚ) : α) = m - n :=\ncast_sub_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_mul [char_zero α] (m n) :\n  ((m * n : ℚ) : α) = m * n :=\ncast_mul_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp, norm_cast] theorem cast_bit0 [char_zero α] (n : ℚ) :\n  ((bit0 n : ℚ) : α) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero α] (n : ℚ) :\n  ((bit1 n : ℚ) : α) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariable (α)\n\n/-- Coercion `ℚ → α` as a `ring_hom`. -/\ndef cast_hom [char_zero α] : ℚ →+* α := ⟨coe, cast_one, cast_mul, cast_zero, cast_add⟩\n\nvariable {α}\n\n@[simp] lemma coe_cast_hom [char_zero α] : ⇑(cast_hom α) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv [char_zero α] (n) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\n(cast_hom α).map_inv _\n\n@[simp, norm_cast] theorem cast_div [char_zero α] (m n) :\n  ((m / n : ℚ) : α) = m / n :=\n(cast_hom α).map_div _ _\n\n@[norm_cast] theorem cast_mk [char_zero α] (a b : ℤ) : ((a /. b) : α) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow [char_zero α] (q) (k : ℕ) :\n  ((q ^ k : ℚ) : α) = q ^ k :=\n(cast_hom α).map_pow q k\n\nend with_div_ring\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field α] : ∀ {n : ℚ}, 0 ≤ (n : α) ↔ 0 ≤ n\n| ⟨n, d, h, c⟩ :=\n  by { rw [num_denom', cast_mk, mk_eq_div, div_nonneg_iff, div_nonneg_iff], norm_cast }\n\n@[simp, norm_cast] theorem cast_le [linear_ordered_field α] {m n : ℚ} : (m : α) ≤ n ↔ m ≤ n :=\nby rw [← sub_nonneg, ← cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field α] {m n : ℚ} : (m : α) < n ↔ m < n :=\nby simpa [-cast_le] using not_congr (@cast_le α _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field α] {n : ℚ} : (n : α) ≤ 0 ↔ n ≤ 0 :=\nby rw [← cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field α] {n : ℚ} : (0 : α) < n ↔ 0 < n :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field α] {n : ℚ} : (n : α) < 0 ↔ n < 0 :=\nby rw [← cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : ∀ n : ℚ, ↑n = n\n| ⟨n, d, h, c⟩ := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field α] {a b : ℚ} :\n  (↑(min a b) : α) = min a b :=\nby by_cases a ≤ b; simp [h, min]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field α] {a b : ℚ} :\n  (↑(max a b) : α) = max a b :=\nby by_cases b ≤ a; simp [h, max]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field α] {q : ℚ} :\n  ((abs q : ℚ) : α) = abs q :=\nby simp [abs]\n\nend rat\n\nopen rat ring_hom\n\nlemma ring_hom.eq_rat_cast {k} [division_ring k] (f : ℚ →+* k) (r : ℚ) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [← int.cast_coe_nat, ← mk_eq_div, num_denom]\n     ... = f r.1 / f r.2 : f.map_div _ _\n     ... = r.1 / r.2     : by rw [map_nat_cast, map_int_cast]\n\n-- This seems to be true for a `[char_p k]` too because `k'` must have the same characteristic\n-- but the proof would be much longer\nlemma ring_hom.map_rat_cast {k k'} [division_ring k] [char_zero k] [division_ring k']\n  (f : k →+* k') (r : ℚ) :\n  f r = r :=\n(f.comp (cast_hom k)).eq_rat_cast r\n\nlemma ring_hom.ext_rat {R : Type*} [semiring R] (f g : ℚ →+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let φ : ℤ →+* R := f.comp (int.cast_ring_hom ℚ),\n  let ψ : ℤ →+* R := g.comp (int.cast_ring_hom ℚ),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:ℚ) ≠ 0 := nat.cast_ne_zero.2 b0,\n  have : ∀ n : ℤ, f n = g n := λ n, show φ n = ψ n, by rw [φ.ext_int ψ],\n  calc f (a * b⁻¹)\n      = f a * f b⁻¹ * (g (b:ℤ) * g b⁻¹) :\n        by rw [int.cast_coe_nat, ← g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b⁻¹ * (f (b:ℤ) * g b⁻¹) : by rw [this a, ← this b]\n  ... = g (a * b⁻¹) :\n        by rw [int.cast_coe_nat, mul_assoc, ← mul_assoc (f b⁻¹),\n              ← f.map_mul, inv_mul_cancel b0', f.map_one, one_mul, g.map_mul]\nend\n\ninstance rat.subsingleton_ring_hom {R : Type*} [semiring R] : subsingleton (ℚ →+* R) :=\n⟨ring_hom.ext_rat⟩\n\nnamespace monoid_with_zero_hom\n\nvariables {M : Type*} [group_with_zero M]\n\n/-- If `f` and `g` agree on the integers then they are equal `φ`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : monoid_with_zero_hom ℚ M}\n  (same_on_int : f.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom ℚ).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : ∀ k : ℤ, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [← @rat.num_denom x, rat.mk_eq_div, f.map_div, g.map_div,\n    same_on_int' x.num, same_on_int' x.denom],\nend\n\n/-- Positive integer values of a morphism `φ` and its value on `-1` completely determine `φ`. -/\ntheorem ext_rat_on_pnat {f g : monoid_with_zero_hom ℚ M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : ∀ n : ℕ, 0 < n → f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) ‹_›\n\nend monoid_with_zero_hom\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/rat/cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.4755613113063916}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport algebra.big_operators.multiset\n\n/-!\n# Bind operation for multisets\n\nThis file defines a few basic operations on `multiset`, notably the monadic bind.\n\n## Main declarations\n\n* `multiset.join`: The join, aka union or sum, of multisets.\n* `multiset.bind`: The bind of a multiset-indexed family of multisets.\n* `multiset.product`: Cartesian product of two multisets.\n* `multiset.sigma`: Disjoint sum of multisets in a sigma type.\n-/\n\nvariables {α β γ δ : Type*}\n\nnamespace multiset\n\n/-! ### Join -/\n\n/-- `join S`, where `S` is a multiset of multisets, is the lift of the list join\n  operation, that is, the union of all the sets.\n     join {{1, 2}, {1, 2}, {0, 1}} = {0, 1, 1, 1, 2, 2} -/\ndef join : multiset (multiset α) → multiset α := sum\n\nlemma coe_join : ∀ L : list (list α),\n  join (L.map (@coe _ (multiset α) _) : multiset (multiset α)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (λ s : multiset α, ↑l + s) (coe_join L)\n\n@[simp] lemma join_zero : @join α 0 = 0 := rfl\n@[simp] lemma join_cons (s S) : @join α (s ::ₘ S) = s + join S := sum_cons _ _\n@[simp] lemma join_add (S T) : @join α (S + T) = join S + join T := sum_add _ _\n@[simp] lemma singleton_join (a) : join ({a} : multiset (multiset α)) = a := sum_singleton _\n\n@[simp] lemma mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s :=\nmultiset.induction_on S (by simp) $\n  by simp [or_and_distrib_right, exists_or_distrib] {contextual := tt}\n\n@[simp] lemma card_join (S) : card (@join α S) = sum (map card S) :=\nmultiset.induction_on S (by simp) (by simp)\n\nlemma rel_join {r : α → β → Prop} {s t} (h : rel (rel r) s t) : rel r s.join t.join :=\nbegin\n  induction h,\n  case rel.zero { simp },\n  case rel.cons : a b s t hab hst ih { simpa using hab.add ih }\nend\n\n/-! ### Bind -/\n\nsection bind\nvariables (a : α) (s t : multiset α) (f g : α → multiset β)\n\n/-- `s.bind f` is the monad bind operation, defined as `(s.map f).join`. It is the union of `f a` as\n`a` ranges over `s`. -/\ndef bind (s : multiset α) (f : α → multiset β) : multiset β := (s.map f).join\n\n@[simp] lemma coe_bind (l : list α) (f : α → list β) : @bind α β l (λ a, f a) = l.bind f :=\nby rw [list.bind, ←coe_join, list.map_map]; refl\n\n@[simp] lemma zero_bind : bind 0 f = 0 := rfl\n@[simp] lemma cons_bind : (a ::ₘ s).bind f = f a + s.bind f := by simp [bind]\n@[simp] lemma singleton_bind : bind {a} f = f a := by simp [bind]\n@[simp] lemma add_bind : (s + t).bind f = s.bind f + t.bind f := by simp [bind]\n@[simp] lemma bind_zero : s.bind (λ a, 0 : α → multiset β) = 0 := by simp [bind, join, nsmul_zero]\n@[simp] lemma bind_add : s.bind (λ a, f a + g a) = s.bind f + s.bind g := by simp [bind, join]\n\n@[simp] lemma bind_cons (f : α → β) (g : α → multiset β) :\n  s.bind (λ a, f a ::ₘ g a) = map f s + s.bind g :=\nmultiset.induction_on s (by simp) (by simp [add_comm, add_left_comm] {contextual := tt})\n\n@[simp] lemma bind_singleton (f : α → β) : s.bind (λ x, ({f x} : multiset β)) = map f s :=\nmultiset.induction_on s (by rw [zero_bind, map_zero]) (by simp [singleton_add])\n\n@[simp] lemma mem_bind {b s} {f : α → multiset β} : b ∈ bind s f ↔ ∃ a ∈ s, b ∈ f a :=\nby simp [bind]; simp [-exists_and_distrib_right, exists_and_distrib_right.symm];\n   rw exists_swap; simp [and_assoc]\n\n@[simp] lemma card_bind : (s.bind f).card = (s.map (card ∘ f)).sum := by simp [bind]\n\nlemma bind_congr {f g : α → multiset β} {m : multiset α} :\n  (∀ a ∈ m, f a = g a) → bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {β' : Type*} {m : multiset α} {f : α → multiset β} {f' : α → multiset β'}\n  (h : β = β') (hf : ∀a ∈ m, f a == f' a) :\n  bind m f == bind m f' :=\nbegin subst h, simp at hf, simp [bind_congr hf] end\n\nlemma map_bind (m : multiset α) (n : α → multiset β) (f : β → γ) :\n  map f (bind m n) = bind m (λ a, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset α) (n : β → multiset γ) (f : α → β) :\n  bind (map f m) n = bind m (λ a, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset α} {f : α → multiset β} {g : β → multiset γ} :\n  (s.bind f).bind g = s.bind (λ a, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset α) (n : multiset β) {f : α → β → multiset γ} :\n  (bind m $ λ a, bind n $ λ b, f a b) = (bind n $ λ b, bind m $ λ a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset α) (n : multiset β) {f : α → β → γ} :\n  (bind m $ λ a, n.map $ λ b, f a b) = (bind n $ λ b, m.map $ λ a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid β] (s : multiset α) (t : α → multiset β) :\n  (s.bind t).prod = (s.map $ λ a, (t a).prod).prod :=\nmultiset.induction_on s (by simp) (assume a s ih, by simp [ih, cons_bind])\n\nlemma rel_bind {r : α → β → Prop} {p : γ → δ → Prop} {s t} {f : α → multiset γ} {g : β → multiset δ}\n  (h : (r ⇒ rel p) f g) (hst : rel r s t) :\n  rel p (s.bind f) (t.bind g) :=\nby { apply rel_join, rw rel_map, exact hst.mono (λ a ha b hb hr, h hr) }\n\nlemma count_sum [decidable_eq α] {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (map f m).sum = sum (m.map $ λ b, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind [decidable_eq α] {m : multiset β} {f : β → multiset α} {a : α} :\n  count a (bind m f) = sum (m.map $ λ b, count a $ f b) := count_sum\n\nlemma le_bind {α β : Type*} {f : α → multiset β} (S : multiset α) {x : α} (hx : x ∈ S) :\n  f x ≤ S.bind f :=\nbegin\n  classical,\n  rw le_iff_count, intro a,\n  rw count_bind, apply le_sum_of_mem,\n  rw mem_map, exact ⟨x, hx, rfl⟩\nend\nend bind\n\n/-! ### Product of two multisets -/\n\nsection product\nvariables (a : α) (b : β) (s : multiset α) (t : multiset β)\n\n/-- The multiplicity of `(a, b)` in `s.product t` is\n  the product of the multiplicity of `a` in `s` and `b` in `t`. -/\ndef product (s : multiset α) (t : multiset β) : multiset (α × β) := s.bind $ λ a, t.map $ prod.mk a\n\n@[simp] lemma coe_product (l₁ : list α) (l₂ : list β) : @product α β l₁ l₂ = l₁.product l₂ :=\nby { rw [product, list.product, ←coe_bind], simp }\n\n@[simp] lemma zero_product : @product α β 0 t = 0 := rfl\n--TODO: Add `product_zero`\n\n@[simp] lemma cons_product : (a ::ₘ s).product t = map (prod.mk a) t + s.product t :=\nby simp [product]\n\n@[simp] lemma product_singleton : ({a} : multiset α).product ({b} : multiset β) = {(a, b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] lemma add_product (s t : multiset α) (u : multiset β) :\n  (s + t).product u = s.product u + product t u :=\nby simp [product]\n\n@[simp] lemma product_add (s : multiset α) : ∀ t u : multiset β,\n  s.product (t + u) = s.product t + s.product u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] lemma mem_product {s t} : ∀ {p : α × β}, p ∈ @product α β s t ↔ p.1 ∈ s ∧ p.2 ∈ t\n| (a, b) := by simp [product, and.left_comm]\n\n@[simp] lemma card_product : (s.product t).card = s.card * t.card :=\nby simp [product, repeat, (∘), mul_comm]\n\nend product\n\n/-! ### Disjoint sum of multisets -/\n\nsection sigma\nvariables {σ : α → Type*} (a : α) (s : multiset α) (t : Π a, multiset (σ a))\n\n/-- `sigma s t` is the dependent version of `product`. It is the sum of\n  `(a, b)` as `a` ranges over `s` and `b` ranges over `t a`. -/\nprotected def sigma (s : multiset α) (t : Π a, multiset (σ a)) : multiset (Σ a, σ a) :=\ns.bind $ λ a, (t a).map $ sigma.mk a\n\n@[simp] lemma coe_sigma (l₁ : list α) (l₂ : Π a, list (σ a)) :\n  @multiset.sigma α σ l₁ (λ a, l₂ a) = l₁.sigma l₂ :=\nby rw [multiset.sigma, list.sigma, ←coe_bind]; simp\n\n@[simp] lemma zero_sigma : @multiset.sigma α σ 0 t = 0 := rfl\n\n@[simp] lemma cons_sigma : (a ::ₘ s).sigma t = (t a).map (sigma.mk a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_singleton (b : α → β) :\n  ({a} : multiset α).sigma (λ a, ({b a} : multiset β)) = {⟨a, b a⟩} := rfl\n\n@[simp] lemma add_sigma (s t : multiset α) (u : Π a, multiset (σ a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_add : ∀ t u : Π a, multiset (σ a),\n  s.sigma (λ a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (λ t u, rfl) $ λ a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] lemma mem_sigma {s t} : ∀ {p : Σ a, σ a},\n  p ∈ @multiset.sigma α σ s t ↔ p.1 ∈ s ∧ p.2 ∈ t p.1\n| ⟨a, b⟩ := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] lemma card_sigma :\n  card (s.sigma t) = sum (map (λ a, card (t a)) s) :=\nby simp [multiset.sigma, (∘)]\n\nend sigma\nend multiset\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/data/multiset/bind.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529715, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.47556130753811243}}
{"text": "variable g : ℕ → ℕ → ℕ\nvariable hg : g 0 0 = 0\n\ntheorem gex1 : ∃ x, g x x = x := ⟨0, hg⟩\ntheorem gex2 : ∃ x, g x 0 = x := ⟨0, hg⟩\ntheorem gex3 : ∃ x, g 0 0 = x := ⟨0, hg⟩\ntheorem gex4 : ∃ x, g x x = 0 := ⟨0, hg⟩\n\nset_option pp.implicit true\n#print gex1\n#print gex2\n#print gex3\n#print gex4\n\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch4/ex0403.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.47554429058474135}}
{"text": "/-\nCopyright (c) 2022 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module analysis.von_neumann_algebra.basic\n! leanprover-community/mathlib commit 46b633fd842bef9469441c0209906f6dddd2b4f5\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Analysis.NormedSpace.Dual\nimport Mathbin.Analysis.NormedSpace.Star.Basic\nimport Mathbin.Analysis.Complex.Basic\nimport Mathbin.Analysis.InnerProductSpace.Adjoint\nimport Mathbin.Algebra.Star.Subalgebra\n\n/-!\n# Von Neumann algebras\n\nWe give the \"abstract\" and \"concrete\" definitions of a von Neumann algebra.\nWe still have a major project ahead of us to show the equivalence between these definitions!\n\nAn abstract von Neumann algebra `wstar_algebra M` is a C^* algebra with a Banach space predual,\nper Sakai (1971).\n\nA concrete von Neumann algebra `von_neumann_algebra H` (where `H` is a Hilbert space)\nis a *-closed subalgebra of bounded operators on `H` which is equal to its double commutant.\n\nWe'll also need to prove the von Neumann double commutant theorem,\nthat the concrete definition is equivalent to a *-closed subalgebra which is weakly closed.\n-/\n\n\nuniverse u v\n\n/-- Sakai's definition of a von Neumann algebra as a C^* algebra with a Banach space predual.\n\nSo that we can unambiguously talk about these \"abstract\" von Neumann algebras\nin parallel with the \"concrete\" ones (weakly closed *-subalgebras of B(H)),\nwe name this definition `wstar_algebra`.\n\nNote that for now we only assert the mere existence of predual, rather than picking one.\nThis may later prove problematic, and need to be revisited.\nPicking one may cause problems with definitional unification of different instances.\nOne the other hand, not picking one means that the weak-* topology\n(which depends on a choice of predual) must be defined using the choice,\nand we may be unhappy with the resulting opaqueness of the definition.\n-/\nclass WstarAlgebra (M : Type u) [NormedRing M] [StarRing M] [CstarRing M] [Module ℂ M]\n  [NormedAlgebra ℂ M] [StarModule ℂ M] where\n  exists_predual :\n    ∃ (X : Type u)(_ : NormedAddCommGroup X)(_ : NormedSpace ℂ X)(_ : CompleteSpace X),\n      Nonempty (NormedSpace.Dual ℂ X ≃ₗᵢ⋆[ℂ] M)\n#align wstar_algebra WstarAlgebra\n\n-- TODO: Without this, `von_neumann_algebra` times out. Why?\n/-- The double commutant definition of a von Neumann algebra,\nas a *-closed subalgebra of bounded operators on a Hilbert space,\nwhich is equal to its double commutant.\n\nNote that this definition is parameterised by the Hilbert space\non which the algebra faithfully acts, as is standard in the literature.\nSee `wstar_algebra` for the abstract notion (a C^*-algebra with Banach space predual).\n\nNote this is a bundled structure, parameterised by the Hilbert space `H`,\nrather than a typeclass on the type of elements.\nThus we can't say that the bounded operators `H →L[ℂ] H` form a `von_neumann_algebra`\n(although we will later construct the instance `wstar_algebra (H →L[ℂ] H)`),\nand instead will use `⊤ : von_neumann_algebra H`.\n-/\n@[nolint has_nonempty_instance]\nstructure VonNeumannAlgebra (H : Type u) [NormedAddCommGroup H] [InnerProductSpace ℂ H]\n  [CompleteSpace H] extends StarSubalgebra ℂ (H →L[ℂ] H) where\n  centralizer_centralizer' : Set.centralizer (Set.centralizer carrier) = carrier\n#align von_neumann_algebra VonNeumannAlgebra\n\n/-- Consider a von Neumann algebra acting on a Hilbert space `H` as a *-subalgebra of `H →L[ℂ] H`.\n(That is, we forget that it is equal to its double commutant\nor equivalently that it is closed in the weak and strong operator topologies.)\n-/\nadd_decl_doc VonNeumannAlgebra.toStarSubalgebra\n\nnamespace VonNeumannAlgebra\n\nvariable {H : Type u} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H]\n\ninstance : SetLike (VonNeumannAlgebra H) (H →L[ℂ] H) :=\n  ⟨VonNeumannAlgebra.carrier, fun S T h => by cases S <;> cases T <;> congr ⟩\n\ninstance : StarMemClass (VonNeumannAlgebra H) (H →L[ℂ] H) where star_mem s a := s.star_mem'\n\ninstance : SubringClass (VonNeumannAlgebra H) (H →L[ℂ] H)\n    where\n  add_mem := add_mem'\n  mul_mem := mul_mem'\n  one_mem := one_mem'\n  zero_mem := zero_mem'\n  neg_mem s a ha := show -a ∈ s.toStarSubalgebra from neg_mem ha\n\n@[simp]\ntheorem mem_carrier {S : VonNeumannAlgebra H} {x : H →L[ℂ] H} :\n    x ∈ S.carrier ↔ x ∈ (S : Set (H →L[ℂ] H)) :=\n  Iff.rfl\n#align von_neumann_algebra.mem_carrier VonNeumannAlgebra.mem_carrier\n\n@[ext]\ntheorem ext {S T : VonNeumannAlgebra H} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=\n  SetLike.ext h\n#align von_neumann_algebra.ext VonNeumannAlgebra.ext\n\n@[simp]\ntheorem centralizer_centralizer (S : VonNeumannAlgebra H) :\n    Set.centralizer (Set.centralizer (S : Set (H →L[ℂ] H))) = S :=\n  S.centralizer_centralizer'\n#align von_neumann_algebra.centralizer_centralizer VonNeumannAlgebra.centralizer_centralizer\n\n/-- The centralizer of a `von_neumann_algebra`, as a `von_neumann_algebra`.-/\ndef commutant (S : VonNeumannAlgebra H) : VonNeumannAlgebra H :=\n  {\n    StarSubalgebra.centralizer ℂ (S : Set (H →L[ℂ] H)) fun a (ha : a ∈ S) =>\n      (star_mem ha : _) with\n    carrier := Set.centralizer (S : Set (H →L[ℂ] H))\n    centralizer_centralizer' := by rw [S.centralizer_centralizer] }\n#align von_neumann_algebra.commutant VonNeumannAlgebra.commutant\n\n@[simp]\ntheorem coe_commutant (S : VonNeumannAlgebra H) :\n    ↑S.commutant = Set.centralizer (S : Set (H →L[ℂ] H)) :=\n  rfl\n#align von_neumann_algebra.coe_commutant VonNeumannAlgebra.coe_commutant\n\n@[simp]\ntheorem mem_commutant_iff {S : VonNeumannAlgebra H} {z : H →L[ℂ] H} :\n    z ∈ S.commutant ↔ ∀ g ∈ S, g * z = z * g :=\n  Iff.rfl\n#align von_neumann_algebra.mem_commutant_iff VonNeumannAlgebra.mem_commutant_iff\n\n@[simp]\ntheorem commutant_commutant (S : VonNeumannAlgebra H) : S.commutant.commutant = S :=\n  SetLike.coe_injective S.centralizer_centralizer'\n#align von_neumann_algebra.commutant_commutant VonNeumannAlgebra.commutant_commutant\n\nend VonNeumannAlgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Analysis/VonNeumannAlgebra/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.47542629996957303}}
{"text": "lemma p_equiv_np_implies_false : ∀ P, ¬(P ↔ ¬P) :=\nbegin \n  intro P,\n  by_contradiction,\n  have h := classical.em P, cases h,\n  { have np := h.mp h_1,\n    apply (np h_1), },\n  { have p := h.mpr h_1,\n    apply (h_1 p), }\nend", "meta": {"author": "crabbo-rave", "repo": "cantor", "sha": "2e690e45029d2d096ced1253897c200020eb5216", "save_path": "github-repos/lean/crabbo-rave-cantor", "path": "github-repos/lean/crabbo-rave-cantor/cantor-2e690e45029d2d096ced1253897c200020eb5216/src/helper.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4754262894782685}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\n \n\nuniverses u v \n\nnamespace Mathlib\n\nnamespace smt\n\n\ndef array (α : Type u) (β : Type v) :=\n  α → β\n\ndef select {α : Type u} {β : Type v} (a : array α β) (i : α) : β :=\n  a i\n\ntheorem arrayext {α : Type u} {β : Type v} (a₁ : array α β) (a₂ : array α β) : (∀ (i : α), select a₁ i = select a₂ i) → a₁ = a₂ :=\n  funext\n\ndef store {α : Type u} {β : Type v} [DecidableEq α] (a : array α β) (i : α) (v : β) : array α β :=\n  fun (j : α) => ite (j = i) v (select a j)\n\n@[simp] theorem select_store {α : Type u} {β : Type v} [DecidableEq α] (a : array α β) (i : α) (v : β) : select (store a i v) i = v := sorry\n\n@[simp] theorem select_store_ne {α : Type u} {β : Type v} [DecidableEq α] (a : array α β) (i : α) (j : α) (v : β) : j ≠ i → select (store a i v) j = select a j := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/smt/array.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4754262894782685}}
{"text": "import lambda_calculus.utlc.basic\nimport lambda_calculus.utlc.identities\nimport lambda_calculus.utlc.reduction\nimport lambda_calculus.utlc.beta.basic\nimport lambda_calculus.utlc.eta.basic\n\n\nnamespace lambda_calculus\nnamespace utlc\nnamespace βη\n\ndef head_step (f g: utlc) := β.head_step f g ∨ η.head_step f g\n\ninstance : has_βη_reduction utlc := ⟨ reduction_step_of head_step ⟩\n\ntheorem step_iff (f g: utlc): f →βη g ↔ f →β g ∨ f →η g :=\nbegin\n  induction f generalizing g;\n  simp only [lambda_notation, dot_notation, has_βη_reduction.step] at *,\n  { simp [head_step] },\n  { simp [lambda_reduction_step_iff, head_step, η.lambda_step_iff, β.lambda_step_iff, f_ih,\n      and_or_distrib_left, exists_or_distrib,\n      @or.left_comm _ (f_f = g ↑¹ 0 · ↓0)] },\n  { simp [dot_reduction_step_iff, head_step, η.dot_step_iff', β.dot_step_iff, f_ih_f, f_ih_g,\n      and_or_distrib_left, exists_or_distrib, and.assoc, or.assoc],\n    conv {\n      congr,\n      congr,\n      congr,\n      funext,\n      rw [and_comm],\n      skip,\n      skip,\n    }, itauto }\nend\n\ntheorem reduction_of_beta {f g: utlc}: f ↠β g → f ↠βη g :=\nbegin\n  intro p,\n  induction p with x g hfx hxg ih,\n  refl,\n  apply trans ih (relation.refl_trans_gen.single _),\n  rw [step_iff],\n  exact or.inl hxg,\nend\n\ntheorem reduction_of_eta {f g: utlc}: f ↠η g → f ↠βη g :=\nbegin\n  intro p,\n  induction p with x g hfx hxg ih,\n  refl,\n  apply trans ih (relation.refl_trans_gen.single _),\n  rw [step_iff],\n  exact or.inr hxg,\nend\n\ndef head_reduced (f: utlc): bool := β.head_reduced f ∧ η.head_reduced f\n\ndef reduced := reduced_of head_reduced\n\ntheorem reduced_iff_no_reduction {f: utlc}: reduced f ↔ ∀ g, ¬ f →βη g :=\nbegin\n  apply reduced_iff_not_reduction_step,\n  intro f,\n  simp [head_reduced, head_step, β.head_reduced_iff_not_head_step, η.head_reduced_iff_not_head_step,\n    forall_and_distrib, not_or_distrib],\nend \n\nend βη\nend utlc\nend lambda_calculus", "meta": {"author": "calcu16", "repo": "lean_complexity", "sha": "0dcb73bde8d1d4237f782f4790166365ac3209fe", "save_path": "github-repos/lean/calcu16-lean_complexity", "path": "github-repos/lean/calcu16-lean_complexity/lean_complexity-0dcb73bde8d1d4237f782f4790166365ac3209fe/src/lambda_calculus/utlc/beta_eta/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.47531351552317247}}
{"text": "constants p q : Prop\n\nlemma t1 : p → q → p :=\n  assume hp : p,\n  assume hq : q,\n  show p, from hp\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0205.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4753135052399306}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\n\nimport algebra.category.Module.basic\nimport linear_algebra.basic\nimport category_theory.abelian.basic\n--import exact\nimport modules.trivial_equivalence\nimport modules.mono_epi\nimport modules.to_mathlib\n\nopen category_theory\nopen category_theory.limits\nopen category_theory.abelian\nopen category_theory.preadditive\nopen category_theory.limits.walking_parallel_pair\nopen linear_map\n\nnoncomputable theory\n\nuniverse u\n\nvariables {R : Type u} [ring R]\n\nnamespace Module\n\nsection cokernel\nvariables {M N : Module R} (f : M ⟶ N)\n\ndef cokernel_cocone : cofork f 0 :=\ncokernel_cofork.of_π (up f.range.mkq) $ comp_mkq _\n\ndef cokernel_is_colimit : is_colimit (cokernel_cocone f) :=\ncofork.is_colimit.mk _\n  (λ s, f.range.liftq (cofork.π s) $ range_le_ker_iff.2 $ cokernel_cofork.condition s)\n  (λ s, f.range.liftq_mkq (cofork.π s) _)\n  (λ s m h,\n  begin\n    haveI : epi (up f.range.mkq) := epi_of_range_eq_top _ (submodule.range_mkq _),\n    apply (cancel_epi (up f.range.mkq)).1,\n    convert h walking_parallel_pair.one,\n    exact submodule.liftq_mkq _ _ _\n  end)\n\nend cokernel\n\nsection cokernel\n\ninstance module_has_cokernels : has_cokernels.{u} (Module R) :=\n⟨λ _ _ f, ⟨cokernel_cocone f, cokernel_is_colimit f⟩⟩\n\nend cokernel\n\nsection products\n\ndef module_has_limit_pair (M N : Module R) : has_limit (pair M N) :=\n{ cone := @binary_fan.mk _ _ M N (of R $ M × N) (fst R M N) (snd R M N),\n  is_limit :=\n  { lift := λ s, prod (s.π.app walking_pair.left) (s.π.app walking_pair.right),\n    fac' := λ s j, walking_pair.cases_on j (fst_prod _ _) (snd_prod _ _),\n    uniq' := λ s m h,\n    begin\n      ext,\n      rw prod_apply,\n      { rw ←h walking_pair.left, refl },\n      { rw ←h walking_pair.right, refl }\n    end } }\n\nsection\n\nlocal attribute [instance] module_has_limit_pair\n\ninstance module_has_binary_products : has_binary_products.{u} (Module R) :=\nhas_binary_products_of_has_limit_pair (Module R)\n\nend\n\ndef module_has_colimit_pair (M N : Module R) : has_colimit (pair M N) :=\n{ cocone := @binary_cofan.mk _ _ M N (of R $ M × N) (inl R M N) (inr R M N),\n  is_colimit :=\n  { desc := λ s, coprod (s.ι.app walking_pair.left) (s.ι.app walking_pair.right),\n    fac' := λ s j, walking_pair.cases_on j (coprod_inl _ _) (coprod_inr _ _),\n    uniq' := λ s m h,\n    begin\n      ext,\n      erw [coprod_apply, ←h walking_pair.left, ←h walking_pair.right,\n        binary_cofan.mk_ι_app_left, binary_cofan.mk_ι_app_right, comp_apply, comp_apply, ←map_add],\n      apply congr_arg,\n      rw [inl_apply, inr_apply, prod.mk_add_mk, zero_add, add_zero, prod.mk.eta]\n    end } }\n\nsection\n\nlocal attribute [instance] module_has_colimit_pair\n\ninstance module_has_binary_coproducts : has_binary_coproducts.{u} (Module R) :=\nhas_binary_coproducts_of_has_colimit_pair (Module R)\n\nend\n\nend products\n\ninstance : abelian.{u} (Module.{u} R) :=\n{ hom_group := by apply_instance,\n  distrib_left' := λ P Q R f f' g,\n    show (f + f') ≫ g = f ≫ g + f' ≫ g, by ext; simp,\n  distrib_right' := λ P Q R f g g',\n    show f ≫ (g + g') = f ≫ g + f ≫ g', by ext; simp,\n  has_zero_object := by apply_instance,\n  has_binary_products := by apply_instance,\n  has_binary_coproducts := by apply_instance,\n  has_kernels := by apply_instance,\n  has_cokernels := by apply_instance,\n  mono_is_kernel := λ A B f m,\n  { Z := of R f.range.quotient,\n    g := f.range.mkq,\n    w := comp_mkq f,\n    is_limit := begin\n      refine kernel.transport _ _ _ _,\n      { haveI := m,\n        exact up_equiv (equiv_range_of_ker_bot f (ker_eq_bot_of_mono f)), },\n      { ext, refl }\n    end },\n  epi_is_cokernel := λ A B f e,\n  { W := of R f.ker,\n    g := f.ker.subtype,\n    w := ker_comp f,\n    is_colimit := begin\n      refine cokernel.transport _ _ _ _,\n      { haveI := e,\n        exact up_equiv (equiv_range_of_range_top f (range_eq_top_of_epi f)), },\n      { ext, refl }\n    end } }\n\nsection\nvariables {X Y Z : Module R} (f : X ⟶ Y) (g : Y ⟶ Z)\n\nlemma exact_is_exact : exact f g ↔ f.range = g.ker :=\n⟨λ h, le_antisymm (range_le_ker_iff.2 h.1) (ker_le_range_iff.2 h.2),\n λ h, ⟨range_le_ker_iff.1 $ le_of_eq h, ker_le_range_iff.1 $ le_of_eq h.symm⟩⟩\n\n end\n\nend Module\n", "meta": {"author": "TwoFX", "repo": "lean-homological-algebra", "sha": "e3a8e4ecaf49bec6c7b38b34c0b8f9749e941aa8", "save_path": "github-repos/lean/TwoFX-lean-homological-algebra", "path": "github-repos/lean/TwoFX-lean-homological-algebra/lean-homological-algebra-e3a8e4ecaf49bec6c7b38b34c0b8f9749e941aa8/src/modules/modules.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744673038221, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.47525856467558986}}
{"text": "-- Bottcher map for Julia sets\n\nimport logic.basic\nnoncomputable theory\n\n-- Values that make sense only on a set\ndef if_p {A : Type} [has_zero A] (P : Prop) (f : P → A) : A :=\n  @dite _ _ (classical.dec P) (λ p, f p) (λ _, 0)\n\nlemma if_p_true {A : Type} [has_zero A] {P : Prop} {f : P → A} (p : P) : if_p P f = f p := by { rw if_p, simp [p] }\nlemma if_p_false {A : Type} [has_zero A] {P : Prop} {f : P → A} (p : ¬P) : if_p P f = 0 := by { rw if_p, simp [p] }\n\n-- If the body of if_p does not depend on the P, we can drop it on a set where P holds\nlemma if_p_const' {A B : Type} [has_zero B] {f : A → B}\n    (s : set A) (P : A → Prop) (p : ∀ a, a ∈ s → P a)\n    : ∀ a, a ∈ s → if_p (P a) (λ _, f a) = f a := begin\n  intros a m, rw if_p_true (p a m)\nend\n\n-- Special case of if_p_const' where P = a ∈ s\nlemma if_p_const {A B : Type} [has_zero B] {f : A → B} (s : set A)\n    : ∀ a : A, a ∈ s → if_p (a ∈ s) (λ _, f a) = f a := begin\n  intros a m, rw if_p_true m\nend", "meta": {"author": "girving", "repo": "ray", "sha": "e0c501756e067711e2d3667d4b1d18045d83a313", "save_path": "github-repos/lean/girving-ray", "path": "github-repos/lean/girving-ray/ray-e0c501756e067711e2d3667d4b1d18045d83a313/src/if_p.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.47523759954512557}}
{"text": "def f (x y : Nat) : Nat :=\n  match x, y with\n  | 0, 0 => 1\n  | _, _ => 2\n\nexample (h : f x y = 1) : f x y ≠ 2 := by\n  simp [f] at *\n  split\n  next => decide\n  next x' y' hnp => simp [hnp] at h\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/simpMatch.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4752375928454798}}
{"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  --Let A be an open covering of R^n.\n  assume A : set (set (euclidean_space ℝ (fin n))),\n  assume hA : is_open_cover A,\n\n  --We now construct a locally finite open refinement C of A that covers R^n.\n  have h1 : ∃ C : set (set (euclidean_space ℝ (fin n))), is_open_cover C ∧ is_locally_finite_refinement A C,\n  {\n    --First, we define a collection of pen balls.\n    --Let B_0 = phi, and for each n in N, let B_m denote the ball of radius m centered at 0.\n    have h1a : ∀ (m : ℕ), ∃ Bm : set (euclidean_space ℝ (fin n)), is_open Bm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∃ (a : ℝ) (b : fin n), (a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a),\n    {\n      assume m : ℕ,\n      let Bm : set (euclidean_space ℝ (fin n)),\n      let hBm : is_open Bm,\n      let hBm1 : ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∃ (a : ℝ) (b : fin n), (a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a),\n      {\n        assume x : euclidean_space ℝ (fin n),\n        split,\n        {\n          assume h1 : x ∈ Bm,\n          let a : ℝ,\n          let b : fin n,\n          have h2 : ∃ (a : ℝ) (b : fin n), (a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a),\n          {\n            have h2a : ∃ (a : ℝ) (b : fin n), abs (x i - b i) < a, from by auto [h1],\n            have h2b : ∃ (a : ℝ) (b : fin n), ((a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a)), from by auto [h2a],\n            exact h2b,\n          },\n          have h3 : ∃! (a : ℝ) (b : fin n), ((a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a)), from by auto [h2],\n          have h4 : ∃ (a : ℝ) (b : fin n), ((a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a)), from by auto [exists_unique.exists, h3],\n          exact h4,\n        },\n        {\n          assume h1 : ∃ (a : ℝ) (b : fin n), (a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a),\n          let a : ℝ,\n          let b : fin n,\n          have h2 : a > 0 ∧ ∀ (i : fin n), abs (x i - b i) < a, from by auto [h1],\n          have h3 : x ∈ Bm, from by auto [h2],\n          exact h3,\n        },\n      },\n      exact hBm1,\n    },\n    have h1b : ∀ (m : ℕ), ∃ Bm : set (euclidean_space ℝ (fin n)), is_open Bm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Bm ↔ ∃ (a : ℝ) (b : fin n), (a > 0) ∧ (∀ (i : fin n), abs (x i - b i) < a), from by auto [h1a],\n\n    --Given m, set Bar{B_m} is compact in R^n by the Heine-Borel theorem, so choose finitely many elements of A that cover Bar{B_m} and intersect each one with the open set R^n setminus Bar{B_{m - 1}}, and let C_m denote this collection of open sets (each an open subset of an element of A).\n    have h1c : ∀ (m : ℕ), ∃ Cm : set (set (euclidean_space ℝ (fin n))), is_open_cover Cm ∧ (∀ (U : set (euclidean_space ℝ (fin n))), U ∈ Cm ↔ (∃ (V : set (euclidean_space ℝ (fin n))), V ∈ A ∧ U = V ∩ (set.inter_compl (set.compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl (set.inter_compl))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))),\n    {\n      assume m : ℕ,\n      let Cm : set (set (euclidean_space ℝ (fin n))),\n      let hCm : is_open_cover Cm,\n      let hCm1 : ∀ (U : set (euclidean_space\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  intros A HA,\n  have B0 : set (euclidean_space ℝ (fin n)) := ∅,\n  have Bm : ∀ m : ℕ, set (euclidean_space ℝ (fin n)) := λ m, ball (0 : euclidean_space ℝ (fin n)) m,\n  have B : ∀ m : ℕ, set (euclidean_space ℝ (fin n)) := λ m, closure (Bm m),\n  have Cm : ∀ (m : ℕ) (A : set (euclidean_space ℝ (fin n))), \n    ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from\n  begin\n    assume (m : ℕ) (A : set (euclidean_space ℝ (fin n))),\n    have h1 : (Bm m) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) ⊆ A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : ∃ (C : set (euclidean_space ℝ (fin n))), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_inter_of_subset],\n    show ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_of_mem_of_subset, set.exists.elim] using [h5],\n  end,\n  have Cm' : ∀ (m : ℕ) (A : set (euclidean_space ℝ (fin n))), \n    ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from\n  begin\n    assume (m : ℕ) (A : set (euclidean_space ℝ (fin n))),\n    have h1 : (Bm m) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) ⊆ A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : ∃ (C : set (euclidean_space ℝ (fin n))), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_inter_of_subset],\n    show ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_of_mem_of_subset, set.exists.elim] using [h5],\n  end,\n  have Cm'' : ∀ (m : ℕ) (A : set (euclidean_space ℝ (fin n))), \n    ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from\n  begin\n    assume (m : ℕ) (A : set (euclidean_space ℝ (fin n))),\n    have h1 : (Bm m) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) ⊆ A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : ∃ (C : set (euclidean_space ℝ (fin n))), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_inter_of_subset],\n    show ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_of_mem_of_subset, set.exists.elim] using [h5],\n  end,\n  have Cm''' : ∀ (m : ℕ) (A : set (euclidean_space ℝ (fin n))), \n    ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from\n  begin\n    assume (m : ℕ) (A : set (euclidean_space ℝ (fin n))),\n    have h1 : (Bm m) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) ⊆ A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) ∩ A ≠ ∅, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : ∃ (C : set (euclidean_space ℝ (fin n))), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_inter_of_subset],\n    show ∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ HA), (Bm m) ⊆ C ∧ (Bm (m-1)) ∩ C = ∅, from by auto [set.exists_of_mem_of_subset, set.ex\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open_cover A),\n  have h1 : ∀ (x : ℝ) (n : ℕ), ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1), from \n  begin\n    assume (x : ℝ) (n : ℕ),\n    have h1 : ∃ m : ℕ, (x ≤ m), from exists_nat.of_le (le_of_lt ((x : ℝ) + 1)),\n    have h2 : ∃ m : ℕ, (m ≤ x + 1), from exists_nat.of_le (le_add_right x 1),\n    have h3 : ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1), from \n    begin\n      cases h1 with m hm,\n      cases h2 with n hn,\n      existsi max m n,\n      apply and.intro,\n      apply le_max_left,\n      apply le_max_right,\n    end,\n    exact h3,\n  end,\n  have h2 : ∀ (x : ℝ) (n : ℕ), ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n), from \n  begin\n    assume (x : ℝ) (n : ℕ),\n    have h1 : ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1), from h1 x n,\n    cases h1 with m hm,\n    have h2 : ∀ (n : ℕ), m ≤ n → x ≤ n, from le_trans (and.elim_right hm) (le_add_left x 1),\n    existsi m,\n    apply and.intro,\n    apply and.elim_left hm,\n    apply and.intro,\n    apply and.elim_right hm,\n    exact h2,\n  end,\n  have h3 : ∀ (x : ℝ) (n : ℕ), ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n ∧ ∀ (n : ℕ), x ≤ n → m ≤ n), from \n  begin\n    assume (x : ℝ) (n : ℕ),\n    have h1 : ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n), from h2 x n,\n    cases h1 with m hm,\n    have h2 : ∀ (n : ℕ), x ≤ n → m ≤ n, from le_trans (and.elim_right (and.elim_right hm)) (le_add_left x 1),\n    existsi m,\n    apply and.intro,\n    apply and.elim_left hm,\n    apply and.intro,\n    apply and.elim_right (and.elim_left hm),\n    apply and.intro,\n    apply and.elim_right (and.elim_left hm),\n    exact h2,\n  end,\n  have h4 : ∀ (x : ℝ) (n : ℕ), ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n ∧ ∀ (n : ℕ), x ≤ n → m ≤ n ∧ ∀ (n : ℕ), m ≤ n → x + 1 ≤ n), from\n  begin\n    assume (x : ℝ) (n : ℕ),\n    have h1 : ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n ∧ ∀ (n : ℕ), x ≤ n → m ≤ n), from h3 x n,\n    cases h1 with m hm,\n    have h2 : ∀ (n : ℕ), m ≤ n → x + 1 ≤ n, from le_trans (and.elim_right (and.elim_right (and.elim_right (and.elim_left hm)))) (le_add_right x 1),\n    existsi m,\n    apply and.intro,\n    apply and.elim_left hm,\n    apply and.intro,\n    apply and.elim_right (and.elim_left hm),\n    apply and.intro,\n    apply and.elim_right (and.elim_left (and.elim_left hm)),\n    apply and.intro,\n    apply and.elim_right (and.elim_left (and.elim_left hm)),\n    exact h2,\n  end,\n  have h5 : ∀ (x : ℝ) (n : ℕ), ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n ∧ ∀ (n : ℕ), x ≤ n → m ≤ n ∧ ∀ (n : ℕ), m ≤ n → x + 1 ≤ n ∧ ∀ (n : ℕ), x ≤ n → x + 1 ≤ n), from\n  begin\n    assume (x : ℝ) (n : ℕ),\n    have h1 : ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n ∧ ∀ (n : ℕ), x ≤ n → m ≤ n ∧ ∀ (n : ℕ), m ≤ n → x + 1 ≤ n), from h4 x n,\n    cases h1 with m hm,\n    have h2 : ∀ (n : ℕ), x ≤ n → x + 1 ≤ n, from le_trans (and.elim_right (and.elim_right (and.elim_right (and.elim_left (and.elim_left hm))))) (le_add_right x 1),\n    existsi m,\n    apply and.intro,\n    apply and.elim_left hm,\n    apply and.intro,\n    apply and.elim_right (and.elim_left hm),\n    apply and.intro,\n    apply and.elim_right (and.elim_left (and.elim_left hm)),\n    apply and.intro,\n    apply and.elim_right (and.elim_left (and.elim_left (and.elim_left hm))),\n    apply and.intro,\n    apply and.elim_right (and.elim_left (and.elim_left (and.elim_left hm))),\n    exact h2,\n  end,\n  have h6 : ∀ (x : ℝ) (n : ℕ), ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n ∧ ∀ (n : ℕ), x ≤ n → m ≤ n ∧ ∀ (n : ℕ), m ≤ n → x + 1 ≤ n ∧ ∀ (n : ℕ), x ≤ n → x + 1 ≤ n ∧ ∀ (n : ℕ), x + 1 ≤ n → m ≤ n), from\n  begin\n    assume (x : ℝ) (n : ℕ),\n    have h1 : ∃ m : ℕ, (x ≤ m ∧ m ≤ x + 1 ∧ ∀ (n : ℕ), m ≤ n → x ≤ n ∧ ∀ (n : ℕ), x ≤ n → m ≤ n ∧ ∀ (n : ℕ), m ≤ n → x + 1 ≤ n ∧ ∀ (n : ℕ), x ≤ n → x + 1 ≤ n), from h5 x n,\n    cases h1 with m hm,\n    have h2 : ∀ (n : ℕ), x + 1 ≤ n → m ≤ n\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  have h1 : ∀ A : set (euclidean_space ℝ (fin n)), is_open A → is_open (A ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.inter_univ],\n  have h2 : ∀ m : ℕ, is_open (set.Iio (m : ℝ) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h3 : ∀ m : ℕ, is_open (set.Icc (m : ℝ) (m + 1) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h4 : (set.Iio (0 : ℝ) ∩ (univ : set (euclidean_space ℝ (fin n)))) ⊆ (set.Icc (0 : ℝ) 1 ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h5 : (set.Icc (0 : ℝ) 1 ∩ (univ : set (euclidean_space ℝ (fin n)))) ⊆ (set.Iio (0 : ℝ) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h6 : is_open (set.Iio (0 : ℝ) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [h2, h3, h4, h5],\n  have h7 : ∀ m : ℕ, is_open (set.Ico (m : ℝ) (m + 1) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h8 : is_open (set.Ico (0 : ℝ) 1 ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [h7],\n  have h9 : ∀ m : ℕ, is_open (set.Icc (m : ℝ) (m + 1) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h10 : ∀ m : ℕ, is_open (set.Icc (m : ℝ) (m + 1)), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h11 : ∀ m : ℕ, is_open (set.Iio (m : ℝ)), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h12 : ∀ m : ℕ, is_open (set.Ico (m : ℝ)), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h13 : ∀ m : ℕ, is_open (set.Icc (m : ℝ) (m + 1) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h14 : ∀ m : ℕ, is_open (set.Icc (m : ℝ) (m + 1)), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h15 : ∀ m : ℕ, is_open (set.Ico (m : ℝ) (m + 1) ∩ (univ : set (euclidean_space ℝ (fin n)))), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_univ],\n  have h16 : ∀ m : ℕ, is_open (set.Ico (m : ℝ) (m + 1)), from by auto [set.Iio_subset_Ioi, set.Ioi_subset_Icc, set.Icc_subset_Ioc, set.Ioc_subset_Ico, set.Ico_subset_Ioo, set.Ioo_subset_Icc, set.Icc_subset_Icc, set.Icc_subset_univ, set.inter_un\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  let A := λ (a : ℝ), {b : ℝ | a < b},\n  have h1 : ∀ (a : ℝ), is_open (A a), from by auto [is_open_lt],\n  let B := λ (a : ℝ), {b : ℝ | b < a},\n  have h2 : ∀ (a : ℝ), is_open (B a), from by auto [is_open_gt],\n  have h3 : ∀ (a : ℝ), is_open (A a) ∧ is_open (B a), from by auto [h1, h2],\n  have h4 : ∀ (a : ℝ) (h : a > 0), ∃ b : ℝ, b > a, from by auto [h1],\n  have h5 : ∀ (a : ℝ) (h : a < 0), ∃ b : ℝ, b < a, from by auto [h2],\n  have h6 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b ≠ a, from by auto [h4, h5],\n  have h7 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h8 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h9 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h10 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h11 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h12 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h13 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h14 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h15 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h16 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h17 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h18 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h19 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h20 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h21 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h22 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h23 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h24 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h25 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h26 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h27 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h28 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h29 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h30 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h31 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h32 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h33 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h34 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h35 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h36 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h37 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h38 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h39 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h40 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h41 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h42 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h43 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h44 : ∀ (a : ℝ) (h : a ≠ 0), ∃ b : ℝ, b = a, from by auto [h4, h5],\n  have h45\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  have h1 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m} ∈ (𝓝 (0 : ℝ ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h2 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥} ∈ (𝓝 (0 : ℝ ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h3 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ < m} ∈ (𝓝 (0 : ℝ ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h4 : ∀ m : ℕ, {x : ℝ ^ n // m < ∥x∥} ∈ (𝓝 (0 : ℝ ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h5 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h6 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h7 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h8 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h9 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h10 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h11 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h12 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h13 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h14 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h15 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h16 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h17 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h18 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h19 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h20 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h21 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h22 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n  have h23 : ∀ m : ℕ, {x : ℝ ^ n // ∥x∥ ≤ m ∧ ∥x∥ < m + 1} = {x : ℝ ^ n // ∥x∥ ≤ m} ∩ {x : ℝ ^ n // ∥x∥ < m + 1}, from by auto,\n  have h24 : ∀ m : ℕ, {x : ℝ ^ n // m ≤ ∥x∥ ∧ m + 1 < ∥x∥} = {x : ℝ ^ n // m ≤ ∥x∥} ∩ {x : ℝ ^ n // m + 1 < ∥x∥}, from by auto,\n \nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  let A : set (euclidean_space ℝ (fin n)) → Prop := λ x, (is_open x),\n  let S : set (euclidean_space ℝ (fin n)) := univ,\n  let T : set (euclidean_space ℝ (fin n)) → Prop := λ x, (is_open x) ∧ cover S x ∧ locally_finite x,\n  let U : set (euclidean_space ℝ (fin n)) → Prop := λ x, (is_open x) ∧ cover S x,\n  let C : set (euclidean_space ℝ (fin n)) → Prop := λ x, (is_open x) ∧ locally_finite x,\n  have h1 : S ∈ 𝒫 (euclidean_space ℝ (fin n)), from by auto [set.univ_mem_powerset],\n  have h2 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C), from by auto [set.is_open_of_mem_powerset],\n  have h3 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C, from by auto [set.is_open_of_mem_powerset, set.cover_univ, set.univ_mem_powerset],\n  have h4 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∧ locally_finite C, from by auto [set.is_open_of_mem_powerset, set.cover_univ, set.univ_mem_powerset, set.locally_finite_of_mem_powerset],\n  have h5 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ locally_finite C, from by auto [set.is_open_of_mem_powerset, set.locally_finite_of_mem_powerset],\n  have h6 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∧ locally_finite C ↔ (is_open C) ∧ cover S C, from by auto [iff_iff_iff_iff],\n  have h7 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∧ locally_finite C ↔ (is_open C) ∧ locally_finite C, from by auto [iff_iff_iff_iff],\n  have h8 : T = U ∨ T = C, from by auto [set.ext],\n  have h9 : (∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∧ locally_finite C) ↔ (∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C), from by auto [h6],\n  have h10 : (∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∧ locally_finite C) ↔ (∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ locally_finite C), from by auto [h7],\n  have h11 : (∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∧ locally_finite C) ↔ (∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C) ∨ (∃ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ locally_finite C), from by auto [h8, h9, h10, exists_or_distrib],\n  have h12 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C, from by auto [set.is_open_of_mem_powerset, set.cover_univ, set.univ_mem_powerset],\n  have h13 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ locally_finite C, from by auto [set.is_open_of_mem_powerset, set.locally_finite_of_mem_powerset],\n  have h14 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∨ (is_open C) ∧ locally_finite C, from by auto [h11],\n  have h15 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∨ (is_open C) ∧ locally_finite C, from by auto [h14, h12, h13, classical.or_iff_not_imp_left, set.ext, classical.not_not_iff_iff],\n  have h16 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∨ (is_open C) ∧ locally_finite C, from by auto [h15, set.ext],\n  have h17 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∨ (is_open C) ∧ locally_finite C, from by auto [h16, set.ext],\n  have h18 : ∀ (C : set (euclidean_space ℝ (fin n))) (hC : C ∈ 𝒫 (euclidean_space ℝ (fin n))), (is_open C) ∧ cover S C ∨ (is_open C) ∧ locally_finite C, from by auto [h17, set.\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n  assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open A),\n  have h1 : is_open (⋃ (m : ℕ), (λ (x : euclidean_space ℝ (fin n)), (∃ (m : ℕ), ∀ (i : fin n), abs (x $ i) ≤ m)) ⁻¹' {m} ∩ A) := by auto [is_open_Inter, is_open_Ball, is_open_Union, is_open_Inter, is_open_Ball, is_open_Union],\n  have h2 :  (⋃ (m : ℕ), (λ (x : euclidean_space ℝ (fin n)), (∃ (m : ℕ), ∀ (i : fin n), abs (x $ i) ≤ m)) ⁻¹' {m} ∩ A) = A, from by auto [ext_iff],\n\n  show ∃ (B : set (euclidean_space ℝ (fin n))), is_open B ∧ is_locally_finite B ∧ ⋃ B = A, from by auto [exists_prop, h1, h2],\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n  have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n  show (A ∩ B) ∈  𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n  ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n  ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n  ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\n\\mathbb{R}^n is paracompact\n$\\mathbb{R}^n$ is paracompact for all $n$.\n`proof`\nLet $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$. We now construct a locally finite open refinement $\\mathcal{C}$ of $\\mathcal{A}$ that covers $\\mathbb{R}^n$. First, we define a collection of pen balls. Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$\ncentered at 0. Given $m$, set $\\Bar{B_m}$ is compact in $\\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\\mathcal{A}$ that cover $\\Bar{B_m}$ and intersect each one with the open set $\\mathbb{R}^n \\setminus \\Bar{B_{m - 1}}$, and let $\\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\\mathcal{A}$). So $\\mathcal{C} = \\bigcup_{m = 0}^{\\infty} \\mathcal{C}_m$ is an open refinement of $\\mathcal{A}$. Note that $\\mathcal{C}$ covers $\\mathbb{R}^n$ since for any $x \\in \\mathbb{R}^n$, there is a smallest $m \\in \\mathbb{N}$ such that $x \\in \\Bar{B_{m}}$ (namely, some $m$ where $\\rVert x \\lVert \\leq m \\leq \\rVert x \\lVert + 1$), and so $x$ is an element of $\\mathcal{C}_m$. Now collection $\\mathcal{C}$ is locally finite since for given $x \\in \\mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\\mathcal{C}$, namely those elements in collection $\\mathcal{C}_1 \\cup \\mathcal{C}_2 \\cup \\cdots \\mathcal{C}_m$. So $\\mathcal{C}$ is a locally finite open refinement of $\\mathcal{A}$ that covers $\\mathbb{R}^n$, hence $\\mathbb{R}^n$ is paracompact.\n\nQED\n-/\ntheorem  ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto-3_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.47522712927439936}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Johan Commelin, Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.equivalence\nimport Mathlib.data.equiv.basic\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l u₃ v₃ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\n\n/--\n`F ⊣ G` represents the data of an adjunction between two functors\n`F : C ⥤ D` and `G : D ⥤ C`. `F` is the left adjoint and `G` is the right adjoint.\n\nTo construct an `adjunction` between two functors, it's often easier to instead use the\nconstructors `mk_of_hom_equiv` or `mk_of_unit_counit`. To construct a left adjoint,\nthere are also constructors `left_adjoint_of_equiv` and `adjunction_of_equiv_left` (as\nwell as their duals) which can be simpler in practice.\n\nUniqueness of adjoints is shown in `category_theory.adjunction.opposites`.\n\nSee https://stacks.math.columbia.edu/tag/0037.\n-/\nstructure adjunction {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) (G : D ⥤ C) \nwhere\n  hom_equiv : (X : C) → (Y : D) → (functor.obj F X ⟶ Y) ≃ (X ⟶ functor.obj G Y)\n  unit : 𝟭 ⟶ F ⋙ G\n  counit : G ⋙ F ⟶ 𝟭\n  hom_equiv_unit' : autoParam\n  (∀ {X : C} {Y : D} {f : functor.obj F X ⟶ Y}, coe_fn (hom_equiv X Y) f = nat_trans.app unit X ≫ functor.map G f)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  hom_equiv_counit' : autoParam\n  (∀ {X : C} {Y : D} {g : X ⟶ functor.obj G Y},\n    coe_fn (equiv.symm (hom_equiv X Y)) g = functor.map F g ≫ nat_trans.app counit Y)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\ninfixl:15 \" ⊣ \" => Mathlib.category_theory.adjunction\n\n/-- A class giving a chosen right adjoint to the functor `left`. -/\nclass is_left_adjoint {C : Type u₁} [category C] {D : Type u₂} [category D] (left : C ⥤ D) \nwhere\n  right : D ⥤ C\n  adj : left ⊣ right\n\n/-- A class giving a chosen left adjoint to the functor `right`. -/\nclass is_right_adjoint {C : Type u₁} [category C] {D : Type u₂} [category D] (right : D ⥤ C) \nwhere\n  left : C ⥤ D\n  adj : left ⊣ right\n\n/-- Extract the left adjoint from the instance giving the chosen adjoint. -/\ndef left_adjoint {C : Type u₁} [category C] {D : Type u₂} [category D] (R : D ⥤ C) [is_right_adjoint R] : C ⥤ D :=\n  is_right_adjoint.left R\n\n/-- Extract the right adjoint from the instance giving the chosen adjoint. -/\ndef right_adjoint {C : Type u₁} [category C] {D : Type u₂} [category D] (L : C ⥤ D) [is_left_adjoint L] : D ⥤ C :=\n  is_left_adjoint.right L\n\n/-- The adjunction associated to a functor known to be a left adjoint. -/\ndef adjunction.of_left_adjoint {C : Type u₁} [category C] {D : Type u₂} [category D] (left : C ⥤ D) [is_left_adjoint left] : left ⊣ right_adjoint left :=\n  is_left_adjoint.adj\n\n/-- The adjunction associated to a functor known to be a right adjoint. -/\ndef adjunction.of_right_adjoint {C : Type u₁} [category C] {D : Type u₂} [category D] (right : C ⥤ D) [is_right_adjoint right] : left_adjoint right ⊣ right :=\n  is_right_adjoint.adj\n\nnamespace adjunction\n\n\n@[simp] theorem hom_equiv_unit {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (c : F ⊣ G) {X : C} {Y : D} {f : functor.obj F X ⟶ Y} : coe_fn (hom_equiv c X Y) f = nat_trans.app (unit c) X ≫ functor.map G f := sorry\n\n@[simp] theorem hom_equiv_counit {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (c : F ⊣ G) {X : C} {Y : D} {g : X ⟶ functor.obj G Y} : coe_fn (equiv.symm (hom_equiv c X Y)) g = functor.map F g ≫ nat_trans.app (counit c) Y := sorry\n\n@[simp] theorem hom_equiv_naturality_left_symm {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X' : C} {X : C} {Y : D} (f : X' ⟶ X) (g : X ⟶ functor.obj G Y) : coe_fn (equiv.symm (hom_equiv adj X' Y)) (f ≫ g) = functor.map F f ≫ coe_fn (equiv.symm (hom_equiv adj X Y)) g := sorry\n\n@[simp] theorem hom_equiv_naturality_left {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X' : C} {X : C} {Y : D} (f : X' ⟶ X) (g : functor.obj F X ⟶ Y) : coe_fn (hom_equiv adj X' Y) (functor.map F f ≫ g) = f ≫ coe_fn (hom_equiv adj X Y) g := sorry\n\n@[simp] theorem hom_equiv_naturality_right {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X : C} {Y : D} {Y' : D} (f : functor.obj F X ⟶ Y) (g : Y ⟶ Y') : coe_fn (hom_equiv adj X Y') (f ≫ g) = coe_fn (hom_equiv adj X Y) f ≫ functor.map G g := sorry\n\n@[simp] theorem hom_equiv_naturality_right_symm {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X : C} {Y : D} {Y' : D} (f : X ⟶ functor.obj G Y) (g : Y ⟶ Y') : coe_fn (equiv.symm (hom_equiv adj X Y')) (f ≫ functor.map G g) = coe_fn (equiv.symm (hom_equiv adj X Y)) f ≫ g := sorry\n\n@[simp] theorem left_triangle {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : whisker_right (unit adj) F ≫ whisker_left F (counit adj) = nat_trans.id (𝟭 ⋙ F) := sorry\n\n@[simp] theorem right_triangle {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) : whisker_left G (unit adj) ≫ whisker_right (counit adj) G = nat_trans.id (G ⋙ 𝟭) := sorry\n\n@[simp] theorem left_triangle_components_assoc {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X : C} {X' : D} (f' : functor.obj 𝟭 (functor.obj F X) ⟶ X') : functor.map F (nat_trans.app (unit adj) X) ≫ nat_trans.app (counit adj) (functor.obj F X) ≫ f' = f' := sorry\n\n@[simp] theorem right_triangle_components {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {Y : D} : nat_trans.app (unit adj) (functor.obj G Y) ≫ functor.map G (nat_trans.app (counit adj) Y) = 𝟙 :=\n  congr_arg (fun (t : nat_trans (G ⋙ 𝟭) (G ⋙ 𝟭)) => nat_trans.app t Y) (right_triangle adj)\n\n@[simp] theorem counit_naturality {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X : D} {Y : D} (f : X ⟶ Y) : functor.map F (functor.map G f) ≫ nat_trans.app (counit adj) Y = nat_trans.app (counit adj) X ≫ f :=\n  nat_trans.naturality (counit adj) f\n\n@[simp] theorem unit_naturality {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X : C} {Y : C} (f : X ⟶ Y) : nat_trans.app (unit adj) X ≫ functor.map G (functor.map F f) = f ≫ nat_trans.app (unit adj) Y :=\n  Eq.symm (nat_trans.naturality (unit adj) f)\n\ntheorem hom_equiv_apply_eq {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {A : C} {B : D} (f : functor.obj F A ⟶ B) (g : A ⟶ functor.obj G B) : coe_fn (hom_equiv adj A B) f = g ↔ f = coe_fn (equiv.symm (hom_equiv adj A B)) g := sorry\n\ntheorem eq_hom_equiv_apply {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {A : C} {B : D} (f : functor.obj F A ⟶ B) (g : A ⟶ functor.obj G B) : g = coe_fn (hom_equiv adj A B) f ↔ coe_fn (equiv.symm (hom_equiv adj A B)) g = f := sorry\n\nend adjunction\n\n\nnamespace adjunction\n\n\n/--\nThis is an auxiliary data structure useful for constructing adjunctions.\nSee `adjunction.mk_of_hom_equiv`.\nThis structure won't typically be used anywhere else.\n-/\nstructure core_hom_equiv {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) (G : D ⥤ C) \nwhere\n  hom_equiv : (X : C) → (Y : D) → (functor.obj F X ⟶ Y) ≃ (X ⟶ functor.obj G Y)\n  hom_equiv_naturality_left_symm' : autoParam\n  (∀ {X' X : C} {Y : D} (f : X' ⟶ X) (g : X ⟶ functor.obj G Y),\n    coe_fn (equiv.symm (hom_equiv X' Y)) (f ≫ g) = functor.map F f ≫ coe_fn (equiv.symm (hom_equiv X Y)) g)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  hom_equiv_naturality_right' : autoParam\n  (∀ {X : C} {Y Y' : D} (f : functor.obj F X ⟶ Y) (g : Y ⟶ Y'),\n    coe_fn (hom_equiv X Y') (f ≫ g) = coe_fn (hom_equiv X Y) f ≫ functor.map G g)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\nnamespace core_hom_equiv\n\n\n@[simp] theorem hom_equiv_naturality_left_symm {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (c : core_hom_equiv F G) {X' : C} {X : C} {Y : D} (f : X' ⟶ X) (g : X ⟶ functor.obj G Y) : coe_fn (equiv.symm (hom_equiv c X' Y)) (f ≫ g) = functor.map F f ≫ coe_fn (equiv.symm (hom_equiv c X Y)) g := sorry\n\n@[simp] theorem hom_equiv_naturality_right {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (c : core_hom_equiv F G) {X : C} {Y : D} {Y' : D} (f : functor.obj F X ⟶ Y) (g : Y ⟶ Y') : coe_fn (hom_equiv c X Y') (f ≫ g) = coe_fn (hom_equiv c X Y) f ≫ functor.map G g := sorry\n\n@[simp] theorem hom_equiv_naturality_left {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : core_hom_equiv F G) {X' : C} {X : C} {Y : D} (f : X' ⟶ X) (g : functor.obj F X ⟶ Y) : coe_fn (hom_equiv adj X' Y) (functor.map F f ≫ g) = f ≫ coe_fn (hom_equiv adj X Y) g := sorry\n\n@[simp] theorem hom_equiv_naturality_right_symm {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : core_hom_equiv F G) {X : C} {Y : D} {Y' : D} (f : X ⟶ functor.obj G Y) (g : Y ⟶ Y') : coe_fn (equiv.symm (hom_equiv adj X Y')) (f ≫ functor.map G g) = coe_fn (equiv.symm (hom_equiv adj X Y)) f ≫ g := sorry\n\nend core_hom_equiv\n\n\n/--\nThis is an auxiliary data structure useful for constructing adjunctions.\nSee `adjunction.mk_of_hom_equiv`.\nThis structure won't typically be used anywhere else.\n-/\nstructure core_unit_counit {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) (G : D ⥤ C) \nwhere\n  unit : 𝟭 ⟶ F ⋙ G\n  counit : G ⋙ F ⟶ 𝟭\n  left_triangle' : autoParam (whisker_right unit F ≫ iso.hom (functor.associator F G F) ≫ whisker_left F counit = nat_trans.id (𝟭 ⋙ F))\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  right_triangle' : autoParam (whisker_left G unit ≫ iso.inv (functor.associator G F G) ≫ whisker_right counit G = nat_trans.id (G ⋙ 𝟭))\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\nnamespace core_unit_counit\n\n\n@[simp] theorem left_triangle {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (c : core_unit_counit F G) : whisker_right (unit c) F ≫ iso.hom (functor.associator F G F) ≫ whisker_left F (counit c) = nat_trans.id (𝟭 ⋙ F) := sorry\n\n@[simp] theorem right_triangle {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (c : core_unit_counit F G) : whisker_left G (unit c) ≫ iso.inv (functor.associator G F G) ≫ whisker_right (counit c) G = nat_trans.id (G ⋙ 𝟭) := sorry\n\nend core_unit_counit\n\n\n/-- Construct an adjunction between `F` and `G` out of a natural bijection between each\n`F.obj X ⟶ Y` and `X ⟶ G.obj Y`. -/\n@[simp] theorem mk_of_hom_equiv_counit_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : core_hom_equiv F G) (Y : D) : nat_trans.app (counit (mk_of_hom_equiv adj)) Y =\n  equiv.inv_fun (core_hom_equiv.hom_equiv adj (functor.obj G Y) (functor.obj 𝟭 Y)) 𝟙 :=\n  Eq.refl (nat_trans.app (counit (mk_of_hom_equiv adj)) Y)\n\n/-- Construct an adjunction between functors `F` and `G` given a unit and counit for the adjunction\nsatisfying the triangle identities. -/\n@[simp] theorem mk_of_unit_counit_counit {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : core_unit_counit F G) : counit (mk_of_unit_counit adj) = core_unit_counit.counit adj :=\n  Eq.refl (counit (mk_of_unit_counit adj))\n\n/-- The adjunction between the identity functor on a category and itself. -/\ndef id {C : Type u₁} [category C] : 𝟭 ⊣ 𝟭 :=\n  mk (fun (X Y : C) => equiv.refl (functor.obj 𝟭 X ⟶ Y)) 𝟙 𝟙\n\n-- Satisfy the inhabited linter.\n\nprotected instance inhabited {C : Type u₁} [category C] : Inhabited (𝟭 ⊣ 𝟭) :=\n  { default := id }\n\n/-- If F and G are naturally isomorphic functors, establish an equivalence of hom-sets. -/\n@[simp] theorem equiv_homset_left_of_nat_iso_symm_apply {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {F' : C ⥤ D} (iso : F ≅ F') {X : C} {Y : D} (g : functor.obj F' X ⟶ Y) : coe_fn (equiv.symm (equiv_homset_left_of_nat_iso iso)) g = nat_trans.app (iso.hom iso) X ≫ g :=\n  Eq.refl (coe_fn (equiv.symm (equiv_homset_left_of_nat_iso iso)) g)\n\n/-- If G and H are naturally isomorphic functors, establish an equivalence of hom-sets. -/\n@[simp] theorem equiv_homset_right_of_nat_iso_apply {C : Type u₁} [category C] {D : Type u₂} [category D] {G : D ⥤ C} {G' : D ⥤ C} (iso : G ≅ G') {X : C} {Y : D} (f : X ⟶ functor.obj G Y) : coe_fn (equiv_homset_right_of_nat_iso iso) f = f ≫ nat_trans.app (iso.hom iso) Y :=\n  Eq.refl (coe_fn (equiv_homset_right_of_nat_iso iso) f)\n\n/-- Transport an adjunction along an natural isomorphism on the left. -/\ndef of_nat_iso_left {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} {H : D ⥤ C} (adj : F ⊣ H) (iso : F ≅ G) : G ⊣ H :=\n  mk_of_hom_equiv\n    (core_hom_equiv.mk\n      fun (X : C) (Y : D) => equiv.trans (equiv_homset_left_of_nat_iso (iso.symm iso)) (hom_equiv adj X Y))\n\n/-- Transport an adjunction along an natural isomorphism on the right. -/\ndef of_nat_iso_right {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} {H : D ⥤ C} (adj : F ⊣ G) (iso : G ≅ H) : F ⊣ H :=\n  mk_of_hom_equiv\n    (core_hom_equiv.mk fun (X : C) (Y : D) => equiv.trans (hom_equiv adj X Y) (equiv_homset_right_of_nat_iso iso))\n\n/-- Transport being a right adjoint along a natural isomorphism. -/\ndef right_adjoint_of_nat_iso {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (h : F ≅ G) [r : is_right_adjoint F] : is_right_adjoint G :=\n  is_right_adjoint.mk (is_right_adjoint.left F) (of_nat_iso_right is_right_adjoint.adj h)\n\n/-- Transport being a left adjoint along a natural isomorphism. -/\ndef left_adjoint_of_nat_iso {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (h : F ≅ G) [r : is_left_adjoint F] : is_left_adjoint G :=\n  is_left_adjoint.mk (is_left_adjoint.right F) (of_nat_iso_left is_left_adjoint.adj h)\n\n/--\nComposition of adjunctions.\n\nSee https://stacks.math.columbia.edu/tag/0DV0.\n-/\ndef comp {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} {E : Type u₃} [ℰ : category E] (H : D ⥤ E) (I : E ⥤ D) (adj₁ : F ⊣ G) (adj₂ : H ⊣ I) : F ⋙ H ⊣ I ⋙ G :=\n  mk (fun (X : C) (Z : E) => equiv.trans (hom_equiv adj₂ (functor.obj F X) Z) (hom_equiv adj₁ X (functor.obj I Z)))\n    (unit adj₁ ≫ whisker_left F (whisker_right (unit adj₂) G) ≫ iso.inv (functor.associator F (H ⋙ I) G))\n    (iso.hom (functor.associator I G (F ⋙ H)) ≫ whisker_left I (whisker_right (counit adj₁) H) ≫ counit adj₂)\n\n/-- If `F` and `G` are left adjoints then `F ⋙ G` is a left adjoint too. -/\nprotected instance left_adjoint_of_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [ℰ : category E] (F : C ⥤ D) (G : D ⥤ E) [Fl : is_left_adjoint F] [Gl : is_left_adjoint G] : is_left_adjoint (F ⋙ G) :=\n  is_left_adjoint.mk (is_left_adjoint.right G ⋙ is_left_adjoint.right F)\n    (comp G (is_left_adjoint.right G) is_left_adjoint.adj is_left_adjoint.adj)\n\n/-- If `F` and `G` are right adjoints then `F ⋙ G` is a right adjoint too. -/\nprotected instance right_adjoint_of_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [ℰ : category E] {F : C ⥤ D} {G : D ⥤ E} [Fr : is_right_adjoint F] [Gr : is_right_adjoint G] : is_right_adjoint (F ⋙ G) :=\n  is_right_adjoint.mk (is_right_adjoint.left G ⋙ is_right_adjoint.left F)\n    (comp (is_right_adjoint.left F) F is_right_adjoint.adj is_right_adjoint.adj)\n\n-- Construction of a left adjoint. In order to construct a left\n\n-- adjoint to a functor G : D → C, it suffices to give the object part\n\n-- of a functor F : C → D together with isomorphisms Hom(FX, Y) ≃\n\n-- Hom(X, GY) natural in Y. The action of F on morphisms can be\n\n-- constructed from this data.\n\n/-- Construct a left adjoint functor to `G`, given the functor's value on objects `F_obj` and\na bijection `e` between `F_obj X ⟶ Y` and `X ⟶ G.obj Y` satisfying a naturality law\n`he : ∀ X Y Y' g h, e X Y' (h ≫ g) = e X Y h ≫ G.map g`.\nDual to `right_adjoint_of_equiv`. -/\n@[simp] theorem left_adjoint_of_equiv_obj {C : Type u₁} [category C] {D : Type u₂} [category D] {G : D ⥤ C} {F_obj : C → D} (e : (X : C) → (Y : D) → (F_obj X ⟶ Y) ≃ (X ⟶ functor.obj G Y)) (he : ∀ (X : C) (Y Y' : D) (g : Y ⟶ Y') (h : F_obj X ⟶ Y), coe_fn (e X Y') (h ≫ g) = coe_fn (e X Y) h ≫ functor.map G g) : ∀ (ᾰ : C), functor.obj (left_adjoint_of_equiv e he) ᾰ = F_obj ᾰ :=\n  fun (ᾰ : C) => Eq.refl (functor.obj (left_adjoint_of_equiv e he) ᾰ)\n\n/-- Show that the functor given by `left_adjoint_of_equiv` is indeed left adjoint to `G`. Dual\nto `adjunction_of_equiv_right`. -/\n@[simp] theorem adjunction_of_equiv_left_hom_equiv {C : Type u₁} [category C] {D : Type u₂} [category D] {G : D ⥤ C} {F_obj : C → D} (e : (X : C) → (Y : D) → (F_obj X ⟶ Y) ≃ (X ⟶ functor.obj G Y)) (he : ∀ (X : C) (Y Y' : D) (g : Y ⟶ Y') (h : F_obj X ⟶ Y), coe_fn (e X Y') (h ≫ g) = coe_fn (e X Y) h ≫ functor.map G g) (X : C) (Y : D) : hom_equiv (adjunction_of_equiv_left e he) X Y = e X Y :=\n  Eq.refl (e X Y)\n\n-- Construction of a right adjoint, analogous to the above.\n\n/-- Construct a right adjoint functor to `F`, given the functor's value on objects `G_obj` and\na bijection `e` between `F.obj X ⟶ Y` and `X ⟶ G_obj Y` satisfying a naturality law\n`he : ∀ X Y Y' g h, e X' Y (F.map f ≫ g) = f ≫ e X Y g`.\nDual to `left_adjoint_of_equiv`. -/\n@[simp] theorem right_adjoint_of_equiv_obj {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G_obj : D → C} (e : (X : C) → (Y : D) → (functor.obj F X ⟶ Y) ≃ (X ⟶ G_obj Y)) (he : ∀ (X' X : C) (Y : D) (f : X' ⟶ X) (g : functor.obj F X ⟶ Y),\n  coe_fn (e X' Y) (functor.map F f ≫ g) = f ≫ coe_fn (e X Y) g) : ∀ (ᾰ : D), functor.obj (right_adjoint_of_equiv e he) ᾰ = G_obj ᾰ :=\n  fun (ᾰ : D) => Eq.refl (functor.obj (right_adjoint_of_equiv e he) ᾰ)\n\n/-- Show that the functor given by `right_adjoint_of_equiv` is indeed right adjoint to `F`. Dual\nto `adjunction_of_equiv_left`. -/\n@[simp] theorem adjunction_of_equiv_right_counit_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G_obj : D → C} (e : (X : C) → (Y : D) → (functor.obj F X ⟶ Y) ≃ (X ⟶ G_obj Y)) (he : ∀ (X' X : C) (Y : D) (f : X' ⟶ X) (g : functor.obj F X ⟶ Y),\n  coe_fn (e X' Y) (functor.map F f ≫ g) = f ≫ coe_fn (e X Y) g) (Y : D) : nat_trans.app (counit (adjunction_of_equiv_right e he)) Y = coe_fn (equiv.symm (e (G_obj Y) Y)) 𝟙 :=\n  Eq.refl (coe_fn (equiv.symm (e (G_obj Y) Y)) 𝟙)\n\n/--\nIf the unit and counit of a given adjunction are (pointwise) isomorphisms, then we can upgrade the\nadjunction to an equivalence.\n-/\n@[simp] theorem to_equivalence_functor {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) [(X : C) → is_iso (nat_trans.app (unit adj) X)] [(Y : D) → is_iso (nat_trans.app (counit adj) Y)] : equivalence.functor (to_equivalence adj) = F :=\n  Eq.refl (equivalence.functor (to_equivalence adj))\n\n/--\nIf the unit and counit for the adjunction corresponding to a right adjoint functor are (pointwise)\nisomorphisms, then the functor is an equivalence of categories.\n-/\n@[simp] theorem is_right_adjoint_to_is_equivalence_unit_iso_inv_app {C : Type u₁} [category C] {D : Type u₂} [category D] {G : D ⥤ C} [is_right_adjoint G] [(X : C) → is_iso (nat_trans.app (unit (of_right_adjoint G)) X)] [(Y : D) → is_iso (nat_trans.app (counit (of_right_adjoint G)) Y)] (X : D) : nat_trans.app (iso.inv is_equivalence.unit_iso) X = nat_trans.app (counit (of_right_adjoint G)) X :=\n  Eq.refl (nat_trans.app (counit (of_right_adjoint G)) X)\n\nend adjunction\n\n\nnamespace equivalence\n\n\n/-- The adjunction given by an equivalence of categories. (To obtain the opposite adjunction,\nsimply use `e.symm.to_adjunction`. -/\ndef to_adjunction {C : Type u₁} [category C] {D : Type u₂} [category D] (e : C ≌ D) : functor e ⊣ inverse e :=\n  adjunction.mk_of_unit_counit (adjunction.core_unit_counit.mk (unit e) (counit e))\n\nend equivalence\n\n\nnamespace functor\n\n\n/-- An equivalence `E` is left adjoint to its inverse. -/\ndef adjunction {C : Type u₁} [category C] {D : Type u₂} [category D] (E : C ⥤ D) [is_equivalence E] : E ⊣ inv E :=\n  equivalence.to_adjunction (as_equivalence E)\n\n/-- If `F` is an equivalence, it's a left adjoint. -/\nprotected instance left_adjoint_of_equivalence {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} [is_equivalence F] : is_left_adjoint F :=\n  is_left_adjoint.mk (inv F) (adjunction F)\n\n@[simp] theorem right_adjoint_of_is_equivalence {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} [is_equivalence F] : right_adjoint F = inv F :=\n  rfl\n\n/-- If `F` is an equivalence, it's a right adjoint. -/\nprotected instance right_adjoint_of_equivalence {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} [is_equivalence F] : is_right_adjoint F :=\n  is_right_adjoint.mk (inv F) (adjunction (inv F))\n\n@[simp] theorem left_adjoint_of_is_equivalence {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} [is_equivalence F] : left_adjoint F = inv F :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/adjunction/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4752271292743993}}
{"text": "structure Something (i: Nat) where\n  n1: Nat := 1\n  n2: Nat := 1 + i\n\ndef s : Something 10 := {}\n\nexample : s.n2 = 11 := rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/defaulValueParamIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4752271229662524}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport algebraic_topology.alternating_face_map_complex\nimport algebraic_topology.simplicial_set\nimport algebraic_topology.cech_nerve\nimport algebra.homology.homotopy\nimport tactic.fin_cases\n\n/-!\n\n# Augmented simplicial objects with an extra degeneracy\n\nIn simplicial homotopy theory, in order to prove that the connected components\nof a simplicial set `X` are contractible, it suffices to construct an extra\ndegeneracy as it is defined in *Simplicial Homotopy Theory* by Goerss-Jardine p. 190.\nIt consists of a series of maps `π₀ X → X _[0]` and `X _[n] → X _[n+1]` which\nbehave formally like an extra degeneracy `σ (-1)`. It can be thought as a datum\nassociated to the augmented simplicial set `X → π₀ X`.\n\nIn this file, we adapt this definition to the case of augmented\nsimplicial objects in any category.\n\n## Main definitions\n\n- the structure `extra_degeneracy X` for any `X : simplicial_object.augmented C`\n- `extra_degeneracy.map`: extra degeneracies are preserved by the application of any\nfunctor `C ⥤ D`\n- `sSet.augmented.standard_simplex.extra_degeneracy`: the standard `n`-simplex has\nan extra degeneracy\n- `arrow.augmented_cech_nerve.extra_degeneracy`: the Čech nerve of a split\nepimorphism has an extra degeneracy\n- `extra_degeneracy.homotopy_equiv`: in the case the category `C` is preadditive,\nif we have an extra degeneracy on `X : simplicial_object.augmented C`, then\nthe augmentation on the alternating face map complex of `X` is a homotopy\nequivalence.\n\n## References\n* [Paul G. Goerss, John F. Jardine, *Simplical Homotopy Theory*][goerss-jardine-2009]\n\n-/\n\nopen category_theory category_theory.category\nopen category_theory.simplicial_object.augmented\nopen opposite\nopen_locale simplicial\n\nnamespace simplicial_object\n\nnamespace augmented\n\nvariables {C : Type*} [category C]\n\n/-- The datum of an extra degeneracy is a technical condition on\naugmented simplicial objects. The morphisms `s'` and `s n` of the\nstructure formally behave like extra degeneracies `σ (-1)`. -/\n@[ext]\nstructure extra_degeneracy (X : simplicial_object.augmented C) :=\n(s' : point.obj X ⟶ (drop.obj X) _[0])\n(s : Π (n : ℕ), (drop.obj X) _[n] ⟶ (drop.obj X) _[n+1])\n(s'_comp_ε' : s' ≫ X.hom.app (op [0]) = 𝟙 _)\n(s₀_comp_δ₁' : s 0 ≫ (drop.obj X).δ 1 = X.hom.app (op [0]) ≫ s')\n(s_comp_δ₀' : Π (n : ℕ), s n ≫ (drop.obj X).δ 0 = 𝟙 _)\n(s_comp_δ' : Π (n : ℕ) (i : fin (n+2)), s (n+1) ≫ (drop.obj X).δ i.succ =\n  (drop.obj X).δ i ≫ s n)\n(s_comp_σ' : Π (n : ℕ) (i : fin (n+1)), s n ≫ (drop.obj X).σ i.succ =\n  (drop.obj X).σ i ≫ s (n+1))\n\nnamespace extra_degeneracy\n\nrestate_axiom s'_comp_ε'\nrestate_axiom s₀_comp_δ₁'\nrestate_axiom s_comp_δ₀'\nrestate_axiom s_comp_δ'\nrestate_axiom s_comp_σ'\nattribute [reassoc] s'_comp_ε s₀_comp_δ₁ s_comp_δ₀ s_comp_δ s_comp_σ\nattribute [simp] s'_comp_ε s_comp_δ₀\n\n/-- If `ed` is an extra degeneracy for `X : simplicial_object.augmented C` and\n`F : C ⥤ D` is a functor, then `ed.map F` is an extra degeneracy for the\naugmented simplical object in `D` obtained by applying `F` to `X`. -/\ndef map {D : Type*} [category D]\n  {X : simplicial_object.augmented C} (ed : extra_degeneracy X) (F : C ⥤ D) :\n  extra_degeneracy (((whiskering _ _).obj F).obj X) :=\n{ s' := F.map ed.s',\n  s := λ n, F.map (ed.s n),\n  s'_comp_ε' := by { dsimp, erw [comp_id, ← F.map_comp, ed.s'_comp_ε, F.map_id], },\n  s₀_comp_δ₁' := by { dsimp, erw [comp_id, ← F.map_comp, ← F.map_comp, ed.s₀_comp_δ₁], },\n  s_comp_δ₀' := λ n, by { dsimp, erw [← F.map_comp, ed.s_comp_δ₀, F.map_id], },\n  s_comp_δ' := λ n i, by { dsimp, erw [← F.map_comp, ← F.map_comp, ed.s_comp_δ], refl, },\n  s_comp_σ' := λ n i, by { dsimp, erw [← F.map_comp, ← F.map_comp, ed.s_comp_σ], refl, }, }\n\n/-- If `X` and `Y` are isomorphic augmented simplicial objects, then an extra\ndegeneracy for `X` gives also an extra degeneracy for `Y` -/\ndef of_iso {X Y : simplicial_object.augmented C} (e : X ≅ Y) (ed : extra_degeneracy X) :\n  extra_degeneracy Y :=\n{ s' := (point.map_iso e).inv ≫ ed.s' ≫ (drop.map_iso e).hom.app (op [0]),\n  s := λ n, (drop.map_iso e).inv.app (op [n]) ≫ ed.s n ≫ (drop.map_iso e).hom.app (op [n+1]),\n  s'_comp_ε' := by simpa only [functor.map_iso, assoc, w₀, ed.s'_comp_ε_assoc]\n    using (point.map_iso e).inv_hom_id,\n  s₀_comp_δ₁' := begin\n    have h := w₀ e.inv,\n    dsimp at h ⊢,\n    simp only [assoc, ← simplicial_object.δ_naturality, ed.s₀_comp_δ₁_assoc, reassoc_of h],\n  end,\n  s_comp_δ₀' := λ n, begin\n    have h := ed.s_comp_δ₀',\n    dsimp at ⊢ h,\n    simpa only [assoc, ← simplicial_object.δ_naturality, reassoc_of h]\n      using congr_app (drop.map_iso e).inv_hom_id (op [n]),\n  end,\n  s_comp_δ' := λ n i, begin\n    have h := ed.s_comp_δ' n i,\n    dsimp at ⊢ h,\n    simp only [assoc, ← simplicial_object.δ_naturality, reassoc_of h,\n      ← simplicial_object.δ_naturality_assoc],\n  end,\n  s_comp_σ' := λ n i, begin\n    have h := ed.s_comp_σ' n i,\n    dsimp at ⊢ h,\n    simp only [assoc, ← simplicial_object.σ_naturality, reassoc_of h,\n      ← simplicial_object.σ_naturality_assoc],\n  end,}\n\nend extra_degeneracy\n\nend augmented\n\nend simplicial_object\n\nnamespace sSet\n\nnamespace augmented\n\nnamespace standard_simplex\n\n/-- When `[has_zero X]`, the shift of a map `f : fin n → X`\nis a map `fin (n+1) → X` which sends `0` to `0` and `i.succ` to `f i`. -/\ndef shift_fun {n : ℕ} {X : Type*} [has_zero X] (f : fin n → X) (i : fin (n+1)) : X :=\ndite (i = 0) (λ h, 0) (λ h, f (i.pred h))\n\n@[simp]\nlemma shift_fun_0 {n : ℕ} {X : Type*} [has_zero X] (f : fin n → X) : shift_fun f 0 = 0 := rfl\n\n@[simp]\nlemma shift_fun_succ {n : ℕ} {X : Type*} [has_zero X] (f : fin n → X)\n  (i : fin n) : shift_fun f i.succ = f i :=\nbegin\n  dsimp [shift_fun],\n  split_ifs,\n  { exfalso,\n    simpa only [fin.ext_iff, fin.coe_succ] using h, },\n  { simp only [fin.pred_succ], },\nend\n\n/-- The shift of a morphism `f : [n] → Δ` in `simplex_category` corresponds to\nthe monotone map which sends `0` to `0` and `i.succ` to `f.to_order_hom i`. -/\n@[simp]\ndef shift {n : ℕ} {Δ : simplex_category} (f : [n] ⟶ Δ) : [n+1] ⟶ Δ := simplex_category.hom.mk\n{ to_fun := shift_fun f.to_order_hom,\n  monotone' := λ i₁ i₂ hi, begin\n    by_cases h₁ : i₁ = 0,\n    { subst h₁,\n      simp only [shift_fun_0, fin.zero_le], },\n    { have h₂ : i₂ ≠ 0 := by { intro h₂, subst h₂, exact h₁ (le_antisymm hi (fin.zero_le _)), },\n      cases fin.eq_succ_of_ne_zero h₁ with j₁ hj₁,\n      cases fin.eq_succ_of_ne_zero h₂ with j₂ hj₂,\n      substs hj₁ hj₂,\n      simpa only [shift_fun_succ] using f.to_order_hom.monotone (fin.succ_le_succ_iff.mp hi), },\n  end, }\n\n/-- The obvious extra degeneracy on the standard simplex. -/\n@[protected]\ndef extra_degeneracy (Δ : simplex_category) :\n  simplicial_object.augmented.extra_degeneracy (standard_simplex.obj Δ) :=\n{ s' := λ x, simplex_category.hom.mk (order_hom.const _ 0),\n  s := λ n f, shift f,\n  s'_comp_ε' := by { ext1 j, fin_cases j, },\n  s₀_comp_δ₁' := by { ext x j, fin_cases j, refl, },\n  s_comp_δ₀' := λ n, begin\n    ext φ i : 4,\n    dsimp [simplicial_object.δ, simplex_category.δ, sSet.standard_simplex],\n    simp only [shift_fun_succ],\n  end,\n  s_comp_δ' := λ n i, begin\n    ext φ j : 4,\n    dsimp [simplicial_object.δ, simplex_category.δ, sSet.standard_simplex],\n    by_cases j = 0,\n    { subst h,\n      simp only [fin.succ_succ_above_zero, shift_fun_0], },\n    { cases fin.eq_succ_of_ne_zero h with k hk,\n      subst hk,\n      simp only [fin.succ_succ_above_succ, shift_fun_succ], },\n  end,\n  s_comp_σ' := λ n i, begin\n    ext φ j : 4,\n    dsimp [simplicial_object.σ, simplex_category.σ, sSet.standard_simplex],\n    by_cases j = 0,\n    { subst h,\n      simpa only [shift_fun_0] using shift_fun_0 φ.to_order_hom, },\n    { cases fin.eq_succ_of_ne_zero h with k hk,\n      subst hk,\n      simp only [fin.succ_pred_above_succ, shift_fun_succ], },\n  end, }\n\ninstance nonempty_extra_degeneracy_standard_simplex (Δ : simplex_category) :\n  nonempty (simplicial_object.augmented.extra_degeneracy (standard_simplex.obj Δ)) :=\n⟨standard_simplex.extra_degeneracy Δ⟩\n\nend standard_simplex\n\nend augmented\n\nend sSet\n\nnamespace category_theory\n\nopen limits\n\nnamespace arrow\n\nnamespace augmented_cech_nerve\n\nvariables {C : Type*} [category C] (f : arrow C)\n  [∀ n : ℕ, has_wide_pullback f.right (λ i : fin (n+1), f.left) (λ i, f.hom)]\n  (S : split_epi f.hom)\n\ninclude S\n\n/-- The extra degeneracy map on the Čech nerve of a split epi. It is\ngiven on the `0`-projection by the given section of the split epi,\nand by shifting the indices on the other projections. -/\nnoncomputable def extra_degeneracy.s (n : ℕ) :\n  f.cech_nerve.obj (op [n]) ⟶ f.cech_nerve.obj (op [n + 1]) :=\nwide_pullback.lift (wide_pullback.base _)\n  (λ i, dite (i = 0) (λ h, wide_pullback.base _ ≫ S.section_)\n    (λ h, wide_pullback.π _ (i.pred h)))\n  (λ i, begin\n    split_ifs,\n    { subst h,\n      simp only [assoc, split_epi.id, comp_id], },\n    { simp only [wide_pullback.π_arrow], },\n  end)\n\n@[simp]\nlemma extra_degeneracy.s_comp_π_0 (n : ℕ) :\n  extra_degeneracy.s f S n ≫ wide_pullback.π _ 0 = wide_pullback.base _ ≫ S.section_ :=\nby { dsimp [extra_degeneracy.s], simpa only [wide_pullback.lift_π], }\n\n@[simp]\nlemma extra_degeneracy.s_comp_π_succ (n : ℕ) (i : fin (n+1)) :\n  extra_degeneracy.s f S n ≫ wide_pullback.π _ i.succ = wide_pullback.π _ i :=\nbegin\n  dsimp [extra_degeneracy.s],\n  simp only [wide_pullback.lift_π],\n  split_ifs,\n  { exfalso,\n    simpa only [fin.ext_iff, fin.coe_succ, fin.coe_zero, nat.succ_ne_zero] using h, },\n  { congr,\n    apply fin.pred_succ, },\nend\n\n@[simp]\nlemma extra_degeneracy.s_comp_base (n : ℕ) :\n  extra_degeneracy.s f S n ≫ wide_pullback.base _ = wide_pullback.base _ :=\nby apply wide_pullback.lift_base\n\n/-- The augmented Čech nerve associated to a split epimorphism has an extra degeneracy. -/\nnoncomputable def extra_degeneracy :\n  simplicial_object.augmented.extra_degeneracy f.augmented_cech_nerve :=\n{ s' := S.section_ ≫ wide_pullback.lift f.hom (λ i, 𝟙 _) (λ i, by rw id_comp),\n  s := λ n, extra_degeneracy.s f S n,\n  s'_comp_ε' :=\n    by simp only [augmented_cech_nerve_hom_app, assoc, wide_pullback.lift_base, split_epi.id],\n  s₀_comp_δ₁' := begin\n    dsimp [cech_nerve, simplicial_object.δ, simplex_category.δ],\n    ext j,\n    { fin_cases j,\n      simpa only [assoc, wide_pullback.lift_π, comp_id] using extra_degeneracy.s_comp_π_0 f S 0, },\n    { simpa only [assoc, wide_pullback.lift_base, split_epi.id, comp_id]\n        using extra_degeneracy.s_comp_base f S 0, },\n  end,\n  s_comp_δ₀' := λ n, begin\n    dsimp [cech_nerve, simplicial_object.δ, simplex_category.δ],\n    ext j,\n    { simpa only [assoc, wide_pullback.lift_π, id_comp]\n        using extra_degeneracy.s_comp_π_succ f S n j, },\n    { simpa only [assoc, wide_pullback.lift_base, id_comp]\n        using extra_degeneracy.s_comp_base f S n, },\n  end,\n  s_comp_δ' := λ n i, begin\n    dsimp [cech_nerve, simplicial_object.δ, simplex_category.δ],\n    ext j,\n    { simp only [assoc, wide_pullback.lift_π],\n      by_cases j = 0,\n      { subst h,\n        erw [fin.succ_succ_above_zero, extra_degeneracy.s_comp_π_0, extra_degeneracy.s_comp_π_0],\n        dsimp,\n        simp only [wide_pullback.lift_base_assoc], },\n      { cases fin.eq_succ_of_ne_zero h with k hk,\n        subst hk,\n        erw [fin.succ_succ_above_succ, extra_degeneracy.s_comp_π_succ,\n          extra_degeneracy.s_comp_π_succ],\n        dsimp,\n        simp only [wide_pullback.lift_π], }, },\n    { simp only [assoc, wide_pullback.lift_base],\n      erw [extra_degeneracy.s_comp_base, extra_degeneracy.s_comp_base],\n      dsimp,\n      simp only [wide_pullback.lift_base], },\n  end,\n  s_comp_σ' := λ n i, begin\n    dsimp [cech_nerve, simplicial_object.σ, simplex_category.σ],\n    ext j,\n    { simp only [assoc, wide_pullback.lift_π],\n      by_cases j = 0,\n      { subst h,\n        erw [extra_degeneracy.s_comp_π_0, extra_degeneracy.s_comp_π_0],\n        dsimp,\n        simp only [wide_pullback.lift_base_assoc], },\n      { cases fin.eq_succ_of_ne_zero h with k hk,\n        subst hk,\n        erw [fin.succ_pred_above_succ, extra_degeneracy.s_comp_π_succ,\n          extra_degeneracy.s_comp_π_succ],\n        dsimp,\n        simp only [wide_pullback.lift_π], }, },\n    { simp only [assoc, wide_pullback.lift_base],\n      erw [extra_degeneracy.s_comp_base, extra_degeneracy.s_comp_base],\n      dsimp,\n      simp only [wide_pullback.lift_base], },\n  end, }\n\nend augmented_cech_nerve\n\nend arrow\n\nend category_theory\n\nnamespace simplicial_object\n\nnamespace augmented\n\nnamespace extra_degeneracy\n\nopen algebraic_topology category_theory category_theory.limits\n\n/-- If `C` is a preadditive category and `X` is an augmented simplicial object\nin `C` that has an extra degeneracy, then the augmentation on the alternating\nface map complex of `X` is an homotopy equivalence. -/\nnoncomputable\ndef homotopy_equiv {C : Type*} [category C]\n  [preadditive C] [has_zero_object C] {X : simplicial_object.augmented C}\n  (ed : extra_degeneracy X) :\n  homotopy_equiv (algebraic_topology.alternating_face_map_complex.obj (drop.obj X))\n    ((chain_complex.single₀ C).obj (point.obj X)) :=\n{ hom := alternating_face_map_complex.ε.app X,\n  inv := (chain_complex.from_single₀_equiv _ _).inv_fun ed.s',\n  homotopy_inv_hom_id := homotopy.of_eq (by { ext, exact ed.s'_comp_ε, }),\n  homotopy_hom_inv_id :=\n  { hom := λ i j, begin\n      by_cases i+1 = j,\n      { exact (-ed.s i) ≫ eq_to_hom (by congr'), },\n      { exact 0, },\n    end,\n    zero' := λ i j hij, begin\n      split_ifs,\n      { exfalso, exact hij h, },\n      { simp only [eq_self_iff_true], },\n    end,\n    comm := λ i, begin\n      cases i,\n      { rw [homotopy.prev_d_chain_complex, homotopy.d_next_zero_chain_complex, zero_add],\n        dsimp [chain_complex.from_single₀_equiv, chain_complex.to_single₀_equiv],\n        simp only [zero_add, eq_self_iff_true, preadditive.neg_comp, comp_id, if_true,\n          alternating_face_map_complex.obj_d_eq, fin.sum_univ_two, fin.coe_zero, pow_zero,\n          one_zsmul, fin.coe_one, pow_one, neg_smul, preadditive.comp_add, ← s₀_comp_δ₁,\n          s_comp_δ₀, preadditive.comp_neg, neg_add_rev, neg_neg, neg_add_cancel_right,\n          neg_add_cancel_comm], },\n      { rw [homotopy.prev_d_chain_complex, homotopy.d_next_succ_chain_complex],\n        dsimp [chain_complex.to_single₀_equiv, chain_complex.from_single₀_equiv],\n        simp only [zero_comp, alternating_face_map_complex.obj_d_eq, eq_self_iff_true,\n          preadditive.neg_comp, comp_id, if_true, preadditive.comp_neg,\n          @fin.sum_univ_succ _ _ (i+2), preadditive.comp_add, fin.coe_zero, pow_zero, one_zsmul,\n          s_comp_δ₀, fin.coe_succ, pow_add, pow_one, mul_neg, neg_zsmul,\n          preadditive.comp_sum, preadditive.sum_comp, neg_neg, mul_one,\n          preadditive.comp_zsmul, preadditive.zsmul_comp, s_comp_δ, zsmul_neg],\n        rw [add_comm (-𝟙 _), add_assoc, add_assoc, add_left_neg, add_zero,\n          finset.sum_neg_distrib, add_left_neg], },\n    end, }, }\n\nend extra_degeneracy\n\nend augmented\n\nend simplicial_object\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_topology/extra_degeneracy.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.47522712296625236}}
{"text": "/-\nCopyright (c) 2018 Andreas Swerdlow. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andreas Swerdlow\n-/\nimport algebra.module.linear_map\nimport linear_algebra.bilinear_map\nimport linear_algebra.matrix.basis\n\n/-!\n# Sesquilinear form\n\nThis files provides properties about sesquilinear forms. The maps considered are of the form\n`M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R`, where `I₁ : R₁ →+* R` and `I₂ : R₂ →+* R` are ring homomorphisms and\n`M₁` is a module over `R₁` and `M₂` is a module over `R₂`.\nSesquilinear forms are the special case that `M₁ = M₂`, `R₁ = R₂ = R`, and `I₁ = ring_hom.id R`.\nTaking additionally `I₂ = ring_hom.id R`, then one obtains bilinear forms.\n\nThese forms are a special case of the bilinear maps defined in `bilinear_map.lean` and all basic\nlemmas about construction and elementary calculations are found there.\n\n## Main declarations\n\n* `is_ortho`: states that two vectors are orthogonal with respect to a sesquilinear form\n* `is_symm`, `is_alt`: states that a sesquilinear form is symmetric and alternating, respectively\n* `orthogonal_bilin`: provides the orthogonal complement with respect to sesquilinear form\n\n## References\n\n* <https://en.wikipedia.org/wiki/Sesquilinear_form#Over_arbitrary_rings>\n\n## Tags\n\nSesquilinear form,\n-/\n\nopen_locale big_operators\n\nvariables {R R₁ R₂ R₃ M M₁ M₂ K K₁ K₂ V V₁ V₂ n: Type*}\n\nnamespace linear_map\n\n/-! ### Orthogonal vectors -/\n\nsection comm_ring\n\n-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables [comm_semiring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  [comm_semiring R₂] [add_comm_monoid M₂] [module R₂ M₂]\n  {I₁ : R₁ →+* R} {I₂ : R₂ →+* R} {I₁' : R₁ →+* R}\n\n/-- The proposition that two elements of a sesquilinear form space are orthogonal -/\ndef is_ortho (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x y) : Prop := B x y = 0\n\nlemma is_ortho_def {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} {x y} :\n  B.is_ortho x y ↔ B x y = 0 := iff.rfl\n\nlemma is_ortho_zero_left (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x) : is_ortho B (0 : M₁) x :=\n  by { dunfold is_ortho, rw [ map_zero B, zero_apply] }\n\nlemma is_ortho_zero_right (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x) : is_ortho B x (0 : M₂) :=\n  map_zero (B x)\n\n/-- A set of vectors `v` is orthogonal with respect to some bilinear form `B` if and only\nif for all `i ≠ j`, `B (v i) (v j) = 0`. For orthogonality between two elements, use\n`bilin_form.is_ortho` -/\ndef is_Ortho {n : Type*} (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R) (v : n → M₁) : Prop :=\npairwise (B.is_ortho on v)\n\nlemma is_Ortho_def {n : Type*} {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R} {v : n → M₁} :\n  B.is_Ortho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 := iff.rfl\n\nend comm_ring\nsection field\n\nvariables [field K] [field K₁] [add_comm_group V₁] [module K₁ V₁]\n  [field K₂] [add_comm_group V₂] [module K₂ V₂]\n  {I₁ : K₁ →+* K} {I₂ : K₂ →+* K} {I₁' : K₁ →+* K}\n  {J₁ : K →+* K} {J₂ : K →+* K}\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J₁ is invertible\nlemma ortho_smul_left {B : V₁ →ₛₗ[I₁] V₂ →ₛₗ[I₂] K} {x y} {a : K₁} (ha : a ≠ 0) :\n  (is_ortho B x y) ↔ (is_ortho B (a • x) y) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smulₛₗ₂, H, smul_zero]},\n  { rw [map_smulₛₗ₂, smul_eq_zero] at H,\n    cases H,\n    { rw I₁.map_eq_zero at H, trivial },\n    { exact H }}\nend\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J₂ is invertible\nlemma ortho_smul_right {B : V₁ →ₛₗ[I₁] V₂ →ₛₗ[I₂] K} {x y} {a : K₂} {ha : a ≠ 0} :\n(is_ortho B x y) ↔ (is_ortho B x (a • y)) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smulₛₗ, H, smul_zero] },\n  { rw [map_smulₛₗ, smul_eq_zero] at H,\n    cases H,\n    { simp at H,\n      exfalso,\n      exact ha H },\n    { exact H }}\nend\n\n/-- A set of orthogonal vectors `v` with respect to some sesquilinear form `B` is linearly\n  independent if for all `i`, `B (v i) (v i) ≠ 0`. -/\nlemma linear_independent_of_is_Ortho {B : V₁ →ₛₗ[I₁] V₁ →ₛₗ[I₁'] K} {v : n → V₁}\n  (hv₁ : B.is_Ortho v) (hv₂ : ∀ i, ¬ B.is_ortho (v i) (v i)) : linear_independent K₁ v :=\nbegin\n  classical,\n  rw linear_independent_iff',\n  intros s w hs i hi,\n  have : B (s.sum $ λ (i : n), w i • v i) (v i) = 0,\n  { rw [hs, map_zero, zero_apply] },\n  have hsum : s.sum (λ (j : n), I₁(w j) * B (v j) (v i)) = I₁(w i) * B (v i) (v i),\n  { apply finset.sum_eq_single_of_mem i hi,\n    intros j hj hij,\n    rw [is_Ortho_def.1 hv₁ _ _ hij, mul_zero], },\n  simp_rw [B.map_sum₂, map_smulₛₗ₂, smul_eq_mul, hsum] at this,\n  apply I₁.map_eq_zero.mp,\n  exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv₂ i) this,\nend\n\nend field\n\nvariables [comm_ring R] [add_comm_group M] [module R M]\n  [comm_ring R₁] [add_comm_group M₁] [module R₁ M₁]\n  {I : R →+* R} {I₁ : R₁ →+* R} {I₂ : R₁ →+* R}\n  {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n  {B' : M →ₗ[R] M →ₛₗ[I] R}\n\n/-! ### Reflexive bilinear forms -/\n\n/-- The proposition that a sesquilinear form is reflexive -/\ndef is_refl (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : Prop :=\n  ∀ (x y), B x y = 0 → B y x = 0\n\nnamespace is_refl\n\nvariable (H : B.is_refl)\n\nlemma eq_zero : ∀ {x y}, B x y = 0 → B y x = 0 := λ x y, H x y\n\nlemma ortho_comm {x y} : is_ortho B x y ↔ is_ortho B y x := ⟨eq_zero H, eq_zero H⟩\n\nend is_refl\n\n/-! ### Symmetric bilinear forms -/\n\n/-- The proposition that a sesquilinear form is symmetric -/\ndef is_symm (B : M →ₗ[R] M →ₛₗ[I] R) : Prop :=\n  ∀ (x y), I (B x y) = B y x\n\nnamespace is_symm\n\nvariable (H : B'.is_symm)\ninclude H\n\nprotected lemma eq (x y) : (I (B' x y)) = B' y x := H x y\n\nlemma is_refl : B'.is_refl := λ x y H1, by { rw [←H], simp [H1] }\n\nlemma ortho_comm {x y} : is_ortho B' x y ↔ is_ortho B' y x := H.is_refl.ortho_comm\n\nend is_symm\n\n/-! ### Alternating bilinear forms -/\n\n/-- The proposition that a sesquilinear form is alternating -/\ndef is_alt (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : Prop := ∀ x, B x x = 0\n\nnamespace is_alt\n\nvariable (H : B.is_alt)\ninclude H\n\nlemma self_eq_zero (x) : B x x = 0 := H x\n\nlemma neg (x y) : - B x y = B y x :=\nbegin\n  have H1 : B (y + x) (y + x) = 0,\n  { exact self_eq_zero H (y + x) },\n  simp [map_add, self_eq_zero H] at H1,\n  rw [add_eq_zero_iff_neg_eq] at H1,\n  exact H1,\nend\n\nlemma is_refl : B.is_refl :=\nbegin\n  intros x y h,\n  rw [←neg H, h, neg_zero],\nend\n\nlemma ortho_comm {x y} : is_ortho B x y ↔ is_ortho B y x := H.is_refl.ortho_comm\n\nend is_alt\n\nend linear_map\n\nnamespace submodule\n\n/-! ### The orthogonal complement -/\n\nvariables [comm_ring R] [comm_ring R₁] [add_comm_group M₁] [module R₁ M₁]\n  {I₁ : R₁ →+* R} {I₂ : R₁ →+* R}\n  {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n\n/-- The orthogonal complement of a submodule `N` with respect to some bilinear form is the set of\nelements `x` which are orthogonal to all elements of `N`; i.e., for all `y` in `N`, `B x y = 0`.\n\nNote that for general (neither symmetric nor antisymmetric) bilinear forms this definition has a\nchirality; in addition to this \"left\" orthogonal complement one could define a \"right\" orthogonal\ncomplement for which, for all `y` in `N`, `B y x = 0`.  This variant definition is not currently\nprovided in mathlib. -/\ndef orthogonal_bilin (N : submodule R₁ M₁) (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : submodule R₁ M₁ :=\n{ carrier := { m | ∀ n ∈ N, B.is_ortho n m },\n  zero_mem' := λ x _, B.is_ortho_zero_right x,\n  add_mem' := λ x y hx hy n hn,\n    by rw [linear_map.is_ortho, map_add, show B n x = 0, by exact hx n hn,\n        show B n y = 0, by exact hy n hn, zero_add],\n  smul_mem' := λ c x hx n hn,\n    by rw [linear_map.is_ortho, linear_map.map_smulₛₗ, show B n x = 0, by exact hx n hn,\n        smul_zero] }\n\nvariables {N L : submodule R₁ M₁}\n\n@[simp] lemma mem_orthogonal_bilin_iff {m : M₁} :\n  m ∈ N.orthogonal_bilin B ↔ ∀ n ∈ N, B.is_ortho n m := iff.rfl\n\nlemma orthogonal_bilin_le (h : N ≤ L) : L.orthogonal_bilin B ≤ N.orthogonal_bilin B :=\nλ _ hn l hl, hn l (h hl)\n\nlemma le_orthogonal_bilin_orthogonal_bilin (b : B.is_refl) :\n  N ≤ (N.orthogonal_bilin B).orthogonal_bilin B :=\nλ n hn m hm, b _ _ (hm n hn)\n\nend submodule\n\nnamespace linear_map\n\nsection orthogonal\n\nvariables [field K] [add_comm_group V] [module K V]\n  [field K₁] [add_comm_group V₁] [module K₁ V₁]\n  {J : K →+* K} {J₁ : K₁ →+* K} {J₁' : K₁ →+* K}\n\n-- ↓ This lemma only applies in fields as we require `a * b = 0 → a = 0 ∨ b = 0`\nlemma span_singleton_inf_orthogonal_eq_bot\n  (B : V₁ →ₛₗ[J₁] V₁ →ₛₗ[J₁'] K) (x : V₁) (hx : ¬ B.is_ortho x x) :\n  (K₁ ∙ x) ⊓ submodule.orthogonal_bilin (K₁ ∙ x) B = ⊥ :=\nbegin\n  rw ← finset.coe_singleton,\n  refine eq_bot_iff.2 (λ y h, _),\n  rcases mem_span_finset.1 h.1 with ⟨μ, rfl⟩,\n  have := h.2 x _,\n  { rw finset.sum_singleton at this ⊢,\n    suffices hμzero : μ x = 0,\n    { rw [hμzero, zero_smul, submodule.mem_bot] },\n    change B x (μ x • x) = 0 at this, rw [map_smulₛₗ, smul_eq_mul] at this,\n    exact or.elim (zero_eq_mul.mp this.symm)\n    (λ y, by { simp at y, exact y })\n    (λ hfalse, false.elim $ hx hfalse) },\n  { rw submodule.mem_span; exact λ _ hp, hp $ finset.mem_singleton_self _ }\nend\n\n-- ↓ This lemma only applies in fields since we use the `mul_eq_zero`\nlemma orthogonal_span_singleton_eq_to_lin_ker {B : V →ₗ[K] V →ₛₗ[J] K} (x : V) :\n  submodule.orthogonal_bilin (K ∙ x) B = (B x).ker :=\nbegin\n  ext y,\n  simp_rw [submodule.mem_orthogonal_bilin_iff, linear_map.mem_ker,\n           submodule.mem_span_singleton ],\n  split,\n  { exact λ h, h x ⟨1, one_smul _ _⟩ },\n  { rintro h _ ⟨z, rfl⟩,\n    rw [is_ortho, map_smulₛₗ₂, smul_eq_zero],\n    exact or.intro_right _ h }\nend\n\n\n-- todo: Generalize this to sesquilinear maps\nlemma span_singleton_sup_orthogonal_eq_top {B : V →ₗ[K] V →ₗ[K] K}\n  {x : V} (hx : ¬ B.is_ortho x x) :\n  (K ∙ x) ⊔ submodule.orthogonal_bilin (K ∙ x) B = ⊤ :=\nbegin\n  rw orthogonal_span_singleton_eq_to_lin_ker,\n  exact (B x).span_singleton_sup_ker_eq_top hx,\nend\n\n\n-- todo: Generalize this to sesquilinear maps\n/-- Given a bilinear form `B` and some `x` such that `B x x ≠ 0`, the span of the singleton of `x`\n  is complement to its orthogonal complement. -/\nlemma is_compl_span_singleton_orthogonal {B : V →ₗ[K] V →ₗ[K] K}\n  {x : V} (hx : ¬ B.is_ortho x x) : is_compl (K ∙ x) (submodule.orthogonal_bilin (K ∙ x) B) :=\n{ inf_le_bot := eq_bot_iff.1 $\n    (span_singleton_inf_orthogonal_eq_bot B x hx),\n  top_le_sup := eq_top_iff.1 $ span_singleton_sup_orthogonal_eq_top hx }\n\nend orthogonal\n\nend linear_map\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/linear_algebra/sesquilinear_form.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.47522712296625236}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.functor\nimport Mathlib.data.mv_polynomial.equiv\nimport Mathlib.data.mv_polynomial.comm_ring\nimport Mathlib.ring_theory.free_ring\nimport Mathlib.PostPort\n\nuniverses u v u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Free commutative rings\n\nThe theory of the free commutative ring generated by a type `α`.\nIt is isomorphic to the polynomial ring over ℤ with variables\nin `α`\n\n## Main definitions\n\n* `free_comm_ring α`     : the free commutative ring on a type α\n* `lift_hom (f : α → R)` : the ring hom `free_comm_ring α →+* R` induced by functoriality from `f`.\n* `map (f : α → β)`      : the ring hom `free_comm_ring α →*+ free_comm_ring β` induced by\n                           functoriality from f.\n\n## Main results\n\n`free_comm_ring` has functorial properties (it is an adjoint to the forgetful functor).\nIn this file we have:\n\n* `of : α → free_comm_ring α`\n* `lift_hom (f : α → R) : free_comm_ring α →+* R`\n* `map (f : α → β) : free_comm_ring α →+* free_comm_ring β`\n\n* `free_comm_ring_equiv_mv_polynomial_int : free_comm_ring α ≃+* mv_polynomial α ℤ` :\n    `free_comm_ring α` is isomorphic to a polynomial ring.\n\n\n\n## Implementation notes\n\n`free_comm_ring α` is implemented not using `mv_polynomial` but\ndirectly as the free abelian group on `multiset α`, the type\nof monomials in this free commutative ring.\n\n## Tags\n\nfree commutative ring, free ring\n-/\n\n/-- `free_comm_ring α` is the free commutative ring on the type `α`. -/\ndef free_comm_ring (α : Type u) := free_abelian_group (multiplicative (multiset α))\n\nnamespace free_comm_ring\n\n\n/-- The structure of a commutative ring on `free_comm_ring α`. -/\nprotected instance comm_ring (α : Type u) : comm_ring (free_comm_ring α) :=\n  free_abelian_group.comm_ring (multiplicative (multiset α))\n\nprotected instance inhabited (α : Type u) : Inhabited (free_comm_ring α) := { default := 0 }\n\n/-- The canonical map from `α` to the free commutative ring on `α`. -/\ndef of {α : Type u} (x : α) : free_comm_ring α := free_abelian_group.of ↑[x]\n\ntheorem of_injective {α : Type u} : function.injective of :=\n  function.injective.comp free_abelian_group.of_injective\n    fun (x y : α) => iff.mp (iff.trans multiset.coe_eq_coe list.singleton_perm_singleton)\n\nprotected theorem induction_on {α : Type u} {C : free_comm_ring α → Prop} (z : free_comm_ring α)\n    (hn1 : C (-1)) (hb : ∀ (b : α), C (of b))\n    (ha : ∀ (x y : free_comm_ring α), C x → C y → C (x + y))\n    (hm : ∀ (x y : free_comm_ring α), C x → C y → C (x * y)) : C z :=\n  sorry\n\n/-- Lift a map `α → R` to a additive group homomorphism `free_comm_ring α → R`.\nFor a version producing a bundled homomorphism, see `lift_hom`. -/\ndef lift {α : Type u} {R : Type v} [comm_ring R] (f : α → R) : free_comm_ring α →+* R :=\n  ring_hom.mk\n    (add_monoid_hom.to_fun\n      (free_abelian_group.lift\n        fun (s : multiplicative (multiset α)) =>\n          multiset.prod (multiset.map f (coe_fn multiplicative.to_add s))))\n    sorry sorry sorry sorry\n\n@[simp] theorem lift_of {α : Type u} {R : Type v} [comm_ring R] (f : α → R) (x : α) :\n    coe_fn (lift f) (of x) = f x :=\n  sorry\n\n@[simp] theorem lift_comp_of {α : Type u} {R : Type v} [comm_ring R] (f : free_comm_ring α →+* R) :\n    lift (⇑f ∘ of) = f :=\n  sorry\n\n/-- A map `f : α → β` produces a ring homomorphism `free_comm_ring α →+* free_comm_ring β`. -/\ndef map {α : Type u} {β : Type v} (f : α → β) : free_comm_ring α →+* free_comm_ring β :=\n  lift (of ∘ f)\n\n@[simp] theorem map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :\n    coe_fn (map f) (of x) = of (f x) :=\n  lift_of (of ∘ f) x\n\n/-- `is_supported x s` means that all monomials showing up in `x` have variables in `s`. -/\ndef is_supported {α : Type u} (x : free_comm_ring α) (s : set α) := x ∈ ring.closure (of '' s)\n\ntheorem is_supported_upwards {α : Type u} {x : free_comm_ring α} {s : set α} {t : set α}\n    (hs : is_supported x s) (hst : s ⊆ t) : is_supported x t :=\n  ring.closure_mono (set.monotone_image hst) hs\n\ntheorem is_supported_add {α : Type u} {x : free_comm_ring α} {y : free_comm_ring α} {s : set α}\n    (hxs : is_supported x s) (hys : is_supported y s) : is_supported (x + y) s :=\n  is_add_submonoid.add_mem hxs hys\n\ntheorem is_supported_neg {α : Type u} {x : free_comm_ring α} {s : set α} (hxs : is_supported x s) :\n    is_supported (-x) s :=\n  is_add_subgroup.neg_mem hxs\n\ntheorem is_supported_sub {α : Type u} {x : free_comm_ring α} {y : free_comm_ring α} {s : set α}\n    (hxs : is_supported x s) (hys : is_supported y s) : is_supported (x - y) s :=\n  is_add_subgroup.sub_mem hxs hys\n\ntheorem is_supported_mul {α : Type u} {x : free_comm_ring α} {y : free_comm_ring α} {s : set α}\n    (hxs : is_supported x s) (hys : is_supported y s) : is_supported (x * y) s :=\n  is_submonoid.mul_mem hxs hys\n\ntheorem is_supported_zero {α : Type u} {s : set α} : is_supported 0 s := is_add_submonoid.zero_mem\n\ntheorem is_supported_one {α : Type u} {s : set α} : is_supported 1 s := is_submonoid.one_mem\n\ntheorem is_supported_int {α : Type u} {i : ℤ} {s : set α} : is_supported (↑i) s := sorry\n\n/-- The restriction map from `free_comm_ring α` to `free_comm_ring s` where `s : set α`, defined\n  by sending all variables not in `s` to zero. -/\ndef restriction {α : Type u} (s : set α) [decidable_pred s] :\n    free_comm_ring α →+* free_comm_ring ↥s :=\n  lift\n    fun (p : α) =>\n      dite (p ∈ s) (fun (H : p ∈ s) => of { val := p, property := H }) fun (H : ¬p ∈ s) => 0\n\n@[simp] theorem restriction_of {α : Type u} (s : set α) [decidable_pred s] (p : α) :\n    coe_fn (restriction s) (of p) =\n        dite (p ∈ s) (fun (H : p ∈ s) => of { val := p, property := H }) fun (H : ¬p ∈ s) => 0 :=\n  lift_of\n    (fun (p : α) =>\n      dite (p ∈ s) (fun (H : p ∈ s) => of { val := p, property := H }) fun (H : ¬p ∈ s) => 0)\n    p\n\ntheorem is_supported_of {α : Type u} {p : α} {s : set α} : is_supported (of p) s ↔ p ∈ s := sorry\n\ntheorem map_subtype_val_restriction {α : Type u} {x : free_comm_ring α} (s : set α)\n    [decidable_pred s] (hxs : is_supported x s) :\n    coe_fn (map subtype.val) (coe_fn (restriction s) x) = x :=\n  sorry\n\ntheorem exists_finite_support {α : Type u} (x : free_comm_ring α) :\n    ∃ (s : set α), set.finite s ∧ is_supported x s :=\n  sorry\n\ntheorem exists_finset_support {α : Type u} (x : free_comm_ring α) :\n    ∃ (s : finset α), is_supported x ↑s :=\n  sorry\n\nend free_comm_ring\n\n\nnamespace free_ring\n\n\n/-- The canonical ring homomorphism from the free ring generated by `α` to the free commutative ring\n    generated by `α`. -/\ndef to_free_comm_ring {α : Type u_1} : free_ring α →+* free_comm_ring α := lift free_comm_ring.of\n\nprotected instance free_comm_ring.has_coe (α : Type u) : has_coe (free_ring α) (free_comm_ring α) :=\n  has_coe.mk ⇑to_free_comm_ring\n\nprotected instance coe.is_ring_hom (α : Type u) : is_ring_hom coe :=\n  ring_hom.is_ring_hom to_free_comm_ring\n\n@[simp] protected theorem coe_zero (α : Type u) : ↑0 = 0 := rfl\n\n@[simp] protected theorem coe_one (α : Type u) : ↑1 = 1 := rfl\n\n@[simp] protected theorem coe_of {α : Type u} (a : α) : ↑(of a) = free_comm_ring.of a :=\n  lift_of free_comm_ring.of a\n\n@[simp] protected theorem coe_neg {α : Type u} (x : free_ring α) : ↑(-x) = -↑x :=\n  ring_hom.map_neg (lift free_comm_ring.of) x\n\n@[simp] protected theorem coe_add {α : Type u} (x : free_ring α) (y : free_ring α) :\n    ↑(x + y) = ↑x + ↑y :=\n  ring_hom.map_add (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_sub {α : Type u} (x : free_ring α) (y : free_ring α) :\n    ↑(x - y) = ↑x - ↑y :=\n  ring_hom.map_sub (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_mul {α : Type u} (x : free_ring α) (y : free_ring α) :\n    ↑(x * y) = ↑x * ↑y :=\n  ring_hom.map_mul (lift free_comm_ring.of) x y\n\nprotected theorem coe_surjective (α : Type u) : function.surjective coe := sorry\n\ntheorem coe_eq (α : Type u) : coe = Functor.map fun (l : List α) => ↑l := sorry\n\n-- FIXME This was in `deprecated.ring`, but only used here.\n\n-- It would be good to inline it into the next construction.\n\n/-- Interpret an equivalence `f : R ≃ S` as a ring equivalence `R ≃+* S`. -/\ndef of' {R : Type u_1} {S : Type u_2} [ring R] [ring S] (e : R ≃ S) [is_ring_hom ⇑e] : R ≃+* S :=\n  ring_equiv.mk (equiv.to_fun e) (equiv.inv_fun e) (equiv.left_inv e) (equiv.right_inv e) sorry\n    sorry\n\n/-- If α has size at most 1 then the natural map from the free ring on `α` to the\n    free commutative ring on `α` is an isomorphism of rings. -/\ndef subsingleton_equiv_free_comm_ring (α : Type u) [subsingleton α] :\n    free_ring α ≃+* free_comm_ring α :=\n  of' (functor.map_equiv free_abelian_group (multiset.subsingleton_equiv α))\n\nprotected instance comm_ring (α : Type u) [subsingleton α] : comm_ring (free_ring α) :=\n  comm_ring.mk ring.add sorry ring.zero sorry sorry ring.neg ring.sub sorry sorry ring.mul sorry\n    ring.one sorry sorry sorry sorry sorry\n\nend free_ring\n\n\n/-- The free commutative ring on `α` is isomorphic to the polynomial ring over ℤ with\n    variables in `α` -/\ndef free_comm_ring_equiv_mv_polynomial_int (α : Type u) : free_comm_ring α ≃+* mv_polynomial α ℤ :=\n  ring_equiv.mk (⇑(free_comm_ring.lift fun (a : α) => mv_polynomial.X a))\n    (mv_polynomial.eval₂ (int.cast_ring_hom (free_comm_ring α)) free_comm_ring.of) sorry sorry sorry\n    sorry\n\n/-- The free commutative ring on the empty type is isomorphic to `ℤ`. -/\ndef free_comm_ring_pempty_equiv_int : free_comm_ring pempty ≃+* ℤ :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int pempty)\n    (mv_polynomial.pempty_ring_equiv ℤ)\n\n/-- The free commutative ring on a type with one term is isomorphic to `ℤ[X]`. -/\ndef free_comm_ring_punit_equiv_polynomial_int : free_comm_ring PUnit ≃+* polynomial ℤ :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int PUnit) (mv_polynomial.punit_ring_equiv ℤ)\n\n/-- The free ring on the empty type is isomorphic to `ℤ`. -/\ndef free_ring_pempty_equiv_int : free_ring pempty ≃+* ℤ :=\n  ring_equiv.trans (free_ring.subsingleton_equiv_free_comm_ring pempty)\n    free_comm_ring_pempty_equiv_int\n\n/-- The free ring on a type with one term is isomorphic to `ℤ[X]`. -/\ndef free_ring_punit_equiv_polynomial_int : free_ring PUnit ≃+* polynomial ℤ :=\n  ring_equiv.trans (free_ring.subsingleton_equiv_free_comm_ring PUnit)\n    free_comm_ring_punit_equiv_polynomial_int\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/free_comm_ring_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4752271166581052}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Scott Morrison\n-/\nimport category_theory.fin_category\nimport category_theory.limits.cones\nimport category_theory.adjunction.basic\nimport category_theory.category.preorder\nimport category_theory.category.ulift\nimport order.bounded_order\n\n/-!\n# Filtered categories\n\nA category is filtered if every finite diagram admits a cocone.\nWe give a simple characterisation of this condition as\n1. for every pair of objects there exists another object \"to the right\",\n2. for every pair of parallel morphisms there exists a morphism to the right so the compositions\n   are equal, and\n3. there exists some object.\n\nFiltered colimits are often better behaved than arbitrary colimits.\nSee `category_theory/limits/types` for some details.\n\nFiltered categories are nice because colimits indexed by filtered categories tend to be\neasier to describe than general colimits (and more often preserved by functors).\n\nIn this file we show that any functor from a finite category to a filtered category admits a cocone:\n* `cocone_nonempty [fin_category J] [is_filtered C] (F : J ⥤ C) : nonempty (cocone F)`\nMore generally,\nfor any finite collection of objects and morphisms between them in a filtered category\n(even if not closed under composition) there exists some object `Z` receiving maps from all of them,\nso that all the triangles (one edge from the finite set, two from morphisms to `Z`) commute.\nThis formulation is often more useful in practice and is available via `sup_exists`,\nwhich takes a finset of objects, and an indexed family (indexed by source and target)\nof finsets of morphisms.\n\nFurthermore, we give special support for two diagram categories: The `bowtie` and the `tulip`.\nThis is because these shapes show up in the proofs that forgetful functors of algebraic categories\n(e.g. `Mon`, `CommRing`, ...) preserve filtered colimits.\n\nAll of the above API, except for the `bowtie` and the `tulip`, is also provided for cofiltered\ncategories.\n\n## See also\nIn `category_theory.limits.filtered_colimit_commutes_finite_limit` we show that filtered colimits\ncommute with finite limits.\n\n-/\n\nopen function\n\nuniverses v v₁ u u₁ u₂ -- declare the `v`'s first; see `category_theory.category` for an explanation\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/--\nA category `is_filtered_or_empty` if\n1. for every pair of objects there exists another object \"to the right\", and\n2. for every pair of parallel morphisms there exists a morphism to the right so the compositions\n   are equal.\n-/\nclass is_filtered_or_empty : Prop :=\n(cocone_objs : ∀ (X Y : C), ∃ Z (f : X ⟶ Z) (g : Y ⟶ Z), true)\n(cocone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ Z (h : Y ⟶ Z), f ≫ h = g ≫ h)\n\n/--\nA category `is_filtered` if\n1. for every pair of objects there exists another object \"to the right\",\n2. for every pair of parallel morphisms there exists a morphism to the right so the compositions\n   are equal, and\n3. there exists some object.\n\nSee <https://stacks.math.columbia.edu/tag/002V>. (They also define a diagram being filtered.)\n-/\nclass is_filtered extends is_filtered_or_empty C : Prop :=\n[nonempty : nonempty C]\n\n@[priority 100]\ninstance is_filtered_or_empty_of_semilattice_sup\n  (α : Type u) [semilattice_sup α] : is_filtered_or_empty α :=\n{ cocone_objs := λ X Y, ⟨X ⊔ Y, hom_of_le le_sup_left, hom_of_le le_sup_right, trivial⟩,\n  cocone_maps := λ X Y f g, ⟨Y, 𝟙 _, (by ext)⟩, }\n\n@[priority 100]\ninstance is_filtered_of_semilattice_sup_nonempty\n  (α : Type u) [semilattice_sup α] [nonempty α] : is_filtered α := {}\n\n@[priority 100]\ninstance is_filtered_or_empty_of_directed_le (α : Type u) [preorder α] [is_directed α (≤)] :\n  is_filtered_or_empty α :=\n{ cocone_objs := λ X Y, let ⟨Z, h1, h2⟩ := exists_ge_ge X Y in\n    ⟨Z, hom_of_le h1, hom_of_le h2, trivial⟩,\n  cocone_maps := λ X Y f g, ⟨Y, 𝟙 _, by simp⟩ }\n\n@[priority 100]\ninstance is_filtered_of_directed_le_nonempty  (α : Type u) [preorder α] [is_directed α (≤)]\n  [nonempty α] :\n  is_filtered α := {}\n\n-- Sanity checks\nexample (α : Type u) [semilattice_sup α] [order_bot α] : is_filtered α := by apply_instance\nexample (α : Type u) [semilattice_sup α] [order_top α] : is_filtered α := by apply_instance\n\nnamespace is_filtered\n\nvariables {C} [is_filtered C]\n\n/--\n`max j j'` is an arbitrary choice of object to the right of both `j` and `j'`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def max (j j' : C) : C :=\n(is_filtered_or_empty.cocone_objs j j').some\n\n/--\n`left_to_max j j'` is an arbitrarily choice of morphism from `j` to `max j j'`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def left_to_max (j j' : C) : j ⟶ max j j' :=\n(is_filtered_or_empty.cocone_objs j j').some_spec.some\n\n/--\n`right_to_max j j'` is an arbitrarily choice of morphism from `j'` to `max j j'`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def right_to_max (j j' : C) : j' ⟶ max j j' :=\n(is_filtered_or_empty.cocone_objs j j').some_spec.some_spec.some\n\n/--\n`coeq f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of object\nwhich admits a morphism `coeq_hom f f' : j' ⟶ coeq f f'` such that\n`coeq_condition : f ≫ coeq_hom f f' = f' ≫ coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq {j j' : C} (f f' : j ⟶ j') : C :=\n(is_filtered_or_empty.cocone_maps f f').some\n\n/--\n`coeq_hom f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of morphism\n`coeq_hom f f' : j' ⟶ coeq f f'` such that\n`coeq_condition : f ≫ coeq_hom f f' = f' ≫ coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq_hom {j j' : C} (f f' : j ⟶ j') : j' ⟶ coeq f f' :=\n(is_filtered_or_empty.cocone_maps f f').some_spec.some\n\n/--\n`coeq_condition f f'`, for morphisms `f f' : j ⟶ j'`, is the proof that\n`f ≫ coeq_hom f f' = f' ≫ coeq_hom f f'`.\n-/\n@[simp, reassoc]\nlemma coeq_condition {j j' : C} (f f' : j ⟶ j') : f ≫ coeq_hom f f' = f' ≫ coeq_hom f f' :=\n(is_filtered_or_empty.cocone_maps f f').some_spec.some_spec\n\nopen category_theory.limits\n\n/--\nAny finite collection of objects in a filtered category has an object \"to the right\".\n-/\nlemma sup_objs_exists (O : finset C) : ∃ (S : C), ∀ {X}, X ∈ O → _root_.nonempty (X ⟶ S) :=\nbegin\n  classical,\n  apply finset.induction_on O,\n  { exact ⟨is_filtered.nonempty.some, (by rintros - ⟨⟩)⟩, },\n  { rintros X O' nm ⟨S', w'⟩,\n    use max X S',\n    rintros Y mY,\n    obtain rfl|h := eq_or_ne Y X,\n    { exact ⟨left_to_max _ _⟩, },\n    { exact ⟨(w' (finset.mem_of_mem_insert_of_ne mY h)).some ≫ right_to_max _ _⟩, }, }\nend\n\nvariables (O : finset C) (H : finset (Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y))\n\n/--\nGiven any `finset` of objects `{X, ...}` and\nindexed collection of `finset`s of morphisms `{f, ...}` in `C`,\nthere exists an object `S`, with a morphism `T X : X ⟶ S` from each `X`,\nsuch that the triangles commute: `f ≫ T Y = T X`, for `f : X ⟶ Y` in the `finset`.\n-/\nlemma sup_exists :\n  ∃ (S : C) (T : Π {X : C}, X ∈ O → (X ⟶ S)), ∀ {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y},\n    (⟨X, Y, mX, mY, f⟩ : (Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y)) ∈ H → f ≫ T mY = T mX :=\nbegin\n  classical,\n  apply finset.induction_on H,\n  { obtain ⟨S, f⟩ := sup_objs_exists O,\n    refine ⟨S, λ X mX, (f mX).some, _⟩,\n    rintros - - - - - ⟨⟩, },\n  { rintros ⟨X, Y, mX, mY, f⟩ H' nmf ⟨S', T', w'⟩,\n    refine ⟨coeq (f ≫ T' mY) (T' mX), λ Z mZ, T' mZ ≫ coeq_hom (f ≫ T' mY) (T' mX), _⟩,\n    intros X' Y' mX' mY' f' mf',\n    rw [←category.assoc],\n    by_cases h : X = X' ∧ Y = Y',\n    { rcases h with ⟨rfl, rfl⟩,\n      by_cases hf : f = f',\n      { subst hf,\n        apply coeq_condition, },\n      { rw @w' _ _ mX mY f' (by simpa [hf ∘ eq.symm] using mf') }, },\n    { rw @w' _ _ mX' mY' f' _,\n      apply finset.mem_of_mem_insert_of_ne mf',\n      contrapose! h,\n      obtain ⟨rfl, h⟩ := h,\n      rw [heq_iff_eq, psigma.mk.inj_iff] at h,\n      exact ⟨rfl, h.1.symm⟩ }, },\nend\n\n/--\nAn arbitrary choice of object \"to the right\"\nof a finite collection of objects `O` and morphisms `H`,\nmaking all the triangles commute.\n-/\nnoncomputable\ndef sup : C :=\n(sup_exists O H).some\n\n/--\nThe morphisms to `sup O H`.\n-/\nnoncomputable\ndef to_sup {X : C} (m : X ∈ O) :\n  X ⟶ sup O H :=\n(sup_exists O H).some_spec.some m\n\n/--\nThe triangles of consisting of a morphism in `H` and the maps to `sup O H` commute.\n-/\nlemma to_sup_commutes\n  {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y}\n  (mf : (⟨X, Y, mX, mY, f⟩ : Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y) ∈ H) :\n  f ≫ to_sup O H mY = to_sup O H mX :=\n(sup_exists O H).some_spec.some_spec mX mY mf\n\nvariables {J : Type v} [small_category J] [fin_category J]\n\n/--\nIf we have `is_filtered C`, then for any functor `F : J ⥤ C` with `fin_category J`,\nthere exists a cocone over `F`.\n-/\nlemma cocone_nonempty (F : J ⥤ C) : _root_.nonempty (cocone F) :=\nbegin\n  classical,\n  let O := (finset.univ.image F.obj),\n  let H : finset (Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y) :=\n    finset.univ.bUnion (λ X : J, finset.univ.bUnion (λ Y : J, finset.univ.image (λ f : X ⟶ Y,\n      ⟨F.obj X, F.obj Y, by simp, by simp, F.map f⟩))),\n  obtain ⟨Z, f, w⟩ := sup_exists O H,\n  refine ⟨⟨Z, ⟨λ X, f (by simp), _⟩⟩⟩,\n  intros j j' g,\n  dsimp,\n  simp only [category.comp_id],\n  apply w,\n  simp only [finset.mem_univ, finset.mem_bUnion, exists_and_distrib_left,\n    exists_prop_of_true, finset.mem_image],\n  exact ⟨j, rfl, j', g, (by simp)⟩,\nend\n\n/--\nAn arbitrary choice of cocone over `F : J ⥤ C`, for `fin_category J` and `is_filtered C`.\n-/\nnoncomputable def cocone (F : J ⥤ C) : cocone F :=\n(cocone_nonempty F).some\n\nvariables {D : Type u₁} [category.{v₁} D]\n\n/--\nIf `C` is filtered, and we have a functor `R : C ⥤ D` with a left adjoint, then `D` is filtered.\n-/\nlemma of_right_adjoint {L : D ⥤ C} {R : C ⥤ D} (h : L ⊣ R) : is_filtered D :=\n{ cocone_objs := λ X Y,\n    ⟨_, h.hom_equiv _ _ (left_to_max _ _), h.hom_equiv _ _ (right_to_max _ _), ⟨⟩⟩,\n  cocone_maps := λ X Y f g,\n    ⟨_, h.hom_equiv _ _ (coeq_hom _ _),\n     by rw [← h.hom_equiv_naturality_left, ← h.hom_equiv_naturality_left, coeq_condition]⟩,\n  nonempty := is_filtered.nonempty.map R.obj }\n\n/-- If `C` is filtered, and we have a right adjoint functor `R : C ⥤ D`, then `D` is filtered. -/\nlemma of_is_right_adjoint (R : C ⥤ D) [is_right_adjoint R] : is_filtered D :=\nof_right_adjoint (adjunction.of_right_adjoint R)\n\n/-- Being filtered is preserved by equivalence of categories. -/\nlemma of_equivalence (h : C ≌ D) : is_filtered D :=\nof_right_adjoint h.symm.to_adjunction\n\nsection special_shapes\n\n/--\n`max₃ j₁ j₂ j₃` is an arbitrary choice of object to the right of `j₁`, `j₂` and `j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def max₃ (j₁ j₂ j₃ : C) : C := max (max j₁ j₂) j₃\n\n/--\n`first_to_max₃ j₁ j₂ j₃` is an arbitrarily choice of morphism from `j₁` to `max₃ j₁ j₂ j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def first_to_max₃ (j₁ j₂ j₃ : C) : j₁ ⟶ max₃ j₁ j₂ j₃ :=\nleft_to_max j₁ j₂ ≫ left_to_max (max j₁ j₂) j₃\n\n/--\n`second_to_max₃ j₁ j₂ j₃` is an arbitrarily choice of morphism from `j₂` to `max₃ j₁ j₂ j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def second_to_max₃ (j₁ j₂ j₃ : C) : j₂ ⟶ max₃ j₁ j₂ j₃ :=\nright_to_max j₁ j₂ ≫ left_to_max (max j₁ j₂) j₃\n\n/--\n`third_to_max₃ j₁ j₂ j₃` is an arbitrarily choice of morphism from `j₃` to `max₃ j₁ j₂ j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def third_to_max₃ (j₁ j₂ j₃ : C) : j₃ ⟶ max₃ j₁ j₂ j₃ :=\nright_to_max (max j₁ j₂) j₃\n\n/--\n`coeq₃ f g h`, for morphisms `f g h : j₁ ⟶ j₂`, is an arbitrary choice of object\nwhich admits a morphism `coeq₃_hom f g h : j₂ ⟶ coeq₃ f g h` such that\n`coeq₃_condition₁`, `coeq₃_condition₂` and `coeq₃_condition₃` are satisfied.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq₃ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : C :=\ncoeq (coeq_hom f g ≫ left_to_max (coeq f g) (coeq g h))\n  (coeq_hom g h ≫ right_to_max (coeq f g) (coeq g h))\n\n/--\n`coeq₃_hom f g h`, for morphisms `f g h : j₁ ⟶ j₂`, is an arbitrary choice of morphism\n`j₂ ⟶ coeq₃ f g h` such that `coeq₃_condition₁`, `coeq₃_condition₂` and `coeq₃_condition₃`\nare satisfied. Its existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq₃_hom {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : j₂ ⟶ coeq₃ f g h :=\ncoeq_hom f g ≫ left_to_max (coeq f g) (coeq g h) ≫\ncoeq_hom (coeq_hom f g ≫ left_to_max (coeq f g) (coeq g h))\n  (coeq_hom g h ≫ right_to_max (coeq f g) (coeq g h))\n\nlemma coeq₃_condition₁ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) :\n  f ≫ coeq₃_hom f g h = g ≫ coeq₃_hom f g h :=\nbegin\n  dsimp [coeq₃_hom],\n  slice_lhs 1 2 { rw coeq_condition f g },\n  simp only [category.assoc],\nend\n\nlemma coeq₃_condition₂ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) :\n  g ≫ coeq₃_hom f g h = h ≫ coeq₃_hom f g h :=\nbegin\n  dsimp [coeq₃_hom],\n  slice_lhs 2 4 { rw [← category.assoc, coeq_condition _ _] },\n  slice_rhs 2 4 { rw [← category.assoc, coeq_condition _ _] },\n  slice_lhs 1 3 { rw [← category.assoc, coeq_condition _ _] },\n  simp only [category.assoc],\nend\n\nlemma coeq₃_condition₃ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) :\n  f ≫ coeq₃_hom f g h = h ≫ coeq₃_hom f g h :=\neq.trans (coeq₃_condition₁ f g h) (coeq₃_condition₂ f g h)\n\n/--\nGiven a \"bowtie\" of morphisms\n```\n j₁   j₂\n |\\  /|\n | \\/ |\n | /\\ |\n |/  \\∣\n vv  vv\n k₁  k₂\n```\nin a filtered category, we can construct an object `s` and two morphisms from `k₁` and `k₂` to `s`,\nmaking the resulting squares commute.\n-/\nlemma bowtie {j₁ j₂ k₁ k₂ : C}\n  (f₁ : j₁ ⟶ k₁) (g₁ : j₁ ⟶ k₂) (f₂ : j₂ ⟶ k₁) (g₂ : j₂ ⟶ k₂) :\n  ∃ (s : C) (α : k₁ ⟶ s) (β : k₂ ⟶ s), f₁ ≫ α = g₁ ≫ β ∧ f₂ ≫ α = g₂ ≫ β :=\nbegin\n  let sa := max k₁ k₂,\n  let sb := coeq (f₁ ≫ left_to_max _ _) (g₁ ≫ right_to_max _ _),\n  let sc := coeq (f₂ ≫ left_to_max _ _) (g₂ ≫ right_to_max _ _),\n  let sd := max sb sc,\n  let s := coeq ((coeq_hom _ _ : sa ⟶ sb) ≫ left_to_max _ _)\n    ((coeq_hom _ _ : sa ⟶ sc) ≫ right_to_max _ _),\n  use s,\n  fsplit,\n  exact left_to_max k₁ k₂ ≫ coeq_hom _ _ ≫ left_to_max sb sc ≫ coeq_hom _ _,\n  fsplit,\n  exact right_to_max k₁ k₂ ≫ coeq_hom _ _ ≫ right_to_max sb sc ≫ coeq_hom _ _,\n  fsplit,\n  { slice_lhs 1 3 { rw [←category.assoc, coeq_condition], },\n    slice_lhs 3 5 { rw [←category.assoc, coeq_condition], },\n    simp only [category.assoc], },\n  { slice_lhs 3 5 { rw [←category.assoc, coeq_condition], },\n    slice_lhs 1 3 { rw [←category.assoc, coeq_condition], },\n    simp only [category.assoc], }\nend\n\n/--\nGiven a \"tulip\" of morphisms\n```\n j₁    j₂    j₃\n |\\   / \\   / |\n | \\ /   \\ /  |\n |  vv    vv  |\n \\  k₁    k₂ /\n  \\         /\n   \\       /\n    \\     /\n     \\   /\n      v v\n       l\n```\nin a filtered category, we can construct an object `s` and three morphisms from `k₁`, `k₂` and `l`\nto `s`, making the resulting sqaures commute.\n-/\nlemma tulip {j₁ j₂ j₃ k₁ k₂ l : C} (f₁ : j₁ ⟶ k₁) (f₂ : j₂ ⟶ k₁) (f₃ : j₂ ⟶ k₂) (f₄ : j₃ ⟶ k₂)\n  (g₁ : j₁ ⟶ l) (g₂ : j₃ ⟶ l) :\n  ∃ (s : C) (α : k₁ ⟶ s) (β : l ⟶ s) (γ : k₂ ⟶ s),\n    f₁ ≫ α = g₁ ≫ β ∧ f₂ ≫ α = f₃ ≫ γ ∧ f₄ ≫ γ = g₂ ≫ β :=\nbegin\n  let sa := max₃ k₁ l k₂,\n  let sb := coeq (f₁ ≫ first_to_max₃ k₁ l k₂) (g₁ ≫ second_to_max₃ k₁ l k₂),\n  let sc := coeq (f₂ ≫ first_to_max₃ k₁ l k₂) (f₃ ≫ third_to_max₃ k₁ l k₂),\n  let sd := coeq (f₄ ≫ third_to_max₃ k₁ l k₂) (g₂ ≫ second_to_max₃ k₁ l k₂),\n  let se := max₃ sb sc sd,\n  let sf := coeq₃ (coeq_hom _ _ ≫ first_to_max₃ sb sc sd)\n    (coeq_hom _ _ ≫ second_to_max₃ sb sc sd) (coeq_hom _ _ ≫ third_to_max₃ sb sc sd),\n  use sf,\n  use first_to_max₃ k₁ l k₂ ≫ coeq_hom _ _ ≫ first_to_max₃ sb sc sd ≫ coeq₃_hom _ _ _,\n  use second_to_max₃ k₁ l k₂ ≫ coeq_hom _ _ ≫ second_to_max₃ sb sc sd ≫ coeq₃_hom _ _ _,\n  use third_to_max₃ k₁ l k₂ ≫ coeq_hom _ _ ≫ third_to_max₃ sb sc sd ≫ coeq₃_hom _ _ _,\n  fsplit,\n  slice_lhs 1 3 { rw [← category.assoc, coeq_condition] },\n  slice_lhs 3 6 { rw [← category.assoc, coeq₃_condition₁] },\n  simp only [category.assoc],\n  fsplit,\n  slice_lhs 3 6 { rw [← category.assoc, coeq₃_condition₁] },\n  slice_lhs 1 3 { rw [← category.assoc, coeq_condition] },\n  slice_rhs 3 6 { rw [← category.assoc, ← coeq₃_condition₂] },\n  simp only [category.assoc],\n  slice_rhs 3 6 { rw [← category.assoc, coeq₃_condition₂] },\n  slice_rhs 1 3 { rw [← category.assoc, ← coeq_condition] },\n  simp only [category.assoc],\nend\n\nend special_shapes\n\nend is_filtered\n\n/--\nA category `is_cofiltered_or_empty` if\n1. for every pair of objects there exists another object \"to the left\", and\n2. for every pair of parallel morphisms there exists a morphism to the left so the compositions\n   are equal.\n-/\nclass is_cofiltered_or_empty : Prop :=\n(cocone_objs : ∀ (X Y : C), ∃ W (f : W ⟶ X) (g : W ⟶ Y), true)\n(cocone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ W (h : W ⟶ X), h ≫ f = h ≫ g)\n\n/--\nA category `is_cofiltered` if\n1. for every pair of objects there exists another object \"to the left\",\n2. for every pair of parallel morphisms there exists a morphism to the left so the compositions\n   are equal, and\n3. there exists some object.\n\nSee <https://stacks.math.columbia.edu/tag/04AZ>.\n-/\nclass is_cofiltered extends is_cofiltered_or_empty C : Prop :=\n[nonempty : nonempty C]\n\n@[priority 100]\ninstance is_cofiltered_or_empty_of_semilattice_inf\n  (α : Type u) [semilattice_inf α] : is_cofiltered_or_empty α :=\n{ cocone_objs := λ X Y, ⟨X ⊓ Y, hom_of_le inf_le_left, hom_of_le inf_le_right, trivial⟩,\n  cocone_maps := λ X Y f g, ⟨X, 𝟙 _, (by ext)⟩, }\n\n@[priority 100]\ninstance is_cofiltered_of_semilattice_inf_nonempty\n  (α : Type u) [semilattice_inf α] [nonempty α] : is_cofiltered α := {}\n\n@[priority 100]\ninstance is_cofiltered_or_empty_of_directed_ge (α : Type u) [preorder α]\n  [is_directed α (≥)] :\n  is_cofiltered_or_empty α :=\n{ cocone_objs := λ X Y, let ⟨Z, hX, hY⟩ := exists_le_le X Y in\n    ⟨Z, hom_of_le hX, hom_of_le hY, trivial⟩,\n  cocone_maps := λ X Y f g, ⟨X, 𝟙 _, by simp⟩ }\n\n@[priority 100]\ninstance is_cofiltered_of_directed_ge_nonempty  (α : Type u) [preorder α] [is_directed α (≥)]\n  [nonempty α] :\n  is_cofiltered α := {}\n\n-- Sanity checks\nexample (α : Type u) [semilattice_inf α] [order_bot α] : is_cofiltered α := by apply_instance\nexample (α : Type u) [semilattice_inf α] [order_top α] : is_cofiltered α := by apply_instance\n\nnamespace is_cofiltered\n\nvariables {C} [is_cofiltered C]\n\n/--\n`min j j'` is an arbitrary choice of object to the left of both `j` and `j'`,\nwhose existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def min (j j' : C) : C :=\n(is_cofiltered_or_empty.cocone_objs j j').some\n\n/--\n`min_to_left j j'` is an arbitrarily choice of morphism from `min j j'` to `j`,\nwhose existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def min_to_left (j j' : C) : min j j' ⟶ j :=\n(is_cofiltered_or_empty.cocone_objs j j').some_spec.some\n\n/--\n`min_to_right j j'` is an arbitrarily choice of morphism from `min j j'` to `j'`,\nwhose existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def min_to_right (j j' : C) : min j j' ⟶ j' :=\n(is_cofiltered_or_empty.cocone_objs j j').some_spec.some_spec.some\n\n/--\n`eq f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of object\nwhich admits a morphism `eq_hom f f' : eq f f' ⟶ j` such that\n`eq_condition : eq_hom f f' ≫ f = eq_hom f f' ≫ f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eq {j j' : C} (f f' : j ⟶ j') : C :=\n(is_cofiltered_or_empty.cocone_maps f f').some\n\n/--\n`eq_hom f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of morphism\n`eq_hom f f' : eq f f' ⟶ j` such that\n`eq_condition : eq_hom f f' ≫ f = eq_hom f f' ≫ f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eq_hom {j j' : C} (f f' : j ⟶ j') : eq f f' ⟶ j :=\n(is_cofiltered_or_empty.cocone_maps f f').some_spec.some\n\n/--\n`eq_condition f f'`, for morphisms `f f' : j ⟶ j'`, is the proof that\n`eq_hom f f' ≫ f = eq_hom f f' ≫ f'`.\n-/\n@[simp, reassoc]\nlemma eq_condition {j j' : C} (f f' : j ⟶ j') : eq_hom f f' ≫ f = eq_hom f f' ≫ f' :=\n(is_cofiltered_or_empty.cocone_maps f f').some_spec.some_spec\n\nopen category_theory.limits\n\n/--\nAny finite collection of objects in a cofiltered category has an object \"to the left\".\n-/\nlemma inf_objs_exists (O : finset C) : ∃ (S : C), ∀ {X}, X ∈ O → _root_.nonempty (S ⟶ X) :=\nbegin\n  classical,\n  apply finset.induction_on O,\n  { exact ⟨is_cofiltered.nonempty.some, (by rintros - ⟨⟩)⟩, },\n  { rintros X O' nm ⟨S', w'⟩,\n    use min X S',\n    rintros Y mY,\n    obtain rfl|h := eq_or_ne Y X,\n    { exact ⟨min_to_left _ _⟩, },\n    { exact ⟨min_to_right _ _ ≫ (w' (finset.mem_of_mem_insert_of_ne mY h)).some⟩, }, }\nend\n\nvariables (O : finset C) (H : finset (Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y))\n\n/--\nGiven any `finset` of objects `{X, ...}` and\nindexed collection of `finset`s of morphisms `{f, ...}` in `C`,\nthere exists an object `S`, with a morphism `T X : S ⟶ X` from each `X`,\nsuch that the triangles commute: `T X ≫ f = T Y`, for `f : X ⟶ Y` in the `finset`.\n-/\nlemma inf_exists :\n  ∃ (S : C) (T : Π {X : C}, X ∈ O → (S ⟶ X)), ∀ {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y},\n    (⟨X, Y, mX, mY, f⟩ : (Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y)) ∈ H → T mX ≫ f = T mY :=\nbegin\n  classical,\n  apply finset.induction_on H,\n  { obtain ⟨S, f⟩ := inf_objs_exists O,\n    refine ⟨S, λ X mX, (f mX).some, _⟩,\n    rintros - - - - - ⟨⟩, },\n  { rintros ⟨X, Y, mX, mY, f⟩ H' nmf ⟨S', T', w'⟩,\n    refine ⟨eq (T' mX ≫ f) (T' mY), λ Z mZ, eq_hom (T' mX ≫ f) (T' mY) ≫ T' mZ, _⟩,\n    intros X' Y' mX' mY' f' mf',\n    rw [category.assoc],\n    by_cases h : X = X' ∧ Y = Y',\n    { rcases h with ⟨rfl, rfl⟩,\n      by_cases hf : f = f',\n      { subst hf,\n        apply eq_condition, },\n      { rw @w' _ _ mX mY f' (by simpa [hf ∘ eq.symm] using mf') }, },\n    { rw @w' _ _ mX' mY' f' _,\n      apply finset.mem_of_mem_insert_of_ne mf',\n      contrapose! h,\n      obtain ⟨rfl, h⟩ := h,\n      rw [heq_iff_eq, psigma.mk.inj_iff] at h,\n      exact ⟨rfl, h.1.symm⟩ }, },\nend\n\n/--\nAn arbitrary choice of object \"to the left\"\nof a finite collection of objects `O` and morphisms `H`,\nmaking all the triangles commute.\n-/\nnoncomputable\ndef inf : C :=\n(inf_exists O H).some\n\n/--\nThe morphisms from `inf O H`.\n-/\nnoncomputable\ndef inf_to {X : C} (m : X ∈ O) :\n  inf O H ⟶ X :=\n(inf_exists O H).some_spec.some m\n\n/--\nThe triangles consisting of a morphism in `H` and the maps from `inf O H` commute.\n-/\nlemma inf_to_commutes\n  {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y}\n  (mf : (⟨X, Y, mX, mY, f⟩ : Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y) ∈ H) :\n  inf_to O H mX ≫ f = inf_to O H mY :=\n(inf_exists O H).some_spec.some_spec mX mY mf\n\nvariables {J : Type v} [small_category J] [fin_category J]\n\n/--\nIf we have `is_cofiltered C`, then for any functor `F : J ⥤ C` with `fin_category J`,\nthere exists a cone over `F`.\n-/\nlemma cone_nonempty (F : J ⥤ C) : _root_.nonempty (cone F) :=\nbegin\n  classical,\n  let O := (finset.univ.image F.obj),\n  let H : finset (Σ' (X Y : C) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y) :=\n    finset.univ.bUnion (λ X : J, finset.univ.bUnion (λ Y : J, finset.univ.image (λ f : X ⟶ Y,\n      ⟨F.obj X, F.obj Y, by simp, by simp, F.map f⟩))),\n  obtain ⟨Z, f, w⟩ := inf_exists O H,\n  refine ⟨⟨Z, ⟨λ X, f (by simp), _⟩⟩⟩,\n  intros j j' g,\n  dsimp,\n  simp only [category.id_comp],\n  symmetry,\n  apply w,\n  simp only [finset.mem_univ, finset.mem_bUnion, exists_and_distrib_left,\n    exists_prop_of_true, finset.mem_image],\n  exact ⟨j, rfl, j', g, (by simp)⟩,\nend\n\n/--\nAn arbitrary choice of cone over `F : J ⥤ C`, for `fin_category J` and `is_cofiltered C`.\n-/\nnoncomputable def cone (F : J ⥤ C) : cone F :=\n(cone_nonempty F).some\n\nvariables {D : Type u₁} [category.{v₁} D]\n\n/--\nIf `C` is cofiltered, and we have a functor `L : C ⥤ D` with a right adjoint,\nthen `D` is cofiltered.\n-/\nlemma of_left_adjoint {L : C ⥤ D} {R : D ⥤ C} (h : L ⊣ R) : is_cofiltered D :=\n{ cocone_objs := λ X Y,\n    ⟨L.obj (min (R.obj X) (R.obj Y)),\n      (h.hom_equiv _ X).symm (min_to_left _ _), (h.hom_equiv _ Y).symm (min_to_right _ _), ⟨⟩⟩,\n  cocone_maps := λ X Y f g,\n    ⟨L.obj (eq (R.map f) (R.map g)), (h.hom_equiv _ _).symm (eq_hom _ _),\n     by rw [← h.hom_equiv_naturality_right_symm, ← h.hom_equiv_naturality_right_symm,\n       eq_condition]⟩,\n  nonempty := is_cofiltered.nonempty.map L.obj }\n\n/-- If `C` is cofiltered, and we have a left adjoint functor `L : C ⥤ D`, then `D` is cofiltered. -/\n\n\n/-- Being cofiltered is preserved by equivalence of categories. -/\nlemma of_equivalence (h : C ≌ D) : is_cofiltered D :=\nof_left_adjoint h.to_adjunction\n\nend is_cofiltered\n\nsection opposite\nopen opposite\n\ninstance is_cofiltered_op_of_is_filtered [is_filtered C] : is_cofiltered Cᵒᵖ :=\n{ cocone_objs := λ X Y, ⟨op (is_filtered.max X.unop Y.unop),\n    (is_filtered.left_to_max _ _).op, (is_filtered.right_to_max _ _).op, trivial⟩,\n  cocone_maps := λ X Y f g, ⟨op (is_filtered.coeq f.unop g.unop),\n    (is_filtered.coeq_hom _ _).op, begin\n      rw [(show f = f.unop.op, by simp), (show g = g.unop.op, by simp),\n        ← op_comp, ← op_comp],\n      congr' 1,\n      exact is_filtered.coeq_condition f.unop g.unop,\n    end⟩,\n  nonempty := ⟨op is_filtered.nonempty.some⟩ }\n\ninstance is_filtered_op_of_is_cofiltered [is_cofiltered C] : is_filtered Cᵒᵖ :=\n{ cocone_objs := λ X Y, ⟨op (is_cofiltered.min X.unop Y.unop),\n    (is_cofiltered.min_to_left X.unop Y.unop).op,\n    (is_cofiltered.min_to_right X.unop Y.unop).op, trivial⟩,\n  cocone_maps := λ X Y f g, ⟨op (is_cofiltered.eq f.unop g.unop),\n    (is_cofiltered.eq_hom f.unop g.unop).op, begin\n      rw [(show f = f.unop.op, by simp), (show g = g.unop.op, by simp),\n        ← op_comp, ← op_comp],\n      congr' 1,\n      exact is_cofiltered.eq_condition f.unop g.unop,\n    end⟩,\n  nonempty := ⟨op is_cofiltered.nonempty.some⟩ }\n\nend opposite\n\nsection ulift\n\ninstance [is_filtered C] : is_filtered (ulift.{u₂} C) :=\nis_filtered.of_equivalence ulift.equivalence\n\ninstance [is_cofiltered C] : is_cofiltered (ulift.{u₂} C) :=\nis_cofiltered.of_equivalence ulift.equivalence\n\ninstance [is_filtered C] : is_filtered (ulift_hom C) :=\nis_filtered.of_equivalence ulift_hom.equiv\n\ninstance [is_cofiltered C] : is_cofiltered (ulift_hom C) :=\nis_cofiltered.of_equivalence ulift_hom.equiv\n\ninstance [is_filtered C] : is_filtered (as_small C) :=\nis_filtered.of_equivalence as_small.equiv\n\ninstance [is_cofiltered C] : is_cofiltered (as_small C) :=\nis_cofiltered.of_equivalence as_small.equiv\n\nend ulift\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/filtered.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4752083706569571}}
{"text": "import data.real.basic\nimport tactic\nimport real_definitions\nimport utils\n\n-- #print linarith.make_comp_with_zero\n\nopen lean.parser tactic interactive\nopen interactive (loc.ns)\nopen interactive.types\nopen expr\n\n\n-- useful lemmas:\n-- ge_iff_le\n-- gt_iff_lt\n-- lt_of_le_of_ne\n-- le_of_lt\n-- div_pos\n-- mul_pos\n-- inv_pos\n\nopen tactic.interactive\n\n-------------------------------------------\n-------------------------------------------\n-- Make 'a < b' from 'a ≠ b' and 'a ≤ b' --\n-------------------------------------------\n-------------------------------------------\n-- This is achieved by the following sequence of tactics:\n-- * make_ineq  take \"a ≤ b\" and \"a' ≠ b'\" and try to make \"a < b\"\n-- * extract_gt extract the list of inequalities \"a ≤ b\" from a list of expressions\n-- * extract_non_eq does the same for \"a ≠ b\"\n-- * list_prod make the product list of two lists\n-- * get_pos_from_pos_eq_from_list is build on the previous ones:\n-- it takes a list of expressions,\n-- extract inequalities and non-equalities,\n-- take all pairs and try to make \"a < b\" by applying make_ineq\n-- * get_pos_from_pos_eq is an interactive tactic that applies this to the local context\n\n\n----------------\n---- Lemmas ----\n----------------\nnamespace compute_lemmas\nlemma ineq_from_non_eq {α: Type} [linear_order α] (a b : α) : ¬ a = b ↔ (a < b ∨ b < a) :=\nbegin\n    todo\nend\n\n/- Unused? -/\nlemma definition.useful_abs {α: Type} [decidable_linear_ordered_add_comm_group α] (a: α) :\nabs a = if a ≥ 0 then a else -a :=\nbegin\n    todo\nend\n\nend compute_lemmas\n\nopen compute_lemmas\n\n--------------------------------------------------\n--------------------------------------------------\n-- Detecting abs, max, strict inequalities etc. --\n--------------------------------------------------\n--------------------------------------------------\nnamespace tactic.interactive\n/- Just a front-end to trace, easy to desactivate. -/\nmeta def compute_trace  {α : Type} [has_to_tactic_format α] (a : α) : tactic unit := \ndo trace\"DEBUG:\", trace a\n\n/- Check if some expression contains some constant name inside app. -/\nmeta def contain_cst (cst_name: name) : expr → bool\n| (const a a_1) := (a = cst_name)\n| (app a a_1) := (contain_cst a) ∨ (contain_cst a_1)\n| _ := ff\n\n/- Check if some expression contains some constant name of a list. -/\nmeta def contain_csts : (list name) × expr → bool\n| ([], _) := ff\n| ((n :: tail), e) := if (contain_cst n e) then tt else (contain_csts (tail, e))\n\n/- Check if expr contains abs inside app. -/\nmeta def contain_abs (e: expr) : tactic bool :=\nreturn (contain_cst `abs e)\n\n/- List of constants that will launch `develop_ite`in `compute_n`. -/\ndef cst_for_ite : list name := [`abs, `max, `min] -- TODO: move in compute.cfg\n\n/- Check if expr contains abs inside app. -/\nmeta def contain_ite (e: expr) : tactic bool :=\nreturn (contain_csts (cst_for_ite, e))\n\n/- Detect abs in target in app. -/\nmeta def target_abs : tactic bool :=\ndo  target ← tactic.target, e ← infer_type target,\n    b ← contain_abs target,\n    -- tactic.trace b, \n    return b\n\n/- Detect abs in target in app. -/\nmeta def target_ite : tactic bool :=\ndo  target ← tactic.target, e ← infer_type target,\n    b ← contain_ite target,\n    -- tactic.trace b, \n    return b\n\n-- example : 0 < 1 + max 2 3 := begin target_ite, sorry end  -- tt\n-- example : 0 < 1 + 2/3 := begin target_ite, sorry end  -- ff\n\n/- Check if target is a strict inequality. -/\nmeta def target_lt_or_gt : tactic bool :=\ndo  target ← tactic.target,\n    match target with\n    | `(%%a < %%b) := -- do trace \"1\", \n        return tt\n    | `(%%a > %%b) := -- do trace \"2\", \n        return tt\n    | `(¬(%%a = %%b)) := -- do trace \"3\", \n        return tt\n    | _ := -- do trace \"4\", \n        return ff\n    end\n\n---------------------------\n---------------------------\n-- Chaining tactic string -\n---------------------------\n---------------------------\n-- set_option trace.linarith true\n-- set_option trace.eqn_compiler.elim_match true\n\n/- Concatenate a list of strings using commas as separators-/\ndef string.concatenate : (list string) → string\n-- (l: list string) : string :=\n-- list.foldl (λ (s: string) (t: string), s ++ \", \" ++ t) \"\" l\n| []  := \"\"\n| [s] := s\n| (\"\" :: tail) := string.concatenate tail\n| (head :: tail) := do let tail_string := string.concatenate tail,\n                    match tail_string with\n                    | \"\" := head\n                    | _  := head ++ \", \" ++ tail_string\n                    end\n\n\n/- Try some (tactic string) and in case of success return its string.\nAlways succeed. -/\nmeta def try_and_return_code (my_tactic: tactic string) : tactic string :=\ndo {s ← my_tactic, return s} <|> return \"\"\n\nmeta def norm_num_and_return_code : tactic string := \ndo `[norm_num at *, return \"norm_num at *\"] <|> return \"\"\n\n/- Iterate some (tactic string) and return the concatenated returned strings.\nStops as soon as the tactic makes no progress,\ni.e. returns the empty string or num_goals = 0.\nFail if some tactic fails. -/\nmeta def iterate_and_return_code : nat → tactic string → tactic string\n| 0       my_tactic := return \"\"\n| (n + 1) my_tactic := do -- trace \"(iterating tactic...)\",\n    first_code ← my_tactic, l ← num_goals,\n    match first_code, l with\n    | \"\", _  := return \"\"\n    | s, 0   := return s\n    | _ , _  := do\n        remaining_code ← iterate_and_return_code n my_tactic,\n        return $ string.concatenate [first_code, remaining_code]\n    end\n\n/- Apply successively tactics in a given list,\nbut stop as soon as there is no more goal,\nand return concatenation of returned code.\nFail if some tactic fails. -/\nmeta def and_then_and_return_code : list (tactic string) → tactic string \n| []                  := return \"\"\n| (first_tac :: tail) :=  do\n    first_code ← first_tac, l ← num_goals,\n    match first_code, l with\n    | s, 0   := return s\n    | _ , _  := do\n        remaining_code ← and_then_and_return_code tail,\n        return $ string.concatenate [first_code, remaining_code]\n    end\n\nmeta def or_else_and_return_code : list (tactic string) → tactic string\n| [] := fail \"\"\n| (head :: tail) := do head <|> or_else_and_return_code tail\n\n/- Try some tactic to solve all current goals. If the tactic fails to solve some goal, then \nstop and fail. Otherwiser, return the list of successfull codes. -/\nmeta def solve_all_and_return_code (tac: tactic string) : tactic (string) :=\n do strings ← tactic.all_goals tac, return (string.concatenate strings)\n\nmeta def try_tactic_string (my_tac: tactic string) : tactic string :=\ndo {my_tac <|> return \"\"}\n\nmeta def skip_tactic_string : tactic string :=\ndo {skip, return \"\"}\n\n/- Apply some tactic string and trace the returned string as effective code with id-/\nmeta def apply_and_trace_code (id: string) (my_tactic: tactic string) : tactic unit:=\ndo  effective_code ← my_tactic, \n    tactic.trace $ \"EFFECTIVE CODE LEAN n°\" ++ id ++ \":\" ++ effective_code,\n    tactic.trace $ \"Try this: \"++ effective_code\n\n\n-------------------\n-------------------\n-- Pre-processing -\n-------------------\n-------------------\n/- Series of tactic when target is a strict inequality, or contains abs / min / max. -/\n\nlemma inv_pos_mpr {α : Type} [linear_ordered_field α] (a:α) :\n0 < a → 0 < a⁻¹ := inv_pos.mpr\n\n-- TODO: when target abs add  apply abs_pos_of_ne_zero, apply sub_ne_zero_of_ne, \n\n/- Unfold some definitions using if_then_else, then get rid of if_then_else by case reasoning.\nUnfolded definitions includes abs, max, min. (Fails if there is nothing to unfold.) -/\nmeta def develop_ite : tactic string :=\n    -- do ite ← target_ite, if ite then\n        do  {`[unfold abs], `[unfold min max], `[split_ifs],\n             compute_trace \"develope ite, #goals = \", compute_trace num_goals,  -- for debugging\n             return \"unfold abs, unfold min max, split_ifs\"}\n       --  else return \"COMPUTE DEBUG: (no if-then-else found)\"\n\n/- The same for all goals: more precisely, keep unfolding and splitting in any goal \nuntil there is nothing to unfold anymore. Always succeeds. -/\nmeta def develop_ite' : tactic string :=\n    -- do ite ← target_ite, if ite then\n        do  {`[repeat {any_goals {unfold abs, unfold min max, split_ifs}}],\n             compute_trace \"develope ite', #goals = \", compute_trace num_goals,  -- for debugging\n             return \"repeat {any_goals {unfold abs, unfold min max, split_ifs}}\"}\n       --  else return \"COMPUTE DEBUG: (no if-then-else found)\"\n\n/- Split non-equalities `a≠b` into `a<b or b<a`, then split cases. -/\nmeta def develop_neq : tactic string :=\n    -- do ineq ← target_lt_or_gt, if ineq then\n        do {`[rw ineq_from_non_eq at *], `[cases_type* or],\n            compute_trace \"develope neq, #goals = \", compute_trace num_goals,  -- for debugging\n            return \"rw ineq_from_non_eq at *, cases_type* or\"}\n        -- else return \"(target is not a strict inequality)\"\n\nmeta def split_tacs : (bool × bool) → list (tactic string)\n        | (tt, tt) := [develop_neq, develop_ite'] -- todo\n        | (tt, ff) := [develop_neq]\n        | (ff, tt) := [develop_ite]\n        | (ff, ff) := []\n\nmeta def mk_tac_str : (name × string) → tactic string\n| (n, s) := do {tactic.applyc ``n, return s}\n\n-------------------\n-------------------\n-- Tactic compute -\n-------------------\n-------------------\n/-- A configuration object for `compute1`. \n develop_ite: set to tt to develop if_then_else definitions, e.g. abs and max.\n -/\nmeta structure compute_config : Type :=\n(nb_iterations : nat := 1)\n(develop_ite : bool := tt) -- unused\n(develop_neq : bool := tt) -- unused\n(ineq_tactics: list (name × string) := [(`mul_pos, \"mul_pos\"),\n                                        (`inv_pos_mpr, \"inv_pos.mpr\"),\n                                        (`mul_ne_zero, \"mul_ne_zero\")])\n\nopen linarith\n/- Non-interactive version of nl_linarith. -/\nmeta def nl_linarith (cfg : linarith_config := {}): tactic unit :=\ndo\n{\ntactic.linarith false false []\n  { cfg with preprocessors := some $\n      cfg.preprocessors.get_or_else default_preprocessors ++ [nlinarith_extras] }\n}\n\n\n/- Try assumption, tautology, linarith, nl_linarith. -/\nmeta def compute1 : tactic string :=\ndo compute_trace \"(compute1...)\",\ndo {   do {assumption, return \"assumption\"}\n    <|>\n    -- solve e.g. \"n_0 ≤ n_0 ∨ n_0 ≤ n_1\"\n    -- with norm_num, solves \"n_0 ≤ max n_0 n_1\"\n    do {tactic.tautology, return \"tautology\"}\n    <|>\n    do {tactic.linarith false false [], return \"linarith\"}\n    <|>\n    do {nl_linarith, return \"nl_linarith\"}\n}\n\n/- Repeat n times the tactic compute1, inserting various strategies according to\nwhether\n            -- target is a stric inequality, and \n            -- contains ite expr (`abs`, `max`, and so on).\nAlways start with linarith before splitting.\n-/\nmeta def compute_n  (cfg: compute_config := {}) : tactic string :=\n    do  t_ineq ← target_lt_or_gt, t_abs ← target_ite, match (t_ineq, t_abs) with\n        | (ff, ff) := do compute_trace \"Target is NOT a strict inequality and does NOT contain ite\",\n            compute1 -- nothing more to try here (?)\n        | (ff, tt) := do compute_trace \"Target is NOT a strict inequality but contains ite\",\n        -- Essentially unfold def and split if_then_else, then re-try linarith\n            let ite_tacs :=\n                and_then_and_return_code [develop_ite,\n                                          (solve_all_and_return_code compute1)] \n            in or_else_and_return_code [compute1, ite_tacs]\n        | (tt, ff) := do compute_trace \"Target is a strict inequality but does NOT contain ite\",\n        -- Essentially try successively specific tactics on the target and linarith\n            let ineq_tacs_1 := \n                iterate_and_return_code cfg.nb_iterations $ or_else_and_return_code $\n                    (cfg.ineq_tactics.map mk_tac_str) ++ [compute1]\n            -- if this fails then split non_equalities\n            in let ineq_tacs_2 := \n                and_then_and_return_code [develop_neq, (solve_all_and_return_code compute1)]\n            in or_else_and_return_code [compute1, ineq_tacs_1, ineq_tacs_2]\n        | (tt, tt) := do compute_trace \"Target is a strict inequality and contains ite\",\n            let ineq_tacs_1 := \n                iterate_and_return_code cfg.nb_iterations $ or_else_and_return_code $\n                    (cfg.ineq_tactics.map mk_tac_str) ++ [compute1]\n            -- if this fails then split non_equalities\n            in let ineq_tacs_2 := \n                and_then_and_return_code [try_and_return_code develop_neq, develop_ite', (solve_all_and_return_code compute1)]\n            in or_else_and_return_code [compute1, ineq_tacs_1, ineq_tacs_2]\n        end\n\n/- Apply norm_num at * if possible, then the compute_n tactic n times,\nand in case of success trace the effective code with id. -/\nmeta def compute_and_trace_code (id: string)  (cfg: compute_config := {}):\ntactic unit := let tacs := [norm_num_and_return_code, (tactic.interactive.compute_n cfg)] in \ndo apply_and_trace_code id (and_then_and_return_code tacs)\n\n\nend tactic.interactive\n\n\n", "meta": {"author": "dEAduction", "repo": "dEAduction-lean", "sha": "4fe1d642078fc94f9081ccbed08e047e86a741fd", "save_path": "github-repos/lean/dEAduction-dEAduction-lean", "path": "github-repos/lean/dEAduction-dEAduction-lean/dEAduction-lean-4fe1d642078fc94f9081ccbed08e047e86a741fd/src/lean_src_deaduction_synchro/compute3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.4752083676130358}}
{"text": "/-\nCopyright (c) 2020 Zhouhang Zhou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Zhouhang Zhou\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.group.pi\nimport Mathlib.group_theory.group_action.default\nimport Mathlib.data.support\nimport Mathlib.data.finset.lattice\nimport Mathlib.PostPort\n\nuniverses u_1 u_3 u_2 u_4 u_5 \n\nnamespace Mathlib\n\n/-!\n# Indicator function\n\n`indicator (s : set α) (f : α → β) (a : α)` is `f a` if `a ∈ s` and is `0` otherwise.\n\n## Implementation note\n\nIn mathematics, an indicator function or a characteristic function is a function used to indicate\nmembership of an element in a set `s`, having the value `1` for all elements of `s` and the value `0`\notherwise. But since it is usually used to restrict a function to a certain set `s`, we let the\nindicator function take the value `f x` for some function `f`, instead of `1`. If the usual indicator\nfunction is needed, just set `f` to be the constant function `λx, 1`.\n\n## Tags\nindicator, characteristic\n-/\n\nnamespace set\n\n\n/-- `indicator s f a` is `f a` if `a ∈ s`, `0` otherwise.  -/\ndef indicator {α : Type u_1} {β : Type u_3} [HasZero β] (s : set α) (f : α → β) : α → β :=\n  fun (x : α) => ite (x ∈ s) (f x) 0\n\n@[simp] theorem piecewise_eq_indicator {α : Type u_1} {β : Type u_3} [HasZero β] {f : α → β} {s : set α} : piecewise s f 0 = indicator s f :=\n  rfl\n\ntheorem indicator_apply {α : Type u_1} {β : Type u_3} [HasZero β] (s : set α) (f : α → β) (a : α) : indicator s f a = ite (a ∈ s) (f a) 0 :=\n  rfl\n\n@[simp] theorem indicator_of_mem {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {a : α} (h : a ∈ s) (f : α → β) : indicator s f a = f a :=\n  if_pos h\n\n@[simp] theorem indicator_of_not_mem {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {a : α} (h : ¬a ∈ s) (f : α → β) : indicator s f a = 0 :=\n  if_neg h\n\ntheorem indicator_eq_zero_or_self {α : Type u_1} {β : Type u_3} [HasZero β] (s : set α) (f : α → β) (a : α) : indicator s f a = 0 ∨ indicator s f a = f a :=\n  dite (a ∈ s) (fun (h : a ∈ s) => Or.inr (indicator_of_mem h f)) fun (h : ¬a ∈ s) => Or.inl (indicator_of_not_mem h f)\n\n/-- If an indicator function is nonzero at a point, that\npoint is in the set. -/\ntheorem mem_of_indicator_ne_zero {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} {a : α} (h : indicator s f a ≠ 0) : a ∈ s :=\n  iff.mp not_imp_comm (fun (hn : ¬a ∈ s) => indicator_of_not_mem hn f) h\n\ntheorem eq_on_indicator {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} : eq_on (indicator s f) f s :=\n  fun (x : α) (hx : x ∈ s) => indicator_of_mem hx f\n\ntheorem support_indicator {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} : function.support (indicator s f) ⊆ s :=\n  fun (x : α) (hx : x ∈ function.support (indicator s f)) =>\n    not.imp_symm (fun (h : ¬x ∈ s) => indicator_of_not_mem h f) hx\n\n@[simp] theorem indicator_apply_eq_self {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} {a : α} : indicator s f a = f a ↔ ¬a ∈ s → f a = 0 :=\n  iff.trans ite_eq_left_iff\n    (eq.mpr (id (Eq._oldrec (Eq.refl (¬a ∈ s → 0 = f a ↔ ¬a ∈ s → f a = 0)) (propext eq_comm)))\n      (iff.refl (¬a ∈ s → 0 = f a)))\n\n@[simp] theorem indicator_eq_self {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} : indicator s f = f ↔ function.support f ⊆ s := sorry\n\n@[simp] theorem indicator_support {α : Type u_1} {β : Type u_3} [HasZero β] {f : α → β} : indicator (function.support f) f = f :=\n  iff.mpr indicator_eq_self (subset.refl (function.support f))\n\n@[simp] theorem indicator_apply_eq_zero {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} {a : α} : indicator s f a = 0 ↔ a ∈ s → f a = 0 :=\n  ite_eq_right_iff\n\n@[simp] theorem indicator_eq_zero {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} : (indicator s f = fun (x : α) => 0) ↔ disjoint (function.support f) s := sorry\n\n@[simp] theorem indicator_eq_zero' {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} : indicator s f = 0 ↔ disjoint (function.support f) s :=\n  indicator_eq_zero\n\n@[simp] theorem indicator_range_comp {α : Type u_1} {β : Type u_3} [HasZero β] {ι : Sort u_2} (f : ι → α) (g : α → β) : indicator (range f) g ∘ f = g ∘ f :=\n  piecewise_range_comp f (fun (x : α) => g x) fun (x : α) => 0\n\ntheorem indicator_congr {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} {g : α → β} (h : ∀ (a : α), a ∈ s → f a = g a) : indicator s f = indicator s g := sorry\n\n@[simp] theorem indicator_univ {α : Type u_1} {β : Type u_3} [HasZero β] (f : α → β) : indicator univ f = f :=\n  iff.mpr indicator_eq_self (subset_univ (function.support f))\n\n@[simp] theorem indicator_empty {α : Type u_1} {β : Type u_3} [HasZero β] (f : α → β) : indicator ∅ f = fun (a : α) => 0 :=\n  iff.mpr indicator_eq_zero (disjoint_empty (function.support f))\n\n@[simp] theorem indicator_zero {α : Type u_1} (β : Type u_3) [HasZero β] (s : set α) : (indicator s fun (x : α) => 0) = fun (x : α) => 0 := sorry\n\n@[simp] theorem indicator_zero' {α : Type u_1} (β : Type u_3) [HasZero β] {s : set α} : indicator s 0 = 0 :=\n  indicator_zero β s\n\ntheorem indicator_indicator {α : Type u_1} {β : Type u_3} [HasZero β] (s : set α) (t : set α) (f : α → β) : indicator s (indicator t f) = indicator (s ∩ t) f := sorry\n\ntheorem comp_indicator {α : Type u_1} {β : Type u_3} {γ : Type u_4} [HasZero β] (h : β → γ) (f : α → β) {s : set α} {x : α} : h (indicator s f x) = piecewise s (h ∘ f) (function.const α (h 0)) x :=\n  comp_piecewise s h\n\ntheorem indicator_comp_right {α : Type u_1} {β : Type u_3} {γ : Type u_4} [HasZero β] {s : set α} (f : γ → α) {g : α → β} {x : γ} : indicator (f ⁻¹' s) (g ∘ f) x = indicator s g (f x) := sorry\n\ntheorem indicator_comp_of_zero {α : Type u_1} {β : Type u_3} {γ : Type u_4} [HasZero β] {s : set α} {f : α → β} [HasZero γ] {g : β → γ} (hg : g 0 = 0) : indicator s (g ∘ f) = g ∘ indicator s f := sorry\n\ntheorem indicator_preimage {α : Type u_1} {β : Type u_3} [HasZero β] (s : set α) (f : α → β) (B : set β) : indicator s f ⁻¹' B = s ∩ f ⁻¹' B ∪ sᶜ ∩ (fun (a : α) => 0) ⁻¹' B :=\n  piecewise_preimage s f 0 B\n\ntheorem indicator_preimage_of_not_mem {α : Type u_1} {β : Type u_3} [HasZero β] (s : set α) (f : α → β) {t : set β} (ht : ¬0 ∈ t) : indicator s f ⁻¹' t = s ∩ f ⁻¹' t := sorry\n\ntheorem mem_range_indicator {α : Type u_1} {β : Type u_3} [HasZero β] {r : β} {s : set α} {f : α → β} : r ∈ range (indicator s f) ↔ r = 0 ∧ s ≠ univ ∨ r ∈ f '' s := sorry\n\ntheorem indicator_rel_indicator {α : Type u_1} {β : Type u_3} [HasZero β] {s : set α} {f : α → β} {g : α → β} {a : α} {r : β → β → Prop} (h0 : r 0 0) (ha : a ∈ s → r (f a) (g a)) : r (indicator s f a) (indicator s g a) := sorry\n\n/-- Consider a sum of `g i (f i)` over a `finset`.  Suppose `g` is a\nfunction such as multiplication, which maps a second argument of 0 to\n0.  (A typical use case would be a weighted sum of `f i * h i` or `f i\n• h i`, where `f` gives the weights that are multiplied by some other\nfunction `h`.)  Then if `f` is replaced by the corresponding indicator\nfunction, the `finset` may be replaced by a possibly larger `finset`\nwithout changing the value of the sum. -/\ntheorem sum_indicator_subset_of_eq_zero {α : Type u_1} {β : Type u_3} [HasZero β] {γ : Type u_2} [add_comm_monoid γ] (f : α → β) (g : α → β → γ) {s₁ : finset α} {s₂ : finset α} (h : s₁ ⊆ s₂) (hg : ∀ (a : α), g a 0 = 0) : (finset.sum s₁ fun (i : α) => g i (f i)) = finset.sum s₂ fun (i : α) => g i (indicator (↑s₁) f i) := sorry\n\n/-- Summing an indicator function over a possibly larger `finset` is\nthe same as summing the original function over the original\n`finset`. -/\ntheorem sum_indicator_subset {α : Type u_1} {γ : Type u_2} [add_comm_monoid γ] (f : α → γ) {s₁ : finset α} {s₂ : finset α} (h : s₁ ⊆ s₂) : (finset.sum s₁ fun (i : α) => f i) = finset.sum s₂ fun (i : α) => indicator (↑s₁) f i :=\n  sum_indicator_subset_of_eq_zero (fun (i : α) => f i) (fun (a : α) (b : γ) => b) h fun (_x : α) => rfl\n\ntheorem indicator_union_of_not_mem_inter {α : Type u_1} {β : Type u_3} [add_monoid β] {s : set α} {t : set α} {a : α} (h : ¬a ∈ s ∩ t) (f : α → β) : indicator (s ∪ t) f a = indicator s f a + indicator t f a := sorry\n\ntheorem indicator_union_of_disjoint {α : Type u_1} {β : Type u_3} [add_monoid β] {s : set α} {t : set α} (h : disjoint s t) (f : α → β) : indicator (s ∪ t) f = fun (a : α) => indicator s f a + indicator t f a := sorry\n\ntheorem indicator_add {α : Type u_1} {β : Type u_3} [add_monoid β] (s : set α) (f : α → β) (g : α → β) : (indicator s fun (a : α) => f a + g a) = fun (a : α) => indicator s f a + indicator s g a := sorry\n\n@[simp] theorem indicator_compl_add_self_apply {α : Type u_1} {β : Type u_3} [add_monoid β] (s : set α) (f : α → β) (a : α) : indicator (sᶜ) f a + indicator s f a = f a := sorry\n\n@[simp] theorem indicator_compl_add_self {α : Type u_1} {β : Type u_3} [add_monoid β] (s : set α) (f : α → β) : indicator (sᶜ) f + indicator s f = f :=\n  funext (indicator_compl_add_self_apply s f)\n\n@[simp] theorem indicator_self_add_compl_apply {α : Type u_1} {β : Type u_3} [add_monoid β] (s : set α) (f : α → β) (a : α) : indicator s f a + indicator (sᶜ) f a = f a := sorry\n\n@[simp] theorem indicator_self_add_compl {α : Type u_1} {β : Type u_3} [add_monoid β] (s : set α) (f : α → β) : indicator s f + indicator (sᶜ) f = f :=\n  funext (indicator_self_add_compl_apply s f)\n\nprotected instance is_add_monoid_hom.indicator {α : Type u_1} (β : Type u_3) [add_monoid β] (s : set α) : is_add_monoid_hom fun (f : α → β) => indicator s f :=\n  is_add_monoid_hom.mk (indicator_zero β s)\n\ntheorem indicator_smul {α : Type u_1} {β : Type u_3} [add_monoid β] {𝕜 : Type u_5} [monoid 𝕜] [distrib_mul_action 𝕜 β] (s : set α) (r : 𝕜) (f : α → β) : (indicator s fun (x : α) => r • f x) = fun (x : α) => r • indicator s f x := sorry\n\ntheorem indicator_add_eq_left {α : Type u_1} {β : Type u_3} [add_monoid β] {f : α → β} {g : α → β} (h : univ ⊆ f ⁻¹' singleton 0 ∪ g ⁻¹' singleton 0) : indicator (f ⁻¹' singleton 0ᶜ) (f + g) = f := sorry\n\ntheorem indicator_add_eq_right {α : Type u_1} {β : Type u_3} [add_monoid β] {f : α → β} {g : α → β} (h : univ ⊆ f ⁻¹' singleton 0 ∪ g ⁻¹' singleton 0) : indicator (g ⁻¹' singleton 0ᶜ) (f + g) = g := sorry\n\nprotected instance is_add_group_hom.indicator {α : Type u_1} (β : Type u_3) [add_group β] (s : set α) : is_add_group_hom fun (f : α → β) => indicator s f :=\n  is_add_group_hom.mk\n\ntheorem indicator_neg {α : Type u_1} {β : Type u_3} [add_group β] (s : set α) (f : α → β) : (indicator s fun (a : α) => -f a) = fun (a : α) => -indicator s f a :=\n  (fun (this : indicator s (-f) = -indicator s f) => this) (is_add_group_hom.map_neg (indicator s) f)\n\ntheorem indicator_sub {α : Type u_1} {β : Type u_3} [add_group β] (s : set α) (f : α → β) (g : α → β) : (indicator s fun (a : α) => f a - g a) = fun (a : α) => indicator s f a - indicator s g a :=\n  (fun (this : indicator s (f - g) = indicator s f - indicator s g) => this) (is_add_group_hom.map_sub (indicator s) f g)\n\ntheorem indicator_compl {α : Type u_1} {β : Type u_3} [add_group β] (s : set α) (f : α → β) : indicator (sᶜ) f = f - indicator s f :=\n  eq_sub_of_add_eq (indicator_compl_add_self s f)\n\ntheorem indicator_finset_sum {α : Type u_1} {β : Type u_2} [add_comm_monoid β] {ι : Type u_3} (I : finset ι) (s : set α) (f : ι → α → β) : indicator s (finset.sum I fun (i : ι) => f i) = finset.sum I fun (i : ι) => indicator s (f i) := sorry\n\ntheorem indicator_finset_bUnion {α : Type u_1} {β : Type u_2} [add_comm_monoid β] {ι : Type u_3} (I : finset ι) (s : ι → set α) {f : α → β} : (∀ (i : ι), i ∈ I → ∀ (j : ι), j ∈ I → i ≠ j → s i ∩ s j = ∅) →\n  indicator (Union fun (i : ι) => Union fun (H : i ∈ I) => s i) f =\n    fun (a : α) => finset.sum I fun (i : ι) => indicator (s i) f a := sorry\n\ntheorem indicator_mul {α : Type u_1} {β : Type u_3} [mul_zero_class β] (s : set α) (f : α → β) (g : α → β) : (indicator s fun (a : α) => f a * g a) = fun (a : α) => indicator s f a * indicator s g a := sorry\n\ntheorem indicator_mul_left {α : Type u_1} {β : Type u_3} [mul_zero_class β] {a : α} (s : set α) (f : α → β) (g : α → β) : indicator s (fun (a : α) => f a * g a) a = indicator s f a * g a := sorry\n\ntheorem indicator_mul_right {α : Type u_1} {β : Type u_3} [mul_zero_class β] {a : α} (s : set α) (f : α → β) (g : α → β) : indicator s (fun (a : α) => f a * g a) a = f a * indicator s g a := sorry\n\ntheorem indicator_prod_one {α : Type u_1} {α' : Type u_2} {β : Type u_3} [monoid_with_zero β] {s : set α} {t : set α'} {x : α} {y : α'} : indicator (set.prod s t) 1 (x, y) = indicator s 1 x * indicator t 1 y := sorry\n\ntheorem indicator_nonneg' {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {f : α → β} {a : α} (h : a ∈ s → 0 ≤ f a) : 0 ≤ indicator s f a := sorry\n\ntheorem indicator_nonneg {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {f : α → β} (h : ∀ (a : α), a ∈ s → 0 ≤ f a) (a : α) : 0 ≤ indicator s f a :=\n  indicator_nonneg' (h a)\n\ntheorem indicator_nonpos' {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {f : α → β} {a : α} (h : a ∈ s → f a ≤ 0) : indicator s f a ≤ 0 := sorry\n\ntheorem indicator_nonpos {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {f : α → β} (h : ∀ (a : α), a ∈ s → f a ≤ 0) (a : α) : indicator s f a ≤ 0 :=\n  indicator_nonpos' (h a)\n\ntheorem indicator_le' {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {f : α → β} {g : α → β} (hfg : ∀ (a : α), a ∈ s → f a ≤ g a) (hg : ∀ (a : α), ¬a ∈ s → 0 ≤ g a) : indicator s f ≤ g := sorry\n\ntheorem indicator_le_indicator {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {f : α → β} {g : α → β} {a : α} (h : f a ≤ g a) : indicator s f a ≤ indicator s g a :=\n  indicator_rel_indicator (le_refl 0) fun (_x : a ∈ s) => h\n\ntheorem indicator_le_indicator_of_subset {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {t : set α} {f : α → β} (h : s ⊆ t) (hf : ∀ (a : α), 0 ≤ f a) (a : α) : indicator s f a ≤ indicator t f a := sorry\n\ntheorem indicator_le_self' {α : Type u_1} {β : Type u_3} [HasZero β] [preorder β] {s : set α} {f : α → β} (hf : ∀ (x : α), ¬x ∈ s → 0 ≤ f x) : indicator s f ≤ f :=\n  indicator_le' (fun (_x : α) (_x_1 : _x ∈ s) => le_refl (f _x)) hf\n\ntheorem indicator_le_self {α : Type u_1} {β : Type u_2} [canonically_ordered_add_monoid β] (s : set α) (f : α → β) : indicator s f ≤ f :=\n  indicator_le_self' fun (_x : α) (_x_1 : ¬_x ∈ s) => zero_le (f _x)\n\ntheorem indicator_le {α : Type u_1} {β : Type u_2} [canonically_ordered_add_monoid β] {s : set α} {f : α → β} {g : α → β} (hfg : ∀ (a : α), a ∈ s → f a ≤ g a) : indicator s f ≤ g :=\n  indicator_le' hfg fun (_x : α) (_x_1 : ¬_x ∈ s) => zero_le (g _x)\n\ntheorem indicator_Union_apply {α : Type u_1} {ι : Sort u_2} {β : Type u_3} [complete_lattice β] [HasZero β] (h0 : ⊥ = 0) (s : ι → set α) (f : α → β) (x : α) : indicator (Union fun (i : ι) => s i) f x = supr fun (i : ι) => indicator (s i) f x := sorry\n\nend set\n\n\ntheorem add_monoid_hom.map_indicator {α : Type u_1} {M : Type u_2} {N : Type u_3} [add_monoid M] [add_monoid N] (f : M →+ N) (s : set α) (g : α → M) (x : α) : coe_fn f (set.indicator s g x) = set.indicator s (⇑f ∘ g) x :=\n  congr_fun (Eq.symm (set.indicator_comp_of_zero (add_monoid_hom.map_zero f))) x\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/indicator_function.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.4752083618785993}}
{"text": "import Basic\nimport Tangle\nopen Brick\n\nstructure Graph (α : Type) where\n  V: List α\n  E: List (α × α)\n  deriving Repr\n\nnamespace Graph\ndef from_edges {α : Type} [BEq α] (e : List (α × α)) : Graph α :=\n  Graph.mk\n    (e.foldr (fun n ns =>\n        match (ns.elem n.fst, ns.elem n.snd) with\n        | (true, true) => ns\n        | (false, true) => n.fst::ns\n        | (true, false) => n.snd::ns\n        | (false, false) => n.snd::n.fst::ns\n      )\n      [])\n    e\n\ndef contains_vert [BEq α] (g : Graph α) : α → Bool := g.V.elem\ndef contains_edge_directed [BEq α] (g : Graph α) : (α × α) → Bool := g.E.elem\ndef contains_edge [BEq α] (g : Graph α) (a b : α) : Bool :=\n  (g.contains_edge_directed (a, b)) ∨ (g.contains_edge_directed (b, a))\n\ndef add_vert [BEq α] (g : Graph α) (v : α) : Graph α :=\n  match (g.V.elem v) with\n  | true => g\n  | false => Graph.mk (v::g.V) g.E\n\ndef add_edge [BEq α] (g : Graph α) (a b : α) : Graph α :=\n  match g.contains_edge a b with\n  | false =>\n      let V := match (g.V.elem a), (g.V.elem b) with\n        | true, true => g.V\n        | true, false => b::g.V\n        | false, true => a::g.V\n        | false, false => b::a::g.V\n      Graph.mk V ((a, b)::g.E)\n  | _ => g\n\n\nstructure Acc where\n  N: Nat\n  I: List Nat\n  O: List Nat\n  E: List (Nat × Nat)\n  deriving Repr\n\n-- specialized List.zip which carries proof that lengths are equal\ndef zip_eq (a b : List Nat) (leneq : a.length = b.length) : List (Nat × Nat) := match a, b with\n  | [], [] => []\n  | a::a', b::b' => \n      have leneq' : a'.length = b'.length := by\n        simp [List.length] at leneq\n        assumption\n      (Prod.mk a b)::(zip_eq a' b' leneq')\n\ndef stack (acc acc': Acc) (iolen: acc.O.length = acc'.I.length) : Acc :=\n  Acc.mk\n    (Nat.max acc.N acc'.N)\n    acc.I\n    acc'.O\n    (((zip_eq acc.O acc'.I iolen).append acc.E).append acc'.E)\n\ntheorem stack_length_eq {acc acc' : Acc} {iolen : acc.O.length = acc'.I.length} :\n  (stack acc acc' iolen).I.length = acc.I.length ∧ (stack acc acc' iolen).O.length = acc'.O.length := by\n  rewrite [stack]\n  simp\n\ndef acc_brick : Brick → Acc → Acc\n  | Vert,  ⟨n, i, o, e⟩ => ⟨n+2, n::i,        (n+1)::o,        ⟨n, n+1⟩::e⟩\n  | Cap,   ⟨n, i, o, e⟩ => ⟨n+2, i,           (n+1)::n::o,     ⟨n, n+1⟩::e⟩\n  | Cup,   ⟨n, i, o, e⟩ => ⟨n+2, (n+1)::n::i, o,               ⟨n, n+1⟩::e⟩\n  | Over,  ⟨n, i, o, e⟩ => ⟨n+4, (n+1)::n::i, (n+3)::(n+2)::o, ⟨n, n+3⟩::⟨n+1, n+2⟩::e⟩\n  | Under, ⟨n, i, o, e⟩ => ⟨n+4, (n+1)::n::i, (n+3)::(n+2)::o, ⟨n, n+3⟩::⟨n+1, n+2⟩::e⟩\n\ndef acc_bricks (bs: Bricks) (acc: Acc) : Acc := match bs with\n  | [] => acc\n  | b::bs => acc_brick b (acc_bricks bs acc)\n\n\ntheorem acc_brick_io {b : Brick} {acc : Acc} :\n      ((acc_brick b acc).I.length = acc.I.length + b.domain)\n    ∧ ((acc_brick b acc).O.length = acc.O.length + b.codomain) := by\n  cases b <;> simp [acc_brick, Brick.domain, Brick.codomain]\n\ntheorem acc_bricks_io {bs : Bricks} {acc : Acc} :\n      ((acc_bricks bs acc).I.length = acc.I.length + bs.domain)\n    ∧ ((acc_bricks bs acc).O.length = acc.O.length + bs.codomain) := by\n  induction bs\n  case nil => simp [acc_bricks, Bricks.domain, Bricks.codomain, List.foldr]\n  case cons hd tl hind =>\n    simp [acc_bricks, List.length, Bricks.domain, Bricks.codomain, List.foldr]\n    rewrite [←Bricks.domain, ←Bricks.codomain]\n    apply And.intro\n    case left =>\n      rewrite [Nat.add_comm hd.domain _, ←Nat.add_assoc]\n      rewrite [acc_brick_io.left, hind.left]\n      rfl\n    case right =>\n      rewrite [Nat.add_comm hd.codomain _, ←Nat.add_assoc]\n      rewrite [acc_brick_io.right, hind.right]\n      rfl\n\n\ndef acc_tangle_aux (bs : Bricks) (w : Wall) (ht : isTangle (bs::w)) (acc : Acc) (domeq : bs.domain = acc.O.length) : Acc := match w, ht with\n  | [], _ =>\n      let acc' := acc_bricks bs (Acc.mk acc.N [] [] [])\n      have hs: acc.O.length = acc'.I.length := by\n        rewrite [acc_bricks_io.left, List.length, domeq, Nat.add_comm, Nat.add_zero]\n        exact Eq.refl _\n      stack acc acc' hs\n  | bs'::w, ht =>\n      let acc' := acc_bricks bs (Acc.mk acc.N [] [] [])\n      have hs: acc.O.length = acc'.I.length := by\n        rewrite [acc_bricks_io.left, List.length, domeq, Nat.add_comm, Nat.add_zero]\n        exact Eq.refl _\n      let acc := stack acc acc' hs\n      have hs' : bs'.domain = acc.O.length := by\n        have codomeq : bs.codomain = acc.O.length := by\n          rewrite [stack_length_eq.right, acc_bricks_io.right]\n          simp\n        rw [isTangle] at ht\n        rw [←ht.left]\n        exact codomeq\n      have ht' : isTangle (bs'::w) := by\n        rw [isTangle] at ht\n        exact ht.right\n      acc_tangle_aux bs' w ht' acc hs'\ndef acc_tangle : (t: Tangle) → (acc: Acc) → (domeq: t.domain = acc.O.length) → Acc\n  | ⟨[], _⟩, acc, _ => acc\n  | ⟨bs::w, prop⟩, acc, domeq => acc_tangle_aux bs w prop acc domeq\n\n\ndef subgraphsAux {α : Type} [BEq α] (gs : List (Graph α)) : List (α × α) → List (Graph α)\n  | [] => gs\n  | (a, b)::e =>\n      let vnew := match gs.partition (fun vs => (vs.contains_vert a) ∨ (vs.contains_vert b)) with\n        | ([], eqGrps) => (Graph.mk [a,b] [(a,b)])::eqGrps\n        | (g::gs', gs) => ((gs'.foldr (fun g' g => Graph.mk (g'.V.append g.V) (g'.E.append g.E)) g).add_edge a b)::gs\n      subgraphsAux vnew e\n/-- partitions a graph into its independent subgraphs -/\ndef subgraphs {α : Type} [BEq α] (g : Graph α) : List (Graph α) :=\n  subgraphsAux (g.V.map (fun v => Graph.mk [v] [])) g.E\n\ntheorem ind_subgraph_idempotent [BEq α] {g : Graph α} :\n  (hlen : 0 < (subgraphs g).length)\n  → subgraphs ((subgraphs g)[0]) = [(subgraphs g)[0]] := sorry\n\nnamespace Example\ndef g : Graph Nat := Graph.from_edges [⟨0, 1⟩]\n#eval g\n#eval Graph.subgraphsAux (g.V.map (fun v => Graph.mk [v] [])) g.E\n#eval Graph.subgraphs g\nend Example\n\nend Graph\n\n\ntheorem List.iota_length_eq_n {n : Nat} : (List.iota n).length = n := by\n  induction n\n  case zero =>\n    rewrite [List.iota, List.length]\n    exact Eq.refl _\n  case succ n ind =>\n    rewrite [List.iota, List.length, Nat.succ_eq_add_one, ind]\n    exact Eq.refl _\n\nnamespace Tangle\n/-- thread count is to tangle as link number is to links -/\ndef thread_count (t : Tangle) : Nat :=\n  let acc0 : Graph.Acc := ⟨0, [], List.iota t.domain, []⟩\n  let acc := Graph.acc_tangle t acc0 (Eq.symm List.iota_length_eq_n)\n  -- graph from edges\n  let g := Graph.from_edges acc.E\n  -- add any dangling verts, shouldn't happen with tangles?\n  let g := (acc.I.append acc.O).foldr (fun v g => g.add_vert v) g\n  (g.subgraphs).length\n\n\nnamespace Example\ndef unknot : Tangle :=\n  let unknot : Wall := [\n    [Cap],\n    [Cup]\n  ]\n  ⟨unknot, by simp [isTangle]⟩\n\n#eval thread_count unknot\n\n\ndef ltrefoil : Tangle :=\n  let trefoil : Wall := [\n    [Cap],\n    [Vert, Cap, Vert],\n    [Over, Over],\n    [Vert, Under, Vert],\n    [Cup, Cup]\n  ]\n  ⟨trefoil, by simp [isTangle]⟩\n\n#eval List.iota ltrefoil.domain\n#eval Graph.acc_tangle ltrefoil ⟨0, [], List.iota ltrefoil.domain, []⟩ (Eq.symm List.iota_length_eq_n)\n#eval Graph.subgraphs (Graph.from_edges [⟨0,1⟩, ⟨1,2⟩, ⟨2,0⟩])\n#eval Graph.subgraphs (Graph.from_edges (Graph.acc_tangle ltrefoil ⟨0, [], List.iota ltrefoil.domain, []⟩ (Eq.symm List.iota_length_eq_n)).E)\n#eval thread_count ltrefoil\n\n\ndef hopf_link : Tangle :=\n  let hopf_link : Wall := [\n    [Cap, Cap],\n    [Vert, Over, Vert],\n    [Vert, Over, Vert],\n    [Cup, Cup]\n  ]\n  ⟨hopf_link, by simp [isTangle]⟩\n\n#eval thread_count hopf_link\n\nend Example\n\nend Tangle\n\n", "meta": {"author": "shua", "repo": "leanknot", "sha": "5c50fc107c1e98978d2cd966d4c6b22348e1ee4a", "save_path": "github-repos/lean/shua-leanknot", "path": "github-repos/lean/shua-leanknot/leanknot-5c50fc107c1e98978d2cd966d4c6b22348e1ee4a/Graph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.4751422421310416}}
{"text": "lemma add_comm (a b : mynat) : a + b = b + a :=\nbegin\ninduction b with k Pk,\nrw add_zero, rw zero_add, refl, \nrw add_succ, rw succ_add, rw Pk, refl,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/2-addition-world/l4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.4751422421310415}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.eq_to_hom\nimport data.ulift\n\n/-!\n# Discrete categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define `discrete α` as a structure containing a term `a : α` for any type `α`,\nand use this type alias to provide a `small_category` instance\nwhose only morphisms are the identities.\n\nThere is an annoying technical difficulty that it has turned out to be inconvenient\nto allow categories with morphisms living in `Prop`,\nso instead of defining `X ⟶ Y` in `discrete α` as `X = Y`,\none might define it as `plift (X = Y)`.\nIn fact, to allow `discrete α` to be a `small_category`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X ⟶ Y` as `ulift (plift (X = Y))`.\n\n`discrete.functor` promotes a function `f : I → C` (for any category `C`) to a functor\n`discrete.functor f : discrete I ⥤ C`.\n\nSimilarly, `discrete.nat_trans` and `discrete.nat_iso` promote `I`-indexed families of morphisms,\nor `I`-indexed families of isomorphisms to natural transformations or natural isomorphism.\n\nWe show equivalences of types are the same as (categorical) equivalences of the corresponding\ndiscrete categories.\n-/\n\nnamespace category_theory\n\n-- morphism levels before object levels. See note [category_theory universes].\nuniverses v₁ v₂ v₃ u₁ u₁' u₂ u₃\n\n/--\nA wrapper for promoting any type to a category,\nwith the only morphisms being equalities.\n-/\n-- This is intentionally a structure rather than a type synonym\n-- to enforce using `discrete_equiv` (or `discrete.mk` and `discrete.as`) to move between\n-- `discrete α` and `α`. Otherwise there is too much API leakage.\n@[ext] structure discrete (α : Type u₁) :=\n(as : α)\n\n@[simp] lemma discrete.mk_as {α : Type u₁} (X : discrete α) : discrete.mk X.as = X :=\nby { ext, refl, }\n\n/-- `discrete α` is equivalent to the original type `α`.-/\n@[simps] def discrete_equiv {α : Type u₁} : discrete α ≃ α :=\n{ to_fun := discrete.as,\n  inv_fun := discrete.mk,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\ninstance {α : Type u₁} [decidable_eq α] : decidable_eq (discrete α) :=\ndiscrete_equiv.decidable_eq\n\n/--\nThe \"discrete\" category on a type, whose morphisms are equalities.\n\nBecause we do not allow morphisms in `Prop` (only in `Type`),\nsomewhat annoyingly we have to define `X ⟶ Y` as `ulift (plift (X = Y))`.\n\nSee <https://stacks.math.columbia.edu/tag/001A>\n-/\ninstance discrete_category (α : Type u₁) : small_category (discrete α) :=\n{ hom  := λ X Y, ulift (plift (X.as = Y.as)),\n  id   := λ X, ulift.up (plift.up rfl),\n  comp := λ X Y Z g f, by { cases X, cases Y, cases Z, rcases f with ⟨⟨⟨⟩⟩⟩, exact g } }\n\nnamespace discrete\n\nvariables {α : Type u₁}\n\ninstance [inhabited α] : inhabited (discrete α) :=\n⟨⟨default⟩⟩\n\ninstance [subsingleton α] : subsingleton (discrete α) :=\n⟨by { intros, ext, apply subsingleton.elim, }⟩\n\n/-- A simple tactic to run `cases` on any `discrete α` hypotheses. -/\nmeta def _root_.tactic.discrete_cases : tactic unit :=\n`[cases_matching* [discrete _, (_ : discrete _) ⟶ (_ : discrete _), plift _]]\n\nrun_cmd add_interactive [``tactic.discrete_cases]\n\nlocal attribute [tidy] tactic.discrete_cases\n\ninstance [unique α] : unique (discrete α) :=\nunique.mk' (discrete α)\n\n/-- Extract the equation from a morphism in a discrete category. -/\n\n\n/-- Promote an equation between the wrapped terms in `X Y : discrete α` to a morphism `X ⟶ Y`\nin the discrete category. -/\nabbreviation eq_to_hom {X Y : discrete α} (h : X.as = Y.as) : X ⟶ Y :=\neq_to_hom (by { ext, exact h, })\n\n/-- Promote an equation between the wrapped terms in `X Y : discrete α` to an isomorphism `X ≅ Y`\nin the discrete category. -/\nabbreviation eq_to_iso {X Y : discrete α} (h : X.as = Y.as) : X ≅ Y :=\neq_to_iso (by { ext, exact h, })\n\n/-- A variant of `eq_to_hom` that lifts terms to the discrete category. -/\nabbreviation eq_to_hom' {a b : α} (h : a = b) : discrete.mk a ⟶ discrete.mk b :=\neq_to_hom h\n\n/-- A variant of `eq_to_iso` that lifts terms to the discrete category. -/\nabbreviation eq_to_iso' {a b : α} (h : a = b) : discrete.mk a ≅ discrete.mk b :=\neq_to_iso h\n\n@[simp] lemma id_def (X : discrete α) : ulift.up (plift.up (eq.refl X.as)) = 𝟙 X := rfl\n\nvariables {C : Type u₂} [category.{v₂} C]\n\ninstance {I : Type u₁} {i j : discrete I} (f : i ⟶ j) : is_iso f :=\n⟨⟨eq_to_hom (eq_of_hom f).symm, by tidy⟩⟩\n\n/--\nAny function `I → C` gives a functor `discrete I ⥤ C`.\n-/\ndef functor {I : Type u₁} (F : I → C) : discrete I ⥤ C :=\n{ obj := F ∘ discrete.as,\n  map := λ X Y f, by { discrete_cases, cases f, exact 𝟙 (F X), } }\n\n@[simp] lemma functor_obj  {I : Type u₁} (F : I → C) (i : I) :\n  (discrete.functor F).obj (discrete.mk i) = F i := rfl\n\nlemma functor_map  {I : Type u₁} (F : I → C) {i : discrete I} (f : i ⟶ i) :\n  (discrete.functor F).map f = 𝟙 (F i.as) :=\nby tidy\n\n/--\nThe discrete functor induced by a composition of maps can be written as a\ncomposition of two discrete functors.\n-/\n@[simps]\ndef functor_comp {I : Type u₁} {J : Type u₁'} (f : J → C) (g : I → J) :\n  discrete.functor (f ∘ g) ≅ discrete.functor (discrete.mk ∘ g) ⋙ discrete.functor f :=\nnat_iso.of_components (λ X, iso.refl _) (by tidy)\n\n/--\nFor functors out of a discrete category,\na natural transformation is just a collection of maps,\nas the naturality squares are trivial.\n-/\n@[simps]\ndef nat_trans {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ⟶ G.obj i) : F ⟶ G :=\n{ app := f,\n  naturality' := λ X Y g, by { discrete_cases, cases g, simp, } }\n\n/--\nFor functors out of a discrete category,\na natural isomorphism is just a collection of isomorphisms,\nas the naturality squares are trivial.\n-/\n@[simps]\ndef nat_iso {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) : F ≅ G :=\nnat_iso.of_components f (λ X Y g, by { discrete_cases, cases g, simp, })\n\n@[simp]\nlemma nat_iso_app {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) (i : discrete I) :\n  (discrete.nat_iso f).app i = f i :=\nby tidy\n\n/-- Every functor `F` from a discrete category is naturally isomorphic (actually, equal) to\n  `discrete.functor (F.obj)`. -/\n@[simp]\ndef nat_iso_functor {I : Type u₁} {F : discrete I ⥤ C} :\n  F ≅ discrete.functor (F.obj ∘ discrete.mk) :=\nnat_iso $ λ i, by { discrete_cases, refl, }\n\n/-- Composing `discrete.functor F` with another functor `G` amounts to composing `F` with `G.obj` -/\n@[simp]\ndef comp_nat_iso_discrete {I : Type u₁} {D : Type u₃} [category.{v₃} D]\n (F : I → C) (G : C ⥤ D) : discrete.functor F ⋙ G ≅ discrete.functor (G.obj ∘ F) :=\nnat_iso $ λ i, iso.refl _\n\n/--\nWe can promote a type-level `equiv` to\nan equivalence between the corresponding `discrete` categories.\n-/\n@[simps]\ndef equivalence {I : Type u₁} {J : Type u₂} (e : I ≃ J) : discrete I ≌ discrete J :=\n{ functor := discrete.functor (discrete.mk ∘ (e : I → J)),\n  inverse := discrete.functor (discrete.mk ∘ (e.symm : J → I)),\n  unit_iso := discrete.nat_iso (λ i, eq_to_iso (by { discrete_cases, simp })),\n  counit_iso := discrete.nat_iso (λ j, eq_to_iso (by { discrete_cases, simp })), }\n\n/-- We can convert an equivalence of `discrete` categories to a type-level `equiv`. -/\n@[simps]\ndef equiv_of_equivalence {α : Type u₁} {β : Type u₂} (h : discrete α ≌ discrete β) : α ≃ β :=\n{ to_fun := discrete.as ∘ h.functor.obj ∘ discrete.mk,\n  inv_fun := discrete.as ∘ h.inverse.obj ∘ discrete.mk,\n  left_inv := λ a, by simpa using eq_of_hom (h.unit_iso.app (discrete.mk a)).2,\n  right_inv := λ a, by simpa using eq_of_hom (h.counit_iso.app (discrete.mk a)).1, }\n\nend discrete\n\nnamespace discrete\nvariables {J : Type v₁}\n\nopen opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\n@[simps functor_obj_as inverse_obj]\nprotected def opposite (α : Type u₁) : (discrete α)ᵒᵖ ≌ discrete α :=\nlet F : discrete α ⥤ (discrete α)ᵒᵖ := discrete.functor (λ x, op (discrete.mk x)) in\nbegin\n  refine equivalence.mk (functor.left_op F) F _\n    (discrete.nat_iso $ λ X, by { discrete_cases, simp [F] }),\n  refine nat_iso.of_components (λ X, by { tactic.op_induction', discrete_cases, simp [F], }) _,\n  tidy\nend\n\nvariables {C : Type u₂} [category.{v₂} C]\n\n@[simp] lemma functor_map_id\n  (F : discrete J ⥤ C) {j : discrete J} (f : j ⟶ j) : F.map f = 𝟙 (F.obj j) :=\nbegin\n  have h : f = 𝟙 j, { cases f, cases f, ext, },\n  rw h,\n  simp,\nend\n\nend discrete\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/discrete_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.4751422377315029}}
{"text": "--import subfield_stuff\nimport field_theory.subfield\nimport field_theory.separable\nimport field_theory.tower\nimport group_theory.subgroup\nimport field_theory.minimal_polynomial\nimport linear_algebra.dimension\nimport linear_algebra.finite_dimensional\nimport ring_theory.adjoin_root\nimport data.zmod.basic\n\nvariables (F : Type*) [field F] {E : Type*} [field E] [algebra F E] (S : set E)\n\ndef adjoin : set E := field.closure (set.range (algebra_map F E) ∪ S)\n\nlemma adjoin.field_mem (x : F) : algebra_map F E x ∈ adjoin F S :=\nfield.mem_closure (or.inl (set.mem_range_self x))\n\nlemma adjoin.field_subset : set.range (algebra_map F E) ⊆ adjoin F S :=\nbegin\n    intros x hx,\n    cases hx with f hf,\n    rw ←hf,\n    exact adjoin.field_mem F S f,\nend\n\ninstance adjoin.field_coe : has_coe_t F (adjoin F S) :=\n{coe := λ x, ⟨algebra_map F E x, adjoin.field_mem F S x⟩}\n\nlemma adjoin.set_mem (x : S) : ↑x ∈ adjoin F S :=\nfield.mem_closure (or.inr (subtype.mem x))\n\nlemma adjoin.set_subset : S ⊆ adjoin F S :=\nλ x hx, adjoin.set_mem F S ⟨x,hx⟩\n\ninstance adjoin.set_coe : has_coe_t S (adjoin F S) :=\n{coe := λ x, ⟨↑x, adjoin.set_mem F S x⟩}\n\nlemma adjoin.mono (T : set E) (h : S ⊆ T) : adjoin F S ⊆ adjoin F T :=\nfield.closure_mono (set.union_subset (set.subset_union_left _ _) (set.subset_union_of_subset_right h _))\n\ninstance adjoin.is_subfield : is_subfield (adjoin F S) := field.closure.is_subfield\n\nlemma adjoin_contains_field_as_subfield (F : set E) {HF : is_subfield F} : F ⊆ adjoin F S :=\nλ x hx, adjoin.field_mem F S ⟨x, hx⟩\n\nlemma adjoin_contains_subset {T : set E} {H : T ⊆ S} : T ⊆ adjoin F S :=\nbegin\n    intros x hx,\n    exact adjoin.set_mem F S ⟨x,H hx⟩,\nend\n\ninstance adjoin.is_algebra : algebra F (adjoin F S) := {\n    smul := λ x y, ⟨algebra_map F E x, adjoin.field_mem F S x⟩ * y,\n    to_fun := λ x, ⟨algebra_map F E x, adjoin.field_mem F S x⟩,\n    map_one' := by simp only [ring_hom.map_one];refl,\n    map_mul' := λ x y, by simp only [ring_hom.map_mul];refl,\n    map_zero' := by simp only [ring_hom.map_zero];refl,\n    map_add' := λ x y, by simp only [ring_hom.map_add];refl,\n    commutes' := λ x y, by rw mul_comm,\n    smul_def' := λ x y, rfl,\n}\n\ndef adjoin_as_submodule : submodule F E := {\n    carrier := adjoin F S,\n    zero_mem' := is_add_submonoid.zero_mem,\n    add_mem' := λ a b, is_add_submonoid.add_mem,\n    smul_mem' :=\n    begin\n        intros a b hb,\n        rw algebra.smul_def,\n        exact is_submonoid.mul_mem (adjoin.field_mem F S a) hb,\n    end\n}\n\ndefinition adjoin_as_submodule_equiv : (adjoin F S) ≃ₗ[F] (adjoin_as_submodule F S) := {\n    to_fun := λ x, x,\n    map_add' := λ x y, rfl,\n    map_smul' :=\n    begin\n        intros x y,\n        ext1,\n        change _ = x • ↑y,\n        rw algebra.smul_def,\n        rw algebra.smul_def,\n        refl,\n    end,\n    inv_fun := λ x, x,\n    left_inv := λ x, rfl,\n    right_inv := λ x, rfl,\n}\n\nlemma adjoin_subset {T : set E} [is_subfield T] (HF : set.range (algebra_map F E) ⊆ T) (HS : S ⊆ T) : adjoin F S ⊆ T :=\nbegin\n    apply field.closure_subset,\n    rw set.union_subset_iff,\n    exact ⟨HF,HS⟩,\nend\n\n/-- If S ⊆ F[T] then F[S] ⊆ F[T] -/\nlemma adjoin_subset' {T : set E} (HT : S ⊆ adjoin F T) : adjoin F S ⊆ adjoin F T :=\nadjoin_subset F S (adjoin.field_subset F T) HT\n\nlemma set_range_subset {T₁ T₂ : set E} [is_subfield T₁] [is_subfield T₂] {hyp : T₁ ⊆ T₂} :\nset.range (algebra_map T₁ E) ⊆ T₂ :=\nbegin\n    intros x hx,\n    cases hx with f hf,\n    rw ←hf,\n    cases f with t ht,\n    exact hyp ht,\nend\n\n/- The range of the embedding of F into E is equal to the range of the inclusion embedding of\n    range(F → E) into E. -/\nlemma algebra_map_twice : set.range (algebra_map (set.range (algebra_map F E)) E) = set.range (algebra_map F E) :=\nbegin\n    ext, split,\n    {   rintros ⟨⟨y, ⟨z, rfl⟩⟩, rfl⟩,\n        exact ⟨z, rfl⟩,\n    },\n    {   exact λ hx, ⟨⟨x, hx⟩, rfl⟩, },\nend\n\n/- Adjoining S to F is the same as adjoining S to the range of the embedding of F into E. -/\nlemma adjoin_equals_adjoin_range : adjoin F S = adjoin (set.range (algebra_map F E)) S :=\nby simp only [adjoin, algebra_map_twice]\n\nlemma adjoin_contains_field_subset {F : set E} {HF : is_subfield F} {T : set E} {HT : T ⊆ F} : T ⊆ adjoin F S :=\nλ x hx, adjoin.field_mem F S ⟨x,HT hx⟩\n\nlemma adjoin_twice (T : set E) : adjoin (adjoin F S) T = adjoin F (S ∪ T) :=\nbegin\n    apply set.eq_of_subset_of_subset,\n    apply adjoin_subset,\n    apply set_range_subset,\n    apply adjoin_subset,\n    apply adjoin.field_subset,\n    apply adjoin_contains_subset,\n    apply set.subset_union_left,\n    apply adjoin_contains_subset,\n    apply set.subset_union_right,\n    apply adjoin_subset,\n    transitivity adjoin F S,\n    apply adjoin.field_subset,\n    apply adjoin_subset,\n    apply adjoin_contains_field_subset,\n    apply adjoin.field_subset,\n    apply adjoin_contains_field_subset,\n    apply adjoin.set_subset,\n    apply set.union_subset,\n    apply adjoin_contains_field_subset,\n    apply adjoin.set_subset,\n    apply adjoin.set_subset,\nend\n\nlemma adjoin.composition : (algebra_map F E) = (algebra_map (adjoin F S) E).comp (algebra_map F (adjoin F S)) :=\nbegin\n    ext,\n    refl,\nend\n\ninstance adjoin_algebra_tower : is_scalar_tower F (adjoin F S) E := {\n    smul_assoc :=\n    begin\n        intros x y z,\n        rw algebra.smul_def,\n        rw algebra.smul_def,\n        rw algebra.smul_def,\n        rw ring_hom.map_mul,\n        rw mul_assoc,\n        refl,\n    end\n}\n\nlemma adjoin_separable [F_sep : is_separable F E] : is_separable (adjoin F S) E :=\nbegin\n    intro x,\n    cases F_sep x with hx hs,\n    have hx' : is_integral (adjoin F S) x := is_integral_of_is_scalar_tower x hx,\n    use hx',\n    have key : (minimal_polynomial hx') ∣ (minimal_polynomial hx).map(algebra_map F (adjoin F S)),\n    apply minimal_polynomial.dvd,\n    dsimp[polynomial.aeval],\n    rw polynomial.eval₂_map,\n    rw ← adjoin.composition,\n    apply minimal_polynomial.aeval,\n    cases key with q hq,\n    apply polynomial.separable.of_mul_left,\n    rw ←hq,\n    exact polynomial.separable.map hs,\nend\n\nvariables (α : E) (h : is_integral F α)\n\n-- Let's try out this notation?\nnotation K`[`:std.prec.max_plus β`]` := adjoin K (@singleton _ _ set.has_singleton β)\nnotation K`[`:std.prec.max_plus β `,` γ`]` := adjoin K {β,γ}\n-- This notation would allow us to write F[α, β] for adjoin_simple (adjoin_simple F α) β\n-- notation K`⟨`L:(foldr `,` (x M, adjoin_simple M x) K `⟩`) := L \n-- notation K`[[` binders `]]`s:(scoped β, set.insert β) := adjoin K s\n\nlemma adjoin_simple_contains_element : α ∈ F[α] :=\nadjoin.set_mem F {α} (⟨α,set.mem_singleton α⟩ : ({α} : set E))\n\ninstance adjoin_is_algebra : algebra F F[α] :=\nadjoin.is_algebra F {α}\n\ndef adjoin_simple_as_submodule : submodule F E :=\nadjoin_as_submodule F {α}\n\ndefinition adjoin_simple_as_submodule_equiv : F[α] ≃ₗ[F] (adjoin_simple_as_submodule F α) :=\nadjoin_as_submodule_equiv F {α}\n\n/-- A subfield of E that contains F and α also contains F[α] -/\nlemma adjoin_simple_subset {T : set E} [is_subfield T] (HF : set.range (algebra_map F E) ⊆ T) (Hα : α ∈ T) : F[α] ⊆ T :=\nadjoin_subset F {α} HF (set.singleton_subset_iff.mpr Hα)\n\n/-- If α is in F[T] then F[α] ⊆ F[T] -/\nlemma adjoin_simple_subset' {T : set E} (HT : α ∈ adjoin F T) : F[α] ⊆ adjoin F T :=\nadjoin_subset' F {α} (set.singleton_subset_iff.mpr HT)\n\n--generator of F(α)\ndef adjoin_simple.gen : F[α] := ⟨α, adjoin_simple_contains_element F α⟩\n\nlemma adjoin_simple.gen_eq_alpha : algebra_map F[α] E (adjoin_simple.gen F α) = α := rfl\n\n/-- If the generator is not in the inclusion of F in E then it's also not in the inclusion of\n    F in F[α]. -/\nlemma adjoin_simple_gen_nontrivial {α : E} (hα : α ∉ set.range (algebra_map F E)) :\n    adjoin_simple.gen F α ∉ set.range (algebra_map F F[α]) :=\nbegin\n    revert hα,\n    contrapose!,\n    rintros ⟨x, hx⟩,\n    injections_and_clear,\n    use x, assumption,\nend\n\nlemma adjoin_simple_twice (β : E) : F[α][β] = adjoin F {α,β} :=\nadjoin_twice _ _ _\n\ndef submodule_restrict_field (α : E) (p : submodule F[α] E) : submodule F E := {\n    carrier := p.carrier,\n    zero_mem' := p.zero_mem',\n    add_mem' := p.add_mem',\n    smul_mem' :=\n    begin\n        intros c x hx,\n        rw algebra.smul_def,\n        rw adjoin.composition F {α},\n        rw ring_hom.comp_apply,\n        rw ←algebra.smul_def,\n        exact p.smul_mem' _ hx,\n    end\n}\n\ninstance adjoin_simple_algebra_tower : is_scalar_tower F (F[α]) E :=\nadjoin_algebra_tower F {α}\n\nsection\nopen finite_dimensional\n\n/-- If a subset of a set is infinite then the set is infinite. -/\nlemma inf_of_subset_inf {X : Type*} {s : set X} {t : set X} (hst : s ⊆ t) (hs : s.infinite) : t.infinite :=\nmt (λ ht, ht.subset hst) hs\n\n/-- If E is a finite extension of F then it is also a finite extension of F adjoin alpha. -/\ninstance adjoin_findim_of_findim [F_findim : finite_dimensional F E] (α : E) :\n    finite_dimensional F[α] E :=\nbegin\n    rw iff_fg,\n    rw submodule.fg_iff_finite_dimensional,\n    cases (finite_dimensional.exists_is_basis_finite F E) with B hB,\n    have key : submodule.span F[α] B = ⊤,\n    {   ext,\n        simp only [submodule.mem_top, iff_true],\n        have hx : x ∈ submodule.span F (set.range coe),\n        {   rw hB.1.2,\n            exact submodule.mem_top, },\n        rw submodule.mem_span,\n        intros p hp,\n        rw submodule.mem_span at hx,\n        apply hx (submodule_restrict_field F α p),\n        rw subtype.range_coe,\n        exact hp, },\n    rw ← key,\n    apply finite_dimensional.span_of_finite F[α] hB.2,\nend\n\ninstance adjoin_findim_of_findim_base [F_findim : finite_dimensional F E] (α : E) :\n    finite_dimensional F F[α] :=\nbegin\n    have h := finite_dimensional.finite_dimensional_submodule (adjoin_simple_as_submodule F α),\n    exact linear_equiv.finite_dimensional (adjoin_simple_as_submodule_equiv F α).symm,\nend\n\n/-- If the field extension E has an element not in the base field F then the degree of E over F is\n    greater than 1. -/\nlemma algebra_findim_lt [hF : finite_dimensional F E] : (∃ x : E, x ∉ set.range (algebra_map F E)) →\n    1 < findim F E :=\nbegin\n    contrapose!,\n    intros E_dim x,\n    have : 0 < findim F E := findim_pos_iff_exists_ne_zero.mpr ⟨1, one_ne_zero⟩,\n    replace E_dim : findim F E = 1 := by omega,\n    set s : set E := {1} with hs,\n    have : fintype s := unique.fintype,\n    have s_lin_ind : linear_independent F (coe : s → E) := linear_independent_singleton one_ne_zero,\n    have s_card : s.to_finset.card = findim F E := by change s.to_finset.card with 1; rw E_dim,\n    obtain ⟨_, s_spans⟩ := set_is_basis_of_linear_independent_of_card_eq_findim s_lin_ind s_card,\n    have x_in_span_one : x ∈ submodule.span F s :=\n    begin\n        rw subtype.range_coe at s_spans,\n        rw s_spans,\n        exact submodule.mem_top,\n    end,\n    obtain ⟨a, ha⟩ := submodule.mem_span_singleton.mp x_in_span_one,\n    exact ⟨a, by rw [← ha, algebra.smul_def, mul_one]⟩,\nend\n\n/-- Adjoining an element from outside of F strictly decreases the degree of a finite extension. -/\nlemma adjoin_dim_lt [hF : finite_dimensional F E] {α : E} (hα : α ∉ set.range (algebra_map F E)) :\n    findim F[α] E < findim F E :=\nbegin\n    rw ← findim_mul_findim F F[α] E,\n    have : 0 < findim F[α] E := findim_pos_iff_exists_ne_zero.mpr ⟨1, one_ne_zero⟩,\n    have : adjoin_simple.gen F α ∉ set.range (algebra_map F F[α]) := adjoin_simple_gen_nontrivial F hα,\n    have : findim F F[α] > 1 := algebra_findim_lt F (by tauto),\n    nlinarith,\nend\n\n/-- If F is infinite then its inclusion into E is infinite. -/\nlemma inclusion.infinite (hF : infinite F) : (set.range (algebra_map F E)).infinite :=\nbegin\n    apply set.infinite_coe_iff.mp,\n    apply infinite.of_injective (set.range_factorization (algebra_map F E)),\n    exact subtype.coind_injective (λ (a : F), set.mem_range_self a) ((algebra_map F E).injective),\nend\n\nlemma adjoin_inf_of_inf (S : set E) (hF : infinite F) : infinite (adjoin F S) :=\nbegin\n    rw adjoin_equals_adjoin_range,\n    apply set.infinite_coe_iff.mpr,\n    exact inf_of_subset_inf (adjoin_contains_field_as_subfield S (set.range (algebra_map F E))) (inclusion.infinite F hF),\nend\n\nend\n\nvariables {E' : Type*} [field E'] [algebra F E'] (α' : E') (hα' : (minimal_polynomial h).eval₂ (algebra_map F E') α' = 0)\n\nnoncomputable def quotient_embedding_ring_hom :\n(adjoin_root (minimal_polynomial h)) →+* E' :=\nadjoin_root.lift (algebra_map F E') α' hα'\n\nnoncomputable def quotient_embedding : (adjoin_root (minimal_polynomial h)) →ₐ[F] E' := {\n    to_fun := (quotient_embedding_ring_hom F α h α' hα').to_fun,\n    map_one' := (quotient_embedding_ring_hom F α h α' hα').map_one',\n    map_mul' := (quotient_embedding_ring_hom F α h α' hα').map_mul',\n    map_zero' := (quotient_embedding_ring_hom F α h α' hα').map_zero',\n    map_add' := (quotient_embedding_ring_hom F α h α' hα').map_add',\n    commutes' :=\n    begin\n        intro r,\n        change (quotient_embedding_ring_hom F α h α' hα') r = _,\n        exact adjoin_root.lift_of,\n    end\n}\n\n@[simp] lemma quotient_embedding_of_field (f : F) : quotient_embedding F α h α' hα' f = algebra_map F E' f :=\nbegin\n    change quotient_embedding_ring_hom F α h α' hα' f = algebra_map F E' f,\n    exact adjoin_root.lift_of,\nend\n\n@[simp] lemma quotient_embedding_of_root : quotient_embedding F α h α' hα' (adjoin_root.root (minimal_polynomial h)) = α' :=\nbegin\n    change quotient_embedding_ring_hom F α h α' hα' (adjoin_root.root (minimal_polynomial h)) = α',\n    exact adjoin_root.lift_root,\nend\n\nnoncomputable instance yes_its_a_field_but_lean_want_me_to_give_this_instance_a_name : field (adjoin_root (minimal_polynomial h)) :=\n@adjoin_root.field F _ (minimal_polynomial h) (minimal_polynomial.irreducible h)\n\nlemma adjoin_simple.eval_gen : polynomial.eval₂ (algebra_map F F[α]) (adjoin_simple.gen F α) (minimal_polynomial h) = 0 :=\nbegin\n    ext,\n    have eval := minimal_polynomial.aeval h,\n    dsimp[polynomial.aeval] at eval,\n    rw adjoin.composition F {α} at eval,\n    have h := polynomial.hom_eval₂ (minimal_polynomial h) (algebra_map F F[α]) (algebra_map F[α] E) (adjoin_simple.gen F α),\n    rw adjoin_simple.gen_eq_alpha at h,\n    rw ←h at eval,\n    exact eval,\nend\n\nnoncomputable def quotient_to_adjunction_algebra_hom : (adjoin_root (minimal_polynomial h)) →ₐ[F] F[α] :=\nquotient_embedding F α h (adjoin_simple.gen F α) (adjoin_simple.eval_gen F α h)\n\nnoncomputable def algebra_equiv_of_bij_hom' {A : Type*} [ring A] [algebra F A] {B : Type*} [ring B] [algebra F B] (f : A →ₐ[F] B) (h : function.bijective f) : A ≃ₐ[F] B :=\n{ .. f, .. equiv.of_bijective _ h }\n\nnoncomputable def quotient_to_adjunction : adjoin_root (minimal_polynomial h) ≃ₐ[F] F[α] :=\nalgebra_equiv_of_bij_hom' F (quotient_to_adjunction_algebra_hom F α h)\nbegin\n    set f := (algebra_map F[α] E).comp((quotient_to_adjunction_algebra_hom F α h) : (adjoin_root (minimal_polynomial h)) →+* F[α]),\n    split,\n    apply ring_hom.injective,\n    have inclusion : (set.range (algebra_map F E) ∪ {α}) ⊆ set.range(f),\n    rw set.union_subset_iff,\n    split,\n    intros x hx,\n    rw set.mem_range at hx,\n    cases hx with y hy,\n    rw ←hy,\n    use y,\n    dsimp[f,quotient_to_adjunction_algebra_hom],\n    rw quotient_embedding_of_field F α h (adjoin_simple.gen F α) (adjoin_simple.eval_gen F α h) y,\n    refl,\n    intros x hx,\n    rw set.mem_singleton_iff at hx,\n    rw hx,\n    use adjoin_root.root (minimal_polynomial h),\n    dsimp[f,quotient_to_adjunction_algebra_hom],\n    rw quotient_embedding_of_root F α h (adjoin_simple.gen F α) (adjoin_simple.eval_gen F α h),\n    refl,\n    have key : F[α] ⊆ set.range(f) := field.closure_subset inclusion,\n    intro x,\n    specialize key (subtype.mem x),\n    cases key with a ah,\n    use a,\n    ext1,\n    assumption,\nend\n\n@[simp] lemma quotient_to_adjunction_of_field (f : F) : quotient_to_adjunction F α h f = f :=\nquotient_embedding_of_field F α h (adjoin_simple.gen F α) (adjoin_simple.eval_gen F α h) f\n\n@[simp] lemma quotient_to_adjunction_of_root : quotient_to_adjunction F α h (adjoin_root.root (minimal_polynomial h)) = adjoin_simple.gen F α :=\nquotient_embedding_of_root F α h (adjoin_simple.gen F α) (adjoin_simple.eval_gen F α h)\n\nnoncomputable def adjunction_embedding : F[α] →ₐ[F] E' :=\n(quotient_embedding F α h α' hα').comp((quotient_to_adjunction F α h).symm)\n\n@[simp] lemma adjunction_embedding_of_field (f : F) : adjunction_embedding F α h α' hα' f = algebra_map F E' f :=\nbegin\n    dsimp[adjunction_embedding],\n    rw ←quotient_to_adjunction_of_field,\n    rw alg_equiv.symm_apply_apply,\n    rw quotient_embedding_of_field,\nend\n\n@[simp] lemma adjunction_embedding_of_root : adjunction_embedding F α h α' hα' (adjoin_simple.gen F α) = α' :=\nbegin\n    dsimp[adjunction_embedding],\n    rw ←quotient_to_adjunction_of_root,\n    rw alg_equiv.symm_apply_apply,\n    rw quotient_embedding_of_root,\nend\n\nvariables (ϕ ψ : (adjoin F S) →+* E')\n\ndef adjoin_equalizer : set (adjoin F S) :=\n(λ f, ϕ f = ψ f)\n\ninstance to_adjunction_embedding_equalizer_is_subfield : is_subfield (adjoin_equalizer F S ϕ ψ) := {\n    zero_mem :=\n    begin\n        change ϕ 0 = ψ 0,\n        rw ring_hom.map_zero,\n        rw ring_hom.map_zero,\n    end,\n    add_mem :=\n    begin\n        intros a b ha hb,\n        change ϕ a = ψ a at ha,\n        change ϕ b = ψ b at hb,\n        change ϕ (a + b) = ψ (a + b),\n        rw ring_hom.map_add,\n        rw ring_hom.map_add,\n        rw ha,\n        rw hb,\n    end,\n    neg_mem :=\n    begin\n        intros a ha,\n        change ϕ a = ψ a at ha,\n        change ϕ (-a) = ψ (-a),\n        rw ring_hom.map_neg,\n        rw ring_hom.map_neg,\n        rw ha,\n    end,\n    one_mem :=\n    begin\n        change ϕ 1 = ψ 1,\n        rw ring_hom.map_one,\n        rw ring_hom.map_one,\n    end,\n    mul_mem :=\n    begin\n        intros a b ha hb,\n        change ϕ a = ψ a at ha,\n        change ϕ b = ψ b at hb,\n        change ϕ (a * b) = ψ (a * b),\n        rw ring_hom.map_mul,\n        rw ring_hom.map_mul,\n        rw ha,\n        rw hb,\n    end,\n    inv_mem :=\n    begin\n        intros a ha,\n        change ϕ a = ψ a at ha,\n        change ϕ a⁻¹ = ψ a⁻¹,\n        rw ring_hom.map_inv,\n        rw ring_hom.map_inv,\n        rw ha,\n    end\n}\n\ninstance to_adjunction_embedding_equalizer_coe_is_subfield : is_subfield ((coe '' adjoin_equalizer F S ϕ ψ) : set E) := {\n    zero_mem := ⟨0,⟨is_add_submonoid.zero_mem,rfl⟩⟩,\n    add_mem :=\n    begin\n        intros a b ha hb,\n        cases ha with a' ha',\n        cases hb with b' hb',\n        rw[←ha'.2,←hb'.2],\n        exact ⟨a'+b',⟨is_add_submonoid.add_mem ha'.1 hb'.1,rfl⟩⟩,\n    end,\n    neg_mem :=\n    begin\n        intros a ha,\n        cases ha with a' ha',\n        rw ←ha'.2,\n        exact ⟨-a',⟨is_add_subgroup.neg_mem ha'.1,rfl⟩⟩,\n    end,\n    one_mem := ⟨1,⟨is_submonoid.one_mem,rfl⟩⟩,\n    mul_mem :=\n    begin\n        intros a b ha hb,\n        cases ha with a' ha',\n        cases hb with b' hb',\n        rw[←ha'.2,←hb'.2],\n        exact ⟨a'*b',⟨is_submonoid.mul_mem ha'.1 hb'.1,rfl⟩⟩,\n    end,\n    inv_mem :=\n    begin\n        intros a ha,\n        cases ha with a' ha',\n        rw ←ha'.2,\n        exact ⟨a'⁻¹,⟨is_subfield.inv_mem ha'.1,rfl⟩⟩,\n    end\n}\n\nlemma ring_hom_determined_by_generators (hF : ∀ f : F, ϕ f = ψ f) (hS : ∀ s : S, ϕ s = ψ s) : ϕ = ψ :=\nbegin\n    suffices key : adjoin F S ⊆ coe '' adjoin_equalizer F S ϕ ψ,\n    ext,\n    specialize key (subtype.mem x),\n    cases key with y hy,\n    rw ←subtype.ext hy.2,\n    exact hy.1,\n    dsimp[adjoin],\n    rw field.closure_subset_iff,\n    rw set.union_subset_iff,\n    split,\n    intros x hx,\n    cases hx with y hy,\n    exact ⟨↑y,⟨hF y,hy⟩⟩,\n    intros x hx,\n    exact ⟨⟨x,adjoin.set_mem F S ⟨x,hx⟩⟩,⟨hS ⟨x,hx⟩,rfl⟩⟩,\nend\n\nvariable (ι : F[α] →ₐ[F] E') \n\nlemma adjunction_embedding_classification_aux : polynomial.eval₂ (algebra_map F E') (ι (adjoin_simple.gen F α)) (minimal_polynomial h) = 0 :=\nbegin\n    have key2 : ((ι : F[α] →+* E').comp(algebra_map F F[α]) = algebra_map F E'),\n    ext,\n    simp only [alg_hom.coe_to_ring_hom, function.comp_app, ring_hom.coe_comp, alg_hom.commutes],\n    rw ←key2,\n    change polynomial.eval₂ ((ι : F[α] →+* E').comp(algebra_map F F[α])) ((ι : F[α] →+* E') (adjoin_simple.gen F α)) (minimal_polynomial h) = 0,\n    rw ←polynomial.hom_eval₂ (minimal_polynomial h) (algebra_map F F[α]) (ι : F[α] →+* E') (adjoin_simple.gen F α),\n    rw adjoin_simple.eval_gen,\n    simp only [alg_hom.coe_to_ring_hom, alg_hom.map_zero],\nend\n\nnoncomputable def to_adjunction_embedding : F[α] →ₐ[F] E' :=\nadjunction_embedding F α h (ι (adjoin_simple.gen F α)) (adjunction_embedding_classification_aux F α h ι)\n\n--proves that every map F(α) → E' is comes from adjunction_embedding\nlemma adjunction_embedding_classification : ι = to_adjunction_embedding F α h ι :=\nbegin\n    have key := ring_hom_determined_by_generators F {α} (ι : F[α] →+* E') (to_adjunction_embedding F α h ι : F[α] →+* E'),\n    have hF : ∀ f : F, ι f = to_adjunction_embedding F α h ι f,\n    intro f,\n    dsimp[to_adjunction_embedding],\n    rw adjunction_embedding_of_field,\n    exact alg_hom.commutes ι f,\n    specialize key hF,\n    rw ring_hom.ext_iff at key,\n    rw alg_hom.ext_iff,\n    apply key,\n    intro s,\n    have h' : (↑s : adjoin F {α}) = adjoin_simple.gen F α,\n    ext,\n    cases s with s hs,\n    exact set.mem_singleton_iff.2 hs,\n    rw h',\n    dsimp[to_adjunction_embedding],\n    rw adjunction_embedding_of_root,\nend\n\n/-lemma quotient_degree_finite : finite_dimensional F (adjoin_root (minimal_polynomial h)) :=\nbegin\n    sorry\nend\n\nlemma quotient_degree : (finite_dimensional.findim F (adjoin_root (minimal_polynomial h))) = (minimal_polynomial h).nat_degree :=\nbegin\n    sorry\nend\n\nlemma adjunction_degree_finite : finite_dimensional F (adjoin_root (minimal_polynomial h)) :=\nbegin\n    sorry\nend\n\nlemma adjunction_degree : (finite_dimensional.findim F (adjoin_simple F α)) = (minimal_polynomial h).nat_degree :=\nbegin\n    have algequiv : adjoin_root (minimal_polynomial h) ≃ₐ[F] adjoin_simple F α := quotient_to_adjunction F α h,\n    have linequiv : adjoin_root (minimal_polynomial h) ≃ₗ[F] adjoin_simple F α,\n    fconstructor,\n    exact algequiv.to_fun,\n    exact algequiv.map_add,\n    intro c,\n    intro x,\n    change algequiv (c * x) = ((algebra_map F (adjoin_simple F α) c) * (algequiv x)),\n    rw[algequiv.map_mul,←algequiv.commutes],\n    refl,\n    exact algequiv.inv_fun,\n    exact algequiv.left_inv,\n    exact algequiv.right_inv,\n    rw ← @linear_equiv.findim_eq F (adjoin_root (minimal_polynomial h)) _ _ _ (adjoin_simple F α) _ _ linequiv (quotient_degree_finite F α h),\n    exact quotient_degree F α h,\nend-/", "meta": {"author": "pglutz", "repo": "galois_theory", "sha": "4561c2c97d4c49377356e1d7a2051dedc87d30ba", "save_path": "github-repos/lean/pglutz-galois_theory", "path": "github-repos/lean/pglutz-galois_theory/galois_theory-4561c2c97d4c49377356e1d7a2051dedc87d30ba/src/adjoin.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056295505783, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4751422377315027}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.constructions.filtered\n! leanprover-community/mathlib commit 10bf4f825ad729c5653adc039dafa3622e7f93c9\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Constructions.LimitsOfProductsAndEqualizers\nimport Mathbin.CategoryTheory.Limits.Opposites\n\n/-!\n# Constructing colimits from finite colimits and filtered colimits\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe construct colimits of size `w` from finite colimits and filtered colimits of size `w`. Since\n`w`-sized colimits are constructured from coequalizers and `w`-sized coproducts, it suffices to\nconstruct `w`-sized coproducts from finite coproducts and `w`-sized filtered colimits.\n\nThe idea is simple: to construct coproducts of shape `α`, we take the colimit of the filtered\ndiagram of all coproducts of finite subsets of `α`.\n\nWe also deduce the dual statement by invoking the original statement in `Cᵒᵖ`.\n-/\n\n\nuniverse w v u\n\nnoncomputable section\n\nopen CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] {α : Type w}\n\nnamespace CategoryTheory.Limits\n\nnamespace CoproductsFromFiniteFiltered\n\nattribute [local tidy] tactic.case_bash\n\n#print CategoryTheory.Limits.CoproductsFromFiniteFiltered.liftToFinset /-\n/-- If `C` has finite coproducts, a functor `discrete α ⥤ C` lifts to a functor\n    `finset (discrete α) ⥤ C` by taking coproducts. -/\n@[simps]\ndef liftToFinset [HasFiniteCoproducts C] (F : Discrete α ⥤ C) : Finset (Discrete α) ⥤ C\n    where\n  obj s := ∐ fun x : s => F.obj x\n  map s t h := Sigma.desc fun y => Sigma.ι (fun x : t => F.obj x) ⟨y, h.down.down y.2⟩\n#align category_theory.limits.coproducts_from_finite_filtered.lift_to_finset CategoryTheory.Limits.CoproductsFromFiniteFiltered.liftToFinset\n-/\n\n#print CategoryTheory.Limits.CoproductsFromFiniteFiltered.liftToFinsetColimitCocone /-\n/-- If `C` has finite coproducts and filtered colimits, we can construct arbitrary coproducts by\n    taking the colimit of the diagram formed by the coproducts of finite sets over the indexing\n    type. -/\n@[simps]\ndef liftToFinsetColimitCocone [HasFiniteCoproducts C] [HasFilteredColimitsOfSize.{w, w} C]\n    [DecidableEq α] (F : Discrete α ⥤ C) : ColimitCocone F\n    where\n  Cocone :=\n    { pt := colimit (liftToFinset F)\n      ι :=\n        Discrete.natTrans fun j =>\n          @Sigma.ι _ _ _ (fun x : ({j} : Finset (Discrete α)) => F.obj x) _ ⟨j, by simp⟩ ≫\n            colimit.ι (liftToFinset F) {j} }\n  IsColimit :=\n    { desc := fun s =>\n        colimit.desc (liftToFinset F)\n          { pt := s.pt\n            ι := { app := fun t => Sigma.desc fun x => s.ι.app x } }\n      uniq := fun s m h => by\n        ext (t⟨⟨j, hj⟩⟩)\n        convert h j using 1\n        · simp [← colimit.w (lift_to_finset F) ⟨⟨Finset.singleton_subset_iff.2 hj⟩⟩]\n          rfl\n        · tidy }\n#align category_theory.limits.coproducts_from_finite_filtered.lift_to_finset_colimit_cocone CategoryTheory.Limits.CoproductsFromFiniteFiltered.liftToFinsetColimitCocone\n-/\n\nend CoproductsFromFiniteFiltered\n\nopen CoproductsFromFiniteFiltered\n\n#print CategoryTheory.Limits.hasCoproducts_of_finite_and_filtered /-\ntheorem hasCoproducts_of_finite_and_filtered [HasFiniteCoproducts C]\n    [HasFilteredColimitsOfSize.{w, w} C] : HasCoproducts.{w} C := fun α => by\n  classical exact ⟨fun F => has_colimit.mk (lift_to_finset_colimit_cocone F)⟩\n#align category_theory.limits.has_coproducts_of_finite_and_filtered CategoryTheory.Limits.hasCoproducts_of_finite_and_filtered\n-/\n\n#print CategoryTheory.Limits.has_colimits_of_finite_and_filtered /-\ntheorem has_colimits_of_finite_and_filtered [HasFiniteColimits C]\n    [HasFilteredColimitsOfSize.{w, w} C] : HasColimitsOfSize.{w, w} C :=\n  have : HasCoproducts.{w} C := hasCoproducts_of_finite_and_filtered\n  has_colimits_of_has_coequalizers_and_coproducts\n#align category_theory.limits.has_colimits_of_finite_and_filtered CategoryTheory.Limits.has_colimits_of_finite_and_filtered\n-/\n\n#print CategoryTheory.Limits.hasProducts_of_finite_and_cofiltered /-\ntheorem hasProducts_of_finite_and_cofiltered [HasFiniteProducts C]\n    [HasCofilteredLimitsOfSize.{w, w} C] : HasProducts.{w} C :=\n  have : HasCoproducts.{w} Cᵒᵖ := hasCoproducts_of_finite_and_filtered\n  has_products_of_opposite\n#align category_theory.limits.has_products_of_finite_and_cofiltered CategoryTheory.Limits.hasProducts_of_finite_and_cofiltered\n-/\n\n#print CategoryTheory.Limits.has_limits_of_finite_and_cofiltered /-\ntheorem has_limits_of_finite_and_cofiltered [HasFiniteLimits C]\n    [HasCofilteredLimitsOfSize.{w, w} C] : HasLimitsOfSize.{w, w} C :=\n  have : HasProducts.{w} C := hasProducts_of_finite_and_cofiltered\n  has_limits_of_has_equalizers_and_products\n#align category_theory.limits.has_limits_of_finite_and_cofiltered CategoryTheory.Limits.has_limits_of_finite_and_cofiltered\n-/\n\nend CategoryTheory.Limits\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Constructions/Filtered.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.47511739529389657}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Yaël Dillies\n\n! This file was ported from Lean 3 source module order.disjointed\n! leanprover-community/mathlib commit 68d1483e8a718ec63219f0e227ca3f0140361086\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.PartialSups\n\n/-!\n# Consecutive differences of sets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the way to make a sequence of elements into a sequence of disjoint elements with\nthe same partial sups.\n\nFor a sequence `f : ℕ → α`, this new sequence will be `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 ⊔ f 1)`.\nIt is actually unique, as `disjointed_unique` shows.\n\n## Main declarations\n\n* `disjointed f`: The sequence `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 ⊔ f 1)`, ....\n* `partial_sups_disjointed`: `disjointed f` has the same partial sups as `f`.\n* `disjoint_disjointed`: The elements of `disjointed f` are pairwise disjoint.\n* `disjointed_unique`: `disjointed f` is the only pairwise disjoint sequence having the same partial\n  sups as `f`.\n* `supr_disjointed`: `disjointed f` has the same supremum as `f`. Limiting case of\n  `partial_sups_disjointed`.\n\nWe also provide set notation variants of some lemmas.\n\n## TODO\n\nFind a useful statement of `disjointed_rec_succ`.\n\nOne could generalize `disjointed` to any locally finite bot preorder domain, in place of `ℕ`.\nRelated to the TODO in the module docstring of `order.partial_sups`.\n-/\n\n\nvariable {α β : Type _}\n\nsection GeneralizedBooleanAlgebra\n\nvariable [GeneralizedBooleanAlgebra α]\n\n#print disjointed /-\n/-- If `f : ℕ → α` is a sequence of elements, then `disjointed f` is the sequence formed by\nsubtracting each element from the nexts. This is the unique disjoint sequence whose partial sups\nare the same as the original sequence. -/\ndef disjointed (f : ℕ → α) : ℕ → α\n  | 0 => f 0\n  | n + 1 => f (n + 1) \\ partialSups f n\n#align disjointed disjointed\n-/\n\n#print disjointed_zero /-\n@[simp]\ntheorem disjointed_zero (f : ℕ → α) : disjointed f 0 = f 0 :=\n  rfl\n#align disjointed_zero disjointed_zero\n-/\n\n/- warning: disjointed_succ -> disjointed_succ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] (f : Nat -> α) (n : Nat), Eq.{succ u1} α (disjointed.{u1} α _inst_1 f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toHasSdiff.{u1} α _inst_1) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (coeFn.{succ u1, succ u1} (OrderHom.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (SemilatticeSup.toPartialOrder.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (fun (_x : OrderHom.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (SemilatticeSup.toPartialOrder.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) => Nat -> α) (OrderHom.hasCoeToFun.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (SemilatticeSup.toPartialOrder.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (partialSups.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) f) n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] (f : Nat -> α) (n : Nat), Eq.{succ u1} α (disjointed.{u1} α _inst_1 f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toSDiff.{u1} α _inst_1) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (OrderHom.toFun.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (SemilatticeSup.toPartialOrder.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))))) (partialSups.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) f) n))\nCase conversion may be inaccurate. Consider using '#align disjointed_succ disjointed_succₓ'. -/\ntheorem disjointed_succ (f : ℕ → α) (n : ℕ) : disjointed f (n + 1) = f (n + 1) \\ partialSups f n :=\n  rfl\n#align disjointed_succ disjointed_succ\n\n#print disjointed_le_id /-\ntheorem disjointed_le_id : disjointed ≤ (id : (ℕ → α) → ℕ → α) :=\n  by\n  rintro f n\n  cases n\n  · rfl\n  · exact sdiff_le\n#align disjointed_le_id disjointed_le_id\n-/\n\n#print disjointed_le /-\ntheorem disjointed_le (f : ℕ → α) : disjointed f ≤ f :=\n  disjointed_le_id f\n#align disjointed_le disjointed_le\n-/\n\n#print disjoint_disjointed /-\ntheorem disjoint_disjointed (f : ℕ → α) : Pairwise (Disjoint on disjointed f) :=\n  by\n  refine' (Symmetric.pairwise_on Disjoint.symm _).2 fun m n h => _\n  cases n\n  · exact (Nat.not_lt_zero _ h).elim\n  exact\n    disjoint_sdiff_self_right.mono_left\n      ((disjointed_le f m).trans (le_partialSups_of_le f (Nat.lt_add_one_iff.1 h)))\n#align disjoint_disjointed disjoint_disjointed\n-/\n\n/- warning: disjointed_rec -> disjointedRec is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] {f : Nat -> α} {p : α -> Sort.{u2}}, (forall {{t : α}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toHasSdiff.{u1} α _inst_1) t (f i)))) -> (forall {{n : Nat}}, (p (f n)) -> (p (disjointed.{u1} α _inst_1 f n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] {f : Nat -> α} {p : α -> Sort.{u2}}, (forall {{t : α}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toSDiff.{u1} α _inst_1) t (f i)))) -> (forall {{n : Nat}}, (p (f n)) -> (p (disjointed.{u1} α _inst_1 f n)))\nCase conversion may be inaccurate. Consider using '#align disjointed_rec disjointedRecₓ'. -/\n/-- An induction principle for `disjointed`. To define/prove something on `disjointed f n`, it's\nenough to define/prove it for `f n` and being able to extend through diffs. -/\ndef disjointedRec {f : ℕ → α} {p : α → Sort _} (hdiff : ∀ ⦃t i⦄, p t → p (t \\ f i)) :\n    ∀ ⦃n⦄, p (f n) → p (disjointed f n)\n  | 0 => id\n  | n + 1 => fun h => by\n    suffices H : ∀ k, p (f (n + 1) \\ partialSups f k)\n    · exact H n\n    rintro k\n    induction' k with k ih\n    · exact hdiff h\n    rw [partialSups_succ, ← sdiff_sdiff_left]\n    exact hdiff ih\n#align disjointed_rec disjointedRec\n\n/- warning: disjointed_rec_zero -> disjointedRec_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] {f : Nat -> α} {p : α -> Sort.{u2}} (hdiff : forall {{t : α}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toHasSdiff.{u1} α _inst_1) t (f i)))) (h₀ : p (f (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))), Eq.{u2} (p (disjointed.{u1} α _inst_1 (fun (i : Nat) => f i) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))) (disjointedRec.{u1, u2} α _inst_1 (fun (i : Nat) => f i) (fun (t : α) => p t) hdiff (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) h₀) h₀\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] {f : Nat -> α} {p : α -> Sort.{u2}} (hdiff : forall {{t : α}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toSDiff.{u1} α _inst_1) t (f i)))) (h₀ : p (f (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))), Eq.{u2} (p (disjointed.{u1} α _inst_1 (fun (i : Nat) => f i) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))) (disjointedRec.{u1, u2} α _inst_1 (fun (i : Nat) => f i) (fun (t : α) => p t) hdiff (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) h₀) h₀\nCase conversion may be inaccurate. Consider using '#align disjointed_rec_zero disjointedRec_zeroₓ'. -/\n@[simp]\ntheorem disjointedRec_zero {f : ℕ → α} {p : α → Sort _} (hdiff : ∀ ⦃t i⦄, p t → p (t \\ f i))\n    (h₀ : p (f 0)) : disjointedRec hdiff h₀ = h₀ :=\n  rfl\n#align disjointed_rec_zero disjointedRec_zero\n\n/- warning: monotone.disjointed_eq -> Monotone.disjointed_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] {f : Nat -> α}, (Monotone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))))) f) -> (forall (n : Nat), Eq.{succ u1} α (disjointed.{u1} α _inst_1 f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toHasSdiff.{u1} α _inst_1) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (f n)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} α] {f : Nat -> α}, (Monotone.{0, u1} Nat α (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))))) f) -> (forall (n : Nat), Eq.{succ u1} α (disjointed.{u1} α _inst_1 f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (SDiff.sdiff.{u1} α (GeneralizedBooleanAlgebra.toSDiff.{u1} α _inst_1) (f (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (f n)))\nCase conversion may be inaccurate. Consider using '#align monotone.disjointed_eq Monotone.disjointed_eqₓ'. -/\n-- TODO: Find a useful statement of `disjointed_rec_succ`.\ntheorem Monotone.disjointed_eq {f : ℕ → α} (hf : Monotone f) (n : ℕ) :\n    disjointed f (n + 1) = f (n + 1) \\ f n := by rw [disjointed_succ, hf.partial_sups_eq]\n#align monotone.disjointed_eq Monotone.disjointed_eq\n\n#print partialSups_disjointed /-\n@[simp]\ntheorem partialSups_disjointed (f : ℕ → α) : partialSups (disjointed f) = partialSups f :=\n  by\n  ext n\n  induction' n with k ih\n  · rw [partialSups_zero, partialSups_zero, disjointed_zero]\n  · rw [partialSups_succ, partialSups_succ, disjointed_succ, ih, sup_sdiff_self_right]\n#align partial_sups_disjointed partialSups_disjointed\n-/\n\n#print disjointed_unique /-\n/-- `disjointed f` is the unique sequence that is pairwise disjoint and has the same partial sups\nas `f`. -/\ntheorem disjointed_unique {f d : ℕ → α} (hdisj : Pairwise (Disjoint on d))\n    (hsups : partialSups d = partialSups f) : d = disjointed f :=\n  by\n  ext n\n  cases n\n  · rw [← partialSups_zero d, hsups, partialSups_zero, disjointed_zero]\n  suffices h : d n.succ = partialSups d n.succ \\ partialSups d n\n  · rw [h, hsups, partialSups_succ, disjointed_succ, sup_sdiff, sdiff_self, bot_sup_eq]\n  rw [partialSups_succ, sup_sdiff, sdiff_self, bot_sup_eq, eq_comm, sdiff_eq_self_iff_disjoint]\n  suffices h : ∀ m ≤ n, Disjoint (partialSups d m) (d n.succ)\n  · exact h n le_rfl\n  rintro m hm\n  induction' m with m ih\n  · exact hdisj (Nat.succ_ne_zero _).symm\n  rw [partialSups_succ, disjoint_iff, inf_sup_right, sup_eq_bot_iff, ← disjoint_iff, ← disjoint_iff]\n  exact ⟨ih (Nat.le_of_succ_le hm), hdisj (Nat.lt_succ_of_le hm).Ne⟩\n#align disjointed_unique disjointed_unique\n-/\n\nend GeneralizedBooleanAlgebra\n\nsection CompleteBooleanAlgebra\n\nvariable [CompleteBooleanAlgebra α]\n\n/- warning: supr_disjointed -> supᵢ_disjointed is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} α] (f : Nat -> α), Eq.{succ u1} α (supᵢ.{u1, 1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) Nat (fun (n : Nat) => disjointed.{u1} α (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} α (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} α _inst_1)) f n)) (supᵢ.{u1, 1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) Nat (fun (n : Nat) => f n))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} α] (f : Nat -> α), Eq.{succ u1} α (supᵢ.{u1, 1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) Nat (fun (n : Nat) => disjointed.{u1} α (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} α (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} α _inst_1)) f n)) (supᵢ.{u1, 1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) Nat (fun (n : Nat) => f n))\nCase conversion may be inaccurate. Consider using '#align supr_disjointed supᵢ_disjointedₓ'. -/\ntheorem supᵢ_disjointed (f : ℕ → α) : (⨆ n, disjointed f n) = ⨆ n, f n :=\n  supᵢ_eq_supᵢ_of_partialSups_eq_partialSups (partialSups_disjointed f)\n#align supr_disjointed supᵢ_disjointed\n\n/- warning: disjointed_eq_inf_compl -> disjointed_eq_inf_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} α] (f : Nat -> α) (n : Nat), Eq.{succ u1} α (disjointed.{u1} α (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} α (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} α _inst_1)) f n) (Inf.inf.{u1} α (SemilatticeInf.toHasInf.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))))) (f n) (infᵢ.{u1, 1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) Nat (fun (i : Nat) => infᵢ.{u1, 0} α (ConditionallyCompleteLattice.toHasInf.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) (LT.lt.{0} Nat Nat.hasLt i n) (fun (H : LT.lt.{0} Nat Nat.hasLt i n) => HasCompl.compl.{u1} α (BooleanAlgebra.toHasCompl.{u1} α (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} α _inst_1)) (f i)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} α] (f : Nat -> α) (n : Nat), Eq.{succ u1} α (disjointed.{u1} α (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} α (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} α _inst_1)) f n) (Inf.inf.{u1} α (Lattice.toInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1)))))) (f n) (infᵢ.{u1, 1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) Nat (fun (i : Nat) => infᵢ.{u1, 0} α (ConditionallyCompleteLattice.toInfSet.{u1} α (CompleteLattice.toConditionallyCompleteLattice.{u1} α (Order.Coframe.toCompleteLattice.{u1} α (CompleteDistribLattice.toCoframe.{u1} α (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} α _inst_1))))) (LT.lt.{0} Nat instLTNat i n) (fun (H : LT.lt.{0} Nat instLTNat i n) => HasCompl.compl.{u1} α (BooleanAlgebra.toHasCompl.{u1} α (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} α _inst_1)) (f i)))))\nCase conversion may be inaccurate. Consider using '#align disjointed_eq_inf_compl disjointed_eq_inf_complₓ'. -/\ntheorem disjointed_eq_inf_compl (f : ℕ → α) (n : ℕ) : disjointed f n = f n ⊓ ⨅ i < n, f iᶜ :=\n  by\n  cases n\n  · rw [disjointed_zero, eq_comm, inf_eq_left]\n    simp_rw [le_infᵢ_iff]\n    exact fun i hi => (i.not_lt_zero hi).elim\n  simp_rw [disjointed_succ, partialSups_eq_bsupᵢ, sdiff_eq, compl_supᵢ]\n  congr\n  ext i\n  rw [Nat.lt_succ_iff]\n#align disjointed_eq_inf_compl disjointed_eq_inf_compl\n\nend CompleteBooleanAlgebra\n\n/-! ### Set notation variants of lemmas -/\n\n\n/- warning: disjointed_subset -> disjointed_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Nat -> (Set.{u1} α)) (n : Nat), HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) f n) (f n)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Nat -> (Set.{u1} α)) (n : Nat), HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) f n) (f n)\nCase conversion may be inaccurate. Consider using '#align disjointed_subset disjointed_subsetₓ'. -/\ntheorem disjointed_subset (f : ℕ → Set α) (n : ℕ) : disjointed f n ⊆ f n :=\n  disjointed_le f n\n#align disjointed_subset disjointed_subset\n\n/- warning: Union_disjointed -> unionᵢ_disjointed is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Nat -> (Set.{u1} α)}, Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) f n)) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => f n))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Nat -> (Set.{u1} α)}, Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) f n)) (Set.unionᵢ.{u1, 1} α Nat (fun (n : Nat) => f n))\nCase conversion may be inaccurate. Consider using '#align Union_disjointed unionᵢ_disjointedₓ'. -/\ntheorem unionᵢ_disjointed {f : ℕ → Set α} : (⋃ n, disjointed f n) = ⋃ n, f n :=\n  supᵢ_disjointed f\n#align Union_disjointed unionᵢ_disjointed\n\n/- warning: disjointed_eq_inter_compl -> disjointed_eq_inter_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Nat -> (Set.{u1} α)) (n : Nat), Eq.{succ u1} (Set.{u1} α) (disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) f n) (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (f n) (Set.interᵢ.{u1, 1} α Nat (fun (i : Nat) => Set.interᵢ.{u1, 0} α (LT.lt.{0} Nat Nat.hasLt i n) (fun (H : LT.lt.{0} Nat Nat.hasLt i n) => HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) (f i)))))\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Nat -> (Set.{u1} α)) (n : Nat), Eq.{succ u1} (Set.{u1} α) (disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) f n) (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (f n) (Set.interᵢ.{u1, 1} α Nat (fun (i : Nat) => Set.interᵢ.{u1, 0} α (LT.lt.{0} Nat instLTNat i n) (fun (H : LT.lt.{0} Nat instLTNat i n) => HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) (f i)))))\nCase conversion may be inaccurate. Consider using '#align disjointed_eq_inter_compl disjointed_eq_inter_complₓ'. -/\ntheorem disjointed_eq_inter_compl (f : ℕ → Set α) (n : ℕ) : disjointed f n = f n ∩ ⋂ i < n, f iᶜ :=\n  disjointed_eq_inf_compl f n\n#align disjointed_eq_inter_compl disjointed_eq_inter_compl\n\n/- warning: preimage_find_eq_disjointed -> preimage_find_eq_disjointed is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Nat -> (Set.{u1} α)) (H : forall (x : α), Exists.{1} Nat (fun (n : Nat) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (s n))) [_inst_1 : forall (x : α) (n : Nat), Decidable (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (s n))] (n : Nat), Eq.{succ u1} (Set.{u1} α) (Set.preimage.{u1, 0} α Nat (fun (x : α) => Nat.find (fun (n : Nat) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (s n)) (fun (a : Nat) => _inst_1 x a) (H x)) (Singleton.singleton.{0, 0} Nat (Set.{0} Nat) (Set.hasSingleton.{0} Nat) n)) (disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s n)\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Nat -> (Set.{u1} α)) (H : forall (x : α), Exists.{1} Nat (fun (n : Nat) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (s n))) [_inst_1 : forall (x : α) (n : Nat), Decidable (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (s n))] (n : Nat), Eq.{succ u1} (Set.{u1} α) (Set.preimage.{u1, 0} α Nat (fun (x : α) => Nat.find (fun (n : Nat) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (s n)) (fun (a : Nat) => _inst_1 x a) (H x)) (Singleton.singleton.{0, 0} Nat (Set.{0} Nat) (Set.instSingletonSet.{0} Nat) n)) (disjointed.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s n)\nCase conversion may be inaccurate. Consider using '#align preimage_find_eq_disjointed preimage_find_eq_disjointedₓ'. -/\ntheorem preimage_find_eq_disjointed (s : ℕ → Set α) (H : ∀ x, ∃ n, x ∈ s n)\n    [∀ x n, Decidable (x ∈ s n)] (n : ℕ) : (fun x => Nat.find (H x)) ⁻¹' {n} = disjointed s n :=\n  by\n  ext x\n  simp [Nat.find_eq_iff, disjointed_eq_inter_compl]\n#align preimage_find_eq_disjointed preimage_find_eq_disjointed\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Disjointed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.4751173908470659}}
{"text": "/-\nCopyright (c) 2018 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Scott Morrison\n-/\nimport category_theory.opposites\n\n/-!\n# Morphisms from equations between objects.\n\nWhen working categorically, sometimes one encounters an equation `h : X = Y` between objects.\n\nYour initial aversion to this is natural and appropriate:\nyou're in for some trouble, and if there is another way to approach the problem that won't\nrely on this equality, it may be worth pursuing.\n\nYou have two options:\n1. Use the equality `h` as one normally would in Lean (e.g. using `rw` and `subst`).\n   This may immediately cause difficulties, because in category theory everything is dependently\n   typed, and equations between objects quickly lead to nasty goals with `eq.rec`.\n2. Promote `h` to a morphism using `eq_to_hom h : X ⟶ Y`, or `eq_to_iso h : X ≅ Y`.\n\nThis file introduces various `simp` lemmas which in favourable circumstances\nresult in the various `eq_to_hom` morphisms to drop out at the appropriate moment!\n-/\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n-- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen opposite\n\nvariables {C : Type u₁} [category.{v₁} C]\n\n/--\nAn equality `X = Y` gives us a morphism `X ⟶ Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `𝟙 _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_hom {X Y : C} (p : X = Y) : X ⟶ Y := by rw p; exact 𝟙 _\n\n@[simp] lemma eq_to_hom_refl (X : C) (p : X = X) : eq_to_hom p = 𝟙 X := rfl\n@[simp, reassoc] lemma eq_to_hom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) :\n  eq_to_hom p ≫ eq_to_hom q = eq_to_hom (p.trans q) :=\nby { cases p, cases q, simp, }\n\n/--\nIf we (perhaps unintentionally) perform equational rewriting on\nthe source object of a morphism,\nwe can replace the resulting `_.mpr f` term by a composition with an `eq_to_hom`.\n\nIt may be advisable to introduce any necessary `eq_to_hom` morphisms manually,\nrather than relying on this lemma firing.\n-/\n@[simp]\nlemma congr_arg_mpr_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) :\n  (congr_arg (λ W : C, W ⟶ Z) p).mpr q = eq_to_hom p ≫ q :=\nby { cases p, simp, }\n\n/--\nIf we (perhaps unintentionally) perform equational rewriting on\nthe target object of a morphism,\nwe can replace the resulting `_.mpr f` term by a composition with an `eq_to_hom`.\n\nIt may be advisable to introduce any necessary `eq_to_hom` morphisms manually,\nrather than relying on this lemma firing.\n-/\n@[simp]\nlemma congr_arg_mpr_hom_right {X Y Z : C} (p : X ⟶ Y) (q : Z = Y) :\n  (congr_arg (λ W : C, X ⟶ W) q).mpr p = p ≫ eq_to_hom q.symm :=\nby { cases q, simp, }\n\n/--\nAn equality `X = Y` gives us an isomorphism `X ≅ Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `iso.refl _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_iso {X Y : C} (p : X = Y) : X ≅ Y :=\n⟨eq_to_hom p, eq_to_hom p.symm, by simp, by simp⟩\n\n@[simp] lemma eq_to_iso.hom {X Y : C} (p : X = Y) : (eq_to_iso p).hom = eq_to_hom p :=\nrfl\n@[simp] lemma eq_to_iso.inv {X Y : C} (p : X = Y) : (eq_to_iso p).inv = eq_to_hom p.symm :=\nrfl\n\n@[simp] \n\n@[simp] lemma eq_to_hom_op {X Y : C} (h : X = Y) :\n  (eq_to_hom h).op = eq_to_hom (congr_arg op h.symm) :=\nby { cases h, refl, }\n\n@[simp] lemma eq_to_hom_unop {X Y : Cᵒᵖ} (h : X = Y) :\n  (eq_to_hom h).unop = eq_to_hom (congr_arg unop h.symm) :=\nby { cases h, refl, }\n\ninstance {X Y : C} (h : X = Y) : is_iso (eq_to_hom h) := is_iso.of_iso (eq_to_iso h)\n\n@[simp] lemma inv_eq_to_hom {X Y : C} (h : X = Y) : inv (eq_to_hom h) = eq_to_hom h.symm :=\nby { ext, simp, }\n\nvariables {D : Type u₂} [category.{v₂} D]\n\nnamespace functor\n\n/-- Proving equality between functors. This isn't an extensionality lemma,\n  because usually you don't really want to do this. -/\nlemma ext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ X Y f, F.map f = eq_to_hom (h_obj X) ≫ G.map f ≫ eq_to_hom (h_obj Y).symm) :\n  F = G :=\nbegin\n  cases F with F_obj _ _ _, cases G with G_obj _ _ _,\n  have : F_obj = G_obj, by ext X; apply h_obj,\n  subst this,\n  congr,\n  funext X Y f,\n  simpa using h_map X Y f\nend\n\n/-- Two morphisms are conjugate via eq_to_hom if and only if they are heterogeneously equal. --/\nlemma conj_eq_to_hom_iff_heq {W X Y Z : C} (f : W ⟶ X) (g : Y ⟶ Z) (h : W = Y) (h' : X = Z) :\n  f = eq_to_hom h ≫ g ≫ eq_to_hom h'.symm ↔ f == g :=\nby { cases h, cases h', simp }\n\n/-- Proving equality between functors using heterogeneous equality. -/\nlemma hext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ X Y (f : X ⟶ Y), F.map f == G.map f) : F = G :=\nfunctor.ext h_obj (λ _ _ f,\n  (conj_eq_to_hom_iff_heq _ _ (h_obj _) (h_obj _)).2 $ h_map _ _ f)\n\n-- Using equalities between functors.\n\nlemma congr_obj {F G : C ⥤ D} (h : F = G) (X) : F.obj X = G.obj X :=\nby subst h\n\nlemma congr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) :\n  F.map f = eq_to_hom (congr_obj h X) ≫ G.map f ≫ eq_to_hom (congr_obj h Y).symm :=\nby subst h; simp\n\nsection heq\n\n/- Composition of functors and maps w.r.t. heq -/\n\nvariables {E : Type u₃} [category.{v₃} E] {F G : C ⥤ D} {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z}\n\nlemma map_comp_heq (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y) (hz : F.obj Z = G.obj Z)\n  (hf : F.map f == G.map f) (hg : F.map g == G.map g) : F.map (f ≫ g) == G.map (f ≫ g) :=\nby { rw [F.map_comp, G.map_comp], congr' }\n\nlemma map_comp_heq' (hobj : ∀ X : C, F.obj X = G.obj X)\n  (hmap : ∀ {X Y} (f : X ⟶ Y), F.map f == G.map f) :\n  F.map (f ≫ g) == G.map (f ≫ g) :=\nby rw functor.hext hobj (λ _ _, hmap)\n\nlemma precomp_map_heq (H : E ⥤ C)\n  (hmap : ∀ {X Y} (f : X ⟶ Y), F.map f == G.map f) {X Y : E} (f : X ⟶ Y) :\n  (H ⋙ F).map f == (H ⋙ G).map f := hmap _\n\nlemma postcomp_map_heq (H : D ⥤ E) (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y)\n  (hmap : F.map f == G.map f) : (F ⋙ H).map f == (G ⋙ H).map f :=\nby { dsimp, congr' }\n\nlemma postcomp_map_heq' (H : D ⥤ E) (hobj : ∀ X : C, F.obj X = G.obj X)\n  (hmap : ∀ {X Y} (f : X ⟶ Y), F.map f == G.map f) :\n  (F ⋙ H).map f == (G ⋙ H).map f :=\nby rw functor.hext hobj (λ _ _, hmap)\n\nlemma hcongr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) : F.map f == G.map f :=\nby subst h\n\nend heq\n\nend functor\n\n@[simp] lemma eq_to_hom_map (F : C ⥤ D) {X Y : C} (p : X = Y) :\n  F.map (eq_to_hom p) = eq_to_hom (congr_arg F.obj p) :=\nby cases p; simp\n\n@[simp] lemma eq_to_iso_map (F : C ⥤ D) {X Y : C} (p : X = Y) :\n  F.map_iso (eq_to_iso p) = eq_to_iso (congr_arg F.obj p) :=\nby ext; cases p; simp\n\n@[simp] lemma eq_to_hom_app {F G : C ⥤ D} (h : F = G) (X : C) :\n  (eq_to_hom h : F ⟶ G).app X = eq_to_hom (functor.congr_obj h X) :=\nby subst h; refl\n\nlemma nat_trans.congr {F G : C ⥤ D} (α : F ⟶ G) {X Y : C} (h : X = Y) :\n  α.app X = F.map (eq_to_hom h) ≫ α.app Y ≫ G.map (eq_to_hom h.symm) :=\nby { rw [α.naturality_assoc], simp }\n\nlemma eq_conj_eq_to_hom {X Y : C} (f : X ⟶ Y) :\n  f = eq_to_hom rfl ≫ f ≫ eq_to_hom rfl :=\nby simp only [category.id_comp, eq_to_hom_refl, category.comp_id]\n\nlemma dcongr_arg {ι : Type*} {F G : ι → C} (α : ∀ i, F i ⟶ G i) {i j : ι} (h : i = j) :\n  α i = eq_to_hom (congr_arg F h) ≫ α j ≫ eq_to_hom (congr_arg G h.symm) :=\nby { subst h, simp }\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/eq_to_hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.4751173864002353}}
{"text": "/-\nCopyright (c) 2020 Kevin Buzzard, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Bhavik Mehta\n-/\n\nimport category_theory.sites.sheaf_of_types\nimport category_theory.limits.yoneda\nimport category_theory.limits.preserves.shapes.equalizers\nimport category_theory.limits.preserves.shapes.products\nimport category_theory.concrete_category\n\n/-!\n# Sheaves taking values in a category\n\nIf C is a category with a Grothendieck topology, we define the notion of a sheaf taking values in\nan arbitrary category `A`. We follow the definition in https://stacks.math.columbia.edu/tag/00VR,\nnoting that the presheaf of sets \"defined above\" can be seen in the comments between tags 00VQ and\n00VR on the page https://stacks.math.columbia.edu/tag/00VL. The advantage of this definition is\nthat we need no assumptions whatsoever on `A` other than the assumption that the morphisms in `C`\nand `A` live in the same universe.\n\n* An `A`-valued presheaf `P : Cᵒᵖ ⥤ A` is defined to be a sheaf (for the topology `J`) iff for\n  every `X : A`, the type-valued presheaves of sets given by sending `U : Cᵒᵖ` to `Hom_{A}(X, P U)`\n  are all sheaves of sets, see `category_theory.presheaf.is_sheaf`.\n* When `A = Type`, this recovers the basic definition of sheaves of sets, see\n  `category_theory.is_sheaf_iff_is_sheaf_of_type`.\n* An alternate definition when `C` is small, has pullbacks and `A` has products is given by an\n  equalizer condition `category_theory.presheaf.is_sheaf'`. This is equivalent to the earlier\n  definition, shown in `category_theory.presheaf.is_sheaf_iff_is_sheaf'`.\n* When `A = Type`, this is *definitionally* equal to the equalizer condition for presieves in\n  `category_theory.sites.sheaf_of_types`.\n* When `A` has limits and there is a functor `s : A ⥤ Type` which is faithful, reflects isomorphisms\n  and preserves limits, then `P : C^op ⥤ A` is a sheaf iff the underlying presheaf of types\n  `P ⋙ s : C^op ⥤ Type` is a sheaf (`category_theory.presheaf.is_sheaf_iff_is_sheaf_forget`).\n  Cf https://stacks.math.columbia.edu/tag/0073, which is a weaker version of this statement (it's\n  only over spaces, not sites) and https://stacks.math.columbia.edu/tag/00YR (a), which\n  additionally assumes filtered colimits.\n-/\n\nuniverses v v' u' u\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen opposite category_theory category limits sieve classical\n\nnamespace presheaf\n\nvariables {C : Type u} [category.{v} C]\nvariables {A : Type u'} [category.{v} A]\nvariables (J : grothendieck_topology C)\n\n-- We follow https://stacks.math.columbia.edu/tag/00VL definition 00VR\n\n/--\nA sheaf of A is a presheaf P : C^op => A such that for every X : A, the\npresheaf of types given by sending U : C to Hom_{A}(X, P U) is a sheaf of types.\n\nhttps://stacks.math.columbia.edu/tag/00VR\n-/\ndef is_sheaf (P : Cᵒᵖ ⥤ A) : Prop :=\n∀ X : A, presieve.is_sheaf J (P ⋙ coyoneda.obj (op X))\n\nend presheaf\n\nvariables {C : Type u} [category.{v} C]\nvariables (J : grothendieck_topology C)\nvariables (A : Type u') [category.{v} A]\n\n/-- The category of sheaves taking values in `A` on a grothendieck topology. -/\n@[derive category]\ndef Sheaf : Type* :=\n{P : Cᵒᵖ ⥤ A // presheaf.is_sheaf J P}\n\n/-- The inclusion functor from sheaves to presheaves. -/\n@[simps {rhs_md := semireducible}, derive [full, faithful]]\ndef Sheaf_to_presheaf : Sheaf J A ⥤ (Cᵒᵖ ⥤ A) :=\nfull_subcategory_inclusion (presheaf.is_sheaf J)\n\nlemma is_sheaf_iff_is_sheaf_of_type (P : Cᵒᵖ ⥤ Type v) :\n  presheaf.is_sheaf J P ↔ presieve.is_sheaf J P :=\nbegin\n  split,\n  { intros hP,\n    exact presieve.is_sheaf_iso J (coyoneda.iso_comp_punit _) (hP punit) },\n  { intros hP X Y S hS z hz,\n    refine ⟨λ x, (hP S hS).amalgamate (λ Z f hf, z f hf x) _, _, _⟩,\n    { intros Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ h,\n      exact congr_fun (hz g₁ g₂ hf₁ hf₂ h) x },\n    { intros Z f hf,\n      ext x,\n      apply presieve.is_sheaf_for.valid_glue },\n    { intros y hy,\n      ext x,\n      apply (hP S hS).is_separated_for.ext,\n      intros Y' f hf,\n      rw [presieve.is_sheaf_for.valid_glue _ _ _ hf, ← hy _ hf],\n      refl } }\nend\n\n/--\nThe category of sheaves taking values in Type is the same as the category of set-valued sheaves.\n-/\n@[simps]\ndef Sheaf_equiv_SheafOfTypes : Sheaf J (Type v) ≌ SheafOfTypes J :=\n{ functor :=\n  { obj := λ S, ⟨S.1, (is_sheaf_iff_is_sheaf_of_type _ _).1 S.2⟩,\n    map := λ S₁ S₂ f, f },\n  inverse :=\n  { obj := λ S, ⟨S.1, (is_sheaf_iff_is_sheaf_of_type _ _).2 S.2⟩,\n    map := λ S₁ S₂ f, f },\n  unit_iso := nat_iso.of_components (λ X, ⟨𝟙 _, 𝟙 _, by tidy, by tidy⟩) (by tidy),\n  counit_iso := nat_iso.of_components (λ X, ⟨𝟙 _, 𝟙 _, by tidy, by tidy⟩) (by tidy) }\n\ninstance : inhabited (Sheaf (⊥ : grothendieck_topology C) (Type v)) :=\n⟨(Sheaf_equiv_SheafOfTypes _).inverse.obj (default _)⟩\n\nend category_theory\n\nnamespace category_theory\n\nopen opposite category_theory category limits sieve classical\n\nnamespace presheaf\n\n-- Under here is the equalizer story, which is equivalent if A has products (and doesn't\n-- make sense otherwise). It's described in https://stacks.math.columbia.edu/tag/00VL,\n-- between 00VQ and 00VR.\n\nvariables {C : Type v} [small_category C]\nvariables {A : Type u} [category.{v} A]\nvariables (J : grothendieck_topology C)\nvariables {U : C} (R : presieve U)\nvariables (P : Cᵒᵖ ⥤ A)\n\nsection\n\nvariables [has_products A]\n\n/--\nThe middle object of the fork diagram given in Equation (3) of [MM92], as well as the fork diagram\nof https://stacks.math.columbia.edu/tag/00VM.\n-/\ndef first_obj : A :=\n∏ (λ (f : Σ V, {f : V ⟶ U // R f}), P.obj (op f.1))\n\n/--\nThe left morphism of the fork diagram given in Equation (3) of [MM92], as well as the fork diagram\nof https://stacks.math.columbia.edu/tag/00VM.\n-/\ndef fork_map : P.obj (op U) ⟶ first_obj R P :=\npi.lift (λ f, P.map f.2.1.op)\n\nvariables [has_pullbacks C]\n\n/--\nThe rightmost object of the fork diagram of https://stacks.math.columbia.edu/tag/00VM, which\ncontains the data used to check a family of elements for a presieve is compatible.\n-/\ndef second_obj : A :=\n∏ (λ (fg : (Σ V, {f : V ⟶ U // R f}) × (Σ W, {g : W ⟶ U // R g})),\n  P.obj (op (pullback fg.1.2.1 fg.2.2.1)))\n\n/-- The map `pr₀*` of https://stacks.math.columbia.edu/tag/00VM. -/\ndef first_map : first_obj R P ⟶ second_obj R P :=\npi.lift (λ fg, pi.π _ _ ≫ P.map pullback.fst.op)\n\n/-- The map `pr₁*` of https://stacks.math.columbia.edu/tag/00VM. -/\ndef second_map : first_obj R P ⟶ second_obj R P :=\npi.lift (λ fg, pi.π _ _ ≫ P.map pullback.snd.op)\n\nlemma w : fork_map R P ≫ first_map R P = fork_map R P ≫ second_map R P :=\nbegin\n  apply limit.hom_ext,\n  rintro ⟨⟨Y, f, hf⟩, ⟨Z, g, hg⟩⟩,\n  simp only [first_map, second_map, fork_map, limit.lift_π, limit.lift_π_assoc, assoc,\n    fan.mk_π_app, subtype.coe_mk, subtype.val_eq_coe],\n  rw [← P.map_comp, ← op_comp, pullback.condition],\n  simp,\nend\n\n/--\nAn alternative definition of the sheaf condition in terms of equalizers. This is shown to be\nequivalent in `category_theory.presheaf.is_sheaf_iff_is_sheaf'`.\n-/\ndef is_sheaf' (P : Cᵒᵖ ⥤ A) : Prop := ∀ (U : C) (R : presieve U) (hR : generate R ∈ J U),\nnonempty (is_limit (fork.of_ι _ (w R P)))\n\n/-- (Implementation). An auxiliary lemma to convert between sheaf conditions. -/\ndef is_sheaf_for_is_sheaf_for' (P : Cᵒᵖ ⥤ A) (s : A ⥤ Type v)\n  [Π J, preserves_limits_of_shape (discrete J) s] (U : C) (R : presieve U) :\n  is_limit (s.map_cone (fork.of_ι _ (w R P))) ≃\n    is_limit (fork.of_ι _ (equalizer.presieve.w (P ⋙ s) R)) :=\nbegin\n  apply equiv.trans (is_limit_map_cone_fork_equiv _ _) _,\n  apply (is_limit.postcompose_hom_equiv _ _).symm.trans (is_limit.equiv_iso_limit _),\n  { apply nat_iso.of_components _ _,\n    { rintro (_ | _),\n      { apply preserves_product.iso s },\n      { apply preserves_product.iso s } },\n    { rintro _ _ (_ | _),\n      { ext : 1,\n        dsimp [equalizer.presieve.first_map, first_map],\n        simp only [limit.lift_π, map_lift_pi_comparison, assoc, fan.mk_π_app, functor.map_comp],\n        erw pi_comparison_comp_π_assoc },\n      { ext : 1,\n        dsimp [equalizer.presieve.second_map, second_map],\n        simp only [limit.lift_π, map_lift_pi_comparison, assoc, fan.mk_π_app, functor.map_comp],\n        erw pi_comparison_comp_π_assoc },\n      { dsimp,\n        simp } } },\n  { refine fork.ext (iso.refl _) _,\n    dsimp [equalizer.fork_map, fork_map],\n    simp }\nend\n\n/-- The equalizer definition of a sheaf given by `is_sheaf'` is equivalent to `is_sheaf`. -/\ntheorem is_sheaf_iff_is_sheaf' :\n  is_sheaf J P ↔ is_sheaf' J P :=\nbegin\n  split,\n  { intros h U R hR,\n    refine ⟨_⟩,\n    apply coyoneda_jointly_reflects_limits,\n    intro X,\n    have q : presieve.is_sheaf_for (P ⋙ coyoneda.obj X) _ := h X.unop _ hR,\n    rw ←presieve.is_sheaf_for_iff_generate at q,\n    rw equalizer.presieve.sheaf_condition at q,\n    replace q := classical.choice q,\n    apply (is_sheaf_for_is_sheaf_for' _ _ _ _).symm q },\n  { intros h U X S hS,\n    rw equalizer.presieve.sheaf_condition,\n    refine ⟨_⟩,\n    refine is_sheaf_for_is_sheaf_for' _ _ _ _ _,\n    apply is_limit_of_preserves,\n    apply classical.choice (h _ S _),\n    simpa }\nend\n\nend\n\nsection concrete\n\nvariables [has_pullbacks C]\n\n/--\nFor a concrete category `(A, s)` where the forgetful functor `s : A ⥤ Type v` preserves limits and\nreflects isomorphisms, and `A` has limits, an `A`-valued presheaf `P : Cᵒᵖ ⥤ A` is a sheaf iff its\nunderlying `Type`-valued presheaf `P ⋙ s : Cᵒᵖ ⥤ Type` is a sheaf.\n\nNote this lemma applies for \"algebraic\" categories, eg groups, abelian groups and rings, but not\nfor the category of topological spaces, topological rings, etc since reflecting isomorphisms doesn't\nhold.\n-/\nlemma is_sheaf_iff_is_sheaf_forget (s : A ⥤ Type v)\n  [has_limits A] [preserves_limits s] [reflects_isomorphisms s] :\n  is_sheaf J P ↔ is_sheaf J (P ⋙ s) :=\nbegin\n  rw [is_sheaf_iff_is_sheaf', is_sheaf_iff_is_sheaf'],\n  apply forall_congr (λ U, _),\n  apply ball_congr (λ R hR, _),\n  letI : reflects_limits s := reflects_limits_of_reflects_isomorphisms,\n  have : is_limit (s.map_cone (fork.of_ι _ (w R P))) ≃ is_limit (fork.of_ι _ (w R (P ⋙ s))) :=\n    is_sheaf_for_is_sheaf_for' P s U R,\n  rw ←equiv.nonempty_iff_nonempty this,\n  split,\n  { exact nonempty.map (λ t, is_limit_of_preserves s t) },\n  { exact nonempty.map (λ t, is_limit_of_reflects s t) }\nend\n\nend concrete\n\nend presheaf\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/sites/sheaf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.47511738640023526}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport order.category.BddLat\nimport order.hom.complete_lattice\n\n/-!\n# The category of complete lattices\n\nThis file defines `CompleteLat`, the category of complete lattices.\n-/\n\nuniverses u\n\nopen category_theory\n\n/-- The category of complete lattices. -/\ndef CompleteLat := bundled complete_lattice\n\nnamespace CompleteLat\n\ninstance : has_coe_to_sort CompleteLat Type* := bundled.has_coe_to_sort\ninstance (X : CompleteLat) : complete_lattice X := X.str\n\n/-- Construct a bundled `CompleteLat` from a `complete_lattice`. -/\ndef of (α : Type*) [complete_lattice α] : CompleteLat := bundled.of α\n\n@[simp] lemma coe_of (α : Type*) [complete_lattice α] : ↥(of α) = α := rfl\n\ninstance : inhabited CompleteLat := ⟨of punit⟩\n\ninstance : bundled_hom @complete_lattice_hom :=\n{ to_fun := λ _ _ _ _, coe_fn,\n  id := @complete_lattice_hom.id,\n  comp := @complete_lattice_hom.comp,\n  hom_ext := λ X Y _ _, by exactI fun_like.coe_injective }\ninstance : large_category.{u} CompleteLat := bundled_hom.category complete_lattice_hom\ninstance : concrete_category CompleteLat := bundled_hom.concrete_category complete_lattice_hom\n\ninstance has_forget_to_BddLat : has_forget₂ CompleteLat BddLat :=\n{ forget₂ := { obj := λ X, BddLat.of X,\n               map := λ X Y, complete_lattice_hom.to_bounded_lattice_hom },\n  forget_comp := rfl }\n\n/-- Constructs an isomorphism of complete lattices from an order isomorphism between them. -/\n@[simps] def iso.mk {α β : CompleteLat.{u}} (e : α ≃o β) : α ≅ β :=\n{ hom := e,\n  inv := e.symm,\n  hom_inv_id' := by { ext, exact e.symm_apply_apply _ },\n  inv_hom_id' := by { ext, exact e.apply_symm_apply _ } }\n\n/-- `order_dual` as a functor. -/\n@[simps] def dual : CompleteLat ⥤ CompleteLat :=\n{ obj := λ X, of Xᵒᵈ, map := λ X Y, complete_lattice_hom.dual }\n\n/-- The equivalence between `CompleteLat` and itself induced by `order_dual` both ways. -/\n@[simps functor inverse] def dual_equiv : CompleteLat ≌ CompleteLat :=\nequivalence.mk dual dual\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n\nend CompleteLat\n\nlemma CompleteLat_dual_comp_forget_to_BddLat :\n  CompleteLat.dual ⋙ forget₂ CompleteLat BddLat =\n    forget₂ CompleteLat BddLat ⋙ BddLat.dual := rfl\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/order/category/CompleteLat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.47511738214293175}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro\n\n! This file was ported from Lean 3 source module algebra.order.ring.with_top\n! leanprover-community/mathlib commit 0111834459f5d7400215223ea95ae38a1265a907\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Hom.Ring\nimport Mathlib.Algebra.Order.Monoid.WithTop\nimport Mathlib.Algebra.Order.Ring.Canonical\nimport Std.Data.Option.Lemmas\n\n/-! # Structures involving `*` and `0` on `WithTop` and `WithBot`\nThe main results of this section are `WithTop.canonicallyOrderedCommSemiring` and\n`WithBot.orderedCommSemiring`.\n-/\n\nvariable {α : Type _}\n\nnamespace WithTop\n\nvariable [DecidableEq α]\n\ninstance : DecidableEq (WithTop α) := instDecidableEqOption\n\nsection Mul\n\nvariable [Zero α] [Mul α]\n\ninstance : MulZeroClass (WithTop α) where\n  zero := 0\n  mul m n := if m = 0 ∨ n = 0 then 0 else Option.map₂ (· * ·) m n\n  zero_mul _ := if_pos <| Or.inl rfl\n  mul_zero _ := if_pos <| Or.inr rfl\n\ntheorem mul_def {a b : WithTop α} :\n    a * b = (if a = 0 ∨ b = 0 then 0 else Option.map₂ (· * ·) a b : WithTop α) :=\n  rfl\n#align with_top.mul_def WithTop.mul_def\n\n-- Porting note: commented out @[simp] to placate the `simp can prove this` linter\n-- @[simp]\ntheorem top_mul_top : (⊤ * ⊤ : WithTop α) = ⊤ := by simp [mul_def]; rfl\n#align with_top.top_mul_top WithTop.top_mul_top\n\ntheorem mul_top' (a : WithTop α) : a * ⊤ = if a = 0 then 0 else ⊤ := by\n  induction a using recTopCoe <;> simp [mul_def] <;> rfl\n#align with_top.mul_top' WithTop.mul_top'\n\n@[simp] theorem mul_top {a : WithTop α} (h : a ≠ 0) : a * ⊤ = ⊤ := by rw [mul_top', if_neg h]\n#align with_top.mul_top WithTop.mul_top\n\ntheorem top_mul' (a : WithTop α) : ⊤ * a = if a = 0 then 0 else ⊤ := by\n  induction a using recTopCoe <;> simp [mul_def] <;> rfl\n#align with_top.top_mul' WithTop.top_mul'\n\n@[simp] theorem top_mul {a : WithTop α} (h : a ≠ 0) : ⊤ * a = ⊤ := by rw [top_mul', if_neg h]\n#align with_top.top_mul WithTop.top_mul\n\ntheorem mul_eq_top_iff {a b : WithTop α} : a * b = ⊤ ↔ a ≠ 0 ∧ b = ⊤ ∨ a = ⊤ ∧ b ≠ 0 := by\n  rw [mul_def, ite_eq_iff, ← none_eq_top, Option.map₂_eq_none_iff]\n  have ha : a = 0 → a ≠ none := fun h => h.symm ▸ zero_ne_top\n  have hb : b = 0 → b ≠ none := fun h => h.symm ▸ zero_ne_top\n  tauto\n#align with_top.mul_eq_top_iff WithTop.mul_eq_top_iff\n\ntheorem mul_lt_top' [LT α] {a b : WithTop α} (ha : a < ⊤) (hb : b < ⊤) : a * b < ⊤ := by\n  rw [WithTop.lt_top_iff_ne_top] at *\n  simp only [Ne.def, mul_eq_top_iff, *, and_false, false_and, false_or]\n#align with_top.mul_lt_top' WithTop.mul_lt_top'\n\ntheorem mul_lt_top [LT α] {a b : WithTop α} (ha : a ≠ ⊤) (hb : b ≠ ⊤) : a * b < ⊤ :=\n  mul_lt_top' (WithTop.lt_top_iff_ne_top.2 ha) (WithTop.lt_top_iff_ne_top.2 hb)\n#align with_top.mul_lt_top WithTop.mul_lt_top\n\ninstance noZeroDivisors [NoZeroDivisors α] : NoZeroDivisors (WithTop α) := by\n  refine ⟨fun h₁ => Decidable.by_contradiction <| fun h₂ => ?_⟩\n  rw [mul_def, if_neg h₂] at h₁\n  rcases Option.mem_map₂_iff.1 h₁ with ⟨a, b, (rfl : _ = _), (rfl : _ = _), hab⟩\n  exact h₂ ((eq_zero_or_eq_zero_of_mul_eq_zero hab).imp (congr_arg some) (congr_arg some))\n\nend Mul\n\nsection MulZeroClass\n\nvariable [MulZeroClass α]\n\n@[simp, norm_cast]\ntheorem coe_mul {a b : α} : (↑(a * b) : WithTop α) = a * b := by\n  by_cases ha : a = 0\n  · simp [ha]\n  · by_cases hb : b = 0\n    · simp [hb]\n    · simp [*, mul_def]\n      rfl\n#align with_top.coe_mul WithTop.coe_mul\n\ntheorem mul_coe {b : α} (hb : b ≠ 0) : ∀ {a : WithTop α},\n    a * (b : WithTop α) = a.bind fun a : α => ↑(a * b)\n  | none =>\n    show (if (⊤ : WithTop α) = 0 ∨ (b : WithTop α) = 0 then 0 else ⊤ : WithTop α) = ⊤ by simp [hb]\n  | Option.some a => by\n    rw [some_eq_coe, ← coe_mul]\n    rfl\n#align with_top.mul_coe WithTop.mul_coe\n\n@[simp]\ntheorem untop'_zero_mul (a b : WithTop α) : (a * b).untop' 0 = a.untop' 0 * b.untop' 0 := by\n  by_cases ha : a = 0; · rw [ha, zero_mul, ← coe_zero, untop'_coe, zero_mul]\n  by_cases hb : b = 0; · rw [hb, mul_zero, ← coe_zero, untop'_coe, mul_zero]\n  induction a using WithTop.recTopCoe; · rw [top_mul hb, untop'_top, zero_mul]\n  induction b using WithTop.recTopCoe; · rw [mul_top ha, untop'_top, mul_zero]\n  rw [← coe_mul, untop'_coe, untop'_coe, untop'_coe]\n#align with_top.untop'_zero_mul WithTop.untop'_zero_mul\n\nend MulZeroClass\n\n/-- `Nontrivial α` is needed here as otherwise we have `1 * ⊤ = ⊤` but also `0 * ⊤ = 0`. -/\ninstance [MulZeroOneClass α] [Nontrivial α] : MulZeroOneClass (WithTop α) :=\n  { WithTop.instMulZeroClassWithTop with\n    mul := (· * ·)\n    one := 1, zero := 0\n    one_mul := fun a =>\n      match a with\n      | ⊤ => mul_top (mt coe_eq_coe.1 one_ne_zero)\n      | (a : α) => by rw [← coe_one, ← coe_mul, one_mul],\n    mul_one := fun a =>\n      match a with\n      | ⊤ => top_mul (mt coe_eq_coe.1 one_ne_zero)\n      | (a : α) => by rw [← coe_one, ← coe_mul, mul_one] }\n\n/-- A version of `WithTop.map` for `MonoidWithZeroHom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def _root_.MonoidWithZeroHom.withTopMap {R S : Type _} [MulZeroOneClass R] [DecidableEq R]\n    [Nontrivial R] [MulZeroOneClass S] [DecidableEq S] [Nontrivial S] (f : R →*₀ S)\n    (hf : Function.Injective f) : WithTop R →*₀ WithTop S :=\n  { f.toZeroHom.withTopMap, f.toMonoidHom.toOneHom.withTopMap with\n    toFun := WithTop.map f\n    map_mul' := fun x y => by\n      have : ∀ z, map f z = 0 ↔ z = 0 := fun z =>\n        (Option.map_injective hf).eq_iff' f.toZeroHom.withTopMap.map_zero\n      rcases Decidable.eq_or_ne x 0 with (rfl | hx)\n      · simp\n      rcases Decidable.eq_or_ne y 0 with (rfl | hy)\n      · simp\n      induction' x using WithTop.recTopCoe with x\n      · simp [hy, this]\n      induction' y using WithTop.recTopCoe with y\n      · have : (f x : WithTop S) ≠ 0 := by simpa [hf.eq_iff' (map_zero f)] using hx\n        simp [mul_top hx, mul_top this]\n      · simp only [map_coe, ← coe_mul, map_mul] } -- porting note: todo: `simp [← coe_mul]` fails\n#align monoid_with_zero_hom.with_top_map MonoidWithZeroHom.withTopMap\n\ninstance [SemigroupWithZero α] [NoZeroDivisors α] : SemigroupWithZero (WithTop α) :=\n  { WithTop.instMulZeroClassWithTop with\n    mul := (· * ·)\n    zero := 0\n    mul_assoc := fun a b c => by\n      rcases eq_or_ne a 0 with (rfl | ha); · simp only [zero_mul]\n      rcases eq_or_ne b 0 with (rfl | hb); · simp only [zero_mul, mul_zero]\n      rcases eq_or_ne c 0 with (rfl | hc); · simp only [mul_zero]\n    -- Porting note: below needed to be rewritten due to changed `simp` behaviour for `coe`\n      induction' a using WithTop.recTopCoe with a; · simp [hb, hc]\n      induction' b using WithTop.recTopCoe with b; · simp [mul_top ha, top_mul hc]\n      induction' c using WithTop.recTopCoe with c\n      · rw [mul_top hb, mul_top ha]\n        rw [← coe_zero, ne_eq, coe_eq_coe] at ha hb\n        simp [ha, hb]\n      simp only [← coe_mul, mul_assoc] }\n\ninstance monoidWithZero [MonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] :\n    MonoidWithZero (WithTop α) :=\n  { WithTop.instMulZeroOneClassWithTop, WithTop.instSemigroupWithZeroWithTop with }\n\ninstance commMonoidWithZero [CommMonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] :\n    CommMonoidWithZero (WithTop α) :=\n  { WithTop.monoidWithZero with\n    mul := (· * ·)\n    zero := 0,\n    mul_comm := fun _ _ => ite_congr (propext or_comm) (fun _ => rfl)\n      (fun _ => Option.map₂_comm mul_comm) }\n\nvariable [CanonicallyOrderedCommSemiring α]\n\nprivate theorem distrib' (a b c : WithTop α) : (a + b) * c = a * c + b * c := by\n  induction' c using WithTop.recTopCoe with c\n  · by_cases ha : a = 0 <;> simp [ha]\n  · by_cases hc : c = 0\n    · simp [hc]\n    simp [mul_coe hc]\n    cases a <;> cases b\n    repeat' first | rfl |exact congr_arg some (add_mul _ _ _)\n\n/-- This instance requires `CanonicallyOrderedCommSemiring` as it is the smallest class\nthat derives from both `NonAssocNonUnitalSemiring` and `CanonicallyOrderedAddMonoid`, both\nof which are required for distributivity. -/\ninstance commSemiring [Nontrivial α] : CommSemiring (WithTop α) :=\n  { WithTop.addCommMonoidWithOne, WithTop.commMonoidWithZero with\n    right_distrib := distrib'\n    left_distrib := fun a b c => by\n      rw [mul_comm, distrib', mul_comm b, mul_comm c] }\n\ninstance [Nontrivial α] : CanonicallyOrderedCommSemiring (WithTop α) :=\n  { WithTop.commSemiring, WithTop.canonicallyOrderedAddMonoid with\n  eq_zero_or_eq_zero_of_mul_eq_zero := eq_zero_or_eq_zero_of_mul_eq_zero}\n\n/-- A version of `WithTop.map` for `RingHom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def _root_.RingHom.withTopMap {R S : Type _} [CanonicallyOrderedCommSemiring R]\n    [DecidableEq R] [Nontrivial R] [CanonicallyOrderedCommSemiring S] [DecidableEq S] [Nontrivial S]\n    (f : R →+* S) (hf : Function.Injective f) : WithTop R →+* WithTop S :=\n  {MonoidWithZeroHom.withTopMap f.toMonoidWithZeroHom hf, f.toAddMonoidHom.withTopMap with}\n#align ring_hom.with_top_map RingHom.withTopMap\n\nend WithTop\n\nnamespace WithBot\n\nvariable [DecidableEq α]\n\ninstance : DecidableEq (WithBot α) := instDecidableEqOption\n\nsection Mul\n\nvariable [Zero α] [Mul α]\n\ninstance : MulZeroClass (WithBot α) :=\n  WithTop.instMulZeroClassWithTop\n\ntheorem mul_def {a b : WithBot α} :\n    a * b = if a = 0 ∨ b = 0 then (0 : WithBot α) else Option.map₂ (· * ·) a b :=\n  rfl\n#align with_bot.mul_def WithBot.mul_def\n\n@[simp]\ntheorem mul_bot {a : WithBot α} (h : a ≠ 0) : a * ⊥ = ⊥ :=\n  WithTop.mul_top h\n#align with_bot.mul_bot WithBot.mul_bot\n\n@[simp]\ntheorem bot_mul {a : WithBot α} (h : a ≠ 0) : ⊥ * a = ⊥ :=\n  WithTop.top_mul h\n#align with_bot.bot_mul WithBot.bot_mul\n\n@[simp]\ntheorem bot_mul_bot : (⊥ * ⊥ : WithBot α) = ⊥ :=\n  WithTop.top_mul_top\n#align with_bot.bot_mul_bot WithBot.bot_mul_bot\n\ntheorem mul_eq_bot_iff {a b : WithBot α} : a * b = ⊥ ↔ a ≠ 0 ∧ b = ⊥ ∨ a = ⊥ ∧ b ≠ 0 :=\n  WithTop.mul_eq_top_iff\n#align with_bot.mul_eq_bot_iff WithBot.mul_eq_bot_iff\n\ntheorem bot_lt_mul' [LT α] {a b : WithBot α} (ha : ⊥ < a) (hb : ⊥ < b) : ⊥ < a * b :=\n  WithTop.mul_lt_top' (α := αᵒᵈ) ha hb\n#align with_bot.bot_lt_mul' WithBot.bot_lt_mul'\n\ntheorem bot_lt_mul [LT α] {a b : WithBot α} (ha : a ≠ ⊥) (hb : b ≠ ⊥) : ⊥ < a * b :=\n  WithTop.mul_lt_top (α := αᵒᵈ) ha hb\n#align with_bot.bot_lt_mul WithBot.bot_lt_mul\n\nend Mul\n\nsection MulZeroClass\n\nvariable [MulZeroClass α]\n\n@[simp, norm_cast] -- porting note: added `simp`\ntheorem coe_mul {a b : α} : (↑(a * b) : WithBot α) = a * b :=\n  WithTop.coe_mul\n#align with_bot.coe_mul WithBot.coe_mul\n\ntheorem mul_coe {b : α} (hb : b ≠ 0) {a : WithBot α} :\n    a * (b : WithBot α) = a.bind fun a : α => ↑(a * b) :=\n  WithTop.mul_coe hb\n#align with_bot.mul_coe WithBot.mul_coe\n\nend MulZeroClass\n\n/-- `Nontrivial α` is needed here as otherwise we have `1 * ⊥ = ⊥` but also `= 0 * ⊥ = 0`. -/\ninstance [MulZeroOneClass α] [Nontrivial α] : MulZeroOneClass (WithBot α) :=\n  WithTop.instMulZeroOneClassWithTop\n\ninstance [MulZeroClass α] [NoZeroDivisors α] : NoZeroDivisors (WithBot α) :=\n  WithTop.noZeroDivisors\n\ninstance [SemigroupWithZero α] [NoZeroDivisors α] : SemigroupWithZero (WithBot α) :=\n  WithTop.instSemigroupWithZeroWithTop\n\ninstance [MonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] : MonoidWithZero (WithBot α) :=\n  WithTop.monoidWithZero\n\ninstance commMonoidWithZero [CommMonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] :\n    CommMonoidWithZero (WithBot α) :=\n  WithTop.commMonoidWithZero\n\ninstance commSemiring [CanonicallyOrderedCommSemiring α] [Nontrivial α] :\n    CommSemiring (WithBot α) :=\n  WithTop.commSemiring\n\ninstance [MulZeroClass α] [Preorder α] [PosMulMono α] : PosMulMono (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with rfl | x0'\n    · simp\n    lift x to α\n    · rintro rfl\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction a using WithBot.recBotCoe\n    · simp_rw [mul_bot x0', bot_le]\n    induction b using WithBot.recBotCoe\n    · exact absurd h (bot_lt_coe _).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact mul_le_mul_of_nonneg_left h x0 ⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosMono α] : MulPosMono (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with rfl | x0'\n    · simp\n    lift x to α\n    · rintro rfl\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction a using WithBot.recBotCoe\n    · simp_rw [bot_mul x0', bot_le]\n    induction b using WithBot.recBotCoe\n    · exact absurd h (bot_lt_coe _).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact mul_le_mul_of_nonneg_right h x0 ⟩\n\ninstance [MulZeroClass α] [Preorder α] [PosMulStrictMono α] : PosMulStrictMono (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk]\n    lift x to α using x0.ne_bot\n    induction b using WithBot.recBotCoe\n    · exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe\n    · simp_rw [mul_bot x0.ne.symm, ← coe_mul, bot_lt_coe]\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact mul_lt_mul_of_pos_left h x0 ⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosStrictMono α] : MulPosStrictMono (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk]\n    lift x to α using x0.ne_bot\n    induction b using WithBot.recBotCoe\n    · exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe\n    · simp_rw [bot_mul x0.ne.symm, ← coe_mul, bot_lt_coe]\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact mul_lt_mul_of_pos_right h x0 ⟩\n\ninstance [MulZeroClass α] [Preorder α] [PosMulReflectLT α] : PosMulReflectLT (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with rfl | x0'\n    · simp at h\n    lift x to α\n    · rintro rfl\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction b using WithBot.recBotCoe\n    · rw [mul_bot x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe\n    · exact WithBot.bot_lt_coe _\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact lt_of_mul_lt_mul_left h x0 ⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosReflectLT α] : MulPosReflectLT (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with rfl | x0'\n    · simp at h\n    lift x to α\n    · rintro rfl\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction b using WithBot.recBotCoe\n    · rw [bot_mul x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe\n    · exact WithBot.bot_lt_coe _\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact lt_of_mul_lt_mul_right h x0 ⟩\n\ninstance [MulZeroClass α] [Preorder α] [PosMulMonoRev α] : PosMulMonoRev (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk] at h\n    lift x to α using x0.ne_bot\n    induction a using WithBot.recBotCoe\n    · exact bot_le\n    induction b using WithBot.recBotCoe\n    · rw [mul_bot x0.ne.symm, ← coe_mul] at h\n      exact absurd h (bot_lt_coe _).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact le_of_mul_le_mul_left h x0 ⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosMonoRev α] : MulPosMonoRev (WithBot α) :=\n  ⟨by\n    intro ⟨x, x0⟩ a b h\n    simp only [Subtype.coe_mk] at h\n    lift x to α using x0.ne_bot\n    induction a using WithBot.recBotCoe\n    · exact bot_le\n    induction b using WithBot.recBotCoe\n    · rw [bot_mul x0.ne.symm, ← coe_mul] at h\n      exact absurd h (bot_lt_coe _).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact le_of_mul_le_mul_right h x0 ⟩\n\ninstance orderedCommSemiring [CanonicallyOrderedCommSemiring α] [Nontrivial α] :\n    OrderedCommSemiring (WithBot α) :=\n  { WithBot.zeroLEOneClass, WithBot.orderedAddCommMonoid, WithBot.commSemiring with\n    mul_le_mul_of_nonneg_left  := fun _ _ _ => mul_le_mul_of_nonneg_left\n    mul_le_mul_of_nonneg_right := fun _ _ _ => mul_le_mul_of_nonneg_right }\n\nend WithBot\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/Order/Ring/WithTop.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.4751173776961012}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau\n-/\nimport algebra.module.pi\nimport algebra.big_operators.basic\nimport data.set.finite\nimport group_theory.submonoid.basic\n\n/-!\n# Dependent functions with finite support\n\nFor a non-dependent version see `data/finsupp.lean`.\n-/\n\nuniverses u u₁ u₂ v v₁ v₂ v₃ w x y l\n\nopen_locale big_operators\n\nvariables (ι : Type u) (β : ι → Type v) {β₁ : ι → Type v₁} {β₂ : ι → Type v₂}\n\nnamespace dfinsupp\n\nvariable [Π i, has_zero (β i)]\n\nstructure pre : Type (max u v) :=\n(to_fun : Π i, β i)\n(pre_support : multiset ι)\n(zero : ∀ i, i ∈ pre_support ∨ to_fun i = 0)\n\ninstance inhabited_pre : inhabited (pre ι β) :=\n⟨⟨λ i, 0, ∅, λ i, or.inr rfl⟩⟩\n\ninstance : setoid (pre ι β) :=\n{ r := λ x y, ∀ i, x.to_fun i = y.to_fun i,\n  iseqv := ⟨λ f i, rfl, λ f g H i, (H i).symm,\n    λ f g h H1 H2 i, (H1 i).trans (H2 i)⟩ }\n\nend dfinsupp\n\nvariable {ι}\n/-- A dependent function `Π i, β i` with finite support. -/\n@[reducible]\ndef dfinsupp [Π i, has_zero (β i)] : Type* :=\nquotient (dfinsupp.pre.setoid ι β)\nvariable {β}\n\nnotation `Π₀` binders `, ` r:(scoped f, dfinsupp f) := r\ninfix ` →ₚ `:25 := dfinsupp\n\nnamespace dfinsupp\n\nsection basic\nvariables [Π i, has_zero (β i)] [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n\ninstance : has_coe_to_fun (Π₀ i, β i) :=\n⟨λ _, Π i, β i, λ f, quotient.lift_on f pre.to_fun $ λ _ _, funext⟩\n\ninstance : has_zero (Π₀ i, β i) := ⟨⟦⟨0, ∅, λ i, or.inr rfl⟩⟧⟩\ninstance : inhabited (Π₀ i, β i) := ⟨0⟩\n\n@[simp] lemma coe_zero : ⇑(0 : Π₀ i, β i) = 0 := rfl\nlemma zero_apply (i : ι) : (0 : Π₀ i, β i) i = 0 := rfl\n\nlemma coe_fn_injective : @function.injective (Π₀ i, β i) (Π i, β i) coe_fn :=\nλ f g H, quotient.induction_on₂ f g (λ _ _ H, quotient.sound H) (congr_fun H)\n\n@[ext] lemma ext {f g : Π₀ i, β i} (H : ∀ i, f i = g i) : f = g :=\ncoe_fn_injective (funext H)\n\n/-- The composition of `f : β₁ → β₂` and `g : Π₀ i, β₁ i` is\n  `map_range f hf g : Π₀ i, β₂ i`, well defined when `f 0 = 0`.\n\nThis preserves the structure on `f`, and exists in various bundled forms for when `f` is itself\nbundled:\n\n* `dfinsupp.map_range.add_monoid_hom`\n* `dfinsupp.map_range.add_equiv`\n* `dfinsupp.map_range.linear_map`\n* `dfinsupp.map_range.linear_equiv`\n-/\ndef map_range (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (g : Π₀ i, β₁ i) : Π₀ i, β₂ i :=\nquotient.lift_on g (λ x, ⟦(⟨λ i, f i (x.1 i), x.2,\n  λ i, or.cases_on (x.3 i) or.inl $ λ H, or.inr $ by rw [H, hf]⟩ : pre ι β₂)⟧) $ λ x y H,\nquotient.sound $ λ i, by simp only [H i]\n\n@[simp] lemma map_range_apply\n  (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (g : Π₀ i, β₁ i) (i : ι) :\n  map_range f hf g i = f i (g i) :=\nquotient.induction_on g $ λ x, rfl\n\n@[simp] lemma map_range_id (h : ∀ i, id (0 : β₁ i) = 0 := λ i, rfl) (g : Π₀ (i : ι), β₁ i) :\n  map_range (λ i, (id : β₁ i → β₁ i)) h g = g :=\nby { ext, simp only [map_range_apply, id.def] }\n\nlemma map_range_comp (f : Π i, β₁ i → β₂ i) (f₂ : Π i, β i → β₁ i)\n  (hf : ∀ i, f i 0 = 0) (hf₂ : ∀ i, f₂ i 0 = 0) (h : ∀ i, (f i ∘ f₂ i) 0 = 0)\n  (g : Π₀ (i : ι), β i) :\n  map_range (λ i, f i ∘ f₂ i) h g = map_range f hf (map_range f₂ hf₂ g) :=\nby { ext, simp only [map_range_apply] }\n\n@[simp] lemma map_range_zero (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) :\n  map_range f hf (0 : Π₀ i, β₁ i) = 0 :=\nby { ext, simp only [map_range_apply, coe_zero, pi.zero_apply, hf] }\n\n/-- Let `f i` be a binary operation `β₁ i → β₂ i → β i` such that `f i 0 0 = 0`.\nThen `zip_with f hf` is a binary operation `Π₀ i, β₁ i → Π₀ i, β₂ i → Π₀ i, β i`. -/\ndef zip_with (f : Π i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0)\n  (g₁ : Π₀ i, β₁ i) (g₂ : Π₀ i, β₂ i) : (Π₀ i, β i) :=\nbegin\n  refine quotient.lift_on₂ g₁ g₂ (λ x y, ⟦(⟨λ i, f i (x.1 i) (y.1 i), x.2 + y.2,\n    λ i, _⟩ : pre ι β)⟧) _,\n  { cases x.3 i with h1 h1,\n    { left, rw multiset.mem_add, left, exact h1 },\n    cases y.3 i with h2 h2,\n    { left, rw multiset.mem_add, right, exact h2 },\n    right, rw [h1, h2, hf] },\n  exact λ x₁ x₂ y₁ y₂ H1 H2, quotient.sound $ λ i, by simp only [H1 i, H2 i]\nend\n\n@[simp] lemma zip_with_apply\n  (f : Π i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0) (g₁ : Π₀ i, β₁ i) (g₂ : Π₀ i, β₂ i) (i : ι) :\n  zip_with f hf g₁ g₂ i = f i (g₁ i) (g₂ i) :=\nquotient.induction_on₂ g₁ g₂ $ λ _ _, rfl\n\nend basic\n\nsection algebra\n\ninstance [Π i, add_zero_class (β i)] : has_add (Π₀ i, β i) :=\n⟨zip_with (λ _, (+)) (λ _, add_zero 0)⟩\n\nlemma add_apply [Π i, add_zero_class (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) :\n  (g₁ + g₂) i = g₁ i + g₂ i :=\nzip_with_apply _ _ g₁ g₂ i\n\n@[simp] lemma coe_add [Π i, add_zero_class (β i)] (g₁ g₂ : Π₀ i, β i) :\n  ⇑(g₁ + g₂) = g₁ + g₂ :=\nfunext $ add_apply g₁ g₂\n\ninstance [Π i, add_zero_class (β i)] : add_zero_class (Π₀ i, β i) :=\n{ zero      := 0,\n  add       := (+),\n  zero_add  := λ f, ext $ λ i, by simp only [add_apply, zero_apply, zero_add],\n  add_zero  := λ f, ext $ λ i, by simp only [add_apply, zero_apply, add_zero] }\n\ninstance [Π i, add_monoid (β i)] : add_monoid (Π₀ i, β i) :=\n{ add_monoid .\n  zero      := 0,\n  add       := (+),\n  add_assoc := λ f g h, ext $ λ i, by simp only [add_apply, add_assoc],\n  .. dfinsupp.add_zero_class }\n\ninstance is_add_monoid_hom [Π i, add_zero_class (β i)] {i : ι} :\n  is_add_monoid_hom (λ g : Π₀ i : ι, β i, g i) :=\n{ map_add := λ f g, add_apply f g i, map_zero := zero_apply i }\n\ninstance [Π i, add_group (β i)] : has_neg (Π₀ i, β i) :=\n⟨λ f, f.map_range (λ _, has_neg.neg) (λ _, neg_zero)⟩\n\ninstance [Π i, add_comm_monoid (β i)] : add_comm_monoid (Π₀ i, β i) :=\n{ add_comm := λ f g, ext $ λ i, by simp only [add_apply, add_comm],\n  .. dfinsupp.add_monoid }\n\nlemma neg_apply [Π i, add_group (β i)] (g : Π₀ i, β i) (i : ι) : (- g) i = - g i :=\nmap_range_apply _ _ g i\n\n@[simp] lemma coe_neg [Π i, add_group (β i)] (g : Π₀ i, β i) : ⇑(- g) = - g :=\nfunext $ neg_apply g\n\ninstance [Π i, add_group (β i)] : add_group (Π₀ i, β i) :=\n{ add_left_neg := λ f, ext $ λ i, by simp only [add_apply, neg_apply, zero_apply, add_left_neg],\n  .. dfinsupp.add_monoid,\n  .. (infer_instance : has_neg (Π₀ i, β i)) }\n\nlemma sub_apply [Π i, add_group (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) :\n  (g₁ - g₂) i = g₁ i - g₂ i :=\nby rw [sub_eq_add_neg]; simp [sub_eq_add_neg]\n\n@[simp] lemma coe_sub [Π i, add_group (β i)] (g₁ g₂ : Π₀ i, β i) :\n  ⇑(g₁ - g₂) = g₁ - g₂ :=\nfunext $ sub_apply g₁ g₂\n\ninstance [Π i, add_comm_group (β i)] : add_comm_group (Π₀ i, β i) :=\n{ add_comm := λ f g, ext $ λ i, by simp only [add_apply, add_comm],\n  ..dfinsupp.add_group }\n\n/-- Dependent functions with finite support inherit a semiring action from an action on each\ncoordinate. -/\ninstance {γ : Type w} [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] :\n  has_scalar γ (Π₀ i, β i) :=\n⟨λc v, v.map_range (λ _, (•) c) (λ _, smul_zero _)⟩\n\nlemma smul_apply {γ : Type w} [monoid γ] [Π i, add_monoid (β i)]\n  [Π i, distrib_mul_action γ (β i)] (b : γ) (v : Π₀ i, β i) (i : ι) :\n  (b • v) i = b • (v i) :=\nmap_range_apply _ _ v i\n\n@[simp] lemma coe_smul {γ : Type w} [monoid γ] [Π i, add_monoid (β i)]\n  [Π i, distrib_mul_action γ (β i)] (b : γ) (v : Π₀ i, β i) :\n  ⇑(b • v) = b • v :=\nfunext $ smul_apply b v\n\ninstance {γ : Type w} {δ : Type*} [monoid γ] [monoid δ]\n  [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] [Π i, distrib_mul_action δ (β i)]\n  [Π i, smul_comm_class γ δ (β i)] :\n  smul_comm_class γ δ (Π₀ i, β i) :=\n{ smul_comm := λ r s m, ext $ λ i, by simp only [smul_apply, smul_comm r s (m i)] }\n\ninstance {γ : Type w} {δ : Type*} [monoid γ] [monoid δ]\n  [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] [Π i, distrib_mul_action δ (β i)]\n  [has_scalar γ δ] [Π i, is_scalar_tower γ δ (β i)] :\n  is_scalar_tower γ δ (Π₀ i, β i) :=\n{ smul_assoc := λ r s m, ext $ λ i, by simp only [smul_apply, smul_assoc r s (m i)] }\n\n/-- Dependent functions with finite support inherit a `distrib_mul_action` structure from such a\nstructure on each coordinate. -/\ninstance {γ : Type w} [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] :\n  distrib_mul_action γ (Π₀ i, β i) :=\n{ smul_zero := λ c, ext $ λ i, by simp only [smul_apply, smul_zero, zero_apply],\n  smul_add := λ c x y, ext $ λ i, by simp only [add_apply, smul_apply, smul_add],\n  one_smul := λ x, ext $ λ i, by simp only [smul_apply, one_smul],\n  mul_smul := λ r s x, ext $ λ i, by simp only [smul_apply, smul_smul],\n  ..dfinsupp.has_scalar }\n\n/-- Dependent functions with finite support inherit a module structure from such a structure on\neach coordinate. -/\ninstance {γ : Type w} [semiring γ] [Π i, add_comm_monoid (β i)] [Π i, module γ (β i)] :\n  module γ (Π₀ i, β i) :=\n{ zero_smul := λ c, ext $ λ i, by simp only [smul_apply, zero_smul, zero_apply],\n  add_smul := λ c x y, ext $ λ i, by simp only [add_apply, smul_apply, add_smul],\n  ..dfinsupp.distrib_mul_action }\n\nend algebra\n\nsection filter_and_subtype_domain\n\n/-- `filter p f` is the function which is `f i` if `p i` is true and 0 otherwise. -/\ndef filter [Π i, has_zero (β i)] (p : ι → Prop) [decidable_pred p] (f : Π₀ i, β i) : Π₀ i, β i :=\nquotient.lift_on f (λ x, ⟦(⟨λ i, if p i then x.1 i else 0, x.2,\n  λ i, or.cases_on (x.3 i) or.inl $ λ H, or.inr $ by rw [H, if_t_t]⟩ : pre ι β)⟧) $ λ x y H,\nquotient.sound $ λ i, by simp only [H i]\n\n@[simp] lemma filter_apply [Π i, has_zero (β i)]\n  (p : ι → Prop) [decidable_pred p] (i : ι) (f : Π₀ i, β i) :\n  f.filter p i = if p i then f i else 0 :=\nquotient.induction_on f $ λ x, rfl\n\nlemma filter_apply_pos [Π i, has_zero (β i)]\n  {p : ι → Prop} [decidable_pred p] (f : Π₀ i, β i) {i : ι} (h : p i) :\n  f.filter p i = f i :=\nby simp only [filter_apply, if_pos h]\n\nlemma filter_apply_neg [Π i, has_zero (β i)]\n  {p : ι → Prop} [decidable_pred p] (f : Π₀ i, β i) {i : ι} (h : ¬ p i) :\n  f.filter p i = 0 :=\nby simp only [filter_apply, if_neg h]\n\nlemma filter_pos_add_filter_neg [Π i, add_zero_class (β i)] (f : Π₀ i, β i)\n  (p : ι → Prop) [decidable_pred p] :\n  f.filter p + f.filter (λi, ¬ p i) = f :=\next $ λ i, by simp only [add_apply, filter_apply]; split_ifs; simp only [add_zero, zero_add]\n\n/-- `subtype_domain p f` is the restriction of the finitely supported function\n  `f` to the subtype `p`. -/\ndef subtype_domain [Π i, has_zero (β i)] (p : ι → Prop) [decidable_pred p]\n  (f : Π₀ i, β i) : Π₀ i : subtype p, β i :=\nbegin\n  fapply quotient.lift_on f,\n  { intro x,\n    refine ⟦⟨λ i, x.1 (i : ι),\n      (x.2.filter p).attach.map $ λ j, ⟨j, (multiset.mem_filter.1 j.2).2⟩, _⟩⟧,\n    refine λ i, or.cases_on (x.3 i) (λ H, _) or.inr,\n    left, rw multiset.mem_map, refine ⟨⟨i, multiset.mem_filter.2 ⟨H, i.2⟩⟩, _, subtype.eta _ _⟩,\n    apply multiset.mem_attach },\n  intros x y H,\n  exact quotient.sound (λ i, H i)\nend\n\n@[simp] lemma subtype_domain_zero [Π i, has_zero (β i)] {p : ι → Prop} [decidable_pred p] :\n  subtype_domain p (0 : Π₀ i, β i) = 0 :=\nrfl\n\n@[simp] lemma subtype_domain_apply [Π i, has_zero (β i)] {p : ι → Prop} [decidable_pred p]\n  {i : subtype p} {v : Π₀ i, β i} :\n  (subtype_domain p v) i = v i :=\nquotient.induction_on v $ λ x, rfl\n\n@[simp] lemma subtype_domain_add [Π i, add_zero_class (β i)] {p : ι → Prop} [decidable_pred p]\n  {v v' : Π₀ i, β i} :\n  (v + v').subtype_domain p = v.subtype_domain p + v'.subtype_domain p :=\next $ λ i, by simp only [add_apply, subtype_domain_apply]\n\ninstance subtype_domain.is_add_monoid_hom [Π i, add_zero_class (β i)]\n  {p : ι → Prop} [decidable_pred p] :\n  is_add_monoid_hom (subtype_domain p : (Π₀ i : ι, β i) → Π₀ i : subtype p, β i) :=\n{ map_add := λ _ _, subtype_domain_add, map_zero := subtype_domain_zero }\n\n@[simp]\nlemma subtype_domain_neg [Π i, add_group (β i)] {p : ι → Prop} [decidable_pred p] {v : Π₀ i, β i} :\n  (- v).subtype_domain p = - v.subtype_domain p :=\next $ λ i, by simp only [neg_apply, subtype_domain_apply]\n\n@[simp] lemma subtype_domain_sub [Π i, add_group (β i)] {p : ι → Prop} [decidable_pred p]\n  {v v' : Π₀ i, β i} :\n  (v - v').subtype_domain p = v.subtype_domain p - v'.subtype_domain p :=\next $ λ i, by simp only [sub_apply, subtype_domain_apply]\n\nend filter_and_subtype_domain\n\n\nvariable [dec : decidable_eq ι]\ninclude dec\n\nsection basic\nvariable [Π i, has_zero (β i)]\n\nomit dec\nlemma finite_support (f : Π₀ i, β i) : set.finite {i | f i ≠ 0} :=\nbegin\n  classical,\n  exact quotient.induction_on f (λ x, x.2.to_finset.finite_to_set.subset (λ i H,\n    multiset.mem_to_finset.2 ((x.3 i).resolve_right H)))\nend\ninclude dec\n\n/-- Create an element of `Π₀ i, β i` from a finset `s` and a function `x`\ndefined on this `finset`. -/\ndef mk (s : finset ι) (x : Π i : (↑s : set ι), β (i : ι)) : Π₀ i, β i :=\n⟦⟨λ i, if H : i ∈ s then x ⟨i, H⟩ else 0, s.1,\nλ i, if H : i ∈ s then or.inl H else or.inr $ dif_neg H⟩⟧\n\n@[simp] lemma mk_apply {s : finset ι} {x : Π i : (↑s : set ι), β i} {i : ι} :\n  (mk s x : Π i, β i) i = if H : i ∈ s then x ⟨i, H⟩ else 0 :=\nrfl\n\ntheorem mk_injective (s : finset ι) : function.injective (@mk ι β _ _ s) :=\nbegin\n  intros x y H,\n  ext i,\n  have h1 : (mk s x : Π i, β i) i = (mk s y : Π i, β i) i, {rw H},\n  cases i with i hi,\n  change i ∈ s at hi,\n  dsimp only [mk_apply, subtype.coe_mk] at h1,\n  simpa only [dif_pos hi] using h1\nend\n\n/-- The function `single i b : Π₀ i, β i` sends `i` to `b`\nand all other points to `0`. -/\ndef single (i : ι) (b : β i) : Π₀ i, β i :=\nmk {i} $ λ j, eq.rec_on (finset.mem_singleton.1 j.prop).symm b\n\n@[simp] lemma single_apply {i i' b} :\n  (single i b : Π₀ i, β i) i' = (if h : i = i' then eq.rec_on h b else 0) :=\nbegin\n  dsimp only [single],\n  by_cases h : i = i',\n  { have h1 : i' ∈ ({i} : finset ι) := finset.mem_singleton.2 h.symm,\n    simp only [mk_apply, dif_pos h, dif_pos h1], refl },\n  { have h1 : i' ∉ ({i} : finset ι) := finset.not_mem_singleton.2 (ne.symm h),\n    simp only [mk_apply, dif_neg h, dif_neg h1] }\nend\n\n@[simp] lemma single_zero {i} : (single i 0 : Π₀ i, β i) = 0 :=\nquotient.sound $ λ j, if H : j ∈ ({i} : finset _)\nthen by dsimp only; rw [dif_pos H]; cases finset.mem_singleton.1 H; refl\nelse dif_neg H\n\n@[simp] lemma single_eq_same {i b} : (single i b : Π₀ i, β i) i = b :=\nby simp only [single_apply, dif_pos rfl]\n\nlemma single_eq_of_ne {i i' b} (h : i ≠ i') : (single i b : Π₀ i, β i) i' = 0 :=\nby simp only [single_apply, dif_neg h]\n\nlemma single_injective {i} : function.injective (single i : β i → Π₀ i, β i) :=\nλ x y H, congr_fun (mk_injective _ H) ⟨i, by simp⟩\n\n/-- Like `finsupp.single_eq_single_iff`, but with a `heq` due to dependent types -/\nlemma single_eq_single_iff (i j : ι) (xi : β i) (xj : β j) :\n  dfinsupp.single i xi = dfinsupp.single j xj ↔ i = j ∧ xi == xj ∨ xi = 0 ∧ xj = 0 :=\nbegin\n  split,\n  { intro h,\n    by_cases hij : i = j,\n    { subst hij,\n      exact or.inl ⟨rfl, heq_of_eq (dfinsupp.single_injective h)⟩, },\n    { have h_coe : ⇑(dfinsupp.single i xi) = dfinsupp.single j xj := congr_arg coe_fn h,\n      have hci := congr_fun h_coe i,\n      have hcj := congr_fun h_coe j,\n      rw dfinsupp.single_eq_same at hci hcj,\n      rw dfinsupp.single_eq_of_ne (ne.symm hij) at hci,\n      rw dfinsupp.single_eq_of_ne (hij) at hcj,\n      exact or.inr ⟨hci, hcj.symm⟩, }, },\n  { rintros (⟨hi, hxi⟩ | ⟨hi, hj⟩),\n    { subst hi,\n      rw eq_of_heq hxi, },\n    { rw [hi, hj, dfinsupp.single_zero, dfinsupp.single_zero], }, },\nend\n\n/-- Equality of sigma types is sufficient (but not necessary) to show equality of `dfinsupp`s. -/\nlemma single_eq_of_sigma_eq\n  {i j} {xi : β i} {xj : β j} (h : (⟨i, xi⟩ : sigma β) = ⟨j, xj⟩) :\n  dfinsupp.single i xi = dfinsupp.single j xj :=\nby { cases h, refl }\n\n/-- Redefine `f i` to be `0`. -/\ndef erase (i : ι) (f : Π₀ i, β i) : Π₀ i, β i :=\nquotient.lift_on f (λ x, ⟦(⟨λ j, if j = i then 0 else x.1 j, x.2,\nλ j, or.cases_on (x.3 j) or.inl $ λ H, or.inr $ by simp only [H, if_t_t]⟩ : pre ι β)⟧) $ λ x y H,\nquotient.sound $ λ j, if h : j = i then by simp only [if_pos h]\nelse by simp only [if_neg h, H j]\n\n@[simp] lemma erase_apply {i j : ι} {f : Π₀ i, β i} :\n  (f.erase i) j = if j = i then 0 else f j :=\nquotient.induction_on f $ λ x, rfl\n\n@[simp] lemma erase_same {i : ι} {f : Π₀ i, β i} : (f.erase i) i = 0 :=\nby simp\n\nlemma erase_ne {i i' : ι} {f : Π₀ i, β i} (h : i' ≠ i) : (f.erase i) i' = f i' :=\nby simp [h]\n\nend basic\n\nsection add_monoid\n\nvariable [Π i, add_zero_class (β i)]\n\n@[simp] lemma single_add {i : ι} {b₁ b₂ : β i} : single i (b₁ + b₂) = single i b₁ + single i b₂ :=\next $ assume i',\nbegin\n  by_cases h : i = i',\n  { subst h, simp only [add_apply, single_eq_same] },\n  { simp only [add_apply, single_eq_of_ne h, zero_add] }\nend\n\nvariables (β)\n\n/-- `dfinsupp.single` as an `add_monoid_hom`. -/\n@[simps] def single_add_hom (i : ι) : β i →+ Π₀ i, β i :=\n{ to_fun := single i, map_zero' := single_zero, map_add' := λ _ _, single_add }\n\nvariables {β}\n\nlemma single_add_erase {i : ι} {f : Π₀ i, β i} : single i (f i) + f.erase i = f :=\next $ λ i',\nif h : i = i'\nthen by subst h; simp only [add_apply, single_apply, erase_apply, dif_pos rfl, if_pos, add_zero]\nelse by simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (ne.symm h), zero_add]\n\nlemma erase_add_single {i : ι} {f : Π₀ i, β i} : f.erase i + single i (f i) = f :=\next $ λ i',\nif h : i = i'\nthen by subst h; simp only [add_apply, single_apply, erase_apply, dif_pos rfl, if_pos, zero_add]\nelse by simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (ne.symm h), add_zero]\n\nprotected theorem induction {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i)\n  (h0 : p 0) (ha : ∀i b (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (single i b + f)) :\n  p f :=\nbegin\n  refine quotient.induction_on f (λ x, _),\n  cases x with f s H, revert f H,\n  apply multiset.induction_on s,\n  { intros f H, convert h0, ext i, exact (H i).resolve_left id },\n  intros i s ih f H,\n  by_cases H1 : i ∈ s,\n  { have H2 : ∀ j, j ∈ s ∨ f j = 0,\n    { intro j, cases H j with H2 H2,\n      { cases multiset.mem_cons.1 H2 with H3 H3,\n        { left, rw H3, exact H1 },\n        { left, exact H3 } },\n      right, exact H2 },\n    have H3 : (⟦{to_fun := f, pre_support := i ::ₘ s, zero := H}⟧ : Π₀ i, β i)\n      = ⟦{to_fun := f, pre_support := s, zero := H2}⟧,\n    { exact quotient.sound (λ i, rfl) },\n    rw H3, apply ih },\n  have H2 : p (erase i ⟦{to_fun := f, pre_support := i ::ₘ s, zero := H}⟧),\n  { dsimp only [erase, quotient.lift_on_mk],\n    have H2 : ∀ j, j ∈ s ∨ ite (j = i) 0 (f j) = 0,\n    { intro j, cases H j with H2 H2,\n      { cases multiset.mem_cons.1 H2 with H3 H3,\n        { right, exact if_pos H3 },\n        { left, exact H3 } },\n      right, split_ifs; [refl, exact H2] },\n    have H3 : (⟦{to_fun := λ (j : ι), ite (j = i) 0 (f j),\n         pre_support := i ::ₘ s, zero := _}⟧ : Π₀ i, β i)\n      = ⟦{to_fun := λ (j : ι), ite (j = i) 0 (f j), pre_support := s, zero := H2}⟧ :=\n      quotient.sound (λ i, rfl),\n    rw H3, apply ih },\n  have H3 : single i _ + _ = (⟦{to_fun := f, pre_support := i ::ₘ s, zero := H}⟧ : Π₀ i, β i) :=\n    single_add_erase,\n  rw ← H3,\n  change p (single i (f i) + _),\n  cases classical.em (f i = 0) with h h,\n  { rw [h, single_zero, zero_add], exact H2 },\n  refine ha _ _ _ _ h H2,\n  rw erase_same\nend\n\nlemma induction₂ {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i)\n  (h0 : p 0) (ha : ∀i b (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (f + single i b)) :\n  p f :=\ndfinsupp.induction f h0 $ λ i b f h1 h2 h3,\nhave h4 : f + single i b = single i b + f,\n{ ext j, by_cases H : i = j,\n  { subst H, simp [h1] },\n  { simp [H] } },\neq.rec_on h4 $ ha i b f h1 h2 h3\n\n@[simp] lemma add_closure_Union_range_single :\n  add_submonoid.closure (⋃ i : ι, set.range (single i : β i → (Π₀ i, β i))) = ⊤ :=\ntop_unique $ λ x hx, (begin\n  apply dfinsupp.induction x,\n  exact add_submonoid.zero_mem _,\n  exact λ a b f ha hb hf, add_submonoid.add_mem _\n    (add_submonoid.subset_closure $ set.mem_Union.2 ⟨a, set.mem_range_self _⟩) hf\nend)\n\n/-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then\nthey are equal. -/\nlemma add_hom_ext {γ : Type w} [add_zero_class γ] ⦃f g : (Π₀ i, β i) →+ γ⦄\n  (H : ∀ (i : ι) (y : β i), f (single i y) = g (single i y)) :\n  f = g :=\nbegin\n  refine add_monoid_hom.eq_of_eq_on_mdense add_closure_Union_range_single (λ f hf, _),\n  simp only [set.mem_Union, set.mem_range] at hf,\n  rcases hf with ⟨x, y, rfl⟩,\n  apply H\nend\n\n/-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then\nthey are equal.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext] lemma add_hom_ext' {γ : Type w} [add_zero_class γ] ⦃f g : (Π₀ i, β i) →+ γ⦄\n  (H : ∀ x, f.comp (single_add_hom β x) = g.comp (single_add_hom β x)) :\n  f = g :=\nadd_hom_ext $ λ x, add_monoid_hom.congr_fun (H x)\n\nend add_monoid\n\n@[simp] lemma mk_add [Π i, add_zero_class (β i)] {s : finset ι} {x y : Π i : (↑s : set ι), β i} :\n  mk s (x + y) = mk s x + mk s y :=\next $ λ i, by simp only [add_apply, mk_apply]; split_ifs; [refl, rw zero_add]\n\n@[simp] lemma mk_zero [Π i, has_zero (β i)] {s : finset ι} :\n  mk s (0 : Π i : (↑s : set ι), β i.1) = 0 :=\next $ λ i, by simp only [mk_apply]; split_ifs; refl\n\n@[simp] lemma mk_neg [Π i, add_group (β i)] {s : finset ι} {x : Π i : (↑s : set ι), β i.1} :\n  mk s (-x) = -mk s x :=\next $ λ i, by simp only [neg_apply, mk_apply]; split_ifs; [refl, rw neg_zero]\n\n@[simp] lemma mk_sub [Π i, add_group (β i)] {s : finset ι} {x y : Π i : (↑s : set ι), β i.1} :\n  mk s (x - y) = mk s x - mk s y :=\next $ λ i, by simp only [sub_apply, mk_apply]; split_ifs; [refl, rw sub_zero]\n\ninstance [Π i, add_group (β i)] {s : finset ι} : is_add_group_hom (@mk ι β _ _ s) :=\n{ map_add := λ _ _, mk_add }\n\nsection\nvariables (γ : Type w) [semiring γ] [Π i, add_comm_monoid (β i)] [Π i, module γ (β i)]\ninclude γ\n\n@[simp] lemma mk_smul {s : finset ι} {c : γ} (x : Π i : (↑s : set ι), β i.1) :\n  mk s (c • x) = c • mk s x :=\next $ λ i, by simp only [smul_apply, mk_apply]; split_ifs; [refl, rw smul_zero]\n\n@[simp] lemma single_smul {i : ι} {c : γ} {x : β i} :\n  single i (c • x) = c • single i x :=\next $ λ i, by simp only [smul_apply, single_apply]; split_ifs; [cases h, rw smul_zero]; refl\n\nend\n\nsection support_basic\n\nvariables [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n\n/-- Set `{i | f x ≠ 0}` as a `finset`. -/\ndef support (f : Π₀ i, β i) : finset ι :=\nquotient.lift_on f (λ x, x.2.to_finset.filter $ λ i, x.1 i ≠ 0) $\nbegin\n  intros x y Hxy,\n  ext i, split,\n  { intro H,\n    rcases finset.mem_filter.1 H with ⟨h1, h2⟩,\n    rw Hxy i at h2,\n    exact finset.mem_filter.2 ⟨multiset.mem_to_finset.2 $ (y.3 i).resolve_right h2, h2⟩ },\n  { intro H,\n    rcases finset.mem_filter.1 H with ⟨h1, h2⟩,\n    rw ← Hxy i at h2,\n    exact finset.mem_filter.2 ⟨multiset.mem_to_finset.2 $ (x.3 i).resolve_right h2, h2⟩ },\nend\n\n@[simp] theorem support_mk_subset {s : finset ι} {x : Π i : (↑s : set ι), β i.1} :\n  (mk s x).support ⊆ s :=\nλ i H, multiset.mem_to_finset.1 (finset.mem_filter.1 H).1\n\n@[simp] theorem mem_support_to_fun (f : Π₀ i, β i) (i) : i ∈ f.support ↔ f i ≠ 0 :=\nbegin\n  refine quotient.induction_on f (λ x, _),\n  dsimp only [support, quotient.lift_on_mk],\n  rw [finset.mem_filter, multiset.mem_to_finset],\n  exact and_iff_right_of_imp (x.3 i).resolve_right\nend\n\ntheorem eq_mk_support (f : Π₀ i, β i) : f = mk f.support (λ i, f i) :=\nbegin\n  change f = mk f.support (λ i, f i.1),\n  ext i,\n  by_cases h : f i ≠ 0; [skip, rw [not_not] at h];\n    simp [h]\nend\n\n@[simp] lemma support_zero : (0 : Π₀ i, β i).support = ∅ := rfl\n\nlemma mem_support_iff (f : Π₀ i, β i) : ∀i:ι, i ∈ f.support ↔ f i ≠ 0 :=\nf.mem_support_to_fun\n\n@[simp] lemma support_eq_empty {f : Π₀ i, β i} : f.support = ∅ ↔ f = 0 :=\n⟨λ H, ext $ by simpa [finset.ext_iff] using H, by simp {contextual:=tt}⟩\n\ninstance decidable_zero : decidable_pred (eq (0 : Π₀ i, β i)) :=\nλ f, decidable_of_iff _ $ support_eq_empty.trans eq_comm\n\nlemma support_subset_iff {s : set ι} {f : Π₀ i, β i} :\n  ↑f.support ⊆ s ↔ (∀i∉s, f i = 0) :=\nby simp [set.subset_def];\n   exact forall_congr (assume i, not_imp_comm)\n\nlemma support_single_ne_zero {i : ι} {b : β i} (hb : b ≠ 0) : (single i b).support = {i} :=\nbegin\n  ext j, by_cases h : i = j,\n  { subst h, simp [hb] },\n  simp [ne.symm h, h]\nend\n\nlemma support_single_subset {i : ι} {b : β i} : (single i b).support ⊆ {i} :=\nsupport_mk_subset\n\nsection map_range_and_zip_with\n\nvariables [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n\nlemma map_range_def [Π i (x : β₁ i), decidable (x ≠ 0)]\n  {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} :\n  map_range f hf g = mk g.support (λ i, f i.1 (g i.1)) :=\nbegin\n  ext i,\n  by_cases h : g i ≠ 0; simp at h; simp [h, hf]\nend\n\n@[simp] lemma map_range_single {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {i : ι} {b : β₁ i} :\n  map_range f hf (single i b) = single i (f i b) :=\ndfinsupp.ext $ λ i', by by_cases i = i'; [{subst i', simp}, simp [h, hf]]\n\nvariables [Π i (x : β₁ i), decidable (x ≠ 0)] [Π i (x : β₂ i), decidable (x ≠ 0)]\n\nlemma support_map_range {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} :\n  (map_range f hf g).support ⊆ g.support :=\nby simp [map_range_def]\n\nlemma zip_with_def {f : Π i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0}\n  {g₁ : Π₀ i, β₁ i} {g₂ : Π₀ i, β₂ i} :\n  zip_with f hf g₁ g₂ = mk (g₁.support ∪ g₂.support) (λ i, f i.1 (g₁ i.1) (g₂ i.1)) :=\nbegin\n  ext i,\n  by_cases h1 : g₁ i ≠ 0; by_cases h2 : g₂ i ≠ 0;\n    simp only [not_not, ne.def] at h1 h2; simp [h1, h2, hf]\nend\n\nlemma support_zip_with {f : Π i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0}\n  {g₁ : Π₀ i, β₁ i} {g₂ : Π₀ i, β₂ i} :\n  (zip_with f hf g₁ g₂).support ⊆ g₁.support ∪ g₂.support :=\nby simp [zip_with_def]\n\nend map_range_and_zip_with\n\nlemma erase_def (i : ι) (f : Π₀ i, β i) :\n  f.erase i = mk (f.support.erase i) (λ j, f j.1) :=\nby { ext j, by_cases h1 : j = i; by_cases h2 : f j ≠ 0; simp at h2; simp [h1, h2] }\n\n@[simp] lemma support_erase (i : ι) (f : Π₀ i, β i) :\n  (f.erase i).support = f.support.erase i :=\nby { ext j, by_cases h1 : j = i; by_cases h2 : f j ≠ 0; simp at h2; simp [h1, h2] }\n\nsection filter_and_subtype_domain\n\nvariables {p : ι → Prop} [decidable_pred p]\n\nlemma filter_def (f : Π₀ i, β i) :\n  f.filter p = mk (f.support.filter p) (λ i, f i.1) :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i ≠ 0;\n simp at h2; simp [h1, h2]\n\n@[simp] lemma support_filter (f : Π₀ i, β i) :\n  (f.filter p).support = f.support.filter p :=\nby ext i; by_cases h : p i; simp [h]\n\nlemma subtype_domain_def (f : Π₀ i, β i) :\n  f.subtype_domain p = mk (f.support.subtype p) (λ i, f i) :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i ≠ 0;\ntry {simp at h2}; dsimp; simp [h1, h2, ← subtype.val_eq_coe]\n\n@[simp] lemma support_subtype_domain {f : Π₀ i, β i} :\n  (subtype_domain p f).support = f.support.subtype p :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i ≠ 0;\ntry {simp at h2}; dsimp; simp [h1, h2]\n\nend filter_and_subtype_domain\n\nend support_basic\n\nlemma support_add [Π i, add_zero_class (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  {g₁ g₂ : Π₀ i, β i} :\n  (g₁ + g₂).support ⊆ g₁.support ∪ g₂.support :=\nsupport_zip_with\n\n@[simp] lemma support_neg [Π i, add_group (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  {f : Π₀ i, β i} :\n  support (-f) = support f :=\nby ext i; simp\n\nlemma support_smul {γ : Type w} [semiring γ] [Π i, add_comm_monoid (β i)] [Π i, module γ (β i)]\n  [Π ( i : ι) (x : β i), decidable (x ≠ 0)]\n  (b : γ) (v : Π₀ i, β i) : (b • v).support ⊆ v.support :=\nsupport_map_range\n\ninstance [Π i, has_zero (β i)] [Π i, decidable_eq (β i)] : decidable_eq (Π₀ i, β i) :=\nassume f g, decidable_of_iff (f.support = g.support ∧ (∀i∈f.support, f i = g i))\n  ⟨assume ⟨h₁, h₂⟩, ext $ assume i,\n      if h : i ∈ f.support then h₂ i h else\n        have hf : f i = 0, by rwa [f.mem_support_iff, not_not] at h,\n        have hg : g i = 0, by rwa [h₁, g.mem_support_iff, not_not] at h,\n        by rw [hf, hg],\n    by intro h; subst h; simp⟩\n\nsection prod_and_sum\n\nvariables {γ : Type w}\n\n-- [to_additive sum] for dfinsupp.prod doesn't work, the equation lemmas are not generated\n/-- `sum f g` is the sum of `g i (f i)` over the support of `f`. -/\ndef sum [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)] [add_comm_monoid γ]\n  (f : Π₀ i, β i) (g : Π i, β i → γ) : γ :=\n∑ i in f.support, g i (f i)\n\n/-- `prod f g` is the product of `g i (f i)` over the support of `f`. -/\n@[to_additive]\ndef prod [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)] [comm_monoid γ]\n  (f : Π₀ i, β i) (g : Π i, β i → γ) : γ :=\n∏ i in f.support, g i (f i)\n\n@[to_additive]\nlemma prod_map_range_index {β₁ : ι → Type v₁} {β₂ : ι → Type v₂}\n  [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n  [Π i (x : β₁ i), decidable (x ≠ 0)] [Π i (x : β₂ i), decidable (x ≠ 0)] [comm_monoid γ]\n  {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} {h : Π i, β₂ i → γ}\n  (h0 : ∀i, h i 0 = 1) :\n  (map_range f hf g).prod h = g.prod (λi b, h i (f i b)) :=\nbegin\n  rw [map_range_def],\n  refine (finset.prod_subset support_mk_subset _).trans _,\n  { intros i h1 h2,\n    dsimp, simp [h1] at h2, dsimp at h2,\n    simp [h1, h2, h0] },\n  { refine finset.prod_congr rfl _,\n    intros i h1,\n    simp [h1] }\nend\n\n@[to_additive]\nlemma prod_zero_index [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {h : Π i, β i → γ} : (0 : Π₀ i, β i).prod h = 1 :=\nrfl\n\n@[to_additive]\nlemma prod_single_index [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)] [comm_monoid γ]\n  {i : ι} {b : β i} {h : Π i, β i → γ} (h_zero : h i 0 = 1) :\n  (single i b).prod h = h i b :=\nbegin\n  by_cases h : b ≠ 0,\n  { simp [dfinsupp.prod, support_single_ne_zero h] },\n  { rw [not_not] at h, simp [h, prod_zero_index, h_zero], refl }\nend\n\n@[to_additive]\nlemma prod_neg_index [Π i, add_group (β i)] [Π i (x : β i), decidable (x ≠ 0)] [comm_monoid γ]\n  {g : Π₀ i, β i} {h : Π i, β i → γ} (h0 : ∀i, h i 0 = 1) :\n  (-g).prod h = g.prod (λi b, h i (- b)) :=\nprod_map_range_index h0\n\nomit dec\n@[to_additive]\nlemma prod_comm {ι₁ ι₂ : Sort*} {β₁ : ι₁ → Type*} {β₂ : ι₂ → Type*}\n  [decidable_eq ι₁] [decidable_eq ι₂] [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n  [Π i (x : β₁ i), decidable (x ≠ 0)] [Π i (x : β₂ i), decidable (x ≠ 0)] [comm_monoid γ]\n  (f₁ : Π₀ i, β₁ i) (f₂ : Π₀ i, β₂ i) (h : Π i, β₁ i → Π i, β₂ i → γ) :\n  f₁.prod (λ i₁ x₁, f₂.prod $ λ i₂ x₂, h i₁ x₁ i₂ x₂) =\n  f₂.prod (λ i₂ x₂, f₁.prod $ λ i₁ x₁, h i₁ x₁ i₂ x₂) := finset.prod_comm\n\n@[simp] lemma sum_apply {ι₁ : Type u₁} [decidable_eq ι₁] {β₁ : ι₁ → Type v₁}\n  [Π i₁, has_zero (β₁ i₁)] [Π i (x : β₁ i), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)]\n  {f : Π₀ i₁, β₁ i₁} {g : Π i₁, β₁ i₁ → Π₀ i, β i} {i₂ : ι} :\n  (f.sum g) i₂ = f.sum (λi₁ b, g i₁ b i₂) :=\n(f.support.sum_hom (λf : Π₀ i, β i, f i₂)).symm\ninclude dec\n\nlemma support_sum {ι₁ : Type u₁} [decidable_eq ι₁] {β₁ : ι₁ → Type v₁}\n  [Π i₁, has_zero (β₁ i₁)] [Π i (x : β₁ i), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  {f : Π₀ i₁, β₁ i₁} {g : Π i₁, β₁ i₁ → Π₀ i, β i} :\n  (f.sum g).support ⊆ f.support.bUnion (λi, (g i (f i)).support) :=\nhave ∀i₁ : ι, f.sum (λ (i : ι₁) (b : β₁ i), (g i b) i₁) ≠ 0 →\n    (∃ (i : ι₁), f i ≠ 0 ∧ ¬ (g i (f i)) i₁ = 0),\n  from assume i₁ h,\n  let ⟨i, hi, ne⟩ := finset.exists_ne_zero_of_sum_ne_zero h in\n  ⟨i, (f.mem_support_iff i).mp hi, ne⟩,\nby simpa [finset.subset_iff, mem_support_iff, finset.mem_bUnion, sum_apply] using this\n\n@[simp, to_additive] lemma prod_one [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {f : Π₀ i, β i} :\n  f.prod (λi b, (1 : γ)) = 1 :=\nfinset.prod_const_one\n\n@[simp, to_additive] lemma prod_mul [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {f : Π₀ i, β i} {h₁ h₂ : Π i, β i → γ} :\n  f.prod (λi b, h₁ i b * h₂ i b) = f.prod h₁ * f.prod h₂ :=\nfinset.prod_mul_distrib\n\n@[simp, to_additive] lemma prod_inv [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_group γ] {f : Π₀ i, β i} {h : Π i, β i → γ} :\n  f.prod (λi b, (h i b)⁻¹) = (f.prod h)⁻¹ :=\nf.support.prod_hom (@has_inv.inv γ _)\n\n@[to_additive]\nlemma prod_add_index [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {f g : Π₀ i, β i}\n  {h : Π i, β i → γ} (h_zero : ∀i, h i 0 = 1) (h_add : ∀i b₁ b₂, h i (b₁ + b₂) = h i b₁ * h i b₂) :\n  (f + g).prod h = f.prod h * g.prod h :=\nhave f_eq : ∏ i in f.support ∪ g.support, h i (f i) = f.prod h,\n  from (finset.prod_subset (finset.subset_union_left _ _) $\n    by simp [mem_support_iff, h_zero] {contextual := tt}).symm,\nhave g_eq : ∏ i in f.support ∪ g.support, h i (g i) = g.prod h,\n  from (finset.prod_subset (finset.subset_union_right _ _) $\n    by simp [mem_support_iff, h_zero] {contextual := tt}).symm,\ncalc ∏ i in (f + g).support, h i ((f + g) i) =\n      ∏ i in f.support ∪ g.support, h i ((f + g) i) :\n    finset.prod_subset support_add $\n      by simp [mem_support_iff, h_zero] {contextual := tt}\n  ... = (∏ i in f.support ∪ g.support, h i (f i)) *\n      (∏ i in f.support ∪ g.support, h i (g i)) :\n    by simp [h_add, finset.prod_mul_distrib]\n  ... = _ : by rw [f_eq, g_eq]\n\n/--\nWhen summing over an `add_monoid_hom`, the decidability assumption is not needed, and the result is\nalso an `add_monoid_hom`.\n-/\ndef sum_add_hom [Π i, add_zero_class (β i)] [add_comm_monoid γ] (φ : Π i, β i →+ γ) :\n  (Π₀ i, β i) →+ γ :=\n{ to_fun := (λ f,\n    quotient.lift_on f (λ x, ∑ i in x.2.to_finset, φ i (x.1 i)) $ λ x y H,\n    begin\n      have H1 : x.2.to_finset ∩ y.2.to_finset ⊆ x.2.to_finset, from finset.inter_subset_left _ _,\n      have H2 : x.2.to_finset ∩ y.2.to_finset ⊆ y.2.to_finset, from finset.inter_subset_right _ _,\n      refine (finset.sum_subset H1 _).symm.trans\n          ((finset.sum_congr rfl _).trans (finset.sum_subset H2 _)),\n      { intros i H1 H2, rw finset.mem_inter at H2, rw H i,\n        simp only [multiset.mem_to_finset] at H1 H2,\n        rw [(y.3 i).resolve_left (mt (and.intro H1) H2), add_monoid_hom.map_zero] },\n      { intros i H1, rw H i },\n      { intros i H1 H2, rw finset.mem_inter at H2, rw ← H i,\n        simp only [multiset.mem_to_finset] at H1 H2,\n        rw [(x.3 i).resolve_left (mt (λ H3, and.intro H3 H1) H2), add_monoid_hom.map_zero] }\n    end),\n  map_add' := assume f g,\n  begin\n    refine quotient.induction_on f (λ x, _),\n    refine quotient.induction_on g (λ y, _),\n    change ∑ i in _, _ = (∑ i in _, _) + (∑ i in _, _),\n    simp only, conv { to_lhs, congr, skip, funext, rw add_monoid_hom.map_add },\n    simp only [finset.sum_add_distrib],\n    congr' 1,\n    { refine (finset.sum_subset _ _).symm,\n      { intro i, simp only [multiset.mem_to_finset, multiset.mem_add], exact or.inl },\n      { intros i H1 H2, simp only [multiset.mem_to_finset, multiset.mem_add] at H2,\n        rw [(x.3 i).resolve_left H2, add_monoid_hom.map_zero] } },\n    { refine (finset.sum_subset _ _).symm,\n      { intro i, simp only [multiset.mem_to_finset, multiset.mem_add], exact or.inr },\n      { intros i H1 H2, simp only [multiset.mem_to_finset, multiset.mem_add] at H2,\n        rw [(y.3 i).resolve_left H2, add_monoid_hom.map_zero] } }\n  end,\n  map_zero' := rfl }\n\n@[simp] lemma sum_add_hom_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (φ : Π i, β i →+ γ) (i) (x : β i) : sum_add_hom φ (single i x) = φ i x :=\n(add_zero _).trans $ congr_arg (φ i) $ show (if H : i ∈ ({i} : finset _) then x else 0) = x,\nfrom dif_pos $ finset.mem_singleton_self i\n\n@[simp] lemma sum_add_hom_comp_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (f : Π i, β i →+ γ) (i : ι) :\n  (sum_add_hom f).comp (single_add_hom β i) = f i :=\nadd_monoid_hom.ext $ λ x, sum_add_hom_single f i x\n\n/-- While we didn't need decidable instances to define it, we do to reduce it to a sum -/\nlemma sum_add_hom_apply [Π i, add_zero_class (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [add_comm_monoid γ] (φ : Π i, β i →+ γ) (f : Π₀ i, β i) :\n  sum_add_hom φ f = f.sum (λ x, φ x) :=\nbegin\n  refine quotient.induction_on f (λ x, _),\n  change ∑ i in _, _ = (∑ i in finset.filter _ _, _),\n  rw [finset.sum_filter, finset.sum_congr rfl],\n  intros i _,\n  dsimp only,\n  split_ifs,\n  refl,\n  rw [(not_not.mp h), add_monoid_hom.map_zero],\nend\n\nomit dec\nlemma sum_add_hom_comm {ι₁ ι₂ : Sort*} {β₁ : ι₁ → Type*} {β₂ : ι₂ → Type*} {γ : Type*}\n  [decidable_eq ι₁] [decidable_eq ι₂] [Π i, add_zero_class (β₁ i)] [Π i, add_zero_class (β₂ i)]\n  [add_comm_monoid γ]\n  (f₁ : Π₀ i, β₁ i) (f₂ : Π₀ i, β₂ i) (h : Π i j, β₁ i →+ β₂ j →+ γ) :\n  sum_add_hom (λ i₂, sum_add_hom (λ i₁, h i₁ i₂) f₁) f₂ =\n  sum_add_hom (λ i₁, sum_add_hom (λ i₂, (h i₁ i₂).flip) f₂) f₁ :=\nbegin\n  refine quotient.induction_on₂ f₁ f₂ (λ x₁ x₂, _),\n  simp only [sum_add_hom, add_monoid_hom.finset_sum_apply, quotient.lift_on_mk,\n    add_monoid_hom.coe_mk, add_monoid_hom.flip_apply],\n  exact finset.sum_comm,\nend\n\ninclude dec\n/-- The `dfinsupp` version of `finsupp.lift_add_hom`,-/\n@[simps apply symm_apply]\ndef lift_add_hom [Π i, add_zero_class (β i)] [add_comm_monoid γ] :\n  (Π i, β i →+ γ) ≃+ ((Π₀ i, β i) →+ γ) :=\n{ to_fun := sum_add_hom,\n  inv_fun := λ F i, F.comp (single_add_hom β i),\n  left_inv := λ x, by { ext, simp },\n  right_inv := λ ψ, by { ext, simp },\n  map_add' := λ F G, by { ext, simp } }\n\n/-- The `dfinsupp` version of `finsupp.lift_add_hom_single_add_hom`,-/\n@[simp] lemma lift_add_hom_single_add_hom [Π i, add_comm_monoid (β i)] :\n  lift_add_hom (single_add_hom β) = add_monoid_hom.id (Π₀ i, β i) :=\nlift_add_hom.to_equiv.apply_eq_iff_eq_symm_apply.2 rfl\n\n/-- The `dfinsupp` version of `finsupp.lift_add_hom_apply_single`,-/\nlemma lift_add_hom_apply_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (f : Π i, β i →+ γ) (i : ι) (x : β i) :\n  lift_add_hom f (single i x) = f i x :=\nby simp\n\n/-- The `dfinsupp` version of `finsupp.lift_add_hom_comp_single`,-/\nlemma lift_add_hom_comp_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (f : Π i, β i →+ γ) (i : ι) :\n  (lift_add_hom f).comp (single_add_hom β i) = f i :=\nby simp\n\n/-- The `dfinsupp` version of `finsupp.comp_lift_add_hom`,-/\nlemma comp_lift_add_hom {δ : Type*} [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  [add_comm_monoid δ] (g : γ →+ δ) (f : Π i, β i →+ γ) :\n  g.comp (lift_add_hom f) = lift_add_hom (λ a, g.comp (f a)) :=\nlift_add_hom.symm_apply_eq.1 $ funext $ λ a,\n  by rw [lift_add_hom_symm_apply, add_monoid_hom.comp_assoc, lift_add_hom_comp_single]\n\n@[simp]\nlemma sum_add_hom_zero [Π i, add_zero_class (β i)] [add_comm_monoid γ] :\n  sum_add_hom (λ i, (0 : β i →+ γ)) = 0 :=\n(lift_add_hom : (Π i, β i →+ γ) ≃+ _).map_zero\n\n@[simp]\nlemma sum_add_hom_add [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (g : Π i, β i →+ γ) (h : Π i, β i →+ γ) :\n  sum_add_hom (λ i, g i + h i) = sum_add_hom g + sum_add_hom h :=\nlift_add_hom.map_add _ _\n\n@[simp]\nlemma sum_add_hom_single_add_hom [Π i, add_comm_monoid (β i)] :\n  sum_add_hom (single_add_hom β) = add_monoid_hom.id _ :=\nlift_add_hom_single_add_hom\n\nlemma comp_sum_add_hom {δ : Type*} [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  [add_comm_monoid δ] (g : γ →+ δ) (f : Π i, β i →+ γ) :\n  g.comp (sum_add_hom f) = sum_add_hom (λ a, g.comp (f a)) :=\ncomp_lift_add_hom _ _\n\nlemma sum_sub_index [Π i, add_group (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [add_comm_group γ] {f g : Π₀ i, β i}\n  {h : Π i, β i → γ} (h_sub : ∀i b₁ b₂, h i (b₁ - b₂) = h i b₁ - h i b₂) :\n  (f - g).sum h = f.sum h - g.sum h :=\nbegin\n  have := (lift_add_hom (λ a, add_monoid_hom.of_map_sub (h a) (h_sub a))).map_sub f g,\n  rw [lift_add_hom_apply, sum_add_hom_apply, sum_add_hom_apply, sum_add_hom_apply] at this,\n  exact this,\nend\n\n@[to_additive]\nlemma prod_finset_sum_index {γ : Type w} {α : Type x}\n  [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ]\n  {s : finset α} {g : α → Π₀ i, β i}\n  {h : Π i, β i → γ} (h_zero : ∀i, h i 0 = 1) (h_add : ∀i b₁ b₂, h i (b₁ + b₂) = h i b₁ * h i b₂) :\n  ∏ i in s, (g i).prod h = (∑ i in s, g i).prod h :=\nbegin\n  classical,\n  exact finset.induction_on s\n  (by simp [prod_zero_index])\n  (by simp [prod_add_index, h_zero, h_add] {contextual := tt})\nend\n\n@[to_additive]\nlemma prod_sum_index  {ι₁ : Type u₁} [decidable_eq ι₁] {β₁ : ι₁ → Type v₁}\n  [Π i₁, has_zero (β₁ i₁)] [Π i (x : β₁ i), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ]\n  {f : Π₀ i₁, β₁ i₁} {g : Π i₁, β₁ i₁ → Π₀ i, β i}\n  {h : Π i, β i → γ} (h_zero : ∀i, h i 0 = 1) (h_add : ∀i b₁ b₂, h i (b₁ + b₂) = h i b₁ * h i b₂) :\n  (f.sum g).prod h = f.prod (λi b, (g i b).prod h) :=\n(prod_finset_sum_index h_zero h_add).symm\n\n@[simp] lemma sum_single [Π i, add_comm_monoid (β i)]\n  [Π i (x : β i), decidable (x ≠ 0)] {f : Π₀ i, β i} :\n  f.sum single = f :=\nbegin\n  have := add_monoid_hom.congr_fun lift_add_hom_single_add_hom f,\n  rw [lift_add_hom_apply, sum_add_hom_apply] at this,\n  exact this,\nend\n\n@[to_additive]\nlemma prod_subtype_domain_index [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {v : Π₀ i, β i} {p : ι → Prop} [decidable_pred p]\n  {h : Π i, β i → γ} (hp : ∀ x ∈ v.support, p x) :\n  (v.subtype_domain p).prod (λi b, h i b) = v.prod h :=\nfinset.prod_bij (λp _, p)\n  (by simp) (by simp)\n  (assume ⟨a₀, ha₀⟩ ⟨a₁, ha₁⟩, by simp)\n  (λ i hi, ⟨⟨i, hp i hi⟩, by simpa using hi, rfl⟩)\n\nomit dec\nlemma subtype_domain_sum [Π i, add_comm_monoid (β i)]\n  {s : finset γ} {h : γ → Π₀ i, β i} {p : ι → Prop} [decidable_pred p] :\n  (∑ c in s, h c).subtype_domain p = ∑ c in s, (h c).subtype_domain p :=\neq.symm (s.sum_hom _)\n\nlemma subtype_domain_finsupp_sum {δ : γ → Type x} [decidable_eq γ]\n  [Π c, has_zero (δ c)] [Π c (x : δ c), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)]\n  {p : ι → Prop} [decidable_pred p]\n  {s : Π₀ c, δ c} {h : Π c, δ c → Π₀ i, β i} :\n  (s.sum h).subtype_domain p = s.sum (λc d, (h c d).subtype_domain p) :=\nsubtype_domain_sum\n\nend prod_and_sum\n\n/-! ### Bundled versions of `dfinsupp.map_range`\n\nThe names should match the equivalent bundled `finsupp.map_range` definitions.\n-/\n\nsection map_range\nomit dec\n\nvariables [Π i, add_zero_class (β i)] [Π i, add_zero_class (β₁ i)] [Π i, add_zero_class (β₂ i)]\n\nlemma map_range_add (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0)\n  (hf' : ∀ i x y, f i (x + y) = f i x + f i y) (g₁ g₂ : Π₀ i, β₁ i):\n  map_range f hf (g₁ + g₂) = map_range f hf g₁ + map_range f hf g₂ :=\nbegin\n  ext,\n  simp only [map_range_apply f, coe_add, pi.add_apply, hf']\nend\n\n/-- `dfinsupp.map_range` as an `add_monoid_hom`. -/\n@[simps apply]\ndef map_range.add_monoid_hom (f : Π i, β₁ i →+ β₂ i) : (Π₀ i, β₁ i) →+ (Π₀ i, β₂ i) :=\n{ to_fun := map_range (λ i x, f i x) (λ i, (f i).map_zero),\n  map_zero' := map_range_zero _ _,\n  map_add' := map_range_add _ _ (λ i, (f i).map_add) }\n\n@[simp]\nlemma map_range.add_monoid_hom_id :\n  map_range.add_monoid_hom (λ i, add_monoid_hom.id (β₂ i)) = add_monoid_hom.id _ :=\nadd_monoid_hom.ext map_range_id\n\nlemma map_range.add_monoid_hom_comp (f : Π i, β₁ i →+ β₂ i) (f₂ : Π i, β i →+ β₁ i):\n  map_range.add_monoid_hom (λ i, (f i).comp (f₂ i)) =\n    (map_range.add_monoid_hom f).comp (map_range.add_monoid_hom f₂) :=\nadd_monoid_hom.ext $ map_range_comp (λ i x, f i x) (λ i x, f₂ i x) _ _ _\n\n/-- `dfinsupp.map_range.add_monoid_hom` as an `add_equiv`. -/\n@[simps apply]\ndef map_range.add_equiv (e : Π i, β₁ i ≃+ β₂ i) : (Π₀ i, β₁ i) ≃+ (Π₀ i, β₂ i) :=\n{ to_fun := map_range (λ i x, e i x) (λ i, (e i).map_zero),\n  inv_fun := map_range (λ i x, (e i).symm x) (λ i, (e i).symm.map_zero),\n  left_inv := λ x, by rw ←map_range_comp; { simp_rw add_equiv.symm_comp_self, simp },\n  right_inv := λ x, by rw ←map_range_comp; { simp_rw add_equiv.self_comp_symm, simp },\n  .. map_range.add_monoid_hom (λ i, (e i).to_add_monoid_hom) }\n\n@[simp]\nlemma map_range.add_equiv_refl :\n  (map_range.add_equiv $ λ i, add_equiv.refl (β₁ i)) = add_equiv.refl _ :=\nadd_equiv.ext map_range_id\n\nlemma map_range.add_equiv_trans (f : Π i, β i ≃+ β₁ i) (f₂ : Π i, β₁ i ≃+ β₂ i):\n  map_range.add_equiv (λ i, (f i).trans (f₂ i)) =\n    (map_range.add_equiv f).trans (map_range.add_equiv f₂) :=\nadd_equiv.ext $ map_range_comp (λ i x, f₂ i x) (λ i x, f i x) _ _ _\n\n@[simp]\nlemma map_range.add_equiv_symm (e : Π i, β₁ i ≃+ β₂ i) :\n  (map_range.add_equiv e).symm = map_range.add_equiv (λ i, (e i).symm) := rfl\n\nend map_range\n\nend dfinsupp\n\n/-! ### Product and sum lemmas for bundled morphisms -/\nsection\n\nvariables [decidable_eq ι]\n\nnamespace monoid_hom\nvariables {R S : Type*}\nvariables [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n\n@[simp, to_additive]\nlemma map_dfinsupp_prod [comm_monoid R] [comm_monoid S]\n  (h : R →* S) (f : Π₀ i, β i) (g : Π i, β i → R) :\n  h (f.prod g) = f.prod (λ a b, h (g a b)) := h.map_prod _ _\n\n@[to_additive]\nlemma coe_dfinsupp_prod [monoid R] [comm_monoid S]\n  (f : Π₀ i, β i) (g : Π i, β i → R →* S) :\n  ⇑(f.prod g) = f.prod (λ a b, (g a b)) := coe_prod _ _\n\n@[simp, to_additive]\nlemma dfinsupp_prod_apply [monoid R] [comm_monoid S]\n  (f : Π₀ i, β i) (g : Π i, β i → R →* S) (r : R) :\n  (f.prod g) r = f.prod (λ a b, (g a b) r) := finset_prod_apply _ _ _\n\nend monoid_hom\n\nnamespace add_monoid_hom\nvariables {R S : Type*}\n\nopen dfinsupp\n\n/-! The above lemmas, repeated for `dfinsupp.sum_add_hom`. -/\n@[simp]\nlemma map_dfinsupp_sum_add_hom [add_comm_monoid R] [add_comm_monoid S] [Π i, add_comm_monoid (β i)]\n  (h : R →+ S) (f : Π₀ i, β i) (g : Π i, β i →+ R) :\n  h (sum_add_hom g f) = sum_add_hom (λ i, h.comp (g i)) f :=\ncongr_fun (comp_lift_add_hom h g) f\n\n@[simp]\nlemma dfinsupp_sum_add_hom_apply [add_zero_class R] [add_comm_monoid S] [Π i, add_comm_monoid (β i)]\n  (f : Π₀ i, β i) (g : Π i, β i →+ R →+ S) (r : R) :\n  (sum_add_hom g f) r = sum_add_hom (λ i, (eval r).comp (g i)) f :=\nmap_dfinsupp_sum_add_hom (eval r) f g\n\nlemma coe_dfinsupp_sum_add_hom [add_zero_class R] [add_comm_monoid S] [Π i, add_comm_monoid (β i)]\n  (f : Π₀ i, β i) (g : Π i, β i →+ R →+ S) :\n  ⇑(sum_add_hom g f) = sum_add_hom (λ i, (coe_fn R S).comp (g i)) f :=\nmap_dfinsupp_sum_add_hom (coe_fn R S) f g\n\nend add_monoid_hom\n\nend\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/dfinsupp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4751173776013376}}
{"text": "/-\nCopyright (c) 2015 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Floris van Doorn\n\nTheorems about 2-dimensional paths\n-/\n\nimport .cubical.square\nuniverses u v w\nhott_theory\n\nnamespace hott\nopen function hott.is_equiv hott.equiv\n\nnamespace eq\n  variables {A : Type _} {B : Type _} {C : Type _} {f : A → B} {a a' a₁ a₂ a₃ a₄ : A} {b b' : B}\n\n  @[hott] theorem ap_is_constant_eq (p : Πx, f x = b) (q : a = a') :\n      ap_is_constant f p q =\n      eq_con_inv_of_con_eq ((eq_of_square (square_of_pathover (apd p q)))⁻¹ ⬝\n      whisker_left (p a) (ap_constant q b)) :=\n  begin\n    induction q, dsimp [ap_constant, ap_is_constant, apd], \n    hinduction p a, refl\n  end\n\n  @[hott] def ap_inv2 {p q : a = a'} (r : p = q)\n    : square (ap (ap f) (inverse2 r))\n             (inverse2 (ap (ap f) r))\n             (ap_inv f p)\n             (ap_inv f q) :=\n  by induction r;exact hrfl\n\n  @[hott] def ap_con2 {p₁ q₁ : a₁ = a₂} {p₂ q₂ : a₂ = a₃} (r₁ : p₁ = q₁) (r₂ : p₂ = q₂)\n    : square (ap (ap f) (r₁ ◾ r₂))\n             (ap (ap f) r₁ ◾ ap (ap f) r₂)\n             (ap_con f p₁ p₂)\n             (ap_con f q₁ q₂) :=\n  by induction r₂;induction r₁;exact hrfl\n\n  @[hott] theorem ap_con_right_inv_sq {A B : Type _} {a1 a2 : A} (f : A → B) (p : a1 = a2) :\n    square (ap (ap f) (con.right_inv p))\n           (con.right_inv (ap f p))\n           (ap_con f p p⁻¹ ⬝ whisker_left _ (ap_inv f p))\n           idp :=\n  by induction p;apply hrefl\n\n  @[hott] theorem ap_con_left_inv_sq {A B : Type _} {a1 a2 : A} (f : A → B) (p : a1 = a2) :\n    square (ap (ap f) (con.left_inv p))\n           (con.left_inv (ap f p))\n           (ap_con f p⁻¹ p ⬝ whisker_right _ (ap_inv f p))\n           idp :=\n  by induction p;apply vrefl\n\n  @[hott] def ap02_compose {A B C : Type _} (g : B → C) (f : A → B) {a a' : A}\n    {p₁ p₂ : a = a'} (q : p₁ = p₂) :\n    square (ap_compose g f p₁) (ap_compose g f p₂) (ap02 (g ∘ f) q) (ap02 g (ap02 f q)) :=\n  by induction q; exact vrfl\n\n  @[hott] def ap02_id {A : Type _} {a a' : A}\n    {p₁ p₂ : a = a'} (q : p₁ = p₂) :\n    square (ap_id p₁) (ap_id p₂) (ap02 id q) q :=\n  by induction q; exact vrfl\n\n  @[hott] theorem ap_ap_is_constant {A B C : Type _} (g : B → C) {f : A → B} {b : B}\n    (p : Πx, f x = b) {x y : A} (q : x = y) :\n    square (ap (ap g) (ap_is_constant f p q))\n           (by exact (ap_is_constant (g ∘ f) (λa, ap g (p a)) q))\n           (ap_compose g f q)⁻¹\n           (ap_con _ _ _ ⬝ whisker_left _ (ap_inv _ _)) :=\n  begin\n    induction q, dsimp [ap_is_constant], hinduction (p x), apply ids\n  end\n\n  @[hott] theorem ap_ap_compose {A B C D : Type _} (h : C → D) (g : B → C) (f : A → B)\n    {x y : A} (p : x = y) :\n    square (ap_compose (h ∘ g) f p)\n           (ap (ap h) (ap_compose g f p))\n           (ap_compose h (g ∘ f) p)\n           (ap_compose h g (ap f p)) :=\n  by induction p; exact ids\n\n  @[hott] def ap_compose_inv {A B C : Type _} (g : B → C) (f : A → B)\n    {x y : A} (p : x = y) :\n    square (ap_compose g f p⁻¹)\n           (inverse2 (ap_compose g f p) ⬝ (ap_inv g (ap f p))⁻¹)\n           (ap_inv (g ∘ f) p)\n           (ap (ap g) (ap_inv f p)) :=\n  by induction p; exact ids\n\n  @[hott] def ap_compose_con (g : B → C) (f : A → B) (p : a₁ = a₂) (q : a₂ = a₃) :\n    square (ap_compose g f (p ⬝ q))\n           (ap_compose g f p ◾ ap_compose g f q ⬝ (ap_con g (ap f p) (ap f q))⁻¹)\n           (ap_con (g ∘ f) p q)\n           (ap (ap g) (ap_con f p q)) :=\n  by induction q; induction p; exact ids\n\n  @[hott] theorem ap_compose_natural {A B C : Type _} (g : B → C) (f : A → B)\n    {x y : A} {p q : x = y} (r : p = q) :\n    square (ap (ap (g ∘ f)) r)\n           (ap (ap g ∘ ap f) r)\n           (ap_compose g f p)\n           (ap_compose g f q) :=\n  natural_square_tr (ap_compose g f) r\n\n  @[hott] theorem whisker_right_eq_of_con_inv_eq_idp {p q : a₁ = a₂} (r : p ⬝ q⁻¹ = idp) :\n    whisker_right q⁻¹ (eq_of_con_inv_eq_idp r) ⬝ con.right_inv q = r :=\n  begin induction q, hinduction r using eq.rec_symm, reflexivity end\n\n  @[hott] theorem ap_eq_of_con_inv_eq_idp (f : A → B) {p q : a₁ = a₂} (r : p ⬝ q⁻¹ = idp)\n  : ap02 f (eq_of_con_inv_eq_idp r) =\n           eq_of_con_inv_eq_idp (whisker_left _ (ap_inv _ _)⁻¹ ⬝ (ap_con _ _ _)⁻¹ ⬝ ap02 f r) :=\n  by induction q; hinduction r using eq.rec_symm; reflexivity\n\n  @[hott] theorem eq_of_con_inv_eq_idp_con2 {p p' q q' : a₁ = a₂} (r : p = p') (s : q = q')\n    (t : p' ⬝ q'⁻¹ = idp)\n  : eq_of_con_inv_eq_idp (r ◾ inverse2 s ⬝ t) = r ⬝ eq_of_con_inv_eq_idp t ⬝ s⁻¹ :=\n  by induction s; induction r; induction q; reflexivity\n\n  @[hott] def naturality_apd_eq {A : Type _} {B : A → Type _} {a a₂ : A} {f g : Πa, B a}\n    (H : f ~ g) (p : a = a₂)\n    : apd f p = concato_eq (eq_concato (H a) (apd g p)) (H a₂)⁻¹ :=\n  begin\n    induction p, dsimp, \n    hgeneralize : H a = p, revert p,\n    hgeneralize : g a = x, intro p, \n    induction p,\n    reflexivity\n  end\n\n  @[hott] theorem con_tr_idp {P : A → Type _} {x y : A} (q : x = y) (u : P x) :\n    con_tr idp q u = ap (λp, p ▸ u) (idp_con q) :=\n  by induction q;reflexivity\n\n  @[hott] def whisker_left_idp_con_eq_assoc\n    {A : Type _} {a₁ a₂ a₃ : A} (p : a₁ = a₂) (q : a₂ = a₃)\n    : whisker_left p (idp_con q)⁻¹ = con.assoc p idp q :=\n  by induction q; reflexivity\n\n  @[hott] def whisker_left_inverse2 {A : Type _} {a : A} {p : a = a} (q : p = idp)\n    : whisker_left p q⁻² ⬝ q = con.right_inv p :=\n  by hinduction q using eq.rec_symm; reflexivity\n\n  @[hott] def cast_fn_cast_square {A : Type _} {B C : A → Type _} (f : Π⦃a⦄, B a → C a) {a₁ a₂ : A}\n    (p : a₁ = a₂) (q : a₂ = a₁) (r : p ⬝ q = idp) (b : B a₁) :\n    cast (ap C q) (f (cast (ap B p) b)) = f b :=\n  have q⁻¹ = p, from inv_eq_of_idp_eq_con r⁻¹,\n  begin induction this, induction q, reflexivity end\n\n  @[hott] def ap011_ap_square_right {A B C : Type _} (f : A → B → C) {a a' : A} (p : a = a')\n    {b₁ b₂ b₃ : B} {q₁₂ : b₁ = b₂} {q₂₃ : b₂ = b₃} {q₁₃ : b₁ = b₃} (r : q₁₂ ⬝ q₂₃ = q₁₃) :\n    square (ap011 f p q₁₂) (ap (λx, f x b₃) p) (ap (f a) q₁₃) (ap (f a') q₂₃) :=\n  by induction r; induction q₂₃; induction q₁₂; induction p; exact ids\n\n  @[hott] def ap011_ap_square_left {A B C : Type _} (f : B → A → C) {a a' : A} (p : a = a')\n    {b₁ b₂ b₃ : B} {q₁₂ : b₁ = b₂} {q₂₃ : b₂ = b₃} {q₁₃ : b₁ = b₃} (r : q₁₂ ⬝ q₂₃ = q₁₃) :\n    square (ap011 f q₁₂ p) (ap (f b₃) p) (ap (λx, f x a) q₁₃) (ap (λx, f x a') q₂₃) :=\n  by induction r; induction q₂₃; induction q₁₂; induction p; exact ids\n\n  @[hott] def con2_assoc {A : Type _} {x y z t : A} {p p' : x = y} {q q' : y = z} {r r' : z = t}\n    (h : p = p') (h' : q = q') (h'' : r = r') :\n    square ((h ◾ h') ◾ h'') (h ◾ (h' ◾ h'')) (con.assoc p q r) (con.assoc p' q' r') :=\n  by induction h; induction h'; induction h''; exact hrfl\n\n  @[hott] def con_left_inv_idp {A : Type _} {x : A} {p : x = x} (q : p = idp)\n    : con.left_inv p = q⁻² ◾ q :=\n  by hinduction q using eq.rec_symm; reflexivity\n\n  @[hott] def eckmann_hilton_con2 {A : Type _} {x : A} {p p' q q': idp = idp :> x = x}\n    (h : p = p') (h' : q = q') : square (h ◾ h') (h' ◾ h) (eckmann_hilton p q) (eckmann_hilton p' q') :=\n  by induction h; induction h'; exact hrfl\n\n  @[hott] def ap_con_fn {A B : Type _} {a a' : A} {b : B} (g h : A → b = b) (p : a = a') :\n    ap (λa, g a ⬝ h a) p = ap g p ◾ ap h p :=\n  by induction p; reflexivity\n\n  @[hott] def ap_eq_ap011 {A B C X : Type _} (f : A → B → C) (g : X → A) (h : X → B) {x x' : X}\n    (p : x = x') : ap (λx, f (g x) (h x)) p = ap011 f (ap g p) (ap h p) :=\n  by induction p; reflexivity\n\n  @[hott] def ap_is_weakly_constant {A B : Type _} {f : A → B}\n    (h : is_weakly_constant f) {a a' : A} (p : a = a') : ap f p = (h a a)⁻¹ ⬝ h a a' :=\n  by induction p; exact (con.left_inv _)⁻¹\n\n  @[hott] def ap_is_constant_idp {A B : Type _} {f : A → B} {b : B} (p : Πa, f a = b) {a : A} (q : a = a)\n    (r : q = idp) : ap_is_constant f p q = ap02 f r ⬝ (con.right_inv (p a))⁻¹ :=\n  by hinduction r using eq.rec_symm; exact (idp_con _)⁻¹\n\n  @[hott] def con_right_inv_natural {A : Type _} {a a' : A} {p p' : a = a'} (q : p = p') :\n    con.right_inv p = q ◾ q⁻² ⬝ con.right_inv p' :=\n  by induction q; induction p; reflexivity\n\n  @[hott] def whisker_right_ap {A B : Type _} {a a' : A}{b₁ b₂ b₃ : B} (q : b₂ = b₃) (f : A → b₁ = b₂)\n    (p : a = a') : whisker_right q (ap f p) = ap (λa, f a ⬝ q) p :=\n  by induction p; reflexivity\n\n  @[hott] def ap02_ap_constant {A B C : Type _} {a a' : A} (f : B → C) (b : B) (p : a = a') :\n    square (ap_constant p (f b)) (ap02 f (ap_constant p b)) (ap_compose f (λx, b) p) idp :=\n  by induction p; exact ids\n\n  @[hott] def ap_constant_compose {A B C : Type _} {a a' : A} (c : C) (f : A → B) (p : a = a') :\n    square (ap_constant p c) (ap_constant (ap f p) c) (ap_compose (λx, c) f p) idp :=\n  by induction p; exact ids\n\n  @[hott] def ap02_constant {A B : Type _} {a a' : A} (b : B) {p p' : a = a'}\n    (q : p = p') : square (ap_constant p b) (ap_constant p' b) (ap02 (λx, b) q) idp :=\n  by induction q; exact vrfl\n\nend eq\nend hott", "meta": {"author": "gebner", "repo": "hott3", "sha": "7ead7a8a2503049eacd45cbff6587802bae2add2", "save_path": "github-repos/lean/gebner-hott3", "path": "github-repos/lean/gebner-hott3/hott3-7ead7a8a2503049eacd45cbff6587802bae2add2/src/hott/eq2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.6926419704455588, "lm_q1q2_score": 0.47511737324927045}}
{"text": "import Lean \nopen Lean\n\ndef checkGetBelowIndices (ctorName : Name) (indices : Array Nat) : MetaM Unit := do\n  let actualIndices ← Meta.IndPredBelow.getBelowIndices ctorName\n  if actualIndices != indices then\n    throwError \"wrong indices for {ctorName}: {actualIndices} ≟ {indices}\"\n\nnamespace Ex\ninductive LE : Nat → Nat → Prop\n  | refl : LE n n\n  | succ : LE n m → LE n m.succ\n#eval checkGetBelowIndices ``LE.refl #[1]\n#eval checkGetBelowIndices ``LE.succ #[1, 2, 3]\n\ndef typeOf {α : Sort u} (a : α) := α\n\ntheorem LE_brecOn : typeOf @LE.brecOn =\n∀ {motive : (a a_1 : Nat) → LE a a_1 → Prop} {a a_1 : Nat} (x : LE a a_1),\n  (∀ (a a_2 : Nat) (x : LE a a_2), @LE.below motive a a_2 x → motive a a_2 x) → motive a a_1 x := rfl\n\ntheorem LE.trans : LE m n → LE n o → LE m o := by\n  intro h1 h2\n  induction h2 with\n  | refl => assumption\n  | succ h2 ih => exact succ (ih h1)\n\ntheorem LE.trans' : LE m n → LE n o → LE m o\n  | h1, refl    => h1\n  | h1, succ h2 => succ (trans' h1 h2) -- the structural recursion in being performed on the implicit `Nat` parameter\n\ninductive Even : Nat → Prop\n  | zero : Even 0\n  | ss   : Even n → Even n.succ.succ\n#eval checkGetBelowIndices ``Even.zero #[]\n#eval checkGetBelowIndices ``Even.ss #[1, 2]\n\ntheorem Even_brecOn : typeOf @Even.brecOn = ∀ {motive : (a : Nat) → Even a → Prop} {a : Nat} (x : Even a),\n  (∀ (a : Nat) (x : Even a), @Even.below motive a x → motive a x) → motive a x := rfl\n\ntheorem Even.add : Even n → Even m → Even (n+m) := by\n  intro h1 h2\n  induction h2 with\n  | zero => exact h1\n  | ss h2 ih => exact ss ih\n\ntheorem Even.add' : Even n → Even m → Even (n+m)\n  | h1, zero  => h1\n  | h1, ss h2 => ss (add' h1 h2)  -- the structural recursion in being performed on the implicit `Nat` parameter\n\ntheorem mul_left_comm (n m o : Nat) : n * (m * o) = m * (n * o) := by\n  rw [← Nat.mul_assoc, Nat.mul_comm n m, Nat.mul_assoc]\n\ninductive Power2 : Nat → Prop\n  | base : Power2 1\n  | ind  : Power2 n → Power2 (2*n) -- Note that index here is not a constructor\n#eval checkGetBelowIndices ``Power2.base #[]\n#eval checkGetBelowIndices ``Power2.ind #[1, 2]\n\ntheorem Power2_brecOn : typeOf @Power2.brecOn = ∀ {motive : (a : Nat) → Power2 a → Prop} {a : Nat} (x : Power2 a),\n  (∀ (a : Nat) (x : Power2 a), @Power2.below motive a x → motive a x) → motive a x := rfl\n\ntheorem Power2.mul : Power2 n → Power2 m → Power2 (n*m) := by\n  intro h1 h2\n  induction h2 with\n  | base      => simp_all\n  | ind h2 ih => exact mul_left_comm .. ▸ ind ih\n\n/- The following example fails because the structural recursion cannot be performed on the `Nat`s and\n   the `brecOn` construction doesn't work for inductive predicates -/\n-- theorem Power2.mul' : Power2 n → Power2 m → Power2 (n*m)\n--  | h1, base => by simp_all\n--  | h1, ind h2 => mul_left_comm .. ▸ ind (mul' h1 h2)\n\ninductive tm : Type :=\n  | C : Nat → tm\n  | P : tm → tm → tm\n\nopen tm\n\nset_option hygiene false in\ninfixl:40 \" ==> \" => step\ninductive step : tm → tm → Prop :=\n  | ST_PlusConstConst : ∀ n1 n2,\n      P (C n1) (C n2) ==> C (n1 + n2)\n  | ST_Plus1 : ∀ t1 t1' t2,\n      t1 ==> t1' →\n      P t1 t2 ==> P t1' t2\n  | ST_Plus2 : ∀ n1 t2 t2',\n      t2 ==> t2' →\n      P (C n1) t2 ==> P (C n1) t2'\n#eval checkGetBelowIndices ``step.ST_PlusConstConst #[1, 2]\n#eval checkGetBelowIndices ``step.ST_Plus1 #[1, 2, 3, 4]\n#eval checkGetBelowIndices ``step.ST_Plus2 #[1, 2, 3, 4]\n\ndef deterministic {X : Type} (R : X → X → Prop) :=\n  ∀ x y1 y2 : X, R x y1 → R x y2 → y1 = y2\n\ntheorem step_deterministic' : deterministic step := λ x y₁ y₂ hy₁ hy₂ =>\n  @step.brecOn (λ s t st => ∀ y₂, s ==> y₂ → t = y₂) _ _ hy₁ (λ s t st hy₁ y₂ hy₂ =>\n    match hy₁, hy₂ with\n    | step.below.ST_PlusConstConst _ _, step.ST_PlusConstConst _ _ => rfl\n    | step.below.ST_Plus1 _ _ _ hy₁ ih, step.ST_Plus1 _ t₁' _ _ => by rw [←ih t₁']; assumption\n    | step.below.ST_Plus1 _ _ _ hy₁ ih, step.ST_Plus2 _ _ _ _ => by cases hy₁\n    | step.below.ST_Plus2 _ _ _ _ ih, step.ST_Plus2 _ _ t₂ _ => by rw [←ih t₂]; assumption\n    | step.below.ST_Plus2 _ _ _ hy₁ _, step.ST_PlusConstConst _ _ => by cases hy₁\n    ) y₂ hy₂\n\nsection NestedRecursion\n\naxiom f : Nat → Nat\n\ninductive is_nat : Nat -> Prop\n| Z : is_nat 0\n| S {n} : is_nat n → is_nat (f n)\n#eval checkGetBelowIndices ``is_nat.Z #[]\n#eval checkGetBelowIndices ``is_nat.S #[1, 2]\n\naxiom P : Nat → Prop\naxiom F0 : P 0\naxiom F1 : P (f 0)\naxiom FS {n : Nat} : P n → P (f (f n))\n\n-- we would like to write this\n-- theorem foo : ∀ {n}, is_nat n → P n\n-- | _, is_nat.Z => F0\n-- | _, is_nat.S is_nat.Z => F1\n-- | _, is_nat.S (is_nat.S h) => FS (foo h)\n\ntheorem foo' : ∀ {n}, is_nat n → P n := fun h =>\n  @is_nat.brecOn (fun n hn => P n) _ h fun n h ih =>\n  match ih with\n  | is_nat.below.Z => F0\n  | is_nat.below.S is_nat.below.Z _ => F1\n  | is_nat.below.S (is_nat.below.S b hx) h₂ => FS hx\n\nend NestedRecursion\n\nend Ex\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/run/inductive_pred.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4750428772178636}}
{"text": "/-\nCopyright (c) 2020 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot\n-/\nimport analysis.specific_limits.basic\n\n/-!\n# Hofer's lemma\n\nThis is an elementary lemma about complete metric spaces. It is motivated by an\napplication to the bubbling-off analysis for holomorphic curves in symplectic topology.\nWe are *very* far away from having these applications, but the proof here is a nice\nexample of a proof needing to construct a sequence by induction in the middle of the proof.\n\n## References:\n\n* H. Hofer and C. Viterbo, *The Weinstein conjecture in the presence of holomorphic spheres*\n-/\n\nopen_locale classical topological_space big_operators\nopen filter finset\n\nlocal notation `d` := dist\n\nlemma hofer {X: Type*} [metric_space X] [complete_space X]\n  (x : X) (ε : ℝ) (ε_pos : 0 < ε)\n  {ϕ : X → ℝ} (cont : continuous ϕ) (nonneg : ∀ y, 0 ≤ ϕ y) :\n  ∃ (ε' > 0) (x' : X), ε' ≤ ε ∧\n                       d x' x ≤ 2*ε ∧\n                       ε * ϕ(x) ≤ ε' * ϕ x' ∧\n                       ∀ y, d x' y ≤ ε' → ϕ y ≤ 2*ϕ x' :=\nbegin\n  by_contradiction H,\n  have reformulation : ∀ x' (k : ℕ), ε * ϕ x ≤ ε / 2 ^ k * ϕ x' ↔ 2^k * ϕ x ≤ ϕ x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left ε_pos, mul_comm],\n    exact pow_pos (by norm_num) k, },\n  -- Now let's specialize to `ε/2^k`\n  replace H : ∀ k : ℕ, ∀ x', d x' x ≤ 2 * ε ∧ 2^k * ϕ x ≤ ϕ x' →\n    ∃ y, d x' y ≤ ε/2^k ∧ 2 * ϕ x' < ϕ y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using\n      H (ε/2^k) (by simp [ε_pos, zero_lt_two]) x' (by simp [ε_pos, zero_lt_two, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := ⟨x⟩,\n  choose! F hF using H,  -- Use the axiom of choice\n  -- Now define u by induction starting at x, with u_{n+1} = F(n, u_n)\n  let u : ℕ → X := λ n, nat.rec_on n x F,\n  have hu0 : u 0 = x := rfl,\n  -- The properties of F translate to properties of u\n  have hu :\n    ∀ n,\n      d (u n) x ≤ 2 * ε ∧ 2^n * ϕ x ≤ ϕ (u n) →\n      d (u n) (u $ n + 1) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u $ n + 1),\n  { intro n,\n    exact hF n (u n) },\n  clear hF,\n  -- Key properties of u, to be proven by induction\n  have key : ∀ n, d (u n) (u (n + 1)) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u (n + 1)),\n  { intro n,\n    induction n using nat.case_strong_induction_on with n IH,\n    { specialize hu 0,\n      simpa [hu0, mul_nonneg_iff, zero_le_one, ε_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x ≤ 2 * ε,\n    { rw [dist_comm],\n      let r := range (n+1), -- range (n+1) = {0, ..., n}\n      calc\n      d (u 0) (u (n + 1))\n          ≤ ∑ i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... ≤ ∑ i in r, ε/2^i             : sum_le_sum (λ i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = ∑ i in r, (1/2)^i*ε         : by { congr' with i, field_simp }\n      ... = (∑ i in r, (1/2)^i)*ε       : finset.sum_mul.symm\n      ... ≤ 2*ε                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt ε_pos), },\n    have B : 2^(n+1) * ϕ x ≤ ϕ (u (n + 1)),\n    { refine @geom_le (ϕ ∘ u) _ zero_le_two (n + 1) (λ m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) ⟨A, B⟩, },\n  cases forall_and_distrib.mp key with key₁ key₂,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ ε one_half_lt_one (λ n, _),\n    simpa only [one_div, inv_pow₀] using key₁ n },\n  -- So u converges to some y\n  obtain ⟨y, limy⟩ : ∃ y, tendsto u at_top (𝓝 y),\n    from complete_space.complete cauchy_u,\n  -- And ϕ ∘ u goes to +∞\n  have lim_top : tendsto (ϕ ∘ u) at_top at_top,\n  { let v := λ n, (ϕ ∘ u) (n+1),\n    suffices : tendsto v at_top at_top,\n      by rwa tendsto_add_at_top_iff_nat at this,\n    have hv₀ : 0 < v 0,\n    { have : 0 ≤ ϕ (u 0) := nonneg x,\n      calc 0 ≤ 2 * ϕ (u 0) : by linarith\n      ... < ϕ (u (0 + 1)) : key₂ 0 },\n    apply tendsto_at_top_of_geom_le hv₀ one_lt_two,\n    exact λ n, (key₂ (n+1)).le },\n  -- But ϕ ∘ u also needs to go to ϕ(y)\n  have lim : tendsto (ϕ ∘ u) at_top (𝓝 (ϕ y)),\n    from tendsto.comp cont.continuous_at limy,\n  -- So we have our contradiction!\n  exact not_tendsto_at_top_of_tendsto_nhds lim lim_top,\nend\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/analysis/hofer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.47491871262813234}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Thomas Read, Andrew Yang\n-/\n\nimport category_theory.adjunction.basic\nimport category_theory.yoneda\nimport category_theory.opposites\n\n/-!\n# Opposite adjunctions\n\nThis file contains constructions to relate adjunctions of functors to adjunctions of their\nopposites.\nThese constructions are used to show uniqueness of adjoints (up to natural isomorphism).\n\n## Tags\nadjunction, opposite, uniqueness\n-/\n\n\nopen category_theory\n\nuniverses v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\nnamespace category_theory.adjunction\n\n/-- If `G.op` is adjoint to `F.op` then `F` is adjoint to `G`. -/\n@[simps unit_app counit_app] def adjoint_of_op_adjoint_op\n  (F : C ⥤ D) (G : D ⥤ C) (h : G.op ⊣ F.op) : F ⊣ G :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := λ X Y,\n  ((h.hom_equiv (opposite.op Y) (opposite.op X)).trans (op_equiv _ _)).symm.trans (op_equiv _ _) }\n\n/-- If `G` is adjoint to `F.op` then `F` is adjoint to `G.unop`. -/\ndef adjoint_unop_of_adjoint_op (F : C ⥤ D) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G ⊣ F.op) : F ⊣ G.unop :=\nadjoint_of_op_adjoint_op F G.unop (h.of_nat_iso_left G.op_unop_iso.symm)\n\n/-- If `G.op` is adjoint to `F` then `F.unop` is adjoint to `G`. -/\ndef unop_adjoint_of_op_adjoint (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : D ⥤ C) (h : G.op ⊣ F) : F.unop ⊣ G :=\nadjoint_of_op_adjoint_op _ _ (h.of_nat_iso_right F.op_unop_iso.symm)\n\n/-- If `G` is adjoint to `F` then `F.unop` is adjoint to `G.unop`. -/\ndef unop_adjoint_unop_of_adjoint (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G ⊣ F) : F.unop ⊣ G.unop :=\nadjoint_unop_of_adjoint_op F.unop G (h.of_nat_iso_right F.op_unop_iso.symm)\n\n/-- If `G` is adjoint to `F` then `F.op` is adjoint to `G.op`. -/\n@[simps unit_app counit_app] def op_adjoint_op_of_adjoint\n  (F : C ⥤ D) (G : D ⥤ C) (h : G ⊣ F) : F.op ⊣ G.op :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := λ X Y,\n  (op_equiv _ Y).trans ((h.hom_equiv _ _).symm.trans (op_equiv X (opposite.op _)).symm) }\n\n/-- If `G` is adjoint to `F.unop` then `F` is adjoint to `G.op`. -/\ndef adjoint_op_of_adjoint_unop (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : D ⥤ C) (h : G ⊣ F.unop) : F ⊣ G.op :=\n(op_adjoint_op_of_adjoint F.unop _ h).of_nat_iso_left F.op_unop_iso\n\n/-- If `G.unop` is adjoint to `F` then `F.op` is adjoint to `G`. -/\ndef op_adjoint_of_unop_adjoint (F : C ⥤ D) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G.unop ⊣ F) : F.op ⊣ G :=\n(op_adjoint_op_of_adjoint _ G.unop h).of_nat_iso_right G.op_unop_iso\n\n/-- If `G.unop` is adjoint to `F.unop` then `F` is adjoint to `G`. -/\ndef adjoint_of_unop_adjoint_unop (F : Cᵒᵖ ⥤ Dᵒᵖ) (G : Dᵒᵖ ⥤ Cᵒᵖ) (h : G.unop ⊣ F.unop) : F ⊣ G :=\n(adjoint_op_of_adjoint_unop _ _ h).of_nat_iso_right G.op_unop_iso\n\n/--\nIf `F` and `F'` are both adjoint to `G`, there is a natural isomorphism\n`F.op ⋙ coyoneda ≅ F'.op ⋙ coyoneda`.\nWe use this in combination with `fully_faithful_cancel_right` to show left adjoints are unique.\n-/\ndef left_adjoints_coyoneda_equiv {F F' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G):\n  F.op ⋙ coyoneda ≅ F'.op ⋙ coyoneda :=\nnat_iso.of_components\n  (λ X, nat_iso.of_components\n    (λ Y, ((adj1.hom_equiv X.unop Y).trans (adj2.hom_equiv X.unop Y).symm).to_iso)\n    (by tidy))\n  (by tidy)\n\n/-- If `F` and `F'` are both left adjoint to `G`, then they are naturally isomorphic. -/\ndef left_adjoint_uniq {F F' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G) : F ≅ F' :=\nnat_iso.remove_op (fully_faithful_cancel_right _ (left_adjoints_coyoneda_equiv adj2 adj1))\n\n@[simp]\nlemma hom_equiv_left_adjoint_uniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) :\n  adj1.hom_equiv _ _ ((left_adjoint_uniq adj1 adj2).hom.app x) = adj2.unit.app x :=\nbegin\n  apply (adj1.hom_equiv _ _).symm.injective,\n  apply quiver.hom.op_inj,\n  apply coyoneda.map_injective,\n  swap, apply_instance,\n  ext f y,\n  simpa [left_adjoint_uniq, left_adjoints_coyoneda_equiv]\nend\n\n@[simp, reassoc]\nlemma unit_left_adjoint_uniq_hom {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :\n  adj1.unit ≫ whisker_right (left_adjoint_uniq adj1 adj2).hom G = adj2.unit :=\nbegin\n  ext x,\n  rw [nat_trans.comp_app, ← hom_equiv_left_adjoint_uniq_hom_app adj1 adj2],\n  simp [-hom_equiv_left_adjoint_uniq_hom_app, ←G.map_comp]\nend\n\n@[simp, reassoc]\nlemma unit_left_adjoint_uniq_hom_app {F F' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) :\n  adj1.unit.app x ≫ G.map ((left_adjoint_uniq adj1 adj2).hom.app x) = adj2.unit.app x :=\nby { rw ← unit_left_adjoint_uniq_hom adj1 adj2, refl }\n\n@[simp, reassoc]\nlemma left_adjoint_uniq_hom_counit {F F' : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F' ⊣ G) :\n  whisker_left G (left_adjoint_uniq adj1 adj2).hom ≫ adj2.counit = adj1.counit :=\nbegin\n  ext x,\n  apply quiver.hom.op_inj,\n  apply coyoneda.map_injective,\n  swap, apply_instance,\n  ext y f,\n  have : F.map (adj2.unit.app (G.obj x)) ≫ adj1.counit.app (F'.obj (G.obj x)) ≫\n    adj2.counit.app x ≫ f = adj1.counit.app x ≫ f,\n  { erw [← adj1.counit.naturality, ← F.map_comp_assoc], simpa },\n  simpa [left_adjoint_uniq, left_adjoints_coyoneda_equiv] using this\nend\n\n@[simp, reassoc]\nlemma left_adjoint_uniq_hom_app_counit {F F' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : D) :\n  (left_adjoint_uniq adj1 adj2).hom.app (G.obj x) ≫ adj2.counit.app x = adj1.counit.app x :=\nby { rw ← left_adjoint_uniq_hom_counit adj1 adj2, refl }\n\n@[simp]\nlemma left_adjoint_uniq_inv_app {F F' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (x : C) :\n  (left_adjoint_uniq adj1 adj2).inv.app x = (left_adjoint_uniq adj2 adj1).hom.app x := rfl\n\n@[simp, reassoc]\nlemma left_adjoint_uniq_trans {F F' F'' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) :\n  (left_adjoint_uniq adj1 adj2).hom ≫ (left_adjoint_uniq adj2 adj3).hom =\n    (left_adjoint_uniq adj1 adj3).hom :=\nbegin\n  ext,\n  apply quiver.hom.op_inj,\n  apply coyoneda.map_injective,\n  swap, apply_instance,\n  ext,\n  simp [left_adjoints_coyoneda_equiv, left_adjoint_uniq]\nend\n\n@[simp, reassoc]\nlemma left_adjoint_uniq_trans_app {F F' F'' : C ⥤ D} {G : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G) (adj3 : F'' ⊣ G) (x : C) :\n  (left_adjoint_uniq adj1 adj2).hom.app x ≫ (left_adjoint_uniq adj2 adj3).hom.app x =\n    (left_adjoint_uniq adj1 adj3).hom.app x :=\nby { rw ← left_adjoint_uniq_trans adj1 adj2 adj3, refl }\n\n@[simp]\nlemma left_adjoint_uniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) :\n  (left_adjoint_uniq adj1 adj1).hom = 𝟙 _ :=\nbegin\n  ext,\n  apply quiver.hom.op_inj,\n  apply coyoneda.map_injective,\n  swap, apply_instance,\n  ext,\n  simp [left_adjoints_coyoneda_equiv, left_adjoint_uniq]\nend\n\n/-- If `G` and `G'` are both right adjoint to `F`, then they are naturally isomorphic. -/\ndef right_adjoint_uniq {F : C ⥤ D} {G G' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F ⊣ G') : G ≅ G' :=\nnat_iso.remove_op\n  (left_adjoint_uniq (op_adjoint_op_of_adjoint _ F adj2) (op_adjoint_op_of_adjoint _ _ adj1))\n\n@[simp]\nlemma hom_equiv_symm_right_adjoint_uniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : D) :\n  (adj2.hom_equiv _ _).symm ((right_adjoint_uniq adj1 adj2).hom.app x) = adj1.counit.app x :=\nbegin\n  apply quiver.hom.op_inj,\n  convert hom_equiv_left_adjoint_uniq_hom_app\n    (op_adjoint_op_of_adjoint _ F adj2) (op_adjoint_op_of_adjoint _ _ adj1) (opposite.op x),\n  simpa\nend\n\n@[simp, reassoc]\nlemma unit_right_adjoint_uniq_hom_app {F : C ⥤ D} {G G' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : C) :\n  adj1.unit.app x ≫ (right_adjoint_uniq adj1 adj2).hom.app (F.obj x) = adj2.unit.app x :=\nbegin\n  apply quiver.hom.op_inj,\n  convert left_adjoint_uniq_hom_app_counit\n    (op_adjoint_op_of_adjoint _ _ adj2) (op_adjoint_op_of_adjoint _ _ adj1) (opposite.op x),\n  all_goals { simpa }\nend\n\n@[simp, reassoc]\nlemma unit_right_adjoint_uniq_hom {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') :\n  adj1.unit ≫ whisker_left F (right_adjoint_uniq adj1 adj2).hom = adj2.unit :=\nby { ext x, simp }\n\n@[simp, reassoc]\nlemma right_adjoint_uniq_hom_app_counit {F : C ⥤ D} {G G' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : D) :\n  F.map ((right_adjoint_uniq adj1 adj2).hom.app x) ≫ adj2.counit.app x = adj1.counit.app x :=\nbegin\n  apply quiver.hom.op_inj,\n  convert unit_left_adjoint_uniq_hom_app\n    (op_adjoint_op_of_adjoint _ _ adj2) (op_adjoint_op_of_adjoint _ _ adj1) (opposite.op x),\n  all_goals { simpa }\nend\n\n@[simp, reassoc]\nlemma right_adjoint_uniq_hom_counit {F : C ⥤ D} {G G' : D ⥤ C} (adj1 : F ⊣ G) (adj2 : F ⊣ G') :\n  whisker_right (right_adjoint_uniq adj1 adj2).hom F ≫ adj2.counit = adj1.counit :=\nby { ext, simp }\n\n@[simp]\nlemma right_adjoint_uniq_inv_app {F : C ⥤ D} {G G' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F ⊣ G') (x : D) :\n  (right_adjoint_uniq adj1 adj2).inv.app x = (right_adjoint_uniq adj2 adj1).hom.app x := rfl\n\n@[simp, reassoc]\nlemma right_adjoint_uniq_trans_app {F : C ⥤ D} {G G' G'' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F ⊣ G') (adj3 : F ⊣ G'') (x : D) :\n  (right_adjoint_uniq adj1 adj2).hom.app x ≫ (right_adjoint_uniq adj2 adj3).hom.app x =\n    (right_adjoint_uniq adj1 adj3).hom.app x :=\nbegin\n  apply quiver.hom.op_inj,\n  exact left_adjoint_uniq_trans_app (op_adjoint_op_of_adjoint _ _ adj3)\n    (op_adjoint_op_of_adjoint _ _ adj2) (op_adjoint_op_of_adjoint _ _ adj1) (opposite.op x)\nend\n\n@[simp, reassoc]\nlemma right_adjoint_uniq_trans {F : C ⥤ D} {G G' G'' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F ⊣ G') (adj3 : F ⊣ G'') :\n  (right_adjoint_uniq adj1 adj2).hom ≫ (right_adjoint_uniq adj2 adj3).hom =\n    (right_adjoint_uniq adj1 adj3).hom :=\nby { ext, simp }\n\n@[simp]\nlemma right_adjoint_uniq_refl {F : C ⥤ D} {G : D ⥤ C} (adj1 : F ⊣ G) :\n  (right_adjoint_uniq adj1 adj1).hom = 𝟙 _ :=\nby { delta right_adjoint_uniq, simp }\n\n/--\nGiven two adjunctions, if the left adjoints are naturally isomorphic, then so are the right\nadjoints.\n-/\ndef nat_iso_of_left_adjoint_nat_iso {F F' : C ⥤ D} {G G' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (l : F ≅ F') :\n  G ≅ G' :=\nright_adjoint_uniq adj1 (adj2.of_nat_iso_left l.symm)\n\n/--\nGiven two adjunctions, if the right adjoints are naturally isomorphic, then so are the left\nadjoints.\n-/\ndef nat_iso_of_right_adjoint_nat_iso {F F' : C ⥤ D} {G G' : D ⥤ C}\n  (adj1 : F ⊣ G) (adj2 : F' ⊣ G') (r : G ≅ G') :\n  F ≅ F' :=\nleft_adjoint_uniq adj1 (adj2.of_nat_iso_right r.symm)\n\nend category_theory.adjunction\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/adjunction/opposites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.47491870326238245}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.continuous_on\nimport Mathlib.group_theory.submonoid.basic\nimport Mathlib.algebra.group.prod\nimport Mathlib.algebra.pointwise\nimport Mathlib.PostPort\n\nuniverses u_5 l u_3 u_1 u_4 u_2 \n\nnamespace Mathlib\n\n/-!\n# Theory of topological monoids\n\nIn this file we define mixin classes `has_continuous_mul` and `has_continuous_add`. While in many\napplications the underlying type is a monoid (multiplicative or additive), we do not require this in\nthe definitions.\n-/\n\n/-- Basic hypothesis to talk about a topological additive monoid or a topological additive\nsemigroup. A topological additive monoid over `α`, for example, is obtained by requiring both the\ninstances `add_monoid α` and `has_continuous_add α`. -/\nclass has_continuous_add (M : Type u_5) [topological_space M] [Add M] where\n  continuous_add : continuous fun (p : M × M) => prod.fst p + prod.snd p\n\n/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.\nA topological monoid over `α`, for example, is obtained by requiring both the instances `monoid α`\nand `has_continuous_mul α`. -/\nclass has_continuous_mul (M : Type u_5) [topological_space M] [Mul M] where\n  continuous_mul : continuous fun (p : M × M) => prod.fst p * prod.snd p\n\ntheorem continuous_add {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] :\n    continuous fun (p : M × M) => prod.fst p + prod.snd p :=\n  has_continuous_add.continuous_add\n\ntheorem continuous.mul {α : Type u_1} {M : Type u_3} [topological_space M] [Mul M]\n    [has_continuous_mul M] [topological_space α] {f : α → M} {g : α → M} (hf : continuous f)\n    (hg : continuous g) : continuous fun (x : α) => f x * g x :=\n  continuous.comp continuous_mul (continuous.prod_mk hf hg)\n\n-- should `to_additive` be doing this?\n\ntheorem continuous_add_left {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M]\n    (a : M) : continuous fun (b : M) => a + b :=\n  continuous.add continuous_const continuous_id\n\ntheorem continuous_add_right {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M]\n    (a : M) : continuous fun (b : M) => b + a :=\n  continuous.add continuous_id continuous_const\n\ntheorem continuous_on.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] [topological_space α] {f : α → M} {g : α → M} {s : set α}\n    (hf : continuous_on f s) (hg : continuous_on g s) :\n    continuous_on (fun (x : α) => f x + g x) s :=\n  continuous.comp_continuous_on continuous_add (continuous_on.prod hf hg)\n\ntheorem tendsto_add {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] {a : M}\n    {b : M} :\n    filter.tendsto (fun (p : M × M) => prod.fst p + prod.snd p) (nhds (a, b)) (nhds (a + b)) :=\n  iff.mp continuous_iff_continuous_at has_continuous_add.continuous_add (a, b)\n\ntheorem filter.tendsto.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] {f : α → M} {g : α → M} {x : filter α} {a : M} {b : M}\n    (hf : filter.tendsto f x (nhds a)) (hg : filter.tendsto g x (nhds b)) :\n    filter.tendsto (fun (x : α) => f x + g x) x (nhds (a + b)) :=\n  filter.tendsto.comp tendsto_add (filter.tendsto.prod_mk_nhds hf hg)\n\ntheorem tendsto.const_mul {α : Type u_1} {M : Type u_3} [topological_space M] [Mul M]\n    [has_continuous_mul M] (b : M) {c : M} {f : α → M} {l : filter α}\n    (h : filter.tendsto (fun (k : α) => f k) l (nhds c)) :\n    filter.tendsto (fun (k : α) => b * f k) l (nhds (b * c)) :=\n  filter.tendsto.mul tendsto_const_nhds h\n\ntheorem tendsto.add_const {α : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] (b : M) {c : M} {f : α → M} {l : filter α}\n    (h : filter.tendsto (fun (k : α) => f k) l (nhds c)) :\n    filter.tendsto (fun (k : α) => f k + b) l (nhds (c + b)) :=\n  filter.tendsto.add h tendsto_const_nhds\n\ntheorem continuous_at.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] [topological_space α] {f : α → M} {g : α → M} {x : α}\n    (hf : continuous_at f x) (hg : continuous_at g x) :\n    continuous_at (fun (x : α) => f x + g x) x :=\n  filter.tendsto.add hf hg\n\ntheorem continuous_within_at.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] [topological_space α] {f : α → M} {g : α → M} {s : set α} {x : α}\n    (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n    continuous_within_at (fun (x : α) => f x + g x) s x :=\n  filter.tendsto.add hf hg\n\nprotected instance prod.has_continuous_mul {M : Type u_3} {N : Type u_4} [topological_space M]\n    [Mul M] [has_continuous_mul M] [topological_space N] [Mul N] [has_continuous_mul N] :\n    has_continuous_mul (M × N) :=\n  has_continuous_mul.mk\n    (continuous.prod_mk\n      (continuous.mul (continuous.comp continuous_fst continuous_fst)\n        (continuous.comp continuous_fst continuous_snd))\n      (continuous.mul (continuous.comp continuous_snd continuous_fst)\n        (continuous.comp continuous_snd continuous_snd)))\n\nprotected instance has_continuous_mul_of_discrete_topology {N : Type u_4} [topological_space N]\n    [Mul N] [discrete_topology N] : has_continuous_mul N :=\n  has_continuous_mul.mk continuous_of_discrete_topology\n\ntheorem has_continuous_mul.of_nhds_one {M : Type (max u_1 u_2)} [monoid M] [topological_space M]\n    (hmul : filter.tendsto (function.uncurry Mul.mul) (filter.prod (nhds 1) (nhds 1)) (nhds 1))\n    (hleft : ∀ (x₀ : M), nhds x₀ = filter.map (fun (x : M) => x₀ * x) (nhds 1))\n    (hright : ∀ (x₀ : M), nhds x₀ = filter.map (fun (x : M) => x * x₀) (nhds 1)) :\n    has_continuous_mul M :=\n  sorry\n\ntheorem has_continuous_mul_of_comm_of_nhds_one (M : Type (max u_1 u_2)) [comm_monoid M]\n    [topological_space M]\n    (hmul : filter.tendsto (function.uncurry Mul.mul) (filter.prod (nhds 1) (nhds 1)) (nhds 1))\n    (hleft : ∀ (x₀ : M), nhds x₀ = filter.map (fun (x : M) => x₀ * x) (nhds 1)) :\n    has_continuous_mul M :=\n  sorry\n\ntheorem add_submonoid.top_closure_add_self_subset {M : Type u_3} [topological_space M]\n    [add_monoid M] [has_continuous_add M] (s : add_submonoid M) :\n    closure ↑s + closure ↑s ⊆ closure ↑s :=\n  sorry\n\ntheorem submonoid.top_closure_mul_self_eq {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] (s : submonoid M) : closure ↑s * closure ↑s = closure ↑s :=\n  sorry\n\n/-- The (topological-space) closure of a submonoid of a space `M` with `has_continuous_mul` is\nitself a submonoid. -/\ndef add_submonoid.topological_closure {M : Type u_3} [topological_space M] [add_monoid M]\n    [has_continuous_add M] (s : add_submonoid M) : add_submonoid M :=\n  add_submonoid.mk (closure ↑s) sorry sorry\n\ntheorem submonoid.submonoid_topological_closure {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] (s : submonoid M) : s ≤ submonoid.topological_closure s :=\n  subset_closure\n\ntheorem submonoid.is_closed_topological_closure {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] (s : submonoid M) : is_closed ↑(submonoid.topological_closure s) :=\n  sorry\n\ntheorem submonoid.topological_closure_minimal {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] (s : submonoid M) {t : submonoid M} (h : s ≤ t) (ht : is_closed ↑t) :\n    submonoid.topological_closure s ≤ t :=\n  closure_minimal h ht\n\ntheorem exists_open_nhds_zero_half {M : Type u_3} [topological_space M] [add_monoid M]\n    [has_continuous_add M] {s : set M} (hs : s ∈ nhds 0) :\n    ∃ (V : set M), is_open V ∧ 0 ∈ V ∧ ∀ (v : M), v ∈ V → ∀ (w : M), w ∈ V → v + w ∈ s :=\n  sorry\n\ntheorem exists_nhds_zero_half {M : Type u_3} [topological_space M] [add_monoid M]\n    [has_continuous_add M] {s : set M} (hs : s ∈ nhds 0) :\n    ∃ (V : set M), ∃ (H : V ∈ nhds 0), ∀ (v : M), v ∈ V → ∀ (w : M), w ∈ V → v + w ∈ s :=\n  sorry\n\ntheorem exists_nhds_one_split4 {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] {u : set M} (hu : u ∈ nhds 1) :\n    ∃ (V : set M),\n        ∃ (H : V ∈ nhds 1), ∀ {v w s t : M}, v ∈ V → w ∈ V → s ∈ V → t ∈ V → v * w * s * t ∈ u :=\n  sorry\n\n/-- Given a neighborhood `U` of `1` there is an open neighborhood `V` of `1`\nsuch that `VV ⊆ U`. -/\ntheorem exists_open_nhds_one_mul_subset {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] {U : set M} (hU : U ∈ nhds 1) :\n    ∃ (V : set M), is_open V ∧ 1 ∈ V ∧ V * V ⊆ U :=\n  sorry\n\ntheorem tendsto_list_sum {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M]\n    [add_monoid M] [has_continuous_add M] {f : β → α → M} {x : filter α} {a : β → M} (l : List β) :\n    (∀ (c : β), c ∈ l → filter.tendsto (f c) x (nhds (a c))) →\n        filter.tendsto (fun (b : α) => list.sum (list.map (fun (c : β) => f c b) l)) x\n          (nhds (list.sum (list.map a l))) :=\n  sorry\n\ntheorem continuous_list_sum {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M]\n    [add_monoid M] [has_continuous_add M] [topological_space α] {f : β → α → M} (l : List β)\n    (h : ∀ (c : β), c ∈ l → continuous (f c)) :\n    continuous fun (a : α) => list.sum (list.map (fun (c : β) => f c a) l) :=\n  iff.mpr continuous_iff_continuous_at\n    fun (x : α) =>\n      tendsto_list_sum l fun (c : β) (hc : c ∈ l) => iff.mp continuous_iff_continuous_at (h c hc) x\n\n-- @[to_additive continuous_smul]\n\ntheorem continuous_pow {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M]\n    (n : ℕ) : continuous fun (a : M) => a ^ n :=\n  sorry\n\ntheorem continuous.pow {α : Type u_1} {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] {f : α → M} [topological_space α] (h : continuous f) (n : ℕ) :\n    continuous fun (b : α) => f b ^ n :=\n  continuous.comp (continuous_pow n) h\n\ntheorem submonoid.mem_nhds_one {M : Type u_3} [topological_space M] [comm_monoid M]\n    (S : submonoid M) (oS : is_open ↑S) : ↑S ∈ nhds 1 :=\n  mem_nhds_sets oS (submonoid.one_mem S)\n\ntheorem tendsto_multiset_prod {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M]\n    [comm_monoid M] [has_continuous_mul M] {f : β → α → M} {x : filter α} {a : β → M}\n    (s : multiset β) :\n    (∀ (c : β), c ∈ s → filter.tendsto (f c) x (nhds (a c))) →\n        filter.tendsto (fun (b : α) => multiset.prod (multiset.map (fun (c : β) => f c b) s)) x\n          (nhds (multiset.prod (multiset.map a s))) :=\n  sorry\n\ntheorem tendsto_finset_sum {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M]\n    [add_comm_monoid M] [has_continuous_add M] {f : β → α → M} {x : filter α} {a : β → M}\n    (s : finset β) :\n    (∀ (c : β), c ∈ s → filter.tendsto (f c) x (nhds (a c))) →\n        filter.tendsto (fun (b : α) => finset.sum s fun (c : β) => f c b) x\n          (nhds (finset.sum s fun (c : β) => a c)) :=\n  tendsto_multiset_sum (finset.val s)\n\ntheorem continuous_multiset_prod {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M]\n    [comm_monoid M] [has_continuous_mul M] [topological_space α] {f : β → α → M} (s : multiset β) :\n    (∀ (c : β), c ∈ s → continuous (f c)) →\n        continuous fun (a : α) => multiset.prod (multiset.map (fun (c : β) => f c a) s) :=\n  sorry\n\ntheorem continuous_finset_prod {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M]\n    [comm_monoid M] [has_continuous_mul M] [topological_space α] {f : β → α → M} (s : finset β) :\n    (∀ (c : β), c ∈ s → continuous (f c)) →\n        continuous fun (a : α) => finset.prod s fun (c : β) => f c a :=\n  continuous_multiset_prod (finset.val s)\n\n-- should `to_additive` be doing this?\n\nprotected instance additive.has_continuous_add {M : Type u_1} [h : topological_space M] [Mul M]\n    [has_continuous_mul M] : has_continuous_add (additive M) :=\n  has_continuous_add.mk continuous_mul\n\nprotected instance multiplicative.has_continuous_mul {M : Type u_1} [h : topological_space M]\n    [Add M] [has_continuous_add M] : has_continuous_mul (multiplicative M) :=\n  has_continuous_mul.mk continuous_add\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/monoid_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.6992544273261176, "lm_q1q2_score": 0.47491870326238245}}
{"text": "import logic.funrel\n\n/-!\n * bool supported on a truth value.\n--/\n\n@[reducible]\ndefinition subbool (p : Prop) : Type := {b // p ∨ b=ff}\n\ninstance (p : Prop) : inhabited (subbool p) := inhabited.mk ⟨ff,or.inr rfl⟩\ninstance (p : Prop) : has_zero (subbool p) := has_zero.mk ⟨ff,or.inr rfl⟩\ninstance (p : Prop) : decidable_eq (subbool p) :=\n  λ a b, @decidable.cases_on (a.val=b.val) (λ_, decidable (a=b)) (bool.decidable_eq a.val b.val) (λ hn, is_false (λ (h : a=b), hn (congr (@rfl _ subtype.val) h))) (λ h, is_true (subtype.eq h))\n\ninstance : subsingleton (subbool false) :=\n  begin\n    constructor,\n    intros a b,\n    apply subtype.eq,\n    apply a.property.elim; try { exact false.elim },\n    apply b.property.elim; try { exact false.elim },\n    intros hb ha,\n    rw [hb, ha]\n  end\n\nnamespace subbool\n\n@[reducible,inline]\nprotected\ndefinition ff (p : Prop) : subbool p := ⟨ff,or.inr rfl⟩\n\n@[reducible,inline]\nprotected\ndefinition tt {p : Prop} : p → subbool p := λ h, ⟨tt,or.inl h⟩\n\n@[reducible]\nprotected\ndefinition and {p : Prop} : subbool p → subbool p → subbool p\n| ⟨tt,hl⟩ ⟨tt,_⟩ := ⟨tt,or.elim hl or.inl (λ tf, bool.no_confusion tf)⟩\n| _ _ := ⟨ff,or.inr rfl⟩\n\n@[reducible]\nprotected\ndefinition or {p : Prop} : subbool p → subbool p → subbool p\n| ⟨ff,_⟩ ⟨ff,_⟩ := ⟨ff, by right; refl⟩\n| ⟨ff,_⟩ ⟨tt,qt⟩ := ⟨tt, qt.elim _root_.or.inl (λ tf, bool.no_confusion tf)⟩\n| ⟨tt,qt⟩ ⟨ff,_⟩ := ⟨tt, qt.elim _root_.or.inl (λ tf, bool.no_confusion tf)⟩\n| ⟨tt,qt⟩ ⟨tt,_⟩ := ⟨tt, qt.elim _root_.or.inl (λ tf, bool.no_confusion tf)⟩\n\n@[reducible]\ndefinition xor {p : Prop} : subbool p → subbool p → subbool p\n| ⟨ff,_⟩ ⟨ff,_⟩ := ⟨ff, or.inr rfl⟩\n| ⟨ff,_⟩ ⟨tt,qt⟩ := ⟨tt, or.elim qt or.inl (λ tf, bool.no_confusion tf)⟩\n| ⟨tt,qt⟩ ⟨ff,_⟩ := ⟨tt, or.elim qt or.inl (λ tf, bool.no_confusion tf)⟩\n| ⟨tt,_⟩ ⟨tt,_⟩ := ⟨ff, or.inr rfl⟩\n\n@[simp]\nprotected\nlemma xor_ff {p : Prop} (a : subbool p) : xor a ⟨ff,or.inr rfl⟩ = a :=\n  by cases a; cases a_val; unfold xor\n\n@[simp]\nprotected\nlemma ff_xor {p : Prop} (a : subbool p) : xor ⟨ff,or.inr rfl⟩ a = a :=\n  by cases a; cases a_val; unfold xor\n\n@[simp]\nprotected\nlemma xor_self {p : Prop} (a : subbool p) : xor a a = ⟨ff,or.inr rfl⟩ :=\n  by cases a; cases a_val; unfold xor\n\nprotected\nlemma xor_comm {p : Prop} (a b : subbool p) : xor a b = xor b a :=\n  by cases a; cases a_val; cases b; cases b_val; unfold xor\n\nprotected\nlemma xor_assoc {p : Prop} (a b c : subbool p) : xor (xor a b) c = xor a (xor b c) :=\n  by cases a; cases a_val; cases b; cases b_val; cases c; cases c_val; unfold xor\n\n--- Relax the restriction on the support.\n@[reducible]\ndefinition relax {p q : Prop} (hpq : p → q) : subbool p → subbool q\n| ⟨a,ha⟩ := ⟨a, ha.elim (or.inl ∘ hpq) or.inr⟩\n\n@[reducible,inline]\ndefinition to_bool {p : Prop} : subbool p → bool := subtype.val\n\n@[reducible]\ndefinition from_bool (p : Prop) : bool → subbool true := λ x, ⟨x,or.inl true.intro⟩\n\nend subbool\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/data/bool/subbool.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799252, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4748957883767602}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport linear_algebra.clifford_algebra.conjugation\n\n/-!\n# Recursive computation rules for the Clifford algebra\n\nThis file provides API for a special case `clifford_algebra.foldr` of the universal property\n`clifford_algebra.lift` with `A = module.End R N` for some arbitrary module `N`. This specialization\nresembles the `list.foldr` operation, allowing a bilinear map to be \"folded\" along the generators.\n\nFor convenience, this file also provides `clifford_algebra.foldl`, implemented via\n`clifford_algebra.reverse`\n\n## Main definitions\n\n* `clifford_algebra.foldr`: a computation rule for building linear maps out of the clifford\n  algebra starting on the right, analogous to using `list.foldr` on the generators.\n* `clifford_algebra.foldl`: a computation rule for building linear maps out of the clifford\n  algebra starting on the left, analogous to using `list.foldl` on the generators.\n\n## Main statements\n\n* `clifford_algebra.right_induction`: an induction rule that adds generators from the right.\n* `clifford_algebra.left_induction`: an induction rule that adds generators from the left.\n-/\n\nuniverses u1 u2 u3\n\nvariables {R M N : Type*}\nvariables [comm_ring R] [add_comm_group M] [add_comm_group N]\nvariables [module R M] [module R N]\nvariables (Q : quadratic_form R M)\n\nnamespace clifford_algebra\n\nsection foldr\n\n/-- Fold a bilinear map along the generators of a term of the clifford algebra, with the rule\ngiven by `foldr Q f hf n (ι Q m * x) = f m (foldr Q f hf n x)`.\n\nFor example, `foldr f hf n (r • ι R u + ι R v * ι R w) = r • f u n + f v (f w n)`. -/\ndef foldr (f : M →ₗ[R] N →ₗ[R] N) (hf : ∀ m x, f m (f m x) = Q m • x) :\n  N →ₗ[R] clifford_algebra Q →ₗ[R] N :=\n(clifford_algebra.lift Q ⟨f, λ v, linear_map.ext $ hf v⟩).to_linear_map.flip\n\n@[simp] lemma foldr_ι (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (m : M) :\n  foldr Q f hf n (ι Q m) = f m n :=\nlinear_map.congr_fun (lift_ι_apply _ _ _) n\n\n@[simp] lemma foldr_algebra_map (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (r : R) :\n  foldr Q f hf n (algebra_map R _ r) = r • n :=\nlinear_map.congr_fun (alg_hom.commutes _ r) n\n\n@[simp] lemma foldr_one (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) :\n  foldr Q f hf n 1 = n :=\nlinear_map.congr_fun (alg_hom.map_one _) n\n\n@[simp] lemma foldr_mul (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (a b : clifford_algebra Q) :\n  foldr Q f hf n (a * b) = foldr Q f hf (foldr Q f hf n b) a :=\nlinear_map.congr_fun (alg_hom.map_mul _ _ _) n\n\n\n/-- This lemma demonstrates the origin of the `foldr` name. -/\nlemma foldr_prod_map_ι (l : list M) (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N):\n  foldr Q f hf n (l.map $ ι Q).prod = list.foldr (λ m n, f m n) n l :=\nbegin\n  induction l with hd tl ih,\n  { rw [list.map_nil, list.prod_nil, list.foldr_nil, foldr_one] },\n  { rw [list.map_cons, list.prod_cons, list.foldr_cons, foldr_mul, foldr_ι, ih] },\nend\n\nend foldr\n\nsection foldl\n\n/-- Fold a bilinear map along the generators of a term of the clifford algebra, with the rule\ngiven by `foldl Q f hf n (ι Q m * x) = f m (foldl Q f hf n x)`.\n\nFor example, `foldl f hf n (r • ι R u + ι R v * ι R w) = r • f u n + f v (f w n)`. -/\ndef foldl (f : M →ₗ[R] N →ₗ[R] N) (hf : ∀ m x, f m (f m x) = Q m • x) :\n  N →ₗ[R] clifford_algebra Q →ₗ[R] N :=\nlinear_map.compl₂ (foldr Q f hf) reverse\n\n@[simp] lemma foldl_reverse (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (x : clifford_algebra Q) :\n  foldl Q f hf n (reverse x) = foldr Q f hf n x :=\nfun_like.congr_arg (foldr Q f hf n) $ reverse_reverse _\n\n@[simp] lemma foldr_reverse (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (x : clifford_algebra Q) :\n  foldr Q f hf n (reverse x) = foldl Q f hf n x := rfl\n\n@[simp] lemma foldl_ι (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (m : M) :\n  foldl Q f hf n (ι Q m) = f m n :=\nby rw [←foldr_reverse, reverse_ι, foldr_ι]\n\n@[simp] lemma foldl_algebra_map (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (r : R) :\n  foldl Q f hf n (algebra_map R _ r) = r • n :=\nby rw [←foldr_reverse, reverse.commutes, foldr_algebra_map]\n\n@[simp] lemma foldl_one (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) :\n  foldl Q f hf n 1 = n :=\nby rw [←foldr_reverse, reverse.map_one, foldr_one]\n\n@[simp] lemma foldl_mul (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N) (a b : clifford_algebra Q) :\n  foldl Q f hf n (a * b) = foldl Q f hf (foldl Q f hf n a) b :=\nby rw [←foldr_reverse, ←foldr_reverse, ←foldr_reverse, reverse.map_mul, foldr_mul]\n\n/-- This lemma demonstrates the origin of the `foldl` name. -/\nlemma foldl_prod_map_ι (l : list M) (f : M →ₗ[R] N →ₗ[R] N) (hf) (n : N):\n  foldl Q f hf n (l.map $ ι Q).prod = list.foldl (λ m n, f n m) n l :=\nby rw [←foldr_reverse, reverse_prod_map_ι, ←list.map_reverse, foldr_prod_map_ι, list.foldr_reverse]\n\nend foldl\n\nlemma right_induction {P : clifford_algebra Q → Prop}\n  (hr : ∀ r : R, P (algebra_map _ _ r))\n  (h_add : ∀ x y, P x → P y → P (x + y))\n  (h_ι_mul : ∀ m x, P x → P (x * ι Q m)) : ∀ x, P x :=\nbegin\n  /- It would be neat if we could prove this via `foldr` like how we prove\n  `clifford_algebra.induction`, but going via the grading seems easier. -/\n  intro x,\n  have : x ∈ ⊤ := submodule.mem_top,\n  rw ←supr_ι_range_eq_top at this,\n  apply submodule.supr_induction _ this (λ i x hx, _) _ h_add,\n  { refine submodule.pow_induction_on_right _ hr h_add (λ x px m, _) hx,\n    rintro ⟨m, rfl⟩,\n    exact h_ι_mul _ _ px },\n  { simpa only [map_zero] using hr 0}\nend\n\nlemma left_induction {P : clifford_algebra Q → Prop}\n  (hr : ∀ r : R, P (algebra_map _ _ r))\n  (h_add : ∀ x y, P x → P y → P (x + y))\n  (h_mul_ι : ∀ x m, P x → P (ι Q m * x)) : ∀ x, P x :=\nbegin\n  refine reverse_involutive.surjective.forall.2 _,\n  intro x,\n  induction x using clifford_algebra.right_induction with r x y hx hy m x hx,\n  { simpa only [reverse.commutes] using hr r },\n  { simpa only [map_add] using h_add _ _ hx hy },\n  { simpa only [reverse.map_mul, reverse_ι] using h_mul_ι _ _ hx },\nend\n\n/-! ### Versions with extra state -/\n/-- Auxiliary definition for `clifford_algebra.foldr'` -/\ndef foldr'_aux (f : M →ₗ[R] clifford_algebra Q × N →ₗ[R] N) :\n  M →ₗ[R] module.End R (clifford_algebra Q × N) :=\nbegin\n  have v_mul := (algebra.lmul R (clifford_algebra Q)).to_linear_map ∘ₗ (ι Q),\n  have l := v_mul.compl₂ (linear_map.fst _ _ N),\n  exact { to_fun := λ m, (l m).prod (f m),\n          map_add' := λ v₂ v₂, linear_map.ext $ λ x, prod.ext\n            (linear_map.congr_fun (l.map_add _ _) x) (linear_map.congr_fun (f.map_add _ _) x),\n          map_smul' := λ c v, linear_map.ext $ λ x, prod.ext\n            (linear_map.congr_fun (l.map_smul _ _) x) (linear_map.congr_fun (f.map_smul _ _) x), },\nend\n\nlemma foldr'_aux_apply_apply (f : M →ₗ[R] clifford_algebra Q × N →ₗ[R] N) (m : M) (x_fx) :\n    foldr'_aux Q f m x_fx = (ι Q m * x_fx.1, f m x_fx) := rfl\n\nlemma foldr'_aux_foldr'_aux (f : M →ₗ[R] clifford_algebra Q × N →ₗ[R] N)\n  (hf : ∀ m x fx, f m (ι Q m * x, f m (x, fx)) = Q m • fx)\n  (v : M) (x_fx) :\n  foldr'_aux Q f v (foldr'_aux Q f v x_fx) = Q v • x_fx :=\nbegin\n  cases x_fx with x fx,\n  simp only [foldr'_aux_apply_apply],\n  rw [←mul_assoc, ι_sq_scalar, ← algebra.smul_def, hf, prod.smul_mk],\nend\n\n/-- Fold a bilinear map along the generators of a term of the clifford algebra, with the rule\ngiven by `foldr' Q f hf n (ι Q m * x) = f m (x, foldr' Q f hf n x)`.\nNote this is like `clifford_algebra.foldr`, but with an extra `x` argument.\nImplement the recursion scheme `F[n0](m * x) = f(m, (x, F[n0](x)))`. -/\ndef foldr' (f : M →ₗ[R] clifford_algebra Q × N →ₗ[R] N)\n  (hf : ∀ m x fx, f m (ι Q m * x, f m (x, fx)) = Q m • fx)\n  (n : N) :\n  clifford_algebra Q →ₗ[R] N :=\nlinear_map.snd _ _ _ ∘ₗ foldr Q (foldr'_aux Q f) (foldr'_aux_foldr'_aux Q _ hf) (1, n)\n\nlemma foldr'_algebra_map (f : M →ₗ[R] clifford_algebra Q × N →ₗ[R] N)\n  (hf : ∀ m x fx, f m (ι Q m * x, f m (x, fx)) = Q m • fx) (n r) :\n  foldr' Q f hf n (algebra_map R _ r) = r • n :=\ncongr_arg prod.snd (foldr_algebra_map _ _ _ _ _)\n\nlemma foldr'_ι (f : M →ₗ[R] clifford_algebra Q × N →ₗ[R] N)\n  (hf : ∀ m x fx, f m (ι Q m * x, f m (x, fx)) = Q m • fx) (n m) :\n  foldr' Q f hf n (ι Q m) = f m (1, n) :=\ncongr_arg prod.snd (foldr_ι _ _ _ _ _)\n\nlemma foldr'_ι_mul (f : M →ₗ[R] clifford_algebra Q × N →ₗ[R] N)\n  (hf : ∀ m x fx, f m (ι Q m * x, f m (x, fx)) = Q m • fx) (n m) (x) :\n  foldr' Q f hf n (ι Q m * x) = f m (x, foldr' Q f hf n x) :=\nbegin\n  dsimp [foldr'],\n  rw [foldr_mul, foldr_ι, foldr'_aux_apply_apply],\n  refine congr_arg (f m) (prod.mk.eta.symm.trans _),\n  congr' 1,\n  induction x using clifford_algebra.left_induction with r x y hx hy m x hx,\n  { simp_rw [foldr_algebra_map, prod.smul_mk, algebra.algebra_map_eq_smul_one] },\n  { rw [map_add, prod.fst_add, hx, hy] },\n  { rw [foldr_mul, foldr_ι, foldr'_aux_apply_apply, hx], },\nend\n\nend clifford_algebra\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/linear_algebra/clifford_algebra/fold.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.47489578574619756}}
{"text": "/-\nCopyright (c) 2021 David Kurniadi Angdinata. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Kurniadi Angdinata\n-/\n\nimport algebra.char_p.algebra\nimport group_theory.finiteness\n\nimport algebraic_geometry.EllipticCurve.torsion\n\n-- Note: temporary\nimport algebraic_geometry.EllipticCurve.kummer\n\n/-!\n# The Mordell-Weil theorem for an elliptic curve over a number field\n-/\n\nnoncomputable theory\nopen_locale classical\n\nuniverse u\n\nvariables {F : Type u} [field F]\nvariables {E : EllipticCurve F}\nvariables {K : Type u} [field K] [algebra F K]\n\n----------------------------------------------------------------------------------------------------\n\nnamespace EllipticCurve\n\nopen point\n\n----------------------------------------------------------------------------------------------------\n/-! ## Reduction lemma -/\n\nsection reduction\n\nvariables (n : ℕ)\n\n/-- `nE(F)` is a subgroup of `ιₚ⁻¹(nE(K))`. -/\nlemma range_le_comap_range : (E⟮F⟯⬝n) ≤ add_subgroup.comap ιₚ E⟮K⟯⬝n :=\nby { rintro P ⟨Q, hQ⟩, rw [← hQ], exact ⟨ιₚ Q, (map_nsmul ιₚ Q n).symm⟩ }\n\n/-- The kernel `Φ` of the cokernel map `E(F)/nE(F) → E(K)/nE(K)` induced by `ιₚ : E(F) ↪ E(K)`. -/\ndef Φ (E : EllipticCurve F) (K : Type u) [field K] [algebra F K] : add_subgroup E⟮F⟯/n :=\n(quotient_add_group.map _ _ _ $ @range_le_comap_range _ _ _ K _ _ n).ker\n\n/-- If `[P] ∈ Φ`, then `ιₚ(P) ∈ nE(K)`. -/\nlemma Φ_mem_range (P : Φ n E K) : ιₚ (quot.out P.val) ∈ E⟮K⟯⬝n :=\nbegin\n  cases P with P hP,\n  change (quotient_add_group.lift _ ((quotient_add_group.mk' _).comp _) _) P = 0 at hP,\n  rw [← quot.out_eq P, quotient_add_group.lift_quot_mk, add_monoid_hom.coe_comp,\n      quotient_add_group.coe_mk', quotient_add_group.eq_zero_iff] at hP,\n  exact hP\nend\n\nvariables [finite_dimensional F K] [is_galois F K]\n\n/-- The map `κ : Φ → H¹(Gal(K/F), E(K)[n])` induced by the inflation-restriction exact sequence. -/\ndef κ : Φ n E K → (K ≃ₐ[F] K) → E⟮K⟯[n] :=\nλ P σ, ⟨σ • (Φ_mem_range n P).some - (Φ_mem_range n P).some,\nbegin\n  change n • (σ • _ - _ : E⟮K⟯) = 0,\n  rw [smul_sub, mul_by.map_smul],\n  change σ • mul_by n _ - mul_by n _ = 0,\n  rw [(Φ_mem_range n P).some_spec, sub_eq_zero],\n  revert σ,\n  change ιₚ (quot.out P.val) ∈ E⟮K⟯^F,\n  rw [point_gal.fixed.eq],\n  exact ⟨quot.out P.val, rfl⟩\nend⟩\n\n/-- `κ` is injective. -/\nlemma κ.injective : function.injective $ @κ _ _ E K _ _ n _ _ :=\nbegin\n  intros P₁_ P₂_ hP_,\n  let P₁ := quot.out P₁_.val,\n  let P₂ := quot.out P₂_.val,\n  have hP₁ : ∃ Q₁ : E⟮K⟯, n • Q₁ = ιₚ P₁ := Φ_mem_range n P₁_,\n  have hP₂ : ∃ Q₂ : E⟮K⟯, n • Q₂ = ιₚ P₂ := Φ_mem_range n P₂_,\n  have hP : hP₁.some - hP₂.some ∈ (ιₚ : E⟮F⟯ →+ E⟮K⟯).range :=\n  begin\n    rw [← point_gal.fixed.eq],\n    intro σ,\n    rw [smul_sub, sub_eq_sub_iff_sub_eq_sub],\n    injection (congr_fun hP_) σ\n  end,\n  cases hP with Q hQ,\n  apply_fun ((•) n) at hQ,\n  rw [smul_sub, hP₁.some_spec, hP₂.some_spec] at hQ,\n  rw [← P₁_.eta P₁_.property, ← P₂_.eta P₂_.property, subtype.mk_eq_mk, ← quotient.out_equiv_out],\n  change ∃ S : E⟮F⟯, n • S = -P₁ + P₂,\n  existsi [-Q],\n  apply_fun (ιₚ : E⟮F⟯ →+ E⟮K⟯) using point_hom.injective,\n  rw [← neg_inj, ← map_neg, smul_neg, neg_neg, map_nsmul, ← map_neg, neg_add', neg_neg, map_sub],\n  exact hQ\nend\n\n/-- If `E(K)/2E(K)` is finite, then `E(F)/2E(F)` is finite. -/\ndef coker_2_of_fg_extension.fintype [invertible (2 : F)] : fintype (E⟮K⟯/2) → fintype E⟮F⟯/2 :=\nadd_group.fintype_of_ker_codom $ fintype.of_injective (κ 2) (κ.injective 2)\n\nend reduction\n\n----------------------------------------------------------------------------------------------------\n/-! ## Complete 2-descent -/\n\nsection complete_2_descent\n\n-- Note: requires minimality of Weierstrass equation\n/-- The primes of a number field dividing `n` or at which `E` has bad reduction. -/\nlemma bad_primes [number_field K] (n : ℕ) : finset $ primes K :=\n@set.to_finset _ {p : primes K | (p.valuation ((F↑K)E.disc_unit) ≠ 1) ∨ (p.valuation ((ℤ↑K)n) < 1)}\nbegin\n  sorry\nend\n\nvariables [number_field F] [number_field K] [algebra F⟮E[2]⟯ K] [is_scalar_tower F F⟮E[2]⟯ K]\n\nnotation K⟮E; n⟯² := K⟮@bad_primes _ _ E _ _ _ infer_instance n, n⟯²\n\n/-- `2` is invertible in a number field. -/\ninstance number_field.invertible_two : invertible (2 : F) := invertible_of_nonzero two_ne_zero'\n\nvariables (ha₁ : E.a₁ = 0) (ha₃ : E.a₃ = 0)\nvariables {a b c : K} (h3 : (cubic.map (F↑K) $ ψ₂_x E F).roots = {a, b, c})\n\ninclude ha₁ ha₃ h3\n\nlocal notation n`⬝`K := (zpow_group_hom n : Kˣ →* Kˣ).range\n\n/-- The complete 2-descent function `δ : E(K) → Kˣ/(Kˣ)² × Kˣ/(Kˣ)²`. -/\ndef δ.to_fun : E⟮K⟯ → (Kˣ ⧸ (2⬝K)) × (Kˣ ⧸ (2⬝K))\n| 0            := 1\n| (some x y w) :=\nif ha : x = a then\n  (units.mk0 ((a - c) * (a - b)⁻¹) $ mul_ne_zero (sub_ne_zero.mpr (ψ₂_x.roots_ne h3).2.1) $\n    inv_ne_zero $ sub_ne_zero.mpr (ψ₂_x.roots_ne h3).1,\n  units.mk0 (a - b) $ sub_ne_zero.mpr (ψ₂_x.roots_ne h3).1)\nelse if hb : x = b then\n  (units.mk0 (b - a) $ sub_ne_zero.mpr (ψ₂_x.roots_ne h3).1.symm,\n  units.mk0 ((b - c) * (b - a)⁻¹) $ mul_ne_zero (sub_ne_zero.mpr (ψ₂_x.roots_ne h3).2.2) $\n    inv_ne_zero $ sub_ne_zero.mpr (ψ₂_x.roots_ne h3).1.symm)\nelse\n  (units.mk0 (x - a) $ sub_ne_zero.mpr ha, units.mk0 (x - b) $ sub_ne_zero.mpr hb)\n\nomit ha₁ ha₃ h3\n\n-- Input: explicit computation\n/-- The complete 2-descent homomorphism `δ : E(K) → Kˣ/(Kˣ)² × Kˣ/(Kˣ)²`. -/\ndef δ : E⟮K⟯ →+ additive ((Kˣ ⧸ (2⬝K)) × (Kˣ ⧸ (2⬝K))) :=\n{ to_fun    := δ.to_fun ha₁ ha₃ h3,\n  map_zero' := rfl,\n  map_add'  := sorry }\n\n@[simp] lemma δ.map_zero : δ ha₁ ha₃ h3 (0 : E⟮K⟯) = 0 := (δ ha₁ ha₃ h3).map_zero'\n\n@[simp] lemma δ.map_add (P Q : E⟮K⟯) : δ ha₁ ha₃ h3 (P + Q) = δ ha₁ ha₃ h3 P + δ ha₁ ha₃ h3 Q :=\n(δ ha₁ ha₃ h3).map_add' P Q\n\n-- Input: constructive proof for `ker δ = 2E(K)`\nlemma δ.ker : (δ ha₁ ha₃ h3).ker = E⟮K⟯⬝2 :=\nbegin\n  ext P,\n  split,\n  { intro hP,\n    cases P with x y w,\n    { exact ⟨0, rfl⟩ },\n    { change δ.to_fun ha₁ ha₃ h3 _ = 1 at hP,\n      simp only [δ.to_fun] at hP,\n      split_ifs at hP,\n      { sorry },\n      { sorry },\n      { sorry } } },\n  { rintro ⟨Q, hQ⟩,\n    rw [← hQ],\n    change δ ha₁ ha₃ h3 (2 • Q) = 0,\n    rw [map_nsmul],\n    change ((δ ha₁ ha₃ h3 Q).1 ^ 2, (δ ha₁ ha₃ h3 Q).2 ^ 2) = 1,\n    apply prod.ext,\n    all_goals { rw [← quotient_group.out_eq' (δ ha₁ ha₃ h3 Q).1,\n                    ← quotient_group.out_eq' (δ ha₁ ha₃ h3 Q).2],\n                exact (quotient_group.eq_one_iff _).mpr ⟨quot.out _, rfl⟩ } }\nend\n\n-- Input: local analysis for `im δ ≤ K(E; 2) × K(E; 2)`\nlemma δ.range_le : (δ ha₁ ha₃ h3).range ≤ K⟮E; 2⟯² :=\nbegin\n  sorry\nend\n\n/-- The lift `δ' : E(K)/2E(K) → K(E; 2) × K(E; 2)` of `δ`. -/\ndef δ.lift : (E⟮K⟯/2) →+ K⟮E; 2⟯² :=\n(add_subgroup.inclusion $ δ.range_le ha₁ ha₃ h3).comp $\n  (quotient_add_group.range_ker_lift $ δ ha₁ ha₃ h3).comp $\n  (quotient_add_group.equiv_quotient_of_eq $ δ.ker ha₁ ha₃ h3).symm.to_add_monoid_hom\n\nlemma δ.lift.injective : function.injective $ @δ.lift _ _ _ K _ _ _ _ _ _ ha₁ ha₃ _ _ _ h3 :=\nbegin\n  apply function.injective.comp,\n  { intros x y hxy,\n    rw [← set_like.coe_eq_coe, add_subgroup.coe_inclusion, add_subgroup.coe_inclusion,\n        set_like.coe_eq_coe] at hxy,\n    exact hxy },\n  simp only,\n  apply function.injective.comp,\n  { exact quotient_add_group.range_ker_lift_injective (δ ha₁ ha₃ h3) },\n  simp only,\n  { intros x y hxy,\n    rw [add_equiv.coe_to_add_monoid_hom, add_equiv.apply_eq_iff_eq] at hxy,\n    exact hxy }\nend\n\nend complete_2_descent\n\n----------------------------------------------------------------------------------------------------\n/-! ## The weak Mordell-Weil theorem -/\n\nsection weak_mordell_weil\n\nvariables [number_field F]\n\n/-- A splitting field of a number field has characteristic zero. -/\ninstance : char_zero F⟮E[2]⟯ := char_zero_of_injective_algebra_map (F↑F⟮E[2]⟯).injective\n\n/-- A splitting field of a number field is a number field. -/\ninstance : number_field F⟮E[2]⟯ :=\n@number_field.mk _ _ _ $ @finite_dimensional.trans _ F _ _ _ _ _ _\n  (@algebra.to_module _ _ _ _ $ @algebra_rat F⟮E[2]⟯ _ _) (by convert is_scalar_tower.rat) _ _\n\n/-- A splitting field of a number field is Galois. -/\ninstance : is_galois F F⟮E[2]⟯ := ⟨⟩\n\n/-- The weak Mordell-Weil theorem for `n = 2` assuming `E[2] ⊂ E(F)`: `E(F)/2E(F)` is finite. -/\ninstance coker_2_of_rat_E₂.fintype (ha₁ : E.a₁ = 0) (ha₃ : E.a₃ = 0) : fintype E⟮F⟮E[2]⟯⟯/2 :=\nfintype.of_injective _ $ δ.lift.injective ha₁ ha₃\n  ((cubic.splits_iff_roots_eq_three $ ψ₂_x.a_ne_zero E F).mp $ ψ₂_x.splits F⟮E[2]⟯)\n    .some_spec.some_spec.some_spec\n\n/-- The weak Mordell-Weil theorem for `n = 2`: `E(F)/2E(F)` is finite. -/\ninstance : fintype E⟮F⟯/2 :=\nbegin\n  apply @coker_2_of_fg_extension.fintype _ _ E F⟮E[2]⟯,\n  apply @fintype.of_equiv _ _ (@coker_2_of_rat_E₂.fintype _ _ E.covₘ _ (covₘ.a₁ E) (covₘ.a₃ E)),\n  apply (quotient_add_group.quotient_equiv_of_equiv _ 2).to_equiv,\n  rw [← ψ₂_x.eq_covₘ],\n  apply covₘ.equiv_add\nend\n\nend weak_mordell_weil\n\n----------------------------------------------------------------------------------------------------\n/-! ## The Mordell-Weil theorem -/\n\nsection mordell_weil\n\nvariables [number_field F]\n\n/-- The Mordell-Weil theorem: `E(F)` is finitely generated. -/\ninstance : add_group.fg E⟮F⟯ := sorry\n\nend mordell_weil\n\n----------------------------------------------------------------------------------------------------\n\nend EllipticCurve\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebraic_geometry/EllipticCurve/mordell_weil.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246118695629, "lm_q2_score": 0.5698526514141572, "lm_q1q2_score": 0.4748722395625438}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit : sorry := sorry\n\n/--`theorem`\nDensity of rational orbit\nThe fractional parts of the integer multiples of a rational number form a dense subset of the unit interval\n`proof`\nThis is a corollary of the Density of irrational orbit.\n\nLet $\\alpha$ be a rational number. Then there exists $i, j \\in \\mathbb{Z}$ such that $\\alpha=\\frac{i}{j}$. Then\n$$\n\\left\\{\\frac{i}{j} k\\right\\}=k\\frac{i}{j}-\\lfloor k\\frac{i}{j} \\rfloor=\\frac{i}{j}-\\frac{\\lfloor k\\frac{i}{j} \\rfloor}{k}\n$$\nis an integer multiple of the irrational number $\\alpha-\\frac{\\lfloor k\\frac{i}{j} \\rfloor}{k}$.\n\nHence, the set $S$ from the Density of irrational orbit contains all integer multiples of $\\alpha-\\frac{\\lfloor k\\frac{i}{j} \\rfloor}{k}$, which implies that it contains all integer multiples of $\\alpha$, and that it is dense in $[0,1]$.\n\nQED\n-/\ntheorem density_of_rational_orbit : sorry := sorry\nend\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (ha : irrational α) : \n∀ ε > 0, ∃ N : ℕ, ∀ n : ℕ, n ≥ N → ∃ m : ℤ, |((m : ℝ) * α) % 1 - ε| < ε :=\nbegin\n  assume (ε : ℝ) (hε : ε > 0),\n  \n  -- Let $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$\n  have h1 : ∀ (i j : ℤ), i ≠ j → ((i : ℝ) * α) % 1 ≠ ((j : ℝ) * α) % 1, from sorry,\n\n  -- If this were not true, then\n  have h2 : ((i : ℝ) * α) % 1 = ((j : ℝ) * α) % 1 → i = j, from sorry,\n\n  -- Then\n  have h3 : ((i : ℝ) * α) % 1 = ((j : ℝ) * α) % 1 → irrational α, from sorry,\n\n  -- Hence,\n  -- $S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$ is an infinite subset of $\\left[0,1\\right]$.\n  have h4 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h5 : ∀ (i j : ℤ), i ≠ j → ((i : ℝ) * α) % 1 ≠ ((j : ℝ) * α) % 1, from sorry,\n  have h6 : ∀ (i : ℤ), ∃ (j : ℤ), ((j : ℝ) * α) % 1 ≠ ((i : ℝ) * α) % 1, from sorry,\n  have h7 : ∀ (i : ℤ), ∃ (j : ℤ), ((j : ℝ) * α) % 1 ≠ ((i : ℝ) * α) % 1, from sorry,\n  have h8 : ∀ (i : ℤ), ∃ (j : ℤ), ((j : ℝ) * α) % 1 ≠ ((i : ℝ) * α) % 1, from sorry,\n  have h9 : ∃ (i : ℤ), ∃ (j : ℤ), ((j : ℝ) * α) % 1 ≠ ((i : ℝ) * α) % 1, from sorry,\n  have h10 : set.Icc 0 1 ≠ ∅, from sorry,\n  -- have h4 : ∃ (i : ℤ), ∃ (j : ℤ), ((j : ℝ) * α) % 1 ≠ ((i : ℝ) * α) % 1, from sorry,\n  have h11 : ∞, from sorry,\n  have h12 : ((j : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h13 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h14 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h15 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h16 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h17 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h18 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h19 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h20 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h21 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h22 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h23 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h24 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h25 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h26 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h27 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h28 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h29 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h30 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h31 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h32 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h33 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h34 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h35 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h36 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h37 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h38 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h39 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h40 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h41 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h42 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h43 : ∀ (i : ℤ), ((i : ℝ) * α) % 1 ∈ set.Icc 0 1, from sorry,\n  have h44 : ∀ (i : ℤ), ((i : ℝ) * α) %\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_irrational_orbit (α : ℝ) : \n  (∀ (i j : ℤ), i ≠ j → ¬(α * i - ⌊α * i⌋ = α * j - ⌊α * j⌋)) \n  → ∀ x : ℝ, x ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋) \n  → ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ∧ abs (y - x) < ε \n:=\nbegin\n  --Let $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  assume (h1 : ∀ (i j : ℤ), i ≠ j → ¬(α * i - ⌊α * i⌋ = α * j - ⌊α * j⌋)),\n  assume (x : ℝ) (h2 : x ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋)),\n  assume (ε : ℝ) (h3 : ε > 0),\n\n  --$S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$ is an infinite subset of $\\left[0,1\\right]$.\n  have h4 : ∀ (i : ℤ), α * i - ⌊α * i⌋ ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋), from sorry,\n  have h5 : set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ≠ ∅, from sorry,\n  have h6 : set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ⊆ set.Icc 0 1, from sorry,\n\n  --By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h7 : ∀ (B : set ℝ), B ≠ ∅ → B ⊆ set.Icc 0 1 → ∃ (l : ℝ), l ∈ set.Icc 0 1 ∧ (∀ (ε : ℝ), ε > 0 → ∃ (x : ℝ), x ∈ B ∧ abs (l - x) < ε), from sorry,\n  have h8 : ∃ (l : ℝ), l ∈ set.Icc 0 1 ∧ (∀ (ε : ℝ), ε > 0 → ∃ (x : ℝ), x ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ∧ abs (l - x) < ε), from sorry,\n\n  --One can thus find pairs of elements of $S$ that are arbitrarily close. \n  have h9 : ∀ (ε : ℝ), ε > 0 → ∃ (x y : ℝ), x ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ∧ y ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ∧ abs (x - y) < ε, from sorry,\n\n  --Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n  have h10 : ∀ (ε : ℝ), ε > 0 → ∃ (x : ℝ), x ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ∧ abs x < ε, from sorry,\n\n  --To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. \n  show ∃ (y : ℝ), y ∈ set.range (λ (i : ℤ), α * i - ⌊α * i⌋) ∧ abs (y - x) < ε, from sorry,\nend\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=irrational_orbit_dense {α : Type*} [discrete_linear_ordered_field α] (α : α) (h ⊢ : ¬ is_rat α) :\n  ∀ (ε : α) (ε_pos : 0 < ε) (y : α) (y_in : 0 ≤ y ∧ y < 1), ∃ x : α, x ∈ {n • α | n : ℤ} ∧ |y - x| < ε :=\nbegin\n  assume ε (ε_pos : 0 < ε) y (y_in : 0 ≤ y ∧ y < 1),\n  -- Let $\\alpha$ be an irrational number. \n  -- Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  -- If this were not true, then\n  have h1 : ∀ (i j : ℤ) (h_ne : i ≠ j), (i • α) - (i•α).to_int ≠ (j • α) - (j•α).to_int,\n  from sorry,\n\n  -- Then\n  -- $$\n  -- i \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n  -- $$\n  -- which yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. \n  have h2 : ∀ (i j : ℤ) (h_ne : i ≠ j), (i • α) - (i•α).to_int = (j • α) - (j•α).to_int →\n    (α = (i • α).to_int - (j • α).to_int) / (i - j) ∨ (α = (j • α).to_int - (i • α).to_int) / (j - i),\n  from sorry,\n\n  -- Hence,\n  -- $$\n  -- S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n  -- $$\n  -- is an infinite subset of $\\left[0,1\\right]$.\n  have h3 : {n • α | n : ℤ} ⊆ {x : α | 0 ≤ x ∧ x < 1}, from sorry,\n  have h4 : ∃ x : α, x ∈ {n • α | n : ℤ}, from sorry,\n  have h5 : {n • α | n : ℤ} ≠ ∅, from sorry,\n  have h6 : {n • α | n : ℤ} ⊆ {x : α | 0 ≤ x ∧ x < 1}, from sorry,\n  have h7 : ∀ (x : α), x ∈ {n • α | n : ℤ} → 0 ≤ x ∧ x < 1, from sorry,\n  have h8 : ∃ (x : α), x ∈ {n • α | n : ℤ} ∧ 0 ≤ x ∧ x < 1, from sorry,\n  have h9 : ∀ (x : α), x ∈ {n • α | n : ℤ} → x ≤ 1, from sorry,\n  have h10 : ∃ (x : α), x ∈ {n • α | n : ℤ} ∧ x ≤ 1, from sorry,\n  have h11 : {n • α | n : ℤ} ⊆ {x : α | x ≤ 1}, from sorry,\n  have h12 : {n • α | n : ℤ} ⊆ ↑({n • α | n : ℤ} : set α), from sorry,\n  have h13 : ↑({n • α | n : ℤ} : set α) ⊆ {x : α | 0 ≤ x ∧ x < 1}, from sorry,\n  have h14 : ↑({n • α | n : ℤ} : set α) ≠ ∅, from sorry,\n  have h15 : ↑({n • α | n : ℤ} : set α) ⊆ {x : α | 0 ≤ x ∧ x < 1}, from sorry,\n  have h16 : ∀ (x : α), x ∈ ↑({n • α | n : ℤ} : set α) → 0 ≤ x ∧ x < 1, from sorry,\n  have h17 : ∃ (x : α), x ∈ ↑({n • α | n : ℤ} : set α) ∧ 0 ≤ x ∧ x < 1, from sorry,\n  have h18 : ∀ (x : α), x ∈ ↑({n • α | n : ℤ} : set α) → x ≤ 1, from sorry,\n  have h19 : ∃ (x : α), x ∈ ↑({n • α | n : ℤ} : set α) ∧ x ≤ 1, from sorry,\n  have h20 : ↑({n • α | n : ℤ} : set α) ⊆ {x : α | x ≤ 1}, from sorry,\n\n  -- By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h21 : ∃ (x : α), x ∈ ↑({n • α | n : ℤ} : set α) ∧ ∀ (ε : α) (ε_pos : 0 < ε), ∃ (N : ℤ), ∀ (n : ℤ), n > N → |x - (n•α)| < ε, from sorry,\n  cases h21 with x h22,\n\n  -- One can thus find pairs of elements of $S$ that are arbitrarily close.\n  have h23 : ∀ (ε : α) (ε_pos : 0 < ε), ∃ (i j : ℤ) (h_ne : i ≠ j), |x - (i•α)| < ε ∧ |x - (j•α)| < ε, from sorry,\n  cases h23 ε ε_pos with i h24,\n  cases h24 with j h25,\n  cases h25 with h_ne h26,\n  cases h26 with h27 h28,\n\n  -- Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n  have h29 : ∀ (i j : ℤ) (h_ne : i ≠ j), |(i•α) - (j•α)| ∈ {n • α | n : ℤ}, from sorry,\n  have h30 : ∀ (ε : α) (ε_pos : 0 < ε), ∃ (N : ℤ), ∀ (n : ℤ), n > N → |(0:α) - (n•α)| < ε, from sorry,\n\n  -- To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. \n  have h31 : ∀ (y : α) (h_in : 0 ≤ y ∧ y < 1) (ε : α) (ε_pos : 0 < ε), ∃ (x : α), x ∈ {n • α | n : ℤ} ∧ |y - x| < ε, from sorry,\n\n  -- Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n  have h32 : ∀ (y : α) (h_in : 0 ≤ y ∧ y < 1) (ε : α) (ε_pos : 0 < ε), ∃ (x : α), x ∈ {n • α | n : ℤ} ∧ |y - x| < ε, from sorry,\n  show ∃ (x : α), x ∈ {n • α | n : ℤ} ∧ |y - x| < ε, from sorry,\nend\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (h1 : ¬ ∃ x : ℝ, α = x/x) : \n∀ y ∈ Icc 0 1, ∃ x : ℝ, ∃ i : ℤ, y = x ∧ x = i * α :=\nbegin\n  assume y h2,\n  have h3 : ∀ i j : ℤ, i ≠ j → i * α ≠ j * α, from sorry,\n  have h4 : ∀ i : ℤ, i * α ≠ 0, from sorry, \n  have h5 : ∃ x : ℝ, ∃ i : ℤ, ∀ i : ℤ, x ≠ i * α, from sorry,\n  have h6 : ∀ i : ℤ, ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h7 : ∃ N : ℕ, ∀ i : ℤ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h8 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h9 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h10 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h11 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h12 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h13 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h14 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h15 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h16 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h17 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h18 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h19 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h20 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h21 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h22 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h23 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h24 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h25 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h26 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h27 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h28 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h29 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h30 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h31 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h32 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h33 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h34 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h35 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h36 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h37 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h38 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h39 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h40 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h41 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h42 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h43 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h44 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h45 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h46 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N → ∃ x : ℝ, x ≠ i * α, from sorry,\n  have h47 : ∃ N : ℕ, ∀ i : ℕ, i ≥ N →\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : ¬ is_rat α) : \n  ∃ (S : set ℝ), ∀ (x : ℝ), x ∈ S → 0 ≤ x ∧ x < 1 ∧ ∀ y : ℝ, 0 ≤ y ∧ y < 1 → ∃ (x : ℝ), x ∈ S ∧ |y - x| < 1 :=\nbegin\n  -- Let $\\alpha$ be an irrational number.\n  assume α,\n  assume hα : ¬ is_rat α,\n\n  -- Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  have h2 : ∀ (i j : ℤ), i ≠ j → {i * α} ≠ {j * α}, \n  from sorry,\n\n  -- If this were not true, then\n  -- $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$.\n  have h3 : ∀ (i j : ℤ), i ≠ j → (α = (floor i α - floor j α) / (i - j) → (α ∈ ℚ)), \n  from sorry,\n\n  -- Hence,\n  -- $S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$\n  -- is an infinite subset of $\\left[0,1\\right]$.\n  have h4 : ∃ (S : set ℝ), ∀ (x : ℝ), x ∈ S → 0 ≤ x ∧ x < 1 ∧ ∀ (y : ℝ), y ∈ S → 0 ≤ y ∧ y < 1 ∧ ∀ (i j : ℤ), i ≠ j → {i * α} ≠ {j * α}, \n  from sorry,\n\n  -- By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h5 : ∃ (S : set ℝ), ∀ (x : ℝ), x ∈ S → 0 ≤ x ∧ x < 1 ∧ ∀ (y : ℝ), y ∈ S → 0 ≤ y ∧ y < 1 ∧ ∀ (i j : ℤ), i ≠ j → {i * α} ≠ {j * α} ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε, \n  from sorry,\n\n  -- One can thus find pairs of elements of $S$ that are arbitrarily close.\n  have h6 : ∃ (S : set ℝ), ∀ (x : ℝ), x ∈ S → 0 ≤ x ∧ x < 1 ∧ ∀ (y : ℝ), y ∈ S → 0 ≤ y ∧ y < 1 ∧ ∀ (i j : ℤ), i ≠ j → {i * α} ≠ {j * α} ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε ∧ ∀ (x y : ℝ), x ∈ S ∧ y ∈ S → ∃ (ε : ℝ), ε > 0 ∧ |x - y| < ε, \n  from sorry,\n\n  -- Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n  have h7 : ∃ (S : set ℝ), ∀ (x : ℝ), x ∈ S → 0 ≤ x ∧ x < 1 ∧ ∀ (y : ℝ), y ∈ S → 0 ≤ y ∧ y < 1 ∧ ∀ (i j : ℤ), i ≠ j → {i * α} ≠ {j * α} ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε ∧ ∀ (x y : ℝ), x ∈ S ∧ y ∈ S → ∃ (ε : ℝ), ε > 0 ∧ |x - y| < ε ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε, \n  from sorry,\n\n  -- To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$.\n  have h8 : ∃ (S : set ℝ), ∀ (x : ℝ), x ∈ S → 0 ≤ x ∧ x < 1 ∧ ∀ (y : ℝ), y ∈ S → 0 ≤ y ∧ y < 1 ∧ ∀ (i j : ℤ), i ≠ j → {i * α} ≠ {j * α} ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε ∧ ∀ (x y : ℝ), x ∈ S ∧ y ∈ S → ∃ (ε : ℝ), ε > 0 ∧ |x - y| < ε ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε ∧ ∀ (y : ℝ), 0 ≤ y ∧ y < 1 → ∃ (x : ℝ), x ∈ S ∧ ∃ (ε : ℝ), ε > 0 ∧ |y - x| < ε, \n  from sorry,\n\n  -- Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n  have h9 : ∃ (S : set ℝ), ∀ (x : ℝ), x ∈ S → 0 ≤ x ∧ x < 1 ∧ ∀ (y : ℝ), y ∈ S → 0 ≤ y ∧ y < 1 ∧ ∀ (i j : ℤ), i ≠ j → {i * α} ≠ {j * α} ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε ∧ ∀ (x y : ℝ), x ∈ S ∧ y ∈ S → ∃ (ε : ℝ), ε > 0 ∧ |x - y| < ε ∧ ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (y : ℝ), y ∈ S ∧ |x - y| < ε ∧ ∀ (y : ℝ), 0 ≤ y ∧ y < 1 → ∃ (x : ℝ), x ∈ S ∧ ∃ (ε : ℝ), ε > 0 ∧ |y - x| < ε ∧ ∀ (y : ℝ), 0 ≤ y ∧ y < 1 → ∃ (x : ℝ), x ∈ S ∧ ∀ (ε : ℝ), ε > 0 → ∃ (n : ℕ), |y - ({n * x} % 1) | < ε, \n  from sorry,\n\n  -- QED\n  show ∃ (S : set\nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit : ∀ (α : ℝ) (hα : ¬ is_rat α), ∀ y ∈ set.Icc 0 1, ∃ x ∈ set.Icc 0 1, ∃ N : ℤ, \n∀ (ε : ℝ) (hε : ε > 0), |y - (N : ℝ) * x| < ε :=\nbegin\n  assume α hα y h1,\n  have h2 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h3 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h4 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h5 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h6 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h7 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h8 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h9 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h10 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n\n  have h11 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h12 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h13 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h14 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h15 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h16 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h17 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h18 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h19 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h20 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h21 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h22 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h23 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h24 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h25 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h26 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h27 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h28 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h29 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h30 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h31 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h32 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h33 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h34 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h35 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h36 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h37 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h38 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h39 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h40 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h41 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h42 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h43 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h44 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h45 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h46 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h47 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h48 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h49 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h50 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h51 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h52 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h53 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h54 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\n  have h55 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from sorry,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_irrational_orbit {α : Type*} [decidable_linear_order α] (α : ℚ) : ∀ ε > 0, ∃ n : ℤ, |n*α - (n*α).floor| < ε :=\nbegin\n  assume ε,\n  assume h1 : ε > 0,\n  have h2 : ∃ n : ℤ, |n*α - (n*α).floor| < ε, from sorry,\n  show ∃ n : ℤ, |n*α - (n*α).floor| < ε, from sorry,\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from sorry,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from sorry,\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by sorry\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by sorry\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by sorry\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n      have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n      show e = (1 : G), from sorry,     \n    },\n    sorry,\n  }\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n  from sorry,\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : ε > 0),\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that $\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n  cases h2 ε h7 with N1 h8,\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that $\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n  cases h3 ε h7 with N2 h9,\n  \n  --Let $N = \\max \\set {N_1, N_2}$.\n  let N := max N1 N2,\n  use N,\n\n  --Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n  have h10 : ∀ n > N, n > N1 ∧ n > N2 := sorry,\n  \n  --$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n  --$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n  --$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n  --So $\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n  from sorry,\n    \n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n  from sorry,\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  ∀ (n : ℕ), n > N → |x n - l| < ε, \n  from sorry,\nend\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n\nTo show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n\nQED\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline_with_comments-Natural-Language-Proof-Translation/lean_proof_outline_with_comments-4_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246118695629, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.47487223956254376}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.shapes.terminal\nimport category_theory.limits.preserves.basic\n\n/-!\n# Preserving terminal object\n\nConstructions to relate the notions of preserving terminal objects and reflecting terminal objects\nto concrete objects.\n\nIn particular, we show that `terminal_comparison G` is an isomorphism iff `G` preserves terminal\nobjects.\n-/\n\nuniverses v v₁ v₂ u u₁ u₂\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u₁} [category.{v₁} C]\nvariables {D : Type u₂} [category.{v₂} D]\nvariables (G : C ⥤ D)\n\nnamespace category_theory.limits\n\nvariables (X : C)\n\nsection terminal\n\n/--\nThe map of an empty cone is a limit iff the mapped object is terminal.\n-/\ndef is_limit_map_cone_empty_cone_equiv :\n  is_limit (G.map_cone (as_empty_cone.{v₁} X)) ≃ is_terminal (G.obj X) :=\nis_limit_empty_cone_equiv D _ _ (eq_to_iso rfl)\n\n/-- The property of preserving terminal objects expressed in terms of `is_terminal`. -/\ndef is_terminal.is_terminal_obj [preserves_limit (functor.empty.{0} C) G]\n  (l : is_terminal X) : is_terminal (G.obj X) :=\nis_limit_map_cone_empty_cone_equiv G X (preserves_limit.preserves l)\n\n/-- The property of reflecting terminal objects expressed in terms of `is_terminal`. -/\ndef is_terminal.is_terminal_of_obj [reflects_limit (functor.empty.{0} C) G]\n  (l : is_terminal (G.obj X)) : is_terminal X :=\nreflects_limit.reflects ((is_limit_map_cone_empty_cone_equiv G X).symm l)\n\nvariables [has_terminal C]\n/--\nIf `G` preserves the terminal object and `C` has a terminal object, then the image of the terminal\nobject is terminal.\n-/\ndef is_limit_of_has_terminal_of_preserves_limit [preserves_limit (functor.empty.{0} C) G] :\n  is_terminal (G.obj (⊤_ C)) :=\nterminal_is_terminal.is_terminal_obj G (⊤_ C)\n\n/--\nIf `C` has a terminal object and `G` preserves terminal objects, then `D` has a terminal object\nalso.\nNote this property is somewhat unique to (co)limits of the empty diagram: for general `J`, if `C`\nhas limits of shape `J` and `G` preserves them, then `D` does not necessarily have limits of shape\n`J`.\n-/\nlemma has_terminal_of_has_terminal_of_preserves_limit [preserves_limit (functor.empty.{0} C) G] :\n  has_terminal D :=\n⟨λ F,\nbegin\n  haveI := has_limit.mk ⟨_, is_limit_of_has_terminal_of_preserves_limit G⟩,\n  apply has_limit_of_iso F.unique_from_empty.symm,\nend⟩\n\nvariable [has_terminal D]\n/--\nIf the terminal comparison map for `G` is an isomorphism, then `G` preserves terminal objects.\n-/\ndef preserves_terminal.of_iso_comparison\n  [i : is_iso (terminal_comparison G)] : preserves_limit (functor.empty C) G :=\nbegin\n  apply preserves_limit_of_preserves_limit_cone terminal_is_terminal,\n  apply (is_limit_map_cone_empty_cone_equiv _ _).symm _,\n  apply is_limit.of_point_iso (limit.is_limit (functor.empty.{0} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `G.obj ⊤ ⟶ ⊤`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_is_iso\n  (f : G.obj (⊤_ C) ⟶ ⊤_ D) [i : is_iso f] : preserves_limit (functor.empty C) G :=\nbegin\n  rw subsingleton.elim f (terminal_comparison G) at i,\n  exactI preserves_terminal.of_iso_comparison G,\nend\n\n/-- If there is any isomorphism `G.obj ⊤ ≅ ⊤`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_iso\n  (f : G.obj (⊤_ C) ≅ ⊤_ D) : preserves_limit (functor.empty C) G :=\npreserves_terminal_of_is_iso G f.hom\n\nvariables [preserves_limit (functor.empty.{0} C) G]\n\n/--\nIf `G` preserves terminal objects, then the terminal comparison map for `G` is an isomorphism.\n-/\ndef preserves_terminal.iso : G.obj (⊤_ C) ≅ ⊤_ D :=\n(is_limit_of_has_terminal_of_preserves_limit G).cone_point_unique_up_to_iso (limit.is_limit _)\n\n@[simp]\nlemma preserves_terminal.iso_hom : (preserves_terminal.iso G).hom = terminal_comparison G :=\nrfl\n\ninstance : is_iso (terminal_comparison G) :=\nbegin\n  rw ← preserves_terminal.iso_hom,\n  apply_instance,\nend\n\nend terminal\n\nsection initial\n\n/--\nThe map of an empty cocone is a colimit iff the mapped object is initial.\n-/\ndef is_colimit_map_cocone_empty_cocone_equiv :\n  is_colimit (G.map_cocone (as_empty_cocone.{v₁} X)) ≃ is_initial (G.obj X) :=\nis_colimit_empty_cocone_equiv D _ _ (eq_to_iso rfl)\n\n/-- The property of preserving initial objects expressed in terms of `is_initial`. -/\ndef is_initial.is_initial_obj [preserves_colimit (functor.empty.{0} C) G]\n  (l : is_initial X) : is_initial (G.obj X) :=\nis_colimit_map_cocone_empty_cocone_equiv G X (preserves_colimit.preserves l)\n\n/-- The property of reflecting initial objects expressed in terms of `is_initial`. -/\ndef is_initial.is_initial_of_obj [reflects_colimit (functor.empty.{0} C) G]\n  (l : is_initial (G.obj X)) : is_initial X :=\nreflects_colimit.reflects ((is_colimit_map_cocone_empty_cocone_equiv G X).symm l)\n\nvariables [has_initial C]\n/--\nIf `G` preserves the initial object and `C` has a initial object, then the image of the initial\nobject is initial.\n-/\ndef is_colimit_of_has_initial_of_preserves_colimit [preserves_colimit (functor.empty.{0} C) G] :\n  is_initial (G.obj (⊥_ C)) :=\ninitial_is_initial.is_initial_obj G (⊥_ C)\n\n/--\nIf `C` has a initial object and `G` preserves initial objects, then `D` has a initial object\nalso.\nNote this property is somewhat unique to colimits of the empty diagram: for general `J`, if `C`\nhas colimits of shape `J` and `G` preserves them, then `D` does not necessarily have colimits of\nshape `J`.\n-/\nlemma has_initial_of_has_initial_of_preserves_colimit [preserves_colimit (functor.empty.{0} C) G] :\n  has_initial D :=\n⟨λ F,\nbegin\n  haveI := has_colimit.mk ⟨_, is_colimit_of_has_initial_of_preserves_colimit G⟩,\n  apply has_colimit_of_iso F.unique_from_empty,\nend⟩\n\nvariable [has_initial D]\n/--\nIf the initial comparison map for `G` is an isomorphism, then `G` preserves initial objects.\n-/\ndef preserves_initial.of_iso_comparison\n  [i : is_iso (initial_comparison G)] : preserves_colimit (functor.empty C) G :=\nbegin\n  apply preserves_colimit_of_preserves_colimit_cocone initial_is_initial,\n  apply (is_colimit_map_cocone_empty_cocone_equiv _ _).symm _,\n  apply is_colimit.of_point_iso (colimit.is_colimit (functor.empty.{0} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `⊥ ⟶ G.obj ⊥`, then `G` preserves initial objects. -/\ndef preserves_initial_of_is_iso\n  (f : ⊥_ D ⟶ G.obj (⊥_ C)) [i : is_iso f] : preserves_colimit (functor.empty C) G :=\nbegin\n  rw subsingleton.elim f (initial_comparison G) at i,\n  exactI preserves_initial.of_iso_comparison G,\nend\n\n/-- If there is any isomorphism `⊥ ≅ G.obj ⊥ `, then `G` preserves initial objects. -/\ndef preserves_initial_of_iso\n  (f : ⊥_ D ≅ G.obj (⊥_ C)) : preserves_colimit (functor.empty C) G :=\npreserves_initial_of_is_iso G f.hom\n\nvariables [preserves_colimit (functor.empty.{0} C) G]\n\n/-- If `G` preserves initial objects, then the initial comparison map for `G` is an isomorphism. -/\ndef preserves_initial.iso : G.obj (⊥_ C) ≅ ⊥_ D :=\n(is_colimit_of_has_initial_of_preserves_colimit G).cocone_point_unique_up_to_iso\n  (colimit.is_colimit _)\n\n@[simp]\nlemma preserves_initial.iso_hom : (preserves_initial.iso G).inv = initial_comparison G :=\nrfl\n\ninstance : is_iso (initial_comparison G) :=\nbegin\n  rw ← preserves_initial.iso_hom,\n  apply_instance,\nend\n\nend initial\n\nend category_theory.limits\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/category_theory/limits/preserves/shapes/terminal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.6150878555160666, "lm_q1q2_score": 0.4747515618798562}}
{"text": "/-\nCopyright (c) 2021 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Aaron Anderson\n-/\nimport data.set.finite\nimport order.well_founded\nimport order.order_iso_nat\nimport algebra.pointwise\n\n/-!\n# Well-founded sets\n\nA well-founded subset of an ordered type is one on which the relation `<` is well-founded.\n\n## Main Definitions\n * `set.well_founded_on s r` indicates that the relation `r` is\n  well-founded when restricted to the set `s`.\n * `set.is_wf s` indicates that `<` is well-founded when restricted to `s`.\n * `set.partially_well_ordered_on s r` indicates that the relation `r` is\n  partially well-ordered (also known as well quasi-ordered) when restricted to the set `s`.\n * `set.is_pwo s` indicates that any infinite sequence of elements in `s`\n  contains an infinite monotone subsequence. Note that\n\n### Definitions for Hahn Series\n * `set.add_antidiagonal s t a` and `set.mul_antidiagonal s t a` are the sets of pairs of elements\n  from `s` and `t` that add/multiply to `a`.\n * `finset.add_antidiagonal` and `finset.mul_antidiagonal` are finite versions of\n  `set.add_antidiagonal` and `set.mul_antidiagonal` defined when `s` and `t` are well-founded.\n\n## Main Results\n * Higman's Lemma, `set.partially_well_ordered_on.partially_well_ordered_on_sublist_forall₂`,\n  shows that if `r` is partially well-ordered on `s`, then `list.sublist_forall₂` is partially\n  well-ordered on the set of lists of elements of `s`. The result was originally published by\n  Higman, but this proof more closely follows Nash-Williams.\n * `set.well_founded_on_iff` relates `well_founded_on` to the well-foundedness of a relation on the\n original type, to avoid dealing with subtypes.\n * `set.is_wf.mono` shows that a subset of a well-founded subset is well-founded.\n * `set.is_wf.union` shows that the union of two well-founded subsets is well-founded.\n * `finset.is_wf` shows that all `finset`s are well-founded.\n\n## References\n * [Higman, *Ordering by Divisibility in Abstract Algebras*][Higman52]\n * [Nash-Williams, *On Well-Quasi-Ordering Finite Trees*][Nash-Williams63]\n-/\n\nopen_locale pointwise\n\nvariables {α : Type*}\n\nnamespace set\n\n/-- `s.well_founded_on r` indicates that the relation `r` is well-founded when restricted to `s`. -/\ndef well_founded_on (s : set α) (r : α → α → Prop) : Prop :=\nwell_founded (λ (a : s) (b : s), r a b)\n\nlemma well_founded_on_iff {s : set α} {r : α → α → Prop} :\n  s.well_founded_on r ↔ well_founded (λ (a b : α), r a b ∧ a ∈ s ∧ b ∈ s) :=\nbegin\n  have f : rel_embedding (λ (a : s) (b : s), r a b) (λ (a b : α), r a b ∧ a ∈ s ∧ b ∈ s) :=\n    ⟨⟨coe, subtype.coe_injective⟩, λ a b, by simp⟩,\n  refine ⟨λ h, _, f.well_founded⟩,\n  rw well_founded.well_founded_iff_has_min,\n  intros t ht,\n  by_cases hst : (s ∩ t).nonempty,\n  { rw ← subtype.preimage_coe_nonempty at hst,\n    rcases well_founded.well_founded_iff_has_min.1 h (coe ⁻¹' t) hst with ⟨⟨m, ms⟩, mt, hm⟩,\n    exact ⟨m, mt, λ x xt ⟨xm, xs, ms⟩, hm ⟨x, xs⟩ xt xm⟩ },\n  { rcases ht with ⟨m, mt⟩,\n    exact ⟨m, mt, λ x xt ⟨xm, xs, ms⟩, hst ⟨m, ⟨ms, mt⟩⟩⟩ }\nend\n\nlemma well_founded_on.induction {s : set α} {r : α → α → Prop} (hs : s.well_founded_on r) {x : α}\n  (hx : x ∈ s) {P : α → Prop} (hP : ∀ (y ∈ s), (∀ (z ∈ s), r z y → P z) → P y) :\n  P x :=\nbegin\n  let Q : s → Prop := λ y, P y,\n  change Q ⟨x, hx⟩,\n  refine well_founded.induction hs ⟨x, hx⟩ _,\n  rintros ⟨y, ys⟩ ih,\n  exact hP _ ys (λ z zs zy, ih ⟨z, zs⟩ zy),\nend\n\ninstance is_strict_order.subset {s : set α} {r : α → α → Prop} [is_strict_order α r] :\n  is_strict_order α (λ (a b : α), r a b ∧ a ∈ s ∧ b ∈ s) :=\n{ to_is_irrefl := ⟨λ a con, irrefl_of r a con.1 ⟩,\n  to_is_trans := ⟨λ a b c ab bc, ⟨trans_of r ab.1 bc.1, ab.2.1, bc.2.2⟩ ⟩ }\n\ntheorem well_founded_on_iff_no_descending_seq {s : set α} {r : α → α → Prop} [is_strict_order α r] :\n  s.well_founded_on r ↔ ∀ (f : ((>) : ℕ → ℕ → Prop) ↪r r), ¬ (range f) ⊆ s :=\nbegin\n  rw [well_founded_on_iff, rel_embedding.well_founded_iff_no_descending_seq],\n  refine ⟨λ h f con, begin\n      refine h.elim' ⟨⟨f, f.injective⟩, λ a b, _⟩,\n       simp only [con (mem_range_self a), con (mem_range_self b), and_true, gt_iff_lt,\n        function.embedding.coe_fn_mk, f.map_rel_iff]\n    end, λ h, ⟨λ con, _⟩⟩,\n  rcases con with ⟨f, hf⟩,\n  have hfs' : ∀ n : ℕ, f n ∈ s := λ n, (hf.2 n.lt_succ_self).2.2,\n  refine h ⟨f, λ a b, _⟩ (λ n hn, _),\n  { rw ← hf,\n    exact ⟨λ h, ⟨h, hfs' _, hfs' _⟩, λ h, h.1⟩ },\n  { rcases set.mem_range.1 hn with ⟨m, hm⟩,\n    rw ← hm,\n    apply hfs' }\nend\n\nsection has_lt\nvariables [has_lt α]\n\n/-- `s.is_wf` indicates that `<` is well-founded when restricted to `s`. -/\ndef is_wf (s : set α) : Prop := well_founded_on s (<)\n\nlemma is_wf_univ_iff : is_wf (univ : set α) ↔ well_founded ((<) : α → α → Prop) :=\nby simp [is_wf, well_founded_on_iff]\n\nvariables {s t : set α}\n\ntheorem is_wf.mono (h : is_wf t) (st : s ⊆ t) : is_wf s :=\nbegin\n  rw [is_wf, well_founded_on_iff] at *,\n  refine subrelation.wf (λ x y xy, _) h,\n  exact ⟨xy.1, st xy.2.1, st xy.2.2⟩,\nend\nend has_lt\n\nsection partial_order\nvariables [partial_order α] {s t : set α} {a : α}\n\ntheorem is_wf_iff_no_descending_seq :\n  is_wf s ↔ ∀ (f : (order_dual ℕ) ↪o α), ¬ (range f) ⊆ s :=\nbegin\n  haveI : is_strict_order α (λ (a b : α), a < b ∧ a ∈ s ∧ b ∈ s) :=\n  { to_is_irrefl := ⟨λ x con, lt_irrefl x con.1⟩,\n    to_is_trans := ⟨λ a b c ab bc, ⟨lt_trans ab.1 bc.1, ab.2.1, bc.2.2⟩⟩, },\n  rw [is_wf, well_founded_on_iff_no_descending_seq],\n  exact ⟨λ h f, h f.lt_embedding, λ h f, h (order_embedding.of_strict_mono\n    f (λ _ _, f.map_rel_iff.2))⟩,\nend\n\ntheorem is_wf.union (hs : is_wf s) (ht : is_wf t) : is_wf (s ∪ t) :=\nbegin\n  classical,\n  rw [is_wf_iff_no_descending_seq] at *,\n  rintros f fst,\n  have h : infinite (f ⁻¹' s) ∨ infinite (f ⁻¹' t),\n  { have h : infinite (univ : set ℕ) := infinite_univ,\n    have hpre : f ⁻¹' (s ∪ t) = set.univ,\n    { rw [← image_univ, image_subset_iff, univ_subset_iff] at fst,\n      exact fst },\n    rw preimage_union at hpre,\n    rw ← hpre at h,\n    rw [infinite, infinite],\n    rw infinite at h,\n    contrapose! h,\n    exact finite.union h.1 h.2, },\n  rw [← infinite_coe_iff, ← infinite_coe_iff] at h,\n  cases h with inf inf; haveI := inf,\n  { apply hs ((nat.order_embedding_of_set (f ⁻¹' s)).dual.trans f),\n    change range (function.comp f (nat.order_embedding_of_set (f ⁻¹' s))) ⊆ s,\n    rw [range_comp, image_subset_iff],\n      simp },\n  { apply ht ((nat.order_embedding_of_set (f ⁻¹' t)).dual.trans f),\n    change range (function.comp f (nat.order_embedding_of_set (f ⁻¹' t))) ⊆ t,\n    rw [range_comp, image_subset_iff],\n      simp }\nend\nend partial_order\n\nend set\n\nnamespace set\n\n/-- A subset is partially well-ordered by a relation `r` when any infinite sequence contains\n  two elements where the first is related to the second by `r`. -/\ndef partially_well_ordered_on (s) (r : α → α → Prop) : Prop :=\n  ∀ (f : ℕ → α), range f ⊆ s → ∃ (m n : ℕ), m < n ∧ r (f m) (f n)\n\n/-- A subset of a preorder is partially well-ordered when any infinite sequence contains\n  a monotone subsequence of length 2 (or equivalently, an infinite monotone subsequence). -/\ndef is_pwo [preorder α] (s) : Prop :=\npartially_well_ordered_on s ((≤) : α → α → Prop)\n\ntheorem partially_well_ordered_on.mono {s t : set α} {r : α → α → Prop}\n  (ht : t.partially_well_ordered_on r) (hsub : s ⊆ t) :\n  s.partially_well_ordered_on r :=\nλ f hf, ht f (set.subset.trans hf hsub)\n\ntheorem partially_well_ordered_on.image_of_monotone_on {s : set α}\n  {r : α → α → Prop} {β : Type*} {r' : β → β → Prop}\n  (hs : s.partially_well_ordered_on r) {f : α → β}\n  (hf : ∀ a1 a2 : α, a1 ∈ s → a2 ∈ s → r a1 a2 → r' (f a1) (f a2)) :\n  (f '' s).partially_well_ordered_on r' :=\nλ g hg, begin\n  have h := λ (n : ℕ), ((mem_image _ _ _).1 (hg (mem_range_self n))),\n  obtain ⟨m, n, hlt, hmn⟩ := hs (λ n, classical.some (h n)) _,\n  { refine ⟨m, n, hlt, _⟩,\n    rw [← (classical.some_spec (h m)).2,\n      ← (classical.some_spec (h n)).2],\n    exact hf _ _ (classical.some_spec (h m)).1 (classical.some_spec (h n)).1 hmn },\n  { rintros _ ⟨n, rfl⟩,\n    exact (classical.some_spec (h n)).1 }\nend\n\nsection partial_order\nvariables {s : set α} {t : set α} {r : α → α → Prop}\n\ntheorem partially_well_ordered_on.exists_monotone_subseq [is_refl α r] [is_trans α r]\n  (h : s.partially_well_ordered_on r) (f : ℕ → α) (hf : range f ⊆ s) :\n  ∃ (g : ℕ ↪o ℕ), ∀ m n : ℕ, m ≤ n → r (f (g m)) (f (g n)) :=\nbegin\n  obtain ⟨g, h1 | h2⟩ := exists_increasing_or_nonincreasing_subseq r f,\n  { refine ⟨g, λ m n hle, _⟩,\n    obtain hlt | heq := lt_or_eq_of_le hle,\n    { exact h1 m n hlt, },\n    { rw [heq],\n      apply refl_of r } },\n  { exfalso,\n    obtain ⟨m, n, hlt, hle⟩ := h (f ∘ g) (subset.trans (range_comp_subset_range _ _) hf),\n    exact h2 m n hlt hle }\nend\n\ntheorem partially_well_ordered_on_iff_exists_monotone_subseq [is_refl α r] [is_trans α r] :\n  s.partially_well_ordered_on r ↔\n    ∀ f : ℕ → α, range f ⊆ s → ∃ (g : ℕ ↪o ℕ), ∀ m n : ℕ, m ≤ n → r (f (g m)) (f (g n)) :=\nbegin\n  classical,\n  split; intros h f hf,\n  { exact h.exists_monotone_subseq f hf },\n  { obtain ⟨g, gmon⟩ := h f hf,\n    refine ⟨g 0, g 1, g.lt_iff_lt.2 zero_lt_one, gmon _ _ zero_le_one⟩, }\nend\n\nlemma partially_well_ordered_on.well_founded_on [is_partial_order α r]\n  (h : s.partially_well_ordered_on r) :\n  s.well_founded_on (λ a b, r a b ∧ a ≠ b) :=\nbegin\n  haveI : is_strict_order α (λ a b, r a b ∧ a ≠ b) :=\n  { to_is_irrefl := ⟨λ a con, con.2 rfl⟩,\n    to_is_trans := ⟨λ a b c ab bc, ⟨trans ab.1 bc.1,\n      λ ac, ab.2 (antisymm ab.1 (ac.symm ▸ bc.1))⟩⟩ },\n  rw well_founded_on_iff_no_descending_seq,\n  intros f con,\n  obtain ⟨m, n, hlt, hle⟩ := h f con,\n  exact (f.map_rel_iff.2 hlt).2 (antisymm hle (f.map_rel_iff.2 hlt).1).symm,\nend\n\nvariables [partial_order α]\n\nlemma is_pwo.is_wf (h : s.is_pwo) :\n  s.is_wf :=\nbegin\n  rw [is_wf],\n  convert h.well_founded_on,\n  ext x y,\n  rw lt_iff_le_and_ne,\nend\n\ntheorem is_pwo.exists_monotone_subseq\n  (h : s.is_pwo) (f : ℕ → α) (hf : range f ⊆ s) :\n  ∃ (g : ℕ ↪o ℕ), monotone (f ∘ g) :=\nh.exists_monotone_subseq f hf\n\ntheorem is_pwo_iff_exists_monotone_subseq :\n  s.is_pwo ↔\n    ∀ f : ℕ → α, range f ⊆ s → ∃ (g : ℕ ↪o ℕ), monotone (f ∘ g) :=\npartially_well_ordered_on_iff_exists_monotone_subseq\n\nlemma is_pwo.prod (hs : s.is_pwo)\n  (ht : t.is_pwo) :\n  (s.prod t).is_pwo :=\nbegin\n  classical,\n  rw is_pwo_iff_exists_monotone_subseq at *,\n  intros f hf,\n  obtain ⟨g1, h1⟩ := hs (prod.fst ∘ f) _,\n  swap,\n  { rw [range_comp, image_subset_iff],\n    refine subset.trans hf _,\n    rintros ⟨x1, x2⟩ hx,\n    simp only [mem_preimage, hx.1] },\n  obtain ⟨g2, h2⟩ := ht (prod.snd ∘ f ∘ g1) _,\n  refine ⟨g2.trans g1, λ m n mn, _⟩,\n  swap,\n  { rw [range_comp, image_subset_iff],\n    refine subset.trans (range_comp_subset_range _ _) (subset.trans hf _),\n    rintros ⟨x1, x2⟩ hx,\n    simp only [mem_preimage, hx.2] },\n  simp only [rel_embedding.coe_trans, function.comp_app],\n  exact ⟨h1 (g2.le_iff_le.2 mn), h2 mn⟩,\nend\n\ntheorem is_pwo.image_of_monotone {β : Type*} [partial_order β]\n  (hs : s.is_pwo) {f : α → β} (hf : monotone f) :\n  is_pwo (f '' s) :=\nhs.image_of_monotone_on (λ _ _ _ _ ab, hf ab)\n\ntheorem is_pwo.union (hs : is_pwo s) (ht : is_pwo t) : is_pwo (s ∪ t) :=\nbegin\n  classical,\n  rw [is_pwo_iff_exists_monotone_subseq] at *,\n  rintros f fst,\n  have h : infinite (f ⁻¹' s) ∨ infinite (f ⁻¹' t),\n  { have h : infinite (univ : set ℕ) := infinite_univ,\n    have hpre : f ⁻¹' (s ∪ t) = set.univ,\n    { rw [← image_univ, image_subset_iff, univ_subset_iff] at fst,\n      exact fst },\n    rw preimage_union at hpre,\n    rw ← hpre at h,\n    rw [infinite, infinite],\n    rw infinite at h,\n    contrapose! h,\n    exact finite.union h.1 h.2, },\n  rw [← infinite_coe_iff, ← infinite_coe_iff] at h,\n  cases h with inf inf; haveI := inf,\n  { obtain ⟨g, hg⟩ := hs (f ∘ (nat.order_embedding_of_set (f ⁻¹' s))) _,\n    { rw [function.comp.assoc, ← rel_embedding.coe_trans] at hg,\n      exact ⟨_, hg⟩ },\n    rw [range_comp, image_subset_iff],\n    simp },\n  { obtain ⟨g, hg⟩ := ht (f ∘ (nat.order_embedding_of_set (f ⁻¹' t))) _,\n    { rw [function.comp.assoc, ← rel_embedding.coe_trans] at hg,\n      exact ⟨_, hg⟩ },\n    rw [range_comp, image_subset_iff],\n    simp }\nend\n\nend partial_order\n\ntheorem is_wf.is_pwo [linear_order α] {s : set α}\n  (hs : s.is_wf) : s.is_pwo :=\nλ f hf, begin\n  rw [is_wf, well_founded_on_iff] at hs,\n  have hrange : (range f).nonempty := ⟨f 0, mem_range_self 0⟩,\n  let a := hs.min (range f) hrange,\n  obtain ⟨m, hm⟩ := hs.min_mem (range f) hrange,\n  refine ⟨m, m.succ, m.lt_succ_self, le_of_not_lt (λ con, _)⟩,\n  rw hm at con,\n  apply hs.not_lt_min (range f) hrange (mem_range_self m.succ)\n    ⟨con, hf (mem_range_self m.succ), hf _⟩,\n  rw ← hm,\n  apply mem_range_self,\nend\n\ntheorem is_wf_iff_is_pwo [linear_order α] {s : set α} :\n  s.is_wf ↔ s.is_pwo :=\n⟨is_wf.is_pwo, is_pwo.is_wf⟩\n\nend set\n\nnamespace finset\n\n@[simp]\ntheorem partially_well_ordered_on {r : α → α → Prop} [is_refl α r] (f : finset α) :\n  set.partially_well_ordered_on (↑f : set α) r :=\nbegin\n  intros g hg,\n  by_cases hinj : function.injective g,\n  { exact (set.infinite_of_injective_forall_mem hinj (set.range_subset_iff.1 hg)\n      f.finite_to_set).elim },\n  { rw [function.injective] at hinj,\n    push_neg at hinj,\n    obtain ⟨m, n, gmgn, hne⟩ := hinj,\n    cases lt_or_gt_of_ne hne with hlt hlt;\n    { refine ⟨_, _, hlt, _⟩,\n      rw gmgn,\n      exact refl_of r _, } }\nend\n\n@[simp]\ntheorem is_pwo [partial_order α] (f : finset α) :\n  set.is_pwo (↑f : set α) :=\nf.partially_well_ordered_on\n\n@[simp]\ntheorem well_founded_on {r : α → α → Prop} [is_strict_order α r] (f : finset α) :\n  set.well_founded_on (↑f : set α) r :=\nbegin\n  rw [set.well_founded_on_iff_no_descending_seq],\n  intros g con,\n  apply set.infinite_of_injective_forall_mem g.injective (set.range_subset_iff.1 con),\n  exact f.finite_to_set,\nend\n\n@[simp]\ntheorem is_wf [partial_order α] (f : finset α) : set.is_wf (↑f : set α) :=\nf.is_pwo.is_wf\n\nend finset\n\nnamespace set\nvariables [partial_order α] {s : set α} {a : α}\n\ntheorem finite.is_pwo (h : s.finite) : s.is_pwo :=\nbegin\n  rw ← h.coe_to_finset,\n  exact h.to_finset.is_pwo,\nend\n\n@[simp]\ntheorem fintype.is_pwo [fintype α] : s.is_pwo := (finite.of_fintype s).is_pwo\n\n@[simp]\ntheorem is_pwo_empty : is_pwo (∅ : set α) :=\nfinite_empty.is_pwo\n\n@[simp]\ntheorem is_pwo_singleton (a) : is_pwo ({a} : set α) :=\n(finite_singleton a).is_pwo\n\ntheorem is_pwo.insert (a) (hs : is_pwo s) : is_pwo (insert a s) :=\nby { rw ← union_singleton, exact hs.union (is_pwo_singleton a) }\n\n/-- `is_wf.min` returns a minimal element of a nonempty well-founded set. -/\nnoncomputable def is_wf.min (hs : is_wf s) (hn : s.nonempty) : α :=\nhs.min univ (nonempty_iff_univ_nonempty.1 hn.to_subtype)\n\nlemma is_wf.min_mem (hs : is_wf s) (hn : s.nonempty) : hs.min hn ∈ s :=\n(well_founded.min hs univ (nonempty_iff_univ_nonempty.1 hn.to_subtype)).2\n\nlemma is_wf.not_lt_min (hs : is_wf s) (hn : s.nonempty) (ha : a ∈ s) : ¬ a < hs.min hn :=\nhs.not_lt_min univ (nonempty_iff_univ_nonempty.1 hn.to_subtype) (mem_univ (⟨a, ha⟩ : s))\n\n@[simp]\nlemma is_wf_min_singleton (a) {hs : is_wf ({a} : set α)} {hn : ({a} : set α).nonempty} :\n  hs.min hn = a :=\neq_of_mem_singleton (is_wf.min_mem hs hn)\n\nend set\n\n@[simp]\ntheorem finset.is_wf_sup {ι : Type*} [partial_order α] (f : finset ι) (g : ι → set α)\n  (hf : ∀ i : ι, i ∈ f → (g i).is_wf) : (f.sup g).is_wf :=\nbegin\n  classical,\n  revert hf,\n  apply f.induction_on,\n  { intro h,\n    simp [set.is_pwo_empty.is_wf], },\n  { intros s f sf hf hsf,\n    rw finset.sup_insert,\n    exact (hsf s (finset.mem_insert_self _ _)).union  (hf (λ s' s'f, hsf _\n      (finset.mem_insert_of_mem s'f))) }\nend\n\n@[simp]\ntheorem finset.is_pwo_sup {ι : Type*} [partial_order α] (f : finset ι) (g : ι → set α)\n  (hf : ∀ i : ι, i ∈ f → (g i).is_pwo) : (f.sup g).is_pwo :=\nbegin\n  classical,\n  revert hf,\n  apply f.induction_on,\n  { intro h,\n    simp [set.is_pwo_empty.is_wf], },\n  { intros s f sf hf hsf,\n    rw finset.sup_insert,\n    exact (hsf s (finset.mem_insert_self _ _)).union  (hf (λ s' s'f, hsf _\n      (finset.mem_insert_of_mem s'f))) }\nend\n\nnamespace set\nvariables [linear_order α] {s t : set α} {a : α}\n\nlemma is_wf.min_le\n  (hs : s.is_wf) (hn : s.nonempty) (ha : a ∈ s) : hs.min hn ≤ a :=\nle_of_not_lt (hs.not_lt_min hn ha)\n\nlemma is_wf.le_min_iff\n  (hs : s.is_wf) (hn : s.nonempty) :\n  a ≤ hs.min hn ↔ ∀ b, b ∈ s → a ≤ b :=\n⟨λ ha b hb, le_trans ha (hs.min_le hn hb), λ h, h _ (hs.min_mem _)⟩\n\nlemma is_wf.min_le_min_of_subset\n  {hs : s.is_wf} {hsn : s.nonempty} {ht : t.is_wf} {htn : t.nonempty} (hst : s ⊆ t) :\n  ht.min htn ≤ hs.min hsn :=\n(is_wf.le_min_iff _ _).2 (λ b hb, ht.min_le htn (hst hb))\n\nlemma is_wf.min_union (hs : s.is_wf) (hsn : s.nonempty) (ht : t.is_wf) (htn : t.nonempty) :\n  (hs.union ht).min (union_nonempty.2 (or.intro_left _ hsn)) = min (hs.min hsn) (ht.min htn) :=\nbegin\n  refine le_antisymm (le_min (is_wf.min_le_min_of_subset (subset_union_left _ _))\n      (is_wf.min_le_min_of_subset (subset_union_right _ _))) _,\n  rw min_le_iff,\n  exact ((mem_union _ _ _).1 ((hs.union ht).min_mem\n    (union_nonempty.2 (or.intro_left _ hsn)))).imp (hs.min_le _) (ht.min_le _),\nend\n\nend set\n\nnamespace set\n\nvariables {s : set α} {t : set α}\n\n@[to_additive]\ntheorem is_pwo.mul [ordered_cancel_comm_monoid α] (hs : s.is_pwo) (ht : t.is_pwo) :\n  is_pwo (s * t) :=\nbegin\n  rw ← image_mul_prod,\n  exact (is_pwo.prod hs ht).image_of_monotone (λ _ _ h, mul_le_mul' h.1 h.2),\nend\n\nvariable [linear_ordered_cancel_comm_monoid α]\n\n@[to_additive]\ntheorem is_wf.mul (hs : s.is_wf) (ht : t.is_wf) : is_wf (s * t) :=\n(hs.is_pwo.mul ht.is_pwo).is_wf\n\n@[to_additive]\ntheorem is_wf.min_mul (hs : s.is_wf) (ht : t.is_wf) (hsn : s.nonempty) (htn : t.nonempty) :\n  (hs.mul ht).min (hsn.mul htn) = hs.min hsn * ht.min htn :=\nbegin\n  refine le_antisymm (is_wf.min_le _ _ (mem_mul.2 ⟨_, _, hs.min_mem _, ht.min_mem _, rfl⟩)) _,\n  rw is_wf.le_min_iff,\n  rintros _ ⟨x, y, hx, hy, rfl⟩,\n  exact mul_le_mul' (hs.min_le _ hx) (ht.min_le _ hy),\nend\n\nend set\n\nnamespace set\nnamespace partially_well_ordered_on\n\n/-- In the context of partial well-orderings, a bad sequence is a nonincreasing sequence\n  whose range is contained in a particular set `s`. One exists if and only if `s` is not\n  partially well-ordered. -/\ndef is_bad_seq (r : α → α → Prop) (s : set α) (f : ℕ → α) : Prop :=\nset.range f ⊆ s ∧ ∀ (m n : ℕ), m < n → ¬ r (f m) (f n)\n\nlemma iff_forall_not_is_bad_seq (r : α → α → Prop) (s : set α) :\n  s.partially_well_ordered_on r ↔\n    ∀ f, ¬ is_bad_seq r s f :=\nbegin\n  rw [set.partially_well_ordered_on],\n  apply forall_congr (λ f, _),\n  simp [is_bad_seq]\nend\n\n/-- This indicates that every bad sequence `g` that agrees with `f` on the first `n`\n  terms has `rk (f n) ≤ rk (g n)`. -/\ndef is_min_bad_seq (r : α → α → Prop) (rk : α → ℕ) (s : set α) (n : ℕ) (f : ℕ → α) : Prop :=\n  ∀ g : ℕ → α, (∀ (m : ℕ), m < n → f m = g m) → rk (g n) < rk (f n) → ¬ is_bad_seq r s g\n\n/-- Given a bad sequence `f`, this constructs a bad sequence that agrees with `f` on the first `n`\n  terms and is minimal at `n`.\n-/\nnoncomputable def min_bad_seq_of_bad_seq (r : α → α → Prop) (rk : α → ℕ) (s : set α)\n  (n : ℕ) (f : ℕ → α) (hf : is_bad_seq r s f) :\n  { g : ℕ → α // (∀ (m : ℕ), m < n → f m = g m) ∧ is_bad_seq r s g ∧ is_min_bad_seq r rk s n g } :=\nbegin\n  classical,\n  have h : ∃ (k : ℕ) (g : ℕ → α), (∀ m, m < n → f m = g m) ∧ is_bad_seq r s g\n        ∧ rk (g n) = k :=\n  ⟨_, f, λ _ _, rfl, hf, rfl⟩,\n  obtain ⟨h1, h2, h3⟩ := classical.some_spec (nat.find_spec h),\n  refine ⟨classical.some (nat.find_spec h), h1, by convert h2, λ g hg1 hg2 con, _⟩,\n  refine nat.find_min h _ ⟨g, λ m mn, (h1 m mn).trans (hg1 m mn), by convert con, rfl⟩,\n  rwa ← h3,\nend\n\nlemma exists_min_bad_of_exists_bad (r : α → α → Prop) (rk : α → ℕ) (s : set α) :\n  (∃ f, is_bad_seq r s f) → ∃ f, is_bad_seq r s f ∧ ∀ n, is_min_bad_seq r rk s n f :=\nbegin\n  rintro ⟨f0, (hf0 : is_bad_seq r s f0)⟩,\n  let fs : Π (n : ℕ), { f :  ℕ → α // is_bad_seq r s f ∧ is_min_bad_seq r rk s n f },\n  { refine nat.rec _ _,\n    { exact ⟨(min_bad_seq_of_bad_seq r rk s 0 f0 hf0).1,\n        (min_bad_seq_of_bad_seq r rk s 0 f0 hf0).2.2⟩, },\n    { exact λ n fn, ⟨(min_bad_seq_of_bad_seq r rk s (n + 1) fn.1 fn.2.1).1,\n        (min_bad_seq_of_bad_seq r rk s (n + 1) fn.1 fn.2.1).2.2⟩ } },\n  have h : ∀ m n, m ≤ n → (fs m).1 m = (fs n).1 m,\n  { intros m n mn,\n    obtain ⟨k, rfl⟩ := exists_add_of_le mn,\n    clear mn,\n    induction k with k ih,\n    { refl },\n    rw [ih, ((min_bad_seq_of_bad_seq r rk s (m + k).succ (fs (m + k)).1 (fs (m + k)).2.1).2.1 m\n        (nat.lt_succ_iff.2 (nat.add_le_add_left k.zero_le m)))],\n    refl },\n  refine ⟨λ n, (fs n).1 n, ⟨set.range_subset_iff.2 (λ n, ((fs n).2).1.1 (mem_range_self n)),\n    λ m n mn, _⟩, λ n g hg1 hg2, _⟩,\n  { dsimp,\n    rw [← subtype.val_eq_coe, h m n (le_of_lt mn)],\n    convert (fs n).2.1.2 m n mn },\n  { convert (fs n).2.2 g (λ m mn, eq.trans _ (hg1 m mn)) (lt_of_lt_of_le hg2 (le_refl _)),\n    rw ← h m n (le_of_lt mn) },\nend\n\nlemma iff_not_exists_is_min_bad_seq {r : α → α → Prop} (rk : α → ℕ) {s : set α} :\n  s.partially_well_ordered_on r ↔ ¬ ∃ f, is_bad_seq r s f ∧ ∀ n, is_min_bad_seq r rk s n f :=\nbegin\n  rw [iff_forall_not_is_bad_seq, ← not_exists, not_congr],\n  split,\n  { apply exists_min_bad_of_exists_bad },\n  rintro ⟨f, hf1, hf2⟩,\n  exact ⟨f, hf1⟩,\nend\n\n/-- Higman's Lemma, which states that for any reflexive, transitive relation `r` which is\n  partially well-ordered on a set `s`, the relation `list.sublist_forall₂ r` is partially\n  well-ordered on the set of lists of elements of `s`. That relation is defined so that\n  `list.sublist_forall₂ r l₁ l₂` whenever `l₁` related pointwise by `r` to a sublist of `l₂`.  -/\nlemma partially_well_ordered_on_sublist_forall₂ (r : α → α → Prop) [is_refl α r] [is_trans α r]\n  {s : set α} (h : s.partially_well_ordered_on r) :\n  { l : list α | ∀ x, x ∈ l → x ∈ s }.partially_well_ordered_on (list.sublist_forall₂ r) :=\nbegin\n  rcases s.eq_empty_or_nonempty with rfl | ⟨as, has⟩,\n  { apply partially_well_ordered_on.mono (finset.partially_well_ordered_on {list.nil}),\n    { intros l hl,\n      rw [finset.mem_coe, finset.mem_singleton, list.eq_nil_iff_forall_not_mem],\n      exact hl, },\n    apply_instance },\n  haveI : inhabited α := ⟨as⟩,\n  rw [iff_not_exists_is_min_bad_seq (list.length)],\n  rintro ⟨f, hf1, hf2⟩,\n  have hnil : ∀ n, f n ≠ list.nil :=\n    λ n con, (hf1).2 n n.succ n.lt_succ_self (con.symm ▸ list.sublist_forall₂.nil),\n  obtain ⟨g, hg⟩ := h.exists_monotone_subseq (list.head ∘ f) _,\n  swap, { simp only [set.range_subset_iff, function.comp_apply],\n    exact λ n, hf1.1 (set.mem_range_self n) _ (list.head_mem_self (hnil n)) },\n  have hf' := hf2 (g 0) (λ n, if n < g 0 then f n else list.tail (f (g (n - g 0))))\n    (λ m hm, (if_pos hm).symm) _,\n  swap, { simp only [if_neg (lt_irrefl (g 0)), tsub_self],\n    rw [list.length_tail, ← nat.pred_eq_sub_one],\n    exact nat.pred_lt (λ con, hnil _ (list.length_eq_zero.1 con)) },\n  rw [is_bad_seq] at hf',\n  push_neg at hf',\n  obtain ⟨m, n, mn, hmn⟩ := hf' _,\n  swap, { rw set.range_subset_iff,\n    rintro n x hx,\n    split_ifs at hx with hn hn,\n    { exact hf1.1 (set.mem_range_self _) _ hx },\n    { refine hf1.1 (set.mem_range_self _) _ (list.tail_subset _ hx), } },\n  by_cases hn : n < g 0,\n  { apply hf1.2 m n mn,\n    rwa [if_pos hn, if_pos (mn.trans hn)] at hmn },\n  { obtain ⟨n', rfl⟩ := le_iff_exists_add.1 (not_lt.1 hn),\n    rw [if_neg hn, add_comm (g 0) n', add_tsub_cancel_right] at hmn,\n    split_ifs at hmn with hm hm,\n    { apply hf1.2 m (g n') (lt_of_lt_of_le hm (g.monotone n'.zero_le)),\n      exact trans hmn (list.tail_sublist_forall₂_self _) },\n    { rw [← (tsub_lt_iff_left (le_of_not_lt hm))] at mn,\n      apply hf1.2 _ _ (g.lt_iff_lt.2 mn),\n      rw [← list.cons_head_tail (hnil (g (m - g 0))), ← list.cons_head_tail (hnil (g n'))],\n      exact list.sublist_forall₂.cons (hg _ _ (le_of_lt mn)) hmn, } }\nend\n\nend partially_well_ordered_on\n\nnamespace is_pwo\n\n@[to_additive]\nlemma submonoid_closure [ordered_cancel_comm_monoid α] {s : set α} (hpos : ∀ x : α, x ∈ s → 1 ≤ x)\n  (h : s.is_pwo) : is_pwo ((submonoid.closure s) : set α) :=\nbegin\n  have hl : ((submonoid.closure s) : set α) ⊆ list.prod '' { l : list α | ∀ x, x ∈ l → x ∈ s },\n  { intros x hx,\n    rw set_like.mem_coe at hx,\n    refine submonoid.closure_induction hx (λ x hx, ⟨_, λ y hy, _, list.prod_singleton⟩)\n      ⟨_, λ y hy, (list.not_mem_nil _ hy).elim, list.prod_nil⟩ _,\n    { rwa list.mem_singleton.1 hy },\n    rintros _ _ ⟨l, hl, rfl⟩ ⟨l', hl', rfl⟩,\n    refine ⟨_, λ y hy, _, list.prod_append⟩,\n    cases list.mem_append.1 hy with hy hy,\n    { exact hl _ hy },\n    { exact hl' _ hy } },\n  apply ((h.partially_well_ordered_on_sublist_forall₂ (≤)).image_of_monotone_on _).mono hl,\n  intros l1 l2 hl1 hl2 h12,\n  obtain ⟨l, hll1, hll2⟩ := list.sublist_forall₂_iff.1 h12,\n  refine le_trans (list.rel_prod (le_refl 1) (λ a b ab c d cd, mul_le_mul' ab cd) hll1) _,\n  obtain ⟨l', hl'⟩ := hll2.exists_perm_append,\n  rw [hl'.prod_eq, list.prod_append, ← mul_one l.prod, mul_assoc, one_mul],\n  apply mul_le_mul_left',\n  have hl's := λ x hx, hl2 x (list.subset.trans (l.subset_append_right _) hl'.symm.subset hx),\n  clear hl',\n  induction l' with x1 x2 x3 x4 x5,\n  { refl },\n  rw [list.prod_cons, ← one_mul (1 : α)],\n  exact mul_le_mul' (hpos x1 (hl's x1 (list.mem_cons_self x1 x2)))\n    (x3 (λ x hx, hl's x (list.mem_cons_of_mem _ hx)))\nend\n\nend is_pwo\n\n/-- `set.mul_antidiagonal s t a` is the set of all pairs of an element in `s` and an element in `t`\n  that multiply to `a`. -/\n@[to_additive \"`set.add_antidiagonal s t a` is the set of all pairs of an element in `s`\n  and an element in `t` that add to `a`.\"]\ndef mul_antidiagonal [monoid α] (s t : set α) (a : α) : set (α × α) :=\n{ x | x.1 * x.2 = a ∧ x.1 ∈ s ∧ x.2 ∈ t }\n\nnamespace mul_antidiagonal\n\n@[simp, to_additive]\nlemma mem_mul_antidiagonal [monoid α] {s t : set α} {a : α} {x : α × α} :\n  x ∈ mul_antidiagonal s t a ↔ x.1 * x.2 = a ∧ x.1 ∈ s ∧ x.2 ∈ t := iff.refl _\n\nsection cancel_comm_monoid\nvariables [cancel_comm_monoid α] {s t : set α} {a : α}\n\n@[to_additive]\nlemma fst_eq_fst_iff_snd_eq_snd {x y : (mul_antidiagonal s t a)} :\n  (x : α × α).fst = (y : α × α).fst ↔ (x : α × α).snd = (y : α × α).snd :=\n⟨λ h, begin\n  have hx := x.2.1,\n  rw [subtype.val_eq_coe, h] at hx,\n  apply mul_left_cancel (hx.trans y.2.1.symm),\nend, λ h, begin\n  have hx := x.2.1,\n  rw [subtype.val_eq_coe, h] at hx,\n  apply mul_right_cancel (hx.trans y.2.1.symm),\nend⟩\n\n@[to_additive]\nlemma eq_of_fst_eq_fst {x y : (mul_antidiagonal s t a)}\n  (h : (x : α × α).fst = (y : α × α).fst) : x = y :=\nsubtype.ext (prod.ext h (mul_antidiagonal.fst_eq_fst_iff_snd_eq_snd.1 h))\n\n@[to_additive]\nlemma eq_of_snd_eq_snd {x y : (mul_antidiagonal s t a)}\n  (h : (x : α × α).snd = (y : α × α).snd) : x = y :=\nsubtype.ext (prod.ext (mul_antidiagonal.fst_eq_fst_iff_snd_eq_snd.2 h) h)\n\nend cancel_comm_monoid\n\nsection ordered_cancel_comm_monoid\nvariables [ordered_cancel_comm_monoid α] (s t : set α) (a : α)\n\n@[to_additive]\nlemma eq_of_fst_le_fst_of_snd_le_snd {x y : (mul_antidiagonal s t a)}\n  (h1 : (x : α × α).fst ≤ (y : α × α).fst) (h2 : (x : α × α).snd ≤ (y : α × α).snd ) :\n  x = y :=\nbegin\n  apply eq_of_fst_eq_fst,\n  cases eq_or_lt_of_le h1 with heq hlt,\n  { exact heq },\n  exfalso,\n  exact ne_of_lt (mul_lt_mul_of_lt_of_le hlt h2)\n    ((mem_mul_antidiagonal.1 x.2).1.trans (mem_mul_antidiagonal.1 y.2).1.symm)\nend\n\nvariables {s} {t}\n\n@[to_additive]\ntheorem finite_of_is_pwo (hs : s.is_pwo) (ht : t.is_pwo) (a) :\n  (mul_antidiagonal s t a).finite :=\nbegin\n  by_contra h,\n  rw [← set.infinite] at h,\n  have h1 : (mul_antidiagonal s t a).partially_well_ordered_on (prod.fst ⁻¹'o (≤)),\n  { intros f hf,\n    refine hs (prod.fst ∘ f) _,\n    rw range_comp,\n    rintros _ ⟨⟨x, y⟩, hxy, rfl⟩,\n    exact (mem_mul_antidiagonal.1 (hf hxy)).2.1 },\n  have h2 : (mul_antidiagonal s t a).partially_well_ordered_on (prod.snd ⁻¹'o (≤)),\n  { intros f hf,\n    refine ht (prod.snd ∘ f) _,\n    rw range_comp,\n    rintros _ ⟨⟨x, y⟩, hxy, rfl⟩,\n    exact (mem_mul_antidiagonal.1 (hf hxy)).2.2 },\n  obtain ⟨g, hg⟩ := h1.exists_monotone_subseq (λ x, h.nat_embedding _ x) _,\n  swap, { rintro _ ⟨k, rfl⟩,\n    exact ((infinite.nat_embedding (s.mul_antidiagonal t a) h) _).2 },\n  obtain ⟨m, n, mn, h2'⟩ := h2 (λ x, (h.nat_embedding _) (g x)) _,\n  swap, { rintro _ ⟨k, rfl⟩,\n    exact ((infinite.nat_embedding (s.mul_antidiagonal t a) h) _).2, },\n  apply ne_of_lt mn (g.injective ((h.nat_embedding _).injective _)),\n  exact eq_of_fst_le_fst_of_snd_le_snd _ _ _ (hg _ _ (le_of_lt mn)) h2',\nend\n\nend ordered_cancel_comm_monoid\n\n@[to_additive]\ntheorem finite_of_is_wf [linear_ordered_cancel_comm_monoid α] {s t : set α}\n  (hs : s.is_wf) (ht : t.is_wf) (a) :\n  (mul_antidiagonal s t a).finite :=\nfinite_of_is_pwo hs.is_pwo ht.is_pwo a\n\nend mul_antidiagonal\nend set\n\nnamespace finset\n\nvariables [ordered_cancel_comm_monoid α]\nvariables {s t : set α} (hs : s.is_pwo) (ht : t.is_pwo) (a : α)\n\n/-- `finset.mul_antidiagonal_of_is_wf hs ht a` is the set of all pairs of an element in\n  `s` and an element in `t` that multiply to `a`, but its construction requires proofs\n  `hs` and `ht` that `s` and `t` are well-ordered. -/\n@[to_additive \"`finset.add_antidiagonal_of_is_wf hs ht a` is the set of all pairs of an element in\n  `s` and an element in `t` that add to `a`, but its construction requires proofs\n  `hs` and `ht` that `s` and `t` are well-ordered.\"]\nnoncomputable def mul_antidiagonal : finset (α × α) :=\n(set.mul_antidiagonal.finite_of_is_pwo hs ht a).to_finset\n\nvariables {hs} {ht} {u : set α} {hu : u.is_pwo} {a} {x : α × α}\n\n@[simp, to_additive]\nlemma mem_mul_antidiagonal :\n  x ∈ mul_antidiagonal hs ht a ↔ x.1 * x.2 = a ∧ x.1 ∈ s ∧ x.2 ∈ t :=\nby simp [mul_antidiagonal]\n\n@[to_additive]\nlemma mul_antidiagonal_mono_left (hus : u ⊆ s) :\n  (finset.mul_antidiagonal hu ht a) ⊆ (finset.mul_antidiagonal hs ht a) :=\nλ x hx, begin\n  rw mem_mul_antidiagonal at *,\n  exact ⟨hx.1, hus hx.2.1, hx.2.2⟩,\nend\n\n@[to_additive]\nlemma mul_antidiagonal_mono_right (hut : u ⊆ t) :\n  (finset.mul_antidiagonal hs hu a) ⊆ (finset.mul_antidiagonal hs ht a) :=\nλ x hx, begin\n  rw mem_mul_antidiagonal at *,\n  exact ⟨hx.1, hx.2.1, hut hx.2.2⟩,\nend\n\n@[to_additive]\nlemma support_mul_antidiagonal_subset_mul :\n  { a : α | (mul_antidiagonal hs ht a).nonempty } ⊆ s * t :=\n(λ x ⟨⟨a1, a2⟩, ha⟩, begin\n  obtain ⟨hmul, h1, h2⟩ := mem_mul_antidiagonal.1 ha,\n  exact ⟨a1, a2, h1, h2, hmul⟩,\nend)\n\n@[to_additive]\ntheorem is_pwo_support_mul_antidiagonal :\n  { a : α | (mul_antidiagonal hs ht a).nonempty }.is_pwo :=\n(hs.mul ht).mono support_mul_antidiagonal_subset_mul\n\n@[to_additive]\ntheorem mul_antidiagonal_min_mul_min {α} [linear_ordered_cancel_comm_monoid α] {s t : set α}\n  (hs : s.is_wf) (ht : t.is_wf)\n  (hns : s.nonempty) (hnt : t.nonempty) :\n  mul_antidiagonal hs.is_pwo ht.is_pwo ((hs.min hns) * (ht.min hnt)) =\n    {(hs.min hns, ht.min hnt)} :=\nbegin\n  ext ⟨a1, a2⟩,\n  rw [mem_mul_antidiagonal, finset.mem_singleton, prod.ext_iff],\n  split,\n  { rintro ⟨hast, has, hat⟩,\n    cases eq_or_lt_of_le (hs.min_le hns has) with heq hlt,\n    { refine ⟨heq.symm, _⟩,\n      rw heq at hast,\n      exact mul_left_cancel hast },\n    { contrapose hast,\n      exact ne_of_gt (mul_lt_mul_of_lt_of_le hlt (ht.min_le hnt hat)) } },\n  { rintro ⟨ha1, ha2⟩,\n    rw [ha1, ha2],\n    exact ⟨rfl, hs.min_mem _, ht.min_mem _⟩ }\nend\n\nend finset\n\nlemma well_founded.is_wf [has_lt α] (h : well_founded ((<) : α → α → Prop)) (s : set α) :\n  s.is_wf :=\n(set.is_wf_univ_iff.2 h).mono (set.subset_univ s)\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/order/well_founded_set.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.47474494814831353}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport algebra.big_operators.order\nimport algebra.big_operators.ring\nimport data.rat.cast\n\n/-!\n# The Oxford Invariants Puzzle Challenges - Summer 2021, Week 3, Problem 1\n\n## Original statement\n\nLet `n ≥ 3`, `a₁, ..., aₙ` be strictly positive integers such that `aᵢ ∣ aᵢ₋₁ + aᵢ₊₁` for\n`i = 2, ..., n - 1`. Show that $\\sum_{i=1}^{n-1}\\dfrac{a_0a_n}{a_ia_{i+1}} ∈ \\mathbb N$.\n\n## Comments\n\nMathlib is based on type theory, so saying that a rational is a natural doesn't make sense. Instead,\nwe ask that there exists `b : ℕ` whose cast to `α` is the sum we want.\n\nIn mathlib, `ℕ` starts at `0`. To make the indexing cleaner, we use `a₀, ..., aₙ₋₁` instead of\n`a₁, ..., aₙ`. Similarly, it's nicer to not use substraction of naturals, so we replace\n`aᵢ ∣ aᵢ₋₁ + aᵢ₊₁` by `aᵢ₊₁ ∣ aᵢ + aᵢ₊₂`.\n\nWe don't actually have to work in `ℚ` or `ℝ`. We can be even more general by stating the result for\nany linearly ordered field.\n\nInstead of having `n` naturals, we use a function `a : ℕ → ℕ`.\n\nIn the proof itself, we replace `n : ℕ, 1 ≤ n` by `n + 1`.\n\nThe statement is actually true for `n = 0, 1` (`n = 1, 2` before the reindexing) as the sum is\nsimply `0` and `1` respectively. So the version we prove is slightly more general.\n\nOverall, the indexing is a bit of a mess to understand. But, trust Lean, it works.\n\n## Formalised statement\n\nLet `n : ℕ`, `a : ℕ → ℕ`, `∀ i ≤ n, 0 < a i`, `∀ i, i + 2 ≤ n → aᵢ₊₁ ∣ aᵢ + aᵢ₊₂` (read `→` as\n\"implies\"). Then there exists `b : ℕ` such that `b` as an element of any linearly ordered field\nequals $\\sum_{i=0}^{n-1} (a_0 a_n) / (a_i a_{i+1})$.\n\n## Proof outline\n\nThe case `n = 0` is trivial.\n\nFor `n + 1`, we prove the result by induction but by adding `aₙ₊₁ ∣ aₙ * b - a₀` to the induction\nhypothesis, where `b` is the previous sum, $\\sum_{i=0}^{n-1} (a_0 a_n) / (a_i a_{i+1})$, as a\nnatural.\n* Base case:\n  * $\\sum_{i=0}^0 (a_0 a_{0+1}) / (a_0 a_{0+1})$ is a natural:\n    $\\sum_{i=0}^0 (a_0 a_{0+1}) / (a_0 a_{0+1}) = (a_0 a_1) / (a_0 a_1) = 1$.\n  * Divisibility condition:\n    `a₀ * 1 - a₀ = 0` is clearly divisible by `a₁`.\n* Induction step:\n  * $\\sum_{i=0}^n (a_0 a_{n+1}) / (a_i a_{i+1})$ is a natural:\n    $$\\sum_{i=0}^{n+1} (a_0 a_{n+2}) / (a_i a_{i+1})\n      = \\sum_{i=0}^n\\ (a_0 a_{n+2}) / (a_i a_{i+1}) + (a_0 a_{n+2}) / (a_{n+1} a_{n+2})\n      = a_{n+2} / a_{n+1} × \\sum_{i=0}^n (a_0 a_{n+1}) / (a_i a_{i+1}) + a_0 / a_{n+1}\n      = a_{n+2} / a_{n+1} × b + a_0 / a_{n+1}\n      = (a_n + a_{n+2}) / a_{n+1} × b - (a_n b - a_0)(a_{n+1})$$\n    which is a natural because `(aₙ + aₙ₊₂)/aₙ₊₁`, `b` and `(aₙ * b - a₀)/aₙ₊₁` are (plus an\n    annoying inequality, or the fact that the original sum is positive because its terms are).\n  * Divisibility condition:\n    `aₙ₊₁ * ((aₙ + aₙ₊₂)/aₙ₊₁ * b - (aₙ * b - a₀)/aₙ₊₁) - a₀ = aₙ₊₁aₙ₊₂b` is divisible by `aₙ₊₂`.\n-/\n\nopen_locale big_operators\n\nvariables {α : Type*} [linear_ordered_field α]\n\ntheorem week3_p1 (n : ℕ) (a : ℕ → ℕ) (a_pos : ∀ i ≤ n, 0 < a i)\n  (ha : ∀ i, i + 2 ≤ n → a (i + 1) ∣ a i + a (i + 2)) :\n  ∃ b : ℕ, (b : α) = ∑ i in finset.range n, (a 0 * a n)/(a i * a (i + 1)) :=\nbegin\n  -- Treat separately `n = 0` and `n ≥ 1`\n  cases n,\n  /- Case `n = 0`\n  The sum is trivially equal to `0` -/\n  { exact ⟨0, by rw [nat.cast_zero, finset.sum_range_zero]⟩ }, -- `⟨Claim it, Prove it⟩`\n  /- Case `n ≥ 1`. We replace `n` by `n + 1` everywhere to make this inequality explicit\n  Set up the stronger induction hypothesis -/\n  suffices h : ∃ b : ℕ, (b : α) = ∑ i in finset.range (n + 1), (a 0 * a (n + 1))/(a i * a (i + 1))\n           ∧ a (n + 1) ∣ a n * b - a 0,\n  { obtain ⟨b, hb, -⟩ := h,\n    exact ⟨b, hb⟩ },\n  simp_rw ←@nat.cast_pos α at a_pos,\n  /- Declare the induction\n  `ih` will be the induction hypothesis -/\n  induction n with n ih,\n  /- Base case\n  Claim that the sum equals `1`-/\n  { refine ⟨1, _, _⟩,\n    -- Check that this indeed equals the sum\n    { rw [nat.cast_one, finset.sum_range_one, div_self],\n      exact (mul_pos (a_pos 0 (nat.zero_le _)) (a_pos 1 (nat.zero_lt_succ _))).ne' },\n    -- Check the divisibility condition\n    { rw [mul_one, tsub_self],\n      exact dvd_zero _ } },\n  /- Induction step\n  `b` is the value of the previous sum as a natural, `hb` is the proof that it is indeed the value,\n  and `han` is the divisibility condition -/\n  obtain ⟨b, hb, han⟩ := ih (λ i hi, ha i $ nat.le_succ_of_le hi)\n    (λ i hi, a_pos i $ nat.le_succ_of_le hi),\n  specialize ha n le_rfl,\n  have ha₀ : a 0 ≤ a n * b, -- Needing this is an artifact of `ℕ`-substraction.\n  { rw [←@nat.cast_le α, nat.cast_mul, hb, ←div_le_iff' (a_pos _ $ n.le_succ.trans $ nat.le_succ _),\n      ←mul_div_mul_right _ _ (a_pos _ $ nat.le_succ _).ne'],\n    suffices h : ∀ i, i ∈ finset.range (n + 1) → 0 ≤ (a 0 : α) * a (n + 1) / (a i * a (i + 1)),\n    { exact finset.single_le_sum h (finset.self_mem_range_succ n) },\n    refine (λ i _, div_nonneg _ _); refine mul_nonneg _ _; exact nat.cast_nonneg _ },\n  -- Claim that the sum equals `(aₙ + aₙ₊₂)/aₙ₊₁ * b - (aₙ * b - a₀)/aₙ₊₁`\n  refine ⟨(a n + a (n + 2))/ a (n + 1) * b - (a n * b - a 0) / a (n + 1), _, _⟩,\n  -- Check that this indeed equals the sum\n  { calc\n      (((a n + a (n + 2)) / a (n + 1) * b - (a n * b - a 0) / a (n + 1) : ℕ) : α)\n        = (a n + a (n + 2)) / a (n + 1) * b - (a n * b - a 0) / a (n + 1) : begin\n          norm_cast,\n          rw nat.cast_sub (nat.div_le_of_le_mul _),\n          rw [←mul_assoc, nat.mul_div_cancel' ha, add_mul],\n          exact tsub_le_self.trans (nat.le_add_right _ _),\n        end\n    ... = a (n + 2) / a (n + 1) * b + (a 0 * a (n + 2)) / (a (n + 1) * a (n + 2))\n        : by rw [add_div, add_mul, sub_div, mul_div_right_comm, add_sub_sub_cancel,\n            mul_div_mul_right _ _ (a_pos _ le_rfl).ne']\n    ... = ∑ (i : ℕ) in finset.range (n + 2), a 0 * a (n + 2) / (a i * a (i + 1))\n        : begin\n          rw [finset.sum_range_succ, hb, finset.mul_sum],\n          congr, ext i,\n          rw [←mul_div_assoc, ←mul_div_right_comm, mul_div_assoc, mul_div_cancel _\n            (a_pos _ $ nat.le_succ _).ne', mul_comm],\n        end },\n  -- Check the divisibility condition\n  { rw [mul_tsub, ← mul_assoc, nat.mul_div_cancel' ha, add_mul,\n      nat.mul_div_cancel' han, add_tsub_tsub_cancel ha₀, add_tsub_cancel_right],\n    exact dvd_mul_right _ _ }\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/archive/oxford_invariants/2021summer/week3_p1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6548947357776796, "lm_q1q2_score": 0.4747137357747501}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.fintype.card\nimport data.finset.sum\nimport logic.embedding.set\n\n/-!\n## Instances\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe provide the `fintype` instance for the sum of two fintypes.\n-/\n\nuniverses u v\n\nvariables {α β : Type*}\n\nopen finset\n\ninstance (α : Type u) (β : Type v) [fintype α] [fintype β] : fintype (α ⊕ β) :=\n{ elems := univ.disj_sum univ,\n  complete := by rintro (_ | _); simp }\n\n@[simp] lemma finset.univ_disj_sum_univ {α β : Type*} [fintype α] [fintype β] :\n  univ.disj_sum univ = (univ : finset (α ⊕ β)) :=\nrfl\n\n@[simp] theorem fintype.card_sum [fintype α] [fintype β] :\n  fintype.card (α ⊕ β) = fintype.card α + fintype.card β :=\ncard_disj_sum _ _\n\n/-- If the subtype of all-but-one elements is a `fintype` then the type itself is a `fintype`. -/\ndef fintype_of_fintype_ne (a : α) (h : fintype {b // b ≠ a}) : fintype α :=\nfintype.of_bijective (sum.elim (coe : {b // b = a} → α) (coe : {b // b ≠ a} → α)) $\n  by { classical, exact (equiv.sum_compl (= a)).bijective }\n\nlemma image_subtype_ne_univ_eq_image_erase [fintype α] [decidable_eq β] (k : β) (b : α → β) :\n  image (λ i : {a // b a ≠ k}, b ↑i) univ = (image b univ).erase k :=\nbegin\n  apply subset_antisymm,\n  { rw image_subset_iff,\n    intros i _,\n    apply mem_erase_of_ne_of_mem i.2 (mem_image_of_mem _ (mem_univ _)) },\n  { intros i hi,\n    rw mem_image,\n    rcases mem_image.1 (erase_subset _ _ hi) with ⟨a, _, ha⟩,\n    subst ha,\n    exact ⟨⟨a, ne_of_mem_erase hi⟩, mem_univ _, rfl⟩ }\nend\n\nlemma image_subtype_univ_ssubset_image_univ [fintype α] [decidable_eq β] (k : β) (b : α → β)\n  (hk : k ∈ image b univ) (p : β → Prop) [decidable_pred p] (hp : ¬ p k) :\n  image (λ i : {a // p (b a)}, b ↑i) univ ⊂ image b univ :=\nbegin\n  split,\n  { intros x hx,\n    rcases mem_image.1 hx with ⟨y, _, hy⟩,\n    exact hy ▸ mem_image_of_mem b (mem_univ y) },\n  { intros h,\n    rw mem_image at hk,\n    rcases hk with ⟨k', _, hk'⟩, subst hk',\n    have := h (mem_image_of_mem b (mem_univ k')),\n    rw mem_image at this,\n    rcases this with ⟨j, hj, hj'⟩,\n    exact hp (hj' ▸ j.2) }\nend\n\n/-- Any injection from a finset `s` in a fintype `α` to a finset `t` of the same cardinality as `α`\ncan be extended to a bijection between `α` and `t`. -/\nlemma finset.exists_equiv_extend_of_card_eq [fintype α] [decidable_eq β] {t : finset β}\n  (hαt : fintype.card α = t.card) {s : finset α} {f : α → β} (hfst : s.image f ⊆ t)\n  (hfs : set.inj_on f s) :\n  ∃ g : α ≃ t, ∀ i ∈ s, (g i : β) = f i :=\nbegin\n  classical,\n  induction s using finset.induction with a s has H generalizing f,\n  { obtain ⟨e⟩ : nonempty (α ≃ ↥t) := by rwa [← fintype.card_eq, fintype.card_coe],\n    use e,\n    simp },\n  have hfst' : finset.image f s ⊆ t := (finset.image_mono _ (s.subset_insert a)).trans hfst,\n  have hfs' : set.inj_on f s := hfs.mono (s.subset_insert a),\n  obtain ⟨g', hg'⟩ := H hfst' hfs',\n  have hfat : f a ∈ t := hfst (mem_image_of_mem _ (s.mem_insert_self a)),\n  use g'.trans (equiv.swap (⟨f a, hfat⟩ : t) (g' a)),\n  simp_rw mem_insert,\n  rintro i (rfl | hi),\n  { simp },\n  rw [equiv.trans_apply, equiv.swap_apply_of_ne_of_ne, hg' _ hi],\n  { exact ne_of_apply_ne subtype.val (ne_of_eq_of_ne (hg' _ hi) $\n    hfs.ne (subset_insert _ _ hi) (mem_insert_self _ _) $ ne_of_mem_of_not_mem hi has) },\n  { exact g'.injective.ne (ne_of_mem_of_not_mem hi has) },\nend\n\n/-- Any injection from a set `s` in a fintype `α` to a finset `t` of the same cardinality as `α`\ncan be extended to a bijection between `α` and `t`. -/\nlemma set.maps_to.exists_equiv_extend_of_card_eq [fintype α] {t : finset β}\n  (hαt : fintype.card α = t.card) {s : set α} {f : α → β} (hfst : s.maps_to f t)\n  (hfs : set.inj_on f s) :\n  ∃ g : α ≃ t, ∀ i ∈ s, (g i : β) = f i :=\nbegin\n  classical,\n  let s' : finset α := s.to_finset,\n  have hfst' : s'.image f ⊆ t := by simpa [← finset.coe_subset] using hfst,\n  have hfs' : set.inj_on f s' := by simpa using hfs,\n  obtain ⟨g, hg⟩ := finset.exists_equiv_extend_of_card_eq hαt hfst' hfs',\n  refine ⟨g, λ i hi, _⟩,\n  apply hg,\n  simpa using hi,\nend\n\nlemma fintype.card_subtype_or (p q : α → Prop)\n  [fintype {x // p x}] [fintype {x // q x}] [fintype {x // p x ∨ q x}] :\n  fintype.card {x // p x ∨ q x} ≤ fintype.card {x // p x} + fintype.card {x // q x} :=\nbegin\n  classical,\n  convert fintype.card_le_of_embedding (subtype_or_left_embedding p q),\n  rw fintype.card_sum\nend\n\nlemma fintype.card_subtype_or_disjoint (p q : α → Prop) (h : disjoint p q)\n  [fintype {x // p x}] [fintype {x // q x}] [fintype {x // p x ∨ q x}] :\n  fintype.card {x // p x ∨ q x} = fintype.card {x // p x} + fintype.card {x // q x} :=\nbegin\n  classical,\n  convert fintype.card_congr (subtype_or_equiv p q h),\n  simp\nend\n\nsection\nopen_locale classical\n\n@[simp] lemma infinite_sum : infinite (α ⊕ β) ↔ infinite α ∨ infinite β :=\nbegin\n  refine ⟨λ H, _, λ H, H.elim (@sum.infinite_of_left α β) (@sum.infinite_of_right α β)⟩,\n  contrapose! H, haveI := fintype_of_not_infinite H.1, haveI := fintype_of_not_infinite H.2,\n  exact infinite.false\nend\n\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/fintype/sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.47471371921509636}}
{"text": "import Mathlib\nimport RSACryptosystems\n\ntheorem mod_pow_eq :  mod_pow a b n = (a ^ b) % n :=\n  by\n  rw[mod_pow]\n  have h' : n > 1 := by\n    sorry\n  by_cases h : b = 0\n  · simp[h, h', Nat.mod_eq_of_lt]\n  · simp[h, h']\n    sorry\n\n#check Commute.add_pow\n#check Nat.Prime.dvd_choose_self\n\ntheorem freshman's_dream (a b : ℕ) (hp : Nat.Prime p) : ((a + b) ^ p) % p = (a ^ p + b ^ p)%p := by\n  rw[← Nat.ModEq]\n  rw[add_pow]\n  rw[Nat.ModEq.comm]\n  have h1 : {0, p} ⊆  Finset.range (p + 1) := by \n    rw[Finset.subset_iff]\n    simp \n  rw[←Finset.sum_sdiff h1 ]\n  have h2 : 0 ≠ p := by \n    sorry\n  rw[Finset.sum_pair h2] \n  simp \n  rw[Nat.modEq_iff_dvd']\n  rw[Nat.sub_add_eq,← Nat.add_assoc]\n  simp[← Nat.add_le_add_left]\n  sorry\n\n\ntheorem fermat_little_theorem (p : ℕ) (hp : Nat.Prime p) (a : ℕ) : a ^ (p - 1) % p = 1 := by\n  sorry\n\ntheorem ende : (decryption e n (encryption e n m)) = m :=\n  by\n  sorry\n", "meta": {"author": "Shraze97", "repo": "RSA-cryptosystems", "sha": "026d4556ecf9b71d9aa06cfb4e2fd4be46c1a955", "save_path": "github-repos/lean/Shraze97-RSA-cryptosystems", "path": "github-repos/lean/Shraze97-RSA-cryptosystems/RSA-cryptosystems-026d4556ecf9b71d9aa06cfb4e2fd4be46c1a955/utils/Conditions_to_satisfy.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711794579723, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4745618538984628}}
{"text": "import ..mcrl2_mrg.mcrl2_mrg\n\nopen mcrl2\n\nvariable {α : Type}\nvariable [comm_semigroup_with_zero α]\n\n/- The relation used to prove congruence of encapsulation-/\ninductive R_encap {x₁ y₁ : mcrl2 α} {A : set α} (R : mcrl2 α → mcrl2 α → Prop) :\nmcrl2 α → mcrl2 α → Prop\n| R {x y} (h : R x y) : R_encap x y\n| basel : R_encap (encap A x₁) (encap A y₁)\n| baser : R_encap (encap A y₁) (encap A x₁)\n| step {x y} (h : R x y) : R_encap (encap A x) (encap A y)\n\ntheorem R_encap.symm {x₁ y₁ A R} (R_symm : symmetric R) :\nsymmetric (@R_encap α _ x₁ y₁ A R) :=\nbegin\n  intros x y h,\n  cases h,\n  { apply R_encap.R,\n    exact R_symm h_h},\n  { exact R_encap.baser},\n  { exact R_encap.basel},\n  { exact R_encap.step (R_symm h_h)}\nend\n\ntheorem bisim.encap {x₁ x₂ : mcrl2 α} {A} (h : x₁ ≈ x₂) : \n(encap A x₁) ≈ (encap A x₂) :=\nbegin\n  rcases h with ⟨R, Rx, R_bisim⟩,\n  apply exists.intro (R_encap R),\n  apply and.intro R_encap.basel,\n  apply and.intro,\n  { intros x y x' a h₁ h₂, \n    cases h₁,\n    { have h : ∃y', transition y a y' ∧ option.rel R x' y',\n      by exact bisim_lift R_bisim h₁_h h₂,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro w,\n      apply and.intro haw,\n      apply option.rel.mono,\n      { intros a b, exact R_encap.R},\n      { assumption}},\n    { cases h₂,\n      have h : ∃y', transition x₂ a y' ∧ option.rel R h₂_y y',\n      by exact bisim_lift R_bisim Rx h₂_h₂,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro (encap A <$> w), \n      apply and.intro,\n      { apply transition.encap_pass; assumption},\n      { cases hRw,\n        { apply option.rel.some,\n          apply R_encap.step,\n          assumption},\n        { exact option.rel.none}}},\n    { cases h₂,\n      have h : ∃y', transition x₁ a y' ∧ option.rel R h₂_y y',\n      by exact bisim_lift R_bisim (R_bisim.right Rx) h₂_h₂,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro (encap A <$> w), \n      apply and.intro,\n      { apply transition.encap_pass; assumption},\n      { cases hRw,\n        { apply option.rel.some,\n          apply R_encap.step,\n          assumption},\n        { exact option.rel.none}}},\n    { cases h₂,\n      have h : ∃y', transition h₁_y a y' ∧ option.rel R h₂_y y',\n      by exact bisim_lift R_bisim h₁_h h₂_h₂,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro (encap A <$> w), \n      apply and.intro,\n      { apply transition.encap_pass; assumption},\n      { cases hRw,\n        { apply option.rel.some,\n          apply R_encap.step,\n          assumption},\n        { exact option.rel.none}}}},\n  { exact R_encap.symm R_bisim.right} \nend", "meta": {"author": "Wolfb34", "repo": "mucrl2lean_public", "sha": "0d687d0ad00a6f276f1c1e9acbfc3dd4c0b2ce39", "save_path": "github-repos/lean/Wolfb34-mucrl2lean_public", "path": "github-repos/lean/Wolfb34-mucrl2lean_public/mucrl2lean_public-0d687d0ad00a6f276f1c1e9acbfc3dd4c0b2ce39/Lean/mcrl2_encap/encap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4745568639716012}}
{"text": "import o_minimal.o_minimal\nimport data.set.disjointed\nimport data.setoid.partition\n\nnamespace o_minimal\n\nvariables {R : Type*} [DUNLO R]\nvariables (S : struc R) [definable_constants S] [is_definable_le S R]\n\nnamespace struc\n\ndef cell : Π {n}, set (finvec n R) → Prop\n| 0     s := s = set.univ\n| (n+1) s := ∃ (s₀ : set (finvec n R)) (h : cell s₀),\n                  s = {x | x.init ∈ s₀}\n              ∨\n              (∃ (f : finvec n R → R) (hf : def_fun S f),\n                  s = {x | x.init ∈ s₀ ∧ x (fin.last n) = f x.init}\n                ∨ s = {x | x.init ∈ s₀ ∧ x (fin.last n) ∈ set.Ioi (f x.init)}\n                ∨ s = {x | x.init ∈ s₀ ∧ x (fin.last n) ∈ set.Iio (f x.init)})\n              ∨\n              (∃ (f g : finvec n R → R) (hf : def_fun S f) (hg : def_fun S g),\n                (∀ x₀ ∈ s₀, f x₀ < g x₀) ∧\n                  s = {x | x.init ∈ s₀ ∧ x (fin.last n) ∈ set.Ioo (f x.init) (g x.init)})\n\nlemma init_definable (n : ℕ) :\n  def_fun S (finvec.init : finvec (n+1) R → finvec n R) :=\nbegin\n  sorry\nend\n\nlemma cell.definable : ∀ {n} (s : set (finvec n R)) (hs : S.cell s), def_set S s\n| 0     s hs := by { cases hs, apply def_set_univ }\n| (n+1) s hs :=\nbegin\n  obtain ⟨s₀, hs₀, H|H|H⟩ := hs,\n  { cases H,\n    show def_set S (finvec.init ⁻¹' s₀), sorry },\n  sorry,\n  sorry,\nend\n\ndef decomposition : Π {n} (C : set (set (finvec n R))), Prop\n| 0     C := C = {set.univ}\n| (n+1) C := C.finite ∧ setoid.is_partition C\n            ∧ ∀ s ∈ C, S.cell s\n            ∧ decomposition ((set.image finvec.init) '' C)\n\nend struc\n\nend o_minimal\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/omin/cells.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079208, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.474543412130051}}
{"text": "\n/- Formalization of floating-point numbers, using the Flocq library. -/\n\nimport .integers .lib .flocq .archi\n\nnamespace floats\nopen integers flocq word\n\n/- Boolean-valued comparisons -/\n\ndef cmp_of_comparison : comparison → option ordering → bool\n| Ceq (some ordering.eq) := tt\n| Ceq _                  := ff\n| Cne (some ordering.eq) := ff\n| Cne _                  := tt\n| Clt (some ordering.lt) := tt\n| Clt _                  := ff\n| Cle (some ordering.lt) := tt\n| Cle (some ordering.eq) := tt\n| Cle _                  := ff\n| Cgt (some ordering.gt) := tt\n| Cgt _                  := ff\n| Cge (some ordering.gt) := tt\n| Cge (some ordering.eq) := tt\n| Cge _                  := ff\n\nlemma cmp_of_comparison_swap (c x) :\n  cmp_of_comparison (swap_comparison c) x =\n  cmp_of_comparison c (ordering.swap <$> x) := sorry'\n\nlemma cmp_of_comparison_ne_eq (x) :\n  cmp_of_comparison Cne x = bnot (cmp_of_comparison Ceq x) := sorry'\n\nlemma cmp_of_comparison_lt_not_eq (x) :\n  cmp_of_comparison Clt x → ¬ cmp_of_comparison Ceq x := sorry'\n\nlemma cmp_of_comparison_le_lt_eq (x) :\n  cmp_of_comparison Cle x = cmp_of_comparison Clt x || cmp_of_comparison Ceq x := sorry'\n\nlemma cmp_of_comparison_gt_not_eq (x) :\n  cmp_of_comparison Cgt x → ¬ cmp_of_comparison Ceq x := sorry'\n\nlemma cmp_of_comparison_ge_gt_eq (x) :\n  cmp_of_comparison Cge x = cmp_of_comparison Cgt x || cmp_of_comparison Ceq x := sorry'\n\nlemma cmp_of_comparison_lt_not_gt (x) :\n  cmp_of_comparison Clt x → ¬ cmp_of_comparison Cgt x := sorry'\n\ndef float : Type := sorry' /- the type of IEE754 double-precision FP numbers -/\ndef float32 : Type := sorry' /- the type of IEE754 single-precision FP numbers -/\n\n/- * Double-precision FP numbers -/\n\nnamespace float\n\n/- ** NaN payload manipulations -/\n\n/- The following definitions are not part of the IEEE754 standard but\n    apply to all architectures supported by CompCert. -/\n\n/- Transform a Nan payload to a quiet Nan payload. -/\n\ndef transform_quiet_pl (pl : nan_pl 53) : nan_pl 53 :=\nword.or pl (word.repr (2^22))\n\nlemma transform_quiet_pl_idempotent (pl) :\n  transform_quiet_pl (transform_quiet_pl pl) = transform_quiet_pl pl := sorry'\n\n/- Nan payload operations for single <-> double conversions. -/\n\ndef expand_pl (pl : nan_pl 24) : nan_pl 53 :=\nword.shl (ucoe pl) (repr 29)\n\ndef of_single_pl (s : bool) (pl : nan_pl 24) : bool × nan_pl 53 :=\n(s, if archi.float_of_single_preserves_sNaN\n    then expand_pl pl\n    else transform_quiet_pl (expand_pl pl))\n\ndef reduce_pl (pl : nan_pl 53) : nan_pl 24 :=\nucoe (word.shr pl (repr 29))\n\ndef to_single_pl (s : bool) (pl : nan_pl 53) : bool × nan_pl 24 :=\n(s, reduce_pl (transform_quiet_pl pl))\n\n/- NaN payload operations for opposite and absolute value. -/\n\ndef neg_pl (s : bool) (pl : nan_pl 53) := (bnot s, pl)\ndef abs_pl (s : bool) (pl : nan_pl 53) := (ff, pl)\n\n/- The NaN payload operations for two-argument arithmetic operations\n   are not part of the IEEE754 standard, but all architectures of\n   Compcert share a similar NaN behavior, parameterized by:\n- a \"default\" payload which occurs when an operation generates a NaN from\n  non-NaN arguments;\n- a choice function determining which of the payload arguments to choose,\n  when an operation is given two NaN arguments. -/\n\ndef binop_pl (x y : binary64) : bool × nan_pl 53 := sorry'\n\n/- ** Operations over double-precision floats -/\n\ndef zero : float := sorry' /- the float [+0.0] -/\n\ninstance : has_zero float := ⟨zero⟩\n\ninstance eq_dec : decidable_eq float := sorry'\n\n/- Arithmetic operations -/\n\nprotected def neg : float → float := sorry' /- opposite (change sign) -/\ndef abs : float → float := sorry' /- absolute value (set sign to [+]) -/\nprotected def add : float → float → float := sorry' /- addition -/\nprotected def sub : float → float → float := sorry' /- subtraction -/\nprotected def mul : float → float → float := sorry' /- multiplication -/\nprotected def div : float → float → float := sorry' /- division -/\ndef cmp (c:comparison) (f1 f2 : float) : bool := /- comparison -/\ncmp_of_comparison c sorry'\n\ninstance : has_add float := ⟨float.add⟩\ninstance : has_neg float := ⟨float.neg⟩\ninstance : has_sub float := ⟨float.sub⟩\ninstance : has_mul float := ⟨float.mul⟩\ninstance : has_div float := ⟨float.div⟩\n\n/- Conversions -/\n\ndef of_single : float32 → float := sorry'\ndef to_single : float → float32 := sorry'\n\ndef to_int (f:float) : option int32 := /- conversion to signed 32-bit int -/\nrepr <$> sorry'\ndef to_intu (f:float) : option int32 := /- conversion to unsigned 32-bit int -/\nrepr <$> sorry'\ndef to_long (f:float) : option int64 := /- conversion to signed 64-bit int -/\nrepr <$> sorry'\ndef to_longu (f:float) : option int64 := /- conversion to unsigned 64-bit int -/\nrepr <$> sorry'\n\ndef of_int (n:int32) : float := /- conversion from signed 32-bit int -/\nsorry'\ndef of_intu (n:int32) : float:= /- conversion from unsigned 32-bit int -/\nsorry'\n\ndef of_long (n:int64) : float := /- conversion from signed 64-bit int -/\nsorry'\ndef of_longu (n:int64) : float:= /- conversion from unsigned 64-bit int -/\nsorry'\n\ninstance coe_int32_float : has_coe int32 float := ⟨of_int⟩\ninstance coe_int64_float : has_coe int64 float := ⟨of_long⟩\n\ndef from_parsed (base : pos_num) (intPart : pos_num) (expPart : ℤ) : float :=\nsorry'\n\n/- Conversions between floats and their concrete in-memory representation\n    as a sequence of 64 bits. -/\n\ndef to_bits (f : float) : int64 := sorry'\ndef of_bits (b : int64) : float := sorry'\n\ndef from_words (hi lo : int32) : float := of_bits (int64.ofwords hi lo)\n\ndef is_nan : float → bool := sorry'\n\n/- ** Properties -/\n\n/- Below are the only properties of floating-point arithmetic that we\n  rely on in the compiler proof. -/\n\n/- Commutativity properties of addition and multiplication. -/\n\ntheorem add_comm (x y) : ¬ is_nan x ∨ ¬ is_nan y → x + y = y + x := sorry'\n\ntheorem mul_comm (x y) : ¬ is_nan x ∨ ¬ is_nan y → x * y = y * x := sorry'\n\n/- Multiplication by 2 is diagonal addition. -/\n\ntheorem mul2_add (f) : f + f = f * of_int 2 := sorry'\n\n/- Divisions that can be turned into multiplication by an inverse. -/\n\ndef exact_inverse : float → option float := sorry'\n\ntheorem div_mul_inverse (x y z) : exact_inverse y = some z → x / y = x * z := sorry'\n\n/- Properties of comparisons. -/\n\nlemma cmp_swap (c x y) : cmp (swap_comparison c) x y = cmp c y x := sorry'\n\nlemma cmp_ne_eq (x y) : cmp Cne x y = bnot (cmp Ceq x y) := sorry'\n\nlemma cmp_lt_not_eq (x y) : cmp Clt x y → ¬ cmp Ceq x y := sorry'\n\nlemma cmp_le_lt_eq (x y) : cmp Cle x y = cmp Clt x y || cmp Ceq x y := sorry'\n\nlemma cmp_gt_not_eq (x y) : cmp Cgt x y → ¬ cmp Ceq x y := sorry'\n\nlemma cmp_ge_gt_eq (x y) : cmp Cge x y = cmp Cgt x y || cmp Ceq x y := sorry'\n\nlemma cmp_lt_not_gt (x y) : cmp Clt x y → ¬ cmp Cgt x y := sorry'\n\n/- Properties of conversions to/from in-memory representation.\n  The conversions are bijective (one-to-one). -/\n\ntheorem of_to_bits (f) : of_bits (to_bits f) = f := sorry'\n\ntheorem to_of_bits (b) : to_bits (of_bits b) = b := sorry'\n\n/- Conversions between floats and unsigned ints can be defined\n  in terms of conversions between floats and signed ints.\n  (Most processors provide only the latter, forcing the compiler\n  to emulate the former.)   -/\n\ndef half32 : int32 := repr (@min_signed W32).  /- [0x8000_0000] -/\n\ntheorem of_intu_of_int_1 (x) : word.ltu x half32 → of_intu x = of_int x := sorry'\n\ntheorem of_intu_of_int_2 (x) : ¬ word.ltu x half32 → of_intu x = of_int (x - half32) + of_intu half32 := sorry'\n\ntheorem to_intu_to_int_1 (x n) : cmp Clt x (of_intu half32) → to_intu x = some n → to_int x = some n := sorry'\n\ntheorem to_intu_to_int_2 (x n) : ¬ cmp Clt x (of_intu half32) → to_intu x = some n →\n  to_int (x - of_intu half32) = some (n - half32) := sorry'\n\n/- Conversions from ints to floats can be defined as bitwise manipulations\n  over the in-memory representation.  This is what the PowerPC port does.\n  The trick is that [from_words 0x4330_0000 x] is the float\n  [2^52 + of_intu x]. -/\n\ndef bit433 : int32 := repr 0x43300000\n\nlemma split_bits_or (x) :\n  split_bits 52 11 (unsigned (int64.ofwords bit433 x)) = (ff, unsigned x, 1075) := sorry'\n\ntheorem of_intu_from_words (x) :\n  of_intu x = from_words bit433 x - from_words bit433 0 := sorry'\n\nlemma half32_signed_unsigned (x) :\n  (unsigned (x + half32) : ℤ) = signed x + @half_modulus W32 := sorry'\n\ntheorem of_int_from_words (x) :\n  of_int x = from_words bit433 (x + half32) - from_words bit433 half32 := sorry'\n\ndef bit453 : int32 := repr 0x45300000\n\nlemma split_bits_or' (x) :\n  split_bits 52 11 (unsigned (int64.ofwords bit453 x)) = (ff, unsigned x, 1107) := sorry'\n\ntheorem of_longu_from_words (l) : of_longu l =\n  from_words bit453 (int64.hiword l) -\n  from_words bit453 (repr (2^20)) +\n  from_words bit433 (int64.loword l) := sorry'\n\ntheorem of_long_from_words (l) : of_long l =\n    from_words bit453 (int64.hiword l + half32) -\n    from_words bit453 (repr (2^20+2^31)) +\n    from_words bit433 (int64.loword l) := sorry'\n\n/- Conversions from unsigned longs can be expressed in terms of conversions from signed longs.\n    If the unsigned long is too big, a round-to-odd must be performed on it\n    to avoid double rounding. -/\n\ntheorem of_longu_of_long_1 (x) :\n  word.ltu x (repr (@half_modulus W64)) →\n  of_longu x = of_long x := sorry'\n\ntheorem of_longu_of_long_2 (x) :\n  ¬ word.ltu x (repr (@half_modulus W64)) →\n  of_longu x = of_long (word.or (word.shru x 1) (word.and x 1)) * of_int (repr 2) := sorry'\n\nend float\n\n/- * Single-precision FP numbers -/\n\nnamespace float32\n\n/- ** NaN payload manipulations -/\n\ndef transform_quiet_pl (pl : nan_pl 24) : nan_pl 24 :=\nword.or pl (repr (2^22))\n\nlemma transform_quiet_pl_idempotent (pl) :\n  transform_quiet_pl (transform_quiet_pl pl) = transform_quiet_pl pl := sorry'\n\ndef neg_pl (s:bool) (pl:nan_pl 24) := (bnot s, pl)\ndef abs_pl (s:bool) (pl:nan_pl 24) := (ff, pl)\n\ndef binop_pl (x y : binary32) : bool × nan_pl 24 := sorry'\n\n/- ** Operations over single-precision floats -/\n\ndef zero : float32 := sorry' /- the float [+0.0] -/\n\ninstance : has_zero float32 := ⟨zero⟩\n\ninstance eq_dec : decidable_eq float32 := sorry'\n\n/- Arithmetic operations -/\n\nprotected def neg : float32 → float32 := sorry' /- opposite (change sign) -/\ndef abs : float32 → float32 := sorry' /- absolute value (set sign to [+]) -/\nprotected def add : float32 → float32 → float32 := sorry' /- addition -/\nprotected def sub : float32 → float32 → float32 := sorry' /- subtraction -/\nprotected def mul : float32 → float32 → float32 := sorry' /- multiplication -/\nprotected def div : float32 → float32 → float32 := sorry' /- division -/\ndef cmp (c:comparison) (f1 f2 : float32) : bool := /- comparison -/\ncmp_of_comparison c sorry'\n\ninstance : has_add float32 := ⟨float32.add⟩\ninstance : has_neg float32 := ⟨float32.neg⟩\ninstance : has_sub float32 := ⟨float32.sub⟩\ninstance : has_mul float32 := ⟨float32.mul⟩\ninstance : has_div float32 := ⟨float32.div⟩\n\n/- Conversions -/\n\ndef of_double : float → float32 := float.to_single\ndef to_double : float32 → float := float.of_single\n\ndef to_int (f:float32) : option int32 := /- conversion to signed 32-bit int -/\nrepr <$> sorry'\ndef to_intu (f:float32) : option int32 := /- conversion to unsigned 32-bit int -/\nrepr <$> sorry'\ndef to_long (f:float32) : option int64 := /- conversion to signed 64-bit int -/\nrepr <$> sorry'\ndef to_longu (f:float32) : option int64 := /- conversion to unsigned 64-bit int -/\nrepr <$> sorry'\n\ndef of_int (n:int32) : float32 := /- conversion from signed 32-bit int to single-precision float -/\nsorry'\ndef of_intu (n:int32) : float32 := /- conversion from unsigned 32-bit int to single-precision float -/\nsorry'\n\ndef of_long (n:int64) : float32 := /- conversion from signed 64-bit int to single-precision float -/\nsorry'\ndef of_longu (n:int64) : float32 := /- conversion from unsigned 64-bit int to single-precision float -/\nsorry'\n\ndef from_parsed (base : pos_num) (intPart : pos_num) (expPart : ℤ) : float32 :=\nsorry'\n\n/- Conversions between floats and their concrete in-memory representation\n    as a sequence of 32 bits. -/\n\ndef to_bits (f : float32) : int32 := sorry'\ndef of_bits (b : int32) : float32 := sorry'\n\ndef is_nan : float32 → bool := sorry'\n\n/- ** Properties -/\n\n/- Commutativity properties of addition and multiplication. -/\n\ntheorem add_comm (x y) : ¬ is_nan x ∨ ¬ is_nan y → x + y = y + x := sorry'\n\ntheorem mul_comm (x y) : ¬ is_nan x ∨ ¬ is_nan y → x * y = y * x := sorry'\n\n/- Multiplication by 2 is diagonal addition. -/\n\ntheorem mul2_add (f) : f + f = f * of_int 2 := sorry'\n\n/- Divisions that can be turned into multiplication by an inverse. -/\n\ndef exact_inverse : float32 → option float32 := sorry'\n\ntheorem div_mul_inverse (x y z) : exact_inverse y = some z → x / y = x * z := sorry'\n\n/- Properties of comparisons. -/\n\nlemma cmp_swap (c x y) : cmp (swap_comparison c) x y = cmp c y x := sorry'\n\nlemma cmp_ne_eq (x y) : cmp Cne x y = bnot (cmp Ceq x y) := sorry'\n\nlemma cmp_lt_not_eq (x y) : cmp Clt x y → ¬ cmp Ceq x y := sorry'\n\nlemma cmp_le_lt_eq (x y) : cmp Cle x y = cmp Clt x y || cmp Ceq x y := sorry'\n\nlemma cmp_gt_not_eq (x y) : cmp Cgt x y → ¬ cmp Ceq x y := sorry'\n\nlemma cmp_ge_gt_eq (x y) : cmp Cge x y = cmp Cgt x y || cmp Ceq x y := sorry'\n\nlemma cmp_lt_not_gt (x y) : cmp Clt x y → ¬ cmp Cgt x y := sorry'\n\ntheorem cmp_double (f1 f2 c) : cmp c f1 f2 = float.cmp c (to_double f1) (to_double f2) := sorry'\n\n/- Properties of conversions to/from in-memory representation.\n  The conversions are bijective (one-to-one). -/\n\ntheorem of_to_bits (f) : of_bits (to_bits f) = f := sorry'\n\ntheorem to_of_bits (b) : to_bits (of_bits b) = b := sorry'\n\n/- Conversions from 32-bit integers to single-precision floats can\n  be decomposed into a conversion to a double-precision float,\n  followed by a [Float32.of_double] conversion.  No double rounding occurs. -/\n\ntheorem of_int_double (n) : of_int n = of_double (float.of_int n) := sorry'\n\ntheorem of_intu_double (n) : of_intu n = of_double (float.of_intu n) := sorry'\n\n/- Conversion of single-precision floats to integers can be decomposed\n  into a [Float32.to_double] extension, followed by a double-precision-to-int\n  conversion. -/\n\ntheorem to_int_double (f n) : to_int f = some n → float.to_int (to_double f) = some n := sorry'\n\ntheorem to_intu_double (f n) : to_intu f = some n → float.to_intu (to_double f) = some n := sorry'\n\ntheorem to_long_double (f n) : to_long f = some n → float.to_long (to_double f) = some n := sorry'\n\ntheorem to_longu_double (f n) : to_longu f = some n → float.to_longu (to_double f) = some n := sorry'\n\n/- Conversions from 64-bit integers to single-precision floats can be expressed\n  as conversion to a double-precision float followed by a [Float32.of_double] conversion.\n  To avoid double rounding when the integer is large (above [2^53]), a round\n  to odd must be performed on the integer before conversion to double-precision float. -/\n\nlemma int_round_odd_plus (p n) :\n  int_round_odd n p = int.land (int.lor n (int.land n (2^p-1) + (2^p-1))) (-(2^p)) := sorry'\n\ntheorem of_longu_double_1 (n) : unsigned n ≤ 2^53 →\n  of_longu n = of_double (float.of_longu n) := sorry'\n\ntheorem of_longu_double_2 (n) : 2^36 ≤ unsigned n →\n  of_longu n = of_double (float.of_longu $\n    word.and (word.or n (word.and n (repr 2047) + repr 2047)) (repr (-2048))) := sorry'\n\ntheorem of_long_double_1 (n) : (signed n).nat_abs ≤ 2^53 →\n  of_long n = of_double (float.of_long n) := sorry'\n\ntheorem of_long_double_2 (n) : 2^36 ≤ (signed n).nat_abs →\n  of_long n = of_double (float.of_long $\n    word.and (word.or n (word.and n (repr 2047) + repr 2047)) (repr (-2048))) := sorry'\n\nend float32\n\nend floats\n", "meta": {"author": "digama0", "repo": "kremlin", "sha": "d4665929ce9012e93a0b05fc7063b96256bab86f", "save_path": "github-repos/lean/digama0-kremlin", "path": "github-repos/lean/digama0-kremlin/kremlin-d4665929ce9012e93a0b05fc7063b96256bab86f/floats.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006919925839875, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.474543400855201}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Jeremy Avigad, Simon Hudon\n\n! This file was ported from Lean 3 source module data.part\n! leanprover-community/mathlib commit 80c43012d26f63026d362c3aba28f3c3bafb07e6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Set.Basic\nimport Mathlib.Logic.Equiv.Defs\n\n/-!\n# Partial values of a type\nThis file defines `Part α`, the partial values of a type.\n`o : Part α` carries a proposition `o.Dom`, its domain, along with a function `get : o.Dom → α`, its\nvalue. The rule is then that every partial value has a value but, to access it, you need to provide\na proof of the domain.\n`Part α` behaves the same as `Option α` except that `o : Option α` is decidably `none` or `some a`\nfor some `a : α`, while the domain of `o : Part α` doesn't have to be decidable. That means you can\ntranslate back and forth between a partial value with a decidable domain and an option, and\n`Option α` and `Part α` are classically equivalent. In general, `Part α` is bigger than `Option α`.\nIn current mathlib, `Part ℕ`, aka `PartENat`, is used to move decidability of the order to\ndecidability of `PartENat.find` (which is the smallest natural satisfying a predicate, or `∞` if\nthere's none).\n## Main declarations\n`Option`-like declarations:\n* `Part.none`: The partial value whose domain is `False`.\n* `Part.some a`: The partial value whose domain is `True` and whose value is `a`.\n* `Part.ofOption`: Converts an `Option α` to a `Part α` by sending `none` to `none` and `some a` to\n  `some a`.\n* `Part.toOption`: Converts a `Part α` with a decidable domain to an `Option α`.\n* `Part.equivOption`: Classical equivalence between `Part α` and `Option α`.\nMonadic structure:\n* `Part.bind`: `o.bind f` has value `(f (o.get _)).get _` (`f o` morally) and is defined when `o`\n  and `f (o.get _)` are defined.\n* `Part.map`: Maps the value and keeps the same domain.\nOther:\n* `Part.restrict`: `Part.restrict p o` replaces the domain of `o : Part α` by `p : Prop` so long as\n  `p → o.Dom`.\n* `Part.assert`: `assert p f` appends `p` to the domains of the values of a partial function.\n* `Part.unwrap`: Gets the value of a partial value regardless of its domain. Unsound.\n## Notation\nFor `a : α`, `o : Part α`, `a ∈ o` means that `o` is defined and equal to `a`. Formally, it means\n`o.Dom` and `o.get _ = a`.\n-/\n\nopen Function\n\n/-- `Part α` is the type of \"partial values\" of type `α`. It\n  is similar to `Option α` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure Part.{u} (α : Type u) : Type u where\n  /-- The domain of a partial value -/\n  Dom : Prop\n  /-- Extract a value from a partial value given a proof of `Dom` -/\n  get : Dom → α\n#align part Part\n\nnamespace Part\n\nvariable {α : Type _} {β : Type _} {γ : Type _}\n\n/-- Convert a `Part α` with a decidable domain to an option -/\ndef toOption (o : Part α) [Decidable o.Dom] : Option α :=\n  if h : Dom o then some (o.get h) else none\n#align part.to_option Part.toOption\n\n@[simp] lemma toOption_isSome (o : Part α) [Decidable o.Dom] : o.toOption.isSome ↔ o.Dom := by\n  by_cases h : o.Dom <;> simp [h, toOption]\n#align part.to_option_is_some Part.toOption_isSome\n\n@[simp] lemma toOption_isNone (o : Part α) [Decidable o.Dom] : o.toOption.isNone ↔ ¬o.Dom := by\n  by_cases h : o.Dom <;> simp [h, toOption]\n#align part.to_option_is_none Part.toOption_isNone\n\n/-- `Part` extensionality -/\ntheorem ext' : ∀ {o p : Part α} (_ : o.Dom ↔ p.Dom) (_ : ∀ h₁ h₂, o.get h₁ = p.get h₂), o = p\n  | ⟨od, o⟩, ⟨pd, p⟩, H1, H2 => by\n    have t : od = pd := propext H1\n    cases t; rw [show o = p from funext fun p => H2 p p]\n#align part.ext' Part.ext'\n\n/-- `Part` eta expansion -/\n@[simp]\ntheorem eta : ∀ o : Part α, (⟨o.Dom, fun h => o.get h⟩ : Part α) = o\n  | ⟨_, _⟩ => rfl\n#align part.eta Part.eta\n\n/-- `a ∈ o` means that `o` is defined and equal to `a` -/\nprotected def Mem (a : α) (o : Part α) : Prop :=\n  ∃ h, o.get h = a\n#align part.mem Part.Mem\n\ninstance : Membership α (Part α) :=\n  ⟨Part.Mem⟩\n\ntheorem mem_eq (a : α) (o : Part α) : (a ∈ o) = ∃ h, o.get h = a :=\n  rfl\n#align part.mem_eq Part.mem_eq\n\ntheorem dom_iff_mem : ∀ {o : Part α}, o.Dom ↔ ∃ y, y ∈ o\n  | ⟨_, f⟩ => ⟨fun h => ⟨f h, h, rfl⟩, fun ⟨_, h, rfl⟩ => h⟩\n#align part.dom_iff_mem Part.dom_iff_mem\n\ntheorem get_mem {o : Part α} (h) : get o h ∈ o :=\n  ⟨_, rfl⟩\n#align part.get_mem Part.get_mem\n\n@[simp]\ntheorem mem_mk_iff {p : Prop} {o : p → α} {a : α} : a ∈ Part.mk p o ↔ ∃ h, o h = a :=\n  Iff.rfl\n#align part.mem_mk_iff Part.mem_mk_iff\n\n/-- `Part` extensionality -/\n@[ext]\ntheorem ext {o p : Part α} (H : ∀ a, a ∈ o ↔ a ∈ p) : o = p :=\n  (ext' ⟨fun h => ((H _).1 ⟨h, rfl⟩).fst, fun h => ((H _).2 ⟨h, rfl⟩).fst⟩) fun _ _ =>\n    ((H _).2 ⟨_, rfl⟩).snd\n#align part.ext Part.ext\n\n/-- The `none` value in `Part` has a `False` domain and an empty function. -/\ndef none : Part α :=\n  ⟨False, False.rec⟩\n#align part.none Part.none\n\ninstance : Inhabited (Part α) :=\n  ⟨none⟩\n\n@[simp]\ntheorem not_mem_none (a : α) : a ∉ @none α := fun h => h.fst\n#align part.not_mem_none Part.not_mem_none\n\n/-- The `some a` value in `Part` has a `true` domain and the\n  function returns `a`. -/\ndef some (a : α) : Part α :=\n  ⟨True, fun _ => a⟩\n#align part.some Part.some\n\n@[simp]\ntheorem some_dom (a : α) : (some a).Dom :=\n  trivial\n#align part.some_dom Part.some_dom\n\ntheorem mem_unique : ∀ {a b : α} {o : Part α}, a ∈ o → b ∈ o → a = b\n  | _, _, ⟨_, _⟩, ⟨_, rfl⟩, ⟨_, rfl⟩ => rfl\n#align part.mem_unique Part.mem_unique\n\ntheorem Mem.left_unique : Relator.LeftUnique ((· ∈ ·) : α → Part α → Prop) := fun _ _ _ =>\n  mem_unique\n#align part.mem.left_unique Part.Mem.left_unique\n\ntheorem get_eq_of_mem {o : Part α} {a} (h : a ∈ o) (h') : get o h' = a :=\n  mem_unique ⟨_, rfl⟩ h\n#align part.get_eq_of_mem Part.get_eq_of_mem\n\nprotected theorem subsingleton (o : Part α) : Set.Subsingleton { a | a ∈ o } := fun _ ha _ hb =>\n  mem_unique ha hb\n#align part.subsingleton Part.subsingleton\n\n@[simp]\ntheorem get_some {a : α} (ha : (some a).Dom) : get (some a) ha = a :=\n  rfl\n#align part.get_some Part.get_some\n\ntheorem mem_some (a : α) : a ∈ some a :=\n  ⟨trivial, rfl⟩\n#align part.mem_some Part.mem_some\n\n@[simp]\ntheorem mem_some_iff {a b} : b ∈ (some a : Part α) ↔ b = a :=\n  ⟨fun ⟨_, e⟩ => e.symm, fun e => ⟨trivial, e.symm⟩⟩\n#align part.mem_some_iff Part.mem_some_iff\n\ntheorem eq_some_iff {a : α} {o : Part α} : o = some a ↔ a ∈ o :=\n  ⟨fun e => e.symm ▸ mem_some _, fun ⟨h, e⟩ => e ▸ ext' (iff_true_intro h) fun _ _ => rfl⟩\n#align part.eq_some_iff Part.eq_some_iff\n\ntheorem eq_none_iff {o : Part α} : o = none ↔ ∀ a, a ∉ o :=\n  ⟨fun e => e.symm ▸ not_mem_none, fun h => ext (by simpa)⟩\n#align part.eq_none_iff Part.eq_none_iff\n\ntheorem eq_none_iff' {o : Part α} : o = none ↔ ¬o.Dom :=\n  ⟨fun e => e.symm ▸ id, fun h => eq_none_iff.2 fun _ h' => h h'.fst⟩\n#align part.eq_none_iff' Part.eq_none_iff'\n\n@[simp]\ntheorem not_none_dom : ¬(none : Part α).Dom :=\n  id\n#align part.not_none_dom Part.not_none_dom\n\n@[simp]\ntheorem some_ne_none (x : α) : some x ≠ none := by\n  intro h\n  exact true_ne_false (congr_arg Dom h)\n#align part.some_ne_none Part.some_ne_none\n\n@[simp]\ntheorem none_ne_some (x : α) : none ≠ some x :=\n  (some_ne_none x).symm\n#align part.none_ne_some Part.none_ne_some\n\ntheorem ne_none_iff {o : Part α} : o ≠ none ↔ ∃ x, o = some x := by\n  constructor\n  · rw [Ne, eq_none_iff', not_not]\n    exact fun h => ⟨o.get h, eq_some_iff.2 (get_mem h)⟩\n  · rintro ⟨x, rfl⟩\n    apply some_ne_none\n#align part.ne_none_iff Part.ne_none_iff\n\ntheorem eq_none_or_eq_some (o : Part α) : o = none ∨ ∃ x, o = some x :=\n  or_iff_not_imp_left.2 ne_none_iff.1\n#align part.eq_none_or_eq_some Part.eq_none_or_eq_some\n\ntheorem some_injective : Injective (@Part.some α) := fun _ _ h =>\n  congr_fun (eq_of_heq (Part.mk.inj h).2) trivial\n#align part.some_injective Part.some_injective\n\n@[simp]\ntheorem some_inj {a b : α} : Part.some a = some b ↔ a = b :=\n  some_injective.eq_iff\n#align part.some_inj Part.some_inj\n\n@[simp]\ntheorem some_get {a : Part α} (ha : a.Dom) : Part.some (Part.get a ha) = a :=\n  Eq.symm (eq_some_iff.2 ⟨ha, rfl⟩)\n#align part.some_get Part.some_get\n\ntheorem get_eq_iff_eq_some {a : Part α} {ha : a.Dom} {b : α} : a.get ha = b ↔ a = some b :=\n  ⟨fun h => by simp [h.symm], fun h => by simp [h]⟩\n#align part.get_eq_iff_eq_some Part.get_eq_iff_eq_some\n\ntheorem get_eq_get_of_eq (a : Part α) (ha : a.Dom) {b : Part α} (h : a = b) :\n    a.get ha = b.get (h ▸ ha) := by\n  congr\n#align part.get_eq_get_of_eq Part.get_eq_get_of_eq\n\ntheorem get_eq_iff_mem {o : Part α} {a : α} (h : o.Dom) : o.get h = a ↔ a ∈ o :=\n  ⟨fun H => ⟨h, H⟩, fun ⟨_, H⟩ => H⟩\n#align part.get_eq_iff_mem Part.get_eq_iff_mem\n\ntheorem eq_get_iff_mem {o : Part α} {a : α} (h : o.Dom) : a = o.get h ↔ a ∈ o :=\n  eq_comm.trans (get_eq_iff_mem h)\n#align part.eq_get_iff_mem Part.eq_get_iff_mem\n\n@[simp]\ntheorem none_toOption [Decidable (@none α).Dom] : (none : Part α).toOption = Option.none :=\n  dif_neg id\n#align part.none_to_option Part.none_toOption\n\n@[simp]\ntheorem some_toOption (a : α) [Decidable (some a).Dom] : (some a).toOption = Option.some a :=\n  dif_pos trivial\n#align part.some_to_option Part.some_toOption\n\ninstance noneDecidable : Decidable (@none α).Dom :=\n  instDecidableFalse\n#align part.none_decidable Part.noneDecidable\n\ninstance someDecidable (a : α) : Decidable (some a).Dom :=\n  instDecidableTrue\n#align part.some_decidable Part.someDecidable\n\n/-- Retrieves the value of `a : part α` if it exists, and return the provided default value\notherwise. -/\ndef getOrElse (a : Part α) [Decidable a.Dom] (d : α) :=\n  if ha : a.Dom then a.get ha else d\n#align part.get_or_else Part.getOrElse\n\ntheorem getOrElse_of_dom (a : Part α) (h : a.Dom) [Decidable a.Dom] (d : α) :\n    getOrElse a d = a.get h :=\n  dif_pos h\n#align part.get_or_else_of_dom Part.getOrElse_of_dom\n\ntheorem getOrElse_of_not_dom (a : Part α) (h : ¬a.Dom) [Decidable a.Dom] (d : α) :\n    getOrElse a d = d :=\n  dif_neg h\n#align part.get_or_else_of_not_dom Part.getOrElse_of_not_dom\n\n@[simp]\ntheorem getOrElse_none (d : α) [Decidable (none : Part α).Dom] : getOrElse none d = d :=\n  none.getOrElse_of_not_dom not_none_dom d\n#align part.get_or_else_none Part.getOrElse_none\n\n@[simp]\ntheorem getOrElse_some (a : α) (d : α) [Decidable (some a).Dom] : getOrElse (some a) d = a :=\n  (some a).getOrElse_of_dom (some_dom a) d\n#align part.get_or_else_some Part.getOrElse_some\n\n--Porting note: removed `simp`\ntheorem mem_toOption {o : Part α} [Decidable o.Dom] {a : α} : a ∈ toOption o ↔ a ∈ o := by\n  unfold toOption\n  by_cases h : o.Dom <;> simp [h]\n  · exact ⟨fun h => ⟨_, h⟩, fun ⟨_, h⟩ => h⟩\n  · exact mt Exists.fst h\n#align part.mem_to_option Part.mem_toOption\n\n--Porting note : New theorem, like `mem_toOption` but with LHS in `simp` normal form\n@[simp]\ntheorem toOption_eq_some_iff {o : Part α} [Decidable o.Dom] {a : α} :\n    toOption o = Option.some a ↔ a ∈ o :=\n  by rw [← Option.mem_def, mem_toOption]\n\nprotected theorem Dom.toOption {o : Part α} [Decidable o.Dom] (h : o.Dom) : o.toOption = o.get h :=\n  dif_pos h\n#align part.dom.to_option Part.Dom.toOption\n\ntheorem toOption_eq_none_iff {a : Part α} [Decidable a.Dom] : a.toOption = Option.none ↔ ¬a.Dom :=\n  Ne.dite_eq_right_iff fun _ => Option.some_ne_none _\n#align part.to_option_eq_none_iff Part.toOption_eq_none_iff\n\n/- Porting TODO: Removed `simp`. Maybe add `@[simp]` later if `@[simp]` is taken off definition of\n`Option.elim` -/\ntheorem elim_toOption {α β : Type _} (a : Part α) [Decidable a.Dom] (b : β) (f : α → β) :\n    a.toOption.elim b f = if h : a.Dom then f (a.get h) else b := by\n  split_ifs with h\n  · rw [h.toOption]\n    rfl\n  · rw [Part.toOption_eq_none_iff.2 h]\n    rfl\n#align part.elim_to_option Part.elim_toOption\n\n/-- Converts an `Option α` into a `Part α`. -/\ndef ofOption : Option α → Part α\n  | Option.none => none\n  | Option.some a => some a\n#align part.of_option Part.ofOption\n\n@[simp]\ntheorem mem_ofOption {a : α} : ∀ {o : Option α}, a ∈ ofOption o ↔ a ∈ o\n  | Option.none => ⟨fun h => h.fst.elim, fun h => Option.noConfusion h⟩\n  | Option.some _ => ⟨fun h => congr_arg Option.some h.snd, fun h => ⟨trivial, Option.some.inj h⟩⟩\n#align part.mem_of_option Part.mem_ofOption\n\n@[simp]\ntheorem ofOption_dom {α} : ∀ o : Option α, (ofOption o).Dom ↔ o.isSome\n  | Option.none => by simp [ofOption, none]\n  | Option.some a => by simp [ofOption]\n#align part.of_option_dom Part.ofOption_dom\n\ntheorem ofOption_eq_get {α} (o : Option α) : ofOption o = ⟨_, @Option.get _ o⟩ :=\n  Part.ext' (ofOption_dom o) fun h₁ h₂ => by\n    cases o\n    . simp at h₂\n    . rfl\n#align part.of_option_eq_get Part.ofOption_eq_get\n\ninstance : Coe (Option α) (Part α) :=\n  ⟨ofOption⟩\n\ntheorem mem_coe {a : α} {o : Option α} : a ∈ (o : Part α) ↔ a ∈ o :=\n  mem_ofOption\n#align part.mem_coe Part.mem_coe\n\n@[simp]\n\n\n@[simp]\ntheorem coe_some (a : α) : (Option.some a : Part α) = some a :=\n  rfl\n#align part.coe_some Part.coe_some\n\n@[elab_as_elim]\nprotected theorem induction_on {P : Part α → Prop} (a : Part α) (hnone : P none)\n    (hsome : ∀ a : α, P (some a)) : P a :=\n  (Classical.em a.Dom).elim (fun h => Part.some_get h ▸ hsome _) fun h =>\n    (eq_none_iff'.2 h).symm ▸ hnone\n#align part.induction_on Part.induction_on\n\ninstance ofOptionDecidable : ∀ o : Option α, Decidable (ofOption o).Dom\n  | Option.none => Part.noneDecidable\n  | Option.some a => Part.someDecidable a\n#align part.of_option_decidable Part.ofOptionDecidable\n\n@[simp]\ntheorem to_ofOption (o : Option α) : toOption (ofOption o) = o := by cases o <;> rfl\n#align part.to_of_option Part.to_ofOption\n\n@[simp]\ntheorem of_toOption (o : Part α) [Decidable o.Dom] : ofOption (toOption o) = o :=\n  ext fun _ => mem_ofOption.trans mem_toOption\n#align part.of_to_option Part.of_toOption\n\n/-- `Part α` is (classically) equivalent to `Option α`. -/\nnoncomputable def equivOption : Part α ≃ Option α :=\n  haveI := Classical.dec\n  ⟨fun o => toOption o, ofOption, fun o => of_toOption o, fun o =>\n    Eq.trans (by dsimp; congr ) (to_ofOption o)⟩\n#align part.equiv_option Part.equivOption\n\n/-- We give `Part α` the order where everything is greater than `none`. -/\ninstance : PartialOrder (Part\n        α) where\n  le x y := ∀ i, i ∈ x → i ∈ y\n  le_refl x y := id\n  le_trans x y z f g i := g _ ∘ f _\n  le_antisymm x y f g := Part.ext fun z => ⟨f _, g _⟩\n\ninstance : OrderBot (Part α) where\n  bot := none\n  bot_le := by\n    introv x\n    rintro ⟨⟨_⟩, _⟩\n\ntheorem le_total_of_le_of_le {x y : Part α} (z : Part α) (hx : x ≤ z) (hy : y ≤ z) :\n    x ≤ y ∨ y ≤ x := by\n  rcases Part.eq_none_or_eq_some x with (h | ⟨b, h₀⟩)\n  · rw [h]\n    left\n    apply OrderBot.bot_le _\n  right; intro b' h₁\n  rw [Part.eq_some_iff] at h₀\n  have hx := hx _ h₀; have hy := hy _ h₁\n  have hx := Part.mem_unique hx hy; subst hx\n  exact h₀\n#align part.le_total_of_le_of_le Part.le_total_of_le_of_le\n\n/-- `assert p f` is a bind-like operation which appends an additional condition\n  `p` to the domain and uses `f` to produce the value. -/\ndef assert (p : Prop) (f : p → Part α) : Part α :=\n  ⟨∃ h : p, (f h).Dom, fun ha => (f ha.fst).get ha.snd⟩\n#align part.assert Part.assert\n\n/-- The bind operation has value `g (f.get)`, and is defined when all the\n  parts are defined. -/\nprotected def bind (f : Part α) (g : α → Part β) : Part β :=\n  assert (Dom f) fun b => g (f.get b)\n#align part.bind Part.bind\n\n/-- The map operation for `Part` just maps the value and maintains the same domain. -/\n@[simps]\ndef map (f : α → β) (o : Part α) : Part β :=\n  ⟨o.Dom, f ∘ o.get⟩\n#align part.map Part.map\n#align part.map_dom Part.map_Dom\n#align part.map_get Part.map_get\n\ntheorem mem_map (f : α → β) {o : Part α} : ∀ {a}, a ∈ o → f a ∈ map f o\n  | _, ⟨_, rfl⟩ => ⟨_, rfl⟩\n#align part.mem_map Part.mem_map\n\n@[simp]\ntheorem mem_map_iff (f : α → β) {o : Part α} {b} : b ∈ map f o ↔ ∃ a ∈ o, f a = b :=\n  ⟨fun hb => match b, hb with\n    | _, ⟨_, rfl⟩ => ⟨_, ⟨_, rfl⟩, rfl⟩,\n    fun ⟨_, h₁, h₂⟩ => h₂ ▸ mem_map f h₁⟩\n#align part.mem_map_iff Part.mem_map_iff\n\n@[simp]\ntheorem map_none (f : α → β) : map f none = none :=\n  eq_none_iff.2 fun a => by simp\n#align part.map_none Part.map_none\n\n@[simp]\ntheorem map_some (f : α → β) (a : α) : map f (some a) = some (f a) :=\n  eq_some_iff.2 <| mem_map f <| mem_some _\n#align part.map_some Part.map_some\n\ntheorem mem_assert {p : Prop} {f : p → Part α} : ∀ {a} (h : p), a ∈ f h → a ∈ assert p f\n  | _, x, ⟨h, rfl⟩ => ⟨⟨x, h⟩, rfl⟩\n#align part.mem_assert Part.mem_assert\n\n@[simp]\ntheorem mem_assert_iff {p : Prop} {f : p → Part α} {a} : a ∈ assert p f ↔ ∃ h : p, a ∈ f h :=\n  ⟨fun ha => match a, ha with\n    | _, ⟨_, rfl⟩ => ⟨_, ⟨_, rfl⟩⟩,\n    fun ⟨_, h⟩ => mem_assert _ h⟩\n#align part.mem_assert_iff Part.mem_assert_iff\n\ntheorem assert_pos {p : Prop} {f : p → Part α} (h : p) : assert p f = f h := by\n  dsimp [assert]\n  cases h' : f h\n  simp [h', mk.injEq, h, exists_prop_of_true, true_and]\n  apply Function.hfunext\n  · simp only [h, h', exists_prop_of_true]\n  · aesop\n#align part.assert_pos Part.assert_pos\n\ntheorem assert_neg {p : Prop} {f : p → Part α} (h : ¬p) : assert p f = none := by\n  dsimp [assert, none]; congr\n  · simp only [h, not_false_iff, exists_prop_of_false]\n  · apply Function.hfunext\n    · simp only [h, not_false_iff, exists_prop_of_false]\n    simp at *\n#align part.assert_neg Part.assert_neg\n\ntheorem mem_bind {f : Part α} {g : α → Part β} : ∀ {a b}, a ∈ f → b ∈ g a → b ∈ f.bind g\n  | _, _, ⟨h, rfl⟩, ⟨h₂, rfl⟩ => ⟨⟨h, h₂⟩, rfl⟩\n#align part.mem_bind Part.mem_bind\n\n@[simp]\ntheorem mem_bind_iff {f : Part α} {g : α → Part β} {b} : b ∈ f.bind g ↔ ∃ a ∈ f, b ∈ g a :=\n  ⟨fun hb => match b, hb with\n    | _, ⟨⟨_, _⟩, rfl⟩ => ⟨_, ⟨_, rfl⟩, ⟨_, rfl⟩⟩,\n    fun ⟨_, h₁, h₂⟩ => mem_bind h₁ h₂⟩\n#align part.mem_bind_iff Part.mem_bind_iff\n\nprotected theorem Dom.bind {o : Part α} (h : o.Dom) (f : α → Part β) : o.bind f = f (o.get h) := by\n  ext b\n  simp only [Part.mem_bind_iff, exists_prop]\n  refine' ⟨_, fun hb => ⟨o.get h, Part.get_mem _, hb⟩⟩\n  rintro ⟨a, ha, hb⟩\n  rwa [Part.get_eq_of_mem ha]\n#align part.dom.bind Part.Dom.bind\n\ntheorem Dom.of_bind {f : α → Part β} {a : Part α} (h : (a.bind f).Dom) : a.Dom :=\n  h.1\n#align part.dom.of_bind Part.Dom.of_bind\n\n@[simp]\ntheorem bind_none (f : α → Part β) : none.bind f = none :=\n  eq_none_iff.2 fun a => by simp\n#align part.bind_none Part.bind_none\n\n@[simp]\ntheorem bind_some (a : α) (f : α → Part β) : (some a).bind f = f a :=\n  ext <| by simp\n#align part.bind_some Part.bind_some\n\ntheorem bind_of_mem {o : Part α} {a : α} (h : a ∈ o) (f : α → Part β) : o.bind f = f a := by\n  rw [eq_some_iff.2 h, bind_some]\n#align part.bind_of_mem Part.bind_of_mem\n\ntheorem bind_some_eq_map (f : α → β) (x : Part α) : x.bind (some ∘ f) = map f x :=\n  ext <| by simp [eq_comm]\n#align part.bind_some_eq_map Part.bind_some_eq_map\n\ntheorem bind_toOption (f : α → Part β) (o : Part α) [Decidable o.Dom] [∀ a, Decidable (f a).Dom]\n    [Decidable (o.bind f).Dom] :\n    (o.bind f).toOption = o.toOption.elim Option.none fun a => (f a).toOption := by\n  by_cases h : o.Dom\n  · simp_rw [h.toOption, h.bind]\n    rfl\n  · rw [Part.toOption_eq_none_iff.2 h]\n    exact Part.toOption_eq_none_iff.2 fun ho => h ho.of_bind\n#align part.bind_to_option Part.bind_toOption\n\ntheorem bind_assoc {γ} (f : Part α) (g : α → Part β) (k : β → Part γ) :\n    (f.bind g).bind k = f.bind fun x => (g x).bind k :=\n  ext fun a => by\n    simp;\n      exact\n        ⟨fun ⟨_, ⟨_, h₁, h₂⟩, h₃⟩ => ⟨_, h₁, _, h₂, h₃⟩, fun ⟨_, h₁, _, h₂, h₃⟩ =>\n          ⟨_, ⟨_, h₁, h₂⟩, h₃⟩⟩\n#align part.bind_assoc Part.bind_assoc\n\n@[simp]\ntheorem bind_map {γ} (f : α → β) (x) (g : β → Part γ) :\n    (map f x).bind g = x.bind fun y => g (f y) := by rw [← bind_some_eq_map, bind_assoc]; simp\n#align part.bind_map Part.bind_map\n\n@[simp]\ntheorem map_bind {γ} (f : α → Part β) (x : Part α) (g : β → γ) :\n    map g (x.bind f) = x.bind fun y => map g (f y) := by\n  rw [← bind_some_eq_map, bind_assoc]; simp [bind_some_eq_map]\n#align part.map_bind Part.map_bind\n\ntheorem map_map (g : β → γ) (f : α → β) (o : Part α) : map g (map f o) = map (g ∘ f) o := by\n  erw [← bind_some_eq_map, bind_map, bind_some_eq_map]\n#align part.map_map Part.map_map\n\ninstance : Monad Part where\n  pure := @some\n  map := @map\n  bind := @Part.bind\n\ninstance : LawfulMonad\n      Part where\n  bind_pure_comp := @bind_some_eq_map\n  id_map f := by cases f; rfl\n  pure_bind := @bind_some\n  bind_assoc := @bind_assoc\n  map_const := by simp [Functor.mapConst, Functor.map]\n  --Porting TODO : In Lean3 these were automatic by a tactic\n  seqLeft_eq x y := ext'\n    (by simp [SeqLeft.seqLeft, Part.bind, assert, Seq.seq, const, (. <$> .), and_comm])\n    (fun _ _ => rfl)\n  seqRight_eq x y := ext'\n    (by simp [SeqRight.seqRight, Part.bind, assert, Seq.seq, const, (. <$> .), and_comm])\n    (fun _ _ => rfl)\n  pure_seq x y := ext'\n    (by simp [Seq.seq, Part.bind, assert, (. <$> .), pure])\n    (fun _ _ => rfl)\n  bind_map x y := ext'\n    (by simp [(. >>= .), Part.bind, assert, Seq.seq, get, (. <$> .)] )\n    (fun _ _ => rfl)\n\ntheorem map_id' {f : α → α} (H : ∀ x : α, f x = x) (o) : map f o = o := by\n  rw [show f = id from funext H]; exact id_map o\n#align part.map_id' Part.map_id'\n\n@[simp]\ntheorem bind_some_right (x : Part α) : x.bind some = x := by\n  erw [bind_some_eq_map]; simp [map_id']\n#align part.bind_some_right Part.bind_some_right\n\n@[simp]\ntheorem pure_eq_some (a : α) : pure a = some a :=\n  rfl\n#align part.pure_eq_some Part.pure_eq_some\n\n@[simp]\ntheorem ret_eq_some (a : α) : (return a : Part α) = some a :=\n  rfl\n#align part.ret_eq_some Part.ret_eq_some\n\n@[simp]\ntheorem map_eq_map {α β} (f : α → β) (o : Part α) : f <$> o = map f o :=\n  rfl\n#align part.map_eq_map Part.map_eq_map\n\n@[simp]\ntheorem bind_eq_bind {α β} (f : Part α) (g : α → Part β) : f >>= g = f.bind g :=\n  rfl\n#align part.bind_eq_bind Part.bind_eq_bind\n\ntheorem bind_le {α} (x : Part α) (f : α → Part β) (y : Part β) :\n    x >>= f ≤ y ↔ ∀ a, a ∈ x → f a ≤ y := by\n  constructor <;> intro h\n  · intro a h' b\n    have h := h b\n    simp only [and_imp, exists_prop, bind_eq_bind, mem_bind_iff, exists_imp] at h\n    apply h _ h'\n  · intro b h'\n    simp only [exists_prop, bind_eq_bind, mem_bind_iff] at h'\n    rcases h' with ⟨a, h₀, h₁⟩\n    apply h _ h₀ _ h₁\n#align part.bind_le Part.bind_le\n\n--Porting note: No MonadFail in Lean4 yet\n-- instance : MonadFail Part :=\n--   { Part.monad with fail := fun _ _ => none }\n\n/-- `restrict p o h` replaces the domain of `o` with `p`, and is well defined when\n  `p` implies `o` is defined. -/\ndef restrict (p : Prop) (o : Part α) (H : p → o.Dom) : Part α :=\n  ⟨p, fun h => o.get (H h)⟩\n#align part.restrict Part.restrict\n\n@[simp]\ntheorem mem_restrict (p : Prop) (o : Part α) (h : p → o.Dom) (a : α) :\n    a ∈ restrict p o h ↔ p ∧ a ∈ o := by\n  dsimp [restrict, mem_eq]; constructor\n  · rintro ⟨h₀, h₁⟩\n    exact ⟨h₀, ⟨_, h₁⟩⟩\n  rintro ⟨h₀, _, h₂⟩; exact ⟨h₀, h₂⟩\n#align part.mem_restrict Part.mem_restrict\n\n/-- `unwrap o` gets the value at `o`, ignoring the condition. This function is unsound. -/\nunsafe def unwrap (o : Part α) : α :=\n  o.get lcProof\n#align part.unwrap Part.unwrap\n\ntheorem assert_defined {p : Prop} {f : p → Part α} : ∀ h : p, (f h).Dom → (assert p f).Dom :=\n  Exists.intro\n#align part.assert_defined Part.assert_defined\n\ntheorem bind_defined {f : Part α} {g : α → Part β} :\n    ∀ h : f.Dom, (g (f.get h)).Dom → (f.bind g).Dom :=\n  assert_defined\n#align part.bind_defined Part.bind_defined\n\n@[simp]\ntheorem bind_dom {f : Part α} {g : α → Part β} : (f.bind g).Dom ↔ ∃ h : f.Dom, (g (f.get h)).Dom :=\n  Iff.rfl\n#align part.bind_dom Part.bind_dom\n\nsection Instances\n\n-- We define several instances for constants and operations on `Part α` inherited from `α`.\n@[to_additive]\ninstance [One α] : One (Part α) where one := pure 1\n\n@[to_additive]\ninstance [Mul α] : Mul (Part α) where mul a b := (· * ·) <$> a <*> b\n\n@[to_additive]\ninstance [Inv α] : Inv (Part α) where inv := map Inv.inv\n\n@[to_additive]\ninstance [Div α] : Div (Part α) where div a b := (· / ·) <$> a <*> b\n\ninstance [Mod α] : Mod (Part α) where mod a b := (· % ·) <$> a <*> b\n\ninstance [Append α] : Append (Part α) where append a b := (· ++ ·) <$> a <*> b\n\ninstance [Inter α] : Inter (Part α) where inter a b := (· ∩ ·) <$> a <*> b\n\ninstance [Union α] : Union (Part α) where union a b := (· ∪ ·) <$> a <*> b\n\ninstance [SDiff α] : SDiff (Part α) where sdiff a b := (· \\ ·) <$> a <*> b\n\nsection\n-- Porting note : new theorems to unfold definitions\ntheorem mul_def [Mul α] (a b : Part α) : a * b = bind a fun y ↦ map (y * .) b := rfl\ntheorem one_def [One α] : (1 : Part α) = some 1 := rfl\ntheorem inv_def [Inv α] (a : Part α) : a⁻¹ = Part.map (. ⁻¹) a := rfl\ntheorem div_def [Div α] (a b : Part α) : a / b = bind a fun y => map (y / .) b := rfl\ntheorem mod_def [Mod α] (a b : Part α) : a % b = bind a fun y => map (y % .) b := rfl\ntheorem append_def [Append α] (a b : Part α) : a ++ b = bind a fun y => map (y ++ .) b := rfl\ntheorem inter_def [Inter α] (a b : Part α) : a ∩ b = bind a fun y => map (y ∩ .) b := rfl\ntheorem union_def [Union α] (a b : Part α) : a ∪ b = bind a fun y => map (y ∪ .) b := rfl\ntheorem sdiff_def [SDiff α] (a b : Part α) : a \\ b = bind a fun y => map (y \\ .) b := rfl\n\nend\n\n@[to_additive]\ntheorem one_mem_one [One α] : (1 : α) ∈ (1 : Part α) :=\n  ⟨trivial, rfl⟩\n#align part.one_mem_one Part.one_mem_one\n#align part.zero_mem_zero Part.zero_mem_zero\n\n@[to_additive]\ntheorem mul_mem_mul [Mul α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma * mb ∈ a * b := ⟨⟨ha.1, hb.1⟩, by simp [← ha.2, ← hb.2]; rfl⟩\n#align part.mul_mem_mul Part.mul_mem_mul\n#align part.add_mem_add Part.add_mem_add\n\n@[to_additive]\ntheorem left_dom_of_mul_dom [Mul α] {a b : Part α} (hab : Dom (a * b)) : a.Dom := hab.1\n#align part.left_dom_of_mul_dom Part.left_dom_of_mul_dom\n#align part.left_dom_of_add_dom Part.left_dom_of_add_dom\n\n@[to_additive]\ntheorem right_dom_of_mul_dom [Mul α] {a b : Part α} (hab : Dom (a * b)) : b.Dom := hab.2\n#align part.right_dom_of_mul_dom Part.right_dom_of_mul_dom\n#align part.right_dom_of_add_dom Part.right_dom_of_add_dom\n\n@[to_additive (attr := simp)]\ntheorem mul_get_eq [Mul α] (a b : Part α) (hab : Dom (a * b)) :\n    (a * b).get hab = a.get (left_dom_of_mul_dom hab) * b.get (right_dom_of_mul_dom hab) := rfl\n#align part.mul_get_eq Part.mul_get_eq\n#align part.add_get_eq Part.add_get_eq\n\n@[to_additive]\ntheorem some_mul_some [Mul α] (a b : α) : some a * some b = some (a * b) := by simp [mul_def]\n#align part.some_mul_some Part.some_mul_some\n#align part.some_add_some Part.some_add_some\n\n@[to_additive]\ntheorem inv_mem_inv [Inv α] (a : Part α) (ma : α) (ha : ma ∈ a) : ma⁻¹ ∈ a⁻¹ :=\n  by simp [inv_def]; aesop\n#align part.inv_mem_inv Part.inv_mem_inv\n#align part.neg_mem_neg Part.neg_mem_neg\n\n@[to_additive]\ntheorem inv_some [Inv α] (a : α) : (some a)⁻¹ = some a⁻¹ :=\n  rfl\n#align part.inv_some Part.inv_some\n#align part.neg_some Part.neg_some\n\n@[to_additive]\ntheorem div_mem_div [Div α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma / mb ∈ a / b := by simp [div_def]; aesop\n#align part.div_mem_div Part.div_mem_div\n#align part.sub_mem_sub Part.sub_mem_sub\n\n@[to_additive]\ntheorem left_dom_of_div_dom [Div α] {a b : Part α} (hab : Dom (a / b)) : a.Dom := hab.1\n#align part.left_dom_of_div_dom Part.left_dom_of_div_dom\n#align part.left_dom_of_sub_dom Part.left_dom_of_sub_dom\n\n@[to_additive]\ntheorem right_dom_of_div_dom [Div α] {a b : Part α} (hab : Dom (a / b)) : b.Dom := hab.2\n#align part.right_dom_of_div_dom Part.right_dom_of_div_dom\n#align part.right_dom_of_sub_dom Part.right_dom_of_sub_dom\n\n@[to_additive (attr := simp)]\ntheorem div_get_eq [Div α] (a b : Part α) (hab : Dom (a / b)) :\n    (a / b).get hab = a.get (left_dom_of_div_dom hab) / b.get (right_dom_of_div_dom hab) :=\n  by simp [div_def]; aesop\n#align part.div_get_eq Part.div_get_eq\n#align part.sub_get_eq Part.sub_get_eq\n\n@[to_additive]\ntheorem some_div_some [Div α] (a b : α) : some a / some b = some (a / b) := by simp [div_def]\n#align part.some_div_some Part.some_div_some\n#align part.some_sub_some Part.some_sub_some\n\ntheorem mod_mem_mod [Mod α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma % mb ∈ a % b := by simp [mod_def]; aesop\n#align part.mod_mem_mod Part.mod_mem_mod\n\ntheorem left_dom_of_mod_dom [Mod α] {a b : Part α} (hab : Dom (a % b)) : a.Dom := hab.1\n#align part.left_dom_of_mod_dom Part.left_dom_of_mod_dom\n\ntheorem right_dom_of_mod_dom [Mod α] {a b : Part α} (hab : Dom (a % b)) : b.Dom := hab.2\n#align part.right_dom_of_mod_dom Part.right_dom_of_mod_dom\n\n@[simp]\ntheorem mod_get_eq [Mod α] (a b : Part α) (hab : Dom (a % b)) :\n    (a % b).get hab = a.get (left_dom_of_mod_dom hab) % b.get (right_dom_of_mod_dom hab) :=\n  by simp [mod_def]; aesop\n#align part.mod_get_eq Part.mod_get_eq\n\ntheorem some_mod_some [Mod α] (a b : α) : some a % some b = some (a % b) := by simp [mod_def]\n#align part.some_mod_some Part.some_mod_some\n\ntheorem append_mem_append [Append α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma ++ mb ∈ a ++ b := by simp [append_def]; aesop\n#align part.append_mem_append Part.append_mem_append\n\ntheorem left_dom_of_append_dom [Append α] {a b : Part α} (hab : Dom (a ++ b)) : a.Dom := hab.1\n#align part.left_dom_of_append_dom Part.left_dom_of_append_dom\n\ntheorem right_dom_of_append_dom [Append α] {a b : Part α} (hab : Dom (a ++ b)) : b.Dom := hab.2\n#align part.right_dom_of_append_dom Part.right_dom_of_append_dom\n\n@[simp]\ntheorem append_get_eq [Append α] (a b : Part α) (hab : Dom (a ++ b)) :\n    (a ++ b).get hab = a.get (left_dom_of_append_dom hab) ++ b.get (right_dom_of_append_dom hab) :=\n  by simp [append_def]; aesop\n#align part.append_get_eq Part.append_get_eq\n\ntheorem some_append_some [Append α] (a b : α) : some a ++ some b = some (a ++ b) :=\n  by simp [append_def]\n#align part.some_append_some Part.some_append_some\n\ntheorem inter_mem_inter [Inter α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma ∩ mb ∈ a ∩ b := by simp [inter_def]; aesop\n#align part.inter_mem_inter Part.inter_mem_inter\n\ntheorem left_dom_of_inter_dom [Inter α] {a b : Part α} (hab : Dom (a ∩ b)) : a.Dom := hab.1\n#align part.left_dom_of_inter_dom Part.left_dom_of_inter_dom\n\ntheorem right_dom_of_inter_dom [Inter α] {a b : Part α} (hab : Dom (a ∩ b)) : b.Dom := hab.2\n#align part.right_dom_of_inter_dom Part.right_dom_of_inter_dom\n\n@[simp]\ntheorem inter_get_eq [Inter α] (a b : Part α) (hab : Dom (a ∩ b)) :\n    (a ∩ b).get hab = a.get (left_dom_of_inter_dom hab) ∩ b.get (right_dom_of_inter_dom hab) :=\n  by simp [inter_def]; aesop\n#align part.inter_get_eq Part.inter_get_eq\n\ntheorem some_inter_some [Inter α] (a b : α) : some a ∩ some b = some (a ∩ b) :=\n  by simp [inter_def]\n#align part.some_inter_some Part.some_inter_some\n\ntheorem union_mem_union [Union α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma ∪ mb ∈ a ∪ b := by simp [union_def]; aesop\n#align part.union_mem_union Part.union_mem_union\n\ntheorem left_dom_of_union_dom [Union α] {a b : Part α} (hab : Dom (a ∪ b)) : a.Dom := hab.1\n#align part.left_dom_of_union_dom Part.left_dom_of_union_dom\n\ntheorem right_dom_of_union_dom [Union α] {a b : Part α} (hab : Dom (a ∪ b)) : b.Dom := hab.2\n#align part.right_dom_of_union_dom Part.right_dom_of_union_dom\n\n@[simp]\ntheorem union_get_eq [Union α] (a b : Part α) (hab : Dom (a ∪ b)) :\n    (a ∪ b).get hab = a.get (left_dom_of_union_dom hab) ∪ b.get (right_dom_of_union_dom hab) :=\n  by simp [union_def]; aesop\n#align part.union_get_eq Part.union_get_eq\n\ntheorem some_union_some [Union α] (a b : α) : some a ∪ some b = some (a ∪ b) := by simp [union_def]\n#align part.some_union_some Part.some_union_some\n\ntheorem sdiff_mem_sdiff [SDiff α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma \\ mb ∈ a \\ b := by simp [sdiff_def]; aesop\n#align part.sdiff_mem_sdiff Part.sdiff_mem_sdiff\n\ntheorem left_dom_of_sdiff_dom [SDiff α] {a b : Part α} (hab : Dom (a \\ b)) : a.Dom := hab.1\n#align part.left_dom_of_sdiff_dom Part.left_dom_of_sdiff_dom\n\ntheorem right_dom_of_sdiff_dom [SDiff α] {a b : Part α} (hab : Dom (a \\ b)) : b.Dom := hab.2\n#align part.right_dom_of_sdiff_dom Part.right_dom_of_sdiff_dom\n\n@[simp]\ntheorem sdiff_get_eq [SDiff α] (a b : Part α) (hab : Dom (a \\ b)) :\n    (a \\ b).get hab = a.get (left_dom_of_sdiff_dom hab) \\ b.get (right_dom_of_sdiff_dom hab) :=\n  by simp [sdiff_def]; aesop\n#align part.sdiff_get_eq Part.sdiff_get_eq\n\ntheorem some_sdiff_some [SDiff α] (a b : α) : some a \\ some b = some (a \\ b) := by simp [sdiff_def]\n#align part.some_sdiff_some Part.some_sdiff_some\n\nend Instances\n\nend Part\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Part.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.47452165628862747}}
{"text": "/-\nCopyright (c) 2020 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Floris van Doorn\n\n! This file was ported from Lean 3 source module logic.encodable.lattice\n! leanprover-community/mathlib commit f2f413b9d4be3a02840d0663dace76e8fe3da053\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Logic.Encodable.Basic\nimport Mathbin.Logic.Pairwise\n\n/-!\n# Lattice operations on encodable types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nLemmas about lattice and set operations on encodable types\n\n## Implementation Notes\n\nThis is a separate file, to avoid unnecessary imports in basic files.\n\nPreviously some of these results were in the `measure_theory` folder.\n-/\n\n\nopen Set\n\nnamespace Encodable\n\nvariable {α : Type _} {β : Type _} [Encodable β]\n\n/- warning: encodable.supr_decode₂ -> Encodable.supᵢ_decode₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Encodable.{u2} β] [_inst_2 : CompleteLattice.{u1} α] (f : β -> α), Eq.{succ u1} α (supᵢ.{u1, 1} α (CompleteSemilatticeSup.toHasSup.{u1} α (CompleteLattice.toCompleteSemilatticeSup.{u1} α _inst_2)) Nat (fun (i : Nat) => supᵢ.{u1, succ u2} α (CompleteSemilatticeSup.toHasSup.{u1} α (CompleteLattice.toCompleteSemilatticeSup.{u1} α _inst_2)) β (fun (b : β) => supᵢ.{u1, 0} α (CompleteSemilatticeSup.toHasSup.{u1} α (CompleteLattice.toCompleteSemilatticeSup.{u1} α _inst_2)) (Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 i)) (fun (H : Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 i)) => f b)))) (supᵢ.{u1, succ u2} α (CompleteSemilatticeSup.toHasSup.{u1} α (CompleteLattice.toCompleteSemilatticeSup.{u1} α _inst_2)) β (fun (b : β) => f b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Encodable.{u1} β] [_inst_2 : CompleteLattice.{u2} α] (f : β -> α), Eq.{succ u2} α (supᵢ.{u2, 1} α (CompleteLattice.toSupSet.{u2} α _inst_2) Nat (fun (i : Nat) => supᵢ.{u2, succ u1} α (CompleteLattice.toSupSet.{u2} α _inst_2) β (fun (b : β) => supᵢ.{u2, 0} α (CompleteLattice.toSupSet.{u2} α _inst_2) (Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 i)) (fun (H : Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 i)) => f b)))) (supᵢ.{u2, succ u1} α (CompleteLattice.toSupSet.{u2} α _inst_2) β (fun (b : β) => f b))\nCase conversion may be inaccurate. Consider using '#align encodable.supr_decode₂ Encodable.supᵢ_decode₂ₓ'. -/\ntheorem supᵢ_decode₂ [CompleteLattice α] (f : β → α) :\n    (⨆ (i : ℕ) (b ∈ decode₂ β i), f b) = ⨆ b, f b :=\n  by\n  rw [supᵢ_comm]\n  simp [mem_decode₂]\n#align encodable.supr_decode₂ Encodable.supᵢ_decode₂\n\n/- warning: encodable.Union_decode₂ -> Encodable.unionᵢ_decode₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Encodable.{u2} β] (f : β -> (Set.{u1} α)), Eq.{succ u1} (Set.{u1} α) (Set.unionᵢ.{u1, 1} α Nat (fun (i : Nat) => Set.unionᵢ.{u1, succ u2} α β (fun (b : β) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 i)) (fun (H : Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 i)) => f b)))) (Set.unionᵢ.{u1, succ u2} α β (fun (b : β) => f b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Encodable.{u1} β] (f : β -> (Set.{u2} α)), Eq.{succ u2} (Set.{u2} α) (Set.unionᵢ.{u2, 1} α Nat (fun (i : Nat) => Set.unionᵢ.{u2, succ u1} α β (fun (b : β) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 i)) (fun (H : Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 i)) => f b)))) (Set.unionᵢ.{u2, succ u1} α β (fun (b : β) => f b))\nCase conversion may be inaccurate. Consider using '#align encodable.Union_decode₂ Encodable.unionᵢ_decode₂ₓ'. -/\ntheorem unionᵢ_decode₂ (f : β → Set α) : (⋃ (i : ℕ) (b ∈ decode₂ β i), f b) = ⋃ b, f b :=\n  supᵢ_decode₂ f\n#align encodable.Union_decode₂ Encodable.unionᵢ_decode₂\n\n/- warning: encodable.Union_decode₂_cases -> Encodable.unionᵢ_decode₂_cases is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Encodable.{u2} β] {f : β -> (Set.{u1} α)} {C : (Set.{u1} α) -> Prop}, (C (EmptyCollection.emptyCollection.{u1} (Set.{u1} α) (Set.hasEmptyc.{u1} α))) -> (forall (b : β), C (f b)) -> (forall {n : Nat}, C (Set.unionᵢ.{u1, succ u2} α β (fun (b : β) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 n)) (fun (H : Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 n)) => f b))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Encodable.{u1} β] {f : β -> (Set.{u2} α)} {C : (Set.{u2} α) -> Prop}, (C (EmptyCollection.emptyCollection.{u2} (Set.{u2} α) (Set.instEmptyCollectionSet.{u2} α))) -> (forall (b : β), C (f b)) -> (forall {n : Nat}, C (Set.unionᵢ.{u2, succ u1} α β (fun (b : β) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 n)) (fun (H : Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 n)) => f b))))\nCase conversion may be inaccurate. Consider using '#align encodable.Union_decode₂_cases Encodable.unionᵢ_decode₂_casesₓ'. -/\n@[elab_as_elim]\ntheorem unionᵢ_decode₂_cases {f : β → Set α} {C : Set α → Prop} (H0 : C ∅) (H1 : ∀ b, C (f b)) {n} :\n    C (⋃ b ∈ decode₂ β n, f b) :=\n  match decode₂ β n with\n  | none => by\n    simp\n    apply H0\n  | some b => by\n    convert H1 b\n    simp [ext_iff]\n#align encodable.Union_decode₂_cases Encodable.unionᵢ_decode₂_cases\n\n/- warning: encodable.Union_decode₂_disjoint_on -> Encodable.unionᵢ_decode₂_disjoint_on is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Encodable.{u2} β] {f : β -> (Set.{u1} α)}, (Pairwise.{u2} β (Function.onFun.{succ u2, succ u1, 1} β (Set.{u1} α) Prop (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)))) f)) -> (Pairwise.{0} Nat (Function.onFun.{1, succ u1, 1} Nat (Set.{u1} α) Prop (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)))) (fun (i : Nat) => Set.unionᵢ.{u1, succ u2} α β (fun (b : β) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 i)) (fun (H : Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b (Encodable.decode₂.{u2} β _inst_1 i)) => f b)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Encodable.{u1} β] {f : β -> (Set.{u2} α)}, (Pairwise.{u1} β (Function.onFun.{succ u1, succ u2, 1} β (Set.{u2} α) Prop (Disjoint.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} α) (Preorder.toLE.{u2} (Set.{u2} α) (PartialOrder.toPreorder.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α))))))) f)) -> (Pairwise.{0} Nat (Function.onFun.{1, succ u2, 1} Nat (Set.{u2} α) Prop (Disjoint.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} α) (Preorder.toLE.{u2} (Set.{u2} α) (PartialOrder.toPreorder.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α))))))) (fun (i : Nat) => Set.unionᵢ.{u2, succ u1} α β (fun (b : β) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 i)) (fun (H : Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b (Encodable.decode₂.{u1} β _inst_1 i)) => f b)))))\nCase conversion may be inaccurate. Consider using '#align encodable.Union_decode₂_disjoint_on Encodable.unionᵢ_decode₂_disjoint_onₓ'. -/\ntheorem unionᵢ_decode₂_disjoint_on {f : β → Set α} (hd : Pairwise (Disjoint on f)) :\n    Pairwise (Disjoint on fun i => ⋃ b ∈ decode₂ β i, f b) :=\n  by\n  rintro i j ij\n  refine' disjoint_left.mpr fun x => _\n  suffices ∀ a, encode a = i → x ∈ f a → ∀ b, encode b = j → x ∉ f b by simpa [decode₂_eq_some]\n  rintro a rfl ha b rfl hb\n  exact (hd (mt (congr_arg encode) ij)).le_bot ⟨ha, hb⟩\n#align encodable.Union_decode₂_disjoint_on Encodable.unionᵢ_decode₂_disjoint_on\n\nend Encodable\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Logic/Encodable/Lattice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.4744733946458606}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.computability.partrec_code\nimport Mathlib.PostPort\n\nuniverses u_1 u_4 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Computability theory and the halting problem\n\nA universal partial recursive function, Rice's theorem, and the halting problem.\n\n## References\n\n* [Mario Carneiro, *Formalizing computability theory via partial recursive functions*][carneiro2019]\n-/\n\nnamespace nat.partrec\n\n\ntheorem merge' {f : ℕ →. ℕ} {g : ℕ →. ℕ} (hf : partrec f) (hg : partrec g) : ∃ (h : ℕ →. ℕ),\n  partrec h ∧\n    ∀ (a : ℕ), (∀ (x : ℕ), x ∈ h a → x ∈ f a ∨ x ∈ g a) ∧ (roption.dom (h a) ↔ roption.dom (f a) ∨ roption.dom (g a)) := sorry\n\nend nat.partrec\n\n\nnamespace partrec\n\n\ntheorem merge' {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {f : α →. σ} {g : α →. σ} (hf : partrec f) (hg : partrec g) : ∃ (k : α →. σ),\n  partrec k ∧\n    ∀ (a : α), (∀ (x : σ), x ∈ k a → x ∈ f a ∨ x ∈ g a) ∧ (roption.dom (k a) ↔ roption.dom (f a) ∨ roption.dom (g a)) := sorry\n\ntheorem merge {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {f : α →. σ} {g : α →. σ} (hf : partrec f) (hg : partrec g) (H : ∀ (a : α) (x : σ), x ∈ f a → ∀ (y : σ), y ∈ g a → x = y) : ∃ (k : α →. σ), partrec k ∧ ∀ (a : α) (x : σ), x ∈ k a ↔ x ∈ f a ∨ x ∈ g a := sorry\n\ntheorem cond {α : Type u_1} {σ : Type u_4} [primcodable α] [primcodable σ] {c : α → Bool} {f : α →. σ} {g : α →. σ} (hc : computable c) (hf : partrec f) (hg : partrec g) : partrec fun (a : α) => cond (c a) (f a) (g a) := sorry\n\ntheorem sum_cases {α : Type u_1} {β : Type u_2} {γ : Type u_3} {σ : Type u_4} [primcodable α] [primcodable β] [primcodable γ] [primcodable σ] {f : α → β ⊕ γ} {g : α → β →. σ} {h : α → γ →. σ} (hf : computable f) (hg : partrec₂ g) (hh : partrec₂ h) : partrec fun (a : α) => sum.cases_on (f a) (g a) (h a) := sorry\n\nend partrec\n\n\n/-- A computable predicate is one whose indicator function is computable. -/\ndef computable_pred {α : Type u_1} [primcodable α] (p : α → Prop) :=\n  Exists (computable fun (a : α) => to_bool (p a))\n\n/-- A recursively enumerable predicate is one which is the domain of a computable partial function.\n -/\ndef re_pred {α : Type u_1} [primcodable α] (p : α → Prop) :=\n  partrec fun (a : α) => roption.assert (p a) fun (_x : p a) => roption.some Unit.unit\n\ntheorem computable_pred.of_eq {α : Type u_1} [primcodable α] {p : α → Prop} {q : α → Prop} (hp : computable_pred p) (H : ∀ (a : α), p a ↔ q a) : computable_pred q :=\n  (funext fun (a : α) => propext (H a)) ▸ hp\n\nnamespace computable_pred\n\n\ntheorem computable_iff {α : Type u_1} [primcodable α] {p : α → Prop} : computable_pred p ↔ ∃ (f : α → Bool), computable f ∧ p = fun (a : α) => ↥(f a) := sorry\n\nprotected theorem not {α : Type u_1} [primcodable α] {p : α → Prop} (hp : computable_pred p) : computable_pred fun (a : α) => ¬p a := sorry\n\ntheorem to_re {α : Type u_1} [primcodable α] {p : α → Prop} (hp : computable_pred p) : re_pred p := sorry\n\ntheorem rice (C : set (ℕ →. ℕ)) (h : computable_pred fun (c : nat.partrec.code) => nat.partrec.code.eval c ∈ C) {f : ℕ →. ℕ} {g : ℕ →. ℕ} (hf : nat.partrec f) (hg : nat.partrec g) (fC : f ∈ C) : g ∈ C := sorry\n\ntheorem rice₂ (C : set nat.partrec.code) (H : ∀ (cf cg : nat.partrec.code), nat.partrec.code.eval cf = nat.partrec.code.eval cg → (cf ∈ C ↔ cg ∈ C)) : (computable_pred fun (c : nat.partrec.code) => c ∈ C) ↔ C = ∅ ∨ C = set.univ := sorry\n\ntheorem halting_problem (n : ℕ) : ¬computable_pred fun (c : nat.partrec.code) => roption.dom (nat.partrec.code.eval c n) :=\n  fun (ᾰ : computable_pred fun (c : nat.partrec.code) => roption.dom (nat.partrec.code.eval c n)) =>\n    idRhs ((fun (n : ℕ) => roption.none) ∈ set_of fun (f : ℕ →. ℕ) => roption.dom (f n))\n      (rice (set_of fun (f : ℕ →. ℕ) => roption.dom (f n)) ᾰ nat.partrec.zero nat.partrec.none trivial)\n\n-- Post's theorem on the equivalence of r.e., co-r.e. sets and\n\n-- computable sets. The assumption that p is decidable is required\n\n-- unless we assume Markov's principle or LEM.\n\ntheorem computable_iff_re_compl_re {α : Type u_1} [primcodable α] {p : α → Prop} [decidable_pred p] : computable_pred p ↔ re_pred p ∧ re_pred fun (a : α) => ¬p a := sorry\n\nend computable_pred\n\n\nnamespace nat\n\n\n/-- A simplified basis for `partrec`. -/\ninductive partrec' : {n : ℕ} → (vector ℕ n →. ℕ) → Prop\nwhere\n| prim : ∀ {n : ℕ} {f : vector ℕ n → ℕ}, primrec' f → partrec' ↑f\n| comp : ∀ {m n : ℕ} {f : vector ℕ n →. ℕ} (g : fin n → vector ℕ m →. ℕ),\n  partrec' f →\n    (∀ (i : fin n), partrec' (g i)) → partrec' fun (v : vector ℕ m) => (vector.m_of_fn fun (i : fin n) => g i v) >>= f\n| rfind : ∀ {n : ℕ} {f : vector ℕ (n + 1) → ℕ},\n  partrec' ↑f → partrec' fun (v : vector ℕ n) => rfind fun (n_1 : ℕ) => roption.some (to_bool (f (n_1::ᵥv) = 0))\n\nend nat\n\n\nnamespace nat.partrec'\n\n\ntheorem to_part {n : ℕ} {f : vector ℕ n →. ℕ} (pf : partrec' f) : partrec f := sorry\n\ntheorem of_eq {n : ℕ} {f : vector ℕ n →. ℕ} {g : vector ℕ n →. ℕ} (hf : partrec' f) (H : ∀ (i : vector ℕ n), f i = g i) : partrec' g :=\n  funext H ▸ hf\n\ntheorem of_prim {n : ℕ} {f : vector ℕ n → ℕ} (hf : primrec f) : partrec' ↑f :=\n  prim (primrec'.of_prim hf)\n\ntheorem head {n : ℕ} : partrec' ↑vector.head :=\n  prim primrec'.head\n\ntheorem tail {n : ℕ} {f : vector ℕ n →. ℕ} (hf : partrec' f) : partrec' fun (v : vector ℕ (Nat.succ n)) => f (vector.tail v) := sorry\n\nprotected theorem bind {n : ℕ} {f : vector ℕ n →. ℕ} {g : vector ℕ (n + 1) →. ℕ} (hf : partrec' f) (hg : partrec' g) : partrec' fun (v : vector ℕ n) => roption.bind (f v) fun (a : ℕ) => g (a::ᵥv) := sorry\n\nprotected theorem map {n : ℕ} {f : vector ℕ n →. ℕ} {g : vector ℕ (n + 1) → ℕ} (hf : partrec' f) (hg : partrec' ↑g) : partrec' fun (v : vector ℕ n) => roption.map (fun (a : ℕ) => g (a::ᵥv)) (f v) := sorry\n\n/-- Analogous to `nat.partrec'` for `ℕ`-valued functions, a predicate for partial recursive\n  vector-valued functions.-/\ndef vec {n : ℕ} {m : ℕ} (f : vector ℕ n → vector ℕ m) :=\n  ∀ (i : fin m), partrec' ↑fun (v : vector ℕ n) => vector.nth (f v) i\n\ntheorem vec.prim {n : ℕ} {m : ℕ} {f : vector ℕ n → vector ℕ m} (hf : primrec'.vec f) : vec f :=\n  fun (i : fin m) => prim (hf i)\n\nprotected theorem nil {n : ℕ} : vec fun (_x : vector ℕ n) => vector.nil :=\n  fun (i : fin 0) => fin.elim0 i\n\nprotected theorem cons {n : ℕ} {m : ℕ} {f : vector ℕ n → ℕ} {g : vector ℕ n → vector ℕ m} (hf : partrec' ↑f) (hg : vec g) : vec fun (v : vector ℕ n) => f v::ᵥg v := sorry\n\ntheorem idv {n : ℕ} : vec id :=\n  vec.prim primrec'.idv\n\ntheorem comp' {n : ℕ} {m : ℕ} {f : vector ℕ m →. ℕ} {g : vector ℕ n → vector ℕ m} (hf : partrec' f) (hg : vec g) : partrec' fun (v : vector ℕ n) => f (g v) := sorry\n\ntheorem comp₁ {n : ℕ} (f : ℕ →. ℕ) {g : vector ℕ n → ℕ} (hf : partrec' fun (v : vector ℕ 1) => f (vector.head v)) (hg : partrec' ↑g) : partrec' fun (v : vector ℕ n) => f (g v) := sorry\n\ntheorem rfind_opt {n : ℕ} {f : vector ℕ (n + 1) → ℕ} (hf : partrec' ↑f) : partrec' fun (v : vector ℕ n) => rfind_opt fun (a : ℕ) => denumerable.of_nat (Option ℕ) (f (a::ᵥv)) := sorry\n\ntheorem of_part {n : ℕ} {f : vector ℕ n →. ℕ} : partrec f → partrec' f := sorry\n\ntheorem part_iff {n : ℕ} {f : vector ℕ n →. ℕ} : partrec' f ↔ partrec f :=\n  { mp := to_part, mpr := of_part }\n\ntheorem part_iff₁ {f : ℕ →. ℕ} : (partrec' fun (v : vector ℕ 1) => f (vector.head v)) ↔ partrec f := sorry\n\ntheorem part_iff₂ {f : ℕ → ℕ →. ℕ} : (partrec' fun (v : vector ℕ (bit0 1)) => f (vector.head v) (vector.head (vector.tail v))) ↔ partrec₂ f := sorry\n\ntheorem vec_iff {m : ℕ} {n : ℕ} {f : vector ℕ m → vector ℕ n} : vec f ↔ computable f := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/computability/halting.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.47447337722257377}}
{"text": "import .defs\nimport .metric\nimport data.enat.basic\nimport tactic.basic\n\nuniverses u v w\n\nvariables {V V' V'' : Type u} (G : simple_graph V) (G' : simple_graph V') (G'' : simple_graph V'')\n\nopen simple_graph\n\n@[reducible]\ndef coarse_lipschitz_with (K : ℕ∞) (C : ℕ) (f : V → V') :=\n  ∀ ⦃x y : V⦄, ∀ ⦃a : ℕ∞⦄, G.edist x y < a → G'.edist (f x) (f y) < K * a + C\n\ndef coarse_equal_with (K : ℕ∞) (f g : V → V'):=\n  ∀ x : V, G'.edist (f x) (g x) < K\n\nnamespace coarse_lipschitz\n\nvariables {G} {G'}\n\n-- can be derived from `hom`\nprotected theorem id : coarse_lipschitz_with G G 1 0 id := by {\n  simp [coarse_lipschitz_with],\n}\n\ntheorem hom (φ : G →g G') : coarse_lipschitz_with G G' 1 0 φ := by {\n  intros x y a h,\n  cases le_iff_lt_or_eq.mp (simple_graph.hom.edist_le φ x y) with \n    hedist_lt hedist_eq,\n  { simp only [one_mul, algebra_map.coe_zero, add_zero],\n    exact lt_trans hedist_lt h, },\n  { simp only [h, hedist_eq, one_mul, algebra_map.coe_zero, add_zero], }}\n\ntheorem mono {f : V → V'} {K K' : ℕ∞} {C C' : ℕ} (hK : K ≤ K') (hC : C ≤ C')\n  (hf : coarse_lipschitz_with G G' K C f)\n  : coarse_lipschitz_with G G' K' C' f := by {\n    rw [coarse_lipschitz_with],\n    intros x y a hdist,\n    refine lt_of_le_of_lt' _ (hf hdist),\n    exact add_le_add (enat.mul_right_le hK) (with_top.coe_mono hC),\n  }\n\ntheorem comp (f : V → V') (g : V' → V'')\n  {K K' : ℕ∞} {C C' : ℕ}\n  (hf : coarse_lipschitz_with G G' K C f) (hg : coarse_lipschitz_with G' G'' K' C' g)\n  : coarse_lipschitz_with G G'' (K' * K) (K'.to_nat * C + C') (g ∘ f) := by {\n    intros _ _ a hdist,\n    refine lt_of_le_of_lt' _ (hg (hf hdist)),\n    rw [enat.coe_add, ← add_assoc, mul_add, ← mul_assoc, enat.coe_mul],\n    refine add_le_add _ (le_refl _),\n    by_cases h : K' = ⊤,\n    { subst h,\n      simp only [enat.top_mul_left, enat.top_add_left, top_le_iff], },\n    { rw [(enat.coe_to_nat_eq_self).mpr h],\n      exact le_refl _, }\n  }\n\ndef infty_wlog {P : (V → V') → Sort*} (C : ℕ) :\n  (∀ (f : V → V') (hf : coarse_lipschitz_with G G' ⊤ C f), P f) →\n  (∀ (f : V → V') (K : ℕ∞) (hf : coarse_lipschitz_with G G' K C f), P f) :=\nbegin\n  intros h f K hf,\n  apply h,\n  exact mono le_top (le_refl _) hf,\nend\n\ntheorem infty_iff (f : V → V') {C : ℕ} :\n  (coarse_lipschitz_with G G' ⊤ C f) ↔ (∀ x y : V, G.reachable x y → G'.reachable (f x) (f y)) := by {\n    simp_rw [simple_graph.reachable_iff_edist_lt_top],\n    split,\n    { intros hcoarse x y hdist,\n      refine lt_of_le_of_lt' _ (hcoarse hdist),\n      simp only [enat.top_mul_right, enat.top_add_left, top_le_iff],\n    },\n    { intros hreach _ _ _ hdist,\n      simp only [enat.top_mul_left, enat.top_add_left],\n      apply hreach,\n      exact lt_of_le_of_lt' le_top hdist,\n     }\n  }\n\ndef out_restrict {f : V → V'} {k : ℕ∞} {c : ℕ} (hf : coarse_lipschitz_with G G' k c f) (K : set V) :\n  coarse_lipschitz_with (G.induce Kᶜ) G' k c (f ∘ subtype.val) := by {\n    intros x y a hdist,\n    apply hf,\n    refine lt_of_le_of_lt _ hdist,\n    rw [G.val_of_out_val_hom, G.val_of_out_val_hom],\n    apply hom.edist_le, }\n\n-- the \"relative\" version of `out_restrict`\ndef out'_restrict {K K' : set V} (h : K ⊆ K') {f : ↥(K)ᶜ → V'} {k : ℕ∞} {c : ℕ}\n  (hf : coarse_lipschitz_with (G.out K) G' k c f) :\n    coarse_lipschitz_with (G.out K') G' k c (f ∘ (simple_graph.out_hom G h).to_fun) := by {\n      intros x y a hdist,\n      apply hf,\n      exact lt_of_le_of_lt (hom.edist_le (G.out_hom h) x y) hdist, }\n\ndef expand_out {L L' : set V'} (h : L ⊆ L') {f : V → ↥L'ᶜ} {k : ℕ∞} {c : ℕ}\n  (hf : coarse_lipschitz_with G (G'.out L') k c f) :\n  coarse_lipschitz_with G (G'.out L) k c ((induce_out id h) ∘ f) :=\n  -- TODO maybe replace `induce_out id h`\n    by { intros _ _ a hdist,\n      exact lt_of_le_of_lt (hom.edist_le (induce_out_hom hom.id h) (f x) (f y)) (hf hdist), }\n\ndef comp_map {f : V → V'} {k : ℕ∞} {c : ℕ} (hf : coarse_lipschitz_with G G' k c f) :\n  G.connected_component → G'.connected_component :=\n    simple_graph.connected_component.lift (λ v, G'.connected_component_mk (f v)) (by {\n      intros _ _ p _,\n      rw simple_graph.connected_component.eq,\n      apply (infty_iff f).mp,\n      refine mono le_top (nat.le_refl c) hf,\n      exact nonempty.intro p, })\n\n-- this could potentially be stated better using an \"absolute\" rather than a \"relative\" perspective\ntheorem up_comp {K K' : set V} (h : K ⊆ K') {f : ↥(K)ᶜ → V'} {k : ℕ∞} {c : ℕ}\n  (hf : coarse_lipschitz_with (G.out K) G' k c f) (C : G.comp_out K') :\n    comp_map hf (C.hom h) = comp_map (out'_restrict h hf) C := by {\n      refine C.ind _,\n      intros _ _,\n      dsimp [comp_out.hom, connected_component.map, comp_map],\n      congr, }\n\ntheorem comp_down {L L' : finset V'} (h : L ⊆ L') {f : V → ↥(↑L')ᶜ} {k : ℕ∞} {c : ℕ}\n  (hf : coarse_lipschitz_with G (G'.out L') k c f) {C : G.connected_component} :\n    comp_out.hom h (comp_map hf C) = (comp_map (expand_out h hf) C) := by {\n      refine C.ind _,\n      intro _,\n      dsimp [comp_out.hom, connected_component.map, comp_map],\n      congr,\n      apply subtype.eq,\n      simp, }\n\nend coarse_lipschitz\n\ndef induce_out (f : V → V') {K : set V} {L : set V'} (h : f⁻¹' L ⊆ K) : Kᶜ → Lᶜ :=\n  λ ⟨k, hk⟩, ⟨f k, λ hL, hk (h hL)⟩\n\n/-- The kind of map between graphs which induces a map on the ends. -/\nstructure coarse_map {V V' : Type u} (G : simple_graph V) (G' : simple_graph V') (φ : V → V') :=\n  (κ : ℕ∞) (C : ℕ)\n  (finset_mapping : finset V' → finset V)\n  (finset_inv_sub : ∀ L : finset V', φ ⁻¹' (L : set V') ⊆ (finset_mapping L : set V))\n  (induced_coarse_lipschitz : ∀ L : finset V',\n    coarse_lipschitz_with (G.induce (finset_mapping L)ᶜ) (G'.induce Lᶜ)\n      κ C (induce_out φ (finset_inv_sub L)))\n\n\n\n-- TODO maybe there can be a parametrized structure \"lifting\" any property of homomorphisms\n-- to its coarse version\nstructure coarse_close {V V' : Type u} (G : simple_graph V) (G' : simple_graph V') (f g : V → V') :=\n  (κ : ℕ∞)\n  (finset_mapping : finset V' → finset V)\n  (finset_inv_subl : ∀ L : finset V', f⁻¹' (L : set V') ⊆ (finset_mapping L : set V))\n  (finset_inv_subr : ∀ L : finset V', g⁻¹' (L : set V') ⊆ (finset_mapping L : set V))\n  (induced_coarse_equal : ∀ L : finset V', coarse_equal_with (G'.induce Lᶜ) κ\n    (induce_out f (finset_inv_subl L)) (induce_out g (finset_inv_subr L)))\n\nvariables {G} {G'}\n\n-- TODO Move this to `defs`\nlemma end_back {K K' : (finset V)ᵒᵖ} (h : K.unop ⊆ K'.unop) (e : G.end) :\n  e.val K = (e.val K').hom h := by {\n    symmetry,\n    exact e.property (category_theory.op_hom_of_le h),  }\n\ndef coarse_map.end_map [decidable_eq V] {f : V → V'} (fcoarse : coarse_map G G' f) : G.end → G'.end := by\n  {\n    rintro e,\n    refine ⟨λ L, _, _⟩,\n    let comp_map := coarse_lipschitz.comp_map (fcoarse.induced_coarse_lipschitz L.unop),\n    apply comp_map,\n    let Gcomp := e.val (opposite.op $ fcoarse.finset_mapping L.unop),\n    exact Gcomp,\n    { intros L L' hLL',\n      let K : (finset V)ᵒᵖ := opposite.op (\n        (fcoarse.finset_mapping L.unop) ∪ (fcoarse.finset_mapping L'.unop)),\n      have hL : (opposite.op $ fcoarse.finset_mapping L.unop).unop ⊆ K.unop := by {\n        simp only [opposite.unop_op], apply finset.subset_union_left, },\n      have hL' : (opposite.op $ fcoarse.finset_mapping L'.unop).unop ⊆ K.unop := by {\n        simp only [opposite.unop_op], apply finset.subset_union_right, },\n      dsimp,\n      rw [← subtype.val_eq_coe,\n      end_back hL e, end_back hL' e,\n      coarse_lipschitz.up_comp, coarse_lipschitz.up_comp],\n      dsimp [comp_out_functor],\n      rw [coarse_lipschitz.comp_down],\n      refl,\n    },\n  }\n\ndef coarse_close.left_coarse_map {f g : V → V'} (hclose : coarse_close G G' f g) : coarse_map G G' f := \n{ κ := hclose.κ,\n  C := 0,\n  finset_mapping := hclose.finset_mapping,\n  finset_inv_sub := hclose.finset_inv_subl,\n  induced_coarse_lipschitz := by {\n    intro L,\n    unfold coarse_lipschitz_with,\n    have := hclose.induced_coarse_equal L,\n    unfold coarse_equal_with at this,\n    sorry -- seems impossible, more assumptions needed\n  } }\n\ndef coarse_close.right_coarse_map {f g : V → V'} (hclose : coarse_close G G' f g) : coarse_map G G' g := sorry\n\nprivate lemma well_separated (G : simple_graph V) (Gpc : G.preconnected) (K : finset V) (m : ℕ)\n  (C : G.comp_out K)\n  (c : V) (cC : c ∈ C) (c' : V) :\n  c ∉ (G.closed_neighborhood K m) → G.edist c c' ≤ m → c' ∈ C :=\nbegin\n  rintro cnK,\n  sorry,\n/-rintro cnK,\n  obtain ⟨w,wm⟩ := reachable.exists_walk_of_dist (Gpc c c'), rw ←wm,\n  rintro hwm,\n  have wdisK : disjoint (w.support.to_finset : set V) K, by {\n    rw finset.disjoint_coe,\n    by_contradiction h, rw finset.not_disjoint_iff at h,\n    obtain ⟨x,xw,xK⟩ := h,\n    rw [list.mem_to_finset,walk.mem_support_iff_exists_append] at xw,\n    obtain ⟨cx,_,rfl⟩ := xw,\n    apply cnK,\n    dsimp only [thicken_],\n    simp only [finite.mem_to_finset, mem_set_of_eq, exists_prop],\n    use [x,xK],\n    apply (dist_le cx).trans,\n    refine le_trans _ hwm,\n    simp only [length_append, le_add_iff_nonneg_right, zero_le'],},\n\n  let Cw := comp_out.of_connected_disjoint (w.support.to_finset : set V) (connected.walk_support w) wdisK.symm,\n  have : C = Cw, by\n  { apply comp_out.eq_of_not_disjoint,\n    rw set.not_disjoint_iff,\n    use [c,cC],\n    apply comp_out.of_connected_disjoint_sub,\n    simp only [mem_coe, list.mem_to_finset, start_mem_support],},\n  rw this,\n  apply comp_out.of_connected_disjoint_sub,\n  simp only [mem_coe, list.mem_to_finset, end_mem_support], -/\nend\n\n\ndef coarse_equal.of_coarse_close [decidable_eq V] {f g : V → V'} {k : ℕ∞}\n  (fcoarse : coarse_map G G' f) (gcoarse : coarse_map G G' g)\n  (close : coarse_equal_with G' k f g)  : coarse_close G G' f g := \n  sorry -- TODO\n\ndef coarse_equal.end_equal [decidable_eq V] {f g : V → V'} {k : ℕ∞}\n  (fcoarse : coarse_map G G' f) (gcoarse : coarse_map G G' g)\n  (close : coarse_equal_with G' k f g) :\n  coarse_map.end_map fcoarse = coarse_map.end_map gcoarse := by {\n    dsimp [coarse_map.end_map],\n    ext e L,\n    dsimp,\n    let K : (finset V)ᵒᵖ := opposite.op (\n        (fcoarse.finset_mapping L.unop) ∪ (gcoarse.finset_mapping L.unop)),\n    have hfL : (opposite.op $ fcoarse.finset_mapping L.unop).unop ⊆ K.unop := sorry,\n    have hgL : (opposite.op $ gcoarse.finset_mapping L.unop).unop ⊆ K.unop := sorry,\n    rw [← subtype.val_eq_coe,\n    end_back hfL e, end_back hgL e,\n    coarse_lipschitz.up_comp, coarse_lipschitz.up_comp],\n\n    generalize : e.val K = C,\n    refine C.ind _,\n    intros v hv,\n    dsimp [coarse_lipschitz.comp_map],\n    rw [simple_graph.connected_component.eq, simple_graph.reachable_iff_edist_ne_top],\n    dsimp [induce_out],\n    have hyp := (coarse_equal.of_coarse_close fcoarse gcoarse close).induced_coarse_equal L.unop\n      ⟨v, sorry⟩,\n    dsimp [induce_out, coarse_equal_with] at hyp,\n    sorry, -- need `coarse_close`, not just `coarse_equal`\n  }", "meta": {"author": "0art0", "repo": "Freudenthal-Hopf", "sha": "1fefe94a6f0432686f21f97e4916efcbb81fec9d", "save_path": "github-repos/lean/0art0-Freudenthal-Hopf", "path": "github-repos/lean/0art0-Freudenthal-Hopf/Freudenthal-Hopf-1fefe94a6f0432686f21f97e4916efcbb81fec9d/src/functoriality.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4744733666490599}}
{"text": "example {a : Type u} {s t : list α} : length (s ++ t) = length s + length t :=\nlist.rec_on s\n(\n    -- length t = length [] + length t\n    -- length [] = 0 by definition\n    -- 0 + x = x by definition\n    show length ([] ++ t) = length [] + length t, from\n    begin\n        have z : [] ++ t = t, from rfl,\n        rw z,\n        have g : length [] = 0, from rfl,\n        assumption,\n        rw g,\n        rw zero_add,\n    end\n)\n(\n    λ x y z,\n    -- z : length (y ++ t) = length y + length t\n    show length (x :: y ++ t) = length (x :: y) + length t, from\n    begin\n        show length (x :: y ++ t) = ((length y) + 1) + length t,\n        have r : length (x :: y) = ((length y) + 1), refl,\n        -- unfinished\n    end\n)\n", "meta": {"author": "Or7ando", "repo": "group_representation", "sha": "9b576984f17764ebf26c8caa2a542d248f1b50d2", "save_path": "github-repos/lean/Or7ando-group_representation", "path": "github-repos/lean/Or7ando-group_representation/group_representation-9b576984f17764ebf26c8caa2a542d248f1b50d2/group_rep1/testre.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.47446709490779904}}
{"text": "import category_theory.limits.shapes.finite_products\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen category\n\nnamespace limits\n\nsection\n\nvariables {J₁ J₂ C : Type*} [category C] (X : J₂ → C) [has_product X] (e : J₁ ≃ J₂)\n\ndef fan_of_equiv : fan (X ∘ e) := fan.mk (∏ X)\n(λ j, pi.π _ (e j))\n\n@[simp]\nlemma fan_of_equiv_proj (j : J₁) : (fan_of_equiv X e).proj j = pi.π _ (e j) := rfl\n\nlemma fan.congr_proj {J : Type*} {F : J → C} (s : fan F)\n  {j₁ j₂ : J} (h : j₁ = j₂) : s.proj j₁ ≫ eq_to_hom (by rw h) = s.proj j₂ :=\nby { subst h, rw [eq_to_hom_refl, comp_id], }\n\nlemma cone.congr_π {J : Type*} [category J] {F : J ⥤ C} (s : cone F)\n  {j₁ j₂ : J} (h : j₁ = j₂) : s.π.app j₁ ≫ eq_to_hom (by rw h) = (s.π.app j₂ : s.X ⟶ _) :=\nby { subst h, rw [eq_to_hom_refl, comp_id], }\n\nlemma is_limit_fan_of_equiv : is_limit (fan_of_equiv X e) :=\nmk_fan_limit _ (λ s, pi.lift (λ j₂,s.proj (e.symm j₂) ≫ eq_to_hom (by simp)))\n(λ s j, begin\n  simp only [fan_of_equiv_proj, limit.lift_π, fan.mk_π_app],\n  exact fan.congr_proj _ (by simp),\nend)\n(λ s m hm, begin\n  ext j₂,\n  discrete_cases,\n  simp only [limit.lift_π, fan.mk_π_app, ← hm, assoc],\n  congr' 1,\n  dsimp,\n  symmetry,\n  have h : discrete.mk (e (e.symm j₂)) = discrete.mk j₂ := by simp,\n  apply cone.congr_π _ h,\nend)\n\nlemma has_product_of_equiv : has_product (X ∘ e) :=\n⟨nonempty.intro ⟨_, is_limit_fan_of_equiv X e⟩⟩\n\nlemma product_iso_of_equiv [has_product (X ∘ e)] : ∏ (X ∘ e) ≅ ∏ X :=\nis_limit.cone_point_unique_up_to_iso (limit.is_limit _) (is_limit_fan_of_equiv X e)\n\nend\n\nlemma product_iso_option {C J : Type*} [category C]\n  (X : option J → C) [has_product X] [has_product (λ j, X (some j))]\n  [has_binary_product (∏ (λ j, X (some j))) (X none)] :\n  (∏ X) ≅ (∏ (λ j, X (some j))) ⨯ (X none) :=\n{ hom := limits.prod.lift (pi.lift (λ j, pi.π _ (some j))) (pi.π _ none),\n  inv := pi.lift (by { rintro (_|j), exacts [prod.snd, prod.fst ≫ pi.π _ j], } ),\n  hom_inv_id' := begin\n    ext,\n    discrete_cases,\n    rcases j with (_|j),\n    { simp only [assoc, limit.lift_π, fan.mk_π_app, prod.lift_snd, id_comp], },\n    { simp only [assoc, limit.lift_π, fan.mk_π_app, prod.lift_fst_assoc, id_comp], },\n  end,\n  inv_hom_id' := begin\n    ext j,\n    { discrete_cases,\n      simp only [limit.lift_π, fan.mk_π_app, prod.lift_fst, assoc, id_comp], },\n    { simp only [prod.comp_lift, limit.lift_π, fan.mk_π_app, prod.lift_snd, id_comp], },\n  end, }\n\nend limits\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/limits/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4744280394877572}}
{"text": "/-\nCopyright (c) 2019 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.module.equiv\nimport data.bracket\nimport linear_algebra.basic\nimport tactic.noncomm_ring\n\n/-!\n# Lie algebras\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines Lie rings and Lie algebras over a commutative ring together with their\nmodules, morphisms and equivalences, as well as various lemmas to make these definitions usable.\n\n## Main definitions\n\n  * `lie_ring`\n  * `lie_algebra`\n  * `lie_ring_module`\n  * `lie_module`\n  * `lie_hom`\n  * `lie_equiv`\n  * `lie_module_hom`\n  * `lie_module_equiv`\n\n## Notation\n\nWorking over a fixed commutative ring `R`, we introduce the notations:\n * `L →ₗ⁅R⁆ L'` for a morphism of Lie algebras,\n * `L ≃ₗ⁅R⁆ L'` for an equivalence of Lie algebras,\n * `M →ₗ⁅R,L⁆ N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,\n * `M ≃ₗ⁅R,L⁆ N` for an equivalence of Lie algebra modules `M`, `N` over a Lie algebra `L`.\n\n## Implementation notes\n\nLie algebras are defined as modules with a compatible Lie ring structure and thus, like modules,\nare partially unbundled.\n\n## References\n* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975)\n\n## Tags\n\nlie bracket, jacobi identity, lie ring, lie algebra, lie module\n-/\n\nuniverses u v w w₁ w₂\nopen function\n\n/-- A Lie ring is an additive group with compatible product, known as the bracket, satisfying the\nJacobi identity. -/\n@[protect_proj] class lie_ring (L : Type v) extends add_comm_group L, has_bracket L L :=\n(add_lie  : ∀ (x y z : L), ⁅x + y, z⁆ = ⁅x, z⁆ + ⁅y, z⁆)\n(lie_add  : ∀ (x y z : L), ⁅x, y + z⁆ = ⁅x, y⁆ + ⁅x, z⁆)\n(lie_self : ∀ (x : L), ⁅x, x⁆ = 0)\n(leibniz_lie : ∀ (x y z : L), ⁅x, ⁅y, z⁆⁆ = ⁅⁅x, y⁆, z⁆ + ⁅y, ⁅x, z⁆⁆)\n\n/-- A Lie algebra is a module with compatible product, known as the bracket, satisfying the Jacobi\nidentity. Forgetting the scalar multiplication, every Lie algebra is a Lie ring. -/\n@[protect_proj] class lie_algebra (R : Type u) (L : Type v) [comm_ring R] [lie_ring L]\n  extends module R L :=\n(lie_smul : ∀ (t : R) (x y : L), ⁅x, t • y⁆ = t • ⁅x, y⁆)\n\n/-- A Lie ring module is an additive group, together with an additive action of a\nLie ring on this group, such that the Lie bracket acts as the commutator of endomorphisms.\n(For representations of Lie *algebras* see `lie_module`.) -/\n@[protect_proj] class lie_ring_module (L : Type v) (M : Type w)\n  [lie_ring L] [add_comm_group M] extends has_bracket L M :=\n(add_lie     : ∀ (x y : L) (m : M), ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆)\n(lie_add     : ∀ (x : L) (m n : M), ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆)\n(leibniz_lie : ∀ (x y : L) (m : M), ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆)\n\n/-- A Lie module is a module over a commutative ring, together with a linear action of a Lie\nalgebra on this module, such that the Lie bracket acts as the commutator of endomorphisms. -/\n@[protect_proj] class lie_module (R : Type u) (L : Type v) (M : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [add_comm_group M] [module R M]\n  [lie_ring_module L M] :=\n(smul_lie : ∀ (t : R) (x : L) (m : M), ⁅t • x, m⁆ = t • ⁅x, m⁆)\n(lie_smul : ∀ (t : R) (x : L) (m : M), ⁅x, t • m⁆ = t • ⁅x, m⁆)\n\nsection basic_properties\n\nvariables {R : Type u} {L : Type v} {M : Type w} {N : Type w₁}\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables [add_comm_group M] [module R M] [lie_ring_module L M] [lie_module R L M]\nvariables [add_comm_group N] [module R N] [lie_ring_module L N] [lie_module R L N]\nvariables (t : R) (x y z : L) (m n : M)\n\n@[simp] lemma add_lie : ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆ := lie_ring_module.add_lie x y m\n\n@[simp] lemma lie_add : ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆ := lie_ring_module.lie_add x m n\n\n@[simp] lemma smul_lie : ⁅t • x, m⁆ = t • ⁅x, m⁆ := lie_module.smul_lie t x m\n\n@[simp] lemma lie_smul : ⁅x, t • m⁆ = t • ⁅x, m⁆ := lie_module.lie_smul t x m\n\nlemma leibniz_lie : ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆ := lie_ring_module.leibniz_lie x y m\n\n@[simp] lemma lie_zero : ⁅x, 0⁆ = (0 : M) := (add_monoid_hom.mk' _ (lie_add x)).map_zero\n\n@[simp] lemma zero_lie : ⁅(0 : L), m⁆ = 0 :=\n(add_monoid_hom.mk' (λ (x : L), ⁅x, m⁆) (λ x y, add_lie x y m)).map_zero\n\n@[simp] lemma lie_self : ⁅x, x⁆ = 0 := lie_ring.lie_self x\n\ninstance lie_ring_self_module : lie_ring_module L L := { ..(infer_instance : lie_ring L) }\n\n@[simp] lemma lie_skew : -⁅y, x⁆ = ⁅x, y⁆ :=\nhave h : ⁅x + y, x⁆ + ⁅x + y, y⁆ = 0, { rw ← lie_add, apply lie_self, },\nby simpa [neg_eq_iff_add_eq_zero] using h\n\n/-- Every Lie algebra is a module over itself. -/\ninstance lie_algebra_self_module : lie_module R L L :=\n{ smul_lie := λ t x m, by rw [←lie_skew, ←lie_skew x m, lie_algebra.lie_smul, smul_neg],\n  lie_smul := by apply lie_algebra.lie_smul, }\n\n@[simp] lemma neg_lie : ⁅-x, m⁆ = -⁅x, m⁆ :=\nby { rw [←sub_eq_zero, sub_neg_eq_add, ←add_lie], simp, }\n\n@[simp] lemma lie_neg : ⁅x, -m⁆ = -⁅x, m⁆ :=\nby { rw [←sub_eq_zero, sub_neg_eq_add, ←lie_add], simp, }\n\n@[simp] lemma sub_lie : ⁅x - y, m⁆ = ⁅x, m⁆ - ⁅y, m⁆ :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma lie_sub : ⁅x, m - n⁆ = ⁅x, m⁆ - ⁅x, n⁆ :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma nsmul_lie (n : ℕ) : ⁅n • x, m⁆ = n • ⁅x, m⁆ :=\nadd_monoid_hom.map_nsmul ⟨λ (x : L), ⁅x, m⁆, zero_lie m, λ _ _, add_lie _ _ _⟩ _ _\n\n@[simp] lemma lie_nsmul (n : ℕ) : ⁅x, n • m⁆ = n • ⁅x, m⁆ :=\nadd_monoid_hom.map_nsmul ⟨λ (m : M), ⁅x, m⁆, lie_zero x, λ _ _, lie_add _ _ _⟩ _ _\n\n@[simp] lemma zsmul_lie (a : ℤ) : ⁅a • x, m⁆ = a • ⁅x, m⁆ :=\nadd_monoid_hom.map_zsmul ⟨λ (x : L), ⁅x, m⁆, zero_lie m, λ _ _, add_lie _ _ _⟩ _ _\n\n@[simp] lemma lie_zsmul (a : ℤ) : ⁅x, a • m⁆ = a • ⁅x, m⁆ :=\nadd_monoid_hom.map_zsmul ⟨λ (m : M), ⁅x, m⁆, lie_zero x, λ _ _, lie_add _ _ _⟩ _ _\n\n@[simp] lemma lie_lie : ⁅⁅x, y⁆, m⁆ = ⁅x, ⁅y, m⁆⁆ - ⁅y, ⁅x, m⁆⁆ :=\nby rw [leibniz_lie, add_sub_cancel]\n\nlemma lie_jacobi : ⁅x, ⁅y, z⁆⁆ + ⁅y, ⁅z, x⁆⁆ + ⁅z, ⁅x, y⁆⁆ = 0 :=\nby { rw [← neg_neg ⁅x, y⁆, lie_neg z, lie_skew y x, ← lie_skew, lie_lie], abel, }\n\ninstance lie_ring.int_lie_algebra : lie_algebra ℤ L :=\n{ lie_smul := λ n x y, lie_zsmul x y n, }\n\ninstance : lie_ring_module L (M →ₗ[R] N) :=\n{ bracket     := λ x f,\n  { to_fun    := λ m, ⁅x, f m⁆ - f ⁅x, m⁆,\n    map_add'  := λ m n, by { simp only [lie_add, linear_map.map_add], abel, },\n    map_smul' := λ t m, by simp only [smul_sub, linear_map.map_smul, lie_smul, ring_hom.id_apply] },\n  add_lie     := λ x y f, by\n    { ext n, simp only [add_lie, linear_map.coe_mk, linear_map.add_apply, linear_map.map_add],\n      abel, },\n  lie_add     := λ x f g, by\n    { ext n, simp only [linear_map.coe_mk, lie_add, linear_map.add_apply], abel, },\n  leibniz_lie := λ x y f, by\n    { ext n,\n      simp only [lie_lie, linear_map.coe_mk, linear_map.map_sub, linear_map.add_apply, lie_sub],\n      abel, }, }\n\n@[simp] lemma lie_hom.lie_apply (f : M →ₗ[R] N) (x : L) (m : M) :\n  ⁅x, f⁆ m = ⁅x, f m⁆ - f ⁅x, m⁆ :=\nrfl\n\ninstance : lie_module R L (M →ₗ[R] N) :=\n{ smul_lie := λ t x f, by\n    { ext n,\n      simp only [smul_sub, smul_lie, linear_map.smul_apply, lie_hom.lie_apply,\n        linear_map.map_smul], },\n  lie_smul := λ t x f, by\n    { ext n, simp only [smul_sub, linear_map.smul_apply, lie_hom.lie_apply, lie_smul], }, }\n\nend basic_properties\n\n/-- A morphism of Lie algebras is a linear map respecting the bracket operations. -/\nstructure lie_hom (R : Type u) (L : Type v) (L' : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [lie_ring L'] [lie_algebra R L']\n  extends L →ₗ[R] L' :=\n(map_lie' : ∀ {x y : L}, to_fun ⁅x, y⁆ = ⁅to_fun x, to_fun y⁆)\n\nattribute [nolint doc_blame] lie_hom.to_linear_map\n\nnotation L ` →ₗ⁅`:25 R:25 `⁆ `:0 L':0 := lie_hom R L L'\n\nnamespace lie_hom\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁}\nvariables [comm_ring R]\nvariables [lie_ring L₁] [lie_algebra R L₁]\nvariables [lie_ring L₂] [lie_algebra R L₂]\nvariables [lie_ring L₃] [lie_algebra R L₃]\n\ninstance : has_coe (L₁ →ₗ⁅R⁆ L₂) (L₁ →ₗ[R] L₂) := ⟨lie_hom.to_linear_map⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L₁ →ₗ⁅R⁆ L₂) (λ _, L₁ → L₂) := ⟨λ f, f.to_linear_map.to_fun⟩\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂ := h\n\ninitialize_simps_projections lie_hom (to_linear_map_to_fun → apply)\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : L₁ →ₗ⁅R⁆ L₂) : ((f : L₁ →ₗ[R] L₂) : L₁ → L₂) = f :=\nrfl\n\n@[simp] lemma to_fun_eq_coe (f : L₁ →ₗ⁅R⁆ L₂) : f.to_fun = ⇑f := rfl\n\n@[simp] lemma map_smul (f : L₁ →ₗ⁅R⁆ L₂) (c : R) (x : L₁) : f (c • x) = c • f x :=\nlinear_map.map_smul (f : L₁ →ₗ[R] L₂) c x\n\n@[simp] lemma map_add (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : L₁ →ₗ[R] L₂) x y\n\n@[simp] lemma map_sub (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : L₁ →ₗ[R] L₂) x y\n\n@[simp] lemma map_neg (f : L₁ →ₗ⁅R⁆ L₂) (x : L₁) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : L₁ →ₗ[R] L₂) x\n\n@[simp] lemma map_lie (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f ⁅x, y⁆ = ⁅f x, f y⁆ := lie_hom.map_lie' f\n\n@[simp] lemma map_zero (f : L₁ →ₗ⁅R⁆ L₂) : f 0 = 0 := (f : L₁ →ₗ[R] L₂).map_zero\n\n/-- The identity map is a morphism of Lie algebras. -/\ndef id : L₁ →ₗ⁅R⁆ L₁ :=\n{ map_lie' := λ x y, rfl,\n  .. (linear_map.id : L₁ →ₗ[R] L₁) }\n\n@[simp] lemma coe_id : ((id : L₁ →ₗ⁅R⁆ L₁) : L₁ → L₁) = _root_.id := rfl\n\nlemma id_apply (x : L₁) : (id : L₁ →ₗ⁅R⁆ L₁) x = x := rfl\n\n/-- The constant 0 map is a Lie algebra morphism. -/\ninstance : has_zero (L₁ →ₗ⁅R⁆ L₂) := ⟨{ map_lie' := by simp, ..(0 : L₁ →ₗ[R] L₂)}⟩\n\n@[norm_cast, simp] lemma coe_zero : ((0 : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = 0 := rfl\n\nlemma zero_apply (x : L₁) : (0 : L₁ →ₗ⁅R⁆ L₂) x = 0 := rfl\n\n/-- The identity map is a Lie algebra morphism. -/\ninstance : has_one (L₁ →ₗ⁅R⁆ L₁) := ⟨id⟩\n\n@[simp] lemma coe_one : ((1 : (L₁ →ₗ⁅R⁆ L₁)) : L₁ → L₁) = _root_.id := rfl\n\nlemma one_apply (x : L₁) : (1 : (L₁ →ₗ⁅R⁆ L₁)) x = x := rfl\n\ninstance : inhabited (L₁ →ₗ⁅R⁆ L₂) := ⟨0⟩\n\nlemma coe_injective : @function.injective (L₁ →ₗ⁅R⁆ L₂) (L₁ → L₂) coe_fn :=\nby rintro ⟨⟨f, _⟩⟩ ⟨⟨g, _⟩⟩ ⟨h⟩; congr\n\n@[ext] lemma ext {f g : L₁ →ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : L₁ →ₗ⁅R⁆ L₂} : f = g ↔ ∀ x, f x = g x :=\n⟨by { rintro rfl x, refl }, ext⟩\n\nlemma congr_fun {f g : L₁ →ₗ⁅R⁆ L₂} (h : f = g) (x : L₁) : f x = g x := h ▸ rfl\n\n@[simp] lemma mk_coe (f : L₁ →ₗ⁅R⁆ L₂) (h₁ h₂ h₃) :\n  (⟨⟨f, h₁, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : L₁ → L₂) (h₁ h₂ h₃) :\n  ((⟨⟨f, h₁, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = f := rfl\n\n/-- The composition of morphisms is a morphism. -/\ndef comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) : L₁ →ₗ⁅R⁆ L₃ :=\n{ map_lie' := λ x y, by { change f (g ⁅x, y⁆) = ⁅f (g x), f (g y)⁆, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) (x : L₁) :\n  f.comp g x = f (g x) := rfl\n\n@[norm_cast, simp]\nlemma coe_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) :\n  (f.comp g : L₁ → L₃) = f ∘ g :=\nrfl\n\n@[norm_cast, simp]\nlemma coe_linear_map_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) :\n  (f.comp g : L₁ →ₗ[R] L₃) = (f : L₂ →ₗ[R] L₃).comp (g : L₁ →ₗ[R] L₂) :=\nrfl\n\n@[simp] lemma comp_id (f : L₁ →ₗ⁅R⁆ L₂) : f.comp (id : L₁ →ₗ⁅R⁆ L₁) = f :=\nby { ext, refl, }\n\n@[simp] lemma id_comp (f : L₁ →ₗ⁅R⁆ L₂) : (id : L₂ →ₗ⁅R⁆ L₂).comp f = f :=\nby { ext, refl, }\n\n/-- The inverse of a bijective morphism is a morphism. -/\ndef inverse (f : L₁ →ₗ⁅R⁆ L₂) (g : L₂ → L₁)\n  (h₁ : function.left_inverse g f) (h₂ : function.right_inverse g f) : L₂ →ₗ⁅R⁆ L₁ :=\n{ map_lie' := λ x y,\n  calc g ⁅x, y⁆ = g ⁅f (g x), f (g y)⁆ : by { conv_lhs { rw [←h₂ x, ←h₂ y], }, }\n            ... = g (f ⁅g x, g y⁆) : by rw map_lie\n            ... = ⁅g x, g y⁆ : (h₁ _),\n  ..linear_map.inverse f.to_linear_map g h₁ h₂ }\n\nend lie_hom\n\nsection module_pull_back\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} (M : Type w₁)\nvariables [comm_ring R]  [lie_ring L₁] [lie_algebra R L₁] [lie_ring L₂] [lie_algebra R L₂]\nvariables [add_comm_group M] [lie_ring_module L₂ M]\nvariables (f : L₁ →ₗ⁅R⁆ L₂)\ninclude f\n\n/-- A Lie ring module may be pulled back along a morphism of Lie algebras.\n\nSee note [reducible non-instances]. -/\n@[reducible]\ndef lie_ring_module.comp_lie_hom : lie_ring_module L₁ M :=\n{ bracket     := λ x m, ⁅f x, m⁆,\n  lie_add     := λ x, lie_add (f x),\n  add_lie     := λ x y m, by simp only [lie_hom.map_add, add_lie],\n  leibniz_lie := λ x y m, by simp only [lie_lie, sub_add_cancel, lie_hom.map_lie], }\n\nlemma lie_ring_module.comp_lie_hom_apply (x : L₁) (m : M) :\n  by haveI := lie_ring_module.comp_lie_hom M f; exact\n  ⁅x, m⁆ = ⁅f x, m⁆ :=\nrfl\n\n/-- A Lie module may be pulled back along a morphism of Lie algebras.\n\nSee note [reducible non-instances]. -/\n@[reducible]\ndef lie_module.comp_lie_hom [module R M] [lie_module R L₂ M] :\n  @lie_module R L₁ M _ _ _ _ _ (lie_ring_module.comp_lie_hom M f) :=\n{ smul_lie := λ t x m, by simp only [smul_lie, lie_hom.map_smul],\n  lie_smul := λ t x m, by simp only [lie_smul], }\n\nend module_pull_back\n\n/-- An equivalence of Lie algebras is a morphism which is also a linear equivalence. We could\ninstead define an equivalence to be a morphism which is also a (plain) equivalence. However it is\nmore convenient to define via linear equivalence to get `.to_linear_equiv` for free. -/\nstructure lie_equiv (R : Type u) (L : Type v) (L' : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [lie_ring L'] [lie_algebra R L']\n  extends L →ₗ⁅R⁆ L' :=\n(inv_fun   : L' → L)\n(left_inv  : function.left_inverse inv_fun to_lie_hom.to_fun)\n(right_inv : function.right_inverse inv_fun to_lie_hom.to_fun)\n\nattribute [nolint doc_blame] lie_equiv.to_lie_hom\n\nnotation L ` ≃ₗ⁅`:50 R `⁆ ` L' := lie_equiv R L L'\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁}\nvariables [comm_ring R] [lie_ring L₁] [lie_ring L₂] [lie_ring L₃]\nvariables [lie_algebra R L₁] [lie_algebra R L₂] [lie_algebra R L₃]\n\n/-- Consider an equivalence of Lie algebras as a linear equivalence. -/\ndef to_linear_equiv (f : L₁ ≃ₗ⁅R⁆ L₂) : L₁ ≃ₗ[R] L₂ := { ..f.to_lie_hom, ..f }\n\ninstance has_coe_to_lie_hom : has_coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ →ₗ⁅R⁆ L₂) := ⟨to_lie_hom⟩\ninstance has_coe_to_linear_equiv : has_coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ ≃ₗ[R] L₂) := ⟨to_linear_equiv⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L₁ ≃ₗ⁅R⁆ L₂) (λ _, L₁ → L₂) := ⟨λ e, e.to_lie_hom.to_fun⟩\n\n@[simp, norm_cast] lemma coe_to_lie_hom (e : L₁ ≃ₗ⁅R⁆ L₂) : ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = e :=\nrfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : L₁ ≃ₗ⁅R⁆ L₂) :\n  ((e : L₁ ≃ₗ[R] L₂) : L₁ → L₂) = e := rfl\n\n@[simp] lemma to_linear_equiv_mk (f : L₁ →ₗ⁅R⁆ L₂) (g h₁ h₂) :\n  (mk f g h₁ h₂ : L₁ ≃ₗ[R] L₂) = { inv_fun := g, left_inv := h₁, right_inv := h₂, .. f } := rfl\n\nlemma coe_linear_equiv_injective : injective (coe : (L₁ ≃ₗ⁅R⁆ L₂) → (L₁ ≃ₗ[R] L₂)) :=\nbegin\n  intros f₁ f₂ h, cases f₁, cases f₂, dsimp at h, simp only at h,\n  congr, exacts [lie_hom.coe_injective h.1, h.2]\nend\n\nlemma coe_injective : @injective (L₁ ≃ₗ⁅R⁆ L₂) (L₁ → L₂) coe_fn :=\nlinear_equiv.coe_injective.comp coe_linear_equiv_injective\n\n@[ext] lemma ext {f g : L₁ ≃ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g := coe_injective $ funext h\n\ninstance : has_one (L₁ ≃ₗ⁅R⁆ L₁) :=\n⟨{ map_lie' := λ x y, rfl,\n  ..(1 : L₁ ≃ₗ[R] L₁)}⟩\n\n@[simp] lemma one_apply (x : L₁) : (1 : (L₁ ≃ₗ⁅R⁆ L₁)) x = x := rfl\n\ninstance : inhabited (L₁ ≃ₗ⁅R⁆ L₁) := ⟨1⟩\n\n/-- Lie algebra equivalences are reflexive. -/\n@[refl]\ndef refl : L₁ ≃ₗ⁅R⁆ L₁ := 1\n\n@[simp] lemma refl_apply (x : L₁) : (refl : L₁ ≃ₗ⁅R⁆ L₁) x = x := rfl\n\n/-- Lie algebra equivalences are symmetric. -/\n@[symm]\ndef symm (e : L₁ ≃ₗ⁅R⁆ L₂) : L₂ ≃ₗ⁅R⁆ L₁ :=\n{ ..lie_hom.inverse e.to_lie_hom e.inv_fun e.left_inv e.right_inv,\n  ..e.to_linear_equiv.symm }\n\n@[simp] lemma symm_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.symm = e :=\nby { ext, refl }\n\n@[simp] lemma apply_symm_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n@[simp]\n\n\n/-- Lie algebra equivalences are transitive. -/\n@[trans]\ndef trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) : L₁ ≃ₗ⁅R⁆ L₃ :=\n{ ..lie_hom.comp e₂.to_lie_hom e₁.to_lie_hom,\n  ..linear_equiv.trans e₁.to_linear_equiv e₂.to_linear_equiv }\n\n@[simp] lemma self_trans_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.trans e.symm = refl :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.trans e = refl :=\ne.symm.self_trans_symm\n\n@[simp] lemma trans_apply (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) (x : L₁) :\n  (e₁.trans e₂) x = e₂ (e₁ x) := rfl\n\n@[simp] lemma symm_trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) :\n  (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl\n\nprotected lemma bijective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.bijective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.bijective\n\nprotected lemma injective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.injective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.injective\n\nprotected lemma surjective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.surjective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.surjective\n\n/-- A bijective morphism of Lie algebras yields an equivalence of Lie algebras. -/\n@[simps] noncomputable def of_bijective (f : L₁ →ₗ⁅R⁆ L₂)\n  (h : function.bijective f) : L₁ ≃ₗ⁅R⁆ L₂ :=\n{ to_fun   := f,\n  map_lie' := f.map_lie,\n  .. (linear_equiv.of_bijective (f : L₁ →ₗ[R] L₂) h), }\n\nend lie_equiv\n\nsection lie_module_morphisms\n\nvariables (R : Type u) (L : Type v) (M : Type w) (N : Type w₁) (P : Type w₂)\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables [add_comm_group M] [add_comm_group N] [add_comm_group P]\nvariables [module R M] [module R N] [module R P]\nvariables [lie_ring_module L M] [lie_ring_module L N] [lie_ring_module L P]\nvariables [lie_module R L M] [lie_module R L N] [lie_module R L P]\n\n/-- A morphism of Lie algebra modules is a linear map which commutes with the action of the Lie\nalgebra. -/\nstructure lie_module_hom extends M →ₗ[R] N :=\n(map_lie' : ∀ {x : L} {m : M}, to_fun ⁅x, m⁆ = ⁅x, to_fun m⁆)\n\nattribute [nolint doc_blame] lie_module_hom.to_linear_map\n\nnotation M ` →ₗ⁅`:25 R,L:25 `⁆ `:0 N:0 := lie_module_hom R L M N\n\nnamespace lie_module_hom\n\nvariables {R L M N P}\n\ninstance : has_coe (M →ₗ⁅R,L⁆ N) (M →ₗ[R] N) := ⟨lie_module_hom.to_linear_map⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M →ₗ⁅R,L⁆ N) (λ _, M → N) := ⟨λ f, f.to_linear_map.to_fun⟩\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : M →ₗ⁅R,L⁆ N) : ((f : M →ₗ[R] N) : M → N) = f :=\nrfl\n\n@[simp] lemma map_smul (f : M →ₗ⁅R,L⁆ N) (c : R) (x : M) : f (c • x) = c • f x :=\nlinear_map.map_smul (f : M →ₗ[R] N) c x\n\n@[simp] lemma map_add (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : M →ₗ[R] N) x y\n\n@[simp] lemma map_sub (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : M →ₗ[R] N) x y\n\n@[simp] lemma map_neg (f : M →ₗ⁅R,L⁆ N) (x : M) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : M →ₗ[R] N) x\n\n@[simp] lemma map_lie (f : M →ₗ⁅R,L⁆ N) (x : L) (m : M) : f ⁅x, m⁆ = ⁅x, f m⁆ :=\nlie_module_hom.map_lie' f\n\nlemma map_lie₂ (f : M →ₗ⁅R,L⁆ N →ₗ[R] P) (x : L) (m : M) (n : N) :\n  ⁅x, f m n⁆ = f ⁅x, m⁆ n + f m ⁅x, n⁆ :=\nby simp only [sub_add_cancel, map_lie, lie_hom.lie_apply]\n\n@[simp] lemma map_zero (f : M →ₗ⁅R,L⁆ N) : f 0 = 0 :=\nlinear_map.map_zero (f : M →ₗ[R] N)\n\n/-- The identity map is a morphism of Lie modules. -/\ndef id : M →ₗ⁅R,L⁆ M :=\n{ map_lie' := λ x m, rfl,\n  .. (linear_map.id : M →ₗ[R] M) }\n\n@[simp] lemma coe_id : ((id : M →ₗ⁅R,L⁆ M) : M → M) = _root_.id := rfl\n\nlemma id_apply (x : M) : (id : M →ₗ⁅R,L⁆ M) x = x := rfl\n\n/-- The constant 0 map is a Lie module morphism. -/\ninstance : has_zero (M →ₗ⁅R,L⁆ N) := ⟨{ map_lie' := by simp, ..(0 : M →ₗ[R] N) }⟩\n\n@[norm_cast, simp] lemma coe_zero : ((0 : M →ₗ⁅R,L⁆ N) : M → N) = 0 := rfl\n\nlemma zero_apply (m : M) : (0 : M →ₗ⁅R,L⁆ N) m = 0 := rfl\n\n/-- The identity map is a Lie module morphism. -/\ninstance : has_one (M →ₗ⁅R,L⁆ M) := ⟨id⟩\n\ninstance : inhabited (M →ₗ⁅R,L⁆ N) := ⟨0⟩\n\nlemma coe_injective : @function.injective (M →ₗ⁅R,L⁆ N) (M → N) coe_fn :=\nby { rintros ⟨⟨f, _⟩⟩ ⟨⟨g, _⟩⟩ ⟨h⟩, congr, }\n\n@[ext] lemma ext {f g : M →ₗ⁅R,L⁆ N} (h : ∀ m, f m = g m) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : M →ₗ⁅R,L⁆ N} : f = g ↔ ∀ m, f m = g m :=\n⟨by { rintro rfl m, refl, }, ext⟩\n\nlemma congr_fun {f g : M →ₗ⁅R,L⁆ N} (h : f = g) (x : M) : f x = g x := h ▸ rfl\n\n@[simp] lemma mk_coe (f : M →ₗ⁅R,L⁆ N) (h) :\n  (⟨f, h⟩ : M →ₗ⁅R,L⁆ N) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : M →ₗ[R] N) (h) :\n  ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M → N) = f :=\nby { ext, refl, }\n\n@[norm_cast, simp] lemma coe_linear_mk (f : M →ₗ[R] N) (h) :\n  ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M →ₗ[R] N) = f :=\nby { ext, refl, }\n\n/-- The composition of Lie module morphisms is a morphism. -/\ndef comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) : M →ₗ⁅R,L⁆ P :=\n{ map_lie' := λ x m, by { change f (g ⁅x, m⁆) = ⁅x, f (g m)⁆, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) (m : M) :\n  f.comp g m = f (g m) := rfl\n\n@[norm_cast, simp] lemma coe_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) :\n  (f.comp g : M → P) = f ∘ g :=\nrfl\n\n@[norm_cast, simp] lemma coe_linear_map_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) :\n  (f.comp g : M →ₗ[R] P) = (f : N →ₗ[R] P).comp (g : M →ₗ[R] N) :=\nrfl\n\n/-- The inverse of a bijective morphism of Lie modules is a morphism of Lie modules. -/\ndef inverse (f : M →ₗ⁅R,L⁆ N) (g : N → M)\n  (h₁ : function.left_inverse g f) (h₂ : function.right_inverse g f) : N →ₗ⁅R,L⁆ M :=\n{ map_lie' := λ x n,\n    calc g ⁅x, n⁆ = g ⁅x, f (g n)⁆ : by rw h₂\n              ... = g (f ⁅x, g n⁆) : by rw map_lie\n              ... = ⁅x, g n⁆ : (h₁ _),\n  ..linear_map.inverse f.to_linear_map g h₁ h₂ }\n\ninstance : has_add (M →ₗ⁅R,L⁆ N) :=\n{ add := λ f g, { map_lie' := by simp, ..((f : M →ₗ[R] N) + (g : M →ₗ[R] N)) }, }\n\ninstance : has_sub (M →ₗ⁅R,L⁆ N) :=\n{ sub := λ f g, { map_lie' := by simp, ..((f : M →ₗ[R] N) - (g : M →ₗ[R] N)) }, }\n\ninstance : has_neg (M →ₗ⁅R,L⁆ N) :=\n{ neg := λ f, { map_lie' := by simp, ..(-(f : (M →ₗ[R] N))) }, }\n\n@[norm_cast, simp] lemma coe_add (f g : M →ₗ⁅R,L⁆ N) : ⇑(f + g) = f + g := rfl\n\nlemma add_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f + g) m = f m + g m := rfl\n\n@[norm_cast, simp] lemma coe_sub (f g : M →ₗ⁅R,L⁆ N) : ⇑(f - g) = f - g := rfl\n\nlemma sub_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f - g) m = f m - g m := rfl\n\n@[norm_cast, simp] lemma coe_neg (f : M →ₗ⁅R,L⁆ N) : ⇑(-f) = -f := rfl\n\nlemma neg_apply (f : M →ₗ⁅R,L⁆ N) (m : M) : (-f) m = -(f m) := rfl\n\ninstance has_nsmul : has_smul ℕ (M →ₗ⁅R,L⁆ N) :=\n{ smul := λ n f, { map_lie' := λ x m, by simp, ..(n • (f : M →ₗ[R] N)) } }\n\n@[norm_cast, simp] lemma coe_nsmul (n : ℕ) (f : M →ₗ⁅R,L⁆ N) : ⇑(n • f) = n • f := rfl\n\nlemma nsmul_apply (n : ℕ) (f : M →ₗ⁅R,L⁆ N) (m : M) : (n • f) m = n • f m := rfl\n\ninstance has_zsmul : has_smul ℤ (M →ₗ⁅R,L⁆ N) :=\n{ smul := λ z f, { map_lie' := λ x m, by simp, ..(z • (f : M →ₗ[R] N)) } }\n\n@[norm_cast, simp] lemma coe_zsmul (z : ℤ) (f : M →ₗ⁅R,L⁆ N) : ⇑(z • f) = z • f := rfl\n\nlemma zsmul_apply (z : ℤ) (f : M →ₗ⁅R,L⁆ N) (m : M) : (z • f) m = z • f m := rfl\n\ninstance : add_comm_group (M →ₗ⁅R,L⁆ N) :=\ncoe_injective.add_comm_group _\n  coe_zero coe_add coe_neg coe_sub (λ _ _, coe_nsmul _ _) (λ _ _, coe_zsmul _ _)\n\ninstance : has_smul R (M →ₗ⁅R,L⁆ N) :=\n{ smul := λ t f, { map_lie' := by simp, ..(t • (f : M →ₗ[R] N)) }, }\n\n@[norm_cast, simp] lemma coe_smul (t : R) (f : M →ₗ⁅R,L⁆ N) : ⇑(t • f) = t • f := rfl\n\nlemma smul_apply (t : R) (f : M →ₗ⁅R,L⁆ N) (m : M) : (t • f) m = t • (f m) := rfl\n\ninstance : module R (M →ₗ⁅R,L⁆ N) :=\nfunction.injective.module R ⟨λ f, f.to_linear_map.to_fun, rfl, coe_add⟩ coe_injective coe_smul\n\nend lie_module_hom\n\n/-- An equivalence of Lie algebra modules is a linear equivalence which is also a morphism of\nLie algebra modules. -/\nstructure lie_module_equiv extends M →ₗ⁅R,L⁆ N :=\n(inv_fun   : N → M)\n(left_inv  : function.left_inverse inv_fun to_fun)\n(right_inv : function.right_inverse inv_fun to_fun)\n\nattribute [nolint doc_blame] lie_module_equiv.to_lie_module_hom\n\nnotation M ` ≃ₗ⁅`:25 R,L:25 `⁆ `:0 N:0 := lie_module_equiv R L M N\n\nnamespace lie_module_equiv\n\nvariables {R L M N P}\n\n/-- View an equivalence of Lie modules as a linear equivalence. -/\n@[ancestor]\ndef to_linear_equiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ₗ[R] N := { ..e }\n\n/-- View an equivalence of Lie modules as a type level equivalence. -/\n@[ancestor]\ndef to_equiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ N := { ..e }\n\ninstance has_coe_to_equiv : has_coe (M ≃ₗ⁅R,L⁆ N) (M ≃ N) := ⟨to_equiv⟩\ninstance has_coe_to_lie_module_hom : has_coe (M ≃ₗ⁅R,L⁆ N) (M →ₗ⁅R,L⁆ N) := ⟨to_lie_module_hom⟩\ninstance has_coe_to_linear_equiv : has_coe (M ≃ₗ⁅R,L⁆ N) (M ≃ₗ[R] N) := ⟨to_linear_equiv⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M ≃ₗ⁅R,L⁆ N) (λ _, M → N) := ⟨λ e, e.to_lie_module_hom.to_fun⟩\n\nlemma injective (e : M ≃ₗ⁅R,L⁆ N) : function.injective e := e.to_equiv.injective\n\n@[simp] lemma coe_mk (f : M →ₗ⁅R,L⁆ N) (inv_fun h₁ h₂) :\n  ((⟨f, inv_fun, h₁, h₂⟩ : M ≃ₗ⁅R,L⁆ N) : M → N) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_lie_module_hom (e : M ≃ₗ⁅R,L⁆ N) :\n  ((e : M →ₗ⁅R,L⁆ N) : M → N) = e := rfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : M ≃ₗ⁅R,L⁆ N) : ((e : M ≃ₗ[R] N) : M → N) = e :=\nrfl\n\nlemma to_equiv_injective : function.injective (to_equiv : (M ≃ₗ⁅R,L⁆ N) → M ≃ N) :=\nλ e₁ e₂ h, begin\n  rcases e₁ with ⟨⟨⟩⟩, rcases e₂ with ⟨⟨⟩⟩,\n  have inj := equiv.mk.inj h,\n  dsimp at inj,\n  apply lie_module_equiv.mk.inj_eq.mpr,\n  split,\n  { congr,\n    ext,\n    rw inj.1 },\n  { exact inj.2 },\nend\n\n@[ext] lemma ext (e₁ e₂ : M ≃ₗ⁅R,L⁆ N) (h : ∀ m, e₁ m = e₂ m) : e₁ = e₂ :=\nto_equiv_injective (equiv.ext h)\n\ninstance : has_one (M ≃ₗ⁅R,L⁆ M) := ⟨{ map_lie' := λ x m, rfl, ..(1 : M ≃ₗ[R] M) }⟩\n\n@[simp] lemma one_apply (m : M) : (1 : (M ≃ₗ⁅R,L⁆ M)) m = m := rfl\n\ninstance : inhabited (M ≃ₗ⁅R,L⁆ M) := ⟨1⟩\n\n/-- Lie module equivalences are reflexive. -/\n@[refl] def refl : M ≃ₗ⁅R,L⁆ M := 1\n\n@[simp] lemma refl_apply (m : M) : (refl : M ≃ₗ⁅R,L⁆ M) m = m := rfl\n\n/-- Lie module equivalences are syemmtric. -/\n@[symm] def symm (e : M ≃ₗ⁅R,L⁆ N) : N ≃ₗ⁅R,L⁆ M :=\n{ ..lie_module_hom.inverse e.to_lie_module_hom e.inv_fun e.left_inv e.right_inv,\n  ..(e : M ≃ₗ[R] N).symm }\n\n@[simp] lemma apply_symm_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n@[simp] lemma symm_symm (e : M ≃ₗ⁅R,L⁆ N) : e.symm.symm = e :=\nby { ext, apply_fun e.symm using e.symm.injective, simp, }\n\n/-- Lie module equivalences are transitive. -/\n@[trans] def trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) : M ≃ₗ⁅R,L⁆ P :=\n{ ..lie_module_hom.comp e₂.to_lie_module_hom e₁.to_lie_module_hom,\n  ..linear_equiv.trans e₁.to_linear_equiv e₂.to_linear_equiv }\n\n@[simp] lemma trans_apply (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) (m : M) :\n  (e₁.trans e₂) m = e₂ (e₁ m) := rfl\n\n@[simp] lemma symm_trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) :\n  (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl\n\n@[simp] lemma self_trans_symm (e : M ≃ₗ⁅R,L⁆ N) : e.trans e.symm = refl :=\next _ _ e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : M ≃ₗ⁅R,L⁆ N) : e.symm.trans e = refl :=\next _ _ e.apply_symm_apply\n\nend lie_module_equiv\n\nend lie_module_morphisms\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/lie/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.47427285129627383}}
{"text": "/-\nCopyright (c) 2021 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module algebraic_geometry.presheafed_space.gluing\n! leanprover-community/mathlib commit d39590fc8728fbf6743249802486f8c91ffe07bc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Topology.Gluing\nimport Mathbin.AlgebraicGeometry.OpenImmersion\nimport Mathbin.AlgebraicGeometry.LocallyRingedSpace.HasColimits\n\n/-!\n# Gluing Structured spaces\n\nGiven a family of gluing data of structured spaces (presheafed spaces, sheafed spaces, or locally\nringed spaces), we may glue them together.\n\nThe construction should be \"sealed\" and considered as a black box, while only using the API\nprovided.\n\n## Main definitions\n\n* `algebraic_geometry.PresheafedSpace.glue_data`: A structure containing the family of gluing data.\n* `category_theory.glue_data.glued`: The glued presheafed space.\n    This is defined as the multicoequalizer of `∐ V i j ⇉ ∐ U i`, so that the general colimit API\n    can be used.\n* `category_theory.glue_data.ι`: The immersion `ι i : U i ⟶ glued` for each `i : J`.\n\n## Main results\n\n* `algebraic_geometry.PresheafedSpace.glue_data.ι_is_open_immersion`: The map `ι i : U i ⟶ glued`\n  is an open immersion for each `i : J`.\n* `algebraic_geometry.PresheafedSpace.glue_data.ι_jointly_surjective` : The underlying maps of\n  `ι i : U i ⟶ glued` are jointly surjective.\n* `algebraic_geometry.PresheafedSpace.glue_data.V_pullback_cone_is_limit` : `V i j` is the pullback\n  (intersection) of `U i` and `U j` over the glued space.\n\nAnalogous results are also provided for `SheafedSpace` and `LocallyRingedSpace`.\n\n## Implementation details\n\nAlmost the whole file is dedicated to showing tht `ι i` is an open immersion. The fact that\nthis is an open embedding of topological spaces follows from `topology.gluing.lean`, and it remains\nto construct `Γ(𝒪_{U_i}, U) ⟶ Γ(𝒪_X, ι i '' U)` for each `U ⊆ U i`.\nSince `Γ(𝒪_X, ι i '' U)` is the the limit of `diagram_over_open`, the components of the structure\nsheafs of the spaces in the gluing diagram, we need to construct a map\n`ι_inv_app_π_app : Γ(𝒪_{U_i}, U) ⟶ Γ(𝒪_V, U_V)` for each `V` in the gluing diagram.\n\nWe will refer to ![this diagram](https://i.imgur.com/P0phrwr.png) in the following doc strings.\nThe `X` is the glued space, and the dotted arrow is a partial inverse guaranteed by the fact\nthat it is an open immersion. The map `Γ(𝒪_{U_i}, U) ⟶ Γ(𝒪_{U_j}, _)` is given by the composition\nof the red arrows, and the map `Γ(𝒪_{U_i}, U) ⟶ Γ(𝒪_{V_{jk}}, _)` is given by the composition of the\nblue arrows. To lift this into a map from `Γ(𝒪_X, ι i '' U)`, we also need to show that these\ncommute with the maps in the diagram (the green arrows), which is just a lengthy diagram-chasing.\n\n-/\n\n\nnoncomputable section\n\nopen TopologicalSpace CategoryTheory Opposite\n\nopen CategoryTheory.Limits AlgebraicGeometry.PresheafedSpace\n\nopen CategoryTheory.GlueData\n\nnamespace AlgebraicGeometry\n\nuniverse v u\n\nvariable (C : Type u) [Category.{v} C]\n\nnamespace PresheafedSpace\n\n/-- A family of gluing data consists of\n1. An index type `J`\n2. A presheafed space `U i` for each `i : J`.\n3. A presheafed space `V i j` for each `i j : J`.\n  (Note that this is `J × J → PresheafedSpace C` rather than `J → J → PresheafedSpace C` to\n  connect to the limits library easier.)\n4. An open immersion `f i j : V i j ⟶ U i` for each `i j : ι`.\n5. A transition map `t i j : V i j ⟶ V j i` for each `i j : ι`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some\n    `t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`.\n9. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`.\n\nWe can then glue the spaces `U i` together by identifying `V i j` with `V j i`, such\nthat the `U i`'s are open subspaces of the glued space.\n-/\n@[nolint has_nonempty_instance]\nstructure GlueData extends GlueData (PresheafedSpace.{v} C) where\n  f_open : ∀ i j, IsOpenImmersion (f i j)\n#align algebraic_geometry.PresheafedSpace.glue_data AlgebraicGeometry.PresheafedSpace.GlueData\n\nattribute [instance] glue_data.f_open\n\nnamespace GlueData\n\nvariable {C} (D : GlueData C)\n\n-- mathport name: «expr𝖣»\nlocal notation \"𝖣\" => D.toGlueData\n\n-- mathport name: «exprπ₁ , , »\nlocal notation \"π₁ \" i \", \" j \", \" k => @pullback.fst _ _ _ _ _ (D.f i j) (D.f i k) _\n\n-- mathport name: «exprπ₂ , , »\nlocal notation \"π₂ \" i \", \" j \", \" k => @pullback.snd _ _ _ _ _ (D.f i j) (D.f i k) _\n\n-- mathport name: «exprπ₁⁻¹ , , »\nlocal notation \"π₁⁻¹ \" i \", \" j \", \" k =>\n  (PresheafedSpace.IsOpenImmersion.pullbackFstOfRight (D.f i j) (D.f i k)).invApp\n\n-- mathport name: «exprπ₂⁻¹ , , »\nlocal notation \"π₂⁻¹ \" i \", \" j \", \" k =>\n  (PresheafedSpace.IsOpenImmersion.pullbackSndOfLeft (D.f i j) (D.f i k)).invApp\n\n/-- The glue data of topological spaces associated to a family of glue data of PresheafedSpaces. -/\nabbrev toTopGlueData : TopCat.GlueData :=\n  { f_open := fun i j => (D.f_open i j).base_open\n    toGlueData := 𝖣.mapGlueData (forget C) }\n#align algebraic_geometry.PresheafedSpace.glue_data.to_Top_glue_data AlgebraicGeometry.PresheafedSpace.GlueData.toTopGlueData\n\ntheorem ι_openEmbedding [HasLimits C] (i : D.J) : OpenEmbedding (𝖣.ι i).base :=\n  by\n  rw [← show _ = (𝖣.ι i).base from 𝖣.ι_gluedIso_inv (PresheafedSpace.forget _) _]\n  exact\n    OpenEmbedding.comp\n      (TopCat.homeoOfIso (𝖣.gluedIso (PresheafedSpace.forget _)).symm).OpenEmbedding\n      (D.to_Top_glue_data.ι_open_embedding i)\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_open_embedding AlgebraicGeometry.PresheafedSpace.GlueData.ι_openEmbedding\n\ntheorem pullback_base (i j k : D.J) (S : Set (D.V (i, j)).carrier) :\n    (π₂ i, j, k) '' ((π₁ i, j, k) ⁻¹' S) = D.f i k ⁻¹' (D.f i j '' S) :=\n  by\n  have eq₁ : _ = (π₁ i, j, k).base := preserves_pullback.iso_hom_fst (forget C) _ _\n  have eq₂ : _ = (π₂ i, j, k).base := preserves_pullback.iso_hom_snd (forget C) _ _\n  rw [coe_to_fun_eq, coe_to_fun_eq, ← eq₁, ← eq₂, coe_comp, Set.image_comp, coe_comp,\n    Set.preimage_comp, Set.image_preimage_eq, TopCat.pullback_snd_image_fst_preimage]\n  rfl\n  rw [← TopCat.epi_iff_surjective]\n  infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.pullback_base AlgebraicGeometry.PresheafedSpace.GlueData.pullback_base\n\n/-- The red and the blue arrows in ![this diagram](https://i.imgur.com/0GiBUh6.png) commute. -/\n@[simp, reassoc.1]\ntheorem f_invApp_f_app (i j k : D.J) (U : Opens (D.V (i, j)).carrier) :\n    (D.f_open i j).invApp U ≫ (D.f i k).c.app _ =\n      (π₁ i, j, k).c.app (op U) ≫\n        (π₂⁻¹ i, j, k) (unop _) ≫\n          (D.V _).Presheaf.map\n            (eqToHom\n              (by\n                delta is_open_immersion.open_functor\n                dsimp only [functor.op, IsOpenMap.functor, opens.map, unop_op]\n                congr\n                apply pullback_base)) :=\n  by\n  have := PresheafedSpace.congr_app (@pullback.condition _ _ _ _ _ (D.f i j) (D.f i k) _)\n  dsimp only [comp_c_app] at this\n  rw [← cancel_epi (inv ((D.f_open i j).invApp U)), is_iso.inv_hom_id_assoc,\n    is_open_immersion.inv_inv_app]\n  simp_rw [category.assoc]\n  erw [(π₁ i, j, k).c.naturality_assoc, reassoc_of this, ← functor.map_comp_assoc,\n    is_open_immersion.inv_naturality_assoc, is_open_immersion.app_inv_app_assoc, ←\n    (D.V (i, k)).Presheaf.map_comp, ← (D.V (i, k)).Presheaf.map_comp]\n  convert(category.comp_id _).symm\n  erw [(D.V (i, k)).Presheaf.map_id]\n  rfl\n#align algebraic_geometry.PresheafedSpace.glue_data.f_inv_app_f_app AlgebraicGeometry.PresheafedSpace.GlueData.f_invApp_f_app\n\n/-- We can prove the `eq` along with the lemma. Thus this is bundled together here, and the\nlemma itself is separated below.\n-/\ntheorem snd_invApp_t_app' (i j k : D.J) (U : Opens (pullback (D.f i j) (D.f i k)).carrier) :\n    ∃ eq,\n      (π₂⁻¹ i, j, k) U ≫ (D.t k i).c.app _ ≫ (D.V (k, i)).Presheaf.map (eqToHom Eq) =\n        (D.t' k i j).c.app _ ≫ (π₁⁻¹ k, j, i) (unop _) :=\n  by\n  constructor\n  rw [← is_iso.eq_inv_comp, is_open_immersion.inv_inv_app, category.assoc,\n    (D.t' k i j).c.naturality_assoc]\n  simp_rw [← category.assoc]\n  erw [← comp_c_app]\n  rw [congr_app (D.t_fac k i j), comp_c_app]\n  simp_rw [category.assoc]\n  erw [is_open_immersion.inv_naturality, is_open_immersion.inv_naturality_assoc,\n    is_open_immersion.app_inv_app'_assoc]\n  simp_rw [← (𝖣.V (k, i)).Presheaf.map_comp, eq_to_hom_map (functor.op _), eq_to_hom_op,\n    eq_to_hom_trans]\n  rintro x ⟨y, hy, eq⟩\n  replace eq := concrete_category.congr_arg (𝖣.t i k).base Eq\n  change ((π₂ i, j, k) ≫ D.t i k).base y = (D.t k i ≫ D.t i k).base x at eq\n  rw [𝖣.t_inv, id_base, TopCat.id_app] at eq\n  subst Eq\n  use (inv (D.t' k i j)).base y\n  change (inv (D.t' k i j) ≫ π₁ k, i, j).base y = _\n  congr 2\n  rw [is_iso.inv_comp_eq, 𝖣.t_fac_assoc, 𝖣.t_inv, category.comp_id]\n#align algebraic_geometry.PresheafedSpace.glue_data.snd_inv_app_t_app' AlgebraicGeometry.PresheafedSpace.GlueData.snd_invApp_t_app'\n\n/-- The red and the blue arrows in ![this diagram](https://i.imgur.com/q6X1GJ9.png) commute. -/\n@[simp, reassoc.1]\ntheorem snd_invApp_t_app (i j k : D.J) (U : Opens (pullback (D.f i j) (D.f i k)).carrier) :\n    (π₂⁻¹ i, j, k) U ≫ (D.t k i).c.app _ =\n      (D.t' k i j).c.app _ ≫\n        (π₁⁻¹ k, j, i) (unop _) ≫\n          (D.V (k, i)).Presheaf.map (eqToHom (D.snd_invApp_t_app' i j k U).some.symm) :=\n  by\n  have e := (D.snd_inv_app_t_app' i j k U).choose_spec\n  reassoc! e\n  rw [← e]\n  simp [eq_to_hom_map]\n#align algebraic_geometry.PresheafedSpace.glue_data.snd_inv_app_t_app AlgebraicGeometry.PresheafedSpace.GlueData.snd_invApp_t_app\n\nvariable [HasLimits C]\n\ntheorem ι_image_preimage_eq (i j : D.J) (U : Opens (D.U i).carrier) :\n    (Opens.map (𝖣.ι j).base).obj ((D.ι_openEmbedding i).IsOpenMap.Functor.obj U) =\n      (D.f_open j i).openFunctor.obj\n        ((Opens.map (𝖣.t j i).base).obj ((Opens.map (𝖣.f i j).base).obj U)) :=\n  by\n  ext1\n  dsimp only [opens.map_coe, IsOpenMap.functor_obj_coe]\n  rw [← show _ = (𝖣.ι i).base from 𝖣.ι_gluedIso_inv (PresheafedSpace.forget _) i, ←\n    show _ = (𝖣.ι j).base from 𝖣.ι_gluedIso_inv (PresheafedSpace.forget _) j, coe_comp, coe_comp,\n    Set.image_comp, Set.preimage_comp, Set.preimage_image_eq]\n  refine' Eq.trans (D.to_Top_glue_data.preimage_image_eq_image' _ _ _) _\n  rw [coe_comp, Set.image_comp]\n  congr 1\n  erw [Set.eq_preimage_iff_image_eq]\n  rw [← Set.image_comp]\n  change (D.t i j ≫ D.t j i).base '' _ = _\n  rw [𝖣.t_inv]\n  · simp\n  · change Function.Bijective (TopCat.homeoOfIso (as_iso _))\n    exact Homeomorph.bijective _\n    infer_instance\n  · rw [← TopCat.mono_iff_injective]\n    infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_image_preimage_eq AlgebraicGeometry.PresheafedSpace.GlueData.ι_image_preimage_eq\n\n/-- (Implementation). The map `Γ(𝒪_{U_i}, U) ⟶ Γ(𝒪_{U_j}, 𝖣.ι j ⁻¹' (𝖣.ι i '' U))` -/\ndef opensImagePreimageMap (i j : D.J) (U : Opens (D.U i).carrier) :\n    (D.U i).Presheaf.obj (op U) ⟶ (D.U j).Presheaf.obj _ :=\n  (D.f i j).c.app (op U) ≫\n    (D.t j i).c.app _ ≫\n      (D.f_open j i).invApp (unop _) ≫\n        (𝖣.U j).Presheaf.map (eqToHom (D.ι_image_preimage_eq i j U)).op\n#align algebraic_geometry.PresheafedSpace.glue_data.opens_image_preimage_map AlgebraicGeometry.PresheafedSpace.GlueData.opensImagePreimageMap\n\ntheorem opensImagePreimageMap_app' (i j k : D.J) (U : Opens (D.U i).carrier) :\n    ∃ eq,\n      D.opensImagePreimageMap i j U ≫ (D.f j k).c.app _ =\n        ((π₁ j, i, k) ≫ D.t j i ≫ D.f i j).c.app (op U) ≫\n          (π₂⁻¹ j, i, k) (unop _) ≫ (D.V (j, k)).Presheaf.map (eqToHom Eq) :=\n  by\n  constructor\n  delta opens_image_preimage_map\n  simp_rw [category.assoc]\n  rw [(D.f j k).c.naturality, f_inv_app_f_app_assoc]\n  erw [← (D.V (j, k)).Presheaf.map_comp]\n  simp_rw [← category.assoc]\n  erw [← comp_c_app, ← comp_c_app]\n  simp_rw [category.assoc]\n  dsimp only [functor.op, unop_op, Quiver.Hom.unop_op]\n  rw [eq_to_hom_map (opens.map _), eq_to_hom_op, eq_to_hom_trans]\n  congr\n#align algebraic_geometry.PresheafedSpace.glue_data.opens_image_preimage_map_app' AlgebraicGeometry.PresheafedSpace.GlueData.opensImagePreimageMap_app'\n\n/-- The red and the blue arrows in ![this diagram](https://i.imgur.com/mBzV1Rx.png) commute. -/\ntheorem opensImagePreimageMap_app (i j k : D.J) (U : Opens (D.U i).carrier) :\n    D.opensImagePreimageMap i j U ≫ (D.f j k).c.app _ =\n      ((π₁ j, i, k) ≫ D.t j i ≫ D.f i j).c.app (op U) ≫\n        (π₂⁻¹ j, i, k) (unop _) ≫\n          (D.V (j, k)).Presheaf.map (eqToHom (opensImagePreimageMap_app' D i j k U).some) :=\n  (opensImagePreimageMap_app' D i j k U).choose_spec\n#align algebraic_geometry.PresheafedSpace.glue_data.opens_image_preimage_map_app AlgebraicGeometry.PresheafedSpace.GlueData.opensImagePreimageMap_app\n\n-- This is proved separately since `reassoc` somehow timeouts.\ntheorem opensImagePreimageMap_app_assoc (i j k : D.J) (U : Opens (D.U i).carrier) {X' : C}\n    (f' : _ ⟶ X') :\n    D.opensImagePreimageMap i j U ≫ (D.f j k).c.app _ ≫ f' =\n      ((π₁ j, i, k) ≫ D.t j i ≫ D.f i j).c.app (op U) ≫\n        (π₂⁻¹ j, i, k) (unop _) ≫\n          (D.V (j, k)).Presheaf.map (eqToHom (opensImagePreimageMap_app' D i j k U).some) ≫ f' :=\n  by\n  simpa only [category.assoc] using\n    congr_arg (fun g => g ≫ f') (opens_image_preimage_map_app D i j k U)\n#align algebraic_geometry.PresheafedSpace.glue_data.opens_image_preimage_map_app_assoc AlgebraicGeometry.PresheafedSpace.GlueData.opensImagePreimageMap_app_assoc\n\n/-- (Implementation) Given an open subset of one of the spaces `U ⊆ Uᵢ`, the sheaf component of\nthe image `ι '' U` in the glued space is the limit of this diagram. -/\nabbrev diagramOverOpen {i : D.J} (U : Opens (D.U i).carrier) : (WalkingMultispan _ _)ᵒᵖ ⥤ C :=\n  componentwiseDiagram 𝖣.diagram.multispan ((D.ι_openEmbedding i).IsOpenMap.Functor.obj U)\n#align algebraic_geometry.PresheafedSpace.glue_data.diagram_over_open AlgebraicGeometry.PresheafedSpace.GlueData.diagramOverOpen\n\n/-- (Implementation)\nThe projection from the limit of `diagram_over_open` to a component of `D.U j`. -/\nabbrev diagramOverOpenπ {i : D.J} (U : Opens (D.U i).carrier) (j : D.J) :=\n  limit.π (D.diagramOverOpen U) (op (WalkingMultispan.right j))\n#align algebraic_geometry.PresheafedSpace.glue_data.diagram_over_open_π AlgebraicGeometry.PresheafedSpace.GlueData.diagramOverOpenπ\n\n/-- (Implementation) We construct the map `Γ(𝒪_{U_i}, U) ⟶ Γ(𝒪_V, U_V)` for each `V` in the gluing\ndiagram. We will lift these maps into `ι_inv_app`. -/\ndef ιInvAppπApp {i : D.J} (U : Opens (D.U i).carrier) (j) :\n    (𝖣.U i).Presheaf.obj (op U) ⟶ (D.diagramOverOpen U).obj (op j) :=\n  by\n  rcases j with (⟨j, k⟩ | j)\n  · refine'\n      D.opens_image_preimage_map i j U ≫ (D.f j k).c.app _ ≫ (D.V (j, k)).Presheaf.map (eq_to_hom _)\n    rw [functor.op_obj]\n    congr 1\n    ext1\n    dsimp only [functor.op_obj, opens.map_coe, unop_op, IsOpenMap.functor_obj_coe]\n    rw [Set.preimage_preimage]\n    change (D.f j k ≫ 𝖣.ι j).base ⁻¹' _ = _\n    congr 3\n    exact colimit.w 𝖣.diagram.multispan (walking_multispan.hom.fst (j, k))\n  · exact D.opens_image_preimage_map i j U\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_inv_app_π_app AlgebraicGeometry.PresheafedSpace.GlueData.ιInvAppπApp\n\n/-- (Implementation) The natural map `Γ(𝒪_{U_i}, U) ⟶ Γ(𝒪_X, 𝖣.ι i '' U)`.\nThis forms the inverse of `(𝖣.ι i).c.app (op U)`. -/\ndef ιInvApp {i : D.J} (U : Opens (D.U i).carrier) :\n    (D.U i).Presheaf.obj (op U) ⟶ limit (D.diagramOverOpen U) :=\n  limit.lift (D.diagramOverOpen U)\n    { pt := (D.U i).Presheaf.obj (op U)\n      π :=\n        { app := fun j => D.ιInvAppπApp U (unop j)\n          naturality' := fun X Y f' => by\n            induction X using Opposite.rec\n            induction Y using Opposite.rec\n            let f : Y ⟶ X := f'.unop\n            have : f' = f.op := rfl\n            clear_value f\n            subst this\n            rcases f with (_ | ⟨j, k⟩ | ⟨j, k⟩)\n            · erw [category.id_comp, CategoryTheory.Functor.map_id]\n              rw [category.comp_id]\n            · erw [category.id_comp]\n              congr 1\n            erw [category.id_comp]\n            -- It remains to show that the blue is equal to red + green in the original diagram.\n            -- The proof strategy is illustrated in ![this diagram](https://i.imgur.com/mBzV1Rx.png)\n            -- where we prove red = pink = light-blue = green = blue.\n            change\n              D.opens_image_preimage_map i j U ≫\n                  (D.f j k).c.app _ ≫ (D.V (j, k)).Presheaf.map (eq_to_hom _) =\n                D.opens_image_preimage_map _ _ _ ≫\n                  ((D.f k j).c.app _ ≫ (D.t j k).c.app _) ≫ (D.V (j, k)).Presheaf.map (eq_to_hom _)\n            erw [opens_image_preimage_map_app_assoc]\n            simp_rw [category.assoc]\n            erw [opens_image_preimage_map_app_assoc, (D.t j k).c.naturality_assoc]\n            rw [snd_inv_app_t_app_assoc]\n            erw [← PresheafedSpace.comp_c_app_assoc]\n            -- light-blue = green is relatively easy since the part that differs does not involve\n            -- partial inverses.\n            have :\n              D.t' j k i ≫ (π₁ k, i, j) ≫ D.t k i ≫ 𝖣.f i k =\n                (pullback_symmetry _ _).Hom ≫ (π₁ j, i, k) ≫ D.t j i ≫ D.f i j :=\n              by\n              rw [← 𝖣.t_fac_assoc, 𝖣.t'_comp_eq_pullbackSymmetry_assoc,\n                pullback_symmetry_hom_comp_snd_assoc, pullback.condition, 𝖣.t_fac_assoc]\n            rw [congr_app this]\n            erw [PresheafedSpace.comp_c_app_assoc (pullback_symmetry _ _).Hom]\n            simp_rw [category.assoc]\n            congr 1\n            rw [← is_iso.eq_inv_comp]\n            erw [is_open_immersion.inv_inv_app]\n            simp_rw [category.assoc]\n            erw [nat_trans.naturality_assoc, ← PresheafedSpace.comp_c_app_assoc,\n              congr_app (pullback_symmetry_hom_comp_snd _ _)]\n            simp_rw [category.assoc]\n            erw [is_open_immersion.inv_naturality_assoc, is_open_immersion.inv_naturality_assoc,\n              is_open_immersion.inv_naturality_assoc, is_open_immersion.app_inv_app_assoc]\n            repeat' erw [← (D.V (j, k)).Presheaf.map_comp]\n            congr } }\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_inv_app AlgebraicGeometry.PresheafedSpace.GlueData.ιInvApp\n\n/-- `ι_inv_app` is the left inverse of `D.ι i` on `U`. -/\ntheorem ιInvApp_π {i : D.J} (U : Opens (D.U i).carrier) :\n    ∃ eq, D.ιInvApp U ≫ D.diagramOverOpenπ U i = (D.U i).Presheaf.map (eqToHom Eq) :=\n  by\n  constructor\n  delta ι_inv_app\n  rw [limit.lift_π]\n  change D.opens_image_preimage_map i i U = _\n  dsimp [opens_image_preimage_map]\n  rw [congr_app (D.t_id _), id_c_app, ← functor.map_comp]\n  erw [is_open_immersion.inv_naturality_assoc, is_open_immersion.app_inv_app'_assoc]\n  simp only [eq_to_hom_op, eq_to_hom_trans, eq_to_hom_map (functor.op _), ← functor.map_comp]\n  rw [set.range_iff_surjective.mpr _]\n  · simp\n  · rw [← TopCat.epi_iff_surjective]\n    infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_inv_app_π AlgebraicGeometry.PresheafedSpace.GlueData.ιInvApp_π\n\n/-- The `eq_to_hom` given by `ι_inv_app_π`. -/\nabbrev ιInvAppπEqMap {i : D.J} (U : Opens (D.U i).carrier) :=\n  (D.U i).Presheaf.map (eqToIso (D.ιInvApp_π U).some).inv\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_inv_app_π_eq_map AlgebraicGeometry.PresheafedSpace.GlueData.ιInvAppπEqMap\n\n/-- `ι_inv_app` is the right inverse of `D.ι i` on `U`. -/\ntheorem π_ιInvApp_π (i j : D.J) (U : Opens (D.U i).carrier) :\n    D.diagramOverOpenπ U i ≫ D.ιInvAppπEqMap U ≫ D.ιInvApp U ≫ D.diagramOverOpenπ U j =\n      D.diagramOverOpenπ U j :=\n  by\n  rw [←\n    cancel_mono\n      ((componentwise_diagram 𝖣.diagram.multispan _).map\n          (Quiver.Hom.op (walking_multispan.hom.snd (i, j))) ≫\n        𝟙 _)]\n  simp_rw [category.assoc]\n  rw [limit.w_assoc]\n  erw [limit.lift_π_assoc]\n  rw [category.comp_id, category.comp_id]\n  change _ ≫ _ ≫ (_ ≫ _) ≫ _ = _\n  rw [congr_app (D.t_id _), id_c_app]\n  simp_rw [category.assoc]\n  rw [← functor.map_comp_assoc, is_open_immersion.inv_naturality_assoc]\n  erw [is_open_immersion.app_inv_app_assoc]\n  iterate 3 rw [← functor.map_comp_assoc]\n  rw [nat_trans.naturality_assoc]\n  erw [← (D.V (i, j)).Presheaf.map_comp]\n  convert limit.w (componentwise_diagram 𝖣.diagram.multispan _)\n      (Quiver.Hom.op (walking_multispan.hom.fst (i, j)))\n  · rw [category.comp_id]\n    apply (config := { instances := false }) mono_comp\n    change mono ((_ ≫ D.f j i).c.app _)\n    rw [comp_c_app]\n    apply (config := { instances := false }) mono_comp\n    erw [D.ι_image_preimage_eq i j U]\n    all_goals infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.π_ι_inv_app_π AlgebraicGeometry.PresheafedSpace.GlueData.π_ιInvApp_π\n\n/-- `ι_inv_app` is the inverse of `D.ι i` on `U`. -/\ntheorem π_ιInvApp_eq_id (i : D.J) (U : Opens (D.U i).carrier) :\n    D.diagramOverOpenπ U i ≫ D.ιInvAppπEqMap U ≫ D.ιInvApp U = 𝟙 _ :=\n  by\n  ext j\n  induction j using Opposite.rec\n  rcases j with (⟨j, k⟩ | ⟨j⟩)\n  · rw [←\n      limit.w (componentwise_diagram 𝖣.diagram.multispan _)\n        (Quiver.Hom.op (walking_multispan.hom.fst (j, k))),\n      ← category.assoc, category.id_comp]\n    congr 1\n    simp_rw [category.assoc]\n    apply π_ι_inv_app_π\n  · simp_rw [category.assoc]\n    rw [category.id_comp]\n    apply π_ι_inv_app_π\n#align algebraic_geometry.PresheafedSpace.glue_data.π_ι_inv_app_eq_id AlgebraicGeometry.PresheafedSpace.GlueData.π_ιInvApp_eq_id\n\ninstance componentwise_diagram_π_isIso (i : D.J) (U : Opens (D.U i).carrier) :\n    IsIso (D.diagramOverOpenπ U i) :=\n  by\n  use D.ι_inv_app_π_eq_map U ≫ D.ι_inv_app U\n  constructor\n  · apply π_ι_inv_app_eq_id\n  · rw [category.assoc, (D.ι_inv_app_π _).choose_spec]\n    exact iso.inv_hom_id ((D.to_glue_data.U i).Presheaf.mapIso (eq_to_iso _))\n#align algebraic_geometry.PresheafedSpace.glue_data.componentwise_diagram_π_is_iso AlgebraicGeometry.PresheafedSpace.GlueData.componentwise_diagram_π_isIso\n\ninstance ιIsOpenImmersion (i : D.J) : IsOpenImmersion (𝖣.ι i)\n    where\n  base_open := D.ι_openEmbedding i\n  c_iso U := by\n    erw [← colimit_presheaf_obj_iso_componentwise_limit_hom_π]\n    infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_is_open_immersion AlgebraicGeometry.PresheafedSpace.GlueData.ιIsOpenImmersion\n\n/-- The following diagram is a pullback, i.e. `Vᵢⱼ` is the intersection of `Uᵢ` and `Uⱼ` in `X`.\n\nVᵢⱼ ⟶ Uᵢ\n |      |\n ↓      ↓\n Uⱼ ⟶ X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (𝖣.vPullbackCone i j) :=\n  PullbackCone.isLimitAux' _ fun s => by\n    refine' ⟨_, _, _, _⟩\n    · refine' PresheafedSpace.is_open_immersion.lift (D.f i j) s.fst _\n      erw [← D.to_Top_glue_data.preimage_range j i]\n      have :\n        s.fst.base ≫ D.to_Top_glue_data.to_glue_data.ι i =\n          s.snd.base ≫ D.to_Top_glue_data.to_glue_data.ι j :=\n        by\n        rw [← 𝖣.ι_gluedIso_hom (PresheafedSpace.forget _) _, ←\n          𝖣.ι_gluedIso_hom (PresheafedSpace.forget _) _]\n        have := congr_arg PresheafedSpace.hom.base s.condition\n        rw [comp_base, comp_base] at this\n        reassoc! this\n        exact this _\n      rw [← Set.image_subset_iff, ← Set.image_univ, ← Set.image_comp, Set.image_univ, ← coe_comp,\n        this, coe_comp, ← Set.image_univ, Set.image_comp]\n      exact Set.image_subset_range _ _\n    · apply is_open_immersion.lift_fac\n    · rw [← cancel_mono (𝖣.ι j), category.assoc, ← (𝖣.vPullbackCone i j).condition]\n      conv_rhs => rw [← s.condition]\n      erw [is_open_immersion.lift_fac_assoc]\n    · intro m e₁ e₂\n      rw [← cancel_mono (D.f i j)]\n      erw [e₁]\n      rw [is_open_immersion.lift_fac]\n#align algebraic_geometry.PresheafedSpace.glue_data.V_pullback_cone_is_limit AlgebraicGeometry.PresheafedSpace.GlueData.vPullbackConeIsLimit\n\ntheorem ι_jointly_surjective (x : 𝖣.glued) : ∃ (i : D.J)(y : D.U i), (𝖣.ι i).base y = x :=\n  𝖣.ι_jointly_surjective (PresheafedSpace.forget _ ⋙ CategoryTheory.forget TopCat) x\n#align algebraic_geometry.PresheafedSpace.glue_data.ι_jointly_surjective AlgebraicGeometry.PresheafedSpace.GlueData.ι_jointly_surjective\n\nend GlueData\n\nend PresheafedSpace\n\nnamespace SheafedSpace\n\nvariable (C) [HasProducts.{v} C]\n\n/-- A family of gluing data consists of\n1. An index type `J`\n2. A sheafed space `U i` for each `i : J`.\n3. A sheafed space `V i j` for each `i j : J`.\n  (Note that this is `J × J → SheafedSpace C` rather than `J → J → SheafedSpace C` to\n  connect to the limits library easier.)\n4. An open immersion `f i j : V i j ⟶ U i` for each `i j : ι`.\n5. A transition map `t i j : V i j ⟶ V j i` for each `i j : ι`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some\n    `t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`.\n9. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`.\n\nWe can then glue the spaces `U i` together by identifying `V i j` with `V j i`, such\nthat the `U i`'s are open subspaces of the glued space.\n-/\n@[nolint has_nonempty_instance]\nstructure GlueData extends GlueData (SheafedSpace.{v} C) where\n  f_open : ∀ i j, SheafedSpace.IsOpenImmersion (f i j)\n#align algebraic_geometry.SheafedSpace.glue_data AlgebraicGeometry.SheafedSpace.GlueData\n\nattribute [instance] glue_data.f_open\n\nnamespace GlueData\n\nvariable {C} (D : GlueData C)\n\n-- mathport name: «expr𝖣»\nlocal notation \"𝖣\" => D.toGlueData\n\n/-- The glue data of presheafed spaces associated to a family of glue data of sheafed spaces. -/\nabbrev toPresheafedSpaceGlueData : PresheafedSpace.GlueData C :=\n  { f_open := D.f_open\n    toGlueData := 𝖣.mapGlueData forgetToPresheafedSpace }\n#align algebraic_geometry.SheafedSpace.glue_data.to_PresheafedSpace_glue_data AlgebraicGeometry.SheafedSpace.GlueData.toPresheafedSpaceGlueData\n\nvariable [HasLimits C]\n\n/-- The gluing as sheafed spaces is isomorphic to the gluing as presheafed spaces. -/\nabbrev isoPresheafedSpace :\n    𝖣.glued.toPresheafedSpace ≅ D.toPresheafedSpaceGlueData.toGlueData.glued :=\n  𝖣.gluedIso forgetToPresheafedSpace\n#align algebraic_geometry.SheafedSpace.glue_data.iso_PresheafedSpace AlgebraicGeometry.SheafedSpace.GlueData.isoPresheafedSpace\n\ntheorem ι_isoPresheafedSpace_inv (i : D.J) :\n    D.toPresheafedSpaceGlueData.toGlueData.ι i ≫ D.isoPresheafedSpace.inv = 𝖣.ι i :=\n  𝖣.ι_gluedIso_inv _ _\n#align algebraic_geometry.SheafedSpace.glue_data.ι_iso_PresheafedSpace_inv AlgebraicGeometry.SheafedSpace.GlueData.ι_isoPresheafedSpace_inv\n\ninstance ι_isOpenImmersion (i : D.J) : IsOpenImmersion (𝖣.ι i) :=\n  by\n  rw [← D.ι_iso_PresheafedSpace_inv]\n  infer_instance\n#align algebraic_geometry.SheafedSpace.glue_data.ι_is_open_immersion AlgebraicGeometry.SheafedSpace.GlueData.ι_isOpenImmersion\n\ntheorem ι_jointly_surjective (x : 𝖣.glued) : ∃ (i : D.J)(y : D.U i), (𝖣.ι i).base y = x :=\n  𝖣.ι_jointly_surjective (SheafedSpace.forget _ ⋙ CategoryTheory.forget TopCat) x\n#align algebraic_geometry.SheafedSpace.glue_data.ι_jointly_surjective AlgebraicGeometry.SheafedSpace.GlueData.ι_jointly_surjective\n\n/-- The following diagram is a pullback, i.e. `Vᵢⱼ` is the intersection of `Uᵢ` and `Uⱼ` in `X`.\n\nVᵢⱼ ⟶ Uᵢ\n |      |\n ↓      ↓\n Uⱼ ⟶ X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (𝖣.vPullbackCone i j) :=\n  𝖣.vPullbackConeIsLimitOfMap forgetToPresheafedSpace i j\n    (D.toPresheafedSpaceGlueData.vPullbackConeIsLimit _ _)\n#align algebraic_geometry.SheafedSpace.glue_data.V_pullback_cone_is_limit AlgebraicGeometry.SheafedSpace.GlueData.vPullbackConeIsLimit\n\nend GlueData\n\nend SheafedSpace\n\nnamespace LocallyRingedSpace\n\n/-- A family of gluing data consists of\n1. An index type `J`\n2. A locally ringed space `U i` for each `i : J`.\n3. A locally ringed space `V i j` for each `i j : J`.\n  (Note that this is `J × J → LocallyRingedSpace` rather than `J → J → LocallyRingedSpace` to\n  connect to the limits library easier.)\n4. An open immersion `f i j : V i j ⟶ U i` for each `i j : ι`.\n5. A transition map `t i j : V i j ⟶ V j i` for each `i j : ι`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j ×[U i] V i k ⟶ V i j ⟶ V j i` factors through `V j k ×[U j] V j i ⟶ V j i` via some\n    `t' : V i j ×[U i] V i k ⟶ V j k ×[U j] V j i`.\n9. `t' i j k ≫ t' j k i ≫ t' k i j = 𝟙 _`.\n\nWe can then glue the spaces `U i` together by identifying `V i j` with `V j i`, such\nthat the `U i`'s are open subspaces of the glued space.\n-/\n@[nolint has_nonempty_instance]\nstructure GlueData extends GlueData LocallyRingedSpace where\n  f_open : ∀ i j, LocallyRingedSpace.IsOpenImmersion (f i j)\n#align algebraic_geometry.LocallyRingedSpace.glue_data AlgebraicGeometry.LocallyRingedSpace.GlueData\n\nattribute [instance] glue_data.f_open\n\nnamespace GlueData\n\nvariable (D : GlueData)\n\n-- mathport name: «expr𝖣»\nlocal notation \"𝖣\" => D.toGlueData\n\n/-- The glue data of ringed spaces associated to a family of glue data of locally ringed spaces. -/\nabbrev toSheafedSpaceGlueData : SheafedSpace.GlueData CommRingCat :=\n  { f_open := D.f_open\n    toGlueData := 𝖣.mapGlueData forgetToSheafedSpace }\n#align algebraic_geometry.LocallyRingedSpace.glue_data.to_SheafedSpace_glue_data AlgebraicGeometry.LocallyRingedSpace.GlueData.toSheafedSpaceGlueData\n\n/-- The gluing as locally ringed spaces is isomorphic to the gluing as ringed spaces. -/\nabbrev isoSheafedSpace : 𝖣.glued.toSheafedSpace ≅ D.toSheafedSpaceGlueData.toGlueData.glued :=\n  𝖣.gluedIso forgetToSheafedSpace\n#align algebraic_geometry.LocallyRingedSpace.glue_data.iso_SheafedSpace AlgebraicGeometry.LocallyRingedSpace.GlueData.isoSheafedSpace\n\ntheorem ι_isoSheafedSpace_inv (i : D.J) :\n    D.toSheafedSpaceGlueData.toGlueData.ι i ≫ D.isoSheafedSpace.inv = (𝖣.ι i).1 :=\n  𝖣.ι_gluedIso_inv forgetToSheafedSpace i\n#align algebraic_geometry.LocallyRingedSpace.glue_data.ι_iso_SheafedSpace_inv AlgebraicGeometry.LocallyRingedSpace.GlueData.ι_isoSheafedSpace_inv\n\ninstance ι_isOpenImmersion (i : D.J) : IsOpenImmersion (𝖣.ι i) :=\n  by\n  delta is_open_immersion\n  rw [← D.ι_iso_SheafedSpace_inv]\n  apply PresheafedSpace.is_open_immersion.comp\n#align algebraic_geometry.LocallyRingedSpace.glue_data.ι_is_open_immersion AlgebraicGeometry.LocallyRingedSpace.GlueData.ι_isOpenImmersion\n\ninstance (i j k : D.J) : PreservesLimit (cospan (𝖣.f i j) (𝖣.f i k)) forgetToSheafedSpace :=\n  inferInstance\n\ntheorem ι_jointly_surjective (x : 𝖣.glued) : ∃ (i : D.J)(y : D.U i), (𝖣.ι i).1.base y = x :=\n  𝖣.ι_jointly_surjective\n    ((LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) ⋙ forget TopCat) x\n#align algebraic_geometry.LocallyRingedSpace.glue_data.ι_jointly_surjective AlgebraicGeometry.LocallyRingedSpace.GlueData.ι_jointly_surjective\n\n/-- The following diagram is a pullback, i.e. `Vᵢⱼ` is the intersection of `Uᵢ` and `Uⱼ` in `X`.\n\nVᵢⱼ ⟶ Uᵢ\n |      |\n ↓      ↓\n Uⱼ ⟶ X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (𝖣.vPullbackCone i j) :=\n  𝖣.vPullbackConeIsLimitOfMap forgetToSheafedSpace i j\n    (D.toSheafedSpaceGlueData.vPullbackConeIsLimit _ _)\n#align algebraic_geometry.LocallyRingedSpace.glue_data.V_pullback_cone_is_limit AlgebraicGeometry.LocallyRingedSpace.GlueData.vPullbackConeIsLimit\n\nend GlueData\n\nend LocallyRingedSpace\n\nend AlgebraicGeometry\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/AlgebraicGeometry/PresheafedSpace/Gluing.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4742728512962738}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.dold_kan.split_simplicial_object\n\n/-!\n\n# Construction of the inverse functor of the Dold-Kan equivalence\n\n\nIn this file, we construct the functor `Γ₀ : chain_complex C ℕ ⥤ simplicial_object C`\nwhich shall be the inverse functor of the Dold-Kan equivalence in the case of abelian categories,\nand more generally pseudoabelian categories.\n\nBy definition, when `K` is a chain_complex, `Γ₀.obj K` is a simplicial object which\nsends `Δ : simplex_categoryᵒᵖ` to a certain coproduct indexed by the set\n`splitting.index_set Δ` whose elements consists of epimorphisms `e : Δ.unop ⟶ Δ'.unop`\n(with `Δ' : simplex_categoryᵒᵖ`); the summand attached to such an `e` is `K.X Δ'.unop.len`.\nBy construction, `Γ₀.obj K` is a split simplicial object whose splitting is `Γ₀.splitting K`.\n\nWe also construct `Γ₂ : karoubi (chain_complex C ℕ) ⥤ karoubi (simplicial_object C)`\nwhich shall be an equivalence for any additive category `C`.\n\n-/\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n  simplex_category simplicial_object opposite category_theory.idempotents\nopen_locale simplicial dold_kan\n\nnamespace algebraic_topology\n\nnamespace dold_kan\n\nvariables {C : Type*} [category C] [preadditive C] (K K' : chain_complex C ℕ) (f : K ⟶ K')\n  {Δ'' Δ' Δ : simplex_category} (i' : Δ'' ⟶ Δ') [mono i'] (i : Δ' ⟶ Δ) [mono i]\n\n/-- `is_δ₀ i` is a simple condition used to check whether a monomorphism `i` in\n`simplex_category` identifies to the coface map `δ 0`. -/\n@[nolint unused_arguments]\ndef is_δ₀ {Δ Δ' : simplex_category} (i : Δ' ⟶ Δ) [mono i] : Prop :=\n(Δ.len = Δ'.len+1) ∧ (i.to_order_hom 0 ≠ 0)\n\nnamespace is_δ₀\n\nlemma iff {j : ℕ} {i : fin (j+2)} : is_δ₀ (simplex_category.δ i) ↔ i = 0 :=\nbegin\n  split,\n  { rintro ⟨h₁, h₂⟩,\n    by_contradiction,\n    exact h₂ (fin.succ_above_ne_zero_zero h), },\n  { rintro rfl,\n    exact ⟨rfl, fin.succ_ne_zero _⟩, },\nend\n\nlemma eq_δ₀ {n : ℕ} {i : [n] ⟶ [n+1]} [mono i] (hi : is_δ₀ i) :\n  i = simplex_category.δ 0 :=\nbegin\n  unfreezingI { obtain ⟨j, rfl⟩ := simplex_category.eq_δ_of_mono i, },\n  rw iff at hi,\n  rw hi,\nend\n\nend is_δ₀\n\nnamespace Γ₀\n\nnamespace obj\n\n/-- In the definition of `(Γ₀.obj K).obj Δ` as a direct sum indexed by `A : splitting.index_set Δ`,\nthe summand `summand K Δ A` is `K.X A.1.len`. -/\ndef summand (Δ : simplex_categoryᵒᵖ) (A : splitting.index_set Δ) : C := K.X A.1.unop.len\n\n/-- The functor `Γ₀` sends a chain complex `K` to the simplicial object which\nsends `Δ` to the direct sum of the objects `summand K Δ A` for all `A : splitting.index_set Δ` -/\ndef obj₂ (K : chain_complex C ℕ) (Δ : simplex_categoryᵒᵖ) [has_finite_coproducts C] : C :=\n∐ (λ (A : splitting.index_set Δ), summand K Δ A)\n\nnamespace termwise\n\n/-- A monomorphism `i : Δ' ⟶ Δ` induces a morphism `K.X Δ.len ⟶ K.X Δ'.len` which\nis the identity if `Δ = Δ'`, the differential on the complex `K` if `i = δ 0`, and\nzero otherwise. -/\ndef map_mono (K : chain_complex C ℕ) {Δ' Δ : simplex_category} (i : Δ' ⟶ Δ) [mono i] :\n  K.X Δ.len ⟶ K.X Δ'.len :=\nbegin\n  by_cases Δ = Δ',\n  { exact eq_to_hom (by congr'), },\n  { by_cases is_δ₀ i,\n    { exact K.d Δ.len Δ'.len, },\n    { exact 0, }, },\nend\n\nvariable (Δ)\n\nlemma map_mono_id : map_mono K (𝟙 Δ) = 𝟙 _ :=\nby { unfold map_mono, simp only [eq_self_iff_true, eq_to_hom_refl, dite_eq_ite, if_true], }\n\nvariable {Δ}\n\nlemma map_mono_δ₀' (hi : is_δ₀ i) : map_mono K i = K.d Δ.len Δ'.len :=\nbegin\n  unfold map_mono,\n  classical,\n  rw [dif_neg, dif_pos hi],\n  unfreezingI { rintro rfl, },\n  simpa only [self_eq_add_right, nat.one_ne_zero] using hi.1,\nend\n\n@[simp]\nlemma map_mono_δ₀ {n : ℕ} : map_mono K (δ (0 : fin (n+2))) = K.d (n+1) n :=\nmap_mono_δ₀' K _ (by rw is_δ₀.iff)\n\nlemma map_mono_eq_zero (h₁ : Δ ≠ Δ') (h₂ : ¬is_δ₀ i) : map_mono K i = 0 :=\nby { unfold map_mono, rw ne.def at h₁, split_ifs, refl, }\n\nvariables {K K'}\n\n@[simp, reassoc]\nlemma map_mono_naturality : map_mono K i ≫ f.f Δ'.len = f.f Δ.len ≫ map_mono K' i :=\nbegin\n  unfold map_mono,\n  split_ifs,\n  { unfreezingI { subst h, },\n    simp only [id_comp, eq_to_hom_refl, comp_id], },\n  { rw homological_complex.hom.comm, },\n  { rw [zero_comp, comp_zero], }\nend\n\nvariable (K)\n\n@[simp, reassoc]\nlemma map_mono_comp : map_mono K i ≫ map_mono K i' = map_mono K (i' ≫ i) :=\nbegin\n  /- case where i : Δ' ⟶ Δ is the identity -/\n  by_cases h₁ : Δ = Δ',\n  { unfreezingI { subst h₁, },\n    simp only [simplex_category.eq_id_of_mono i,\n      comp_id, id_comp, map_mono_id K, eq_to_hom_refl], },\n  /- case where i' : Δ'' ⟶ Δ' is the identity -/\n  by_cases h₂ : Δ' = Δ'',\n  { unfreezingI { subst h₂, },\n    simp only [simplex_category.eq_id_of_mono i',\n      comp_id, id_comp, map_mono_id K, eq_to_hom_refl], },\n  /- then the RHS is always zero -/\n  obtain ⟨k, hk⟩ := nat.exists_eq_add_of_lt (len_lt_of_mono i h₁),\n  obtain ⟨k', hk'⟩ := nat.exists_eq_add_of_lt (len_lt_of_mono i' h₂),\n  have eq : Δ.len = Δ''.len + (k+k'+2) := by linarith,\n  rw map_mono_eq_zero K (i' ≫ i) _ _, rotate,\n  { by_contradiction,\n    simpa only [self_eq_add_right, h] using eq, },\n  { by_contradiction,\n    simp only [h.1, add_right_inj] at eq,\n    linarith, },\n  /- in all cases, the LHS is also zero, either by definition, or because d ≫ d = 0 -/\n  by_cases h₃ : is_δ₀ i,\n  { by_cases h₄ : is_δ₀ i',\n    { rw [map_mono_δ₀' K i h₃, map_mono_δ₀' K i' h₄,\n        homological_complex.d_comp_d], },\n    { simp only [map_mono_eq_zero K i' h₂ h₄, comp_zero], }, },\n  { simp only [map_mono_eq_zero K i h₁ h₃, zero_comp], },\nend\n\nend termwise\n\nvariable [has_finite_coproducts C]\n\n/-- The simplicial morphism on the simplicial object `Γ₀.obj K` induced by\na morphism `Δ' → Δ` in `simplex_category` is defined on each summand\nassociated to an `A : Γ_index_set Δ` in terms of the epi-mono factorisation\nof `θ ≫ A.e`. -/\ndef map (K : chain_complex C ℕ) {Δ' Δ : simplex_categoryᵒᵖ} (θ : Δ ⟶ Δ') :\n  obj₂ K Δ ⟶ obj₂ K Δ' :=\nsigma.desc (λ A, termwise.map_mono K (image.ι (θ.unop ≫ A.e)) ≫\n  (sigma.ι (summand K Δ') (A.pull θ)))\n\n@[reassoc]\nlemma map_on_summand₀ {Δ Δ' : simplex_categoryᵒᵖ} (A : splitting.index_set Δ) {θ : Δ ⟶ Δ'}\n  {Δ'' : simplex_category} {e : Δ'.unop ⟶ Δ''} {i : Δ'' ⟶ A.1.unop} [epi e] [mono i]\n  (fac : e ≫ i = θ.unop ≫ A.e) :\n  (sigma.ι (summand K Δ) A) ≫ map K θ =\n    termwise.map_mono K i ≫ sigma.ι (summand K Δ') (splitting.index_set.mk e) :=\nbegin\n  simp only [map, colimit.ι_desc, cofan.mk_ι_app],\n  have h := simplex_category.image_eq fac,\n  unfreezingI { subst h, },\n  congr,\n  { exact simplex_category.image_ι_eq fac, },\n  { dsimp only [simplicial_object.splitting.index_set.pull],\n    congr,\n    exact simplex_category.factor_thru_image_eq fac, },\nend\n\n@[reassoc]\nlemma map_on_summand₀' {Δ Δ' : simplex_categoryᵒᵖ} (A : splitting.index_set Δ) (θ : Δ ⟶ Δ') :\n  (sigma.ι (summand K Δ) A) ≫ map K θ =\n    termwise.map_mono K (image.ι (θ.unop ≫ A.e)) ≫ sigma.ι (summand K _) (A.pull θ) :=\nmap_on_summand₀ K A (A.fac_pull θ)\n\nend obj\n\nvariable [has_finite_coproducts C]\n\n/-- The functor `Γ₀ : chain_complex C ℕ ⥤ simplicial_object C`, on objects. -/\n@[simps]\ndef obj (K : chain_complex C ℕ) : simplicial_object C :=\n{ obj := λ Δ, obj.obj₂ K Δ,\n  map := λ Δ Δ' θ, obj.map K θ,\n  map_id' := λ Δ, begin\n    ext A,\n    cases A,\n    have fac : A.e ≫ 𝟙 A.1.unop = (𝟙 Δ).unop ≫ A.e := by rw [unop_id, comp_id, id_comp],\n    erw [obj.map_on_summand₀ K A fac, obj.termwise.map_mono_id, id_comp, comp_id],\n    unfreezingI { rcases A with ⟨Δ', ⟨e, he⟩⟩, },\n    refl,\n  end,\n  map_comp' := λ Δ'' Δ' Δ θ' θ, begin\n    ext A,\n    cases A,\n    have fac : θ.unop ≫ θ'.unop ≫ A.e = (θ' ≫ θ).unop ≫ A.e := by rw [unop_comp, assoc],\n    rw [← image.fac (θ'.unop ≫ A.e), ← assoc,\n      ← image.fac (θ.unop ≫ factor_thru_image (θ'.unop ≫ A.e)), assoc] at fac,\n    simpa only [obj.map_on_summand₀'_assoc K A θ', obj.map_on_summand₀' K _ θ,\n      obj.termwise.map_mono_comp_assoc, obj.map_on_summand₀ K A fac],\n  end }\n\nlemma splitting_map_eq_id (Δ : simplex_categoryᵒᵖ) :\n  (simplicial_object.splitting.map (Γ₀.obj K)\n    (λ (n : ℕ), sigma.ι (Γ₀.obj.summand K (op [n])) (splitting.index_set.id (op [n]))) Δ)\n    = 𝟙 _ :=\nbegin\n  ext A,\n  discrete_cases,\n  induction Δ using opposite.rec,\n  induction Δ with n,\n  dsimp,\n  simp only [colimit.ι_desc, cofan.mk_ι_app, comp_id, Γ₀.obj_map],\n  rw [Γ₀.obj.map_on_summand₀ K\n    (simplicial_object.splitting.index_set.id A.1) (show A.e ≫ 𝟙 _ = A.e.op.unop ≫ 𝟙 _, by refl),\n    Γ₀.obj.termwise.map_mono_id, A.ext'],\n  apply id_comp,\nend\n\n/-- By construction, the simplicial `Γ₀.obj K` is equipped with a splitting. -/\ndef splitting (K : chain_complex C ℕ) : simplicial_object.splitting (Γ₀.obj K) :=\n{ N := λ n, K.X n,\n  ι := λ n, sigma.ι (Γ₀.obj.summand K (op [n])) (splitting.index_set.id (op [n])),\n  map_is_iso' := λ Δ, begin\n    rw Γ₀.splitting_map_eq_id,\n    apply is_iso.id,\n  end, }\n\n@[simp]\nlemma splitting_iso_hom_eq_id (Δ : simplex_categoryᵒᵖ) : ((splitting K).iso Δ).hom = 𝟙 _ :=\nsplitting_map_eq_id K Δ\n\n@[reassoc]\nlemma obj.map_on_summand {Δ Δ' : simplex_categoryᵒᵖ} (A : splitting.index_set Δ) (θ : Δ ⟶ Δ')\n  {Δ'' : simplex_category}\n  {e : Δ'.unop ⟶ Δ''} {i : Δ'' ⟶ A.1.unop} [epi e] [mono i]\n  (fac : e ≫ i = θ.unop ≫ A.e) : (Γ₀.splitting K).ι_summand A ≫ (Γ₀.obj K).map θ =\n  Γ₀.obj.termwise.map_mono K i ≫ (Γ₀.splitting K).ι_summand (splitting.index_set.mk e) :=\nbegin\n  dsimp only [simplicial_object.splitting.ι_summand,\n    simplicial_object.splitting.ι_coprod],\n  simp only [assoc, Γ₀.splitting_iso_hom_eq_id, id_comp, comp_id],\n  exact Γ₀.obj.map_on_summand₀ K A fac,\nend\n\n@[reassoc]\nlemma obj.map_on_summand' {Δ Δ' : simplex_categoryᵒᵖ} (A : splitting.index_set Δ) (θ : Δ ⟶ Δ') :\n  (splitting K).ι_summand A ≫ (obj K).map θ =\n    obj.termwise.map_mono K (image.ι (θ.unop ≫ A.e)) ≫ (splitting K).ι_summand (A.pull θ) :=\nby { apply obj.map_on_summand, apply image.fac, }\n\n@[reassoc]\nlemma obj.map_mono_on_summand_id {Δ Δ' : simplex_category} (i : Δ' ⟶ Δ) [mono i] :\n  (splitting K).ι_summand (splitting.index_set.id (op Δ)) ≫ (obj K).map i.op =\n  obj.termwise.map_mono K i ≫ (splitting K).ι_summand (splitting.index_set.id (op Δ')) :=\nobj.map_on_summand K (splitting.index_set.id (op Δ)) i.op (rfl : 𝟙 _ ≫ i = i ≫ 𝟙 _)\n\n@[reassoc]\nlemma obj.map_epi_on_summand_id {Δ Δ' : simplex_category } (e : Δ' ⟶ Δ) [epi e] :\n  (Γ₀.splitting K).ι_summand (splitting.index_set.id (op Δ)) ≫ (Γ₀.obj K).map e.op =\n    (Γ₀.splitting K).ι_summand (splitting.index_set.mk e) :=\nby simpa only [Γ₀.obj.map_on_summand K (splitting.index_set.id (op Δ)) e.op\n    (rfl : e ≫ 𝟙 Δ = e ≫ 𝟙 Δ), Γ₀.obj.termwise.map_mono_id] using id_comp _\n\n/-- The functor `Γ₀ : chain_complex C ℕ ⥤ simplicial_object C`, on morphisms. -/\n@[simps]\ndef map {K K' : chain_complex C ℕ} (f : K ⟶ K') : obj K ⟶ obj K' :=\n{ app := λ Δ, (Γ₀.splitting K).desc Δ (λ A, f.f A.1.unop.len ≫ (Γ₀.splitting K').ι_summand A),\n  naturality' := λ Δ' Δ θ, begin\n    apply (Γ₀.splitting K).hom_ext',\n    intro A,\n    simp only [(splitting K).ι_desc_assoc, obj.map_on_summand'_assoc K _ θ,\n      (splitting K).ι_desc, assoc, obj.map_on_summand' K' _ θ],\n    apply obj.termwise.map_mono_naturality_assoc,\n  end, }\n\nend Γ₀\n\nvariable [has_finite_coproducts C]\n\n/-- The functor `Γ₀' : chain_complex C ℕ ⥤ simplicial_object.split C`\nthat induces `Γ₀ : chain_complex C ℕ ⥤ simplicial_object C`, which\nshall be the inverse functor of the Dold-Kan equivalence for\nabelian or pseudo-abelian categories. -/\n@[simps]\ndef Γ₀' : chain_complex C ℕ ⥤ simplicial_object.split C :=\n{ obj := λ K, simplicial_object.split.mk' (Γ₀.splitting K),\n  map := λ K K' f,\n  { F := Γ₀.map f,\n    f := f.f,\n    comm' := λ n, by { dsimp, simpa only [← splitting.ι_summand_id,\n      (Γ₀.splitting K).ι_desc], }, }, }\n\n/-- The functor `Γ₀ : chain_complex C ℕ ⥤ simplicial_object C`, which is\nthe inverse functor of the Dold-Kan equivalence when `C` is an abelian\ncategory, or more generally a pseudoabelian category. -/\n@[simps]\ndef Γ₀ : chain_complex C ℕ ⥤ simplicial_object C := Γ₀' ⋙ split.forget _\n\n\n/-- The extension of `Γ₀ : chain_complex C ℕ ⥤ simplicial_object C`\non the idempotent completions. It shall be an equivalence of categories\nfor any additive category `C`. -/\n@[simps]\ndef Γ₂ : karoubi (chain_complex C ℕ) ⥤ karoubi (simplicial_object C) :=\n(category_theory.idempotents.functor_extension₂ _ _).obj Γ₀\n\nlemma higher_faces_vanish.on_Γ₀_summand_id (K : chain_complex C ℕ) (n : ℕ) :\n  higher_faces_vanish (n+1) ((Γ₀.splitting K).ι_summand (splitting.index_set.id (op [n+1]))) :=\nbegin\n  intros j hj,\n  have eq := Γ₀.obj.map_mono_on_summand_id K (simplex_category.δ j.succ),\n  rw [Γ₀.obj.termwise.map_mono_eq_zero K, zero_comp] at eq, rotate,\n  { intro h,\n    exact (nat.succ_ne_self n) (congr_arg simplex_category.len h), },\n  { exact λ h, fin.succ_ne_zero j (by simpa only [is_δ₀.iff] using h), },\n  exact eq,\nend\n\n@[simp, reassoc]\nlemma P_infty_on_Γ₀_splitting_summand_eq_self\n  (K : chain_complex C ℕ) {n : ℕ} :\n  (Γ₀.splitting K).ι_summand (splitting.index_set.id (op [n])) ≫ (P_infty : K[Γ₀.obj K] ⟶ _).f n =\n    (Γ₀.splitting K).ι_summand (splitting.index_set.id (op [n])) :=\nbegin\n  rw P_infty_f,\n  cases n,\n  { simpa only [P_f_0_eq] using comp_id _, },\n  { exact (higher_faces_vanish.on_Γ₀_summand_id K n).comp_P_eq_self, },\nend\n\nend dold_kan\n\nend algebraic_topology\n", "meta": {"author": "joelriou", "repo": "dold-kan", "sha": "a083fe264275774ac49ac520caf25f2ee29debb1", "save_path": "github-repos/lean/joelriou-dold-kan", "path": "github-repos/lean/joelriou-dold-kan/dold-kan-a083fe264275774ac49ac520caf25f2ee29debb1/src/for_mathlib/dold_kan/functor_gamma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.474272845227191}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Eric Wieser\n\n! This file was ported from Lean 3 source module data.matrix.notation\n! leanprover-community/mathlib commit 55e2dfde0cff928ce5c70926a3f2c7dee3e2dd99\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Matrix.Basic\nimport Mathbin.Data.Fin.VecNotation\nimport Mathbin.Tactic.FinCases\nimport Mathbin.Algebra.BigOperators.Fin\n\n/-!\n# Matrix and vector notation\n\nThis file includes `simp` lemmas for applying operations in `data.matrix.basic` to values built out\nof the matrix notation `![a, b] = vec_cons a (vec_cons b vec_empty)` defined in\n`data.fin.vec_notation`.\n\nThis also provides the new notation `!![a, b; c, d] = matrix.of ![![a, b], ![c, d]]`.\nThis notation also works for empty matrices; `!![,,,] : matrix (fin 0) (fin 3)` and\n`!![;;;] : matrix (fin 3) (fin 0)`.\n\n## Implementation notes\n\nThe `simp` lemmas require that one of the arguments is of the form `vec_cons _ _`.\nThis ensures `simp` works with entries only when (some) entries are already given.\nIn other words, this notation will only appear in the output of `simp` if it\nalready appears in the input.\n\n## Notations\n\nThis file provide notation `!![a, b; c, d]` for matrices, which corresponds to\n`matrix.of ![![a, b], ![c, d]]`.\nA parser for `a, b; c, d`-style strings is provided as `matrix.entry_parser`, while\n`matrix.notation` provides the hook for the `!!` notation.\nNote that in lean 3 the pretty-printer will not show `!!` notation, instead showing the version\nwith `of ![![...]]`.\n\n## Examples\n\nExamples of usage can be found in the `test/matrix.lean` file.\n-/\n\n\nnamespace Matrix\n\nuniverse u\n\nvariable {α : Type u} {o n m : ℕ} {m' n' o' : Type _}\n\nopen Matrix\n\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:73:14: unsupported tactic `reflect_name #[] -/\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:73:14: unsupported tactic `reflect_name #[] -/\n/-- Matrices can be reflected whenever their entries can. We insert an `@id (matrix m' n' α)` to\nprevent immediate decay to a function. -/\nunsafe instance matrix.reflect [reflected_univ.{u}] [reflected_univ.{u_1}] [reflected_univ.{u_2}]\n    [reflected _ α] [reflected _ m'] [reflected _ n'] [h : has_reflect (m' → n' → α)] :\n    has_reflect (Matrix m' n' α) := fun m =>\n  (by\n          trace\n            \"./././Mathport/Syntax/Translate/Tactic/Builtin.lean:73:14: unsupported tactic `reflect_name #[]\" :\n          reflected _ @id.{max u_1 u_2 u + 1}).subst₂\n      ((by\n            trace\n              \"./././Mathport/Syntax/Translate/Tactic/Builtin.lean:73:14: unsupported tactic `reflect_name #[]\" :\n            reflected _ @Matrix.{u_1, u_2, u}).subst₃\n        q(_) q(_) q(_)) <|\n    by\n    dsimp only [Matrix]\n    exact h m\n#align matrix.matrix.reflect matrix.matrix.reflect\n\nsection Parser\n\nopen Lean\n\nopen Lean.Parser\n\nopen Interactive\n\nopen Interactive.Types\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Parse the entries of a matrix -/\nunsafe def entry_parser {α : Type} (p : parser α) : parser (Σm n, Fin m → Fin n → α) := do\n  let-- a list of lists if the matrix has at least one row, or the number of columns if the matrix has\n  -- zero rows.\n  p :\n    parser (Sum (List (List α)) ℕ) :=-- empty rows\n        Sum.inl <$>\n        ((pure [] <* tk \";\").repeat_at_least 1 <|>\n          (sep_by_trailing (tk \";\") <| sep_by_trailing (tk \",\") p)) <|>\n      Sum.inr <$> List.length <$> many (tk \",\")\n  let which\n    ←-- empty columns\n      p\n  match which with\n    | Sum.inl l => do\n      let h::tl ← pure l\n      let n := h\n      let l : List (Vector α n) ←\n        l fun row =>\n            if h : row = n then pure (⟨row, h⟩ : Vector α n)\n            else interaction_monad.fail \"Rows must be of equal length\"\n      pure ⟨l, n, fun i j => (l _ i).get? j⟩\n    | Sum.inr n => pure ⟨0, n, finZeroElim⟩\n#align matrix.entry_parser matrix.entry_parser\n\n-- Lean can't find this instance without some help. We only need it available in `Type 0`, and it is\n-- a massive amount of effort to make it universe-polymorphic.\n@[instance]\nunsafe def sigma_sigma_fin_matrix_has_reflect {α : Type} [has_reflect α] [reflected _ α] :\n    has_reflect (Σm n : ℕ, Fin m → Fin n → α) :=\n  @sigma.reflect.{0, 0} _ _ ℕ (fun m => Σn, Fin m → Fin n → α) _ _ _ fun i =>\n    @sigma.reflect.{0, 0} _ _ ℕ _ _ _ _ fun j => inferInstance\n#align matrix.sigma_sigma_fin_matrix_has_reflect matrix.sigma_sigma_fin_matrix_has_reflect\n\n/-- `!![a, b; c, d]` notation for matrices indexed by `fin m` and `fin n`. See the module docstring\nfor details. -/\n@[user_notation]\nunsafe def notation (_ : parse <| tk \"!![\")\n    (val : parse (entry_parser (parser.pexpr 1) <* tk \"]\")) : parser pexpr := do\n  let ⟨m, n, entries⟩ := val\n  let entry_vals := pi_fin.to_pexpr (pi_fin.to_pexpr ∘ entries)\n  pure (``(@Matrix.of (Fin $(q(m))) (Fin $(q(n))) _).app entry_vals)\n#align matrix.notation matrix.notation\n\nend Parser\n\nvariable (a b : ℕ)\n\n/-- Use `![...]` notation for displaying a `fin`-indexed matrix, for example:\n\n```\n#eval !![1, 2; 3, 4] + !![3, 4; 5, 6]  -- !![4, 6; 8, 10]\n```\n-/\ninstance [Repr α] : Repr (Matrix (Fin m) (Fin n) α)\n    where repr f :=\n    \"!![\" ++\n        (String.intercalate \"; \" <|\n          (List.finRange m).map fun i =>\n            String.intercalate \", \" <| (List.finRange n).map fun j => repr (f i j)) ++\n      \"]\"\n\n@[simp]\ntheorem cons_val' (v : n' → α) (B : Fin m → n' → α) (i j) :\n    vecCons v B i j = vecCons (v j) (fun i => B i j) i := by refine' Fin.cases _ _ i <;> simp\n#align matrix.cons_val' Matrix.cons_val'\n\n@[simp]\ntheorem head_val' (B : Fin m.succ → n' → α) (j : n') : (vecHead fun i => B i j) = vecHead B j :=\n  rfl\n#align matrix.head_val' Matrix.head_val'\n\n@[simp]\ntheorem tail_val' (B : Fin m.succ → n' → α) (j : n') :\n    (vecTail fun i => B i j) = fun i => vecTail B i j :=\n  by\n  ext\n  simp [vec_tail]\n#align matrix.tail_val' Matrix.tail_val'\n\nsection DotProduct\n\nvariable [AddCommMonoid α] [Mul α]\n\n@[simp]\ntheorem dotProduct_empty (v w : Fin 0 → α) : dotProduct v w = 0 :=\n  Finset.sum_empty\n#align matrix.dot_product_empty Matrix.dotProduct_empty\n\n@[simp]\ntheorem cons_dotProduct (x : α) (v : Fin n → α) (w : Fin n.succ → α) :\n    dotProduct (vecCons x v) w = x * vecHead w + dotProduct v (vecTail w) := by\n  simp [dot_product, Fin.sum_univ_succ, vec_head, vec_tail]\n#align matrix.cons_dot_product Matrix.cons_dotProduct\n\n@[simp]\ntheorem dotProduct_cons (v : Fin n.succ → α) (x : α) (w : Fin n → α) :\n    dotProduct v (vecCons x w) = vecHead v * x + dotProduct (vecTail v) w := by\n  simp [dot_product, Fin.sum_univ_succ, vec_head, vec_tail]\n#align matrix.dot_product_cons Matrix.dotProduct_cons\n\n@[simp]\ntheorem cons_dotProduct_cons (x : α) (v : Fin n → α) (y : α) (w : Fin n → α) :\n    dotProduct (vecCons x v) (vecCons y w) = x * y + dotProduct v w := by simp\n#align matrix.cons_dot_product_cons Matrix.cons_dotProduct_cons\n\nend DotProduct\n\nsection ColRow\n\n@[simp]\ntheorem col_empty (v : Fin 0 → α) : col v = vecEmpty :=\n  empty_eq _\n#align matrix.col_empty Matrix.col_empty\n\n@[simp]\ntheorem col_cons (x : α) (u : Fin m → α) : col (vecCons x u) = vecCons (fun _ => x) (col u) :=\n  by\n  ext (i j)\n  refine' Fin.cases _ _ i <;> simp [vec_head, vec_tail]\n#align matrix.col_cons Matrix.col_cons\n\n@[simp]\ntheorem row_empty : row (vecEmpty : Fin 0 → α) = fun _ => vecEmpty :=\n  by\n  ext\n  rfl\n#align matrix.row_empty Matrix.row_empty\n\n@[simp]\ntheorem row_cons (x : α) (u : Fin m → α) : row (vecCons x u) = fun _ => vecCons x u :=\n  by\n  ext\n  rfl\n#align matrix.row_cons Matrix.row_cons\n\nend ColRow\n\nsection Transpose\n\n@[simp]\ntheorem transpose_empty_rows (A : Matrix m' (Fin 0) α) : Aᵀ = of ![] :=\n  empty_eq _\n#align matrix.transpose_empty_rows Matrix.transpose_empty_rows\n\n@[simp]\ntheorem transpose_empty_cols (A : Matrix (Fin 0) m' α) : Aᵀ = of fun i => ![] :=\n  funext fun i => empty_eq _\n#align matrix.transpose_empty_cols Matrix.transpose_empty_cols\n\n@[simp]\ntheorem cons_transpose (v : n' → α) (A : Matrix (Fin m) n' α) :\n    (of (vecCons v A))ᵀ = of fun i => vecCons (v i) (Aᵀ i) :=\n  by\n  ext (i j)\n  refine' Fin.cases _ _ j <;> simp\n#align matrix.cons_transpose Matrix.cons_transpose\n\n@[simp]\ntheorem head_transpose (A : Matrix m' (Fin n.succ) α) :\n    vecHead (of.symm Aᵀ) = vecHead ∘ of.symm A :=\n  rfl\n#align matrix.head_transpose Matrix.head_transpose\n\n@[simp]\ntheorem tail_transpose (A : Matrix m' (Fin n.succ) α) : vecTail (of.symm Aᵀ) = (vecTail ∘ A)ᵀ :=\n  by\n  ext (i j)\n  rfl\n#align matrix.tail_transpose Matrix.tail_transpose\n\nend Transpose\n\nsection Mul\n\nvariable [Semiring α]\n\n@[simp]\ntheorem empty_mul [Fintype n'] (A : Matrix (Fin 0) n' α) (B : Matrix n' o' α) : A ⬝ B = of ![] :=\n  empty_eq _\n#align matrix.empty_mul Matrix.empty_mul\n\n@[simp]\ntheorem empty_mul_empty (A : Matrix m' (Fin 0) α) (B : Matrix (Fin 0) o' α) : A ⬝ B = 0 :=\n  rfl\n#align matrix.empty_mul_empty Matrix.empty_mul_empty\n\n@[simp]\ntheorem mul_empty [Fintype n'] (A : Matrix m' n' α) (B : Matrix n' (Fin 0) α) :\n    A ⬝ B = of fun _ => ![] :=\n  funext fun _ => empty_eq _\n#align matrix.mul_empty Matrix.mul_empty\n\ntheorem mul_val_succ [Fintype n'] (A : Matrix (Fin m.succ) n' α) (B : Matrix n' o' α) (i : Fin m)\n    (j : o') : (A ⬝ B) i.succ j = (of (vecTail (of.symm A)) ⬝ B) i j :=\n  rfl\n#align matrix.mul_val_succ Matrix.mul_val_succ\n\n@[simp]\ntheorem cons_mul [Fintype n'] (v : n' → α) (A : Fin m → n' → α) (B : Matrix n' o' α) :\n    of (vecCons v A) ⬝ B = of (vecCons (vecMul v B) (of.symm (of A ⬝ B))) :=\n  by\n  ext (i j)\n  refine' Fin.cases _ _ i\n  · rfl\n  simp [mul_val_succ]\n#align matrix.cons_mul Matrix.cons_mul\n\nend Mul\n\nsection VecMul\n\nvariable [Semiring α]\n\n@[simp]\ntheorem empty_vecMul (v : Fin 0 → α) (B : Matrix (Fin 0) o' α) : vecMul v B = 0 :=\n  rfl\n#align matrix.empty_vec_mul Matrix.empty_vecMul\n\n@[simp]\ntheorem vecMul_empty [Fintype n'] (v : n' → α) (B : Matrix n' (Fin 0) α) : vecMul v B = ![] :=\n  empty_eq _\n#align matrix.vec_mul_empty Matrix.vecMul_empty\n\n@[simp]\ntheorem cons_vecMul (x : α) (v : Fin n → α) (B : Fin n.succ → o' → α) :\n    vecMul (vecCons x v) (of B) = x • vecHead B + vecMul v (of <| vecTail B) :=\n  by\n  ext i\n  simp [vec_mul]\n#align matrix.cons_vec_mul Matrix.cons_vecMul\n\n@[simp]\ntheorem vecMul_cons (v : Fin n.succ → α) (w : o' → α) (B : Fin n → o' → α) :\n    vecMul v (of <| vecCons w B) = vecHead v • w + vecMul (vecTail v) (of B) :=\n  by\n  ext i\n  simp [vec_mul]\n#align matrix.vec_mul_cons Matrix.vecMul_cons\n\n@[simp]\ntheorem cons_vecMul_cons (x : α) (v : Fin n → α) (w : o' → α) (B : Fin n → o' → α) :\n    vecMul (vecCons x v) (of <| vecCons w B) = x • w + vecMul v (of B) := by simp\n#align matrix.cons_vec_mul_cons Matrix.cons_vecMul_cons\n\nend VecMul\n\nsection MulVec\n\nvariable [Semiring α]\n\n@[simp]\ntheorem empty_mulVec [Fintype n'] (A : Matrix (Fin 0) n' α) (v : n' → α) : mulVec A v = ![] :=\n  empty_eq _\n#align matrix.empty_mul_vec Matrix.empty_mulVec\n\n@[simp]\ntheorem mulVec_empty (A : Matrix m' (Fin 0) α) (v : Fin 0 → α) : mulVec A v = 0 :=\n  rfl\n#align matrix.mul_vec_empty Matrix.mulVec_empty\n\n@[simp]\ntheorem cons_mulVec [Fintype n'] (v : n' → α) (A : Fin m → n' → α) (w : n' → α) :\n    mulVec (of <| vecCons v A) w = vecCons (dotProduct v w) (mulVec (of A) w) :=\n  by\n  ext i\n  refine' Fin.cases _ _ i <;> simp [mul_vec]\n#align matrix.cons_mul_vec Matrix.cons_mulVec\n\n@[simp]\ntheorem mulVec_cons {α} [CommSemiring α] (A : m' → Fin n.succ → α) (x : α) (v : Fin n → α) :\n    mulVec (of A) (vecCons x v) = x • vecHead ∘ A + mulVec (of (vecTail ∘ A)) v :=\n  by\n  ext i\n  simp [mul_vec, mul_comm]\n#align matrix.mul_vec_cons Matrix.mulVec_cons\n\nend MulVec\n\nsection VecMulVec\n\nvariable [Semiring α]\n\n@[simp]\ntheorem empty_vecMulVec (v : Fin 0 → α) (w : n' → α) : vecMulVec v w = ![] :=\n  empty_eq _\n#align matrix.empty_vec_mul_vec Matrix.empty_vecMulVec\n\n@[simp]\ntheorem vecMulVec_empty (v : m' → α) (w : Fin 0 → α) : vecMulVec v w = fun _ => ![] :=\n  funext fun i => empty_eq _\n#align matrix.vec_mul_vec_empty Matrix.vecMulVec_empty\n\n@[simp]\ntheorem cons_vecMulVec (x : α) (v : Fin m → α) (w : n' → α) :\n    vecMulVec (vecCons x v) w = vecCons (x • w) (vecMulVec v w) :=\n  by\n  ext i\n  refine' Fin.cases _ _ i <;> simp [vec_mul_vec]\n#align matrix.cons_vec_mul_vec Matrix.cons_vecMulVec\n\n@[simp]\ntheorem vecMulVec_cons (v : m' → α) (x : α) (w : Fin n → α) :\n    vecMulVec v (vecCons x w) = fun i => v i • vecCons x w :=\n  by\n  ext (i j)\n  rw [vec_mul_vec, Pi.smul_apply, smul_eq_mul]\n#align matrix.vec_mul_vec_cons Matrix.vecMulVec_cons\n\nend VecMulVec\n\nsection Smul\n\nvariable [Semiring α]\n\n@[simp]\ntheorem smul_mat_empty {m' : Type _} (x : α) (A : Fin 0 → m' → α) : x • A = ![] :=\n  empty_eq _\n#align matrix.smul_mat_empty Matrix.smul_mat_empty\n\n@[simp]\ntheorem smul_mat_cons (x : α) (v : n' → α) (A : Fin m → n' → α) :\n    x • vecCons v A = vecCons (x • v) (x • A) :=\n  by\n  ext i\n  refine' Fin.cases _ _ i <;> simp\n#align matrix.smul_mat_cons Matrix.smul_mat_cons\n\nend Smul\n\nsection Submatrix\n\n@[simp]\ntheorem submatrix_empty (A : Matrix m' n' α) (row : Fin 0 → m') (col : o' → n') :\n    submatrix A row col = ![] :=\n  empty_eq _\n#align matrix.submatrix_empty Matrix.submatrix_empty\n\n@[simp]\ntheorem submatrix_cons_row (A : Matrix m' n' α) (i : m') (row : Fin m → m') (col : o' → n') :\n    submatrix A (vecCons i row) col = vecCons (fun j => A i (col j)) (submatrix A row col) :=\n  by\n  ext (i j)\n  refine' Fin.cases _ _ i <;> simp [submatrix]\n#align matrix.submatrix_cons_row Matrix.submatrix_cons_row\n\nend Submatrix\n\nsection Vec2AndVec3\n\nsection One\n\nvariable [Zero α] [One α]\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem one_fin_two :\n    (1 : Matrix (Fin 2) (Fin 2) α) =\n      «expr!![ »\n        \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" :=\n  by\n  ext (i j)\n  fin_cases i <;> fin_cases j <;> rfl\n#align matrix.one_fin_two Matrix.one_fin_two\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem one_fin_three :\n    (1 : Matrix (Fin 3) (Fin 3) α) =\n      «expr!![ »\n        \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" :=\n  by\n  ext (i j)\n  fin_cases i <;> fin_cases j <;> rfl\n#align matrix.one_fin_three Matrix.one_fin_three\n\nend One\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem eta_fin_two (A : Matrix (Fin 2) (Fin 2) α) :\n    A =\n      «expr!![ »\n        \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" :=\n  by\n  ext (i j)\n  fin_cases i <;> fin_cases j <;> rfl\n#align matrix.eta_fin_two Matrix.eta_fin_two\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem eta_fin_three (A : Matrix (Fin 3) (Fin 3) α) :\n    A =\n      «expr!![ »\n        \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" :=\n  by\n  ext (i j)\n  fin_cases i <;> fin_cases j <;> rfl\n#align matrix.eta_fin_three Matrix.eta_fin_three\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem mul_fin_two [AddCommMonoid α] [Mul α] (a₁₁ a₁₂ a₂₁ a₂₂ b₁₁ b₁₂ b₂₁ b₂₂ : α) :\n    «expr!![ »\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" ⬝\n        «expr!![ »\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" =\n      «expr!![ »\n        \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" :=\n  by\n  ext (i j)\n  fin_cases i <;> fin_cases j <;> simp [Matrix.mul, dot_product, Fin.sum_univ_succ]\n#align matrix.mul_fin_two Matrix.mul_fin_two\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr!![ » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem mul_fin_three [AddCommMonoid α] [Mul α]\n    (a₁₁ a₁₂ a₁₃ a₂₁ a₂₂ a₂₃ a₃₁ a₃₂ a₃₃ b₁₁ b₁₂ b₁₃ b₂₁ b₂₂ b₂₃ b₃₁ b₃₂ b₃₃ : α) :\n    «expr!![ »\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" ⬝\n        «expr!![ »\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" =\n      «expr!![ »\n        \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" :=\n  by\n  ext (i j)\n  fin_cases i <;> fin_cases j <;> simp [Matrix.mul, dot_product, Fin.sum_univ_succ, ← add_assoc]\n#align matrix.mul_fin_three Matrix.mul_fin_three\n\ntheorem vec2_eq {a₀ a₁ b₀ b₁ : α} (h₀ : a₀ = b₀) (h₁ : a₁ = b₁) : ![a₀, a₁] = ![b₀, b₁] := by\n  subst_vars\n#align matrix.vec2_eq Matrix.vec2_eq\n\ntheorem vec3_eq {a₀ a₁ a₂ b₀ b₁ b₂ : α} (h₀ : a₀ = b₀) (h₁ : a₁ = b₁) (h₂ : a₂ = b₂) :\n    ![a₀, a₁, a₂] = ![b₀, b₁, b₂] := by subst_vars\n#align matrix.vec3_eq Matrix.vec3_eq\n\ntheorem vec2_add [Add α] (a₀ a₁ b₀ b₁ : α) : ![a₀, a₁] + ![b₀, b₁] = ![a₀ + b₀, a₁ + b₁] := by\n  rw [cons_add_cons, cons_add_cons, empty_add_empty]\n#align matrix.vec2_add Matrix.vec2_add\n\ntheorem vec3_add [Add α] (a₀ a₁ a₂ b₀ b₁ b₂ : α) :\n    ![a₀, a₁, a₂] + ![b₀, b₁, b₂] = ![a₀ + b₀, a₁ + b₁, a₂ + b₂] := by\n  rw [cons_add_cons, cons_add_cons, cons_add_cons, empty_add_empty]\n#align matrix.vec3_add Matrix.vec3_add\n\ntheorem smul_vec2 {R : Type _} [SMul R α] (x : R) (a₀ a₁ : α) : x • ![a₀, a₁] = ![x • a₀, x • a₁] :=\n  by rw [smul_cons, smul_cons, smul_empty]\n#align matrix.smul_vec2 Matrix.smul_vec2\n\ntheorem smul_vec3 {R : Type _} [SMul R α] (x : R) (a₀ a₁ a₂ : α) :\n    x • ![a₀, a₁, a₂] = ![x • a₀, x • a₁, x • a₂] := by\n  rw [smul_cons, smul_cons, smul_cons, smul_empty]\n#align matrix.smul_vec3 Matrix.smul_vec3\n\nvariable [AddCommMonoid α] [Mul α]\n\ntheorem vec2_dot_product' {a₀ a₁ b₀ b₁ : α} : ![a₀, a₁] ⬝ᵥ ![b₀, b₁] = a₀ * b₀ + a₁ * b₁ := by\n  rw [cons_dot_product_cons, cons_dot_product_cons, dot_product_empty, add_zero]\n#align matrix.vec2_dot_product' Matrix.vec2_dot_product'\n\n@[simp]\ntheorem vec2_dotProduct (v w : Fin 2 → α) : v ⬝ᵥ w = v 0 * w 0 + v 1 * w 1 :=\n  vec2_dot_product'\n#align matrix.vec2_dot_product Matrix.vec2_dotProduct\n\ntheorem vec3_dot_product' {a₀ a₁ a₂ b₀ b₁ b₂ : α} :\n    ![a₀, a₁, a₂] ⬝ᵥ ![b₀, b₁, b₂] = a₀ * b₀ + a₁ * b₁ + a₂ * b₂ := by\n  rw [cons_dot_product_cons, cons_dot_product_cons, cons_dot_product_cons, dot_product_empty,\n    add_zero, add_assoc]\n#align matrix.vec3_dot_product' Matrix.vec3_dot_product'\n\n@[simp]\ntheorem vec3_dotProduct (v w : Fin 3 → α) : v ⬝ᵥ w = v 0 * w 0 + v 1 * w 1 + v 2 * w 2 :=\n  vec3_dot_product'\n#align matrix.vec3_dot_product Matrix.vec3_dotProduct\n\nend Vec2AndVec3\n\nend Matrix\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Matrix/Notation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.47424891103948347}}
{"text": "import .basic\nopen list quot subtype decidable function\n\nnamespace finset\n/- image (corresponds to map on list) -/\nsection image\nvariables {A B : Type}\nvariable [h : decidable_eq B]\ninclude h\n\ndefinition image (f : A → B) (s : finset A) : finset B :=\nquot.lift_on s\n  (λ l, to_finset (list.map f l.1))\n  (λ l₁ l₂ p, quot.sound (perm.perm_erase_dup_of_perm (perm.perm_map _ p)))\n\n\ninfix `'` := image\n\ntheorem image_empty (f : A → B) : image f empty = empty := rfl\n\ntheorem mem_image_of_mem (f : A → B) {s : finset A} {a : A} : a ∈ s → f a ∈ image f s :=\nquot.induction_on s (take l, assume H : a ∈ l.1, mem_to_finset (mem_map f H))\n\ntheorem mem_image {f : A → B} {s : finset A} {a : A} {b : B}\n    (H1 : a ∈ s) (H2 : f a = b) :\n  b ∈ image f s :=\neq.subst H2 (mem_image_of_mem f H1)\n\ntheorem exists_of_mem_image {f : A → B} {s : finset A} {b : B} :\n  b ∈ image f s → ∃a, a ∈ s ∧ f a = b :=\nquot.induction_on s\n  (take l, assume H : b ∈ erase_dup (list.map f l.1),\n    exists_of_mem_map (mem_of_mem_erase_dup H))\n\n\ntheorem mem_image_iff (f : A → B) {s : finset A} {y : B} : y ∈ image f s ↔ ∃x, x ∈ s ∧ f x = y :=\niff.intro exists_of_mem_image\n  (assume H, let ⟨x,H₁,H₂⟩ := H in mem_image H₁ H₂)\n\ntheorem mem_image_eq (f : A → B) {s : finset A} {y : B} : y ∈ image f s = ∃x, x ∈ s ∧ f x = y :=\npropext (mem_image_iff f)\n\ntheorem mem_image_of_mem_image_of_subset {f : A → B} {s t : finset A} {y : B}\n    (H1 : y ∈ image f s) (H2 : s ⊆ t) : y ∈ image f t :=\nlet ⟨x, H3, H4⟩ := exists_of_mem_image H1 in\nhave H5 : x ∈ t, from mem_of_subset_of_mem H2 H3,\nshow y ∈ image f t, from mem_image H5 H4\n\ntheorem image_insert [h' : decidable_eq A] (f : A → B) (s : finset A) (a : A) :\n  image f (insert a s) = insert (f a) (image f s) :=\next (take y, iff.intro\n  (assume H : y ∈ image f (insert a s),\n    let ⟨x,H1l,H1r⟩ := exists_of_mem_image H in\n    have x = a ∨ x ∈ s, from eq_or_mem_of_mem_insert H1l,\n    or.elim this\n      (suppose x = a,\n        have f a = y, from eq.subst this H1r,\n        show y ∈ insert (f a) (image f s), from eq.subst this (mem_insert _ _))\n      (suppose x ∈ s,\n        have f x ∈ image f s, from mem_image_of_mem f this,\n        show y ∈ insert (f a) (image f s), from eq.subst H1r (mem_insert_of_mem _ this)))\n  (suppose y ∈ insert (f a) (image f s),\n    have y = f a ∨ y ∈ image f s, from eq_or_mem_of_mem_insert this,\n    or.elim this\n      (assume eq : y = f a,\n        have f a ∈ image f (insert a s), from mem_image_of_mem f (mem_insert _ _),\n        show y ∈ image f (insert a s), by rw eq;exact this)\n      (suppose y ∈ image f s,\n        show y ∈ image f (insert a s), from mem_image_of_mem_image_of_subset this (subset_insert _ _) )))\n\n\nlemma image_comp {C : Type} [deceqC : decidable_eq C] {f : B → C} {g : A → B} {s : finset A} :\n  image (f∘g) s = image f (image g s) :=\next (take z, iff.intro\n  (suppose z ∈ image (f∘g) s,\n   let ⟨x,Hx,Hgfx⟩ := exists_of_mem_image this in\n    by rewrite -Hgfx; apply mem_image_of_mem _ (mem_image_of_mem _ Hx))\n  (suppose z ∈ image f (image g s),\n   let ⟨y,Hy,Hfy⟩ := exists_of_mem_image this in\n   let ⟨x,Hx,Hgx⟩ := exists_of_mem_image Hy in\n   mem_image Hx (begin simp [comp, Hgx, Hfy] end)))\n\nlemma image_subset {a b : finset A} (f : A → B) (H : a ⊆ b) : image f a ⊆ image f b :=\nsubset_of_forall\n  (take y, assume Hy : y ∈ image f a,\n    let ⟨x,Hx₁,Hx₂⟩ := exists_of_mem_image Hy in\n    mem_image (mem_of_subset_of_mem H Hx₁) Hx₂)\n\ntheorem image_union [h' : decidable_eq A] (f : A → B) (s t : finset A) :\n  image f (s ∪ t) = image f s ∪ image f t :=\next (take y, iff.intro\n  (assume H : y ∈ image f (s ∪ t),\n   let ⟨x,xst,fxy⟩ := exists_of_mem_image H in\n    or.elim (mem_or_mem_of_mem_union xst)\n      (assume xs, mem_union_l (mem_image xs fxy))\n      (assume xt, mem_union_r (mem_image xt fxy)))\n  (assume H : y ∈ image f s ∪ image f t,\n    or.elim (mem_or_mem_of_mem_union H)\n      (assume yifs : y ∈ image f s,\n        let ⟨x,xs,fxy⟩ := exists_of_mem_image yifs in\n        mem_image (mem_union_l xs) fxy)\n      (assume yift : y ∈ image f t,\n        let ⟨x,xt,fxy⟩ := exists_of_mem_image yift in\n        mem_image (mem_union_r xt) fxy)))\n\nend image\n\n\n/- separation and set-builder notation -/\nsection sep\nvariables {A : Type} [deceq : decidable_eq A]\ninclude deceq\nvariables (p : A → Prop) [decp : decidable_pred p] (s : finset A) {x : A}\ninclude decp\n\ndefinition sep : finset A :=\nquot.lift_on s\n  (λl, to_finset_of_nodup\n    (list.filter p l.1)\n    (list.nodup_filter p l.2))\n(λ l₁ l₂ u, quot.sound (perm.perm_filter u))\n\n-- notation [priority finset.prio] `{` binder ` ∈ ` s ` | ` r:(scoped:1 p, sep p s) `}` := r\n\ntheorem sep_empty : sep p empty = empty := rfl\n\nvariables {p s}\n\ntheorem of_mem_sep : x ∈ sep p s → p x :=\nquot.induction_on s (take l, list.of_mem_filter)\n\ntheorem mem_of_mem_sep : x ∈ sep p s → x ∈ s :=\nquot.induction_on s (take l, list.mem_of_mem_filter)\n\ntheorem mem_sep_of_mem {x : A} : x ∈ s → p x → x ∈ sep p s :=\nquot.induction_on s (take l, list.mem_filter_of_mem)\n\nvariables (p s)\n\n\ntheorem mem_sep_iff : x ∈ sep p s ↔ x ∈ s ∧ p x :=\niff.intro\n  (assume H, and.intro (mem_of_mem_sep H) (of_mem_sep H))\n  (assume H, mem_sep_of_mem (and.left H) (and.right H))\n\ntheorem mem_sep_eq : x ∈ sep p s = (x ∈ s ∧ p x) :=\npropext (mem_sep_iff _ _)\n\nvariable t : finset A\n\ntheorem mem_sep_union_iff : x ∈ sep p (s ∪ t) ↔ x ∈ sep p s ∨ x ∈ sep p t :=\nby repeat {rw mem_sep_iff}; rw [mem_union_iff]; super\n\nend sep\n\n\nsection\n\nvariables {A : Type} [deceqA : decidable_eq A]\ninclude deceqA\n\ntheorem eq_sep_of_subset {s t : finset A} (ssubt : s ⊆ t) : s = sep (λ x, x ∈ s) t := \next (take x, iff.intro\n  (suppose x ∈ s, mem_sep_of_mem (mem_of_subset_of_mem ssubt this) this)\n  (suppose x ∈ sep (λ x, x ∈ s) t, @of_mem_sep _ _ _ _ _ _ this))\n\nend\n\n/- set difference -/\nsection diff\nvariables {A : Type} [deceq : decidable_eq A]\ninclude deceq\n\ndefinition diff (s t : finset A) : finset A := sep (λ x, x ∉ t) s\ninfix ` \\ ` := diff\n\ntheorem mem_of_mem_diff {s t : finset A} {x : A} (H : x ∈ s \\ t) : x ∈ s :=\nmem_of_mem_sep H\n\ntheorem not_mem_of_mem_diff {s t : finset A} {x : A} (H : x ∈ s \\ t) : x ∉ t :=\n@of_mem_sep _ _ _ _ _ _ H\n\ntheorem mem_diff {s t : finset A} {x : A} (H1 : x ∈ s) (H2 : x ∉ t) : x ∈ s \\ t :=\nmem_sep_of_mem H1 H2\n\ntheorem mem_diff_iff (s t : finset A) (x : A) : x ∈ s \\ t ↔ x ∈ s ∧ x ∉ t :=\niff.intro\n  (assume H, and.intro (mem_of_mem_diff H) (not_mem_of_mem_diff H))\n  (assume H, mem_diff (and.left H) (and.right H))\n\ntheorem mem_diff_eq (s t : finset A) (x : A) : x ∈ s \\ t = (x ∈ s ∧ x ∉ t) :=\npropext (mem_diff_iff _ _ _)\n\ntheorem union_diff_cancel {s t : finset A} (H : s ⊆ t) : s ∪ (t \\ s) = t :=\next (take x, iff.intro\n  (suppose x ∈ s ∪ (t \\ s),\n    or.elim (mem_or_mem_of_mem_union this)\n      (suppose x ∈ s, mem_of_subset_of_mem H this)\n      (suppose x ∈ t \\ s, mem_of_mem_diff this))\n  (assume h,\n    decidable.by_cases\n      (suppose x ∈ s, mem_union_left _ this)\n      (suppose x ∉ s, mem_union_right _ (mem_diff h this))))\n\ntheorem diff_union_cancel {s t : finset A} (H : s ⊆ t) : (t \\ s) ∪ s = t :=\n@eq.subst _ (λ x, x = t) _ _ (union_comm _ _) (union_diff_cancel H)\n\nend diff\n\n/- set complement -/\nsection complement\n-- TODO\nend complement\n\nend finset\n", "meta": {"author": "minchaowu", "repo": "Kruskal.lean3", "sha": "a14516f47b21e636e9df914fc6ebe64cbe5cd38d", "save_path": "github-repos/lean/minchaowu-Kruskal.lean3", "path": "github-repos/lean/minchaowu-Kruskal.lean3/Kruskal.lean3-a14516f47b21e636e9df914fc6ebe64cbe5cd38d/finset/comb.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4742488975669351}}
{"text": "import GMLInit.Meta.Prelude\n\ntheorem eqRec_eq_cast {α} {a b : α} {motive : (b : α) → a = b → Sort _} (t : motive a rfl) (h : a = b) : Eq.rec t h = cast (show motive a rfl = motive b h by cases h; rfl) t := by cases h; rfl\n\ntheorem eqNdrec_eq_cast {α} {a b : α} {motive : α → Sort _} (t : motive a) (h : a = b) : Eq.ndrec t h = cast (h ▸ rfl) t := by cases h; rfl\n\ntheorem eqNdrec_symm {α} {motive : α → Sort _} {a b : α} (h : a = b) (x : motive a) (y : motive b) : Eq.ndrec x h = y ↔ x = Eq.ndrec y h.symm := by cases h; exact Iff.rfl\n\n@[elim_casts] theorem cast_irrel {α β} (h₁ h₂ : α = β) (a : α) : cast h₁ a = cast h₂ a := rfl\n\n@[elim_casts] theorem cast_refl {α} (a : α) : cast rfl a = a := rfl\n\n@[elim_casts] theorem cast_trans {α β γ} (h₁ : α = β) (h₂ : β = γ) (a : α) : cast h₂ (cast h₁ a) = cast (Eq.trans h₁ h₂) a := by cases h₁; cases h₂; rfl\n\n@[elim_casts] theorem cast_symm {α β} (h : α = β) (a : α) (b : β) : cast h a = b ↔ a = cast h.symm b := by cases h; exact Iff.rfl\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Logic/Cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6688802471698041, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.47424889345429355}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen,\n  Frédéric Dupuis, Heather Macbeth\n\n! This file was ported from Lean 3 source module algebra.module.linear_map\n! leanprover-community/mathlib commit cc8e88c7c8c7bc80f91f84d11adb584bf9bd658f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Hom.GroupAction\nimport Mathlib.Algebra.Module.Pi\nimport Mathlib.Algebra.Star.Basic\nimport Mathlib.Data.Set.Pointwise.SMul\nimport Mathlib.Algebra.Ring.CompTypeclasses\n\n/-!\n# (Semi)linear maps\n\nIn this file we define\n\n* `LinearMap σ M M₂`, `M →ₛₗ[σ] M₂` : a semilinear map between two `Module`s. Here,\n  `σ` is a `RingHom` from `R` to `R₂` and an `f : M →ₛₗ[σ] M₂` satisfies\n  `f (c • x) = (σ c) • (f x)`. We recover plain linear maps by choosing `σ` to be `RingHom.id R`.\n  This is denoted by `M →ₗ[R] M₂`. We also add the notation `M →ₗ⋆[R] M₂` for star-linear maps.\n\n* `IsLinearMap R f` : predicate saying that `f : M → M₂` is a linear map. (Note that this\n  was not generalized to semilinear maps.)\n\nWe then provide `LinearMap` with the following instances:\n\n* `LinearMap.addCommMonoid` and `LinearMap.AddCommGroup`: the elementwise addition structures\n  corresponding to addition in the codomain\n* `LinearMap.distribMulAction` and `LinearMap.module`: the elementwise scalar action structures\n  corresponding to applying the action in the codomain.\n* `Module.End.semiring` and `Module.End.ring`: the (semi)ring of endomorphisms formed by taking the\n  additive structure above with composition as multiplication.\n\n## Implementation notes\n\nTo ensure that composition works smoothly for semilinear maps, we use the typeclasses\n`RingHomCompTriple`, `RingHomInvPair` and `RingHomSurjective` from\n`Mathlib.Algebra.Ring.CompTypeclasses`.\n\n## Notation\n\n* Throughout the file, we denote regular linear maps by `fₗ`, `gₗ`, etc, and semilinear maps\n  by `f`, `g`, etc.\n\n## TODO\n\n* Parts of this file have not yet been generalized to semilinear maps (i.e. `CompatibleSMul`)\n\n## Tags\n\nlinear map\n-/\n\n\n-- Porting note: `assert_not_exists` is not defined yet\n/-\nassert_not_exists Submonoid\n\nassert_not_exists finset\n-/\n\nopen Function\n\nuniverse u u' v w x y z\n\nvariable {R : Type _} {R₁ : Type _} {R₂ : Type _} {R₃ : Type _}\nvariable {k : Type _} {S : Type _} {S₃ : Type _} {T : Type _}\nvariable {M : Type _} {M₁ : Type _} {M₂ : Type _} {M₃ : Type _}\nvariable {N₁ : Type _} {N₂ : Type _} {N₃ : Type _} {ι : Type _}\n\n/-- A map `f` between modules over a semiring is linear if it satisfies the two properties\n`f (x + y) = f x + f y` and `f (c • x) = c • f x`. The predicate `IsLinearMap R f` asserts this\nproperty. A bundled version is available with `LinearMap`, and should be favored over\n`IsLinearMap` most of the time. -/\nstructure IsLinearMap (R : Type u) {M : Type v} {M₂ : Type w} [Semiring R] [AddCommMonoid M]\n  [AddCommMonoid M₂] [Module R M] [Module R M₂] (f : M → M₂) : Prop where\n  /-- A linear map preserves addition. -/\n  map_add : ∀ x y, f (x + y) = f x + f y\n  /-- A linear map preserves scalar multiplication. -/\n  map_smul : ∀ (c : R) (x), f (c • x) = c • f x\n#align is_linear_map IsLinearMap\n\nsection\n\n/-- A map `f` between an `R`-module and an `S`-module over a ring homomorphism `σ : R →+* S`\nis semilinear if it satisfies the two properties `f (x + y) = f x + f y` and\n`f (c • x) = (σ c) • f x`. Elements of `LinearMap σ M M₂` (available under the notation\n`M →ₛₗ[σ] M₂`) are bundled versions of such maps. For plain linear maps (i.e. for which\n`σ = RingHom.id R`), the notation `M →ₗ[R] M₂` is available. An unbundled version of plain linear\nmaps is available with the predicate `IsLinearMap`, but it should be avoided most of the time. -/\nstructure LinearMap {R : Type _} {S : Type _} [Semiring R] [Semiring S] (σ : R →+* S) (M : Type _)\n    (M₂ : Type _) [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] extends\n    AddHom M M₂ where\n  /-- A linear map preserves scalar multiplication.\n  We prefer the spelling `_root_.map_smul` instead. -/\n  map_smul' : ∀ (r : R) (x : M), toFun (r • x) = σ r • toFun x\n#align linear_map LinearMap\n\n/-- The `add_hom` underlying a `LinearMap`. -/\nadd_decl_doc LinearMap.toAddHom\n#align linear_map.to_add_hom LinearMap.toAddHom\n\n-- mathport name: «expr →ₛₗ[ ] »\n/-- `M →ₛₗ[σ] N` is the type of `σ`-semilinear maps from `M` to `N`. -/\nnotation:25 M \" →ₛₗ[\" σ:25 \"] \" M₂:0 => LinearMap σ M M₂\n\n/-- `M →ₗ[R] N` is the type of `R`-linear maps from `M` to `N`. -/\n-- mathport name: «expr →ₗ[ ] »\nnotation:25 M \" →ₗ[\" R:25 \"] \" M₂:0 => LinearMap (RingHom.id R) M M₂\n\n/-- `M →ₗ⋆[R] N` is the type of `R`-conjugate-linear maps from `M` to `N`. -/\n-- mathport name: «expr →ₗ⋆[ ] »\nnotation:25 M \" →ₗ⋆[\" R:25 \"] \" M₂:0 => LinearMap (starRingEnd R) M M₂\n\n/-- `SemilinearMapClass F σ M M₂` asserts `F` is a type of bundled `σ`-semilinear maps `M → M₂`.\n\nSee also `LinearMapClass F R M M₂` for the case where `σ` is the identity map on `R`.\n\nA map `f` between an `R`-module and an `S`-module over a ring homomorphism `σ : R →+* S`\nis semilinear if it satisfies the two properties `f (x + y) = f x + f y` and\n`f (c • x) = (σ c) • f x`. -/\nclass SemilinearMapClass (F : Type _) {R S : outParam (Type _)} [Semiring R] [Semiring S]\n  (σ : outParam (R →+* S)) (M M₂ : outParam (Type _)) [AddCommMonoid M] [AddCommMonoid M₂]\n  [Module R M] [Module S M₂] extends AddHomClass F M M₂ where\n  /-- A semilinear map preserves scalar multiplication up to some ring homomorphism `σ`.\n  See also `_root_.map_smul` for the case where `σ` is the identity. -/\n  map_smulₛₗ : ∀ (f : F) (r : R) (x : M), f (r • x) = σ r • f x\n#align semilinear_map_class SemilinearMapClass\n\nend\n\n-- Porting note: `dangerousInstance` linter has become smarter about `outParam`s\n-- `σ` becomes a metavariable but that's fine because it's an `outParam`\n-- attribute [nolint dangerousInstance] SemilinearMapClass.toAddHomClass\n\nexport SemilinearMapClass (map_smulₛₗ)\n\nattribute [simp] map_smulₛₗ\n\n/-- `LinearMapClass F R M M₂` asserts `F` is a type of bundled `R`-linear maps `M → M₂`.\n\nThis is an abbreviation for `semilinear_map_class F (RingHom.id R) M M₂`.\n-/\nabbrev LinearMapClass (F : Type _) (R M M₂ : outParam (Type _)) [Semiring R] [AddCommMonoid M]\n    [AddCommMonoid M₂] [Module R M] [Module R M₂] :=\n  SemilinearMapClass F (RingHom.id R) M M₂\n#align linear_map_class LinearMapClass\n\nnamespace SemilinearMapClass\n\nvariable (F : Type _)\nvariable {_ : Semiring R} {_ : Semiring S}\nvariable {_ : AddCommMonoid M} {_ : AddCommMonoid M₁} {_ : AddCommMonoid M₂} {_ : AddCommMonoid M₃}\nvariable {_ : AddCommMonoid N₁} {_ : AddCommMonoid N₂} {_ : AddCommMonoid N₃}\nvariable {_ : Module R M} {_ : Module R M₂} {_ : Module S M₃}\nvariable {σ : R →+* S}\n\n-- Porting note: the `dangerousInstance` linter has become smarter about `outParam`s\n-- @[nolint dangerousInstance] -- `σ` is an `outParam` so it's not dangerous\ninstance (priority := 100) addMonoidHomClass [SemilinearMapClass F σ M M₃] :\n    AddMonoidHomClass F M M₃ :=\n  { SemilinearMapClass.toAddHomClass with\n    coe := fun f ↦ (f : M → M₃)\n    map_zero := fun f ↦\n      show f 0 = 0 by\n        rw [← zero_smul R (0 : M), map_smulₛₗ]\n        simp }\n\n-- The `Semiring` should be an instance parameter but depends on outParams.\n-- If Lean 4 gets better support for instance params depending on outParams,\n-- we should be able to remove this nolint.\n@[nolint dangerousInstance]\ninstance (priority := 100) distribMulActionHomClass [LinearMapClass F R M M₂] :\n    DistribMulActionHomClass F R M M₂ :=\n  { SemilinearMapClass.addMonoidHomClass F with\n    coe := fun f ↦ (f : M → M₂)\n    map_smul := fun f c x ↦ by rw [map_smulₛₗ, RingHom.id_apply] }\n\nvariable {F} (f : F) [i : SemilinearMapClass F σ M M₃]\n\ntheorem map_smul_inv {σ' : S →+* R} [RingHomInvPair σ σ'] (c : S) (x : M) :\n    c • f x = f (σ' c • x) := by simp\n#align semilinear_map_class.map_smul_inv SemilinearMapClass.map_smul_inv\n\nend SemilinearMapClass\n\nnamespace LinearMap\n\nsection AddCommMonoid\n\nvariable [Semiring R] [Semiring S]\n\nsection\n\nvariable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃]\n\nvariable [AddCommMonoid N₁] [AddCommMonoid N₂] [AddCommMonoid N₃]\n\nvariable [Module R M] [Module R M₂] [Module S M₃]\n\nvariable {σ : R →+* S}\n\ninstance : SemilinearMapClass (M →ₛₗ[σ] M₃) σ M M₃ where\n  coe f := f.toFun\n  coe_injective' f g h := by\n    cases f\n    cases g\n    congr\n    apply FunLike.coe_injective'\n    exact h\n  map_add f := f.map_add'\n  map_smulₛₗ := LinearMap.map_smul'\n\n-- Porting note: we don't port specialized `CoeFun` instances if there is `FunLike` instead\n#noalign LinearMap.has_coe_to_fun\n\n-- Porting note: adding this instance prevents a timeout in `ext_ring_op`\ninstance {σ : R →+* S} : FunLike (M →ₛₗ[σ] M₃) M (λ _ ↦ M₃) :=\n  { AddHomClass.toFunLike with }\n\n/-- The `DistribMulActionHom` underlying a `LinearMap`. -/\ndef toDistribMulActionHom (f : M →ₗ[R] M₂) : DistribMulActionHom R M M₂ :=\n  { f with map_zero' := show f 0 = 0 from map_zero f }\n#align linear_map.to_distrib_mul_action_hom LinearMap.toDistribMulActionHom\n\n@[simp]\ntheorem coe_toAddHom (f : M →ₛₗ[σ] M₃) : ⇑f.toAddHom = f := rfl\n\n-- porting note: no longer a `simp`\ntheorem toFun_eq_coe {f : M →ₛₗ[σ] M₃} : f.toFun = (f : M → M₃) := rfl\n#align linear_map.to_fun_eq_coe LinearMap.toFun_eq_coe\n\n@[ext]\ntheorem ext {f g : M →ₛₗ[σ] M₃} (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext f g h\n#align linear_map.ext LinearMap.ext\n\n/-- Copy of a `LinearMap` with a new `toFun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : M →ₛₗ[σ] M₃) (f' : M → M₃) (h : f' = ⇑f) : M →ₛₗ[σ] M₃\n    where\n  toFun := f'\n  map_add' := h.symm ▸ f.map_add'\n  map_smul' := h.symm ▸ f.map_smul'\n#align linear_map.copy LinearMap.copy\n\n@[simp]\ntheorem coe_copy (f : M →ₛₗ[σ] M₃) (f' : M → M₃) (h : f' = ⇑f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align linear_map.coe_copy LinearMap.coe_copy\n\ntheorem copy_eq (f : M →ₛₗ[σ] M₃) (f' : M → M₃) (h : f' = ⇑f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align linear_map.copy_eq LinearMap.copy_eq\n\ninitialize_simps_projections LinearMap (toFun → apply)\n\n@[simp]\ntheorem coe_mk {σ : R →+* S} (f : AddHom M M₃) (h) :\n    ((LinearMap.mk f h : M →ₛₗ[σ] M₃) : M → M₃) = f :=\n  rfl\n#align linear_map.coe_mk LinearMap.coe_mk\n\n-- Porting note: This theorem is new.\n@[simp]\ntheorem coe_addHom_mk {σ : R →+* S} (f : AddHom M M₃) (h) :\n    ((LinearMap.mk f h : M →ₛₗ[σ] M₃) : AddHom M M₃) = f :=\n  rfl\n\n/-- Identity map as a `LinearMap` -/\ndef id : M →ₗ[R] M :=\n  { DistribMulActionHom.id R with toFun := _root_.id }\n#align linear_map.id LinearMap.id\n\ntheorem id_apply (x : M) : @id R M _ _ _ x = x :=\n  rfl\n#align linear_map.id_apply LinearMap.id_apply\n\n@[simp, norm_cast]\ntheorem id_coe : ((LinearMap.id : M →ₗ[R] M) : M → M) = _root_.id :=\n  rfl\n#align linear_map.id_coe LinearMap.id_coe\n\nend\n\nsection\n\nvariable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃]\n\nvariable [AddCommMonoid N₁] [AddCommMonoid N₂] [AddCommMonoid N₃]\n\nvariable [Module R M] [Module R M₂] [Module S M₃]\n\nvariable (σ : R →+* S)\n\nvariable (fₗ gₗ : M →ₗ[R] M₂) (f g : M →ₛₗ[σ] M₃)\n\ntheorem isLinear : IsLinearMap R fₗ :=\n  ⟨fₗ.map_add', fₗ.map_smul'⟩\n#align linear_map.is_linear LinearMap.isLinear\n\nvariable {fₗ gₗ f g σ}\n\ntheorem coe_injective : Injective (FunLike.coe : (M →ₛₗ[σ] M₃) → _) :=\n  FunLike.coe_injective\n#align linear_map.coe_injective LinearMap.coe_injective\n\nprotected theorem congr_arg {x x' : M} : x = x' → f x = f x' :=\n  FunLike.congr_arg f\n#align linear_map.congr_arg LinearMap.congr_arg\n\n/-- If two linear maps are equal, they are equal at each point. -/\nprotected theorem congr_fun (h : f = g) (x : M) : f x = g x :=\n  FunLike.congr_fun h x\n#align linear_map.congr_fun LinearMap.congr_fun\n\ntheorem ext_iff : f = g ↔ ∀ x, f x = g x :=\n  FunLike.ext_iff\n#align linear_map.ext_iff LinearMap.ext_iff\n\n@[simp]\ntheorem mk_coe (f : M →ₛₗ[σ] M₃) (h) : (LinearMap.mk f h : M →ₛₗ[σ] M₃) = f :=\n  ext fun _ ↦ rfl\n#align linear_map.mk_coe LinearMap.mk_coe\n\nvariable (fₗ gₗ f g)\n\nprotected theorem map_add (x y : M) : f (x + y) = f x + f y :=\n  map_add f x y\n#align linear_map.map_add LinearMap.map_add\n\nprotected theorem map_zero : f 0 = 0 :=\n  map_zero f\n#align linear_map.map_zero LinearMap.map_zero\n\n-- Porting note: `simp` wasn't picking up `map_smulₛₗ` for `LinearMap`s without specifying\n-- `map_smulₛₗ f`, so we marked this as `@[simp]` in Mathlib3.\n-- For Mathlib4, let's try without the `@[simp]` attribute and hope it won't need to be re-enabled.\nprotected theorem map_smulₛₗ (c : R) (x : M) : f (c • x) = σ c • f x :=\n  map_smulₛₗ f c x\n#align linear_map.map_smulₛₗ LinearMap.map_smulₛₗ\n\nprotected theorem map_smul (c : R) (x : M) : fₗ (c • x) = c • fₗ x :=\n  map_smul fₗ c x\n#align linear_map.map_smul LinearMap.map_smul\n\nprotected theorem map_smul_inv {σ' : S →+* R} [RingHomInvPair σ σ'] (c : S) (x : M) :\n    c • f x = f (σ' c • x) := by simp\n#align linear_map.map_smul_inv LinearMap.map_smul_inv\n\n@[simp]\ntheorem map_eq_zero_iff (h : Function.Injective f) {x : M} : f x = 0 ↔ x = 0 :=\n  _root_.map_eq_zero_iff f h\n#align linear_map.map_eq_zero_iff LinearMap.map_eq_zero_iff\n\nsection Pointwise\n\nopen Pointwise\n\nvariable (M M₃ σ) {F : Type _} (h : F)\n\n@[simp]\ntheorem _root_.image_smul_setₛₗ [SemilinearMapClass F σ M M₃] (c : R) (s : Set M) :\n    h '' (c • s) = σ c • h '' s := by\n  apply Set.Subset.antisymm\n  · rintro x ⟨y, ⟨z, zs, rfl⟩, rfl⟩\n    exact ⟨h z, Set.mem_image_of_mem _ zs, (map_smulₛₗ _ _ _).symm⟩\n  · rintro x ⟨y, ⟨z, hz, rfl⟩, rfl⟩\n    exact (Set.mem_image _ _ _).2 ⟨c • z, Set.smul_mem_smul_set hz, map_smulₛₗ _ _ _⟩\n#align image_smul_setₛₗ image_smul_setₛₗ\n\ntheorem _root_.preimage_smul_setₛₗ [SemilinearMapClass F σ M M₃] {c : R} (hc : IsUnit c)\n    (s : Set M₃) :\n    h ⁻¹' (σ c • s) = c • h ⁻¹' s := by\n  apply Set.Subset.antisymm\n  · rintro x ⟨y, ys, hy⟩\n    refine' ⟨(hc.unit.inv : R) • x, _, _⟩\n    ·\n      simp only [← hy, smul_smul, Set.mem_preimage, Units.inv_eq_val_inv, map_smulₛₗ h, ← map_mul,\n        IsUnit.val_inv_mul, one_smul, map_one, ys]\n    · simp only [smul_smul, IsUnit.mul_val_inv, one_smul, Units.inv_eq_val_inv]\n  · rintro x ⟨y, hy, rfl⟩\n    refine' ⟨h y, hy, by simp only [RingHom.id_apply, map_smulₛₗ h]⟩\n#align preimage_smul_setₛₗ preimage_smul_setₛₗ\n\nvariable (R M₂)\n\ntheorem _root_.image_smul_set [LinearMapClass F R M M₂] (c : R) (s : Set M) :\n    h '' (c • s) = c • h '' s :=\n  image_smul_setₛₗ _ _ _ h c s\n#align image_smul_set image_smul_set\n\ntheorem _root_.preimage_smul_set [LinearMapClass F R M M₂] {c : R} (hc : IsUnit c) (s : Set M₂) :\n    h ⁻¹' (c • s) = c • h ⁻¹' s :=\n  preimage_smul_setₛₗ _ _ _ h hc s\n#align preimage_smul_set preimage_smul_set\n\nend Pointwise\n\nvariable (M M₂)\n\n/-- A typeclass for `has_smul` structures which can be moved through a `LinearMap`.\nThis typeclass is generated automatically from a `IsScalarTower` instance, but exists so that\nwe can also add an instance for `AddCommGroup.intModule`, allowing `z •` to be moved even if\n`R` does not support negation.\n-/\nclass CompatibleSMul (R S : Type _) [Semiring S] [SMul R M] [Module S M] [SMul R M₂]\n  [Module S M₂] where\n  /-- Scalar multiplication by `R` of `M` can be moved through linear maps. -/\n  map_smul : ∀ (fₗ : M →ₗ[S] M₂) (c : R) (x : M), fₗ (c • x) = c • fₗ x\n#align linear_map.compatible_smul LinearMap.CompatibleSMul\n\nvariable {M M₂}\n\ninstance (priority := 100) IsScalarTower.compatibleSMul {R S : Type _} [Semiring S] [SMul R S]\n    [SMul R M] [Module S M] [IsScalarTower R S M] [SMul R M₂] [Module S M₂] [IsScalarTower R S M₂] :\n    CompatibleSMul M M₂ R S :=\n  ⟨fun fₗ c x ↦ by rw [← smul_one_smul S c x, ← smul_one_smul S c (fₗ x), map_smul]⟩\n#align linear_map.is_scalar_tower.compatible_smul LinearMap.IsScalarTower.compatibleSMul\n\n@[simp]\ntheorem map_smul_of_tower {R S : Type _} [Semiring S] [SMul R M] [Module S M] [SMul R M₂]\n    [Module S M₂] [CompatibleSMul M M₂ R S] (fₗ : M →ₗ[S] M₂) (c : R) (x : M) :\n    fₗ (c • x) = c • fₗ x :=\n  CompatibleSMul.map_smul fₗ c x\n#align linear_map.map_smul_of_tower LinearMap.map_smul_of_tower\n\n/-- convert a linear map to an additive map -/\ndef toAddMonoidHom : M →+ M₃ where\n  toFun := f\n  map_zero' := f.map_zero\n  map_add' := f.map_add\n#align linear_map.to_add_monoid_hom LinearMap.toAddMonoidHom\n\n@[simp]\ntheorem toAddMonoidHom_coe : ⇑f.toAddMonoidHom = f :=\n  rfl\n#align linear_map.to_add_monoid_hom_coe LinearMap.toAddMonoidHom_coe\n\nsection RestrictScalars\n\nvariable (R)\nvariable [Module S M] [Module S M₂] [CompatibleSMul M M₂ R S]\n\n/-- If `M` and `M₂` are both `R`-modules and `S`-modules and `R`-module structures\nare defined by an action of `R` on `S` (formally, we have two scalar towers), then any `S`-linear\nmap from `M` to `M₂` is `R`-linear.\n\nSee also `LinearMap.map_smul_of_tower`. -/\n@[coe] def restrictScalars (fₗ : M →ₗ[S] M₂) : M →ₗ[R] M₂ where\n  toFun := fₗ\n  map_add' := fₗ.map_add\n  map_smul' := fₗ.map_smul_of_tower\n#align linear_map.restrict_scalars LinearMap.restrictScalars\n\n-- porting note: generalized from `Algebra` to `Compatible SMul`\ninstance coeIsScalarTower : CoeHTCT (M →ₗ[S] M₂) (M →ₗ[R] M₂) :=\n  ⟨restrictScalars R⟩\n#align linear_map.coe_is_scalar_tower LinearMap.coeIsScalarTower\n\n@[simp, norm_cast]\ntheorem coe_restrictScalars (f : M →ₗ[S] M₂) : ((f : M →ₗ[R] M₂) : M → M₂) = f :=\n  rfl\n#align linear_map.coe_restrict_scalars LinearMap.coe_restrictScalars\n\ntheorem restrictScalars_apply (fₗ : M →ₗ[S] M₂) (x) : restrictScalars R fₗ x = fₗ x :=\n  rfl\n#align linear_map.restrict_scalars_apply LinearMap.restrictScalars_apply\n\ntheorem restrictScalars_injective :\n    Function.Injective (restrictScalars R : (M →ₗ[S] M₂) → M →ₗ[R] M₂) := fun _ _ h ↦\n  ext (LinearMap.congr_fun h : _)\n#align linear_map.restrict_scalars_injective LinearMap.restrictScalars_injective\n\n@[simp]\ntheorem restrictScalars_inj (fₗ gₗ : M →ₗ[S] M₂) :\n    fₗ.restrictScalars R = gₗ.restrictScalars R ↔ fₗ = gₗ :=\n  (restrictScalars_injective R).eq_iff\n#align linear_map.restrict_scalars_inj LinearMap.restrictScalars_inj\n\nend RestrictScalars\n\ntheorem toAddMonoidHom_injective :\n    Function.Injective (toAddMonoidHom : (M →ₛₗ[σ] M₃) → M →+ M₃) := fun fₗ gₗ h ↦\n  ext <| (FunLike.congr_fun h : ∀ x, fₗ.toAddMonoidHom x = gₗ.toAddMonoidHom x)\n#align linear_map.to_add_monoid_hom_injective LinearMap.toAddMonoidHom_injective\n\n/-- If two `σ`-linear maps from `R` are equal on `1`, then they are equal. -/\n@[ext high]\ntheorem ext_ring {f g : R →ₛₗ[σ] M₃} (h : f 1 = g 1) : f = g :=\n  ext fun x ↦ by rw [← mul_one x, ← smul_eq_mul, f.map_smulₛₗ, g.map_smulₛₗ, h]\n#align linear_map.ext_ring LinearMap.ext_ring\n\ntheorem ext_ring_iff {σ : R →+* R} {f g : R →ₛₗ[σ] M} : f = g ↔ f 1 = g 1 :=\n  ⟨fun h ↦ h ▸ rfl, ext_ring⟩\n#align linear_map.ext_ring_iff LinearMap.ext_ring_iff\n\n@[ext high]\ntheorem ext_ring_op {σ : Rᵐᵒᵖ →+* S} {f g : R →ₛₗ[σ] M₃} (h : f (1 : R) = g (1 : R)) :\n    f = g :=\n  ext fun x ↦ by\n    -- Porting note: replaced the oneliner `rw` proof with a partially term-mode proof\n    -- because `rw` was giving \"motive is type incorrect\" errors\n    rw [← one_mul x, ← op_smul_eq_mul]\n    refine (f.map_smulₛₗ (MulOpposite.op x) 1).trans ?_\n    rw [h]\n    exact (g.map_smulₛₗ (MulOpposite.op x) 1).symm\n#align linear_map.ext_ring_op LinearMap.ext_ring_op\n\nend\n\n/-- Interpret a `RingHom` `f` as an `f`-semilinear map. -/\n@[simps]\ndef _root_.RingHom.toSemilinearMap (f : R →+* S) : R →ₛₗ[f] S :=\n  { f with\n    toFun := f\n    map_smul' := f.map_mul }\n#align ring_hom.to_semilinear_map RingHom.toSemilinearMap\n#align ring_hom.to_semilinear_map_apply RingHom.toSemilinearMap_apply\n\nsection\n\nvariable [Semiring R₁] [Semiring R₂] [Semiring R₃]\nvariable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃]\nvariable {module_M₁ : Module R₁ M₁} {module_M₂ : Module R₂ M₂} {module_M₃ : Module R₃ M₃}\nvariable {σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R₁ →+* R₃}\nvariable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]\nvariable (f : M₂ →ₛₗ[σ₂₃] M₃) (g : M₁ →ₛₗ[σ₁₂] M₂)\n\n/-- Composition of two linear maps is a linear map -/\ndef comp : M₁ →ₛₗ[σ₁₃] M₃ where\n  toFun := f ∘ g\n  map_add' := by simp only [map_add, forall_const, Function.comp_apply]\n  map_smul' r x := by simp only [Function.comp_apply, map_smulₛₗ, RingHomCompTriple.comp_apply]\n#align linear_map.comp LinearMap.comp\n\n-- mathport name: «expr ∘ₗ »\nset_option quotPrecheck false in -- Porting note: error message suggested to do this\n/-- `∘ₗ` is notation for composition of two linear (not semilinear!) maps into a linear map.\nThis is useful when Lean is struggling to infer the `RingHomCompTriple` instance. -/\ninfixr:80 \" ∘ₗ \" =>\n  @LinearMap.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ (RingHom.id _) (RingHom.id _) (RingHom.id _)\n    RingHomCompTriple.ids\n\ntheorem comp_apply (x : M₁) : f.comp g x = f (g x) :=\n  rfl\n#align linear_map.comp_apply LinearMap.comp_apply\n\n@[simp, norm_cast]\ntheorem coe_comp : (f.comp g : M₁ → M₃) = f ∘ g :=\n  rfl\n#align linear_map.coe_comp LinearMap.coe_comp\n\n@[simp]\ntheorem comp_id : f.comp id = f :=\n  LinearMap.ext fun _ ↦ rfl\n#align linear_map.comp_id LinearMap.comp_id\n\n@[simp]\ntheorem id_comp : id.comp f = f :=\n  LinearMap.ext fun _ ↦ rfl\n#align linear_map.id_comp LinearMap.id_comp\n\nvariable {f g} {f' : M₂ →ₛₗ[σ₂₃] M₃} {g' : M₁ →ₛₗ[σ₁₂] M₂}\n\ntheorem cancel_right (hg : Function.Surjective g) : f.comp g = f'.comp g ↔ f = f' :=\n  ⟨fun h ↦ ext <| hg.forall.2 (ext_iff.1 h), fun h ↦ h ▸ rfl⟩\n#align linear_map.cancel_right LinearMap.cancel_right\n\ntheorem cancel_left (hf : Function.Injective f) : f.comp g = f.comp g' ↔ g = g' :=\n  ⟨fun h ↦ ext fun x ↦ hf <| by rw [← comp_apply, h, comp_apply], fun h ↦ h ▸ rfl⟩\n#align linear_map.cancel_left LinearMap.cancel_left\n\nend\n\nvariable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃]\n\n/-- If a function `g` is a left and right inverse of a linear map `f`, then `g` is linear itself. -/\ndef inverse [Module R M] [Module S M₂] {σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ']\n    (f : M →ₛₗ[σ] M₂) (g : M₂ → M) (h₁ : LeftInverse g f) (h₂ : RightInverse g f) : M₂ →ₛₗ[σ'] M :=\n  by\n  dsimp [LeftInverse, Function.RightInverse] at h₁ h₂\n  exact\n    { toFun := g\n      map_add' := fun x y ↦ by rw [← h₁ (g (x + y)), ← h₁ (g x + g y)] ; simp [h₂]\n      map_smul' := fun a b ↦ by\n        dsimp only\n        rw [← h₁ (g (a • b)), ← h₁ (σ' a • g b)]\n        simp [h₂] }\n#align linear_map.inverse LinearMap.inverse\n\nend AddCommMonoid\n\nsection AddCommGroup\n\nvariable [Semiring R] [Semiring S] [AddCommGroup M] [AddCommGroup M₂]\n\nvariable {module_M : Module R M} {module_M₂ : Module S M₂} {σ : R →+* S}\n\nvariable (f : M →ₛₗ[σ] M₂)\n\nprotected theorem map_neg (x : M) : f (-x) = -f x :=\n  map_neg f x\n#align linear_map.map_neg LinearMap.map_neg\n\nprotected theorem map_sub (x y : M) : f (x - y) = f x - f y :=\n  map_sub f x y\n#align linear_map.map_sub LinearMap.map_sub\n\ninstance CompatibleSMul.intModule {S : Type _} [Semiring S] [Module S M] [Module S M₂] :\n    CompatibleSMul M M₂ ℤ S :=\n  ⟨fun fₗ c x ↦ by\n    induction c using Int.induction_on\n    case hz => simp\n    case hp n ih => simp [add_smul, ih]\n    case hn n ih => simp [sub_smul, ih]⟩\n#align linear_map.compatible_smul.int_module LinearMap.CompatibleSMul.intModule\n\ninstance CompatibleSMul.units {R S : Type _} [Monoid R] [MulAction R M] [MulAction R M₂]\n    [Semiring S] [Module S M] [Module S M₂] [CompatibleSMul M M₂ R S] : CompatibleSMul M M₂ Rˣ S :=\n  ⟨fun fₗ c x ↦ (CompatibleSMul.map_smul fₗ (c : R) x : _)⟩\n#align linear_map.compatible_smul.units LinearMap.CompatibleSMul.units\n\nend AddCommGroup\n\nend LinearMap\n\nnamespace Module\n\n/-- `g : R →+* S` is `R`-linear when the module structure on `S` is `module.comp_hom S g` . -/\n@[simps]\ndef compHom.toLinearMap {R S : Type _} [Semiring R] [Semiring S] (g : R →+* S) :\n    letI := compHom S g; R →ₗ[R] S :=\nletI := compHom S g\n{ toFun := (g : R → S)\n  map_add' := g.map_add\n  map_smul' := g.map_mul }\n#align module.comp_hom.to_linear_map Module.compHom.toLinearMap\n#align module.comp_hom.to_linear_map_apply Module.compHom.toLinearMap_apply\n\nend Module\n\nnamespace DistribMulActionHom\n\nvariable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R M₂]\n\n/-- A `DistribMulActionHom` between two modules is a linear map. -/\n@[coe]\ndef toLinearMap (fₗ : M →+[R] M₂) : M →ₗ[R] M₂ :=\n  { fₗ with }\n#align distrib_mul_action_hom.to_linear_map DistribMulActionHom.toLinearMap\n\ninstance : Coe (M →+[R] M₂) (M →ₗ[R] M₂) :=\n  ⟨toLinearMap⟩\n\n-- Porting note: because coercions get unfolded, there is no need for this rewrite\n#noalign distrib_mul_action_hom.to_linear_map_eq_coe\n\n-- Porting note: removed @[norm_cast] attribute due to error:\n-- norm_cast: badly shaped lemma, rhs can't start with coe\n@[simp]\ntheorem coe_toLinearMap (f : M →+[R] M₂) : ((f : M →ₗ[R] M₂) : M → M₂) = f :=\n  rfl\n#align distrib_mul_action_hom.coe_to_linear_map DistribMulActionHom.coe_toLinearMap\n\ntheorem toLinearMap_injective {f g : M →+[R] M₂} (h : (f : M →ₗ[R] M₂) = (g : M →ₗ[R] M₂)) :\n    f = g := by\n  ext m\n  exact LinearMap.congr_fun h m\n#align distrib_mul_action_hom.to_linear_map_injective DistribMulActionHom.toLinearMap_injective\n\nend DistribMulActionHom\n\nnamespace IsLinearMap\n\nsection AddCommMonoid\n\nvariable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂]\nvariable [Module R M] [Module R M₂]\n\n/-- Convert an `IsLinearMap` predicate to a `LinearMap` -/\ndef mk' (f : M → M₂) (H : IsLinearMap R f) : M →ₗ[R] M₂\n    where\n  toFun := f\n  map_add' := H.1\n  map_smul' := H.2\n#align is_linear_map.mk' IsLinearMap.mk'\n\n@[simp]\ntheorem mk'_apply {f : M → M₂} (H : IsLinearMap R f) (x : M) : mk' f H x = f x :=\n  rfl\n#align is_linear_map.mk'_apply IsLinearMap.mk'_apply\n\ntheorem isLinearMap_smul {R M : Type _} [CommSemiring R] [AddCommMonoid M] [Module R M] (c : R) :\n    IsLinearMap R fun z : M ↦ c • z :=\n  by\n  refine' IsLinearMap.mk (smul_add c) _\n  intro _ _\n  simp only [smul_smul, mul_comm]\n#align is_linear_map.is_linear_map_smul IsLinearMap.isLinearMap_smul\n\ntheorem isLinearMap_smul' {R M : Type _} [Semiring R] [AddCommMonoid M] [Module R M] (a : M) :\n    IsLinearMap R fun c : R ↦ c • a :=\n  IsLinearMap.mk (fun x y ↦ add_smul x y a) fun x y ↦ mul_smul x y a\n#align is_linear_map.is_linear_map_smul' IsLinearMap.isLinearMap_smul'\n\nvariable {f : M → M₂} (lin : IsLinearMap R f)\n\ntheorem map_zero : f (0 : M) = (0 : M₂) :=\n  (lin.mk' f).map_zero\n#align is_linear_map.map_zero IsLinearMap.map_zero\n\nend AddCommMonoid\n\nsection AddCommGroup\n\nvariable [Semiring R] [AddCommGroup M] [AddCommGroup M₂]\nvariable [Module R M] [Module R M₂]\n\ntheorem isLinearMap_neg : IsLinearMap R fun z : M ↦ -z :=\n  IsLinearMap.mk neg_add fun x y ↦ (smul_neg x y).symm\n#align is_linear_map.is_linear_map_neg IsLinearMap.isLinearMap_neg\n\nvariable {f : M → M₂} (lin : IsLinearMap R f)\n\ntheorem map_neg (x : M) : f (-x) = -f x :=\n  (lin.mk' f).map_neg x\n#align is_linear_map.map_neg IsLinearMap.map_neg\n\ntheorem map_sub (x y) : f (x - y) = f x - f y :=\n  (lin.mk' f).map_sub x y\n#align is_linear_map.map_sub IsLinearMap.map_sub\n\nend AddCommGroup\n\nend IsLinearMap\n\n/-- Linear endomorphisms of a module, with associated ring structure\n`Module.End.semiring` and algebra structure `Module.End.algebra`. -/\nabbrev Module.End (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] [Module R M] :=\n  M →ₗ[R] M\n#align module.End Module.End\n\n/-- Reinterpret an additive homomorphism as a `ℕ`-linear map. -/\ndef AddMonoidHom.toNatLinearMap [AddCommMonoid M] [AddCommMonoid M₂] (f : M →+ M₂) : M →ₗ[ℕ] M₂\n    where\n  toFun := f\n  map_add' := f.map_add\n  map_smul' := map_nsmul f\n#align add_monoid_hom.to_nat_linear_map AddMonoidHom.toNatLinearMap\n\ntheorem AddMonoidHom.toNatLinearMap_injective [AddCommMonoid M] [AddCommMonoid M₂] :\n    Function.Injective (@AddMonoidHom.toNatLinearMap M M₂ _ _) :=\n  by\n  intro f g h\n  ext x\n  exact LinearMap.congr_fun h x\n#align add_monoid_hom.to_nat_linear_map_injective AddMonoidHom.toNatLinearMap_injective\n\n/-- Reinterpret an additive homomorphism as a `ℤ`-linear map. -/\ndef AddMonoidHom.toIntLinearMap [AddCommGroup M] [AddCommGroup M₂] (f : M →+ M₂) : M →ₗ[ℤ] M₂\n    where\n  toFun := f\n  map_add' := f.map_add\n  map_smul' := map_zsmul f\n#align add_monoid_hom.to_int_linear_map AddMonoidHom.toIntLinearMap\n\ntheorem AddMonoidHom.toIntLinearMap_injective [AddCommGroup M] [AddCommGroup M₂] :\n    Function.Injective (@AddMonoidHom.toIntLinearMap M M₂ _ _) :=\n  by\n  intro f g h\n  ext x\n  exact LinearMap.congr_fun h x\n#align add_monoid_hom.to_int_linear_map_injective AddMonoidHom.toIntLinearMap_injective\n\n@[simp]\ntheorem AddMonoidHom.coe_toIntLinearMap [AddCommGroup M] [AddCommGroup M₂] (f : M →+ M₂) :\n    ⇑f.toIntLinearMap = f :=\n  rfl\n#align add_monoid_hom.coe_to_int_linear_map AddMonoidHom.coe_toIntLinearMap\n\n/-- Reinterpret an additive homomorphism as a `ℚ`-linear map. -/\ndef AddMonoidHom.toRatLinearMap [AddCommGroup M] [Module ℚ M] [AddCommGroup M₂] [Module ℚ M₂]\n    (f : M →+ M₂) : M →ₗ[ℚ] M₂ :=\n  { f with map_smul' := map_rat_smul f }\n#align add_monoid_hom.to_rat_linear_map AddMonoidHom.toRatLinearMap\n\ntheorem AddMonoidHom.toRatLinearMap_injective [AddCommGroup M] [Module ℚ M] [AddCommGroup M₂]\n    [Module ℚ M₂] : Function.Injective (@AddMonoidHom.toRatLinearMap M M₂ _ _ _ _) :=\n  by\n  intro f g h\n  ext x\n  exact LinearMap.congr_fun h x\n#align add_monoid_hom.to_rat_linear_map_injective AddMonoidHom.toRatLinearMap_injective\n\n@[simp]\ntheorem AddMonoidHom.coe_toRatLinearMap [AddCommGroup M] [Module ℚ M] [AddCommGroup M₂]\n    [Module ℚ M₂] (f : M →+ M₂) : ⇑f.toRatLinearMap = f :=\n  rfl\n#align add_monoid_hom.coe_to_rat_linear_map AddMonoidHom.coe_toRatLinearMap\n\nnamespace LinearMap\n\nsection SMul\n\nvariable [Semiring R] [Semiring R₂] [Semiring R₃]\nvariable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃]\nvariable [Module R M] [Module R₂ M₂] [Module R₃ M₃]\nvariable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]\nvariable [Monoid S] [DistribMulAction S M₂] [SMulCommClass R₂ S M₂]\nvariable [Monoid S₃] [DistribMulAction S₃ M₃] [SMulCommClass R₃ S₃ M₃]\nvariable [Monoid T] [DistribMulAction T M₂] [SMulCommClass R₂ T M₂]\n\ninstance : SMul S (M →ₛₗ[σ₁₂] M₂) :=\n  ⟨fun a f ↦\n    { toFun := a • (f : M → M₂)\n      map_add' := fun x y ↦ by simp only [Pi.smul_apply, f.map_add, smul_add]\n      map_smul' := fun c x ↦ by simp [Pi.smul_apply, smul_comm] }⟩\n\n@[simp]\ntheorem smul_apply (a : S) (f : M →ₛₗ[σ₁₂] M₂) (x : M) : (a • f) x = a • f x :=\n  rfl\n#align linear_map.smul_apply LinearMap.smul_apply\n\ntheorem coe_smul (a : S) (f : M →ₛₗ[σ₁₂] M₂) : (a • f : M →ₛₗ[σ₁₂] M₂) = a • (f : M → M₂) :=\n  rfl\n#align linear_map.coe_smul LinearMap.coe_smul\n\ninstance [SMulCommClass S T M₂] : SMulCommClass S T (M →ₛₗ[σ₁₂] M₂) :=\n  ⟨fun _ _ _ ↦ ext fun _ ↦ smul_comm _ _ _⟩\n\n-- example application of this instance: if S -> T -> R are homomorphisms of commutative rings and\n-- M and M₂ are R-modules then the S-module and T-module structures on Hom_R(M,M₂) are compatible.\ninstance [SMul S T] [IsScalarTower S T M₂] : IsScalarTower S T (M →ₛₗ[σ₁₂] M₂)\n    where smul_assoc _ _ _ := ext fun _ ↦ smul_assoc _ _ _\n\ninstance [DistribMulAction Sᵐᵒᵖ M₂] [SMulCommClass R₂ Sᵐᵒᵖ M₂] [IsCentralScalar S M₂] :\n    IsCentralScalar S (M →ₛₗ[σ₁₂] M₂) where op_smul_eq_smul _ _ := ext fun _ ↦ op_smul_eq_smul _ _\n\nend SMul\n\n/-! ### Arithmetic on the codomain -/\n\n\nsection Arithmetic\n\nvariable [Semiring R₁] [Semiring R₂] [Semiring R₃]\nvariable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃]\nvariable [AddCommGroup N₁] [AddCommGroup N₂] [AddCommGroup N₃]\nvariable [Module R₁ M] [Module R₂ M₂] [Module R₃ M₃]\nvariable [Module R₁ N₁] [Module R₂ N₂] [Module R₃ N₃]\nvariable {σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R₁ →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]\n\n/-- The constant 0 map is linear. -/\ninstance : Zero (M →ₛₗ[σ₁₂] M₂) :=\n  ⟨{  toFun := 0\n      map_add' := by simp\n      map_smul' := by simp }⟩\n\n@[simp]\ntheorem zero_apply (x : M) : (0 : M →ₛₗ[σ₁₂] M₂) x = 0 :=\n  rfl\n#align linear_map.zero_apply LinearMap.zero_apply\n\n@[simp]\ntheorem comp_zero (g : M₂ →ₛₗ[σ₂₃] M₃) : (g.comp (0 : M →ₛₗ[σ₁₂] M₂) : M →ₛₗ[σ₁₃] M₃) = 0 :=\n  ext fun c ↦ by rw [comp_apply, zero_apply, zero_apply, g.map_zero]\n#align linear_map.comp_zero LinearMap.comp_zero\n\n@[simp]\ntheorem zero_comp (f : M →ₛₗ[σ₁₂] M₂) : ((0 : M₂ →ₛₗ[σ₂₃] M₃).comp f : M →ₛₗ[σ₁₃] M₃) = 0 :=\n  rfl\n#align linear_map.zero_comp LinearMap.zero_comp\n\ninstance : Inhabited (M →ₛₗ[σ₁₂] M₂) :=\n  ⟨0⟩\n\n@[simp]\ntheorem default_def : (default : M →ₛₗ[σ₁₂] M₂) = 0 :=\n  rfl\n#align linear_map.default_def LinearMap.default_def\n\n/-- The sum of two linear maps is linear. -/\ninstance : Add (M →ₛₗ[σ₁₂] M₂) :=\n  ⟨fun f g ↦\n    { toFun := f + g\n      map_add' := by simp [add_comm, add_left_comm]\n      map_smul' := by simp [smul_add] }⟩\n\n@[simp]\n\n\ntheorem add_comp (f : M →ₛₗ[σ₁₂] M₂) (g h : M₂ →ₛₗ[σ₂₃] M₃) :\n    ((h + g).comp f : M →ₛₗ[σ₁₃] M₃) = h.comp f + g.comp f :=\n  rfl\n#align linear_map.add_comp LinearMap.add_comp\n\ntheorem comp_add (f g : M →ₛₗ[σ₁₂] M₂) (h : M₂ →ₛₗ[σ₂₃] M₃) :\n    (h.comp (f + g) : M →ₛₗ[σ₁₃] M₃) = h.comp f + h.comp g :=\n  ext fun _ ↦ h.map_add _ _\n#align linear_map.comp_add LinearMap.comp_add\n\n/-- The type of linear maps is an additive monoid. -/\ninstance addCommMonoid : AddCommMonoid (M →ₛₗ[σ₁₂] M₂) :=\n  FunLike.coe_injective.addCommMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl\n\n/-- The negation of a linear map is linear. -/\ninstance : Neg (M →ₛₗ[σ₁₂] N₂) :=\n  ⟨fun f ↦\n    { toFun := -f\n      map_add' := by simp [add_comm]\n      map_smul' := by simp }⟩\n\n@[simp]\ntheorem neg_apply (f : M →ₛₗ[σ₁₂] N₂) (x : M) : (-f) x = -f x :=\n  rfl\n#align linear_map.neg_apply LinearMap.neg_apply\n\n@[simp]\ntheorem neg_comp (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] N₃) : (-g).comp f = -g.comp f :=\n  rfl\n#align linear_map.neg_comp LinearMap.neg_comp\n\n@[simp]\ntheorem comp_neg (f : M →ₛₗ[σ₁₂] N₂) (g : N₂ →ₛₗ[σ₂₃] N₃) : g.comp (-f) = -g.comp f :=\n  ext fun _ ↦ g.map_neg _\n#align linear_map.comp_neg LinearMap.comp_neg\n\n/-- The subtraction of two linear maps is linear. -/\ninstance : Sub (M →ₛₗ[σ₁₂] N₂) :=\n  ⟨fun f g ↦\n    { toFun := f - g\n      map_add' := fun x y ↦ by simp only [Pi.sub_apply, map_add, add_sub_add_comm]\n      map_smul' := fun r x ↦ by simp [Pi.sub_apply, map_smul, smul_sub] }⟩\n\n@[simp]\ntheorem sub_apply (f g : M →ₛₗ[σ₁₂] N₂) (x : M) : (f - g) x = f x - g x :=\n  rfl\n#align linear_map.sub_apply LinearMap.sub_apply\n\ntheorem sub_comp (f : M →ₛₗ[σ₁₂] M₂) (g h : M₂ →ₛₗ[σ₂₃] N₃) :\n    (g - h).comp f = g.comp f - h.comp f :=\n  rfl\n#align linear_map.sub_comp LinearMap.sub_comp\n\ntheorem comp_sub (f g : M →ₛₗ[σ₁₂] N₂) (h : N₂ →ₛₗ[σ₂₃] N₃) :\n    h.comp (g - f) = h.comp g - h.comp f :=\n  ext fun _ ↦ h.map_sub _ _\n#align linear_map.comp_sub LinearMap.comp_sub\n\n/-- The type of linear maps is an additive group. -/\ninstance addCommGroup : AddCommGroup (M →ₛₗ[σ₁₂] N₂) :=\n  FunLike.coe_injective.addCommGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl)\n    (fun _ _ ↦ rfl) fun _ _ ↦ rfl\n\nend Arithmetic\n\nsection Actions\n\nvariable [Semiring R] [Semiring R₂] [Semiring R₃]\nvariable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃]\nvariable [Module R M] [Module R₂ M₂] [Module R₃ M₃]\nvariable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]\n\nsection SMul\n\nvariable [Monoid S] [DistribMulAction S M₂] [SMulCommClass R₂ S M₂]\nvariable [Monoid S₃] [DistribMulAction S₃ M₃] [SMulCommClass R₃ S₃ M₃]\nvariable [Monoid T] [DistribMulAction T M₂] [SMulCommClass R₂ T M₂]\n\ninstance : DistribMulAction S (M →ₛₗ[σ₁₂] M₂)\n    where\n  one_smul _ := ext fun _ ↦ one_smul _ _\n  mul_smul _ _ _ := ext fun _ ↦ mul_smul _ _ _\n  smul_add _ _ _ := ext fun _ ↦ smul_add _ _ _\n  smul_zero _ := ext fun _ ↦ smul_zero _\n\ntheorem smul_comp (a : S₃) (g : M₂ →ₛₗ[σ₂₃] M₃) (f : M →ₛₗ[σ₁₂] M₂) :\n    (a • g).comp f = a • g.comp f :=\n  rfl\n#align linear_map.smul_comp LinearMap.smul_comp\n\n-- TODO: generalize this to semilinear maps\ntheorem comp_smul [Module R M₂] [Module R M₃] [SMulCommClass R S M₂] [DistribMulAction S M₃]\n    [SMulCommClass R S M₃] [CompatibleSMul M₃ M₂ S R] (g : M₃ →ₗ[R] M₂) (a : S) (f : M →ₗ[R] M₃) :\n    g.comp (a • f) = a • g.comp f :=\n  ext fun _ ↦ g.map_smul_of_tower _ _\n#align linear_map.comp_smul LinearMap.comp_smul\n\nend SMul\n\nsection Module\n\nvariable [Semiring S] [Module S M₂] [SMulCommClass R₂ S M₂]\n\ninstance : Module S (M →ₛₗ[σ₁₂] M₂)\n    where\n  add_smul _ _ _ := ext fun _ ↦ add_smul _ _ _\n  zero_smul _ := ext fun _ ↦ zero_smul _ _\n\ninstance [NoZeroSMulDivisors S M₂] : NoZeroSMulDivisors S (M →ₛₗ[σ₁₂] M₂) :=\n  coe_injective.noZeroSMulDivisors _ rfl coe_smul\n\nend Module\n\nend Actions\n\n/-!\n### Monoid structure of endomorphisms\n\nLemmas about `pow` such as `LinearMap.pow_apply` appear in later files.\n-/\n\n\nsection Endomorphisms\n\nvariable [Semiring R] [AddCommMonoid M] [AddCommGroup N₁] [Module R M] [Module R N₁]\n\ninstance : One (Module.End R M) :=\n  ⟨LinearMap.id⟩\n\ninstance : Mul (Module.End R M) :=\n  ⟨LinearMap.comp⟩\n\ntheorem one_eq_id : (1 : Module.End R M) = id :=\n  rfl\n#align linear_map.one_eq_id LinearMap.one_eq_id\n\ntheorem mul_eq_comp (f g : Module.End R M) : f * g = f.comp g :=\n  rfl\n#align linear_map.mul_eq_comp LinearMap.mul_eq_comp\n\n@[simp]\ntheorem one_apply (x : M) : (1 : Module.End R M) x = x :=\n  rfl\n#align linear_map.one_apply LinearMap.one_apply\n\n@[simp]\ntheorem mul_apply (f g : Module.End R M) (x : M) : (f * g) x = f (g x) :=\n  rfl\n#align linear_map.mul_apply LinearMap.mul_apply\n\ntheorem coe_one : ⇑(1 : Module.End R M) = _root_.id :=\n  rfl\n#align linear_map.coe_one LinearMap.coe_one\n\ntheorem coe_mul (f g : Module.End R M) : ⇑(f * g) = f ∘ g :=\n  rfl\n#align linear_map.coe_mul LinearMap.coe_mul\n\ninstance _root_.Module.End.monoid : Monoid (Module.End R M)\n    where\n  mul := (· * ·)\n  one := (1 : M →ₗ[R] M)\n  mul_assoc f g h := LinearMap.ext fun x ↦ rfl\n  mul_one := comp_id\n  one_mul := id_comp\n#align module.End.monoid Module.End.monoid\n\ninstance _root_.Module.End.semiring : Semiring (Module.End R M) :=\n  { AddMonoidWithOne.unary, Module.End.monoid, LinearMap.addCommMonoid with\n    mul := (· * ·)\n    one := (1 : M →ₗ[R] M)\n    zero := (0 : M →ₗ[R] M)\n    add := (· + ·)\n    mul_zero := comp_zero\n    zero_mul := zero_comp\n    left_distrib := fun _ _ _ ↦ comp_add _ _ _\n    right_distrib := fun _ _ _ ↦ add_comp _ _ _\n    natCast := fun n ↦ n • (1 : M →ₗ[R] M)\n    natCast_zero := zero_smul ℕ (1 : M →ₗ[R] M)\n    natCast_succ := fun n ↦ (AddMonoid.nsmul_succ n (1 : M →ₗ[R] M)).trans (add_comm _ _) }\n#align module.End.semiring Module.End.semiring\n\n/-- See also `Module.End.natCast_def`. -/\n@[simp]\ntheorem _root_.Module.End.natCast_apply (n : ℕ) (m : M) : (↑n : Module.End R M) m = n • m :=\n  rfl\n#align module.End.nat_cast_apply Module.End.natCast_apply\n\n-- *TODO*: why are you still timing out?\nset_option maxHeartbeats 300000 in\ninstance _root_.Module.End.ring : Ring (Module.End R N₁) :=\n  { Module.End.semiring, LinearMap.addCommGroup with\n    mul := (· * ·)\n    one := (1 : N₁ →ₗ[R] N₁)\n    zero := (0 : N₁ →ₗ[R] N₁)\n    add := (· + ·)\n    intCast := fun z ↦ z • (1 : N₁ →ₗ[R] N₁)\n    intCast_ofNat := ofNat_zsmul _\n    intCast_negSucc := negSucc_zsmul _ }\n#align module.End.ring Module.End.ring\n\n/-- See also `Module.End.intCast_def`. -/\n@[simp]\ntheorem _root_.Module.End.intCast_apply (z : ℤ) (m : N₁) : (z : Module.End R N₁) m = z • m :=\n  rfl\n#align module.End.int_cast_apply Module.End.intCast_apply\n\nsection\n\nvariable [Monoid S] [DistribMulAction S M] [SMulCommClass R S M]\n\ninstance _root_.Module.End.isScalarTower :\n    IsScalarTower S (Module.End R M) (Module.End R M) :=\n  ⟨smul_comp⟩\n#align module.End.is_scalar_tower Module.End.isScalarTower\n\ninstance _root_.Module.End.smulCommClass [SMul S R] [IsScalarTower S R M] :\n    SMulCommClass S (Module.End R M) (Module.End R M) :=\n  ⟨fun s _ _ ↦ (comp_smul _ s _).symm⟩\n#align module.End.smul_comm_class Module.End.smulCommClass\n\ninstance _root_.Module.End.smulCommClass' [SMul S R] [IsScalarTower S R M] :\n    SMulCommClass (Module.End R M) S (Module.End R M) :=\n  SMulCommClass.symm _ _ _\n#align module.End.smul_comm_class' Module.End.smulCommClass'\n\nend\n\n/-! ### Action by a module endomorphism. -/\n\n\n/-- The tautological action by `module.End R M` (aka `M →ₗ[R] M`) on `M`.\n\nThis generalizes `Function.End.applyMulAction`. -/\ninstance applyModule : Module (Module.End R M) M\n    where\n  smul := (· <| ·)\n  smul_zero := LinearMap.map_zero\n  smul_add := LinearMap.map_add\n  add_smul := LinearMap.add_apply\n  zero_smul := (LinearMap.zero_apply : ∀ m, (0 : M →ₗ[R] M) m = 0)\n  one_smul _ := rfl\n  mul_smul _ _ _ := rfl\n#align linear_map.apply_module LinearMap.applyModule\n\n@[simp]\nprotected theorem smul_def (f : Module.End R M) (a : M) : f • a = f a :=\n  rfl\n#align linear_map.smul_def LinearMap.smul_def\n\n/-- `LinearMap.applyModule` is faithful. -/\ninstance apply_faithfulSMul : FaithfulSMul (Module.End R M) M :=\n  ⟨LinearMap.ext⟩\n#align linear_map.apply_has_faithful_smul LinearMap.apply_faithfulSMul\n\ninstance apply_smulCommClass : SMulCommClass R (Module.End R M) M\n    where smul_comm r e m := (e.map_smul r m).symm\n#align linear_map.apply_smul_comm_class LinearMap.apply_smulCommClass\n\ninstance apply_smulCommClass' : SMulCommClass (Module.End R M) R M\n    where smul_comm := LinearMap.map_smul\n#align linear_map.apply_smul_comm_class' LinearMap.apply_smulCommClass'\n\ninstance apply_isScalarTower {R M : Type _} [CommSemiring R] [AddCommMonoid M] [Module R M] :\n    IsScalarTower R (Module.End R M) M :=\n  ⟨fun _ _ _ ↦ rfl⟩\n#align linear_map.apply_is_scalar_tower LinearMap.apply_isScalarTower\n\nend Endomorphisms\n\nend LinearMap\n\n/-! ### Actions as module endomorphisms -/\n\n\nnamespace DistribMulAction\n\nvariable (R M) [Semiring R] [AddCommMonoid M] [Module R M]\n\nvariable [Monoid S] [DistribMulAction S M] [SMulCommClass S R M]\n\n/-- Each element of the monoid defines a linear map.\n\nThis is a stronger version of `DistribMulAction.toAddMonoidHom`. -/\n@[simps]\ndef toLinearMap (s : S) : M →ₗ[R] M where\n  toFun := SMul.smul s\n  map_add' := smul_add s\n  map_smul' _ _ := smul_comm _ _ _\n#align distrib_mul_action.to_linear_map DistribMulAction.toLinearMap\n#align distrib_mul_action.to_linear_map_apply DistribMulAction.toLinearMap_apply\n\n/-- Each element of the monoid defines a module endomorphism.\n\nThis is a stronger version of `DistribMulAction.toAddMonoidEnd`. -/\n@[simps]\ndef toModuleEnd : S →* Module.End R M\n    where\n  toFun := toLinearMap R M\n  map_one' := LinearMap.ext <| one_smul _\n  map_mul' _ _ := LinearMap.ext <| mul_smul _ _\n#align distrib_mul_action.to_module_End DistribMulAction.toModuleEnd\n#align distrib_mul_action.to_module_End_apply DistribMulAction.toModuleEnd_apply\n\nend DistribMulAction\n\nnamespace Module\n\nvariable (R M) [Semiring R] [AddCommMonoid M] [Module R M]\n\nvariable [Semiring S] [Module S M] [SMulCommClass S R M]\n\n/-- Each element of the semiring defines a module endomorphism.\n\nThis is a stronger version of `DistribMulAction.toModuleEnd`. -/\n@[simps]\ndef toModuleEnd : S →+* Module.End R M :=\n  {\n    DistribMulAction.toModuleEnd R\n      M with\n    toFun := DistribMulAction.toLinearMap R M\n    map_zero' := LinearMap.ext <| zero_smul _\n    map_add' := fun _ _ ↦ LinearMap.ext <| add_smul _ _ }\n#align module.to_module_End Module.toModuleEnd\n#align module.to_module_End_apply Module.toModuleEnd_apply\n\n/-- The canonical (semi)ring isomorphism from `Rᵐᵒᵖ` to `Module.End R R` induced by the right\nmultiplication. -/\n@[simps]\ndef moduleEndSelf : Rᵐᵒᵖ ≃+* Module.End R R :=\n  { Module.toModuleEnd R R with\n    toFun := DistribMulAction.toLinearMap R R\n    invFun := fun f ↦ MulOpposite.op (f 1)\n    left_inv := mul_one\n    right_inv := fun _ ↦ LinearMap.ext_ring <| one_mul _ }\n#align module.module_End_self Module.moduleEndSelf\n#align module.module_End_self_apply Module.moduleEndSelf_apply\n\n/-- The canonical (semi)ring isomorphism from `R` to `Module.End Rᵐᵒᵖ R` induced by the left\nmultiplication. -/\n@[simps]\ndef moduleEndSelfOp : R ≃+* Module.End Rᵐᵒᵖ R :=\n  { Module.toModuleEnd _ _ with\n    toFun := DistribMulAction.toLinearMap _ _\n    invFun := fun f ↦ f 1\n    left_inv := mul_one\n    right_inv := fun _ ↦ LinearMap.ext_ring_op <| mul_one _ }\n#align module.module_End_self_op Module.moduleEndSelfOp\n#align module.module_End_self_op_symm_apply Module.moduleEndSelfOp_symm_apply\n#align module.module_End_self_op_apply Module.moduleEndSelfOp_apply\n\ntheorem End.natCast_def (n : ℕ) [AddCommMonoid N₁] [Module R N₁] :\n    (↑n : Module.End R N₁) = Module.toModuleEnd R N₁ n :=\n  rfl\n#align module.End.nat_cast_def Module.End.natCast_def\n\ntheorem End.intCast_def (z : ℤ) [AddCommGroup N₁] [Module R N₁] :\n    (z : Module.End R N₁) = Module.toModuleEnd R N₁ z :=\n  rfl\n#align module.End.int_cast_def Module.End.intCast_def\n\nend Module\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/Module/LinearMap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802471698041, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.4742488893416519}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.nat.multiplicity\nimport Mathlib.ring_theory.witt_vector.basic\nimport Mathlib.ring_theory.witt_vector.is_poly\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n## The Frobenius operator\n\nIf `R` has characteristic `p`, then there is a ring endomorphism `frobenius R p`\nthat raises `r : R` to the power `p`.\nBy applying `witt_vector.map` to `frobenius R p`, we obtain a ring endomorphism `𝕎 R →+* 𝕎 R`.\nIt turns out that this endomorphism can be described by polynomials over `ℤ`\nthat do not depend on `R` or the fact that it has characteristic `p`.\nIn this way, we obtain a Frobenius endomorphism `witt_vector.frobenius_fun : 𝕎 R → 𝕎 R`\nfor every commutative ring `R`.\n\nUnfortunately, the aforementioned polynomials can not be obtained using the machinery\nof `witt_structure_int` that was developed in `structure_polynomial.lean`.\nWe therefore have to define the polynomials by hand, and check that they have the required property.\n\nIn case `R` has characteristic `p`, we show in `frobenius_fun_eq_map_frobenius`\nthat `witt_vector.frobenius_fun` is equal to `witt_vector.map (frobenius R p)`.\n\n### Main definitions and results\n\n* `frobenius_poly`: the polynomials that describe the coefficients of `frobenius_fun`;\n* `frobenius_fun`: the Frobenius endomorphism on Witt vectors;\n* `frobenius_fun_is_poly`: the tautological assertion that Frobenius is a polynomial function;\n* `frobenius_fun_eq_map_frobenius`: the fact that in characteristic `p`, Frobenius is equal to\n  `witt_vector.map (frobenius R p)`.\n\nTODO: Show that `witt_vector.frobenius_fun` is a ring homomorphism,\nand bundle it into `witt_vector.frobenius`.\n\n-/\n\nnamespace witt_vector\n\n\n/-- The rational polynomials that give the coefficients of `frobenius x`,\nin terms of the coefficients of `x`.\nThese polynomials actually have integral coefficients,\nsee `frobenius_poly` and `map_frobenius_poly`. -/\ndef frobenius_poly_rat (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : mv_polynomial ℕ ℚ :=\n  coe_fn (mv_polynomial.bind₁ (witt_polynomial p ℚ ∘ fun (n : ℕ) => n + 1)) (X_in_terms_of_W p ℚ n)\n\ntheorem bind₁_frobenius_poly_rat_witt_polynomial (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : coe_fn (mv_polynomial.bind₁ (frobenius_poly_rat p)) (witt_polynomial p ℚ n) = witt_polynomial p ℚ (n + 1) := sorry\n\n/-- An auxilliary definition, to avoid an excessive amount of finiteness proofs\nfor `multiplicity p n`. -/\n/-- An auxilliary polynomial over the integers, that satisfies\n`(frobenius_poly_aux p n - X n ^ p) / p = frobenius_poly p n`.\nThis makes it easy to show that `frobenius_poly p n` is congruent to `X n ^ p`\nmodulo `p`. -/\ndef frobenius_poly_aux (p : ℕ) [hp : fact (nat.prime p)] : ℕ → mv_polynomial ℕ ℤ :=\n  sorry\n\ntheorem frobenius_poly_aux_eq (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : frobenius_poly_aux p n =\n  mv_polynomial.X (n + 1) -\n    finset.sum (finset.range n)\n      fun (i : ℕ) =>\n        finset.sum (finset.range (p ^ (n - i)))\n          fun (j : ℕ) =>\n            (mv_polynomial.X i ^ p) ^ (p ^ (n - i) - (j + 1)) * frobenius_poly_aux p i ^ (j + 1) *\n              coe_fn mv_polynomial.C\n                ↑(nat.choose (p ^ (n - i)) (j + 1) /\n                      p ^ (n - i - pnat_multiplicity p { val := j + 1, property := nat.succ_pos j }) *\n                    ↑p ^ (j - pnat_multiplicity p { val := j + 1, property := nat.succ_pos j })) := sorry\n\n/-- The polynomials that give the coefficients of `frobenius x`,\nin terms of the coefficients of `x`. -/\ndef frobenius_poly (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : mv_polynomial ℕ ℤ :=\n  mv_polynomial.X n ^ p + coe_fn mv_polynomial.C ↑p * frobenius_poly_aux p n\n\n/-\nOur next goal is to prove\n```\nlemma map_frobenius_poly (n : ℕ) :\n  mv_polynomial.map (int.cast_ring_hom ℚ) (frobenius_poly p n) = frobenius_poly_rat p n\n```\nThis lemma has a rather long proof, but it mostly boils down to applying induction,\nand then using the following two key facts at the right point.\n-/\n\n/-- A key divisibility fact for the proof of `witt_vector.map_frobenius_poly`. -/\ntheorem map_frobenius_poly.key₁ (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (j : ℕ) (hj : j < p ^ n) : p ^ (n - pnat_multiplicity p { val := j + 1, property := nat.succ_pos j }) ∣ nat.choose (p ^ n) (j + 1) := sorry\n\n/-- A key numerical identity needed for the proof of `witt_vector.map_frobenius_poly`. -/\ntheorem map_frobenius_poly.key₂ (p : ℕ) [hp : fact (nat.prime p)] {n : ℕ} {i : ℕ} {j : ℕ} (hi : i < n) (hj : j < p ^ (n - i)) : j - pnat_multiplicity p { val := j + 1, property := nat.succ_pos j } + n =\n  i + j + (n - i - pnat_multiplicity p { val := j + 1, property := nat.succ_pos j }) := sorry\n\ntheorem map_frobenius_poly (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) (frobenius_poly p n) = frobenius_poly_rat p n := sorry\n\ntheorem frobenius_poly_zmod (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : coe_fn (mv_polynomial.map (int.cast_ring_hom (zmod p))) (frobenius_poly p n) = mv_polynomial.X n ^ p := sorry\n\n@[simp] theorem bind₁_frobenius_poly_witt_polynomial (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : coe_fn (mv_polynomial.bind₁ (frobenius_poly p)) (witt_polynomial p ℤ n) = witt_polynomial p ℤ (n + 1) := sorry\n\n/-- `frobenius_fun` is the function underlying the ring endomorphism\n`frobenius : 𝕎 R →+* frobenius 𝕎 R`. -/\ndef frobenius_fun {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) : witt_vector p R :=\n  mk p fun (n : ℕ) => coe_fn (mv_polynomial.aeval (coeff x)) (frobenius_poly p n)\n\ntheorem coeff_frobenius_fun {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : ℕ) : coeff (frobenius_fun x) n = coe_fn (mv_polynomial.aeval (coeff x)) (frobenius_poly p n) := sorry\n\n/-- `frobenius_fun` is tautologically a polynomial function.\n\nSee also `frobenius_is_poly`. -/\ntheorem frobenius_fun_is_poly (p : ℕ) [hp : fact (nat.prime p)] : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => frobenius_fun :=\n  Exists.intro (frobenius_poly p)\n    fun (R : Type u_1) (_inst_4 : comm_ring R) (x : witt_vector p R) => funext fun (n : ℕ) => coeff_frobenius_fun x n\n\ntheorem ghost_component_frobenius_fun {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (n : ℕ) (x : witt_vector p R) : coe_fn (ghost_component n) (frobenius_fun x) = coe_fn (ghost_component (n + 1)) x := sorry\n\n/--\nIf `R` has characteristic `p`, then there is a ring endomorphism\nthat raises `r : R` to the power `p`.\nBy applying `witt_vector.map` to this endomorphism,\nwe obtain a ring endomorphism `frobenius R p : 𝕎 R →+* 𝕎 R`.\n\nThe underlying function of this morphism is `witt_vector.frobenius_fun`.\n-/\ndef frobenius {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] : witt_vector p R →+* witt_vector p R :=\n  ring_hom.mk frobenius_fun sorry sorry sorry sorry\n\ntheorem coeff_frobenius {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : ℕ) : coeff (coe_fn frobenius x) n = coe_fn (mv_polynomial.aeval (coeff x)) (frobenius_poly p n) :=\n  coeff_frobenius_fun x n\n\ntheorem ghost_component_frobenius {p : ℕ} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (n : ℕ) (x : witt_vector p R) : coe_fn (ghost_component n) (coe_fn frobenius x) = coe_fn (ghost_component (n + 1)) x :=\n  ghost_component_frobenius_fun n x\n\n/-- `frobenius` is tautologically a polynomial function. -/\ntheorem frobenius_is_poly (p : ℕ) [hp : fact (nat.prime p)] : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => ⇑frobenius :=\n  frobenius_fun_is_poly p\n\n@[simp] theorem coeff_frobenius_char_p (p : ℕ) {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] [char_p R p] (x : witt_vector p R) (n : ℕ) : coeff (coe_fn frobenius x) n = coeff x n ^ p := sorry\n\ntheorem frobenius_eq_map_frobenius (p : ℕ) {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] [char_p R p] : frobenius = map (frobenius R p) := sorry\n\n@[simp] theorem frobenius_zmodp (p : ℕ) [hp : fact (nat.prime p)] (x : witt_vector p (zmod p)) : coe_fn frobenius x = x := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/frobenius.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.4742488852290101}}
{"text": "import tactic\nimport tactic.induction\nimport data.int.basic\nimport data.set.basic\nimport logic.function.iterate\nimport data.list\n\nimport .base .point .dist .board .state .player\n\nnoncomputable theory\nopen_locale classical\n\ndef Game.set_A {pw pw₁ : ℕ} (g : Game pw) (a₁ : A pw₁) : Game pw₁ :=\n{g with a := a₁}\n\ndef Game.set_D {pw : ℕ} (g : Game pw) (d₁ : D) : Game pw :=\n{g with d := d₁}\n\ndef Game.set_players {pw pw₁ : ℕ} (g : Game pw)\n  (a₁ : A pw₁) (d₁ : D) : Game pw₁ :=\n(g.set_A a₁).set_D d₁\n\ndef Game.set_prev_moves {pw : ℕ} (g : Game pw)\n  (fa : A_prev_moves pw g.s)\n  (fd : D_prev_moves g.s) : Game pw :=\ng.set_players (g.a.set_prev_moves g.s fa) (g.d.set_prev_moves g.s fd)\n\ndef Game.D_wins {pw : ℕ} (g : Game pw) :=\n∃ (n : ℕ), ¬(g.play n).act\n\ndef D_hws_at (pw : ℕ) (s : State) :=\n∃ (d : D), ∀ (a : A pw), (init_game a d s).D_wins\n\ndef D_hws (pw : ℕ) := D_hws_at pw state₀\n\n-----\n\ndef simulate {pw : ℕ} (a : A pw) (d : D) (n : ℕ) : Game pw :=\n(init_game a d state₀).play n\n\ndef all_s {pw : ℕ} (a : A pw) (d : D) (P : State → Prop) :=\n∀ (n : ℕ), P (simulate a d n).s\n\ndef all_b {pw : ℕ} (a : A pw) (d : D) (P : Board → Prop) :=\nall_s a d (λ s, P s.board)\n\ndef any_s {pw : ℕ} (a : A pw) (d : D) (P : State → Prop) :=\n¬all_s a d (λ s, ¬P s)\n\ndef any_b {pw : ℕ} (a : A pw) (d : D) (P : Board → Prop) :=\nany_s a d (λ s, P s.board)\n\ndef D_wins_in {pw : ℕ} (a : A pw) (d : D) (n : ℕ) :=\n∀ (k : ℕ), n ≤ k → ¬(simulate a d k).act\n\ndef valid_A_state (pw : ℕ) (s : State) :=\n∃ (a : A pw) (d : D) (n : ℕ) hs, (play_D_move_at (simulate a d n) hs).s = s\n\ndef valid_D_state (pw : ℕ) (s : State) :=\n∃ (a : A pw) (d : D) (n : ℕ), (simulate a d n).s = s\n\ndef valid_state (pw : ℕ) (s : State) :=\nvalid_D_state pw s\n\n-----\n\nlemma not_A_wins_at {pw : ℕ} {g : Game pw} :\n  ¬g.A_wins ↔ g.D_wins :=\nby simp [Game.A_wins, Game.D_wins]\n\nlemma not_D_wins_at {pw : ℕ} {g : Game pw} :\n  ¬g.D_wins ↔ g.A_wins :=\nby simp [Game.A_wins, Game.D_wins]\n\nlemma play_at_succ {pw n : ℕ} {g : Game pw} :\n  g.play n.succ = g.play_move.play n :=\nfunction.iterate_succ_apply _ _ _\n\nlemma play_at_succ' {pw n : ℕ} {g : Game pw} :\n  g.play n.succ = (g.play n).play_move :=\nfunction.iterate_succ_apply' _ _ _\n\n-----\n\nlemma A_wins_at_play_of {pw : ℕ} {g : Game pw}\n  (h : g.A_wins) {n : ℕ} : (g.play n).A_wins :=\nbegin\n  intro k, specialize h (k + n),\n  rw [Game.play, function.iterate_add] at h, exact h,\nend\n\nlemma A_wins_at_play_move_of {pw : ℕ} {g : Game pw}\n  (h : g.A_wins) : g.play_move.A_wins :=\n@A_wins_at_play_of _ _ h 1\n\nlemma play_A_move_at_players_eq {pw : ℕ} {g : Game pw} :\n  (play_A_move_at g).a = g.a ∧ (play_A_move_at g).d = g.d :=\nby { rw [play_A_move_at], split_ifs; exact ⟨rfl, rfl⟩ }\n\nlemma play_D_move_at_players_eq {pw : ℕ} {g : Game pw} {hs} :\n  (play_D_move_at g hs).a = g.a ∧ (play_D_move_at g hs).d = g.d :=\nby { rw [play_D_move_at], exact ⟨rfl, rfl⟩ }\n\nlemma play_move_at_players_eq {pw : ℕ} {g : Game pw} :\n  g.play_move.a = g.a ∧ g.play_move.d = g.d :=\nbegin\n  rw [Game.play_move], split_ifs, swap, exact ⟨rfl, rfl⟩,\n  rw [play_A_move_at_players_eq.1, play_A_move_at_players_eq.2],\n  rw [play_D_move_at_players_eq.1, play_D_move_at_players_eq.2],\n  exact ⟨rfl, rfl⟩,\nend\n\nlemma play_move_at_players_eq' {pw : ℕ} {g : Game pw} {hs} :\n  (play_A_move_at (play_D_move_at g hs)).a = g.a ∧\n  (play_A_move_at (play_D_move_at g hs)).d = g.d :=\nby { rw play_A_move_at, split_ifs; exact ⟨rfl, rfl⟩ }\n\nlemma play_at_players_eq {pw n : ℕ} {g : Game pw} :\n  (g.play n).a = g.a ∧ (g.play n).d = g.d :=\nbegin\n  induction n with n ih,\n  { exact ⟨rfl, rfl⟩ },\n  { simp_rw play_at_succ',\n    rwa [play_move_at_players_eq.1, play_move_at_players_eq.2] },\nend\n\nlemma play_move_at_act {pw : ℕ} {g : Game pw}\n  (h : g.act) :\n  g.play_move = play_A_move_at (play_D_move_at g h) :=\ndif_pos h\n\nlemma play_move_at_not_act {pw : ℕ} {g : Game pw}\n  (h : ¬g.act) :\n  g.play_move = g :=\ndif_neg h\n\nlemma play_A_move_hvm {pw : ℕ} {g : Game pw} (hs)\n  (h : A_has_valid_move pw g.s.board) :\n  ∃ h, play_A_move_at g = play_A_move_at' g.a g hs h :=\nby exact ⟨_, dif_pos ⟨hs, h⟩⟩\n\nlemma play_A_move_at_set_D {pw : ℕ}\n  {g : Game pw} {d₁ : D} :\n  play_A_move_at (g.set_D d₁) = (play_A_move_at g).set_D d₁ :=\nby { simp_rw play_A_move_at, split_ifs; refl }\n\nlemma play_D_move_at_set_A {pw pw₁ : ℕ}\n  {g : Game pw} {a₁ : A pw₁} {hs} :\n  play_D_move_at (g.set_A a₁) hs =\n  (play_D_move_at g hs).set_A a₁ :=\nrfl\n\nlemma A_has_valid_move_at_play_D_move {pw : ℕ} {g : Game pw} {hs}\n  (h : g.A_wins) :\n  A_has_valid_move pw (play_D_move_at g hs).s.board :=\nbegin\n  specialize h 1, change g.play_move.act at h,\n  rw play_move_at_act hs at h, rw play_A_move_at at h,\n  split_ifs at h with h₁,\n  { exact h₁.2 },\n  { cases h },\nend\n\n-----\n\nlemma act_of_act_play_move {pw : ℕ} {g : Game pw}\n  (h : g.play_move.act) : g.act :=\nby { rw Game.play_move at h, split_ifs at h with h₁; assumption }\n\nlemma act_play_of_act_play_succ {pw n : ℕ} {g : Game pw}\n  (h : (g.play n.succ).act) : (g.play n).act :=\nby { rw play_at_succ' at h, exact act_of_act_play_move h }\n\nlemma act_play_le {pw n m : ℕ} {g : Game pw}\n  (h₁ : n ≤ m) (h₂ : (g.play m).act) : (g.play n).act :=\nbegin\n  induction' h₁,\n  { exact h₂ },\n  { rw play_at_succ' at h₂, exact ih (act_of_act_play_move h₂) },\nend\n\nlemma hist_len_play_A_move_at' {pw pw₁ : ℕ} {g : Game pw}\n  {a₁ : A pw₁} {h₁ h₂} :\n  (play_A_move_at' a₁ g h₁ h₂).s.len = g.s.len.succ :=\nhist_len_apply_A_move\n\nlemma hist_len_play_D_move_at {pw : ℕ} {g : Game pw} {hs} :\n  (play_D_move_at g hs).s.len = g.s.len.succ :=\nhist_len_apply_D_move\n\nlemma play_A_move_at_hist_len_ge {pw : ℕ} {g : Game pw} :\n  g.s.len ≤ (play_A_move_at g).s.len :=\nbegin\n  rw play_A_move_at, split_ifs, swap, { refl },\n  rw hist_len_play_A_move_at',\n  exact nat.le_of_lt (nat.lt_succ_self _),\nend\n\nlemma play_D_move_at_hist_len_ge {pw : ℕ} {g : Game pw} {hs} :\n  g.s.len ≤ (play_D_move_at g hs).s.len :=\nby { rw hist_len_play_D_move_at, exact nat.le_of_lt (nat.lt_succ_self _) }\n\nlemma play_D_move_at_hist_len_eq {pw : ℕ} {g : Game pw} {hs} :\n  (play_D_move_at g hs).s.len = g.s.len.succ :=\nby rw hist_len_play_D_move_at\n\nlemma play_move_at_hist_len_ge {pw : ℕ} {g : Game pw} :\n  g.s.len ≤ g.play_move.s.len :=\nbegin\n  rw Game.play_move, split_ifs with hs, swap, { refl },\n  rw play_A_move_at, split_ifs with h₁,\n  { change (play_D_move_at g hs).a with g.a,\n    transitivity (play_D_move_at g hs).s.len,\n    { exact play_D_move_at_hist_len_ge },\n    { rw hist_len_play_A_move_at',\n      exact nat.le_of_lt (nat.lt_succ_self _) }},\n  { change _ ≤ (play_D_move_at g hs).s.len,\n    rw hist_len_play_D_move_at,\n    exact nat.le_of_lt (nat.lt_succ_self _) },\nend\n\nlemma play_at_hist_len_ge {pw n : ℕ} {g : Game pw} :\n  g.s.len ≤ (g.play n).s.len :=\nbegin\n  induction n with n ih,\n  { refl },\n  { apply le_trans ih, clear ih, rw play_at_succ',\n    exact play_move_at_hist_len_ge },\nend\n\nlemma set_players_flip {pw pw₁ : ℕ} {g : Game pw}\n  {a₁ : A pw₁} {d₁ : D} :\n  (g.set_A a₁).set_D d₁ = (g.set_D d₁).set_A a₁ :=\nrfl\n\nlemma play_move_eq_set_state_of_act_next {pw : ℕ} {g : Game pw}\n  (h : g.play_move.act) :\n  g.play_move = g.set_state g.play_move.s :=\nbegin\n  ext,\n  { exact play_move_at_players_eq.1 },\n  { exact play_move_at_players_eq.2 },\n  { refl },\nend\n\nlemma play_D_move_eq {pw : ℕ} {g : Game pw} {hs} :\n  play_D_move_at g hs =\n  g.set_state (apply_D_move g.s (g.d.f g.s hs).m) :=\nrfl\n\n-----\n\nlemma set_prev_moves_A_wins_iff {pw : ℕ} {g : Game pw}\n  {fa : A_prev_moves pw g.s}\n  {fd : D_prev_moves g.s} :\n  (g.set_prev_moves fa fd).A_wins ↔ g.A_wins :=\nbegin\n  let a := g.a, let d := g.d,\n  let a' := a.set_prev_moves g.s fa,\n  let d' := d.set_prev_moves g.s fd,\n  let g' : Game pw := _,\n  change (∀ n, (g'.play n).act) ↔ (∀ n, ((g.play n).set_players a' d').act),\n  suffices h : ∀ {n}, g'.play n = (g.play n).set_players a' d', simp_rw h,\n  intro n, induction n with n ih, { refl },\n  let g₁ := g.play n,\n  let g₁' := g₁.set_players a' d',\n  simp_rw play_at_succ', rw ih, clear ih,\n  change (g₁.set_players a' d').play_move = g₁.play_move.set_players a' d',\n  simp_rw Game.play_move,\n  split_ifs, swap, { refl },\n  have h₁ : play_D_move_at (g₁.set_players a' d') h =\n    (play_D_move_at g₁ h).set_players a' d',\n  { simp_rw [Game.set_players, set_players_flip, play_D_move_at_set_A],\n    congr, simp_rw play_D_move_at,\n    change (g₁.set_D d').d with d',\n    ext; try { refl }, change _ = apply_D_move _ _,\n    simp [apply_D_move, apply_move], simp_rw Game.set_state,\n    refine ⟨_, snoc_eq_snoc_iff.mpr ⟨rfl, rfl⟩, rfl⟩,\n    change (g₁.set_D d').s with g₁.s,\n    congr' 1, generalize_proofs, change d'.f g₁.s h with dite _ _ _,\n    split_ifs with h₂,\n    { exfalso, contrapose! h₂, clear h₂,\n      transitivity (g.play n).s.len,\n      { exact play_at_hist_len_ge },\n      { refl }},\n    { congr, exact play_at_players_eq.2.symm }},\n  rw h₁, clear h₁,\n  let g₂ : Game pw := _, change (play_D_move_at g₁ h) with g₂,\n  have h₁ : play_A_move_at (g₂.set_A a') =\n    (play_A_move_at g₂).set_A a',\n  { simp_rw play_A_move_at,\n    change dite (g₂.act ∧ A_has_valid_move pw g₂.s.board) _ _ = _,\n    split_ifs with hx, swap, { refl },\n    change (g₂.set_A a').a with a',\n    simp_rw play_A_move_at', ext; try {refl},\n    simp_rw Game.set_state,\n    change (g₂.set_A a').s with g₂.s at hx ⊢,\n    change _ = apply_A_move _ _,\n    simp [apply_A_move, apply_move],\n    generalize_proofs hy hz,\n    change a'.f g₂.s h hy with dite _ _ _,\n    split_ifs with h₂,\n    { exfalso, contrapose! h₂, clear h₂,\n      transitivity (g.play n).s.len,\n      { exact play_at_hist_len_ge },\n      { exact play_D_move_at_hist_len_ge }},\n    { congr, exact play_at_players_eq.1.symm }},\n  simp_rw [Game.set_players, play_A_move_at_set_D, h₁],\nend\n\nlemma A_set_move_A_wins_iff {pw : ℕ} {g : Game pw}\n  {s : State} {m : Valid_A_move pw s.board}\n  (h : s.len < g.s.len) :\n  (g.set_A (g.a.set_move s m)).A_wins ↔ g.A_wins :=\nbegin\n  convert set_prev_moves_A_wins_iff, ext,\n  { change _ = g.a.prev_moves_set g.s s m h, rw A_prev_moves_set_eq, refl },\n  repeat { refl }, change _ = g.d.prev_moves_id g.s,\n  rw D_prev_moves_id_eq, refl,\nend\n\nlemma D_set_move_A_wins_iff {pw : ℕ} {g : Game pw}\n  {s : State} {m : Valid_D_move s.board}\n  (h : s.len < g.s.len) :\n  (g.set_D (g.d.set_move s m)).A_wins ↔ g.A_wins :=\nbegin\n  convert set_prev_moves_A_wins_iff, ext,\n  { change _ = g.a.prev_moves_id g.s, rw A_prev_moves_id_eq, },\n  repeat { refl }, change _ = g.d.prev_moves_set g.s s m h,\n  rw D_prev_moves_set_eq,\nend\n\nlemma play_1 {pw : ℕ} {g : Game pw} : g.play 1 = g.play_move := rfl\n\n-----\n\n@[simp]\nlemma init_game_act {pw : ℕ}\n  {a : A pw} {d : D} {s : State} :\n  (init_game a d s).act ↔ s.act := by refl\n\nlemma init_game_play_move {pw : ℕ}\n  {a : A pw} {d : D} {s : State} (hs) :\n  (init_game a d s).play_move =\n  play_A_move_at (play_D_move_at (init_game a d s) hs) :=\ndif_pos (init_game_act.mp hs)\n\nlemma hist_len_game_finish {pw : ℕ} {g : Game pw} :\n  g.finish.s.len = g.s.len := rfl\n\nlemma hist_len_le_play_move {pw : ℕ} {g : Game pw} :\n  g.s.len ≤ g.play_move.s.len :=\nbegin\n  rw Game.play_move, split_ifs with hs, swap, { refl },\n  rw play_A_move_at, split_ifs with h,\n  { rw [hist_len_play_A_move_at', hist_len_play_D_move_at],\n    apply nat.le_succ_of_le (nat.le_succ _) },\n  { rw [hist_len_game_finish, hist_len_play_D_move_at],\n    apply nat.le_succ },\nend\n\nlemma hist_len_le_play {pw n : ℕ} {g : Game pw} :\n  g.s.len ≤ (g.play n).s.len :=\nbegin\n  induction n with n ih, { refl }, rw play_at_succ',\n  exact ih.trans hist_len_le_play_move,\nend\n\nlemma play_add {pw n k} {g : Game pw} :\n  g.play (n + k) = (g.play n).play k :=\nby { rw add_comm, apply function.iterate_add_apply }\n\nlemma play_add' {pw n k} {g : Game pw} :\n  g.play (n + k) = (g.play k).play n :=\nby { apply function.iterate_add_apply }\n\n@[simp]\nlemma init_game_s {pw : ℕ} {a : A pw} {d : D} {s : State} :\n  (init_game a d s).s = s := rfl\n\nlemma play_move_state_eq_of_act_play_move {pw : ℕ} {g : Game pw}\n  (h : g.play_move.act) :\n  ∃ s' hs hs' hvm, s' = apply_D_move g.s (g.d.f g.s hs).m ∧\n  g.play_move.s = apply_A_move s' (g.a.f s' hs' hvm).m :=\nbegin\n  have hs := act_of_act_play_move h,\n  let s' := apply_D_move g.s (g.d.f g.s hs).m,\n  have hvm : A_has_valid_move pw s'.board,\n  { rw [play_move_at_act hs, play_A_move_at] at h,\n    split_ifs at h with h₁,\n    { exact h₁.2 },\n    { cases h }},\n  use [s', hs, hs, hvm, rfl],\n  rw [play_move_at_act hs, play_A_move_at, dif_pos],\n  swap, { exact ⟨hs, hvm⟩ }, refl,\nend\n\nlemma act_play_move_of_A_hvm {pw : ℕ} {g : Game pw} {hs}\n  (h : A_has_valid_move pw (apply_D_move g.s (g.d.f g.s hs).m).board) :\n  g.play_move.act :=\nby { rw [play_move_at_act hs, play_A_move_at], split_ifs with h₁; tauto }\n\n@[simp] lemma init_game_a_eq {pw : ℕ} {a : A pw} {d : D} {s : State} :\n  (init_game a d s).a = a := rfl\n\n@[simp] lemma init_game_d_eq {pw : ℕ} {a : A pw} {d : D} {s : State} :\n  (init_game a d s).d = d := rfl\n\n@[simp] lemma init_game_s_eq {pw : ℕ} {a : A pw} {d : D} {s : State} :\n  (init_game a d s).s = s := rfl\n\n@[simp] lemma set_state_s {pw : ℕ} {g : Game pw} {s : State} :\n  (g.set_state s).s = s := rfl\n\n-----\n\nlemma valid_state₀ {pw : ℕ} : valid_state pw state₀ :=\n⟨default, default, 0, rfl⟩\n\nlemma valid_A_state_play_D_move {pw : ℕ} {g : Game pw} {hs}\n  (h : valid_state pw g.s) :\n  valid_A_state pw (play_D_move_at g hs).s :=\nbegin\n  rcases h with ⟨a, d, n, h⟩,\n  let d₁ := d.set_move g.s (g.d.f g.s hs),\n  refine ⟨a, d₁, n, _⟩,\n  have h₂ : (simulate a d₁ n).s = g.s,\n  {\n    revert hs,\n    rw ←h, clear h,\n    let s : State := _,\n    change (simulate a d n).s with s,\n    rintro hs d₁,\n    change s with (simulate a d n).s,\n    sorry\n  },\n  sorry {\n    simp [h, h₂],\n    use hs,\n    generalize_proofs h₃,\n    simp_rw [play_D_move_eq, set_state_s],\n    rw (_ : (simulate a d₁ n).d = d₁),\n    swap,\n    {\n      exact play_at_players_eq.2,\n    },\n    congr' 2,\n    {\n      rw h₂,\n    },\n    {\n      revert h₃,\n      rw h₂,\n      exact λ _, heq_of_eq D_set_move_eq,\n    },\n  },\nend\n\nlemma valid_state_play_A_move {pw : ℕ} {g : Game pw}\n  (h : valid_A_state pw g.s) :\n  valid_state pw (play_A_move_at g).s :=\nbegin\n  sorry\nend\n\n-- #exit\n\nlemma valid_state_play_move {pw : ℕ} {g : Game pw}\n  (h : valid_state pw g.s) :\n  valid_state pw g.play_move.s :=\nbegin\n  rw Game.play_move, split_ifs with h₁,\n  { exact valid_state_play_A_move (valid_A_state_play_D_move h) },\n  { exact h },\nend\n\n@[simp]\nlemma play_D_move_act {pw : ℕ} {g : Game pw} {hs} :\n  (play_D_move_at g hs).act ↔ g.act := by refl\n\n@[simp]\nlemma play_D_move_s {pw : ℕ} {g : Game pw} {hs} :\n  (play_D_move_at g hs).s = apply_D_move g.s (g.d.f g.s hs).m := rfl", "meta": {"author": "user7230724", "repo": "lean-projects", "sha": "ab9a83874775efd18f8c5b867e480bae4d596b31", "save_path": "github-repos/lean/user7230724-lean-projects", "path": "github-repos/lean/user7230724-lean-projects/lean-projects-ab9a83874775efd18f8c5b867e480bae4d596b31/src/ap/game.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4741822453123168}}
{"text": "import algebra.homology.homotopy\nimport category_theory.abelian.basic\nimport for_mathlib.short_complex_functor_category\nimport for_mathlib.short_complex_homological_complex\n\nuniverses v u\n\nnoncomputable theory\n\nopen category_theory category_theory.limits\n\nvariables {ι ι' ι₁ ι₂ : Type*}\n\nnamespace complex_shape\n\n/-- An embedding `embedding c₁ c₂` between two complex shapes `ι₁` and `ι₂` is\nan injection `ι₁ → ι₂` sending related vertices to related vertices. Recall that two\nvertices are related in a complex shape iff the differential between them is allowed to\nbe nonzero. -/\n@[nolint has_inhabited_instance]\nstructure embedding (c₁ : complex_shape ι₁) (c₂ : complex_shape ι₂) :=\n(f : ι₁ → ι₂)\n(r : ι₂ → option ι₁)\n(eq_some : ∀ i₂ i₁, r i₂ = some i₁ ↔ f i₁ = i₂)\n(c : ∀ ⦃i j⦄, c₁.rel i j → c₂.rel (f i) (f j))\n\nnamespace embedding\n\n/-- extra condition which shall be useful to compare homology -/\ndef c_iff {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) : Prop :=\n∀ (i j), c₁.rel i j ↔ c₂.rel (e.f i) (e.f j)\n\nlemma r_f {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (i : ι₁) :\n  e.r (e.f i) = some i := by rw e.eq_some\n\nlemma r_none {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (i : ι₂)\n  (hi: ¬∃ (i₁ : ι₁), i = e.f i₁) : e.r i = none :=\nbegin\n  classical,\n  by_contra hi2,\n  apply hi,\n  obtain ⟨j, hj⟩ := option.ne_none_iff_exists'.1 hi2,\n  use j,\n  rw e.eq_some at hj,\n  rw hj,\nend\n\n/-- The map from `ℤ` to `option ℕ` which is `some n` on `n : ℕ : ℤ` and `none otherwise. -/\ndef pos_int_to_onat : ℤ → option ℕ\n| (n:ℕ)  := n\n| -[1+n] := none\n\n/-- The map from `ℤ` to `option ℕ` which is `some n` on `-(n : ℕ : ℤ)` and `none otherwise. -/\ndef neg_int_to_onat : ℤ → option ℕ\n| 0       := (0:ℕ)\n| (n+1:ℕ) := none\n| -[1+n]  := (n+1:ℕ)\n\n/-- The obvious embedding from the ℕ-indexed \"cohomological\" complex `* → * → * → ...`\n  to the corresponding ℤ-indexed complex. -/\ndef nat_up_int_up : embedding (complex_shape.up ℕ) (complex_shape.up ℤ) :=\n{ f := coe,\n  r := pos_int_to_onat,\n  eq_some := begin\n    rintro (i|i) i',\n    { split; { rintro ⟨rfl⟩, refl }, },\n    { split; { rintro ⟨⟩, } }\n  end,\n  c := by { rintro i j (rfl : _ = _), dsimp, refl } }\n\n/-- The obvious embedding from the ℕ-indexed \"homological\" complex `* ← * ← * ← ...`\n  to the corresponding ℤ-indexed homological complex. -/\ndef nat_down_int_down : embedding (complex_shape.down ℕ) (complex_shape.down ℤ) :=\n{ f := coe,\n  r := pos_int_to_onat,\n  eq_some := begin\n    rintro (i|i) i',\n    { split; { rintro ⟨rfl⟩, refl }, },\n    { split; { rintro ⟨⟩, } }\n  end,\n  c := by { rintro i j (rfl : _ = _), dsimp, refl } }\n\n/-- Obvious embedding from the `ℕ`-indexed homological complex `* ← * ← * ...`\n  to `ℤ`-indexed cohomological complex ` ... → * → * → ...` sending $n$ to $-n$\n  on the corresponding map `ℕ → ℤ`. -/\ndef nat_down_int_up : embedding (complex_shape.down ℕ) (complex_shape.up ℤ) :=\n{ f := -coe,\n  r := neg_int_to_onat,\n  eq_some := begin\n    rintro ((_|i)|i) (_|i'),\n    any_goals { split; { rintro ⟨⟩, } },\n    any_goals { split; { rintro ⟨rfl⟩, refl }, },\n  end,\n  c := by { rintro i j (rfl : _ = _),\n    simp only [pi.neg_apply, int.coe_nat_succ, neg_add_rev, up_rel, neg_add_cancel_comm], } }\n\nlemma nat_down_int_up_c_iff : nat_down_int_up.c_iff :=\nbegin\n  intros i j,\n  split,\n  { apply nat_down_int_up.c, },\n  { intro hij,\n    change j+1 = i,\n    dsimp [nat_down_int_up] at hij,\n    rw ← int.coe_nat_eq_coe_nat_iff,\n    simp only [int.coe_nat_succ],\n    linarith, },\nend\n\n/-- Obvious embedding from the `ℕ`-indexed cohomological complex `* → * → * ...`\n  to `ℤ`-indexed homological complex ` ... ← * ← * ← ...` sending $n$ to $-n$\n  on the corresponding map `ℕ → ℤ`. -/\ndef nat_up_int_down : embedding (complex_shape.up ℕ) (complex_shape.down ℤ) :=\n{ f := -coe,\n  r := neg_int_to_onat,\n  eq_some := begin\n    rintro ((_|i)|i) (_|i'),\n    any_goals { split; { rintro ⟨⟩, } },\n    any_goals { split; { rintro ⟨rfl⟩, refl }, },\n  end,\n  c := by { rintro i j (rfl : _ = _),\n    simp only [pi.neg_apply, int.coe_nat_succ, neg_add_rev, down_rel, neg_add_cancel_comm] } }\n\nend embedding\n\nend complex_shape\n\nvariables {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂}\nvariables {cι : complex_shape ι} {cι' : complex_shape ι'}\n\nvariables {𝒞 : Type*} [category 𝒞] [preadditive 𝒞] [has_zero_object 𝒞] -- reclaim category notation!\n\nnamespace homological_complex\n\nopen_locale zero_object\n\nsection embed_X_and_d_basics\n\n/-\n\n`embed`, not to be confused with `embedding` later on, is simply\nthe extension of constructions involving the index type `ι` of our complex,\nto the larger type `option ι`, with `none` being sent to `zero`.\n\n-/\nvariable (X : homological_complex 𝒞 cι)\n\n\n/-- If `𝒞` is an abelian category,  and `(Xᵢ)ᵢ` is a `𝒞`-valued homological\ncomplex on a complex-shape with index `ι`, then `embed.X X oi` for `oi : option ι`\nis the value `Xᵢ` of `h` at `some i` (an object of `𝒞`), or `0` for `none`. -/\ndef embed.X : option ι → 𝒞\n| (some i) := X.X i\n| none     := 0\n\ndef embed.X_iso_of_none {e : option ι} (he : e = none) :\n  embed.X X e ≅ 0 :=\nby { rw he, refl }\n\ndef embed.X_is_zero_of_none {e : option ι} (he : e = none) :\n  is_zero (embed.X X e) :=\nis_zero.of_iso (category_theory.limits.is_zero_zero 𝒞) (embed.X_iso_of_none X he)\n\ndef embed.X_iso_of_some {e : option ι} {i} (he : e = some i) :\n  embed.X X e ≅ X.X i :=\nby { rw he, refl }\n\n@[simp] lemma embed.X_none : embed.X X none = 0 := rfl\n@[simp] lemma embed.X_some (i : ι) : embed.X X (some i) = X.X i := rfl\n\n/-- The morphism `Xᵢ → Xⱼ` with `i j : option ι` coming from the complex `X`.\nEqual to zero if either `i` or `j` is `none`.  -/\ndef embed.d : Π i j, embed.X X i ⟶ embed.X X j\n| (some i) (some j) := X.d i j\n| (some i) none     := 0\n| none     j        := 0\n\ndef embed.d_of_none_src {e₁ e₂ : option ι} (he : e₁ = none) :\n  embed.d X e₁ e₂ = 0 :=\nby { rw he, refl }\n\ndef embed.d_of_none_tgt {e₁ e₂ : option ι} (he : e₂ = none) :\n  embed.d X e₁ e₂ = 0 :=\nby { rw he, cases e₁; refl }\n\ndef embed.d_of_some_of_some {e₁ e₂ : option ι} {i j}\n  (h₁ : e₁ = some i) (h₂ : e₂ = some j) :\n  embed.d X e₁ e₂ = (embed.X_iso_of_some X h₁).hom ≫ X.d i j ≫\n    (embed.X_iso_of_some X h₂).inv :=\nby { subst h₁, subst h₂, change _ = 𝟙 _ ≫ _ ≫ 𝟙 _, simpa }\n\n@[simp] lemma embed.d_some_some (i j : ι) : embed.d X (some i) (some j) = X.d i j :=\nrfl\n\nlemma embed.d_ne_zero (e₁ e₂ : option ι) (h : embed.d X e₁ e₂ ≠ 0) :\n  ∃ (i j : ι) (h₁ : e₁ = some i) (h₂ : e₂ = some j), X.d i j ≠ 0 :=\nbegin\n  rcases h₁ : e₁ with _ | ⟨i⟩,\n  { exfalso,\n    apply h,\n    exact embed.d_of_none_src X h₁, },\n  { rcases h₂ : e₂ with _ | ⟨j⟩,\n    { exfalso,\n      apply h,\n      exact embed.d_of_none_tgt X h₂, },\n    { substs h₁ h₂,\n      refine ⟨i, j, rfl, rfl, h⟩, }, },\nend\n\n/-- Prop-valued so probably won't break anything. To deal with zerology. -/\ninstance homological_complex.embed.subsingleton_to_none (c : _) : subsingleton (c ⟶ embed.X X none) :=\n@unique.subsingleton _ (has_zero_object.unique_from c)\n\ninstance homological_complex.embed.subsingleton_of_none (c) : subsingleton (embed.X X none ⟶ c) :=\n@unique.subsingleton _ (has_zero_object.unique_to c)\n\n@[simp] lemma embed.d_to_none (i : option ι) : embed.d X i none = 0 :=\nby cases i; refl\n\n@[simp] lemma embed.d_of_none (i : option ι) : embed.d X none i = 0 :=\nrfl\n\nlemma embed.shape : ∀ (i j : option ι)\n  (h : ∀ (i' j' : ι), i = some i' → j = some j' → ¬ cι.rel i' j'),\n  embed.d X i j = 0\n| (some i) (some j) h := X.shape _ _ $ h i j rfl rfl\n| (some i) none     h := rfl\n| none     j        h := rfl\n\nlemma embed.d_comp_d : ∀ i j k, embed.d X i j ≫ embed.d X j k = 0\n| (some i) (some j) (some k) := X.d_comp_d _ _ _\n| (some i) (some j) none     := comp_zero\n| (some i) none     k        := comp_zero\n| none     j        k        := zero_comp\n\nend embed_X_and_d_basics\n\nsection embedding_change_of_complex\n\nvariable (e : cι.embedding cι')\n\n/-- Object-valued pushforward of `𝒞`-valued homological complexes along an embedding\n  `ι₁ ↪ ι₂` of complex-shapes (with all indexes not in the image going to `0`). -/\ndef embed.obj (X : homological_complex 𝒞 cι) : homological_complex 𝒞 cι' :=\n{ X := λ i, embed.X X (e.r i),\n  d := λ i j, embed.d X (e.r i) (e.r j),\n  shape' := λ i j hij, embed.shape X _ _ begin\n    simp only [e.eq_some],\n    rintro i' j' rfl rfl h',\n    exact hij (e.c h')\n  end,\n  d_comp_d' := λ i j k hij hjk, embed.d_comp_d X _ _ _ }\n\nvariables {X Y Z : homological_complex 𝒞 cι} (f : X ⟶ Y) (g : Y ⟶ Z)\n\n/-- Morphism-valued pushforward of `𝒞`-valued homological complexes along an embedding of complex-shapes\n( with all morphisms not in the image being defined to be 0) -/\ndef embed.f : Π i, embed.X X i ⟶ embed.X Y i\n| (some i) := f.f i\n| none     := 0\n\n@[simp] lemma embed.f_none : embed.f f none = 0 := rfl\n@[simp] lemma embed.f_some (i : ι) : embed.f f (some i) = f.f i := rfl\n\nlemma embed.f_add {f g : X ⟶ Y} : ∀ i, embed.f (f + g) i = embed.f f i + embed.f g i\n| (some i) := by simp\n| none     := by simp\n\nlemma embed.comm :  ∀ i j, embed.f f i ≫ embed.d Y i j = embed.d X i j ≫ embed.f f j\n| (some i) (some j) := f.comm _ _\n| (some i) none     := show _ ≫ 0 = 0 ≫ 0, by simp only [comp_zero]\n| none     j        := show 0 ≫ 0 = 0 ≫ _, by simp only [zero_comp]\n\n/-- Pushforward of a morphism `(Xᵢ)ᵢ ⟶ (Yᵢ)ᵢ` of homological complexes with\n  the same complex-shape `ι`, along an embedding of complex shapes c.embedding `ι → ι'` -/\ndef embed.map : embed.obj e X ⟶ embed.obj e Y :=\n{ f := λ i, embed.f f _,\n  comm' := λ i j hij, embed.comm f _ _ }\n\nlemma embed.f_id : ∀ i, embed.f (𝟙 X) i = 𝟙 (embed.X X i)\n| (some i) := rfl\n| none     := has_zero_object.from_zero_ext _ _\n\nlemma embed.f_comp : ∀ i, embed.f (f ≫ g) i = embed.f f i ≫ embed.f g i\n| (some i) := rfl\n| none     := has_zero_object.from_zero_ext _ _\n\nlemma embed.f_of_some {e : option ι} {i} (he : e = some i) :\n  embed.f f e =\n    (embed.X_iso_of_some _ he).hom ≫\n    f.f i ≫\n    (embed.X_iso_of_some _ he).inv :=\nby { subst he, change _ = 𝟙 _ ≫ _ ≫ 𝟙 _, simp, }\n\n/-- Functor pushing forward, for a fixed abelian category `𝒞`, the category\nof `𝒞`-valued homological complexes of shape `ι₁` along an embedding `ι₁ ↪ ι₂`\n(not Lean notation -- fix somehow?) of complexes. -/\ndef embed : homological_complex 𝒞 cι ⥤ homological_complex 𝒞 cι' :=\n{ obj := embed.obj e,\n  map := λ X Y f, embed.map e f,\n  map_id' := λ X, by { ext i, exact embed.f_id _ },\n  map_comp' := by { intros, ext i, exact embed.f_comp f g _ } }\n.\n\ninstance embed_additive :\n  (embed e : homological_complex 𝒞 cι ⥤ homological_complex 𝒞 cι').additive :=\n { map_add' := λ X Y f g, by { ext, exact embed.f_add _, }, }\n\ndef embed_iso (i : ι) : ((embed e).obj X).X (e.f i) ≅ X.X i :=\neq_to_iso\nbegin\n  delta embed embed.obj,\n  dsimp,\n  rw e.r_f,\n  refl,\nend\n\nlemma embed_eval_is_zero_of_none (i' : ι') (hi' : e.r i' = none) :\n  is_zero (embed e ⋙ homological_complex.eval 𝒞 _ i') :=\nbegin\n  rw functor.is_zero_iff,\n  intro X,\n  exact is_zero.of_iso (limits.is_zero_zero _) (embed.X_iso_of_none X hi'),\nend\n\n@[simps]\ndef embed_eval_iso_of_some (i' : ι') (i : ι) (hi' : e.r i' = some i) :\n  embed e ⋙ homological_complex.eval 𝒞 cι' i' ≅ homological_complex.eval 𝒞 cι i :=\nnat_iso.of_components (λ X, embed.X_iso_of_some X hi')\n  (λ X₁ X₂ f, begin\n    dsimp [embed, embed.map],\n    rw embed.f_of_some f hi',\n    simp only [category.assoc, iso.inv_hom_id, category.comp_id],\n  end)\n\n@[simp]\nlemma embed_nat_obj_down_up_succ\n  (C : chain_complex 𝒞 ℕ) (i : ℕ) :\n  ((embed complex_shape.embedding.nat_down_int_up).obj C).X (-[1+i]) = C.X (i+1) := rfl\n\n@[simp]\nlemma embed_nat_obj_down_up_zero\n  (C : chain_complex 𝒞 ℕ) :\n  ((embed complex_shape.embedding.nat_down_int_up).obj C).X 0 = C.X 0 := rfl\n\n@[simp]\nlemma embed_nat_obj_down_up_pos\n  (C : chain_complex 𝒞 ℕ) (i : ℕ) :\n  ((embed complex_shape.embedding.nat_down_int_up).obj C).X (i+1) = 0 := rfl\n\n@[simp]\nlemma embed_nat_obj_down_up_succ_f\n  (C₁ C₂ : chain_complex 𝒞 ℕ) (f : C₁ ⟶ C₂) (i : ℕ) :\n  ((embed complex_shape.embedding.nat_down_int_up).map f).f (-[1+i]) = f.f (i+1) := rfl\n\n@[simp]\nlemma embed_nat_obj_down_up_zero_f\n  (C₁ C₂ : chain_complex 𝒞 ℕ) (f : C₁ ⟶ C₂) :\n  ((embed complex_shape.embedding.nat_down_int_up).map f).f 0 = f.f 0 := rfl\n\n@[simp]\nlemma embed_nat_obj_down_up_zero_pos\n  (C₁ C₂ : chain_complex 𝒞 ℕ) (f : C₁ ⟶ C₂) (i : ℕ) :\n  ((embed complex_shape.embedding.nat_down_int_up).map f).f (i+1) = 0 := rfl\n\nend embedding_change_of_complex\n\nsection homotopy\n\nvariables {X Y : homological_complex 𝒞 cι}\n\nvariables (f f' : X ⟶ Y) (h : homotopy f f')\n\n/-- The morphism `hᵢⱼ: Xᵢ ⟶ Yⱼ` coming from a homotopy between two morphisms of type `X ⟶ Y`.\n  Here `X` and `Y` are complexes of shape `ι` and the indices `i j` run over `option ι`. -/\ndef embed_homotopy_hom : Π (i j : option ι), embed.X X i ⟶ embed.X Y j\n| (some i) (some j) := h.hom i j\n| (some i) none     := 0\n| none     j        := 0\n\n@[simp] lemma embed_homotopy_hom_some (i j : ι) :\n  embed_homotopy_hom f f' h (some i) (some j) = h.hom i j := rfl\n\n@[simp] lemma embed_homotopy_hom_eq_zero_of_to_none (oi : option ι) :\n  embed_homotopy_hom f f' h oi none = 0 := by cases oi; refl\n\n@[simp] lemma embed_homotopy_hom_eq_zero_of_of_none (oi : option ι) :\n  embed_homotopy_hom f f' h none oi = 0 := rfl\n\nlemma embed_homotopy_zero : Π (oi oj : option ι)\n  (H : ∀ (i j : ι), oi = some i → oj = some j → ¬ cι.rel j i),\n  embed_homotopy_hom f f' h oi oj = 0\n| (some i) (some j) H := h.zero i j $ H _ _ rfl rfl\n| (some i) none     H := rfl\n| none     j        H := rfl\n\ndef embed_homotopy (e : cι.embedding cι') :\n  homotopy ((embed e).map f) ((embed e).map f') :=\n{ hom := λ i j, embed_homotopy_hom f f' h (e.r i) (e.r j),\n  zero' := λ i j hij, embed_homotopy_zero f f' h _ _ begin\n    simp only [e.eq_some],\n    rintro i' j' rfl rfl h',\n    exact hij (e.c h')\n  end,\n  comm := λ i', begin\n    by_cases hi : ∃ i : ι, i' = e.f i,\n    { rcases hi with ⟨i, rfl⟩,\n      delta embed embed.map embed.obj embed.X embed.d embed.f\n        embed_homotopy_hom d_next prev_d id_rhs,\n      dsimp only [add_monoid_hom.mk'_apply],\n      rw e.r_f i,\n      dsimp only,\n      rw h.comm i,\n      delta d_next prev_d id_rhs,\n      dsimp only [add_monoid_hom.mk'_apply],\n      rw add_left_inj,\n      congr' 1,\n      { by_cases aux : ∃ j, cι.rel i j,\n        { rcases aux with ⟨j, hj⟩,\n          rw [cι.next_eq' hj, cι'.next_eq' (e.c hj), e.r_f] },\n        { push_neg at aux,\n          induction x : e.r (cι'.next (e.f i));\n          simp only [X.shape _ _ (aux _), zero_comp], } },\n      { by_cases aux : ∃ j, cι.rel j i,\n        { rcases aux with ⟨j, hj⟩,\n          rw [cι.prev_eq' hj, cι'.prev_eq' (e.c hj), e.r_f] },\n        { push_neg at aux,\n          induction x : e.r (cι'.prev (e.f i));\n          simp only [Y.shape _ _ (aux _), comp_zero], } } },\n    { -- i' not in image\n      have foo := e.r_none _ hi,\n      suffices : subsingleton (embed.X X (e.r i') ⟶ embed.X Y (e.r i')),\n      { refine @subsingleton.elim _ this _ _ },\n      convert (homological_complex.embed.subsingleton_of_none X _), },\n  end }\n\nend homotopy\n\nsection homology_comparison\n\ndef congr_eval (𝓐 : Type*) [category 𝓐] [preadditive 𝓐] (c₁ : complex_shape ι₁) (i j : ι₁)\n  (h : i = j) : eval 𝓐 c₁ i ≅ eval 𝓐 c₁ j := eq_to_iso (by rw h)\n\ndef congr_prev_functor (𝓐 : Type*) [category 𝓐] [abelian 𝓐] (c₁ : complex_shape ι₁) (i j : ι₁)\n  (h : i = j) : prev_functor 𝓐 c₁ i ≅ prev_functor 𝓐 c₁ j := eq_to_iso (by rw h)\n\ndef congr_next_functor (𝓐 : Type*) [category 𝓐] [abelian 𝓐] (c₁ : complex_shape ι₁) (i j : ι₁)\n  (h : i = j) : next_functor 𝓐 c₁ i ≅ next_functor 𝓐 c₁ j := eq_to_iso (by rw h)\n\ndef embed_comp_eval (𝓐 : Type*) [category 𝓐] [preadditive 𝓐] [has_zero_object 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (i₁ : ι₁) :\n  embed e ⋙ eval 𝓐 c₂ (e.f i₁) ≅ eval 𝓐 c₁ i₁ :=\nnat_iso.of_components\n(λ X, embed.X_iso_of_some X (e.r_f i₁))\n(λ X Y f, begin\n  dsimp [embed, embed.map],\n  rw embed.f_of_some f (e.r_f i₁),\n  simp only [category.assoc, iso.inv_hom_id, category.comp_id],\nend)\n\n/-\ndef embed_comp_prev_functor (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (he : e.c_iff) (i₁ : ι₁) :\n  embed e ⋙ prev_functor 𝓐 c₂ (e.f i₁) ≅ prev_functor 𝓐 c₁ i₁ :=\nbegin\n  rcases h₁ : c₁.prev i₁ with _ | ⟨j, hj⟩,\n  { apply is_zero.iso,\n    { rcases h₂ : c₂.prev (e.f i₁) with _ | ⟨k, hk⟩,\n      { apply functor.is_zero_of_comp,\n        exact prev_functor_is_zero _ _ _ h₂, },\n      { rw is_zero.iff_id_eq_zero,\n        ext X,\n        apply is_zero.eq_of_src,\n        dsimp,\n        refine is_zero.of_iso _ (((embed e).obj X).X_prev_iso hk),\n        dsimp [embed, embed.obj],\n        apply embed.X_is_zero_of_none X,\n        apply e.r_none,\n        rintro ⟨i, hi⟩,\n        rw [hi, ← he] at hk,\n        rw c₁.prev_eq_some hk at h₁,\n        simpa only using h₁, }, },\n    { exact prev_functor_is_zero _ _ _ h₁, }, },\n  { exact iso_whisker_left (embed e) (prev_functor_iso_eval 𝓐 c₂ (e.f i₁) (e.f j) (e.c hj)) ≪≫\n       embed_comp_eval 𝓐 e j ≪≫\n       (prev_functor_iso_eval 𝓐 c₁ i₁ j hj).symm, }\nend\n\ndef embed_comp_next_functor (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (he : e.c_iff) (i₁ : ι₁) :\n  embed e ⋙ next_functor 𝓐 c₂ (e.f i₁) ≅ next_functor 𝓐 c₁ i₁ :=\nbegin\n  rcases h₁ : c₁.next i₁ with _ | ⟨j, hj⟩,\n  { apply is_zero.iso,\n    { rcases h₂ : c₂.next (e.f i₁) with _ | ⟨k, hk⟩,\n      { apply functor.is_zero_of_comp,\n        exact next_functor_is_zero _ _ _ h₂, },\n      { rw is_zero.iff_id_eq_zero,\n        ext X,\n        apply is_zero.eq_of_src,\n        dsimp,\n        refine is_zero.of_iso _ (((embed e).obj X).X_next_iso hk),\n        dsimp [embed, embed.obj],\n        apply embed.X_is_zero_of_none X,\n        apply e.r_none,\n        rintro ⟨i, hi⟩,\n        rw [hi, ← he] at hk,\n        rw c₁.next_eq_some hk at h₁,\n        simpa only using h₁,}, },\n    { exact next_functor_is_zero _ _ _ h₁, }, },\n  { exact iso_whisker_left (embed e) (next_functor_iso_eval 𝓐 c₂ (e.f i₁) (e.f j) (e.c hj)) ≪≫\n       embed_comp_eval 𝓐 e j ≪≫\n       (next_functor_iso_eval 𝓐 c₁ i₁ j hj).symm }\nend\n\ndef embed_short_complex_functor_homological_complex_π₁ (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (he : e.c_iff)\n  (i₁ : ι₁) (i₂ : ι₂) (h₁₂ : e.f i₁ = i₂) :\n  (embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂) ⋙ short_complex.π₁ ≅\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₁ :=\nfunctor.associator _ _ _ ≪≫\n  iso_whisker_left (embed e)\n    (short_complex.functor_homological_complex_π₁_iso_prev_functor 𝓐 c₂ i₂) ≪≫\n  (iso_whisker_left (embed e) (congr_prev_functor 𝓐 c₂ i₂ (e.f i₁) h₁₂.symm)) ≪≫\n  embed_comp_prev_functor 𝓐 e he i₁ ≪≫\n  (short_complex.functor_homological_complex_π₁_iso_prev_functor 𝓐 c₁ i₁).symm\n\ndef embed_short_complex_functor_homological_complex_π₂ (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (i₁ : ι₁) (i₂ : ι₂)\n  (h₁₂ : e.f i₁ = i₂) :\n  (embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂) ⋙ short_complex.π₂ ≅\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₂ :=\nfunctor.associator _ _ _ ≪≫\n  iso_whisker_left (embed e)\n    (short_complex.functor_homological_complex_π₂_iso_eval 𝓐 c₂ i₂) ≪≫\n  (iso_whisker_left (embed e) (congr_eval 𝓐 c₂ i₂ (e.f i₁) h₁₂.symm)) ≪≫\n  embed_comp_eval 𝓐 e i₁ ≪≫\n  (short_complex.functor_homological_complex_π₂_iso_eval 𝓐 c₁ i₁).symm\n\ndef embed_short_complex_functor_homological_complex_π₃ (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (he : e.c_iff)\n  (i₁ : ι₁) (i₂ : ι₂) (h₁₂ : e.f i₁ = i₂) :\n  (embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂) ⋙ short_complex.π₃ ≅\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₃ :=\nfunctor.associator _ _ _ ≪≫\n  iso_whisker_left (embed e)\n    (short_complex.functor_homological_complex_π₃_iso_next_functor 𝓐 c₂ i₂) ≪≫\n  (iso_whisker_left (embed e) (congr_next_functor 𝓐 c₂ i₂ (e.f i₁) h₁₂.symm)) ≪≫\n  embed_comp_next_functor 𝓐 e he i₁ ≪≫\n  (short_complex.functor_homological_complex_π₃_iso_next_functor 𝓐 c₁ i₁).symm\n\nlemma embed_d_to (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (he : e.c_iff)\n  (i₁ : ι₁) (X : homological_complex 𝓐 c₁) :\n  ((embed e).obj X).d_to (e.f i₁) ≫ (embed.X_iso_of_some X (e.r_f i₁)).hom =\n  (embed_comp_prev_functor 𝓐 e he i₁).hom.app X ≫ X.d_to i₁ :=\nbegin\n  dsimp [embed_comp_prev_functor],\n  rcases h₁ : c₁.prev i₁ with _ | ⟨j, hj⟩,\n  { simp only [h₁, d_to_eq_zero, comp_zero, preadditive.is_iso.comp_right_eq_zero],\n    rcases h₂ : c₂.prev (e.f i₁) with _ | ⟨k, hk⟩,\n    { apply is_zero.eq_of_src,\n      exact is_zero.of_iso (limits.is_zero_zero _) (((embed e).obj X).X_prev_iso_zero h₂), },\n    { simp only [homological_complex.d_to_eq _ hk, preadditive.is_iso.comp_left_eq_zero],\n      dsimp [embed, embed.obj, embed.d],\n      rcases h₃ : e.r k with _ | l,\n      { refl, },\n      { rw e.r_f i₁,\n        dsimp [embed.d],\n        by_cases h₄ : c₁.rel l i₁,\n        { exfalso,\n          simpa only [c₁.prev_eq_some h₄] using h₁, },\n        { exact X.shape _ _ h₄, }, }, }, },\n  { simp only [h₁, homological_complex.d_to_eq _ hj,\n      homological_complex.d_to_eq _ (e.c hj)],\n    conv_lhs { congr, congr, skip, dsimp [embed, embed.obj, embed.d], },\n    rw embed.d_of_some_of_some X (e.r_f j) (e.r_f i₁),\n    dsimp [iso_whisker_left, prev_functor_iso_eval, embed_comp_eval, nat_iso.of_components],\n    simp only [category.assoc, iso.inv_hom_id, category.comp_id, iso.inv_hom_id_assoc], },\nend\n\nlemma embed_d_from (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (he : e.c_iff)\n  (i₁ : ι₁) (X : homological_complex 𝓐 c₁) :\n  ((embed e).obj X).d_from (e.f i₁) ≫ (embed_comp_next_functor 𝓐 e he i₁).hom.app X =\n  (embed.X_iso_of_some X (e.r_f i₁)).hom ≫ X.d_from i₁ :=\nbegin\n  dsimp [embed_comp_next_functor],\n  rcases h₁ : c₁.next i₁ with _ | ⟨j, hj⟩,\n  { simp only [h₁, d_from_eq_zero, comp_zero, preadditive.is_iso.comp_right_eq_zero],\n    rcases h₂ : c₂.next (e.f i₁) with _ | ⟨k, hk⟩,\n    { apply is_zero.eq_of_tgt,\n      exact is_zero.of_iso (limits.is_zero_zero _) (((embed e).obj X).X_next_iso_zero h₂), },\n    { simp only [homological_complex.d_from_eq _ hk, preadditive.is_iso.comp_right_eq_zero],\n      dsimp [embed, embed.obj, embed.d],\n      rcases h₃ : e.r k with _ | l,\n      { exact embed.d_of_none_tgt X rfl, },\n      { rw e.r_f i₁,\n        dsimp [embed.d],\n        by_cases h₄ : c₁.rel i₁ l,\n        { exfalso,\n          simpa only [c₁.next_eq_some h₄] using h₁, },\n        { exact X.shape _ _ h₄, }, }, }, },\n  { simp only [h₁, homological_complex.d_from_eq _ hj,\n      homological_complex.d_from_eq _ (e.c hj)],\n    conv_lhs { congr, congr, dsimp [embed, embed.obj, embed.d], },\n    rw embed.d_of_some_of_some X (e.r_f i₁) (e.r_f j),\n    dsimp [iso_whisker_left, next_functor_iso_eval, embed_comp_eval, nat_iso.of_components],\n    simp only [category.assoc, eq_to_hom_trans, eq_to_hom_refl, category.comp_id,\n      iso.inv_hom_id_assoc], },\nend\n\ndef embed_short_complex_functor_homological_complex (𝓐 : Type*) [category 𝓐] [abelian 𝓐]\n  {c₁ : complex_shape ι₁} {c₂ : complex_shape ι₂} (e : c₁.embedding c₂) (he : e.c_iff)\n  (i₁ : ι₁) (i₂ : ι₂) (h₁₂ : e.f i₁ = i₂) :\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ ≅\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ :=\nbegin\n  refine short_complex.functor_nat_iso_mk\n    (embed_short_complex_functor_homological_complex_π₁ 𝓐 e he i₁ i₂ h₁₂)\n    (embed_short_complex_functor_homological_complex_π₂ 𝓐 e i₁ i₂ h₁₂)\n    (embed_short_complex_functor_homological_complex_π₃ 𝓐 e he i₁ i₂ h₁₂) _ _,\n  { subst h₁₂,\n    ext X,\n    dsimp [nat_trans.hcomp, embed_short_complex_functor_homological_complex_π₂,\n      short_complex.functor_homological_complex_π₂_iso_eval,\n      embed_short_complex_functor_homological_complex_π₁, congr_eval,\n      congr_prev_functor, embed_comp_eval, iso.refl,\n      short_complex.functor_homological_complex_π₁_iso_prev_functor],\n    simp only [category.assoc],\n    erw [nat_trans.id_app, nat_trans.id_app],\n    repeat { erw category.id_comp, },\n    repeat { erw category.comp_id, },\n    apply embed_d_to, },\n  { subst h₁₂,\n    ext X,\n    dsimp [nat_trans.hcomp, embed_short_complex_functor_homological_complex_π₂,\n      short_complex.functor_homological_complex_π₂_iso_eval,\n      embed_short_complex_functor_homological_complex_π₃, congr_eval,\n      congr_prev_functor, embed_comp_eval, iso.refl,\n      short_complex.functor_homological_complex_π₃_iso_next_functor],\n    simp only [category.assoc],\n    erw [nat_trans.id_app, nat_trans.id_app],\n    repeat { erw category.id_comp, },\n    repeat { erw category.comp_id, },\n    apply embed_d_from, },\nend\n-/\n\nvariables (𝓐 : Type*) [category 𝓐] [abelian 𝓐] (e : c₁.embedding c₂)\n  (i₁ : ι₁) (i₂ : ι₂)\n\n@[simp]\ndef embed_short_complex_π₁_ι :\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ ⋙ short_complex.π₁ ⟶\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₁ :=\nbegin\n  by_cases e.r (c₂.prev i₂) = some (c₁.prev i₁),\n  { exact (embed_eval_iso_of_some e _ _ h).hom, },\n  { exact 0, },\nend\n\n@[simp]\ndef embed_short_complex_π₂_iso (h₁₂ : e.f i₁ = i₂) :\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ ⋙ short_complex.π₂ ≅\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₂ :=\nembed_eval_iso_of_some e i₂ i₁ (by { rw [← h₁₂, e.r_f],})\n\n@[simp]\ndef embed_short_complex_π₃_ι :\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ ⋙ short_complex.π₃ ⟶\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₃ :=\nbegin\n  by_cases e.r (c₂.next i₂) = some (c₁.next i₁),\n  { exact (embed_eval_iso_of_some e _ _ h).hom, },\n  { exact 0, },\nend\n\n-- @[simps]\ndef embed_short_complex_ι (h₁₂ : e.f i₁ = i₂) :\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ ⟶\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ :=\nshort_complex.nat_trans_hom_mk\n  (embed_short_complex_π₁_ι 𝓐 e _ _)\n  (embed_short_complex_π₂_iso 𝓐 e _ _ h₁₂).hom\n  (embed_short_complex_π₃_ι 𝓐 e _ _)\nbegin\n  ext X,\n  subst h₁₂,\n  show (((embed e).obj X).d_to (e.f i₁) ≫ 𝟙 (((embed e).obj X).X (e.f i₁))) ≫ (embed.X_iso_of_some X _).hom =\n    (embed_short_complex_π₁_ι 𝓐 e i₁ (e.f i₁)).app X ≫ X.d_to i₁ ≫ 𝟙 (X.X i₁),\n  simp only [embed_short_complex_π₁_ι, category.comp_id],\n  split_ifs with h,\n  { show embed.d X (e.r (c₂.prev (e.f i₁))) (e.r (e.f i₁)) ≫ (embed.X_iso_of_some X _).hom =\n      (embed.X_iso_of_some X h).hom ≫ X.d (c₁.prev i₁) i₁,\n    simp only [embed.d_of_some_of_some X h (e.r_f i₁),\n      category.assoc, iso.inv_hom_id, category.comp_id], },\n  { suffices : ((embed e).obj X).d_to (e.f i₁) = 0,\n    { simp only [this, nat_trans.app_zero, zero_comp], },\n    rcases h₂ : e.r (c₂.prev (e.f i₁)) with _ | j,\n    { apply is_zero.eq_of_src,\n      apply embed.X_is_zero_of_none,\n      exact h₂, },\n    { show embed.d X (e.r (c₂.prev (e.f i₁))) (e.r (e.f i₁)) = 0,\n      by_contra h',\n      rcases embed.d_ne_zero _ _ _ h' with ⟨i, k, h₃, h₄, h₅⟩,\n      rw e.r_f at h₄,\n      rw h₂ at h₃,\n      simp only at h₄ h₃,\n      substs h₃ h₄,\n      have h₅' : c₁.rel j i₁,\n      { by_contra h₅'',\n        exact h₅ (X.shape _ _ h₅''), },\n      rw c₁.prev_eq' h₅' at h,\n      exact h h₂, }, },\nend\nbegin\n  ext X,\n  show (((embed e).obj X).d_from i₂ ≫ 𝟙 (((embed e).obj X).X_next i₂)) ≫ _ =\n    (embed.X_iso_of_some X _).hom ≫ X.d_from i₁ ≫ 𝟙 (X.X_next i₁),\n  dsimp only [embed_short_complex_π₃_ι],\n  subst h₁₂,\n  split_ifs with h,\n  { simp only [category.comp_id],\n    show embed.d X (e.r (e.f i₁)) (e.r (c₂.next (e.f i₁))) ≫ (embed.X_iso_of_some X h).hom =\n      (embed.X_iso_of_some X _).hom ≫ X.d_from i₁,\n    simp only [embed.d_of_some_of_some X (e.r_f i₁) h,\n      category.assoc, iso.inv_hom_id, category.comp_id], },\n  { suffices : X.d i₁ (c₁.next i₁) = 0,\n    { delta d_from, simp only [this, zero_comp, comp_zero, nat_trans.app_zero], },\n    apply X.shape,\n    rw e.eq_some at h,\n    contrapose! h,\n    rw c₂.next_eq' (e.c h) },\nend\n.\n\n@[simp]\ndef embed_short_complex_π₁_π :\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₁ ⟶\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ ⋙ short_complex.π₁ :=\nbegin\n  by_cases e.r (c₂.prev i₂) = some (c₁.prev i₁),\n  { exact (embed_eval_iso_of_some e _ _ h).inv, },\n  { exact 0, },\nend\n\n@[simp]\ndef embed_short_complex_π₃_π :\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⋙ short_complex.π₃ ⟶\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ ⋙ short_complex.π₃ :=\nbegin\n  by_cases e.r (c₂.next i₂) = some (c₁.next i₁),\n  { exact (embed_eval_iso_of_some e _ _ h).inv, },\n  { exact 0, },\nend\n\n@[simps]\ndef embed_short_complex_π (h₁₂ : e.f i₁ = i₂) :\n  short_complex.functor_homological_complex 𝓐 c₁ i₁ ⟶\n  embed e ⋙ short_complex.functor_homological_complex 𝓐 c₂ i₂ :=\nshort_complex.nat_trans_hom_mk\n  (embed_short_complex_π₁_π 𝓐 e _ _)\n  (embed_short_complex_π₂_iso 𝓐 e _ _ h₁₂).inv\n  (embed_short_complex_π₃_π 𝓐 e _ _)\nbegin\n  ext X,\n  show (X.d_to i₁ ≫ 𝟙 (X.X i₁)) ≫ (embed.X_iso_of_some X _).inv =\n    _ ≫ ((embed e).obj X).d_to i₂ ≫ 𝟙 (((embed e).obj X).X i₂),\n  dsimp only [embed_short_complex_π₁_π],\n  subst h₁₂,\n  split_ifs with h,\n  { simp only [category.comp_id],\n    show X.d (c₁.prev i₁) i₁ ≫ (embed.X_iso_of_some X _).inv =\n      (embed.X_iso_of_some X h).inv ≫ embed.d X (e.r (c₂.prev (e.f i₁))) (e.r (e.f i₁)),\n    simp only [embed.d_of_some_of_some X h (e.r_f i₁), category.assoc, iso.inv_hom_id_assoc], },\n  { suffices : X.d (c₁.prev i₁) i₁ = 0,\n    { delta d_to, simp only [this, zero_comp, nat_trans.app_zero], },\n    apply X.shape,\n    rw e.eq_some at h,\n    contrapose! h,\n    rw c₂.prev_eq' (e.c h) },\nend\nbegin\n  ext X,\n  show (X.d_from i₁ ≫ 𝟙 (X.X_next i₁)) ≫ _ =\n    (embed.X_iso_of_some X _).inv ≫ ((embed e).obj X).d_from i₂ ≫ 𝟙 (((embed e).obj X).X_next i₂),\n  dsimp only [embed_short_complex_π₃_π],\n  subst h₁₂,\n  split_ifs with h,\n  { simp only [category.comp_id],\n    show X.d i₁ (c₁.next i₁) ≫ (embed.X_iso_of_some X h).inv =\n      (embed.X_iso_of_some X _).inv ≫ embed.d X (e.r (e.f i₁)) (e.r (c₂.next (e.f i₁))),\n    simp only [embed.d_of_some_of_some X (e.r_f i₁) h, category.assoc, iso.inv_hom_id_assoc], },\n  { suffices : ((embed e).obj X).d_from (e.f i₁) = 0,\n    { simp only [this, nat_trans.app_zero, zero_comp, comp_zero], },\n    rcases h₂ : e.r (c₂.next (e.f i₁)) with _ | j,\n    { apply is_zero.eq_of_tgt,\n      apply embed.X_is_zero_of_none,\n      exact h₂, },\n    { show embed.d X (e.r (e.f i₁)) (e.r (c₂.next (e.f i₁))) = 0,\n      by_contra h',\n      rcases embed.d_ne_zero _ _ _ h' with ⟨i, k, h₃, h₄, h₅⟩,\n      rw e.r_f at h₃,\n      rw h₂ at h₄,\n      simp only at h₄ h₃,\n      substs h₃ h₄,\n      have h₅' : c₁.rel i₁ j,\n      { by_contra h₅'',\n        exact h₅ (X.shape _ _ h₅''), },\n      rw c₁.next_eq' h₅' at h,\n      exact h h₂, }, },\nend\n\ndef homology_embed_nat_iso (h₁₂ : e.f i₁ = i₂) :\n  embed e ⋙ homology_functor 𝓐 c₂ i₂ ≅ homology_functor 𝓐 c₁ i₁ :=\n{ hom := embed_short_complex_ι 𝓐 e i₁ i₂ h₁₂ ◫ (𝟙 short_complex.homology_functor),\n  inv := embed_short_complex_π 𝓐 e i₁ i₂ h₁₂ ◫ (𝟙 short_complex.homology_functor),\n  hom_inv_id' := begin\n    ext K : 2,\n    simp only [nat_trans.comp_app, nat_trans.hcomp_id_app, nat_trans.id_app,\n      ← functor.map_comp],\n    apply short_complex.homology_functor_map_eq_id,\n    simp only [short_complex.comp_τ₂],\n    dsimp only [embed_short_complex_ι, embed_short_complex_π],\n    simpa only [short_complex.nat_trans_hom_mk_app_τ₂_eq,\n      iso.hom_inv_id_app],\n  end,\n  inv_hom_id' := begin\n    ext K : 2,\n    simp only [nat_trans.comp_app, nat_trans.hcomp_id_app, nat_trans.id_app,\n      ← functor.map_comp],\n    apply short_complex.homology_functor_map_eq_id,\n    simp only [short_complex.comp_τ₂],\n    dsimp only [embed_short_complex_ι, embed_short_complex_π],\n    simpa only [short_complex.nat_trans_hom_mk_app_τ₂_eq,\n      iso.inv_hom_id_app],\n  end, }\n\nend homology_comparison\n\nend homological_complex\n\nnamespace chain_complex\n\ndef single₀_comp_embed_iso_single_component (X : 𝒞) : Π (i : ℤ),\n  ((single₀ 𝒞 ⋙ homological_complex.embed complex_shape.embedding.nat_down_int_up).obj X).X i ≅\n    ((homological_complex.single 𝒞 (complex_shape.up ℤ) 0).obj X).X i\n| 0       := iso.refl _\n| (n+1:ℕ) := iso.refl _\n| -[1+n]  := iso.refl _\n\ndef single₀_comp_embed_iso_single :\n  single₀ 𝒞 ⋙ homological_complex.embed complex_shape.embedding.nat_down_int_up ≅\n    homological_complex.single 𝒞 (complex_shape.up ℤ) 0 :=\nnat_iso.of_components\n  (λ X, homological_complex.hom.iso_of_components\n    (single₀_comp_embed_iso_single_component X)\n    (by rintro ((_|i)|i) ((_|j)|j) hij; exact comp_zero.trans zero_comp.symm))\n  begin\n    intros X Y f,\n    ext ((_|i)|i);\n    refine (category.comp_id _).trans (eq.trans _ (category.id_comp _).symm);\n    dsimp [homological_complex.single],\n    { simp only [eq_self_iff_true, category.comp_id, category.id_comp, if_true, nat.cast_zero], refl },\n    { rw dif_neg, swap, dec_trivial, refl },\n    { rw dif_neg, swap, dec_trivial }\n  end\n\nend chain_complex\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/complex_extend.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4741822453123168}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Tim Baanen\n-/\nimport Mathlib.Tactic.Ring.Basic\nimport Mathlib.Tactic.Conv\n\n/-!\n# `ring_nf` tactic\n\nA tactic which uses `ring` to rewrite expressions. This can be used non-terminally to normalize\nring expressions in the goal such as `⊢ P (x + x + x)` ~> `⊢ P (x * 3)`, as well as being able to\nprove some equations that `ring` cannot because they involve ring reasoning inside a subterm,\nsuch as `sin (x + y) + sin (y + x) = 2 * sin (x + y)`.\n\n-/\n\nnamespace Mathlib.Tactic\nopen Lean hiding Rat\nopen Qq Meta\n\nnamespace Ring\n\n/-- True if this represents an atomic expression. -/\ndef ExBase.isAtom : ExBase sα a → Bool\n  | .atom _ => true\n  | _ => false\n\n/-- True if this represents an atomic expression. -/\ndef ExProd.isAtom : ExProd sα a → Bool\n  | .mul va₁ (.const 1 _) (.const 1 _) => va₁.isAtom\n  | _ => false\n\n/-- True if this represents an atomic expression. -/\ndef ExSum.isAtom : ExSum sα a → Bool\n  | .add va₁ va₂ => match va₂ with -- FIXME: this takes a while to compile as one match\n    | .zero => va₁.isAtom\n    | _ => false\n  | _ => false\n\nend Ring\n\nnamespace RingNF\nopen Ring\n\n/-- The normalization style for `ring_nf`. -/\ninductive RingMode where\n  /-- Sum-of-products form, like `x + x * y * 2 + z ^ 2`. -/\n  | SOP\n  /-- Raw form: the representation `ring` uses internally. -/\n  | raw\n  deriving Inhabited, BEq, Repr\n\n/-- Configuration for `ring_nf`. -/\nstructure Config where\n  /-- the reducibility setting to use when comparing atoms for defeq -/\n  red := TransparencyMode.reducible\n  /-- if true, atoms inside ring expressions will be reduced recursively -/\n  recursive := true\n  /-- The normalization style. -/\n  mode := RingMode.SOP\n  deriving Inhabited, BEq, Repr\n\n/-- Function elaborating `RingNF.Config`. -/\ndeclare_config_elab elabConfig Config\n\n/-- The read-only state of the `RingNF` monad. -/\nstructure Context where\n  /-- A basically empty simp context, passed to the `simp` traversal in `RingNF.rewrite`. -/\n  ctx : Simp.Context\n  /-- A cleanup routine, which simplifies normalized polynomials to a more human-friendly\n  format. -/\n  simp : Simp.Result → SimpM Simp.Result\n\n/-- The monad for `RingNF` contains, in addition to the `AtomM` state,\na simp context for the main traversal and a simp function (which has another simp context)\nto simplify normalized polynomials. -/\nabbrev M := ReaderT Context AtomM\n\n/--\nA tactic in the `RingNF.M` monad which will simplify expression `parent` to a normal form.\n* `root`: true if this is a direct call to the function.\n  `RingNF.M.run` sets this to `false` in recursive mode.\n-/\ndef rewrite (parent : Expr) (root := true) : M Simp.Result :=\n  fun nctx rctx s ↦ do\n    let pre e :=\n      try\n        guard <| root || parent != e -- recursion guard\n        let e ← withReducible <| whnf e\n        guard e.isApp -- all interesting ring expressions are applications\n        let ⟨.succ u, α, e⟩ ← inferTypeQ e | failure\n        let sα ← synthInstanceQ (q(CommSemiring $α) : Q(Type u))\n        let c ← mkCache sα\n        let ⟨a, _, pa⟩ ← match ← isAtomOrDerivable sα c e rctx s with\n        | none => eval sα c e rctx s -- `none` indicates that `eval` will find something algebraic.\n        | some none => failure -- No point rewriting atoms\n        | some (some r) => pure r -- Nothing algebraic for `eval` to use, but `norm_num` simplifies.\n        let r ← nctx.simp { expr := a, proof? := pa }\n        if ← withReducible <| isDefEq r.expr e then return .done { expr := r.expr }\n        pure (.done r)\n      catch _ => pure <| .visit { expr := e }\n    let post := (Simp.postDefault · fun _ ↦ none)\n    (·.1) <$> Simp.main parent nctx.ctx (methods := { pre, post })\n\nvariable [CommSemiring R]\n\ntheorem add_assoc_rev (a b c : R) : a + (b + c) = a + b + c := (add_assoc ..).symm\ntheorem mul_assoc_rev (a b c : R) : a * (b * c) = a * b * c := (mul_assoc ..).symm\ntheorem mul_neg {R} [Ring R] (a b : R) : a * -b = -(a * b) := by simp\ntheorem add_neg {R} [Ring R] (a b : R) : a + -b = a - b := (sub_eq_add_neg ..).symm\ntheorem nat_rawCast_0 : (Nat.rawCast 0 : R) = 0 := by simp\ntheorem nat_rawCast_1 : (Nat.rawCast 1 : R) = 1 := by simp\ntheorem nat_rawCast_2 [Nat.AtLeastTwo n] : (Nat.rawCast n : R) = OfNat.ofNat n := rfl\ntheorem int_rawCast_1 {R} [Ring R] : (Int.rawCast (.negOfNat 1) : R) = -1 := by\n  simp [Int.negOfNat_eq]\ntheorem int_rawCast_2 {R} [Ring R] [Nat.AtLeastTwo n] :\n    (Int.rawCast (.negOfNat n) : R) = -OfNat.ofNat n := by\n  simp [Int.negOfNat_eq, OfNat.ofNat]\ntheorem rat_rawCast_2 {R} [DivisionRing R] : (Rat.rawCast n d : R) = n / d := by simp\n\n/--\nRuns a tactic in the `RingNF.M` monad, given initial data:\n\n* `s`: a reference to the mutable state of `ring`, for persisting across calls.\n  This ensures that atom ordering is used consistently.\n* `cfg`: the configuration options\n* `x`: the tactic to run\n-/\npartial def M.run\n    (s : IO.Ref AtomM.State) (cfg : RingNF.Config) (x : M α) : MetaM α := do\n  let ctx := {\n    simpTheorems := #[← Elab.Tactic.simpOnlyBuiltins.foldlM (·.addConst ·) {}]\n    congrTheorems := ← getSimpCongrTheorems }\n  let simp ← match cfg.mode with\n  | .raw => pure pure\n  | .SOP =>\n    let thms : SimpTheorems := {}\n    let thms ← [``add_zero, ``add_assoc_rev, ``_root_.mul_one, ``mul_assoc_rev,\n      ``_root_.pow_one, ``mul_neg, ``add_neg].foldlM (·.addConst ·) thms\n    let thms ← [``nat_rawCast_0, ``nat_rawCast_1, ``nat_rawCast_2, ``int_rawCast_1, ``int_rawCast_2,\n      ``rat_rawCast_2].foldlM (·.addConst · (post := false)) thms\n    let ctx' := { ctx with simpTheorems := #[thms] }\n    pure fun r' : Simp.Result ↦ do\n      Simp.mkEqTrans r' (← Simp.main r'.expr ctx' (methods := Simp.DefaultMethods.methods)).1\n  let nctx := { ctx, simp }\n  let rec\n    /-- The recursive context. -/\n    rctx := { red := cfg.red, evalAtom },\n    /-- The atom evaluator calls either `RingNF.rewrite` recursively,\n    or nothing depending on `cfg.recursive`. -/\n    evalAtom := if cfg.recursive\n      then fun e ↦ rewrite e false nctx rctx s\n      else fun e ↦ pure { expr := e }\n  x nctx rctx s\n\n/-- Overrides the default error message in `ring1` to use a prettified version of the goal. -/\ninitialize ringCleanupRef.set fun e => do\n  M.run (← IO.mkRef {}) { recursive := false } fun nctx _ _ =>\n    return (← nctx.simp { expr := e } nctx.ctx |>.run {}).1.expr\n\nopen Elab.Tactic Parser.Tactic\n/-- Use `ring_nf` to rewrite the main goal. -/\ndef ringNFTarget (s : IO.Ref AtomM.State) (cfg : Config) : TacticM Unit := withMainContext do\n  let goal ← getMainGoal\n  let tgt ← instantiateMVars (← goal.getType)\n  let r ← M.run s cfg <| rewrite tgt\n  if r.expr.isConstOf ``True then\n    goal.assign (← mkOfEqTrue (← r.getProof))\n    replaceMainGoal []\n  else\n    replaceMainGoal [← applySimpResultToTarget goal tgt r]\n\n/-- Use `ring_nf` to rewrite hypothesis `h`. -/\ndef ringNFLocalDecl (s : IO.Ref AtomM.State) (cfg : Config) (fvarId : FVarId) :\n    TacticM Unit := withMainContext do\n  let tgt ← instantiateMVars (← fvarId.getType)\n  let goal ← getMainGoal\n  let myres ← M.run s cfg <| rewrite tgt\n  match ← applySimpResultToLocalDecl goal fvarId myres false with\n  | none => replaceMainGoal []\n  | some (_, newGoal) => replaceMainGoal [newGoal]\n\n/--\nSimplification tactic for expressions in the language of commutative (semi)rings,\nwhich rewrites all ring expressions into a normal form.\n* `ring_nf!` will use a more aggressive reducibility setting to identify atoms.\n* `ring_nf (config := cfg)` allows for additional configuration:\n  * `red`: the reducibility setting (overridden by `!`)\n  * `recursive`: if true, `ring_nf` will also recurse into atoms\n* `ring_nf` works as both a tactic and a conv tactic.\n  In tactic mode, `ring_nf at h` can be used to rewrite in a hypothesis.\n-/\nelab (name := ringNF) \"ring_nf\" tk:\"!\"? cfg:(config ?) loc:(ppSpace location)? : tactic => do\n  let mut cfg ← elabConfig cfg\n  if tk.isSome then cfg := { cfg with red := .default }\n  let loc := (loc.map expandLocation).getD (.targets #[] true)\n  let s ← IO.mkRef {}\n  withLocation loc (ringNFLocalDecl s cfg) (ringNFTarget s cfg)\n    fun _ ↦ throwError \"ring_nf failed\"\n\n@[inherit_doc ringNF] macro \"ring_nf!\" cfg:(config)? loc:(ppSpace location)? : tactic =>\n  `(tactic| ring_nf ! $(cfg)? $(loc)?)\n\n@[inherit_doc ringNF] syntax (name := ringNFConv) \"ring_nf\" \"!\"? (config)? : conv\n\n/--\nTactic for solving equations of *commutative* (semi)rings, allowing variables in the exponent.\n\n* This version of `ring1` uses `ring_nf` to simplify in atoms.\n* The variant `ring1_nf!` will use a more aggressive reducibility setting\n  to determine equality of atoms.\n-/\nelab (name := ring1NF) \"ring1_nf\" tk:\"!\"? cfg:(config ?) : tactic => do\n  let mut cfg ← elabConfig cfg\n  if tk.isSome then cfg := { cfg with red := .default }\n  let s ← IO.mkRef {}\n  liftMetaMAtMain fun g ↦ M.run s cfg <| proveEq g\n\n@[inherit_doc ring1NF] macro \"ring1_nf!\" cfg:(config)? : tactic => `(tactic| ring1_nf ! $(cfg)?)\n\n/-- Elaborator for the `ring_nf` tactic. -/\n@[tactic ringNFConv] def elabRingNFConv : Tactic := fun stx ↦ match stx with\n  | `(conv| ring_nf $[!%$tk]? $(_cfg)?) => withMainContext do\n    let mut cfg ← elabConfig stx[2]\n    if tk.isSome then cfg := { cfg with red := .default }\n    let s ← IO.mkRef {}\n    Conv.applySimpResult (← M.run s cfg <| rewrite (← instantiateMVars (← Conv.getLhs)))\n  | _ => Elab.throwUnsupportedSyntax\n\n@[inherit_doc ringNF] macro \"ring_nf!\" cfg:(config)? : conv => `(conv| ring_nf ! $(cfg)?)\n\n/--\nTactic for evaluating expressions in *commutative* (semi)rings, allowing for variables in the\nexponent.\n\n* `ring!` will use a more aggressive reducibility setting to determine equality of atoms.\n* `ring1` fails if the target is not an equality.\n\nFor example:\n```\nexample (n : ℕ) (m : ℤ) : 2^(n+1) * m = 2 * 2^n * m := by ring\nexample (a b : ℤ) (n : ℕ) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring\nexample (x y : ℕ) : x + id y = y + id x := by ring!\n```\n-/\nmacro (name := ring) \"ring\" : tactic =>\n  `(tactic| first | ring1 | ring_nf; trace \"Try this: ring_nf\")\n@[inherit_doc ring] macro \"ring!\" : tactic =>\n  `(tactic| first | ring1! | ring_nf!; trace \"Try this: ring_nf!\")\n\n/--\nThe tactic `ring` evaluates expressions in *commutative* (semi)rings.\nThis is the conv tactic version, which rewrites a target which is a ring equality to `True`.\n\nSee also the `ring` tactic.\n-/\nmacro (name := ringConv) \"ring\" : conv =>\n  `(conv| first | discharge => ring1 | ring_nf; tactic => trace \"Try this: ring_nf\")\n@[inherit_doc ringConv] macro \"ring!\" : conv =>\n  `(conv| first | discharge => ring1! | ring_nf!; tactic => trace \"Try this: ring_nf!\")\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Tactic/Ring/RingNF.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4741822424990138}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro\n\n! This file was ported from Lean 3 source module algebra.order.ring.with_top\n! leanprover-community/mathlib commit 0111834459f5d7400215223ea95ae38a1265a907\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Hom.Ring\nimport Mathbin.Algebra.Order.Monoid.WithTop\nimport Mathbin.Algebra.Order.Ring.Canonical\n\n/-! # Structures involving `*` and `0` on `with_top` and `with_bot`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThe main results of this section are `with_top.canonically_ordered_comm_semiring` and\n`with_bot.ordered_comm_semiring`.\n-/\n\n\nvariable {α : Type _}\n\nnamespace WithTop\n\nvariable [DecidableEq α]\n\nsection Mul\n\nvariable [Zero α] [Mul α]\n\ninstance : MulZeroClass (WithTop α) where\n  zero := 0\n  mul m n := if m = 0 ∨ n = 0 then 0 else Option.map₂ (· * ·) m n\n  zero_mul a := if_pos <| Or.inl rfl\n  mul_zero a := if_pos <| Or.inr rfl\n\n/- warning: with_top.mul_def -> WithTop.mul_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithTop.{u1} α) (Or (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (Eq.{succ u1} (WithTop.{u1} α) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))))) (Or.decidable (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (Eq.{succ u1} (WithTop.{u1} α) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (Option.decidableEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (Option.decidableEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (Option.map₂.{u1, u1, u1} α α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_3)) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithTop.{u1} α) (Or (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (Eq.{succ u1} (WithTop.{u1} α) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (instDecidableOr (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (Eq.{succ u1} (WithTop.{u1} α) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))) (Option.map₂.{u1, u1, u1} α α α (fun (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.200 : α) (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.202 : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_3) x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.200 x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.202) a b))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_def WithTop.mul_defₓ'. -/\ntheorem mul_def {a b : WithTop α} : a * b = if a = 0 ∨ b = 0 then 0 else Option.map₂ (· * ·) a b :=\n  rfl\n#align with_top.mul_def WithTop.mul_def\n\n/- warning: with_top.mul_top' -> WithTop.mul_top' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α}, Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (ite.{succ u1} (WithTop.{u1} α) (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (Option.decidableEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] (a : WithTop.{u1} α), Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (ite.{succ u1} (WithTop.{u1} α) (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_top' WithTop.mul_top'ₓ'. -/\ntheorem mul_top' {a : WithTop α} : a * ⊤ = if a = 0 then 0 else ⊤ := by\n  induction a using WithTop.recTopCoe <;> simp [mul_def] <;> rfl\n#align with_top.mul_top' WithTop.mul_top'\n\n/- warning: with_top.mul_top -> WithTop.mul_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α}, (Ne.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) -> (Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α}, (Ne.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) -> (Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_top WithTop.mul_topₓ'. -/\n@[simp]\ntheorem mul_top {a : WithTop α} (h : a ≠ 0) : a * ⊤ = ⊤ := by rw [mul_top', if_neg h]\n#align with_top.mul_top WithTop.mul_top\n\n/- warning: with_top.top_mul' -> WithTop.top_mul' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α}, Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)) a) (ite.{succ u1} (WithTop.{u1} α) (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (Option.decidableEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] (a : WithTop.{u1} α), Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)) a) (ite.{succ u1} (WithTop.{u1} α) (Eq.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_top.top_mul' WithTop.top_mul'ₓ'. -/\ntheorem top_mul' {a : WithTop α} : ⊤ * a = if a = 0 then 0 else ⊤ := by\n  induction a using WithTop.recTopCoe <;> simp [mul_def] <;> rfl\n#align with_top.top_mul' WithTop.top_mul'\n\n/- warning: with_top.top_mul -> WithTop.top_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α}, (Ne.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) -> (Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)) a) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α}, (Ne.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) -> (Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)) a) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_top.top_mul WithTop.top_mulₓ'. -/\n@[simp]\ntheorem top_mul {a : WithTop α} (h : a ≠ 0) : ⊤ * a = ⊤ := by rw [top_mul', if_neg h]\n#align with_top.top_mul WithTop.top_mul\n\n/- warning: with_top.top_mul_top -> WithTop.top_mul_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α], Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α], Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))\nCase conversion may be inaccurate. Consider using '#align with_top.top_mul_top WithTop.top_mul_topₓ'. -/\n@[simp]\ntheorem top_mul_top : (⊤ * ⊤ : WithTop α) = ⊤ :=\n  top_mul top_ne_zero\n#align with_top.top_mul_top WithTop.top_mul_top\n\n/- warning: with_top.mul_eq_top_iff -> WithTop.mul_eq_top_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (Or (And (Ne.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))) (Eq.{succ u1} (WithTop.{u1} α) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))) (And (Eq.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (Ne.{succ u1} (WithTop.{u1} α) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (Or (And (Ne.{succ u1} (WithTop.{u1} α) a (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2)))) (Eq.{succ u1} (WithTop.{u1} α) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))) (And (Eq.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (Ne.{succ u1} (WithTop.{u1} α) b (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_eq_top_iff WithTop.mul_eq_top_iffₓ'. -/\ntheorem mul_eq_top_iff {a b : WithTop α} : a * b = ⊤ ↔ a ≠ 0 ∧ b = ⊤ ∨ a = ⊤ ∧ b ≠ 0 :=\n  by\n  rw [mul_def, ite_eq_iff, ← none_eq_top, Option.map₂_eq_none_iff]\n  have ha : a = 0 → a ≠ none := fun h => h.symm ▸ zero_ne_top\n  have hb : b = 0 → b ≠ none := fun h => h.symm ▸ zero_ne_top\n  tauto\n#align with_top.mul_eq_top_iff WithTop.mul_eq_top_iff\n\n/- warning: with_top.mul_lt_top' -> WithTop.mul_lt_top' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_4) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_4) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_4) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_4) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_lt_top' WithTop.mul_lt_top'ₓ'. -/\ntheorem mul_lt_top' [LT α] {a b : WithTop α} (ha : a < ⊤) (hb : b < ⊤) : a * b < ⊤ :=\n  by\n  rw [WithTop.lt_top_iff_ne_top] at *\n  simp only [Ne.def, mul_eq_top_iff, *, and_false_iff, false_and_iff, false_or_iff, not_false_iff]\n#align with_top.mul_lt_top' WithTop.mul_lt_top'\n\n/- warning: with_top.mul_lt_top -> WithTop.mul_lt_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (Ne.{succ u1} (WithTop.{u1} α) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (Ne.{succ u1} (WithTop.{u1} α) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_lt_top WithTop.mul_lt_topₓ'. -/\ntheorem mul_lt_top [LT α] {a b : WithTop α} (ha : a ≠ ⊤) (hb : b ≠ ⊤) : a * b < ⊤ :=\n  mul_lt_top' (WithTop.lt_top_iff_ne_top.2 ha) (WithTop.lt_top_iff_ne_top.2 hb)\n#align with_top.mul_lt_top WithTop.mul_lt_top\n\ninstance [NoZeroDivisors α] : NoZeroDivisors (WithTop α) :=\n  by\n  refine' ⟨fun a b h₁ => Decidable.by_contradiction fun h₂ => _⟩\n  rw [mul_def, if_neg h₂] at h₁\n  rcases Option.mem_map₂_iff.1 h₁ with ⟨a, b, rfl : _ = _, rfl : _ = _, hab⟩\n  exact h₂ ((eq_zero_or_eq_zero_of_mul_eq_zero hab).imp (congr_arg some) (congr_arg some))\n\nend Mul\n\nsection MulZeroClass\n\nvariable [MulZeroClass α]\n\n/- warning: with_top.coe_mul -> WithTop.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {a : α} {b : α}, Eq.{succ u1} (WithTop.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) (MulZeroClass.toHasMul.{u1} α _inst_2)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {a : α} {b : α}, Eq.{succ u1} (WithTop.{u1} α) (WithTop.some.{u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toZero.{u1} α _inst_2) (MulZeroClass.toMul.{u1} α _inst_2)))) (WithTop.some.{u1} α a) (WithTop.some.{u1} α b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_mul WithTop.coe_mulₓ'. -/\n@[simp, norm_cast]\ntheorem coe_mul {a b : α} : (↑(a * b) : WithTop α) = a * b :=\n  Decidable.byCases (fun this : a = 0 => by simp [this]) fun ha =>\n    Decidable.byCases (fun this : b = 0 => by simp [this]) fun hb => by simp [*, mul_def]\n#align with_top.coe_mul WithTop.coe_mul\n\n/- warning: with_top.mul_coe -> WithTop.mul_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {b : α}, (Ne.{succ u1} α b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α _inst_2))))) -> (forall {a : WithTop.{u1} α}, Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) (MulZeroClass.toHasMul.{u1} α _inst_2)))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b)) (Option.bind.{u1, u1} α α a (fun (a : α) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (Option.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (Option.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (Option.{u1} α) (coeOption.{u1} α))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α _inst_2)) a b))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {b : α}, (Ne.{succ u1} α b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MulZeroClass.toZero.{u1} α _inst_2)))) -> (forall {a : WithTop.{u1} α}, Eq.{succ u1} (WithTop.{u1} α) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toZero.{u1} α _inst_2) (MulZeroClass.toMul.{u1} α _inst_2)))) a (WithTop.some.{u1} α b)) (Option.bind.{u1, u1} α α a (fun (a : α) => Option.some.{u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α _inst_2)) a b))))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_coe WithTop.mul_coeₓ'. -/\ntheorem mul_coe {b : α} (hb : b ≠ 0) : ∀ {a : WithTop α}, a * b = a.bind fun a : α => ↑(a * b)\n  | none =>\n    show (if (⊤ : WithTop α) = 0 ∨ (b : WithTop α) = 0 then 0 else ⊤ : WithTop α) = ⊤ by simp [hb]\n  | some a => show ↑a * ↑b = ↑(a * b) from coe_mul.symm\n#align with_top.mul_coe WithTop.mul_coe\n\n/- warning: with_top.untop'_zero_mul -> WithTop.untop'_zero_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] (a : WithTop.{u1} α) (b : WithTop.{u1} α), Eq.{succ u1} α (WithTop.untop'.{u1} α (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α _inst_2)))) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} α) (WithTop.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) (MulZeroClass.toHasMul.{u1} α _inst_2)))) a b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α _inst_2)) (WithTop.untop'.{u1} α (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α _inst_2)))) a) (WithTop.untop'.{u1} α (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α _inst_2)))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] (a : WithTop.{u1} α) (b : WithTop.{u1} α), Eq.{succ u1} α (WithTop.untop'.{u1} α (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MulZeroClass.toZero.{u1} α _inst_2))) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHMul.{u1} (WithTop.{u1} α) (MulZeroClass.toMul.{u1} (WithTop.{u1} α) (WithTop.instMulZeroClassWithTop.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toZero.{u1} α _inst_2) (MulZeroClass.toMul.{u1} α _inst_2)))) a b)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α _inst_2)) (WithTop.untop'.{u1} α (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MulZeroClass.toZero.{u1} α _inst_2))) a) (WithTop.untop'.{u1} α (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MulZeroClass.toZero.{u1} α _inst_2))) b))\nCase conversion may be inaccurate. Consider using '#align with_top.untop'_zero_mul WithTop.untop'_zero_mulₓ'. -/\n@[simp]\ntheorem untop'_zero_mul (a b : WithTop α) : (a * b).untop' 0 = a.untop' 0 * b.untop' 0 :=\n  by\n  by_cases ha : a = 0;\n  · rw [ha, MulZeroClass.zero_mul, ← coe_zero, untop'_coe, MulZeroClass.zero_mul]\n  by_cases hb : b = 0;\n  · rw [hb, MulZeroClass.mul_zero, ← coe_zero, untop'_coe, MulZeroClass.mul_zero]\n  induction a using WithTop.recTopCoe; · rw [top_mul hb, untop'_top, MulZeroClass.zero_mul]\n  induction b using WithTop.recTopCoe; · rw [mul_top ha, untop'_top, MulZeroClass.mul_zero]\n  rw [← coe_mul, untop'_coe, untop'_coe, untop'_coe]\n#align with_top.untop'_zero_mul WithTop.untop'_zero_mul\n\nend MulZeroClass\n\n/-- `nontrivial α` is needed here as otherwise we have `1 * ⊤ = ⊤` but also `0 * ⊤ = 0`. -/\ninstance [MulZeroOneClass α] [Nontrivial α] : MulZeroOneClass (WithTop α) :=\n  { WithTop.mulZeroClass with\n    mul := (· * ·)\n    one := 1\n    zero := 0\n    one_mul := fun a =>\n      match a with\n      | ⊤ => mul_top (mt coe_eq_coe.1 one_ne_zero)\n      | (a : α) => by rw [← coe_one, ← coe_mul, one_mul]\n    mul_one := fun a =>\n      match a with\n      | ⊤ => top_mul (mt coe_eq_coe.1 one_ne_zero)\n      | (a : α) => by rw [← coe_one, ← coe_mul, mul_one] }\n\n/- warning: monoid_with_zero_hom.with_top_map -> MonoidWithZeroHom.withTopMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_2 : MulZeroOneClass.{u1} R] [_inst_3 : DecidableEq.{succ u1} R] [_inst_4 : Nontrivial.{u1} R] [_inst_5 : MulZeroOneClass.{u2} S] [_inst_6 : DecidableEq.{succ u2} S] [_inst_7 : Nontrivial.{u2} S] (f : MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5), (Function.Injective.{succ u1, succ u2} R S (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5) (fun (_x : MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5) => R -> S) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} R S _inst_2 _inst_5) f)) -> (MonoidWithZeroHom.{u1, u2} (WithTop.{u1} R) (WithTop.{u2} S) (WithTop.mulZeroOneClass.{u1} R (fun (a : R) (b : R) => _inst_3 a b) _inst_2 _inst_4) (WithTop.mulZeroOneClass.{u2} S (fun (a : S) (b : S) => _inst_6 a b) _inst_5 _inst_7))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_2 : MulZeroOneClass.{u1} R] [_inst_3 : DecidableEq.{succ u1} R] [_inst_4 : Nontrivial.{u1} R] [_inst_5 : MulZeroOneClass.{u2} S] [_inst_6 : DecidableEq.{succ u2} S] [_inst_7 : Nontrivial.{u2} S] (f : MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5), (Function.Injective.{succ u1, succ u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5) R S (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R _inst_2)) (MulOneClass.toMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S _inst_5)) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5) R S (MulZeroOneClass.toMulOneClass.{u1} R _inst_2) (MulZeroOneClass.toMulOneClass.{u2} S _inst_5) (MonoidWithZeroHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (MonoidWithZeroHom.{u1, u2} R S _inst_2 _inst_5) R S _inst_2 _inst_5 (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u2} R S _inst_2 _inst_5)))) f)) -> (MonoidWithZeroHom.{u1, u2} (WithTop.{u1} R) (WithTop.{u2} S) (WithTop.instMulZeroOneClassWithTop.{u1} R (fun (a : R) (b : R) => _inst_3 a b) _inst_2 _inst_4) (WithTop.instMulZeroOneClassWithTop.{u2} S (fun (a : S) (b : S) => _inst_6 a b) _inst_5 _inst_7))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.with_top_map MonoidWithZeroHom.withTopMapₓ'. -/\n/-- A version of `with_top.map` for `monoid_with_zero_hom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def MonoidWithZeroHom.withTopMap {R S : Type _} [MulZeroOneClass R] [DecidableEq R]\n    [Nontrivial R] [MulZeroOneClass S] [DecidableEq S] [Nontrivial S] (f : R →*₀ S)\n    (hf : Function.Injective f) : WithTop R →*₀ WithTop S :=\n  { f.toZeroHom.withTop_map,\n    f.toMonoidHom.toOneHom.withTop_map with\n    toFun := WithTop.map f\n    map_mul' := fun x y =>\n      by\n      have : ∀ z, map f z = 0 ↔ z = 0 := fun z =>\n        (Option.map_injective hf).eq_iff' f.to_zero_hom.with_top_map.map_zero\n      rcases Decidable.eq_or_ne x 0 with (rfl | hx)\n      · simp\n      rcases Decidable.eq_or_ne y 0 with (rfl | hy)\n      · simp\n      induction x using WithTop.recTopCoe\n      · simp [hy, this]\n      induction y using WithTop.recTopCoe\n      · have : (f x : WithTop S) ≠ 0 := by simpa [hf.eq_iff' (map_zero f)] using hx\n        simp [hx, this]\n      simp only [← coe_mul, map_coe, map_mul] }\n#align monoid_with_zero_hom.with_top_map MonoidWithZeroHom.withTopMap\n\ninstance [SemigroupWithZero α] [NoZeroDivisors α] : SemigroupWithZero (WithTop α) :=\n  { WithTop.mulZeroClass with\n    mul := (· * ·)\n    zero := 0\n    mul_assoc := fun a b c => by\n      rcases eq_or_ne a 0 with (rfl | ha); · simp only [MulZeroClass.zero_mul]\n      rcases eq_or_ne b 0 with (rfl | hb);\n      · simp only [MulZeroClass.zero_mul, MulZeroClass.mul_zero]\n      rcases eq_or_ne c 0 with (rfl | hc); · simp only [MulZeroClass.mul_zero]\n      induction a using WithTop.recTopCoe; · simp [hb, hc]\n      induction b using WithTop.recTopCoe; · simp [ha, hc]\n      induction c using WithTop.recTopCoe; · simp [ha, hb]\n      simp only [← coe_mul, mul_assoc] }\n\ninstance [MonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] : MonoidWithZero (WithTop α) :=\n  { WithTop.mulZeroOneClass, WithTop.semigroupWithZero with }\n\ninstance [CommMonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] :\n    CommMonoidWithZero (WithTop α) :=\n  { WithTop.monoidWithZero with\n    mul := (· * ·)\n    zero := 0\n    mul_comm := fun a b => by\n      simp only [or_comm', mul_def, mul_comm, @Option.map₂_comm _ _ _ _ a b _ mul_comm] }\n\nvariable [CanonicallyOrderedCommSemiring α]\n\nprivate theorem distrib' (a b c : WithTop α) : (a + b) * c = a * c + b * c :=\n  by\n  induction c using WithTop.recTopCoe\n  · by_cases ha : a = 0 <;> simp [ha]\n  · by_cases hc : c = 0\n    · simp [hc]\n    simp only [mul_coe hc]\n    cases a <;> cases b\n    repeat' first |rfl|exact congr_arg some (add_mul _ _ _)\n#align with_top.distrib' with_top.distrib'\n\n/-- This instance requires `canonically_ordered_comm_semiring` as it is the smallest class\nthat derives from both `non_assoc_non_unital_semiring` and `canonically_ordered_add_monoid`, both\nof which are required for distributivity. -/\ninstance [Nontrivial α] : CommSemiring (WithTop α) :=\n  { WithTop.addCommMonoidWithOne,\n    WithTop.commMonoidWithZero with\n    right_distrib := distrib'\n    left_distrib := fun a b c =>\n      by\n      rw [mul_comm, distrib', mul_comm b, mul_comm c]\n      rfl }\n\ninstance [Nontrivial α] : CanonicallyOrderedCommSemiring (WithTop α) :=\n  { WithTop.commSemiring, WithTop.canonicallyOrderedAddMonoid, WithTop.noZeroDivisors with }\n\n/- warning: ring_hom.with_top_map -> RingHom.withTopMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_3 : CanonicallyOrderedCommSemiring.{u1} R] [_inst_4 : DecidableEq.{succ u1} R] [_inst_5 : Nontrivial.{u1} R] [_inst_6 : CanonicallyOrderedCommSemiring.{u2} S] [_inst_7 : DecidableEq.{succ u2} S] [_inst_8 : Nontrivial.{u2} S] (f : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))), (Function.Injective.{succ u1, succ u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) (fun (_x : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) f)) -> (RingHom.{u1, u2} (WithTop.{u1} R) (WithTop.{u2} S) (Semiring.toNonAssocSemiring.{u1} (WithTop.{u1} R) (OrderedSemiring.toSemiring.{u1} (WithTop.{u1} R) (OrderedCommSemiring.toOrderedSemiring.{u1} (WithTop.{u1} R) (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} (WithTop.{u1} R) (WithTop.canonicallyOrderedCommSemiring.{u1} R (fun (a : R) (b : R) => _inst_4 a b) _inst_3 _inst_5))))) (Semiring.toNonAssocSemiring.{u2} (WithTop.{u2} S) (OrderedSemiring.toSemiring.{u2} (WithTop.{u2} S) (OrderedCommSemiring.toOrderedSemiring.{u2} (WithTop.{u2} S) (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} (WithTop.{u2} S) (WithTop.canonicallyOrderedCommSemiring.{u2} S (fun (a : S) (b : S) => _inst_7 a b) _inst_6 _inst_8))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_3 : CanonicallyOrderedCommSemiring.{u1} R] [_inst_4 : DecidableEq.{succ u1} R] [_inst_5 : Nontrivial.{u1} R] [_inst_6 : CanonicallyOrderedCommSemiring.{u2} S] [_inst_7 : DecidableEq.{succ u2} S] [_inst_8 : Nontrivial.{u2} S] (f : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))), (Function.Injective.{succ u1, succ u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))))) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6))))) R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6)))) (RingHom.instRingHomClassRingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_3)))) (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} S _inst_6)))))))) f)) -> (RingHom.{u1, u2} (WithTop.{u1} R) (WithTop.{u2} S) (Semiring.toNonAssocSemiring.{u1} (WithTop.{u1} R) (OrderedSemiring.toSemiring.{u1} (WithTop.{u1} R) (OrderedCommSemiring.toOrderedSemiring.{u1} (WithTop.{u1} R) (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} (WithTop.{u1} R) (WithTop.instCanonicallyOrderedCommSemiringWithTop.{u1} R (fun (a : R) (b : R) => _inst_4 a b) _inst_3 _inst_5))))) (Semiring.toNonAssocSemiring.{u2} (WithTop.{u2} S) (OrderedSemiring.toSemiring.{u2} (WithTop.{u2} S) (OrderedCommSemiring.toOrderedSemiring.{u2} (WithTop.{u2} S) (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} (WithTop.{u2} S) (WithTop.instCanonicallyOrderedCommSemiringWithTop.{u2} S (fun (a : S) (b : S) => _inst_7 a b) _inst_6 _inst_8))))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.with_top_map RingHom.withTopMapₓ'. -/\n/-- A version of `with_top.map` for `ring_hom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def RingHom.withTopMap {R S : Type _} [CanonicallyOrderedCommSemiring R] [DecidableEq R]\n    [Nontrivial R] [CanonicallyOrderedCommSemiring S] [DecidableEq S] [Nontrivial S] (f : R →+* S)\n    (hf : Function.Injective f) : WithTop R →+* WithTop S :=\n  { f.toMonoidWithZeroHom.withTop_map hf, f.toAddMonoidHom.withTop_map with toFun := WithTop.map f }\n#align ring_hom.with_top_map RingHom.withTopMap\n\nend WithTop\n\nnamespace WithBot\n\nvariable [DecidableEq α]\n\nsection Mul\n\nvariable [Zero α] [Mul α]\n\ninstance : MulZeroClass (WithBot α) :=\n  WithTop.mulZeroClass\n\n/- warning: with_bot.mul_def -> WithBot.mul_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithBot.{u1} α) (Or (Eq.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2))))) (Eq.{succ u1} (WithBot.{u1} α) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2)))))) (Or.decidable (Eq.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2))))) (Eq.{succ u1} (WithBot.{u1} α) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2))))) (Option.decidableEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2))))) (Option.decidableEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2)))))) (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2)))) (Option.map₂.{u1, u1, u1} α α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_3)) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithBot.{u1} α) (Or (Eq.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2)))) (Eq.{succ u1} (WithBot.{u1} α) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2))))) (instDecidableOr (Eq.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2)))) (Eq.{succ u1} (WithBot.{u1} α) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2)))) (WithBot.instDecidableEqWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2)))) (WithBot.instDecidableEqWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2))))) (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2))) (Option.map₂.{u1, u1, u1} α α α (fun (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.3008 : α) (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.3010 : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_3) x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.3008 x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.3010) a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.mul_def WithBot.mul_defₓ'. -/\ntheorem mul_def {a b : WithBot α} : a * b = if a = 0 ∨ b = 0 then 0 else Option.map₂ (· * ·) a b :=\n  rfl\n#align with_bot.mul_def WithBot.mul_def\n\n/- warning: with_bot.mul_bot -> WithBot.mul_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α}, (Ne.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2))))) -> (Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α}, (Ne.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2)))) -> (Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_bot.mul_bot WithBot.mul_botₓ'. -/\n@[simp]\ntheorem mul_bot {a : WithBot α} (h : a ≠ 0) : a * ⊥ = ⊥ :=\n  WithTop.mul_top h\n#align with_bot.mul_bot WithBot.mul_bot\n\n/- warning: with_bot.bot_mul -> WithBot.bot_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α}, (Ne.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2))))) -> (Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) a) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α}, (Ne.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2)))) -> (Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) a) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_mul WithBot.bot_mulₓ'. -/\n@[simp]\ntheorem bot_mul {a : WithBot α} (h : a ≠ 0) : ⊥ * a = ⊥ :=\n  WithTop.top_mul h\n#align with_bot.bot_mul WithBot.bot_mul\n\n/- warning: with_bot.bot_mul_bot -> WithBot.bot_mul_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α], Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α], Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_mul_bot WithBot.bot_mul_botₓ'. -/\n@[simp]\ntheorem bot_mul_bot : (⊥ * ⊥ : WithBot α) = ⊥ :=\n  WithTop.top_mul_top\n#align with_bot.bot_mul_bot WithBot.bot_mul_bot\n\n/- warning: with_bot.mul_eq_bot_iff -> WithBot.mul_eq_bot_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (Or (And (Ne.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2))))) (Eq.{succ u1} (WithBot.{u1} α) b (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)))) (And (Eq.{succ u1} (WithBot.{u1} α) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (Ne.{succ u1} (WithBot.{u1} α) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (OfNat.mk.{u1} (WithBot.{u1} α) 0 (Zero.zero.{u1} (WithBot.{u1} α) (WithBot.hasZero.{u1} α _inst_2)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))) (Or (And (Ne.{succ u1} (WithBot.{u1} α) a (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2)))) (Eq.{succ u1} (WithBot.{u1} α) b (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)))) (And (Eq.{succ u1} (WithBot.{u1} α) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))) (Ne.{succ u1} (WithBot.{u1} α) b (OfNat.ofNat.{u1} (WithBot.{u1} α) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} α) (WithBot.zero.{u1} α _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align with_bot.mul_eq_bot_iff WithBot.mul_eq_bot_iffₓ'. -/\ntheorem mul_eq_bot_iff {a b : WithBot α} : a * b = ⊥ ↔ a ≠ 0 ∧ b = ⊥ ∨ a = ⊥ ∧ b ≠ 0 :=\n  WithTop.mul_eq_top_iff\n#align with_bot.mul_eq_bot_iff WithBot.mul_eq_bot_iff\n\n/- warning: with_bot.bot_lt_mul' -> WithBot.bot_lt_mul' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) a) -> (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) b) -> (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) a) -> (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) b) -> (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_mul' WithBot.bot_lt_mul'ₓ'. -/\ntheorem bot_lt_mul' [LT α] {a b : WithBot α} (ha : ⊥ < a) (hb : ⊥ < b) : ⊥ < a * b :=\n  @WithTop.mul_lt_top' αᵒᵈ _ _ _ _ _ _ ha hb\n#align with_bot.bot_lt_mul' WithBot.bot_lt_mul'\n\n/- warning: with_bot.bot_lt_mul -> WithBot.bot_lt_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, (Ne.{succ u1} (WithBot.{u1} α) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) -> (Ne.{succ u1} (WithBot.{u1} α) b (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) -> (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Zero.{u1} α] [_inst_3 : Mul.{u1} α] [_inst_4 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, (Ne.{succ u1} (WithBot.{u1} α) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))) -> (Ne.{succ u1} (WithBot.{u1} α) b (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))) -> (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_4) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) _inst_2 _inst_3))) a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_mul WithBot.bot_lt_mulₓ'. -/\ntheorem bot_lt_mul [LT α] {a b : WithBot α} (ha : a ≠ ⊥) (hb : b ≠ ⊥) : ⊥ < a * b :=\n  @WithTop.mul_lt_top αᵒᵈ _ _ _ _ _ _ ha hb\n#align with_bot.bot_lt_mul WithBot.bot_lt_mul\n\nend Mul\n\nsection MulZeroClass\n\nvariable [MulZeroClass α]\n\n/- warning: with_bot.coe_mul -> WithBot.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {a : α} {b : α}, Eq.{succ u1} (WithBot.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) (MulZeroClass.toHasMul.{u1} α _inst_2)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {a : α} {b : α}, Eq.{succ u1} (WithBot.{u1} α) (WithBot.some.{u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toZero.{u1} α _inst_2) (MulZeroClass.toMul.{u1} α _inst_2)))) (WithBot.some.{u1} α a) (WithBot.some.{u1} α b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_mul WithBot.coe_mulₓ'. -/\n@[norm_cast]\ntheorem coe_mul {a b : α} : (↑(a * b) : WithBot α) = a * b :=\n  WithTop.coe_mul\n#align with_bot.coe_mul WithBot.coe_mul\n\n/- warning: with_bot.mul_coe -> WithBot.mul_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {b : α}, (Ne.{succ u1} α b (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α _inst_2))))) -> (forall {a : WithBot.{u1} α}, Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} α) (WithBot.mulZeroClass.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} α _inst_2) (MulZeroClass.toHasMul.{u1} α _inst_2)))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b)) (Option.bind.{u1, u1} α α a (fun (a : α) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (Option.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (Option.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (Option.{u1} α) (coeOption.{u1} α))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α _inst_2)) a b))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : MulZeroClass.{u1} α] {b : α}, (Ne.{succ u1} α b (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MulZeroClass.toZero.{u1} α _inst_2)))) -> (forall {a : WithBot.{u1} α}, Eq.{succ u1} (WithBot.{u1} α) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHMul.{u1} (WithBot.{u1} α) (MulZeroClass.toMul.{u1} (WithBot.{u1} α) (WithBot.instMulZeroClassWithBot.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (MulZeroClass.toZero.{u1} α _inst_2) (MulZeroClass.toMul.{u1} α _inst_2)))) a (WithBot.some.{u1} α b)) (Option.bind.{u1, u1} α α a (fun (a : α) => Option.some.{u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α _inst_2)) a b))))\nCase conversion may be inaccurate. Consider using '#align with_bot.mul_coe WithBot.mul_coeₓ'. -/\ntheorem mul_coe {b : α} (hb : b ≠ 0) {a : WithBot α} : a * b = a.bind fun a : α => ↑(a * b) :=\n  WithTop.mul_coe hb\n#align with_bot.mul_coe WithBot.mul_coe\n\nend MulZeroClass\n\n/-- `nontrivial α` is needed here as otherwise we have `1 * ⊥ = ⊥` but also `= 0 * ⊥ = 0`. -/\ninstance [MulZeroOneClass α] [Nontrivial α] : MulZeroOneClass (WithBot α) :=\n  WithTop.mulZeroOneClass\n\ninstance [MulZeroClass α] [NoZeroDivisors α] : NoZeroDivisors (WithBot α) :=\n  WithTop.noZeroDivisors\n\ninstance [SemigroupWithZero α] [NoZeroDivisors α] : SemigroupWithZero (WithBot α) :=\n  WithTop.semigroupWithZero\n\ninstance [MonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] : MonoidWithZero (WithBot α) :=\n  WithTop.monoidWithZero\n\ninstance [CommMonoidWithZero α] [NoZeroDivisors α] [Nontrivial α] :\n    CommMonoidWithZero (WithBot α) :=\n  WithTop.commMonoidWithZero\n\ninstance [CanonicallyOrderedCommSemiring α] [Nontrivial α] : CommSemiring (WithBot α) :=\n  WithTop.commSemiring\n\ninstance [MulZeroClass α] [Preorder α] [PosMulMono α] : PosMulMono (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with (rfl | x0'); · simp\n    lift x to α;\n    · rintro ⟨rfl⟩\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction a using WithBot.recBotCoe; · simp_rw [mul_bot x0', bot_le]\n    induction b using WithBot.recBotCoe; · exact absurd h (bot_lt_coe a).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact mul_le_mul_of_nonneg_left h x0⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosMono α] : MulPosMono (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with (rfl | x0'); · simp\n    lift x to α;\n    · rintro ⟨rfl⟩\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction a using WithBot.recBotCoe; · simp_rw [bot_mul x0', bot_le]\n    induction b using WithBot.recBotCoe; · exact absurd h (bot_lt_coe a).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact mul_le_mul_of_nonneg_right h x0⟩\n\ninstance [MulZeroClass α] [Preorder α] [PosMulStrictMono α] : PosMulStrictMono (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk]\n    lift x to α using x0.ne_bot\n    induction b using WithBot.recBotCoe; · exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe; · simp_rw [mul_bot x0.ne.symm, ← coe_mul, bot_lt_coe]\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact mul_lt_mul_of_pos_left h x0⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosStrictMono α] : MulPosStrictMono (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk]\n    lift x to α using x0.ne_bot\n    induction b using WithBot.recBotCoe; · exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe; · simp_rw [bot_mul x0.ne.symm, ← coe_mul, bot_lt_coe]\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact mul_lt_mul_of_pos_right h x0⟩\n\ninstance [MulZeroClass α] [Preorder α] [PosMulReflectLT α] : PosMulReflectLT (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with (rfl | x0'); · simpa using h\n    lift x to α;\n    · rintro ⟨rfl⟩\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction b using WithBot.recBotCoe;\n    · rw [mul_bot x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe; · exact WithBot.bot_lt_coe _\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact lt_of_mul_lt_mul_left h x0⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosReflectLT α] : MulPosReflectLT (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with (rfl | x0'); · simpa using h\n    lift x to α;\n    · rintro ⟨rfl⟩\n      exact (WithBot.bot_lt_coe (0 : α)).not_le x0\n    induction b using WithBot.recBotCoe;\n    · rw [bot_mul x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe; · exact WithBot.bot_lt_coe _\n    simp only [← coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact lt_of_mul_lt_mul_right h x0⟩\n\ninstance [MulZeroClass α] [Preorder α] [PosMulMonoRev α] : PosMulMonoRev (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk] at h\n    lift x to α using x0.ne_bot\n    induction a using WithBot.recBotCoe; · exact bot_le\n    induction b using WithBot.recBotCoe\n    · rw [mul_bot x0.ne.symm, ← coe_mul] at h\n      exact absurd h (bot_lt_coe (x * a)).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact le_of_mul_le_mul_left h x0⟩\n\ninstance [MulZeroClass α] [Preorder α] [MulPosMonoRev α] : MulPosMonoRev (WithBot α) :=\n  ⟨by\n    rintro ⟨x, x0⟩ a b h; simp only [Subtype.coe_mk] at h\n    lift x to α using x0.ne_bot\n    induction a using WithBot.recBotCoe; · exact bot_le\n    induction b using WithBot.recBotCoe\n    · rw [bot_mul x0.ne.symm, ← coe_mul] at h\n      exact absurd h (bot_lt_coe (a * x)).not_le\n    simp only [← coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact le_of_mul_le_mul_right h x0⟩\n\ninstance [CanonicallyOrderedCommSemiring α] [Nontrivial α] : OrderedCommSemiring (WithBot α) :=\n  { WithBot.zeroLeOneClass, WithBot.orderedAddCommMonoid,\n    WithBot.commSemiring with\n    mul_le_mul_of_nonneg_left := fun _ _ _ => mul_le_mul_of_nonneg_left\n    mul_le_mul_of_nonneg_right := fun _ _ _ => mul_le_mul_of_nonneg_right }\n\nend WithBot\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Ring/WithTop.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4741822424990138}}
{"text": "/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Ashvni Narayanan\n\n! This file was ported from Lean 3 source module number_theory.function_field\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.Group.TypeTags\nimport Mathbin.FieldTheory.Ratfunc\nimport Mathbin.RingTheory.DedekindDomain.IntegralClosure\nimport Mathbin.RingTheory.IntegrallyClosed\nimport Mathbin.Topology.Algebra.ValuedField\n\n/-!\n# Function fields\n\nThis file defines a function field and the ring of integers corresponding to it.\n\n## Main definitions\n - `function_field Fq F` states that `F` is a function field over the (finite) field `Fq`,\n   i.e. it is a finite extension of the field of rational functions in one variable over `Fq`.\n - `function_field.ring_of_integers` defines the ring of integers corresponding to a function field\n    as the integral closure of `Fq[X]` in the function field.\n - `function_field.infty_valuation` : The place at infinity on `Fq(t)` is the nonarchimedean\n    valuation on `Fq(t)` with uniformizer `1/t`.\n -  `function_field.Fqt_infty` : The completion `Fq((t⁻¹))`  of `Fq(t)` with respect to the\n    valuation at infinity.\n\n## Implementation notes\nThe definitions that involve a field of fractions choose a canonical field of fractions,\nbut are independent of that choice. We also omit assumptions like `finite Fq` or\n`is_scalar_tower Fq[X] (fraction_ring Fq[X]) F` in definitions,\nadding them back in lemmas when they are needed.\n\n## References\n* [D. Marcus, *Number Fields*][marcus1977number]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n* [P. Samuel, *Algebraic Theory of Numbers*][samuel1970algebraic]\n\n## Tags\nfunction field, ring of integers\n-/\n\n\nnoncomputable section\n\nopen nonZeroDivisors Polynomial DiscreteValuation\n\nvariable (Fq F : Type) [Field Fq] [Field F]\n\n/-- `F` is a function field over the finite field `Fq` if it is a finite\nextension of the field of rational functions in one variable over `Fq`.\n\nNote that `F` can be a function field over multiple, non-isomorphic, `Fq`.\n-/\nabbrev FunctionField [Algebra (Ratfunc Fq) F] : Prop :=\n  FiniteDimensional (Ratfunc Fq) F\n#align function_field FunctionField\n\n/-- `F` is a function field over `Fq` iff it is a finite extension of `Fq(t)`. -/\nprotected theorem functionField_iff (Fqt : Type _) [Field Fqt] [Algebra Fq[X] Fqt]\n    [IsFractionRing Fq[X] Fqt] [Algebra (Ratfunc Fq) F] [Algebra Fqt F] [Algebra Fq[X] F]\n    [IsScalarTower Fq[X] Fqt F] [IsScalarTower Fq[X] (Ratfunc Fq) F] :\n    FunctionField Fq F ↔ FiniteDimensional Fqt F :=\n  by\n  let e := IsLocalization.algEquiv Fq[X]⁰ (Ratfunc Fq) Fqt\n  have : ∀ (c) (x : F), e c • x = c • x := by\n    intro c x\n    rw [Algebra.smul_def, Algebra.smul_def]\n    congr\n    refine' congr_fun _ c\n    refine' IsLocalization.ext (nonZeroDivisors Fq[X]) _ _ _ _ _ _ _ <;> intros <;>\n      simp only [AlgEquiv.map_one, RingHom.map_one, AlgEquiv.map_mul, RingHom.map_mul,\n        AlgEquiv.commutes, ← IsScalarTower.algebraMap_apply]\n  constructor <;> intro h <;> skip\n  · let b := FiniteDimensional.finBasis (Ratfunc Fq) F\n    exact FiniteDimensional.of_fintype_basis (b.map_coeffs e this)\n  · let b := FiniteDimensional.finBasis Fqt F\n    refine' FiniteDimensional.of_fintype_basis (b.map_coeffs e.symm _)\n    intro c x\n    convert(this (e.symm c) x).symm\n    simp only [e.apply_symm_apply]\n#align function_field_iff functionField_iff\n\ntheorem algebraMap_injective [Algebra Fq[X] F] [Algebra (Ratfunc Fq) F]\n    [IsScalarTower Fq[X] (Ratfunc Fq) F] : Function.Injective ⇑(algebraMap Fq[X] F) :=\n  by\n  rw [IsScalarTower.algebraMap_eq Fq[X] (Ratfunc Fq) F]\n  exact\n    Function.Injective.comp (algebraMap (Ratfunc Fq) F).Injective\n      (IsFractionRing.injective Fq[X] (Ratfunc Fq))\n#align algebra_map_injective algebraMap_injective\n\nnamespace FunctionField\n\n/-- The function field analogue of `number_field.ring_of_integers`:\n`function_field.ring_of_integers Fq Fqt F` is the integral closure of `Fq[t]` in `F`.\n\nWe don't actually assume `F` is a function field over `Fq` in the definition,\nonly when proving its properties.\n-/\ndef ringOfIntegers [Algebra Fq[X] F] :=\n  integralClosure Fq[X] F\n#align function_field.ring_of_integers FunctionField.ringOfIntegers\n\nnamespace RingOfIntegers\n\nvariable [Algebra Fq[X] F]\n\ninstance : IsDomain (ringOfIntegers Fq F) :=\n  (ringOfIntegers Fq F).IsDomain\n\ninstance : IsIntegralClosure (ringOfIntegers Fq F) Fq[X] F :=\n  integralClosure.isIntegralClosure _ _\n\nvariable [Algebra (Ratfunc Fq) F] [IsScalarTower Fq[X] (Ratfunc Fq) F]\n\ntheorem algebraMap_injective : Function.Injective ⇑(algebraMap Fq[X] (ringOfIntegers Fq F)) :=\n  by\n  have hinj : Function.Injective ⇑(algebraMap Fq[X] F) :=\n    by\n    rw [IsScalarTower.algebraMap_eq Fq[X] (Ratfunc Fq) F]\n    exact\n      Function.Injective.comp (algebraMap (Ratfunc Fq) F).Injective\n        (IsFractionRing.injective Fq[X] (Ratfunc Fq))\n  rw [injective_iff_map_eq_zero (algebraMap Fq[X] ↥(ring_of_integers Fq F))]\n  intro p hp\n  rw [← Subtype.coe_inj, Subalgebra.coe_zero] at hp\n  rw [injective_iff_map_eq_zero (algebraMap Fq[X] F)] at hinj\n  exact hinj p hp\n#align function_field.ring_of_integers.algebra_map_injective FunctionField.ringOfIntegers.algebraMap_injective\n\ntheorem not_isField : ¬IsField (ringOfIntegers Fq F) := by\n  simpa [←\n    (IsIntegralClosure.isIntegral_algebra Fq[X] F).isField_iff_isField\n      (algebraMap_injective Fq F)] using\n    Polynomial.not_isField Fq\n#align function_field.ring_of_integers.not_is_field FunctionField.ringOfIntegers.not_isField\n\nvariable [FunctionField Fq F]\n\ninstance : IsFractionRing (ringOfIntegers Fq F) F :=\n  integralClosure.isFractionRing_of_finite_extension (Ratfunc Fq) F\n\ninstance : IsIntegrallyClosed (ringOfIntegers Fq F) :=\n  integralClosure.isIntegrallyClosedOfFiniteExtension (Ratfunc Fq)\n\ninstance [IsSeparable (Ratfunc Fq) F] : IsNoetherian Fq[X] (ringOfIntegers Fq F) :=\n  IsIntegralClosure.isNoetherian _ (Ratfunc Fq) F _\n\ninstance [IsSeparable (Ratfunc Fq) F] : IsDedekindDomain (ringOfIntegers Fq F) :=\n  IsIntegralClosure.isDedekindDomain Fq[X] (Ratfunc Fq) F _\n\nend RingOfIntegers\n\n/-! ### The place at infinity on Fq(t) -/\n\n\nsection InftyValuation\n\nvariable [DecidableEq (Ratfunc Fq)]\n\n/-- The valuation at infinity is the nonarchimedean valuation on `Fq(t)` with uniformizer `1/t`.\nExplicitly, if `f/g ∈ Fq(t)` is a nonzero quotient of polynomials, its valuation at infinity is\n`multiplicative.of_add(degree(f) - degree(g))`. -/\ndef inftyValuationDef (r : Ratfunc Fq) : ℤₘ₀ :=\n  if r = 0 then 0 else Multiplicative.ofAdd r.intDegree\n#align function_field.infty_valuation_def FunctionField.inftyValuationDef\n\ntheorem InftyValuation.map_zero' : inftyValuationDef Fq 0 = 0 :=\n  if_pos rfl\n#align function_field.infty_valuation.map_zero' FunctionField.InftyValuation.map_zero'\n\ntheorem InftyValuation.map_one' : inftyValuationDef Fq 1 = 1 :=\n  (if_neg one_ne_zero).trans <| by rw [Ratfunc.intDegree_one, ofAdd_zero, WithZero.coe_one]\n#align function_field.infty_valuation.map_one' FunctionField.InftyValuation.map_one'\n\ntheorem InftyValuation.map_mul' (x y : Ratfunc Fq) :\n    inftyValuationDef Fq (x * y) = inftyValuationDef Fq x * inftyValuationDef Fq y :=\n  by\n  rw [infty_valuation_def, infty_valuation_def, infty_valuation_def]\n  by_cases hx : x = 0\n  · rw [hx, MulZeroClass.zero_mul, if_pos (Eq.refl _), MulZeroClass.zero_mul]\n  · by_cases hy : y = 0\n    · rw [hy, MulZeroClass.mul_zero, if_pos (Eq.refl _), MulZeroClass.mul_zero]\n    ·\n      rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), ← WithZero.coe_mul, WithZero.coe_inj, ←\n        ofAdd_add, Ratfunc.intDegree_mul hx hy]\n#align function_field.infty_valuation.map_mul' FunctionField.InftyValuation.map_mul'\n\ntheorem InftyValuation.map_add_le_max' (x y : Ratfunc Fq) :\n    inftyValuationDef Fq (x + y) ≤ max (inftyValuationDef Fq x) (inftyValuationDef Fq y) :=\n  by\n  by_cases hx : x = 0\n  · rw [hx, zero_add]\n    conv_rhs => rw [infty_valuation_def, if_pos (Eq.refl _)]\n    rw [max_eq_right (WithZero.zero_le (infty_valuation_def Fq y))]\n    exact le_refl _\n  · by_cases hy : y = 0\n    · rw [hy, add_zero]\n      conv_rhs => rw [max_comm, infty_valuation_def, if_pos (Eq.refl _)]\n      rw [max_eq_right (WithZero.zero_le (infty_valuation_def Fq x))]\n      exact le_refl _\n    · by_cases hxy : x + y = 0\n      · rw [infty_valuation_def, if_pos hxy]\n        exact zero_le'\n      · rw [infty_valuation_def, infty_valuation_def, infty_valuation_def, if_neg hx, if_neg hy,\n          if_neg hxy]\n        rw [le_max_iff, WithZero.coe_le_coe, Multiplicative.ofAdd_le, WithZero.coe_le_coe,\n          Multiplicative.ofAdd_le, ← le_max_iff]\n        exact Ratfunc.intDegree_add_le hy hxy\n#align function_field.infty_valuation.map_add_le_max' FunctionField.InftyValuation.map_add_le_max'\n\n@[simp]\ntheorem infty_valuation_of_nonzero {x : Ratfunc Fq} (hx : x ≠ 0) :\n    inftyValuationDef Fq x = Multiplicative.ofAdd x.intDegree := by\n  rw [infty_valuation_def, if_neg hx]\n#align function_field.infty_valuation_of_nonzero FunctionField.infty_valuation_of_nonzero\n\n/-- The valuation at infinity on `Fq(t)`. -/\ndef inftyValuation : Valuation (Ratfunc Fq) ℤₘ₀\n    where\n  toFun := inftyValuationDef Fq\n  map_zero' := InftyValuation.map_zero' Fq\n  map_one' := InftyValuation.map_one' Fq\n  map_mul' := InftyValuation.map_mul' Fq\n  map_add_le_max' := InftyValuation.map_add_le_max' Fq\n#align function_field.infty_valuation FunctionField.inftyValuation\n\n@[simp]\ntheorem inftyValuation_apply {x : Ratfunc Fq} : inftyValuation Fq x = inftyValuationDef Fq x :=\n  rfl\n#align function_field.infty_valuation_apply FunctionField.inftyValuation_apply\n\n@[simp]\ntheorem inftyValuation.c {k : Fq} (hk : k ≠ 0) :\n    inftyValuationDef Fq (Ratfunc.c k) = Multiplicative.ofAdd (0 : ℤ) :=\n  by\n  have hCk : Ratfunc.c k ≠ 0 := (map_ne_zero _).mpr hk\n  rw [infty_valuation_def, if_neg hCk, Ratfunc.intDegree_c]\n#align function_field.infty_valuation.C FunctionField.inftyValuation.c\n\n@[simp]\ntheorem inftyValuation.x : inftyValuationDef Fq Ratfunc.x = Multiplicative.ofAdd (1 : ℤ) := by\n  rw [infty_valuation_def, if_neg Ratfunc.x_ne_zero, Ratfunc.intDegree_x]\n#align function_field.infty_valuation.X FunctionField.inftyValuation.x\n\n@[simp]\ntheorem inftyValuation.polynomial {p : Fq[X]} (hp : p ≠ 0) :\n    inftyValuationDef Fq (algebraMap Fq[X] (Ratfunc Fq) p) =\n      Multiplicative.ofAdd (p.natDegree : ℤ) :=\n  by\n  have hp' : algebraMap Fq[X] (Ratfunc Fq) p ≠ 0 :=\n    by\n    rw [Ne.def, Ratfunc.algebraMap_eq_zero_iff]\n    exact hp\n  rw [infty_valuation_def, if_neg hp', Ratfunc.intDegree_polynomial]\n#align function_field.infty_valuation.polynomial FunctionField.inftyValuation.polynomial\n\n/-- The valued field `Fq(t)` with the valuation at infinity. -/\ndef inftyValuedFqt : Valued (Ratfunc Fq) ℤₘ₀ :=\n  Valued.mk' <| inftyValuation Fq\n#align function_field.infty_valued_Fqt FunctionField.inftyValuedFqt\n\ntheorem inftyValuedFqt.def {x : Ratfunc Fq} :\n    @Valued.v (Ratfunc Fq) _ _ _ (inftyValuedFqt Fq) x = inftyValuationDef Fq x :=\n  rfl\n#align function_field.infty_valued_Fqt.def FunctionField.inftyValuedFqt.def\n\n/-- The completion `Fq((t⁻¹))`  of `Fq(t)` with respect to the valuation at infinity. -/\ndef FqtInfty :=\n  @UniformSpace.Completion (Ratfunc Fq) <| (inftyValuedFqt Fq).toUniformSpace\n#align function_field.Fqt_infty FunctionField.FqtInfty\n\ninstance : Field (FqtInfty Fq) :=\n  letI := infty_valued_Fqt Fq\n  UniformSpace.Completion.field\n\ninstance : Inhabited (FqtInfty Fq) :=\n  ⟨(0 : FqtInfty Fq)⟩\n\n/-- The valuation at infinity on `k(t)` extends to a valuation on `Fqt_infty`. -/\ninstance valuedFqtInfty : Valued (FqtInfty Fq) ℤₘ₀ :=\n  @Valued.valuedCompletion _ _ _ _ (inftyValuedFqt Fq)\n#align function_field.valued_Fqt_infty FunctionField.valuedFqtInfty\n\ntheorem valuedFqtInfty.def {x : FqtInfty Fq} :\n    Valued.v x = @Valued.extension (Ratfunc Fq) _ _ _ (inftyValuedFqt Fq) x :=\n  rfl\n#align function_field.valued_Fqt_infty.def FunctionField.valuedFqtInfty.def\n\nend InftyValuation\n\nend FunctionField\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/NumberTheory/FunctionField.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548782017745, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.47417035601195334}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module data.option.n_ary\n! leanprover-community/mathlib commit 995b47e555f1b6297c7cf16855f1023e355219fb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Option.Basic\n\n/-!\n# Binary map of options\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the binary map of `option`. This is mostly useful to define pointwise operations\non intervals.\n\n## Main declarations\n\n* `option.map₂`: Binary map of options.\n\n## Notes\n\nThis file is very similar to `data.set.n_ary`, `data.finset.n_ary` and `order.filter.n_ary`. Please\nkeep them in sync.\n\nWe do not define `option.map₃` as its only purpose so far would be to prove properties of\n`option.map₂` and casing already fulfills this task.\n-/\n\n\nopen Function\n\nnamespace Option\n\nvariable {α α' β β' γ γ' δ δ' ε ε' : Type _} {f : α → β → γ} {a : Option α} {b : Option β}\n  {c : Option γ}\n\n#print Option.map₂ /-\n/-- The image of a binary function `f : α → β → γ` as a function `option α → option β → option γ`.\nMathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/\ndef map₂ (f : α → β → γ) (a : Option α) (b : Option β) : Option γ :=\n  a.bind fun a => b.map <| f a\n#align option.map₂ Option.map₂\n-/\n\n/- warning: option.map₂_def -> Option.map₂_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} (f : α -> β -> γ) (a : Option.{u1} α) (b : Option.{u1} β), Eq.{succ u1} (Option.{u1} γ) (Option.map₂.{u1, u1, u1} α β γ f a b) (Seq.seq.{u1, u1} Option.{u1} (Applicative.toHasSeq.{u1, u1} Option.{u1} (Monad.toApplicative.{u1, u1} Option.{u1} Option.monad.{u1})) β γ (Functor.map.{u1, u1} Option.{u1} (Traversable.toFunctor.{u1} Option.{u1} Option.traversable.{u1}) α (β -> γ) f a) b)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u1}} {γ : Type.{u1}} (f : α -> β -> γ) (a : Option.{u1} α) (b : Option.{u1} β), Eq.{succ u1} (Option.{u1} γ) (Option.map₂.{u1, u1, u1} α β γ f a b) (Seq.seq.{u1, u1} Option.{u1} (Applicative.toSeq.{u1, u1} Option.{u1} (Alternative.toApplicative.{u1, u1} Option.{u1} instAlternativeOption.{u1})) β γ (Functor.map.{u1, u1} Option.{u1} instFunctorOption.{u1} α (β -> γ) f a) (fun (x._@.Mathlib.Data.Option.NAry._hyg.142 : Unit) => b))\nCase conversion may be inaccurate. Consider using '#align option.map₂_def Option.map₂_defₓ'. -/\n/-- `option.map₂` in terms of monadic operations. Note that this can't be taken as the definition\nbecause of the lack of universe polymorphism. -/\ntheorem map₂_def {α β γ : Type _} (f : α → β → γ) (a : Option α) (b : Option β) :\n    map₂ f a b = f <$> a <*> b := by cases a <;> rfl\n#align option.map₂_def Option.map₂_def\n\n/- warning: option.map₂_some_some -> Option.map₂_some_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (a : α) (b : β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f (Option.some.{u1} α a) (Option.some.{u2} β b)) (Option.some.{u3} γ (f a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} (f : α -> β -> γ) (a : α) (b : β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u2, u1, u3} α β γ f (Option.some.{u2} α a) (Option.some.{u1} β b)) (Option.some.{u3} γ (f a b))\nCase conversion may be inaccurate. Consider using '#align option.map₂_some_some Option.map₂_some_someₓ'. -/\n@[simp]\ntheorem map₂_some_some (f : α → β → γ) (a : α) (b : β) : map₂ f (some a) (some b) = some (f a b) :=\n  rfl\n#align option.map₂_some_some Option.map₂_some_some\n\n/- warning: option.map₂_coe_coe -> Option.map₂_coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (a : α) (b : β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (Option.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (Option.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (Option.{u1} α) (coeOption.{u1} α))) a) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) β (Option.{u2} β) (HasLiftT.mk.{succ u2, succ u2} β (Option.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} β (Option.{u2} β) (coeOption.{u2} β))) b)) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) γ (Option.{u3} γ) (HasLiftT.mk.{succ u3, succ u3} γ (Option.{u3} γ) (CoeTCₓ.coe.{succ u3, succ u3} γ (Option.{u3} γ) (coeOption.{u3} γ))) (f a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} (f : α -> β -> γ) (a : α) (b : β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u2, u1, u3} α β γ f (Option.some.{u2} α a) (Option.some.{u1} β b)) (Option.some.{u3} γ (f a b))\nCase conversion may be inaccurate. Consider using '#align option.map₂_coe_coe Option.map₂_coe_coeₓ'. -/\ntheorem map₂_coe_coe (f : α → β → γ) (a : α) (b : β) : map₂ f a b = f a b :=\n  rfl\n#align option.map₂_coe_coe Option.map₂_coe_coe\n\n/- warning: option.map₂_none_left -> Option.map₂_none_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (b : Option.{u2} β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f (Option.none.{u1} α) b) (Option.none.{u3} γ)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} (f : α -> β -> γ) (b : Option.{u3} β), Eq.{succ u2} (Option.{u2} γ) (Option.map₂.{u1, u3, u2} α β γ f (Option.none.{u1} α) b) (Option.none.{u2} γ)\nCase conversion may be inaccurate. Consider using '#align option.map₂_none_left Option.map₂_none_leftₓ'. -/\n@[simp]\ntheorem map₂_none_left (f : α → β → γ) (b : Option β) : map₂ f none b = none :=\n  rfl\n#align option.map₂_none_left Option.map₂_none_left\n\n/- warning: option.map₂_none_right -> Option.map₂_none_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (a : Option.{u1} α), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f a (Option.none.{u2} β)) (Option.none.{u3} γ)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} (f : α -> β -> γ) (a : Option.{u3} α), Eq.{succ u2} (Option.{u2} γ) (Option.map₂.{u3, u1, u2} α β γ f a (Option.none.{u1} β)) (Option.none.{u2} γ)\nCase conversion may be inaccurate. Consider using '#align option.map₂_none_right Option.map₂_none_rightₓ'. -/\n@[simp]\ntheorem map₂_none_right (f : α → β → γ) (a : Option α) : map₂ f a none = none := by cases a <;> rfl\n#align option.map₂_none_right Option.map₂_none_right\n\n/- warning: option.map₂_coe_left -> Option.map₂_coe_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (a : α) (b : Option.{u2} β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (Option.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (Option.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (Option.{u1} α) (coeOption.{u1} α))) a) b) (Option.map.{u2, u3} β γ (fun (b : β) => f a b) b)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} (f : α -> β -> γ) (a : α) (b : Option.{u3} β), Eq.{succ u2} (Option.{u2} γ) (Option.map₂.{u1, u3, u2} α β γ f (Option.some.{u1} α a) b) (Option.map.{u3, u2} β γ (fun (b : β) => f a b) b)\nCase conversion may be inaccurate. Consider using '#align option.map₂_coe_left Option.map₂_coe_leftₓ'. -/\n@[simp]\ntheorem map₂_coe_left (f : α → β → γ) (a : α) (b : Option β) : map₂ f a b = b.map fun b => f a b :=\n  rfl\n#align option.map₂_coe_left Option.map₂_coe_left\n\n/- warning: option.map₂_coe_right -> Option.map₂_coe_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (a : Option.{u1} α) (b : β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f a ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) β (Option.{u2} β) (HasLiftT.mk.{succ u2, succ u2} β (Option.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} β (Option.{u2} β) (coeOption.{u2} β))) b)) (Option.map.{u1, u3} α γ (fun (a : α) => f a b) a)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} (f : α -> β -> γ) (a : Option.{u3} α) (b : β), Eq.{succ u2} (Option.{u2} γ) (Option.map₂.{u3, u1, u2} α β γ f a (Option.some.{u1} β b)) (Option.map.{u3, u2} α γ (fun (a : α) => f a b) a)\nCase conversion may be inaccurate. Consider using '#align option.map₂_coe_right Option.map₂_coe_rightₓ'. -/\n@[simp]\ntheorem map₂_coe_right (f : α → β → γ) (a : Option α) (b : β) : map₂ f a b = a.map fun a => f a b :=\n  rfl\n#align option.map₂_coe_right Option.map₂_coe_right\n\n/- warning: option.mem_map₂_iff -> Option.mem_map₂_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u2} β} {c : γ}, Iff (Membership.Mem.{u3, u3} γ (Option.{u3} γ) (Option.hasMem.{u3} γ) c (Option.map₂.{u1, u2, u3} α β γ f a b)) (Exists.{succ u1} α (fun (a' : α) => Exists.{succ u2} β (fun (b' : β) => And (Membership.Mem.{u1, u1} α (Option.{u1} α) (Option.hasMem.{u1} α) a' a) (And (Membership.Mem.{u2, u2} β (Option.{u2} β) (Option.hasMem.{u2} β) b' b) (Eq.{succ u3} γ (f a' b') c)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} {f : α -> β -> γ} {a : Option.{u2} α} {b : Option.{u1} β} {c : γ}, Iff (Membership.mem.{u3, u3} γ (Option.{u3} γ) (Option.instMembershipOption.{u3} γ) c (Option.map₂.{u2, u1, u3} α β γ f a b)) (Exists.{succ u2} α (fun (a' : α) => Exists.{succ u1} β (fun (b' : β) => And (Membership.mem.{u2, u2} α (Option.{u2} α) (Option.instMembershipOption.{u2} α) a' a) (And (Membership.mem.{u1, u1} β (Option.{u1} β) (Option.instMembershipOption.{u1} β) b' b) (Eq.{succ u3} γ (f a' b') c)))))\nCase conversion may be inaccurate. Consider using '#align option.mem_map₂_iff Option.mem_map₂_iffₓ'. -/\n@[simp]\ntheorem mem_map₂_iff {c : γ} : c ∈ map₂ f a b ↔ ∃ a' b', a' ∈ a ∧ b' ∈ b ∧ f a' b' = c := by\n  simp [map₂]\n#align option.mem_map₂_iff Option.mem_map₂_iff\n\n/- warning: option.map₂_eq_none_iff -> Option.map₂_eq_none_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u2} β}, Iff (Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f a b) (Option.none.{u3} γ)) (Or (Eq.{succ u1} (Option.{u1} α) a (Option.none.{u1} α)) (Eq.{succ u2} (Option.{u2} β) b (Option.none.{u2} β)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} {f : α -> β -> γ} {a : Option.{u2} α} {b : Option.{u1} β}, Iff (Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u2, u1, u3} α β γ f a b) (Option.none.{u3} γ)) (Or (Eq.{succ u2} (Option.{u2} α) a (Option.none.{u2} α)) (Eq.{succ u1} (Option.{u1} β) b (Option.none.{u1} β)))\nCase conversion may be inaccurate. Consider using '#align option.map₂_eq_none_iff Option.map₂_eq_none_iffₓ'. -/\n@[simp]\ntheorem map₂_eq_none_iff : map₂ f a b = none ↔ a = none ∨ b = none := by\n  cases a <;> cases b <;> simp\n#align option.map₂_eq_none_iff Option.map₂_eq_none_iff\n\n/- warning: option.map₂_swap -> Option.map₂_swap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (a : Option.{u1} α) (b : Option.{u2} β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f a b) (Option.map₂.{u2, u1, u3} β α γ (fun (a : β) (b : α) => f b a) b a)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (f : α -> β -> γ) (a : Option.{u3} α) (b : Option.{u2} β), Eq.{succ u1} (Option.{u1} γ) (Option.map₂.{u3, u2, u1} α β γ f a b) (Option.map₂.{u2, u3, u1} β α γ (fun (a : β) (b : α) => f b a) b a)\nCase conversion may be inaccurate. Consider using '#align option.map₂_swap Option.map₂_swapₓ'. -/\ntheorem map₂_swap (f : α → β → γ) (a : Option α) (b : Option β) :\n    map₂ f a b = map₂ (fun a b => f b a) b a := by cases a <;> cases b <;> rfl\n#align option.map₂_swap Option.map₂_swap\n\n/- warning: option.map_map₂ -> Option.map_map₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {a : Option.{u1} α} {b : Option.{u2} β} (f : α -> β -> γ) (g : γ -> δ), Eq.{succ u4} (Option.{u4} δ) (Option.map.{u3, u4} γ δ g (Option.map₂.{u1, u2, u3} α β γ f a b)) (Option.map₂.{u1, u2, u4} α β δ (fun (a : α) (b : β) => g (f a b)) a b)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} {δ : Option.{u2} α} {a : Option.{u1} β} {b : Type.{u4}} (f : α -> β -> γ) (g : γ -> b), Eq.{succ u4} (Option.{u4} b) (Option.map.{u3, u4} γ b g (Option.map₂.{u2, u1, u3} α β γ f δ a)) (Option.map₂.{u2, u1, u4} α β b (fun (a : α) (b : β) => g (f a b)) δ a)\nCase conversion may be inaccurate. Consider using '#align option.map_map₂ Option.map_map₂ₓ'. -/\ntheorem map_map₂ (f : α → β → γ) (g : γ → δ) :\n    (map₂ f a b).map g = map₂ (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl\n#align option.map_map₂ Option.map_map₂\n\n/- warning: option.map₂_map_left -> Option.map₂_map_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {a : Option.{u1} α} {b : Option.{u2} β} (f : γ -> β -> δ) (g : α -> γ), Eq.{succ u4} (Option.{u4} δ) (Option.map₂.{u3, u2, u4} γ β δ f (Option.map.{u1, u3} α γ g a) b) (Option.map₂.{u1, u2, u4} α β δ (fun (a : α) (b : β) => f (g a) b) a b)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Option.{u1} α} {a : Option.{u2} β} {b : Type.{u4}} (f : γ -> β -> b) (g : α -> γ), Eq.{succ u4} (Option.{u4} b) (Option.map₂.{u3, u2, u4} γ β b f (Option.map.{u1, u3} α γ g δ) a) (Option.map₂.{u1, u2, u4} α β b (fun (a : α) (b : β) => f (g a) b) δ a)\nCase conversion may be inaccurate. Consider using '#align option.map₂_map_left Option.map₂_map_leftₓ'. -/\ntheorem map₂_map_left (f : γ → β → δ) (g : α → γ) :\n    map₂ f (a.map g) b = map₂ (fun a b => f (g a) b) a b := by cases a <;> rfl\n#align option.map₂_map_left Option.map₂_map_left\n\n/- warning: option.map₂_map_right -> Option.map₂_map_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {a : Option.{u1} α} {b : Option.{u2} β} (f : α -> γ -> δ) (g : β -> γ), Eq.{succ u4} (Option.{u4} δ) (Option.map₂.{u1, u3, u4} α γ δ f a (Option.map.{u2, u3} β γ g b)) (Option.map₂.{u1, u2, u4} α β δ (fun (a : α) (b : β) => f a (g b)) a b)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} {δ : Option.{u3} α} {a : Option.{u1} β} {b : Type.{u4}} (f : α -> γ -> b) (g : β -> γ), Eq.{succ u4} (Option.{u4} b) (Option.map₂.{u3, u2, u4} α γ b f δ (Option.map.{u1, u2} β γ g a)) (Option.map₂.{u3, u1, u4} α β b (fun (a : α) (b : β) => f a (g b)) δ a)\nCase conversion may be inaccurate. Consider using '#align option.map₂_map_right Option.map₂_map_rightₓ'. -/\ntheorem map₂_map_right (f : α → γ → δ) (g : β → γ) :\n    map₂ f a (b.map g) = map₂ (fun a b => f a (g b)) a b := by cases b <;> rfl\n#align option.map₂_map_right Option.map₂_map_right\n\n/- warning: option.map₂_curry -> Option.map₂_curry is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : (Prod.{u1, u2} α β) -> γ) (a : Option.{u1} α) (b : Option.{u2} β), Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ (Function.curry.{u1, u2, u3} α β γ f) a b) (Option.map.{max u1 u2, u3} (Prod.{u1, u2} α β) γ f (Option.map₂.{u1, u2, max u1 u2} α β (Prod.{u1, u2} α β) (Prod.mk.{u1, u2} α β) a b))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (f : (Prod.{u3, u2} α β) -> γ) (a : Option.{u3} α) (b : Option.{u2} β), Eq.{succ u1} (Option.{u1} γ) (Option.map₂.{u3, u2, u1} α β γ (Function.curry.{u3, u2, u1} α β γ f) a b) (Option.map.{max u3 u2, u1} (Prod.{u3, u2} α β) γ f (Option.map₂.{u3, u2, max u3 u2} α β (Prod.{u3, u2} α β) (Prod.mk.{u3, u2} α β) a b))\nCase conversion may be inaccurate. Consider using '#align option.map₂_curry Option.map₂_curryₓ'. -/\n@[simp]\ntheorem map₂_curry (f : α × β → γ) (a : Option α) (b : Option β) :\n    map₂ (curry f) a b = Option.map f (map₂ Prod.mk a b) :=\n  (map_map₂ _ _).symm\n#align option.map₂_curry Option.map₂_curry\n\n/- warning: option.map_uncurry -> Option.map_uncurry is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β -> γ) (x : Option.{max u1 u2} (Prod.{u1, u2} α β)), Eq.{succ u3} (Option.{u3} γ) (Option.map.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Function.uncurry.{u1, u2, u3} α β γ f) x) (Option.map₂.{u1, u2, u3} α β γ f (Option.map.{max u1 u2, u1} (Prod.{u1, u2} α β) α (Prod.fst.{u1, u2} α β) x) (Option.map.{max u1 u2, u2} (Prod.{u1, u2} α β) β (Prod.snd.{u1, u2} α β) x))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} (f : α -> β -> γ) (x : Option.{max u3 u2} (Prod.{u2, u3} α β)), Eq.{succ u1} (Option.{u1} γ) (Option.map.{max u3 u2, u1} (Prod.{u2, u3} α β) γ (Function.uncurry.{u2, u3, u1} α β γ f) x) (Option.map₂.{u2, u3, u1} α β γ f (Option.map.{max u3 u2, u2} (Prod.{u2, u3} α β) α (Prod.fst.{u2, u3} α β) x) (Option.map.{max u3 u2, u3} (Prod.{u2, u3} α β) β (Prod.snd.{u2, u3} α β) x))\nCase conversion may be inaccurate. Consider using '#align option.map_uncurry Option.map_uncurryₓ'. -/\n@[simp]\ntheorem map_uncurry (f : α → β → γ) (x : Option (α × β)) :\n    x.map (uncurry f) = map₂ f (x.map Prod.fst) (x.map Prod.snd) := by cases x <;> rfl\n#align option.map_uncurry Option.map_uncurry\n\n/-!\n### Algebraic replacement rules\n\nA collection of lemmas to transfer associativity, commutativity, distributivity, ... of operations\nto the associativity, commutativity, distributivity, ... of `option.map₂` of those operations.\nThe proof pattern is `map₂_lemma operation_lemma`. For example, `map₂_comm mul_comm` proves that\n`map₂ (*) a b = map₂ (*) g f` in a `comm_semigroup`.\n-/\n\n\n/- warning: option.map₂_assoc -> Option.map₂_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {ε : Type.{u5}} {ε' : Type.{u6}} {a : Option.{u1} α} {b : Option.{u2} β} {c : Option.{u3} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f' : α -> ε' -> ε} {g' : β -> γ -> ε'}, (forall (a : α) (b : β) (c : γ), Eq.{succ u5} ε (f (g a b) c) (f' a (g' b c))) -> (Eq.{succ u5} (Option.{u5} ε) (Option.map₂.{u4, u3, u5} δ γ ε f (Option.map₂.{u1, u2, u4} α β δ g a b) c) (Option.map₂.{u1, u6, u5} α ε' ε f' a (Option.map₂.{u2, u3, u6} β γ ε' g' b c)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} {δ : Option.{u2} α} {ε : Option.{u1} β} {ε' : Option.{u3} γ} {a : Type.{u6}} {b : Type.{u5}} {c : Type.{u4}} {f : a -> γ -> b} {g : α -> β -> a} {f' : α -> c -> b} {g' : β -> γ -> c}, (forall (a : α) (b_1 : β) (c : γ), Eq.{succ u5} b (f (g a b_1) c) (f' a (g' b_1 c))) -> (Eq.{succ u5} (Option.{u5} b) (Option.map₂.{u6, u3, u5} a γ b f (Option.map₂.{u2, u1, u6} α β a g δ ε) ε') (Option.map₂.{u2, u4, u5} α c b f' δ (Option.map₂.{u1, u3, u4} β γ c g' ε ε')))\nCase conversion may be inaccurate. Consider using '#align option.map₂_assoc Option.map₂_assocₓ'. -/\ntheorem map₂_assoc {f : δ → γ → ε} {g : α → β → δ} {f' : α → ε' → ε} {g' : β → γ → ε'}\n    (h_assoc : ∀ a b c, f (g a b) c = f' a (g' b c)) :\n    map₂ f (map₂ g a b) c = map₂ f' a (map₂ g' b c) := by\n  cases a <;> cases b <;> cases c <;> simp [h_assoc]\n#align option.map₂_assoc Option.map₂_assoc\n\n/- warning: option.map₂_comm -> Option.map₂_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u2} β} {g : β -> α -> γ}, (forall (a : α) (b : β), Eq.{succ u3} γ (f a b) (g b a)) -> (Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u1, u2, u3} α β γ f a b) (Option.map₂.{u2, u1, u3} β α γ g b a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} {f : α -> β -> γ} {a : Option.{u2} α} {b : Option.{u1} β} {g : β -> α -> γ}, (forall (a : α) (b : β), Eq.{succ u3} γ (f a b) (g b a)) -> (Eq.{succ u3} (Option.{u3} γ) (Option.map₂.{u2, u1, u3} α β γ f a b) (Option.map₂.{u1, u2, u3} β α γ g b a))\nCase conversion may be inaccurate. Consider using '#align option.map₂_comm Option.map₂_commₓ'. -/\ntheorem map₂_comm {g : β → α → γ} (h_comm : ∀ a b, f a b = g b a) : map₂ f a b = map₂ g b a := by\n  cases a <;> cases b <;> simp [h_comm]\n#align option.map₂_comm Option.map₂_comm\n\n/- warning: option.map₂_left_comm -> Option.map₂_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {δ' : Type.{u5}} {ε : Type.{u6}} {a : Option.{u1} α} {b : Option.{u2} β} {c : Option.{u3} γ} {f : α -> δ -> ε} {g : β -> γ -> δ} {f' : α -> γ -> δ'} {g' : β -> δ' -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u6} ε (f a (g b c)) (g' b (f' a c))) -> (Eq.{succ u6} (Option.{u6} ε) (Option.map₂.{u1, u4, u6} α δ ε f a (Option.map₂.{u2, u3, u4} β γ δ g b c)) (Option.map₂.{u2, u5, u6} β δ' ε g' b (Option.map₂.{u1, u3, u5} α γ δ' f' a c)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} {δ : Option.{u3} α} {δ' : Option.{u2} β} {ε : Option.{u1} γ} {a : Type.{u6}} {b : Type.{u5}} {c : Type.{u4}} {f : α -> a -> b} {g : β -> γ -> a} {f' : α -> γ -> c} {g' : β -> c -> b}, (forall (a : α) (b_1 : β) (c : γ), Eq.{succ u5} b (f a (g b_1 c)) (g' b_1 (f' a c))) -> (Eq.{succ u5} (Option.{u5} b) (Option.map₂.{u3, u6, u5} α a b f δ (Option.map₂.{u2, u1, u6} β γ a g δ' ε)) (Option.map₂.{u2, u4, u5} β c b g' δ' (Option.map₂.{u3, u1, u4} α γ c f' δ ε)))\nCase conversion may be inaccurate. Consider using '#align option.map₂_left_comm Option.map₂_left_commₓ'. -/\ntheorem map₂_left_comm {f : α → δ → ε} {g : β → γ → δ} {f' : α → γ → δ'} {g' : β → δ' → ε}\n    (h_left_comm : ∀ a b c, f a (g b c) = g' b (f' a c)) :\n    map₂ f a (map₂ g b c) = map₂ g' b (map₂ f' a c) := by\n  cases a <;> cases b <;> cases c <;> simp [h_left_comm]\n#align option.map₂_left_comm Option.map₂_left_comm\n\n/- warning: option.map₂_right_comm -> Option.map₂_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {δ' : Type.{u5}} {ε : Type.{u6}} {a : Option.{u1} α} {b : Option.{u2} β} {c : Option.{u3} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f' : α -> γ -> δ'} {g' : δ' -> β -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u6} ε (f (g a b) c) (g' (f' a c) b)) -> (Eq.{succ u6} (Option.{u6} ε) (Option.map₂.{u4, u3, u6} δ γ ε f (Option.map₂.{u1, u2, u4} α β δ g a b) c) (Option.map₂.{u5, u2, u6} δ' β ε g' (Option.map₂.{u1, u3, u5} α γ δ' f' a c) b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} {δ : Option.{u2} α} {δ' : Option.{u1} β} {ε : Option.{u3} γ} {a : Type.{u6}} {b : Type.{u5}} {c : Type.{u4}} {f : a -> γ -> b} {g : α -> β -> a} {f' : α -> γ -> c} {g' : c -> β -> b}, (forall (a : α) (b_1 : β) (c : γ), Eq.{succ u5} b (f (g a b_1) c) (g' (f' a c) b_1)) -> (Eq.{succ u5} (Option.{u5} b) (Option.map₂.{u6, u3, u5} a γ b f (Option.map₂.{u2, u1, u6} α β a g δ δ') ε) (Option.map₂.{u4, u1, u5} c β b g' (Option.map₂.{u2, u3, u4} α γ c f' δ ε) δ'))\nCase conversion may be inaccurate. Consider using '#align option.map₂_right_comm Option.map₂_right_commₓ'. -/\ntheorem map₂_right_comm {f : δ → γ → ε} {g : α → β → δ} {f' : α → γ → δ'} {g' : δ' → β → ε}\n    (h_right_comm : ∀ a b c, f (g a b) c = g' (f' a c) b) :\n    map₂ f (map₂ g a b) c = map₂ g' (map₂ f' a c) b := by\n  cases a <;> cases b <;> cases c <;> simp [h_right_comm]\n#align option.map₂_right_comm Option.map₂_right_comm\n\n/- warning: option.map_map₂_distrib -> Option.map_map₂_distrib is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {β' : Type.{u4}} {γ : Type.{u5}} {δ : Type.{u6}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u3} β} {g : γ -> δ} {f' : α' -> β' -> δ} {g₁ : α -> α'} {g₂ : β -> β'}, (forall (a : α) (b : β), Eq.{succ u6} δ (g (f a b)) (f' (g₁ a) (g₂ b))) -> (Eq.{succ u6} (Option.{u6} δ) (Option.map.{u5, u6} γ δ g (Option.map₂.{u1, u3, u5} α β γ f a b)) (Option.map₂.{u2, u4, u6} α' β' δ f' (Option.map.{u1, u2} α α' g₁ a) (Option.map.{u3, u4} β β' g₂ b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {α' : Type.{u1}} {β : Type.{u3}} {β' : α -> α' -> β} {γ : Option.{u2} α} {δ : Option.{u1} α'} {f : Type.{u6}} {a : Type.{u5}} {b : Type.{u4}} {g : β -> f} {f' : a -> b -> f} {g₁ : α -> a} {g₂ : α' -> b}, (forall (a : α) (b : α'), Eq.{succ u6} f (g (β' a b)) (f' (g₁ a) (g₂ b))) -> (Eq.{succ u6} (Option.{u6} f) (Option.map.{u3, u6} β f g (Option.map₂.{u2, u1, u3} α α' β β' γ δ)) (Option.map₂.{u5, u4, u6} a b f f' (Option.map.{u2, u5} α a g₁ γ) (Option.map.{u1, u4} α' b g₂ δ)))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_distrib Option.map_map₂_distribₓ'. -/\ntheorem map_map₂_distrib {g : γ → δ} {f' : α' → β' → δ} {g₁ : α → α'} {g₂ : β → β'}\n    (h_distrib : ∀ a b, g (f a b) = f' (g₁ a) (g₂ b)) :\n    (map₂ f a b).map g = map₂ f' (a.map g₁) (b.map g₂) := by\n  cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map₂_distrib Option.map_map₂_distrib\n\n/-!\nThe following symmetric restatement are needed because unification has a hard time figuring all the\nfunctions if you symmetrize on the spot. This is also how the other n-ary APIs do it.\n-/\n\n\n/- warning: option.map_map₂_distrib_left -> Option.map_map₂_distrib_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u3} β} {g : γ -> δ} {f' : α' -> β -> δ} {g' : α -> α'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' (g' a) b)) -> (Eq.{succ u5} (Option.{u5} δ) (Option.map.{u4, u5} γ δ g (Option.map₂.{u1, u3, u4} α β γ f a b)) (Option.map₂.{u2, u3, u5} α' β δ f' (Option.map.{u1, u2} α α' g' a) b))\nbut is expected to have type\n  forall {α : Type.{u2}} {α' : Type.{u1}} {β : Type.{u3}} {γ : α -> α' -> β} {δ : Option.{u2} α} {f : Option.{u1} α'} {a : Type.{u5}} {b : Type.{u4}} {g : β -> a} {f' : b -> α' -> a} {g' : α -> b}, (forall (a_1 : α) (b : α'), Eq.{succ u5} a (g (γ a_1 b)) (f' (g' a_1) b)) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} β a g (Option.map₂.{u2, u1, u3} α α' β γ δ f)) (Option.map₂.{u4, u1, u5} b α' a f' (Option.map.{u2, u4} α b g' δ) f))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_distrib_left Option.map_map₂_distrib_leftₓ'. -/\n/-- Symmetric statement to `option.map₂_map_left_comm`. -/\ntheorem map_map₂_distrib_left {g : γ → δ} {f' : α' → β → δ} {g' : α → α'}\n    (h_distrib : ∀ a b, g (f a b) = f' (g' a) b) : (map₂ f a b).map g = map₂ f' (a.map g') b := by\n  cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map₂_distrib_left Option.map_map₂_distrib_left\n\n/- warning: option.map_map₂_distrib_right -> Option.map_map₂_distrib_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u2} β} {g : γ -> δ} {f' : α -> β' -> δ} {g' : β -> β'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' a (g' b))) -> (Eq.{succ u5} (Option.{u5} δ) (Option.map.{u4, u5} γ δ g (Option.map₂.{u1, u2, u4} α β γ f a b)) (Option.map₂.{u1, u3, u5} α β' δ f' a (Option.map.{u2, u3} β β' g' b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {β' : Type.{u3}} {γ : α -> β -> β'} {δ : Option.{u2} α} {f : Option.{u1} β} {a : Type.{u5}} {b : Type.{u4}} {g : β' -> a} {f' : α -> b -> a} {g' : β -> b}, (forall (a_1 : α) (b : β), Eq.{succ u5} a (g (γ a_1 b)) (f' a_1 (g' b))) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} β' a g (Option.map₂.{u2, u1, u3} α β β' γ δ f)) (Option.map₂.{u2, u4, u5} α b a f' δ (Option.map.{u1, u4} β b g' f)))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_distrib_right Option.map_map₂_distrib_rightₓ'. -/\n/-- Symmetric statement to `option.map_map₂_right_comm`. -/\ntheorem map_map₂_distrib_right {g : γ → δ} {f' : α → β' → δ} {g' : β → β'}\n    (h_distrib : ∀ a b, g (f a b) = f' a (g' b)) : (map₂ f a b).map g = map₂ f' a (b.map g') := by\n  cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map₂_distrib_right Option.map_map₂_distrib_right\n\n/- warning: option.map₂_map_left_comm -> Option.map₂_map_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {a : Option.{u1} α} {b : Option.{u3} β} {f : α' -> β -> γ} {g : α -> α'} {f' : α -> β -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f (g a) b) (g' (f' a b))) -> (Eq.{succ u4} (Option.{u4} γ) (Option.map₂.{u2, u3, u4} α' β γ f (Option.map.{u1, u2} α α' g a) b) (Option.map.{u5, u4} δ γ g' (Option.map₂.{u1, u3, u5} α β δ f' a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Option.{u1} α} {δ : Option.{u2} α'} {a : Type.{u5}} {b : Type.{u4}} {f : a -> α' -> β} {g : α -> a} {f' : α -> α' -> b} {g' : b -> β}, (forall (a : α) (b : α'), Eq.{succ u3} β (f (g a) b) (g' (f' a b))) -> (Eq.{succ u3} (Option.{u3} β) (Option.map₂.{u5, u2, u3} a α' β f (Option.map.{u1, u5} α a g γ) δ) (Option.map.{u4, u3} b β g' (Option.map₂.{u1, u2, u4} α α' b f' γ δ)))\nCase conversion may be inaccurate. Consider using '#align option.map₂_map_left_comm Option.map₂_map_left_commₓ'. -/\n/-- Symmetric statement to `option.map_map₂_distrib_left`. -/\ntheorem map₂_map_left_comm {f : α' → β → γ} {g : α → α'} {f' : α → β → δ} {g' : δ → γ}\n    (h_left_comm : ∀ a b, f (g a) b = g' (f' a b)) : map₂ f (a.map g) b = (map₂ f' a b).map g' := by\n  cases a <;> cases b <;> simp [h_left_comm]\n#align option.map₂_map_left_comm Option.map₂_map_left_comm\n\n/- warning: option.map_map₂_right_comm -> Option.map_map₂_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {a : Option.{u1} α} {b : Option.{u2} β} {f : α -> β' -> γ} {g : β -> β'} {f' : α -> β -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f a (g b)) (g' (f' a b))) -> (Eq.{succ u4} (Option.{u4} γ) (Option.map₂.{u1, u3, u4} α β' γ f a (Option.map.{u2, u3} β β' g b)) (Option.map.{u5, u4} δ γ g' (Option.map₂.{u1, u2, u5} α β δ f' a b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {β' : Type.{u3}} {γ : Option.{u2} α} {δ : Option.{u1} β} {a : Type.{u5}} {b : Type.{u4}} {f : α -> a -> β'} {g : β -> a} {f' : α -> β -> b} {g' : b -> β'}, (forall (a : α) (b : β), Eq.{succ u3} β' (f a (g b)) (g' (f' a b))) -> (Eq.{succ u3} (Option.{u3} β') (Option.map₂.{u2, u5, u3} α a β' f γ (Option.map.{u1, u5} β a g δ)) (Option.map.{u4, u3} b β' g' (Option.map₂.{u2, u1, u4} α β b f' γ δ)))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_right_comm Option.map_map₂_right_commₓ'. -/\n/-- Symmetric statement to `option.map_map₂_distrib_right`. -/\ntheorem map_map₂_right_comm {f : α → β' → γ} {g : β → β'} {f' : α → β → δ} {g' : δ → γ}\n    (h_right_comm : ∀ a b, f a (g b) = g' (f' a b)) : map₂ f a (b.map g) = (map₂ f' a b).map g' :=\n  by cases a <;> cases b <;> simp [h_right_comm]\n#align option.map_map₂_right_comm Option.map_map₂_right_comm\n\n/- warning: option.map_map₂_antidistrib -> Option.map_map₂_antidistrib is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {β' : Type.{u4}} {γ : Type.{u5}} {δ : Type.{u6}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u3} β} {g : γ -> δ} {f' : β' -> α' -> δ} {g₁ : β -> β'} {g₂ : α -> α'}, (forall (a : α) (b : β), Eq.{succ u6} δ (g (f a b)) (f' (g₁ b) (g₂ a))) -> (Eq.{succ u6} (Option.{u6} δ) (Option.map.{u5, u6} γ δ g (Option.map₂.{u1, u3, u5} α β γ f a b)) (Option.map₂.{u4, u2, u6} β' α' δ f' (Option.map.{u3, u4} β β' g₁ b) (Option.map.{u1, u2} α α' g₂ a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {α' : Type.{u1}} {β : Type.{u3}} {β' : α -> α' -> β} {γ : Option.{u2} α} {δ : Option.{u1} α'} {f : Type.{u6}} {a : Type.{u5}} {b : Type.{u4}} {g : β -> f} {f' : a -> b -> f} {g₁ : α' -> a} {g₂ : α -> b}, (forall (a : α) (b : α'), Eq.{succ u6} f (g (β' a b)) (f' (g₁ b) (g₂ a))) -> (Eq.{succ u6} (Option.{u6} f) (Option.map.{u3, u6} β f g (Option.map₂.{u2, u1, u3} α α' β β' γ δ)) (Option.map₂.{u5, u4, u6} a b f f' (Option.map.{u1, u5} α' a g₁ δ) (Option.map.{u2, u4} α b g₂ γ)))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_antidistrib Option.map_map₂_antidistribₓ'. -/\ntheorem map_map₂_antidistrib {g : γ → δ} {f' : β' → α' → δ} {g₁ : β → β'} {g₂ : α → α'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' (g₁ b) (g₂ a)) :\n    (map₂ f a b).map g = map₂ f' (b.map g₁) (a.map g₂) := by\n  cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map₂_antidistrib Option.map_map₂_antidistrib\n\n/- warning: option.map_map₂_antidistrib_left -> Option.map_map₂_antidistrib_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u2} β} {g : γ -> δ} {f' : β' -> α -> δ} {g' : β -> β'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' (g' b) a)) -> (Eq.{succ u5} (Option.{u5} δ) (Option.map.{u4, u5} γ δ g (Option.map₂.{u1, u2, u4} α β γ f a b)) (Option.map₂.{u3, u1, u5} β' α δ f' (Option.map.{u2, u3} β β' g' b) a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {β' : Type.{u3}} {γ : α -> β -> β'} {δ : Option.{u2} α} {f : Option.{u1} β} {a : Type.{u5}} {b : Type.{u4}} {g : β' -> a} {f' : b -> α -> a} {g' : β -> b}, (forall (a_1 : α) (b : β), Eq.{succ u5} a (g (γ a_1 b)) (f' (g' b) a_1)) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} β' a g (Option.map₂.{u2, u1, u3} α β β' γ δ f)) (Option.map₂.{u4, u2, u5} b α a f' (Option.map.{u1, u4} β b g' f) δ))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_antidistrib_left Option.map_map₂_antidistrib_leftₓ'. -/\n/-- Symmetric statement to `option.map₂_map_left_anticomm`. -/\ntheorem map_map₂_antidistrib_left {g : γ → δ} {f' : β' → α → δ} {g' : β → β'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' (g' b) a) : (map₂ f a b).map g = map₂ f' (b.map g') a :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map₂_antidistrib_left Option.map_map₂_antidistrib_left\n\n/- warning: option.map_map₂_antidistrib_right -> Option.map_map₂_antidistrib_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {f : α -> β -> γ} {a : Option.{u1} α} {b : Option.{u3} β} {g : γ -> δ} {f' : β -> α' -> δ} {g' : α -> α'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' b (g' a))) -> (Eq.{succ u5} (Option.{u5} δ) (Option.map.{u4, u5} γ δ g (Option.map₂.{u1, u3, u4} α β γ f a b)) (Option.map₂.{u3, u2, u5} β α' δ f' b (Option.map.{u1, u2} α α' g' a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {α' : Type.{u1}} {β : Type.{u3}} {γ : α -> α' -> β} {δ : Option.{u2} α} {f : Option.{u1} α'} {a : Type.{u5}} {b : Type.{u4}} {g : β -> a} {f' : α' -> b -> a} {g' : α -> b}, (forall (a_1 : α) (b : α'), Eq.{succ u5} a (g (γ a_1 b)) (f' b (g' a_1))) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} β a g (Option.map₂.{u2, u1, u3} α α' β γ δ f)) (Option.map₂.{u1, u4, u5} α' b a f' f (Option.map.{u2, u4} α b g' δ)))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_antidistrib_right Option.map_map₂_antidistrib_rightₓ'. -/\n/-- Symmetric statement to `option.map_map₂_right_anticomm`. -/\ntheorem map_map₂_antidistrib_right {g : γ → δ} {f' : β → α' → δ} {g' : α → α'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' b (g' a)) : (map₂ f a b).map g = map₂ f' b (a.map g') :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map₂_antidistrib_right Option.map_map₂_antidistrib_right\n\n/- warning: option.map₂_map_left_anticomm -> Option.map₂_map_left_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {a : Option.{u1} α} {b : Option.{u3} β} {f : α' -> β -> γ} {g : α -> α'} {f' : β -> α -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f (g a) b) (g' (f' b a))) -> (Eq.{succ u4} (Option.{u4} γ) (Option.map₂.{u2, u3, u4} α' β γ f (Option.map.{u1, u2} α α' g a) b) (Option.map.{u5, u4} δ γ g' (Option.map₂.{u3, u1, u5} β α δ f' b a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Option.{u1} α} {δ : Option.{u2} α'} {a : Type.{u5}} {b : Type.{u4}} {f : a -> α' -> β} {g : α -> a} {f' : α' -> α -> b} {g' : b -> β}, (forall (a : α) (b : α'), Eq.{succ u3} β (f (g a) b) (g' (f' b a))) -> (Eq.{succ u3} (Option.{u3} β) (Option.map₂.{u5, u2, u3} a α' β f (Option.map.{u1, u5} α a g γ) δ) (Option.map.{u4, u3} b β g' (Option.map₂.{u2, u1, u4} α' α b f' δ γ)))\nCase conversion may be inaccurate. Consider using '#align option.map₂_map_left_anticomm Option.map₂_map_left_anticommₓ'. -/\n/-- Symmetric statement to `option.map_map₂_antidistrib_left`. -/\ntheorem map₂_map_left_anticomm {f : α' → β → γ} {g : α → α'} {f' : β → α → δ} {g' : δ → γ}\n    (h_left_anticomm : ∀ a b, f (g a) b = g' (f' b a)) :\n    map₂ f (a.map g) b = (map₂ f' b a).map g' := by cases a <;> cases b <;> simp [h_left_anticomm]\n#align option.map₂_map_left_anticomm Option.map₂_map_left_anticomm\n\n/- warning: option.map_map₂_right_anticomm -> Option.map_map₂_right_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {a : Option.{u1} α} {b : Option.{u2} β} {f : α -> β' -> γ} {g : β -> β'} {f' : β -> α -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f a (g b)) (g' (f' b a))) -> (Eq.{succ u4} (Option.{u4} γ) (Option.map₂.{u1, u3, u4} α β' γ f a (Option.map.{u2, u3} β β' g b)) (Option.map.{u5, u4} δ γ g' (Option.map₂.{u2, u1, u5} β α δ f' b a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {β' : Type.{u3}} {γ : Option.{u2} α} {δ : Option.{u1} β} {a : Type.{u5}} {b : Type.{u4}} {f : α -> a -> β'} {g : β -> a} {f' : β -> α -> b} {g' : b -> β'}, (forall (a : α) (b : β), Eq.{succ u3} β' (f a (g b)) (g' (f' b a))) -> (Eq.{succ u3} (Option.{u3} β') (Option.map₂.{u2, u5, u3} α a β' f γ (Option.map.{u1, u5} β a g δ)) (Option.map.{u4, u3} b β' g' (Option.map₂.{u1, u2, u4} β α b f' δ γ)))\nCase conversion may be inaccurate. Consider using '#align option.map_map₂_right_anticomm Option.map_map₂_right_anticommₓ'. -/\n/-- Symmetric statement to `option.map_map₂_antidistrib_right`. -/\ntheorem map_map₂_right_anticomm {f : α → β' → γ} {g : β → β'} {f' : β → α → δ} {g' : δ → γ}\n    (h_right_anticomm : ∀ a b, f a (g b) = g' (f' b a)) :\n    map₂ f a (b.map g) = (map₂ f' b a).map g' := by cases a <;> cases b <;> simp [h_right_anticomm]\n#align option.map_map₂_right_anticomm Option.map_map₂_right_anticomm\n\n#print Option.map₂_left_identity /-\n/-- If `a` is a left identity for a binary operation `f`, then `some a` is a left identity for\n`option.map₂ f`. -/\ntheorem map₂_left_identity {f : α → β → β} {a : α} (h : ∀ b, f a b = b) (o : Option β) :\n    map₂ f (some a) o = o := by\n  cases o\n  exacts[rfl, congr_arg some (h _)]\n#align option.map₂_left_identity Option.map₂_left_identity\n-/\n\n/- warning: option.map₂_right_identity -> Option.map₂_right_identity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β -> α} {b : β}, (forall (a : α), Eq.{succ u1} α (f a b) a) -> (forall (o : Option.{u1} α), Eq.{succ u1} (Option.{u1} α) (Option.map₂.{u1, u2, u1} α β α f o (Option.some.{u2} β b)) o)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {f : α -> β -> α} {b : β}, (forall (a : α), Eq.{succ u2} α (f a b) a) -> (forall (o : Option.{u2} α), Eq.{succ u2} (Option.{u2} α) (Option.map₂.{u2, u1, u2} α β α f o (Option.some.{u1} β b)) o)\nCase conversion may be inaccurate. Consider using '#align option.map₂_right_identity Option.map₂_right_identityₓ'. -/\n/-- If `b` is a right identity for a binary operation `f`, then `some b` is a right identity for\n`option.map₂ f`. -/\ntheorem map₂_right_identity {f : α → β → α} {b : β} (h : ∀ a, f a b = a) (o : Option α) :\n    map₂ f o (some b) = o := by simp [h, map₂]\n#align option.map₂_right_identity Option.map₂_right_identity\n\nend Option\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Option/NAry.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.4741703538464447}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module algebra.module.hom\n! leanprover-community/mathlib commit be24ec5de6701447e5df5ca75400ffee19d65659\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Module.Pi\n\n/-!\n# Bundled hom instances for module and multiplicative actions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines instances for module, mul_action and related structures on bundled `_hom` types.\n\nThese are analogous to the instances in `algebra.module.pi`, but for bundled instead of unbundled\nfunctions.\n-/\n\n\nvariable {R S A B : Type _}\n\nnamespace AddMonoidHom\n\nsection\n\nvariable [Monoid R] [Monoid S] [AddMonoid A] [AddCommMonoid B]\n\nvariable [DistribMulAction R B] [DistribMulAction S B]\n\ninstance : DistribMulAction R (A →+ B)\n    where\n  smul r f :=\n    { toFun := r • f\n      map_zero' := by simp\n      map_add' := fun x y => by simp [smul_add] }\n  one_smul f := by simp\n  mul_smul r s f := by simp [mul_smul]\n  smul_add r f g := ext fun x => by simp [smul_add]\n  smul_zero r := ext fun x => by simp [smul_zero]\n\n/- warning: add_monoid_hom.coe_smul -> AddMonoidHom.coe_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : Monoid.{u1} R] [_inst_3 : AddMonoid.{u2} A] [_inst_4 : AddCommMonoid.{u3} B] [_inst_5 : DistribMulAction.{u1, u3} R B _inst_1 (AddCommMonoid.toAddMonoid.{u3} B _inst_4)] (r : R) (f : AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))), Eq.{succ (max u2 u3)} (A -> B) (coeFn.{succ (max u3 u2), succ (max u2 u3)} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (fun (_x : AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) => A -> B) (AddMonoidHom.hasCoeToFun.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (SMul.smul.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (SMulZeroClass.toHasSmul.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddZeroClass.toHasZero.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoid.toAddZeroClass.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoidHom.addCommMonoid.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) _inst_4)))) (DistribSMul.toSmulZeroClass.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoid.toAddZeroClass.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoidHom.addCommMonoid.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) _inst_4))) (DistribMulAction.toDistribSMul.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) _inst_1 (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoidHom.addCommMonoid.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) _inst_4)) (AddMonoidHom.distribMulAction.{u1, u2, u3} R A B _inst_1 _inst_3 _inst_4 _inst_5)))) r f)) (SMul.smul.{u1, max u2 u3} R (A -> B) (Function.hasSMul.{u2, u1, u3} A R B (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (DistribSMul.toSmulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4)) (DistribMulAction.toDistribSMul.{u1, u3} R B _inst_1 (AddCommMonoid.toAddMonoid.{u3} B _inst_4) _inst_5)))) r (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (fun (_x : AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) => A -> B) (AddMonoidHom.hasCoeToFun.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) f))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u3}} {B : Type.{u2}} [_inst_1 : Monoid.{u1} R] [_inst_3 : AddMonoid.{u3} A] [_inst_4 : AddCommMonoid.{u2} B] [_inst_5 : DistribMulAction.{u1, u2} R B _inst_1 (AddCommMonoid.toAddMonoid.{u2} B _inst_4)] (r : R) (f : AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))), Eq.{max (succ u3) (succ u2)} (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) ᾰ) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) _x) (AddHomClass.toFunLike.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddZeroClass.toAdd.{u3} A (AddMonoid.toAddZeroClass.{u3} A _inst_3)) (AddZeroClass.toAdd.{u2} B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHomClass.toAddHomClass.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4)) (AddMonoidHom.addMonoidHomClass.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))))) (HSMul.hSMul.{u1, max u3 u2, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (instHSMul.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (SMulZeroClass.toSMul.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (instZeroAddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (DistribSMul.toSMulZeroClass.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoid.toAddZeroClass.{max u3 u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHom.addCommMonoid.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) _inst_4))) (DistribMulAction.toDistribSMul.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) _inst_1 (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHom.addCommMonoid.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) _inst_4)) (AddMonoidHom.distribMulAction.{u1, u3, u2} R A B _inst_1 _inst_3 _inst_4 _inst_5))))) r f)) (HSMul.hSMul.{u1, max u3 u2, max u3 u2} R (forall (a : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) a) (forall (ᾰ : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) ᾰ) (instHSMul.{u1, max u3 u2} R (forall (a : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) a) (Pi.instSMul.{u3, u2, u1} A R (fun (a : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) a) (fun (i : A) => SMulZeroClass.toSMul.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) (AddMonoid.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) _inst_4)) (DistribSMul.toSMulZeroClass.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) (AddMonoid.toAddZeroClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) _inst_4)) (DistribMulAction.toDistribSMul.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) _inst_1 (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) i) _inst_4) _inst_5))))) r (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) _x) (AddHomClass.toFunLike.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddZeroClass.toAdd.{u3} A (AddMonoid.toAddZeroClass.{u3} A _inst_3)) (AddZeroClass.toAdd.{u2} B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHomClass.toAddHomClass.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4)) (AddMonoidHom.addMonoidHomClass.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))))) f))\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.coe_smul AddMonoidHom.coe_smulₓ'. -/\n@[simp]\ntheorem coe_smul (r : R) (f : A →+ B) : ⇑(r • f) = r • f :=\n  rfl\n#align add_monoid_hom.coe_smul AddMonoidHom.coe_smul\n\n/- warning: add_monoid_hom.smul_apply -> AddMonoidHom.smul_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : Monoid.{u1} R] [_inst_3 : AddMonoid.{u2} A] [_inst_4 : AddCommMonoid.{u3} B] [_inst_5 : DistribMulAction.{u1, u3} R B _inst_1 (AddCommMonoid.toAddMonoid.{u3} B _inst_4)] (r : R) (f : AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (x : A), Eq.{succ u3} B (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (fun (_x : AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) => A -> B) (AddMonoidHom.hasCoeToFun.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (SMul.smul.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (SMulZeroClass.toHasSmul.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddZeroClass.toHasZero.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoid.toAddZeroClass.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoidHom.addCommMonoid.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) _inst_4)))) (DistribSMul.toSmulZeroClass.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoid.toAddZeroClass.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoidHom.addCommMonoid.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) _inst_4))) (DistribMulAction.toDistribSMul.{u1, max u3 u2} R (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) _inst_1 (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (AddMonoidHom.addCommMonoid.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) _inst_4)) (AddMonoidHom.distribMulAction.{u1, u2, u3} R A B _inst_1 _inst_3 _inst_4 _inst_5)))) r f) x) (SMul.smul.{u1, u3} R B (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (DistribSMul.toSmulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4)) (DistribMulAction.toDistribSMul.{u1, u3} R B _inst_1 (AddCommMonoid.toAddMonoid.{u3} B _inst_4) _inst_5))) r (coeFn.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) (fun (_x : AddMonoidHom.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) => A -> B) (AddMonoidHom.hasCoeToFun.{u2, u3} A B (AddMonoid.toAddZeroClass.{u2} A _inst_3) (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B _inst_4))) f x))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u3}} {B : Type.{u2}} [_inst_1 : Monoid.{u1} R] [_inst_3 : AddMonoid.{u3} A] [_inst_4 : AddCommMonoid.{u2} B] [_inst_5 : DistribMulAction.{u1, u2} R B _inst_1 (AddCommMonoid.toAddMonoid.{u2} B _inst_4)] (r : R) (f : AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (x : A), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) _x) (AddHomClass.toFunLike.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddZeroClass.toAdd.{u3} A (AddMonoid.toAddZeroClass.{u3} A _inst_3)) (AddZeroClass.toAdd.{u2} B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHomClass.toAddHomClass.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4)) (AddMonoidHom.addMonoidHomClass.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))))) (HSMul.hSMul.{u1, max u3 u2, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (instHSMul.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (SMulZeroClass.toSMul.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (instZeroAddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (DistribSMul.toSMulZeroClass.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoid.toAddZeroClass.{max u3 u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHom.addCommMonoid.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) _inst_4))) (DistribMulAction.toDistribSMul.{u1, max u3 u2} R (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) _inst_1 (AddCommMonoid.toAddMonoid.{max u3 u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHom.addCommMonoid.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) _inst_4)) (AddMonoidHom.distribMulAction.{u1, u3, u2} R A B _inst_1 _inst_3 _inst_4 _inst_5))))) r f) x) (HSMul.hSMul.{u1, u2, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) (instHSMul.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) (SMulZeroClass.toSMul.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) (AddMonoid.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) _inst_4)) (DistribSMul.toSMulZeroClass.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) (AddMonoid.toAddZeroClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) _inst_4)) (DistribMulAction.toDistribSMul.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) _inst_1 (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) x) _inst_4) _inst_5)))) r (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) _x) (AddHomClass.toFunLike.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddZeroClass.toAdd.{u3} A (AddMonoid.toAddZeroClass.{u3} A _inst_3)) (AddZeroClass.toAdd.{u2} B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) (AddMonoidHomClass.toAddHomClass.{max u3 u2, u3, u2} (AddMonoidHom.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))) A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4)) (AddMonoidHom.addMonoidHomClass.{u3, u2} A B (AddMonoid.toAddZeroClass.{u3} A _inst_3) (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B _inst_4))))) f x))\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.smul_apply AddMonoidHom.smul_applyₓ'. -/\ntheorem smul_apply (r : R) (f : A →+ B) (x : A) : (r • f) x = r • f x :=\n  rfl\n#align add_monoid_hom.smul_apply AddMonoidHom.smul_apply\n\ninstance [SMulCommClass R S B] : SMulCommClass R S (A →+ B) :=\n  ⟨fun a b f => ext fun x => smul_comm _ _ _⟩\n\ninstance [SMul R S] [IsScalarTower R S B] : IsScalarTower R S (A →+ B) :=\n  ⟨fun a b f => ext fun x => smul_assoc _ _ _⟩\n\ninstance [DistribMulAction Rᵐᵒᵖ B] [IsCentralScalar R B] : IsCentralScalar R (A →+ B) :=\n  ⟨fun a b => ext fun x => op_smul_eq_smul _ _⟩\n\nend\n\ninstance [Semiring R] [AddMonoid A] [AddCommMonoid B] [Module R B] : Module R (A →+ B) :=\n  {\n    AddMonoidHom.distribMulAction with\n    add_smul := fun r s x => ext fun y => by simp [add_smul]\n    zero_smul := fun x => ext fun y => by simp [zero_smul] }\n\nend AddMonoidHom\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Module/Hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.4741703401486908}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.algebra.homology.twist_cocycle\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits category_theory.preadditive\n\nnamespace cochain_complex\n\nnamespace lifting\n\nopen hom_complex\n\nvariables {C : Type*} [category C] [abelian C]\n\nvariables {A B K X Y : cochain_complex C ℤ} {n : ℤ} {z : cocycle B A 1} {f : A ⟶ X} (g : twist z ⟶ Y) {p : X ⟶ Y} {j : K ⟶ X}\n  (sq : comm_sq f (twist.inr z) p g) (l : Π (q : ℤ), comm_sq.lift_struct ((homological_complex.eval C _ q).map_comm_sq sq))\n  (hpj : is_termwise_kernel j p)\n\n@[simp]\ndef φ : cochain B Y 0 := cochain.comp (twist.inl z (zero_add 1)) (cochain.of_hom g) (zero_add 0).symm\n\nlemma dφ : δ 0 1 (φ g) = cochain.comp ↑z (cochain.of_hom (twist.inr z ≫ g)) (add_zero 1).symm :=\nby simp only [φ, add_left_eq_self, δ_comp_of_second_is_zero_cochain,\n  cocycle.δ_cochain_of_hom, cochain.comp_zero, twist.δ_inl,\n  cochain.comp_assoc_of_third_is_zero_cochain, cochain.of_hom_comp]\n\nvariable {g}\n\n@[simp]\ndef L : cochain B X 0 := cochain.comp (twist.inl z (zero_add 1))\n  (cochain.of_homs (λ q, (l q).l)) (zero_add 0).symm\n\ninclude sq l\n\n@[simps]\ndef obs₀ : cocycle B X 1 :=\ncocycle.mk (δ 0 1 (L sq l) - cochain.comp ↑z (cochain.of_hom f) (add_zero 1).symm) 2 rfl\n(by simp only [δ_sub, δδ, zero_sub, δ_comp_of_second_is_zero_cochain _ _ 2 rfl, neg_zero,\n    cocycle.δ_eq_zero, cocycle.δ_cochain_of_hom, cochain.comp_zero, cochain.zero_comp, add_zero])\n\ndef obs : cocycle B K 1 :=\ncocycle.lift_to_kernel (obs₀ sq l) hpj\nbegin\n  have eq₁ : cochain.comp (cochain.of_homs (λ (q : ℤ), (l q).l))\n    (cochain.of_hom p) (zero_add 0).symm = cochain.of_hom g,\n  { simp only [cochain.of_hom, cochain.of_homs_comp],\n    congr' 1,\n    ext1 q,\n    exact (l q).fac_right, },\n  have eq₂ : cochain.comp (δ 0 1 (cochain.of_homs (λ (q : ℤ), (l q).l))) (cochain.of_hom p)\n    (add_zero 1).symm = 0,\n  { suffices : δ 0 1 (cochain.comp (cochain.of_homs (λ (q : ℤ), (l q).l)) (cochain.of_hom p)\n      (zero_add 0).symm) = 0,\n    { simpa only [δ_comp_of_second_is_zero_cochain _ _ _ (zero_add 1),\n        zero_add, cocycle.δ_cochain_of_hom, cochain.comp_zero] using this, },\n    simp only [eq₁, cocycle.δ_cochain_of_hom], },\n  simp only [obs₀, cochain.sub_comp, cocycle.mk_coe, cochain.add_comp,\n    cochain.comp_assoc_of_third_is_zero_cochain, ← cochain.of_hom_comp, sq.w, L,\n    δ_comp_of_second_is_zero_cochain _ _ _ (zero_add 1),\n    eq₂, cochain.comp_zero, zero_add,\n    eq₁, ← dφ g, φ, cocycle.δ_cochain_of_hom, sub_self],\nend\n\n@[simp]\nlemma obs_comp :\n  cochain.comp (obs sq l hpj : cochain B K 1) (cochain.of_hom j)\n    (add_zero 1).symm = ↑(obs₀ sq l) :=\nby apply cocycle.lift_to_kernel_comp\n\nvariables (w : cochain B K 0) (hw : δ 0 1 w = ↑(obs sq l hpj))\nvariable (j)\n\n@[simp]\ndef F : cochain B X 0 := L sq l - cochain.comp w (cochain.of_hom j) (add_zero 0).symm\n\nvariable {j}\ninclude hw\n\nlemma dF :\n  δ 0 1 (F j sq l w) =\n    (z : cochain B A 1).comp (cochain.of_hom f) (add_zero 1).symm :=\nby simp only [F, δ_sub, δ_comp_of_second_is_zero_cochain _ _ _ (zero_add 1),\n  cocycle.δ_cochain_of_hom, cochain.comp_zero, zero_add, hw, obs_comp, obs₀,\n  cocycle.mk_coe, sub_sub_cancel]\n\nlemma lift_of_coboundary : comm_sq.lift_struct sq :=\n{ l := twist.desc z (F j sq l w) f (zero_add 1) (dF sq l hpj w hw),\n  fac_left' := by apply twist.inr_comp_desc,\n  fac_right' := begin\n    apply cochain.of_hom_injective,\n    simp only [twist.desc, cochain.of_hom_comp,cocycle.cochain_of_hom_hom_of_eq_coe,\n      twist.desc_hom_as_cocycle_coe,\n      twist.cochain_ext z _ _ (zero_add 1) (zero_add 0).symm,\n      ← cochain.comp_assoc_of_third_is_zero_cochain, twist.inl_comp_desc_cochain,\n      twist.inr_comp_desc_cochain],\n    split,\n    { ext i,\n      have hl := (l i).fac_right,\n      simp only [homological_complex.eval_map] at hl,\n      simp only [F, L, hl, cochain.sub_comp, cochain.comp_assoc_of_third_is_zero_cochain,\n        cochain.sub_v, cochain.comp_zero_cochain, cochain.of_homs_v, cochain.of_hom_v,\n        sub_eq_self, hpj.zero i, comp_zero], },\n    { simp only [← cochain.of_hom_comp, sq.w], },\n  end }\n\nend lifting\n\nend cochain_complex\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebra/homology/lifting.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6187804337438502, "lm_q1q2_score": 0.47416751284388525}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes Hölzl\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.instances.nnreal\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Extended non-negative reals\n-/\n\nnamespace ennreal\n\n\n/-- Topology on `ennreal`.\n\nNote: this is different from the `emetric_space` topology. The `emetric_space` topology has\n`is_open {⊤}`, while this topology doesn't have singleton elements. -/\nprotected instance topological_space : topological_space ennreal := preorder.topology ennreal\n\nprotected instance order_topology : order_topology ennreal := order_topology.mk rfl\n\nprotected instance t2_space : t2_space ennreal := regular_space.t2_space ennreal\n\nprotected instance topological_space.second_countable_topology :\n    topological_space.second_countable_topology ennreal :=\n  sorry\n\ntheorem embedding_coe : embedding coe := sorry\n\ntheorem is_open_ne_top : is_open (set_of fun (a : ennreal) => a ≠ ⊤) := is_open_ne\n\ntheorem is_open_Ico_zero {b : ennreal} : is_open (set.Ico 0 b) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_open (set.Ico 0 b))) ennreal.Ico_eq_Iio)) is_open_Iio\n\ntheorem coe_range_mem_nhds {r : nnreal} : set.range coe ∈ nhds ↑r := sorry\n\ntheorem tendsto_coe {α : Type u_1} {f : filter α} {m : α → nnreal} {a : nnreal} :\n    filter.tendsto (fun (a : α) => ↑(m a)) f (nhds ↑a) ↔ filter.tendsto m f (nhds a) :=\n  iff.symm (embedding.tendsto_nhds_iff embedding_coe)\n\ntheorem continuous_coe : continuous coe := embedding.continuous embedding_coe\n\ntheorem continuous_coe_iff {α : Type u_1} [topological_space α] {f : α → nnreal} :\n    (continuous fun (a : α) => ↑(f a)) ↔ continuous f :=\n  iff.symm (embedding.continuous_iff embedding_coe)\n\ntheorem nhds_coe {r : nnreal} : nhds ↑r = filter.map coe (nhds r) := sorry\n\ntheorem nhds_coe_coe {r : nnreal} {p : nnreal} :\n    nhds (↑r, ↑p) =\n        filter.map (fun (p : nnreal × nnreal) => (↑(prod.fst p), ↑(prod.snd p))) (nhds (r, p)) :=\n  sorry\n\ntheorem continuous_of_real : continuous ennreal.of_real :=\n  continuous.comp (iff.mpr continuous_coe_iff continuous_id) nnreal.continuous_of_real\n\ntheorem tendsto_of_real {α : Type u_1} {f : filter α} {m : α → ℝ} {a : ℝ}\n    (h : filter.tendsto m f (nhds a)) :\n    filter.tendsto (fun (a : α) => ennreal.of_real (m a)) f (nhds (ennreal.of_real a)) :=\n  filter.tendsto.comp (continuous.tendsto continuous_of_real a) h\n\ntheorem tendsto_to_nnreal {a : ennreal} :\n    a ≠ ⊤ → filter.tendsto ennreal.to_nnreal (nhds a) (nhds (ennreal.to_nnreal a)) :=\n  sorry\n\ntheorem continuous_on_to_nnreal :\n    continuous_on ennreal.to_nnreal (set_of fun (a : ennreal) => a ≠ ⊤) :=\n  sorry\n\ntheorem tendsto_to_real {a : ennreal} :\n    a ≠ ⊤ → filter.tendsto ennreal.to_real (nhds a) (nhds (ennreal.to_real a)) :=\n  fun (ha : a ≠ ⊤) =>\n    filter.tendsto.comp (iff.mpr nnreal.tendsto_coe filter.tendsto_id) (tendsto_to_nnreal ha)\n\n/-- The set of finite `ennreal` numbers is homeomorphic to `ℝ≥0`. -/\ndef ne_top_homeomorph_nnreal : ↥(set_of fun (a : ennreal) => a ≠ ⊤) ≃ₜ nnreal :=\n  homeomorph.mk\n    (equiv.mk (equiv.to_fun ne_top_equiv_nnreal) (equiv.inv_fun ne_top_equiv_nnreal) sorry sorry)\n\n/-- The set of finite `ennreal` numbers is homeomorphic to `ℝ≥0`. -/\ndef lt_top_homeomorph_nnreal : ↥(set_of fun (a : ennreal) => a < ⊤) ≃ₜ nnreal :=\n  homeomorph.trans (homeomorph.set_congr sorry) ne_top_homeomorph_nnreal\n\ntheorem nhds_top :\n    nhds ⊤ = infi fun (a : ennreal) => infi fun (H : a ≠ ⊤) => filter.principal (set.Ioi a) :=\n  sorry\n\ntheorem nhds_top' : nhds ⊤ = infi fun (r : nnreal) => filter.principal (set.Ioi ↑r) :=\n  Eq.trans nhds_top (infi_ne_top fun (a : ennreal) => filter.principal (set.Ioi a))\n\ntheorem tendsto_nhds_top_iff_nnreal {α : Type u_1} {m : α → ennreal} {f : filter α} :\n    filter.tendsto m f (nhds ⊤) ↔ ∀ (x : nnreal), filter.eventually (fun (a : α) => ↑x < m a) f :=\n  sorry\n\ntheorem tendsto_nhds_top_iff_nat {α : Type u_1} {m : α → ennreal} {f : filter α} :\n    filter.tendsto m f (nhds ⊤) ↔ ∀ (n : ℕ), filter.eventually (fun (a : α) => ↑n < m a) f :=\n  sorry\n\ntheorem tendsto_nhds_top {α : Type u_1} {m : α → ennreal} {f : filter α}\n    (h : ∀ (n : ℕ), filter.eventually (fun (a : α) => ↑n < m a) f) : filter.tendsto m f (nhds ⊤) :=\n  iff.mpr tendsto_nhds_top_iff_nat h\n\ntheorem tendsto_nat_nhds_top : filter.tendsto (fun (n : ℕ) => ↑n) filter.at_top (nhds ⊤) := sorry\n\n@[simp] theorem tendsto_coe_nhds_top {α : Type u_1} {f : α → nnreal} {l : filter α} :\n    filter.tendsto (fun (x : α) => ↑(f x)) l (nhds ⊤) ↔ filter.tendsto f l filter.at_top :=\n  sorry\n\ntheorem nhds_zero :\n    nhds 0 = infi fun (a : ennreal) => infi fun (H : a ≠ 0) => filter.principal (set.Iio a) :=\n  sorry\n\ninstance nhds_within_Ioi_coe_ne_bot {r : nnreal} : filter.ne_bot (nhds_within (↑r) (set.Ioi ↑r)) :=\n  nhds_within_Ioi_self_ne_bot' coe_lt_top\n\ninstance nhds_within_Ioi_zero_ne_bot : filter.ne_bot (nhds_within 0 (set.Ioi 0)) :=\n  nhds_within_Ioi_coe_ne_bot\n\n-- using Icc because\n\n-- • don't have 'Ioo (x - ε) (x + ε) ∈ 𝓝 x' unless x > 0\n\n-- • (x - y ≤ ε ↔ x ≤ ε + y) is true, while (x - y < ε ↔ x < ε + y) is not\n\ntheorem Icc_mem_nhds {x : ennreal} {ε : ennreal} :\n    x ≠ ⊤ → 0 < ε → set.Icc (x - ε) (x + ε) ∈ nhds x :=\n  sorry\n\ntheorem nhds_of_ne_top {x : ennreal} :\n    x ≠ ⊤ →\n        nhds x =\n          infi\n            fun (ε : ennreal) =>\n              infi fun (H : ε > 0) => filter.principal (set.Icc (x - ε) (x + ε)) :=\n  sorry\n\n/-- Characterization of neighborhoods for `ennreal` numbers. See also `tendsto_order`\nfor a version with strict inequalities. -/\nprotected theorem tendsto_nhds {α : Type u_1} {f : filter α} {u : α → ennreal} {a : ennreal}\n    (ha : a ≠ ⊤) :\n    filter.tendsto u f (nhds a) ↔\n        ∀ (ε : ennreal),\n          ε > 0 → filter.eventually (fun (x : α) => u x ∈ set.Icc (a - ε) (a + ε)) f :=\n  sorry\n\nprotected theorem tendsto_at_top {β : Type u_2} [Nonempty β] [semilattice_sup β] {f : β → ennreal}\n    {a : ennreal} (ha : a ≠ ⊤) :\n    filter.tendsto f filter.at_top (nhds a) ↔\n        ∀ (ε : ennreal), ε > 0 → ∃ (N : β), ∀ (n : β), n ≥ N → f n ∈ set.Icc (a - ε) (a + ε) :=\n  sorry\n\nprotected instance has_continuous_add : has_continuous_add ennreal := sorry\n\nprotected theorem tendsto_mul {a : ennreal} {b : ennreal} (ha : a ≠ 0 ∨ b ≠ ⊤)\n    (hb : b ≠ 0 ∨ a ≠ ⊤) :\n    filter.tendsto (fun (p : ennreal × ennreal) => prod.fst p * prod.snd p) (nhds (a, b))\n        (nhds (a * b)) :=\n  sorry\n\nprotected theorem tendsto.mul {α : Type u_1} {f : filter α} {ma : α → ennreal} {mb : α → ennreal}\n    {a : ennreal} {b : ennreal} (hma : filter.tendsto ma f (nhds a)) (ha : a ≠ 0 ∨ b ≠ ⊤)\n    (hmb : filter.tendsto mb f (nhds b)) (hb : b ≠ 0 ∨ a ≠ ⊤) :\n    filter.tendsto (fun (a : α) => ma a * mb a) f (nhds (a * b)) :=\n  sorry\n\nprotected theorem tendsto.const_mul {α : Type u_1} {f : filter α} {m : α → ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds b)) (hb : b ≠ 0 ∨ a ≠ ⊤) :\n    filter.tendsto (fun (b : α) => a * m b) f (nhds (a * b)) :=\n  sorry\n\nprotected theorem tendsto.mul_const {α : Type u_1} {f : filter α} {m : α → ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds a)) (ha : a ≠ 0 ∨ b ≠ ⊤) :\n    filter.tendsto (fun (x : α) => m x * b) f (nhds (a * b)) :=\n  sorry\n\nprotected theorem continuous_at_const_mul {a : ennreal} {b : ennreal} (h : a ≠ ⊤ ∨ b ≠ 0) :\n    continuous_at (Mul.mul a) b :=\n  tendsto.const_mul filter.tendsto_id (or.symm h)\n\nprotected theorem continuous_at_mul_const {a : ennreal} {b : ennreal} (h : a ≠ ⊤ ∨ b ≠ 0) :\n    continuous_at (fun (x : ennreal) => x * a) b :=\n  tendsto.mul_const filter.tendsto_id (or.symm h)\n\nprotected theorem continuous_const_mul {a : ennreal} (ha : a ≠ ⊤) : continuous (Mul.mul a) :=\n  iff.mpr continuous_iff_continuous_at\n    fun (x : ennreal) => ennreal.continuous_at_const_mul (Or.inl ha)\n\nprotected theorem continuous_mul_const {a : ennreal} (ha : a ≠ ⊤) :\n    continuous fun (x : ennreal) => x * a :=\n  iff.mpr continuous_iff_continuous_at\n    fun (x : ennreal) => ennreal.continuous_at_mul_const (Or.inl ha)\n\ntheorem le_of_forall_lt_one_mul_le {x : ennreal} {y : ennreal}\n    (h : ∀ (a : ennreal), a < 1 → a * x ≤ y) : x ≤ y :=\n  sorry\n\ntheorem infi_mul_left {ι : Sort u_1} [Nonempty ι] {f : ι → ennreal} {a : ennreal}\n    (h : a = ⊤ → (infi fun (i : ι) => f i) = 0 → ∃ (i : ι), f i = 0) :\n    (infi fun (i : ι) => a * f i) = a * infi fun (i : ι) => f i :=\n  sorry\n\ntheorem infi_mul_right {ι : Sort u_1} [Nonempty ι] {f : ι → ennreal} {a : ennreal}\n    (h : a = ⊤ → (infi fun (i : ι) => f i) = 0 → ∃ (i : ι), f i = 0) :\n    (infi fun (i : ι) => f i * a) = (infi fun (i : ι) => f i) * a :=\n  sorry\n\nprotected theorem continuous_inv : continuous has_inv.inv := sorry\n\n@[simp] protected theorem tendsto_inv_iff {α : Type u_1} {f : filter α} {m : α → ennreal}\n    {a : ennreal} :\n    filter.tendsto (fun (x : α) => m x⁻¹) f (nhds (a⁻¹)) ↔ filter.tendsto m f (nhds a) :=\n  sorry\n\nprotected theorem tendsto.div {α : Type u_1} {f : filter α} {ma : α → ennreal} {mb : α → ennreal}\n    {a : ennreal} {b : ennreal} (hma : filter.tendsto ma f (nhds a)) (ha : a ≠ 0 ∨ b ≠ 0)\n    (hmb : filter.tendsto mb f (nhds b)) (hb : b ≠ ⊤ ∨ a ≠ ⊤) :\n    filter.tendsto (fun (a : α) => ma a / mb a) f (nhds (a / b)) :=\n  sorry\n\nprotected theorem tendsto.const_div {α : Type u_1} {f : filter α} {m : α → ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds b)) (hb : b ≠ ⊤ ∨ a ≠ ⊤) :\n    filter.tendsto (fun (b : α) => a / m b) f (nhds (a / b)) :=\n  sorry\n\nprotected theorem tendsto.div_const {α : Type u_1} {f : filter α} {m : α → ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds a)) (ha : a ≠ 0 ∨ b ≠ 0) :\n    filter.tendsto (fun (x : α) => m x / b) f (nhds (a / b)) :=\n  sorry\n\nprotected theorem tendsto_inv_nat_nhds_zero :\n    filter.tendsto (fun (n : ℕ) => ↑n⁻¹) filter.at_top (nhds 0) :=\n  inv_top ▸ iff.mpr ennreal.tendsto_inv_iff tendsto_nat_nhds_top\n\ntheorem bsupr_add {a : ennreal} {ι : Type u_1} {s : set ι} (hs : set.nonempty s) {f : ι → ennreal} :\n    (supr fun (i : ι) => supr fun (H : i ∈ s) => f i) + a =\n        supr fun (i : ι) => supr fun (H : i ∈ s) => f i + a :=\n  sorry\n\ntheorem Sup_add {a : ennreal} {s : set ennreal} (hs : set.nonempty s) :\n    Sup s + a = supr fun (b : ennreal) => supr fun (H : b ∈ s) => b + a :=\n  sorry\n\ntheorem supr_add {a : ennreal} {ι : Sort u_1} {s : ι → ennreal} [h : Nonempty ι] :\n    supr s + a = supr fun (b : ι) => s b + a :=\n  sorry\n\ntheorem add_supr {a : ennreal} {ι : Sort u_1} {s : ι → ennreal} [h : Nonempty ι] :\n    a + supr s = supr fun (b : ι) => a + s b :=\n  sorry\n\ntheorem supr_add_supr {ι : Sort u_1} {f : ι → ennreal} {g : ι → ennreal}\n    (h : ∀ (i j : ι), ∃ (k : ι), f i + g j ≤ f k + g k) :\n    supr f + supr g = supr fun (a : ι) => f a + g a :=\n  sorry\n\ntheorem supr_add_supr_of_monotone {ι : Type u_1} [semilattice_sup ι] {f : ι → ennreal}\n    {g : ι → ennreal} (hf : monotone f) (hg : monotone g) :\n    supr f + supr g = supr fun (a : ι) => f a + g a :=\n  supr_add_supr\n    fun (i j : ι) => Exists.intro (i ⊔ j) (add_le_add (hf le_sup_left) (hg le_sup_right))\n\ntheorem finset_sum_supr_nat {α : Type u_1} {ι : Type u_2} [semilattice_sup ι] {s : finset α}\n    {f : α → ι → ennreal} (hf : ∀ (a : α), monotone (f a)) :\n    (finset.sum s fun (a : α) => supr (f a)) =\n        supr fun (n : ι) => finset.sum s fun (a : α) => f a n :=\n  sorry\n\ntheorem mul_Sup {s : set ennreal} {a : ennreal} :\n    a * Sup s = supr fun (i : ennreal) => supr fun (H : i ∈ s) => a * i :=\n  sorry\n\ntheorem mul_supr {ι : Sort u_1} {f : ι → ennreal} {a : ennreal} :\n    a * supr f = supr fun (i : ι) => a * f i :=\n  sorry\n\ntheorem supr_mul {ι : Sort u_1} {f : ι → ennreal} {a : ennreal} :\n    supr f * a = supr fun (i : ι) => f i * a :=\n  sorry\n\nprotected theorem tendsto_coe_sub {r : nnreal} {b : ennreal} :\n    filter.tendsto (fun (b : ennreal) => ↑r - b) (nhds b) (nhds (↑r - b)) :=\n  sorry\n\ntheorem sub_supr {a : ennreal} {ι : Sort u_1} [hι : Nonempty ι] {b : ι → ennreal} (hr : a < ⊤) :\n    (a - supr fun (i : ι) => b i) = infi fun (i : ι) => a - b i :=\n  sorry\n\ntheorem supr_eq_zero {ι : Sort u_1} {f : ι → ennreal} :\n    (supr fun (i : ι) => f i) = 0 ↔ ∀ (i : ι), f i = 0 :=\n  sorry\n\nprotected theorem has_sum_coe {α : Type u_1} {f : α → nnreal} {r : nnreal} :\n    has_sum (fun (a : α) => ↑(f a)) ↑r ↔ has_sum f r :=\n  sorry\n\nprotected theorem tsum_coe_eq {α : Type u_1} {r : nnreal} {f : α → nnreal} (h : has_sum f r) :\n    (tsum fun (a : α) => ↑(f a)) = ↑r :=\n  has_sum.tsum_eq (iff.mpr ennreal.has_sum_coe h)\n\nprotected theorem coe_tsum {α : Type u_1} {f : α → nnreal} :\n    summable f → ↑(tsum f) = tsum fun (a : α) => ↑(f a) :=\n  sorry\n\nprotected theorem has_sum {α : Type u_1} {f : α → ennreal} :\n    has_sum f (supr fun (s : finset α) => finset.sum s fun (a : α) => f a) :=\n  tendsto_at_top_supr fun (s t : finset α) => finset.sum_le_sum_of_subset\n\n@[simp] protected theorem summable {α : Type u_1} {f : α → ennreal} : summable f :=\n  Exists.intro (supr fun (s : finset α) => finset.sum s fun (a : α) => f a) ennreal.has_sum\n\ntheorem tsum_coe_ne_top_iff_summable {β : Type u_2} {f : β → nnreal} :\n    (tsum fun (b : β) => ↑(f b)) ≠ ⊤ ↔ summable f :=\n  sorry\n\nprotected theorem tsum_eq_supr_sum {α : Type u_1} {f : α → ennreal} :\n    (tsum fun (a : α) => f a) = supr fun (s : finset α) => finset.sum s fun (a : α) => f a :=\n  has_sum.tsum_eq ennreal.has_sum\n\nprotected theorem tsum_eq_supr_sum' {α : Type u_1} {f : α → ennreal} {ι : Type u_2}\n    (s : ι → finset α) (hs : ∀ (t : finset α), ∃ (i : ι), t ⊆ s i) :\n    (tsum fun (a : α) => f a) = supr fun (i : ι) => finset.sum (s i) fun (a : α) => f a :=\n  sorry\n\nprotected theorem tsum_sigma {α : Type u_1} {β : α → Type u_2} (f : (a : α) → β a → ennreal) :\n    (tsum fun (p : sigma fun (a : α) => β a) => f (sigma.fst p) (sigma.snd p)) =\n        tsum fun (a : α) => tsum fun (b : β a) => f a b :=\n  tsum_sigma' (fun (b : α) => ennreal.summable) ennreal.summable\n\nprotected theorem tsum_sigma' {α : Type u_1} {β : α → Type u_2}\n    (f : (sigma fun (a : α) => β a) → ennreal) :\n    (tsum fun (p : sigma fun (a : α) => β a) => f p) =\n        tsum fun (a : α) => tsum fun (b : β a) => f (sigma.mk a b) :=\n  tsum_sigma' (fun (b : α) => ennreal.summable) ennreal.summable\n\nprotected theorem tsum_prod {α : Type u_1} {β : Type u_2} {f : α → β → ennreal} :\n    (tsum fun (p : α × β) => f (prod.fst p) (prod.snd p)) =\n        tsum fun (a : α) => tsum fun (b : β) => f a b :=\n  tsum_prod' ennreal.summable fun (_x : α) => ennreal.summable\n\nprotected theorem tsum_comm {α : Type u_1} {β : Type u_2} {f : α → β → ennreal} :\n    (tsum fun (a : α) => tsum fun (b : β) => f a b) =\n        tsum fun (b : β) => tsum fun (a : α) => f a b :=\n  tsum_comm' ennreal.summable (fun (_x : β) => ennreal.summable) fun (_x : α) => ennreal.summable\n\nprotected theorem tsum_add {α : Type u_1} {f : α → ennreal} {g : α → ennreal} :\n    (tsum fun (a : α) => f a + g a) = (tsum fun (a : α) => f a) + tsum fun (a : α) => g a :=\n  tsum_add ennreal.summable ennreal.summable\n\nprotected theorem tsum_le_tsum {α : Type u_1} {f : α → ennreal} {g : α → ennreal}\n    (h : ∀ (a : α), f a ≤ g a) : (tsum fun (a : α) => f a) ≤ tsum fun (a : α) => g a :=\n  tsum_le_tsum h ennreal.summable ennreal.summable\n\nprotected theorem sum_le_tsum {α : Type u_1} {f : α → ennreal} (s : finset α) :\n    (finset.sum s fun (x : α) => f x) ≤ tsum fun (x : α) => f x :=\n  sum_le_tsum s (fun (x : α) (hx : ¬x ∈ s) => zero_le (f x)) ennreal.summable\n\nprotected theorem tsum_eq_supr_nat' {f : ℕ → ennreal} {N : ℕ → ℕ}\n    (hN : filter.tendsto N filter.at_top filter.at_top) :\n    (tsum fun (i : ℕ) => f i) =\n        supr fun (i : ℕ) => finset.sum (finset.range (N i)) fun (i : ℕ) => f i :=\n  sorry\n\nprotected theorem tsum_eq_supr_nat {f : ℕ → ennreal} :\n    (tsum fun (i : ℕ) => f i) =\n        supr fun (i : ℕ) => finset.sum (finset.range i) fun (i : ℕ) => f i :=\n  ennreal.tsum_eq_supr_sum' (fun (i : ℕ) => finset.range i) finset.exists_nat_subset_range\n\nprotected theorem le_tsum {α : Type u_1} {f : α → ennreal} (a : α) :\n    f a ≤ tsum fun (a : α) => f a :=\n  le_tsum' ennreal.summable a\n\nprotected theorem tsum_eq_top_of_eq_top {α : Type u_1} {f : α → ennreal} :\n    (∃ (a : α), f a = ⊤) → (tsum fun (a : α) => f a) = ⊤ :=\n  fun (ᾰ : ∃ (a : α), f a = ⊤) =>\n    Exists.dcases_on ᾰ\n      fun (ᾰ_w : α) (ᾰ_h : f ᾰ_w = ⊤) =>\n        idRhs ((tsum fun (a : α) => f a) = ⊤) (top_unique (ᾰ_h ▸ ennreal.le_tsum ᾰ_w))\n\nprotected theorem ne_top_of_tsum_ne_top {α : Type u_1} {f : α → ennreal}\n    (h : (tsum fun (a : α) => f a) ≠ ⊤) (a : α) : f a ≠ ⊤ :=\n  fun (ha : f a = ⊤) => h (ennreal.tsum_eq_top_of_eq_top (Exists.intro a ha))\n\nprotected theorem tsum_mul_left {α : Type u_1} {a : ennreal} {f : α → ennreal} :\n    (tsum fun (i : α) => a * f i) = a * tsum fun (i : α) => f i :=\n  sorry\n\nprotected theorem tsum_mul_right {α : Type u_1} {a : ennreal} {f : α → ennreal} :\n    (tsum fun (i : α) => f i * a) = (tsum fun (i : α) => f i) * a :=\n  sorry\n\n@[simp] theorem tsum_supr_eq {α : Type u_1} (a : α) {f : α → ennreal} :\n    (tsum fun (b : α) => supr fun (h : a = b) => f b) = f a :=\n  sorry\n\ntheorem has_sum_iff_tendsto_nat {f : ℕ → ennreal} (r : ennreal) :\n    has_sum f r ↔\n        filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i) filter.at_top\n          (nhds r) :=\n  sorry\n\ntheorem to_nnreal_apply_of_tsum_ne_top {α : Type u_1} {f : α → ennreal}\n    (hf : (tsum fun (i : α) => f i) ≠ ⊤) (x : α) : ↑(function.comp ennreal.to_nnreal f x) = f x :=\n  coe_to_nnreal (ennreal.ne_top_of_tsum_ne_top hf x)\n\ntheorem summable_to_nnreal_of_tsum_ne_top {α : Type u_1} {f : α → ennreal}\n    (hf : (tsum fun (i : α) => f i) ≠ ⊤) : summable (ennreal.to_nnreal ∘ f) :=\n  sorry\n\nprotected theorem tsum_apply {ι : Type u_1} {α : Type u_2} {f : ι → α → ennreal} {x : α} :\n    tsum (fun (i : ι) => f i) x = tsum fun (i : ι) => f i x :=\n  tsum_apply (iff.mpr pi.summable fun (_x : α) => ennreal.summable)\n\ntheorem tsum_sub {f : ℕ → ennreal} {g : ℕ → ennreal} (h₁ : (tsum fun (i : ℕ) => g i) < ⊤)\n    (h₂ : g ≤ f) :\n    (tsum fun (i : ℕ) => f i - g i) = (tsum fun (i : ℕ) => f i) - tsum fun (i : ℕ) => g i :=\n  sorry\n\nend ennreal\n\n\nnamespace nnreal\n\n\n/-- Comparison test of convergence of `ℝ≥0`-valued series. -/\ntheorem exists_le_has_sum_of_le {β : Type u_2} {f : β → nnreal} {g : β → nnreal} {r : nnreal}\n    (hgf : ∀ (b : β), g b ≤ f b) (hfr : has_sum f r) : ∃ (p : nnreal), ∃ (H : p ≤ r), has_sum g p :=\n  sorry\n\n/-- Comparison test of convergence of `ℝ≥0`-valued series. -/\ntheorem summable_of_le {β : Type u_2} {f : β → nnreal} {g : β → nnreal}\n    (hgf : ∀ (b : β), g b ≤ f b) : summable f → summable g :=\n  sorry\n\n/-- A series of non-negative real numbers converges to `r` in the sense of `has_sum` if and only if\nthe sequence of partial sum converges to `r`. -/\ntheorem has_sum_iff_tendsto_nat {f : ℕ → nnreal} {r : nnreal} :\n    has_sum f r ↔\n        filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i) filter.at_top\n          (nhds r) :=\n  sorry\n\ntheorem not_summable_iff_tendsto_nat_at_top {f : ℕ → nnreal} :\n    ¬summable f ↔\n        filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i) filter.at_top\n          filter.at_top :=\n  sorry\n\ntheorem summable_iff_not_tendsto_nat_at_top {f : ℕ → nnreal} :\n    summable f ↔\n        ¬filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i)\n            filter.at_top filter.at_top :=\n  sorry\n\ntheorem summable_of_sum_range_le {f : ℕ → nnreal} {c : nnreal}\n    (h : ∀ (n : ℕ), (finset.sum (finset.range n) fun (i : ℕ) => f i) ≤ c) : summable f :=\n  sorry\n\ntheorem tsum_le_of_sum_range_le {f : ℕ → nnreal} {c : nnreal}\n    (h : ∀ (n : ℕ), (finset.sum (finset.range n) fun (i : ℕ) => f i) ≤ c) :\n    (tsum fun (i : ℕ) => f i) ≤ c :=\n  le_of_tendsto' (iff.mp has_sum_iff_tendsto_nat (summable.has_sum (summable_of_sum_range_le h))) h\n\ntheorem tsum_comp_le_tsum_of_inj {α : Type u_1} {β : Type u_2} {f : α → nnreal} (hf : summable f)\n    {i : β → α} (hi : function.injective i) :\n    (tsum fun (x : β) => f (i x)) ≤ tsum fun (x : α) => f x :=\n  tsum_le_tsum_of_inj i hi (fun (c : α) (hc : ¬c ∈ set.range i) => zero_le (f c))\n    (fun (b : β) => le_refl (f (i b))) (summable_comp_injective hf hi) hf\n\ntheorem summable_sigma {α : Type u_1} {β : α → Type u_2} {f : (sigma fun (x : α) => β x) → nnreal} :\n    summable f ↔\n        (∀ (x : α), summable fun (y : β x) => f (sigma.mk x y)) ∧\n          summable fun (x : α) => tsum fun (y : β x) => f (sigma.mk x y) :=\n  sorry\n\n/-- For `f : ℕ → ℝ≥0`, then `∑' k, f (k + i)` tends to zero. This does not require a summability\nassumption on `f`, as otherwise all sums are zero. -/\ntheorem tendsto_sum_nat_add (f : ℕ → nnreal) :\n    filter.tendsto (fun (i : ℕ) => tsum fun (k : ℕ) => f (k + i)) filter.at_top (nhds 0) :=\n  sorry\n\nend nnreal\n\n\nnamespace ennreal\n\n\ntheorem tendsto_sum_nat_add (f : ℕ → ennreal) (hf : (tsum fun (i : ℕ) => f i) ≠ ⊤) :\n    filter.tendsto (fun (i : ℕ) => tsum fun (k : ℕ) => f (k + i)) filter.at_top (nhds 0) :=\n  sorry\n\nend ennreal\n\n\ntheorem tsum_comp_le_tsum_of_inj {α : Type u_1} {β : Type u_2} {f : α → ℝ} (hf : summable f)\n    (hn : ∀ (a : α), 0 ≤ f a) {i : β → α} (hi : function.injective i) : tsum (f ∘ i) ≤ tsum f :=\n  sorry\n\n/-- Comparison test of convergence of series of non-negative real numbers. -/\ntheorem summable_of_nonneg_of_le {β : Type u_2} {f : β → ℝ} {g : β → ℝ} (hg : ∀ (b : β), 0 ≤ g b)\n    (hgf : ∀ (b : β), g b ≤ f b) (hf : summable f) : summable g :=\n  sorry\n\n/-- A series of non-negative real numbers converges to `r` in the sense of `has_sum` if and only if\nthe sequence of partial sum converges to `r`. -/\ntheorem has_sum_iff_tendsto_nat_of_nonneg {f : ℕ → ℝ} (hf : ∀ (i : ℕ), 0 ≤ f i) (r : ℝ) :\n    has_sum f r ↔\n        filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i) filter.at_top\n          (nhds r) :=\n  sorry\n\ntheorem ennreal.of_real_tsum_of_nonneg {α : Type u_1} {f : α → ℝ} (hf_nonneg : ∀ (n : α), 0 ≤ f n)\n    (hf : summable f) :\n    ennreal.of_real (tsum fun (n : α) => f n) = tsum fun (n : α) => ennreal.of_real (f n) :=\n  sorry\n\ntheorem not_summable_iff_tendsto_nat_at_top_of_nonneg {f : ℕ → ℝ} (hf : ∀ (n : ℕ), 0 ≤ f n) :\n    ¬summable f ↔\n        filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i) filter.at_top\n          filter.at_top :=\n  sorry\n\ntheorem summable_iff_not_tendsto_nat_at_top_of_nonneg {f : ℕ → ℝ} (hf : ∀ (n : ℕ), 0 ≤ f n) :\n    summable f ↔\n        ¬filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => f i)\n            filter.at_top filter.at_top :=\n  sorry\n\ntheorem summable_sigma_of_nonneg {α : Type u_1} {β : α → Type u_2}\n    {f : (sigma fun (x : α) => β x) → ℝ} (hf : ∀ (x : sigma fun (x : α) => β x), 0 ≤ f x) :\n    summable f ↔\n        (∀ (x : α), summable fun (y : β x) => f (sigma.mk x y)) ∧\n          summable fun (x : α) => tsum fun (y : β x) => f (sigma.mk x y) :=\n  sorry\n\ntheorem summable_of_sum_range_le {f : ℕ → ℝ} {c : ℝ} (hf : ∀ (n : ℕ), 0 ≤ f n)\n    (h : ∀ (n : ℕ), (finset.sum (finset.range n) fun (i : ℕ) => f i) ≤ c) : summable f :=\n  sorry\n\ntheorem tsum_le_of_sum_range_le {f : ℕ → ℝ} {c : ℝ} (hf : ∀ (n : ℕ), 0 ≤ f n)\n    (h : ∀ (n : ℕ), (finset.sum (finset.range n) fun (i : ℕ) => f i) ≤ c) :\n    (tsum fun (i : ℕ) => f i) ≤ c :=\n  sorry\n\n/-- In an emetric ball, the distance between points is everywhere finite -/\ntheorem edist_ne_top_of_mem_ball {β : Type u_2} [emetric_space β] {a : β} {r : ennreal}\n    (x : ↥(emetric.ball a r)) (y : ↥(emetric.ball a r)) :\n    edist (subtype.val x) (subtype.val y) ≠ ⊤ :=\n  sorry\n\n/-- Each ball in an extended metric space gives us a metric space, as the edist\nis everywhere finite. -/\ndef metric_space_emetric_ball {β : Type u_2} [emetric_space β] (a : β) (r : ennreal) :\n    metric_space ↥(emetric.ball a r) :=\n  emetric_space.to_metric_space edist_ne_top_of_mem_ball\n\ntheorem nhds_eq_nhds_emetric_ball {β : Type u_2} [emetric_space β] (a : β) (x : β) (r : ennreal)\n    (h : x ∈ emetric.ball a r) : nhds x = filter.map coe (nhds { val := x, property := h }) :=\n  Eq.symm (map_nhds_subtype_coe_eq h (mem_nhds_sets emetric.is_open_ball h))\n\ntheorem tendsto_iff_edist_tendsto_0 {α : Type u_1} {β : Type u_2} [emetric_space α] {l : filter β}\n    {f : β → α} {y : α} :\n    filter.tendsto f l (nhds y) ↔ filter.tendsto (fun (x : β) => edist (f x) y) l (nhds 0) :=\n  sorry\n\n/-- Yet another metric characterization of Cauchy sequences on integers. This one is often the\nmost efficient. -/\ntheorem emetric.cauchy_seq_iff_le_tendsto_0 {α : Type u_1} {β : Type u_2} [emetric_space α]\n    [Nonempty β] [semilattice_sup β] {s : β → α} :\n    cauchy_seq s ↔\n        ∃ (b : β → ennreal),\n          (∀ (n m N : β), N ≤ n → N ≤ m → edist (s n) (s m) ≤ b N) ∧\n            filter.tendsto b filter.at_top (nhds 0) :=\n  sorry\n\ntheorem continuous_of_le_add_edist {α : Type u_1} [emetric_space α] {f : α → ennreal} (C : ennreal)\n    (hC : C ≠ ⊤) (h : ∀ (x y : α), f x ≤ f y + C * edist x y) : continuous f :=\n  sorry\n\ntheorem continuous_edist {α : Type u_1} [emetric_space α] :\n    continuous fun (p : α × α) => edist (prod.fst p) (prod.snd p) :=\n  sorry\n\ntheorem continuous.edist {α : Type u_1} {β : Type u_2} [emetric_space α] [topological_space β]\n    {f : β → α} {g : β → α} (hf : continuous f) (hg : continuous g) :\n    continuous fun (b : β) => edist (f b) (g b) :=\n  continuous.comp continuous_edist (continuous.prod_mk hf hg)\n\ntheorem filter.tendsto.edist {α : Type u_1} {β : Type u_2} [emetric_space α] {f : β → α} {g : β → α}\n    {x : filter β} {a : α} {b : α} (hf : filter.tendsto f x (nhds a))\n    (hg : filter.tendsto g x (nhds b)) :\n    filter.tendsto (fun (x : β) => edist (f x) (g x)) x (nhds (edist a b)) :=\n  filter.tendsto.comp (continuous.tendsto continuous_edist (a, b))\n    (filter.tendsto.prod_mk_nhds hf hg)\n\ntheorem cauchy_seq_of_edist_le_of_tsum_ne_top {α : Type u_1} [emetric_space α] {f : ℕ → α}\n    (d : ℕ → ennreal) (hf : ∀ (n : ℕ), edist (f n) (f (Nat.succ n)) ≤ d n) (hd : tsum d ≠ ⊤) :\n    cauchy_seq f :=\n  sorry\n\ntheorem emetric.is_closed_ball {α : Type u_1} [emetric_space α] {a : α} {r : ennreal} :\n    is_closed (emetric.closed_ball a r) :=\n  is_closed_le (continuous.edist continuous_id continuous_const) continuous_const\n\n/-- If `edist (f n) (f (n+1))` is bounded above by a function `d : ℕ → ennreal`,\nthen the distance from `f n` to the limit is bounded by `∑'_{k=n}^∞ d k`. -/\ntheorem edist_le_tsum_of_edist_le_of_tendsto {α : Type u_1} [emetric_space α] {f : ℕ → α}\n    (d : ℕ → ennreal) (hf : ∀ (n : ℕ), edist (f n) (f (Nat.succ n)) ≤ d n) {a : α}\n    (ha : filter.tendsto f filter.at_top (nhds a)) (n : ℕ) :\n    edist (f n) a ≤ tsum fun (m : ℕ) => d (n + m) :=\n  sorry\n\n/-- If `edist (f n) (f (n+1))` is bounded above by a function `d : ℕ → ennreal`,\nthen the distance from `f 0` to the limit is bounded by `∑'_{k=0}^∞ d k`. -/\ntheorem edist_le_tsum_of_edist_le_of_tendsto₀ {α : Type u_1} [emetric_space α] {f : ℕ → α}\n    (d : ℕ → ennreal) (hf : ∀ (n : ℕ), edist (f n) (f (Nat.succ n)) ≤ d n) {a : α}\n    (ha : filter.tendsto f filter.at_top (nhds a)) : edist (f 0) a ≤ tsum fun (m : ℕ) => d m :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/instances/ennreal_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.47416751284388525}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n\n! This file was ported from Lean 3 source module category_theory.sites.sheafification\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Adjunction.FullyFaithful\nimport Mathbin.CategoryTheory.Sites.Plus\nimport Mathbin.CategoryTheory.Limits.ConcreteCategory\nimport Mathbin.CategoryTheory.ConcreteCategory.Elementwise\n\n/-!\n\n# Sheafification\n\nWe construct the sheafification of a presheaf over a site `C` with values in `D` whenever\n`D` is a concrete category for which the forgetful functor preserves the appropriate (co)limits\nand reflects isomorphisms.\n\nWe generally follow the approach of https://stacks.math.columbia.edu/tag/00W1\n\n-/\n\n\nnamespace CategoryTheory\n\nopen CategoryTheory.Limits Opposite\n\nuniverse w v u\n\nvariable {C : Type u} [Category.{v} C] {J : GrothendieckTopology C}\n\nvariable {D : Type w} [Category.{max v u} D]\n\nsection\n\nvariable [ConcreteCategory.{max v u} D]\n\nattribute [local instance] concrete_category.has_coe_to_sort concrete_category.has_coe_to_fun\n\n/-- A concrete version of the multiequalizer, to be used below. -/\n@[nolint has_nonempty_instance]\ndef Meq {X : C} (P : Cᵒᵖ ⥤ D) (S : J.cover X) :=\n  { x : ∀ I : S.arrow, P.obj (op I.y) //\n    ∀ I : S.Relation, P.map I.g₁.op (x I.fst) = P.map I.g₂.op (x I.snd) }\n#align category_theory.meq CategoryTheory.Meq\n\nend\n\nnamespace Meq\n\nvariable [ConcreteCategory.{max v u} D]\n\nattribute [local instance] concrete_category.has_coe_to_sort concrete_category.has_coe_to_fun\n\ninstance {X} (P : Cᵒᵖ ⥤ D) (S : J.cover X) :\n    CoeFun (Meq P S) fun x => ∀ I : S.arrow, P.obj (op I.y) :=\n  ⟨fun x => x.1⟩\n\n@[ext]\ntheorem ext {X} {P : Cᵒᵖ ⥤ D} {S : J.cover X} (x y : Meq P S) (h : ∀ I : S.arrow, x I = y I) :\n    x = y :=\n  Subtype.ext <| funext <| h\n#align category_theory.meq.ext CategoryTheory.Meq.ext\n\ntheorem condition {X} {P : Cᵒᵖ ⥤ D} {S : J.cover X} (x : Meq P S) (I : S.Relation) :\n    P.map I.g₁.op (x ((S.index P).fstTo I)) = P.map I.g₂.op (x ((S.index P).sndTo I)) :=\n  x.2 _\n#align category_theory.meq.condition CategoryTheory.Meq.condition\n\n/-- Refine a term of `meq P T` with respect to a refinement `S ⟶ T` of covers. -/\ndef refine {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.cover X} (x : Meq P T) (e : S ⟶ T) : Meq P S :=\n  ⟨fun I => x ⟨I.y, I.f, (leOfHom e) _ I.hf⟩, fun I =>\n    x.condition\n      ⟨I.y₁, I.y₂, I.z, I.g₁, I.g₂, I.f₁, I.f₂, (leOfHom e) _ I.h₁, (leOfHom e) _ I.h₂, I.w⟩⟩\n#align category_theory.meq.refine CategoryTheory.Meq.refine\n\n@[simp]\ntheorem refine_apply {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.cover X} (x : Meq P T) (e : S ⟶ T)\n    (I : S.arrow) : x.refine e I = x ⟨I.y, I.f, (leOfHom e) _ I.hf⟩ :=\n  rfl\n#align category_theory.meq.refine_apply CategoryTheory.Meq.refine_apply\n\n/-- Pull back a term of `meq P S` with respect to a morphism `f : Y ⟶ X` in `C`. -/\ndef pullback {Y X : C} {P : Cᵒᵖ ⥤ D} {S : J.cover X} (x : Meq P S) (f : Y ⟶ X) :\n    Meq P ((J.pullback f).obj S) :=\n  ⟨fun I => x ⟨_, I.f ≫ f, I.hf⟩, fun I =>\n    x.condition\n      ⟨I.y₁, I.y₂, I.z, I.g₁, I.g₂, I.f₁ ≫ f, I.f₂ ≫ f, I.h₁, I.h₂, by simp [reassoc_of I.w]⟩⟩\n#align category_theory.meq.pullback CategoryTheory.Meq.pullback\n\n@[simp]\ntheorem pullback_apply {Y X : C} {P : Cᵒᵖ ⥤ D} {S : J.cover X} (x : Meq P S) (f : Y ⟶ X)\n    (I : ((J.pullback f).obj S).arrow) : x.pullback f I = x ⟨_, I.f ≫ f, I.hf⟩ :=\n  rfl\n#align category_theory.meq.pullback_apply CategoryTheory.Meq.pullback_apply\n\n@[simp]\ntheorem pullback_refine {Y X : C} {P : Cᵒᵖ ⥤ D} {S T : J.cover X} (h : S ⟶ T) (f : Y ⟶ X)\n    (x : Meq P T) : (x.pullback f).refine ((J.pullback f).map h) = (refine x h).pullback _ :=\n  rfl\n#align category_theory.meq.pullback_refine CategoryTheory.Meq.pullback_refine\n\n/-- Make a term of `meq P S`. -/\ndef mk {X : C} {P : Cᵒᵖ ⥤ D} (S : J.cover X) (x : P.obj (op X)) : Meq P S :=\n  ⟨fun I => P.map I.f.op x, fun I => by\n    dsimp\n    simp only [← comp_apply, ← P.map_comp, ← op_comp, I.w]⟩\n#align category_theory.meq.mk CategoryTheory.Meq.mk\n\ntheorem mk_apply {X : C} {P : Cᵒᵖ ⥤ D} (S : J.cover X) (x : P.obj (op X)) (I : S.arrow) :\n    mk S x I = P.map I.f.op x :=\n  rfl\n#align category_theory.meq.mk_apply CategoryTheory.Meq.mk_apply\n\nvariable [PreservesLimits (forget D)]\n\n/-- The equivalence between the type associated to `multiequalizer (S.index P)` and `meq P S`. -/\nnoncomputable def equiv {X : C} (P : Cᵒᵖ ⥤ D) (S : J.cover X) [HasMultiequalizer (S.index P)] :\n    (multiequalizer (S.index P) : D) ≃ Meq P S :=\n  Limits.Concrete.multiequalizerEquiv _\n#align category_theory.meq.equiv CategoryTheory.Meq.equiv\n\n@[simp]\ntheorem equiv_apply {X : C} {P : Cᵒᵖ ⥤ D} {S : J.cover X} [HasMultiequalizer (S.index P)]\n    (x : multiequalizer (S.index P)) (I : S.arrow) :\n    equiv P S x I = Multiequalizer.ι (S.index P) I x :=\n  rfl\n#align category_theory.meq.equiv_apply CategoryTheory.Meq.equiv_apply\n\n@[simp]\ntheorem equiv_symm_eq_apply {X : C} {P : Cᵒᵖ ⥤ D} {S : J.cover X} [HasMultiequalizer (S.index P)]\n    (x : Meq P S) (I : S.arrow) : Multiequalizer.ι (S.index P) I ((Meq.equiv P S).symm x) = x I :=\n  by\n  let z := (meq.equiv P S).symm x\n  rw [← equiv_apply]\n  simp\n#align category_theory.meq.equiv_symm_eq_apply CategoryTheory.Meq.equiv_symm_eq_apply\n\nend Meq\n\nnamespace GrothendieckTopology\n\nnamespace Plus\n\nvariable [ConcreteCategory.{max v u} D]\n\nattribute [local instance] concrete_category.has_coe_to_sort concrete_category.has_coe_to_fun\n\nvariable [PreservesLimits (forget D)]\n\nvariable [∀ X : C, HasColimitsOfShape (J.cover X)ᵒᵖ D]\n\nvariable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.cover X), HasMultiequalizer (S.index P)]\n\nnoncomputable section\n\n/-- Make a term of `(J.plus_obj P).obj (op X)` from `x : meq P S`. -/\ndef mk {X : C} {P : Cᵒᵖ ⥤ D} {S : J.cover X} (x : Meq P S) : (J.plusObj P).obj (op X) :=\n  colimit.ι (J.diagram P X) (op S) ((Meq.equiv P S).symm x)\n#align category_theory.grothendieck_topology.plus.mk CategoryTheory.GrothendieckTopology.Plus.mk\n\ntheorem res_mk_eq_mk_pullback {Y X : C} {P : Cᵒᵖ ⥤ D} {S : J.cover X} (x : Meq P S) (f : Y ⟶ X) :\n    (J.plusObj P).map f.op (mk x) = mk (x.pullback f) :=\n  by\n  dsimp [mk, plus_obj]\n  simp only [← comp_apply, colimit.ι_pre, ι_colim_map_assoc]\n  simp_rw [comp_apply]\n  congr 1\n  apply_fun meq.equiv P _\n  erw [Equiv.apply_symm_apply]\n  ext i\n  simp only [diagram_pullback_app, meq.pullback_apply, meq.equiv_apply, ← comp_apply]\n  erw [multiequalizer.lift_ι, meq.equiv_symm_eq_apply]\n  cases i; rfl\n#align category_theory.grothendieck_topology.plus.res_mk_eq_mk_pullback CategoryTheory.GrothendieckTopology.Plus.res_mk_eq_mk_pullback\n\ntheorem toPlus_mk {X : C} {P : Cᵒᵖ ⥤ D} (S : J.cover X) (x : P.obj (op X)) :\n    (J.toPlus P).app _ x = mk (Meq.mk S x) :=\n  by\n  dsimp [mk, to_plus]\n  let e : S ⟶ ⊤ := hom_of_le (OrderTop.le_top _)\n  rw [← colimit.w _ e.op]\n  delta cover.to_multiequalizer\n  simp only [comp_apply]\n  congr 1\n  dsimp [diagram]\n  apply concrete.multiequalizer_ext\n  intro i\n  simpa only [← comp_apply, category.assoc, multiequalizer.lift_ι, category.comp_id,\n    meq.equiv_symm_eq_apply]\n#align category_theory.grothendieck_topology.plus.to_plus_mk CategoryTheory.GrothendieckTopology.Plus.toPlus_mk\n\ntheorem toPlus_apply {X : C} {P : Cᵒᵖ ⥤ D} (S : J.cover X) (x : Meq P S) (I : S.arrow) :\n    (J.toPlus P).app _ (x I) = (J.plusObj P).map I.f.op (mk x) :=\n  by\n  dsimp only [to_plus, plus_obj]\n  delta cover.to_multiequalizer\n  dsimp [mk]\n  simp only [← comp_apply, colimit.ι_pre, ι_colim_map_assoc]\n  simp only [comp_apply]\n  dsimp only [functor.op]\n  let e : (J.pullback I.f).obj (unop (op S)) ⟶ ⊤ := hom_of_le (OrderTop.le_top _)\n  rw [← colimit.w _ e.op]\n  simp only [comp_apply]\n  congr 1\n  apply concrete.multiequalizer_ext\n  intro i\n  dsimp [diagram]\n  simp only [← comp_apply, category.assoc, multiequalizer.lift_ι, category.comp_id,\n    meq.equiv_symm_eq_apply]\n  let RR : S.relation :=\n    ⟨_, _, _, i.f, 𝟙 _, I.f, i.f ≫ I.f, I.hf, sieve.downward_closed _ I.hf _, by simp⟩\n  cases I\n  erw [x.condition RR]\n  simpa [RR]\n#align category_theory.grothendieck_topology.plus.to_plus_apply CategoryTheory.GrothendieckTopology.Plus.toPlus_apply\n\ntheorem toPlus_eq_mk {X : C} {P : Cᵒᵖ ⥤ D} (x : P.obj (op X)) :\n    (J.toPlus P).app _ x = mk (Meq.mk ⊤ x) :=\n  by\n  dsimp [mk, to_plus]\n  delta cover.to_multiequalizer\n  simp only [comp_apply]\n  congr 1\n  apply_fun meq.equiv P ⊤\n  ext i\n  simpa\n#align category_theory.grothendieck_topology.plus.to_plus_eq_mk CategoryTheory.GrothendieckTopology.Plus.toPlus_eq_mk\n\nvariable [∀ X : C, PreservesColimitsOfShape (J.cover X)ᵒᵖ (forget D)]\n\ntheorem exists_rep {X : C} {P : Cᵒᵖ ⥤ D} (x : (J.plusObj P).obj (op X)) :\n    ∃ (S : J.cover X)(y : Meq P S), x = mk y :=\n  by\n  obtain ⟨S, y, h⟩ := concrete.colimit_exists_rep (J.diagram P X) x\n  use S.unop, meq.equiv _ _ y\n  rw [← h]\n  dsimp [mk]\n  simp\n#align category_theory.grothendieck_topology.plus.exists_rep CategoryTheory.GrothendieckTopology.Plus.exists_rep\n\ntheorem eq_mk_iff_exists {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.cover X} (x : Meq P S) (y : Meq P T) :\n    mk x = mk y ↔ ∃ (W : J.cover X)(h1 : W ⟶ S)(h2 : W ⟶ T), x.refine h1 = y.refine h2 :=\n  by\n  constructor\n  · intro h\n    obtain ⟨W, h1, h2, hh⟩ := concrete.colimit_exists_of_rep_eq _ _ _ h\n    use W.unop, h1.unop, h2.unop\n    ext I\n    apply_fun multiequalizer.ι (W.unop.index P) I  at hh\n    convert hh\n    all_goals\n      dsimp [diagram]\n      simp only [← comp_apply, multiequalizer.lift_ι, category.comp_id, meq.equiv_symm_eq_apply]\n      cases I; rfl\n  · rintro ⟨S, h1, h2, e⟩\n    apply concrete.colimit_rep_eq_of_exists\n    use op S, h1.op, h2.op\n    apply concrete.multiequalizer_ext\n    intro i\n    apply_fun fun ee => ee i  at e\n    convert e\n    all_goals\n      dsimp [diagram]\n      simp only [← comp_apply, multiequalizer.lift_ι, meq.equiv_symm_eq_apply]\n      cases i; rfl\n#align category_theory.grothendieck_topology.plus.eq_mk_iff_exists CategoryTheory.GrothendieckTopology.Plus.eq_mk_iff_exists\n\n/-- `P⁺` is always separated. -/\ntheorem sep {X : C} (P : Cᵒᵖ ⥤ D) (S : J.cover X) (x y : (J.plusObj P).obj (op X))\n    (h : ∀ I : S.arrow, (J.plusObj P).map I.f.op x = (J.plusObj P).map I.f.op y) : x = y :=\n  by\n  -- First, we choose representatives for x and y.\n  obtain ⟨Sx, x, rfl⟩ := exists_rep x\n  obtain ⟨Sy, y, rfl⟩ := exists_rep y\n  simp only [res_mk_eq_mk_pullback] at h\n  -- Next, using our assumption,\n  -- choose covers over which the pullbacks of these representatives become equal.\n  choose W h1 h2 hh using fun I : S.arrow => (eq_mk_iff_exists _ _).mp (h I)\n  -- To prove equality, it suffices to prove that there exists a cover over which\n  -- the representatives become equal.\n  rw [eq_mk_iff_exists]\n  -- Construct the cover over which the representatives become equal by combining the various\n  -- covers chosen above.\n  let B : J.cover X := S.bind W\n  use B\n  -- Prove that this cover refines the two covers over which our representatives are defined\n  -- and use these proofs.\n  let ex : B ⟶ Sx :=\n    hom_of_le\n      (by\n        rintro Y f ⟨Z, e1, e2, he2, he1, hee⟩\n        rw [← hee]\n        apply le_of_hom (h1 ⟨_, _, he2⟩)\n        exact he1)\n  let ey : B ⟶ Sy :=\n    hom_of_le\n      (by\n        rintro Y f ⟨Z, e1, e2, he2, he1, hee⟩\n        rw [← hee]\n        apply le_of_hom (h2 ⟨_, _, he2⟩)\n        exact he1)\n  use ex, ey\n  -- Now prove that indeed the representatives become equal over `B`.\n  -- This will follow by using the fact that our representatives become\n  -- equal over the chosen covers.\n  ext1 I\n  let IS : S.arrow := I.from_middle\n  specialize hh IS\n  let IW : (W IS).arrow := I.to_middle\n  apply_fun fun e => e IW  at hh\n  convert hh\n  · let Rx : Sx.relation :=\n      ⟨I.Y, I.Y, I.Y, 𝟙 _, 𝟙 _, I.f, I.to_middle_hom ≫ I.from_middle_hom, _, _, by\n        simp [I.middle_spec]⟩\n    have := x.condition Rx\n    simpa using this\n  · let Ry : Sy.relation :=\n      ⟨I.Y, I.Y, I.Y, 𝟙 _, 𝟙 _, I.f, I.to_middle_hom ≫ I.from_middle_hom, _, _, by\n        simp [I.middle_spec]⟩\n    have := y.condition Ry\n    simpa using this\n#align category_theory.grothendieck_topology.plus.sep CategoryTheory.GrothendieckTopology.Plus.sep\n\ntheorem inj_of_sep (P : Cᵒᵖ ⥤ D)\n    (hsep :\n      ∀ (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (∀ I : S.arrow, P.map I.f.op x = P.map I.f.op y) → x = y)\n    (X : C) : Function.Injective ((J.toPlus P).app (op X)) :=\n  by\n  intro x y h\n  simp only [to_plus_eq_mk] at h\n  rw [eq_mk_iff_exists] at h\n  obtain ⟨W, h1, h2, hh⟩ := h\n  apply hsep X W\n  intro I\n  apply_fun fun e => e I  at hh\n  exact hh\n#align category_theory.grothendieck_topology.plus.inj_of_sep CategoryTheory.GrothendieckTopology.Plus.inj_of_sep\n\n/-- An auxiliary definition to be used in the proof of `exists_of_sep` below.\n  Given a compatible family of local sections for `P⁺`, and representatives of said sections,\n  construct a compatible family of local sections of `P` over the combination of the covers\n  associated to the representatives.\n  The separatedness condition is used to prove compatibility among these local sections of `P`. -/\ndef meqOfSep (P : Cᵒᵖ ⥤ D)\n    (hsep :\n      ∀ (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (∀ I : S.arrow, P.map I.f.op x = P.map I.f.op y) → x = y)\n    (X : C) (S : J.cover X) (s : Meq (J.plusObj P) S) (T : ∀ I : S.arrow, J.cover I.y)\n    (t : ∀ I : S.arrow, Meq P (T I)) (ht : ∀ I : S.arrow, s I = mk (t I)) : Meq P (S.bind T)\n    where\n  val I := t I.fromMiddle I.toMiddle\n  property := by\n    intro II\n    apply inj_of_sep P hsep\n    rw [← comp_apply, ← comp_apply, (J.to_plus P).naturality, (J.to_plus P).naturality, comp_apply,\n      comp_apply]\n    erw [to_plus_apply (T II.fst.from_middle) (t II.fst.from_middle) II.fst.to_middle,\n      to_plus_apply (T II.snd.from_middle) (t II.snd.from_middle) II.snd.to_middle, ← ht, ← ht, ←\n      comp_apply, ← comp_apply, ← (J.plus_obj P).map_comp, ← (J.plus_obj P).map_comp]\n    rw [← op_comp, ← op_comp]\n    let IR : S.relation :=\n      ⟨_, _, _, II.g₁ ≫ II.fst.to_middle_hom, II.g₂ ≫ II.snd.to_middle_hom, II.fst.from_middle_hom,\n        II.snd.from_middle_hom, II.fst.from_middle_condition, II.snd.from_middle_condition, _⟩\n    swap;\n    · simp only [category.assoc, II.fst.middle_spec, II.snd.middle_spec]\n      apply II.w\n    exact s.condition IR\n#align category_theory.grothendieck_topology.plus.meq_of_sep CategoryTheory.GrothendieckTopology.Plus.meqOfSep\n\ntheorem exists_of_sep (P : Cᵒᵖ ⥤ D)\n    (hsep :\n      ∀ (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (∀ I : S.arrow, P.map I.f.op x = P.map I.f.op y) → x = y)\n    (X : C) (S : J.cover X) (s : Meq (J.plusObj P) S) :\n    ∃ t : (J.plusObj P).obj (op X), Meq.mk S t = s :=\n  by\n  have inj : ∀ X : C, Function.Injective ((J.to_plus P).app (op X)) := inj_of_sep _ hsep\n  -- Choose representatives for the given local sections.\n  choose T t ht using fun I => exists_rep (s I)\n  -- Construct a large cover over which we will define a representative that will\n  -- provide the gluing of the given local sections.\n  let B : J.cover X := S.bind T\n  choose Z e1 e2 he2 he1 hee using fun I : B.arrow => I.hf\n  -- Construct a compatible system of local sections over this large cover, using the chosen\n  -- representatives of our local sections.\n  -- The compatilibity here follows from the separatedness assumption.\n  let w : meq P B := meq_of_sep P hsep X S s T t ht\n  -- The associated gluing will be the candidate section.\n  use mk w\n  ext I\n  erw [ht, res_mk_eq_mk_pullback]\n  -- Use the separatedness of `P⁺` to prove that this is indeed a gluing of our\n  -- original local sections.\n  apply sep P (T I)\n  intro II\n  simp only [res_mk_eq_mk_pullback, eq_mk_iff_exists]\n  -- It suffices to prove equality for representatives over a\n  -- convenient sufficiently large cover...\n  use (J.pullback II.f).obj (T I)\n  let e0 : (J.pullback II.f).obj (T I) ⟶ (J.pullback II.f).obj ((J.pullback I.f).obj B) :=\n    hom_of_le\n      (by\n        intro Y f hf\n        apply sieve.le_pullback_bind _ _ _ I.hf\n        · cases I\n          exact hf)\n  use e0, 𝟙 _\n  ext IV\n  dsimp only [meq.refine_apply, meq.pullback_apply, w]\n  let IA : B.arrow := ⟨_, (IV.f ≫ II.f) ≫ I.f, _⟩\n  swap\n  · refine' ⟨I.Y, _, _, I.hf, _, rfl⟩\n    apply sieve.downward_closed\n    convert II.hf\n    cases I\n    rfl\n  let IB : S.arrow := IA.from_middle\n  let IC : (T IB).arrow := IA.to_middle\n  let ID : (T I).arrow := ⟨IV.Y, IV.f ≫ II.f, sieve.downward_closed (T I) II.hf IV.f⟩\n  change t IB IC = t I ID\n  apply inj IV.Y\n  erw [to_plus_apply (T I) (t I) ID, to_plus_apply (T IB) (t IB) IC, ← ht, ← ht]\n  -- Conclude by constructing the relation showing equality...\n  let IR : S.relation := ⟨_, _, IV.Y, IC.f, ID.f, IB.f, I.f, _, I.hf, IA.middle_spec⟩\n  convert s.condition IR\n  cases I; rfl\n#align category_theory.grothendieck_topology.plus.exists_of_sep CategoryTheory.GrothendieckTopology.Plus.exists_of_sep\n\nvariable [ReflectsIsomorphisms (forget D)]\n\n/-- If `P` is separated, then `P⁺` is a sheaf. -/\ntheorem isSheaf_of_sep (P : Cᵒᵖ ⥤ D)\n    (hsep :\n      ∀ (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (∀ I : S.arrow, P.map I.f.op x = P.map I.f.op y) → x = y) :\n    Presheaf.IsSheaf J (J.plusObj P) :=\n  by\n  rw [presheaf.is_sheaf_iff_multiequalizer]\n  intro X S\n  apply is_iso_of_reflects_iso _ (forget D)\n  rw [is_iso_iff_bijective]\n  constructor\n  · intro x y h\n    apply sep P S _ _\n    intro I\n    apply_fun meq.equiv _ _  at h\n    apply_fun fun e => e I  at h\n    convert h\n    · erw [meq.equiv_apply, ← comp_apply, multiequalizer.lift_ι]\n    · erw [meq.equiv_apply, ← comp_apply, multiequalizer.lift_ι]\n  · rintro (x : (multiequalizer (S.index _) : D))\n    obtain ⟨t, ht⟩ := exists_of_sep P hsep X S (meq.equiv _ _ x)\n    use t\n    apply_fun meq.equiv _ _\n    swap\n    · infer_instance\n    rw [← ht]\n    ext i\n    dsimp\n    rw [← comp_apply, multiequalizer.lift_ι]\n    rfl\n#align category_theory.grothendieck_topology.plus.is_sheaf_of_sep CategoryTheory.GrothendieckTopology.Plus.isSheaf_of_sep\n\nvariable (J)\n\n/-- `P⁺⁺` is always a sheaf. -/\ntheorem isSheaf_plus_plus (P : Cᵒᵖ ⥤ D) : Presheaf.IsSheaf J (J.plusObj (J.plusObj P)) :=\n  by\n  apply is_sheaf_of_sep\n  intro X S x y\n  apply sep\n#align category_theory.grothendieck_topology.plus.is_sheaf_plus_plus CategoryTheory.GrothendieckTopology.Plus.isSheaf_plus_plus\n\nend Plus\n\nvariable (J)\n\nvariable [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.cover X), HasMultiequalizer (S.index P)]\n  [∀ X : C, HasColimitsOfShape (J.cover X)ᵒᵖ D]\n\n/-- The sheafification of a presheaf `P`.\n*NOTE:* Additional hypotheses are needed to obtain a proof that this is a sheaf! -/\ndef sheafify (P : Cᵒᵖ ⥤ D) : Cᵒᵖ ⥤ D :=\n  J.plusObj (J.plusObj P)\n#align category_theory.grothendieck_topology.sheafify CategoryTheory.GrothendieckTopology.sheafify\n\n/-- The canonical map from `P` to its sheafification. -/\ndef toSheafify (P : Cᵒᵖ ⥤ D) : P ⟶ J.sheafify P :=\n  J.toPlus P ≫ J.plusMap (J.toPlus P)\n#align category_theory.grothendieck_topology.to_sheafify CategoryTheory.GrothendieckTopology.toSheafify\n\n/-- The canonical map on sheafifications induced by a morphism. -/\ndef sheafifyMap {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) : J.sheafify P ⟶ J.sheafify Q :=\n  J.plusMap <| J.plusMap η\n#align category_theory.grothendieck_topology.sheafify_map CategoryTheory.GrothendieckTopology.sheafifyMap\n\n@[simp]\ntheorem sheafifyMap_id (P : Cᵒᵖ ⥤ D) : J.sheafifyMap (𝟙 P) = 𝟙 (J.sheafify P) :=\n  by\n  dsimp [sheafify_map, sheafify]\n  simp\n#align category_theory.grothendieck_topology.sheafify_map_id CategoryTheory.GrothendieckTopology.sheafifyMap_id\n\n@[simp]\ntheorem sheafifyMap_comp {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) :\n    J.sheafifyMap (η ≫ γ) = J.sheafifyMap η ≫ J.sheafifyMap γ :=\n  by\n  dsimp [sheafify_map, sheafify]\n  simp\n#align category_theory.grothendieck_topology.sheafify_map_comp CategoryTheory.GrothendieckTopology.sheafifyMap_comp\n\n@[simp, reassoc.1]\ntheorem toSheafify_naturality {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) :\n    η ≫ J.toSheafify _ = J.toSheafify _ ≫ J.sheafifyMap η :=\n  by\n  dsimp [sheafify_map, sheafify, to_sheafify]\n  simp\n#align category_theory.grothendieck_topology.to_sheafify_naturality CategoryTheory.GrothendieckTopology.toSheafify_naturality\n\nvariable (D)\n\n/-- The sheafification of a presheaf `P`, as a functor.\n*NOTE:* Additional hypotheses are needed to obtain a proof that this is a sheaf! -/\ndef sheafification : (Cᵒᵖ ⥤ D) ⥤ Cᵒᵖ ⥤ D :=\n  J.plusFunctor D ⋙ J.plusFunctor D\n#align category_theory.grothendieck_topology.sheafification CategoryTheory.GrothendieckTopology.sheafification\n\n@[simp]\ntheorem sheafification_obj (P : Cᵒᵖ ⥤ D) : (J.sheafification D).obj P = J.sheafify P :=\n  rfl\n#align category_theory.grothendieck_topology.sheafification_obj CategoryTheory.GrothendieckTopology.sheafification_obj\n\n@[simp]\ntheorem sheafification_map {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) :\n    (J.sheafification D).map η = J.sheafifyMap η :=\n  rfl\n#align category_theory.grothendieck_topology.sheafification_map CategoryTheory.GrothendieckTopology.sheafification_map\n\n/-- The canonical map from `P` to its sheafification, as a natural transformation.\n*Note:* We only show this is a sheaf under additional hypotheses on `D`. -/\ndef toSheafification : 𝟭 _ ⟶ sheafification J D :=\n  J.toPlusNatTrans D ≫ whiskerRight (J.toPlusNatTrans D) (J.plusFunctor D)\n#align category_theory.grothendieck_topology.to_sheafification CategoryTheory.GrothendieckTopology.toSheafification\n\n@[simp]\ntheorem toSheafification_app (P : Cᵒᵖ ⥤ D) : (J.toSheafification D).app P = J.toSheafify P :=\n  rfl\n#align category_theory.grothendieck_topology.to_sheafification_app CategoryTheory.GrothendieckTopology.toSheafification_app\n\nvariable {D}\n\ntheorem isIso_toSheafify {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : IsIso (J.toSheafify P) :=\n  by\n  dsimp [to_sheafify]\n  haveI : is_iso (J.to_plus P) := by apply is_iso_to_plus_of_is_sheaf J P hP\n  haveI : is_iso ((J.plus_functor D).map (J.to_plus P)) := by apply functor.map_is_iso\n  exact @is_iso.comp_is_iso _ _ _ _ _ (J.to_plus P) ((J.plus_functor D).map (J.to_plus P)) _ _\n#align category_theory.grothendieck_topology.is_iso_to_sheafify CategoryTheory.GrothendieckTopology.isIso_toSheafify\n\n/-- If `P` is a sheaf, then `P` is isomorphic to `J.sheafify P`. -/\ndef isoSheafify {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : P ≅ J.sheafify P :=\n  letI := is_iso_to_sheafify J hP\n  as_iso (J.to_sheafify P)\n#align category_theory.grothendieck_topology.iso_sheafify CategoryTheory.GrothendieckTopology.isoSheafify\n\n@[simp]\ntheorem isoSheafify_hom {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) :\n    (J.isoSheafify hP).Hom = J.toSheafify P :=\n  rfl\n#align category_theory.grothendieck_topology.iso_sheafify_hom CategoryTheory.GrothendieckTopology.isoSheafify_hom\n\n/-- Given a sheaf `Q` and a morphism `P ⟶ Q`, construct a morphism from\n`J.sheafifcation P` to `Q`. -/\ndef sheafifyLift {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : Presheaf.IsSheaf J Q) : J.sheafify P ⟶ Q :=\n  J.plusLift (J.plusLift η hQ) hQ\n#align category_theory.grothendieck_topology.sheafify_lift CategoryTheory.GrothendieckTopology.sheafifyLift\n\n@[simp, reassoc.1]\ntheorem toSheafify_sheafifyLift {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : Presheaf.IsSheaf J Q) :\n    J.toSheafify P ≫ sheafifyLift J η hQ = η :=\n  by\n  dsimp only [sheafify_lift, to_sheafify]\n  simp\n#align category_theory.grothendieck_topology.to_sheafify_sheafify_lift CategoryTheory.GrothendieckTopology.toSheafify_sheafifyLift\n\ntheorem sheafifyLift_unique {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : Presheaf.IsSheaf J Q)\n    (γ : J.sheafify P ⟶ Q) : J.toSheafify P ≫ γ = η → γ = sheafifyLift J η hQ :=\n  by\n  intro h\n  apply plus_lift_unique\n  apply plus_lift_unique\n  rw [← category.assoc, ← plus_map_to_plus]\n  exact h\n#align category_theory.grothendieck_topology.sheafify_lift_unique CategoryTheory.GrothendieckTopology.sheafifyLift_unique\n\n@[simp]\ntheorem isoSheafify_inv {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) :\n    (J.isoSheafify hP).inv = J.sheafifyLift (𝟙 _) hP :=\n  by\n  apply J.sheafify_lift_unique\n  simp [iso.comp_inv_eq]\n#align category_theory.grothendieck_topology.iso_sheafify_inv CategoryTheory.GrothendieckTopology.isoSheafify_inv\n\ntheorem sheafify_hom_ext {P Q : Cᵒᵖ ⥤ D} (η γ : J.sheafify P ⟶ Q) (hQ : Presheaf.IsSheaf J Q)\n    (h : J.toSheafify P ≫ η = J.toSheafify P ≫ γ) : η = γ :=\n  by\n  apply J.plus_hom_ext _ _ hQ\n  apply J.plus_hom_ext _ _ hQ\n  rw [← category.assoc, ← category.assoc, ← plus_map_to_plus]\n  exact h\n#align category_theory.grothendieck_topology.sheafify_hom_ext CategoryTheory.GrothendieckTopology.sheafify_hom_ext\n\n@[simp, reassoc.1]\ntheorem sheafifyMap_sheafifyLift {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R)\n    (hR : Presheaf.IsSheaf J R) :\n    J.sheafifyMap η ≫ J.sheafifyLift γ hR = J.sheafifyLift (η ≫ γ) hR :=\n  by\n  apply J.sheafify_lift_unique\n  rw [← category.assoc, ← J.to_sheafify_naturality, category.assoc, to_sheafify_sheafify_lift]\n#align category_theory.grothendieck_topology.sheafify_map_sheafify_lift CategoryTheory.GrothendieckTopology.sheafifyMap_sheafifyLift\n\nend GrothendieckTopology\n\nvariable (J)\n\nvariable [ConcreteCategory.{max v u} D] [PreservesLimits (forget D)]\n  [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.cover X), HasMultiequalizer (S.index P)]\n  [∀ X : C, HasColimitsOfShape (J.cover X)ᵒᵖ D]\n  [∀ X : C, PreservesColimitsOfShape (J.cover X)ᵒᵖ (forget D)] [ReflectsIsomorphisms (forget D)]\n\ntheorem GrothendieckTopology.sheafify_isSheaf (P : Cᵒᵖ ⥤ D) : Presheaf.IsSheaf J (J.sheafify P) :=\n  GrothendieckTopology.Plus.isSheaf_plus_plus _ _\n#align category_theory.grothendieck_topology.sheafify_is_sheaf CategoryTheory.GrothendieckTopology.sheafify_isSheaf\n\nvariable (D)\n\n/-- The sheafification functor, as a functor taking values in `Sheaf`. -/\n@[simps]\ndef presheafToSheaf : (Cᵒᵖ ⥤ D) ⥤ Sheaf J D\n    where\n  obj P := ⟨J.sheafify P, J.sheafify_isSheaf P⟩\n  map P Q η := ⟨J.sheafifyMap η⟩\n  map_id' P := Sheaf.Hom.ext _ _ <| J.sheafifyMap_id _\n  map_comp' P Q R f g := Sheaf.Hom.ext _ _ <| J.sheafifyMap_comp _ _\n#align category_theory.presheaf_to_Sheaf CategoryTheory.presheafToSheaf\n\ninstance presheafToSheaf_preservesZeroMorphisms [Preadditive D] :\n    (presheafToSheaf J D).PreservesZeroMorphisms\n    where map_zero' F G := by\n    ext\n    erw [colimit.ι_map, comp_zero, J.plus_map_zero, J.diagram_nat_trans_zero, zero_comp]\n#align category_theory.presheaf_to_Sheaf_preserves_zero_morphisms CategoryTheory.presheafToSheaf_preservesZeroMorphisms\n\n/-- The sheafification functor is left adjoint to the forgetful functor. -/\n@[simps unit_app counit_app_val]\ndef sheafificationAdjunction : presheafToSheaf J D ⊣ sheafToPresheaf J D :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun P Q =>\n        { toFun := fun e => J.toSheafify P ≫ e.val\n          invFun := fun e => ⟨J.sheafifyLift e Q.2⟩\n          left_inv := fun e => Sheaf.Hom.ext _ _ <| (J.sheafifyLift_unique _ _ _ rfl).symm\n          right_inv := fun e => J.toSheafify_sheafifyLift _ _ }\n      homEquiv_naturality_left_symm := by\n        intro P Q R η γ; ext1; dsimp; symm\n        apply J.sheafify_map_sheafify_lift\n      homEquiv_naturality_right := fun P Q R η γ =>\n        by\n        dsimp\n        rw [category.assoc] }\n#align category_theory.sheafification_adjunction CategoryTheory.sheafificationAdjunction\n\ninstance sheafToPresheafIsRightAdjoint : IsRightAdjoint (sheafToPresheaf J D) :=\n  ⟨_, sheafificationAdjunction J D⟩\n#align category_theory.Sheaf_to_presheaf_is_right_adjoint CategoryTheory.sheafToPresheafIsRightAdjoint\n\ninstance presheaf_mono_of_mono {F G : Sheaf J D} (f : F ⟶ G) [Mono f] : Mono f.1 :=\n  (sheafToPresheaf J D).map_mono _\n#align category_theory.presheaf_mono_of_mono CategoryTheory.presheaf_mono_of_mono\n\ntheorem Sheaf.Hom.mono_iff_presheaf_mono {F G : Sheaf J D} (f : F ⟶ G) : Mono f ↔ Mono f.1 :=\n  ⟨fun m => by\n    skip\n    infer_instance, fun m => by\n    skip\n    exact Sheaf.hom.mono_of_presheaf_mono J D f⟩\n#align category_theory.Sheaf.hom.mono_iff_presheaf_mono CategoryTheory.Sheaf.Hom.mono_iff_presheaf_mono\n\nvariable {J D}\n\n/-- A sheaf `P` is isomorphic to its own sheafification. -/\n@[simps]\ndef sheafificationIso (P : Sheaf J D) : P ≅ (presheafToSheaf J D).obj P.val\n    where\n  Hom := ⟨(J.isoSheafify P.2).Hom⟩\n  inv := ⟨(J.isoSheafify P.2).inv⟩\n  hom_inv_id' := by\n    ext1\n    apply (J.iso_sheafify P.2).hom_inv_id\n  inv_hom_id' := by\n    ext1\n    apply (J.iso_sheafify P.2).inv_hom_id\n#align category_theory.sheafification_iso CategoryTheory.sheafificationIso\n\ninstance isIso_sheafificationAdjunction_counit (P : Sheaf J D) :\n    IsIso ((sheafificationAdjunction J D).counit.app P) :=\n  isIso_of_fully_faithful (sheafToPresheaf J D) _\n#align category_theory.is_iso_sheafification_adjunction_counit CategoryTheory.isIso_sheafificationAdjunction_counit\n\ninstance sheafification_reflective : IsIso (sheafificationAdjunction J D).counit :=\n  NatIso.isIso_of_isIso_app _\n#align category_theory.sheafification_reflective CategoryTheory.sheafification_reflective\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Sites/Sheafification.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.47416751162586435}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Scott Morrison\n-/\nimport algebraic_geometry.prime_spectrum\nimport algebra.category.CommRing.colimits\nimport algebra.category.CommRing.limits\nimport topology.sheaves.local_predicate\nimport topology.sheaves.forget\nimport ring_theory.localization\nimport ring_theory.subring\n\n/-!\n# The structure sheaf on `prime_spectrum R`.\n\nWe define the structure sheaf on `Top.of (prime_spectrum R)`, for a commutative ring `R`.\nWe define this as a subsheaf of the sheaf of dependent functions into the localizations,\ncut out by the condition that the function must be locally equal to a ratio of elements of `R`.\n\nBecause the condition \"is equal to a fraction\" passes to smaller open subsets,\nthe subset of functions satisfying this condition is automatically a subpresheaf.\nBecause the condition \"is locally equal to a fraction\" is local,\nit is also a subsheaf.\n\n(It may be helpful to refer back to `topology.sheaves.sheaf_of_functions`,\nwhere we show that dependent functions into any type family form a sheaf,\nand also `topology.sheaves.local_predicate`, where we characterise the predicates\nwhich pick out sub-presheaves and sub-sheaves of these sheaves.)\n\nWe also set up the ring structure, obtaining\n`structure_sheaf R : sheaf CommRing (Top.of (prime_spectrum R))`.\n-/\n\nuniverse u\n\nnoncomputable theory\n\nvariables (R : Type u) [comm_ring R]\n\nopen Top\nopen topological_space\nopen category_theory\nopen opposite\n\nnamespace algebraic_geometry\n\n/--\n$Spec R$, just as a topological space.\n-/\ndef Spec.Top : Top := Top.of (prime_spectrum R)\n\nnamespace structure_sheaf\n\n/--\nThe type family over `prime_spectrum R` consisting of the localization over each point.\n-/\n@[derive [comm_ring, local_ring]]\ndef localizations (P : Spec.Top R) : Type u := localization.at_prime P.as_ideal\n\ninstance (P : Spec.Top R) : inhabited (localizations R P) :=\n⟨(localization.of _).to_map 1⟩\n\nvariables {R}\n\n/--\nThe predicate saying that a dependent function on an open `U` is realised as a fixed fraction\n`r / s` in each of the stalks (which are localizations at various prime ideals).\n-/\ndef is_fraction {U : opens (Spec.Top R)} (f : Π x : U, localizations R x) : Prop :=\n∃ (r s : R), ∀ x : U,\n  ¬ (s ∈ x.1.as_ideal) ∧ f x * (localization.of _).to_map s = (localization.of _).to_map r\n\nvariables (R)\n\n/--\nThe predicate `is_fraction` is \"prelocal\",\nin the sense that if it holds on `U` it holds on any open subset `V` of `U`.\n-/\ndef is_fraction_prelocal : prelocal_predicate (localizations R) :=\n{ pred := λ U f, is_fraction f,\n  res := by { rintro V U i f ⟨r, s, w⟩, exact ⟨r, s, λ x, w (i x)⟩ } }\n\n/--\nWe will define the structure sheaf as\nthe subsheaf of all dependent functions in `Π x : U, localizations R x`\nconsisting of those functions which can locally be expressed as a ratio of\n(the images in the localization of) elements of `R`.\n\nQuoting Hartshorne:\n\nFor an open set $U ⊆ Spec A$, we define $𝒪(U)$ to be the set of functions\n$s : U → ⨆_{𝔭 ∈ U} A_𝔭$, such that $s(𝔭) ∈ A_𝔭$ for each $𝔭$,\nand such that $s$ is locally a quotient of elements of $A$:\nto be precise, we require that for each $𝔭 ∈ U$, there is a neighborhood $V$ of $𝔭$,\ncontained in $U$, and elements $a, f ∈ A$, such that for each $𝔮 ∈ V, f ∉ 𝔮$,\nand $s(𝔮) = a/f$ in $A_𝔮$.\n\nNow Hartshorne had the disadvantage of not knowing about dependent functions,\nso we replace his circumlocution about functions into a disjoint union with\n`Π x : U, localizations x`.\n-/\ndef is_locally_fraction : local_predicate (localizations R) :=\n(is_fraction_prelocal R).sheafify\n\n@[simp]\nlemma is_locally_fraction_pred\n  {U : opens (Spec.Top R)} (f : Π x : U, localizations R x) :\n  (is_locally_fraction R).pred f =\n  ∀ x : U, ∃ (V) (m : x.1 ∈ V) (i : V ⟶ U),\n  ∃ (r s : R), ∀ y : V,\n  ¬ (s ∈ y.1.as_ideal) ∧\n    f (i y : U) * (localization.of _).to_map s = (localization.of _).to_map r :=\nrfl\n\n/--\nThe functions satisfying `is_locally_fraction` form a subring.\n-/\ndef sections_subring (U : (opens (Spec.Top R))ᵒᵖ) :\n  subring (Π x : unop U, localizations R x) :=\n{ carrier := { f | (is_locally_fraction R).pred f },\n  zero_mem' :=\n  begin\n    refine λ x, ⟨unop U, x.2, 𝟙 _, 0, 1, λ y, ⟨_, _⟩⟩,\n    { rw ←ideal.ne_top_iff_one, exact y.1.is_prime.1, },\n    { simp, },\n  end,\n  one_mem' :=\n  begin\n    refine λ x, ⟨unop U, x.2, 𝟙 _, 1, 1, λ y, ⟨_, _⟩⟩,\n    { rw ←ideal.ne_top_iff_one, exact y.1.is_prime.1, },\n    { simp, },\n  end,\n  add_mem' :=\n  begin\n    intros a b ha hb x,\n    rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩,\n    rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩,\n    refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ra * sb + rb * sa, sa * sb, _⟩,\n    intro y,\n    rcases wa (opens.inf_le_left _ _ y) with ⟨nma, wa⟩,\n    rcases wb (opens.inf_le_right _ _ y) with ⟨nmb, wb⟩,\n    fsplit,\n    { intro H, cases y.1.is_prime.mem_or_mem H; contradiction, },\n    { simp only [add_mul, ring_hom.map_add, pi.add_apply, ring_hom.map_mul],\n      erw [←wa, ←wb],\n      simp only [mul_assoc],\n      congr' 2,\n      rw [mul_comm], refl, }\n  end,\n  neg_mem' :=\n  begin\n    intros a ha x,\n    rcases ha x with ⟨V, m, i, r, s, w⟩,\n    refine ⟨V, m, i, -r, s, _⟩,\n    intro y,\n    rcases w y with ⟨nm, w⟩,\n    fsplit,\n    { exact nm, },\n    { simp only [ring_hom.map_neg, pi.neg_apply],\n      erw [←w],\n      simp only [neg_mul_eq_neg_mul_symm], }\n  end,\n  mul_mem' :=\n  begin\n    intros a b ha hb x,\n    rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩,\n    rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩,\n    refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ra * rb, sa * sb, _⟩,\n    intro y,\n    rcases wa (opens.inf_le_left _ _ y) with ⟨nma, wa⟩,\n    rcases wb (opens.inf_le_right _ _ y) with ⟨nmb, wb⟩,\n    fsplit,\n    { intro H, cases y.1.is_prime.mem_or_mem H; contradiction, },\n    { simp only [pi.mul_apply, ring_hom.map_mul],\n      erw [←wa, ←wb],\n      simp only [mul_left_comm, mul_assoc, mul_comm],\n      refl, }\n  end, }\n\nend structure_sheaf\n\nopen structure_sheaf\n\n/--\nThe structure sheaf (valued in `Type`, not yet `CommRing`) is the subsheaf consisting of\nfunctions satisfying `is_locally_fraction`.\n-/\ndef structure_sheaf_in_Type : sheaf (Type u) (Spec.Top R):=\nsubsheaf_to_Types (is_locally_fraction R)\n\ninstance comm_ring_structure_sheaf_in_Type_obj (U : (opens (Spec.Top R))ᵒᵖ) :\n  comm_ring ((structure_sheaf_in_Type R).presheaf.obj U) :=\n(sections_subring R U).to_comm_ring\n\nopen prime_spectrum\n\n/--\nThe structure presheaf, valued in `CommRing`, constructed by dressing up the `Type` valued\nstructure presheaf.\n-/\n@[simps]\ndef structure_presheaf_in_CommRing : presheaf CommRing (Spec.Top R) :=\n{ obj := λ U, CommRing.of ((structure_sheaf_in_Type R).presheaf.obj U),\n  map := λ U V i,\n  { to_fun := ((structure_sheaf_in_Type R).presheaf.map i),\n    map_zero' := rfl,\n    map_add' := λ x y, rfl,\n    map_one' := rfl,\n    map_mul' := λ x y, rfl, }, }\n\n/--\nSome glue, verifying that that structure presheaf valued in `CommRing` agrees\nwith the `Type` valued structure presheaf.\n-/\ndef structure_presheaf_comp_forget :\n  structure_presheaf_in_CommRing R ⋙ (forget CommRing) ≅ (structure_sheaf_in_Type R).presheaf :=\nnat_iso.of_components\n  (λ U, iso.refl _)\n  (by tidy)\n\nopen Top.presheaf\n\n/--\nThe structure sheaf on $Spec R$, valued in `CommRing`.\n\nThis is provided as a bundled `SheafedSpace` as `Spec.SheafedSpace R` later.\n-/\ndef structure_sheaf : sheaf CommRing (Spec.Top R) :=\n{ presheaf := structure_presheaf_in_CommRing R,\n  sheaf_condition :=\n    -- We check the sheaf condition under `forget CommRing`.\n    (sheaf_condition_equiv_sheaf_condition_comp _ _).symm\n      (sheaf_condition_equiv_of_iso (structure_presheaf_comp_forget R).symm\n        (structure_sheaf_in_Type R).sheaf_condition), }\n\n@[simp] lemma res_apply (U V : opens (Spec.Top R)) (i : V ⟶ U)\n  (s : (structure_sheaf R).presheaf.obj (op U)) (x : V) :\n  ((structure_sheaf R).presheaf.map i.op s).1 x = (s.1 (i x) : _) :=\nrfl\n\n/-\n\nNotation in this comment\n\nX = Spec R\nOX = structure sheaf\n\nIn the following we construct an isomorphism between OX_p and R_p given any point p corresponding\nto a prime ideal in R.\n\nWe do this via 8 steps:\n\n1. def const (f g : R) (V) (hv : V ≤ D_g) : OX(V) [for api]\n2. def to_open (U) : R ⟶ OX(U)\n3. [2] def to_stalk (p : Spec R) : R ⟶ OX_p\n4. [2] def to_basic_open (f : R) : R_f ⟶ OX(D_f)\n5. [3] def localization_to_stalk (p : Spec R) : R_p ⟶ OX_p\n6. def open_to_localization (U) (p) (hp : p ∈ U) : OX(U) ⟶ R_p\n7. [6] def stalk_to_fiber_ring_hom (p : Spec R) : OX_p ⟶ R_p\n8. [5,7] def stalk_iso (p : Spec R) : OX_p ≅ R_p\n\nIn the square brackets we list the dependencies of a construction on the previous steps.\n\n-/\n\n/-- The section of `structure_sheaf R` on an open `U` sending each `x ∈ U` to the element\n`f/g` in the localization of `R` at `x`. -/\ndef const (f g : R) (U : opens (Spec.Top R))\n  (hu : ∀ x ∈ U, g ∈ (x : Spec.Top R).as_ideal.prime_compl) :\n  (structure_sheaf R).presheaf.obj (op U) :=\n⟨λ x, (localization.of _).mk' f ⟨g, hu x x.2⟩,\n λ x, ⟨U, x.2, 𝟙 _, f, g, λ y, ⟨hu y y.2, localization_map.mk'_spec _ _ _⟩⟩⟩\n\n@[simp] lemma const_apply (f g : R) (U : opens (Spec.Top R))\n  (hu : ∀ x ∈ U, g ∈ (x : Spec.Top R).as_ideal.prime_compl) (x : U) :\n  (const R f g U hu).1 x = (localization.of _).mk' f ⟨g, hu x x.2⟩ :=\nrfl\n\nlemma const_apply' (f g : R) (U : opens (Spec.Top R))\n  (hu : ∀ x ∈ U, g ∈ (x : Spec.Top R).as_ideal.prime_compl) (x : U)\n  (hx : g ∈ (as_ideal x.1).prime_compl) :\n  (const R f g U hu).1 x = (localization.of _).mk' f ⟨g, hx⟩ :=\nrfl\n\nlemma exists_const (U) (s : (structure_sheaf R).presheaf.obj (op U)) (x : Spec.Top R) (hx : x ∈ U) :\n  ∃ (V : opens (Spec.Top R)) (hxV : x ∈ V) (i : V ⟶ U) (f g : R) hg,\n  const R f g V hg = (structure_sheaf R).presheaf.map i.op s :=\nlet ⟨V, hxV, iVU, f, g, hfg⟩ := s.2 ⟨x, hx⟩ in\n⟨V, hxV, iVU, f, g, λ y hyV, (hfg ⟨y, hyV⟩).1, subtype.eq $ funext $ λ y,\n(localization.of _).mk'_eq_iff_eq_mul.2 $ eq.symm $ (hfg y).2⟩\n\n@[simp] lemma res_const (f g : R) (U hu V hv i) :\n  (structure_sheaf R).presheaf.map i (const R f g U hu) = const R f g V hv :=\nrfl\n\nlemma res_const' (f g : R) (V hv) :\n  (structure_sheaf R).presheaf.map (hom_of_le hv).op (const R f g (basic_open g) (λ _, id)) =\n    const R f g V hv :=\nrfl\n\nlemma const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=\nsubtype.eq $ funext $ λ x, (localization.of _).mk'_eq_iff_eq_mul.2 $\nby erw [ring_hom.map_zero, subtype.val_eq_coe, subring.coe_zero, pi.zero_apply, zero_mul]\n\nlemma const_self (f : R) (U hu) : const R f f U hu = 1 :=\nsubtype.eq $ funext $ λ x, localization_map.mk'_self _ _\n\nlemma const_one (U) : const R 1 1 U (λ p _, submonoid.one_mem _) = 1 :=\nconst_self R 1 U _\n\nlemma const_add (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :\n  const R f₁ g₁ U hu₁ + const R f₂ g₂ U hu₂ =\n  const R (f₁ * g₂ + f₂ * g₁) (g₁ * g₂) U (λ x hx, submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx)) :=\nsubtype.eq $ funext $ λ x, eq.symm $\nby convert (localization.of _).mk'_add f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩\n\nlemma const_mul (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :\n  const R f₁ g₁ U hu₁ * const R f₂ g₂ U hu₂ =\n  const R (f₁ * f₂) (g₁ * g₂) U (λ x hx, submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx)) :=\nsubtype.eq $ funext $ λ x, eq.symm $\nby convert (localization.of _).mk'_mul f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩\n\nlemma const_ext {f₁ f₂ g₁ g₂ : R} {U hu₁ hu₂} (h : f₁ * g₂ = f₂ * g₁) :\n  const R f₁ g₁ U hu₁ = const R f₂ g₂ U hu₂ :=\nsubtype.eq $ funext $ λ x, (localization.of _).mk'_eq_of_eq h.symm\n\nlemma const_congr {f₁ f₂ g₁ g₂ : R} {U hu} (hf : f₁ = f₂) (hg : g₁ = g₂) :\n  const R f₁ g₁ U hu = const R f₂ g₂ U (hg ▸ hu) :=\nby substs hf hg\n\nlemma const_mul_rev (f g : R) (U hu₁ hu₂) :\n  const R f g U hu₁ * const R g f U hu₂ = 1 :=\nby rw [const_mul, const_congr R rfl (mul_comm g f), const_self]\n\nlemma const_mul_cancel (f g₁ g₂ : R) (U hu₁ hu₂) :\n  const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ :=\nby { rw [const_mul, const_ext], rw mul_assoc }\n\nlemma const_mul_cancel' (f g₁ g₂ : R) (U hu₁ hu₂) :\n  const R g₁ g₂ U hu₂ * const R f g₁ U hu₁ = const R f g₂ U hu₂ :=\nby rw [mul_comm, const_mul_cancel]\n\n/-- The canonical ring homomorphism interpreting an element of `R` as\na section of the structure sheaf. -/\ndef to_open (U : opens (Spec.Top R)) : CommRing.of R ⟶ (structure_sheaf R).presheaf.obj (op U) :=\n{ to_fun := λ f, ⟨λ x, (localization.of _).to_map f,\n    λ x, ⟨U, x.2, 𝟙 _, f, 1, λ y, ⟨(ideal.ne_top_iff_one _).1 y.1.2.1,\n      by { rw [ring_hom.map_one, mul_one], refl } ⟩⟩⟩,\n  map_one' := subtype.eq $ funext $ λ x, ring_hom.map_one _,\n  map_mul' := λ f g, subtype.eq $ funext $ λ x, ring_hom.map_mul _ _ _,\n  map_zero' := subtype.eq $ funext $ λ x, ring_hom.map_zero _,\n  map_add' := λ f g, subtype.eq $ funext $ λ x, ring_hom.map_add _ _ _ }\n\n@[simp] lemma to_open_res (U V : opens (Spec.Top R)) (i : V ⟶ U) :\n  to_open R U ≫ (structure_sheaf R).presheaf.map i.op = to_open R V :=\nrfl\n\n@[simp] lemma to_open_apply (U : opens (Spec.Top R)) (f : R) (x : U) :\n  (to_open R U f).1 x = (localization.of _).to_map f :=\nrfl\n\nlemma to_open_eq_const (U : opens (Spec.Top R)) (f : R) : to_open R U f =\n  const R f 1 U (λ x _, (ideal.ne_top_iff_one _).1 x.2.1) :=\nsubtype.eq $ funext $ λ x, eq.symm $ (localization.of _).mk'_one f\n\n/-- The canonical ring homomorphism interpreting an element of `R` as an element of\nthe stalk of `structure_sheaf R` at `x`. -/\ndef to_stalk (x : Spec.Top R) : CommRing.of R ⟶ (structure_sheaf R).presheaf.stalk x :=\n(to_open R ⊤ ≫ (structure_sheaf R).presheaf.germ ⟨x, ⟨⟩⟩ : _)\n\n@[simp] lemma to_open_germ (U : opens (Spec.Top R)) (x : U) :\n  to_open R U ≫ (structure_sheaf R).presheaf.germ x =\n  to_stalk R x :=\nby { rw [← to_open_res R ⊤ U (hom_of_le le_top : U ⟶ ⊤), category.assoc, presheaf.germ_res], refl }\n\n@[simp] lemma germ_to_open (U : opens (Spec.Top R)) (x : U) (f : R) :\n  (structure_sheaf R).presheaf.germ x (to_open R U f) = to_stalk R x f :=\nby { rw ← to_open_germ, refl }\n\nlemma germ_to_top (x : Spec.Top R) (f : R) :\n  (structure_sheaf R).presheaf.germ (⟨x, trivial⟩ : (⊤ : opens (Spec.Top R))) (to_open R ⊤ f) =\n    to_stalk R x f :=\nrfl\n\nlemma is_unit_to_basic_open_self (f : R) : is_unit (to_open R (basic_open f) f) :=\nis_unit_of_mul_eq_one _ (const R 1 f (basic_open f) (λ _, id)) $\nby rw [to_open_eq_const, const_mul_rev]\n\n/-- The canonical ring homomorphism interpreting `s ∈ R_f` as a section of the structure sheaf\non the basic open defined by `f ∈ R`. -/\ndef to_basic_open (f : R) : CommRing.of (localization (submonoid.powers f)) ⟶\n  (structure_sheaf R).presheaf.obj (op $ basic_open f) :=\nlocalization_map.away_map.lift f (localization.away.of f) (is_unit_to_basic_open_self R f)\n\n@[simp] lemma to_basic_open_mk' (s f : R) (g : submonoid.powers s) :\n  to_basic_open R s ((localization.of _).mk' f g) =\n  const R f g (basic_open s) (λ x hx, submonoid.powers_subset hx g.2) :=\n((localization.of _).lift_mk'_spec _ _ _ _).2 $\nby rw [to_open_eq_const, to_open_eq_const, const_mul_cancel']\n\n@[simp] lemma localization_to_basic_open (f : R) :\n  @category_theory.category_struct.comp _ _ (CommRing.of R)\n      (CommRing.of (localization (submonoid.powers f))) _\n    (localization.of $ submonoid.powers f).to_map\n    (to_basic_open R f) =\n  to_open R (basic_open f) :=\nring_hom.ext $ λ g, (localization.of _).lift_eq _ _\n\n@[simp] lemma to_basic_open_to_map (s f : R) : to_basic_open R s ((localization.of _).to_map f) =\n  const R f 1 (basic_open s) (λ _ _, submonoid.one_mem _) :=\n((localization.of _).lift_eq _ _).trans $ to_open_eq_const _ _ _\n\nlemma is_unit_to_stalk (x : Spec.Top R) (f : x.as_ideal.prime_compl) :\n  is_unit (to_stalk R x (f : R)) :=\nby { erw ← germ_to_open R (basic_open (f : R)) ⟨x, f.2⟩ (f : R),\n    exact ring_hom.is_unit_map _ (is_unit_to_basic_open_self R f) }\n\n/-- The canonical ring homomorphism from the localization of `R` at `p` to the stalk\nof the structure sheaf at the point `p`. -/\ndef localization_to_stalk (x : Spec.Top R) :\n  CommRing.of (localization.at_prime x.as_ideal) ⟶ (structure_sheaf R).presheaf.stalk x :=\n(localization.of _).lift (is_unit_to_stalk R x)\n\n@[simp] lemma localization_to_stalk_of (x : Spec.Top R) (f : R) :\n  localization_to_stalk R x ((localization.of _).to_map f) = to_stalk R x f :=\n(localization.of _).lift_eq _ f\n\n@[simp] lemma localization_to_stalk_mk' (x : Spec.Top R) (f : R) (s : (as_ideal x).prime_compl) :\n  localization_to_stalk R x ((localization.of _).mk' f s) =\n  (structure_sheaf R).presheaf.germ (⟨x, s.2⟩ : basic_open (s : R))\n    (const R f s (basic_open s) (λ _, id)) :=\n((localization.of _).lift_mk'_spec _ _ _ _).2 $\nby erw [← germ_to_open R (basic_open s) ⟨x, s.2⟩, ← germ_to_open R (basic_open s) ⟨x, s.2⟩,\n    ← ring_hom.map_mul, to_open_eq_const, to_open_eq_const, const_mul_cancel']\n\n/-- The ring homomorphism that takes a section of the structure sheaf of `R` on the open set `U`,\nimplemented as a subtype of dependent functions to localizations at prime ideals, and evaluates\nthe section on the point corresponding to a given prime ideal. -/\ndef open_to_localization (U : opens (Spec.Top R)) (x : Spec.Top R) (hx : x ∈ U) :\n  (structure_sheaf R).presheaf.obj (op U) ⟶ CommRing.of (localization.at_prime x.as_ideal) :=\n{ to_fun := λ s, (s.1 ⟨x, hx⟩ : _),\n  map_one' := rfl,\n  map_mul' := λ _ _, rfl,\n  map_zero' := rfl,\n  map_add' := λ _ _, rfl }\n\n@[simp] lemma coe_open_to_localization (U : opens (Spec.Top R)) (x : Spec.Top R) (hx : x ∈ U) :\n  (open_to_localization R U x hx :\n    (structure_sheaf R).presheaf.obj (op U) → localization.at_prime x.as_ideal) =\n  (λ s, (s.1 ⟨x, hx⟩ : _)) :=\nrfl\n\nlemma open_to_localization_apply (U : opens (Spec.Top R)) (x : Spec.Top R) (hx : x ∈ U)\n  (s : (structure_sheaf R).presheaf.obj (op U)) :\n  open_to_localization R U x hx s = (s.1 ⟨x, hx⟩ : _) :=\nrfl\n\n/-- The ring homomorphism from the stalk of the structure sheaf of `R` at a point corresponding to\na prime ideal `p` to the localization of `R` at `p`,\nformed by gluing the `open_to_localization` maps. -/\ndef stalk_to_fiber_ring_hom (x : Spec.Top R) :\n  (structure_sheaf R).presheaf.stalk x ⟶ CommRing.of (localization.at_prime x.as_ideal) :=\nlimits.colimit.desc (((open_nhds.inclusion x).op) ⋙ (structure_sheaf R).presheaf)\n  { X := _,\n    ι :=\n    { app := λ U, open_to_localization R ((open_nhds.inclusion _).obj (unop U)) x (unop U).2, } }\n\n@[simp] lemma germ_comp_stalk_to_fiber_ring_hom (U : opens (Spec.Top R)) (x : U) :\n  (structure_sheaf R).presheaf.germ x ≫ stalk_to_fiber_ring_hom R x =\n  open_to_localization R U x x.2 :=\nlimits.colimit.ι_desc _ _\n\n@[simp] lemma stalk_to_fiber_ring_hom_germ' (U : opens (Spec.Top R)) (x : Spec.Top R) (hx : x ∈ U)\n  (s : (structure_sheaf R).presheaf.obj (op U)) :\n  stalk_to_fiber_ring_hom R x ((structure_sheaf R).presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=\nring_hom.ext_iff.1 (germ_comp_stalk_to_fiber_ring_hom R U ⟨x, hx⟩ : _) s\n\n@[simp] lemma stalk_to_fiber_ring_hom_germ (U : opens (Spec.Top R)) (x : U)\n  (s : (structure_sheaf R).presheaf.obj (op U)) :\n  stalk_to_fiber_ring_hom R x ((structure_sheaf R).presheaf.germ x s) = s.1 x :=\nby { cases x, exact stalk_to_fiber_ring_hom_germ' R U _ _ _ }\n\n@[simp] lemma to_stalk_comp_stalk_to_fiber_ring_hom (x : Spec.Top R) :\n  to_stalk R x ≫ stalk_to_fiber_ring_hom R x = (localization.of _).to_map :=\nby { erw [to_stalk, category.assoc, germ_comp_stalk_to_fiber_ring_hom], refl }\n\n@[simp] lemma stalk_to_fiber_ring_hom_to_stalk (x : Spec.Top R) (f : R) :\n  stalk_to_fiber_ring_hom R x (to_stalk R x f) = (localization.of _).to_map f :=\nring_hom.ext_iff.1 (to_stalk_comp_stalk_to_fiber_ring_hom R x) _\n\n/-- The ring isomorphism between the stalk of the structure sheaf of `R` at a point `p`\ncorresponding to a prime ideal in `R` and the localization of `R` at `p`. -/\ndef stalk_iso (x : Spec.Top R) :\n  (structure_sheaf R).presheaf.stalk x ≅ CommRing.of (localization.at_prime x.as_ideal) :=\n{ hom := stalk_to_fiber_ring_hom R x,\n  inv := localization_to_stalk R x,\n  hom_inv_id' := (structure_sheaf R).presheaf.stalk_hom_ext $ λ U hxU,\n  begin\n    ext s, simp only [coe_comp], rw [coe_id, stalk_to_fiber_ring_hom_germ'],\n    obtain ⟨V, hxV, iVU, f, g, hg, hs⟩ := exists_const _ _ s x hxU,\n    erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localization_to_stalk_mk'],\n    refine (structure_sheaf R).presheaf.germ_ext V hxV (hom_of_le hg) iVU _,\n    erw [← hs, res_const']\n  end,\n  inv_hom_id' := (localization.of x.as_ideal.prime_compl).epic_of_localization_map $ λ f,\n    by simp only [ring_hom.comp_apply, coe_comp, coe_id, localization_to_stalk_of,\n        stalk_to_fiber_ring_hom_to_stalk] }\n\nend algebraic_geometry\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebraic_geometry/structure_sheaf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.47397295821556107}}
{"text": "/-\nCopyright (c) 2021 OpenAI. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f\n-/\nimport mathzoo.imports.miniF2F\n\nopen_locale nat rat real big_operators topological_space\n\ntheorem algebra_2complexrootspoly_xsqp49eqxp7itxpn7i\n  (x : ℂ) :\n  x^2 + 49 = (x + (7 * complex.I)) * (x + (-7 * complex.I)) :=\nbegin\n  ring_nf,\n  ring_nf,\n  rw [pow_two, pow_two, complex.I_mul_I],\n  ring,\nend", "meta": {"author": "leanprover-community", "repo": "mathzoo", "sha": "87e9b492daeb929838706942aaa2437621b34a0e", "save_path": "github-repos/lean/leanprover-community-mathzoo", "path": "github-repos/lean/leanprover-community-mathzoo/mathzoo-87e9b492daeb929838706942aaa2437621b34a0e/src/mathzoo/misc/miniF2F/algebra/2complexrootspoly_xsqp49eqxp7itxpn7i.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.473972958215561}}
{"text": "/-\nCopyright (c) 2022 Ian Wood. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ian Wood\n-/\nimport meta.expr\n\n/-!\n# `expand_exists`\n\n`expand_exists` is an attribute which takes a proof that something exists with some property, and\noutputs a value using `classical.some`, and a proof that it has that property using\n`classical.some_spec`. For example:\n\n```lean\n@[expand_exists it it_spec]\nlemma it_exists (n : ℕ) : ∃ m : ℕ, n < m := sorry\n```\n\nproduces\n\n```\ndef it (n : ℕ) : ℕ := classical.some (it_exists n)\n\nlemma it_spec (n : ℕ) : n < it n := classical.some_spec (it_exists n)\n```\n-/\n\nnamespace tactic\n\nopen expr\n\nnamespace expand_exists\n\n/--\nData known when parsing pi expressions.\n\n`decl`'s arguments are: is_theorem, name, type, value.\n-/\nmeta structure parse_ctx :=\n(original_decl : declaration)\n(decl : bool → name → expr → pexpr → tactic unit)\n(names : list name)\n(pis_depth : ℕ := 0)\n\n/--\nData known when parsing exists expressions (after parsing pi expressions).\n\n* `with_args` applies pi arguments to a term (eg `id` -> `id #2 #1 #0`).\n* `spec_chain` takes the form of `classical.some_spec^n (it_exists ...)`,\nwith `n` the depth of `∃` parsed.\n* `exists_decls` is a list of declarations containing the value(s) of witnesses.\n-/\nmeta structure parse_ctx_exists extends parse_ctx :=\n(with_args : expr → expr)\n(spec_chain : pexpr)\n(exists_decls : list name := [])\n\n/--\nData known when parsing the proposition (after parsing exists and pi expressions).\n\n`project_proof` projects a proof of the full proposition (eg `A ∧ B ∧ C`) to a specific proof (eg\n`B`).\n-/\nmeta structure parse_ctx_props extends parse_ctx_exists :=\n(project_proof : pexpr → pexpr := id)\n\n/--\nReplaces free variables with their exists declaration. For example, if:\n\n```lean\ndef n_value : ℕ := ... -- generated by `expand_exists`\n```\n\nthen this function converts `#0` in `#0 = #0` from `∃ n : ℕ, n = n` to `n_value = n_value`.\n-/\nmeta def instantiate_exists_decls (ctx : parse_ctx_exists) (p : expr) : expr :=\np.instantiate_vars $ ctx.exists_decls.reverse.map (λname,\n  ctx.with_args (const name ctx.original_decl.univ_levels))\n\n/--\nParses a proposition and creates the associated specification proof. Does not break down the\nproposition further.\n-/\nmeta def parse_one_prop (ctx : parse_ctx_props) (p : expr) : tactic unit :=\ndo\n  let p : expr := instantiate_exists_decls { ..ctx } p,\n  let val : pexpr := ctx.project_proof ctx.spec_chain,\n  n <- match ctx.names with\n  | [n] := return n\n  | [] := fail \"missing name for proposition\"\n  | _ := fail \"too many names for propositions (are you missing an and?)\"\n  end,\n  ctx.decl true n p val\n\n/--\nParses a proposition and decides if it should be broken down (eg `P ∧ Q` -> `P` and `Q`) depending\non how many `names` are left. Then creates the associated specification proof(s).\n-/\nmeta def parse_props : parse_ctx_props → expr → tactic unit\n| ctx (app (app (const \"and\" []) p) q) := do\n  match ctx.names with\n  | [n] := parse_one_prop ctx (app (app (const `and []) p) q)\n  | (n :: tail) :=\n    parse_one_prop { names := [n],\n      project_proof := (λ p, (const `and.left []) p) ∘ ctx.project_proof,\n      ..ctx } p\n    >> parse_props { names := tail,\n      project_proof := (λ p, (const `and.right []) p) ∘ ctx.project_proof,\n      ..ctx } q\n  | [] := fail \"missing name for proposition\"\n  end\n| ctx p := parse_one_prop ctx p\n\n/--\nParses an `∃ a : α, p a`, and creates an associated definition with a value of `α`. When `p α` is\nnot an exists statement, it will call `parse_props`.\n-/\nmeta def parse_exists : parse_ctx_exists → expr → tactic unit\n| ctx (app (app (const \"Exists\" [lvl]) type) (lam var_name bi var_type body)) := do\n  /- TODO: Is this needed, and/or does this create issues? -/\n  (if type = var_type then tactic.skip else tactic.fail \"exists types should be equal\"),\n  ⟨n, names⟩ <- match ctx.names with\n  | (n :: tail) := return (n, tail)\n  | [] := fail \"missing name for exists\"\n  end,\n  -- Type may be dependant on earlier arguments.\n  let type := instantiate_exists_decls ctx type,\n  let value : pexpr := (const `classical.some [lvl]) ctx.spec_chain,\n  ctx.decl false n type value,\n\n  let exists_decls := ctx.exists_decls.concat n,\n  let some_spec : pexpr := (const `classical.some_spec [lvl]) ctx.spec_chain,\n  let ctx : parse_ctx_exists := { names := names,\n    spec_chain := some_spec,\n    exists_decls := exists_decls,\n    ..ctx },\n  parse_exists ctx body\n| ctx e := parse_props { ..ctx } e\n\n/--\nParses a `∀ (a : α), p a`. If `p` is not a pi expression, it will call `parse_exists`\n-/\nmeta def parse_pis : parse_ctx → expr → tactic unit\n| ctx (pi n bi ty body) :=\n  -- When making a declaration, wrap in an equivalent pi expression.\n  let decl := (λ is_theorem name type val,\n    ctx.decl is_theorem name (pi n bi ty type) (lam n bi (to_pexpr ty) val)) in\n  parse_pis { decl := decl, pis_depth := ctx.pis_depth + 1, ..ctx } body\n| ctx (app (app (const \"Exists\" [lvl]) type) p) :=\n  let with_args := (λ (e : expr),\n    (list.range ctx.pis_depth).foldr (λ n (e : expr), e (var n)) e) in\n  parse_exists { with_args := with_args,\n    spec_chain := to_pexpr (\n      with_args $ const ctx.original_decl.to_name ctx.original_decl.univ_levels),\n    ..ctx } (app (app (const \"Exists\" [lvl]) type) p)\n| ctx e := fail (\"unexpected expression \" ++ to_string e)\n\nend expand_exists\n\n/--\nFrom a proof that (a) value(s) exist(s) with certain properties, constructs (an) instance(s)\nsatisfying those properties. For instance:\n\n```lean\n@[expand_exists nat_greater nat_greater_spec]\nlemma nat_greater_exists (n : ℕ) : ∃ m : ℕ, n < m := ...\n\n#check nat_greater      -- nat_greater : ℕ → ℕ\n#check nat_greater_spec -- nat_greater_spec : ∀ (n : ℕ), n < nat_greater n\n```\n\nIt supports multiple witnesses:\n\n```lean\n@[expand_exists nat_greater_m nat_greater_l nat_greater_spec]\nlemma nat_greater_exists (n : ℕ) : ∃ (m l : ℕ), n < m ∧ m < l := ...\n\n#check nat_greater_m      -- nat_greater : ℕ → ℕ\n#check nat_greater_l      -- nat_greater : ℕ → ℕ\n#check nat_greater_spec-- nat_greater_spec : ∀ (n : ℕ),\n  n < nat_greater_m n ∧ nat_greater_m n < nat_greater_l n\n```\n\nIt also supports logical conjunctions:\n```lean\n@[expand_exists nat_greater nat_greater_lt nat_greater_nonzero]\nlemma nat_greater_exists (n : ℕ) : ∃ m : ℕ, n < m ∧ m ≠ 0 := ...\n\n#check nat_greater         -- nat_greater : ℕ → ℕ\n#check nat_greater_lt      -- nat_greater_lt : ∀ (n : ℕ), n < nat_greater n\n#check nat_greater_nonzero -- nat_greater_nonzero : ∀ (n : ℕ), nat_greater n ≠ 0\n```\nNote that without the last argument `nat_greater_nonzero`, `nat_greater_lt` would be:\n```lean\n#check nat_greater_lt -- nat_greater_lt : ∀ (n : ℕ), n < nat_greater n ∧ nat_greater n ≠ 0\n```\n-/\n@[user_attribute]\nmeta def expand_exists_attr : user_attribute unit (list name) :=\n{ name := \"expand_exists\",\n  descr := \"From a proof that (a) value(s) exist(s) with certain properties, \"\n  ++ \"constructs (an) instance(s) satisfying those properties.\",\n  parser := lean.parser.many lean.parser.ident,\n  after_set := some $ λ decl prio persistent, do\n    d <- get_decl decl,\n    names <- expand_exists_attr.get_param decl,\n    expand_exists.parse_pis\n    { original_decl := d,\n      decl := λ is_t n ty val, (tactic.to_expr val >>= λ val,\n        tactic.add_decl (if is_t then declaration.thm n d.univ_params ty (pure val)\n          else declaration.defn n d.univ_params ty val default tt)),\n      names := names } d.type }\n\nadd_tactic_doc\n{ name := \"expand_exists\",\n  category := doc_category.attr,\n  decl_names := [`tactic.expand_exists_attr],\n  tags := [\"lemma derivation\", \"environment\"] }\n\nend tactic\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/tactic/expand_exists.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4739268156719015}}
{"text": "import mod_forms.Eisenstein_Series.Eisenstein_series_index_lemmas\nimport analysis.complex.upper_half_plane.basic\nimport analysis.complex.upper_half_plane.metric\nimport analysis.complex.upper_half_plane.topology\nimport number_theory.modular_forms.basic\nimport geometry.manifold.mfderiv\nimport tactic\n\nuniverses u v w\n\nopen complex\n\nopen_locale big_operators nnreal classical filter upper_half_plane\n\nopen modular_form\nopen slash_invariant_form\n\nlocal notation `SL2Z`:=matrix.special_linear_group (fin 2) ℤ\nnoncomputable theory\n\nlocal notation `ℍ'`:= (⟨upper_half_plane.upper_half_space , upper_half_plane_is_open⟩: topological_space.opens ℂ)\n\n/-! ### Eisenstein series -/\n\nnamespace Eisenstein_series\n\n/-- The function on `ℤ × ℤ` whose sum defines an Eisenstein series.-/\n\ndef Eise (k: ℤ) (z : ℍ) : ℤ × ℤ →  ℂ:=\nλ x, 1/(x.1*z+x.2)^k\n\n/-\ndef Eisen (k : ℤ) (x : ℤ × ℤ) : C(ℍ, ℂ) :=\n⟨λ z, 1/(x.1*z+x.2)^k, by {simp,  sorry}⟩\n-/\n\ninstance : topological_space C(ℍ, ℂ) :=infer_instance\n\n\n\ndef Eise' (k: ℤ) (z : ℂ) : ℤ × ℤ →  ℂ:=\nλ x, 1/(x.1*z+x.2)^k\n\ndef real_Eise (k: ℤ) (z : ℍ) : ℤ × ℤ →  ℝ:=\nλ x, complex.abs(1/(x.1*z+x.2)^k)\n\n\ndef Eise_deriv (k: ℤ) (z : ℂ) : ℤ × ℤ →  ℂ:=\nλ x, (-k*x.1)/(x.1*z+x.2)^(k+1)\n\n\n/--The Eisenstein series of weight `k : ℤ` -/\ndef Eisenstein_series_of_weight_ (k: ℤ) : ℍ → ℂ:=\n λ z, ∑' (x : ℤ × ℤ), (Eise k z x)\n\ndef real_Eisenstein_series_of_weight_ (k: ℤ) : ℍ → ℝ:=\n λ z, ∑' (x : ℤ × ℤ), (real_Eise k z x)\n\ndef Eisenstein_deriv_weight (k: ℤ) : ℍ → ℂ:=\n λ z, ∑' (x : ℤ × ℤ), (Eise_deriv k z x)\n\n\n/-\nlemma summable2 (k : ℤ) (h: 3 ≤ k) : summable (Eisen k):=\nbegin\n  sorry,\nend\n\n\ndef Eisenstein_series_of_weight_' (k: ℤ) : C(ℍ, ℂ):=\n ∑' (x : ℤ × ℤ), Eisen k x\n-/\n\nlemma Eise_is_nonneg (k: ℤ) (z : ℍ) (y : ℤ × ℤ): 0 ≤ abs (Eise k z y):=\nbegin\n apply complex.abs.nonneg,\nend\n\nlemma calc_lem (k: ℤ) (a b c d i1 i2: ℂ) (z : ℍ) (h: c*z+d ≠ 0) :\n((i1* ((a*z+b)/(c*z+d))+i2)^k)⁻¹=(c*z+d)^k* (((i1 * a + i2 * c) * z + (i1 * b + i2 * d))^k)⁻¹:=\nbegin\n  have h1 : i1*((a*z+b)/(c*z+d))+i2=(i1*(a*z+b)/(c*z+d)+i2), by {ring  }, rw h1,\n  have h2 :  (i1*(a*z+b)/(c*z+d)+i2)=((i1*(a*z+b))/(c*z+d)+i2), by {ring}, rw h2,\n  have h3 := div_add' (i1*(a*z+b)) i2 (c*z+d) h,\n  rw h3,\n  simp only [div_zpow, inv_div],\n  rw [div_eq_inv_mul, mul_comm],\n  have h5: (c*z+d)^k ≠ 0,\n  by {apply zpow_ne_zero _ h,  },\n  apply congr_arg (λ (b : ℂ), (c*z+d)^k * b⁻¹),\n  ring_nf,\nend\n\nlemma coe_chain (A: SL2Z) (i j : fin (2)):\n  (A.1 i j : ℂ)= ((A.1 : (matrix (fin 2) (fin 2) ℝ) ) i j : ℂ):=\nbegin\n  simp,\n  rw ← coe_coe,\n  fin_cases i;\n  fin_cases j,\n  all_goals {simp [coe_coe],\n  norm_cast},\nend\n\n\n/- How the Eise function changes under the Moebius action-/\nlemma Eise_moeb (k: ℤ) (z : ℍ) (A : SL2Z) (i : ℤ × ℤ ) :\n  Eise k ( (A : matrix.GL_pos (fin 2) ℝ) • z) i =\n  ((A.1 1 0*z+A.1 1 1)^k)*(Eise k z (Ind_equiv A i ) ) :=\nbegin\n  rw Eise,\n  rw Eise,\n  simp [coe_fn_coe_base'],\n  dsimp,\n  rw calc_lem,\n  have h1:= coe_chain A,\n  simp only [subtype.val_eq_coe] at h1,\n  rw h1,\n  rw h1,\n  rw ← coe_coe,\n  apply upper_half_plane.denom_ne_zero A,\nend\n\ndef Eisenstein_is_slash_inv (Γ : subgroup SL2Z) (k: ℤ) :\n(slash_invariant_form Γ k) :=\n{to_fun := (Eisenstein_series_of_weight_ k),\n  slash_action_eq' := begin\n  intro A,\n  ext1,\n  simp_rw slash_action_eq'_iff,\n  rw Eisenstein_series_of_weight_,\n  simp only [set.mem_set_of_eq],\n  simp,\n  have h1:= Eise_moeb k x A,\n  have h2:=tsum_congr h1,\n  convert h2,\n  simp only [subtype.val_eq_coe],\n  have h3:=equiv.tsum_eq (Ind_equiv A) (Eise k x),\n  rw tsum_mul_left,\n  rw h3,\n  end }\n\n/-\nbegin\nrw modular_forms.wmodular_mem',\nrw Eisenstein_series_of_weight_,\nsimp only [set.mem_set_of_eq],\nintros A z,\nhave h1:= Eise_moeb k z A,\nhave h2:=tsum_congr h1,\nconvert h2,\nsimp only [subtype.val_eq_coe],\nhave h3:=equiv.tsum_eq (Ind_equiv A) (Eise k z),\nrw tsum_mul_left,\nrw h3,\nsimp,\nend\n\n-/\n\nlemma Eise_on_square_is_bounded ( k : ℕ) (z : ℍ) (n : ℕ) (x: ℤ × ℤ) (h: x ∈ Square n) (hn: 1 ≤ n):\n  (complex.abs(((x.1: ℂ)*z+(x.2: ℂ))^k))⁻¹ ≤ (complex.abs ((rfunct z)^k* n^k))⁻¹ :=\nbegin\n  by_cases C1: complex.abs (x.1: ℂ)=n,\n  rw inv_le_inv,\n  have h0: (x.1:ℂ) ≠ 0,\n  by {norm_cast,\n  intro hx,\n  rw hx at C1,\n  simp  [int.cast_zero] at C1,\n  norm_cast at C1,\n  rw ← C1 at hn,\n  simp only [nat.one_ne_zero, le_zero_iff] at hn,\n  exact hn,},\n  have h1:(↑(x.fst) * ↑z + ↑(x.snd)) ^ k =  (↑(x.fst))^k* ((z: ℂ)+(x.2: ℂ)/(↑(x.fst)))^k,\n  by { rw ← mul_pow,\n  rw div_eq_mul_inv,\n  have: (x.fst: ℂ) * ((z: ℂ)  + (x.snd: ℂ) * ((x.fst: ℂ))⁻¹)=(x.fst: ℂ) * (z: ℂ) + (x.snd: ℂ),\n  by {have p1: (x.fst: ℂ) * ((z: ℂ)  + (x.snd: ℂ) * ((x.fst: ℂ))⁻¹)=\n  ((x.fst: ℂ) * (z: ℂ)  + (x.fst : ℂ) * ((x.fst: ℂ))⁻¹ * (x.snd: ℂ)),\n  ring_nf,\n  rw mul_inv_cancel at p1,\n  simp only [one_mul] at p1,\n  rw p1,\n  exact h0,},\n  rw this,},\n  rw h1,\n  simp_rw  map_mul complex.abs,\n  have h3: complex.abs (↑(x.fst) ^ k)= (complex.abs (↑(x.fst)))^k , by {apply complex.abs_pow, },\n  rw h3,\n  rw C1,\n  have h4: complex.abs (↑n ^ k)=↑n ^ k, by {norm_cast, },\n  rw h4,\n  rw mul_comm,\n  apply mul_le_mul_of_nonneg_left,\n  have:=auxlem2 z n  x h k ,\n  apply this, norm_cast,\n  simp only [zero_le'],\n  simp only [complex.abs.pos, ne.def],\n  have hh : ((x.fst): ℂ) * (z: ℂ) + (x.snd: ℂ) ≠ 0, by {\n  intro H,\n  have H1 : x.1 = 0 ∨ (z: ℂ).im = 0, by simpa using congr_arg complex.im H,\n  cases H1, {rw H1 at C1, simp only [int.cast_zero, abs_zero] at C1,\n  norm_cast at C1,\n  rw ← C1 at hn,\n  simp only [nat.one_ne_zero, square_mem, le_zero_iff] at *,\n  exact hn,},\n  have HH:= z.property,\n  simp only [subtype.val_eq_coe] at HH,\n  rw H1 at HH,\n  simp at HH,\n  exact HH,},\n  apply complex.abs.pos,\n  apply pow_ne_zero,\n  exact hh,\n  rw map_mul complex.abs,\n  apply mul_pos,\n  apply complex.abs.pos,\n  apply pow_ne_zero,\n  have:= rfunct_pos z,\n  norm_cast,\n  intro np,\n  rw np at this,\n  simp only [lt_self_iff_false] at this,\n  exact this,\n  apply complex.abs.pos,\n  apply pow_ne_zero,\n  norm_cast,\n  intro Hn,\n  rw Hn at hn,\n  simp only [nat.one_ne_zero, le_zero_iff] at hn,\n  exact hn,\n  have C2: complex.abs (x.2: ℂ)=n, by {simp only [square_mem] at h,\n  have:=max_aux'' x.1.nat_abs x.2.nat_abs n h,\n  norm_cast,\n  cases this,\n  by_contra,\n  norm_cast at C1,\n  rw ← this at C1,\n  rw int.abs_eq_nat_abs at C1,\n  simp only [eq_self_iff_true, not_true] at C1,\n  exact C1,\n  rw ← this,\n  rw int.abs_eq_nat_abs,},\n  rw inv_le_inv,\n  have h0: (x.2: ℂ ) ≠ 0, by {norm_cast,\n  intro hx,\n  rw hx at C2,\n  simp only [int.cast_zero, abs_zero] at C2,\n  norm_cast at C2,\n  rw ← C2 at hn,\n  simp only [nat.one_ne_zero, le_zero_iff] at hn,\n  exact hn,},\n  have h1:(↑(x.fst) * ↑z + ↑(x.snd)) ^ k =  (↑(x.snd))^k* (((x.1:ℂ)/(x.2: ℂ))*(z: ℂ)+1)^k,\n  by {rw ← mul_pow,simp only,\n  rw div_eq_mul_inv,\n  have: (x.snd: ℂ) * ((x.fst: ℂ) * ((x.snd: ℂ))⁻¹ * (z:ℂ) + 1)=\n  ((x.snd: ℂ ) * ((x.snd : ℂ))⁻¹ * (x.fst : ℂ )* (z: ℂ) + (x.snd: ℂ)), by {ring,},\n  rw this,\n  rw mul_inv_cancel,\n  simp only [one_mul],\n  exact h0,},\n  rw h1,\n  rw map_mul complex.abs,\n  rw map_mul complex.abs,\n  have h3: complex.abs (↑(x.2) ^ k)= (complex.abs (↑(x.2)))^k ,\n  by {apply complex.abs_pow,},\n  rw h3,\n  rw C2,\n  have h4: complex.abs (↑n ^ k)=↑n ^ k, by {norm_cast, },\n  rw h4,\n  rw mul_comm,\n  apply mul_le_mul_of_nonneg_left,\n  have:=auxlem3 z n  x h k ,\n  apply this,\n  norm_cast,\n  simp only [zero_le'],\n  have hh : ((x.fst): ℂ) * (z: ℂ) + (x.snd: ℂ) ≠ 0,\n  by {intro H,\n  have H1 : x.1 = 0 ∨ (z: ℂ).im = 0,\n  by simpa using congr_arg complex.im H,\n  cases H1,\n  {rw H1 at H,\n  simp only [int.cast_eq_zero, int.cast_zero, zero_mul, zero_add] at H,\n  rw H at C2,\n  simp only [int.cast_zero, abs_zero] at C2,\n  norm_cast at C2,\n  rw ← C2 at hn,\n  simp only [nat.one_ne_zero, square_mem, le_zero_iff] at *,\n  exact hn},\n  have HH:= z.property, simp only [subtype.val_eq_coe] at HH,\n  rw H1 at HH, simp only [lt_self_iff_false] at HH,\n  exact HH,},\n  apply complex.abs.pos,\n  apply pow_ne_zero,\n  exact hh,\n  rw map_mul complex.abs,\n  apply mul_pos,\n  apply complex.abs.pos,\n  apply pow_ne_zero,\n  have:= rfunct_pos z,\n  norm_cast,\n  intro np,\n  rw np at this,\n  simp only [lt_self_iff_false] at this,\n  exact this,\n  apply complex.abs.pos,\n  apply pow_ne_zero,\n  norm_cast,\n  intro Hn,\n  rw Hn at hn,\n  simp only [nat.one_ne_zero, le_zero_iff] at hn,\n  exact hn,\nend\n\nlemma Eise_on_square_is_bounded' ( k : ℕ) (z : ℍ) (n : ℕ) (hn: 1 ≤ n): ∀ (x: ℤ × ℤ),\nx ∈ (Square n) →  (complex.abs(((x.1: ℂ)*z+(x.2: ℂ))^k))⁻¹ ≤ (complex.abs ((rfunct z)^k* n^k))⁻¹ :=\nbegin\nintros x hx,\napply Eise_on_square_is_bounded k z n x hx hn,\nend\n\nlemma Eise_on_zero_Square (k : ℕ) (z : ℍ) (h: 1 ≤ k) : ∀ (x : ℤ × ℤ),\nx ∈ (Square 0) →  (complex.abs(((x.1: ℂ)*z+(x.2: ℂ))^k))⁻¹ ≤ (complex.abs ((rfunct z)^k* 0^k))⁻¹ :=\nbegin\n  intros x hx,\n  rw Square_zero at hx,\n  simp only [finset.mem_singleton] at hx,\n  simp_rw hx,\n  simp only [add_zero, int.cast_zero, zero_mul, map_mul complex.abs],\n  have h1: (0: ℂ)^k=0, by {rw zero_pow_eq_zero, linarith,},\n  rw h1,\n  simp,\nend\n\nlemma Eise_on_square_is_bounded'' ( k : ℕ) (z : ℍ) (n : ℕ) (hn: 1 ≤ k): ∀ (x: ℤ × ℤ),\nx ∈ (Square n) →  (complex.abs(((x.1: ℂ)*z+(x.2: ℂ))^k))⁻¹ ≤ (complex.abs ((rfunct z)^k* n^k))⁻¹ :=\nbegin\n  by_cases h0: n=0,\n  {rw h0,have:= Eise_on_zero_Square k z hn, simp at *, apply this, },\n  have Hn: 1 ≤ n,\n  by { have:= nat.pos_of_ne_zero h0,\n  linarith },\n  intros x hx,\n  apply Eise_on_square_is_bounded k z n x hx Hn,\nend\n\nlemma natpowsinv (x : ℝ) (n : ℤ)  (h2: x ≠ 0): (x^(n-1))⁻¹=(x^n)⁻¹*x:=\nbegin\nhave:=zpow_sub_one₀ h2 n,\nrw this,\nhave h3:=mul_zpow (x^n) (x⁻¹) (-1),\nsimp at *,\nexact h3,\nend\n\n/-Sum over squares is bounded -/\nlemma BigClaim (k : ℕ) (z : ℍ) (h : 3 ≤ k):\n  ∀ (n: ℕ), ∑ (y: ℤ × ℤ) in (Square n),\n  ((real_Eise k z) y)  ≤ (8/((rfunct z)^k))*(n^((k: ℤ)-1))⁻¹:=\nbegin\n  intro n,\n  rw real_Eise,\n  simp  [one_div, complex.abs_pow, abs_inv, zpow_coe_nat],\n  have k0: 1 ≤ k, by {linarith,},\n  have BO :=  Eise_on_square_is_bounded'' ( k : ℕ) (z : ℍ) (n : ℕ) k0,\n  by_cases n0 : n=0,\n  { rw n0,\n  rw Square_zero,\n  simp only [add_zero, int.cast_zero, nat.cast_zero, zero_mul, finset.sum_singleton],\n  have H0: (0: ℂ)^k=0, by {rw zero_pow_eq_zero, linarith,},\n  simp  [abs_zero, inv_zero],\n  have H00: (0: ℝ)^((k: ℤ)-1)=0,\n  by { rw zero_zpow, linarith,},\n  rw H00,\n  simp [inv_zero, mul_zero], norm_cast at *, rw H0,},\n  have := finset.sum_le_sum BO,\n  simp only [finset.sum_const, map_mul complex.abs, nsmul_eq_mul] at this,\n  rw Square_size n at this,\n  norm_cast at this,\n  have ne:( (8 * n) * (complex.abs (rfunct z ^ k) * ((n ^ k): ℝ))⁻¹ : ℝ)=\n  (8/((rfunct z)^k))*(n^((k: ℤ)-1))⁻¹,\n  by {rw complex.abs_pow,\n  rw complex.abs_of_nonneg,\n  rw ← mul_pow,\n  rw div_eq_inv_mul,\n  have : 8* ↑n * ((rfunct z * ↑n) ^ k)⁻¹= 8*((rfunct z)^k)⁻¹ * (↑n^((k: ℤ)-1))⁻¹,\n  by {have dis: ((rfunct z * ↑n) ^ k)⁻¹ = ((rfunct z)^k)⁻¹* (↑n^k)⁻¹,\n  by {rw mul_pow,\n  simp_rw [← zpow_neg_one],\n  simp_rw [← mul_zpow], },\n  simp [dis],\n  rw natpowsinv,\n  ring,\n  norm_cast,\n  intro hN,\n  rw hN at n0,\n  simp only [eq_self_iff_true, not_true] at n0,\n  exact n0,},\n  rw this,\n  ring,\n  have rpos := rfunct_pos z,\n  apply le_of_lt rpos,},\n  norm_cast at ne,\n  rw ne at this,\n  norm_cast,\n  simp at *,\n  apply this,\n  have hhh := nat.pos_of_ne_zero n0,\n  linarith,\nend\n\n\nlemma SmallClaim (k : ℕ) (z : ℍ) (h : 3 ≤ k):\n ∀ (n : ℕ), (λ (x: ℕ), ∑ (y : ℤ × ℤ) in (Square x), (real_Eise k z) y) n ≤\n  (8/(rfunct z)^k) * ((rie (k-1)) n):=\nbegin\nhave BIGCLAIM:= BigClaim k z h,\nsimp only at BIGCLAIM,\nrw rie,\nsimp only [one_div],\nintro n,\nhave tr :((↑n ^ ((k: ℤ) - 1))⁻¹: ℝ)=((↑n ^ ((k: ℝ) - 1))⁻¹: ℝ), by {simp [inv_inj],\nhave:= realpow n k,\nrw ← this,\nsimp [int.cast_coe_nat, int.cast_one, int.cast_sub],},\nrw ← tr,\napply BIGCLAIM n,\nend\n\n\nlemma real_eise_is_summable (k : ℕ) (z : ℍ) (h : 3 ≤ k): summable (real_Eise k z):=\nbegin\n  let In:=Square,\n  have HI:=Squares_cover_all,\n  let g:= λ (y : ℤ × ℤ), (real_Eise k z) y,\n  have gpos: ∀ (y : ℤ × ℤ), 0 ≤ g y,\n  by {simp_rw g, intro y, rw real_Eise, simp,},\n  have index_lem:= sum_lemma g  gpos In HI,\n  rw index_lem,\n  let e:=λ (x: ℕ), ∑ (y : ℤ × ℤ) in (In x), g y,\n  have BIGCLAIM: ∀ (n : ℕ), ∑ (y : ℤ × ℤ) in (In n), g y ≤(8/((rfunct z)^k))*(n^((k: ℤ)-1))⁻¹,\n  by {simp_rw g,\n  apply BigClaim k z h,},\n  have smallerclaim:  ∀ (n : ℕ), e n ≤  (8/(rfunct z)^k) * ((rie (k-1)) n),\n  by {simp_rw e,\n  apply SmallClaim k z h,},\n  have epos: ∀ (x : ℕ), 0 ≤ e x, by {simp_rw e, simp_rw g, intro x,\n  apply finset.sum_nonneg,  intros i hi, apply complex.abs.nonneg, },\n  have hk: 1 < ((k-1): ℤ), by { linarith, },\n  have nze: ((8/((rfunct z)^k)): ℝ)  ≠ 0,\n  by {apply div_ne_zero,\n  simp only [ne.def, not_false_iff, bit0_eq_zero, one_ne_zero],\n  apply pow_ne_zero,\n  simp only [ne.def],\n  by_contra HR,\n  have := rfunct_pos z,\n  rw HR at this,\n  simp only [lt_self_iff_false] at this,\n    exact this, },\n  have riesum:=int_Riemann_zeta_is_summmable (k-1) hk,\n  have riesum': summable (λ (n : ℕ), (8 / (rfunct z)^k) * rie (↑k - 1) n),\n  by {rw (summable_mul_left_iff nze).symm,\n  simp only [int.cast_coe_nat, int.cast_one, int.cast_sub] at riesum,\n  apply riesum,},\n  have:=summable_of_nonneg_of_le epos smallerclaim,\n  apply this,\n  apply riesum',\nend\n\n\nlemma Real_Eisenstein_bound (k : ℕ) (z : ℍ) (h : 3 ≤ k):\n    (real_Eisenstein_series_of_weight_ k z) ≤ (8/(rfunct z)^k)*Riemann_zeta (k-1):=\nbegin\n  rw [real_Eisenstein_series_of_weight_, Riemann_zeta, ← tsum_mul_left],\n  let In:=Square,\n  have HI:=Squares_cover_all,\n  let g:= λ (y : ℤ × ℤ), (real_Eise k z) y,\n  have gpos: ∀ (y : ℤ × ℤ), 0 ≤ g y,\n  by {simp_rw g, intro y, rw real_Eise, simp,},\n  have hgsumm: summable g,\n  by {simp_rw g, apply real_eise_is_summable k z h, },\n  have index_lem:= tsum_lemma g In HI hgsumm,\n  simp_rw g at index_lem,\n  simp,\n  rw index_lem,\n  have ind_lem2:=sum_lemma g gpos In HI,\n  have smallclaim:= SmallClaim k z h,\n  have hk: 1 < ((k-1): ℤ), by { linarith, },\n  have nze: ((8/((rfunct z)^k)): ℝ)  ≠ 0,\n  by {apply div_ne_zero, simp, apply pow_ne_zero,\n  simp, by_contra HR,\n  have:=rfunct_pos z,\n  rw HR at this,\n  simp at this,\n  exact this, },\n  have riesum:=int_Riemann_zeta_is_summmable (k-1) hk,\n  have riesum': summable (λ (n : ℕ), (8 / (rfunct z)^k) * rie (↑k - 1) n),\n  by {rw (summable_mul_left_iff nze).symm,\n  simp at riesum,\n  apply riesum,},\n  apply tsum_le_tsum,\n  apply smallclaim,\n  simp_rw g at ind_lem2,\n  rw ← ind_lem2,\n  simp_rw g at hgsumm,\n  apply hgsumm,\n  apply riesum',\nend\n\nlemma Eisenstein_series_is_summable (k : ℕ) (z : ℍ) (h : 3 ≤ k) : summable (Eise k z) :=\nbegin\nlet f:=(Eise k z),\nhave sum_Eq:  summable (λ x, abs (f x)) → summable f, by {apply summable_if_complex_abs_summable,},\napply sum_Eq,\nsimp_rw f,\nhave:=real_eise_is_summable k z h,\nrw real_Eise at this,\nexact this,\nend\n\n/--The sum of Eise over the `Square`'s-/\ndef eisen_square (k : ℤ) (n: ℕ): ℍ → ℂ:=\nλ z, ∑ x in Square n, Eise k z x\n\n\nlemma Eisenstein_series_is_sum_eisen_squares (k: ℕ) (z: ℍ) (h : 3 ≤ k) :\n(Eisenstein_series_of_weight_ k z) = ∑' (n : ℕ), eisen_square k n z:=\nbegin\nrw Eisenstein_series_of_weight_, simp_rw eisen_square,\n\nhave HI:=Squares_cover_all,\nlet g:= λ (y : ℤ × ℤ),  (Eise k z ) y,\nhave hgsumm: summable g, by {simp_rw g, apply Eisenstein_series_is_summable k z h, },\nhave index_lem:= tsum_lemma' g Square HI hgsumm, simp_rw g at index_lem, exact index_lem,\n\nend\n\ndef Eisen_partial_sums (k: ℤ) (n : ℕ): ℍ → ℂ:=\nλ z, ∑ x in (finset.range n), (eisen_square k x z)\n\ndef upper_half_space_slice (A B : ℝ) :=\n  {z : ℍ' | complex.abs(z.1.1) ≤ A ∧ complex.abs(z.1.2) ≥ B  }\n\ninstance upper_half_space_slice_to_uhs (A B : ℝ) :\n  has_coe (upper_half_space_slice A B) ℍ := ⟨λ z, z.1⟩\n\n@[simp]lemma slice_mem (A B : ℝ) (z: ℍ): z ∈ (upper_half_space_slice A B) ↔\n(complex.abs(z.1.1) ≤ A ∧ complex.abs(z.1.2) ≥ B) :=iff.rfl\n\nlemma slice_in_upper_half (A B : ℝ) (x : (upper_half_space_slice A B) ) :\n  x.1.1 ∈ ℍ'.1:=\nbegin\nhave hx : 0 < x.1.1.im, by {apply upper_half_plane.im_pos,},\nsimp at hx,\nsimp,\napply hx,\nend\n\n\nlemma ball_in_upper_half (z : ℍ') (A B ε : ℝ)(hB : 0 < B) ( hε : 0 < ε) (hBε : ε < B)\n  (h : metric.closed_ball z ε ⊆ upper_half_space_slice A B) :\n    metric.closed_ball z.1 ε ⊆ ℍ'.1 :=\nbegin\nintros x hx,\nsimp at *,\nhave hg : 0 < (x.2), by {\n  rw metric.closed_ball at h,\n    have hz : z ∈ upper_half_space_slice A B, by {apply h, simp [hε.le]},\n    simp at hz,\n    have hz2:= z.2,\n    have hzB: B ≤ complex.abs z.1.2, by {simp [hz.2],},\n    rw dist_eq_norm at hx,\n    simp at hx,\n    have h3:= le_trans (abs_im_le_abs (x-z.1)) hx,\n    have h4:= _root_.abs_sub_le z.1.2 x.2 0,\n    rw sub_im at h3,\n    rw _root_.abs_sub_comm at h3,\n    have h33: -ε ≤ - |z.1.im - x.im|, by {simp, apply h3, },\n    simp at h4,\n    have h5 : |z.1.im| - |z.1.im - x.im| ≤ |x.im|, by {simp,linarith,},\n    simp at hzB,\n    have h6 : B - ε ≤ |z.1.im| - |z.1.im - x.im|, by {simp at *, linarith, },\n    by_contradiction hc,\n    simp at hc,\n    have hcc: 0 ≤ -x.im, by {linarith, },\n    have hzc :|z.1.im - x.im| = z.1.im - x.im, by {apply _root_.abs_of_nonneg, apply add_nonneg,\n    have := upper_half_plane.im_pos z,\n    apply this.le, apply hcc,},\n    have hzp : |z.1.im| = z.1.im, by {apply _root_.abs_of_nonneg (upper_half_plane.im_pos z).le,},\n    simp_rw [hzc, hzp] at h6,\n    simp only [sub_sub_cancel] at h6,\n    linarith,},\napply hg,\nend\n\nlemma closed_ball_in_slice (z : ℍ') : ∃ (A B ε : ℝ), 0 < ε ∧ 0 < B ∧\n  metric.closed_ball z ε ⊆ upper_half_space_slice A B ∧  0 ≤ A ∧ ε < B:=\nbegin\n  let e := 3⁻¹ * complex.abs(z.1.2),\n  let a := complex.abs(z.1.2) +  complex.abs(z),\n  let b := complex.abs(z.1.2) - e,\n  use a,\n  use b,\n  use e,\n  split,\n  simp_rw e,\n  simp,\n  apply upper_half_plane.im_ne_zero z,\n  split,\n  simp_rw b,\n  simp_rw e,\n  ring_nf,\n  simp only [abs_of_real, upper_half_plane.coe_im, subtype.val_eq_coe],\n  apply mul_pos,\n  nlinarith,\n  simp,\n  apply upper_half_plane.im_ne_zero z,\n  split,\n  intro x,\n  simp only [abs_of_real, tsub_le_iff_right, ge_iff_le, metric.mem_closed_ball, slice_mem,\n  upper_half_plane.coe_im, subtype.val_eq_coe, upper_half_plane.coe_re],\n  intro hxz,\n  have d1 : dist x z = dist (x : ℂ) (z :ℂ), by {exact subtype.dist_eq x z,},\n  rw d1 at  hxz,\n  rw dist_eq_norm at hxz,\n  simp only [norm_eq_abs] at hxz,\n  have:= complex.abs.sub_le (x : ℂ) (z : ℂ) 0,\n  simp only [sub_zero, subtype.val_eq_coe] at this,\n  split,\n  simp_rw a,\n  have hre := le_trans (abs_re_le_abs x.1) this,\n  rw upper_half_plane.re,\n  simp only [abs_of_real, upper_half_plane.coe_im, subtype.val_eq_coe, upper_half_plane.coe_re] at *,\n  apply le_trans hre,\n  simp only [add_le_add_iff_right],\n  apply le_trans hxz,\n  simp_rw e,\n  rw upper_half_plane.im,\n  simp only [abs_of_real, upper_half_plane.coe_im, subtype.val_eq_coe],\n  have hxim : 0 ≤ |upper_half_plane.im z|, by {apply _root_.abs_nonneg,},\n  ring_nf,\n  linarith,\n  have ineq1:= _root_.abs_sub_le z.1.2 x.1.2 0,\n  simp only [sub_zero, upper_half_plane.coe_im, subtype.val_eq_coe] at ineq1,\n  apply le_trans ineq1,\n  rw add_comm,\n  simp only [add_le_add_iff_left],\n  have ki:= le_trans (abs_im_le_abs (x.1-z.1)) hxz,\n  rw sub_im at ki,\n  rw _root_.abs_sub_comm at ki,\n  convert ki,\n  simp_rw a,\n  split,\n  apply add_nonneg,\n  apply complex.abs.nonneg,\n  apply complex.abs.nonneg,\n  simp_rw b,\n  simp_rw e,\n  ring_nf,\n  rw ← sub_pos,\n  have hr : 0 < complex.abs (z.1.im), by {simp, apply upper_half_plane.im_ne_zero z,},\n  linarith,\nend\n\n/--Canonical point in the `A B` slice-/\ndef lbpoint (A B : ℝ) (h: 0 < B): ℍ := ⟨⟨A,B⟩, by { simp, exact h,},⟩\n\nlemma aux55 (a b : ℝ ) (h : a ≠ 0 ) : a/(a+b)=1/(b/a+1) :=\nbegin\n  have : b/a+1=(b+a)/a, by {ring_nf, simp [h],},\n  rw this,\n  simp,\n  rw add_comm,\nend\n\nlemma aux4 (a b : ℝ) (h: 0 < b): (b^4+(a*b)^2)/(a^2+b^2)^2=1/((a/b)^2 +1 ):=\nbegin\n  have h1 : (a^2+b^2)^2=(a^2+b^2)*(a^2+b^2), by {ring,},\n  rw h1,\n  have h2: (b^4+(a*b)^2)=b^2*(a^2+b^2) , by {ring},\n  rw h2,\n  rw mul_div_assoc,\n  simp only [one_div, div_pow, div_self_mul_self'],\n  field_simp,\n  have hb : b^2 ≠ 0 , by {simp [h], intro h3, linarith,},\n  have:= (aux55  (b^2) (a^2) hb),\n  rw add_comm,\n  exact this,\nend\n\nlemma aux5 (a b : ℝ): 0 < a^2/b^2+1:=\nbegin\n  have h1: 0 ≤a^2/b^2, by  {apply div_nonneg, nlinarith, nlinarith, },\n  linarith,\nend\n\nlemma aux6 (a b : ℝ) (h: 0 ≤  a) (h2: 0 ≤ b) : a ≤ b → a^2 ≤ b^2 :=\nbegin\n  intro hab,\n  nlinarith,\nend\n\nlemma hcoe : upper_half_plane.upper_half_space = coe '' (set.univ : set upper_half_plane) :=\nbegin\nsimp, refl,\nend\n\nlemma rfunct_lower_bound_on_slice (A B : ℝ) (h: 0 < B) (z : upper_half_space_slice A B) :\nrfunct (lbpoint A B h) ≤  rfunct(z.1) :=\nbegin\n  simp at *,\n  simp_rw rfunct,\n  simp_rw lbpoint,\n  simp only [ min_le_iff, le_min_iff,subtype.val_eq_coe],\n  cases z,\n  have zpos:= upper_half_plane.im_pos z_val,\n  cases z_property,\n  cases z_val,\n  dsimp at *,\n  simp at *,\n  fsplit,\n  simp_rw lb,\n  rw real.sqrt_le_sqrt_iff,\n  have h1: B^2 ≤ complex.abs (z_val_val.im)^2, by {norm_cast, nlinarith, },\n  norm_cast at h1,\n  rw _root_.sq_abs at h1,\n  simp [h1],\n  nlinarith,\n  simp_rw lb,\n  rw real.sqrt_le_sqrt_iff,\n  rw real.sqrt_le_sqrt_iff,\n  rw aux4,\n  rw aux4,\n  simp,\n  rw inv_le_inv,\n  simp,\n  simp_rw [hcoe] at z_val_property,\n  simp at z_val_property,\n  have i1: (((z_val_val.im)^2)⁻¹ : ℝ)≤ ((B^2)⁻¹ : ℝ) ,\n    by {rw inv_le_inv,\n    have h' : 0 ≤ B , by {linarith,},\n    have z_prop' : 0 ≤ z_val_val.im, by {apply zpos.le, },\n    apply aux6 _ _ h' z_prop',\n    have : z_val_val.im = complex.abs (z_val_val.im),\n    by  {norm_cast, have:= abs_of_pos zpos, exact this.symm,},\n    norm_cast at this,\n    rw this,\n    exact z_property_right,\n    apply pow_two_pos_of_ne_zero,\n     have z_prop2 : 0 < z_val_val.im, by {apply zpos, },\n    linarith,\n    apply pow_two_pos_of_ne_zero, linarith,},\n  have i2: ((z_val_val.re)^2 : ℝ )≤ (A^2 : ℝ),\n    by {have : (complex.abs (z_val_val.re))^2 = z_val_val.re^2,\n    by {norm_cast,\n    simp,},\n    norm_cast at this,\n    rw ← this,\n    have v2: 0 ≤ complex.abs (z_val_val.re), by {apply complex.abs.nonneg,},\n    norm_cast at v2,\n    have v1: 0 ≤ A, by {apply le_trans v2 z_property_left,},\n    apply aux6 _ _ v2 v1,\n    exact z_property_left,},\n  ring_nf,\n  have i3:= mul_le_mul i1 i2,\n  have i4: 0 ≤ (z_val_val.re)^2, by {nlinarith,},\n  have i5: 0 ≤ (B ^ 2)⁻¹ , by { simp, nlinarith,},\n  have i6:= i3 i4 i5,\n  simp_rw i6,\n  simp,\n  apply aux5,\n  apply aux5,\n  exact h,\n  exact z_val_property,\n  apply div_nonneg,\n  apply right.add_nonneg,\n  have he : even (4 : ℤ), by {simp,},\n  have := even.zpow_nonneg he (z_val_val.im) ,\n  apply this,\n  simp,\n  nlinarith,\n  nlinarith,\n  apply div_nonneg,\n  apply right.add_nonneg,\n  have he : even (4 : ℤ), by {simp,},\n  have := even.zpow_nonneg he (z_val_val.im) ,\n  apply this,\n  simp only,\n  nlinarith,\n  nlinarith,\nend\n\n\nlemma rfunctbound (k : ℕ) (h : 3 ≤ k) (A B : ℝ) (hb : 0 < B) (z : upper_half_space_slice A B) :\n(8/(rfunct z)^k)*Riemann_zeta (k-1)  ≤ (8/(rfunct (lbpoint A B hb) )^k)*Riemann_zeta (k-1) :=\nbegin\n  have h1:= rfunct_lower_bound_on_slice A B hb z,\n  simp only [subtype.val_eq_coe] at h1,\n  have v1: 0 ≤ rfunct z, by {have:= rfunct_pos z, linarith, },\n  have v2: 0 ≤ rfunct (lbpoint A B hb), by {have:= rfunct_pos (lbpoint A B hb), linarith, },\n  have h2 := pow_le_pow_of_le_left v2 h1 k,\n  ring_nf,\n  rw ← inv_le_inv at h2,\n  have h3: 0 ≤  Riemann_zeta (k-1), by {have hk: 1 < (k-1 : ℤ), by { linarith,},\n  have hkk: 1 < ((k-1 : ℤ) : ℝ), by {norm_cast, exact hk,},\n  simp only [int.cast_coe_nat, int.cast_one, int.cast_sub] at hkk,\n  have:= Riemann_zeta_pos (k-1) hkk, linarith,},\n  nlinarith,\n  apply pow_pos,\n  apply rfunct_pos,\n  apply pow_pos,\n  apply rfunct_pos,\nend\n\n\nlemma rfunctbound' (k : ℕ) (A B : ℝ) (hb : 0 < B) (z : upper_half_space_slice A B)\n(n : ℕ) : (8/(rfunct z)^k)* (rie (k-1) n)  ≤ (8/(rfunct (lbpoint A B hb) )^k)* (rie (k-1) n) :=\nbegin\n  have h1:= rfunct_lower_bound_on_slice A B hb z,\n  simp only [subtype.val_eq_coe] at h1,\n  have v1: 0 ≤ rfunct z, by {have:= rfunct_pos z, linarith, },\n  have v2: 0 ≤ rfunct (lbpoint A B hb), by {have:= rfunct_pos (lbpoint A B hb), linarith, },\n  have h2 := pow_le_pow_of_le_left v2 h1 k,\n  ring_nf,\n  rw ← inv_le_inv at h2,\n  have h3: 0 ≤  rie (k-1) n,\n  by {rw rie,\n  simp only [one_div, inv_nonneg],\n  apply real.rpow_nonneg_of_nonneg,\n  simp only [nat.cast_nonneg],},\n  nlinarith,\n  apply pow_pos,\n  apply rfunct_pos,\n  apply pow_pos,\n  apply rfunct_pos,\nend\n\nlemma Real_Eisenstein_bound_unifomly_on_stip (k : ℕ) (h : 3 ≤ k) (A B : ℝ) (hb : 0 < B)\n  (z : upper_half_space_slice A B) :\n    (real_Eisenstein_series_of_weight_ k z.1) ≤ (8/(rfunct (lbpoint A B hb) )^k)*Riemann_zeta (k-1):=\nbegin\nhave : (8/(rfunct z)^k)*Riemann_zeta (k-1)  ≤ (8/(rfunct (lbpoint A B hb) )^k)*Riemann_zeta (k-1),\nby {apply rfunctbound, exact h},\napply le_trans (Real_Eisenstein_bound k z h) this,\nend\n\ndef Eisen_square_slice (k : ℤ) (A B : ℝ)  (n : ℕ) :\n  (upper_half_space_slice A B) → ℂ := λ x, (eisen_square k n x)\n\ndef Eisen_par_sum_slice (k : ℤ) (A B : ℝ) (n : ℕ) :\n  (upper_half_space_slice A B) → ℂ :=\n  λ z, ∑ x in (finset.range n), (Eisen_square_slice k A B  x z)\n\ninstance : has_coe ℍ ℍ' :=\n⟨ λ z, ⟨ z.1, by {simp, cases z, assumption,}, ⟩ ⟩\n\ninstance slice_coe (A B : ℝ) (hb : 0 < B) : has_coe (upper_half_space_slice A B) ℍ' :=\n⟨λ (x : (upper_half_space_slice A B)), (x : ℍ')  ⟩\n\ndef Eisenstein_series_restrict (k : ℤ) (A B : ℝ) : (upper_half_space_slice A B) → ℂ :=\nλ x, Eisenstein_series_of_weight_ k x\n\ninstance  nonemp (A B : ℝ) (ha : 0 ≤  A) (hb : 0 < B) : nonempty (upper_half_space_slice A B):=\nbegin\n  let z:= (⟨  A, B⟩ : ℂ),\n  rw ← exists_true_iff_nonempty,\n  simp,\n  use z,\n  have zim: z.im = B, by {refl,},\n  use hb,\n  simp_rw z,\n  simp_rw [upper_half_plane.re, upper_half_plane.im],\n  simp,\n  split,\n  have:= abs_eq_self.2 ha,\n  rw this,\n  apply le_abs_self,\nend\n\nlemma Eisenstein_series_is_sum_eisen_squares_slice (k: ℕ) (h : 3 ≤ k) (A B : ℝ) (hb : 0 < B)\n (z: (upper_half_space_slice A B)) :\n  (Eisenstein_series_restrict k A B z) = ∑' (n : ℕ), (Eisen_square_slice k A B n z):=\nbegin\n  rw Eisenstein_series_restrict, simp_rw Eisen_square_slice,\n  have HI:=Squares_cover_all,\n  let g:= λ (y : ℤ × ℤ),  (Eise k z ) y,\n  have hgsumm: summable g,\n  by {simp_rw g, apply Eisenstein_series_is_summable k z h, },\n  have index_lem:= tsum_lemma' g Square HI hgsumm,\n  simp_rw g at index_lem,\n  exact index_lem,\nend\n\nlemma Eisen_partial_tends_to_uniformly (k: ℕ) (h : 3 ≤ k) (A B : ℝ) (ha : 0 ≤ A) (hb : 0 < B) :\ntendsto_uniformly (Eisen_par_sum_slice k A B ) (Eisenstein_series_restrict k A B) filter.at_top:=\nbegin\n  let M : ℕ → ℝ := λ x,   (8/(rfunct (lbpoint A B hb) )^k)* (rie  (k-1) x),\n  have:= M_test_uniform _ (Eisen_square_slice k A B ) M,\n  simp_rw  ← (Eisenstein_series_is_sum_eisen_squares_slice k h A B hb _) at this,\n  apply this,\n  simp_rw Eisen_square_slice,\n  simp_rw eisen_square,\n  simp_rw M,\n  simp_rw Eise,\n  intros n a,\n  have SC:= SmallClaim k a h n,\n  rw real_Eise at SC,\n  simp at SC,\n  simp,\n  have ineq1:\n  complex.abs (∑ (x : ℤ × ℤ) in Square n, ((↑(x.fst) * ↑↑a + ↑(x.snd)) ^ k)⁻¹) ≤\n  ∑ (x : ℤ × ℤ) in Square n, (complex.abs ((↑(x.fst) * ↑↑a + ↑(x.snd)) ^ k))⁻¹,\n  by {simp,\n  have := complex_abs_sum_le  (Square n)\n  (λ  (x : ℤ × ℤ),  (((x.1 : ℂ) * (a : ℂ) + (x.2 : ℂ)) ^ k)⁻¹),\n  simp at this,\n  exact this, },\n  simp at *,\n  have SC2:= le_trans ineq1 SC,\n  have rb := rfunctbound' k A B hb a n,\n  apply le_trans SC2 rb,\n  apply_instance,\n  apply_instance,\n  simp_rw M,\n  have hk: 1 < ((k-1): ℤ), by { linarith, },\n  have nze: ((8/((rfunct (lbpoint A B hb))^k)): ℝ)  ≠ 0,\n  by {apply div_ne_zero, simp, apply pow_ne_zero,\n  simp, by_contra HR,\n  have:=rfunct_pos (lbpoint A B hb),\n  rw HR at this,\n  simp at this,\n  exact this, },\n  have riesum:=int_Riemann_zeta_is_summmable (k-1) hk,\n  rw (summable_mul_left_iff nze).symm,\n  simp at riesum,\n  apply riesum,\n  apply Eisenstein_series.nonemp A B ha hb,\nend\n\ndef powfun  (k : ℤ) : ℂ → ℂ :=\nλ x, x^k\n\ndef trans (a b : ℤ) : ℂ → ℂ :=\nλ x, a*x+b\n\ndef ein (a b k : ℤ): ℂ → ℂ :=\nλ x, (a*x+b)^k\n\nlemma com (a b k : ℤ): (ein a b k) = (powfun k) ∘ trans a b :=\nbegin\nrefl,\nend\n\nlemma d1 (k: ℤ) (x : ℂ): deriv (λ x, x^k) x = k*x^(k-1) :=\nby {simp only [deriv_zpow'], }\n\nlemma d2 (a b k: ℤ) (x : ℂ) (h : (a: ℂ)*x+b ≠ 0) : deriv (ein a b k) x = k*a*(a*x+b)^(k-1):=\nbegin\n  rw com,\n  rw deriv.comp,\n  rw powfun,\n  rw trans,\n  simp,\n  ring,\n  rw powfun,\n  rw trans, simp, simp_rw differentiable_at_zpow ,\n  simp [h],\n  rw trans,\n  simp only [differentiable_at_const,\n  differentiable_at_add_const_iff,\n  differentiable_at_id',\n  differentiable_at.mul],\nend\n\n\nlemma aux8 (a b k: ℤ ) (x : ℂ): (((a : ℂ)*x+b)^k)⁻¹ =  ((a : ℂ)*x+b)^-k:=\nbegin\nrefine (zpow_neg _ k).symm,\nend\n\nlemma dd2 (a b k: ℤ) (x : ℂ) (h : (a: ℂ)*x+b ≠ 0) :\n  has_deriv_at (ein a b k) (k*(a*x+b)^(k-1)*(a) : ℂ) x:=\nbegin\n  rw com,\n  apply has_deriv_at.comp,\n  rw powfun,\n  rw trans,\n  simp,\n  apply has_deriv_at_zpow,\n  simp [h],\n  rw trans,\n  apply has_deriv_at.add_const,\n  have:= has_deriv_at.const_mul (a: ℂ) (has_deriv_at_id x) ,\n  simp at *,\n  exact this,\nend\n\nlemma H_member (z : ℂ) : z ∈ upper_half_plane.upper_half_space ↔ 0 < z.im:=iff.rfl\n\nlemma Eise'_has_deriv_within_at (k : ℤ) (y: ℤ × ℤ) (hkn: k ≠ 0) :\n  is_holomorphic_on (λ (z : ℍ'), Eise k z y):=\nbegin\n  rw is_holomorphic_on,\n  intro z,\n  by_cases hy: (y.1 : ℂ)*z.1 + y.2 ≠ 0,\n  simp_rw Eise, ring_nf,\n\n  have:= aux8 y.1 y.2 k z.1,\n  simp only [subtype.val_eq_coe] at this,\n  have nz: (y.1 : ℂ)*z.1 + y.2 ≠ 0 , by {apply hy,},\n  have hdd:= dd2 y.1 y.2 (-k) z nz,\n  rw ein at hdd,\n  have H' := has_deriv_at.has_deriv_within_at hdd,\n  have H : has_deriv_within_at (λ (x : ℂ), (↑(y.fst) * x + ↑(y.snd)) ^ -k)\n  (↑-k * (↑(y.fst) * ↑z + ↑(y.snd)) ^ (-k - 1) * ↑(y.fst)) upper_half_plane.upper_half_space ↑z, by {apply H'},\n  simp at H,\n  let fx:=(-k*((y.1:ℂ)*z.1+y.2)^(-k-1)*(y.1) : ℂ),\n  refine ⟨ fx, _⟩,\n  rw has_deriv_within_at_iff_tendsto at *,\n  simp  [ zpow_neg, algebra.id.smul_eq_mul, eq_self_iff_true,\n   ne.def, int.cast_neg, subtype.val_eq_coe, norm_eq_abs,\n  sub_neg_eq_add] at *,\n  rw metric.tendsto_nhds_within_nhds at *,\n  intros ε hε,\n  have HH:= H ε hε,\n  obtain ⟨d1, hd1, hh⟩ := HH,\n  refine ⟨d1 ,hd1, _⟩,\n  intros x hx hd,\n  dsimp at *,\n  simp_rw extend_by_zero,\n  simp only [dite_eq_ite, if_true, subtype.coe_prop, subtype.coe_eta, subtype.coe_mk],\n  rw ← dite_eq_ite, rw dif_pos hx,\n  have H3:= hh hx hd,\n  simp_rw fx,\n  convert H3,\n\n  ring_nf,\n  simp only [not_not, subtype.val_eq_coe] at hy,\n  have hz: y.1 =0 ∧ y.2 = 0,\n  by {by_contra,\n  simp only [not_and] at h,\n  cases z,\n  cases y,\n  dsimp at *,\n  injections_and_clear,\n  dsimp at *,\n  simp only [int_cast_re, int.cast_eq_zero, add_zero, int_cast_im, zero_mul, sub_zero,\n  mul_eq_zero] at *,\n  cases h_2,\n  rw h_2 at h_1,\n  simp only [int.cast_eq_zero, int.cast_zero, zero_mul, zero_add] at *,\n  have:= h h_2,\n  rw h_1 at this,\n  simp only [eq_self_iff_true, not_true] at this,\n  exact this,\n  simp only [H_member] at z_property,\n  rw h_2 at z_property,\n  simp only [lt_self_iff_false] at z_property,\n  exact z_property,},\n  simp_rw Eise, rw [hz.1, hz.2],\n  simp only [one_div, add_zero, int.cast_zero, zero_mul],\n  have zhol:= zero_hol ℍ' ,\n  rw is_holomorphic_on at zhol,\n  have zhol':= zhol z,\n  simp only at zhol',\n  have zk: ((0: ℂ)^k)⁻¹ =0,\n  by {simp only [inv_eq_zero],\n  apply zero_zpow,\n  apply hkn,},\n  rw zk,\n  exact zhol',\nend\n\nlemma Eise'_has_diff_within_at (k : ℤ) (y: ℤ × ℤ) (hkn: k ≠ 0) :\n  differentiable_on ℂ (extend_by_zero (λ (z : ℍ'), Eise k z y)) ℍ':=\nbegin\n  have:= is_holomorphic_on_iff_differentiable_on ℍ' (λ (z : ℍ'), Eise k z y),\n  simp only [subtype.coe_mk],\n  rw this,\n  apply Eise'_has_deriv_within_at,\n  apply hkn,\nend\n\nlemma Eis_diff_on_ball {R : ℝ} {z w : ℂ} (hw : w ∈ metric.ball z R) (k : ℤ) (y: ℤ × ℤ) (hkn: k ≠ 0)\n  (h : metric.closed_ball z R ⊆ ℍ' ):\n  differentiable_on ℂ (extend_by_zero (λ (z : ℍ'), Eise k z y)) (metric.closed_ball z R) :=\nbegin\n  apply differentiable_on.mono (Eise'_has_diff_within_at k y hkn),\n  simp only [metric.mem_ball, ne.def, subtype.coe_mk] at *,\n  apply h,\nend\n\nend Eisenstein_series\n", "meta": {"author": "CBirkbeck", "repo": "ModularForms", "sha": "9ef5fda326f3d8dd132da5a09ea64cb8b29b82bc", "save_path": "github-repos/lean/CBirkbeck-ModularForms", "path": "github-repos/lean/CBirkbeck-ModularForms/ModularForms-9ef5fda326f3d8dd132da5a09ea64cb8b29b82bc/src/mod_forms/Eisenstein_Series/Eisenstein_series.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324803738429, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.47389716043494434}}
{"text": "import number_theory.bernoulli\n\n\n--OUTPUT 1\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  apply nat.strong_induction_on n,\n  clear n,\n  assume n hn x,\n  -- We want to prove that for all $m < d$, we have $B_{m} (1 + x) = B_{m} (x) + m x^{m - 1}$\n  assume h1 : ∀ m : ℕ, m < n → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1),\n  -- We want to show that $$B_{d} (1 + x) = B_{d} (x) + d x^{d - 1}$$\n  have h2 : (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1),\n  {\n    -- Multiplying both sides by $d + 1$, and using the fact that, for all $l \\in \\mathbb{N}$, $\\sum_{k = 0}^{l} {l + 1 \\choose k} B_k = (l + 1) X^l$ (where $B_k$ is the $k$-th Bernoulli number), we get that \n    have h3 : (n + 1) * (1 + x)^n - (n + 1) * x^n = (n + 1) * ∑ (l : ℕ) in finset.range (n + 1), (n + 1) * (finset.range (n + 1)).sum (λ (k : ℕ) (hk : k ∈ finset.range (n + 1)), (n + 1) * (polynomial.bernoulli k).eval x^k) * x^(l - 1),\n    {\n      apply polynomial.ext,\n      assume i,\n      -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n      have h4 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * ∑ (l : ℕ) in finset.range (n + 1), (n + 1) * (finset.range (n + 1)).sum (λ (k : ℕ) (hk : k ∈ finset.range (n + 1)), (n + 1) * (polynomial.bernoulli k).eval x^k) * x^(l - 1),\n      {\n        -- We want to prove that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h5 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto,\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h6 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h7 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h8 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h9 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h10 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h11 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h12 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h13 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h14 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\n        have h15 : (n + 1) * (1 + x)^i - (n + 1) * x^i = (n + 1) * (1 + x)^i - (n + 1) * x^i, from by auto [mul_sub],\n        -- We want to show that $$(d + 1) (1 + x)^i - (d + 1) x^i = \\sum_{l = 0}^{d} {\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) := \nbegin\n  -- We apply strong induction on $n$\n  by_cases (n = 0),\n  {\n    assume h0 : n = 0,\n    show (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1), from by auto [h0, polynomial.bernoulli_zero]\n  },\n  {\n    assume h0 : n ≠ 0,\n    have h1 : ∀ (m : ℕ) (h : m < n), (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [lt_of_le_of_ne, polynomial.bernoulli_eval_one_add_lemma],\n    have h2 : ∀ (m : ℕ) (h : m > n), (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [lt_of_le_of_ne, polynomial.bernoulli_eval_one_add_lemma],\n    have h3 : ∀ (m : ℕ) (h : m = n), (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [lt_of_le_of_ne, polynomial.bernoulli_eval_one_add_lemma],\n    show (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1), from by auto [h1, h2, h3, lt_irrefl, nat.not_succ_le_zero, nat.not_succ_le_self, nat.succ_pos, lt_or_eq_of_le, ne.def, eq.symm, lt_of_lt_of_le, lt_of_le_of_ne]\n  },\nend\n\n--OUTPUT 3\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  -- apply strong induction on $n$\n  apply nat.strong_induction_on n,\n  assume n (ih : ∀ m : ℕ, m < n → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1)),\n  show (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1),\n  -- multiply both sides by $d + 1$\n  calc (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + (n + 1) * x^n : by auto [bernoulli_eval_add]\n  -- Using the fact that, for all $l \\in \\mathbb{N}$, $\\sum_{k = 0}^{l} {l + 1 \\choose k} B_k = (l + 1) X^l$\n  ... = (polynomial.bernoulli n).eval x + (n + 1) * x^n : by rw [nat.sum_eq_sum_binomial, add_comm, polynomial.eval_pow, polynomial.eval_C],\n  -- The conclusion then follows easily.\n  ... = (polynomial.bernoulli n).eval x + n * x^(n - 1) : by rw [nat.sub_add_cancel, nat.sub_add_cancel]\nend\n\n--OUTPUT 4\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  -- We apply strong induction on $n$.\n  induction n with d hd,\n  -- So, for all $m < d$, we have $B_{m} (1 + x) = B_{m} (x) + m x^{m - 1}$\n  -- and we want to show that $$B_{d} (1 + x) = B_{d} (x) + d x^{d - 1}$$\n  have h1 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h2 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h3 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h4 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h5 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h6 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h7 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h8 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h9 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h10 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h11 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h12 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h13 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h14 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h15 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h16 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h17 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h18 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h19 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h20 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h21 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h22 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h23 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h24 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h25 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h26 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h27 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h28 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h29 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h30 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h31 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h32 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h33 : ∀ m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h34 : ∀ m < d, (polynomial.bernoulli\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli m = (m + 1) * polynomial.X^m - ∑ l in finset.range (m + 1), (m + 1) * (finset.range (m + 1)).sum (λ (k : ℕ), (m + 1) * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)), from \n    by auto [polynomial.eval_sum, polynomial.eval_pow, polynomial.eval_X, polynomial.eval_C, polynomial.X_ne_zero, polynomial.eval_smul, polynomial.eval_add, polynomial.eval_sub, polynomial.eval_C],\n  have h2 : ∀ (m : ℕ) (x : ℚ), (m + 1) * polynomial.X^m - ∑ l in finset.range (m + 1), (m + 1) * (finset.range (m + 1)).sum (λ (k : ℕ), (m + 1) * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)) = m * polynomial.X^m - ∑ l in finset.range m, m * (finset.range m).sum (λ (k : ℕ), m * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)), from\n    by auto [polynomial.eval_sum, polynomial.eval_pow, polynomial.eval_X, polynomial.eval_C, polynomial.X_ne_zero, polynomial.eval_smul, polynomial.eval_add, polynomial.eval_sub, polynomial.eval_C],\n  have h3 : ∀ (m : ℕ) (x : ℚ), (m + 1) * polynomial.X^m - ∑ l in finset.range m, m * (finset.range m).sum (λ (k : ℕ), m * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)) = m * polynomial.X^m - ∑ l in finset.range m, m * (finset.range m).sum (λ (k : ℕ), m * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)) + polynomial.X^m + m * polynomial.X^(m - 1) * polynomial.bernoulli m / (m + 1), from\n    by auto [polynomial.eval_sum, polynomial.eval_pow, polynomial.eval_X, polynomial.eval_C, polynomial.X_ne_zero, polynomial.eval_smul, polynomial.eval_add, polynomial.eval_sub, polynomial.eval_C],\n  have h4 : ∀ (m : ℕ) (x : ℚ), m * polynomial.X^m - ∑ l in finset.range m, m * (finset.range m).sum (λ (k : ℕ), m * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)) + polynomial.X^m + m * polynomial.X^(m - 1) * polynomial.bernoulli m / (m + 1) = polynomial.X^m + m * polynomial.X^(m - 1) * polynomial.bernoulli m / (m + 1), from\n    by auto [polynomial.eval_sum, polynomial.eval_pow, polynomial.eval_X, polynomial.eval_C, polynomial.X_ne_zero, polynomial.eval_smul, polynomial.eval_add, polynomial.eval_sub, polynomial.eval_C],\n  have h5 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli m = polynomial.X^m + m * polynomial.X^(m - 1) * polynomial.bernoulli m / (m + 1), from\n    by auto [h1, h2, h3, h4],\n  have h6 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli m = polynomial.X^m + m * polynomial.X^(m - 1) * polynomial.bernoulli m / (m + 1), from\n    by auto [h5],\n  have h7 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h6],\n  have h8 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h7],\n  have h9 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from \n    by auto [h8],\n  have h10 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h9],\n  have h11 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h10],\n  have h12 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h11],\n  have h13 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h12],\n  have h14 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h13],\n  have h15 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h14],\n  have h16 : ∀ (m : ℕ) (x : ℚ), polynomial.bernoulli (m + 1) = polynomial.bernoulli m + (m + 1) * polynomial.X^m * polynomial.bernoulli (m + 1) / (m + 2), from\n    by auto [h15],\n  have h17 : ∀ (m :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : (∀ m : ℕ, m < n → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1)),\n  { assume m,\n    assume hm : m < n,\n    induction m with m IH hm,\n    { -- base case\n      show (polynomial.bernoulli 0).eval (1 + x) = (polynomial.bernoulli 0).eval x + 0 * x^(0 - 1),\n        by auto using [bernoulli_zero, eval_zero, eval_one, zero_add, zero_mul]\n    },\n    { -- inductive step\n      have hm1 : m < n, from nat.lt_of_succ_lt hm,\n      have h1 : (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from IH hm1,\n      have h2 : (polynomial.bernoulli (m + 1)).eval (1 + x) = (polynomial.bernoulli (m + 1)).eval x + (m + 1) * x^((m + 1) - 1),\n      {\n        calc (polynomial.bernoulli (m + 1)).eval (1 + x) = (polynomial.bernoulli (m + 1)).eval x + m * (1 + x)^(m + 1) - (m + 1) * x^(m + 1) : by auto [bernoulli_add_one, eval_add, eval_mul, eval_pow]\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * (1 + x)^m * (1 + x) - (m + 1) * x^(m + 1) : by rw nat.succ_eq_add_one\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * (1 + x)^m * (1 + x) - (m + 1) * x^m * x : by rw nat.succ_eq_add_one\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * (1 + x)^m * (1 + x) - m * x^m * x - x^m * x : by rw nat.add_sub_cancel\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * (1 + x)^m * (1 + x) - m * x^m * x - x^m * x : by rw mul_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * (1 + x)^m * 1 - m * x^m * x - x^m * x : by rw mul_one\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * (1 + x)^m * 1 - m * x^m * x - x^m * x : by rw one_mul\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m * 1) - m * x^m * x - x^m * x : by rw mul_one\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m * 1) - (m * x^m * x + x^m * x) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m * 1) - m * x^m * x - x^m * x : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m * 1) - (m * x^m * x + x^m * x) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m * 1) - (m * x^m + x^m) * x : by rw mul_add\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m * 1) - m * x^m * x - x^m * x : by rw mul_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - m * x^m * x - x^m * x : by rw mul_one\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * x^m * x + x^m * x) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * x^m * x + x^m * x) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - m * x^m * x - x^m * x : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * x^m * x + x^m * x) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * x^m + x^m) * x : by rw mul_add\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - m * x^m * x - x^m * x : by rw mul_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * x^m * x + x^m * x) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * x^m + x^m) * x : by rw mul_add\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - m * x^m * x - x^m * x : by rw mul_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * x^m * x + x^m * x) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - ((m * x^m * x + x^m * x) + (m * ((1 + x)^m) - (m * x^m * x + x^m * x))) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - ((m * ((1 + x)^m) + (m * x^m * x + x^m * x)) + (m * ((1 + x)^m) - (m * x^m * x + x^m * x))) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * ((1 + x)^m) + (m * ((1 + x)^m) - (m * x^m * x + x^m * x))) : by rw add_comm\n        ... = (polynomial.bernoulli (m + 1)).eval x + m * ((1 + x)^m) - (m * ((1 + x)^m) + ((m * ((1 + x)^m) - (m * x^m * x + x^m * x)) + (m * x^m * x + x^m * x))) : by rw add_comm\n        ... = (polynomial.bernoulli (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  -- We apply strong induction on $n$\n  apply nat.strong_induction_on n,\n  -- So, for all $m < d$, we have $B_{m} (1 + x) = B_{m} (x) + m x^{m - 1}$ and we want to show that $$B_{d} (1 + x) = B_{d} (x) + d x^{d - 1}$$\n  assume d,\n  assume h : ∀ m : ℕ, m < d → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1),\n  -- Multiplying both sides by $d + 1$, and using the fact that, for all $l \\in \\mathbb{N}$, $\\sum_{k = 0}^{l} {l + 1 \\choose k} B_k = (l + 1) X^l$ (where $B_k$ is the $k$-th Bernoulli number), we get that \n  have h1 : (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval x = (d + 1) * (x^d),\n  begin\n    -- Multiplying both sides by $d + 1$\n    calc (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval x = (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval x : by auto [ring]\n    ... = (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x + -x) : by auto [ring]\n    ... = (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x) + (d + 1) * (polynomial.bernoulli d).eval x : by auto [ring]\n    ... = (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x) + (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval x : by auto [ring]\n    ... = (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x) + (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval x : by auto [ring]\n    ... = (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x) + (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x) - (d + 1) * (polynomial.bernoulli d).eval (1 + x) + (d + 1) * (polynomial.bernoulli d).eval x : by auto [ring]\n    ... = (d + 1) * ((polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval x) : by auto [ring]\n    ... = (d + 1) * ((polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval x) : by auto [ring]\n    ... = (d + 1) * ((polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval x) : by auto [ring]\n    ... = (d + 1) * ((polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval x) : by auto [ring]\n    ... = (d + 1) * ((polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval x) : by auto [ring]\n    ... = (d + 1) * ((polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval x) : by auto [ring]\n    ... = (d + 1) * ((polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bernoulli d).eval (1 + x) + (polynomial.bernoulli d).eval (1 + x) - (polynomial.bern\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  induction n with d hd,\n  {\n    -- base case\n    show (polynomial.bernoulli 0).eval (1 + x) = (polynomial.bernoulli 0).eval x + 0 * x^(0 - 1), from by auto [ring],\n  },\n  {\n    -- inductive case\n    have h1 : (polynomial.bernoulli d).eval (1 + x) = (polynomial.bernoulli d).eval x + d * x^(d - 1), from hd,\n    have h2 : (d + 1) * (polynomial.bernoulli (d + 1)).eval (1 + x) = (d + 1) * (polynomial.bernoulli (d + 1)).eval x + (d + 1) * (d + 1) * x^(d + 1 - 1), by auto [ring, h1],\n    have h3 : (d + 1) * (polynomial.bernoulli (d + 1)).eval (1 + x) = (d + 1) * (polynomial.bernoulli (d + 1)).eval x + (d + 1) * (d + 1) * x^(d), from by auto [ring],\n    have h4 : (d + 1) * (polynomial.bernoulli (d + 1)).eval (1 + x) - (d + 1) * (polynomial.bernoulli (d + 1)).eval x = (d + 1) * (d + 1) * x^(d), from by auto [ring],\n    have h5 : (d + 1) * (polynomial.bernoulli (d + 1)).eval (1 + x) - (d + 1) * (polynomial.bernoulli (d + 1)).eval x = (d + 1) * (d + 1 - 1) * x^(d - 1) + (d + 1) * x^(d - 1), from by auto [ring],\n    have h6 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (d + 1 - 1) * x^(d - 1) + (d + 1) * x^(d - 1), from by auto [ring, h4],\n    have h7 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (d + 1 - 1) * x^(d - 1) + (d + 1) * x^(d - 1), from by auto [ring],\n    have h8 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (d * x^(d - 1)) + (d + 1) * x^(d - 1), from by auto [ring],\n    have h9 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = d * (d + 1) * x^(d - 1) + (d + 1) * x^(d - 1), from by auto [ring],\n    have h10 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * ((d + 1) * x^(d - 1) + x^(d - 1)), from by auto [ring],\n    have h11 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + d * x^(d - 1) + x^(d - 1)), from by auto [ring],\n    have h12 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1) * d * x^(d - 1) + (d + 1) * x^(d - 1), from by auto [ring],\n    have h13 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1) * d * x^(d - 1) + (d + 1) * x^(d - 1), from by auto [ring],\n    have h14 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1) * x^(d - 1) + (d + 1) * d * x^(d - 1), from by auto [ring],\n    have h15 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1) * x^(d - 1) + (d + 1) * d * x^(d - 1), from by auto [ring],\n    have h16 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1) * (x^(d - 1) + d * x^(d - 1)), from by auto [ring],\n    have h17 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1) * ((d + 1) * x^(d - 1)), from by auto [ring],\n    have h18 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1)^2 * x^(d - 1), from by auto [ring],\n    have h19 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * x^(d - 1) + (d + 1)^2 * x^(d - 1), from by auto [ring],\n    have h20 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x^(d - 1)), from by auto [ring],\n    have h21 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x^(d - 1)), from by auto [ring],\n    have h22 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x^(d - 1)), from by auto [ring],\n    have h23 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x^(d - 1)), from by auto [ring],\n    have h24 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x^(d - 1)), from by auto [ring],\n    have h25 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x^(d - 1)), from by auto [ring],\n    have h26 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x^(d - 1)), from by auto [ring],\n    have h27 : (d + 1) * ((1 + x)^(d + 1) - x^(d + 1)) = (d + 1) * (x^(d - 1) + (d + 1) * x\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\nBernoulli polynomial evaluation\nGiven a natural number $n$ and a rational $x$, let $B_n (x)$ denote the $n$-th Bernoulli polynomial evaluated at $x$. Then, $$B_n (1 + x) = B_n (x) + n x^{n - 1}$$\n`proof`\nWe apply strong induction on $n$. So, for all $m < d$, we have $B_{m} (1 + x) = B_{m} (x) + m x^{m - 1}$ and we want to show that $$B_{d} (1 + x) = B_{d} (x) + d x^{d - 1}$$\nMultiplying both sides by $d + 1$, and using the fact that, for all $l \\in \\mathbb{N}$, $\\sum_{k = 0}^{l} {l + 1 \\choose k} B_k = (l + 1) X^l$ (where $B_k$ is the $k$-th Bernoulli number), we get that \n$$ (d + 1) (1 + x)^d - (d + 1) x^d = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\nThe conclusion then follows easily.\n\nQED\n\n-/\ntheorem  bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto_with_comments-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto_with_comments-3_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Bernoulli polynomial evaluation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430520409023, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.47362907190996295}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport deprecated.subgroup\nimport deprecated.group\nimport ring_theory.subring.basic\n\n/-!\n# Unbundled subrings (deprecated)\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file is deprecated, and is no longer imported by anything in mathlib other than other\ndeprecated files, and test files. You should not need to import it.\n\nThis file defines predicates for unbundled subrings. Instead of using this file, please use\n`subring`, defined in `ring_theory.subring.basic`, for subrings of rings.\n\n## Main definitions\n\n`is_subring (S : set R) : Prop` : the predicate that `S` is the underlying set of a subring\nof the ring `R`. The bundled variant `subring R` should be used in preference to this.\n\n## Tags\n\nis_subring\n-/\nuniverses u v\n\nopen group\n\nvariables {R : Type u} [ring R]\n\n/-- `S` is a subring: a set containing 1 and closed under multiplication, addition and additive\ninverse. -/\nstructure is_subring (S : set R) extends is_add_subgroup S, is_submonoid S : Prop.\n\n/-- Construct a `subring` from a set satisfying `is_subring`. -/\ndef is_subring.subring {S : set R} (hs : is_subring S) : subring R :=\n{ carrier := S,\n  one_mem' := hs.one_mem,\n  mul_mem' := λ _ _, hs.mul_mem,\n  zero_mem' := hs.zero_mem,\n  add_mem' := λ _ _, hs.add_mem,\n  neg_mem' := λ _, hs.neg_mem }\n\nnamespace ring_hom\n\nlemma is_subring_preimage {R : Type u} {S : Type v} [ring R] [ring S]\n  (f : R →+* S) {s : set S} (hs : is_subring s) : is_subring (f ⁻¹' s) :=\n{ ..is_add_group_hom.preimage f.to_is_add_group_hom hs.to_is_add_subgroup,\n  ..is_submonoid.preimage f.to_is_monoid_hom hs.to_is_submonoid, }\n\nlemma is_subring_image {R : Type u} {S : Type v} [ring R] [ring S]\n  (f : R →+* S) {s : set R} (hs : is_subring s) : is_subring (f '' s) :=\n{ ..is_add_group_hom.image_add_subgroup f.to_is_add_group_hom hs.to_is_add_subgroup,\n  ..is_submonoid.image f.to_is_monoid_hom hs.to_is_submonoid, }\n\nlemma is_subring_set_range {R : Type u} {S : Type v} [ring R] [ring S]\n  (f : R →+* S) : is_subring (set.range f) :=\n{ ..is_add_group_hom.range_add_subgroup f.to_is_add_group_hom,\n  ..range.is_submonoid f.to_is_monoid_hom, }\n\nend ring_hom\n\nvariables {cR : Type u} [comm_ring cR]\n\nlemma is_subring.inter {S₁ S₂ : set R} (hS₁ : is_subring S₁) (hS₂ : is_subring S₂) :\n  is_subring (S₁ ∩ S₂) :=\n{ ..is_add_subgroup.inter hS₁.to_is_add_subgroup hS₂.to_is_add_subgroup,\n  ..is_submonoid.inter hS₁.to_is_submonoid hS₂.to_is_submonoid }\n\nlemma is_subring.Inter {ι : Sort*} {S : ι → set R} (h : ∀ y : ι, is_subring (S y)) :\n  is_subring (set.Inter S) :=\n{ ..is_add_subgroup.Inter (λ i, (h i).to_is_add_subgroup),\n  ..is_submonoid.Inter (λ i, (h i).to_is_submonoid) }\n\nlemma is_subring_Union_of_directed {ι : Type*} [hι : nonempty ι]\n  {s : ι → set R} (h : ∀ i, is_subring (s i))\n  (directed : ∀ i j, ∃ k, s i ⊆ s k ∧ s j ⊆ s k) :\n  is_subring (⋃i, s i) :=\n{ to_is_add_subgroup := is_add_subgroup_Union_of_directed\n    (λ i, (h i).to_is_add_subgroup) directed,\n  to_is_submonoid := is_submonoid_Union_of_directed (λ i, (h i).to_is_submonoid) directed }\n\nnamespace ring\n\n/-- The smallest subring containing a given subset of a ring, considered as a set. This function\nis deprecated; use `subring.closure`. -/\ndef closure (s : set R) := add_group.closure (monoid.closure s)\n\nvariable {s : set R}\n\nlocal attribute [reducible] closure\n\ntheorem exists_list_of_mem_closure {a : R} (h : a ∈ closure s) :\n  (∃ L : list (list R), (∀ l ∈ L, ∀ x ∈ l, x ∈ s ∨ x = (-1:R)) ∧ (L.map list.prod).sum = a) :=\nadd_group.in_closure.rec_on h\n  (λ x hx, match x, monoid.exists_list_of_mem_closure hx with\n    | _, ⟨L, h1, rfl⟩ := ⟨[L], list.forall_mem_singleton.2 (λ r hr, or.inl (h1 r hr)), zero_add _⟩\n    end)\n  ⟨[], list.forall_mem_nil _, rfl⟩\n  (λ b _ ih, match b, ih with\n    | _, ⟨L1, h1, rfl⟩ := ⟨L1.map (list.cons (-1)),\n      λ L2 h2, match L2, list.mem_map.1 h2 with\n        | _, ⟨L3, h3, rfl⟩ := list.forall_mem_cons.2 ⟨or.inr rfl, h1 L3 h3⟩\n        end,\n      by simp only [list.map_map, (∘), list.prod_cons, neg_one_mul];\n      exact list.rec_on L1 neg_zero.symm (λ hd tl ih,\n        by rw [list.map_cons, list.sum_cons, ih, list.map_cons, list.sum_cons, neg_add])⟩\n    end)\n  (λ r1 r2 hr1 hr2 ih1 ih2, match r1, r2, ih1, ih2 with\n    | _, _, ⟨L1, h1, rfl⟩, ⟨L2, h2, rfl⟩ := ⟨L1 ++ L2, list.forall_mem_append.2 ⟨h1, h2⟩,\n      by rw [list.map_append, list.sum_append]⟩\n    end)\n\n@[elab_as_eliminator]\nprotected theorem in_closure.rec_on {C : R → Prop} {x : R} (hx : x ∈ closure s)\n  (h1 : C 1) (hneg1 : C (-1)) (hs : ∀ z ∈ s, ∀ n, C n → C (z * n))\n  (ha : ∀ {x y}, C x → C y → C (x + y)) : C x :=\nbegin\n  have h0 : C 0 := add_neg_self (1:R) ▸ ha h1 hneg1,\n  rcases exists_list_of_mem_closure hx with ⟨L, HL, rfl⟩, clear hx,\n  induction L with hd tl ih, { exact h0 },\n  rw list.forall_mem_cons at HL,\n  suffices : C (list.prod hd),\n  { rw [list.map_cons, list.sum_cons],\n    exact ha this (ih HL.2) },\n  replace HL := HL.1, clear ih tl,\n  rsuffices ⟨L, HL', HP | HP⟩ : ∃ L : list R,\n    (∀ x ∈ L, x ∈ s) ∧ (list.prod hd = list.prod L ∨ list.prod hd = -list.prod L),\n  { rw HP, clear HP HL hd, induction L with hd tl ih, { exact h1 },\n    rw list.forall_mem_cons at HL',\n    rw list.prod_cons,\n    exact hs _ HL'.1 _ (ih HL'.2) },\n  { rw HP, clear HP HL hd, induction L with hd tl ih, { exact hneg1 },\n    rw [list.prod_cons, neg_mul_eq_mul_neg],\n    rw list.forall_mem_cons at HL',\n    exact hs _ HL'.1 _ (ih HL'.2) },\n  induction hd with hd tl ih,\n  { exact ⟨[], list.forall_mem_nil _, or.inl rfl⟩ },\n  rw list.forall_mem_cons at HL,\n  rcases ih HL.2 with ⟨L, HL', HP | HP⟩; cases HL.1 with hhd hhd,\n  { exact ⟨hd :: L, list.forall_mem_cons.2 ⟨hhd, HL'⟩, or.inl $\n      by rw [list.prod_cons, list.prod_cons, HP]⟩ },\n  { exact ⟨L, HL', or.inr $ by rw [list.prod_cons, hhd, neg_one_mul, HP]⟩ },\n  { exact ⟨hd :: L, list.forall_mem_cons.2 ⟨hhd, HL'⟩, or.inr $\n      by rw [list.prod_cons, list.prod_cons, HP, neg_mul_eq_mul_neg]⟩ },\n  { exact ⟨L, HL', or.inl $ by rw [list.prod_cons, hhd, HP, neg_one_mul, neg_neg]⟩ }\nend\n\nlemma closure.is_subring : is_subring (closure s) :=\n{ one_mem := add_group.mem_closure $ is_submonoid.one_mem $ monoid.closure.is_submonoid _,\n  mul_mem := λ a b ha hb, add_group.in_closure.rec_on hb\n    ( λ c hc, add_group.in_closure.rec_on ha\n      ( λ d hd, add_group.subset_closure ((monoid.closure.is_submonoid _).mul_mem hd hc))\n      ( (zero_mul c).symm ▸ (add_group.closure.is_add_subgroup _).zero_mem)\n      ( λ d hd hdc, neg_mul_eq_neg_mul d c ▸ (add_group.closure.is_add_subgroup _).neg_mem hdc)\n      ( λ d e hd he hdc hec, (add_mul d e c).symm ▸\n        ((add_group.closure.is_add_subgroup _).add_mem hdc hec)))\n    ( (mul_zero a).symm ▸ (add_group.closure.is_add_subgroup _).zero_mem)\n    ( λ c hc hac, neg_mul_eq_mul_neg a c ▸ (add_group.closure.is_add_subgroup _).neg_mem hac)\n    ( λ c d hc hd hac had, (mul_add a c d).symm ▸\n      (add_group.closure.is_add_subgroup _).add_mem hac had),\n  ..add_group.closure.is_add_subgroup _}\n\ntheorem mem_closure {a : R} : a ∈ s → a ∈ closure s :=\nadd_group.mem_closure ∘ @monoid.subset_closure _ _ _ _\n\ntheorem subset_closure : s ⊆ closure s :=\nλ _, mem_closure\n\ntheorem closure_subset {t : set R} (ht : is_subring t) : s ⊆ t → closure s ⊆ t :=\n(add_group.closure_subset ht.to_is_add_subgroup) ∘ (monoid.closure_subset ht.to_is_submonoid)\n\ntheorem closure_subset_iff {s t : set R} (ht : is_subring t) : closure s ⊆ t ↔ s ⊆ t :=\n(add_group.closure_subset_iff ht.to_is_add_subgroup).trans\n  ⟨set.subset.trans monoid.subset_closure, monoid.closure_subset ht.to_is_submonoid⟩\n\ntheorem closure_mono {s t : set R} (H : s ⊆ t) : closure s ⊆ closure t :=\nclosure_subset closure.is_subring $ set.subset.trans H subset_closure\n\nlemma image_closure {S : Type*} [ring S] (f : R →+* S) (s : set R) :\n  f '' closure s = closure (f '' s) :=\nle_antisymm\n  begin\n    rintros _ ⟨x, hx, rfl⟩,\n    apply in_closure.rec_on hx; intros,\n    { rw [f.map_one], apply closure.is_subring.to_is_submonoid.one_mem },\n    { rw [f.map_neg, f.map_one],\n      apply closure.is_subring.to_is_add_subgroup.neg_mem,\n      apply closure.is_subring.to_is_submonoid.one_mem },\n    { rw [f.map_mul],\n      apply closure.is_subring.to_is_submonoid.mul_mem;\n      solve_by_elim [subset_closure, set.mem_image_of_mem] },\n    { rw [f.map_add], apply closure.is_subring.to_is_add_submonoid.add_mem, assumption' },\n  end\n  (closure_subset (ring_hom.is_subring_image _ closure.is_subring) $\n    set.image_subset _ subset_closure)\n\nend ring\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/deprecated/subring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430436757312, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.473629067143048}}
{"text": "/-\nCopyright (c) 2014 Parikshit Khanna. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro\n-/\nimport Std.Control.ForInStep.Lemmas\nimport Std.Data.Nat.Lemmas\nimport Std.Data.List.Basic\nimport Std.Data.Option.Lemmas\nimport Std.Classes.BEq\nimport Std.Tactic.Ext\n\nnamespace List\n\nopen Nat\n\n/-! # Basic properties of Lists -/\n\ntheorem cons_ne_nil (a : α) (l : List α) : a :: l ≠ [] := fun.\n\ntheorem cons_ne_self (a : α) (l : List α) : a :: l ≠ l := mt (congrArg length) (Nat.succ_ne_self _)\n\ntheorem head_eq_of_cons_eq (H : h₁ :: t₁ = h₂ :: t₂) : h₁ = h₂ := (cons.inj H).1\n\ntheorem tail_eq_of_cons_eq (H : h₁ :: t₁ = h₂ :: t₂) : t₁ = t₂ := (cons.inj H).2\n\ntheorem cons_inj (a : α) {l l' : List α} : a :: l = a :: l' ↔ l = l' :=\n  ⟨tail_eq_of_cons_eq, congrArg _⟩\n\ntheorem exists_cons_of_ne_nil : ∀ {l : List α}, l ≠ [] → ∃ b L, l = b :: L\n  | c :: l', _ => ⟨c, l', rfl⟩\n\n/-! ### length -/\n\n@[simp 1100] theorem length_singleton (a : α) : length [a] = 1 := rfl\n\ntheorem length_pos_of_mem {a : α} : ∀ {l : List α}, a ∈ l → 0 < length l\n  | _::_, _ => Nat.zero_lt_succ _\n\ntheorem exists_mem_of_length_pos : ∀ {l : List α}, 0 < length l → ∃ a, a ∈ l\n  | _::_, _ => ⟨_, .head ..⟩\n\ntheorem length_pos_iff_exists_mem {l : List α} : 0 < length l ↔ ∃ a, a ∈ l :=\n  ⟨exists_mem_of_length_pos, fun ⟨_, h⟩ => length_pos_of_mem h⟩\n\ntheorem length_pos {l : List α} : 0 < length l ↔ l ≠ [] :=\n  Nat.pos_iff_ne_zero.trans (not_congr length_eq_zero)\n\ntheorem exists_mem_of_ne_nil (l : List α) (h : l ≠ []) : ∃ x, x ∈ l :=\n  exists_mem_of_length_pos (length_pos.2 h)\n\ntheorem length_eq_one {l : List α} : length l = 1 ↔ ∃ a, l = [a] :=\n  ⟨fun h => match l, h with | [_], _ => ⟨_, rfl⟩, fun ⟨_, h⟩ => by simp [h]⟩\n\n/-! ### mem -/\n\n@[simp] theorem not_mem_nil (a : α) : ¬ a ∈ [] := fun.\n\ntheorem mem_nil_iff (a : α) : a ∈ ([] : List α) ↔ False := by simp\n\n@[simp] theorem mem_cons : a ∈ (b :: l) ↔ a = b ∨ a ∈ l :=\n  ⟨fun h => by cases h <;> simp [Membership.mem, *],\n   fun | Or.inl rfl => by constructor | Or.inr h => by constructor; assumption⟩\n\ntheorem mem_cons_self (a : α) (l : List α) : a ∈ a :: l := .head ..\n\ntheorem mem_cons_of_mem (y : α) {a : α} {l : List α} : a ∈ l → a ∈ y :: l := .tail _\n\ntheorem mem_singleton_self (a : α) : a ∈ [a] := mem_cons_self _ _\n\ntheorem eq_of_mem_singleton : a ∈ [b] → a = b\n  | .head .. => rfl\n\n@[simp 1100] theorem mem_singleton {a b : α} : a ∈ [b] ↔ a = b :=\n  ⟨eq_of_mem_singleton, (by simp [·])⟩\n\ntheorem mem_of_mem_cons_of_mem : ∀ {a b : α} {l : List α}, a ∈ b :: l → b ∈ l → a ∈ l\n  | _, _, _, .head .., h | _, _, _, .tail _ h, _ => h\n\ntheorem eq_or_ne_mem_of_mem {a b : α} {l : List α} (h' : a ∈ b :: l) : a = b ∨ (a ≠ b ∧ a ∈ l) :=\n  (Classical.em _).imp_right fun h => ⟨h, (mem_cons.1 h').resolve_left h⟩\n\ntheorem ne_nil_of_mem {a : α} {l : List α} (h : a ∈ l) : l ≠ [] := by cases h <;> intro.\n\ntheorem append_of_mem {a : α} {l : List α} : a ∈ l → ∃ s t : List α, l = s ++ a :: t\n  | .head l => ⟨[], l, rfl⟩\n  | .tail b h => let ⟨s, t, h'⟩ := append_of_mem h; ⟨b::s, t, by rw [h', cons_append]⟩\n\n@[simp] theorem elem_iff [DecidableEq α] {a : α} {as : List α} :\n    elem a as ↔ a ∈ as := ⟨mem_of_elem_eq_true, elem_eq_true_of_mem⟩\n\ntheorem mem_of_ne_of_mem {a y : α} {l : List α} (h₁ : a ≠ y) (h₂ : a ∈ y :: l) : a ∈ l :=\n  Or.elim (mem_cons.mp h₂) (absurd · h₁) (·)\n\ntheorem ne_of_not_mem_cons {a b : α} {l : List α} : a ∉ b::l → a ≠ b := mt (· ▸ .head _)\n\ntheorem not_mem_of_not_mem_cons {a b : α} {l : List α} : a ∉ b::l → a ∉ l := mt (.tail _)\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : α} {l : List α} : a ≠ y → a ∉ l → a ∉ y::l :=\n  mt ∘ mem_of_ne_of_mem\n\ntheorem ne_and_not_mem_of_not_mem_cons {a y : α} {l : List α} : a ∉ y::l → a ≠ y ∧ a ∉ l :=\n  fun p => ⟨ne_of_not_mem_cons p, not_mem_of_not_mem_cons p⟩\n\n/-! ### append -/\n\ntheorem append_eq_append : List.append l₁ l₂ = l₁ ++ l₂ := rfl\n\n@[simp] theorem append_eq_nil : p ++ q = [] ↔ p = [] ∧ q = [] := by\n  cases p <;> simp\n\ntheorem append_ne_nil_of_ne_nil_left (s t : List α) : s ≠ [] → s ++ t ≠ [] := by simp_all\n\ntheorem append_ne_nil_of_ne_nil_right (s t : List α) : t ≠ [] → s ++ t ≠ [] := by simp_all\n\n@[simp] theorem nil_eq_append : [] = a ++ b ↔ a = [] ∧ b = [] := by\n  rw [eq_comm, append_eq_nil]\n\ntheorem append_ne_nil_of_left_ne_nil (a b : List α) (h0 : a ≠ []) : a ++ b ≠ [] := by simp [*]\n\ntheorem append_eq_cons :\n    a ++ b = x :: c ↔ (a = [] ∧ b = x :: c) ∨ (∃ a', a = x :: a' ∧ c = a' ++ b) := by\n  cases a with simp | cons a as => ?_\n  exact ⟨fun h => ⟨as, by simp [h]⟩, fun ⟨a', ⟨aeq, aseq⟩, h⟩ => ⟨aeq, by rw [aseq, h]⟩⟩\n\ntheorem cons_eq_append :\n    x :: c = a ++ b ↔ (a = [] ∧ b = x :: c) ∨ (∃ a', a = x :: a' ∧ c = a' ++ b) := by\n  rw [eq_comm, append_eq_cons]\n\ntheorem append_eq_append_iff {a b c d : List α} :\n  a ++ b = c ++ d ↔ (∃ a', c = a ++ a' ∧ b = a' ++ d) ∨ ∃ c', a = c ++ c' ∧ d = c' ++ b := by\n  induction a generalizing c with\n  | nil => simp; exact (or_iff_left_of_imp fun ⟨_, ⟨e, rfl⟩, h⟩ => e ▸ h.symm).symm\n  | cons a as ih => cases c <;> simp [eq_comm, and_assoc, ih, and_or_left]\n\n@[simp] theorem mem_append {a : α} {s t : List α} : a ∈ s ++ t ↔ a ∈ s ∨ a ∈ t := by\n  induction s <;> simp_all [or_assoc]\n\ntheorem not_mem_append {a : α} {s t : List α} (h₁ : a ∉ s) (h₂ : a ∉ t) : a ∉ s ++ t :=\n  mt mem_append.1 $ not_or.mpr ⟨h₁, h₂⟩\n\ntheorem mem_append_eq (a : α) (s t : List α) : (a ∈ s ++ t) = (a ∈ s ∨ a ∈ t) :=\n  propext mem_append\n\ntheorem mem_append_left {a : α} {l₁ : List α} (l₂ : List α) (h : a ∈ l₁) : a ∈ l₁ ++ l₂ :=\n  mem_append.2 (Or.inl h)\n\ntheorem mem_append_right {a : α} (l₁ : List α) {l₂ : List α} (h : a ∈ l₂) : a ∈ l₁ ++ l₂ :=\n  mem_append.2 (Or.inr h)\n\n/-! ### map -/\n\ntheorem map_singleton (f : α → β) (a : α) : map f [a] = [f a] := rfl\n\n@[simp] theorem mem_map {f : α → β} : ∀ {l : List α}, b ∈ l.map f ↔ ∃ a, a ∈ l ∧ f a = b\n  | [] => by simp\n  | _ :: l => by simp [mem_map (l := l), eq_comm (a := b)]\n\ntheorem mem_map_of_mem (f : α → β) (h : a ∈ l) : f a ∈ map f l := mem_map.2 ⟨_, h, rfl⟩\n\ntheorem exists_of_mem_map (h : b ∈ map f l) : ∃ a, a ∈ l ∧ f a = b := mem_map.1 h\n\ntheorem forall_mem_map_iff {f : α → β} {l : List α} {P : β → Prop} :\n    (∀ i ∈ l.map f, P i) ↔ ∀ j ∈ l, P (f j) := by\n  simp; exact ⟨fun H j h => H _ _ h rfl, fun H i x h e => e ▸ H _ h⟩\n\n@[simp] theorem map_eq_nil {f : α → β} {l : List α} : map f l = [] ↔ l = [] := by\n  constructor <;> exact fun _ => match l with | [] => rfl\n\n@[simp] theorem length_zipWith (f : α → β → γ) (l₁ l₂) :\n    length (zipWith f l₁ l₂) = min (length l₁) (length l₂) := by\n  induction l₁ generalizing l₂ <;> cases l₂ <;>\n    simp_all [add_one, min_succ_succ, Nat.zero_min, Nat.min_zero]\n\n/-! ### join -/\n\ntheorem join_nil : join ([] : List (List α)) = [] := rfl\n\ntheorem join_cons : join (a :: l : List (List α)) = a ++ join l := rfl\n\ntheorem mem_join : ∀ {L : List (List α)}, a ∈ L.join ↔ ∃ l, l ∈ L ∧ a ∈ l\n  | [] => by simp\n  | b :: l => by simp [mem_join, or_and_right, exists_or]\n\ntheorem exists_of_mem_join : a ∈ join L → ∃ l, l ∈ L ∧ a ∈ l := mem_join.1\n\ntheorem mem_join_of_mem (lL : l ∈ L) (al : a ∈ l) : a ∈ join L := mem_join.2 ⟨l, lL, al⟩\n\n/-! ### bind -/\n\ntheorem mem_bind {f : α → List β} {b} {l : List α} : b ∈ l.bind f ↔ ∃ a, a ∈ l ∧ b ∈ f a := by\n  simp [List.bind, mem_join]\n  exact ⟨fun ⟨_, ⟨a, h₁, rfl⟩, h₂⟩ => ⟨a, h₁, h₂⟩, fun ⟨a, h₁, h₂⟩ => ⟨_, ⟨a, h₁, rfl⟩, h₂⟩⟩\n\ntheorem exists_of_mem_bind {b : β} {l : List α} {f : α → List β} :\n    b ∈ List.bind l f → ∃ a, a ∈ l ∧ b ∈ f a := mem_bind.1\n\ntheorem mem_bind_of_mem {b : β} {l : List α} {f : α → List β} {a} (al : a ∈ l) (h : b ∈ f a) :\n    b ∈ List.bind l f := mem_bind.2 ⟨a, al, h⟩\n\ntheorem bind_map (f : β → γ) (g : α → List β) :\n    ∀ l : List α, map f (l.bind g) = l.bind fun a => (g a).map f\n  | [] => rfl\n  | a::l => by simp only [cons_bind, map_append, bind_map _ _ l]\n\n/-! ### set-theoretic notation of Lists -/\n\n@[simp] theorem empty_eq : (∅ : List α) = [] := rfl\n\n/-! ### bounded quantifiers over Lists -/\n\ntheorem exists_mem_nil (p : α → Prop) : ¬∃ x ∈ @nil α, p x := fun.\n\ntheorem forall_mem_nil (p : α → Prop) : ∀ x ∈ @nil α, p x := fun.\n\ntheorem exists_mem_cons {p : α → Prop} {a : α} {l : List α} :\n    (∃ x ∈ a :: l, p x) ↔ p a ∨ ∃ x ∈ l, p x := by simp\n\ntheorem forall_mem_cons {p : α → Prop} {a : α} {l : List α} :\n    (∀ x ∈ a :: l, p x) ↔ p a ∧ ∀ x ∈ l, p x := by simp\n\ntheorem forall_mem_singleton {p : α → Prop} {a : α} : (∀ x ∈ [a], p x) ↔ p a := by\n  simp only [mem_singleton, forall_eq]\n\ntheorem forall_mem_append {p : α → Prop} {l₁ l₂ : List α} :\n    (∀ x ∈ l₁ ++ l₂, p x) ↔ (∀ x ∈ l₁, p x) ∧ (∀ x ∈ l₂, p x) := by\n  simp only [mem_append, or_imp, forall_and]\n\n/-! ### List subset -/\n\ntheorem subset_def {l₁ l₂ : List α} : l₁ ⊆ l₂ ↔ ∀ {a : α}, a ∈ l₁ → a ∈ l₂ := .rfl\n\n@[simp] theorem nil_subset (l : List α) : [] ⊆ l := fun.\n\n@[simp] theorem Subset.refl (l : List α) : l ⊆ l := fun _ i => i\n\ntheorem Subset.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ ⊆ l₂) (h₂ : l₂ ⊆ l₃) : l₁ ⊆ l₃ :=\n  fun _ i => h₂ (h₁ i)\n\n@[simp] theorem subset_cons (a : α) (l : List α) : l ⊆ a :: l := fun _ => Mem.tail _\n\ntheorem subset_of_cons_subset {a : α} {l₁ l₂ : List α} : a :: l₁ ⊆ l₂ → l₁ ⊆ l₂ :=\n  fun s _ i => s (mem_cons_of_mem _ i)\n\ntheorem subset_cons_of_subset (a : α) {l₁ l₂ : List α} : l₁ ⊆ l₂ → l₁ ⊆ a :: l₂ :=\n  fun s _ i => .tail _ (s i)\n\ntheorem cons_subset_cons {l₁ l₂ : List α} (a : α) (s : l₁ ⊆ l₂) : a :: l₁ ⊆ a :: l₂ :=\n  fun _ => by simp only [mem_cons]; exact Or.imp_right (@s _)\n\n@[simp] theorem subset_append_left (l₁ l₂ : List α) : l₁ ⊆ l₁ ++ l₂ := fun _ => mem_append_left _\n\n@[simp] theorem subset_append_right (l₁ l₂ : List α) : l₂ ⊆ l₁ ++ l₂ := fun _ => mem_append_right _\n\ntheorem subset_append_of_subset_left (l₂ : List α) : l ⊆ l₁ → l ⊆ l₁ ++ l₂ :=\nfun s => Subset.trans s <| subset_append_left _ _\n\ntheorem subset_append_of_subset_right (l₁ : List α) : l ⊆ l₂ → l ⊆ l₁ ++ l₂ :=\nfun s => Subset.trans s <| subset_append_right _ _\n\n@[simp] theorem cons_subset : a :: l ⊆ m ↔ a ∈ m ∧ l ⊆ m := by\n  simp only [subset_def, mem_cons, or_imp, forall_and, forall_eq]\n\n@[simp] theorem append_subset {l₁ l₂ l : List α} :\n    l₁ ++ l₂ ⊆ l ↔ l₁ ⊆ l ∧ l₂ ⊆ l := by simp [subset_def, or_imp, forall_and]\n\ntheorem subset_nil {l : List α} : l ⊆ [] ↔ l = [] :=\n  ⟨fun h => match l with | [] => rfl | _::_ => nomatch h (.head ..), fun | rfl => Subset.refl _⟩\n\ntheorem eq_nil_iff_forall_not_mem {l : List α} : l = [] ↔ ∀ a, a ∉ l :=\n  subset_nil.symm.trans <| by simp [subset_def]\n\ntheorem map_subset {l₁ l₂ : List α} (f : α → β) (H : l₁ ⊆ l₂) : map f l₁ ⊆ map f l₂ :=\n  fun x => by simp only [mem_map]; exact .imp fun a => .imp_left (@H _)\n\n/-! ### replicate -/\n\ntheorem replicate_succ (a : α) (n) : replicate (n+1) a = a :: replicate n a := rfl\n\ntheorem mem_replicate {a b : α} : ∀ {n}, b ∈ replicate n a ↔ n ≠ 0 ∧ b = a\n  | 0 => by simp\n  | n+1 => by simp [mem_replicate, Nat.succ_ne_zero]\n\ntheorem eq_of_mem_replicate {a b : α} {n} (h : b ∈ replicate n a) : b = a := (mem_replicate.1 h).2\n\ntheorem eq_replicate_of_mem {a : α} :\n    ∀ {l : List α}, (∀ b ∈ l, b = a) → l = replicate l.length a\n  | [], _ => rfl\n  | b :: l, H => by\n    let ⟨rfl, H₂⟩ := forall_mem_cons.1 H\n    rw [length_cons, replicate, ← eq_replicate_of_mem H₂]\n\ntheorem eq_replicate {a : α} {n} {l : List α} :\n    l = replicate n a ↔ length l = n ∧ ∀ b ∈ l, b = a :=\n  ⟨fun h => h ▸ ⟨length_replicate .., fun _ => eq_of_mem_replicate⟩,\n   fun ⟨e, al⟩ => e ▸ eq_replicate_of_mem al⟩\n\n/-! ### getLast -/\n\ntheorem getLast_cons' {a : α} {l : List α} : ∀ (h₁ : a :: l ≠ nil) (h₂ : l ≠ nil),\n  getLast (a :: l) h₁ = getLast l h₂ := by\n  induction l <;> intros; {contradiction}; rfl\n\n@[simp] theorem getLast_append {a : α} : ∀ (l : List α) h, getLast (l ++ [a]) h = a\n  | [], _ => rfl\n  | a::t, h => by\n    simp [getLast_cons' _ fun H => cons_ne_nil _ _ (append_eq_nil.1 H).2, getLast_append t]\n\ntheorem getLast_concat : (h : concat l a ≠ []) → getLast (concat l a) h = a :=\n  concat_eq_append .. ▸ getLast_append _\n\n/-! ### sublists -/\n\n@[simp] theorem nil_sublist : ∀ l : List α, [] <+ l\n  | [] => .slnil\n  | a :: l => (nil_sublist l).cons a\n\n@[simp] theorem Sublist.refl : ∀ l : List α, l <+ l\n  | [] => .slnil\n  | a :: l => (Sublist.refl l).cons₂ a\n\ntheorem Sublist.trans {l₁ l₂ l₃ : List α} (h₁ : l₁ <+ l₂) (h₂ : l₂ <+ l₃) : l₁ <+ l₃ := by\n  induction h₂ generalizing l₁ with\n  | slnil => exact h₁\n  | cons _ _ IH => exact (IH h₁).cons _\n  | @cons₂ l₂ _ a _ IH =>\n    generalize e : a :: l₂ = l₂'\n    match e ▸ h₁ with\n    | .slnil => apply nil_sublist\n    | .cons a' h₁' => cases e; apply (IH h₁').cons\n    | .cons₂ a' h₁' => cases e; apply (IH h₁').cons₂\n\ninstance : Trans (@Sublist α) Sublist Sublist := ⟨Sublist.trans⟩\n\n@[simp] theorem sublist_cons (a : α) (l : List α) : l <+ a :: l := (Sublist.refl l).cons _\n\ntheorem sublist_of_cons_sublist : a :: l₁ <+ l₂ → l₁ <+ l₂ :=\n  (sublist_cons a l₁).trans\n\n@[simp] theorem sublist_append_left : ∀ l₁ l₂ : List α, l₁ <+ l₁ ++ l₂\n  | [], _ => nil_sublist _\n  | _ :: l₁, l₂ => (sublist_append_left l₁ l₂).cons₂ _\n\n@[simp] theorem sublist_append_right : ∀ l₁ l₂ : List α, l₂ <+ l₁ ++ l₂\n  | [], _ => Sublist.refl _\n  | _ :: l₁, l₂ => (sublist_append_right l₁ l₂).cons _\n\ntheorem sublist_append_of_sublist_left (s : l <+ l₁) : l <+ l₁ ++ l₂ :=\n  s.trans <| sublist_append_left ..\n\ntheorem sublist_append_of_sublist_right (s : l <+ l₂) : l <+ l₁ ++ l₂ :=\n  s.trans <| sublist_append_right ..\n\ntheorem cons_sublist_cons : a :: l₁ <+ a :: l₂ ↔ l₁ <+ l₂ :=\n  ⟨fun | .cons _ s => sublist_of_cons_sublist s | .cons₂ _ s => s, .cons₂ _⟩\n\n@[simp] theorem append_sublist_append_left : ∀ l, l ++ l₁ <+ l ++ l₂ ↔ l₁ <+ l₂\n  | [] => Iff.rfl\n  | _ :: l => cons_sublist_cons.trans (append_sublist_append_left l)\n\ntheorem Sublist.append_right : l₁ <+ l₂ → ∀ l, l₁ ++ l <+ l₂ ++ l\n  | .slnil, _ => Sublist.refl _\n  | .cons _ h, _ => (h.append_right _).cons _\n  | .cons₂ _ h, _ => (h.append_right _).cons₂ _\n\ntheorem sublist_or_mem_of_sublist (h : l <+ l₁ ++ a :: l₂) : l <+ l₁ ++ l₂ ∨ a ∈ l := by\n  induction l₁ generalizing l with\n  | nil => match h with\n    | .cons _ h => exact .inl h\n    | .cons₂ _ h => exact .inr (.head ..)\n  | cons b l₁ IH =>\n    match h with\n    | .cons _ h => exact (IH h).imp_left (Sublist.cons _)\n    | .cons₂ _ h => exact (IH h).imp (Sublist.cons₂ _) (.tail _)\n\ntheorem Sublist.reverse : l₁ <+ l₂ → l₁.reverse <+ l₂.reverse\n  | .slnil => Sublist.refl _\n  | .cons _ h => by rw [reverse_cons]; exact sublist_append_of_sublist_left h.reverse\n  | .cons₂ _ h => by rw [reverse_cons, reverse_cons]; exact h.reverse.append_right _\n\n@[simp] theorem reverse_sublist : l₁.reverse <+ l₂.reverse ↔ l₁ <+ l₂ :=\n  ⟨fun h => l₁.reverse_reverse ▸ l₂.reverse_reverse ▸ h.reverse, Sublist.reverse⟩\n\n@[simp] theorem append_sublist_append_right (l) : l₁ ++ l <+ l₂ ++ l ↔ l₁ <+ l₂ :=\n  ⟨fun h => by\n    have := h.reverse\n    simp only [reverse_append, append_sublist_append_left, reverse_sublist] at this\n    exact this,\n   fun h => h.append_right l⟩\n\ntheorem Sublist.append (hl : l₁ <+ l₂) (hr : r₁ <+ r₂) : l₁ ++ r₁ <+ l₂ ++ r₂ :=\n  (hl.append_right _).trans ((append_sublist_append_left _).2 hr)\n\ntheorem Sublist.subset : l₁ <+ l₂ → l₁ ⊆ l₂\n  | .slnil, _, h => h\n  | .cons _ s, _, h => .tail _ (s.subset h)\n  | .cons₂ .., _, .head .. => .head ..\n  | .cons₂ _ s, _, .tail _ h => .tail _ (s.subset h)\n\ntheorem Sublist.length_le : l₁ <+ l₂ → length l₁ ≤ length l₂\n  | .slnil => Nat.le_refl 0\n  | .cons _l s => le_succ_of_le (length_le s)\n  | .cons₂ _ s => succ_le_succ (length_le s)\n\n@[simp] theorem sublist_nil {l : List α} : l <+ [] ↔ l = [] :=\n  ⟨fun s => subset_nil.mp <| s.subset, fun H => H ▸ Sublist.refl _⟩\n\ntheorem Sublist.eq_of_length : l₁ <+ l₂ → length l₁ = length l₂ → l₁ = l₂\n  | .slnil, _ => rfl\n  | .cons a s, h => nomatch Nat.not_lt.2 s.length_le (h ▸ lt_succ_self _)\n  | .cons₂ a s, h => by rw [s.eq_of_length (succ.inj h)]\n\ntheorem Sublist.eq_of_length_le (s : l₁ <+ l₂) (h : length l₂ ≤ length l₁) : l₁ = l₂ :=\n  s.eq_of_length <| Nat.le_antisymm s.length_le h\n\n@[simp] theorem singleton_sublist {a : α} {l} : [a] <+ l ↔ a ∈ l := by\n  refine ⟨fun h => h.subset (mem_singleton_self _), fun h => ?_⟩\n  obtain ⟨_, _, rfl⟩ := append_of_mem h\n  exact ((nil_sublist _).cons₂ _).trans (sublist_append_right ..)\n\n@[simp] theorem replicate_sublist_replicate {m n} (a : α) :\n    replicate m a <+ replicate n a ↔ m ≤ n := by\n  refine ⟨fun h => ?_, fun h => ?_⟩\n  · have := h.length_le; simp only [length_replicate] at this ⊢; exact this\n  · induction h with\n    | refl => apply Sublist.refl\n    | step => simp [*, replicate, Sublist.cons]\n\n/-! ### head -/\n\ntheorem head!_of_head? [Inhabited α] : ∀ {l : List α}, head? l = some a → head! l = a\n  | _a::_l, rfl => rfl\n\ntheorem head?_eq_head : ∀ l h, @head? α l = some (head l h)\n  | [], h => nomatch h rfl\n  | _::_, _ => rfl\n\n/-! ### tail -/\n\n@[simp] theorem tailD_eq_tail? (l l' : List α) : tailD l l' = (tail? l).getD l' := by\n  cases l <;> rfl\n\ntheorem tail_eq_tailD (l) : @tail α l = tailD l [] := by cases l <;> rfl\n\ntheorem tail_eq_tail? (l) : @tail α l = (tail? l).getD [] := by simp [tail_eq_tailD]\n\n/-! ### next? -/\n\n@[simp] theorem next?_nil : @next? α [] = none := rfl\n@[simp] theorem next?_cons (a l) : @next? α (a :: l) = some (a, l) := rfl\n\n/-! ### getLast -/\n\n@[simp] theorem getLastD_nil (a) : @getLastD α [] a = a := rfl\n@[simp] theorem getLastD_cons (a b l) : @getLastD α (b::l) a = getLastD l b := by cases l <;> rfl\n\ntheorem getLast_eq_getLastD (a l h) : @getLast α (a::l) h = getLastD l a := by\n  cases l <;> rfl\n\ntheorem getLast_singleton (a h) : @getLast α [a] h = a := rfl\n\ntheorem getLast!_cons [Inhabited α] : @getLast! α _ (a::l) = getLastD l a := by\n  simp [getLast!, getLast_eq_getLastD]\n\n@[simp] theorem getLast?_nil : @getLast? α [] = none := rfl\ntheorem getLast?_cons : @getLast? α (a::l) = getLastD l a := by\n  simp [getLast?, getLast_eq_getLastD]\n\ntheorem getLast?_eq_getLast : ∀ l h, @getLast? α l = some (getLast l h)\n  | [], h => nomatch h rfl\n  | _::_, _ => rfl\n\n/-! ### dropLast -/\n\n@[simp] theorem dropLast_nil : @dropLast α [] = [] := rfl\n@[simp] theorem dropLast_single : dropLast [a] = [] := rfl\n@[simp] theorem dropLast_cons₂ : dropLast (a::b::l) = a :: dropLast (b::l) := rfl\n\n@[simp] theorem dropLast_append_cons : dropLast (l₁ ++ b::l₂) = l₁ ++ dropLast (b::l₂) := by\n  induction l₁ <;> simp [*]\n\n@[simp 1100] theorem dropLast_concat : dropLast (l₁ ++ [b]) = l₁ := by simp\n\n/-! ### nth element -/\n\n@[simp] theorem get_cons_zero {as : List α} : (a :: as).get ⟨0, Nat.zero_lt_succ _⟩ = a := rfl\n\n@[simp] theorem get_cons_succ {as : List α} {h : i + 1 < (a :: as).length} :\n  (a :: as).get ⟨i+1, h⟩ = as.get ⟨i, Nat.lt_of_succ_lt_succ h⟩ := rfl\n\ntheorem get_of_mem : ∀ {a} {l : List α}, a ∈ l → ∃ n, get l n = a\n  | _, _ :: _, .head .. => ⟨⟨0, Nat.succ_pos _⟩, rfl⟩\n  | _, _ :: _, .tail _ m => let ⟨⟨n, h⟩, e⟩ := get_of_mem m; ⟨⟨n+1, Nat.succ_lt_succ h⟩, e⟩\n\ntheorem get?_eq_get : ∀ {l : List α} {n} h, l.get? n = some (get l ⟨n, h⟩)\n  | _ :: _, 0, _ => rfl\n  | _ :: l, _+1, _ => get?_eq_get (l := l) _\n\ntheorem get?_len_le : ∀ {l : List α} {n}, length l ≤ n → l.get? n = none\n  | [], _, _ => rfl\n  | _ :: l, _+1, h => get?_len_le (l := l) <| Nat.le_of_succ_le_succ h\n\ntheorem get?_eq_some : l.get? n = some a ↔ ∃ h, get l ⟨n, h⟩ = a :=\n  ⟨fun e =>\n    have : n < length l := Nat.lt_of_not_le fun hn => by cases get?_len_le hn ▸ e\n    ⟨this, by rwa [get?_eq_get this, Option.some.injEq] at e⟩,\n  fun ⟨h, e⟩ => e ▸ get?_eq_get _⟩\n\n@[simp] theorem get?_eq_none : l.get? n = none ↔ length l ≤ n :=\n  ⟨fun e => Nat.le_of_not_lt (fun h' => by cases e ▸ get?_eq_some.2 ⟨h', rfl⟩), get?_len_le⟩\n\ntheorem get?_of_mem {a} {l : List α} (h : a ∈ l) : ∃ n, l.get? n = some a :=\n  let ⟨⟨n, _⟩, e⟩ := get_of_mem h; ⟨n, e ▸ get?_eq_get _⟩\n\ntheorem get_mem : ∀ (l : List α) n h, get l ⟨n, h⟩ ∈ l\n  | _ :: _, 0, _ => .head ..\n  | _ :: l, _+1, _ => .tail _ (get_mem l ..)\n\ntheorem get?_mem {l : List α} {n a} (e : l.get? n = some a) : a ∈ l :=\n  let ⟨_, e⟩ := get?_eq_some.1 e; e ▸ get_mem ..\n\ntheorem mem_iff_get {a} {l : List α} : a ∈ l ↔ ∃ n, get l n = a :=\n  ⟨get_of_mem, fun ⟨_, e⟩ => e ▸ get_mem ..⟩\n\n-- TODO(Mario): move somewhere else\ntheorem Fin.exists_iff (p : Fin n → Prop) : (∃ i, p i) ↔ ∃ i h, p ⟨i, h⟩ :=\n  ⟨fun ⟨i, h⟩ => ⟨i.1, i.2, h⟩, fun ⟨i, hi, h⟩ => ⟨⟨i, hi⟩, h⟩⟩\n\ntheorem mem_iff_get? {a} {l : List α} : a ∈ l ↔ ∃ n, l.get? n = some a := by\n  simp [get?_eq_some, Fin.exists_iff, mem_iff_get]\n\ntheorem get?_zero (l : List α) : l.get? 0 = l.head? := by cases l <;> rfl\n\n@[simp] theorem getElem_eq_get (l : List α) (i : Nat) (h) : l[i]'h = l.get ⟨i, h⟩ := rfl\n\n@[simp] theorem getElem?_eq_get? (l : List α) (i : Nat) : l[i]? = l.get? i := by\n  unfold getElem?; split\n  · exact (get?_eq_get ‹_›).symm\n  · exact (get?_eq_none.2 <| Nat.not_lt.1 ‹_›).symm\n\ntheorem get?_inj\n    (h₀ : i < xs.length) (h₁ : Nodup xs) (h₂ : xs.get? i = xs.get? j) : i = j := by\n  induction xs generalizing i j with\n  | nil => cases h₀\n  | cons x xs ih =>\n    match i, j with\n    | 0, 0 => rfl\n    | i+1, j+1 => simp; cases h₁ with\n      | cons ha h₁ => exact ih (Nat.lt_of_succ_lt_succ h₀) h₁ h₂\n    | i+1, 0 => ?_ | 0, j+1 => ?_\n    all_goals\n      simp at h₂\n      cases h₁; rename_i h' h\n      have := h x ?_ rfl; cases this\n      rw [mem_iff_get?]\n    exact ⟨_, h₂⟩; exact ⟨_ , h₂.symm⟩\n\n@[simp] theorem get?_map (f : α → β) : ∀ l n, (map f l).get? n = (l.get? n).map f\n  | [], _ => rfl\n  | _ :: _, 0 => rfl\n  | _ :: l, n+1 => get?_map f l n\n\n@[simp] theorem get_map (f : α → β) {l n} : get (map f l) n = f (get l ⟨n, length_map l f ▸ n.2⟩) :=\n  Option.some.inj <| by rw [← get?_eq_get, get?_map, get?_eq_get]; rfl\n\n/--\nIf one has `get l i hi` in a formula and `h : l = l'`, one can not `rw h` in the formula as\n`hi` gives `i < l.length` and not `i < l'.length`. The theorem `get_of_eq` can be used to make\nsuch a rewrite, with `rw (get_of_eq h)`.\n-/\ntheorem get_of_eq {l l' : List α} (h : l = l') (i : Fin l.length) :\n    get l i = get l' ⟨i, h ▸ i.2⟩ := by cases h; rfl\n\n@[simp] \n\ntheorem get_zero : ∀ {l : List α} (h : 0 < l.length), l.get ⟨0, h⟩ = l.head?\n  | _::_, _ => rfl\n\ntheorem get_append : ∀ {l₁ l₂ : List α} (n : Nat) (h : n < l₁.length),\n    (l₁ ++ l₂).get ⟨n, length_append .. ▸ Nat.lt_add_right _ _ _ h⟩ = l₁.get ⟨n, h⟩\n| a :: l, _, 0, h => rfl\n| a :: l, _, n+1, h => by simp only [get, cons_append]; apply get_append\n\ntheorem get?_append_right : ∀ {l₁ l₂ : List α} {n : Nat}, l₁.length ≤ n →\n  (l₁ ++ l₂).get? n = l₂.get? (n - l₁.length)\n| [], _, n, _ => rfl\n| a :: l, _, n+1, h₁ => by rw [cons_append]; simp [get?_append_right (Nat.lt_succ.1 h₁)]\n\ntheorem get_append_right_aux {l₁ l₂ : List α} {n : Nat}\n  (h₁ : l₁.length ≤ n) (h₂ : n < (l₁ ++ l₂).length) : n - l₁.length < l₂.length := by\n  rw [length_append] at h₂\n  exact Nat.sub_lt_left_of_lt_add h₁ h₂\n\ntheorem get_append_right' {l₁ l₂ : List α} {n : Nat} (h₁ : l₁.length ≤ n) (h₂) :\n    (l₁ ++ l₂).get ⟨n, h₂⟩ = l₂.get ⟨n - l₁.length, get_append_right_aux h₁ h₂⟩ :=\nOption.some.inj <| by rw [← get?_eq_get, ← get?_eq_get, get?_append_right h₁]\n\ntheorem get_of_append_proof {l : List α}\n    (eq : l = l₁ ++ a :: l₂) (h : l₁.length = n) : n < length l := eq ▸ h ▸ by simp_arith\n\ntheorem get_of_append {l : List α} (eq : l = l₁ ++ a :: l₂) (h : l₁.length = n) :\n    l.get ⟨n, get_of_append_proof eq h⟩ = a := Option.some.inj <| by\n  rw [← get?_eq_get, eq, get?_append_right (h ▸ Nat.le_refl _), h, Nat.sub_self]; rfl\n\n@[simp] theorem get_replicate (a : α) {n : Nat} (m : Fin _) : (replicate n a).get m = a :=\n  eq_of_mem_replicate (get_mem _ _ _)\n\ntheorem get?_append {l₁ l₂ : List α} {n : Nat} (hn : n < l₁.length) :\n  (l₁ ++ l₂).get? n = l₁.get? n := by\n  have hn' : n < (l₁ ++ l₂).length := Nat.lt_of_lt_of_le hn <|\n    length_append .. ▸ Nat.le_add_right ..\n  rw [get?_eq_get hn, get?_eq_get hn', get_append]\n\ntheorem getLast_eq_get : ∀ (l : List α) (h : l ≠ []),\n    getLast l h = l.get ⟨l.length - 1, Nat.sub_lt (length_pos.2 h) Nat.one_pos⟩\n  | [a], h => by\n    rw [getLast_singleton, get_singleton]\n  | a :: b :: l, h => by rw [getLast_cons', getLast_eq_get (b :: l)]; {rfl}; exact cons_ne_nil b l\n\ntheorem getLast?_eq_get? : ∀ (l : List α), getLast? l = l.get? (l.length - 1)\n  | [] => rfl\n  | a::l => by rw [getLast?_eq_getLast (a::l) fun., getLast_eq_get, get?_eq_get]\n\n@[simp] theorem get?_concat_length : ∀ (l : List α) (a : α), (l ++ [a]).get? l.length = some a\n  | [], a => rfl\n  | b :: l, a => by rw [cons_append, length_cons]; simp only [get?, get?_concat_length]\n\n@[simp] theorem getLast?_concat (l : List α) : getLast? (l ++ [a]) = some a := by\n  simp [getLast?_eq_get?]\n\ntheorem get_cons_length (x : α) (xs : List α) (n : Nat) (h : n = xs.length) :\n    (x :: xs).get ⟨n, by simp [h]⟩ = (x :: xs).getLast (cons_ne_nil x xs) := by\n  rw [getLast_eq_get]; cases h; rfl\n\n@[ext] theorem ext : ∀ {l₁ l₂ : List α}, (∀ n, l₁.get? n = l₂.get? n) → l₁ = l₂\n  | [], [], _ => rfl\n  | a :: l₁, [], h => nomatch h 0\n  | [], a' :: l₂, h => nomatch h 0\n  | a :: l₁, a' :: l₂, h => by\n    have h0 : some a = some a' := h 0\n    injection h0 with aa; simp only [aa, ext fun n => h (n+1)]\n\ntheorem ext_get {l₁ l₂ : List α} (hl : length l₁ = length l₂)\n    (h : ∀ n h₁ h₂, get l₁ ⟨n, h₁⟩ = get l₂ ⟨n, h₂⟩) : l₁ = l₂ :=\n  ext fun n =>\n    if h₁ : n < length l₁ then by\n      rw [get?_eq_get, get?_eq_get, h n h₁ (by rwa [← hl])]\n    else by\n      have h₁ := Nat.le_of_not_lt h₁\n      rw [get?_len_le h₁, get?_len_le]; rwa [← hl]\n\ntheorem get?_reverse' : ∀ {l : List α} (i j), i + j + 1 = length l →\n    get? l.reverse i = get? l j\n  | [], _, _, _ => rfl\n  | a::l, i, 0, h => by simp at h; simp [h, get?_append_right]\n  | a::l, i, j+1, h => by\n    have := Nat.succ.inj h; simp at this ⊢\n    rw [get?_append, get?_reverse' _ j this]\n    rw [length_reverse, ← this]; apply Nat.lt_add_of_pos_right (Nat.succ_pos _)\n\ntheorem get?_reverse {l : List α} (i) (h : i < length l) :\n    get? l.reverse i = get? l (l.length - 1 - i) :=\n  get?_reverse' _ _ <| by\n    rw [Nat.add_sub_of_le (Nat.le_pred_of_lt h),\n      Nat.sub_add_cancel (Nat.lt_of_le_of_lt (Nat.zero_le _) h)]\n\ntheorem get!_of_get? [Inhabited α] : ∀ {l : List α} {n}, get? l n = some a → get! l n = a\n  | _a::_, 0, rfl => rfl\n  | _::l, _+1, e => get!_of_get? (l := l) e\n\ntheorem getD_eq_get? : ∀ l n (a : α), getD l n a = (get? l n).getD a\n  | [], _, _ => rfl\n  | _a::_, 0, _ => rfl\n  | _::l, _+1, _ => getD_eq_get? (l := l) ..\n\n/-! ### take and drop -/\n\n@[simp] theorem length_take : ∀ (i : Nat) (l : List α), length (take i l) = min i (length l)\n  | 0, l => by simp [Nat.zero_min]\n  | succ n, [] => by simp [Nat.min_zero]\n  | succ n, _ :: l => by simp [Nat.min_succ_succ, add_one, length_take]\n\ntheorem length_take_le (n) (l : List α) : length (take n l) ≤ n := by simp [Nat.min_le_left]\n\ntheorem length_take_of_le (h : n ≤ length l) : length (take n l) = n := by simp [Nat.min_eq_left h]\n\ntheorem get_cons_drop : ∀ (l : List α) i, get l i :: drop (i + 1) l = drop i l\n  | _::_, ⟨0, _⟩ => rfl\n  | _::_, ⟨i+1, _⟩ => get_cons_drop _ ⟨i, _⟩\n\ntheorem map_eq_append_split {f : α → β} {l : List α} {s₁ s₂ : List β}\n    (h : map f l = s₁ ++ s₂) : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ map f l₁ = s₁ ∧ map f l₂ = s₂ := by\n  have := h\n  rw [← take_append_drop (length s₁) l] at this ⊢\n  rw [map_append] at this\n  refine ⟨_, _, rfl, append_inj this ?_⟩\n  rw [length_map, length_take, Nat.min_eq_left]\n  rw [← length_map l f, h, length_append]\n  apply Nat.le_add_right\n\n-- TODO: original proof: drop_subset n l h\ntheorem mem_of_mem_drop : ∀ {n} {l : List α}, a ∈ l.drop n → a ∈ l\n  | 0, _, h => h\n  | _+1, _::_, h => .tail _ (mem_of_mem_drop h)\n\n/-! ### modify nth -/\n\ntheorem modifyNthTail_id : ∀ n (l : List α), l.modifyNthTail id n = l\n  | 0, _ => rfl\n  | _+1, [] => rfl\n  | n+1, a :: l => congrArg (cons a) (modifyNthTail_id n l)\n\ntheorem removeNth_eq_nth_tail : ∀ n (l : List α), removeNth l n = modifyNthTail tail n l\n  | 0, l => by cases l <;> rfl\n  | n+1, [] => rfl\n  | n+1, a :: l => congrArg (cons _) (removeNth_eq_nth_tail _ _)\n\ntheorem get?_modifyNth (f : α → α) :\n    ∀ n (l : List α) m, (modifyNth f n l).get? m = (fun a => if n = m then f a else a) <$> l.get? m\n  | n, l, 0 => by cases l <;> cases n <;> rfl\n  | n, [], _+1 => by cases n <;> rfl\n  | 0, _ :: l, m+1 => by cases l.get? m <;> rfl\n  | n+1, a :: l, m+1 =>\n    (get?_modifyNth f n l m).trans <| by\n      cases l.get? m <;> by_cases h : n = m <;>\n        simp only [h, if_pos, if_true, if_false, Option.map, mt Nat.succ.inj, not_false_iff]\n\ntheorem modifyNthTail_length (f : List α → List α) (H : ∀ l, length (f l) = length l) :\n    ∀ n l, length (modifyNthTail f n l) = length l\n  | 0, _ => H _\n  | _+1, [] => rfl\n  | _+1, _ :: _ => congrArg (·+1) (modifyNthTail_length _ H _ _)\n\ntheorem modifyNthTail_add (f : List α → List α) (n) (l₁ l₂ : List α) :\n    modifyNthTail f (l₁.length + n) (l₁ ++ l₂) = l₁ ++ modifyNthTail f n l₂ := by\n  induction l₁ <;> simp [*, Nat.succ_add]\n\ntheorem exists_of_modifyNthTail (f : List α → List α) {n} {l : List α} (h : n ≤ l.length) :\n    ∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n ∧ modifyNthTail f n l = l₁ ++ f l₂ :=\n  have ⟨_, _, eq, hl⟩ : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ l₁.length = n :=\n    ⟨_, _, (take_append_drop n l).symm, length_take_of_le h⟩\n  ⟨_, _, eq, hl, hl ▸ eq ▸ modifyNthTail_add (n := 0) ..⟩\n\n@[simp] theorem modify_get?_length (f : α → α) : ∀ n l, length (modifyNth f n l) = length l :=\n  modifyNthTail_length _ fun l => by cases l <;> rfl\n\n@[simp] theorem get?_modifyNth_eq (f : α → α) (n) (l : List α) :\n  (modifyNth f n l).get? n = f <$> l.get? n := by\n  simp only [get?_modifyNth, if_pos]\n\n@[simp] theorem get?_modifyNth_ne (f : α → α) {m n} (l : List α) (h : m ≠ n) :\n    (modifyNth f m l).get? n = l.get? n := by\n  simp only [get?_modifyNth, if_neg h, id_map']\n\ntheorem exists_of_modifyNth (f : α → α) {n} {l : List α} (h : n < l.length) :\n    ∃ l₁ a l₂, l = l₁ ++ a :: l₂ ∧ l₁.length = n ∧ modifyNth f n l = l₁ ++ f a :: l₂ :=\n  match exists_of_modifyNthTail _ (Nat.le_of_lt h) with\n  | ⟨_, _::_, eq, hl, H⟩ => ⟨_, _, _, eq, hl, H⟩\n  | ⟨_, [], eq, hl, _⟩ => nomatch Nat.ne_of_gt h (eq ▸ append_nil _ ▸ hl)\n\n/-! ### set -/\n\ntheorem set_eq_modifyNth (a : α) : ∀ n (l : List α), set l n a = modifyNth (fun _ => a) n l\n  | 0, l => by cases l <;> rfl\n  | n+1, [] => rfl\n  | n+1, b :: l => congrArg (cons _) (set_eq_modifyNth _ _ _)\n\ntheorem modifyNth_eq_set_get? (f : α → α) :\n    ∀ n (l : List α), l.modifyNth f n = ((fun a => l.set n (f a)) <$> l.get? n).getD l\n  | 0, l => by cases l <;> rfl\n  | n+1, [] => rfl\n  | n+1, b :: l =>\n    (congrArg (cons _) (modifyNth_eq_set_get? ..)).trans <| by cases l.get? n <;> rfl\n\ntheorem modifyNth_eq_set_get (f : α → α) {n} {l : List α} (h) :\n    l.modifyNth f n = l.set n (f (l.get ⟨n, h⟩)) := by\n  rw [modifyNth_eq_set_get?, get?_eq_get h]; rfl\n\ntheorem exists_of_set {l : List α} (h : n < l.length) :\n    ∃ l₁ a l₂, l = l₁ ++ a :: l₂ ∧ l₁.length = n ∧ l.set n a' = l₁ ++ a' :: l₂ := by\n  rw [set_eq_modifyNth]; exact exists_of_modifyNth _ h\n\ntheorem exists_of_set' {l : List α} (h : n < l.length) :\n    ∃ l₁ l₂, l = l₁ ++ l.get ⟨n, h⟩ :: l₂ ∧ l₁.length = n ∧ l.set n a' = l₁ ++ a' :: l₂ :=\n  have ⟨_, _, _, h₁, h₂, h₃⟩ := exists_of_set h; ⟨_, _, get_of_append h₁ h₂ ▸ h₁, h₂, h₃⟩\n\ntheorem get?_set_eq (a : α) (n) (l : List α) : (set l n a).get? n = (fun _ => a) <$> l.get? n := by\n  simp only [set_eq_modifyNth, get?_modifyNth_eq]\n\ntheorem get?_set_eq_of_lt (a : α) {n} {l : List α} (h : n < length l) :\n  (set l n a).get? n = some a := by rw [get?_set_eq, get?_eq_get h]; rfl\n\ntheorem get?_set_ne (a : α) {m n} (l : List α) (h : m ≠ n) : (set l m a).get? n = l.get? n := by\n  simp only [set_eq_modifyNth, get?_modifyNth_ne _ _ h]\n\ntheorem get?_set (a : α) {m n} (l : List α) :\n    (set l m a).get? n = if m = n then (fun _ => a) <$> l.get? n else l.get? n := by\n  by_cases m = n <;> simp [*, get?_set_eq, get?_set_ne]\n\ntheorem get?_set_of_lt (a : α) {m n} (l : List α) (h : n < length l) :\n    (set l m a).get? n = if m = n then some a else l.get? n := by\n  simp [get?_set, get?_eq_get h]\n\ntheorem get?_set_of_lt' (a : α) {m n} (l : List α) (h : m < length l) :\n    (set l m a).get? n = if m = n then some a else l.get? n := by\n  simp [get?_set]; split <;> subst_vars <;> simp [*, get?_eq_get h]\n\n@[simp] theorem set_nil (n : Nat) (a : α) : [].set n a = [] := rfl\n\n@[simp] theorem set_succ (x : α) (xs : List α) (n : Nat) (a : α) :\n  (x :: xs).set n.succ a = x :: xs.set n a := rfl\n\ntheorem set_comm (a b : α) : ∀ {n m : Nat} (l : List α), n ≠ m →\n    (l.set n a).set m b = (l.set m b).set n a\n  | _, _, [], _ => by simp\n  | n+1, 0, _ :: _, _ => by simp [set]\n  | 0, m+1, _ :: _, _ => by simp [set]\n  | n+1, m+1, x :: t, h =>\n    congrArg _ <| set_comm a b t fun h' => h <| Nat.succ_inj'.mpr h'\n\n@[simp] theorem get_set_eq (l : List α) (i : Nat) (a : α) (h : i < (l.set i a).length) :\n    (l.set i a).get ⟨i, h⟩ = a := by\n  rw [← Option.some_inj, ← get?_eq_get, get?_set_eq, get?_eq_get] <;> simp_all\n\n@[simp] theorem get_set_ne {l : List α} {i j : Nat} (h : i ≠ j) (a : α)\n    (hj : j < (l.set i a).length) :\n    (l.set i a).get ⟨j, hj⟩ = l.get ⟨j, by simp at hj; exact hj⟩ := by\n  rw [← Option.some_inj, ← get?_eq_get, get?_set_ne _ _ h, get?_eq_get]\n\ntheorem get_set (a : α) {m n} (l : List α) (h) :\n    (set l m a).get ⟨n, h⟩ = if m = n then a else l.get ⟨n, length_set .. ▸ h⟩ := by\n  if h : m = n then subst m; simp else simp [h]\n\ntheorem mem_or_eq_of_mem_set : ∀ {l : List α} {n : Nat} {a b : α}, a ∈ l.set n b → a ∈ l ∨ a = b\n  | _ :: _, 0, _, _, h => ((mem_cons ..).1 h).symm.imp_left (.tail _)\n  | _ :: _, _+1, _, _, .head .. => .inl (.head ..)\n  | _ :: _, _+1, _, _, .tail _ h => (mem_or_eq_of_mem_set h).imp_left (.tail _)\n\n/-! ### remove nth -/\n\ntheorem length_removeNth : ∀ {l i}, i < length l → length (@removeNth α l i) = length l - 1\n  | [], _, _ => rfl\n  | _::_, 0, _ => by simp [removeNth]\n  | x::xs, i+1, h => by\n    have : i < length xs := Nat.lt_of_succ_lt_succ h\n    simp [removeNth, ← Nat.add_one]\n    rw [length_removeNth this, Nat.sub_add_cancel (Nat.lt_of_le_of_lt (Nat.zero_le _) this)]\n\n/-! ### tail -/\n\n@[simp] theorem length_tail (l : List α) : length (tail l) = length l - 1 := by cases l <;> rfl\n\n/-! ### all / any -/\n\n@[simp] theorem all_eq_true {l : List α} : l.all p ↔ ∀ x ∈ l, p x := by induction l <;> simp [*]\n\n@[simp] theorem any_eq_true {l : List α} : l.any p ↔ ∃ x ∈ l, p x := by induction l <;> simp [*]\n\n/-! ### reverse -/\n\n@[simp] theorem mem_reverseAux (x : α) : ∀ as bs, x ∈ reverseAux as bs ↔ x ∈ as ∨ x ∈ bs\n  | [], _ => by simp\n  | a :: _, _ => by simp [mem_reverseAux]; rw [← or_assoc, @or_comm (x = a)]\n\n@[simp] theorem mem_reverse (x : α) (as : List α) : x ∈ reverse as ↔ x ∈ as := by simp [reverse]\n\n/-! ### insert -/\n\nsection insert\nvariable [DecidableEq α]\n\n@[simp] theorem insert_of_mem {l : List α} (h : a ∈ l) : l.insert a = l := by\n  simp only [List.insert, if_pos h]\n\n@[simp] theorem insert_of_not_mem {l : List α} (h : a ∉ l) : l.insert a = a :: l := by\n  simp only [List.insert, if_neg h]\n\n@[simp] theorem mem_insert_iff {l : List α} : a ∈ l.insert b ↔ a = b ∨ a ∈ l := by\n  if h : b ∈ l then\n    rw [insert_of_mem h]\n    constructor; {apply Or.inr}\n    intro\n    | Or.inl h' => rw [h']; exact h\n    | Or.inr h' => exact h'\n  else rw [insert_of_not_mem h, mem_cons]\n\n@[simp 1100] theorem mem_insert_self (a : α) (l : List α) : a ∈ l.insert a :=\n  mem_insert_iff.2 (Or.inl rfl)\n\ntheorem mem_insert_of_mem {l : List α} (h : a ∈ l) : a ∈ l.insert b :=\n  mem_insert_iff.2 (Or.inr h)\n\ntheorem eq_or_mem_of_mem_insert {l : List α} (h : a ∈ l.insert b) : a = b ∨ a ∈ l :=\n  mem_insert_iff.1 h\n\n@[simp] theorem length_insert_of_mem {l : List α} (h : a ∈ l) :\n    length (l.insert a) = length l := by rw [insert_of_mem h]\n\n@[simp] theorem length_insert_of_not_mem {l : List α} (h : a ∉ l) :\n    length (l.insert a) = length l + 1 := by rw [insert_of_not_mem h]; rfl\n\nend insert\n\n/-! ### eraseP -/\n\n@[simp] theorem eraseP_nil : [].eraseP p = [] := rfl\n\ntheorem eraseP_cons (a : α) (l : List α) :\n    (a :: l).eraseP p = bif p a then l else a :: l.eraseP p := rfl\n\n@[simp] theorem eraseP_cons_of_pos {l : List α} (p) (h : p a) : (a :: l).eraseP p = l := by\n  simp [eraseP_cons, h]\n\n@[simp] theorem eraseP_cons_of_neg {l : List α} (p) (h : ¬p a) :\n    (a :: l).eraseP p = a :: l.eraseP p := by simp [eraseP_cons, h]\n\ntheorem eraseP_of_forall_not {l : List α} (h : ∀ a, a ∈ l → ¬p a) : l.eraseP p = l := by\n  induction l with\n  | nil => rfl\n  | cons _ _ ih => simp [h _ (.head ..), ih (forall_mem_cons.1 h).2]\n\ntheorem exists_of_eraseP : ∀ {l : List α} {a} (al : a ∈ l) (pa : p a),\n    ∃ a l₁ l₂, (∀ b ∈ l₁, ¬p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.eraseP p = l₁ ++ l₂\n  | b :: l, a, al, pa =>\n    if pb : p b then\n      ⟨b, [], l, forall_mem_nil _, pb, by simp [pb]⟩\n    else\n      match al with\n      | .head .. => nomatch pb pa\n      | .tail _ al =>\n        let ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩ := exists_of_eraseP al pa\n        ⟨c, b::l₁, l₂, (forall_mem_cons ..).2 ⟨pb, h₁⟩,\n          h₂, by rw [h₃, cons_append], by simp [pb, h₄]⟩\n\ntheorem exists_or_eq_self_of_eraseP (p) (l : List α) :\n    l.eraseP p = l ∨\n    ∃ a l₁ l₂, (∀ b ∈ l₁, ¬p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.eraseP p = l₁ ++ l₂ :=\n  if h : ∃ a ∈ l, p a then\n    let ⟨_, ha, pa⟩ := h\n    .inr (exists_of_eraseP ha pa)\n  else\n    .inl (eraseP_of_forall_not (h ⟨·, ·, ·⟩))\n\n@[simp] theorem length_eraseP_of_mem (al : a ∈ l) (pa : p a) :\n    length (l.eraseP p) = Nat.pred (length l) := by\n  let ⟨_, l₁, l₂, _, _, e₁, e₂⟩ := exists_of_eraseP al pa\n  rw [e₂]; simp [length_append, e₁]; rfl\n\ntheorem eraseP_append_left {a : α} (pa : p a) :\n    ∀ {l₁ : List α} l₂, a ∈ l₁ → (l₁++l₂).eraseP p = l₁.eraseP p ++ l₂\n  | x :: xs, l₂, h => by\n    by_cases h' : p x <;> simp [h']\n    rw [eraseP_append_left pa l₂ ((mem_cons.1 h).resolve_left (mt _ h'))]\n    intro | rfl => exact pa\n\ntheorem eraseP_append_right :\n    ∀ {l₁ : List α} l₂, (∀ b ∈ l₁, ¬p b) → eraseP p (l₁++l₂) = l₁ ++ l₂.eraseP p\n  | [],      l₂, _ => rfl\n  | x :: xs, l₂, h => by\n    simp [(forall_mem_cons.1 h).1, eraseP_append_right _ (forall_mem_cons.1 h).2]\n\ntheorem eraseP_sublist (l : List α) : l.eraseP p <+ l := by\n  match exists_or_eq_self_of_eraseP p l with\n  | .inl h => rw [h]; apply Sublist.refl\n  | .inr ⟨c, l₁, l₂, _, _, h₃, h₄⟩ => rw [h₄, h₃]; simp\n\ntheorem eraseP_subset (l : List α) : l.eraseP p ⊆ l := (eraseP_sublist l).subset\n\ntheorem Sublist.eraseP : l₁ <+ l₂ → l₁.eraseP p <+ l₂.eraseP p\n  | .slnil => Sublist.refl _\n  | .cons a s => by\n    by_cases h : p a <;> simp [h]\n    exacts [s.eraseP.trans (eraseP_sublist _), s.eraseP.cons _]\n  | .cons₂ a s => by\n    by_cases h : p a <;> simp [h]\n    exacts [s, s.eraseP.cons₂ _]\n\ntheorem mem_of_mem_eraseP {l : List α} : a ∈ l.eraseP p → a ∈ l := (eraseP_subset _ ·)\n\n@[simp] theorem mem_eraseP_of_neg {l : List α} (pa : ¬p a) : a ∈ l.eraseP p ↔ a ∈ l := by\n  refine ⟨mem_of_mem_eraseP, fun al => ?_⟩\n  match exists_or_eq_self_of_eraseP p l with\n  | .inl h => rw [h]; assumption\n  | .inr ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩ =>\n    rw [h₄]; rw [h₃] at al\n    have : a ≠ c := fun h => (h ▸ pa).elim h₂\n    simp [this] at al; simp [al]\n\ntheorem eraseP_map (f : β → α) : ∀ (l : List β), (map f l).eraseP p = map f (l.eraseP (p ∘ f))\n  | [] => rfl\n  | b::l => by by_cases h : p (f b) <;> simp [h, eraseP_map f l, eraseP_cons_of_pos]\n\n@[simp] theorem extractP_eq_find?_eraseP\n    (l : List α) : extractP p l = (find? p l, eraseP p l) := by\n  let rec go (acc) : ∀ xs, l = acc.data ++ xs →\n    extractP.go p l xs acc = (xs.find? p, acc.data ++ xs.eraseP p)\n  | [] => fun h => by simp [extractP.go, find?, eraseP, h]\n  | x::xs => by\n    simp [extractP.go, find?, eraseP]; cases p x <;> simp\n    · intro h; rw [go _ xs]; {simp}; simp [h]\n  exact go #[] _ rfl\n\n/-! ### erase -/\n\nsection erase\n-- FIXME: this should use a `BEq` assumption\nvariable [DecidableEq α]\n\n@[simp] theorem erase_nil (a : α) : [].erase a = [] := rfl\n\ntheorem erase_cons (a b : α) (l : List α) :\n    (b :: l).erase a = if b = a then l else b :: l.erase a :=\n  if h : b = a then by simp [List.erase, h]\n  else by simp [List.erase, h, (beq_eq_false_iff_ne _ _).2 h]\n\n@[simp] theorem erase_cons_head (a : α) (l : List α) : (a :: l).erase a = l := by\n  simp [erase_cons]\n\n@[simp] theorem erase_cons_tail {a b : α} (l : List α) (h : b ≠ a) :\n    (b :: l).erase a = b :: l.erase a := by simp only [erase_cons, if_neg h]\n\ntheorem erase_eq_eraseP (a : α) : ∀ l : List α, l.erase a = l.eraseP (Eq a)\n  | [] => rfl\n  | b :: l => by\n    if h : a = b then simp [h] else simp [h, Ne.symm h, erase_eq_eraseP a l]\n\ntheorem Sublist.erase (a : α) {l₁ l₂ : List α} (h : l₁ <+ l₂) : l₁.erase a <+ l₂.erase a := by\n  simp [erase_eq_eraseP]; exact Sublist.eraseP h\n\ntheorem erase_of_not_mem {a : α} : ∀ {l : List α}, a ∉ l → l.erase a = l\n  | [], _ => rfl\n  | b :: l, h => by\n    rw [mem_cons, not_or] at h\n    rw [erase_cons, if_neg (Ne.symm h.1), erase_of_not_mem h.2]\n\ntheorem exists_erase_eq {a : α} {l : List α} (h : a ∈ l) :\n    ∃ l₁ l₂, a ∉ l₁ ∧ l = l₁ ++ a :: l₂ ∧ l.erase a = l₁ ++ l₂ := by\n  let ⟨_, l₁, l₂, h₁, e, h₂, h₃⟩ := exists_of_eraseP h (beq_self_eq_true _)\n  rw [erase_eq_eraseP]; exact ⟨l₁, l₂, fun h => h₁ _ h (beq_self_eq_true _), eq_of_beq e ▸ h₂, h₃⟩\n\n@[simp] theorem length_erase_of_mem {a : α} {l : List α} (h : a ∈ l) :\n    length (l.erase a) = Nat.pred (length l) := by\n  rw [erase_eq_eraseP]; exact length_eraseP_of_mem h (decide_eq_true rfl)\n\ntheorem erase_append_left {l₁ : List α} (l₂) (h : a ∈ l₁) :\n    (l₁ ++ l₂).erase a = l₁.erase a ++ l₂ := by\n  simp [erase_eq_eraseP]; exact eraseP_append_left (by exact decide_eq_true rfl) l₂ h\n\ntheorem erase_append_right {a : α} {l₁ : List α} (l₂ : List α) (h : a ∉ l₁) :\n    (l₁ ++ l₂).erase a = (l₁ ++ l₂.erase a) := by\n  rw [erase_eq_eraseP, erase_eq_eraseP, eraseP_append_right]\n  intros b h' h''; rw [of_decide_eq_true h''] at h; exact h h'\n\ntheorem erase_sublist (a : α) (l : List α) : l.erase a <+ l :=\n  erase_eq_eraseP a l ▸ eraseP_sublist l\n\ntheorem erase_subset (a : α) (l : List α) : l.erase a ⊆ l := (erase_sublist a l).subset\n\ntheorem sublist.erase (a : α) {l₁ l₂ : List α} (h : l₁ <+ l₂) : l₁.erase a <+ l₂.erase a := by\n  simp only [erase_eq_eraseP]; exact h.eraseP\n\ntheorem mem_of_mem_erase {a b : α} {l : List α} (h : a ∈ l.erase b) : a ∈ l := erase_subset _ _ h\n\n@[simp] theorem mem_erase_of_ne {a b : α} {l : List α} (ab : a ≠ b) : a ∈ l.erase b ↔ a ∈ l :=\n  erase_eq_eraseP b l ▸ mem_eraseP_of_neg (mt of_decide_eq_true ab.symm)\n\ntheorem erase_comm (a b : α) (l : List α) : (l.erase a).erase b = (l.erase b).erase a := by\n  if ab : a = b then rw [ab] else ?_\n  if ha : a ∈ l then ?_ else\n    simp only [erase_of_not_mem ha, erase_of_not_mem (mt mem_of_mem_erase ha)]\n  if hb : b ∈ l then ?_ else\n    simp only [erase_of_not_mem hb, erase_of_not_mem (mt mem_of_mem_erase hb)]\n  match l, l.erase a, exists_erase_eq ha with\n  | _, _, ⟨l₁, l₂, ha', rfl, rfl⟩ =>\n    if h₁ : b ∈ l₁ then\n      rw [erase_append_left _ h₁, erase_append_left _ h₁,\n          erase_append_right _ (mt mem_of_mem_erase ha'), erase_cons_head]\n    else\n      rw [erase_append_right _ h₁, erase_append_right _ h₁, erase_append_right _ ha',\n          erase_cons_tail _ ab, erase_cons_head]\n\nend erase\n\n/-! ### filter and partition -/\n\n@[simp] theorem filter_nil (p : α → Bool) : filter p [] = [] := rfl\n\n@[simp] theorem filter_cons_of_pos {p : α → Bool} {a : α} (l) (pa : p a) :\n    filter p (a :: l) = a :: filter p l := by rw [filter, pa]\n\n@[simp] theorem filter_cons_of_neg {p : α → Bool} {a : α} (l) (pa : ¬ p a) :\n    filter p (a :: l) = filter p l := by rw [filter, eq_false_of_ne_true pa]\n\n@[simp] theorem filter_append {p : α → Bool} :\n    ∀ (l₁ l₂ : List α), filter p (l₁ ++ l₂) = filter p l₁ ++ filter p l₂\n  | [], l₂ => rfl\n  | a :: l₁, l₂ => by simp [filter]; split <;> simp [filter_append l₁]\n\n@[simp] theorem filter_sublist {p : α → Bool} : ∀ (l : List α), filter p l <+ l\n  | [] => .slnil\n  | a :: l => by rw [filter]; split <;> simp [Sublist.cons, Sublist.cons₂, filter_sublist l]\n\ntheorem mem_filter : x ∈ filter p as ↔ x ∈ as ∧ p x := by\n  induction as with\n  | nil => simp [filter]\n  | cons a as ih =>\n    by_cases h : p a <;> simp [*, or_and_right]\n    · exact or_congr_left (and_iff_left_of_imp fun | rfl => h).symm\n    · exact (or_iff_right fun ⟨rfl, h'⟩ => h h').symm\n\n@[simp] theorem partition_eq_filter_filter (p : α → Bool) (l : List α) :\n    partition p l = (filter p l, filter (not ∘ p) l) := by simp [partition, aux] where\n  aux : ∀ l {as bs}, partition.loop p l (as, bs) =\n    (as.reverse ++ filter p l, bs.reverse ++ filter (not ∘ p) l)\n  | [] => by simp [partition.loop, filter]\n  | a :: l => by cases pa : p a <;> simp [partition.loop, pa, aux, filter, append_assoc]\n\ntheorem filter_congr' {p q : α → Bool} :\n    ∀ {l : List α}, (∀ x ∈ l, p x ↔ q x) → filter p l = filter q l\n  | [], _ => rfl\n  | a :: l, h => by\n    rw [forall_mem_cons] at h; by_cases pa : p a\n    · simp [pa, h.1.1 pa, filter_congr' h.2]\n    · simp [pa, mt h.1.2 pa, filter_congr' h.2]\n\n/-! ### filterMap -/\n\n@[simp] theorem filterMap_nil (f : α → Option β) : filterMap f [] = [] := rfl\n\n@[simp] theorem filterMap_cons (f : α → Option β) (a : α) (l : List α) :\n    filterMap f (a :: l) =\n      match f a with\n      | none => filterMap f l\n      | some b => b :: filterMap f l := rfl\n\ntheorem filterMap_cons_none {f : α → Option β} (a : α) (l : List α) (h : f a = none) :\n    filterMap f (a :: l) = filterMap f l := by simp only [filterMap, h]\n\ntheorem filterMap_cons_some (f : α → Option β) (a : α) (l : List α) {b : β} (h : f a = some b) :\n    filterMap f (a :: l) = b :: filterMap f l := by simp only [filterMap, h]\n\ntheorem filterMap_append {α β : Type _} (l l' : List α) (f : α → Option β) :\n    filterMap f (l ++ l') = filterMap f l ++ filterMap f l' := by\n  induction l <;> simp; split <;> simp [*]\n\ntheorem filterMap_eq_map (f : α → β) : filterMap (some ∘ f) = map f := by\n  funext l; induction l <;> simp [*]\n\ntheorem filterMap_eq_filter (p : α → Bool) :\n    filterMap (Option.guard (p ·)) = filter p := by\n  funext l\n  induction l with\n  | nil => rfl\n  | cons a l IH => by_cases pa : p a <;> simp [Option.guard, pa, ← IH]\n\ntheorem filterMap_filterMap (f : α → Option β) (g : β → Option γ) (l : List α) :\n    filterMap g (filterMap f l) = filterMap (fun x => (f x).bind g) l := by\n  induction l with\n  | nil => rfl\n  | cons a l IH => cases h : f a <;> simp [*]\n\ntheorem map_filterMap (f : α → Option β) (g : β → γ) (l : List α) :\n    map g (filterMap f l) = filterMap (fun x => (f x).map g) l := by\n  simp only [← filterMap_eq_map, filterMap_filterMap, Option.map_eq_bind]\n\ntheorem filterMap_map (f : α → β) (g : β → Option γ) (l : List α) :\n    filterMap g (map f l) = filterMap (g ∘ f) l := by\n  rw [← filterMap_eq_map, filterMap_filterMap]; rfl\n\ntheorem filter_filterMap (f : α → Option β) (p : β → Bool) (l : List α) :\n    filter p (filterMap f l) = filterMap (fun x => (f x).filter p) l := by\n  rw [← filterMap_eq_filter, filterMap_filterMap]\n  congr; funext x; cases f x <;> simp [Option.filter, Option.guard]\n\ntheorem filterMap_filter (p : α → Bool) (f : α → Option β) (l : List α) :\n    filterMap f (filter p l) = filterMap (fun x => if p x then f x else none) l := by\n  rw [← filterMap_eq_filter, filterMap_filterMap]\n  congr; funext x; by_cases h : p x <;> simp [Option.guard, h]\n\n@[simp] theorem filterMap_some (l : List α) : filterMap some l = l := by\n  erw [filterMap_eq_map, map_id]\n\ntheorem map_filterMap_some_eq_filter_map_is_some (f : α → Option β) (l : List α) :\n    (l.filterMap f).map some = (l.map f).filter fun b => b.isSome := by\n  induction l <;> simp; split <;> simp [*]\n\n@[simp] theorem mem_filterMap (f : α → Option β) (l : List α) {b : β} :\n    b ∈ filterMap f l ↔ ∃ a, a ∈ l ∧ f a = some b := by\n  induction l <;> simp; split <;> simp [*, eq_comm]\n\n@[simp] theorem filterMap_join (f : α → Option β) (L : List (List α)) :\n    filterMap f (join L) = join (map (filterMap f) L) := by\n  induction L <;> simp [*, filterMap_append]\n\ntheorem map_filterMap_of_inv (f : α → Option β) (g : β → α) (H : ∀ x : α, (f x).map g = some x)\n    (l : List α) : map g (filterMap f l) = l := by simp only [map_filterMap, H, filterMap_some]\n\ntheorem length_filter_le (p : α → Bool) (l : List α) :\n    (l.filter p).length ≤ l.length := (filter_sublist _).length_le\n\ntheorem length_filterMap_le (f : α → Option β) (l : List α) :\n    (filterMap f l).length ≤ l.length := by\n  rw [← length_map _ some, map_filterMap_some_eq_filter_map_is_some, ← length_map _ f]\n  apply length_filter_le\n\ntheorem Sublist.filterMap (f : α → Option β) (s : l₁ <+ l₂) : filterMap f l₁ <+ filterMap f l₂ := by\n  induction s <;> simp <;> split <;> simp [*, cons, cons₂]\n\ntheorem Sublist.filter (p : α → Bool) {l₁ l₂} (s : l₁ <+ l₂) : filter p l₁ <+ filter p l₂ := by\n  rw [← filterMap_eq_filter]; apply s.filterMap\n\ntheorem map_filter (f : β → α) (l : List β) : filter p (map f l) = map f (filter (p ∘ f) l) := by\n  rw [← filterMap_eq_map, filter_filterMap, filterMap_filter]; rfl\n\n@[simp] theorem filter_filter (q) : ∀ l, filter p (filter q l) = filter (fun a => p a ∧ q a) l\n  | [] => rfl\n  | a :: l => by by_cases hp : p a <;> by_cases hq : q a <;> simp [hp, hq, filter_filter _ l]\n\ntheorem filter_eq_nil {l} : filter p l = [] ↔ ∀ a ∈ l, ¬p a := by\n  simp only [eq_nil_iff_forall_not_mem, mem_filter, not_and]\n\ntheorem filter_eq_self {l} : filter p l = l ↔ ∀ a ∈ l, p a := by\n  induction l with simp\n  | cons a l ih =>\n    cases h : p a <;> simp [*]\n    intro h; exact Nat.lt_irrefl _ (h ▸ length_filter_le p l)\n\ntheorem filter_length_eq_length {l} : (filter p l).length = l.length ↔ ∀ a ∈ l, p a :=\n  Iff.trans ⟨l.filter_sublist.eq_of_length, congrArg length⟩ filter_eq_self\n\n/-! ### find? -/\n\ntheorem find?_cons_of_pos (l) (h : p a) : find? p (a :: l) = some a :=\n  by simp [find?, h]\n\ntheorem find?_cons_of_neg (l) (h : ¬p a) : find? p (a :: l) = find? p l :=\n  by simp [find?, h]\n\ntheorem find?_eq_none : find? p l = none ↔ ∀ x ∈ l, ¬ p x := by\n  induction l <;> simp; split <;> simp [*]\n\ntheorem find?_some : ∀ {l}, find? p l = some a → p a\n  | b :: l, H => by\n    by_cases h : p b <;> simp [find?, h] at H\n    · exact H ▸ h\n    · exact find?_some H\n\n@[simp] theorem mem_of_find?_eq_some : ∀ {l}, find? p l = some a → a ∈ l\n  | b :: l, H => by\n    by_cases h : p b <;> simp [find?, h] at H\n    · exact H ▸ .head _\n    · exact .tail _ (mem_of_find?_eq_some H)\n\n/-! ### pairwise -/\n\ntheorem Pairwise.sublist : l₁ <+ l₂ → l₂.Pairwise R → l₁.Pairwise R\n  | .slnil, h => h\n  | .cons _ s, .cons _ h₂ => h₂.sublist s\n  | .cons₂ _ s, .cons h₁ h₂ => (h₂.sublist s).cons fun _ h => h₁ _ (s.subset h)\n\ntheorem pairwise_map {l : List α} :\n    (l.map f).Pairwise R ↔ l.Pairwise fun a b => R (f a) (f b) := by\n  induction l\n  . simp\n  . simp only [map, pairwise_cons, forall_mem_map_iff, *]\n\ntheorem pairwise_append {l₁ l₂ : List α} :\n    (l₁ ++ l₂).Pairwise R ↔ l₁.Pairwise R ∧ l₂.Pairwise R ∧ ∀ a ∈ l₁, ∀ b ∈ l₂, R a b := by\n  induction l₁ <;> simp [*, or_imp, forall_and, and_assoc, and_left_comm]\n\ntheorem pairwise_reverse {l : List α} :\n    l.reverse.Pairwise R ↔ l.Pairwise (fun a b => R b a) := by\n  induction l <;> simp [*, pairwise_append, and_comm]\n\ntheorem Pairwise.imp {α R S} (H : ∀ {a b}, R a b → S a b) :\n    ∀ {l : List α}, l.Pairwise R → l.Pairwise S\n  | _, .nil => .nil\n  | _, .cons h₁ h₂ => .cons (H ∘ h₁ ·) (h₂.imp H)\n\n/-! ### replaceF -/\n\n@[simp] theorem length_replaceF : length (replaceF f l) = length l := by\n  induction l <;> simp; split <;> simp [*]\n\n/-! ### disjoint -/\n\ntheorem disjoint_symm (d : Disjoint l₁ l₂) : Disjoint l₂ l₁ := fun _ i₂ i₁ => d i₁ i₂\n\ntheorem disjoint_comm : Disjoint l₁ l₂ ↔ Disjoint l₂ l₁ := ⟨disjoint_symm, disjoint_symm⟩\n\ntheorem disjoint_left : Disjoint l₁ l₂ ↔ ∀ ⦃a⦄, a ∈ l₁ → a ∉ l₂ := by simp [Disjoint]\n\ntheorem disjoint_right : Disjoint l₁ l₂ ↔ ∀ ⦃a⦄, a ∈ l₂ → a ∉ l₁ := disjoint_comm\n\ntheorem disjoint_iff_ne : Disjoint l₁ l₂ ↔ ∀ a ∈ l₁, ∀ b ∈ l₂, a ≠ b :=\n  ⟨fun h _ al1 _ bl2 ab => h al1 (ab ▸ bl2), fun h _ al1 al2 => h _ al1 _ al2 rfl⟩\n\ntheorem disjoint_of_subset_left (ss : l₁ ⊆ l) (d : Disjoint l l₂) : Disjoint l₁ l₂ :=\n  fun _ m => d (ss m)\n\ntheorem disjoint_of_subset_right (ss : l₂ ⊆ l) (d : Disjoint l₁ l) : Disjoint l₁ l₂ :=\n  fun _ m m₁ => d m (ss m₁)\n\ntheorem disjoint_of_disjoint_cons_left {l₁ l₂} : Disjoint (a :: l₁) l₂ → Disjoint l₁ l₂ :=\ndisjoint_of_subset_left (subset_cons _ _)\n\ntheorem disjoint_of_disjoint_cons_right {l₁ l₂} : Disjoint l₁ (a :: l₂) → Disjoint l₁ l₂ :=\ndisjoint_of_subset_right (subset_cons _ _)\n\n@[simp] theorem disjoint_nil_left (l : List α) : Disjoint [] l := fun a => (not_mem_nil a).elim\n\n@[simp] theorem disjoint_nil_right (l : List α) : Disjoint l [] := by\n  rw [disjoint_comm]; exact disjoint_nil_left _\n\n@[simp 1100] theorem singleton_disjoint : Disjoint [a] l ↔ a ∉ l := by simp [Disjoint]\n\n@[simp 1100] theorem disjoint_singleton : Disjoint l [a] ↔ a ∉ l := by\n  rw [disjoint_comm, singleton_disjoint]\n\n@[simp] theorem disjoint_append_left : Disjoint (l₁ ++ l₂) l ↔ Disjoint l₁ l ∧ Disjoint l₂ l := by\n  simp [Disjoint, or_imp, forall_and]\n\n@[simp] theorem disjoint_append_right : Disjoint l (l₁ ++ l₂) ↔ Disjoint l l₁ ∧ Disjoint l l₂ :=\n  disjoint_comm.trans <| by rw [disjoint_append_left]; simp [disjoint_comm]\n\n@[simp] theorem disjoint_cons_left : Disjoint (a::l₁) l₂ ↔ (a ∉ l₂) ∧ Disjoint l₁ l₂ :=\n  (disjoint_append_left (l₁ := [a])).trans <| by simp [singleton_disjoint]\n\n@[simp] theorem disjoint_cons_right : Disjoint l₁ (a :: l₂) ↔ (a ∉ l₁) ∧ Disjoint l₁ l₂ :=\n  disjoint_comm.trans <| by rw [disjoint_cons_left]; simp [disjoint_comm]\n\ntheorem disjoint_of_disjoint_append_left_left (d : Disjoint (l₁ ++ l₂) l) : Disjoint l₁ l :=\n  (disjoint_append_left.1 d).1\n\ntheorem disjoint_of_disjoint_append_left_right (d : Disjoint (l₁ ++ l₂) l) : Disjoint l₂ l :=\n  (disjoint_append_left.1 d).2\n\ntheorem disjoint_of_disjoint_append_right_left (d : Disjoint l (l₁ ++ l₂)) : Disjoint l l₁ :=\n  (disjoint_append_right.1 d).1\n\ntheorem disjoint_of_disjoint_append_right_right (d : Disjoint l (l₁ ++ l₂)) : Disjoint l l₂ :=\n  (disjoint_append_right.1 d).2\n\ntheorem disjoint_take_drop : ∀ {l : List α}, l.Nodup → m ≤ n → Disjoint (l.take m) (l.drop n)\n  | [], _, _ => by simp\n  | x :: xs, hl, h => by\n    cases m <;> cases n <;> simp only [disjoint_cons_left, mem_cons, disjoint_cons_right,\n      drop, true_or, eq_self_iff_true, not_true, false_and, not_mem_nil, disjoint_nil_left, take]\n    · case succ.zero => cases h\n    · cases hl with | cons h₀ h₁ =>\n      refine ⟨fun h => h₀ _ (mem_of_mem_drop h) rfl, ?_⟩\n      exact disjoint_take_drop h₁ (Nat.le_of_succ_le_succ h)\n\n/-! ### foldl / foldr -/\n\ntheorem foldl_map (f : β₁ → β₂) (g : α → β₂ → α) (l : List β₁) (init : α) :\n    (l.map f).foldl g init = l.foldl (fun x y => g x (f y)) init := by\n  induction l generalizing init <;> simp [*]\n\ntheorem foldr_map (f : α₁ → α₂) (g : α₂ → β → β) (l : List α₁) (init : β) :\n    (l.map f).foldr g init = l.foldr (fun x y => g (f x) y) init := by\n  induction l generalizing init <;> simp [*]\n\ntheorem foldl_hom (f : α₁ → α₂) (g₁ : α₁ → β → α₁) (g₂ : α₂ → β → α₂) (l : List β) (init : α₁)\n    (H : ∀ x y, g₂ (f x) y = f (g₁ x y)) : l.foldl g₂ (f init) = f (l.foldl g₁ init) := by\n  induction l generalizing init <;> simp [*, H]\n\ntheorem foldr_hom (f : β₁ → β₂) (g₁ : α → β₁ → β₁) (g₂ : α → β₂ → β₂) (l : List α) (init : β₁)\n    (H : ∀ x y, g₂ x (f y) = f (g₁ x y)) : l.foldr g₂ (f init) = f (l.foldr g₁ init) := by\n  induction l <;> simp [*, H]\n\n/-! ### union -/\n\nsection union\n\nvariable [DecidableEq α]\n\n@[simp] theorem nil_union (l : List α) : nil.union l = l := by simp [List.union, foldr]\n\n@[simp] theorem cons_union (a : α) (l₁ l₂ : List α) :\n    (a :: l₁).union l₂ = (l₁.union l₂).insert a := by simp [List.union, foldr]\n\n@[simp] theorem mem_union_iff [DecidableEq α] {x : α} {l₁ l₂ : List α} :\n    x ∈ l₁.union l₂ ↔ x ∈ l₁ ∨ x ∈ l₂ := by induction l₁ <;> simp [*, or_assoc]\n\nend union\n\n/-! ### inter -/\n\n@[simp] theorem mem_inter_iff [DecidableEq α] {x : α} {l₁ l₂ : List α} :\n    x ∈ l₁.inter l₂ ↔ x ∈ l₁ ∧ x ∈ l₂ := by\n  cases l₁ <;> simp [List.inter, mem_filter]\n\n/-! ### product -/\n\n/-- List.prod satisfies a specification of cartesian product on lists. -/\ntheorem pair_mem_product {xs : List α} {ys : List β} {x : α} {y : β} :\n    (x, y) ∈ product xs ys ↔ x ∈ xs ∧ y ∈ ys := by\n  simp only [product, and_imp, exists_prop, mem_map, Prod.mk.injEq,\n    exists_eq_right_right, mem_bind, iff_self]\n\n/-! ### leftpad -/\n\n/-- The length of the List returned by `List.leftpad n a l` is equal\n  to the larger of `n` and `l.length` -/\ntheorem leftpad_length (n : Nat) (a : α) (l : List α) :\n    (leftpad n a l).length = max n l.length := by\n  simp only [leftpad, length_append, length_replicate, Nat.sub_add_eq_max]\n\ntheorem leftpad_prefix (n : Nat) (a : α) (l : List α) :\n    isPrefix (replicate (n - length l) a) (leftpad n a l) := by\n  simp only [isPrefix, leftpad]\n  exact Exists.intro l rfl\n\ntheorem leftpad_suffix (n : Nat) (a : α) (l : List α) : isSuffix l (leftpad n a l) := by\n  simp only [isSuffix, leftpad]\n  exact Exists.intro (replicate (n - length l) a) rfl\n\n/-! ### monadic operations -/\n\n-- we use ForIn.forIn as the simp normal form\n@[simp] theorem forIn_eq_forIn [Monad m] : @List.forIn α β m _ = forIn := rfl\n\ntheorem forIn_eq_bindList [Monad m] [LawfulMonad m]\n    (f : α → β → m (ForInStep β)) (l : List α) (init : β) :\n    forIn l init f = ForInStep.run <$> (ForInStep.yield init).bindList f l := by\n  induction l generalizing init <;> simp [*, map_eq_pure_bind]\n  congr; ext (b | b) <;> simp\n\n@[simp] theorem forM_append [Monad m] [LawfulMonad m] (l₁ l₂ : List α) (f : α → m PUnit) :\n    (l₁ ++ l₂).forM f = (do l₁.forM f; l₂.forM f) := by induction l₁ <;> simp [*]\n\n/-! ### diff -/\n\nsection Diff\n-- TODO: theorems about `BEq`\nvariable [DecidableEq α]\n\n@[simp] theorem diff_nil (l : List α) : l.diff [] = l := rfl\n\n@[simp] theorem diff_cons (l₁ l₂ : List α) (a : α) : l₁.diff (a :: l₂) = (l₁.erase a).diff l₂ := by\n  simp [List.diff]; split <;> simp [*, erase_of_not_mem]\n\ntheorem diff_cons_right (l₁ l₂ : List α) (a : α) : l₁.diff (a :: l₂) = (l₁.diff l₂).erase a := by\n  apply Eq.symm; induction l₂ generalizing l₁ <;> simp [erase_comm, *]\n\ntheorem diff_erase (l₁ l₂ : List α) (a : α) : (l₁.diff l₂).erase a = (l₁.erase a).diff l₂ := by\n  rw [← diff_cons_right, diff_cons]\n\n@[simp] theorem nil_diff (l : List α) : [].diff l = [] := by\n  induction l <;> simp [*, erase_of_not_mem]\n\ntheorem cons_diff (a : α) (l₁ l₂ : List α) :\n    (a :: l₁).diff l₂ = if a ∈ l₂ then l₁.diff (l₂.erase a) else a :: l₁.diff l₂ := by\n  induction l₂ generalizing l₁ with\n  | nil => rfl\n  | cons b l₂ ih => by_cases h : a = b <;> simp [*, eq_comm]\n\ntheorem cons_diff_of_mem {a : α} {l₂ : List α} (h : a ∈ l₂) (l₁ : List α) :\n    (a :: l₁).diff l₂ = l₁.diff (l₂.erase a) := by rw [cons_diff, if_pos h]\n\ntheorem cons_diff_of_not_mem {a : α} {l₂ : List α} (h : a ∉ l₂) (l₁ : List α) :\n    (a :: l₁).diff l₂ = a :: l₁.diff l₂ := by rw [cons_diff, if_neg h]\n\ntheorem diff_eq_foldl : ∀ l₁ l₂ : List α, l₁.diff l₂ = foldl List.erase l₁ l₂\n  | _, [] => rfl\n  | l₁, a :: l₂ => (diff_cons l₁ l₂ a).trans (diff_eq_foldl _ _)\n\n@[simp] theorem diff_append (l₁ l₂ l₃ : List α) : l₁.diff (l₂ ++ l₃) = (l₁.diff l₂).diff l₃ := by\n  simp only [diff_eq_foldl, foldl_append]\n\ntheorem diff_sublist : ∀ l₁ l₂ : List α, l₁.diff l₂ <+ l₁\n  | _, [] => .refl _\n  | l₁, a :: l₂ =>\n    calc\n      l₁.diff (a :: l₂) = (l₁.erase a).diff l₂ := diff_cons ..\n      _ <+ l₁.erase a := diff_sublist ..\n      _ <+ l₁ := erase_sublist ..\n\ntheorem diff_subset (l₁ l₂ : List α) : l₁.diff l₂ ⊆ l₁ := (diff_sublist ..).subset\n\ntheorem mem_diff_of_mem {a : α} : ∀ {l₁ l₂ : List α}, a ∈ l₁ → a ∉ l₂ → a ∈ l₁.diff l₂\n  | _, [], h₁, _ => h₁\n  | l₁, b :: l₂, h₁, h₂ => by\n    rw [diff_cons]\n    exact mem_diff_of_mem ((mem_erase_of_ne <| ne_of_not_mem_cons h₂).2 h₁) (mt (.tail _) h₂)\n\ntheorem Sublist.diff_right : ∀ {l₁ l₂ l₃ : List α}, l₁ <+ l₂ → l₁.diff l₃ <+ l₂.diff l₃\n  | _,  _, [], h => h\n  | l₁, l₂, a :: l₃, h => by simp only [diff_cons, (h.erase _).diff_right]\n\ntheorem Sublist.erase_diff_erase_sublist {a : α} :\n    ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → (l₂.erase a).diff (l₁.erase a) <+ l₂.diff l₁\n  | [], l₂, _ => erase_sublist _ _\n  | b :: l₁, l₂, h => by\n    if heq : b = a then\n      simp [heq]\n    else\n      simp [heq, erase_comm a]\n      exact (erase_cons_head b _ ▸ h.erase b).erase_diff_erase_sublist\n\nend Diff\n", "meta": {"author": "leanprover", "repo": "std4", "sha": "5507f9d8409f93b984ce04eccf4914d534e6fca2", "save_path": "github-repos/lean/leanprover-std4", "path": "github-repos/lean/leanprover-std4/std4-5507f9d8409f93b984ce04eccf4914d534e6fca2/Std/Data/List/Lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.4735984408540818}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\n\nimport algebra.group.pi\nimport algebra.hom.equiv\nimport algebra.ring.opposite\nimport data.finset.fold\nimport data.fintype.basic\nimport data.set.pairwise\n\n/-!\n# Big operators\n\nIn this file we define products and sums indexed by finite sets (specifically, `finset`).\n\n## Notation\n\nWe introduce the following notation, localized in `big_operators`.\nTo enable the notation, use `open_locale big_operators`.\n\nLet `s` be a `finset α`, and `f : α → β` a function.\n\n* `∏ x in s, f x` is notation for `finset.prod s f` (assuming `β` is a `comm_monoid`)\n* `∑ x in s, f x` is notation for `finset.sum s f` (assuming `β` is an `add_comm_monoid`)\n* `∏ x, f x` is notation for `finset.prod finset.univ f`\n  (assuming `α` is a `fintype` and `β` is a `comm_monoid`)\n* `∑ x, f x` is notation for `finset.sum finset.univ f`\n  (assuming `α` is a `fintype` and `β` is an `add_comm_monoid`)\n\n## Implementation Notes\n\nThe first arguments in all definitions and lemmas is the codomain of the function of the big\noperator. This is necessary for the heuristic in `@[to_additive]`.\nSee the documentation of `to_additive.attr` for more information.\n\n-/\n\nuniverses u v w\nvariables {β : Type u} {α : Type v} {γ : Type w}\n\nnamespace finset\n\n/--\n`∏ x in s, f x` is the product of `f x`\nas `x` ranges over the elements of the finite set `s`.\n-/\n@[to_additive \"`∑ x in s, f x` is the sum of `f x` as `x` ranges over the elements\nof the finite set `s`.\"]\nprotected def prod [comm_monoid β] (s : finset α) (f : α → β) : β := (s.1.map f).prod\n\n@[simp, to_additive] lemma prod_mk [comm_monoid β] (s : multiset α) (hs : s.nodup) (f : α → β) :\n  (⟨s, hs⟩ : finset α).prod f = (s.map f).prod :=\nrfl\n\nend finset\n\n/--\nThere is no established mathematical convention\nfor the operator precedence of big operators like `∏` and `∑`.\nWe will have to make a choice.\n\nOnline discussions, such as https://math.stackexchange.com/q/185538/30839\nseem to suggest that `∏` and `∑` should have the same precedence,\nand that this should be somewhere between `*` and `+`.\nThe latter have precedence levels `70` and `65` respectively,\nand we therefore choose the level `67`.\n\nIn practice, this means that parentheses should be placed as follows:\n```lean\n∑ k in K, (a k + b k) = ∑ k in K, a k + ∑ k in K, b k →\n  ∏ k in K, a k * b k = (∏ k in K, a k) * (∏ k in K, b k)\n```\n(Example taken from page 490 of Knuth's *Concrete Mathematics*.)\n-/\nlibrary_note \"operator precedence of big operators\"\n\nlocalized \"notation `∑` binders `, ` r:(scoped:67 f, finset.sum finset.univ f) := r\"\n  in big_operators\nlocalized \"notation `∏` binders `, ` r:(scoped:67 f, finset.prod finset.univ f) := r\"\n  in big_operators\n\nlocalized \"notation `∑` binders ` in ` s `, ` r:(scoped:67 f, finset.sum s f) := r\"\n  in big_operators\nlocalized \"notation `∏` binders ` in ` s `, ` r:(scoped:67 f, finset.prod s f) := r\"\n  in big_operators\n\nopen_locale big_operators\n\nnamespace finset\nvariables {s s₁ s₂ : finset α} {a : α} {f g : α → β}\n\n@[to_additive] lemma prod_eq_multiset_prod [comm_monoid β] (s : finset α) (f : α → β) :\n  ∏ x in s, f x = (s.1.map f).prod := rfl\n\n@[to_additive]\ntheorem prod_eq_fold [comm_monoid β] (s : finset α) (f : α → β) :\n  ∏ x in s, f x = s.fold (*) 1 f :=\nrfl\n\n@[simp] lemma sum_multiset_singleton (s : finset α) :\n  s.sum (λ x, {x}) = s.val :=\nby simp only [sum_eq_multiset_sum, multiset.sum_map_singleton]\n\nend finset\n\n@[to_additive]\nlemma map_prod [comm_monoid β] [comm_monoid γ] {G : Type*} [monoid_hom_class G β γ] (g : G)\n  (f : α → β) (s : finset α) :\n  g (∏ x in s, f x) = ∏ x in s, g (f x) :=\nby simp only [finset.prod_eq_multiset_prod, map_multiset_prod, multiset.map_map]\n\nsection deprecated\n\n/-- Deprecated: use `_root_.map_prod` instead. -/\n@[to_additive \"Deprecated: use `_root_.map_sum` instead.\"]\nprotected lemma monoid_hom.map_prod [comm_monoid β] [comm_monoid γ] (g : β →* γ) (f : α → β)\n  (s : finset α) : g (∏ x in s, f x) = ∏ x in s, g (f x) :=\nmap_prod g f s\n\n/-- Deprecated: use `_root_.map_prod` instead. -/\n@[to_additive \"Deprecated: use `_root_.map_sum` instead.\"]\nprotected lemma mul_equiv.map_prod [comm_monoid β] [comm_monoid γ] (g : β ≃* γ) (f : α → β)\n  (s : finset α) : g (∏ x in s, f x) = ∏ x in s, g (f x) :=\nmap_prod g f s\n\n/-- Deprecated: use `_root_.map_list_prod` instead. -/\nprotected lemma ring_hom.map_list_prod [semiring β] [semiring γ] (f : β →+* γ) (l : list β) :\n  f l.prod = (l.map f).prod :=\nmap_list_prod f l\n\n/-- Deprecated: use `_root_.map_list_sum` instead. -/\nprotected lemma ring_hom.map_list_sum [non_assoc_semiring β] [non_assoc_semiring γ]\n  (f : β →+* γ) (l : list β) :\n  f l.sum = (l.map f).sum :=\nmap_list_sum f l\n\n/-- A morphism into the opposite ring acts on the product by acting on the reversed elements.\n\nDeprecated: use `_root_.unop_map_list_prod` instead.\n-/\nprotected lemma ring_hom.unop_map_list_prod [semiring β] [semiring γ] (f : β →+* γᵐᵒᵖ)\n  (l : list β) : mul_opposite.unop (f l.prod) = (l.map (mul_opposite.unop ∘ f)).reverse.prod :=\nunop_map_list_prod f l\n\n/-- Deprecated: use `_root_.map_multiset_prod` instead. -/\nprotected lemma ring_hom.map_multiset_prod [comm_semiring β] [comm_semiring γ] (f : β →+* γ)\n  (s : multiset β) :\n  f s.prod = (s.map f).prod :=\nmap_multiset_prod f s\n\n/-- Deprecated: use `_root_.map_multiset_sum` instead. -/\nprotected lemma ring_hom.map_multiset_sum [non_assoc_semiring β] [non_assoc_semiring γ]\n  (f : β →+* γ) (s : multiset β) :\n  f s.sum = (s.map f).sum :=\nmap_multiset_sum f s\n\n/-- Deprecated: use `_root_.map_prod` instead. -/\nprotected lemma ring_hom.map_prod [comm_semiring β] [comm_semiring γ] (g : β →+* γ) (f : α → β)\n  (s : finset α) :\n  g (∏ x in s, f x) = ∏ x in s, g (f x) :=\nmap_prod g f s\n\n/-- Deprecated: use `_root_.map_sum` instead. -/\nprotected lemma ring_hom.map_sum [non_assoc_semiring β] [non_assoc_semiring γ]\n  (g : β →+* γ) (f : α → β) (s : finset α) :\n  g (∑ x in s, f x) = ∑ x in s, g (f x) :=\nmap_sum g f s\n\nend deprecated\n\n@[to_additive]\nlemma monoid_hom.coe_finset_prod [mul_one_class β] [comm_monoid γ] (f : α → β →* γ) (s : finset α) :\n  ⇑(∏ x in s, f x) = ∏ x in s, f x :=\n(monoid_hom.coe_fn β γ).map_prod _ _\n\n-- See also `finset.prod_apply`, with the same conclusion\n-- but with the weaker hypothesis `f : α → β → γ`.\n@[simp, to_additive]\nlemma monoid_hom.finset_prod_apply [mul_one_class β] [comm_monoid γ] (f : α → β →* γ)\n  (s : finset α) (b : β) : (∏ x in s, f x) b = ∏ x in s, f x b :=\n(monoid_hom.eval b).map_prod _ _\n\nvariables {s s₁ s₂ : finset α} {a : α} {f g : α → β}\n\nnamespace finset\n\nsection comm_monoid\nvariables [comm_monoid β]\n\n@[simp, to_additive]\nlemma prod_empty {f : α → β} : (∏ x in (∅:finset α), f x) = 1 := rfl\n\n@[simp, to_additive]\nlemma prod_cons (h : a ∉ s) : (∏ x in (cons a s h), f x) = f a * ∏ x in s, f x :=\nfold_cons h\n\n@[simp, to_additive]\nlemma prod_insert [decidable_eq α] : a ∉ s → (∏ x in (insert a s), f x) = f a * ∏ x in s, f x :=\nfold_insert\n\n/--\nThe product of `f` over `insert a s` is the same as\nthe product over `s`, as long as `a` is in `s` or `f a = 1`.\n-/\n@[simp, to_additive \"The sum of `f` over `insert a s` is the same as\nthe sum over `s`, as long as `a` is in `s` or `f a = 0`.\"]\nlemma prod_insert_of_eq_one_if_not_mem [decidable_eq α] (h : a ∉ s → f a = 1) :\n  ∏ x in insert a s, f x = ∏ x in s, f x :=\nbegin\n  by_cases hm : a ∈ s,\n  { simp_rw insert_eq_of_mem hm },\n  { rw [prod_insert hm, h hm, one_mul] },\nend\n\n/--\nThe product of `f` over `insert a s` is the same as the product over `s`, as long as `f a = 1`.\n-/\n@[simp, to_additive \"The sum of `f` over `insert a s` is the same as\nthe sum over `s`, as long as `f a = 0`.\"]\nlemma prod_insert_one [decidable_eq α] (h : f a = 1) :\n  ∏ x in insert a s, f x = ∏ x in s, f x :=\nprod_insert_of_eq_one_if_not_mem (λ _, h)\n\n@[simp, to_additive]\nlemma prod_singleton : (∏ x in (singleton a), f x) = f a :=\neq.trans fold_singleton $ mul_one _\n\n@[to_additive]\nlemma prod_pair [decidable_eq α] {a b : α} (h : a ≠ b) :\n  (∏ x in ({a, b} : finset α), f x) = f a * f b :=\nby rw [prod_insert (not_mem_singleton.2 h), prod_singleton]\n\n@[simp, priority 1100, to_additive]\nlemma prod_const_one : (∏ x in s, (1 : β)) = 1 :=\nby simp only [finset.prod, multiset.map_const, multiset.prod_repeat, one_pow]\n\n@[simp, to_additive]\nlemma prod_image [decidable_eq α] {s : finset γ} {g : γ → α} :\n  (∀ x ∈ s, ∀ y ∈ s, g x = g y → x = y) → (∏ x in (s.image g), f x) = ∏ x in s, f (g x) :=\nfold_image\n\n@[simp, to_additive]\nlemma prod_map (s : finset α) (e : α ↪ γ) (f : γ → β) :\n  (∏ x in (s.map e), f x) = ∏ x in s, f (e x) :=\nby rw [finset.prod, finset.map_val, multiset.map_map]; refl\n\n@[congr, to_additive]\nlemma prod_congr (h : s₁ = s₂) : (∀ x ∈ s₂, f x = g x) → s₁.prod f = s₂.prod g :=\nby rw [h]; exact fold_congr\nattribute [congr] finset.sum_congr\n\n@[to_additive]\nlemma prod_union_inter [decidable_eq α] :\n  (∏ x in (s₁ ∪ s₂), f x) * (∏ x in (s₁ ∩ s₂), f x) = (∏ x in s₁, f x) * (∏ x in s₂, f x) :=\nfold_union_inter\n\n@[to_additive]\nlemma prod_union [decidable_eq α] (h : disjoint s₁ s₂) :\n  (∏ x in (s₁ ∪ s₂), f x) = (∏ x in s₁, f x) * (∏ x in s₂, f x) :=\nby rw [←prod_union_inter, (disjoint_iff_inter_eq_empty.mp h)]; exact (mul_one _).symm\n\n@[to_additive]\nlemma prod_filter_mul_prod_filter_not (s : finset α) (p : α → Prop) [decidable_pred p]\n  [decidable_pred (λ x, ¬p x)] (f : α → β) :\n  (∏ x in s.filter p, f x) * (∏ x in s.filter (λ x, ¬p x), f x) = ∏ x in s, f x :=\nbegin\n  haveI := classical.dec_eq α,\n  rw [← prod_union (filter_inter_filter_neg_eq p s).le, filter_union_filter_neg_eq]\nend\n\nsection to_list\n\n@[simp, to_additive]\nlemma prod_to_list (s : finset α) (f : α → β) : (s.to_list.map f).prod = s.prod f :=\nby rw [finset.prod, ← multiset.coe_prod, ← multiset.coe_map, finset.coe_to_list]\n\nend to_list\n\n@[to_additive]\nlemma _root_.equiv.perm.prod_comp (σ : equiv.perm α) (s : finset α) (f : α → β)\n  (hs : {a | σ a ≠ a} ⊆ s) :\n  (∏ x in s, f (σ x)) = ∏ x in s, f x :=\nby { convert (prod_map _ σ.to_embedding _).symm, exact (map_perm hs).symm }\n\n@[to_additive]\nlemma _root_.equiv.perm.prod_comp' (σ : equiv.perm α) (s : finset α) (f : α → α → β)\n  (hs : {a | σ a ≠ a} ⊆ s) :\n  (∏ x in s, f (σ x) x) = ∏ x in s, f x (σ.symm x) :=\nby { convert σ.prod_comp s (λ x, f x (σ.symm x)) hs, ext, rw equiv.symm_apply_apply }\n\nend comm_monoid\n\nend finset\n\nsection\nopen finset\nvariables [fintype α] [decidable_eq α] [comm_monoid β]\n\n@[to_additive]\nlemma is_compl.prod_mul_prod {s t : finset α} (h : is_compl s t) (f : α → β) :\n  (∏ i in s, f i) * (∏ i in t, f i) = ∏ i, f i :=\n(finset.prod_union h.disjoint).symm.trans $ by rw [← finset.sup_eq_union, h.sup_eq_top]; refl\n\nend\n\nnamespace finset\n\nsection comm_monoid\nvariables [comm_monoid β]\n\n/-- Multiplying the products of a function over `s` and over `sᶜ` gives the whole product.\nFor a version expressed with subtypes, see `fintype.prod_subtype_mul_prod_subtype`. -/\n@[to_additive \"Adding the sums of a function over `s` and over `sᶜ` gives the whole sum.\nFor a version expressed with subtypes, see `fintype.sum_subtype_add_sum_subtype`. \"]\nlemma prod_mul_prod_compl [fintype α] [decidable_eq α] (s : finset α) (f : α → β) :\n  (∏ i in s, f i) * (∏ i in sᶜ, f i) = ∏ i, f i :=\nis_compl.prod_mul_prod is_compl_compl f\n\n@[to_additive]\nlemma prod_compl_mul_prod [fintype α] [decidable_eq α] (s : finset α) (f : α → β) :\n  (∏ i in sᶜ, f i) * (∏ i in s, f i) = ∏ i, f i :=\n(@is_compl_compl _ s _).symm.prod_mul_prod f\n\n@[to_additive]\nlemma prod_sdiff [decidable_eq α] (h : s₁ ⊆ s₂) :\n  (∏ x in (s₂ \\ s₁), f x) * (∏ x in s₁, f x) = (∏ x in s₂, f x) :=\nby rw [←prod_union sdiff_disjoint, sdiff_union_of_subset h]\n\n@[simp, to_additive]\nlemma prod_sum_elim [decidable_eq (α ⊕ γ)]\n  (s : finset α) (t : finset γ) (f : α → β) (g : γ → β) :\n  ∏ x in s.map function.embedding.inl ∪ t.map function.embedding.inr, sum.elim f g x =\n    (∏ x in s, f x) * (∏ x in t, g x) :=\nbegin\n  rw [prod_union, prod_map, prod_map],\n  { simp only [sum.elim_inl, function.embedding.inl_apply, function.embedding.inr_apply,\n      sum.elim_inr] },\n  { simp only [disjoint_left, finset.mem_map, finset.mem_map],\n    rintros _ ⟨i, hi, rfl⟩ ⟨j, hj, H⟩,\n    cases H }\nend\n\n@[to_additive]\nlemma prod_bUnion [decidable_eq α] {s : finset γ} {t : γ → finset α}\n  (hs : set.pairwise_disjoint ↑s t) :\n  (∏ x in (s.bUnion t), f x) = ∏ x in s, ∏ i in t x, f i :=\nbegin\n  haveI := classical.dec_eq γ,\n  induction s using finset.induction_on with x s hxs ih hd,\n  { simp_rw [bUnion_empty, prod_empty] },\n  { simp_rw [coe_insert, set.pairwise_disjoint_insert, mem_coe] at hs,\n    have : disjoint (t x) (finset.bUnion s t),\n    { exact (disjoint_bUnion_right _ _ _).mpr (λ y hy, hs.2 y hy $ λ H, hxs $ H.substr hy) },\n    rw [bUnion_insert, prod_insert hxs, prod_union this, ih hs.1] }\nend\n\n/-- Product over a sigma type equals the product of fiberwise products. For rewriting\nin the reverse direction, use `finset.prod_sigma'`.  -/\n@[to_additive \"Sum over a sigma type equals the sum of fiberwise sums. For rewriting\nin the reverse direction, use `finset.sum_sigma'`\"]\nlemma prod_sigma {σ : α → Type*}\n  (s : finset α) (t : Π a, finset (σ a)) (f : sigma σ → β) :\n  (∏ x in s.sigma t, f x) = ∏ a in s, ∏ s in (t a), f ⟨a, s⟩ :=\nby classical;\ncalc (∏ x in s.sigma t, f x) =\n       ∏ x in s.bUnion (λ a, (t a).map (function.embedding.sigma_mk a)), f x : by rw sigma_eq_bUnion\n  ... = ∏ a in s, ∏ x in (t a).map (function.embedding.sigma_mk a), f x :\n    prod_bUnion $ assume a₁ ha a₂ ha₂ h x hx,\n    by { simp only [inf_eq_inter, mem_inter, mem_map, function.embedding.sigma_mk_apply] at hx,\n      rcases hx with ⟨⟨y, hy, rfl⟩, ⟨z, hz, hz'⟩⟩, cc }\n  ... = ∏ a in s, ∏ s in t a, f ⟨a, s⟩ :\n    prod_congr rfl $ λ _ _, prod_map _ _ _\n\n@[to_additive]\nlemma prod_sigma' {σ : α → Type*}\n  (s : finset α) (t : Π a, finset (σ a)) (f : Π a, σ a → β) :\n  (∏ a in s, ∏ s in (t a), f a s) = ∏ x in s.sigma t, f x.1 x.2 :=\neq.symm $ prod_sigma s t (λ x, f x.1 x.2)\n\n/--\n  Reorder a product.\n\n  The difference with `prod_bij'` is that the bijection is specified as a surjective injection,\n  rather than by an inverse function.\n-/\n@[to_additive \"\n  Reorder a sum.\n\n  The difference with `sum_bij'` is that the bijection is specified as a surjective injection,\n  rather than by an inverse function.\n\"]\nlemma prod_bij {s : finset α} {t : finset γ} {f : α → β} {g : γ → β}\n  (i : Π a ∈ s, γ) (hi : ∀ a ha, i a ha ∈ t) (h : ∀ a ha, f a = g (i a ha))\n  (i_inj : ∀ a₁ a₂ ha₁ ha₂, i a₁ ha₁ = i a₂ ha₂ → a₁ = a₂) (i_surj : ∀ b ∈ t, ∃ a ha, b = i a ha) :\n  (∏ x in s, f x) = (∏ x in t, g x) :=\ncongr_arg multiset.prod\n  (multiset.map_eq_map_of_bij_of_nodup f g s.2 t.2 i hi h i_inj i_surj)\n\n/--\n  Reorder a product.\n\n  The difference with `prod_bij` is that the bijection is specified with an inverse, rather than\n  as a surjective injection.\n-/\n@[to_additive \"\n  Reorder a sum.\n\n  The difference with `sum_bij` is that the bijection is specified with an inverse, rather than\n  as a surjective injection.\n\"]\nlemma prod_bij' {s : finset α} {t : finset γ} {f : α → β} {g : γ → β}\n  (i : Π a ∈ s, γ) (hi : ∀ a ha, i a ha ∈ t) (h : ∀ a ha, f a = g (i a ha))\n  (j : Π a ∈ t, α) (hj : ∀ a ha, j a ha ∈ s) (left_inv : ∀ a ha, j (i a ha) (hi a ha) = a)\n  (right_inv : ∀ a ha, i (j a ha) (hj a ha) = a) :\n  (∏ x in s, f x) = (∏ x in t, g x) :=\nbegin\n  refine prod_bij i hi h _ _,\n  {intros a1 a2 h1 h2 eq, rw [←left_inv a1 h1, ←left_inv a2 h2], cc,},\n  {intros b hb, use j b hb, use hj b hb, exact (right_inv b hb).symm,},\nend\n\n@[to_additive] lemma prod_finset_product\n  (r : finset (γ × α)) (s : finset γ) (t : γ → finset α)\n  (h : ∀ p : γ × α, p ∈ r ↔ p.1 ∈ s ∧ p.2 ∈ t p.1) {f : γ × α → β} :\n  ∏ p in r, f p = ∏ c in s, ∏ a in t c, f (c, a) :=\nbegin\n  refine eq.trans _ (prod_sigma s t (λ p, f (p.1, p.2))),\n  exact prod_bij' (λ p hp, ⟨p.1, p.2⟩) (λ p, mem_sigma.mpr ∘ (h p).mp)\n    (λ p hp, congr_arg f prod.mk.eta.symm) (λ p hp, (p.1, p.2))\n    (λ p, (h (p.1, p.2)).mpr ∘ mem_sigma.mp) (λ p hp, prod.mk.eta) (λ p hp, p.eta),\nend\n\n@[to_additive] lemma prod_finset_product'\n  (r : finset (γ × α)) (s : finset γ) (t : γ → finset α)\n  (h : ∀ p : γ × α, p ∈ r ↔ p.1 ∈ s ∧ p.2 ∈ t p.1) {f : γ → α → β} :\n  ∏ p in r, f p.1 p.2 = ∏ c in s, ∏ a in t c, f c a :=\nprod_finset_product r s t h\n\n@[to_additive] lemma prod_finset_product_right\n  (r : finset (α × γ)) (s : finset γ) (t : γ → finset α)\n  (h : ∀ p : α × γ, p ∈ r ↔ p.2 ∈ s ∧ p.1 ∈ t p.2) {f : α × γ → β} :\n  ∏ p in r, f p = ∏ c in s, ∏ a in t c, f (a, c) :=\nbegin\n  refine eq.trans _ (prod_sigma s t (λ p, f (p.2, p.1))),\n  exact prod_bij' (λ p hp, ⟨p.2, p.1⟩) (λ p, mem_sigma.mpr ∘ (h p).mp)\n    (λ p hp, congr_arg f prod.mk.eta.symm) (λ p hp, (p.2, p.1))\n    (λ p, (h (p.2, p.1)).mpr ∘ mem_sigma.mp) (λ p hp, prod.mk.eta) (λ p hp, p.eta),\nend\n\n@[to_additive] lemma prod_finset_product_right'\n  (r : finset (α × γ)) (s : finset γ) (t : γ → finset α)\n  (h : ∀ p : α × γ, p ∈ r ↔ p.2 ∈ s ∧ p.1 ∈ t p.2) {f : α → γ → β} :\n  ∏ p in r, f p.1 p.2 = ∏ c in s, ∏ a in t c, f a c :=\nprod_finset_product_right r s t h\n\n@[to_additive]\nlemma prod_fiberwise_of_maps_to [decidable_eq γ] {s : finset α} {t : finset γ} {g : α → γ}\n  (h : ∀ x ∈ s, g x ∈ t) (f : α → β) :\n  (∏ y in t, ∏ x in s.filter (λ x, g x = y), f x) = ∏ x in s, f x :=\nbegin\n  letI := classical.dec_eq α,\n  rw [← bUnion_filter_eq_of_maps_to h] {occs := occurrences.pos [2]},\n  refine (prod_bUnion $ λ x' hx y' hy hne, _).symm,\n  rw [function.on_fun, disjoint_filter],\n  rintros x hx rfl,\n  exact hne\nend\n\n@[to_additive]\nlemma prod_image' [decidable_eq α] {s : finset γ} {g : γ → α} (h : γ → β)\n  (eq : ∀ c ∈ s, f (g c) = ∏ x in s.filter (λ c', g c' = g c), h x) :\n  (∏ x in s.image g, f x) = ∏ x in s, h x :=\ncalc (∏ x in s.image g, f x) = ∏ x in s.image g, ∏ x in s.filter (λ c', g c' = x), h x :\n  prod_congr rfl $ λ x hx, let ⟨c, hcs, hc⟩ := mem_image.1 hx in hc ▸ (eq c hcs)\n... = ∏ x in s, h x : prod_fiberwise_of_maps_to (λ x, mem_image_of_mem g) _\n\n@[to_additive]\nlemma prod_mul_distrib : ∏ x in s, (f x * g x) = (∏ x in s, f x) * (∏ x in s, g x) :=\neq.trans (by rw one_mul; refl) fold_op_distrib\n\n@[to_additive]\nlemma prod_comm {s : finset γ} {t : finset α} {f : γ → α → β} :\n  (∏ x in s, ∏ y in t, f x y) = (∏ y in t, ∏ x in s, f x y) :=\nbegin\n  classical,\n  apply finset.induction_on s,\n  { simp only [prod_empty, prod_const_one] },\n  { intros _ _ H ih,\n    simp only [prod_insert H, prod_mul_distrib, ih] }\nend\n\n@[to_additive]\nlemma prod_product {s : finset γ} {t : finset α} {f : γ×α → β} :\n  (∏ x in s.product t, f x) = ∏ x in s, ∏ y in t, f (x, y) :=\nprod_finset_product (s.product t) s (λ a, t) (λ p, mem_product)\n\n/-- An uncurried version of `finset.prod_product`. -/\n@[to_additive \"An uncurried version of `finset.sum_product`\"]\nlemma prod_product' {s : finset γ} {t : finset α} {f : γ → α → β} :\n  (∏ x in s.product t, f x.1 x.2) = ∏ x in s, ∏ y in t, f x y :=\nprod_product\n\n@[to_additive]\nlemma prod_product_right {s : finset γ} {t : finset α} {f : γ×α → β} :\n  (∏ x in s.product t, f x) = ∏ y in t, ∏ x in s, f (x, y) :=\nby rw [prod_product, prod_comm]\n\n/-- An uncurried version of `finset.prod_product_right`. -/\n@[to_additive \"An uncurried version of `finset.prod_product_right`\"]\nlemma prod_product_right' {s : finset γ} {t : finset α} {f : γ → α → β} :\n  (∏ x in s.product t, f x.1 x.2) = ∏ y in t, ∏ x in s, f x y :=\nprod_product_right\n\n@[to_additive]\nlemma prod_hom_rel [comm_monoid γ] {r : β → γ → Prop} {f : α → β} {g : α → γ} {s : finset α}\n  (h₁ : r 1 1) (h₂ : ∀ a b c, r b c → r (f a * b) (g a * c)) : r (∏ x in s, f x) (∏ x in s, g x) :=\nby { delta finset.prod, apply multiset.prod_hom_rel; assumption }\n\n@[to_additive]\nlemma prod_eq_one {f : α → β} {s : finset α} (h : ∀ x ∈ s, f x = 1) : (∏ x in s, f x) = 1 :=\ncalc (∏ x in s, f x) = ∏ x in s, 1 : finset.prod_congr rfl h\n  ... = 1 : finset.prod_const_one\n\n@[to_additive]\nlemma prod_subset_one_on_sdiff [decidable_eq α] (h : s₁ ⊆ s₂) (hg : ∀ x ∈ (s₂ \\ s₁), g x = 1)\n  (hfg : ∀ x ∈ s₁, f x = g x) : ∏ i in s₁, f i = ∏ i in s₂, g i :=\nbegin\n  rw [← prod_sdiff h, prod_eq_one hg, one_mul],\n  exact prod_congr rfl hfg\nend\n\n@[to_additive]\nlemma prod_subset (h : s₁ ⊆ s₂) (hf : ∀ x ∈ s₂, x ∉ s₁ → f x = 1) :\n  (∏ x in s₁, f x) = ∏ x in s₂, f x :=\nby haveI := classical.dec_eq α; exact prod_subset_one_on_sdiff h (by simpa) (λ _ _, rfl)\n\n@[to_additive]\nlemma prod_filter_of_ne {p : α → Prop} [decidable_pred p] (hp : ∀ x ∈ s, f x ≠ 1 → p x) :\n  (∏ x in (s.filter p), f x) = (∏ x in s, f x) :=\nprod_subset (filter_subset _ _) $ λ x,\n  by { classical, rw [not_imp_comm, mem_filter], exact λ h₁ h₂, ⟨h₁, hp _ h₁ h₂⟩ }\n\n-- If we use `[decidable_eq β]` here, some rewrites fail because they find a wrong `decidable`\n-- instance first; `{∀ x, decidable (f x ≠ 1)}` doesn't work with `rw ← prod_filter_ne_one`\n@[to_additive]\nlemma prod_filter_ne_one [∀ x, decidable (f x ≠ 1)] :\n  (∏ x in (s.filter $ λ x, f x ≠ 1), f x) = (∏ x in s, f x) :=\nprod_filter_of_ne $ λ _ _, id\n\n@[to_additive]\nlemma prod_filter (p : α → Prop) [decidable_pred p] (f : α → β) :\n  (∏ a in s.filter p, f a) = (∏ a in s, if p a then f a else 1) :=\ncalc (∏ a in s.filter p, f a) = ∏ a in s.filter p, if p a then f a else 1 :\n    prod_congr rfl (assume a h, by rw [if_pos (mem_filter.1 h).2])\n  ... = ∏ a in s, if p a then f a else 1 :\n    begin\n      refine prod_subset (filter_subset _ s) (assume x hs h, _),\n      rw [mem_filter, not_and] at h,\n      exact if_neg (h hs)\n    end\n\n@[to_additive]\nlemma prod_eq_single_of_mem {s : finset α} {f : α → β} (a : α) (h : a ∈ s)\n  (h₀ : ∀ b ∈ s, b ≠ a → f b = 1) : (∏ x in s, f x) = f a :=\nbegin\n  haveI := classical.dec_eq α,\n  calc (∏ x in s, f x) = ∏ x in {a}, f x :\n      begin\n        refine (prod_subset _ _).symm,\n        { intros _ H, rwa mem_singleton.1 H },\n        { simpa only [mem_singleton] }\n      end\n      ... = f a : prod_singleton\nend\n\n@[to_additive]\nlemma prod_eq_single {s : finset α} {f : α → β} (a : α)\n  (h₀ : ∀ b ∈ s, b ≠ a → f b = 1) (h₁ : a ∉ s → f a = 1) : (∏ x in s, f x) = f a :=\nby haveI := classical.dec_eq α;\nfrom classical.by_cases\n  (assume : a ∈ s, prod_eq_single_of_mem a this h₀)\n  (assume : a ∉ s,\n    (prod_congr rfl $ λ b hb, h₀ b hb $ by rintro rfl; cc).trans $\n      prod_const_one.trans (h₁ this).symm)\n\n@[to_additive]\n\n\n@[to_additive]\nlemma prod_eq_mul {s : finset α} {f : α → β} (a b : α) (hn : a ≠ b)\n  (h₀ : ∀ c ∈ s, c ≠ a ∧ c ≠ b → f c = 1) (ha : a ∉ s → f a = 1) (hb : b ∉ s → f b = 1) :\n  (∏ x in s, f x) = (f a) * (f b) :=\nbegin\n  haveI := classical.dec_eq α;\n  by_cases h₁ : a ∈ s; by_cases h₂ : b ∈ s,\n  { exact prod_eq_mul_of_mem a b h₁ h₂ hn h₀ },\n  { rw [hb h₂, mul_one],\n    apply prod_eq_single_of_mem a h₁,\n    exact λ c hc hca, h₀ c hc ⟨hca, ne_of_mem_of_not_mem hc h₂⟩ },\n  { rw [ha h₁, one_mul],\n    apply prod_eq_single_of_mem b h₂,\n    exact λ c hc hcb, h₀ c hc ⟨ne_of_mem_of_not_mem hc h₁, hcb⟩ },\n  { rw [ha h₁, hb h₂, mul_one],\n    exact trans\n      (prod_congr rfl (λ c hc, h₀ c hc ⟨ne_of_mem_of_not_mem hc h₁, ne_of_mem_of_not_mem hc h₂⟩))\n      prod_const_one }\nend\n\n@[to_additive]\nlemma prod_attach {f : α → β} : (∏ x in s.attach, f x) = (∏ x in s, f x) :=\nby haveI := classical.dec_eq α; exact\n  calc (∏ x in s.attach, f x.val) = (∏ x in (s.attach).image subtype.val, f x) :\n    by rw [prod_image]; exact assume x _ y _, subtype.eq\n  ... = _ : by rw [attach_image_val]\n\n/-- A product over `s.subtype p` equals one over `s.filter p`. -/\n@[simp, to_additive \"A sum over `s.subtype p` equals one over `s.filter p`.\"]\nlemma prod_subtype_eq_prod_filter (f : α → β) {p : α → Prop} [decidable_pred p] :\n  ∏ x in s.subtype p, f x = ∏ x in s.filter p, f x :=\nbegin\n  conv_lhs { erw ←prod_map (s.subtype p) (function.embedding.subtype _) f },\n  exact prod_congr (subtype_map _) (λ x hx, rfl)\nend\n\n/-- If all elements of a `finset` satisfy the predicate `p`, a product\nover `s.subtype p` equals that product over `s`. -/\n@[to_additive \"If all elements of a `finset` satisfy the predicate `p`, a sum\nover `s.subtype p` equals that sum over `s`.\"]\nlemma prod_subtype_of_mem (f : α → β) {p : α → Prop} [decidable_pred p]\n    (h : ∀ x ∈ s, p x) : ∏ x in s.subtype p, f x = ∏ x in s, f x :=\nby simp_rw [prod_subtype_eq_prod_filter, filter_true_of_mem h]\n\n/-- A product of a function over a `finset` in a subtype equals a\nproduct in the main type of a function that agrees with the first\nfunction on that `finset`. -/\n@[to_additive \"A sum of a function over a `finset` in a subtype equals a\nsum in the main type of a function that agrees with the first\nfunction on that `finset`.\"]\nlemma prod_subtype_map_embedding {p : α → Prop} {s : finset {x // p x}} {f : {x // p x} → β}\n    {g : α → β} (h : ∀ x : {x // p x}, x ∈ s → g x = f x) :\n  ∏ x in s.map (function.embedding.subtype _), g x = ∏ x in s, f x :=\nbegin\n  rw finset.prod_map,\n  exact finset.prod_congr rfl h\nend\n\n@[to_additive]\nlemma prod_finset_coe (f : α → β) (s : finset α) :\n  ∏ (i : (s : set α)), f i = ∏ i in s, f i :=\nprod_attach\n\n@[to_additive]\nlemma prod_subtype {p : α → Prop} {F : fintype (subtype p)} (s : finset α)\n  (h : ∀ x, x ∈ s ↔ p x) (f : α → β) :\n  ∏ a in s, f a = ∏ a : subtype p, f a :=\nhave (∈ s) = p, from set.ext h, by { substI p, rw [←prod_finset_coe], congr }\n\n@[to_additive] lemma prod_apply_dite {s : finset α} {p : α → Prop} {hp : decidable_pred p}\n  [decidable_pred (λ x, ¬ p x)] (f : Π (x : α), p x → γ) (g : Π (x : α), ¬p x → γ)\n  (h : γ → β) :\n  (∏ x in s, h (if hx : p x then f x hx else g x hx)) =\n  (∏ x in (s.filter p).attach, h (f x.1 (mem_filter.mp x.2).2)) *\n    (∏ x in (s.filter (λ x, ¬ p x)).attach, h (g x.1 (mem_filter.mp x.2).2)) :=\ncalc ∏ x in s, h (if hx : p x then f x hx else g x hx)\n    = (∏ x in s.filter p, h (if hx : p x then f x hx else g x hx)) *\n    (∏ x in s.filter (λ x, ¬ p x), h (if hx : p x then f x hx else g x hx)) :\n  (prod_filter_mul_prod_filter_not s p _).symm\n... = (∏ x in (s.filter p).attach, h (if hx : p x.1 then f x.1 hx else g x.1 hx)) *\n    (∏ x in (s.filter (λ x, ¬ p x)).attach, h (if hx : p x.1 then f x.1 hx else g x.1 hx)) :\n  congr_arg2 _ prod_attach.symm prod_attach.symm\n... = (∏ x in (s.filter p).attach, h (f x.1 (mem_filter.mp x.2).2)) *\n    (∏ x in (s.filter (λ x, ¬ p x)).attach, h (g x.1 (mem_filter.mp x.2).2)) :\n  congr_arg2 _\n    (prod_congr rfl (λ x hx, congr_arg h (dif_pos (mem_filter.mp x.2).2)))\n    (prod_congr rfl (λ x hx, congr_arg h (dif_neg (mem_filter.mp x.2).2)))\n\n@[to_additive] lemma prod_apply_ite {s : finset α}\n  {p : α → Prop} {hp : decidable_pred p} (f g : α → γ) (h : γ → β) :\n  (∏ x in s, h (if p x then f x else g x)) =\n  (∏ x in s.filter p, h (f x)) * (∏ x in s.filter (λ x, ¬ p x), h (g x)) :=\ntrans (prod_apply_dite _ _ _)\n  (congr_arg2 _ (@prod_attach _ _ _ _ (h ∘ f)) (@prod_attach _ _ _ _ (h ∘ g)))\n\n@[to_additive] lemma prod_dite {s : finset α} {p : α → Prop} {hp : decidable_pred p}\n  (f : Π (x : α), p x → β) (g : Π (x : α), ¬p x → β) :\n  (∏ x in s, if hx : p x then f x hx else g x hx) =\n  (∏ x in (s.filter p).attach, f x.1 (mem_filter.mp x.2).2) *\n    (∏ x in (s.filter (λ x, ¬ p x)).attach, g x.1 (mem_filter.mp x.2).2) :=\nby simp [prod_apply_dite _ _ (λ x, x)]\n\n@[to_additive] lemma prod_ite {s : finset α}\n  {p : α → Prop} {hp : decidable_pred p} (f g : α → β) :\n  (∏ x in s, if p x then f x else g x) =\n  (∏ x in s.filter p, f x) * (∏ x in s.filter (λ x, ¬ p x), g x) :=\nby simp [prod_apply_ite _ _ (λ x, x)]\n\n@[to_additive] lemma prod_ite_of_false {p : α → Prop} {hp : decidable_pred p} (f g : α → β)\n  (h : ∀ x ∈ s, ¬p x) : (∏ x in s, if p x then f x else g x) = (∏ x in s, g x) :=\nby { rw prod_ite, simp [filter_false_of_mem h, filter_true_of_mem h] }\n\n@[to_additive] lemma prod_ite_of_true {p : α → Prop} {hp : decidable_pred p} (f g : α → β)\n  (h : ∀ x ∈ s, p x) : (∏ x in s, if p x then f x else g x) = (∏ x in s, f x) :=\nby { simp_rw ←(ite_not (p _)), apply prod_ite_of_false, simpa }\n\n@[to_additive] lemma prod_apply_ite_of_false {p : α → Prop} {hp : decidable_pred p} (f g : α → γ)\n  (k : γ → β) (h : ∀ x ∈ s, ¬p x) :\n  (∏ x in s, k (if p x then f x else g x)) = (∏ x in s, k (g x)) :=\nby { simp_rw apply_ite k, exact prod_ite_of_false _ _ h }\n\n@[to_additive] lemma prod_apply_ite_of_true {p : α → Prop} {hp : decidable_pred p} (f g : α → γ)\n  (k : γ → β) (h : ∀ x ∈ s, p x) :\n  (∏ x in s, k (if p x then f x else g x)) = (∏ x in s, k (f x)) :=\nby { simp_rw apply_ite k, exact prod_ite_of_true _ _ h }\n\n@[to_additive]\nlemma prod_extend_by_one [decidable_eq α] (s : finset α) (f : α → β) :\n  ∏ i in s, (if i ∈ s then f i else 1) = ∏ i in s, f i :=\nprod_congr rfl $ λ i hi, if_pos hi\n\n@[simp, to_additive]\nlemma prod_dite_eq [decidable_eq α] (s : finset α) (a : α) (b : Π x : α, a = x → β) :\n  (∏ x in s, (if h : a = x then b x h else 1)) = ite (a ∈ s) (b a rfl) 1 :=\nbegin\n  split_ifs with h,\n  { rw [finset.prod_eq_single a, dif_pos rfl],\n    { intros, rw dif_neg, cc },\n    { cc } },\n  { rw finset.prod_eq_one,\n    intros, rw dif_neg, intro, cc }\nend\n\n@[simp, to_additive]\nlemma prod_dite_eq' [decidable_eq α] (s : finset α) (a : α) (b : Π x : α, x = a → β) :\n  (∏ x in s, (if h : x = a then b x h else 1)) = ite (a ∈ s) (b a rfl) 1 :=\nbegin\n  split_ifs with h,\n  { rw [finset.prod_eq_single a, dif_pos rfl],\n    { intros, rw dif_neg, cc },\n    { cc } },\n  { rw finset.prod_eq_one,\n    intros, rw dif_neg, intro, cc }\nend\n\n@[simp, to_additive] lemma prod_ite_eq [decidable_eq α] (s : finset α) (a : α) (b : α → β) :\n  (∏ x in s, (ite (a = x) (b x) 1)) = ite (a ∈ s) (b a) 1 :=\nprod_dite_eq s a (λ x _, b x)\n\n/-- A product taken over a conditional whose condition is an equality test on the index and whose\nalternative is `1` has value either the term at that index or `1`.\n\nThe difference with `finset.prod_ite_eq` is that the arguments to `eq` are swapped. -/\n@[simp, to_additive \"A sum taken over a conditional whose condition is an equality test on the index\nand whose alternative is `0` has value either the term at that index or `0`.\n\nThe difference with `finset.sum_ite_eq` is that the arguments to `eq` are swapped.\"]\nlemma prod_ite_eq' [decidable_eq α] (s : finset α) (a : α) (b : α → β) :\n  (∏ x in s, (ite (x = a) (b x) 1)) = ite (a ∈ s) (b a) 1 :=\nprod_dite_eq' s a (λ x _, b x)\n\n@[to_additive]\nlemma prod_ite_index (p : Prop) [decidable p] (s t : finset α) (f : α → β) :\n  (∏ x in if p then s else t, f x) = if p then ∏ x in s, f x else ∏ x in t, f x :=\napply_ite (λ s, ∏ x in s, f x) _ _ _\n\n@[simp, to_additive]\nlemma prod_dite_irrel (p : Prop) [decidable p] (s : finset α) (f : p → α → β) (g : ¬p → α → β):\n  (∏ x in s, if h : p then f h x else g h x) = if h : p then ∏ x in s, f h x else ∏ x in s, g h x :=\nby { split_ifs with h; refl }\n\n@[simp] lemma sum_pi_single' {ι M : Type*} [decidable_eq ι] [add_comm_monoid M]\n  (i : ι) (x : M) (s : finset ι) :\n  ∑ j in s, pi.single i x j = if i ∈ s then x else 0 :=\nsum_dite_eq' _ _ _\n\n@[simp] lemma sum_pi_single {ι : Type*} {M : ι → Type*}\n  [decidable_eq ι] [Π i, add_comm_monoid (M i)] (i : ι) (f : Π i, M i) (s : finset ι) :\n  ∑ j in s, pi.single j (f j) i = if i ∈ s then f i else 0 :=\nsum_dite_eq _ _ _\n\n@[to_additive]\nlemma prod_bij_ne_one {s : finset α} {t : finset γ} {f : α → β} {g : γ → β}\n  (i : Π a ∈ s, f a ≠ 1 → γ) (hi : ∀ a h₁ h₂, i a h₁ h₂ ∈ t)\n  (i_inj : ∀ a₁ a₂ h₁₁ h₁₂ h₂₁ h₂₂, i a₁ h₁₁ h₁₂ = i a₂ h₂₁ h₂₂ → a₁ = a₂)\n  (i_surj : ∀ b ∈ t, g b ≠ 1 → ∃ a h₁ h₂, b = i a h₁ h₂)\n  (h : ∀ a h₁ h₂, f a = g (i a h₁ h₂)) :\n  (∏ x in s, f x) = (∏ x in t, g x) :=\nby classical; exact\ncalc (∏ x in s, f x) = ∏ x in (s.filter $ λ x, f x ≠ 1), f x : prod_filter_ne_one.symm\n  ... = ∏ x in (t.filter $ λ x, g x ≠ 1), g x :\n    prod_bij (assume a ha, i a (mem_filter.mp ha).1 (mem_filter.mp ha).2)\n      (assume a ha, (mem_filter.mp ha).elim $ λ h₁ h₂, mem_filter.mpr\n        ⟨hi a h₁ h₂, λ hg, h₂ (hg ▸ h a h₁ h₂)⟩)\n      (assume a ha, (mem_filter.mp ha).elim $ h a)\n      (assume a₁ a₂ ha₁ ha₂,\n        (mem_filter.mp ha₁).elim $ λ ha₁₁ ha₁₂,\n          (mem_filter.mp ha₂).elim $ λ ha₂₁ ha₂₂, i_inj a₁ a₂ _ _ _ _)\n      (assume b hb, (mem_filter.mp hb).elim $ λ h₁ h₂,\n        let ⟨a, ha₁, ha₂, eq⟩ := i_surj b h₁ h₂ in ⟨a, mem_filter.mpr ⟨ha₁, ha₂⟩, eq⟩)\n  ... = (∏ x in t, g x) : prod_filter_ne_one\n\n@[to_additive] lemma prod_dite_of_false {p : α → Prop} {hp : decidable_pred p}\n  (h : ∀ x ∈ s, ¬ p x) (f : Π (x : α), p x → β) (g : Π (x : α), ¬p x → β) :\n  (∏ x in s, if hx : p x then f x hx else g x hx) =\n  ∏ (x : s), g x.val (h x.val x.property) :=\nprod_bij (λ x hx, ⟨x,hx⟩) (λ x hx, by simp) (λ a ha, by { dsimp, rw dif_neg })\n  (λ a₁ a₂ h₁ h₂ hh, congr_arg coe hh) (λ b hb, ⟨b.1, b.2, by simp⟩)\n\n@[to_additive] lemma prod_dite_of_true {p : α → Prop} {hp : decidable_pred p}\n  (h : ∀ x ∈ s, p x) (f : Π (x : α), p x → β) (g : Π (x : α), ¬p x → β) :\n  (∏ x in s, if hx : p x then f x hx else g x hx) =\n  ∏ (x : s), f x.val (h x.val x.property) :=\nprod_bij (λ x hx, ⟨x,hx⟩) (λ x hx, by simp) (λ a ha, by { dsimp, rw dif_pos })\n  (λ a₁ a₂ h₁ h₂ hh, congr_arg coe hh) (λ b hb, ⟨b.1, b.2, by simp⟩)\n\n@[to_additive]\nlemma nonempty_of_prod_ne_one (h : (∏ x in s, f x) ≠ 1) : s.nonempty :=\ns.eq_empty_or_nonempty.elim (λ H, false.elim $ h $ H.symm ▸ prod_empty) id\n\n@[to_additive]\nlemma exists_ne_one_of_prod_ne_one (h : (∏ x in s, f x) ≠ 1) : ∃ a ∈ s, f a ≠ 1 :=\nbegin\n  classical,\n  rw ← prod_filter_ne_one at h,\n  rcases nonempty_of_prod_ne_one h with ⟨x, hx⟩,\n  exact ⟨x, (mem_filter.1 hx).1, (mem_filter.1 hx).2⟩\nend\n\n@[to_additive]\nlemma prod_range_succ_comm (f : ℕ → β) (n : ℕ) :\n  ∏ x in range (n + 1), f x = f n * ∏ x in range n, f x :=\nby rw [range_succ, prod_insert not_mem_range_self]\n\n@[to_additive]\nlemma prod_range_succ (f : ℕ → β) (n : ℕ) :\n  ∏ x in range (n + 1), f x = (∏ x in range n, f x) * f n :=\nby simp only [mul_comm, prod_range_succ_comm]\n\n@[to_additive]\nlemma prod_range_succ' (f : ℕ → β) :\n  ∀ n : ℕ, (∏ k in range (n + 1), f k) = (∏ k in range n, f (k+1)) * f 0\n| 0       := prod_range_succ _ _\n| (n + 1) := by rw [prod_range_succ _ n, mul_right_comm, ← prod_range_succ', prod_range_succ]\n\n@[to_additive]\nlemma eventually_constant_prod {u : ℕ → β} {N : ℕ} (hu : ∀ n ≥ N, u n = 1) {n : ℕ} (hn : N ≤ n) :\n  ∏ k in range (n + 1), u k = ∏ k in range (N + 1), u k :=\nbegin\n  obtain ⟨m, rfl : n = N + m⟩ := le_iff_exists_add.mp hn,\n  clear hn,\n  induction m with m hm,\n  { simp },\n  erw [prod_range_succ, hm],\n  simp [hu]\nend\n\n@[to_additive]\nlemma prod_range_add (f : ℕ → β) (n m : ℕ) :\n  ∏ x in range (n + m), f x =\n  (∏ x in range n, f x) * (∏ x in range m, f (n + x)) :=\nbegin\n  induction m with m hm,\n  { simp },\n  { rw [nat.add_succ, prod_range_succ, hm, prod_range_succ, mul_assoc], },\nend\n\n@[to_additive]\nlemma prod_range_add_div_prod_range {α : Type*} [comm_group α] (f : ℕ → α) (n m : ℕ) :\n  (∏ k in range (n + m), f k) / (∏ k in range n, f k) = ∏ k in finset.range m, f (n + k) :=\ndiv_eq_of_eq_mul' (prod_range_add f n m)\n\n@[to_additive]\nlemma prod_range_zero (f : ℕ → β) :\n  ∏ k in range 0, f k = 1 :=\nby rw [range_zero, prod_empty]\n\n@[to_additive sum_range_one]\nlemma prod_range_one (f : ℕ → β) :\n  ∏ k in range 1, f k = f 0 :=\nby { rw [range_one], apply @prod_singleton β ℕ 0 f }\n\nopen multiset\n\n@[to_additive] lemma prod_multiset_map_count [decidable_eq α] (s : multiset α)\n  {M : Type*} [comm_monoid M] (f : α → M) :\n  (s.map f).prod = ∏ m in s.to_finset, (f m) ^ (s.count m) :=\nbegin\n  induction s using multiset.induction_on with a s ih,\n  { simp only [prod_const_one, count_zero, prod_zero, pow_zero, multiset.map_zero] },\n  simp only [multiset.prod_cons, map_cons, to_finset_cons, ih],\n  by_cases has : a ∈ s.to_finset,\n  { rw [insert_eq_of_mem has, ← insert_erase has, prod_insert (not_mem_erase _ _),\n        prod_insert (not_mem_erase _ _), ← mul_assoc, count_cons_self, pow_succ],\n    congr' 1, refine prod_congr rfl (λ x hx, _),\n    rw [count_cons_of_ne (ne_of_mem_erase hx)] },\n  rw [prod_insert has, count_cons_self, count_eq_zero_of_not_mem (mt mem_to_finset.2 has), pow_one],\n  congr' 1, refine prod_congr rfl (λ x hx, _),\n  rw count_cons_of_ne,\n  rintro rfl, exact has hx\nend\n\n@[to_additive]\nlemma prod_multiset_count [decidable_eq α] [comm_monoid α] (s : multiset α) :\n  s.prod = ∏ m in s.to_finset, m ^ (s.count m) :=\nby { convert prod_multiset_map_count s id, rw map_id }\n\n@[to_additive]\nlemma prod_multiset_count_of_subset [decidable_eq α] [comm_monoid α]\n  (m : multiset α) (s : finset α) (hs : m.to_finset ⊆ s) :\n  m.prod = ∏ i in s, i ^ (m.count i) :=\nbegin\n  rw prod_multiset_count,\n  apply prod_subset hs,\n  rintros x - hx,\n  rw [mem_to_finset] at hx,\n  rw [count_eq_zero_of_not_mem hx, pow_zero],\nend\n\n@[to_additive] lemma prod_mem_multiset [decidable_eq α]\n  (m : multiset α) (f : {x // x ∈ m} → β) (g : α → β)\n  (hfg : ∀ x, f x = g x) :\n  ∏ (x : {x // x ∈ m}), f x = ∏ x in m.to_finset, g x :=\nprod_bij (λ x _, x.1) (λ x _, multiset.mem_to_finset.mpr x.2)\n  (λ _ _, hfg _)\n  (λ _ _ _ _ h, by { ext, assumption })\n  (λ y hy, ⟨⟨y, multiset.mem_to_finset.mp hy⟩, finset.mem_univ _, rfl⟩)\n\n/--\nTo prove a property of a product, it suffices to prove that\nthe property is multiplicative and holds on factors.\n-/\n@[to_additive \"To prove a property of a sum, it suffices to prove that\nthe property is additive and holds on summands.\"]\nlemma prod_induction {M : Type*} [comm_monoid M] (f : α → M) (p : M → Prop)\n  (p_mul : ∀ a b, p a → p b → p (a * b)) (p_one : p 1) (p_s : ∀ x ∈ s, p $ f x) :\n  p $ ∏ x in s, f x :=\nmultiset.prod_induction _ _ p_mul p_one (multiset.forall_mem_map_iff.mpr p_s)\n\n/--\nTo prove a property of a product, it suffices to prove that\nthe property is multiplicative and holds on factors.\n-/\n@[to_additive \"To prove a property of a sum, it suffices to prove that\nthe property is additive and holds on summands.\"]\nlemma prod_induction_nonempty {M : Type*} [comm_monoid M] (f : α → M) (p : M → Prop)\n  (p_mul : ∀ a b, p a → p b → p (a * b)) (hs_nonempty : s.nonempty) (p_s : ∀ x ∈ s, p $ f x) :\n  p $ ∏ x in s, f x :=\nmultiset.prod_induction_nonempty p p_mul (by simp [nonempty_iff_ne_empty.mp hs_nonempty])\n  (multiset.forall_mem_map_iff.mpr p_s)\n\n/--\nFor any product along `{0, ..., n-1}` of a commutative-monoid-valued function, we can verify that\nit's equal to a different function just by checking ratios of adjacent terms.\nThis is a multiplicative discrete analogue of the fundamental theorem of calculus. -/\nlemma prod_range_induction {M : Type*} [comm_monoid M]\n  (f s : ℕ → M) (h0 : s 0 = 1) (h : ∀ n, s (n + 1) = s n * f n) (n : ℕ) :\n  ∏ k in finset.range n, f k = s n :=\nbegin\n  induction n with k hk,\n  { simp only [h0, finset.prod_range_zero] },\n  { simp only [hk, finset.prod_range_succ, h, mul_comm] }\nend\n\n/--\nFor any sum along `{0, ..., n-1}` of a commutative-monoid-valued function,\nwe can verify that it's equal to a different function\njust by checking differences of adjacent terms.\nThis is a discrete analogue\nof the fundamental theorem of calculus.\n-/\nlemma sum_range_induction {M : Type*} [add_comm_monoid M]\n  (f s : ℕ → M) (h0 : s 0 = 0) (h : ∀ n, s (n + 1) = s n + f n) (n : ℕ) :\n  ∑ k in finset.range n, f k = s n :=\n@prod_range_induction (multiplicative M) _ f s h0 h n\n\n/-- A telescoping sum along `{0, ..., n - 1}` of an additive commutative group valued function\nreduces to the difference of the last and first terms.-/\nlemma sum_range_sub {G : Type*} [add_comm_group G] (f : ℕ → G) (n : ℕ) :\n  ∑ i in range n, (f (i+1) - f i) = f n - f 0 :=\nby { apply sum_range_induction; simp }\n\nlemma sum_range_sub' {G : Type*} [add_comm_group G] (f : ℕ → G) (n : ℕ) :\n  ∑ i in range n, (f i - f (i+1)) = f 0 - f n :=\nby { apply sum_range_induction; simp }\n\n/-- A telescoping product along `{0, ..., n - 1}` of a commutative group valued function reduces to\nthe ratio of the last and first factors. -/\n@[to_additive]\nlemma prod_range_div {M : Type*} [comm_group M] (f : ℕ → M) (n : ℕ) :\n  ∏ i in range n, (f (i+1) * (f i)⁻¹) = f n * (f 0)⁻¹ :=\nby simpa only [← div_eq_mul_inv] using @sum_range_sub (additive M) _ f n\n\n@[to_additive]\nlemma prod_range_div' {M : Type*} [comm_group M] (f : ℕ → M) (n : ℕ) :\n  ∏ i in range n, (f i * (f (i+1))⁻¹) = f 0 * (f n)⁻¹ :=\nby simpa only [← div_eq_mul_inv] using @sum_range_sub' (additive M) _ f n\n\n/--\nA telescoping sum along `{0, ..., n-1}` of an `ℕ`-valued function\nreduces to the difference of the last and first terms\nwhen the function we are summing is monotone.\n-/\nlemma sum_range_sub_of_monotone {f : ℕ → ℕ} (h : monotone f) (n : ℕ) :\n  ∑ i in range n, (f (i+1) - f i) = f n - f 0 :=\nbegin\n  refine sum_range_induction _ _ (tsub_self _) (λ n, _) _,\n  have h₁ : f n ≤ f (n+1) := h (nat.le_succ _),\n  have h₂ : f 0 ≤ f n := h (nat.zero_le _),\n  rw [tsub_add_eq_add_tsub h₂, add_tsub_cancel_of_le h₁],\nend\n\n@[simp, to_additive] lemma prod_const (b : β) : (∏ x in s, b) = b ^ s.card :=\nby haveI := classical.dec_eq α; exact\nfinset.induction_on s (by simp) (λ a s has ih,\nby rw [prod_insert has, card_insert_of_not_mem has, pow_succ, ih])\n\n@[to_additive]\nlemma pow_eq_prod_const (b : β) : ∀ n, b ^ n = ∏ k in range n, b := by simp\n\n@[to_additive]\nlemma prod_pow (s : finset α) (n : ℕ) (f : α → β) :\n  ∏ x in s, f x ^ n = (∏ x in s, f x) ^ n :=\nby haveI := classical.dec_eq α; exact\nfinset.induction_on s (by simp) (by simp [mul_pow] {contextual := tt})\n\n@[to_additive]\nlemma prod_flip {n : ℕ} (f : ℕ → β) :\n  ∏ r in range (n + 1), f (n - r) = ∏ k in range (n + 1), f k :=\nbegin\n  induction n with n ih,\n  { rw [prod_range_one, prod_range_one] },\n  { rw [prod_range_succ', prod_range_succ _ (nat.succ n)],\n    simp [← ih] }\nend\n\n@[to_additive]\nlemma prod_involution {s : finset α} {f : α → β} :\n  ∀ (g : Π a ∈ s, α)\n  (h : ∀ a ha, f a * f (g a ha) = 1)\n  (g_ne : ∀ a ha, f a ≠ 1 → g a ha ≠ a)\n  (g_mem : ∀ a ha, g a ha ∈ s)\n  (g_inv : ∀ a ha, g (g a ha) (g_mem a ha) = a),\n  (∏ x in s, f x) = 1 :=\nby haveI := classical.dec_eq α;\nhaveI := classical.dec_eq β; exact\nfinset.strong_induction_on s\n  (λ s ih g h g_ne g_mem g_inv,\n    s.eq_empty_or_nonempty.elim (λ hs, hs.symm ▸ rfl)\n      (λ ⟨x, hx⟩,\n      have hmem : ∀ y ∈ (s.erase x).erase (g x hx), y ∈ s,\n        from λ y hy, (mem_of_mem_erase (mem_of_mem_erase hy)),\n      have g_inj : ∀ {x hx y hy}, g x hx = g y hy → x = y,\n        from λ x hx y hy h, by rw [← g_inv x hx, ← g_inv y hy]; simp [h],\n      have ih': ∏ y in erase (erase s x) (g x hx), f y = (1 : β) :=\n        ih ((s.erase x).erase (g x hx))\n          ⟨subset.trans (erase_subset _ _) (erase_subset _ _),\n            λ h, not_mem_erase (g x hx) (s.erase x) (h (g_mem x hx))⟩\n          (λ y hy, g y (hmem y hy))\n          (λ y hy, h y (hmem y hy))\n          (λ y hy, g_ne y (hmem y hy))\n          (λ y hy, mem_erase.2 ⟨λ (h : g y _ = g x hx), by simpa [g_inj h] using hy,\n            mem_erase.2 ⟨λ (h : g y _ = x),\n              have y = g x hx, from g_inv y (hmem y hy) ▸ by simp [h],\n              by simpa [this] using hy, g_mem y (hmem y hy)⟩⟩)\n          (λ y hy, g_inv y (hmem y hy)),\n      if hx1 : f x = 1\n      then ih' ▸ eq.symm (prod_subset hmem\n        (λ y hy hy₁,\n          have y = x ∨ y = g x hx, by simp [hy] at hy₁; tauto,\n          this.elim (λ hy, hy.symm ▸ hx1)\n            (λ hy, h x hx ▸ hy ▸ hx1.symm ▸ (one_mul _).symm)))\n      else by rw [← insert_erase hx, prod_insert (not_mem_erase _ _),\n        ← insert_erase (mem_erase.2 ⟨g_ne x hx hx1, g_mem x hx⟩),\n        prod_insert (not_mem_erase _ _), ih', mul_one, h x hx]))\n\n\n/-- The product of the composition of functions `f` and `g`, is the product over `b ∈ s.image g` of\n`f b` to the power of the cardinality of the fibre of `b`. See also `finset.prod_image`. -/\n@[to_additive \"The sum of the composition of functions `f` and `g`, is the sum over `b ∈ s.image g`\nof `f b` times of the cardinality of the fibre of `b`. See also `finset.sum_image`.\"]\nlemma prod_comp [decidable_eq γ] (f : γ → β) (g : α → γ) :\n  ∏ a in s, f (g a) = ∏ b in s.image g, f b ^ (s.filter (λ a, g a = b)).card  :=\ncalc ∏ a in s, f (g a)\n    = ∏ x in (s.image g).sigma (λ b : γ, s.filter (λ a, g a = b)), f (g x.2) :\n  prod_bij (λ a ha, ⟨g a, a⟩) (by simp; tauto) (λ _ _, rfl) (by simp) -- `(by finish)` closes this\n  (by { rintro ⟨b_fst, b_snd⟩ H,\n        simp only [mem_image, exists_prop, mem_filter, mem_sigma] at H,\n        tauto })\n... = ∏ b in s.image g, ∏ a in s.filter (λ a, g a = b), f (g a) : prod_sigma _ _ _\n... = ∏ b in s.image g, ∏ a in s.filter (λ a, g a = b), f b :\n  prod_congr rfl (λ b hb, prod_congr rfl (by simp {contextual := tt}))\n... = ∏ b in s.image g, f b ^ (s.filter (λ a, g a = b)).card :\n  prod_congr rfl (λ _ _, prod_const _)\n\n@[to_additive]\nlemma prod_piecewise [decidable_eq α] (s t : finset α) (f g : α → β) :\n  (∏ x in s, (t.piecewise f g) x) = (∏ x in s ∩ t, f x) * (∏ x in s \\ t, g x) :=\nby { rw [piecewise, prod_ite, filter_mem_eq_inter, ← sdiff_eq_filter], }\n\n@[to_additive]\nlemma prod_inter_mul_prod_diff [decidable_eq α] (s t : finset α) (f : α → β) :\n  (∏ x in s ∩ t, f x) * (∏ x in s \\ t, f x) = (∏ x in s, f x) :=\nby { convert (s.prod_piecewise t f f).symm, simp [finset.piecewise] }\n\n@[to_additive]\nlemma prod_eq_mul_prod_diff_singleton [decidable_eq α] {s : finset α} {i : α} (h : i ∈ s)\n  (f : α → β) : ∏ x in s, f x = f i * ∏ x in s \\ {i}, f x :=\nby { convert (s.prod_inter_mul_prod_diff {i} f).symm, simp [h] }\n\n@[to_additive]\nlemma prod_eq_prod_diff_singleton_mul [decidable_eq α] {s : finset α} {i : α} (h : i ∈ s)\n  (f : α → β) : ∏ x in s, f x = (∏ x in s \\ {i}, f x) * f i :=\nby { rw [prod_eq_mul_prod_diff_singleton h, mul_comm] }\n\n@[to_additive]\nlemma _root_.fintype.prod_eq_mul_prod_compl [decidable_eq α] [fintype α] (a : α) (f : α → β) :\n  ∏ i, f i = (f a) * ∏ i in {a}ᶜ, f i :=\nprod_eq_mul_prod_diff_singleton (mem_univ a) f\n\n@[to_additive]\nlemma _root_.fintype.prod_eq_prod_compl_mul [decidable_eq α] [fintype α] (a : α) (f : α → β) :\n  ∏ i, f i = (∏ i in {a}ᶜ, f i) * f a :=\nprod_eq_prod_diff_singleton_mul (mem_univ a) f\n\nlemma dvd_prod_of_mem (f : α → β) {a : α} {s : finset α} (ha : a ∈ s) :\n  f a ∣ ∏ i in s, f i :=\nbegin\n  classical,\n  rw finset.prod_eq_mul_prod_diff_singleton ha,\n  exact dvd_mul_right _ _,\nend\n\n/-- A product can be partitioned into a product of products, each equivalent under a setoid. -/\n@[to_additive \"A sum can be partitioned into a sum of sums, each equivalent under a setoid.\"]\nlemma prod_partition (R : setoid α) [decidable_rel R.r] :\n  (∏ x in s, f x) = ∏ xbar in s.image quotient.mk, ∏ y in s.filter (λ y, ⟦y⟧ = xbar), f y :=\nbegin\n  refine (finset.prod_image' f (λ x hx, _)).symm,\n  refl,\nend\n\n/-- If we can partition a product into subsets that cancel out, then the whole product cancels. -/\n@[to_additive \"If we can partition a sum into subsets that cancel out, then the whole sum cancels.\"]\nlemma prod_cancels_of_partition_cancels (R : setoid α) [decidable_rel R.r]\n  (h : ∀ x ∈ s, (∏ a in s.filter (λ y, y ≈ x), f a) = 1) : (∏ x in s, f x) = 1 :=\nbegin\n  rw [prod_partition R, ←finset.prod_eq_one],\n  intros xbar xbar_in_s,\n  obtain ⟨x, x_in_s, xbar_eq_x⟩ := mem_image.mp xbar_in_s,\n  rw [←xbar_eq_x, filter_congr (λ y _, @quotient.eq _ R y x)],\n  apply h x x_in_s,\nend\n\n@[to_additive]\nlemma prod_update_of_not_mem [decidable_eq α] {s : finset α} {i : α}\n  (h : i ∉ s) (f : α → β) (b : β) : (∏ x in s, function.update f i b x) = (∏ x in s, f x) :=\nbegin\n  apply prod_congr rfl (λ j hj, _),\n  have : j ≠ i, by { assume eq, rw eq at hj, exact h hj },\n  simp [this]\nend\n\n@[to_additive]\nlemma prod_update_of_mem [decidable_eq α] {s : finset α} {i : α} (h : i ∈ s) (f : α → β) (b : β) :\n  (∏ x in s, function.update f i b x) = b * (∏ x in s \\ (singleton i), f x) :=\nby { rw [update_eq_piecewise, prod_piecewise], simp [h] }\n\n/-- If a product of a `finset` of size at most 1 has a given value, so\ndo the terms in that product. -/\n@[to_additive eq_of_card_le_one_of_sum_eq \"If a sum of a `finset` of size at most 1 has a given\nvalue, so do the terms in that sum.\"]\nlemma eq_of_card_le_one_of_prod_eq {s : finset α} (hc : s.card ≤ 1) {f : α → β} {b : β}\n    (h : ∏ x in s, f x = b) : ∀ x ∈ s, f x = b :=\nbegin\n  intros x hx,\n  by_cases hc0 : s.card = 0,\n  { exact false.elim (card_ne_zero_of_mem hx hc0) },\n  { have h1 : s.card = 1 := le_antisymm hc (nat.one_le_of_lt (nat.pos_of_ne_zero hc0)),\n    rw card_eq_one at h1,\n    cases h1 with x2 hx2,\n    rw [hx2, mem_singleton] at hx,\n    simp_rw hx2 at h,\n    rw hx,\n    rw prod_singleton at h,\n    exact h }\nend\n\n/-- Taking a product over `s : finset α` is the same as multiplying the value on a single element\n`f a` by the product of `s.erase a`. -/\n@[to_additive \"Taking a sum over `s : finset α` is the same as adding the value on a single element\n`f a` to the sum over `s.erase a`.\"]\nlemma mul_prod_erase [decidable_eq α] (s : finset α) (f : α → β) {a : α} (h : a ∈ s) :\n  f a * (∏ x in s.erase a, f x) = ∏ x in s, f x :=\nby rw [← prod_insert (not_mem_erase a s), insert_erase h]\n\n/-- A variant of `finset.mul_prod_erase` with the multiplication swapped. -/\n@[to_additive \"A variant of `finset.add_sum_erase` with the addition swapped.\"]\nlemma prod_erase_mul [decidable_eq α] (s : finset α) (f : α → β) {a : α} (h : a ∈ s) :\n  (∏ x in s.erase a, f x) * f a = ∏ x in s, f x :=\nby rw [mul_comm, mul_prod_erase s f h]\n\n/-- If a function applied at a point is 1, a product is unchanged by\nremoving that point, if present, from a `finset`. -/\n@[to_additive \"If a function applied at a point is 0, a sum is unchanged by\nremoving that point, if present, from a `finset`.\"]\nlemma prod_erase [decidable_eq α] (s : finset α) {f : α → β} {a : α} (h : f a = 1) :\n  ∏ x in s.erase a, f x = ∏ x in s, f x :=\nbegin\n  rw ←sdiff_singleton_eq_erase,\n  refine prod_subset (sdiff_subset _ _) (λ x hx hnx, _),\n  rw sdiff_singleton_eq_erase at hnx,\n  rwa eq_of_mem_of_not_mem_erase hx hnx\nend\n\n/-- If a product is 1 and the function is 1 except possibly at one\npoint, it is 1 everywhere on the `finset`. -/\n@[to_additive \"If a sum is 0 and the function is 0 except possibly at one\npoint, it is 0 everywhere on the `finset`.\"]\nlemma eq_one_of_prod_eq_one {s : finset α} {f : α → β} {a : α} (hp : ∏ x in s, f x = 1)\n    (h1 : ∀ x ∈ s, x ≠ a → f x = 1) : ∀ x ∈ s, f x = 1 :=\nbegin\n  intros x hx,\n  classical,\n  by_cases h : x = a,\n  { rw h,\n    rw h at hx,\n    rw [←prod_subset (singleton_subset_iff.2 hx)\n                      (λ t ht ha, h1 t ht (not_mem_singleton.1 ha)),\n        prod_singleton] at hp,\n    exact hp },\n  { exact h1 x hx h }\nend\n\nlemma prod_pow_boole [decidable_eq α] (s : finset α) (f : α → β) (a : α) :\n  (∏ x in s, (f x)^(ite (a = x) 1 0)) = ite (a ∈ s) (f a) 1 :=\nby simp\n\nlemma prod_dvd_prod_of_dvd {S : finset α} (g1 g2 : α → β) (h : ∀ a ∈ S, g1 a ∣ g2 a) :\n  S.prod g1 ∣ S.prod g2 :=\nbegin\n  classical,\n  apply finset.induction_on' S, { simp },\n  intros a T haS _ haT IH,\n  repeat {rw finset.prod_insert haT},\n  exact mul_dvd_mul (h a haS) IH,\nend\n\nlemma prod_dvd_prod_of_subset {ι M : Type*} [comm_monoid M] (s t : finset ι) (f : ι → M)\n  (h : s ⊆ t) : ∏ i in s, f i ∣ ∏ i in t, f i :=\nmultiset.prod_dvd_prod_of_le $ multiset.map_le_map $ by simpa\n\nend comm_monoid\n\n/-- If `f = g = h` everywhere but at `i`, where `f i = g i + h i`, then the product of `f` over `s`\n  is the sum of the products of `g` and `h`. -/\nlemma prod_add_prod_eq [comm_semiring β] {s : finset α} {i : α} {f g h : α → β}\n  (hi : i ∈ s) (h1 : g i + h i = f i) (h2 : ∀ j ∈ s, j ≠ i → g j = f j)\n  (h3 : ∀ j ∈ s, j ≠ i → h j = f j) : ∏ i in s, g i + ∏ i in s, h i = ∏ i in s, f i :=\nby { classical, simp_rw [prod_eq_mul_prod_diff_singleton hi, ← h1, right_distrib],\n     congr' 2; apply prod_congr rfl; simpa }\n\nlemma card_eq_sum_ones (s : finset α) : s.card = ∑ _ in s, 1 :=\nby simp\n\nlemma sum_const_nat {m : ℕ} {f : α → ℕ} (h₁ : ∀ x ∈ s, f x = m) :\n  (∑ x in s, f x) = card s * m :=\nbegin\n  rw [← nat.nsmul_eq_mul, ← sum_const],\n  apply sum_congr rfl h₁\nend\n\n@[simp]\nlemma sum_boole {s : finset α} {p : α → Prop} [non_assoc_semiring β] {hp : decidable_pred p} :\n  (∑ x in s, if p x then (1 : β) else (0 : β)) = (s.filter p).card :=\nby simp [sum_ite]\n\nlemma eq_sum_range_sub [add_comm_group β] (f : ℕ → β) (n : ℕ) :\n  f n = f 0 + ∑ i in range n, (f (i+1) - f i) :=\nby rw [finset.sum_range_sub, add_sub_cancel'_right]\n\nlemma eq_sum_range_sub' [add_comm_group β] (f : ℕ → β) (n : ℕ) :\n  f n = ∑ i in range (n + 1), if i = 0 then f 0 else f i - f (i - 1) :=\nbegin\n  conv_lhs { rw [finset.eq_sum_range_sub f] },\n  simp [finset.sum_range_succ', add_comm]\nend\n\nlemma _root_.commute.sum_right [non_unital_non_assoc_semiring β] (s : finset α)\n  (f : α → β) (b : β) (h : ∀ i ∈ s, commute b (f i)) :\n  commute b (∑ i in s, f i) :=\ncommute.multiset_sum_right _ _ $ λ b hb, begin\n  obtain ⟨i, hi, rfl⟩ := multiset.mem_map.mp hb,\n  exact h _ hi\nend\n\nlemma _root_.commute.sum_left [non_unital_non_assoc_semiring β] (s : finset α)\n  (f : α → β) (b : β) (h : ∀ i ∈ s, commute (f i) b) :\n  commute (∑ i in s, f i) b :=\n(commute.sum_right _ _ _ $ λ i hi, (h _ hi).symm).symm\n\nsection opposite\n\nopen mul_opposite\n\n/-- Moving to the opposite additive commutative monoid commutes with summing. -/\n@[simp] lemma op_sum [add_comm_monoid β] {s : finset α} (f : α → β) :\n  op (∑ x in s, f x) = ∑ x in s, op (f x) :=\n(op_add_equiv : β ≃+ βᵐᵒᵖ).map_sum _ _\n\n@[simp] lemma unop_sum [add_comm_monoid β] {s : finset α} (f : α → βᵐᵒᵖ) :\n  unop (∑ x in s, f x) = ∑ x in s, unop (f x) :=\n(op_add_equiv : β ≃+ βᵐᵒᵖ).symm.map_sum _ _\n\nend opposite\n\nsection comm_group\nvariables [comm_group β]\n\n@[simp, to_additive]\nlemma prod_inv_distrib : (∏ x in s, (f x)⁻¹) = (∏ x in s, f x)⁻¹ := multiset.prod_map_inv'\n\n@[to_additive zsmul_sum]\nlemma prod_zpow (f : α → β) (s : finset α) (n : ℤ) :\n  (∏ a in s, f a) ^ n = ∏ a in s, (f a) ^ n :=\nmultiset.prod_map_zpow.symm\n\n@[to_additive]\nlemma prod_sdiff_div_prod_sdiff [decidable_eq α] :\n  (∏ (x : α) in s₂ \\ s₁, f x) / (∏ (x : α) in s₁ \\ s₂, f x)\n  = (∏ (x : α) in s₂, f x) / (∏ (x : α) in s₁, f x) :=\nby simp [← finset.prod_sdiff (@inf_le_left _ _ s₁ s₂),\n  ← finset.prod_sdiff (@inf_le_right _ _ s₁ s₂)]\n\nend comm_group\n\n@[simp] theorem card_sigma {σ : α → Type*} (s : finset α) (t : Π a, finset (σ a)) :\n  card (s.sigma t) = ∑ a in s, card (t a) :=\nmultiset.card_sigma _ _\n\nlemma card_bUnion [decidable_eq β] {s : finset α} {t : α → finset β}\n  (h : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → disjoint (t x) (t y)) :\n  (s.bUnion t).card = ∑ u in s, card (t u) :=\ncalc (s.bUnion t).card = ∑ i in s.bUnion t, 1 : by simp\n... = ∑ a in s, ∑ i in t a, 1 : finset.sum_bUnion h\n... = ∑ u in s, card (t u) : by simp\n\nlemma card_bUnion_le [decidable_eq β] {s : finset α} {t : α → finset β} :\n  (s.bUnion t).card ≤ ∑ a in s, (t a).card :=\nby haveI := classical.dec_eq α; exact\nfinset.induction_on s (by simp)\n  (λ a s has ih,\n    calc ((insert a s).bUnion t).card ≤ (t a).card + (s.bUnion t).card :\n    by rw bUnion_insert; exact finset.card_union_le _ _\n    ... ≤ ∑ a in insert a s, card (t a) :\n    by rw sum_insert has; exact add_le_add_left ih _)\n\ntheorem card_eq_sum_card_fiberwise [decidable_eq β] {f : α → β} {s : finset α} {t : finset β}\n  (H : ∀ x ∈ s, f x ∈ t) :\n  s.card = ∑ a in t, (s.filter (λ x, f x = a)).card :=\nby simp only [card_eq_sum_ones, sum_fiberwise_of_maps_to H]\n\ntheorem card_eq_sum_card_image [decidable_eq β] (f : α → β) (s : finset α) :\n  s.card = ∑ a in s.image f, (s.filter (λ x, f x = a)).card :=\ncard_eq_sum_card_fiberwise (λ _, mem_image_of_mem _)\n\n@[simp] lemma sum_sub_distrib [add_comm_group β] :\n  ∑ x in s, (f x - g x) = (∑ x in s, f x) - (∑ x in s, g x) :=\nby simpa only [sub_eq_add_neg] using sum_add_distrib.trans (congr_arg _ sum_neg_distrib)\n\nlemma mem_sum {f : α → multiset β} (s : finset α) (b : β) :\n  b ∈ ∑ x in s, f x ↔ ∃ a ∈ s, b ∈ f a :=\nbegin\n  classical,\n  refine s.induction_on (by simp) _,\n  { intros a t hi ih,\n    simp [sum_insert hi, ih, or_and_distrib_right, exists_or_distrib] }\nend\n\nsection prod_eq_zero\nvariables [comm_monoid_with_zero β]\n\nlemma prod_eq_zero (ha : a ∈ s) (h : f a = 0) : (∏ x in s, f x) = 0 :=\nby { haveI := classical.dec_eq α, rw [←prod_erase_mul _ _ ha, h, mul_zero] }\n\nlemma prod_boole {s : finset α} {p : α → Prop} [decidable_pred p] :\n  ∏ i in s, ite (p i) (1 : β) (0 : β) = ite (∀ i ∈ s, p i) 1 0 :=\nbegin\n  split_ifs,\n  { apply prod_eq_one,\n    intros i hi,\n    rw if_pos (h i hi) },\n  { push_neg at h,\n    rcases h with ⟨i, hi, hq⟩,\n    apply prod_eq_zero hi,\n    rw [if_neg hq] },\nend\n\nvariables [nontrivial β] [no_zero_divisors β]\n\nlemma prod_eq_zero_iff : (∏ x in s, f x) = 0 ↔ (∃ a ∈ s, f a = 0) :=\nbegin\n  classical,\n  apply finset.induction_on s,\n  exact ⟨not.elim one_ne_zero, λ ⟨_, H, _⟩, H.elim⟩,\n  assume a s ha ih,\n  rw [prod_insert ha, mul_eq_zero, bex_def, exists_mem_insert, ih, ← bex_def]\nend\n\ntheorem prod_ne_zero_iff : (∏ x in s, f x) ≠ 0 ↔ (∀ a ∈ s, f a ≠ 0) :=\nby { rw [ne, prod_eq_zero_iff], push_neg }\n\nend prod_eq_zero\n\nsection comm_group_with_zero\nvariables [comm_group_with_zero β]\n\n@[simp]\nlemma prod_inv_distrib' : (∏ x in s, (f x)⁻¹) = (∏ x in s, f x)⁻¹ :=\nbegin\n  classical,\n  by_cases h : ∃ x ∈ s, f x = 0,\n  { simpa [prod_eq_zero_iff.mpr h, prod_eq_zero_iff] using h },\n  { push_neg at h,\n    have h' := prod_ne_zero_iff.mpr h,\n    have hf : ∀ x ∈ s, (f x)⁻¹ * f x = 1 := λ x hx, inv_mul_cancel (h x hx),\n    apply mul_right_cancel₀ h',\n    simp [h, h', ← finset.prod_mul_distrib, prod_congr rfl hf] }\nend\n\nend comm_group_with_zero\n\n@[to_additive]\nlemma prod_unique_nonempty {α β : Type*} [comm_monoid β] [unique α]\n  (s : finset α) (f : α → β) (h : s.nonempty) :\n  (∏ x in s, f x) = f default :=\nbegin\n  obtain ⟨a, ha⟩ := h,\n  have : s = {a},\n  { ext b,\n    simpa [subsingleton.elim a b] using ha },\n  rw [this, finset.prod_singleton, subsingleton.elim a default]\nend\n\nend finset\n\nnamespace fintype\n\nopen finset\n\n/-- `fintype.prod_bijective` is a variant of `finset.prod_bij` that accepts `function.bijective`.\n\nSee `function.bijective.prod_comp` for a version without `h`. -/\n@[to_additive \"`fintype.sum_equiv` is a variant of `finset.sum_bij` that accepts\n`function.bijective`.\n\nSee `function.bijective.sum_comp` for a version without `h`. \"]\nlemma prod_bijective {α β M : Type*} [fintype α] [fintype β] [comm_monoid M]\n  (e : α → β) (he : function.bijective e) (f : α → M) (g : β → M) (h : ∀ x, f x = g (e x)) :\n  ∏ x : α, f x = ∏ x : β, g x :=\nprod_bij\n  (λ x _, e x)\n  (λ x _, mem_univ (e x))\n  (λ x _, h x)\n  (λ x x' _ _ h, he.injective h)\n  (λ y _, (he.surjective y).imp $ λ a h, ⟨mem_univ _, h.symm⟩)\n\n/-- `fintype.prod_equiv` is a specialization of `finset.prod_bij` that\nautomatically fills in most arguments.\n\nSee `equiv.prod_comp` for a version without `h`.\n-/\n@[to_additive \"`fintype.sum_equiv` is a specialization of `finset.sum_bij` that\nautomatically fills in most arguments.\n\nSee `equiv.sum_comp` for a version without `h`.\n\"]\nlemma prod_equiv {α β M : Type*} [fintype α] [fintype β] [comm_monoid M]\n  (e : α ≃ β) (f : α → M) (g : β → M) (h : ∀ x, f x = g (e x)) :\n  ∏ x : α, f x = ∏ x : β, g x :=\nprod_bijective e e.bijective f g h\n\n@[to_additive]\nlemma prod_finset_coe [comm_monoid β] :\n  ∏ (i : (s : set α)), f i = ∏ i in s, f i :=\n(finset.prod_subtype s (λ _, iff.rfl) f).symm\n\n@[to_additive]\nlemma prod_unique {α β : Type*} [comm_monoid β] [unique α] (f : α → β) :\n  (∏ x : α, f x) = f default :=\nby rw [univ_unique, prod_singleton]\n\n@[to_additive] lemma prod_empty {α β : Type*} [comm_monoid β] [is_empty α] (f : α → β) :\n  (∏ x : α, f x) = 1 :=\nby rw [eq_empty_of_is_empty (univ : finset α), finset.prod_empty]\n\n@[to_additive]\nlemma prod_subsingleton {α β : Type*} [comm_monoid β] [subsingleton α] (f : α → β) (a : α) :\n  (∏ x : α, f x) = f a :=\nbegin\n  haveI : unique α := unique_of_subsingleton a,\n  convert prod_unique f\nend\n\n@[to_additive]\nlemma prod_subtype_mul_prod_subtype {α β : Type*} [fintype α] [comm_monoid β]\n  (p : α → Prop) (f : α → β) [decidable_pred p] :\n  (∏ (i : {x // p x}), f i) * (∏ i : {x // ¬ p x}, f i) = ∏ i, f i :=\nbegin\n  classical,\n  let s := {x | p x}.to_finset,\n  rw [← finset.prod_subtype s, ← finset.prod_subtype sᶜ],\n  { exact finset.prod_mul_prod_compl _ _ },\n  { simp },\n  { simp }\nend\n\nend fintype\n\nnamespace list\n\n@[to_additive] lemma prod_to_finset {M : Type*} [decidable_eq α] [comm_monoid M]\n  (f : α → M) : ∀ {l : list α} (hl : l.nodup), l.to_finset.prod f = (l.map f).prod\n| [] _ := by simp\n| (a :: l) hl := let ⟨not_mem, hl⟩ := list.nodup_cons.mp hl in\n  by simp [finset.prod_insert (mt list.mem_to_finset.mp not_mem), prod_to_finset hl]\n\nend list\n\nnamespace multiset\n\nvariables [decidable_eq α]\n\n@[simp] lemma to_finset_sum_count_eq (s : multiset α) :\n  (∑ a in s.to_finset, s.count a) = s.card :=\nmultiset.induction_on s rfl\n  (assume a s ih,\n    calc (∑ x in to_finset (a ::ₘ s), count x (a ::ₘ s)) =\n      ∑ x in to_finset (a ::ₘ s), ((if x = a then 1 else 0) + count x s) :\n        finset.sum_congr rfl $ λ _ _, by split_ifs;\n        [simp only [h, count_cons_self, nat.one_add], simp only [count_cons_of_ne h, zero_add]]\n      ... = card (a ::ₘ s) :\n      begin\n        by_cases a ∈ s.to_finset,\n        { have : ∑ x in s.to_finset, ite (x = a) 1 0 = ∑ x in {a}, ite (x = a) 1 0,\n          { rw [finset.sum_ite_eq', if_pos h, finset.sum_singleton, if_pos rfl], },\n          rw [to_finset_cons, finset.insert_eq_of_mem h, finset.sum_add_distrib, ih, this,\n            finset.sum_singleton, if_pos rfl, add_comm, card_cons] },\n        { have ha : a ∉ s, by rwa mem_to_finset at h,\n          have : ∑ x in to_finset s, ite (x = a) 1 0 = ∑ x in to_finset s, 0, from\n            finset.sum_congr rfl (λ x hx, if_neg $ by rintro rfl; cc),\n          rw [to_finset_cons, finset.sum_insert h, if_pos rfl, finset.sum_add_distrib, this,\n            finset.sum_const_zero, ih, count_eq_zero_of_not_mem ha, zero_add, add_comm, card_cons] }\n      end)\n\nlemma count_sum' {s : finset β} {a : α} {f : β → multiset α} :\n  count a (∑ x in s, f x) = ∑ x in s, count a (f x) :=\nby { dunfold finset.sum, rw count_sum }\n\n@[simp] lemma to_finset_sum_count_nsmul_eq (s : multiset α) :\n  (∑ a in s.to_finset, s.count a • {a}) = s :=\nbegin\n  apply ext', intro b,\n  rw count_sum',\n  have h : count b s = count b (count b s • {b}),\n  { rw [count_nsmul, count_singleton_self, mul_one] },\n  rw h, clear h,\n  apply finset.sum_eq_single b,\n  { intros c h hcb, rw count_nsmul, convert mul_zero (count c s),\n    apply count_eq_zero.mpr, exact finset.not_mem_singleton.mpr (ne.symm hcb) },\n  { intro hb, rw [count_eq_zero_of_not_mem (mt mem_to_finset.2 hb), count_nsmul, zero_mul]}\nend\n\ntheorem exists_smul_of_dvd_count (s : multiset α) {k : ℕ}\n  (h : ∀ (a : α), a ∈ s → k ∣ multiset.count a s) :\n  ∃ (u : multiset α), s = k • u :=\nbegin\n  use ∑ a in s.to_finset, (s.count a / k) • {a},\n  have h₂ : ∑ (x : α) in s.to_finset, k • (count x s / k) • ({x} : multiset α) =\n    ∑ (x : α) in s.to_finset, count x s • {x},\n  { apply finset.sum_congr rfl,\n    intros x hx,\n    rw [← mul_nsmul, nat.mul_div_cancel' (h x (mem_to_finset.mp hx))] },\n  rw [← finset.sum_nsmul, h₂, to_finset_sum_count_nsmul_eq]\nend\n\nlemma to_finset_prod_dvd_prod [comm_monoid α] (S : multiset α) : S.to_finset.prod id ∣ S.prod :=\nbegin\n  rw finset.prod_eq_multiset_prod,\n  refine multiset.prod_dvd_prod_of_le _,\n  simp [multiset.dedup_le S],\nend\n\n@[to_additive]\nlemma prod_sum {α : Type*} {ι : Type*} [comm_monoid α] (f : ι → multiset α) (s : finset ι) :\n  (∑ x in s, f x).prod = ∏ x in s, (f x).prod :=\nbegin\n  classical,\n  induction s using finset.induction_on with a t hat ih,\n  { rw [finset.sum_empty, finset.prod_empty, multiset.prod_zero] },\n  { rw [finset.sum_insert hat, finset.prod_insert hat, multiset.prod_add, ih] }\nend\n\nend multiset\n\n@[simp, norm_cast] lemma nat.cast_sum [add_comm_monoid β] [has_one β] (s : finset α) (f : α → ℕ) :\n  ↑(∑ x in s, f x : ℕ) = (∑ x in s, (f x : β)) :=\n(nat.cast_add_monoid_hom β).map_sum f s\n\n@[simp, norm_cast] lemma int.cast_sum [add_comm_group β] [has_one β] (s : finset α) (f : α → ℤ) :\n  ↑(∑ x in s, f x : ℤ) = (∑ x in s, (f x : β)) :=\n(int.cast_add_hom β).map_sum f s\n\n@[simp, norm_cast] lemma nat.cast_prod {R : Type*} [comm_semiring R] (f : α → ℕ) (s : finset α) :\n  (↑∏ i in s, f i : R) = ∏ i in s, f i :=\n(nat.cast_ring_hom R).map_prod _ _\n\n@[simp, norm_cast] lemma int.cast_prod {R : Type*} [comm_ring R] (f : α → ℤ) (s : finset α) :\n  (↑∏ i in s, f i : R) = ∏ i in s, f i :=\n(int.cast_ring_hom R).map_prod _ _\n\n@[simp, norm_cast] lemma units.coe_prod {M : Type*} [comm_monoid M] (f : α → Mˣ)\n  (s : finset α) : (↑∏ i in s, f i : M) = ∏ i in s, f i :=\n(units.coe_hom M).map_prod _ _\n\nlemma nat_abs_sum_le {ι : Type*} (s : finset ι) (f : ι → ℤ) :\n  (∑ i in s, f i).nat_abs ≤ ∑ i in s, (f i).nat_abs :=\nbegin\n  classical,\n  apply finset.induction_on s,\n  { simp only [finset.sum_empty, int.nat_abs_zero] },\n  { intros i s his IH,\n    simp only [his, finset.sum_insert, not_false_iff],\n    exact (int.nat_abs_add_le _ _).trans (add_le_add le_rfl IH) }\nend\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/big_operators/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4735984338537276}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.pempty\nimport category_theory.limits.has_limits\nimport category_theory.epi_mono\nimport category_theory.category.preorder\n\n/-!\n# Initial and terminal objects in a category.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n## References\n* [Stacks: Initial and final objects](https://stacks.math.columbia.edu/tag/002B)\n-/\n\nnoncomputable theory\n\nuniverses w w' v v₁ v₂ u u₁ u₂\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables {C : Type u₁} [category.{v₁} C]\n\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- Construct a cone for the empty diagram given an object. -/\n@[simps] def as_empty_cone (X : C) : cone (functor.empty.{0} C) := { X := X, π := by tidy }\n/-- Construct a cocone for the empty diagram given an object. -/\n@[simps] def as_empty_cocone (X : C) : cocone (functor.empty.{0} C) := { X := X, ι := by tidy }\n\n/-- `X` is terminal if the cone it induces on the empty diagram is limiting. -/\nabbreviation is_terminal (X : C) := is_limit (as_empty_cone X)\n/-- `X` is initial if the cocone it induces on the empty diagram is colimiting. -/\nabbreviation is_initial (X : C) := is_colimit (as_empty_cocone X)\n\n/-- An object `Y` is terminal iff for every `X` there is a unique morphism `X ⟶ Y`. -/\ndef is_terminal_equiv_unique (F : discrete.{0} pempty.{1} ⥤ C) (Y : C) :\n  is_limit (⟨Y, by tidy⟩ : cone F) ≃ ∀ X : C, unique (X ⟶ Y) :=\n{ to_fun := λ t X, { default := t.lift ⟨X, by tidy⟩,\n    uniq := λ f, t.uniq ⟨X, by tidy⟩ f (by tidy) },\n  inv_fun := λ u, { lift := λ s, (u s.X).default, uniq' := λ s _ _, (u s.X).2 _ },\n  left_inv := by tidy,\n  right_inv := by tidy }\n\n/-- An object `Y` is terminal if for every `X` there is a unique morphism `X ⟶ Y`\n    (as an instance). -/\ndef is_terminal.of_unique (Y : C) [h : Π X : C, unique (X ⟶ Y)] : is_terminal Y :=\n{ lift := λ s, (h s.X).default }\n\n/-- If `α` is a preorder with top, then `⊤` is a terminal object. -/\ndef is_terminal_top {α : Type*} [preorder α] [order_top α] : is_terminal (⊤ : α) :=\nis_terminal.of_unique _\n\n/-- Transport a term of type `is_terminal` across an isomorphism. -/\ndef is_terminal.of_iso {Y Z : C} (hY : is_terminal Y) (i : Y ≅ Z) : is_terminal Z :=\nis_limit.of_iso_limit hY\n{ hom := { hom := i.hom },\n  inv := { hom := i.inv } }\n\n/-- An object `X` is initial iff for every `Y` there is a unique morphism `X ⟶ Y`. -/\ndef is_initial_equiv_unique (F : discrete.{0} pempty.{1} ⥤ C) (X : C) :\n  is_colimit (⟨X, by tidy⟩ : cocone F) ≃ ∀ Y : C, unique (X ⟶ Y) :=\n{ to_fun := λ t X, { default := t.desc ⟨X, by tidy⟩,\n    uniq := λ f, t.uniq ⟨X, by tidy⟩ f (by tidy) },\n  inv_fun := λ u, { desc := λ s, (u s.X).default, uniq' := λ s _ _, (u s.X).2 _ },\n  left_inv := by tidy,\n  right_inv := by tidy }\n\n/-- An object `X` is initial if for every `Y` there is a unique morphism `X ⟶ Y`\n    (as an instance). -/\ndef is_initial.of_unique (X : C) [h : Π Y : C, unique (X ⟶ Y)] : is_initial X :=\n{ desc := λ s, (h s.X).default }\n\n/-- If `α` is a preorder with bot, then `⊥` is an initial object. -/\ndef is_initial_bot {α : Type*} [preorder α] [order_bot α] : is_initial (⊥ : α) :=\nis_initial.of_unique _\n\n/-- Transport a term of type `is_initial` across an isomorphism. -/\ndef is_initial.of_iso {X Y : C} (hX : is_initial X) (i : X ≅ Y) : is_initial Y :=\nis_colimit.of_iso_colimit hX\n{ hom := { hom := i.hom },\n  inv := { hom := i.inv } }\n\n/-- Give the morphism to a terminal object from any other. -/\ndef is_terminal.from {X : C} (t : is_terminal X) (Y : C) : Y ⟶ X :=\nt.lift (as_empty_cone Y)\n\n/-- Any two morphisms to a terminal object are equal. -/\nlemma is_terminal.hom_ext {X Y : C} (t : is_terminal X) (f g : Y ⟶ X) : f = g :=\nt.hom_ext (by tidy)\n\n@[simp] lemma is_terminal.comp_from {Z : C} (t : is_terminal Z) {X Y : C} (f : X ⟶ Y) :\n  f ≫ t.from Y = t.from X :=\nt.hom_ext _ _\n\n@[simp] lemma is_terminal.from_self {X : C} (t : is_terminal X) : t.from X = 𝟙 X :=\nt.hom_ext _ _\n\n/-- Give the morphism from an initial object to any other. -/\ndef is_initial.to {X : C} (t : is_initial X) (Y : C) : X ⟶ Y :=\nt.desc (as_empty_cocone Y)\n\n/-- Any two morphisms from an initial object are equal. -/\nlemma is_initial.hom_ext {X Y : C} (t : is_initial X) (f g : X ⟶ Y) : f = g :=\nt.hom_ext (by tidy)\n\n@[simp] lemma is_initial.to_comp {X : C} (t : is_initial X) {Y Z : C} (f : Y ⟶ Z) :\n  t.to Y ≫ f = t.to Z :=\nt.hom_ext _ _\n\n@[simp] lemma is_initial.to_self {X : C} (t : is_initial X) : t.to X = 𝟙 X :=\nt.hom_ext _ _\n\n/-- Any morphism from a terminal object is split mono. -/\nlemma is_terminal.is_split_mono_from {X Y : C} (t : is_terminal X) (f : X ⟶ Y) :\n  is_split_mono f := is_split_mono.mk' ⟨t.from _, t.hom_ext _ _⟩\n\n/-- Any morphism to an initial object is split epi. -/\nlemma is_initial.is_split_epi_to {X Y : C} (t : is_initial X) (f : Y ⟶ X) :\n  is_split_epi f := is_split_epi.mk' ⟨t.to _, t.hom_ext _ _⟩\n\n/-- Any morphism from a terminal object is mono. -/\nlemma is_terminal.mono_from {X Y : C} (t : is_terminal X) (f : X ⟶ Y) : mono f :=\nby haveI := t.is_split_mono_from f; apply_instance\n\n/-- Any morphism to an initial object is epi. -/\nlemma is_initial.epi_to {X Y : C} (t : is_initial X) (f : Y ⟶ X) : epi f :=\nby haveI := t.is_split_epi_to f; apply_instance\n\n/-- If `T` and `T'` are terminal, they are isomorphic. -/\n@[simps]\ndef is_terminal.unique_up_to_iso {T T' : C} (hT : is_terminal T) (hT' : is_terminal T') : T ≅ T' :=\n{ hom := hT'.from _,\n  inv := hT.from _ }\n\n/-- If `I` and `I'` are initial, they are isomorphic. -/\n@[simps]\ndef is_initial.unique_up_to_iso {I I' : C} (hI : is_initial I) (hI' : is_initial I') : I ≅ I' :=\n{ hom := hI.to _,\n  inv := hI'.to _ }\n\nvariable (C)\n\n/--\nA category has a terminal object if it has a limit over the empty diagram.\nUse `has_terminal_of_unique` to construct instances.\n-/\nabbreviation has_terminal := has_limits_of_shape (discrete.{0} pempty) C\n/--\nA category has an initial object if it has a colimit over the empty diagram.\nUse `has_initial_of_unique` to construct instances.\n-/\nabbreviation has_initial := has_colimits_of_shape (discrete.{0} pempty) C\n\nsection univ\n\nvariables (X : C) {F₁ : discrete.{w} pempty ⥤ C} {F₂ : discrete.{w'} pempty ⥤ C}\n\n/-- Being terminal is independent of the empty diagram, its universe, and the cone over it,\n    as long as the cone points are isomorphic. -/\ndef is_limit_change_empty_cone {c₁ : cone F₁} (hl : is_limit c₁)\n  (c₂ : cone F₂) (hi : c₁.X ≅ c₂.X) : is_limit c₂ :=\n{ lift := λ c, hl.lift ⟨c.X, by tidy⟩ ≫ hi.hom,\n  fac' := λ _ j, j.as.elim,\n  uniq' := λ c f _, by { erw ← hl.uniq ⟨c.X, by tidy⟩ (f ≫ hi.inv) (λ j, j.as.elim), simp } }\n\n/-- Replacing an empty cone in `is_limit` by another with the same cone point\n    is an equivalence. -/\ndef is_limit_empty_cone_equiv (c₁ : cone F₁) (c₂ : cone F₂) (h : c₁.X ≅ c₂.X) :\n  is_limit c₁ ≃ is_limit c₂ :=\n{ to_fun := λ hl, is_limit_change_empty_cone C hl c₂ h,\n  inv_fun := λ hl, is_limit_change_empty_cone C hl c₁ h.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\nlemma has_terminal_change_diagram (h : has_limit F₁) : has_limit F₂ :=\n⟨⟨⟨⟨limit F₁, by tidy⟩, is_limit_change_empty_cone C (limit.is_limit F₁) _ (eq_to_iso rfl)⟩⟩⟩\n\nlemma has_terminal_change_universe [h : has_limits_of_shape (discrete.{w} pempty) C] :\n  has_limits_of_shape (discrete.{w'} pempty) C :=\n{ has_limit := λ J, has_terminal_change_diagram C (let f := h.1 in f (functor.empty C)) }\n\n/-- Being initial is independent of the empty diagram, its universe, and the cocone over it,\n    as long as the cocone points are isomorphic. -/\ndef is_colimit_change_empty_cocone {c₁ : cocone F₁} (hl : is_colimit c₁)\n  (c₂ : cocone F₂) (hi : c₁.X ≅ c₂.X) : is_colimit c₂ :=\n{ desc := λ c, hi.inv ≫ hl.desc ⟨c.X, by tidy⟩,\n  fac' := λ _ j, j.as.elim,\n  uniq' := λ c f _, by { erw ← hl.uniq ⟨c.X, by tidy⟩ (hi.hom ≫ f) (λ j, j.as.elim), simp } }\n\n/-- Replacing an empty cocone in `is_colimit` by another with the same cocone point\n    is an equivalence. -/\ndef is_colimit_empty_cocone_equiv (c₁ : cocone F₁) (c₂ : cocone F₂) (h : c₁.X ≅ c₂.X) :\n  is_colimit c₁ ≃ is_colimit c₂ :=\n{ to_fun := λ hl, is_colimit_change_empty_cocone C hl c₂ h,\n  inv_fun := λ hl, is_colimit_change_empty_cocone C hl c₁ h.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\nlemma has_initial_change_diagram (h : has_colimit F₁) : has_colimit F₂ :=\n⟨⟨⟨⟨colimit F₁, by tidy⟩,\n   is_colimit_change_empty_cocone C (colimit.is_colimit F₁) _ (eq_to_iso rfl)⟩⟩⟩\n\n\n\nend univ\n\n/--\nAn arbitrary choice of terminal object, if one exists.\nYou can use the notation `⊤_ C`.\nThis object is characterized by having a unique morphism from any object.\n-/\nabbreviation terminal [has_terminal C] : C := limit (functor.empty.{0} C)\n/--\nAn arbitrary choice of initial object, if one exists.\nYou can use the notation `⊥_ C`.\nThis object is characterized by having a unique morphism to any object.\n-/\nabbreviation initial [has_initial C] : C := colimit (functor.empty.{0} C)\n\nnotation `⊤_ ` C:20 := terminal C\nnotation `⊥_ ` C:20 := initial C\n\nsection\nvariables {C}\n\n/-- We can more explicitly show that a category has a terminal object by specifying the object,\nand showing there is a unique morphism to it from any other object. -/\nlemma has_terminal_of_unique (X : C) [h : Π Y : C, unique (Y ⟶ X)] : has_terminal C :=\n{ has_limit := λ F, has_limit.mk ⟨_, (is_terminal_equiv_unique F X).inv_fun h⟩ }\n\nlemma is_terminal.has_terminal {X : C} (h : is_terminal X) : has_terminal C :=\n{ has_limit := λ F, has_limit.mk ⟨⟨X, by tidy⟩, is_limit_change_empty_cone _ h _ (iso.refl _)⟩ }\n\n/-- We can more explicitly show that a category has an initial object by specifying the object,\nand showing there is a unique morphism from it to any other object. -/\nlemma has_initial_of_unique (X : C) [h : Π Y : C, unique (X ⟶ Y)] : has_initial C :=\n{ has_colimit := λ F, has_colimit.mk ⟨_, (is_initial_equiv_unique F X).inv_fun h⟩ }\n\nlemma is_initial.has_initial {X : C} (h : is_initial X) : has_initial C :=\n{ has_colimit := λ F, has_colimit.mk\n    ⟨⟨X, by tidy⟩, is_colimit_change_empty_cocone _ h _ (iso.refl _)⟩ }\n\n/-- The map from an object to the terminal object. -/\nabbreviation terminal.from [has_terminal C] (P : C) : P ⟶ ⊤_ C :=\nlimit.lift (functor.empty C) (as_empty_cone P)\n/-- The map to an object from the initial object. -/\nabbreviation initial.to [has_initial C] (P : C) : ⊥_ C ⟶ P :=\ncolimit.desc (functor.empty C) (as_empty_cocone P)\n\n/-- A terminal object is terminal. -/\ndef terminal_is_terminal [has_terminal C] : is_terminal (⊤_ C) :=\n{ lift := λ s, terminal.from _ }\n\n/-- An initial object is initial. -/\ndef initial_is_initial [has_initial C] : is_initial (⊥_ C) :=\n{ desc := λ s, initial.to _ }\n\ninstance unique_to_terminal [has_terminal C] (P : C) : unique (P ⟶ ⊤_ C) :=\nis_terminal_equiv_unique _ (⊤_ C) terminal_is_terminal P\n\ninstance unique_from_initial [has_initial C] (P : C) : unique (⊥_ C ⟶ P) :=\nis_initial_equiv_unique _ (⊥_ C) initial_is_initial P\n\n@[simp] lemma terminal.comp_from [has_terminal C] {P Q : C} (f : P ⟶ Q) :\n  f ≫ terminal.from Q = terminal.from P :=\nby tidy\n@[simp] lemma initial.to_comp [has_initial C] {P Q : C} (f : P ⟶ Q) :\n  initial.to P ≫ f = initial.to Q :=\nby tidy\n\n/-- The (unique) isomorphism between the chosen initial object and any other initial object. -/\n@[simp] def initial_iso_is_initial [has_initial C] {P : C} (t : is_initial P) : ⊥_ C ≅ P :=\ninitial_is_initial.unique_up_to_iso t\n\n/-- The (unique) isomorphism between the chosen terminal object and any other terminal object. -/\n@[simp] def terminal_iso_is_terminal [has_terminal C] {P : C}  (t : is_terminal P) : ⊤_ C ≅ P :=\nterminal_is_terminal.unique_up_to_iso t\n\n/-- Any morphism from a terminal object is split mono. -/\ninstance terminal.is_split_mono_from {Y : C} [has_terminal C] (f : ⊤_ C ⟶ Y) : is_split_mono f :=\nis_terminal.is_split_mono_from terminal_is_terminal _\n\n/-- Any morphism to an initial object is split epi. -/\ninstance initial.is_split_epi_to {Y : C} [has_initial C] (f : Y ⟶ ⊥_ C) : is_split_epi f :=\nis_initial.is_split_epi_to initial_is_initial _\n\n/-- An initial object is terminal in the opposite category. -/\ndef terminal_op_of_initial {X : C} (t : is_initial X) : is_terminal (opposite.op X) :=\n{ lift := λ s, (t.to s.X.unop).op,\n  uniq' := λ s m w, quiver.hom.unop_inj (t.hom_ext _ _) }\n\n/-- An initial object in the opposite category is terminal in the original category. -/\ndef terminal_unop_of_initial {X : Cᵒᵖ} (t : is_initial X) : is_terminal X.unop :=\n{ lift := λ s, (t.to (opposite.op s.X)).unop,\n  uniq' := λ s m w, quiver.hom.op_inj (t.hom_ext _ _) }\n\n/-- A terminal object is initial in the opposite category. -/\ndef initial_op_of_terminal {X : C} (t : is_terminal X) : is_initial (opposite.op X) :=\n{ desc := λ s, (t.from s.X.unop).op,\n  uniq' := λ s m w, quiver.hom.unop_inj (t.hom_ext _ _) }\n\n/-- A terminal object in the opposite category is initial in the original category. -/\ndef initial_unop_of_terminal {X : Cᵒᵖ} (t : is_terminal X) : is_initial X.unop :=\n{ desc := λ s, (t.from (opposite.op s.X)).unop,\n  uniq' := λ s m w, quiver.hom.op_inj (t.hom_ext _ _) }\n\ninstance has_initial_op_of_has_terminal [has_terminal C] : has_initial Cᵒᵖ :=\n(initial_op_of_terminal terminal_is_terminal).has_initial\n\ninstance has_terminal_op_of_has_initial [has_initial C] : has_terminal Cᵒᵖ :=\n(terminal_op_of_initial initial_is_initial).has_terminal\n\nlemma has_terminal_of_has_initial_op [has_initial Cᵒᵖ] : has_terminal C :=\n(terminal_unop_of_initial initial_is_initial).has_terminal\n\nlemma has_initial_of_has_terminal_op [has_terminal Cᵒᵖ] : has_initial C :=\n(initial_unop_of_terminal terminal_is_terminal).has_initial\n\ninstance {J : Type*} [category J] {C : Type*} [category C] [has_terminal C] :\n  has_limit ((category_theory.functor.const J).obj (⊤_ C)) :=\nhas_limit.mk\n{ cone :=\n  { X := ⊤_ C,\n    π := { app := λ _, terminal.from _, }, },\n  is_limit :=\n  { lift := λ s, terminal.from _, }, }\n\n/-- The limit of the constant `⊤_ C` functor is `⊤_ C`. -/\n@[simps hom]\ndef limit_const_terminal {J : Type*} [category J] {C : Type*} [category C] [has_terminal C] :\n  limit ((category_theory.functor.const J).obj (⊤_ C)) ≅ ⊤_ C :=\n{ hom := terminal.from _,\n  inv := limit.lift ((category_theory.functor.const J).obj (⊤_ C))\n    { X := ⊤_ C, π := { app := λ j, terminal.from _, }}, }\n\n@[simp, reassoc] lemma limit_const_terminal_inv_π\n  {J : Type*} [category J] {C : Type*} [category C] [has_terminal C] {j : J} :\n  limit_const_terminal.inv ≫ limit.π ((category_theory.functor.const J).obj (⊤_ C)) j =\n    terminal.from _ :=\nby ext ⟨⟨⟩⟩\n\ninstance {J : Type*} [category J] {C : Type*} [category C] [has_initial C] :\n  has_colimit ((category_theory.functor.const J).obj (⊥_ C)) :=\nhas_colimit.mk\n{ cocone :=\n  { X := ⊥_ C,\n    ι := { app := λ _, initial.to _, }, },\n  is_colimit :=\n  { desc := λ s, initial.to _, }, }\n\n/-- The colimit of the constant `⊥_ C` functor is `⊥_ C`. -/\n@[simps inv]\ndef colimit_const_initial {J : Type*} [category J] {C : Type*} [category C] [has_initial C] :\n  colimit ((category_theory.functor.const J).obj (⊥_ C)) ≅ ⊥_ C :=\n{ hom := colimit.desc ((category_theory.functor.const J).obj (⊥_ C))\n    { X := ⊥_ C, ι := { app := λ j, initial.to _, }, },\n  inv := initial.to _, }\n\n@[simp, reassoc] lemma ι_colimit_const_initial_hom\n  {J : Type*} [category J] {C : Type*} [category C] [has_initial C] {j : J} :\n  colimit.ι ((category_theory.functor.const J).obj (⊥_ C)) j ≫ colimit_const_initial.hom =\n    initial.to _ :=\nby ext ⟨⟨⟩⟩\n\n/-- A category is a `initial_mono_class` if the canonical morphism of an initial object is a\nmonomorphism.  In practice, this is most useful when given an arbitrary morphism out of the chosen\ninitial object, see `initial.mono_from`.\nGiven a terminal object, this is equivalent to the assumption that the unique morphism from initial\nto terminal is a monomorphism, which is the second of Freyd's axioms for an AT category.\n\nTODO: This is a condition satisfied by categories with zero objects and morphisms.\n-/\nclass initial_mono_class (C : Type u₁) [category.{v₁} C] : Prop :=\n(is_initial_mono_from : ∀ {I} (X : C) (hI : is_initial I), mono (hI.to X))\n\nlemma is_initial.mono_from [initial_mono_class C] {I} {X : C} (hI : is_initial I) (f : I ⟶ X) :\n  mono f :=\nbegin\n  rw hI.hom_ext f (hI.to X),\n  apply initial_mono_class.is_initial_mono_from,\nend\n\n@[priority 100]\ninstance initial.mono_from [has_initial C] [initial_mono_class C] (X : C) (f : ⊥_ C ⟶ X) :\n  mono f :=\ninitial_is_initial.mono_from f\n\n/-- To show a category is a `initial_mono_class` it suffices to give an initial object such that\nevery morphism out of it is a monomorphism. -/\nlemma initial_mono_class.of_is_initial {I : C} (hI : is_initial I) (h : ∀ X, mono (hI.to X)) :\n  initial_mono_class C :=\n{ is_initial_mono_from := λ I' X hI',\n  begin\n    rw hI'.hom_ext (hI'.to X) ((hI'.unique_up_to_iso hI).hom ≫ hI.to X),\n    apply mono_comp,\n  end }\n\n/-- To show a category is a `initial_mono_class` it suffices to show every morphism out of the\ninitial object is a monomorphism. -/\nlemma initial_mono_class.of_initial [has_initial C] (h : ∀ X : C, mono (initial.to X)) :\n  initial_mono_class C :=\ninitial_mono_class.of_is_initial initial_is_initial h\n\n/-- To show a category is a `initial_mono_class` it suffices to show the unique morphism from an\ninitial object to a terminal object is a monomorphism. -/\nlemma initial_mono_class.of_is_terminal {I T : C} (hI : is_initial I) (hT : is_terminal T)\n  (f : mono (hI.to T)) :\n  initial_mono_class C :=\ninitial_mono_class.of_is_initial hI (λ X, mono_of_mono_fac (hI.hom_ext (_ ≫ hT.from X) (hI.to T)))\n\n/-- To show a category is a `initial_mono_class` it suffices to show the unique morphism from the\ninitial object to a terminal object is a monomorphism. -/\nlemma initial_mono_class.of_terminal [has_initial C] [has_terminal C]\n  (h : mono (initial.to (⊤_ C))) :\n  initial_mono_class C :=\ninitial_mono_class.of_is_terminal initial_is_initial terminal_is_terminal h\n\nsection comparison\nvariables {D : Type u₂} [category.{v₂} D] (G : C ⥤ D)\n\n/--\nThe comparison morphism from the image of a terminal object to the terminal object in the target\ncategory.\nThis is an isomorphism iff `G` preserves terminal objects, see\n`category_theory.limits.preserves_terminal.of_iso_comparison`.\n-/\ndef terminal_comparison [has_terminal C] [has_terminal D] :\n  G.obj (⊤_ C) ⟶ ⊤_ D :=\nterminal.from _\n\n/--\nThe comparison morphism from the initial object in the target category to the image of the initial\nobject.\n-/\n-- TODO: Show this is an isomorphism if and only if `G` preserves initial objects.\ndef initial_comparison [has_initial C] [has_initial D] :\n  ⊥_ D ⟶ G.obj (⊥_ C) :=\ninitial.to _\n\nend comparison\n\nvariables {J : Type u} [category.{v} J]\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J`, construct a cone for `J`.\nIn `limit_of_diagram_initial` we show it is a limit cone. -/\n@[simps]\ndef cone_of_diagram_initial\n  {X : J} (tX : is_initial X) (F : J ⥤ C) : cone F :=\n{ X := F.obj X,\n  π :=\n  { app := λ j, F.map (tX.to j),\n    naturality' := λ j j' k,\n    begin\n      dsimp,\n      rw [← F.map_comp, category.id_comp, tX.hom_ext (tX.to j ≫ k) (tX.to j')],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J`, show the cone\n`cone_of_diagram_initial` is a limit. -/\ndef limit_of_diagram_initial\n  {X : J} (tX : is_initial X) (F : J ⥤ C) :\nis_limit (cone_of_diagram_initial tX F) :=\n{ lift := λ s, s.π.app X,\n  uniq' := λ s m w,\n    begin\n      rw [← w X, cone_of_diagram_initial_π_app, tX.hom_ext (tX.to X) (𝟙 _)],\n      dsimp, simp -- See note [dsimp, simp]\n    end}\n\n-- This is reducible to allow usage of lemmas about `cone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has an initial object then the image of it is isomorphic\nto the limit of `F`. -/\n@[reducible]\ndef limit_of_initial (F : J ⥤ C)\n  [has_initial J] [has_limit F] :\nlimit F ≅ F.obj (⊥_ J) :=\nis_limit.cone_point_unique_up_to_iso\n  (limit.is_limit _)\n  (limit_of_diagram_initial initial_is_initial F)\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J`, construct a cone for `J`,\nprovided that the morphisms in the diagram are isomorphisms.\nIn `limit_of_diagram_terminal` we show it is a limit cone. -/\n@[simps]\ndef cone_of_diagram_terminal {X : J} (hX : is_terminal X)\n  (F : J ⥤ C) [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : cone F :=\n{ X := F.obj X,\n  π :=\n  { app := λ i, inv (F.map (hX.from _)),\n    naturality' := begin\n      intros i j f,\n      dsimp,\n      simp only [is_iso.eq_inv_comp, is_iso.comp_inv_eq, category.id_comp,\n        ← F.map_comp, hX.hom_ext (hX.from i) (f ≫ hX.from j)],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J` and that the morphisms in the\ndiagram are isomorphisms, show the cone `cone_of_diagram_terminal` is a limit. -/\ndef limit_of_diagram_terminal {X : J} (hX : is_terminal X)\n  (F : J ⥤ C) [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] :\n  is_limit (cone_of_diagram_terminal hX F) :=\n{ lift := λ S, S.π.app _ }\n\n-- This is reducible to allow usage of lemmas about `cone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has a terminal object and all the morphisms in the diagram\nare isomorphisms, then the image of the terminal object is isomorphic to the limit of `F`. -/\n@[reducible]\ndef limit_of_terminal (F : J ⥤ C)\n  [has_terminal J] [has_limit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] :\nlimit F ≅ F.obj (⊤_ J) :=\nis_limit.cone_point_unique_up_to_iso\n  (limit.is_limit _)\n  (limit_of_diagram_terminal terminal_is_terminal F)\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J`, construct a cocone for `J`.\nIn `colimit_of_diagram_terminal` we show it is a colimit cocone. -/\n@[simps]\ndef cocone_of_diagram_terminal\n  {X : J} (tX : is_terminal X) (F : J ⥤ C) : cocone F :=\n{ X := F.obj X,\n  ι :=\n  { app := λ j, F.map (tX.from j),\n    naturality' := λ j j' k,\n    begin\n      dsimp,\n      rw [← F.map_comp, category.comp_id, tX.hom_ext (k ≫ tX.from j') (tX.from j)],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given a terminal object of `J`, show the cocone\n`cocone_of_diagram_terminal` is a colimit. -/\ndef colimit_of_diagram_terminal\n  {X : J} (tX : is_terminal X) (F : J ⥤ C) :\nis_colimit (cocone_of_diagram_terminal tX F) :=\n{ desc := λ s, s.ι.app X,\n  uniq' := λ s m w,\n    by { rw [← w X, cocone_of_diagram_terminal_ι_app, tX.hom_ext (tX.from X) (𝟙 _)], simp } }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has a terminal object then the image of it is isomorphic\nto the colimit of `F`. -/\n@[reducible]\ndef colimit_of_terminal (F : J ⥤ C)\n  [has_terminal J] [has_colimit F] :\ncolimit F ≅ F.obj (⊤_ J) :=\nis_colimit.cocone_point_unique_up_to_iso\n  (colimit.is_colimit _)\n  (colimit_of_diagram_terminal terminal_is_terminal F)\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J`, construct a cocone for `J`,\nprovided that the morphisms in the diagram are isomorphisms.\nIn `colimit_of_diagram_initial` we show it is a colimit cocone. -/\n@[simps]\ndef cocone_of_diagram_initial {X : J} (hX : is_initial X) (F : J ⥤ C)\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : cocone F :=\n{ X := F.obj X,\n  ι :=\n  { app := λ i, inv (F.map (hX.to _)),\n    naturality' := begin\n      intros i j f,\n      dsimp,\n      simp only [is_iso.eq_inv_comp, is_iso.comp_inv_eq, category.comp_id,\n        ← F.map_comp, hX.hom_ext (hX.to i ≫ f) (hX.to j)],\n    end } }\n\n/-- From a functor `F : J ⥤ C`, given an initial object of `J` and that the morphisms in the\ndiagram are isomorphisms, show the cone `cocone_of_diagram_initial` is a colimit. -/\ndef colimit_of_diagram_initial {X : J} (hX : is_initial X) (F : J ⥤ C)\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_colimit (cocone_of_diagram_initial hX F) :=\n{ desc := λ S, S.ι.app _ }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J ⥤ C`, if `J` has an initial object and all the morphisms in the diagram\nare isomorphisms, then the image of the initial object is isomorphic to the colimit of `F`. -/\n@[reducible]\ndef colimit_of_initial (F : J ⥤ C)\n  [has_initial J] [has_colimit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] :\ncolimit F ≅ F.obj (⊥_ J) :=\nis_colimit.cocone_point_unique_up_to_iso\n  (colimit.is_colimit _)\n  (colimit_of_diagram_initial initial_is_initial _)\n\n/--\nIf `j` is initial in the index category, then the map `limit.π F j` is an isomorphism.\n-/\nlemma is_iso_π_of_is_initial {j : J} (I : is_initial j) (F : J ⥤ C) [has_limit F] :\n  is_iso (limit.π F j) :=\n⟨⟨limit.lift _ (cone_of_diagram_initial I F), ⟨by { ext, simp }, by simp⟩⟩⟩\n\ninstance is_iso_π_initial [has_initial J] (F : J ⥤ C) [has_limit F] :\n  is_iso (limit.π F (⊥_ J)) :=\nis_iso_π_of_is_initial (initial_is_initial) F\n\nlemma is_iso_π_of_is_terminal {j : J} (I : is_terminal j) (F : J ⥤ C)\n  [has_limit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (limit.π F j) :=\n⟨⟨limit.lift _ (cone_of_diagram_terminal I F), by { ext, simp }, by simp ⟩⟩\n\ninstance is_iso_π_terminal [has_terminal J] (F : J ⥤ C) [has_limit F]\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (limit.π F (⊤_ J)) :=\nis_iso_π_of_is_terminal terminal_is_terminal F\n\n/--\nIf `j` is terminal in the index category, then the map `colimit.ι F j` is an isomorphism.\n-/\nlemma is_iso_ι_of_is_terminal {j : J} (I : is_terminal j) (F : J ⥤ C) [has_colimit F] :\n  is_iso (colimit.ι F j) :=\n⟨⟨colimit.desc _ (cocone_of_diagram_terminal I F), ⟨by simp, by { ext, simp }⟩⟩⟩\n\ninstance is_iso_ι_terminal [has_terminal J] (F : J ⥤ C) [has_colimit F] :\n  is_iso (colimit.ι F (⊤_ J)) :=\nis_iso_ι_of_is_terminal (terminal_is_terminal) F\n\nlemma is_iso_ι_of_is_initial {j : J} (I : is_initial j) (F : J ⥤ C)\n  [has_colimit F] [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (colimit.ι F j) :=\n⟨⟨colimit.desc _ (cocone_of_diagram_initial I F), ⟨by tidy, by { ext, simp }⟩⟩⟩\n\ninstance is_iso_ι_initial [has_initial J] (F : J ⥤ C) [has_colimit F]\n  [∀ (i j : J) (f : i ⟶ j), is_iso (F.map f)] : is_iso (colimit.ι F (⊥_ J)) :=\nis_iso_ι_of_is_initial initial_is_initial F\n\nend\n\nend category_theory.limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/shapes/terminal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.47359842340275876}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Bhavik Mehta\n-/\nimport category_theory.structured_arrow\nimport category_theory.punit\nimport category_theory.reflects_isomorphisms\nimport category_theory.epi_mono\n\n/-!\n# Over and under categories\n\nOver (and under) categories are special cases of comma categories.\n* If `L` is the identity functor and `R` is a constant functor, then `comma L R` is the \"slice\" or\n  \"over\" category over the object `R` maps to.\n* Conversely, if `L` is a constant functor and `R` is the identity functor, then `comma L R` is the\n  \"coslice\" or \"under\" category under the object `L` maps to.\n\n## Tags\n\ncomma, slice, coslice, over, under\n-/\n\nnamespace category_theory\n\nuniverses v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u₁} [category.{v₁} T]\n\n/--\nThe over category has as objects arrows in `T` with codomain `X` and as morphisms commutative\ntriangles.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\n@[derive category]\ndef over (X : T) := costructured_arrow (𝟭 T) X\n\n-- Satisfying the inhabited linter\ninstance over.inhabited [inhabited T] : inhabited (over (default : T)) :=\n{ default :=\n  { left := default,\n    hom := 𝟙 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U ⟶ V}\n  (h : f.left = g.left) : f = g :=\nby tidy\n\n@[simp] lemma over_right (U : over X) : U.right = punit.star := by tidy\n\n@[simp] lemma id_left (U : over X) : comma_morphism.left (𝟙 U) = 𝟙 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).left = f.left ≫ g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A ⟶ B) : f.left ≫ B.hom = A.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/\n@[simps]\ndef mk {X Y : T} (f : Y ⟶ X) : over X :=\ncostructured_arrow.mk f\n\n/-- We can set up a coercion from arrows with codomain `X` to `over X`. This most likely should not\n    be a global instance, but it is sometimes useful. -/\ndef coe_from_hom {X Y : T} : has_coe (Y ⟶ X) (over X) :=\n{ coe := mk }\n\nsection\nlocal attribute [instance] coe_from_hom\n\n@[simp] lemma coe_hom {X Y : T} (f : Y ⟶ X) : (f : over X).hom = f := rfl\nend\n\n/-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative\n    triangle. -/\n@[simps]\ndef hom_mk {U V : over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom . obviously) :\n  U ⟶ V :=\ncostructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\n@[simps]\ndef iso_mk {f g : over X} (hl : f.left ≅ g.left) (hw : hl.hom ≫ g.hom = f.hom . obviously) :\n  f ≅ g :=\ncostructured_arrow.iso_mk hl hw\n\nsection\nvariable (X)\n/--\nThe forgetful functor mapping an arrow to its domain.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef forget : over X ⥤ T := comma.fst _ _\n\nend\n\n@[simp] lemma forget_obj {U : over X} : (forget X).obj U = U.left := rfl\n@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : (forget X).map f = f.left := rfl\n\n/-- The natural cocone over the forgetful functor `over X ⥤ T` with cocone point `X`. -/\n@[simps] def forget_cocone (X : T) : limits.cocone (forget X) :=\n{ X := X, ι := { app := comma.hom } }\n\n/--\nA morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef map {Y : T} (f : X ⟶ Y) : over X ⥤ over Y := comma.map_right _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : over X} {g : U ⟶ V}\n@[simp] lemma map_obj_left : ((map f).obj U).left = U.left := rfl\n@[simp] lemma map_obj_hom  : ((map f).obj U).hom  = U.hom ≫ f := rfl\n@[simp] lemma map_map_left : ((map f).map g).left = g.left := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map f ⋙ map g :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := λ Y Z f t, by exactI\n  ⟨⟨over.hom_mk (inv ((forget X).map f))\n      ((as_iso ((forget X).map f)).inv_comp_eq.2 (over.w f).symm),\n    by tidy⟩⟩ }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\n/--\nIf `k.left` is an epimorphism, then `k` is an epimorphism. In other words, `over.forget X` reflects\nepimorphisms.\nThe converse does not hold without additional assumptions on the underlying category.\n-/\n-- TODO: Show the converse holds if `T` has binary products or pushouts.\nlemma epi_of_epi_left {f g : over X} (k : f ⟶ g) [hk : epi k.left] : epi k :=\nfaithful_reflects_epi (forget X) hk\n\n/--\nIf `k.left` is a monomorphism, then `k` is a monomorphism. In other words, `over.forget X` reflects\nmonomorphisms.\nThe converse of `category_theory.over.mono_left_of_mono`.\n\nThis lemma is not an instance, to avoid loops in type class inference.\n-/\nlemma mono_of_mono_left {f g : over X} (k : f ⟶ g) [hk : mono k.left] : mono k :=\nfaithful_reflects_mono (forget X) hk\n\n/--\nIf `k` is a monomorphism, then `k.left` is a monomorphism. In other words, `over.forget X` preserves\nmonomorphisms.\nThe converse of `category_theory.over.mono_of_mono_left`.\n-/\ninstance mono_left_of_mono {f g : over X} (k : f ⟶ g) [mono k] : mono k.left :=\nbegin\n  refine ⟨λ (Y : T) l m a, _⟩,\n  let l' : mk (m ≫ f.hom) ⟶ f := hom_mk l (by { dsimp, rw [←over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw ← cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y ⟶ X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f ⥤ over f.left :=\n{ obj := λ α, over.mk α.hom.left,\n  map := λ α β κ, over.hom_mk κ.left.left (by { rw auto_param_eq, rw ← over.w κ, refl }) }\n\n/-- Given f : Y ⟶ X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left ⥤ over f :=\n{ obj := λ g, mk (hom_mk g.hom : mk (g.hom ≫ f.hom) ⟶ f),\n  map := λ g h α, hom_mk (hom_mk α.left (w_assoc α f.hom)) (over_morphism.ext (w α)) }\n\n/-- Given f : Y ⟶ X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f ≌ over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (iso.refl _) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f ⋙ forget f.left = forget f ⋙ forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f ⋙ forget f ⋙ forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `over X ⥤ over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T ⥤ D) : over X ⥤ over (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { left := F.map f.left,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend over\n\n/-- The under category has as objects arrows with domain `X` and as morphisms commutative\n    triangles. -/\n@[derive category]\ndef under (X : T) := structured_arrow X (𝟭 T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default : T)) :=\n{ default :=\n  { right := default,\n    hom := 𝟙 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U ⟶ V}\n  (h : f.right = g.right) : f = g :=\nby tidy\n\n@[simp] lemma under_left (U : under X) : U.left = punit.star := by tidy\n\n@[simp] lemma id_right (U : under X) : comma_morphism.right (𝟙 U) = 𝟙 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).right = f.right ≫ g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A ⟶ B) : A.hom ≫ f.right = B.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/\n@[simps]\ndef mk {X Y : T} (f : X ⟶ Y) : under X :=\nstructured_arrow.mk f\n\n/-- To give a morphism in the under category, it suffices to give a morphism fitting in a\n    commutative triangle. -/\n@[simps]\ndef hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom . obviously) :\n  U ⟶ V :=\nstructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\ndef iso_mk {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) : f ≅ g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).hom.right = hr.hom := rfl\n\n@[simp]\nlemma iso_mk_inv_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).inv.right = hr.inv := rfl\n\nsection\nvariables (X)\n/-- The forgetful functor mapping an arrow to its domain. -/\ndef forget : under X ⥤ T := comma.snd _ _\n\nend\n\n@[simp] lemma forget_obj {U : under X} : (forget X).obj U = U.right := rfl\n@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : (forget X).map f = f.right := rfl\n\n/-- The natural cone over the forgetful functor `under X ⥤ T` with cone point `X`. -/\n@[simps] def forget_cone (X : T) : limits.cone (forget X) :=\n{ X := X, π := { app := comma.hom } }\n\n/-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/\ndef map {Y : T} (f : X ⟶ Y) : under Y ⥤ under X := comma.map_left _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : under Y} {g : U ⟶ V}\n@[simp] lemma map_obj_right : ((map f).obj U).right = U.right := rfl\n@[simp] lemma map_obj_hom   : ((map f).obj U).hom   = f ≫ U.hom := rfl\n@[simp] lemma map_map_right : ((map f).map g).right = g.right := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := λ Y Z f t, by exactI\n  ⟨⟨under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm),\n    by tidy⟩⟩ }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `under X ⥤ under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T ⥤ D) : under X ⥤ under (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { right := F.map f.right,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend under\n\nend category_theory\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/category_theory/over.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.47357844445511993}}
{"text": "import GMLInit.Data.Index.Basic\n\nopen Sum (inl inr)\n\ntheorem List.reverseAux_step (z : α) (xs ys : List α) : List.reverseAux (z :: xs) ys = List.reverseAux xs (z :: ys) := rfl\n\nnamespace Index\nvariable {α} {xs ys : List α}\n\ndef reverseAux : {xs ys : List α} → Sum (Index xs) (Index ys) → Index (List.reverseAux xs ys)\n| [], _, .inr j => j\n| x :: xs, ys, .inl .head => (List.reverseAux_step x xs ys).symm ▸ reverseAux (.inr .head)\n| x :: xs, ys, .inl (.tail i) => (List.reverseAux_step x xs ys).symm ▸ reverseAux (.inl i)\n| x :: xs, ys, .inr j => (List.reverseAux_step x xs ys).symm ▸ reverseAux (.inr (.tail j))\n\ndef reverseTR {xs : List α} (i : Index xs) : Index xs.reverse := reverseAux (.inl i)\n\ndef appendTR {xs ys : List α} : Sum (Index xs) (Index ys) → Index (List.append xs ys)\n| .inl i => List.append_eq_appendTR ▸ reverseAux (.inl i.reverseTR)\n| .inr j => List.append_eq_appendTR ▸ reverseAux (.inr j)\n\nend Index\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/Index/ReverseAux.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833945721304, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.47356632425439116}}
{"text": "import rescale.pseudo_normed_group\n\nnoncomputable theory\n\nopen_locale nnreal big_operators\nlocal attribute [instance] type_pow\n\nsection\n\nvariables {r' : ℝ≥0} (M : Type*) (N : ℕ)\n\nnamespace profinitely_filtered_pseudo_normed_group\n\nvariables [profinitely_filtered_pseudo_normed_group M]\n\ndef unrescale (N : ℝ≥0) (M : Type*) [profinitely_filtered_pseudo_normed_group M] :\n  comphaus_filtered_pseudo_normed_group_hom (rescale N M) M :=\ncomphaus_filtered_pseudo_normed_group_hom.mk_of_bound (add_monoid_hom.id _) N⁻¹\nbegin\n  intro c,\n  refine ⟨λ x hx, _, _⟩,\n  { rwa mul_comm },\n  { haveI : fact (c * N⁻¹ ≤ N⁻¹ * c) := ⟨(mul_comm _ _).le⟩,\n    exact comphaus_filtered_pseudo_normed_group.continuous_cast_le (c * N⁻¹) (N⁻¹ * c) },\nend\n\ndef rescale_proj (i : fin N) :\n  comphaus_filtered_pseudo_normed_group_hom (rescale N (M ^ N)) M :=\n(comphaus_filtered_pseudo_normed_group.pi_proj i).comp (unrescale N _)\n\nlemma rescale_proj_bound_by (i : fin N) : (rescale_proj M N i).bound_by N⁻¹ :=\nby { intros c x hx, rw [rescale.mem_filtration, mul_comm] at hx, exact hx i }\n\ndef sum_hom (N : ℕ) :\n  comphaus_filtered_pseudo_normed_group_hom (rescale N (M ^ N)) M :=\n∑ i, rescale_proj M N i\n\nlemma sum_hom_apply (x) : sum_hom M N x = ∑ i, x i :=\ncomphaus_filtered_pseudo_normed_group_hom.sum_apply _ _ _\n\nlemma sum_hom_strict [fact (0 < N)] : (sum_hom M N).strict :=\nbegin\n  rw comphaus_filtered_pseudo_normed_group_hom.strict_iff_bound_by_one,\n  have := comphaus_filtered_pseudo_normed_group_hom.sum_bound_by finset.univ\n    (rescale_proj M N) (λ i, N⁻¹) (λ i _, rescale_proj_bound_by M N i),\n  dsimp at this,\n  simp only [finset.sum_const, finset.card_univ, fintype.card_fin, nsmul_eq_mul] at this,\n  rwa [mul_inv_cancel] at this,\n  apply ne_of_gt,\n  norm_cast,\n  exact fact.out _\nend\n\nend profinitely_filtered_pseudo_normed_group\n\nnamespace profinitely_filtered_pseudo_normed_group_with_Tinv\n\nopen profinitely_filtered_pseudo_normed_group\n\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M] [fact (0 < r')] [fact (0 < N)]\n\ndef sum_hom :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (rescale N (M ^ N)) M :=\ncomphaus_filtered_pseudo_normed_group_with_Tinv_hom.mk'\n  (sum_hom M N)\n  (sum_hom_strict M N).bound_by_one\n  (λ x, by { simp only [sum_hom, comphaus_filtered_pseudo_normed_group_hom.sum_apply,\n    comphaus_filtered_pseudo_normed_group_hom.map_sum], refl })\n\ninclude r'\n\nlemma sum_hom_apply (x) : sum_hom M N x = ∑ i, x i :=\nsum_hom_apply _ _ _\n\nend profinitely_filtered_pseudo_normed_group_with_Tinv\n\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/pseudo_normed_group/sum_hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.47356631789161224}}
{"text": "/-\nCopyright (c) 2020 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.calculus.mean_value\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# L'Hôpital's rule for 0/0 indeterminate forms\n\nIn this file, we prove several forms of \"L'Hopital's rule\" for computing 0/0\nindeterminate forms. The proof of `has_deriv_at.lhopital_zero_right_on_Ioo`\nis based on the one given in the corresponding\n[Wikibooks](https://en.wikibooks.org/wiki/Calculus/L%27H%C3%B4pital%27s_Rule)\nchapter, and all other statements are derived from this one by composing by\ncarefully chosen functions.\n\nNote that the filter `f'/g'` tends to isn't required to be one of `𝓝 a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `ℝ`.\n\nEach statement is available in a `has_deriv_at` form and a `deriv` form, which\nis denoted by each statement being in either the `has_deriv_at` or the `deriv`\nnamespace.\n-/\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' ≠ 0`) have\nto be satisfied on an explicitely-provided interval.\n-/\n\nnamespace has_deriv_at\n\n\ntheorem lhopital_zero_right_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ}\n    {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x)\n    (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x)\n    (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0)\n    (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_right_on_Ico {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ}\n    {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x)\n    (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x)\n    (hcf : continuous_on f (set.Ico a b)) (hcg : continuous_on g (set.Ico a b))\n    (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0) (hfa : f a = 0) (hga : g a = 0)\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ}\n    {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x)\n    (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x)\n    (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0)\n    (hfb : filter.tendsto f (nhds_within b (set.Iio b)) (nhds 0))\n    (hgb : filter.tendsto g (nhds_within b (set.Iio b)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within b (set.Iio b)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within b (set.Iio b)) l :=\n  sorry\n\ntheorem lhopital_zero_left_on_Ioc {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ}\n    {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x)\n    (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x)\n    (hcf : continuous_on f (set.Ioc a b)) (hcg : continuous_on g (set.Ioc a b))\n    (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0) (hfb : f b = 0) (hgb : g b = 0)\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within b (set.Iio b)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within b (set.Iio b)) l :=\n  sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ}\n    {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Ioi a → has_deriv_at f (f' x) x)\n    (hgg' : ∀ (x : ℝ), x ∈ set.Ioi a → has_deriv_at g (g' x) x)\n    (hg' : ∀ (x : ℝ), x ∈ set.Ioi a → g' x ≠ 0) (hftop : filter.tendsto f filter.at_top (nhds 0))\n    (hgtop : filter.tendsto g filter.at_top (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_top l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l :=\n  sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ}\n    {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Iio a → has_deriv_at f (f' x) x)\n    (hgg' : ∀ (x : ℝ), x ∈ set.Iio a → has_deriv_at g (g' x) x)\n    (hg' : ∀ (x : ℝ), x ∈ set.Iio a → g' x ≠ 0) (hfbot : filter.tendsto f filter.at_bot (nhds 0))\n    (hgbot : filter.tendsto g filter.at_bot (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_bot l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l :=\n  sorry\n\nend has_deriv_at\n\n\nnamespace deriv\n\n\ntheorem lhopital_zero_right_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ}\n    {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Ioo a b))\n    (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → deriv g x ≠ 0)\n    (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_right_on_Ico {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ}\n    {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Ioo a b)) (hcf : continuous_on f (set.Ico a b))\n    (hcg : continuous_on g (set.Ico a b)) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → deriv g x ≠ 0)\n    (hfa : f a = 0) (hga : g a = 0)\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ}\n    {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Ioo a b))\n    (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → deriv g x ≠ 0)\n    (hfb : filter.tendsto f (nhds_within b (set.Iio b)) (nhds 0))\n    (hgb : filter.tendsto g (nhds_within b (set.Iio b)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within b (set.Iio b)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within b (set.Iio b)) l :=\n  sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf : differentiable_on ℝ f (set.Ioi a)) (hg' : ∀ (x : ℝ), x ∈ set.Ioi a → deriv g x ≠ 0)\n    (hftop : filter.tendsto f filter.at_top (nhds 0))\n    (hgtop : filter.tendsto g filter.at_top (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_top l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l :=\n  sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf : differentiable_on ℝ f (set.Iio a)) (hg' : ∀ (x : ℝ), x ∈ set.Iio a → deriv g x ≠ 0)\n    (hfbot : filter.tendsto f filter.at_bot (nhds 0))\n    (hgbot : filter.tendsto g filter.at_bot (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_bot l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l :=\n  sorry\n\nend deriv\n\n\n/-!\n## Generic versions\n\nThe following statements no longer any explicit interval, as they only require\nconditions holding eventually.\n-/\n\nnamespace has_deriv_at\n\n\n/-- L'Hôpital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ}\n    {g' : ℝ → ℝ}\n    (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) (nhds_within a (set.Ioi a)))\n    (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) (nhds_within a (set.Ioi a)))\n    (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds_within a (set.Ioi a)))\n    (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ}\n    {g' : ℝ → ℝ}\n    (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) (nhds_within a (set.Iio a)))\n    (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) (nhds_within a (set.Iio a)))\n    (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds_within a (set.Iio a)))\n    (hfa : filter.tendsto f (nhds_within a (set.Iio a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.Iio a)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Iio a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Iio a)) l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching a real, `has_deriv_at` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds' {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' :\n      filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x)\n        (nhds_within a (set.univ \\ singleton a)))\n    (hgg' :\n      filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x)\n        (nhds_within a (set.univ \\ singleton a)))\n    (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds_within a (set.univ \\ singleton a)))\n    (hfa : filter.tendsto f (nhds_within a (set.univ \\ singleton a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.univ \\ singleton a)) (nhds 0))\n    (hdiv :\n      filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.univ \\ singleton a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) (nhds a))\n    (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) (nhds a))\n    (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds a))\n    (hfa : filter.tendsto f (nhds a) (nhds 0)) (hga : filter.tendsto g (nhds a) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds a) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  lhopital_zero_nhds' (eventually_nhds_within_of_eventually_nhds hff')\n    (eventually_nhds_within_of_eventually_nhds hgg') (eventually_nhds_within_of_eventually_nhds hg')\n    (tendsto_nhds_within_of_tendsto_nhds hfa) (tendsto_nhds_within_of_tendsto_nhds hga)\n    (tendsto_nhds_within_of_tendsto_nhds hdiv)\n\n/-- L'Hôpital's rule for approaching +∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) filter.at_top)\n    (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) filter.at_top)\n    (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) filter.at_top)\n    (hftop : filter.tendsto f filter.at_top (nhds 0))\n    (hgtop : filter.tendsto g filter.at_top (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_top l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching -∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ}\n    (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) filter.at_bot)\n    (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) filter.at_bot)\n    (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) filter.at_bot)\n    (hfbot : filter.tendsto f filter.at_bot (nhds 0))\n    (hgbot : filter.tendsto g filter.at_bot (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_bot l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l :=\n  sorry\n\nend has_deriv_at\n\n\nnamespace deriv\n\n\n/-- L'Hôpital's rule for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) (nhds_within a (set.Ioi a)))\n    (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds_within a (set.Ioi a)))\n    (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) (nhds_within a (set.Iio a)))\n    (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds_within a (set.Iio a)))\n    (hfa : filter.tendsto f (nhds_within a (set.Iio a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.Iio a)) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Iio a)) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Iio a)) l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching a real, `deriv` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds' {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf :\n      filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x)\n        (nhds_within a (set.univ \\ singleton a)))\n    (hg' :\n      filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds_within a (set.univ \\ singleton a)))\n    (hfa : filter.tendsto f (nhds_within a (set.univ \\ singleton a)) (nhds 0))\n    (hga : filter.tendsto g (nhds_within a (set.univ \\ singleton a)) (nhds 0))\n    (hdiv :\n      filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.univ \\ singleton a))\n        l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) (nhds a))\n    (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds a))\n    (hfa : filter.tendsto f (nhds a) (nhds 0)) (hga : filter.tendsto g (nhds a) (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds a) l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  lhopital_zero_nhds' (eventually_nhds_within_of_eventually_nhds hdf)\n    (eventually_nhds_within_of_eventually_nhds hg') (tendsto_nhds_within_of_tendsto_nhds hfa)\n    (tendsto_nhds_within_of_tendsto_nhds hga) (tendsto_nhds_within_of_tendsto_nhds hdiv)\n\n/-- L'Hôpital's rule for approaching +∞, `deriv` version -/\ntheorem lhopital_zero_at_top {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) filter.at_top)\n    (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) filter.at_top)\n    (hftop : filter.tendsto f filter.at_top (nhds 0))\n    (hgtop : filter.tendsto g filter.at_top (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_top l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l :=\n  sorry\n\n/-- L'Hôpital's rule for approaching -∞, `deriv` version -/\ntheorem lhopital_zero_at_bot {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ}\n    (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) filter.at_bot)\n    (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) filter.at_bot)\n    (hfbot : filter.tendsto f filter.at_bot (nhds 0))\n    (hgbot : filter.tendsto g filter.at_bot (nhds 0))\n    (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_bot l) :\n    filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/calculus/lhopital_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577158, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.47356631152883316}}
{"text": "/-\nCopyright (c) 2020 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.elements\nimport Mathlib.category_theory.single_obj\nimport Mathlib.group_theory.group_action.basic\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\n/-!\n# Actions as functors and as categories\n\nFrom a multiplicative action M ↻ X, we can construct a functor from M to the category of\ntypes, mapping the single object of M to X and an element `m : M` to map `X → X` given by\nmultiplication by `m`.\n  This functor induces a category structure on X -- a special case of the category of elements.\nA morphism `x ⟶ y` in this category is simply a scalar `m : M` such that `m • x = y`. In the case\nwhere M is a group, this category is a groupoid -- the `action groupoid'.\n-/\n\nnamespace category_theory\n\n\n/-- A multiplicative action M ↻ X viewed as a functor mapping the single object of M to X\n  and an element `m : M` to the map `X → X` given by multiplication by `m`. -/\n@[simp] theorem action_as_functor_obj (M : Type u_1) [monoid M] (X : Type u) [mul_action M X]\n    (_x : single_obj M) : functor.obj (action_as_functor M X) _x = X :=\n  Eq.refl (functor.obj (action_as_functor M X) _x)\n\n/-- A multiplicative action M ↻ X induces a category strucure on X, where a morphism\n from x to y is a scalar taking x to y. Due to implementation details, the object type\n of this category is not equal to X, but is in bijection with X. -/\ndef action_category (M : Type u_1) [monoid M] (X : Type u) [mul_action M X] :=\n  functor.elements (action_as_functor M X)\n\nnamespace action_category\n\n\nprotected instance category_theory.groupoid (X : Type u) (G : Type u_1) [group G] [mul_action G X] :\n    groupoid (action_category G X) :=\n  category_theory.groupoid_of_elements (action_as_functor G X)\n\n/-- The projection from the action category to the monoid, mapping a morphism to its\n  label. -/\ndef π (M : Type u_1) [monoid M] (X : Type u) [mul_action M X] :\n    action_category M X ⥤ single_obj M :=\n  category_of_elements.π (action_as_functor M X)\n\n@[simp] theorem π_map (M : Type u_1) [monoid M] (X : Type u) [mul_action M X]\n    (p : action_category M X) (q : action_category M X) (f : p ⟶ q) :\n    functor.map (π M X) f = subtype.val f :=\n  rfl\n\n@[simp] theorem π_obj (M : Type u_1) [monoid M] (X : Type u) [mul_action M X]\n    (p : action_category M X) : functor.obj (π M X) p = single_obj.star M :=\n  subsingleton.elim (functor.obj (π M X) p) (single_obj.star M)\n\n/-- An object of the action category given by M ↻ X corresponds to an element of X. -/\ndef obj_equiv (M : Type u_1) [monoid M] (X : Type u) [mul_action M X] : X ≃ action_category M X :=\n  equiv.mk (fun (x : X) => sigma.mk (single_obj.star M) x)\n    (fun (p : action_category M X) => sigma.snd p) sorry sorry\n\ntheorem hom_as_subtype (M : Type u_1) [monoid M] (X : Type u) [mul_action M X]\n    (p : action_category M X) (q : action_category M X) :\n    (p ⟶ q) =\n        Subtype\n          fun (m : M) =>\n            m • coe_fn (equiv.symm (obj_equiv M X)) p = coe_fn (equiv.symm (obj_equiv M X)) q :=\n  rfl\n\nprotected instance inhabited (M : Type u_1) [monoid M] (X : Type u) [mul_action M X] [Inhabited X] :\n    Inhabited (action_category M X) :=\n  { default := coe_fn (obj_equiv M X) Inhabited.default }\n\n/-- The stabilizer of a point is isomorphic to the endomorphism monoid at the\n  corresponding point. In fact they are definitionally equivalent. -/\ndef stabilizer_iso_End (M : Type u_1) [monoid M] {X : Type u} [mul_action M X] (x : X) :\n    ↥(mul_action.stabilizer.submonoid M x) ≃* End (coe_fn (obj_equiv M X) x) :=\n  mul_equiv.refl ↥(mul_action.stabilizer.submonoid M x)\n\n@[simp] theorem stabilizer_iso_End_apply (M : Type u_1) [monoid M] {X : Type u} [mul_action M X]\n    (x : X) (f : ↥(mul_action.stabilizer.submonoid M x)) :\n    mul_equiv.to_fun (stabilizer_iso_End M x) f = f :=\n  rfl\n\n@[simp] theorem stabilizer_iso_End_symm_apply (M : Type u_1) [monoid M] {X : Type u}\n    [mul_action M X] (x : X) (f : End (coe_fn (obj_equiv M X) x)) :\n    mul_equiv.inv_fun (stabilizer_iso_End M x) f = f :=\n  rfl\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/action_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.473555518283692}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Yury Kudryashov\n-/\nimport order.preorder_hom\nimport dynamics.fixed_points.basic\n\n/-!\n# Fixed point construction on complete lattices\n\nThis file sets up the basic theory of fixed points of a monotone function in a complete lattice.\n\n## Main definitions\n\n* `preorder_hom.lfp`: The least fixed point of a bundled monotone function.\n* `preorder_hom.gfp`: The greatest fixed point of a bundled monotone function.\n* `preorder_hom.prev_fixed`: The greatest fixed point of a bundled monotone function smaller than or\n  equal to a given element.\n* `preorder_hom.next_fixed`: The least fixed point of a bundled monotone function greater than or\n  equal to a given element.\n* `fixed_points.complete_lattice`: The Knaster-Tarski theorem: fixed points of a monotone\n  self-map of a complete lattice form themselves a complete lattice.\n\n## Tags\n\nfixed point, complete lattice, monotone function\n-/\n\nuniverses u v w\nvariables {α : Type u} {β : Type v} {γ : Type w}\n\nopen function (fixed_points is_fixed_pt)\n\nnamespace preorder_hom\n\nsection basic\n\nvariables [complete_lattice α] (f : α →ₘ α)\n\n/-- Least fixed point of a monotone function -/\ndef lfp : (α →ₘ α) →ₘ α :=\n{ to_fun := λ f, Inf {a | f a ≤ a},\n  monotone' := λ f g hle, Inf_le_Inf $ λ a ha, (hle a).trans ha }\n\n/-- Greatest fixed point of a monotone function -/\ndef gfp : (α →ₘ α) →ₘ α :=\n{ to_fun := λ f, Sup {a | a ≤ f a},\n  monotone' := λ f g hle, Sup_le_Sup $ λ a ha, le_trans ha (hle a) }\n\nlemma lfp_le {a : α} (h : f a ≤ a) : lfp f ≤ a := Inf_le h\n\nlemma lfp_le_fixed {a : α} (h : f a = a) : lfp f ≤ a := f.lfp_le h.le\n\nlemma le_lfp {a : α} (h : ∀ b, f b ≤ b → a ≤ b) : a ≤ lfp f := le_Inf h\n\nlemma map_le_lfp {a : α} (ha : a ≤ f.lfp) : f a ≤ f.lfp :=\nf.le_lfp $ λ b hb, (f.mono $ le_Inf_iff.1 ha _ hb).trans hb\n\n@[simp] lemma map_lfp : f (lfp f) = lfp f :=\nhave h : f (lfp f) ≤ lfp f, from f.map_le_lfp le_rfl,\nh.antisymm $ f.lfp_le $ f.mono h\n\nlemma is_fixed_pt_lfp : is_fixed_pt f f.lfp := f.map_lfp\n\nlemma lfp_le_map {a : α} (ha : lfp f ≤ a) : lfp f ≤ f a :=\ncalc lfp f = f (lfp f) : f.map_lfp.symm\n       ... ≤ f a       : f.mono ha\n\nlemma is_least_lfp_le : is_least {a | f a ≤ a} (lfp f) :=\n⟨f.map_lfp.le, λ a, f.lfp_le⟩\n\nlemma is_least_lfp : is_least (fixed_points f) (lfp f) :=\n⟨f.is_fixed_pt_lfp, λ a, f.lfp_le_fixed⟩\n\nlemma lfp_induction {p : α → Prop} (step : ∀ a, p a → a ≤ lfp f → p (f a))\n  (hSup : ∀ s, (∀ a ∈ s, p a) → p (Sup s)) :\n  p (lfp f) :=\nbegin\n  set s := {a | a ≤ lfp f ∧ p a},\n  specialize hSup s (λ a, and.right),\n  suffices : Sup s = lfp f, from this ▸ hSup,\n  have h : Sup s ≤ lfp f := Sup_le (λ b, and.left),\n  have hmem : f (Sup s) ∈ s, from ⟨f.map_le_lfp h, step _ hSup h⟩,\n  exact h.antisymm (f.lfp_le $ le_Sup hmem)\nend\n\nlemma le_gfp {a : α} (h : a ≤ f a) : a ≤ gfp f :=\nle_Sup h\n\nlemma gfp_le {a : α} (h : ∀ b, b ≤ f b → b ≤ a) : gfp f ≤ a :=\nSup_le h\n\nlemma is_fixed_pt_gfp : is_fixed_pt f (gfp f) := f.dual.is_fixed_pt_lfp\n\n@[simp] lemma map_gfp : f (gfp f) = gfp f := f.dual.map_lfp\n\nlemma map_le_gfp {a : α} (ha : a ≤ gfp f) : f a ≤ gfp f := f.dual.lfp_le_map ha\n\nlemma gfp_le_map {a : α} (ha : gfp f ≤ a) : gfp f ≤ f a := f.dual.map_le_lfp ha\n\nlemma is_greatest_gfp_le : is_greatest {a | a ≤ f a} (gfp f) :=\nf.dual.is_least_lfp_le\n\nlemma is_greatest_gfp : is_greatest (fixed_points f) (gfp f) :=\nf.dual.is_least_lfp\n\nlemma gfp_induction {p : α → Prop} (step : ∀ a, p a → gfp f ≤ a → p (f a))\n  (hInf : ∀ s, (∀ a ∈ s, p a) → p (Inf s)) :\n  p (gfp f) :=\nf.dual.lfp_induction step hInf\n\nend basic\n\nsection eqn\n\nvariables [complete_lattice α] [complete_lattice β] (f : β →ₘ α) (g : α →ₘ β)\n\n-- Rolling rule\nlemma map_lfp_comp : f (lfp (g.comp f)) = lfp (f.comp g) :=\nle_antisymm ((f.comp g).map_lfp ▸ f.mono (lfp_le_fixed _ $ congr_arg g (f.comp g).map_lfp)) $\n  lfp_le _ (congr_arg f (g.comp f).map_lfp).le\n\nlemma map_gfp_comp : f ((g.comp f).gfp) = (f.comp g).gfp :=\nf.dual.map_lfp_comp g.dual\n\n-- Diagonal rule\nlemma lfp_lfp (h : α →ₘ α →ₘ α) :\n  lfp (lfp.comp h) = lfp h.on_diag :=\nbegin\n  let a := lfp (lfp.comp h),\n  refine (lfp_le _ _).antisymm (lfp_le _ (eq.le _)),\n  { exact lfp_le _ h.on_diag.map_lfp.le },\n  have ha : (lfp ∘ h) a = a := (lfp.comp h).map_lfp,\n  calc h a a = h a (lfp (h a)) : congr_arg (h a) ha.symm\n         ... = lfp (h a)       : (h a).map_lfp\n         ... = a               : ha\nend\n\nlemma gfp_gfp (h : α →ₘ α →ₘ α) :\n  gfp (gfp.comp h) = gfp h.on_diag :=\n@lfp_lfp (order_dual α) _ $ (preorder_hom.dual_iso (order_dual α)\n  (order_dual α)).symm.to_order_embedding.to_preorder_hom.comp h.dual\n\nend eqn\n\nsection prev_next\nvariables [complete_lattice α] (f : α →ₘ α)\n\nlemma gfp_const_inf_le (x : α) : gfp (const α x ⊓ f) ≤ x :=\ngfp_le _ $ λ b hb, hb.trans inf_le_left\n\n/-- Previous fixed point of a monotone map. If `f` is a monotone self-map of a complete lattice and\n`x` is a point such that `f x ≤ x`, then `f.prev_fixed x hx` is the greatest fixed point of `f`\nthat is less than or equal to `x`. -/\ndef prev_fixed (x : α) (hx : f x ≤ x) : fixed_points f :=\n⟨gfp (const α x ⊓ f),\n  calc f (gfp (const α x ⊓ f)) = x ⊓ f (gfp (const α x ⊓ f)) :\n    eq.symm $ inf_of_le_right $ (f.mono $ f.gfp_const_inf_le x).trans hx\n  ... = gfp (const α x ⊓ f) : (const α x ⊓ f).map_gfp ⟩\n\n/-- Next fixed point of a monotone map. If `f` is a monotone self-map of a complete lattice and\n`x` is a point such that `x ≤ f x`, then `f.next_fixed x hx` is the least fixed point of `f`\nthat is greater than or equal to `x`. -/\ndef next_fixed (x : α) (hx : x ≤ f x) : fixed_points f :=\n{ val := (const α x ⊔ f).lfp,\n  .. f.dual.prev_fixed x hx }\n\nlemma prev_fixed_le {x : α} (hx : f x ≤ x) : ↑(f.prev_fixed x hx) ≤ x :=\nf.gfp_const_inf_le x\n\nlemma le_next_fixed {x : α} (hx : x ≤ f x) : x ≤ f.next_fixed x hx :=\nf.dual.prev_fixed_le hx\n\nlemma next_fixed_le {x : α} (hx : x ≤ f x) {y : fixed_points f} (h : x ≤ y) :\n  f.next_fixed x hx ≤ y :=\nsubtype.coe_le_coe.1 $ lfp_le _ $ sup_le h y.2.le\n\n@[simp] lemma next_fixed_le_iff {x : α} (hx : x ≤ f x) {y : fixed_points f} :\n  f.next_fixed x hx ≤ y ↔ x ≤ y :=\n⟨λ h, (f.le_next_fixed hx).trans h, f.next_fixed_le hx⟩\n\n@[simp] \n\nlemma le_prev_fixed {x : α} (hx : f x ≤ x) {y : fixed_points f} (h : ↑y ≤ x) :\n  y ≤ f.prev_fixed x hx :=\n(f.le_prev_fixed_iff hx).2 h\n\nlemma le_map_sup_fixed_points (x y : fixed_points f) : (x ⊔ y : α) ≤ f (x ⊔ y) :=\ncalc (x ⊔ y : α) = f x ⊔ f y : congr_arg2 (⊔) x.2.symm y.2.symm\n             ... ≤ f (x ⊔ y) : f.mono.le_map_sup x y\n\nlemma map_inf_fixed_points_le (x y : fixed_points f) : f (x ⊓ y) ≤ x ⊓ y :=\nf.dual.le_map_sup_fixed_points x y\n\nlemma le_map_Sup_subset_fixed_points (A : set α) (hA : A ⊆ fixed_points f) : Sup A ≤ f (Sup A) :=\nSup_le $ λ x hx, hA hx ▸ (f.mono $ le_Sup hx)\n\nlemma map_Inf_subset_fixed_points_le (A : set α) (hA : A ⊆ fixed_points f) : f (Inf A) ≤ Inf A :=\nle_Inf $ λ x hx, (hA hx) ▸ (f.mono $ Inf_le hx)\n\nend prev_next\n\nend preorder_hom\n\nnamespace fixed_points\n\nopen preorder_hom\n\nvariables [complete_lattice α] (f : α →ₘ α)\n\ninstance : semilattice_sup (fixed_points f) :=\n{ sup := λ x y, f.next_fixed (x ⊔ y) (f.le_map_sup_fixed_points x y),\n  le_sup_left := λ x y, subtype.coe_le_coe.1 $ le_sup_left.trans (f.le_next_fixed _),\n  le_sup_right := λ x y, subtype.coe_le_coe.1 $ le_sup_right.trans (f.le_next_fixed _),\n  sup_le := λ x y z hxz hyz, f.next_fixed_le _ $ sup_le hxz hyz,\n  .. subtype.partial_order _ }\n\ninstance : semilattice_inf (fixed_points f) :=\n{ inf := λ x y, f.prev_fixed (x ⊓ y) (f.map_inf_fixed_points_le x y),\n  .. subtype.partial_order _, .. (order_dual.semilattice_inf (fixed_points f.dual))  }\n\ninstance : complete_semilattice_Sup (fixed_points f) :=\n{ Sup := λ s, f.next_fixed (Sup (coe '' s))\n    (f.le_map_Sup_subset_fixed_points (coe '' s) (λ z ⟨x, hx⟩, hx.2 ▸ x.2)),\n  le_Sup := λ s x hx, subtype.coe_le_coe.1 $ le_trans (le_Sup $ set.mem_image_of_mem _ hx)\n    (f.le_next_fixed _),\n  Sup_le := λ s x hx, f.next_fixed_le _ $ Sup_le $ set.ball_image_iff.2 hx,\n  .. subtype.partial_order _ }\n\ninstance : complete_semilattice_Inf (fixed_points f) :=\n{ Inf := λ s, f.prev_fixed (Inf (coe '' s))\n    (f.map_Inf_subset_fixed_points_le (coe '' s) (λ z ⟨x, hx⟩, hx.2 ▸ x.2)),\n  le_Inf := λ s x hx, f.le_prev_fixed _ $ le_Inf $ set.ball_image_iff.2 hx,\n  Inf_le := λ s x hx, subtype.coe_le_coe.1 $ le_trans (f.prev_fixed_le _)\n    (Inf_le $ set.mem_image_of_mem _ hx),\n  .. subtype.partial_order _ }\n\n/-- **Knaster-Tarski Theorem**: The fixed points of `f` form a complete lattice. -/\ninstance : complete_lattice (fixed_points f) :=\n{ top := ⟨f.gfp, f.is_fixed_pt_gfp⟩,\n  bot := ⟨f.lfp, f.is_fixed_pt_lfp⟩,\n  le_top := λ x, f.le_gfp x.2.ge,\n  bot_le := λ x, f.lfp_le x.2.le,\n  .. subtype.partial_order _,\n  .. fixed_points.semilattice_sup f,\n  .. fixed_points.semilattice_inf f,\n  .. fixed_points.complete_semilattice_Sup f,\n  .. fixed_points.complete_semilattice_Inf f }\n\nend fixed_points\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/order/fixed_points.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.47355551351239145}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes Hölzl\n\nExtended non-negative reals\n-/\nimport topology.instances.nnreal data.real.ennreal\nnoncomputable theory\nopen classical set lattice filter metric\nlocal attribute [instance] prop_decidable\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\nlocal notation `∞` := ennreal.infinity\n\nnamespace ennreal\nvariables {a b c d : ennreal} {r p q : nnreal}\n\nsection topological_space\nopen topological_space\n\n/-- Topology on `ennreal`.\n\nNote: this is different from the `emetric_space` topology. The `emetric_space` topology has\n`is_open {⊤}`, while this topology doesn't have singleton elements. -/\ninstance : topological_space ennreal :=\ntopological_space.generate_from {s | ∃a, s = {b | a < b} ∨ s = {b | b < a}}\n\ninstance : orderable_topology ennreal := ⟨rfl⟩\n\ninstance : t2_space ennreal := by apply_instance\n\ninstance : second_countable_topology ennreal :=\n⟨⟨⋃q ≥ (0:ℚ), {{a : ennreal | a < nnreal.of_real q}, {a : ennreal | ↑(nnreal.of_real q) < a}},\n  countable_bUnion (countable_encodable _) $ assume a ha, countable_insert (countable_singleton _),\n  le_antisymm\n    (generate_from_le $ λ s h, begin\n      rcases h with ⟨a, hs | hs⟩;\n      [ rw show s = ⋃q∈{q:ℚ | 0 ≤ q ∧ a < nnreal.of_real q}, {b | ↑(nnreal.of_real q) < b},\n           from set.ext (assume b, by simp [hs, @ennreal.lt_iff_exists_rat_btwn a b, and_assoc]),\n        rw show s = ⋃q∈{q:ℚ | 0 ≤ q ∧ ↑(nnreal.of_real q) < a}, {b | b < ↑(nnreal.of_real q)},\n           from set.ext (assume b, by simp [hs, @ennreal.lt_iff_exists_rat_btwn b a, and_comm, and_assoc])];\n      { apply is_open_Union, intro q,\n        apply is_open_Union, intro hq,\n        exact generate_open.basic _ (mem_bUnion hq.1 $ by simp) }\n    end)\n    (generate_from_le $ by simp [or_imp_distrib, is_open_lt', is_open_gt'] {contextual := tt})⟩⟩\n\nlemma embedding_coe : embedding (coe : nnreal → ennreal) :=\nand.intro (assume a b, coe_eq_coe.1) $\nbegin\n  refine le_antisymm _ _,\n  { rw [orderable_topology.topology_eq_generate_intervals nnreal],\n    refine generate_from_le (assume s ha, _),\n    rcases ha with ⟨a, rfl | rfl⟩,\n    exact ⟨{b : ennreal | ↑a < b}, @is_open_lt' ennreal ennreal.topological_space _ _ _, by simp⟩,\n    exact ⟨{b : ennreal | b < ↑a}, @is_open_gt' ennreal ennreal.topological_space _ _ _, by simp⟩, },\n  { rw [orderable_topology.topology_eq_generate_intervals ennreal,\n      induced_le_iff_le_coinduced],\n    refine generate_from_le (assume s ha, _),\n    rcases ha with ⟨a, rfl | rfl⟩,\n    show is_open {b : nnreal | a < ↑b},\n    { cases a; simp [none_eq_top, some_eq_coe, is_open_lt'] },\n    show is_open {b : nnreal | ↑b < a},\n    { cases a; simp [none_eq_top, some_eq_coe, is_open_gt', is_open_const] } }\nend\n\nlemma is_open_ne_top : is_open {a : ennreal | a ≠ ⊤} :=\nis_open_neg (is_closed_eq continuous_id continuous_const)\n\nlemma coe_range_mem_nhds : range (coe : nnreal → ennreal) ∈ nhds (r : ennreal) :=\nhave {a : ennreal | a ≠ ⊤} = range (coe : nnreal → ennreal),\n  from set.ext $ assume a, by cases a; simp [none_eq_top, some_eq_coe],\nthis ▸ mem_nhds_sets is_open_ne_top coe_ne_top\n\nlemma tendsto_coe {f : filter α} {m : α → nnreal} {a : nnreal} :\n  tendsto (λa, (m a : ennreal)) f (nhds ↑a) ↔ tendsto m f (nhds a) :=\nembedding_coe.tendsto_nhds_iff.symm\n\nlemma continuous_coe {α} [topological_space α] {f : α → nnreal} :\ncontinuous (λa, (f a : ennreal)) ↔ continuous f :=\nembedding_coe.continuous_iff.symm\n\nlemma nhds_coe {r : nnreal} : nhds (r : ennreal) = (nhds r).map coe :=\nby rw [embedding_coe.2, map_nhds_induced_eq coe_range_mem_nhds]\n\nlemma nhds_coe_coe {r p : nnreal} : nhds ((r : ennreal), (p : ennreal)) =\n  (nhds (r, p)).map (λp:nnreal×nnreal, (p.1, p.2)) :=\nbegin\n  rw [(embedding_prod_mk embedding_coe embedding_coe).map_nhds_eq],\n  rw [← prod_range_range_eq],\n  exact prod_mem_nhds_sets coe_range_mem_nhds coe_range_mem_nhds\nend\n\nlemma continuous_of_real : continuous ennreal.of_real :=\ncontinuous.comp nnreal.continuous_of_real (continuous_coe.2 continuous_id)\n\nlemma tendsto_of_real {f : filter α} {m : α → ℝ} {a : ℝ} (h : tendsto m f (nhds a)) :\n  tendsto (λa, ennreal.of_real (m a)) f (nhds (ennreal.of_real a)) :=\ntendsto.comp h (continuous.tendsto continuous_of_real _)\n\nlemma tendsto_to_nnreal {a : ennreal} : a ≠ ⊤ →\n  tendsto (ennreal.to_nnreal) (nhds a) (nhds a.to_nnreal) :=\nbegin\n  cases a; simp [some_eq_coe, none_eq_top, nhds_coe, tendsto_map'_iff, (∘)],\n  exact tendsto_id\nend\n\nlemma tendsto_nhds_top {m : α → ennreal} {f : filter α}\n  (h : ∀n:ℕ, {a | ↑n < m a} ∈ f) : tendsto m f (nhds ⊤) :=\ntendsto_nhds_generate_from $ assume s hs,\nmatch s, hs with\n| _, ⟨none,   or.inl rfl⟩, hr := (lt_irrefl ⊤ hr).elim\n| _, ⟨some r, or.inl rfl⟩, hr :=\n  let ⟨n, hrn⟩ := exists_nat_gt r in\n  mem_sets_of_superset (h n) $ assume a hnma, show ↑r < m a, from\n    lt_trans (show (r : ennreal) < n, from (coe_nat n) ▸ coe_lt_coe.2 hrn) hnma\n| _, ⟨a,      or.inr rfl⟩, hr := (not_top_lt $ show ⊤ < a, from hr).elim\nend\n\nlemma tendsto_coe_nnreal_nhds_top {α} {l : filter α} {f : α → nnreal} (h : tendsto f l at_top) :\n  tendsto (λa, (f a : ennreal)) l (nhds (⊤:ennreal)) :=\ntendsto_nhds_top $ assume n,\nhave {a : α | ↑(n+1) ≤ f a} ∈ l := h $ mem_at_top _,\nmem_sets_of_superset this $ assume a (ha : ↑(n+1) ≤ f a),\nbegin\n  rw [← coe_nat],\n  dsimp,\n  exact coe_lt_coe.2 (lt_of_lt_of_le (nat.cast_lt.2 (nat.lt_succ_self _)) ha)\nend\n\ninstance : topological_add_monoid ennreal :=\n⟨ continuous_iff_continuous_at.2 $\n  have hl : ∀a:ennreal, tendsto (λ (p : ennreal × ennreal), p.fst + p.snd) (nhds (⊤, a)) (nhds ⊤), from\n    assume a, tendsto_nhds_top $ assume n,\n    have set.prod {a | ↑n < a } univ ∈ nhds ((⊤:ennreal), a), from\n      prod_mem_nhds_sets (lt_mem_nhds $ coe_nat n ▸ coe_lt_top) univ_mem_sets,\n    show {a : ennreal × ennreal | ↑n < a.fst + a.snd} ∈ nhds (⊤, a),\n    begin filter_upwards [this] assume ⟨a₁, a₂⟩ ⟨h₁, h₂⟩, lt_of_lt_of_le h₁ (le_add_right $ le_refl _) end,\n  begin\n    rintro ⟨a₁, a₂⟩,\n    cases a₁, { simp [continuous_at, none_eq_top, hl a₂], },\n    cases a₂, { simp [continuous_at, none_eq_top, some_eq_coe, nhds_swap (a₁ : ennreal) ⊤,\n                      tendsto_map'_iff, (∘), hl ↑a₁] },\n    simp [continuous_at, some_eq_coe, nhds_coe_coe, tendsto_map'_iff, (∘)],\n    simp only [coe_add.symm, tendsto_coe, tendsto_add']\n  end ⟩\n\nprotected lemma tendsto_mul' (ha : a ≠ 0 ∨ b ≠ ⊤) (hb : b ≠ 0 ∨ a ≠ ⊤) :\n  tendsto (λp:ennreal×ennreal, p.1 * p.2) (nhds (a, b)) (nhds (a * b)) :=\nhave ht : ∀b:ennreal, b ≠ 0 → tendsto (λp:ennreal×ennreal, p.1 * p.2) (nhds ((⊤:ennreal), b)) (nhds ⊤),\nbegin\n  refine assume b hb, tendsto_nhds_top $ assume n, _,\n  rcases dense (zero_lt_iff_ne_zero.2 hb) with ⟨ε', hε', hεb'⟩,\n  rcases ennreal.lt_iff_exists_coe.1 hεb' with ⟨ε, rfl, h⟩,\n  rcases exists_nat_gt (↑n / ε) with ⟨m, hm⟩,\n  have hε : ε > 0, from coe_lt_coe.1 hε',\n  refine mem_sets_of_superset (prod_mem_nhds_sets (lt_mem_nhds $ @coe_lt_top m) (lt_mem_nhds $ h)) _,\n  rintros ⟨a₁, a₂⟩ ⟨h₁, h₂⟩,\n  dsimp at h₁ h₂ ⊢,\n  calc (n:ennreal) = ↑(((n:nnreal) / ε) * ε) :\n    begin\n      simp [nnreal.div_def],\n      rw [mul_assoc, ← coe_mul, nnreal.inv_mul_cancel, coe_one, ← coe_nat, mul_one],\n      exact zero_lt_iff_ne_zero.1 hε\n    end\n    ... < (↑m * ε : nnreal) : coe_lt_coe.2 $ mul_lt_mul hm (le_refl _) hε (nat.cast_nonneg _)\n    ... ≤ a₁ * a₂ : by rw [coe_mul]; exact canonically_ordered_semiring.mul_le_mul\n      (le_of_lt h₁)\n      (le_of_lt h₂)\nend,\nbegin\n  cases a, {simp [none_eq_top] at hb, simp [none_eq_top, ht b hb, top_mul, hb] },\n  cases b, {\n    simp [none_eq_top] at ha,\n    have ha' : a ≠ 0, from mt coe_eq_coe.2 ha,\n    simp [*, nhds_swap (a : ennreal) ⊤, none_eq_top, some_eq_coe, top_mul, tendsto_map'_iff, (∘), mul_comm] },\n  simp [some_eq_coe, nhds_coe_coe, tendsto_map'_iff, (∘)],\n  simp only [coe_mul.symm, tendsto_coe, tendsto_mul']\nend\n\nprotected lemma tendsto_mul {f : filter α} {ma : α → ennreal} {mb : α → ennreal} {a b : ennreal}\n  (hma : tendsto ma f (nhds a)) (ha : a ≠ 0 ∨ b ≠ ⊤) (hmb : tendsto mb f (nhds b)) (hb : b ≠ 0 ∨ a ≠ ⊤) :\n  tendsto (λa, ma a * mb a) f (nhds (a * b)) :=\nshow tendsto ((λp:ennreal×ennreal, p.1 * p.2) ∘ (λa, (ma a, mb a))) f (nhds (a * b)), from\ntendsto.comp (tendsto_prod_mk_nhds hma hmb) (ennreal.tendsto_mul' ha hb)\n\nprotected lemma tendsto_mul_right {f : filter α} {m : α → ennreal} {a b : ennreal}\n  (hm : tendsto m f (nhds b)) (hb : b ≠ 0 ∨ a ≠ ⊤) : tendsto (λb, a * m b) f (nhds (a * b)) :=\nby_cases\n  (assume : a = 0, by simp [this, tendsto_const_nhds])\n  (assume ha : a ≠ 0, ennreal.tendsto_mul tendsto_const_nhds (or.inl ha) hm hb)\n\nlemma Sup_add {s : set ennreal} (hs : s ≠ ∅) : Sup s + a = ⨆b∈s, b + a :=\nhave Sup ((λb, b + a) '' s) = Sup s + a,\n  from is_lub_iff_Sup_eq.mp $ is_lub_of_is_lub_of_tendsto\n    (assume x _ y _ h, add_le_add' h (le_refl _))\n    is_lub_Sup\n    hs\n    (tendsto_add (tendsto_id' inf_le_left) tendsto_const_nhds),\nby simp [Sup_image, -add_comm] at this; exact this.symm\n\nlemma supr_add {ι : Sort*} {s : ι → ennreal} [h : nonempty ι] : supr s + a = ⨆b, s b + a :=\nlet ⟨x⟩ := h in\ncalc supr s + a = Sup (range s) + a : by simp [Sup_range]\n  ... = (⨆b∈range s, b + a) : Sup_add $ ne_empty_iff_exists_mem.mpr ⟨s x, x, rfl⟩\n  ... = _ : by simp [supr_range, -mem_range]\n\nlemma add_supr {ι : Sort*} {s : ι → ennreal} [h : nonempty ι] : a + supr s = ⨆b, a + s b :=\nby rw [add_comm, supr_add]; simp\n\nlemma supr_add_supr {ι : Sort*} {f g : ι → ennreal} (h : ∀i j, ∃k, f i + g j ≤ f k + g k) :\n  supr f + supr g = (⨆ a, f a + g a) :=\nbegin\n  by_cases hι : nonempty ι,\n  { letI := hι,\n    refine le_antisymm _ (supr_le $ λ a, add_le_add' (le_supr _ _) (le_supr _ _)),\n    simpa [add_supr, supr_add] using\n      λ i j:ι, show f i + g j ≤ ⨆ a, f a + g a, from\n      let ⟨k, hk⟩ := h i j in le_supr_of_le k hk },\n  { have : ∀f:ι → ennreal, (⨆i, f i) = 0 := assume f, bot_unique (supr_le $ assume i, (hι ⟨i⟩).elim),\n    rw [this, this, this, zero_add] }\nend\n\nlemma supr_add_supr_of_monotone {ι : Sort*} [semilattice_sup ι]\n  {f g : ι → ennreal} (hf : monotone f) (hg : monotone g) :\n  supr f + supr g = (⨆ a, f a + g a) :=\nsupr_add_supr $ assume i j, ⟨i ⊔ j, add_le_add' (hf $ le_sup_left) (hg $ le_sup_right)⟩\n\nlemma finset_sum_supr_nat {α} {ι} [semilattice_sup ι] {s : finset α} {f : α → ι → ennreal}\n  (hf : ∀a, monotone (f a)) :\n  s.sum (λa, supr (f a)) = (⨆ n, s.sum (λa, f a n)) :=\nbegin\n  refine finset.induction_on s _ _,\n  { simp,\n    exact (bot_unique $ supr_le $ assume i, le_refl ⊥).symm },\n  { assume a s has ih,\n    simp only [finset.sum_insert has],\n    rw [ih, supr_add_supr_of_monotone (hf a)],\n    assume i j h,\n    exact (finset.sum_le_sum' $ assume a ha, hf a h) }\nend\n\nlemma mul_Sup {s : set ennreal} {a : ennreal} : a * Sup s = ⨆i∈s, a * i :=\nbegin\n  by_cases hs : ∀x∈s, x = (0:ennreal),\n  { have h₁ : Sup s = 0 := (bot_unique $ Sup_le $ assume a ha, (hs a ha).symm ▸ le_refl 0),\n    have h₂ : (⨆i ∈ s, a * i) = 0 :=\n      (bot_unique $ supr_le $ assume a, supr_le $ assume ha, by simp [hs a ha]),\n    rw [h₁, h₂, mul_zero] },\n  { simp only [not_forall] at hs,\n    rcases hs with ⟨x, hx, hx0⟩,\n    have s₀ : s ≠ ∅ := not_eq_empty_iff_exists.2 ⟨x, hx⟩,\n    have s₁ : Sup s ≠ 0 :=\n      zero_lt_iff_ne_zero.1 (lt_of_lt_of_le (zero_lt_iff_ne_zero.2 hx0) (le_Sup hx)),\n    have : Sup ((λb, a * b) '' s) = a * Sup s :=\n      is_lub_iff_Sup_eq.mp (is_lub_of_is_lub_of_tendsto\n        (assume x _ y _ h, canonically_ordered_semiring.mul_le_mul (le_refl _) h)\n        is_lub_Sup\n        s₀\n        (ennreal.tendsto_mul_right (tendsto_id' inf_le_left) (or.inl s₁))),\n    rw [this.symm, Sup_image] }\nend\n\nlemma mul_supr {ι : Sort*} {f : ι → ennreal} {a : ennreal} : a * supr f = ⨆i, a * f i :=\nby rw [← Sup_range, mul_Sup, supr_range]\n\nlemma supr_mul {ι : Sort*} {f : ι → ennreal} {a : ennreal} : supr f * a = ⨆i, f i * a :=\nby rw [mul_comm, mul_supr]; congr; funext; rw [mul_comm]\n\nprotected lemma tendsto_coe_sub : ∀{b:ennreal}, tendsto (λb:ennreal, ↑r - b) (nhds b) (nhds (↑r - b)) :=\nbegin\n  refine (forall_ennreal.2 $ and.intro (assume a, _) _),\n  { simp [@nhds_coe a, tendsto_map'_iff, (∘), tendsto_coe, coe_sub.symm],\n    exact nnreal.tendsto_sub tendsto_const_nhds tendsto_id },\n  simp,\n  exact (tendsto.congr' (mem_sets_of_superset (lt_mem_nhds $ @coe_lt_top r) $\n    by simp [le_of_lt] {contextual := tt})) tendsto_const_nhds\nend\n\nlemma sub_supr {ι : Sort*} [hι : nonempty ι] {b : ι → ennreal} (hr : a < ⊤) :\n  a - (⨆i, b i) = (⨅i, a - b i) :=\nlet ⟨i⟩ := hι in\nlet ⟨r, eq, _⟩ := lt_iff_exists_coe.mp hr in\nhave Inf ((λb, ↑r - b) '' range b) = ↑r - (⨆i, b i),\n  from is_glb_iff_Inf_eq.mp $ is_glb_of_is_lub_of_tendsto\n    (assume x _ y _, sub_le_sub (le_refl _))\n    is_lub_supr\n    (ne_empty_of_mem ⟨i, rfl⟩)\n    (tendsto.comp (tendsto_id' inf_le_left) ennreal.tendsto_coe_sub),\nby rw [eq, ←this]; simp [Inf_image, infi_range, -mem_range]; exact le_refl _\n\nend topological_space\n\nsection tsum\n\nvariables {f g : α → ennreal}\n\nprotected lemma is_sum_coe {f : α → nnreal} {r : nnreal} :\n  is_sum (λa, (f a : ennreal)) ↑r ↔ is_sum f r :=\nhave (λs:finset α, s.sum (coe ∘ f)) = (coe : nnreal → ennreal) ∘ (λs:finset α, s.sum f),\n  from funext $ assume s, ennreal.coe_finset_sum.symm,\nby unfold is_sum; rw [this, tendsto_coe]\n\nprotected lemma tsum_coe_eq {f : α → nnreal} (h : is_sum f r) : (∑a, (f a : ennreal)) = r :=\ntsum_eq_is_sum $ ennreal.is_sum_coe.2 $ h\n\nprotected lemma tsum_coe {f : α → nnreal} : has_sum f → (∑a, (f a : ennreal)) = ↑(tsum f)\n| ⟨r, hr⟩ := by rw [tsum_eq_is_sum hr, ennreal.tsum_coe_eq hr]\n\nprotected lemma is_sum : is_sum f (⨆s:finset α, s.sum f) :=\ntendsto_orderable.2\n  ⟨assume a' ha',\n    let ⟨s, hs⟩ := lt_supr_iff.mp ha' in\n    mem_at_top_sets.mpr ⟨s, assume t ht, lt_of_lt_of_le hs $ finset.sum_le_sum_of_subset ht⟩,\n  assume a' ha',\n    univ_mem_sets' $ assume s,\n    have s.sum f ≤ ⨆(s : finset α), s.sum f,\n      from le_supr (λ(s : finset α), s.sum f) s,\n    lt_of_le_of_lt this ha'⟩\n\n@[simp] protected lemma has_sum : has_sum f := ⟨_, ennreal.is_sum⟩\n\nprotected lemma tsum_eq_supr_sum : (∑a, f a) = (⨆s:finset α, s.sum f) :=\ntsum_eq_is_sum ennreal.is_sum\n\nprotected lemma tsum_sigma {β : α → Type*} (f : Πa, β a → ennreal) :\n  (∑p:Σa, β a, f p.1 p.2) = (∑a b, f a b) :=\ntsum_sigma (assume b, ennreal.has_sum) ennreal.has_sum\n\nprotected lemma tsum_prod {f : α → β → ennreal} : (∑p:α×β, f p.1 p.2) = (∑a, ∑b, f a b) :=\nlet j : α × β → (Σa:α, β) := λp, sigma.mk p.1 p.2 in\nlet i : (Σa:α, β) → α × β := λp, (p.1, p.2) in\nlet f' : (Σa:α, β) → ennreal := λp, f p.1 p.2 in\ncalc (∑p:α×β, f' (j p)) = (∑p:Σa:α, β, f p.1 p.2) :\n    tsum_eq_tsum_of_iso j i (assume ⟨a, b⟩, rfl) (assume ⟨a, b⟩, rfl)\n   ... = (∑a, ∑b, f a b) : ennreal.tsum_sigma f\n\nprotected lemma tsum_comm {f : α → β → ennreal} : (∑a, ∑b, f a b) = (∑b, ∑a, f a b) :=\nlet f' : α×β → ennreal := λp, f p.1 p.2 in\ncalc (∑a, ∑b, f a b) = (∑p:α×β, f' p) : ennreal.tsum_prod.symm\n  ... = (∑p:β×α, f' (prod.swap p)) :\n    (tsum_eq_tsum_of_iso prod.swap (@prod.swap α β) (assume ⟨a, b⟩, rfl) (assume ⟨a, b⟩, rfl)).symm\n  ... = (∑b, ∑a, f' (prod.swap (b, a))) : @ennreal.tsum_prod β α (λb a, f' (prod.swap (b, a)))\n\nprotected lemma tsum_add : (∑a, f a + g a) = (∑a, f a) + (∑a, g a) :=\ntsum_add ennreal.has_sum ennreal.has_sum\n\nprotected lemma tsum_le_tsum (h : ∀a, f a ≤ g a) : (∑a, f a) ≤ (∑a, g a) :=\ntsum_le_tsum h ennreal.has_sum ennreal.has_sum\n\nprotected lemma tsum_eq_supr_nat {f : ℕ → ennreal} :\n  (∑i:ℕ, f i) = (⨆i:ℕ, (finset.range i).sum f) :=\ncalc _ = (⨆s:finset ℕ, s.sum f) : ennreal.tsum_eq_supr_sum\n  ... = (⨆i:ℕ, (finset.range i).sum f) : le_antisymm\n    (supr_le_supr2 $ assume s,\n      let ⟨n, hn⟩ := finset.exists_nat_subset_range s in\n      ⟨n, finset.sum_le_sum_of_subset hn⟩)\n    (supr_le_supr2 $ assume i, ⟨finset.range i, le_refl _⟩)\n\nprotected lemma le_tsum (a : α) : f a ≤ (∑a, f a) :=\ncalc f a = ({a} : finset α).sum f : by simp\n  ... ≤ (⨆s:finset α, s.sum f) : le_supr (λs:finset α, s.sum f) _\n  ... = (∑a, f a) : by rw [ennreal.tsum_eq_supr_sum]\n\nprotected lemma mul_tsum : (∑i, a * f i) = a * (∑i, f i) :=\nif h : ∀i, f i = 0 then by simp [h] else\nlet ⟨i, (hi : f i ≠ 0)⟩ := classical.not_forall.mp h in\nhave sum_ne_0 : (∑i, f i) ≠ 0, from ne_of_gt $\n  calc 0 < f i : lt_of_le_of_ne (zero_le _) hi.symm\n    ... ≤ (∑i, f i) : ennreal.le_tsum _,\nhave tendsto (λs:finset α, s.sum ((*) a ∘ f)) at_top (nhds (a * (∑i, f i))),\n  by rw [← show (*) a ∘ (λs:finset α, s.sum f) = λs, s.sum ((*) a ∘ f),\n         from funext $ λ s, finset.mul_sum];\n  exact ennreal.tendsto_mul_right (is_sum_tsum ennreal.has_sum) (or.inl sum_ne_0),\ntsum_eq_is_sum this\n\nprotected lemma tsum_mul : (∑i, f i * a) = (∑i, f i) * a :=\nby simp [mul_comm, ennreal.mul_tsum]\n\n@[simp] lemma tsum_supr_eq {α : Type*} (a : α) {f : α → ennreal} :\n  (∑b:α, ⨆ (h : a = b), f b) = f a :=\nle_antisymm\n  (by rw [ennreal.tsum_eq_supr_sum]; exact supr_le (assume s,\n    calc s.sum (λb, ⨆ (h : a = b), f b) ≤ (finset.singleton a).sum (λb, ⨆ (h : a = b), f b) :\n        finset.sum_le_sum_of_ne_zero $ assume b _ hb,\n          suffices a = b, by simpa using this.symm,\n          classical.by_contradiction $ assume h,\n            by simpa [h] using hb\n      ... = f a : by simp))\n  (calc f a ≤ (⨆ (h : a = a), f a) : le_supr (λh:a=a, f a) rfl\n    ... ≤ (∑b:α, ⨆ (h : a = b), f b) : ennreal.le_tsum _)\n\nlemma is_sum_iff_tendsto_nat {f : ℕ → ennreal} (r : ennreal) :\n  is_sum f r ↔ tendsto (λn:ℕ, (finset.range n).sum f) at_top (nhds r) :=\nbegin\n  refine ⟨tendsto_sum_nat_of_is_sum, assume h, _⟩,\n  rw [← supr_eq_of_tendsto _ h, ← ennreal.tsum_eq_supr_nat],\n  { exact is_sum_tsum ennreal.has_sum },\n  { exact assume s t hst, finset.sum_le_sum_of_subset (finset.range_subset.2 hst) }\nend\n\nend tsum\n\nend ennreal\n\nnamespace nnreal\n\nlemma exists_le_is_sum_of_le {f g : β → nnreal} {r : nnreal}\n  (hgf : ∀b, g b ≤ f b) (hfr : is_sum f r) : ∃p≤r, is_sum g p :=\nhave (∑b, (g b : ennreal)) ≤ r,\nbegin\n  refine is_sum_le (assume b, _) (is_sum_tsum ennreal.has_sum) (ennreal.is_sum_coe.2 hfr),\n  exact ennreal.coe_le_coe.2 (hgf _)\nend,\nlet ⟨p, eq, hpr⟩ := ennreal.le_coe_iff.1 this in\n⟨p, hpr, ennreal.is_sum_coe.1 $ eq ▸ is_sum_tsum ennreal.has_sum⟩\n\nlemma has_sum_of_le {f g : β → nnreal} (hgf : ∀b, g b ≤ f b) : has_sum f → has_sum g\n| ⟨r, hfr⟩ := let ⟨p, _, hp⟩ := exists_le_is_sum_of_le hgf hfr in has_sum_spec hp\n\nlemma is_sum_iff_tendsto_nat {f : ℕ → nnreal} (r : nnreal) :\n  is_sum f r ↔ tendsto (λn:ℕ, (finset.range n).sum f) at_top (nhds r) :=\nbegin\n  rw [← ennreal.is_sum_coe, ennreal.is_sum_iff_tendsto_nat],\n  simp only [ennreal.coe_finset_sum.symm],\n  exact ennreal.tendsto_coe\nend\n\nend nnreal\n\nlemma has_sum_of_nonneg_of_le {f g : β → ℝ}\n  (hg : ∀b, 0 ≤ g b) (hgf : ∀b, g b ≤ f b) (hf : has_sum f) : has_sum g :=\nlet f' (b : β) : nnreal := ⟨f b, le_trans (hg b) (hgf b)⟩ in\nlet g' (b : β) : nnreal := ⟨g b, hg b⟩ in\nhave has_sum f', from nnreal.has_sum_coe.1 hf,\nhave has_sum g', from\n  nnreal.has_sum_of_le (assume b, (@nnreal.coe_le (g' b) (f' b)).2 $ hgf b) this,\nshow has_sum (λb, g' b : β → ℝ), from nnreal.has_sum_coe.2 this\n\nlemma is_sum_iff_tendsto_nat_of_nonneg {f : ℕ → ℝ} (hf : ∀i, 0 ≤ f i) (r : ℝ) :\n  is_sum f r ↔ tendsto (λn:ℕ, (finset.range n).sum f) at_top (nhds r) :=\n⟨tendsto_sum_nat_of_is_sum,\n  assume hfr,\n  have 0 ≤ r := ge_of_tendsto at_top_ne_bot hfr $ univ_mem_sets' $ assume i,\n    show 0 ≤ (finset.range i).sum f, from finset.zero_le_sum $ assume i _, hf i,\n  let f' (n : ℕ) : nnreal := ⟨f n, hf n⟩, r' : nnreal := ⟨r, this⟩ in\n  have f_eq : f = (λi:ℕ, (f' i : ℝ)) := rfl,\n  have r_eq : r = r' := rfl,\n  begin\n    rw [f_eq, r_eq, nnreal.is_sum_coe, nnreal.is_sum_iff_tendsto_nat, ← nnreal.tendsto_coe],\n    simp only [nnreal.sum_coe],\n    exact hfr\n  end⟩\n\nlemma infi_real_pos_eq_infi_nnreal_pos {α : Type*} [complete_lattice α] {f : ℝ → α} :\n  (⨅(n:ℝ) (h : n > 0), f n) = (⨅(n:nnreal) (h : n > 0), f n) :=\nle_antisymm\n  (le_infi $ assume n, le_infi $ assume hn, infi_le_of_le n $ infi_le _ (nnreal.coe_pos.2 hn))\n  (le_infi $ assume r, le_infi $ assume hr, infi_le_of_le ⟨r, le_of_lt hr⟩ $ infi_le _ hr)\n\nsection\nvariables [emetric_space β]\nopen lattice ennreal filter emetric\n\n/-- In an emetric ball, the distance between points is everywhere finite -/\nlemma edist_ne_top_of_mem_ball {a : β} {r : ennreal} (x y : ball a r) : edist x.1 y.1 ≠ ⊤ :=\nlt_top_iff_ne_top.1 $\ncalc edist x y ≤ edist a x + edist a y : edist_triangle_left x.1 y.1 a\n  ... < r + r : by rw [edist_comm a x, edist_comm a y]; exact add_lt_add x.2 y.2\n  ... ≤ ⊤ : le_top\n\n/-- Each ball in an extended metric space gives us a metric space, as the edist\nis everywhere finite. -/\ndef metric_space_emetric_ball (a : β) (r : ennreal) : metric_space (ball a r) :=\nemetric_space.to_metric_space edist_ne_top_of_mem_ball\n\nlocal attribute [instance] metric_space_emetric_ball\n\nlemma nhds_eq_nhds_emetric_ball (a x : β) (r : ennreal) (h : x ∈ ball a r) :\n  nhds x = map (coe : ball a r → β) (nhds ⟨x, h⟩) :=\n(map_nhds_subtype_val_eq _ $ mem_nhds_sets emetric.is_open_ball h).symm\nend\n\nsection\nvariable [emetric_space α]\nopen emetric\n\n/-- Yet another metric characterization of Cauchy sequences on integers. This one is often the\nmost efficient. -/\nlemma emetric.cauchy_seq_iff_le_tendsto_0 [inhabited β] [semilattice_sup β] {s : β → α} :\n  cauchy_seq s ↔ (∃ (b: β → ennreal), (∀ n m N : β, N ≤ n → N ≤ m → edist (s n) (s m) ≤ b N)\n                    ∧ (tendsto b at_top (nhds 0))) :=\n⟨begin\n  assume hs,\n  rw emetric.cauchy_seq_iff at hs,\n  /- `s` is Cauchy sequence. The sequence `b` will be constructed by taking\n  the supremum of the distances between `s n` and `s m` for `n m ≥ N`-/\n  let b := λN, Sup ((λ(p : β × β), edist (s p.1) (s p.2))''{p | p.1 ≥ N ∧ p.2 ≥ N}),\n  --Prove that it bounds the distances of points in the Cauchy sequence\n  have C : ∀ n m N, N ≤ n → N ≤ m → edist (s n) (s m) ≤ b N,\n  { refine λm n N hm hn, le_Sup _,\n    use (prod.mk m n),\n    simp only [and_true, eq_self_iff_true, set.mem_set_of_eq],\n    exact ⟨hm, hn⟩ },\n  --Prove that it tends to `0`, by using the Cauchy property of `s`\n  have D : tendsto b at_top (nhds 0),\n  { refine tendsto_orderable.2 ⟨λa ha, absurd ha (ennreal.not_lt_zero), λε εpos, _⟩,\n    rcases dense εpos with ⟨δ, δpos, δlt⟩,\n    rcases hs δ δpos with ⟨N, hN⟩,\n    refine filter.mem_at_top_sets.2 ⟨N, λn hn, _⟩,\n    have : b n ≤ δ := Sup_le begin\n      simp only [and_imp, set.mem_image, set.mem_set_of_eq, exists_imp_distrib, prod.exists],\n      intros d p q hp hq hd,\n      rw ← hd,\n      exact le_of_lt (hN q p (le_trans hn hq) (le_trans hn hp))\n    end,\n    simpa using lt_of_le_of_lt this δlt },\n  -- Conclude\n  exact ⟨b, ⟨C, D⟩⟩\nend,\nbegin\n  rintros ⟨b, ⟨b_bound, b_lim⟩⟩,\n  /-b : ℕ → ℝ, b_bound : ∀ (n m N : ℕ), N ≤ n → N ≤ m → edist (s n) (s m) ≤ b N,\n    b_lim : tendsto b at_top (nhds 0)-/\n  refine emetric.cauchy_seq_iff.2 (λε εpos, _),\n  have : {n | b n < ε} ∈ at_top := (tendsto_orderable.1 b_lim ).2 _ εpos,\n  rcases filter.mem_at_top_sets.1 this with ⟨N, hN⟩,\n  exact ⟨N, λm n hm hn, calc\n    edist (s n) (s m) ≤ b N : b_bound n m N hn hm\n    ... < ε : (hN _ (le_refl N)) ⟩\nend⟩\n\nlemma continuous_of_le_add_edist {f : α → ennreal} (C : ennreal)\n  (hC : C ≠ ⊤) (h : ∀x y, f x ≤ f y + C * edist x y) : continuous f :=\nbegin\n  refine continuous_iff_continuous_at.2 (λx, tendsto_orderable.2 ⟨_, _⟩),\n  show ∀e, e < f x → {y : α | e < f y} ∈ nhds x,\n  { assume e he,\n    let ε := min (f x - e) 1,\n    have : ε < ⊤ := lt_of_le_of_lt (min_le_right _ _) (by simp [lt_top_iff_ne_top]),\n    have : 0 < ε := by simp [ε, hC, he, ennreal.zero_lt_one],\n    have : 0 < C⁻¹ * (ε/2) := bot_lt_iff_ne_bot.2 (by simp [hC, (ne_of_lt this).symm, ennreal.mul_eq_zero]),\n    have I : C * (C⁻¹ * (ε/2)) < ε,\n    { by_cases C_zero : C = 0,\n      { simp [C_zero, ‹0 < ε›] },\n      { calc C * (C⁻¹ * (ε/2)) = (C * C⁻¹) * (ε/2) : by simp [mul_assoc]\n        ... = ε/2 : by simp [ennreal.mul_inv_cancel C_zero hC]\n        ... < ε : ennreal.half_lt_self (bot_lt_iff_ne_bot.1 ‹0 < ε›) (lt_top_iff_ne_top.1 ‹ε < ⊤›) }},\n    have : ball x (C⁻¹ * (ε/2)) ⊆ {y : α | e < f y},\n    { rintros y hy,\n      by_cases htop : f y = ⊤,\n      { simp [htop, lt_top_iff_ne_top, ne_top_of_lt he] },\n      { simp at hy,\n        have : e + ε < f y + ε := calc\n          e + ε ≤ e + (f x - e) : add_le_add_left' (min_le_left _ _)\n          ... = f x : by simp [le_of_lt he]\n          ... ≤ f y + C * edist x y : h x y\n          ... = f y + C * edist y x : by simp [edist_comm]\n          ... ≤ f y + C * (C⁻¹ * (ε/2)) :\n            add_le_add_left' $ canonically_ordered_semiring.mul_le_mul (le_refl _) (le_of_lt hy)\n          ... < f y + ε : (ennreal.add_lt_add_iff_left (lt_top_iff_ne_top.2 htop)).2 I,\n        show e < f y, from\n          (ennreal.add_lt_add_iff_right ‹ε < ⊤›).1 this }},\n    apply filter.mem_sets_of_superset (ball_mem_nhds _ (‹0 < C⁻¹ * (ε/2)›)) this },\n  show ∀e, f x < e → {y : α | f y < e} ∈ nhds x,\n  { assume e he,\n    let ε := min (e - f x) 1,\n    have : ε < ⊤ := lt_of_le_of_lt (min_le_right _ _) (by simp [lt_top_iff_ne_top]),\n    have : 0 < ε := by simp [ε, he, ennreal.zero_lt_one],\n    have : 0 < C⁻¹ * (ε/2) := bot_lt_iff_ne_bot.2 (by simp [hC, (ne_of_lt this).symm, ennreal.mul_eq_zero]),\n    have I : C * (C⁻¹ * (ε/2)) < ε,\n    { by_cases C_zero : C = 0,\n      simp [C_zero, ‹0 < ε›],\n      calc C * (C⁻¹ * (ε/2)) = (C * C⁻¹) * (ε/2) : by simp [mul_assoc]\n        ... = ε/2 : by simp [ennreal.mul_inv_cancel C_zero hC]\n        ... < ε : ennreal.half_lt_self (bot_lt_iff_ne_bot.1 ‹0 < ε›) (lt_top_iff_ne_top.1 ‹ε < ⊤›) },\n    have : ball x (C⁻¹ * (ε/2)) ⊆ {y : α | f y < e},\n    { rintros y hy,\n      have htop : f x ≠ ⊤ := ne_top_of_lt he,\n      show f y < e, from calc\n        f y ≤ f x + C * edist y x : h y x\n        ... ≤ f x + C * (C⁻¹ * (ε/2)) :\n            add_le_add_left' $ canonically_ordered_semiring.mul_le_mul (le_refl _) (le_of_lt hy)\n        ... < f x + ε : (ennreal.add_lt_add_iff_left (lt_top_iff_ne_top.2 htop)).2 I\n        ... ≤ f x + (e - f x) : add_le_add_left' (min_le_left _ _)\n        ... = e : by simp [le_of_lt he] },\n    apply filter.mem_sets_of_superset (ball_mem_nhds _ (‹0 < C⁻¹ * (ε/2)›)) this },\nend\n\ntheorem continuous_edist' : continuous (λp:α×α, edist p.1 p.2) :=\nbegin\n  apply continuous_of_le_add_edist 2 (by simp),\n  rintros ⟨x, y⟩ ⟨x', y'⟩,\n  calc edist x y ≤ edist x x' + edist x' y' + edist y' y : edist_triangle4 _ _ _ _\n    ... = edist x' y' + (edist x x' + edist y y') : by simp [add_comm, edist_comm]\n    ... ≤ edist x' y' + (edist (x, y) (x', y') + edist (x, y) (x', y')) :\n      add_le_add_left' (add_le_add' (by simp [edist, le_refl]) (by simp [edist, le_refl]))\n    ... = edist x' y' + 2 * edist (x, y) (x', y') : by rw [← mul_two, mul_comm]\nend\n\ntheorem continuous_edist [topological_space β] {f g : β → α}\n  (hf : continuous f) (hg : continuous g) : continuous (λb, edist (f b) (g b)) :=\n(hf.prod_mk hg).comp continuous_edist'\n\ntheorem tendsto_edist {f g : β → α} {x : filter β} {a b : α}\n  (hf : tendsto f x (nhds a)) (hg : tendsto g x (nhds b)) :\n  tendsto (λx, edist (f x) (g x)) x (nhds (edist a b)) :=\nhave tendsto (λp:α×α, edist p.1 p.2) (nhds (a, b)) (nhds (edist a b)),\n  from continuous_iff_continuous_at.mp continuous_edist' (a, b),\n(hf.prod_mk hg).comp (by rw [nhds_prod_eq] at this; exact this)\n\nend --section\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/topology/instances/ennreal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.47355549116601636}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module data.multiset.interval\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.LocallyFinite\nimport Mathbin.Data.Dfinsupp.Interval\nimport Mathbin.Data.Dfinsupp.Multiset\nimport Mathbin.Data.Nat.Interval\n\n/-!\n# Finite intervals of multisets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides the `locally_finite_order` instance for `multiset α` and calculates the\ncardinality of its finite intervals.\n\n## Implementation notes\n\nWe implement the intervals via the intervals on `dfinsupp`, rather than via filtering\n`multiset.powerset`; this is because `(multiset.replicate n x).powerset` has `2^n` entries not `n+1`\nentries as it contains duplicates. We do not go via `finsupp` as this would be noncomputable, and\nmultisets are typically used computationally.\n\n-/\n\n\nopen Finset Dfinsupp Function\n\nopen BigOperators Pointwise\n\nvariable {α : Type _} {β : α → Type _}\n\nnamespace Multiset\n\nvariable [DecidableEq α] (f g : Multiset α)\n\ninstance : LocallyFiniteOrder (Multiset α) :=\n  LocallyFiniteOrder.ofIcc (Multiset α)\n    (fun f g =>\n      (Finset.Icc f.toDfinsupp g.toDfinsupp).map Multiset.equivDfinsupp.toEquiv.symm.toEmbedding)\n    fun f g x => by simp\n\n/- warning: multiset.Icc_eq -> Multiset.Icc_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{succ u1} (Finset.{u1} (Multiset.{u1} α)) (Finset.Icc.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α)) (Multiset.locallyFiniteOrder.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g) (Finset.map.{u1, u1} (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (Multiset.{u1} α) (Equiv.toEmbedding.{succ u1, succ u1} (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (Multiset.{u1} α) (Equiv.symm.{succ u1, succ u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (AddEquiv.toEquiv.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (Multiset.hasAdd.{u1} α) (AddZeroClass.toHasAdd.{u1} (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.equivDfinsupp.{u1} α (fun (a : α) (b : α) => _inst_1 a b))))) (Finset.Icc.{u1} (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (Dfinsupp.preorder.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero) (fun (i : α) => PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (Dfinsupp.locallyFiniteOrder.{u1, 0} α (fun (a : α) => Nat) (fun (a : α) (b : α) => _inst_1 a b) (fun (i : α) (a : Nat) (b : Nat) => Nat.decidableEq a b) (fun (i : α) => OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)) (fun (i : α) => Nat.hasZero) (fun (i : α) => Nat.locallyFiniteOrder)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (fun (_x : AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) => (Multiset.{u1} α) -> (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero))) (AddMonoidHom.hasCoeToFun.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.toDfinsupp.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (fun (_x : AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) => (Multiset.{u1} α) -> (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero))) (AddMonoidHom.hasCoeToFun.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.toDfinsupp.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) g)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{succ u1} (Finset.{u1} (Multiset.{u1} α)) (Finset.Icc.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g) (Finset.map.{u1, u1} (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Multiset.{u1} α) (Equiv.toEmbedding.{succ u1, succ u1} (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Multiset.{u1} α) (Equiv.symm.{succ u1, succ u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddEquiv.toEquiv.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Multiset.instAddMultiset.{u1} α) (Dfinsupp.instAddDfinsuppToZero.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.equivDfinsupp.{u1} α (fun (a : α) (b : α) => _inst_1 a b))))) (Finset.Icc.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) f) (Dfinsupp.instPreorderDfinsupp.{u1, 0} α (fun (a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero) (fun (i : α) => PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u1, 0} α (fun (a : α) => Nat) (fun (a : α) (b : α) => _inst_1 a b) (fun (i : α) (a : Nat) (b : Nat) => instDecidableEqNat a b) (fun (i : α) => StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero) (fun (i : α) => instLocallyFiniteOrderNatToPreorderToPartialOrderStrictOrderedSemiring)) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{u1} (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHom.addMonoidHomClass.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))))) (Multiset.toDfinsupp.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{u1} (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHom.addMonoidHomClass.{u1, u1} (Multiset.{u1} α) (Dfinsupp.{u1, 0} α (fun (_a : α) => Nat) (fun (i : α) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : α) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (Dfinsupp.addZeroClass'.{u1, 0} α Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))))) (Multiset.toDfinsupp.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) g)))\nCase conversion may be inaccurate. Consider using '#align multiset.Icc_eq Multiset.Icc_eqₓ'. -/\ntheorem Icc_eq :\n    Finset.Icc f g =\n      (Finset.Icc f.toDfinsupp g.toDfinsupp).map Multiset.equivDfinsupp.toEquiv.symm.toEmbedding :=\n  rfl\n#align multiset.Icc_eq Multiset.Icc_eq\n\n/- warning: multiset.card_Icc -> Multiset.card_Icc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Icc.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α)) (Multiset.locallyFiniteOrder.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Icc.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Icc Multiset.card_Iccₓ'. -/\ntheorem card_Icc :\n    (Finset.Icc f g).card = ∏ i in f.toFinset ∪ g.toFinset, g.count i + 1 - f.count i := by\n  simp_rw [Icc_eq, Finset.card_map, Dfinsupp.card_Icc, Nat.card_Icc, Multiset.toDfinsupp_apply,\n    toDfinsupp_support]\n#align multiset.card_Icc Multiset.card_Icc\n\n/- warning: multiset.card_Ico -> Multiset.card_Ico is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Ico.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α)) (Multiset.locallyFiniteOrder.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f))) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Ico.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f))) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Ico Multiset.card_Icoₓ'. -/\ntheorem card_Ico :\n    (Finset.Ico f g).card = (∏ i in f.toFinset ∪ g.toFinset, g.count i + 1 - f.count i) - 1 := by\n  rw [card_Ico_eq_card_Icc_sub_one, card_Icc]\n#align multiset.card_Ico Multiset.card_Ico\n\n/- warning: multiset.card_Ioc -> Multiset.card_Ioc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Ioc.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α)) (Multiset.locallyFiniteOrder.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f))) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Ioc.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f))) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Ioc Multiset.card_Iocₓ'. -/\ntheorem card_Ioc :\n    (Finset.Ioc f g).card = (∏ i in f.toFinset ∪ g.toFinset, g.count i + 1 - f.count i) - 1 := by\n  rw [card_Ioc_eq_card_Icc_sub_one, card_Icc]\n#align multiset.card_Ioc Multiset.card_Ioc\n\n/- warning: multiset.card_Ioo -> Multiset.card_Ioo is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Ioo.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α)) (Multiset.locallyFiniteOrder.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f))) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α) (g : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Ioo.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) g)) (fun (i : α) => HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f))) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Ioo Multiset.card_Iooₓ'. -/\ntheorem card_Ioo :\n    (Finset.Ioo f g).card = (∏ i in f.toFinset ∪ g.toFinset, g.count i + 1 - f.count i) - 2 := by\n  rw [card_Ioo_eq_card_Icc_sub_two, card_Icc]\n#align multiset.card_Ioo Multiset.card_Ioo\n\n/- warning: multiset.card_Iic -> Multiset.card_Iic is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Iic.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α)) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.partialOrder.{u1} α)) (Multiset.orderBot.{u1} α) (Multiset.locallyFiniteOrder.{u1} α (fun (a : α) (b : α) => _inst_1 a b))) f)) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (fun (i : α) => HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (f : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} α) (Finset.Iic.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α)) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} (Multiset.{u1} α) (PartialOrder.toPreorder.{u1} (Multiset.{u1} α) (Multiset.instPartialOrderMultiset.{u1} α)) (Multiset.instOrderBotMultisetToLEToPreorderInstPartialOrderMultiset.{u1} α) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} α (fun (a : α) (b : α) => _inst_1 a b))) f)) (Finset.prod.{0, u1} Nat α Nat.commMonoid (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) f) (fun (i : α) => HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Multiset.count.{u1} α (fun (a : α) (b : α) => _inst_1 a b) i f) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Iic Multiset.card_Iicₓ'. -/\ntheorem card_Iic : (Finset.Iic f).card = ∏ i in f.toFinset, f.count i + 1 := by\n  simp_rw [Iic_eq_Icc, card_Icc, bot_eq_zero, to_finset_zero, empty_union, count_zero, tsub_zero]\n#align multiset.card_Iic Multiset.card_Iic\n\nend Multiset\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Multiset/Interval.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152497, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.47348460651974966}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\nimport order.filter.small_sets\nimport topology.subset_properties\nimport topology.nhds_set\n\n/-!\n# Uniform spaces\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nUniform spaces are a generalization of metric spaces and topological groups. Many concepts directly\ngeneralize to uniform spaces, e.g.\n\n* uniform continuity (in this file)\n* completeness (in `cauchy.lean`)\n* extension of uniform continuous functions to complete spaces (in `uniform_embedding.lean`)\n* totally bounded sets (in `cauchy.lean`)\n* totally bounded complete sets are compact (in `cauchy.lean`)\n\nA uniform structure on a type `X` is a filter `𝓤 X` on `X × X` satisfying some conditions\nwhich makes it reasonable to say that `∀ᶠ (p : X × X) in 𝓤 X, ...` means\n\"for all p.1 and p.2 in X close enough, ...\". Elements of this filter are called entourages\nof `X`. The two main examples are:\n\n* If `X` is a metric space, `V ∈ 𝓤 X ↔ ∃ ε > 0, { p | dist p.1 p.2 < ε } ⊆ V`\n* If `G` is an additive topological group, `V ∈ 𝓤 G ↔ ∃ U ∈ 𝓝 (0 : G), {p | p.2 - p.1 ∈ U} ⊆ V`\n\nThose examples are generalizations in two different directions of the elementary example where\n`X = ℝ` and `V ∈ 𝓤 ℝ ↔ ∃ ε > 0, { p | |p.2 - p.1| < ε } ⊆ V` which features both the topological\ngroup structure on `ℝ` and its metric space structure.\n\nEach uniform structure on `X` induces a topology on `X` characterized by\n\n> `nhds_eq_comap_uniformity : ∀ {x : X}, 𝓝 x = comap (prod.mk x) (𝓤 X)`\n\nwhere `prod.mk x : X → X × X := (λ y, (x, y))` is the partial evaluation of the product\nconstructor.\n\nThe dictionary with metric spaces includes:\n* an upper bound for `dist x y` translates into `(x, y) ∈ V` for some `V ∈ 𝓤 X`\n* a ball `ball x r` roughly corresponds to `uniform_space.ball x V := {y | (x, y) ∈ V}`\n  for some `V ∈ 𝓤 X`, but the later is more general (it includes in\n  particular both open and closed balls for suitable `V`).\n  In particular we have:\n  `is_open_iff_ball_subset {s : set X} : is_open s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 X, ball x V ⊆ s`\n\nThe triangle inequality is abstracted to a statement involving the composition of relations in `X`.\nFirst note that the triangle inequality in a metric space is equivalent to\n`∀ (x y z : X) (r r' : ℝ), dist x y ≤ r → dist y z ≤ r' → dist x z ≤ r + r'`.\nThen, for any `V` and `W` with type `set (X × X)`, the composition `V ○ W : set (X × X)` is\ndefined as `{ p : X × X | ∃ z, (p.1, z) ∈ V ∧ (z, p.2) ∈ W }`.\nIn the metric space case, if `V = { p | dist p.1 p.2 ≤ r }` and `W = { p | dist p.1 p.2 ≤ r' }`\nthen the triangle inequality, as reformulated above, says `V ○ W` is contained in\n`{p | dist p.1 p.2 ≤ r + r'}` which is the entourage associated to the radius `r + r'`.\nIn general we have `mem_ball_comp (h : y ∈ ball x V) (h' : z ∈ ball y W) : z ∈ ball x (V ○ W)`.\nNote that this discussion does not depend on any axiom imposed on the uniformity filter,\nit is simply captured by the definition of composition.\n\nThe uniform space axioms ask the filter `𝓤 X` to satisfy the following:\n* every `V ∈ 𝓤 X` contains the diagonal `id_rel = { p | p.1 = p.2 }`. This abstracts the fact\n  that `dist x x ≤ r` for every non-negative radius `r` in the metric space case and also that\n  `x - x` belongs to every neighborhood of zero in the topological group case.\n* `V ∈ 𝓤 X → prod.swap '' V ∈ 𝓤 X`. This is tightly related the fact that `dist x y = dist y x`\n  in a metric space, and to continuity of negation in the topological group case.\n* `∀ V ∈ 𝓤 X, ∃ W ∈ 𝓤 X, W ○ W ⊆ V`. In the metric space case, it corresponds\n  to cutting the radius of a ball in half and applying the triangle inequality.\n  In the topological group case, it comes from continuity of addition at `(0, 0)`.\n\nThese three axioms are stated more abstractly in the definition below, in terms of\noperations on filters, without directly manipulating entourages.\n\n## Main definitions\n\n* `uniform_space X` is a uniform space structure on a type `X`\n* `uniform_continuous f` is a predicate saying a function `f : α → β` between uniform spaces\n  is uniformly continuous : `∀ r ∈ 𝓤 β, ∀ᶠ (x : α × α) in 𝓤 α, (f x.1, f x.2) ∈ r`\n\nIn this file we also define a complete lattice structure on the type `uniform_space X`\nof uniform structures on `X`, as well as the pullback (`uniform_space.comap`) of uniform structures\ncoming from the pullback of filters.\nLike distance functions, uniform structures cannot be pushed forward in general.\n\n## Notations\n\nLocalized in `uniformity`, we have the notation `𝓤 X` for the uniformity on a uniform space `X`,\nand `○` for composition of relations, seen as terms with type `set (X × X)`.\n\n## Implementation notes\n\nThere is already a theory of relations in `data/rel.lean` where the main definition is\n`def rel (α β : Type*) := α → β → Prop`.\nThe relations used in the current file involve only one type, but this is not the reason why\nwe don't reuse `data/rel.lean`. We use `set (α × α)`\ninstead of `rel α α` because we really need sets to use the filter library, and elements\nof filters on `α × α` have type `set (α × α)`.\n\nThe structure `uniform_space X` bundles a uniform structure on `X`, a topology on `X` and\nan assumption saying those are compatible. This may not seem mathematically reasonable at first,\nbut is in fact an instance of the forgetful inheritance pattern. See Note [forgetful inheritance]\nbelow.\n\n## References\n\nThe formalization uses the books:\n\n* [N. Bourbaki, *General Topology*][bourbaki1966]\n* [I. M. James, *Topologies and Uniformities*][james1999]\n\nBut it makes a more systematic use of the filter library.\n-/\n\nopen set filter classical\nopen_locale classical topology filter\n\nset_option eqn_compiler.zeta true\n\nuniverses u\n\n/-!\n### Relations, seen as `set (α × α)`\n-/\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} {ι : Sort*}\n\n/-- The identity relation, or the graph of the identity function -/\ndef id_rel {α : Type*} := {p : α × α | p.1 = p.2}\n\n@[simp] theorem mem_id_rel {a b : α} : (a, b) ∈ @id_rel α ↔ a = b := iff.rfl\n\n@[simp] theorem id_rel_subset {s : set (α × α)} : id_rel ⊆ s ↔ ∀ a, (a, a) ∈ s :=\nby simp [subset_def]; exact forall_congr (λ a, by simp)\n\n/-- The composition of relations -/\ndef comp_rel {α : Type u} (r₁ r₂ : set (α×α)) := {p : α × α | ∃z:α, (p.1, z) ∈ r₁ ∧ (z, p.2) ∈ r₂}\n\nlocalized \"infix (name := uniformity.comp_rel) ` ○ `:55 := comp_rel\" in uniformity\n\n@[simp] theorem mem_comp_rel {r₁ r₂ : set (α×α)}\n  {x y : α} : (x, y) ∈ r₁ ○ r₂ ↔ ∃ z, (x, z) ∈ r₁ ∧ (z, y) ∈ r₂ := iff.rfl\n\n@[simp] theorem swap_id_rel : prod.swap '' id_rel = @id_rel α :=\nset.ext $ assume ⟨a, b⟩, by simp [image_swap_eq_preimage_swap]; exact eq_comm\n\ntheorem monotone.comp_rel [preorder β] {f g : β → set (α×α)}\n  (hf : monotone f) (hg : monotone g) : monotone (λx, (f x) ○ (g x)) :=\nassume a b h p ⟨z, h₁, h₂⟩, ⟨z, hf h h₁, hg h h₂⟩\n\n@[mono]\nlemma comp_rel_mono {f g h k: set (α×α)} (h₁ : f ⊆ h) (h₂ : g ⊆ k) : f ○ g ⊆ h ○ k :=\nλ ⟨x, y⟩ ⟨z, h, h'⟩, ⟨z, h₁ h, h₂ h'⟩\n\nlemma prod_mk_mem_comp_rel {a b c : α} {s t : set (α×α)} (h₁ : (a, c) ∈ s) (h₂ : (c, b) ∈ t) :\n  (a, b) ∈ s ○ t :=\n⟨c, h₁, h₂⟩\n\n@[simp] lemma id_comp_rel {r : set (α×α)} : id_rel ○ r = r :=\nset.ext $ assume ⟨a, b⟩, by simp\n\nlemma comp_rel_assoc {r s t : set (α×α)} :\n  (r ○ s) ○ t = r ○ (s ○ t) :=\nby ext p; cases p; simp only [mem_comp_rel]; tauto\n\nlemma left_subset_comp_rel {s t : set (α × α)} (h : id_rel ⊆ t) : s ⊆ s ○ t :=\nλ ⟨x, y⟩ xy_in, ⟨y, xy_in, h $ by exact rfl⟩\n\nlemma right_subset_comp_rel {s t : set (α × α)} (h : id_rel ⊆ s) : t ⊆ s ○ t :=\nλ ⟨x, y⟩ xy_in, ⟨x, h $ by exact rfl, xy_in⟩\n\nlemma subset_comp_self {s : set (α × α)} (h : id_rel ⊆ s) : s ⊆ s ○ s :=\nleft_subset_comp_rel h\n\nlemma subset_iterate_comp_rel {s t : set (α × α)} (h : id_rel ⊆ s) (n : ℕ) :\n  t ⊆ (((○) s) ^[n] t) :=\nbegin\n  induction n with n ihn generalizing t,\n  exacts [subset.rfl, (right_subset_comp_rel h).trans ihn]\nend\n\n/-- The relation is invariant under swapping factors. -/\ndef symmetric_rel (V : set (α × α)) : Prop := prod.swap ⁻¹' V = V\n\n/-- The maximal symmetric relation contained in a given relation. -/\ndef symmetrize_rel (V : set (α × α)) : set (α × α) := V ∩ prod.swap ⁻¹' V\n\nlemma symmetric_symmetrize_rel (V : set (α × α)) : symmetric_rel (symmetrize_rel V) :=\nby simp [symmetric_rel, symmetrize_rel, preimage_inter, inter_comm, ← preimage_comp]\n\nlemma symmetrize_rel_subset_self (V : set (α × α)) : symmetrize_rel V ⊆ V :=\nsep_subset _ _\n\n@[mono]\nlemma symmetrize_mono {V W: set (α × α)} (h : V ⊆ W) : symmetrize_rel V ⊆ symmetrize_rel W :=\ninter_subset_inter h $ preimage_mono h\n\nlemma symmetric_rel.mk_mem_comm {V : set (α × α)} (hV : symmetric_rel V) {x y : α} :\n  (x, y) ∈ V ↔ (y, x) ∈ V :=\nset.ext_iff.1 hV (y, x)\n\nlemma symmetric_rel.eq {U : set (α × α)} (hU : symmetric_rel U) : prod.swap ⁻¹' U = U := hU\n\nlemma symmetric_rel.inter {U V : set (α × α)} (hU : symmetric_rel U) (hV : symmetric_rel V) :\n  symmetric_rel (U ∩ V) :=\nby rw [symmetric_rel, preimage_inter, hU.eq, hV.eq]\n\n/-- This core description of a uniform space is outside of the type class hierarchy. It is useful\n  for constructions of uniform spaces, when the topology is derived from the uniform space. -/\nstructure uniform_space.core (α : Type u) :=\n(uniformity : filter (α × α))\n(refl       : 𝓟 id_rel ≤ uniformity)\n(symm       : tendsto prod.swap uniformity uniformity)\n(comp       : uniformity.lift' (λs, s ○ s) ≤ uniformity)\n\n/-- An alternative constructor for `uniform_space.core`. This version unfolds various\n`filter`-related definitions. -/\ndef uniform_space.core.mk' {α : Type u} (U : filter (α × α))\n  (refl : ∀ (r ∈ U) x, (x, x) ∈ r)\n  (symm : ∀ r ∈ U, prod.swap ⁻¹' r ∈ U)\n  (comp : ∀ r ∈ U, ∃ t ∈ U, t ○ t ⊆ r) : uniform_space.core α :=\n⟨U, λ r ru, id_rel_subset.2 (refl _ ru), symm,\n  λ r ru, let ⟨s, hs, hsr⟩ := comp _ ru in mem_of_superset (mem_lift' hs) hsr⟩\n\n/-- Defining an `uniform_space.core` from a filter basis satisfying some uniformity-like axioms. -/\ndef uniform_space.core.mk_of_basis {α : Type u} (B : filter_basis (α × α))\n  (refl : ∀ (r ∈ B) x, (x, x) ∈ r)\n  (symm : ∀ r ∈ B, ∃ t ∈ B, t ⊆ prod.swap ⁻¹' r)\n  (comp : ∀ r ∈ B, ∃ t ∈ B, t ○ t ⊆ r) : uniform_space.core α :=\n{ uniformity := B.filter,\n  refl := B.has_basis.ge_iff.mpr (λ r ru, id_rel_subset.2 $ refl _ ru),\n  symm := (B.has_basis.tendsto_iff B.has_basis).mpr symm,\n  comp := (has_basis.le_basis_iff (B.has_basis.lift' (monotone_id.comp_rel monotone_id))\n    B.has_basis).mpr comp }\n\n/-- A uniform space generates a topological space -/\ndef uniform_space.core.to_topological_space {α : Type u} (u : uniform_space.core α) :\n  topological_space α :=\n{ is_open        := λs, ∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ u.uniformity,\n  is_open_univ   := by simp; intro; exact univ_mem,\n  is_open_inter  :=\n    assume s t hs ht x ⟨xs, xt⟩, by filter_upwards [hs x xs, ht x xt]; simp {contextual := tt},\n  is_open_sUnion :=\n    assume s hs x ⟨t, ts, xt⟩, by filter_upwards [hs t ts x xt] with p ph h using ⟨t, ts, ph h⟩ }\n\nlemma uniform_space.core_eq :\n  ∀{u₁ u₂ : uniform_space.core α}, u₁.uniformity = u₂.uniformity → u₁ = u₂\n| ⟨u₁, _, _, _⟩  ⟨u₂, _, _, _⟩ rfl := by congr\n\n-- the topological structure is embedded in the uniform structure\n-- to avoid instance diamond issues. See Note [forgetful inheritance].\n\n/-- A uniform space is a generalization of the \"uniform\" topological aspects of a\n  metric space. It consists of a filter on `α × α` called the \"uniformity\", which\n  satisfies properties analogous to the reflexivity, symmetry, and triangle properties\n  of a metric.\n\n  A metric space has a natural uniformity, and a uniform space has a natural topology.\n  A topological group also has a natural uniformity, even when it is not metrizable. -/\nclass uniform_space (α : Type u) extends topological_space α, uniform_space.core α :=\n(is_open_uniformity : ∀s, @_root_.is_open _ to_topological_space s ↔\n  (∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ uniformity))\n\n/-- Alternative constructor for `uniform_space α` when a topology is already given. -/\n@[pattern] def uniform_space.mk' {α} (t : topological_space α)\n  (c : uniform_space.core α)\n  (is_open_uniformity : ∀s:set α, is_open s ↔\n    (∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ c.uniformity)) :\n  uniform_space α := ⟨c, is_open_uniformity⟩\n\n/-- Construct a `uniform_space` from a `uniform_space.core`. -/\ndef uniform_space.of_core {α : Type u} (u : uniform_space.core α) : uniform_space α :=\n{ to_core := u,\n  to_topological_space := u.to_topological_space,\n  is_open_uniformity := assume a, iff.rfl }\n\n/-- Construct a `uniform_space` from a `u : uniform_space.core` and a `topological_space` structure\nthat is equal to `u.to_topological_space`. -/\ndef uniform_space.of_core_eq {α : Type u} (u : uniform_space.core α) (t : topological_space α)\n  (h : t = u.to_topological_space) : uniform_space α :=\n{ to_core := u,\n  to_topological_space := t,\n  is_open_uniformity := assume a, h.symm ▸ iff.rfl }\n\nlemma uniform_space.to_core_to_topological_space (u : uniform_space α) :\n  u.to_core.to_topological_space = u.to_topological_space :=\ntopological_space_eq $ funext $ λ s, by rw [uniform_space.is_open_uniformity, is_open_mk]\n\n/-- The uniformity is a filter on α × α (inferred from an ambient uniform space\n  structure on α). -/\ndef uniformity (α : Type u) [uniform_space α] : filter (α × α) :=\n  (@uniform_space.to_core α _).uniformity\n\nlocalized \"notation (name := uniformity_of) `𝓤[` u `]` := @uniformity hole! u\" in topology\n\n@[ext]\nlemma uniform_space_eq : ∀ {u₁ u₂ : uniform_space α}, 𝓤[u₁] = 𝓤[u₂] → u₁ = u₂\n| (uniform_space.mk' t₁ u₁ o₁)  (uniform_space.mk' t₂ u₂ o₂) h :=\n  have u₁ = u₂, from uniform_space.core_eq h,\n  have t₁ = t₂, from topological_space_eq $ funext $ assume s, by rw [o₁, o₂]; simp [this],\n  by simp [*]\n\nlemma uniform_space.of_core_eq_to_core\n  (u : uniform_space α) (t : topological_space α) (h : t = u.to_core.to_topological_space) :\n  uniform_space.of_core_eq u.to_core t h = u :=\nuniform_space_eq rfl\n\n/-- Replace topology in a `uniform_space` instance with a propositionally (but possibly not\ndefinitionally) equal one. -/\n@[reducible] def uniform_space.replace_topology {α : Type*} [i : topological_space α]\n  (u : uniform_space α) (h : i = u.to_topological_space) : uniform_space α :=\nuniform_space.of_core_eq u.to_core i $ h.trans u.to_core_to_topological_space.symm\n\nlemma uniform_space.replace_topology_eq {α : Type*} [i : topological_space α] (u : uniform_space α)\n  (h : i = u.to_topological_space) : u.replace_topology h = u :=\nu.of_core_eq_to_core _ _\n\n/-- Define a `uniform_space` using a \"distance\" function. The function can be, e.g., the distance in\na (usual or extended) metric space or an absolute value on a ring. -/\ndef uniform_space.of_fun {α β : Type*} [ordered_add_comm_monoid β]\n  (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x)\n  (triangle : ∀ x y z, d x z ≤ d x y + d y z)\n  (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) :\n  uniform_space α :=\nuniform_space.of_core\n  { uniformity := ⨅ r > 0, 𝓟 { x | d x.1 x.2 < r },\n    refl := le_infi₂ $ λ r hr, principal_mono.2 $ id_rel_subset.2 $ λ x, by simpa [refl],\n    symm := tendsto_infi_infi $ λ r, tendsto_infi_infi $ λ _, tendsto_principal_principal.2 $\n      λ x hx, by rwa [mem_set_of, symm],\n    comp := le_infi₂ $ λ r hr, let ⟨δ, h0, hδr⟩ := half r hr in le_principal_iff.2 $ mem_of_superset\n      (mem_lift' $ mem_infi_of_mem δ $ mem_infi_of_mem h0 $ mem_principal_self _) $\n      λ ⟨x, z⟩ ⟨y, h₁, h₂⟩, (triangle _ _ _).trans_lt (hδr _ h₁ _ h₂) }\n\nlemma uniform_space.has_basis_of_fun {α β : Type*} [linear_ordered_add_comm_monoid β]\n  (h₀ : ∃ x : β, 0 < x) (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x)\n  (triangle : ∀ x y z, d x z ≤ d x y + d y z)\n  (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) :\n  𝓤[uniform_space.of_fun d refl symm triangle half].has_basis ((<) (0 : β))\n    (λ ε, { x | d x.1 x.2 < ε }) :=\nhas_basis_binfi_principal'\n  (λ ε₁ h₁ ε₂ h₂, ⟨min ε₁ ε₂, lt_min h₁ h₂, λ _x hx, lt_of_lt_of_le hx (min_le_left _ _),\n    λ _x hx, lt_of_lt_of_le hx (min_le_right _ _)⟩) h₀\n\nsection uniform_space\nvariables [uniform_space α]\n\nlocalized \"notation (name := uniformity) `𝓤` := uniformity\" in uniformity\n\nlemma is_open_uniformity {s : set α} :\n  is_open s ↔ (∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α) :=\nuniform_space.is_open_uniformity s\n\nlemma refl_le_uniformity : 𝓟 id_rel ≤ 𝓤 α :=\n(@uniform_space.to_core α _).refl\n\ninstance uniformity.ne_bot [nonempty α] : ne_bot (𝓤 α) :=\ndiagonal_nonempty.principal_ne_bot.mono refl_le_uniformity\n\nlemma refl_mem_uniformity {x : α} {s : set (α × α)} (h : s ∈ 𝓤 α) :\n  (x, x) ∈ s :=\nrefl_le_uniformity h rfl\n\nlemma mem_uniformity_of_eq {x y : α} {s : set (α × α)} (h : s ∈ 𝓤 α) (hx : x = y) :\n  (x, y) ∈ s :=\nrefl_le_uniformity h hx\n\nlemma symm_le_uniformity : map (@prod.swap α α) (𝓤 _) ≤ (𝓤 _) :=\n(@uniform_space.to_core α _).symm\n\nlemma comp_le_uniformity : (𝓤 α).lift' (λs:set (α×α), s ○ s) ≤ 𝓤 α :=\n(@uniform_space.to_core α _).comp\n\nlemma tendsto_swap_uniformity : tendsto (@prod.swap α α) (𝓤 α) (𝓤 α) :=\nsymm_le_uniformity\n\nlemma comp_mem_uniformity_sets {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, t ○ t ⊆ s :=\nhave s ∈ (𝓤 α).lift' (λt:set (α×α), t ○ t),\n  from comp_le_uniformity hs,\n(mem_lift'_sets $ monotone_id.comp_rel monotone_id).mp this\n\n/-- If `s ∈ 𝓤 α`, then for any natural `n`, for a subset `t` of a sufficiently small set in `𝓤 α`,\nwe have `t ○ t ○ ... ○ t ⊆ s` (`n` compositions). -/\nlemma eventually_uniformity_iterate_comp_subset {s : set (α × α)} (hs : s ∈ 𝓤 α) (n : ℕ) :\n  ∀ᶠ t in (𝓤 α).small_sets, ((○) t) ^[n] t ⊆ s :=\nbegin\n  suffices : ∀ᶠ t in (𝓤 α).small_sets, t ⊆ s ∧ (((○) t) ^[n] t ⊆ s),\n    from (eventually_and.1 this).2,\n  induction n with n ihn generalizing s, { simpa },\n  rcases comp_mem_uniformity_sets hs with ⟨t, htU, hts⟩,\n  refine (ihn htU).mono (λ U hU, _),\n  rw [function.iterate_succ_apply'],\n  exact ⟨hU.1.trans $ (subset_comp_self $ refl_le_uniformity htU).trans hts,\n    (comp_rel_mono hU.1 hU.2).trans hts⟩\nend\n\n/-- If `s ∈ 𝓤 α`, then for any natural `n`, for a subset `t` of a sufficiently small set in `𝓤 α`,\nwe have `t ○ t ⊆ s`. -/\nlemma eventually_uniformity_comp_subset {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∀ᶠ t in (𝓤 α).small_sets, t ○ t ⊆ s :=\neventually_uniformity_iterate_comp_subset hs 1\n\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is transitive. -/\nlemma filter.tendsto.uniformity_trans {l : filter β} {f₁ f₂ f₃ : β → α}\n  (h₁₂ : tendsto (λ x, (f₁ x, f₂ x)) l (𝓤 α)) (h₂₃ : tendsto (λ x, (f₂ x, f₃ x)) l (𝓤 α)) :\n  tendsto (λ x, (f₁ x, f₃ x)) l (𝓤 α) :=\nbegin\n  refine le_trans (le_lift'.2 $ λ s hs, mem_map.2 _) comp_le_uniformity,\n  filter_upwards [h₁₂ hs, h₂₃ hs] with x hx₁₂ hx₂₃ using ⟨_, hx₁₂, hx₂₃⟩,\nend\n\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is symmetric -/\nlemma filter.tendsto.uniformity_symm {l : filter β} {f : β → α × α}\n  (h : tendsto f l (𝓤 α)) :\n  tendsto (λ x, ((f x).2, (f x).1)) l (𝓤 α) :=\ntendsto_swap_uniformity.comp h\n\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is reflexive. -/\nlemma tendsto_diag_uniformity (f : β → α) (l : filter β) :\n  tendsto (λ x, (f x, f x)) l (𝓤 α) :=\nassume s hs, mem_map.2 $ univ_mem' $ λ x, refl_mem_uniformity hs\n\nlemma tendsto_const_uniformity {a : α} {f : filter β} : tendsto (λ _, (a, a)) f (𝓤 α) :=\ntendsto_diag_uniformity (λ _, a) f\n\nlemma symm_of_uniformity {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, (∀a b, (a, b) ∈ t → (b, a) ∈ t) ∧ t ⊆ s :=\nhave preimage prod.swap s ∈ 𝓤 α, from symm_le_uniformity hs,\n⟨s ∩ preimage prod.swap s, inter_mem hs this, λ a b ⟨h₁, h₂⟩, ⟨h₂, h₁⟩, inter_subset_left _ _⟩\n\nlemma comp_symm_of_uniformity {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, (∀{a b}, (a, b) ∈ t → (b, a) ∈ t) ∧ t ○ t ⊆ s :=\nlet ⟨t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs in\nlet ⟨t', ht', ht'₁, ht'₂⟩ := symm_of_uniformity ht₁ in\n⟨t', ht', ht'₁, subset.trans (monotone_id.comp_rel monotone_id ht'₂) ht₂⟩\n\nlemma uniformity_le_symm : 𝓤 α ≤ (@prod.swap α α) <$> 𝓤 α :=\nby rw [map_swap_eq_comap_swap];\nfrom map_le_iff_le_comap.1 tendsto_swap_uniformity\n\nlemma uniformity_eq_symm : 𝓤 α = (@prod.swap α α) <$> 𝓤 α :=\nle_antisymm uniformity_le_symm symm_le_uniformity\n\n@[simp] lemma comap_swap_uniformity : comap (@prod.swap α α) (𝓤 α) = 𝓤 α :=\n(congr_arg _ uniformity_eq_symm).trans $ comap_map prod.swap_injective\n\nlemma symmetrize_mem_uniformity {V : set (α × α)} (h : V ∈ 𝓤 α) : symmetrize_rel V ∈ 𝓤 α :=\nbegin\n  apply (𝓤 α).inter_sets h,\n  rw [← image_swap_eq_preimage_swap, uniformity_eq_symm],\n  exact image_mem_map h,\nend\n\n/-- Symmetric entourages form a basis of `𝓤 α` -/\nlemma uniform_space.has_basis_symmetric :\n  (𝓤 α).has_basis (λ s : set (α × α), s ∈ 𝓤 α ∧ symmetric_rel s) id :=\nhas_basis_self.2 $ λ t t_in, ⟨symmetrize_rel t, symmetrize_mem_uniformity t_in,\n  symmetric_symmetrize_rel t, symmetrize_rel_subset_self t⟩\n\ntheorem uniformity_lift_le_swap {g : set (α×α) → filter β} {f : filter β} (hg : monotone g)\n  (h : (𝓤 α).lift (λs, g (preimage prod.swap s)) ≤ f) : (𝓤 α).lift g ≤ f :=\ncalc (𝓤 α).lift g ≤ (filter.map (@prod.swap α α) $ 𝓤 α).lift g :\n    lift_mono uniformity_le_symm le_rfl\n  ... ≤ _ :\n    by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h\n\nlemma uniformity_lift_le_comp {f : set (α×α) → filter β} (h : monotone f) :\n  (𝓤 α).lift (λs, f (s ○ s)) ≤ (𝓤 α).lift f :=\ncalc (𝓤 α).lift (λs, f (s ○ s)) =\n    ((𝓤 α).lift' (λs:set (α×α), s ○ s)).lift f :\n  begin\n    rw [lift_lift'_assoc],\n    exact monotone_id.comp_rel monotone_id,\n    exact h\n  end\n  ... ≤ (𝓤 α).lift f : lift_mono comp_le_uniformity le_rfl\n\nlemma comp_le_uniformity3 :\n  (𝓤 α).lift' (λs:set (α×α), s ○ (s ○ s)) ≤ (𝓤 α) :=\ncalc (𝓤 α).lift' (λd, d ○ (d ○ d)) =\n  (𝓤 α).lift (λs, (𝓤 α).lift' (λt:set(α×α), s ○ (t ○ t))) :\n  begin\n    rw [lift_lift'_same_eq_lift'],\n    exact (assume x, monotone_const.comp_rel $ monotone_id.comp_rel monotone_id),\n    exact (assume x, monotone_id.comp_rel monotone_const),\n  end\n  ... ≤ (𝓤 α).lift (λs, (𝓤 α).lift' (λt:set(α×α), s ○ t)) :\n    lift_mono' $ assume s hs, @uniformity_lift_le_comp α _ _ (𝓟 ∘ (○) s) $\n      monotone_principal.comp (monotone_const.comp_rel monotone_id)\n  ... = (𝓤 α).lift' (λs:set(α×α), s ○ s) :\n    lift_lift'_same_eq_lift'\n      (assume s, monotone_const.comp_rel monotone_id)\n      (assume s, monotone_id.comp_rel monotone_const)\n  ... ≤ (𝓤 α) : comp_le_uniformity\n\n/-- See also `comp_open_symm_mem_uniformity_sets`. -/\nlemma comp_symm_mem_uniformity_sets {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, symmetric_rel t ∧ t ○ t ⊆ s :=\nbegin\n  obtain ⟨w, w_in, w_sub⟩ : ∃ w ∈ 𝓤 α, w ○ w ⊆ s := comp_mem_uniformity_sets hs,\n  use [symmetrize_rel w, symmetrize_mem_uniformity w_in, symmetric_symmetrize_rel w],\n  have : symmetrize_rel w ⊆ w := symmetrize_rel_subset_self w,\n  calc symmetrize_rel w ○ symmetrize_rel w ⊆ w ○ w : by mono\n                                       ... ⊆ s     : w_sub,\nend\n\nlemma subset_comp_self_of_mem_uniformity {s : set (α × α)} (h : s ∈ 𝓤 α) : s ⊆ s ○ s :=\nsubset_comp_self (refl_le_uniformity h)\n\nlemma comp_comp_symm_mem_uniformity_sets {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, symmetric_rel t ∧ t ○ t ○ t ⊆ s :=\nbegin\n  rcases comp_symm_mem_uniformity_sets hs with ⟨w, w_in, w_symm, w_sub⟩,\n  rcases comp_symm_mem_uniformity_sets w_in with ⟨t, t_in, t_symm, t_sub⟩,\n  use [t, t_in, t_symm],\n  have : t ⊆ t ○ t :=  subset_comp_self_of_mem_uniformity t_in,\n  calc\n  t ○ t ○ t ⊆ w ○ t       : by mono\n        ... ⊆ w ○ (t ○ t) : by mono\n        ... ⊆ w ○ w       : by mono\n        ... ⊆ s           : w_sub,\nend\n\n/-!\n### Balls in uniform spaces\n-/\n\n/-- The ball around `(x : β)` with respect to `(V : set (β × β))`. Intended to be\nused for `V ∈ 𝓤 β`, but this is not needed for the definition. Recovers the\nnotions of metric space ball when `V = {p | dist p.1 p.2 < r }`.  -/\ndef uniform_space.ball (x : β) (V : set (β × β)) : set β := (prod.mk x) ⁻¹' V\n\nopen uniform_space (ball)\n\nlemma uniform_space.mem_ball_self (x : α) {V : set (α × α)} (hV : V ∈ 𝓤 α) :\n  x ∈ ball x V :=\nrefl_mem_uniformity hV\n\n/-- The triangle inequality for `uniform_space.ball` -/\nlemma mem_ball_comp {V W : set (β × β)} {x y z} (h : y ∈ ball x V) (h' : z ∈ ball y W) :\n  z ∈ ball x (V ○ W) :=\nprod_mk_mem_comp_rel h h'\n\nlemma ball_subset_of_comp_subset {V W : set (β × β)} {x y} (h : x ∈ ball y W) (h' : W ○ W ⊆ V) :\n  ball x W ⊆ ball y V :=\nλ z z_in, h' (mem_ball_comp h z_in)\n\nlemma ball_mono {V W : set (β × β)} (h : V ⊆ W) (x : β) : ball x V ⊆ ball x W :=\npreimage_mono h\n\nlemma ball_inter (x : β) (V W : set (β × β)) : ball x (V ∩ W) = ball x V ∩ ball x W :=\npreimage_inter\n\nlemma ball_inter_left (x : β) (V W : set (β × β)) : ball x (V ∩ W) ⊆ ball x V :=\nball_mono (inter_subset_left V W) x\n\nlemma ball_inter_right (x : β) (V W : set (β × β)) : ball x (V ∩ W) ⊆ ball x W :=\nball_mono (inter_subset_right V W) x\n\nlemma mem_ball_symmetry {V : set (β × β)} (hV : symmetric_rel V) {x y} :\n  x ∈ ball y V ↔ y ∈ ball x V :=\nshow (x, y) ∈ prod.swap ⁻¹' V ↔ (x, y) ∈ V, by { unfold symmetric_rel at hV, rw hV }\n\nlemma ball_eq_of_symmetry {V : set (β × β)} (hV : symmetric_rel V) {x} :\n  ball x V = {y | (y, x) ∈ V} :=\nby { ext y, rw mem_ball_symmetry hV, exact iff.rfl }\n\nlemma mem_comp_of_mem_ball {V W : set (β × β)} {x y z : β} (hV : symmetric_rel V)\n  (hx : x ∈ ball z V) (hy : y ∈ ball z W) : (x, y) ∈ V ○ W :=\nbegin\n  rw mem_ball_symmetry hV at hx,\n  exact ⟨z, hx, hy⟩\nend\n\nlemma uniform_space.is_open_ball (x : α) {V : set (α × α)} (hV : is_open V) :\n  is_open (ball x V) :=\nhV.preimage $ continuous_const.prod_mk continuous_id\n\nlemma mem_comp_comp {V W M : set (β × β)} (hW' : symmetric_rel W) {p : β × β} :\n  p ∈ V ○ M ○ W ↔ ((ball p.1 V ×ˢ ball p.2 W) ∩ M).nonempty :=\nbegin\n  cases p with x y,\n  split,\n  { rintros ⟨z, ⟨w, hpw, hwz⟩, hzy⟩,\n    exact ⟨(w, z), ⟨hpw, by rwa mem_ball_symmetry hW'⟩, hwz⟩, },\n  { rintro ⟨⟨w, z⟩, ⟨w_in, z_in⟩, hwz⟩,\n    rwa mem_ball_symmetry hW' at z_in,\n    use [z, w] ; tauto },\nend\n\n/-!\n### Neighborhoods in uniform spaces\n-/\n\nlemma mem_nhds_uniformity_iff_right {x : α} {s : set α} :\n  s ∈ 𝓝 x ↔ {p : α × α | p.1 = x → p.2 ∈ s} ∈ 𝓤 α :=\nbegin\n  refine ⟨_, λ hs, _⟩,\n  { simp only [mem_nhds_iff, is_open_uniformity, and_imp, exists_imp_distrib],\n    intros t ts ht xt,\n    filter_upwards [ht x xt] using λ y h eq, ts (h eq) },\n  { refine mem_nhds_iff.mpr ⟨{x | {p : α × α | p.1 = x → p.2 ∈ s} ∈ 𝓤 α}, _, _, hs⟩,\n    { exact λ y hy, refl_mem_uniformity hy rfl },\n    { refine is_open_uniformity.mpr (λ y hy, _),\n      rcases comp_mem_uniformity_sets hy with ⟨t, ht, tr⟩,\n      filter_upwards [ht], rintro ⟨a, b⟩ hp' rfl,\n      filter_upwards [ht], rintro ⟨a', b'⟩ hp'' rfl,\n      exact @tr (a, b') ⟨a', hp', hp''⟩ rfl } }\nend\n\nlemma mem_nhds_uniformity_iff_left {x : α} {s : set α} :\n  s ∈ 𝓝 x ↔ {p : α × α | p.2 = x → p.1 ∈ s} ∈ 𝓤 α :=\nby { rw [uniformity_eq_symm, mem_nhds_uniformity_iff_right], refl }\n\nlemma nhds_eq_comap_uniformity {x : α} : 𝓝 x = (𝓤 α).comap (prod.mk x) :=\nby { ext s, rw [mem_nhds_uniformity_iff_right, mem_comap_prod_mk] }\n\n/-- See also `is_open_iff_open_ball_subset`. -/\nlemma is_open_iff_ball_subset {s : set α} : is_open s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 α, ball x V ⊆ s :=\nbegin\n  simp_rw [is_open_iff_mem_nhds, nhds_eq_comap_uniformity],\n  exact iff.rfl,\nend\n\nlemma nhds_basis_uniformity' {p : ι → Prop} {s : ι → set (α × α)} (h : (𝓤 α).has_basis p s)\n  {x : α} :\n  (𝓝 x).has_basis p (λ i, ball x (s i)) :=\nby { rw [nhds_eq_comap_uniformity], exact h.comap (prod.mk x) }\n\nlemma nhds_basis_uniformity {p : ι → Prop} {s : ι → set (α × α)} (h : (𝓤 α).has_basis p s) {x : α} :\n  (𝓝 x).has_basis p (λ i, {y | (y, x) ∈ s i}) :=\nbegin\n  replace h := h.comap prod.swap,\n  rw [← map_swap_eq_comap_swap, ← uniformity_eq_symm] at h,\n  exact nhds_basis_uniformity' h\nend\n\nlemma nhds_eq_comap_uniformity' {x : α} : 𝓝 x = (𝓤 α).comap (λ y, (y, x)) :=\n(nhds_basis_uniformity (𝓤 α).basis_sets).eq_of_same_basis $ (𝓤 α).basis_sets.comap _\n\nlemma uniform_space.mem_nhds_iff {x : α} {s : set α} : s ∈ 𝓝 x ↔ ∃ V ∈ 𝓤 α, ball x V ⊆ s :=\nbegin\n  rw [nhds_eq_comap_uniformity, mem_comap],\n  exact iff.rfl,\nend\n\nlemma uniform_space.ball_mem_nhds (x : α) ⦃V : set (α × α)⦄ (V_in : V ∈ 𝓤 α) : ball x V ∈ 𝓝 x :=\nbegin\n  rw uniform_space.mem_nhds_iff,\n  exact ⟨V, V_in, subset.refl _⟩\nend\n\nlemma uniform_space.mem_nhds_iff_symm {x : α} {s : set α} :\n  s ∈ 𝓝 x ↔ ∃ V ∈ 𝓤 α, symmetric_rel V ∧ ball x V ⊆ s :=\nbegin\n  rw uniform_space.mem_nhds_iff,\n  split,\n  { rintros ⟨V, V_in, V_sub⟩,\n    use [symmetrize_rel V, symmetrize_mem_uniformity V_in, symmetric_symmetrize_rel V],\n    exact subset.trans (ball_mono (symmetrize_rel_subset_self V) x) V_sub },\n  { rintros ⟨V, V_in, V_symm, V_sub⟩,\n    exact ⟨V, V_in, V_sub⟩ }\nend\n\nlemma uniform_space.has_basis_nhds (x : α) :\n  has_basis (𝓝 x) (λ s : set (α × α), s ∈ 𝓤 α ∧ symmetric_rel s) (λ s, ball x s) :=\n⟨λ t, by simp [uniform_space.mem_nhds_iff_symm, and_assoc]⟩\n\nopen uniform_space\n\nlemma uniform_space.mem_closure_iff_symm_ball {s : set α} {x} :\n  x ∈ closure s ↔ ∀ {V}, V ∈ 𝓤 α → symmetric_rel V → (s ∩ ball x V).nonempty :=\nby simp [mem_closure_iff_nhds_basis (has_basis_nhds x), set.nonempty]\n\nlemma uniform_space.mem_closure_iff_ball {s : set α} {x} :\n  x ∈ closure s ↔ ∀ {V}, V ∈ 𝓤 α → (ball x V ∩ s).nonempty :=\nby simp [mem_closure_iff_nhds_basis' (nhds_basis_uniformity' (𝓤 α).basis_sets)]\n\nlemma uniform_space.has_basis_nhds_prod (x y : α) :\n  has_basis (𝓝 (x, y)) (λ s, s ∈ 𝓤 α ∧ symmetric_rel s) $ λ s, ball x s ×ˢ ball y s :=\nbegin\n  rw nhds_prod_eq,\n  apply (has_basis_nhds x).prod_same_index (has_basis_nhds y),\n  rintro U V ⟨U_in, U_symm⟩ ⟨V_in, V_symm⟩,\n  exact ⟨U ∩ V, ⟨(𝓤 α).inter_sets U_in V_in, U_symm.inter V_symm⟩,\n         ball_inter_left x U V, ball_inter_right y U V⟩,\nend\n\nlemma nhds_eq_uniformity {x : α} : 𝓝 x = (𝓤 α).lift' (ball x) :=\n(nhds_basis_uniformity' (𝓤 α).basis_sets).eq_binfi\n\nlemma nhds_eq_uniformity' {x : α} : 𝓝 x = (𝓤 α).lift' (λ s, {y | (y, x) ∈ s}) :=\n(nhds_basis_uniformity (𝓤 α).basis_sets).eq_binfi\n\nlemma mem_nhds_left (x : α) {s : set (α×α)} (h : s ∈ 𝓤 α) :\n  {y : α | (x, y) ∈ s} ∈ 𝓝 x :=\nball_mem_nhds x h\n\nlemma mem_nhds_right (y : α) {s : set (α×α)} (h : s ∈ 𝓤 α) :\n  {x : α | (x, y) ∈ s} ∈ 𝓝 y :=\nmem_nhds_left _ (symm_le_uniformity h)\n\nlemma exists_mem_nhds_ball_subset_of_mem_nhds {a : α} {U : set α} (h : U ∈ 𝓝 a) :\n  ∃ (V ∈ 𝓝 a) (t ∈ 𝓤 α), ∀ a' ∈ V, uniform_space.ball a' t ⊆ U :=\nlet ⟨t, ht, htU⟩ := comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 h) in\n⟨_, mem_nhds_left a ht, t, ht, λ a₁ h₁ a₂ h₂, @htU (a, a₂) ⟨a₁, h₁, h₂⟩ rfl⟩\n\nlemma is_compact.nhds_set_basis_uniformity {p : ι → Prop} {s : ι → set (α × α)}\n  (hU : (𝓤 α).has_basis p s) {K : set α} (hK : is_compact K) :\n  (𝓝ˢ K).has_basis p (λ i, ⋃ x ∈ K, ball x (s i)) :=\nbegin\n  refine ⟨λ U, _⟩,\n  simp only [mem_nhds_set_iff_forall, (nhds_basis_uniformity' hU).mem_iff, Union₂_subset_iff],\n  refine ⟨λ H, _, λ ⟨i, hpi, hi⟩ x hx, ⟨i, hpi, hi x hx⟩⟩,\n  replace H : ∀ x ∈ K, ∃ i : {i // p i}, ball x (s i ○ s i) ⊆ U,\n  { intros x hx,\n    rcases H x hx with ⟨i, hpi, hi⟩,\n    rcases comp_mem_uniformity_sets (hU.mem_of_mem hpi) with ⟨t, ht_mem, ht⟩,\n    rcases hU.mem_iff.1 ht_mem with ⟨j, hpj, hj⟩,\n    exact ⟨⟨j, hpj⟩, subset.trans (ball_mono ((comp_rel_mono hj hj).trans ht) _) hi⟩ },\n  haveI : nonempty {a // p a}, from nonempty_subtype.2 hU.ex_mem,\n  choose! I hI using H,\n  rcases hK.elim_nhds_subcover (λ x, ball x $ s (I x))\n    (λ x hx, ball_mem_nhds _ $ hU.mem_of_mem (I x).2) with ⟨t, htK, ht⟩,\n  obtain ⟨i, hpi, hi⟩ : ∃ i (hpi : p i), s i ⊆ ⋂ x ∈ t, s (I x),\n    from hU.mem_iff.1 ((bInter_finset_mem t).2 (λ x hx, hU.mem_of_mem (I x).2)),\n  rw [subset_Inter₂_iff] at hi,\n  refine ⟨i, hpi, λ x hx, _⟩,\n  rcases mem_Union₂.1 (ht hx) with ⟨z, hzt : z ∈ t, hzx : x ∈ ball z (s (I z))⟩,\n  calc ball x (s i) ⊆ ball z (s (I z) ○ s (I z)) : λ y hy, ⟨x, hzx, hi z hzt hy⟩\n                ... ⊆ U                          : hI z (htK z hzt),\nend\n\nlemma disjoint.exists_uniform_thickening {A B : set α}\n  (hA : is_compact A) (hB : is_closed B) (h : disjoint A B) :\n  ∃ V ∈ 𝓤 α, disjoint (⋃ x ∈ A, ball x V) (⋃ x ∈ B, ball x V) :=\nbegin\n  have : Bᶜ ∈ 𝓝ˢ A := hB.is_open_compl.mem_nhds_set.mpr h.le_compl_right,\n  rw (hA.nhds_set_basis_uniformity (filter.basis_sets _)).mem_iff at this,\n  rcases this with ⟨U, hU, hUAB⟩,\n  rcases comp_symm_mem_uniformity_sets hU with ⟨V, hV, hVsymm, hVU⟩,\n  refine ⟨V, hV, set.disjoint_left.mpr $ λ x, _⟩,\n  simp only [mem_Union₂],\n  rintro ⟨a, ha, hxa⟩ ⟨b, hb, hxb⟩,\n  rw mem_ball_symmetry hVsymm at hxa hxb,\n  exact hUAB (mem_Union₂_of_mem ha $ hVU $ mem_comp_of_mem_ball hVsymm hxa hxb) hb\nend\n\nlemma disjoint.exists_uniform_thickening_of_basis {p : ι → Prop} {s : ι → set (α × α)}\n  (hU : (𝓤 α).has_basis p s) {A B : set α}\n  (hA : is_compact A) (hB : is_closed B) (h : disjoint A B) :\n  ∃ i, p i ∧ disjoint (⋃ x ∈ A, ball x (s i)) (⋃ x ∈ B, ball x (s i)) :=\nbegin\n  rcases h.exists_uniform_thickening hA hB with ⟨V, hV, hVAB⟩,\n  rcases hU.mem_iff.1 hV with ⟨i, hi, hiV⟩,\n  exact ⟨i, hi, hVAB.mono\n    (Union₂_mono $ λ a _, ball_mono hiV a) (Union₂_mono $ λ b _, ball_mono hiV b)⟩,\nend\n\nlemma tendsto_right_nhds_uniformity {a : α} : tendsto (λa', (a', a)) (𝓝 a) (𝓤 α) :=\nassume s, mem_nhds_right a\n\nlemma tendsto_left_nhds_uniformity {a : α} : tendsto (λa', (a, a')) (𝓝 a) (𝓤 α) :=\nassume s, mem_nhds_left a\n\nlemma lift_nhds_left {x : α} {g : set α → filter β} (hg : monotone g) :\n  (𝓝 x).lift g = (𝓤 α).lift (λs:set (α×α), g (ball x s)) :=\nby { rw [nhds_eq_comap_uniformity, comap_lift_eq2 hg], refl }\n\nlemma lift_nhds_right {x : α} {g : set α → filter β} (hg : monotone g) :\n  (𝓝 x).lift g = (𝓤 α).lift (λs:set (α×α), g {y | (y, x) ∈ s}) :=\nby { rw [nhds_eq_comap_uniformity', comap_lift_eq2 hg], refl }\n\nlemma nhds_nhds_eq_uniformity_uniformity_prod {a b : α} :\n  𝓝 a ×ᶠ 𝓝 b =\n  (𝓤 α).lift (λs:set (α×α), (𝓤 α).lift' (λt:set (α×α),\n    {y : α | (y, a) ∈ s} ×ˢ {y : α | (b, y) ∈ t})) :=\nbegin\n  rw [nhds_eq_uniformity', nhds_eq_uniformity, prod_lift'_lift'],\n  exacts [rfl, monotone_preimage, monotone_preimage]\nend\n\nlemma nhds_eq_uniformity_prod {a b : α} :\n  𝓝 (a, b) =\n  (𝓤 α).lift' (λs:set (α×α), {y : α | (y, a) ∈ s} ×ˢ {y : α | (b, y) ∈ s}) :=\nbegin\n  rw [nhds_prod_eq, nhds_nhds_eq_uniformity_uniformity_prod, lift_lift'_same_eq_lift'],\n  { intro s, exact monotone_const.set_prod monotone_preimage },\n  { intro t, exact monotone_preimage.set_prod monotone_const }\nend\n\nlemma nhdset_of_mem_uniformity {d : set (α×α)} (s : set (α×α)) (hd : d ∈ 𝓤 α) :\n  ∃(t : set (α×α)), is_open t ∧ s ⊆ t ∧ t ⊆ {p | ∃x y, (p.1, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.2) ∈ d} :=\nlet cl_d := {p:α×α | ∃x y, (p.1, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.2) ∈ d} in\nhave ∀p ∈ s, ∃t ⊆ cl_d, is_open t ∧ p ∈ t, from\n  assume ⟨x, y⟩ hp, _root_.mem_nhds_iff.mp $\n  show cl_d ∈ 𝓝 (x, y),\n  begin\n    rw [nhds_eq_uniformity_prod, mem_lift'_sets],\n    exact ⟨d, hd, assume ⟨a, b⟩ ⟨ha, hb⟩, ⟨x, y, ha, hp, hb⟩⟩,\n    exact monotone_preimage.set_prod monotone_preimage\n  end,\nhave ∃t:(Π(p:α×α) (h:p ∈ s), set (α×α)),\n    ∀p, ∀h:p ∈ s, t p h ⊆ cl_d ∧ is_open (t p h) ∧ p ∈ t p h,\n  by simp [classical.skolem] at this; simp; assumption,\nmatch this with\n| ⟨t, ht⟩ :=\n  ⟨(⋃ p:α×α, ⋃ h : p ∈ s, t p h : set (α×α)),\n    is_open_Union $ assume (p:α×α), is_open_Union $ assume hp, (ht p hp).right.left,\n    assume ⟨a, b⟩ hp, begin simp; exact ⟨a, b, hp, (ht (a,b) hp).right.right⟩ end,\n    Union_subset $ assume p, Union_subset $ assume hp, (ht p hp).left⟩\nend\n\n/-- Entourages are neighborhoods of the diagonal. -/\nlemma nhds_le_uniformity (x : α) : 𝓝 (x, x) ≤ 𝓤 α :=\nbegin\n  intros V V_in,\n  rcases comp_symm_mem_uniformity_sets V_in with ⟨w, w_in, w_symm, w_sub⟩,\n  have : ball x w ×ˢ ball x w ∈ 𝓝 (x, x),\n  { rw nhds_prod_eq,\n    exact prod_mem_prod (ball_mem_nhds x w_in) (ball_mem_nhds x w_in) },\n  apply mem_of_superset this,\n  rintros ⟨u, v⟩ ⟨u_in, v_in⟩,\n  exact w_sub (mem_comp_of_mem_ball w_symm u_in v_in)\nend\n\n/-- Entourages are neighborhoods of the diagonal. -/\nlemma supr_nhds_le_uniformity : (⨆ x : α, 𝓝 (x, x)) ≤ 𝓤 α :=\nsupr_le nhds_le_uniformity\n\n/-- Entourages are neighborhoods of the diagonal. -/\nlemma nhds_set_diagonal_le_uniformity : 𝓝ˢ (diagonal α) ≤ 𝓤 α :=\n(nhds_set_diagonal α).trans_le supr_nhds_le_uniformity\n\n/-!\n### Closure and interior in uniform spaces\n-/\n\nlemma closure_eq_uniformity (s : set $ α × α) :\n  closure s = ⋂ V ∈ {V | V ∈ 𝓤 α ∧ symmetric_rel V}, V ○ s ○ V :=\nbegin\n  ext ⟨x, y⟩,\n  simp only [mem_closure_iff_nhds_basis (uniform_space.has_basis_nhds_prod x y), mem_Inter,\n    mem_set_of_eq, and_imp, mem_comp_comp, exists_prop, ← mem_inter_iff, inter_comm, set.nonempty]\n    { contextual := tt }\nend\n\nlemma uniformity_has_basis_closed : has_basis (𝓤 α) (λ V : set (α × α), V ∈ 𝓤 α ∧ is_closed V) id :=\nbegin\n  refine filter.has_basis_self.2 (λ t h, _),\n  rcases comp_comp_symm_mem_uniformity_sets h with ⟨w, w_in, w_symm, r⟩,\n  refine ⟨closure w, mem_of_superset w_in subset_closure, is_closed_closure, _⟩,\n  refine subset.trans _ r,\n  rw closure_eq_uniformity,\n  apply Inter_subset_of_subset,\n  apply Inter_subset,\n  exact ⟨w_in, w_symm⟩\nend\n\nlemma uniformity_eq_uniformity_closure : 𝓤 α = (𝓤 α).lift' closure :=\neq.symm $ uniformity_has_basis_closed.lift'_closure_eq_self $ λ _, and.right\n\nlemma filter.has_basis.uniformity_closure {p : ι → Prop} {U : ι → set (α × α)}\n  (h : (𝓤 α).has_basis p U) : (𝓤 α).has_basis p (λ i, closure (U i)) :=\n(@uniformity_eq_uniformity_closure α _).symm ▸ h.lift'_closure\n\n/-- Closed entourages form a basis of the uniformity filter. -/\nlemma uniformity_has_basis_closure : has_basis (𝓤 α) (λ V : set (α × α), V ∈ 𝓤 α) closure :=\n(𝓤 α).basis_sets.uniformity_closure\n\nlemma closure_eq_inter_uniformity {t : set (α×α)} :\n  closure t = (⋂ d ∈ 𝓤 α, d ○ (t ○ d)) :=\ncalc closure t = ⋂ V (hV : V ∈ 𝓤 α ∧ symmetric_rel V), V ○ t ○ V : closure_eq_uniformity t\n... = ⋂ V ∈ 𝓤 α, V ○ t ○ V : eq.symm $ uniform_space.has_basis_symmetric.bInter_mem $\n  λ V₁ V₂ hV, comp_rel_mono (comp_rel_mono hV subset.rfl) hV\n... = ⋂ V ∈ 𝓤 α, V ○ (t ○ V) : by simp only [comp_rel_assoc]\n\nlemma uniformity_eq_uniformity_interior : 𝓤 α = (𝓤 α).lift' interior :=\nle_antisymm\n  (le_infi $ assume d, le_infi $ assume hd,\n    let ⟨s, hs, hs_comp⟩ := (mem_lift'_sets $\n      monotone_id.comp_rel $ monotone_id.comp_rel monotone_id).mp\n        (comp_le_uniformity3 hd) in\n    let ⟨t, ht, hst, ht_comp⟩ := nhdset_of_mem_uniformity s hs in\n    have s ⊆ interior d, from\n      calc s ⊆ t : hst\n       ... ⊆ interior d : ht.subset_interior_iff.mpr $\n        λ x (hx : x ∈ t), let ⟨x, y, h₁, h₂, h₃⟩ := ht_comp hx in hs_comp ⟨x, h₁, y, h₂, h₃⟩,\n    have interior d ∈ 𝓤 α, by filter_upwards [hs] using this,\n    by simp [this])\n  (assume s hs, ((𝓤 α).lift' interior).sets_of_superset (mem_lift' hs) interior_subset)\n\nlemma interior_mem_uniformity {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  interior s ∈ 𝓤 α :=\nby rw [uniformity_eq_uniformity_interior]; exact mem_lift' hs\n\nlemma mem_uniformity_is_closed {s : set (α×α)} (h : s ∈ 𝓤 α) :\n  ∃t ∈ 𝓤 α, is_closed t ∧ t ⊆ s :=\nlet ⟨t, ⟨ht_mem, htc⟩, hts⟩ := uniformity_has_basis_closed.mem_iff.1 h in\n⟨t, ht_mem, htc, hts⟩\n\nlemma is_open_iff_open_ball_subset {s : set α} :\n  is_open s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 α, is_open V ∧ ball x V ⊆ s :=\nbegin\n  rw is_open_iff_ball_subset,\n  split; intros h x hx,\n  { obtain ⟨V, hV, hV'⟩ := h x hx,\n    exact ⟨interior V, interior_mem_uniformity hV, is_open_interior,\n      (ball_mono interior_subset x).trans hV'⟩, },\n  { obtain ⟨V, hV, -, hV'⟩ := h x hx,\n    exact ⟨V, hV, hV'⟩, },\nend\n\n/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/\nlemma dense.bUnion_uniformity_ball {s : set α} {U : set (α × α)} (hs : dense s) (hU : U ∈ 𝓤 α) :\n  (⋃ x ∈ s, ball x U) = univ :=\nbegin\n  refine Union₂_eq_univ_iff.2 (λ y, _),\n  rcases hs.inter_nhds_nonempty (mem_nhds_right y hU) with ⟨x, hxs, hxy : (x, y) ∈ U⟩,\n  exact ⟨x, hxs, hxy⟩\nend\n\n/-!\n### Uniformity bases\n-/\n\n/-- Open elements of `𝓤 α` form a basis of `𝓤 α`. -/\nlemma uniformity_has_basis_open : has_basis (𝓤 α) (λ V : set (α × α), V ∈ 𝓤 α ∧ is_open V) id :=\nhas_basis_self.2 $ λ s hs,\n  ⟨interior s, interior_mem_uniformity hs, is_open_interior, interior_subset⟩\n\nlemma filter.has_basis.mem_uniformity_iff {p : β → Prop} {s : β → set (α×α)}\n  (h : (𝓤 α).has_basis p s) {t : set (α × α)} :\n  t ∈ 𝓤 α ↔ ∃ i (hi : p i), ∀ a b, (a, b) ∈ s i → (a, b) ∈ t :=\nh.mem_iff.trans $ by simp only [prod.forall, subset_def]\n\n/-- Open elements `s : set (α × α)` of `𝓤 α` such that `(x, y) ∈ s ↔ (y, x) ∈ s` form a basis\nof `𝓤 α`. -/\nlemma uniformity_has_basis_open_symmetric :\n  has_basis (𝓤 α) (λ V : set (α × α), V ∈ 𝓤 α ∧ is_open V ∧ symmetric_rel V) id :=\nbegin\n  simp only [← and_assoc],\n  refine uniformity_has_basis_open.restrict (λ s hs, ⟨symmetrize_rel s, _⟩),\n  exact ⟨⟨symmetrize_mem_uniformity hs.1, is_open.inter hs.2 (hs.2.preimage continuous_swap)⟩,\n    symmetric_symmetrize_rel s, symmetrize_rel_subset_self s⟩\nend\n\nlemma comp_open_symm_mem_uniformity_sets {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, is_open t ∧ symmetric_rel t ∧ t ○ t ⊆ s :=\nbegin\n  obtain ⟨t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs,\n  obtain ⟨u, ⟨hu₁, hu₂, hu₃⟩, hu₄ : u ⊆ t⟩ := uniformity_has_basis_open_symmetric.mem_iff.mp ht₁,\n  exact ⟨u, hu₁, hu₂, hu₃, (comp_rel_mono hu₄ hu₄).trans ht₂⟩,\nend\n\nsection\n\nvariable (α)\n\nlemma uniform_space.has_seq_basis [is_countably_generated $ 𝓤 α] :\n  ∃ V : ℕ → set (α × α), has_antitone_basis (𝓤 α) V ∧ ∀ n, symmetric_rel (V n) :=\nlet ⟨U, hsym, hbasis⟩ :=  uniform_space.has_basis_symmetric.exists_antitone_subbasis\nin ⟨U, hbasis, λ n, (hsym n).2⟩\n\nend\n\nlemma filter.has_basis.bInter_bUnion_ball {p : ι → Prop} {U : ι → set (α × α)}\n  (h : has_basis (𝓤 α) p U) (s : set α) :\n  (⋂ i (hi : p i), ⋃ x ∈ s, ball x (U i)) = closure s :=\nbegin\n  ext x,\n  simp [mem_closure_iff_nhds_basis (nhds_basis_uniformity h), ball]\nend\n\n/-! ### Uniform continuity -/\n\n/-- A function `f : α → β` is *uniformly continuous* if `(f x, f y)` tends to the diagonal\nas `(x, y)` tends to the diagonal. In other words, if `x` is sufficiently close to `y`, then\n`f x` is close to `f y` no matter where `x` and `y` are located in `α`. -/\ndef uniform_continuous [uniform_space β] (f : α → β) :=\ntendsto (λx:α×α, (f x.1, f x.2)) (𝓤 α) (𝓤 β)\n\n/-- A function `f : α → β` is *uniformly continuous* on `s : set α` if `(f x, f y)` tends to\nthe diagonal as `(x, y)` tends to the diagonal while remaining in `s ×ˢ s`.\nIn other words, if `x` is sufficiently close to `y`, then `f x` is close to\n`f y` no matter where `x` and `y` are located in `s`.-/\ndef uniform_continuous_on [uniform_space β] (f : α → β) (s : set α) : Prop :=\ntendsto (λ x : α × α, (f x.1, f x.2)) (𝓤 α ⊓ principal (s ×ˢ s)) (𝓤 β)\n\ntheorem uniform_continuous_def [uniform_space β] {f : α → β} :\n  uniform_continuous f ↔ ∀ r ∈ 𝓤 β, { x : α × α | (f x.1, f x.2) ∈ r} ∈ 𝓤 α :=\niff.rfl\n\ntheorem uniform_continuous_iff_eventually [uniform_space β] {f : α → β} :\n  uniform_continuous f ↔ ∀ r ∈ 𝓤 β, ∀ᶠ (x : α × α) in 𝓤 α, (f x.1, f x.2) ∈ r :=\niff.rfl\n\ntheorem uniform_continuous_on_univ [uniform_space β] {f : α → β} :\n  uniform_continuous_on f univ ↔ uniform_continuous f :=\nby rw [uniform_continuous_on, uniform_continuous, univ_prod_univ, principal_univ, inf_top_eq]\n\nlemma uniform_continuous_of_const [uniform_space β] {c : α → β} (h : ∀a b, c a = c b) :\n  uniform_continuous c :=\nhave (λ (x : α × α), (c (x.fst), c (x.snd))) ⁻¹' id_rel = univ, from\n  eq_univ_iff_forall.2 $ assume ⟨a, b⟩, h a b,\nle_trans (map_le_iff_le_comap.2 $ by simp [comap_principal, this, univ_mem]) refl_le_uniformity\n\nlemma uniform_continuous_id : uniform_continuous (@id α) :=\nby simp [uniform_continuous]; exact tendsto_id\n\nlemma uniform_continuous_const [uniform_space β] {b : β} : uniform_continuous (λa:α, b) :=\nuniform_continuous_of_const $ λ _ _, rfl\n\nlemma uniform_continuous.comp [uniform_space β] [uniform_space γ] {g : β → γ} {f : α → β}\n  (hg : uniform_continuous g) (hf : uniform_continuous f) : uniform_continuous (g ∘ f) :=\nhg.comp hf\n\nlemma filter.has_basis.uniform_continuous_iff {ι'} [uniform_space β] {p : ι → Prop}\n  {s : ι → set (α×α)} (ha : (𝓤 α).has_basis p s) {q : ι' → Prop} {t : ι' → set (β×β)}\n  (hb : (𝓤 β).has_basis q t) {f : α → β} :\n  uniform_continuous f ↔ ∀ i (hi : q i), ∃ j (hj : p j), ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ t i :=\n(ha.tendsto_iff hb).trans $ by simp only [prod.forall]\n\nlemma filter.has_basis.uniform_continuous_on_iff {ι'} [uniform_space β] {p : ι → Prop}\n  {s : ι → set (α×α)} (ha : (𝓤 α).has_basis p s) {q : ι' → Prop} {t : ι' → set (β×β)}\n  (hb : (𝓤 β).has_basis q t) {f : α → β} {S : set α} :\n  uniform_continuous_on f S ↔\n    ∀ i (hi : q i), ∃ j (hj : p j), ∀ x y ∈ S, (x, y) ∈ s j → (f x, f y) ∈ t i :=\n((ha.inf_principal (S ×ˢ S)).tendsto_iff hb).trans $\nby simp_rw [prod.forall, set.inter_comm (s _), ball_mem_comm, mem_inter_iff, mem_prod, and_imp]\n\nend uniform_space\n\nopen_locale uniformity\n\nsection constructions\n\ninstance : partial_order (uniform_space α) :=\n{ le          := λt s, t.uniformity ≤ s.uniformity,\n  le_antisymm := assume t s h₁ h₂, uniform_space_eq $ le_antisymm h₁ h₂,\n  le_refl     := assume t, le_rfl,\n  le_trans    := assume a b c h₁ h₂, le_trans h₁ h₂ }\n\ninstance : has_Inf (uniform_space α) :=\n⟨assume s, uniform_space.of_core\n{ uniformity := (⨅u∈s, 𝓤[u]),\n  refl       := le_infi $ assume u, le_infi $ assume hu, u.refl,\n  symm       := le_infi $ assume u, le_infi $ assume hu,\n    le_trans (map_mono $ infi_le_of_le _ $ infi_le _ hu) u.symm,\n  comp       := le_infi $ assume u, le_infi $ assume hu,\n    le_trans (lift'_mono (infi_le_of_le _ $ infi_le _ hu) $ le_rfl) u.comp }⟩\n\nprivate lemma Inf_le {tt : set (uniform_space α)} {t : uniform_space α} (h : t ∈ tt) :\n  Inf tt ≤ t :=\nshow (⨅ u ∈ tt, 𝓤[u]) ≤ 𝓤[t], from infi₂_le t h\n\nprivate lemma le_Inf {tt : set (uniform_space α)} {t : uniform_space α} (h : ∀t'∈tt, t ≤ t') :\n  t ≤ Inf tt :=\nshow 𝓤[t] ≤ (⨅ u ∈ tt, 𝓤[u]), from le_infi₂ h\n\ninstance : has_top (uniform_space α) :=\n⟨uniform_space.of_core { uniformity := ⊤, refl := le_top, symm := le_top, comp := le_top }⟩\n\ninstance : has_bot (uniform_space α) :=\n⟨{ to_topological_space := ⊥,\n  uniformity  := 𝓟 id_rel,\n  refl        := le_rfl,\n  symm        := by simp [tendsto],\n  comp        := lift'_le (mem_principal_self _) $ principal_mono.2 id_comp_rel.subset,\n  is_open_uniformity :=\n    assume s, by simp [is_open_fold, subset_def, id_rel] {contextual := tt } } ⟩\n\ninstance : has_inf (uniform_space α) :=\n⟨λ u₁ u₂,\n  @uniform_space.replace_topology _\n    (u₁.to_topological_space ⊓ u₂.to_topological_space) (uniform_space.of_core\n    { uniformity  := u₁.uniformity ⊓ u₂.uniformity,\n      refl        := le_inf u₁.refl u₂.refl,\n      symm        := u₁.symm.inf u₂.symm,\n      comp        := (lift'_inf_le _ _ _).trans $ inf_le_inf u₁.comp u₂.comp }) $\n    eq_of_nhds_eq_nhds $ λ a,\n      by simpa only [nhds_inf, nhds_eq_comap_uniformity] using comap_inf.symm⟩\n\ninstance : complete_lattice (uniform_space α) :=\n{ sup           := λa b, Inf {x | a ≤ x ∧ b ≤ x},\n  le_sup_left   := λ a b, le_Inf (λ _ ⟨h, _⟩, h),\n  le_sup_right  := λ a b, le_Inf (λ _ ⟨_, h⟩, h),\n  sup_le        := λ a b c h₁ h₂, Inf_le ⟨h₁, h₂⟩,\n  inf           := (⊓),\n  le_inf        := λ a b c h₁ h₂, show a.uniformity ≤ _, from le_inf h₁ h₂,\n  inf_le_left   := λ a b, show _ ≤ a.uniformity, from inf_le_left,\n  inf_le_right  := λ a b, show _ ≤ b.uniformity, from inf_le_right,\n  top           := ⊤,\n  le_top        := λ a, show a.uniformity ≤ ⊤, from le_top,\n  bot           := ⊥,\n  bot_le        := λ u, u.refl,\n  Sup           := λ tt, Inf {t | ∀ t' ∈ tt, t' ≤ t},\n  le_Sup        := λ s u h, le_Inf (λ u' h', h' u h),\n  Sup_le        := λ s u h, Inf_le h,\n  Inf           := Inf,\n  le_Inf        := λ s a hs, le_Inf hs,\n  Inf_le        := λ s a ha, Inf_le ha,\n  ..uniform_space.partial_order }\n\nlemma infi_uniformity {ι : Sort*} {u : ι → uniform_space α} : 𝓤[infi u] = (⨅i, 𝓤[u i]) :=\ninfi_range\n\nlemma inf_uniformity {u v : uniform_space α} : 𝓤[u ⊓ v] = 𝓤[u] ⊓ 𝓤[v] := rfl\n\ninstance inhabited_uniform_space : inhabited (uniform_space α) := ⟨⊥⟩\ninstance inhabited_uniform_space_core : inhabited (uniform_space.core α) :=\n⟨@uniform_space.to_core _ default⟩\n\n/-- Given `f : α → β` and a uniformity `u` on `β`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `α × α → β × β`. -/\ndef uniform_space.comap (f : α → β) (u : uniform_space β) : uniform_space α :=\n{ uniformity := 𝓤[u].comap (λp:α×α, (f p.1, f p.2)),\n  to_topological_space := u.to_topological_space.induced f,\n  refl := le_trans (by simp; exact assume ⟨a, b⟩ (h : a = b), h ▸ rfl) (comap_mono u.refl),\n  symm := by simp [tendsto_comap_iff, prod.swap, (∘)];\n            exact tendsto_swap_uniformity.comp tendsto_comap,\n  comp := le_trans\n    begin\n      rw [comap_lift'_eq, comap_lift'_eq2],\n      exact (lift'_mono' $ assume s hs ⟨a₁, a₂⟩ ⟨x, h₁, h₂⟩, ⟨f x, h₁, h₂⟩),\n      exact monotone_id.comp_rel monotone_id\n    end\n    (comap_mono u.comp),\n  is_open_uniformity := λ s, by simp only [is_open_fold, is_open_induced, is_open_iff_mem_nhds,\n    nhds_induced, nhds_eq_comap_uniformity, comap_comap, ← mem_comap_prod_mk, ← uniformity] }\n\nlemma uniformity_comap [uniform_space β] (f : α → β) :\n  𝓤[uniform_space.comap f ‹_›] = comap (prod.map f f) (𝓤 β) :=\nrfl\n\n@[simp] lemma uniform_space_comap_id {α : Type*} : uniform_space.comap (id : α → α) = id :=\nby { ext : 2, rw [uniformity_comap, prod.map_id, comap_id] }\n\nlemma uniform_space.comap_comap {α β γ} [uγ : uniform_space γ] {f : α → β} {g : β → γ} :\n  uniform_space.comap (g ∘ f) uγ = uniform_space.comap f (uniform_space.comap g uγ) :=\nby { ext1, simp only [uniformity_comap, comap_comap, prod.map_comp_map] }\n\nlemma uniform_space.comap_inf {α γ} {u₁ u₂ : uniform_space γ} {f : α → γ} :\n  (u₁ ⊓ u₂).comap f = u₁.comap f ⊓ u₂.comap f :=\nuniform_space_eq comap_inf\n\nlemma uniform_space.comap_infi {ι α γ} {u : ι → uniform_space γ} {f : α → γ} :\n  (⨅ i, u i).comap f = ⨅ i, (u i).comap f :=\nbegin\n  ext : 1,\n  simp [uniformity_comap, infi_uniformity]\nend\n\nlemma uniform_space.comap_mono {α γ} {f : α → γ} :\n  monotone (λ u : uniform_space γ, u.comap f) :=\nbegin\n  intros u₁ u₂ hu,\n  change (𝓤 _) ≤ (𝓤 _),\n  rw uniformity_comap,\n  exact comap_mono hu\nend\n\nlemma uniform_continuous_iff {α β} {uα : uniform_space α} {uβ : uniform_space β} {f : α → β} :\n  uniform_continuous f ↔ uα ≤ uβ.comap f :=\nfilter.map_le_iff_le_comap\n\nlemma le_iff_uniform_continuous_id {u v : uniform_space α} :\n  u ≤ v ↔ @uniform_continuous _ _ u v id :=\nby rw [uniform_continuous_iff, uniform_space_comap_id, id]\n\nlemma uniform_continuous_comap {f : α → β} [u : uniform_space β] :\n  @uniform_continuous α β (uniform_space.comap f u) u f :=\ntendsto_comap\n\ntheorem to_topological_space_comap {f : α → β} {u : uniform_space β} :\n  @uniform_space.to_topological_space _ (uniform_space.comap f u) =\n  topological_space.induced f (@uniform_space.to_topological_space β u) := rfl\n\nlemma uniform_continuous_comap' {f : γ → β} {g : α → γ} [v : uniform_space β] [u : uniform_space α]\n  (h : uniform_continuous (f ∘ g)) : @uniform_continuous α γ u (uniform_space.comap f v) g :=\ntendsto_comap_iff.2 h\n\nlemma to_nhds_mono {u₁ u₂ : uniform_space α} (h : u₁ ≤ u₂) (a : α) :\n  @nhds _ (@uniform_space.to_topological_space _ u₁) a ≤\n    @nhds _ (@uniform_space.to_topological_space _ u₂) a :=\nby rw [@nhds_eq_uniformity α u₁ a, @nhds_eq_uniformity α u₂ a]; exact (lift'_mono h le_rfl)\n\nlemma to_topological_space_mono {u₁ u₂ : uniform_space α} (h : u₁ ≤ u₂) :\n  @uniform_space.to_topological_space _ u₁ ≤ @uniform_space.to_topological_space _ u₂ :=\nle_of_nhds_le_nhds $ to_nhds_mono h\n\nlemma uniform_continuous.continuous [uniform_space α] [uniform_space β] {f : α → β}\n  (hf : uniform_continuous f) : continuous f :=\ncontinuous_iff_le_induced.mpr $ to_topological_space_mono $ uniform_continuous_iff.1 hf\n\nlemma to_topological_space_bot : @uniform_space.to_topological_space α ⊥ = ⊥ := rfl\n\nlemma to_topological_space_top : @uniform_space.to_topological_space α ⊤ = ⊤ :=\ntop_unique $ assume s hs, s.eq_empty_or_nonempty.elim\n  (assume : s = ∅, this.symm ▸ @is_open_empty _ ⊤)\n  (assume  ⟨x, hx⟩,\n    have s = univ, from top_unique $ assume y hy, hs x hx (x, y) rfl,\n    this.symm ▸ @is_open_univ _ ⊤)\n\nlemma to_topological_space_infi {ι : Sort*} {u : ι → uniform_space α} :\n  (infi u).to_topological_space = ⨅i, (u i).to_topological_space :=\nbegin\n  refine (eq_of_nhds_eq_nhds $ assume a, _),\n  simp only [nhds_infi, nhds_eq_uniformity, infi_uniformity],\n  exact lift'_infi_of_map_univ (ball_inter _) preimage_univ\nend\n\nlemma to_topological_space_Inf {s : set (uniform_space α)} :\n  (Inf s).to_topological_space = (⨅i∈s, @uniform_space.to_topological_space α i) :=\nbegin\n  rw [Inf_eq_infi],\n  simp only [← to_topological_space_infi],\nend\n\nlemma to_topological_space_inf {u v : uniform_space α} :\n  (u ⊓ v).to_topological_space = u.to_topological_space ⊓ v.to_topological_space :=\nrfl\n\n/-- Uniform space structure on `ulift α`. -/\ninstance ulift.uniform_space [uniform_space α] : uniform_space (ulift α) :=\nuniform_space.comap ulift.down ‹_›\n\nsection uniform_continuous_infi\n\nlemma uniform_continuous_inf_rng {f : α → β} {u₁ : uniform_space α} {u₂ u₃ : uniform_space β}\n  (h₁ : @@uniform_continuous u₁ u₂ f) (h₂ : @@uniform_continuous u₁ u₃ f) :\n  @@uniform_continuous u₁ (u₂ ⊓ u₃) f :=\ntendsto_inf.mpr ⟨h₁, h₂⟩\n\nlemma uniform_continuous_inf_dom_left {f : α → β} {u₁ u₂ : uniform_space α} {u₃ : uniform_space β}\n  (hf : @@uniform_continuous u₁ u₃ f) : @@uniform_continuous (u₁ ⊓ u₂) u₃ f :=\ntendsto_inf_left hf\n\nlemma uniform_continuous_inf_dom_right {f : α → β} {u₁ u₂ : uniform_space α} {u₃ : uniform_space β}\n  (hf : @@uniform_continuous u₂ u₃ f) : @@uniform_continuous (u₁ ⊓ u₂) u₃ f :=\ntendsto_inf_right hf\n\nlemma uniform_continuous_Inf_dom {f : α → β} {u₁ : set (uniform_space α)} {u₂ : uniform_space β}\n  {u : uniform_space α} (h₁ : u ∈ u₁) (hf : @@uniform_continuous u u₂ f) :\n  @@uniform_continuous (Inf u₁) u₂ f :=\nbegin\n  rw [uniform_continuous, Inf_eq_infi', infi_uniformity],\n  exact tendsto_infi' ⟨u, h₁⟩ hf\nend\n\nlemma uniform_continuous_Inf_rng {f : α → β} {u₁ : uniform_space α} {u₂ : set (uniform_space β)}\n  (h : ∀u∈u₂, @@uniform_continuous u₁ u f) : @@uniform_continuous u₁ (Inf u₂) f :=\nbegin\n  rw [uniform_continuous, Inf_eq_infi', infi_uniformity],\n  exact tendsto_infi.mpr (λ ⟨u, hu⟩, h u hu)\nend\n\nlemma uniform_continuous_infi_dom {f : α → β} {u₁ : ι → uniform_space α} {u₂ : uniform_space β}\n  {i : ι} (hf : @@uniform_continuous (u₁ i) u₂ f) : @@uniform_continuous (infi u₁) u₂ f :=\nbegin\n  rw [uniform_continuous, infi_uniformity],\n  exact tendsto_infi' i hf\nend\n\nlemma uniform_continuous_infi_rng {f : α → β} {u₁ : uniform_space α} {u₂ : ι → uniform_space β}\n  (h : ∀i, @@uniform_continuous u₁ (u₂ i) f) : @@uniform_continuous u₁ (infi u₂) f :=\nby rwa [uniform_continuous, infi_uniformity, tendsto_infi]\n\nend uniform_continuous_infi\n\n/-- A uniform space with the discrete uniformity has the discrete topology. -/\nlemma discrete_topology_of_discrete_uniformity [hα : uniform_space α]\n  (h : uniformity α = 𝓟 id_rel) :\n  discrete_topology α :=\n⟨(uniform_space_eq h.symm : ⊥ = hα) ▸ rfl⟩\n\ninstance : uniform_space empty := ⊥\ninstance : uniform_space punit := ⊥\ninstance : uniform_space bool := ⊥\ninstance : uniform_space ℕ := ⊥\ninstance : uniform_space ℤ := ⊥\n\nsection\nvariables [uniform_space α]\n\nopen additive multiplicative\n\ninstance : uniform_space (additive α) := ‹uniform_space α›\ninstance : uniform_space (multiplicative α) := ‹uniform_space α›\n\nlemma uniform_continuous_of_mul : uniform_continuous (of_mul : α → additive α) :=\nuniform_continuous_id\nlemma uniform_continuous_to_mul : uniform_continuous (to_mul : additive α → α) :=\nuniform_continuous_id\nlemma uniform_continuous_of_add : uniform_continuous (of_add : α → multiplicative α) :=\nuniform_continuous_id\nlemma uniform_continuous_to_add : uniform_continuous (to_add : multiplicative α → α) :=\nuniform_continuous_id\n\nlemma uniformity_additive : 𝓤 (additive α) = (𝓤 α).map (prod.map of_mul of_mul) :=\nby { convert map_id.symm, exact prod.map_id }\n\nlemma uniformity_multiplicative : 𝓤 (multiplicative α) = (𝓤 α).map (prod.map of_add of_add) :=\nby { convert map_id.symm, exact prod.map_id }\n\nend\n\ninstance {p : α → Prop} [t : uniform_space α] : uniform_space (subtype p) :=\nuniform_space.comap subtype.val t\n\nlemma uniformity_subtype {p : α → Prop} [t : uniform_space α] :\n  𝓤 (subtype p) = comap (λq:subtype p × subtype p, (q.1.1, q.2.1)) (𝓤 α) :=\nrfl\n\nlemma uniformity_set_coe {s : set α} [t : uniform_space α] :\n  𝓤 s = comap (prod.map (coe : s → α) (coe : s → α)) (𝓤 α) :=\nrfl\n\nlemma uniform_continuous_subtype_val {p : α → Prop} [uniform_space α] :\n  uniform_continuous (subtype.val : {a : α // p a} → α) :=\nuniform_continuous_comap\n\nlemma uniform_continuous_subtype_coe {p : α → Prop} [uniform_space α] :\n  uniform_continuous (coe : {a : α // p a} → α) :=\nuniform_continuous_subtype_val\n\nlemma uniform_continuous.subtype_mk {p : α → Prop} [uniform_space α] [uniform_space β]\n  {f : β → α} (hf : uniform_continuous f) (h : ∀x, p (f x)) :\n  uniform_continuous (λx, ⟨f x, h x⟩ : β → subtype p) :=\nuniform_continuous_comap' hf\n\nlemma uniform_continuous_on_iff_restrict [uniform_space α] [uniform_space β] {f : α → β}\n  {s : set α} :\n  uniform_continuous_on f s ↔ uniform_continuous (s.restrict f) :=\nbegin\n  unfold uniform_continuous_on set.restrict uniform_continuous tendsto,\n  conv_rhs { rw [show (λ x : s × s, (f x.1, f x.2)) = prod.map f f ∘ prod.map coe coe, from rfl,\n    uniformity_set_coe, ← map_map, map_comap, range_prod_map, subtype.range_coe] },\n  refl\nend\n\nlemma tendsto_of_uniform_continuous_subtype\n  [uniform_space α] [uniform_space β] {f : α → β} {s : set α} {a : α}\n  (hf : uniform_continuous (λx:s, f x.val)) (ha : s ∈ 𝓝 a) :\n  tendsto f (𝓝 a) (𝓝 (f a)) :=\nby rw [(@map_nhds_subtype_coe_eq α _ s a (mem_of_mem_nhds ha) ha).symm]; exact\ntendsto_map' (continuous_iff_continuous_at.mp hf.continuous _)\n\nlemma uniform_continuous_on.continuous_on [uniform_space α] [uniform_space β] {f : α → β}\n  {s : set α} (h : uniform_continuous_on f s) : continuous_on f s :=\nbegin\n  rw uniform_continuous_on_iff_restrict at h,\n  rw continuous_on_iff_continuous_restrict,\n  exact h.continuous\nend\n\n@[to_additive]\ninstance [uniform_space α] : uniform_space (αᵐᵒᵖ) :=\nuniform_space.comap mul_opposite.unop ‹_›\n\n@[to_additive]\nlemma uniformity_mul_opposite [uniform_space α] :\n  𝓤 (αᵐᵒᵖ) = comap (λ q : αᵐᵒᵖ × αᵐᵒᵖ, (q.1.unop, q.2.unop)) (𝓤 α) :=\nrfl\n\n@[simp, to_additive] lemma comap_uniformity_mul_opposite [uniform_space α] :\n  comap (λ p : α × α, (mul_opposite.op p.1, mul_opposite.op p.2)) (𝓤 αᵐᵒᵖ) = 𝓤 α :=\nby simpa [uniformity_mul_opposite, comap_comap, (∘)] using comap_id\n\nnamespace mul_opposite\n\n@[to_additive]\nlemma uniform_continuous_unop [uniform_space α] : uniform_continuous (unop : αᵐᵒᵖ → α) :=\nuniform_continuous_comap\n\n@[to_additive]\nlemma uniform_continuous_op [uniform_space α] : uniform_continuous (op : α → αᵐᵒᵖ) :=\nuniform_continuous_comap' uniform_continuous_id\n\nend mul_opposite\n\nsection prod\n\n/- a similar product space is possible on the function space (uniformity of pointwise convergence),\n  but we want to have the uniformity of uniform convergence on function spaces -/\ninstance [u₁ : uniform_space α] [u₂ : uniform_space β] : uniform_space (α × β) :=\nu₁.comap prod.fst ⊓ u₂.comap prod.snd\n\n-- check the above produces no diamond\nexample [u₁ : uniform_space α] [u₂ : uniform_space β] :\n  (prod.topological_space : topological_space (α × β)) = uniform_space.to_topological_space :=\nrfl\n\ntheorem uniformity_prod [uniform_space α] [uniform_space β] : 𝓤 (α × β) =\n  (𝓤 α).comap (λp:(α × β) × α × β, (p.1.1, p.2.1)) ⊓\n  (𝓤 β).comap (λp:(α × β) × α × β, (p.1.2, p.2.2)) :=\nrfl\n\nlemma uniformity_prod_eq_comap_prod [uniform_space α] [uniform_space β] :\n  𝓤 (α × β) = comap (λ p : (α × β) × (α × β), ((p.1.1, p.2.1), (p.1.2, p.2.2))) (𝓤 α ×ᶠ 𝓤 β) :=\nby rw [uniformity_prod, filter.prod, comap_inf, comap_comap, comap_comap]\n\nlemma uniformity_prod_eq_prod [uniform_space α] [uniform_space β] :\n  𝓤 (α × β) = map (λ p : (α × α) × (β × β), ((p.1.1, p.2.1), (p.1.2, p.2.2))) (𝓤 α ×ᶠ 𝓤 β) :=\nby rw [map_swap4_eq_comap, uniformity_prod_eq_comap_prod]\n\nlemma mem_uniformity_of_uniform_continuous_invariant [uniform_space α] [uniform_space β]\n  {s : set (β × β)} {f : α → α → β} (hf : uniform_continuous (λ p : α × α, f p.1 p.2))\n  (hs : s ∈ 𝓤 β) :\n  ∃ u ∈ 𝓤 α, ∀ a b c, (a, b) ∈ u → (f a c, f b c) ∈ s :=\nbegin\n  rw [uniform_continuous, uniformity_prod_eq_prod, tendsto_map'_iff, (∘)] at hf,\n  rcases mem_prod_iff.1 (mem_map.1 $ hf hs) with ⟨u, hu, v, hv, huvt⟩,\n  exact ⟨u, hu, λ a b c hab, @huvt ((_, _), (_, _)) ⟨hab, refl_mem_uniformity hv⟩⟩\nend\n\nlemma mem_uniform_prod [t₁ : uniform_space α] [t₂ : uniform_space β] {a : set (α × α)}\n  {b : set (β × β)} (ha : a ∈ 𝓤 α) (hb : b ∈ 𝓤 β) :\n  {p:(α×β)×(α×β) | (p.1.1, p.2.1) ∈ a ∧ (p.1.2, p.2.2) ∈ b } ∈ 𝓤 (α × β) :=\nby rw [uniformity_prod]; exact inter_mem_inf (preimage_mem_comap ha) (preimage_mem_comap hb)\n\nlemma tendsto_prod_uniformity_fst [uniform_space α] [uniform_space β] :\n  tendsto (λp:(α×β)×(α×β), (p.1.1, p.2.1)) (𝓤 (α × β)) (𝓤 α) :=\nle_trans (map_mono inf_le_left) map_comap_le\n\nlemma tendsto_prod_uniformity_snd [uniform_space α] [uniform_space β] :\n  tendsto (λp:(α×β)×(α×β), (p.1.2, p.2.2)) (𝓤 (α × β)) (𝓤 β) :=\nle_trans (map_mono inf_le_right) map_comap_le\n\nlemma uniform_continuous_fst [uniform_space α] [uniform_space β] :\n  uniform_continuous (λp:α×β, p.1) :=\ntendsto_prod_uniformity_fst\n\nlemma uniform_continuous_snd [uniform_space α] [uniform_space β] :\n  uniform_continuous (λp:α×β, p.2) :=\ntendsto_prod_uniformity_snd\n\nvariables [uniform_space α] [uniform_space β] [uniform_space γ]\nlemma uniform_continuous.prod_mk\n  {f₁ : α → β} {f₂ : α → γ} (h₁ : uniform_continuous f₁) (h₂ : uniform_continuous f₂) :\n  uniform_continuous (λa, (f₁ a, f₂ a)) :=\nby rw [uniform_continuous, uniformity_prod]; exact\ntendsto_inf.2 ⟨tendsto_comap_iff.2 h₁, tendsto_comap_iff.2 h₂⟩\n\nlemma uniform_continuous.prod_mk_left {f : α × β → γ} (h : uniform_continuous f) (b) :\n  uniform_continuous (λ a, f (a,b)) :=\nh.comp (uniform_continuous_id.prod_mk uniform_continuous_const)\n\nlemma uniform_continuous.prod_mk_right {f : α × β → γ} (h : uniform_continuous f) (a) :\n  uniform_continuous (λ b, f (a,b)) :=\nh.comp (uniform_continuous_const.prod_mk  uniform_continuous_id)\n\nlemma uniform_continuous.prod_map [uniform_space δ] {f : α → γ} {g : β → δ}\n  (hf : uniform_continuous f) (hg : uniform_continuous g) :\n  uniform_continuous (prod.map f g) :=\n(hf.comp uniform_continuous_fst).prod_mk (hg.comp uniform_continuous_snd)\n\nlemma to_topological_space_prod {α} {β} [u : uniform_space α] [v : uniform_space β] :\n  @uniform_space.to_topological_space (α × β) prod.uniform_space =\n    @prod.topological_space α β u.to_topological_space v.to_topological_space := rfl\n\n/-- A version of `uniform_continuous_inf_dom_left` for binary functions -/\nlemma uniform_continuous_inf_dom_left₂ {α β γ} {f : α → β → γ}\n  {ua1 ua2 : uniform_space α} {ub1 ub2 : uniform_space β} {uc1 : uniform_space γ}\n  (h : by haveI := ua1; haveI := ub1; exact uniform_continuous (λ p : α × β, f p.1 p.2)) :\n  by haveI := ua1 ⊓ ua2; haveI := ub1 ⊓ ub2; exact uniform_continuous (λ p : α × β, f p.1 p.2) :=\nbegin\n  -- proof essentially copied from ``continuous_inf_dom_left₂`\n  have ha := @uniform_continuous_inf_dom_left _ _ id ua1 ua2 ua1 (@uniform_continuous_id _ (id _)),\n  have hb := @uniform_continuous_inf_dom_left _ _ id ub1 ub2 ub1 (@uniform_continuous_id _ (id _)),\n  have h_unif_cont_id := @uniform_continuous.prod_map _ _ _ _ (\n    ua1 ⊓ ua2) (ub1 ⊓ ub2) ua1 ub1 _ _ ha hb,\n  exact @uniform_continuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id,\nend\n\n/-- A version of `uniform_continuous_inf_dom_right` for binary functions -/\nlemma uniform_continuous_inf_dom_right₂ {α β γ} {f : α → β → γ}\n  {ua1 ua2 : uniform_space α} {ub1 ub2 : uniform_space β} {uc1 : uniform_space γ}\n  (h : by haveI := ua2; haveI := ub2; exact uniform_continuous (λ p : α × β, f p.1 p.2)) :\n  by haveI := ua1 ⊓ ua2; haveI := ub1 ⊓ ub2; exact uniform_continuous (λ p : α × β, f p.1 p.2) :=\nbegin\n  -- proof essentially copied from ``continuous_inf_dom_right₂`\n  have ha := @uniform_continuous_inf_dom_right _ _ id ua1 ua2 ua2 (@uniform_continuous_id _ (id _)),\n  have hb := @uniform_continuous_inf_dom_right _ _ id ub1 ub2 ub2 (@uniform_continuous_id _ (id _)),\n  have h_unif_cont_id := @uniform_continuous.prod_map _ _ _ _\n    (ua1 ⊓ ua2) (ub1 ⊓ ub2) ua2 ub2  _ _ ha hb,\n  exact @uniform_continuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id,\nend\n\n/-- A version of `uniform_continuous_Inf_dom` for binary functions -/\nlemma uniform_continuous_Inf_dom₂ {α β γ} {f : α → β → γ}\n  {uas : set (uniform_space α)} {ubs : set (uniform_space β)}\n  {ua : uniform_space α} {ub : uniform_space β} {uc : uniform_space γ}\n  (ha : ua ∈ uas) (hb : ub ∈ ubs)\n  (hf : uniform_continuous (λ p : α × β, f p.1 p.2)):\n  by haveI := Inf uas; haveI := Inf ubs;\n    exact @uniform_continuous _ _ _ uc (λ p : α × β, f p.1 p.2) :=\nbegin\n  -- proof essentially copied from ``continuous_Inf_dom`\n  let t : uniform_space (α × β) := prod.uniform_space,\n  have ha := uniform_continuous_Inf_dom ha uniform_continuous_id,\n  have hb := uniform_continuous_Inf_dom hb uniform_continuous_id,\n  have h_unif_cont_id := @uniform_continuous.prod_map _ _ _ _ (Inf uas) (Inf ubs) ua ub _ _ ha hb,\n  exact @uniform_continuous.comp _ _ _ (id _) (id _) _ _ _ hf h_unif_cont_id,\nend\n\nend prod\n\nsection\nopen uniform_space function\nvariables {δ' : Type*} [uniform_space α] [uniform_space β] [uniform_space γ] [uniform_space δ]\n  [uniform_space δ']\n\nlocal notation f ` ∘₂ ` g := function.bicompr f g\n\n/-- Uniform continuity for functions of two variables. -/\ndef uniform_continuous₂ (f : α → β → γ) := uniform_continuous (uncurry f)\n\nlemma uniform_continuous₂_def (f : α → β → γ) :\n  uniform_continuous₂ f ↔ uniform_continuous (uncurry f) := iff.rfl\n\nlemma uniform_continuous₂.uniform_continuous {f : α → β → γ} (h : uniform_continuous₂ f) :\n  uniform_continuous (uncurry f) := h\n\nlemma uniform_continuous₂_curry (f : α × β → γ) :\n  uniform_continuous₂ (function.curry f) ↔ uniform_continuous f :=\nby rw [uniform_continuous₂, uncurry_curry]\n\nlemma uniform_continuous₂.comp {f : α → β → γ} {g : γ → δ}\n  (hg : uniform_continuous g) (hf : uniform_continuous₂ f) :\n  uniform_continuous₂ (g ∘₂ f) :=\nhg.comp hf\n\nlemma uniform_continuous₂.bicompl {f : α → β → γ} {ga : δ → α} {gb : δ' → β}\n  (hf : uniform_continuous₂ f) (hga : uniform_continuous ga) (hgb : uniform_continuous gb) :\n  uniform_continuous₂ (bicompl f ga gb) :=\nhf.uniform_continuous.comp (hga.prod_map hgb)\n\nend\n\nlemma to_topological_space_subtype [u : uniform_space α] {p : α → Prop} :\n  @uniform_space.to_topological_space (subtype p) subtype.uniform_space =\n    @subtype.topological_space α p u.to_topological_space := rfl\n\nsection sum\nvariables [uniform_space α] [uniform_space β]\nopen sum\n\n/-- Uniformity on a disjoint union. Entourages of the diagonal in the union are obtained\nby taking independently an entourage of the diagonal in the first part, and an entourage of\nthe diagonal in the second part. -/\ndef uniform_space.core.sum : uniform_space.core (α ⊕ β) :=\nuniform_space.core.mk'\n  (map (λ p : α × α, (inl p.1, inl p.2)) (𝓤 α) ⊔ map (λ p : β × β, (inr p.1, inr p.2)) (𝓤 β))\n  (λ r ⟨H₁, H₂⟩ x, by cases x; [apply refl_mem_uniformity H₁, apply refl_mem_uniformity H₂])\n  (λ r ⟨H₁, H₂⟩, ⟨symm_le_uniformity H₁, symm_le_uniformity H₂⟩)\n  (λ r ⟨Hrα, Hrβ⟩, begin\n    rcases comp_mem_uniformity_sets Hrα with ⟨tα, htα, Htα⟩,\n    rcases comp_mem_uniformity_sets Hrβ with ⟨tβ, htβ, Htβ⟩,\n    refine ⟨_,\n      ⟨mem_map_iff_exists_image.2 ⟨tα, htα, subset_union_left _ _⟩,\n       mem_map_iff_exists_image.2 ⟨tβ, htβ, subset_union_right _ _⟩⟩, _⟩,\n    rintros ⟨_, _⟩ ⟨z, ⟨⟨a, b⟩, hab, ⟨⟩⟩ | ⟨⟨a, b⟩, hab, ⟨⟩⟩,\n                       ⟨⟨_, c⟩, hbc, ⟨⟩⟩ | ⟨⟨_, c⟩, hbc, ⟨⟩⟩⟩,\n    { have A : (a, c) ∈ tα ○ tα := ⟨b, hab, hbc⟩,\n      exact Htα A },\n    { have A : (a, c) ∈ tβ ○ tβ := ⟨b, hab, hbc⟩,\n      exact Htβ A }\n  end)\n\n/-- The union of an entourage of the diagonal in each set of a disjoint union is again an entourage\nof the diagonal. -/\nlemma union_mem_uniformity_sum\n  {a : set (α × α)} (ha : a ∈ 𝓤 α) {b : set (β × β)} (hb : b ∈ 𝓤 β) :\n  ((λ p : (α × α), (inl p.1, inl p.2)) '' a ∪ (λ p : (β × β), (inr p.1, inr p.2)) '' b) ∈\n    (@uniform_space.core.sum α β _ _).uniformity :=\n⟨mem_map_iff_exists_image.2 ⟨_, ha, subset_union_left _ _⟩,\n  mem_map_iff_exists_image.2 ⟨_, hb, subset_union_right _ _⟩⟩\n\n/- To prove that the topology defined by the uniform structure on the disjoint union coincides with\nthe disjoint union topology, we need two lemmas saying that open sets can be characterized by\nthe uniform structure -/\nlemma uniformity_sum_of_open_aux {s : set (α ⊕ β)} (hs : is_open s) {x : α ⊕ β} (xs : x ∈ s) :\n  { p : ((α ⊕ β) × (α ⊕ β)) | p.1 = x → p.2 ∈ s } ∈ (@uniform_space.core.sum α β _ _).uniformity :=\nbegin\n  cases x,\n  { refine mem_of_superset\n      (union_mem_uniformity_sum (mem_nhds_uniformity_iff_right.1 (is_open.mem_nhds hs.1 xs))\n        univ_mem)\n      (union_subset _ _);\n    rintro _ ⟨⟨_, b⟩, h, ⟨⟩⟩ ⟨⟩,\n    exact h rfl },\n  { refine mem_of_superset\n      (union_mem_uniformity_sum univ_mem (mem_nhds_uniformity_iff_right.1\n        (is_open.mem_nhds hs.2 xs)))\n      (union_subset _ _);\n    rintro _ ⟨⟨a, _⟩, h, ⟨⟩⟩ ⟨⟩,\n    exact h rfl },\nend\n\nlemma open_of_uniformity_sum_aux {s : set (α ⊕ β)}\n  (hs : ∀x ∈ s, { p : ((α ⊕ β) × (α ⊕ β)) | p.1 = x → p.2 ∈ s } ∈\n    (@uniform_space.core.sum α β _ _).uniformity) :\n  is_open s :=\nbegin\n  split,\n  { refine (@is_open_iff_mem_nhds α _ _).2 (λ a ha, mem_nhds_uniformity_iff_right.2 _),\n    rcases mem_map_iff_exists_image.1 (hs _ ha).1 with ⟨t, ht, st⟩,\n    refine mem_of_superset ht _,\n    rintro p pt rfl, exact st ⟨_, pt, rfl⟩ rfl },\n  { refine (@is_open_iff_mem_nhds β _ _).2 (λ b hb, mem_nhds_uniformity_iff_right.2 _),\n    rcases mem_map_iff_exists_image.1 (hs _ hb).2 with ⟨t, ht, st⟩,\n    refine mem_of_superset ht _,\n    rintro p pt rfl, exact st ⟨_, pt, rfl⟩ rfl }\nend\n\n/- We can now define the uniform structure on the disjoint union -/\ninstance sum.uniform_space : uniform_space (α ⊕ β) :=\n{ to_core := uniform_space.core.sum,\n  is_open_uniformity := λ s, ⟨uniformity_sum_of_open_aux, open_of_uniformity_sum_aux⟩ }\n\nlemma sum.uniformity : 𝓤 (α ⊕ β) =\n    map (λ p : α × α, (inl p.1, inl p.2)) (𝓤 α) ⊔\n    map (λ p : β × β, (inr p.1, inr p.2)) (𝓤 β) := rfl\n\nend sum\n\nend constructions\n\n/-- Let `c : ι → set α` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/\nlemma lebesgue_number_lemma {α : Type u} [uniform_space α] {s : set α} {ι} {c : ι → set α}\n  (hs : is_compact s) (hc₁ : ∀ i, is_open (c i)) (hc₂ : s ⊆ ⋃ i, c i) :\n  ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, {y | (x, y) ∈ n} ⊆ c i :=\nbegin\n  let u := λ n, {x | ∃ i (m ∈ 𝓤 α), {y | (x, y) ∈ m ○ n} ⊆ c i},\n  have hu₁ : ∀ n ∈ 𝓤 α, is_open (u n),\n  { refine λ n hn, is_open_uniformity.2 _,\n    rintro x ⟨i, m, hm, h⟩,\n    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩,\n    apply (𝓤 α).sets_of_superset hm',\n    rintros ⟨x, y⟩ hp rfl,\n    refine ⟨i, m', hm', λ z hz, h (monotone_id.comp_rel monotone_const mm' _)⟩,\n    dsimp [-mem_comp_rel] at hz ⊢, rw comp_rel_assoc,\n    exact ⟨y, hp, hz⟩ },\n  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n,\n  { intros x hx,\n    rcases mem_Union.1 (hc₂ hx) with ⟨i, h⟩,\n    rcases comp_mem_uniformity_sets (is_open_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩,\n    exact mem_bUnion hm' ⟨i, _, hm', λ y hy, mm' hy rfl⟩ },\n  rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩,\n  refine ⟨_, (bInter_mem b_fin).2 bu, λ x hx, _⟩,\n  rcases mem_Union₂.1 (b_cover hx) with ⟨n, bn, i, m, hm, h⟩,\n  refine ⟨i, λ y hy, h _⟩,\n  exact prod_mk_mem_comp_rel (refl_mem_uniformity hm) (bInter_subset_of_mem bn hy)\nend\n\n/-- Let `c : set (set α)` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `t ∈ c`. -/\nlemma lebesgue_number_lemma_sUnion {α : Type u} [uniform_space α] {s : set α} {c : set (set α)}\n  (hs : is_compact s) (hc₁ : ∀ t ∈ c, is_open t) (hc₂ : s ⊆ ⋃₀ c) :\n  ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ y, (x, y) ∈ n → y ∈ t :=\nby rw sUnion_eq_Union at hc₂;\n   simpa using lebesgue_number_lemma hs (by simpa) hc₂\n\n/-- A useful consequence of the Lebesgue number lemma: given any compact set `K` contained in an\nopen set `U`, we can find an (open) entourage `V` such that the ball of size `V` about any point of\n`K` is contained in `U`. -/\nlemma lebesgue_number_of_compact_open [uniform_space α]\n  {K U : set α} (hK : is_compact K) (hU : is_open U) (hKU : K ⊆ U) :\n  ∃ V ∈ 𝓤 α, is_open V ∧ ∀ x ∈ K, uniform_space.ball x V ⊆ U :=\nbegin\n  let W : K → set (α × α) := λ k, classical.some $ is_open_iff_open_ball_subset.mp hU k.1 $ hKU k.2,\n  have hW : ∀ k, W k ∈ 𝓤 α ∧ is_open (W k) ∧ uniform_space.ball k.1 (W k) ⊆ U,\n  { intros k,\n    obtain ⟨h₁, h₂, h₃⟩ := classical.some_spec (is_open_iff_open_ball_subset.mp hU k.1 (hKU k.2)),\n    exact ⟨h₁, h₂, h₃⟩, },\n  let c : K → set α := λ k, uniform_space.ball k.1 (W k),\n  have hc₁ : ∀ k, is_open (c k), { exact λ k, uniform_space.is_open_ball k.1 (hW k).2.1, },\n  have hc₂ : K ⊆ ⋃ i, c i,\n  { intros k hk,\n    simp only [mem_Union, set_coe.exists],\n    exact ⟨k, hk, uniform_space.mem_ball_self k (hW ⟨k, hk⟩).1⟩, },\n  have hc₃ : ∀ k, c k ⊆ U, { exact λ k, (hW k).2.2, },\n  obtain ⟨V, hV, hV'⟩ := lebesgue_number_lemma hK hc₁ hc₂,\n  refine ⟨interior V, interior_mem_uniformity hV, is_open_interior, _⟩,\n  intros k hk,\n  obtain ⟨k', hk'⟩ := hV' k hk,\n  exact ((ball_mono interior_subset k).trans hk').trans (hc₃ k'),\nend\n\n/-!\n### Expressing continuity properties in uniform spaces\n\nWe reformulate the various continuity properties of functions taking values in a uniform space\nin terms of the uniformity in the target. Since the same lemmas (essentially with the same names)\nalso exist for metric spaces and emetric spaces (reformulating things in terms of the distance or\nthe edistance in the target), we put them in a namespace `uniform` here.\n\nIn the metric and emetric space setting, there are also similar lemmas where one assumes that\nboth the source and the target are metric spaces, reformulating things in terms of the distance\non both sides. These lemmas are generally written without primes, and the versions where only\nthe target is a metric space is primed. We follow the same convention here, thus giving lemmas\nwith primes.\n-/\n\nnamespace uniform\n\nvariables [uniform_space α]\n\ntheorem tendsto_nhds_right {f : filter β} {u : β → α} {a : α} :\n  tendsto u f (𝓝 a) ↔ tendsto (λ x, (a, u x)) f (𝓤 α)  :=\nby rw [nhds_eq_comap_uniformity, tendsto_comap_iff]\n\ntheorem tendsto_nhds_left {f : filter β} {u : β → α} {a : α} :\n  tendsto u f (𝓝 a) ↔ tendsto (λ x, (u x, a)) f (𝓤 α)  :=\nby rw [nhds_eq_comap_uniformity', tendsto_comap_iff]\n\ntheorem continuous_at_iff'_right [topological_space β] {f : β → α} {b : β} :\n  continuous_at f b ↔ tendsto (λ x, (f b, f x)) (𝓝 b) (𝓤 α) :=\nby rw [continuous_at, tendsto_nhds_right]\n\ntheorem continuous_at_iff'_left [topological_space β] {f : β → α} {b : β} :\n  continuous_at f b ↔ tendsto (λ x, (f x, f b)) (𝓝 b) (𝓤 α) :=\nby rw [continuous_at, tendsto_nhds_left]\n\ntheorem continuous_at_iff_prod [topological_space β] {f : β → α} {b : β} :\n  continuous_at f b ↔ tendsto (λ x : β × β, (f x.1, f x.2)) (𝓝 (b, b)) (𝓤 α) :=\n⟨λ H, le_trans (H.prod_map' H) (nhds_le_uniformity _),\n  λ H, continuous_at_iff'_left.2 $ H.comp $ tendsto_id.prod_mk_nhds tendsto_const_nhds⟩\n\ntheorem continuous_within_at_iff'_right [topological_space β] {f : β → α} {b : β} {s : set β} :\n  continuous_within_at f s b ↔ tendsto (λ x, (f b, f x)) (𝓝[s] b) (𝓤 α) :=\nby rw [continuous_within_at, tendsto_nhds_right]\n\ntheorem continuous_within_at_iff'_left [topological_space β] {f : β → α} {b : β} {s : set β} :\n  continuous_within_at f s b ↔ tendsto (λ x, (f x, f b)) (𝓝[s] b) (𝓤 α) :=\nby rw [continuous_within_at, tendsto_nhds_left]\n\ntheorem continuous_on_iff'_right [topological_space β] {f : β → α} {s : set β} :\n  continuous_on f s ↔ ∀ b ∈ s, tendsto (λ x, (f b, f x)) (𝓝[s] b) (𝓤 α) :=\nby simp [continuous_on, continuous_within_at_iff'_right]\n\ntheorem continuous_on_iff'_left [topological_space β] {f : β → α} {s : set β} :\n  continuous_on f s ↔ ∀ b ∈ s, tendsto (λ x, (f x, f b)) (𝓝[s] b) (𝓤 α) :=\nby simp [continuous_on, continuous_within_at_iff'_left]\n\ntheorem continuous_iff'_right [topological_space β] {f : β → α} :\n  continuous f ↔ ∀ b, tendsto (λ x, (f b, f x)) (𝓝 b) (𝓤 α) :=\ncontinuous_iff_continuous_at.trans $ forall_congr $ λ b, tendsto_nhds_right\n\ntheorem continuous_iff'_left [topological_space β] {f : β → α} :\n  continuous f ↔ ∀ b, tendsto (λ x, (f x, f b)) (𝓝 b) (𝓤 α) :=\ncontinuous_iff_continuous_at.trans $ forall_congr $ λ b, tendsto_nhds_left\n\nend uniform\n\nlemma filter.tendsto.congr_uniformity {α β} [uniform_space β] {f g : α → β} {l : filter α} {b : β}\n  (hf : tendsto f l (𝓝 b)) (hg : tendsto (λ x, (f x, g x)) l (𝓤 β)) :\n  tendsto g l (𝓝 b) :=\nuniform.tendsto_nhds_right.2 $ (uniform.tendsto_nhds_right.1 hf).uniformity_trans hg\n\nlemma uniform.tendsto_congr {α β} [uniform_space β] {f g : α → β} {l : filter α} {b : β}\n  (hfg : tendsto (λ x, (f x, g x)) l (𝓤 β)) :\n  tendsto f l (𝓝 b) ↔ tendsto g l (𝓝 b) :=\n⟨λ h, h.congr_uniformity hfg, λ h, h.congr_uniformity hfg.uniformity_symm⟩\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/uniform_space/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.47347410329849804}}
{"text": "import order.complete_lattice\n\nopen lattice\n\nexample {α : Type*} [partial_order α] (b : α) : partial_order {x // b ≤ x} := by apply_instance\n\n-- why is subtype.ext an iff?\n\ninstance slice.semilattice_sup {α : Type*} [semilattice_sup α] (b : α) : semilattice_sup {x // b ≤ x} :=\n{ sup := λ x y, ⟨x.val ⊔ y.val, le_sup_left_of_le x.2⟩,\n  le_sup_left := λ _ _, le_sup_left,\n  le_sup_right := λ _ _, le_sup_right,\n  sup_le := λ _ _ _, sup_le,\n  ..subtype.partial_order _}\n\ninstance slice.semilattice_inf {α : Type*} [semilattice_inf α] (b : α) : semilattice_inf {x // b ≤ x} :=\n{ inf := λ x y, ⟨x.val ⊓ y.val, le_inf x.2 y.2⟩,\n  inf_le_left := λ _ _, inf_le_left,\n  inf_le_right := λ _ _, inf_le_right,\n  le_inf := λ _ _ _, le_inf,\n  ..subtype.partial_order _}\n\ninstance slice.lattice {α : Type*} [lattice α] (b : α) : lattice {x // b ≤ x} :=\n{ ..slice.semilattice_inf b, ..slice.semilattice_sup b}\n\ninstance slice.order_top {α : Type*} [order_top α] (b : α) : order_top {x // b ≤ x} :=\n{ top := ⟨⊤, le_top⟩,\n  le_top := λ _, le_top,\n  ..subtype.partial_order _ }\n\ninstance slice.order_bot {α : Type*} [partial_order α] (b : α) : order_bot {x // b ≤ x} :=\n{ bot := ⟨b, le_refl b⟩,\n  bot_le := subtype.property,\n  ..subtype.partial_order _ }\n\ninstance slice.bounded_lattice {α : Type*} [bounded_lattice α] (b : α) : bounded_lattice {x // b ≤ x} :=\n{ ..slice.order_top b, ..slice.order_bot b, ..slice.lattice b}\n\ninstance slice.has_Sup {α : Type*} [complete_lattice α] (b : α) : has_Sup {x // b ≤ x} :=\n⟨λ X, ⟨Sup $ set.insert b (set.image subtype.val X), le_Sup $ set.mem_insert b _⟩⟩\n\ninstance slice.has_Inf {α : Type*} [complete_lattice α] (b : α) : has_Inf {x // b ≤ x} :=\n⟨λ X, ⟨Inf $ set.image subtype.val X, le_Inf $ by {rintro _ ⟨y, _, rfl⟩, exact y.2}⟩⟩\n\ninstance slice.complete_lattice {α : Type*} [complete_lattice α] (b : α) : complete_lattice {x // b ≤ x} :=\n{ le_Sup := λ X y h, le_Sup $ set.mem_insert_of_mem _ ⟨y, h, rfl⟩,\n  Sup_le := λ X y h, Sup_le $ λ x h2, begin\n    change x ∈ insert b _ at h2,\n    rw set.mem_insert_iff at h2,\n    rcases h2 with ⟨rfl, h2⟩, exact y.2,\n    rcases h2 with ⟨_, h2, rfl⟩,\n    exact h _ h2,\n  end,\n  Inf_le := λ X y h, Inf_le ⟨y, h, rfl⟩,\n  le_Inf := λ X y h, le_Inf $ by {rintro _ ⟨x, hx, rfl⟩, exact h _ hx},\n  ..slice.bounded_lattice b,\n  ..slice.has_Sup b,\n  ..slice.has_Inf b }", "meta": {"author": "ImperialCollegeLondon", "repo": "lean-groups", "sha": "9a82d2a66ef7f549107fcb4e1504d734c43ebb33", "save_path": "github-repos/lean/ImperialCollegeLondon-lean-groups", "path": "github-repos/lean/ImperialCollegeLondon-lean-groups/lean-groups-9a82d2a66ef7f549107fcb4e1504d734c43ebb33/src/slice_lattice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.6224593382055109, "lm_q1q2_score": 0.47347409511635563}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n\n! This file was ported from Lean 3 source module category_theory.category.ulift\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Category.Basic\nimport Mathbin.CategoryTheory.Equivalence\nimport Mathbin.CategoryTheory.EqToHom\n\n/-!\n# Basic API for ulift\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains a very basic API for working with the categorical\ninstance on `ulift C` where `C` is a type with a category instance.\n\n1. `category_theory.ulift.up` is the functorial version of the usual `ulift.up`.\n2. `category_theory.ulift.down` is the functorial version of the usual `ulift.down`.\n3. `category_theory.ulift.equivalence` is the categorical equivalence between\n  `C` and `ulift C`.\n\n# ulift_hom\n\nGiven a type `C : Type u`, `ulift_hom.{w} C` is just an alias for `C`.\nIf we have `category.{v} C`, then `ulift_hom.{w} C` is endowed with a category instance\nwhose morphisms are obtained by applying `ulift.{w}` to the morphisms from `C`.\n\nThis is a category equivalent to `C`. The forward direction of the equivalence is `ulift_hom.up`,\nthe backward direction is `ulift_hom.donw` and the equivalence is `ulift_hom.equiv`.\n\n# as_small\n\nThis file also contains a construction which takes a type `C : Type u` with a\ncategory instance `category.{v} C` and makes a small category\n`as_small.{w} C : Type (max w v u)` equivalent to `C`.\n\nThe forward direction of the equivalence, `C ⥤ as_small C`, is denoted `as_small.up`\nand the backward direction is `as_small.down`. The equivalence itself is `as_small.equiv`.\n-/\n\n\nuniverse w₁ v₁ v₂ u₁ u₂\n\nnamespace CategoryTheory\n\nvariable {C : Type u₁} [Category.{v₁} C]\n\n#print CategoryTheory.ULift.upFunctor /-\n/-- The functorial version of `ulift.up`. -/\n@[simps]\ndef ULift.upFunctor : C ⥤ ULift.{u₂} C where\n  obj := ULift.up\n  map X Y f := f\n#align category_theory.ulift.up_functor CategoryTheory.ULift.upFunctor\n-/\n\n#print CategoryTheory.ULift.downFunctor /-\n/-- The functorial version of `ulift.down`. -/\n@[simps]\ndef ULift.downFunctor : ULift.{u₂} C ⥤ C\n    where\n  obj := ULift.down\n  map X Y f := f\n#align category_theory.ulift.down_functor CategoryTheory.ULift.downFunctor\n-/\n\n/- warning: category_theory.ulift.equivalence -> CategoryTheory.ULift.equivalence is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{u1, u1, u2, max u2 u3} C _inst_1 (ULift.{u3, u2} C) (CategoryTheory.uliftCategory.{u1, u2, u3} C _inst_1)\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{u1, u1, u2, max u3 u2} C (ULift.{u3, u2} C) _inst_1 (CategoryTheory.uliftCategory.{u1, u2, u3} C _inst_1)\nCase conversion may be inaccurate. Consider using '#align category_theory.ulift.equivalence CategoryTheory.ULift.equivalenceₓ'. -/\n/-- The categorical equivalence between `C` and `ulift C`. -/\n@[simps]\ndef ULift.equivalence : C ≌ ULift.{u₂} C\n    where\n  Functor := ULift.upFunctor\n  inverse := ULift.downFunctor\n  unitIso :=\n    { Hom := 𝟙 _\n      inv := 𝟙 _ }\n  counitIso :=\n    { Hom :=\n        { app := fun X => 𝟙 _\n          naturality' := fun X Y f => by\n            change f ≫ 𝟙 _ = 𝟙 _ ≫ f\n            simp }\n      inv :=\n        { app := fun X => 𝟙 _\n          naturality' := fun X Y f => by\n            change f ≫ 𝟙 _ = 𝟙 _ ≫ f\n            simp }\n      hom_inv_id' := by\n        ext\n        change 𝟙 _ ≫ 𝟙 _ = 𝟙 _\n        simp\n      inv_hom_id' := by\n        ext\n        change 𝟙 _ ≫ 𝟙 _ = 𝟙 _\n        simp }\n  functor_unitIso_comp' X := by\n    change 𝟙 X ≫ 𝟙 X = 𝟙 X\n    simp\n#align category_theory.ulift.equivalence CategoryTheory.ULift.equivalence\n\nsection UliftHom\n\n#print CategoryTheory.ULiftHom /-\n/-- `ulift_hom.{w} C` is an alias for `C`, which is endowed with a category instance\n  whose morphisms are obtained by applying `ulift.{w}` to the morphisms from `C`.\n-/\ndef ULiftHom.{w, u} (C : Type u) :=\n  C\n#align category_theory.ulift_hom CategoryTheory.ULiftHom\n-/\n\ninstance {C} [Inhabited C] : Inhabited (ULiftHom C) :=\n  ⟨(Inhabited.default C : C)⟩\n\n#print CategoryTheory.ULiftHom.objDown /-\n/-- The obvious function `ulift_hom C → C`. -/\ndef ULiftHom.objDown {C} (A : ULiftHom C) : C :=\n  A\n#align category_theory.ulift_hom.obj_down CategoryTheory.ULiftHom.objDown\n-/\n\n#print CategoryTheory.ULiftHom.objUp /-\n/-- The obvious function `C → ulift_hom C`. -/\ndef ULiftHom.objUp {C} (A : C) : ULiftHom C :=\n  A\n#align category_theory.ulift_hom.obj_up CategoryTheory.ULiftHom.objUp\n-/\n\n/- warning: category_theory.obj_down_obj_up -> CategoryTheory.objDown_objUp is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u1}} (A : C), Eq.{succ u1} C (CategoryTheory.ULiftHom.objDown.{u1, u2} C (CategoryTheory.ULiftHom.objUp.{u1, u2} C A)) A\nbut is expected to have type\n  forall {C : Type.{u2}} (A : C), Eq.{succ u2} C (CategoryTheory.ULiftHom.objDown.{u2, u1} C (CategoryTheory.ULiftHom.objUp.{u2, u1} C A)) A\nCase conversion may be inaccurate. Consider using '#align category_theory.obj_down_obj_up CategoryTheory.objDown_objUpₓ'. -/\n@[simp]\ntheorem objDown_objUp {C} (A : C) : (ULiftHom.objUp A).objDown = A :=\n  rfl\n#align category_theory.obj_down_obj_up CategoryTheory.objDown_objUp\n\n/- warning: category_theory.obj_up_obj_down -> CategoryTheory.objUp_objDown is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u1}} (A : CategoryTheory.ULiftHom.{u2, u1} C), Eq.{succ u1} (CategoryTheory.ULiftHom.{u2, u1} C) (CategoryTheory.ULiftHom.objUp.{u1, u2} C (CategoryTheory.ULiftHom.objDown.{u1, u2} C A)) A\nbut is expected to have type\n  forall {C : Type.{u2}} (A : CategoryTheory.ULiftHom.{u1, u2} C), Eq.{succ u2} (CategoryTheory.ULiftHom.{u1, u2} C) (CategoryTheory.ULiftHom.objUp.{u2, u1} C (CategoryTheory.ULiftHom.objDown.{u2, u1} C A)) A\nCase conversion may be inaccurate. Consider using '#align category_theory.obj_up_obj_down CategoryTheory.objUp_objDownₓ'. -/\n@[simp]\ntheorem objUp_objDown {C} (A : ULiftHom C) : ULiftHom.objUp A.objDown = A :=\n  rfl\n#align category_theory.obj_up_obj_down CategoryTheory.objUp_objDown\n\ninstance : Category.{max v₂ v₁} (ULiftHom.{v₂} C)\n    where\n  Hom A B := ULift.{v₂} <| A.objDown ⟶ B.objDown\n  id A := ⟨𝟙 _⟩\n  comp A B C f g := ⟨f.down ≫ g.down⟩\n\n#print CategoryTheory.ULiftHom.up /-\n/-- One half of the quivalence between `C` and `ulift_hom C`. -/\n@[simps]\ndef ULiftHom.up : C ⥤ ULiftHom C where\n  obj := ULiftHom.objUp\n  map X Y f := ⟨f⟩\n#align category_theory.ulift_hom.up CategoryTheory.ULiftHom.up\n-/\n\n#print CategoryTheory.ULiftHom.down /-\n/-- One half of the quivalence between `C` and `ulift_hom C`. -/\n@[simps]\ndef ULiftHom.down : ULiftHom C ⥤ C where\n  obj := ULiftHom.objDown\n  map X Y f := f.down\n#align category_theory.ulift_hom.down CategoryTheory.ULiftHom.down\n-/\n\n/- warning: category_theory.ulift_hom.equiv -> CategoryTheory.ULiftHom.equiv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{u1, max u3 u1, u2, u2} C _inst_1 (CategoryTheory.ULiftHom.{u3, u2} C) (CategoryTheory.ULiftHom.category.{u1, u3, u2} C _inst_1)\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{u1, max u1 u3, u2, u2} C (CategoryTheory.ULiftHom.{u3, u2} C) _inst_1 (CategoryTheory.ULiftHom.category.{u1, u3, u2} C _inst_1)\nCase conversion may be inaccurate. Consider using '#align category_theory.ulift_hom.equiv CategoryTheory.ULiftHom.equivₓ'. -/\n/-- The equivalence between `C` and `ulift_hom C`. -/\ndef ULiftHom.equiv : C ≌ ULiftHom C\n    where\n  Functor := ULiftHom.up\n  inverse := ULiftHom.down\n  unitIso := NatIso.ofComponents (fun A => eqToIso rfl) (by tidy)\n  counitIso := NatIso.ofComponents (fun A => eqToIso rfl) (by tidy)\n#align category_theory.ulift_hom.equiv CategoryTheory.ULiftHom.equiv\n\nend UliftHom\n\n#print CategoryTheory.AsSmall /-\n/-- `as_small C` is a small category equivalent to `C`.\n  More specifically, if `C : Type u` is endowed with `category.{v} C`, then\n  `as_small.{w} C : Type (max w v u)` is endowed with an instance of a small category.\n\n  The objects and morphisms of `as_small C` are defined by applying `ulift` to the\n  objects and morphisms of `C`.\n\n  Note: We require a category instance for this definition in order to have direct\n  access to the universe level `v`.\n-/\n@[nolint unused_arguments]\ndef AsSmall.{w, v, u} (C : Type u) [Category.{v} C] :=\n  ULift.{max w v} C\n#align category_theory.as_small CategoryTheory.AsSmall\n-/\n\ninstance : SmallCategory (AsSmall.{w₁} C)\n    where\n  Hom X Y := ULift.{max w₁ u₁} <| X.down ⟶ Y.down\n  id X := ⟨𝟙 _⟩\n  comp X Y Z f g := ⟨f.down ≫ g.down⟩\n\n#print CategoryTheory.AsSmall.up /-\n/-- One half of the equivalence between `C` and `as_small C`. -/\n@[simps]\ndef AsSmall.up : C ⥤ AsSmall C where\n  obj X := ⟨X⟩\n  map X Y f := ⟨f⟩\n#align category_theory.as_small.up CategoryTheory.AsSmall.up\n-/\n\n#print CategoryTheory.AsSmall.down /-\n/-- One half of the equivalence between `C` and `as_small C`. -/\n@[simps]\ndef AsSmall.down : AsSmall C ⥤ C where\n  obj X := X.down\n  map X Y f := f.down\n#align category_theory.as_small.down CategoryTheory.AsSmall.down\n-/\n\n/- warning: category_theory.as_small.equiv -> CategoryTheory.AsSmall.equiv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{u1, max u2 u3 u1, u2, max u2 u3 u1} C _inst_1 (CategoryTheory.AsSmall.{u3, u1, u2} C _inst_1) (CategoryTheory.AsSmall.smallCategory.{u3, u1, u2} C _inst_1)\nbut is expected to have type\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], CategoryTheory.Equivalence.{u1, max (max u2 u1) u3, u2, max (max u2 u1) u3} C (CategoryTheory.AsSmall.{u3, u1, u2} C _inst_1) _inst_1 (CategoryTheory.instSmallCategoryAsSmall.{u3, u1, u2} C _inst_1)\nCase conversion may be inaccurate. Consider using '#align category_theory.as_small.equiv CategoryTheory.AsSmall.equivₓ'. -/\n/-- The equivalence between `C` and `as_small C`. -/\n@[simps]\ndef AsSmall.equiv : C ≌ AsSmall C where\n  Functor := AsSmall.up\n  inverse := AsSmall.down\n  unitIso := NatIso.ofComponents (fun X => eqToIso rfl) (by tidy)\n  counitIso :=\n    NatIso.ofComponents\n      (fun X =>\n        eqToIso <| by\n          ext\n          rfl)\n      (by tidy)\n#align category_theory.as_small.equiv CategoryTheory.AsSmall.equiv\n\ninstance [Inhabited C] : Inhabited (AsSmall C) :=\n  ⟨⟨Inhabited.default _⟩⟩\n\n/- warning: category_theory.ulift_hom_ulift_category.equiv -> CategoryTheory.ULiftHomULiftCategory.equiv is a dubious translation:\nlean 3 declaration is\n  forall (C : Type.{u4}) [_inst_2 : CategoryTheory.Category.{u3, u4} C], CategoryTheory.Equivalence.{u3, max u1 u3, u4, max u4 u2} C _inst_2 (CategoryTheory.ULiftHom.{u1, max u4 u2} (ULift.{u2, u4} C)) (CategoryTheory.ULiftHom.category.{u3, u1, max u4 u2} (ULift.{u2, u4} C) (CategoryTheory.uliftCategory.{u3, u4, u2} C _inst_2))\nbut is expected to have type\n  forall (C : Type.{u4}) [_inst_2 : CategoryTheory.Category.{u3, u4} C], CategoryTheory.Equivalence.{u3, max u3 u1, u4, max u2 u4} C (CategoryTheory.ULiftHom.{u1, max u2 u4} (ULift.{u2, u4} C)) _inst_2 (CategoryTheory.ULiftHom.category.{u3, u1, max u4 u2} (ULift.{u2, u4} C) (CategoryTheory.uliftCategory.{u3, u4, u2} C _inst_2))\nCase conversion may be inaccurate. Consider using '#align category_theory.ulift_hom_ulift_category.equiv CategoryTheory.ULiftHomULiftCategory.equivₓ'. -/\n/-- The equivalence between `C` and `ulift_hom (ulift C)`. -/\ndef ULiftHomULiftCategory.equiv.{v', u', v, u} (C : Type u) [Category.{v} C] :\n    C ≌ ULiftHom.{v'} (ULift.{u'} C) :=\n  ULift.equivalence.trans ULiftHom.equiv\n#align category_theory.ulift_hom_ulift_category.equiv CategoryTheory.ULiftHomULiftCategory.equiv\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Category/Ulift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431679972357831, "lm_q2_score": 0.6370308082623216, "lm_q1q2_score": 0.4734209099538017}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.eq_to_hom\nimport Mathlib.PostPort\n\nuniverses u₁ v₁ \n\nnamespace Mathlib\n\n/-#\nDisjoint unions of categories, functors, and natural transformations.\n-/\n\nnamespace category_theory\n\n\n/--\n`sum C D` gives the direct sum of two categories.\n-/\nprotected instance sum (C : Type u₁) [category C] (D : Type u₁) [category D] : category (C ⊕ D) :=\n  category.mk\n\n@[simp] theorem sum_comp_inl (C : Type u₁) [category C] (D : Type u₁) [category D] {P : C} {Q : C} {R : C} (f : sum.inl P ⟶ sum.inl Q) (g : sum.inl Q ⟶ sum.inl R) : f ≫ g = f ≫ g :=\n  rfl\n\n@[simp] theorem sum_comp_inr (C : Type u₁) [category C] (D : Type u₁) [category D] {P : D} {Q : D} {R : D} (f : sum.inr P ⟶ sum.inr Q) (g : sum.inr Q ⟶ sum.inr R) : f ≫ g = f ≫ g :=\n  rfl\n\nnamespace sum\n\n\n/-- `inl_` is the functor `X ↦ inl X`. -/\n-- Unfortunate naming here, suggestions welcome.\n\ndef inl_ (C : Type u₁) [category C] (D : Type u₁) [category D] : C ⥤ C ⊕ D :=\n  functor.mk (fun (X : C) => sum.inl X) fun (X Y : C) (f : X ⟶ Y) => f\n\n/-- `inr_` is the functor `X ↦ inr X`. -/\ndef inr_ (C : Type u₁) [category C] (D : Type u₁) [category D] : D ⥤ C ⊕ D :=\n  functor.mk (fun (X : D) => sum.inr X) fun (X Y : D) (f : X ⟶ Y) => f\n\n/-- The functor exchanging two direct summand categories. -/\ndef swap (C : Type u₁) [category C] (D : Type u₁) [category D] : C ⊕ D ⥤ D ⊕ C :=\n  functor.mk (fun (X : C ⊕ D) => sorry) fun (X Y : C ⊕ D) (f : X ⟶ Y) => sorry\n\n@[simp] theorem swap_obj_inl (C : Type u₁) [category C] (D : Type u₁) [category D] (X : C) : functor.obj (swap C D) (sum.inl X) = sum.inr X :=\n  rfl\n\n@[simp] theorem swap_obj_inr (C : Type u₁) [category C] (D : Type u₁) [category D] (X : D) : functor.obj (swap C D) (sum.inr X) = sum.inl X :=\n  rfl\n\n@[simp] theorem swap_map_inl (C : Type u₁) [category C] (D : Type u₁) [category D] {X : C} {Y : C} {f : sum.inl X ⟶ sum.inl Y} : functor.map (swap C D) f = f :=\n  rfl\n\n@[simp] theorem swap_map_inr (C : Type u₁) [category C] (D : Type u₁) [category D] {X : D} {Y : D} {f : sum.inr X ⟶ sum.inr Y} : functor.map (swap C D) f = f :=\n  rfl\n\nnamespace swap\n\n\n/-- `swap` gives an equivalence between `C ⊕ D` and `D ⊕ C`. -/\ndef equivalence (C : Type u₁) [category C] (D : Type u₁) [category D] : C ⊕ D ≌ D ⊕ C :=\n  equivalence.mk (swap C D) (swap D C) (nat_iso.of_components (fun (X : C ⊕ D) => eq_to_iso sorry) sorry)\n    (nat_iso.of_components (fun (X : D ⊕ C) => eq_to_iso sorry) sorry)\n\nprotected instance is_equivalence (C : Type u₁) [category C] (D : Type u₁) [category D] : is_equivalence (swap C D) :=\n  is_equivalence.of_equivalence (equivalence C D)\n\n/-- The double swap on `C ⊕ D` is naturally isomorphic to the identity functor. -/\ndef symmetry (C : Type u₁) [category C] (D : Type u₁) [category D] : swap C D ⋙ swap D C ≅ 𝟭 :=\n  iso.symm (equivalence.unit_iso (equivalence C D))\n\nend swap\n\n\nend sum\n\n\nnamespace functor\n\n\n/-- The sum of two functors. -/\ndef sum {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) : A ⊕ C ⥤ B ⊕ D :=\n  mk (fun (X : A ⊕ C) => sorry) fun (X Y : A ⊕ C) (f : X ⟶ Y) => sorry\n\n@[simp] theorem sum_obj_inl {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) (a : A) : obj (sum F G) (sum.inl a) = sum.inl (obj F a) :=\n  rfl\n\n@[simp] theorem sum_obj_inr {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) (c : C) : obj (sum F G) (sum.inr c) = sum.inr (obj G c) :=\n  rfl\n\n@[simp] theorem sum_map_inl {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) {a : A} {a' : A} (f : sum.inl a ⟶ sum.inl a') : map (sum F G) f = map F f :=\n  rfl\n\n@[simp] theorem sum_map_inr {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] (F : A ⥤ B) (G : C ⥤ D) {c : C} {c' : C} (f : sum.inr c ⟶ sum.inr c') : map (sum F G) f = map G f :=\n  rfl\n\nend functor\n\n\nnamespace nat_trans\n\n\n/-- The sum of two natural transformations. -/\ndef sum {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D} (α : F ⟶ G) (β : H ⟶ I) : functor.sum F H ⟶ functor.sum G I :=\n  mk fun (X : A ⊕ C) => sorry\n\n@[simp] theorem sum_app_inl {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D} (α : F ⟶ G) (β : H ⟶ I) (a : A) : app (sum α β) (sum.inl a) = app α a :=\n  rfl\n\n@[simp] theorem sum_app_inr {A : Type u₁} [category A] {B : Type u₁} [category B] {C : Type u₁} [category C] {D : Type u₁} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D} (α : F ⟶ G) (β : H ⟶ I) (c : C) : app (sum α β) (sum.inr c) = app β c :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/sums/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4734209099538017}}
{"text": "import FOL.class_of_formulae FOL.extend\n\nnamespace fol\nopen formula\nnamespace arithmetic\nopen logic logic.Theory axiomatic_classical_logic' axiomatic_classical_logic\nopen_locale logic_symbol\n\nvariables {L L' : language.{0}}\n\ninductive langf : ℕ → Type\n| zero : langf 0\n| succ : langf 1\n| add  : langf 2\n| mul : langf 2\n\ninductive langp : ℕ → Type\n| le : langp 2\n\n@[reducible] def LA : language := ⟨langf, langp⟩\n\ninductive additional_pr : ℕ → Type\n| lt : additional_pr 2\n| dvd : additional_pr 2\n| prime : additional_pr 1\n\n@[reducible] def additional : language := ⟨λ _, pempty, additional_pr⟩\n\ninductive LIopen_fn : ℕ → Type\n| pair : LIopen_fn 2\n\n@[reducible] def LIopen : language := ⟨LIopen_fn, λ _, pempty⟩\n\ninductive LISigma₁_fn : ℕ → Type\n| exp : LISigma₁_fn 1\n\n@[reducible] def LISigma₁ : language := ⟨LISigma₁_fn, λ _, pempty⟩\n\n@[reducible] def LA' : language := LA + additional\n\ninstance : has_zero_symbol LA := ⟨langf.zero⟩\ninstance : has_succ_symbol LA := ⟨langf.succ⟩\ninstance : has_add_symbol LA := ⟨langf.add⟩\ninstance : has_mul_symbol LA := ⟨langf.mul⟩\ninstance : has_le_symbol LA := ⟨langp.le⟩\n\n@[reducible] def LISigma₁.exp (t : term LISigma₁) : term LISigma₁ := term.app LISigma₁_fn.exp ‹t›\n\nprefix `exp `:max := LISigma₁.exp\n\n@[reducible] def LIopen.pair (t u : term LIopen) : term LIopen := term.app LIopen_fn.pair ‹t, u›\n\nnamespace additional\nvariables {L} [LA'.language_translation_coe L]\n\ninstance LA_ltc_L : LA.language_translation_coe L := language.language_translation_coe.comp LA LA' L\n\ninstance additional_ltc_L : additional.language_translation_coe L := language.language_translation_coe.comp additional LA' L\n\ninstance commutes_LA : language.commutes LA LA' L := ⟨by refl⟩\n\ninstance commutes_additional : language.commutes additional LA' L := ⟨by refl⟩\n\ndef lt (t u : term L) : formula L :=\napp ((coe : LA'.pr 2 → L.pr 2) (sum.inr additional_pr.lt)) ‹t, u›\n\ndef dvd (t u : term L) : formula L :=\napp ((coe : LA'.pr 2 → L.pr 2) (sum.inr additional_pr.dvd)) ‹t, u›\n\ndef prime (t : term L) : formula L := app ((coe : LA'.pr 1 → L.pr 1) (sum.inr additional_pr.prime)) ‹t›\n\nnotation t ` is_prime`:80 := prime t\n\ninstance lt_abb : abberavation₂ (@lt L _) := { map_rew := by simp[lt], arity := by simp[lt] }\n\ninstance dvd_abb : abberavation₂ (@dvd L _) := { map_rew := by simp[dvd], arity := by simp[dvd] }\n\ninstance is_prime_abb : abberavation₁ (@prime L _) := { map_rew := by simp[prime], arity := by simp[prime] }\n\nend additional\n\nlocal infix ` ≺ `:50 := additional.lt\n\nlocal infix ` ⍭ `:50 := additional.dvd\n\ninductive robinson : Theory LA\n| q1 : robinson ∀₁ x, 0 ≠' Succ x\n| q2 : robinson ∀₁ x, ∀₁ y, ((Succ x =' Succ y) ⟶ (x =' y))\n| q3 : robinson ∀₁ x, ((x =' 0) ⊔ ∃₁ y, x =' Succ y)\n| q4 : robinson ∀₁ x, x + 0 =' x\n| q5 : robinson ∀₁ x y, x + Succ y =' Succ (x + y)\n| q6 : robinson ∀₁ x, x * 0 =' 0\n| q7 : robinson ∀₁ x y, x * Succ y =' x * y + x\n| q8 : robinson ∀₁ x y, ((x ≼ y) ⟷ ∃₁ z, z + x =' y)\n\nnotation `𝐐` := robinson\n\ninstance : closed_Theory 𝐐 := ⟨λ p h, by cases h; simp[is_sentence, lrarrow_def, formula.ex, formula.and, fal_fn, ex_fn]⟩\n\nnamespace additional\n\ninstance addditional_predicate : additional.predicate := ⟨λ n, pempty.is_empty⟩\n\n@[simp] def df_pr : Π {n} (r : additional.pr n), formula LA\n| 2 additional_pr.lt := ((#0 : term LA) ≼ #1) ⊓ ((#0 : term LA) ≠' #1)\n| 2 additional_pr.dvd := ∃. (#0 * #1 =' #2)\n| 1 additional_pr.prime := ∃. (#0 + 1 =' #1) ⊓ ∀. (∃. (#0 * #2 =' #1) ⟶ (#0 =' 1) ⊔ (#0 =' #1))\n\n@[reducible] def defs : LA.definitions additional :=\n{ df_fn := λ n f, by exfalso; exact is_empty.false f,\n  hdf_fn := λ n f, by exfalso; exact is_empty.false f,\n  df_pr := @df_pr,\n  hdf_pr := λ n r, by rcases r; simp[df_pr, numeral_one_def] }\n\nvariables [LA'.language_translation_coe L] (T : Theory L) [lextend defs.thy T] {i : ℕ}\n\n@[simp] lemma thy.lt (x y) : T ⊢ (x ≺ y) ⟷ (x ≼ y) ⊓ (x ≠' y) :=\nby simpa[fal_fn] using defs.pr' T additional_pr.lt ‹x, y›\n\n@[simp] lemma thy.dvd (x y) : T ⊢ (x ⍭ y) ⟷ ∃. (#0 * x^1 =' y^1) :=\nby simpa[fal_fn, ex_fn] using defs.pr' T additional_pr.dvd ‹x, y›\n\nvariables {T}\n\ndef Herbrand.lt (h₁ h₂ : Herbrand T i) : Lindenbaum T i :=\nLindenbaum.predicate_of ((coe : LA'.pr 2 → L.pr 2) (sum.inr additional_pr.lt)) ‹h₁, h₂›\n\ninfix ` ≺' `:50 := Herbrand.lt\n\n@[simp] lemma Lindenbaum.lt_def (v) :\n  Lindenbaum.predicate_of ((coe : LA'.pr 2 → L.pr 2) (sum.inr additional_pr.lt)) v = (v 0 ≺' v 1 : Lindenbaum T i) := rfl\n\nlemma Lindenbaum.lt_eq (h₁ h₂ : Herbrand T i) : (h₁ ≺' h₂) = (h₁ ≼ h₂) ⊓ (h₁ =' h₂)ᶜ :=\nby induction h₁ using fol.Herbrand.ind_on with t;\n   induction h₂ using fol.Herbrand.ind_on with u;\n   simpa[lt] using Lindenbaum.eq_of_provable_equiv.mp (thy.lt _ t u)\n\ndef Herbrand.dvd (h₁ h₂ : Herbrand T i) : Lindenbaum T i :=\nLindenbaum.predicate_of ((coe : LA'.pr 2 → L.pr 2) (sum.inr additional_pr.dvd)) ‹h₁, h₂›\n\ninfix ` ⍭' `:50 := Herbrand.dvd\n\n@[simp] lemma Lindenbaum.dvd_def (v) :\n  Lindenbaum.predicate_of ((coe : LA'.pr 2 → L.pr 2) (sum.inr additional_pr.dvd)) v = (v 0 ⍭' v 1 : Lindenbaum T i) := rfl\n\nlemma Lindenbaum.dvd_eq (h₁ h₂ : Herbrand T i) : (h₁ ⍭' h₂) = ∃' (♯0 * h₁.pow =' h₂.pow : Lindenbaum T (i + 1)) :=\nby induction h₁ using fol.Herbrand.ind_on with t;\n   induction h₂ using fol.Herbrand.ind_on with u;\n   simpa[dvd] using Lindenbaum.eq_of_provable_equiv.mp (thy.dvd _ t u)\n\nend additional\n\nnamespace Ind\n\nsection\nvariables [LA.language_translation_coe L]\n\ndef succ_induction (p : formula L) : formula L := ∀.* (p.rew (0 ⌢ ı) ⟶ ∀. (p ⟶ p.rew ((Succ #0) ⌢ (λ x, #(x+1)))) ⟶ ∀. p)\n\ndef test (p : formula L) : formula L := p.rew (0 ⌢ ı)\n\n@[simp] lemma succ_induction_sentence (p : formula L) : is_sentence (succ_induction p) := by simp[succ_induction]\n\ndef succ_induction_axiom (C : Theory LA) : Theory LA := 𝐐 ∪ (succ_induction '' C)\n\nprefix `𝐈`:max := succ_induction_axiom\n\n@[reducible] def peano : Theory LA := 𝐈set.univ\n\nnotation `𝐏𝐀` := peano\n\ninstance {C : Theory LA} : closed_Theory 𝐈C := \n⟨λ p h, by { rcases h with (h | ⟨p, hp, rfl⟩), { refine closed_Theory.cl h }, { simp[succ_induction] } }⟩\n\ndef collection (p : formula L) : formula L :=\n  ∀₁ u, (∀₁ x ≼ᵇ u, ∃₁ y, p.rew ı-{2}) ⟶ (∃₁ v, ∀₁ x ≼ᵇ u, ∃₁ y ≼ᵇ v, p.rew ı-{2}-{2})\n\ndef collection_axiom (C : Theory LA) : Theory LA := 𝐐 ∪ (collection '' C)\n\nprefix `𝐁`:max := collection_axiom\n\nend \n\nsection\nvariables [LA'.language_translation_coe L]\n\ndef order_induction (p : formula L) : formula L := (∀₁ x, ((∀₁ y ≺ᵇ x, p.rew ı-{1}) ⟶ p)) ⟶ ∀₁ x, p\n\ndef order_induction_axiom (C : Theory LA') : Theory LA' := ↑𝐐 ∪ (order_induction '' C)\n\nprefix `𝐈′`:max := order_induction_axiom\n\nend\n\n@[simp] lemma Q_ss_I {C} : 𝐐 ⊆ 𝐈C := by simp[succ_induction_axiom]\n\ninstance extend_Q_I (C : Theory LA) : extend 𝐐 𝐈C := ⟨λ p h, weakening Q_ss_I h⟩\n\ninstance extend_ax₁ (C : Theory LA) (p : formula LA) : extend 𝐐 (𝐈C +{ p }) :=\nTheory.extend_of_inclusion (λ p mem, by simp[Q_ss_I mem])\n\ninstance extend_ax₂ (C : Theory LA) (p q : formula LA) : extend 𝐐 (𝐈C +{ p }+{ q }) :=\nTheory.extend_of_inclusion (λ p mem, by simp[Q_ss_I mem])\n\ninstance extend_ax₃ (C : Theory LA) (p q r : formula LA) : extend 𝐐 (𝐈C +{ p }+{ q }+{ r }) :=\nTheory.extend_of_inclusion (λ p mem, by simp[Q_ss_I mem])\n\ninstance extend_ax₄ (C : Theory LA) (p q r s : formula LA) : extend 𝐐 (𝐈C +{ p }+{ q }+{ r }+{ s }) :=\nTheory.extend_of_inclusion (λ p mem, by simp[Q_ss_I mem])\n\nend Ind\n\nnamespace robinson\nopen Herbrand Lindenbaum provable\nvariables {L} [LA.language_translation_coe L] (Q : Theory L) [lextend 𝐐 Q] (i : ℕ)\n\n@[simp] lemma zero_ne_succ (t : term L) : Q ⊢ 0 ≠' Succ t :=\nby { have : Q ⊢ ∀₁ x, 0 ≠' Succ x, by simpa[fal_fn] using provable.lextend (by_axiom robinson.q1) Q,\n     simpa using this ⊚ t }\n\n@[simp] lemma Lindembaum.zero_ne_succ (h : Herbrand Q i) : 0 =' Succ h = (⊥ : Lindenbaum Q i) :=\nby { induction h using fol.Herbrand.ind_on with t,\n     simpa[Lindenbaum.eq_neg_of_provable_neg_0] using zero_ne_succ (Q^i) t }\n\n@[simp] lemma Lindenbaum.succ_ne_zero (h : Herbrand Q i) : Succ h =' 0 = (⊥ : Lindenbaum Q i) :=\nby simp [Lindenbaum.equal_symm (Succ h) 0]\n\n@[simp] lemma succ_inj (t u : term L) :\n  Q ⊢ (Succ t =' Succ u) ⟶ (t =' u) :=\nby { have : Q ⊢ ∀₁ x y, (Succ x =' Succ y) ⟶ (x =' y), by simpa[fal_fn] using provable.lextend (by_axiom robinson.q2) Q,\n     simpa[fal_fn] using this ⊚ t ⊚ u }\n\n@[simp] lemma Lindenbaum.succ_inj  (h₁ h₂ : Herbrand Q i) : (Succ h₁ =' Succ h₂ : Lindenbaum Q i) = (h₁ =' h₂) :=\nby { induction h₁ using fol.Herbrand.ind_on with t,\n     induction h₂ using fol.Herbrand.ind_on with u,\n     have : Q^i ⊢ (Succ t =' Succ u) ⟷ (t =' u), by simp[iff_equiv],\n     simpa using Lindenbaum.eq_of_provable_equiv.mp this }\n\nlemma Herbrand.succ_injective : function.injective (has_succ.succ : Herbrand Q i → Herbrand Q i) :=\nλ h₁ h₂,\nbegin\n  induction h₁ using fol.Herbrand.ind_on with t,\n  induction h₂ using fol.Herbrand.ind_on with u,\n  intros h,\n  have lmm₁ : Q^i ⊢ Succ t =' Succ u, from Herbrand.eq_of_provable_equiv.mpr (by simp[h]),\n  have lmm₂ : Q^i ⊢ (Succ t =' Succ u) ⟶ (t =' u), by simp, \n  have : Q^i ⊢ t =' u, from lmm₂ ⨀ lmm₁,\n  exact Herbrand.eq_of_provable_equiv.mp this\nend\n\n@[simp] lemma Herbrand.succ_injective_iff (h₁ h₂ : Herbrand Q i) : Succ h₁ = Succ h₂ ↔ h₁ = h₂ :=\n⟨@@Herbrand.succ_injective _ Q _ i, λ h, by simp[h]⟩\n\n@[simp] lemma zero_or_succ (t) : Q ⊢ (t =' 0) ⊔ (∃₁ y, t^1 =' Succ y) :=\nby { have : Q ⊢ ∀₁ x, (x =' 0) ⊔ (∃₁ y, x =' Succ y), by simpa[fal_fn, ex_fn] using provable.lextend (by_axiom robinson.q3) Q,\n     simpa[fal_fn, ex_fn] using this ⊚ t }\n\n@[simp] lemma add_zero (t : term L) : Q ⊢ t + 0 =' t :=\nby { have : Q ⊢ ∀₁ x, (x + 0 =' x), by simpa[fal_fn, ex_fn] using provable.lextend (by_axiom robinson.q4) Q,\n     simpa[fal_fn, ex_fn] using this ⊚ t }\n\n@[simp] lemma Herbrand.add_zero (h : Herbrand Q i) : h + 0 = h :=\nby { induction h using fol.Herbrand.ind_on with t,\n     simpa using Herbrand.eq_of_provable_equiv.mp (add_zero (Q^i) t) }\n\n@[simp] lemma add_succ (t u : term L) : Q ⊢ t + Succ u =' Succ (t + u) :=\nby { have : Q ⊢ ∀₁ x y, x + Succ y =' Succ (x + y), by simpa[fal_fn, ex_fn] using provable.lextend (by_axiom robinson.q5) Q,\n     simpa[fal_fn, ex_fn] using this ⊚ t ⊚ u }\n\n@[simp] lemma Herbrand.add_succ {i} (h₁ h₂ : Herbrand Q i) : h₁ + Succ h₂ = Succ (h₁ + h₂) :=\nby { induction h₁ using fol.Herbrand.ind_on with t,\n     induction h₂ using fol.Herbrand.ind_on with u,\n     simpa using Herbrand.eq_of_provable_equiv.mp (add_succ (Q^i) t u) }\n\n@[simp] lemma mul_zero (t : term L) : Q ⊢ t * 0 =' 0 :=\nby { have : Q ⊢ ∀₁ x, x * 0 =' 0, by simpa[fal_fn, ex_fn] using provable.lextend (by_axiom robinson.q6) Q,\n     simpa[fal_fn, ex_fn] using this ⊚ t }\n\n@[simp] lemma Herbrand.mul_zero  (h : Herbrand Q i) : h * 0 = 0 :=\nby { induction h using fol.Herbrand.ind_on with t,\n     simpa using Herbrand.eq_of_provable_equiv.mp (mul_zero (Q^i) t) }\n\n@[simp] lemma mul_succ (t u : term L) : Q ⊢ t * Succ u =' t * u + t :=\nby { have : Q ⊢ ∀₁ x y, x * Succ y =' x * y + x, by simpa[fal_fn, ex_fn] using provable.lextend (by_axiom robinson.q7) Q,\n     simpa[fal_fn, ex_fn] using this ⊚ t ⊚ u }\n\n@[simp] lemma Herbrand.mul_succ {i} (h₁ h₂ : Herbrand Q i) : h₁ * Succ h₂ = h₁ * h₂ + h₁ :=\nby { induction h₁ using fol.Herbrand.ind_on with t,\n     induction h₂ using fol.Herbrand.ind_on with u,\n     simpa using Herbrand.eq_of_provable_equiv.mp (mul_succ (Q^i) t u) }\n\n@[simp] lemma le_iff (t u : term L) : Q ⊢ (t ≼ u) ⟷ ∃. (#0 + t^1 =' u^1) :=\nby { have : Q ⊢ ∀₁ x y, (x ≼ y) ⟷ ∃₁ z, (z + x =' y), by simpa[fal_fn, ex_fn] using provable.lextend (by_axiom robinson.q8) Q,\n     simpa[fal_fn, ex_fn, ←term.pow_rew_distrib] using this ⊚ t ⊚ u }\n\nlemma Lindenbaum.le_iff {h₁ h₂ : Herbrand Q i} :\n  (h₁ ≼ h₂ : Lindenbaum Q i) = ∃' (♯0 + h₁.pow =' h₂.pow : Lindenbaum Q (i + 1)) :=\nby { induction h₁ using fol.Herbrand.ind_on with t,\n     induction h₂ using fol.Herbrand.ind_on with u,\n     simpa[ex_fn] using Lindenbaum.eq_of_provable_equiv.mp (le_iff (Q^i) t u) }\n\nnamespace Lindenbaum\n\nlemma le_of_eq (e : Herbrand Q i) {h₁ h₂ : Herbrand Q i} (h : e + h₁ = h₂) : h₁ ≤ h₂ :=\nbegin\n  induction e using fol.Herbrand.ind_on with u,\n  induction h₁ using fol.Herbrand.ind_on with t₁,\n  induction h₂ using fol.Herbrand.ind_on with t₂,\n  have lmm₁ : Q^i ⊢ ∃. (#0 + t₁^1 =' t₂^1),\n  { refine use u _, simp, refine Herbrand.eq_of_provable_equiv.mpr (by simp[h]) },\n  have lmm₂ : Q^i ⊢ (t₁ ≼ t₂) ⟷ ∃. (#0 + t₁^1 =' t₂^1), by simp,\n  exact Herbrand.le_iff_provable_le.mp (of_equiv lmm₁ (equiv_symm lmm₂))\nend\n\n@[simp] lemma le_add_self (h₁ h₂ : Herbrand Q i) : h₁ ≤ h₂ + h₁ := le_of_eq Q i h₂ rfl\n\n@[simp] lemma succ_inj_le {h₁ h₂ : Herbrand Q i} :\n  (Succ h₁ ≼ Succ h₂ : Lindenbaum Q i) = (h₁ ≼ h₂) := by simp[le_iff, succ_pow]\n\nlemma add_numeral_eq_numeral_add (m n : ℕ) : (n˙ : Herbrand Q i) + m˙ = (n + m)˙ :=\nby induction m with m IH; simp[numeral, *, ←nat.add_one, ←add_assoc]\n\nlemma mul_numeral_eq_numeral_mul (m n : ℕ) : (n˙ : Herbrand Q i) * m˙ = (n * m)˙ :=\nby induction m with m IH; simp[numeral, *, ←nat.add_one, add_numeral_eq_numeral_add, mul_add]\n\nlemma succ_add_numeral_eq_add_succ_numeral (h : Herbrand Q i) (n : ℕ) : Succ h + n˙ = h + (n + 1)˙ :=\nby induction n with n IH; simp[numeral, *]\n\nend Lindenbaum\n\n@[simp] lemma add_eq_zero : Q ⊢ ∀₁ x y, (x + y =' 0) ⟶ (x =' 0) ⊓ (y =' 0) :=\nbegin\n  refine generalize (generalize _), simp[fal_fn], \n  have lmm₁ : ⤊⤊Q ⊢ (#0 =' 0) ⟶ (#1 + #0 =' 0) ⟶ (#1 =' 0) ⊓ (#0 =' 0),\n    from (deduction.mp (by simp [le_of_provable_imply_0, rew_by_axiom₁])),\n  have lmm₂ : ⤊⤊Q ⊢ (∃₁ y, #1 =' Succ y) ⟶ (#1 + #0 =' 0) ⟶ (#1 =' 0) ⊓ (#0 =' 0),\n    from imply_ex_of_fal_imply (generalize (deduction.mp (by simp [le_of_provable_imply_0, rew_by_axiom₁]))), \n  exact case_of_ax (zero_or_succ _ #0) lmm₁ lmm₂\nend\n\n@[simp] lemma Lindenbaum.add_eq_0_of_eq_0 (x y : Herbrand Q i) :\n  (x + y =' 0 : Lindenbaum Q i) = (x =' 0) ⊓ (y =' 0) :=\nbegin\n  induction x using fol.Herbrand.ind_on,\n  induction y using fol.Herbrand.ind_on,\n  have : Q^i ⊢ (x + y =' 0) ⟷ (x =' 0) ⊓ (y =' 0), \n  { simp[iff_equiv],\n    refine ⟨by simpa[fal_fn] using add_eq_zero (Q^i) ⊚ x ⊚ y, deduction.mp _⟩, simp,\n    simp[Herbrand.eq_of_provable_equiv_0, rew_by_axiom₁, rew_by_axiom₂] },\n  simpa using Lindenbaum.eq_of_provable_equiv.mp this\nend\n\nlemma mul_eq_zero : Q ⊢ ∀₁ x y, (x * y =' 0) ⟶ (x =' 0) ⊔ (y =' 0) :=\nbegin\n  refine generalize (generalize _), simp[fal_fn], \n  have lmm₁ : ⤊⤊Q ⊢ (#0 =' 0) ⟶ (#1 * #0 =' 0) ⟶ (#1 =' 0) ⊔ (#0 =' 0),\n  { refine (deduction.mp _),\n    simp[le_of_provable_imply_0, rew_by_axiom₁] },\n  have lmm₂ : ⤊⤊Q ⊢ (∃₁ y, #1 =' Succ y) ⟶ (#1 * #0 =' 0) ⟶ (#1 =' 0) ⊔ (#0 =' 0),\n  { refine imply_ex_of_fal_imply (generalize (deduction.mp _)), simp,\n    simp[le_of_provable_imply_0, rew_by_axiom₁] },\n  exact case_of_ax (zero_or_succ _ #0) lmm₁ lmm₂\nend\n\nlemma zero_le : Q ⊢ ∀₁ x, 0 ≼ x :=\nbegin\n  refine generalize _, simp[fal_fn],\n  have : ⤊Q ⊢ (0 ≼ #0) ⟷ (∃₁ z, z + 0 =' #1), by simpa using (le_iff ⤊Q 0 #0), \n  refine of_equiv (use #0 (by simp)) (equiv_symm this),\nend\n\n@[simp] lemma Lindenbaum.zero_le (h : Herbrand Q i) : 0 ≤ h :=\nby induction h using fol.Herbrand.ind_on with t;\n   simpa using Herbrand.le_iff_provable_le.mp (by simpa[fal_fn] using zero_le (Q^i) ⊚ t)\n\n@[simp] lemma le_zero_equiv_eq_zero : Q ⊢ ∀₁ x, (x ≼ 0) ⟷ (x =' 0) :=\nbegin\n  refine generalize _, simp[fal_fn],\n  suffices : ⤊Q ⊢ ∃. (#0 + #1 =' 0) ⟷ (#0 =' 0),\n    by simpa[Lindenbaum.eq_of_provable_equiv_0, Lindenbaum.le_iff] using this,\n  simp[iff_equiv], split,\n  { refine ((pnf_imply_ex_iff_fal_imply₁ _ _).mpr $ generalize _),\n    simp[Lindenbaum.le_of_provable_imply_0] },\n  { refine deduction.mp (use 0 _), simp[ı, Herbrand.eq_of_provable_equiv_0, rew_by_axiom₁] }\nend\n\n@[simp] lemma Lindenbaum.le_zero_eq_eq_zero (h : Herbrand Q i) : (h ≼ 0 : Lindenbaum Q i) = (h =' 0) :=\nby induction h using fol.Herbrand.ind_on with t;\n   simpa[Lindenbaum.eq_of_provable_equiv_0] using (le_zero_equiv_eq_zero (Q^i) ⊚ t)\n\n@[simp] lemma add_numeral_eq_numeral_add (n m : ℕ) : Q ⊢ (n˙ : term L) + m˙ =' (n + m)˙ :=\nby simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.add_numeral_eq_numeral_add]\n\n@[simp] lemma mul_numeral_eq_numeral_mul (n m : ℕ) : Q ⊢ (n˙ : term L) * m˙ =' (n * m)˙ :=\nby simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.mul_numeral_eq_numeral_mul]\n\nlemma le_numeral_of_le {n m : ℕ} (h : n ≤ m) : Q ⊢ (n˙ : term L) ≼ m˙ :=\nbegin\n  let l := m - n,\n  have : m = l + n, from (nat.sub_eq_iff_eq_add h).mp rfl,\n  simp[this],\n  refine of_equiv (use (l˙) _) (equiv_symm $ le_iff Q (n˙) ((l + n)˙)), simp\nend\n\nlemma le_numeral_iff (n : ℕ) : Q ⊢ ∀. ((#0 ≼ n˙) ⟷ ⋁ i : fin (n+1), #0 =' (i : ℕ)˙) :=\nbegin\n  suffices : ∀ k : ℕ, Q^k ⊢ ∀. ((#0 ≼ n˙) ⟷ ⋁ i : fin (n+1), #0 =' (i : ℕ)˙),\n  { exact this 0 },\n  induction n with n IH,\n  { intros k, refine generalize _, simp[Lindenbaum.eq_of_provable_equiv_0], exact Lindenbaum.le_zero_eq_eq_zero _ _ _ },\n  { intros k, refine generalize _,\n    simp[←Theory.sf_itr_succ, iff_equiv, -finitary.disjunction], split,\n    { have zero : Q^(k + 1) ⊢ (#0 =' 0) ⟶ (#0 ≼ (n + 1)˙) ⟶ ⋁ (i : fin (n.succ + 1)), #0 =' ↑i˙,\n      { refine (deduction.mp $ deduction.mp $ imply_or_right _ _ ⨀ (rew_of_eq 0 0 (by simp) _)), \n        simp, refine disjunction_of ⟨0, by simp⟩ (by simp[numeral]) },\n      have succ : Q^(k + 1) ⊢ (∃₁ y, #1 =' Succ y) ⟶ (#0 ≼ (n + 1)˙) ⟶ ⋁ (i : fin (n.succ + 1)), #0 =' ↑i˙,\n      { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ rew_of_eq (Succ #0) 1 (by simp) (deduction.mp _)),\n        simp[ -finitary.disjunction, ←Theory.sf_itr_succ], \n        have : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 ≼ (n + 1)˙ } ⊢ #0 ≼ n˙,\n          from of_equiv_p (show _ ⊢ Succ #0 ≼ (n + 1)˙, by simp) (by simp[numeral, Lindenbaum.eq_of_provable_equiv_0]), \n        have lmm₁ : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 ≼ (n + 1)˙ } ⊢ ⋁ (i : fin (n + 1)), #0 =' ↑i˙,\n          from of_equiv_p this (weakening\n            (show Q^(k + 2) ⊆ (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 ≼ (n + 1)˙ }, by { intros p mem, refine set.subset_insert _ _ (set.subset_insert _ _ mem) })\n            (show Q^(k + 2) ⊢ (#0 ≼ n˙) ⟷ ⋁ (i : fin (n + 1)), #0 =' ↑i˙, by simpa using IH (k + 2) ⊚ #0)),\n        have lmm₂ : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 ≼ (n + 1)˙ } ⊢ (⋁ (i : fin (n + 1)), #0 =' ↑i˙) ⟶ (⋁ (i : fin (n.succ + 1)), Succ #0 =' ↑i˙),\n        { suffices : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 ≼ (n + 1)˙ } ⊢ ⋀ (i : fin (n + 1)), (#0 =' ↑i˙) ⟶ ⋁ (i : fin (n.succ + 1)), Succ #0 =' ↑i˙,\n            from of_equiv this (conj_imply_iff_disj_imply _ _),\n          refine conjunction_iff.mpr (λ i, deduction.mp $ rew_of_eq (↑i˙) 0 (by simp) _), simp[-finitary.disjunction],\n          refine disjunction_of ⟨i + 1, by simp⟩ (by simp[numeral]) },\n        exact lmm₂ ⨀ lmm₁ },\n      exact case_of_ax (show (Q^(k + 1)) ⊢ (#0 =' 0) ⊔ ∃₁ y, (#1 =' Succ y), from zero_or_succ (Q^(k + 1)) #0) zero succ },\n    { refine of_equiv (conjunction_iff.mpr _) (conj_imply_iff_disj_imply _ _),\n      rintros ⟨i, hi⟩, refine (deduction.mp $  rew_of_eq (i˙) 0 (by simp) _),\n      simp[←nat.add_one],\n      exact le_numeral_of_le _ (show i ≤ n + 1, from nat.lt_succ_iff.mp hi) } }\nend\n\nend robinson\n\nnamespace Ind\nopen Herbrand Lindenbaum robinson.Lindenbaum provable\nvariables (C : Theory LA)\n          {L} [LA.language_translation_coe L] (T : Theory L) [lextend 𝐈C T]\n          {L'} [LA'.language_translation_coe L'] (T' : Theory L') [lextend 𝐈C T']\n\nlemma I_succ_induction_aux (p : formula LA) (h : p ∈ C) :\n  T ⊢ succ_induction p :=\nby { have : 𝐈C ⊢ succ_induction p, from by_axiom (by { simp[succ_induction_axiom, h], refine or.inr ⟨p, by simp[h]⟩ }),\n     simpa[succ_induction, language.language_translation_coe.coe_p_rew] using provable.lextend this T }\n\nlemma I_succ_induction (p : formula LA) (h : p ∈ C) :\n  T ⊢ p.rew (0 ⌢ ı) ⟶ ∀. (p ⟶ p.rew ((Succ #0) ⌢ (λ x, #(x+1)))) ⟶ ∀. p :=\nby simpa using provable.fal_complete_rew _ ı ⨀ (I_succ_induction_aux C T p h)\n\nlemma equiv_succ_induction_of_equiv {T₀ : Theory L} [closed_Theory T₀] {p q : formula L} (h : T₀ ⊢ p ⟷ q) :\n  T₀ ⊢ succ_induction p ⟷ succ_induction q :=\nbegin\n  refine (equiv_fal_complete_of_equiv _), simp,\n  refine (equiv_imply_of_equiv _ $ equiv_imply_of_equiv _ _),\n  { simpa using cl_prove_rew h (0 ⌢ ı) },\n  { refine equiv_univ_of_equiv (equiv_imply_of_equiv _ _); simp*, simpa using cl_prove_rew h _ },\n  { refine equiv_univ_of_equiv (by simp[h]) }\nend\n\n@[simp] lemma equiv_succ_induction_of_equgiv {L₁ L₂ : language.{0}}\n  [LA.language_translation_coe L₁] [LA.language_translation_coe L₂] [L₁.language_translation_coe L₂] [LA.commutes L₁ L₂]\n  (p : formula L₁) :\n  (↑(succ_induction p : formula L₁) : formula L₂) = succ_induction (↑p : formula L₂) :=\nby simp[succ_induction, language.language_translation_coe.coe_p_rew, function.comp]\n\nsection\nvariables {L₁ L₂ : language.{0}}\n  [LA'.language_translation_coe L₁] [LA'.language_translation_coe L₂] [L₁.language_translation_coe L₂] [LA'.commutes L₁ L₂]\n\n@[simp] lemma coe_lt (t u : term L₁) : ((t ≺ u : formula L₁) : formula L₂) = (t ≺ u) :=\nby simp[additional.lt]; refine language.commutes.coe_coe_pr_of_commute _\n\n@[simp] lemma coe_dvd (t u : term L₁) : ((t ⍭ u : formula L₁) : formula L₂) = (t ⍭ u) :=\nby simp[additional.dvd]; refine language.commutes.coe_coe_pr_of_commute _\n\n@[simp] lemma quantifier_fn_aux_lt (s) (f g : term L₁ → term L₁) (t u : term L₁) :\n  quantifier_fn_aux s (λ x, f x ≺ g x) (t ≺ u) = (f #s ≺ g #s) := rfl\n\n@[simp] lemma quantifier_fn_aux_dvd (s) (f g : term L₁ → term L₁) (t u : term L₁) :\n  quantifier_fn_aux s (λ x, f x ⍭ g x) (t ⍭ u) = (f #s ⍭ g #s) := rfl\n\nend\n\nend Ind\n\nnamespace Iopen\nopen Lindenbaum Herbrand additional robinson Ind robinson.Lindenbaum provable\nvariables {L} [LA.language_translation_coe L] (Iₒₚₑₙ : Theory L) [lextend 𝐈is_open Iₒₚₑₙ] (i : ℕ)\n          {L'} [LA'.language_translation_coe L'] (Iₒₚₑₙ' : Theory L') [lextend 𝐈is_open Iₒₚₑₙ']\n          [lextend additional.defs.thy Iₒₚₑₙ']\n\ninstance lextend_Q : lextend 𝐐 Iₒₚₑₙ := Theory.lextend_trans 𝐐 𝐈is_open Iₒₚₑₙ\n\nlemma I_succ_induction_LA (p : formula LA') (h : formula.coe_inv_is_open defs p):\n  Iₒₚₑₙ' ⊢ p.rew (0 ⌢ ı) ⟶ ∀. (p ⟶ p.rew ((Succ #0) ⌢ (λ x, #(x+1)))) ⟶ ∀. p :=\nbegin\n  have : Iₒₚₑₙ' ⊢ succ_induction ↑p ⟷ succ_induction ↑(coe_inv defs p),\n    by simpa using provable.lextend (equiv_succ_induction_of_equiv (coe_inv_equiv additional.defs p)) Iₒₚₑₙ',\n  have : Iₒₚₑₙ' ⊢ succ_induction ↑p,\n    from of_equiv_p (I_succ_induction_aux is_open Iₒₚₑₙ' (coe_inv defs p) (by simp[set.mem_def, h])) (equiv_symm this),\n  simpa using provable.fal_complete_rew _ ı ⨀ this\nend\n\n@[simp] lemma zero_add : Iₒₚₑₙ ⊢ ∀₁ x, 0 + x =' x :=\nbegin\n  have lmm₁ : Iₒₚₑₙ ⊢ (0 + 0 =' 0) ⟶ ∀. ((0 + #0 =' #0) ⟶ (0 + Succ #0 =' Succ #0)) ⟶ ∀. (0 + #0 =' #0), \n    by simpa using Ind.I_succ_induction is_open Iₒₚₑₙ (0 + #0 =' #0) (by simp[set.mem_def]),\n  have lmm₂ : Iₒₚₑₙ ⊢ ∀. ((0 + #0 =' #0) ⟶ (0 + Succ #0 =' Succ #0)),\n  { refine generalize (deduction.mp _), \n    have : ⤊Iₒₚₑₙ +{ 0 + #0 =' #0 } ⊢ 0 + #0 =' #0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢, exact this },\n  simpa using (lmm₁ ⨀ (by simp[Herbrand.eq_of_provable_equiv_0]) ⨀ lmm₂)\nend\n\n@[simp] lemma Lindenbaum.zero_add (h : Herbrand Iₒₚₑₙ i) : 0 + h = h :=\nby induction h using fol.Herbrand.ind_on with t;\n   simpa using Herbrand.eq_of_provable_equiv.mp (zero_add (Iₒₚₑₙ^i) ⊚ t)\n\n@[simp] lemma succ_add : Iₒₚₑₙ ⊢ ∀₁ x y, Succ x + y =' Succ (x + y) :=\nbegin\n  have ind : ⤊Iₒₚₑₙ ⊢ (Succ #0 + 0 =' Succ (#0 + 0)) ⟶\n                    ∀. ((Succ #1 + #0 =' Succ (#1 + #0)) ⟶ (Succ #1 + Succ #0 =' Succ (#1 + Succ #0))) ⟶\n                    ∀. (Succ #1 + #0 =' Succ (#1 + #0)), \n  by simpa using Ind.I_succ_induction is_open ⤊Iₒₚₑₙ (Succ #1 + #0 =' Succ (#1 + #0)) (by simp[set.mem_def]),\n  have zero : ⤊Iₒₚₑₙ ⊢ Succ #0 + 0 =' Succ (#0 + 0),  by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : ⤊Iₒₚₑₙ ⊢ ∀. ((Succ #1 + #0 =' Succ (#1 + #0)) ⟶ (Succ #1 + Succ #0 =' Succ (#1 + Succ #0))),\n  { refine (generalize $ deduction.mp _), simp,\n    have : ⤊⤊Iₒₚₑₙ +{ Succ #1 + #0 =' Succ (#1 + #0) } ⊢ Succ #1 + #0 =' Succ (#1 + #0), by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢,  exact this },\n  simpa using (generalize $ ind ⨀ zero ⨀ succ)\nend\n\n@[simp] lemma Lindenbaum.succ_add (h₁ h₂ : Herbrand Iₒₚₑₙ i) : Succ h₁ + h₂ = Succ (h₁ + h₂) :=\nby induction h₁ using fol.Herbrand.ind_on with t;\n   induction h₂ using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (succ_add (Iₒₚₑₙ^i) ⊚ t ⊚ u)\n\nlemma add_commutative : Iₒₚₑₙ ⊢ ∀₁ x y, x + y =' y + x :=\nbegin\n  have ind : ⤊Iₒₚₑₙ ⊢ (#0 + 0 =' 0 + #0) ⟶ ∀. ((#1 + #0 =' #0 + #1) ⟶ (#1 + Succ #0 =' Succ #0 + #1)) ⟶ ∀. (#1 + #0 =' #0 + #1),\n    by simpa using Ind.I_succ_induction is_open ⤊Iₒₚₑₙ (#1 + #0 =' #0 + #1) (by simp[set.mem_def]),\n  have zero : ⤊Iₒₚₑₙ ⊢ #0 + 0 =' 0 + #0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : ⤊Iₒₚₑₙ ⊢ ∀. ((#1 + #0 =' #0 + #1) ⟶ (#1 + Succ #0 =' Succ #0 + #1)),\n  { refine (generalize $ deduction.mp _), simp,\n    have : ⤊⤊Iₒₚₑₙ +{ #1 + #0 =' #0 + #1 } ⊢ #1 + #0 =' #0 + #1, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢, exact this },\n  simpa using (generalize $ ind ⨀ zero ⨀ succ)\nend\n\nlemma Lindenbaum.add_commutative (h₁ h₂ : Herbrand Iₒₚₑₙ i) : h₁ + h₂ = h₂ + h₁ :=\nby induction h₁ using fol.Herbrand.ind_on with t;\n   induction h₂ using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (add_commutative (Iₒₚₑₙ^i) ⊚ t ⊚ u)\n\nlemma add_associative : Iₒₚₑₙ ⊢ ∀₁ x y z, x + y + z =' x + (y + z) :=\nbegin\n  have ind : ⤊⤊Iₒₚₑₙ ⊢ (#1 + #0 + 0 =' #1 + (#0 + 0)) ⟶\n                     ∀. ((#2 + #1 + #0 =' #2 + (#1 + #0)) ⟶ (#2 + #1 + Succ #0 =' #2 + (#1 + Succ #0))) ⟶\n                     ∀. (#2 + #1 + #0 =' #2 + (#1 + #0)),\n  by simpa using Ind.I_succ_induction is_open ⤊⤊Iₒₚₑₙ (#2 + #1 + #0 =' #2 + (#1 + #0)) (by simp[set.mem_def]),\n  have zero : ⤊⤊Iₒₚₑₙ ⊢ #1 + #0 + 0 =' #1 + (#0 + 0), by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : ⤊⤊Iₒₚₑₙ ⊢ ∀. ((#2 + #1 + #0 =' #2 + (#1 + #0)) ⟶ (#2 + #1 + Succ #0 =' #2 + (#1 + Succ #0))),\n  { refine (generalize $ deduction.mp _), simp,\n    have : ⤊⤊⤊Iₒₚₑₙ +{ #2 + #1 + #0 =' #2 + (#1 + #0) } ⊢ #2 + #1 + #0 =' #2 + (#1 + #0), by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢, exact this },\n  simpa using (generalize $ generalize $ ind ⨀ zero ⨀ succ)\nend\n\nlemma Lindenbaum.add_associative (h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i) : h₁ + h₂ + h₃ = h₁ + (h₂ + h₃) :=\nby induction h₁ using fol.Herbrand.ind_on with t₁;\n   induction h₂ using fol.Herbrand.ind_on with t₂;\n   induction h₃ using fol.Herbrand.ind_on with t₃;\n   simpa using Herbrand.eq_of_provable_equiv.mp (add_associative _ ⊚ t₁ ⊚ t₂ ⊚ t₃)\n\n\ninstance Lindenbaum.add_comm_semigroup : add_comm_semigroup (Herbrand Iₒₚₑₙ i) :=\n{ add := (+),\n  add_assoc := Lindenbaum.add_associative _ _,\n  add_comm := Lindenbaum.add_commutative _ _ }\n\nlemma zero_mul : Iₒₚₑₙ ⊢ ∀₁ x, 0 * x =' 0 :=\nbegin\n  have ind : Iₒₚₑₙ ⊢ (0 * 0 =' 0) ⟶ ∀. ((0 * #0 =' 0) ⟶ (0 * Succ #0 =' 0)) ⟶ ∀. (0 * #0 =' 0),\n    by simpa using Ind.I_succ_induction is_open Iₒₚₑₙ (0 * #0 =' 0) (by simp[set.mem_def]), \n  have zero : Iₒₚₑₙ ⊢ 0 * 0 =' 0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : Iₒₚₑₙ ⊢ ∀. ((0 * #0 =' 0) ⟶ (0 * Succ #0 =' 0)),\n  { refine (generalize $ deduction.mp _),\n    have : ⤊Iₒₚₑₙ +{ 0 * #0 =' 0 } ⊢ 0 * #0 =' 0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢, simp[this] },\n  simpa using ind ⨀ zero ⨀ succ\nend\n\n@[simp] lemma Lindenbaum.zero_mul (h : Herbrand Iₒₚₑₙ i) : 0 * h = 0 :=\nby induction h using fol.Herbrand.ind_on with t;\n   simpa using Herbrand.eq_of_provable_equiv.mp (zero_mul _ ⊚ t)\n\nlemma succ_mul : Iₒₚₑₙ ⊢ ∀₁ x y, Succ x * y =' x * y + y :=\nbegin\n  have ind : ⤊Iₒₚₑₙ ⊢ (Succ #0 * 0 =' #0 * 0 + 0) ⟶\n                    ∀. ((Succ #1 * #0 =' #1 * #0 + #0) ⟶ (Succ #1 * Succ #0 =' #1 * Succ #0 + Succ #0)) ⟶\n                    ∀. (Succ #1 * #0 =' #1 * #0 + #0),\n  by simpa using Ind.I_succ_induction is_open ⤊Iₒₚₑₙ (Succ #1 * #0 =' #1 * #0 + #0) (by simp[set.mem_def]),\n  have zero : ⤊Iₒₚₑₙ ⊢ Succ #0 * 0 =' #0 * 0 + 0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : ⤊Iₒₚₑₙ ⊢ ∀. ((Succ #1 * #0 =' #1 * #0 + #0) ⟶ (Succ #1 * Succ #0 =' #1 * Succ #0 + Succ #0)),\n  { refine (generalize $ deduction.mp _),\n    have : ⤊⤊Iₒₚₑₙ +{ Succ #1 * #0 =' #1 * #0 + #0 } ⊢ Succ #1 * #0 =' #1 * #0 + #0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢,\n    calc (Succ ♯1 * ♯0 + ♯1 : Herbrand (⤊⤊Iₒₚₑₙ +{ Succ #1 * #0 =' #1 * #0 + #0 }) 0)\n        = ♯1 * ♯0 + ♯0 + ♯1   : by rw[this]\n    ... = ♯1 * ♯0 + (♯1 + ♯0) : by simp[add_assoc, add_comm]\n    ... = ♯1 * ♯0 + ♯1 + ♯0   : by simp[add_assoc] },\n  simpa using (generalize $ ind ⨀ zero ⨀ succ)\nend\n\n@[simp] lemma Lindenbaum.succ_mul (h₁ h₂ : Herbrand Iₒₚₑₙ i) : Succ h₁ * h₂ = h₁ * h₂ + h₂ :=\nby induction h₁ using fol.Herbrand.ind_on with t;\n   induction h₂ using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (succ_mul _ ⊚ t ⊚ u)\n\nlemma mul_commutative : Iₒₚₑₙ ⊢ ∀₁ x y, x * y =' y * x :=\nbegin\n  have ind : ⤊Iₒₚₑₙ ⊢ (#0 * 0 =' 0 * #0) ⟶ ∀. ((#1 * #0 =' #0 * #1) ⟶ (#1 * Succ #0 =' Succ #0 * #1)) ⟶ ∀. (#1 * #0 =' #0 * #1),\n    by simpa using Ind.I_succ_induction is_open ⤊Iₒₚₑₙ (#1 * #0 =' #0 * #1) (by simp[set.mem_def]),\n  have zero : ⤊Iₒₚₑₙ ⊢ #0 * 0 =' 0 * #0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : ⤊Iₒₚₑₙ ⊢ ∀. ((#1 * #0 =' #0 * #1) ⟶ (#1 * Succ #0 =' Succ #0 * #1)),\n  { refine (generalize $ deduction.mp _), simp,\n    have : ⤊⤊Iₒₚₑₙ +{ #1 * #0 =' #0 * #1 } ⊢ #1 * #0 =' #0 * #1, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢, simp[this] },\n  simpa using (generalize $ ind ⨀ zero ⨀ succ)\nend\n\nlemma Lindenbaum.mul_commutative (h₁ h₂ : Herbrand Iₒₚₑₙ i) : h₁ * h₂ = h₂ * h₁ :=\nby induction h₁ using fol.Herbrand.ind_on with t;\n   induction h₂ using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (mul_commutative _ ⊚ t ⊚ u)\n\nlemma mul_add : Iₒₚₑₙ ⊢ ∀₁ x y z, x * (y + z) =' x * y + x * z :=\nbegin\n  have ind : ⤊⤊Iₒₚₑₙ ⊢ (#1 * (#0 + 0) =' #1 * #0 + #1 * 0) ⟶\n                     ∀. ((#2 * (#1 + #0) =' #2 * #1 + #2 * #0) ⟶ (#2 * (#1 + Succ #0) =' #2 * #1 + #2 * Succ #0)) ⟶\n                     ∀. (#2 * (#1 + #0) =' #2 * #1 + #2 * #0),\n  by simpa using Ind.I_succ_induction is_open ⤊⤊Iₒₚₑₙ (#2 * (#1 + #0) =' #2 * #1 + #2 * #0) (by simp[set.mem_def]),\n  have zero : ⤊⤊Iₒₚₑₙ ⊢ #1 * (#0 + 0) =' #1 * #0 + #1 * 0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : ⤊⤊Iₒₚₑₙ ⊢ ∀. ((#2 * (#1 + #0) =' #2 * #1 + #2 * #0) ⟶ (#2 * (#1 + Succ #0) =' #2 * #1 + #2 * Succ #0)),\n  { refine (generalize $ deduction.mp _), simp, \n    have : ⤊⤊⤊Iₒₚₑₙ +{ #2 * (#1 + #0) =' #2 * #1 + #2 * #0 } ⊢ #2 * (#1 + #0) =' #2 * #1 + #2 * #0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢,\n    simp[this, add_assoc] },\n  simpa using (generalize $ generalize $ ind ⨀ zero ⨀ succ)\nend\n\nlemma Lindenbaum.mul_add (h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i) : h₁ * (h₂ + h₃) = h₁ * h₂ + h₁ * h₃ :=\nby induction h₁ using fol.Herbrand.ind_on with t₁;\n   induction h₂ using fol.Herbrand.ind_on with t₂;\n   induction h₃ using fol.Herbrand.ind_on with t₃;\n   simpa using Herbrand.eq_of_provable_equiv.mp (mul_add _ ⊚ t₁ ⊚ t₂ ⊚ t₃)\n\nlemma mul_associative : Iₒₚₑₙ ⊢ ∀₁ x y z, x * y * z =' x * (y * z) :=\nbegin\n  have ind : ⤊⤊Iₒₚₑₙ ⊢ (#1 * #0 * 0 =' #1 * (#0 * 0)) ⟶\n                     ∀. ((#2 * #1 * #0 =' #2 * (#1 * #0)) ⟶ (#2 * #1 * Succ #0 =' #2 * (#1 * Succ #0))) ⟶\n                     ∀. (#2 * #1 * #0 =' #2 * (#1 * #0)),\n  by simpa using Ind.I_succ_induction is_open ⤊⤊Iₒₚₑₙ (#2 * #1 * #0 =' #2 * (#1 * #0)) (by simp[set.mem_def]),\n  have zero : ⤊⤊Iₒₚₑₙ ⊢ #1 * #0 * 0 =' #1 * (#0 * 0), by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : ⤊⤊Iₒₚₑₙ ⊢ ∀. ((#2 * #1 * #0 =' #2 * (#1 * #0)) ⟶ (#2 * #1 * Succ #0 =' #2 * (#1 * Succ #0))),\n  { refine (generalize $ deduction.mp _),\n    have : ⤊⤊⤊Iₒₚₑₙ +{ #2 * #1 * #0 =' #2 * (#1 * #0) } ⊢ #2 * #1 * #0 =' #2 * (#1 * #0), by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this ⊢, simp[this, Lindenbaum.mul_add] },\n  simpa using (generalize $ generalize $ ind ⨀ zero ⨀ succ)\nend\n\nlemma Lindenbaum.mul_associative (h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i) : h₁ * h₂ * h₃ = h₁ * (h₂ * h₃) :=\nby induction h₁ using fol.Herbrand.ind_on with t₁;\n   induction h₂ using fol.Herbrand.ind_on with t₂;\n   induction h₃ using fol.Herbrand.ind_on with t₃;\n   simpa using Herbrand.eq_of_provable_equiv.mp (mul_associative _ ⊚ t₁ ⊚ t₂ ⊚ t₃)\n\n@[simp] lemma mul_one : Iₒₚₑₙ ⊢ ∀₁ x, x * 1 =' x := generalize (Herbrand.eq_of_provable_equiv_0.mpr (by simp[numeral_one_def]))\n\n@[simp] lemma Lindenbaum.mul_one (h : Herbrand Iₒₚₑₙ i) : h * 1 = h := by simp[numeral_one_def]\n\ninstance Lindenbaum.comm_semigroup : comm_semigroup (Herbrand Iₒₚₑₙ i) :=\n{ mul := (*),\n  mul_assoc := Lindenbaum.mul_associative _ _,\n  mul_comm := Lindenbaum.mul_commutative _ _ }\n\ninstance Lindenbaum.distrib : distrib (Herbrand Iₒₚₑₙ i) :=\n{ mul := (*), add := (+),\n  left_distrib := Lindenbaum.mul_add _ _,\n  right_distrib := λ a b c, by simp[mul_comm (a + b), mul_comm a, mul_comm b, Lindenbaum.mul_add] }\n\nlemma add_right_cancel : Iₒₚₑₙ ⊢ ∀₁ x y z, (x + z =' y + z) ⟶ (x =' y) :=\nbegin\n  have ind : ⤊⤊Iₒₚₑₙ ⊢ ((#1 + 0 =' #0 + 0) ⟶ (#1 =' #0)) ⟶\n                     ∀. (((#2 + #0 =' #1 + #0) ⟶ (#2 =' #1)) ⟶ (#2 + Succ #0 =' #1 + Succ #0) ⟶ (#2 =' #1)) ⟶\n                     ∀. ((#2 + #0 =' #1 + #0) ⟶ (#2 =' #1)),\n  by simpa using Ind.I_succ_induction is_open ⤊⤊Iₒₚₑₙ ((#2 + #0 =' #1 + #0) ⟶ (#2 =' #1)) (by simp[set.mem_def]),\n  have zero : ⤊⤊Iₒₚₑₙ ⊢ (#1 + 0 =' #0 + 0) ⟶ (#1 =' #0), by simp[Lindenbaum.le_of_provable_imply_0],\n  have succ : ⤊⤊Iₒₚₑₙ ⊢ ∀. (((#2 + #0 =' #1 + #0) ⟶ (#2 =' #1)) ⟶ (#2 + Succ #0 =' #1 + Succ #0) ⟶ (#2 =' #1)),\n  { refine (generalize $ deduction.mp $ deduction.mp _), simp,\n    have : ⤊⤊⤊Iₒₚₑₙ +{ (#2 + #0 =' #1 + #0) ⟶ (#2 =' #1) } +{ #2 + Succ #0 =' #1 + Succ #0 } ⊢ #2 + #0 =' #1 + #0,\n      from deduction.mpr (by simp[Lindenbaum.le_of_provable_imply_0]),\n    exact (show _ ⊢ (#2 + #0 =' #1 + #0) ⟶ (#2 =' #1), by simp) ⨀ this },\n  simpa using (generalize $ generalize $ ind ⨀ zero ⨀ succ)\nend\n\nlemma Herbrand.add_right_cancel (h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i) : h₁ + h₃ = h₂ + h₃ ↔ h₁ = h₂ :=\n⟨λ h, begin\n  induction h₁ using fol.Herbrand.ind_on with t₁,\n  induction h₂ using fol.Herbrand.ind_on with t₂,\n  induction h₃ using fol.Herbrand.ind_on with t₃,\n  have lmm₁ : Iₒₚₑₙ^i ⊢ t₁ + t₃ =' t₂ + t₃, from Herbrand.eq_of_provable_equiv.mpr (by simp[h]),\n  have lmm₂ : Iₒₚₑₙ^i ⊢ (t₁ + t₃ =' t₂ + t₃) ⟶ (t₁ =' t₂), by simpa[fal_fn] using add_right_cancel _ ⊚ t₁ ⊚ t₂ ⊚ t₃,\n  exact Herbrand.eq_of_provable_equiv.mp (lmm₂ ⨀ lmm₁)\nend, λ h, by simp[h]⟩\n\nlemma Herbrand.add_left_cancel (h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i) : h₃ + h₁ = h₃ + h₂ ↔ h₁ = h₂ :=\nby simp[add_comm h₃, Herbrand.add_right_cancel]\n\n@[simp] lemma Lindenbaum.add_right_cancel (h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i) : (h₁ + h₃ =' h₂ + h₃ : Lindenbaum Iₒₚₑₙ i) = (h₁ =' h₂) :=\nbegin\n  induction h₁ using fol.Herbrand.ind_on with t₁,\n  induction h₂ using fol.Herbrand.ind_on with t₂,\n  induction h₃ using fol.Herbrand.ind_on with t₃,\n  have : Iₒₚₑₙ^i ⊢ (t₁ + t₃ =' t₂ + t₃) ⟷ (t₁ =' t₂),\n  { simp[iff_equiv], refine ⟨by simpa[fal_fn] using add_right_cancel _ ⊚ t₁ ⊚ t₂ ⊚ t₃, deduction.mp _⟩,\n  simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.rew_by_axiom₁] },\n  simpa using Lindenbaum.eq_of_provable_equiv.mp this\nend\n\nlemma add_le_add : Iₒₚₑₙ ⊢ ∀₁ x y z, (x + z ≼ y + z) ⟷ (x ≼ y) :=\nbegin\n  refine (generalize $ generalize $ generalize _), simp[fal_fn],\n  suffices : ⤊⤊⤊Iₒₚₑₙ ⊢ ∃. (#0 + (#3 + #1) =' #2 + #1) ⟷ ∃. (#0 + #3 =' #2),\n  { simpa[Lindenbaum.eq_top_of_provable_0, Lindenbaum.le_iff] using this },\n  simp[iff_equiv], split,\n  { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ use #0 _), simp[formula.pow_eq], \n    have : ⤊⤊⤊⤊Iₒₚₑₙ +{ #0 + (#3 + #1) =' #2 + #1 } ⊢ #0 + (#3 + #1) =' #2 + #1, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0, ←add_assoc, Herbrand.add_right_cancel] at this ⊢, exact this },\n  { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ use #0 _), simp[formula.pow_eq],\n    have : ⤊⤊⤊⤊Iₒₚₑₙ +{ #0 + #3 =' #2 } ⊢ #0 + #3 =' #2, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0, ←add_assoc, Herbrand.add_right_cancel] at this ⊢, exact this }\nend \n\n@[simp] lemma Lindenbaum.le_add_right_cancel (h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i) :\n  (h₁ + h₃ ≼ h₂ + h₃ : Lindenbaum Iₒₚₑₙ i) = (h₁ ≼ h₂) :=\nbegin\n  induction h₁ using fol.Herbrand.ind_on with t₁,\n  induction h₂ using fol.Herbrand.ind_on with t₂,\n  induction h₃ using fol.Herbrand.ind_on with t₃,\n  have : Iₒₚₑₙ^i ⊢ (t₁ + t₃ ≼ t₂ + t₃) ⟷ (t₁ ≼ t₂), by simpa[fal_fn] using add_le_add _ ⊚ t₁ ⊚ t₂ ⊚ t₃,\n  simpa using Lindenbaum.eq_of_provable_equiv.mp this\nend\n\nlemma lt_equiv : Iₒₚₑₙ' ⊢ ∀₁ x y, (x ≺ y) ⟷ ∃₁ z, (Succ z + x =' y) :=\nbegin\n  refine (generalize $ generalize _), simp[fal_fn, ex_fn],\n  suffices : ⤊⤊Iₒₚₑₙ' ⊢ (#1 ≼ #0) ⊓ (#1 ≠' #0) ⟷ ∃. (Succ #0 + #(1 + 1) =' #1),\n    by simpa[lt, Lindenbaum.eq_of_provable_equiv_0, Lindenbaum.lt_eq] using this,\n  simp[iff_equiv], split,\n  { suffices : ⤊⤊Iₒₚₑₙ' ⊢ (∃. (#0 + #2 =' #1)) ⟶ ∼(#1 =' #0) ⟶ ∃. (Succ #0 + #2 =' #1),\n    { simp[Lindenbaum.le_of_provable_imply_0, Lindenbaum.le_iff] at this ⊢,\n      simpa[sdiff_eq] using sdiff_le_iff.mpr (by simpa[sdiff_eq] using this) },\n    refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ rew_of_eq (#0 + #2) 1 (eq_symm $ by simp) _),\n    simp[formula.pow_eq],\n    have zero : ⤊⤊⤊Iₒₚₑₙ' +{ #0 + #2 =' #1 } ⊢ (#0 =' 0) ⟶ (#2 ≠' #0 + #2) ⟶ ∃. (Succ #0 + #3 =' #1 + #3),\n    { refine (deduction.mp _), simp[Lindenbaum.le_of_provable_imply_0, Lindenbaum.rew_by_axiom₁] },\n    have succ : ⤊⤊⤊Iₒₚₑₙ' +{ #0 + #2 =' #1 } ⊢ (∃₁ y, #1 =' Succ y) ⟶ (#2 ≠' #0 + #2) ⟶ ∃. (Succ #0 + #3 =' #1 + #3),\n    { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ deduction.mp $ use #0 _), simp[←sf_dsb], \n      simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.rew_by_axiom₂] },\n    exact case_of_ax (zero_or_succ _ #0) zero succ },\n  { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ rew_of_eq (Succ #0 + #2) 1 (eq_symm $ by simp) _), simp,\n    simp[Herbrand.le_iff_provable_le_0, Lindenbaum.eq_neg_of_provable_neg_0, -Lindenbaum.succ_add],\n    simpa using Lindenbaum.add_right_cancel (⤊⤊⤊Iₒₚₑₙ' +{ Succ #0 + #2 =' #1 }) 0 0 (Succ ♯0) ♯2, }\nend\n\nlemma lt_equiv' (x y) : Iₒₚₑₙ' ⊢ (x ≺ y) ⟷ ∃₁ z, (Succ z + x^1 =' y^1) :=\nby simpa[lt, fal_fn, ex_fn, ←term.pow_rew_distrib] using (lt_equiv _) ⊚ x ⊚ y \n\nlemma Lindenbaum.lt_eq (h₁ h₂ : Herbrand Iₒₚₑₙ' i) :\n  (h₁ ≺' h₂) = ∃' (Succ ♯0 + h₁.pow =' h₂.pow : Lindenbaum Iₒₚₑₙ' (i + 1)) :=\nby induction h₁ using fol.Herbrand.ind_on with t;\n   induction h₂ using fol.Herbrand.ind_on with u;\n   simpa[lt, fal_fn, ex_fn] using Lindenbaum.eq_of_provable_equiv.mp ((lt_equiv' (Iₒₚₑₙ'^i) t u))\n\n@[simp, refl] lemma Lindenbaum.le_refl (h : Herbrand Iₒₚₑₙ i) : h ≤ h :=\nby { have : h ≤ 0 + h, from robinson.Lindenbaum.le_add_self Iₒₚₑₙ i h 0,\n     simpa using this }\n\n@[simp] lemma Lindenbaum.le_succ_refl (h : Herbrand Iₒₚₑₙ i) : h ≤ Succ h :=\nby { have : h ≤ 1 + h, from robinson.Lindenbaum.le_add_self Iₒₚₑₙ i h 1, \n     simpa[numeral_one_def] using this }\n\nlemma le_transitive : Iₒₚₑₙ ⊢ ∀₁ x y z, (x ≼ y) ⟶ (y ≼ z) ⟶ (x ≼ z) :=\nbegin\n  refine (generalize $ generalize $ generalize _), simp[fal_fn],\n  suffices : ⤊⤊⤊Iₒₚₑₙ ⊢ ∃. (#0 + #3 =' #2) ⟶ ∃. (#0 + #2 =' #1) ⟶ ∃. (#0 + #3 =' #1),\n  { simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.le_iff] at this ⊢, exact this },\n  refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ imply_ex_of_fal_imply $ generalize $ deduction.mp $ use (#0 + #1) _),\n  simp[←sf_dsb, formula.pow_eq],\n  show (Iₒₚₑₙ^5) +{ #1 + #4 =' #3 } +{ #0 + #3 =' #2 } ⊢ #0 + #1 + #4 =' #2,\n  by simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.rew_by_axiom₁_inv, Lindenbaum.rew_by_axiom₂_inv, add_assoc]\nend\n\n@[trans] lemma Lindenbaum.le_transitive {h₁ h₂ h₃ : Herbrand Iₒₚₑₙ i} : h₁ ≤ h₂ → h₂ ≤ h₃ → h₁ ≤ h₃ := λ le₁₂ le₂₃,\nbegin\n  induction h₁ using fol.Herbrand.ind_on with t₁,\n  induction h₂ using fol.Herbrand.ind_on with t₂,\n  induction h₃ using fol.Herbrand.ind_on with t₃,\n  have le₁₂ : Iₒₚₑₙ^i ⊢ t₁ ≼ t₂, from Herbrand.le_iff_provable_le.mpr le₁₂,\n  have le₂₃ : Iₒₚₑₙ^i ⊢ t₂ ≼ t₃, from Herbrand.le_iff_provable_le.mpr le₂₃,\n  have : Iₒₚₑₙ^i ⊢ (t₁ ≼ t₂) ⟶ (t₂ ≼ t₃) ⟶ (t₁ ≼ t₃), by simpa[fal_fn] using le_transitive _ ⊚ t₁ ⊚ t₂ ⊚ t₃,\n  exact Herbrand.le_iff_provable_le.mp (this ⨀ le₁₂ ⨀ le₂₃)\nend\n\nlemma add_lt_of_lt_of_lt : Iₒₚₑₙ' ⊢ ∀₁ x y z v, (x ≺ y) ⟶ (z ≺ v) ⟶ (x + z ≺ y + v) :=\nbegin\n  refine (generalize $ generalize $ generalize $ generalize _), simp[fal_fn],\n  show Iₒₚₑₙ'^4 ⊢ (#3 ≺ #2) ⟶ (#1 ≺ #0) ⟶ (#3 + #1 ≺ #2 + #0),\n  suffices : Iₒₚₑₙ'^4 ⊢ ∃. (Succ #0 + #4 =' #3) ⟶ ∃. (Succ #0 + #2 =' #1) ⟶ ∃. (Succ #0 + #4 + #2 =' #3 + #1),\n  { simp[lt, Lindenbaum.eq_top_of_provable_0, Lindenbaum.lt_eq, add_pow, add_assoc] at this ⊢, simpa using this },\n  refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ imply_ex_of_fal_imply $ generalize $ deduction.mp $ use (Succ #1 + #0) _),\n  simp[←sf_dsb, formula.pow_eq],\n  show (Iₒₚₑₙ'^6)+{ Succ #1 + #5 =' #4 }+{ Succ #0 + #3 =' #2 } ⊢ Succ (Succ #1 + #0) + #5 + #3 =' #4 + #2,\n  simp[Herbrand.eq_of_provable_equiv_0, rew_by_axiom₁_inv, rew_by_axiom₂_inv],\n  calc    (♯1 + ♯0 + ♯5 + ♯3 : Herbrand ((Iₒₚₑₙ'^6)+{ Succ #1 + #5 =' #4 }+{ Succ #0 + #3 =' #2 }) 0) \n        = (♯1 + (♯0 + ♯5) + ♯3) : by simp[add_assoc]\n    ... = (♯1 + (♯5 + ♯0) + ♯3) : by simp[add_comm]\n    ... = ♯1 + ♯5 + (♯0 + ♯3)   : by simp[add_assoc]\nend\n\nlemma eq_or_succ_le_of_le : Iₒₚₑₙ ⊢ ∀₁ x y, (x ≼ y) ⟶ (x =' y) ⊔ (Succ x ≼ y) :=\nbegin\n  refine (generalize $ generalize _), simp[fal_fn],\n  suffices : ⤊⤊Iₒₚₑₙ ⊢ ∃. (#0 + #2 =' #1) ⟶ (#1 =' #0) ⊔ ∃. (#0 + Succ #2 =' #1),\n  { simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.le_iff] at this ⊢, exact this },\n  refine (imply_ex_of_fal_imply $ generalize _), simp[formula.pow_eq],\n  show Iₒₚₑₙ^3 ⊢ (#0 + #2 =' #1) ⟶ (#2 =' #1) ⊔ ∃. (#0 + Succ #3 =' #2),\n  have zero : Iₒₚₑₙ^3 ⊢ (#0 =' 0) ⟶ (#0 + #2 =' #1) ⟶ (#2 =' #1) ⊔ ∃. (#0 + Succ #3 =' #2),\n  { refine (deduction.mp $ deduction.mp _),\n    simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.rew_by_axiom₁_inv, Lindenbaum.rew_by_axiom₂] },\n  have succ : Iₒₚₑₙ^3 ⊢ (∃₁ y, #1 =' Succ y) ⟶ (#0 + #2 =' #1) ⟶ (#2 =' #1) ⊔ ∃. (#0 + Succ #3 =' #2),\n  { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ deduction.mp $ imply_or_right _ _ ⨀ use #0 _),\n    simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.rew_by_axiom₁_inv, Lindenbaum.rew_by_axiom₂] },\n  exact case_of_ax (zero_or_succ _ #0) zero succ\nend\n\nlemma le_or_ge : Iₒₚₑₙ ⊢ ∀₁ x y, (x ≼ y) ⊔ (y ≼ x) :=\nbegin\n  have ind : Iₒₚₑₙ^1 ⊢ (#0 ≼ 0) ⊔ (0 ≼ #0) ⟶\n                  ∀. ((#1 ≼ #0) ⊔ (#0 ≼ #1) ⟶ (#1 ≼ Succ #0) ⊔ (Succ #0 ≼ #1)) ⟶\n                  ∀. (#1 ≼ #0) ⊔ (#0 ≼ #1),\n  by simpa using Ind.I_succ_induction is_open ⤊Iₒₚₑₙ ((#1 ≼ #0) ⊔ (#0 ≼ #1)) (by simp[set.mem_def]),\n  have zero : Iₒₚₑₙ^1 ⊢ (#0 ≼ 0) ⊔ (0 ≼ #0), from (imply_or_right _ _ ⨀ (by simp[Herbrand.le_iff_provable_le_0])),\n  have succ : Iₒₚₑₙ^1 ⊢ ∀. ((#1 ≼ #0) ⊔ (#0 ≼ #1) ⟶ (#1 ≼ Succ #0) ⊔ (Succ #0 ≼ #1)),\n  { refine generalize _, \n    have orl : Iₒₚₑₙ^2 ⊢ (#1 ≼ #0) ⟶ (#1 ≼ Succ #0) ⊔ (Succ #0 ≼ #1),\n    { refine (deduction.mp $ imply_or_left _ _ ⨀ _),\n      have : (Iₒₚₑₙ^2)+{ #1 ≼ #0 } ⊢ #1 ≼ #0, by simp,\n      simp[Herbrand.le_iff_provable_le_0] at this ⊢,\n      refine Lindenbaum.le_transitive _ _ this (by simp) },\n    have orr : Iₒₚₑₙ^2 ⊢ (#0 ≼ #1) ⟶ (#1 ≼ Succ #0) ⊔ (Succ #0 ≼ #1),\n    { refine (deduction.mp _),\n      have eq      : (Iₒₚₑₙ^2) +{ #0 ≼ #1 } ⊢ (#0 =' #1) ⟶ (#1 ≼ Succ #0) ⊔ (Succ #0 ≼ #1),\n      { refine (deduction.mp $ imply_or_left _ _ ⨀ _), simp[Herbrand.le_iff_provable_le_0, rew_by_axiom₁] },\n      have succ_le : (Iₒₚₑₙ^2) +{ #0 ≼ #1 } ⊢ (Succ #0 ≼ #1) ⟶ (#1 ≼ Succ #0) ⊔ (Succ #0 ≼ #1),\n        by simp[Lindenbaum.le_of_provable_imply_0],\n      have : (Iₒₚₑₙ^2) +{ #0 ≼ #1 } ⊢ (#0 =' #1) ⊔ (Succ #0 ≼ #1), \n        from deduction.mpr (show (Iₒₚₑₙ^2) ⊢ (#0 ≼ #1) ⟶ (#0 =' #1) ⊔ (Succ #0 ≼ #1),\n        by simpa[fal_fn] using eq_or_succ_le_of_le _ ⊚ #0 ⊚ #1),\n      exact case_of_ax this eq succ_le },\n    exact or_imply _ _ _ ⨀ orl ⨀ orr },\n  refine (generalize _), simp[fal_fn], exact ind ⨀ zero ⨀ succ\nend\n\n@[simp] lemma prec_open (t u : term LA') : coe_inv_is_open defs (t ≺ u) :=\nby { have : ((coe : LA'.pr 2 → LA'.pr 2) (sum.inr additional_pr.lt)) = sum.inr additional_pr.lt,\n       from language.language_translation_coe.coe_pr_eq_self _,\n     simp[lt, this] }\n\nlemma lt_mul_of_nonzero_of_lt :\n  Iₒₚₑₙ' ⊢ ∀₁ x y z, (x ≺ y) ⟶ (z ≠' 0) ⟶ (x * z ≺ y * z) :=\nbegin\n  have ind : Iₒₚₑₙ'^2 ⊢\n       ((#1 ≺ #0) ⟶ ((0 : term LA) ≠' 0) ⟶ (#1 * 0 ≺ #0 * 0)) ⟶\n    ∀. (((#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0)) ⟶ (#2 ≺ #1) ⟶ (Succ #0 ≠' 0) ⟶ (#2 * Succ #0 ≺ #1 * Succ #0)) ⟶\n    ∀. ((#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0)),\n  by simpa[additional.lt] using\n    I_succ_induction_LA (Iₒₚₑₙ'^2) ((#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0)) (by simp),\n  have zero : Iₒₚₑₙ'^2 ⊢ (#1 ≺ #0) ⟶ ((0 : term LA) ≠' 0) ⟶ (#1 * 0 ≺ #0 * 0), by simp[Lindenbaum.eq_top_of_provable_0],\n  have succ : Iₒₚₑₙ'^2 ⊢ ∀. (((#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0)) ⟶ (#2 ≺ #1) ⟶ (Succ #0 ≠' 0) ⟶ (#2 * Succ #0 ≺ #1 * Succ #0)),\n  { refine (generalize $ deduction.mp $ deduction.mp $ deduction.mp _), simp[-iff_and],\n    have zero : (Iₒₚₑₙ'^3) +{ (#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0) } +{ #2 ≺ #1 } +{ Succ #0 ≠' 0 } ⊢ (#0 =' 0) ⟶ (#2 * Succ #0 ≺ #1 * Succ #0),\n    { refine (deduction.mp $ rew_of_eq 0 0 (by simp) _),\n      have : (Iₒₚₑₙ'^3) +{ (#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0) } +{ #2 ≺ #1 } +{ Succ #0 ≠' 0 }+{ #0 =' 0 } ⊢ #2 ≺ #1, by simp,\n      simpa[Herbrand.iff_abberavation₂_0] using this },\n    have nonzero : (Iₒₚₑₙ'^3) +{ (#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0) } +{ #2 ≺ #1 } +{ Succ #0 ≠' 0 } ⊢ (#0 ≠' 0) ⟶ (#2 * Succ #0 ≺ #1 * Succ #0),\n    { refine (deduction.mp _),\n      have lt : (Iₒₚₑₙ'^3) +{ (#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0) } +{ #2 ≺ #1 } +{ Succ #0 ≠' 0 } +{ #0 ≠' 0 } ⊢ #2 * #0 ≺ #1 * #0,\n        from (show _ ⊢ (#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0), by simp) ⨀ (by simp) ⨀ (by simp),\n      have : (Iₒₚₑₙ'^3) ⊢ (#2 * #0 ≺ #1 * #0) ⟶ (#2 ≺ #1) ⟶ (#2 * #0 + #2 ≺ #1 * #0 + #1),\n      by simpa[fal_fn] using ((add_lt_of_lt_of_lt (Iₒₚₑₙ'^3)) ⊚ (#2 * #0) ⊚ (#1 * #0) ⊚ #2 ⊚ #1),\n      have : (Iₒₚₑₙ'^3) +{ (#2 ≺ #1) ⟶ (#0 ≠' 0) ⟶ (#2 * #0 ≺ #1 * #0) } +{ #2 ≺ #1 } +{ Succ #0 ≠' 0 } +{ #0 ≠' 0 } ⊢ #2 * #0 + #2 ≺ #1 * #0 + #1,\n        from this.extend ⨀ lt ⨀ (by simp),\n      simp[Lindenbaum.eq_top_of_provable_0] at this ⊢, exact this },\n    refine cases_of _ _ zero nonzero },\n  refine (generalize $ generalize _), simp[fal_fn], exact ind ⨀ zero ⨀ succ\nend\n\n#check 0  /-\nlemma mul_right_cancel_of_nonzero_aux : Iₒₚₑₙ' ⊢ ∀₁ x y z, (z ≠' 0) ⟶ (x * z =' y * z) ⟶ (x =' y) :=\nbegin\n  refine (generalize $ generalize $ generalize _), simp[fal_fn],\n  suffices : Iₒₚₑₙ'^3 ⊢ (#0 ≠' 0) ⟶ (#2 ≠' #1) ⟶ (#2 * #0 ≠' #1 * #0),\n  {  simp[Lindenbaum.eq_top_of_provable_0] at this ⊢, simpa[sup_comm] using this },\n  have : Iₒₚₑₙ'^3 ⊢ ∀₁ x y z, (x ≺ y) ⟶ (z ≠' 0) ⟶ (x * z ≺ y * z),\n  have := (lt_mul_of_nonzero_of_lt (Iₒₚₑₙ'^3)),\n\n  simp[fal_fn] at this,\n  have orl : Iₒₚₑₙ' ⊢ (#1 ≼ #2) ⟶ ∼(#0 =' 0) ⟶ ∼(#2 =' #1) ⟶ ∼(#2 * #0 =' #1 * #0),\n  { refine (deduction.mp $ deduction.mp $ deduction.mp $ ne_symm _),\n    have : Iₒₚₑₙ' +{ #1 ≼ #2 } +{ #0 ≠' 0 } +{ #2 ≠' #1 } ⊢ _, { have h := (this ⊚ #1 ⊚ #2 ⊚ #0),  }, \n    have := this ⨀ (by {simp[lessthan_def, fal_fn], refine ne_symm (by simp) }) ⨀ (by simp[fal_fn]),\n    simp[lessthan_def, fal_fn] at this, exact this.2 },\n  have orr : Iₒₚₑₙ ⊢ (#2 ≼ #1) ⟶ ∼(#0 =' 0) ⟶ ∼(#2 =' #1) ⟶ ∼(#2 * #0 =' #1 * #0),\n  { refine (deduction.mp $ deduction.mp $ deduction.mp _),\n    have : Iₒₚₑₙ +{ #2 ≼ #1 } +{ #0 ≠' 0 } +{ #2 ≠' #1 } ⊢ _, from provable.extend (this ⊚ #2 ⊚ #1 ⊚ #0), \n    have := this ⨀ (by simp[lessthan_def, fal_fn]) ⨀ (by simp[fal_fn]),\n    simp[lessthan_def, fal_fn] at this, exact this.2 },\n  refine case_of_ax (show Iₒₚₑₙ ⊢ (#1 ≼ #2) ⊔ (#2 ≼ #1), by simpa[fal_fn] using le_or_ge ⊚ #1 ⊚ #2) orl orr\nend\n\nlemma one_divides : Iₒₚₑₙ ⊢ ∀₁ x, 1 ⍭ x :=\nbegin\n  simp[divides_def, fal_fn, numeral_one_def],\n  refine (generalize $ use #1 _), \n  simp[Herbrand.eq_of_provable_equiv_0]\nend\n\nlemma divides_self : Iₒₚₑₙ ⊢ ∀₁ x, x ⍭ x :=\nbegin\n  simp[divides_def, fal_fn, numeral_one_def],\n  refine (generalize $ use (Succ 0) _), \n  simp[Herbrand.eq_of_provable_equiv_0]\nend\n\nlemma divides_zero : Iₒₚₑₙ ⊢ ∀₁ x, x ⍭ 0 :=\nbegin\n  simp[divides_def, fal_fn],\n  refine (generalize $ use 0 _), \n  simp[Herbrand.eq_of_provable_equiv_0]\nend\n\nlemma divides_trans : Iₒₚₑₙ ⊢ ∀₁ x y z, (x ⍭ y) ⟶ (y ⍭ z) ⟶ (x ⍭ z) :=\nbegin\n  simp[divides_def, fal_fn],\n  refine (generalize $ generalize $ generalize $\n    imply_ex_of_fal_imply $ generalize $ deduction.mp $\n    imply_ex_of_fal_imply $ generalize $ deduction.mp $ use (#0 * #1) _),\n  simp[formula.pow_eq, ←sf_dsb],\n  show Iₒₚₑₙ +{ #1 * #5 =' #4 } +{ #0 * #4 =' #3 } ⊢ #0 * #1 * #5 =' #3,\n  simp[Herbrand.eq_of_provable_equiv_0, rew_by_axiom₁_inv, rew_by_axiom₂_inv, mul_assoc]\nend\n-/\nend Iopen\n/-ₒ\ndef \n\n\nlemma add_symm : Iₒₚₑₙ ⊢ ∀₁ x y, (x + y =' y + x) :=\nbegin\n  refine (generalize _), simp[fal_fn],\n  have zero : Iₒₚₑₙ ⊢ (#0 =' 0) ⟶ ∀. (#1 + #0 =' #0 + #1),\n  { refine (deduction.mp $ generalize _), simp[←sf_dsb, Herbrand.eq_of_provable_equiv_0, rew_by_axiom₁] },\n  have succ : Iₒₚₑₙ ⊢ (∃₁ y, #1 =' Succ y) ⟶ ∀. (#1 + #0 =' #0 + #1),\n  { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ rew_of_eq (Succ #0) 1 (by simp) $ generalize _), simp[formula.pow_eq, ←sf_dsb],\n    suffices : Iₒₚₑₙ ⊢ Succ #1 + #0 =' #0 + Succ #1, by simp[this],\n     \n     }\nend\n\n\n\n\ndef Ind {C : Theory LA} : Lindenbaum 𝐈C 1 → Prop := λ l, ∃ p, p ∈ C ∧ l = ⟦p⟧ᴸ\n\nlemma Ind_mem (p : formula LA) : Ind (⟦p⟧ᴸ : Lindenbaum 𝐈C 1) → (⟦peano_induction p⟧ᴸ : Lindenbaum 𝐈C 0) = ⊤ :=\nbegin\n  simp[Ind], \n  intros p0 h eqn, \n  have : 𝐈C ⊢ succ_induction p0,\n  {have := provable.AX (succ_induction_axiom.ind h), exact this },\n  simp[@Lindenbaum.provable_top_iff0] at *,\n  have eqn : classical_logic.to_quo p = classical_logic.to_quo p0, from equiv_eq_top_iff.mp eqn,\n  have : (⟦peano_induction p⟧ᴸ : Lindenbaum 𝐈C 0) = ⟦peano_induction p0⟧ᴸ,\n  { simp[succ_induction, Lindenbaum.pow_eq, Lindenbaum.subst_eq, eqn], },\n  simp*\nend\n\nlemma Lindenbaum_induction \n  (l : Lindenbaum 𝐈C 1) (m : Lindenbaum 𝐈C 0)\n  (h : Ind l)\n  (zero : m ≤ 0 ⊳ l)\n  (succ : m.pow ≤ (♯0 ⊳ l.pow)ᶜ ⊔ (Succ ♯0) ⊳ l.pow) : m ≤ ∀. l :=\nbegin\n  induction l using fol.Lindenbaum.ind_on with p,\n  have P := (provable_top_iff0.mpr (Ind_mem _ h)),\n  have trn : (0 : Herbrand 𝐈C 0) ⊳ ⟦p⟧ᴸ ⊓ ∀. ((♯0 ⊳ pow ⟦p⟧ᴸ)ᶜ ⊔ (Succ ♯0) ⊳ pow ⟦p⟧ᴸ) ≤ ∀. ⟦p⟧ᴸ,\n  { simp[succ_induction, Lindenbaum.subst_eq, Lindenbaum.pow_eq, compl_sup_iff_le,\n    le_of_provable_imply_0, Herbrand.var_eq] at P, refine P },\n  have succ' : m ≤ ∀. ((♯0 ⊳ pow ⟦p⟧ᴸ)ᶜ ⊔ (Succ ♯0) ⊳ pow ⟦p⟧ᴸ),\n    from Lindenbaum.proper.pow_le_le_fal succ,\n  have : m ≤ 0 ⊳ ⟦p⟧ᴸ ⊓ ∀. ((♯0 ⊳ pow ⟦p⟧ᴸ)ᶜ ⊔ (Succ ♯0) ⊳ pow ⟦p⟧ᴸ), \n    from le_inf zero succ',\n  exact le_trans this trn\nend\n\nlemma Lindenbaum_induction_top {p : formula LA} (l : Lindenbaum 𝐈C 1)\n  (h : Ind l)\n  (zero : 0 ⊳ l = ⊤)\n  (succ : ♯0 ⊳ l.pow ≤ (Succ ♯0) ⊳ l.pow) : (∀. l : Lindenbaum 𝐈C 0) = ⊤ :=\nbegin\n  induction l using fol.Lindenbaum.ind_on with p,\n  have P := (provable_top_iff0.mpr (Ind_mem _ h)),\n  have : (0 : Herbrand 𝐈C 0) ⊳ ⟦p⟧ᴸ ⊓ ∀. ((♯0 ⊳ pow ⟦p⟧ᴸ)ᶜ ⊔ (Succ ♯0) ⊳ pow ⟦p⟧ᴸ) ≤ ∀. ⟦p⟧ᴸ,\n  { simp[succ_induction, Lindenbaum.subst_eq, Lindenbaum.pow_eq, compl_sup_iff_le,\n    le_of_provable_imply_0, Herbrand.var_eq] at P, exact P },\n  simp[zero, succ] at this,\n  have eqn : (♯0 ⊳ pow ⟦p⟧ᴸ)ᶜ ⊔ (Succ ♯0) ⊳ pow ⟦p⟧ᴸ = ⊤,\n    from ((♯0 ⊳ pow ⟦p⟧ᴸ).compl_sup_iff_le ((Succ ♯0) ⊳ pow ⟦p⟧ᴸ)).mpr succ,\n  simp[eqn] at this, exact this\nend\n\ndef Lindenbaum.bd_fal {T : Theory LA} (l : Lindenbaum T (i + 1)) (h : Herbrand T i) : Lindenbaum T i := ∀. ((♯0 ≼ h.pow)ᶜ ⊔ l)\ndef Lindenbaum.bd_ex {T : Theory LA} (l : Lindenbaum T (i + 1)) (h : Herbrand T i) : Lindenbaum T i := ∃. ((♯0 ≼ h.pow) ⊓ l)\n\nnotation `∀._{≼ `:95 h `} ` l :90 := Lindenbaum.bd_fal l h \nnotation `∃._{≼ `:95 h `} ` l :90 := Lindenbaum.bd_ex l h \n\ntheorem collection (p : formula LA) [proper 0 (𝚺⁰1)] :\n  𝐈𝚺⁰1 ⊢ ([∀. ≼ #0] ∃. p) ⟶ ∃. [∀. ≼ #1] [∃. ≼ #1] ((p^3).rew ı[4 ⇝ #0]).rew ı[3 ⇝ #1] :=\nbegin\n  simp[le_of_provable_imply_0, bounded_fal, bounded_ex, Lindenbaum.pow_eq p, Herbrand.subst_eq, Lindenbaum.subst_eq],\n  suffices : ∀ l : Lindenbaum 𝐐+𝐈𝚺⁰1 2,\n    ∀._{≼ ♯1} ∃. l ≤ ∃. ∀._{≼ ♯2} ∃._{≼ ♯2} (♯1 ⊳ ♯0 ⊳ l.pow.pow.pow),\n  { sorry },\n  intros l,\n  have : ∀._{≼ ♯1} ∃. l ≤ ∀. ∀. ((♯0 ≼ ♯1)ᶜ ⊔ ∃. ∀._{≼ ♯1} ∃._{≼ ♯1} l.pow.pow.pow),\n  { refine Lindenbaum_induction _ _ _ _ _; sorry }\n  \nend\n\ntheorem collection (p : formula LA) [proper 0 (𝚺⁰1)] : 𝐐+𝐈𝚺⁰1 ⊢ ([∀. ≼ #0] ∃. p) ⟶ ∃. [∀. ≼ #1] [∃. ≼ #1] p :=\nbegin\n  refine deduction.mp _,\n  have : ∀ n, ∃ m, (((ı[0 ⇝ #0] ^ 1) ^ 1) ^ 1) m = (#n : term LA) :=\n    (rewriting_sf_perm $ rewriting_sf_perm $ rewriting_sf_perm $ slide_perm _ #0), \n  rcases formula.total_rew_inv p this with ⟨q, e_q⟩,\n  suffices : 𝐐+𝐈𝚺⁰1+{[∀. ≼ #0] ∃. p} ⊢ ∀. ∀. ((#0 ≼ #1) ⟶ ∃. [∀. ≼ #1] [∃. ≼ #1] q),\n  { have := (this.fal_subst #0).fal_subst #0,\n    simp[e_q, formula.nested_rew, rewriting_sf_itr.pow_add, subst_pow] at this,\n    have eqn : (λ (x : ℕ), term.rew ı[3 ⇝ #3] (ı[4 ⇝ #4] x) : ℕ → term LA) = \n      (λ x, if x < 4 then #x else if 4 < x then #(x - 2) else #3 ),\n    { funext x, have C : x < 4 ∨ x = 4 ∨ 4 < x := trichotomous x 4,\n      cases C, simp[C], { by_cases C₂ : x < 3, simp[C₂], simp[show x = 3, by omega] },\n      cases C; simp[C], \n      { simp[show ¬x < 4, from asymm C, show 3 < x - 1, from nat.lt_sub_left_of_add_lt C, ı],\n        refl } },\n    rw eqn at this, sorry },\n  apply provable.deduction.mpr, simp[Lindenbaum.provable_top_iff0],\n  apply Lindenbaum_induction,\n  { sorry },\n  { simp[e_q],\n    have : predicate₂ (𝐐^0) *≤ ⟦#0⟧ᴴ c⟪*Z⟫⁰ = ⊥,\n    { rw robinson.le_iff, }\n       }\nend\n\nend bd_peano\n-/\nend arithmetic\n\nend fol\n", "meta": {"author": "iehality", "repo": "lean-logic", "sha": "201cef2500203f7de83deb7fa8287934e2e142b2", "save_path": "github-repos/lean/iehality-lean-logic", "path": "github-repos/lean/iehality-lean-logic/lean-logic-201cef2500203f7de83deb7fa8287934e2e142b2/src/FOL/arithmetic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4734209069588131}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport topology.opens\nimport ring_theory.ideal.prod\nimport ring_theory.ideal.over\nimport linear_algebra.finsupp\nimport algebra.punit_instances\n\n/-!\n# Prime spectrum of a commutative ring\n\nThe prime spectrum of a commutative ring is the type of all prime ideals.\nIt is naturally endowed with a topology: the Zariski topology.\n\n(It is also naturally endowed with a sheaf of rings,\nwhich is constructed in `algebraic_geometry.structure_sheaf`.)\n\n## Main definitions\n\n* `prime_spectrum R`: The prime spectrum of a commutative ring `R`,\n  i.e., the set of all prime ideals of `R`.\n* `zero_locus s`: The zero locus of a subset `s` of `R`\n  is the subset of `prime_spectrum R` consisting of all prime ideals that contain `s`.\n* `vanishing_ideal t`: The vanishing ideal of a subset `t` of `prime_spectrum R`\n  is the intersection of points in `t` (viewed as prime ideals).\n\n## Conventions\n\nWe denote subsets of rings with `s`, `s'`, etc...\nwhereas we denote subsets of prime spectra with `t`, `t'`, etc...\n\n## Inspiration/contributors\n\nThe contents of this file draw inspiration from\n<https://github.com/ramonfmir/lean-scheme>\nwhich has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,\nand Chris Hughes (on an earlier repository).\n\n-/\n\nnoncomputable theory\nopen_locale classical\n\nuniverses u v\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The prime spectrum of a commutative ring `R`\nis the type of all prime ideals of `R`.\n\nIt is naturally endowed with a topology (the Zariski topology),\nand a sheaf of commutative rings (see `algebraic_geometry.structure_sheaf`).\nIt is a fundamental building block in algebraic geometry. -/\n@[nolint has_inhabited_instance]\ndef prime_spectrum := {I : ideal R // I.is_prime}\n\nvariable {R}\n\nnamespace prime_spectrum\n\n/-- A method to view a point in the prime spectrum of a commutative ring\nas an ideal of that ring. -/\nabbreviation as_ideal (x : prime_spectrum R) : ideal R := x.val\n\ninstance is_prime (x : prime_spectrum R) :\n  x.as_ideal.is_prime := x.2\n\n/--\nThe prime spectrum of the zero ring is empty.\n-/\nlemma punit (x : prime_spectrum punit) : false :=\nx.1.ne_top_iff_one.1 x.2.1 $ subsingleton.elim (0 : punit) 1 ▸ x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of\n    `R` and the prime spectrum of `S`. -/\nnoncomputable def prime_spectrum_prod :\n  prime_spectrum (R × S) ≃ prime_spectrum R ⊕ prime_spectrum S :=\nideal.prime_ideals_equiv R S\n\nvariables {R S}\n\n@[simp] lemma prime_spectrum_prod_symm_inl_as_ideal (x : prime_spectrum R) :\n  ((prime_spectrum_prod R S).symm (sum.inl x)).as_ideal = ideal.prod x.as_ideal ⊤ :=\nby { cases x, refl }\n@[simp] lemma prime_spectrum_prod_symm_inr_as_ideal (x : prime_spectrum S) :\n  ((prime_spectrum_prod R S).symm (sum.inr x)).as_ideal = ideal.prod ⊤ x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y ↔ x.as_ideal = y.as_ideal :=\nsubtype.ext_iff_val\n\n/-- The zero locus of a set `s` of elements of a commutative ring `R`\nis the set of all prime ideals of the ring that contain the set `s`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `zero_locus s` is exactly the subset of `prime_spectrum R`\nwhere all \"functions\" in `s` vanish simultaneously.\n-/\ndef zero_locus (s : set R) : set (prime_spectrum R) :=\n{x | s ⊆ x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x ∈ zero_locus s ↔ s ⊆ x.as_ideal := iff.rfl\n\n@[simp] lemma zero_locus_span (s : set R) :\n  zero_locus (ideal.span s : set R) = zero_locus s :=\nby { ext x, exact (submodule.gi R R).gc s x.as_ideal }\n\n/-- The vanishing ideal of a set `t` of points\nof the prime spectrum of a commutative ring `R`\nis the intersection of all the prime ideals in the set `t`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `vanishing_ideal t` is exactly the ideal of `R`\nconsisting of all \"functions\" that vanish on all of `t`.\n-/\ndef vanishing_ideal (t : set (prime_spectrum R)) : ideal R :=\n⨅ (x : prime_spectrum R) (h : x ∈ t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal} :=\nbegin\n  ext f,\n  rw [vanishing_ideal, set_like.mem_coe, submodule.mem_infi],\n  apply forall_congr, intro x,\n  rw [submodule.mem_infi],\nend\n\nlemma mem_vanishing_ideal (t : set (prime_spectrum R)) (f : R) :\n  f ∈ vanishing_ideal t ↔ ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal :=\nby rw [← set_like.mem_coe, coe_vanishing_ideal, set.mem_set_of_eq]\n\n@[simp] lemma vanishing_ideal_singleton (x : prime_spectrum R) :\n  vanishing_ideal ({x} : set (prime_spectrum R)) = x.as_ideal :=\nby simp [vanishing_ideal]\n\nlemma subset_zero_locus_iff_le_vanishing_ideal (t : set (prime_spectrum R)) (I : ideal R) :\n  t ⊆ zero_locus I ↔ I ≤ vanishing_ideal t :=\n⟨λ h f k, (mem_vanishing_ideal _ _).mpr (λ x j, (mem_zero_locus _ _).mpr (h j) k), λ h,\n  λ x j, (mem_zero_locus _ _).mpr (le_trans h (λ f h, ((mem_vanishing_ideal _ _).mp h) x j))⟩\n\nsection gc\nvariable (R)\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc : @galois_connection\n  (ideal R) (order_dual (set (prime_spectrum R))) _ _\n  (λ I, zero_locus I) (λ t, vanishing_ideal t) :=\nλ I t, subset_zero_locus_iff_le_vanishing_ideal t I\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc_set : @galois_connection\n  (set R) (order_dual (set (prime_spectrum R))) _ _\n  (λ s, zero_locus s) (λ t, vanishing_ideal t) :=\nhave ideal_gc : galois_connection (ideal.span) coe := (submodule.gi R R).gc,\nby simpa [zero_locus_span, function.comp] using ideal_gc.compose (gc R)\n\nlemma subset_zero_locus_iff_subset_vanishing_ideal (t : set (prime_spectrum R)) (s : set R) :\n  t ⊆ zero_locus s ↔ s ⊆ vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s ⊆ vanishing_ideal (zero_locus s) :=\n(gc_set R).le_u_l s\n\nlemma le_vanishing_ideal_zero_locus (I : ideal R) :\n  I ≤ vanishing_ideal (zero_locus I) :=\n(gc R).le_u_l I\n\n@[simp] lemma vanishing_ideal_zero_locus_eq_radical (I : ideal R) :\n  vanishing_ideal (zero_locus (I : set R)) = I.radical := ideal.ext $ λ f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact ⟨(λ h x hx, h ⟨x, hx.2⟩ hx.1), (λ h x hx, h x.1 ⟨hx, x.2⟩)⟩\nend\n\n@[simp] lemma zero_locus_radical (I : ideal R) : zero_locus (I.radical : set R) = zero_locus I :=\nvanishing_ideal_zero_locus_eq_radical I ▸ (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t ⊆ zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s ⊆ t) : zero_locus t ⊆ zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s ≤ t) :\n  zero_locus (t : set R) ⊆ zero_locus (s : set R) :=\n(gc R).monotone_l h\n\nlemma vanishing_ideal_anti_mono {s t : set (prime_spectrum R)} (h : s ⊆ t) :\n  vanishing_ideal t ≤ vanishing_ideal s :=\n(gc R).monotone_u h\n\nlemma zero_locus_subset_zero_locus_iff (I J : ideal R) :\n  zero_locus (I : set R) ⊆ zero_locus (J : set R) ↔ J ≤ I.radical :=\n⟨λ h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I ▸\n  vanishing_ideal_zero_locus_eq_radical J ▸ vanishing_ideal_anti_mono h),\nλ h, zero_locus_radical I ▸ zero_locus_anti_mono_ideal h⟩\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) ⊆ zero_locus {g} ↔ g ∈ (ideal.span ({f} : set R)).radical :=\nby rw [← zero_locus_span {f}, ← zero_locus_span {g}, zero_locus_subset_zero_locus_iff,\n    ideal.span_le, set.singleton_subset_iff, set_like.mem_coe]\n\nlemma zero_locus_bot :\n  zero_locus ((⊥ : ideal R) : set R) = set.univ :=\n(gc R).l_bot\n\n@[simp] lemma zero_locus_singleton_zero :\n  zero_locus ({0} : set R) = set.univ :=\nzero_locus_bot\n\n@[simp] lemma zero_locus_empty :\n  zero_locus (∅ : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (∅ : set (prime_spectrum R)) = ⊤ :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) ∈ s) :\n  zero_locus s = ∅ :=\nbegin\n  rw set.eq_empty_iff_forall_not_mem,\n  intros x hx,\n  rw mem_zero_locus at hx,\n  have x_prime : x.as_ideal.is_prime := by apply_instance,\n  have eq_top : x.as_ideal = ⊤, { rw ideal.eq_top_iff_one, exact hx h },\n  apply x_prime.ne_top eq_top,\nend\n\n@[simp] lemma zero_locus_singleton_one :\n  zero_locus ({1} : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_singleton (1 : R))\n\nlemma zero_locus_empty_iff_eq_top {I : ideal R} :\n  zero_locus (I : set R) = ∅ ↔ I = ⊤ :=\nbegin\n  split,\n  { contrapose!,\n    intro h,\n    apply set.ne_empty_iff_nonempty.mpr,\n    rcases ideal.exists_le_maximal I h with ⟨M, hM, hIM⟩,\n    exact ⟨⟨M, hM.is_prime⟩, hIM⟩ },\n  { rintro rfl, apply zero_locus_empty_of_one_mem, trivial }\nend\n\n@[simp] lemma zero_locus_univ :\n  zero_locus (set.univ : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I ⊔ J : ideal R) : set R) = zero_locus I ∩ zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s ∪ s') = zero_locus s ∩ zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t ∪ t') = vanishing_ideal t ⊓ vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {ι : Sort*} (I : ι → ideal R) :\n  zero_locus ((⨆ i, I i : ideal R) : set R) = (⋂ i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {ι : Sort*} (s : ι → set R) :\n  zero_locus (⋃ i, s i) = (⋂ i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (⋃ s' ∈ s, s' : set R) = ⋂ s' ∈ s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {ι : Sort*} (t : ι → set (prime_spectrum R)) :\n  vanishing_ideal (⋃ i, t i) = (⨅ i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I ⊓ J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s ∪ zero_locus s' = zero_locus ((ideal.span s) ⊓ (ideal.span s') : ideal R) :=\nby { rw zero_locus_inf, simp }\n\nlemma zero_locus_mul (I J : ideal R) :\n  zero_locus ((I * J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.mul_le\n\nlemma zero_locus_singleton_mul (f g : R) :\n  zero_locus ({f * g} : set R) = zero_locus {f} ∪ zero_locus {g} :=\nset.ext $ λ x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : ℕ} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) ▸ (I.radical_pow n hn).symm ▸ zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : ℕ) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ λ x, by simpa using x.2.pow_mem_iff_mem n hn\n\nlemma sup_vanishing_ideal_le (t t' : set (prime_spectrum R)) :\n  vanishing_ideal t ⊔ vanishing_ideal t' ≤ vanishing_ideal (t ∩ t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro ⟨f, hf, g, hg, rfl⟩ x ⟨hxt, hxt'⟩,\n  rw mem_vanishing_ideal at hf hg,\n  apply submodule.add_mem; solve_by_elim\nend\n\nlemma mem_compl_zero_locus_iff_not_mem {f : R} {I : prime_spectrum R} :\n  I ∈ (zero_locus {f} : set (prime_spectrum R))ᶜ ↔ f ∉ I.as_ideal :=\nby rw [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]; refl\n\n/-- The Zariski topology on the prime spectrum of a commutative ring\nis defined via the closed sets of the topology:\nthey are exactly those sets that are the zero locus of a subset of the ring. -/\ninstance zariski_topology : topological_space (prime_spectrum R) :=\ntopological_space.of_closed (set.range prime_spectrum.zero_locus)\n  (⟨set.univ, by simp⟩)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs → set R := λ i, classical.some (h i.2),\n    have hf : ∀ i : Zs, ↑i = zero_locus (f i) := λ i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact ⟨_, zero_locus_Union _⟩\n  end\n  (by { rintro _ _ ⟨s, rfl⟩ ⟨t, rfl⟩, exact ⟨_, (union_zero_locus s t).symm⟩ })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U ↔ ∃ s, Uᶜ = zero_locus s :=\nby simp only [@eq_comm _ Uᶜ]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ s, Z = zero_locus s :=\nby rw [← is_open_compl_iff, is_open_iff, compl_compl]\n\nlemma is_closed_zero_locus (s : set R) :\n  is_closed (zero_locus s) :=\nby { rw [is_closed_iff_zero_locus], exact ⟨s, rfl⟩ }\n\nlemma is_closed_singleton_iff_is_maximal (x : prime_spectrum R) :\n  is_closed ({x} : set (prime_spectrum R)) ↔ x.as_ideal.is_maximal :=\nbegin\n  refine (is_closed_iff_zero_locus _).trans ⟨λ h, _, λ h, _⟩,\n  { obtain ⟨s, hs⟩ := h,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem] at hs,\n    refine ⟨⟨x.2.1, λ I hI, not_not.1 (mt (ideal.exists_le_maximal I) $\n      not_exists.2 (λ J, not_and.2 $ λ hJ hIJ,_))⟩⟩,\n    exact ne_of_lt (lt_of_lt_of_le hI hIJ) (symm $ congr_arg prime_spectrum.as_ideal\n      (hs.2 ⟨J, hJ.is_prime⟩ (λ r hr, hIJ (le_of_lt hI $ hs.1 hr)))) },\n  { refine ⟨x.as_ideal.1, _⟩,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem],\n    refine ⟨λ _ h, h, λ y hy, prime_spectrum.ext.2 (h.eq_of_le y.2.ne_top hy).symm⟩ }\nend\n\nlemma zero_locus_vanishing_ideal_eq_closure (t : set (prime_spectrum R)) :\n  zero_locus (vanishing_ideal t : set R) = closure t :=\nbegin\n  apply set.subset.antisymm,\n  { rintro x hx t' ⟨ht', ht⟩,\n    obtain ⟨fs, rfl⟩ : ∃ s, t' = zero_locus s,\n    by rwa [is_closed_iff_zero_locus] at ht',\n    rw [subset_zero_locus_iff_subset_vanishing_ideal] at ht,\n    exact set.subset.trans ht hx },\n  { rw (is_closed_zero_locus _).closure_subset_iff,\n    exact subset_zero_locus_vanishing_ideal t }\nend\n\nlemma vanishing_ideal_closure (t : set (prime_spectrum R)) :\n  vanishing_ideal (closure t) = vanishing_ideal t :=\nzero_locus_vanishing_ideal_eq_closure t ▸ (gc R).u_l_u_eq_u t\n\nlemma t1_space_iff_is_field [is_domain R] :\n  t1_space (prime_spectrum R) ↔ is_field R :=\nbegin\n  refine ⟨_, λ h, _⟩,\n  { introI h,\n    have hbot : ideal.is_prime (⊥ : ideal R) := ideal.bot_prime,\n    exact not_not.1 (mt (ring.ne_bot_of_is_maximal_of_not_is_field $\n      (is_closed_singleton_iff_is_maximal _).1 (t1_space.t1 ⟨⊥, hbot⟩)) (not_not.2 rfl)) },\n  { refine ⟨λ x, (is_closed_singleton_iff_is_maximal x).2 _⟩,\n    by_cases hx : x.as_ideal = ⊥,\n    { exact hx.symm ▸ @ideal.bot_is_maximal R (@field.to_division_ring _ $ is_field.to_field R h) },\n    { exact absurd h (ring.not_is_field_iff_exists_prime.2 ⟨x.as_ideal, ⟨hx, x.2⟩⟩) } }\nend\n\nsection comap\nvariables {S : Type v} [comm_ring S] {S' : Type*} [comm_ring S']\n\n\nlemma preimage_comap_zero_locus_aux (f : R →+* S) (s : set R) :\n  (λ y, ⟨ideal.comap f y.as_ideal, infer_instance⟩ :\n    prime_spectrum S → prime_spectrum R) ⁻¹' (zero_locus s) = zero_locus (f '' s) :=\nbegin\n  ext x,\n  simp only [mem_zero_locus, set.image_subset_iff],\n  refl\nend\n\n/-- The function between prime spectra of commutative rings induced by a ring homomorphism.\nThis function is continuous. -/\ndef comap (f : R →+* S) : C(prime_spectrum S, prime_spectrum R) :=\n{ to_fun := λ y, ⟨ideal.comap f y.as_ideal, infer_instance⟩,\n  continuous_to_fun :=\n    begin\n      simp only [continuous_iff_is_closed, is_closed_iff_zero_locus],\n      rintro _ ⟨s, rfl⟩,\n      exact ⟨_, preimage_comap_zero_locus_aux f s⟩\n    end }\n\nvariables (f : R →+* S)\n\n@[simp] lemma comap_as_ideal (y : prime_spectrum S) :\n  (comap f y).as_ideal = ideal.comap f y.as_ideal :=\nrfl\n\n@[simp] lemma comap_id : comap (ring_hom.id R) = continuous_map.id := by { ext, refl }\n\n@[simp] lemma comap_comp (f : R →+* S) (g : S →+* S') :\n  comap (g.comp f) = (comap f).comp (comap g) :=\nrfl\n\n@[simp] lemma preimage_comap_zero_locus (s : set R) :\n  (comap f) ⁻¹' (zero_locus s) = zero_locus (f '' s) :=\npreimage_comap_zero_locus_aux f s\n\nlemma comap_injective_of_surjective (f : R →+* S) (hf : function.surjective f) :\n  function.injective (comap f) :=\nλ x y h, prime_spectrum.ext.2 (ideal.comap_injective_of_surjective f hf\n  (congr_arg prime_spectrum.as_ideal h : (comap f x).as_ideal = (comap f y).as_ideal))\n\nlemma comap_singleton_is_closed_of_surjective (f : R →+* S) (hf : function.surjective f)\n  (x : prime_spectrum S) (hx : is_closed ({x} : set (prime_spectrum S))) :\n  is_closed ({comap f x} : set (prime_spectrum R)) :=\nbegin\n  haveI : x.as_ideal.is_maximal := (is_closed_singleton_iff_is_maximal x).1 hx,\n  exact (is_closed_singleton_iff_is_maximal _).2 (ideal.comap_is_maximal_of_surjective f hf)\nend\n\nlemma comap_singleton_is_closed_of_is_integral (f : R →+* S) (hf : f.is_integral)\n  (x : prime_spectrum S) (hx : is_closed ({x} : set (prime_spectrum S))) :\n  is_closed ({comap f x} : set (prime_spectrum R)) :=\n(is_closed_singleton_iff_is_maximal _).2 (ideal.is_maximal_comap_of_is_integral_of_is_maximal'\n  f hf x.as_ideal $ (is_closed_singleton_iff_is_maximal x).1 hx)\n\nvariable S\n\nlemma localization_comap_inducing [algebra R S] (M : submonoid R)\n  [is_localization M S] : inducing (comap (algebra_map R S)) :=\nbegin\n  constructor,\n  rw topological_space_eq_iff,\n  intro U,\n  simp_rw ← is_closed_compl_iff,\n  generalize : Uᶜ = Z,\n  simp_rw [is_closed_induced_iff, is_closed_iff_zero_locus],\n  split,\n  { rintro ⟨s, rfl⟩,\n    refine ⟨_,⟨(algebra_map R S) ⁻¹' (ideal.span s),rfl⟩,_⟩,\n    rw [preimage_comap_zero_locus, ← zero_locus_span, ← zero_locus_span s],\n    congr' 1,\n    exact congr_arg submodule.carrier (is_localization.map_comap M S (ideal.span s)) },\n  { rintro ⟨_, ⟨t, rfl⟩, rfl⟩, simp }\nend\n\nlemma localization_comap_injective [algebra R S] (M : submonoid R)\n  [is_localization M S] : function.injective (comap (algebra_map R S)) :=\nbegin\n  intros p q h,\n  replace h := congr_arg (λ (x : prime_spectrum R), ideal.map (algebra_map R S) x.as_ideal) h,\n  dsimp only at h,\n  erw [is_localization.map_comap M S, is_localization.map_comap M S] at h,\n  ext1,\n  exact h\nend\n\nlemma localization_comap_embedding [algebra R S] (M : submonoid R)\n  [is_localization M S] : embedding (comap (algebra_map R S)) :=\n⟨localization_comap_inducing S M, localization_comap_injective S M⟩\n\nlemma localization_comap_range [algebra R S] (M : submonoid R)\n  [is_localization M S] :\n  set.range (comap (algebra_map R S)) = { p | disjoint (M : set R) p.as_ideal } :=\nbegin\n  ext x,\n  split,\n  { rintro ⟨p, rfl⟩ x ⟨hx₁, hx₂⟩,\n    exact (p.2.1 : ¬ _)\n      (p.as_ideal.eq_top_of_is_unit_mem hx₂ (is_localization.map_units S ⟨x, hx₁⟩)) },\n  { intro h,\n    use ⟨x.as_ideal.map (algebra_map R S),\n      is_localization.is_prime_of_is_prime_disjoint M S _ x.2 h⟩,\n    ext1,\n    exact is_localization.comap_map_of_is_prime_disjoint M S _ x.2 h }\nend\n\nend comap\n\nsection basic_open\n\n/-- `basic_open r` is the open subset containing all prime ideals not containing `r`. -/\ndef basic_open (r : R) : topological_space.opens (prime_spectrum R) :=\n{ val := { x | r ∉ x.as_ideal },\n  property := ⟨{r}, set.ext $ λ x, set.singleton_subset_iff.trans $ not_not.symm⟩ }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x ∈ basic_open f ↔ f ∉ x.as_ideal := iff.rfl\n\nlemma is_open_basic_open {a : R} : is_open ((basic_open a) : set (prime_spectrum R)) :=\n(basic_open a).property\n\n@[simp] lemma basic_open_eq_zero_locus_compl (r : R) :\n  (basic_open r : set (prime_spectrum R)) = (zero_locus {r})ᶜ :=\nset.ext $ λ x, by simpa only [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]\n\n@[simp] lemma basic_open_one : basic_open (1 : R) = ⊤ :=\ntopological_space.opens.ext $ by {simp, refl}\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = ⊥ :=\ntopological_space.opens.ext $ by {simp, refl}\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f ≤ basic_open g ↔ f ∈ (ideal.span ({g} : set R)).radical :=\nby rw [topological_space.opens.le_def, basic_open_eq_zero_locus_compl,\n    basic_open_eq_zero_locus_compl, set.le_eq_subset, set.compl_subset_compl,\n    zero_locus_subset_zero_locus_singleton_iff]\n\nlemma basic_open_mul (f g : R) : basic_open (f * g) = basic_open f ⊓ basic_open g :=\ntopological_space.opens.ext $ by {simp [zero_locus_singleton_mul]}\n\nlemma basic_open_mul_le_left (f g : R) : basic_open (f * g) ≤ basic_open f :=\nby { rw basic_open_mul f g, exact inf_le_left }\n\nlemma basic_open_mul_le_right (f g : R) : basic_open (f * g) ≤ basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : ℕ) (hn : 0 < n) : basic_open (f ^ n) = basic_open f :=\ntopological_space.opens.ext $ by simpa using zero_locus_singleton_pow f n hn\n\nlemma is_topological_basis_basic_opens : topological_space.is_topological_basis\n  (set.range (λ (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ ⟨r, rfl⟩,\n    exact is_open_basic_open },\n  { rintros p U hp ⟨s, hs⟩,\n    rw [← compl_compl U, set.mem_compl_eq, ← hs, mem_zero_locus, set.not_subset] at hp,\n    obtain ⟨f, hfs, hfp⟩ := hp,\n    refine ⟨basic_open f, ⟨f, rfl⟩, hfp, _⟩,\n    rw [← set.compl_subset_compl, ← hs, basic_open_eq_zero_locus_compl, compl_compl],\n    exact zero_locus_anti_mono (set.singleton_subset_iff.mpr hfs) }\nend\n\nlemma is_basis_basic_opens :\n  topological_space.opens.is_basis (set.range (@basic_open R _)) :=\nbegin\n  unfold topological_space.opens.is_basis,\n  convert is_topological_basis_basic_opens,\n  rw ← set.range_comp,\nend\n\nlemma is_compact_basic_open (f : R) : is_compact (basic_open f : set (prime_spectrum R)) :=\nis_compact_of_finite_subfamily_closed $ λ ι Z hZc hZ,\nbegin\n  let I : ι → ideal R := λ i, vanishing_ideal (Z i),\n  have hI : ∀ i, Z i = zero_locus (I i) := λ i,\n    by simpa only [zero_locus_vanishing_ideal_eq_closure] using (hZc i).closure_eq.symm,\n  rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n      set.diff_eq_empty, funext hI, ← zero_locus_supr] at hZ,\n  obtain ⟨n, hn⟩ : f ∈ (⨆ (i : ι), I i).radical,\n  { rw ← vanishing_ideal_zero_locus_eq_radical,\n    apply vanishing_ideal_anti_mono hZ,\n    exact (subset_vanishing_ideal_zero_locus {f} (set.mem_singleton f)) },\n  rcases submodule.exists_finset_of_mem_supr I hn with ⟨s, hs⟩,\n  use s,\n  -- Using simp_rw here, because `hI` and `zero_locus_supr` need to be applied underneath binders\n  simp_rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n           set.diff_eq_empty, hI, ← zero_locus_supr],\n  rw ← zero_locus_radical, -- this one can't be in `simp_rw` because it would loop\n  apply zero_locus_anti_mono,\n  rw set.singleton_subset_iff,\n  exact ⟨n, hs⟩\nend\n\nlemma localization_away_comap_range (S : Type v) [comm_ring S] [algebra R S] (r : R)\n  [is_localization.away r S] : set.range (comap (algebra_map R S)) = basic_open r :=\nbegin\n  rw localization_comap_range S (submonoid.powers r),\n  ext,\n  simp only [mem_zero_locus, basic_open_eq_zero_locus_compl, set_like.mem_coe, set.mem_set_of_eq,\n    set.singleton_subset_iff, set.mem_compl_eq],\n  split,\n  { intros h₁ h₂,\n    exact h₁ ⟨submonoid.mem_powers r, h₂⟩ },\n  { rintros h₁ _ ⟨⟨n, rfl⟩, h₃⟩,\n    exact h₁ (x.2.mem_of_pow_mem _ h₃) },\nend\n\nlemma localization_away_open_embedding (S : Type v) [comm_ring S] [algebra R S] (r : R)\n  [is_localization.away r S] : open_embedding (comap (algebra_map R S)) :=\n{ to_embedding := localization_comap_embedding S (submonoid.powers r),\n  open_range := by { rw localization_away_comap_range S r, exact is_open_basic_open } }\n\nend basic_open\n\n/-- The prime spectrum of a commutative ring is a compact topological space. -/\ninstance : compact_space (prime_spectrum R) :=\n{ compact_univ := by { convert is_compact_basic_open (1 : R), rw basic_open_one, refl } }\n\nsection order\n\n/-!\n## The specialization order\n\nWe endow `prime_spectrum R` with a partial order,\nwhere `x ≤ y` if and only if `y ∈ closure {x}`.\n\nTODO: maybe define sober topological spaces, and generalise this instance to those\n-/\n\ninstance : partial_order (prime_spectrum R) :=\nsubtype.partial_order _\n\n@[simp] lemma as_ideal_le_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal ≤ y.as_ideal ↔ x ≤ y :=\nsubtype.coe_le_coe\n\n@[simp] lemma as_ideal_lt_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal < y.as_ideal ↔ x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x ≤ y ↔ y ∈ closure ({x} : set (prime_spectrum R)) :=\nby rw [← as_ideal_le_as_ideal, ← zero_locus_vanishing_ideal_eq_closure,\n    mem_zero_locus, vanishing_ideal_singleton, set_like.coe_subset_coe]\n\nend order\n\nend prime_spectrum\n\n\nnamespace local_ring\n\nvariables (R) [local_ring R]\n\n/--\nThe closed point in the prime spectrum of a local ring.\n-/\ndef closed_point : prime_spectrum R :=\n⟨maximal_ideal R, (maximal_ideal.is_maximal R).is_prime⟩\n\nvariable {R}\n\nlemma local_hom_iff_comap_closed_point {S : Type v} [comm_ring S] [local_ring S]\n  {f : R →+* S} : is_local_ring_hom f ↔ prime_spectrum.comap f (closed_point S) = closed_point R :=\nby { rw [(local_hom_tfae f).out 0 4, subtype.ext_iff], refl }\n\nend local_ring\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebraic_geometry/prime_spectrum/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4734208967165172}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.star.basic\nimport algebra.ring.prod\nimport algebra.module.prod\n\n/-!\n# `star` on product types\n\nWe put a `has_star` structure on product types that operates elementwise.\n-/\n\nuniverses u v w\nvariables {R : Type u} {S : Type v}\n\nnamespace prod\n\ninstance [has_star R] [has_star S] : has_star (R × S) :=\n{ star := λ x, (star x.1, star x.2) }\n\n@[simp] lemma fst_star [has_star R] [has_star S] (x : R × S) : (star x).1 = star x.1 := rfl\n@[simp] \n\nlemma star_def [has_star R] [has_star S] (x : R × S) : star x = (star x.1, star x.2) := rfl\n\ninstance [has_involutive_star R] [has_involutive_star S] : has_involutive_star (R × S) :=\n{ star_involutive := λ _, prod.ext (star_star _) (star_star _) }\n\ninstance [semigroup R] [semigroup S] [star_semigroup R] [star_semigroup S] :\n  star_semigroup (R × S) :=\n{ star_mul := λ _ _, prod.ext (star_mul _ _) (star_mul _ _) }\n\ninstance [add_monoid R] [add_monoid S] [star_add_monoid R] [star_add_monoid S] :\n  star_add_monoid (R × S) :=\n{ star_add := λ _ _, prod.ext (star_add _ _) (star_add _ _) }\n\ninstance [non_unital_semiring R] [non_unital_semiring S] [star_ring R] [star_ring S] :\n  star_ring (R × S) :=\n{ ..prod.star_add_monoid, ..(prod.star_semigroup : star_semigroup (R × S)) }\n\ninstance {α : Type w} [has_scalar α R] [has_scalar α S] [has_star α] [has_star R] [has_star S]\n  [star_module α R] [star_module α S] :\n  star_module α (R × S) :=\n{ star_smul := λ r x, prod.ext (star_smul _ _) (star_smul _ _) }\n\nend prod\n\n@[simp] lemma units.embed_product_star [monoid R] [star_semigroup R] (u : Rˣ) :\n  units.embed_product R (star u) = star (units.embed_product R u) := rfl\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/star/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4731351366265705}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\n\nimport control.functor.multivariate\nimport data.qpf.multivariate.basic\n\n/-!\n# Constant functors are QPFs\n\nConstant functors map every type vectors to the same target type. This\nis a useful device for constructing data types from more basic types\nthat are not actually functorial. For instance `const n nat` makes\n`nat` into a functor that can be used in a functor-based data type\nspecification.\n-/\n\nuniverses u\n\nnamespace mvqpf\nopen_locale mvfunctor\n\nvariables (n : ℕ)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A α} [inhabited A] : inhabited (const n A α) :=\n⟨ (default A : A) ⟩\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {α β : typevec.{u} n} (f : α ⟹ β)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) α := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) α) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) α) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A α) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) α → (const n A) β :=\nλ x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := λ α β f, const.map }\n\nlemma map_mk (x : A) :\n  f <$$> const.mk x = const.mk x := rfl\n\nlemma get_map (x : (const n A) α) :\n  const.get (f <$$> x) = const.get x := rfl\n\ninstance mvqpf : @mvqpf _ (const n A) (mvqpf.const.mvfunctor) :=\n{ P         := mvpfunctor.const n A,\n  abs       := λ α x, mvpfunctor.const.get x,\n  repr      := λ α x, mvpfunctor.const.mk n x,\n  abs_repr  := by intros; simp,\n  abs_map   := by intros; simp; refl, }\n\nend const\n\nend mvqpf\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/qpf/multivariate/constructions/const.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238982, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.47313513181007777}}
{"text": "/-\nCopyright (c) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\n-- Ported from mathlib3, file src/data/list/basic.lean,\n-- commit a945b3769cb82bc238ee004b4327201a6864e7e0\n\nimport Aesop\n\nset_option aesop.check.script true\n\n-- We use this constant to 'prove' theorems which Aesop can't solve. We don't\n-- use `sorry` because it generates lots of warnings.\naxiom ADMIT : ∀ {α : Sort _}, α\n\n@[aesop safe cases]\nclass IsEmpty (α : Sort _) where\n  false : α → False\n\n@[aesop safe forward]\ndef IsEmpty.false' (h : IsEmpty α) (a : α) : False :=\n  h.false a\n\n@[aesop safe constructors]\nstructure Unique (α : Sort _) extends Inhabited α where\n  uniq : ∀ a : α, a = toInhabited.default\n\nclass IsLeftId (α : Type _) (op : α → α → α) (o : outParam α) : Prop where\n  leftId : ∀ a, op o a = a\n\ndef Injective (f : α → β) : Prop :=\n  ∀ x y, f x = f y → x = y\n\n@[aesop safe forward]\ntheorem injective_elim (h₁ : Injective f) (h₂ : f a = f b) : a = b :=\n  h₁ _ _ h₂\n\n@[aesop 99%]\ntheorem injective_intro (h : ∀ a b, f a = f b → a = b) : Injective f :=\n  h\n\ndef Surjective (f : α → β) : Prop :=\n  ∀ b, ∃ a, f a = b\n\n@[aesop norm (forward (immediate := [h]))]\ntheorem surjective_elim (h : Surjective f) : ∀ b, ∃ a, f a = b :=\n  h\n\n@[aesop 99%]\ntheorem surjective_intro (h : ∀ b, ∃ a, f a = b) : Surjective f :=\n  h\n\n@[aesop norm unfold]\ndef Bijective (f : α → β) : Prop :=\n  Injective f ∧ Surjective f\n\ndef Involutive (f : α → α) : Prop :=\n  ∀ x, f (f x) = x\n\n@[aesop norm forward]\ntheorem involutive_elim {f : α → α} (h : Involutive f) (a : α) : f (f a) = a :=\n  h a\n\n@[aesop 99%]\ntheorem involutive_intro (h : ∀ a, f (f a) = a) : Involutive f :=\n  h\n\n@[aesop 25%]\ntheorem Involutive.injective : Involutive f → Injective f :=\n  λ h x y hxy => by rw [← h x, ← h y, hxy]\n\n@[aesop 25%]\ntheorem Involutive.surjective : Involutive f → Surjective f :=\n  λ h x => ⟨f x, h x⟩\n\ntheorem Involutive.bijective (h : Involutive f) : Bijective f :=\n  ⟨h.injective, h.surjective⟩\n\nnamespace Option\n\n@[aesop safe [constructors, cases]]\ninductive Mem (a : α) : Option α → Prop\n  | some : Mem a (some a)\n\ninstance : Membership α (Option α) :=\n  ⟨Option.Mem⟩\n\n@[simp]\ntheorem mem_spec {o : Option α} : a ∈ o ↔ o = some a := by\n  aesop (add norm simp Membership.mem)\n\n@[simp]\ntheorem mem_none : a ∈ none ↔ False := by\n  aesop\n\n@[simp]\ntheorem mem_some : a ∈ some b ↔ a = b := by\n  aesop\n\n@[simp]\ndef iget [Inhabited α] : Option α → α\n  | none => default\n  | some a => a\n\nend Option\n\nnamespace List\n\nattribute [simp] map List.bind\n\ninstance : Pure List where\n  pure x := [x]\n\ndef init : List α → List α\n  | [] => []\n  | [_] => []\n  | a :: as => a :: init as\n\n@[simp]\ndef last : (l : List α) → l ≠ [] → α\n  | [], h => nomatch h\n  | [a], _ => a\n  | _ :: a :: as, _ => last (a :: as) (by aesop)\n\n-- The unnecessarily complicated case split in this definition is inherited from\n-- Lean 3.\n@[simp]\ndef ilast [Inhabited α] : List α → α\n  | [] => default\n  | [a] => a\n  | [_, b] => b\n  | _ :: _ :: l => ilast l\n\n@[simp]\ndef head' : List α → Option α\n  | [] => none\n  | a :: _ => some a\n\n@[simp]\ndef ihead [Inhabited α] : List α → α\n  | [] => default\n  | a :: _ => a\n\n@[simp]\ndef nth_le : ∀ (l : List α) (n), n < l.length → α\n  | [],       n,     h => absurd h n.not_lt_zero\n  | (a :: _), 0,     _ => a\n  | (_ :: l), (n+1), h => nth_le l n (by simp_all_arith)\n\n@[simp]\ndef modify_head (f : α → α) : List α → List α\n  | [] => []\n  | (a :: as) => f a :: as\n\n@[simp]\ndef Empty : List α → Prop\n  | [] => True\n  | _ :: _ => False\n\n@[simp] theorem mem_eq_mem : Mem x xs ↔ x ∈ xs := Iff.rfl\n\ntheorem subset_trans {l₁ l₂ l₃ : List α} : l₁ ⊆ l₂ → l₂ ⊆ l₃ → l₁ ⊆ l₃ := by\n  intro h₁ h₂ a ha\n  cases l₁ with\n  | nil =>\n    cases ha\n  | cons x xs =>\n    cases ha with\n    | head =>\n      apply h₂\n      apply h₁\n      constructor\n    | tail _ hxs =>\n      apply h₂\n      apply h₁\n      constructor\n      assumption\n\n-- END PRELUDE\n\ninstance unique_of_is_empty [IsEmpty α] : Unique (List α) := by\n  aesop (add 1% cases List)\n\n-- instance : is_left_id (list α) has_append.append [] :=\n-- ⟨ nil_append ⟩\n\n-- instance : is_right_id (list α) has_append.append [] :=\n-- ⟨ append_nil ⟩\n\n-- instance : is_associative (list α) has_append.append :=\n-- ⟨ append_assoc ⟩\n\n-- attribute [-simp] cons_ne_nil\ntheorem X.cons_ne_nil (a : α) (l : List α) : a::l ≠ [] := by\n  aesop\n\n-- attribute [-simp] cons_ne_self\ntheorem X.cons_ne_self (a : α) (l : List α) : a::l ≠ l := by\n  aesop (add 1% cases Eq)\n\n-- attribute [-simp] head_eq_of_cons_eq\ntheorem X.head_eq_of_cons_eq {h₁ h₂ : α} {t₁ t₂ : List α} :\n      (h₁::t₁) = (h₂::t₂) → h₁ = h₂ := by\n  aesop\n\n-- attribute [-simp] tail_eq_of_cons_eq\ntheorem X.tail_eq_of_cons_eq {h₁ h₂ : α} {t₁ t₂ : List α} :\n      (h₁::t₁) = (h₂::t₂) → t₁ = t₂ := by\n  aesop\n\n@[simp] theorem cons_injective {a : α} : Injective (cons a) := by\n  aesop\n\n-- attribute [-simp] cons_inj\ntheorem X.cons_inj (a : α) {l l' : List α} : a::l = a::l' ↔ l = l' := by\n  aesop\n\n-- attribute [-simp] exists_cons_of_ne_nil\ntheorem X.exists_cons_of_ne_nil : l ≠ nil → ∃ b L, l = b :: L := by\n  aesop (add 1% cases List)\n\n-- theorem set_of_mem_cons (l : list α) (a : α) : {x | x ∈ a :: l} = insert a {x | x ∈ l} := rfl\n\n/-! ### mem -/\n\nattribute [aesop safe constructors] List.Mem\nattribute [aesop safe (cases (patterns := [List.Mem _ [], List.Mem _ (_ :: _)]))] List.Mem\n\n-- attribute [-simp] mem_singleton_self\n@[simp]\ntheorem X.mem_singleton_self (a : α) : a ∈ [a] := by\n  aesop\n\nattribute [-simp] mem_singleton\n-- attribute [-simp] eq_of_mem_singleton\ntheorem X.eq_of_mem_singleton {a b : α} : a ∈ [b] → a = b := by\n  aesop\n\n@[simp]\ntheorem X.mem_singleton {a b : α} : a ∈ [b] ↔ a = b := by\n  aesop\n\n-- attribute [-simp] mem_of_mem_cons_of_mem\ntheorem X.mem_of_mem_cons_of_mem {a b : α} {l : List α} : a ∈ b::l → b ∈ l → a ∈ l := by\n  aesop\n\nset_option linter.unusedVariables false in\ntheorem _root_.decidable.list.eq_or_ne_mem_of_mem [deq : DecidableEq α]\n  {a b : α} {l : List α} (h : a ∈ b :: l) : a = b ∨ (a ≠ b ∧ a ∈ l) :=\n  ADMIT\n  -- cases deq a b <;> aesop\n\n-- attribute [-simp] eq_or_ne_mem_of_mem\ntheorem X.eq_or_ne_mem_of_mem {a b : α} {l : List α} : a ∈ b :: l → a = b ∨ (a ≠ b ∧ a ∈ l) := by\n  open Classical in\n  aesop (add safe [decidable.list.eq_or_ne_mem_of_mem])\n\ntheorem not_mem_append {a : α} {s t : List α} (h₁ : a ∉ s) (h₂ : a ∉ t) : a ∉ s ++ t := by\n  induction s <;> aesop\n\n-- attribute [-simp] ne_nil_of_mem\ntheorem X.ne_nil_of_mem {a : α} {l : List α} (h : a ∈ l) : l ≠ [] := by\n  aesop\n\nset_option linter.unusedVariables false in\ntheorem mem_split {a : α} {l : List α} (h : a ∈ l) : ∃ s t : List α, l = s ++ a :: t :=\n  ADMIT -- Nontrivial existential.\n\ntheorem mem_of_ne_of_mem {a y : α} {l : List α} (h₁ : a ≠ y) (h₂ : a ∈ y :: l) : a ∈ l := by\n  aesop\n\ntheorem ne_of_not_mem_cons {a b : α} {l : List α} : a ∉ b::l → a ≠ b := by\n  aesop\n\ntheorem not_mem_of_not_mem_cons {a b : α} {l : List α} : a ∉ b::l → a ∉ l := by\n  aesop\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : α} {l : List α} : a ≠ y → a ∉ l → a ∉ y::l := by\n  aesop\n\ntheorem ne_and_not_mem_of_not_mem_cons {a y : α} {l : List α} : a ∉ y::l → a ≠ y ∧ a ∉ l := by\n  aesop\n\n-- attribute [-simp] mem_map\n@[simp] theorem X.mem_map {f : α → β} {b : β} {l : List α} : b ∈ map f l ↔ ∃ a, a ∈ l ∧ f a = b := by\n  induction l <;> aesop\n\n-- attribute [-simp] mem_map_of_mem\n@[aesop safe]\ntheorem X.mem_map_of_mem (f : α → β) {a : α} {l : List α} (h : a ∈ l) : f a ∈ map f l := by\n  aesop\n\ntheorem mem_map_of_injective {f : α → β} (H : Injective f) {a : α} {l : List α} :\n  f a ∈ map f l ↔ a ∈ l := by\n  aesop\n\n@[simp] theorem _root_.function.involutive.exists_mem_and_apply_eq_iff {f : α → α}\n  (hf : Involutive f) (x : α) (l : List α) :\n  (∃ (y : α), y ∈ l ∧ f y = x) ↔ f x ∈ l := by\n  aesop\n\ntheorem mem_map_of_involutive {f : α → α} (hf : Involutive f) {a : α} {l : List α} :\n  a ∈ map f l ↔ f a ∈ l := by\n  aesop\n\n-- attribute [-simp] forall_mem_map_iff\ntheorem X.forall_mem_map_iff {f : α → β} {l : List α} {P : β → Prop} :\n  (∀ i, i ∈ l.map f → P i) ↔ ∀ j, j ∈ l → P (f j) := by\n  aesop\n\nattribute [-simp] map_eq_nil\n@[simp] theorem X.map_eq_nil {f : α → β} {l : List α} : map f l = [] ↔ l = [] := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] mem_join\n@[simp] theorem X.mem_join {a : α} : ∀ {L : List (List α)}, a ∈ join L ↔ ∃ l, l ∈ L ∧ a ∈ l := by\n  intro L; induction L <;> aesop\n\n-- attribute [-simp] exists_of_mem_join\ntheorem X.exists_of_mem_join {a : α} {L : List (List α)} : a ∈ join L → ∃ l, l ∈ L ∧ a ∈ l := by\n  aesop\n\n-- attribute [-simp] mem_join_of_mem\ntheorem X.mem_join_of_mem {a : α} {L : List (List α)} {l} (lL : l ∈ L) (al : a ∈ l) : a ∈ join L := by\n  aesop\n\n-- attribute [-simp] mem_bind\n@[simp] theorem X.mem_bind {b : β} {l : List α} {f : α → List β} : b ∈ l.bind f ↔ ∃ a, a ∈ l ∧ b ∈ f a := by\n  induction l <;> aesop\n\n-- attribute [-simp] exists_of_mem_bind\ntheorem X.exists_of_mem_bind {l : List α} :\n    b ∈ l.bind f → ∃ a, a ∈ l ∧ b ∈ f a := by\n  aesop\n\n-- attribute [-simp] mem_bind_of_mem\ntheorem X.mem_bind_of_mem {l : List α} :\n    (∃ a, a ∈ l ∧ b ∈ f a) → b ∈ l.bind f := by\n  induction l <;> aesop\n\n-- attribute [-simp] bind_map\ntheorem X.bind_map {g : α → List β} {f : β → γ} :\n  ∀ l : List α, map f (l.bind g) = l.bind (λa => (g a).map f) := by\n  intro l; induction l <;> aesop\n\ntheorem map_bind (g : β → List γ) (f : α → β) :\n  ∀ l : List α, (map f l).bind g = l.bind (λ a => g (f a)) := by\n  intro l; induction l <;> aesop\n\n-- theorem range_map (f : α → β) : set.range (map f) = {l | ∀ x ∈ l, x ∈ set.range f} :=\n\n-- theorem range_map_coe (s : set α) : set.range (map (coe : s → α)) = {l | ∀ x ∈ l, x ∈ s} :=\n\n-- instance [h : can_lift α β] : can_lift (list α) (list β) :=\n\n/-! ### length -/\n\n-- attribute [-simp] length_eq_zero\ntheorem X.length_eq_zero {l : List α} : length l = 0 ↔ l = [] := by\n  aesop (add 1% cases List)\n\nattribute [-simp] length_singleton\n@[simp] theorem X.length_singleton (a : α) : length [a] = 1 := rfl\n\n-- attribute [-simp] length_pos_of_mem\ntheorem X.length_pos_of_mem {a : α} : ∀ {l : List α}, a ∈ l → 0 < length l := by\n  aesop (add 1% cases List) (simp_options := { arith := true })\n\n-- attribute [-simp] exists_mem_of_length_pos\ntheorem X.exists_mem_of_length_pos : ∀ {l : List α}, 0 < length l → ∃ a, a ∈ l := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] length_pos_iff_exists_mem\ntheorem X.length_pos_iff_exists_mem {l : List α} : 0 < length l ↔ ∃ a, a ∈ l := by\n  aesop (add unsafe [length_pos_of_mem, exists_mem_of_length_pos])\n\ntheorem ne_nil_of_length_pos {l : List α} : 0 < length l → l ≠ [] := by\n  aesop (add 1% cases List)\n\ntheorem length_pos_of_ne_nil {l : List α} : l ≠ [] → 0 < length l := by\n  aesop (add 1% cases List) (simp_options := { arith := true })\n\ntheorem length_pos_iff_ne_nil {l : List α} : 0 < length l ↔ l ≠ [] := by\n  aesop (add unsafe [ne_nil_of_length_pos, length_pos_of_ne_nil])\n\n-- attribute [-simp] exists_mem_of_ne_nil\ntheorem X.exists_mem_of_ne_nil (l : List α) (h : l ≠ []) : ∃ x, x ∈ l := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] length_eq_one\ntheorem X.length_eq_one : length l = 1 ↔ ∃ a, l = [a] := by\n  aesop (add 1% cases List)\n\ntheorem exists_of_length_succ {n} :\n  ∀ l : List α, l.length = n + 1 → ∃ h t, l = h :: t := by\n  intro l; induction l <;> aesop (simp_options := { arith := true })\n\n@[simp] theorem length_injective_iff : Injective (length : List α → Nat) ↔ Subsingleton α :=\n  ADMIT -- Requires induction after case split.\n\n@[simp] theorem length_injective [Subsingleton α] : Injective (length : List α → Nat) := by\n  aesop\n\ntheorem length_eq_two {l : List α} : l.length = 2 ↔ ∃ a b, l = [a, b] := by\n  aesop (add 50% cases List)\n\ntheorem length_eq_three {l : List α} : l.length = 3 ↔ ∃ a b c, l = [a, b, c] := by\n  aesop (add 50% cases List)\n\n/-! ### set-theoretic notation of lists -/\n\nattribute [-simp] empty_eq\ntheorem X.empty_eq : (∅ : List α) = [] := rfl\n\n-- theorem singleton_eq (x : α) : ({x} : List α) = [x]\n\n-- theorem insert_neg [DecidableEq α] {x : α} {l : List α} (h : x ∉ l) :\n--   has_insert.insert x l = x :: l\n\n-- theorem insert_pos [DecidableEq α] {x : α} {l : List α} (h : x ∈ l) :\n--   has_insert.insert x l = l\n\n-- theorem doubleton_eq [DecidableEq α] {x y : α} (h : x ≠ y) : ({x, y} : List α) = [x, y]\n\n/-! ### bounded quantifiers over lists -/\n\n-- The notation used in Lean 3 (`∀ x ∈ xs, P x` and `∃ x ∈ xs, P x`) does not\n-- exist in Lean 4. We've expanded it manually.\n\n-- attribute [-simp] forall_mem_nil\ntheorem X.forall_mem_nil (p : α → Prop) : ∀ x, x ∈ @nil α → p x := by\n  aesop\n\n-- attribute [-simp] forall_mem_cons\ntheorem X.forall_mem_cons : ∀ {p : α → Prop} {a : α} {l : List α},\n    (∀ x, x ∈ a :: l → p x) ↔ p a ∧ ∀ x, x ∈ l → p x := by\n  aesop\n\ntheorem forall_mem_of_forall_mem_cons {p : α → Prop} {a : α} {l : List α}\n    (h : ∀ x, x ∈ a :: l → p x) :\n  ∀ x, x ∈ l → p x := by\n  aesop\n\n-- attribute [-simp] forall_mem_singleton\ntheorem X.forall_mem_singleton {p : α → Prop} {a : α} : (∀ x, x ∈ [a] → p x) ↔ p a := by\n  aesop\n\n-- attribute [-simp] forall_mem_append\ntheorem X.forall_mem_append {p : α → Prop} {l₁ l₂ : List α} :\n    (∀ x, x ∈ l₁ ++ l₂ → p x) ↔ (∀ x, x ∈ l₁ → p x) ∧ (∀ x, x ∈ l₂ → p x) := by\n  aesop\n\ntheorem not_exists_mem_nil (p : α → Prop) : ¬ ∃ x, x ∈ @nil α ∧ p x := by\n  aesop\n\ntheorem exists_mem_cons_of {p : α → Prop} {a : α} (l : List α) (h : p a) :\n    ∃ x, x ∈ a :: l ∧ p x := by\n  aesop\n\ntheorem exists_mem_cons_of_exists {p : α → Prop} {a : α} {l : List α} (h : ∃ x, x ∈ l ∧ p x) :\n  ∃ x, x ∈ a :: l ∧ p x := by\n  aesop\n\ntheorem or_exists_of_exists_mem_cons {p : α → Prop} {a : α} {l : List α} (h : ∃ x, x ∈ a :: l ∧ p x) :\n  p a ∨ ∃ x, x ∈ l ∧ p x := by\n  aesop\n\ntheorem exists_mem_cons_iff (p : α → Prop) (a : α) (l : List α) :\n  (∃ x, x ∈ a :: l ∧ p x) ↔ p a ∨ ∃ x, x ∈ l ∧ p x := by\n  aesop\n\n/-! ### list subset -/\n\n-- attribute [-simp] subset_def\ntheorem X.subset_def {l₁ l₂ : List α} : l₁ ⊆ l₂ ↔ ∀ ⦃a : α⦄, a ∈ l₁ → a ∈ l₂ := by\n  aesop\n\n-- attribute [-simp] subset_append_of_subset_left\ntheorem X.subset_append_of_subset_left (l l₁ l₂ : List α) : l ⊆ l₁ → l ⊆ l₁++l₂ := by\n  aesop (add 1% subset_trans)\n\n-- attribute [-simp] subset_append_of_subset_right\ntheorem X.subset_append_of_subset_right (l l₁ l₂ : List α) : l ⊆ l₂ → l ⊆ l₁ ++ l₂ := by\n  aesop (add 1% subset_trans)\n\nattribute [-simp] cons_subset\n@[simp] theorem X.cons_subset {a : α} {l m : List α} :\n  a::l ⊆ m ↔ a ∈ m ∧ l ⊆ m := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp [HasSubset.Subset, List.Subset])\n\ntheorem cons_subset_of_subset_of_mem {a : α} {l m : List α}\n    (ainm : a ∈ m) (lsubm : l ⊆ m) : a::l ⊆ m := by\n  aesop\n\ntheorem append_subset_of_subset_of_subset {l₁ l₂ l : List α} (l₁subl : l₁ ⊆ l) (l₂subl : l₂ ⊆ l) :\n  l₁ ++ l₂ ⊆ l := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp [HasSubset.Subset, List.Subset])\n\n@[simp] theorem append_subset_iff {l₁ l₂ l : List α} :\n    l₁ ++ l₂ ⊆ l ↔ l₁ ⊆ l ∧ l₂ ⊆ l := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp [HasSubset.Subset, List.Subset])\n\n@[aesop safe destruct]\ntheorem eq_nil_of_subset_nil {l : List α} : l ⊆ [] → l = [] := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] eq_nil_iff_forall_not_mem\ntheorem X.eq_nil_iff_forall_not_mem {l : List α} : l = [] ↔ ∀ a, a ∉ l := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] map_subset\ntheorem X.map_subset {l₁ l₂ : List α} (f : α → β) (H : l₁ ⊆ l₂) : map f l₁ ⊆ map f l₂ := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp [HasSubset.Subset, List.Subset])\n\ntheorem map_subset_iff {l₁ l₂ : List α} (f : α → β) (h : Injective f) :\n    map f l₁ ⊆ map f l₂ ↔ l₁ ⊆ l₂ := by\n  induction l₁ <;> induction l₂ <;> aesop\n\n/-! ### append -/\n\ntheorem append_eq_has_append {L₁ L₂ : List α} : List.append L₁ L₂ = L₁ ++ L₂ := rfl\n\nattribute [-simp] singleton_append\n@[simp] theorem X.singleton_append {x : α} {l : List α} : [x] ++ l = x :: l := rfl\n\n-- attribute [-simp] append_ne_nil_of_ne_nil_left\ntheorem X.append_ne_nil_of_ne_nil_left (s t : List α) : s ≠ [] → s ++ t ≠ [] := by\n  induction s <;> aesop\n\n-- attribute [-simp] append_ne_nil_of_ne_nil_right\ntheorem X.append_ne_nil_of_ne_nil_right (s t : List α) : t ≠ [] → s ++ t ≠ [] := by\n  induction s <;> aesop\n\nattribute [-simp] append_eq_nil\n@[simp] theorem X.append_eq_nil {p q : List α} : (p ++ q) = [] ↔ p = [] ∧ q = [] := by\n  aesop (add 1% cases List)\n\n@[simp] theorem nil_eq_append_iff {a b : List α} : [] = a ++ b ↔ a = [] ∧ b = [] := by\n  induction a <;> aesop\n\ntheorem append_eq_cons_iff {a b c : List α} {x : α} :\n  a ++ b = x :: c ↔ (a = [] ∧ b = x :: c) ∨ (∃a', a = x :: a' ∧ c = a' ++ b) := by\n  aesop (add 1% cases List)\n\ntheorem cons_eq_append_iff {a b c : List α} {x : α} :\n    (x :: c : List α) = a ++ b ↔ (a = [] ∧ b = x :: c) ∨ (∃a', a = x :: a' ∧ c = a' ++ b) := by\n  aesop (add norm simp [append_eq_cons_iff, eq_comm])\n\n-- attribute [-simp] append_eq_append_iff\ntheorem X.append_eq_append_iff {a b c d : List α} :\n    a ++ b = c ++ d ↔ (∃a', c = a ++ a' ∧ b = a' ++ d) ∨ (∃c', a = c ++ c' ∧ d = c' ++ b) :=\n  ADMIT -- Nontrivial existential.\n\nattribute [-simp] take_append_drop\n@[simp] theorem X.take_append_drop : ∀ (n : Nat) (l : List α), take n l ++ drop n l = l\n  | 0        , a         => by aesop\n  | (.succ _), []        => by aesop\n  | (.succ n), (_ :: xs) => by\n    have ih := take_append_drop n xs\n    aesop\n\n-- attribute [-simp] append_inj\n@[aesop safe forward]\ntheorem X.append_inj :\n  ∀ {s₁ s₂ t₁ t₂ : List α}, s₁ ++ t₁ = s₂ ++ t₂ → length s₁ = length s₂ → s₁ = s₂ ∧ t₁ = t₂\n  | []     , []     , t₁, t₂, h, _  => by aesop\n  | (a::s₁), []     , t₁, t₂, _, hl => by aesop\n  | []     , (b::s₂), t₁, t₂, _, hl => by aesop\n  | (a::s₁), (b::s₂), t₁, t₂, h, hl => by\n    have ih := @append_inj _ s₁ s₂ t₁ t₂\n    aesop\n\n-- attribute [-simp] append_inj_right\ntheorem X.append_inj_right {s₁ s₂ t₁ t₂ : List α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n    (hl : length s₁ = length s₂) : t₁ = t₂ := by\n  aesop\n\n-- attribute [-simp] append_inj_left\ntheorem X.append_inj_left {s₁ s₂ t₁ t₂ : List α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n    (hl : length s₁ = length s₂) : s₁ = s₂ := by\n  aesop\n\n-- attribute [-simp] append_inj'\nset_option linter.unusedVariables false in\n@[aesop safe forward]\ntheorem X.append_inj' {s₁ s₂ t₁ t₂ : List α} (h : s₁ ++ t₁ = s₂ ++ t₂) (hl : length t₁ = length t₂) :\n  s₁ = s₂ ∧ t₁ = t₂ := by\n  induction s₁ generalizing s₂ <;> induction s₂ <;>\n    aesop (simp_options := { arith := true })\n\n-- attribute [-simp] append_inj_right'\ntheorem X.append_inj_right' {s₁ s₂ t₁ t₂ : List α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n    (hl : length t₁ = length t₂) : t₁ = t₂ := by\n  aesop\n\n-- attribute [-simp] append_inj_left'\ntheorem X.append_inj_left' {s₁ s₂ t₁ t₂ : List α} (h : s₁ ++ t₁ = s₂ ++ t₂)\n    (hl : length t₁ = length t₂) : s₁ = s₂ := by\n  aesop\n\ntheorem append_left_cancel {s t₁ t₂ : List α} (h : s ++ t₁ = s ++ t₂) : t₁ = t₂ := by\n  aesop\n\ntheorem append_right_cancel {s₁ s₂ t : List α} (h : s₁ ++ t = s₂ ++ t) : s₁ = s₂ := by\n  aesop\n\ntheorem append_right_injective (s : List α) : Injective (λ t => s ++ t) := by\n  aesop\n\n-- attribute [-simp] append_right_inj\ntheorem X.append_right_inj {t₁ t₂ : List α} (s) : s ++ t₁ = s ++ t₂ ↔ t₁ = t₂ := by\n  aesop\n\ntheorem append_left_injective (t : List α) : Injective (λ s => s ++ t) := by\n  aesop\n\n-- attribute [-simp] append_left_inj\ntheorem X.append_left_inj {s₁ s₂ : List α} (t) : s₁ ++ t = s₂ ++ t ↔ s₁ = s₂ := by\n  aesop\n\n-- attribute [-simp] map_eq_append_split\nset_option linter.unusedVariables false in\ntheorem X.map_eq_append_split {f : α → β} {l : List α} {s₁ s₂ : List β}\n    (h : map f l = s₁ ++ s₂) : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ map f l₁ = s₁ ∧ map f l₂ = s₂ :=\n  ADMIT -- Nontrivial existential.\n\n/-! ### replicate/repeat -/\n\n-- Note: `replicate` is called `repeat` in Lean 3 and has flipped arguments.\n\n-- attribute [-simp] replicate_succ\n@[simp] theorem X.replicate_succ (a : α) (n) : replicate (n + 1) a = a :: replicate n a := rfl\n\n-- attribute [-simp] mem_replicate\n@[simp] theorem X.mem_replicate {a b : α} {n} : b ∈ replicate n a ↔ n ≠ 0 ∧ b = a := by\n  induction n <;> aesop\n\n-- attribute [-simp] eq_of_mem_replicate\n@[aesop safe destruct]\ntheorem X.eq_of_mem_replicate {a b : α} {n} (h : b ∈ replicate n a) : b = a := by\n  aesop\n\ntheorem eq_replicate_of_mem {a : α} {l : List α} : (∀ b, b ∈ l → b = a) → l = replicate l.length a := by\n  induction l <;> aesop (simp_options := { useHyps := false })\n\ntheorem eq_replicate' {a : α} {l : List α} : l = replicate l.length a ↔ ∀ b, b ∈ l → b = a := by\n  induction l <;> aesop\n\ntheorem eq_replicate {a : α} {n} {l : List α} : l = replicate n a ↔ length l = n ∧ ∀ b, b ∈ l → b = a := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp eq_replicate')\n\ntheorem replicate_add (a : α) (m n) : replicate (m + n) a = replicate m a ++ replicate n a :=\n  ADMIT -- Need to apply associativity of addition to let `replicate` reduce.\n\ntheorem replicate_subset_singleton (a : α) (n) : replicate n a ⊆ [a] := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp [HasSubset.Subset, List.Subset])\n\ntheorem subset_singleton_iff {a : α} {L : List α} : L ⊆ [a] ↔ ∃ n, L = replicate n a :=\n  ADMIT -- Nontrivial existential.\n\n@[simp] theorem map_const (l : List α) (b : β) : map (λ _ => b) l = replicate l.length b := by\n  induction l <;> aesop\n\ntheorem eq_of_mem_map_const {b₁ b₂ : β} {l : List α} (h : b₁ ∈ map (λ _ => b₂) l) :\n  b₁ = b₂ := by\n  aesop\n\n@[simp] theorem map_replicate (f : α → β) (a : α) (n) : map f (replicate n a) = replicate n (f a) := by\n  induction n <;> aesop\n\n@[simp] theorem tail_replicate (a : α) (n) : tail (replicate n a) = replicate n.pred a := by\n  aesop (add 1% cases Nat)\n\n@[simp] theorem join_replicate_nil (n : Nat) : join (replicate n []) = @nil α := by\n  induction n <;> aesop\n\ntheorem replicate_left_injective {n : Nat} (hn : n ≠ 0) :\n    Injective (λ a : α => replicate n a) := by\n  induction n <;> aesop\n\n@[simp] theorem replicate_left_inj' {a b : α} :\n  ∀ {n}, replicate n a = replicate n b ↔ n = 0 ∨ a = b := by\n  intro n; induction n <;> aesop\n\ntheorem replicate_right_injective (a : α) : Injective (λ n => replicate n a) := by\n  unfold Injective; intro x y\n  induction x generalizing y <;> induction y <;>\n    aesop (simp_options := { useHyps := false })\n\n@[simp] theorem replicate_right_inj {a : α} {n m : Nat} :\n    replicate n a = replicate m a ↔ n = m := by\n  induction n generalizing m <;> aesop (add 1% cases Nat)\n\n/-! ### pure -/\n\n@[simp]\ntheorem mem_pure {α} (x y : α) :\n    x ∈ (pure y : List α) ↔ x = y := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp pure)\n\n/-! ### bind -/\n\ninstance : Bind List where\n  bind l f := List.bind l f\n\n@[simp] theorem bind_eq_bind {α β} (f : α → List β) (l : List α) :\n    l >>= f = l.bind f := rfl\n\ntheorem bind_append (f : α → List β) (l₁ l₂ : List α) :\n  (l₁ ++ l₂).bind f = l₁.bind f ++ l₂.bind f := by\n  induction l₁ <;> aesop\n\n@[simp] theorem bind_singleton (f : α → List β) (x : α) : [x].bind f = f x := by\n  aesop\n\n@[simp] theorem bind_singleton' (l : List α) : l.bind (λ x => [x]) = l := by\n  induction l <;> aesop\n\ntheorem map_eq_bind {α β} (f : α → β) (l : List α) : map f l = l.bind (λ x => [f x]) := by\n  induction l <;> aesop\n\ntheorem bind_assoc {α β γ : Type u} (l : List α) (f : α → List β) (g : β → List γ) :\n    (l.bind f).bind g = l.bind (λ x => (f x).bind g) :=\n  ADMIT\n  -- have aux {δ : Type u} (xs ys : List (List δ)) : join (xs ++ ys) = join xs ++ join ys := by\n  --   induction xs <;> aesop\n  -- induction l <;> aesop (add norm [simp [bind_append], unfold [bind]])\n\n/-! ### concat -/\n\n@[simp] theorem concat_nil (a : α) : concat [] a = [a] := rfl\n\n@[simp] theorem concat_cons (a b : α) (l : List α) : concat (a :: l) b = a :: concat l b := rfl\n\nattribute [-simp] concat_eq_append\n@[simp] theorem X.concat_eq_append (a : α) (l : List α) : concat l a = l ++ [a] := by\n  induction l <;> aesop\n\ntheorem init_eq_of_concat_eq {a : α} {l₁ l₂ : List α} : concat l₁ a = concat l₂ a → l₁ = l₂ := by\n  aesop\n\ntheorem last_eq_of_concat_eq {a b : α} {l : List α} : concat l a = concat l b → a = b := by\n  aesop\n\ntheorem concat_ne_nil (a : α) (l : List α) : concat l a ≠ [] := by\n  aesop\n\nattribute [simp] append_assoc\n\ntheorem concat_append (a : α) (l₁ l₂ : List α) : concat l₁ a ++ l₂ = l₁ ++ a :: l₂ := by\n  aesop\n\nattribute [-simp] length_concat\ntheorem X.length_concat (a : α) (l : List α) : length (concat l a) = .succ (length l) := by\n  aesop\n\ntheorem append_concat (a : α) (l₁ l₂ : List α) : l₁ ++ concat l₂ a = concat (l₁ ++ l₂) a := by\n  aesop\n\n/-! ### reverse -/\n\nattribute [-simp] reverse_nil\n@[simp] theorem X.reverse_nil : reverse (@nil α) = [] := rfl\n\nattribute [-simp] reverse_cons\n@[simp] theorem X.reverse_cons (a : α) (l : List α) : reverse (a::l) = reverse l ++ [a] :=\n  ADMIT\n  -- have aux : ∀ l₁ l₂, reverseAux l₁ l₂ ++ [a] = reverseAux l₁ (l₂ ++ [a]) := by\n  --   intro l₁; induction l₁ <;> aesop (add norm unfold reverseAux)\n  -- aesop (add norm unfold reverse)\n\n-- Note: reverse_core is called reverseAux in Lean 4.\n-- attribute [-simp] reverseAux_eq\n@[simp]\ntheorem reverse_core_eq (l₁ l₂ : List α) : reverseAux l₁ l₂ = reverse l₁ ++ l₂ := by\n  induction l₁ generalizing l₂ <;> aesop\n\ntheorem reverse_cons' (a : α) (l : List α) : reverse (a::l) = concat (reverse l) a := by\n  aesop\n\n@[simp] theorem reverse_singleton (a : α) : reverse [a] = [a] := rfl\n\nattribute [-simp] reverse_append\n@[simp] theorem X.reverse_append (s t : List α) : reverse (s ++ t) = (reverse t) ++ (reverse s) := by\n  induction s <;> aesop\n\n-- attribute [-simp] reverse_concat\ntheorem X.reverse_concat (l : List α) (a : α) : reverse (concat l a) = a :: reverse l := by\n  aesop\n\nattribute [-simp] reverse_reverse\n@[simp] theorem X.reverse_reverse (l : List α) : reverse (reverse l) = l := by\n  induction l <;> aesop\n\n@[simp] theorem reverse_involutive : Involutive (@reverse α) := by\n  aesop\n\n@[simp] theorem reverse_injective {α : Type u} : Injective (@reverse α) := by\n  aesop\n\n@[simp] theorem reverse_surjective {α : Type u} : Surjective (@reverse α) := by\n  aesop\n\n@[simp] theorem reverse_bijective : Bijective (@reverse α) := by\n  aesop\n\n@[simp] theorem reverse_inj {l₁ l₂ : List α} : reverse l₁ = reverse l₂ ↔ l₁ = l₂ := by\n  aesop (add safe forward reverse_injective)\n\ntheorem reverse_eq_iff {l l' : List α} :\n  l.reverse = l' ↔ l = l'.reverse := by\n  aesop\n\n@[simp] theorem reverse_eq_nil {l : List α} : reverse l = [] ↔ l = [] := by\n  aesop (add norm simp reverse_eq_iff)\n\ntheorem concat_eq_reverse_cons (a : α) (l : List α) : concat l a = reverse (a :: reverse l) := by\n  induction l <;> aesop\n\nattribute [-simp] length_reverse\n@[simp] theorem X.length_reverse (l : List α) : length (reverse l) = length l := by\n  induction l <;> aesop\n\ntheorem map_reverse (f : α → β) (l : List α) : map f (reverse l) = reverse (map f l) := by\n  induction l <;> aesop\n\n-- attribute [-simp] map_reverseAux\ntheorem map_reverse_core (f : α → β) (l₁ l₂ : List α) :\n  map f (reverseAux l₁ l₂) = reverseAux (map f l₁) (map f l₂) := by\n  aesop (add norm simp reverse_map)\n\nattribute [-simp] mem_reverse\n@[simp] theorem X.mem_reverse {a : α} {l : List α} : a ∈ reverse l ↔ a ∈ l := by\n  induction l <;> aesop\n\n@[simp] theorem reverse_replicate (a : α) (n) : reverse (replicate n a) = replicate n a :=\n  ADMIT -- Several missing lemmas.\n\n/-! ### empty -/\n\ntheorem empty_iff_eq_nil {l : List α} : Empty l ↔ l = [] := by\n  aesop\n\n/-! ### init -/\n\n@[simp] theorem length_init : ∀ (l : List α), length (init l) = length l - 1\n  | [] => by aesop\n  | [_] => by aesop\n  | (_ :: y :: zs) => by\n    have ih := length_init (y :: zs)\n    aesop (add norm simp [init, Nat.add_sub_cancel])\n\n/-! ### last -/\n\n@[simp] theorem last_cons {a : α} {l : List α} :\n  ∀ (h : l ≠ nil), last (a :: l) (cons_ne_nil a l) = last l h := by\n  aesop (add 1% cases List)\n\n@[simp] theorem last_append_singleton {a : α} (l : List α) :\n  last (l ++ [a]) (append_ne_nil_of_ne_nil_right l _ (cons_ne_nil a _)) = a := by\n  induction l <;> aesop\n\ntheorem last_append (l₁ l₂ : List α) (h : l₂ ≠ []) :\n  last (l₁ ++ l₂) (append_ne_nil_of_ne_nil_right l₁ l₂ h) = last l₂ h := by\n  induction l₁ <;> aesop\n\ntheorem last_concat {a : α} (l : List α) : last (concat l a) (concat_ne_nil a l) = a := by\n  aesop\n\n@[simp] theorem last_singleton (a : α) : last [a] (cons_ne_nil a []) = a := rfl\n\n@[simp] theorem last_cons_cons (a₁ a₂ : α) (l : List α) :\n  last (a₁::a₂::l) (cons_ne_nil _ _) = last (a₂::l) (cons_ne_nil a₂ l) := rfl\n\ntheorem init_append_last : ∀ {l : List α} (h : l ≠ []), init l ++ [last l h] = l\n  | [] => by aesop\n  | [_] => by aesop\n  | x :: y :: zs => by\n    have ih := init_append_last (l := y :: zs)\n    aesop (add norm simp [init, last])\n\ntheorem last_congr {l₁ l₂ : List α} (h₁ : l₁ ≠ []) (h₂ : l₂ ≠ []) (h₃ : l₁ = l₂) :\n  last l₁ h₁ = last l₂ h₂ := by\n  aesop\n\ntheorem last_mem : ∀ {l : List α} (h : l ≠ []), last l h ∈ l := by\n  intro l; induction l <;> aesop (add norm simp last, 1% cases List)\n\ntheorem last_replicate_succ (a m : Nat) :\n  (replicate m.succ a).last\n    (ne_nil_of_length_eq_succ\n      (show (replicate m.succ a).length = m.succ by rw [length_replicate])) =\n  a := by\n  induction m <;> aesop\n\n/-! ### last' -/\n\n@[simp] theorem last'_is_none :\n  ∀ {l : List α}, (last' l).isNone ↔ l = []\n  | [] => by aesop\n  | [a] => by aesop\n  | a :: a' :: as => by\n    have ih := last'_is_none (l := a' :: as)\n    aesop\n\n@[simp] theorem last'_is_some : ∀ {l : List α}, l.last'.isSome ↔ l ≠ []\n  | [] => by aesop\n  | [a] => by aesop\n  | a :: a' :: as => by\n    have ih := last'_is_some (l := a' :: as)\n    aesop\n\ntheorem mem_last'_eq_last : ∀ {l : List α} {x : α}, x ∈ l.last' → ∃ h, x = last l h\n  | [], _, h => by aesop\n  | [_], _, h => by aesop\n  | a :: a' :: as, x, h => by\n    have ih := mem_last'_eq_last (l := a' :: as) (x := x)\n    aesop (add norm simp last')\n\ntheorem last'_eq_last_of_ne_nil : ∀ {l : List α} (h : l ≠ []), l.last' = some (l.last h)\n  | [], h => by aesop\n  | [a], _ => by aesop\n  | _ :: b :: l, _ => by\n    have ih := last'_eq_last_of_ne_nil (l := b :: l)\n    aesop\n\ntheorem mem_last'_cons {x y : α} : ∀ {l : List α} (_ : x ∈ l.last'), x ∈ (y :: l).last' := by\n  intro l; induction l <;> aesop\n\ntheorem mem_of_mem_last' {l : List α} {a : α} (ha : a ∈ l.last') : a ∈ l := by\n  match l with\n  | [] => aesop\n  | [_] => aesop\n  | x :: y :: zs =>\n    have ih := mem_of_mem_last' (l := y :: zs) (a := a)\n    aesop\n\ntheorem init_append_last' : ∀ {l : List α} {a}, a ∈ l.last' → init l ++ [a] = l\n  | [], _ => by aesop\n  | [_], _ => by aesop\n  | x :: y :: zs, a => by\n    have ih := init_append_last' (l := y :: zs) (a := a)\n    aesop (add norm simp init)\n\ntheorem ilast_eq_last' [Inhabited α] : ∀ l : List α, l.ilast = l.last'.iget\n  | [] => by aesop\n  | [a] => by aesop\n  | [_, _] => by aesop\n  | [_, _, _] => by aesop\n  | (_ :: _ :: c :: l) => by\n    have ih := ilast_eq_last' (c :: l)\n    aesop\n\n@[simp] theorem last'_append_cons : ∀ (l₁ : List α) (a : α) (l₂ : List α),\n  last' (l₁ ++ a :: l₂) = last' (a :: l₂)\n  | [], a, l₂ => by aesop\n  | [_], a, l₂ => by aesop\n  | _ :: c :: l₁, a, l₂ =>\n    have ih := last'_append_cons (c :: l₁) a\n    by aesop\n\n@[simp] theorem last'_cons_cons (x y : α) (l : List α) :\n  last' (x :: y :: l) = last' (y :: l) := rfl\n\ntheorem last'_append_of_ne_nil (l₁ : List α) : ∀ {l₂ : List α} (_ : l₂ ≠ []),\n  last' (l₁ ++ l₂) = last' l₂\n  | [], hl₂ => by aesop\n  | b :: l₂, _ => by aesop\n\ntheorem last'_append {l₁ l₂ : List α} {x : α} (h : x ∈ l₂.last') :\n  x ∈ (l₁ ++ l₂).last' := by\n  aesop (add 1% cases List)\n\n/-! ### head(') and tail -/\n\n-- Note: Lean 3 head is Lean 4 ihead.\n\n-- attribute [-simp] ihead_eq_head'\ntheorem head_eq_head' [Inhabited α] (l : List α) : ihead l = (head' l).iget := by\n  aesop (add 1% cases List)\n\ntheorem mem_of_mem_head' {x : α} : ∀ {l : List α}, x ∈ l.head' → x ∈ l := by\n  intro l; induction l <;> aesop\n\n-- attribute [-simp] head'_cons\n@[simp] theorem X.head'_cons [Inhabited α] (a : α) (l : List α) : head' (a::l) = a := rfl\n\nattribute [-simp] tail_nil\n@[simp] theorem X.tail_nil : tail (@nil α) = [] := rfl\n\nattribute [-simp] tail_cons\n@[simp] theorem X.tail_cons (a : α) (l : List α) : tail (a::l) = l := rfl\n\n-- attribute [-simp] ihead_append\n@[simp] theorem head_append [Inhabited α] (t : List α) {s : List α} (h : s ≠ []) :\n  ihead (s ++ t) = ihead s := by\n  aesop (add 1% cases List)\n\ntheorem head'_append {s t : List α} {x : α} (h : x ∈ s.head') :\n  x ∈ (s ++ t).head' := by\n  aesop (add 1% cases List)\n\ntheorem head'_append_of_ne_nil : ∀ (l₁ : List α) {l₂ : List α} (_ : l₁ ≠ []),\n  head' (l₁ ++ l₂) = head' l₁ := by\n  aesop (add 1% cases List)\n\ntheorem tail_append_singleton_of_ne_nil {a : α} {l : List α} (h : l ≠ nil) :\n  tail (l ++ [a]) = tail l ++ [a] := by\n  induction l <;> aesop\n\ntheorem cons_head'_tail : ∀ {l : List α} {a : α} (_ : a ∈ head' l), a :: tail l = l := by\n  aesop\n\n-- attribute [-simp] ihead_mem_head'\ntheorem head_mem_head' [Inhabited α] : ∀ {l : List α} (_ : l ≠ []), ihead l ∈ head' l := by\n  aesop\n\n-- attribute [-simp] cons_ihead_tail\ntheorem cons_head_tail [Inhabited α] {l : List α} (h : l ≠ []) : (ihead l)::(tail l) = l := by\n  aesop\n\nend List\n", "meta": {"author": "JLimperg", "repo": "aesop", "sha": "c68fb1d5a9172498230d81d95c61f6461bea6722", "save_path": "github-repos/lean/JLimperg-aesop", "path": "github-repos/lean/JLimperg-aesop/aesop-c68fb1d5a9172498230d81d95c61f6461bea6722/tests/run/List.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.47313513181007777}}
{"text": "/-\nCopyright (c) 2021 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport tactic cnf\n\nuniverses u v\n\nvariables {α : Type u} [decidable_eq α]\n\nnamespace list\n\nvariables {β : Type v} [add_monoid β] [partial_order β] \nvariables [contravariant_class β β (+) (<)]\nvariables [covariant_class β β (+) (<)]\nvariables [covariant_class β β (function.swap (+)) (≤)]\nvariables [covariant_class β β (function.swap (+)) (<)]\nvariables [covariant_class β β (+) (≤)]\nvariables [@decidable_rel β (≤)]\n\nlemma sum_map_le_sum_map {l : list α} {f g : α → β} (hfg : ∀ x ∈ l, f x ≤ g x) : (l.map f).sum ≤ (l.map g).sum :=\nbegin\n  induction l with x l ih,\n  { refl },\n  { simp only [sum_cons, map],\n    exact add_le_add (hfg _ (mem_cons_self _ _)) (ih (λ x hx, hfg _ (mem_cons_of_mem _ hx))) }\nend\n\nlemma sum_map_lt_sum_map (l : list α) (f g : α → β) (hfg : ∀ x ∈ l, f x ≤ g x) :\n  (l.map f).sum < (l.map g).sum ↔ ∃ x ∈ l, f x < g x :=\nbegin\n  refine ⟨_, _⟩,\n  { induction l with a as ih,\n    { simp only [lt_self_iff_false, forall_false_left, map_nil] },\n    { by_cases h : f a < g a,\n      { exact λ _, ⟨a, ⟨mem_cons_self _ _, h⟩⟩ },\n      { have hfa : f a = g a := decidable.eq_iff_le_not_lt.2 ⟨hfg _ (mem_cons_self _ _), h⟩,\n        simp only [list.map_cons, list.sum_cons, hfa, add_lt_add_iff_left],\n        intro h',\n        obtain ⟨x, ⟨hx, hx'⟩⟩ := ih (λ x hx, hfg _ (mem_cons_of_mem _ hx)) h',\n        exact ⟨x, ⟨mem_cons_of_mem _ hx, hx'⟩⟩ } } },\n  { rintro ⟨x, ⟨hx, hx'⟩⟩,\n    obtain ⟨s, t, rfl⟩ := list.mem_split hx,\n    simp only [sum_cons, map, sum_append, map_append],\n    refine add_lt_add_of_le_of_lt (sum_map_le_sum_map (λ x hx, hfg _ (mem_append_left _ hx))) _,\n    exact add_lt_add_of_lt_of_le hx' (sum_map_le_sum_map (λ x hx, hfg _ (mem_append_right _ (mem_cons_of_mem _ hx)))) }\nend\n\nend list\n\nnamespace literal\n\nend literal\n\nnamespace clause\n\ndef unit_propagate (l : literal α) (c : clause α) : clause α :=\nc.filter $ (≠) l.inverse\n\ndef unit_propagate' (l : literal α) (c : clause α) : option (clause α) :=\nif l ∈ c then none else some (unit_propagate l c)\n\nlemma unit_propagate'_of_mem {l : literal α} {c : clause α} (h : l ∈ c) : unit_propagate' l c = none :=\nby simp only [unit_propagate', h, if_true]\n\nlemma unit_propagate'_of_not_mem {l : literal α} {c : clause α} (h : l ∉ c) :\n  unit_propagate' l c = some (unit_propagate l c) :=\nby simp only [unit_propagate', h, if_false]\n\nlemma unit_propagate'_eq_some (l : literal α) (c d : clause α) :\n  unit_propagate' l c = some d ↔ l ∉ c ∧ unit_propagate l c = d :=\nby by_cases h : l ∈ c; simp [unit_propagate', h]\n\n@[simp]\ndef satisfied' (ι : interpretation α) : option (clause α) → Prop\n| none := tt\n| (some c) := satisfied ι c\n\n@[simp]\ndef length' : option (clause α) → ℕ\n| none := 0\n| (some c) := c.length\n\nlemma length'_comp_some : (length' : option (clause α) → ℕ) ∘ some = list.length :=\nrfl\n\nlemma length_unit_propagate {l : literal α} {c : clause α} (hl : l.inverse ∈ c) :\n  (unit_propagate l c).length < c.length :=\n(list.length_filter_lt_length_iff_exists _ _).2 ⟨_, hl, λ h, h rfl⟩\n\nlemma length'_unit_propagate'_of_mem {l : literal α} {c : clause α} (hl : l ∈ c) : length' (unit_propagate' l c) < c.length :=\nby simpa only [unit_propagate'_of_mem hl, length'] using list.length_pos_of_mem hl\n\nlemma length'_unit_propagate' {l : literal α} {c : clause α} (hl : l.inverse ∈ c) : length' (unit_propagate' l c) < c.length :=\nbegin\n  by_cases h : l ∈ c,\n  { exact length'_unit_propagate'_of_mem h },\n  { rw [unit_propagate'_of_not_mem h, length'],\n    exact length_unit_propagate hl }\nend\n\nlemma length_unit_propagate_le (l : literal α) (c : clause α) : (unit_propagate l c).length ≤ c.length :=\nlist.length_le_of_sublist $ list.filter_sublist c\n\nlemma length'_unit_propagate'_le (l : literal α) (c : clause α) : length' (unit_propagate' l c) ≤ c.length :=\nbegin\n  by_cases h : l ∈ c,\n  { rw unit_propagate'_of_mem h,\n    exact zero_le _ },\n  { rw unit_propagate'_of_not_mem h,\n    exact length_unit_propagate_le l c }\nend\n\nlemma mem_unit_propagate {l : literal α} {c : clause α} {m : literal α} :\n  m ∈ unit_propagate l c ↔ m ∈ c ∧ l.inverse ≠ m :=\nby rw [unit_propagate, list.mem_filter]\n\nlemma satisfied_unit_propagate (l : literal α) (c : clause α) (ι : interpretation α)\n  (hl : literal.satisfied ι l) : satisfied ι (unit_propagate l c) ↔ satisfied ι c :=\nbegin\n  simp only [satisfied],\n  refine ⟨_, _⟩,\n  { rintro ⟨m, ⟨hmem, hm⟩⟩,\n    rw [mem_unit_propagate] at hmem,\n    exact ⟨m, ⟨hmem.1, hm⟩⟩ },\n  { rintro ⟨m, ⟨hmem, hm⟩⟩,\n    refine ⟨m, ⟨_, hm⟩⟩,\n    { rw mem_unit_propagate,\n      refine ⟨hmem, _⟩,\n      symmetry,\n      apply literal.not_satisfied_and_satisfied_inverse _ _ _ hm hl } }\nend\n\nlemma satisfied'_unit_propagate' (l : literal α) (c : clause α) (ι : interpretation α)\n  (hl : literal.satisfied ι l) : satisfied' ι (unit_propagate' l c) ↔ satisfied ι c :=\nbegin\n  by_cases h : l ∈ c,\n  { rw [unit_propagate'_of_mem h, satisfied', satisfied, coe_sort_tt, true_iff],\n    exact ⟨_, h, hl⟩ },\n  { rw [unit_propagate'_of_not_mem h, satisfied', satisfied_unit_propagate],\n    exact hl }\nend\n\nend clause\n\nnamespace cnf\n\ndef unit_propagate (l : literal α) (c : cnf α) : cnf α :=\nc.filter_map $ clause.unit_propagate' l\n\nlemma unit_propagate_cons (l : literal α) (γ : clause α) (c : cnf α) :\n  unit_propagate l (γ :: c) = if l ∈ γ then unit_propagate l c else (clause.unit_propagate l γ) :: unit_propagate l c :=\nbegin\n  by_cases h : l ∈ γ,\n  { simp only [h, unit_propagate, clause.unit_propagate'_of_mem h, list.filter_map_cons_none, if_true] },\n  { simp only [h, unit_propagate, list.filter_map_cons_some _ _ _ (clause.unit_propagate'_of_not_mem h),\n      eq_self_iff_true, if_false, and_self] }\nend\n\nlemma sizeof_unit_propagate (l : literal α) (c : cnf α) :\n  sizeof (unit_propagate l c) = (c.map (clause.length' ∘ clause.unit_propagate' l)).sum :=\nbegin\n  induction c with γ c ih,\n  { refl },\n  { simp only [sizeof_eq_size, size, unit_propagate_cons, list.sum_cons, function.comp_app, list.map],\n    by_cases h : l ∈ γ,\n    { simp only [h, clause.unit_propagate'_of_mem h, ←ih, sizeof_eq_size, size, if_true, clause.length', zero_add] },\n    { simp only [h, clause.unit_propagate'_of_not_mem h, ←ih, sizeof_eq_size, size, list.sum_cons, clause.length',\n      if_false, list.map] } }\nend\n\nlemma sizeof_cnf (c : cnf α) : sizeof c = (c.map (clause.length' ∘ some)).sum :=\nby rw [clause.length'_comp_some, sizeof_eq_size, size]\n\nlemma sizeof_unit_propagate_of_mem {l : literal α} {γ : clause α} {c : cnf α} (hlγ : l ∈ γ ∨ l.inverse ∈ γ) (hγc: γ ∈ c) :\n  sizeof (unit_propagate l c) < sizeof c :=\nbegin\n  rw [sizeof_unit_propagate, sizeof_cnf, list.sum_map_lt_sum_map],\n  { cases hlγ,\n    { exact ⟨γ, hγc, clause.length'_unit_propagate'_of_mem hlγ⟩ },\n    { exact ⟨γ, hγc, clause.length'_unit_propagate' hlγ⟩ } },\n  { exact λ _ _, clause.length'_unit_propagate'_le _ _ }\nend\n\nlemma mem_unit_propagate (l : literal α) (c : cnf α) (γ : clause α) :\n  γ ∈ unit_propagate l c ↔ ∃ δ, (δ ∈ c ∧ l ∉ δ) ∧ clause.unit_propagate l δ = γ :=\nby simp only [unit_propagate, clause.unit_propagate'_eq_some, and.assoc, list.mem_filter_map]\n\nlemma non_mem_unit_propagate {l : literal α} {c : cnf α} {γ : clause α} (hγ : γ ∈ unit_propagate l c) : l ∉ γ :=\nbegin\n  obtain ⟨δ, ⟨⟨hδc, hlδ⟩, rfl⟩⟩ := (mem_unit_propagate l c γ).1 hγ,\n  exact λ hl, hlδ (clause.mem_unit_propagate.1 hl).1\nend\n\nlemma inverse_non_mem_unit_propagate {l : literal α} {c : cnf α} {γ : clause α} (hγ : γ ∈ unit_propagate l c) :\n  l.inverse ∉ γ :=\nbegin\n  obtain ⟨δ, ⟨⟨hδc, hlδ⟩, rfl⟩⟩ := (mem_unit_propagate l c γ).1 hγ,\n  exact λ hl, (clause.mem_unit_propagate.1 hl).2 rfl\nend\n\nlemma satisfied_unit_propagate (l : literal α) {c : cnf α} {ι : interpretation α}\n  (hl : literal.satisfied ι l) : satisfied ι (unit_propagate l c) ↔ satisfied ι c :=\nbegin\n  simp only [satisfied],\n  refine ⟨λ h γ hγ, _, λ h γ hγ, _⟩,\n  { by_cases hlγ : l ∈ γ,\n    { rw clause.satisfied,\n      exact ⟨l, hlγ, hl⟩ },\n    { rw ←clause.satisfied_unit_propagate l _ _ hl,\n      apply h,\n      rw mem_unit_propagate,\n      exact ⟨γ, ⟨hγ, hlγ⟩, rfl⟩ } },\n  { rw mem_unit_propagate at hγ,\n    rcases hγ with ⟨δ, ⟨hδ, -⟩, rfl⟩, \n    rw clause.satisfied_unit_propagate _ _ _ hl,\n    exact h _ hδ }\nend\n\nlemma satisfiable_of_satisfiable_unit_propagate {l : literal α} {c : cnf α} (h : satisfiable (unit_propagate l c)) :\n  satisfiable c :=\nbegin\n  rcases h with ⟨ι, hι⟩,\n  by_cases h : literal.satisfied ι l,\n  { exact ⟨ι, (satisfied_unit_propagate _ h).1 hι⟩ },\n  { refine ⟨ι.flip l, (satisfied_unit_propagate l _).1 ((satisfied_iff _ ι (λ γ hγ m hm, _)).2 hι)⟩,\n    { simpa only [interpretation.satisfied_flip_eq] using h },\n    { apply interpretation.satisfied_flip_neq;\n      rintro rfl,\n      exacts [non_mem_unit_propagate hγ hm, inverse_non_mem_unit_propagate hγ hm] } }\nend\n\ndef any_literal : Π (c : clause α) (hc : c ≠ []), literal α\n| [] hc := false.elim (hc rfl)\n| (l::lc) hc := l\n\nlemma any_literal_mem : ∀ {c : clause α} (hc : c ≠ []), any_literal c hc ∈ c\n| [] hc := false.elim (hc rfl)\n| (l::lc) hc := list.mem_cons_self _ _\n\ndef dpll : cnf α → bool\n| [] := tt\n| (x::xs) := if h : [] ∈ x::xs then ff else\n    have hx : x ≠ [], from λ hx, h $ or.inl hx.symm,\n    have h1 : sizeof (unit_propagate (any_literal x hx) (x::xs)) < sizeof (x::xs),\n      from sizeof_unit_propagate_of_mem (or.inl (any_literal_mem hx)) (list.mem_cons_self _ _),\n    have h2 : sizeof (unit_propagate (any_literal x hx).inverse (x::xs)) < sizeof (x::xs), by\n    { refine sizeof_unit_propagate_of_mem (or.inr _) (list.mem_cons_self _ _),\n      simpa only [literal.inverse_inverse] using any_literal_mem hx },\n    dpll (unit_propagate (any_literal x hx) (x::xs)) || dpll (unit_propagate (any_literal x hx).inverse (x::xs))\n\ntheorem dpll_correct : ∀ (c : cnf α), dpll c ↔ satisfiable c\n| [] := by simp only [dpll, satisfiable_empty, coe_sort_tt]\n| (x::xs) := if h : [] ∈ x::xs then by simpa [dpll, h] using not_satisfiable_of_empty_mem h else\n    have hx : x ≠ [], from λ hx, h $ or.inl hx.symm,\n    have h1 : sizeof (unit_propagate (any_literal x hx) (x::xs)) < sizeof (x::xs),\n      from sizeof_unit_propagate_of_mem (or.inl (any_literal_mem hx)) (list.mem_cons_self _ _),\n    have h2 : sizeof (unit_propagate (any_literal x hx).inverse (x::xs)) < sizeof (x::xs), by\n    { refine sizeof_unit_propagate_of_mem (or.inr _) (list.mem_cons_self _ _),\n      simpa only [literal.inverse_inverse] using any_literal_mem hx },\n    begin\n      simp only [dpll, h, dpll_correct, bor_coe_iff, bor, dif_neg, not_false_iff, literal.inverse],\n      clear h1 h2,\n      refine ⟨_, _⟩,\n      { rintro (hr|hr),\n        { apply satisfiable_of_satisfiable_unit_propagate hr },\n        { apply satisfiable_of_satisfiable_unit_propagate hr } },\n      { rintro ⟨ι, hι⟩,\n        by_cases hlι : literal.satisfied ι (any_literal x hx),\n        { exact or.inl ⟨ι, (satisfied_unit_propagate _ hlι).2 hι⟩ },\n        { refine or.inr ⟨ι, (satisfied_unit_propagate _ _).2 hι⟩,\n          simpa only [literal.satisfied_inverse] using hlι } }\n    end\n\nsection\nopen literal\n\n#eval dpll [[pos 5], [neg 5, pos 6], [neg 6]]\n\nend\n\nend cnf\n", "meta": {"author": "TwoFX", "repo": "lean-dpll", "sha": "f621689295a9ed883ed9af0b8e817927311ce676", "save_path": "github-repos/lean/TwoFX-lean-dpll", "path": "github-repos/lean/TwoFX-lean-dpll/lean-dpll-f621689295a9ed883ed9af0b8e817927311ce676/src/dpll.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.47313512387414397}}
{"text": "import lambda_calculus.utlc.beta.distance\nimport complexity.basic\n\n/-\n - Define complexity in terms of the number of β reductions\n - Programs and data need to be closed,\n -  additionally data needs to be fully reduced such that equivalence implies equality\n -/\n\nnamespace lambda_calculus\nnamespace utlc\nnamespace β\nnamespace encoding\n\nstructure encoded_program :=\nmk :: (value: utlc) (proof: value.closed)\n\ninductive encoding_type\n| church\n| scott\n| compute\n\nstructure encoded_data (_: encoding_type) :=\nmk :: (value: utlc) (proof: value.closed ∧ β.reduced value)\n\ninstance (et: encoding_type): has_equiv (encoded_data et) := ⟨ λ a b : encoded_data et, a.value = b.value ⟩\n\n@[reducible, simp] def church_data := encoded_data encoding_type.church\n@[reducible, simp] def scott_data := encoded_data encoding_type.scott\n@[reducible, simp] def compute_data := encoded_data encoding_type.compute\n\nlocal attribute [reducible] closed\n\ndef distance_model (et: encoding_type): complexity.model encoded_program (encoded_data et) ℕ :=\n ⟨ λ prog data cost, distance_le cost prog.value data.value,\n   λ prog data, ⟨ prog.value·data.value, by simp [closed, prog.proof, data.proof.left] ⟩,\n   λ prog x y cx cy hx hy, reduced_equiv_inj x.proof.right y.proof.right (equiv_trans (equiv_symm (equiv_of_distance_le hx)) (equiv_of_distance_le hy)),\n   λ prog data c₀ c₁, distance_le_mono' ⟩\n\n@[reducible, simp] def church_model := distance_model encoding_type.church\n@[reducible, simp] def scott_model := distance_model encoding_type.scott\n@[reducible, simp] def compute_model := distance_model encoding_type.compute\n\n@[simp] theorem program_is_closed (a: encoded_program):\n  a.value.closed := a.proof\n\n@[simp] theorem program_is_closed_below (a: encoded_program):\n  ∀ n, a.value.closed_below n :=\n  λ n, closed_below_mono' a.proof (nat.zero_le _)\n\n@[simp] theorem program_ignores_shift (a: encoded_program) (n: ℕ):\n  a.value ↑¹ n = a.value := by rw [shift_of_closed a.proof]\n\n@[simp] theorem program_ignores_substitution (a: encoded_program) (n: ℕ) (g: utlc):\n  has_substitution.substitution a.value n g = a.value := by rw [substitution_of_closed a.proof]\n  \nvariable {et: encoding_type}\n\n@[simp] theorem data_is_closed (a: encoded_data et):\n  a.value.closed := a.proof.left\n\n@[simp] theorem data_is_closed_below (a: encoded_data et):\n  ∀ n, a.value.closed_below n :=\n  λ n, closed_below_mono' a.proof.left (nat.zero_le _)\n\n@[simp] theorem data_is_closed_below' {α: Type}\n  [f: complexity.has_encoding (distance_model et) α]\n  (a: α) : ∀ n, (f.value.encode a).value.closed_below n :=\n  λ n, closed_below_mono' (f.value.encode a).proof.left (nat.zero_le _)\n\n@[simp] theorem data_is_reduced (a: encoded_data et):\n   reduced a.value := a.proof.right\n\n@[simp] theorem data_is_reduced' {α: Type}\n  [f: complexity.has_encoding (distance_model et) α]\n  (a: α) : reduced (f.value.encode a).value :=\n  (f.value.encode a).proof.right\n\n@[simp] theorem value_inj (a b: encoded_data et):\n  a ≈ b ↔ a.value = b.value := by refl\n\n@[simp] theorem data_value_inj {α: Type}\n  [f: complexity.has_encoding (distance_model et) α] (a b: α):\n  (f.value.encode a).value = (f.value.encode b).value ↔ a = b :=\nby rw [← value_inj, complexity.encoding.inj_iff]\n\n@[simp] theorem data_ignores_shift (a: encoded_data et) (n: ℕ):\n  a.value ↑¹ n = a.value := by rw [shift_of_closed a.proof.left]\n\n@[simp] theorem data_ignores_substitution (a: encoded_data et) (n: ℕ) (g: utlc):\n  has_substitution.substitution a.value n g = a.value := by rw [substitution_of_closed a.proof.left]\n\nend encoding\nend β\nend utlc\nend lambda_calculus", "meta": {"author": "calcu16", "repo": "lean_complexity", "sha": "0dcb73bde8d1d4237f782f4790166365ac3209fe", "save_path": "github-repos/lean/calcu16-lean_complexity", "path": "github-repos/lean/calcu16-lean_complexity/lean_complexity-0dcb73bde8d1d4237f782f4790166365ac3209fe/src/lambda_calculus/utlc/beta/encoding/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.47305191373962224}}
{"text": "import algebraic_geometry.AffineScheme\nimport for_mathlib.localized_module\n\nopen category_theory category_theory.limits opposite topological_space\n\nnamespace algebraic_geometry\n\nuniverses v u\n\n\nnamespace structure_sheaf\n\nnoncomputable theory\n\nopen Spec\n\nvariables {R S : CommRing.{u}} (f : R ⟶ S) (p : prime_spectrum R)\n\n/--\nFor an algebra `f : R →+* S`, this is the ring homomorphism `S →+* (f∗ 𝒪ₛ)ₚ` for a `p : Spec R`.\nThis is shown to be the localization at `p` in `is_localized_module_to_pushforward_stalk_alg_hom`.\n-/\ndef to_pushforward_stalk :\n  S ⟶ (Spec.Top_map f _* (structure_sheaf S).1).stalk p :=\nstructure_sheaf.to_open S ⊤ ≫\n  @Top.presheaf.germ _ _ _ _ (Spec.Top_map f _* (structure_sheaf S).1) ⊤ ⟨p, trivial⟩\n\n@[reassoc]\nlemma to_pushforward_stalk_comp :\n  f ≫ structure_sheaf.to_pushforward_stalk f p =\n  structure_sheaf.to_stalk R p ≫\n    (Top.presheaf.stalk_functor _ _).map (Spec.SheafedSpace_map f).c :=\nbegin\n  rw structure_sheaf.to_stalk,\n  erw category.assoc,\n  rw Top.presheaf.stalk_functor_map_germ,\n  exact Spec_Γ_naturality_assoc f _,\nend\n\ninstance : algebra R ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) :=\n(f ≫ structure_sheaf.to_pushforward_stalk f p).to_algebra\n\nlemma algebra_map_pushforward_stalk :\n  algebra_map R ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) =\n    f ≫ structure_sheaf.to_pushforward_stalk f p := rfl\n\ninstance pushforward_stalk_algebra : algebra ((structure_sheaf R).presheaf.stalk p) \n  ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) :=\nbegin\n  apply ring_hom.to_algebra,\n  refine (@Top.presheaf.stalk_functor CommRing _ _ (Scheme.Spec.obj $ op R).carrier p).map _,\n  exact (Scheme.Spec.map f.op).1.c\nend\n\nlemma algebra_map_pushforward_stalk_algebra :\n  algebra_map ((structure_sheaf R).presheaf.stalk p)\n    ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) =\n    (@Top.presheaf.stalk_functor CommRing _ _ (Scheme.Spec.obj $ op R).carrier p).map\n      (Scheme.Spec.map f.op).1.c := rfl\n\ninstance : is_scalar_tower R ((structure_sheaf R).presheaf.stalk p) \n  ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) :=\nbegin\n  apply is_scalar_tower.of_algebra_map_eq',\n  exact to_pushforward_stalk_comp f p,\nend\n\nvariables (R S) [algebra R S]\n\n/--\nThis is the `alg_hom` version of `to_pushforward_stalk`, which is the map `S ⟶ (f∗ 𝒪ₛ)ₚ` for some\nalgebra `R ⟶ S` and some `p : Spec R`.\n-/\n@[simps]\ndef to_pushforward_stalk_alg_hom :\n  S →ₐ[R] (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).stalk p :=\n{ commutes' := λ _, rfl, ..(structure_sheaf.to_pushforward_stalk (algebra_map R S) p) }\n\n.\nlemma is_localized_module_to_pushforward_stalk_alg_hom_aux (y) :\n  ∃ (x : S × p.as_ideal.prime_compl), x.2 • y = to_pushforward_stalk_alg_hom R S p x.1 :=\nbegin\n  obtain ⟨U, hp, s, e⟩ := Top.presheaf.germ_exist _ _ y,\n  obtain ⟨_, ⟨r, rfl⟩, hpr, hrU⟩ := prime_spectrum.is_topological_basis_basic_opens\n    .exists_subset_of_mem_open (show p ∈ U.1, from hp) U.2,\n  change prime_spectrum.basic_open r ≤ U at hrU,\n  replace e := ((Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1)\n    .germ_res_apply (hom_of_le hrU) ⟨p, hpr⟩ _).trans e,\n  set s' := (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).map (hom_of_le hrU).op s\n    with h,\n  rw ← h at e,\n  clear_value s', clear_dependent U,\n  obtain ⟨⟨s, ⟨_, n, rfl⟩⟩, hsn⟩ := @is_localization.surj _ _ _\n    _ _ _ (structure_sheaf.is_localization.to_basic_open S $ algebra_map R S r) s',\n  refine ⟨⟨s, ⟨r, hpr⟩ ^ n⟩, _⟩,\n  rw [submonoid.smul_def, algebra.smul_def, algebra_map_pushforward_stalk, to_pushforward_stalk,\n    comp_apply, comp_apply],\n  iterate 2 { erw ← (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).germ_res_apply\n    (hom_of_le le_top) ⟨p, hpr⟩ },\n  rw [← e, ← map_mul, mul_comm],\n  dsimp only [subtype.coe_mk] at hsn,\n  rw ← map_pow (algebra_map R S) at hsn,\n  congr' 1\nend\n\ninstance is_localized_module_to_pushforward_stalk_alg_hom :\n  is_localized_module p.as_ideal.prime_compl (to_pushforward_stalk_alg_hom R S p).to_linear_map :=\nbegin\n  apply is_localized_module.mk_of_algebra,\n  { intros x hx, rw [algebra_map_pushforward_stalk, to_pushforward_stalk_comp, comp_apply],\n    exact (is_localization.map_units ((structure_sheaf R).presheaf.stalk p) ⟨x, hx⟩).map _ },\n  { apply is_localized_module_to_pushforward_stalk_alg_hom_aux },\n  { intros x hx,\n    rw [to_pushforward_stalk_alg_hom_apply, ring_hom.to_fun_eq_coe,\n      ← (to_pushforward_stalk (algebra_map R S) p).map_zero, to_pushforward_stalk, comp_apply,\n      comp_apply, map_zero] at hx,\n    obtain ⟨U, hpU, i₁, i₂, e⟩ := Top.presheaf.germ_eq _ _ _ _ _ _ hx,\n    obtain ⟨_, ⟨r, rfl⟩, hpr, hrU⟩ := prime_spectrum.is_topological_basis_basic_opens\n      .exists_subset_of_mem_open (show p ∈ U.1, from hpU) U.2,\n    change prime_spectrum.basic_open r ≤ U at hrU,\n    apply_fun (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).map (hom_of_le hrU).op at e,\n    simp only [Top.presheaf.pushforward_obj_map, functor.op_map, map_zero, ← comp_apply,\n      to_open_res] at e,\n    have : to_open S (prime_spectrum.basic_open $ algebra_map R S r) x = 0,\n    { refine eq.trans _ e, refl },\n    have := (@is_localization.mk'_one _ _ _\n      _ _ _ (structure_sheaf.is_localization.to_basic_open S $ algebra_map R S r) x).trans this,\n    obtain ⟨⟨_, n, rfl⟩, e⟩ := (is_localization.mk'_eq_zero_iff _ _).mp this,\n    refine ⟨⟨r, hpr⟩ ^ n, _⟩,\n    rw [submonoid.smul_def, algebra.smul_def, submonoid.coe_pow, subtype.coe_mk, mul_comm, map_pow],\n    exact e },\nend\n.\n\ninstance {R A : Type*} [comm_ring R] [comm_ring A] [algebra R A] (S : submonoid R)\n  [H : is_localization S A] : is_localized_module S (algebra.of_id R A).to_linear_map :=\nbegin\n  apply is_localized_module.mk_of_algebra,\n  { exact λ x hx, H.1 ⟨x, hx⟩ },\n  { simp_rw [submonoid.smul_def, algebra.smul_def, mul_comm], exact H.2 },\n  { intros x hx, rw ← (algebra.of_id R A).map_zero at hx,\n    simpa [submonoid.smul_def, mul_comm] using H.3.mp hx }\nend\n\nlemma _root_.algebraic_geometry.Spec.localized_module_map_iso_stalk_map :\n  (is_localized_module.iso p.as_ideal.prime_compl\n    (to_pushforward_stalk_alg_hom R S p).to_linear_map).to_linear_map.comp\n    ((localized_module.map p.as_ideal.prime_compl\n      (algebra.of_id R S).to_linear_map).restrict_scalars R) =\n  (is_scalar_tower.to_alg_hom _ _ _).to_linear_map.comp\n  (is_localized_module.iso p.as_ideal.prime_compl\n    (algebra.of_id R ((structure_sheaf R).presheaf.stalk p)).to_linear_map).to_linear_map :=\nbegin\n  ext x,\n  induction x using localized_module.induction_on,\n  rw [linear_map.comp_apply, linear_map.restrict_scalars_apply, localized_module.map_mk],\n  refine is_localized_module.mk'_eq_iff.mpr _,\n  rw [submonoid.smul_def, linear_map.comp_apply, ← linear_map.map_smul,\n    linear_equiv.coe_to_linear_map, is_localized_module.iso_mk, ← is_localized_module.mk'_smul,\n    ← submonoid.smul_def, is_localized_module.mk'_cancel],\n  dsimp only [alg_hom.to_linear_map_apply, algebra.of_id_apply, is_scalar_tower.to_alg_hom_apply],\n  rw ← is_scalar_tower.algebra_map_apply,\n  refl,\nend\n\nlemma _root_.algebraic_geometry.Spec.localized_module_map_iso_stalk_map' :\n  ((localized_module.map p.as_ideal.prime_compl\n      (algebra.of_id R S).to_linear_map).restrict_scalars R) =\n  (is_localized_module.iso p.as_ideal.prime_compl\n    (to_pushforward_stalk_alg_hom R S p).to_linear_map).symm.to_linear_map.comp\n  ((is_scalar_tower.to_alg_hom _ _ _).to_linear_map.comp\n  (is_localized_module.iso p.as_ideal.prime_compl\n    (algebra.of_id R ((structure_sheaf R).presheaf.stalk p)).to_linear_map).to_linear_map) :=\nbegin\n  rw ← _root_.algebraic_geometry.Spec.localized_module_map_iso_stalk_map,\n  ext1,\n  exact (linear_equiv.symm_apply_apply _ _).symm\nend\n\nend structure_sheaf\n\nend algebraic_geometry", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/algebraic_geometry/pushforward_stalk.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4730519137396222}}
{"text": "example : ∃ n : Nat, n = n := by\n  refine ⟨?n, ?h⟩\n  case h => exact Eq.refl 3\n\nexample : ∃ n : Nat, n = n := by\n  refine ⟨?n, ?h⟩\n  case h => exact rfl\n  case n => exact 3\n\nexample : ∃ n : Nat, n = n := by\n  refine ⟨?n, by rfl⟩\n  case n => exact 3\n\nexample : ∃ n : Nat, n = n := by\n  refine ⟨?n, ?h⟩\n  case h =>\n    refine rfl\n    case n => exact 3\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/492.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031738057795403, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.472980324341005}}
{"text": "import algebraic_topology.simplex_category\nimport algebraic_topology.simplicial_set\nimport algebraic_topology.simplicial_object\nimport category_theory.arrow\nimport category_theory.discrete_category\nimport category_theory.limits.shapes.terminal\nimport category_theory.limits.shapes.products\nimport category_theory.limits.shapes.equalizers\nimport category_theory.limits.presheaf\nimport category_theory.limits.preserves.shapes.equalizers\n\nimport simplex_category\n\nopen category_theory\n\nnoncomputable theory\n\nopen_locale simplicial\n\nuniverse u\n\nvariable n : ℕ\n\nstructure boundary_part :=\n  mk :: (i j : fin (n + 2)) (h : i ≤ j)\n\nstructure end_part :=\n  mk :: (i : fin (n + 3))\n\ndef boundary_f (p : boundary_part n) := Δ[n]\ndef simplex_f (p : end_part n) := Δ[n+1]\n\ndef boundary_start := ∐ (boundary_f n)\n\ndef simplex_end := ∐ (simplex_f n)\n\ndef morph_boundary_1 : boundary_start n ⟶ simplex_end n :=\n  limits.sigma.desc\n    (λ idx : boundary_part n, yoneda.map (simplex_category.δ idx.i)\n      ≫ (limits.sigma.ι (simplex_f n) ⟨idx.j.succ⟩))\n  \ndef morph_boundary_2 : boundary_start n ⟶ simplex_end n :=\n  limits.sigma.desc\n    (λ idx, yoneda.map (simplex_category.δ idx.j)\n      ≫ (limits.sigma.ι (simplex_f n) ⟨idx.i.cast_succ⟩))\n\ndef boundary_morphism : simplex_end n ⟶ ∂Δ[n + 2] :=\n  limits.sigma.desc (λ b, yoneda_equiv.inv_fun ⟨simplex_category.δ b.i, by {\n    simp only [not_exists, not_forall, coe_coe],\n    use b.i,\n    intros x,\n    exact fin.succ_above_ne _ _,\n  }⟩)\n\nlemma boundary_coeq : morph_boundary_1 n ≫ boundary_morphism n = morph_boundary_2 n ≫ boundary_morphism n :=\nbegin\n  rewrite [boundary_morphism, morph_boundary_1, morph_boundary_2],\n  apply limits.colimit.hom_ext,\n  simp only [limits.cofan.mk_ι_app, limits.colimit.ι_desc, limits.colimit.ι_desc_assoc, coe_coe,\n    equiv.inv_fun_as_coe, category.assoc],\n  intro idx,\n  rw [←equiv.apply_eq_iff_eq yoneda_equiv],\n  rw [←yoneda_equiv_naturality, ←yoneda_equiv_naturality],\n  rw [equiv.apply_symm_apply, equiv.apply_symm_apply],\n  dsimp only [sSet.boundary, simplex_category.hom.to_order_hom, coe_coe],\n  simp only [quiver.hom.unop_op, subtype.coe_mk],\n  cases idx with i j h,\n  simp only [function.embedding.to_fun_eq_coe, rel_embedding.coe_fn_to_embedding],\n  exact simplex_category.δ_comp_δ h,\nend\n\ndef boundary_fork := limits.cofork.of_π (boundary_morphism n) (boundary_coeq n)\n\ndef boundary_hole {m n} (f : [m] ⟶ [n + 1]) (h : ¬ function.surjective f.to_order_hom)\n  : ∃ i, i ∉ set.range f.to_order_hom :=\nbegin\n  simp only [not_forall, not_exists] at h,\n  cases h,\n  use h_w,\n  simpa only [set.mem_range, not_exists],\nend\n\n-- def boundary_colim : limits.is_colimit (boundary_fork n) :=\n-- begin\n--   apply limits.cofork.is_colimit.mk, swap 3,\n--   focus {\n--     intro s,\n--     dsimp [boundary_fork],\n--     refine nat_trans.mk _ _,\n--     focus {\n--       intros X f,\n--       let m := X.unop.len,\n--       have hX : X = opposite.op [m] := by simp only [simplex_category.mk_len, opposite.op_unop],\n--       clear_value m,\n--       subst hX,\n--       cases f,\n--       apply yoneda_equiv.to_fun,\n--       dsimp [sSet.standard_simplex] at f_val,\n--       refine _ ≫ _,\n--       exact Δ[n + 1],\n--       apply yoneda_equiv.inv_fun,\n--       exact nonsurj_fun f_val f_property,\n--       refine _ ≫ s.π,\n--       exact limits.sigma.ι (simplex_f n) ⟨nonsurj_index f_val f_property⟩,\n--     },\n--     focus {\n--       intros X Y f,\n--       have sn := s.π.naturality f,\n--       let m := X.unop.len, let k := Y.unop.len,\n--       have hX : X = opposite.op [m] := by simp only [simplex_category.mk_len, opposite.op_unop],\n--       have hY : Y = opposite.op [k] := by simp only [simplex_category.mk_len, opposite.op_unop],\n--       clear_value m k,\n--       subst hX, subst hY,\n--       ext1,\n--       dsimp [sSet.boundary, sSet.standard_simplex, simplex_end] at *,\n--       cases x,\n--       simp only [order_hom.comp_id, simplex_category.hom.mk_to_order_hom],\n--       have sn' : ∀ x, ((∐ simplex_f n).map f ≫ s.π.app (opposite.op [k])) x\n--         = (s.π.app (opposite.op [m]) ≫ s.X.map f) x := by { intro, rw [sn], },\n--       simp only [types_comp_apply] at sn',\n--       rw ←sn',\n--       have cf := limits.cofork.condition s, \n--       dsimp [morph_boundary_1, morph_boundary_2] at cf,\n--     },\n\n\n--     --have df := nonsurj_decomposition f_val f_property,\n--   },\n-- end\n", "meta": {"author": "technosentience", "repo": "simplicial-sets", "sha": "5ceb2760ca45ad9ec419fb6f2ca8d96648c18c76", "save_path": "github-repos/lean/technosentience-simplicial-sets", "path": "github-repos/lean/technosentience-simplicial-sets/simplicial-sets-5ceb2760ca45ad9ec419fb6f2ca8d96648c18c76/src/alt_boundary.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342623, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.47298031324322565}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.dold_kan.decomposition\n\n/-!\n\n# Behaviour of P_infty with respect to degeneracies\n\nFor any `X : simplicial_object C` where `C` is an abelian category,\nthe projector `P_infty : K[X] ⟶ K[X]` is supposed to be the projection\non the normalized subcomplex, parallel to the degenerate subcomplex, i.e.\nthe subcomplex generated by the images of all `X.σ i`.\n\nIn this file, we obtain `degeneracy_comp_P_infty` which states that\nif `X : simplicial_object C` with `C` a preadditive category,\n`θ : [n] ⟶ Δ'` is a non injective map in `simplex_category`, then\n`X.map θ.op ≫ P_infty.f n = 0`. It follows from the more precise\nstatement vanishing statement `σ_comp_P_eq_zero` for the `P q`.\n\n-/\n\nopen category_theory category_theory.category category_theory.limits\n  category_theory.preadditive opposite\nopen_locale simplicial dold_kan\n\nnamespace algebraic_topology\n\nnamespace dold_kan\n\nvariables {C : Type*} [category C] [preadditive C]\n\nlemma higher_faces_vanish.comp_σ {Y : C} {X : simplicial_object C} {n b q : ℕ} {φ : Y ⟶ X _[n+1]}\n  (v : higher_faces_vanish q φ) (hnbq : n + 1 = b + q) :\n    higher_faces_vanish q (φ ≫ X.σ ⟨b,\n    by simpa only [hnbq, nat.lt_succ_iff, le_add_iff_nonneg_right] using zero_le q⟩) :=\nλ j hj, begin\n  rw [assoc, simplicial_object.δ_comp_σ_of_gt', fin.pred_succ,\n    v.comp_δ_eq_zero_assoc _ _ hj, zero_comp],\n  { intro hj',\n    simpa only [hj', hnbq, fin.coe_zero, zero_add, add_comm b, add_assoc, false_and,\n      add_le_iff_nonpos_right, le_zero_iff, add_eq_zero_iff, nat.one_ne_zero] using hj, },\n  { simp only [fin.lt_iff_coe_lt_coe, nat.lt_iff_add_one_le,\n      fin.succ_mk, fin.coe_mk, fin.coe_succ, add_le_add_iff_right],\n    linarith, },\nend\n\nlemma σ_comp_P_eq_zero (X : simplicial_object C)\n  {n q : ℕ} (i : fin (n + 1)) (hi : n + 1 ≤ i + q) : (X.σ i) ≫ (P q).f (n + 1) = 0 :=\nbegin\n  induction q with q hq generalizing i hi,\n  { exfalso,\n    have h := fin.is_lt i,\n    linarith, },\n  { by_cases n+1 ≤ (i : ℕ) + q,\n    { unfold P,\n      simp only [homological_complex.comp_f, ← assoc],\n      rw [hq i h, zero_comp], },\n    { have hi' : n = (i : ℕ) + q,\n      { cases le_iff_exists_add.mp hi with j hj,\n        rw [← nat.lt_succ_iff, nat.succ_eq_add_one, add_assoc, hj, not_lt,\n          add_le_iff_nonpos_right, nonpos_iff_eq_zero] at h,\n        rw [← add_left_inj 1, add_assoc, hj, self_eq_add_right, h], },\n      cases n,\n      { fin_cases i,\n        rw [show q = 0, by linarith],\n        unfold P,\n        simp only [id_comp, homological_complex.add_f_apply, comp_add, homological_complex.id_f,\n          Hσ, homotopy.null_homotopic_map'_f (c_mk 2 1 rfl) (c_mk 1 0 rfl),\n          alternating_face_map_complex.obj_d_eq],\n        erw [hσ'_eq' (zero_add 0).symm, hσ'_eq' (add_zero 1).symm, comp_id,\n          fin.sum_univ_two, fin.sum_univ_succ, fin.sum_univ_two],\n        simp only [pow_zero, pow_one, pow_two, fin.coe_zero, fin.coe_one, fin.coe_two,\n          one_zsmul, neg_zsmul, fin.mk_zero, fin.mk_one, fin.coe_succ, pow_add, one_mul,\n          neg_mul, neg_neg, fin.succ_zero_eq_one, fin.succ_one_eq_two, comp_neg, neg_comp,\n          add_comp, comp_add],\n        erw [simplicial_object.δ_comp_σ_self, simplicial_object.δ_comp_σ_self_assoc,\n          simplicial_object.δ_comp_σ_succ, comp_id, simplicial_object.δ_comp_σ_of_le X\n            (show (0 : fin(2)) ≤ fin.cast_succ 0, by rw fin.cast_succ_zero),\n          simplicial_object.δ_comp_σ_self_assoc, simplicial_object.δ_comp_σ_succ_assoc],\n        abel, },\n      { rw [← id_comp (X.σ i), ← (P_add_Q_f q n.succ : _ = 𝟙 (X.obj _)), add_comp, add_comp],\n        have v : higher_faces_vanish q ((P q).f n.succ ≫ X.σ i) :=\n          (higher_faces_vanish.of_P q n).comp_σ hi',\n        unfold P,\n        erw [← assoc, v.comp_P_eq_self, homological_complex.add_f_apply,\n          preadditive.comp_add, comp_id, v.comp_Hσ_eq hi', assoc,\n          simplicial_object.δ_comp_σ_succ'_assoc, fin.eta,\n          decomposition_Q n q, sum_comp, sum_comp, finset.sum_eq_zero, add_zero,\n          add_neg_eq_zero], swap,\n        { ext, simp only [fin.coe_mk, fin.coe_succ], },\n        { intros j hj,\n          simp only [true_and, finset.mem_univ, finset.mem_filter] at hj,\n          simp only [nat.succ_eq_add_one] at hi',\n          obtain ⟨k, hk⟩ := nat.le.dest (nat.lt_succ_iff.mp (fin.is_lt j)),\n          rw add_comm at hk,\n          have hi'' : i = fin.cast_succ ⟨i, by linarith⟩ :=\n            by { ext, simp only [fin.cast_succ_mk, fin.eta], },\n          have eq := hq j.rev.succ begin\n            simp only [← hk, fin.rev_eq j hk.symm, nat.succ_eq_add_one, fin.succ_mk, fin.coe_mk],\n            linarith,\n          end,\n          rw [homological_complex.comp_f, assoc, assoc, assoc, hi'',\n            simplicial_object.σ_comp_σ_assoc, reassoc_of eq, zero_comp, comp_zero,\n            comp_zero, comp_zero],\n          simp only [fin.rev_eq j hk.symm, fin.le_iff_coe_le_coe, fin.coe_mk],\n          linarith, }, }, }, }\nend\n\n@[simp, reassoc]\nlemma σ_comp_P_infty (X : simplicial_object C) {n : ℕ} (i : fin (n+1)) :\n  (X.σ i) ≫ P_infty.f (n+1) = 0 :=\nbegin\n  rw [P_infty_f, σ_comp_P_eq_zero X i],\n  simp only [le_add_iff_nonneg_left, zero_le],\nend\n\n@[reassoc]\nlemma degeneracy_comp_P_infty (X : simplicial_object C)\n  (n : ℕ) {Δ' : simplex_category} (θ : [n] ⟶ Δ') (hθ : ¬mono θ) :\n  X.map θ.op ≫ P_infty.f n = 0 :=\nbegin\n  rw simplex_category.mono_iff_injective at hθ,\n  cases n,\n  { exfalso,\n    apply hθ,\n    intros x y h,\n    fin_cases x,\n    fin_cases y, },\n  { obtain ⟨i, α, h⟩ := simplex_category.eq_σ_comp_of_not_injective θ hθ,\n    rw [h, op_comp, X.map_comp, assoc, (show X.map (simplex_category.σ i).op = X.σ i, by refl),\n      σ_comp_P_infty, comp_zero], },\nend\n\nend dold_kan\n\nend algebraic_topology\n", "meta": {"author": "joelriou", "repo": "dold-kan", "sha": "a083fe264275774ac49ac520caf25f2ee29debb1", "save_path": "github-repos/lean/joelriou-dold-kan", "path": "github-repos/lean/joelriou-dold-kan/dold-kan-a083fe264275774ac49ac520caf25f2ee29debb1/src/for_mathlib/dold_kan/degeneracies.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.4729382429005075}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport topology.opens\nimport ring_theory.ideal.prod\nimport ring_theory.ideal.over\nimport linear_algebra.finsupp\nimport algebra.punit_instances\nimport ring_theory.nilpotent\nimport topology.sober\n\n/-!\n# Prime spectrum of a commutative ring\n\nThe prime spectrum of a commutative ring is the type of all prime ideals.\nIt is naturally endowed with a topology: the Zariski topology.\n\n(It is also naturally endowed with a sheaf of rings,\nwhich is constructed in `algebraic_geometry.structure_sheaf`.)\n\n## Main definitions\n\n* `prime_spectrum R`: The prime spectrum of a commutative ring `R`,\n  i.e., the set of all prime ideals of `R`.\n* `zero_locus s`: The zero locus of a subset `s` of `R`\n  is the subset of `prime_spectrum R` consisting of all prime ideals that contain `s`.\n* `vanishing_ideal t`: The vanishing ideal of a subset `t` of `prime_spectrum R`\n  is the intersection of points in `t` (viewed as prime ideals).\n\n## Conventions\n\nWe denote subsets of rings with `s`, `s'`, etc...\nwhereas we denote subsets of prime spectra with `t`, `t'`, etc...\n\n## Inspiration/contributors\n\nThe contents of this file draw inspiration from\n<https://github.com/ramonfmir/lean-scheme>\nwhich has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,\nand Chris Hughes (on an earlier repository).\n\n-/\n\nnoncomputable theory\nopen_locale classical\n\nuniverses u v\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The prime spectrum of a commutative ring `R`\nis the type of all prime ideals of `R`.\n\nIt is naturally endowed with a topology (the Zariski topology),\nand a sheaf of commutative rings (see `algebraic_geometry.structure_sheaf`).\nIt is a fundamental building block in algebraic geometry. -/\n@[nolint has_inhabited_instance]\ndef prime_spectrum := {I : ideal R // I.is_prime}\n\nvariable {R}\n\nnamespace prime_spectrum\n\n/-- A method to view a point in the prime spectrum of a commutative ring\nas an ideal of that ring. -/\nabbreviation as_ideal (x : prime_spectrum R) : ideal R := x.val\n\ninstance is_prime (x : prime_spectrum R) :\n  x.as_ideal.is_prime := x.2\n\n/--\nThe prime spectrum of the zero ring is empty.\n-/\nlemma punit (x : prime_spectrum punit) : false :=\nx.1.ne_top_iff_one.1 x.2.1 $ subsingleton.elim (0 : punit) 1 ▸ x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of\n    `R` and the prime spectrum of `S`. -/\nnoncomputable def prime_spectrum_prod :\n  prime_spectrum (R × S) ≃ prime_spectrum R ⊕ prime_spectrum S :=\nideal.prime_ideals_equiv R S\n\nvariables {R S}\n\n@[simp] lemma prime_spectrum_prod_symm_inl_as_ideal (x : prime_spectrum R) :\n  ((prime_spectrum_prod R S).symm (sum.inl x)).as_ideal = ideal.prod x.as_ideal ⊤ :=\nby { cases x, refl }\n@[simp] lemma prime_spectrum_prod_symm_inr_as_ideal (x : prime_spectrum S) :\n  ((prime_spectrum_prod R S).symm (sum.inr x)).as_ideal = ideal.prod ⊤ x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y ↔ x.as_ideal = y.as_ideal :=\nsubtype.ext_iff_val\n\n/-- The zero locus of a set `s` of elements of a commutative ring `R`\nis the set of all prime ideals of the ring that contain the set `s`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `zero_locus s` is exactly the subset of `prime_spectrum R`\nwhere all \"functions\" in `s` vanish simultaneously.\n-/\ndef zero_locus (s : set R) : set (prime_spectrum R) :=\n{x | s ⊆ x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x ∈ zero_locus s ↔ s ⊆ x.as_ideal := iff.rfl\n\n@[simp] lemma zero_locus_span (s : set R) :\n  zero_locus (ideal.span s : set R) = zero_locus s :=\nby { ext x, exact (submodule.gi R R).gc s x.as_ideal }\n\n/-- The vanishing ideal of a set `t` of points\nof the prime spectrum of a commutative ring `R`\nis the intersection of all the prime ideals in the set `t`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `vanishing_ideal t` is exactly the ideal of `R`\nconsisting of all \"functions\" that vanish on all of `t`.\n-/\ndef vanishing_ideal (t : set (prime_spectrum R)) : ideal R :=\n⨅ (x : prime_spectrum R) (h : x ∈ t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal} :=\nbegin\n  ext f,\n  rw [vanishing_ideal, set_like.mem_coe, submodule.mem_infi],\n  apply forall_congr, intro x,\n  rw [submodule.mem_infi],\nend\n\nlemma mem_vanishing_ideal (t : set (prime_spectrum R)) (f : R) :\n  f ∈ vanishing_ideal t ↔ ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal :=\nby rw [← set_like.mem_coe, coe_vanishing_ideal, set.mem_set_of_eq]\n\n@[simp] lemma vanishing_ideal_singleton (x : prime_spectrum R) :\n  vanishing_ideal ({x} : set (prime_spectrum R)) = x.as_ideal :=\nby simp [vanishing_ideal]\n\nlemma subset_zero_locus_iff_le_vanishing_ideal (t : set (prime_spectrum R)) (I : ideal R) :\n  t ⊆ zero_locus I ↔ I ≤ vanishing_ideal t :=\n⟨λ h f k, (mem_vanishing_ideal _ _).mpr (λ x j, (mem_zero_locus _ _).mpr (h j) k), λ h,\n  λ x j, (mem_zero_locus _ _).mpr (le_trans h (λ f h, ((mem_vanishing_ideal _ _).mp h) x j))⟩\n\nsection gc\nvariable (R)\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc : @galois_connection\n  (ideal R) (order_dual (set (prime_spectrum R))) _ _\n  (λ I, zero_locus I) (λ t, vanishing_ideal t) :=\nλ I t, subset_zero_locus_iff_le_vanishing_ideal t I\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc_set : @galois_connection\n  (set R) (order_dual (set (prime_spectrum R))) _ _\n  (λ s, zero_locus s) (λ t, vanishing_ideal t) :=\nhave ideal_gc : galois_connection (ideal.span) coe := (submodule.gi R R).gc,\nby simpa [zero_locus_span, function.comp] using ideal_gc.compose (gc R)\n\nlemma subset_zero_locus_iff_subset_vanishing_ideal (t : set (prime_spectrum R)) (s : set R) :\n  t ⊆ zero_locus s ↔ s ⊆ vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s ⊆ vanishing_ideal (zero_locus s) :=\n(gc_set R).le_u_l s\n\nlemma le_vanishing_ideal_zero_locus (I : ideal R) :\n  I ≤ vanishing_ideal (zero_locus I) :=\n(gc R).le_u_l I\n\n@[simp] lemma vanishing_ideal_zero_locus_eq_radical (I : ideal R) :\n  vanishing_ideal (zero_locus (I : set R)) = I.radical := ideal.ext $ λ f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact ⟨(λ h x hx, h ⟨x, hx.2⟩ hx.1), (λ h x hx, h x.1 ⟨hx, x.2⟩)⟩\nend\n\n@[simp] lemma zero_locus_radical (I : ideal R) : zero_locus (I.radical : set R) = zero_locus I :=\nvanishing_ideal_zero_locus_eq_radical I ▸ (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t ⊆ zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s ⊆ t) : zero_locus t ⊆ zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s ≤ t) :\n  zero_locus (t : set R) ⊆ zero_locus (s : set R) :=\n(gc R).monotone_l h\n\nlemma vanishing_ideal_anti_mono {s t : set (prime_spectrum R)} (h : s ⊆ t) :\n  vanishing_ideal t ≤ vanishing_ideal s :=\n(gc R).monotone_u h\n\nlemma zero_locus_subset_zero_locus_iff (I J : ideal R) :\n  zero_locus (I : set R) ⊆ zero_locus (J : set R) ↔ J ≤ I.radical :=\n⟨λ h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I ▸\n  vanishing_ideal_zero_locus_eq_radical J ▸ vanishing_ideal_anti_mono h),\nλ h, zero_locus_radical I ▸ zero_locus_anti_mono_ideal h⟩\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) ⊆ zero_locus {g} ↔ g ∈ (ideal.span ({f} : set R)).radical :=\nby rw [← zero_locus_span {f}, ← zero_locus_span {g}, zero_locus_subset_zero_locus_iff,\n    ideal.span_le, set.singleton_subset_iff, set_like.mem_coe]\n\nlemma zero_locus_bot :\n  zero_locus ((⊥ : ideal R) : set R) = set.univ :=\n(gc R).l_bot\n\n@[simp] lemma zero_locus_singleton_zero :\n  zero_locus ({0} : set R) = set.univ :=\nzero_locus_bot\n\n@[simp] lemma zero_locus_empty :\n  zero_locus (∅ : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (∅ : set (prime_spectrum R)) = ⊤ :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) ∈ s) :\n  zero_locus s = ∅ :=\nbegin\n  rw set.eq_empty_iff_forall_not_mem,\n  intros x hx,\n  rw mem_zero_locus at hx,\n  have x_prime : x.as_ideal.is_prime := by apply_instance,\n  have eq_top : x.as_ideal = ⊤, { rw ideal.eq_top_iff_one, exact hx h },\n  apply x_prime.ne_top eq_top,\nend\n\n@[simp] lemma zero_locus_singleton_one :\n  zero_locus ({1} : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_singleton (1 : R))\n\nlemma zero_locus_empty_iff_eq_top {I : ideal R} :\n  zero_locus (I : set R) = ∅ ↔ I = ⊤ :=\nbegin\n  split,\n  { contrapose!,\n    intro h,\n    apply set.ne_empty_iff_nonempty.mpr,\n    rcases ideal.exists_le_maximal I h with ⟨M, hM, hIM⟩,\n    exact ⟨⟨M, hM.is_prime⟩, hIM⟩ },\n  { rintro rfl, apply zero_locus_empty_of_one_mem, trivial }\nend\n\n@[simp] lemma zero_locus_univ :\n  zero_locus (set.univ : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I ⊔ J : ideal R) : set R) = zero_locus I ∩ zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s ∪ s') = zero_locus s ∩ zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t ∪ t') = vanishing_ideal t ⊓ vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {ι : Sort*} (I : ι → ideal R) :\n  zero_locus ((⨆ i, I i : ideal R) : set R) = (⋂ i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {ι : Sort*} (s : ι → set R) :\n  zero_locus (⋃ i, s i) = (⋂ i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (⋃ s' ∈ s, s' : set R) = ⋂ s' ∈ s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {ι : Sort*} (t : ι → set (prime_spectrum R)) :\n  vanishing_ideal (⋃ i, t i) = (⨅ i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I ⊓ J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s ∪ zero_locus s' = zero_locus ((ideal.span s) ⊓ (ideal.span s') : ideal R) :=\nby { rw zero_locus_inf, simp }\n\nlemma zero_locus_mul (I J : ideal R) :\n  zero_locus ((I * J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.mul_le\n\nlemma zero_locus_singleton_mul (f g : R) :\n  zero_locus ({f * g} : set R) = zero_locus {f} ∪ zero_locus {g} :=\nset.ext $ λ x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : ℕ} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) ▸ (I.radical_pow n hn).symm ▸ zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : ℕ) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ λ x, by simpa using x.2.pow_mem_iff_mem n hn\n\nlemma sup_vanishing_ideal_le (t t' : set (prime_spectrum R)) :\n  vanishing_ideal t ⊔ vanishing_ideal t' ≤ vanishing_ideal (t ∩ t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro ⟨f, hf, g, hg, rfl⟩ x ⟨hxt, hxt'⟩,\n  rw mem_vanishing_ideal at hf hg,\n  apply submodule.add_mem; solve_by_elim\nend\n\nlemma mem_compl_zero_locus_iff_not_mem {f : R} {I : prime_spectrum R} :\n  I ∈ (zero_locus {f} : set (prime_spectrum R))ᶜ ↔ f ∉ I.as_ideal :=\nby rw [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]; refl\n\n/-- The Zariski topology on the prime spectrum of a commutative ring\nis defined via the closed sets of the topology:\nthey are exactly those sets that are the zero locus of a subset of the ring. -/\ninstance zariski_topology : topological_space (prime_spectrum R) :=\ntopological_space.of_closed (set.range prime_spectrum.zero_locus)\n  (⟨set.univ, by simp⟩)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs → set R := λ i, classical.some (h i.2),\n    have hf : ∀ i : Zs, ↑i = zero_locus (f i) := λ i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact ⟨_, zero_locus_Union _⟩\n  end\n  (by { rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩, exact ⟨_, (union_zero_locus s t).symm⟩ })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U ↔ ∃ s, Uᶜ = zero_locus s :=\nby simp only [@eq_comm _ Uᶜ]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ s, Z = zero_locus s :=\nby rw [← is_open_compl_iff, is_open_iff, compl_compl]\n\nlemma is_closed_iff_zero_locus_ideal (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ (s : ideal R), Z = zero_locus s :=\n(is_closed_iff_zero_locus _).trans\n  ⟨λ x, ⟨_, x.some_spec.trans (zero_locus_span _).symm⟩, λ x, ⟨_, x.some_spec⟩⟩\n\nlemma is_closed_iff_zero_locus_radical_ideal (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ (s : ideal R), s.radical = s ∧ Z = zero_locus s :=\n(is_closed_iff_zero_locus_ideal _).trans\n  ⟨λ x, ⟨_, ideal.radical_idem _, x.some_spec.trans (zero_locus_radical _).symm⟩,\n    λ x, ⟨_, x.some_spec.2⟩⟩\n\nlemma is_closed_zero_locus (s : set R) :\n  is_closed (zero_locus s) :=\nby { rw [is_closed_iff_zero_locus], exact ⟨s, rfl⟩ }\n\nlemma is_closed_singleton_iff_is_maximal (x : prime_spectrum R) :\n  is_closed ({x} : set (prime_spectrum R)) ↔ x.as_ideal.is_maximal :=\nbegin\n  refine (is_closed_iff_zero_locus _).trans ⟨λ h, _, λ h, _⟩,\n  { obtain ⟨s, hs⟩ := h,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem] at hs,\n    refine ⟨⟨x.2.1, λ I hI, not_not.1 (mt (ideal.exists_le_maximal I) $\n      not_exists.2 (λ J, not_and.2 $ λ hJ hIJ,_))⟩⟩,\n    exact ne_of_lt (lt_of_lt_of_le hI hIJ) (symm $ congr_arg prime_spectrum.as_ideal\n      (hs.2 ⟨J, hJ.is_prime⟩ (λ r hr, hIJ (le_of_lt hI $ hs.1 hr)))) },\n  { refine ⟨x.as_ideal.1, _⟩,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem],\n    refine ⟨λ _ h, h, λ y hy, prime_spectrum.ext.2 (h.eq_of_le y.2.ne_top hy).symm⟩ }\nend\n\nlemma zero_locus_vanishing_ideal_eq_closure (t : set (prime_spectrum R)) :\n  zero_locus (vanishing_ideal t : set R) = closure t :=\nbegin\n  apply set.subset.antisymm,\n  { rintro x hx t' ⟨ht', ht⟩,\n    obtain ⟨fs, rfl⟩ : ∃ s, t' = zero_locus s,\n    by rwa [is_closed_iff_zero_locus] at ht',\n    rw [subset_zero_locus_iff_subset_vanishing_ideal] at ht,\n    exact set.subset.trans ht hx },\n  { rw (is_closed_zero_locus _).closure_subset_iff,\n    exact subset_zero_locus_vanishing_ideal t }\nend\n\nlemma vanishing_ideal_closure (t : set (prime_spectrum R)) :\n  vanishing_ideal (closure t) = vanishing_ideal t :=\nzero_locus_vanishing_ideal_eq_closure t ▸ (gc R).u_l_u_eq_u t\n\nlemma t1_space_iff_is_field [is_domain R] :\n  t1_space (prime_spectrum R) ↔ is_field R :=\nbegin\n  refine ⟨_, λ h, _⟩,\n  { introI h,\n    have hbot : ideal.is_prime (⊥ : ideal R) := ideal.bot_prime,\n    exact not_not.1 (mt (ring.ne_bot_of_is_maximal_of_not_is_field $\n      (is_closed_singleton_iff_is_maximal _).1 (t1_space.t1 ⟨⊥, hbot⟩)) (not_not.2 rfl)) },\n  { refine ⟨λ x, (is_closed_singleton_iff_is_maximal x).2 _⟩,\n    by_cases hx : x.as_ideal = ⊥,\n    { exact hx.symm ▸ @ideal.bot_is_maximal R (@field.to_division_ring _ $ is_field.to_field R h) },\n    { exact absurd h (ring.not_is_field_iff_exists_prime.2 ⟨x.as_ideal, ⟨hx, x.2⟩⟩) } }\nend\n\nlocal notation `Z(` a `)` := zero_locus (a : set R)\n\n\n\nlemma is_irreducible_zero_locus_iff (I : ideal R) :\n  is_irreducible (zero_locus (I : set R)) ↔ I.radical.is_prime :=\n(zero_locus_radical I) ▸ is_irreducible_zero_locus_iff_of_radical _ I.radical_idem\n\ninstance [is_domain R] : irreducible_space (prime_spectrum R) :=\nbegin\n  rw [irreducible_space_def, set.top_eq_univ, ← zero_locus_bot, is_irreducible_zero_locus_iff],\n  simpa using ideal.bot_prime\nend\n\ninstance : quasi_sober (prime_spectrum R) :=\nbegin\n  constructor,\n  intros S h₁ h₂,\n  rw [← h₂.closure_eq, ← zero_locus_vanishing_ideal_eq_closure,\n    is_irreducible_zero_locus_iff] at h₁,\n  use ⟨_, h₁⟩,\n  obtain ⟨s, hs, rfl⟩ := (is_closed_iff_zero_locus_radical_ideal _).mp h₂,\n  rw is_generic_point_iff_forall_closed h₂,\n  intros Z hZ hxZ,\n  obtain ⟨t, rfl⟩ := (is_closed_iff_zero_locus_ideal _).mp hZ,\n  exact zero_locus_anti_mono (by simpa [hs] using hxZ),\n  simp [hs]\nend\n\nsection comap\nvariables {S : Type v} [comm_ring S] {S' : Type*} [comm_ring S']\n\n\nlemma preimage_comap_zero_locus_aux (f : R →+* S) (s : set R) :\n  (λ y, ⟨ideal.comap f y.as_ideal, infer_instance⟩ :\n    prime_spectrum S → prime_spectrum R) ⁻¹' (zero_locus s) = zero_locus (f '' s) :=\nbegin\n  ext x,\n  simp only [mem_zero_locus, set.image_subset_iff],\n  refl\nend\n\n/-- The function between prime spectra of commutative rings induced by a ring homomorphism.\nThis function is continuous. -/\ndef comap (f : R →+* S) : C(prime_spectrum S, prime_spectrum R) :=\n{ to_fun := λ y, ⟨ideal.comap f y.as_ideal, infer_instance⟩,\n  continuous_to_fun :=\n    begin\n      simp only [continuous_iff_is_closed, is_closed_iff_zero_locus],\n      rintro _ ⟨s, rfl⟩,\n      exact ⟨_, preimage_comap_zero_locus_aux f s⟩\n    end }\n\nvariables (f : R →+* S)\n\n@[simp] lemma comap_as_ideal (y : prime_spectrum S) :\n  (comap f y).as_ideal = ideal.comap f y.as_ideal :=\nrfl\n\n@[simp] lemma comap_id : comap (ring_hom.id R) = continuous_map.id := by { ext, refl }\n\n@[simp] lemma comap_comp (f : R →+* S) (g : S →+* S') :\n  comap (g.comp f) = (comap f).comp (comap g) :=\nrfl\n\nlemma comap_comp_apply (f : R →+* S) (g : S →+* S') (x : prime_spectrum S') :\n  prime_spectrum.comap (g.comp f) x = (prime_spectrum.comap f) (prime_spectrum.comap g x) :=\nrfl\n\n@[simp] lemma preimage_comap_zero_locus (s : set R) :\n  (comap f) ⁻¹' (zero_locus s) = zero_locus (f '' s) :=\npreimage_comap_zero_locus_aux f s\n\nlemma comap_injective_of_surjective (f : R →+* S) (hf : function.surjective f) :\n  function.injective (comap f) :=\nλ x y h, prime_spectrum.ext.2 (ideal.comap_injective_of_surjective f hf\n  (congr_arg prime_spectrum.as_ideal h : (comap f x).as_ideal = (comap f y).as_ideal))\n\nlemma comap_singleton_is_closed_of_surjective (f : R →+* S) (hf : function.surjective f)\n  (x : prime_spectrum S) (hx : is_closed ({x} : set (prime_spectrum S))) :\n  is_closed ({comap f x} : set (prime_spectrum R)) :=\nbegin\n  haveI : x.as_ideal.is_maximal := (is_closed_singleton_iff_is_maximal x).1 hx,\n  exact (is_closed_singleton_iff_is_maximal _).2 (ideal.comap_is_maximal_of_surjective f hf)\nend\n\nlemma comap_singleton_is_closed_of_is_integral (f : R →+* S) (hf : f.is_integral)\n  (x : prime_spectrum S) (hx : is_closed ({x} : set (prime_spectrum S))) :\n  is_closed ({comap f x} : set (prime_spectrum R)) :=\n(is_closed_singleton_iff_is_maximal _).2 (ideal.is_maximal_comap_of_is_integral_of_is_maximal'\n  f hf x.as_ideal $ (is_closed_singleton_iff_is_maximal x).1 hx)\n\nvariable S\n\nlemma localization_comap_inducing [algebra R S] (M : submonoid R)\n  [is_localization M S] : inducing (comap (algebra_map R S)) :=\nbegin\n  constructor,\n  rw topological_space_eq_iff,\n  intro U,\n  simp_rw ← is_closed_compl_iff,\n  generalize : Uᶜ = Z,\n  simp_rw [is_closed_induced_iff, is_closed_iff_zero_locus],\n  split,\n  { rintro ⟨s, rfl⟩,\n    refine ⟨_,⟨(algebra_map R S) ⁻¹' (ideal.span s),rfl⟩,_⟩,\n    rw [preimage_comap_zero_locus, ← zero_locus_span, ← zero_locus_span s],\n    congr' 1,\n    exact congr_arg submodule.carrier (is_localization.map_comap M S (ideal.span s)) },\n  { rintro ⟨_, ⟨t, rfl⟩, rfl⟩, simp }\nend\n\nlemma localization_comap_injective [algebra R S] (M : submonoid R)\n  [is_localization M S] : function.injective (comap (algebra_map R S)) :=\nbegin\n  intros p q h,\n  replace h := congr_arg (λ (x : prime_spectrum R), ideal.map (algebra_map R S) x.as_ideal) h,\n  dsimp only at h,\n  erw [is_localization.map_comap M S, is_localization.map_comap M S] at h,\n  ext1,\n  exact h\nend\n\nlemma localization_comap_embedding [algebra R S] (M : submonoid R)\n  [is_localization M S] : embedding (comap (algebra_map R S)) :=\n⟨localization_comap_inducing S M, localization_comap_injective S M⟩\n\nlemma localization_comap_range [algebra R S] (M : submonoid R)\n  [is_localization M S] :\n  set.range (comap (algebra_map R S)) = { p | disjoint (M : set R) p.as_ideal } :=\nbegin\n  ext x,\n  split,\n  { rintro ⟨p, rfl⟩ x ⟨hx₁, hx₂⟩,\n    exact (p.2.1 : ¬ _)\n      (p.as_ideal.eq_top_of_is_unit_mem hx₂ (is_localization.map_units S ⟨x, hx₁⟩)) },\n  { intro h,\n    use ⟨x.as_ideal.map (algebra_map R S),\n      is_localization.is_prime_of_is_prime_disjoint M S _ x.2 h⟩,\n    ext1,\n    exact is_localization.comap_map_of_is_prime_disjoint M S _ x.2 h }\nend\n\nend comap\n\nsection basic_open\n\n/-- `basic_open r` is the open subset containing all prime ideals not containing `r`. -/\ndef basic_open (r : R) : topological_space.opens (prime_spectrum R) :=\n{ val := { x | r ∉ x.as_ideal },\n  property := ⟨{r}, set.ext $ λ x, set.singleton_subset_iff.trans $ not_not.symm⟩ }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x ∈ basic_open f ↔ f ∉ x.as_ideal := iff.rfl\n\nlemma is_open_basic_open {a : R} : is_open ((basic_open a) : set (prime_spectrum R)) :=\n(basic_open a).property\n\n@[simp] lemma basic_open_eq_zero_locus_compl (r : R) :\n  (basic_open r : set (prime_spectrum R)) = (zero_locus {r})ᶜ :=\nset.ext $ λ x, by simpa only [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]\n\n@[simp] lemma basic_open_one : basic_open (1 : R) = ⊤ :=\ntopological_space.opens.ext $ by simp\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = ⊥ :=\ntopological_space.opens.ext $ by simp\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f ≤ basic_open g ↔ f ∈ (ideal.span ({g} : set R)).radical :=\nby rw [topological_space.opens.le_def, basic_open_eq_zero_locus_compl,\n    basic_open_eq_zero_locus_compl, set.le_eq_subset, set.compl_subset_compl,\n    zero_locus_subset_zero_locus_singleton_iff]\n\nlemma basic_open_mul (f g : R) : basic_open (f * g) = basic_open f ⊓ basic_open g :=\ntopological_space.opens.ext $ by {simp [zero_locus_singleton_mul]}\n\nlemma basic_open_mul_le_left (f g : R) : basic_open (f * g) ≤ basic_open f :=\nby { rw basic_open_mul f g, exact inf_le_left }\n\nlemma basic_open_mul_le_right (f g : R) : basic_open (f * g) ≤ basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : ℕ) (hn : 0 < n) : basic_open (f ^ n) = basic_open f :=\ntopological_space.opens.ext $ by simpa using zero_locus_singleton_pow f n hn\n\nlemma is_topological_basis_basic_opens : topological_space.is_topological_basis\n  (set.range (λ (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ ⟨r, rfl⟩,\n    exact is_open_basic_open },\n  { rintros p U hp ⟨s, hs⟩,\n    rw [← compl_compl U, set.mem_compl_eq, ← hs, mem_zero_locus, set.not_subset] at hp,\n    obtain ⟨f, hfs, hfp⟩ := hp,\n    refine ⟨basic_open f, ⟨f, rfl⟩, hfp, _⟩,\n    rw [← set.compl_subset_compl, ← hs, basic_open_eq_zero_locus_compl, compl_compl],\n    exact zero_locus_anti_mono (set.singleton_subset_iff.mpr hfs) }\nend\n\nlemma is_basis_basic_opens :\n  topological_space.opens.is_basis (set.range (@basic_open R _)) :=\nbegin\n  unfold topological_space.opens.is_basis,\n  convert is_topological_basis_basic_opens,\n  rw ← set.range_comp,\nend\n\nlemma is_compact_basic_open (f : R) : is_compact (basic_open f : set (prime_spectrum R)) :=\nis_compact_of_finite_subfamily_closed $ λ ι Z hZc hZ,\nbegin\n  let I : ι → ideal R := λ i, vanishing_ideal (Z i),\n  have hI : ∀ i, Z i = zero_locus (I i) := λ i,\n    by simpa only [zero_locus_vanishing_ideal_eq_closure] using (hZc i).closure_eq.symm,\n  rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n      set.diff_eq_empty, funext hI, ← zero_locus_supr] at hZ,\n  obtain ⟨n, hn⟩ : f ∈ (⨆ (i : ι), I i).radical,\n  { rw ← vanishing_ideal_zero_locus_eq_radical,\n    apply vanishing_ideal_anti_mono hZ,\n    exact (subset_vanishing_ideal_zero_locus {f} (set.mem_singleton f)) },\n  rcases submodule.exists_finset_of_mem_supr I hn with ⟨s, hs⟩,\n  use s,\n  -- Using simp_rw here, because `hI` and `zero_locus_supr` need to be applied underneath binders\n  simp_rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n           set.diff_eq_empty, hI, ← zero_locus_supr],\n  rw ← zero_locus_radical, -- this one can't be in `simp_rw` because it would loop\n  apply zero_locus_anti_mono,\n  rw set.singleton_subset_iff,\n  exact ⟨n, hs⟩\nend\n\n@[simp]\nlemma basic_open_eq_bot_iff (f : R) :\n  basic_open f = ⊥ ↔ is_nilpotent f :=\nbegin\n  rw [← subtype.coe_injective.eq_iff, basic_open_eq_zero_locus_compl],\n  simp only [set.eq_univ_iff_forall, topological_space.opens.empty_eq, set.singleton_subset_iff,\n    topological_space.opens.coe_bot, nilpotent_iff_mem_prime, set.compl_empty_iff, mem_zero_locus,\n    set_like.mem_coe],\n  exact subtype.forall,\nend\n\nlemma localization_away_comap_range (S : Type v) [comm_ring S] [algebra R S] (r : R)\n  [is_localization.away r S] : set.range (comap (algebra_map R S)) = basic_open r :=\nbegin\n  rw localization_comap_range S (submonoid.powers r),\n  ext,\n  simp only [mem_zero_locus, basic_open_eq_zero_locus_compl, set_like.mem_coe, set.mem_set_of_eq,\n    set.singleton_subset_iff, set.mem_compl_eq],\n  split,\n  { intros h₁ h₂,\n    exact h₁ ⟨submonoid.mem_powers r, h₂⟩ },\n  { rintros h₁ _ ⟨⟨n, rfl⟩, h₃⟩,\n    exact h₁ (x.2.mem_of_pow_mem _ h₃) },\nend\n\nlemma localization_away_open_embedding (S : Type v) [comm_ring S] [algebra R S] (r : R)\n  [is_localization.away r S] : open_embedding (comap (algebra_map R S)) :=\n{ to_embedding := localization_comap_embedding S (submonoid.powers r),\n  open_range := by { rw localization_away_comap_range S r, exact is_open_basic_open } }\n\nend basic_open\n\n/-- The prime spectrum of a commutative ring is a compact topological space. -/\ninstance : compact_space (prime_spectrum R) :=\n{ compact_univ := by { convert is_compact_basic_open (1 : R), rw basic_open_one, refl } }\n\nsection order\n\n/-!\n## The specialization order\n\nWe endow `prime_spectrum R` with a partial order,\nwhere `x ≤ y` if and only if `y ∈ closure {x}`.\n\nTODO: maybe define sober topological spaces, and generalise this instance to those\n-/\n\ninstance : partial_order (prime_spectrum R) :=\nsubtype.partial_order _\n\n@[simp] lemma as_ideal_le_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal ≤ y.as_ideal ↔ x ≤ y :=\nsubtype.coe_le_coe\n\n@[simp] lemma as_ideal_lt_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal < y.as_ideal ↔ x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x ≤ y ↔ y ∈ closure ({x} : set (prime_spectrum R)) :=\nby rw [← as_ideal_le_as_ideal, ← zero_locus_vanishing_ideal_eq_closure,\n    mem_zero_locus, vanishing_ideal_singleton, set_like.coe_subset_coe]\n\nlemma le_iff_specializes (x y : prime_spectrum R) :\n  x ≤ y ↔ x ⤳ y :=\nle_iff_mem_closure x y\n\ninstance : t0_space (prime_spectrum R) :=\nby { simp [t0_space_iff_or_not_mem_closure, ← le_iff_mem_closure,\n  ← not_and_distrib, ← le_antisymm_iff, eq_comm] }\n\nend order\n\n/-- If `x` specializes to `y`, then there is a natural map from the localization of `y` to\nthe localization of `x`. -/\ndef localization_map_of_specializes {x y : prime_spectrum R} (h : x ⤳ y) :\n  localization.at_prime y.as_ideal →+* localization.at_prime x.as_ideal :=\n@is_localization.lift _ _ _ _ _ _ _ _ localization.is_localization (algebra_map R _)\nbegin\n  rintro ⟨a, ha⟩,\n  rw [← prime_spectrum.le_iff_specializes, ← as_ideal_le_as_ideal, ← set_like.coe_subset_coe,\n    ← set.compl_subset_compl] at h,\n  exact (is_localization.map_units _ ⟨a, (show a ∈ x.as_ideal.prime_compl, from h ha)⟩ : _)\nend\n\nend prime_spectrum\n\n\nnamespace local_ring\n\nvariables (R) [local_ring R]\n\n/--\nThe closed point in the prime spectrum of a local ring.\n-/\ndef closed_point : prime_spectrum R :=\n⟨maximal_ideal R, (maximal_ideal.is_maximal R).is_prime⟩\n\nvariable {R}\n\nlemma is_local_ring_hom_iff_comap_closed_point {S : Type v} [comm_ring S] [local_ring S]\n  (f : R →+* S) : is_local_ring_hom f ↔ prime_spectrum.comap f (closed_point S) = closed_point R :=\nby { rw [(local_hom_tfae f).out 0 4, subtype.ext_iff], refl }\n\n@[simp] lemma comap_closed_point {S : Type v} [comm_ring S] [local_ring S] (f : R →+* S)\n  [is_local_ring_hom f] : prime_spectrum.comap f (closed_point S) = closed_point R :=\n(is_local_ring_hom_iff_comap_closed_point f).mp infer_instance\n\nend local_ring\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebraic_geometry/prime_spectrum/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4729382303909938}}
{"text": "/-\nCopyright (c) 2018 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n\n! This file was ported from Lean 3 source module order.conditionally_complete_lattice.group\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.ConditionallyCompleteLattice.Basic\nimport Mathbin.Algebra.Order.Group.TypeTags\n\n/-!\n# Conditionally complete lattices and groups.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n-/\n\n\nsection Group\n\nvariable {α : Type _} {ι : Sort _} {ι' : Sort _} [Nonempty ι] [Nonempty ι']\n  [ConditionallyCompleteLattice α] [Group α]\n\n/- warning: le_mul_cinfi -> le_mul_cinfᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : Nonempty.{u2} ι] [_inst_3 : ConditionallyCompleteLattice.{u1} α] [_inst_4 : Group.{u1} α] [_inst_5 : CovariantClass.{u1, u1} α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4)))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] {a : α} {g : α} {h : ι -> α}, (forall (j : ι), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) g (h j))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) g (infᵢ.{u1, u2} α (ConditionallyCompleteLattice.toHasInf.{u1} α _inst_3) ι h)))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : Nonempty.{u1} ι] [_inst_3 : ConditionallyCompleteLattice.{u2} α] [_inst_4 : Group.{u2} α] [_inst_5 : CovariantClass.{u2, u2} α α (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.50 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.52 : α) => HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.50 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.52) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.65 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.67 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.65 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.67)] {a : α} {g : α} {h : ι -> α}, (forall (j : ι), LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) a (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) g (h j))) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) a (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) g (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α _inst_3) ι h)))\nCase conversion may be inaccurate. Consider using '#align le_mul_cinfi le_mul_cinfᵢₓ'. -/\n@[to_additive]\ntheorem le_mul_cinfᵢ [CovariantClass α α (· * ·) (· ≤ ·)] {a : α} {g : α} {h : ι → α}\n    (H : ∀ j, a ≤ g * h j) : a ≤ g * infᵢ h :=\n  inv_mul_le_iff_le_mul.mp <| le_cinfᵢ fun hi => inv_mul_le_iff_le_mul.mpr <| H _\n#align le_mul_cinfi le_mul_cinfᵢ\n#align le_add_cinfi le_add_cinfᵢ\n\n/- warning: mul_csupr_le -> mul_csupᵢ_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : Nonempty.{u2} ι] [_inst_3 : ConditionallyCompleteLattice.{u1} α] [_inst_4 : Group.{u1} α] [_inst_5 : CovariantClass.{u1, u1} α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4)))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] {a : α} {g : α} {h : ι -> α}, (forall (j : ι), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) g (h j)) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) g (supᵢ.{u1, u2} α (ConditionallyCompleteLattice.toHasSup.{u1} α _inst_3) ι h)) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : Nonempty.{u1} ι] [_inst_3 : ConditionallyCompleteLattice.{u2} α] [_inst_4 : Group.{u2} α] [_inst_5 : CovariantClass.{u2, u2} α α (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.139 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.141 : α) => HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.139 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.141) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.154 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.156 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.154 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.156)] {a : α} {g : α} {h : ι -> α}, (forall (j : ι), LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) g (h j)) a) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) g (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α _inst_3) ι h)) a)\nCase conversion may be inaccurate. Consider using '#align mul_csupr_le mul_csupᵢ_leₓ'. -/\n@[to_additive]\ntheorem mul_csupᵢ_le [CovariantClass α α (· * ·) (· ≤ ·)] {a : α} {g : α} {h : ι → α}\n    (H : ∀ j, g * h j ≤ a) : g * supᵢ h ≤ a :=\n  @le_mul_cinfᵢ αᵒᵈ _ _ _ _ _ _ _ _ H\n#align mul_csupr_le mul_csupᵢ_le\n#align add_csupr_le add_csupᵢ_le\n\n/- warning: le_cinfi_mul -> le_cinfᵢ_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : Nonempty.{u2} ι] [_inst_3 : ConditionallyCompleteLattice.{u1} α] [_inst_4 : Group.{u1} α] [_inst_5 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] {a : α} {g : ι -> α} {h : α}, (forall (i : ι), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (g i) h)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (infᵢ.{u1, u2} α (ConditionallyCompleteLattice.toHasInf.{u1} α _inst_3) ι g) h))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : Nonempty.{u1} ι] [_inst_3 : ConditionallyCompleteLattice.{u2} α] [_inst_4 : Group.{u2} α] [_inst_5 : CovariantClass.{u2, u2} α α (Function.swap.{succ u2, succ u2, succ u2} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.228 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.230 : α) => HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.228 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.230)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.243 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.245 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.243 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.245)] {a : α} {g : ι -> α} {h : α}, (forall (i : ι), LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) a (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) (g i) h)) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) a (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) (infᵢ.{u2, u1} α (ConditionallyCompleteLattice.toInfSet.{u2} α _inst_3) ι g) h))\nCase conversion may be inaccurate. Consider using '#align le_cinfi_mul le_cinfᵢ_mulₓ'. -/\n@[to_additive]\ntheorem le_cinfᵢ_mul [CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)] {a : α} {g : ι → α}\n    {h : α} (H : ∀ i, a ≤ g i * h) : a ≤ infᵢ g * h :=\n  mul_inv_le_iff_le_mul.mp <| le_cinfᵢ fun gi => mul_inv_le_iff_le_mul.mpr <| H _\n#align le_cinfi_mul le_cinfᵢ_mul\n#align le_cinfi_add le_cinfᵢ_add\n\n/- warning: csupr_mul_le -> csupᵢ_mul_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : Nonempty.{u2} ι] [_inst_3 : ConditionallyCompleteLattice.{u1} α] [_inst_4 : Group.{u1} α] [_inst_5 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] {a : α} {g : ι -> α} {h : α}, (forall (i : ι), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (g i) h) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (supᵢ.{u1, u2} α (ConditionallyCompleteLattice.toHasSup.{u1} α _inst_3) ι g) h) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : Nonempty.{u1} ι] [_inst_3 : ConditionallyCompleteLattice.{u2} α] [_inst_4 : Group.{u2} α] [_inst_5 : CovariantClass.{u2, u2} α α (Function.swap.{succ u2, succ u2, succ u2} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.320 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.322 : α) => HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.320 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.322)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.335 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.337 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.335 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.337)] {a : α} {g : ι -> α} {h : α}, (forall (i : ι), LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) (g i) h) a) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (ConditionallyCompleteLattice.toLattice.{u2} α _inst_3))))) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (MulOneClass.toMul.{u2} α (Monoid.toMulOneClass.{u2} α (DivInvMonoid.toMonoid.{u2} α (Group.toDivInvMonoid.{u2} α _inst_4))))) (supᵢ.{u2, u1} α (ConditionallyCompleteLattice.toSupSet.{u2} α _inst_3) ι g) h) a)\nCase conversion may be inaccurate. Consider using '#align csupr_mul_le csupᵢ_mul_leₓ'. -/\n@[to_additive]\ntheorem csupᵢ_mul_le [CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)] {a : α} {g : ι → α}\n    {h : α} (H : ∀ i, g i * h ≤ a) : supᵢ g * h ≤ a :=\n  @le_cinfᵢ_mul αᵒᵈ _ _ _ _ _ _ _ _ H\n#align csupr_mul_le csupᵢ_mul_le\n#align csupr_add_le csupᵢ_add_le\n\n/- warning: le_cinfi_mul_cinfi -> le_cinfᵢ_mul_cinfᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} {ι' : Sort.{u3}} [_inst_1 : Nonempty.{u2} ι] [_inst_2 : Nonempty.{u3} ι'] [_inst_3 : ConditionallyCompleteLattice.{u1} α] [_inst_4 : Group.{u1} α] [_inst_5 : CovariantClass.{u1, u1} α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4)))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] [_inst_6 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] {a : α} {g : ι -> α} {h : ι' -> α}, (forall (i : ι) (j : ι'), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (g i) (h j))) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) a (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (infᵢ.{u1, u2} α (ConditionallyCompleteLattice.toHasInf.{u1} α _inst_3) ι g) (infᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasInf.{u1} α _inst_3) ι' h)))\nbut is expected to have type\n  forall {α : Type.{u3}} {ι : Sort.{u2}} {ι' : Sort.{u1}} [_inst_1 : Nonempty.{u2} ι] [_inst_2 : Nonempty.{u1} ι'] [_inst_3 : ConditionallyCompleteLattice.{u3} α] [_inst_4 : Group.{u3} α] [_inst_5 : CovariantClass.{u3, u3} α α (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.406 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.408 : α) => HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.406 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.408) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.421 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.423 : α) => LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.421 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.423)] [_inst_6 : CovariantClass.{u3, u3} α α (Function.swap.{succ u3, succ u3, succ u3} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.443 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.445 : α) => HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.443 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.445)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.458 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.460 : α) => LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.458 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.460)] {a : α} {g : ι -> α} {h : ι' -> α}, (forall (i : ι) (j : ι'), LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) a (HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) (g i) (h j))) -> (LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) a (HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) (infᵢ.{u3, u2} α (ConditionallyCompleteLattice.toInfSet.{u3} α _inst_3) ι g) (infᵢ.{u3, u1} α (ConditionallyCompleteLattice.toInfSet.{u3} α _inst_3) ι' h)))\nCase conversion may be inaccurate. Consider using '#align le_cinfi_mul_cinfi le_cinfᵢ_mul_cinfᵢₓ'. -/\n@[to_additive]\ntheorem le_cinfᵢ_mul_cinfᵢ [CovariantClass α α (· * ·) (· ≤ ·)]\n    [CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)] {a : α} {g : ι → α} {h : ι' → α}\n    (H : ∀ i j, a ≤ g i * h j) : a ≤ infᵢ g * infᵢ h :=\n  le_cinfᵢ_mul fun i => le_mul_cinfᵢ <| H _\n#align le_cinfi_mul_cinfi le_cinfᵢ_mul_cinfᵢ\n#align le_cinfi_add_cinfi le_cinfᵢ_add_cinfᵢ\n\n/- warning: csupr_mul_csupr_le -> csupᵢ_mul_csupᵢ_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} {ι' : Sort.{u3}} [_inst_1 : Nonempty.{u2} ι] [_inst_2 : Nonempty.{u3} ι'] [_inst_3 : ConditionallyCompleteLattice.{u1} α] [_inst_4 : Group.{u1} α] [_inst_5 : CovariantClass.{u1, u1} α α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4)))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] [_inst_6 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))))) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))))] {a : α} {g : ι -> α} {h : ι' -> α}, (forall (i : ι) (j : ι'), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (g i) (h j)) a) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α _inst_3))))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α (Group.toDivInvMonoid.{u1} α _inst_4))))) (supᵢ.{u1, u2} α (ConditionallyCompleteLattice.toHasSup.{u1} α _inst_3) ι g) (supᵢ.{u1, u3} α (ConditionallyCompleteLattice.toHasSup.{u1} α _inst_3) ι' h)) a)\nbut is expected to have type\n  forall {α : Type.{u3}} {ι : Sort.{u2}} {ι' : Sort.{u1}} [_inst_1 : Nonempty.{u2} ι] [_inst_2 : Nonempty.{u1} ι'] [_inst_3 : ConditionallyCompleteLattice.{u3} α] [_inst_4 : Group.{u3} α] [_inst_5 : CovariantClass.{u3, u3} α α (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.534 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.536 : α) => HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.534 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.536) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.549 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.551 : α) => LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.549 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.551)] [_inst_6 : CovariantClass.{u3, u3} α α (Function.swap.{succ u3, succ u3, succ u3} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.571 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.573 : α) => HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.571 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.573)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.586 : α) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.588 : α) => LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.586 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.588)] {a : α} {g : ι -> α} {h : ι' -> α}, (forall (i : ι) (j : ι'), LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) (HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) (g i) (h j)) a) -> (LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (ConditionallyCompleteLattice.toLattice.{u3} α _inst_3))))) (HMul.hMul.{u3, u3, u3} α α α (instHMul.{u3} α (MulOneClass.toMul.{u3} α (Monoid.toMulOneClass.{u3} α (DivInvMonoid.toMonoid.{u3} α (Group.toDivInvMonoid.{u3} α _inst_4))))) (supᵢ.{u3, u2} α (ConditionallyCompleteLattice.toSupSet.{u3} α _inst_3) ι g) (supᵢ.{u3, u1} α (ConditionallyCompleteLattice.toSupSet.{u3} α _inst_3) ι' h)) a)\nCase conversion may be inaccurate. Consider using '#align csupr_mul_csupr_le csupᵢ_mul_csupᵢ_leₓ'. -/\n@[to_additive]\ntheorem csupᵢ_mul_csupᵢ_le [CovariantClass α α (· * ·) (· ≤ ·)]\n    [CovariantClass α α (Function.swap (· * ·)) (· ≤ ·)] {a : α} {g : ι → α} {h : ι' → α}\n    (H : ∀ i j, g i * h j ≤ a) : supᵢ g * supᵢ h ≤ a :=\n  csupᵢ_mul_le fun i => mul_csupᵢ_le <| H _\n#align csupr_mul_csupr_le csupᵢ_mul_csupᵢ_le\n#align csupr_add_csupr_le csupᵢ_add_csupᵢ_le\n\nend Group\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/ConditionallyCompleteLattice/Group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835452961425, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4728991724889683}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\n! This file was ported from Lean 3 source module algebra.big_operators.finsupp\n! leanprover-community/mathlib commit 842328d9df7e96fd90fc424e115679c15fb23a71\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Finsupp.Indicator\nimport Mathlib.Algebra.BigOperators.Pi\nimport Mathlib.Algebra.BigOperators.Ring\nimport Mathlib.Algebra.BigOperators.Order\nimport Mathlib.GroupTheory.Submonoid.Membership\n\n/-!\n# Big operators for finsupps\n\nThis file contains theorems relevant to big operators in finitely supported functions.\n-/\n\n\nnoncomputable section\n\nopen Finset Function\n\nopen BigOperators\n\nvariable {α ι γ A B C : Type _} [AddCommMonoid A] [AddCommMonoid B] [AddCommMonoid C]\n\nvariable {t : ι → A → C} (h0 : ∀ i, t i 0 = 0) (h1 : ∀ i x y, t i (x + y) = t i x + t i y)\n\nvariable {s : Finset α} {f : α → ι →₀ A} (i : ι)\n\nvariable (g : ι →₀ A) (k : ι → A → γ → B) (x : γ)\n\nvariable {β M M' N P G H R S : Type _}\n\nnamespace Finsupp\n\n/-!\n### Declarations about `sum` and `prod`\n\nIn most of this section, the domain `β` is assumed to be an `AddMonoid`.\n-/\n\n\nsection SumProd\n\n/-- `prod f g` is the product of `g a (f a)` over the support of `f`. -/\n@[to_additive \"`sum f g` is the sum of `g a (f a)` over the support of `f`. \"]\ndef prod [Zero M] [CommMonoid N] (f : α →₀ M) (g : α → M → N) : N :=\n  ∏ a in f.support, g a (f a)\n#align finsupp.prod Finsupp.prod\n#align finsupp.sum Finsupp.sum\n\nvariable [Zero M] [Zero M'] [CommMonoid N]\n\n@[to_additive]\ntheorem prod_of_support_subset (f : α →₀ M) {s : Finset α} (hs : f.support ⊆ s) (g : α → M → N)\n    (h : ∀ i ∈ s, g i 0 = 1) : f.prod g = ∏ x in s, g x (f x) := by\n  refine Finset.prod_subset hs fun x hxs hx => h x hxs ▸ (congr_arg (g x) ?_)\n  exact not_mem_support_iff.1 hx\n#align finsupp.prod_of_support_subset Finsupp.prod_of_support_subset\n#align finsupp.sum_of_support_subset Finsupp.sum_of_support_subset\n\n@[to_additive]\ntheorem prod_fintype [Fintype α] (f : α →₀ M) (g : α → M → N) (h : ∀ i, g i 0 = 1) :\n    f.prod g = ∏ i, g i (f i) :=\n  f.prod_of_support_subset (subset_univ _) g fun x _ => h x\n#align finsupp.prod_fintype Finsupp.prod_fintype\n#align finsupp.sum_fintype Finsupp.sum_fintype\n\n@[to_additive (attr := simp)]\ntheorem prod_single_index {a : α} {b : M} {h : α → M → N} (h_zero : h a 0 = 1) :\n    (single a b).prod h = h a b :=\n  calc\n    (single a b).prod h = ∏ x in {a}, h x (single a b x) :=\n      prod_of_support_subset _ support_single_subset h fun x hx =>\n        (mem_singleton.1 hx).symm ▸ h_zero\n    _ = h a b := by simp\n\n#align finsupp.prod_single_index Finsupp.prod_single_index\n#align finsupp.sum_single_index Finsupp.sum_single_index\n\n@[to_additive]\ntheorem prod_mapRange_index {f : M → M'} {hf : f 0 = 0} {g : α →₀ M} {h : α → M' → N}\n    (h0 : ∀ a, h a 0 = 1) : (mapRange f hf g).prod h = g.prod fun a b => h a (f b) :=\n  Finset.prod_subset support_mapRange fun _ _ H => by rw [not_mem_support_iff.1 H, h0]\n#align finsupp.prod_map_range_index Finsupp.prod_mapRange_index\n#align finsupp.sum_map_range_index Finsupp.sum_mapRange_index\n\n@[to_additive (attr := simp)]\ntheorem prod_zero_index {h : α → M → N} : (0 : α →₀ M).prod h = 1 :=\n  rfl\n#align finsupp.prod_zero_index Finsupp.prod_zero_index\n#align finsupp.sum_zero_index Finsupp.sum_zero_index\n\n@[to_additive]\ntheorem prod_comm (f : α →₀ M) (g : β →₀ M') (h : α → M → β → M' → N) :\n    (f.prod fun x v => g.prod fun x' v' => h x v x' v') =\n      g.prod fun x' v' => f.prod fun x v => h x v x' v' :=\n  Finset.prod_comm\n#align finsupp.prod_comm Finsupp.prod_comm\n#align finsupp.sum_comm Finsupp.sum_comm\n\n@[to_additive (attr := simp)]\ntheorem prod_ite_eq [DecidableEq α] (f : α →₀ M) (a : α) (b : α → M → N) :\n    (f.prod fun x v => ite (a = x) (b x v) 1) = ite (a ∈ f.support) (b a (f a)) 1 := by\n  dsimp [Finsupp.prod]\n  rw [f.support.prod_ite_eq]\n#align finsupp.prod_ite_eq Finsupp.prod_ite_eq\n#align finsupp.sum_ite_eq Finsupp.sum_ite_eq\n\n/- Porting note: simpnf linter, added aux lemma below\nLeft-hand side simplifies from\n  Finsupp.sum f fun x v => if a = x then v else 0\nto\n  if ↑f a = 0 then 0 else ↑f a\n-/\n-- @[simp]\ntheorem sum_ite_self_eq [DecidableEq α] {N : Type _} [AddCommMonoid N] (f : α →₀ N) (a : α) :\n    (f.sum fun x v => ite (a = x) v 0) = f a := by\n  classical\n    convert f.sum_ite_eq a fun _ => id\n    simp [ite_eq_right_iff.2 Eq.symm]\n#align finsupp.sum_ite_self_eq Finsupp.sum_ite_self_eq\n\n-- Porting note: Added this thm to replace the simp in the previous one. Need to add [DecidableEq N]\n@[simp]\ntheorem sum_ite_self_eq_aux [DecidableEq α] {N : Type _} [AddCommMonoid N] (f : α →₀ N) (a : α) :\n    (if a ∈ f.support then f a else 0) = f a := by\n  simp only [mem_support_iff, ne_eq, ite_eq_left_iff, not_not]\n  exact fun h ↦ h.symm\n\n/-- A restatement of `prod_ite_eq` with the equality test reversed. -/\n@[to_additive (attr := simp) \"A restatement of `sum_ite_eq` with the equality test reversed.\"]\ntheorem prod_ite_eq' [DecidableEq α] (f : α →₀ M) (a : α) (b : α → M → N) :\n    (f.prod fun x v => ite (x = a) (b x v) 1) = ite (a ∈ f.support) (b a (f a)) 1 := by\n  dsimp [Finsupp.prod]\n  rw [f.support.prod_ite_eq']\n#align finsupp.prod_ite_eq' Finsupp.prod_ite_eq'\n#align finsupp.sum_ite_eq' Finsupp.sum_ite_eq'\n\n-- Porting note: simp can prove this\n-- @[simp]\ntheorem sum_ite_self_eq' [DecidableEq α] {N : Type _} [AddCommMonoid N] (f : α →₀ N) (a : α) :\n    (f.sum fun x v => ite (x = a) v 0) = f a := by\n  classical\n    convert f.sum_ite_eq' a fun _ => id\n    simp [ite_eq_right_iff.2 Eq.symm]\n#align finsupp.sum_ite_self_eq' Finsupp.sum_ite_self_eq'\n\n@[simp]\ntheorem prod_pow [Fintype α] (f : α →₀ ℕ) (g : α → N) :\n    (f.prod fun a b => g a ^ b) = ∏ a, g a ^ f a :=\n  f.prod_fintype _ fun _ ↦ pow_zero _\n#align finsupp.prod_pow Finsupp.prod_pow\n\n/-- If `g` maps a second argument of 0 to 1, then multiplying it over the\nresult of `onFinset` is the same as multiplying it over the original `Finset`. -/\n@[to_additive\n      \"If `g` maps a second argument of 0 to 0, summing it over the\n      result of `onFinset` is the same as summing it over the original `Finset`.\"]\ntheorem onFinset_prod {s : Finset α} {f : α → M} {g : α → M → N} (hf : ∀ a, f a ≠ 0 → a ∈ s)\n    (hg : ∀ a, g a 0 = 1) : (onFinset s f hf).prod g = ∏ a in s, g a (f a) :=\n  Finset.prod_subset support_onFinset_subset <| by simp (config := { contextual := true }) [*]\n#align finsupp.on_finset_prod Finsupp.onFinset_prod\n#align finsupp.on_finset_sum Finsupp.onFinset_sum\n\n/-- Taking a product over `f : α →₀ M` is the same as multiplying the value on a single element\n`y ∈ f.support` by the product over `erase y f`. -/\n@[to_additive\n      \" Taking a sum over over `f : α →₀ M` is the same as adding the value on a\n      single element `y ∈ f.support` to the sum over `erase y f`. \"]\ntheorem mul_prod_erase (f : α →₀ M) (y : α) (g : α → M → N) (hyf : y ∈ f.support) :\n    g y (f y) * (erase y f).prod g = f.prod g := by\n  classical\n    rw [Finsupp.prod, Finsupp.prod, ← Finset.mul_prod_erase _ _ hyf, Finsupp.support_erase,\n      Finset.prod_congr rfl]\n    intro h hx\n    rw [Finsupp.erase_ne (ne_of_mem_erase hx)]\n#align finsupp.mul_prod_erase Finsupp.mul_prod_erase\n#align finsupp.add_sum_erase Finsupp.add_sum_erase\n\n/-- Generalization of `Finsupp.mul_prod_erase`: if `g` maps a second argument of 0 to 1,\nthen its product over `f : α →₀ M` is the same as multiplying the value on any element\n`y : α` by the product over `erase y f`. -/\n@[to_additive\n      \" Generalization of `Finsupp.add_sum_erase`: if `g` maps a second argument of 0\n      to 0, then its sum over `f : α →₀ M` is the same as adding the value on any element\n      `y : α` to the sum over `erase y f`. \"]\ntheorem mul_prod_erase' (f : α →₀ M) (y : α) (g : α → M → N) (hg : ∀ i : α, g i 0 = 1) :\n    g y (f y) * (erase y f).prod g = f.prod g := by\n  classical\n    by_cases hyf : y ∈ f.support\n    · exact Finsupp.mul_prod_erase f y g hyf\n    · rw [not_mem_support_iff.mp hyf, hg y, erase_of_not_mem_support hyf, one_mul]\n#align finsupp.mul_prod_erase' Finsupp.mul_prod_erase'\n#align finsupp.add_sum_erase' Finsupp.add_sum_erase'\n\n@[to_additive]\ntheorem _root_.SubmonoidClass.finsupp_prod_mem {S : Type _} [SetLike S N] [SubmonoidClass S N]\n    (s : S) (f : α →₀ M) (g : α → M → N) (h : ∀ c, f c ≠ 0 → g c (f c) ∈ s) : f.prod g ∈ s :=\n  prod_mem fun _i hi => h _ (Finsupp.mem_support_iff.mp hi)\n#align submonoid_class.finsupp_prod_mem SubmonoidClass.finsupp_prod_mem\n#align add_submonoid_class.finsupp_sum_mem AddSubmonoidClass.finsupp_sum_mem\n\n@[to_additive]\ntheorem prod_congr {f : α →₀ M} {g1 g2 : α → M → N} (h : ∀ x ∈ f.support, g1 x (f x) = g2 x (f x)) :\n    f.prod g1 = f.prod g2 :=\n  Finset.prod_congr rfl h\n#align finsupp.prod_congr Finsupp.prod_congr\n#align finsupp.sum_congr Finsupp.sum_congr\n\nend SumProd\n\nend Finsupp\n\n@[to_additive]\ntheorem map_finsupp_prod [Zero M] [CommMonoid N] [CommMonoid P] {H : Type _} [MonoidHomClass H N P]\n    (h : H) (f : α →₀ M) (g : α → M → N) : h (f.prod g) = f.prod fun a b => h (g a b) :=\n  map_prod h _ _\n#align map_finsupp_prod map_finsupp_prod\n#align map_finsupp_sum map_finsupp_sum\n\n/-- Deprecated, use `_root_.map_finsupp_prod` instead. -/\n@[to_additive (attr := deprecated)\n  \"Deprecated, use `_root_.map_finsupp_sum` instead.\"]\nprotected theorem MulEquiv.map_finsupp_prod [Zero M] [CommMonoid N] [CommMonoid P] (h : N ≃* P)\n    (f : α →₀ M) (g : α → M → N) : h (f.prod g) = f.prod fun a b => h (g a b) :=\n  map_finsupp_prod h f g\n#align mul_equiv.map_finsupp_prod MulEquiv.map_finsupp_prod\n#align add_equiv.map_finsupp_sum AddEquiv.map_finsupp_sum\n\n/-- Deprecated, use `_root_.map_finsupp_prod` instead. -/\n@[to_additive (attr := deprecated)\n  \"Deprecated, use `_root_.map_finsupp_sum` instead.\"]\nprotected theorem MonoidHom.map_finsupp_prod [Zero M] [CommMonoid N] [CommMonoid P] (h : N →* P)\n    (f : α →₀ M) (g : α → M → N) : h (f.prod g) = f.prod fun a b => h (g a b) :=\n  map_finsupp_prod h f g\n#align monoid_hom.map_finsupp_prod MonoidHom.map_finsupp_prod\n#align add_monoid_hom.map_finsupp_sum AddMonoidHom.map_finsupp_sum\n\n/-- Deprecated, use `_root_.map_finsupp_sum` instead. -/\n@[deprecated map_finsupp_sum]\nprotected theorem RingHom.map_finsupp_sum [Zero M] [Semiring R] [Semiring S] (h : R →+* S)\n    (f : α →₀ M) (g : α → M → R) : h (f.sum g) = f.sum fun a b => h (g a b) :=\n  map_finsupp_sum h f g\n#align ring_hom.map_finsupp_sum RingHom.map_finsupp_sum\n\n/-- Deprecated, use `_root_.map_finsupp_prod` instead. -/\n@[deprecated map_finsupp_prod]\nprotected theorem RingHom.map_finsupp_prod [Zero M] [CommSemiring R] [CommSemiring S] (h : R →+* S)\n    (f : α →₀ M) (g : α → M → R) : h (f.prod g) = f.prod fun a b => h (g a b) :=\n  map_finsupp_prod h f g\n#align ring_hom.map_finsupp_prod RingHom.map_finsupp_prod\n\n-- Porting note: inserted ⇑ on the rhs\n@[to_additive]\ntheorem MonoidHom.coe_finsupp_prod [Zero β] [Monoid N] [CommMonoid P] (f : α →₀ β)\n    (g : α → β → N →* P) : ⇑(f.prod g) = f.prod fun i fi => ⇑(g i fi) :=\n  MonoidHom.coe_finset_prod _ _\n#align monoid_hom.coe_finsupp_prod MonoidHom.coe_finsupp_prod\n#align add_monoid_hom.coe_finsupp_sum AddMonoidHom.coe_finsupp_sum\n\n@[to_additive (attr := simp)]\ntheorem MonoidHom.finsupp_prod_apply [Zero β] [Monoid N] [CommMonoid P] (f : α →₀ β)\n    (g : α → β → N →* P) (x : N) : f.prod g x = f.prod fun i fi => g i fi x :=\n  MonoidHom.finset_prod_apply _ _ _\n#align monoid_hom.finsupp_prod_apply MonoidHom.finsupp_prod_apply\n#align add_monoid_hom.finsupp_sum_apply AddMonoidHom.finsupp_sum_apply\n\nnamespace Finsupp\n\ntheorem single_multiset_sum [AddCommMonoid M] (s : Multiset M) (a : α) :\n    single a s.sum = (s.map (single a)).sum :=\n  Multiset.induction_on s (single_zero _) fun a s ih => by\n    rw [Multiset.sum_cons, single_add, ih, Multiset.map_cons, Multiset.sum_cons]\n#align finsupp.single_multiset_sum Finsupp.single_multiset_sum\n\ntheorem single_finset_sum [AddCommMonoid M] (s : Finset ι) (f : ι → M) (a : α) :\n    single a (∑ b in s, f b) = ∑ b in s, single a (f b) := by\n  trans\n  · apply single_multiset_sum\n  · rw [Multiset.map_map]\n    rfl\n#align finsupp.single_finset_sum Finsupp.single_finset_sum\n\ntheorem single_sum [Zero M] [AddCommMonoid N] (s : ι →₀ M) (f : ι → M → N) (a : α) :\n    single a (s.sum f) = s.sum fun d c => single a (f d c) :=\n  single_finset_sum _ _ _\n#align finsupp.single_sum Finsupp.single_sum\n\n@[to_additive]\ntheorem prod_neg_index [AddGroup G] [CommMonoid M] {g : α →₀ G} {h : α → G → M}\n    (h0 : ∀ a, h a 0 = 1) : (-g).prod h = g.prod fun a b => h a (-b) :=\n  prod_mapRange_index h0\n#align finsupp.prod_neg_index Finsupp.prod_neg_index\n#align finsupp.sum_neg_index Finsupp.sum_neg_index\n\nend Finsupp\n\nnamespace Finsupp\n\ntheorem finset_sum_apply [AddCommMonoid N] (S : Finset ι) (f : ι → α →₀ N) (a : α) :\n    (∑ i in S, f i) a = ∑ i in S, f i a :=\n  (applyAddHom a : (α →₀ N) →+ _).map_sum _ _\n#align finsupp.finset_sum_apply Finsupp.finset_sum_apply\n\n@[simp]\ntheorem sum_apply [Zero M] [AddCommMonoid N] {f : α →₀ M} {g : α → M → β →₀ N} {a₂ : β} :\n    (f.sum g) a₂ = f.sum fun a₁ b => g a₁ b a₂ :=\n  finset_sum_apply _ _ _\n#align finsupp.sum_apply Finsupp.sum_apply\n\n-- Porting note: inserted ⇑ on the rhs\ntheorem coe_finset_sum [AddCommMonoid N] (S : Finset ι) (f : ι → α →₀ N) :\n    ⇑(∑ i in S, f i) = ∑ i in S, ⇑(f i) :=\n  (coeFnAddHom : (α →₀ N) →+ _).map_sum _ _\n#align finsupp.coe_finset_sum Finsupp.coe_finset_sum\n\n-- Porting note: inserted ⇑ on the rhs\ntheorem coe_sum [Zero M] [AddCommMonoid N] (f : α →₀ M) (g : α → M → β →₀ N) :\n    ⇑(f.sum g) = f.sum fun a₁ b => ⇑(g a₁ b) :=\n  coe_finset_sum _ _\n#align finsupp.coe_sum Finsupp.coe_sum\n\ntheorem support_sum [DecidableEq β] [Zero M] [AddCommMonoid N] {f : α →₀ M} {g : α → M → β →₀ N} :\n    (f.sum g).support ⊆ f.support.bunionᵢ fun a => (g a (f a)).support := by\n  have : ∀ c, (f.sum fun a b => g a b c) ≠ 0 → ∃ a, f a ≠ 0 ∧ ¬(g a (f a)) c = 0 := fun a₁ h =>\n    let ⟨a, ha, ne⟩ := Finset.exists_ne_zero_of_sum_ne_zero h\n    ⟨a, mem_support_iff.mp ha, ne⟩\n  simpa only [Finset.subset_iff, mem_support_iff, Finset.mem_bunionᵢ, sum_apply, exists_prop]\n#align finsupp.support_sum Finsupp.support_sum\n\ntheorem support_finset_sum [DecidableEq β] [AddCommMonoid M] {s : Finset α} {f : α → β →₀ M} :\n    (Finset.sum s f).support ⊆ s.bunionᵢ fun x => (f x).support := by\n  rw [← Finset.sup_eq_bunionᵢ]\n  induction' s using Finset.cons_induction_on with a s ha ih\n  · rfl\n  · rw [Finset.sum_cons, Finset.sup_cons]\n    exact support_add.trans (Finset.union_subset_union (Finset.Subset.refl _) ih)\n#align finsupp.support_finset_sum Finsupp.support_finset_sum\n\n@[simp]\ntheorem sum_zero [Zero M] [AddCommMonoid N] {f : α →₀ M} : (f.sum fun _ _ => (0 : N)) = 0 :=\n  Finset.sum_const_zero\n#align finsupp.sum_zero Finsupp.sum_zero\n\n@[to_additive (attr := simp)]\ntheorem prod_mul [Zero M] [CommMonoid N] {f : α →₀ M} {h₁ h₂ : α → M → N} :\n    (f.prod fun a b => h₁ a b * h₂ a b) = f.prod h₁ * f.prod h₂ :=\n  Finset.prod_mul_distrib\n#align finsupp.prod_mul Finsupp.prod_mul\n#align finsupp.sum_add Finsupp.sum_add\n\n@[to_additive (attr := simp)]\ntheorem prod_inv [Zero M] [CommGroup G] {f : α →₀ M} {h : α → M → G} :\n    (f.prod fun a b => (h a b)⁻¹) = (f.prod h)⁻¹ :=\n  (map_prod (MonoidHom.id G)⁻¹ _ _).symm\n#align finsupp.prod_inv Finsupp.prod_inv\n#align finsupp.sum_neg Finsupp.sum_neg\n\n@[simp]\n\n\n/-- Taking the product under `h` is an additive-to-multiplicative homomorphism of finsupps,\nif `h` is an additive-to-multiplicative homomorphism on the support.\nThis is a more general version of `Finsupp.prod_add_index'`; the latter has simpler hypotheses. -/\n@[to_additive\n      \"Taking the product under `h` is an additive homomorphism of finsupps,  if `h` is an\n      additive homomorphism on the support. This is a more general version of\n      `Finsupp.sum_add_index'`; the latter has simpler hypotheses.\"]\ntheorem prod_add_index [DecidableEq α] [AddZeroClass M] [CommMonoid N] {f g : α →₀ M}\n    {h : α → M → N} (h_zero : ∀ a ∈ f.support ∪ g.support, h a 0 = 1)\n    (h_add : ∀ a ∈ f.support ∪ g.support, ∀ (b₁ b₂), h a (b₁ + b₂) = h a b₁ * h a b₂) :\n    (f + g).prod h = f.prod h * g.prod h := by\n  rw [Finsupp.prod_of_support_subset f (subset_union_left _ g.support) h h_zero,\n    Finsupp.prod_of_support_subset g (subset_union_right f.support _) h h_zero, ←\n    Finset.prod_mul_distrib, Finsupp.prod_of_support_subset (f + g) Finsupp.support_add h h_zero]\n  exact Finset.prod_congr rfl fun x hx => by apply h_add x hx\n#align finsupp.prod_add_index Finsupp.prod_add_index\n#align finsupp.sum_add_index Finsupp.sum_add_index\n\n/-- Taking the product under `h` is an additive-to-multiplicative homomorphism of finsupps,\nif `h` is an additive-to-multiplicative homomorphism.\nThis is a more specialized version of `Finsupp.prod_add_index` with simpler hypotheses. -/\n@[to_additive\n      \"Taking the sum under `h` is an additive homomorphism of finsupps,if `h` is an additive\n      homomorphism. This is a more specific version of `finsupp.sum_add_index` with simpler\n      hypotheses.\"]\ntheorem prod_add_index' [AddZeroClass M] [CommMonoid N] {f g : α →₀ M} {h : α → M → N}\n    (h_zero : ∀ a, h a 0 = 1) (h_add : ∀ a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) :\n    (f + g).prod h = f.prod h * g.prod h := by\n  classical exact prod_add_index (fun a _ => h_zero a) fun a _ => h_add a\n#align finsupp.prod_add_index' Finsupp.prod_add_index'\n#align finsupp.sum_add_index' Finsupp.sum_add_index'\n\n@[simp]\ntheorem sum_hom_add_index [AddZeroClass M] [AddCommMonoid N] {f g : α →₀ M} (h : α → M →+ N) :\n    ((f + g).sum fun x => h x) = (f.sum fun x => h x) + g.sum fun x => h x :=\n  sum_add_index' (fun a => (h a).map_zero) fun a => (h a).map_add\n#align finsupp.sum_hom_add_index Finsupp.sum_hom_add_index\n\n@[simp]\ntheorem prod_hom_add_index [AddZeroClass M] [CommMonoid N] {f g : α →₀ M}\n    (h : α → Multiplicative M →* N) :\n    ((f + g).prod fun a b => h a (Multiplicative.ofAdd b)) =\n      (f.prod fun a b => h a (Multiplicative.ofAdd b)) *\n        g.prod fun a b => h a (Multiplicative.ofAdd b) :=\n  prod_add_index' (fun a => (h a).map_one) fun a => (h a).map_mul\n#align finsupp.prod_hom_add_index Finsupp.prod_hom_add_index\n\n/-- The canonical isomorphism between families of additive monoid homomorphisms `α → (M →+ N)`\nand monoid homomorphisms `(α →₀ M) →+ N`. -/\ndef liftAddHom [AddZeroClass M] [AddCommMonoid N] : (α → M →+ N) ≃+ ((α →₀ M) →+ N)\n    where\n  toFun F :=\n    { toFun := fun f ↦ f.sum fun x ↦ F x\n      map_zero' := Finset.sum_empty\n      map_add' := fun _ _ => sum_add_index' (fun x => (F x).map_zero) fun x => (F x).map_add }\n  invFun F x := F.comp (singleAddHom x)\n  left_inv F := by\n    ext\n    simp [singleAddHom]\n  right_inv F := by\n  -- Porting note: This was `ext` and used the wrong lemma\n    apply Finsupp.addHom_ext'\n    simp [singleAddHom, AddMonoidHom.comp, Function.comp]\n  map_add' F G := by\n    ext x\n    exact sum_add\n#align finsupp.lift_add_hom Finsupp.liftAddHom\n\n@[simp]\ntheorem liftAddHom_apply [AddCommMonoid M] [AddCommMonoid N] (F : α → M →+ N) (f : α →₀ M) :\n    (liftAddHom (α := α) (M := M) (N := N)) F f = f.sum fun x => F x :=\n  rfl\n#align finsupp.lift_add_hom_apply Finsupp.liftAddHom_apply\n\n@[simp]\ntheorem liftAddHom_symm_apply [AddCommMonoid M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α) :\n    (liftAddHom (α := α) (M := M) (N := N)).symm F x = F.comp (singleAddHom x) :=\n  rfl\n#align finsupp.lift_add_hom_symm_apply Finsupp.liftAddHom_symm_apply\n\ntheorem liftAddHom_symm_apply_apply [AddCommMonoid M] [AddCommMonoid N] (F : (α →₀ M) →+ N) (x : α)\n    (y : M) : (liftAddHom (α := α) (M := M) (N := N)).symm F x y = F (single x y) :=\n  rfl\n#align finsupp.lift_add_hom_symm_apply_apply Finsupp.liftAddHom_symm_apply_apply\n\n@[simp]\ntheorem liftAddHom_singleAddHom [AddCommMonoid M] :\n    (liftAddHom (α := α) (M := M) (N := α →₀ M)) (singleAddHom : α → M →+ α →₀ M) =\n      AddMonoidHom.id _ :=\n  liftAddHom.toEquiv.apply_eq_iff_eq_symm_apply.2 rfl\n#align finsupp.lift_add_hom_single_add_hom Finsupp.liftAddHom_singleAddHom\n\n@[simp]\ntheorem sum_single [AddCommMonoid M] (f : α →₀ M) : f.sum single = f :=\n  FunLike.congr_fun liftAddHom_singleAddHom f\n#align finsupp.sum_single Finsupp.sum_single\n\n@[simp]\ntheorem sum_univ_single [AddCommMonoid M] [Fintype α] (i : α) (m : M) :\n    (∑ j : α, (single i m) j) = m := by\n-- Porting note: rewrite due to leaky classical in lean3\n  classical rw [single, coe_mk, Finset.sum_pi_single']\n  simp\n#align finsupp.sum_univ_single Finsupp.sum_univ_single\n\n@[simp]\ntheorem sum_univ_single' [AddCommMonoid M] [Fintype α] (i : α) (m : M) :\n    (∑ j : α, (single j m) i) = m := by\n-- Porting note: rewrite due to leaky classical in lean3\n  simp_rw [single, coe_mk, Finset.sum_pi_single]\n  classical rw [Finset.sum_pi_single]\n  simp\n#align finsupp.sum_univ_single' Finsupp.sum_univ_single'\n\n-- Porting note: simp can prove this\n-- @[simp]\ntheorem liftAddHom_apply_single [AddCommMonoid M] [AddCommMonoid N] (f : α → M →+ N) (a : α)\n    (b : M) : (liftAddHom (α := α) (M := M) (N := N)) f (single a b) = f a b :=\n  sum_single_index (f a).map_zero\n#align finsupp.lift_add_hom_apply_single Finsupp.liftAddHom_apply_single\n\n@[simp]\ntheorem liftAddHom_comp_single [AddCommMonoid M] [AddCommMonoid N] (f : α → M →+ N) (a : α) :\n    ((liftAddHom (α := α) (M := M) (N := N)) f).comp (singleAddHom a) = f a :=\n  AddMonoidHom.ext fun b => liftAddHom_apply_single f a b\n#align finsupp.lift_add_hom_comp_single Finsupp.liftAddHom_comp_single\n\ntheorem comp_liftAddHom [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] (g : N →+ P)\n    (f : α → M →+ N) :\n    g.comp ((liftAddHom (α := α) (M := M) (N := N)) f) =\n      (liftAddHom (α := α) (M := M) (N := P)) fun a => g.comp (f a) :=\n  liftAddHom.symm_apply_eq.1 <|\n    funext fun a => by\n      rw [liftAddHom_symm_apply, AddMonoidHom.comp_assoc, liftAddHom_comp_single]\n#align finsupp.comp_lift_add_hom Finsupp.comp_liftAddHom\n\ntheorem sum_sub_index [AddCommGroup β] [AddCommGroup γ] {f g : α →₀ β} {h : α → β → γ}\n    (h_sub : ∀ a b₁ b₂, h a (b₁ - b₂) = h a b₁ - h a b₂) : (f - g).sum h = f.sum h - g.sum h :=\n  ((liftAddHom (α := α) (M := β) (N := γ)) fun a =>\n    AddMonoidHom.ofMapSub (h a) (h_sub a)).map_sub f g\n#align finsupp.sum_sub_index Finsupp.sum_sub_index\n\n@[to_additive]\ntheorem prod_embDomain [Zero M] [CommMonoid N] {v : α →₀ M} {f : α ↪ β} {g : β → M → N} :\n    (v.embDomain f).prod g = v.prod fun a b => g (f a) b := by\n  rw [prod, prod, support_embDomain, Finset.prod_map]\n  simp_rw [embDomain_apply]\n#align finsupp.prod_emb_domain Finsupp.prod_embDomain\n#align finsupp.sum_emb_domain Finsupp.sum_embDomain\n\n@[to_additive]\ntheorem prod_finset_sum_index [AddCommMonoid M] [CommMonoid N] {s : Finset ι} {g : ι → α →₀ M}\n    {h : α → M → N} (h_zero : ∀ a, h a 0 = 1) (h_add : ∀ a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) :\n    (∏ i in s, (g i).prod h) = (∑ i in s, g i).prod h :=\n  Finset.cons_induction_on s rfl fun a s has ih => by\n    rw [prod_cons, ih, sum_cons, prod_add_index' h_zero h_add]\n#align finsupp.prod_finset_sum_index Finsupp.prod_finset_sum_index\n#align finsupp.sum_finset_sum_index Finsupp.sum_finset_sum_index\n\n@[to_additive]\ntheorem prod_sum_index [AddCommMonoid M] [AddCommMonoid N] [CommMonoid P] {f : α →₀ M}\n    {g : α → M → β →₀ N} {h : β → N → P} (h_zero : ∀ a, h a 0 = 1)\n    (h_add : ∀ a b₁ b₂, h a (b₁ + b₂) = h a b₁ * h a b₂) :\n    (f.sum g).prod h = f.prod fun a b => (g a b).prod h :=\n  (prod_finset_sum_index h_zero h_add).symm\n#align finsupp.prod_sum_index Finsupp.prod_sum_index\n#align finsupp.sum_sum_index Finsupp.sum_sum_index\n\ntheorem multiset_sum_sum_index [AddCommMonoid M] [AddCommMonoid N] (f : Multiset (α →₀ M))\n    (h : α → M → N) (h₀ : ∀ a, h a 0 = 0)\n    (h₁ : ∀ (a : α) (b₁ b₂ : M), h a (b₁ + b₂) = h a b₁ + h a b₂) :\n    f.sum.sum h = (f.map fun g : α →₀ M => g.sum h).sum :=\n  Multiset.induction_on f rfl fun a s ih => by\n    rw [Multiset.sum_cons, Multiset.map_cons, Multiset.sum_cons, sum_add_index' h₀ h₁, ih]\n#align finsupp.multiset_sum_sum_index Finsupp.multiset_sum_sum_index\n\ntheorem support_sum_eq_bunionᵢ {α : Type _} {ι : Type _} {M : Type _} [DecidableEq α]\n    [AddCommMonoid M] {g : ι → α →₀ M} (s : Finset ι)\n    (h : ∀ i₁ i₂, i₁ ≠ i₂ → Disjoint (g i₁).support (g i₂).support) :\n    (∑ i in s, g i).support = s.bunionᵢ fun i => (g i).support := by\n  classical\n  -- Porting note: apply Finset.induction_on s was not working; refine does.\n  refine Finset.induction_on s ?_ ?_\n  · simp\n  · intro i s hi\n    simp only [hi, sum_insert, not_false_iff, bunionᵢ_insert]\n    intro hs\n    rw [Finsupp.support_add_eq, hs]\n    rw [hs, Finset.disjoint_bunionᵢ_right]\n    intro j hj\n    refine' h _ _ (ne_of_mem_of_not_mem hj hi).symm\n#align finsupp.support_sum_eq_bUnion Finsupp.support_sum_eq_bunionᵢ\n\ntheorem multiset_map_sum [Zero M] {f : α →₀ M} {m : β → γ} {h : α → M → Multiset β} :\n    Multiset.map m (f.sum h) = f.sum fun a b => (h a b).map m :=\n  (Multiset.mapAddMonoidHom m).map_sum _ f.support\n#align finsupp.multiset_map_sum Finsupp.multiset_map_sum\n\ntheorem multiset_sum_sum [Zero M] [AddCommMonoid N] {f : α →₀ M} {h : α → M → Multiset N} :\n    Multiset.sum (f.sum h) = f.sum fun a b => Multiset.sum (h a b) :=\n  (Multiset.sumAddMonoidHom : Multiset N →+ N).map_sum _ f.support\n#align finsupp.multiset_sum_sum Finsupp.multiset_sum_sum\n\n/-- For disjoint `f1` and `f2`, and function `g`, the product of the products of `g`\nover `f1` and `f2` equals the product of `g` over `f1 + f2` -/\n@[to_additive\n      \"For disjoint `f1` and `f2`, and function `g`, the sum of the sums of `g`\n      over `f1` and `f2` equals the sum of `g` over `f1 + f2`\"]\ntheorem prod_add_index_of_disjoint [AddCommMonoid M] {f1 f2 : α →₀ M}\n    (hd : Disjoint f1.support f2.support) {β : Type _} [CommMonoid β] (g : α → M → β) :\n    (f1 + f2).prod g = f1.prod g * f2.prod g := by\n  have :\n    ∀ {f1 f2 : α →₀ M},\n      Disjoint f1.support f2.support → (∏ x in f1.support, g x (f1 x + f2 x)) = f1.prod g :=\n    fun hd =>\n    Finset.prod_congr rfl fun x hx => by\n      simp only [not_mem_support_iff.mp (disjoint_left.mp hd hx), add_zero]\n  classical simp_rw [← this hd, ← this hd.symm, add_comm (f2 _), Finsupp.prod, support_add_eq hd,\n      prod_union hd, add_apply]\n#align finsupp.prod_add_index_of_disjoint Finsupp.prod_add_index_of_disjoint\n#align finsupp.sum_add_index_of_disjoint Finsupp.sum_add_index_of_disjoint\n\ntheorem prod_dvd_prod_of_subset_of_dvd [AddCommMonoid M] [CommMonoid N] {f1 f2 : α →₀ M}\n    {g1 g2 : α → M → N} (h1 : f1.support ⊆ f2.support)\n    (h2 : ∀ a : α, a ∈ f1.support → g1 a (f1 a) ∣ g2 a (f2 a)) : f1.prod g1 ∣ f2.prod g2 := by\n  classical\n    simp only [Finsupp.prod, Finsupp.prod_mul]\n    rw [← sdiff_union_of_subset h1, prod_union sdiff_disjoint]\n    apply dvd_mul_of_dvd_right\n    apply prod_dvd_prod_of_dvd\n    exact h2\n#align finsupp.prod_dvd_prod_of_subset_of_dvd Finsupp.prod_dvd_prod_of_subset_of_dvd\n\nlemma indicator_eq_sum_single [AddCommMonoid M] (s : Finset α) (f : ∀ a ∈ s, M) :\n    indicator s f = ∑ x in s.attach, single ↑x (f x x.2) := by\n  rw [← sum_single (indicator s f), sum, sum_subset (support_indicator_subset _ _), ← sum_attach]\n  · refine' Finset.sum_congr rfl (fun _ _ => _)\n    rw [indicator_of_mem]\n  · intro i _ hi\n    rw [not_mem_support_iff.mp hi, single_zero]\n#align finsupp.indicator_eq_sum_single Finsupp.indicator_eq_sum_single\n\n@[to_additive (attr := simp)]\nlemma prod_indicator_index [Zero M] [CommMonoid N]\n    {s : Finset α} (f : ∀ a ∈ s, M) {h : α → M → N} (h_zero : ∀ a ∈ s, h a 0 = 1) :\n    (indicator s f).prod h = ∏ x in s.attach, h ↑x (f x x.2) := by\n  rw [prod_of_support_subset _ (support_indicator_subset _ _) h h_zero, ← prod_attach]\n  refine' Finset.prod_congr rfl (fun _ _ => _)\n  rw [indicator_of_mem]\n#align finsupp.prod_indicator_index Finsupp.prod_indicator_index\n#align finsupp.sum_indicator_index Finsupp.sum_indicator_index\n\nend Finsupp\n\ntheorem Finset.sum_apply' : (∑ k in s, f k) i = ∑ k in s, f k i :=\n  (Finsupp.applyAddHom i : (ι →₀ A) →+ A).map_sum f s\n#align finset.sum_apply' Finset.sum_apply'\n\ntheorem Finsupp.sum_apply' : g.sum k x = g.sum fun i b => k i b x :=\n  Finset.sum_apply _ _ _\n#align finsupp.sum_apply' Finsupp.sum_apply'\n\nsection\n\nopen Classical\n\ntheorem Finsupp.sum_sum_index' : (∑ x in s, f x).sum t = ∑ x in s, (f x).sum t :=\n  Finset.induction_on s rfl fun a s has ih => by\n    simp_rw [Finset.sum_insert has, Finsupp.sum_add_index' h0 h1, ih]\n#align finsupp.sum_sum_index' Finsupp.sum_sum_index'\n\nend\n\nsection\n\nvariable [NonUnitalNonAssocSemiring R] [NonUnitalNonAssocSemiring S]\n\ntheorem Finsupp.sum_mul (b : S) (s : α →₀ R) {f : α → R → S} :\n    s.sum f * b = s.sum fun a c => f a c * b := by simp only [Finsupp.sum, Finset.sum_mul]\n#align finsupp.sum_mul Finsupp.sum_mul\n\ntheorem Finsupp.mul_sum (b : S) (s : α →₀ R) {f : α → R → S} :\n    b * s.sum f = s.sum fun a c => b * f a c := by simp only [Finsupp.sum, Finset.mul_sum]\n#align finsupp.mul_sum Finsupp.mul_sum\n\nend\n\nnamespace Nat\n\n-- Porting note: Needed to replace pow with (· ^ ·)\n/-- If `0 : ℕ` is not in the support of `f : ℕ →₀ ℕ` then `0 < ∏ x in f.support, x ^ (f x)`. -/\ntheorem prod_pow_pos_of_zero_not_mem_support {f : ℕ →₀ ℕ} (hf : 0 ∉ f.support) :\n    0 < f.prod (· ^ ·) :=\n Finset.prod_pos fun a ha => pos_iff_ne_zero.mpr (pow_ne_zero _ fun H => by subst H; exact hf ha)\n\n#align nat.prod_pow_pos_of_zero_not_mem_support Nat.prod_pow_pos_of_zero_not_mem_support\n\nend Nat\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/BigOperators/Finsupp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203136, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4728288078372378}}
{"text": "import set_theory.cardinal\nimport Rings.ToMathlib.fol\nimport data.W.cardinal\n\nuniverses u v\n\nnamespace fol\n\nvariables {L : Language.{u}}\n\nopen_locale cardinal\n\nopen fol.Language\n\ndef bounded_term.rec2_aux {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  Π {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n  (ih_ts : ∀s, ts.pmem s → C s), C (bd_apps t ts)\n| l (bd_var k) dvector.nil := λ _, hvar k\n| l (bd_func f)  ts := λ hs, hfunc f ts hs\n| l (bd_app t s) ts := λ hs, bounded_term.rec2_aux t (dvector.cons s ts) $\n  λ r hr, psum.cases_on hr\n    (λ hrs, eq.rec_on hrs.symm (bounded_term.rec2_aux s dvector.nil $\n      λ s₀ hs₀, false.elim $ by {cases hs₀}))\n    (hs _)\n\ndef bounded_term.rec2 {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  ∀(t : bounded_term L n), C t :=\nλt, bounded_term.rec2_aux hvar (λ _, hfunc) t dvector.nil (λ s hs, false.elim $ by {cases hs})\n\n-- have h : ∀{n l} (f : bounded_preformula L n l) (ts : dvector (bounded_term L n) l),\n--   C n (bd_apps_rel f ts),\n-- begin\n--   intros, induction f; try {rw ts.zero_eq},\n--   apply hfalsum, apply hequal, apply hrel, apply f_ih (f_t::ts),\n--   exact himp (f_ih_f₁ ([])) (f_ih_f₂ ([])), exact hall (f_ih ([]))\n-- end,\n-- λn f, h f ([])\n\n@[simp] def bounded_formula.rec2_aux {C : Πn, bounded_formula L n → Sort v}\n  (hfalsum : Π {n}, C n ⊥)\n  (hequal : Π {n} (t₁ t₂ : bounded_term L n), C n (t₁ ≃ t₂))\n  (hrel : Π {n l : ℕ} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : Π {n} {f₁ f₂ : bounded_formula L n} (ih₁ : C n f₁) (ih₂ : C n f₂), C n (f₁ ⟹ f₂))\n  (hall : Π {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (∀' f)) :\n  ∀{n l} (f : bounded_preformula L n l) (ts : dvector (bounded_term L n) l),\n  C n (bd_apps_rel f ts)\n| _ _ bd_falsum dvector.nil := hfalsum\n| _ _ (t₁ ≃ t₂) dvector.nil := hequal _ _\n| _ _ (bd_rel R)         ts := hrel _ _\n| _ _ (bd_apprel f t)    ts := by {let x := bounded_formula.rec2_aux f (dvector.cons t ts),\n  dsimp [bd_apps_rel] at x, exact x }\n| _ _ (f₁ ⟹ f₂) dvector.nil := himp (bounded_formula.rec2_aux f₁ dvector.nil)\n  (bounded_formula.rec2_aux f₂ dvector.nil)\n| _ _ (∀' f)    dvector.nil := hall (bounded_formula.rec2_aux f dvector.nil)\n\n@[simp] def bounded_formula.rec2 {C : Πn, bounded_formula L n → Sort v}\n  (hfalsum : Π {n}, C n ⊥)\n  (hequal : Π {n} (t₁ t₂ : bounded_term L n), C n (t₁ ≃ t₂))\n  (hrel : Π {n l : ℕ} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : Π {n} {f₁ f₂ : bounded_formula L n} (ih₁ : C n f₁) (ih₂ : C n f₂), C n (f₁ ⟹ f₂))\n  (hall : Π {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (∀' f)) :\n  ∀{n : ℕ} (f : bounded_formula L n), C n f :=\nλ n f, bounded_formula.rec2_aux (λ _, hfalsum) (λ _, hequal) (λ _ _, hrel) (λ _ _ _, himp)\n  (λ _ _, hall) f dvector.nil\n\n-- lemma bounded_term.rec2_aux_bd_apps {n} {C : bounded_term L n → Sort v}\n--   (hvar : ∀(k : fin n), C &k)\n--   (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n--   ∀ {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : ∀t, ts.pmem t → C t),\n--   bounded_term.rec2_aux hvar (λ _, hfunc) (bd_apps t ts)\n--     = sorry :=\n-- begin\n--   sorry\n--   -- intros l t,\n--   -- induction t,\n--   -- {\n--   --   intro ts,\n--   --   -- induction ts,\n\n\n--   -- },\n--   -- {sorry},\n-- end\n\nlemma bounded_term.rec2_bd_var {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  ∀ (k : fin n),\n  bounded_term.rec2 hvar (λ _, hfunc) &k = hvar k := λ k, rfl\n\nlemma bounded_term.rec2_bd_apps {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  ∀ {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t),\n  bounded_term.rec2 hvar (λ _, hfunc) (bd_apps (bd_func f) ts)\n    = hfunc f ts ih_ts :=\nbegin\n  intros l f ts,\n  induction ts with a b c hind e f g,\n  { intro ih_ts,\n    dsimp [bounded_term.rec2, bounded_term.rec2_aux],\n    apply congr_arg,\n    ext _ a,\n    cases a },\n  {\n    intro ih_ts,\n    dsimp [bd_apps, bounded_term.rec2, bounded_term.rec2_aux],\n    sorry,\n\n  },\nend\n\nnamespace cardinal\n\nvariables (L) (n : ℕ)\n\n/-- We make `bounded_term L n` as a `W_type`, viewing the `W_type` as an inductive type\n  the constructors would be indexed by the following definition.\n  For each `k < n` we have a variable `xₙ` (with arity zero given by `pempty`)\n  For each `⟨ n , f ⟩ : Σ n : ℕ, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_α := ulift.{u} (fin n) ⊕ Σ m : ulift.{u} ℕ, L.functions m.down\n\n/-- To define the arities in the `W_type` for `closed_term`.\n  For each `n : ℕ` we have a variable `xₙ` (with arity zero given by `pempty`)\n  For each `⟨ n , f ⟩ : Σ n : ℕ, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_β : Π (c : term_α.{u} L n), Type u\n| (sum.inl m) := pempty.{u+1}\n| (sum.inr ⟨ m , f ⟩) := ulift.{u} (fin m.down)\n\nvariable {L}\n\n/-- The forward map of the equivalence `W_type_term_β_equiv_closed_term` -/\n@[reducible] def bounded_term_of_W_type_term_β : W_type (term_β L n) → bounded_term L n\n| ⟨ sum.inl m , b ⟩ := x_ m.down\n| ⟨ sum.inr (⟨ n , f ⟩) , b ⟩ := bd_apps (bd_func f)\n  (dvector.of_fn (λ k, bounded_term_of_W_type_term_β $ b (ulift.up k)))\n\n/-- The forward map of the equivalence `W_type_term_β_equiv_closed_term` -/\n@[reducible] def W_type_term_β_of_bounded_term : bounded_term L n → W_type (term_β L n) :=\n  bounded_term.rec2\n    (λ m, ⟨ sum.inl ⟨m⟩ , pempty.elim ⟩) $\n    λ l f ts rec,\n    ⟨ sum.inr ⟨ ulift.up l , f ⟩, λ k : ulift (fin l), rec (dvector.nth' ts $ k.down) dvector.pmem_nth' ⟩\n\nlemma bounded_term_of_W_type_term_β_right_inv : ∀ t : bounded_term L n,\n  bounded_term_of_W_type_term_β n (W_type_term_β_of_bounded_term n t) = t :=\nbegin\n  apply bounded_term.rec2,\n  { intro k, refl },\n  { intros l f ts hind,\n    dsimp only [W_type_term_β_of_bounded_term],\n    rw bounded_term.rec2_bd_apps _ _ _ _ (λ t _, W_type_term_β_of_bounded_term n t),\n    dsimp [bounded_term_of_W_type_term_β],\n    congr,\n    rw dvector.ext,\n    intro i,\n    simp [dvector.nth'_of_fn],\n    apply hind,\n    exact dvector.pmem_nth' },\nend\n\n/- This is really an equivalence, but we only need surjectivity -/\nlemma bounded_term_of_W_type_term_β_surjective :\n  function.surjective (@bounded_term_of_W_type_term_β L n) :=\nbegin\n  intros t,\n  use W_type_term_β_of_bounded_term n t,\n  exact bounded_term_of_W_type_term_β_right_inv _ _,\nend\n\nlemma fintype_term_β : Π (a : term_α L n), fintype (term_β L n a)\n| (sum.inl ⟨ m ⟩) := by apply_instance\n| (sum.inr ⟨ m , f ⟩) := fintype.of_equiv (fin m.down) equiv.ulift.symm\n\nlocal attribute [instance] fintype_term_β\n\nlemma bounded_term_le_functions : #(bounded_term L n) ≤\n  max (cardinal.sum (λ n : ulift.{u} (ℕ), #(L.functions n.down))) ω :=\ncalc #(bounded_term L n)\n      ≤ #(W_type (term_β.{u} L n)) :\n    cardinal.mk_le_of_surjective (bounded_term_of_W_type_term_β_surjective n)\n  ... ≤ max (# (ulift.{u} (fin n) ⊕ Σ (m : ulift.{u} ℕ), L.functions m.down)) ω :\n    W_type.cardinal_mk_le_max_omega_of_fintype\n  ... ≤ max (#(Σ n : ulift.{u} ℕ, L.functions n.down)) ω :\n  begin\n    apply max_le _ (le_max_right _ _),\n    simp only [cardinal.mk_sum],\n    apply le_trans (cardinal.add_le_max _ _),\n    apply max_le _ (le_max_right _ _),\n    apply max_le (le_max_of_le_right _) (le_max_of_le_left _),\n    { apply le_of_lt, simp [cardinal.lt_omega] },\n    { simp },\n  end\n  ... = max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :\n    by {rw cardinal.mk_sigma _}\n\n/- We show that the formulas are bounded above by the terms.\n  We first construct a `W_type` for each `bounded_formula L n` as follows\n  ```\n  | constructor | multiplicity         | arity |\n  |-------------+----------------------+-------|\n  | ⊥           | unit                 | empty |\n  | t₁ ≃ t₂     | (bounded_term L n)²  | empty |\n  | ⟹           | unit                 | bool  |\n  ```\n  This gives us a way of injecting `bounded_formula L n`\n  into `W_type β n ⊕ bounded_formula L (n+1)` (to account for `∀`) (there are no relations).\n  This ultimately gives us\n  `bounded_formula L 0 ↪ Σ n : ℕ, W_type β n ` where instead of\n  mapping into `bounded_formula L (n+1)` we map into the next `W_type β (n+1)`.\n  We have bounds on each `W_type β n`, namely by `unit`, `(bounded_term L n)²` and `ω`.\n  Finally we can remove `unit` and the squaring.\n\n  The difference with the case of terms is `bd_all`\n  and the induction is captured in the following example\n  ```\n  inductive box : ℕ → Type u\n  | base {n} : box n\n  | drop {n} (f : box (n+1)) : box n\n  ```\n-/\n\nvariable (L)\n\ndef atomic_formula_α : Type u := punit.{u+1} ⊕ ((bounded_term L n) × (bounded_term L n)) ⊕ punit.{u+1}\n\n@[reducible] def atomic_formula_β : atomic_formula_α L n → Type u\n| (sum.inl x)           := pempty.{u+1}\n| (sum.inr (sum.inl x)) := pempty.{u+1}\n| (sum.inr (sum.inr x)) := ulift.{u} bool\n\n/-- We inject `bounded_formula L n` into the `W_type` built from this `⊕` `bounded_formula L (n+1)`.\n  This could be generalized to when `L` has relation symbols,\n  in which case more constructors should be added.\n  -/\n@[reducible] def formula_α : Type u := atomic_formula_α L n ⊕ (bounded_formula L (n+1))\n\n/-- The arities of the constructors `formula_α` for the `W_type` -/\n@[reducible] def formula_β : formula_α L n → Type u\n| (sum.inl x) := atomic_formula_β L n x\n| (sum.inr x) := pempty.{u+1}\n\nlemma fintype_formula_β : Π (a : formula_α L n), fintype (formula_β L n a)\n| (sum.inl (sum.inl x)) := by apply_instance\n| (sum.inl (sum.inr (sum.inl x))) := by apply_instance\n| (sum.inl (sum.inr (sum.inr x))) := by apply_instance\n| (sum.inr x) := by apply_instance\n\nlocal attribute [instance] fintype_formula_β\n\nvariable {L}\n\n/-- For all `n` we make a characterizing type for `bounded_formula L n`,\n  in the sense that this should be an equivalence.\n  For the recursion to work in the `∀` case,\n  it is important to define it for all `n` at once.\n  This is part of an equivalence -/\n@[simp, reducible] def W_type_of_bounded_formula [is_algebraic L] {n} :\n  bounded_formula L n → W_type (formula_β L n) :=\nbounded_formula.rec2\n  (λ _, ⟨ sum.inl $ sum.inl punit.star , pempty.elim ⟩) -- bd_falsum\n  (λ _ t s, ⟨ sum.inl $ sum.inr $ sum.inl ⟨ t , s ⟩ , pempty.elim ⟩) -- t ≃ s\n  (λ _ l r, false.elim $ Language.is_algebraic.empty_relations l r) -- there are no relation symbols\n  (λ _ f₁ f₂ recf₁ recf₂, ⟨ sum.inl $ sum.inr $ sum.inr punit.star ,\n    λ ⟨b⟩, bool.rec_on b recf₁ recf₂ ⟩ ) -- bd_imp\n  (λ _ f _, ⟨ sum.inr f , pempty.elim ⟩) -- bd_all degenerate case\n\n/-- Mapping `W_type_to_bounded_formula` (part of an equivalence) -/\n@[simp, reducible] def bounded_formula_of_W_type {n} :\n  W_type (formula_β L n) → bounded_formula L n\n| ⟨ (sum.inl (sum.inl x)) , y ⟩ := ⊥\n| ⟨ sum.inl (sum.inr (sum.inl ⟨ t , s ⟩)) , y ⟩ := t ≃ s\n| ⟨ sum.inl (sum.inr (sum.inr x)) , y ⟩ :=\n  bounded_formula_of_W_type (y $ ⟨ ff ⟩) ⟹\n  bounded_formula_of_W_type (y $ ⟨ tt ⟩)\n| ⟨ sum.inr f , y ⟩ := ∀' f\n\nlemma bounded_formula_of_W_type_left_inv\n  [is_algebraic L] {n} : ∀ f : bounded_formula L n,\n  (bounded_formula_of_W_type (W_type_of_bounded_formula f) = f) :=\nbegin\n  apply bounded_formula.rec2,\n  { intros,\n    simp [bounded_formula.rec2, bounded_formula.rec2_aux] },\n  { intros,\n    simp [bounded_formula.rec2, bounded_formula.rec2_aux] },\n  { intros n l r,\n    exfalso,\n    exact Language.is_algebraic.empty_relations l r },\n  { intros _ _ _ h1 h2,\n    simp only [bounded_formula_of_W_type, W_type_of_bounded_formula,\n      bounded_formula.rec2, bounded_formula.rec2_aux ],\n    exact ⟨ h1 , h2 ⟩ },\n  { intros,\n    simp [bounded_formula.rec2, bounded_formula.rec2_aux] },\nend\n\nlemma bounded_formula_of_W_type_right_inv [is_algebraic L] {n} (f : W_type (formula_β L n)) :\n  (W_type_of_bounded_formula (bounded_formula_of_W_type f) = f) :=\nbegin\n  induction f with a b hind,\n  cases a,\n  cases a,\n  { tidy },\n  cases a,\n  { tidy },\n  {\n    cases a,\n    have hff := hind ⟨ ff ⟩,\n    have htt := hind ⟨ tt ⟩,\n    simp only [W_type_of_bounded_formula, bounded_formula.rec2_aux, bounded_formula.rec2,\n      eq_self_iff_true, heq_iff_eq, true_and] at ⊢ hff htt,\n    rw [hff, htt],\n    ext bl, cases bl, cases bl,\n    {refl}, {refl}, },\n  { tidy },\nend\n\n/-- The types `bounded_formula L n` and `W_type (formula_β L n)` are equivalent -/\ndef bounded_formula_equiv_W_type [is_algebraic L] (n : ℕ) :\n  _root_.equiv (bounded_formula L n) (W_type (formula_β L n)) :=\n{ to_fun := W_type_of_bounded_formula,\n  inv_fun := bounded_formula_of_W_type,\n  left_inv := bounded_formula_of_W_type_left_inv,\n  right_inv := bounded_formula_of_W_type_right_inv }\n\ninductive box : ℕ → Type u\n| base {n} : box n\n| succ {n} : box n → box n\n| drop {n} (x : box (n+1)) : box n\n\ndef nat_of_box : ∀ n, box n → ℕ × ℕ × ℕ\n| n (box.base) := ⟨ n , 0 , 0 ⟩\n| n (box.succ x) := ⟨ (nat_of_box n x).1, (nat_of_box n x).2.1.succ , (nat_of_box n x).2.2 ⟩\n| n (box.drop x) := ⟨(nat_of_box (n+1) x).1 , (nat_of_box (n+1) x).2.1 ,\n  (nat_of_box (n+1) x).2.2.succ ⟩\n\n/-- Write formulas as lists of the following symbols -/\ninductive logic_symbol (L : Language.{u}) : Type u\n| bot : logic_symbol\n| eq : logic_symbol\n| imp : logic_symbol\n| all : logic_symbol\n| term : Π (l : ℕ), bounded_term L l → logic_symbol\n| nat : ℕ → logic_symbol\n\n/-- We inject `bounded_formula L n` into lists of symbols, keeping track\n  of how the formula is build.\n  We always include the number of variables of the formula at the beginning\n  by adding `logic_symbo.nat l`,\n  we then note the symbol for the constructor,\n  and then we keep the data of the any inductively attained list. -/\n@[simp] def logic_symbol_of_formula [is_algebraic L] {n} :\n  bounded_formula L n → list (logic_symbol L) :=\nbounded_formula.rec2\n  (λ l, [logic_symbol.nat l, logic_symbol.bot]) -- ⊥\n  (λ l t s, [ logic_symbol.nat l, logic_symbol.eq ,\n    logic_symbol.term l t , logic_symbol.term l s ]) -- t ≃ s\n  (λ _ _ r, false.elim $ Language.is_algebraic.empty_relations _ r) -- bd_rel\n  (λ l ϕ ψ lϕ lψ, (logic_symbol.nat l) :: (logic_symbol.nat (list.length lϕ))\n    :: (logic_symbol.nat (list.length lψ)) :: logic_symbol.imp :: lϕ.append lψ ) -- ϕ ⟹ ψ\n  (λ l ϕ lϕ, (logic_symbol.nat l) :: logic_symbol.all :: lϕ) -- ∀ₗ ϕ\n\nlemma logic_symbol_of_preformula_injective [is_algebraic L] {n} : ∀ (x : bounded_formula L n)\n  {m} (y : bounded_formula L m),\n  logic_symbol_of_formula x = logic_symbol_of_formula y → x == y :=\nbegin\n  -- apply bounded_formula.rec2,\n  have hrel : ∀ {l} {p : Prop} (r : L.relations l), p,\n  { intros _ _ r,\n    exact false.elim (Language.is_algebraic.empty_relations _ r) },\n  apply @bounded_formula.rec2 _ (λ _ x, ∀ {m} (y : bounded_formula L m),\n    logic_symbol_of_formula x = logic_symbol_of_formula y → x == y),\n  { intro l,\n    apply @bounded_formula.rec2 _ (λ n y,\n      logic_symbol_of_formula _ = logic_symbol_of_formula y → _ == y),\n    { intros k h, simp only [logic_symbol_of_formula, bounded_formula.rec2_aux,\n        bounded_formula.rec2, eq_self_iff_true, and_true] at h, subst h },\n    { intros _ _ _ h, simp only [logic_symbol_of_formula, bounded_formula.rec2_aux,\n        bounded_formula.rec2, and_false] at h, simpa [h] },\n    { intros _ _ r, apply hrel r },\n    { intros _ _ _ _ _ h, simp only [logic_symbol_of_formula, bounded_formula.rec2_aux,\n        bounded_formula.rec2, and_false] at h, simpa [h] },\n    { intros _ _ _ h, simp only [logic_symbol_of_formula, bounded_formula.rec2_aux,\n        bounded_formula.rec2, false_and, and_false] at h, simpa [h] } },\n  { intros l t s,\n    apply @bounded_formula.rec2 _ (λ n y,\n      logic_symbol_of_formula _ = logic_symbol_of_formula y → _ == y),\n    { intros k h, simp at h, simpa [h], },\n    { intros _ _ _ h, simp at h, cases h with h h', subst h, cases h' with h h',\n      cases h with h h1, subst h1, cases h' with h' h'1, subst h'1 },\n    { intros _ _ r, apply hrel r },\n    { intros _ _ _ _ _ h, simp at h, simpa [h] },\n    { intros _ _ _ h, simp at h, simpa [h] } },\n  { intros _ _ r, apply hrel r },\n  { intros l f₁ f₂ hf₁ hf₂,\n    apply @bounded_formula.rec2 _ (λ n y,\n      logic_symbol_of_formula _ = logic_symbol_of_formula y → _ == y),\n    { intros k h, simp at h, simpa [h], },\n    { intros _ _ _ h, simp at h, simpa [h] },\n    { intros _ _ r, apply hrel r },\n    { intros l' f₁' f₂' hf₁' hf₂' h, simp at h, obtain ⟨ hll' , hlenϕ , hlenψ , h ⟩ := h,\n      subst hll', obtain ⟨ hf₁f₁' , hf₂f₂'⟩ := list.append_inj h hlenϕ, congr,\n      { simp at hf₁, specialize hf₁ f₁' hf₁f₁', subst hf₁ },\n      { simp at hf₂, specialize hf₂ f₂' hf₂f₂', subst hf₂ } },\n    { intros _ _ _ h, simp at h, simpa [h] } },\n  { intros l f₁ hf₁ m, apply @bounded_formula.rec2 _\n      (λ n y, logic_symbol_of_formula _ = logic_symbol_of_formula y → _ == y),\n    { intros k h, simp at h, simpa [h], },\n    { intros _ _ _ h, simp at h, simpa [h] },\n    { intros _ _ r, apply hrel r },\n    { intros _ _ _ _ _ h, simp at h, simpa [h] },\n    { intros k f₂ hf₂ h, simp only [logic_symbol_of_formula, bounded_formula.rec2_aux,\n        bounded_formula.rec2, eq_self_iff_true, true_and] at h hf₁,\n      cases h with hlk h, subst hlk, congr1, apply eq_of_heq, apply hf₁, exact h } },\nend\n\nlemma card_le_max [is_algebraic L] {n} (hn : #(bounded_formula L (n + 1))\n    ≤ max (cardinal.sum (λ (m : ulift.{u} ℕ), #(bounded_term L m.down))) ω) :\n  #(bounded_formula L n)\n    ≤ max (cardinal.sum (λ m : ulift.{u} ℕ, #(bounded_term L m.down))) ω :=\ncalc #(bounded_formula L n)\n        = #(W_type (formula_β L n)) :\n  cardinal.mk_congr (bounded_formula_equiv_W_type _)\n    ... ≤ _ : W_type.cardinal_mk_le_max_omega_of_fintype\n    ... ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(bounded_term L n.down))) ω :\nbegin\n  dsimp only [formula_α, atomic_formula_α],\n  apply max_le _ (le_max_right _ _),\n  simp only [cardinal.mk_sum, cardinal.mk_punit, cardinal.mk_prod, cardinal.lift_id],\n  apply le_trans (cardinal.add_le_max _ _) (max_le (max_le _ _) (le_max_right _ _)),\n  { apply le_trans (cardinal.add_le_max _ _) (max_le (max_le _ _) (le_max_right _ _)),\n    { apply le_of_lt, simp },\n    { apply le_trans (cardinal.add_le_max _ _) (max_le (max_le _ _) (le_max_right _ _)),\n      { apply le_trans (cardinal.mul_le_max _ _) (max_le (max_le _ _) (le_max_right _ _)),\n        repeat { apply le_max_of_le_left,\n          apply cardinal.le_sum.{u u} (λ (n : ulift.{u} ℕ), #(bounded_term.{u} L n.down)) ⟨ n ⟩ }},\n      { apply le_max_of_le_right (le_of_lt _),\n        simp } } },\n  { exact hn },\nend\n\nlemma bounded_formula_le_bounded_term [is_algebraic L] :\n  #(bounded_formula L n) ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(bounded_term L n.down))) ω :=\ncalc #(bounded_formula L n)\n        = #(W_type (formula_β L n)) :\n  cardinal.mk_congr (bounded_formula_equiv_W_type _)\n    ... ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(bounded_term L n.down))) ω : sorry\n\n\nlemma sentence_le_bounded_term :\n  #(bounded_formula L 0) ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(bounded_term L n.down))) ω :=\ncalc #(bounded_formula L 0) ≤ #(W_type (formula_β L 0)) : sorry\n     ... ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(bounded_term L n.down))) ω : sorry\n\nlemma sentence_le_functions :\n  #(bounded_formula L 0) ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :=\nbegin\n  apply le_trans (sentence_le_bounded_term),\n  apply max_le _ (le_max_right _ _),\n  apply le_trans (cardinal.sum_le_sup _),\n  simp only [cardinal.mk_denumerable],\n  apply le_trans (cardinal.mul_le_max _ _),\n  apply max_le _ (le_max_right _ _),\n  apply max_le (le_max_right _ _),\n  rw cardinal.sup_le,\n  intro i,\n  apply bounded_term_le_functions,\nend\n\nvariable (L)\n\n/-- Applying `∀` is an injection downwards. -/\ndef bounded_formula_bd_all : bounded_formula L (n+1) → (bounded_formula L n) :=\nλ ϕ, ∀' ϕ\n\n/-- Applying `∀` n times is an injection. \"Dropbox\" -/\ndef bounded_formula_bd_alls : Π n, bounded_formula L n → (bounded_formula L 0)\n| 0 := id\n| (n+1) := (bounded_formula_bd_alls n) ∘ bounded_formula_bd_all L n\n\nvariable {L}\n\nlemma bounded_formula_bd_all_injective : function.injective (bounded_formula_bd_all L n) :=\nλ ϕ ψ, bounded_preformula.bd_all.inj\n\nlemma bounded_formula_bd_alls_injective : Π n, function.injective (bounded_formula_bd_alls L n)\n| 0 := function.injective_id\n| (n+1) := function.injective.comp (bounded_formula_bd_alls_injective n) (bounded_formula_bd_all_injective n)\n\n/- Using ∀ we can embed `bounded_formula L (n+1)` into `bounded_formula L n`,\n  hence showing they are all bounded by the function symbols\n -/\nlemma bounded_formula_le_functions (n : ℕ) :\n  #(bounded_formula L n) ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :=\ncalc #(bounded_formula L n) ≤ #(bounded_formula L 0) : cardinal.mk_le_of_injective (bounded_formula_bd_alls_injective _)\n                        ... ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :\n                        sentence_le_functions\n\nend cardinal\n\nend fol\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/cardinal1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.4728288077426518}}
{"text": "import combinatorics.simple_graph.coloring\n\n\n--OUTPUT 1\ntheorem two_colorable_bipartite (G : Type*) [simple_graph G] : \n  (∃ (V1 V2 : set G), (∀ (v : G), v ∈ V1 ∨ v ∈ V2) ∧ (∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)))) ↔ (∃ (V1 V2 : set G), (∀ (v : G), v ∈ V1 ∨ v ∈ V2) ∧ (∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)))) :=\nbegin\n  have h1 : (∃ (V1 V2 : set G), (∀ (v : G), v ∈ V1 ∨ v ∈ V2) ∧ (∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)))), from by {\n    assume (V1 : set G) (V2 : set G) (h1 : ∀ (v : G), v ∈ V1 ∨ v ∈ V2) (h2 : ∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1))),\n    have h3 : ∀ (v : G), v ∈ V1 ∨ v ∈ V2, from by assume v : G,\n      have (v ∈ V1 ∨ v ∈ V2) ∨ (v ∈ V1 ∨ v ∈ V2), from or.inl (h1 v),\n      or.elim (or.inl (h1 v)) (\n        assume h4 : v ∈ V1 ∨ v ∈ V2,\n        show v ∈ V1 ∨ v ∈ V2, from or.inl h4\n      ) (\n        assume h5 : v ∈ V1 ∨ v ∈ V2,\n        show v ∈ V1 ∨ v ∈ V2, from or.inr h5\n      ),\n    have h4 : ∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)), from by assume (e : G) (he : edge e),\n      have ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)) ∨ ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)), from or.inl (h2 e he),\n      or.elim (or.inl (h2 e he)) (\n        assume h5 : (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1),\n        show (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1), from or.inl h5\n      ) (\n        assume h6 : (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1),\n        show (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1), from or.inr h6\n      ),\n    have h5 : (∀ (v : G), v ∈ V1 ∨ v ∈ V2) ∧ (∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1))), from and.intro h3 h4,\n    show ∃ (V1 V2 : set G), (∀ (v : G), v ∈ V1 ∨ v ∈ V2) ∧ (∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1))), from exists.intro V1 (exists.intro V2 h5),\n  },\n  have h2 : (∃ (V1 V2 : set G), (∀ (v : G), v ∈ V1 ∨ v ∈ V2) ∧ (∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)))), from by {\n    assume (V1 : set G) (V2 : set G) (h1 : ∀ (v : G), v ∈ V1 ∨ v ∈ V2) (h2 : ∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1))),\n    have h3 : ∀ (v : G), v ∈ V1 ∨ v ∈ V2, from by assume v : G,\n      have (v ∈ V1 ∨ v ∈ V2) ∨ (v ∈ V1 ∨ v ∈ V2), from or.inr (h1 v),\n      or.elim (or.inr (h1 v)) (\n        assume h4 : v ∈ V1 ∨ v ∈ V2,\n        show v ∈ V1 ∨ v ∈ V2, from or.inl h4\n      ) (\n        assume h5 : v ∈ V1 ∨ v ∈ V2,\n        show v ∈ V1 ∨ v ∈ V2, from or.inr h5\n      ),\n    have h4 : ∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)), from by assume (e : G) (he : edge e),\n      have ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)) ∨ ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1)), from or.inr (h2 e he),\n      or.elim (or.inr (h2 e he)) (\n        assume h5 : (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1),\n        show (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1), from or.inl h5\n      ) (\n        assume h6 : (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1),\n        show (e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1), from or.inr h6\n      ),\n    have h5 : (∀ (v : G), v ∈ V1 ∨ v ∈ V2) ∧ (∀ (e : G), (edge e) → ((e.left ∈ V1 ∧ e.right ∈ V2) ∨ (e.left ∈ V2 ∧ e.right ∈ V1))), from and.intro h3 h4,\n    show ∃ (V1 V2 : set G\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem bipartite_graph_is_two_colorable (G : Type*) [graph G] : ∀ g : G, twocolorable g ↔ bipartite g :=\nbegin\n  assume (g : G),\n  have h1 : twocolorable g → bipartite g, from by {\n    assume h2 : twocolorable g,\n    have h3 : ∃ a b : set (vertex g), a ∩ b = ∅ ∧ a ∪ b = vertex g ∧ ∀ e : edge g, (endpoint g e).fst ∈ a ∧ (endpoint g e).snd ∈ b, from by {\n      have h4 : ∃ a b : vertex g, color g a ≠ color g b, from by {\n        have h5 : ∀ v : vertex g, color g v = red ∨ color g v = blue, from by {\n          assume v : vertex g,\n          have h6 : ∀ v : vertex g, color g v = red, from by {\n            assume v : vertex g,\n            have h7 : ∀ v : vertex g, ∃ c : color g v, color g v = c, from by {\n              assume v : vertex g,\n              show ∃ c : color g v, color g v = c, from by {\n                have h8 : color g v = red ∨ color g v = blue, from \n                  exists_or_distrib.elim (h2 v),\n                cases h8,\n                  use red, exact h8,\n                  use blue, exact h8,\n              },\n            },\n            show color g v = red, from (h7 v).elim (assume c, assume h9, h9),\n          },\n          show ∀ v : vertex g, color g v = red ∨ color g v = blue, from by {\n            assume v : vertex g,\n            have h6 : color g v = red ∨ color g v = blue, from \n              exists_or_distrib.elim (h2 v),\n            cases h6,\n              exact or.inl h6,\n              exact or.inr h6,\n          },\n        },\n        show ∃ a b : vertex g, color g a ≠ color g b, from by {\n          have h6 : ∃ a : vertex g, color g a = red, from by {\n            have h7 : ∀ a : vertex g, color g a = red, from by {\n              assume a : vertex g,\n              have h8 : ∃ c : color g a, color g a = c, from by {\n                have h9 : color g a = red ∨ color g a = blue, from \n                  exists_or_distrib.elim (h2 a),\n                cases h9,\n                  use red, exact h9,\n                  use blue, exact h9,\n              },\n              show color g a = red, from (h8).elim (assume c, assume h10, h10),\n            },\n            show ∃ a : vertex g, color g a = red, from by {\n              have h8 : ∀ a : vertex g, ∃ c : color g a, color g a = c, from by {\n                assume a : vertex g,\n                show ∃ c : color g a, color g a = c, from by {\n                  have h9 : color g a = red ∨ color g a = blue, from \n                    exists_or_distrib.elim (h2 a),\n                  cases h9,\n                    use red, exact h9,\n                    use blue, exact h9,\n                },\n              },\n              show ∃ a : vertex g, color g a = red, from (h8 (arbitrary_vertex g)).elim (assume c, assume h10, ⟨arbitrary_vertex g, h10⟩),\n            },\n          },\n          have h7 : ∃ b : vertex g, color g b = blue, from by {\n            have h8 : ∃ b : vertex g, color g b = blue, from by {\n              have h9 : ∀ b : vertex g, color g b = blue, from by {\n                assume b : vertex g,\n                have h10 : ∃ c : color g b, color g b = c, from by {\n                  have h11 : color g b = red ∨ color g b = blue, from \n                    exists_or_distrib.elim (h2 b),\n                  cases h11,\n                    use red, exact h11,\n                    use blue, exact h11,\n                },\n                show color g b = blue, from (h10).elim (assume c, assume h12, h12),\n              },\n              show ∃ b : vertex g, color g b = blue, from by {\n                have h10 : ∀ b : vertex g, ∃ c : color g b, color g b = c, from by {\n                  assume b : vertex g,\n                  show ∃ c : color g b, color g b = c, from by {\n                    have h11 : color g b = red ∨ color g b = blue, from \n                      exists_or_distrib.elim (h2 b),\n                    cases h11,\n                      use red, exact h11,\n                      use blue, exact h11,\n                  },\n                },\n                show ∃ b : vertex g, color g b = blue, from (h10 (arbitrary_vertex g)).elim (assume c, assume h12, ⟨arbitrary_vertex g, h12⟩),\n              },\n            },\n            show ∃ b : vertex g, color g b = blue, from by {\n              have h9 : ∃ b : vertex g, color g b = blue, from by {\n                have h10 : ∀ b : vertex g, color g b = blue, from by {\n                  assume b : vertex g,\n                  have h11 : ∃ c : color g b, color g b = c, from by {\n                    have h12 : color g b = red ∨ color g b = blue, from \n                      exists_or_distrib.elim (h2 b),\n                    cases h12,\n                      use red, exact h12,\n                      use blue, exact h12,\n                  },\n                  show color g b = blue, from (h11).elim (assume c, assume h13, h13),\n                },\n                show ∃ b : vertex g, color g b = blue, from by {\n                  have h11 : ∀ b : vertex g, ∃ c : color g b, color g b = c, from by {\n                    assume b : vertex g,\n                    show ∃ c : color g b, color g b = c, from by {\n                      have h12 : color g b = red ∨ color g b = blue, from \n                        exists_or_distrib.elim (h2 b),\n                      cases h12,\n                        use red, exact h12,\n                        use blue, exact h12,\n                    },\n                  },\n                  show ∃ b : vertex g, color g b = blue, from (h11 (arbitrary_vertex g)).elim (assume c, assume h12, ⟨arbitrary_vertex g, h12⟩),\n                },\n              },\n              show ∃ b : vertex g, color g b = blue, from by {\n                have h10 : ∃ b : vertex g, color g b = blue, from by {\n                  have h11 : ∀ b : vertex g, color g b = blue, from by {\n                    assume b : vertex g,\n                    have h12 : ∃ c : color g b, color g b = c, from by {\n                      have h13 : color g b = red ∨ color g b = blue, from \n                        exists_or_distrib.elim (h2 b),\n                      cases h13,\n                        use red, exact h13,\n                        use blue, exact h13,\n                    },\n                    show color g b = blue, from (h12).elim (assume c, assume h14, h14),\n                  },\n                  show ∃ b : vertex g, color g b = blue, from by {\n                    have h12 : ∀ b : vertex g, ∃ c : color g b, color g b = c, from by {\n                      assume b : vertex g,\n                      show ∃ c : color g b, color g b = c, from by {\n                        have h13 : color g b = red ∨ color g b = blue, from \n                          exists_or_distrib.elim (h2 b\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem bipartite_iff_two_colorable {G : Type*} [graph G] : bipartite G ↔ two_colorable G :=\nbegin\n  split,\n  {\n    assume h : bipartite G,\n    show two_colorable G, from by {\n      -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n      use {colors := {0,1}, color_map := λ v, if v ∈ h.left then 0 else 1},\n      -- this is a valid coloring\n      have hval : ∀ v, v ∈ (vertex_set G) → (color_map v) ∈ (colors), from by {\n        assume v hv,\n        have hl : v ∈ h.left → (color_map v) ∈ (colors), from by {\n          assume hvl,\n          unfold color_map,\n          rw dif_pos hvl,\n          apply set.mem_singleton_iff.mp,\n          apply set.mem_insert,\n          apply set.mem_singleton_iff.mpr,\n          apply eq.refl 0,\n        },\n        have hr : v ∈ h.right → (color_map v) ∈ (colors), from by {\n          assume hvr,\n          unfold color_map,\n          rw dif_neg hvr,\n          apply set.mem_singleton_iff.mp,\n          apply set.mem_insert,\n          apply set.mem_singleton_iff.mpr,\n          apply eq.refl 1,\n        },\n        exact or.elim (set.mem_or_mem_of_mem_union hv) hl hr,\n      },\n      -- and no edge has both endpoints colored the same color.\n      have hne : ∀ e, e ∈ (edge_set G) → (color_map e.x) ≠ (color_map e.y), from by {\n        assume e he,\n        have hx : e.x ∈ h.left ∨ e.x ∈ h.right, from by apply set.mem_or_mem_of_mem_union,\n        have hy : e.y ∈ h.left ∨ e.y ∈ h.right, from by apply set.mem_or_mem_of_mem_union,\n        unfold color_map,\n        have hnx : e.x ∉ h.left → e.x ∈ h.right, from by {\n          assume hnx,\n          apply set.mem_of_mem_diff hx,\n          exact hnx,\n        },\n        have hny : e.y ∉ h.left → e.y ∈ h.right, from by {\n          assume hny,\n          apply set.mem_of_mem_diff hy,\n          exact hny,\n        },\n        exact or.elim (em (e.x ∈ h.left)) (λ hl, or.elim (em (e.y ∈ h.left)) (λ hyl, (mt dif_pos hl) hyl) (λ hyr, (mt dif_pos hl) hyr)) (λ hr, or.elim (em (e.y ∈ h.left)) (λ hyl, (mt dif_neg (hnx hr)) hyl) (λ hyr, (mt dif_neg (hnx hr)) hyr))\n      },\n      exact ⟨hval,hne⟩,\n    },\n  },\n  {\n    assume h : two_colorable G,\n    show bipartite G, from by {\n      -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n      use {left := {v | ((h.color_map v) = 0) }, right := {v | ((h.color_map v) = 1) }},\n      -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n      have hne : ∀ e, e ∈ (edge_set G) → e.x ∈ (h.left) → e.y ∈ (h.right), from by {\n        assume e he hx,\n        have hx' : (h.color_map e.x) = 0, from by {\n          unfold h.left,\n          rw set.mem_set_of_eq,\n          exact hx,\n        },\n        have hy' : (h.color_map e.y) = 1, from by {\n          unfold h.right,\n          have hy : (h.color_map e.y) ≠ 0, from by {\n            rw h.ne e he,\n            exact hx',\n          },\n          rw set.mem_set_of_eq,\n          exact hy,\n        },\n        unfold h.right,\n        rw set.mem_set_of_eq,\n        exact hy',\n      },\n      -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n      exact ⟨hne⟩,\n    }\n  }\nend\n\n--OUTPUT 4\ntheorem two_colorable_graph_is_bipartite (G : Type*) [simple_graph G] : \n  ∀ (V1 V2 : set G) (h1 : disjoint V1 V2) (h2 : ∀ v w : G, v ≠ w → (v ∈ V1 ∧ w ∈ V2) ∨ (v ∈ V2 ∈ w ∈ V1)), \n    ∀ v : G, ∃! c : color, color_graph G v c :=\nbegin\n  -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n  assume (V1 V2 : set G) (h1 : disjoint V1 V2) (h2 : ∀ v w : G, v ≠ w → (v ∈ V1 ∧ w ∈ V2) ∨ (v ∈ V2 ∧ w ∈ V1)), \n  -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n  let A := {v : G | ∃ c : color, color_graph G v c ∧ c = red},\n  let B := {v : G | ∃ c : color, color_graph G v c ∧ c = blue},\n\n  -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n  have h3 : ∀ v w : G, (v ∈ A ∧ w ∈ A) → ¬ edge_graph G v w, from assume v w : G, assume h3 : (v ∈ A ∧ w ∈ A),\n    have h4 : ∃ c1 : color, color_graph G v c1 ∧ c1 = red, from h3.left,\n    have h5 : ∃ c2 : color, color_graph G w c2 ∧ c2 = red, from h3.right,\n    have h6 : color_graph G v red ∧ color_graph G w red, from and.intro (h4.left) (h5.left),\n    show ¬ edge_graph G v w, from by {apply two_color_graph_no_edge,exact h6},\n  have h4 : ∀ v w : G, (v ∈ B ∧ w ∈ B) → ¬ edge_graph G v w, from assume v w : G, assume h4 : (v ∈ B ∧ w ∈ B),\n    have h5 : ∃ c1 : color, color_graph G v c1 ∧ c1 = blue, from h4.left,\n    have h6 : ∃ c2 : color, color_graph G w c2 ∧ c2 = blue, from h4.right,\n    have h7 : color_graph G v blue ∧ color_graph G w blue, from and.intro (h5.left) (h6.left),\n    show ¬ edge_graph G v w, from by {apply two_color_graph_no_edge,exact h7},\n\n  -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n  have h5 : ∀ v w : G, edge_graph G v w → (v ∈ A ∧ w ∈ B) ∨ (v ∈ B ∧ w ∈ A), from \n    assume v w : G, assume h5 : edge_graph G v w,\n    have h6 : ¬ color_graph G v red ∨ ¬ color_graph G w red, from by {apply two_color_graph_no_edge,exact h5},\n    have h7 : ¬ color_graph G v blue ∨ ¬ color_graph G w blue, from by {apply two_color_graph_no_edge,exact h5},\n    or.elim h6 (assume h8 : ¬ color_graph G v red, or.elim h7 (assume h9 : ¬ color_graph G w blue,\n      begin\n        have h10 : ∃ c1 : color, color_graph G v c1 ∧ c1 = blue, from by {use blue, exact and.intro h9 rfl},\n        have h11 : ∃ c2 : color, color_graph G w c2 ∧ c2 = red, from by {use red, exact and.intro h8 rfl},\n        show (v ∈ B ∧ w ∈ A) ∨ (v ∈ A ∧ w ∈ B), from by {right,exact ⟨h10,h11⟩},\n      end\n    )\n    (assume h9 : color_graph G w blue,\n      begin\n        have h10 : ∃ c1 : color, color_graph G v c1 ∧ c1 = blue, from by {use blue, exact and.intro h9 rfl},\n        have h11 : ∃ c2 : color, color_graph G w c2 ∧ c2 = blue, from by {use blue, exact h9},\n        show (v ∈ B ∧ w ∈ A) ∨ (v ∈ A ∧ w ∈ B), from by {left,exact ⟨h10,h11⟩},\n      end\n    )\n    )\n    (assume h8 : color_graph G v red, or.elim h7 (assume h9 : ¬ color_graph G w blue,\n      begin\n        have h10 : ∃ c1 : color, color_graph G v c1 ∧ c1 = red, from by {use red, exact h8},\n        have h11 : ∃ c2 : color, color_graph G w c2 ∧ c2 = red, from by {use red, exact and.intro h9 rfl},\n        show (v ∈ B ∧ w ∈ A) ∨ (v ∈ A ∧ w ∈ B), from by {right,exact ⟨h10,h11⟩},\n      end\n    )\n    (assume h9 : color_graph G w blue,\n      begin\n        have h10 : ∃ c1 : color, color_graph G v c1 ∧ c1 = red, from by {use red, exact h8},\n        have h11 : ∃ c2 : color, color_graph G w c2 ∧ c2 = blue, from by {use blue, exact h9},\n        show (v ∈ B ∧ w ∈ A) ∨ (v ∈ A ∧ w ∈ B), from by {left,exact ⟨h10,h11⟩},\n      end\n    )\n    ),\n  have h6 : ∀ v w : G, edge_graph G v w → v ∈ A ∧ w ∈ B, from assume v w : G, assume h6 : edge_graph G v w,\n    or.elim (h5 v w h6) (assume h7 : v ∈ B ∧ w ∈ A,\n      begin\n        have h8 : v ∈ A ∧ w ∈ B, from by {split,\n          show v ∈ A, from by {rw A,existsi red,exact ⟨h7.right.left,rfl⟩},\n          show w ∈ B, from by {rw B,existsi blue,exact ⟨h7.left.left,rfl⟩},},\n        exact h8,\n      end\n    )\n    (assume h7 : v ∈ A ∧ w ∈ B, h7),\n\n  -- Conversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$.\n  have h7 : ∀ v w : G, edge_graph G v w → v ∈ V1 ∧ w ∈ V2 ∨ v ∈ V2 ∧ w ∈ V1, from \n    assume v w : G, assume h7 : edge_graph G v w, h6 v w h7,\n  have h8 : ∀ v w : G, v ∈ V1 ∧ w ∈ V2 → edge_graph G v w, from \n    assume v w : G, assume h8 : v ∈ V1 ∧ w ∈ V2, or.elim (h7 v\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem two_coloring_bipartite (G : Type*) [graph G] : \n  (∀ A B : G, ∀ x y : G, (x ∈ A ∧ y ∈ B) ∨ (x ∈ B ∧ y ∈ A)) ↔ (∃ A B : G, ∀ x y : G, (x ∈ A ∧ y ∈ B) ∨ (x ∈ B ∧ y ∈ A)) :=\nbegin\n  -- A graph G is 2-colorable iff G is bipartite\n  split,\n  -- A graph G is 2-colorable implies G is bipartite\n  {\n    assume h2col : ∀ A B : G, ∀ x y : G, (x ∈ A ∧ y ∈ B) ∨ (x ∈ B ∧ y ∈ A),\n    show ∃ A B : G, ∀ x y : G, (x ∈ A ∧ y ∈ B) ∨ (x ∈ B ∧ y ∈ A), from\n    begin\n      use {A : G | true},\n      use {B : G | true},\n      assume x y : G,\n      have h3 : ∃! C : G, x ∈ C, from by {\n        use {x : G | true},\n        rw mem_set_of,\n        exact ⟨trivial, by {obviously}⟩,\n      },\n      have h4 : ∃! D : G, y ∈ D, from by {\n        use {y : G | true},\n        rw mem_set_of,\n        exact ⟨trivial, by {obviously}⟩,\n      },\n      have h5 : ∃! A : G, x ∈ A, from by {\n        have h6 : ∃! A : G, (∃ z : G, z ∈ A), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h7 : ∃! A : G, (∃ z : G, z ∈ A) ∧ x ∈ A, from by {\n          use {A : G | x ∈ A},\n          obviously,\n        },\n        exact h7,\n      },\n      have h8 : ∃! B : G, y ∈ B, from by {\n        have h9 : ∃! B : G, (∃ z : G, z ∈ B), from by {\n          use {B : G | true},\n          obviously,\n        },\n        have h10 : ∃! B : G, (∃ z : G, z ∈ B) ∧ y ∈ B, from by {\n          use {B : G | y ∈ B},\n          obviously,\n        },\n        exact h10,\n      },\n      have h11 : ∃! C : G, x ∈ C ∧ y ∈ C, from by {\n        use {C : G | x ∈ C ∧ y ∈ C},\n        obviously,\n      },\n      have h12 : ∃! A : G, x ∈ A ∧ y ∈ A, from by {\n        have h13 : ∃! A : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ A), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h14 : ∃! A : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ A) ∧ x ∈ A ∧ y ∈ A, from by {\n          use {A : G | x ∈ A ∧ y ∈ A},\n          obviously,\n        },\n        exact h14,\n      },\n      have h15 : ∃! B : G, x ∈ B ∧ y ∈ B, from by {\n        use {B : G | x ∈ B ∧ y ∈ B},\n        obviously,\n      },\n      have h16 : ∃! A : G, x ∈ A ∧ y ∈ B, from by {\n        have h17 : ∃! A : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h18 : ∃! A : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ x ∈ A ∧ y ∈ B, from by {\n          use {A : G | x ∈ A ∧ y ∈ B},\n          obviously,\n        },\n        exact h18,\n      },\n      have h19 : ∃! B : G, x ∈ B ∧ y ∈ A, from by {\n        have h20 : ∃! B : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B), from by {\n          use {B : G | true},\n          obviously,\n        },\n        have h21 : ∃! B : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ x ∈ B ∧ y ∈ A, from by {\n          use {B : G | x ∈ B ∧ y ∈ A},\n          obviously,\n        },\n        exact h21,\n      },\n      have h22 : ∃! A : G, x ∈ A ∧ y ∈ B ∧ x ∈ B ∧ y ∈ A, from by {\n        have h23 : ∃! A : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ (∃ z : G, z ∈ B) ∧ (∃ w : G, w ∈ A), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h24 : ∃! A : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ (∃ z : G, z ∈ B) ∧ (∃ w : G, w ∈ A) ∧ x ∈ A ∧ y ∈ B ∧ x ∈ B ∧ y ∈ A, from by {\n          use {A : G | x ∈ A ∧ y ∈ B ∧ x ∈ B ∧ y ∈ A},\n          obviously,\n        },\n        exact h24,\n      },\n      have h25 : ∃! B : G, x ∈ B ∧ y ∈ A ∧ x ∈ A ∧ y ∈ B, from by {\n        have h26 : ∃! B : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B), from by {\n          use {B : G | true},\n          obviously,\n        },\n        have h27 : ∃! B : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ x ∈ B ∧ y ∈ A ∧ x ∈ A ∧ y ∈ B, from by {\n          use {B : G | x ∈ B ∧ y ∈ A ∧ x ∈ A ∧ y ∈ B},\n          obviously,\n        },\n        exact h27,\n      },\n      have h28 : ∃! A : G, x ∈ A ∧ y ∈ B ∧ x ∈ B ∧ y ∈ A ∧ x ∈ A ∧ y ∈ B ∧ x ∈ B ∧ y ∈ A, from by {\n        have h29 : ∃! A : G, (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ (∃ z : G, z ∈ B) ∧ (∃ w : G, w ∈ A) ∧ (∃ z : G, z ∈ A) ∧ (∃ w : G, w ∈ B) ∧ (∃ z : G, z ∈ B\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem graph_bipartite_iff_two_colorable (G : Type*) [graph G] : \n∀ g : G, bipartite g ↔ two_colorable g :=\nbegin\n  -- Let $G$ be a 2-colorable graph\n  assume g : G,\n  have h1 : ∀ g : G, two_colorable g → bipartite g, from by {\n    assume g : G,\n    assume h2c : two_colorable g,\n    -- which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color\n    have hcoloring : ∃ coloring : coloring g, coloring.is_valid coloring, from h2c,\n    -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n    let coloring : coloring g := classical.some hcoloring,\n    let A : set (vertex g) := coloring.red coloring,\n    let B : set (vertex g) := coloring.blue coloring,\n    -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. \n    have hA : ∀ v : vertex g, (v ∈ A) → (∀ w : vertex g, (v ≠ w) → (v,w) ∉ edge g), from by {\n      assume (v : vertex g) (hv : v ∈ A),\n      assume (w : vertex g) (hvw : v ≠ w),\n      have hvred : coloring.is_red v coloring, from by {\n        have hv : v ∈ vertex g, from by apply set.mem_univ v,\n        show coloring.is_red v coloring, from coloring.is_valid coloring v hv,\n      },\n      have hwred : coloring.is_red w coloring, from by {\n        have hw : w ∈ vertex g, from by apply set.mem_univ w,\n        show coloring.is_red w coloring, from coloring.is_valid coloring w hw,\n      },\n      have hredred : (v,w) ∉ edge g, from\n        two_colorable.no_adjacent_colored_same h2c v hvred w hwred hvw,\n      show (v,w) ∉ edge g, from hredred,\n    },\n    have hB : ∀ v : vertex g, (v ∈ B) → (∀ w : vertex g, (v ≠ w) → (v,w) ∉ edge g), from by {\n      assume (v : vertex g) (hv : v ∈ B),\n      assume (w : vertex g) (hvw : v ≠ w),\n      have hvblue : coloring.is_blue v coloring, from by {\n        have hv : v ∈ vertex g, from by apply set.mem_univ v,\n        show coloring.is_blue v coloring, from coloring.is_valid coloring v hv,\n      },\n      have hwblue : coloring.is_blue w coloring, from by {\n        have hw : w ∈ vertex g, from by apply set.mem_univ w,\n        show coloring.is_blue w coloring, from coloring.is_valid coloring w hw,\n      },\n      have hblueblue : (v,w) ∉ edge g, from\n        two_colorable.no_adjacent_colored_same h2c v hvblue w hwblue hvw,\n      show (v,w) ∉ edge g, from hblueblue,\n    },\n    -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n    have hbipartite : bipartite g, from by {\n      show ∀ v w : vertex g, (v ≠ w) → (v,w) ∈ edge g → (v ∈ A ∧ w ∈ B) ∨ (v ∈ B ∧ w ∈ A), from by {\n        assume (v : vertex g) (w : vertex g) (hvw : v ≠ w),\n        assume (hvwedge : (v,w) ∈ edge g),\n        have hvred : coloring.is_red v coloring, from by {\n          have hv : v ∈ vertex g, from by apply set.mem_univ v,\n          show coloring.is_red v coloring, from coloring.is_valid coloring v hv,\n        },\n        have hwred : coloring.is_red w coloring, from by {\n          have hw : w ∈ vertex g, from by apply set.mem_univ w,\n          show coloring.is_red w coloring, from coloring.is_valid coloring w hw,\n        },\n        have hvblue : coloring.is_blue v coloring, from by {\n          have hv : v ∈ vertex g, from by apply set.mem_univ v,\n          show coloring.is_blue v coloring, from coloring.is_valid coloring v hv,\n        },\n        have hwblue : coloring.is_blue w coloring, from by {\n          have hw : w ∈ vertex g, from by apply set.mem_univ w,\n          show coloring.is_blue w coloring, from coloring.is_valid coloring w hw,\n        },\n        or.elim (em (hvred ∧ hwblue)) (assume hvredblue : hvred ∧ hwblue,\n          have hvA : v ∈ A, from by {\n            apply set.mem_of_mem_of_mem_coloring hvredblue.left,\n            show v ∈ vertex g, from by apply set.mem_univ v,\n          },\n          have hwB : w ∈ B, from by {\n            apply set.mem_of_mem_of_mem_coloring hvredblue.right,\n            show w ∈ vertex g, from by apply set.mem_univ w,\n          },\n          show (v ∈ A ∧ w ∈ B) ∨ (v ∈ B ∧ w ∈ A), from or.inl ⟨hvA,hwB⟩)\n          (assume hvbluered : ¬ (hvred ∧ hwblue),\n            have hredblue : hvblue ∧ hwred, from by {\n              show hvblue ∧ hwred, from ⟨hvbluered.left, hvbluered.right.left,⟩\n            },\n            have hvB : v ∈ B, from by {\n              apply set.mem_of_mem_of_mem_coloring hredblue.left,\n              show v ∈ vertex g, from by apply set.mem_univ v,\n            },\n            have hwA : w ∈ A, from by {\n              apply set.mem_of_mem_of_mem_coloring hredblue.right,\n              show w ∈ vertex g, from by apply set.mem_univ w,\n            },\n            show (v ∈ A ∧ w ∈ B) ∨ (v ∈ B ∧ w ∈ A), from or.inr ⟨hvB, hwA⟩)\n      },\n      show ∀ v w : vertex g, (v ≠ w) → (v,w) ∉ edge g → (v ∈ A ∧ w ∈ A) ∨ (v ∈ B ∧ w ∈ B), from by {\n        assume (v : vertex g) (w : vertex g) (hvw : v ≠ w),\n        assume (hvwnotedge : (v,w) ∉ edge g),\n        have hvA : v ∈ A, from set.mem_of_mem_of_mem_coloring hvwnotedge (h1 g).left hvw,\n        have hwA : w ∈ A, from set.mem_of_mem_of_mem_coloring hvwnotedge (h1 g).left hvw,\n        show (v ∈ A ∧ w ∈ A) ∨ (v ∈ B ∧ w ∈ B), from or.inl ⟨hvA,hwA⟩,\n      },\n    },\n    show bipartite g, from hbipartite,\n  },\n  have h2 : ∀ g : G, bipartite g → two_colorable g, from by {\nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem graph_is_bipartite_iff_two_colorable (G : Type*) [graph G] : ∃! color : G → (color_type G), ∀ e : G, e.edges.forall (λ e, e.color ≠ e.other.color) :=\nbegin\n  -- Assume $G$ is a 2-colorable graph\n  assume color : G → (color_type G),\n  assume e : G, assume h : e.edges.forall (λ e, e.color ≠ e.other.color),\n  -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n  let A : set G := {x : G | x.color = color_type.red},\n  let B : set G := {x : G | x.color = color_type.blue},\n  -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n  have h1 : ∀ a ∈ A, a.edges.forall (λ e, e.other ∉ A), from \n    assume a : G, assume hA : a ∈ A,\n    begin\n      assume e : G, assume h2 : e ∈ a.edges,\n      have h3 : e.other.color = color_type.blue, from \n        by {rw ← h, apply h2,},\n      have h4 : a.color = color_type.red, from by {rw ← hA, rw A,},\n      show e.other ∉ A, from by {rw h3, rw h4, rw A, intro h5, cases h5,},\n    end,\n  have h2 : ∀ b ∈ B, b.edges.forall (λ e, e.other ∉ B), from \n    assume b : G, assume hB : b ∈ B,\n    begin\n      assume e : G, assume h2 : e ∈ b.edges,\n      have h3 : e.other.color = color_type.red, from \n        by {rw ← h, apply h2,},\n      have h4 : b.color = color_type.blue, from by {rw ← hB, rw B,},\n      show e.other ∉ B, from by {rw h3, rw h4, rw B, intro h5, cases h5,},\n    end,\n  -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n  have h3 : ∀ e : G, e ∈ G.edges → e.other ∈ A → e.other ∈ B, from\n    assume e : G, assume h4 : e ∈ G.edges, assume h5 : e.other ∈ A,\n    begin\n      have h6 : e ∈ e.other.edges, from by {rw G.edges, exact or.inr h4,},\n      have h7 : e.other ∉ A, from by {apply h1 e.other h5, exact h6,},\n      show e.other ∈ B, from by {rw B, rw h7,},\n    end,\n  -- \n  have h4 : ∀ e : G, e ∈ G.edges → e.other ∈ B → e.other ∈ A, from\n    assume e : G, assume h4 : e ∈ G.edges, assume h5 : e.other ∈ B,\n    begin\n      have h6 : e ∈ e.other.edges, from by {rw G.edges, exact or.inr h4,},\n      have h7 : e.other ∉ B, from by {apply h2 e.other h5, exact h6,},\n      show e.other ∈ A, from by {rw A, rw h7,},\n    end,\n  show G.is_bipartite, from ⟨A, B, h3, h4⟩,\n\n  -- Conversely, suppose $G$ is bipartite\n  assume h1 : G.is_bipartite,\n  let A : set G := h1.left,\n  let B : set G := h1.right,\n  let color : G → color_type G := \n    begin\n      assume e : G,\n      have h2 : ∃! x ∈ A, e ∈ x.edges, from by {\n        use e,\n        have h3 : e ∈ G.edges, from by {rw G.edges, exact or.inl e.edges.left,},\n        have h4 : e.other ∈ A, from by {apply h1.left_right e h3,},\n        have h5 : e ∈ e.other.edges, from by {rw G.edges, exact or.inr e.edges.left,},\n        show e ∈ A, from by {apply exists_unique.unique (h2 e) h4 h5,},\n      end,\n      have h3 : ∃! x ∈ B, e ∈ x.edges, from by {\n        use e,\n        have h4 : e ∈ G.edges, from by {rw G.edges, exact or.inl e.edges.left,},\n        have h5 : e.other ∈ B, from by {apply h1.right_left e h4,},\n        have h6 : e ∈ e.other.edges, from by {rw G.edges, exact or.inr e.edges.left,},\n        show e ∈ B, from by {apply exists_unique.unique (h3 e) h5 h6,},\n      end,\n      show color_type G, from classical.some (h2).property,\n    end,\n  have h2 : ∀ e : G, e.edges.forall (λ e, e.color ≠ e.other.color), from \n    assume e : G,\n    begin\n      assume e : G, assume h2 : e ∈ e.edges,\n      have h3 : e.color = color e, from by {rw e,},\n      have h4 : e.other.color = color e.other, from by {rw e.other,},\n      show e.color ≠ e.other.color, from \n        by {rw ← h3, rw ← h4, intro h5, cases h5,},\n    end,\n  show ∃! color : G → color_type G, from ⟨color, h2⟩,\nend\n\n--OUTPUT 8\ntheorem two_colorable_iff_bipartite (G : Type*) [graph G] : \n  (∃ (c : G → Prop), ∀ (a b : G), (a ≠ b) → (edge a b) → (c a ≠ c b)) ↔ \n  (∃ (V₁ V₂ : set G), ∀ (a : G), a ∈ V₁ ∨ a ∈ V₂ ∧ ∀ (a b : G), (edge a b) → ((a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁))) :=\nbegin\n  --Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n  assume h1 : ∃ (c : G → Prop), ∀ (a b : G), (a ≠ b) → (edge a b) → (c a ≠ c b),\n  --Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n  cases h1 with c h2, \n  have h3 : ∃ (V₁ V₂ : set G), ∀ (a : G), a ∈ V₁ ∨ a ∈ V₂ ∧ ∀ (a b : G), (edge a b) → ((a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁)), from by {\n    --Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n    let V₁ : set G := {a : G | c a},\n    let V₂ : set G := {a : G | ¬(c a)},\n    have h4 : ∀ (a b : G), (a ≠ b) → (edge a b) → (a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁), from by {\n      assume a b : G, assume h5 : (a ≠ b), assume h6 : (edge a b),\n      --This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n      have h7 : c a ≠ c b, from h2 a b h5 h6,\n      have h8 : a ∈ V₁ ∨ a ∈ V₂, from by {\n        cases (c a),\n        {exact or.inl ⟨_, h⟩,},\n        {exact or.inr ⟨_, h⟩,},\n      },\n      have h9 : b ∈ V₁ ∨ b ∈ V₂, from by {\n        cases (c b),\n        {exact or.inl ⟨_, h⟩,},\n        {exact or.inr ⟨_, h⟩,},\n      },\n      cases h8 with h10 h11,\n      {exact or.inl ⟨h10, h9⟩,},\n      {exact or.inr ⟨h11, h8⟩,},\n    },\n    exact ⟨V₁, V₂, h4⟩,\n  },\n  show ∃ (V₁ V₂ : set G), ∀ (a : G), a ∈ V₁ ∨ a ∈ V₂ ∧ ∀ (a b : G), (edge a b) → ((a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁)), from h3,\n\n  --Conversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$.\n  assume h1 : ∃ (V₁ V₂ : set G), ∀ (a : G), a ∈ V₁ ∨ a ∈ V₂ ∧ ∀ (a b : G), (edge a b) → ((a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁)),\n  --Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable.\n  cases h1 with V₁ h2, cases h2 with V₂ h3,\n  have h4 : ∃ (c : G → Prop), ∀ (a b : G), (a ≠ b) → (edge a b) → (c a ≠ c b), from by {\n    let c : G → Prop := λ (a : G), (a ∈ V₁),\n    have h5 : ∀ (a b : G), (a ≠ b) → (edge a b) → (c a ≠ c b), from by {\n      assume a b : G, assume h5 : (a ≠ b), assume h6 : (edge a b),\n      have h7 : a ∈ V₁ ∨ a ∈ V₂, from h3 a,\n      have h8 : b ∈ V₁ ∨ b ∈ V₂, from h3 b,\n      cases h7 with h9 h10,\n      {\n        cases h8 with h11 h12,\n        {\n          have h13 : (a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁), from h3 a b h6,\n          cases h13 with h14 h15,\n          {\n            have h16 : c a ∧ c b, from ⟨h9, h11⟩,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = c b, from by {rw ← h17,rw ← h18},\n              show c a ≠ c b, from h19 ▸ h5,\n            },\n          },\n          {\n            have h16 : c a ∧ ¬c b, from ⟨h9, h12⟩,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = ¬c b, from by {rw ← h17,rw ← h18},\n              show c a ≠ c b, from h19 ▸ h5,\n            },\n          },\n        },\n        {\n          have h13 : (a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁), from h3 a b h6,\n          cases h13 with h14 h15,\n          {\n            have h16 : c a ∧ c b, from ⟨h9, h11⟩,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = c b, from by {rw ← h17,rw ← h18},\n              show c a ≠ c b, from h19 ▸ h5,\n            },\n          },\n          {\n            have h16 : c a ∧ ¬c b, from ⟨h9, h12⟩,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = ¬c b, from by {rw ← h17,rw ← h18},\n              show c a ≠ c b, from h19 ▸ h5,\n            },\n          },\n        },\n      },\n      {\n        cases h8 with h11 h12,\n        {\n          have h13 : (a ∈ V₁ ∧ b ∈ V₂) ∨ (a ∈ V₂ ∧ b ∈ V₁), from h3 a b h6,\n          cases h13 with h14 h15,\n          {\n            have h16 : c\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by rw add_mul\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n    assume a b : G, use a⁻¹ * b, obviously, },\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n    assume a b : G, use b * a⁻¹, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n    exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n    (mul_one a),\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n    exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n        exists_unique.unique (h3 a) (hident a).right\n        (classical.some_spec (exists_unique.exists (h3 a))), \n      have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n        exists_unique.unique (h4 a) (hident a).left\n        (classical.some_spec (exists_unique.exists (h4 a))),\n      show e = (1 : G), from eq.trans (h9 e) (h6 _),     \n    },\n    exact ⟨by obviously, h7⟩,\n  }\nend\n\n/--`theorem`\nBipartite Graph is two colorable\nLet $G$ be a graph. Then $G$ is 2-colorable if and only if $G$ is bipartite.\n`proof`\nLet $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue. Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n\nConversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$. Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable.\n\nQED\n\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_with_comments-Natural-Language-Proof-Translation/lean_proof_with_comments-3_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Bipartite Graph is two colorable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.808067204308405, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.47280105391462596}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module category_theory.category.Twop\n! leanprover-community/mathlib commit c8ab806ef73c20cab1d87b5157e43a82c205f28e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Category.Bipointed\nimport Mathbin.Data.TwoPointing\n\n/-!\n# The category of two-pointed types\n\nThis defines `Twop`, the category of two-pointed types.\n\n## References\n\n* [nLab, *coalgebra of the real interval*]\n  (https://ncatlab.org/nlab/show/coalgebra+of+the+real+interval)\n-/\n\n\nopen CategoryTheory Option\n\nuniverse u\n\nvariable {α β : Type _}\n\n#print TwoP /-\n/-- The category of two-pointed types. -/\nstructure TwoP : Type (u + 1) where\n  pt : Type u\n  toTwoPointing : TwoPointing X\n#align Twop TwoP\n-/\n\nnamespace TwoP\n\ninstance : CoeSort TwoP (Type _) :=\n  ⟨X⟩\n\nattribute [protected] TwoP.X\n\n#print TwoP.of /-\n/-- Turns a two-pointing into a two-pointed type. -/\ndef of {X : Type _} (to_two_pointing : TwoPointing X) : TwoP :=\n  ⟨X, to_two_pointing⟩\n#align Twop.of TwoP.of\n-/\n\n#print TwoP.coe_of /-\n@[simp]\ntheorem coe_of {X : Type _} (to_two_pointing : TwoPointing X) : ↥(of to_two_pointing) = X :=\n  rfl\n#align Twop.coe_of TwoP.coe_of\n-/\n\nalias of ← _root_.two_pointing.Twop\n#align two_pointing.Twop TwoPointing.TwoP\n\ninstance : Inhabited TwoP :=\n  ⟨of TwoPointing.bool⟩\n\n#print TwoP.toBipointed /-\n/-- Turns a two-pointed type into a bipointed type, by forgetting that the pointed elements are\ndistinct. -/\ndef toBipointed (X : TwoP) : Bipointed :=\n  X.toTwoPointing.toProd.Bipointed\n#align Twop.to_Bipointed TwoP.toBipointed\n-/\n\n#print TwoP.coe_toBipointed /-\n@[simp]\ntheorem coe_toBipointed (X : TwoP) : ↥X.toBipointed = ↥X :=\n  rfl\n#align Twop.coe_to_Bipointed TwoP.coe_toBipointed\n-/\n\n#print TwoP.largeCategory /-\ninstance largeCategory : LargeCategory TwoP :=\n  InducedCategory.category toBipointed\n#align Twop.large_category TwoP.largeCategory\n-/\n\n#print TwoP.concreteCategory /-\ninstance concreteCategory : ConcreteCategory TwoP :=\n  InducedCategory.concreteCategory toBipointed\n#align Twop.concrete_category TwoP.concreteCategory\n-/\n\n#print TwoP.hasForgetToBipointed /-\ninstance hasForgetToBipointed : HasForget₂ TwoP Bipointed :=\n  InducedCategory.hasForget₂ toBipointed\n#align Twop.has_forget_to_Bipointed TwoP.hasForgetToBipointed\n-/\n\n#print TwoP.swap /-\n/-- Swaps the pointed elements of a two-pointed type. `two_pointing.swap` as a functor. -/\n@[simps]\ndef swap : TwoP ⥤ TwoP where\n  obj X := ⟨X, X.toTwoPointing.symm⟩\n  map X Y f := ⟨f.toFun, f.map_snd, f.map_fst⟩\n#align Twop.swap TwoP.swap\n-/\n\n/- warning: Twop.swap_equiv -> TwoP.swapEquiv is a dubious translation:\nlean 3 declaration is\n  CategoryTheory.Equivalence.{u1, u1, succ u1, succ u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.{u1} TwoP.largeCategory.{u1}\nbut is expected to have type\n  CategoryTheory.Equivalence.{u1, u1, succ u1, succ u1} TwoP.{u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.largeCategory.{u1}\nCase conversion may be inaccurate. Consider using '#align Twop.swap_equiv TwoP.swapEquivₓ'. -/\n/-- The equivalence between `Twop` and itself induced by `prod.swap` both ways. -/\n@[simps]\ndef swapEquiv : TwoP ≌ TwoP :=\n  Equivalence.mk swap swap\n    (NatIso.ofComponents\n      (fun X =>\n        { Hom := ⟨id, rfl, rfl⟩\n          inv := ⟨id, rfl, rfl⟩ })\n      fun X Y f => rfl)\n    (NatIso.ofComponents\n      (fun X =>\n        { Hom := ⟨id, rfl, rfl⟩\n          inv := ⟨id, rfl, rfl⟩ })\n      fun X Y f => rfl)\n#align Twop.swap_equiv TwoP.swapEquiv\n\n/- warning: Twop.swap_equiv_symm -> TwoP.swapEquiv_symm is a dubious translation:\nlean 3 declaration is\n  Eq.{succ (succ u1)} (CategoryTheory.Equivalence.{u1, u1, succ u1, succ u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.{u1} TwoP.largeCategory.{u1}) (CategoryTheory.Equivalence.symm.{u1, u1, succ u1, succ u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.swapEquiv.{u1}) TwoP.swapEquiv.{u1}\nbut is expected to have type\n  Eq.{succ (succ u1)} (CategoryTheory.Equivalence.{u1, u1, succ u1, succ u1} TwoP.{u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.largeCategory.{u1}) (CategoryTheory.Equivalence.symm.{u1, u1, succ u1, succ u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.{u1} TwoP.largeCategory.{u1} TwoP.swapEquiv.{u1}) TwoP.swapEquiv.{u1}\nCase conversion may be inaccurate. Consider using '#align Twop.swap_equiv_symm TwoP.swapEquiv_symmₓ'. -/\n@[simp]\ntheorem swapEquiv_symm : swapEquiv.symm = swapEquiv :=\n  rfl\n#align Twop.swap_equiv_symm TwoP.swapEquiv_symm\n\nend TwoP\n\n#print TwoP_swap_comp_forget_to_Bipointed /-\n@[simp]\ntheorem TwoP_swap_comp_forget_to_Bipointed :\n    TwoP.swap ⋙ forget₂ TwoP Bipointed = forget₂ TwoP Bipointed ⋙ Bipointed.swap :=\n  rfl\n#align Twop_swap_comp_forget_to_Bipointed TwoP_swap_comp_forget_to_Bipointed\n-/\n\n#print pointedToTwoPFst /-\n/-- The functor from `Pointed` to `Twop` which adds a second point. -/\n@[simps]\ndef pointedToTwoPFst : Pointed.{u} ⥤ TwoP\n    where\n  obj X := ⟨Option X, ⟨X.point, none⟩, some_ne_none _⟩\n  map X Y f := ⟨Option.map f.toFun, congr_arg _ f.map_point, rfl⟩\n  map_id' X := Bipointed.Hom.ext _ _ Option.map_id\n  map_comp' X Y Z f g := Bipointed.Hom.ext _ _ (Option.map_comp_map _ _).symm\n#align Pointed_to_Twop_fst pointedToTwoPFst\n-/\n\n#print pointedToTwoPSnd /-\n/-- The functor from `Pointed` to `Twop` which adds a first point. -/\n@[simps]\ndef pointedToTwoPSnd : Pointed.{u} ⥤ TwoP\n    where\n  obj X := ⟨Option X, ⟨none, X.point⟩, (some_ne_none _).symm⟩\n  map X Y f := ⟨Option.map f.toFun, rfl, congr_arg _ f.map_point⟩\n  map_id' X := Bipointed.Hom.ext _ _ Option.map_id\n  map_comp' X Y Z f g := Bipointed.Hom.ext _ _ (Option.map_comp_map _ _).symm\n#align Pointed_to_Twop_snd pointedToTwoPSnd\n-/\n\n#print pointedToTwoPFst_comp_swap /-\n@[simp]\ntheorem pointedToTwoPFst_comp_swap : pointedToTwoPFst ⋙ TwoP.swap = pointedToTwoPSnd :=\n  rfl\n#align Pointed_to_Twop_fst_comp_swap pointedToTwoPFst_comp_swap\n-/\n\n#print pointedToTwoPSnd_comp_swap /-\n@[simp]\ntheorem pointedToTwoPSnd_comp_swap : pointedToTwoPSnd ⋙ TwoP.swap = pointedToTwoPFst :=\n  rfl\n#align Pointed_to_Twop_snd_comp_swap pointedToTwoPSnd_comp_swap\n-/\n\n#print pointedToTwoPFst_comp_forget_to_bipointed /-\n@[simp]\ntheorem pointedToTwoPFst_comp_forget_to_bipointed :\n    pointedToTwoPFst ⋙ forget₂ TwoP Bipointed = pointedToBipointedFst :=\n  rfl\n#align Pointed_to_Twop_fst_comp_forget_to_Bipointed pointedToTwoPFst_comp_forget_to_bipointed\n-/\n\n#print pointedToTwoPSnd_comp_forget_to_bipointed /-\n@[simp]\ntheorem pointedToTwoPSnd_comp_forget_to_bipointed :\n    pointedToTwoPSnd ⋙ forget₂ TwoP Bipointed = pointedToBipointedSnd :=\n  rfl\n#align Pointed_to_Twop_snd_comp_forget_to_Bipointed pointedToTwoPSnd_comp_forget_to_bipointed\n-/\n\n#print pointedToTwoPFstForgetCompBipointedToPointedFstAdjunction /-\n/-- Adding a second point is left adjoint to forgetting the second point. -/\ndef pointedToTwoPFstForgetCompBipointedToPointedFstAdjunction :\n    pointedToTwoPFst ⊣ forget₂ TwoP Bipointed ⋙ bipointedToPointedFst :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_fst⟩\n          invFun := fun f => ⟨fun o => o.elim Y.toTwoPointing.toProd.2 f.toFun, f.map_point, rfl⟩\n          left_inv := fun f => by\n            ext\n            cases x\n            exact f.map_snd.symm\n            rfl\n          right_inv := fun f => Pointed.Hom.ext _ _ rfl }\n      homEquiv_naturality_left_symm := fun X' X Y f g =>\n        by\n        ext\n        cases x <;> rfl }\n#align Pointed_to_Twop_fst_forget_comp_Bipointed_to_Pointed_fst_adjunction pointedToTwoPFstForgetCompBipointedToPointedFstAdjunction\n-/\n\n#print pointedToTwoPSndForgetCompBipointedToPointedSndAdjunction /-\n/-- Adding a first point is left adjoint to forgetting the first point. -/\ndef pointedToTwoPSndForgetCompBipointedToPointedSndAdjunction :\n    pointedToTwoPSnd ⊣ forget₂ TwoP Bipointed ⋙ bipointedToPointedSnd :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => ⟨f.toFun ∘ Option.some, f.map_snd⟩\n          invFun := fun f => ⟨fun o => o.elim Y.toTwoPointing.toProd.1 f.toFun, rfl, f.map_point⟩\n          left_inv := fun f => by\n            ext\n            cases x\n            exact f.map_fst.symm\n            rfl\n          right_inv := fun f => Pointed.Hom.ext _ _ rfl }\n      homEquiv_naturality_left_symm := fun X' X Y f g =>\n        by\n        ext\n        cases x <;> rfl }\n#align Pointed_to_Twop_snd_forget_comp_Bipointed_to_Pointed_snd_adjunction pointedToTwoPSndForgetCompBipointedToPointedSndAdjunction\n-/\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Category/Twop.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6926419958239131, "lm_q1q2_score": 0.47277923370033376}}
{"text": "/-\nCopyright (c) 2021 Yourong Zang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yourong Zang\n-/\nimport topology.separation\nimport topology.opens\n\n/-!\n# The Alexandroff Compactification\nWe construct the Alexandroff compactification of an arbitrary topological space `X` and prove\nsome properties inherited from `X`.\n\n## Main defintion\n* `alexandroff`: the Alexandroff compactification\n* `of`: the inclusion map defined by `option.some`. This map requires the argument\n        `topological_space X`\n* `infty`: the extra point\n\n## Main results\n* The topological structure of `alexandroff X`\n* The connectedness of `alexandroff X` for noncompact, preconnected `X`\n* `alexandroff X` is `T₁` for a T₁ space `X`\n* `alexandroff X` is Hausdorff if `X` is locally compact and Hausdorff\n-/\n\nnoncomputable theory\nopen set\nopen_locale classical topological_space filter\n\nsection option_topology\n\n/-- The one-point extension of a topological space -/\n@[reducible]\ndef one_point_extension (X : Type*) [topological_space X] :\n  topological_space (option X) :=\n{ is_open := λ s, if none ∈ s then is_compact (some⁻¹' s)ᶜ ∧ is_open (some⁻¹' s)\n    else is_open (some⁻¹' s),\n  is_open_univ := by simp,\n  is_open_inter :=\n  λ s t hs ht, begin\n    split_ifs at hs ht with h h' h' h' h,\n    { simpa [h, h', compl_inter] using and.intro (hs.1.union ht.1) (hs.2.inter ht.2) },\n    { simpa [h, h'] using hs.inter ht.2 },\n    { simpa [h, h'] using hs.2.inter ht },\n    { simpa [h, h'] using hs.inter ht }\n  end,\n  is_open_sUnion :=\n  λ S ht, begin\n    suffices : is_open (some⁻¹' ⋃₀S),\n    { split_ifs with h,\n      { obtain ⟨(a : set (option X)), ha, ha'⟩ := mem_sUnion.mp h,\n        specialize ht a ha,\n        rw if_pos ha' at ht,\n        refine ⟨compact_of_is_closed_subset ht.left this.is_closed_compl _, this⟩,\n        rw [compl_subset_compl, preimage_subset_iff],\n        intros y hy,\n        refine ⟨a, ha, hy⟩ },\n      { exact this } },\n    rw is_open_iff_forall_mem_open,\n    simp only [and_imp, exists_prop, mem_Union, preimage_sUnion, mem_preimage, exists_imp_distrib],\n    intros y s hs hy,\n    refine ⟨some⁻¹' s, subset_subset_Union _ (subset_subset_Union hs (subset.refl _)), _,\n      mem_preimage.mpr hy⟩,\n    specialize ht s hs,\n    split_ifs at ht,\n    { exact ht.right },\n    { exact ht }\n  end }\n\nlocal attribute [instance] one_point_extension\n\nnamespace one_point_extension\n\nvariables {X : Type*} {s : set (option X)}\n\nlemma some_preimage_none : (some⁻¹' {none} : set X) = ∅ :=\nby { ext, simp }\n\nlemma some_mem_range_some (x : X) : some x ∈ (some '' (univ : set X)) :=\nby simp\n\nlemma none_not_mem_range_some : none ∉ some '' (univ : set X) .\n\n@[simp] lemma none_not_mem_image_some {s : set X} : none ∉ some '' s :=\nnot_mem_subset (image_subset _ $ subset_univ _) none_not_mem_range_some\n\nlemma union_none_eq_univ : (some '' univ ∪ {none}) = (univ : set (option X)) :=\nbegin\n  refine le_antisymm (subset_univ _) _,\n  rintros ⟨_|x⟩;\n  simp\nend\n\nlemma inter_none_eq_empty : (some '' univ) ∩ {none} = (∅ : set (option X)) :=\nby { ext ⟨_|x⟩; simp }\n\nvariables [topological_space X]\n\nlemma is_open_alexandroff_iff_aux :\n  is_open s ↔ if none ∈ s then is_compact (some⁻¹' s)ᶜ ∧ is_open (some⁻¹' s)\n  else is_open (some⁻¹' s) :=\niff.rfl\n\nlemma is_open_iff_of_mem (h : none ∈ s) :\n  is_open s ↔ is_compact (some⁻¹' s)ᶜ ∧ is_closed (some⁻¹' s)ᶜ :=\nby simp [is_open_alexandroff_iff_aux, h, is_closed_compl_iff]\n\nlemma is_open_iff_of_not_mem (h : none ∉ s) :\n  is_open s ↔ is_open (some⁻¹' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_of_is_open (h : is_open s) :\n  is_open (some⁻¹' s) :=\nbegin\n  by_cases H : none ∈ s,\n  { simpa using ((is_open_iff_of_mem H).mp h).2 },\n  { exact (is_open_iff_of_not_mem H).mp h }\nend\n\nlemma is_open_map_some : is_open_map (@some X) :=\nλ s hs, begin\n  rw [← preimage_image_eq s (option.some_injective X)] at hs,\n  rwa is_open_iff_of_not_mem none_not_mem_image_some\nend\n\nlemma continuous_some : continuous (@some X) :=\ncontinuous_def.mpr (λ s hs, is_open_of_is_open hs)\n\n/-- An open set of the extension constructed from a closed compact set in `X`-/\ndef opens_of_compl {s : set X} (h : is_compact s ∧ is_closed s) :\n  topological_space.opens (option X) :=\n⟨(some '' s)ᶜ, by { rw [is_open_iff_of_mem ((mem_compl_iff _ _).mpr none_not_mem_image_some),\n  preimage_compl, compl_compl, (option.some_injective X).preimage_image _], assumption' }⟩\n\nlemma none_mem_opens_of_compl {s : set X} (h : is_compact s ∧ is_closed s) :\n  none ∈ (opens_of_compl h) :=\nby { simp only [opens_of_compl, topological_space.opens.coe_mk],\n     exact mem_compl none_not_mem_image_some }\n\n/-- The one-point extension is compact -/\n@[reducible, nolint def_lemma]\ndef compact_space (X : Type*) [topological_space X] : \n  compact_space (option X) :=\n{ compact_univ :=\n  begin\n    refine is_compact_of_finite_subcover (λ ι Z h H, _),\n    simp only [univ_subset_iff] at H ⊢,\n    rcases Union_eq_univ_iff.mp H none with ⟨K, hK⟩,\n    have minor₁ : is_compact (some⁻¹' Z K)ᶜ,\n    { specialize h K, rw is_open_iff_of_mem hK at h, exact h.1 },\n    let p : ι → set X := λ i, some⁻¹' Z i,\n    have minor₂ : ∀ i, is_open (p i) := λ i, is_open_of_is_open (h i),\n    have minor₃ : (some⁻¹' Z K)ᶜ ⊆ ⋃ i, p i :=\n      by simp only [p, ← preimage_Union, H, preimage_univ, subset_univ],\n    rcases is_compact_iff_finite_subcover.mp minor₁ p minor₂ minor₃ with ⟨ι', H'⟩,\n    refine ⟨insert K ι', _⟩,\n    rw ← preimage_compl at H',\n    simp only [Union_eq_univ_iff],\n    intros x,\n    by_cases hx : x ∈ Z K,\n    { exact ⟨K, mem_Union.mpr ⟨finset.mem_insert_self _ _, hx⟩⟩ },\n    { have triv₁ : x ≠ none := (ne_of_mem_of_not_mem hK hx).symm,\n      rcases option.ne_none_iff_exists.mp triv₁ with ⟨y, hy⟩,\n      have triv₂ : some y ∈ {x} := mem_singleton_of_eq hy,\n      rw [← mem_compl_iff, ← singleton_subset_iff] at hx,\n      have : some⁻¹' {x} ⊆ some⁻¹' (Z K)ᶜ := λ y hy, hx hy,\n      have key : y ∈ ⋃ (i : ι) (H : i ∈ ι'), p i := this.trans H' (mem_preimage.mpr triv₂),\n      rcases mem_bUnion_iff'.mp key with ⟨i, hi, hyi⟩,\n      refine ⟨i, mem_Union.mpr ⟨finset.subset_insert _ ι' hi, _⟩⟩,\n      simpa [hy] using hyi }\n  end }\n\n/-- The one-point extension of a T₁ space `X` is T₁-/\n@[reducible, nolint def_lemma]\ndef t1_space [t1_space X] : t1_space (option X) :=\n{ t1 :=\n  λ z, begin\n    cases z,\n    { rw [← is_open_compl_iff, compl_eq_univ_diff, ← union_none_eq_univ,\n          union_diff_cancel_right (subset.antisymm_iff.mp inter_none_eq_empty).1],\n      exact is_open_map_some _ is_open_univ },\n    { have : none ∈ ({some z}ᶜ : set (option X)) :=\n        mem_compl (λ w, (option.some_ne_none z).symm (mem_singleton_iff.mp w)),\n      rw [← is_open_compl_iff, is_open_iff_of_mem this],\n      rw [preimage_compl, compl_compl, ← image_singleton, \n          (option.some_injective X).preimage_image _],\n      exact ⟨is_compact_singleton, is_closed_singleton⟩ }\n  end }\n\n/-- The one-point extension of a Hausdorff `X` is Hausdorff -/\n@[reducible, nolint def_lemma]\ndef t2_space [locally_compact_space X] [t2_space X] : t2_space (option X) :=\n{ t2 :=\n  λ x y hxy, begin\n    have key : ∀ (z : option X), z ≠ none →\n      ∃ (u v : set (option X)), is_open u ∧ is_open v ∧ none ∈ u ∧ z ∈ v ∧ u ∩ v = ∅ :=\n    λ z h, begin\n      rcases option.ne_none_iff_exists.mp h with ⟨y', hy'⟩,\n      rcases exists_open_with_compact_closure y' with ⟨u, hu, huy', Hu⟩,\n      have minor₁ : _ ∧ is_closed (closure u) := ⟨Hu, is_closed_closure⟩,\n      refine ⟨opens_of_compl minor₁, some '' u, _⟩,\n      refine ⟨(opens_of_compl minor₁).2, is_open_map_some _ hu,\n        none_mem_opens_of_compl minor₁, ⟨y', huy', hy'⟩, _⟩,\n      simp only [opens_of_compl, topological_space.opens.coe_mk],\n      have minor₂ : (some '' closure u)ᶜ ∩ some '' u ⊆ (some '' u)ᶜ ∩ some '' u,\n      { apply inter_subset_inter_left,\n        simp only [compl_subset_compl, image_subset _ (subset_closure)] },\n      rw compl_inter_self at minor₂,\n      exact eq_empty_of_subset_empty minor₂\n    end,\n    cases x; cases y,\n    { simpa using hxy },\n    { simpa using key y hxy.symm },\n    { rcases key x hxy with ⟨u, v, hu, hv, hxu, hyv, huv⟩,\n      exact ⟨v, u, hv, hu, hyv, hxu, (inter_comm u v) ▸ huv⟩ },\n    { have hxy' : x ≠ y := λ w, hxy ((option.some.inj_eq _ _).mpr w),\n      rcases t2_separation hxy' with ⟨u, v, hu, hv, hxu, hyv, huv⟩,\n      refine ⟨some '' u, some '' v, is_open_map_some _ hu, is_open_map_some _ hv,\n        ⟨x, hxu, rfl⟩, ⟨y, hyv, rfl⟩, _⟩,\n      simp only [image_inter (option.some_injective X), huv, image_empty] }\n  end }\n\nlemma dense_range_some (h : ¬ is_compact (univ : set X)) : dense (some '' (univ : set X)) :=\nbegin\n  refine dense_iff_inter_open.mpr (λ s hs Hs, _),\n  by_cases H : none ∈ s,\n  { rw is_open_iff_of_mem H at hs,\n    have minor₁ : s ≠ {none},\n    { by_contra w,\n      rw [not_not.mp w, some_preimage_none, compl_empty] at hs,\n      exact h hs.1 },\n    have minor₂ : some⁻¹' s ≠ ∅,\n    { by_contra w,\n      rw [not_not, eq_empty_iff_forall_not_mem] at w,\n      simp only [mem_preimage] at w,\n      have : ∀ z ∈ s, z = none := λ z hz,\n        by_contra (λ w', let ⟨x, hx⟩ := option.ne_none_iff_exists'.mp w' in\n          by rw hx at hz; exact (w x) hz),\n      exact minor₁ (eq_singleton_iff_unique_mem.mpr ⟨H, this⟩) },\n    rcases ne_empty_iff_nonempty.mp minor₂ with ⟨x, hx⟩,\n    exact ⟨some x, hx, x, mem_univ _, rfl⟩ },\n  { rcases Hs with ⟨z, hz⟩,\n    rcases option.ne_none_iff_exists'.mp (ne_of_mem_of_not_mem hz H) with ⟨x, hx⟩,\n    rw hx at hz,\n    exact ⟨some x, hz, x, mem_univ _, rfl⟩ }\nend\n\nlemma connected_space [preconnected_space X] (h : ¬ is_compact (univ : set X)) :\n  connected_space (option X) :=\n{ is_preconnected_univ :=\n  begin\n    rw ← dense_iff_closure_eq.mp (dense_range_some h),\n    exact is_preconnected.closure\n      (is_preconnected_univ.image some continuous_some.continuous_on)\n  end,\n  to_nonempty := ⟨none⟩ }\n\nend one_point_extension\n\nend option_topology\n\nsection basic\n\n/-- The Alexandroff extension of an arbitrary topological space `X` -/\n@[nolint unused_arguments]\ndef alexandroff (X : Type*) [topological_space X] := option X\n\nvariables {X : Type*} [topological_space X]\n\n/-- The embedding of `X` to its Alexandroff extension -/\ndef of : X → alexandroff X := some\n\n/-- The range of the embedding -/\ndef range_of (X : Type*) [topological_space X] : set (alexandroff X) := of '' (univ : set X)\n\nlemma of_apply {x : X} : of x = some x := rfl\n\nlemma of_injective : function.injective (@of X _) :=\noption.some_injective X\n\n/-- The extra point in the extension -/\ndef infty : alexandroff X := none\n\nlocal notation `∞` := infty\n\nnamespace alexandroff\n\ninstance : has_coe_t X (alexandroff X) := ⟨of⟩\n\ninstance : inhabited(alexandroff X) := ⟨∞⟩\n\n@[norm_cast] \nlemma coe_eq_coe {x y : X} : (x : alexandroff X) = y ↔ x = y :=\nof_injective.eq_iff\n\n@[simp] lemma coe_ne_infty (x : X) : (x : alexandroff X) ≠ ∞  .\n@[simp] lemma infity_ne_coe (x : X) : ∞ ≠ (x : alexandroff X) .\n@[simp] lemma of_eq_coe {x : X} : (of x : alexandroff X) = x := rfl\n\nprotected lemma prop_infty_of_prop_none {p : option X → Prop} (h : p none) : p infty :=\nby simpa [infty] using h\n\n/-- Recursor for `alexandroff` using the preferred forms `∞` and `↑x`. -/\n@[elab_as_eliminator]\ndef rec_infty_coe (C : alexandroff X → Sort*) (h₁ : C infty) (h₂ : Π (x : X), C x) :\n  Π (z : alexandroff X), C z :=\noption.rec h₁ h₂\n\nlemma ne_infty_iff_exists {x : alexandroff X} : \n  x ≠ infty ↔ ∃ (y : X), x = y :=\nby { induction x using alexandroff.rec_infty_coe; simp }\n\n@[simp] lemma coe_mem_range_of (x : X) : (x : alexandroff X) ∈ (range_of X) :=\none_point_extension.some_mem_range_some x\n\nlemma union_infty_eq_univ : (range_of X ∪ {∞}) = univ :=\none_point_extension.union_none_eq_univ\n\n@[simp] lemma infty_not_mem_range_of : ∞ ∉ range_of X :=\none_point_extension.none_not_mem_image_some\n\n@[simp] lemma not_mem_range_of_iff (x : alexandroff X) :\n  x ∉ range_of X ↔ x = ∞ :=\nby { induction x using alexandroff.rec_infty_coe; simp }\n\n@[simp] lemma infty_not_mem_image_of {s : set X} : ∞ ∉ of '' s :=\none_point_extension.none_not_mem_image_some\n\nlemma inter_infty_eq_empty : (range_of X) ∩ {∞} = ∅ :=\none_point_extension.inter_none_eq_empty\n\nlemma of_preimage_infty : (of⁻¹' {∞} : set X) = ∅ :=\none_point_extension.some_preimage_none\n\nend alexandroff\n\nend basic\n\nsection topology\nopen alexandroff\n\nvariables {X : Type*} [topological_space X]\n\ninstance : topological_space (alexandroff X) := one_point_extension X\n\nvariables {s : set (alexandroff X)} {s' : set X}\n\nlemma is_open_alexandroff_iff_aux :\n  is_open s ↔ if infty ∈ s then is_compact (of⁻¹' s)ᶜ ∧ is_open (of⁻¹' s)\n  else is_open (of⁻¹' s) :=\niff.rfl\n\nlemma is_open_iff_of_mem' (h : infty ∈ s) :\n  is_open s ↔ is_compact (of⁻¹' s)ᶜ ∧ is_open (of⁻¹' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_iff_of_mem (h : infty ∈ s) :\n  is_open s ↔ is_compact (of⁻¹' s)ᶜ ∧ is_closed (of⁻¹' s)ᶜ :=\nby simp [is_open_alexandroff_iff_aux, h, is_closed_compl_iff]\n\nlemma is_open_iff_of_not_mem (h : infty ∉ s) :\n  is_open s ↔ is_open (of⁻¹' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_of_is_open (h : is_open s) :\n  is_open (of⁻¹' s) :=\none_point_extension.is_open_of_is_open h\n\nend topology\n\nsection topological\nopen alexandroff\n\nvariables {X : Type*} [topological_space X]\n\n@[continuity] lemma continuous_of : continuous (@of X _) :=\none_point_extension.continuous_some\n\n/-- An open set in `alexandroff X` constructed from a closed compact set in `X` -/\ndef opens_of_compl {s : set X} (h : is_compact s ∧ is_closed s) :\n  topological_space.opens (alexandroff X) :=\n⟨(of '' s)ᶜ, (one_point_extension.opens_of_compl h).2⟩\n\nlemma infty_mem_opens_of_compl {s : set X} (h : is_compact s ∧ is_closed s) :\n  infty ∈ (opens_of_compl h : set (alexandroff X)) :=\none_point_extension.none_mem_opens_of_compl h\n\nlemma is_open_map_of : is_open_map (@of X _) :=\none_point_extension.is_open_map_some\n\nlemma is_open_range_of : is_open (@range_of X _) :=\none_point_extension.is_open_map_some _ is_open_univ\n\ninstance : compact_space (alexandroff X) := one_point_extension.compact_space X\n\nlemma dense_range_of (h : ¬ is_compact (univ : set X)) : dense (@range_of X _) :=\none_point_extension.dense_range_some h\n\nlemma connected_space_alexandroff [preconnected_space X] (h : ¬ is_compact (univ : set X)) :\n  connected_space (alexandroff X) :=\none_point_extension.connected_space h\n\ninstance [t1_space X] : t1_space (alexandroff X) :=\none_point_extension.t1_space\n\ninstance [locally_compact_space X] [t2_space X] : t2_space (alexandroff X) :=\none_point_extension.t2_space\n\nend topological\n\n#lint", "meta": {"author": "justadzr", "repo": "lean-2021", "sha": "dfc6b30de2f27bdba5fbc51183e2b84e73a920d1", "save_path": "github-repos/lean/justadzr-lean-2021", "path": "github-repos/lean/justadzr-lean-2021/lean-2021-dfc6b30de2f27bdba5fbc51183e2b84e73a920d1/src/alexandroff'.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.47268007463227757}}
{"text": "import number_theory.bernoulli\n\n\n--OUTPUT 1\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) := sorry\n\n\n\n-- https://ncatlab.org/nlab/show/Yoneda+lemma#statement\n\n/-!\n\n# Yoneda Lemma\n\nIn category theory, the Yoneda lemma gives an equivalence between two functors, known as a\nYoneda embedding and its left Kan extension. The Yoneda lemma is fundamental to category theory\nand is used to prove many more advanced results.\n\nThe Yoneda lemma shows that each functor from a small category $C$ to the category of sets is\ncompletely determined by the set of values it takes when evaluated at each object of $C$, along\nwith the morphisms between them. More precisely, it states that, for each category $C$, the\nfunctor $y_C : C \\to [C^{op}, Set]$ is fully faithful and essentially surjective.\n\nLet $\\mathcal{C}$ be a category, and let $A,B \\in \\mathcal{C}$. The Yoneda lemma gives a natural\nbijection between the set of morphisms $Mor(A, B)$ and the set of natural transformations\n$A^{op} \\to \\mathcal{C}(B, −)$.\n\n## Examples\n\n## References\n\nhttps://ncatlab.org/nlab/show/Yoneda+lemma#statement\n\n## Tags\n\nYoneda lemma\n-/\n\nnamespace yoneda\n\nopen category_theory\n\nuniverses v u -- declare the `v`'s first; see `category_theory.category` for an explanation\n\nvariable (C : Type u) -- Note that this changes the universe levels to `(C : Type u₁)`, where `u₁ > u`\n\n/--\n`ob C` is the type of objects of the category C.\n-/\ndef ob : Type v := C\n\nvariables {C}\n\n/--\n`hom C` is the type of morphisms of the category C.\n-/\ndef hom : C → C → Type v\n| a b := a ⟶ b\n\n/--\n`comp C` is the composition of morphism of the category C.\n-/\ndef comp {C : Type u} [category.{v} C] (a b c : C) : hom C a b → hom C b c → hom C a c\n| f g := f ≫ g  -- same as `g ≫ f`, because `direct` and `inverse` are symmetric\n\n/--\n`id C` is the identity of morphism of the category C.\n-/\ndef id {C : Type u} [category.{v} C] (a : C) : hom C a a\n| a := 𝟙 a\n\nattribute [simp] comp id\n\ninstance hom_setoid {C : Type u} [category.{v} C] (a b : C) : setoid (hom C a b) := ⟨λ f g, f = g⟩\n\n/--\nThe Yoneda embedding is the functor that takes each object $x$ of $C$ to the covariant\nhom-functor $\\hom_C(−,x)$ and each morphism $f : x → y$ to the function $α → f∘α$ that sends\neach morphism $α : z → x$ to the composite $f∘α : z → y$.\n\nThe Yoneda embedding is fully faithful:\nGiven objects $x,y\\in C$, there is a natural isomorphism\n`natural_equiv (yoneda.obj C x) (yoneda.obj C y)`\n\nProof:\nLet $x,y\\in Ob(C)$.\nThen the naturality square of the Yoneda embedding yields:\n\n{{begin-eqn}}\n{{eqn | l = \\hom_{[C^{op},Set]}(Hom_C(-,x),Hom_C(-,y))\n      | r = \\hom_{[C^{op},Set]}(Hom_C(-,y),Hom_C(-,x)))^{op}\n      | c = \\hom_{[C^{op},Set]}(Hom_C(-,y),Hom_C(-,x))\n}}\n{{eqn | r = \\hom_{[C^{op},Set]}(Hom_C(-,y),Hom_C(-,x))\n      | c = natural_equiv\n}}\n{{eqn | r = \\hom_{C^{op}}(y,x)\n      | c = \\hom_{[C^{op},Set]}(Hom_C(-,y),Hom_C(-,x))\n}}\n{{eqn | r = \\hom_C(x,y)\n      | c = \\hom_{C^{op}}(y,x)\n}}\n{{end-eqn}}\n\n`natural_equiv (yoneda.obj C x) (yoneda.obj C y) ≅ 𝟙 (hom C y x)`\n-/\ninstance yoneda_embedding_fully_faithful [small_category C] : fully_faithful (yoneda.obj C) :=\nbegin\n  intros a b,\n  apply set_category.functor_iso,\n  apply set_category.natural_equiv_iso,\n  simp,\n  /- \n  This does not work without some \"cleanup\"\n  apply inverse, -- must be the inverse because there are two symmetries\n  exact opposite_functor_iso_preimage _ _ _,\n  --/\n  ext, -- Let $f : a → b$ be a morphism in $C$.\n  rw function.funext_iff, -- It suffices to prove that \n  intros α, -- for all $α : x → a$, $f∘α = α'∘f$\n  apply eq_of_inv_eq_inv, -- Since the inverse is unique, \n  rw [←cancel_epi f, ←cancel_epi α], -- $g∘f = id_a$ and $f'∘α$\n  exact opposite_functor_iso_preimage _ _ _, -- follows from `nat_iso_inv_comp_eq_comp_inv_nat_iso`\n  split; ext; refl,\nend\n\n--OUTPUT 2\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  sorry\nend\n\n--OUTPUT 3\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) := \nbegin\n  assume (n : ℕ) (x : ℚ),\n  assume h1 : ∀ m : ℕ, m < n → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1),\n  have h2 : ∀ l : ℕ, (n + 1 : ℚ) * ((1 + x) : ℚ)^l = (n + 1 : ℚ) * (x : ℚ)^l + l * ∑ k = 0 to l - 1, ((nat.choose (l - 1) k) : ℚ) * (x : ℚ)^(l - 1 - k)  := \n  begin\n    assume l : ℕ,\n    show ((n + 1) * ((1 + x) : ℚ)^l) = ((n + 1) * x^l) + l * (∑ k = 0 to l - 1, (nat.choose (l - 1) k) * x^(l - 1 - k)),\n    have h3 : (n + 1 : ℚ) * ((1 + x) : ℚ)^l = (n + 1 : ℚ) * (∑ k = 0 to l - 1, nat.choose l k * x^k), from sorry,\n    have h4 : ∀ k : ℕ, (n + 1 : ℚ) * nat.choose l k * x^k = nat.choose (l - 1) k * x^(l - 1 - k) + l * nat.choose (l - 1) k * x^(l - 1 - k), \n    begin\n      assume k : ℕ,\n      show (n + 1) * nat.choose l k * x^k = nat.choose (l - 1) k * x^(l - 1 - k) + l * nat.choose (l - 1) k * x^(l - 1 - k),\n      sorry,\n    end,\n    have h5 : ∀ k : ℕ, nat.choose (l - 1) k * x^(l - 1 - k) + l * nat.choose (l - 1) k * x^(l - 1 - k) = nat.choose (l - 1) k * x^(l - 1 - k) + (l * x^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k))), from sorry,\n    have h6 : ∀ k : ℕ, k < l → (l * nat.choose (l - 1) k * x^(l - 1 - k) = l * x^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k))), from sorry,\n    have h7 : ∀ k : ℕ, k < l → (n + 1 : ℚ) * (nat.choose l k : ℚ) * (x : ℚ)^k = (nat.choose (l - 1) k : ℚ) * (x : ℚ)^(l - 1 - k) + (l * x^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k))), from sorry,\n    have h8 : ∀ k : ℕ, k < l → ∃! (n + 1) * (nat.choose l k) * x^k = (nat.choose (l - 1) k) * x^(l - 1 - k) + l * x^(l - 1) * (x^(k - l + 1) * nat.choose (l - 1) k), from sorry,\n    have h9 : ∀ k : ℕ, k < l → (n + 1) * (nat.choose l k) * x^k = (nat.choose (l - 1) k) * x^(l - 1 - k) + l * x^(l - 1) * (x^(k - l + 1) * nat.choose (l - 1) k), from sorry,\n    have h10 : ∀ k : ℕ, k < l → ∃! (n + 1) * nat.choose l k * x^k = nat.choose (l - 1) k * x^(l - 1 - k) + l * x^(l - 1) * (x^(k - l + 1) * nat.choose (l - 1) k), from sorry,\n    have h11 : (n + 1 : ℚ) * (∑ k = 0 to l - 1, (nat.choose l k : ℚ) * (x : ℚ)^k) = (∑ k = 0 to l - 1, (nat.choose (l - 1) k : ℚ) * (x : ℚ)^(l - 1 - k) + (l * (x : ℚ)^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k)))), from sorry,\n    have h12 : ∀ k : ℕ, k < l → ∃! (n + 1) * (nat.choose l k)* x^k = (nat.choose (l - 1) k) * x^(l - 1 - k) + l * x^(l - 1) * (x^(k - l + 1) * nat.choose (l - 1) k), from sorry,\n    have h13 : ∀ k : ℕ, ∃! ((n + 1) * (nat.choose l k) * x^k) = (nat.choose (l - 1) k) * x^(l - 1 - k) + l * x^(l - 1) * (x^(k - l + 1) * nat.choose (l - 1) k), from sorry,\n    have h14 : ∀ k : ℕ, nat.choose (l - 1) k * x^(l - 1 - k) + (l * x^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k))) = (n + 1 : ℚ) * (nat.choose l k) * x^k, from sorry,\n    sorry,\n  end,\n  rw (n + 1 : ℚ) * ((1 + x) : ℚ)^n = (n + 1 : ℚ) * (x : ℚ)^n + n * (∑ k : ℕ, (nat.choose n k : ℚ) * (x : ℚ)^(n - 1 - k)) at h2,\n  have h3 : ∀ k : ℕ, ∃! (n + 1 : ℚ) * (nat.choose n k : ℚ) * (x : ℚ)^k = (nat.choose (n - 1) k : ℚ) * (x : ℚ)^(n - 1 - k) + n * (nat.choose (n - 1) k : ℚ) * (x : ℚ)^(n - 1 - k), from sorry,\n  have h4 : ∀ k : ℕ, (n + 1 : ℚ) * (nat.choose n k : ℚ) * (x : ℚ)^k = (nat.choose (n - 1) k : ℚ) * (x : ℚ)^(n - 1 - k) + n * (nat.choose (n - 1) k : ℚ) * (x : ℚ)^(n - 1 - k), from sorry,\n  have h5 : ∀ k : ℕ, (n + 1) * (nat.choose n k) * x^k = (nat.choose (n - 1) k) * x^(n - 1 - k) + n * (nat.choose (n - 1) k) * x^(n - 1 - k), from sorry,\n  have h6 : (n + 1) * (polynomial.bernoulli n).eval ((1 + x) : ℝ) = (n + 1 : ℚ) * (polynomial.bernoulli n).eval x + n * (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  sorry,\nend\n\n--OUTPUT 5\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) := \nbegin\n  sorry,\nend\n\n--OUTPUT 6\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : ∀ (l : ℕ), ∑ k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k).eval x = (l + 1) * x^l, from\n  begin\n    assume (l : ℕ),\n    have h2 : polynomial.degree ((∑ k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k)) : polynomial ℚ) ≤ l, from sorry,\n    rw polynomial.sum_degree_eq_max_of_degree_le at h2,\n    have h3 : ∀ (k : ℕ), k ∈ range (l + 1) → (polynomial.degree (polynomial.const ((l + 1 : ℕ) choose k) * polynomial.bernoulli k)) < l, from sorry,\n    rw polynomial.sum_degree_eq_max_of_degree_lt at h3,\n    have h4 : ∀ (k : ℕ), k ∈ range (l + 1) → (polynomial.degree (polynomial.const ((l + 1 : ℕ) choose k))) < l, from sorry,\n    rw polynomial.sum_degree_eq_max_of_degree_lt at h4,\n\n    calc (∑ k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k).eval x)\n        = (∑ k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k).eval x) : by sorry\n    ... = (∑ k in range (l + 1), ((l + 1) choose k) * x^k) : by sorry\n    ... = (∑ k in range (l + 1), ((l + 1) choose k) * x^k) : by sorry\n    ... = (l + 1) * x^l : by sorry\n  end,\n\n  have h3 : ∀ (m : ℕ) (x : ℚ), m < n → polynomial.bernoulli m).eval (1 + x) = polynomial.bernoulli (m).eval (x) + m * x^(m - 1), from\n  begin\n    assume (m : ℕ) (x : ℚ) (h1 : m < n),\n    induction m with m hm,\n    show polynomial.bernoulli 0).eval (1 + x) = polynomial.bernoulli 0).eval x + 0 * x^(-1), from by sorry,\n    assume (m : ℕ) (ihm : m < n → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval (x) + m * x^(m - 1)),\n    assume (h2 : succ m < n),\n    have h3 : ((succ m) + 1 : ℕ) = succ succ m, from rfl,\n    rw [h3, polynomial.eval_pow] at *, \n    have h4 : ((succ m) + 1 : ℕ) = succ succ m, from rfl,\n    rw [h4, polynomial.eval_pow] at *, \n    have h5 : polynomial.bernoulli n).eval (1 + x) = polynomial.bernoulli n).eval (x) + n * x^(n - 1), from sorry,\n    assume (h6 : (m : ℕ) < n → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval (x) + m * x^(m - 1)),\n    assume (h7 : (n : ℕ) < n),\n  end\nend\n\n--OUTPUT 7\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  -- The proof is by strong induction\n  apply nat.strong_induction_on n,\n  assume (d : ℕ) (h_ind : ∀ m : ℕ, m < d →\n    (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1)),\n  show (polynomial.bernoulli d).eval (1 + x) = (polynomial.bernoulli d).eval x + d * x^(d - 1),\n  begin\n    -- we want to multiply both sides by d+1\n    have h_mult : (polynomial.bernoulli d).eval (1 + x) * (d + 1) =\n                  (polynomial.bernoulli d).eval x * (d + 1) + d * x^d,\n    begin\n      have h1 : (polynomial.bernoulli d).eval (1 + x) * (d + 1) =\n                  (1 + x)^d * (d + 1),\n      {\n        rw polynomial.eval_pow_bernoulli,\n      },\n      have h2 : (polynomial.bernoulli d).eval x * (d + 1) + d * x^d =\n                  x^d * (d + 1) + d * x^d,\n      {\n        rw polynomial.eval_pow_bernoulli,\n      },\n      -- we are going to use the fact that for all l in N, sum from k=0 to l of\n      -- choose(l+1,k)*Bk = (l+1)*X^l\n      have h_sum_bernoulli : ∀ l : ℕ, \n                             (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval (1 + x) =\n                             (l + 1) * (1 + x)^l,\n      {\n        assume (l : ℕ),\n        have h_sum_polynomial : ∀ (l : ℕ) (P : polynomial ℚ), \n        (sum P (finset.range (l + 1))).eval x = ∑ (i : finset (l + 1)), P.eval x,\n        {\n          assume (l : ℕ) (P : polynomial ℚ),\n          rw finset.sum_hom,\n          apply finset.sum_congr rfl,\n          assume (i : finset (l + 1)),\n          apply polynomial.eval_C,\n        },\n        have h_bernoulli_eval_C : ∀ (l : ℕ), \n                                  (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval x = \n                                  ∑ (i : finset (l + 1)), (polynomial.bernoulli l).eval x,\n        {\n          assume (l : ℕ),\n          rw h_sum_polynomial,\n          apply finset.sum_congr rfl,\n          assume (i : finset (l + 1)),\n          apply polynomial.eval_bernoulli,\n        },\n        have h_sum_bernoulli_number : ∀ (l : ℕ), \n                                      (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval x = \n                                      ∑ (i : finset (l + 1)), polynomial.bernoulli_number i,\n        {\n          -- I will use another corollary of the definition of Bernoulli polynomial\n          -- for all l in N, sum from k=0 to l of\n          -- choose(l+1,k)*Bk = (l+1)*X^l\n          assume (l : ℕ),\n          have h_sum_bernoulli_poly : ∀ (l : ℕ) (n : ℕ),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       ∑ (i : finset (l + 1)), (polynomial.bernoulli l).eval x,\n          {\n            assume (l : ℕ) (n : ℕ),\n            rw polynomial.sum_hom,\n            apply finset.sum_congr rfl,\n            assume (i : finset (l + 1)),\n            apply polynomial.eval_bernoulli,\n          },\n          have h_sum_bernoulli_poly_one : ∀ (l : ℕ) (n : ℕ),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       ∑ (i : finset (l + 1)), polynomial.bernoulli_number i,\n          {\n            assume (l : ℕ) (n : ℕ),\n            have h_sum_bernoulli_poly : ∀ (l : ℕ) (n : ℕ),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       ∑ (i : finset (l + 1)), (polynomial.bernoulli l).eval x,\n            {\n              assume (l : ℕ) (n : ℕ),\n              rw polynomial.sum_hom,\n              apply finset.sum_congr rfl,\n              assume (i : finset (l + 1)),\n              apply polynomial.eval_bernoulli,\n            },\n            have h_sum_bernoulli_poly_one : ∀ (l : ℕ) (n : ℕ),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       ∑ (i : finset (l + 1)), polynomial.bernoulli_number i,\n            {\n              assume (l : ℕ) (n : ℕ),\n              by {\n                apply polynomial.bernoulli_eval_one,\n              },\n            },\n            have h_sum_bernoulli_poly_one : ∀ (l : ℕ) (n : ℕ),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       ∑ (i : finset (l + 1)), polynomial.bernoulli_number i,\n            {\n              assume (l : ℕ) (n : ℕ),\n              by {\n                apply polynomial.bernoulli_eval_one,\n              },\n            },\n            have h_sum_bernoulli_poly_one : ∀ (l : ℕ) (n : ℕ),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       ∑ (i : finset (l + 1)), polynomial.bernoulli_number i,\n            {\n              assume (l : ℕ) (n : ℕ),\n              by {\n                apply polynomial.bernoulli_eval_one,\n              },\n            },\n             sorry,\n          },\n          rw h_bernoulli_eval_C,\n          rw h_sum_bernoulli_poly_one,\n        },\n        have h_sum_bernoulli_number_one : ∀ (l : ℕ),\n                                          ∑ (i : finset (l + 1)), polynomial.bernoulli_number i =\n                                           (l + 1) * x^l,\n        {\n          assume (l : ℕ),\n          have h_sum_bernoulli_number : ∀ (l : ℕ), \n                                      (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval x = \n                                      ∑ (i : finset (l + 1)), polynomial.bernoulli_number i,\n          {\n            -- I will use another corollary of the definition of Bernoulli polynomial\n            -- for all l in N, sum from k=0 to l of\n            -- choose(l+1\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  sorry,\nend\n\n--OUTPUT 9\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  sorry\nend\n\n--OUTPUT 10\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : ∀ n : ℕ, ∀ x : ℚ, n < n → (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1), from begin\n    assume (n : ℕ) (h1 : n < n),\n    show (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1), from sorry,\n  end,\n  have h2 : ∀ m : ℕ, ∀ d : ℕ, m < d → \n    ∀ x : ℚ, \n    (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1) → \n    (polynomial.bernoulli d).eval (1 + x) = (polynomial.bernoulli d).eval x + d * x^(d - 1), from begin\n    assume (m : ℕ) (d : ℕ) (h2 : m < d) (x : ℚ) (h3 : (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1)),\n    have h4 : ∀ l : ℕ, (polynomial.bernoulli l).eval (1 + x) = (polynomial.bernoulli l).eval x + l * x^(l - 1), from begin\n      assume (l : ℕ),\n      cases l,\n      simp at h4,\n      have h5 : 0 < (l+1), from sorry,\n      have h6 : l < (l+1), from sorry,     \n      have h7 : (polynomial.bernoulli l).eval (1 + x) = (polynomial.bernoulli l).eval x + l * x^(l - 1), from sorry, \n      show (polynomial.bernoulli (l+1)).eval (1 + x) = (polynomial.bernoulli (l+1)).eval x + (l+1) * x^((l+1) - 1), from sorry,\n    end,\n    show (polynomial.bernoulli d).eval (1 + x) = (polynomial.bernoulli d).eval x + d * x^(d - 1), from sorry,\n  end,\n  sorry,\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n  have h2 : (A ∩ B) ⊆ A, from sorry,\n  have h3 : (A ∩ B) ⊆ S, from sorry,\n  show (A ∩ B) ∈  𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by sorry\n  ... = x*(x+y) + y*(x+y) : by sorry\n  ... = x*x + x*y + y*x + y*y : by sorry\n  ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n  have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n      have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n      show e = (1 : G), from sorry,     \n    },\n    sorry,\n  }\nend\n\n/--`theorem`\nBernoulli polynomial evaluation\nGiven a natural number $n$ and a rational $x$, let $B_n (x)$ denote the $n$-th Bernoulli polynomial evaluated at $x$. Then, $$B_n (1 + x) = B_n (x) + n x^{n - 1}$$\n`proof`\nWe apply strong induction on $n$. So, for all $m < d$, we have $B_{m} (1 + x) = B_{m} (x) + m x^{m - 1}$ and we want to show that $$B_{d} (1 + x) = B_{d} (x) + d x^{d - 1}$$\nMultiplying both sides by $d + 1$, and using the fact that, for all $l \\in \\mathbb{N}$, $\\sum_{k = 0}^{l} {l + 1 \\choose k} B_k = (l + 1) X^l$ (where $B_k$ is the $k$-th Bernoulli number), we get that \n$$ (d + 1) (1 + x)^d - (d + 1) x^d = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\nThe conclusion then follows easily.\n\nQED\n\n-/\ntheorem  bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0.8_max_tokens_2000_n_10/clean_files/Bernoulli polynomial evaluation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.4726800743959037}}
{"text": "import .kruskal .higman data.list\nopen classical fin set nat subtype finite_tree kruskal function prod\n\nnoncomputable theory\n\ntheorem dne {p : Prop} (H : ¬¬p) : p := or.elim (em p) (assume Hp : p, Hp) (assume Hnp : ¬p, absurd Hnp H)\n\nlemma tag_eq_of_eq {A : Type} {P : A → Prop} {a b : subtype P} (H : a = b) :a.1 = b.1 := by rw H\n\nsection\n\nvariables {A B : Type}\nvariable x : A × B\n\ntheorem prod_eta : (x.1,x.2) = x := prod.rec_on x (λ a b, rfl)\n\ntheorem eq_of_prod {A B : Type} {p q : A × B} (H1 : p.1 = q.1) (H2 : p.2 = q.2) : p = q :=\nbegin \ncases p with p1 p2,\ndsimp at H1, dsimp at H2,\nrw [H1,H2,prod_eta]\nend\n\nend\n\ntheorem ne_empty_of_image_on_univ {A B : Type} (f : A → B) [inhabited A] : image f univ ≠ ∅ :=\nhave (∅ : set A) ≠ univ, from empty_ne_univ,\nhave ∃ a, a ∈ (univ : set A), from exists_mem_of_ne_empty (ne.symm this),\nlet ⟨a,h⟩ := this in\nhave f a ∈ image f univ, from exists.intro a (and.intro h rfl),\nset.ne_empty_of_mem this\n\ntheorem val_mapsto (n : ℕ) : maps_to fin.val (@univ (fin n)) {i : ℕ | i < n} :=\ntake x, assume Ha, is_lt x\n\ntheorem injective_val_on_univ (n : ℕ): inj_on fin.val (@univ (fin n)) :=\ntake x₁ x₂, assume H1, assume H2, assume eq, eq_of_veq eq\n\ninstance finite_univ_of_fin (n : ℕ) : finite (@univ (fin n)) :=\nfinite_of_inj_on (val_mapsto n) (injective_val_on_univ n)\n\ntheorem refl_of_image_on_univ {A B: Type} (f : A → B) : set.image f (@set.univ A) = {b : B | ∃ x, f x = b} :=\nhave Hl : set.image f (@set.univ A) ⊆ {b : B | ∃ x, f x = b}, from \n  take x, assume Hx, \n  let ⟨i,h⟩ := Hx in exists.intro i (and.right h),\nhave {b : B | ∃ x, f x = b} ⊆ set.image f  (@set.univ A), from \n  take x, assume Hx, \n  let ⟨i,h⟩ := Hx in exists.intro i (and.intro trivial h),\nset.subset.antisymm Hl this\n\ntheorem finite_image_of_fin {A : Type} {n : ℕ} (f : fin n → A) : finite {a : A | ∃ x, f x = a} := \nhave image f (@univ (fin n)) = {a : A | ∃ x, f x = a}, from refl_of_image_on_univ f,\nhave finite (image f (@univ (fin n))), from finite_image f (@univ (fin n)),\nby super\n\n-- need this to handle trees of the form (f n) where f : ℕ → finite_tree\ntheorem finite_tree_destruct {t : finite_tree} :\n∃ n (ss : fin n → finite_tree), t = cons ss :=\nfinite_tree.cases_on t (λ n a, ⟨n,a,rfl⟩)\n\ndefinition num_of_branches_at_root : finite_tree → ℕ\n| (@cons n ts) := n\n\n-- definition num_of_branches_at_root (t : finite_tree) (H : t ≠ node) : ℕ := \n-- some (exists_eq_cons_of_ne_node H)\n\n-- definition branches_at_root : finite_tree → Π {n : ℕ}, fin n → finite_tree\n-- | (@cons n ts) := ts\n-- some (some_spec (exists_eq_cons_of_ne_node H))\n\n-- definition set_of_branches' {n : ℕ} : finite_tree → set (finite_tree × ℕ)\n-- | (@cons n ts) := {x : finite_tree × ℕ | ∃ a : fin n, ts a = x.1 ∧ val a = x.2}\n\n-- {x : finite_tree × ℕ | ∃ a : fin n, ts a = x.1 ∧ val a = x.2}\n\ndef branches_aux {n : ℕ} (ts : fin n → finite_tree) : set (finite_tree × ℕ) := \n{x : finite_tree × ℕ | ∃ a : fin n, ts a = x.1 ∧ val a = x.2}\n\ntheorem empty_branches (ts : fin 0 → finite_tree) : branches_aux ts = ∅ :=\nhave ∀ x, x ∉ branches_aux ts, from λ x h, let ⟨a,ha⟩ := h in fin_zero_absurd a,\nset.eq_empty_of_forall_not_mem this\n\ndefinition branches : finite_tree → set (finite_tree × ℕ) \n| (@cons n ts) := branches_aux ts\n\ntheorem embeds_of_branches {t : finite_tree × ℕ} {T : finite_tree} : t ∈ (branches T) → t.1 ≼ T := \nbegin\ncases T with n ts,\nintro H, cases H with a h,\ncases t.1 with t1a t1s,\ndsimp [embeds],apply or.inl,\nfapply exists.intro,\nexact a, rw h^.left, apply embeds_refl\nend\n\ntheorem lt_of_size_of_branches {t : finite_tree × ℕ} {T : finite_tree} : t ∈ branches T → size t.1 < size T :=\nbegin \ncases T with n ts,\nintro h,\nassert h' : ∃ i, ts i = t.1, cases h with b hb, \n  {exact exists.intro b hb^.left},\ncases h' with c hc, rw -hc, apply lt_of_size_branches_aux\nend\n\ntheorem finite_set_of_branches {n : ℕ} (ts : fin n → finite_tree) : finite (branches_aux ts) := \nlet f (a : fin n) : finite_tree × ℕ := (ts a, val a) in\nlet S : set (finite_tree × ℕ) := {x : finite_tree × ℕ | ∃ a : fin n, f a = x} in\nhave finS : finite S, from finite_image_of_fin f,\nhave H1 : S ⊆ branches_aux ts, from \n  λ x ⟨a,h⟩, ⟨a,⟨by rw -h,by rw -h⟩⟩,\nhave H2 : branches_aux ts ⊆ S, from \n  λ x ⟨a,h⟩, ⟨a,begin dsimp,rw [h^.left, h^.right], apply prod_eta end⟩, \nbegin rw -(subset.antisymm H1 H2), exact finS end\n\ntheorem finite_branches (t : finite_tree) : finite (branches t) := \nby induction t; apply finite_set_of_branches\n\n#check @minimal_bad_seq\n\nsection\nparameter H : ∃ f, ¬ is_good f embeds\n\ndefinition mbs_of_finite_tree := minimal_bad_seq size H \n\ntheorem bad_mbs_finite_tree : ¬ is_good mbs_of_finite_tree embeds := badness_of_mbs size H\n\ntheorem ne_node_of_elt_of_mbs_finite_tree (n : ℕ) {ts : fin 0 → finite_tree} : mbs_of_finite_tree n ≠ cons ts :=\nassume Hneg,\nhave cons ts  ≼ mbs_of_finite_tree (succ n), by apply node_embeds,\nhave Hr : mbs_of_finite_tree n ≼ mbs_of_finite_tree (succ n), by simph,\nhave n < succ n, from lt_succ_self n,\nhave is_good mbs_of_finite_tree embeds, from exists.intro n (exists.intro (succ n) (and.intro this Hr)),\nshow _, from bad_mbs_finite_tree this\n\ntheorem minimality_of_mbs_finite_tree0 (f : ℕ → finite_tree) (Hf : ¬ is_good f embeds) : size (mbs_of_finite_tree 0) ≤ size (f 0) := minimality_of_mbs_0 size H f Hf\n\ntheorem minimality_of_mbs_finite_tree (n : ℕ) (f : ℕ → finite_tree) (H1 : extends_at n mbs_of_finite_tree f ∧ ¬ is_good f embeds) : size (mbs_of_finite_tree (succ n)) ≤ size (f (succ n)) := minimality_of_mbs size H n f H1\n\ndefinition seq_branches_of_mbs_tree (n : ℕ) : set (finite_tree × ℕ) := branches (mbs_of_finite_tree n)\n\ntheorem mem_of_seq_branches {n i : ℕ} (ts : fin n → finite_tree) (k : fin n) (Heq : mbs_of_finite_tree i = cons ts) : (ts k, val k) ∈ seq_branches_of_mbs_tree i :=\nhave ts k = (ts k, val k).1 ∧ val k = (ts k, val k).2, from and.intro rfl rfl,\nhave ∃ a, ts a = (ts k, val k).1 ∧ val a = (ts k, val k).2, from exists.intro k this,\nhave (ts k, val k) ∈ branches (cons ts), from this,\nby rw -Heq at this;exact this\n\ndefinition mbs_tree : Type := {t : finite_tree × ℕ // ∃ i, t ∈ seq_branches_of_mbs_tree i}\n\ndefinition embeds' (t : mbs_tree) (s : mbs_tree) : Prop := t.val.1 ≼ s.val.1\n\ntheorem embeds'_refl (t : mbs_tree) : embeds' t t := embeds_refl t.val.1\n\ntheorem embeds'_trans (a b c : mbs_tree) : embeds' a b → embeds' b c → embeds' a c :=\nassume H₁, assume H₂, embeds_trans H₁ H₂\n\nsection\n\nparameter H' : ∃ f, ¬ is_good f embeds'\n\ndefinition R : ℕ → mbs_tree := some H'\n\ndefinition family_index (n : ℕ) : ℕ := some ((R n).2) \n\ndefinition index_set_of_mbs_tree : set ℕ := image family_index  univ\n\nlemma index_ne_empty : index_set_of_mbs_tree ≠ ∅ := ne_empty_of_image_on_univ family_index\n\ndefinition least_family_index := least index_set_of_mbs_tree index_ne_empty\n\nlemma exists_least : ∃ i, family_index i = least_family_index :=\nhave least_family_index ∈ index_set_of_mbs_tree, from least_is_mem index_set_of_mbs_tree index_ne_empty,\nlet ⟨i,h⟩ := this in\n⟨i, h^.right⟩\n\ndefinition least_index : ℕ := some exists_least\n\ndefinition Kruskal's_g (n : ℕ) : mbs_tree := R (least_index + n)\n\ndefinition Kruskal's_h (n : ℕ) : ℕ :=  family_index (least_index + n)\n\ntheorem bad_Kruskal's_g : ¬ is_good Kruskal's_g embeds' :=\nsuppose is_good Kruskal's_g embeds',\nlet ⟨i,j,hij⟩ := this in\nhave Hr : embeds' (Kruskal's_g i) (Kruskal's_g j), from hij^.right,\nhave least_index + i < least_index + j, from add_lt_add_left hij^.left _,\nhave is_good R embeds', from ⟨least_index + i, ⟨least_index + j,⟨this, Hr⟩⟩⟩,\n(some_spec H') this\n\ntheorem Kruskal's_Hg : ¬ is_good (fst ∘ (val ∘ Kruskal's_g)) embeds := bad_Kruskal's_g\n\ntheorem trans_of_Kruskal's_g {i j : ℕ} (H1 : mbs_of_finite_tree i ≼ (Kruskal's_g j).val.1) : \nmbs_of_finite_tree i ≼ mbs_of_finite_tree (Kruskal's_h j) := \nhave (Kruskal's_g j).val ∈ branches (mbs_of_finite_tree (Kruskal's_h j)), from some_spec (Kruskal's_g j).2,\nhave (Kruskal's_g j).val.1 ≼ mbs_of_finite_tree (Kruskal's_h j), from embeds_of_branches this,\nembeds_trans H1 this\n\ntheorem size_elt_Kruskal's_g_lt_mbs_finite_tree (n : ℕ) : size (Kruskal's_g n).val.1 < size (mbs_of_finite_tree (Kruskal's_h n)) := \nlt_of_size_of_branches (some_spec (Kruskal's_g n).2)\n\ntheorem Kruskal's_Hbp : size (Kruskal's_g 0).val.1 < size (mbs_of_finite_tree (Kruskal's_h 0)) := size_elt_Kruskal's_g_lt_mbs_finite_tree 0\n\nlemma family_index_in_index_of_mbs_tree (n : ℕ) : Kruskal's_h n ∈ index_set_of_mbs_tree :=\nhave Kruskal's_h n = family_index (least_index + n), from rfl,\n⟨(least_index + n),⟨trivial,rfl⟩⟩\n\ntheorem Kruskal's_Hh (n : ℕ) : Kruskal's_h 0 ≤ Kruskal's_h n :=\n-- have Kruskal's_h 0 = family_index (least_index + 0), from rfl,\nhave Kruskal's_h 0 = family_index least_index, from rfl,--by simph,\nhave family_index least_index = least_family_index, from some_spec exists_least,\nhave Kruskal's_h 0 = least_family_index, by simph,\nbegin rw this, apply minimality, apply family_index_in_index_of_mbs_tree end\n\ntheorem Kruskal's_H : ∀ i j, mbs_of_finite_tree i ≼ (Kruskal's_g (j - Kruskal's_h 0)).val.1 → mbs_of_finite_tree i ≼ mbs_of_finite_tree (Kruskal's_h (j - Kruskal's_h 0)) := λ i j, λ H1, trans_of_Kruskal's_g H1\n\ndefinition Kruskal's_comb_seq (n : ℕ) : finite_tree := @comb_seq_with_mbs _ embeds (fst ∘ (val ∘ Kruskal's_g)) Kruskal's_h size H n\n\ntheorem Kruskal's_local_contradiction : false := local_contra_of_comb_seq_with_mbs Kruskal's_h size Kruskal's_Hh H Kruskal's_Hg Kruskal's_H Kruskal's_Hbp\n\nend\n\n#check Kruskal's_local_contradiction\n\ntheorem embeds'_is_good : ∀ f, is_good f embeds' := \nby_contradiction\n(suppose ¬ ∀ f, is_good f embeds',\n have ∃ f, ¬ is_good f embeds', from classical.exists_not_of_not_forall this,\n Kruskal's_local_contradiction this)\n\ninstance wqo_mbs_tree : wqo mbs_tree :=\n⟨⟨⟨embeds'⟩,embeds'_refl,embeds'_trans⟩,embeds'_is_good⟩\n\ndefinition wqo_finite_subsets_of_mbs_tree : wqo (finite_subsets mbs_tree) := wqo_finite_subsets\n\ndefinition os : finite_subsets mbs_tree → finite_subsets mbs_tree → Prop := wqo_finite_subsets_of_mbs_tree.le\n\n-- type mbs_tree is the collection of all branches at roots appearing in the mbs_of_finite_tree\n-- hence, mbs_of_finite_tree can be viewed as a sequence on finite_subsets mbs_tree. We call this sequence a copy (or a mirror) of mbs_of_finite_tree.\n-- the following theorem says given any sequence f : ℕ → finite_subsets mbs_tree,  there exists i j such that there exists a f' : mbs_tree → mbs_tree which is injective and nondescending from (f i) to (f j). \ntheorem good_finite_subsets_of_mbs_tree : ∀ f, is_good f os := wqo_finite_subsets_of_mbs_tree.is_good\n\n-- Intuitively, the above f' is already a witness of the goodness of mbs_of_finite_tree, as it maps each branch of mbs_of_finite_tree i to a branch of mbs_of_finite_tree j. (Also note that there is no node in the mbs_of_finite_tree.)\n\n-- However, according to the definition of embeds, f' has to be of type fin n → fin m for some n,m ∈ ℕ, representing a permutation on the labels of the branches. The following construction recovers the desired function from f'.\n\n-- branches at root of mbs_of_finite_tree form a set of mbs_tree\ndefinition elt_mirror (n : ℕ) : set mbs_tree := {x : mbs_tree | x.1 ∈ seq_branches_of_mbs_tree n}\n\ntheorem mirror_refl_left (x : mbs_tree) (n : ℕ) : x ∈ elt_mirror n → x.1 ∈ seq_branches_of_mbs_tree n := λ Hx, Hx\n\ntheorem mirror_refl_right (x : mbs_tree) (n : ℕ) : x.1 ∈ seq_branches_of_mbs_tree n → x ∈ elt_mirror n := λ Hx, Hx\n\ninstance  finite_seq_branches (n : ℕ) : finite (seq_branches_of_mbs_tree n) := finite_branches (mbs_of_finite_tree n)\n\ntheorem finite_elt (n : ℕ) : finite (elt_mirror n) := \nhave mapsto : maps_to subtype.val (elt_mirror n) (seq_branches_of_mbs_tree n), from λ x Hx, mirror_refl_left x n Hx,\nhave inj_on subtype.val (elt_mirror n), from λ x₁ x₂ H₁ H₂, subtype.eq,\nfinite_of_inj_on mapsto this\n\n-- this gives a sequence of finite_subsets of mbs_tree. \n-- mirror_of_seq_branches 0 is the branches at the root of the first element of the minimal bad sequence of finite_tree.\n\ndefinition mirror (n : ℕ) : finite_subsets mbs_tree := ⟨elt_mirror n, finite_elt n⟩\n\n-- (mirror i) is the collection of branches at the root of (mbs_of_finite_tree i)\n\ntheorem good_mirror : ∃ i j, i < j ∧ os (mirror i) (mirror j) := good_finite_subsets_of_mbs_tree mirror\n\nsection\n-- destruct the statement: os (mirror i) (mirror j)\n-- we want to show that there exists some i j such that (mbs_of_finite_tree i ≼ mbs_of_finite_tree j)\n-- fortunately, i and j from good_mirror suffice\n-- this section tries to get an injection \"recover\" : fin ni → fin nj such that tsi ti ≼ tsj (recover ti) assuming that (mbs_of_finite_tree i = cons tsi) and (mbs_of_finite_tree j = cons tsj). Note that both are not nodes.\nparameters {i j : ℕ}\n-- -- since finite_subsets_of_mbs_tree is good, we have an injection f' from some set of branches to some set of branches. This is because each set of branches is a subset of mbs_tree.\nparameter f' : mbs_tree → mbs_tree \nparameter inj : inj_from_to f' (elt_mirror i) (elt_mirror j)\n-- -- of course, it is also nondescending by definition.\nparameter nond : ∀ a : mbs_tree, a.val ∈ seq_branches_of_mbs_tree i → a.val.1 ≼ (f' a).val.1 ∧  (f' a).val ∈ seq_branches_of_mbs_tree j\n-- suppose (mbs_of_finite_tree i) is of the form (cons tsi)\nparameters ni nj : ℕ\nparameters (tsi : fin ni → finite_tree) (tsj : fin nj → finite_tree)\n-- suppose we know that they are destructed\nparameter eqi : mbs_of_finite_tree i = cons tsi\nparameter eqj : mbs_of_finite_tree j = cons tsj\n-- this reminds us that each branch at the root of (mbs_of_finite_tree i) is in (seq_branches_of_mbs_tree i)\nparameter Htsi : ∀ a, (tsi a, val a) ∈ seq_branches_of_mbs_tree i\n\n-- lemma eltini (ti : fin ni) : (tsi ti, val ti) ∈ seq_branches_of_mbs_tree i := Htsi ti\n\n-- every ti corresponds to some seq_branches_of_mbs_tree i\nlemma foo (ti : fin ni) : ∃ i, (tsi ti, val ti) ∈ seq_branches_of_mbs_tree i := ⟨i,Htsi ti⟩\n\n-- given a ti, find the corresponding mbs_tree of (tsi ti). The intuition is that this mbs_tree is itself, but of a different type.\ndefinition mbst_form (ti : fin ni) : mbs_tree := ⟨(tsi ti, val ti),(foo ti)⟩\n\ntheorem mem_mbst_form (a : fin ni) : mbst_form a ∈ elt_mirror i := Htsi a\n\ntheorem eq_of_mbst_form {a₁ a₂ : fin ni} (Heq : mbst_form a₁ = mbst_form a₂) : a₁ = a₂ :=\nby apply eq_of_veq;super\n\n-- lemma mem (ti : fin ni) : (f' (mbst_form ti)).val ∈ branches (mbs_of_finite_tree j) := \n-- (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right\ninclude eqj\n\n-- recover : \n-- 1. find the mbst_form of ti, say x. \n-- 2. By nond, we know that (f' x) is in (seq_branches_of_mbs_tree j). \n-- 3. (seq_branches_of_mbs_tree j) is just branches (mbs_of_finite_tree j). \n-- 4. The latter is just (set_of_branches tsj). \n-- 5. This means that some a : fin nj corresponds to ti. 6. By choice, take such a fin nj.\n\ndefinition recover (ti : fin ni) : fin nj :=\nhave (f' (mbst_form ti)).val ∈ seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,\nhave mem : (f' (mbst_form ti)).val ∈ branches (mbs_of_finite_tree j), from this, -- this line is redundant\nhave branches (mbs_of_finite_tree j) = branches (cons tsj), by rw eqj, -- by rw eqj at this{2};exact this, \n-- have branches (mbs_of_finite_tree j) = branches_aux tsj, from this,\nhave (f' (mbst_form ti)).val ∈ branches_aux tsj, by rw this at mem;exact mem,\n-- have ∃ a : fin nj, tsj a = (f' (mbst_form ti)).val.1 ∧ val a = (f' (mbst_form ti)).val.2, from this,\nsome this\n\ntheorem perm_recover (ti : fin ni) : tsi ti ≼ tsj (recover ti) := \nhave (f' (mbst_form ti)).val ∈ seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,\nhave mem : (f' (mbst_form ti)).val ∈ branches (mbs_of_finite_tree j), from this,\n-- have branches (mbs_of_finite_tree j) = branches (mbs_of_finite_tree j), from rfl,\nhave branches (mbs_of_finite_tree j) = branches (cons tsj), by rw eqj, -- by rw eqj at this{2};exact this, \n-- have branches (mbs_of_finite_tree j) = branches_aux tsj, from this,\nhave (f' (mbst_form ti)).val ∈ branches_aux tsj, by rw this at mem;exact mem,\n-- have ∃ a : fin nj, tsj a = (f' (mbst_form ti)).val.1 ∧ val a =  (f' (mbst_form ti)).val.2, from this,\nhave tsj (recover ti) = (f' (mbst_form ti)).val.1, from let ⟨a,b⟩ := some_spec this in a,\nhave tsi ti ≼ (f' (mbst_form ti)).val.1, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.left,\nby simph\n\ntheorem inj_recover : injective recover := \nλ a₁ a₂ Heq,\nhave (f' (mbst_form a₁)).val ∈ seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,\nhave mem : (f' (mbst_form a₁)).val ∈ branches (mbs_of_finite_tree j), from this,\n-- have branches (mbs_of_finite_tree j) = branches (mbs_of_finite_tree j), from rfl,\nhave branches (mbs_of_finite_tree j) = branches (cons tsj), by rw eqj, -- by rw eqj at this{2};exact this, \n-- have branches (mbs_of_finite_tree j) = branches_aux tsj, from this,\nhave (f' (mbst_form a₁)).val ∈ branches_aux tsj, by rw this at mem;exact mem,\n\nhave eeq1 : ∃ a : fin nj, tsj a = (f' (mbst_form a₁)).val.1 ∧ val a = (f' (mbst_form a₁)).val.2, from this,\nhave pr11 : tsj (recover a₁) = (f' (mbst_form a₁)).val.1, from let ⟨a,b⟩ := some_spec eeq1 in a,-- proof and.left (some_spec eeq1) qed,\nhave pr21 : val (recover a₁) = (f' (mbst_form a₁)).val.2, from let ⟨a,b⟩ := some_spec eeq1 in b, -- proof and.right (some_spec eeq1) qed,\nhave (f' (mbst_form a₂)).val ∈ seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,-- proof and.right (nond _ (eltini a₂)) qed,\nhave mem : (f' (mbst_form a₂)).val ∈ branches (mbs_of_finite_tree j), from this,\n-- have branches (mbs_of_finite_tree j) = branches (mbs_of_finite_tree j), from rfl,\nhave branches (mbs_of_finite_tree j) = branches (cons tsj), by rw eqj, -- by+ rw eqj at this{2};exact this, \n-- have branches (mbs_of_finite_tree j) = branches_aux tsj, from this,\nhave (f' (mbst_form a₂)).val ∈ branches_aux tsj, by rw this at mem;exact mem,\nhave eeq2 : ∃ a : fin nj, tsj a = (f' (mbst_form a₂)).val.1 ∧ val a = (f' (mbst_form a₂)).val.2, from this,\nhave pr12 : tsj (recover a₂) = (f' (mbst_form a₂)).val.1,  from let ⟨a,b⟩ := some_spec eeq2 in a,-- proof and.left (some_spec eeq2) qed,\nhave pr22 : val (recover a₂) = (f' (mbst_form a₂)).val.2, from let ⟨a,b⟩ := some_spec eeq2 in b,-- proof and.right (some_spec eeq2) qed,\nhave eq1 : (f' (mbst_form a₁)).val.1 = (f' (mbst_form a₂)).val.1, by rw [-pr12, -pr11, Heq],\nhave (f' (mbst_form a₁)).val.2 = (f' (mbst_form a₂)).val.2, by rw [-pr22,-pr21,Heq],\nhave (f' (mbst_form a₁)).val = (f' (mbst_form a₂)).val, from eq_of_prod eq1 this,\nhave f'eq : f' (mbst_form a₁) = f' (mbst_form a₂), from subtype.eq this,\nhave ∀ x₁ x₂ : mbs_tree, x₁ ∈ elt_mirror i → x₂ ∈ elt_mirror i → f' x₁ = f' x₂ → x₁ = x₂, from and.right inj,\nhave mbst_form a₁ = mbst_form a₂, from this (mbst_form a₁) (mbst_form a₂) (mem_mbst_form a₁) (mem_mbst_form a₂) f'eq,\nshow _, from eq_of_mbst_form this\n\nend\n\n#check @recover\n#check inj_recover\n\ntheorem good_mbs_of_finite_tree :  ∃ i j, i < j ∧ mbs_of_finite_tree i ≼ mbs_of_finite_tree j :=\nlet ⟨i,j,⟨iltj,⟨f',⟨inj,nond⟩⟩⟩⟩ := good_mirror in\nlet ⟨ni,tsi,htsi⟩ := @finite_tree_destruct (mbs_of_finite_tree i) in\nlet ⟨nj,tsj,htsj⟩ := @finite_tree_destruct (mbs_of_finite_tree j) in\nhave Htsi : ∀ a, (tsi a, val a) ∈ seq_branches_of_mbs_tree i, from take a, mem_of_seq_branches tsi a htsi,\nlet f (a : fin ni) : fin nj := recover f' nond ni _ tsi tsj htsj Htsi a in\nhave injf : injective f, from inj_recover _ inj _ _ _ _ _ _ _,\nhave ∀ z : fin ni, tsi z ≼ tsj (f z), from λ z, perm_recover _ _ _ _ _ _ _ _ _,\nhave cons tsi ≼ cons tsj, from or.inr ⟨f,⟨injf,this⟩⟩,\nhave mbs_of_finite_tree i ≼ mbs_of_finite_tree j, by simph,\n⟨i,j,⟨iltj,this⟩⟩\n\ntheorem Kruskal's_contradiction : false := bad_mbs_finite_tree good_mbs_of_finite_tree\n\nend\n\ntheorem embeds_is_good : ∀ f, is_good f embeds :=\nby_contradiction\n(suppose ¬ ∀ f, is_good f embeds,\n have ∃ f, ¬ is_good f embeds, from classical.exists_not_of_not_forall this,\n Kruskal's_contradiction this)\n\ndef wqo_finite_tree : wqo finite_tree :=\n⟨⟨⟨embeds⟩,embeds_refl,@embeds_trans⟩,embeds_is_good⟩\n\n\n", "meta": {"author": "minchaowu", "repo": "Kruskal.lean3", "sha": "a14516f47b21e636e9df914fc6ebe64cbe5cd38d", "save_path": "github-repos/lean/minchaowu-Kruskal.lean3", "path": "github-repos/lean/minchaowu-Kruskal.lean3/Kruskal.lean3-a14516f47b21e636e9df914fc6ebe64cbe5cd38d/theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4726800698765056}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\nFree groups as a quotient over the reduction relation `a * x * x⁻¹ * b = a * b`.\n\nFirst we introduce the one step reduction relation\n  `free_group.red.step`:  w * x * x⁻¹ * v   ~>   w * v\nits reflexive transitive closure:\n  `free_group.red.trans`\nand proof that its join is an equivalence relation.\n\nThen we introduce `free_group α` as a quotient over `free_group.red.step`.\n-/\nimport logic.relation\nimport algebra.group algebra.group_power\nimport data.fintype data.list.basic data.quot\nimport group_theory.subgroup\nopen relation\n\nuniverses u v w\n\nvariables {α : Type u}\n\nlocal attribute [simp] list.append_eq_has_append\n\nnamespace free_group\nvariables {L L₁ L₂ L₃ L₄ : list (α × bool)}\n\n/-- Reduction step: `w * x * x⁻¹ * v ~> w * v` -/\ninductive red.step : list (α × bool) → list (α × bool) → Prop\n| bnot {L₁ L₂ x b} : red.step (L₁ ++ (x, b) :: (x, bnot b) :: L₂) (L₁ ++ L₂)\nattribute [simp] red.step.bnot\n\n/-- Reflexive-transitive closure of red.step -/\ndef red : list (α × bool) → list (α × bool) → Prop := refl_trans_gen red.step\n\n@[refl] lemma red.refl : red L L := refl_trans_gen.refl\n@[trans] lemma red.trans : red L₁ L₂ → red L₂ L₃ → red L₁ L₃ := refl_trans_gen.trans\n\nnamespace red\n\n/-- Predicate asserting that word `w₁` can be reduced to `w₂` in one step, i.e. there are words\n`w₃ w₄` and letter `x` such that `w₁ = w₃xx⁻¹w₄` and `w₂ = w₃w₄`  -/\ntheorem step.length : ∀ {L₁ L₂ : list (α × bool)}, step L₁ L₂ → L₂.length + 2 = L₁.length\n| _ _ (@red.step.bnot _ L1 L2 x b) := by rw [list.length_append, list.length_append]; refl\n\n@[simp] lemma step.bnot_rev {x b} : step (L₁ ++ (x, bnot b) :: (x, b) :: L₂) (L₁ ++ L₂) :=\nby cases b; from step.bnot\n\n@[simp] lemma step.cons_bnot {x b} : red.step ((x, b) :: (x, bnot b) :: L) L :=\n@step.bnot _ [] _ _ _\n\n@[simp] lemma step.cons_bnot_rev {x b} : red.step ((x, bnot b) :: (x, b) :: L) L :=\n@red.step.bnot_rev _ [] _ _ _\n\ntheorem step.append_left : ∀ {L₁ L₂ L₃ : list (α × bool)}, step L₂ L₃ → step (L₁ ++ L₂) (L₁ ++ L₃)\n| _ _ _ red.step.bnot := by rw [← list.append_assoc, ← list.append_assoc]; constructor\n\ntheorem step.cons {x} (H : red.step L₁ L₂) : red.step (x :: L₁) (x :: L₂) :=\n@step.append_left _ [x] _ _ H\n\ntheorem step.append_right : ∀ {L₁ L₂ L₃ : list (α × bool)}, step L₁ L₂ → step (L₁ ++ L₃) (L₂ ++ L₃)\n| _ _ _ red.step.bnot := by simp\n\nlemma not_step_nil : ¬ step [] L :=\nbegin\n  generalize h' : [] = L',\n  assume h,\n  cases h with L₁ L₂,\n  simp [list.nil_eq_append_iff] at h',\n  contradiction\nend\n\nlemma step.cons_left_iff {a : α} {b : bool} :\n  step ((a, b) :: L₁) L₂ ↔ (∃L, step L₁ L ∧ L₂ = (a, b) :: L) ∨ (L₁ = (a, bnot b)::L₂) :=\nbegin\n  split,\n  { generalize hL : ((a, b) :: L₁ : list _) = L,\n    assume h,\n    rcases h with ⟨_ | ⟨p, s'⟩, e, a', b'⟩,\n    { simp at hL, simp [*] },\n    { simp at hL,\n      rcases hL with ⟨rfl, rfl⟩,\n      refine or.inl ⟨s' ++ e, step.bnot, _⟩,\n      simp } },\n  { assume h,\n    rcases h with ⟨L, h, rfl⟩ | rfl,\n    { exact step.cons h },\n    { exact step.cons_bnot } }\nend\n\nlemma not_step_singleton : ∀ {p : α × bool}, ¬ step [p] L\n| (a, b) := by simp [step.cons_left_iff, not_step_nil]\n\nlemma step.cons_cons_iff : ∀{p : α × bool}, step (p :: L₁) (p :: L₂) ↔ step L₁ L₂ :=\nby simp [step.cons_left_iff, iff_def, or_imp_distrib] {contextual := tt}\n\nlemma step.append_left_iff : ∀L, step (L ++ L₁) (L ++ L₂) ↔ step L₁ L₂\n| [] := by simp\n| (p :: l) := by simp [step.append_left_iff l, step.cons_cons_iff]\n\nprivate theorem step.diamond_aux : ∀ {L₁ L₂ L₃ L₄ : list (α × bool)} {x1 b1 x2 b2},\n  L₁ ++ (x1, b1) :: (x1, bnot b1) :: L₂ = L₃ ++ (x2, b2) :: (x2, bnot b2) :: L₄ →\n  L₁ ++ L₂ = L₃ ++ L₄ ∨ ∃ L₅, red.step (L₁ ++ L₂) L₅ ∧ red.step (L₃ ++ L₄) L₅\n| []        _ []        _ _ _ _ _ H := by injections; subst_vars; simp\n| []        _ [(x3,b3)] _ _ _ _ _ H := by injections; subst_vars; simp\n| [(x3,b3)] _ []        _ _ _ _ _ H := by injections; subst_vars; simp\n| []                     _ ((x3,b3)::(x4,b4)::tl) _ _ _ _ _ H :=\n  by injections; subst_vars; simp; right; exact ⟨_, red.step.bnot, red.step.cons_bnot⟩\n| ((x3,b3)::(x4,b4)::tl) _ []                     _ _ _ _ _ H :=\n  by injections; subst_vars; simp; right; exact ⟨_, red.step.cons_bnot, red.step.bnot⟩\n| ((x3,b3)::tl) _ ((x4,b4)::tl2) _ _ _ _ _ H :=\n  let ⟨H1, H2⟩ := list.cons.inj H in\n  match step.diamond_aux H2 with\n    | or.inl H3 := or.inl $ by simp [H1, H3]\n    | or.inr ⟨L₅, H3, H4⟩ := or.inr\n      ⟨_, step.cons H3, by simpa [H1] using step.cons H4⟩\n  end\n\ntheorem step.diamond : ∀ {L₁ L₂ L₃ L₄ : list (α × bool)},\n  red.step L₁ L₃ → red.step L₂ L₄ → L₁ = L₂ →\n  L₃ = L₄ ∨ ∃ L₅, red.step L₃ L₅ ∧ red.step L₄ L₅\n| _ _ _ _ red.step.bnot red.step.bnot H := step.diamond_aux H\n\nlemma step.to_red : step L₁ L₂ → red L₁ L₂ :=\nrefl_trans_gen.single\n\n/-- Church-Rosser theorem for word reduction: If `w1 w2 w3` are words such that `w1` reduces to `w2`\nand `w3` respectively, then there is a word `w4` such that `w2` and `w3` reduce to `w4` respectively. -/\ntheorem church_rosser : red L₁ L₂ → red L₁ L₃ → join red L₂ L₃ :=\nrelation.church_rosser (assume a b c hab hac,\nmatch b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := ⟨b, by refl, by refl⟩\n| b, c, or.inr ⟨d, hbd, hcd⟩ := ⟨d, refl_gen.single hbd, hcd.to_red⟩\nend)\n\nlemma cons_cons {p} : red L₁ L₂ → red (p :: L₁) (p :: L₂) :=\nrefl_trans_gen_lift (list.cons p) (assume a b, step.cons)\n\nlemma cons_cons_iff (p) : red (p :: L₁) (p :: L₂) ↔ red L₁ L₂ :=\niff.intro\n  begin\n    generalize eq₁ : (p :: L₁ : list _) = LL₁,\n    generalize eq₂ : (p :: L₂ : list _) = LL₂,\n    assume h,\n    induction h using relation.refl_trans_gen.head_induction_on\n      with L₁ L₂ h₁₂ h ih\n      generalizing L₁ L₂,\n    { subst_vars, cases eq₂, constructor },\n    { subst_vars,\n      cases p with a b,\n      rw [step.cons_left_iff] at h₁₂,\n      rcases h₁₂ with ⟨L, h₁₂, rfl⟩ | rfl,\n      { exact (ih rfl rfl).head h₁₂ },\n      { exact (cons_cons h).tail step.cons_bnot_rev } }\n  end\n  cons_cons\n\nlemma append_append_left_iff : ∀L, red (L ++ L₁) (L ++ L₂) ↔ red L₁ L₂\n| []       := iff.refl _\n| (p :: L) := by simp [append_append_left_iff L, cons_cons_iff]\n\nlemma append_append (h₁ : red L₁ L₃) (h₂ : red L₂ L₄) : red (L₁ ++ L₂) (L₃ ++ L₄) :=\n(refl_trans_gen_lift (λL, L ++ L₂) (assume a b, step.append_right) h₁).trans\n  ((append_append_left_iff _).2 h₂)\n\nlemma to_append_iff : red L (L₁ ++ L₂) ↔ (∃L₃ L₄, L = L₃ ++ L₄ ∧ red L₃ L₁ ∧ red L₄ L₂) :=\niff.intro\n  begin\n    generalize eq : L₁ ++ L₂ = L₁₂,\n    assume h,\n    induction h with L' L₁₂ hLL' h ih generalizing L₁ L₂,\n    { exact ⟨_, _, eq.symm, by refl, by refl⟩ },\n    { cases h with s e a b,\n      rcases list.append_eq_append_iff.1 eq with ⟨s', rfl, rfl⟩ | ⟨e', rfl, rfl⟩,\n      { have : L₁ ++ (s' ++ ((a, b) :: (a, bnot b) :: e)) = (L₁ ++ s') ++ ((a, b) :: (a, bnot b) :: e),\n        { simp },\n        rcases ih this with ⟨w₁, w₂, rfl, h₁, h₂⟩,\n        exact ⟨w₁, w₂, rfl, h₁, h₂.tail step.bnot⟩ },\n      { have : (s ++ ((a, b) :: (a, bnot b) :: e')) ++ L₂ = s ++ ((a, b) :: (a, bnot b) :: (e' ++ L₂)),\n        { simp },\n        rcases ih this with ⟨w₁, w₂, rfl, h₁, h₂⟩,\n        exact ⟨w₁, w₂, rfl, h₁.tail step.bnot, h₂⟩ }, }\n  end\n  (assume ⟨L₃, L₄, eq, h₃, h₄⟩, eq.symm ▸ append_append h₃ h₄)\n\n/-- The empty word `[]` only reduces to itself. -/\ntheorem nil_iff : red [] L ↔ L = [] :=\nrefl_trans_gen_iff_eq (assume l, red.not_step_nil)\n\n/-- A letter only reduces to itself. -/\ntheorem singleton_iff {x} : red [x] L₁ ↔ L₁ = [x] :=\nrefl_trans_gen_iff_eq (assume l, not_step_singleton)\n\n/-- If `x` is a letter and `w` is a word such that `xw` reduces to the empty word, then `w` reduces\nto `x⁻¹` -/\ntheorem cons_nil_iff_singleton {x b} : red ((x, b) :: L) [] ↔ red L [(x, bnot b)] :=\niff.intro\n  (assume h,\n    have h₁ : red ((x, bnot b) :: (x, b) :: L) [(x, bnot b)], from cons_cons h,\n    have h₂ : red ((x, bnot b) :: (x, b) :: L) L, from refl_trans_gen.single step.cons_bnot_rev,\n    let ⟨L', h₁, h₂⟩ := church_rosser h₁ h₂ in\n    by rw [singleton_iff] at h₁; subst L'; assumption)\n  (assume h, (cons_cons h).tail step.cons_bnot)\n\ntheorem red_iff_irreducible {x1 b1 x2 b2} (h : (x1, b1) ≠ (x2, b2)) :\n  red [(x1, bnot b1), (x2, b2)] L ↔ L = [(x1, bnot b1), (x2, b2)] :=\nbegin\n  apply refl_trans_gen_iff_eq,\n  generalize eq : [(x1, bnot b1), (x2, b2)] = L',\n  assume L h',\n  cases h',\n  simp [list.cons_eq_append_iff, list.nil_eq_append_iff] at eq,\n  rcases eq with ⟨rfl, ⟨rfl, rfl⟩, ⟨rfl, rfl⟩, rfl⟩, subst_vars,\n  simp at h,\n  contradiction\nend\n\n/-- If `x` and `y` are distinct letters and `w₁ w₂` are words such that `xw₁` reduces to `yw₂`, then\n`w₁` reduces to `x⁻¹yw₂`. -/\ntheorem inv_of_red_of_ne {x1 b1 x2 b2}\n  (H1 : (x1, b1) ≠ (x2, b2))\n  (H2 : red ((x1, b1) :: L₁) ((x2, b2) :: L₂)) :\n  red L₁ ((x1, bnot b1) :: (x2, b2) :: L₂) :=\nbegin\n  have : red ((x1, b1) :: L₁) ([(x2, b2)] ++ L₂), from H2,\n  rcases to_append_iff.1 this with ⟨_ | ⟨p, L₃⟩, L₄, eq, h₁, h₂⟩,\n  { simp [nil_iff] at h₁, contradiction },\n  { cases eq,\n    show red (L₃ ++ L₄) ([(x1, bnot b1), (x2, b2)] ++ L₂),\n    apply append_append _ h₂,\n    have h₁ : red ((x1, bnot b1) :: (x1, b1) :: L₃) [(x1, bnot b1), (x2, b2)],\n    { exact cons_cons h₁ },\n    have h₂ : red ((x1, bnot b1) :: (x1, b1) :: L₃) L₃,\n    { exact step.cons_bnot_rev.to_red },\n    rcases church_rosser h₁ h₂ with ⟨L', h₁, h₂⟩,\n    rw [red_iff_irreducible H1] at h₁,\n    rwa [h₁] at h₂ }\nend\n\ntheorem step.sublist (H : red.step L₁ L₂) : L₂ <+ L₁ :=\nby cases H; simp; constructor; constructor; refl\n\n/-- If `w₁ w₂` are words such that `w₁` reduces to `w₂`, then `w₂` is a sublist of `w₁`. -/\ntheorem sublist : red L₁ L₂ → L₂ <+ L₁ :=\nrefl_trans_gen_of_transitive_reflexive\n  (λl, list.sublist.refl l) (λa b c hab hbc, list.sublist.trans hbc hab) (λa b, red.step.sublist)\n\ntheorem sizeof_of_step : ∀ {L₁ L₂ : list (α × bool)}, step L₁ L₂ → L₂.sizeof < L₁.sizeof\n| _ _ (@step.bnot _ L1 L2 x b) :=\n  begin\n    induction L1 with hd tl ih,\n    case list.nil\n    { dsimp [list.sizeof],\n      have H : 1 + sizeof (x, b) + (1 + sizeof (x, bnot b) + list.sizeof L2)\n        = (list.sizeof L2 + 1) + (sizeof (x, b) + sizeof (x, bnot b) + 1),\n      { ac_refl },\n      rw H,\n      exact nat.le_add_right _ _ },\n    case list.cons\n    { dsimp [list.sizeof],\n      exact nat.add_lt_add_left ih _ }\n  end\n\ntheorem length (h : red L₁ L₂) : ∃ n, L₁.length = L₂.length + 2 * n :=\nbegin\n  induction h with L₂ L₃ h₁₂ h₂₃ ih,\n  { exact ⟨0, rfl⟩ },\n  { rcases ih with ⟨n, eq⟩,\n    existsi (1 + n),\n    simp [mul_add, eq, (step.length h₂₃).symm] }\nend\n\ntheorem antisymm (h₁₂ : red L₁ L₂) : red L₂ L₁ → L₁ = L₂ :=\nmatch L₁, h₁₂.cases_head with\n| _,  or.inl rfl            := assume h, rfl\n| L₁, or.inr ⟨L₃, h₁₃, h₃₂⟩ := assume h₂₁,\n  let ⟨n, eq⟩ := length (h₃₂.trans h₂₁) in\n  have list.length L₃ + 0 = list.length L₃ + (2 * n + 2),\n    by simpa [(step.length h₁₃).symm, add_comm, add_assoc] using eq,\n  (nat.no_confusion $ nat.add_left_cancel this)\nend\n\nend red\n\ntheorem equivalence_join_red : equivalence (join (@red α)) :=\nequivalence_join_refl_trans_gen $ assume a b c hab hac,\n(match b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := ⟨b, by refl, by refl⟩\n| b, c, or.inr ⟨d, hbd, hcd⟩ := ⟨d, refl_gen.single hbd, refl_trans_gen.single hcd⟩\nend)\n\ntheorem join_red_of_step (h : red.step L₁ L₂) : join red L₁ L₂ :=\njoin_of_single reflexive_refl_trans_gen h.to_red\n\ntheorem eqv_gen_step_iff_join_red : eqv_gen red.step L₁ L₂ ↔ join red L₁ L₂ :=\niff.intro\n  (assume h,\n    have eqv_gen (join red) L₁ L₂ := eqv_gen_mono (assume a b, join_red_of_step) h,\n    (eqv_gen_iff_of_equivalence $ equivalence_join_red).1 this)\n  (join_of_equivalence (eqv_gen.is_equivalence _) $ assume a b,\n    refl_trans_gen_of_equivalence (eqv_gen.is_equivalence _) eqv_gen.rel)\n\nend free_group\n\n/-- The free group over a type, i.e. the words formed by the elements of the type and their formal\ninverses, quotient by one step reduction. -/\ndef free_group (α : Type u) : Type u :=\nquot $ @free_group.red.step α\n\nnamespace free_group\n\nvariables {α} {L L₁ L₂ L₃ L₄ : list (α × bool)}\n\ndef mk (L) : free_group α := quot.mk red.step L\n\n@[simp] lemma quot_mk_eq_mk : quot.mk red.step L = mk L := rfl\n\n@[simp] lemma quot_lift_mk (β : Type v) (f : list (α × bool) → β)\n  (H : ∀ L₁ L₂, red.step L₁ L₂ → f L₁ = f L₂) :\nquot.lift f H (mk L) = f L := rfl\n\n@[simp] lemma quot_lift_on_mk (β : Type v) (f : list (α × bool) → β)\n  (H : ∀ L₁ L₂, red.step L₁ L₂ → f L₁ = f L₂) :\nquot.lift_on (mk L) f H = f L := rfl\n\ninstance : has_one (free_group α) := ⟨mk []⟩\nlemma one_eq_mk : (1 : free_group α) = mk [] := rfl\n\ninstance : has_mul (free_group α) :=\n⟨λ x y, quot.lift_on x\n    (λ L₁, quot.lift_on y (λ L₂, mk $ L₁ ++ L₂) (λ L₂ L₃ H, quot.sound $ red.step.append_left H))\n    (λ L₁ L₂ H, quot.induction_on y $ λ L₃, quot.sound $ red.step.append_right H)⟩\n@[simp] lemma mul_mk : mk L₁ * mk L₂ = mk (L₁ ++ L₂) := rfl\n\ninstance : has_inv (free_group α) :=\n⟨λx, quot.lift_on x (λ L, mk (L.map $ λ x : α × bool, (x.1, bnot x.2)).reverse)\n  (assume a b h, quot.sound $ by cases h; simp)⟩\n@[simp] lemma inv_mk : (mk L)⁻¹ = mk (L.map $ λ x : α × bool, (x.1, bnot x.2)).reverse := rfl\n\ninstance : group (free_group α) :=\n{ mul := (*),\n  one := 1,\n  inv := has_inv.inv,\n  mul_assoc := by rintros ⟨L₁⟩ ⟨L₂⟩ ⟨L₃⟩; simp,\n  one_mul := by rintros ⟨L⟩; refl,\n  mul_one := by rintros ⟨L⟩; simp [one_eq_mk],\n  mul_left_inv := by rintros ⟨L⟩; exact (list.rec_on L rfl $\n    λ ⟨x, b⟩ tl ih, eq.trans (quot.sound $ by simp [one_eq_mk]) ih) }\n\n/-- `of x` is the canonical injection from the type to the free group over that type by sending each\nelement to the equivalence class of the letter that is the element. -/\ndef of (x : α) : free_group α :=\nmk [(x, tt)]\n\ntheorem red.exact : mk L₁ = mk L₂ ↔ join red L₁ L₂ :=\ncalc (mk L₁ = mk L₂) ↔ eqv_gen red.step L₁ L₂ : iff.intro (quot.exact _) quot.eqv_gen_sound\n  ... ↔ join red L₁ L₂ : eqv_gen_step_iff_join_red\n\n/-- The canonical injection from the type to the free group is an injection. -/\ntheorem of.inj {x y : α} (H : of x = of y) : x = y :=\nlet ⟨L₁, hx, hy⟩ := red.exact.1 H in\nby simp [red.singleton_iff] at hx hy; cc\n\nsection to_group\n\nvariables {β : Type v} [group β] (f : α → β) {x y : free_group α}\n\ndef to_group.aux : list (α × bool) → β :=\nλ L, list.prod $ L.map $ λ x, cond x.2 (f x.1) (f x.1)⁻¹\n\ntheorem red.step.to_group {f : α → β} (H : red.step L₁ L₂) :\n  to_group.aux f L₁ = to_group.aux f L₂ :=\nby cases H with _ _ _ b; cases b; simp [to_group.aux]\n\n/-- If `β` is a group, then any function from `α` to `β`\nextends uniquely to a group homomorphism from\nthe free group over `α` to `β` -/\ndef to_group : free_group α → β :=\nquot.lift (to_group.aux f) $ λ L₁ L₂ H, red.step.to_group H\n\nvariable {f}\n\n@[simp] lemma to_group.mk : to_group f (mk L) =\n  list.prod (L.map $ λ x, cond x.2 (f x.1) (f x.1)⁻¹) :=\nrfl\n\n@[simp] lemma to_group.of {x} : to_group f (of x) = f x :=\none_mul _\n\ninstance to_group.is_group_hom : is_group_hom (to_group f) :=\n⟨by rintros ⟨L₁⟩ ⟨L₂⟩; simp⟩\n\n@[simp] lemma to_group.mul : to_group f (x * y) = to_group f x * to_group f y :=\nis_group_hom.mul _ _ _\n\n@[simp] lemma to_group.one : to_group f 1 = 1 :=\nis_group_hom.one _\n\n@[simp] lemma to_group.inv : to_group f x⁻¹ = (to_group f x)⁻¹ :=\nis_group_hom.inv _ _\n\ntheorem to_group.unique (g : free_group α → β) [is_group_hom g]\n  (hg : ∀ x, g (of x) = f x) : ∀{x}, g x = to_group f x :=\nby rintros ⟨L⟩; exact list.rec_on L (is_group_hom.one g)\n(λ ⟨x, b⟩ t (ih : g (mk t) = _), bool.rec_on b\n  (show g ((of x)⁻¹ * mk t) = to_group f (mk ((x, ff) :: t)),\n     by simp [is_group_hom.mul g, is_group_hom.inv g, hg, ih, to_group, to_group.aux])\n  (show g (of x * mk t) = to_group f (mk ((x, tt) :: t)),\n     by simp [is_group_hom.mul g, is_group_hom.inv g, hg, ih, to_group, to_group.aux]))\n\n\ntheorem to_group.of_eq (x : free_group α) : to_group of x = x :=\neq.symm $ to_group.unique id (λ x, rfl)\n\ntheorem to_group.range_subset {s : set β} [is_subgroup s] (H : set.range f ⊆ s) :\n  set.range (to_group f) ⊆ s :=\nby rintros _ ⟨⟨L⟩, rfl⟩; exact list.rec_on L (is_submonoid.one_mem s)\n(λ ⟨x, b⟩ tl ih, bool.rec_on b\n    (by simp at ih ⊢; from is_submonoid.mul_mem\n      (is_subgroup.inv_mem $ H ⟨x, rfl⟩) ih)\n    (by simp at ih ⊢; from is_submonoid.mul_mem (H ⟨x, rfl⟩) ih))\n\ntheorem to_group.range_eq_closure :\n  set.range (to_group f) = group.closure (set.range f) :=\nset.subset.antisymm\n  (to_group.range_subset group.subset_closure)\n  (group.closure_subset $ λ y ⟨x, hx⟩, ⟨of x, by simpa⟩)\n\nend to_group\n\nsection map\n\nvariables {β : Type v} (f : α → β) {x y : free_group α}\n\ndef map.aux (L : list (α × bool)) : list (β × bool) :=\nL.map $ λ x, (f x.1, x.2)\n\n/-- Any function from `α` to `β` extends uniquely\nto a group homomorphism from the free group\nver `α` to the free group over `β`. -/\ndef map (x : free_group α) : free_group β :=\nx.lift_on (λ L, mk $ map.aux f L) $\nλ L₁ L₂ H, quot.sound $ by cases H; simp [map.aux]\n\ninstance map.is_group_hom : is_group_hom (map f) :=\n⟨by rintros ⟨L₁⟩ ⟨L₂⟩; simp [map, map.aux]⟩\n\nvariable {f}\n\n@[simp] lemma map.mk : map f (mk L) = mk (L.map (λ x, (f x.1, x.2))) :=\nrfl\n\n@[simp] lemma map.id : map id x = x :=\nhave H1 : (λ (x : α × bool), x) = id := rfl,\nby rcases x with ⟨L⟩; simp [H1]\n\n@[simp] lemma map.id' : map (λ z, z) x = x := map.id\n\ntheorem map.comp {γ : Type w} {f : α → β} {g : β → γ} {x} :\n  map g (map f x) = map (g ∘ f) x :=\nby rcases x with ⟨L⟩; simp\n\n@[simp] lemma map.of {x} : map f (of x) = of (f x) := rfl\n\n@[simp] lemma map.mul : map f (x * y) = map f x * map f y :=\nis_group_hom.mul _ x y\n\n@[simp] lemma map.one : map f 1 = 1 :=\nis_group_hom.one _\n\n@[simp] lemma map.inv : map f x⁻¹ = (map f x)⁻¹ :=\nis_group_hom.inv _ x\n\ntheorem map.unique (g : free_group α → free_group β) [is_group_hom g]\n  (hg : ∀ x, g (of x) = of (f x)) : ∀{x}, g x = map f x :=\nby rintros ⟨L⟩; exact list.rec_on L (is_group_hom.one g)\n(λ ⟨x, b⟩ t (ih : g (mk t) = map f (mk t)), bool.rec_on b\n  (show g ((of x)⁻¹ * mk t) = map f ((of x)⁻¹ * mk t),\n     by simp [is_group_hom.mul g, is_group_hom.inv g, hg, ih])\n  (show g (of x * mk t) = map f (of x * mk t),\n     by simp [is_group_hom.mul g, hg, ih]))\n\n/-- Equivalent types give rise to equivalent free groups. -/\ndef free_group_congr {α β} (e : α ≃ β) : free_group α ≃ free_group β :=\n⟨map e, map e.symm,\n λ x, by simp [function.comp, map.comp],\n λ x, by simp [function.comp, map.comp]⟩\n\ntheorem map_eq_to_group : map f x = to_group (of ∘ f) x :=\neq.symm $ map.unique _ $ λ x, by simp\n\nend map\n\nsection prod\n\nvariables [group α] (x y : free_group α)\n\n/-- If `α` is a group, then any function from `α` to `α`\nextends uniquely to a homomorphism from the\nfree group over `α` to `α`. This is the multiplicative\nversion of `sum`. -/\ndef prod : α :=\nto_group id x\n\nvariables {x y}\n\n@[simp] lemma prod_mk :\n  prod (mk L) = list.prod (L.map $ λ x, cond x.2 x.1 x.1⁻¹) :=\nrfl\n\n@[simp] lemma prod.of {x : α} : prod (of x) = x :=\nto_group.of\n\ninstance prod.is_group_hom : is_group_hom (@prod α _) :=\nto_group.is_group_hom\n\n@[simp] lemma prod.mul : prod (x * y) = prod x * prod y :=\nto_group.mul\n\n@[simp] lemma prod.one : prod (1:free_group α) = 1 :=\nto_group.one\n\n@[simp] lemma prod.inv : prod x⁻¹ = (prod x)⁻¹ :=\nto_group.inv\n\nlemma prod.unique (g : free_group α → α) [is_group_hom g]\n  (hg : ∀ x, g (of x) = x) {x} :\n  g x = prod x :=\nto_group.unique g hg\n\nend prod\n\ntheorem to_group_eq_prod_map {β : Type v} [group β] {f : α → β} {x} :\n  to_group f x = prod (map f x) :=\neq.symm $ to_group.unique (prod ∘ map f) $ λ _, by simp\n\nsection sum\n\nvariables [add_group α] (x y : free_group α)\n\n/-- If `α` is a group, then any function from `α` to `α`\nextends uniquely to a homomorphism from the\nfree group over `α` to `α`. This is the additive\nversion of `prod`. -/\ndef sum : α :=\n@prod (multiplicative _) _ x\n\nvariables {x y}\n\n@[simp] lemma sum_mk :\n  sum (mk L) = list.sum (L.map $ λ x, cond x.2 x.1 (-x.1)) :=\nrfl\n\n@[simp] lemma sum.of {x : α} : sum (of x) = x :=\nprod.of\n\ninstance sum.is_group_hom : is_group_hom (@sum α _) :=\nprod.is_group_hom\n\n@[simp] lemma sum.sum : sum (x * y) = sum x + sum y :=\nprod.mul\n\n@[simp] lemma sum.one : sum (1:free_group α) = 0 :=\nprod.one\n\n@[simp] lemma sum.inv : sum x⁻¹ = -sum x :=\nprod.inv\n\nend sum\n\ndef free_group_empty_equiv_unit : free_group empty ≃ unit :=\n{ to_fun    := λ _, (),\n  inv_fun   := λ _, 1,\n  left_inv  := by rintros ⟨_ | ⟨⟨⟨⟩, _⟩, _⟩⟩; refl,\n  right_inv := λ ⟨⟩, rfl }\n\ndef free_group_unit_equiv_int : free_group unit ≃ int :=\n{ to_fun    := λ x, sum $ map (λ _, 1) x,\n  inv_fun   := λ x, of () ^ x,\n  left_inv  := by rintros ⟨L⟩; exact list.rec_on L rfl\n    (λ ⟨⟨⟩, b⟩ tl ih, by cases b; simp [gpow_add] at ih ⊢; rw ih; refl),\n  right_inv := λ x, int.induction_on x (by simp)\n    (λ i ih, by simp at ih; simp [gpow_add, ih])\n    (λ i ih, by simp at ih; simp [gpow_add, ih]) }\n\nsection category\n\nvariables {β : Type u}\n\ninstance : monad free_group.{u} :=\n{ pure := λ α, of,\n  map := λ α β, map,\n  bind := λ α β x f, to_group f x }\n\n@[elab_as_eliminator]\nprotected theorem induction_on\n  {C : free_group α → Prop}\n  (z : free_group α)\n  (C1 : C 1)\n  (Cp : ∀ x, C $ pure x)\n  (Ci : ∀ x, C (pure x) → C (pure x)⁻¹)\n  (Cm : ∀ x y, C x → C y → C (x * y)) : C z :=\nquot.induction_on z $ λ L, list.rec_on L C1 $ λ ⟨x, b⟩ tl ih,\nbool.rec_on b (Cm _ _ (Ci _ $ Cp x) ih) (Cm _ _ (Cp x) ih)\n\n@[simp] lemma map_pure (f : α → β) (x : α) : f <$> (pure x : free_group α) = pure (f x) :=\nmap.of\n\n@[simp] lemma map_one (f : α → β) : f <$> (1 : free_group α) = 1 :=\nmap.one\n\n@[simp] lemma map_mul (f : α → β) (x y : free_group α) : f <$> (x * y) = f <$> x * f <$> y :=\nmap.mul\n\n@[simp] lemma map_inv (f : α → β) (x : free_group α) : f <$> (x⁻¹) = (f <$> x)⁻¹ :=\nmap.inv\n\n@[simp] lemma pure_bind (f : α → free_group β) (x) : pure x >>= f = f x :=\nto_group.of\n\n@[simp] lemma one_bind (f : α → free_group β) : 1 >>= f = 1 :=\n@@to_group.one _ f\n\n@[simp] lemma mul_bind (f : α → free_group β) (x y : free_group α) : x * y >>= f = (x >>= f) * (y >>= f) :=\nto_group.mul\n\n@[simp] lemma inv_bind (f : α → free_group β) (x : free_group α) : x⁻¹ >>= f = (x >>= f)⁻¹ :=\nto_group.inv\n\ninstance : is_lawful_monad free_group.{u} :=\n{ id_map := λ α x, free_group.induction_on x (map_one id) (λ x, map_pure id x)\n    (λ x ih, by rw [map_inv, ih]) (λ x y ihx ihy, by rw [map_mul, ihx, ihy]),\n  pure_bind := λ α β x f, pure_bind f x,\n  bind_assoc := λ α β γ x f g, free_group.induction_on x\n    (by iterate 3 { rw one_bind }) (λ x, by iterate 2 { rw pure_bind })\n    (λ x ih, by iterate 3 { rw inv_bind }; rw ih)\n    (λ x y ihx ihy, by iterate 3 { rw mul_bind }; rw [ihx, ihy]),\n  bind_pure_comp_eq_map := λ α β f x, free_group.induction_on x\n    (by rw [one_bind, map_one]) (λ x, by rw [pure_bind, map_pure])\n    (λ x ih, by rw [inv_bind, map_inv, ih]) (λ x y ihx ihy, by rw [mul_bind, map_mul, ihx, ihy]) }\n\nend category\n\nsection reduce\n\nvariable [decidable_eq α]\n\n/-- The maximal reduction of a word. It is computable\niff `α` has decidable equality. -/\ndef reduce (L : list (α × bool)) : list (α × bool) :=\nlist.rec_on L [] $ λ hd1 tl1 ih,\nlist.cases_on ih [hd1] $ λ hd2 tl2,\nif hd1.1 = hd2.1 ∧ hd1.2 = bnot hd2.2 then tl2\nelse hd1 :: hd2 :: tl2\n\n@[simp] lemma reduce.cons (x) : reduce (x :: L) =\n  list.cases_on (reduce L) [x] (λ hd tl,\n  if x.1 = hd.1 ∧ x.2 = bnot hd.2 then tl\n  else x :: hd :: tl) := rfl\n\n/-- The first theorem that characterises the function\n`reduce`: a word reduces to its maximal reduction. -/\ntheorem reduce.red : red L (reduce L) :=\nbegin\n  induction L with hd1 tl1 ih,\n  case list.nil\n  { constructor },\n  case list.cons\n  { dsimp,\n    revert ih,\n    generalize htl : reduce tl1 = TL,\n    intro ih,\n    cases TL with hd2 tl2,\n    case list.nil\n    { exact red.cons_cons ih },\n    case list.cons\n    { dsimp,\n      by_cases h : hd1.fst = hd2.fst ∧ hd1.snd = bnot (hd2.snd),\n      { rw [if_pos h],\n        transitivity,\n        { exact red.cons_cons ih },\n        { cases hd1, cases hd2, cases h,\n          dsimp at *, subst_vars,\n          exact red.step.cons_bnot_rev.to_red } },\n      { rw [if_neg h],\n        exact red.cons_cons ih } } }\nend\n\ntheorem reduce.not {p : Prop} : ∀ {L₁ L₂ L₃ : list (α × bool)} {x b}, reduce L₁ = L₂ ++ (x, b) :: (x, bnot b) :: L₃ → p\n| [] L2 L3 _ _ := λ h, by cases L2; injections\n| ((x,b)::L1) L2 L3 x' b' := begin\n  dsimp,\n  cases r : reduce L1,\n  { dsimp, intro h,\n    have := congr_arg list.length h,\n    simp [-add_comm] at this,\n    exact absurd this dec_trivial },\n  cases hd with y c,\n  by_cases x = y ∧ b = bnot c; simp [h]; intro H,\n  { rw H at r,\n    exact @reduce.not L1 ((y,c)::L2) L3 x' b' r },\n  rcases L2 with _|⟨a, L2⟩,\n  { injections, subst_vars,\n    simp at h, cc },\n  { refine @reduce.not L1 L2 L3 x' b' _,\n    injection H with _ H,\n    rw [r, H], refl }\nend\n\n/-- The second theorem that characterises the\nfunction `reduce`: the maximal reduction of a word\nonly reduces to itself. -/\ntheorem reduce.min (H : red (reduce L₁) L₂) : reduce L₁ = L₂ :=\nbegin\n  induction H with L1 L' L2 H1 H2 ih,\n  { refl },\n  { cases H1 with L4 L5 x b,\n    exact reduce.not H2 }\nend\n\n/-- `reduce` is idempotent, i.e. the maximal reduction\nof the maximal reduction of a word is the maximal\nreduction of the word. -/\ntheorem reduce.idem : reduce (reduce L) = reduce L :=\neq.symm $ reduce.min reduce.red\n\ntheorem reduce.step.eq (H : red.step L₁ L₂) : reduce L₁ = reduce L₂ :=\nlet ⟨L₃, HR13, HR23⟩ := red.church_rosser reduce.red (reduce.red.head H) in\n(reduce.min HR13).trans (reduce.min HR23).symm\n\n/-- If a word reduces to another word, then they have\na common maximal reduction. -/\ntheorem reduce.eq_of_red (H : red L₁ L₂) : reduce L₁ = reduce L₂ :=\nlet ⟨L₃, HR13, HR23⟩ := red.church_rosser reduce.red (red.trans H reduce.red) in\n(reduce.min HR13).trans (reduce.min HR23).symm\n\n/-- If two words correspond to the same element in\nthe free group, then they have a common maximal\nreduction. This is the proof that the function that\nsends an element of the free group to its maximal\nreduction is well-defined. -/\ntheorem reduce.sound (H : mk L₁ = mk L₂) : reduce L₁ = reduce L₂ :=\nlet ⟨L₃, H13, H23⟩ := red.exact.1 H in\n(reduce.eq_of_red H13).trans (reduce.eq_of_red H23).symm\n\n/-- If two words have a common maximal reduction,\nthen they correspond to the same element in the free group. -/\ntheorem reduce.exact (H : reduce L₁ = reduce L₂) : mk L₁ = mk L₂ :=\nred.exact.2 ⟨reduce L₂, H ▸ reduce.red, reduce.red⟩\n\n/-- A word and its maximal reduction correspond to\nthe same element of the free group. -/\ntheorem reduce.self : mk (reduce L) = mk L :=\nreduce.exact reduce.idem\n\n/-- If words `w₁ w₂` are such that `w₁` reduces to `w₂`,\nthen `w₂` reduces to the maximal reduction of `w₁`. -/\ntheorem reduce.rev (H : red L₁ L₂) : red L₂ (reduce L₁) :=\n(reduce.eq_of_red H).symm ▸ reduce.red\n\n/-- The function that sends an element of the free\ngroup to its maximal reduction. -/\ndef to_word : free_group α → list (α × bool) :=\nquot.lift reduce $ λ L₁ L₂ H, reduce.step.eq H\n\ndef to_word.mk : ∀{x : free_group α}, mk (to_word x) = x :=\nby rintros ⟨L⟩; exact reduce.self\n\ndef to_word.inj : ∀(x y : free_group α), to_word x = to_word y → x = y :=\nby rintros ⟨L₁⟩ ⟨L₂⟩; exact reduce.exact\n\n/-- Constructive Church-Rosser theorem (compare `church_rosser`). -/\ndef reduce.church_rosser (H12 : red L₁ L₂) (H13 : red L₁ L₃) :\n  { L₄ // red L₂ L₄ ∧ red L₃ L₄ } :=\n⟨reduce L₁, reduce.rev H12, reduce.rev H13⟩\n\ninstance : decidable_eq (free_group α) :=\nfunction.injective.decidable_eq to_word.inj\n\ninstance red.decidable_rel : decidable_rel (@red α)\n| [] []          := is_true red.refl\n| [] (hd2::tl2)  := is_false $ λ H, list.no_confusion (red.nil_iff.1 H)\n| ((x,b)::tl) [] := match red.decidable_rel tl [(x, bnot b)] with\n  | is_true H  := is_true $ red.trans (red.cons_cons H) $\n    (@red.step.bnot _ [] [] _ _).to_red\n  | is_false H := is_false $ λ H2, H $ red.cons_nil_iff_singleton.1 H2\n  end\n| ((x1,b1)::tl1) ((x2,b2)::tl2) := if h : (x1, b1) = (x2, b2)\n  then match red.decidable_rel tl1 tl2 with\n    | is_true H  := is_true $ h ▸ red.cons_cons H\n    | is_false H := is_false $ λ H2, H $ h ▸ (red.cons_cons_iff _).1 $ H2\n    end\n  else match red.decidable_rel tl1 ((x1,bnot b1)::(x2,b2)::tl2) with\n    | is_true H  := is_true $ (red.cons_cons H).tail red.step.cons_bnot\n    | is_false H := is_false $ λ H2, H $ red.inv_of_red_of_ne h H2\n    end\n\n/-- A list containing every word that `w₁` reduces to. -/\ndef red.enum (L₁ : list (α × bool)) : list (list (α × bool)) :=\nlist.filter (λ L₂, red L₁ L₂) (list.sublists L₁)\n\ntheorem red.enum.sound (H : L₂ ∈ red.enum L₁) : red L₁ L₂ :=\nlist.of_mem_filter H\n\ntheorem red.enum.complete (H : red L₁ L₂) : L₂ ∈ red.enum L₁ :=\nlist.mem_filter_of_mem (list.mem_sublists.2 $ red.sublist H) H\n\ninstance : fintype { L₂ // red L₁ L₂ } :=\nfintype.subtype (list.to_finset $ red.enum L₁) $\nλ L₂, ⟨λ H, red.enum.sound $ list.mem_to_finset.1 H,\n  λ H, list.mem_to_finset.2 $ red.enum.complete H⟩\n\nend reduce\n\nend free_group\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/group_theory/free_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.4726800655934815}}
{"text": "import GMLInit.Meta.Basic\nimport GMLInit.Meta.Decidable\nimport GMLInit.Meta.Relation\n\nnamespace Nat\n\n@[eliminator] protected def recAux.{u} {motive : Nat → Sort u} (zero : motive 0) (succ : (n : Nat) → motive n → motive (n+1)) : (t : Nat) → motive t\n| 0 => zero\n| n+1 => succ n (Nat.recAux zero succ n)\n\nprotected def recAuxOn.{u} {motive : Nat → Sort u} (t : Nat) (zero : motive 0) (succ : (n : Nat) → motive n → motive (n+1)) : motive t :=\n  Nat.recAux zero succ t\n\nprotected def casesAuxOn.{u} {motive : Nat → Sort u} (t : Nat) (zero : motive 0) (succ : (n : Nat) → motive (n+1)) : motive t :=\n  Nat.recAux zero (λ n _ => succ n) t\n\nprotected def recDiagAux.{u} {motive : Nat → Nat → Sort u}\n  (left : (x : Nat) → motive x 0)\n  (right : (y : Nat) → motive 0 y)\n  (diag : (x y : Nat) → motive x y → motive (x + 1) (y + 1)) :\n  (x y : Nat) → motive x y\n| x, 0 => left x\n| 0, y => right y\n| x + 1, y + 1 => diag x y (Nat.recDiagAux left right diag x y)\n\nprotected def recDiagAuxOn.{u} {motive : Nat → Nat → Sort u} (x y : Nat)\n  (left : (x : Nat) → motive x 0)\n  (right : (y : Nat) → motive 0 y)\n  (diag : (x y : Nat) → motive x y → motive (x + 1) (y + 1)) :\n  motive x y :=\n  Nat.recDiagAux left right diag x y\n\nprotected def casesDiagAuxOn.{u} {motive : Nat → Nat → Sort u} (x y : Nat)\n  (left : (x : Nat) → motive x 0)\n  (right : (y : Nat) → motive 0 y)\n  (diag : (x y : Nat) → motive (x + 1) (y + 1)) :\n  motive x y :=\n  Nat.recDiagAuxOn x y left right (λ x y _ => diag x y)\n\nprotected def recDiag.{u} {motive : Nat → Nat → Sort u}\n  (zero_zero : motive 0 0)\n  (succ_zero : (x : Nat) → motive x 0 → motive (x + 1) 0)\n  (zero_succ : (y : Nat) → motive 0 y → motive 0 (y + 1))\n  (succ_succ : (x y : Nat) → motive x y → motive (x + 1) (y + 1)) :\n  (x y : Nat) → motive x y :=\n  Nat.recDiagAux left right succ_succ where\n  left : (x : Nat) → motive x 0\n  | 0 => zero_zero\n  | x+1 => succ_zero x (left x)\n  right : (y : Nat) → motive 0 y\n  | 0 => zero_zero\n  | y+1 => zero_succ y (right y)\n\nprotected def recDiagOn.{u} {motive : Nat → Nat → Sort u} (x y : Nat)\n  (zero_zero : motive 0 0)\n  (succ_zero : (x : Nat) → motive x 0 → motive (x + 1) 0)\n  (zero_succ : (y : Nat) → motive 0 y → motive 0 (y + 1))\n  (succ_succ : (x y : Nat) → motive x y → motive (x + 1) (y + 1)) :\n  motive x y :=\n  Nat.recDiag zero_zero succ_zero zero_succ succ_succ x y\n\nprotected def casesDiagOn.{u} {motive : Nat → Nat → Sort u} (x y : Nat)\n  (zero_zero : motive 0 0)\n  (succ_zero : (x : Nat) → motive (x + 1) 0)\n  (zero_succ : (y : Nat) → motive 0 (y + 1))\n  (succ_succ : (x y : Nat) → motive (x + 1) (y + 1)) :\n  motive x y :=\n  Nat.recDiagOn x y zero_zero (λ x _ => succ_zero x) (λ y _ => zero_succ y) (λ x y _ => succ_succ x y)\n\nsection clean\n\nattribute [clean] Nat.zero_eq Nat.add_eq Nat.sub_eq Nat.mul_eq Nat.div_eq Nat.mod_eq Nat.pow_eq Nat.add_zero Nat.mul_zero Nat.pow_zero\n\n@[simp,clean] protected lemma succ_eq (x : Nat) : Nat.succ x = x + 1 := rfl\n\n@[simp,clean] protected lemma pred_eq (x : Nat) : Nat.pred x = x - 1 := rfl\n\nend clean\n\nend Nat\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/Nat/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334527, "lm_q2_score": 0.679178692681616, "lm_q1q2_score": 0.4726800653571076}}
{"text": "\nimport pq_like_equalizer_util\n\nuniverse u\n\nsection pq_like_equalizer\n\n-- Idea: Eq(eta, L(eta)) is normal. Useful for proving injectivity?\n\nvariables {Q : Type u} [power_quandle Q]\n\nlemma eta_equalizer_iso_forward_of_L_of (x : pq_group (eta_equalizer Q)) : of (eta_equalizer_iso_forward x) = (L_of_morph of of_is_pq_morphism) (eta_equalizer_iso_forward x) :=\nbegin \n  revert x,\n  refine pq_group_word_induction _ _,\n  {\n    simp only [monoid_hom.map_one],\n    rw of_one,\n  },\n  {\n    intros x y hx,\n    simp only [monoid_hom.map_mul],\n    rw ←hx,\n    rw eta_equalizer_iso_forward_of,\n    cases y with y hy,\n    simp only,\n    unfold eta_equalizer at hy,\n    rw set.mem_def at hy,\n    sorry,\n  },\nend\n\nlemma inclusion_counit_of (x : pq_group (eta_equalizer Q)) : pq_group_eta_equalizer_inclusion x = of (counit (pq_group_eta_equalizer_inclusion x)) :=\nbegin\n  rw inclusion_eq_L_of_of_forward,\n  rw counit_L_of,\n  rw eta_equalizer_iso_forward_of_L_of,\nend\n\nlemma pq_group_eta_equalizer_inclusion_injective : function.injective (pq_group_eta_equalizer_inclusion : pq_group (eta_equalizer Q) → pq_group (pq_group Q)) :=\nbegin\n  --intros x y hxy,\n  refine pq_group_eta_equalizer_inclusion.injective_iff.mpr _,\n  intros x hx,\n  --rw inclusion_eq_L_of_of_forward at hx,\n  \n  revert x,\n  refine pq_group_list _,\n  {\n    intros x hxy,\n    have hxy_rw : (L_of_morph of of_is_pq_morphism) (list.prod (list.map (λ z : (eta_equalizer Q), ↑z) x)) = pq_group_eta_equalizer_inclusion (list.map of x).prod,\n    {\n      clear hxy,\n      induction x,\n      {\n        simp only [list.prod_nil, list.map, monoid_hom.map_one],\n      },\n      {\n        simp only [monoid_hom.map_mul, list.prod_cons, list.map],\n        simp only at x_ih,\n        rw x_ih,\n        congr,\n        clear x_ih x_tl,\n        cases x_hd with x hx,\n        simp only [subtype.coe_mk],\n        have hx1 := eta_equalizer_mem_def _ hx,\n        rw ←hx1,\n        refl,\n      },\n    },\n    rw ←hxy_rw at hxy,\n    clear hxy_rw,\n    sorry,\n    /-\n    have hxy1 : (list.map (λ z : (eta_equalizer Q), (of (↑z) : pq_group (pq_group Q))) x).prod = pq_group_eta_equalizer_inclusion (list.map of x).prod,\n    {\n      clear hxy,\n      induction x with a b hb,\n      {\n        simp only [list.prod_nil, list.map, monoid_hom.map_one],\n      },\n      {\n        simp only [monoid_hom.map_mul, list.prod_cons, list.map],\n        rw hb,\n        cases a with a ha,\n        refl,\n      },\n    },\n    rw ←hxy1 at hxy,\n    clear hxy1,\n    induction x with y x hx,\n    {\n      simp only [list.prod_nil, list.map],\n    },\n    {\n      cases y with y hy,\n      simp only [list.prod_cons, list.map],\n      simp only [list.prod_cons, subtype.coe_mk, list.map] at hxy,\n      \n      sorry,\n    },\n    -/\n  },\n  \nend\n\n/-\nlemma eta_equalizer_iso_helper (x : pq_group Q) (hx : x ∈ ↑(eta_equalizer Q)) : of (⟨x, hx⟩ : eta_equalizer Q) = (L_of_morph of of_is_pq_morphism) (⟨x, hx⟩ : eta_equalizer Q) :=\nbegin\n\nend\n-/\n\ntheorem eta_equalizer_iso_helper_2 (x : pq_group (eta_equalizer Q)) : eta_equalizer_iso_backward (counit (pq_group_eta_equalizer_inclusion x)) = x :=\nbegin\n  revert x,\n  refine pq_group_word_induction _ _,\n  {\n    simp only [monoid_hom.map_one],\n  },\n  {\n    intros x y hx,\n    simp only [monoid_hom.map_mul, hx, mul_left_inj],\n    clear hx,\n    clear x,\n    unfold pq_group_eta_equalizer_inclusion,\n    rw L_of_morph_of,\n    cases y with y hy,\n    simp only,\n    rw eta_equalizer_mem_def,\n    swap, exact hy,\n    revert y,\n    refine pq_group_word_induction _ _,\n    {\n      intros h1,\n      simp only [monoid_hom.map_one],\n      rw ←of_one,\n      refl,\n    },\n    {\n      intros x y hx hxy,\n      sorry,\n    },\n  },\nend\n\ntheorem eta_equalizer_iso_helper (x : eta_equalizer Q) : eta_equalizer_iso_backward (eta_equalizer_iso_forward (of x)) = of x :=\nbegin\n  rw eta_equalizer_iso_forward_of,\n  cases x with x hx,\n  simp only,\n  sorry,\n  /-\n  revert x,\n  refine pq_group_list _,\n  intros x hx,\n  sorry,\n  -/\n  /-\n  refine pq_group_word_induction _ _,\n  {\n    intro hx,\n    simp only [monoid_hom.map_one],\n    rw ←of_one,\n    refl,\n  },\n  {\n    intros x y hx hxy,\n    simp only [monoid_hom.map_mul],\n    rw eta_equalizer_iso_backward_of,\n    have hxy1 := eta_equalizer_mem_def _ hxy,\n    simp only [monoid_hom.map_mul, L_of_morph_of] at hxy1,\n\n  },\n  -/\nend\n\ndef eta_equalizer_iso : pq_group (eta_equalizer Q) ≃* pq_group Q := { \n  to_fun := eta_equalizer_iso_forward,\n  inv_fun := eta_equalizer_iso_backward,\n  left_inv := begin \n    refine pq_group_word_induction _ _,\n    {\n      simp only [monoid_hom.map_one],\n    },\n    {\n      intros x y hx,\n      simp only [monoid_hom.map_mul],\n      rw hx,\n      congr,\n      unfold eta_equalizer_iso_forward,\n      rw pq_morph_to_L_morph_adj_comm_of,\n      cases y with y hy,\n      simp only,\n      clear hx,\n      clear x,\n      apply pq_group_eta_equalizer_inclusion_injective,\n      rw eta_equalizer_in_sub_pq,\n      clear hy,\n      revert y,\n      refine pq_group_word_induction _ _,\n      {\n        simp only [monoid_hom.map_one],\n      },\n      {\n        intros x y hx,\n        simp only [monoid_hom.map_mul],\n        rw hx,\n        congr,\n      },\n    },\n  end,\n  right_inv := begin \n    exact eta_equalizer_iso_forward_of_backward,\n  end,\n  map_mul' := begin \n    intros x y,\n    simp only [monoid_hom.map_mul],\n  end }\n\n\n\nend pq_like_equalizer\n", "meta": {"author": "torstein-vik", "repo": "power-quandle-lean", "sha": "452437602c4be2e6c5ad5f5224b068baabfdf9e1", "save_path": "github-repos/lean/torstein-vik-power-quandle-lean", "path": "github-repos/lean/torstein-vik-power-quandle-lean/power-quandle-lean-452437602c4be2e6c5ad5f5224b068baabfdf9e1/src/pq_like_equalizer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4726747861025519}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\n\nimport abelian\nimport exact\nimport pseudoelements\nimport algebra.homology.homology\n\nopen category_theory\nopen category_theory.limits\nopen cochain_complex\n\nuniverses v u\n\nnamespace category_theory.abelian\n\nopen pseudoelements\n\nsection\nvariables {V : Type u} [𝒱 : category.{v} V] [abelian.{v} V]\ninclude 𝒱\n\nlocal attribute [instance] has_zero_object.has_zero preadditive.has_equalizers_of_has_kernels\n\nsection\nvariable (C : cochain_complex.{v} V)\n\ndef cokernel_to_image_map (i : ℤ) : cokernel (C.d i) ⟶ image (C.d (i + 1)) :=\ncokernel.desc (C.d i) (cokernel.π (kernel.ι (C.d (i + 1))))\nbegin\n  apply (preadditive.cancel_zero_iff_mono (factor_thru_coimage (C.d (i + 1)))).1 (by apply_instance),\n  rw [category.assoc, coimage.fac, d_squared],\nend\n\ninstance coker_to_im_epi {i : ℤ} : epi (cokernel_to_image_map C i) :=\nepi_of_epi_fac $ show cokernel.π (C.d i) ≫ cokernel_to_image_map C i = cokernel.π (kernel.ι (C.d (i + 1))),\n  by erw colimit.ι_desc; refl\n\ndef dd (i : ℤ) : cokernel (C.d i) ⟶ kernel (C.d (i + 1 + 1)) :=\ncokernel_to_image_map C i ≫ image_to_kernel_map C (i + 1)\n\nlemma exact_right (i : ℤ) : exact (dd C i) (cokernel.π (image_to_kernel_map C (i + 1))) :=\nexact_left_epi _ _ _ $ cokernel_exact _\n\nend\n\nend\n\nend category_theory.abelian\n", "meta": {"author": "TwoFX", "repo": "lean-homological-algebra", "sha": "e3a8e4ecaf49bec6c7b38b34c0b8f9749e941aa8", "save_path": "github-repos/lean/TwoFX-lean-homological-algebra", "path": "github-repos/lean/TwoFX-lean-homological-algebra/lean-homological-algebra-e3a8e4ecaf49bec6c7b38b34c0b8f9749e941aa8/src/cohomology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.47267477997936863}}
{"text": "import algebra.module.linear_map\nimport algebra.module.graded_module\nimport ring_theory.graded_algebra.homogeneous_ideal\nimport ring_theory.ideal.quotient\nimport ring_theory.ideal.quotient_operations\n\n\nimport ring_theory.graded_algebra.basic\nimport algebra.graded_mul_action\nimport algebra.direct_sum.decomposition\nimport algebra.module.big_operators\n\n/-!\n# Graded modules over a graded ring, homogeneous submodules\n\nThis file defines a graded module (given by `ℳ : ι → submodule R M` for a `module R M`, homogeneous submodules, and operations on them (sums, intersections, quotients…)\n\nThe ring `R` is  not graded.\n\nAt the end, one adds an `graded_ring 𝒜` for `𝒜 : ι → submodule R A`, an `A`-algebra structure on `M` which is compatible with the `R`-module structure, and the multiplication is compatible with the gradings. \n\nThe case of homogeneous ideals of a graded ring follows.\n\nWORK IN PROGRESS\n\nQuestion : should there be a variant “without R” ?\nMathematically, this is equivalent with having R = ℕ,\nbut it may be painful to have to use `to_nat_module`…\n\nQuestion : There is no reason that the indices of the grading of the ring are the same as for the module, \none should just have an `add_smul_action : ι → θ → θ`\n\nQuestion : What about multiplicative weights?\n\n-/\n\n\nopen set_like direct_sum set\nopen_locale big_operators pointwise direct_sum\n\nvariables {ι σ τ R A M : Type*}\n\n\nvariables [semiring R]\nvariables [decidable_eq ι] [add_monoid ι]\nvariables [add_comm_monoid M] [module R M] \n\n-- variables [comm_ring A] [algebra R A] [module A M] [is_scalar_tower R A M]\n\n-- variables (𝒜 : ι → submodule R A) \n\nvariable (ℳ : ι → submodule R M) \n\nsection graded_module\n\n-- variables [set_like.graded_monoid 𝒜] [graded_ring 𝒜] [set_like.has_graded_smul 𝒜 ℳ]\n\n-- example : set_like.has_graded_smul 𝒜 𝒜 := \n-- set_like.has_graded_mul.to_has_graded_smul 𝒜\n\n/-  Trop lourd\n class graded_module {ι : Type*}  [decidable_eq ι] [add_monoid ι]\n  {A R M : Type*} \n  [comm_semiring R] [comm_semiring A] [add_comm_monoid M] [algebra R A]\n  [graded_algebra 𝒜]\n  [module R M] [module A M] [is_scalar_tower R A M]\n  {σ : Type*} [set_like σ A] [add_submonoid_class σ A] [submodule_class σ R A] (𝒜 : ι → σ) \n  {τ : Type*} [set_like τ M] [add_submonoid_class τ M] [submodule_class τ R M] (ℳ : ι → τ) :=\n(to_decomposition : direct_sum.decomposition ℳ)\n(to_graded_smul : set_like.has_graded_smul 𝒜 ℳ)\n -/\n\nclass graded_module {ι : Type*}  [decidable_eq ι] [add_monoid ι]\n  {R M : Type*} \n  [semiring R] [add_comm_monoid M] \n  [module R M] \n  {τ : Type*} [set_like τ M] [add_submonoid_class τ M] [submodule_class τ R M] (ℳ : ι → τ) \n  extends direct_sum.decomposition ℳ\n\n\nvariable [graded_module ℳ]\n\n/-- The projection maps of a graded module -/\ndef graded_module.proj (i : ι) : M →+ M :=\n(add_submonoid_class.subtype (ℳ i)).comp ((dfinsupp.eval_add_monoid_hom i).comp $\n  add_equiv.to_add_monoid_hom $ direct_sum.decompose_add_equiv ℳ)\n\n@[simp] lemma graded_module.proj_apply (i : ι) (r : M) :\n  graded_module.proj ℳ i r = (decompose ℳ r : ⨁ i, ℳ i) i := rfl\n\nlemma graded_module.proj_recompose (r : ⨁ i, ℳ i) (i : ι) :\n  graded_module.proj ℳ i ((decompose ℳ).symm r) =\n  (decompose ℳ).symm (direct_sum.of _ i (r i)) :=\nby rw [graded_module.proj_apply, decompose_symm_of, equiv.apply_symm_apply]\n\nlemma graded_module.mem_support_iff [Π i (x : ℳ i), decidable (x ≠ 0)] (r : M) (i : ι) :\n  i ∈ (decompose ℳ r).support ↔ graded_module.proj ℳ i r ≠ 0 :=\ndfinsupp.mem_support_iff.trans zero_mem_class.coe_eq_zero.not.symm\n\nend graded_module\n\n\nsection homogeneous_def\n\nvariable [graded_module ℳ]\n\nvariable {R}\n/- An `N : submodule R M` is homogeneous if for every `r ∈ N`, all homogeneous components\n  of `r` are in `N`. -/\ndef submodule.is_homogeneous [graded_module ℳ] (N : submodule R M): Prop :=\n∀ (i : ι) ⦃r : M⦄, r ∈ N → (direct_sum.decompose ℳ r i : M) ∈ N\n\n/-- For any `module R M`, we collect the homogeneous ideals of `M` into a type. -/\nstructure homogeneous_submodule extends submodule R M :=\n(is_homogeneous' : submodule.is_homogeneous ℳ to_submodule)\n\nvariable {ℳ}\n\nlemma homogeneous_submodule.is_homogeneous (N : homogeneous_submodule ℳ) :\n  N.to_submodule.is_homogeneous ℳ := N.is_homogeneous'\n\nlemma homogeneous_submodule.to_submodule_injective :\n  function.injective (homogeneous_submodule.to_submodule : homogeneous_submodule ℳ → submodule R M) :=\nλ ⟨x, hx⟩ ⟨y, hy⟩ (h : x = y), by simp [h]\n\ninstance homogeneous_submodule.set_like : set_like (homogeneous_submodule ℳ) M :=\n{ coe := λ N, N.to_submodule,\n  coe_injective' := λ N P h, homogeneous_submodule.to_submodule_injective $ set_like.coe_injective h }\n\n@[ext] lemma homogeneous_submodule.ext {N P : homogeneous_submodule ℳ}\n  (h : N.to_submodule = P.to_submodule) : N = P := homogeneous_submodule.to_submodule_injective h\n\n@[simp] lemma homogeneous_submodule.mem_iff {N : homogeneous_submodule ℳ} {x : M} :\n  x ∈ N.to_submodule ↔ x ∈ N := iff.rfl\n\nend homogeneous_def\n\nsection homogeneous_core\n\n-- variables [semiring R] [add_comm_monoid M] [module R M]\n-- variables [set_like τ M]  (ℳ : ι → τ)\n\nvariable (N : submodule R M)\nvariable {R}\ninclude M\n\n/-- For any `N : submodule R M`, not necessarily homogeneous, `N.homogeneous_core' ℳ`\nis the largest homogeneous submodule of `M` contained in `N`, as a submodule. -/\ndef submodule.homogeneous_core' (N : submodule R M) : submodule R M :=\nsubmodule.span R (coe '' ((coe : subtype (is_homogeneous ℳ) → M) ⁻¹' N))\n\n\nlemma submodule.homogeneous_core'_mono : monotone (submodule.homogeneous_core' ℳ) :=\nλ N P N_le_P, submodule.span_mono $ set.image_subset _ $ λ x, @N_le_P _\n\nlemma submodule.homogeneous_core'_le : N.homogeneous_core' ℳ ≤ N :=\nsubmodule.span_le.2 $ image_preimage_subset _ _\n\nend homogeneous_core\n\nsection is_homogeneous_submodule_defs\n\n-- variables [semiring R] [add_comm_monoid M] [module R M]\n-- variables [set_like τ M] [add_submonoid_class τ M] [submodule_class τ R M] (ℳ : ι → τ)\n-- variables [decidable_eq ι] [add_monoid ι] [graded_module ℳ]\n\nvariable [graded_module ℳ]\n\nvariable (N : submodule R M)\nvariable {R}\ninclude M\n\nlemma submodule.is_homogeneous_iff_forall_subset :\n  N.is_homogeneous ℳ ↔ ∀ i, (N : set M) ⊆ graded_module.proj ℳ i ⁻¹' N :=\niff.rfl\n\nlemma submodule.is_homogeneous_iff_subset_Inter :\n  N.is_homogeneous ℳ ↔ (N : set M) ⊆ ⋂ i, graded_module.proj ℳ i ⁻¹' ↑N :=\nsubset_Inter_iff.symm\n\n/- --  Plus tard, lorsqu'il y aura un anneau gradué \nlemma submodule.mul_homogeneous_element_mem_of_mem\n  {I : ideal A} (r x : A) (hx₁ : is_homogeneous 𝒜 x) (hx₂ : x ∈ I) (j : ι) :\n  graded_ring.proj 𝒜 j (r * x) ∈ I :=\nbegin\n  classical,\n  rw [←direct_sum.sum_support_decompose 𝒜 r, finset.sum_mul, map_sum],\n  apply ideal.sum_mem,\n  intros k hk,\n  obtain ⟨i, hi⟩ := hx₁,\n  have mem₁ : (direct_sum.decompose 𝒜 r k : A) * x ∈ 𝒜 (k + i) := graded_monoid.mul_mem\n    (set_like.coe_mem _) hi,\n  erw [graded_ring.proj_apply, direct_sum.decompose_of_mem 𝒜 mem₁,\n    coe_of_apply, set_like.coe_mk],\n  split_ifs,\n  { exact I.mul_mem_left _ hx₂ },\n  { exact I.zero_mem },\nend -/\n\nlemma submodule.is_homogeneous_span (s : set M) (h : ∀ x ∈ s, is_homogeneous ℳ x) :\n  (submodule.span R s).is_homogeneous ℳ :=\nbegin\n  rintros i r hr,\n  rw [finsupp.span_eq_range_total, linear_map.mem_range] at hr,\n  obtain ⟨f, rfl⟩ := hr,\n  rw [finsupp.total_apply, finsupp.sum, decompose_sum, dfinsupp.finset_sum_apply,\n    add_submonoid_class.coe_finset_sum],\n  refine submodule.sum_mem _ _,\n  rintros ⟨z, hz⟩ hz1,\n  simp only [decompose_smul, dfinsupp.coe_smul, pi.smul_apply, submodule.coe_smul_of_tower, subtype.coe_mk],\n  refine submodule.smul_mem _ _ _,\n  obtain ⟨j, hzj⟩ := h z hz, \n  by_cases hij : i = j,\n  { rw hij, \n    rw direct_sum.decompose_of_mem_same,\n    exact submodule.subset_span hz,\n    exact hzj },\n  { rw direct_sum.decompose_of_mem_ne ℳ hzj (ne.symm hij),\n    exact submodule.zero_mem _,  },\nend\n\n/--For any `N : submodule R M`, not necessarily homogeneous, `N.homogeneous_core' R ℳ`\nis the largest homogeneous submodule of `M` contained in `N`.-/\ndef submodule.homogeneous_core : homogeneous_submodule ℳ :=\n⟨submodule.homogeneous_core' ℳ N,\n  submodule.is_homogeneous_span ℳ _ (λ x h,\n  by { rw [subtype.image_preimage_coe, mem_inter_iff, mem_coe] at h,exact h.2, })⟩\n\nlemma submodule.homogeneous_core_mono : monotone (submodule.homogeneous_core ℳ) :=\nsubmodule.homogeneous_core'_mono ℳ\n\nlemma submodule.to_submodule_homogeneous_core_le : (N.homogeneous_core ℳ).to_submodule ≤ N :=\nsubmodule.homogeneous_core'_le ℳ N\n\nvariables {ℳ N}\n\nlemma submodule.mem_homogeneous_core_of_is_homogeneous_of_mem {x : M}\n  (h : set_like.is_homogeneous ℳ x) (hmem : x ∈ N) : x ∈ N.homogeneous_core ℳ :=\nsubmodule.subset_span ⟨⟨x, h⟩, hmem, rfl⟩\n\nlemma submodule.is_homogeneous.to_submodule_homogeneous_core_eq_self (h : N.is_homogeneous ℳ) :\n  (N.homogeneous_core ℳ).to_submodule = N :=\nbegin\n  apply le_antisymm (N.homogeneous_core'_le ℳ) _,\n  intros x hx,\n  classical,\n  rw ←direct_sum.sum_support_decompose ℳ x,\n  exact submodule.sum_mem _ (λ j hj, submodule.subset_span ⟨⟨_, is_homogeneous_coe _⟩, h _ hx, rfl⟩)\nend\n\n@[simp] lemma homogeneous_submodule.to_ideal_homogeneous_core_eq_self (N : homogeneous_submodule ℳ) :\n  N.to_submodule.homogeneous_core ℳ = N :=\nby ext1; convert submodule.is_homogeneous.to_submodule_homogeneous_core_eq_self R N.is_homogeneous\n\nvariables (ℳ N)\n\nlemma submodule.is_homogeneous.iff_eq : N.is_homogeneous ℳ ↔ (N.homogeneous_core ℳ).to_submodule = N :=\n⟨ λ hI, hI.to_submodule_homogeneous_core_eq_self,\n  λ hI, hI ▸ (submodule.homogeneous_core ℳ N).2 ⟩\n\ndef homogeneous_set : set M := {m : M | is_homogeneous ℳ m}\n\nlemma submodule.is_homogeneous.iff_exists :\n  N.is_homogeneous ℳ ↔ ∃ (S : set (homogeneous_set ℳ)), N = submodule.span R (coe '' S) :=\nbegin\n  rw [submodule.is_homogeneous.iff_eq, eq_comm],\n  exact ((set.image_preimage.compose (submodule.gi _ _).gc).exists_eq_l _).symm,\nend\n\nend is_homogeneous_submodule_defs\n\n/-! ### Operations\nIn this section, we show that `ideal.is_homogeneous` is preserved by various notations, then use\nthese results to provide these notation typeclasses for `homogeneous_ideal`. -/\n\nsection operations\n\nsection semiring\n\nvariables [semiring A] [decidable_eq ι] [add_monoid ι]\nvariables [set_like σ A] [add_submonoid_class σ A] (𝒜 : ι → σ) [graded_ring 𝒜]\ninclude A\n\nnamespace ideal.is_homogeneous\n\nlemma bot : ideal.is_homogeneous 𝒜 ⊥ := λ i r hr,\nbegin\n  simp only [ideal.mem_bot] at hr,\n  rw [hr, decompose_zero, zero_apply],\n  apply ideal.zero_mem\nend\n\nlemma top : ideal.is_homogeneous 𝒜 ⊤ :=\nλ i r hr, by simp only [submodule.mem_top]\n\nvariables {𝒜}\n\nlemma inf {I J : ideal A} (HI : I.is_homogeneous 𝒜) (HJ : J.is_homogeneous 𝒜) :\n  (I ⊓ J).is_homogeneous 𝒜 :=\nλ i r hr, ⟨HI _ hr.1, HJ _ hr.2⟩\n\nlemma sup {I J : ideal A} (HI : I.is_homogeneous 𝒜) (HJ : J.is_homogeneous 𝒜) :\n  (I ⊔ J).is_homogeneous 𝒜 :=\nbegin\n  rw iff_exists at HI HJ ⊢,\n  obtain ⟨⟨s₁, rfl⟩, ⟨s₂, rfl⟩⟩ := ⟨HI, HJ⟩,\n  refine ⟨s₁ ∪ s₂, _⟩,\n  rw [set.image_union],\n  exact (submodule.span_union _ _).symm,\nend\n\nprotected lemma supr {κ : Sort*} {f : κ → ideal A} (h : ∀ i, (f i).is_homogeneous 𝒜) :\n  (⨆ i, f i).is_homogeneous 𝒜 :=\nbegin\n  simp_rw iff_exists at h ⊢,\n  choose s hs using h,\n  refine ⟨⋃ i, s i, _⟩,\n  simp_rw [set.image_Union, ideal.span_Union],\n  congr',\n  exact funext hs,\nend\n\nprotected lemma infi {κ : Sort*} {f : κ → ideal A} (h : ∀ i, (f i).is_homogeneous 𝒜) :\n  (⨅ i, f i).is_homogeneous 𝒜 :=\nbegin\n  intros i x hx,\n  simp only [ideal.mem_infi] at ⊢ hx,\n  exact λ j, h _ _ (hx j),\nend\n\nlemma supr₂ {κ : Sort*} {κ' : κ → Sort*} {f : Π i, κ' i → ideal A}\n  (h : ∀ i j, (f i j).is_homogeneous 𝒜) :\n  (⨆ i j, f i j).is_homogeneous 𝒜 :=\nis_homogeneous.supr $ λ i, is_homogeneous.supr $ h i\n\nlemma infi₂ {κ : Sort*} {κ' : κ → Sort*} {f : Π i, κ' i → ideal A}\n  (h : ∀ i j, (f i j).is_homogeneous 𝒜) :\n  (⨅ i j, f i j).is_homogeneous 𝒜 :=\nis_homogeneous.infi $ λ i, is_homogeneous.infi $ h i\n\nlemma Sup {ℐ : set (ideal A)} (h : ∀ I ∈ ℐ, ideal.is_homogeneous 𝒜 I) :\n  (Sup ℐ).is_homogeneous 𝒜 :=\nby { rw Sup_eq_supr, exact supr₂ h }\n\nlemma Inf {ℐ : set (ideal A)} (h : ∀ I ∈ ℐ, ideal.is_homogeneous 𝒜 I) :\n  (Inf ℐ).is_homogeneous 𝒜 :=\nby { rw Inf_eq_infi, exact infi₂ h }\n\nend ideal.is_homogeneous\n\nvariables {𝒜}\n\nnamespace homogeneous_ideal\n\ninstance : partial_order (homogeneous_ideal 𝒜) := set_like.partial_order\n\ninstance : has_top (homogeneous_ideal 𝒜) := ⟨⟨⊤, ideal.is_homogeneous.top 𝒜⟩⟩\ninstance : has_bot (homogeneous_ideal 𝒜) := ⟨⟨⊥, ideal.is_homogeneous.bot 𝒜⟩⟩\ninstance : has_sup (homogeneous_ideal 𝒜) := ⟨λ I J, ⟨_, I.is_homogeneous.sup J.is_homogeneous⟩⟩\ninstance : has_inf (homogeneous_ideal 𝒜) := ⟨λ I J, ⟨_, I.is_homogeneous.inf J.is_homogeneous⟩⟩\ninstance : has_Sup (homogeneous_ideal 𝒜) :=\n⟨λ S, ⟨⨆ s ∈ S, to_ideal s, ideal.is_homogeneous.supr₂ $ λ s _, s.is_homogeneous⟩⟩\ninstance : has_Inf (homogeneous_ideal 𝒜) :=\n⟨λ S, ⟨⨅ s ∈ S, to_ideal s, ideal.is_homogeneous.infi₂ $ λ s _, s.is_homogeneous⟩⟩\n\n@[simp] lemma coe_top : ((⊤ : homogeneous_ideal 𝒜) : set A) = univ := rfl\n@[simp] lemma coe_bot : ((⊥ : homogeneous_ideal 𝒜) : set A) = 0 := rfl\n@[simp] lemma coe_sup (I J : homogeneous_ideal 𝒜) : ↑(I ⊔ J) = (I + J : set A) :=\nsubmodule.coe_sup _ _\n@[simp] lemma coe_inf (I J : homogeneous_ideal 𝒜) : (↑(I ⊓ J) : set A) = I ∩ J := rfl\n\n@[simp] lemma to_ideal_top : (⊤ : homogeneous_ideal 𝒜).to_ideal = (⊤ : ideal A) := rfl\n@[simp] lemma to_ideal_bot : (⊥ : homogeneous_ideal 𝒜).to_ideal = (⊥ : ideal A) := rfl\n\n@[simp] lemma to_ideal_sup (I J : homogeneous_ideal 𝒜) :\n  (I ⊔ J).to_ideal = I.to_ideal ⊔ J.to_ideal := rfl\n\n@[simp] lemma to_ideal_inf (I J : homogeneous_ideal 𝒜) :\n  (I ⊓ J).to_ideal = I.to_ideal ⊓ J.to_ideal := rfl\n\n@[simp] lemma to_ideal_Sup (ℐ : set (homogeneous_ideal 𝒜)) :\n  (Sup ℐ).to_ideal = ⨆ s ∈ ℐ, to_ideal s := rfl\n\n@[simp] lemma to_ideal_Inf (ℐ : set (homogeneous_ideal 𝒜)) :\n  (Inf ℐ).to_ideal = ⨅ s ∈ ℐ, to_ideal s := rfl\n\n@[simp] lemma to_ideal_supr {κ : Sort*} (s : κ → homogeneous_ideal 𝒜) :\n  (⨆ i, s i).to_ideal = ⨆ i, (s i).to_ideal :=\nby rw [supr, to_ideal_Sup, supr_range]\n\n@[simp] lemma to_ideal_infi {κ : Sort*} (s : κ → homogeneous_ideal 𝒜) :\n  (⨅ i, s i).to_ideal = ⨅ i, (s i).to_ideal :=\nby rw [infi, to_ideal_Inf, infi_range]\n\n@[simp] lemma to_ideal_supr₂ {κ : Sort*} {κ' : κ → Sort*} (s : Π i, κ' i → homogeneous_ideal 𝒜) :\n  (⨆ i j, s i j).to_ideal = ⨆ i j, (s i j).to_ideal :=\nby simp_rw to_ideal_supr\n\n@[simp] lemma to_ideal_infi₂ {κ : Sort*} {κ' : κ → Sort*} (s : Π i, κ' i → homogeneous_ideal 𝒜) :\n  (⨅ i j, s i j).to_ideal = ⨅ i j, (s i j).to_ideal :=\nby simp_rw to_ideal_infi\n\n@[simp] lemma eq_top_iff (I : homogeneous_ideal 𝒜) : I = ⊤ ↔ I.to_ideal = ⊤ :=\nto_ideal_injective.eq_iff.symm\n\n@[simp] lemma eq_bot_iff (I : homogeneous_ideal 𝒜) : I = ⊥ ↔ I.to_ideal = ⊥ :=\nto_ideal_injective.eq_iff.symm\n\ninstance : complete_lattice (homogeneous_ideal 𝒜) :=\nto_ideal_injective.complete_lattice _ to_ideal_sup to_ideal_inf to_ideal_Sup to_ideal_Inf\n  to_ideal_top to_ideal_bot\n\ninstance : has_add (homogeneous_ideal 𝒜) := ⟨(⊔)⟩\n\n@[simp] lemma to_ideal_add (I J : homogeneous_ideal 𝒜) :\n  (I + J).to_ideal = I.to_ideal + J.to_ideal := rfl\n\ninstance : inhabited (homogeneous_ideal 𝒜) := { default := ⊥ }\n\nend homogeneous_ideal\n\nend semiring\n\nsection comm_semiring\nvariables [comm_semiring A]\nvariables [decidable_eq ι] [add_monoid ι]\nvariables [set_like σ A] [add_submonoid_class σ A] {𝒜 : ι → σ} [graded_ring 𝒜]\nvariable (I : ideal A)\ninclude A\n\nlemma ideal.is_homogeneous.mul {I J : ideal A}\n  (HI : I.is_homogeneous 𝒜) (HJ : J.is_homogeneous 𝒜) : (I * J).is_homogeneous 𝒜 :=\nbegin\n  rw ideal.is_homogeneous.iff_exists at HI HJ ⊢,\n  obtain ⟨⟨s₁, rfl⟩, ⟨s₂, rfl⟩⟩ := ⟨HI, HJ⟩,\n  rw ideal.span_mul_span',\n  exact ⟨s₁ * s₂, congr_arg _ $ (set.image_mul (homogeneous_submonoid 𝒜).subtype).symm⟩,\nend\n\nvariables {𝒜}\n\ninstance : has_mul (homogeneous_ideal 𝒜) :=\n{ mul := λ I J, ⟨I.to_ideal * J.to_ideal, I.is_homogeneous.mul J.is_homogeneous⟩ }\n\n@[simp] lemma homogeneous_ideal.to_ideal_mul (I J : homogeneous_ideal 𝒜) :\n  (I * J).to_ideal = I.to_ideal * J.to_ideal := rfl\n\nend comm_semiring\n\nend operations\n\n/-! ### Homogeneous core\nNote that many results about the homogeneous core came earlier in this file, as they are helpful\nfor building the lattice structure. -/\n\nsection homogeneous_core\n\nopen homogeneous_ideal\n\nvariables [semiring A] [decidable_eq ι] [add_monoid ι]\nvariables [set_like σ A] [add_submonoid_class σ A] (𝒜 : ι → σ) [graded_ring 𝒜]\nvariable (I : ideal A)\ninclude A\n\nlemma ideal.homogeneous_core.gc : galois_connection to_ideal (ideal.homogeneous_core 𝒜) :=\nλ I J, ⟨\n  λ H, I.to_ideal_homogeneous_core_eq_self ▸ ideal.homogeneous_core_mono 𝒜 H,\n  λ H, le_trans H (ideal.homogeneous_core'_le _ _)⟩\n\n/--`to_ideal : homogeneous_ideal 𝒜 → ideal A` and `ideal.homogeneous_core 𝒜` forms a galois\ncoinsertion-/\ndef ideal.homogeneous_core.gi : galois_coinsertion to_ideal (ideal.homogeneous_core 𝒜) :=\n{ choice := λ I HI,\n    ⟨I, le_antisymm (I.to_ideal_homogeneous_core_le 𝒜) HI ▸ homogeneous_ideal.is_homogeneous _⟩,\n  gc := ideal.homogeneous_core.gc 𝒜,\n  u_l_le := λ I, ideal.homogeneous_core'_le _ _,\n  choice_eq := λ I H, le_antisymm H (I.to_ideal_homogeneous_core_le _) }\n\nlemma ideal.homogeneous_core_eq_Sup :\n  I.homogeneous_core 𝒜 = Sup {J : homogeneous_ideal 𝒜 | J.to_ideal ≤ I} :=\neq.symm $ is_lub.Sup_eq $ (ideal.homogeneous_core.gc 𝒜).is_greatest_u.is_lub\n\nlemma ideal.homogeneous_core'_eq_Sup :\n  I.homogeneous_core' 𝒜 = Sup {J : ideal A | J.is_homogeneous 𝒜 ∧ J ≤ I} :=\nbegin\n  refine (is_lub.Sup_eq _).symm,\n  apply is_greatest.is_lub,\n  have coe_mono : monotone (to_ideal : homogeneous_ideal 𝒜 → ideal A) := λ x y, id,\n  convert coe_mono.map_is_greatest (ideal.homogeneous_core.gc 𝒜).is_greatest_u using 1,\n  ext,\n  rw [mem_image, mem_set_of_eq],\n  refine ⟨λ hI, ⟨⟨x, hI.1⟩, ⟨hI.2, rfl⟩⟩, by rintro ⟨x, ⟨hx, rfl⟩⟩; exact ⟨x.is_homogeneous, hx⟩⟩,\nend\n\nend homogeneous_core\n\n/-! ### Homogeneous hulls -/\n\nsection homogeneous_hull\n\nopen homogeneous_ideal\n\nvariables [semiring A] [decidable_eq ι] [add_monoid ι]\nvariables [set_like σ A] [add_submonoid_class σ A] (𝒜 : ι → σ) [graded_ring 𝒜]\nvariable (I : ideal A)\ninclude A\n\n/--For any `I : ideal A`, not necessarily homogeneous, `I.homogeneous_hull 𝒜` is\nthe smallest homogeneous ideal containing `I`. -/\ndef ideal.homogeneous_hull : homogeneous_ideal 𝒜 :=\n⟨ideal.span {r : A | ∃ (i : ι) (x : I), (direct_sum.decompose 𝒜 (x : A) i : A) = r}, begin\n  refine ideal.is_homogeneous_span _ _ (λ x hx, _),\n  obtain ⟨i, x, rfl⟩ := hx,\n  apply set_like.is_homogeneous_coe\nend⟩\n\nlemma ideal.le_to_ideal_homogeneous_hull :\n  I ≤ (ideal.homogeneous_hull 𝒜 I).to_ideal :=\nbegin\n  intros r hr,\n  classical,\n  rw [←direct_sum.sum_support_decompose 𝒜 r],\n  refine ideal.sum_mem _ _, intros j hj,\n  apply ideal.subset_span, use j, use ⟨r, hr⟩, refl,\nend\n\nlemma ideal.homogeneous_hull_mono : monotone (ideal.homogeneous_hull 𝒜) := λ I J I_le_J,\nbegin\n  apply ideal.span_mono,\n  rintros r ⟨hr1, ⟨x, hx⟩, rfl⟩,\n  refine ⟨hr1, ⟨⟨x, I_le_J hx⟩, rfl⟩⟩,\nend\n\nvariables {I 𝒜}\n\nlemma ideal.is_homogeneous.to_ideal_homogeneous_hull_eq_self (h : I.is_homogeneous 𝒜) :\n  (ideal.homogeneous_hull 𝒜 I).to_ideal = I :=\nbegin\n  apply le_antisymm _ (ideal.le_to_ideal_homogeneous_hull _ _),\n  apply (ideal.span_le).2,\n  rintros _ ⟨i, x, rfl⟩,\n  exact h _ x.prop,\nend\n\n@[simp] lemma homogeneous_ideal.homogeneous_hull_to_ideal_eq_self (I : homogeneous_ideal 𝒜) :\n  I.to_ideal.homogeneous_hull 𝒜 = I :=\nhomogeneous_ideal.to_ideal_injective $ I.is_homogeneous.to_ideal_homogeneous_hull_eq_self\n\nvariables (I 𝒜)\n\nlemma ideal.to_ideal_homogeneous_hull_eq_supr :\n  (I.homogeneous_hull 𝒜).to_ideal = ⨆ i, ideal.span (graded_ring.proj 𝒜 i '' I) :=\nbegin\n  rw ←ideal.span_Union,\n  apply congr_arg ideal.span _,\n  ext1,\n  simp only [set.mem_Union, set.mem_image, mem_set_of_eq, graded_ring.proj_apply,\n    set_like.exists, exists_prop, subtype.coe_mk, set_like.mem_coe],\nend\n\nlemma ideal.homogeneous_hull_eq_supr :\n  (I.homogeneous_hull 𝒜) =\n  ⨆ i, ⟨ideal.span (graded_ring.proj 𝒜 i '' I), ideal.is_homogeneous_span 𝒜 _\n    (by {rintros _ ⟨x, -, rfl⟩, apply set_like.is_homogeneous_coe})⟩ :=\nby { ext1, rw [ideal.to_ideal_homogeneous_hull_eq_supr, to_ideal_supr], refl }\n\nend homogeneous_hull\n\nsection galois_connection\n\nopen homogeneous_ideal\n\nvariables [semiring A] [decidable_eq ι] [add_monoid ι]\nvariables [set_like σ A] [add_submonoid_class σ A] (𝒜 : ι → σ) [graded_ring 𝒜]\ninclude A\n\nlemma ideal.homogeneous_hull.gc : galois_connection (ideal.homogeneous_hull 𝒜) to_ideal :=\nλ I J, ⟨\n  le_trans (ideal.le_to_ideal_homogeneous_hull _ _),\n  λ H, J.homogeneous_hull_to_ideal_eq_self ▸ ideal.homogeneous_hull_mono 𝒜 H⟩\n\n/-- `ideal.homogeneous_hull 𝒜` and `to_ideal : homogeneous_ideal 𝒜 → ideal A` form a galois\ninsertion-/\ndef ideal.homogeneous_hull.gi : galois_insertion (ideal.homogeneous_hull 𝒜) to_ideal :=\n{ choice := λ I H, ⟨I, le_antisymm H (I.le_to_ideal_homogeneous_hull 𝒜) ▸ is_homogeneous _⟩,\n  gc := ideal.homogeneous_hull.gc 𝒜,\n  le_l_u := λ I, ideal.le_to_ideal_homogeneous_hull _ _,\n  choice_eq := λ I H, le_antisymm (I.le_to_ideal_homogeneous_hull 𝒜) H}\n\nlemma ideal.homogeneous_hull_eq_Inf (I : ideal A) :\n  ideal.homogeneous_hull 𝒜 I = Inf { J : homogeneous_ideal 𝒜 | I ≤ J.to_ideal } :=\neq.symm $ is_glb.Inf_eq $ (ideal.homogeneous_hull.gc 𝒜).is_least_l.is_glb\n\nend galois_connection", "meta": {"author": "AntoineChambert-Loir", "repo": "divided_powers", "sha": "86b6f8716590d38e63ed11d34c0140de8ae2af7d", "save_path": "github-repos/lean/AntoineChambert-Loir-divided_powers", "path": "github-repos/lean/AntoineChambert-Loir-divided_powers/divided_powers-86b6f8716590d38e63ed11d34c0140de8ae2af7d/src/graded_module_quot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.47267477997936863}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.finite_dimensional\nimport Mathlib.ring_theory.integral_closure\nimport Mathlib.data.polynomial.integral_normalization\nimport Mathlib.PostPort\n\nuniverses u v u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Algebraic elements and algebraic extensions\n\nAn element of an R-algebra is algebraic over R if it is the root of a nonzero polynomial.\nAn R-algebra is algebraic over R if and only if all its elements are algebraic over R.\nThe main result in this file proves transitivity of algebraicity:\na tower of algebraic field extensions is algebraic.\n-/\n\n/-- An element of an R-algebra is algebraic over R if it is the root of a nonzero polynomial. -/\ndef is_algebraic (R : Type u) {A : Type v} [comm_ring R] [ring A] [algebra R A] (x : A) :=\n  ∃ (p : polynomial R), p ≠ 0 ∧ coe_fn (polynomial.aeval x) p = 0\n\n/-- A subalgebra is algebraic if all its elements are algebraic. -/\ndef subalgebra.is_algebraic {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A] (S : subalgebra R A) :=\n  ∀ (x : A), x ∈ S → is_algebraic R x\n\n/-- An algebra is algebraic if all its elements are algebraic. -/\ndef algebra.is_algebraic (R : Type u) (A : Type v) [comm_ring R] [ring A] [algebra R A] :=\n  ∀ (x : A), is_algebraic R x\n\n/-- A subalgebra is algebraic if and only if it is algebraic an algebra. -/\ntheorem subalgebra.is_algebraic_iff {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A] (S : subalgebra R A) : subalgebra.is_algebraic S ↔ algebra.is_algebraic R ↥S := sorry\n\n/-- An algebra is algebraic if and only if it is algebraic as a subalgebra. -/\ntheorem algebra.is_algebraic_iff {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A] : algebra.is_algebraic R A ↔ subalgebra.is_algebraic ⊤ := sorry\n\n/-- An integral element of an algebra is algebraic.-/\ntheorem is_integral.is_algebraic (R : Type u) {A : Type v} [comm_ring R] [nontrivial R] [ring A] [algebra R A] {x : A} (h : is_integral R x) : is_algebraic R x := sorry\n\n/-- An element of an algebra over a field is algebraic if and only if it is integral.-/\ntheorem is_algebraic_iff_is_integral (K : Type u) {A : Type v} [field K] [ring A] [algebra K A] {x : A} : is_algebraic K x ↔ is_integral K x := sorry\n\ntheorem is_algebraic_iff_is_integral' (K : Type u) {A : Type v} [field K] [ring A] [algebra K A] : algebra.is_algebraic K A ↔ algebra.is_integral K A :=\n  { mp := fun (h : algebra.is_algebraic K A) (x : A) => iff.mp (is_algebraic_iff_is_integral K) (h x),\n    mpr := fun (h : algebra.is_integral K A) (x : A) => iff.mpr (is_algebraic_iff_is_integral K) (h x) }\n\nnamespace algebra\n\n\n/-- If L is an algebraic field extension of K and A is an algebraic algebra over L,\nthen A is algebraic over K. -/\ntheorem is_algebraic_trans {K : Type u_1} {L : Type u_2} {A : Type u_3} [field K] [field L] [comm_ring A] [algebra K L] [algebra L A] [algebra K A] [is_scalar_tower K L A] (L_alg : is_algebraic K L) (A_alg : is_algebraic L A) : is_algebraic K A := sorry\n\n/-- A field extension is algebraic if it is finite. -/\ntheorem is_algebraic_of_finite {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L] [finite : finite_dimensional K L] : is_algebraic K L :=\n  fun (x : L) =>\n    iff.mpr (is_algebraic_iff_is_integral K)\n      (is_integral_of_submodule_noetherian ⊤ (is_noetherian_of_submodule_of_noetherian K L (↑⊤) finite) x mem_top)\n\nend algebra\n\n\ntheorem exists_integral_multiple {R : Type u_1} {S : Type u_2} [integral_domain R] [comm_ring S] [algebra R S] {z : S} (hz : is_algebraic R z) (inj : ∀ (x : R), coe_fn (algebra_map R S) x = 0 → x = 0) : ∃ (x : ↥(integral_closure R S)), ∃ (y : ↥(integral_closure R S)), ∃ (H : y ≠ 0), z * ↑y = ↑x := sorry\n\ntheorem inv_eq_of_aeval_div_X_ne_zero {K : Type u_3} {L : Type u_4} [field K] [field L] [algebra K L] {x : L} {p : polynomial K} (aeval_ne : coe_fn (polynomial.aeval x) (polynomial.div_X p) ≠ 0) : x⁻¹ =\n  coe_fn (polynomial.aeval x) (polynomial.div_X p) /\n    (coe_fn (polynomial.aeval x) p - coe_fn (algebra_map K L) (polynomial.coeff p 0)) := sorry\n\ntheorem inv_eq_of_root_of_coeff_zero_ne_zero {K : Type u_3} {L : Type u_4} [field K] [field L] [algebra K L] {x : L} {p : polynomial K} (aeval_eq : coe_fn (polynomial.aeval x) p = 0) (coeff_zero_ne : polynomial.coeff p 0 ≠ 0) : x⁻¹ = -(coe_fn (polynomial.aeval x) (polynomial.div_X p) / coe_fn (algebra_map K L) (polynomial.coeff p 0)) := sorry\n\ntheorem subalgebra.inv_mem_of_root_of_coeff_zero_ne_zero {K : Type u_3} {L : Type u_4} [field K] [field L] [algebra K L] (A : subalgebra K L) {x : ↥A} {p : polynomial K} (aeval_eq : coe_fn (polynomial.aeval x) p = 0) (coeff_zero_ne : polynomial.coeff p 0 ≠ 0) : ↑x⁻¹ ∈ A := sorry\n\ntheorem subalgebra.inv_mem_of_algebraic {K : Type u_3} {L : Type u_4} [field K] [field L] [algebra K L] (A : subalgebra K L) {x : ↥A} (hx : is_algebraic K ↑x) : ↑x⁻¹ ∈ A := sorry\n\n/-- In an algebraic extension L/K, an intermediate subalgebra is a field. -/\ntheorem subalgebra.is_field_of_algebraic {K : Type u_3} {L : Type u_4} [field K] [field L] [algebra K L] (A : subalgebra K L) (hKL : algebra.is_algebraic K L) : is_field ↥A := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/algebraic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4726705250298092}}
{"text": "/-\nCopyright (c) 2022 Eric Rodriguez. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Rodriguez, Eric Wieser\n\n! This file was ported from Lean 3 source module data.list.destutter\n! leanprover-community/mathlib commit f2f413b9d4be3a02840d0663dace76e8fe3da053\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.List.Chain\n\n/-!\n# Destuttering of Lists\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves theorems about `list.destutter` (in `data.list.defs`), which greedily removes all\nnon-related items that are adjacent in a list, e.g. `[2, 2, 3, 3, 2].destutter (≠) = [2, 3, 2]`.\nNote that we make no guarantees of being the longest sublist with this property; e.g.,\n`[123, 1, 2, 5, 543, 1000].destutter (<) = [123, 543, 1000]`, but a longer ascending chain could be\n`[1, 2, 5, 543, 1000]`.\n\n## Main statements\n\n* `list.destutter_sublist`: `l.destutter` is a sublist of `l`.\n* `list.destutter_is_chain'`: `l.destutter` satisfies `chain' R`.\n* Analogies of these theorems for `list.destutter'`, which is the `destutter` equivalent of `chain`.\n\n## Tags\n\nadjacent, chain, duplicates, remove, list, stutter, destutter\n-/\n\n\nvariable {α : Type _} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α}\n\nnamespace List\n\n#print List.destutter'_nil /-\n@[simp]\ntheorem destutter'_nil : destutter' R a [] = [a] :=\n  rfl\n#align list.destutter'_nil List.destutter'_nil\n-/\n\n#print List.destutter'_cons /-\ntheorem destutter'_cons :\n    (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l :=\n  rfl\n#align list.destutter'_cons List.destutter'_cons\n-/\n\nvariable {R}\n\n#print List.destutter'_cons_pos /-\n@[simp]\ntheorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by\n  rw [destutter', if_pos h]\n#align list.destutter'_cons_pos List.destutter'_cons_pos\n-/\n\n#print List.destutter'_cons_neg /-\n@[simp]\ntheorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by\n  rw [destutter', if_neg h]\n#align list.destutter'_cons_neg List.destutter'_cons_neg\n-/\n\nvariable (R)\n\n#print List.destutter'_singleton /-\n@[simp]\ntheorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by\n  split_ifs <;> simp! [h]\n#align list.destutter'_singleton List.destutter'_singleton\n-/\n\n#print List.destutter'_sublist /-\ntheorem destutter'_sublist (a) : l.destutter' R a <+ a :: l :=\n  by\n  induction' l with b l hl generalizing a\n  · simp\n  rw [destutter']\n  split_ifs\n  · exact sublist.cons2 _ _ _ (hl b)\n  · exact (hl a).trans ((l.sublist_cons b).cons_cons a)\n#align list.destutter'_sublist List.destutter'_sublist\n-/\n\n#print List.mem_destutter' /-\ntheorem mem_destutter' (a) : a ∈ l.destutter' R a :=\n  by\n  induction' l with b l hl\n  · simp\n  rw [destutter']\n  split_ifs\n  · simp\n  · assumption\n#align list.mem_destutter' List.mem_destutter'\n-/\n\n#print List.destutter'_is_chain /-\ntheorem destutter'_is_chain : ∀ l : List α, ∀ {a b}, R a b → (l.destutter' R b).Chain R a\n  | [], a, b, h => chain_singleton.mpr h\n  | c :: l, a, b, h => by\n    rw [destutter']\n    split_ifs with hbc\n    · rw [chain_cons]\n      exact ⟨h, destutter'_is_chain l hbc⟩\n    · exact destutter'_is_chain l h\n#align list.destutter'_is_chain List.destutter'_is_chain\n-/\n\n#print List.destutter'_is_chain' /-\ntheorem destutter'_is_chain' (a) : (l.destutter' R a).Chain' R :=\n  by\n  induction' l with b l hl generalizing a\n  · simp\n  rw [destutter']\n  split_ifs\n  · exact destutter'_is_chain R l h\n  · exact hl a\n#align list.destutter'_is_chain' List.destutter'_is_chain'\n-/\n\n#print List.destutter'_of_chain /-\ntheorem destutter'_of_chain (h : l.Chain R a) : l.destutter' R a = a :: l :=\n  by\n  induction' l with b l hb generalizing a\n  · simp\n  obtain ⟨h, hc⟩ := chain_cons.mp h\n  rw [l.destutter'_cons_pos h, hb hc]\n#align list.destutter'_of_chain List.destutter'_of_chain\n-/\n\n#print List.destutter'_eq_self_iff /-\n@[simp]\ntheorem destutter'_eq_self_iff (a) : l.destutter' R a = a :: l ↔ l.Chain R a :=\n  ⟨fun h => by\n    rw [← chain', ← h]\n    exact l.destutter'_is_chain' R a, destutter'_of_chain _ _⟩\n#align list.destutter'_eq_self_iff List.destutter'_eq_self_iff\n-/\n\n#print List.destutter'_ne_nil /-\ntheorem destutter'_ne_nil : l.destutter' R a ≠ [] :=\n  ne_nil_of_mem <| l.mem_destutter' R a\n#align list.destutter'_ne_nil List.destutter'_ne_nil\n-/\n\n#print List.destutter_nil /-\n@[simp]\ntheorem destutter_nil : ([] : List α).destutter R = [] :=\n  rfl\n#align list.destutter_nil List.destutter_nil\n-/\n\n#print List.destutter_cons' /-\ntheorem destutter_cons' : (a :: l).destutter R = destutter' R a l :=\n  rfl\n#align list.destutter_cons' List.destutter_cons'\n-/\n\n#print List.destutter_cons_cons /-\ntheorem destutter_cons_cons :\n    (a :: b :: l).destutter R = if R a b then a :: destutter' R b l else destutter' R a l :=\n  rfl\n#align list.destutter_cons_cons List.destutter_cons_cons\n-/\n\n#print List.destutter_singleton /-\n@[simp]\ntheorem destutter_singleton : destutter R [a] = [a] :=\n  rfl\n#align list.destutter_singleton List.destutter_singleton\n-/\n\n#print List.destutter_pair /-\n@[simp]\ntheorem destutter_pair : destutter R [a, b] = if R a b then [a, b] else [a] :=\n  destutter_cons_cons _ R\n#align list.destutter_pair List.destutter_pair\n-/\n\n#print List.destutter_sublist /-\ntheorem destutter_sublist : ∀ l : List α, l.destutter R <+ l\n  | [] => Sublist.slnil\n  | h :: l => l.destutter'_sublist R h\n#align list.destutter_sublist List.destutter_sublist\n-/\n\n#print List.destutter_is_chain' /-\ntheorem destutter_is_chain' : ∀ l : List α, (l.destutter R).Chain' R\n  | [] => List.chain'_nil\n  | h :: l => l.destutter'_is_chain' R h\n#align list.destutter_is_chain' List.destutter_is_chain'\n-/\n\n#print List.destutter_of_chain' /-\ntheorem destutter_of_chain' : ∀ l : List α, l.Chain' R → l.destutter R = l\n  | [], h => rfl\n  | a :: l, h => l.destutter'_of_chain _ h\n#align list.destutter_of_chain' List.destutter_of_chain'\n-/\n\n#print List.destutter_eq_self_iff /-\n@[simp]\ntheorem destutter_eq_self_iff : ∀ l : List α, l.destutter R = l ↔ l.Chain' R\n  | [] => by simp\n  | a :: l => l.destutter'_eq_self_iff R a\n#align list.destutter_eq_self_iff List.destutter_eq_self_iff\n-/\n\n#print List.destutter_idem /-\ntheorem destutter_idem : (l.destutter R).destutter R = l.destutter R :=\n  destutter_of_chain' R _ <| l.destutter_is_chain' R\n#align list.destutter_idem List.destutter_idem\n-/\n\n#print List.destutter_eq_nil /-\n@[simp]\ntheorem destutter_eq_nil : ∀ {l : List α}, destutter R l = [] ↔ l = []\n  | [] => Iff.rfl\n  | a :: l => ⟨fun h => absurd h <| l.destutter'_ne_nil R, fun h => nomatch h⟩\n#align list.destutter_eq_nil List.destutter_eq_nil\n-/\n\nend List\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/List/Destutter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.4726705215773752}}
{"text": "import algebra.homology.homological_complex\n\nopen category_theory category_theory.limits\n\nnamespace homological_complex\n\nuniverses w' w v v' u u'\n\nvariables {V : Type u} [category.{v} V] {J : Type w} [category.{w'} J]\nvariables {ι : Type u'} {c : complex_shape ι}\n\n-- move this\nsection\nvariables {C : Type u} [category.{v} C] {Z : C → Prop}\n@[simps]\ndef lift_iso {X Y : full_subcategory Z} (h : X.obj ≅ Y.obj) : X ≅ Y :=\n{ hom := h.hom, inv := h.inv, hom_inv_id' := h.hom_inv_id, inv_hom_id' := h.inv_hom_id }\nend\n\nsection walking_complex\n\n@[nolint unused_arguments]\ndef walking_complex (c : complex_shape ι) := ι\n\ninductive walking_complex_hom : walking_complex c → walking_complex c → Type u'\n| id : Π i, walking_complex_hom i i\n| d : Π {i j}, c.rel i j → walking_complex_hom i j\n| zero : Π i j, walking_complex_hom i j\n\nsection\n\nopen walking_complex_hom\n\ndef walking_complex_hom_comp (i j k : walking_complex c) :\n  walking_complex_hom i j → walking_complex_hom j k → walking_complex_hom i k :=\nbegin\n  intros f g,\n  cases f with _ _ _ r,\n  { exact g },\n  { cases g, exacts [walking_complex_hom.d r, walking_complex_hom.zero _ _, walking_complex_hom.zero _ _] },\n  { exact walking_complex_hom.zero _ _ },\nend\n\ninstance : category_struct (walking_complex c) :=\n{ hom := walking_complex_hom,\n  id := walking_complex_hom.id,\n  comp :=\n  begin\n    intros i j k f g,\n    cases f with _ _ _ r,\n    { exact g },\n    { cases g, exacts [walking_complex_hom.d r, walking_complex_hom.zero _ _, walking_complex_hom.zero _ _] },\n    { exact walking_complex_hom.zero _ _ },\n  end }\nend\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance : category (walking_complex c) := {}\n.\n\ninstance walking_complex_hom_has_zero (i j : walking_complex c) : has_zero (i ⟶ j) :=\n⟨walking_complex_hom.zero i j⟩\n\ninstance : has_zero_morphisms (walking_complex c) := {}\n.\n\n@[simp] lemma walking_complex_hom_id (i : walking_complex c) : walking_complex_hom.id i = 𝟙 i :=\nrfl\n@[simp] lemma walking_complex_hom_zero (i : walking_complex c) : walking_complex_hom.zero i = 0 :=\nrfl\n\ndef walking_complex_d {i j : walking_complex c} (r : c.rel i j) : i ⟶ j :=\n  walking_complex_hom.d r\n\n@[simp] lemma walking_complex_d_eq {i j : walking_complex c} (r : c.rel i j) :\n  walking_complex_hom.d r = walking_complex_d r := rfl\n\n@[simp] lemma walking_complex_hom_d_comp_d {i j k : walking_complex c}\n  (r : c.rel i j) (r' : c.rel j k) : walking_complex_d r ≫ walking_complex_d r' = 0 := rfl\n\nvariable [has_zero_morphisms V]\n\ndef complex_to_functor_map\n  (h : homological_complex V c) {i j : walking_complex c} (f : i ⟶ j) : h.X i ⟶ h.X j :=\nbegin\n  cases f, exacts [𝟙 _, h.d _ _, 0]\nend\n\n@[simp]\nlemma complex_to_functor_map_id\n  (h : homological_complex V c) (i : walking_complex c) : complex_to_functor_map h (𝟙 i) = 𝟙 _ :=\nrfl\n\n@[simp]\nlemma complex_to_functor_map_zero\n  (h : homological_complex V c) (i j : walking_complex c) :\n    complex_to_functor_map h (0 : i ⟶ j) = 0 :=\nrfl\n\n@[simp]\nlemma complex_to_functor_map_d\n  (h : homological_complex V c) {i j : walking_complex c} (r : c.rel i j) :\n    complex_to_functor_map h (walking_complex_d r) = h.d _ _ := rfl\n\n@[simps]\ndef complex_to_functor (h : homological_complex V c) :\n  walking_complex c ⥤ V :=\n{ obj := h.X, map := λ i j f, complex_to_functor_map h f }\n.\n\nvariable [decidable_rel c.rel]\n\n@[simps]\ndef functor_to_complex (F : walking_complex c ⥤ V)\n  (hF : ∀ i j, F.map (0 : i ⟶ j) = 0) :\n  homological_complex V c :=\n{ X := F.obj,\n  d := λ i j, if r : c.rel i j then F.map (walking_complex_d r) else 0,\n  d_comp_d' := by { introv r r',\n    rw [dif_pos r, dif_pos r', ← F.map_comp, walking_complex_hom_d_comp_d, hF] } }\n.\nvariables (c V)\n\n@[simps]\ndef complex_to_functor_functor :\n  homological_complex V c ⥤ full_subcategory (λ F : walking_complex c ⥤ V, ∀ i j, F.map (0 : i ⟶ j) = 0) :=\n{ obj := λ X, ⟨complex_to_functor X, λ _ _, rfl⟩, map := λ X Y f, { app := f.f } }\n\n@[simps]\ndef functor_to_complex_functor :\n  full_subcategory (λ F : walking_complex c ⥤ V, ∀ i j, F.map (0 : i ⟶ j) = 0) ⥤ homological_complex V c :=\n{ obj := λ F, functor_to_complex F.1 F.2,\n  map := λ F G f, { f := f.app, comm' := by { intros i j r, simp [dif_pos r] } } }\n.\n\n@[simps]\ndef complex_equiv_functor_unit :\n  𝟭 _ ≅ complex_to_functor_functor V c ⋙ functor_to_complex_functor V c :=\nnat_iso.of_components\n  (λ X, hom.iso_of_components (λ i, iso.refl _) (by { introv r, dsimp, simp [if_pos r] }))\n  (by { intros, ext, dsimp, simp })\n\n@[simps]\ndef complex_equiv_functor_counit :\n  functor_to_complex_functor V c ⋙ complex_to_functor_functor V c ≅ 𝟭 _ :=\nnat_iso.of_components\n  (λ F, lift_iso $ nat_iso.of_components (λ i, iso.refl _)\n    (by { introv, cases F with F hF, cases f; dsimp; simp [*, hF] }))\n  (by { introv, ext, dsimp, erw [nat_trans.comp_app, nat_trans.comp_app], dsimp, simp })\n\n@[simps]\ndef complex_equiv_functor :\n  homological_complex V c ≌ full_subcategory (λ F : walking_complex c ⥤ V, ∀ i j, F.map (0 : i ⟶ j) = 0) :=\n{ functor := complex_to_functor_functor V c,\n  inverse := functor_to_complex_functor V c,\n  unit_iso := complex_equiv_functor_unit V c,\n  counit_iso := complex_equiv_functor_counit V c,\n  functor_unit_iso_comp' :=\n    by { intro x, ext, erw [nat_trans.comp_app, nat_trans.id_app], dsimp, simp } }\n.\n\ninstance : is_equivalence (complex_to_functor_functor V c) :=\nis_equivalence.of_equivalence (complex_equiv_functor V c)\ninstance : is_equivalence (functor_to_complex_functor V c) :=\nis_equivalence.of_equivalence_inverse (complex_equiv_functor V c)\n\n@[simps, derive [full, faithful]]\ndef complex_to_functor_category_functor : homological_complex V c ⥤ walking_complex c ⥤ V :=\ncomplex_to_functor_functor V c ⋙ induced_functor _\n\nend walking_complex\n\nsection walking_preadditive_complex\n\n/-\nTODO : If `V` is preadditive, then the cateogory of homological complexes is equivalent to the\ncategory of additive functors from a preadditive category `walking_preadditive_complex` to `V`.\n-/\n\nend walking_preadditive_complex\n\nend homological_complex\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/homological_complex_equiv_functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.47267051812494115}}
{"text": "/-\nThe problem is originally presented in:\nA. Pease, G. Sutcliffe, N. Siegel, and S. Trac, “Large Theory\nReasoning with SUMO at CASC,” pp. 1–8, Jul. 2009.\nHere we present the natural deduction proof in Lean.\n-/\n\nimport bs_test\n\n-- some initial tests\n\nlemma VertebrateAnimal : ∀ (x : U), ins x Vertebrate → ins x Animal := \nbegin \n intros a h,\n have h1, from a15 Vertebrate Animal a,\n apply h1,\n exact (and.intro a71402 a72771),\n exact (and.intro a71382 h)\nend\n\nlemma subclass_TransitiveRelation : ins subclass_m TransitiveRelation :=\nbegin\n --specialize a15 PartialOrderingRelation TransitiveRelation subclass_m,\n apply a15,\n exact ⟨ a72180, a71844 ⟩, \n exact ⟨ a67818, a13 ⟩, \nend\n\nlemma VertebrateOrganism : ∀ (x : U), ins x Vertebrate → ins x Organism := \nbegin \n intros a h,\n have h1, from a15 Animal Organism a, \n apply h1,\n exact and.intro a72771 a71371,\n have h0 : ∀ x, ins x Vertebrate → ins x Animal, apply VertebrateAnimal; assumption,\n have h2, from h0 a h,\n exact and.intro a71369 h2,\nend\n\nlemma VertebrateOrganism' : ∀ (x : U), ins x Vertebrate → ins x Organism := \nbegin\n  intros a h,\n  have h₁ : ins subclass_m TransitiveRelation,\n    --specialize a15 PartialOrderingRelation TransitiveRelation subclass_m,\n    apply a15,\n    exact ⟨a72180, a71844⟩, \n    exact ⟨a67818, a13⟩, \n  have h₂ : subclass Vertebrate Organism,\n    apply a67809 _ Animal _,\n    exact ⟨a71402, ⟨a72771, a71371⟩⟩,\n    exact h₁,\n    exact ⟨a71382, a71369⟩,\n  apply a15 Vertebrate _ _,\n  exact ⟨a71402, a71371⟩,\n  exact ⟨h₂, h⟩\nend\n\nlemma VertebrateEntity : ∀ (x : U), ins x Vertebrate → ins x Entity := \nbegin\n  intros a h, \n  have h1, apply subclass_TransitiveRelation; assumption,\n  have h2 : subclass Vertebrate Organism,\n    apply a67809 _ Animal _,\n    exact ⟨a71402, ⟨ a72771, a71371 ⟩⟩,\n    exact h1,\n    exact ⟨a71382, a71369⟩,  \n  have h3 : subclass Vertebrate Agent,\n    apply a67809 _ Organism _,\n    exact ⟨a71402, ⟨ a71371, a71872 ⟩⟩,\n    exact h1,\n    exact ⟨h2, a71340⟩,\n  have h4 : subclass Vertebrate Object,\n    apply a67809 _ Agent _,\n    exact ⟨a71402, ⟨ a71872, a71669 ⟩⟩,\n    exact h1,\n    exact ⟨h3, a67315⟩,\n  have h5 : subclass Vertebrate Physical,\n    apply a67809 _ Object _,\n    exact ⟨a71402, ⟨ a71669, a69763 ⟩⟩,\n    exact h1,\n    exact ⟨h4, a67177⟩,\n  have h6 : subclass Vertebrate Entity,\n    apply a67809 _ Physical _,\n    exact ⟨a71402, ⟨ a69763, a67331 ⟩⟩,\n    exact h1,\n    exact ⟨ h5, a67174 ⟩,\n  apply a15 Vertebrate _ _,\n  exact ⟨a71402, a67331⟩,\n  exact ⟨h6, h⟩\nend\n\n-- start proofs\n\nlemma listLemma (hne : nonempty U) : ∀ x y z : U, \n  ins x Entity ∧ ins y Entity ∧ ins z Entity →\n  inList x (ListFn2 y z) → x = y ∨ x = z :=\nbegin\n  intros x y z h h1,\n    rw (a72767 y z ⟨h.right.left, h.right.right⟩) at h1,\n    have h2 : x = y ∨ inList x (ConsFn z NullList_m),\n      rw ←(a72770 (ConsFn z NullList_m) x y),\n      exact h1,\n      simp *,\n      apply novo1 z NullList_m,\n        apply a15 Abstract Entity NullList_m,\n          --simp *,\n            --apply a15 Relation Abstract NullList_m;\n            --  simp *,\n            --  apply a15 List Relation NullList_m;\n            --    simp *,\n            --    assumption,\n          exact ⟨a68771, a67331⟩,\n          have h3, from a15 _ _ _ ⟨a67958, a68763⟩ ⟨a67954, a67959⟩,\n          exact ⟨a67332, a15 _ _ _ ⟨a68763, a68771⟩ ⟨a67450, h3⟩⟩, \n          exact a67959,\n      cases h2,\n        exact or.inl h2,\n        have h3 : x = z ∨ inList x NullList_m,\n          rw ←(a72770 NullList_m x z),\n          exact h2,\n          exact ⟨h.1, ⟨h.2.2, a67959⟩⟩,\n          cases h3,\n            exact or.inr h3,\n            apply false.elim,\n              exact ((a72769 x) h.left) h3\nend\n\n\nlemma lX (hne : nonempty U) : ∀ x c c1 c2,\n  (ins c SetOrClass ∧ ins c1 SetOrClass ∧ ins c2 SetOrClass) →\n  (ins c Class ∧ ins c1 Class ∧ ins c2 Class ∧ ins x Entity) → \n    (partition3 c c1 c2 ∧ ins x c ∧ ¬ ins x c1) → ins x c2 := \nbegin\n  intros a c c1 c2 h1 h2 h3,\n  have a67131', from a67131 c c1 c2,\n  have a67115', from a67115 c1 c2 c a,\n  have h₃, from a67131' ⟨ h2.1, ⟨h2.2.1, h2.2.2.1 ⟩⟩,\n  have h4, from iff.elim_left h₃ h3.1,\n  cases h4 with h4a h4b,\n  cases a67115' with b h5,\n  have h7, from h5.right,\n  have h8, from h2.right.right.right,\n  specialize h7 h8,\n  have h9 : subclass SetOrClass Entity,\n    apply (a67809 _ Abstract _), \n      exact ⟨a67448, ⟨a68771, a67331⟩⟩,\n      apply subclass_TransitiveRelation; assumption,\n      exact ⟨a67446, a67332⟩,\n  have h10 : ins c1 Entity,\n    apply (a15 SetOrClass _ _), \n      exact ⟨a67448, a67331⟩,\n      exact ⟨h9, h1.2.1⟩,\n  have h11 : ins c2 Entity,\n    apply (a15 SetOrClass _ _), \n      exact ⟨a67448, a67331⟩,\n      exact ⟨h9, h1.2.2⟩,\n  specialize h7 ⟨h1.1, ⟨h2.1, ⟨h2.2.1, ⟨h10, ⟨h2.2.2.1, h11⟩⟩⟩⟩⟩,\n  specialize h7 h4a,\n  specialize h7 h3.right.left,\n  have h12 : b = c1 ∨ b = c2,\n    apply listLemma, \n      repeat { assumption },\n      split,\n        apply a15 SetOrClass _ _,\n          exact ⟨a67448, a67331⟩,\n          exact ⟨h9, h5.left⟩,\n      exact ⟨h10, h11⟩,\n      exact h7.left,\n  cases h12,\n    rw h12 at h7,\n    apply false.elim,\n      exact h3.right.right h7.right,\n    rw ←h12,\n    exact h7.right\n end\n\n\nlemma subclass_animal_entity : subclass Animal Entity :=\nbegin\n  have h1, apply subclass_TransitiveRelation; assumption,\n  have h2 : subclass Animal Agent,\n    apply a67809 _ Organism _,\n    exact ⟨a72771, ⟨ a71371, a71872 ⟩⟩,\n    exact h1,\n    exact ⟨a71369, a71340⟩,\n  have h3 : subclass Animal Object,\n    apply a67809 _ Agent _,\n    exact ⟨a72771, ⟨ a71872, a71669 ⟩⟩,\n    exact h1,\n    exact ⟨h2, a67315⟩,\n  have h4 : subclass Animal Physical,\n    apply a67809 _ Object _,\n    exact ⟨a72771, ⟨ a71669, a69763 ⟩⟩,\n    exact h1,\n    exact ⟨h3, a67177⟩,\n  apply a67809 _ Physical _,\n  exact ⟨a72771, ⟨ a69763, a67331 ⟩⟩,\n  exact h1,\n  exact ⟨ h4, a67174 ⟩,\nend\n\nlemma subclass_vertebrate_entity : subclass Vertebrate Entity :=\nbegin\n  have h1, apply subclass_TransitiveRelation; assumption,\n  have h2 : subclass Vertebrate Organism,\n    apply a67809 _ Animal _,\n    exact ⟨a71402, ⟨ a72771, a71371 ⟩⟩,\n    exact h1,\n    exact ⟨a71382, a71369⟩,  \n  have h3 : subclass Vertebrate Agent,\n    apply a67809 _ Organism _,\n    exact ⟨a71402, ⟨ a71371, a71872 ⟩⟩,\n    exact h1,\n    exact ⟨h2, a71340⟩,\n  have h4 : subclass Vertebrate Object,\n    apply a67809 _ Agent _,\n    exact ⟨a71402, ⟨ a71872, a71669 ⟩⟩,\n    exact h1,\n    exact ⟨h3, a67315⟩,\n  have h5 : subclass Vertebrate Physical,\n    apply a67809 _ Object _,\n    exact ⟨a71402, ⟨ a71669, a69763 ⟩⟩,\n    exact h1,\n    exact ⟨h4, a67177⟩,\n  apply a67809 _ Physical _,\n  exact ⟨a71402, ⟨ a69763, a67331 ⟩⟩,\n  exact h1,\n  exact ⟨ h5, a67174 ⟩,\nend\n\nlemma subclass_invertebrate_entity : subclass Invertebrate Entity :=\nbegin\n  have h1, apply subclass_TransitiveRelation; assumption,\n  have h2 : subclass Invertebrate Organism,\n    apply a67809 _ Animal _,\n    exact ⟨a72778, ⟨ a72771, a71371 ⟩⟩,\n    exact h1,\n    exact ⟨a71383, a71369⟩,  \n  have h3 : subclass Invertebrate Agent,\n    apply a67809 _ Organism _,\n    exact ⟨a72778, ⟨ a71371, a71872 ⟩⟩,\n    exact h1,\n    exact ⟨h2, a71340⟩,\n  have h4 : subclass Invertebrate Object,\n    apply a67809 _ Agent _,\n    exact ⟨a72778, ⟨ a71872, a71669 ⟩⟩,\n    exact h1,\n    exact ⟨h3, a67315⟩,\n  have h5 : subclass Invertebrate Physical,\n    apply a67809 _ Object _,\n    exact ⟨a72778, ⟨ a71669, a69763 ⟩⟩,\n    exact h1,\n    exact ⟨h4, a67177⟩,\n  apply a67809 _ Physical _,\n  exact ⟨a72778, ⟨ a69763, a67331 ⟩⟩,\n  exact h1,\n  exact ⟨ h5, a67174 ⟩,\nend\n\nlemma ins_banana_entity : ins BananaSlug10 Entity := \nbegin\n have h1, apply subclass_TransitiveRelation; assumption,\n have h2 : ins BananaSlug10 Organism, \n  --specialize a15 Animal Organism BananaSlug10,\n  apply a15,\n  exact and.intro a72771 a71371,\n  exact and.intro a71369 a72772,\n have h3 : ins BananaSlug10 Agent, \n  --specialize a15 Organism Agent BananaSlug10,\n  apply a15,\n  exact and.intro a71371 a71872,\n  exact and.intro a71340 h2,\n have h4 : ins BananaSlug10 Object, \n  --specialize a15 Agent Object BananaSlug10,\n  apply a15,\n  exact and.intro a71872 a71669,\n  exact and.intro a67315 h3,\n have h5 : ins BananaSlug10 Physical, \n  --specialize a15 Object Physical BananaSlug10,\n  apply a15,\n  exact and.intro a71669 a69763,\n  exact and.intro a67177 h4,\n --specialize a15 Physical Entity BananaSlug10,\n apply a15,\n exact and.intro a69763 a67331,\n exact and.intro a67174 h5,\nend\n\nlemma ins_animal_class : ins Animal Class :=\nbegin\n have h0 : subclass Animal Entity,\n  apply subclass_animal_entity; assumption,\n have h1, from (a67173 Animal),\n exact h1.2 h0,\nend\n\n\n--lemma l0' (hne : nonempty U) : ¬(ins BananaSlug10 Vertebrate) := by simp *\nlemma l0  (hne : nonempty U) : ¬(ins BananaSlug10 Vertebrate) :=\nbegin\n  have a72773', from a72773 BananaSlug10,\n  exact a72773' (and.intro a72772 a72774)\nend\n\ntheorem Banana_Invertebrate (hne: nonempty U) : ins BananaSlug10 Invertebrate :=\nbegin\n have h1 : ¬ ins BananaSlug10 Vertebrate,\n  apply l0; assumption,\n have h2 : ∀ x c c1 c2,\n  (ins c SetOrClass ∧ ins c1 SetOrClass ∧ ins c2 SetOrClass) →\n  (ins c Class ∧ ins c1 Class ∧ ins c2 Class ∧ ins x Entity) → \n   (partition3 c c1 c2 ∧ ins x c ∧ ¬ ins x c1) → ins x c2, \n   apply lX; assumption,\n have h3, from h2 BananaSlug10 Animal Vertebrate Invertebrate,\n apply h3,\n exact ⟨ a72771, ⟨ a71402, a72778 ⟩⟩,\n have h₁ : subclass Animal Entity, \n   apply subclass_animal_entity; assumption,\n have h₂ : ins Animal Class,\n   rw a67173, exact h₁,\n have h₃ : subclass Vertebrate Entity,\n   apply subclass_vertebrate_entity; assumption,\n have h₄ : ins Vertebrate Class, \n   rw a67173, exact h₃,\n have h₅ : subclass Invertebrate Entity,\n   apply subclass_invertebrate_entity; assumption,\n have h₆ : ins Invertebrate Class, \n  rw a67173, exact h₅,\n have h₇ : ins BananaSlug10 Entity, \n  apply ins_banana_entity; assumption,\n exact and.intro h₂ (and.intro h₄ (and.intro h₆ h₇)),\n exact and.intro a71370 (and.intro a72772 h1),\nend\n", "meta": {"author": "own-pt", "repo": "common-sense-lean", "sha": "f672210aecb4172f5bae265e43e6867397e13b1c", "save_path": "github-repos/lean/own-pt-common-sense-lean", "path": "github-repos/lean/own-pt-common-sense-lean/common-sense-lean-f672210aecb4172f5bae265e43e6867397e13b1c/misc/bs2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4726705075916035}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module order.with_bot\n! leanprover-community/mathlib commit 0111834459f5d7400215223ea95ae38a1265a907\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.BoundedOrder\nimport Mathbin.Data.Option.NAry\n\n/-!\n# `with_bot`, `with_top`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nAdding a `bot` or a `top` to an order.\n\n## Main declarations\n\n* `with_<top/bot> α`: Equips `option α` with the order on `α` plus `none` as the top/bottom element.\n\n -/\n\n\nvariable {α β γ δ : Type _}\n\n#print WithBot /-\n/-- Attach `⊥` to a type. -/\ndef WithBot (α : Type _) :=\n  Option α\n#align with_bot WithBot\n-/\n\nnamespace WithBot\n\nvariable {a b : α}\n\nunsafe instance [has_to_format α] : has_to_format (WithBot α)\n    where to_format x :=\n    match x with\n    | none => \"⊥\"\n    | some x => to_fmt x\n\ninstance [Repr α] : Repr (WithBot α) :=\n  ⟨fun o =>\n    match o with\n    | none => \"⊥\"\n    | some a => \"↑\" ++ repr a⟩\n\ninstance : CoeTC α (WithBot α) :=\n  ⟨some⟩\n\ninstance : Bot (WithBot α) :=\n  ⟨none⟩\n\nunsafe instance {α : Type} [reflected _ α] [has_reflect α] : has_reflect (WithBot α)\n  | ⊥ => q(⊥)\n  | (a : α) => q((coe : α → WithBot α)).subst q(a)\n\ninstance : Inhabited (WithBot α) :=\n  ⟨⊥⟩\n\ninstance [Nonempty α] : Nontrivial (WithBot α) :=\n  Option.nontrivial\n\nopen Function\n\n#print WithBot.coe_injective /-\ntheorem coe_injective : Injective (coe : α → WithBot α) :=\n  Option.some_injective _\n#align with_bot.coe_injective WithBot.coe_injective\n-/\n\n#print WithBot.coe_inj /-\n@[norm_cast]\ntheorem coe_inj : (a : WithBot α) = b ↔ a = b :=\n  Option.some_inj\n#align with_bot.coe_inj WithBot.coe_inj\n-/\n\n#print WithBot.forall /-\nprotected theorem forall {p : WithBot α → Prop} : (∀ x, p x) ↔ p ⊥ ∧ ∀ x : α, p x :=\n  Option.forall\n#align with_bot.forall WithBot.forall\n-/\n\n#print WithBot.exists /-\nprotected theorem exists {p : WithBot α → Prop} : (∃ x, p x) ↔ p ⊥ ∨ ∃ x : α, p x :=\n  Option.exists\n#align with_bot.exists WithBot.exists\n-/\n\n#print WithBot.none_eq_bot /-\ntheorem none_eq_bot : (none : WithBot α) = (⊥ : WithBot α) :=\n  rfl\n#align with_bot.none_eq_bot WithBot.none_eq_bot\n-/\n\n#print WithBot.some_eq_coe /-\ntheorem some_eq_coe (a : α) : (some a : WithBot α) = (↑a : WithBot α) :=\n  rfl\n#align with_bot.some_eq_coe WithBot.some_eq_coe\n-/\n\n#print WithBot.bot_ne_coe /-\n@[simp]\ntheorem bot_ne_coe : ⊥ ≠ (a : WithBot α) :=\n  fun.\n#align with_bot.bot_ne_coe WithBot.bot_ne_coe\n-/\n\n#print WithBot.coe_ne_bot /-\n@[simp]\ntheorem coe_ne_bot : (a : WithBot α) ≠ ⊥ :=\n  fun.\n#align with_bot.coe_ne_bot WithBot.coe_ne_bot\n-/\n\n#print WithBot.recBotCoe /-\n/-- Recursor for `with_bot` using the preferred forms `⊥` and `↑a`. -/\n@[elab_as_elim]\ndef recBotCoe {C : WithBot α → Sort _} (h₁ : C ⊥) (h₂ : ∀ a : α, C a) : ∀ n : WithBot α, C n :=\n  Option.rec h₁ h₂\n#align with_bot.rec_bot_coe WithBot.recBotCoe\n-/\n\n/- warning: with_bot.rec_bot_coe_bot -> WithBot.recBotCoe_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {C : (WithBot.{u1} α) -> Sort.{u2}} (d : C (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (f : forall (a : α), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a)), Eq.{u2} (C (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (WithBot.recBotCoe.{u1, u2} α C d f (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) d\nbut is expected to have type\n  forall {α : Type.{u2}} {C : (WithBot.{u2} α) -> Sort.{u1}} (d : C (Bot.bot.{u2} (WithBot.{u2} α) (WithBot.bot.{u2} α))) (f : forall (a : α), C (WithBot.some.{u2} α a)), Eq.{u1} (C (Bot.bot.{u2} (WithBot.{u2} α) (WithBot.bot.{u2} α))) (WithBot.recBotCoe.{u2, u1} α C d f (Bot.bot.{u2} (WithBot.{u2} α) (WithBot.bot.{u2} α))) d\nCase conversion may be inaccurate. Consider using '#align with_bot.rec_bot_coe_bot WithBot.recBotCoe_botₓ'. -/\n@[simp]\ntheorem recBotCoe_bot {C : WithBot α → Sort _} (d : C ⊥) (f : ∀ a : α, C a) :\n    @recBotCoe _ C d f ⊥ = d :=\n  rfl\n#align with_bot.rec_bot_coe_bot WithBot.recBotCoe_bot\n\n/- warning: with_bot.rec_bot_coe_coe -> WithBot.recBotCoe_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {C : (WithBot.{u1} α) -> Sort.{u2}} (d : C (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (f : forall (a : α), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a)) (x : α), Eq.{u2} (C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) x)) (WithBot.recBotCoe.{u1, u2} α C d f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) x)) (f x)\nbut is expected to have type\n  forall {α : Type.{u2}} {C : (WithBot.{u2} α) -> Sort.{u1}} (d : C (Bot.bot.{u2} (WithBot.{u2} α) (WithBot.bot.{u2} α))) (f : forall (a : α), C (WithBot.some.{u2} α a)) (x : α), Eq.{u1} (C (WithBot.some.{u2} α x)) (WithBot.recBotCoe.{u2, u1} α C d f (WithBot.some.{u2} α x)) (f x)\nCase conversion may be inaccurate. Consider using '#align with_bot.rec_bot_coe_coe WithBot.recBotCoe_coeₓ'. -/\n@[simp]\ntheorem recBotCoe_coe {C : WithBot α → Sort _} (d : C ⊥) (f : ∀ a : α, C a) (x : α) :\n    @recBotCoe _ C d f ↑x = f x :=\n  rfl\n#align with_bot.rec_bot_coe_coe WithBot.recBotCoe_coe\n\n#print WithBot.unbot' /-\n/-- Specialization of `option.get_or_else` to values in `with_bot α` that respects API boundaries.\n-/\ndef unbot' (d : α) (x : WithBot α) : α :=\n  recBotCoe d id x\n#align with_bot.unbot' WithBot.unbot'\n-/\n\n#print WithBot.unbot'_bot /-\n@[simp]\ntheorem unbot'_bot {α} (d : α) : unbot' d ⊥ = d :=\n  rfl\n#align with_bot.unbot'_bot WithBot.unbot'_bot\n-/\n\n#print WithBot.unbot'_coe /-\n@[simp]\ntheorem unbot'_coe {α} (d x : α) : unbot' d x = x :=\n  rfl\n#align with_bot.unbot'_coe WithBot.unbot'_coe\n-/\n\n#print WithBot.coe_eq_coe /-\n@[norm_cast]\ntheorem coe_eq_coe : (a : WithBot α) = b ↔ a = b :=\n  Option.some_inj\n#align with_bot.coe_eq_coe WithBot.coe_eq_coe\n-/\n\n#print WithBot.unbot'_eq_iff /-\ntheorem unbot'_eq_iff {d y : α} {x : WithBot α} : unbot' d x = y ↔ x = y ∨ x = ⊥ ∧ y = d := by\n  induction x using WithBot.recBotCoe <;> simp [@eq_comm _ d, coe_eq_coe]\n#align with_bot.unbot'_eq_iff WithBot.unbot'_eq_iff\n-/\n\n#print WithBot.unbot'_eq_self_iff /-\n@[simp]\ntheorem unbot'_eq_self_iff {d : α} {x : WithBot α} : unbot' d x = d ↔ x = d ∨ x = ⊥ := by\n  simp [unbot'_eq_iff]\n#align with_bot.unbot'_eq_self_iff WithBot.unbot'_eq_self_iff\n-/\n\n#print WithBot.unbot'_eq_unbot'_iff /-\ntheorem unbot'_eq_unbot'_iff {d : α} {x y : WithBot α} :\n    unbot' d x = unbot' d y ↔ x = y ∨ x = d ∧ y = ⊥ ∨ x = ⊥ ∧ y = d := by\n  induction y using WithBot.recBotCoe <;> simp [unbot'_eq_iff, or_comm', coe_eq_coe]\n#align with_bot.unbot'_eq_unbot'_iff WithBot.unbot'_eq_unbot'_iff\n-/\n\n#print WithBot.map /-\n/-- Lift a map `f : α → β` to `with_bot α → with_bot β`. Implemented using `option.map`. -/\ndef map (f : α → β) : WithBot α → WithBot β :=\n  Option.map f\n#align with_bot.map WithBot.map\n-/\n\n#print WithBot.map_bot /-\n@[simp]\ntheorem map_bot (f : α → β) : map f ⊥ = ⊥ :=\n  rfl\n#align with_bot.map_bot WithBot.map_bot\n-/\n\n#print WithBot.map_coe /-\n@[simp]\ntheorem map_coe (f : α → β) (a : α) : map f a = f a :=\n  rfl\n#align with_bot.map_coe WithBot.map_coe\n-/\n\n/- warning: with_bot.map_comm -> WithBot.map_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f₁ : α -> β} {f₂ : α -> γ} {g₁ : β -> δ} {g₂ : γ -> δ}, (Eq.{max (succ u1) (succ u4)} (α -> δ) (Function.comp.{succ u1, succ u2, succ u4} α β δ g₁ f₁) (Function.comp.{succ u1, succ u3, succ u4} α γ δ g₂ f₂)) -> (forall (a : α), Eq.{succ u4} (WithBot.{u4} δ) (WithBot.map.{u2, u4} β δ g₁ (WithBot.map.{u1, u2} α β f₁ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a))) (WithBot.map.{u3, u4} γ δ g₂ (WithBot.map.{u1, u3} α γ f₂ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a))))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u2}} {γ : Type.{u1}} {δ : Type.{u3}} {f₁ : α -> β} {f₂ : α -> γ} {g₁ : β -> δ} {g₂ : γ -> δ}, (Eq.{max (succ u4) (succ u3)} (α -> δ) (Function.comp.{succ u4, succ u2, succ u3} α β δ g₁ f₁) (Function.comp.{succ u4, succ u1, succ u3} α γ δ g₂ f₂)) -> (forall (a : α), Eq.{succ u3} (WithBot.{u3} δ) (WithBot.map.{u2, u3} β δ g₁ (WithBot.map.{u4, u2} α β f₁ (WithBot.some.{u4} α a))) (WithBot.map.{u1, u3} γ δ g₂ (WithBot.map.{u4, u1} α γ f₂ (WithBot.some.{u4} α a))))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_comm WithBot.map_commₓ'. -/\ntheorem map_comm {f₁ : α → β} {f₂ : α → γ} {g₁ : β → δ} {g₂ : γ → δ} (h : g₁ ∘ f₁ = g₂ ∘ f₂)\n    (a : α) : map g₁ (map f₁ a) = map g₂ (map f₂ a) :=\n  Option.map_comm h _\n#align with_bot.map_comm WithBot.map_comm\n\n#print WithBot.ne_bot_iff_exists /-\ntheorem ne_bot_iff_exists {x : WithBot α} : x ≠ ⊥ ↔ ∃ a : α, ↑a = x :=\n  Option.ne_none_iff_exists\n#align with_bot.ne_bot_iff_exists WithBot.ne_bot_iff_exists\n-/\n\n#print WithBot.unbot /-\n/-- Deconstruct a `x : with_bot α` to the underlying value in `α`, given a proof that `x ≠ ⊥`. -/\ndef unbot : ∀ x : WithBot α, x ≠ ⊥ → α\n  | ⊥, h => absurd rfl h\n  | some x, h => x\n#align with_bot.unbot WithBot.unbot\n-/\n\n#print WithBot.coe_unbot /-\n@[simp]\ntheorem coe_unbot (x : WithBot α) (h : x ≠ ⊥) : (x.unbot h : WithBot α) = x :=\n  by\n  cases x\n  simpa using h\n  rfl\n#align with_bot.coe_unbot WithBot.coe_unbot\n-/\n\n#print WithBot.unbot_coe /-\n@[simp]\ntheorem unbot_coe (x : α) (h : (x : WithBot α) ≠ ⊥ := coe_ne_bot) : (x : WithBot α).unbot h = x :=\n  rfl\n#align with_bot.unbot_coe WithBot.unbot_coe\n-/\n\n#print WithBot.canLift /-\ninstance canLift : CanLift (WithBot α) α coe fun r => r ≠ ⊥\n    where prf x h := ⟨x.unbot h, coe_unbot _ _⟩\n#align with_bot.can_lift WithBot.canLift\n-/\n\nsection LE\n\nvariable [LE α]\n\ninstance (priority := 10) : LE (WithBot α) :=\n  ⟨fun o₁ o₂ : Option α => ∀ a ∈ o₁, ∃ b ∈ o₂, a ≤ b⟩\n\n/- warning: with_bot.some_le_some -> WithBot.some_le_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.some_le_some WithBot.some_le_someₓ'. -/\n@[simp]\ntheorem some_le_some : @LE.le (WithBot α) _ (some a) (some b) ↔ a ≤ b := by simp [(· ≤ ·)]\n#align with_bot.some_le_some WithBot.some_le_some\n\n/- warning: with_bot.coe_le_coe -> WithBot.coe_le_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b)) (LE.le.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) (WithBot.some.{u1} α a) (WithBot.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le_coe WithBot.coe_le_coeₓ'. -/\n@[simp, norm_cast]\ntheorem coe_le_coe : (a : WithBot α) ≤ b ↔ a ≤ b :=\n  some_le_some\n#align with_bot.coe_le_coe WithBot.coe_le_coe\n\n/- warning: with_bot.none_le -> WithBot.none_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} α}, LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) (Option.none.{u1} α) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} α}, LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) (Option.none.{u1} α) a\nCase conversion may be inaccurate. Consider using '#align with_bot.none_le WithBot.none_leₓ'. -/\n@[simp]\ntheorem none_le {a : WithBot α} : @LE.le (WithBot α) _ none a := fun b h => Option.noConfusion h\n#align with_bot.none_le WithBot.none_le\n\ninstance : OrderBot (WithBot α) :=\n  { WithBot.hasBot with bot_le := fun a => none_le }\n\ninstance [OrderTop α] : OrderTop (WithBot α)\n    where\n  top := some ⊤\n  le_top o a ha := by cases ha <;> exact ⟨_, rfl, le_top⟩\n\ninstance [OrderTop α] : BoundedOrder (WithBot α) :=\n  { WithBot.orderTop, WithBot.orderBot with }\n\n/- warning: with_bot.not_coe_le_bot -> WithBot.not_coe_le_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] (a : α), Not (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] (a : α), Not (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) (WithBot.some.{u1} α a) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_bot.not_coe_le_bot WithBot.not_coe_le_botₓ'. -/\ntheorem not_coe_le_bot (a : α) : ¬(a : WithBot α) ≤ ⊥ := fun h =>\n  let ⟨b, hb, _⟩ := h _ rfl\n  Option.not_mem_none _ hb\n#align with_bot.not_coe_le_bot WithBot.not_coe_le_bot\n\n/- warning: with_bot.coe_le -> WithBot.coe_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α] {o : Option.{u1} α}, (Membership.Mem.{u1, u1} α (Option.{u1} α) (Option.hasMem.{u1} α) b o) -> (Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) o) (LE.le.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α] {o : Option.{u1} α}, (Membership.mem.{u1, u1} α (Option.{u1} α) (Option.instMembershipOption.{u1} α) b o) -> (Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) (WithBot.some.{u1} α a) o) (LE.le.{u1} α _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le WithBot.coe_leₓ'. -/\ntheorem coe_le : ∀ {o : Option α}, b ∈ o → ((a : WithBot α) ≤ o ↔ a ≤ b)\n  | _, rfl => coe_le_coe\n#align with_bot.coe_le WithBot.coe_le\n\n/- warning: with_bot.coe_le_iff -> WithBot.coe_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α] {x : WithBot.{u1} α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) x) (Exists.{succ u1} α (fun (b : α) => And (Eq.{succ u1} (WithBot.{u1} α) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b)) (LE.le.{u1} α _inst_1 a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α] {x : WithBot.{u1} α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) (WithBot.some.{u1} α a) x) (Exists.{succ u1} α (fun (b : α) => And (Eq.{succ u1} (WithBot.{u1} α) x (WithBot.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b)))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le_iff WithBot.coe_le_iffₓ'. -/\ntheorem coe_le_iff : ∀ {x : WithBot α}, ↑a ≤ x ↔ ∃ b : α, x = b ∧ a ≤ b\n  | some a => by simp [some_eq_coe, coe_eq_coe]\n  | none => iff_of_false (not_coe_le_bot _) <| by simp [none_eq_bot]\n#align with_bot.coe_le_iff WithBot.coe_le_iff\n\n/- warning: with_bot.le_coe_iff -> WithBot.le_coe_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {b : α} [_inst_1 : LE.{u1} α] {x : WithBot.{u1} α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b)) (forall (a : α), (Eq.{succ u1} (WithBot.{u1} α) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a)) -> (LE.le.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} {b : α} [_inst_1 : LE.{u1} α] {x : WithBot.{u1} α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) x (WithBot.some.{u1} α b)) (forall (a : α), (Eq.{succ u1} (WithBot.{u1} α) x (WithBot.some.{u1} α a)) -> (LE.le.{u1} α _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.le_coe_iff WithBot.le_coe_iffₓ'. -/\ntheorem le_coe_iff : ∀ {x : WithBot α}, x ≤ b ↔ ∀ a, x = ↑a → a ≤ b\n  | some b => by simp [some_eq_coe, coe_eq_coe]\n  | none => by simp [none_eq_bot]\n#align with_bot.le_coe_iff WithBot.le_coe_iff\n\n/- warning: is_max.with_bot -> IsMax.withBot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α], (IsMax.{u1} α _inst_1 a) -> (IsMax.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α], (IsMax.{u1} α _inst_1 a) -> (IsMax.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) (WithBot.some.{u1} α a))\nCase conversion may be inaccurate. Consider using '#align is_max.with_bot IsMax.withBotₓ'. -/\nprotected theorem IsMax.withBot (h : IsMax a) : IsMax (a : WithBot α)\n  | none, _ => bot_le\n  | some b, hb => some_le_some.2 <| h <| some_le_some.1 hb\n#align is_max.with_bot IsMax.withBot\n\nend LE\n\nsection LT\n\nvariable [LT α]\n\ninstance (priority := 10) : LT (WithBot α) :=\n  ⟨fun o₁ o₂ : Option α => ∃ b ∈ o₂, ∀ a ∈ o₁, a < b⟩\n\n/- warning: with_bot.some_lt_some -> WithBot.some_lt_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LT.{u1} α], Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LT.lt.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LT.{u1} α], Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LT.lt.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.some_lt_some WithBot.some_lt_someₓ'. -/\n@[simp]\ntheorem some_lt_some : @LT.lt (WithBot α) _ (some a) (some b) ↔ a < b := by simp [(· < ·)]\n#align with_bot.some_lt_some WithBot.some_lt_some\n\n/- warning: with_bot.coe_lt_coe -> WithBot.coe_lt_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LT.{u1} α], Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b)) (LT.lt.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LT.{u1} α], Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) (WithBot.some.{u1} α a) (WithBot.some.{u1} α b)) (LT.lt.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_lt_coe WithBot.coe_lt_coeₓ'. -/\n@[simp, norm_cast]\ntheorem coe_lt_coe : (a : WithBot α) < b ↔ a < b :=\n  some_lt_some\n#align with_bot.coe_lt_coe WithBot.coe_lt_coe\n\n/- warning: with_bot.none_lt_some -> WithBot.none_lt_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) (Option.none.{u1} α) (Option.some.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) (Option.none.{u1} α) (WithBot.some.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align with_bot.none_lt_some WithBot.none_lt_someₓ'. -/\n@[simp]\ntheorem none_lt_some (a : α) : @LT.lt (WithBot α) _ none (some a) :=\n  ⟨a, rfl, fun b hb => (Option.not_mem_none _ hb).elim⟩\n#align with_bot.none_lt_some WithBot.none_lt_some\n\n/- warning: with_bot.bot_lt_coe -> WithBot.bot_lt_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) (WithBot.some.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_coe WithBot.bot_lt_coeₓ'. -/\ntheorem bot_lt_coe (a : α) : (⊥ : WithBot α) < a :=\n  none_lt_some a\n#align with_bot.bot_lt_coe WithBot.bot_lt_coe\n\n/- warning: with_bot.not_lt_none -> WithBot.not_lt_none is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : WithBot.{u1} α), Not (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) a (Option.none.{u1} α))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : WithBot.{u1} α), Not (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) a (Option.none.{u1} α))\nCase conversion may be inaccurate. Consider using '#align with_bot.not_lt_none WithBot.not_lt_noneₓ'. -/\n@[simp]\ntheorem not_lt_none (a : WithBot α) : ¬@LT.lt (WithBot α) _ a none := fun ⟨_, h, _⟩ =>\n  Option.not_mem_none _ h\n#align with_bot.not_lt_none WithBot.not_lt_none\n\n/- warning: with_bot.lt_iff_exists_coe -> WithBot.lt_iff_exists_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) a b) (Exists.{succ u1} α (fun (p : α) => And (Eq.{succ u1} (WithBot.{u1} α) b ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) p)) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) p))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) a b) (Exists.{succ u1} α (fun (p : α) => And (Eq.{succ u1} (WithBot.{u1} α) b (WithBot.some.{u1} α p)) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) a (WithBot.some.{u1} α p))))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_iff_exists_coe WithBot.lt_iff_exists_coeₓ'. -/\ntheorem lt_iff_exists_coe : ∀ {a b : WithBot α}, a < b ↔ ∃ p : α, b = p ∧ a < p\n  | a, some b => by simp [some_eq_coe, coe_eq_coe]\n  | a, none => iff_of_false (not_lt_none _) <| by simp [none_eq_bot]\n#align with_bot.lt_iff_exists_coe WithBot.lt_iff_exists_coe\n\n/- warning: with_bot.lt_coe_iff -> WithBot.lt_coe_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {b : α} [_inst_1 : LT.{u1} α] {x : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b)) (forall (a : α), (Eq.{succ u1} (WithBot.{u1} α) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a)) -> (LT.lt.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} {b : α} [_inst_1 : LT.{u1} α] {x : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) x (WithBot.some.{u1} α b)) (forall (a : WithBot.{u1} α), (Eq.{succ u1} (WithBot.{u1} α) x a) -> (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) a (WithBot.some.{u1} α b)))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_coe_iff WithBot.lt_coe_iffₓ'. -/\ntheorem lt_coe_iff : ∀ {x : WithBot α}, x < b ↔ ∀ a, x = ↑a → a < b\n  | some b => by simp [some_eq_coe, coe_eq_coe, coe_lt_coe]\n  | none => by simp [none_eq_bot, bot_lt_coe]\n#align with_bot.lt_coe_iff WithBot.lt_coe_iff\n\n/- warning: with_bot.bot_lt_iff_ne_bot -> WithBot.bot_lt_iff_ne_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {x : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) x) (Ne.{succ u1} (WithBot.{u1} α) x (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {x : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) x) (Ne.{succ u1} (WithBot.{u1} α) x (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_iff_ne_bot WithBot.bot_lt_iff_ne_botₓ'. -/\n/-- A version of `bot_lt_iff_ne_bot` for `with_bot` that only requires `has_lt α`, not\n`partial_order α`. -/\nprotected theorem bot_lt_iff_ne_bot : ∀ {x : WithBot α}, ⊥ < x ↔ x ≠ ⊥\n  | ⊥ => iff_of_false (WithBot.not_lt_none _) fun h => h rfl\n  | (x : α) => by simp [bot_lt_coe]\n#align with_bot.bot_lt_iff_ne_bot WithBot.bot_lt_iff_ne_bot\n\nend LT\n\ninstance [Preorder α] : Preorder (WithBot α)\n    where\n  le := (· ≤ ·)\n  lt := (· < ·)\n  lt_iff_le_not_le := by\n    intros\n    cases a <;> cases b <;> simp [lt_iff_le_not_le] <;> simp [(· < ·), (· ≤ ·)]\n  le_refl o a ha := ⟨a, ha, le_rfl⟩\n  le_trans o₁ o₂ o₃ h₁ h₂ a ha :=\n    let ⟨b, hb, ab⟩ := h₁ a ha\n    let ⟨c, hc, bc⟩ := h₂ b hb\n    ⟨c, hc, le_trans ab bc⟩\n\ninstance [PartialOrder α] : PartialOrder (WithBot α) :=\n  { WithBot.preorder with\n    le_antisymm := fun o₁ o₂ h₁ h₂ => by\n      cases' o₁ with a\n      · cases' o₂ with b\n        · rfl\n        rcases h₂ b rfl with ⟨_, ⟨⟩, _⟩\n      · rcases h₁ a rfl with ⟨b, ⟨⟩, h₁'⟩\n        rcases h₂ b rfl with ⟨_, ⟨⟩, h₂'⟩\n        rw [le_antisymm h₁' h₂'] }\n\n#print WithBot.coe_strictMono /-\ntheorem coe_strictMono [Preorder α] : StrictMono (coe : α → WithBot α) := fun a b => some_lt_some.2\n#align with_bot.coe_strict_mono WithBot.coe_strictMono\n-/\n\n#print WithBot.coe_mono /-\ntheorem coe_mono [Preorder α] : Monotone (coe : α → WithBot α) := fun a b => coe_le_coe.2\n#align with_bot.coe_mono WithBot.coe_mono\n-/\n\n/- warning: with_bot.monotone_iff -> WithBot.monotone_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : (WithBot.{u1} α) -> β}, Iff (Monotone.{u1, u2} (WithBot.{u1} α) β (WithBot.preorder.{u1} α _inst_1) _inst_2 f) (And (Monotone.{u1, u2} α β _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} α (WithBot.{u1} α) β f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α)))))) (forall (x : α), LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) (f (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) x))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : (WithBot.{u2} α) -> β}, Iff (Monotone.{u2, u1} (WithBot.{u2} α) β (WithBot.preorder.{u2} α _inst_1) _inst_2 f) (And (Monotone.{u2, u1} α β _inst_1 _inst_2 (fun (a : α) => f (WithBot.some.{u2} α a))) (forall (x : α), LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) (f (Bot.bot.{u2} (WithBot.{u2} α) (WithBot.bot.{u2} α))) (f (WithBot.some.{u2} α x))))\nCase conversion may be inaccurate. Consider using '#align with_bot.monotone_iff WithBot.monotone_iffₓ'. -/\ntheorem monotone_iff [Preorder α] [Preorder β] {f : WithBot α → β} :\n    Monotone f ↔ Monotone (f ∘ coe : α → β) ∧ ∀ x : α, f ⊥ ≤ f x :=\n  ⟨fun h => ⟨h.comp WithBot.coe_mono, fun x => h bot_le⟩, fun h =>\n    WithBot.forall.2\n      ⟨WithBot.forall.2 ⟨fun _ => le_rfl, fun x _ => h.2 x⟩, fun x =>\n        WithBot.forall.2 ⟨fun h => (not_coe_le_bot _ h).elim, fun y hle => h.1 (coe_le_coe.1 hle)⟩⟩⟩\n#align with_bot.monotone_iff WithBot.monotone_iff\n\n/- warning: with_bot.monotone_map_iff -> WithBot.monotone_map_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, Iff (Monotone.{u1, u2} (WithBot.{u1} α) (WithBot.{u2} β) (WithBot.preorder.{u1} α _inst_1) (WithBot.preorder.{u2} β _inst_2) (WithBot.map.{u1, u2} α β f)) (Monotone.{u1, u2} α β _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, Iff (Monotone.{u2, u1} (WithBot.{u2} α) (WithBot.{u1} β) (WithBot.preorder.{u2} α _inst_1) (WithBot.preorder.{u1} β _inst_2) (WithBot.map.{u2, u1} α β f)) (Monotone.{u2, u1} α β _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_bot.monotone_map_iff WithBot.monotone_map_iffₓ'. -/\n@[simp]\ntheorem monotone_map_iff [Preorder α] [Preorder β] {f : α → β} :\n    Monotone (WithBot.map f) ↔ Monotone f :=\n  monotone_iff.trans <| by simp [Monotone]\n#align with_bot.monotone_map_iff WithBot.monotone_map_iff\n\n/- warning: monotone.with_bot_map -> Monotone.withBot_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β _inst_1 _inst_2 f) -> (Monotone.{u1, u2} (WithBot.{u1} α) (WithBot.{u2} β) (WithBot.preorder.{u1} α _inst_1) (WithBot.preorder.{u2} β _inst_2) (WithBot.map.{u1, u2} α β f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β _inst_1 _inst_2 f) -> (Monotone.{u2, u1} (WithBot.{u2} α) (WithBot.{u1} β) (WithBot.preorder.{u2} α _inst_1) (WithBot.preorder.{u1} β _inst_2) (WithBot.map.{u2, u1} α β f))\nCase conversion may be inaccurate. Consider using '#align monotone.with_bot_map Monotone.withBot_mapₓ'. -/\nalias monotone_map_iff ↔ _ _root_.monotone.with_bot_map\n#align monotone.with_bot_map Monotone.withBot_map\n\n/- warning: with_bot.strict_mono_iff -> WithBot.strictMono_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : (WithBot.{u1} α) -> β}, Iff (StrictMono.{u1, u2} (WithBot.{u1} α) β (WithBot.preorder.{u1} α _inst_1) _inst_2 f) (And (StrictMono.{u1, u2} α β _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} α (WithBot.{u1} α) β f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α)))))) (forall (x : α), LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) (f (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) x))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : (WithBot.{u2} α) -> β}, Iff (StrictMono.{u2, u1} (WithBot.{u2} α) β (WithBot.preorder.{u2} α _inst_1) _inst_2 f) (And (StrictMono.{u2, u1} α β _inst_1 _inst_2 (fun (a : α) => f (WithBot.some.{u2} α a))) (forall (x : α), LT.lt.{u1} β (Preorder.toLT.{u1} β _inst_2) (f (Bot.bot.{u2} (WithBot.{u2} α) (WithBot.bot.{u2} α))) (f (WithBot.some.{u2} α x))))\nCase conversion may be inaccurate. Consider using '#align with_bot.strict_mono_iff WithBot.strictMono_iffₓ'. -/\ntheorem strictMono_iff [Preorder α] [Preorder β] {f : WithBot α → β} :\n    StrictMono f ↔ StrictMono (f ∘ coe : α → β) ∧ ∀ x : α, f ⊥ < f x :=\n  ⟨fun h => ⟨h.comp WithBot.coe_strictMono, fun x => h (bot_lt_coe _)⟩, fun h =>\n    WithBot.forall.2\n      ⟨WithBot.forall.2 ⟨flip absurd (lt_irrefl _), fun x _ => h.2 x⟩, fun x =>\n        WithBot.forall.2 ⟨fun h => (not_lt_bot h).elim, fun y hle => h.1 (coe_lt_coe.1 hle)⟩⟩⟩\n#align with_bot.strict_mono_iff WithBot.strictMono_iff\n\n/- warning: with_bot.strict_mono_map_iff -> WithBot.strictMono_map_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, Iff (StrictMono.{u1, u2} (WithBot.{u1} α) (WithBot.{u2} β) (WithBot.preorder.{u1} α _inst_1) (WithBot.preorder.{u2} β _inst_2) (WithBot.map.{u1, u2} α β f)) (StrictMono.{u1, u2} α β _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, Iff (StrictMono.{u2, u1} (WithBot.{u2} α) (WithBot.{u1} β) (WithBot.preorder.{u2} α _inst_1) (WithBot.preorder.{u1} β _inst_2) (WithBot.map.{u2, u1} α β f)) (StrictMono.{u2, u1} α β _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_bot.strict_mono_map_iff WithBot.strictMono_map_iffₓ'. -/\n@[simp]\ntheorem strictMono_map_iff [Preorder α] [Preorder β] {f : α → β} :\n    StrictMono (WithBot.map f) ↔ StrictMono f :=\n  strictMono_iff.trans <| by simp [StrictMono, bot_lt_coe]\n#align with_bot.strict_mono_map_iff WithBot.strictMono_map_iff\n\n/- warning: strict_mono.with_bot_map -> StrictMono.withBot_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, (StrictMono.{u1, u2} α β _inst_1 _inst_2 f) -> (StrictMono.{u1, u2} (WithBot.{u1} α) (WithBot.{u2} β) (WithBot.preorder.{u1} α _inst_1) (WithBot.preorder.{u2} β _inst_2) (WithBot.map.{u1, u2} α β f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, (StrictMono.{u2, u1} α β _inst_1 _inst_2 f) -> (StrictMono.{u2, u1} (WithBot.{u2} α) (WithBot.{u1} β) (WithBot.preorder.{u2} α _inst_1) (WithBot.preorder.{u1} β _inst_2) (WithBot.map.{u2, u1} α β f))\nCase conversion may be inaccurate. Consider using '#align strict_mono.with_bot_map StrictMono.withBot_mapₓ'. -/\nalias strict_mono_map_iff ↔ _ _root_.strict_mono.with_bot_map\n#align strict_mono.with_bot_map StrictMono.withBot_map\n\n/- warning: with_bot.map_le_iff -> WithBot.map_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] (f : α -> β), (forall {a : α} {b : α}, Iff (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) (f a) (f b)) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) a b)) -> (forall (a : WithBot.{u1} α) (b : WithBot.{u1} α), Iff (LE.le.{u2} (WithBot.{u2} β) (Preorder.toLE.{u2} (WithBot.{u2} β) (WithBot.preorder.{u2} β _inst_2)) (WithBot.map.{u1, u2} α β f a) (WithBot.map.{u1, u2} α β f b)) (LE.le.{u1} (WithBot.{u1} α) (Preorder.toLE.{u1} (WithBot.{u1} α) (WithBot.preorder.{u1} α _inst_1)) a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] (f : α -> β), (forall {a : α} {b : α}, Iff (LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) (f a) (f b)) (LE.le.{u2} α (Preorder.toLE.{u2} α _inst_1) a b)) -> (forall (a : WithBot.{u2} α) (b : WithBot.{u2} α), Iff (LE.le.{u1} (WithBot.{u1} β) (Preorder.toLE.{u1} (WithBot.{u1} β) (WithBot.preorder.{u1} β _inst_2)) (WithBot.map.{u2, u1} α β f a) (WithBot.map.{u2, u1} α β f b)) (LE.le.{u2} (WithBot.{u2} α) (Preorder.toLE.{u2} (WithBot.{u2} α) (WithBot.preorder.{u2} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_le_iff WithBot.map_le_iffₓ'. -/\ntheorem map_le_iff [Preorder α] [Preorder β] (f : α → β) (mono_iff : ∀ {a b}, f a ≤ f b ↔ a ≤ b) :\n    ∀ a b : WithBot α, a.map f ≤ b.map f ↔ a ≤ b\n  | ⊥, _ => by simp only [map_bot, bot_le]\n  | (a : α), ⊥ => by simp only [map_coe, map_bot, coe_ne_bot, not_coe_le_bot _]\n  | (a : α), (b : α) => by simpa only [map_coe, coe_le_coe] using mono_iff\n#align with_bot.map_le_iff WithBot.map_le_iff\n\n#print WithBot.le_coe_unbot' /-\ntheorem le_coe_unbot' [Preorder α] : ∀ (a : WithBot α) (b : α), a ≤ a.unbot' b\n  | (a : α), b => le_rfl\n  | ⊥, b => bot_le\n#align with_bot.le_coe_unbot' WithBot.le_coe_unbot'\n-/\n\n/- warning: with_bot.unbot'_bot_le_iff -> WithBot.unbot'_bot_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : OrderBot.{u1} α _inst_1] {a : WithBot.{u1} α} {b : α}, Iff (LE.le.{u1} α _inst_1 (WithBot.unbot'.{u1} α (Bot.bot.{u1} α (OrderBot.toHasBot.{u1} α _inst_1 _inst_2)) a) b) (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : OrderBot.{u1} α _inst_1] {a : WithBot.{u1} α} {b : α}, Iff (LE.le.{u1} α _inst_1 (WithBot.unbot'.{u1} α (Bot.bot.{u1} α (OrderBot.toBot.{u1} α _inst_1 _inst_2)) a) b) (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) a (WithBot.some.{u1} α b))\nCase conversion may be inaccurate. Consider using '#align with_bot.unbot'_bot_le_iff WithBot.unbot'_bot_le_iffₓ'. -/\ntheorem unbot'_bot_le_iff [LE α] [OrderBot α] {a : WithBot α} {b : α} : a.unbot' ⊥ ≤ b ↔ a ≤ b := by\n  cases a <;> simp [none_eq_bot, some_eq_coe]\n#align with_bot.unbot'_bot_le_iff WithBot.unbot'_bot_le_iff\n\n/- warning: with_bot.unbot'_lt_iff -> WithBot.unbot'_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : α} {c : α}, (Ne.{succ u1} (WithBot.{u1} α) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α))) -> (Iff (LT.lt.{u1} α _inst_1 (WithBot.unbot'.{u1} α b a) c) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) c)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : α} {c : α}, (Ne.{succ u1} (WithBot.{u1} α) a (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α))) -> (Iff (LT.lt.{u1} α _inst_1 (WithBot.unbot'.{u1} α b a) c) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) a (WithBot.some.{u1} α c)))\nCase conversion may be inaccurate. Consider using '#align with_bot.unbot'_lt_iff WithBot.unbot'_lt_iffₓ'. -/\ntheorem unbot'_lt_iff [LT α] {a : WithBot α} {b c : α} (ha : a ≠ ⊥) : a.unbot' b < c ↔ a < c :=\n  by\n  lift a to α using ha\n  rw [unbot'_coe, coe_lt_coe]\n#align with_bot.unbot'_lt_iff WithBot.unbot'_lt_iff\n\ninstance [SemilatticeSup α] : SemilatticeSup (WithBot α) :=\n  { WithBot.orderBot,\n    WithBot.partialOrder with\n    sup := Option.liftOrGet (· ⊔ ·)\n    le_sup_left := fun o₁ o₂ a ha => by cases ha <;> cases o₂ <;> simp [Option.liftOrGet]\n    le_sup_right := fun o₁ o₂ a ha => by cases ha <;> cases o₁ <;> simp [Option.liftOrGet]\n    sup_le := fun o₁ o₂ o₃ h₁ h₂ a ha =>\n      by\n      cases' o₁ with b <;> cases' o₂ with c <;> cases ha\n      · exact h₂ a rfl\n      · exact h₁ a rfl\n      · rcases h₁ b rfl with ⟨d, ⟨⟩, h₁'⟩\n        simp at h₂\n        exact ⟨d, rfl, sup_le h₁' h₂⟩ }\n\n/- warning: with_bot.coe_sup -> WithBot.coe_sup is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithBot.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) (Sup.sup.{u1} α (SemilatticeSup.toHasSup.{u1} α _inst_1) a b)) (Sup.sup.{u1} (WithBot.{u1} α) (SemilatticeSup.toHasSup.{u1} (WithBot.{u1} α) (WithBot.semilatticeSup.{u1} α _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithBot.{u1} α) (WithBot.some.{u1} α (Sup.sup.{u1} α (SemilatticeSup.toSup.{u1} α _inst_1) a b)) (Sup.sup.{u1} (WithBot.{u1} α) (SemilatticeSup.toSup.{u1} (WithBot.{u1} α) (WithBot.semilatticeSup.{u1} α _inst_1)) (WithBot.some.{u1} α a) (WithBot.some.{u1} α b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_sup WithBot.coe_supₓ'. -/\ntheorem coe_sup [SemilatticeSup α] (a b : α) : ((a ⊔ b : α) : WithBot α) = a ⊔ b :=\n  rfl\n#align with_bot.coe_sup WithBot.coe_sup\n\ninstance [SemilatticeInf α] : SemilatticeInf (WithBot α) :=\n  { WithBot.orderBot,\n    WithBot.partialOrder with\n    inf := Option.map₂ (· ⊓ ·)\n    inf_le_left := fun o₁ o₂ a ha =>\n      by\n      rcases Option.mem_map₂_iff.1 ha with ⟨a, b, rfl : _ = _, rfl : _ = _, rfl⟩\n      exact ⟨_, rfl, inf_le_left⟩\n    inf_le_right := fun o₁ o₂ a ha =>\n      by\n      rcases Option.mem_map₂_iff.1 ha with ⟨a, b, rfl : _ = _, rfl : _ = _, rfl⟩\n      exact ⟨_, rfl, inf_le_right⟩\n    le_inf := fun o₁ o₂ o₃ h₁ h₂ a ha => by\n      cases ha\n      rcases h₁ a rfl with ⟨b, ⟨⟩, ab⟩\n      rcases h₂ a rfl with ⟨c, ⟨⟩, ac⟩\n      exact ⟨_, rfl, le_inf ab ac⟩ }\n\n/- warning: with_bot.coe_inf -> WithBot.coe_inf is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithBot.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) (Inf.inf.{u1} α (SemilatticeInf.toHasInf.{u1} α _inst_1) a b)) (Inf.inf.{u1} (WithBot.{u1} α) (SemilatticeInf.toHasInf.{u1} (WithBot.{u1} α) (WithBot.semilatticeInf.{u1} α _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithBot.{u1} α) (WithBot.some.{u1} α (Inf.inf.{u1} α (SemilatticeInf.toInf.{u1} α _inst_1) a b)) (Inf.inf.{u1} (WithBot.{u1} α) (SemilatticeInf.toInf.{u1} (WithBot.{u1} α) (WithBot.semilatticeInf.{u1} α _inst_1)) (WithBot.some.{u1} α a) (WithBot.some.{u1} α b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_inf WithBot.coe_infₓ'. -/\ntheorem coe_inf [SemilatticeInf α] (a b : α) : ((a ⊓ b : α) : WithBot α) = a ⊓ b :=\n  rfl\n#align with_bot.coe_inf WithBot.coe_inf\n\ninstance [Lattice α] : Lattice (WithBot α) :=\n  { WithBot.semilatticeSup, WithBot.semilatticeInf with }\n\ninstance [DistribLattice α] : DistribLattice (WithBot α) :=\n  { WithBot.lattice with\n    le_sup_inf := fun o₁ o₂ o₃ =>\n      match o₁, o₂, o₃ with\n      | ⊥, ⊥, ⊥ => le_rfl\n      | ⊥, ⊥, (a₁ : α) => le_rfl\n      | ⊥, (a₁ : α), ⊥ => le_rfl\n      | ⊥, (a₁ : α), (a₃ : α) => le_rfl\n      | (a₁ : α), ⊥, ⊥ => inf_le_left\n      | (a₁ : α), ⊥, (a₃ : α) => inf_le_left\n      | (a₁ : α), (a₂ : α), ⊥ => inf_le_right\n      | (a₁ : α), (a₂ : α), (a₃ : α) => coe_le_coe.mpr le_sup_inf }\n\n/- warning: with_bot.decidable_le -> WithBot.decidableLE is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (LE.le.{u1} α _inst_1)], DecidableRel.{succ u1} (WithBot.{u1} α) (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (fun (x._@.Mathlib.Order.WithBot._hyg.4186 : α) (x._@.Mathlib.Order.WithBot._hyg.4188 : α) => LE.le.{u1} α _inst_1 x._@.Mathlib.Order.WithBot._hyg.4186 x._@.Mathlib.Order.WithBot._hyg.4188)], DecidableRel.{succ u1} (WithBot.{u1} α) (fun (x._@.Mathlib.Order.WithBot._hyg.4206 : WithBot.{u1} α) (x._@.Mathlib.Order.WithBot._hyg.4208 : WithBot.{u1} α) => LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) x._@.Mathlib.Order.WithBot._hyg.4206 x._@.Mathlib.Order.WithBot._hyg.4208)\nCase conversion may be inaccurate. Consider using '#align with_bot.decidable_le WithBot.decidableLEₓ'. -/\ninstance decidableLE [LE α] [@DecidableRel α (· ≤ ·)] : @DecidableRel (WithBot α) (· ≤ ·)\n  | none, x => isTrue fun a h => Option.noConfusion h\n  | some x, some y => if h : x ≤ y then isTrue (some_le_some.2 h) else isFalse <| by simp [*]\n  | some x, none => isFalse fun h => by rcases h x rfl with ⟨y, ⟨_⟩, _⟩\n#align with_bot.decidable_le WithBot.decidableLE\n\n/- warning: with_bot.decidable_lt -> WithBot.decidableLT is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (LT.lt.{u1} α _inst_1)], DecidableRel.{succ u1} (WithBot.{u1} α) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (fun (x._@.Mathlib.Order.WithBot._hyg.4348 : α) (x._@.Mathlib.Order.WithBot._hyg.4350 : α) => LT.lt.{u1} α _inst_1 x._@.Mathlib.Order.WithBot._hyg.4348 x._@.Mathlib.Order.WithBot._hyg.4350)], DecidableRel.{succ u1} (WithBot.{u1} α) (fun (x._@.Mathlib.Order.WithBot._hyg.4368 : WithBot.{u1} α) (x._@.Mathlib.Order.WithBot._hyg.4370 : WithBot.{u1} α) => LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) x._@.Mathlib.Order.WithBot._hyg.4368 x._@.Mathlib.Order.WithBot._hyg.4370)\nCase conversion may be inaccurate. Consider using '#align with_bot.decidable_lt WithBot.decidableLTₓ'. -/\ninstance decidableLT [LT α] [@DecidableRel α (· < ·)] : @DecidableRel (WithBot α) (· < ·)\n  | none, some x => isTrue <| by exists x, rfl <;> rintro _ ⟨⟩\n  | some x, some y => if h : x < y then isTrue <| by simp [*] else isFalse <| by simp [*]\n  | x, none => isFalse <| by rintro ⟨a, ⟨⟨⟩⟩⟩\n#align with_bot.decidable_lt WithBot.decidableLT\n\n/- warning: with_bot.is_total_le -> WithBot.isTotal_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : IsTotal.{u1} α (LE.le.{u1} α _inst_1)], IsTotal.{u1} (WithBot.{u1} α) (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : IsTotal.{u1} α (fun (x._@.Mathlib.Order.WithBot._hyg.4547 : α) (x._@.Mathlib.Order.WithBot._hyg.4549 : α) => LE.le.{u1} α _inst_1 x._@.Mathlib.Order.WithBot._hyg.4547 x._@.Mathlib.Order.WithBot._hyg.4549)], IsTotal.{u1} (WithBot.{u1} α) (fun (x._@.Mathlib.Order.WithBot._hyg.4567 : WithBot.{u1} α) (x._@.Mathlib.Order.WithBot._hyg.4569 : WithBot.{u1} α) => LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) x._@.Mathlib.Order.WithBot._hyg.4567 x._@.Mathlib.Order.WithBot._hyg.4569)\nCase conversion may be inaccurate. Consider using '#align with_bot.is_total_le WithBot.isTotal_leₓ'. -/\ninstance isTotal_le [LE α] [IsTotal α (· ≤ ·)] : IsTotal (WithBot α) (· ≤ ·) :=\n  ⟨fun a b =>\n    match a, b with\n    | none, _ => Or.inl bot_le\n    | _, none => Or.inr bot_le\n    | some x, some y => (total_of (· ≤ ·) x y).imp some_le_some.2 some_le_some.2⟩\n#align with_bot.is_total_le WithBot.isTotal_le\n\ninstance [LinearOrder α] : LinearOrder (WithBot α) :=\n  Lattice.toLinearOrder _\n\n/- warning: with_bot.coe_min -> WithBot.coe_min is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithBot.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) (LinearOrder.min.{u1} α _inst_1 x y)) (LinearOrder.min.{u1} (WithBot.{u1} α) (WithBot.linearOrder.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) y))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithBot.{u1} α) (WithBot.some.{u1} α (Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_1) x y)) (Min.min.{u1} (WithBot.{u1} α) (LinearOrder.toMin.{u1} (WithBot.{u1} α) (WithBot.linearOrder.{u1} α _inst_1)) (WithBot.some.{u1} α x) (WithBot.some.{u1} α y))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_min WithBot.coe_minₓ'. -/\n-- this is not marked simp because the corresponding with_top lemmas are used\n@[norm_cast]\ntheorem coe_min [LinearOrder α] (x y : α) : ((min x y : α) : WithBot α) = min x y :=\n  rfl\n#align with_bot.coe_min WithBot.coe_min\n\n/- warning: with_bot.coe_max -> WithBot.coe_max is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithBot.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) (LinearOrder.max.{u1} α _inst_1 x y)) (LinearOrder.max.{u1} (WithBot.{u1} α) (WithBot.linearOrder.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) y))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithBot.{u1} α) (WithBot.some.{u1} α (Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_1) x y)) (Max.max.{u1} (WithBot.{u1} α) (LinearOrder.toMax.{u1} (WithBot.{u1} α) (WithBot.linearOrder.{u1} α _inst_1)) (WithBot.some.{u1} α x) (WithBot.some.{u1} α y))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_max WithBot.coe_maxₓ'. -/\n-- this is not marked simp because the corresponding with_top lemmas are used\n@[norm_cast]\ntheorem coe_max [LinearOrder α] (x y : α) : ((max x y : α) : WithBot α) = max x y :=\n  rfl\n#align with_bot.coe_max WithBot.coe_max\n\n#print WithBot.wellFounded_lt /-\ntheorem wellFounded_lt [Preorder α] (h : @WellFounded α (· < ·)) :\n    @WellFounded (WithBot α) (· < ·) :=\n  have acc_bot : Acc ((· < ·) : WithBot α → WithBot α → Prop) ⊥ :=\n    Acc.intro _ fun a ha => (not_le_of_gt ha bot_le).elim\n  ⟨fun a =>\n    Option.recOn a acc_bot fun a =>\n      Acc.intro _ fun b =>\n        Option.recOn b (fun _ => acc_bot) fun b =>\n          WellFounded.induction h b\n            (show\n              ∀ b : α,\n                (∀ c,\n                    c < b → (c : WithBot α) < a → Acc ((· < ·) : WithBot α → WithBot α → Prop) c) →\n                  (b : WithBot α) < a → Acc ((· < ·) : WithBot α → WithBot α → Prop) b\n              from fun b ih hba =>\n              Acc.intro _ fun c =>\n                Option.recOn c (fun _ => acc_bot) fun c hc =>\n                  ih _ (some_lt_some.1 hc) (lt_trans hc hba))⟩\n#align with_bot.well_founded_lt WithBot.wellFounded_lt\n-/\n\ninstance [LT α] [DenselyOrdered α] [NoMinOrder α] : DenselyOrdered (WithBot α) :=\n  ⟨fun a b =>\n    match a, b with\n    | a, none => fun h : a < ⊥ => (not_lt_none _ h).elim\n    | none, some b => fun h =>\n      let ⟨a, ha⟩ := exists_lt b\n      ⟨a, bot_lt_coe a, coe_lt_coe.2 ha⟩\n    | some a, some b => fun h =>\n      let ⟨a, ha₁, ha₂⟩ := exists_between (coe_lt_coe.1 h)\n      ⟨a, coe_lt_coe.2 ha₁, coe_lt_coe.2 ha₂⟩⟩\n\n#print WithBot.lt_iff_exists_coe_btwn /-\ntheorem lt_iff_exists_coe_btwn [Preorder α] [DenselyOrdered α] [NoMinOrder α] {a b : WithBot α} :\n    a < b ↔ ∃ x : α, a < ↑x ∧ ↑x < b :=\n  ⟨fun h =>\n    let ⟨y, hy⟩ := exists_between h\n    let ⟨x, hx⟩ := lt_iff_exists_coe.1 hy.1\n    ⟨x, hx.1 ▸ hy⟩,\n    fun ⟨x, hx⟩ => lt_trans hx.1 hx.2⟩\n#align with_bot.lt_iff_exists_coe_btwn WithBot.lt_iff_exists_coe_btwn\n-/\n\ninstance [LE α] [NoTopOrder α] [Nonempty α] : NoTopOrder (WithBot α) :=\n  ⟨by\n    apply rec_bot_coe\n    · exact ‹Nonempty α›.elim fun a => ⟨a, not_coe_le_bot a⟩\n    · intro a\n      obtain ⟨b, h⟩ := exists_not_le a\n      exact ⟨b, by rwa [coe_le_coe]⟩⟩\n\ninstance [LT α] [NoMaxOrder α] [Nonempty α] : NoMaxOrder (WithBot α) :=\n  ⟨by\n    apply WithBot.recBotCoe\n    · apply ‹Nonempty α›.elim\n      exact fun a => ⟨a, WithBot.bot_lt_coe a⟩\n    · intro a\n      obtain ⟨b, ha⟩ := exists_gt a\n      exact ⟨b, with_bot.coe_lt_coe.mpr ha⟩⟩\n\nend WithBot\n\n#print WithTop /-\n--TODO(Mario): Construct using order dual on with_bot\n/-- Attach `⊤` to a type. -/\ndef WithTop (α : Type _) :=\n  Option α\n#align with_top WithTop\n-/\n\nnamespace WithTop\n\nvariable {a b : α}\n\nunsafe instance [has_to_format α] : has_to_format (WithTop α)\n    where to_format x :=\n    match x with\n    | none => \"⊤\"\n    | some x => to_fmt x\n\ninstance [Repr α] : Repr (WithTop α) :=\n  ⟨fun o =>\n    match o with\n    | none => \"⊤\"\n    | some a => \"↑\" ++ repr a⟩\n\ninstance : CoeTC α (WithTop α) :=\n  ⟨some⟩\n\ninstance : Top (WithTop α) :=\n  ⟨none⟩\n\nunsafe instance {α : Type} [reflected _ α] [has_reflect α] : has_reflect (WithTop α)\n  | ⊤ => q(⊤)\n  | (a : α) => q((coe : α → WithTop α)).subst q(a)\n\ninstance : Inhabited (WithTop α) :=\n  ⟨⊤⟩\n\ninstance [Nonempty α] : Nontrivial (WithTop α) :=\n  Option.nontrivial\n\n#print WithTop.forall /-\nprotected theorem forall {p : WithTop α → Prop} : (∀ x, p x) ↔ p ⊤ ∧ ∀ x : α, p x :=\n  Option.forall\n#align with_top.forall WithTop.forall\n-/\n\n#print WithTop.exists /-\nprotected theorem exists {p : WithTop α → Prop} : (∃ x, p x) ↔ p ⊤ ∨ ∃ x : α, p x :=\n  Option.exists\n#align with_top.exists WithTop.exists\n-/\n\n#print WithTop.none_eq_top /-\ntheorem none_eq_top : (none : WithTop α) = (⊤ : WithTop α) :=\n  rfl\n#align with_top.none_eq_top WithTop.none_eq_top\n-/\n\n#print WithTop.some_eq_coe /-\ntheorem some_eq_coe (a : α) : (some a : WithTop α) = (↑a : WithTop α) :=\n  rfl\n#align with_top.some_eq_coe WithTop.some_eq_coe\n-/\n\n#print WithTop.top_ne_coe /-\n@[simp]\ntheorem top_ne_coe : ⊤ ≠ (a : WithTop α) :=\n  fun.\n#align with_top.top_ne_coe WithTop.top_ne_coe\n-/\n\n#print WithTop.coe_ne_top /-\n@[simp]\ntheorem coe_ne_top : (a : WithTop α) ≠ ⊤ :=\n  fun.\n#align with_top.coe_ne_top WithTop.coe_ne_top\n-/\n\n#print WithTop.recTopCoe /-\n/-- Recursor for `with_top` using the preferred forms `⊤` and `↑a`. -/\n@[elab_as_elim]\ndef recTopCoe {C : WithTop α → Sort _} (h₁ : C ⊤) (h₂ : ∀ a : α, C a) : ∀ n : WithTop α, C n :=\n  Option.rec h₁ h₂\n#align with_top.rec_top_coe WithTop.recTopCoe\n-/\n\n/- warning: with_top.rec_top_coe_top -> WithTop.recTopCoe_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {C : (WithTop.{u1} α) -> Sort.{u2}} (d : C (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (f : forall (a : α), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a)), Eq.{u2} (C (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (WithTop.recTopCoe.{u1, u2} α C d f (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) d\nbut is expected to have type\n  forall {α : Type.{u2}} {C : (WithTop.{u2} α) -> Sort.{u1}} (d : C (Top.top.{u2} (WithTop.{u2} α) (WithTop.top.{u2} α))) (f : forall (a : α), C (WithTop.some.{u2} α a)), Eq.{u1} (C (Top.top.{u2} (WithTop.{u2} α) (WithTop.top.{u2} α))) (WithTop.recTopCoe.{u2, u1} α C d f (Top.top.{u2} (WithTop.{u2} α) (WithTop.top.{u2} α))) d\nCase conversion may be inaccurate. Consider using '#align with_top.rec_top_coe_top WithTop.recTopCoe_topₓ'. -/\n@[simp]\ntheorem recTopCoe_top {C : WithTop α → Sort _} (d : C ⊤) (f : ∀ a : α, C a) :\n    @recTopCoe _ C d f ⊤ = d :=\n  rfl\n#align with_top.rec_top_coe_top WithTop.recTopCoe_top\n\n/- warning: with_top.rec_top_coe_coe -> WithTop.recTopCoe_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {C : (WithTop.{u1} α) -> Sort.{u2}} (d : C (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (f : forall (a : α), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a)) (x : α), Eq.{u2} (C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) x)) (WithTop.recTopCoe.{u1, u2} α C d f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) x)) (f x)\nbut is expected to have type\n  forall {α : Type.{u2}} {C : (WithTop.{u2} α) -> Sort.{u1}} (d : C (Top.top.{u2} (WithTop.{u2} α) (WithTop.top.{u2} α))) (f : forall (a : α), C (WithTop.some.{u2} α a)) (x : α), Eq.{u1} (C (WithTop.some.{u2} α x)) (WithTop.recTopCoe.{u2, u1} α C d f (WithTop.some.{u2} α x)) (f x)\nCase conversion may be inaccurate. Consider using '#align with_top.rec_top_coe_coe WithTop.recTopCoe_coeₓ'. -/\n@[simp]\ntheorem recTopCoe_coe {C : WithTop α → Sort _} (d : C ⊤) (f : ∀ a : α, C a) (x : α) :\n    @recTopCoe _ C d f ↑x = f x :=\n  rfl\n#align with_top.rec_top_coe_coe WithTop.recTopCoe_coe\n\n#print WithTop.toDual /-\n/-- `with_top.to_dual` is the equivalence sending `⊤` to `⊥` and any `a : α` to `to_dual a : αᵒᵈ`.\nSee `with_top.to_dual_bot_equiv` for the related order-iso.\n-/\nprotected def toDual : WithTop α ≃ WithBot αᵒᵈ :=\n  Equiv.refl _\n#align with_top.to_dual WithTop.toDual\n-/\n\n#print WithTop.ofDual /-\n/-- `with_top.of_dual` is the equivalence sending `⊤` to `⊥` and any `a : αᵒᵈ` to `of_dual a : α`.\nSee `with_top.to_dual_bot_equiv` for the related order-iso.\n-/\nprotected def ofDual : WithTop αᵒᵈ ≃ WithBot α :=\n  Equiv.refl _\n#align with_top.of_dual WithTop.ofDual\n-/\n\n#print WithBot.toDual /-\n/-- `with_bot.to_dual` is the equivalence sending `⊥` to `⊤` and any `a : α` to `to_dual a : αᵒᵈ`.\nSee `with_bot.to_dual_top_equiv` for the related order-iso.\n-/\nprotected def WithBot.toDual : WithBot α ≃ WithTop αᵒᵈ :=\n  Equiv.refl _\n#align with_bot.to_dual WithBot.toDual\n-/\n\n#print WithBot.ofDual /-\n/-- `with_bot.of_dual` is the equivalence sending `⊥` to `⊤` and any `a : αᵒᵈ` to `of_dual a : α`.\nSee `with_bot.to_dual_top_equiv` for the related order-iso.\n-/\nprotected def WithBot.ofDual : WithBot αᵒᵈ ≃ WithTop α :=\n  Equiv.refl _\n#align with_bot.of_dual WithBot.ofDual\n-/\n\n#print WithTop.toDual_symm_apply /-\n@[simp]\ntheorem toDual_symm_apply (a : WithBot αᵒᵈ) : WithTop.toDual.symm a = a.ofDual :=\n  rfl\n#align with_top.to_dual_symm_apply WithTop.toDual_symm_apply\n-/\n\n#print WithTop.ofDual_symm_apply /-\n@[simp]\ntheorem ofDual_symm_apply (a : WithBot α) : WithTop.ofDual.symm a = a.toDual :=\n  rfl\n#align with_top.of_dual_symm_apply WithTop.ofDual_symm_apply\n-/\n\n#print WithTop.toDual_apply_top /-\n@[simp]\ntheorem toDual_apply_top : WithTop.toDual (⊤ : WithTop α) = ⊥ :=\n  rfl\n#align with_top.to_dual_apply_top WithTop.toDual_apply_top\n-/\n\n#print WithTop.ofDual_apply_top /-\n@[simp]\ntheorem ofDual_apply_top : WithTop.ofDual (⊤ : WithTop α) = ⊥ :=\n  rfl\n#align with_top.of_dual_apply_top WithTop.ofDual_apply_top\n-/\n\nopen OrderDual\n\n#print WithTop.toDual_apply_coe /-\n@[simp]\ntheorem toDual_apply_coe (a : α) : WithTop.toDual (a : WithTop α) = toDual a :=\n  rfl\n#align with_top.to_dual_apply_coe WithTop.toDual_apply_coe\n-/\n\n#print WithTop.ofDual_apply_coe /-\n@[simp]\ntheorem ofDual_apply_coe (a : αᵒᵈ) : WithTop.ofDual (a : WithTop αᵒᵈ) = ofDual a :=\n  rfl\n#align with_top.of_dual_apply_coe WithTop.ofDual_apply_coe\n-/\n\n#print WithTop.untop' /-\n/-- Specialization of `option.get_or_else` to values in `with_top α` that respects API boundaries.\n-/\ndef untop' (d : α) (x : WithTop α) : α :=\n  recTopCoe d id x\n#align with_top.untop' WithTop.untop'\n-/\n\n#print WithTop.untop'_top /-\n@[simp]\ntheorem untop'_top {α} (d : α) : untop' d ⊤ = d :=\n  rfl\n#align with_top.untop'_top WithTop.untop'_top\n-/\n\n#print WithTop.untop'_coe /-\n@[simp]\ntheorem untop'_coe {α} (d x : α) : untop' d x = x :=\n  rfl\n#align with_top.untop'_coe WithTop.untop'_coe\n-/\n\n#print WithTop.coe_eq_coe /-\n@[norm_cast]\ntheorem coe_eq_coe : (a : WithTop α) = b ↔ a = b :=\n  Option.some_inj\n#align with_top.coe_eq_coe WithTop.coe_eq_coe\n-/\n\n#print WithTop.untop'_eq_iff /-\ntheorem untop'_eq_iff {d y : α} {x : WithTop α} : untop' d x = y ↔ x = y ∨ x = ⊤ ∧ y = d :=\n  WithBot.unbot'_eq_iff\n#align with_top.untop'_eq_iff WithTop.untop'_eq_iff\n-/\n\n#print WithTop.untop'_eq_self_iff /-\n@[simp]\ntheorem untop'_eq_self_iff {d : α} {x : WithTop α} : untop' d x = d ↔ x = d ∨ x = ⊤ :=\n  WithBot.unbot'_eq_self_iff\n#align with_top.untop'_eq_self_iff WithTop.untop'_eq_self_iff\n-/\n\n#print WithTop.untop'_eq_untop'_iff /-\ntheorem untop'_eq_untop'_iff {d : α} {x y : WithTop α} :\n    untop' d x = untop' d y ↔ x = y ∨ x = d ∧ y = ⊤ ∨ x = ⊤ ∧ y = d :=\n  WithBot.unbot'_eq_unbot'_iff\n#align with_top.untop'_eq_untop'_iff WithTop.untop'_eq_untop'_iff\n-/\n\n#print WithTop.map /-\n/-- Lift a map `f : α → β` to `with_top α → with_top β`. Implemented using `option.map`. -/\ndef map (f : α → β) : WithTop α → WithTop β :=\n  Option.map f\n#align with_top.map WithTop.map\n-/\n\n#print WithTop.map_top /-\n@[simp]\ntheorem map_top (f : α → β) : map f ⊤ = ⊤ :=\n  rfl\n#align with_top.map_top WithTop.map_top\n-/\n\n#print WithTop.map_coe /-\n@[simp]\ntheorem map_coe (f : α → β) (a : α) : map f a = f a :=\n  rfl\n#align with_top.map_coe WithTop.map_coe\n-/\n\n/- warning: with_top.map_comm -> WithTop.map_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f₁ : α -> β} {f₂ : α -> γ} {g₁ : β -> δ} {g₂ : γ -> δ}, (Eq.{max (succ u1) (succ u4)} (α -> δ) (Function.comp.{succ u1, succ u2, succ u4} α β δ g₁ f₁) (Function.comp.{succ u1, succ u3, succ u4} α γ δ g₂ f₂)) -> (forall (a : α), Eq.{succ u4} (WithTop.{u4} δ) (WithTop.map.{u2, u4} β δ g₁ (WithTop.map.{u1, u2} α β f₁ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a))) (WithTop.map.{u3, u4} γ δ g₂ (WithTop.map.{u1, u3} α γ f₂ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a))))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u2}} {γ : Type.{u1}} {δ : Type.{u3}} {f₁ : α -> β} {f₂ : α -> γ} {g₁ : β -> δ} {g₂ : γ -> δ}, (Eq.{max (succ u4) (succ u3)} (α -> δ) (Function.comp.{succ u4, succ u2, succ u3} α β δ g₁ f₁) (Function.comp.{succ u4, succ u1, succ u3} α γ δ g₂ f₂)) -> (forall (a : α), Eq.{succ u3} (WithTop.{u3} δ) (WithTop.map.{u2, u3} β δ g₁ (WithTop.map.{u4, u2} α β f₁ (WithTop.some.{u4} α a))) (WithTop.map.{u1, u3} γ δ g₂ (WithTop.map.{u4, u1} α γ f₂ (WithTop.some.{u4} α a))))\nCase conversion may be inaccurate. Consider using '#align with_top.map_comm WithTop.map_commₓ'. -/\ntheorem map_comm {f₁ : α → β} {f₂ : α → γ} {g₁ : β → δ} {g₂ : γ → δ} (h : g₁ ∘ f₁ = g₂ ∘ f₂)\n    (a : α) : map g₁ (map f₁ a) = map g₂ (map f₂ a) :=\n  Option.map_comm h _\n#align with_top.map_comm WithTop.map_comm\n\n/- warning: with_top.map_to_dual -> WithTop.map_toDual is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : (OrderDual.{u1} α) -> (OrderDual.{u2} β)) (a : WithBot.{u1} α), Eq.{succ u2} (WithTop.{u2} (OrderDual.{u2} β)) (WithTop.map.{u1, u2} (OrderDual.{u1} α) (OrderDual.{u2} β) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a)) (WithBot.map.{u1, u2} α (OrderDual.{u2} β) (Function.comp.{succ u1, succ u2, succ u2} α β (OrderDual.{u2} β) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) (fun (_x : Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) => β -> (OrderDual.{u2} β)) (Equiv.hasCoeToFun.{succ u2, succ u2} β (OrderDual.{u2} β)) (OrderDual.toDual.{u2} β)) f) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : (OrderDual.{u2} α) -> (OrderDual.{u1} β)) (a : WithBot.{u2} α), Eq.{succ u1} (WithTop.{u1} (OrderDual.{u1} β)) (WithTop.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} α) (WithTop.{u2} (OrderDual.{u2} α))) (WithBot.{u2} α) (fun (_x : WithBot.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} α) => WithTop.{u2} (OrderDual.{u2} α)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} α) (WithTop.{u2} (OrderDual.{u2} α))) (WithBot.toDual.{u2} α) a)) (WithBot.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} (OrderDual.{u1} β)) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} α) (OrderDual.{u1} β) (OrderDual.{u1} (OrderDual.{u1} β)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} β) (OrderDual.{u1} (OrderDual.{u1} β))) (OrderDual.{u1} β) (fun (_x : OrderDual.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} β) => OrderDual.{u1} (OrderDual.{u1} β)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} β) (OrderDual.{u1} (OrderDual.{u1} β))) (OrderDual.toDual.{u1} (OrderDual.{u1} β))) f) a)\nCase conversion may be inaccurate. Consider using '#align with_top.map_to_dual WithTop.map_toDualₓ'. -/\ntheorem map_toDual (f : αᵒᵈ → βᵒᵈ) (a : WithBot α) :\n    map f (WithBot.toDual a) = a.map (toDual ∘ f) :=\n  rfl\n#align with_top.map_to_dual WithTop.map_toDual\n\n/- warning: with_top.map_of_dual -> WithTop.map_ofDual is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (a : WithBot.{u1} (OrderDual.{u1} α)), Eq.{succ u2} (WithTop.{u2} β) (WithTop.map.{u1, u2} α β f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a)) (WithBot.map.{u1, u2} (OrderDual.{u1} α) β (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} α) (OrderDual.{u2} β) β (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) => (OrderDual.{u2} β) -> β) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} β) β) (OrderDual.ofDual.{u2} β)) f) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (a : WithBot.{u2} (OrderDual.{u2} α)), Eq.{succ u1} (WithTop.{u1} β) (WithTop.map.{u2, u1} α β f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} α)) (WithTop.{u2} α)) (WithBot.{u2} (OrderDual.{u2} α)) (fun (_x : WithBot.{u2} (OrderDual.{u2} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} (OrderDual.{u2} α)) => WithTop.{u2} α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} α)) (WithTop.{u2} α)) (WithBot.ofDual.{u2} α) a)) (WithBot.map.{u2, u1} α β (Function.comp.{succ u2, succ u1, succ u1} α (OrderDual.{u1} β) β (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.{u1} β) (fun (_x : OrderDual.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} β) => β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.ofDual.{u1} β)) f) a)\nCase conversion may be inaccurate. Consider using '#align with_top.map_of_dual WithTop.map_ofDualₓ'. -/\ntheorem map_ofDual (f : α → β) (a : WithBot αᵒᵈ) : map f (WithBot.ofDual a) = a.map (ofDual ∘ f) :=\n  rfl\n#align with_top.map_of_dual WithTop.map_ofDual\n\n/- warning: with_top.to_dual_map -> WithTop.toDual_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (a : WithTop.{u1} α), Eq.{succ u2} (WithBot.{u2} (OrderDual.{u2} β)) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} β) (WithBot.{u2} (OrderDual.{u2} β))) (fun (_x : Equiv.{succ u2, succ u2} (WithTop.{u2} β) (WithBot.{u2} (OrderDual.{u2} β))) => (WithTop.{u2} β) -> (WithBot.{u2} (OrderDual.{u2} β))) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithTop.{u2} β) (WithBot.{u2} (OrderDual.{u2} β))) (WithTop.toDual.{u2} β) (WithTop.map.{u1, u2} α β f a)) (WithBot.map.{u1, u2} (OrderDual.{u1} α) (OrderDual.{u2} β) (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} α) β (OrderDual.{u2} β) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) (fun (_x : Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) => β -> (OrderDual.{u2} β)) (Equiv.hasCoeToFun.{succ u2, succ u2} β (OrderDual.{u2} β)) (OrderDual.toDual.{u2} β)) (Function.comp.{succ u1, succ u1, succ u2} (OrderDual.{u1} α) α β f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} α) α) (fun (_x : Equiv.{succ u1, succ u1} (OrderDual.{u1} α) α) => (OrderDual.{u1} α) -> α) (Equiv.hasCoeToFun.{succ u1, succ u1} (OrderDual.{u1} α) α) (OrderDual.ofDual.{u1} α)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (a : WithTop.{u2} α), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} β) => WithBot.{u1} (OrderDual.{u1} β)) (WithTop.map.{u2, u1} α β f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} β) (WithBot.{u1} (OrderDual.{u1} β))) (WithTop.{u1} β) (fun (_x : WithTop.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} β) => WithBot.{u1} (OrderDual.{u1} β)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} β) (WithBot.{u1} (OrderDual.{u1} β))) (WithTop.toDual.{u1} β) (WithTop.map.{u2, u1} α β f a)) (WithBot.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} α) β (OrderDual.{u1} β) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} β (OrderDual.{u1} β)) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => OrderDual.{u1} β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} β (OrderDual.{u1} β)) (OrderDual.toDual.{u1} β)) (Function.comp.{succ u2, succ u2, succ u1} (OrderDual.{u2} α) α β f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} α) α) (OrderDual.{u2} α) (fun (_x : OrderDual.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u2} α) => α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (OrderDual.{u2} α) α) (OrderDual.ofDual.{u2} α)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} α) (WithBot.{u2} (OrderDual.{u2} α))) (WithTop.{u2} α) (fun (_x : WithTop.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} α) => WithBot.{u2} (OrderDual.{u2} α)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} α) (WithBot.{u2} (OrderDual.{u2} α))) (WithTop.toDual.{u2} α) a))\nCase conversion may be inaccurate. Consider using '#align with_top.to_dual_map WithTop.toDual_mapₓ'. -/\ntheorem toDual_map (f : α → β) (a : WithTop α) :\n    WithTop.toDual (map f a) = WithBot.map (toDual ∘ f ∘ ofDual) a.toDual :=\n  rfl\n#align with_top.to_dual_map WithTop.toDual_map\n\n/- warning: with_top.of_dual_map -> WithTop.ofDual_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : (OrderDual.{u1} α) -> (OrderDual.{u2} β)) (a : WithTop.{u1} (OrderDual.{u1} α)), Eq.{succ u2} (WithBot.{u2} β) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} β)) (WithBot.{u2} β)) (fun (_x : Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} β)) (WithBot.{u2} β)) => (WithTop.{u2} (OrderDual.{u2} β)) -> (WithBot.{u2} β)) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} β)) (WithBot.{u2} β)) (WithTop.ofDual.{u2} β) (WithTop.map.{u1, u2} (OrderDual.{u1} α) (OrderDual.{u2} β) f a)) (WithBot.map.{u1, u2} α β (Function.comp.{succ u1, succ u2, succ u2} α (OrderDual.{u2} β) β (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) => (OrderDual.{u2} β) -> β) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} β) β) (OrderDual.ofDual.{u2} β)) (Function.comp.{succ u1, succ u1, succ u2} α (OrderDual.{u1} α) (OrderDual.{u2} β) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} α (OrderDual.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} α (OrderDual.{u1} α)) => α -> (OrderDual.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} α (OrderDual.{u1} α)) (OrderDual.toDual.{u1} α)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : (OrderDual.{u2} α) -> (OrderDual.{u1} β)) (a : WithTop.{u2} (OrderDual.{u2} α)), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} β)) => WithBot.{u1} β) (WithTop.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} β)) (WithBot.{u1} β)) (WithTop.{u1} (OrderDual.{u1} β)) (fun (_x : WithTop.{u1} (OrderDual.{u1} β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} β)) => WithBot.{u1} β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} β)) (WithBot.{u1} β)) (WithTop.ofDual.{u1} β) (WithTop.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) f a)) (WithBot.map.{u2, u1} α β (Function.comp.{succ u2, succ u1, succ u1} α (OrderDual.{u1} β) β (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.{u1} β) (fun (_x : OrderDual.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} β) => β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.ofDual.{u1} β)) (Function.comp.{succ u2, succ u2, succ u1} α (OrderDual.{u2} α) (OrderDual.{u1} β) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} α (OrderDual.{u2} α)) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => OrderDual.{u2} α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} α (OrderDual.{u2} α)) (OrderDual.toDual.{u2} α)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} α)) (WithBot.{u2} α)) (WithTop.{u2} (OrderDual.{u2} α)) (fun (_x : WithTop.{u2} (OrderDual.{u2} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} (OrderDual.{u2} α)) => WithBot.{u2} α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} α)) (WithBot.{u2} α)) (WithTop.ofDual.{u2} α) a))\nCase conversion may be inaccurate. Consider using '#align with_top.of_dual_map WithTop.ofDual_mapₓ'. -/\ntheorem ofDual_map (f : αᵒᵈ → βᵒᵈ) (a : WithTop αᵒᵈ) :\n    WithTop.ofDual (map f a) = WithBot.map (ofDual ∘ f ∘ toDual) a.ofDual :=\n  rfl\n#align with_top.of_dual_map WithTop.ofDual_map\n\n#print WithTop.ne_top_iff_exists /-\ntheorem ne_top_iff_exists {x : WithTop α} : x ≠ ⊤ ↔ ∃ a : α, ↑a = x :=\n  Option.ne_none_iff_exists\n#align with_top.ne_top_iff_exists WithTop.ne_top_iff_exists\n-/\n\n#print WithTop.untop /-\n/-- Deconstruct a `x : with_top α` to the underlying value in `α`, given a proof that `x ≠ ⊤`. -/\ndef untop : ∀ x : WithTop α, x ≠ ⊤ → α :=\n  WithBot.unbot\n#align with_top.untop WithTop.untop\n-/\n\n#print WithTop.coe_untop /-\n@[simp]\ntheorem coe_untop (x : WithTop α) (h : x ≠ ⊤) : (x.untop h : WithTop α) = x :=\n  WithBot.coe_unbot x h\n#align with_top.coe_untop WithTop.coe_untop\n-/\n\n#print WithTop.untop_coe /-\n@[simp]\ntheorem untop_coe (x : α) (h : (x : WithTop α) ≠ ⊤ := coe_ne_top) : (x : WithTop α).untop h = x :=\n  rfl\n#align with_top.untop_coe WithTop.untop_coe\n-/\n\n#print WithTop.canLift /-\ninstance canLift : CanLift (WithTop α) α coe fun r => r ≠ ⊤\n    where prf x h := ⟨x.untop h, coe_untop _ _⟩\n#align with_top.can_lift WithTop.canLift\n-/\n\nsection LE\n\nvariable [LE α]\n\ninstance (priority := 10) : LE (WithTop α) :=\n  ⟨fun o₁ o₂ : Option α => ∀ a ∈ o₂, ∃ b ∈ o₁, b ≤ a⟩\n\n#print WithTop.toDual_le_iff /-\ntheorem toDual_le_iff {a : WithTop α} {b : WithBot αᵒᵈ} :\n    WithTop.toDual a ≤ b ↔ WithBot.ofDual b ≤ a :=\n  Iff.rfl\n#align with_top.to_dual_le_iff WithTop.toDual_le_iff\n-/\n\n/- warning: with_top.le_to_dual_iff -> WithTop.le_toDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LE.le.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLe.{u1} (OrderDual.{u1} α) (OrderDual.hasLe.{u1} α _inst_1)) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b)) (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LE.le.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.le.{u1} (OrderDual.{u1} α) (OrderDual.instLEOrderDual.{u1} α _inst_1)) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b)) (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a))\nCase conversion may be inaccurate. Consider using '#align with_top.le_to_dual_iff WithTop.le_toDual_iffₓ'. -/\ntheorem le_toDual_iff {a : WithBot αᵒᵈ} {b : WithTop α} :\n    a ≤ WithTop.toDual b ↔ b ≤ WithBot.ofDual a :=\n  Iff.rfl\n#align with_top.le_to_dual_iff WithTop.le_toDual_iff\n\n#print WithTop.toDual_le_toDual_iff /-\n@[simp]\ntheorem toDual_le_toDual_iff {a b : WithTop α} : WithTop.toDual a ≤ WithTop.toDual b ↔ b ≤ a :=\n  Iff.rfl\n#align with_top.to_dual_le_to_dual_iff WithTop.toDual_le_toDual_iff\n-/\n\n#print WithTop.ofDual_le_iff /-\ntheorem ofDual_le_iff {a : WithTop αᵒᵈ} {b : WithBot α} :\n    WithTop.ofDual a ≤ b ↔ WithBot.toDual b ≤ a :=\n  Iff.rfl\n#align with_top.of_dual_le_iff WithTop.ofDual_le_iff\n-/\n\n/- warning: with_top.le_of_dual_iff -> WithTop.le_ofDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b)) (LE.le.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLe.{u1} (OrderDual.{u1} α) (OrderDual.hasLe.{u1} α _inst_1)) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_1) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b)) (LE.le.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.le.{u1} (OrderDual.{u1} α) (OrderDual.instLEOrderDual.{u1} α _inst_1)) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a))\nCase conversion may be inaccurate. Consider using '#align with_top.le_of_dual_iff WithTop.le_ofDual_iffₓ'. -/\ntheorem le_ofDual_iff {a : WithBot α} {b : WithTop αᵒᵈ} :\n    a ≤ WithTop.ofDual b ↔ b ≤ WithBot.toDual a :=\n  Iff.rfl\n#align with_top.le_of_dual_iff WithTop.le_ofDual_iff\n\n#print WithTop.ofDual_le_ofDual_iff /-\n@[simp]\ntheorem ofDual_le_ofDual_iff {a b : WithTop αᵒᵈ} : WithTop.ofDual a ≤ WithTop.ofDual b ↔ b ≤ a :=\n  Iff.rfl\n#align with_top.of_dual_le_of_dual_iff WithTop.ofDual_le_ofDual_iff\n-/\n\n/- warning: with_top.coe_le_coe -> WithTop.coe_le_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b)) (LE.le.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) (WithTop.some.{u1} α a) (WithTop.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.coe_le_coe WithTop.coe_le_coeₓ'. -/\n@[simp, norm_cast]\ntheorem coe_le_coe : (a : WithTop α) ≤ b ↔ a ≤ b := by\n  simp only [← to_dual_le_to_dual_iff, to_dual_apply_coe, WithBot.coe_le_coe, to_dual_le_to_dual]\n#align with_top.coe_le_coe WithTop.coe_le_coe\n\n/- warning: with_top.some_le_some -> WithTop.some_le_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α], Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.some_le_some WithTop.some_le_someₓ'. -/\n@[simp]\ntheorem some_le_some : @LE.le (WithTop α) _ (some a) (some b) ↔ a ≤ b :=\n  coe_le_coe\n#align with_top.some_le_some WithTop.some_le_some\n\n/- warning: with_top.le_none -> WithTop.le_none is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithTop.{u1} α}, LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) a (Option.none.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithTop.{u1} α}, LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) a (Option.none.{u1} α)\nCase conversion may be inaccurate. Consider using '#align with_top.le_none WithTop.le_noneₓ'. -/\n@[simp]\ntheorem le_none {a : WithTop α} : @LE.le (WithTop α) _ a none :=\n  toDual_le_toDual_iff.mp WithBot.none_le\n#align with_top.le_none WithTop.le_none\n\ninstance : OrderTop (WithTop α) :=\n  { WithTop.hasTop with le_top := fun a => le_none }\n\ninstance [OrderBot α] : OrderBot (WithTop α)\n    where\n  bot := some ⊥\n  bot_le o a ha := by cases ha <;> exact ⟨_, rfl, bot_le⟩\n\ninstance [OrderBot α] : BoundedOrder (WithTop α) :=\n  { WithTop.orderTop, WithTop.orderBot with }\n\n/- warning: with_top.not_top_le_coe -> WithTop.not_top_le_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] (a : α), Not (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] (a : α), Not (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)) (WithTop.some.{u1} α a))\nCase conversion may be inaccurate. Consider using '#align with_top.not_top_le_coe WithTop.not_top_le_coeₓ'. -/\ntheorem not_top_le_coe (a : α) : ¬(⊤ : WithTop α) ≤ ↑a :=\n  WithBot.not_coe_le_bot (toDual a)\n#align with_top.not_top_le_coe WithTop.not_top_le_coe\n\n/- warning: with_top.le_coe -> WithTop.le_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α] {o : Option.{u1} α}, (Membership.Mem.{u1, u1} α (Option.{u1} α) (Option.hasMem.{u1} α) a o) -> (Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) o ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b)) (LE.le.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {b : α} [_inst_1 : LE.{u1} α] {o : Option.{u1} α}, (Membership.mem.{u1, u1} α (Option.{u1} α) (Option.instMembershipOption.{u1} α) a o) -> (Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) o (WithTop.some.{u1} α b)) (LE.le.{u1} α _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_top.le_coe WithTop.le_coeₓ'. -/\ntheorem le_coe : ∀ {o : Option α}, a ∈ o → (@LE.le (WithTop α) _ o b ↔ a ≤ b)\n  | _, rfl => coe_le_coe\n#align with_top.le_coe WithTop.le_coe\n\n/- warning: with_top.le_coe_iff -> WithTop.le_coe_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {b : α} [_inst_1 : LE.{u1} α] {x : WithTop.{u1} α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b)) (Exists.{succ u1} α (fun (a : α) => And (Eq.{succ u1} (WithTop.{u1} α) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a)) (LE.le.{u1} α _inst_1 a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} {b : α} [_inst_1 : LE.{u1} α] {x : WithTop.{u1} α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) x (WithTop.some.{u1} α b)) (Exists.{succ u1} α (fun (a : α) => And (Eq.{succ u1} (WithTop.{u1} α) x (WithTop.some.{u1} α a)) (LE.le.{u1} α _inst_1 a b)))\nCase conversion may be inaccurate. Consider using '#align with_top.le_coe_iff WithTop.le_coe_iffₓ'. -/\ntheorem le_coe_iff {x : WithTop α} : x ≤ b ↔ ∃ a : α, x = a ∧ a ≤ b := by\n  simpa [← to_dual_le_to_dual_iff, WithBot.coe_le_iff]\n#align with_top.le_coe_iff WithTop.le_coe_iff\n\n/- warning: with_top.coe_le_iff -> WithTop.coe_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α] {x : WithTop.{u1} α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) x) (forall (b : α), (Eq.{succ u1} (WithTop.{u1} α) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b)) -> (LE.le.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α] {x : WithTop.{u1} α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) (WithTop.some.{u1} α a) x) (forall (b : α), (Eq.{succ u1} (WithTop.{u1} α) x (WithTop.some.{u1} α b)) -> (LE.le.{u1} α _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_le_iff WithTop.coe_le_iffₓ'. -/\ntheorem coe_le_iff {x : WithTop α} : ↑a ≤ x ↔ ∀ b, x = ↑b → a ≤ b :=\n  by\n  simp only [← to_dual_le_to_dual_iff, to_dual_apply_coe, WithBot.le_coe_iff, OrderDual.forall,\n    to_dual_le_to_dual]\n  exact forall₂_congr fun _ _ => Iff.rfl\n#align with_top.coe_le_iff WithTop.coe_le_iff\n\n/- warning: is_min.with_top -> IsMin.withTop is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α], (IsMin.{u1} α _inst_1 a) -> (IsMin.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} [_inst_1 : LE.{u1} α], (IsMin.{u1} α _inst_1 a) -> (IsMin.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) (WithTop.some.{u1} α a))\nCase conversion may be inaccurate. Consider using '#align is_min.with_top IsMin.withTopₓ'. -/\nprotected theorem IsMin.withTop (h : IsMin a) : IsMin (a : WithTop α) :=\n  by\n  -- defeq to is_max_to_dual_iff.mp (is_max.with_bot _), but that breaks API boundary\n  intro _ hb\n  rw [← to_dual_le_to_dual_iff] at hb\n  simpa [to_dual_le_iff] using (IsMax.withBot h : IsMax (to_dual a : WithBot αᵒᵈ)) hb\n#align is_min.with_top IsMin.withTop\n\nend LE\n\nsection LT\n\nvariable [LT α]\n\ninstance (priority := 10) : LT (WithTop α) :=\n  ⟨fun o₁ o₂ : Option α => ∃ b ∈ o₁, ∀ a ∈ o₂, b < a⟩\n\n/- warning: with_top.to_dual_lt_iff -> WithTop.toDual_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithBot.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a) b) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithBot.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) a) (WithBot.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) b) (WithTop.lt.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) b) a)\nCase conversion may be inaccurate. Consider using '#align with_top.to_dual_lt_iff WithTop.toDual_lt_iffₓ'. -/\ntheorem toDual_lt_iff {a : WithTop α} {b : WithBot αᵒᵈ} :\n    WithTop.toDual a < b ↔ WithBot.ofDual b < a :=\n  Iff.rfl\n#align with_top.to_dual_lt_iff WithTop.toDual_lt_iff\n\n/- warning: with_top.lt_to_dual_iff -> WithTop.lt_toDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_to_dual_iff WithTop.lt_toDual_iffₓ'. -/\ntheorem lt_toDual_iff {a : WithBot αᵒᵈ} {b : WithTop α} :\n    a < WithTop.toDual b ↔ b < WithBot.ofDual a :=\n  Iff.rfl\n#align with_top.lt_to_dual_iff WithTop.lt_toDual_iff\n\n/- warning: with_top.to_dual_lt_to_dual_iff -> WithTop.toDual_lt_toDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) a) (WithBot.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) b a)\nCase conversion may be inaccurate. Consider using '#align with_top.to_dual_lt_to_dual_iff WithTop.toDual_lt_toDual_iffₓ'. -/\n@[simp]\ntheorem toDual_lt_toDual_iff {a b : WithTop α} : WithTop.toDual a < WithTop.toDual b ↔ b < a :=\n  Iff.rfl\n#align with_top.to_dual_lt_to_dual_iff WithTop.toDual_lt_toDual_iff\n\n/- warning: with_top.of_dual_lt_iff -> WithTop.ofDual_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} (OrderDual.{u1} α)} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a) b) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} (OrderDual.{u1} α)} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) a) (WithBot.lt.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) b) (WithTop.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) b) a)\nCase conversion may be inaccurate. Consider using '#align with_top.of_dual_lt_iff WithTop.ofDual_lt_iffₓ'. -/\ntheorem ofDual_lt_iff {a : WithTop αᵒᵈ} {b : WithBot α} :\n    WithTop.ofDual a < b ↔ WithBot.toDual b < a :=\n  Iff.rfl\n#align with_top.of_dual_lt_iff WithTop.ofDual_lt_iff\n\n/- warning: with_top.lt_of_dual_iff -> WithTop.lt_ofDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_of_dual_iff WithTop.lt_ofDual_iffₓ'. -/\ntheorem lt_ofDual_iff {a : WithBot α} {b : WithTop αᵒᵈ} :\n    a < WithTop.ofDual b ↔ b < WithBot.toDual a :=\n  Iff.rfl\n#align with_top.lt_of_dual_iff WithTop.lt_ofDual_iff\n\n/- warning: with_top.of_dual_lt_of_dual_iff -> WithTop.ofDual_lt_ofDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) a) (WithBot.lt.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) b a)\nCase conversion may be inaccurate. Consider using '#align with_top.of_dual_lt_of_dual_iff WithTop.ofDual_lt_ofDual_iffₓ'. -/\n@[simp]\ntheorem ofDual_lt_ofDual_iff {a b : WithTop αᵒᵈ} : WithTop.ofDual a < WithTop.ofDual b ↔ b < a :=\n  Iff.rfl\n#align with_top.of_dual_lt_of_dual_iff WithTop.ofDual_lt_ofDual_iff\n\nend LT\n\nend WithTop\n\nnamespace WithBot\n\nopen OrderDual\n\n#print WithBot.toDual_symm_apply /-\n@[simp]\ntheorem toDual_symm_apply (a : WithTop αᵒᵈ) : WithBot.toDual.symm a = a.ofDual :=\n  rfl\n#align with_bot.to_dual_symm_apply WithBot.toDual_symm_apply\n-/\n\n#print WithBot.ofDual_symm_apply /-\n@[simp]\ntheorem ofDual_symm_apply (a : WithTop α) : WithBot.ofDual.symm a = a.toDual :=\n  rfl\n#align with_bot.of_dual_symm_apply WithBot.ofDual_symm_apply\n-/\n\n#print WithBot.toDual_apply_bot /-\n@[simp]\ntheorem toDual_apply_bot : WithBot.toDual (⊥ : WithBot α) = ⊤ :=\n  rfl\n#align with_bot.to_dual_apply_bot WithBot.toDual_apply_bot\n-/\n\n#print WithBot.ofDual_apply_bot /-\n@[simp]\ntheorem ofDual_apply_bot : WithBot.ofDual (⊥ : WithBot α) = ⊤ :=\n  rfl\n#align with_bot.of_dual_apply_bot WithBot.ofDual_apply_bot\n-/\n\n#print WithBot.toDual_apply_coe /-\n@[simp]\ntheorem toDual_apply_coe (a : α) : WithBot.toDual (a : WithBot α) = toDual a :=\n  rfl\n#align with_bot.to_dual_apply_coe WithBot.toDual_apply_coe\n-/\n\n#print WithBot.ofDual_apply_coe /-\n@[simp]\ntheorem ofDual_apply_coe (a : αᵒᵈ) : WithBot.ofDual (a : WithBot αᵒᵈ) = ofDual a :=\n  rfl\n#align with_bot.of_dual_apply_coe WithBot.ofDual_apply_coe\n-/\n\n/- warning: with_bot.map_to_dual -> WithBot.map_toDual is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : (OrderDual.{u1} α) -> (OrderDual.{u2} β)) (a : WithTop.{u1} α), Eq.{succ u2} (WithBot.{u2} (OrderDual.{u2} β)) (WithBot.map.{u1, u2} (OrderDual.{u1} α) (OrderDual.{u2} β) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a)) (WithTop.map.{u1, u2} α (OrderDual.{u2} β) (Function.comp.{succ u1, succ u2, succ u2} α β (OrderDual.{u2} β) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) (fun (_x : Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) => β -> (OrderDual.{u2} β)) (Equiv.hasCoeToFun.{succ u2, succ u2} β (OrderDual.{u2} β)) (OrderDual.toDual.{u2} β)) f) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : (OrderDual.{u2} α) -> (OrderDual.{u1} β)) (a : WithTop.{u2} α), Eq.{succ u1} (WithBot.{u1} (OrderDual.{u1} β)) (WithBot.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} α) (WithBot.{u2} (OrderDual.{u2} α))) (WithTop.{u2} α) (fun (_x : WithTop.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} α) => WithBot.{u2} (OrderDual.{u2} α)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} α) (WithBot.{u2} (OrderDual.{u2} α))) (WithTop.toDual.{u2} α) a)) (WithTop.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} (OrderDual.{u1} β)) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} α) (OrderDual.{u1} β) (OrderDual.{u1} (OrderDual.{u1} β)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} β) (OrderDual.{u1} (OrderDual.{u1} β))) (OrderDual.{u1} β) (fun (_x : OrderDual.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} β) => OrderDual.{u1} (OrderDual.{u1} β)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} β) (OrderDual.{u1} (OrderDual.{u1} β))) (OrderDual.toDual.{u1} (OrderDual.{u1} β))) f) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.map_to_dual WithBot.map_toDualₓ'. -/\ntheorem map_toDual (f : αᵒᵈ → βᵒᵈ) (a : WithTop α) :\n    WithBot.map f (WithTop.toDual a) = a.map (toDual ∘ f) :=\n  rfl\n#align with_bot.map_to_dual WithBot.map_toDual\n\n/- warning: with_bot.map_of_dual -> WithBot.map_ofDual is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (a : WithTop.{u1} (OrderDual.{u1} α)), Eq.{succ u2} (WithBot.{u2} β) (WithBot.map.{u1, u2} α β f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a)) (WithTop.map.{u1, u2} (OrderDual.{u1} α) β (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} α) (OrderDual.{u2} β) β (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) => (OrderDual.{u2} β) -> β) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} β) β) (OrderDual.ofDual.{u2} β)) f) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (a : WithTop.{u2} (OrderDual.{u2} α)), Eq.{succ u1} (WithBot.{u1} β) (WithBot.map.{u2, u1} α β f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} α)) (WithBot.{u2} α)) (WithTop.{u2} (OrderDual.{u2} α)) (fun (_x : WithTop.{u2} (OrderDual.{u2} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} (OrderDual.{u2} α)) => WithBot.{u2} α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} α)) (WithBot.{u2} α)) (WithTop.ofDual.{u2} α) a)) (WithTop.map.{u2, u1} α β (Function.comp.{succ u2, succ u1, succ u1} α (OrderDual.{u1} β) β (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.{u1} β) (fun (_x : OrderDual.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} β) => β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.ofDual.{u1} β)) f) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.map_of_dual WithBot.map_ofDualₓ'. -/\ntheorem map_ofDual (f : α → β) (a : WithTop αᵒᵈ) :\n    WithBot.map f (WithTop.ofDual a) = a.map (ofDual ∘ f) :=\n  rfl\n#align with_bot.map_of_dual WithBot.map_ofDual\n\n/- warning: with_bot.to_dual_map -> WithBot.toDual_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (a : WithBot.{u1} α), Eq.{succ u2} (WithTop.{u2} (OrderDual.{u2} β)) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} β) (WithTop.{u2} (OrderDual.{u2} β))) (fun (_x : Equiv.{succ u2, succ u2} (WithBot.{u2} β) (WithTop.{u2} (OrderDual.{u2} β))) => (WithBot.{u2} β) -> (WithTop.{u2} (OrderDual.{u2} β))) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithBot.{u2} β) (WithTop.{u2} (OrderDual.{u2} β))) (WithBot.toDual.{u2} β) (WithBot.map.{u1, u2} α β f a)) (WithBot.map.{u1, u2} (OrderDual.{u1} α) (OrderDual.{u2} β) (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} α) β (OrderDual.{u2} β) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) (fun (_x : Equiv.{succ u2, succ u2} β (OrderDual.{u2} β)) => β -> (OrderDual.{u2} β)) (Equiv.hasCoeToFun.{succ u2, succ u2} β (OrderDual.{u2} β)) (OrderDual.toDual.{u2} β)) (Function.comp.{succ u1, succ u1, succ u2} (OrderDual.{u1} α) α β f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} α) α) (fun (_x : Equiv.{succ u1, succ u1} (OrderDual.{u1} α) α) => (OrderDual.{u1} α) -> α) (Equiv.hasCoeToFun.{succ u1, succ u1} (OrderDual.{u1} α) α) (OrderDual.ofDual.{u1} α)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (a : WithBot.{u2} α), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} β) => WithTop.{u1} (OrderDual.{u1} β)) (WithBot.map.{u2, u1} α β f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} β) (WithTop.{u1} (OrderDual.{u1} β))) (WithBot.{u1} β) (fun (_x : WithBot.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} β) => WithTop.{u1} (OrderDual.{u1} β)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} β) (WithTop.{u1} (OrderDual.{u1} β))) (WithBot.toDual.{u1} β) (WithBot.map.{u2, u1} α β f a)) (WithBot.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} α) β (OrderDual.{u1} β) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} β (OrderDual.{u1} β)) β (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => OrderDual.{u1} β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} β (OrderDual.{u1} β)) (OrderDual.toDual.{u1} β)) (Function.comp.{succ u2, succ u2, succ u1} (OrderDual.{u2} α) α β f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} α) α) (OrderDual.{u2} α) (fun (_x : OrderDual.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u2} α) => α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (OrderDual.{u2} α) α) (OrderDual.ofDual.{u2} α)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} α) (WithTop.{u2} (OrderDual.{u2} α))) (WithBot.{u2} α) (fun (_x : WithBot.{u2} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} α) => WithTop.{u2} (OrderDual.{u2} α)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} α) (WithTop.{u2} (OrderDual.{u2} α))) (WithBot.toDual.{u2} α) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.to_dual_map WithBot.toDual_mapₓ'. -/\ntheorem toDual_map (f : α → β) (a : WithBot α) :\n    WithBot.toDual (WithBot.map f a) = map (toDual ∘ f ∘ ofDual) a.toDual :=\n  rfl\n#align with_bot.to_dual_map WithBot.toDual_map\n\n/- warning: with_bot.of_dual_map -> WithBot.ofDual_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : (OrderDual.{u1} α) -> (OrderDual.{u2} β)) (a : WithBot.{u1} (OrderDual.{u1} α)), Eq.{succ u2} (WithTop.{u2} β) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} β)) (WithTop.{u2} β)) (fun (_x : Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} β)) (WithTop.{u2} β)) => (WithBot.{u2} (OrderDual.{u2} β)) -> (WithTop.{u2} β)) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} β)) (WithTop.{u2} β)) (WithBot.ofDual.{u2} β) (WithBot.map.{u1, u2} (OrderDual.{u1} α) (OrderDual.{u2} β) f a)) (WithBot.map.{u1, u2} α β (Function.comp.{succ u1, succ u2, succ u2} α (OrderDual.{u2} β) β (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} β) β) => (OrderDual.{u2} β) -> β) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} β) β) (OrderDual.ofDual.{u2} β)) (Function.comp.{succ u1, succ u1, succ u2} α (OrderDual.{u1} α) (OrderDual.{u2} β) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} α (OrderDual.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} α (OrderDual.{u1} α)) => α -> (OrderDual.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} α (OrderDual.{u1} α)) (OrderDual.toDual.{u1} α)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : (OrderDual.{u2} α) -> (OrderDual.{u1} β)) (a : WithBot.{u2} (OrderDual.{u2} α)), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} β)) => WithTop.{u1} β) (WithBot.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} β)) (WithTop.{u1} β)) (WithBot.{u1} (OrderDual.{u1} β)) (fun (_x : WithBot.{u1} (OrderDual.{u1} β)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} β)) => WithTop.{u1} β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} β)) (WithTop.{u1} β)) (WithBot.ofDual.{u1} β) (WithBot.map.{u2, u1} (OrderDual.{u2} α) (OrderDual.{u1} β) f a)) (WithBot.map.{u2, u1} α β (Function.comp.{succ u2, succ u1, succ u1} α (OrderDual.{u1} β) β (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.{u1} β) (fun (_x : OrderDual.{u1} β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} β) => β) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} β) β) (OrderDual.ofDual.{u1} β)) (Function.comp.{succ u2, succ u2, succ u1} α (OrderDual.{u2} α) (OrderDual.{u1} β) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} α (OrderDual.{u2} α)) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => OrderDual.{u2} α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} α (OrderDual.{u2} α)) (OrderDual.toDual.{u2} α)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} α)) (WithTop.{u2} α)) (WithBot.{u2} (OrderDual.{u2} α)) (fun (_x : WithBot.{u2} (OrderDual.{u2} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} (OrderDual.{u2} α)) => WithTop.{u2} α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} α)) (WithTop.{u2} α)) (WithBot.ofDual.{u2} α) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.of_dual_map WithBot.ofDual_mapₓ'. -/\ntheorem ofDual_map (f : αᵒᵈ → βᵒᵈ) (a : WithBot αᵒᵈ) :\n    WithBot.ofDual (WithBot.map f a) = map (ofDual ∘ f ∘ toDual) a.ofDual :=\n  rfl\n#align with_bot.of_dual_map WithBot.ofDual_map\n\nsection LE\n\nvariable [LE α] {a b : α}\n\n/- warning: with_bot.to_dual_le_iff -> WithBot.toDual_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LE.le.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLe.{u1} (OrderDual.{u1} α) (OrderDual.hasLe.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a) b) (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) a) (WithTop.le.{u1} (OrderDual.{u1} α) (OrderDual.instLEOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a) b) (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) b) (WithBot.le.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.to_dual_le_iff WithBot.toDual_le_iffₓ'. -/\ntheorem toDual_le_iff {a : WithBot α} {b : WithTop αᵒᵈ} :\n    WithBot.toDual a ≤ b ↔ WithTop.ofDual b ≤ a :=\n  Iff.rfl\n#align with_bot.to_dual_le_iff WithBot.toDual_le_iff\n\n#print WithBot.le_toDual_iff /-\ntheorem le_toDual_iff {a : WithTop αᵒᵈ} {b : WithBot α} :\n    a ≤ WithBot.toDual b ↔ b ≤ WithTop.ofDual a :=\n  Iff.rfl\n#align with_bot.le_to_dual_iff WithBot.le_toDual_iff\n-/\n\n#print WithBot.toDual_le_toDual_iff /-\n@[simp]\ntheorem toDual_le_toDual_iff {a b : WithBot α} : WithBot.toDual a ≤ WithBot.toDual b ↔ b ≤ a :=\n  Iff.rfl\n#align with_bot.to_dual_le_to_dual_iff WithBot.toDual_le_toDual_iff\n-/\n\n/- warning: with_bot.of_dual_le_iff -> WithBot.ofDual_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a) b) (LE.le.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLe.{u1} (OrderDual.{u1} α) (OrderDual.hasLe.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) a) (WithTop.le.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a) b) (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) b) (WithBot.le.{u1} (OrderDual.{u1} α) (OrderDual.instLEOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.of_dual_le_iff WithBot.ofDual_le_iffₓ'. -/\ntheorem ofDual_le_iff {a : WithBot αᵒᵈ} {b : WithTop α} :\n    WithBot.ofDual a ≤ b ↔ WithTop.toDual b ≤ a :=\n  Iff.rfl\n#align with_bot.of_dual_le_iff WithBot.ofDual_le_iff\n\n#print WithBot.le_ofDual_iff /-\ntheorem le_ofDual_iff {a : WithTop α} {b : WithBot αᵒᵈ} :\n    a ≤ WithBot.ofDual b ↔ b ≤ WithTop.toDual a :=\n  Iff.rfl\n#align with_bot.le_of_dual_iff WithBot.le_ofDual_iff\n-/\n\n#print WithBot.ofDual_le_ofDual_iff /-\n@[simp]\ntheorem ofDual_le_ofDual_iff {a b : WithBot αᵒᵈ} : WithBot.ofDual a ≤ WithBot.ofDual b ↔ b ≤ a :=\n  Iff.rfl\n#align with_bot.of_dual_le_of_dual_iff WithBot.ofDual_le_ofDual_iff\n-/\n\nend LE\n\nsection LT\n\nvariable [LT α] {a b : α}\n\n/- warning: with_bot.to_dual_lt_iff -> WithBot.toDual_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a) b) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithTop.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) a) (WithTop.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) b) (WithBot.lt.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.to_dual_lt_iff WithBot.toDual_lt_iffₓ'. -/\ntheorem toDual_lt_iff {a : WithBot α} {b : WithTop αᵒᵈ} :\n    WithBot.toDual a < b ↔ WithTop.ofDual b < a :=\n  Iff.rfl\n#align with_bot.to_dual_lt_iff WithBot.toDual_lt_iff\n\n/- warning: with_bot.lt_to_dual_iff -> WithBot.lt_toDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} (OrderDual.{u1} α)} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) => (WithTop.{u1} (OrderDual.{u1} α)) -> (WithBot.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} (OrderDual.{u1} α)} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.{u1} (OrderDual.{u1} α)) (fun (_x : WithTop.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} α)) => WithBot.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithBot.{u1} α)) (WithTop.ofDual.{u1} α) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_to_dual_iff WithBot.lt_toDual_iffₓ'. -/\ntheorem lt_toDual_iff {a : WithTop αᵒᵈ} {b : WithBot α} :\n    a < WithBot.toDual b ↔ b < WithTop.ofDual a :=\n  Iff.rfl\n#align with_bot.lt_to_dual_iff WithBot.lt_toDual_iff\n\n/- warning: with_bot.to_dual_lt_to_dual_iff -> WithBot.toDual_lt_toDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} α)) (WithTop.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) => (WithBot.{u1} α) -> (WithTop.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_1) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) a) (WithTop.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.{u1} α) (fun (_x : WithBot.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} α) => WithTop.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} α) (WithTop.{u1} (OrderDual.{u1} α))) (WithBot.toDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_1) b a)\nCase conversion may be inaccurate. Consider using '#align with_bot.to_dual_lt_to_dual_iff WithBot.toDual_lt_toDual_iffₓ'. -/\n@[simp]\ntheorem toDual_lt_toDual_iff {a b : WithBot α} : WithBot.toDual a < WithBot.toDual b ↔ b < a :=\n  Iff.rfl\n#align with_bot.to_dual_lt_to_dual_iff WithBot.toDual_lt_toDual_iff\n\n/- warning: with_bot.of_dual_lt_iff -> WithBot.ofDual_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a) b) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) a) (WithTop.lt.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) b) (WithBot.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.of_dual_lt_iff WithBot.ofDual_lt_iffₓ'. -/\ntheorem ofDual_lt_iff {a : WithBot αᵒᵈ} {b : WithTop α} :\n    WithBot.ofDual a < b ↔ WithTop.toDual b < a :=\n  Iff.rfl\n#align with_bot.of_dual_lt_iff WithBot.ofDual_lt_iff\n\n/- warning: with_bot.lt_of_dual_iff -> WithBot.lt_ofDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithBot.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) => (WithTop.{u1} α) -> (WithBot.{u1} (OrderDual.{u1} α))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithBot.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.{u1} α) (fun (_x : WithTop.{u1} α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} α) => WithBot.{u1} (OrderDual.{u1} α)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} α) (WithBot.{u1} (OrderDual.{u1} α))) (WithTop.toDual.{u1} α) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_of_dual_iff WithBot.lt_ofDual_iffₓ'. -/\ntheorem lt_ofDual_iff {a : WithTop α} {b : WithBot αᵒᵈ} :\n    a < WithBot.ofDual b ↔ b < WithTop.toDual a :=\n  Iff.rfl\n#align with_bot.lt_of_dual_iff WithBot.lt_ofDual_iff\n\n/- warning: with_bot.of_dual_lt_of_dual_iff -> WithBot.ofDual_lt_ofDual_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithBot.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) => (WithBot.{u1} (OrderDual.{u1} α)) -> (WithTop.{u1} α)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.hasLt.{u1} (OrderDual.{u1} α) (OrderDual.hasLt.{u1} α _inst_1)) b a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithBot.{u1} (OrderDual.{u1} α)} {b : WithBot.{u1} (OrderDual.{u1} α)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) a) (WithTop.lt.{u1} α _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.{u1} (OrderDual.{u1} α)) (fun (_x : WithBot.{u1} (OrderDual.{u1} α)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} α)) => WithTop.{u1} α) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithTop.{u1} α)) (WithBot.ofDual.{u1} α) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} α)) (WithBot.lt.{u1} (OrderDual.{u1} α) (OrderDual.instLTOrderDual.{u1} α _inst_1)) b a)\nCase conversion may be inaccurate. Consider using '#align with_bot.of_dual_lt_of_dual_iff WithBot.ofDual_lt_ofDual_iffₓ'. -/\n@[simp]\ntheorem ofDual_lt_ofDual_iff {a b : WithBot αᵒᵈ} : WithBot.ofDual a < WithBot.ofDual b ↔ b < a :=\n  Iff.rfl\n#align with_bot.of_dual_lt_of_dual_iff WithBot.ofDual_lt_ofDual_iff\n\nend LT\n\nend WithBot\n\nnamespace WithTop\n\nsection LT\n\nvariable [LT α] {a b : α}\n\nopen OrderDual\n\n/- warning: with_top.coe_lt_coe -> WithTop.coe_lt_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b)) (LT.lt.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (WithTop.some.{u1} α a) (WithTop.some.{u1} α b)) (LT.lt.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_coe WithTop.coe_lt_coeₓ'. -/\n@[simp, norm_cast]\ntheorem coe_lt_coe : (a : WithTop α) < b ↔ a < b := by\n  simp only [← to_dual_lt_to_dual_iff, to_dual_apply_coe, WithBot.coe_lt_coe, to_dual_lt_to_dual]\n#align with_top.coe_lt_coe WithTop.coe_lt_coe\n\n/- warning: with_top.some_lt_some -> WithTop.some_lt_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LT.lt.{u1} α _inst_1 a b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : α} {b : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (Option.some.{u1} α a) (Option.some.{u1} α b)) (LT.lt.{u1} α _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.some_lt_some WithTop.some_lt_someₓ'. -/\n@[simp]\ntheorem some_lt_some : @LT.lt (WithTop α) _ (some a) (some b) ↔ a < b :=\n  coe_lt_coe\n#align with_top.some_lt_some WithTop.some_lt_some\n\n/- warning: with_top.coe_lt_top -> WithTop.coe_lt_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (WithTop.some.{u1} α a) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_top WithTop.coe_lt_topₓ'. -/\ntheorem coe_lt_top (a : α) : (a : WithTop α) < ⊤ := by\n  simpa [← to_dual_lt_to_dual_iff] using WithBot.bot_lt_coe _\n#align with_top.coe_lt_top WithTop.coe_lt_top\n\n/- warning: with_top.some_lt_none -> WithTop.some_lt_none is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) (Option.some.{u1} α a) (Option.none.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : α), LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (Option.some.{u1} α a) (Option.none.{u1} α)\nCase conversion may be inaccurate. Consider using '#align with_top.some_lt_none WithTop.some_lt_noneₓ'. -/\n@[simp]\ntheorem some_lt_none (a : α) : @LT.lt (WithTop α) _ (some a) none :=\n  coe_lt_top a\n#align with_top.some_lt_none WithTop.some_lt_none\n\n/- warning: with_top.not_none_lt -> WithTop.not_none_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : WithTop.{u1} α), Not (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) (Option.none.{u1} α) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] (a : WithTop.{u1} α), Not (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (Option.none.{u1} α) a)\nCase conversion may be inaccurate. Consider using '#align with_top.not_none_lt WithTop.not_none_ltₓ'. -/\n@[simp]\ntheorem not_none_lt (a : WithTop α) : ¬@LT.lt (WithTop α) _ none a :=\n  by\n  rw [← to_dual_lt_to_dual_iff]\n  exact WithBot.not_lt_none _\n#align with_top.not_none_lt WithTop.not_none_lt\n\n/- warning: with_top.lt_iff_exists_coe -> WithTop.lt_iff_exists_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) a b) (Exists.{succ u1} α (fun (p : α) => And (Eq.{succ u1} (WithTop.{u1} α) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) p)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) p) b)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) a b) (Exists.{succ u1} α (fun (p : α) => And (Eq.{succ u1} (WithTop.{u1} α) a (WithTop.some.{u1} α p)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (WithTop.some.{u1} α p) b)))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_iff_exists_coe WithTop.lt_iff_exists_coeₓ'. -/\ntheorem lt_iff_exists_coe {a b : WithTop α} : a < b ↔ ∃ p : α, a = p ∧ ↑p < b :=\n  by\n  rw [← to_dual_lt_to_dual_iff, WithBot.lt_iff_exists_coe, OrderDual.exists]\n  exact exists_congr fun _ => and_congr_left' Iff.rfl\n#align with_top.lt_iff_exists_coe WithTop.lt_iff_exists_coe\n\n/- warning: with_top.coe_lt_iff -> WithTop.coe_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : α} {x : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) x) (forall (b : α), (Eq.{succ u1} (WithTop.{u1} α) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b)) -> (LT.lt.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {a : α} {x : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (WithTop.some.{u1} α a) x) (forall (b : WithTop.{u1} α), (Eq.{succ u1} (WithTop.{u1} α) x b) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) (WithTop.some.{u1} α a) b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_iff WithTop.coe_lt_iffₓ'. -/\ntheorem coe_lt_iff {x : WithTop α} : ↑a < x ↔ ∀ b, x = ↑b → a < b :=\n  by\n  simp only [← to_dual_lt_to_dual_iff, WithBot.lt_coe_iff, to_dual_apply_coe, OrderDual.forall,\n    to_dual_lt_to_dual]\n  exact forall₂_congr fun _ _ => Iff.rfl\n#align with_top.coe_lt_iff WithTop.coe_lt_iff\n\n/- warning: with_top.lt_top_iff_ne_top -> WithTop.lt_top_iff_ne_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {x : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1) x (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (Ne.{succ u1} (WithTop.{u1} α) x (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] {x : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) x (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (Ne.{succ u1} (WithTop.{u1} α) x (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_top_iff_ne_top WithTop.lt_top_iff_ne_topₓ'. -/\n/-- A version of `lt_top_iff_ne_top` for `with_top` that only requires `has_lt α`, not\n`partial_order α`. -/\nprotected theorem lt_top_iff_ne_top {x : WithTop α} : x < ⊤ ↔ x ≠ ⊤ :=\n  @WithBot.bot_lt_iff_ne_bot αᵒᵈ _ x\n#align with_top.lt_top_iff_ne_top WithTop.lt_top_iff_ne_top\n\nend LT\n\ninstance [Preorder α] : Preorder (WithTop α)\n    where\n  le := (· ≤ ·)\n  lt := (· < ·)\n  lt_iff_le_not_le := by simp [← to_dual_lt_to_dual_iff, lt_iff_le_not_le]\n  le_refl _ := toDual_le_toDual_iff.mp le_rfl\n  le_trans _ _ _ := by\n    simp_rw [← to_dual_le_to_dual_iff]\n    exact Function.swap le_trans\n\ninstance [PartialOrder α] : PartialOrder (WithTop α) :=\n  { WithTop.preorder with\n    le_antisymm := fun _ _ => by\n      simp_rw [← to_dual_le_to_dual_iff]\n      exact Function.swap le_antisymm }\n\n#print WithTop.coe_strictMono /-\ntheorem coe_strictMono [Preorder α] : StrictMono (coe : α → WithTop α) := fun a b => some_lt_some.2\n#align with_top.coe_strict_mono WithTop.coe_strictMono\n-/\n\n#print WithTop.coe_mono /-\ntheorem coe_mono [Preorder α] : Monotone (coe : α → WithTop α) := fun a b => coe_le_coe.2\n#align with_top.coe_mono WithTop.coe_mono\n-/\n\n/- warning: with_top.monotone_iff -> WithTop.monotone_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : (WithTop.{u1} α) -> β}, Iff (Monotone.{u1, u2} (WithTop.{u1} α) β (WithTop.preorder.{u1} α _inst_1) _inst_2 f) (And (Monotone.{u1, u2} α β _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} α (WithTop.{u1} α) β f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α)))))) (forall (x : α), LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) x)) (f (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : (WithTop.{u2} α) -> β}, Iff (Monotone.{u2, u1} (WithTop.{u2} α) β (WithTop.preorder.{u2} α _inst_1) _inst_2 f) (And (Monotone.{u2, u1} α β _inst_1 _inst_2 (fun (a : α) => f (WithTop.some.{u2} α a))) (forall (x : α), LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) (f (WithTop.some.{u2} α x)) (f (Top.top.{u2} (WithTop.{u2} α) (WithTop.top.{u2} α)))))\nCase conversion may be inaccurate. Consider using '#align with_top.monotone_iff WithTop.monotone_iffₓ'. -/\ntheorem monotone_iff [Preorder α] [Preorder β] {f : WithTop α → β} :\n    Monotone f ↔ Monotone (f ∘ coe : α → β) ∧ ∀ x : α, f x ≤ f ⊤ :=\n  ⟨fun h => ⟨h.comp WithTop.coe_mono, fun x => h le_top⟩, fun h =>\n    WithTop.forall.2\n      ⟨WithTop.forall.2 ⟨fun _ => le_rfl, fun x h => (not_top_le_coe _ h).elim⟩, fun x =>\n        WithTop.forall.2 ⟨fun _ => h.2 x, fun y hle => h.1 (coe_le_coe.1 hle)⟩⟩⟩\n#align with_top.monotone_iff WithTop.monotone_iff\n\n/- warning: with_top.monotone_map_iff -> WithTop.monotone_map_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, Iff (Monotone.{u1, u2} (WithTop.{u1} α) (WithTop.{u2} β) (WithTop.preorder.{u1} α _inst_1) (WithTop.preorder.{u2} β _inst_2) (WithTop.map.{u1, u2} α β f)) (Monotone.{u1, u2} α β _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, Iff (Monotone.{u2, u1} (WithTop.{u2} α) (WithTop.{u1} β) (WithTop.preorder.{u2} α _inst_1) (WithTop.preorder.{u1} β _inst_2) (WithTop.map.{u2, u1} α β f)) (Monotone.{u2, u1} α β _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_top.monotone_map_iff WithTop.monotone_map_iffₓ'. -/\n@[simp]\ntheorem monotone_map_iff [Preorder α] [Preorder β] {f : α → β} :\n    Monotone (WithTop.map f) ↔ Monotone f :=\n  monotone_iff.trans <| by simp [Monotone]\n#align with_top.monotone_map_iff WithTop.monotone_map_iff\n\n/- warning: monotone.with_top_map -> Monotone.withTop_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, (Monotone.{u1, u2} α β _inst_1 _inst_2 f) -> (Monotone.{u1, u2} (WithTop.{u1} α) (WithTop.{u2} β) (WithTop.preorder.{u1} α _inst_1) (WithTop.preorder.{u2} β _inst_2) (WithTop.map.{u1, u2} α β f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, (Monotone.{u2, u1} α β _inst_1 _inst_2 f) -> (Monotone.{u2, u1} (WithTop.{u2} α) (WithTop.{u1} β) (WithTop.preorder.{u2} α _inst_1) (WithTop.preorder.{u1} β _inst_2) (WithTop.map.{u2, u1} α β f))\nCase conversion may be inaccurate. Consider using '#align monotone.with_top_map Monotone.withTop_mapₓ'. -/\nalias monotone_map_iff ↔ _ _root_.monotone.with_top_map\n#align monotone.with_top_map Monotone.withTop_map\n\n/- warning: with_top.strict_mono_iff -> WithTop.strictMono_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : (WithTop.{u1} α) -> β}, Iff (StrictMono.{u1, u2} (WithTop.{u1} α) β (WithTop.preorder.{u1} α _inst_1) _inst_2 f) (And (StrictMono.{u1, u2} α β _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} α (WithTop.{u1} α) β f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α)))))) (forall (x : α), LT.lt.{u2} β (Preorder.toLT.{u2} β _inst_2) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) x)) (f (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : (WithTop.{u2} α) -> β}, Iff (StrictMono.{u2, u1} (WithTop.{u2} α) β (WithTop.preorder.{u2} α _inst_1) _inst_2 f) (And (StrictMono.{u2, u1} α β _inst_1 _inst_2 (fun (a : α) => f (WithTop.some.{u2} α a))) (forall (x : α), LT.lt.{u1} β (Preorder.toLT.{u1} β _inst_2) (f (WithTop.some.{u2} α x)) (f (Top.top.{u2} (WithTop.{u2} α) (WithTop.top.{u2} α)))))\nCase conversion may be inaccurate. Consider using '#align with_top.strict_mono_iff WithTop.strictMono_iffₓ'. -/\ntheorem strictMono_iff [Preorder α] [Preorder β] {f : WithTop α → β} :\n    StrictMono f ↔ StrictMono (f ∘ coe : α → β) ∧ ∀ x : α, f x < f ⊤ :=\n  ⟨fun h => ⟨h.comp WithTop.coe_strictMono, fun x => h (coe_lt_top _)⟩, fun h =>\n    WithTop.forall.2\n      ⟨WithTop.forall.2 ⟨flip absurd (lt_irrefl _), fun x h => (not_top_lt h).elim⟩, fun x =>\n        WithTop.forall.2 ⟨fun _ => h.2 x, fun y hle => h.1 (coe_lt_coe.1 hle)⟩⟩⟩\n#align with_top.strict_mono_iff WithTop.strictMono_iff\n\n/- warning: with_top.strict_mono_map_iff -> WithTop.strictMono_map_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, Iff (StrictMono.{u1, u2} (WithTop.{u1} α) (WithTop.{u2} β) (WithTop.preorder.{u1} α _inst_1) (WithTop.preorder.{u2} β _inst_2) (WithTop.map.{u1, u2} α β f)) (StrictMono.{u1, u2} α β _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, Iff (StrictMono.{u2, u1} (WithTop.{u2} α) (WithTop.{u1} β) (WithTop.preorder.{u2} α _inst_1) (WithTop.preorder.{u1} β _inst_2) (WithTop.map.{u2, u1} α β f)) (StrictMono.{u2, u1} α β _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_top.strict_mono_map_iff WithTop.strictMono_map_iffₓ'. -/\n@[simp]\ntheorem strictMono_map_iff [Preorder α] [Preorder β] {f : α → β} :\n    StrictMono (WithTop.map f) ↔ StrictMono f :=\n  strictMono_iff.trans <| by simp [StrictMono, coe_lt_top]\n#align with_top.strict_mono_map_iff WithTop.strictMono_map_iff\n\n/- warning: strict_mono.with_top_map -> StrictMono.withTop_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] {f : α -> β}, (StrictMono.{u1, u2} α β _inst_1 _inst_2 f) -> (StrictMono.{u1, u2} (WithTop.{u1} α) (WithTop.{u2} β) (WithTop.preorder.{u1} α _inst_1) (WithTop.preorder.{u2} β _inst_2) (WithTop.map.{u1, u2} α β f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] {f : α -> β}, (StrictMono.{u2, u1} α β _inst_1 _inst_2 f) -> (StrictMono.{u2, u1} (WithTop.{u2} α) (WithTop.{u1} β) (WithTop.preorder.{u2} α _inst_1) (WithTop.preorder.{u1} β _inst_2) (WithTop.map.{u2, u1} α β f))\nCase conversion may be inaccurate. Consider using '#align strict_mono.with_top_map StrictMono.withTop_mapₓ'. -/\nalias strict_mono_map_iff ↔ _ _root_.strict_mono.with_top_map\n#align strict_mono.with_top_map StrictMono.withTop_map\n\n/- warning: with_top.map_le_iff -> WithTop.map_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u1} α] [_inst_2 : Preorder.{u2} β] (f : α -> β) (a : WithTop.{u1} α) (b : WithTop.{u1} α), (forall {a : α} {b : α}, Iff (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) (f a) (f b)) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_1) a b)) -> (Iff (LE.le.{u2} (WithTop.{u2} β) (Preorder.toLE.{u2} (WithTop.{u2} β) (WithTop.preorder.{u2} β _inst_2)) (WithTop.map.{u1, u2} α β f a) (WithTop.map.{u1, u2} α β f b)) (LE.le.{u1} (WithTop.{u1} α) (Preorder.toLE.{u1} (WithTop.{u1} α) (WithTop.preorder.{u1} α _inst_1)) a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Preorder.{u2} α] [_inst_2 : Preorder.{u1} β] (f : α -> β) (a : WithTop.{u2} α) (b : WithTop.{u2} α), (forall {a : α} {b : α}, Iff (LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) (f a) (f b)) (LE.le.{u2} α (Preorder.toLE.{u2} α _inst_1) a b)) -> (Iff (LE.le.{u1} (WithTop.{u1} β) (Preorder.toLE.{u1} (WithTop.{u1} β) (WithTop.preorder.{u1} β _inst_2)) (WithTop.map.{u2, u1} α β f a) (WithTop.map.{u2, u1} α β f b)) (LE.le.{u2} (WithTop.{u2} α) (Preorder.toLE.{u2} (WithTop.{u2} α) (WithTop.preorder.{u2} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align with_top.map_le_iff WithTop.map_le_iffₓ'. -/\ntheorem map_le_iff [Preorder α] [Preorder β] (f : α → β) (a b : WithTop α)\n    (mono_iff : ∀ {a b}, f a ≤ f b ↔ a ≤ b) : a.map f ≤ b.map f ↔ a ≤ b :=\n  by\n  rw [← to_dual_le_to_dual_iff, to_dual_map, to_dual_map, WithBot.map_le_iff,\n    to_dual_le_to_dual_iff]\n  simp [mono_iff]\n#align with_top.map_le_iff WithTop.map_le_iff\n\ninstance [SemilatticeInf α] : SemilatticeInf (WithTop α) :=\n  { WithTop.partialOrder with\n    inf := Option.liftOrGet (· ⊓ ·)\n    inf_le_left := fun o₁ o₂ a ha => by cases ha <;> cases o₂ <;> simp [Option.liftOrGet]\n    inf_le_right := fun o₁ o₂ a ha => by cases ha <;> cases o₁ <;> simp [Option.liftOrGet]\n    le_inf := fun o₁ o₂ o₃ h₁ h₂ a ha =>\n      by\n      cases' o₂ with b <;> cases' o₃ with c <;> cases ha\n      · exact h₂ a rfl\n      · exact h₁ a rfl\n      · rcases h₁ b rfl with ⟨d, ⟨⟩, h₁'⟩\n        simp at h₂\n        exact ⟨d, rfl, le_inf h₁' h₂⟩ }\n\n/- warning: with_top.coe_inf -> WithTop.coe_inf is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithTop.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) (Inf.inf.{u1} α (SemilatticeInf.toHasInf.{u1} α _inst_1) a b)) (Inf.inf.{u1} (WithTop.{u1} α) (SemilatticeInf.toHasInf.{u1} (WithTop.{u1} α) (WithTop.semilatticeInf.{u1} α _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithTop.{u1} α) (WithTop.some.{u1} α (Inf.inf.{u1} α (SemilatticeInf.toInf.{u1} α _inst_1) a b)) (Inf.inf.{u1} (WithTop.{u1} α) (SemilatticeInf.toInf.{u1} (WithTop.{u1} α) (WithTop.semilatticeInf.{u1} α _inst_1)) (WithTop.some.{u1} α a) (WithTop.some.{u1} α b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_inf WithTop.coe_infₓ'. -/\ntheorem coe_inf [SemilatticeInf α] (a b : α) : ((a ⊓ b : α) : WithTop α) = a ⊓ b :=\n  rfl\n#align with_top.coe_inf WithTop.coe_inf\n\ninstance [SemilatticeSup α] : SemilatticeSup (WithTop α) :=\n  { WithTop.partialOrder with\n    sup := Option.map₂ (· ⊔ ·)\n    le_sup_left := fun o₁ o₂ a ha =>\n      by\n      rcases Option.mem_map₂_iff.1 ha with ⟨a, b, rfl : _ = _, rfl : _ = _, rfl⟩\n      exact ⟨_, rfl, le_sup_left⟩\n    le_sup_right := fun o₁ o₂ a ha =>\n      by\n      rcases Option.mem_map₂_iff.1 ha with ⟨a, b, rfl : _ = _, rfl : _ = _, rfl⟩\n      exact ⟨_, rfl, le_sup_right⟩\n    sup_le := fun o₁ o₂ o₃ h₁ h₂ a ha => by\n      cases ha\n      rcases h₁ a rfl with ⟨b, ⟨⟩, ab⟩\n      rcases h₂ a rfl with ⟨c, ⟨⟩, ac⟩\n      exact ⟨_, rfl, sup_le ab ac⟩ }\n\n/- warning: with_top.coe_sup -> WithTop.coe_sup is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithTop.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) (Sup.sup.{u1} α (SemilatticeSup.toHasSup.{u1} α _inst_1) a b)) (Sup.sup.{u1} (WithTop.{u1} α) (SemilatticeSup.toHasSup.{u1} (WithTop.{u1} α) (WithTop.semilatticeSup.{u1} α _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} α] (a : α) (b : α), Eq.{succ u1} (WithTop.{u1} α) (WithTop.some.{u1} α (Sup.sup.{u1} α (SemilatticeSup.toSup.{u1} α _inst_1) a b)) (Sup.sup.{u1} (WithTop.{u1} α) (SemilatticeSup.toSup.{u1} (WithTop.{u1} α) (WithTop.semilatticeSup.{u1} α _inst_1)) (WithTop.some.{u1} α a) (WithTop.some.{u1} α b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_sup WithTop.coe_supₓ'. -/\ntheorem coe_sup [SemilatticeSup α] (a b : α) : ((a ⊔ b : α) : WithTop α) = a ⊔ b :=\n  rfl\n#align with_top.coe_sup WithTop.coe_sup\n\ninstance [Lattice α] : Lattice (WithTop α) :=\n  { WithTop.semilatticeSup, WithTop.semilatticeInf with }\n\ninstance [DistribLattice α] : DistribLattice (WithTop α) :=\n  { WithTop.lattice with\n    le_sup_inf := fun o₁ o₂ o₃ =>\n      match o₁, o₂, o₃ with\n      | ⊤, o₂, o₃ => le_rfl\n      | (a₁ : α), ⊤, ⊤ => le_rfl\n      | (a₁ : α), ⊤, (a₃ : α) => le_rfl\n      | (a₁ : α), (a₂ : α), ⊤ => le_rfl\n      | (a₁ : α), (a₂ : α), (a₃ : α) => coe_le_coe.mpr le_sup_inf }\n\n/- warning: with_top.decidable_le -> WithTop.decidableLE is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (LE.le.{u1} α _inst_1)], DecidableRel.{succ u1} (WithTop.{u1} α) (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (fun (x._@.Mathlib.Order.WithBot._hyg.10360 : α) (x._@.Mathlib.Order.WithBot._hyg.10362 : α) => LE.le.{u1} α _inst_1 x._@.Mathlib.Order.WithBot._hyg.10360 x._@.Mathlib.Order.WithBot._hyg.10362)], DecidableRel.{succ u1} (WithTop.{u1} α) (fun (x._@.Mathlib.Order.WithBot._hyg.10380 : WithTop.{u1} α) (x._@.Mathlib.Order.WithBot._hyg.10382 : WithTop.{u1} α) => LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) x._@.Mathlib.Order.WithBot._hyg.10380 x._@.Mathlib.Order.WithBot._hyg.10382)\nCase conversion may be inaccurate. Consider using '#align with_top.decidable_le WithTop.decidableLEₓ'. -/\ninstance decidableLE [LE α] [@DecidableRel α (· ≤ ·)] : @DecidableRel (WithTop α) (· ≤ ·) :=\n  fun _ _ => decidable_of_decidable_of_iff (WithBot.decidableLE _ _) toDual_le_toDual_iff\n#align with_top.decidable_le WithTop.decidableLE\n\n/- warning: with_top.decidable_lt -> WithTop.decidableLT is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (LT.lt.{u1} α _inst_1)], DecidableRel.{succ u1} (WithTop.{u1} α) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LT.{u1} α] [_inst_2 : DecidableRel.{succ u1} α (fun (x._@.Mathlib.Order.WithBot._hyg.10415 : α) (x._@.Mathlib.Order.WithBot._hyg.10417 : α) => LT.lt.{u1} α _inst_1 x._@.Mathlib.Order.WithBot._hyg.10415 x._@.Mathlib.Order.WithBot._hyg.10417)], DecidableRel.{succ u1} (WithTop.{u1} α) (fun (x._@.Mathlib.Order.WithBot._hyg.10435 : WithTop.{u1} α) (x._@.Mathlib.Order.WithBot._hyg.10437 : WithTop.{u1} α) => LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_1) x._@.Mathlib.Order.WithBot._hyg.10435 x._@.Mathlib.Order.WithBot._hyg.10437)\nCase conversion may be inaccurate. Consider using '#align with_top.decidable_lt WithTop.decidableLTₓ'. -/\ninstance decidableLT [LT α] [@DecidableRel α (· < ·)] : @DecidableRel (WithTop α) (· < ·) :=\n  fun _ _ => decidable_of_decidable_of_iff (WithBot.decidableLT _ _) toDual_lt_toDual_iff\n#align with_top.decidable_lt WithTop.decidableLT\n\n/- warning: with_top.is_total_le -> WithTop.isTotal_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : IsTotal.{u1} α (LE.le.{u1} α _inst_1)], IsTotal.{u1} (WithTop.{u1} α) (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LE.{u1} α] [_inst_2 : IsTotal.{u1} α (fun (x._@.Mathlib.Order.WithBot._hyg.10470 : α) (x._@.Mathlib.Order.WithBot._hyg.10472 : α) => LE.le.{u1} α _inst_1 x._@.Mathlib.Order.WithBot._hyg.10470 x._@.Mathlib.Order.WithBot._hyg.10472)], IsTotal.{u1} (WithTop.{u1} α) (fun (x._@.Mathlib.Order.WithBot._hyg.10490 : WithTop.{u1} α) (x._@.Mathlib.Order.WithBot._hyg.10492 : WithTop.{u1} α) => LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_1) x._@.Mathlib.Order.WithBot._hyg.10490 x._@.Mathlib.Order.WithBot._hyg.10492)\nCase conversion may be inaccurate. Consider using '#align with_top.is_total_le WithTop.isTotal_leₓ'. -/\ninstance isTotal_le [LE α] [IsTotal α (· ≤ ·)] : IsTotal (WithTop α) (· ≤ ·) :=\n  ⟨fun _ _ => by\n    simp_rw [← to_dual_le_to_dual_iff]\n    exact total_of _ _ _⟩\n#align with_top.is_total_le WithTop.isTotal_le\n\ninstance [LinearOrder α] : LinearOrder (WithTop α) :=\n  Lattice.toLinearOrder _\n\n/- warning: with_top.coe_min -> WithTop.coe_min is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithTop.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) (LinearOrder.min.{u1} α _inst_1 x y)) (LinearOrder.min.{u1} (WithTop.{u1} α) (WithTop.linearOrder.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) y))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithTop.{u1} α) (WithTop.some.{u1} α (Min.min.{u1} α (LinearOrder.toMin.{u1} α _inst_1) x y)) (Min.min.{u1} (WithTop.{u1} α) (LinearOrder.toMin.{u1} (WithTop.{u1} α) (WithTop.linearOrder.{u1} α _inst_1)) (WithTop.some.{u1} α x) (WithTop.some.{u1} α y))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_min WithTop.coe_minₓ'. -/\n@[simp, norm_cast]\ntheorem coe_min [LinearOrder α] (x y : α) : (↑(min x y) : WithTop α) = min x y :=\n  rfl\n#align with_top.coe_min WithTop.coe_min\n\n/- warning: with_top.coe_max -> WithTop.coe_max is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithTop.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) (LinearOrder.max.{u1} α _inst_1 x y)) (LinearOrder.max.{u1} (WithTop.{u1} α) (WithTop.linearOrder.{u1} α _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) y))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrder.{u1} α] (x : α) (y : α), Eq.{succ u1} (WithTop.{u1} α) (WithTop.some.{u1} α (Max.max.{u1} α (LinearOrder.toMax.{u1} α _inst_1) x y)) (Max.max.{u1} (WithTop.{u1} α) (LinearOrder.toMax.{u1} (WithTop.{u1} α) (WithTop.linearOrder.{u1} α _inst_1)) (WithTop.some.{u1} α x) (WithTop.some.{u1} α y))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_max WithTop.coe_maxₓ'. -/\n@[simp, norm_cast]\ntheorem coe_max [LinearOrder α] (x y : α) : (↑(max x y) : WithTop α) = max x y :=\n  rfl\n#align with_top.coe_max WithTop.coe_max\n\n#print WithTop.wellFounded_lt /-\ntheorem wellFounded_lt [Preorder α] (h : @WellFounded α (· < ·)) :\n    @WellFounded (WithTop α) (· < ·) :=\n  have acc_some : ∀ a : α, Acc ((· < ·) : WithTop α → WithTop α → Prop) (some a) := fun a =>\n    Acc.intro _\n      (WellFounded.induction h a\n        (show\n          ∀ b,\n            (∀ c, c < b → ∀ d : WithTop α, d < some c → Acc (· < ·) d) →\n              ∀ y : WithTop α, y < some b → Acc (· < ·) y\n          from fun b ih c =>\n          Option.recOn c (fun hc => (not_lt_of_ge le_top hc).elim) fun c hc =>\n            Acc.intro _ (ih _ (some_lt_some.1 hc))))\n  ⟨fun a =>\n    Option.recOn a\n      (Acc.intro _ fun y => Option.recOn y (fun h => (lt_irrefl _ h).elim) fun _ _ => acc_some _)\n      acc_some⟩\n#align with_top.well_founded_lt WithTop.wellFounded_lt\n-/\n\nopen OrderDual\n\n#print WithTop.wellFounded_gt /-\ntheorem wellFounded_gt [Preorder α] (h : @WellFounded α (· > ·)) :\n    @WellFounded (WithTop α) (· > ·) :=\n  ⟨fun a =>\n    by\n    -- ideally, use rel_hom_class.acc, but that is defined later\n    have : Acc (· < ·) a.to_dual := WellFounded.apply (WithBot.wellFounded_lt h) _\n    revert this\n    generalize ha : a.to_dual = b; intro ac\n    induction' ac with _ H IH generalizing a; subst ha\n    exact ⟨_, fun a' h => IH a'.toDual (to_dual_lt_to_dual.mpr h) _ rfl⟩⟩\n#align with_top.well_founded_gt WithTop.wellFounded_gt\n-/\n\n#print WithBot.wellFounded_gt /-\ntheorem WithBot.wellFounded_gt [Preorder α] (h : @WellFounded α (· > ·)) :\n    @WellFounded (WithBot α) (· > ·) :=\n  ⟨fun a =>\n    by\n    -- ideally, use rel_hom_class.acc, but that is defined later\n    have : Acc (· < ·) a.to_dual := WellFounded.apply (WithTop.wellFounded_lt h) _\n    revert this\n    generalize ha : a.to_dual = b; intro ac\n    induction' ac with _ H IH generalizing a; subst ha\n    exact ⟨_, fun a' h => IH a'.toDual (to_dual_lt_to_dual.mpr h) _ rfl⟩⟩\n#align with_bot.well_founded_gt WithBot.wellFounded_gt\n-/\n\n#print WithTop.trichotomous.lt /-\ninstance trichotomous.lt [Preorder α] [IsTrichotomous α (· < ·)] :\n    IsTrichotomous (WithTop α) (· < ·) :=\n  ⟨by\n    rintro (a | _) (b | _)\n    iterate 3 simp\n    simpa [Option.some_inj] using @trichotomous _ (· < ·) _ a b⟩\n#align with_top.trichotomous.lt WithTop.trichotomous.lt\n-/\n\n#print WithTop.IsWellOrder.lt /-\ninstance IsWellOrder.lt [Preorder α] [h : IsWellOrder α (· < ·)] : IsWellOrder (WithTop α) (· < ·)\n    where wf := wellFounded_lt h.wf\n#align with_top.is_well_order.lt WithTop.IsWellOrder.lt\n-/\n\n#print WithTop.trichotomous.gt /-\ninstance trichotomous.gt [Preorder α] [IsTrichotomous α (· > ·)] :\n    IsTrichotomous (WithTop α) (· > ·) :=\n  ⟨by\n    rintro (a | _) (b | _)\n    iterate 3 simp\n    simpa [Option.some_inj] using @trichotomous _ (· > ·) _ a b⟩\n#align with_top.trichotomous.gt WithTop.trichotomous.gt\n-/\n\n#print WithTop.IsWellOrder.gt /-\ninstance IsWellOrder.gt [Preorder α] [h : IsWellOrder α (· > ·)] : IsWellOrder (WithTop α) (· > ·)\n    where wf := wellFounded_gt h.wf\n#align with_top.is_well_order.gt WithTop.IsWellOrder.gt\n-/\n\n#print WithBot.trichotomous.lt /-\ninstance WithBot.trichotomous.lt [Preorder α] [h : IsTrichotomous α (· < ·)] :\n    IsTrichotomous (WithBot α) (· < ·) :=\n  @WithTop.trichotomous.gt αᵒᵈ _ h\n#align with_bot.trichotomous.lt WithBot.trichotomous.lt\n-/\n\n#print WithBot.isWellOrder.lt /-\ninstance WithBot.isWellOrder.lt [Preorder α] [h : IsWellOrder α (· < ·)] :\n    IsWellOrder (WithBot α) (· < ·) :=\n  @WithTop.IsWellOrder.gt αᵒᵈ _ h\n#align with_bot.is_well_order.lt WithBot.isWellOrder.lt\n-/\n\n#print WithBot.trichotomous.gt /-\ninstance WithBot.trichotomous.gt [Preorder α] [h : IsTrichotomous α (· > ·)] :\n    IsTrichotomous (WithBot α) (· > ·) :=\n  @WithTop.trichotomous.lt αᵒᵈ _ h\n#align with_bot.trichotomous.gt WithBot.trichotomous.gt\n-/\n\n#print WithBot.isWellOrder.gt /-\ninstance WithBot.isWellOrder.gt [Preorder α] [h : IsWellOrder α (· > ·)] :\n    IsWellOrder (WithBot α) (· > ·) :=\n  @WithTop.IsWellOrder.lt αᵒᵈ _ h\n#align with_bot.is_well_order.gt WithBot.isWellOrder.gt\n-/\n\ninstance [LT α] [DenselyOrdered α] [NoMaxOrder α] : DenselyOrdered (WithTop α) :=\n  OrderDual.denselyOrdered (WithBot αᵒᵈ)\n\n#print WithTop.lt_iff_exists_coe_btwn /-\ntheorem lt_iff_exists_coe_btwn [Preorder α] [DenselyOrdered α] [NoMaxOrder α] {a b : WithTop α} :\n    a < b ↔ ∃ x : α, a < ↑x ∧ ↑x < b :=\n  ⟨fun h =>\n    let ⟨y, hy⟩ := exists_between h\n    let ⟨x, hx⟩ := lt_iff_exists_coe.1 hy.2\n    ⟨x, hx.1 ▸ hy⟩,\n    fun ⟨x, hx⟩ => lt_trans hx.1 hx.2⟩\n#align with_top.lt_iff_exists_coe_btwn WithTop.lt_iff_exists_coe_btwn\n-/\n\ninstance [LE α] [NoBotOrder α] [Nonempty α] : NoBotOrder (WithTop α) :=\n  OrderDual.noBotOrder (WithBot αᵒᵈ)\n\ninstance [LT α] [NoMinOrder α] [Nonempty α] : NoMinOrder (WithTop α) :=\n  OrderDual.noMinOrder (WithBot αᵒᵈ)\n\nend WithTop\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/WithBot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.4726658312489395}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\n\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.ennreal\nimport formal_ml.sum\nimport formal_ml.lattice\nimport formal_ml.measurable_space\nimport formal_ml.classical\nimport formal_ml.core\nimport formal_ml.characteristic\nimport formal_ml.measure\nimport data.equiv.list\n\n\nnoncomputable def prod.outer_measure {α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.outer_measure α) (μβ:measure_theory.outer_measure β):measure_theory.outer_measure (α × β) := \n  measure_theory.outer_measure.of_function\n  (λ P:set (α × β), μα (prod.fst '' P) * μβ (prod.snd '' P))\nbegin\n  simp,\nend \n\nnoncomputable def prod.measure {α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.measure α) (μβ:measure_theory.measure β):measure_theory.measure (α × β) := \n  (prod.outer_measure μα.to_outer_measure μβ.to_outer_measure).to_measure \nbegin\n  unfold prod.measurable_space,\n  simp,\n  split;\n  intros P A1;\n  unfold measurable_space.comap at A1;\n  cases A1 with s A1;\n  cases A1 with A1 A2;\n  subst P;\n  apply measure_theory.outer_measure.of_function_caratheodory;\n  simp,\n  {intros t,\n   have B1:μα (prod.fst '' t ∩ s) + μα (prod.fst '' t \\ s) = μα (prod.fst '' t),\n   {rw ← measure_theory.measure_eq_inter_diff', apply A1},\n   rw ← B1,\n   clear B1,\n   rw right_distrib,\n   apply @add_le_add ennreal _;apply ennreal.mul_le_mul;try {apply measure_theory.measure_mono};simp;rw set.subset_def;\n   intros p B2;cases p;simp at B2;simp [B2];\n   try {apply exists.intro p_snd,simp [B2]};\n   {apply exists.intro p_fst,simp [B2]}},\n  {intros t,\n   have B1:μβ (prod.snd '' t ∩ s) + μβ (prod.snd '' t \\ s) = μβ (prod.snd '' t),\n   {rw ← measure_theory.measure_eq_inter_diff', apply A1},\n   rw ← B1,\n   clear B1,\n   rw left_distrib,\n   apply @add_le_add ennreal _;apply ennreal.mul_le_mul;try {apply measure_theory.measure_mono};simp;rw set.subset_def;\n   intros p B2;cases p;simp at B2;simp [B2];\n   try {apply exists.intro p_snd,simp [B2]};\n   {apply exists.intro p_fst,simp [B2]}},\nend\n\n@[simp]\nlemma set.prod_fst_image_of_prod {α:Type*} {β:Type*} (A:set α) (B:set β) (h:B.nonempty):(prod.fst '' (A.prod B)) = A :=\nbegin\n  ext p;split;intros A1,\n  simp at A1,simp [A1],\n  simp [A1],\n  apply h,\nend\n\n@[simp]\nlemma set.prod_snd_image_of_prod {α:Type*} {β:Type*} (A:set α) (B:set β) (h:A.nonempty):(prod.snd '' (A.prod B)) = B :=\nbegin\n  ext p;split;intros A1,\n  simp at A1,simp [A1],\n  simp [A1],\n  apply h,\nend\n\nlemma prod.outer_measure.Inf_sum {α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.outer_measure α) (μβ:measure_theory.outer_measure β) {P:set (α × β)}:\n  prod.outer_measure μα μβ P = \n  ⨅ (f:ℕ → set α) (g:ℕ → set β) (h₁: P ⊆ ⋃ n, (f n).prod (g n)), ∑' n, μα (f n) * μβ (g n) :=\nbegin\n  unfold prod.outer_measure measure_theory.outer_measure.of_function,\n  rw ← measure_theory.outer_measure.measure_of_eq_coe,\n  simp,\n  apply le_antisymm,\n  simp,\n  intros f g B1,\n  apply @infi_le_of_le ennreal  _ _ _ _ (λ (n:ℕ), (f n).prod (g n)),\n  apply @infi_le_of_le ennreal  _ _ _ _ _,\n  apply ennreal.tsum_le_tsum,\n  intros a,\n  cases (set.eq_empty_or_nonempty (f a)) with B2 B2,\n  {simp [B2]},\n  cases (set.eq_empty_or_nonempty (g a)) with B3 B3,\n  {simp [B3]},\n  {simp [B2,B3,le_refl]},\n  {simp [B1]},\n  simp,\n  intros h C1,\n  apply @infi_le_of_le ennreal _ _ _ _ (λ n, prod.fst '' (h n)),\n  apply @infi_le_of_le ennreal _ _ _ _ (λ n, prod.snd '' (h n)),\n  apply @infi_le_of_le ennreal  _ _ _ _ _,\n  simp,\n  apply le_refl _,\n  simp,\n  apply @set.subset.trans (α × β) P (set.Union h) (⋃ (n : ℕ), (prod.fst '' h n).prod (prod.snd '' h n)) C1,\n  apply set.Union_subset_Union,\n  intro i,\n  rw set.subset_def,\n  intros a C2,cases a,simp,\n  apply and.intro (exists.intro a_snd C2) (exists.intro a_fst C2),\nend\n\nlemma set.prod_subset_prod {α:Type*} {β:Type*} {A A':set α} {B B':set β}:A ⊆ A' → B ⊆ B' →\nA.prod B ⊆ A'.prod B' := begin\n  intros hA hB,\n  intros p hp,\n  split,\n  simp at hp,\n  apply hA,\n  apply hp.left,\n  apply hB,\n  apply hp.right,\nend\n\nlemma prod.outer_measure.Inf_sum2 {α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.measure α) (μβ:measure_theory.measure β) {P:set (α × β)}:\n  prod.outer_measure μα.to_outer_measure μβ.to_outer_measure P = \n  ⨅ (f:ℕ → set α) (g:ℕ → set β) \n    (h₁ : ∀ n, measurable_set (f n)) \n    (h₂ : ∀ n, measurable_set (g n)) \n   (h₃: P ⊆ ⋃ n, (f n).prod (g n)), ∑' n, μα (f n) * μβ (g n) :=\nbegin\n  rw prod.outer_measure.Inf_sum,\n  apply le_antisymm,\n  { simp,\n    intros f g h₁ h₂ h₃,\n    apply @infi_le_trans (ℕ→ set α) ennreal _ f,\n    apply @infi_le_trans (ℕ→ set β) ennreal _ g,\n    rw infi_prop_def,\n    apply le_refl _,\n    apply h₃ },\n  { simp,\n    intros f g h₃,\n    have h4 := λ n, measure_theory.measurable_eq μα (f n),\n    rw classical.skolem at h4,\n    cases h4 with f' h4,\n    have h5 := λ n, measure_theory.measurable_eq μβ (g n),\n    rw classical.skolem at h5,\n    cases h5 with g' h5,\n\n\n    apply @infi_le_trans (ℕ→ set α) ennreal _ f',\n    apply @infi_le_trans (ℕ→ set β) ennreal _ g',\n    rw infi_prop_def,\n    rw infi_prop_def,\n    rw infi_prop_def,\n    apply ennreal.tsum_le_tsum,\n    intro n,\n    rw (h4 n).right.left,\n    rw (h5 n).right.left,\n    apply le_refl _,\n    apply @set.subset.trans _ P (⋃ (n : ℕ), (f n).prod (g n)) \n          (⋃ (n : ℕ), (f' n).prod (g' n)) h₃,\n    apply set.Union_subset_Union,\n    intro n,\n    apply set.prod_subset_prod,\n    apply (h4 n).right.right,\n    apply (h5 n).right.right,\n    { intro n, apply (h5 n).left },\n    { intro n, apply (h4 n).left },\n    },\n -- sorry\n  \nend\n\n\n/-\n  If we can make this into an equality, we're home free. \n  See https://www.math.ucdavis.edu/~hunter/measure_theory/measure_notes_ch5.pdf\n  Those notes focus on measurable sets. We could theoretically do the same. However,\n  it would make the rest of the analysis much more complex.\n  I wonder if using an \"outer measure lower integral\" would make this useful. \n-/\nlemma prod.outer_measure.apply_prod_le {α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.outer_measure α) (μβ:measure_theory.outer_measure β) {A:set α} {B:set β}:\n  prod.outer_measure μα μβ (A.prod B) ≤ μα A * μβ B :=\nbegin\n  rw prod.outer_measure.Inf_sum,\n  {apply @infi_le_of_le ennreal _ _ _ _ (λ (n:ℕ), ite (n = 0) A ∅),\n  apply @infi_le_of_le ennreal _ _ _ _ (λ (n:ℕ), ite (n = 0) B ∅),\n  apply @infi_le_of_le ennreal _ _ _ _ _,\n  rw tsum_eq_single 0,\n  {simp [le_refl]},\n  intros b' B1,\n  simp [B1],\n  apply ennreal.t2_space,\n  rw set.subset_def,\n  intros p B2,\n  simp,\n  apply exists.intro 0,\n  {simp at B2,simp [B2]}},\nend\n\n--measure_theory.lintegral_characteristic\n/- The primary focus is on measures, instead of outer measures. This establishes an\n    inequality when the sets are measurable and we are looking at a product of two \n    measures. -/\nlemma prod.outer_measure.le_apply_prod {α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.measure α) (μβ:measure_theory.measure β) {A:set α} {B:set β}:\n  (measurable_set A) → (measurable_set B) →\n  μα A * μβ B  ≤ prod.outer_measure μα.to_outer_measure μβ.to_outer_measure (A.prod B) :=\nbegin\n  intros A4 A5,\n  rw prod.outer_measure.Inf_sum2,\n  simp,\n  intros f g A2 A3 A1,\n  have h2:(A.prod B).characteristic ≤ ∑' (n : ℕ), ((f n).prod (g n)).characteristic,\n  { apply function.le_trans (set.characteristic.subset A1),\n    apply set.characteristic.Union,\n     },\n  have h3:∀ (a:α) (b:β), (A.characteristic a) * (B.characteristic b)  ≤ \n          ∑' (n : ℕ), ((f n).characteristic a * (g n).characteristic b),\n  { intros a b,\n    rw ← set.characteristic.prod,\n    have h3a: (λ n, ((f n).characteristic a * (g n).characteristic b)) =\n              (λ n, ((f n).prod (g n)).characteristic (a, b)),\n    { ext n, rw set.characteristic.prod },\n    rw h3a,\n    have h3b:((∑' (n : ℕ), ((f n).prod (g n)).characteristic) (a, b)) =\n        (∑' (n : ℕ), ((f n).prod (g n)).characteristic (a, b)) ,\n    { apply ennreal.tsum_apply }, \n    rw ← h3b,\n    apply h2 },\n  have h4:∀ (b:β), measure_theory.lintegral μα  (λ a, A.characteristic a * (B.characteristic b))  ≤ measure_theory.lintegral μα (λ a, \n            ∑' (n : ℕ), ((f n).characteristic a) * (g n).characteristic b),\n  { intro b,\n    have h4a: ∀ (a:α), (A.characteristic a) * (B.characteristic b)  ≤ \n          ∑' (n : ℕ), ((f n).characteristic a * (g n).characteristic b),\n    { intro a, apply h3 },\n    apply measure_theory.lintegral_mono, apply h4a },\n  have h5:∀ (b:β), μα A * (B.characteristic b)  ≤ \n            ∑' (n : ℕ), ((μα (f n)) * (g n).characteristic b),\n  { intro b,\n    have h5a := h4 b,\n    rw measure_theory.lintegral_mul_const at h5a,\n    rw measure_theory.lintegral_characteristic at h5a,\n\n    rw measure_theory.lintegral_tsum at h5a,\n    have h5b : (λ i, (∫⁻ (a : α), (f i).characteristic a * (g i).characteristic b ∂μα)) =\n               (λ i, μα (f i) * (g i).characteristic b),\n    { ext1 i,\n      rw measure_theory.lintegral_mul_const,\n      --rw set.characteristic_integral,\n      rw measure_theory.lintegral_characteristic,\n      apply A2,\n      apply measurable.characteristic,\n      apply A2 },\n    rw h5b at h5a,\n      apply h5a,\n    { intro i, apply measurable.ennreal_mul,\n      apply measurable.characteristic,\n      apply A2,\n      apply measurable_const },\n    { apply A4 },\n    { apply measurable.characteristic, apply A4 } },\n  have h6:∫⁻ (b : β),   (μα A) * B.characteristic b ∂μβ ≤\n          ∫⁻ (b : β), ( ∑' (n : ℕ), (μα (f n)) * (g n).characteristic b)  ∂μβ,\n  { apply measure_theory.lintegral_mono,\n    apply h5, },\n  rw measure_theory.lintegral_const_mul at h6,\n  rw measure_theory.lintegral_characteristic at h6, -- set.characteristic_integral at h6,\n  rw measure_theory.lintegral_tsum at h6,\n  have h7: (λ i, ∫⁻ (b : β), μα (f i) * (g i).characteristic b ∂μβ) =\n           (λ i,  μα (f i) *  μβ (g i)),\n  {  ext1 i,\n     rw measure_theory.lintegral_const_mul,\n     rw measure_theory.lintegral_characteristic, -- set.characteristic_integral,\n     apply A3, apply measurable.characteristic,\n     apply A3 },\n  rw h7 at h6,\n  apply h6,\n  { intro i, apply measurable.ennreal_mul,\n    apply measurable_const,\n    apply measurable.characteristic,\n    apply A3 },\n  { apply A5 },\n  { apply measurable.characteristic, apply A5 },\nend\n\n\n\n\n\nlemma prod.measure_apply {α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.measure α) (μβ:measure_theory.measure β) (S:set (α × β)):measurable_set S →\n  prod.measure μα μβ S = \n  prod.outer_measure μα.to_outer_measure μβ.to_outer_measure S :=\nbegin\n  intro h,\n  simp [prod.measure],\n  rw measure_theory.to_measure_apply,\n  apply h,\nend\n\nlemma prod.measure.apply_prod\n{α:Type*} {β:Type*} [Mα:measurable_space α] [Mβ:measurable_space β] \n  (μα:measure_theory.measure α) (μβ:measure_theory.measure β) (A:set α) (B:set β):measurable_set A →\n  measurable_set B → \n  (prod.measure μα μβ) (A.prod B) = (μα A) * (μβ B)  :=\nbegin\n  intros A1 A2,\n  rw prod.measure_apply,\n  apply le_antisymm,\n  { apply prod.outer_measure.apply_prod_le,\n     },\n  apply prod.outer_measure.le_apply_prod,\n  apply A1,\n  apply A2,\n  apply measurable_set.prod A1 A2,\nend\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/prod_measure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6548947357776796, "lm_q1q2_score": 0.47266582638760074}}
{"text": "/- Tactics -/\n\nexample : p → q → p ∧ q ∧ p := by\n  intro hp hq\n  apply And.intro\n  exact hp\n  apply And.intro\n  exact hq\n  exact hp\n\nexample : p → q → p ∧ q ∧ p := by\n  intro hp hq; apply And.intro hp; exact And.intro hq hp\n\n/- Structuring proofs -/\n\nexample : p → q → p ∧ q ∧ p := by\n  intro hp hq\n  apply And.intro\n  case left => exact hp\n  case right =>\n    apply And.intro\n    case left => exact hq\n    case right => exact hp\n\nexample : p → q → p ∧ q ∧ p := by\n  intro hp hq\n  apply And.intro\n  . exact hp\n  . apply And.intro\n    . exact hq\n    . exact hp\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/doc/examples/NFM2022/nfm14.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.47266582544593694}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.natural_transformation\n\n/-!\n# The category of functors and natural transformations between two fixed categories.\n\nWe provide the category instance on `C ⥤ D`, with morphisms the natural transformations.\n\n## Universes\n\nIf `C` and `D` are both small categories at the same universe level,\nthis is another small category at that level.\nHowever if `C` and `D` are both large categories at the same universe level,\nthis is a small category at the next higher level.\n-/\n\nnamespace category_theory\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\nopen nat_trans category category_theory.functor\n\nvariables (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D]\n\nlocal attribute [simp] vcomp_app\n/--\n`functor.category C D` gives the category structure on functors and natural transformations\nbetween categories `C` and `D`.\n\nNotice that if `C` and `D` are both small categories at the same universe level,\nthis is another small category at that level.\nHowever if `C` and `D` are both large categories at the same universe level,\nthis is a small category at the next higher level.\n-/\ninstance functor.category : category.{(max u₁ v₂)} (C ⥤ D) :=\n{ hom     := λ F G, nat_trans F G,\n  id      := λ F, nat_trans.id F,\n  comp    := λ _ _ _ α β, vcomp α β }\n\nvariables {C D} {E : Type u₃} [category.{v₃} E]\nvariables {F G H I : C ⥤ D}\n\nnamespace nat_trans\n\n@[simp] lemma vcomp_eq_comp (α : F ⟶ G) (β : G ⟶ H) : vcomp α β = α ≫ β := rfl\n\nlemma vcomp_app' (α : F ⟶ G) (β : G ⟶ H) (X : C) :\n  (α ≫ β).app X = (α.app X) ≫ (β.app X) := rfl\n\nlemma congr_app {α β : F ⟶ G} (h : α = β) (X : C) : α.app X = β.app X := by rw h\n@[simp] lemma id_app (F : C ⥤ D) (X : C) : (𝟙 F : F ⟶ F).app X = 𝟙 (F.obj X) := rfl\n@[simp] lemma comp_app {F G H : C ⥤ D} (α : F ⟶ G) (β : G ⟶ H) (X : C) :\n  (α ≫ β).app X = α.app X ≫ β.app X := rfl\n\nlemma app_naturality {F G : C ⥤ (D ⥤ E)} (T : F ⟶ G) (X : C) {Y Z : D} (f : Y ⟶ Z) :\n  ((F.obj X).map f) ≫ ((T.app X).app Z) = ((T.app X).app Y) ≫ ((G.obj X).map f) :=\n(T.app X).naturality f\n\nlemma naturality_app {F G : C ⥤ (D ⥤ E)} (T : F ⟶ G) (Z : D) {X Y : C} (f : X ⟶ Y) :\n  ((F.map f).app Z) ≫ ((T.app Y).app Z) = ((T.app X).app Z) ≫ ((G.map f).app Z) :=\ncongr_fun (congr_arg app (T.naturality f)) Z\n\n/-- A natural transformation is a monomorphism if each component is. -/\nlemma mono_app_of_mono (α : F ⟶ G) [∀ (X : C), mono (α.app X)] : mono α :=\n⟨λ H g h eq, by { ext X, rw [←cancel_mono (α.app X), ←comp_app, eq, comp_app] }⟩\n\n/-- A natural transformation is an epimorphism if each component is. -/\nlemma epi_app_of_epi (α : F ⟶ G) [∀ (X : C), epi (α.app X)] : epi α :=\n⟨λ H g h eq, by { ext X, rw [←cancel_epi (α.app X), ←comp_app, eq, comp_app] }⟩\n\n/-- `hcomp α β` is the horizontal composition of natural transformations. -/\ndef hcomp {H I : D ⥤ E} (α : F ⟶ G) (β : H ⟶ I) : (F ⋙ H) ⟶ (G ⋙ I) :=\n{ app         := λ X : C, (β.app (F.obj X)) ≫ (I.map (α.app X)),\n  naturality' := λ X Y f,\n  begin\n    rw [functor.comp_map, functor.comp_map, ←assoc, naturality, assoc,\n        ←map_comp I, naturality, map_comp, assoc]\n  end }\n\ninfix ` ◫ `:80 := hcomp\n\n@[simp] lemma hcomp_app {H I : D ⥤ E} (α : F ⟶ G) (β : H ⟶ I) (X : C) :\n  (α ◫ β).app X = (β.app (F.obj X)) ≫ (I.map (α.app X)) := rfl\n\n@[simp] lemma hcomp_id_app {H : D ⥤ E} (α : F ⟶ G) (X : C) : (α ◫ 𝟙 H).app X = H.map (α.app X) :=\n  by {dsimp, simp} -- See note [dsimp, simp].\n\nlemma id_hcomp_app {H : E ⥤ C} (α : F ⟶ G) (X : E) : (𝟙 H ◫ α).app X = α.app _ := by simp\n\n-- Note that we don't yet prove a `hcomp_assoc` lemma here: even stating it is painful, because we\n-- need to use associativity of functor composition. (It's true without the explicit associator,\n-- because functor composition is definitionally associative,\n-- but relying on the definitional equality causes bad problems with elaboration later.)\n\nlemma exchange {I J K : D ⥤ E} (α : F ⟶ G) (β : G ⟶ H)\n  (γ : I ⟶ J) (δ : J ⟶ K) : (α ≫ β) ◫ (γ ≫ δ) = (α ◫ γ) ≫ (β ◫ δ) :=\nby ext; simp\n\nend nat_trans\nopen nat_trans\nnamespace functor\n\n/-- Flip the arguments of a bifunctor. See also `currying.lean`. -/\nprotected def flip (F : C ⥤ (D ⥤ E)) : D ⥤ (C ⥤ E) :=\n{ obj := λ k,\n  { obj := λ j, (F.obj j).obj k,\n    map := λ j j' f, (F.map f).app k,\n    map_id' := λ X, begin rw category_theory.functor.map_id, refl end,\n    map_comp' := λ X Y Z f g, by rw [map_comp, ←comp_app] },\n  map := λ c c' f,\n  { app := λ j, (F.obj j).map f } }.\n\n@[simp] lemma flip_obj_obj (F : C ⥤ (D ⥤ E)) (c) (d) : (F.flip.obj d).obj c = (F.obj c).obj d := rfl\n@[simp] lemma flip_obj_map (F : C ⥤ (D ⥤ E)) {c c' : C} (f : c ⟶ c') (d : D) :\n  (F.flip.obj d).map f = (F.map f).app d := rfl\n@[simp] lemma flip_map_app (F : C ⥤ (D ⥤ E)) {d d' : D} (f : d ⟶ d') (c : C) :\n  (F.flip.map f).app c = (F.obj c).map f := rfl\n\nend functor\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.47266581854825}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport ring_theory.polynomial.basic\nimport ring_theory.principal_ideal_domain\nimport ring_theory.adjoin.polynomial\n\n/-!\n# Adjoining elements to form subalgebras\n\nThis file develops the basic theory of finitely-generated subalgebras.\n\n## Definitions\n\n* `fg (S : subalgebra R A)` : A predicate saying that the subalgebra is finitely-generated\nas an A-algebra\n\n## Tags\n\nadjoin, algebra, finitely-generated algebra\n\n-/\n\nuniverses u v w\n\nopen subsemiring ring submodule\nopen_locale pointwise\n\nnamespace algebra\n\nvariables {R : Type u} {A : Type v} {B : Type w}\n  [comm_semiring R] [comm_semiring A] [algebra R A] {s t : set A}\n\ntheorem fg_trans (h1 : (adjoin R s).to_submodule.fg)\n  (h2 : (adjoin (adjoin R s) t).to_submodule.fg) :\n  (adjoin R (s ∪ t)).to_submodule.fg :=\nbegin\n  rcases fg_def.1 h1 with ⟨p, hp, hp'⟩,\n  rcases fg_def.1 h2 with ⟨q, hq, hq'⟩,\n  refine fg_def.2 ⟨p * q, hp.mul hq, le_antisymm _ _⟩,\n  { rw [span_le],\n    rintros _ ⟨x, y, hx, hy, rfl⟩,\n    change x * y ∈ _,\n    refine subalgebra.mul_mem _ _ _,\n    { have : x ∈ (adjoin R s).to_submodule,\n      { rw ← hp', exact subset_span hx },\n      exact adjoin_mono (set.subset_union_left _ _) this },\n    have : y ∈ (adjoin (adjoin R s) t).to_submodule,\n    { rw ← hq', exact subset_span hy },\n    change y ∈ adjoin R (s ∪ t), rwa adjoin_union_eq_adjoin_adjoin },\n  { intros r hr,\n    change r ∈ adjoin R (s ∪ t) at hr,\n    rw adjoin_union_eq_adjoin_adjoin at hr,\n    change r ∈ (adjoin (adjoin R s) t).to_submodule at hr,\n    rw [← hq', ← set.image_id q, finsupp.mem_span_image_iff_total (adjoin R s)] at hr,\n    rcases hr with ⟨l, hlq, rfl⟩,\n    have := @finsupp.total_apply A A (adjoin R s),\n    rw [this, finsupp.sum],\n    refine sum_mem _ _,\n    intros z hz, change (l z).1 * _ ∈ _,\n    have : (l z).1 ∈ (adjoin R s).to_submodule := (l z).2,\n    rw [← hp', ← set.image_id p, finsupp.mem_span_image_iff_total R] at this,\n    rcases this with ⟨l2, hlp, hl⟩,\n    have := @finsupp.total_apply A A R,\n    rw this at hl,\n    rw [←hl, finsupp.sum_mul],\n    refine sum_mem _ _,\n    intros t ht, change _ * _ ∈ _, rw smul_mul_assoc, refine smul_mem _ _ _,\n    exact subset_span ⟨t, z, hlp ht, hlq hz, rfl⟩ }\nend\n\nend algebra\n\nnamespace subalgebra\n\nvariables {R : Type u} {A : Type v} {B : Type w}\nvariables [comm_semiring R] [semiring A] [algebra R A] [semiring B] [algebra R B]\n\n/-- A subalgebra `S` is finitely generated if there exists `t : finset A` such that\n`algebra.adjoin R t = S`. -/\ndef fg (S : subalgebra R A) : Prop :=\n∃ t : finset A, algebra.adjoin R ↑t = S\n\nlemma fg_adjoin_finset (s : finset A) : (algebra.adjoin R (↑s : set A)).fg :=\n⟨s, rfl⟩\n\ntheorem fg_def {S : subalgebra R A} : S.fg ↔ ∃ t : set A, set.finite t ∧ algebra.adjoin R t = S :=\n⟨λ ⟨t, ht⟩, ⟨↑t, set.finite_mem_finset t, ht⟩,\nλ ⟨t, ht1, ht2⟩, ⟨ht1.to_finset, by rwa set.finite.coe_to_finset⟩⟩\n\ntheorem fg_bot : (⊥ : subalgebra R A).fg :=\n⟨∅, algebra.adjoin_empty R A⟩\n\ntheorem fg_of_fg_to_submodule {S : subalgebra R A} : S.to_submodule.fg → S.fg :=\nλ ⟨t, ht⟩, ⟨t, le_antisymm\n  (algebra.adjoin_le (λ x hx, show x ∈ S.to_submodule, from ht ▸ subset_span hx)) $\n  show S.to_submodule ≤ (algebra.adjoin R ↑t).to_submodule,\n  from (λ x hx, span_le.mpr\n    (λ x hx, algebra.subset_adjoin hx)\n      (show x ∈ span R ↑t, by { rw ht, exact hx }))⟩\n\ntheorem fg_of_noetherian [is_noetherian R A] (S : subalgebra R A) : S.fg :=\nfg_of_fg_to_submodule (is_noetherian.noetherian S.to_submodule)\n\nlemma fg_of_submodule_fg (h : (⊤ : submodule R A).fg) : (⊤ : subalgebra R A).fg :=\nlet ⟨s, hs⟩ := h in ⟨s, to_submodule_injective $\nby { rw [algebra.top_to_submodule, eq_top_iff, ← hs, span_le], exact algebra.subset_adjoin }⟩\n\nlemma fg_prod {S : subalgebra R A} {T : subalgebra R B} (hS : S.fg) (hT : T.fg) : (S.prod T).fg :=\nbegin\n  obtain ⟨s, hs⟩ := fg_def.1 hS,\n  obtain ⟨t, ht⟩ := fg_def.1 hT,\n  rw [← hs.2, ← ht.2],\n  exact fg_def.2 ⟨(linear_map.inl R A B '' (s ∪ {1})) ∪ (linear_map.inr R A B '' (t ∪ {1})),\n    set.finite.union (set.finite.image _ (set.finite.union hs.1 (set.finite_singleton _)))\n    (set.finite.image _ (set.finite.union ht.1 (set.finite_singleton _))),\n    algebra.adjoin_inl_union_inr_eq_prod R s t⟩\nend\n\nsection\nopen_locale classical\nlemma fg_map (S : subalgebra R A) (f : A →ₐ[R] B) (hs : S.fg) : (S.map f).fg :=\nlet ⟨s, hs⟩ := hs in ⟨s.image f, by rw [finset.coe_image, algebra.adjoin_image, hs]⟩\nend\n\nlemma fg_of_fg_map (S : subalgebra R A) (f : A →ₐ[R] B) (hf : function.injective f)\n  (hs : (S.map f).fg) : S.fg :=\nlet ⟨s, hs⟩ := hs in ⟨s.preimage f $ λ _ _ _ _ h, hf h, map_injective f hf $\nby { rw [← algebra.adjoin_image, finset.coe_preimage, set.image_preimage_eq_of_subset, hs],\n  rw [← alg_hom.coe_range, ← algebra.adjoin_le_iff, hs, ← algebra.map_top], exact map_mono le_top }⟩\n\nlemma fg_top (S : subalgebra R A) : (⊤ : subalgebra R S).fg ↔ S.fg :=\n⟨λ h, by { rw [← S.range_val, ← algebra.map_top], exact fg_map _ _ h },\nλ h, fg_of_fg_map _ S.val subtype.val_injective $ by { rw [algebra.map_top, range_val], exact h }⟩\n\nlemma induction_on_adjoin [is_noetherian R A] (P : subalgebra R A → Prop)\n  (base : P ⊥) (ih : ∀ (S : subalgebra R A) (x : A), P S → P (algebra.adjoin R (insert x S)))\n  (S : subalgebra R A) : P S :=\nbegin\n  classical,\n  obtain ⟨t, rfl⟩ := S.fg_of_noetherian,\n  refine finset.induction_on t _ _,\n  { simpa using base },\n  intros x t hxt h,\n  rw [finset.coe_insert],\n  simpa only [algebra.adjoin_insert_adjoin] using ih _ x h,\nend\n\nend subalgebra\n\nsection semiring\n\nvariables {R : Type u} {A : Type v} {B : Type w}\nvariables [comm_semiring R] [comm_ring A] [comm_ring B] [algebra R A] [algebra R B]\n\n/-- The image of a Noetherian R-algebra under an R-algebra map is a Noetherian ring. -/\ninstance alg_hom.is_noetherian_ring_range (f : A →ₐ[R] B) [is_noetherian_ring A] :\n  is_noetherian_ring f.range :=\nis_noetherian_ring_range f.to_ring_hom\n\nend semiring\n\nsection ring\n\nvariables {R : Type u} {A : Type v} {B : Type w}\nvariables [comm_ring R] [comm_ring A] [comm_ring B] [algebra R A] [algebra R B]\n\ntheorem is_noetherian_ring_of_fg {S : subalgebra R A} (HS : S.fg)\n  [is_noetherian_ring R] : is_noetherian_ring S :=\nlet ⟨t, ht⟩ := HS in ht ▸ (algebra.adjoin_eq_range R (↑t : set A)).symm ▸\nby haveI : is_noetherian_ring (mv_polynomial (↑t : set A) R) :=\nmv_polynomial.is_noetherian_ring;\nconvert alg_hom.is_noetherian_ring_range _; apply_instance\n\ntheorem is_noetherian_subring_closure (s : set R) (hs : s.finite) :\n  is_noetherian_ring (subring.closure s) :=\nshow is_noetherian_ring (subalgebra_of_subring (subring.closure s)), from\nalgebra.adjoin_int s ▸ is_noetherian_ring_of_fg (subalgebra.fg_def.2 ⟨s, hs, rfl⟩)\n\nend ring\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/ring_theory/adjoin/fg.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.721743206297598, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.47266581666492286}}
{"text": "import data.equiv.fin\nimport data.fin\nimport data.nat.basic\nimport tactic\nimport init.data.nat.lemmas\n\n/-!\n\n# Finite Tuples\n\nThis file contains some definitions and results around finite tuples in an arbitrary type.\nWe have chosen to implement finite `n`-tuples in `A` as maps `fin n → A`.\nThis is primarily due to some restrictions arising from our inductive constructions.\n\n-/\n\ndef ftuple (A : Type*) (n : ℕ) := fin n → A\n\nlocal notation `η` := sum_fin_sum_equiv.to_fun \nlocal notation `δ` := sum_fin_sum_equiv.inv_fun\n\ndef fin.swap_args {m n} (f : fin (m + n)) : fin (n + m) := f.cast (by rwa add_comm)\n\nnamespace ftuple\nsection definitions\n/-!\n## Definitions\nThis section contains some basic definitions.\n-/\n\nvariables {A : Type*} {B : Type*}\n\n\ndef inl {m n} : fin m → fin (m + n) := η ∘ sum.inl \ndef inr {m n} : fin n → fin (m + n) := η ∘ sum.inr\n\ndef nil : ftuple A 0 := λ i, fin.elim0 i\ndef cast {m n} (h : m = n) (as : ftuple A m) : ftuple A n := as ∘ (fin.cast h.symm)\ndef swap_args {m n} (as : ftuple A (m + n)) : ftuple A (n + m) := cast (by rwa add_comm) as\ndef cast_to {m} (as : ftuple A m) (n) (h : m = n) : ftuple A n := as.cast h\ndef of (a : A) : ftuple A 1 := λ i, a\ndef append {m n} (as : ftuple A m) (bs : ftuple A n) : ftuple A (m+n) := λ i, sum.cases_on (δ i) as bs\ndef map {n} (as : ftuple A n) (f : A → B) : ftuple B n := f ∘ as\ndef proj {m n} (f : fin m → fin n) (as : ftuple A n) : ftuple A m := as ∘ f\ndef init {m n} (as : ftuple A (m + n)) : ftuple A m := λ i, as (η $ sum.inl i)\ndef last {m n} (as : ftuple A (m + n)) : ftuple A n := λ i, as (η $ sum.inr i)\ndef compl {m n} (as : ftuple A (m+n)) (f : ftuple A m → A) (g : ftuple A (1 + n) → A) : A := \n  g $ append (of $ f as.init) as.last\ndef compr {m n} (as : ftuple A (n+m)) (f : ftuple A m → A) (g : ftuple A (n + 1) → A) : A := \n  g $ append as.init $ of $ f as.last\n\ndef cons {n} (a : A) (as : ftuple A n) : ftuple A (n+1) := fin.cons a as --((of a).append as).cast (by rw add_comm)\ndef head {n} (as : ftuple A (n+1)) := as 0\ndef tail {n} (as : ftuple A (n+1)) : ftuple A n := fin.tail as --(as.cast_to (1+n) (by rw add_comm)).last\n\ndef curry {n} (f : ftuple A (n+1) → B) : A → (ftuple A n → B) := λ a as, f (cons a as) \ndef uncurry {n} (f : A → (ftuple A n → B)) : ftuple A (n+1) → B := λ as, f as.head as.tail\n\nend definitions\n\n\nsection map_lemmas\n\nvariables {A : Type*} {B : Type*} {C : Type*}\n\n@[simp]\nlemma map_of (a : A) (f : A → B) : (of a).map f = of (f a) := rfl\n\n@[simp]\nlemma map_proj {m n} (f : fin m → fin n) (g : A → B) (as : ftuple A n) : \n  (as.proj f).map g = (as.map g).proj f := rfl\n\n@[simp]\nlemma map_init {m n} (f : A → B) (as : ftuple A (m+n)) : as.init.map f = (as.map f).init := rfl\n\n@[simp]\nlemma map_last {m n} (f : A → B) (as : ftuple A (m+n)) : as.last.map f = (as.map f).last := rfl\n\n@[simp]\nlemma map_map {n} (f : A → B) (g : B → C) (as : ftuple A n) : as.map (g ∘ f) = (as.map f).map g := rfl\n\n@[simp]\nlemma map_eval {n} (f : A → B) (as : ftuple A n) : ∀ i, (as.map f) i = f (as i) := by tauto\n\nend map_lemmas\n\n\nsection other_lemmas\n\nvariables {A : Type*} {B : Type*}\n\n-- There is only one empty tuple\nlemma nil_unique (ft1 ft2 : ftuple A 0) : ft1 = ft2 :=\nbegin\n  ext,\n  exact fin_zero_elim x,\nend\n\nlemma cast_eval {m n} (h : m = n) (as : ftuple A m) (i : fin n):\n  (cast h as) i = as (fin.cast h.symm i) := rfl\n\n@[simp]\nlemma cons_at_zero {n} (a : A) (as : ftuple A n) :\n  cons a as 0 = a := rfl\n\n@[simp]\nlemma append_eval_inl {m n} (as : ftuple A m) (bs : ftuple A n) (i : fin m) :\n  (as.append bs) (inl i) = as i := \nbegin\n  unfold append,\n  dsimp only [],\n  have : inl i = η (sum.inl i), by refl, rw this, clear this,\n  rw equiv.left_inv,\nend\n\n@[simp]\nlemma append_eval_inr {m n} (as : ftuple A m) (bs : ftuple A n) (i : fin n) :\n  (as.append bs) (inr i) = bs i := \nbegin\n  unfold append,\n  dsimp only [],\n  have : inr i = η (sum.inr i), by refl, rw this, clear this,\n  rw equiv.left_inv,\nend\n\nprivate lemma sub_helper {m n} (x : fin (m + n)) (hx : m ≤ x.val)\n  : x.val - m < n :=\nbegin\n  cases x with xv xp,\n  apply (nat.sub_lt_left_iff_lt_add hx).mpr,\n  exact xp,\nend\n\nlemma lt_swap {m n} (x : fin (m + n))\n  : x.val < n + m :=\nbegin\n  cases x with xv xp,\n  rw add_comm at xp,\n  exact xp,\nend\n\nlemma inr_val {m n} (x : fin n)\n  : (@inr m n x).val = x.val + m:=\nbegin\n  unfold inr,\n  exact add_comm m x.val,\nend\n\nlemma inr_sub {m n} (x : fin (m + n)) (hx : m ≤ x.val)\n  : inr (fin.sub_nat m x.swap_args hx) = x :=\nbegin\n  ext,\n  rw inr_val,\n  rw fin.sub_nat_val _ _,\n  exact nat.sub_add_cancel hx,\nend\n\nlemma eval_sub {m n} (as : ftuple A m) (bs : ftuple A n) (x : fin (m + n)) (hx : m ≤ x.val)\n  : (as.append bs) x = bs (fin.sub_nat m x.swap_args hx) :=\nbegin\n  conv_lhs\n  { rw ← (inr_sub x hx), },\n  rw append_eval_inr,\nend\n\n@[simp]\nlemma map_append {m n} (as : ftuple A m) (bs : ftuple A n) (f : A → B) : \n  (as.append bs).map f = (as.map f).append (bs.map f) :=\nbegin\n  ext,\n  rw map_eval,\n  by_cases x.val < m,\n  { let y : fin m := ⟨x.val, h⟩,\n    change f (as.append bs (inl y)) = (as.map f).append (bs.map f) (inl y),\n    repeat {rw append_eval_inl},\n    refl, },\n  { rw not_lt at h,\n    let y := fin.sub_nat m x.swap_args h,\n    repeat {rw eval_sub _ _  x h},\n    rw map_eval, }\nend\n\nlemma cons_shift {n} (a : A) (as : ftuple A n) \n  : ∀ i : fin n, ((cons a as) (i.succ) = as i) := by apply fin.cons_succ\n\nlemma val_nonzero_of_fin_nonzero {n : ℕ} (i : fin n.succ) (h : i ≠ 0) : i.val ≠ 0 :=\nbegin\n  intro contra,\n  exact h ((fin.ext_iff i 0).mpr contra),\nend\n\ndef zero_lt_val {n : ℕ} (i : fin n.succ) (h : i ≠ 0) : 0 < i.val := \nbegin\n  have hi := val_nonzero_of_fin_nonzero i h,\n  exact nat.pos_of_ne_zero hi,\nend\n\nlemma cons_nil (a : A)\n  : (cons a nil) = of a :=\nbegin\n  ext,\n  have hx : x = 0, by exact subsingleton.elim x 0,\n  rw hx,\n  rw cons_at_zero,\n  refl,\nend\n\nlemma tail_shift {n : ℕ} (as : ftuple A n.succ)\n  : ∀ i, as.tail i = as i.succ := \nbegin\n  intro i,\n  symmetry, \n  have : as = cons as.head as.tail,\n  { unfold cons,\n    erw fin.cons_self_tail },\n  conv_lhs {rw this},\n  apply fin.cons_succ,\nend\n\nlemma map_cons {n} (as : ftuple A n) (a : A) (f : A → B)\n  : (cons a as).map f = cons (f a) (as.map f) :=\nbegin\n  ext,\n  by_cases hx : x = 0,\n  { rw hx,\n    rw cons_at_zero,\n    refl, },\n  { rw ← fin.succ_pred x hx,\n    rw cons_shift,\n    rw map_eval,\n    rw cons_shift,\n    refl, }\nend\n\n-- This will let us split up ftuples for the following theorem\nlemma is_append {n : ℕ} (as : ftuple A (n.succ))\n  : cons (as 0) as.tail = as :=\nbegin\n  ext,\n  by_cases x = 0,\n  { rw [h, cons_at_zero], },\n  { rw ← fin.succ_pred x h,\n    rw cons_shift,\n    apply tail_shift as, }\nend\n\n-- by induction on n.\ntheorem exists_rep {n} {f : A → B} (bs : ftuple B n) (surj : function.surjective f) :\n  ∃ as : ftuple A n, as.map f = bs :=\nbegin\n  induction n with n hn,\n  { use nil,\n    apply nil_unique, },\n  { rw ←is_append bs,\n    specialize surj (bs 0),\n    cases surj with a ha,\n    specialize hn bs.tail,\n    cases hn with as has,\n    use cons a as,\n    ext,\n    by_cases x = 0,\n    { rw h,\n      rw cons_at_zero,\n      rw map_cons,\n      rw cons_at_zero,\n      exact ha, },\n    { rw ← fin.succ_pred x h,\n      repeat {rw map_cons},\n      repeat {rw cons_shift},\n      rw has, } }\nend\n\nend other_lemmas\n\n\nsection quotient_stuff\n\nvariables {A : Type*} [I : setoid A] \nvariables {B : Type*}\n\ninclude I\nlemma tail_rel {n} (a : A) (as bs : ftuple A n) : \n  (∀ i, (cons a as) i ≈ (cons a bs) i) ↔\n  (∀ i, as i ≈ bs i) :=\nbegin\n  split,\n  { intros h j,\n    replace h := h (j.succ),\n    repeat {rw cons_shift at h},\n    exact h },\n  { intros h j, \n    by_cases c : j = 0,\n    { rw c,\n      simp_rw cons_at_zero },\n    {  rw ← fin.succ_pred j c,\n      repeat {rw cons_shift},\n      finish, } }\nend\n\nlemma head_rel {n} (a b : A) (as : ftuple A n) : \n  (∀ i, (cons a as) i ≈ (cons b as) i) ↔\n  a ≈ b :=\nbegin\n  split,\n  { intro h,\n    specialize h 0,\n    repeat {rw cons_at_zero at h},\n    exact h, },\n  { intros h i,\n    by_cases hi : i = 0,\n    { rw hi,\n      repeat {rw cons_at_zero},\n      exact h, },\n    { rw ← fin.succ_pred i hi,\n      repeat {rw cons_shift}, } }\nend\n\ndef quotient_lift : Π {n} (f : ftuple A n → B) \n  (hyp : ∀ (as bs : ftuple A n), (∀ i, as i ≈ bs i) → f as = f bs),  \n  ftuple (quotient I) n → B := λ n, nat.rec_on n \n  (λ f hyp, λ _, f nil) \n  (λ n ind f hyp, uncurry $ quotient.lift (λ a, ind (curry f a) \n  begin\n    intros as bs h, \n    change f _ = f _,\n    apply hyp,\n    rw tail_rel, assumption,\n  end) \n  begin\n    intros a b h, \n    dsimp only [],\n    suffices : curry f a = curry f b, by simp_rw this,\n    funext,\n    change f _ = f _,\n    apply hyp,\n    rw head_rel, assumption, \n  end)\n\n-- by induction on n\ntheorem quotient_lift_beta {n} (f : ftuple A n → B)\n  (hyp : ∀ (as bs : ftuple A n), (∀ i, as i ≈ bs i) → f as = f bs) (as : ftuple A n):  \n  (quotient_lift f hyp) (as.map (λ a, ⟦a⟧)) = f as := \nbegin\n  induction n with n ind,\n  { have : as = nil, by apply nil_unique,\n    rw this,\n    refl },\n  { erw ind,\n    unfold curry,\n    apply congr_arg,\n    exact is_append as }\nend\n\nend quotient_stuff\n\nend ftuple", "meta": {"author": "adamtopaz", "repo": "UnivAlg", "sha": "2458d47a6e4fd0525e3a25b07cb7dd518ac173ef", "save_path": "github-repos/lean/adamtopaz-UnivAlg", "path": "github-repos/lean/adamtopaz-UnivAlg/UnivAlg-2458d47a6e4fd0525e3a25b07cb7dd518ac173ef/src/ftuple.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.4726120963159262}}
{"text": "import .infinite_sums\nimport .log_harmonic\nimport .factors_le\n\nimport data.finset.image\nimport data.pnat.defs\nimport data.real.ennreal\nimport order.filter.basic\nimport order.filter.at_top_bot\nimport algebra.big_operators.basic\nimport topology.algebra.infinite_sum\n\nopen real filter\nopen_locale big_operators\n\n\nlemma prod_geom_series_primes_eq (n : ℕ) :\n  ∏ p in primes_le n, ((1 - (↑p)⁻¹)⁻¹ : ℝ) ≤\n  ↑(finset.card (primes_le n) + 1) :=\nbegin\n  sorry,\nend\n\n-- def pnat_range (n : ℕ) : finset ℕ+ := finset.image nat.to_pnat' (finset.Icc 1 n)\n--\n-- lemma coe_pnat_range_eq {n : ℕ} : finset.image coe (pnat_range n) = finset.Icc 1 n :=\n-- begin\n--   rw pnat_range,\n--   simp [finset.image_image],\n--   rw (_ : finset.image (coe ∘ nat.to_pnat') (finset.Icc 1 n) = finset.image id (finset.Icc 1 n)),\n--   { simp, },\n--   apply finset.image_congr,\n--   simp [set.eq_on],\n--   intros x h1 h2 h3,\n--   exfalso,\n--   revert h1,\n--   simp [h3],\n-- end\n\nlemma mem_pnat_fac_le_of_mem_Icc {n : ℕ} {x : ℕ} (hx : x ∈ finset.Icc 1 n) : (nat.to_pnat' x ∈ pnat_fac_le n) :=\nbegin\n  simp [pnat_fac_le],\n  cases x,\n  { exfalso, revert hx, simp, },\n  apply all_factors_le_of_le,\n  simp at *,\n  exact hx.right,\nend\n\ndef pnat_fac_le_range (n : ℕ) : finset ↥(pnat_fac_le n) :=\n  -- finset.image (λ x, ⟨nat.to_pnat' x.val, mem_pnat_fac_le_of_mem_Icc x.property⟩) (finset.Icc 1 n).attach\n  (finset.Icc 1 n).attach.image (λ x, ⟨nat.to_pnat' x.val, mem_pnat_fac_le_of_mem_Icc x.property⟩)\n\nlemma coe_pnat_fac_le_range_eq {n : ℕ} : finset.image coe (pnat_fac_le_range n) = finset.Icc 1 n :=\nbegin\n  rw (_ : finset.image coe (pnat_fac_le_range n) = finset.image coe (finset.Icc 1 n).attach),\n  { rw finset.attach_image_coe, },\n  rw pnat_fac_le_range,\n  rw finset.image_image,\n  apply finset.image_congr,\n  simp [set.eq_on],\n  intros a ha _ h,\n  exfalso,\n  revert ha,\n  rw h,\n  simp,\nend\n\n-- lemma nnreal_sum_le_tsum {α : Type*} {f : α → nnreal} (s : finset α) :\n--   s.sum (λ (x : α), f x) ≤ ∑' (x : α), f x :=\n-- begin\n--   -- Should be easy to prove this? Non-negative! Needs summable?!\n--   rw sum_eq_tsum_indicator,\n--   sorry,\n-- end\n\nlemma finset_sum_inv_le_tsum_pnat_inv {n : ℕ} :\n  -- ∑ k : ℕ+ in finset.Icc 1 n, ((↑k)⁻¹ : nnreal) ≤ \n  harmonic n ≤ ∑' k : ↥(pnat_fac_le n), (↑k)⁻¹ :=\nbegin\n  rw harmonic,\n  rw ← coe_pnat_fac_le_range_eq,\n  rw finset.sum_image,\n  { rw ← ennreal.coe_le_coe,\n    push_cast,\n    -- Should be possible to avoid need for summable proof here?\n    rw ennreal.coe_tsum (sum_inv_pnat_fac_le_eq_prod_geom_series n).summable,\n    apply ennreal.sum_le_tsum, },\n  { simp, },\nend\n\nlemma log_le_card_primes {n : ℕ} : \n  log (↑n + 1) ≤ ↑(finset.card (primes_le n) + 1) :=\nbegin\n  apply le_trans log_add_one_le_harmonic,\n  norm_cast,\n  apply le_trans finset_sum_inv_le_tsum_pnat_inv,\n  -- rw (by simp : ∀ {x : ℕ}, (↑x : ℝ) = ((↑x : nnreal) : ℝ)),\n  -- norm_cast,\n  rw has_sum.tsum_eq (sum_inv_pnat_fac_le_eq_prod_geom_series n),\n  apply le_trans _ (prod_geom_series_primes_eq _),\n  push_cast,\n  apply le_of_eq,\n  apply finset.prod_congr rfl,\n  intros p _,\n  simp,\n  rw nnreal.coe_sub _,\n  { simp, },\n  simp,\n  norm_cast,\n  simp,\nend\n\n\ntheorem infinite_primes : tendsto (λ n, finset.card (primes_le n)) at_top at_top :=\nbegin\n  sorry,\nend\n", "meta": {"author": "jvlmdr", "repo": "from_the_book", "sha": "d4f557b920d52b69791fc939092a0dd407e895bc", "save_path": "github-repos/lean/jvlmdr-from_the_book", "path": "github-repos/lean/jvlmdr-from_the_book/from_the_book-d4f557b920d52b69791fc939092a0dd407e895bc/src/ch01_integral/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.47261209115253244}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Kenny Lau, Yury Kudryashov\n-/\nimport data.list.pairwise\nimport logic.relation\n\n/-!\n# Relation chain\n\nThis file provides basic results about `list.chain` (definition in `data.list.defs`).\nA list `[a₂, ..., aₙ]` is a `chain` starting at `a₁` with respect to the relation `r` if `r a₁ a₂`\nand `r a₂ a₃` and ... and `r aₙ₋₁ aₙ`. We write it `chain r a₁ [a₂, ..., aₙ]`.\nA graph-specialized version is in development and will hopefully be added under `combinatorics.`\nsometime soon.\n-/\n\nuniverses u v\n\nopen nat\n\nnamespace list\n\nvariables {α : Type u} {β : Type v} {R : α → α → Prop}\n\nmk_iff_of_inductive_prop list.chain list.chain_iff\n\ntheorem rel_of_chain_cons {a b : α} {l : list α}\n  (p : chain R a (b :: l)) : R a b :=\n(chain_cons.1 p).1\n\ntheorem chain_of_chain_cons {a b : α} {l : list α}\n  (p : chain R a (b :: l)) : chain R b l :=\n(chain_cons.1 p).2\n\ntheorem chain.imp' {S : α → α → Prop}\n  (HRS : ∀ ⦃a b⦄, R a b → S a b) {a b : α} (Hab : ∀ ⦃c⦄, R a c → S b c)\n  {l : list α} (p : chain R a l) : chain S b l :=\nby induction p with _ a c l r p IH generalizing b; constructor;\n   [exact Hab r, exact IH (@HRS _)]\n\ntheorem chain.imp {S : α → α → Prop}\n  (H : ∀ a b, R a b → S a b) {a : α} {l : list α} (p : chain R a l) : chain S a l :=\np.imp' H (H a)\n\ntheorem chain.iff {S : α → α → Prop}\n  (H : ∀ a b, R a b ↔ S a b) {a : α} {l : list α} : chain R a l ↔ chain S a l :=\n⟨chain.imp (λ a b, (H a b).1), chain.imp (λ a b, (H a b).2)⟩\n\ntheorem chain.iff_mem {a : α} {l : list α} :\n  chain R a l ↔ chain (λ x y, x ∈ a :: l ∧ y ∈ l ∧ R x y) a l :=\n⟨λ p, by induction p with _ a b l r p IH; constructor;\n  [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩,\n   exact IH.imp (λ a b ⟨am, bm, h⟩,\n    ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩)],\n chain.imp (λ a b h, h.2.2)⟩\n\ntheorem chain_singleton {a b : α} : chain R a [b] ↔ R a b :=\nby simp only [chain_cons, chain.nil, and_true]\n\ntheorem chain_split {a b : α} {l₁ l₂ : list α} : chain R a (l₁ ++ b :: l₂) ↔\n  chain R a (l₁ ++ [b]) ∧ chain R b l₂ :=\nby induction l₁ with x l₁ IH generalizing a;\nsimp only [*, nil_append, cons_append, chain.nil, chain_cons, and_true, and_assoc]\n\ntheorem chain_map (f : β → α) {b : β} {l : list β} :\n  chain R (f b) (map f l) ↔ chain (λ a b : β, R (f a) (f b)) b l :=\nby induction l generalizing b; simp only [map, chain.nil, chain_cons, *]\n\ntheorem chain_of_chain_map {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, S (f a) (f b) → R a b) {a : α} {l : list α}\n  (p : chain S (f a) (map f l)) : chain R a l :=\n((chain_map f).1 p).imp H\n\ntheorem chain_map_of_chain {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, R a b → S (f a) (f b)) {a : α} {l : list α}\n  (p : chain R a l) : chain S (f a) (map f l) :=\n(chain_map f).2 $ p.imp H\n\ntheorem chain_pmap_of_chain {S : β → β → Prop} {p : α → Prop}\n  {f : Π a, p a → β}\n  (H : ∀ a b ha hb, R a b → S (f a ha) (f b hb))\n  {a : α} {l : list α}\n  (hl₁ : chain R a l) (ha : p a) (hl₂ : ∀ a ∈ l, p a) :\n  chain S (f a ha) (list.pmap f l hl₂) :=\nbegin\n  induction l with lh lt l_ih generalizing a,\n  { simp },\n  { simp [H _ _ _ _ (rel_of_chain_cons hl₁), l_ih _ (chain_of_chain_cons hl₁)] }\nend\n\ntheorem chain_of_chain_pmap {S : β → β → Prop} {p : α → Prop}\n  (f : Π a, p a → β) {l : list α} (hl₁ : ∀ a ∈ l, p a)\n  {a : α} (ha : p a) (hl₂ : chain S (f a ha) (list.pmap f l hl₁))\n  (H : ∀ a b ha hb, S (f a ha) (f b hb) → R a b) :\n  chain R a l :=\nbegin\n  induction l with lh lt l_ih generalizing a,\n  { simp },\n  { simp [H _ _ _ _ (rel_of_chain_cons hl₂), l_ih _ _ (chain_of_chain_cons hl₂)] }\nend\n\ntheorem chain_of_pairwise {a : α} {l : list α} (p : pairwise R (a :: l)) : chain R a l :=\nbegin\n  cases pairwise_cons.1 p with r p', clear p,\n  induction p' with b l r' p IH generalizing a, {exact chain.nil},\n  simp only [chain_cons, forall_mem_cons] at r,\n  exact chain_cons.2 ⟨r.1, IH r'⟩\nend\n\ntheorem chain_iff_pairwise (tr : transitive R) {a : α} {l : list α} :\n  chain R a l ↔ pairwise R (a :: l) :=\n⟨λ c, begin\n  induction c with b b c l r p IH, {exact pairwise_singleton _ _},\n  apply IH.cons _, simp only [mem_cons_iff, forall_eq_or_imp, r, true_and],\n  show ∀ x ∈ l, R b x, from λ x m, (tr r (rel_of_pairwise_cons IH m)),\nend, chain_of_pairwise⟩\n\ntheorem chain_iff_nth_le {R} : ∀ {a : α} {l : list α},\n  chain R a l ↔ (∀ h : 0 < length l, R a (nth_le l 0 h)) ∧ (∀ i (h : i < length l - 1),\n    R (nth_le l i (lt_of_lt_pred h)) (nth_le l (i+1) (lt_pred_iff.mp h)))\n| a []       := by simp\n| a (b :: t) :=\nbegin\n  rw [chain_cons, chain_iff_nth_le],\n  split,\n  { rintro ⟨R, ⟨h0, h⟩⟩,\n    split,\n    { intro w, exact R },\n    intros i w,\n    cases i,\n    { apply h0 },\n    convert h i _ using 1,\n    simp only [succ_eq_add_one, add_succ_sub_one, add_zero, length, add_lt_add_iff_right] at w,\n    exact lt_pred_iff.mpr w, },\n  rintro ⟨h0, h⟩, split,\n  { apply h0, simp, },\n  split,\n  { apply h 0, },\n  intros i w, convert h (i+1) _ using 1,\n  exact lt_pred_iff.mp w,\nend\n\ntheorem chain'.imp {S : α → α → Prop}\n  (H : ∀ a b, R a b → S a b) {l : list α} (p : chain' R l) : chain' S l :=\nby cases l; [trivial, exact p.imp H]\n\ntheorem chain'.iff {S : α → α → Prop}\n  (H : ∀ a b, R a b ↔ S a b) {l : list α} : chain' R l ↔ chain' S l :=\n⟨chain'.imp (λ a b, (H a b).1), chain'.imp (λ a b, (H a b).2)⟩\n\ntheorem chain'.iff_mem : ∀ {l : list α}, chain' R l ↔ chain' (λ x y, x ∈ l ∧ y ∈ l ∧ R x y) l\n| []       := iff.rfl\n| (x :: l) :=\n  ⟨λ h, (chain.iff_mem.1 h).imp $ λ a b ⟨h₁, h₂, h₃⟩, ⟨h₁, or.inr h₂, h₃⟩,\n   chain'.imp $ λ a b h, h.2.2⟩\n\n@[simp] theorem chain'_nil : chain' R [] := trivial\n\n@[simp] theorem chain'_singleton (a : α) : chain' R [a] := chain.nil\n\ntheorem chain'_split {a : α} : ∀ {l₁ l₂ : list α}, chain' R (l₁ ++ a :: l₂) ↔\n  chain' R (l₁ ++ [a]) ∧ chain' R (a :: l₂)\n| []        l₂ := (and_iff_right (chain'_singleton a)).symm\n| (b :: l₁) l₂ := chain_split\n\ntheorem chain'_map (f : β → α) {l : list β} :\n  chain' R (map f l) ↔ chain' (λ a b : β, R (f a) (f b)) l :=\nby cases l; [refl, exact chain_map _]\n\ntheorem chain'_of_chain'_map {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, S (f a) (f b) → R a b) {l : list α}\n  (p : chain' S (map f l)) : chain' R l :=\n((chain'_map f).1 p).imp H\n\ntheorem chain'_map_of_chain' {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, R a b → S (f a) (f b)) {l : list α}\n  (p : chain' R l) : chain' S (map f l) :=\n(chain'_map f).2 $ p.imp H\n\ntheorem pairwise.chain' : ∀ {l : list α}, pairwise R l → chain' R l\n| []       _ := trivial\n| (a :: l) h := chain_of_pairwise h\n\ntheorem chain'_iff_pairwise (tr : transitive R) : ∀ {l : list α},\n  chain' R l ↔ pairwise R l\n| []       := (iff_true_intro pairwise.nil).symm\n| (a :: l) := chain_iff_pairwise tr\n\n@[simp] theorem chain'_cons {x y l} : chain' R (x :: y :: l) ↔ R x y ∧ chain' R (y :: l) :=\nchain_cons\n\ntheorem chain'.cons {x y l} (h₁ : R x y) (h₂ : chain' R (y :: l)) :\n  chain' R (x :: y :: l) :=\nchain'_cons.2 ⟨h₁, h₂⟩\n\ntheorem chain'.tail : ∀ {l} (h : chain' R l), chain' R l.tail\n| []            _ := trivial\n| [x]           _ := trivial\n| (x :: y :: l) h := (chain'_cons.mp h).right\n\ntheorem chain'.rel_head {x y l} (h : chain' R (x :: y :: l)) : R x y :=\nrel_of_chain_cons h\n\ntheorem chain'.rel_head' {x l} (h : chain' R (x :: l)) ⦃y⦄ (hy : y ∈ head' l) : R x y :=\nby { rw ← cons_head'_tail hy at h, exact h.rel_head }\n\ntheorem chain'.cons' {x} :\n  ∀ {l : list α},  chain' R l → (∀ y ∈ l.head', R x y) → chain' R (x :: l)\n| []       _  _ := chain'_singleton x\n| (a :: l) hl H := hl.cons $ H _ rfl\n\ntheorem chain'_cons' {x l} : chain' R (x :: l) ↔ (∀ y ∈ head' l, R x y) ∧ chain' R l :=\n⟨λ h, ⟨h.rel_head', h.tail⟩, λ ⟨h₁, h₂⟩, h₂.cons' h₁⟩\n\ntheorem chain'.drop : ∀ (n) {l} (h : chain' R l), chain' R (drop n l)\n| 0       _             h := h\n| _       []            _ := by {rw drop_nil, exact chain'_nil}\n| (n + 1) [a]           _ := by {unfold drop, rw drop_nil, exact chain'_nil}\n| (n + 1) (a :: b :: l) h := chain'.drop n (chain'_cons'.mp h).right\n\ntheorem chain'.append : ∀ {l₁ l₂ : list α} (h₁ : chain' R l₁) (h₂ : chain' R l₂)\n  (h : ∀ (x ∈ l₁.last') (y ∈ l₂.head'), R x y),\n  chain' R (l₁ ++ l₂)\n| []            l₂ h₁ h₂ h := h₂\n| [a]           l₂ h₁ h₂ h := h₂.cons' $ h _ rfl\n| (a :: b :: l) l₂ h₁ h₂ h :=\n  begin\n    simp only [last'] at h,\n    have : chain' R (b :: l) := h₁.tail,\n    exact (this.append h₂ h).cons h₁.rel_head\n  end\n\ntheorem chain'_pair {x y} : chain' R [x, y] ↔ R x y :=\nby simp only [chain'_singleton, chain'_cons, and_true]\n\ntheorem chain'.imp_head {x y} (h : ∀ {z}, R x z → R y z) {l} (hl : chain' R (x :: l)) :\n  chain' R (y :: l) :=\nhl.tail.cons' $ λ z hz, h $ hl.rel_head' hz\n\ntheorem chain'_reverse : ∀ {l}, chain' R (reverse l) ↔ chain' (flip R) l\n| []            := iff.rfl\n| [a]           := by simp only [chain'_singleton, reverse_singleton]\n| (a :: b :: l) := by rw [chain'_cons, reverse_cons, reverse_cons, append_assoc, cons_append,\n    nil_append, chain'_split, ← reverse_cons, @chain'_reverse (b :: l), and_comm, chain'_pair, flip]\n\ntheorem chain'_iff_nth_le {R} : ∀ {l : list α},\n  chain' R l ↔ ∀ i (h : i < length l - 1),\n    R (nth_le l i (lt_of_lt_pred h)) (nth_le l (i+1) (lt_pred_iff.mp h))\n| []            := by simp\n| [a]           := by simp\n| (a :: b :: t) :=\nbegin\n  rw [chain'_cons, chain'_iff_nth_le],\n  split,\n  { rintro ⟨R, h⟩ i w,\n    cases i,\n    { exact R, },\n    { convert h i _ using 1,\n      simp only [succ_eq_add_one, add_succ_sub_one, add_zero, length, add_lt_add_iff_right] at w,\n      simpa using w, } },\n  { rintro h, split,\n    { apply h 0, simp, },\n    { intros i w, convert h (i+1) _ using 1,\n      simp only [add_zero, length, add_succ_sub_one] at w,\n      simpa using w, } },\nend\n\n/-- If `l₁ l₂` and `l₃` are lists and `l₁ ++ l₂` and `l₂ ++ l₃` both satisfy\n  `chain' R`, then so does `l₁ ++ l₂ ++ l₃` provided `l₂ ≠ []` -/\nlemma chain'.append_overlap : ∀ {l₁ l₂ l₃ : list α}\n  (h₁ : chain' R (l₁ ++ l₂)) (h₂ : chain' R (l₂ ++ l₃)) (hn : l₂ ≠ []),\n  chain' R (l₁ ++ l₂ ++ l₃)\n| []             l₂        l₃ h₁ h₂ hn := h₂\n| l₁             []        l₃ h₁ h₂ hn := (hn rfl).elim\n| [a]            (b :: l₂) l₃ h₁ h₂ hn := by { simp at *, tauto }\n| (a :: b :: l₁) (c :: l₂) l₃ h₁ h₂ hn := begin\n  simp only [cons_append, chain'_cons] at h₁ h₂ ⊢,\n  simp only [← cons_append] at h₁ h₂ ⊢,\n  exact ⟨h₁.1, chain'.append_overlap h₁.2 h₂ (cons_ne_nil _ _)⟩\nend\n\nvariables {r : α → α → Prop} {a b : α}\n/--\nIf `a` and `b` are related by the reflexive transitive closure of `r`, then there is a `r`-chain\nstarting from `a` and ending on `b`.\nThe converse of `relation_refl_trans_gen_of_exists_chain`.\n-/\nlemma exists_chain_of_relation_refl_trans_gen (h : relation.refl_trans_gen r a b) :\n  ∃ l, chain r a l ∧ last (a :: l) (cons_ne_nil _ _) = b :=\nbegin\n  apply relation.refl_trans_gen.head_induction_on h,\n  { exact ⟨[], chain.nil, rfl⟩ },\n  { intros c d e t ih,\n    obtain ⟨l, hl₁, hl₂⟩ := ih,\n    refine ⟨d :: l, chain.cons e hl₁, _⟩,\n    rwa last_cons_cons }\nend\n\n/--\nGiven a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then\nthe predicate is true everywhere in the chain and at `a`.\nThat is, we can propagate the predicate up the chain.\n-/\nlemma chain.induction (p : α → Prop)\n  (l : list α) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : ∀ i ∈ a :: l, p i :=\nbegin\n  induction l generalizing a,\n  { cases hb,\n    simp [final] },\n  { rw chain_cons at h,\n    rintro _ (rfl | _),\n    apply carries h.1 (l_ih h.2 hb _ (or.inl rfl)),\n    apply l_ih h.2 hb _ H }\nend\n\n/--\nGiven a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then\nthe predicate is true at `a`.\nThat is, we can propagate the predicate all the way up the chain.\n-/\n@[elab_as_eliminator]\nlemma chain.induction_head (p : α → Prop)\n  (l : list α) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : p a :=\n(chain.induction p l h hb carries final) _ (mem_cons_self _ _)\n\n/--\nIf there is an `r`-chain starting from `a` and ending at `b`, then `a` and `b` are related by the\nreflexive transitive closure of `r`. The converse of `exists_chain_of_relation_refl_trans_gen`.\n-/\nlemma relation_refl_trans_gen_of_exists_chain (l) (hl₁ : chain r a l)\n  (hl₂ : last (a :: l) (cons_ne_nil _ _) = b) :\n  relation.refl_trans_gen r a b :=\nchain.induction_head _ l hl₁ hl₂ (λ x y, relation.refl_trans_gen.head) relation.refl_trans_gen.refl\n\nend list\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/list/chain.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190477, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.4725313890928365}}
{"text": "/-\nCopyright (c) 2020 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.invertible\nimport algebra.lie.skew_adjoint\nimport algebra.lie.abelian\n\n/-!\n# Classical Lie algebras\n\nThis file is the place to find definitions and basic properties of the classical Lie algebras:\n  * Aₗ = sl(l+1)\n  * Bₗ ≃ so(l+1, l) ≃ so(2l+1)\n  * Cₗ = sp(l)\n  * Dₗ ≃ so(l, l) ≃ so(2l)\n\n## Main definitions\n\n  * `lie_algebra.special_linear.sl`\n  * `lie_algebra.symplectic.sp`\n  * `lie_algebra.orthogonal.so`\n  * `lie_algebra.orthogonal.so'`\n  * `lie_algebra.orthogonal.so_indefinite_equiv`\n  * `lie_algebra.orthogonal.type_D`\n  * `lie_algebra.orthogonal.type_B`\n  * `lie_algebra.orthogonal.type_D_equiv_so'`\n  * `lie_algebra.orthogonal.type_B_equiv_so'`\n\n## Implementation notes\n\n### Matrices or endomorphisms\n\nGiven a finite type and a commutative ring, the corresponding square matrices are equivalent to the\nendomorphisms of the corresponding finite-rank free module as Lie algebras, see `lie_equiv_matrix'`.\nWe can thus define the classical Lie algebras as Lie subalgebras either of matrices or of\nendomorphisms. We have opted for the former. At the time of writing (August 2020) it is unclear\nwhich approach should be preferred so the choice should be assumed to be somewhat arbitrary.\n\n### Diagonal quadratic form or diagonal Cartan subalgebra\n\nFor the algebras of type `B` and `D`, there are two natural definitions. For example since the\nthe `2l × 2l` matrix:\n$$\n  J = \\left[\\begin{array}{cc}\n              0_l & 1_l\\\\\n              1_l & 0_l\n            \\end{array}\\right]\n$$\ndefines a symmetric bilinear form equivalent to that defined by the identity matrix `I`, we can\ndefine the algebras of type `D` to be the Lie subalgebra of skew-adjoint matrices either for `J` or\nfor `I`. Both definitions have their advantages (in particular the `J`-skew-adjoint matrices define\na Lie algebra for which the diagonal matrices form a Cartan subalgebra) and so we provide both.\nWe thus also provide equivalences `type_D_equiv_so'`, `so_indefinite_equiv` which show the two\ndefinitions are equivalent. Similarly for the algebras of type `B`.\n\n## Tags\n\nclassical lie algebra, special linear, symplectic, orthogonal\n-/\n\nuniverses u₁ u₂\n\nnamespace lie_algebra\nopen_locale matrix\n\nvariables (n p q l : Type*) (R : Type u₂)\nvariables [fintype n] [fintype l] [fintype p] [fintype q]\nvariables [decidable_eq n] [decidable_eq p] [decidable_eq q] [decidable_eq l]\nvariables [comm_ring R]\n\n@[simp] lemma matrix_trace_commutator_zero (X Y : matrix n n R) : matrix.trace n R R ⁅X, Y⁆ = 0 :=\nbegin\n  -- TODO: if we use matrix.mul here, we get a timeout\n  change matrix.trace n R R (X * Y - Y * X) = 0,\n  erw [linear_map.map_sub, matrix.trace_mul_comm, sub_self]\nend\n\nnamespace special_linear\n\n/-- The special linear Lie algebra: square matrices of trace zero. -/\ndef sl : lie_subalgebra R (matrix n n R) :=\n{ lie_mem' := λ X Y _ _, linear_map.mem_ker.2 $ matrix_trace_commutator_zero _ _ _ _,\n  ..linear_map.ker (matrix.trace n R R) }\n\nlemma sl_bracket (A B : sl n R) : ⁅A, B⁆.val = A.val ⬝ B.val - B.val ⬝ A.val := rfl\n\nsection elementary_basis\n\nvariables {n} (i j : n)\n\n/-- It is useful to define these matrices for explicit calculations in sl n R. -/\nabbreviation E : matrix n n R := λ i' j', if i = i' ∧ j = j' then 1 else 0\n\n@[simp] lemma E_apply_one : E R i j i j = 1 := if_pos (and.intro rfl rfl)\n\n@[simp] lemma E_apply_zero (i' j' : n) (h : ¬(i = i' ∧ j = j')) : E R i j i' j' = 0 := if_neg h\n\n@[simp] lemma E_diag_zero (h : j ≠ i) : matrix.diag n R R (E R i j) = 0 :=\nbegin\n  ext k, rw matrix.diag_apply,\n  suffices : ¬(i = k ∧ j = k), by exact if_neg this,\n  rintros ⟨e₁, e₂⟩, apply h, subst e₁, exact e₂,\nend\n\nlemma E_trace_zero (h : j ≠ i) : matrix.trace n R R (E R i j) = 0 := by simp [h]\n\n/-- When j ≠ i, the elementary matrices are elements of sl n R, in fact they are part of a natural\nbasis of sl n R. -/\ndef Eb (h : j ≠ i) : sl n R :=\n⟨E R i j, by { change E R i j ∈ linear_map.ker (matrix.trace n R R), simp [E_trace_zero R i j h], }⟩\n\n@[simp] lemma Eb_val (h : j ≠ i) : (Eb R i j h).val = E R i j := rfl\n\nend elementary_basis\n\n\n\nend special_linear\n\nnamespace symplectic\n\n/-- The matrix defining the canonical skew-symmetric bilinear form. -/\ndef J : matrix (l ⊕ l) (l ⊕ l) R := matrix.from_blocks 0 (-1) 1 0\n\n/-- The symplectic Lie algebra: skew-adjoint matrices with respect to the canonical skew-symmetric\nbilinear form. -/\ndef sp : lie_subalgebra R (matrix (l ⊕ l) (l ⊕ l) R) :=\n  skew_adjoint_matrices_lie_subalgebra (J l R)\n\nend symplectic\n\nnamespace orthogonal\n\n/-- The definite orthogonal Lie subalgebra: skew-adjoint matrices with respect to the symmetric\nbilinear form defined by the identity matrix. -/\ndef so : lie_subalgebra R (matrix n n R) :=\n  skew_adjoint_matrices_lie_subalgebra (1 : matrix n n R)\n\n@[simp] lemma mem_so (A : matrix n n R) : A ∈ so n R ↔ Aᵀ = -A :=\nbegin\n  erw mem_skew_adjoint_matrices_submodule,\n  simp only [matrix.is_skew_adjoint, matrix.is_adjoint_pair, matrix.mul_one, matrix.one_mul],\nend\n\n/-- The indefinite diagonal matrix with `p` 1s and `q` -1s. -/\ndef indefinite_diagonal : matrix (p ⊕ q) (p ⊕ q) R :=\n  matrix.diagonal $ sum.elim (λ _, 1) (λ _, -1)\n\n/-- The indefinite orthogonal Lie subalgebra: skew-adjoint matrices with respect to the symmetric\nbilinear form defined by the indefinite diagonal matrix. -/\ndef so' : lie_subalgebra R (matrix (p ⊕ q) (p ⊕ q) R) :=\n  skew_adjoint_matrices_lie_subalgebra $ indefinite_diagonal p q R\n\n/-- A matrix for transforming the indefinite diagonal bilinear form into the definite one, provided\nthe parameter `i` is a square root of -1. -/\ndef Pso (i : R) : matrix (p ⊕ q) (p ⊕ q) R :=\n  matrix.diagonal $ sum.elim (λ _, 1) (λ _, i)\n\nlemma Pso_inv {i : R} (hi : i*i = -1) : (Pso p q R i) * (Pso p q R (-i)) = 1 :=\nbegin\n  ext x y, rcases x; rcases y,\n  { -- x y : p\n    by_cases h : x = y; simp [Pso, indefinite_diagonal, h], },\n  { -- x : p, y : q\n    simp [Pso, indefinite_diagonal], },\n  { -- x : q, y : p\n    simp [Pso, indefinite_diagonal], },\n  { -- x y : q\n    by_cases h : x = y; simp [Pso, indefinite_diagonal, h, hi], },\nend\n\nlemma is_unit_Pso {i : R} (hi : i*i = -1) : is_unit (Pso p q R i) :=\n⟨{ val     := Pso p q R i,\n   inv     := Pso p q R (-i),\n   val_inv := Pso_inv p q R hi,\n   inv_val := by { apply matrix.nonsing_inv_left_right, exact Pso_inv p q R hi, }, },\nrfl⟩\n\nlemma indefinite_diagonal_transform {i : R} (hi : i*i = -1) :\n  (Pso p q R i)ᵀ ⬝ (indefinite_diagonal p q R) ⬝ (Pso p q R i) = 1 :=\nbegin\n  ext x y, rcases x; rcases y,\n  { -- x y : p\n    by_cases h : x = y; simp [Pso, indefinite_diagonal, h], },\n  { -- x : p, y : q\n    simp [Pso, indefinite_diagonal], },\n  { -- x : q, y : p\n    simp [Pso, indefinite_diagonal], },\n  { -- x y : q\n    by_cases h : x = y; simp [Pso, indefinite_diagonal, h, hi], },\nend\n\n/-- An equivalence between the indefinite and definite orthogonal Lie algebras, over a ring\ncontaining a square root of -1. -/\nnoncomputable def so_indefinite_equiv {i : R} (hi : i*i = -1) : so' p q R ≃ₗ⁅R⁆ so (p ⊕ q) R :=\nbegin\n  apply (skew_adjoint_matrices_lie_subalgebra_equiv\n    (indefinite_diagonal p q R) (Pso p q R i) (is_unit_Pso p q R hi)).trans,\n  apply lie_equiv.of_eq,\n  ext A, rw indefinite_diagonal_transform p q R hi, refl,\nend\n\nlemma so_indefinite_equiv_apply {i : R} (hi : i*i = -1) (A : so' p q R) :\n  (so_indefinite_equiv p q R hi A : matrix (p ⊕ q) (p ⊕ q) R) =\n    (Pso p q R i)⁻¹ ⬝ (A : matrix (p ⊕ q) (p ⊕ q) R) ⬝ (Pso p q R i) :=\nby erw [lie_equiv.trans_apply, lie_equiv.of_eq_apply,\n        skew_adjoint_matrices_lie_subalgebra_equiv_apply]\n\n/-- A matrix defining a canonical even-rank symmetric bilinear form.\n\nIt looks like this as a `2l x 2l` matrix of `l x l` blocks:\n\n   [ 0 1 ]\n   [ 1 0 ]\n-/\ndef JD : matrix (l ⊕ l) (l ⊕ l) R := matrix.from_blocks 0 1 1 0\n\n/-- The classical Lie algebra of type D as a Lie subalgebra of matrices associated to the matrix\n`JD`. -/\ndef type_D := skew_adjoint_matrices_lie_subalgebra (JD l R)\n\n/-- A matrix transforming the bilinear form defined by the matrix `JD` into a split-signature\ndiagonal matrix.\n\nIt looks like this as a `2l x 2l` matrix of `l x l` blocks:\n\n   [ 1 -1 ]\n   [ 1  1 ]\n-/\ndef PD : matrix (l ⊕ l) (l ⊕ l) R := matrix.from_blocks 1 (-1) 1 1\n\n/-- The split-signature diagonal matrix. -/\ndef S := indefinite_diagonal l l R\n\nlemma S_as_blocks : S l R = matrix.from_blocks 1 0 0 (-1) :=\nbegin\n  rw [← matrix.diagonal_one, matrix.diagonal_neg, matrix.from_blocks_diagonal],\n  refl,\nend\n\nlemma JD_transform : (PD l R)ᵀ ⬝ (JD l R) ⬝ (PD l R) = (2 : R) • (S l R) :=\nbegin\n  have h : (PD l R)ᵀ ⬝ (JD l R) = matrix.from_blocks 1 1 1 (-1) := by\n  { simp [PD, JD, matrix.from_blocks_transpose, matrix.from_blocks_multiply], },\n  erw [h, S_as_blocks, matrix.from_blocks_multiply, matrix.from_blocks_smul],\n  congr; simp [two_smul],\nend\n\nlemma PD_inv [invertible (2 : R)] : (PD l R) * (⅟(2 : R) • (PD l R)ᵀ) = 1 :=\nbegin\n  have h : ⅟(2 : R) • (1 : matrix l l R) + ⅟(2 : R) • 1 = 1 := by\n    rw [← smul_add, ← (two_smul R _), smul_smul, inv_of_mul_self, one_smul],\n  erw [matrix.from_blocks_transpose, matrix.from_blocks_smul, matrix.mul_eq_mul,\n    matrix.from_blocks_multiply],\n  simp [h],\nend\n\nlemma is_unit_PD [invertible (2 : R)] : is_unit (PD l R) :=\n⟨{ val     := PD l R,\n   inv     := ⅟(2 : R) • (PD l R)ᵀ,\n   val_inv := PD_inv l R,\n   inv_val := by { apply matrix.nonsing_inv_left_right, exact PD_inv l R, }, },\nrfl⟩\n\n/-- An equivalence between two possible definitions of the classical Lie algebra of type D. -/\nnoncomputable def type_D_equiv_so' [invertible (2 : R)] :\n  type_D l R ≃ₗ⁅R⁆ so' l l R :=\nbegin\n  apply (skew_adjoint_matrices_lie_subalgebra_equiv (JD l R) (PD l R) (is_unit_PD l R)).trans,\n  apply lie_equiv.of_eq,\n  ext A,\n  rw [JD_transform, ← unit_of_invertible_val (2 : R), lie_subalgebra.mem_coe,\n      mem_skew_adjoint_matrices_lie_subalgebra_unit_smul],\n  refl,\nend\n\n/-- A matrix defining a canonical odd-rank symmetric bilinear form.\n\nIt looks like this as a `(2l+1) x (2l+1)` matrix of blocks:\n\n   [ 2 0 0 ]\n   [ 0 0 1 ]\n   [ 0 1 0 ]\n\nwhere sizes of the blocks are:\n\n   [`1 x 1` `1 x l` `1 x l`]\n   [`l x 1` `l x l` `l x l`]\n   [`l x 1` `l x l` `l x l`]\n-/\ndef JB := matrix.from_blocks ((2 : R) • 1 : matrix unit unit R) 0 0 (JD l R)\n\n/-- The classical Lie algebra of type B as a Lie subalgebra of matrices associated to the matrix\n`JB`. -/\ndef type_B := skew_adjoint_matrices_lie_subalgebra (JB l R)\n\n/-- A matrix transforming the bilinear form defined by the matrix `JB` into an\nalmost-split-signature diagonal matrix.\n\nIt looks like this as a `(2l+1) x (2l+1)` matrix of blocks:\n\n   [ 1 0  0 ]\n   [ 0 1 -1 ]\n   [ 0 1  1 ]\n\nwhere sizes of the blocks are:\n\n   [`1 x 1` `1 x l` `1 x l`]\n   [`l x 1` `l x l` `l x l`]\n   [`l x 1` `l x l` `l x l`]\n-/\ndef PB := matrix.from_blocks (1 : matrix unit unit R) 0 0 (PD l R)\n\nlemma PB_inv [invertible (2 : R)] : (PB l R) * (matrix.from_blocks 1 0 0 (PD l R)⁻¹) = 1 :=\nbegin\n  simp [PB, matrix.from_blocks_multiply, (PD l R).mul_nonsing_inv, is_unit_PD,\n        ← (PD l R).is_unit_iff_is_unit_det]\nend\n\nlemma is_unit_PB [invertible (2 : R)] : is_unit (PB l R) :=\n⟨{ val     := PB l R,\n   inv     := matrix.from_blocks 1 0 0 (PD l R)⁻¹,\n   val_inv := PB_inv l R,\n   inv_val := by { apply matrix.nonsing_inv_left_right, exact PB_inv l R, }, },\nrfl⟩\n\nlemma JB_transform : (PB l R)ᵀ ⬝ (JB l R) ⬝ (PB l R) = (2 : R) • matrix.from_blocks 1 0 0 (S l R) :=\nby simp [PB, JB, JD_transform, matrix.from_blocks_transpose, matrix.from_blocks_multiply,\n         matrix.from_blocks_smul]\n\nlemma indefinite_diagonal_assoc :\n  indefinite_diagonal (unit ⊕ l) l R =\n  matrix.reindex_lie_equiv (equiv.sum_assoc unit l l).symm\n    (matrix.from_blocks 1 0 0 (indefinite_diagonal l l R)) :=\nbegin\n  ext i j,\n  rcases i with ⟨⟨i₁ | i₂⟩ | i₃⟩;\n  rcases j with ⟨⟨j₁ | j₂⟩ | j₃⟩;\n  simp [indefinite_diagonal, matrix.diagonal],\nend\n\n/-- An equivalence between two possible definitions of the classical Lie algebra of type B. -/\nnoncomputable def type_B_equiv_so' [invertible (2 : R)] :\n  type_B l R ≃ₗ⁅R⁆ so' (unit ⊕ l) l R :=\nbegin\n  apply (skew_adjoint_matrices_lie_subalgebra_equiv (JB l R) (PB l R) (is_unit_PB l R)).trans,\n  symmetry,\n  apply (skew_adjoint_matrices_lie_subalgebra_equiv_transpose\n    (indefinite_diagonal (unit ⊕ l) l R)\n    (matrix.reindex_alg_equiv (equiv.sum_assoc punit l l)) (matrix.transpose_reindex _ _)).trans,\n  apply lie_equiv.of_eq,\n  ext A,\n  rw [JB_transform, ← unit_of_invertible_val (2 : R), lie_subalgebra.mem_coe,\n      lie_subalgebra.mem_coe, mem_skew_adjoint_matrices_lie_subalgebra_unit_smul],\n  simpa [indefinite_diagonal_assoc],\nend\n\nend orthogonal\n\nend lie_algebra\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/lie/classical.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.4725313802915214}}
{"text": "/-\nCopyright (c) 2020 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.list.basic\nimport Mathlib.data.list.defs\nimport Mathlib.logic.basic\nimport Mathlib.PostPort\n\nuniverses u v u_1 \n\nnamespace Mathlib\n\nnamespace list\n\n\n/-- Specification of `foldr_with_index_aux`. -/\ndef foldr_with_index_aux_spec {α : Type u} {β : Type v} (f : ℕ → α → β → β) (start : ℕ) (b : β) (as : List α) : β :=\n  foldr (function.uncurry f) b (enum_from start as)\n\ntheorem foldr_with_index_aux_spec_cons {α : Type u} {β : Type v} (f : ℕ → α → β → β) (start : ℕ) (b : β) (a : α) (as : List α) : foldr_with_index_aux_spec f start b (a :: as) = f start a (foldr_with_index_aux_spec f (start + 1) b as) :=\n  rfl\n\ntheorem foldr_with_index_aux_eq_foldr_with_index_aux_spec {α : Type u} {β : Type v} (f : ℕ → α → β → β) (start : ℕ) (b : β) (as : List α) : foldr_with_index_aux f start b as = foldr_with_index_aux_spec f start b as := sorry\n\ntheorem foldr_with_index_eq_foldr_enum {α : Type u} {β : Type v} (f : ℕ → α → β → β) (b : β) (as : List α) : foldr_with_index f b as = foldr (function.uncurry f) b (enum as) := sorry\n\ntheorem indexes_values_eq_filter_enum {α : Type u} (p : α → Prop) [decidable_pred p] (as : List α) : indexes_values p as = filter (p ∘ prod.snd) (enum as) := sorry\n\ntheorem find_indexes_eq_map_indexes_values {α : Type u} (p : α → Prop) [decidable_pred p] (as : List α) : find_indexes p as = map prod.fst (indexes_values p as) := sorry\n\n/-- Specification of `foldl_with_index_aux`. -/\ndef foldl_with_index_aux_spec {α : Type u} {β : Type v} (f : ℕ → α → β → α) (start : ℕ) (a : α) (bs : List β) : α :=\n  foldl (fun (a : α) (p : ℕ × β) => f (prod.fst p) a (prod.snd p)) a (enum_from start bs)\n\ntheorem foldl_with_index_aux_spec_cons {α : Type u} {β : Type v} (f : ℕ → α → β → α) (start : ℕ) (a : α) (b : β) (bs : List β) : foldl_with_index_aux_spec f start a (b :: bs) = foldl_with_index_aux_spec f (start + 1) (f start a b) bs :=\n  rfl\n\ntheorem foldl_with_index_aux_eq_foldl_with_index_aux_spec {α : Type u} {β : Type v} (f : ℕ → α → β → α) (start : ℕ) (a : α) (bs : List β) : foldl_with_index_aux f start a bs = foldl_with_index_aux_spec f start a bs := sorry\n\ntheorem foldl_with_index_eq_foldl_enum {α : Type u} {β : Type v} (f : ℕ → α → β → α) (a : α) (bs : List β) : foldl_with_index f a bs = foldl (fun (a : α) (p : ℕ × β) => f (prod.fst p) a (prod.snd p)) a (enum bs) := sorry\n\ntheorem mfoldr_with_index_eq_mfoldr_enum {m : Type u → Type v} [Monad m] {α : Type u_1} {β : Type u} (f : ℕ → α → β → m β) (b : β) (as : List α) : mfoldr_with_index f b as = mfoldr (function.uncurry f) b (enum as) := sorry\n\ntheorem mfoldl_with_index_eq_mfoldl_enum {m : Type u → Type v} [Monad m] [is_lawful_monad m] {α : Type u_1} {β : Type u} (f : ℕ → β → α → m β) (b : β) (as : List α) : mfoldl_with_index f b as = mfoldl (fun (b : β) (p : ℕ × α) => f (prod.fst p) b (prod.snd p)) b (enum as) := sorry\n\n/-- Specification of `mmap_with_index_aux`. -/\ndef mmap_with_index_aux_spec {m : Type u → Type v} [Applicative m] {α : Type u_1} {β : Type u} (f : ℕ → α → m β) (start : ℕ) (as : List α) : m (List β) :=\n  list.traverse (function.uncurry f) (enum_from start as)\n\n-- Note: `traverse` the class method would require a less universe-polymorphic\n\n-- `m : Type u → Type u`.\n\ntheorem mmap_with_index_aux_spec_cons {m : Type u → Type v} [Applicative m] {α : Type u_1} {β : Type u} (f : ℕ → α → m β) (start : ℕ) (a : α) (as : List α) : mmap_with_index_aux_spec f start (a :: as) = List.cons <$> f start a <*> mmap_with_index_aux_spec f (start + 1) as :=\n  rfl\n\ntheorem mmap_with_index_aux_eq_mmap_with_index_aux_spec {m : Type u → Type v} [Applicative m] {α : Type u_1} {β : Type u} (f : ℕ → α → m β) (start : ℕ) (as : List α) : mmap_with_index_aux f start as = mmap_with_index_aux_spec f start as := sorry\n\ntheorem mmap_with_index_eq_mmap_enum {m : Type u → Type v} [Applicative m] {α : Type u_1} {β : Type u} (f : ℕ → α → m β) (as : List α) : mmap_with_index f as = list.traverse (function.uncurry f) (enum as) := sorry\n\ntheorem mmap_with_index'_aux_eq_mmap_with_index_aux {m : Type u → Type v} [Applicative m] [is_lawful_applicative m] {α : Type u_1} (f : ℕ → α → m PUnit) (start : ℕ) (as : List α) : mmap_with_index'_aux f start as = mmap_with_index_aux f start as *> pure PUnit.unit := sorry\n\ntheorem mmap_with_index'_eq_mmap_with_index {m : Type u → Type v} [Applicative m] [is_lawful_applicative m] {α : Type u_1} (f : ℕ → α → m PUnit) (as : List α) : mmap_with_index' f as = mmap_with_index f as *> pure PUnit.unit :=\n  mmap_with_index'_aux_eq_mmap_with_index_aux f 0 as\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/list/indexes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592642, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.47253137149020635}}
{"text": "attribute [local simp] Nat.mul_comm Nat.mul_assoc Nat.mul_left_comm\nattribute [local simp] Nat.add_assoc Nat.add_comm Nat.add_left_comm\nexample (w x y z : Nat) (p : Nat → Prop)\n        (h : p (x * y + z * w  * x)) : p (x * w * z + y * x) := by\n  simp at *; assumption\n\nexample (x y z : Nat) (p : Nat → Prop)\n        (h₁ : p (1 * x + y)) (h₂ : p  (x * z * 1))\n        : p (y + 0 + x) ∧ p (z * x) := by\n  simp at * <;> constructor <;> assumption\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/ACltBug.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4723365038218563}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.zero\nimport Mathlib.category_theory.limits.shapes.kernels\nimport Mathlib.category_theory.abelian.basic\nimport Mathlib.PostPort\n\nuniverses v u l \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/-- An object is simple if monomorphisms into it are (exclusively) either isomorphisms or zero. -/\n-- This is a constructive definition, from which we can extract an inverse for `f` given `f ≠ 0`.\n\n-- We show below that although it contains data, it is a subsingleton.\n\nclass simple {C : Type u} [category C] [limits.has_zero_morphisms C] (X : C) where\n  mono_is_iso_equiv_nonzero : {Y : C} → (f : Y ⟶ X) → [_inst_3 : mono f] → is_iso f ≃ f ≠ 0\n\ntheorem simple.ext {C : Type u} [category C] [limits.has_zero_morphisms C] {X : C} {a : simple X}\n    {b : simple X} : a = b :=\n  sorry\n\nprotected instance subsingleton_simple {C : Type u} [category C] [limits.has_zero_morphisms C]\n    (X : C) : subsingleton (simple X) :=\n  subsingleton.intro simple.ext\n\n/-- A nonzero monomorphism to a simple object is an isomorphism. -/\ndef is_iso_of_mono_of_nonzero {C : Type u} [category C] [limits.has_zero_morphisms C] {X : C}\n    {Y : C} [simple Y] {f : X ⟶ Y} [mono f] (w : f ≠ 0) : is_iso f :=\n  coe_fn (equiv.symm (simple.mono_is_iso_equiv_nonzero f)) w\n\ntheorem kernel_zero_of_nonzero_from_simple {C : Type u} [category C] [limits.has_zero_morphisms C]\n    {X : C} {Y : C} [simple X] {f : X ⟶ Y} [limits.has_kernel f] (w : f ≠ 0) :\n    limits.kernel.ι f = 0 :=\n  decidable.by_contradiction fun (h : ¬limits.kernel.ι f = 0) => w (limits.eq_zero_of_epi_kernel f)\n\ntheorem mono_to_simple_zero_of_not_iso {C : Type u} [category C] [limits.has_zero_morphisms C]\n    {X : C} {Y : C} [simple Y] {f : X ⟶ Y} [mono f] (w : is_iso f → False) : f = 0 :=\n  decidable.by_contradiction fun (h : ¬f = 0) => w (is_iso_of_mono_of_nonzero h)\n\ntheorem id_nonzero {C : Type u} [category C] [limits.has_zero_morphisms C] (X : C) [simple X] :\n    𝟙 ≠ 0 :=\n  coe_fn (simple.mono_is_iso_equiv_nonzero 𝟙) (is_iso.id X)\n\n/-- We don't want the definition of 'simple' to include the zero object, so we check that here. -/\ntheorem zero_not_simple {C : Type u} [category C] [limits.has_zero_morphisms C]\n    [limits.has_zero_object C] [simple 0] : False :=\n  coe_fn (simple.mono_is_iso_equiv_nonzero 0) (is_iso.mk 0) rfl\n\n-- We next make the dual arguments, but for this we must be in an abelian category.\n\n/-- In an abelian category, an object satisfying the dual of the definition of a simple object is\n    simple. -/\ndef simple_of_cosimple {C : Type u} [category C] [abelian C] (X : C)\n    (h : {Z : C} → (f : X ⟶ Z) → [_inst_3 : epi f] → is_iso f ≃ f ≠ 0) : simple X :=\n  simple.mk\n    fun (Y : C) (f : Y ⟶ X) (I : mono f) =>\n      equiv_of_subsingleton_of_subsingleton sorry\n        fun (hf : f ≠ 0) => abelian.is_iso_of_mono_of_epi f\n\n/-- A nonzero epimorphism from a simple object is an isomorphism. -/\ndef is_iso_of_epi_of_nonzero {C : Type u} [category C] [abelian C] {X : C} {Y : C} [simple X]\n    {f : X ⟶ Y} [epi f] (w : f ≠ 0) : is_iso f :=\n  abelian.is_iso_of_mono_of_epi f\n\ntheorem cokernel_zero_of_nonzero_to_simple {C : Type u} [category C] [abelian C] {X : C} {Y : C}\n    [simple Y] {f : X ⟶ Y} [limits.has_cokernel f] (w : f ≠ 0) : limits.cokernel.π f = 0 :=\n  decidable.by_contradiction\n    fun (h : ¬limits.cokernel.π f = 0) => w (limits.eq_zero_of_mono_cokernel f)\n\ntheorem epi_from_simple_zero_of_not_iso {C : Type u} [category C] [abelian C] {X : C} {Y : C}\n    [simple X] {f : X ⟶ Y} [epi f] (w : is_iso f → False) : f = 0 :=\n  decidable.by_contradiction fun (h : ¬f = 0) => w (is_iso_of_epi_of_nonzero h)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/simple_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998714925403, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4723365038218563}}
{"text": "import phase2.constrains\n\nopen set sum\nopen_locale cardinal\n\nuniverse u\n\nnamespace con_nf\nvariables [params.{u}] (α : Λ) [position_data.{}] [phase_2_assumptions α] {β : type_index}\n\n/-- A litter is *inflexible* if it is the image of some f-map. -/\n@[mk_iff] inductive inflexible : litter → extended_index β → Prop\n| mk_coe ⦃γ : Iic α⦄ ⦃δ : Iio α⦄ ⦃ε : Iio α⦄ (hδ : (δ : Λ) < γ) (hε : (ε : Λ) < γ) (hδε : δ ≠ ε)\n    (A : quiver.path (β : type_index) γ) (t : tangle δ) :\n    inflexible\n      (f_map (with_bot.coe_ne_coe.mpr $ coe_ne' hδε) t)\n      ((A.cons (coe_lt hε)).cons (with_bot.bot_lt_coe _))\n| mk_bot ⦃γ : Iic α⦄ ⦃ε : Iio α⦄ (hε : (ε : Λ) < γ)\n    (A : quiver.path (β : type_index) γ) (a : atom) :\n    inflexible\n      (f_map (show (⊥ : type_index) ≠ (ε : Λ), from with_bot.bot_ne_coe) a)\n      ((A.cons (coe_lt hε)).cons (with_bot.bot_lt_coe _))\n\n/-- A litter is *flexible* if it is not the image of any f-map. -/\ndef flexible (L : litter) (A : extended_index β) : Prop := ¬inflexible α L A\n\nlemma mk_flexible (A : extended_index β) : #{L | flexible α L A} = #μ :=\nbegin\n  refine le_antisymm ((cardinal.mk_subtype_le _).trans mk_litter.le) _,\n  refine ⟨⟨λ ν, ⟨⟨ν, ⊥, α, with_bot.bot_ne_coe⟩, _⟩, _⟩⟩,\n  { intro h,\n    rw inflexible_iff at h,\n    obtain (⟨γ, δ, ε, hδ, hε, hδε, A, t, h, rfl⟩ | ⟨γ, ε, hε, A, t, h, rfl⟩) := h,\n    all_goals { have := f_map_γ _ _,\n      rw ← h at this,\n      exact ne_of_lt ε.prop this.symm, }, },\n  { intros ν₁ ν₂ h,\n    simp only [subtype.mk_eq_mk, eq_self_iff_true, and_true] at h,\n    exact h, },\nend\n\nvariable {α}\n\nlemma inflexible.comp {γ : type_index} {L : litter} {A : extended_index γ}\n  (h : inflexible α L A) (B : quiver.path β γ) : inflexible α L (B.comp A) :=\nbegin\n  induction h,\n  refine inflexible.mk_coe _ _ _ _ _,\n  assumption,\n  exact inflexible.mk_bot _ _ _,\nend\n\n@[simp] lemma not_flexible_iff {L : litter} {A : extended_index β} :\n  ¬flexible α L A ↔ inflexible α L A := not_not\n\nlemma flexible_of_comp_flexible {γ : type_index} {L : litter} {A : extended_index γ}\n  {B : quiver.path β γ} (h : flexible α L (B.comp A)) : flexible α L A :=\nλ h', h (h'.comp B)\n\nend con_nf\n", "meta": {"author": "leanprover-community", "repo": "con-nf", "sha": "f0b66bd73ca5d3bd8b744985242c4c0b5464913f", "save_path": "github-repos/lean/leanprover-community-con-nf", "path": "github-repos/lean/leanprover-community-con-nf/con-nf-f0b66bd73ca5d3bd8b744985242c4c0b5464913f/src/phase2/flexible.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.47233649755207935}}
{"text": "/-\nCopyright (c) 2014 Parikshit Khanna. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro\n\nBasic properties of lists.\n-/\nimport\n  tactic.interactive tactic.mk_iff_of_inductive_prop tactic.split_ifs\n  logic.basic logic.function logic.relation\n  algebra.group order.basic\n  data.list.defs data.nat.basic data.option.basic\n  data.bool data.prod data.sigma data.fin\nopen function nat\n\nnamespace list\nuniverses u v w x\nvariables {α : Type u} {β : Type v} {γ : Type w} {δ : Type x}\n\ninstance : is_left_id (list α) has_append.append [] :=\n⟨ nil_append ⟩\n\ninstance : is_right_id (list α) has_append.append [] :=\n⟨ append_nil ⟩\n\ninstance : is_associative (list α) has_append.append :=\n⟨ append_assoc ⟩\n\n@[simp] theorem cons_ne_nil (a : α) (l : list α) : a::l ≠ [].\n\ntheorem head_eq_of_cons_eq {h₁ h₂ : α} {t₁ t₂ : list α} :\n      (h₁::t₁) = (h₂::t₂) → h₁ = h₂ :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pheq)\n\ntheorem tail_eq_of_cons_eq {h₁ h₂ : α} {t₁ t₂ : list α} :\n      (h₁::t₁) = (h₂::t₂) → t₁ = t₂ :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pteq)\n\ntheorem cons_inj {a : α} : injective (cons a) :=\nassume l₁ l₂, assume Pe, tail_eq_of_cons_eq Pe\n\n@[simp] theorem cons_inj' (a : α) {l l' : list α} : a::l = a::l' ↔ l = l' :=\n⟨λ e, cons_inj e, congr_arg _⟩\n\n/- mem -/\n\ntheorem mem_singleton_self (a : α) : a ∈ [a] := mem_cons_self _ _\n\ntheorem eq_of_mem_singleton {a b : α} : a ∈ [b] → a = b :=\nassume : a ∈ [b], or.elim (eq_or_mem_of_mem_cons this)\n  (assume : a = b, this)\n  (assume : a ∈ [], absurd this (not_mem_nil a))\n\n@[simp] theorem mem_singleton {a b : α} : a ∈ [b] ↔ a = b :=\n⟨eq_of_mem_singleton, or.inl⟩\n\ntheorem mem_of_mem_cons_of_mem {a b : α} {l : list α} : a ∈ b::l → b ∈ l → a ∈ l :=\nassume ainbl binl, or.elim (eq_or_mem_of_mem_cons ainbl)\n  (assume : a = b, begin subst a, exact binl end)\n  (assume : a ∈ l, this)\n\ntheorem eq_or_ne_mem_of_mem {a b : α} {l : list α} (h : a ∈ b :: l) : a = b ∨ (a ≠ b ∧ a ∈ l) :=\nclassical.by_cases or.inl $ assume : a ≠ b, h.elim or.inl $ assume h, or.inr ⟨this, h⟩\n\ntheorem not_mem_append {a : α} {s t : list α} (h₁ : a ∉ s) (h₂ : a ∉ t) : a ∉ s ++ t :=\nmt mem_append.1 $ not_or_distrib.2 ⟨h₁, h₂⟩\n\ntheorem ne_nil_of_mem {a : α} {l : list α} (h : a ∈ l) : l ≠ [] :=\nby intro e; rw e at h; cases h\n\ntheorem length_eq_zero {l : list α} : length l = 0 ↔ l = [] :=\n⟨eq_nil_of_length_eq_zero, λ h, h.symm ▸ rfl⟩\n\ntheorem length_pos_of_mem {a : α} : ∀ {l : list α}, a ∈ l → 0 < length l\n| (b::l) _ := zero_lt_succ _\n\ntheorem exists_mem_of_length_pos : ∀ {l : list α}, 0 < length l → ∃ a, a ∈ l\n| (b::l) _ := ⟨b, mem_cons_self _ _⟩\n\ntheorem length_pos_iff_exists_mem {l : list α} : 0 < length l ↔ ∃ a, a ∈ l :=\n⟨exists_mem_of_length_pos, λ ⟨a, h⟩, length_pos_of_mem h⟩\n\ntheorem length_eq_one {l : list α} : length l = 1 ↔ ∃ a, l = [a] :=\n⟨match l with [a], _ := ⟨a, rfl⟩ end, λ ⟨a, e⟩, e.symm ▸ rfl⟩\n\ntheorem mem_split {a : α} {l : list α} (h : a ∈ l) : ∃ s t : list α, l = s ++ a :: t :=\nbegin\n  induction l with b l ih, {cases h}, rcases h with rfl | h,\n  { exact ⟨[], l, rfl⟩ },\n  { rcases ih h with ⟨s, t, rfl⟩,\n    exact ⟨b::s, t, rfl⟩ }\nend\n\ntheorem mem_of_ne_of_mem {a y : α} {l : list α} (h₁ : a ≠ y) (h₂ : a ∈ y :: l) : a ∈ l :=\nor.elim (eq_or_mem_of_mem_cons h₂) (λe, absurd e h₁) (λr, r)\n\ntheorem ne_of_not_mem_cons {a b : α} {l : list α} : a ∉ b::l → a ≠ b :=\nassume nin aeqb, absurd (or.inl aeqb) nin\n\ntheorem not_mem_of_not_mem_cons {a b : α} {l : list α} : a ∉ b::l → a ∉ l :=\nassume nin nainl, absurd (or.inr nainl) nin\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : α} {l : list α} : a ≠ y → a ∉ l → a ∉ y::l :=\nassume p1 p2, not.intro (assume Pain, absurd (eq_or_mem_of_mem_cons Pain) (not_or p1 p2))\n\ntheorem ne_and_not_mem_of_not_mem_cons {a y : α} {l : list α} : a ∉ y::l → a ≠ y ∧ a ∉ l :=\nassume p, and.intro (ne_of_not_mem_cons p) (not_mem_of_not_mem_cons p)\n\ntheorem mem_map_of_mem (f : α → β) {a : α} {l : list α} (h : a ∈ l) : f a ∈ map f l :=\nbegin\n  induction l with b l' ih,\n  {cases h},\n  {rcases h with rfl | h,\n    {exact or.inl rfl},\n    {exact or.inr (ih h)}}\nend\n\ntheorem exists_of_mem_map {f : α → β} {b : β} {l : list α} (h : b ∈ map f l) : ∃ a, a ∈ l ∧ f a = b :=\nbegin\n  induction l with c l' ih,\n  {cases h},\n  {cases (eq_or_mem_of_mem_cons h) with h h,\n    {exact ⟨c, mem_cons_self _ _, h.symm⟩},\n    {rcases ih h with ⟨a, ha₁, ha₂⟩,\n      exact ⟨a, mem_cons_of_mem _ ha₁, ha₂⟩ }}\nend\n\n@[simp] theorem mem_map {f : α → β} {b : β} {l : list α} : b ∈ map f l ↔ ∃ a, a ∈ l ∧ f a = b :=\n⟨exists_of_mem_map, λ ⟨a, la, h⟩, by rw [← h]; exact mem_map_of_mem f la⟩\n\n@[simp] theorem mem_map_of_inj {f : α → β} (H : injective f) {a : α} {l : list α} :\n  f a ∈ map f l ↔ a ∈ l :=\n⟨λ m, let ⟨a', m', e⟩ := exists_of_mem_map m in H e ▸ m', mem_map_of_mem _⟩\n\n@[simp] theorem mem_join {a : α} : ∀ {L : list (list α)}, a ∈ join L ↔ ∃ l, l ∈ L ∧ a ∈ l\n| []       := ⟨false.elim, λ⟨_, h, _⟩, false.elim h⟩\n| (c :: L) := by simp only [join, mem_append, @mem_join L, mem_cons_iff, or_and_distrib_right, exists_or_distrib, exists_eq_left]\n\ntheorem exists_of_mem_join {a : α} {L : list (list α)} : a ∈ join L → ∃ l, l ∈ L ∧ a ∈ l :=\nmem_join.1\n\ntheorem mem_join_of_mem {a : α} {L : list (list α)} {l} (lL : l ∈ L) (al : a ∈ l) : a ∈ join L :=\nmem_join.2 ⟨l, lL, al⟩\n\n@[simp] theorem mem_bind {b : β} {l : list α} {f : α → list β} : b ∈ list.bind l f ↔ ∃ a ∈ l, b ∈ f a :=\niff.trans mem_join\n  ⟨λ ⟨l', h1, h2⟩, let ⟨a, al, fa⟩ := exists_of_mem_map h1 in ⟨a, al, fa.symm ▸ h2⟩,\n  λ ⟨a, al, bfa⟩, ⟨f a, mem_map_of_mem _ al, bfa⟩⟩\n\ntheorem exists_of_mem_bind {b : β} {l : list α} {f : α → list β} : b ∈ list.bind l f → ∃ a ∈ l, b ∈ f a :=\nmem_bind.1\n\ntheorem mem_bind_of_mem {b : β} {l : list α} {f : α → list β} {a} (al : a ∈ l) (h : b ∈ f a) : b ∈ list.bind l f :=\nmem_bind.2 ⟨a, al, h⟩\n\nlemma bind_map {g : α → list β} {f : β → γ} :\n  ∀(l : list α), list.map f (l.bind g) = l.bind (λa, (g a).map f)\n| [] := rfl\n| (a::l) := by simp only [cons_bind, map_append, bind_map l]\n\n/- bounded quantifiers over lists -/\n\ntheorem forall_mem_nil (p : α → Prop) : ∀ x ∈ @nil α, p x.\n\n@[simp] theorem forall_mem_cons' {p : α → Prop} {a : α} {l : list α} :\n  (∀ (x : α), x = a ∨ x ∈ l → p x) ↔ p a ∧ ∀ x ∈ l, p x :=\nby simp only [or_imp_distrib, forall_and_distrib, forall_eq]\n\ntheorem forall_mem_cons {p : α → Prop} {a : α} {l : list α} :\n  (∀ x ∈ a :: l, p x) ↔ p a ∧ ∀ x ∈ l, p x :=\nby simp only [mem_cons_iff, forall_mem_cons']\n\ntheorem forall_mem_of_forall_mem_cons {p : α → Prop} {a : α} {l : list α}\n    (h : ∀ x ∈ a :: l, p x) :\n  ∀ x ∈ l, p x :=\n(forall_mem_cons.1 h).2\n\ntheorem forall_mem_singleton {p : α → Prop} {a : α} : (∀ x ∈ [a], p x) ↔ p a :=\nby simp only [mem_singleton, forall_eq]\n\ntheorem forall_mem_append {p : α → Prop} {l₁ l₂ : list α} :\n  (∀ x ∈ l₁ ++ l₂, p x) ↔ (∀ x ∈ l₁, p x) ∧ (∀ x ∈ l₂, p x) :=\nby simp only [mem_append, or_imp_distrib, forall_and_distrib]\n\ntheorem not_exists_mem_nil (p : α → Prop) : ¬ ∃ x ∈ @nil α, p x.\n\ntheorem exists_mem_cons_of {p : α → Prop} {a : α} (l : list α) (h : p a) :\n  ∃ x ∈ a :: l, p x :=\nbex.intro a (mem_cons_self _ _) h\n\ntheorem exists_mem_cons_of_exists {p : α → Prop} {a : α} {l : list α} (h : ∃ x ∈ l, p x) :\n  ∃ x ∈ a :: l, p x :=\nbex.elim h (λ x xl px, bex.intro x (mem_cons_of_mem _ xl) px)\n\ntheorem or_exists_of_exists_mem_cons {p : α → Prop} {a : α} {l : list α} (h : ∃ x ∈ a :: l, p x) :\n  p a ∨ ∃ x ∈ l, p x :=\nbex.elim h (λ x xal px,\n  or.elim (eq_or_mem_of_mem_cons xal)\n    (assume : x = a, begin rw ←this, left, exact px end)\n    (assume : x ∈ l, or.inr (bex.intro x this px)))\n\n@[simp] theorem exists_mem_cons_iff (p : α → Prop) (a : α) (l : list α) :\n  (∃ x ∈ a :: l, p x) ↔ p a ∨ ∃ x ∈ l, p x :=\niff.intro or_exists_of_exists_mem_cons\n  (assume h, or.elim h (exists_mem_cons_of l) exists_mem_cons_of_exists)\n\n/- list subset -/\n\ntheorem subset_def {l₁ l₂ : list α} : l₁ ⊆ l₂ ↔ ∀ ⦃a : α⦄, a ∈ l₁ → a ∈ l₂ := iff.rfl\n\ntheorem subset_app_of_subset_left (l l₁ l₂ : list α) : l ⊆ l₁ → l ⊆ l₁++l₂ :=\nλ s, subset.trans s $ subset_append_left _ _\n\ntheorem subset_app_of_subset_right (l l₁ l₂ : list α) : l ⊆ l₂ → l ⊆ l₁++l₂ :=\nλ s, subset.trans s $ subset_append_right _ _\n\n@[simp] theorem cons_subset {a : α} {l m : list α} :\n  a::l ⊆ m ↔ a ∈ m ∧ l ⊆ m :=\nby simp only [subset_def, mem_cons_iff, or_imp_distrib, forall_and_distrib, forall_eq]\n\ntheorem cons_subset_of_subset_of_mem {a : α} {l m : list α}\n  (ainm : a ∈ m) (lsubm : l ⊆ m) : a::l ⊆ m :=\ncons_subset.2 ⟨ainm, lsubm⟩\n\ntheorem app_subset_of_subset_of_subset {l₁ l₂ l : list α} (l₁subl : l₁ ⊆ l) (l₂subl : l₂ ⊆ l) :\n  l₁ ++ l₂ ⊆ l :=\nλ a h, (mem_append.1 h).elim (@l₁subl _) (@l₂subl _)\n\ntheorem eq_nil_of_subset_nil : ∀ {l : list α}, l ⊆ [] → l = []\n| []     s := rfl\n| (a::l) s := false.elim $ s $ mem_cons_self a l\n\ntheorem eq_nil_iff_forall_not_mem {l : list α} : l = [] ↔ ∀ a, a ∉ l :=\nshow l = [] ↔ l ⊆ [], from ⟨λ e, e ▸ subset.refl _, eq_nil_of_subset_nil⟩\n\ntheorem map_subset {l₁ l₂ : list α} (f : α → β) (H : l₁ ⊆ l₂) : map f l₁ ⊆ map f l₂ :=\nλ x, by simp only [mem_map, not_and, exists_imp_distrib, and_imp]; exact λ a h e, ⟨a, H h, e⟩\n\n/- append -/\n\nlemma append_eq_has_append {L₁ L₂ : list α} : list.append L₁ L₂ = L₁ ++ L₂ := rfl\n\ntheorem append_ne_nil_of_ne_nil_left (s t : list α) : s ≠ [] → s ++ t ≠ [] :=\nby induction s; intros; contradiction\n\ntheorem append_ne_nil_of_ne_nil_right (s t : list α) : t ≠ [] → s ++ t ≠ [] :=\nby induction s; intros; contradiction\n\ntheorem append_foldl (f : α → β → α) (a : α) (s t : list β) : foldl f a (s ++ t) = foldl f (foldl f a s) t :=\nby {induction s with b s H generalizing a, refl, simp only [foldl, cons_append], rw H _}\n\ntheorem append_foldr (f : α → β → β) (a : β) (s t : list α) : foldr f a (s ++ t) = foldr f (foldr f a t) s :=\nby {induction s with b s H generalizing a, refl, simp only [foldr, cons_append], rw H _}\n\n@[simp] lemma append_eq_nil {p q : list α} : (p ++ q) = [] ↔ p = [] ∧ q = [] :=\nby cases p; simp only [nil_append, cons_append, eq_self_iff_true, true_and, false_and]\n\n@[simp] lemma nil_eq_append_iff {a b : list α} : [] = a ++ b ↔ a = [] ∧ b = [] :=\nby rw [eq_comm, append_eq_nil]\n\nlemma append_eq_cons_iff {a b c : list α} {x : α} :\n  a ++ b = x :: c ↔ (a = [] ∧ b = x :: c) ∨ (∃a', a = x :: a' ∧ c = a' ++ b) :=\nby cases a; simp only [and_assoc, @eq_comm _ c, nil_append, cons_append, eq_self_iff_true,\n  true_and, false_and, exists_false, false_or, or_false, exists_and_distrib_left, exists_eq_left']\n\nlemma cons_eq_append_iff {a b c : list α} {x : α} :\n  (x :: c : list α) = a ++ b ↔ (a = [] ∧ b = x :: c) ∨ (∃a', a = x :: a' ∧ c = a' ++ b) :=\nby rw [eq_comm, append_eq_cons_iff]\n\nlemma append_eq_append_iff {a b c d : list α} :\n  a ++ b = c ++ d ↔ (∃a', c = a ++ a' ∧ b = a' ++ d) ∨ (∃c', a = c ++ c' ∧ d = c' ++ b) :=\nbegin\n  induction a generalizing c,\n  case nil { rw nil_append, split,\n    { rintro rfl, left, exact ⟨_, rfl, rfl⟩ },\n    { rintro (⟨a', rfl, rfl⟩ | ⟨a', H, rfl⟩), {refl}, {rw [← append_assoc, ← H], refl} } },\n  case cons : a as ih {\n    cases c,\n    { simp only [cons_append, nil_append, false_and, exists_false, false_or, exists_eq_left'], exact eq_comm },\n    { simp only [cons_append, @eq_comm _ a, ih, and_assoc, and_or_distrib_left, exists_and_distrib_left] } }\nend\n\n@[simp] theorem split_at_eq_take_drop : ∀ (n : ℕ) (l : list α), split_at n l = (take n l, drop n l)\n| 0        a         := rfl\n| (succ n) []        := rfl\n| (succ n) (x :: xs) := by simp only [split_at, split_at_eq_take_drop n xs, take, drop]\n\n@[simp] theorem take_append_drop : ∀ (n : ℕ) (l : list α), take n l ++ drop n l = l\n| 0        a         := rfl\n| (succ n) []        := rfl\n| (succ n) (x :: xs) := congr_arg (cons x) $ take_append_drop n xs\n\n-- TODO(Leo): cleanup proof after arith dec proc\ntheorem append_inj : ∀ {s₁ s₂ t₁ t₂ : list α}, s₁ ++ t₁ = s₂ ++ t₂ → length s₁ = length s₂ → s₁ = s₂ ∧ t₁ = t₂\n| []      []      t₁ t₂ h hl := ⟨rfl, h⟩\n| (a::s₁) []      t₁ t₂ h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl\n| []      (b::s₂) t₁ t₂ h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl.symm\n| (a::s₁) (b::s₂) t₁ t₂ h hl := list.no_confusion h $ λab hap,\n  let ⟨e1, e2⟩ := @append_inj s₁ s₂ t₁ t₂ hap (succ.inj hl) in\n  by rw [ab, e1, e2]; exact ⟨rfl, rfl⟩\n\ntheorem append_inj_left {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂) (hl : length s₁ = length s₂) : t₁ = t₂ :=\n(append_inj h hl).right\n\ntheorem append_inj_right {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂) (hl : length s₁ = length s₂) : s₁ = s₂ :=\n(append_inj h hl).left\n\ntheorem append_inj' {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂) (hl : length t₁ = length t₂) : s₁ = s₂ ∧ t₁ = t₂ :=\nappend_inj h $ @nat.add_right_cancel _ (length t₁) _ $\nlet hap := congr_arg length h in by simp only [length_append] at hap; rwa [← hl] at hap\n\ntheorem append_inj_left' {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂) (hl : length t₁ = length t₂) : t₁ = t₂ :=\n(append_inj' h hl).right\n\ntheorem append_inj_right' {s₁ s₂ t₁ t₂ : list α} (h : s₁ ++ t₁ = s₂ ++ t₂) (hl : length t₁ = length t₂) : s₁ = s₂ :=\n(append_inj' h hl).left\n\ntheorem append_left_cancel {s t₁ t₂ : list α} (h : s ++ t₁ = s ++ t₂) : t₁ = t₂ :=\nappend_inj_left h rfl\n\ntheorem append_right_cancel {s₁ s₂ t : list α} (h : s₁ ++ t = s₂ ++ t) : s₁ = s₂ :=\nappend_inj_right' h rfl\n\ntheorem append_left_inj {t₁ t₂ : list α} (s) : s ++ t₁ = s ++ t₂ ↔ t₁ = t₂ :=\n⟨append_left_cancel, congr_arg _⟩\n\ntheorem append_right_inj {s₁ s₂ : list α} (t) : s₁ ++ t = s₂ ++ t ↔ s₁ = s₂ :=\n⟨append_right_cancel, congr_arg _⟩\n\ntheorem map_eq_append_split {f : α → β} {l : list α} {s₁ s₂ : list β}\n  (h : map f l = s₁ ++ s₂) : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ map f l₁ = s₁ ∧ map f l₂ = s₂ :=\nbegin\n  have := h, rw [← take_append_drop (length s₁) l] at this ⊢,\n  rw map_append at this,\n  refine ⟨_, _, rfl, append_inj this _⟩,\n  rw [length_map, length_take, min_eq_left],\n  rw [← length_map f l, h, length_append],\n  apply nat.le_add_right\nend\n\n/- join -/\n\nattribute [simp] join\n\ntheorem join_eq_nil : ∀ {L : list (list α)}, join L = [] ↔ ∀ l ∈ L, l = []\n| []     := iff_of_true rfl (forall_mem_nil _)\n| (l::L) := by simp only [join, append_eq_nil, join_eq_nil, forall_mem_cons]\n\n@[simp] theorem join_append (L₁ L₂ : list (list α)) : join (L₁ ++ L₂) = join L₁ ++ join L₂ :=\nby induction L₁; [refl, simp only [*, join, cons_append, append_assoc]]\n\n/- repeat -/\n\n@[simp] theorem repeat_succ (a : α) (n) : repeat a (n + 1) = a :: repeat a n := rfl\n\ntheorem eq_of_mem_repeat {a b : α} : ∀ {n}, b ∈ repeat a n → b = a\n| (n+1) h := or.elim h id $ @eq_of_mem_repeat _\n\ntheorem eq_repeat_of_mem {a : α} : ∀ {l : list α}, (∀ b ∈ l, b = a) → l = repeat a l.length\n| []     H := rfl\n| (b::l) H := by cases forall_mem_cons.1 H with H₁ H₂;\n  unfold length repeat; congr; [exact H₁, exact eq_repeat_of_mem H₂]\n\ntheorem eq_repeat' {a : α} {l : list α} : l = repeat a l.length ↔ ∀ b ∈ l, b = a :=\n⟨λ h, h.symm ▸ λ b, eq_of_mem_repeat, eq_repeat_of_mem⟩\n\ntheorem eq_repeat {a : α} {n} {l : list α} : l = repeat a n ↔ length l = n ∧ ∀ b ∈ l, b = a :=\n⟨λ h, h.symm ▸ ⟨length_repeat _ _, λ b, eq_of_mem_repeat⟩,\n λ ⟨e, al⟩, e ▸ eq_repeat_of_mem al⟩\n\ntheorem repeat_add (a : α) (m n) : repeat a (m + n) = repeat a m ++ repeat a n :=\nby induction m; simp only [*, zero_add, succ_add, repeat]; split; refl\n\ntheorem repeat_subset_singleton (a : α) (n) : repeat a n ⊆ [a] :=\nλ b h, mem_singleton.2 (eq_of_mem_repeat h)\n\n@[simp] theorem map_const (l : list α) (b : β) : map (function.const α b) l = repeat b l.length :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\ntheorem eq_of_mem_map_const {b₁ b₂ : β} {l : list α} (h : b₁ ∈ map (function.const α b₂) l) : b₁ = b₂ :=\nby rw map_const at h; exact eq_of_mem_repeat h\n\n@[simp] theorem map_repeat (f : α → β) (a : α) (n) : map f (repeat a n) = repeat (f a) n :=\nby induction n; [refl, simp only [*, repeat, map]]; split; refl\n\n@[simp] theorem tail_repeat (a : α) (n) : tail (repeat a n) = repeat a n.pred :=\nby cases n; refl\n\n@[simp] theorem join_repeat_nil (n : ℕ) : join (repeat [] n) = @nil α :=\nby induction n; [refl, simp only [*, repeat, join, append_nil]]\n\n/- bind -/\n\n@[simp] theorem bind_eq_bind {α β} (f : α → list β) (l : list α) :\n  l >>= f = l.bind f := rfl\n\n@[simp] theorem bind_append {α β} (f : α → list β) (l₁ l₂ : list α) :\n  (l₁ ++ l₂).bind f = l₁.bind f ++ l₂.bind f :=\nappend_bind _ _ _\n\n/- concat -/\n\n@[simp] theorem concat_nil (a : α) : concat [] a = [a] := rfl\n\n@[simp] theorem concat_cons (a b : α) (l : list α) : concat (a :: l) b = a :: concat l b := rfl\n\n@[simp] theorem concat_ne_nil (a : α) (l : list α) : concat l a ≠ [] :=\nby induction l; intro h; contradiction\n\n@[simp] theorem concat_append (a : α) (l₁ l₂ : list α) : concat l₁ a ++ l₂ = l₁ ++ a :: l₂ :=\nby induction l₁; simp only [*, cons_append, concat]; split; refl\n\n@[simp] theorem concat_eq_append (a : α) (l : list α) : concat l a = l ++ [a] :=\nby induction l; simp only [*, concat]; split; refl\n\n@[simp] theorem length_concat (a : α) (l : list α) : length (concat l a) = succ (length l) :=\nby simp only [concat_eq_append, length_append, length]\n\ntheorem append_concat (a : α) (l₁ l₂ : list α) : l₁ ++ concat l₂ a = concat (l₁ ++ l₂) a :=\nby induction l₂ with b l₂ ih; simp only [concat_eq_append, nil_append, cons_append, append_assoc]\n\n/- reverse -/\n\n@[simp] theorem reverse_nil : reverse (@nil α) = [] := rfl\n\nlocal attribute [simp] reverse_core\n\n@[simp] theorem reverse_cons (a : α) (l : list α) : reverse (a::l) = reverse l ++ [a] :=\nhave aux : ∀ l₁ l₂, reverse_core l₁ l₂ ++ [a] = reverse_core l₁ (l₂ ++ [a]),\nby intro l₁; induction l₁; intros; [refl, simp only [*, reverse_core, cons_append]],\n(aux l nil).symm\n\ntheorem reverse_core_eq (l₁ l₂ : list α) : reverse_core l₁ l₂ = reverse l₁ ++ l₂ :=\nby induction l₁ generalizing l₂; [refl, simp only [*, reverse_core, reverse_cons, append_assoc]]; refl\n\ntheorem reverse_cons' (a : α) (l : list α) : reverse (a::l) = concat (reverse l) a :=\nby simp only [reverse_cons, concat_eq_append]\n\n@[simp] theorem reverse_singleton (a : α) : reverse [a] = [a] := rfl\n\n@[simp] theorem reverse_append (s t : list α) : reverse (s ++ t) = (reverse t) ++ (reverse s) :=\nby induction s; [rw [nil_append, reverse_nil, append_nil],\nsimp only [*, cons_append, reverse_cons, append_assoc]]\n\n@[simp] theorem reverse_reverse (l : list α) : reverse (reverse l) = l :=\nby induction l; [refl, simp only [*, reverse_cons, reverse_append]]; refl\n\ntheorem reverse_injective : injective (@reverse α) :=\ninjective_of_left_inverse reverse_reverse\n\n@[simp] theorem reverse_inj {l₁ l₂ : list α} : reverse l₁ = reverse l₂ ↔ l₁ = l₂ :=\nreverse_injective.eq_iff\n\n@[simp] theorem reverse_eq_nil {l : list α} : reverse l = [] ↔ l = [] :=\n@reverse_inj _ l []\n\ntheorem concat_eq_reverse_cons (a : α) (l : list α) : concat l a = reverse (a :: reverse l) :=\nby simp only [concat_eq_append, reverse_cons, reverse_reverse]\n\n@[simp] theorem length_reverse (l : list α) : length (reverse l) = length l :=\nby induction l; [refl, simp only [*, reverse_cons, length_append, length]]\n\n@[simp] theorem map_reverse (f : α → β) (l : list α) : map f (reverse l) = reverse (map f l) :=\nby induction l; [refl, simp only [*, map, reverse_cons, map_append]]\n\ntheorem map_reverse_core (f : α → β) (l₁ l₂ : list α) :\n  map f (reverse_core l₁ l₂) = reverse_core (map f l₁) (map f l₂) :=\nby simp only [reverse_core_eq, map_append, map_reverse]\n\n@[simp] theorem mem_reverse {a : α} {l : list α} : a ∈ reverse l ↔ a ∈ l :=\nby induction l; [refl, simp only [*, reverse_cons, mem_append, mem_singleton, mem_cons_iff, not_mem_nil, false_or, or_false, or_comm]]\n\n@[simp] theorem reverse_repeat (a : α) (n) : reverse (repeat a n) = repeat a n :=\neq_repeat.2 ⟨by simp only [length_reverse, length_repeat], λ b h, eq_of_mem_repeat (mem_reverse.1 h)⟩\n\n@[elab_as_eliminator] def reverse_rec_on {C : list α → Sort*}\n  (l : list α) (H0 : C [])\n  (H1 : ∀ (l : list α) (a : α), C l → C (l ++ [a])) : C l :=\nbegin\n  rw ← reverse_reverse l,\n  induction reverse l,\n  { exact H0 },\n  { rw reverse_cons, exact H1 _ _ ih }\nend\n\n/- last -/\n\n@[simp] theorem last_cons {a : α} {l : list α} : ∀ (h₁ : a :: l ≠ nil) (h₂ : l ≠ nil), last (a :: l) h₁ = last l h₂ :=\nby {induction l; intros, contradiction, reflexivity}\n\n@[simp] theorem last_append {a : α} (l : list α) (h : l ++ [a] ≠ []) : last (l ++ [a]) h = a :=\nby induction l; [refl, simp only [cons_append, last_cons _ (λ H, cons_ne_nil _ _ (append_eq_nil.1 H).2), *]]\n\ntheorem last_concat {a : α} (l : list α) (h : concat l a ≠ []) : last (concat l a) h = a :=\nby simp only [concat_eq_append, last_append]\n\n@[simp] theorem last_singleton (a : α) (h : [a] ≠ []) : last [a] h = a := rfl\n\n@[simp] theorem last_cons_cons (a₁ a₂ : α) (l : list α) (h : a₁::a₂::l ≠ []) :\n  last (a₁::a₂::l) h = last (a₂::l) (cons_ne_nil a₂ l) := rfl\n\ntheorem last_congr {l₁ l₂ : list α} (h₁ : l₁ ≠ []) (h₂ : l₂ ≠ []) (h₃ : l₁ = l₂) :\n  last l₁ h₁ = last l₂ h₂ :=\nby subst l₁\n\n/- head(') and tail -/\n\ntheorem head_eq_head' [inhabited α] (l : list α) : head l = (head' l).iget :=\nby cases l; refl\n\n@[simp] theorem head_cons [inhabited α] (a : α) (l : list α) : head (a::l) = a := rfl\n\n@[simp] theorem tail_nil : tail (@nil α) = [] := rfl\n\n@[simp] theorem tail_cons (a : α) (l : list α) : tail (a::l) = l := rfl\n\n@[simp] theorem head_append [inhabited α] (t : list α) {s : list α} (h : s ≠ []) : head (s ++ t) = head s :=\nby {induction s, contradiction, refl}\n\ntheorem cons_head_tail [inhabited α] {l : list α} (h : l ≠ []) : (head l)::(tail l) = l :=\nby {induction l, contradiction, refl}\n\n/- map -/\n\nlemma map_congr {f g : α → β} : ∀ {l : list α}, (∀ x ∈ l, f x = g x) → map f l = map g l\n| []     _ := rfl\n| (a::l) h := let ⟨h₁, h₂⟩ := forall_mem_cons.1 h in\n  by rw [map, map, h₁, map_congr h₂]\n\ntheorem map_concat (f : α → β) (a : α) (l : list α) : map f (concat l a) = concat (map f l) (f a) :=\nby induction l; [refl, simp only [*, concat_eq_append, cons_append, map, map_append]]; split; refl\n\ntheorem map_id' {f : α → α} (h : ∀ x, f x = x) (l : list α) : map f l = l :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\n@[simp] theorem foldl_map (g : β → γ) (f : α → γ → α) (a : α) (l : list β) : foldl f a (map g l) = foldl (λx y, f x (g y)) a l :=\nby revert a; induction l; intros; [refl, simp only [*, map, foldl]]\n\n@[simp] theorem foldr_map (g : β → γ) (f : γ → α → α) (a : α) (l : list β) : foldr f a (map g l) = foldr (f ∘ g) a l :=\nby revert a; induction l; intros; [refl, simp only [*, map, foldr]]\n\ntheorem foldl_hom (f : α → β) (g : α → γ → α) (g' : β → γ → β) (a : α)\n  (h : ∀a x, f (g a x) = g' (f a) x) (l : list γ) : f (foldl g a l) = foldl g' (f a) l :=\nby revert a; induction l; intros; [refl, simp only [*, foldl]]\n\ntheorem foldr_hom (f : α → β) (g : γ → α → α) (g' : γ → β → β) (a : α)\n  (h : ∀x a, f (g x a) = g' x (f a)) (l : list γ) : f (foldr g a l) = foldr g' (f a) l :=\nby revert a; induction l; intros; [refl, simp only [*, foldr]]\n\ntheorem eq_nil_of_map_eq_nil {f : α → β} {l : list α} (h : map f l = nil) : l = nil :=\neq_nil_of_length_eq_zero $ by rw [← length_map f l, h]; refl\n\n@[simp] theorem map_join (f : α → β) (L : list (list α)) :\n  map f (join L) = join (map (map f) L) :=\nby induction L; [refl, simp only [*, join, map, map_append]]\n\ntheorem bind_ret_eq_map {α β} (f : α → β) (l : list α) :\n  l.bind (list.ret ∘ f) = map f l :=\nby unfold list.bind; induction l; simp only [map, join, list.ret, cons_append, nil_append, *]; split; refl\n\n@[simp] theorem map_eq_map {α β} (f : α → β) (l : list α) :\n  f <$> l = map f l := rfl\n\n@[simp] theorem map_tail (f : α → β) (l) : map f (tail l) = tail (map f l) :=\nby cases l; refl\n\n/- map₂ -/\n\ntheorem nil_map₂ (f : α → β → γ) (l : list β) : map₂ f [] l = [] :=\nby cases l; refl\n\ntheorem map₂_nil (f : α → β → γ) (l : list α) : map₂ f l [] = [] :=\nby cases l; refl\n\n/- sublists -/\n\n@[simp] theorem nil_sublist : Π (l : list α), [] <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons _ _ a (nil_sublist l)\n\n@[refl, simp] theorem sublist.refl : Π (l : list α), l <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons2 _ _ a (sublist.refl l)\n\n@[trans] theorem sublist.trans {l₁ l₂ l₃ : list α} (h₁ : l₁ <+ l₂) (h₂ : l₂ <+ l₃) : l₁ <+ l₃ :=\nsublist.rec_on h₂ (λ_ s, s)\n  (λl₂ l₃ a h₂ IH l₁ h₁, sublist.cons _ _ _ (IH l₁ h₁))\n  (λl₂ l₃ a h₂ IH l₁ h₁, @sublist.cases_on _ (λl₁ l₂', l₂' = a :: l₂ → l₁ <+ a :: l₃) _ _ h₁\n    (λ_, nil_sublist _)\n    (λl₁ l₂' a' h₁' e, match a', l₂', e, h₁' with ._, ._, rfl, h₁ := sublist.cons _ _ _ (IH _ h₁) end)\n    (λl₁ l₂' a' h₁' e, match a', l₂', e, h₁' with ._, ._, rfl, h₁ := sublist.cons2 _ _ _ (IH _ h₁) end) rfl)\n  l₁ h₁\n\n@[simp] theorem sublist_cons (a : α) (l : list α) : l <+ a::l :=\nsublist.cons _ _ _ (sublist.refl l)\n\ntheorem sublist_of_cons_sublist {a : α} {l₁ l₂ : list α} : a::l₁ <+ l₂ → l₁ <+ l₂ :=\nsublist.trans (sublist_cons a l₁)\n\ntheorem cons_sublist_cons {l₁ l₂ : list α} (a : α) (s : l₁ <+ l₂) : a::l₁ <+ a::l₂ :=\nsublist.cons2 _ _ _ s\n\n@[simp] theorem sublist_append_left : Π (l₁ l₂ : list α), l₁ <+ l₁++l₂\n| []      l₂ := nil_sublist _\n| (a::l₁) l₂ := cons_sublist_cons _ (sublist_append_left l₁ l₂)\n\n@[simp] theorem sublist_append_right : Π (l₁ l₂ : list α), l₂ <+ l₁++l₂\n| []      l₂ := sublist.refl _\n| (a::l₁) l₂ := sublist.cons _ _ _ (sublist_append_right l₁ l₂)\n\ntheorem sublist_cons_of_sublist (a : α) {l₁ l₂ : list α} : l₁ <+ l₂ → l₁ <+ a::l₂ :=\nsublist.cons _ _ _\n\ntheorem sublist_app_of_sublist_left {l l₁ l₂ : list α} (s : l <+ l₁) : l <+ l₁++l₂ :=\ns.trans $ sublist_append_left _ _\n\ntheorem sublist_app_of_sublist_right {l l₁ l₂ : list α} (s : l <+ l₂) : l <+ l₁++l₂ :=\ns.trans $ sublist_append_right _ _\n\ntheorem sublist_of_cons_sublist_cons {l₁ l₂ : list α} : ∀ {a : α}, a::l₁ <+ a::l₂ → l₁ <+ l₂\n| ._ (sublist.cons  ._ ._ a s) := sublist_of_cons_sublist s\n| ._ (sublist.cons2 ._ ._ a s) := s\n\ntheorem cons_sublist_cons_iff {l₁ l₂ : list α} {a : α} : a::l₁ <+ a::l₂ ↔ l₁ <+ l₂ :=\n⟨sublist_of_cons_sublist_cons, cons_sublist_cons _⟩\n\n@[simp] theorem append_sublist_append_left {l₁ l₂ : list α} : ∀ l, l++l₁ <+ l++l₂ ↔ l₁ <+ l₂\n| []     := iff.rfl\n| (a::l) := cons_sublist_cons_iff.trans (append_sublist_append_left l)\n\ntheorem append_sublist_append_of_sublist_right {l₁ l₂ : list α} (h : l₁ <+ l₂) (l) : l₁++l <+ l₂++l :=\nbegin\n  induction h with _ _ a _ ih _ _ a _ ih,\n  { refl },\n  { apply sublist_cons_of_sublist a ih },\n  { apply cons_sublist_cons a ih }\nend\n\ntheorem sublist_or_mem_of_sublist {l l₁ l₂ : list α} {a : α} (h : l <+ l₁ ++ a::l₂) : l <+ l₁ ++ l₂ ∨ a ∈ l :=\nbegin\n  induction l₁ with b l₁ IH generalizing l,\n  { cases h, { left, exact ‹l <+ l₂› }, { right, apply mem_cons_self } },\n  { cases h with _ _ _ h _ _ _ h,\n    { exact or.imp_left (sublist_cons_of_sublist _) (IH h) },\n    { exact (IH h).imp (cons_sublist_cons _) (mem_cons_of_mem _) } }\nend\n\ntheorem reverse_sublist {l₁ l₂ : list α} (h : l₁ <+ l₂) : l₁.reverse <+ l₂.reverse :=\nbegin\n  induction h with _ _ _ _ ih _ _ a _ ih, {refl},\n  { rw reverse_cons, exact sublist_app_of_sublist_left ih },\n  { rw [reverse_cons, reverse_cons], exact append_sublist_append_of_sublist_right ih [a] }\nend\n\n@[simp] theorem reverse_sublist_iff {l₁ l₂ : list α} : l₁.reverse <+ l₂.reverse ↔ l₁ <+ l₂ :=\n⟨λ h, by have := reverse_sublist h; simp only [reverse_reverse] at this; assumption, reverse_sublist⟩\n\n@[simp] theorem append_sublist_append_right {l₁ l₂ : list α} (l) : l₁++l <+ l₂++l ↔ l₁ <+ l₂ :=\n⟨λ h, by have := reverse_sublist h; simp only [reverse_append, append_sublist_append_left, reverse_sublist_iff] at this; assumption,\n λ h, append_sublist_append_of_sublist_right h l⟩\n\ntheorem subset_of_sublist : Π {l₁ l₂ : list α}, l₁ <+ l₂ → l₁ ⊆ l₂\n| ._ ._ sublist.slnil             b h := h\n| ._ ._ (sublist.cons  l₁ l₂ a s) b h := mem_cons_of_mem _ (subset_of_sublist s h)\n| ._ ._ (sublist.cons2 l₁ l₂ a s) b h :=\n  match eq_or_mem_of_mem_cons h with\n  | or.inl h := h ▸ mem_cons_self _ _\n  | or.inr h := mem_cons_of_mem _ (subset_of_sublist s h)\n  end\n\ntheorem singleton_sublist {a : α} {l} : [a] <+ l ↔ a ∈ l :=\n⟨λ h, subset_of_sublist h (mem_singleton_self _), λ h,\nlet ⟨s, t, e⟩ := mem_split h in e.symm ▸\n  (cons_sublist_cons _ (nil_sublist _)).trans (sublist_append_right _ _)⟩\n\ntheorem eq_nil_of_sublist_nil {l : list α} (s : l <+ []) : l = [] :=\neq_nil_of_subset_nil $ subset_of_sublist s\n\ntheorem repeat_sublist_repeat (a : α) {m n} : repeat a m <+ repeat a n ↔ m ≤ n :=\n⟨λ h, by simpa only [length_repeat] using length_le_of_sublist h,\n λ h, by induction h; [refl, simp only [*, repeat_succ, sublist.cons]] ⟩\n\ntheorem eq_of_sublist_of_length_eq : ∀ {l₁ l₂ : list α}, l₁ <+ l₂ → length l₁ = length l₂ → l₁ = l₂\n| ._ ._ sublist.slnil             h := rfl\n| ._ ._ (sublist.cons  l₁ l₂ a s) h :=\n  absurd (length_le_of_sublist s) $ not_le_of_gt $ by rw h; apply lt_succ_self\n| ._ ._ (sublist.cons2 l₁ l₂ a s) h :=\n  by rw [length, length] at h; injection h with h; rw eq_of_sublist_of_length_eq s h\n\ntheorem eq_of_sublist_of_length_le {l₁ l₂ : list α} (s : l₁ <+ l₂) (h : length l₂ ≤ length l₁) : l₁ = l₂ :=\neq_of_sublist_of_length_eq s (le_antisymm (length_le_of_sublist s) h)\n\ntheorem sublist_antisymm {l₁ l₂ : list α} (s₁ : l₁ <+ l₂) (s₂ : l₂ <+ l₁) : l₁ = l₂ :=\neq_of_sublist_of_length_le s₁ (length_le_of_sublist s₂)\n\ninstance decidable_sublist [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <+ l₂)\n| []      l₂      := is_true $ nil_sublist _\n| (a::l₁) []      := is_false $ λh, list.no_confusion $ eq_nil_of_sublist_nil h\n| (a::l₁) (b::l₂) :=\n  if h : a = b then\n    decidable_of_decidable_of_iff (decidable_sublist l₁ l₂) $\n      by rw [← h]; exact ⟨cons_sublist_cons _, sublist_of_cons_sublist_cons⟩\n  else decidable_of_decidable_of_iff (decidable_sublist (a::l₁) l₂)\n    ⟨sublist_cons_of_sublist _, λs, match a, l₁, s, h with\n    | a, l₁, sublist.cons ._ ._ ._ s', h := s'\n    | ._, ._, sublist.cons2 t ._ ._ s', h := absurd rfl h\n    end⟩\n\n/- index_of -/\n\nsection index_of\nvariable [decidable_eq α]\n\n@[simp] theorem index_of_nil (a : α) : index_of a [] = 0 := rfl\n\ntheorem index_of_cons (a b : α) (l : list α) : index_of a (b::l) = if a = b then 0 else succ (index_of a l) := rfl\n\ntheorem index_of_cons_eq {a b : α} (l : list α) : a = b → index_of a (b::l) = 0 :=\nassume e, if_pos e\n\n@[simp] theorem index_of_cons_self (a : α) (l : list α) : index_of a (a::l) = 0 :=\nindex_of_cons_eq _ rfl\n\n@[simp] theorem index_of_cons_ne {a b : α} (l : list α) : a ≠ b → index_of a (b::l) = succ (index_of a l) :=\nassume n, if_neg n\n\ntheorem index_of_eq_length {a : α} {l : list α} : index_of a l = length l ↔ a ∉ l :=\nbegin\n  induction l with b l ih,\n  { exact iff_of_true rfl (not_mem_nil _) },\n  simp only [length, mem_cons_iff, index_of_cons], split_ifs,\n  { exact iff_of_false (by rintro ⟨⟩) (λ H, H $ or.inl h) },\n  { simp only [h, false_or], rw ← ih, exact succ_inj' }\nend\n\n@[simp] theorem index_of_of_not_mem {l : list α} {a : α} : a ∉ l → index_of a l = length l :=\nindex_of_eq_length.2\n\ntheorem index_of_le_length {a : α} {l : list α} : index_of a l ≤ length l :=\nbegin\n  induction l with b l ih, {refl},\n  simp only [length, index_of_cons],\n  by_cases h : a = b, {rw if_pos h, exact nat.zero_le _},\n  rw if_neg h, exact succ_le_succ ih\nend\n\ntheorem index_of_lt_length {a} {l : list α} : index_of a l < length l ↔ a ∈ l :=\n⟨λh, by_contradiction $ λ al, ne_of_lt h $ index_of_eq_length.2 al,\nλal, lt_of_le_of_ne index_of_le_length $ λ h, index_of_eq_length.1 h al⟩\n\nend index_of\n\n/- nth element -/\n\ntheorem nth_le_of_mem : ∀ {a} {l : list α}, a ∈ l → ∃ n h, nth_le l n h = a\n| a (_ :: l) (or.inl rfl) := ⟨0, succ_pos _, rfl⟩\n| a (b :: l) (or.inr m)   :=\n  let ⟨n, h, e⟩ := nth_le_of_mem m in ⟨n+1, succ_lt_succ h, e⟩\n\ntheorem nth_le_nth : ∀ {l : list α} {n} h, nth l n = some (nth_le l n h)\n| (a :: l) 0     h := rfl\n| (a :: l) (n+1) h := @nth_le_nth l n _\n\ntheorem nth_ge_len : ∀ {l : list α} {n}, n ≥ length l → nth l n = none\n| []       n     h := rfl\n| (a :: l) (n+1) h := nth_ge_len (le_of_succ_le_succ h)\n\ntheorem nth_eq_some {l : list α} {n a} : nth l n = some a ↔ ∃ h, nth_le l n h = a :=\n⟨λ e,\n  have h : n < length l, from lt_of_not_ge $ λ hn,\n    by rw nth_ge_len hn at e; contradiction,\n  ⟨h, by rw nth_le_nth h at e;\n    injection e with e; apply nth_le_mem⟩,\nλ ⟨h, e⟩, e ▸ nth_le_nth _⟩\n\ntheorem nth_of_mem {a} {l : list α} (h : a ∈ l) : ∃ n, nth l n = some a :=\nlet ⟨n, h, e⟩ := nth_le_of_mem h in ⟨n, by rw [nth_le_nth, e]⟩\n\ntheorem nth_le_mem : ∀ (l : list α) n h, nth_le l n h ∈ l\n| (a :: l) 0     h := mem_cons_self _ _\n| (a :: l) (n+1) h := mem_cons_of_mem _ (nth_le_mem l _ _)\n\ntheorem nth_mem {l : list α} {n a} (e : nth l n = some a) : a ∈ l :=\nlet ⟨h, e⟩ := nth_eq_some.1 e in e ▸ nth_le_mem _ _ _\n\ntheorem mem_iff_nth_le {a} {l : list α} : a ∈ l ↔ ∃ n h, nth_le l n h = a :=\n⟨nth_le_of_mem, λ ⟨n, h, e⟩, e ▸ nth_le_mem _ _ _⟩\n\ntheorem mem_iff_nth {a} {l : list α} : a ∈ l ↔ ∃ n, nth l n = some a :=\nmem_iff_nth_le.trans $ exists_congr $ λ n, nth_eq_some.symm\n\n@[simp] theorem nth_map (f : α → β) : ∀ l n, nth (map f l) n = (nth l n).map f\n| []       n     := rfl\n| (a :: l) 0     := rfl\n| (a :: l) (n+1) := nth_map l n\n\ntheorem nth_le_map (f : α → β) {l n} (H1 H2) : nth_le (map f l) n H1 = f (nth_le l n H2) :=\noption.some.inj $ by rw [← nth_le_nth, nth_map, nth_le_nth]; refl\n\n@[simp] theorem nth_le_map' (f : α → β) {l n} (H) :\n  nth_le (map f l) n H = f (nth_le l n (length_map f l ▸ H)) :=\nnth_le_map f _ _\n\n@[simp] lemma nth_le_singleton (a : α) {n : ℕ} (hn : n < 1) :\n  nth_le [a] n hn = a :=\nhave hn0 : n = 0 := le_zero_iff.1 (le_of_lt_succ hn),\nby subst hn0; refl\n\nlemma nth_le_append : ∀ {l₁ l₂ : list α} {n : ℕ} (hn₁) (hn₂),\n  (l₁ ++ l₂).nth_le n hn₁ = l₁.nth_le n hn₂\n| []     _ n     hn₁ hn₂  := (not_lt_zero _ hn₂).elim\n| (a::l) _ 0     hn₁ hn₂ := rfl\n| (a::l) _ (n+1) hn₁ hn₂ := by simp only [nth_le, cons_append];\n                         exact nth_le_append _ _\n\n@[simp] lemma nth_le_repeat (a : α) {n m : ℕ} (h : m < n) :\n  (list.repeat a n).nth_le m (by rwa list.length_repeat) = a :=\neq_of_mem_repeat (nth_le_mem _ _ _)\n\nlemma nth_append  {l₁ l₂ : list α} {n : ℕ} (hn : n < l₁.length) :\n  (l₁ ++ l₂).nth n = l₁.nth n :=\nhave hn' : n < (l₁ ++ l₂).length := lt_of_lt_of_le hn\n  (by rw length_append; exact le_add_right _ _),\nby rw [nth_le_nth hn, nth_le_nth hn', nth_le_append]\n\n@[simp] lemma nth_concat_length: ∀ (l : list α) (a : α), (l ++ [a]).nth l.length = a\n| []     a := rfl\n| (b::l) a := by rw [cons_append, length_cons, nth, nth_concat_length]\n\n@[extensionality]\ntheorem ext : ∀ {l₁ l₂ : list α}, (∀n, nth l₁ n = nth l₂ n) → l₁ = l₂\n| []      []       h := rfl\n| (a::l₁) []       h := by have h0 := h 0; contradiction\n| []      (a'::l₂) h := by have h0 := h 0; contradiction\n| (a::l₁) (a'::l₂) h := by have h0 : some a = some a' := h 0; injection h0 with aa;\n    simp only [aa, ext (λn, h (n+1))]; split; refl\n\ntheorem ext_le {l₁ l₂ : list α} (hl : length l₁ = length l₂) (h : ∀n h₁ h₂, nth_le l₁ n h₁ = nth_le l₂ n h₂) : l₁ = l₂ :=\next $ λn, if h₁ : n < length l₁\n  then by rw [nth_le_nth, nth_le_nth, h n h₁ (by rwa [← hl])]\n  else let h₁ := le_of_not_gt h₁ in by rw [nth_ge_len h₁, nth_ge_len (by rwa [← hl])]\n\n@[simp] theorem index_of_nth_le [decidable_eq α] {a : α} : ∀ {l : list α} h, nth_le l (index_of a l) h = a\n| (b::l) h := by by_cases h' : a = b; simp only [h', if_pos, if_false, index_of_cons, nth_le, @index_of_nth_le l]\n\n@[simp] theorem index_of_nth [decidable_eq α] {a : α} {l : list α} (h : a ∈ l) : nth l (index_of a l) = some a :=\nby rw [nth_le_nth, index_of_nth_le (index_of_lt_length.2 h)]\n\ntheorem nth_le_reverse_aux1 : ∀ (l r : list α) (i h1 h2), nth_le (reverse_core l r) (i + length l) h1 = nth_le r i h2\n| []       r i := λh1 h2, rfl\n| (a :: l) r i := by rw (show i + length (a :: l) = i + 1 + length l, from add_right_comm i (length l) 1); exact\n  λh1 h2, nth_le_reverse_aux1 l (a :: r) (i+1) h1 (succ_lt_succ h2)\n\ntheorem nth_le_reverse_aux2 : ∀ (l r : list α) (i : nat) (h1) (h2),\n  nth_le (reverse_core l r) (length l - 1 - i) h1 = nth_le l i h2\n| []       r i     h1 h2 := absurd h2 (not_lt_zero _)\n| (a :: l) r 0     h1 h2 := begin\n    have aux := nth_le_reverse_aux1 l (a :: r) 0,\n    rw zero_add at aux,\n    exact aux _ (zero_lt_succ _)\n  end\n| (a :: l) r (i+1) h1 h2 := begin\n    have aux := nth_le_reverse_aux2 l (a :: r) i,\n    have heq := calc length (a :: l) - 1 - (i + 1)\n          = length l - (1 + i) : by rw add_comm; refl\n      ... = length l - 1 - i   : by rw nat.sub_sub,\n    rw [← heq] at aux,\n    apply aux\n  end\n\n@[simp] theorem nth_le_reverse (l : list α) (i : nat) (h1 h2) :\n  nth_le (reverse l) (length l - 1 - i) h1 = nth_le l i h2 :=\nnth_le_reverse_aux2 _ _ _ _ _\n\nlemma modify_nth_tail_modify_nth_tail {f g : list α → list α} (m : ℕ) :\n  ∀n (l:list α), (l.modify_nth_tail f n).modify_nth_tail g (m + n) =\n    l.modify_nth_tail (λl, (f l).modify_nth_tail g m) n\n| 0     l      := rfl\n| (n+1) []     := rfl\n| (n+1) (a::l) := congr_arg (list.cons a) (modify_nth_tail_modify_nth_tail n l)\n\nlemma modify_nth_tail_modify_nth_tail_le\n  {f g : list α → list α} (m n : ℕ) (l : list α) (h : n ≤ m) :\n  (l.modify_nth_tail f n).modify_nth_tail g m =\n    l.modify_nth_tail (λl, (f l).modify_nth_tail g (m - n)) n :=\nbegin\n  rcases le_iff_exists_add.1 h with ⟨m, rfl⟩,\n  rw [nat.add_sub_cancel_left, add_comm, modify_nth_tail_modify_nth_tail]\nend\n\nlemma modify_nth_tail_modify_nth_tail_same {f g : list α → list α} (n : ℕ) (l:list α) :\n  (l.modify_nth_tail f n).modify_nth_tail g n = l.modify_nth_tail (g ∘ f) n :=\nby rw [modify_nth_tail_modify_nth_tail_le n n l (le_refl n), nat.sub_self]; refl\n\nlemma modify_nth_tail_id :\n  ∀n (l:list α), l.modify_nth_tail id n = l\n| 0     l      := rfl\n| (n+1) []     := rfl\n| (n+1) (a::l) := congr_arg (list.cons a) (modify_nth_tail_id n l)\n\ntheorem remove_nth_eq_nth_tail : ∀ n (l : list α), remove_nth l n = modify_nth_tail tail n l\n| 0     l      := by cases l; refl\n| (n+1) []     := rfl\n| (n+1) (a::l) := congr_arg (cons _) (remove_nth_eq_nth_tail _ _)\n\ntheorem update_nth_eq_modify_nth (a : α) : ∀ n (l : list α),\n  update_nth l n a = modify_nth (λ _, a) n l\n| 0     l      := by cases l; refl\n| (n+1) []     := rfl\n| (n+1) (b::l) := congr_arg (cons _) (update_nth_eq_modify_nth _ _)\n\ntheorem modify_nth_eq_update_nth (f : α → α) : ∀ n (l : list α),\n  modify_nth f n l = ((λ a, update_nth l n (f a)) <$> nth l n).get_or_else l\n| 0     l      := by cases l; refl\n| (n+1) []     := rfl\n| (n+1) (b::l) := (congr_arg (cons b)\n  (modify_nth_eq_update_nth n l)).trans $ by cases nth l n; refl\n\ntheorem nth_modify_nth (f : α → α) : ∀ n (l : list α) m,\n  nth (modify_nth f n l) m = (λ a, if n = m then f a else a) <$> nth l m\n| n     l      0     := by cases l; cases n; refl\n| n     []     (m+1) := by cases n; refl\n| 0     (a::l) (m+1) := by cases nth l m; refl\n| (n+1) (a::l) (m+1) := (nth_modify_nth n l m).trans $\n  by cases nth l m with b; by_cases n = m;\n  simp only [h, if_pos, if_true, if_false, option.map_none, option.map_some, mt succ_inj, not_false_iff]\n\ntheorem modify_nth_tail_length (f : list α → list α) (H : ∀ l, length (f l) = length l) :\n  ∀ n l, length (modify_nth_tail f n l) = length l\n| 0     l      := H _\n| (n+1) []     := rfl\n| (n+1) (a::l) := @congr_arg _ _ _ _ (+1) (modify_nth_tail_length _ _)\n\n@[simp] theorem modify_nth_length (f : α → α) :\n  ∀ n l, length (modify_nth f n l) = length l :=\nmodify_nth_tail_length _ (λ l, by cases l; refl)\n\n@[simp] theorem update_nth_length (l : list α) (n) (a : α) :\n  length (update_nth l n a) = length l :=\nby simp only [update_nth_eq_modify_nth, modify_nth_length]\n\n@[simp] theorem nth_modify_nth_eq (f : α → α) (n) (l : list α) :\n  nth (modify_nth f n l) n = f <$> nth l n :=\nby simp only [nth_modify_nth, if_pos]\n\n@[simp] theorem nth_modify_nth_ne (f : α → α) {m n} (l : list α) (h : m ≠ n) :\n  nth (modify_nth f m l) n = nth l n :=\nby simp only [nth_modify_nth, if_neg h, id_map']\n\ntheorem nth_update_nth_eq (a : α) (n) (l : list α) :\n  nth (update_nth l n a) n = (λ _, a) <$> nth l n :=\nby simp only [update_nth_eq_modify_nth, nth_modify_nth_eq]\n\ntheorem nth_update_nth_of_lt (a : α) {n} {l : list α} (h : n < length l) :\n  nth (update_nth l n a) n = some a :=\nby rw [nth_update_nth_eq, nth_le_nth h]; refl\n\ntheorem nth_update_nth_ne (a : α) {m n} (l : list α) (h : m ≠ n) :\n  nth (update_nth l m a) n = nth l n :=\nby simp only [update_nth_eq_modify_nth, nth_modify_nth_ne _ _ h]\n\nsection insert_nth\nvariable {a : α}\n\n@[simp] lemma insert_nth_nil (a : α) : insert_nth 0 a [] = [a] := rfl\n\nlemma length_insert_nth : ∀n as, n ≤ length as → length (insert_nth n a as) = length as + 1\n| 0     as       h := rfl\n| (n+1) []       h := (nat.not_succ_le_zero _ h).elim\n| (n+1) (a'::as) h := congr_arg nat.succ $ length_insert_nth n as (nat.le_of_succ_le_succ h)\n\nlemma remove_nth_insert_nth (n:ℕ) (l : list α) : (l.insert_nth n a).remove_nth n = l :=\nby rw [remove_nth_eq_nth_tail, insert_nth, modify_nth_tail_modify_nth_tail_same];\nfrom modify_nth_tail_id _ _\n\nlemma insert_nth_remove_nth_of_ge : ∀n m as, n < length as → m ≥ n →\n  insert_nth m a (as.remove_nth n) = (as.insert_nth (m + 1) a).remove_nth n\n| 0     0     []      has _   := (lt_irrefl _ has).elim\n| 0     0     (a::as) has hmn := by simp [remove_nth, insert_nth]\n| 0     (m+1) (a::as) has hmn := rfl\n| (n+1) (m+1) (a::as) has hmn :=\n  congr_arg (cons a) $\n    insert_nth_remove_nth_of_ge n m as (nat.lt_of_succ_lt_succ has) (nat.le_of_succ_le_succ hmn)\n\nlemma insert_nth_remove_nth_of_le : ∀n m as, n < length as → m ≤ n →\n  insert_nth m a (as.remove_nth n) = (as.insert_nth m a).remove_nth (n + 1)\n| n       0       (a :: as) has hmn := rfl\n| (n + 1) (m + 1) (a :: as) has hmn :=\n  congr_arg (cons a) $\n    insert_nth_remove_nth_of_le n m as (nat.lt_of_succ_lt_succ has) (nat.le_of_succ_le_succ hmn)\n\nlemma insert_nth_comm (a b : α) :\n  ∀(i j : ℕ) (l : list α) (h : i ≤ j) (hj : j ≤ length l),\n    (l.insert_nth i a).insert_nth (j + 1) b = (l.insert_nth j b).insert_nth i a\n| 0       j     l      := by simp [insert_nth]\n| (i + 1) 0     l      := assume h, (nat.not_lt_zero _ h).elim\n| (i + 1) (j+1) []     := by simp\n| (i + 1) (j+1) (c::l) :=\n  assume h₀ h₁,\n  by simp [insert_nth]; exact insert_nth_comm i j l (nat.le_of_succ_le_succ h₀) (nat.le_of_succ_le_succ h₁)\n\nend insert_nth\n\n/- take, drop -/\n@[simp] theorem take_zero (l : list α) : take 0 l = [] := rfl\n\n@[simp] theorem take_nil : ∀ n, take n [] = ([] : list α)\n| 0     := rfl\n| (n+1) := rfl\n\ntheorem take_cons (n) (a : α) (l : list α) : take (succ n) (a::l) = a :: take n l := rfl\n\n@[simp] theorem take_all : ∀ (l : list α), take (length l) l = l\n| []     := rfl\n| (a::l) := begin change a :: (take (length l) l) = a :: l, rw take_all end\n\ntheorem take_all_of_ge : ∀ {n} {l : list α}, n ≥ length l → take n l = l\n| 0     []     h := rfl\n| 0     (a::l) h := absurd h (not_le_of_gt (zero_lt_succ _))\n| (n+1) []     h := rfl\n| (n+1) (a::l) h :=\n  begin\n    change a :: take n l = a :: l,\n    rw [take_all_of_ge (le_of_succ_le_succ h)]\n  end\n\n@[simp] theorem take_left : ∀ l₁ l₂ : list α, take (length l₁) (l₁ ++ l₂) = l₁\n| []      l₂ := rfl\n| (a::l₁) l₂ := congr_arg (cons a) (take_left l₁ l₂)\n\ntheorem take_left' {l₁ l₂ : list α} {n} (h : length l₁ = n) :\n  take n (l₁ ++ l₂) = l₁ :=\nby rw ← h; apply take_left\n\ntheorem take_take : ∀ (n m) (l : list α), take n (take m l) = take (min n m) l\n| n         0        l      := by rw [min_zero, take_zero, take_nil]\n| 0         m        l      := by rw [zero_min, take_zero, take_zero]\n| (succ n)  (succ m) nil    := by simp only [take_nil]\n| (succ n)  (succ m) (a::l) := by simp only [take, min_succ_succ, take_take n m l]; split; refl\n\n@[simp] theorem drop_nil : ∀ n, drop n [] = ([] : list α)\n| 0     := rfl\n| (n+1) := rfl\n\n@[simp] theorem drop_one : ∀ l : list α, drop 1 l = tail l\n| []       := rfl\n| (a :: l) := rfl\n\ntheorem drop_add : ∀ m n (l : list α), drop (m + n) l = drop m (drop n l)\n| m 0     l      := rfl\n| m (n+1) []     := (drop_nil _).symm\n| m (n+1) (a::l) := drop_add m n _\n\n@[simp] theorem drop_left : ∀ l₁ l₂ : list α, drop (length l₁) (l₁ ++ l₂) = l₂\n| []      l₂ := rfl\n| (a::l₁) l₂ := drop_left l₁ l₂\n\ntheorem drop_left' {l₁ l₂ : list α} {n} (h : length l₁ = n) :\n  drop n (l₁ ++ l₂) = l₂ :=\nby rw ← h; apply drop_left\n\ntheorem drop_eq_nth_le_cons : ∀ {n} {l : list α} h,\n  drop n l = nth_le l n h :: drop (n+1) l\n| 0     (a::l) h := rfl\n| (n+1) (a::l) h := @drop_eq_nth_le_cons n _ _\n\n@[simp] lemma drop_all (l : list α) : l.drop l.length = [] :=\ncalc l.drop l.length = (l ++ []).drop l.length : by simp\n                 ... = [] : drop_left _ _\n\nlemma drop_append_of_le_length : ∀ {l₁ l₂ : list α} {n : ℕ}, n ≤ l₁.length →\n  (l₁ ++ l₂).drop n = l₁.drop n ++ l₂\n| l₁      l₂ 0     hn := by simp\n| []      l₂ (n+1) hn := absurd hn dec_trivial\n| (a::l₁) l₂ (n+1) hn :=\nby rw [drop, cons_append, drop, drop_append_of_le_length (le_of_succ_le_succ hn)]\n\nlemma take_append_of_le_length : ∀ {l₁ l₂ : list α} {n : ℕ},\n  n ≤ l₁.length → (l₁ ++ l₂).take n = l₁.take n\n| l₁      l₂ 0     hn := by simp\n| []      l₂ (n+1) hn := absurd hn dec_trivial\n| (a::l₁) l₂ (n+1) hn :=\nby rw [list.take, list.cons_append, list.take, take_append_of_le_length (le_of_succ_le_succ hn)]\n\n@[simp] theorem drop_drop (n : ℕ) : ∀ (m) (l : list α), drop n (drop m l) = drop (n + m) l\n| m     []     := by simp\n| 0     l      := by simp\n| (m+1) (a::l) :=\n  calc drop n (drop (m + 1) (a :: l)) = drop n (drop m l) : rfl\n    ... = drop (n + m) l : drop_drop m l\n    ... = drop (n + (m + 1)) (a :: l) : rfl\n\ntheorem drop_take : ∀ (m : ℕ) (n : ℕ) (l : list α),\n  drop m (take (m + n) l) = take n (drop m l)\n| 0     n _      := by simp\n| (m+1) n nil    := by simp\n| (m+1) n (_::l) :=\n  have h: m + 1 + n = (m+n) + 1, by simp,\n  by simpa [take_cons, h] using drop_take m n l\n\ntheorem modify_nth_tail_eq_take_drop (f : list α → list α) (H : f [] = []) :\n  ∀ n l, modify_nth_tail f n l = take n l ++ f (drop n l)\n| 0     l      := rfl\n| (n+1) []     := H.symm\n| (n+1) (b::l) := congr_arg (cons b) (modify_nth_tail_eq_take_drop n l)\n\ntheorem modify_nth_eq_take_drop (f : α → α) :\n  ∀ n l, modify_nth f n l = take n l ++ modify_head f (drop n l) :=\nmodify_nth_tail_eq_take_drop _ rfl\n\ntheorem modify_nth_eq_take_cons_drop (f : α → α) {n l} (h) :\n  modify_nth f n l = take n l ++ f (nth_le l n h) :: drop (n+1) l :=\nby rw [modify_nth_eq_take_drop, drop_eq_nth_le_cons h]; refl\n\ntheorem update_nth_eq_take_cons_drop (a : α) {n l} (h : n < length l) :\n  update_nth l n a = take n l ++ a :: drop (n+1) l :=\nby rw [update_nth_eq_modify_nth, modify_nth_eq_take_cons_drop _ h]\n\n@[simp] lemma update_nth_eq_nil (l : list α) (n : ℕ) (a : α) : l.update_nth n a = [] ↔ l = [] :=\nby cases l; cases n; simp only [update_nth]\n\nsection take'\nvariable [inhabited α]\n\n@[simp] theorem take'_length : ∀ n l, length (@take' α _ n l) = n\n| 0     l := rfl\n| (n+1) l := congr_arg succ (take'_length _ _)\n\n@[simp] theorem take'_nil : ∀ n, take' n (@nil α) = repeat (default _) n\n| 0     := rfl\n| (n+1) := congr_arg (cons _) (take'_nil _)\n\ntheorem take'_eq_take : ∀ {n} {l : list α},\n  n ≤ length l → take' n l = take n l\n| 0     l      h := rfl\n| (n+1) (a::l) h := congr_arg (cons _) $\n  take'_eq_take $ le_of_succ_le_succ h\n\n@[simp] theorem take'_left (l₁ l₂ : list α) : take' (length l₁) (l₁ ++ l₂) = l₁ :=\n(take'_eq_take (by simp only [length_append, nat.le_add_right])).trans (take_left _ _)\n\ntheorem take'_left' {l₁ l₂ : list α} {n} (h : length l₁ = n) :\n  take' n (l₁ ++ l₂) = l₁ :=\nby rw ← h; apply take'_left\n\nend take'\n\n/- foldl, foldr -/\n\nlemma foldl_ext (f g : α → β → α) (a : α)\n  {l : list β} (H : ∀ a : α, ∀ b ∈ l, f a b = g a b) :\n  foldl f a l = foldl g a l :=\nbegin\n  induction l with hd tl ih generalizing a, {refl},\n  unfold foldl,\n  rw [ih (λ a b bin, H a b $ mem_cons_of_mem _ bin), H a hd (mem_cons_self _ _)]\nend\n\nlemma foldr_ext (f g : α → β → β) (b : β)\n  {l : list α} (H : ∀ a ∈ l, ∀ b : β, f a b = g a b) :\n  foldr f b l = foldr g b l :=\nbegin\n  induction l with hd tl ih, {refl},\n  simp only [mem_cons_iff, or_imp_distrib, forall_and_distrib, forall_eq] at H,\n  simp only [foldr, ih H.2, H.1]\nend\n\n@[simp] theorem foldl_nil (f : α → β → α) (a : α) : foldl f a [] = a := rfl\n\n@[simp] theorem foldl_cons (f : α → β → α) (a : α) (b : β) (l : list β) :\n  foldl f a (b::l) = foldl f (f a b) l := rfl\n\n@[simp] theorem foldr_nil (f : α → β → β) (b : β) : foldr f b [] = b := rfl\n\n@[simp] theorem foldr_cons (f : α → β → β) (b : β) (a : α) (l : list α) :\n  foldr f b (a::l) = f a (foldr f b l) := rfl\n\n@[simp] theorem foldl_append (f : α → β → α) :\n  ∀ (a : α) (l₁ l₂ : list β), foldl f a (l₁++l₂) = foldl f (foldl f a l₁) l₂\n| a []      l₂ := rfl\n| a (b::l₁) l₂ := by simp only [cons_append, foldl_cons, foldl_append (f a b) l₁ l₂]\n\n@[simp] theorem foldr_append (f : α → β → β) :\n  ∀ (b : β) (l₁ l₂ : list α), foldr f b (l₁++l₂) = foldr f (foldr f b l₂) l₁\n| b []      l₂ := rfl\n| b (a::l₁) l₂ := by simp only [cons_append, foldr_cons, foldr_append b l₁ l₂]\n\n@[simp] theorem foldl_join (f : α → β → α) :\n  ∀ (a : α) (L : list (list β)), foldl f a (join L) = foldl (foldl f) a L\n| a []     := rfl\n| a (l::L) := by simp only [join, foldl_append, foldl_cons, foldl_join (foldl f a l) L]\n\n@[simp] theorem foldr_join (f : α → β → β) :\n  ∀ (b : β) (L : list (list α)), foldr f b (join L) = foldr (λ l b, foldr f b l) b L\n| a []     := rfl\n| a (l::L) := by simp only [join, foldr_append, foldr_join a L, foldr_cons]\n\ntheorem foldl_reverse (f : α → β → α) (a : α) (l : list β) : foldl f a (reverse l) = foldr (λx y, f y x) a l :=\nby induction l; [refl, simp only [*, reverse_cons, foldl_append, foldl_cons, foldl_nil, foldr]]\n\ntheorem foldr_reverse (f : α → β → β) (a : β) (l : list α) : foldr f a (reverse l) = foldl (λx y, f y x) a l :=\nlet t := foldl_reverse (λx y, f y x) a (reverse l) in\nby rw reverse_reverse l at t; rwa t\n\n@[simp] theorem foldr_eta : ∀ (l : list α), foldr cons [] l = l\n| []     := rfl\n| (x::l) := by simp only [foldr_cons, foldr_eta l]; split; refl\n\n@[simp] theorem reverse_foldl {l : list α} : reverse (foldl (λ t h, h :: t) [] l) = l :=\nby rw ←foldr_reverse; simp\n\n/- scanr -/\n\n@[simp] theorem scanr_nil (f : α → β → β) (b : β) : scanr f b [] = [b] := rfl\n\n@[simp] theorem scanr_aux_cons (f : α → β → β) (b : β) : ∀ (a : α) (l : list α),\n  scanr_aux f b (a::l) = (foldr f b (a::l), scanr f b l)\n| a []     := rfl\n| a (x::l) := let t := scanr_aux_cons x l in\n  by simp only [scanr, scanr_aux, t, foldr_cons]\n\n@[simp] theorem scanr_cons (f : α → β → β) (b : β) (a : α) (l : list α) :\n  scanr f b (a::l) = foldr f b (a::l) :: scanr f b l :=\nby simp only [scanr, scanr_aux_cons, foldr_cons]; split; refl\n\nsection foldl_eq_foldr\n  -- foldl and foldr coincide when f is commutative and associative\n  variables {f : α → α → α} (hcomm : commutative f) (hassoc : associative f)\n\n  include hassoc\n  theorem foldl1_eq_foldr1 : ∀ a b l, foldl f a (l++[b]) = foldr f b (a::l)\n  | a b nil      := rfl\n  | a b (c :: l) := by simp only [cons_append, foldl_cons, foldr_cons, foldl1_eq_foldr1 _ _ l]; rw hassoc\n\n  include hcomm\n  theorem foldl_eq_of_comm_of_assoc : ∀ a b l, foldl f a (b::l) = f b (foldl f a l)\n  | a b  nil    := hcomm a b\n  | a b  (c::l) := by simp only [foldl_cons];\n    rw [← foldl_eq_of_comm_of_assoc, right_comm _ hcomm hassoc]; refl\n\n  theorem foldl_eq_foldr : ∀ a l, foldl f a l = foldr f a l\n  | a nil      := rfl\n  | a (b :: l) :=\n    by simp only [foldr_cons, foldl_eq_of_comm_of_assoc hcomm hassoc]; rw (foldl_eq_foldr a l)\nend foldl_eq_foldr\n\nsection\nvariables {op : α → α → α} [ha : is_associative α op] [hc : is_commutative α op]\nlocal notation a * b := op a b\nlocal notation l <*> a := foldl op a l\n\ninclude ha\n\nlemma foldl_assoc : ∀ {l : list α} {a₁ a₂}, l <*> (a₁ * a₂) = a₁ * (l <*> a₂)\n| [] a₁ a₂ := rfl\n| (a :: l) a₁ a₂ :=\n  calc a::l <*> (a₁ * a₂) = l <*> (a₁ * (a₂ * a)) : by simp only [foldl_cons, ha.assoc]\n    ... = a₁ * (a::l <*> a₂) : by rw [foldl_assoc, foldl_cons]\n\nlemma foldl_op_eq_op_foldr_assoc : ∀{l : list α} {a₁ a₂}, (l <*> a₁) * a₂ = a₁ * l.foldr (*) a₂\n| [] a₁ a₂ := rfl\n| (a :: l) a₁ a₂ := by simp only [foldl_cons, foldr_cons, foldl_assoc, ha.assoc]; rw [foldl_op_eq_op_foldr_assoc]\n\ninclude hc\n\nlemma foldl_assoc_comm_cons {l : list α} {a₁ a₂} : (a₁ :: l) <*> a₂ = a₁ * (l <*> a₂) :=\nby rw [foldl_cons, hc.comm, foldl_assoc]\n\nend\n\n/- mfoldl, mfoldr -/\n\nsection mfoldl_mfoldr\nvariables {m : Type v → Type w} [monad m]\n\n@[simp] theorem mfoldl_nil (f : β → α → m β) {b} : mfoldl f b [] = pure b := rfl\n\n@[simp] theorem mfoldr_nil (f : α → β → m β) {b} : mfoldr f b [] = pure b := rfl\n\n@[simp] theorem mfoldl_cons {f : β → α → m β} {b a l} :\n  mfoldl f b (a :: l) = f b a >>= λ b', mfoldl f b' l := rfl\n\n@[simp] theorem mfoldr_cons {f : α → β → m β} {b a l} :\n  mfoldr f b (a :: l) = mfoldr f b l >>= f a := rfl\n\nvariables [is_lawful_monad m]\n\n@[simp] theorem mfoldl_append {f : β → α → m β} : ∀ {b l₁ l₂},\n  mfoldl f b (l₁ ++ l₂) = mfoldl f b l₁ >>= λ x, mfoldl f x l₂\n| _ []     _ := by simp only [nil_append, mfoldl_nil, pure_bind]\n| _ (_::_) _ := by simp only [cons_append, mfoldl_cons, mfoldl_append, bind_assoc]\n\n@[simp] theorem mfoldr_append {f : α → β → m β} : ∀ {b l₁ l₂},\n  mfoldr f b (l₁ ++ l₂) = mfoldr f b l₂ >>= λ x, mfoldr f x l₁\n| _ []     _ := by simp only [nil_append, mfoldr_nil, bind_pure]\n| _ (_::_) _ := by simp only [mfoldr_cons, cons_append, mfoldr_append, bind_assoc]\n\nend mfoldl_mfoldr\n\n/- sum -/\n\nattribute [to_additive list.sum] list.prod\nattribute [to_additive list.sum.equations._eqn_1] list.prod.equations._eqn_1\n\nsection monoid\nvariables [monoid α] {l l₁ l₂ : list α} {a : α}\n\n@[simp, to_additive list.sum_nil]\ntheorem prod_nil : ([] : list α).prod = 1 := rfl\n\n@[simp, to_additive list.sum_cons]\ntheorem prod_cons : (a::l).prod = a * l.prod :=\ncalc (a::l).prod = foldl (*) (a * 1) l : by simp only [list.prod, foldl_cons, one_mul, mul_one]\n  ... = _ : foldl_assoc\n\n@[simp, to_additive list.sum_append]\ntheorem prod_append : (l₁ ++ l₂).prod = l₁.prod * l₂.prod :=\ncalc (l₁ ++ l₂).prod = foldl (*) (foldl (*) 1 l₁ * 1) l₂ : by simp [list.prod]\n  ... = l₁.prod * l₂.prod : foldl_assoc\n\n@[simp, to_additive list.sum_join]\ntheorem prod_join {l : list (list α)} : l.join.prod = (l.map list.prod).prod :=\nby induction l; [refl, simp only [*, list.join, map, prod_append, prod_cons]]\n\nend monoid\n\n@[simp, to_additive list.sum_erase]\ntheorem prod_erase [decidable_eq α] [comm_monoid α] {a} :\n  Π {l : list α}, a ∈ l → a * (l.erase a).prod = l.prod\n| (b::l) h :=\n  begin\n    rcases eq_or_ne_mem_of_mem h with rfl | ⟨ne, h⟩,\n    { simp only [list.erase, if_pos, prod_cons] },\n    { simp only [list.erase, if_neg (mt eq.symm ne), prod_cons, prod_erase h, mul_left_comm a b] }\n  end\n\nlemma dvd_prod [comm_semiring α] {a} {l : list α} (ha : a ∈ l) : a ∣ l.prod :=\nlet ⟨s, t, h⟩ := mem_split ha in\nby rw [h, prod_append, prod_cons, mul_left_comm]; exact dvd_mul_right _ _\n\n@[simp] theorem sum_const_nat (m n : ℕ) : sum (list.repeat m n) = m * n :=\nby induction n; [refl, simp only [*, repeat_succ, sum_cons, nat.mul_succ, add_comm]]\n\n@[simp] theorem length_join (L : list (list α)) : length (join L) = sum (map length L) :=\nby induction L; [refl, simp only [*, join, map, sum_cons, length_append]]\n\n@[simp] theorem length_bind (l : list α) (f : α → list β) : length (list.bind l f) = sum (map (length ∘ f) l) :=\nby rw [list.bind, length_join, map_map]\n\n/- lexicographic ordering -/\n\ninductive lex (r : α → α → Prop) : list α → list α → Prop\n| nil {} {a l} : lex [] (a :: l)\n| cons {a l₁ l₂} (h : lex l₁ l₂) : lex (a :: l₁) (a :: l₂)\n| rel {a₁ l₁ a₂ l₂} (h : r a₁ a₂) : lex (a₁ :: l₁) (a₂ :: l₂)\n\nnamespace lex\ntheorem cons_iff {r : α → α → Prop} [is_irrefl α r] {a l₁ l₂} :\n  lex r (a :: l₁) (a :: l₂) ↔ lex r l₁ l₂ :=\n⟨λ h, by cases h with _ _ _ _ _ h _ _ _ _ h;\n  [exact h, exact (irrefl_of r a h).elim], lex.cons⟩\n\ninstance is_order_connected (r : α → α → Prop)\n  [is_order_connected α r] [is_trichotomous α r] :\n  is_order_connected (list α) (lex r) :=\n⟨λ l₁, match l₁ with\n| _,     [],    c::l₃, nil    := or.inr nil\n| _,     [],    c::l₃, rel _ := or.inr nil\n| _,     [],    c::l₃, cons _ := or.inr nil\n| _,     b::l₂, c::l₃, nil := or.inl nil\n| a::l₁, b::l₂, c::l₃, rel h :=\n  (is_order_connected.conn _ b _ h).imp rel rel\n| a::l₁, b::l₂, _::l₃, cons h := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match _ l₂ _ h).imp cons cons },\n    { exact or.inr (rel ab) }\n  end\nend⟩\n\ninstance is_trichotomous (r : α → α → Prop) [is_trichotomous α r] :\n  is_trichotomous (list α) (lex r) :=\n⟨λ l₁, match l₁ with\n| [], [] := or.inr (or.inl rfl)\n| [], b::l₂ := or.inl nil\n| a::l₁, [] := or.inr (or.inr nil)\n| a::l₁, b::l₂ := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match l₁ l₂).imp cons\n      (or.imp (congr_arg _) cons) },\n    { exact or.inr (or.inr (rel ab)) }\n  end\nend⟩\n\ninstance is_asymm (r : α → α → Prop)\n  [is_asymm α r] : is_asymm (list α) (lex r) :=\n⟨λ l₁, match l₁ with\n| a::l₁, b::l₂, lex.rel h₁, lex.rel h₂ := asymm h₁ h₂\n| a::l₁, b::l₂, lex.rel h₁, lex.cons h₂ := asymm h₁ h₁\n| a::l₁, b::l₂, lex.cons h₁, lex.rel h₂ := asymm h₂ h₂\n| a::l₁, b::l₂, lex.cons h₁, lex.cons h₂ :=\n  by exact _match _ _ h₁ h₂\nend⟩\n\ninstance is_strict_total_order (r : α → α → Prop)\n  [is_strict_total_order' α r] : is_strict_total_order' (list α) (lex r) :=\n{..is_strict_weak_order_of_is_order_connected}\n\ninstance decidable_rel [decidable_eq α] (r : α → α → Prop)\n  [decidable_rel r] : decidable_rel (lex r)\n| l₁ [] := is_false $ λ h, by cases h\n| [] (b::l₂) := is_true lex.nil\n| (a::l₁) (b::l₂) := begin\n  haveI := decidable_rel l₁ l₂,\n  refine decidable_of_iff (r a b ∨ a = b ∧ lex r l₁ l₂) ⟨λ h, _, λ h, _⟩,\n  { rcases h with h | ⟨rfl, h⟩,\n    { exact lex.rel h },\n    { exact lex.cons h } },\n  { rcases h with _|⟨_,_,_,h⟩|⟨_,_,_,_,h⟩,\n    { exact or.inr ⟨rfl, h⟩ },\n    { exact or.inl h } }\nend\n\ntheorem append_right (r : α → α → Prop) :\n  ∀ {s₁ s₂} t, lex r s₁ s₂ → lex r s₁ (s₂ ++ t)\n| _ _ t nil      := nil\n| _ _ t (cons h) := cons (append_right _ h)\n| _ _ t (rel r)  := rel r\n\ntheorem append_left (R : α → α → Prop) {t₁ t₂} (h : lex R t₁ t₂) :\n  ∀ s, lex R (s ++ t₁) (s ++ t₂)\n| []      := h\n| (a::l) := cons (append_left l)\n\ntheorem imp {r s : α → α → Prop} (H : ∀ a b, r a b → s a b) :\n  ∀ l₁ l₂, lex r l₁ l₂ → lex s l₁ l₂\n| _ _ nil      := nil\n| _ _ (cons h) := cons (imp _ _ h)\n| _ _ (rel r)  := rel (H _ _ r)\n\ntheorem to_ne : ∀ {l₁ l₂ : list α}, lex (≠) l₁ l₂ → l₁ ≠ l₂\n| _ _ (cons h) e := to_ne h (list.cons.inj e).2\n| _ _ (rel r)  e := r (list.cons.inj e).1\n\ntheorem ne_iff {l₁ l₂ : list α} (H : length l₁ ≤ length l₂) :\n  lex (≠) l₁ l₂ ↔ l₁ ≠ l₂ :=\n⟨to_ne, λ h, begin\n  induction l₁ with a l₁ IH generalizing l₂; cases l₂ with b l₂,\n  { contradiction },\n  { apply nil },\n  { exact (not_lt_of_ge H).elim (succ_pos _) },\n  { cases classical.em (a = b) with ab ab,\n    { subst b, apply cons,\n      exact IH (le_of_succ_le_succ H) (mt (congr_arg _) h) },\n    { exact rel ab } }\nend⟩\n\nend lex\n\n--Note: this overrides an instance in core lean\ninstance has_lt' [has_lt α] : has_lt (list α) := ⟨lex (<)⟩\n\ntheorem nil_lt_cons [has_lt α] (a : α) (l : list α) : [] < a :: l :=\nlex.nil\n\ninstance [linear_order α] : linear_order (list α) :=\nlinear_order_of_STO' (lex (<))\n\n--Note: this overrides an instance in core lean\ninstance has_le' [linear_order α] : has_le (list α) :=\npreorder.to_has_le _\n\ninstance [decidable_linear_order α] : decidable_linear_order (list α) :=\ndecidable_linear_order_of_STO' (lex (<))\n\n/- all & any -/\n\n@[simp] theorem all_nil (p : α → bool) : all [] p = tt := rfl\n\n@[simp] theorem all_cons (p : α → bool) (a : α) (l : list α) : all (a::l) p = (p a && all l p) := rfl\n\ntheorem all_iff_forall {p : α → bool} {l : list α} : all l p ↔ ∀ a ∈ l, p a :=\nbegin\n  induction l with a l ih,\n  { exact iff_of_true rfl (forall_mem_nil _) },\n  simp only [all_cons, band_coe_iff, ih, forall_mem_cons]\nend\n\ntheorem all_iff_forall_prop {p : α → Prop} [decidable_pred p]\n  {l : list α} : all l (λ a, p a) ↔ ∀ a ∈ l, p a :=\nby simp only [all_iff_forall, bool.of_to_bool_iff]\n\n@[simp] theorem any_nil (p : α → bool) : any [] p = ff := rfl\n\n@[simp] theorem any_cons (p : α → bool) (a : α) (l : list α) : any (a::l) p = (p a || any l p) := rfl\n\ntheorem any_iff_exists {p : α → bool} {l : list α} : any l p ↔ ∃ a ∈ l, p a :=\nbegin\n  induction l with a l ih,\n  { exact iff_of_false bool.not_ff (not_exists_mem_nil _) },\n  simp only [any_cons, bor_coe_iff, ih, exists_mem_cons_iff]\nend\n\ntheorem any_iff_exists_prop {p : α → Prop} [decidable_pred p]\n  {l : list α} : any l (λ a, p a) ↔ ∃ a ∈ l, p a :=\nby simp [any_iff_exists]\n\ntheorem any_of_mem {p : α → bool} {a : α} {l : list α} (h₁ : a ∈ l) (h₂ : p a) : any l p :=\nany_iff_exists.2 ⟨_, h₁, h₂⟩\n\n@[priority 500] instance decidable_forall_mem {p : α → Prop} [decidable_pred p] (l : list α) :\n  decidable (∀ x ∈ l, p x) :=\ndecidable_of_iff _ all_iff_forall_prop\n\ninstance decidable_exists_mem {p : α → Prop} [decidable_pred p] (l : list α) :\n  decidable (∃ x ∈ l, p x) :=\ndecidable_of_iff _ any_iff_exists_prop\n\n/- map for partial functions -/\n\n/-- Partial map. If `f : Π a, p a → β` is a partial function defined on\n  `a : α` satisfying `p`, then `pmap f l h` is essentially the same as `map f l`\n  but is defined only when all members of `l` satisfy `p`, using the proof\n  to apply `f`. -/\n@[simp] def pmap {p : α → Prop} (f : Π a, p a → β) : Π l : list α, (∀ a ∈ l, p a) → list β\n| []     H := []\n| (a::l) H := f a (forall_mem_cons.1 H).1 :: pmap l (forall_mem_cons.1 H).2\n\n/-- \"Attach\" the proof that the elements of `l` are in `l` to produce a new list\n  with the same elements but in the type `{x // x ∈ l}`. -/\ndef attach (l : list α) : list {x // x ∈ l} := pmap subtype.mk l (λ a, id)\n\ntheorem pmap_eq_map (p : α → Prop) (f : α → β) (l : list α) (H) :\n  @pmap _ _ p (λ a _, f a) l H = map f l :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_congr {p q : α → Prop} {f : Π a, p a → β} {g : Π a, q a → β}\n  (l : list α) {H₁ H₂} (h : ∀ a h₁ h₂, f a h₁ = g a h₂) :\n  pmap f l H₁ = pmap g l H₂ :=\nby induction l with _ _ ih; [refl, rw [pmap, pmap, h, ih]]\n\ntheorem map_pmap {p : α → Prop} (g : β → γ) (f : Π a, p a → β)\n  (l H) : map g (pmap f l H) = pmap (λ a h, g (f a h)) l H :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_eq_map_attach {p : α → Prop} (f : Π a, p a → β)\n  (l H) : pmap f l H = l.attach.map (λ x, f x.1 (H _ x.2)) :=\nby rw [attach, map_pmap]; exact pmap_congr l (λ a h₁ h₂, rfl)\n\ntheorem attach_map_val (l : list α) : l.attach.map subtype.val = l :=\nby rw [attach, map_pmap]; exact (pmap_eq_map _ _ _ _).trans (map_id l)\n\n@[simp] theorem mem_attach (l : list α) : ∀ x, x ∈ l.attach | ⟨a, h⟩ :=\nby have := mem_map.1 (by rw [attach_map_val]; exact h);\n   { rcases this with ⟨⟨_, _⟩, m, rfl⟩, exact m }\n\n@[simp] theorem mem_pmap {p : α → Prop} {f : Π a, p a → β}\n  {l H b} : b ∈ pmap f l H ↔ ∃ a (h : a ∈ l), f a (H a h) = b :=\nby simp only [pmap_eq_map_attach, mem_map, mem_attach, true_and, subtype.exists]\n\n@[simp] theorem length_pmap {p : α → Prop} {f : Π a, p a → β}\n  {l H} : length (pmap f l H) = length l :=\nby induction l; [refl, simp only [*, pmap, length]]\n\n@[simp] lemma length_attach {α} (L : list α) : L.attach.length = L.length := length_pmap\n\n/- find -/\n\nsection find\nvariables {p : α → Prop} [decidable_pred p] {l : list α} {a : α}\n\n@[simp] theorem find_nil (p : α → Prop) [decidable_pred p] : find p [] = none :=\nrfl\n\n@[simp] theorem find_cons_of_pos (l) (h : p a) : find p (a::l) = some a :=\nif_pos h\n\n@[simp] theorem find_cons_of_neg (l) (h : ¬ p a) : find p (a::l) = find p l :=\nif_neg h\n\n@[simp] theorem find_eq_none : find p l = none ↔ ∀ x ∈ l, ¬ p x :=\nbegin\n  induction l with a l IH,\n  { exact iff_of_true rfl (forall_mem_nil _) },\n  rw forall_mem_cons, by_cases h : p a,\n  { simp only [find_cons_of_pos _ h, h, not_true, false_and] },\n  { rwa [find_cons_of_neg _ h, iff_true_intro h, true_and] }\nend\n\n@[simp] theorem find_some (H : find p l = some a) : p a :=\nbegin\n  induction l with b l IH, {contradiction},\n  by_cases h : p b,\n  { rw find_cons_of_pos _ h at H, cases H, exact h },\n  { rw find_cons_of_neg _ h at H, exact IH H }\nend\n\n@[simp] theorem find_mem (H : find p l = some a) : a ∈ l :=\nbegin\n  induction l with b l IH, {contradiction},\n  by_cases h : p b,\n  { rw find_cons_of_pos _ h at H, cases H, apply mem_cons_self },\n  { rw find_cons_of_neg _ h at H, exact mem_cons_of_mem _ (IH H) }\nend\n\nend find\n\n/- lookmap -/\nsection lookmap\nvariables (f : α → option α)\n\n@[simp] theorem lookmap_nil : [].lookmap f = [] := rfl\n\n@[simp] theorem lookmap_cons_none {a : α} (l : list α) (h : f a = none) :\n  (a :: l).lookmap f = a :: l.lookmap f :=\nby simp [lookmap, h]\n\n@[simp] theorem lookmap_cons_some {a b : α} (l : list α) (h : f a = some b) :\n  (a :: l).lookmap f = b :: l :=\nby simp [lookmap, h]\n\ntheorem lookmap_some : ∀ l : list α, l.lookmap some = l\n| []     := rfl\n| (a::l) := rfl\n\ntheorem lookmap_none : ∀ l : list α, l.lookmap (λ _, none) = l\n| []     := rfl\n| (a::l) := congr_arg (cons a) (lookmap_none l)\n\ntheorem lookmap_congr {f g : α → option α} :\n  ∀ {l : list α}, (∀ a ∈ l, f a = g a) → l.lookmap f = l.lookmap g\n| []     H := rfl\n| (a::l) H := begin\n  cases forall_mem_cons.1 H with H₁ H₂,\n  cases h : g a with b,\n  { simp [h, H₁.trans h, lookmap_congr H₂] },\n  { simp [lookmap_cons_some _ _ h, lookmap_cons_some _ _ (H₁.trans h)] }\nend\n\ntheorem lookmap_of_forall_not {l : list α} (H : ∀ a ∈ l, f a = none) : l.lookmap f = l :=\n(lookmap_congr H).trans (lookmap_none l)\n\ntheorem lookmap_map_eq (g : α → β) (h : ∀ a (b ∈ f a), g a = g b) :\n  ∀ l : list α, map g (l.lookmap f) = map g l\n| []     := rfl\n| (a::l) := begin\n  cases h' : f a with b,\n  { simp [h', lookmap_map_eq] },\n  { simp [lookmap_cons_some _ _ h', h _ _ h'] }\nend\n\ntheorem lookmap_id' (h : ∀ a (b ∈ f a), a = b) (l : list α) : l.lookmap f = l :=\nby rw [← map_id (l.lookmap f), lookmap_map_eq, map_id]; exact h\n\ntheorem length_lookmap (l : list α) : length (l.lookmap f) = length l :=\nby rw [← length_map, lookmap_map_eq _ (λ _, ()), length_map]; simp\n\nend lookmap\n\n/- filter_map -/\n\n@[simp] theorem filter_map_nil (f : α → option β) : filter_map f [] = [] := rfl\n\n@[simp] theorem filter_map_cons_none {f : α → option β} (a : α) (l : list α) (h : f a = none) :\n  filter_map f (a :: l) = filter_map f l :=\nby simp only [filter_map, h]\n\n@[simp] theorem filter_map_cons_some (f : α → option β)\n  (a : α) (l : list α) {b : β} (h : f a = some b) :\n  filter_map f (a :: l) = b :: filter_map f l :=\nby simp only [filter_map, h]; split; refl\n\ntheorem filter_map_eq_map (f : α → β) : filter_map (some ∘ f) = map f :=\nbegin\n  funext l,\n  induction l with a l IH, {refl},\n  simp only [filter_map_cons_some (some ∘ f) _ _ rfl, IH, map_cons], split; refl\nend\n\ntheorem filter_map_eq_filter (p : α → Prop) [decidable_pred p] :\n  filter_map (option.guard p) = filter p :=\nbegin\n  funext l,\n  induction l with a l IH, {refl},\n  by_cases pa : p a,\n  { simp only [filter_map, option.guard, IH, if_pos pa, filter_cons_of_pos _ pa], split; refl },\n  { simp only [filter_map, option.guard, IH, if_neg pa, filter_cons_of_neg _ pa] }\nend\n\ntheorem filter_map_filter_map (f : α → option β) (g : β → option γ) (l : list α) :\n  filter_map g (filter_map f l) = filter_map (λ x, (f x).bind g) l :=\nbegin\n  induction l with a l IH, {refl},\n  cases h : f a with b,\n  { rw [filter_map_cons_none _ _ h, filter_map_cons_none, IH],\n    simp only [h, option.none_bind'] },\n  rw filter_map_cons_some _ _ _ h,\n  cases h' : g b with c;\n  [ rw [filter_map_cons_none _ _ h', filter_map_cons_none, IH],\n    rw [filter_map_cons_some _ _ _ h', filter_map_cons_some, IH] ];\n  simp only [h, h', option.some_bind']\nend\n\ntheorem map_filter_map (f : α → option β) (g : β → γ) (l : list α) :\n  map g (filter_map f l) = filter_map (λ x, (f x).map g) l :=\nby rw [← filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_map_map (f : α → β) (g : β → option γ) (l : list α) :\n  filter_map g (map f l) = filter_map (g ∘ f) l :=\nby rw [← filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_filter_map (f : α → option β) (p : β → Prop) [decidable_pred p] (l : list α) :\n  filter p (filter_map f l) = filter_map (λ x, (f x).filter p) l :=\nby rw [← filter_map_eq_filter, filter_map_filter_map]; refl\n\ntheorem filter_map_filter (p : α → Prop) [decidable_pred p] (f : α → option β) (l : list α) :\n  filter_map f (filter p l) = filter_map (λ x, if p x then f x else none) l :=\nbegin\n  rw [← filter_map_eq_filter, filter_map_filter_map], congr,\n  funext x,\n  show (option.guard p x).bind f = ite (p x) (f x) none,\n  by_cases h : p x,\n  { simp only [option.guard, if_pos h, option.some_bind'] },\n  { simp only [option.guard, if_neg h, option.none_bind'] }\nend\n\n@[simp] theorem filter_map_some (l : list α) : filter_map some l = l :=\nby rw filter_map_eq_map; apply map_id\n\n@[simp] theorem mem_filter_map (f : α → option β) (l : list α) {b : β} :\n  b ∈ filter_map f l ↔ ∃ a, a ∈ l ∧ f a = some b :=\nbegin\n  induction l with a l IH,\n  { split, { intro H, cases H }, { rintro ⟨_, H, _⟩, cases H } },\n  cases h : f a with b',\n  { have : f a ≠ some b, {rw h, intro, contradiction},\n    simp only [filter_map_cons_none _ _ h, IH, mem_cons_iff,\n      or_and_distrib_right, exists_or_distrib, exists_eq_left, this, false_or] },\n  { have : f a = some b ↔ b = b',\n    { split; intro t, {rw t at h; injection h}, {exact t.symm ▸ h} },\n      simp only [filter_map_cons_some _ _ _ h, IH, mem_cons_iff,\n        or_and_distrib_right, exists_or_distrib, this, exists_eq_left] }\nend\n\ntheorem map_filter_map_of_inv (f : α → option β) (g : β → α)\n  (H : ∀ x : α, (f x).map g = some x) (l : list α) :\n  map g (filter_map f l) = l :=\nby simp only [map_filter_map, H, filter_map_some]\n\ntheorem filter_map_sublist_filter_map (f : α → option β) {l₁ l₂ : list α}\n  (s : l₁ <+ l₂) : filter_map f l₁ <+ filter_map f l₂ :=\nby induction s with l₁ l₂ a s IH l₁ l₂ a s IH;\n   simp only [filter_map]; cases f a with b;\n   simp only [filter_map, IH, sublist.cons, sublist.cons2]\n\ntheorem map_sublist_map (f : α → β) {l₁ l₂ : list α}\n  (s : l₁ <+ l₂) : map f l₁ <+ map f l₂ :=\nby rw ← filter_map_eq_map; exact filter_map_sublist_filter_map _ s\n\n/- filter -/\n\nsection filter\nvariables {p : α → Prop} [decidable_pred p]\n\nlemma filter_congr {p q : α → Prop} [decidable_pred p] [decidable_pred q]\n  : ∀ {l : list α}, (∀ x ∈ l, p x ↔ q x) → filter p l = filter q l\n| [] _     := rfl\n| (a::l) h := by rw forall_mem_cons at h; by_cases pa : p a;\n  [simp only [filter_cons_of_pos _ pa, filter_cons_of_pos _ (h.1.1 pa), filter_congr h.2],\n   simp only [filter_cons_of_neg _ pa, filter_cons_of_neg _ (mt h.1.2 pa), filter_congr h.2]]; split; refl\n\n@[simp] theorem filter_subset (l : list α) : filter p l ⊆ l :=\nsubset_of_sublist $ filter_sublist l\n\ntheorem of_mem_filter {a : α} : ∀ {l}, a ∈ filter p l → p a\n| (b::l) ain :=\n  if pb : p b then\n    have a ∈ b :: filter p l, by simpa only [filter_cons_of_pos _ pb] using ain,\n    or.elim (eq_or_mem_of_mem_cons this)\n      (assume : a = b, begin rw [← this] at pb, exact pb end)\n      (assume : a ∈ filter p l, of_mem_filter this)\n  else\n    begin simp only [filter_cons_of_neg _ pb] at ain, exact (of_mem_filter ain) end\n\ntheorem mem_of_mem_filter {a : α} {l} (h : a ∈ filter p l) : a ∈ l :=\nfilter_subset l h\n\ntheorem mem_filter_of_mem {a : α} : ∀ {l}, a ∈ l → p a → a ∈ filter p l\n| (_::l) (or.inl rfl) pa := by rw filter_cons_of_pos _ pa; apply mem_cons_self\n| (b::l) (or.inr ain) pa := if pb : p b\n    then by rw [filter_cons_of_pos _ pb]; apply mem_cons_of_mem; apply mem_filter_of_mem ain pa\n    else by rw [filter_cons_of_neg _ pb]; apply mem_filter_of_mem ain pa\n\n@[simp] theorem mem_filter {a : α} {l} : a ∈ filter p l ↔ a ∈ l ∧ p a :=\n⟨λ h, ⟨mem_of_mem_filter h, of_mem_filter h⟩, λ ⟨h₁, h₂⟩, mem_filter_of_mem h₁ h₂⟩\n\ntheorem filter_eq_self {l} : filter p l = l ↔ ∀ a ∈ l, p a :=\nbegin\n  induction l with a l ih,\n  { exact iff_of_true rfl (forall_mem_nil _) },\n  rw forall_mem_cons, by_cases p a,\n  { rw [filter_cons_of_pos _ h, cons_inj', ih, and_iff_right h] },\n  { rw [filter_cons_of_neg _ h],\n    refine iff_of_false _ (mt and.left h), intro e,\n    have := filter_sublist l, rw e at this,\n    exact not_lt_of_ge (length_le_of_sublist this) (lt_succ_self _) }\nend\n\ntheorem filter_eq_nil {l} : filter p l = [] ↔ ∀ a ∈ l, ¬p a :=\nby simp only [eq_nil_iff_forall_not_mem, mem_filter, not_and]\n\ntheorem filter_sublist_filter {l₁ l₂} (s : l₁ <+ l₂) : filter p l₁ <+ filter p l₂ :=\nby rw ← filter_map_eq_filter; exact filter_map_sublist_filter_map _ s\n\ntheorem filter_of_map (f : β → α) (l) : filter p (map f l) = map f (filter (p ∘ f) l) :=\nby rw [← filter_map_eq_map, filter_filter_map, filter_map_filter]; refl\n\n@[simp] theorem filter_filter {q} [decidable_pred q] : ∀ l,\n  filter p (filter q l) = filter (λ a, p a ∧ q a) l\n| [] := rfl\n| (a :: l) := by by_cases hp : p a; by_cases hq : q a; simp only [hp, hq, filter, if_true, if_false,\n    true_and, false_and, filter_filter l, eq_self_iff_true]\n\n@[simp] theorem span_eq_take_drop (p : α → Prop) [decidable_pred p] : ∀ (l : list α), span p l = (take_while p l, drop_while p l)\n| []     := rfl\n| (a::l) := if pa : p a then by simp only [span, if_pos pa, span_eq_take_drop l, take_while, drop_while]\n    else by simp only [span, take_while, drop_while, if_neg pa]\n\n@[simp] theorem take_while_append_drop (p : α → Prop) [decidable_pred p] : ∀ (l : list α), take_while p l ++ drop_while p l = l\n| []     := rfl\n| (a::l) := if pa : p a then by rw [take_while, drop_while, if_pos pa, if_pos pa, cons_append, take_while_append_drop l]\n    else by rw [take_while, drop_while, if_neg pa, if_neg pa, nil_append]\n\n@[simp] theorem countp_nil (p : α → Prop) [decidable_pred p] : countp p [] = 0 := rfl\n\n@[simp] theorem countp_cons_of_pos {a : α} (l) (pa : p a) : countp p (a::l) = countp p l + 1 :=\nif_pos pa\n\n@[simp] theorem countp_cons_of_neg {a : α} (l) (pa : ¬ p a) : countp p (a::l) = countp p l :=\nif_neg pa\n\ntheorem countp_eq_length_filter (l) : countp p l = length (filter p l) :=\nby induction l with x l ih; [refl, by_cases (p x)]; [simp only [filter_cons_of_pos _ h, countp, ih, if_pos h],\n  simp only [countp_cons_of_neg _ h, ih, filter_cons_of_neg _ h]]; refl\nlocal attribute [simp] countp_eq_length_filter\n\n@[simp] theorem countp_append (l₁ l₂) : countp p (l₁ ++ l₂) = countp p l₁ + countp p l₂ :=\nby simp only [countp_eq_length_filter, filter_append, length_append]\n\ntheorem countp_pos {l} : 0 < countp p l ↔ ∃ a ∈ l, p a :=\nby simp only [countp_eq_length_filter, length_pos_iff_exists_mem, mem_filter, exists_prop]\n\ntheorem countp_le_of_sublist {l₁ l₂} (s : l₁ <+ l₂) : countp p l₁ ≤ countp p l₂ :=\nby simpa only [countp_eq_length_filter] using length_le_of_sublist (filter_sublist_filter s)\n\n@[simp] theorem countp_filter {q} [decidable_pred q] (l : list α) :\n  countp p (filter q l) = countp (λ a, p a ∧ q a) l :=\nby simp only [countp_eq_length_filter, filter_filter]\n\nend filter\n\n/- count -/\n\nsection count\nvariable [decidable_eq α]\n\n@[simp] theorem count_nil (a : α) : count a [] = 0 := rfl\n\ntheorem count_cons (a b : α) (l : list α) :\n  count a (b :: l) = if a = b then succ (count a l) else count a l := rfl\n\ntheorem count_cons' (a b : α) (l : list α) :\n  count a (b :: l) = count a l + (if a = b then 1 else 0) :=\nbegin rw count_cons, split_ifs; refl end\n\n@[simp] theorem count_cons_self (a : α) (l : list α) : count a (a::l) = succ (count a l) :=\nif_pos rfl\n\n@[simp] theorem count_cons_of_ne {a b : α} (h : a ≠ b) (l : list α) : count a (b::l) = count a l :=\nif_neg h\n\ntheorem count_le_of_sublist (a : α) {l₁ l₂} : l₁ <+ l₂ → count a l₁ ≤ count a l₂ :=\ncountp_le_of_sublist\n\ntheorem count_le_count_cons (a b : α) (l : list α) : count a l ≤ count a (b :: l) :=\ncount_le_of_sublist _ (sublist_cons _ _)\n\ntheorem count_singleton (a : α) : count a [a] = 1 := if_pos rfl\n\n@[simp] theorem count_append (a : α) : ∀ l₁ l₂, count a (l₁ ++ l₂) = count a l₁ + count a l₂ :=\ncountp_append\n\n@[simp] theorem count_concat (a : α) (l : list α) : count a (concat l a) = succ (count a l) :=\nby rw [concat_eq_append, count_append, count_singleton]\n\ntheorem count_pos {a : α} {l : list α} : 0 < count a l ↔ a ∈ l :=\nby simp only [count, countp_pos, exists_prop, exists_eq_right']\n\n@[simp] theorem count_eq_zero_of_not_mem {a : α} {l : list α} (h : a ∉ l) : count a l = 0 :=\nby_contradiction $ λ h', h $ count_pos.1 (nat.pos_of_ne_zero h')\n\ntheorem not_mem_of_count_eq_zero {a : α} {l : list α} (h : count a l = 0) : a ∉ l :=\nλ h', ne_of_gt (count_pos.2 h') h\n\n@[simp] theorem count_repeat (a : α) (n : ℕ) : count a (repeat a n) = n :=\nby rw [count, countp_eq_length_filter, filter_eq_self.2, length_repeat];\n   exact λ b m, (eq_of_mem_repeat m).symm\n\ntheorem le_count_iff_repeat_sublist {a : α} {l : list α} {n : ℕ} : n ≤ count a l ↔ repeat a n <+ l :=\n⟨λ h, ((repeat_sublist_repeat a).2 h).trans $\n  have filter (eq a) l = repeat a (count a l), from eq_repeat.2\n    ⟨by simp only [count, countp_eq_length_filter], λ b m, (of_mem_filter m).symm⟩,\n  by rw ← this; apply filter_sublist,\n λ h, by simpa only [count_repeat] using count_le_of_sublist a h⟩\n\n@[simp] theorem count_filter {p} [decidable_pred p]\n  {a} {l : list α} (h : p a) : count a (filter p l) = count a l :=\nby simp only [count, countp_filter]; congr; exact\nset.ext (λ b, and_iff_left_of_imp (λ e, e ▸ h))\n\nend count\n\n/- prefix, suffix, infix -/\n\n@[simp] theorem prefix_append (l₁ l₂ : list α) : l₁ <+: l₁ ++ l₂ := ⟨l₂, rfl⟩\n\n@[simp] theorem suffix_append (l₁ l₂ : list α) : l₂ <:+ l₁ ++ l₂ := ⟨l₁, rfl⟩\n\n@[simp] theorem infix_append (l₁ l₂ l₃ : list α) : l₂ <:+: l₁ ++ l₂ ++ l₃ := ⟨l₁, l₃, rfl⟩\n\ntheorem nil_prefix (l : list α) : [] <+: l := ⟨l, rfl⟩\n\ntheorem nil_suffix (l : list α) : [] <:+ l := ⟨l, append_nil _⟩\n\n@[refl] theorem prefix_refl (l : list α) : l <+: l := ⟨[], append_nil _⟩\n\n@[refl] theorem suffix_refl (l : list α) : l <:+ l := ⟨[], rfl⟩\n\n@[simp] theorem suffix_cons (a : α) : ∀ l, l <:+ a :: l := suffix_append [a]\n\n@[simp] theorem prefix_concat (a : α) (l) : l <+: concat l a :=\nby simp only [concat_eq_append, prefix_append]\n\ntheorem infix_of_prefix {l₁ l₂ : list α} : l₁ <+: l₂ → l₁ <:+: l₂ :=\nλ⟨t, h⟩, ⟨[], t, h⟩\n\ntheorem infix_of_suffix {l₁ l₂ : list α} : l₁ <:+ l₂ → l₁ <:+: l₂ :=\nλ⟨t, h⟩, ⟨t, [], by simp only [h, append_nil]⟩\n\n@[refl] theorem infix_refl (l : list α) : l <:+: l := infix_of_prefix $ prefix_refl l\n\ntheorem nil_infix (l : list α) : [] <:+: l := infix_of_prefix $ nil_prefix l\n\ntheorem infix_cons {L₁ L₂ : list α} {x : α} : L₁ <:+: L₂ → L₁ <:+: x :: L₂ :=\nλ⟨LP, LS, H⟩, ⟨x :: LP, LS, H ▸ rfl⟩\n\n@[trans] theorem is_prefix.trans : ∀ {l₁ l₂ l₃ : list α}, l₁ <+: l₂ → l₂ <+: l₃ → l₁ <+: l₃\n| l ._ ._ ⟨r₁, rfl⟩ ⟨r₂, rfl⟩ := ⟨r₁ ++ r₂, (append_assoc _ _ _).symm⟩\n\n@[trans] theorem is_suffix.trans : ∀ {l₁ l₂ l₃ : list α}, l₁ <:+ l₂ → l₂ <:+ l₃ → l₁ <:+ l₃\n| l ._ ._ ⟨l₁, rfl⟩ ⟨l₂, rfl⟩ := ⟨l₂ ++ l₁, append_assoc _ _ _⟩\n\n@[trans] theorem is_infix.trans : ∀ {l₁ l₂ l₃ : list α}, l₁ <:+: l₂ → l₂ <:+: l₃ → l₁ <:+: l₃\n| l ._ ._ ⟨l₁, r₁, rfl⟩ ⟨l₂, r₂, rfl⟩ := ⟨l₂ ++ l₁, r₁ ++ r₂, by simp only [append_assoc]⟩\n\ntheorem sublist_of_infix {l₁ l₂ : list α} : l₁ <:+: l₂ → l₁ <+ l₂ :=\nλ⟨s, t, h⟩, by rw [← h]; exact (sublist_append_right _ _).trans (sublist_append_left _ _)\n\ntheorem sublist_of_prefix {l₁ l₂ : list α} : l₁ <+: l₂ → l₁ <+ l₂ :=\nsublist_of_infix ∘ infix_of_prefix\n\ntheorem sublist_of_suffix {l₁ l₂ : list α} : l₁ <:+ l₂ → l₁ <+ l₂ :=\nsublist_of_infix ∘ infix_of_suffix\n\ntheorem reverse_suffix {l₁ l₂ : list α} : reverse l₁ <:+ reverse l₂ ↔ l₁ <+: l₂ :=\n⟨λ ⟨r, e⟩, ⟨reverse r,\n  by rw [← reverse_reverse l₁, ← reverse_append, e, reverse_reverse]⟩,\n λ ⟨r, e⟩, ⟨reverse r, by rw [← reverse_append, e]⟩⟩\n\ntheorem reverse_prefix {l₁ l₂ : list α} : reverse l₁ <+: reverse l₂ ↔ l₁ <:+ l₂ :=\nby rw ← reverse_suffix; simp only [reverse_reverse]\n\ntheorem length_le_of_infix {l₁ l₂ : list α} (s : l₁ <:+: l₂) : length l₁ ≤ length l₂ :=\nlength_le_of_sublist $ sublist_of_infix s\n\ntheorem eq_nil_of_infix_nil {l : list α} (s : l <:+: []) : l = [] :=\neq_nil_of_sublist_nil $ sublist_of_infix s\n\ntheorem eq_nil_of_prefix_nil {l : list α} (s : l <+: []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_prefix s\n\ntheorem eq_nil_of_suffix_nil {l : list α} (s : l <:+ []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_suffix s\n\ntheorem infix_iff_prefix_suffix (l₁ l₂ : list α) : l₁ <:+: l₂ ↔ ∃ t, l₁ <+: t ∧ t <:+ l₂ :=\n⟨λ⟨s, t, e⟩, ⟨l₁ ++ t, ⟨_, rfl⟩, by rw [← e, append_assoc]; exact ⟨_, rfl⟩⟩,\nλ⟨._, ⟨t, rfl⟩, ⟨s, e⟩⟩, ⟨s, t, by rw append_assoc; exact e⟩⟩\n\ntheorem eq_of_infix_of_length_eq {l₁ l₂ : list α} (s : l₁ <:+: l₂) : length l₁ = length l₂ → l₁ = l₂ :=\neq_of_sublist_of_length_eq $ sublist_of_infix s\n\ntheorem eq_of_prefix_of_length_eq {l₁ l₂ : list α} (s : l₁ <+: l₂) : length l₁ = length l₂ → l₁ = l₂ :=\neq_of_sublist_of_length_eq $ sublist_of_prefix s\n\ntheorem eq_of_suffix_of_length_eq {l₁ l₂ : list α} (s : l₁ <:+ l₂) : length l₁ = length l₂ → l₁ = l₂ :=\neq_of_sublist_of_length_eq $ sublist_of_suffix s\n\ntheorem prefix_of_prefix_length_le : ∀ {l₁ l₂ l₃ : list α},\n l₁ <+: l₃ → l₂ <+: l₃ → length l₁ ≤ length l₂ → l₁ <+: l₂\n| []      l₂ l₃ h₁ h₂ _ := nil_prefix _\n| (a::l₁) (b::l₂) _ ⟨r₁, rfl⟩ ⟨r₂, e⟩ ll := begin\n  injection e with _ e', subst b,\n  rcases prefix_of_prefix_length_le ⟨_, rfl⟩ ⟨_, e'⟩\n    (le_of_succ_le_succ ll) with ⟨r₃, rfl⟩,\n  exact ⟨r₃, rfl⟩\nend\n\ntheorem prefix_or_prefix_of_prefix {l₁ l₂ l₃ : list α}\n (h₁ : l₁ <+: l₃) (h₂ : l₂ <+: l₃) : l₁ <+: l₂ ∨ l₂ <+: l₁ :=\n(le_total (length l₁) (length l₂)).imp\n  (prefix_of_prefix_length_le h₁ h₂)\n  (prefix_of_prefix_length_le h₂ h₁)\n\ntheorem suffix_of_suffix_length_le {l₁ l₂ l₃ : list α}\n (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) (ll : length l₁ ≤ length l₂) : l₁ <:+ l₂ :=\nreverse_prefix.1 $ prefix_of_prefix_length_le\n  (reverse_prefix.2 h₁) (reverse_prefix.2 h₂) (by simp [ll])\n\ntheorem suffix_or_suffix_of_suffix {l₁ l₂ l₃ : list α}\n (h₁ : l₁ <:+ l₃) (h₂ : l₂ <:+ l₃) : l₁ <:+ l₂ ∨ l₂ <:+ l₁ :=\n(prefix_or_prefix_of_prefix (reverse_prefix.2 h₁) (reverse_prefix.2 h₂)).imp\n  reverse_prefix.1 reverse_prefix.1\n\ntheorem infix_of_mem_join : ∀ {L : list (list α)} {l}, l ∈ L → l <:+: join L\n| (_  :: L) l (or.inl rfl) := infix_append [] _ _\n| (l' :: L) l (or.inr h)   :=\n  is_infix.trans (infix_of_mem_join h) $ infix_of_suffix $ suffix_append _ _\n\ntheorem prefix_append_left_inj {l₁ l₂ : list α} (l) : l ++ l₁ <+: l ++ l₂ ↔ l₁ <+: l₂ :=\nexists_congr $ λ r, by rw [append_assoc, append_left_inj]\n\ntheorem prefix_cons_inj {l₁ l₂ : list α} (a) : a :: l₁ <+: a :: l₂ ↔ l₁ <+: l₂ :=\nprefix_append_left_inj [a]\n\ntheorem take_prefix (n) (l : list α) : take n l <+: l := ⟨_, take_append_drop _ _⟩\n\ntheorem drop_suffix (n) (l : list α) : drop n l <:+ l := ⟨_, take_append_drop _ _⟩\n\ntheorem prefix_iff_eq_append {l₁ l₂ : list α} : l₁ <+: l₂ ↔ l₁ ++ drop (length l₁) l₂ = l₂ :=\n⟨by rintros ⟨r, rfl⟩; rw drop_left, λ e, ⟨_, e⟩⟩\n\ntheorem suffix_iff_eq_append {l₁ l₂ : list α} : l₁ <:+ l₂ ↔ take (length l₂ - length l₁) l₂ ++ l₁ = l₂ :=\n⟨by rintros ⟨r, rfl⟩; simp only [length_append, nat.add_sub_cancel, take_left], λ e, ⟨_, e⟩⟩\n\ntheorem prefix_iff_eq_take {l₁ l₂ : list α} : l₁ <+: l₂ ↔ l₁ = take (length l₁) l₂ :=\n⟨λ h, append_right_cancel $\n  (prefix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n λ e, e.symm ▸ take_prefix _ _⟩\n\ntheorem suffix_iff_eq_drop {l₁ l₂ : list α} : l₁ <:+ l₂ ↔ l₁ = drop (length l₂ - length l₁) l₂ :=\n⟨λ h, append_left_cancel $\n  (suffix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n λ e, e.symm ▸ drop_suffix _ _⟩\n\ninstance decidable_prefix [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <+: l₂)\n| []      l₂ := is_true ⟨l₂, rfl⟩\n| (a::l₁) [] := is_false $ λ ⟨t, te⟩, list.no_confusion te\n| (a::l₁) (b::l₂) :=\n  if h : a = b then\n    @decidable_of_iff _ _ (by rw [← h, prefix_cons_inj])\n      (decidable_prefix l₁ l₂)\n  else\n    is_false $ λ ⟨t, te⟩, h $ by injection te\n\n-- Alternatively, use mem_tails\ninstance decidable_suffix [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <:+ l₂)\n| []      l₂ := is_true ⟨l₂, append_nil _⟩\n| (a::l₁) [] := is_false $ mt (length_le_of_sublist ∘ sublist_of_suffix) dec_trivial\n| l₁      l₂ := let len1 := length l₁, len2 := length l₂ in\n  if hl : len1 ≤ len2 then\n    decidable_of_iff' (l₁ = drop (len2-len1) l₂) suffix_iff_eq_drop\n  else is_false $ λ h, hl $ length_le_of_sublist $ sublist_of_suffix h\n\n@[simp] theorem mem_inits : ∀ (s t : list α), s ∈ inits t ↔ s <+: t\n| s []     := suffices s = nil ↔ s <+: nil, by simpa only [inits, mem_singleton],\n  ⟨λh, h.symm ▸ prefix_refl [], eq_nil_of_prefix_nil⟩\n| s (a::t) :=\n  suffices (s = nil ∨ ∃ l ∈ inits t, a :: l = s) ↔ s <+: a :: t, by simpa,\n  ⟨λo, match s, o with\n  | ._, or.inl rfl := ⟨_, rfl⟩\n  | s, or.inr ⟨r, hr, hs⟩ := let ⟨s, ht⟩ := (mem_inits _ _).1 hr in\n    by rw [← hs, ← ht]; exact ⟨s, rfl⟩\n  end, λmi, match s, mi with\n  | [], ⟨._, rfl⟩ := or.inl rfl\n  | (b::s), ⟨r, hr⟩ := list.no_confusion hr $ λba (st : s++r = t), or.inr $\n    by rw ba; exact ⟨_, (mem_inits _ _).2 ⟨_, st⟩, rfl⟩\n  end⟩\n\n@[simp] theorem mem_tails : ∀ (s t : list α), s ∈ tails t ↔ s <:+ t\n| s []     := by simp only [tails, mem_singleton]; exact ⟨λh, by rw h; exact suffix_refl [], eq_nil_of_suffix_nil⟩\n| s (a::t) := by simp only [tails, mem_cons_iff, mem_tails s t]; exact show s = a :: t ∨ s <:+ t ↔ s <:+ a :: t, from\n  ⟨λo, match s, t, o with\n  | ._, t, or.inl rfl := suffix_refl _\n  | s, ._, or.inr ⟨l, rfl⟩ := ⟨a::l, rfl⟩\n  end, λe, match s, t, e with\n  | ._, t, ⟨[], rfl⟩ := or.inl rfl\n  | s, t, ⟨b::l, he⟩ := list.no_confusion he (λab lt, or.inr ⟨l, lt⟩)\n  end⟩\n\ninstance decidable_infix [decidable_eq α] : ∀ (l₁ l₂ : list α), decidable (l₁ <:+: l₂)\n| []      l₂ := is_true ⟨[], l₂, rfl⟩\n| (a::l₁) [] := is_false $ λ⟨s, t, te⟩, absurd te $ append_ne_nil_of_ne_nil_left _ _ $\n                append_ne_nil_of_ne_nil_right _ _ $ λh, list.no_confusion h\n| l₁      l₂ := decidable_of_decidable_of_iff (list.decidable_bex (λt, l₁ <+: t) (tails l₂)) $\n  by refine (exists_congr (λt, _)).trans (infix_iff_prefix_suffix _ _).symm;\n     exact ⟨λ⟨h1, h2⟩, ⟨h2, (mem_tails _ _).1 h1⟩, λ⟨h2, h1⟩, ⟨(mem_tails _ _).2 h1, h2⟩⟩\n\n/- sublists -/\n\n@[simp] theorem sublists'_nil : sublists' (@nil α) = [[]] := rfl\n\n@[simp] theorem sublists'_singleton (a : α) : sublists' [a] = [[], [a]] := rfl\n\ntheorem map_sublists'_aux (g : list β → list γ) (l : list α) (f r) :\n  map g (sublists'_aux l f r) = sublists'_aux l (g ∘ f) (map g r) :=\nby induction l generalizing f r; [refl, simp only [*, sublists'_aux]]\n\ntheorem sublists'_aux_append (r' : list (list β)) (l : list α) (f r) :\n  sublists'_aux l f (r ++ r') = sublists'_aux l f r ++ r' :=\nby induction l generalizing f r; [refl, simp only [*, sublists'_aux]]\n\ntheorem sublists'_aux_eq_sublists' (l f r) :\n  @sublists'_aux α β l f r = map f (sublists' l) ++ r :=\nby rw [sublists', map_sublists'_aux, ← sublists'_aux_append]; refl\n\n@[simp] theorem sublists'_cons (a : α) (l : list α) :\n  sublists' (a :: l) = sublists' l ++ map (cons a) (sublists' l) :=\nby rw [sublists', sublists'_aux]; simp only [sublists'_aux_eq_sublists', map_id, append_nil]; refl\n\n@[simp] theorem mem_sublists' {s t : list α} : s ∈ sublists' t ↔ s <+ t :=\nbegin\n  induction t with a t IH generalizing s,\n  { simp only [sublists'_nil, mem_singleton],\n    exact ⟨λ h, by rw h, eq_nil_of_sublist_nil⟩ },\n  simp only [sublists'_cons, mem_append, IH, mem_map],\n  split; intro h, rcases h with h | ⟨s, h, rfl⟩,\n  { exact sublist_cons_of_sublist _ h },\n  { exact cons_sublist_cons _ h },\n  { cases h with _ _ _ h s _ _ h,\n    { exact or.inl h },\n    { exact or.inr ⟨s, h, rfl⟩ } }\nend\n\n@[simp] theorem length_sublists' : ∀ l : list α, length (sublists' l) = 2 ^ length l\n| []     := rfl\n| (a::l) := by simp only [sublists'_cons, length_append, length_sublists' l, length_map,\n    length, pow_succ, mul_succ, mul_zero, zero_add]\n\n@[simp] theorem sublists_nil : sublists (@nil α) = [[]] := rfl\n\n@[simp] theorem sublists_singleton (a : α) : sublists [a] = [[], [a]] := rfl\n\ntheorem sublists_aux₁_eq_sublists_aux : ∀ l (f : list α → list β),\n  sublists_aux₁ l f = sublists_aux l (λ ys r, f ys ++ r)\n| []     f := rfl\n| (a::l) f := by rw [sublists_aux₁, sublists_aux]; simp only [*, append_assoc]\n\ntheorem sublists_aux_cons_eq_sublists_aux₁ (l : list α) :\n  sublists_aux l cons = sublists_aux₁ l (λ x, [x]) :=\nby rw [sublists_aux₁_eq_sublists_aux]; refl\n\ntheorem sublists_aux_eq_foldr.aux {a : α} {l : list α}\n  (IH₁ : ∀ (f : list α → list β → list β), sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (IH₂ : ∀ (f : list α → list (list α) → list (list α)),\n      sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (f : list α → list β → list β) : sublists_aux (a::l) f = foldr f [] (sublists_aux (a::l) cons) :=\nbegin\n  simp only [sublists_aux, foldr_cons], rw [IH₂, IH₁], congr' 1,\n  induction sublists_aux l cons with _ _ ih, {refl},\n  simp only [ih, foldr_cons]\nend\n\ntheorem sublists_aux_eq_foldr (l : list α) : ∀ (f : list α → list β → list β),\n  sublists_aux l f = foldr f [] (sublists_aux l cons) :=\nsuffices _ ∧ ∀ f : list α → list (list α) → list (list α),\n    sublists_aux l f = foldr f [] (sublists_aux l cons),\n  from this.1,\nbegin\n  induction l with a l IH, {split; intro; refl},\n  exact ⟨sublists_aux_eq_foldr.aux IH.1 IH.2,\n         sublists_aux_eq_foldr.aux IH.2 IH.2⟩\nend\n\ntheorem sublists_aux_cons_cons (l : list α) (a : α) :\n  sublists_aux (a::l) cons = [a] :: foldr (λys r, ys :: (a :: ys) :: r) [] (sublists_aux l cons) :=\nby rw [← sublists_aux_eq_foldr]; refl\n\ntheorem sublists_aux₁_append : ∀ (l₁ l₂ : list α) (f : list α → list β),\n  sublists_aux₁ (l₁ ++ l₂) f = sublists_aux₁ l₁ f ++\n    sublists_aux₁ l₂ (λ x, f x ++ sublists_aux₁ l₁ (f ∘ (++ x)))\n| []      l₂ f := by simp only [sublists_aux₁, nil_append, append_nil]\n| (a::l₁) l₂ f := by simp only [sublists_aux₁, cons_append, sublists_aux₁_append l₁, append_assoc]; refl\n\ntheorem sublists_aux₁_concat (l : list α) (a : α) (f : list α → list β) :\n  sublists_aux₁ (l ++ [a]) f = sublists_aux₁ l f ++\n    f [a] ++ sublists_aux₁ l (λ x, f (x ++ [a])) :=\nby simp only [sublists_aux₁_append, sublists_aux₁, append_assoc, append_nil]\n\ntheorem sublists_aux₁_bind : ∀ (l : list α)\n  (f : list α → list β) (g : β → list γ),\n  (sublists_aux₁ l f).bind g = sublists_aux₁ l (λ x, (f x).bind g)\n| []     f g := rfl\n| (a::l) f g := by simp only [sublists_aux₁, bind_append, sublists_aux₁_bind l]\n\ntheorem sublists_aux_cons_append (l₁ l₂ : list α) :\n  sublists_aux (l₁ ++ l₂) cons = sublists_aux l₁ cons ++\n    (do x ← sublists_aux l₂ cons, (++ x) <$> sublists l₁) :=\nbegin\n  simp only [sublists, sublists_aux_cons_eq_sublists_aux₁, sublists_aux₁_append, bind_eq_bind, sublists_aux₁_bind],\n  congr, funext x, apply congr_arg _,\n  rw [← bind_ret_eq_map, sublists_aux₁_bind], exact (append_nil _).symm\nend\n\ntheorem sublists_append (l₁ l₂ : list α) :\n  sublists (l₁ ++ l₂) = (do x ← sublists l₂, (++ x) <$> sublists l₁) :=\nby simp only [map, sublists, sublists_aux_cons_append, map_eq_map, bind_eq_bind,\n  cons_bind, map_id', append_nil, cons_append, map_id' (λ _, rfl)]; split; refl\n\n@[simp] theorem sublists_concat (l : list α) (a : α) :\n  sublists (l ++ [a]) = sublists l ++ map (λ x, x ++ [a]) (sublists l) :=\nby rw [sublists_append, sublists_singleton, bind_eq_bind, cons_bind, cons_bind, nil_bind,\n  map_eq_map, map_eq_map, map_id' (append_nil), append_nil]\n\ntheorem sublists_reverse (l : list α) : sublists (reverse l) = map reverse (sublists' l) :=\nby induction l with hd tl ih; [refl,\nsimp only [reverse_cons, sublists_append, sublists'_cons, map_append, ih, sublists_singleton,\n  map_eq_map, bind_eq_bind, map_map, cons_bind, append_nil, nil_bind, (∘)]]\n\ntheorem sublists_eq_sublists' (l : list α) : sublists l = map reverse (sublists' (reverse l)) :=\nby rw [← sublists_reverse, reverse_reverse]\n\ntheorem sublists'_reverse (l : list α) : sublists' (reverse l) = map reverse (sublists l) :=\nby simp only [sublists_eq_sublists', map_map, map_id' (reverse_reverse)]\n\ntheorem sublists'_eq_sublists (l : list α) : sublists' l = map reverse (sublists (reverse l)) :=\nby rw [← sublists'_reverse, reverse_reverse]\n\ntheorem sublists_aux_ne_nil : ∀ (l : list α), [] ∉ sublists_aux l cons\n| [] := id\n| (a::l) := begin\n  rw [sublists_aux_cons_cons],\n  refine not_mem_cons_of_ne_of_not_mem (cons_ne_nil _ _).symm _,\n  have := sublists_aux_ne_nil l, revert this,\n  induction sublists_aux l cons; intro, {rwa foldr},\n  simp only [foldr, mem_cons_iff, false_or, not_or_distrib],\n  exact ⟨ne_of_not_mem_cons this, ih (not_mem_of_not_mem_cons this)⟩\nend\n\n@[simp] theorem mem_sublists {s t : list α} : s ∈ sublists t ↔ s <+ t :=\nby rw [← reverse_sublist_iff, ← mem_sublists',\n       sublists'_reverse, mem_map_of_inj reverse_injective]\n\n@[simp] theorem length_sublists (l : list α) : length (sublists l) = 2 ^ length l :=\nby simp only [sublists_eq_sublists', length_map, length_sublists', length_reverse]\n\ntheorem map_ret_sublist_sublists (l : list α) : map list.ret l <+ sublists l :=\nreverse_rec_on l (nil_sublist _) $\nλ l a IH, by simp only [map, map_append, sublists_concat]; exact\n((append_sublist_append_left _).2 $ singleton_sublist.2 $\n  mem_map.2 ⟨[], mem_sublists.2 (nil_sublist _), by refl⟩).trans\n((append_sublist_append_right _).2 IH)\n\n/- forall₂ -/\n\nsection forall₂\nvariables {r : α → β → Prop} {p : γ → δ → Prop}\nopen relator relation\n\nrun_cmd tactic.mk_iff_of_inductive_prop `list.forall₂ `list.forall₂_iff\n\n@[simp] theorem forall₂_cons {R : α → β → Prop} {a b l₁ l₂} :\n  forall₂ R (a::l₁) (b::l₂) ↔ R a b ∧ forall₂ R l₁ l₂ :=\n⟨λ h, by cases h with h₁ h₂; split; assumption, λ ⟨h₁, h₂⟩, forall₂.cons h₁ h₂⟩\n\ntheorem forall₂.imp {R S : α → β → Prop}\n  (H : ∀ a b, R a b → S a b) {l₁ l₂}\n  (h : forall₂ R l₁ l₂) : forall₂ S l₁ l₂ :=\nby induction h; constructor; solve_by_elim\n\nlemma forall₂.mp {r q s : α → β → Prop} (h : ∀a b, r a b → q a b → s a b) :\n  ∀{l₁ l₂}, forall₂ r l₁ l₂ → forall₂ q l₁ l₂ → forall₂ s l₁ l₂\n| []      []      forall₂.nil           forall₂.nil           := forall₂.nil\n| (a::l₁) (b::l₂) (forall₂.cons hr hrs) (forall₂.cons hq hqs) :=\n  forall₂.cons (h a b hr hq) (forall₂.mp hrs hqs)\n\nlemma forall₂.flip : ∀{a b}, forall₂ (flip r) b a → forall₂ r a b\n| _ _                 forall₂.nil          := forall₂.nil\n| (a :: as) (b :: bs) (forall₂.cons h₁ h₂) := forall₂.cons h₁ h₂.flip\n\nlemma forall₂_same {r : α → α → Prop} : ∀{l}, (∀x∈l, r x x) → forall₂ r l l\n| []      _ := forall₂.nil\n| (a::as) h := forall₂.cons\n    (h _ (mem_cons_self _ _))\n    (forall₂_same $ assume a ha, h a $ mem_cons_of_mem _ ha)\n\nlemma forall₂_refl {r} [is_refl α r] (l : list α) : forall₂ r l l :=\nforall₂_same $ assume a h, is_refl.refl _ _\n\nlemma forall₂_eq_eq_eq : forall₂ ((=) : α → α → Prop) = (=) :=\nbegin\n  funext a b, apply propext,\n  split,\n  { assume h, induction h, {refl}, simp only [*]; split; refl },\n  { assume h, subst h, exact forall₂_refl _ }\nend\n\n@[simp] lemma forall₂_nil_left_iff {l} : forall₂ r nil l ↔ l = nil :=\n⟨λ H, by cases H; refl, by rintro rfl; exact forall₂.nil⟩\n\n@[simp] lemma forall₂_nil_right_iff {l} : forall₂ r l nil ↔ l = nil :=\n⟨λ H, by cases H; refl, by rintro rfl; exact forall₂.nil⟩\n\nlemma forall₂_cons_left_iff {a l u} : forall₂ r (a::l) u ↔ (∃b u', r a b ∧ forall₂ r l u' ∧ u = b :: u') :=\niff.intro\n  (assume h, match u, h with (b :: u'), forall₂.cons h₁ h₂ := ⟨b, u', h₁, h₂, rfl⟩ end)\n  (assume h, match u, h with _, ⟨b, u', h₁, h₂, rfl⟩ := forall₂.cons h₁ h₂ end)\n\nlemma forall₂_cons_right_iff {b l u} :\n  forall₂ r u (b::l) ↔ (∃a u', r a b ∧ forall₂ r u' l ∧ u = a :: u') :=\niff.intro\n  (assume h, match u, h with (b :: u'), forall₂.cons h₁ h₂ := ⟨b, u', h₁, h₂, rfl⟩ end)\n  (assume h, match u, h with _, ⟨b, u', h₁, h₂, rfl⟩ := forall₂.cons h₁ h₂ end)\n\nlemma forall₂_and_left {r : α → β → Prop} {p : α → Prop} :\n  ∀l u, forall₂ (λa b, p a ∧ r a b) l u ↔ (∀a∈l, p a) ∧ forall₂ r l u\n| []     u := by simp only [forall₂_nil_left_iff, forall_prop_of_false (not_mem_nil _), imp_true_iff, true_and]\n| (a::l) u := by simp only [forall₂_and_left l, forall₂_cons_left_iff, forall_mem_cons,\n    and_assoc, and_comm, and.left_comm, exists_and_distrib_left.symm]\n\n@[simp] lemma forall₂_map_left_iff {f : γ → α} :\n  ∀{l u}, forall₂ r (map f l) u ↔ forall₂ (λc b, r (f c) b) l u\n| []     _ := by simp only [map, forall₂_nil_left_iff]\n| (a::l) _ := by simp only [map, forall₂_cons_left_iff, forall₂_map_left_iff]\n\n@[simp] lemma forall₂_map_right_iff {f : γ → β} :\n  ∀{l u}, forall₂ r l (map f u) ↔ forall₂ (λa c, r a (f c)) l u\n| _ []     := by simp only [map, forall₂_nil_right_iff]\n| _ (b::u) := by simp only [map, forall₂_cons_right_iff, forall₂_map_right_iff]\n\nlemma left_unique_forall₂ (hr : left_unique r) : left_unique (forall₂ r)\n| a₀ nil a₁ forall₂.nil forall₂.nil := rfl\n| (a₀::l₀) (b::l) (a₁::l₁) (forall₂.cons ha₀ h₀) (forall₂.cons ha₁ h₁) :=\n  hr ha₀ ha₁ ▸ left_unique_forall₂ h₀ h₁ ▸ rfl\n\nlemma right_unique_forall₂ (hr : right_unique r) : right_unique (forall₂ r)\n| nil a₀ a₁ forall₂.nil forall₂.nil := rfl\n| (b::l) (a₀::l₀) (a₁::l₁) (forall₂.cons ha₀ h₀) (forall₂.cons ha₁ h₁) :=\n  hr ha₀ ha₁ ▸ right_unique_forall₂ h₀ h₁ ▸ rfl\n\nlemma bi_unique_forall₂ (hr : bi_unique r) : bi_unique (forall₂ r) :=\n⟨assume a b c, left_unique_forall₂ hr.1, assume a b c, right_unique_forall₂ hr.2⟩\n\ntheorem forall₂_length_eq {R : α → β → Prop} :\n  ∀ {l₁ l₂}, forall₂ R l₁ l₂ → length l₁ = length l₂\n| _ _ forall₂.nil          := rfl\n| _ _ (forall₂.cons h₁ h₂) := congr_arg succ (forall₂_length_eq h₂)\n\ntheorem forall₂_zip {R : α → β → Prop} :\n  ∀ {l₁ l₂}, forall₂ R l₁ l₂ → ∀ {a b}, (a, b) ∈ zip l₁ l₂ → R a b\n| _ _ (forall₂.cons h₁ h₂) x y (or.inl rfl) := h₁\n| _ _ (forall₂.cons h₁ h₂) x y (or.inr h₃) := forall₂_zip h₂ h₃\n\ntheorem forall₂_iff_zip {R : α → β → Prop} {l₁ l₂} : forall₂ R l₁ l₂ ↔\n  length l₁ = length l₂ ∧ ∀ {a b}, (a, b) ∈ zip l₁ l₂ → R a b :=\n⟨λ h, ⟨forall₂_length_eq h, @forall₂_zip _ _ _ _ _ h⟩,\n λ h, begin\n  cases h with h₁ h₂,\n  induction l₁ with a l₁ IH generalizing l₂,\n  { cases length_eq_zero.1 h₁.symm, constructor },\n  { cases l₂ with b l₂; injection h₁ with h₁,\n    exact forall₂.cons (h₂ $ or.inl rfl) (IH h₁ $ λ a b h, h₂ $ or.inr h) }\nend⟩\n\ntheorem forall₂_take {R : α → β → Prop} :\n  ∀ n {l₁ l₂}, forall₂ R l₁ l₂ → forall₂ R (take n l₁) (take n l₂)\n| 0 _ _ _ := by simp only [forall₂.nil, take]\n| (n+1) _ _ (forall₂.nil) := by simp only [forall₂.nil, take]\n| (n+1) _ _ (forall₂.cons h₁ h₂) := by simp [and.intro h₁ h₂, forall₂_take n]\n\ntheorem forall₂_drop {R : α → β → Prop} :\n  ∀ n {l₁ l₂}, forall₂ R l₁ l₂ → forall₂ R (drop n l₁) (drop n l₂)\n| 0 _ _ h := by simp only [drop, h]\n| (n+1) _ _ (forall₂.nil) := by simp only [forall₂.nil, drop]\n| (n+1) _ _ (forall₂.cons h₁ h₂) := by simp [and.intro h₁ h₂, forall₂_drop n]\n\ntheorem forall₂_take_append {R : α → β → Prop} (l : list α) (l₁ : list β) (l₂ : list β)\n  (h : forall₂ R l (l₁ ++ l₂)) : forall₂ R (list.take (length l₁) l) l₁ :=\nhave h': forall₂ R (take (length l₁) l) (take (length l₁) (l₁ ++ l₂)), from forall₂_take (length l₁) h,\nby rwa [take_left] at h'\n\ntheorem forall₂_drop_append {R : α → β → Prop} (l : list α) (l₁ : list β) (l₂ : list β)\n  (h : forall₂ R l (l₁ ++ l₂)) : forall₂ R (list.drop (length l₁) l) l₂ :=\nhave h': forall₂ R (drop (length l₁) l) (drop (length l₁) (l₁ ++ l₂)), from forall₂_drop (length l₁) h,\nby rwa [drop_left] at h'\n\nlemma rel_mem (hr : bi_unique r) : (r ⇒ forall₂ r ⇒ iff) (∈) (∈)\n| a b h [] [] forall₂.nil := by simp only [not_mem_nil]\n| a b h (a'::as) (b'::bs) (forall₂.cons h₁ h₂) := rel_or (rel_eq hr h h₁) (rel_mem h h₂)\n\nlemma rel_map : ((r ⇒ p) ⇒ forall₂ r ⇒ forall₂ p) map map\n| f g h [] [] forall₂.nil := forall₂.nil\n| f g h (a::as) (b::bs) (forall₂.cons h₁ h₂) := forall₂.cons (h h₁) (rel_map @h h₂)\n\nlemma rel_append : (forall₂ r ⇒ forall₂ r ⇒ forall₂ r) append append\n| [] [] h l₁ l₂ hl := hl\n| (a::as) (b::bs) (forall₂.cons h₁ h₂) l₁ l₂ hl := forall₂.cons h₁ (rel_append h₂ hl)\n\nlemma rel_join : (forall₂ (forall₂ r) ⇒ forall₂ r) join join\n| [] [] forall₂.nil := forall₂.nil\n| (a::as) (b::bs) (forall₂.cons h₁ h₂) := rel_append h₁ (rel_join h₂)\n\nlemma rel_bind : (forall₂ r ⇒ (r ⇒ forall₂ p) ⇒ forall₂ p) list.bind list.bind :=\nassume a b h₁ f g h₂, rel_join (rel_map @h₂ h₁)\n\nlemma rel_foldl : ((p ⇒ r ⇒ p) ⇒ p ⇒ forall₂ r ⇒ p) foldl foldl\n| f g hfg _ _ h _ _ forall₂.nil := h\n| f g hfg x y hxy _ _ (forall₂.cons hab hs) := rel_foldl @hfg (hfg hxy hab) hs\n\nlemma rel_foldr : ((r ⇒ p ⇒ p) ⇒ p ⇒ forall₂ r ⇒ p) foldr foldr\n| f g hfg _ _ h _ _ forall₂.nil := h\n| f g hfg x y hxy _ _ (forall₂.cons hab hs) := hfg hab (rel_foldr @hfg hxy hs)\n\nlemma rel_filter {p : α → Prop} {q : β → Prop} [decidable_pred p] [decidable_pred q]\n  (hpq : (r ⇒ (↔)) p q) :\n  (forall₂ r ⇒ forall₂ r) (filter p) (filter q)\n| _ _ forall₂.nil := forall₂.nil\n| (a::as) (b::bs) (forall₂.cons h₁ h₂) :=\n  begin\n    by_cases p a,\n    { have : q b, { rwa [← hpq h₁] },\n      simp only [filter_cons_of_pos _ h, filter_cons_of_pos _ this, forall₂_cons, h₁, rel_filter h₂, and_true], },\n    { have : ¬ q b, { rwa [← hpq h₁] },\n      simp only [filter_cons_of_neg _ h, filter_cons_of_neg _ this, rel_filter h₂], },\n  end\n\ntheorem filter_map_cons (f : α → option β) (a : α) (l : list α) :\n  filter_map f (a :: l) = option.cases_on (f a) (filter_map f l) (λb, b :: filter_map f l) :=\nbegin\n  generalize eq : f a = b,\n  cases b,\n  { rw filter_map_cons_none _ _ eq },\n  { rw filter_map_cons_some _ _ _ eq },\nend\n\nlemma rel_filter_map {f : α → option γ} {q : β → option δ} :\n  ((r ⇒ option.rel p) ⇒ forall₂ r ⇒ forall₂ p) filter_map filter_map\n| f g hfg _ _ forall₂.nil := forall₂.nil\n| f g hfg (a::as) (b::bs) (forall₂.cons h₁ h₂) :=\n  by rw [filter_map_cons, filter_map_cons];\n  from match f a, g b, hfg h₁ with\n  | _, _, option.rel.none := rel_filter_map @hfg h₂\n  | _, _, option.rel.some h := forall₂.cons h (rel_filter_map @hfg h₂)\n  end\n\n@[to_additive list.rel_sum]\nlemma rel_prod [monoid α] [monoid β]\n  (h : r 1 1) (hf : (r ⇒ r ⇒ r) (*) (*)) : (forall₂ r ⇒ r) prod prod :=\nassume a b, rel_foldl (assume a b, hf) h\n\nend forall₂\n\n/- sections -/\n\ntheorem mem_sections {L : list (list α)} {f} : f ∈ sections L ↔ forall₂ (∈) f L :=\nbegin\n  refine ⟨λ h, _, λ h, _⟩,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall₂.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with ⟨_, _, _, _, rfl⟩,\n    simp only [*, forall₂_cons, true_and] },\n  { induction h with a l f L al fL fs, {exact or.inl rfl},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map],\n    exact ⟨_, fs, _, al, rfl, rfl⟩ }\nend\n\ntheorem mem_sections_length {L : list (list α)} {f} (h : f ∈ sections L) : length f = length L :=\nforall₂_length_eq (mem_sections.1 h)\n\nlemma rel_sections {r : α → β → Prop} : (forall₂ (forall₂ r) ⇒ forall₂ (forall₂ r)) sections sections\n| _ _ forall₂.nil := forall₂.cons forall₂.nil forall₂.nil\n| _ _ (forall₂.cons h₀ h₁) :=\n  rel_bind (rel_sections h₁) (assume _ _ hl, rel_map (assume _ _ ha, forall₂.cons ha hl) h₀)\n\n/- permutations -/\n\nsection permutations\n\n@[simp] theorem permutations_aux_nil (is : list α) : permutations_aux [] is = [] :=\nby rw [permutations_aux, permutations_aux.rec]\n\n@[simp] theorem permutations_aux_cons (t : α) (ts is : list α) :\n  permutations_aux (t :: ts) is = foldr (λy r, (permutations_aux2 t ts r y id).2)\n    (permutations_aux ts (t::is)) (permutations is) :=\nby rw [permutations_aux, permutations_aux.rec]; refl\n\nend permutations\n\n/- insert -/\nsection insert\nvariable [decidable_eq α]\n\n@[simp] theorem insert_nil (a : α) : insert a nil = [a] := rfl\n\ntheorem insert.def (a : α) (l : list α) : insert a l = if a ∈ l then l else a :: l := rfl\n\n@[simp] theorem insert_of_mem {a : α} {l : list α} (h : a ∈ l) : insert a l = l :=\nby simp only [insert.def, if_pos h]\n\n@[simp] theorem insert_of_not_mem {a : α} {l : list α} (h : a ∉ l) : insert a l = a :: l :=\nby simp only [insert.def, if_neg h]; split; refl\n\n@[simp] theorem mem_insert_iff {a b : α} {l : list α} : a ∈ insert b l ↔ a = b ∨ a ∈ l :=\nbegin\n  by_cases h' : b ∈ l,\n  { simp only [insert_of_mem h'],\n    apply (or_iff_right_of_imp _).symm,\n    exact λ e, e.symm ▸ h' },\n  simp only [insert_of_not_mem h', mem_cons_iff]\nend\n\n@[simp] theorem suffix_insert (a : α) (l : list α) : l <:+ insert a l :=\nby by_cases a ∈ l; [simp only [insert_of_mem h], simp only [insert_of_not_mem h, suffix_cons]]\n\n@[simp] theorem mem_insert_self (a : α) (l : list α) : a ∈ insert a l :=\nmem_insert_iff.2 (or.inl rfl)\n\n@[simp] theorem mem_insert_of_mem {a b : α} {l : list α} (h : a ∈ l) : a ∈ insert b l :=\nmem_insert_iff.2 (or.inr h)\n\ntheorem eq_or_mem_of_mem_insert {a b : α} {l : list α} (h : a ∈ insert b l) : a = b ∨ a ∈ l :=\nmem_insert_iff.1 h\n\n@[simp] theorem length_insert_of_mem {a : α} [decidable_eq α] {l : list α} (h : a ∈ l) :\n  length (insert a l) = length l :=\nby rw insert_of_mem h\n\n@[simp] theorem length_insert_of_not_mem {a : α} [decidable_eq α] {l : list α} (h : a ∉ l) :\n  length (insert a l) = length l + 1 :=\nby rw insert_of_not_mem h; refl\n\nend insert\n\n/- erasep -/\nsection erasep\nvariables {p : α → Prop} [decidable_pred p]\n\n@[simp] theorem erasep_nil : [].erasep p = [] := rfl\n\ntheorem erasep_cons (a : α) (l : list α) : (a :: l).erasep p = if p a then l else a :: l.erasep p := rfl\n\n@[simp] theorem erasep_cons_of_pos {a : α} {l : list α} (h : p a) : (a :: l).erasep p = l :=\nby simp [erasep_cons, h]\n\n@[simp] theorem erasep_cons_of_neg {a : α} {l : list α} (h : ¬ p a) : (a::l).erasep p = a :: l.erasep p :=\nby simp [erasep_cons, h]\n\ntheorem erasep_of_forall_not {l : list α}\n  (h : ∀ a ∈ l, ¬ p a) : l.erasep p = l :=\nby induction l with _ _ ih; [refl,\n  simp [h _ (or.inl rfl), ih (forall_mem_of_forall_mem_cons h)]]\n\ntheorem exists_of_erasep {l : list α} {a} (al : a ∈ l) (pa : p a) :\n  ∃ a l₁ l₂, (∀ b ∈ l₁, ¬ p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.erasep p = l₁ ++ l₂ :=\nbegin\n  induction l with b l IH, {cases al},\n  by_cases pb : p b,\n  { exact ⟨b, [], l, forall_mem_nil _, pb, by simp [pb]⟩ },\n  { rcases al with rfl | al, {exact pb.elim pa},\n    rcases IH al with ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩,\n    exact ⟨c, b::l₁, l₂, forall_mem_cons.2 ⟨pb, h₁⟩,\n      h₂, by rw h₃; refl, by simp [pb, h₄]⟩ }\nend\n\ntheorem exists_or_eq_self_of_erasep (p : α → Prop) [decidable_pred p] (l : list α) :\n  l.erasep p = l ∨ ∃ a l₁ l₂, (∀ b ∈ l₁, ¬ p b) ∧ p a ∧ l = l₁ ++ a :: l₂ ∧ l.erasep p = l₁ ++ l₂ :=\nbegin\n  by_cases h : ∃ a ∈ l, p a,\n  { rcases h with ⟨a, ha, pa⟩,\n    exact or.inr (exists_of_erasep ha pa) },\n  { simp at h, exact or.inl (erasep_of_forall_not h) }\nend\n\n@[simp] theorem length_erasep_of_mem {l : list α} {a} (al : a ∈ l) (pa : p a) :\n length (l.erasep p) = pred (length l) :=\nby rcases exists_of_erasep al pa with ⟨_, l₁, l₂, _, _, e₁, e₂⟩;\n   rw e₂; simp [-add_comm, e₁]; refl\n\ntheorem erasep_append_left {a : α} (pa : p a) :\n  ∀ {l₁ : list α} (l₂), a ∈ l₁ → (l₁++l₂).erasep p = l₁.erasep p ++ l₂\n| (x::xs) l₂ h := begin\n  by_cases h' : p x; simp [h'],\n  rw erasep_append_left l₂ (mem_of_ne_of_mem (mt _ h') h),\n  rintro rfl, exact pa\nend\n\ntheorem erasep_append_right : ∀ {l₁ : list α} (l₂), (∀ b ∈ l₁, ¬ p b) → (l₁++l₂).erasep p = l₁ ++ l₂.erasep p\n| []      l₂ h := rfl\n| (x::xs) l₂ h := by simp [(forall_mem_cons.1 h).1,\n  erasep_append_right _ (forall_mem_cons.1 h).2]\n\ntheorem erasep_sublist (l : list α) : l.erasep p <+ l :=\nby rcases exists_or_eq_self_of_erasep p l with h | ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩;\n   [rw h, {rw [h₄, h₃], simp}]\n\ntheorem erasep_subset (l : list α) : l.erasep p ⊆ l :=\nsubset_of_sublist (erasep_sublist l)\n\ntheorem erasep_sublist_erasep {l₁ l₂ : list α} (s : l₁ <+ l₂) : l₁.erasep p <+ l₂.erasep p :=\nbegin\n  induction s,\n  case list.sublist.slnil { refl },\n  case list.sublist.cons : l₁ l₂ a s IH {\n    by_cases h : p a; simp [h],\n    exacts [IH.trans (erasep_sublist _), IH.cons _ _ _] },\n  case list.sublist.cons2 : l₁ l₂ a s IH {\n    by_cases h : p a; simp [h],\n    exacts [s, IH.cons2 _ _ _] }\nend\n\ntheorem mem_of_mem_erasep {a : α} {l : list α} : a ∈ l.erasep p → a ∈ l :=\n@erasep_subset _ _ _ _ _\n\n@[simp] theorem mem_erasep_of_neg {a : α} {l : list α} (pa : ¬ p a) : a ∈ l.erasep p ↔ a ∈ l :=\n⟨mem_of_mem_erasep, λ al, begin\n  rcases exists_or_eq_self_of_erasep p l with h | ⟨c, l₁, l₂, h₁, h₂, h₃, h₄⟩,\n  { rwa h },\n  { rw h₄, rw h₃ at al,\n    have : a ≠ c, {rintro rfl, exact pa.elim h₂},\n    simpa [this] using al }\nend⟩\n\ntheorem erasep_map (f : β → α) :\n  ∀ (l : list β), (map f l).erasep p = map f (l.erasep (p ∘ f))\n| []     := rfl\n| (b::l) := by by_cases p (f b); simp [h, erasep_map l]\n\n@[simp] theorem extractp_eq_find_erasep :\n  ∀ l : list α, extractp p l = (find p l, erasep p l)\n| []     := rfl\n| (a::l) := by by_cases pa : p a; simp [extractp, pa, extractp_eq_find_erasep l]\n\nend erasep\n\n/- erase -/\nsection erase\nvariable [decidable_eq α]\n\n@[simp] theorem erase_nil (a : α) : [].erase a = [] := rfl\n\ntheorem erase_cons (a b : α) (l : list α) : (b :: l).erase a = if b = a then l else b :: l.erase a := rfl\n\n@[simp] theorem erase_cons_head (a : α) (l : list α) : (a :: l).erase a = l :=\nby simp only [erase_cons, if_pos rfl]\n\n@[simp] theorem erase_cons_tail {a b : α} (l : list α) (h : b ≠ a) : (b::l).erase a = b :: l.erase a :=\nby simp only [erase_cons, if_neg h]; split; refl\n\ntheorem erase_eq_erasep (a : α) (l : list α) : l.erase a = l.erasep (eq a) :=\nby { induction l with b l, {refl},\n  by_cases a = b; [simp [h], simp [h, ne.symm h, *]] }\n\n@[simp] theorem erase_of_not_mem {a : α} {l : list α} (h : a ∉ l) : l.erase a = l :=\nby rw [erase_eq_erasep, erasep_of_forall_not]; rintro b h' rfl; exact h h'\n\ntheorem exists_erase_eq {a : α} {l : list α} (h : a ∈ l) :\n  ∃ l₁ l₂, a ∉ l₁ ∧ l = l₁ ++ a :: l₂ ∧ l.erase a = l₁ ++ l₂ :=\nby rcases exists_of_erasep h rfl with ⟨_, l₁, l₂, h₁, rfl, h₂, h₃⟩;\n   rw erase_eq_erasep; exact ⟨l₁, l₂, λ h, h₁ _ h rfl, h₂, h₃⟩\n\n@[simp] theorem length_erase_of_mem {a : α} {l : list α} (h : a ∈ l) : length (l.erase a) = pred (length l) :=\nby rw erase_eq_erasep; exact length_erasep_of_mem h rfl\n\ntheorem erase_append_left {a : α} {l₁ : list α} (l₂) (h : a ∈ l₁) :\n  (l₁++l₂).erase a = l₁.erase a ++ l₂ :=\nby simp [erase_eq_erasep]; exact erasep_append_left (by refl) l₂ h\n\ntheorem erase_append_right {a : α} {l₁ : list α} (l₂) (h : a ∉ l₁) :\n  (l₁++l₂).erase a = l₁ ++ l₂.erase a :=\nby rw [erase_eq_erasep, erase_eq_erasep, erasep_append_right];\n   rintro b h' rfl; exact h h'\n\ntheorem erase_sublist (a : α) (l : list α) : l.erase a <+ l :=\nby rw erase_eq_erasep; apply erasep_sublist\n\ntheorem erase_subset (a : α) (l : list α) : l.erase a ⊆ l :=\nsubset_of_sublist (erase_sublist a l)\n\ntheorem erase_sublist_erase (a : α) {l₁ l₂ : list α} (h : l₁ <+ l₂) : l₁.erase a <+ l₂.erase a :=\nby simp [erase_eq_erasep]; exact erasep_sublist_erasep h\n\ntheorem mem_of_mem_erase {a b : α} {l : list α} : a ∈ l.erase b → a ∈ l :=\n@erase_subset _ _ _ _ _\n\n@[simp] theorem mem_erase_of_ne {a b : α} {l : list α} (ab : a ≠ b) : a ∈ l.erase b ↔ a ∈ l :=\nby rw erase_eq_erasep; exact mem_erasep_of_neg ab.symm\n\ntheorem erase_comm (a b : α) (l : list α) : (l.erase a).erase b = (l.erase b).erase a :=\nif ab : a = b then by rw ab else\nif ha : a ∈ l then\nif hb : b ∈ l then match l, l.erase a, exists_erase_eq ha, hb with\n| ._, ._, ⟨l₁, l₂, ha', rfl, rfl⟩, hb :=\n  if h₁ : b ∈ l₁ then\n    by rw [erase_append_left _ h₁, erase_append_left _ h₁,\n           erase_append_right _ (mt mem_of_mem_erase ha'), erase_cons_head]\n  else\n    by rw [erase_append_right _ h₁, erase_append_right _ h₁, erase_append_right _ ha',\n           erase_cons_tail _ ab, erase_cons_head]\nend\nelse by simp only [erase_of_not_mem hb, erase_of_not_mem (mt mem_of_mem_erase hb)]\nelse by simp only [erase_of_not_mem ha, erase_of_not_mem (mt mem_of_mem_erase ha)]\n\ntheorem map_erase [decidable_eq β] {f : α → β} (finj : injective f) {a : α}\n  (l : list α) : map f (l.erase a) = (map f l).erase (f a) :=\nby rw [erase_eq_erasep, erase_eq_erasep, erasep_map]; congr;\n   ext b; simp [finj.eq_iff]\n\ntheorem map_foldl_erase [decidable_eq β] {f : α → β} (finj : injective f) {l₁ l₂ : list α} :\n  map f (foldl list.erase l₁ l₂) = foldl (λ l a, l.erase (f a)) (map f l₁) l₂ :=\nby induction l₂ generalizing l₁; [refl,\nsimp only [foldl_cons, map_erase finj, *]]\n\n@[simp] theorem count_erase_self (a : α) : ∀ (s : list α), count a (list.erase s a) = pred (count a s)\n| [] := by simp\n| (h :: t) :=\nbegin\n  rw erase_cons,\n  by_cases p : h = a,\n  { rw [if_pos p, count_cons', if_pos p.symm], simp },\n  { rw [if_neg p, count_cons', count_cons', if_neg (λ x : a = h, p x.symm), count_erase_self],\n    simp, }\nend\n\n@[simp] theorem count_erase_of_ne {a b : α} (ab : a ≠ b) : ∀ (s : list α), count a (list.erase s b) = count a s\n| [] := by simp\n| (x :: xs) :=\nbegin\n  rw erase_cons,\n  split_ifs with h,\n  { rw [count_cons', h, if_neg ab], simp },\n  { rw [count_cons', count_cons', count_erase_of_ne] }\nend\n\nend erase\n\n/- diff -/\nsection diff\nvariable [decidable_eq α]\n\n@[simp] theorem diff_nil (l : list α) : l.diff [] = l := rfl\n\n@[simp] theorem diff_cons (l₁ l₂ : list α) (a : α) : l₁.diff (a::l₂) = (l₁.erase a).diff l₂ :=\nif h : a ∈ l₁ then by simp only [list.diff, if_pos h]\nelse by simp only [list.diff, if_neg h, erase_of_not_mem h]\n\n@[simp] theorem nil_diff (l : list α) : [].diff l = [] :=\nby induction l; [refl, simp only [*, diff_cons, erase_of_not_mem (not_mem_nil _)]]\n\ntheorem diff_eq_foldl : ∀ (l₁ l₂ : list α), l₁.diff l₂ = foldl list.erase l₁ l₂\n| l₁ []      := rfl\n| l₁ (a::l₂) := (diff_cons l₁ l₂ a).trans (diff_eq_foldl _ _)\n\n@[simp] theorem diff_append (l₁ l₂ l₃ : list α) : l₁.diff (l₂ ++ l₃) = (l₁.diff l₂).diff l₃ :=\nby simp only [diff_eq_foldl, foldl_append]\n\n@[simp] theorem map_diff [decidable_eq β] {f : α → β} (finj : injective f) {l₁ l₂ : list α} :\n  map f (l₁.diff l₂) = (map f l₁).diff (map f l₂) :=\nby simp only [diff_eq_foldl, foldl_map, map_foldl_erase finj]\n\ntheorem diff_sublist : ∀ l₁ l₂ : list α, l₁.diff l₂ <+ l₁\n| l₁ []      := sublist.refl _\n| l₁ (a::l₂) := calc l₁.diff (a :: l₂) = (l₁.erase a).diff l₂ : diff_cons _ _ _\n  ... <+ l₁.erase a : diff_sublist _ _\n  ... <+ l₁ : list.erase_sublist _ _\n\ntheorem diff_subset (l₁ l₂ : list α) : l₁.diff l₂ ⊆ l₁ :=\nsubset_of_sublist $ diff_sublist _ _\n\ntheorem mem_diff_of_mem {a : α} : ∀ {l₁ l₂ : list α}, a ∈ l₁ → a ∉ l₂ → a ∈ l₁.diff l₂\n| l₁ []      h₁ h₂ := h₁\n| l₁ (b::l₂) h₁ h₂ := by rw diff_cons; exact\n  mem_diff_of_mem ((mem_erase_of_ne (ne_of_not_mem_cons h₂)).2 h₁) (not_mem_of_not_mem_cons h₂)\n\ntheorem diff_sublist_of_sublist : ∀ {l₁ l₂ l₃: list α}, l₁ <+ l₂ → l₁.diff l₃ <+ l₂.diff l₃\n| l₁ l₂ [] h      := h\n| l₁ l₂ (a::l₃) h := by simp only\n  [diff_cons, diff_sublist_of_sublist (erase_sublist_erase _ h)]\n\ntheorem erase_diff_erase_sublist_of_sublist {a : α} : ∀ {l₁ l₂ : list α},\n  l₁ <+ l₂ → (l₂.erase a).diff (l₁.erase a) <+ l₂.diff l₁\n| []      l₂ h := erase_sublist _ _\n| (b::l₁) l₂ h := if heq : b = a then by simp only [heq, erase_cons_head, diff_cons]\n                  else by simpa only [erase_cons_head, erase_cons_tail _ heq, diff_cons, erase_comm a b l₂]\n                  using erase_diff_erase_sublist_of_sublist (erase_sublist_erase b h)\n\nend diff\n\n/- zip & unzip -/\n\n@[simp] theorem zip_cons_cons (a : α) (b : β) (l₁ : list α) (l₂ : list β) :\n  zip (a :: l₁) (b :: l₂) = (a, b) :: zip l₁ l₂ := rfl\n\n@[simp] theorem zip_nil_left (l : list α) : zip ([] : list β) l = [] := rfl\n\n@[simp] theorem zip_nil_right (l : list α) : zip l ([] : list β) = [] :=\nby cases l; refl\n\n@[simp] theorem zip_swap : ∀ (l₁ : list α) (l₂ : list β),\n  (zip l₁ l₂).map prod.swap = zip l₂ l₁\n| []      l₂      := (zip_nil_right _).symm\n| l₁      []      := by rw zip_nil_right; refl\n| (a::l₁) (b::l₂) := by simp only [zip_cons_cons, map_cons, zip_swap l₁ l₂, prod.swap_prod_mk]; split; refl\n\n@[simp] theorem length_zip : ∀ (l₁ : list α) (l₂ : list β),\n   length (zip l₁ l₂) = min (length l₁) (length l₂)\n| []      l₂      := rfl\n| l₁      []      := by simp only [length, zip_nil_right, min_zero]\n| (a::l₁) (b::l₂) := by by simp only [length, zip_cons_cons, length_zip l₁ l₂, min_add_add_right]\n\ntheorem zip_append : ∀ {l₁ l₂ r₁ r₂ : list α} (h : length l₁ = length l₂),\n   zip (l₁ ++ r₁) (l₂ ++ r₂) = zip l₁ l₂ ++ zip r₁ r₂\n| []      l₂      r₁ r₂ h := by simp only [eq_nil_of_length_eq_zero h.symm]; refl\n| l₁      []      r₁ r₂ h := by simp only [eq_nil_of_length_eq_zero h]; refl\n| (a::l₁) (b::l₂) r₁ r₂ h := by simp only [cons_append, zip_cons_cons, zip_append (succ_inj h)]; split; refl\n\ntheorem zip_map (f : α → γ) (g : β → δ) : ∀ (l₁ : list α) (l₂ : list β),\n   zip (l₁.map f) (l₂.map g) = (zip l₁ l₂).map (prod.map f g)\n| []      l₂      := rfl\n| l₁      []      := by simp only [map, zip_nil_right]\n| (a::l₁) (b::l₂) := by simp only [map, zip_cons_cons, zip_map l₁ l₂, prod.map]; split; refl\n\ntheorem zip_map_left (f : α → γ) (l₁ : list α) (l₂ : list β) :\n   zip (l₁.map f) l₂ = (zip l₁ l₂).map (prod.map f id) :=\nby rw [← zip_map, map_id]\n\ntheorem zip_map_right (f : β → γ) (l₁ : list α) (l₂ : list β) :\n   zip l₁ (l₂.map f) = (zip l₁ l₂).map (prod.map id f) :=\nby rw [← zip_map, map_id]\n\ntheorem zip_map' (f : α → β) (g : α → γ) : ∀ (l : list α),\n   zip (l.map f) (l.map g) = l.map (λ a, (f a, g a))\n| []     := rfl\n| (a::l) := by simp only [map, zip_cons_cons, zip_map' l]; split; refl\n\ntheorem mem_zip {a b} : ∀ {l₁ : list α} {l₂ : list β},\n   (a, b) ∈ zip l₁ l₂ → a ∈ l₁ ∧ b ∈ l₂\n| (_::l₁) (_::l₂) (or.inl rfl) := ⟨or.inl rfl, or.inl rfl⟩\n| (a'::l₁) (b'::l₂) (or.inr h) := by split; simp only [mem_cons_iff, or_true, mem_zip h]\n\n@[simp] theorem unzip_nil : unzip (@nil (α × β)) = ([], []) := rfl\n\n@[simp] theorem unzip_cons (a : α) (b : β) (l : list (α × β)) :\n   unzip ((a, b) :: l) = (a :: (unzip l).1, b :: (unzip l).2) :=\nby rw unzip; cases unzip l; refl\n\ntheorem unzip_eq_map : ∀ (l : list (α × β)), unzip l = (l.map prod.fst, l.map prod.snd)\n| []            := rfl\n| ((a, b) :: l) := by simp only [unzip_cons, map_cons, unzip_eq_map l]\n\ntheorem unzip_left (l : list (α × β)) : (unzip l).1 = l.map prod.fst :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_right (l : list (α × β)) : (unzip l).2 = l.map prod.snd :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_swap (l : list (α × β)) : unzip (l.map prod.swap) = (unzip l).swap :=\nby simp only [unzip_eq_map, map_map]; split; refl\n\ntheorem zip_unzip : ∀ (l : list (α × β)), zip (unzip l).1 (unzip l).2 = l\n| []            := rfl\n| ((a, b) :: l) := by simp only [unzip_cons, zip_cons_cons, zip_unzip l]; split; refl\n\ntheorem unzip_zip_left : ∀ {l₁ : list α} {l₂ : list β}, length l₁ ≤ length l₂ →\n  (unzip (zip l₁ l₂)).1 = l₁\n| []      l₂      h := rfl\n| l₁      []      h := by rw eq_nil_of_length_eq_zero (eq_zero_of_le_zero h); refl\n| (a::l₁) (b::l₂) h := by simp only [zip_cons_cons, unzip_cons, unzip_zip_left (le_of_succ_le_succ h)]; split; refl\n\ntheorem unzip_zip_right {l₁ : list α} {l₂ : list β} (h : length l₂ ≤ length l₁) :\n  (unzip (zip l₁ l₂)).2 = l₂ :=\nby rw [← zip_swap, unzip_swap]; exact unzip_zip_left h\n\ntheorem unzip_zip {l₁ : list α} {l₂ : list β} (h : length l₁ = length l₂) :\n  unzip (zip l₁ l₂) = (l₁, l₂) :=\nby rw [← @prod.mk.eta _ _ (unzip (zip l₁ l₂)),\n  unzip_zip_left (le_of_eq h), unzip_zip_right (ge_of_eq h)]\n\n@[simp] theorem length_revzip (l : list α) : length (revzip l) = length l :=\nby simp only [revzip, length_zip, length_reverse, min_self]\n\n@[simp] theorem unzip_revzip (l : list α) : (revzip l).unzip = (l, l.reverse) :=\nunzip_zip (length_reverse l).symm\n\n@[simp] theorem revzip_map_fst (l : list α) : (revzip l).map prod.fst = l :=\nby rw [← unzip_left, unzip_revzip]\n\n@[simp] theorem revzip_map_snd (l : list α) : (revzip l).map prod.snd = l.reverse :=\nby rw [← unzip_right, unzip_revzip]\n\ntheorem reverse_revzip (l : list α) : reverse l.revzip = revzip l.reverse :=\nby rw [← zip_unzip.{u u} (revzip l).reverse, unzip_eq_map]; simp; simp [revzip]\n\ntheorem revzip_swap (l : list α) : (revzip l).map prod.swap = revzip l.reverse :=\nby simp [revzip]\n\n/- enum -/\n\ntheorem length_enum_from : ∀ n (l : list α), length (enum_from n l) = length l\n| n []     := rfl\n| n (a::l) := congr_arg nat.succ (length_enum_from _ _)\n\ntheorem length_enum : ∀ (l : list α), length (enum l) = length l := length_enum_from _\n\n@[simp] theorem enum_from_nth : ∀ n (l : list α) m,\n  nth (enum_from n l) m = (λ a, (n + m, a)) <$> nth l m\n| n []       m     := rfl\n| n (a :: l) 0     := rfl\n| n (a :: l) (m+1) := (enum_from_nth (n+1) l m).trans $\n  by rw [add_right_comm]; refl\n\n@[simp] theorem enum_nth : ∀ (l : list α) n,\n  nth (enum l) n = (λ a, (n, a)) <$> nth l n :=\nby simp only [enum, enum_from_nth, zero_add]; intros; refl\n\n@[simp] theorem enum_from_map_snd : ∀ n (l : list α),\n  map prod.snd (enum_from n l) = l\n| n []       := rfl\n| n (a :: l) := congr_arg (cons _) (enum_from_map_snd _ _)\n\n@[simp] theorem enum_map_snd : ∀ (l : list α),\n  map prod.snd (enum l) = l := enum_from_map_snd _\n\n\n/- product -/\n\n@[simp] theorem nil_product (l : list β) : product (@nil α) l = [] := rfl\n\n@[simp] theorem product_cons (a : α) (l₁ : list α) (l₂ : list β)\n        : product (a::l₁) l₂ = map (λ b, (a, b)) l₂ ++ product l₁ l₂ := rfl\n\n@[simp] theorem product_nil : ∀ (l : list α), product l (@nil β) = []\n| []     := rfl\n| (a::l) := by rw [product_cons, product_nil]; refl\n\n@[simp] theorem mem_product {l₁ : list α} {l₂ : list β} {a : α} {b : β} :\n  (a, b) ∈ product l₁ l₂ ↔ a ∈ l₁ ∧ b ∈ l₂ :=\nby simp only [product, mem_bind, mem_map, prod.ext_iff, exists_prop,\n  and.left_comm, exists_and_distrib_left, exists_eq_left, exists_eq_right]\n\ntheorem length_product (l₁ : list α) (l₂ : list β) :\n  length (product l₁ l₂) = length l₁ * length l₂ :=\nby induction l₁ with x l₁ IH; [exact (zero_mul _).symm,\n  simp only [length, product_cons, length_append, IH,\n    right_distrib, one_mul, length_map, add_comm]]\n\n\n/- sigma -/\nsection\nvariable {σ : α → Type*}\n\n@[simp] theorem nil_sigma (l : Π a, list (σ a)) : (@nil α).sigma l = [] := rfl\n\n@[simp] theorem sigma_cons (a : α) (l₁ : list α) (l₂ : Π a, list (σ a))\n        : (a::l₁).sigma l₂ = map (sigma.mk a) (l₂ a) ++ l₁.sigma l₂ := rfl\n\n@[simp] theorem sigma_nil : ∀ (l : list α), l.sigma (λ a, @nil (σ a)) = []\n| []     := rfl\n| (a::l) := by rw [sigma_cons, sigma_nil]; refl\n\n@[simp] theorem mem_sigma {l₁ : list α} {l₂ : Π a, list (σ a)} {a : α} {b : σ a} :\n  sigma.mk a b ∈ l₁.sigma l₂ ↔ a ∈ l₁ ∧ b ∈ l₂ a :=\nby simp only [list.sigma, mem_bind, mem_map, exists_prop, exists_and_distrib_left,\n  and.left_comm, exists_eq_left, heq_iff_eq, exists_eq_right]\n\ntheorem length_sigma (l₁ : list α) (l₂ : Π a, list (σ a)) :\n  length (l₁.sigma l₂) = (l₁.map (λ a, length (l₂ a))).sum :=\nby induction l₁ with x l₁ IH; [refl,\nsimp only [map, sigma_cons, length_append, length_map, IH, sum_cons]]\nend\n\n/- of_fn -/\n\ntheorem length_of_fn_aux {n} (f : fin n → α) :\n  ∀ m h l, length (of_fn_aux f m h l) = length l + m\n| 0        h l := rfl\n| (succ m) h l := (length_of_fn_aux m _ _).trans (succ_add _ _)\n\n@[simp] theorem length_of_fn {n} (f : fin n → α) : length (of_fn f) = n :=\n(length_of_fn_aux f _ _ _).trans (zero_add _)\n\ntheorem nth_of_fn_aux {n} (f : fin n → α) (i) :\n  ∀ m h l,\n    (∀ i, nth l i = of_fn_nth_val f (i + m)) →\n     nth (of_fn_aux f m h l) i = of_fn_nth_val f i\n| 0        h l H := H i\n| (succ m) h l H := nth_of_fn_aux m _ _ begin\n  intro j, cases j with j,\n  { simp only [nth, of_fn_nth_val, zero_add, dif_pos (show m < n, from h)] },\n  { simp only [nth, H, succ_add] }\nend\n\n@[simp] theorem nth_of_fn {n} (f : fin n → α) (i) :\n  nth (of_fn f) i = of_fn_nth_val f i :=\nnth_of_fn_aux f _ _ _ _ $ λ i,\nby simp only [of_fn_nth_val, dif_neg (not_lt.2 (le_add_left n i))]; refl\n\n@[simp] theorem nth_le_of_fn {n} (f : fin n → α) (i : fin n) :\n  nth_le (of_fn f) i.1 ((length_of_fn f).symm ▸ i.2) = f i :=\noption.some.inj $ by rw [← nth_le_nth];\n  simp only [list.nth_of_fn, of_fn_nth_val, fin.eta, dif_pos i.2]\n\ntheorem array_eq_of_fn {n} (a : array n α) : a.to_list = of_fn a.read :=\nsuffices ∀ {m h l}, d_array.rev_iterate_aux a\n  (λ i, cons) m h l = of_fn_aux (d_array.read a) m h l, from this,\nbegin\n  intros, induction m with m IH generalizing l, {refl},\n  simp only [d_array.rev_iterate_aux, of_fn_aux, IH]\nend\n\ntheorem of_fn_zero (f : fin 0 → α) : of_fn f = [] := rfl\n\ntheorem of_fn_succ {n} (f : fin (succ n) → α) :\n  of_fn f = f 0 :: of_fn (λ i, f i.succ) :=\nsuffices ∀ {m h l}, of_fn_aux f (succ m) (succ_le_succ h) l =\n  f 0 :: of_fn_aux (λ i, f i.succ) m h l, from this,\nbegin\n  intros, induction m with m IH generalizing l, {refl},\n  rw [of_fn_aux, IH], refl\nend\n\ntheorem of_fn_nth_le : ∀ l : list α, of_fn (λ i, nth_le l i.1 i.2) = l\n| [] := rfl\n| (a::l) := by rw of_fn_succ; congr; simp only [fin.succ_val]; exact of_fn_nth_le l\n\n/- disjoint -/\nsection disjoint\n\ntheorem disjoint.symm {l₁ l₂ : list α} (d : disjoint l₁ l₂) : disjoint l₂ l₁\n| a i₂ i₁ := d i₁ i₂\n\n@[simp] theorem disjoint_comm {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ disjoint l₂ l₁ :=\n⟨disjoint.symm, disjoint.symm⟩\n\ntheorem disjoint_left {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ ∀ {a}, a ∈ l₁ → a ∉ l₂ := iff.rfl\n\ntheorem disjoint_right {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ ∀ {a}, a ∈ l₂ → a ∉ l₁ :=\ndisjoint_comm\n\ntheorem disjoint_iff_ne {l₁ l₂ : list α} : disjoint l₁ l₂ ↔ ∀ a ∈ l₁, ∀ b ∈ l₂, a ≠ b :=\nby simp only [disjoint_left, imp_not_comm, forall_eq']\n\ntheorem disjoint_of_subset_left {l₁ l₂ l : list α} (ss : l₁ ⊆ l) (d : disjoint l l₂) : disjoint l₁ l₂\n| x m₁ := d (ss m₁)\n\ntheorem disjoint_of_subset_right {l₁ l₂ l : list α} (ss : l₂ ⊆ l) (d : disjoint l₁ l) : disjoint l₁ l₂\n| x m m₁ := d m (ss m₁)\n\ntheorem disjoint_of_disjoint_cons_left {a : α} {l₁ l₂} : disjoint (a::l₁) l₂ → disjoint l₁ l₂ :=\ndisjoint_of_subset_left (list.subset_cons _ _)\n\ntheorem disjoint_of_disjoint_cons_right {a : α} {l₁ l₂} : disjoint l₁ (a::l₂) → disjoint l₁ l₂ :=\ndisjoint_of_subset_right (list.subset_cons _ _)\n\n@[simp] theorem disjoint_nil_left (l : list α) : disjoint [] l\n| a := (not_mem_nil a).elim\n\n@[simp] theorem singleton_disjoint {l : list α} {a : α} : disjoint [a] l ↔ a ∉ l :=\nby simp only [disjoint, mem_singleton, forall_eq]; refl\n\n@[simp] theorem disjoint_singleton {l : list α} {a : α} : disjoint l [a] ↔ a ∉ l :=\nby rw disjoint_comm; simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_append_left {l₁ l₂ l : list α} :\n  disjoint (l₁++l₂) l ↔ disjoint l₁ l ∧ disjoint l₂ l :=\nby simp only [disjoint, mem_append, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_append_right {l₁ l₂ l : list α} :\n  disjoint l (l₁++l₂) ↔ disjoint l l₁ ∧ disjoint l l₂ :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_append_left]\n\n@[simp] theorem disjoint_cons_left {a : α} {l₁ l₂ : list α} :\n  disjoint (a::l₁) l₂ ↔ a ∉ l₂ ∧ disjoint l₁ l₂ :=\n(@disjoint_append_left _ [a] l₁ l₂).trans $ by simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_cons_right {a : α} {l₁ l₂ : list α} :\n  disjoint l₁ (a::l₂) ↔ a ∉ l₁ ∧ disjoint l₁ l₂ :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_cons_left]\n\ntheorem disjoint_of_disjoint_append_left_left {l₁ l₂ l : list α} (d : disjoint (l₁++l₂) l) : disjoint l₁ l :=\n(disjoint_append_left.1 d).1\n\ntheorem disjoint_of_disjoint_append_left_right {l₁ l₂ l : list α} (d : disjoint (l₁++l₂) l) : disjoint l₂ l :=\n(disjoint_append_left.1 d).2\n\ntheorem disjoint_of_disjoint_append_right_left {l₁ l₂ l : list α} (d : disjoint l (l₁++l₂)) : disjoint l l₁ :=\n(disjoint_append_right.1 d).1\n\ntheorem disjoint_of_disjoint_append_right_right {l₁ l₂ l : list α} (d : disjoint l (l₁++l₂)) : disjoint l l₂ :=\n(disjoint_append_right.1 d).2\n\nend disjoint\n\n/- union -/\nsection union\nvariable [decidable_eq α]\n\n@[simp] theorem nil_union (l : list α) : [] ∪ l = l := rfl\n\n@[simp] theorem cons_union (l₁ l₂ : list α) (a : α) : a :: l₁ ∪ l₂ = insert a (l₁ ∪ l₂) := rfl\n\n@[simp] theorem mem_union {l₁ l₂ : list α} {a : α} : a ∈ l₁ ∪ l₂ ↔ a ∈ l₁ ∨ a ∈ l₂ :=\nby induction l₁; simp only [nil_union, not_mem_nil, false_or, cons_union, mem_insert_iff, mem_cons_iff, or_assoc, *]\n\ntheorem mem_union_left {a : α} {l₁ : list α} (h : a ∈ l₁) (l₂ : list α) : a ∈ l₁ ∪ l₂ :=\nmem_union.2 (or.inl h)\n\ntheorem mem_union_right {a : α} (l₁ : list α) {l₂ : list α} (h : a ∈ l₂) : a ∈ l₁ ∪ l₂ :=\nmem_union.2 (or.inr h)\n\ntheorem sublist_suffix_of_union : ∀ l₁ l₂ : list α, ∃ t, t <+ l₁ ∧ t ++ l₂ = l₁ ∪ l₂\n| [] l₂ := ⟨[], by refl, rfl⟩\n| (a::l₁) l₂ := let ⟨t, s, e⟩ := sublist_suffix_of_union l₁ l₂ in\n  if h : a ∈ l₁ ∪ l₂\n  then ⟨t, sublist_cons_of_sublist _ s, by simp only [e, cons_union, insert_of_mem h]⟩\n  else ⟨a::t, cons_sublist_cons _ s, by simp only [cons_append, cons_union, e, insert_of_not_mem h]; split; refl⟩\n\ntheorem suffix_union_right (l₁ l₂ : list α) : l₂ <:+ l₁ ∪ l₂ :=\n(sublist_suffix_of_union l₁ l₂).imp (λ a, and.right)\n\ntheorem union_sublist_append (l₁ l₂ : list α) : l₁ ∪ l₂ <+ l₁ ++ l₂ :=\nlet ⟨t, s, e⟩ := sublist_suffix_of_union l₁ l₂ in\ne ▸ (append_sublist_append_right _).2 s\n\ntheorem forall_mem_union {p : α → Prop} {l₁ l₂ : list α} :\n  (∀ x ∈ l₁ ∪ l₂, p x) ↔ (∀ x ∈ l₁, p x) ∧ (∀ x ∈ l₂, p x) :=\nby simp only [mem_union, or_imp_distrib, forall_and_distrib]\n\ntheorem forall_mem_of_forall_mem_union_left {p : α → Prop} {l₁ l₂ : list α}\n   (h : ∀ x ∈ l₁ ∪ l₂, p x) : ∀ x ∈ l₁, p x :=\n(forall_mem_union.1 h).1\n\ntheorem forall_mem_of_forall_mem_union_right {p : α → Prop} {l₁ l₂ : list α}\n   (h : ∀ x ∈ l₁ ∪ l₂, p x) : ∀ x ∈ l₂, p x :=\n(forall_mem_union.1 h).2\n\nend union\n\n/- inter -/\nsection inter\nvariable [decidable_eq α]\n\n@[simp] theorem inter_nil (l : list α) : [] ∩ l = [] := rfl\n\n@[simp] theorem inter_cons_of_mem {a : α} (l₁ : list α) {l₂ : list α} (h : a ∈ l₂) :\n  (a::l₁) ∩ l₂ = a :: (l₁ ∩ l₂) :=\nif_pos h\n\n@[simp] theorem inter_cons_of_not_mem {a : α} (l₁ : list α) {l₂ : list α} (h : a ∉ l₂) :\n  (a::l₁) ∩ l₂ = l₁ ∩ l₂ :=\nif_neg h\n\ntheorem mem_of_mem_inter_left {l₁ l₂ : list α} {a : α} : a ∈ l₁ ∩ l₂ → a ∈ l₁ :=\nmem_of_mem_filter\n\ntheorem mem_of_mem_inter_right {l₁ l₂ : list α} {a : α} : a ∈ l₁ ∩ l₂ → a ∈ l₂ :=\nof_mem_filter\n\ntheorem mem_inter_of_mem_of_mem {l₁ l₂ : list α} {a : α} : a ∈ l₁ → a ∈ l₂ → a ∈ l₁ ∩ l₂ :=\nmem_filter_of_mem\n\n@[simp] theorem mem_inter {a : α} {l₁ l₂ : list α} : a ∈ l₁ ∩ l₂ ↔ a ∈ l₁ ∧ a ∈ l₂ :=\nmem_filter\n\ntheorem inter_subset_left (l₁ l₂ : list α) : l₁ ∩ l₂ ⊆ l₁ :=\nfilter_subset _\n\ntheorem inter_subset_right (l₁ l₂ : list α) : l₁ ∩ l₂ ⊆ l₂ :=\nλ a, mem_of_mem_inter_right\n\ntheorem subset_inter {l l₁ l₂ : list α} (h₁ : l ⊆ l₁) (h₂ : l ⊆ l₂) : l ⊆ l₁ ∩ l₂ :=\nλ a h, mem_inter.2 ⟨h₁ h, h₂ h⟩\n\ntheorem inter_eq_nil_iff_disjoint {l₁ l₂ : list α} : l₁ ∩ l₂ = [] ↔ disjoint l₁ l₂ :=\nby simp only [eq_nil_iff_forall_not_mem, mem_inter, not_and]; refl\n\ntheorem forall_mem_inter_of_forall_left {p : α → Prop} {l₁ : list α} (h : ∀ x ∈ l₁, p x)\n     (l₂ : list α) :\n  ∀ x, x ∈ l₁ ∩ l₂ → p x :=\nball.imp_left (λ x, mem_of_mem_inter_left) h\n\ntheorem forall_mem_inter_of_forall_right {p : α → Prop} (l₁ : list α) {l₂ : list α}\n    (h : ∀ x ∈ l₂, p x) :\n  ∀ x, x ∈ l₁ ∩ l₂ → p x :=\nball.imp_left (λ x, mem_of_mem_inter_right) h\n\nend inter\n\n/- bag_inter -/\nsection bag_inter\nvariable [decidable_eq α]\n\n@[simp] theorem nil_bag_inter (l : list α) : [].bag_inter l = [] :=\nby cases l; refl\n\n@[simp] theorem bag_inter_nil (l : list α) : l.bag_inter [] = [] :=\nby cases l; refl\n\n@[simp] theorem cons_bag_inter_of_pos {a} (l₁ : list α) {l₂} (h : a ∈ l₂) :\n  (a :: l₁).bag_inter l₂ = a :: l₁.bag_inter (l₂.erase a) :=\nby cases l₂; exact if_pos h\n\n@[simp] theorem cons_bag_inter_of_neg {a} (l₁ : list α) {l₂} (h : a ∉ l₂) :\n  (a :: l₁).bag_inter l₂ = l₁.bag_inter l₂ :=\nbegin\n  cases l₂, {simp only [bag_inter_nil]},\n  simp only [erase_of_not_mem h, list.bag_inter, if_neg h]\nend\n\n@[simp] theorem mem_bag_inter {a : α} : ∀ {l₁ l₂ : list α}, a ∈ l₁.bag_inter l₂ ↔ a ∈ l₁ ∧ a ∈ l₂\n| []      l₂ := by simp only [nil_bag_inter, not_mem_nil, false_and]\n| (b::l₁) l₂ := begin\n    by_cases b ∈ l₂,\n    { rw [cons_bag_inter_of_pos _ h, mem_cons_iff, mem_cons_iff, mem_bag_inter],\n      by_cases ba : a = b,\n      { simp only [ba, h, eq_self_iff_true, true_or, true_and] },\n      { simp only [mem_erase_of_ne ba, ba, false_or] } },\n    { rw [cons_bag_inter_of_neg _ h, mem_bag_inter, mem_cons_iff, or_and_distrib_right],\n      symmetry, apply or_iff_right_of_imp,\n      rintro ⟨rfl, h'⟩, exact h.elim h' }\n  end\n\n@[simp] theorem count_bag_inter {a : α} :\n  ∀ {l₁ l₂ : list α}, count a (l₁.bag_inter l₂) = min (count a l₁) (count a l₂)\n| []         l₂ := by simp\n| l₁         [] := by simp\n| (h₁ :: l₁) (h₂ :: l₂) :=\nbegin\n  simp only [list.bag_inter, list.mem_cons_iff],\n  by_cases p₁ : h₂ = h₁; by_cases p₂ : h₁ = a,\n  { simp only [p₁, p₂, count_bag_inter, min_succ_succ, erase_cons_head, if_true, mem_cons_iff,\n               count_cons_self, true_or, eq_self_iff_true] },\n  { simp only [p₁, ne.symm p₂, count_bag_inter, count_cons, erase_cons_head, if_true, mem_cons_iff,\n               true_or, eq_self_iff_true, if_false] },\n  { rw p₂ at p₁,\n    by_cases p₃ : a ∈ l₂,\n    { simp only [p₁, ne.symm p₁, p₂, p₃, erase_cons, count_bag_inter, eq.symm (min_succ_succ _ _),\n                 succ_pred_eq_of_pos (count_pos.2 p₃), if_true, mem_cons_iff, false_or,\n                 count_cons_self, eq_self_iff_true, if_false, ne.def, not_false_iff,\n                 count_erase_self, list.count_cons_of_ne] },\n    { simp [ne.symm p₁, p₂, p₃] } },\n  { by_cases p₄ : h₁ ∈ l₂; simp only [ne.symm p₁, ne.symm p₂, p₄, count_bag_inter, if_true, if_false,\n      mem_cons_iff, false_or, eq_self_iff_true, ne.def, not_false_iff,count_erase_of_ne, count_cons_of_ne] }\nend\n\ntheorem bag_inter_sublist_left : ∀ l₁ l₂ : list α, l₁.bag_inter l₂ <+ l₁\n| []      l₂ := by simp [nil_sublist]\n| (b::l₁) l₂ := begin\n  by_cases b ∈ l₂; simp [h],\n  { apply cons_sublist_cons, apply bag_inter_sublist_left },\n  { apply sublist_cons_of_sublist, apply bag_inter_sublist_left }\nend\n\ntheorem bag_inter_nil_iff_inter_nil : ∀ l₁ l₂ : list α, l₁.bag_inter l₂ = [] ↔ l₁ ∩ l₂ = []\n| []      l₂ := by simp\n| (b::l₁) l₂ :=\nbegin\n  by_cases h : b ∈ l₂; simp [h],\n  exact bag_inter_nil_iff_inter_nil l₁ l₂\nend\n\nend bag_inter\n\n/- pairwise relation (generalized no duplicate) -/\n\nsection pairwise\n\nrun_cmd tactic.mk_iff_of_inductive_prop `list.pairwise `list.pairwise_iff\n\nvariable {R : α → α → Prop}\n\ntheorem rel_of_pairwise_cons {a : α} {l : list α}\n  (p : pairwise R (a::l)) : ∀ {a'}, a' ∈ l → R a a' :=\n(pairwise_cons.1 p).1\n\ntheorem pairwise_of_pairwise_cons {a : α} {l : list α}\n  (p : pairwise R (a::l)) : pairwise R l :=\n(pairwise_cons.1 p).2\n\ntheorem pairwise.imp_of_mem {S : α → α → Prop} {l : list α}\n  (H : ∀ {a b}, a ∈ l → b ∈ l → R a b → S a b) (p : pairwise R l) : pairwise S l :=\nbegin\n  induction p with a l r p IH generalizing H; constructor,\n  { exact ball.imp_right\n      (λ x h, H (mem_cons_self _ _) (mem_cons_of_mem _ h)) r },\n  { exact IH (λ a b m m', H\n      (mem_cons_of_mem _ m) (mem_cons_of_mem _ m')) }\nend\n\ntheorem pairwise.imp {S : α → α → Prop}\n  (H : ∀ a b, R a b → S a b) {l : list α} : pairwise R l → pairwise S l :=\npairwise.imp_of_mem (λ a b _ _, H a b)\n\ntheorem pairwise.and {S : α → α → Prop} {l : list α} :\n  pairwise (λ a b, R a b ∧ S a b) l ↔ pairwise R l ∧ pairwise S l :=\n⟨λ h, ⟨h.imp (λ a b h, h.1), h.imp (λ a b h, h.2)⟩,\n λ ⟨hR, hS⟩, begin\n  clear_, induction hR with a l R1 R2 IH;\n  simp only [pairwise.nil, pairwise_cons] at *,\n  exact ⟨λ b bl, ⟨R1 b bl, hS.1 b bl⟩, IH hS.2⟩\n end⟩\n\ntheorem pairwise.imp₂ {S : α → α → Prop} {T : α → α → Prop}\n  (H : ∀ a b, R a b → S a b → T a b) {l : list α}\n  (hR : pairwise R l) (hS : pairwise S l) : pairwise T l :=\n(pairwise.and.2 ⟨hR, hS⟩).imp $ λ a b, and.rec (H a b)\n\ntheorem pairwise.iff_of_mem {S : α → α → Prop} {l : list α}\n  (H : ∀ {a b}, a ∈ l → b ∈ l → (R a b ↔ S a b)) : pairwise R l ↔ pairwise S l :=\n⟨pairwise.imp_of_mem (λ a b m m', (H m m').1),\n pairwise.imp_of_mem (λ a b m m', (H m m').2)⟩\n\ntheorem pairwise.iff {S : α → α → Prop}\n  (H : ∀ a b, R a b ↔ S a b) {l : list α} : pairwise R l ↔ pairwise S l :=\npairwise.iff_of_mem (λ a b _ _, H a b)\n\ntheorem pairwise_of_forall {l : list α} (H : ∀ x y, R x y) : pairwise R l :=\nby induction l; [exact pairwise.nil,\nsimp only [*, pairwise_cons, forall_2_true_iff, and_true]]\n\ntheorem pairwise.and_mem {l : list α} :\n  pairwise R l ↔ pairwise (λ x y, x ∈ l ∧ y ∈ l ∧ R x y) l :=\npairwise.iff_of_mem (by simp only [true_and, iff_self, forall_2_true_iff] {contextual := tt})\n\ntheorem pairwise.imp_mem {l : list α} :\n  pairwise R l ↔ pairwise (λ x y, x ∈ l → y ∈ l → R x y) l :=\npairwise.iff_of_mem (by simp only [forall_prop_of_true, iff_self, forall_2_true_iff] {contextual := tt})\n\ntheorem pairwise_of_sublist : Π {l₁ l₂ : list α}, l₁ <+ l₂ → pairwise R l₂ → pairwise R l₁\n| ._ ._ sublist.slnil h := h\n| ._ ._ (sublist.cons l₁ l₂ a s) (pairwise.cons i n) := pairwise_of_sublist s n\n| ._ ._ (sublist.cons2 l₁ l₂ a s) (pairwise.cons i n) :=\n  (pairwise_of_sublist s n).cons (ball.imp_left (subset_of_sublist s) i)\n\ntheorem forall_of_forall_of_pairwise (H : symmetric R)\n  {l : list α} (H₁ : ∀ x ∈ l, R x x) (H₂ : pairwise R l) :\n  ∀ (x ∈ l) (y ∈ l), R x y :=\nbegin\n  induction l with a l IH, { exact forall_mem_nil _ },\n  cases forall_mem_cons.1 H₁ with H₁₁ H₁₂,\n  cases pairwise_cons.1 H₂ with H₂₁ H₂₂,\n  rintro x (rfl | hx) y (rfl | hy),\n  exacts [H₁₁, H₂₁ _ hy, H (H₂₁ _ hx), IH H₁₂ H₂₂ _ hx _ hy]\nend\n\nlemma forall_of_pairwise (H : symmetric R) {l : list α}\n   (hl : pairwise R l) : (∀a∈l, ∀b∈l, a ≠ b → R a b) :=\nforall_of_forall_of_pairwise\n  (λ a b h hne, H (h hne.symm))\n  (λ _ _ h, (h rfl).elim)\n  (pairwise.imp (λ _ _ h _, h) hl)\n\ntheorem pairwise_singleton (R) (a : α) : pairwise R [a] :=\nby simp only [pairwise_cons, mem_singleton, forall_prop_of_false (not_mem_nil _), forall_true_iff, pairwise.nil, and_true]\n\ntheorem pairwise_pair {a b : α} : pairwise R [a, b] ↔ R a b :=\nby simp only [pairwise_cons, mem_singleton, forall_eq, forall_prop_of_false (not_mem_nil _), forall_true_iff, pairwise.nil, and_true]\n\ntheorem pairwise_append {l₁ l₂ : list α} : pairwise R (l₁++l₂) ↔\n  pairwise R l₁ ∧ pairwise R l₂ ∧ ∀ x ∈ l₁, ∀ y ∈ l₂, R x y :=\nby induction l₁ with x l₁ IH; [simp only [list.pairwise.nil, forall_prop_of_false (not_mem_nil _), forall_true_iff, and_true, true_and, nil_append],\nsimp only [cons_append, pairwise_cons, forall_mem_append, IH, forall_mem_cons, forall_and_distrib, and_assoc, and.left_comm]]\n\ntheorem pairwise_app_comm (s : symmetric R) {l₁ l₂ : list α} :\n  pairwise R (l₁++l₂) ↔ pairwise R (l₂++l₁) :=\nhave ∀ l₁ l₂ : list α,\n  (∀ (x : α), x ∈ l₁ → ∀ (y : α), y ∈ l₂ → R x y) →\n  (∀ (x : α), x ∈ l₂ → ∀ (y : α), y ∈ l₁ → R x y),\nfrom λ l₁ l₂ a x xm y ym, s (a y ym x xm),\nby simp only [pairwise_append, and.left_comm]; rw iff.intro (this l₁ l₂) (this l₂ l₁)\n\ntheorem pairwise_middle (s : symmetric R) {a : α} {l₁ l₂ : list α} :\n  pairwise R (l₁ ++ a::l₂) ↔ pairwise R (a::(l₁++l₂)) :=\nshow pairwise R (l₁ ++ ([a] ++ l₂)) ↔ pairwise R ([a] ++ l₁ ++ l₂),\nby rw [← append_assoc, pairwise_append, @pairwise_append _ _ ([a] ++ l₁), pairwise_app_comm s];\n   simp only [mem_append, or_comm]\n\ntheorem pairwise_map (f : β → α) :\n  ∀ {l : list β}, pairwise R (map f l) ↔ pairwise (λ a b : β, R (f a) (f b)) l\n| []     := by simp only [map, pairwise.nil]\n| (b::l) :=\n  have (∀ a b', b' ∈ l → f b' = a → R (f b) a) ↔ ∀ (b' : β), b' ∈ l → R (f b) (f b'), from\n  forall_swap.trans $ forall_congr $ λ a, forall_swap.trans $ by simp only [forall_eq'],\n  by simp only [map, pairwise_cons, mem_map, exists_imp_distrib, and_imp, this, pairwise_map]\n\ntheorem pairwise_of_pairwise_map {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, S (f a) (f b) → R a b) {l : list α}\n  (p : pairwise S (map f l)) : pairwise R l :=\n((pairwise_map f).1 p).imp H\n\ntheorem pairwise_map_of_pairwise {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, R a b → S (f a) (f b)) {l : list α}\n  (p : pairwise R l) : pairwise S (map f l) :=\n(pairwise_map f).2 $ p.imp H\n\ntheorem pairwise_filter_map (f : β → option α) {l : list β} :\n  pairwise R (filter_map f l) ↔ pairwise (λ a a' : β, ∀ (b ∈ f a) (b' ∈ f a'), R b b') l :=\nlet S (a a' : β) := ∀ (b ∈ f a) (b' ∈ f a'), R b b' in\nbegin\n  simp only [option.mem_def], induction l with a l IH,\n  { simp only [filter_map, pairwise.nil] },\n  cases e : f a with b,\n  { rw [filter_map_cons_none _ _ e, IH, pairwise_cons],\n    simp only [e, forall_prop_of_false not_false, forall_3_true_iff, true_and] },\n  rw [filter_map_cons_some _ _ _ e],\n  simp only [pairwise_cons, mem_filter_map, exists_imp_distrib, and_imp, IH, e, forall_eq'],\n  show (∀ (a' : α) (x : β), x ∈ l → f x = some a' → R b a') ∧ pairwise S l ↔\n        (∀ (a' : β), a' ∈ l → ∀ (b' : α), f a' = some b' → R b b') ∧ pairwise S l,\n  from and_congr ⟨λ h b mb a ma, h a b mb ma, λ h a b mb ma, h b mb a ma⟩ iff.rfl\nend\n\ntheorem pairwise_filter_map_of_pairwise {S : β → β → Prop} (f : α → option β)\n  (H : ∀ (a a' : α), R a a' → ∀ (b ∈ f a) (b' ∈ f a'), S b b') {l : list α}\n  (p : pairwise R l) : pairwise S (filter_map f l) :=\n(pairwise_filter_map _).2 $ p.imp H\n\ntheorem pairwise_filter (p : α → Prop) [decidable_pred p] {l : list α} :\n  pairwise R (filter p l) ↔ pairwise (λ x y, p x → p y → R x y) l :=\nbegin\n  rw [← filter_map_eq_filter, pairwise_filter_map],\n  apply pairwise.iff, intros, simp only [option.mem_def, option.guard_eq_some, and_imp, forall_eq'],\nend\n\ntheorem pairwise_filter_of_pairwise (p : α → Prop) [decidable_pred p] {l : list α}\n  : pairwise R l → pairwise R (filter p l) :=\npairwise_of_sublist (filter_sublist _)\n\ntheorem pairwise_join {L : list (list α)} : pairwise R (join L) ↔\n  (∀ l ∈ L, pairwise R l) ∧ pairwise (λ l₁ l₂, ∀ (x ∈ l₁) (y ∈ l₂), R x y) L :=\nbegin\n  induction L with l L IH, {simp only [join, pairwise.nil, forall_prop_of_false (not_mem_nil _), forall_const, and_self]},\n  have : (∀ (x : α), x ∈ l → ∀ (y : α) (x_1 : list α), x_1 ∈ L → y ∈ x_1 → R x y) ↔\n          ∀ (a' : list α), a' ∈ L → ∀ (x : α), x ∈ l → ∀ (y : α), y ∈ a' → R x y :=\n    ⟨λ h a b c d e, h c d e a b, λ h c d e a b, h a b c d e⟩,\n  simp only [join, pairwise_append, IH, mem_join, exists_imp_distrib, and_imp, this, forall_mem_cons, pairwise_cons],\n  simp only [and_assoc, and_comm, and.left_comm],\nend\n\n@[simp] theorem pairwise_reverse : ∀ {R} {l : list α},\n  pairwise R (reverse l) ↔ pairwise (λ x y, R y x) l :=\nsuffices ∀ {R l}, @pairwise α R l → pairwise (λ x y, R y x) (reverse l),\nfrom λ R l, ⟨λ p, reverse_reverse l ▸ this p, this⟩,\nλ R l p, by induction p with a l h p IH;\n  [apply pairwise.nil, simpa only [reverse_cons, pairwise_append, IH,\n    pairwise_cons, forall_prop_of_false (not_mem_nil _), forall_true_iff,\n    pairwise.nil, mem_reverse, mem_singleton, forall_eq, true_and] using h]\n\ntheorem pairwise_iff_nth_le {R} : ∀ {l : list α},\n  pairwise R l ↔ ∀ i j (h₁ : j < length l) (h₂ : i < j), R (nth_le l i (lt_trans h₂ h₁)) (nth_le l j h₁)\n| [] := by simp only [pairwise.nil, true_iff]; exact λ i j h, (not_lt_zero j).elim h\n| (a::l) := begin\n  rw [pairwise_cons, pairwise_iff_nth_le],\n  refine ⟨λ H i j h₁ h₂, _, λ H, ⟨λ a' m, _,\n    λ i j h₁ h₂, H _ _ (succ_lt_succ h₁) (succ_lt_succ h₂)⟩⟩,\n  { cases j with j, {exact (not_lt_zero _).elim h₂},\n    cases i with i,\n    { exact H.1 _ (nth_le_mem l _ _) },\n    { exact H.2 _ _ (lt_of_succ_lt_succ h₁) (lt_of_succ_lt_succ h₂) } },\n  { rcases nth_le_of_mem m with ⟨n, h, rfl⟩,\n    exact H _ _ (succ_lt_succ h) (succ_pos _) }\nend\n\ntheorem pairwise_sublists' {R} : ∀ {l : list α}, pairwise R l →\n  pairwise (lex (swap R)) (sublists' l)\n| _ pairwise.nil := pairwise_singleton _ _\n| _ (@pairwise.cons _ _ a l H₁ H₂) :=\n  begin\n    simp only [sublists'_cons, pairwise_append, pairwise_map, mem_sublists', mem_map, exists_imp_distrib, and_imp],\n    have IH := pairwise_sublists' H₂,\n    refine ⟨IH, IH.imp (λ l₁ l₂, lex.cons), _⟩,\n    intros l₁ sl₁ x l₂ sl₂ e, subst e,\n    cases l₁ with b l₁, {constructor},\n    exact lex.rel (H₁ _ $ subset_of_sublist sl₁ $ mem_cons_self _ _)\n  end\n\ntheorem pairwise_sublists {R} {l : list α} (H : pairwise R l) :\n  pairwise (λ l₁ l₂, lex R (reverse l₁) (reverse l₂)) (sublists l) :=\nby have := pairwise_sublists' (pairwise_reverse.2 H);\n   rwa [sublists'_reverse, pairwise_map] at this\n\n/- pairwise reduct -/\n\nvariable [decidable_rel R]\n\n@[simp] theorem pw_filter_nil : pw_filter R [] = [] := rfl\n\n@[simp] theorem pw_filter_cons_of_pos {a : α} {l : list α} (h : ∀ b ∈ pw_filter R l, R a b) :\n  pw_filter R (a::l) = a :: pw_filter R l := if_pos h\n\n@[simp] theorem pw_filter_cons_of_neg {a : α} {l : list α} (h : ¬ ∀ b ∈ pw_filter R l, R a b) :\n  pw_filter R (a::l) = pw_filter R l := if_neg h\n\ntheorem pw_filter_sublist : ∀ (l : list α), pw_filter R l <+ l\n| []     := nil_sublist _\n| (x::l) := begin\n  by_cases (∀ y ∈ pw_filter R l, R x y),\n  { rw [pw_filter_cons_of_pos h],\n    exact cons_sublist_cons _ (pw_filter_sublist l) },\n  { rw [pw_filter_cons_of_neg h],\n    exact sublist_cons_of_sublist _ (pw_filter_sublist l) },\nend\n\ntheorem pw_filter_subset (l : list α) : pw_filter R l ⊆ l :=\nsubset_of_sublist (pw_filter_sublist _)\n\ntheorem pairwise_pw_filter : ∀ (l : list α), pairwise R (pw_filter R l)\n| []     := pairwise.nil\n| (x::l) := begin\n  by_cases (∀ y ∈ pw_filter R l, R x y),\n  { rw [pw_filter_cons_of_pos h],\n    exact pairwise_cons.2 ⟨h, pairwise_pw_filter l⟩ },\n  { rw [pw_filter_cons_of_neg h],\n    exact pairwise_pw_filter l },\nend\n\ntheorem pw_filter_eq_self {l : list α} : pw_filter R l = l ↔ pairwise R l :=\n⟨λ e, e ▸ pairwise_pw_filter l, λ p, begin\n  induction l with x l IH, {refl},\n  cases pairwise_cons.1 p with al p,\n  rw [pw_filter_cons_of_pos (ball.imp_left (pw_filter_subset l) al), IH p],\nend⟩\n\n@[simp] theorem pw_filter_idempotent {l : list α} :\n  pw_filter R (pw_filter R l) = pw_filter R l :=\npw_filter_eq_self.mpr (pairwise_pw_filter l)\n\ntheorem forall_mem_pw_filter (neg_trans : ∀ {x y z}, R x z → R x y ∨ R y z)\n  (a : α) (l : list α) : (∀ b ∈ pw_filter R l, R a b) ↔ (∀ b ∈ l, R a b) :=\n⟨begin\n  induction l with x l IH, { exact λ _ _, false.elim },\n  simp only [forall_mem_cons],\n  by_cases (∀ y ∈ pw_filter R l, R x y); dsimp at h,\n  { simp only [pw_filter_cons_of_pos h, forall_mem_cons, and_imp],\n    exact λ r H, ⟨r, IH H⟩ },\n  { rw [pw_filter_cons_of_neg h],\n    refine λ H, ⟨_, IH H⟩,\n    cases e : find (λ y, ¬ R x y) (pw_filter R l) with k,\n    { refine h.elim (ball.imp_right _ (find_eq_none.1 e)),\n      exact λ y _, not_not.1 },\n    { have := find_some e,\n      exact (neg_trans (H k (find_mem e))).resolve_right this } }\nend, ball.imp_left (pw_filter_subset l)⟩\n\nend pairwise\n\n/- chain relation (conjunction of R a b ∧ R b c ∧ R c d ...) -/\n\nsection chain\n\nrun_cmd tactic.mk_iff_of_inductive_prop `list.chain `list.chain_iff\n\nvariable {R : α → α → Prop}\n\ntheorem rel_of_chain_cons {a b : α} {l : list α}\n  (p : chain R a (b::l)) : R a b :=\n(chain_cons.1 p).1\n\ntheorem chain_of_chain_cons {a b : α} {l : list α}\n  (p : chain R a (b::l)) : chain R b l :=\n(chain_cons.1 p).2\n\ntheorem chain.imp {S : α → α → Prop}\n  (H : ∀ a b, R a b → S a b) {a : α} {l : list α} (p : chain R a l) : chain S a l :=\nby induction p with _ a b l r p IH; constructor;\n   [exact H _ _ r, exact IH]\n\ntheorem chain.iff {S : α → α → Prop}\n  (H : ∀ a b, R a b ↔ S a b) {a : α} {l : list α} : chain R a l ↔ chain S a l :=\n⟨chain.imp (λ a b, (H a b).1), chain.imp (λ a b, (H a b).2)⟩\n\ntheorem chain.iff_mem {a : α} {l : list α} :\n  chain R a l ↔ chain (λ x y, x ∈ a :: l ∧ y ∈ l ∧ R x y) a l :=\n⟨λ p, by induction p with _ a b l r p IH; constructor;\n  [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩,\n   exact IH.imp (λ a b ⟨am, bm, h⟩,\n    ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩)],\n chain.imp (λ a b h, h.2.2)⟩\n\ntheorem chain_singleton {a b : α} : chain R a [b] ↔ R a b :=\nby simp only [chain_cons, chain.nil, and_true]\n\ntheorem chain_split {a b : α} {l₁ l₂ : list α} : chain R a (l₁++b::l₂) ↔\n  chain R a (l₁++[b]) ∧ chain R b l₂ :=\nby induction l₁ with x l₁ IH generalizing a;\nsimp only [*, nil_append, cons_append, chain.nil, chain_cons, and_true, and_assoc]\n\ntheorem chain_map (f : β → α) {b : β} {l : list β} :\n  chain R (f b) (map f l) ↔ chain (λ a b : β, R (f a) (f b)) b l :=\nby induction l generalizing b; simp only [map, chain.nil, chain_cons, *]\n\ntheorem chain_of_chain_map {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, S (f a) (f b) → R a b) {a : α} {l : list α}\n  (p : chain S (f a) (map f l)) : chain R a l :=\n((chain_map f).1 p).imp H\n\ntheorem chain_map_of_chain {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, R a b → S (f a) (f b)) {a : α} {l : list α}\n  (p : chain R a l) : chain S (f a) (map f l) :=\n(chain_map f).2 $ p.imp H\n\ntheorem chain_of_pairwise {a : α} {l : list α} (p : pairwise R (a::l)) : chain R a l :=\nbegin\n  cases pairwise_cons.1 p with r p', clear p,\n  induction p' with b l r' p IH generalizing a, {exact chain.nil},\n  simp only [chain_cons, forall_mem_cons] at r,\n  exact chain_cons.2 ⟨r.1, IH r'⟩\nend\n\ntheorem chain_iff_pairwise (tr : transitive R) {a : α} {l : list α} :\n  chain R a l ↔ pairwise R (a::l) :=\n⟨λ c, begin\n  induction c with b b c l r p IH, {exact pairwise_singleton _ _},\n  apply IH.cons _, simp only [mem_cons_iff, forall_mem_cons', r, true_and],\n  show ∀ x ∈ l, R b x, from λ x m, (tr r (rel_of_pairwise_cons IH m)),\nend, chain_of_pairwise⟩\n\ntheorem chain'.imp {S : α → α → Prop}\n  (H : ∀ a b, R a b → S a b) {l : list α} (p : chain' R l) : chain' S l :=\nby cases l; [trivial, exact p.imp H]\n\ntheorem chain'.iff {S : α → α → Prop}\n  (H : ∀ a b, R a b ↔ S a b) {l : list α} : chain' R l ↔ chain' S l :=\n⟨chain'.imp (λ a b, (H a b).1), chain'.imp (λ a b, (H a b).2)⟩\n\ntheorem chain'.iff_mem {S : α → α → Prop} : ∀ {l : list α},\n  chain' R l ↔ chain' (λ x y, x ∈ l ∧ y ∈ l ∧ R x y) l\n| [] := iff.rfl\n| (x::l) :=\n  ⟨λ h, (chain.iff_mem.1 h).imp $ λ a b ⟨h₁, h₂, h₃⟩, ⟨h₁, or.inr h₂, h₃⟩,\n   chain'.imp $ λ a b h, h.2.2⟩\n\ntheorem chain'_singleton (a : α) : chain' R [a] := chain.nil\n\ntheorem chain'_split {a : α} : ∀ {l₁ l₂ : list α}, chain' R (l₁++a::l₂) ↔\n  chain' R (l₁++[a]) ∧ chain' R (a::l₂)\n| []      l₂ := (and_iff_right (chain'_singleton a)).symm\n| (b::l₁) l₂ := chain_split\n\ntheorem chain'_map (f : β → α) {l : list β} :\n  chain' R (map f l) ↔ chain' (λ a b : β, R (f a) (f b)) l :=\nby cases l; [refl, exact chain_map _]\n\ntheorem chain'_of_chain'_map {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, S (f a) (f b) → R a b) {l : list α}\n  (p : chain' S (map f l)) : chain' R l :=\n((chain'_map f).1 p).imp H\n\ntheorem chain'_map_of_chain' {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, R a b → S (f a) (f b)) {l : list α}\n  (p : chain' R l) : chain' S (map f l) :=\n(chain'_map f).2 $ p.imp H\n\ntheorem chain'_of_pairwise : ∀ {l : list α}, pairwise R l → chain' R l\n| [] _ := trivial\n| (a::l) h := chain_of_pairwise h\n\ntheorem chain'_iff_pairwise (tr : transitive R) : ∀ {l : list α},\n  chain' R l ↔ pairwise R l\n| [] := (iff_true_intro pairwise.nil).symm\n| (a::l) := chain_iff_pairwise tr\n\nend chain\n\n/- no duplicates predicate -/\n\nsection nodup\n\n@[simp] theorem forall_mem_ne {a : α} {l : list α} : (∀ (a' : α), a' ∈ l → ¬a = a') ↔ a ∉ l :=\n⟨λ h m, h _ m rfl, λ h a' m e, h (e.symm ▸ m)⟩\n\n@[simp] theorem nodup_nil : @nodup α [] := pairwise.nil\n\n@[simp] theorem nodup_cons {a : α} {l : list α} : nodup (a::l) ↔ a ∉ l ∧ nodup l :=\nby simp only [nodup, pairwise_cons, forall_mem_ne]\n\nlemma rel_nodup {r : α → β → Prop} (hr : relator.bi_unique r) : (forall₂ r ⇒ (↔)) nodup nodup\n| _ _ forall₂.nil      := by simp only [nodup_nil]\n| _ _ (forall₂.cons hab h) :=\n  by simpa only [nodup_cons] using relator.rel_and (relator.rel_not (rel_mem hr hab h)) (rel_nodup h)\n\ntheorem nodup_cons_of_nodup {a : α} {l : list α} (m : a ∉ l) (n : nodup l) : nodup (a::l) :=\nnodup_cons.2 ⟨m, n⟩\n\ntheorem nodup_singleton (a : α) : nodup [a] :=\nnodup_cons_of_nodup (not_mem_nil a) nodup_nil\n\ntheorem nodup_of_nodup_cons {a : α} {l : list α} (h : nodup (a::l)) : nodup l :=\n(nodup_cons.1 h).2\n\ntheorem not_mem_of_nodup_cons {a : α} {l : list α} (h : nodup (a::l)) : a ∉ l :=\n(nodup_cons.1 h).1\n\ntheorem not_nodup_cons_of_mem {a : α} {l : list α} : a ∈ l → ¬ nodup (a :: l) :=\nimp_not_comm.1 not_mem_of_nodup_cons\n\ntheorem nodup_of_sublist {l₁ l₂ : list α} : l₁ <+ l₂ → nodup l₂ → nodup l₁ :=\npairwise_of_sublist\n\ntheorem not_nodup_pair (a : α) : ¬ nodup [a, a] :=\nnot_nodup_cons_of_mem $ mem_singleton_self _\n\ntheorem nodup_iff_sublist {l : list α} : nodup l ↔ ∀ a, ¬ [a, a] <+ l :=\n⟨λ d a h, not_nodup_pair a (nodup_of_sublist h d), begin\n  induction l with a l IH; intro h, {exact nodup_nil},\n  exact nodup_cons_of_nodup\n    (λ al, h a $ cons_sublist_cons _ $ singleton_sublist.2 al)\n    (IH $ λ a s, h a $ sublist_cons_of_sublist _ s)\nend⟩\n\ntheorem nodup_iff_nth_le_inj {l : list α} :\n  nodup l ↔ ∀ i j h₁ h₂, nth_le l i h₁ = nth_le l j h₂ → i = j :=\npairwise_iff_nth_le.trans\n⟨λ H i j h₁ h₂ h, ((lt_trichotomy _ _)\n  .resolve_left (λ h', H _ _ h₂ h' h))\n  .resolve_right (λ h', H _ _ h₁ h' h.symm),\n λ H i j h₁ h₂ h, ne_of_lt h₂ (H _ _ _ _ h)⟩\n\n@[simp] theorem nth_le_index_of [decidable_eq α] {l : list α} (H : nodup l) (n h) : index_of (nth_le l n h) l = n :=\nnodup_iff_nth_le_inj.1 H _ _ _ h $\nindex_of_nth_le $ index_of_lt_length.2 $ nth_le_mem _ _ _\n\ntheorem nodup_iff_count_le_one [decidable_eq α] {l : list α} : nodup l ↔ ∀ a, count a l ≤ 1 :=\nnodup_iff_sublist.trans $ forall_congr $ λ a,\nhave [a, a] <+ l ↔ 1 < count a l, from (@le_count_iff_repeat_sublist _ _ a l 2).symm,\n(not_congr this).trans not_lt\n\ntheorem nodup_repeat (a : α) : ∀ {n : ℕ}, nodup (repeat a n) ↔ n ≤ 1\n| 0 := by simp [nat.zero_le]\n| 1 := by simp\n| (n+2) := iff_of_false\n  (λ H, nodup_iff_sublist.1 H a ((repeat_sublist_repeat _).2 (le_add_left 2 n)))\n  (not_le_of_lt $ le_add_left 2 n)\n\n@[simp] theorem count_eq_one_of_mem [decidable_eq α] {a : α} {l : list α}\n  (d : nodup l) (h : a ∈ l) : count a l = 1 :=\nle_antisymm (nodup_iff_count_le_one.1 d a) (count_pos.2 h)\n\ntheorem nodup_of_nodup_append_left {l₁ l₂ : list α} : nodup (l₁++l₂) → nodup l₁ :=\nnodup_of_sublist (sublist_append_left l₁ l₂)\n\ntheorem nodup_of_nodup_append_right {l₁ l₂ : list α} : nodup (l₁++l₂) → nodup l₂ :=\nnodup_of_sublist (sublist_append_right l₁ l₂)\n\ntheorem nodup_append {l₁ l₂ : list α} : nodup (l₁++l₂) ↔ nodup l₁ ∧ nodup l₂ ∧ disjoint l₁ l₂ :=\nby simp only [nodup, pairwise_append, disjoint_iff_ne]\n\ntheorem disjoint_of_nodup_append {l₁ l₂ : list α} (d : nodup (l₁++l₂)) : disjoint l₁ l₂ :=\n(nodup_append.1 d).2.2\n\ntheorem nodup_append_of_nodup {l₁ l₂ : list α} (d₁ : nodup l₁) (d₂ : nodup l₂) (dj : disjoint l₁ l₂) : nodup (l₁++l₂) :=\nnodup_append.2 ⟨d₁, d₂, dj⟩\n\ntheorem nodup_app_comm {l₁ l₂ : list α} : nodup (l₁++l₂) ↔ nodup (l₂++l₁) :=\nby simp only [nodup_append, and.left_comm, disjoint_comm]\n\ntheorem nodup_middle {a : α} {l₁ l₂ : list α} : nodup (l₁ ++ a::l₂) ↔ nodup (a::(l₁++l₂)) :=\nby simp only [nodup_append, not_or_distrib, and.left_comm, and_assoc, nodup_cons, mem_append, disjoint_cons_right]\n\ntheorem nodup_of_nodup_map (f : α → β) {l : list α} : nodup (map f l) → nodup l :=\npairwise_of_pairwise_map f $ λ a b, mt $ congr_arg f\n\ntheorem nodup_map_on {f : α → β} {l : list α} (H : ∀x∈l, ∀y∈l, f x = f y → x = y)\n  (d : nodup l) : nodup (map f l) :=\npairwise_map_of_pairwise _ (by exact λ a b ⟨ma, mb, n⟩ e, n (H a ma b mb e)) (pairwise.and_mem.1 d)\n\ntheorem nodup_map {f : α → β} {l : list α} (hf : injective f) : nodup l → nodup (map f l) :=\nnodup_map_on (assume x _ y _ h, hf h)\n\ntheorem nodup_map_iff {f : α → β} {l : list α} (hf : injective f) : nodup (map f l) ↔ nodup l :=\n⟨nodup_of_nodup_map _, nodup_map hf⟩\n\n@[simp] theorem nodup_attach {l : list α} : nodup (attach l) ↔ nodup l :=\n⟨λ h, attach_map_val l ▸ nodup_map (λ a b, subtype.eq) h,\n λ h, nodup_of_nodup_map subtype.val ((attach_map_val l).symm ▸ h)⟩\n\ntheorem nodup_pmap {p : α → Prop} {f : Π a, p a → β} {l : list α} {H}\n  (hf : ∀ a ha b hb, f a ha = f b hb → a = b) (h : nodup l) : nodup (pmap f l H) :=\nby rw [pmap_eq_map_attach]; exact nodup_map\n  (λ ⟨a, ha⟩ ⟨b, hb⟩ h, by congr; exact hf a (H _ ha) b (H _ hb) h)\n  (nodup_attach.2 h)\n\ntheorem nodup_filter (p : α → Prop) [decidable_pred p] {l} : nodup l → nodup (filter p l) :=\npairwise_filter_of_pairwise p\n\n@[simp] theorem nodup_reverse {l : list α} : nodup (reverse l) ↔ nodup l :=\npairwise_reverse.trans $ by simp only [nodup, ne.def, eq_comm]\n\ntheorem nodup_erase_eq_filter [decidable_eq α] (a : α) {l} (d : nodup l) : l.erase a = filter (≠ a) l :=\nbegin\n  induction d with b l m d IH, {refl},\n  by_cases b = a,\n  { subst h, rw [erase_cons_head, filter_cons_of_neg],\n    symmetry, rw filter_eq_self, simpa only [ne.def, eq_comm] using m, exact not_not_intro rfl },\n  { rw [erase_cons_tail _ h, filter_cons_of_pos, IH], exact h }\nend\n\ntheorem nodup_erase_of_nodup [decidable_eq α] (a : α) {l} : nodup l → nodup (l.erase a) :=\nnodup_of_sublist (erase_sublist _ _)\n\ntheorem mem_erase_iff_of_nodup [decidable_eq α] {a b : α} {l} (d : nodup l) :\n  a ∈ l.erase b ↔ a ≠ b ∧ a ∈ l :=\nby rw nodup_erase_eq_filter b d; simp only [mem_filter, and_comm]\n\ntheorem mem_erase_of_nodup [decidable_eq α] {a : α} {l} (h : nodup l) : a ∉ l.erase a :=\nλ H, ((mem_erase_iff_of_nodup h).1 H).1 rfl\n\ntheorem nodup_join {L : list (list α)} : nodup (join L) ↔ (∀ l ∈ L, nodup l) ∧ pairwise disjoint L :=\nby simp only [nodup, pairwise_join, disjoint_left.symm, forall_mem_ne]\n\ntheorem nodup_bind {l₁ : list α} {f : α → list β} : nodup (l₁.bind f) ↔\n  (∀ x ∈ l₁, nodup (f x)) ∧ pairwise (λ (a b : α), disjoint (f a) (f b)) l₁ :=\nby simp only [list.bind, nodup_join, pairwise_map, and_comm, and.left_comm, mem_map, exists_imp_distrib, and_imp];\n   rw [show (∀ (l : list β) (x : α), f x = l → x ∈ l₁ → nodup l) ↔\n            (∀ (x : α), x ∈ l₁ → nodup (f x)),\n       from forall_swap.trans $ forall_congr $ λ_, forall_eq']\n\ntheorem nodup_product {l₁ : list α} {l₂ : list β} (d₁ : nodup l₁) (d₂ : nodup l₂) :\n  nodup (product l₁ l₂) :=\n nodup_bind.2\n  ⟨λ a ma, nodup_map (injective_of_left_inverse (λ b, (rfl : (a,b).2 = b))) d₂,\n  d₁.imp $ λ a₁ a₂ n x h₁ h₂, begin\n    rcases mem_map.1 h₁ with ⟨b₁, mb₁, rfl⟩,\n    rcases mem_map.1 h₂ with ⟨b₂, mb₂, ⟨⟩⟩,\n    exact n rfl\n  end⟩\n\ntheorem nodup_sigma {σ : α → Type*} {l₁ : list α} {l₂ : Π a, list (σ a)}\n  (d₁ : nodup l₁) (d₂ : ∀ a, nodup (l₂ a)) : nodup (l₁.sigma l₂) :=\n nodup_bind.2\n  ⟨λ a ma, nodup_map (λ b b' h, by injection h with _ h; exact eq_of_heq h) (d₂ a),\n  d₁.imp $ λ a₁ a₂ n x h₁ h₂, begin\n    rcases mem_map.1 h₁ with ⟨b₁, mb₁, rfl⟩,\n    rcases mem_map.1 h₂ with ⟨b₂, mb₂, ⟨⟩⟩,\n    exact n rfl\n  end⟩\n\ntheorem nodup_filter_map {f : α → option β} {l : list α}\n  (H : ∀ (a a' : α) (b : β), b ∈ f a → b ∈ f a' → a = a') :\n  nodup l → nodup (filter_map f l) :=\npairwise_filter_map_of_pairwise f $ λ a a' n b bm b' bm' e, n $ H a a' b' (e ▸ bm) bm'\n\ntheorem nodup_concat {a : α} {l : list α} (h : a ∉ l) (h' : nodup l) : nodup (concat l a) :=\nby rw concat_eq_append; exact nodup_append_of_nodup h' (nodup_singleton _) (disjoint_singleton.2 h)\n\ntheorem nodup_insert [decidable_eq α] {a : α} {l : list α} (h : nodup l) : nodup (insert a l) :=\nif h' : a ∈ l then by rw [insert_of_mem h']; exact h\nelse by rw [insert_of_not_mem h', nodup_cons]; split; assumption\n\ntheorem nodup_union [decidable_eq α] (l₁ : list α) {l₂ : list α} (h : nodup l₂) :\n  nodup (l₁ ∪ l₂) :=\nbegin\n  induction l₁ with a l₁ ih generalizing l₂,\n  { exact h },\n  apply nodup_insert,\n  exact ih h\nend\n\ntheorem nodup_inter_of_nodup [decidable_eq α] {l₁ : list α} (l₂) : nodup l₁ → nodup (l₁ ∩ l₂) :=\nnodup_filter _\n\n@[simp] theorem nodup_sublists {l : list α} : nodup (sublists l) ↔ nodup l :=\n⟨λ h, nodup_of_nodup_map _ (nodup_of_sublist (map_ret_sublist_sublists _) h),\n λ h, (pairwise_sublists h).imp (λ _ _ h, mt reverse_inj.2 h.to_ne)⟩\n\n@[simp] theorem nodup_sublists' {l : list α} : nodup (sublists' l) ↔ nodup l :=\nby rw [sublists'_eq_sublists, nodup_map_iff reverse_injective,\n       nodup_sublists, nodup_reverse]\n\nend nodup\n\n/- erase duplicates function -/\n\nsection erase_dup\nvariable [decidable_eq α]\n\n@[simp] theorem erase_dup_nil : erase_dup [] = ([] : list α) := rfl\n\ntheorem erase_dup_cons_of_mem' {a : α} {l : list α} (h : a ∈ erase_dup l) :\n  erase_dup (a::l) = erase_dup l :=\npw_filter_cons_of_neg $ by simpa only [forall_mem_ne] using h\n\ntheorem erase_dup_cons_of_not_mem' {a : α} {l : list α} (h : a ∉ erase_dup l) :\n  erase_dup (a::l) = a :: erase_dup l :=\npw_filter_cons_of_pos $ by simpa only [forall_mem_ne] using h\n\n@[simp] theorem mem_erase_dup {a : α} {l : list α} : a ∈ erase_dup l ↔ a ∈ l :=\nby simpa only [erase_dup, forall_mem_ne, not_not] using not_congr (@forall_mem_pw_filter α (≠) _\n  (λ x y z xz, not_and_distrib.1 $ mt (and.rec eq.trans) xz) a l)\n\n@[simp] theorem erase_dup_cons_of_mem {a : α} {l : list α} (h : a ∈ l) :\n  erase_dup (a::l) = erase_dup l :=\nerase_dup_cons_of_mem' $ mem_erase_dup.2 h\n\n@[simp] theorem erase_dup_cons_of_not_mem {a : α} {l : list α} (h : a ∉ l) :\n  erase_dup (a::l) = a :: erase_dup l :=\nerase_dup_cons_of_not_mem' $ mt mem_erase_dup.1 h\n\ntheorem erase_dup_sublist : ∀ (l : list α), erase_dup l <+ l := pw_filter_sublist\n\ntheorem erase_dup_subset : ∀ (l : list α), erase_dup l ⊆ l := pw_filter_subset\n\ntheorem subset_erase_dup (l : list α) : l ⊆ erase_dup l :=\nλ a, mem_erase_dup.2\n\ntheorem nodup_erase_dup : ∀ l : list α, nodup (erase_dup l) := pairwise_pw_filter\n\ntheorem erase_dup_eq_self {l : list α} : erase_dup l = l ↔ nodup l := pw_filter_eq_self\n\n@[simp] theorem erase_dup_idempotent {l : list α} : erase_dup (erase_dup l) = erase_dup l :=\npw_filter_idempotent\n\ntheorem erase_dup_append (l₁ l₂ : list α) : erase_dup (l₁ ++ l₂) = l₁ ∪ erase_dup l₂ :=\nbegin\n  induction l₁ with a l₁ IH, {refl}, rw [cons_union, ← IH],\n  show erase_dup (a :: (l₁ ++ l₂)) = insert a (erase_dup (l₁ ++ l₂)),\n  by_cases a ∈ erase_dup (l₁ ++ l₂);\n  [ rw [erase_dup_cons_of_mem' h, insert_of_mem h],\n    rw [erase_dup_cons_of_not_mem' h, insert_of_not_mem h]]\nend\n\nend erase_dup\n\n/- iota and range(') -/\n\n@[simp] theorem length_range' : ∀ (s n : ℕ), length (range' s n) = n\n| s 0     := rfl\n| s (n+1) := congr_arg succ (length_range' _ _)\n\n@[simp] theorem mem_range' {m : ℕ} : ∀ {s n : ℕ}, m ∈ range' s n ↔ s ≤ m ∧ m < s + n\n| s 0     := (false_iff _).2 $ λ ⟨H1, H2⟩, not_le_of_lt H2 H1\n| s (succ n) :=\n  have m = s → m < s + n + 1,\n    from λ e, e ▸ lt_succ_of_le (le_add_right _ _),\n  have l : m = s ∨ s + 1 ≤ m ↔ s ≤ m,\n    by simpa only [eq_comm] using (@le_iff_eq_or_lt _ _ s m).symm,\n  (mem_cons_iff _ _ _).trans $ by simp only [mem_range',\n    or_and_distrib_left, or_iff_right_of_imp this, l, add_right_comm]; refl\n\ntheorem map_add_range' (a) : ∀ s n : ℕ, map ((+) a) (range' s n) = range' (a + s) n\n| s 0     := rfl\n| s (n+1) := congr_arg (cons _) (map_add_range' (s+1) n)\n\ntheorem map_sub_range' (a) : ∀ (s n : ℕ) (h : a ≤ s), map (λ x, x - a) (range' s n) = range' (s - a) n\n| s 0     _ := rfl\n| s (n+1) h :=\nbegin\n  convert congr_arg (cons (s-a)) (map_sub_range' (s+1) n (nat.le_succ_of_le h)),\n  rw nat.succ_sub h,\n  refl,\nend\n\ntheorem chain_succ_range' : ∀ s n : ℕ, chain (λ a b, b = succ a) s (range' (s+1) n)\n| s 0     := chain.nil\n| s (n+1) := (chain_succ_range' (s+1) n).cons rfl\n\ntheorem chain_lt_range' (s n : ℕ) : chain (<) s (range' (s+1) n) :=\n(chain_succ_range' s n).imp (λ a b e, e.symm ▸ lt_succ_self _)\n\ntheorem pairwise_lt_range' : ∀ s n : ℕ, pairwise (<) (range' s n)\n| s 0     := pairwise.nil\n| s (n+1) := (chain_iff_pairwise (by exact λ a b c, lt_trans)).1 (chain_lt_range' s n)\n\ntheorem nodup_range' (s n : ℕ) : nodup (range' s n) :=\n(pairwise_lt_range' s n).imp (λ a b, ne_of_lt)\n\n@[simp] theorem range'_append : ∀ s m n : ℕ, range' s m ++ range' (s+m) n = range' s (n+m)\n| s 0     n := rfl\n| s (m+1) n := show s :: (range' (s+1) m ++ range' (s+m+1) n) = s :: range' (s+1) (n+m),\n               by rw [add_right_comm, range'_append]\n\ntheorem range'_sublist_right {s m n : ℕ} : range' s m <+ range' s n ↔ m ≤ n :=\n⟨λ h, by simpa only [length_range'] using length_le_of_sublist h,\n λ h, by rw [← nat.sub_add_cancel h, ← range'_append]; apply sublist_append_left⟩\n\ntheorem range'_subset_right {s m n : ℕ} : range' s m ⊆ range' s n ↔ m ≤ n :=\n⟨λ h, le_of_not_lt $ λ hn, lt_irrefl (s+n) $\n  (mem_range'.1 $ h $ mem_range'.2 ⟨le_add_right _ _, nat.add_lt_add_left hn s⟩).2,\n λ h, subset_of_sublist (range'_sublist_right.2 h)⟩\n\ntheorem nth_range' : ∀ s {m n : ℕ}, m < n → nth (range' s n) m = some (s + m)\n| s 0     (n+1) _ := rfl\n| s (m+1) (n+1) h := (nth_range' (s+1) (lt_of_add_lt_add_right h)).trans $ by rw add_right_comm; refl\n\ntheorem range'_concat (s n : ℕ) : range' s (n + 1) = range' s n ++ [s+n] :=\nby rw add_comm n 1; exact (range'_append s n 1).symm\n\ntheorem range_core_range' : ∀ s n : ℕ, range_core s (range' s n) = range' 0 (n + s)\n| 0     n := rfl\n| (s+1) n := by rw [show n+(s+1) = n+1+s, from add_right_comm n s 1]; exact range_core_range' s (n+1)\n\ntheorem range_eq_range' (n : ℕ) : range n = range' 0 n :=\n(range_core_range' n 0).trans $ by rw zero_add\n\ntheorem range_succ_eq_map (n : ℕ) : range (n + 1) = 0 :: map succ (range n) :=\nby rw [range_eq_range', range_eq_range', range',\n       add_comm, ← map_add_range'];\n   congr; exact funext one_add\n\ntheorem range'_eq_map_range (s n : ℕ) : range' s n = map ((+) s) (range n) :=\nby rw [range_eq_range', map_add_range']; refl\n\n@[simp] theorem length_range (n : ℕ) : length (range n) = n :=\nby simp only [range_eq_range', length_range']\n\ntheorem pairwise_lt_range (n : ℕ) : pairwise (<) (range n) :=\nby simp only [range_eq_range', pairwise_lt_range']\n\ntheorem nodup_range (n : ℕ) : nodup (range n) :=\nby simp only [range_eq_range', nodup_range']\n\ntheorem range_sublist {m n : ℕ} : range m <+ range n ↔ m ≤ n :=\nby simp only [range_eq_range', range'_sublist_right]\n\ntheorem range_subset {m n : ℕ} : range m ⊆ range n ↔ m ≤ n :=\nby simp only [range_eq_range', range'_subset_right]\n\n@[simp] theorem mem_range {m n : ℕ} : m ∈ range n ↔ m < n :=\nby simp only [range_eq_range', mem_range', nat.zero_le, true_and, zero_add]\n\n@[simp] theorem not_mem_range_self {n : ℕ} : n ∉ range n :=\nmt mem_range.1 $ lt_irrefl _\n\ntheorem nth_range {m n : ℕ} (h : m < n) : nth (range n) m = some m :=\nby simp only [range_eq_range', nth_range' _ h, zero_add]\n\ntheorem range_concat (n : ℕ) : range (n + 1) = range n ++ [n] :=\nby simp only [range_eq_range', range'_concat, zero_add]\n\ntheorem iota_eq_reverse_range' : ∀ n : ℕ, iota n = reverse (range' 1 n)\n| 0     := rfl\n| (n+1) := by simp only [iota, range'_concat, iota_eq_reverse_range' n, reverse_append, add_comm]; refl\n\n@[simp] theorem length_iota (n : ℕ) : length (iota n) = n :=\nby simp only [iota_eq_reverse_range', length_reverse, length_range']\n\ntheorem pairwise_gt_iota (n : ℕ) : pairwise (>) (iota n) :=\nby simp only [iota_eq_reverse_range', pairwise_reverse, pairwise_lt_range']\n\ntheorem nodup_iota (n : ℕ) : nodup (iota n) :=\nby simp only [iota_eq_reverse_range', nodup_reverse, nodup_range']\n\ntheorem mem_iota {m n : ℕ} : m ∈ iota n ↔ 1 ≤ m ∧ m ≤ n :=\nby simp only [iota_eq_reverse_range', mem_reverse, mem_range', add_comm, lt_succ_iff]\n\ntheorem reverse_range' : ∀ s n : ℕ,\n  reverse (range' s n) = map (λ i, s + n - 1 - i) (range n)\n| s 0     := rfl\n| s (n+1) := by rw [range'_concat, reverse_append, range_succ_eq_map];\n  simpa only [show s + (n + 1) - 1 = s + n, from rfl, (∘),\n    λ a i, show a - 1 - i = a - succ i, from pred_sub _ _,\n    reverse_singleton, map_cons, nat.sub_zero, cons_append,\n    nil_append, eq_self_iff_true, true_and, map_map]\n  using reverse_range' s n\n\n/--\n`Ico n m` is the list of natural numbers `n ≤ x < m`.\n(Ico stands for \"interval, closed-open\".)\n\nSee also `data/set/intervals.lean` for `set.Ico`, modelling intervals in general preorders, and\n`multiset.Ico` and `finset.Ico` for `n ≤ x < m` as a multiset or as a finset.\n\n@TODO (anyone): Define `Ioo` and `Icc`, state basic lemmas about them.\n@TODO (anyone): Prove that `finset.Ico` and `set.Ico` agree.\n@TODO (anyone): Also do the versions for integers?\n@TODO (anyone): One could generalise even further, defining\n'locally finite partial orders', for which `set.Ico a b` is `[finite]`, and\n'locally finite total orders', for which there is a list model.\n -/\ndef Ico (n m : ℕ) : list ℕ := range' n (m - n)\n\nnamespace Ico\n\ntheorem zero_bot (n : ℕ) : Ico 0 n = range n :=\nby rw [Ico, nat.sub_zero, range_eq_range']\n\n@[simp] theorem length (n m : ℕ) : length (Ico n m) = m - n :=\nby dsimp [Ico]; simp only [length_range']\n\ntheorem pairwise_lt (n m : ℕ) : pairwise (<) (Ico n m) :=\nby dsimp [Ico]; simp only [pairwise_lt_range']\n\ntheorem nodup (n m : ℕ) : nodup (Ico n m) :=\nby dsimp [Ico]; simp only [nodup_range']\n\n@[simp] theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m :=\nsuffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m, by simp [Ico, this],\nbegin\n  cases le_total n m with hnm hmn,\n  { rw [nat.add_sub_of_le hnm] },\n  { rw [nat.sub_eq_zero_of_le hmn, add_zero],\n    exact and_congr_right (assume hnl, iff.intro\n      (assume hln, (not_le_of_gt hln hnl).elim)\n      (assume hlm, lt_of_lt_of_le hlm hmn)) }\nend\n\ntheorem eq_nil_of_le {n m : ℕ} (h : m ≤ n) : Ico n m = [] :=\nby simp [Ico, nat.sub_eq_zero_of_le h]\n\ntheorem map_add (n m k : ℕ) : (Ico n m).map ((+) k) = Ico (n + k) (m + k) :=\nby rw [Ico, Ico, map_add_range', nat.add_sub_add_right, add_comm n k]\n\ntheorem map_sub (n m k : ℕ) (h₁ : k ≤ n): (Ico n m).map (λ x, x - k) = Ico (n - k) (m - k) :=\nbegin\n  by_cases h₂ : n < m,\n  { rw [Ico, Ico],\n    rw nat.sub_sub_sub_cancel_right h₁,\n    rw [map_sub_range' _ _ _ h₁] },\n  { simp at h₂,\n    rw [eq_nil_of_le h₂],\n    rw [eq_nil_of_le (nat.sub_le_sub_right h₂ _)],\n    refl }\nend\n\n@[simp] theorem self_empty {n : ℕ} : Ico n n = [] :=\neq_nil_of_le (le_refl n)\n\n@[simp] theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n :=\niff.intro (assume h, nat.le_of_sub_eq_zero $ by rw [← length, h]; refl) eq_nil_of_le\n\nlemma append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :\n  Ico n m ++ Ico m l = Ico n l :=\nbegin\n  dunfold Ico,\n  convert range'_append _ _ _,\n  { exact (nat.add_sub_of_le hnm).symm },\n  { rwa [← nat.add_sub_assoc hnm, nat.sub_add_cancel] }\nend\n\n@[simp] lemma inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] :=\nbegin\n  apply eq_nil_iff_forall_not_mem.2,\n  intro a,\n  simp only [and_imp, not_and, not_lt, list.mem_inter, list.Ico.mem],\n  intros h₁ h₂ h₃,\n  exfalso,\n  exact not_lt_of_ge h₃ h₂\nend\n\n@[simp] lemma bag_inter_consecutive (n m l : ℕ) : list.bag_inter (Ico n m) (Ico m l) = [] :=\n(bag_inter_nil_iff_inter_nil _ _).2 (inter_consecutive n m l)\n\n@[simp] theorem succ_singleton {n : ℕ} : Ico n (n+1) = [n] :=\nby dsimp [Ico]; simp [nat.add_sub_cancel_left]\n\ntheorem succ_top {n m : ℕ} (h : n ≤ m) : Ico n (m + 1) = Ico n m ++ [m] :=\nby rwa [← succ_singleton, append_consecutive]; exact nat.le_succ _\n\ntheorem eq_cons {n m : ℕ} (h : n < m) : Ico n m = n :: Ico (n + 1) m :=\nby rw [← append_consecutive (nat.le_succ n) h, succ_singleton]; refl\n\n@[simp] theorem pred_singleton {m : ℕ} (h : m > 0) : Ico (m - 1) m = [m - 1] :=\nby dsimp [Ico]; rw nat.sub_sub_self h; simp\n\ntheorem chain'_succ (n m : ℕ) : chain' (λa b, b = succ a) (Ico n m) :=\nbegin\n  by_cases n < m,\n  { rw [eq_cons h], exact chain_succ_range' _ _ },\n  { rw [eq_nil_of_le (le_of_not_gt h)], trivial }\nend\n\n@[simp] theorem not_mem_top {n m : ℕ} : m ∉ Ico n m :=\nby simp; intros; refl\n\nlemma filter_lt_of_top_le {n m l : ℕ} (hml : m ≤ l) : (Ico n m).filter (λ x, x < l) = Ico n m :=\nfilter_eq_self.2 $ assume k hk, lt_of_lt_of_le (mem.1 hk).2 hml\n\nlemma filter_lt_of_le_bot {n m l : ℕ} (hln : l ≤ n) : (Ico n m).filter (λ x, x < l) = [] :=\nfilter_eq_nil.2 $ assume k hk, not_lt_of_le $ le_trans hln $ (mem.1 hk).1\n\nlemma filter_lt_of_ge {n m l : ℕ} (hlm : l ≤ m) : (Ico n m).filter (λ x, x < l) = Ico n l :=\nbegin\n  cases le_total n l with hnl hln,\n  { rw [← append_consecutive hnl hlm, filter_append,\n      filter_lt_of_top_le (le_refl l), filter_lt_of_le_bot (le_refl l), append_nil] },\n  { rw [eq_nil_of_le hln, filter_lt_of_le_bot hln] }\nend\n\n@[simp] lemma filter_lt (n m l : ℕ) : (Ico n m).filter (λ x, x < l) = Ico n (min m l) :=\nbegin\n  cases le_total m l with hml hlm,\n  { rw [min_eq_left hml, filter_lt_of_top_le hml] },\n  { rw [min_eq_right hlm, filter_lt_of_ge hlm] }\nend\n\nlemma filter_ge_of_le_bot {n m l : ℕ} (hln : l ≤ n) : (Ico n m).filter (λ x, x ≥ l) = Ico n m :=\nfilter_eq_self.2 $ assume k hk, le_trans hln (mem.1 hk).1\n\nlemma filter_ge_of_top_le {n m l : ℕ} (hml : m ≤ l) : (Ico n m).filter (λ x, x ≥ l) = [] :=\nfilter_eq_nil.2 $ assume k hk, not_le_of_gt (lt_of_lt_of_le (mem.1 hk).2 hml)\n\nlemma filter_ge_of_ge {n m l : ℕ} (hnl : n ≤ l) : (Ico n m).filter (λ x, x ≥ l) = Ico l m :=\nbegin\n  cases le_total l m with hlm hml,\n  { rw [← append_consecutive hnl hlm, filter_append,\n      filter_ge_of_top_le (le_refl l), filter_ge_of_le_bot (le_refl l), nil_append] },\n  { rw [eq_nil_of_le hml, filter_ge_of_top_le hml] }\nend\n\n@[simp] lemma filter_ge (n m l : ℕ) : (Ico n m).filter (λ x, x ≥ l) = Ico (max n l) m :=\nbegin\n  cases le_total n l with hnl hln,\n  { rw [max_eq_right hnl, filter_ge_of_ge hnl] },\n  { rw [max_eq_left hln, filter_ge_of_le_bot hln] }\nend\n\nend Ico\n\n@[simp] theorem enum_from_map_fst : ∀ n (l : list α),\n  map prod.fst (enum_from n l) = range' n l.length\n| n []       := rfl\n| n (a :: l) := congr_arg (cons _) (enum_from_map_fst _ _)\n\n@[simp] theorem enum_map_fst (l : list α) :\n  map prod.fst (enum l) = range l.length :=\nby simp only [enum, enum_from_map_fst, range_eq_range']\n\ntheorem last'_mem {α} : ∀ a l, @last' α a l ∈ a :: l\n| a []     := or.inl rfl\n| a (b::l) := or.inr (last'_mem b l)\n\n@[simp] lemma nth_le_attach {α} (L : list α) (i) (H : i < L.attach.length) :\n  (L.attach.nth_le i H).1 = L.nth_le i (length_attach L ▸ H) :=\ncalc  (L.attach.nth_le i H).1\n    = (L.attach.map subtype.val).nth_le i (by simpa using H) : by rw nth_le_map'\n... = L.nth_le i _ : by congr; apply attach_map_val\n\n@[simp] lemma nth_le_range {n} (i) (H : i < (range n).length) :\n  nth_le (range n) i H = i :=\noption.some.inj $ by rw [← nth_le_nth _, nth_range (by simpa using H)]\n\ntheorem of_fn_eq_pmap {α n} {f : fin n → α} :\n  of_fn f = pmap (λ i hi, f ⟨i, hi⟩) (range n) (λ _, mem_range.1) :=\nby rw [pmap_eq_map_attach]; from ext_le (by simp)\n  (λ i hi1 hi2, by simp at hi1; simp [nth_le_of_fn f ⟨i, hi1⟩])\n\ntheorem nodup_of_fn {α n} {f : fin n → α} (hf : function.injective f) :\n  nodup (of_fn f) :=\nby rw of_fn_eq_pmap; from nodup_pmap\n  (λ _ _ _ _ H, fin.veq_of_eq $ hf H) (nodup_range n)\n\nsection tfae\n\n/- tfae: The Following (propositions) Are Equivalent -/\n\ntheorem tfae_nil : tfae [] := forall_mem_nil _\ntheorem tfae_singleton (p) : tfae [p] := by simp [tfae]\n\ntheorem tfae_cons_of_mem {a b} {l : list Prop} (h : b ∈ l) :\n  tfae (a::l) ↔ (a ↔ b) ∧ tfae l :=\n⟨λ H, ⟨H a (by simp) b (or.inr h), λ p hp q hq, H _ (or.inr hp) _ (or.inr hq)⟩,\nbegin\n   rintro ⟨ab, H⟩ p (rfl | hp) q (rfl | hq),\n   { refl },\n   { exact ab.trans (H _ h _ hq) },\n   { exact (ab.trans (H _ h _ hp)).symm },\n   { exact H _ hp _ hq }\nend⟩\n\ntheorem tfae_cons_cons {a b} {l : list Prop} : tfae (a::b::l) ↔ (a ↔ b) ∧ tfae (b::l) :=\ntfae_cons_of_mem (or.inl rfl)\n\ntheorem tfae_of_forall (b : Prop) (l : list Prop) (h : ∀ a ∈ l, a ↔ b) : tfae l :=\nλ a₁ h₁ a₂ h₂, (h _ h₁).trans (h _ h₂).symm\n\ntheorem tfae_of_cycle {a b} {l : list Prop} :\n  list.chain (→) a (b::l) → (last' b l → a) → tfae (a::b::l) :=\nbegin\n  induction l with c l IH generalizing a b; simp [tfae_cons_cons, tfae_singleton] at *,\n  { intros a _ b, exact iff.intro a b },\n  intros ab bc ch la,\n  have := IH bc ch (ab ∘ la),\n  exact ⟨⟨ab, la ∘ (this.2 c (or.inl rfl) _ (last'_mem _ _)).1 ∘ bc⟩, this⟩\nend\n\ntheorem tfae.out {l} (h : tfae l) (n₁ n₂)\n (h₁ : n₁ < list.length l . tactic.exact_dec_trivial)\n (h₂ : n₂ < list.length l . tactic.exact_dec_trivial) :\n  list.nth_le l n₁ h₁ ↔ list.nth_le l n₂ h₂ :=\nh _ (list.nth_le_mem _ _ _) _ (list.nth_le_mem _ _ _)\n\nend tfae\n\nlemma rotate_mod (l : list α) (n : ℕ) : l.rotate (n % l.length) = l.rotate n :=\nby simp [rotate]\n\n@[simp] lemma rotate_nil (n : ℕ) : ([] : list α).rotate n = [] := by cases n; refl\n\n@[simp] lemma rotate_zero (l : list α) : l.rotate 0 = l := by simp [rotate]\n\n@[simp] lemma rotate'_nil (n : ℕ) : ([] : list α).rotate' n = [] := by cases n; refl\n\n@[simp] lemma rotate'_zero (l : list α) : l.rotate' 0 = l := by cases l; refl\n\nlemma rotate'_cons_succ (l : list α) (a : α) (n : ℕ) :\n  (a :: l : list α).rotate' n.succ = (l ++ [a]).rotate' n := by simp [rotate']\n\n@[simp] lemma length_rotate' : ∀ (l : list α) (n : ℕ), (l.rotate' n).length = l.length\n| []     n     := rfl\n| (a::l) 0     := rfl\n| (a::l) (n+1) := by rw [list.rotate', length_rotate' (l ++ [a]) n]; simp\n\nlemma rotate'_eq_take_append_drop : ∀ {l : list α} {n : ℕ}, n ≤ l.length →\n  l.rotate' n = l.drop n ++ l.take n\n| []     n     h := by simp [drop_append_of_le_length h]\n| l      0     h := by simp [take_append_of_le_length h]\n| (a::l) (n+1) h :=\nhave hnl : n ≤ l.length, from le_of_succ_le_succ h,\nhave hnl' : n ≤ (l ++ [a]).length,\n  by rw [length_append, length_cons, list.length, zero_add];\n    exact (le_of_succ_le h),\nby rw [rotate'_cons_succ, rotate'_eq_take_append_drop hnl', drop, take,\n     drop_append_of_le_length hnl, take_append_of_le_length hnl];\n   simp\n\nlemma rotate'_rotate' : ∀ (l : list α) (n m : ℕ), (l.rotate' n).rotate' m = l.rotate' (n + m)\n| (a::l) 0     m := by simp\n| []     n     m := by simp\n| (a::l) (n+1) m := by rw [rotate'_cons_succ, rotate'_rotate', add_right_comm, rotate'_cons_succ]\n\n@[simp] lemma rotate'_length (l : list α) : rotate' l l.length = l :=\nby rw rotate'_eq_take_append_drop (le_refl _); simp\n\n@[simp] lemma rotate'_length_mul (l : list α) : ∀ n : ℕ, l.rotate' (l.length * n) = l\n| 0     := by simp\n| (n+1) :=\ncalc l.rotate' (l.length * (n + 1)) =\n  (l.rotate' (l.length * n)).rotate' (l.rotate' (l.length * n)).length :\n    by simp [-rotate'_length, nat.mul_succ, rotate'_rotate']\n... = l : by rw [rotate'_length, rotate'_length_mul]\n\nlemma rotate'_mod (l : list α) (n : ℕ) : l.rotate' (n % l.length) = l.rotate' n :=\ncalc l.rotate' (n % l.length) = (l.rotate' (n % l.length)).rotate'\n    ((l.rotate' (n % l.length)).length * (n / l.length)) : by rw rotate'_length_mul\n... = l.rotate' n : by rw [rotate'_rotate', length_rotate', nat.mod_add_div]\n\nlemma rotate_eq_rotate' (l : list α) (n : ℕ) : l.rotate n = l.rotate' n :=\nif h : l.length = 0 then by simp [length_eq_zero, *] at *\nelse by\n  rw [← rotate'_mod, rotate'_eq_take_append_drop (le_of_lt (nat.mod_lt _ (nat.pos_of_ne_zero h)))];\n  simp [rotate]\n\nlemma rotate_cons_succ (l : list α) (a : α) (n : ℕ) :\n  (a :: l : list α).rotate n.succ = (l ++ [a]).rotate n :=\nby rw [rotate_eq_rotate', rotate_eq_rotate', rotate'_cons_succ]\n\n@[simp] lemma mem_rotate : ∀ {l : list α} {a : α} {n : ℕ}, a ∈ l.rotate n ↔ a ∈ l\n| []     _ n     := by simp\n| (a::l) _ 0     := by simp\n| (a::l) _ (n+1) := by simp [rotate_cons_succ, mem_rotate, or.comm]\n\n@[simp] lemma length_rotate (l : list α) (n : ℕ) : (l.rotate n).length = l.length :=\nby rw [rotate_eq_rotate', length_rotate']\n\nlemma rotate_eq_take_append_drop {l : list α} {n : ℕ} : n ≤ l.length →\n  l.rotate n = l.drop n ++ l.take n :=\nby rw rotate_eq_rotate'; exact rotate'_eq_take_append_drop\n\nlemma rotate_rotate (l : list α) (n m : ℕ) : (l.rotate n).rotate m = l.rotate (n + m) :=\nby rw [rotate_eq_rotate', rotate_eq_rotate', rotate_eq_rotate', rotate'_rotate']\n\n@[simp] lemma rotate_length (l : list α) : rotate l l.length = l :=\nby rw [rotate_eq_rotate', rotate'_length]\n\n@[simp] lemma rotate_length_mul (l : list α) (n : ℕ) : l.rotate (l.length * n) = l :=\nby rw [rotate_eq_rotate', rotate'_length_mul]\n\nlemma prod_rotate_eq_one_of_prod_eq_one [group α] : ∀ {l : list α} (hl : l.prod = 1) (n : ℕ),\n  (l.rotate n).prod = 1\n| []     _  _ := by simp\n| (a::l) hl n :=\nhave n % list.length (a :: l) ≤ list.length (a :: l), from le_of_lt (nat.mod_lt _ dec_trivial),\nby rw ← list.take_append_drop (n % list.length (a :: l)) (a :: l) at hl;\n  rw [← rotate_mod, rotate_eq_take_append_drop this, list.prod_append, mul_eq_one_iff_inv_eq,\n    ← one_mul (list.prod _)⁻¹, ← hl, list.prod_append, mul_assoc, mul_inv_self, mul_one]\n\nsection choose\nvariables (p : α → Prop) [decidable_pred p] (l : list α)\n\nlemma choose_spec (hp : ∃ a, a ∈ l ∧ p a) : choose p l hp ∈ l ∧ p (choose p l hp) :=\n(choose_x p l hp).property\n\nlemma choose_mem (hp : ∃ a, a ∈ l ∧ p a) : choose p l hp ∈ l := (choose_spec _ _ _).1\n\nlemma choose_property (hp : ∃ a, a ∈ l ∧ p a) : p (choose p l hp) := (choose_spec _ _ _).2\n\nend choose\n\nend list\n\ntheorem option.to_list_nodup {α} : ∀ o : option α, o.to_list.nodup\n| none     := list.nodup_nil\n| (some x) := list.nodup_singleton x\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/data/list/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.7772998560157663, "lm_q1q2_score": 0.4723364944171909}}
{"text": "import deduction.deduction order.bounded_order\n\nnamespace deduction_cart\n\nopen deduction_basic\n\n/- Truth -/\nclass has_ltop (Form : Type) extends has_struct_derives Form := \n  (top : Form)\n  (truth : ∀ {Φ : Hyp}, derives Φ top)\n\ninstance {Form : Type} [Der : has_ltop Form] : has_top Form := ⟨ Der.top ⟩\n\n/- Logical And -/\nclass has_and (Form : Type) extends has_ltop Form :=\n  (and : Form → Form → Form)\n  (and_intro {Φ} {φ ψ : Form}    \n        : derives Φ φ → derives Φ ψ → derives Φ (and φ ψ))\n  (and_eliml {Φ} {φ ψ : Form}    \n        : derives Φ (and φ ψ) → derives Φ φ)\n  (and_elimr {Φ} {φ ψ : Form}    \n        : derives Φ (and φ ψ) → derives Φ ψ)\n\ninfix `&`:79      := has_and.and \n\n/- Implication -/\nclass has_impl (Form : Type) extends has_and Form :=\n  (impl : Form → Form → Form)\n  (impl_intro {Φ} (φ) {ψ}   \n        : derives (insert φ Φ) ψ → derives Φ (impl φ ψ))\n  (impl_elim {Φ} (φ) {ψ} \n        : derives Φ (impl φ ψ) → derives Φ φ → derives Φ ψ)\n\nnotation (name:= has_impl.impl) φ ` ⊃ `:80 ψ := has_impl.impl φ ψ \n\n\n/- All three -/\nend deduction_cart\n\n\nnamespace cart_x\n  open deduction_basic\n  open deduction_cart\n\n  lemma and_intro1 {Form : Type} [Der : has_and Form] {φ ψ : Form} : \n    Der.derives (Der.insertHyp.insert ψ {φ}) (φ&ψ) :=\n  begin\n    apply Der.and_intro,\n    apply Der.weak1,\n    apply derive_refl,\n    apply Der.hyp,\n    apply Der.inInsert,\n  end\n  lemma and_internal {Form : Type} [Der : has_and Form] {φ ψ θ: Form} : \n    (φ & ψ ⊢ θ) → Der.derives (Der.insertHyp.insert ψ {φ}) θ :=\n  begin\n    assume h,\n    apply Der.derive_Trans (φ & ψ),\n    exact and_intro1,\n    exact h,\n  end\n\n\n  lemma and_eliml1 {Form : Type} [Der : has_and Form] {φ ψ : Form} : \n    φ & ψ ⊢ φ :=\n  begin\n    apply Der.and_eliml,\n    apply derive_refl,\n  end\n  lemma and_elimr1 {Form : Type} [Der : has_and Form] {φ ψ : Form} : \n    φ & ψ ⊢ ψ :=\n  begin\n    apply Der.and_elimr,\n    apply derive_refl,\n  end\n\n  lemma modus_ponens {Form : Type} [Der : has_impl Form] : \n    ∀ {φ ψ : Form}, (φ ⊃ ψ) & φ ⊢ ψ :=\n  begin\n    assume φ ψ,\n    apply Der.impl_elim φ,\n    apply and_eliml1,\n    apply and_elimr1,\n  end\n\n  lemma impl_ε {Form : Type} [Der : has_impl Form] :\n    ∀ {φ ψ θ : Form}, φ & ψ ⊢ θ  →  φ ⊢ ψ ⊃ θ :=\n  begin\n    assume φ ψ θ h,\n    apply Der.impl_intro,\n    apply Der.derive_Trans,\n    apply and_intro1,\n    exact h,\n  end\n\n  lemma insert_trans {Form : Type} [Der : has_impl Form] {Φ} {φ ψ : Form} :\n    (φ ⊢ ψ) → Der.derives (Der.insertHyp.insert φ Φ) ψ :=\n  begin\n    assume h,\n    apply Der.derive_Trans φ,\n    apply Der.hyp,\n    apply Der.inInsert,\n    exact h,\n  end\nend cart_x", "meta": {"author": "lean-catLogic", "repo": "formalization", "sha": "bf4eda918a90ed04b8867bfcc587cc0dda1c4347", "save_path": "github-repos/lean/lean-catLogic-formalization", "path": "github-repos/lean/lean-catLogic-formalization/formalization-bf4eda918a90ed04b8867bfcc587cc0dda1c4347/src/deduction/deduction_cartesian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568417, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4723364912823023}}
{"text": "/-\nCopyright (c) 2021 Kevin Kappelmann. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Kappelmann\n-/\nimport algebra.continued_fractions.computation.approximations\nimport algebra.continued_fractions.convergents_equiv\nimport topology.algebra.ordered\n/-!\n# Corollaries From Approximation Lemmas (`algebra.continued_fractions.computation.approximations`)\n\n## Summary\n\nWe show that the generalized_continued_fraction given by `generalized_continued_fraction.of` in fact\nis a (regular) continued fraction. Using the equivalence of the convergents computations\n(`generalized_continued_fraction.convergents` and `generalized_continued_fraction.convergents'`) for\ncontinued fractions (see `algebra.continued_fractions.convergents_equiv`), it follows that the\nconvergents computations for `generalized_continued_fraction.of` are equivalent.\n\nMoreover, we show the convergence of the continued fractions computations, that is\n`(generalized_continued_fraction.of v).convergents` indeed computes `v` in the limit.\n\n## Main Definitions\n\n- `continued_fraction.of` returns the (regular) continued fraction of a value.\n\n## Main Theorems\n\n- `generalized_continued_fraction.of_convergents_eq_convergents'` shows that the convergents\n  computations for `generalized_continued_fraction.of` are equivalent.\n- `generalized_continued_fraction.of_convergence` shows that\n  `(generalized_continued_fraction.of v).convergents` converges to `v`.\n\n## Tags\n\nconvergence, fractions\n-/\n\nvariables {K : Type*} (v : K) [linear_ordered_field K] [floor_ring K]\nopen generalized_continued_fraction as gcf\n\nlemma generalized_continued_fraction.of_is_simple_continued_fraction :\n  (gcf.of v).is_simple_continued_fraction :=\n(λ _ _ nth_part_num_eq, gcf.of_part_num_eq_one nth_part_num_eq)\n\n/-- Creates the simple continued fraction of a value. -/\ndef simple_continued_fraction.of : simple_continued_fraction K :=\n⟨gcf.of v, generalized_continued_fraction.of_is_simple_continued_fraction v⟩\n\nlemma simple_continued_fraction.of_is_continued_fraction :\n  (simple_continued_fraction.of v).is_continued_fraction :=\n(λ _ denom nth_part_denom_eq,\n  lt_of_lt_of_le zero_lt_one(gcf.of_one_le_nth_part_denom nth_part_denom_eq))\n\n/-- Creates the continued fraction of a value. -/\ndef continued_fraction.of : continued_fraction K :=\n⟨simple_continued_fraction.of v, simple_continued_fraction.of_is_continued_fraction v⟩\n\nnamespace generalized_continued_fraction\n\nopen continued_fraction as cf\n\nlemma of_convergents_eq_convergents' : (gcf.of v).convergents = (gcf.of v).convergents' :=\n@cf.convergents_eq_convergents'  _ _ (continued_fraction.of v)\n\nsection convergence\n/-!\n### Convergence\n\nWe next show that `(generalized_continued_fraction.of v).convergents v` converges to `v`.\n-/\n\nvariable [archimedean K]\nlocal notation `|` x `|` := abs x\nopen nat\n\ntheorem of_convergence_epsilon :\n  ∀ (ε > (0 : K)), ∃ (N : ℕ), ∀ (n ≥ N), |v - (gcf.of v).convergents n| < ε :=\nbegin\n  assume ε ε_pos,\n  -- use the archemidean property to obtian a suitable N\n  rcases (exists_nat_gt (1 / ε) : ∃ (N' : ℕ), 1 / ε < N') with ⟨N', one_div_ε_lt_N'⟩,\n  let N := max N' 5, -- set minimum to 5 to have N ≤ fib N work\n  existsi N,\n  assume n n_ge_N,\n  let g := gcf.of v,\n  cases decidable.em (g.terminated_at n) with terminated_at_n not_terminated_at_n,\n  { have : v = g.convergents n, from of_correctness_of_terminated_at terminated_at_n,\n    have : v - g.convergents n = 0, from sub_eq_zero.elim_right this,\n    rw [this],\n    exact_mod_cast ε_pos },\n  { let B := g.denominators n,\n    let nB := g.denominators (n + 1),\n    have abs_v_sub_conv_le : |v - g.convergents n| ≤ 1 / (B * nB), from\n      abs_sub_convergents_le not_terminated_at_n,\n    suffices : 1 / (B * nB) < ε, from lt_of_le_of_lt abs_v_sub_conv_le this,\n    -- show that `0 < (B * nB)` and then multiply by `B * nB` to get rid of the division\n    have nB_ineq : (fib (n + 2) : K) ≤ nB, by\n    { have : ¬g.terminated_at (n + 1 - 1), from not_terminated_at_n,\n      exact (succ_nth_fib_le_of_nth_denom (or.inr this)) },\n    have B_ineq : (fib (n + 1) : K) ≤ B, by\n    { have : ¬g.terminated_at (n - 1), from mt (terminated_stable n.pred_le) not_terminated_at_n,\n      exact (succ_nth_fib_le_of_nth_denom (or.inr this)) },\n    have zero_lt_B : 0 < B, by\n    { have : (0 : K) < fib (n + 1), by exact_mod_cast fib_pos n.zero_lt_succ,\n      exact (lt_of_lt_of_le this B_ineq) },\n    have zero_lt_mul_conts : 0 < B * nB, by\n    { have : 0 < nB, by\n      { have : (0 : K) < fib (n + 2), by exact_mod_cast fib_pos (n + 1).zero_lt_succ,\n        exact (lt_of_lt_of_le this nB_ineq) },\n      solve_by_elim [mul_pos] },\n    suffices : 1 < ε * (B * nB), from (div_lt_iff zero_lt_mul_conts).elim_right this,\n    -- use that `N ≥ n` was obtained from the archimedian property to show the following\n    have one_lt_ε_mul_N : 1 < ε * n, by\n    { have one_lt_ε_mul_N' : 1 < ε * (N' : K), from (div_lt_iff' ε_pos).elim_left one_div_ε_lt_N',\n      have : (N' : K) ≤ N, by exact_mod_cast (le_max_left  _ _),\n      have : ε * N' ≤ ε * n, from\n        (mul_le_mul_left ε_pos).elim_right (le_trans this (by exact_mod_cast n_ge_N)),\n      exact (lt_of_lt_of_le one_lt_ε_mul_N' this) },\n    suffices : ε * n ≤ ε * (B * nB), from lt_of_lt_of_le one_lt_ε_mul_N this,\n    -- cancel `ε`\n    suffices : (n : K) ≤ B * nB, from (mul_le_mul_left ε_pos).elim_right this,\n    show (n : K) ≤ B * nB,\n      calc (n : K)\n          ≤ fib n                     : by exact_mod_cast (le_fib_self $ le_trans\n                                           (le_max_right N' 5) n_ge_N)\n      ... ≤ fib (n + 1)               : by exact_mod_cast fib_le_fib_succ\n      ... ≤ fib (n + 1) * fib (n + 1) : by exact_mod_cast ((fib (n + 1)).le_mul_self)\n      ... ≤ fib (n + 1) * fib (n + 2) : mul_le_mul_of_nonneg_left\n                                          (by exact_mod_cast fib_le_fib_succ)\n                                          (by exact_mod_cast (fib (n + 1)).zero_le)\n      ... ≤ B * nB                    : mul_le_mul B_ineq nB_ineq\n                                          (by exact_mod_cast (fib (n + 2)).zero_le)\n                                          (le_of_lt zero_lt_B) }\nend\n\nlocal attribute [instance] preorder.topology\n\ntheorem of_convergence [order_topology K] :\n  filter.tendsto ((gcf.of v).convergents) filter.at_top $ nhds v :=\nby simpa [linear_ordered_add_comm_group.tendsto_nhds, abs_sub] using (of_convergence_epsilon v)\n\nend convergence\n\nend generalized_continued_fraction\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/continued_fractions/computation/approximation_corollaries.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.4723332272130398}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Johannes Hölzl, Reid Barton, Sean Leather, Yury Kudryashov\n\n! This file was ported from Lean 3 source module category_theory.concrete_category.basic\n! leanprover-community/mathlib commit 05b820ec79b3c98a7dbf1cb32e181584166da2ca\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Types\nimport Mathlib.CategoryTheory.Functor.EpiMono\nimport Mathlib.CategoryTheory.Limits.Constructions.EpiMono\n\n/-!\n# Concrete categories\n\nA concrete category is a category `C` with a fixed faithful functor\n`forget : C ⥤ Type*`.  We define concrete categories using `class\nconcrete_category`.  In particular, we impose no restrictions on the\ncarrier type `C`, so `Type` is a concrete category with the identity\nforgetful functor.\n\nEach concrete category `C` comes with a canonical faithful functor\n`forget C : C ⥤ Type*`.  We say that a concrete category `C` admits a\n*forgetful functor* to a concrete category `D`, if it has a functor\n`forget₂ C D : C ⥤ D` such that `(forget₂ C D) ⋙ (forget D) = forget C`,\nsee `class has_forget₂`.  Due to `faithful.div_comp`, it suffices\nto verify that `forget₂.obj` and `forget₂.map` agree with the equality\nabove; then `forget₂` will satisfy the functor laws automatically, see\n`has_forget₂.mk'`.\n\nTwo classes helping construct concrete categories in the two most\ncommon cases are provided in the files `bundled_hom` and\n`unbundled_hom`, see their documentation for details.\n\n## References\n\nSee [Ahrens and Lumsdaine, *Displayed Categories*][ahrens2017] for\nrelated work.\n-/\n\n\nuniverse w v v' u\n\nnamespace CategoryTheory\n\nopen CategoryTheory.Limits\n\n/-- A concrete category is a category `C` with a fixed faithful functor `Forget : C ⥤ Type`.\n\nNote that `ConcreteCategory` potentially depends on three independent universe levels,\n* the universe level `w` appearing in `Forget : C ⥤ Type w`\n* the universe level `v` of the morphisms (i.e. we have a `Category.{v} C`)\n* the universe level `u` of the objects (i.e `C : Type u`)\nThey are specified that order, to avoid unnecessary universe annotations.\n-/\nclass ConcreteCategory (C : Type u) [Category.{v} C] where\n  /-- We have a functor to Type -/\n  Forget : C ⥤ Type w -- Porting note: it has Type in the signature...\n  /-- That functor is faithful -/\n  [forget_faithful : Faithful Forget]\n#align category_theory.concrete_category CategoryTheory.ConcreteCategory\n#align category_theory.concrete_category.forget CategoryTheory.ConcreteCategory.Forget\n\nattribute [instance] ConcreteCategory.forget_faithful\n\n/-- The forgetful functor from a concrete category to `Type u`. -/\n@[reducible]\ndef forget (C : Type v) [Category C] [ConcreteCategory.{u} C] : C ⥤ Type u :=\n  ConcreteCategory.Forget\n#align category_theory.forget CategoryTheory.forget\n\ninstance ConcreteCategory.types : ConcreteCategory (Type u) where\n  Forget := 𝟭 _\n#align category_theory.concrete_category.types CategoryTheory.ConcreteCategory.types\n\n/-- Provide a coercion to `Type u` for a concrete category. This is not marked as an instance\nas it could potentially apply to every type, and so is too expensive in typeclass search.\n\nYou can use it on particular examples as:\n```\ninstance : HasCoeToSort X := ConcreteCategory.hasCoeToSort X\n```\n-/\ndef ConcreteCategory.hasCoeToSort (C : Type v) [Category C] [ConcreteCategory C] :\n    CoeSort C (Type u) where\n  coe := fun X => ConcreteCategory.Forget.obj X\n#align category_theory.concrete_category.has_coe_to_sort CategoryTheory.ConcreteCategory.hasCoeToSort\n\nsection\n\nattribute [local instance] ConcreteCategory.hasCoeToSort\n\nvariable {C : Type v} [Category C] [ConcreteCategory.{w} C]\n\n@[simp]\ntheorem forget_obj_eq_coe {X : C} : (forget C).obj X = X := rfl\n#align category_theory.forget_obj_eq_coe CategoryTheory.forget_obj_eq_coe\n\n/-- Usually a bundled hom structure already has a coercion to function\nthat works with different universes. So we don't use this as a global instance. -/\ndef ConcreteCategory.hasCoeToFun {X Y : C} : CoeFun (X ⟶ Y) fun _ => X → Y :=\n  ⟨fun f => (forget _).map f⟩\n#align category_theory.concrete_category.has_coe_to_fun CategoryTheory.ConcreteCategory.hasCoeToFun\n\nattribute [local instance] ConcreteCategory.hasCoeToFun\n\n/-- In any concrete category, we can test equality of morphisms by pointwise evaluations.-/\n@[ext 900] -- Porting note: lowered priority\ntheorem ConcreteCategory.hom_ext {X Y : C} (f g : X ⟶ Y) (w : ∀ x : X, f x = g x) : f = g := by\n  apply @Faithful.map_injective C _ (Type w) _ (forget C) _ X Y\n  dsimp [forget]\n  funext x\n  exact w x\n#align category_theory.concrete_category.hom_ext CategoryTheory.ConcreteCategory.hom_ext\n\n@[simp, nolint synTaut] -- Porting note: synTaut is fine with CoeFun.coe explicitly on the RHS\ntheorem forget_map_eq_coe {X Y : C} (f : X ⟶ Y) : (forget C).map f = f := rfl\n#align category_theory.forget_map_eq_coe CategoryTheory.forget_map_eq_coe\n\n/-- Analogue of `congr_fun h x`,\nwhen `h : f = g` is an equality between morphisms in a concrete category.\n-/\ntheorem congr_hom {X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x :=\n  congrFun (congrArg (fun k : X ⟶ Y => (k : X → Y)) h) x\n#align category_theory.congr_hom CategoryTheory.congr_hom\n\ntheorem coe_id {X : C} : (𝟙 X : X → X) = id :=\n  (forget _).map_id X\n#align category_theory.coe_id CategoryTheory.coe_id\n\ntheorem coe_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g : X → Z) = g ∘ f :=\n  (forget _).map_comp f g\n#align category_theory.coe_comp CategoryTheory.coe_comp\n\n-- Porting note: removed @[simp] since simp can prove this\ntheorem id_apply {X : C} (x : X) : (𝟙 X : X → X) x = x :=\n  congr_fun ((forget _).map_id X) x\n#align category_theory.id_apply CategoryTheory.id_apply\n\n-- Porting note: removed @[simp] since simp can prove this\ntheorem comp_apply {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) :=\n  congr_fun ((forget _).map_comp _ _) x\n#align category_theory.comp_apply CategoryTheory.comp_apply\n\ntheorem ConcreteCategory.congr_hom {X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x :=\n  congr_fun (congr_arg (fun f : X ⟶ Y => (f : X → Y)) h) x\n#align category_theory.concrete_category.congr_hom CategoryTheory.ConcreteCategory.congr_hom\n\ntheorem ConcreteCategory.congr_arg {X Y : C} (f : X ⟶ Y) {x x' : X} (h : x = x') : f x = f x' :=\n  congrArg (f : X → Y) h\n#align category_theory.concrete_category.congr_arg CategoryTheory.ConcreteCategory.congr_arg\n\n/-- In any concrete category, injective morphisms are monomorphisms. -/\ntheorem ConcreteCategory.mono_of_injective {X Y : C} (f : X ⟶ Y) (i : Function.Injective f) :\n    Mono f :=\n  (forget C).mono_of_mono_map ((mono_iff_injective f).2 i)\n#align category_theory.concrete_category.mono_of_injective CategoryTheory.ConcreteCategory.mono_of_injective\n\ntheorem ConcreteCategory.injective_of_mono_of_preservesPullback {X Y : C} (f : X ⟶ Y) [Mono f]\n    [PreservesLimitsOfShape WalkingCospan (forget C)] : Function.Injective f :=\n  (mono_iff_injective ((forget C).map f)).mp inferInstance\n#align category_theory.concrete_category.injective_of_mono_of_preserves_pullback CategoryTheory.ConcreteCategory.injective_of_mono_of_preservesPullback\n\ntheorem ConcreteCategory.mono_iff_injective_of_preservesPullback {X Y : C} (f : X ⟶ Y)\n    [PreservesLimitsOfShape WalkingCospan (forget C)] : Mono f ↔ Function.Injective f :=\n  ((forget C).mono_map_iff_mono _).symm.trans (mono_iff_injective _)\n#align category_theory.concrete_category.mono_iff_injective_of_preserves_pullback CategoryTheory.ConcreteCategory.mono_iff_injective_of_preservesPullback\n\n/-- In any concrete category, surjective morphisms are epimorphisms. -/\ntheorem ConcreteCategory.epi_of_surjective {X Y : C} (f : X ⟶ Y) (s : Function.Surjective f) :\n    Epi f :=\n  (forget C).epi_of_epi_map ((epi_iff_surjective f).2 s)\n#align category_theory.concrete_category.epi_of_surjective CategoryTheory.ConcreteCategory.epi_of_surjective\n\ntheorem ConcreteCategory.surjective_of_epi_of_preservesPushout {X Y : C} (f : X ⟶ Y) [Epi f]\n    [PreservesColimitsOfShape WalkingSpan (forget C)] : Function.Surjective f :=\n  (epi_iff_surjective ((forget C).map f)).mp inferInstance\n#align category_theory.concrete_category.surjective_of_epi_of_preserves_pushout CategoryTheory.ConcreteCategory.surjective_of_epi_of_preservesPushout\n\ntheorem ConcreteCategory.epi_iff_surjective_of_preservesPushout {X Y : C} (f : X ⟶ Y)\n    [PreservesColimitsOfShape WalkingSpan (forget C)] : Epi f ↔ Function.Surjective f :=\n  ((forget C).epi_map_iff_epi _).symm.trans (epi_iff_surjective _)\n#align category_theory.concrete_category.epi_iff_surjective_of_preserves_pushout CategoryTheory.ConcreteCategory.epi_iff_surjective_of_preservesPushout\n\ntheorem ConcreteCategory.bijective_of_isIso {X Y : C} (f : X ⟶ Y) [IsIso f] :\n    Function.Bijective ((forget C).map f) := by\n  rw [← isIso_iff_bijective]\n  infer_instance\n#align category_theory.concrete_category.bijective_of_is_iso CategoryTheory.ConcreteCategory.bijective_of_isIso\n\n@[simp]\ntheorem ConcreteCategory.hasCoeToFun_Type {X Y : Type u} (f : X ⟶  Y) : CoeFun.coe f = f := rfl\n#align category_theory.concrete_category.has_coe_to_fun_Type CategoryTheory.ConcreteCategory.hasCoeToFun_Type\n\nend\n\n/-- `HasForget₂ C D`, where `C` and `D` are both concrete categories, provides a functor\n`forget₂ C D : C ⥤ D` and a proof that `forget₂ ⋙ (forget D) = forget C`.\n-/\nclass HasForget₂ (C : Type v) (D : Type v') [Category C] [ConcreteCategory.{u} C] [Category D]\n  [ConcreteCategory.{u} D] where\n  /-- A functor from `C` to `D` -/\n  forget₂ : C ⥤ D\n  /-- It covers the `ConcreteCategory.Forget` for `C` and `D` -/\n  forget_comp : forget₂ ⋙ forget D = forget C := by aesop\n#align category_theory.has_forget₂ CategoryTheory.HasForget₂\n\n/-- The forgetful functor `C ⥤ D` between concrete categories for which we have an instance\n`HasForget₂ C `. -/\n@[reducible]\ndef forget₂ (C : Type v) (D : Type v') [Category C] [ConcreteCategory C] [Category D]\n    [ConcreteCategory D] [HasForget₂ C D] : C ⥤ D :=\n  HasForget₂.forget₂\n#align category_theory.forget₂ CategoryTheory.forget₂\n\ninstance forget₂_faithful (C : Type v) (D : Type v') [Category C] [ConcreteCategory C] [Category D]\n    [ConcreteCategory D] [HasForget₂ C D] : Faithful (forget₂ C D) :=\n  HasForget₂.forget_comp.faithful_of_comp\n#align category_theory.forget₂_faithful CategoryTheory.forget₂_faithful\n\ninstance forget₂_preservesMonomorphisms (C : Type v) (D : Type v') [Category C] [ConcreteCategory C]\n    [Category D] [ConcreteCategory D] [HasForget₂ C D] [(forget C).PreservesMonomorphisms] :\n    (forget₂ C D).PreservesMonomorphisms :=\n  have : (forget₂ C D ⋙ forget D).PreservesMonomorphisms := by\n    simp only [HasForget₂.forget_comp]\n    infer_instance\n  Functor.preservesMonomorphisms_of_preserves_of_reflects _ (forget D)\n#align category_theory.forget₂_preserves_monomorphisms CategoryTheory.forget₂_preservesMonomorphisms\n\ninstance forget₂_preservesEpimorphisms (C : Type v) (D : Type v') [Category C] [ConcreteCategory C]\n    [Category D] [ConcreteCategory D] [HasForget₂ C D] [(forget C).PreservesEpimorphisms] :\n    (forget₂ C D).PreservesEpimorphisms :=\n  have : (forget₂ C D ⋙ forget D).PreservesEpimorphisms := by\n    simp only [HasForget₂.forget_comp]\n    infer_instance\n  Functor.preservesEpimorphisms_of_preserves_of_reflects _ (forget D)\n#align category_theory.forget₂_preserves_epimorphisms CategoryTheory.forget₂_preservesEpimorphisms\n\ninstance InducedCategory.concreteCategory {C : Type v} {D : Type v'} [Category D]\n    [ConcreteCategory D] (f : C → D) : ConcreteCategory (InducedCategory D f) where\n  Forget := inducedFunctor f ⋙ forget D\n#align category_theory.induced_category.concrete_category CategoryTheory.InducedCategory.concreteCategory\n\ninstance InducedCategory.hasForget₂ {C : Type v} {D : Type v'} [Category D] [ConcreteCategory D]\n    (f : C → D) : HasForget₂ (InducedCategory D f) D where\n  forget₂ := inducedFunctor f\n  forget_comp := rfl\n#align category_theory.induced_category.has_forget₂ CategoryTheory.InducedCategory.hasForget₂\n\ninstance FullSubcategory.concreteCategory {C : Type v} [Category C] [ConcreteCategory C]\n    (Z : C → Prop) : ConcreteCategory (FullSubcategory Z) where\n  Forget := fullSubcategoryInclusion Z ⋙ forget C\n#align category_theory.full_subcategory.concrete_category CategoryTheory.FullSubcategoryₓ.concreteCategory\n\ninstance FullSubcategory.hasForget₂ {C : Type v} [Category C] [ConcreteCategory C] (Z : C → Prop) :\n    HasForget₂ (FullSubcategory Z) C where\n  forget₂ := fullSubcategoryInclusion Z\n  forget_comp := rfl\n#align category_theory.full_subcategory.has_forget₂ CategoryTheory.FullSubcategoryₓ.hasForget₂\n\n/-- In order to construct a “partially forgetting” functor, we do not need to verify functor laws;\nit suffices to ensure that compositions agree with `forget₂ C D ⋙ forget D = forget C`.\n-/\ndef HasForget₂.mk' {C : Type v} {D : Type v'} [Category C] [ConcreteCategory C] [Category D]\n    [ConcreteCategory D] (obj : C → D) (h_obj : ∀ X, (forget D).obj (obj X) = (forget C).obj X)\n    (map : ∀ {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))\n    (h_map : ∀ {X Y} {f : X ⟶ Y}, HEq ((forget D).map (map f)) ((forget C).map f)) : HasForget₂ C D\n    where\n  forget₂ := Faithful.div _ _ _ @h_obj _ @h_map\n  forget_comp := by apply Faithful.div_comp\n#align category_theory.has_forget₂.mk' CategoryTheory.HasForget₂.mk'\n\n/-- Every forgetful functor factors through the identity functor. This is not a global instance as\n    it is prone to creating type class resolution loops. -/\ndef hasForgetToType (C : Type v) [Category C] [ConcreteCategory C] : HasForget₂ C (Type u) where\n  forget₂ := forget C\n  forget_comp := Functor.comp_id _\n#align category_theory.has_forget_to_Type CategoryTheory.hasForgetToType\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/ConcreteCategory/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.47233322721303966}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.functor.fully_faithful\n\n/-!\n# Functors which reflect isomorphisms\n\nA functor `F` reflects isomorphisms if whenever `F.map f` is an isomorphism, `f` was too.\n\nIt is formalized as a `Prop` valued typeclass `reflects_isomorphisms F`.\n\nAny fully faithful functor reflects isomorphisms.\n-/\n\nopen category_theory\n\nnamespace category_theory\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\nvariables {C : Type u₁} [category.{v₁} C]\n\nsection reflects_iso\nvariables {D : Type u₂} [category.{v₂} D]\nvariables {E : Type u₃} [category.{v₃} E]\n\n/--\nDefine what it means for a functor `F : C ⥤ D` to reflect isomorphisms: for any\nmorphism `f : A ⟶ B`, if `F.map f` is an isomorphism then `f` is as well.\nNote that we do not assume or require that `F` is faithful.\n-/\nclass reflects_isomorphisms (F : C ⥤ D) : Prop :=\n(reflects : Π {A B : C} (f : A ⟶ B) [is_iso (F.map f)], is_iso f)\n\n/-- If `F` reflects isos and `F.map f` is an iso, then `f` is an iso. -/\nlemma is_iso_of_reflects_iso {A B : C} (f : A ⟶ B) (F : C ⥤ D)\n  [is_iso (F.map f)] [reflects_isomorphisms F] :\n  is_iso f :=\nreflects_isomorphisms.reflects F f\n\n@[priority 100]\ninstance of_full_and_faithful (F : C ⥤ D) [full F] [faithful F] : reflects_isomorphisms F :=\n{ reflects := λ X Y f i, by exactI\n  ⟨⟨F.preimage (inv (F.map f)), ⟨F.map_injective (by simp), F.map_injective (by simp)⟩⟩⟩ }\n\ninstance (F : C ⥤ D) (G : D ⥤ E) [reflects_isomorphisms F] [reflects_isomorphisms G] :\n  reflects_isomorphisms (F ⋙ G) :=\n⟨λ _ _ f (hf : is_iso (G.map _)),\n  by { resetI, haveI := is_iso_of_reflects_iso (F.map f) G, exact is_iso_of_reflects_iso f F }⟩\n\nend reflects_iso\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/functor/reflects_isomorphisms.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4723332188382927}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.natural_isomorphism\nimport Mathlib.category_theory.full_subcategory\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l \n\nnamespace Mathlib\n\n/-!\n# Essential image of a functor\n\nThe essential image `ess_image` of a functor consists of the objects in the target category which\nare isomorphic to an object in the image of the object function.\nThis, for instance, allows us to talk about objects belonging to a subcategory expressed as a\nfunctor rather than a subtype, preserving the principle of equivalence. For example this lets us\ndefine exponential ideals.\n\nThe essential image can also be seen as a subcategory of the target category, and witnesses that\na functor decomposes into a essentially surjective functor and a fully faithful functor.\n(TODO: show that this decomposition forms an orthogonal factorisation system).\n-/\n\nnamespace category_theory\n\n\nnamespace functor\n\n\n/--\nThe essential image of a functor `F` consists of those objects in the target category which are\nisomorphic to an object in the image of the function `F.obj`. In other words, this is the closure\nunder isomorphism of the function `F.obj`.\nThis is the \"non-evil\" way of describing the image of a functor.\n-/\ndef ess_image {C : Type u₁} {D : Type u₂} [category C] [category D] (F : C ⥤ D) : set D :=\n  fun (Y : D) => ∃ (X : C), Nonempty (obj F X ≅ Y)\n\n/-- Get the witnessing object that `Y` is in the subcategory given by `F`. -/\ndef ess_image.witness {C : Type u₁} {D : Type u₂} [category C] [category D] {F : C ⥤ D} {Y : D}\n    (h : Y ∈ ess_image F) : C :=\n  Exists.some h\n\n/-- Extract the isomorphism between `F.obj h.witness` and `Y` itself. -/\ndef ess_image.get_iso {C : Type u₁} {D : Type u₂} [category C] [category D] {F : C ⥤ D} {Y : D}\n    (h : Y ∈ ess_image F) : obj F (ess_image.witness h) ≅ Y :=\n  Classical.choice sorry\n\n/-- Being in the essential image is a \"hygenic\" property: it is preserved under isomorphism. -/\ntheorem ess_image.of_iso {C : Type u₁} {D : Type u₂} [category C] [category D] {F : C ⥤ D} {Y : D}\n    {Y' : D} (h : Y ≅ Y') (hY : Y ∈ ess_image F) : Y' ∈ ess_image F :=\n  Exists.imp (fun (B : C) => nonempty.map fun (_x : obj F B ≅ Y) => _x ≪≫ h) hY\n\n/--\nIf `Y` is in the essential image of `F` then it is in the essential image of `F'` as long as\n`F ≅ F'`.\n-/\ntheorem ess_image.of_nat_iso {C : Type u₁} {D : Type u₂} [category C] [category D] {F : C ⥤ D}\n    {F' : C ⥤ D} (h : F ≅ F') {Y : D} (hY : Y ∈ ess_image F) : Y ∈ ess_image F' :=\n  Exists.imp (fun (X : C) => nonempty.map fun (t : obj F X ≅ Y) => iso.app (iso.symm h) X ≪≫ t) hY\n\n/-- Isomorphic functors have equal essential images. -/\ntheorem ess_image_eq_of_nat_iso {C : Type u₁} {D : Type u₂} [category C] [category D] {F : C ⥤ D}\n    {F' : C ⥤ D} (h : F ≅ F') : ess_image F = ess_image F' :=\n  set.ext fun (A : D) => { mp := ess_image.of_nat_iso h, mpr := ess_image.of_nat_iso (iso.symm h) }\n\n/-- An object in the image is in the essential image. -/\ntheorem obj_mem_ess_image {C : Type u₁} {D : Type u₂} [category C] [category D] (F : D ⥤ C)\n    (Y : D) : obj F Y ∈ ess_image F :=\n  Exists.intro Y (Nonempty.intro (iso.refl (obj F Y)))\n\nprotected instance ess_image.category_theory.category {C : Type u₁} {D : Type u₂} [category C]\n    [category D] {F : C ⥤ D} : category ↥(ess_image F) :=\n  category_theory.full_subcategory fun (x : D) => x ∈ ess_image F\n\n/-- The essential image as a subcategory has a fully faithful inclusion into the target category. -/\n@[simp] theorem ess_image_inclusion_obj {C : Type u₁} {D : Type u₂} [category C] [category D]\n    (F : C ⥤ D) (c : Subtype fun (X : D) => (fun (x : D) => x ∈ ess_image F) X) :\n    obj (ess_image_inclusion F) c = ↑c :=\n  Eq.refl ↑c\n\n/--\nGiven a functor `F : C ⥤ D`, we have an (essentially surjective) functor from `C` to the essential\nimage of `F`.\n-/\ndef to_ess_image {C : Type u₁} {D : Type u₂} [category C] [category D] (F : C ⥤ D) :\n    C ⥤ ↥(ess_image F) :=\n  mk (fun (X : C) => { val := obj F X, property := obj_mem_ess_image F X })\n    fun (X Y : C) (f : X ⟶ Y) => preimage (ess_image_inclusion F) (map F f)\n\n/--\nThe functor `F` factorises through its essential image, where the first functor is essentially\nsurjective and the second is fully faithful.\n-/\n@[simp] theorem to_ess_image_comp_essential_image_inclusion_hom_app {C : Type u₁} {D : Type u₂}\n    [category C] [category D] {F : C ⥤ D} (X : C) :\n    nat_trans.app (iso.hom to_ess_image_comp_essential_image_inclusion) X = 𝟙 :=\n  Eq.refl 𝟙\n\nend functor\n\n\n/--\nA functor `F : C ⥤ D` is essentially surjective if every object of `D` is in the essential image\nof `F`. In other words, for every `Y : D`, there is some `X : C` with `F.obj X ≅ Y`.\n\nSee https://stacks.math.columbia.edu/tag/001C.\n-/\nclass ess_surj {C : Type u₁} {D : Type u₂} [category C] [category D] (F : C ⥤ D) where\n  mem_ess_image : ∀ (Y : D), Y ∈ functor.ess_image F\n\nprotected instance functor.to_ess_image.ess_surj {C : Type u₁} {D : Type u₂} [category C]\n    [category D] {F : C ⥤ D} : ess_surj (functor.to_ess_image F) :=\n  ess_surj.mk fun (_x : ↥(functor.ess_image F)) => sorry\n\n/-- Given an essentially surjective functor, we can find a preimage for every object `Y` in the\n    codomain. Applying the functor to this preimage will yield an object isomorphic to `Y`, see\n    `obj_obj_preimage_iso`. -/\n/-- Applying an essentially surjective functor to a preimage of `Y` yields an object that is\ndef functor.obj_preimage {C : Type u₁} {D : Type u₂} [category C] [category D] (F : C ⥤ D)\n    [ess_surj F] (Y : D) : C :=\n  functor.ess_image.witness (ess_surj.mem_ess_image F Y)\n\n    isomorphic to `Y`. -/\ndef functor.obj_obj_preimage_iso {C : Type u₁} {D : Type u₂} [category C] [category D] (F : C ⥤ D)\n    [ess_surj F] (Y : D) : functor.obj F (functor.obj_preimage F Y) ≅ Y :=\n  functor.ess_image.get_iso (ess_surj.mem_ess_image F Y)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/essential_image_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4723332142258283}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport order.category.Lat\n\n/-!\n# Category of linear orders\n\nThis defines `LinOrd`, the category of linear orders with monotone maps.\n-/\n\nopen category_theory\n\nuniverse u\n\n/-- The category of linear orders. -/\ndef LinOrd := bundled linear_order\n\nnamespace LinOrd\n\ninstance : bundled_hom.parent_projection @linear_order.to_partial_order := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] LinOrd\n\ninstance : has_coe_to_sort LinOrd Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `LinOrd` from the underlying type and typeclass. -/\ndef of (α : Type*) [linear_order α] : LinOrd := bundled.of α\n\n@[simp] lemma coe_of (α : Type*) [linear_order α] : ↥(of α) = α := rfl\n\ninstance : inhabited LinOrd := ⟨of punit⟩\n\ninstance (α : LinOrd) : linear_order α := α.str\n\ninstance has_forget_to_Lat : has_forget₂ LinOrd Lat :=\n{ forget₂ := { obj := λ X, Lat.of X,\n               map := λ X Y f, (order_hom_class.to_lattice_hom X Y f : lattice_hom X Y) } }\n\n/-- Constructs an equivalence between linear orders from an order isomorphism between them. -/\n@[simps] def iso.mk {α β : LinOrd.{u}} (e : α ≃o β) : α ≅ β :=\n{ hom := e,\n  inv := e.symm,\n  hom_inv_id' := by { ext, exact e.symm_apply_apply x },\n  inv_hom_id' := by { ext, exact e.apply_symm_apply x } }\n\n/-- `order_dual` as a functor. -/\n@[simps] def dual : LinOrd ⥤ LinOrd :=\n{ obj := λ X, of Xᵒᵈ, map := λ X Y, order_hom.dual }\n\n/-- The equivalence between `LinOrd` and itself induced by `order_dual` both ways. -/\n@[simps functor inverse] def dual_equiv : LinOrd ≌ LinOrd :=\nequivalence.mk dual dual\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n\nend LinOrd\n\nlemma LinOrd_dual_comp_forget_to_Lat :\n  LinOrd.dual ⋙ forget₂ LinOrd Lat = forget₂ LinOrd Lat ⋙ Lat.dual :=\nrfl\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/order/category/LinOrd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.7025300449389325, "lm_q1q2_score": 0.4723332096133637}}
{"text": "import\n  IMO2020.N4.N4_basic\n  number_theory.legendre_symbol.quadratic_reciprocity\n  extra.number_theory.dirichlet_thm_arithmetic_progression\n\n/-! # IMO 2020 N4, Generalized Version (Part 2) -/\n\nnamespace IMOSL\nnamespace IMO2020N4\n\nopen function\nopen_locale classical\n\ndef balanced (p : ℕ) := ∀ a b : ℕ,\n  a.coprime p → b.coprime p → a < b → ∃ i : ℕ, 0 < i ∧ (F p^[i]) a ≤ (F p^[i]) b\n\n\n\nsection general_results\n\nvariables {p : ℕ} (h : odd p)\ninclude h\n\ntheorem balanced_iff_S0_coprime_eq_pairwise :\n  balanced p ↔ ∀ x y : ℕ, x.coprime p → y.coprime p → S0 h x = S0 h y :=\nbegin\n  ---- Right-to-left direction is easy\n  symmetry; refine ⟨λ h1 a b ha hb h2, ⟨order_two_mod_p h, order_two_mod_p_pos h, _⟩, _⟩,\n  rw [F_iterate_S, F_iterate_S, ← S0, ← S0, h1 a b ha hb, add_le_add_iff_right],\n  exact le_of_lt h2,\n  \n  ---- Use contrapositive, and reduce to the case `S_p(x) < S_p(y)`\n  suffices : (∃ x y : ℕ, x.coprime p ∧ y.coprime p ∧ S0 h x < S0 h y) → ¬balanced p,\n  { intros h1; contrapose! h1,\n    rcases h1 with ⟨x, y, h1, h2, h3⟩,\n    rw [ne_iff_lt_or_gt, gt_iff_lt] at h3,\n    cases h3 with h3 h3,\n    exacts [this ⟨x, y, h1, h2, h3⟩, this ⟨y, x, h2, h1, h3⟩] },\n\n  ---- There exists such `x` and `y` with an extra condition: `y < x`\n  rintros ⟨u, y, h1, h2, h3⟩,\n  simp only [balanced, not_forall, not_exists, not_and, not_le],\n  replace h1 : ∃ x : ℕ, x.coprime p ∧ y < x ∧ S0 h x < S0 h y :=\n  begin\n    refine ⟨u + (y + 1) * p, _, _, _⟩,\n    rwa nat.coprime_add_mul_right_left,\n    rw ← nat.add_one_le_iff,\n    exact le_trans (nat.le_mul_of_pos_right h.pos) le_add_self,\n    rwa [S0_mod_p, nat.add_mul_mod_self_right, ← S0_mod_p]\n  end,\n  clear h3 u,\n  rcases h1 with ⟨x, h1, h3⟩,\n\n  ---- It suffices to find some `N ≥ 0` such that `F_p^N(x) > F_p^N(y)` but\n  ----   `F_p^n(x) > F_p^n(y)` for all `n > N`\n  suffices : ∃ N : ℕ, (∀ n : ℕ, N < n → (F p^[n]) x < (F p^[n]) y) ∧ (F p^[N]) y < (F p^[N]) x,\n  { rcases this with ⟨N, h4, h5⟩,\n    refine ⟨(F p^[N]) y, (F p^[N]) x, F_iterate_coprime h h2 _,\n      F_iterate_coprime h h1 _, h5, λ k hk, _⟩,\n    replace h4 := h4 (k + N) (lt_add_of_pos_left N hk),\n    rwa [iterate_add, comp_app, comp_app] at h4 },\n\n  ---- Finishing: find such `N`\n  clear h1 h2; cases h3 with h1 h2,\n  replace h2 := eventually_F_lt_of_S0_lt h h2,\n  have h3 := nat.find_spec h2,\n  refine ⟨(nat.find h2).pred, λ n X, h3 n (nat.le_of_pred_lt X), _⟩,\n  generalize_hyp h4 : nat.find h2 = N at h3 ⊢,\n  cases N with _ N,\n  exact h1,\n  refine lt_of_le_of_ne _ (λ X, ne_of_lt h1 (injective.iterate (F_injective h) _ X)),\n  rw [nat.pred_succ, ← not_lt],\n  replace h4 := nat.find_min h2 (by rw h4; exact N.lt_succ_self),\n  clear h2,\n  simp only [not_forall] at h4,\n  rcases h4 with ⟨n, h2, h4⟩,\n  rw [le_iff_eq_or_lt, ← nat.succ_le_iff] at h2,\n  rcases h2 with rfl | h2,\n  exact h4,\n  exfalso; exact h4 (h3 n h2)\nend\n\ntheorem balanced_iff_S0_coprime_eq_const (h0 : 1 < p) :\n  balanced p ↔ ∀ x : ℕ, x.coprime p → 2 * S0 h x = order_two_mod_p h * p :=\nbegin\n  ---- Right-to-left direction is again easy\n  rw [balanced_iff_S0_coprime_eq_pairwise h, iff.comm],\n  refine ⟨λ h1 x y h2 h3, _, λ h1 x h2, _⟩,\n  replace h2 := h1 x h2,\n  rw ← h1 y h3 at h2,\n  exact nat.eq_of_mul_eq_mul_left two_pos h2,\n\n  ---- Left-to-right direction is not too hard either\n  suffices : ∃ y : ℕ, y.coprime p ∧ p ∣ x + y,\n  { rcases this with ⟨y, h3, h4⟩,\n    rw [← S0_p_dvd_add h (not_dvd_of_coprime (ne_of_gt h0) h2) h4, ← h1 x y h2 h3, ← two_mul] },\n  clear h1 h0,\n  refine ⟨x * (p - 1), h2.mul _, _⟩,\n  cases p with _ p,\n  exfalso; exact nat.lt_irrefl 0 h.pos,\n  rw [nat.succ_eq_add_one, nat.add_sub_cancel, nat.coprime_self_add_right],\n  exact nat.coprime_one_right p,\n  rw [← mul_one_add, add_comm, nat.sub_add_cancel h.pos],\n  exact ⟨x, mul_comm x p⟩\nend\n\n/-- Generally, if `-1` is a power of `2` mod `p`, then `p` is balanced -/\nlemma balanced_of_neg_one_is_two_pow_mod_p (h0 : 1 < p) (h1 : ∃ c : ℕ, p ∣ 2 ^ c + 1) :\n  balanced p :=\nbegin\n  cases h1 with c h1,\n  rw balanced_iff_S0_coprime_eq_const h h0; intros x h2,\n  replace h1 : p ∣ x + 2 ^ c * x :=\n    by rw [← one_add_mul, add_comm]; exact dvd_mul_of_dvd_left h1 x,\n  rw [← S0_p_dvd_add h (not_dvd_of_coprime (ne_of_gt h0) h2) h1, S0_two_pow_mul h, ← two_mul]\nend\n\n/-- Generally, if `p` is balanced, then the order of `2` mod `p` is even -/\nlemma even_order_two_mod_p_of_balanced (h0 : 1 < p) (h1 : balanced p) :\n  even (order_two_mod_p h) :=\nbegin\n  rw balanced_iff_S0_coprime_eq_const h h0 at h1,\n  replace h1 : 2 ∣ order_two_mod_p h * p := ⟨S0 h 1, (h1 1 (nat.coprime_one_left p)).symm⟩,\n  rwa [(two_coprime_p h).dvd_mul_right, ← even_iff_two_dvd] at h1\nend\n\nend general_results\n\n\n\nsection prime_results\n\n/-- Final solution, part 2, prime power version -/\ntheorem final_solution_part2' {p : ℕ} (h : odd p) (h0 : is_prime_pow p) :\n  balanced p ↔ even (order_two_mod_p h) :=\n⟨even_order_two_mod_p_of_balanced h h0.one_lt,\n  λ h1, balanced_of_neg_one_is_two_pow_mod_p h h0.one_lt\n    ((order_two_even_iff_prime_pow h h0).mp h1)⟩\n\nvariables {p : ℕ} (hp : p.prime)\ninclude hp\n\n/-- Final solution, part 2 -/\ntheorem final_solution_part2 (h : odd p) :\n  balanced p ↔ even (order_two_mod_p h) :=\n  final_solution_part2' h hp.is_prime_pow\n\n/-- If p is prime, p ≡ 3 or 5 (mod 8), then p is balanced -/\ntheorem balanced_3_or_5_mod_8 (h : p % 8 = 3 ∨ p % 8 = 5) : balanced p :=\nbegin\n  have h0 : p ≠ 2 := by contrapose! h; subst h; split; norm_num,\n  have h1 : odd p := (or_iff_right h0).mp hp.eq_two_or_odd',\n  refine balanced_of_neg_one_is_two_pow_mod_p h1 hp.one_lt ⟨p / 2, _⟩,\n  haveI : fact p.prime := ⟨hp⟩,\n  have h2 := h0,\n  rw [← nat.coprime_primes hp nat.prime_two, hp.coprime_iff_not_dvd,\n      ← char_p.cast_eq_zero_iff (zmod p), nat.cast_two, ← int.cast_two] at h2,\n  cases legendre_sym.eq_one_or_neg_one p h2 with h3 h3,\n  rw [legendre_sym.eq_one_iff p h2, int.cast_two, zmod.exists_sq_eq_two_iff h0] at h3,\n  exfalso; contrapose! h,\n  cases h3 with h3 h3; rw h3; norm_num,\n  rw [← char_p.cast_eq_zero_iff (zmod p), nat.cast_succ, add_eq_zero_iff_eq_neg,\n      nat.cast_pow, nat.cast_two, ← int.cast_two, ← legendre_sym.eq_pow, h3,\n      int.cast_neg, int.cast_one]\nend\n\n/-- If p is prime, p ≡ 7 (mod 8), then p is not balanced -/\ntheorem not_balanced_7_mod_8 (h : p % 8 = 7) : ¬balanced p :=\nbegin\n  have h0 : p ≠ 2 := by contrapose! h; subst h; norm_num,\n  have h1 : odd p := (or_iff_right h0).mp hp.eq_two_or_odd',\n  rw [final_solution_part2 hp h1, ← nat.odd_iff_not_even],\n  suffices : 2 ^ (p / 2) ≡ 1 [MOD p],\n  { rw two_pow_mod_p_eq_one_iff h1 at this,\n    cases this with c this,\n    refine @nat.odd.of_mul_left _ c _,\n    rw ← this; clear this c,\n    rw [← nat.div_add_mod p 8, h, bit0, ← two_mul, mul_assoc, add_comm,\n        nat.add_mul_div_left _ _ two_pos, nat.odd_add],\n    norm_num },\n\n  haveI : fact p.prime := ⟨hp⟩,\n  rw [← zmod.eq_iff_modeq_nat, nat.cast_one, nat.cast_pow, nat.cast_two,\n      ← zmod.euler_criterion, zmod.exists_sq_eq_two_iff h0],\n  right; exact h,\n  rwa [ne.def, ← nat.cast_two, char_p.cast_eq_zero_iff (zmod p) p,\n       ← hp.coprime_iff_not_dvd, nat.coprime_primes hp nat.prime_two]\nend\n\nend prime_results\n\n\n\n\n\n/-- There are infinitely many odd primes that are not balanced.\n  This is the original version of Part 2. -/\ntheorem infinite_set_of_odd_primes_not_balanced :\n  {p : ℕ | odd p ∧ p.prime ∧ ¬balanced p}.infinite :=\nbegin\n  have h : 7 < 8 := by norm_num,\n  have h0 : nat.coprime 7 8 := by norm_num,\n  refine set.infinite.mono _ (extra.infinite_set_of_primes_mod_eq h h0),\n  rintros p ⟨hp, h1⟩,\n  refine ⟨_, hp, not_balanced_7_mod_8 hp h1⟩,\n  refine (or_iff_right _).mp hp.eq_two_or_odd',\n  contrapose! h1; subst h1; norm_num\nend\n\n/-- There are also infinitely many odd primes that are balanced. -/\ntheorem infinite_set_of_odd_primes_balanced :\n  {p : ℕ | odd p ∧ p.prime ∧ balanced p}.infinite :=\nbegin\n  have h : 5 < 8 := by norm_num,\n  have h0 : nat.coprime 5 8 := by norm_num,\n  refine set.infinite.mono _ (extra.infinite_set_of_primes_mod_eq h h0),\n  rintros p ⟨hp, h1⟩,\n  refine ⟨_, hp, balanced_3_or_5_mod_8 hp (or.inr h1)⟩,\n  refine (or_iff_right _).mp hp.eq_two_or_odd',\n  contrapose! h1; subst h1; norm_num\nend\n\nend IMO2020N4\nend IMOSL\n", "meta": {"author": "mortarsanjaya", "repo": "imo-A-and-N", "sha": "645a924da7442f41d56ee6a0d96dc4d777b593a9", "save_path": "github-repos/lean/mortarsanjaya-imo-A-and-N", "path": "github-repos/lean/mortarsanjaya-imo-A-and-N/imo-A-and-N-645a924da7442f41d56ee6a0d96dc4d777b593a9/src/IMO2020/N4/N4_part2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.47224995706638345}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\nIntroduces the rational numbers as discrete, linear ordered field.\n-/\n\nimport\n  data.nat.gcd data.pnat data.int.sqrt data.equiv.encodable order.basic\n  algebra.ordered_field data.real.cau_seq\n\n/- rational numbers -/\n\n/-- `rat`, or `ℚ`, is the type of rational numbers. It is defined\n  as the set of pairs ⟨n, d⟩ of integers such that `d` is positive and `n` and\n  `d` are coprime. This representation is preferred to the quotient\n  because without periodic reduction, the numerator and denominator can grow\n  exponentially (for example, adding 1/2 to itself repeatedly). -/\nstructure rat := mk' ::\n(num : ℤ)\n(denom : ℕ)\n(pos : denom > 0)\n(cop : num.nat_abs.coprime denom)\nnotation `ℚ` := rat\n\nnamespace rat\n\nprotected def repr : ℚ → string\n| ⟨n, d, _, _⟩ := if d = 1 then _root_.repr n else\n  _root_.repr n ++ \"/\" ++ _root_.repr d\n\ninstance : has_repr ℚ := ⟨rat.repr⟩\ninstance : has_to_string ℚ := ⟨rat.repr⟩\nmeta instance : has_to_format ℚ := ⟨coe ∘ rat.repr⟩\n\ninstance : encodable ℚ := encodable.of_equiv (Σ n : ℤ, {d : ℕ // d > 0 ∧ n.nat_abs.coprime d})\n  ⟨λ ⟨a, b, c, d⟩, ⟨a, b, c, d⟩, λ⟨a, b, c, d⟩, ⟨a, b, c, d⟩,\n   λ ⟨a, b, c, d⟩, rfl, λ⟨a, b, c, d⟩, rfl⟩\n\n/-- Embed an integer as a rational number -/\ndef of_int (n : ℤ) : ℚ :=\n⟨n, 1, nat.one_pos, nat.coprime_one_right _⟩\n\ninstance : has_zero ℚ := ⟨of_int 0⟩\ninstance : has_one ℚ := ⟨of_int 1⟩\ninstance : inhabited ℚ := ⟨0⟩\n\n/-- Form the quotient `n / d` where `n:ℤ` and `d:ℕ+` (not necessarily coprime) -/\ndef mk_pnat (n : ℤ) : ℕ+ → ℚ | ⟨d, dpos⟩ :=\nlet n' := n.nat_abs, g := n'.gcd d in\n⟨n / g, d / g, begin\n  apply (nat.le_div_iff_mul_le _ _ (nat.gcd_pos_of_pos_right _ dpos)).2,\n  simp, exact nat.le_of_dvd dpos (nat.gcd_dvd_right _ _)\nend, begin\n  have : int.nat_abs (n / ↑g) = n' / g,\n  { cases int.nat_abs_eq n with e e; rw e, { refl },\n    rw [int.neg_div_of_dvd, int.nat_abs_neg], { refl },\n    exact int.coe_nat_dvd.2 (nat.gcd_dvd_left _ _) },\n  rw this,\n  exact nat.coprime_div_gcd_div_gcd (nat.gcd_pos_of_pos_right _ dpos)\nend⟩\n\n/-- Form the quotient `n / d` where `n:ℤ` and `d:ℕ`. In the case `d = 0`, we\n  define `n / 0 = 0` by convention. -/\ndef mk_nat (n : ℤ) (d : ℕ) : ℚ :=\nif d0 : d = 0 then 0 else mk_pnat n ⟨d, nat.pos_of_ne_zero d0⟩\n\n/-- Form the quotient `n / d` where `n d : ℤ`. -/\ndef mk : ℤ → ℤ → ℚ\n| n (int.of_nat d) := mk_nat n d\n| n -[1+ d]        := mk_pnat (-n) d.succ_pnat\n\nlocal infix ` /. `:70 := mk\n\ntheorem mk_pnat_eq (n d h) : mk_pnat n ⟨d, h⟩ = n /. d :=\nby change n /. d with dite _ _ _; simp [ne_of_gt h]\n\ntheorem mk_nat_eq (n d) : mk_nat n d = n /. d := rfl\n\n@[simp] theorem mk_zero (n) : n /. 0 = 0 := rfl\n\n@[simp] theorem zero_mk_pnat (n) : mk_pnat 0 n = 0 :=\nby cases n; simp [mk_pnat]; change int.nat_abs 0 with 0; simp *; refl\n\n@[simp] theorem zero_mk_nat (n) : mk_nat 0 n = 0 :=\nby by_cases n = 0; simp [*, mk_nat]\n\n@[simp] theorem zero_mk (n) : 0 /. n = 0 :=\nby cases n; simp [mk]\n\nprivate lemma gcd_abs_dvd_left {a b} : (nat.gcd (int.nat_abs a) b : ℤ) ∣ a :=\nint.dvd_nat_abs.1 $ int.coe_nat_dvd.2 $ nat.gcd_dvd_left (int.nat_abs a) b\n\n@[simp] theorem mk_eq_zero {a b : ℤ} (b0 : b ≠ 0) : a /. b = 0 ↔ a = 0 :=\nbegin\n  constructor; intro h; [skip, {subst a, simp}],\n  have : ∀ {a b}, mk_pnat a b = 0 → a = 0,\n  { intros a b e, cases b with b h,\n    injection e with e,\n    apply int.eq_mul_of_div_eq_right gcd_abs_dvd_left e },\n  cases b with b; simp [mk, mk_nat] at h,\n  { simp [mt (congr_arg int.of_nat) b0] at h,\n    exact this h },\n  { apply neg_inj, simp [this h] }\nend\n\ntheorem mk_eq : ∀ {a b c d : ℤ} (hb : b ≠ 0) (hd : d ≠ 0),\n  a /. b = c /. d ↔ a * d = c * b :=\nsuffices ∀ a b c d hb hd, mk_pnat a ⟨b, hb⟩ = mk_pnat c ⟨d, hd⟩ ↔ a * d = c * b,\nbegin\n  intros, cases b with b b; simp [mk, mk_nat, nat.succ_pnat],\n  simp [mt (congr_arg int.of_nat) hb],\n  all_goals {\n    cases d with d d; simp [mk, mk_nat, nat.succ_pnat],\n    simp [mt (congr_arg int.of_nat) hd],\n    all_goals { rw this, try {refl} } },\n  { change a * ↑(d.succ) = -c * ↑b ↔ a * -(d.succ) = c * b,\n    constructor; intro h; apply neg_inj; simpa [left_distrib, neg_add_eq_iff_eq_add,\n      eq_neg_iff_add_eq_zero, neg_eq_iff_add_eq_zero] using h },\n  { change -a * ↑d = c * b.succ ↔ a * d = c * -b.succ,\n    constructor; intro h; apply neg_inj; simpa [left_distrib, eq_comm] using h },\n  { change -a * d.succ = -c * b.succ ↔ a * -d.succ = c * -b.succ,\n    simp [left_distrib] }\nend,\nbegin\n  intros, simp [mk_pnat], constructor; intro h,\n  { cases h with ha hb,\n    have ha, {\n      have dv := @gcd_abs_dvd_left,\n      have := int.eq_mul_of_div_eq_right dv ha,\n      rw ← int.mul_div_assoc _ dv at this,\n      exact int.eq_mul_of_div_eq_left (dvd_mul_of_dvd_right dv _) this.symm },\n    have hb, {\n      have dv := λ {a b}, nat.gcd_dvd_right (int.nat_abs a) b,\n      have := nat.eq_mul_of_div_eq_right dv hb,\n      rw ← nat.mul_div_assoc _ dv at this,\n      exact nat.eq_mul_of_div_eq_left (dvd_mul_of_dvd_right dv _) this.symm },\n    have m0 : (a.nat_abs.gcd b * c.nat_abs.gcd d : ℤ) ≠ 0, {\n      refine int.coe_nat_ne_zero.2 (ne_of_gt _),\n      apply mul_pos; apply nat.gcd_pos_of_pos_right; assumption },\n    apply eq_of_mul_eq_mul_right m0,\n    simpa [mul_comm, mul_left_comm] using\n      congr (congr_arg (*) ha.symm) (congr_arg coe hb) },\n  { suffices : ∀ a c, a * d = c * b →\n      a / a.gcd b = c / c.gcd d ∧ b / a.gcd b = d / c.gcd d,\n    { cases this a.nat_abs c.nat_abs\n        (by simpa [int.nat_abs_mul] using congr_arg int.nat_abs h) with h₁ h₂,\n      have hs := congr_arg int.sign h,\n      simp [int.sign_eq_one_of_pos (int.coe_nat_lt.2 hb),\n            int.sign_eq_one_of_pos (int.coe_nat_lt.2 hd)] at hs,\n      conv in a { rw ← int.sign_mul_nat_abs a },\n      conv in c { rw ← int.sign_mul_nat_abs c },\n      rw [int.mul_div_assoc, int.mul_div_assoc],\n      exact ⟨congr (congr_arg (*) hs) (congr_arg coe h₁), h₂⟩,\n      all_goals { exact int.coe_nat_dvd.2 (nat.gcd_dvd_left _ _) } },\n    intros a c h,\n    suffices bd : b / a.gcd b = d / c.gcd d,\n    { refine ⟨_, bd⟩,\n      apply nat.eq_of_mul_eq_mul_left hb,\n      rw [← nat.mul_div_assoc _ (nat.gcd_dvd_left _ _), mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), bd,\n          ← nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), h, mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_left _ _)] },\n    suffices : ∀ {a c : ℕ} (b>0) (d>0),\n      a * d = c * b → b / a.gcd b ≤ d / c.gcd d,\n    { exact le_antisymm (this _ hb _ hd h) (this _ hd _ hb h.symm) },\n    intros a c b hb d hd h,\n    have gb0 := nat.gcd_pos_of_pos_right a hb,\n    have gd0 := nat.gcd_pos_of_pos_right c hd,\n    apply nat.le_of_dvd,\n    apply (nat.le_div_iff_mul_le _ _ gd0).2,\n    simp, apply nat.le_of_dvd hd (nat.gcd_dvd_right _ _),\n    apply (nat.coprime_div_gcd_div_gcd gb0).symm.dvd_of_dvd_mul_left,\n    refine ⟨c / c.gcd d, _⟩,\n    rw [← nat.mul_div_assoc _ (nat.gcd_dvd_left _ _),\n        ← nat.mul_div_assoc _ (nat.gcd_dvd_right _ _)],\n    apply congr_arg (/ c.gcd d),\n    rw [mul_comm, ← nat.mul_div_assoc _ (nat.gcd_dvd_left _ _),\n        mul_comm, h, nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), mul_comm] }\nend\n\n@[simp] theorem div_mk_div_cancel_left {a b c : ℤ} (c0 : c ≠ 0) :\n  (a * c) /. (b * c) = a /. b :=\nbegin\n  by_cases b0 : b = 0, { subst b0, simp },\n  apply (mk_eq (mul_ne_zero b0 c0) b0).2, simp [mul_comm, mul_assoc]\nend\n\ntheorem num_denom : ∀ a : ℚ, a = a.num /. a.denom\n| ⟨n, d, h, (c:_=1)⟩ := show _ = mk_nat n d,\n  by simp [mk_nat, ne_of_gt h, mk_pnat, c]\n\ntheorem num_denom' (n d h c) : (⟨n, d, h, c⟩ : ℚ) = n /. d := num_denom _\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on {C : ℚ → Sort u}\n   : ∀ (a : ℚ) (H : ∀ n d, d > 0 → (int.nat_abs n).coprime d → C (n /. d)), C a\n| ⟨n, d, h, c⟩ H := by rw num_denom'; exact H n d h c\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on' {C : ℚ → Sort u}\n   (a : ℚ) (H : ∀ (n:ℤ) (d:ℕ), d ≠ 0 → C (n /. d)) : C a :=\nnum_denom_cases_on a $ λ n d h c,\nH n d $ ne_of_gt h\n\ntheorem num_dvd (a) {b : ℤ} (b0 : b ≠ 0) : (a /. b).num ∣ a :=\nbegin\n  cases e : a /. b with n d h c,\n  rw [rat.num_denom', rat.mk_eq b0\n    (ne_of_gt (int.coe_nat_pos.2 h))] at e,\n  refine (int.nat_abs_dvd.1 $ int.dvd_nat_abs.1 $ int.coe_nat_dvd.2 $\n    c.dvd_of_dvd_mul_right _),\n  have := congr_arg int.nat_abs e,\n  simp [int.nat_abs_mul, int.nat_abs_of_nat] at this, simp [this]\nend\n\ntheorem denom_dvd (a b : ℤ) : ((a /. b).denom : ℤ) ∣ b :=\nbegin\n  by_cases b0 : b = 0, {simp [b0]},\n  cases e : a /. b with n d h c,\n  rw [num_denom', mk_eq b0 (ne_of_gt (int.coe_nat_pos.2 h))] at e,\n  refine (int.dvd_nat_abs.1 $ int.coe_nat_dvd.2 $ c.symm.dvd_of_dvd_mul_left _),\n  rw [← int.nat_abs_mul, ← int.coe_nat_dvd, int.dvd_nat_abs, ← e], simp\nend\n\nprotected def add : ℚ → ℚ → ℚ\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := mk_pnat (n₁ * d₂ + n₂ * d₁) ⟨d₁ * d₂, mul_pos h₁ h₂⟩\n\ninstance : has_add ℚ := ⟨rat.add⟩\n\ntheorem lift_binop_eq (f : ℚ → ℚ → ℚ) (f₁ : ℤ → ℤ → ℤ → ℤ → ℤ) (f₂ : ℤ → ℤ → ℤ → ℤ → ℤ)\n  (fv : ∀ {n₁ d₁ h₁ c₁ n₂ d₂ h₂ c₂},\n    f ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ = f₁ n₁ d₁ n₂ d₂ /. f₂ n₁ d₁ n₂ d₂)\n  (f0 : ∀ {n₁ d₁ n₂ d₂} (d₁0 : d₁ ≠ 0) (d₂0 : d₂ ≠ 0), f₂ n₁ d₁ n₂ d₂ ≠ 0)\n  (a b c d : ℤ) (b0 : b ≠ 0) (d0 : d ≠ 0)\n  (H : ∀ {n₁ d₁ n₂ d₂} (h₁ : a * d₁ = n₁ * b) (h₂ : c * d₂ = n₂ * d),\n       f₁ n₁ d₁ n₂ d₂ * f₂ a b c d = f₁ a b c d * f₂ n₁ d₁ n₂ d₂) :\n  f (a /. b) (c /. d) = f₁ a b c d /. f₂ a b c d :=\nbegin\n  generalize ha : a /. b = x, cases x with n₁ d₁ h₁ c₁, rw num_denom' at ha,\n  generalize hc : c /. d = x, cases x with n₂ d₂ h₂ c₂, rw num_denom' at hc,\n  rw fv,\n  have d₁0 := ne_of_gt (int.coe_nat_lt.2 h₁),\n  have d₂0 := ne_of_gt (int.coe_nat_lt.2 h₂),\n  exact (mk_eq (f0 d₁0 d₂0) (f0 b0 d0)).2 (H ((mk_eq b0 d₁0).1 ha) ((mk_eq d0 d₂0).1 hc))\nend\n\n@[simp] theorem add_def {a b c d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n  a /. b + c /. d = (a * d + c * b) /. (b * d) :=\nbegin\n  apply lift_binop_eq rat.add; intros; try {assumption},\n  { apply mk_pnat_eq },\n  { apply mul_ne_zero d₁0 d₂0 },\n  calc (n₁ * d₂ + n₂ * d₁) * (b * d) =\n          (n₁ * b) * d₂ * d + (n₂ * d) * (d₁ * b) : by simp [mul_add, mul_comm, mul_left_comm]\n    ... = (a * d₁) * d₂ * d + (c * d₂) * (d₁ * b) : by rw [h₁, h₂]\n    ... = (a * d + c * b) * (d₁ * d₂)             : by simp [mul_add, mul_comm, mul_left_comm]\nend\n\nprotected def neg : ℚ → ℚ\n| ⟨n, d, h, c⟩ := ⟨-n, d, h, by simp [c]⟩\n\ninstance : has_neg ℚ := ⟨rat.neg⟩\n\n@[simp] theorem neg_def {a b : ℤ} : -(a /. b) = -a /. b :=\nbegin\n  by_cases b0 :  b = 0, { subst b0, simp, refl },\n  generalize ha : a /. b = x, cases x with n₁ d₁ h₁ c₁, rw num_denom' at ha,\n  show rat.mk' _ _ _ _ = _, rw num_denom',\n  have d0 := ne_of_gt (int.coe_nat_lt.2 h₁),\n  apply (mk_eq d0 b0).2, have h₁ := (mk_eq b0 d0).1 ha,\n  simp only [neg_mul_eq_neg_mul_symm, congr_arg has_neg.neg h₁]\nend\n\nprotected def mul : ℚ → ℚ → ℚ\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := mk_pnat (n₁ * n₂) ⟨d₁ * d₂, mul_pos h₁ h₂⟩\n\ninstance : has_mul ℚ := ⟨rat.mul⟩\n\n@[simp] theorem mul_def {a b c d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n  (a /. b) * (c /. d) = (a * c) /. (b * d) :=\nbegin\n  apply lift_binop_eq rat.mul; intros; try {assumption},\n  { apply mk_pnat_eq },\n  { apply mul_ne_zero d₁0 d₂0 },\n  cc\nend\n\nprotected def inv : ℚ → ℚ\n| ⟨(n+1:ℕ), d, h, c⟩ := ⟨d, n+1, n.succ_pos, c.symm⟩\n| ⟨0, d, h, c⟩ := 0\n| ⟨-[1+ n], d, h, c⟩ := ⟨-d, n+1, n.succ_pos, nat.coprime.symm $ by simp; exact c⟩\n\ninstance : has_inv ℚ := ⟨rat.inv⟩\n\n@[simp] theorem inv_def {a b : ℤ} : (a /. b)⁻¹ = b /. a :=\nbegin\n  by_cases a0 : a = 0, { subst a0, simp, refl },\n  by_cases b0 : b = 0, { subst b0, simp, refl },\n  generalize ha : a /. b = x, cases x with n d h c, rw num_denom' at ha,\n  refine eq.trans (_ : rat.inv ⟨n, d, h, c⟩ = d /. n) _,\n  { cases n with n; [cases n with n, skip],\n    { refl },\n    { change int.of_nat n.succ with (n+1:ℕ),\n      unfold rat.inv, rw num_denom' },\n    { unfold rat.inv, rw num_denom', refl } },\n  have n0 : n ≠ 0,\n  { refine mt (λ (n0 : n = 0), _) a0,\n    subst n0, simp at ha,\n    exact (mk_eq_zero b0).1 ha },\n  have d0 := ne_of_gt (int.coe_nat_lt.2 h),\n  have ha := (mk_eq b0 d0).1 ha,\n  apply (mk_eq n0 a0).2,\n  cc\nend\n\nvariables (a b c : ℚ)\n\nprotected theorem add_zero : a + 0 = a :=\nnum_denom_cases_on' a $ λ n d h,\nby rw [← zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem zero_add : 0 + a = a :=\nnum_denom_cases_on' a $ λ n d h,\nby rw [← zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem add_comm : a + b = b + a :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nby simp [h₁, h₂, mul_comm]\n\nprotected theorem add_assoc : a + b + c = a + (b + c) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nnum_denom_cases_on' c $ λ n₃ d₃ h₃,\nby simp [h₁, h₂, h₃, mul_ne_zero, mul_add, mul_comm, mul_left_comm, add_left_comm]\n\nprotected theorem add_left_neg : -a + a = 0 :=\nnum_denom_cases_on' a $ λ n d h,\nby simp [h]\n\nprotected theorem mul_one : a * 1 = a :=\nnum_denom_cases_on' a $ λ n d h,\nby change (1:ℚ) with 1 /. 1; simp [h]\n\nprotected theorem one_mul : 1 * a = a :=\nnum_denom_cases_on' a $ λ n d h,\nby change (1:ℚ) with 1 /. 1; simp [h]\n\nprotected theorem mul_comm : a * b = b * a :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nby simp [h₁, h₂, mul_comm]\n\nprotected theorem mul_assoc : a * b * c = a * (b * c) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nnum_denom_cases_on' c $ λ n₃ d₃ h₃,\nby simp [h₁, h₂, h₃, mul_ne_zero, mul_comm, mul_left_comm]\n\nprotected theorem add_mul : (a + b) * c = a * c + b * c :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nnum_denom_cases_on' c $ λ n₃ d₃ h₃,\nby simp [h₁, h₂, h₃, mul_ne_zero];\n   refine (div_mk_div_cancel_left (int.coe_nat_ne_zero.2 h₃)).symm.trans _;\n   simp [mul_add, mul_comm, mul_assoc, mul_left_comm]\n\nprotected theorem mul_add : a * (b + c) = a * b + a * c :=\nby rw [rat.mul_comm, rat.add_mul, rat.mul_comm, rat.mul_comm c a]\n\nprotected theorem zero_ne_one : 0 ≠ (1:ℚ) :=\nmt (λ (h : 0 = 1 /. 1), (mk_eq_zero one_ne_zero).1 h.symm) one_ne_zero\n\nprotected theorem mul_inv_cancel : a ≠ 0 → a * a⁻¹ = 1 :=\nnum_denom_cases_on' a $ λ n d h a0,\nhave n0 : n ≠ 0, from mt (by intro e; subst e; simp) a0,\nby simp [h, n0, mul_comm]; exact\neq.trans (by simp) (@div_mk_div_cancel_left 1 1 _ n0)\n\nprotected theorem inv_mul_cancel (h : a ≠ 0) : a⁻¹ * a = 1 :=\neq.trans (rat.mul_comm _ _) (rat.mul_inv_cancel _ h)\n\ninstance : decidable_eq ℚ := by tactic.mk_dec_eq_instance\n\ninstance : discrete_field ℚ :=\n{ zero             := 0,\n  add              := rat.add,\n  neg              := rat.neg,\n  one              := 1,\n  mul              := rat.mul,\n  inv              := rat.inv,\n  zero_add         := rat.zero_add,\n  add_zero         := rat.add_zero,\n  add_comm         := rat.add_comm,\n  add_assoc        := rat.add_assoc,\n  add_left_neg     := rat.add_left_neg,\n  mul_one          := rat.mul_one,\n  one_mul          := rat.one_mul,\n  mul_comm         := rat.mul_comm,\n  mul_assoc        := rat.mul_assoc,\n  left_distrib     := rat.mul_add,\n  right_distrib    := rat.add_mul,\n  zero_ne_one      := rat.zero_ne_one,\n  mul_inv_cancel   := rat.mul_inv_cancel,\n  inv_mul_cancel   := rat.inv_mul_cancel,\n  has_decidable_eq := rat.decidable_eq,\n  inv_zero         := rfl }\n\n/- Extra instances to short-circuit type class resolution -/\ninstance : field ℚ              := by apply_instance\ninstance : division_ring ℚ      := by apply_instance\ninstance : integral_domain ℚ    := by apply_instance\n-- TODO(Mario): this instance slows down data.real.basic\n--instance : domain ℚ           := by apply_instance\ninstance : nonzero_comm_ring ℚ  := by apply_instance\ninstance : comm_ring ℚ          := by apply_instance\n--instance : ring ℚ             := by apply_instance\ninstance : comm_semiring ℚ      := by apply_instance\ninstance : semiring ℚ           := by apply_instance\ninstance : add_comm_group ℚ     := by apply_instance\ninstance : add_group ℚ          := by apply_instance\ninstance : add_comm_monoid ℚ    := by apply_instance\ninstance : add_monoid ℚ         := by apply_instance\ninstance : add_left_cancel_semigroup ℚ := by apply_instance\ninstance : add_right_cancel_semigroup ℚ := by apply_instance\ninstance : add_comm_semigroup ℚ := by apply_instance\ninstance : add_semigroup ℚ      := by apply_instance\ninstance : comm_monoid ℚ        := by apply_instance\ninstance : monoid ℚ             := by apply_instance\ninstance : comm_semigroup ℚ     := by apply_instance\ninstance : semigroup ℚ          := by apply_instance\n\ntheorem sub_def {a b c d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :\n  a /. b - c /. d = (a * d - c * b) /. (b * d) :=\nby simp [b0, d0]\n\nprotected def nonneg : ℚ → Prop\n| ⟨n, d, h, c⟩ := n ≥ 0\n\n@[simp] theorem mk_nonneg (a : ℤ) {b : ℤ} (h : b > 0) : (a /. b).nonneg ↔ a ≥ 0 :=\nbegin\n  generalize ha : a /. b = x, cases x with n₁ d₁ h₁ c₁, rw num_denom' at ha,\n  simp [rat.nonneg],\n  have d0 := int.coe_nat_lt.2 h₁,\n  have := (mk_eq (ne_of_gt h) (ne_of_gt d0)).1 ha,\n  constructor; intro h₂,\n  { apply nonneg_of_mul_nonneg_right _ d0,\n    rw this, exact mul_nonneg h₂ (le_of_lt h) },\n  { apply nonneg_of_mul_nonneg_right _ h,\n    rw ← this, exact mul_nonneg h₂ (int.coe_zero_le _) },\nend\n\nprotected def nonneg_add {a b} : rat.nonneg a → rat.nonneg b → rat.nonneg (a + b) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nbegin\n  have d₁0 : (d₁:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₁),\n  have d₂0 : (d₂:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₂),\n  simp [d₁0, d₂0, h₁, h₂, mul_pos d₁0 d₂0],\n  intros n₁0 n₂0,\n  apply add_nonneg; apply mul_nonneg; {assumption <|> apply int.coe_zero_le}\nend\n\nprotected def nonneg_mul {a b} : rat.nonneg a → rat.nonneg b → rat.nonneg (a * b) :=\nnum_denom_cases_on' a $ λ n₁ d₁ h₁,\nnum_denom_cases_on' b $ λ n₂ d₂ h₂,\nbegin\n  have d₁0 : (d₁:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₁),\n  have d₂0 : (d₂:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h₂),\n  simp [d₁0, d₂0, h₁, h₂, mul_pos d₁0 d₂0],\n  exact mul_nonneg\nend\n\nprotected def nonneg_antisymm {a} : rat.nonneg a → rat.nonneg (-a) → a = 0 :=\nnum_denom_cases_on' a $ λ n d h,\nbegin\n  have d0 : (d:ℤ) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h),\n  simp [d0, h],\n  exact λ h₁ h₂, le_antisymm (nonpos_of_neg_nonneg h₂) h₁\nend\n\nprotected def nonneg_total : rat.nonneg a ∨ rat.nonneg (-a) :=\nby cases a with n; exact\nor.imp_right neg_nonneg_of_nonpos (le_total 0 n)\n\ninstance decidable_nonneg : decidable (rat.nonneg a) :=\nby cases a; unfold rat.nonneg; apply_instance\n\nprotected def le (a b : ℚ) := rat.nonneg (b - a)\n\ninstance : has_le ℚ := ⟨rat.le⟩\n\ninstance decidable_le : decidable_rel ((≤) : ℚ → ℚ → Prop)\n| a b := show decidable (rat.nonneg (b - a)), by apply_instance\n\nprotected theorem le_def {a b c d : ℤ} (b0 : b > 0) (d0 : d > 0) :\n  a /. b ≤ c /. d ↔ a * d ≤ c * b :=\nshow rat.nonneg _ ↔ _,\nby simpa [ne_of_gt b0, ne_of_gt d0, mul_pos b0 d0, mul_comm]\n   using @sub_nonneg _ _ (b * c) (a * d)\n\nprotected theorem le_refl : a ≤ a :=\nshow rat.nonneg (a - a), by rw sub_self; exact le_refl (0 : ℤ)\n\nprotected theorem le_total : a ≤ b ∨ b ≤ a :=\nby have := rat.nonneg_total (b - a); rwa neg_sub at this\n\nprotected theorem le_antisymm {a b : ℚ} (hab : a ≤ b) (hba : b ≤ a) : a = b :=\nby have := eq_neg_of_add_eq_zero (rat.nonneg_antisymm hba $ by simpa);\n   rwa neg_neg at this\n\nprotected theorem le_trans {a b c : ℚ} (hab : a ≤ b) (hbc : b ≤ c) : a ≤ c :=\nhave rat.nonneg (b - a + (c - b)), from rat.nonneg_add hab hbc,\nby simpa\n\ninstance : decidable_linear_order ℚ :=\n{ le              := rat.le,\n  le_refl         := rat.le_refl,\n  le_trans        := @rat.le_trans,\n  le_antisymm     := @rat.le_antisymm,\n  le_total        := rat.le_total,\n  decidable_eq    := by apply_instance,\n  decidable_le    := assume a b, rat.decidable_nonneg (b - a) }\n\n/- Extra instances to short-circuit type class resolution -/\ninstance : has_lt ℚ                  := by apply_instance\ninstance : lattice.distrib_lattice ℚ := by apply_instance\ninstance : lattice.lattice ℚ         := by apply_instance\ninstance : lattice.semilattice_inf ℚ := by apply_instance\ninstance : lattice.semilattice_sup ℚ := by apply_instance\ninstance : lattice.has_inf ℚ         := by apply_instance\ninstance : lattice.has_sup ℚ         := by apply_instance\ninstance : linear_order ℚ            := by apply_instance\ninstance : partial_order ℚ           := by apply_instance\ninstance : preorder ℚ                := by apply_instance\n\ntheorem nonneg_iff_zero_le {a} : rat.nonneg a ↔ 0 ≤ a :=\nshow rat.nonneg a ↔ rat.nonneg (a - 0), by simp\n\ntheorem num_nonneg_iff_zero_le : ∀ {a : ℚ}, 0 ≤ a.num ↔ 0 ≤ a\n| ⟨n, d, h, c⟩ := @nonneg_iff_zero_le ⟨n, d, h, c⟩\n\ntheorem mk_le {a b c d : ℤ} (h₁ : b > 0) (h₂ : d > 0) :\n  a /. b ≤ c /. d ↔ a * d ≤ c * b :=\nby conv in (_ ≤ _) {\n  simp only [(≤), rat.le],\n  rw [sub_def (ne_of_gt h₂) (ne_of_gt h₁),\n      mk_nonneg _ (mul_pos h₂ h₁), ge, sub_nonneg] }\n\nprotected theorem add_le_add_left {a b c : ℚ} : c + a ≤ c + b ↔ a ≤ b :=\nby unfold has_le.le rat.le; rw add_sub_add_left_eq_sub\n\nprotected theorem mul_nonneg {a b : ℚ} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a * b :=\nby rw ← nonneg_iff_zero_le at ha hb ⊢; exact rat.nonneg_mul ha hb\n\ninstance : discrete_linear_ordered_field ℚ :=\n{ zero_lt_one     := dec_trivial,\n  add_le_add_left := assume a b ab c, rat.add_le_add_left.2 ab,\n  add_lt_add_left := assume a b ab c, lt_of_not_ge $ λ ba,\n    not_le_of_lt ab $ rat.add_le_add_left.1 ba,\n  mul_nonneg      := @rat.mul_nonneg,\n  mul_pos         := assume a b ha hb, lt_of_le_of_ne\n    (rat.mul_nonneg (le_of_lt ha) (le_of_lt hb))\n    (mul_ne_zero (ne_of_lt ha).symm (ne_of_lt hb).symm).symm,\n  ..rat.discrete_field, ..rat.decidable_linear_order }\n\n/- Extra instances to short-circuit type class resolution -/\ninstance : linear_ordered_field ℚ                := by apply_instance\ninstance : decidable_linear_ordered_comm_ring ℚ  := by apply_instance\ninstance : linear_ordered_comm_ring ℚ            := by apply_instance\ninstance : linear_ordered_ring ℚ                 := by apply_instance\ninstance : ordered_ring ℚ                        := by apply_instance\ninstance : decidable_linear_ordered_semiring ℚ   := by apply_instance\ninstance : linear_ordered_semiring ℚ             := by apply_instance\ninstance : ordered_semiring ℚ                    := by apply_instance\ninstance : decidable_linear_ordered_comm_group ℚ := by apply_instance\ninstance : ordered_comm_group ℚ                  := by apply_instance\ninstance : ordered_cancel_comm_monoid ℚ          := by apply_instance\ninstance : ordered_comm_monoid ℚ                 := by apply_instance\n\nattribute [irreducible] rat.le\n\ntheorem num_pos_iff_pos {a : ℚ} : 0 < a.num ↔ 0 < a :=\nlt_iff_lt_of_le_iff_le $\nby simpa [(by cases a; refl : (-a).num = -a.num)]\n   using @num_nonneg_iff_zero_le (-a)\n\ntheorem of_int_eq_mk (z : ℤ) : of_int z = z /. 1 := num_denom' _ _ _ _\n\ntheorem coe_int_eq_mk : ∀ z : ℤ, ↑z = z /. 1\n| (n : ℕ) := show (n:ℚ) = n /. 1,\n  by induction n with n IH n; simp [*, show (1:ℚ) = 1 /. 1, from rfl]\n| -[1+ n] := show (-(n + 1) : ℚ) = -[1+ n] /. 1, begin\n  induction n with n IH, {refl},\n  show -(n + 1 + 1 : ℚ) = -[1+ n.succ] /. 1,\n  rw [neg_add, IH],\n  simpa [show -1 = (-1) /. 1, from rfl]\nend\n\ntheorem coe_int_eq_of_int (z : ℤ) : ↑z = of_int z :=\n(coe_int_eq_mk z).trans (of_int_eq_mk z).symm\n\ntheorem mk_eq_div (n d : ℤ) : n /. d = (n / d : ℚ) :=\nbegin\n  by_cases d0 : d = 0, {simp [d0, div_zero]},\n  rw [division_def, coe_int_eq_mk, coe_int_eq_mk, inv_def,\n      mul_def one_ne_zero d0, one_mul, mul_one]\nend\n\n/-- `floor q` is the largest integer `z` such that `z ≤ q` -/\ndef floor : ℚ → ℤ\n| ⟨n, d, h, c⟩ := n / d\n\ntheorem le_floor {z : ℤ} : ∀ {r : ℚ}, z ≤ floor r ↔ (z : ℚ) ≤ r\n| ⟨n, d, h, c⟩ := begin\n  simp [floor],\n  rw [num_denom'],\n  have h' := int.coe_nat_lt.2 h,\n  conv { to_rhs,\n    rw [coe_int_eq_mk, mk_le zero_lt_one h', mul_one] },\n  exact int.le_div_iff_mul_le h'\nend\n\ntheorem floor_lt {r : ℚ} {z : ℤ} : floor r < z ↔ r < z :=\nlt_iff_lt_of_le_iff_le le_floor\n\ntheorem floor_le (r : ℚ) : (floor r : ℚ) ≤ r :=\nle_floor.1 (le_refl _)\n\ntheorem lt_succ_floor (r : ℚ) : r < (floor r).succ :=\nfloor_lt.1 $ int.lt_succ_self _\n\n@[simp] theorem floor_coe (z : ℤ) : floor z = z :=\neq_of_forall_le_iff $ λ a, by rw [le_floor, int.cast_le]\n\ntheorem floor_mono {a b : ℚ} (h : a ≤ b) : floor a ≤ floor b :=\nle_floor.2 (le_trans (floor_le _) h)\n\n@[simp] theorem floor_add_int (r : ℚ) (z : ℤ) : floor (r + z) = floor r + z :=\neq_of_forall_le_iff $ λ a, by rw [le_floor,\n  ← sub_le_iff_le_add, ← sub_le_iff_le_add, le_floor, int.cast_sub]\n\ntheorem floor_sub_int (r : ℚ) (z : ℤ) : floor (r - z) = floor r - z :=\neq.trans (by rw [int.cast_neg]; refl) (floor_add_int _ _)\n\n/-- `ceil q` is the smallest integer `z` such that `q ≤ z` -/\ndef ceil (r : ℚ) : ℤ :=\n-(floor (-r))\n\ntheorem ceil_le {z : ℤ} {r : ℚ} : ceil r ≤ z ↔ r ≤ z :=\nby rw [ceil, neg_le, le_floor, int.cast_neg, neg_le_neg_iff]\n\ntheorem le_ceil (r : ℚ) : r ≤ ceil r :=\nceil_le.1 (le_refl _)\n\n@[simp] theorem ceil_coe (z : ℤ) : ceil z = z :=\nby rw [ceil, ← int.cast_neg, floor_coe, neg_neg]\n\ntheorem ceil_mono {a b : ℚ} (h : a ≤ b) : ceil a ≤ ceil b :=\nceil_le.2 (le_trans h (le_ceil _))\n\n@[simp] theorem ceil_add_int (r : ℚ) (z : ℤ) : ceil (r + z) = ceil r + z :=\nby rw [ceil, neg_add', floor_sub_int, neg_sub, sub_eq_neg_add]; refl\n\ntheorem ceil_sub_int (r : ℚ) (z : ℤ) : ceil (r - z) = ceil r - z :=\neq.trans (by rw [int.cast_neg]; refl) (ceil_add_int _ _)\n\n/- cast (injection into fields) -/\n\nsection cast\nvariables {α : Type*}\n\nsection\nvariables [division_ring α]\n\n/-- Construct the canonical injection from `ℚ` into an arbitrary\n  division ring. If the field has positive characteristic `p`,\n  we define `1 / p = 1 / 0 = 0` for consistency with our\n  division by zero convention. -/\nprotected def cast : ℚ → α\n| ⟨n, d, h, c⟩ := n / d\n\n@[priority 0] instance cast_coe : has_coe ℚ α := ⟨rat.cast⟩\n\n@[simp] theorem cast_of_int (n : ℤ) : (of_int n : α) = n :=\nshow (n / (1:ℕ) : α) = n, by rw [nat.cast_one, div_one]\n\n@[simp] theorem cast_coe_int (n : ℤ) : ((n : ℚ) : α) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp] theorem coe_int_num (n : ℤ) : (n : ℚ).num = n :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_int_denom (n : ℤ) : (n : ℚ).denom = 1 :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_nat_num (n : ℕ) : (n : ℚ).num = n :=\nby rw [← int.cast_coe_nat, coe_int_num]\n\n@[simp] theorem coe_nat_denom (n : ℕ) : (n : ℚ).denom = 1 :=\nby rw [← int.cast_coe_nat, coe_int_denom]\n\n@[simp] theorem cast_coe_nat (n : ℕ) : ((n : ℚ) : α) = n := cast_coe_int n\n\n@[simp] theorem cast_zero : ((0 : ℚ) : α) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp] theorem cast_one : ((1 : ℚ) : α) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem mul_cast_comm (a : α) :\n  ∀ (n : ℚ), (n.denom : α) ≠ 0 → a * n = n * a\n| ⟨n, d, h, c⟩ h₂ := show a * (n * d⁻¹) = n * d⁻¹ * a,\n  by rw [← mul_assoc, int.mul_cast_comm, mul_assoc, mul_assoc,\n         ← show (d:α)⁻¹ * a = a * d⁻¹, from\n           division_ring.inv_comm_of_comm h₂ (int.mul_cast_comm a d).symm]\n\ntheorem cast_mk_of_ne_zero (a b : ℤ)\n  (b0 : (b:α) ≠ 0) : (a /. b : α) = a / b :=\nbegin\n  have b0' : b ≠ 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:α) ≠ 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:ℤ) ∣ b, by rwa e at dd) with k ke,\n    have : (b:α) = (d:α) * (k:α), {rw [ke, int.cast_mul], refl},\n    rw [d0, zero_mul] at this, contradiction },\n  rw [num_denom'] at e,\n  have := congr_arg (coe : ℤ → α) ((mk_eq b0' $ ne_of_gt $ int.coe_nat_pos.2 h).1 e),\n  rw [int.cast_mul, int.cast_mul, int.cast_coe_nat] at this,\n  symmetry, change (a * b⁻¹ : α) = n / d,\n  rw [eq_div_iff_mul_eq _ _ d0, mul_assoc, nat.mul_cast_comm,\n      ← mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\ntheorem cast_add_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m + n : ℚ) : α) = m + n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', add_def d₁0' d₂0'],\n  suffices : (n₁ * (d₂ * (d₂⁻¹ * d₁⁻¹)) +\n    n₂ * (d₁ * d₂⁻¹) * d₁⁻¹ : α) = n₁ * d₁⁻¹ + n₂ * d₂⁻¹,\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, left_distrib, right_distrib, mul_inv_eq,\n             d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0]} },\n  rw [← mul_assoc (d₂:α), mul_inv_cancel d₂0, one_mul,\n      ← nat.mul_cast_comm], simp [d₁0, mul_assoc]\nend\n\n@[simp] theorem cast_neg : ∀ n, ((-n : ℚ) : α) = -n\n| ⟨n, d, h, c⟩ := show (↑-n * d⁻¹ : α) = -(n * d⁻¹),\n  by rw [int.cast_neg, neg_mul_eq_neg_mul]\n\ntheorem cast_sub_of_ne_zero {m n : ℚ}\n  (m0 : (m.denom : α) ≠ 0) (n0 : (n.denom : α) ≠ 0) : ((m - n : ℚ) : α) = m - n :=\nhave ((-n).denom : α) ≠ 0, by cases n; exact n0,\nby simp [m0, this, cast_add_of_ne_zero]\n\ntheorem cast_mul_of_ne_zero : ∀ {m n : ℚ},\n  (m.denom : α) ≠ 0 → (n.denom : α) ≠ 0 → ((m * n : ℚ) : α) = m * n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := λ (d₁0 : (d₁:α) ≠ 0) (d₂0 : (d₂:α) ≠ 0), begin\n  have d₁0' : (d₁:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₁0; exact d₁0 rfl),\n  have d₂0' : (d₂:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d₂0; exact d₂0 rfl),\n  rw [num_denom', num_denom', mul_def d₁0' d₂0'],\n  suffices : (n₁ * ((n₂ * d₂⁻¹) * d₁⁻¹) : α) = n₁ * (d₁⁻¹ * (n₂ * d₂⁻¹)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_eq, d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0, mul_assoc] },\n    all_goals {simp [d₁0, d₂0, division_ring.mul_ne_zero d₁0 d₂0]} },\n  rw [division_ring.inv_comm_of_comm d₁0 (nat.mul_cast_comm _ _).symm]\nend\n\ntheorem cast_inv_of_ne_zero : ∀ {n : ℚ},\n  (n.num : α) ≠ 0 → (n.denom : α) ≠ 0 → ((n⁻¹ : ℚ) : α) = n⁻¹\n| ⟨n, d, h, c⟩ := λ (n0 : (n:α) ≠ 0) (d0 : (d:α) ≠ 0), begin\n  have n0' : (n:ℤ) ≠ 0 := λ e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:ℤ) ≠ 0 := int.coe_nat_ne_zero.2 (λ e, by rw e at d0; exact d0 rfl),\n  rw [num_denom', inv_def],\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, inv_div];\n  simp [n0, d0]\nend\n\ntheorem cast_div_of_ne_zero {m n : ℚ} (md : (m.denom : α) ≠ 0)\n  (nn : (n.num : α) ≠ 0) (nd : (n.denom : α) ≠ 0) : ((m / n : ℚ) : α) = m / n :=\nhave (n⁻¹.denom : ℤ) ∣ n.num,\nby conv in n⁻¹.denom { rw [num_denom n, inv_def] };\n   apply denom_dvd,\nhave (n⁻¹.denom : α) = 0 → (n.num : α) = 0, from\nλ h, let ⟨k, e⟩ := this in\n  by have := congr_arg (coe : ℤ → α) e;\n     rwa [int.cast_mul, int.cast_coe_nat, h, zero_mul] at this,\nby rw [division_def, cast_mul_of_ne_zero md (mt this nn), cast_inv_of_ne_zero nn nd, division_def]\n\n@[simp] theorem cast_inj [char_zero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n\n| ⟨n₁, d₁, h₁, c₁⟩ ⟨n₂, d₂, h₂, c₂⟩ := begin\n  refine ⟨λ h, _, congr_arg _⟩,\n  have d₁0 : d₁ ≠ 0 := ne_of_gt h₁,\n  have d₂0 : d₂ ≠ 0 := ne_of_gt h₂,\n  have d₁a : (d₁:α) ≠ 0 := nat.cast_ne_zero.2 d₁0,\n  have d₂a : (d₂:α) ≠ 0 := nat.cast_ne_zero.2 d₂0,\n  rw [num_denom', num_denom'] at h ⊢,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d₁0, d₂0] at h ⊢,\n  rwa [eq_div_iff_mul_eq _ _ d₂a, division_def, mul_assoc,\n    division_ring.inv_comm_of_comm d₁a (nat.mul_cast_comm _ _),\n    ← mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq _ _ d₁a, eq_comm,\n    ← int.cast_coe_nat, ← int.cast_mul, ← int.cast_coe_nat, ← int.cast_mul,\n    int.cast_inj, ← mk_eq (int.coe_nat_ne_zero.2 d₁0) (int.coe_nat_ne_zero.2 d₂0)] at h\nend\n\ntheorem cast_injective [char_zero α] : function.injective (coe : ℚ → α)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 :=\nby rw [← cast_zero, cast_inj]\n\n@[simp] theorem cast_ne_zero [char_zero α] {n : ℚ} : (n : α) ≠ 0 ↔ n ≠ 0 :=\nnot_congr cast_eq_zero\n\ntheorem eq_cast_of_ne_zero (f : ℚ → α) (H1 : f 1 = 1)\n  (Hadd : ∀ x y, f (x + y) = f x + f y)\n  (Hmul : ∀ x y, f (x * y) = f x * f y) :\n  ∀ n : ℚ, (n.denom : α) ≠ 0 → f n = n\n| ⟨n, d, h, c⟩ := λ (h₂ : ((d:ℤ):α) ≠ 0), show _ = (n / (d:ℤ) : α), begin\n  rw [num_denom', mk_eq_div, eq_div_iff_mul_eq _ _ h₂],\n  have : ∀ n : ℤ, f n = n, { apply int.eq_cast; simp [H1, Hadd] },\n  rw [← this, ← this, ← Hmul, div_mul_cancel],\n  exact int.cast_ne_zero.2 (int.coe_nat_ne_zero.2 $ ne_of_gt h),\nend\n\ntheorem eq_cast [char_zero α] (f : ℚ → α) (H1 : f 1 = 1)\n  (Hadd : ∀ x y, f (x + y) = f x + f y)\n  (Hmul : ∀ x y, f (x * y) = f x * f y) (n : ℚ) : f n = n :=\neq_cast_of_ne_zero _ H1 Hadd Hmul _ $\n  nat.cast_ne_zero.2 $ ne_of_gt n.pos\n\nend\n\ntheorem cast_mk [discrete_field α] [char_zero α] (a b : ℤ) : ((a /. b) : α) = a / b :=\nif b0 : b = 0 then by simp [b0, div_zero]\nelse cast_mk_of_ne_zero a b (int.cast_ne_zero.2 b0)\n\n@[simp] theorem cast_add [division_ring α] [char_zero α] (m n) : ((m + n : ℚ) : α) = m + n :=\ncast_add_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_sub [division_ring α] [char_zero α] (m n) : ((m - n : ℚ) : α) = m - n :=\ncast_sub_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_mul [division_ring α] [char_zero α] (m n) : ((m * n : ℚ) : α) = m * n :=\ncast_mul_of_ne_zero (nat.cast_ne_zero.2 $ ne_of_gt m.pos) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_inv [discrete_field α] [char_zero α] (n) : ((n⁻¹ : ℚ) : α) = n⁻¹ :=\nif n0 : n.num = 0 then\n  by simp [show n = 0, by rw [num_denom n, n0]; simp, inv_zero] else\ncast_inv_of_ne_zero (int.cast_ne_zero.2 n0) (nat.cast_ne_zero.2 $ ne_of_gt n.pos)\n\n@[simp] theorem cast_div [discrete_field α] [char_zero α] (m n) : ((m / n : ℚ) : α) = m / n :=\nby rw [division_def, cast_mul, cast_inv, division_def]\n\n@[simp] theorem cast_pow [discrete_field α] [char_zero α] (q) (k : ℕ) : ((q ^ k : ℚ) : α) = q ^ k :=\nby induction k; simp only [*, cast_one, cast_mul, pow_zero, pow_succ]\n\n@[simp] theorem cast_bit0 [division_ring α] [char_zero α] (n : ℚ) : ((bit0 n : ℚ) : α) = bit0 n := cast_add _ _\n\n@[simp] theorem cast_bit1 [division_ring α] [char_zero α] (n : ℚ) : ((bit1 n : ℚ) : α) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\n@[simp] theorem cast_nonneg [linear_ordered_field α] : ∀ {n : ℚ}, 0 ≤ (n : α) ↔ 0 ≤ n\n| ⟨n, d, h, c⟩ := show 0 ≤ (n * d⁻¹ : α) ↔ 0 ≤ (⟨n, d, h, c⟩ : ℚ),\n  by rw [num_denom', ← nonneg_iff_zero_le, mk_nonneg _ (int.coe_nat_pos.2 h),\n    mul_nonneg_iff_right_nonneg_of_pos (@inv_pos α _ _ (nat.cast_pos.2 h)),\n    int.cast_nonneg]\n\n@[simp] theorem cast_le [linear_ordered_field α] {m n : ℚ} : (m : α) ≤ n ↔ m ≤ n :=\nby rw [← sub_nonneg, ← cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp] theorem cast_lt [linear_ordered_field α] {m n : ℚ} : (m : α) < n ↔ m < n :=\nby simpa [-cast_le] using not_congr (@cast_le α _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field α] {n : ℚ} : (n : α) ≤ 0 ↔ n ≤ 0 :=\nby rw [← cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field α] {n : ℚ} : (0 : α) < n ↔ 0 < n :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field α] {n : ℚ} : (n : α) < 0 ↔ n < 0 :=\nby rw [← cast_zero, cast_lt]\n\n@[simp] theorem cast_id : ∀ n : ℚ, ↑n = n\n| ⟨n, d, h, c⟩ := show (n / (d : ℤ) : ℚ) = _, by rw [num_denom', mk_eq_div]\n\n@[simp] theorem cast_min [discrete_linear_ordered_field α] {a b : ℚ} : (↑(min a b) : α) = min a b :=\nby by_cases a ≤ b; simp [h, min]\n\n@[simp] theorem cast_max [discrete_linear_ordered_field α] {a b : ℚ} : (↑(max a b) : α) = max a b :=\nby by_cases a ≤ b; simp [h, max]\n\n@[simp] theorem cast_abs [discrete_linear_ordered_field α] {q : ℚ} : ((abs q : ℚ) : α) = abs q :=\nby simp [abs]\n\nend cast\n\n/- nat ceiling -/\n\n/-- `nat_ceil q` is the smallest nonnegative integer `n` with `q ≤ n`.\n  It is the same as `ceil q` when `q ≥ 0`, otherwise it is `0`. -/\ndef nat_ceil (q : ℚ) : ℕ := int.to_nat (ceil q)\n\ntheorem nat_ceil_le {q : ℚ} {n : ℕ} : nat_ceil q ≤ n ↔ q ≤ n :=\nby rw [nat_ceil, int.to_nat_le, ceil_le]; refl\n\ntheorem lt_nat_ceil {q : ℚ} {n : ℕ} : n < nat_ceil q ↔ (n : ℚ) < q :=\nnot_iff_not.1 $ by rw [not_lt, not_lt, nat_ceil_le]\n\ntheorem le_nat_ceil (q : ℚ) : q ≤ nat_ceil q :=\nnat_ceil_le.1 (le_refl _)\n\ntheorem nat_ceil_mono {q₁ q₂ : ℚ} (h : q₁ ≤ q₂) : nat_ceil q₁ ≤ nat_ceil q₂ :=\nnat_ceil_le.2 (le_trans h (le_nat_ceil _))\n\n@[simp] theorem nat_ceil_coe (n : ℕ) : nat_ceil n = n :=\nshow (ceil (n:ℤ)).to_nat = n, by rw [ceil_coe]; refl\n\n@[simp] theorem nat_ceil_zero : nat_ceil 0 = 0 := nat_ceil_coe 0\n\ntheorem nat_ceil_add_nat {q : ℚ} (hq : 0 ≤ q) (n : ℕ) : nat_ceil (q + n) = nat_ceil q + n :=\nshow int.to_nat (ceil (q + (n:ℤ))) = int.to_nat (ceil q) + n,\nby rw [ceil_add_int]; exact\nmatch ceil q, int.eq_coe_of_zero_le (ceil_mono hq) with\n| _, ⟨m, rfl⟩ := rfl\nend\n\ntheorem nat_ceil_lt_add_one {q : ℚ} (hq : q ≥ 0) : ↑(nat_ceil q) < q + 1 :=\nlt_nat_ceil.1 $ by rw [\n  show nat_ceil (q+1) = nat_ceil q+1, from nat_ceil_add_nat hq 1]; apply nat.lt_succ_self\n\n@[simp] lemma denom_neg_eq_denom : ∀ q : ℚ, (-q).denom = q.denom\n| ⟨_, d, _, _⟩ := rfl\n\n@[simp] lemma num_neg_eq_neg_num : ∀ q : ℚ, (-q).num = -(q.num)\n| ⟨n, _, _, _⟩ := rfl\n\n@[simp] lemma num_zero : rat.num 0 = 0 := rfl\n\nlemma zero_of_num_zero {q : ℚ} (hq : q.num = 0) : q = 0 :=\nhave q = q.num /. q.denom, from num_denom _,\nby simpa [hq]\n\nlemma zero_iff_num_zero {q : ℚ} : q = 0 ↔ q.num = 0 :=\n⟨λ _, by simp *, zero_of_num_zero⟩\n\nlemma num_ne_zero_of_ne_zero {q : ℚ} (h : q ≠ 0) : q.num ≠ 0 :=\nassume : q.num = 0,\nh $ zero_of_num_zero this\n\n@[simp] lemma num_one : (1 : ℚ).num = 1 := rfl\n\n@[simp] lemma denom_one : (1 : ℚ).denom = 1 := rfl\n\nlemma denom_ne_zero (q : ℚ) : q.denom ≠ 0 :=\nne_of_gt q.pos\n\nlemma mk_num_ne_zero_of_ne_zero {q : ℚ} {n d : ℤ} (hq : q ≠ 0) (hqnd : q = n /. d) : n ≠ 0 :=\nassume : n = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_denom_ne_zero_of_ne_zero {q : ℚ} {n d : ℤ} (hq : q ≠ 0) (hqnd : q = n /. d) : d ≠ 0 :=\nassume : d = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_ne_zero_of_ne_zero {n d : ℤ} (h : n ≠ 0) (hd : d ≠ 0) : n /. d ≠ 0 :=\nassume : n /. d = 0,\nh $ (mk_eq_zero hd).1 this\n\nlemma mul_num_denom (q r : ℚ) : q * r = (q.num * r.num) /. ↑(q.denom * r.denom) :=\nhave hq' : (↑q.denom : ℤ) ≠ 0, by have := denom_ne_zero q; simpa,\nhave hr' : (↑r.denom : ℤ) ≠ 0, by have := denom_ne_zero r; simpa,\nsuffices (q.num /. ↑q.denom) * (r.num /. ↑r.denom) = (q.num * r.num) /. ↑(q.denom * r.denom),\n  by rwa [←num_denom q, ←num_denom r] at this,\nby simp [mul_def hq' hr']\n\nlemma div_num_denom (q r : ℚ) : q / r = (q.num * r.denom) /. (q.denom * r.num) :=\nif hr : r.num = 0 then\n  have hr' : r = 0, from zero_of_num_zero hr,\n  by simp *\nelse calc q / r = q * r⁻¹ : div_eq_mul_inv\n            ... = (q.num /. q.denom) * (r.num /. r.denom)⁻¹ : by rw [←num_denom q, ←num_denom r]\n            ... = (q.num /. q.denom) * (r.denom /. r.num) : by rw inv_def\n            ... = (q.num * r.denom) /. (q.denom * r.num) : mul_def (by simpa using denom_ne_zero q) hr\n\nlemma num_denom_mk {q : ℚ} {n d : ℤ} (hn : n ≠ 0) (hd : d ≠ 0) (qdf : q = n /. d) :\n      ∃ c : ℤ, n = c * q.num ∧ d = c * q.denom :=\nhave hq : q ≠ 0, from\n  assume : q = 0,\n  hn $ (rat.mk_eq_zero hd).1 (by cc),\nhave q.num /. q.denom = n /. d, by rwa [←rat.num_denom q],\nhave q.num * d = n * ↑(q.denom), from (rat.mk_eq (by simp [rat.denom_ne_zero]) hd).1 this,\nbegin\n  existsi n / q.num,\n  have hqdn : q.num ∣ n, begin rw qdf, apply rat.num_dvd, assumption end,\n  split,\n    { rw int.div_mul_cancel hqdn },\n    { apply int.eq_mul_div_of_mul_eq_mul_of_dvd_left,\n      {apply rat.num_ne_zero_of_ne_zero hq},\n      {simp [rat.denom_ne_zero]},\n      repeat {assumption} }\nend\n\ntheorem mk_pnat_num (n : ℤ) (d : ℕ+) :\n  (mk_pnat n d).num = n / nat.gcd n.nat_abs d :=\nby cases d; refl\n\ntheorem mk_pnat_denom (n : ℤ) (d : ℕ+) :\n  (mk_pnat n d).denom = d / nat.gcd n.nat_abs d :=\nby cases d; refl\n\ntheorem mul_num (q₁ q₂ : ℚ) : (q₁ * q₂).num =\n  (q₁.num * q₂.num) / nat.gcd (q₁.num * q₂.num).nat_abs (q₁.denom * q₂.denom) :=\nby cases q₁; cases q₂; refl\n\ntheorem mul_denom (q₁ q₂ : ℚ) : (q₁ * q₂).denom =\n  (q₁.denom * q₂.denom) / nat.gcd (q₁.num * q₂.num).nat_abs (q₁.denom * q₂.denom) :=\nby cases q₁; cases q₂; refl\n\ntheorem mul_self_num (q : ℚ) : (q * q).num = q.num * q.num :=\nby rw [mul_num, int.nat_abs_mul, nat.coprime.gcd_eq_one, int.coe_nat_one, int.div_one];\nexact (q.cop.mul_right q.cop).mul (q.cop.mul_right q.cop)\n\ntheorem mul_self_denom (q : ℚ) : (q * q).denom = q.denom * q.denom :=\nby rw [rat.mul_denom, int.nat_abs_mul, nat.coprime.gcd_eq_one, nat.div_one];\nexact (q.cop.mul_right q.cop).mul (q.cop.mul_right q.cop)\n\ntheorem abs_def (q : ℚ) : abs q = q.num.nat_abs /. q.denom :=\nbegin\n  have hz : (0:ℚ) = 0 /. 1 := rfl,\n  cases le_total q 0 with hq hq,\n  { rw [abs_of_nonpos hq],\n    rw [num_denom q, hz, rat.le_def (int.coe_nat_pos.2 q.pos) zero_lt_one,\n        mul_one, zero_mul] at hq,\n    rw [int.of_nat_nat_abs_of_nonpos hq, ← neg_def, ← num_denom q] },\n  { rw [abs_of_nonneg hq],\n    rw [num_denom q, hz, rat.le_def zero_lt_one (int.coe_nat_pos.2 q.pos),\n        mul_one, zero_mul] at hq,\n    rw [int.nat_abs_of_nonneg hq, ← num_denom q] }\nend\n\nlemma add_num_denom (q r : ℚ) : q + r =\n  ((q.num * r.denom + q.denom * r.num : ℤ)) /. (↑q.denom * ↑r.denom : ℤ) :=\nhave hqd : (q.denom : ℤ) ≠ 0, from int.coe_nat_ne_zero_iff_pos.2 q.3,\nhave hrd : (r.denom : ℤ) ≠ 0, from int.coe_nat_ne_zero_iff_pos.2 r.3,\nby conv { to_lhs, rw [rat.num_denom q, rat.num_denom r, rat.add_def hqd hrd] };\n  simp [mul_comm]\n\ndef sqrt (q : ℚ) : ℚ :=\nrat.mk (int.sqrt q.num) (nat.sqrt q.denom)\n\ntheorem sqrt_eq (q : ℚ) : rat.sqrt (q*q) = abs q :=\nby rw [sqrt, mul_self_num, mul_self_denom,\n       int.sqrt_eq, nat.sqrt_eq, abs_def]\n\ntheorem exists_mul_self (x : ℚ) :\n  (∃ q, q * q = x) ↔ rat.sqrt x * rat.sqrt x = x :=\n⟨λ ⟨n, hn⟩, by rw [← hn, sqrt_eq, abs_mul_abs_self],\nλ h, ⟨rat.sqrt x, h⟩⟩\n\ntheorem sqrt_nonneg (q : ℚ) : 0 ≤ rat.sqrt q :=\nnonneg_iff_zero_le.1 $ (mk_nonneg _ $ int.coe_nat_pos.2 $\nnat.pos_of_ne_zero $ λ H, nat.pos_iff_ne_zero.1 q.pos $ nat.sqrt_eq_zero.1 H).2 trivial\n\nend rat\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/data/rat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.737158174177441, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4722499570663834}}
{"text": "/- THE CUBE CATEGORY ON fiITE SETS -/\nimport .cubes .fi\n\nopen cmonad fi nat\n\nuniverses u v\n\ndef cfi (n : ℕ) := cmonad (fi n)\n\n/- Projecting at the i-th dimension -/\n-- TODO generalize this to arbitrary elementary surjections?\ndef cproj (b : bool) : Π {m}, fi (m + 1) → cmor (fi (m + 1)) (fi m)\n| m       fi.zero fi.zero := b\n| (m + 1) fi.zero (suc j) := dim j\n| (m + 1) (suc i) fi.zero := dim fi.zero\n| (m + 1) (suc i) (suc j) := do x <- cproj i j,\n                                dim $ suc x\n\n--TODO simplify this\ntheorem cproj_self (b : bool) {m} (i : fi (m + 1)) : cproj b i i = b :=\nbegin\n  cases i with n n i,\n  { cases m, repeat {reflexivity} },\n  { induction i with n n i ih_i, simp[cproj], \n    { cases n, repeat {simp[cproj], rw cbind_bool} },\n    { simp[cproj], rw [ih_i, cbind_bool] } }\nend\n\ndef cdeg {m} (i : fi (m + 1)) : cmor (fi m) (fi (m + 1)) := dim ∘ deg i\n\ntheorem cproj_cdeg {m} {b : bool} (i : fi (m + 1)) : cproj b i ∘c cdeg i = dim :=\nbegin\n  apply funext, intro j, change (_ ∘c dim) _ = _, rw cid_right,\n  cases i with n n i,\n  { induction j, reflexivity, reflexivity },\n  { induction j with n n j ih_j, reflexivity, \n    simp[deg, cproj], cases i, \n    { cases j, reflexivity, reflexivity },\n    { rw ih_j, reflexivity } }\nend\n\n/- Lift a cubical morphism by 1 -/\n-- TODO generalize this\ndef clift {n k} (f : cmor (fi n) (fi k)) : cmor (fi (succ n)) (fi (succ k))\n| fi.zero := dim fi.zero\n| (suc i) := do x <- f i,\n                dim $ suc x\n\ntheorem clift_suc {n k} (f : cmor (fi n) (fi k)) (i : fi n) :\n    clift f (suc i) = (f i >>= (dim ∘ suc)) :=\nby reflexivity\n\ntheorem clift_dim {n : ℕ} : clift (@dim (fi n)) = dim :=\nbegin\n  apply funext, intro i, cases i, repeat {reflexivity},\nend\n\ntheorem clift_ccomp {m n o : ℕ} (f : cmor (fi m) (fi n)) (g : cmor (fi n) (fi o)) :\n  clift (g ∘c f) = (clift g) ∘c (clift f) :=\nbegin\n  apply funext, intro i, cases i with n n i, reflexivity,\n  simp[clift,ccomp], cases (f i) with j, reflexivity, reflexivity,\n  change (g j >>= _) = clift _ _, rw clift_suc,\nend\n\n--TODO generalize to arbitrary projections\ntheorem cproj_clift {m n : ℕ} (f : cmor (fi m) (fi n)) (b : bool) :\n  (cproj b fi.zero) ∘c (clift f) = f ∘c (cproj b fi.zero) :=\nbegin\n  apply funext, intro i, cases i with n n i,\n  simp[ccomp, clift], rw [cproj_self, cbind_bool, cbind_dim, cproj_self],\n  { cases m, simp[ccomp], cases i,\n    simp[ccomp, cproj, clift], rw [cbind_dim, cbind_assoc], \n    cases f i with j, reflexivity, reflexivity, rw cbind_dim, rw cbind_dim, \n    cases n, cases j, reflexivity }\nend\n\ndef zero_deg {m : ℕ} : cmor (fi 0) (fi m) := λ i, match i with\n                                                  end\n\ntheorem zero_deg_right {m n : ℕ} (f : cmor (fi m) (fi n)) :\n  f ∘c zero_deg = zero_deg :=\nbegin\n  apply funext, intro i, cases i\nend", "meta": {"author": "javra", "repo": "cubes", "sha": "734bdf71b9086b0ba9ef7dba3ede0c71f10872cc", "save_path": "github-repos/lean/javra-cubes", "path": "github-repos/lean/javra-cubes/cubes-734bdf71b9086b0ba9ef7dba3ede0c71f10872cc/cubes_fin.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4722499523847728}}
{"text": "import tactic.basic\nimport tactic.omega\nimport tactic.tauto\nimport .ch11_imp\n\n/-\nLtac inv H := inversion H; subst; clear H.\n\nTheorem ceval_deterministic: ∀c st st1 st2,\n    st =[ c ]⇒ st1 →\n    st =[ c ]⇒ st2 →\n    st1 = st2.\nProof.\n  intros c st st1 st2 E1 E2;\n  generalize dependent st2;\n  induction E1; intros st2 E2; inv E2.\n  - (* E_Skip *) reflexivity.\n  - (* E_Ass *) reflexivity.\n  - (* E_Seq *)\n    assert (st' = st'0) as EQ1.\n    { (* Proof of assertion *) apply IHE1_1; apply H1. }\n    subst st'0.\n    apply IHE1_2. assumption.\n  (* E_IfTrue *)\n  - (* b evaluates to true *)\n    apply IHE1. assumption.\n  - (* b evaluates to false (contradiction) *)\n    rewrite H in H5. inversion H5.\n  (* E_IfFalse *)\n  - (* b evaluates to true (contradiction) *)\n    rewrite H in H5. inversion H5.\n  - (* b evaluates to false *)\n    apply IHE1. assumption.\n  (* E_WhileFalse *)\n  - (* b evaluates to false *)\n    reflexivity.\n  - (* b evaluates to true (contradiction) *)\n    rewrite H in H2. inversion H2.\n  (* E_WhileTrue *)\n  - (* b evaluates to false (contradiction) *)\n    rewrite H in H4. inversion H4.\n  - (* b evaluates to true *)\n    assert (st' = st'0) as EQ1.\n    { (* Proof of assertion *) apply IHE1_1; assumption. }\n    subst st'0.\n    apply IHE1_2. assumption. Qed.\n-/\n\n-- namespace tactic\n-- open native\n\n-- meta def names : list expr → tactic (list name) :=\n-- λes, match es with\n-- | [] := do pure []\n-- | e::es := do\n--   es' ← names es,\n--   pure $ e.local_pp_name::es'\n-- end\n\n-- meta def inv (h : name) (ns : list name := []): tactic unit := do\n--   h' ← get_local h,\n--   rs ← cases h',\n--   try $ clear_lst [h],\n--   subst_vars,\n--   g ← get_goals,\n--   -- supporting naming\n--   try $ (list.zip g rs).mmap'(λr, do\n--     -- trace r,\n--     let ⟨g, n, e⟩ := r,\n--     n' ← names e,\n--     rename_many (rb_map.of_list $ n'.zip ns)\n--     -- trace r\n--     -- try $ with_enable_tags $ set_main_tag [n]\n--   )\n\n-- end tactic\n\nopen interactive interactive.types lean.parser tactic\n\nnamespace tactic.interactive\n\nmeta def inv (h : parse ident) (w : parse with_ident_list): tactic unit :=\n  propagate_tags $ do\n  h' ← get_local h,\n  rs ← cases (none, pexpr.of_expr h') w,\n  try $ propagate_tags $ do\n  clear_lst [h],\n  subst_vars\n  -- g ← get_goals,\n  -- -- supporting naming\n  -- try $ (list.zip g rs).mmap'(λr, do\n  --   -- trace r,\n  --   let ⟨g, n, e⟩ := r,\n  --   n' ← names e,\n  --   rename_many (rb_map.of_list $ n'.zip ns)\n  --   -- trace r\n  --   -- try $ with_enable_tags $ set_main_tag [n]\n  -- )\n\nend tactic.interactive\n\nopen imp imp.ceval\n\n/-\ninductive ceval : com → state → state → Prop\n| E_Skip : ∀st, ceval SKIP st st\n| E_Ass : ∀{st a₁ n} x,\n  aeval st a₁ = n →\n  ceval (x ::= a₁) st (x !→ n ; st)\n| E_Seq : ∀{c₁ c₂ st st' st''},\n  ceval c₁ st st' →\n  ceval c₂ st' st'' →\n  ceval (c₁ ;; c₂) st st''\n| E_IfTrue : ∀{st st' b c₁} c₂,\n  beval st b = tt →\n  ceval c₁ st st' →\n  ceval (TEST b THEN c₁ ELSE c₂ FI) st st'\n| E_IfFalse : ∀{st st' b} c₁ {c₂},\n  beval st b = ff →\n  ceval c₂ st st' →\n  ceval (TEST b THEN c₁ ELSE c₂ FI) st st'\n| E_WhileFalse : ∀{b st} c,\n  beval st b = ff →\n  ceval (WHILE b DO c END) st st\n| E_WhileTrue : ∀{st st' st'' b c},\n  beval st b = tt →\n  ceval c st st' →\n  ceval (WHILE b DO c END) st' st'' →\n  ceval (WHILE b DO c END) st st''\n\n-/\n\n/- it's horrible (like the coq version) -/\n/-\nTODO  i could make it less so with names since i improved the tactic\n-/\ntheorem ceval_deterministic {c st st₁ st₂}\n  (h₁ : st =[ c ]⇒ st₁) (h₂ : st =[ c ]⇒ st₂)\n  : st₁ = st₂ :=\nbegin\n  induction h₁ generalizing st₂; inv h₂,\n  case E_Ass { refl, },\n  case E_Seq {\n    cases h₁_ih_a h₂_a,\n    exact h₁_ih_a_1 h₂_a_1,\n  },\n  case E_IfTrue E_IfTrue { exact h₁_ih h₂_a_1, },\n  case E_IfTrue E_IfFalse {\n    rw h₁_a at h₂_a,\n    contradiction,\n  },\n  case E_IfFalse E_IfTrue {\n    rw h₁_a at h₂_a,\n    contradiction,\n  },\n  case E_IfFalse E_IfFalse { exact h₁_ih h₂_a_1, },\n  case E_WhileFalse E_WhileTrue {\n    rw h₁_a at h₂_a,\n    contradiction,\n  },\n  case E_WhileTrue E_WhileFalse {\n    rw h₁_a at h₂_a,\n    contradiction,\n  },\n  case E_WhileTrue E_WhileTrue {\n    cases h₁_ih_a h₂_a_1,\n    exact h₁_ih_a_1 h₂_a_2,\n  },\nend\n\n/-\nExample auto_example_1 : ∀(P Q R: Prop),\n  (P → Q) → (Q → R) → P → R.\nProof.\n  intros P Q R H1 H2 H3.\n  apply H2. apply H1. assumption.\nQed.\n-/\n\nexample {P Q R : Prop} (hpq : P → Q) (hqr : Q → R) (hp : P) : R :=\nbegin\n  apply hqr,\n  apply hpq,\n  exact hp,\nend\n\n/-\nExample auto_example_1' : ∀(P Q R: Prop),\n  (P → Q) → (Q → R) → P → R.\nProof.\n  auto.\nQed.\n-/\n\nexample (P Q R : Prop) : (P → Q) → (Q → R) → P → R := by tauto\n\n/-\nExample auto_example_2 : ∀P Q R S T U : Prop,\n  (P → Q) →\n  (P → R) →\n  (T → R) →\n  (S → T → U) →\n  ((P→Q) → (P→S)) →\n  T →\n  P →\n  U.\nProof. auto. Qed.\n-/\n\n/- tauto is not good -/\nexample (P Q R S T U : Prop) :\n  (P → Q) →\n  (P → R) →\n  (T → R) →\n  (S → T → U) →\n  ((P → Q) → (P → S)) →\n  T →\n  P →\n  U := by\nbegin\n  intros,\n  apply a_3; tauto,\nend\n\n/- cc destroys this though -/\nexample (P Q R S T U : Prop) :\n  (P → Q) →\n  (P → R) →\n  (T → R) →\n  (S → T → U) →\n  ((P → Q) → (P → S)) →\n  T →\n  P →\n  U := by cc\n\n/-\nExample auto_example_3 : ∀(P Q R S T U: Prop),\n  (P → Q) →\n  (Q → R) →\n  (R → S) →\n  (S → T) →\n  (T → U) →\n  P →\n  U.\nProof.\n  (* When it cannot solve the goal, auto does nothing *)\n  auto.\n  (* Optional argument says how deep to search (default is 5) *)\n  auto 6.\nQed.\n-/\n\n/- no depth limit -/\n/- tauto is kind of terrible -/\nexample (P Q R S T U : Prop) :\n  (P → Q) →\n  (Q → R) →\n  (R → S) →\n  (S → T) →\n  (T → U) →\n  P →\n  U :=\nbegin\n  intros,\n  apply a_4,\n  apply a_3,\n  apply a_2,\n  tauto,\nend\n\n/- again, cc ftw -/\nexample (P Q R S T U : Prop) :\n  (P → Q) →\n  (Q → R) →\n  (R → S) →\n  (S → T) →\n  (T → U) →\n  P →\n  U := by cc\n\n/-\nExample auto_example_4 : ∀P Q R : Prop,\n  Q →\n  (Q → R) →\n  P ∨ (Q ∧ R).\nProof. auto. Qed.\n-/\n\n/- tauto failed here too -/\nexample (P Q R : Prop) : Q → (Q → R) → P ∨ (Q ∧ R) := by cc\n\n/-\nLemma le_antisym : ∀n m: nat, (n ≤ m ∧ m ≤ n) → n = m.\nProof. intros. omega. Qed.\n\nExample auto_example_6 : ∀n m p : nat,\n  (n ≤ p → (n ≤ m ∧ m ≤ n)) →\n  n ≤ p →\n  n = m.\nProof.\n  intros.\n  auto using le_antisym.\nQed.\n-/\n\nlemma le_antisym {n m : ℕ} (h : n ≤ m ∧ m ≤ n) : n = m := by finish\n\n/- maybe not the best idea, but tauto can pick this up -/\n-- local attribute [refl] le_antisym\n\n/-\nhint is dope\n-/\n\n/- le_antisym not needed -/\nexample (n m p : ℕ) :\n  (n ≤ p → n ≤ m ∧ m ≤ n) →\n  n ≤ p →\n  n = m := by finish using [le_antisym] {classical := ff}\n\n/-\nHint Resolve T.\n\nHint Constructors c.\n\nHint Unfold d.\n-/\n\n/-\nseems like attribute refl or simp handles that\n-/\n\n/-\nHint Resolve le_antisym.\n\nExample auto_example_6' : ∀n m p : nat,\n  (n≤ p → (n ≤ m ∧ m ≤ n)) →\n  n ≤ p →\n  n = m.\nProof.\n  intros.\n  auto. (* picks up hint from database *)\nQed.\n\nDefinition is_fortytwo x := (x = 42).\n\nExample auto_example_7: ∀x,\n  (x ≤ 42 ∧ 42 ≤ x) → is_fortytwo x.\nProof.\n  auto. (* does nothing *)\nAbort.\n\nHint Unfold is_fortytwo.\n\nExample auto_example_7' : ∀x,\n  (x ≤ 42 ∧ 42 ≤ x) → is_fortytwo x.\nProof. auto. Qed.\n-/\n\n/- clarify and safe work too -/\n/- iversions don't use classical -/\n\n/- hint was never needed -/\nexample (n m p : ℕ) :\n  (n ≤ p → n ≤ m ∧ m ≤ n) →\n  n ≤ p →\n  n = m := by ifinish\n\ndef is_fortytwo (x) := x = 42\n\n-- example (x) : (x ≤ 42 ∧ 42 ≤ x) → is_fortytwo x := by isafe,\n\nexample (x) : (x ≤ 42 ∧ 42 ≤ x) → is_fortytwo x := by isafe using is_fortytwo\n\nlocal attribute [simp] is_fortytwo\n\nexample (x) : (x ≤ 42 ∧ 42 ≤ x) → is_fortytwo x := by finish\n\n/-\nTheorem ceval_deterministic': ∀c st st1 st2,\n    st =[ c ]⇒ st1 →\n    st =[ c ]⇒ st2 →\n    st1 = st2.\nProof.\n  intros c st st1 st2 E1 E2.\n  generalize dependent st2;\n       induction E1; intros st2 E2; inv E2; auto.\n  - (* E_Seq *)\n    assert (st' = st'0) as EQ1 by auto.\n    subst st'0.\n    auto.\n  - (* E_IfTrue *)\n    + (* b evaluates to false (contradiction) *)\n      rewrite H in H5. inversion H5.\n  - (* E_IfFalse *)\n    + (* b evaluates to true (contradiction) *)\n      rewrite H in H5. inversion H5.\n  - (* E_WhileFalse *)\n    + (* b evaluates to true (contradiction) *)\n      rewrite H in H2. inversion H2.\n  (* E_WhileTrue *)\n  - (* b evaluates to false (contradiction) *)\n    rewrite H in H4. inversion H4.\n  - (* b evaluates to true *)\n    assert (st' = st'0) as EQ1 by auto.\n    subst st'0.\n    auto.\nQed.\n-/\n\ntheorem ceval_deterministic' {c st st₁ st₂}\n  (h₁ : st =[ c ]⇒ st₁) (h₂ : st =[ c ]⇒ st₂)\n  : st₁ = st₂ :=\nbegin\n  induction h₁ generalizing st₂; inv h₂; try { ifinish },\n  /- E_ASS -/ { tauto, },\n  /- E_SEQ -/ {\n    have : h₁_st' = h₂_st', tauto,\n    ifinish,\n  },\n  /- E_WHILE_TRUE E_WHILE_TRUE -/ {\n    have : h₁_st' = h₂_st', tauto,\n    ifinish,\n  },\nend\n\n/- not a lot of repetition above -/\n/- it's horribly slow and obnoxious to run though -/\n\n/-\nLtac rwinv H1 H2 := rewrite H1 in H2; inv H2.\n\nTheorem ceval_deterministic'': ∀c st st1 st2,\n    st =[ c ]⇒ st1 →\n    st =[ c ]⇒ st2 →\n    st1 = st2.\nProof.\n  intros c st st1 st2 E1 E2.\n  generalize dependent st2;\n  induction E1; intros st2 E2; inv E2; auto.\n  - (* E_Seq *)\n    assert (st' = st'0) as EQ1 by auto.\n    subst st'0.\n    auto.\n  - (* E_IfTrue *)\n    + (* b evaluates to false (contradiction) *)\n      rwinv H H5.\n  - (* E_IfFalse *)\n    + (* b evaluates to true (contradiction) *)\n      rwinv H H5.\n  - (* E_WhileFalse *)\n    + (* b evaluates to true (contradiction) *)\n      rwinv H H2.\n  (* E_WhileTrue *)\n  - (* b evaluates to false (contradiction) *)\n    rwinv H H4.\n  - (* b evaluates to true *)\n    assert (st' = st'0) as EQ1 by auto.\n    subst st'0.\n    auto. Qed.\n-/\n\nnamespace tactic.interactive\n\n/-\nTODO: use rewrite_rules, location, and with_ident_list\n-/\nmeta def rwinv (h₁ h₂ : parse ident) : tactic unit :=\npropagate_tags $ do\n  h₁' ← get_local h₁,\n  h₂' ← get_local h₂,\n  rewrite_hyp h₁' h₂',\n  inv h₂ []\n\nend tactic.interactive\n\ntheorem ceval_deterministic'' {c st st₁ st₂}\n  (h₁ : st =[ c ]⇒ st₁) (h₂ : st =[ c ]⇒ st₂)\n  : st₁ = st₂ :=\nbegin\n  induction h₁ generalizing st₂; inv h₂; try { tauto <|> rwinv h₁_a h₂_a },\n  case E_Seq {\n    have : h₁_st' = h₂_st', tauto,\n    ifinish,\n  },\n  case E_WhileTrue E_WhileTrue {\n    have : h₁_st' = h₂_st', tauto,\n    ifinish,\n  },\nend\n\n/-\nLtac find_rwinv :=\n  match goal with\n    H1: ?E = true,\n    H2: ?E = false\n    ⊢ _ ⇒ rwinv H1 H2\n  end.\n-/\n\nnamespace tactic.interactive\n\n-- meta def eq_bool (b : bool): list expr → tactic (option expr)\n-- | [] := none\n-- | (e::es) := do\n--   e' ← infer_type e,\n--   match e' with\n--   | `(_ = %%b') := if (reflect b).to_expr = b'\n--                    then pure $ some e\n--                    else eq_bool es\n--   | _ := eq_bool es\n--   end\n\nmeta def find_rwinv : tactic unit :=\ndo\n  ctx ← local_context,\n  mv ← mk_mvar,\n  h₁ ← find_same_type `(%%mv = tt) ctx,\n  h₂ ← find_same_type `(%%mv = ff) ctx,\n  rwinv h₁.local_pp_name h₂.local_pp_name\n\nend tactic.interactive\n\ntheorem ceval_deterministic''' {c st st₁ st₂}\n  (h₁ : st =[ c ]⇒ st₁) (h₂ : st =[ c ]⇒ st₂)\n  : st₁ = st₂ :=\nbegin\n  induction h₁ generalizing st₂; inv h₂; try { tauto <|> find_rwinv },\n  case E_Seq {\n    have : h₁_st' = h₂_st', tauto,\n    ifinish,\n  },\n  case E_WhileTrue E_WhileTrue {\n    have : h₁_st' = h₂_st', tauto,\n    ifinish,\n  },\nend\n\n/-\nLtac find_eqn :=\n  match goal with\n    H1: ∀x, ?P x → ?L = ?R,\n    H2: ?P ?X\n    ⊢ _ ⇒ rewrite (H1 X H2) in *\n  end.\n-/\n\n/-\nltac is nice...\n-/\nnamespace tactic.interactive\n\nopen expr binder_info\n\n-- meta def expr_view : expr → tactic string := λe, do\n--   trace $ \"e: \" ++ to_string e,\n--   s ← match e with\n--   | app e body :=\n--     pure $ \"app: \" ++ to_string e ++ to_string body\n--   | const n l := pure $ \"const: \" ++ to_string n ++ to_string l\n--   | elet n e₁ e₂ body :=\n--     pure $ \"elet: \" ++ to_string n ++ to_string e₁ ++\n--       to_string e₂ ++ to_string body\n--   | lam n bind e body :=\n--     pure $ \"lam: \" ++ to_string n ++ to_string e ++ to_string body\n--   | local_const n₁ n₂ bind e :=\n--     pure $ \"loc: \" ++ to_string n₁ ++ to_string n₂ ++ to_string e\n--   | macro d es := pure $ \"mac: \" ++ to_string es\n--   | mvar n₁ n₂ e :=\n--     pure $ \"mvar: \" ++ to_string n₁ ++ to_string n₂ ++ to_string e\n--   | pi n bind e body :=\n--     -- expr_view e >>= λe,\n--     -- expr_view body >>= λbody,\n--     pure $ \"pi: \" ++ to_string n ++ to_string e ++ to_string body\n--   | sort l := pure $ \"sort: \" ++ to_string l\n--   | var n := pure $ \"var: \" ++ to_string n\n--   end,\n--   trace s,\n--   pure s\n\n-- meta def ctx_view : tactic unit :=\n-- do\n--   ctx ← local_context,\n--   ctx.mmap' (λh, expr_view h >> infer_type h >>= expr_view)\n\n-- meta def infer (e : expr) : tactic (expr × expr) := do\n--   e' ← infer_type e,\n--   pure (e, e')\n\nmeta def find_pi : (list (expr × expr)) → tactic (list (expr × expr)) := λes,\n  match es with\n  | (n, (pi _ _ _ (pi _ _ (app e₁ e₂) `(%%l = %%r))))::es := do\n    es ← find_pi es,\n    pure $ (n, e₁)::es\n  | (_::es) := find_pi es\n  | _ := pure $ []\n  end\n\nmeta def find_app (e: expr) : (list (expr × expr)) → tactic (list (expr × expr))\n:= λes,\n  match es with\n  | (n, (app e₁ e₂))::es := do\n    es ← find_app es,\n    pure $ if e = e₁ then (n, e₂)::es else es\n  | (_::es) := find_app es\n  | _ := pure $ []\n  end\n\nmeta def find_props : tactic (list (expr × expr × expr)) := do\n  h ← local_context,\n  h ← h.mmap (λh, do h' ← infer_type h, pure (h, h')),\n  a ← find_pi h,\n  p ← a.mmap (λ⟨n, e⟩, do\n    p ← find_app e h,\n    pure $ p.map (λ⟨n₁, e⟩, (n, n₁, e))\n  ),\n  pure p.join\n\nmeta def find_eqn : tactic unit :=\npropagate_tags $ do\n  p ← find_props,\n  p.mmap' (λ⟨n₁, n₂, e⟩, do\n    h ← note `this none (mk_app n₁ [e, n₂]),\n    do tactic.subst h <|> tactic.clear h\n  )\n\nend tactic.interactive\n\n/-\nTheorem ceval_deterministic''''': ∀c st st1 st2,\n    st =[ c ]⇒ st1 →\n    st =[ c ]⇒ st2 →\n    st1 = st2.\nProof.\n  intros c st st1 st2 E1 E2.\n  generalize dependent st2;\n  induction E1; intros st2 E2; inv E2; try find_rwinv;\n    repeat find_eqn; auto.\nQed.\n-/\n\n/-\nnote: finish fails to find refl for E_ASS and find_eqn runs a loop internally\n-/\ntheorem ceval_deterministic''''' {c st st₁ st₂}\n  (h₁ : st =[ c ]⇒ st₁) (h₂ : st =[ c ]⇒ st₂)\n  : st₁ = st₂ :=\nbegin\n  induction h₁ generalizing st₂;\n    inv h₂;\n    try { refl <|> find_rwinv };\n    find_eqn;\n    ifinish,\nend\n\n/-\nModule Repeat.\n\nInductive com : Type :=\n  | CSkip\n  | CAsgn (x : string) (a : aexp)\n  | CSeq (c1 c2 : com)\n  | CIf (b : bexp) (c1 c2 : com)\n  | CWhile (b : bexp) (c : com)\n  | CRepeat (c : com) (b : bexp).\n-/\n\nnamespace repeat\n\ninductive com\n| CSkip\n| CAsgn (x : string) (a : aexp)\n| CSeq (c₁ c₂ : com)\n| CIf (b : bexp) (c₁ c₂ : com)\n| CWhile (b : bexp) (c : com)\n| CRepeat (c : com) (b : bexp)\n\nopen com\n\n/-\nNotation \"'SKIP'\" :=\n  CSkip.\nNotation \"c1 ; c2\" :=\n  (CSeq c1 c2) (at level 80, right associativity).\nNotation \"X '::=' a\" :=\n  (CAsgn X a) (at level 60).\nNotation \"'WHILE' b 'DO' c 'END'\" :=\n  (CWhile b c) (at level 80, right associativity).\nNotation \"'TEST' e1 'THEN' e2 'ELSE' e3 'FI'\" :=\n  (CIf e1 e2 e3) (at level 80, right associativity).\nNotation \"'REPEAT' e1 'UNTIL' b2 'END'\" :=\n  (CRepeat e1 b2) (at level 80, right associativity).\n\nInductive ceval : state → com → state → Prop :=\n  | E_Skip : ∀st,\n      ceval st SKIP st\n  | E_Ass : ∀st a1 n X,\n      aeval st a1 = n →\n      ceval st (X ::= a1) (t_update st X n)\n  | E_Seq : ∀c1 c2 st st' st'',\n      ceval st c1 st' →\n      ceval st' c2 st'' →\n      ceval st (c1 ; c2) st''\n  | E_IfTrue : ∀st st' b1 c1 c2,\n      beval st b1 = true →\n      ceval st c1 st' →\n      ceval st (TEST b1 THEN c1 ELSE c2 FI) st'\n  | E_IfFalse : ∀st st' b1 c1 c2,\n      beval st b1 = false →\n      ceval st c2 st' →\n      ceval st (TEST b1 THEN c1 ELSE c2 FI) st'\n  | E_WhileFalse : ∀b1 st c1,\n      beval st b1 = false →\n      ceval st (WHILE b1 DO c1 END) st\n  | E_WhileTrue : ∀st st' st'' b1 c1,\n      beval st b1 = true →\n      ceval st c1 st' →\n      ceval st' (WHILE b1 DO c1 END) st'' →\n      ceval st (WHILE b1 DO c1 END) st''\n  | E_RepeatEnd : ∀st st' b1 c1,\n      ceval st c1 st' →\n      beval st' b1 = true →\n      ceval st (CRepeat c1 b1) st'\n  | E_RepeatLoop : ∀st st' st'' b1 c1,\n      ceval st c1 st' →\n      beval st' b1 = false →\n      ceval st' (CRepeat c1 b1) st'' →\n      ceval st (CRepeat c1 b1) st''.\n\nNotation \"st '=[' c ']⇒' st'\" := (ceval st c st')\n                                 (at level 40).\n-/\n\nlocal notation `SKIP` := CSkip\nlocal infix ` ::= `:60 := CAsgn\nlocal infix ` ;; `:35 := CSeq\nlocal notation `WHILE ` b ` DO ` c ` END` := CWhile b c\nlocal notation `TEST ` c₁ ` THEN ` c₂ ` ELSE ` c₃ ` FI` := CIf c₁ c₂ c₃\nlocal notation `REPEAT ` e₁ ` UNTIL ` b₂ ` END` := CRepeat e₁ b₂\n\ninductive ceval : com → imp.state → imp.state → Prop\n| E_Skip : ∀st, ceval SKIP st st\n| E_Ass : ∀{st a₁ n} x,\n  aeval st a₁ = n →\n  ceval (x ::= a₁) st (x !→ n ; st)\n| E_Seq : ∀{c₁ c₂ st st' st''},\n  ceval c₁ st st' →\n  ceval c₂ st' st'' →\n  ceval (c₁ ;; c₂) st st''\n| E_IfTrue : ∀{st st' b c₁} c₂,\n  beval st b = tt →\n  ceval c₁ st st' →\n  ceval (TEST b THEN c₁ ELSE c₂ FI) st st'\n| E_IfFalse : ∀{st st' b} c₁ {c₂},\n  beval st b = ff →\n  ceval c₂ st st' →\n  ceval (TEST b THEN c₁ ELSE c₂ FI) st st'\n| E_WhileFalse : ∀{b st} c,\n  beval st b = ff →\n  ceval (WHILE b DO c END) st st\n| E_WhileTrue : ∀{st st' st'' b c},\n  beval st b = tt →\n  ceval c st st' →\n  ceval (WHILE b DO c END) st' st'' →\n  ceval (WHILE b DO c END) st st''\n| E_RepeatEnd : ∀{st st' b c},\n  ceval c st st' →\n  beval st' b = tt →\n  ceval (REPEAT c UNTIL b END) st st'\n| E_RepeatLoop : ∀{st st' st'' b c},\n  ceval c st st' →\n  beval st' b = ff →\n  ceval (REPEAT c UNTIL b END) st' st'' →\n  ceval (REPEAT c UNTIL b END) st st''\n\nopen ceval\n\nlocal notation st ` =[ ` c ` ]⇒ ` st' := ceval c st st'\n\nopen imp\n\n/-\nTheorem ceval_deterministic: ∀c st st1 st2,\n    st =[ c ]⇒ st1 →\n    st =[ c ]⇒ st2 →\n    st1 = st2.\nProof.\n  intros c st st1 st2 E1 E2.\n  generalize dependent st2;\n  induction E1;\n    intros st2 E2; inv E2; try find_rwinv; repeat find_eqn; auto.\n  - (* E_RepeatEnd *)\n    + (* b evaluates to false (contradiction) *)\n       find_rwinv.\n       (* oops: why didn't find_rwinv solve this for us already?\n          answer: we did things in the wrong order. *)\n  - (* E_RepeatLoop *)\n     + (* b evaluates to true (contradiction) *)\n        find_rwinv.\nQed.\n-/\n\n/-\nTODO: for reasons i cannot even begin to fathom,\nusing notation for h₂ breaks it\n\nnote: ifinish can handle find_rwinv so moving find_eqn makes no difference\n-/\ntheorem ceval_deterministic {c : com} {st st₁ st₂}\n  (h₁ : st =[ c ]⇒ st₁) (h₂ : ceval c st st₂)\n  : st₁ = st₂ :=\nbegin\n  induction h₁ generalizing st₂;\n    inv h₂;\n    try { refl <|> find_rwinv };\n    find_eqn;\n    ifinish,\nend\n\n/-\nTheorem ceval_deterministic': ∀c st st1 st2,\n    st =[ c ]⇒ st1 →\n    st =[ c ]⇒ st2 →\n    st1 = st2.\nProof.\n  intros c st st1 st2 E1 E2.\n  generalize dependent st2;\n  induction E1;\n    intros st2 E2; inv E2; repeat find_eqn; try find_rwinv; auto.\nQed.\nEnd Repeat.\n-/\n\ntheorem ceval_deterministic' {c : com} {st st₁ st₂}\n  (h₁ : st =[ c ]⇒ st₁) (h₂ : ceval c st st₂)\n  : st₁ = st₂ :=\nbegin\n  induction h₁ generalizing st₂;\n    inv h₂;\n    find_eqn;\n    try { refl <|> find_rwinv };\n    ifinish,\nend\n\nend repeat\n\n/-\nExample ceval_example1:\n  empty_st =[\n    X ::= 2;;\n    TEST X ≤ 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]⇒ (Z !-> 4 ; X !-> 2).\nProof.\n  (* We supply the intermediate state st'... *)\n  apply E_Seq with (X !-> 2).\n  - apply E_Ass. reflexivity.\n  - apply E_IfFalse. reflexivity. apply E_Ass. reflexivity.\nQed.\n-/\n\nexample :\n  empty_st =[\n    X ::= 2;;\n    TEST X ≤' 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]⇒ Z !→ 4 ; X !→ 2 :=\nbegin\n  apply E_Seq,\n    apply E_Ass,\n    refl,\n  apply E_IfFalse,\n    refl,\n  apply E_Ass,\n  refl,\nend\n\n/-\nExample ceval'_example1:\n  empty_st =[\n    X ::= 2;;\n    TEST X ≤ 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]⇒ (Z !-> 4 ; X !-> 2).\nProof.\n  eapply E_Seq. (* 1 *)\n  - apply E_Ass. (* 2 *)\n    reflexivity. (* 3 *)\n  - (* 4 *) apply E_IfFalse. reflexivity. apply E_Ass. reflexivity.\nQed.\n-/\n\n/-\neapply doesn't create the metavariable subgoal,\nbut it doesn't have any other noticeable effects in this proof\n-/\n\nexample :\n  empty_st =[\n    X ::= 2;;\n    TEST X ≤' 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]⇒ Z !→ 4 ; X !→ 2 :=\nbegin\n  eapply E_Seq,\n    eapply E_Ass,\n    refl,\n  eapply E_IfFalse,\n    refl,\n  eapply E_Ass,\n  refl,\nend\n\n/-\nHint Constructors ceval.\nHint Transparent state.\nHint Transparent total_map.\n\nDefinition st12 := (Y !-> 2 ; X !-> 1).\nDefinition st21 := (Y !-> 1 ; X !-> 2).\n\nExample eauto_example : ∃s',\n  st21 =[\n    TEST X ≤ Y\n      THEN Z ::= Y - X\n      ELSE Y ::= X + Z\n    FI\n  ]⇒ s'.\nProof. eauto. Qed.\n-/\n\n/-\nTODO: no finishing tactic handles this\n-/\n\n-- def st₁₂ := Y !→ 2 ; X !→ 1\n-- def st₂₁ := Y !→ 1 ; X !→ 2\n\n-- example : ∃s',\n--   st₂₁ =[\n--     TEST X ≤' Y\n--       THEN Z ::= Y - X\n--       ELSE Y ::= X + Z\n--     FI\n--   ]⇒ s' := by ifinish\n", "meta": {"author": "michens", "repo": "learn-lean", "sha": "f38fc342780ddff5a164a18e5482163dea506ccd", "save_path": "github-repos/lean/michens-learn-lean", "path": "github-repos/lean/michens-learn-lean/learn-lean-f38fc342780ddff5a164a18e5482163dea506ccd/sf/v1/ch16_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635868562172, "lm_q2_score": 0.7371581510799253, "lm_q1q2_score": 0.4722499523847728}}
{"text": "import data.complex.basic\n\nnamespace cau_seq\n\ntheorem const_inv {α β : Type*} [discrete_field β] [discrete_linear_ordered_field α] {abv : β → α} \n  [is_absolute_value abv] {x : β} (hx : x ≠ 0) : \n  const abv (x⁻¹) = inv (const abv x) (by rwa const_lim_zero) :=\n ext (assume n, by simp[inv_apply, const_apply])\n\nend cau_seq\n\nnamespace real\n\nopen cau_seq real\n\nlemma eq_lim_of_const_equiv {f : cau_seq ℝ abs} {x : ℝ} (h : cau_seq.const abs x ≈ f) : x = lim f :=\nconst_equiv.mp $ setoid.trans h $ equiv_lim f\n\nlemma lim_eq_of_equiv_const {f : cau_seq ℝ abs} {x : ℝ} (h : f ≈ cau_seq.const abs x) : lim f = x :=\n(eq_lim_of_const_equiv $ setoid.symm h).symm\n\nlemma lim_eq_lim_of_equiv {f g : cau_seq ℝ abs} (h : f ≈ g) : lim f = lim g := \nlim_eq_of_equiv_const $ setoid.trans h $ equiv_lim g\n\n@[simp] lemma lim_const (x : ℝ) : lim (const abs x) = x := \nlim_eq_of_equiv_const $ setoid.refl _\n\nlemma lim_add (f g : cau_seq ℝ abs) : lim f + lim g = lim ⇑(f + g) := \neq_lim_of_const_equiv $ show lim_zero (const abs (lim ⇑f + lim ⇑g) - (f + g)),\n  by rw [const_add, add_sub_comm];\n  exact add_lim_zero (setoid.symm (equiv_lim f)) (setoid.symm (equiv_lim g))\n\nlemma lim_mul_lim (f g : cau_seq ℝ abs) : lim f * lim g = lim ⇑(f * g) := \neq_lim_of_const_equiv $ show lim_zero (const abs (lim ⇑f * lim ⇑g) - f * g),\n  from have h : const abs (lim ⇑f * lim ⇑g) - f * g = g * (const abs (lim f) - f) \n      + const abs (lim f) * (const abs (lim g) - g) := \n    by simp [mul_sub, mul_comm, const_mul, mul_add],\n  by rw h; exact add_lim_zero (mul_lim_zero _ (setoid.symm (equiv_lim f))) \n      (mul_lim_zero _ (setoid.symm (equiv_lim g)))\n\nlemma lim_mul (f : cau_seq ℝ abs) (x : ℝ) : lim f * x = lim ⇑(f * const abs x) :=\nby rw [← lim_mul_lim, lim_const]\n\nlemma lim_neg (f : cau_seq ℝ abs) : lim ⇑(-f) = -lim f :=\nlim_eq_of_equiv_const (show lim_zero (-f - const abs (-lim ⇑f)),\n  by rw [const_neg, sub_neg_eq_add, add_comm];\n  exact setoid.symm (equiv_lim f))\n\nlemma lim_eq_zero_iff (f : cau_seq ℝ abs) : lim f = 0 ↔ lim_zero f :=\n⟨assume h,\n  by have hf := equiv_lim f;\n  rw h at hf;\n  exact (lim_zero_congr hf).mpr (const_lim_zero.mpr rfl),\nassume h, \n  have h₁ : f = (f - const abs 0) := ext (λ n, by simp [sub_apply, const_apply]),\n  by rw h₁ at h; exact lim_eq_of_equiv_const h ⟩\n\nlemma lim_inv {f : cau_seq ℝ abs} (hf : ¬ lim_zero f) : lim ⇑(inv f hf) = (lim f)⁻¹ :=\nhave hl : lim f ≠ 0 := by rwa ← lim_eq_zero_iff at hf, \nlim_eq_of_equiv_const $ show lim_zero (inv f hf - const abs (lim ⇑f)⁻¹),\n  from have h₁ : ∀ (g f : cau_seq ℝ abs) (hf : ¬ lim_zero f), lim_zero (g - f * inv f hf * g) := \n    λ g f hf, by rw [← one_mul g, ← mul_assoc, ← sub_mul, mul_one, mul_comm, mul_comm f];\n    exact mul_lim_zero _ (setoid.symm (cau_seq.inv_mul_cancel _)),\n  have h₂ : lim_zero ((inv f hf - const abs (lim ⇑f)⁻¹) - (const abs (lim f) - f) * \n      (inv f hf * const abs (lim ⇑f)⁻¹)) := \n    by rw [sub_mul, ← sub_add, sub_sub, sub_add_eq_sub_sub, sub_right_comm, sub_add];\n    exact show lim_zero (inv f hf - const abs (lim ⇑f) * (inv f hf * const abs (lim ⇑f)⁻¹)\n      - (const abs (lim ⇑f)⁻¹ - f * (inv f hf * const abs (lim ⇑f)⁻¹))),\n    from sub_lim_zero\n      (by rw [← mul_assoc, mul_right_comm, const_inv hl]; exact h₁ _ _ _)\n      (by rw [← mul_assoc]; exact h₁ _ _ _),\n  (lim_zero_congr h₂).mpr $ by rw mul_comm; exact mul_lim_zero _ (setoid.symm (equiv_lim f))\n\nend real\n\nnamespace complex\nopen cau_seq\n\nlemma re_const_equiv_of_const_equiv {f : ℕ → ℂ} (hf : is_cau_seq abs f) (z : ℂ) :\n    cau_seq.const abs z ≈ ⟨f, hf⟩ → cau_seq.const _root_.abs z.re ≈ ⟨(λ (n : ℕ), (f n).re), \n    complex.is_cau_seq_re ⟨f,hf⟩⟩ := begin\n  assume h,assume ε ε0,cases h ε ε0 with i hi,existsi i,assume j ji,\n  replace hi := hi j ji, simp at *, rw [←complex.neg_re,←complex.add_re],\n  exact lt_of_le_of_lt (complex.abs_re_le_abs _) hi,\nend\n\nlemma im_const_equiv_of_const_equiv {f : ℕ → ℂ} (hf : is_cau_seq abs f) (z : ℂ) :\n    cau_seq.const abs z ≈ ⟨f, hf⟩ → cau_seq.const _root_.abs z.im ≈ ⟨(λ (n : ℕ), (f n).im),\n    complex.is_cau_seq_im ⟨f,hf⟩⟩ := begin\n  assume h,assume ε ε0,cases h ε ε0 with i hi,existsi i,assume j ji,\n  replace hi := hi j ji, simp at *, rw [←complex.neg_im,←complex.add_im],\n  exact lt_of_le_of_lt (complex.abs_im_le_abs _) hi,\nend\n\nlemma eq_lim_of_const_equiv {f : cau_seq ℂ abs}  {z: ℂ} : \n    cau_seq.const complex.abs z ≈ f → z = complex.lim f := begin\n  assume h,\n  unfold complex.lim,cases z with zre zim,simp,\n  split, have := real.equiv_lim ⟨(λ (n : ℕ), (f.1 n).re), complex.is_cau_seq_re f⟩,\n  rw ←cau_seq.const_equiv,simp at this,\n  have hf := complex.re_const_equiv_of_const_equiv f.2 {re := zre, im := zim} h,simp at hf,\n  exact setoid.trans hf this,\n  have := real.equiv_lim ⟨(λ (n : ℕ), (f.1 n).im), complex.is_cau_seq_im f⟩,\n  rw ←cau_seq.const_equiv,simp at this,\n  have hf := complex.im_const_equiv_of_const_equiv f.2 {re := zre, im := zim} h,simp at hf,\n  exact setoid.trans hf this,\nend\n\nlemma lim_eq_of_equiv_const {f : cau_seq ℂ complex.abs} {x : ℂ} (h : f ≈ cau_seq.const complex.abs x) : lim f = x :=\n(eq_lim_of_const_equiv $ setoid.symm h).symm\n\nlemma lim_eq_lim_of_equiv {f g : cau_seq ℂ complex.abs} (h : f ≈ g) : lim f = lim g := \nlim_eq_of_equiv_const $ setoid.trans h $ equiv_lim g\n\n@[simp] lemma lim_const (x : ℂ) : lim (const abs x) = x := \nlim_eq_of_equiv_const $ setoid.refl _\n\nlemma lim_add (f g : cau_seq ℂ complex.abs) : lim f + lim g = lim ⇑(f + g) := \neq_lim_of_const_equiv $ show lim_zero (const complex.abs (lim ⇑f + lim ⇑g) - (f + g)),\n  by rw [const_add, add_sub_comm];\n  exact add_lim_zero (setoid.symm (equiv_lim f)) (setoid.symm (equiv_lim g))\n\nlemma lim_mul_lim (f g : cau_seq ℂ complex.abs) : lim f * lim g = lim ⇑(f * g) := \neq_lim_of_const_equiv $ show lim_zero (const complex.abs (lim ⇑f * lim ⇑g) - f * g),\n  from have h : const complex.abs (lim ⇑f * lim ⇑g) - f * g = g * (const complex.abs (lim f) - f) \n      + const complex.abs (lim f) * (const complex.abs (lim g) - g) := \n    by simp [mul_sub, mul_comm, const_mul, mul_add],\n  by rw h; exact add_lim_zero (mul_lim_zero _ (setoid.symm (equiv_lim f))) \n      (mul_lim_zero _ (setoid.symm (equiv_lim g)))\n\nlemma lim_mul (f : cau_seq ℂ complex.abs) (x : ℂ) : lim f * x = lim ⇑(f * const complex.abs x) :=\nby rw [← lim_mul_lim, lim_const]\n\nlemma lim_neg (f : cau_seq ℂ complex.abs) : lim ⇑(-f) = -lim f :=\nlim_eq_of_equiv_const (show lim_zero (-f - const complex.abs (-lim ⇑f)),\n  by rw [const_neg, sub_neg_eq_add, add_comm];\n  exact setoid.symm (equiv_lim f))\n\nlemma lim_eq_zero_iff (f : cau_seq ℂ complex.abs) : lim f = 0 ↔ lim_zero f :=\n⟨assume h,\n  by have hf := equiv_lim f;\n  rw h at hf;\n  exact (lim_zero_congr hf).mpr (const_lim_zero.mpr rfl),\nassume h, \n  have h₁ : f = (f - const complex.abs (0 : ℂ)) := cau_seq.ext (λ n, by simp [sub_apply, const_apply]),\n  by rw h₁ at h; exact lim_eq_of_equiv_const h ⟩\n\nlemma lim_inv {f : cau_seq ℂ complex.abs} (hf : ¬ lim_zero f) : lim ⇑(inv f hf) = (lim f)⁻¹ :=\nhave hl : lim f ≠ 0 := by rwa ← lim_eq_zero_iff at hf, \nlim_eq_of_equiv_const $ show lim_zero (inv f hf - const abs (lim ⇑f)⁻¹),\n  from have h₁ : ∀ (g f : cau_seq ℂ abs) (hf : ¬ lim_zero f), lim_zero (g - f * inv f hf * g) := \n    λ g f hf, by rw [← one_mul g, ← mul_assoc, ← sub_mul, mul_one, mul_comm, mul_comm f];\n    exact mul_lim_zero _ (setoid.symm (cau_seq.inv_mul_cancel _)),\n  have h₂ : lim_zero ((inv f hf - const abs (lim ⇑f)⁻¹) - (const abs (lim f) - f) * \n      (inv f hf * const abs (lim ⇑f)⁻¹)) := \n    by rw [sub_mul, ← sub_add, sub_sub, sub_add_eq_sub_sub, sub_right_comm, sub_add];\n    exact show lim_zero (inv f hf - const abs (lim ⇑f) * (inv f hf * const abs (lim ⇑f)⁻¹)\n      - (const abs (lim ⇑f)⁻¹ - f * (inv f hf * const abs (lim ⇑f)⁻¹))),\n    from sub_lim_zero\n      (by rw [← mul_assoc, mul_right_comm, cau_seq.const_inv hl]; exact h₁ _ _ _)\n      (by rw [← mul_assoc]; exact h₁ _ _ _),\n  (lim_zero_congr h₂).mpr $ by rw mul_comm; exact mul_lim_zero _ (setoid.symm (equiv_lim f))\n\nend complex", "meta": {"author": "ChrisHughes24", "repo": "leanstuff", "sha": "9efa85f72efaccd1d540385952a6acc18fce8687", "save_path": "github-repos/lean/ChrisHughes24-leanstuff", "path": "github-repos/lean/ChrisHughes24-leanstuff/leanstuff-9efa85f72efaccd1d540385952a6acc18fce8687/limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.472147780639601}}
{"text": "lemma or_symm (P Q : Prop) : P ∨ Q → Q ∨ P :=\nbegin\nintro h,\ncases h with p q,\nright,\nexact p,\nleft,\nexact q,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/5-advanced-proposition-world/l7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4721477757337804}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot, Yury Kudryashov, Rémy Degenne\n! This file was ported from Lean 3 source module data.set.intervals.order_iso\n! leanprover-community/mathlib commit d012cd09a9b256d870751284dd6a29882b0be105\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Set.Intervals.Basic\nimport Mathlib.Order.Hom.Set\n\n/-!\n# Lemmas about images of intervals under order isomorphisms.\n-/\n\nopen Set\n\nnamespace OrderIso\n\nsection Preorder\n\nvariable [Preorder α] [Preorder β]\n\n@[simp]\ntheorem preimage_Iic (e : α ≃o β) (b : β) : e ⁻¹' Iic b = Iic (e.symm b) := by\n  ext x\n  simp [← e.le_iff_le]\n#align order_iso.preimage_Iic OrderIso.preimage_Iic\n\n@[simp]\ntheorem preimage_Ici (e : α ≃o β) (b : β) : e ⁻¹' Ici b = Ici (e.symm b) := by\n  ext x\n  simp [← e.le_iff_le]\n#align order_iso.preimage_Ici OrderIso.preimage_Ici\n\n@[simp]\ntheorem preimage_Iio (e : α ≃o β) (b : β) : e ⁻¹' Iio b = Iio (e.symm b) := by\n  ext x\n  simp [← e.lt_iff_lt]\n#align order_iso.preimage_Iio OrderIso.preimage_Iio\n\n@[simp]\ntheorem preimage_Ioi (e : α ≃o β) (b : β) : e ⁻¹' Ioi b = Ioi (e.symm b) := by\n  ext x\n  simp [← e.lt_iff_lt]\n#align order_iso.preimage_Ioi OrderIso.preimage_Ioi\n\n@[simp]\ntheorem preimage_Icc (e : α ≃o β) (a b : β) : e ⁻¹' Icc a b = Icc (e.symm a) (e.symm b) := by\n  simp [← Ici_inter_Iic]\n#align order_iso.preimage_Icc OrderIso.preimage_Icc\n\n@[simp]\ntheorem preimage_Ico (e : α ≃o β) (a b : β) : e ⁻¹' Ico a b = Ico (e.symm a) (e.symm b) := by\n  simp [← Ici_inter_Iio]\n#align order_iso.preimage_Ico OrderIso.preimage_Ico\n\n@[simp]\ntheorem preimage_Ioc (e : α ≃o β) (a b : β) : e ⁻¹' Ioc a b = Ioc (e.symm a) (e.symm b) := by\n  simp [← Ioi_inter_Iic]\n#align order_iso.preimage_Ioc OrderIso.preimage_Ioc\n\n@[simp]\ntheorem preimage_Ioo (e : α ≃o β) (a b : β) : e ⁻¹' Ioo a b = Ioo (e.symm a) (e.symm b) := by\n  simp [← Ioi_inter_Iio]\n#align order_iso.preimage_Ioo OrderIso.preimage_Ioo\n\n@[simp]\ntheorem image_Iic (e : α ≃o β) (a : α) : e '' Iic a = Iic (e a) := by\n  rw [e.image_eq_preimage, e.symm.preimage_Iic, e.symm_symm]\n#align order_iso.image_Iic OrderIso.image_Iic\n\n@[simp]\ntheorem image_Ici (e : α ≃o β) (a : α) : e '' Ici a = Ici (e a) :=\n  e.dual.image_Iic a\n#align order_iso.image_Ici OrderIso.image_Ici\n\n@[simp]\ntheorem image_Iio (e : α ≃o β) (a : α) : e '' Iio a = Iio (e a) := by\n  rw [e.image_eq_preimage, e.symm.preimage_Iio, e.symm_symm]\n#align order_iso.image_Iio OrderIso.image_Iio\n\n@[simp]\ntheorem image_Ioi (e : α ≃o β) (a : α) : e '' Ioi a = Ioi (e a) :=\n  e.dual.image_Iio a\n#align order_iso.image_Ioi OrderIso.image_Ioi\n\n@[simp]\ntheorem image_Ioo (e : α ≃o β) (a b : α) : e '' Ioo a b = Ioo (e a) (e b) := by\n  rw [e.image_eq_preimage, e.symm.preimage_Ioo, e.symm_symm]\n#align order_iso.image_Ioo OrderIso.image_Ioo\n\n@[simp]\ntheorem image_Ioc (e : α ≃o β) (a b : α) : e '' Ioc a b = Ioc (e a) (e b) := by\n  rw [e.image_eq_preimage, e.symm.preimage_Ioc, e.symm_symm]\n#align order_iso.image_Ioc OrderIso.image_Ioc\n\n@[simp]\ntheorem image_Ico (e : α ≃o β) (a b : α) : e '' Ico a b = Ico (e a) (e b) := by\n  rw [e.image_eq_preimage, e.symm.preimage_Ico, e.symm_symm]\n#align order_iso.image_Ico OrderIso.image_Ico\n\n@[simp]\ntheorem image_Icc (e : α ≃o β) (a b : α) : e '' Icc a b = Icc (e a) (e b) := by\n  rw [e.image_eq_preimage, e.symm.preimage_Icc, e.symm_symm]\n#align order_iso.image_Icc OrderIso.image_Icc\n\nend Preorder\n\n/-- Order isomorphism between `Iic (⊤ : α)` and `α` when `α` has a top element -/\ndef IicTop [Preorder α] [OrderTop α] : Iic (⊤ : α) ≃o α :=\n  { @Equiv.subtypeUnivEquiv α (Iic (⊤ : α)) fun x => le_top with\n    map_rel_iff' := @fun x y => by rfl }\n#align order_iso.Iic_top OrderIso.IicTop\n\n/-- Order isomorphism between `Ici (⊥ : α)` and `α` when `α` has a bottom element -/\ndef IciBot [Preorder α] [OrderBot α] : Ici (⊥ : α) ≃o α :=\n  { @Equiv.subtypeUnivEquiv α (Ici (⊥ : α)) fun x => bot_le with\n    map_rel_iff' := @fun x y => by rfl }\n#align order_iso.Ici_bot OrderIso.IciBot\n\nend OrderIso\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Set/Intervals/OrderIso.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6513548578981939, "lm_q1q2_score": 0.47214777573378036}}
{"text": "/-\nCopyright (c) 2022 Arthur Paulino, Damiano Testa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Arthur Paulino, Damiano Testa\n-/\nimport tactic.core\nimport algebra.group.basic\n\n/-!\n# `move_add`: a tactic for moving summands\n\nCalling `move_add [a, ← b, c]`, recursively looks inside the goal for expressions involving a sum.\nWhenever it finds one, it moves the summands that unify to `a, b, c`, removing all parentheses.\n\nSee the doc-string for `tactic.interactive.move_add` for more information.\n\n##  Implementation notes\n\nThis file defines a general `move_op` tactic, intended for reordering terms in an expression\nobtained by repeated applications of a given associative, commutative binary operation.  The\nuser decides the final reordering.  Applying `move_op` without specifying the order will simply\nremove all parentheses from the expression.\nThe main user-facing tactics are `move_add` and `move_mul`, dealing with addition and\nmultiplication, respectively.\n\nIn what is below, we talk about `move_add` for definiteness, but everything applies\nto `move_mul` and to the more general `move_op`.\n\nThe implementation of `move_add` only moves the terms specified by the user (and rearranges\nparentheses).\n\nNote that the tactic `abel` already implements a very solid heuristic for normalizing terms in an\nadditive commutative semigroup and produces expressions in more or less standard form.\nThe scope of `move_add` is different: it is designed to make it easy to move individual terms\naround a sum.\n\n##  Future work\n\n* Add support for `neg/div/inv` in additive/multiplicative groups?\n* Currently the tactic has special support for `+` and `*`.  Every other operation is outsourced\n  to `ac_refl` (see the proof of `reorder_hyp`).  Should there be the desire for specialized support\n  of other operations (e.g. `∪, ∩, ⊓, ⊔, ...`), that is the definition to modify, at least in the\n  first instance.\n* Add functionality for moving terms across the two sides of an in/dis/equality.\n  E.g. it might be desirable to have `to_lhs [a]` converting `b + c = a + d` to `- a + b + c = d`.\n* Add a non-recursive version for use in `conv` mode.\n* Revise tests?\n-/\n\nnamespace tactic\n\nnamespace move_op\n\n/-!\nThroughout this file, `op : pexpr` denotes an arbitrary (binary) operation.  We do not use,\nbut implicitly imagine, that this operation is associative, since we extract iterations of\nsuch operations, with complete disregard of the order in which these iterations arise.\n-/\n\n/--  Given a list `un` of `α`s and a list `bo` of `bool`s, return the sublist of `un`\nconsisting of the entries of `un` whose corresponding entry in `bo` is `tt`.\n\nUsed for error management: `un` is the list of user inputs, `bo` is the list encoding which input\nis unused (`tt`) and which input is used (`ff`).\n`return_unused` returns the unused user inputs.\n\nIf `bo` is shorter than `un`, `return_unused` will include the remainder of `un`.\n-/\ndef return_unused {α : Type*} : list α → list bool → list α\n| un [] := un\n| [] bo := []\n| (u::us) (b::bs) := if b then u::return_unused us bs else return_unused us bs\n\n/--  Given a list `lp` of `bool × pexpr` and a list `l_un` of `expr`, scan the elements of `lp` one\nat a time and produce 3 sublists of `l_un`.\n\nIf `(tf,pe)` is the first element of `lp`, we look for the first element of `l_un` that unifies with\n`pe.to_expr`.  If no such element exists, then we discard `(tf,pe)` and move along.\nIf `eu ∈ l_un` is the first element of `l_un` that unifies with `pe.to_expr`, then we add `eu` as\nthe next element of either the first or the second list, depending on the boolean `tf` and we remove\n`eu` from the list `l_un`.  In this case, we continue our scanning with the next element of `lp`,\nreplacing `l_un` by `l_un.erase eu`.\n\nOnce we exhaust the elements of `lp`, we return the four lists:\n* `l_tt`: the list of elements of `l_un` that came from an element of `lp` whose boolean was `tt`,\n* `l_ff`: the list of elements of `l_un` that came from an element of `lp` whose boolean was `ff`,\n* `l_un`: the un-unified elements of `l_un`,\n* `l_m`: a \"mask\" list of booleans corresponding to the elements of `lp` that were placed in `l_un`.\n\nThe ununified elements of `l_un` get used for error management: they keep track of which user inputs\nare superfluous. -/\nmeta def move_left_or_right : list (bool × expr) → list expr → list bool →\n  tactic (list expr × list expr × list expr × list bool)\n| [] l_un l_m      := return ([], [], l_un, l_m)\n| (be::l) l_un l_m := do\n  (ex :: _) ← l_un.mfilter $ λ e', succeeds $ unify be.2 e' |\n    move_left_or_right l l_un (l_m.append [tt]),\n  (l_tt, l_ff, l_un, l_m) ← move_left_or_right l (l_un.erase ex) (l_m.append [ff]),\n  if be.1 then return (ex::l_tt, l_ff, l_un, l_m) else return (l_tt, ex::l_ff, l_un, l_m)\n\n/--  We adapt `move_left_or_right` to our goal:\n1. we convert a list of pairs `bool × pexpr` to a list of pairs `bool × expr`,\n2. we use the extra input `sl : list expr` to perform the unification and sorting step\n   `move_left_or_right`,\n3. we jam the third factor inside the first two.\n-/\nmeta def final_sort (lp : list (bool × pexpr)) (sl : list expr) : tactic (list expr × list bool) :=\ndo\n  lp_exp : list (bool × expr) ← lp.mmap $ λ x, (do e ← to_expr x.2 tt ff, return (x.1, e)),\n  (l1, l2, l3, is_unused) ← move_left_or_right lp_exp sl [],\n  return (l1 ++ l3 ++ l2, is_unused)\n\n/-- `as_given_op op e` unifies the head term of `e`, which is a ≥2-argument function application,\nwith the binary operation `op`, failing if it cannot. -/\nmeta def as_given_op (op : pexpr) : expr → tactic expr\n| (expr.app (expr.app F a) b) := do\n    to_expr op tt ff >>= unify F,\n    return F\n| _ := failed\n\n/-- `(e, unused) ← reorder_oper op lp e` converts an expression `e` to a similar looking one.\nThe tactic scans the expression `e` looking for subexpressions that begin with the given binary\noperation `op`.  As soon as `reorder_oper` finds one such subexpression,\n* it extracts the \"`op`-summands\" in the subexpression,\n* it rearranges them according to the rules determined by `lp`,\n* it recurses into each `op`-summand.\n\nThe `unused` output is a list of booleans.  It is keeping track of which of the inputs provided\nby `lp` is actually used to perform the rearrangements.  It is useful to report unused inputs.\n\nHere are two examples:\n```lean\n#eval trace $ reorder_oper ``((=)) [(ff,``(2)), (tt,``(7))] `(∀ x y : ℕ, 2 = 0)\n--  (ℕ → ℕ → 0 = 2, [ff, tt])\n-- the input `[(ff,``(2)), (tt,``(7))]` instructs Lean to move `2` to the right and `7`\n-- to the left.  Lean reports that `2` is not unused and `7` is unused as `[ff, tt]`.\n\n#eval trace $ reorder_oper ``((+)) [(ff,``(2)), (tt,``(5))]\n  `(λ (e : ℕ), ∀ (x : ℕ), ∃ (y : ℕ),\n      2 + x * (y + (e + 5)) + y = x + 2 + e → 2 + x = x + 5 + (2 + y))\n/-  `2` moves to the right, `5` moves to the left.  Lean reports that `2, 5` are not unused\n    as `[ff,ff]`\n   (λ (e : ℕ), ∀ (x : ℕ), ∃ (y : ℕ),\n      x * (5 + y + e) + y + 2   = x + e + 2 → x + 2 = 5 + x + y + 2, [ff, ff]) -/\n```\n\nTODO: use `ext_simplify_core` instead of traversing the expression manually\n-/\nmeta def reorder_oper (op : pexpr) (lp : list (bool × pexpr)) :\n  expr → tactic (expr × list bool)\n| F'@(expr.app F b) := do\n    is_op ← try_core (as_given_op op F'),\n    match is_op with\n    | some op := do\n        (sort_list, is_unused) ← list_binary_operands op F' >>= final_sort lp,\n        sort_all ← sort_list.mmap (λ e, do\n          (e, lu) ← reorder_oper e,\n          pure (e, [lu, is_unused].transpose.map list.band)),\n        let (recs, list_unused) := sort_all.unzip,\n        recs_0 :: recs_rest ← pure recs | fail!\"internal error: cannot have 0 operands\",\n        let summed := recs_rest.foldl (λ e f, op.mk_app [e, f]) recs_0,\n        return (summed, list_unused.transpose.map list.band)\n    | none := do\n        [(Fn, unused_F), (bn, unused_b)] ← [F, b].mmap $ reorder_oper,\n        return $ (expr.app Fn bn, [unused_F, unused_b].transpose.map list.band)\n    end\n| (expr.pi na bi e f)           := do\n  [en, fn] ← [e, f].mmap $ reorder_oper,\n  return (expr.pi  na bi en.1 fn.1, [en.2, fn.2].transpose.map list.band)\n| (expr.lam na bi e f)          := do\n  [en, fn] ← [e, f].mmap $ reorder_oper,\n  return (expr.lam na bi en.1 fn.1, [en.2, fn.2].transpose.map list.band)\n| (expr.mvar na pp e)           := do  -- is it really needed to recurse here?\n  en ← reorder_oper e,\n  return (expr.mvar na pp en.1, [en.2].transpose.map list.band)\n| (expr.local_const na pp bi e) := do  -- is it really needed to recurse here?\n  en ← reorder_oper e,\n  return (expr.local_const na pp bi en.1, [en.2].transpose.map list.band)\n| (expr.elet na e f g)          := do\n  [en, fn, gn] ← [e, f, g].mmap $ reorder_oper,\n  return (expr.elet na en.1 fn.1 gn.1, [en.2, fn.2, gn.2].transpose.map list.band)\n| (expr.macro ma le)            := do  -- is it really needed to recurse here?\n  len ← le.mmap $ reorder_oper,\n  let (lee, lb) := len.unzip,\n  return (expr.macro ma lee, lb.transpose.map list.band)\n| e := pure (e, (lp.map (λ _, tt)))\n\n/-- Passes the user input `na` to `reorder_oper` at a single location, that could either be\n`none` (referring to the goal) or `some name` (referring to hypothesis `name`).  Replaces the\ngiven hypothesis/goal with the rearranged one that `reorder_hyp` receives from `reorder_oper`.\nReturns a pair consisting of a boolean and a further list of booleans.\nThe single boolean is `tt` iff the tactic did *not* change the goal on which it was acting.\nThe list of booleans records which variable in `ll` has been unified in the application:\n`tt` means that the corresponding variable has *not* been unified.\n\nThis definition is useful to streamline error catching. -/\nmeta def reorder_hyp (op : pexpr) (lp : list (bool × pexpr)) (na : option name) :\n  tactic (bool × list bool) := do\n(thyp, hyploc) ← match na with\n  | none := do\n      t ← target,\n      return (t, none)\n  | some na := do\n      hl ← get_local na,\n      th ← infer_type hl,\n      return (th, some hl)\n  end,\n(reordered, is_unused) ← reorder_oper op lp thyp,\nunify reordered thyp >> return (tt, is_unused) <|> do\n-- the current `do` block takes place where the reordered expression is not equal to the original\nneq ← mk_app `eq [thyp, reordered],\nnop ← to_expr op tt ff,\npre ← pp reordered,\n(_, prf) ← solve_aux neq $ match nop with\n  | `(has_add.add) := `[{ simp only [add_comm, add_assoc, add_left_comm]; refl, done }]\n  | `(has_mul.mul) := `[{ simp only [mul_comm, mul_assoc, mul_left_comm]; refl, done }]\n  | _ := ac_refl <|>\n    fail format!(\"the associative/commutative lemmas used do not suffice to prove that \" ++\n      \"the initial goal equals:\\n\\n{pre}\\n\" ++\n      \"Hint: try adding `is_associative` or `is_commutative` instances.\\n\")\n  end,\nmatch hyploc with\n| none := replace_target reordered prf\n| some hyploc := replace_hyp hyploc reordered prf >> skip\nend,\nreturn (ff, is_unused)\n\nsection parsing_arguments_for_move_op\nsetup_tactic_parser\n\n/-- `move_op_arg` is a single elementary argument that `move_op` takes for the\nvariables to be moved.  It is either a `pexpr`, or a `pexpr` preceded by a `←`. -/\nmeta def move_op_arg (prec : nat) : parser (bool × pexpr) :=\nprod.mk <$> (option.is_some <$> (tk \"<-\")?) <*> parser.pexpr prec\n\n/-- `move_pexpr_list_or_texpr` is either a list of `move_op_arg`, possibly empty, or a single\n`move_op_arg`. -/\nmeta def move_pexpr_list_or_texpr : parser (list (bool × pexpr)) :=\nlist_of (move_op_arg 0) <|> list.ret <$> move_op_arg tac_rbp <|> return []\n\nend parsing_arguments_for_move_op\n\nend move_op\n\nsetup_tactic_parser\nopen move_op\n\n/--  `move_op args locat op` is the non-interactive version of the main tactics `move_add` and\n`move_mul` of this file.  Given as input `args` (a list of terms of a sequence of operands),\n`locat` (hypotheses or goal where the tactic should act) and `op` (the operation to use),\n`move_op` attempts to perform the rearrangement of the terms determined by `args`.\n\nCurrently, the tactic uses only `add/mul_comm, add/mul_assoc, add/mul_left_comm`, so other\noperations will not actually work.\n-/\nmeta def move_op (args : parse move_pexpr_list_or_texpr) (locat : parse location) (op : pexpr) :\n  tactic unit := do\nlocas ← locat.get_locals,\ntg ← target,\nlet locas_with_tg := if locat.include_goal then locas ++ [tg] else locas,\nner ← locas_with_tg.mmap (λ e, reorder_hyp op args e.local_pp_name <|> reorder_hyp op args none),\nlet (unch_tgts, unus_vars) := ner.unzip,\nstr_unva ← match\n  (return_unused args (unus_vars.transpose.map list.band)).map (λ e : bool × pexpr, e.2) with\n  | []   := pure []\n  | [pe] := do\n    nm ← to_expr pe tt ff >>= λ ex, pp ex.replace_mvars,\n    return [format!\"'{nm}' is an unused variable\"]\n  | pes  := do\n    nms ← pes.mmap (λ e, to_expr e tt ff) >>= λ exs, (exs.map expr.replace_mvars).mmap pp,\n    return [format!\"'{nms}' are unused variables\"]\n  end,\nlet str_tgts := match locat with\n  | loc.wildcard := if unch_tgts.band then [format!\"nothing changed\"] else []\n  | loc.ns names := let linames := return_unused locas unch_tgts in\n      (if none ∈ return_unused names unch_tgts\n        then [format!\"Goal did not change\"] else []) ++\n      (if linames ≠ [] then [format!\"'{linames.reverse}' did not change\"] else [])\n  end,\n[] ← pure (str_tgts ++ str_unva) | fail (format.intercalate \"\\n\" (str_tgts ++ str_unva)),\nassumption <|> try (tactic.reflexivity reducible)\n\nnamespace interactive\n\n/--\nCalling `move_add [a, ← b, c]`, recursively looks inside the goal for expressions involving a sum.\nWhenever it finds one, it moves the summands that unify to `a, b, c`, removing all parentheses.\nRepetitions are allowed, and are processed following the user-specified ordering.\nThe terms preceded by a `←` get placed to the left, the ones without the arrow get placed to the\nright.  Unnamed terms stay in place.  Due to re-parenthesizing, doing `move_add` with no argument\nmay change the goal. Also, the *order* in which the terms are provided matters: the tactic reads\nthem from left to right.  This is especially important if there are multiple matches for the typed\nterms in the given expressions.\n\nA single call of `move_add` moves terms across different sums in the same expression.\nHere is an example.\n\n```lean\nimport tactic.move_add\n\nexample {a b c d : ℕ} (h : c = d) : c + b + a = b + a + d :=\nbegin\n  move_add [← a, b],  -- Goal: `a + c + b = a + d + b`  -- both sides changed\n  congr,\n  exact h\nend\n\nexample {a b c d : ℕ} (h : c = d) : c + b * c + a * c = a * d + d + b * d :=\nbegin\n  move_add [_ * c, ← _ * c], -- Goal: `a * c + c + b * c = a * d + d + b * d`\n  -- the first `_ * c` unifies with `b * c` and moves to the right\n  -- the second `_ * c` unifies with `a * c` and moves to the left\n  congr;\n  assumption\nend\n```\n\nThe list of expressions that `move_add` takes is optional and a single expression can be passed\nwithout brackets.  Thus `move_add ← f` and `move_add [← f]` mean the same.\n\nFinally, `move_add` can also target one or more hypotheses.  If `hp₁, hp₂` are in the\nlocal context, then `move_add [f, ← g] at hp₁ hp₂` performs the rearranging at `hp₁` and `hp₂`.\nAs usual, passing `⊢` refers to acting on the goal.\n\n##  Reporting sub-optimal usage\n\nThe tactic could fail to prove the reordering.  One potential cause is when there are multiple\nmatches for the rearrangements and an earlier rewrite makes a subsequent one fail.  Another\npossibility is that the rearranged expression changes the *Type* of some expression and the\ntactic gets stumped.  Please, report bugs and failures in the Zulip chat!\n\nThere are three kinds of unwanted use for `move_add` that result in errors, where the tactic fails\nand flags the unwanted use.\n1. `move_add [vars]? at *` reports globally unused variables and whether *all* goals\n   are unchanged, not *each unchanged goal*.\n2. If a target of `move_add [vars]? at targets` is left unchanged by the tactic, then this will be\n   flagged (unless we are using `at *`).\n3. If a user-provided expression never unifies, then the variable is flagged.\n\nIn these cases, the tactic produces an error, reporting unused inputs and unchanged targets as\nappropriate.\n\nFor instance, `move_add ← _` always fails reporting an unchanged goal, but never an unused variable.\n\n##  Comparison with existing tactics\n\n* `tactic.interactive.abel`\n  performs a \"reduction to normal form\" that allows it to close goals involving sums with higher\n  success rate than `move_add`.  If the goal is an equality of two sums that are simply obtained by\n  reparenthesizing and permuting summands, then `move_add [appropriate terms]` can close the goal.\n  Compared to `abel`, `move_add` has the advantage of allowing the user to specify the beginning and\n  the end of the final sum, so that from there the user can continue with the proof.\n\n* `tactic.interactive.ac_change`\n  supports a wide variety of operations.  At the moment, `move_add` works with addition, `move_mul`\n  works with multiplication.  There is the possibility of supporting other operations, using the\n  non-interactive tactic `tactic.move_op`.\n  Still, on several experiments, `move_add` had a much quicker performance than `ac_change`.\n  Also, for `move_add` the user need only specify a few terms: the tactic itself takes care of\n  producing the full rearrangement and proving it \"behind the scenes\".\n\n###  Remark:\nIt is still possible that the same output of `move_add [exprs]` can be achieved by a proper sublist\nof `[exprs]`, even if the tactic does not flag anything.  For instance, giving the full re-ordering\nof the expressions in the target that we want to achieve will not complain that there are unused\nvariables, since all the user-provided variables have been matched.  Of course, specifying the order\nof all-but-the-last variable suffices to determine the permutation.  E.g., with a goal of\n`a + b = 0`, applying either one of `move_add [b,a]`, or `move_add a`, or `move_add ← b` has the\nsame effect and changes the goal to `b + a = 0`.  These are all valid uses of `move_add`.\n-/\nmeta def move_add (args : parse move_pexpr_list_or_texpr) (locat : parse location) :\n  tactic unit :=\nmove_op args locat ``((+))\n\n/--  See the doc-string for `tactic.interactive.move_add` and mentally\nreplace addition with multiplication throughout. ;-) -/\nmeta def move_mul (args : parse move_pexpr_list_or_texpr) (locat : parse location) :\n  tactic unit :=\nmove_op args locat ``(has_mul.mul)\n\n/--  `move_oper` behaves like `move_add` except that it also takes an associative, commutative,\nbinary operation as input.  The operation must be passed as a list consisting of a single element.\nFor instance\n```lean\nexample (a b : ℕ) : max a b = max b a :=\nby move_oper [max] [← a, b] at *\n```\nsolves the goal.  For more details, see the `move_add` doc-string, replacing `add` with your\nintended operation.\n-/\nmeta def move_oper\n  (op : parse pexpr_list) (args : parse move_pexpr_list_or_texpr) (locat : parse location) :\n  tactic unit := do\n[op] ← pure op | fail \"only one operation is allowed\",\nmove_op args locat op\n\nadd_tactic_doc\n{ name := \"move_add\",\n  category := doc_category.tactic,\n  decl_names := [`tactic.interactive.move_add],\n  tags := [\"arithmetic\"] }\n\nadd_tactic_doc\n{ name := \"move_mul\",\n  category := doc_category.tactic,\n  decl_names := [`tactic.interactive.move_mul],\n  tags := [\"arithmetic\"] }\n\nend interactive\nend tactic\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/tactic/move_add.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.4721477728968451}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Kevin Buzzard, Scott Morrison, Johan Commelin, Chris Hughes,\n  Johannes Hölzl, Yury Kudryashov\n\n! This file was ported from Lean 3 source module algebra.hom.commute\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Hom.Group\nimport Mathbin.Algebra.Group.Commute\n\n/-!\n# Multiplicative homomorphisms respect semiconjugation and commutation.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nsection Commute\n\nvariable {F M N : Type _} [Mul M] [Mul N] {a x y : M}\n\n/- warning: semiconj_by.map -> SemiconjBy.map is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u3} N] {a : M} {x : M} {y : M} [_inst_3 : MulHomClass.{u1, u2, u3} F M N _inst_1 _inst_2], (SemiconjBy.{u2} M _inst_1 a x y) -> (forall (f : F), SemiconjBy.{u3} N _inst_2 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u1, u2, u3} F M N _inst_1 _inst_2 _inst_3)) f a) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u1, u2, u3} F M N _inst_1 _inst_2 _inst_3)) f x) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u1, u2, u3} F M N _inst_1 _inst_2 _inst_3)) f y))\nbut is expected to have type\n  forall {F : Type.{u3}} {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] {a : M} {x : M} {y : M} [_inst_3 : MulHomClass.{u3, u2, u1} F M N _inst_1 _inst_2], (SemiconjBy.{u2} M _inst_1 a x y) -> (forall (f : F), SemiconjBy.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) a) _inst_2 (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f a) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f x) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f y))\nCase conversion may be inaccurate. Consider using '#align semiconj_by.map SemiconjBy.mapₓ'. -/\n@[simp, to_additive]\nprotected theorem SemiconjBy.map [MulHomClass F M N] (h : SemiconjBy a x y) (f : F) :\n    SemiconjBy (f a) (f x) (f y) := by simpa only [SemiconjBy, map_mul] using congr_arg f h\n#align semiconj_by.map SemiconjBy.map\n#align add_semiconj_by.map AddSemiconjBy.map\n\n/- warning: commute.map -> Commute.map is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u3} N] {x : M} {y : M} [_inst_3 : MulHomClass.{u1, u2, u3} F M N _inst_1 _inst_2], (Commute.{u2} M _inst_1 x y) -> (forall (f : F), Commute.{u3} N _inst_2 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u1, u2, u3} F M N _inst_1 _inst_2 _inst_3)) f x) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => M -> N) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F M (fun (_x : M) => N) (MulHomClass.toFunLike.{u1, u2, u3} F M N _inst_1 _inst_2 _inst_3)) f y))\nbut is expected to have type\n  forall {F : Type.{u3}} {M : Type.{u2}} {N : Type.{u1}} [_inst_1 : Mul.{u2} M] [_inst_2 : Mul.{u1} N] {x : M} {y : M} [_inst_3 : MulHomClass.{u3, u2, u1} F M N _inst_1 _inst_2], (Commute.{u2} M _inst_1 x y) -> (forall (f : F), Commute.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) _inst_2 (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f x) (FunLike.coe.{succ u3, succ u2, succ u1} F M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{u3, u2, u1} F M N _inst_1 _inst_2 _inst_3) f y))\nCase conversion may be inaccurate. Consider using '#align commute.map Commute.mapₓ'. -/\n@[simp, to_additive]\nprotected theorem Commute.map [MulHomClass F M N] (h : Commute x y) (f : F) : Commute (f x) (f y) :=\n  h.map f\n#align commute.map Commute.map\n#align add_commute.map AddCommute.map\n\nend Commute\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Hom/Commute.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.47214777082795967}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Jeremy Avigad, Yury Kudryashov\n\n! This file was ported from Lean 3 source module order.filter.ultrafilter\n! leanprover-community/mathlib commit 4d392a6c9c4539cbeca399b3ee0afea398fbd2eb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Filter.Cofinite\nimport Mathbin.Order.ZornAtoms\n\n/-!\n# Ultrafilters\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nAn ultrafilter is a minimal (maximal in the set order) proper filter.\nIn this file we define\n\n* `ultrafilter.of`: an ultrafilter that is less than or equal to a given filter;\n* `ultrafilter`: subtype of ultrafilters;\n* `ultrafilter.pure`: `pure x` as an `ultrafiler`;\n* `ultrafilter.map`, `ultrafilter.bind`, `ultrafilter.comap` : operations on ultrafilters;\n* `hyperfilter`: the ultrafilter extending the cofinite filter.\n-/\n\n\nuniverse u v\n\nvariable {α : Type u} {β : Type v} {γ : Type _}\n\nopen Set Filter Function\n\nopen Classical Filter\n\n/-- `filter α` is an atomic type: for every filter there exists an ultrafilter that is less than or\nequal to this filter. -/\ninstance : IsAtomic (Filter α) :=\n  IsAtomic.of_isChain_bounded fun c hc hne hb =>\n    ⟨infₛ c, (infₛ_neBot_of_directed' hne (show IsChain (· ≥ ·) c from hc.symm).DirectedOn hb).Ne,\n      fun x hx => infₛ_le hx⟩\n\n#print Ultrafilter /-\n/-- An ultrafilter is a minimal (maximal in the set order) proper filter. -/\n@[protect_proj]\nstructure Ultrafilter (α : Type _) extends Filter α where\n  ne_bot' : NeBot to_filter\n  le_of_le : ∀ g, Filter.NeBot g → g ≤ to_filter → to_filter ≤ g\n#align ultrafilter Ultrafilter\n-/\n\nnamespace Ultrafilter\n\nvariable {f g : Ultrafilter α} {s t : Set α} {p q : α → Prop}\n\ninstance : CoeTC (Ultrafilter α) (Filter α) :=\n  ⟨Ultrafilter.toFilter⟩\n\ninstance : Membership (Set α) (Ultrafilter α) :=\n  ⟨fun s f => s ∈ (f : Filter α)⟩\n\n/- warning: ultrafilter.unique -> Ultrafilter.unique is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) {g : Filter.{u1} α}, (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f)) -> (autoParamₓ.{0} (Filter.NeBot.{u1} α g) (Name.mk_string (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str (String.str String.empty (Char.ofNat (OfNat.ofNat.{0} Nat 97 (OfNat.mk.{0} Nat 97 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 112 (OfNat.mk.{0} Nat 112 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 112 (OfNat.mk.{0} Nat 112 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 108 (OfNat.mk.{0} Nat 108 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 121 (OfNat.mk.{0} Nat 121 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 95 (OfNat.mk.{0} Nat 95 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 105 (OfNat.mk.{0} Nat 105 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 110 (OfNat.mk.{0} Nat 110 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 115 (OfNat.mk.{0} Nat 115 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 116 (OfNat.mk.{0} Nat 116 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 97 (OfNat.mk.{0} Nat 97 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 110 (OfNat.mk.{0} Nat 110 (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 99 (OfNat.mk.{0} Nat 99 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 101 (OfNat.mk.{0} Nat 101 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Name.mk_string (String.str (String.str (String.str (String.str (String.str (String.str String.empty (Char.ofNat (OfNat.ofNat.{0} Nat 116 (OfNat.mk.{0} Nat 116 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 97 (OfNat.mk.{0} Nat 97 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 99 (OfNat.mk.{0} Nat 99 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 116 (OfNat.mk.{0} Nat 116 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 105 (OfNat.mk.{0} Nat 105 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) (Char.ofNat (OfNat.ofNat.{0} Nat 99 (OfNat.mk.{0} Nat 99 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))))))) Name.anonymous))) -> (Eq.{succ u1} (Filter.{u1} α) g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f))\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) {g : Filter.{u1} α}, (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) g (Ultrafilter.toFilter.{u1} α f)) -> (autoParam.{0} (Filter.NeBot.{u1} α g) _auto._@.Mathlib.Order.Filter.Ultrafilter._hyg.261) -> (Eq.{succ u1} (Filter.{u1} α) g (Ultrafilter.toFilter.{u1} α f))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.unique Ultrafilter.uniqueₓ'. -/\ntheorem unique (f : Ultrafilter α) {g : Filter α} (h : g ≤ f) (hne : NeBot g := by infer_instance) :\n    g = f :=\n  le_antisymm h <| f.le_of_le g hne h\n#align ultrafilter.unique Ultrafilter.unique\n\n#print Ultrafilter.neBot /-\ninstance neBot (f : Ultrafilter α) : NeBot (f : Filter α) :=\n  f.ne_bot'\n#align ultrafilter.ne_bot Ultrafilter.neBot\n-/\n\n/- warning: ultrafilter.is_atom -> Ultrafilter.isAtom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α), IsAtom.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α), IsAtom.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.is_atom Ultrafilter.isAtomₓ'. -/\nprotected theorem isAtom (f : Ultrafilter α) : IsAtom (f : Filter α) :=\n  ⟨f.ne_bot.Ne, fun g hgf => by_contra fun hg => hgf.Ne <| f.unique hgf.le ⟨hg⟩⟩\n#align ultrafilter.is_atom Ultrafilter.isAtom\n\n#print Ultrafilter.mem_coe /-\n@[simp, norm_cast]\ntheorem mem_coe : s ∈ (f : Filter α) ↔ s ∈ f :=\n  Iff.rfl\n#align ultrafilter.mem_coe Ultrafilter.mem_coe\n-/\n\n#print Ultrafilter.coe_injective /-\ntheorem coe_injective : Injective (coe : Ultrafilter α → Filter α)\n  | ⟨f, h₁, h₂⟩, ⟨g, h₃, h₄⟩, rfl => by congr\n#align ultrafilter.coe_injective Ultrafilter.coe_injective\n-/\n\n/- warning: ultrafilter.eq_of_le -> Ultrafilter.eq_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Ultrafilter.{u1} α}, (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g)) -> (Eq.{succ u1} (Ultrafilter.{u1} α) f g)\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Ultrafilter.{u1} α}, (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) (Ultrafilter.toFilter.{u1} α g)) -> (Eq.{succ u1} (Ultrafilter.{u1} α) f g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.eq_of_le Ultrafilter.eq_of_leₓ'. -/\ntheorem eq_of_le {f g : Ultrafilter α} (h : (f : Filter α) ≤ g) : f = g :=\n  coe_injective (g.unique h)\n#align ultrafilter.eq_of_le Ultrafilter.eq_of_le\n\n/- warning: ultrafilter.coe_le_coe -> Ultrafilter.coe_le_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Ultrafilter.{u1} α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g)) (Eq.{succ u1} (Ultrafilter.{u1} α) f g)\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Ultrafilter.{u1} α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) (Ultrafilter.toFilter.{u1} α g)) (Eq.{succ u1} (Ultrafilter.{u1} α) f g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.coe_le_coe Ultrafilter.coe_le_coeₓ'. -/\n@[simp, norm_cast]\ntheorem coe_le_coe {f g : Ultrafilter α} : (f : Filter α) ≤ g ↔ f = g :=\n  ⟨fun h => eq_of_le h, fun h => h ▸ le_rfl⟩\n#align ultrafilter.coe_le_coe Ultrafilter.coe_le_coe\n\n#print Ultrafilter.coe_inj /-\n@[simp, norm_cast]\ntheorem coe_inj : (f : Filter α) = g ↔ f = g :=\n  coe_injective.eq_iff\n#align ultrafilter.coe_inj Ultrafilter.coe_inj\n-/\n\n#print Ultrafilter.ext /-\n@[ext]\ntheorem ext ⦃f g : Ultrafilter α⦄ (h : ∀ s, s ∈ f ↔ s ∈ g) : f = g :=\n  coe_injective <| Filter.ext h\n#align ultrafilter.ext Ultrafilter.ext\n-/\n\n/- warning: ultrafilter.le_of_inf_ne_bot -> Ultrafilter.le_of_inf_neBot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) {g : Filter.{u1} α}, (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g)) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) {g : Filter.{u1} α}, (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (Ultrafilter.toFilter.{u1} α f) g)) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_of_inf_ne_bot Ultrafilter.le_of_inf_neBotₓ'. -/\ntheorem le_of_inf_neBot (f : Ultrafilter α) {g : Filter α} (hg : NeBot (↑f ⊓ g)) : ↑f ≤ g :=\n  le_of_inf_eq (f.unique inf_le_left hg)\n#align ultrafilter.le_of_inf_ne_bot Ultrafilter.le_of_inf_neBot\n\n/- warning: ultrafilter.le_of_inf_ne_bot' -> Ultrafilter.le_of_inf_neBot' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) {g : Filter.{u1} α}, (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f))) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) {g : Filter.{u1} α}, (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) g (Ultrafilter.toFilter.{u1} α f))) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_of_inf_ne_bot' Ultrafilter.le_of_inf_neBot'ₓ'. -/\ntheorem le_of_inf_neBot' (f : Ultrafilter α) {g : Filter α} (hg : NeBot (g ⊓ f)) : ↑f ≤ g :=\n  f.le_of_inf_neBot <| by rwa [inf_comm]\n#align ultrafilter.le_of_inf_ne_bot' Ultrafilter.le_of_inf_neBot'\n\n/- warning: ultrafilter.inf_ne_bot_iff -> Ultrafilter.inf_neBot_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Filter.{u1} α}, Iff (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g)) (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g)\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Filter.{u1} α}, Iff (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (Ultrafilter.toFilter.{u1} α f) g)) (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.inf_ne_bot_iff Ultrafilter.inf_neBot_iffₓ'. -/\ntheorem inf_neBot_iff {f : Ultrafilter α} {g : Filter α} : NeBot (↑f ⊓ g) ↔ ↑f ≤ g :=\n  ⟨le_of_inf_neBot f, fun h => (inf_of_le_left h).symm ▸ f.ne_bot⟩\n#align ultrafilter.inf_ne_bot_iff Ultrafilter.inf_neBot_iff\n\n/- warning: ultrafilter.disjoint_iff_not_le -> Ultrafilter.disjoint_iff_not_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Filter.{u1} α}, Iff (Disjoint.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g) (Not (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {g : Filter.{u1} α}, Iff (Disjoint.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) g) (Not (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) g))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.disjoint_iff_not_le Ultrafilter.disjoint_iff_not_leₓ'. -/\ntheorem disjoint_iff_not_le {f : Ultrafilter α} {g : Filter α} : Disjoint (↑f) g ↔ ¬↑f ≤ g := by\n  rw [← inf_ne_bot_iff, ne_bot_iff, Ne.def, Classical.not_not, disjoint_iff]\n#align ultrafilter.disjoint_iff_not_le Ultrafilter.disjoint_iff_not_le\n\n/- warning: ultrafilter.compl_not_mem_iff -> Ultrafilter.compl_not_mem_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α}, Iff (Not (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) f)) (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s f)\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α}, Iff (Not (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) f)) (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.compl_not_mem_iff Ultrafilter.compl_not_mem_iffₓ'. -/\n@[simp]\ntheorem compl_not_mem_iff : sᶜ ∉ f ↔ s ∈ f :=\n  ⟨fun hsc =>\n    le_principal_iff.1 <| f.le_of_inf_neBot ⟨fun h => hsc <| mem_of_eq_bot <| by rwa [compl_compl]⟩,\n    compl_not_mem⟩\n#align ultrafilter.compl_not_mem_iff Ultrafilter.compl_not_mem_iff\n\n#print Ultrafilter.frequently_iff_eventually /-\n@[simp]\ntheorem frequently_iff_eventually : (∃ᶠ x in f, p x) ↔ ∀ᶠ x in f, p x :=\n  compl_not_mem_iff\n#align ultrafilter.frequently_iff_eventually Ultrafilter.frequently_iff_eventually\n-/\n\nalias frequently_iff_eventually ↔ _root_.filter.frequently.eventually _\n#align filter.frequently.eventually Filter.Frequently.eventually\n\n/- warning: ultrafilter.compl_mem_iff_not_mem -> Ultrafilter.compl_mem_iff_not_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) f) (Not (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s f))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) f) (Not (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s f))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.compl_mem_iff_not_mem Ultrafilter.compl_mem_iff_not_memₓ'. -/\ntheorem compl_mem_iff_not_mem : sᶜ ∈ f ↔ s ∉ f := by rw [← compl_not_mem_iff, compl_compl]\n#align ultrafilter.compl_mem_iff_not_mem Ultrafilter.compl_mem_iff_not_mem\n\n/- warning: ultrafilter.diff_mem_iff -> Ultrafilter.diff_mem_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} (f : Ultrafilter.{u1} α), Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s t) f) (And (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s f) (Not (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) t f)))\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} α} {t : Set.{u1} α} (f : Ultrafilter.{u1} α), Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (Set.instSDiffSet.{u1} α) s t) f) (And (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s f) (Not (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) t f)))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.diff_mem_iff Ultrafilter.diff_mem_iffₓ'. -/\ntheorem diff_mem_iff (f : Ultrafilter α) : s \\ t ∈ f ↔ s ∈ f ∧ t ∉ f :=\n  inter_mem_iff.trans <| and_congr Iff.rfl compl_mem_iff_not_mem\n#align ultrafilter.diff_mem_iff Ultrafilter.diff_mem_iff\n\n/- warning: ultrafilter.of_compl_not_mem_iff -> Ultrafilter.ofComplNotMemIff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Filter.{u1} α), (forall (s : Set.{u1} α), Iff (Not (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) f)) (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s f)) -> (Ultrafilter.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Filter.{u1} α), (forall (s : Set.{u1} α), Iff (Not (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) f)) (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s f)) -> (Ultrafilter.{u1} α)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.of_compl_not_mem_iff Ultrafilter.ofComplNotMemIffₓ'. -/\n/-- If `sᶜ ∉ f ↔ s ∈ f`, then `f` is an ultrafilter. The other implication is given by\n`ultrafilter.compl_not_mem_iff`.  -/\ndef ofComplNotMemIff (f : Filter α) (h : ∀ s, sᶜ ∉ f ↔ s ∈ f) : Ultrafilter α\n    where\n  toFilter := f\n  ne_bot' := ⟨fun hf => by simpa [hf] using h⟩\n  le_of_le g hg hgf s hs := (h s).1 fun hsc => compl_not_mem hs (hgf hsc)\n#align ultrafilter.of_compl_not_mem_iff Ultrafilter.ofComplNotMemIff\n\n/- warning: ultrafilter.of_atom -> Ultrafilter.ofAtom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Filter.{u1} α), (IsAtom.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) f) -> (Ultrafilter.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Filter.{u1} α), (IsAtom.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) f) -> (Ultrafilter.{u1} α)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.of_atom Ultrafilter.ofAtomₓ'. -/\n/-- If `f : filter α` is an atom, then it is an ultrafilter. -/\ndef ofAtom (f : Filter α) (hf : IsAtom f) : Ultrafilter α\n    where\n  toFilter := f\n  ne_bot' := ⟨hf.1⟩\n  le_of_le g hg := (isAtom_iff.1 hf).2 g hg.Ne\n#align ultrafilter.of_atom Ultrafilter.ofAtom\n\n#print Ultrafilter.nonempty_of_mem /-\ntheorem nonempty_of_mem (hs : s ∈ f) : s.Nonempty :=\n  nonempty_of_mem hs\n#align ultrafilter.nonempty_of_mem Ultrafilter.nonempty_of_mem\n-/\n\n#print Ultrafilter.ne_empty_of_mem /-\ntheorem ne_empty_of_mem (hs : s ∈ f) : s ≠ ∅ :=\n  (nonempty_of_mem hs).ne_empty\n#align ultrafilter.ne_empty_of_mem Ultrafilter.ne_empty_of_mem\n-/\n\n#print Ultrafilter.empty_not_mem /-\n@[simp]\ntheorem empty_not_mem : ∅ ∉ f :=\n  empty_not_mem f\n#align ultrafilter.empty_not_mem Ultrafilter.empty_not_mem\n-/\n\n/- warning: ultrafilter.le_sup_iff -> Ultrafilter.le_sup_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {u : Ultrafilter.{u1} α} {f : Filter.{u1} α} {g : Filter.{u1} α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) u) (Sup.sup.{u1} (Filter.{u1} α) (SemilatticeSup.toHasSup.{u1} (Filter.{u1} α) (Lattice.toSemilatticeSup.{u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toLattice.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))))) f g)) (Or (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) u) f) (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) u) g))\nbut is expected to have type\n  forall {α : Type.{u1}} {u : Ultrafilter.{u1} α} {f : Filter.{u1} α} {g : Filter.{u1} α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α u) (Sup.sup.{u1} (Filter.{u1} α) (SemilatticeSup.toSup.{u1} (Filter.{u1} α) (Lattice.toSemilatticeSup.{u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toLattice.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))))) f g)) (Or (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α u) f) (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α u) g))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_sup_iff Ultrafilter.le_sup_iffₓ'. -/\n@[simp]\ntheorem le_sup_iff {u : Ultrafilter α} {f g : Filter α} : ↑u ≤ f ⊔ g ↔ ↑u ≤ f ∨ ↑u ≤ g :=\n  not_iff_not.1 <| by simp only [← disjoint_iff_not_le, not_or, disjoint_sup_right]\n#align ultrafilter.le_sup_iff Ultrafilter.le_sup_iff\n\n/- warning: ultrafilter.union_mem_iff -> Ultrafilter.union_mem_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t) f) (Or (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s f) (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) t f))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α} {t : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t) f) (Or (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s f) (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) t f))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.union_mem_iff Ultrafilter.union_mem_iffₓ'. -/\n@[simp]\ntheorem union_mem_iff : s ∪ t ∈ f ↔ s ∈ f ∨ t ∈ f := by\n  simp only [← mem_coe, ← le_principal_iff, ← sup_principal, le_sup_iff]\n#align ultrafilter.union_mem_iff Ultrafilter.union_mem_iff\n\n/- warning: ultrafilter.mem_or_compl_mem -> Ultrafilter.mem_or_compl_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) (s : Set.{u1} α), Or (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s f) (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) f)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α) (s : Set.{u1} α), Or (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s f) (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.mem_or_compl_mem Ultrafilter.mem_or_compl_memₓ'. -/\ntheorem mem_or_compl_mem (f : Ultrafilter α) (s : Set α) : s ∈ f ∨ sᶜ ∈ f :=\n  or_iff_not_imp_left.2 compl_mem_iff_not_mem.2\n#align ultrafilter.mem_or_compl_mem Ultrafilter.mem_or_compl_mem\n\n#print Ultrafilter.em /-\nprotected theorem em (f : Ultrafilter α) (p : α → Prop) : (∀ᶠ x in f, p x) ∨ ∀ᶠ x in f, ¬p x :=\n  f.mem_or_compl_mem { x | p x }\n#align ultrafilter.em Ultrafilter.em\n-/\n\n#print Ultrafilter.eventually_or /-\ntheorem eventually_or : (∀ᶠ x in f, p x ∨ q x) ↔ (∀ᶠ x in f, p x) ∨ ∀ᶠ x in f, q x :=\n  union_mem_iff\n#align ultrafilter.eventually_or Ultrafilter.eventually_or\n-/\n\n#print Ultrafilter.eventually_not /-\ntheorem eventually_not : (∀ᶠ x in f, ¬p x) ↔ ¬∀ᶠ x in f, p x :=\n  compl_mem_iff_not_mem\n#align ultrafilter.eventually_not Ultrafilter.eventually_not\n-/\n\n#print Ultrafilter.eventually_imp /-\ntheorem eventually_imp : (∀ᶠ x in f, p x → q x) ↔ (∀ᶠ x in f, p x) → ∀ᶠ x in f, q x := by\n  simp only [imp_iff_not_or, eventually_or, eventually_not]\n#align ultrafilter.eventually_imp Ultrafilter.eventually_imp\n-/\n\n/- warning: ultrafilter.finite_sUnion_mem_iff -> Ultrafilter.finite_unionₛ_mem_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} (Set.{u1} α)}, (Set.Finite.{u1} (Set.{u1} α) s) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (Set.unionₛ.{u1} α s) f) (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t s) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t s) => Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) t f))))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} (Set.{u1} α)}, (Set.Finite.{u1} (Set.{u1} α) s) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (Set.unionₛ.{u1} α s) f) (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) t s) (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) t f))))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.finite_sUnion_mem_iff Ultrafilter.finite_unionₛ_mem_iffₓ'. -/\ntheorem finite_unionₛ_mem_iff {s : Set (Set α)} (hs : s.Finite) : ⋃₀ s ∈ f ↔ ∃ t ∈ s, t ∈ f :=\n  Finite.induction_on hs (by simp) fun a s ha hs his => by\n    simp [union_mem_iff, his, or_and_right, exists_or]\n#align ultrafilter.finite_sUnion_mem_iff Ultrafilter.finite_unionₛ_mem_iff\n\n/- warning: ultrafilter.finite_bUnion_mem_iff -> Ultrafilter.finite_bunionᵢ_mem_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : Ultrafilter.{u1} α} {is : Set.{u2} β} {s : β -> (Set.{u1} α)}, (Set.Finite.{u2} β is) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (Set.unionᵢ.{u1, succ u2} α β (fun (i : β) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) i is) (fun (H : Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) i is) => s i))) f) (Exists.{succ u2} β (fun (i : β) => Exists.{0} (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) i is) (fun (H : Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) i is) => Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (s i) f))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : Ultrafilter.{u1} α} {is : Set.{u2} β} {s : β -> (Set.{u1} α)}, (Set.Finite.{u2} β is) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (Set.unionᵢ.{u1, succ u2} α β (fun (i : β) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) i is) (fun (H : Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) i is) => s i))) f) (Exists.{succ u2} β (fun (i : β) => And (Membership.mem.{u2, u2} β (Set.{u2} β) (Set.instMembershipSet.{u2} β) i is) (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (s i) f))))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.finite_bUnion_mem_iff Ultrafilter.finite_bunionᵢ_mem_iffₓ'. -/\ntheorem finite_bunionᵢ_mem_iff {is : Set β} {s : β → Set α} (his : is.Finite) :\n    (⋃ i ∈ is, s i) ∈ f ↔ ∃ i ∈ is, s i ∈ f := by\n  simp only [← sUnion_image, finite_sUnion_mem_iff (his.image s), bex_image_iff]\n#align ultrafilter.finite_bUnion_mem_iff Ultrafilter.finite_bunionᵢ_mem_iff\n\n#print Ultrafilter.map /-\n/-- Pushforward for ultrafilters. -/\ndef map (m : α → β) (f : Ultrafilter α) : Ultrafilter β :=\n  ofComplNotMemIff (map m f) fun s => @compl_not_mem_iff _ f (m ⁻¹' s)\n#align ultrafilter.map Ultrafilter.map\n-/\n\n#print Ultrafilter.coe_map /-\n@[simp, norm_cast]\ntheorem coe_map (m : α → β) (f : Ultrafilter α) : (map m f : Filter β) = Filter.map m ↑f :=\n  rfl\n#align ultrafilter.coe_map Ultrafilter.coe_map\n-/\n\n#print Ultrafilter.mem_map /-\n@[simp]\ntheorem mem_map {m : α → β} {f : Ultrafilter α} {s : Set β} : s ∈ map m f ↔ m ⁻¹' s ∈ f :=\n  Iff.rfl\n#align ultrafilter.mem_map Ultrafilter.mem_map\n-/\n\n#print Ultrafilter.map_id /-\n@[simp]\ntheorem map_id (f : Ultrafilter α) : f.map id = f :=\n  coe_injective map_id\n#align ultrafilter.map_id Ultrafilter.map_id\n-/\n\n#print Ultrafilter.map_id' /-\n@[simp]\ntheorem map_id' (f : Ultrafilter α) : (f.map fun x => x) = f :=\n  map_id _\n#align ultrafilter.map_id' Ultrafilter.map_id'\n-/\n\n/- warning: ultrafilter.map_map -> Ultrafilter.map_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : Ultrafilter.{u1} α) (m : α -> β) (n : β -> γ), Eq.{succ u3} (Ultrafilter.{u3} γ) (Ultrafilter.map.{u2, u3} β γ n (Ultrafilter.map.{u1, u2} α β m f)) (Ultrafilter.map.{u1, u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ n m) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} (f : Ultrafilter.{u2} α) (m : α -> β) (n : β -> γ), Eq.{succ u1} (Ultrafilter.{u1} γ) (Ultrafilter.map.{u3, u1} β γ n (Ultrafilter.map.{u2, u3} α β m f)) (Ultrafilter.map.{u2, u1} α γ (Function.comp.{succ u2, succ u3, succ u1} α β γ n m) f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.map_map Ultrafilter.map_mapₓ'. -/\n@[simp]\ntheorem map_map (f : Ultrafilter α) (m : α → β) (n : β → γ) : (f.map m).map n = f.map (n ∘ m) :=\n  coe_injective map_map\n#align ultrafilter.map_map Ultrafilter.map_map\n\n#print Ultrafilter.comap /-\n/-- The pullback of an ultrafilter along an injection whose range is large with respect to the given\nultrafilter. -/\ndef comap {m : α → β} (u : Ultrafilter β) (inj : Injective m) (large : Set.range m ∈ u) :\n    Ultrafilter α where\n  toFilter := comap m u\n  ne_bot' := u.ne_bot'.comap_of_range_mem large\n  le_of_le g hg hgu := by\n    skip\n    simp only [← u.unique (map_le_iff_le_comap.2 hgu), comap_map inj, le_rfl]\n#align ultrafilter.comap Ultrafilter.comap\n-/\n\n#print Ultrafilter.mem_comap /-\n@[simp]\ntheorem mem_comap {m : α → β} (u : Ultrafilter β) (inj : Injective m) (large : Set.range m ∈ u)\n    {s : Set α} : s ∈ u.comap inj large ↔ m '' s ∈ u :=\n  mem_comap_iff inj large\n#align ultrafilter.mem_comap Ultrafilter.mem_comap\n-/\n\n#print Ultrafilter.coe_comap /-\n@[simp, norm_cast]\ntheorem coe_comap {m : α → β} (u : Ultrafilter β) (inj : Injective m) (large : Set.range m ∈ u) :\n    (u.comap inj large : Filter α) = Filter.comap m u :=\n  rfl\n#align ultrafilter.coe_comap Ultrafilter.coe_comap\n-/\n\n#print Ultrafilter.comap_id /-\n@[simp]\ntheorem comap_id (f : Ultrafilter α) (h₀ : Injective (id : α → α) := injective_id)\n    (h₁ : range id ∈ f :=\n      (by\n        rw [range_id]\n        exact univ_mem)) :\n    f.comap h₀ h₁ = f :=\n  coe_injective comap_id\n#align ultrafilter.comap_id Ultrafilter.comap_id\n-/\n\n/- warning: ultrafilter.comap_comap -> Ultrafilter.comap_comap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : Ultrafilter.{u3} γ) {m : α -> β} {n : β -> γ} (inj₀ : Function.Injective.{succ u2, succ u3} β γ n) (large₀ : Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.range.{u3, succ u2} γ β n) f) (inj₁ : Function.Injective.{succ u1, succ u2} α β m) (large₁ : Membership.Mem.{u2, u2} (Set.{u2} β) (Ultrafilter.{u2} β) (Ultrafilter.hasMem.{u2} β) (Set.range.{u2, succ u1} β α m) (Ultrafilter.comap.{u2, u3} β γ n f inj₀ large₀)) (inj₂ : optParam.{0} (Function.Injective.{succ u1, succ u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ n m)) (Function.Injective.comp.{succ u1, succ u2, succ u3} α β γ n m inj₀ inj₁)) (large₂ : optParam.{0} (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.range.{u3, succ u1} γ α (Function.comp.{succ u1, succ u2, succ u3} α β γ n m)) f) (Eq.mpr.{0} (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.range.{u3, succ u1} γ α (Function.comp.{succ u1, succ u2, succ u3} α β γ n m)) f) (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.image.{u2, u3} β γ n (Set.range.{u2, succ u1} β α m)) f) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.range.{u3, succ u1} γ α (Function.comp.{succ u1, succ u2, succ u3} α β γ n m)) f) (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.image.{u2, u3} β γ n (Set.range.{u2, succ u1} β α m)) f)) (Eq.ndrec.{0, succ u3} (Set.{u3} γ) (Set.range.{u3, succ u1} γ α (Function.comp.{succ u1, succ u2, succ u3} α β γ n m)) (fun (_a : Set.{u3} γ) => Eq.{1} Prop (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.range.{u3, succ u1} γ α (Function.comp.{succ u1, succ u2, succ u3} α β γ n m)) f) (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) _a f)) (rfl.{1} Prop (Membership.Mem.{u3, u3} (Set.{u3} γ) (Ultrafilter.{u3} γ) (Ultrafilter.hasMem.{u3} γ) (Set.range.{u3, succ u1} γ α (Function.comp.{succ u1, succ u2, succ u3} α β γ n m)) f)) (Set.image.{u2, u3} β γ n (Set.range.{u2, succ u1} β α m)) (Set.range_comp.{u2, u3, succ u1} β γ α n m))) (Filter.image_mem_of_mem_comap.{u3, u2} γ β ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Ultrafilter.{u3} γ) (Filter.{u3} γ) (HasLiftT.mk.{succ u3, succ u3} (Ultrafilter.{u3} γ) (Filter.{u3} γ) (CoeTCₓ.coe.{succ u3, succ u3} (Ultrafilter.{u3} γ) (Filter.{u3} γ) (Ultrafilter.Filter.hasCoeT.{u3} γ))) f) n large₀ (Set.range.{u2, succ u1} β α m) large₁))), Eq.{succ u1} (Ultrafilter.{u1} α) (Ultrafilter.comap.{u1, u2} α β m (Ultrafilter.comap.{u2, u3} β γ n f inj₀ large₀) inj₁ large₁) (Ultrafilter.comap.{u1, u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ n m) f inj₂ large₂)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} (f : Ultrafilter.{u1} γ) {m : α -> β} {n : β -> γ} (inj₀ : Function.Injective.{succ u3, succ u1} β γ n) (large₀ : Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.range.{u1, succ u3} γ β n) f) (inj₁ : Function.Injective.{succ u2, succ u3} α β m) (large₁ : Membership.mem.{u3, u3} (Set.{u3} β) (Ultrafilter.{u3} β) (Ultrafilter.instMembershipSetUltrafilter.{u3} β) (Set.range.{u3, succ u2} β α m) (Ultrafilter.comap.{u3, u1} β γ n f inj₀ large₀)) (inj₂ : optParam.{0} (Function.Injective.{succ u2, succ u1} α γ (Function.comp.{succ u2, succ u3, succ u1} α β γ n m)) (Function.Injective.comp.{succ u2, succ u3, succ u1} α β γ n m inj₀ inj₁)) (large₂ : optParam.{0} (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.range.{u1, succ u2} γ α (Function.comp.{succ u2, succ u3, succ u1} α β γ n m)) f) (Eq.mpr.{0} (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.range.{u1, succ u2} γ α (Function.comp.{succ u2, succ u3, succ u1} α β γ n m)) f) (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.image.{u3, u1} β γ n (Set.range.{u3, succ u2} β α m)) f) (id.{0} (Eq.{1} Prop (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.range.{u1, succ u2} γ α (Function.comp.{succ u2, succ u3, succ u1} α β γ n m)) f) (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.image.{u3, u1} β γ n (Set.range.{u3, succ u2} β α m)) f)) (Eq.ndrec.{0, succ u1} (Set.{u1} γ) (Set.range.{u1, succ u2} γ α (Function.comp.{succ u2, succ u3, succ u1} α β γ n m)) (fun (_a : Set.{u1} γ) => Eq.{1} Prop (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.range.{u1, succ u2} γ α (Function.comp.{succ u2, succ u3, succ u1} α β γ n m)) f) (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) _a f)) (Eq.refl.{1} Prop (Membership.mem.{u1, u1} (Set.{u1} γ) (Ultrafilter.{u1} γ) (Ultrafilter.instMembershipSetUltrafilter.{u1} γ) (Set.range.{u1, succ u2} γ α (Function.comp.{succ u2, succ u3, succ u1} α β γ n m)) f)) (Set.image.{u3, u1} β γ n (Set.range.{u3, succ u2} β α m)) (Set.range_comp.{u3, succ u2, u1} β γ α n m))) (Filter.image_mem_of_mem_comap.{u1, u3} γ β (Ultrafilter.toFilter.{u1} γ f) n large₀ (Set.range.{u3, succ u2} β α m) large₁))), Eq.{succ u2} (Ultrafilter.{u2} α) (Ultrafilter.comap.{u2, u3} α β m (Ultrafilter.comap.{u3, u1} β γ n f inj₀ large₀) inj₁ large₁) (Ultrafilter.comap.{u2, u1} α γ (Function.comp.{succ u2, succ u3, succ u1} α β γ n m) f inj₂ large₂)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.comap_comap Ultrafilter.comap_comapₓ'. -/\n@[simp]\ntheorem comap_comap (f : Ultrafilter γ) {m : α → β} {n : β → γ} (inj₀ : Injective n)\n    (large₀ : range n ∈ f) (inj₁ : Injective m) (large₁ : range m ∈ f.comap inj₀ large₀)\n    (inj₂ : Injective (n ∘ m) := inj₀.comp inj₁)\n    (large₂ : range (n ∘ m) ∈ f :=\n      (by\n        rw [range_comp]\n        exact image_mem_of_mem_comap large₀ large₁)) :\n    (f.comap inj₀ large₀).comap inj₁ large₁ = f.comap inj₂ large₂ :=\n  coe_injective comap_comap\n#align ultrafilter.comap_comap Ultrafilter.comap_comap\n\n/-- The principal ultrafilter associated to a point `x`. -/\ninstance : Pure Ultrafilter :=\n  ⟨fun α a => ofComplNotMemIff (pure a) fun s => by simp⟩\n\n/- warning: ultrafilter.mem_pure -> Ultrafilter.mem_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} α a)) (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a s)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α a)) (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a s)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.mem_pure Ultrafilter.mem_pureₓ'. -/\n@[simp]\ntheorem mem_pure {a : α} {s : Set α} : s ∈ (pure a : Ultrafilter α) ↔ a ∈ s :=\n  Iff.rfl\n#align ultrafilter.mem_pure Ultrafilter.mem_pure\n\n/- warning: ultrafilter.coe_pure -> Ultrafilter.coe_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Filter.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} α a)) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Filter.{u1} α) (Ultrafilter.toFilter.{u1} α (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α a)) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.coe_pure Ultrafilter.coe_pureₓ'. -/\n@[simp]\ntheorem coe_pure (a : α) : ↑(pure a : Ultrafilter α) = (pure a : Filter α) :=\n  rfl\n#align ultrafilter.coe_pure Ultrafilter.coe_pure\n\n/- warning: ultrafilter.map_pure -> Ultrafilter.map_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (m : α -> β) (a : α), Eq.{succ u2} (Ultrafilter.{u2} β) (Ultrafilter.map.{u1, u2} α β m (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} α a)) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.hasPure.{u2} β (m a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} (m : α -> β) (a : α), Eq.{succ u2} (Ultrafilter.{u2} β) (Ultrafilter.map.{u1, u2} α β m (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α a)) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.instPureUltrafilter.{u2} β (m a))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.map_pure Ultrafilter.map_pureₓ'. -/\n@[simp]\ntheorem map_pure (m : α → β) (a : α) : map m (pure a) = pure (m a) :=\n  rfl\n#align ultrafilter.map_pure Ultrafilter.map_pure\n\n/- warning: ultrafilter.comap_pure -> Ultrafilter.comap_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {m : α -> β} (a : α) (inj : Function.Injective.{succ u1, succ u2} α β m) (large : Membership.Mem.{u2, u2} (Set.{u2} β) (Ultrafilter.{u2} β) (Ultrafilter.hasMem.{u2} β) (Set.range.{u2, succ u1} β α m) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.hasPure.{u2} β (m a))), Eq.{succ u1} (Ultrafilter.{u1} α) (Ultrafilter.comap.{u1, u2} α β m (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.hasPure.{u2} β (m a)) inj large) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {m : α -> β} (a : α) (inj : Function.Injective.{succ u1, succ u2} α β m) (large : Membership.mem.{u2, u2} (Set.{u2} β) (Ultrafilter.{u2} β) (Ultrafilter.instMembershipSetUltrafilter.{u2} β) (Set.range.{u2, succ u1} β α m) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.instPureUltrafilter.{u2} β (m a))), Eq.{succ u1} (Ultrafilter.{u1} α) (Ultrafilter.comap.{u1, u2} α β m (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.instPureUltrafilter.{u2} β (m a)) inj large) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.comap_pure Ultrafilter.comap_pureₓ'. -/\n@[simp]\ntheorem comap_pure {m : α → β} (a : α) (inj : Injective m) (large) :\n    comap (pure <| m a) inj large = pure a :=\n  coe_injective <|\n    comap_pure.trans <| by\n      rw [coe_pure, ← principal_singleton, ← image_singleton, preimage_image_eq _ inj]\n#align ultrafilter.comap_pure Ultrafilter.comap_pure\n\n/- warning: ultrafilter.pure_injective -> Ultrafilter.pure_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}}, Function.Injective.{succ u1, succ u1} α (Ultrafilter.{u1} α) (Pure.pure.{u1, u1} (fun {α : Type.{u1}} => Ultrafilter.{u1} α) Ultrafilter.hasPure.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}}, Function.Injective.{succ u1, succ u1} α (Ultrafilter.{u1} α) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.pure_injective Ultrafilter.pure_injectiveₓ'. -/\ntheorem pure_injective : Injective (pure : α → Ultrafilter α) := fun a b h =>\n  Filter.pure_injective (congr_arg Ultrafilter.toFilter h : _)\n#align ultrafilter.pure_injective Ultrafilter.pure_injective\n\ninstance [Inhabited α] : Inhabited (Ultrafilter α) :=\n  ⟨pure default⟩\n\ninstance [Nonempty α] : Nonempty (Ultrafilter α) :=\n  Nonempty.map pure inferInstance\n\n/- warning: ultrafilter.eq_pure_of_finite_mem -> Ultrafilter.eq_pure_of_finite_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α}, (Set.Finite.{u1} α s) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s f) -> (Exists.{succ u1} α (fun (x : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) => Eq.{succ u1} (Ultrafilter.{u1} α) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} α x))))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Ultrafilter.{u1} α} {s : Set.{u1} α}, (Set.Finite.{u1} α s) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s f) -> (Exists.{succ u1} α (fun (x : α) => And (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) (Eq.{succ u1} (Ultrafilter.{u1} α) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α x))))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.eq_pure_of_finite_mem Ultrafilter.eq_pure_of_finite_memₓ'. -/\ntheorem eq_pure_of_finite_mem (h : s.Finite) (h' : s ∈ f) : ∃ x ∈ s, f = pure x :=\n  by\n  rw [← bUnion_of_singleton s] at h'\n  rcases(Ultrafilter.finite_bunionᵢ_mem_iff h).mp h' with ⟨a, has, haf⟩\n  exact ⟨a, has, eq_of_le (Filter.le_pure_iff.2 haf)⟩\n#align ultrafilter.eq_pure_of_finite_mem Ultrafilter.eq_pure_of_finite_mem\n\n/- warning: ultrafilter.eq_pure_of_finite -> Ultrafilter.eq_pure_of_finite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] (f : Ultrafilter.{u1} α), Exists.{succ u1} α (fun (a : α) => Eq.{succ u1} (Ultrafilter.{u1} α) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} α a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] (f : Ultrafilter.{u1} α), Exists.{succ u1} α (fun (a : α) => Eq.{succ u1} (Ultrafilter.{u1} α) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α a))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.eq_pure_of_finite Ultrafilter.eq_pure_of_finiteₓ'. -/\ntheorem eq_pure_of_finite [Finite α] (f : Ultrafilter α) : ∃ a, f = pure a :=\n  (eq_pure_of_finite_mem finite_univ univ_mem).imp fun a ⟨_, ha⟩ => ha\n#align ultrafilter.eq_pure_of_finite Ultrafilter.eq_pure_of_finite\n\n/- warning: ultrafilter.le_cofinite_or_eq_pure -> Ultrafilter.le_cofinite_or_eq_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α), Or (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) (Filter.cofinite.{u1} α)) (Exists.{succ u1} α (fun (a : α) => Eq.{succ u1} (Ultrafilter.{u1} α) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} α a)))\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Ultrafilter.{u1} α), Or (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) (Filter.cofinite.{u1} α)) (Exists.{succ u1} α (fun (a : α) => Eq.{succ u1} (Ultrafilter.{u1} α) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} α a)))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_cofinite_or_eq_pure Ultrafilter.le_cofinite_or_eq_pureₓ'. -/\ntheorem le_cofinite_or_eq_pure (f : Ultrafilter α) : (f : Filter α) ≤ cofinite ∨ ∃ a, f = pure a :=\n  or_iff_not_imp_left.2 fun h =>\n    let ⟨s, hs, hfin⟩ := Filter.disjoint_cofinite_right.1 (disjoint_iff_not_le.2 h)\n    let ⟨a, has, hf⟩ := eq_pure_of_finite_mem hfin hs\n    ⟨a, hf⟩\n#align ultrafilter.le_cofinite_or_eq_pure Ultrafilter.le_cofinite_or_eq_pure\n\n#print Ultrafilter.bind /-\n/-- Monadic bind for ultrafilters, coming from the one on filters\ndefined in terms of map and join.-/\ndef bind (f : Ultrafilter α) (m : α → Ultrafilter β) : Ultrafilter β :=\n  ofComplNotMemIff (bind ↑f fun x => ↑(m x)) fun s => by\n    simp only [mem_bind', mem_coe, ← compl_mem_iff_not_mem, compl_set_of, compl_compl]\n#align ultrafilter.bind Ultrafilter.bind\n-/\n\n#print Ultrafilter.instBind /-\ninstance instBind : Bind Ultrafilter :=\n  ⟨@Ultrafilter.bind⟩\n#align ultrafilter.has_bind Ultrafilter.instBind\n-/\n\n#print Ultrafilter.functor /-\ninstance functor : Functor Ultrafilter where map := @Ultrafilter.map\n#align ultrafilter.functor Ultrafilter.functor\n-/\n\n#print Ultrafilter.monad /-\ninstance monad : Monad Ultrafilter where map := @Ultrafilter.map\n#align ultrafilter.monad Ultrafilter.monad\n-/\n\nsection\n\nattribute [local instance] Filter.monad Filter.lawfulMonad\n\n#print Ultrafilter.lawfulMonad /-\ninstance lawfulMonad : LawfulMonad Ultrafilter\n    where\n  id_map α f := coe_injective (id_map f.1)\n  pure_bind α β a f := coe_injective (pure_bind a (coe ∘ f))\n  bind_assoc α β γ f m₁ m₂ := coe_injective (filter_eq rfl)\n  bind_pure_comp_eq_map α β f x := coe_injective (bind_pure_comp_eq_map f x.1)\n#align ultrafilter.is_lawful_monad Ultrafilter.lawfulMonad\n-/\n\nend\n\n/- warning: ultrafilter.exists_le -> Ultrafilter.exists_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Filter.{u1} α) [h : Filter.NeBot.{u1} α f], Exists.{succ u1} (Ultrafilter.{u1} α) (fun (u : Ultrafilter.{u1} α) => LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) u) f)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Filter.{u1} α) [h : Filter.NeBot.{u1} α f], Exists.{succ u1} (Ultrafilter.{u1} α) (fun (u : Ultrafilter.{u1} α) => LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α u) f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.exists_le Ultrafilter.exists_leₓ'. -/\n/-- The ultrafilter lemma: Any proper filter is contained in an ultrafilter. -/\ntheorem exists_le (f : Filter α) [h : NeBot f] : ∃ u : Ultrafilter α, ↑u ≤ f :=\n  let ⟨u, hu, huf⟩ := (eq_bot_or_exists_atom_le f).resolve_left h.Ne\n  ⟨ofAtom u hu, huf⟩\n#align ultrafilter.exists_le Ultrafilter.exists_le\n\n/- warning: filter.exists_ultrafilter_le -> Filter.exists_ultrafilter_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Filter.{u1} α) [h : Filter.NeBot.{u1} α f], Exists.{succ u1} (Ultrafilter.{u1} α) (fun (u : Ultrafilter.{u1} α) => LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) u) f)\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Filter.{u1} α) [h : Filter.NeBot.{u1} α f], Exists.{succ u1} (Ultrafilter.{u1} α) (fun (u : Ultrafilter.{u1} α) => LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α u) f)\nCase conversion may be inaccurate. Consider using '#align filter.exists_ultrafilter_le Filter.exists_ultrafilter_leₓ'. -/\nalias exists_le ← _root_.filter.exists_ultrafilter_le\n#align filter.exists_ultrafilter_le Filter.exists_ultrafilter_le\n\n#print Ultrafilter.of /-\n/-- Construct an ultrafilter extending a given filter.\n  The ultrafilter lemma is the assertion that such a filter exists;\n  we use the axiom of choice to pick one. -/\nnoncomputable def of (f : Filter α) [NeBot f] : Ultrafilter α :=\n  Classical.choose (exists_le f)\n#align ultrafilter.of Ultrafilter.of\n-/\n\n/- warning: ultrafilter.of_le -> Ultrafilter.of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Filter.{u1} α) [_inst_1 : Filter.NeBot.{u1} α f], LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) (Ultrafilter.of.{u1} α f _inst_1)) f\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Filter.{u1} α) [_inst_1 : Filter.NeBot.{u1} α f], LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α (Ultrafilter.of.{u1} α f _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align ultrafilter.of_le Ultrafilter.of_leₓ'. -/\ntheorem of_le (f : Filter α) [NeBot f] : ↑(of f) ≤ f :=\n  Classical.choose_spec (exists_le f)\n#align ultrafilter.of_le Ultrafilter.of_le\n\n#print Ultrafilter.of_coe /-\ntheorem of_coe (f : Ultrafilter α) : of ↑f = f :=\n  coe_inj.1 <| f.unique (of_le f)\n#align ultrafilter.of_coe Ultrafilter.of_coe\n-/\n\n#print Ultrafilter.exists_ultrafilter_of_finite_inter_nonempty /-\ntheorem exists_ultrafilter_of_finite_inter_nonempty (S : Set (Set α))\n    (cond : ∀ T : Finset (Set α), (↑T : Set (Set α)) ⊆ S → (⋂₀ (↑T : Set (Set α))).Nonempty) :\n    ∃ F : Ultrafilter α, S ⊆ F.sets :=\n  haveI : ne_bot (generate S) :=\n    generate_ne_bot_iff.2 fun t hts ht =>\n      ht.coe_toFinset ▸ cond ht.toFinset (ht.coe_to_finset.symm ▸ hts)\n  ⟨of (generate S), fun t ht => (of_le <| generate S) <| generate_sets.basic ht⟩\n#align ultrafilter.exists_ultrafilter_of_finite_inter_nonempty Ultrafilter.exists_ultrafilter_of_finite_inter_nonempty\n-/\n\nend Ultrafilter\n\nnamespace Filter\n\nvariable {f : Filter α} {s : Set α} {a : α}\n\nopen Ultrafilter\n\n/- warning: filter.is_atom_pure -> Filter.isAtom_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {a : α}, IsAtom.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} {a : α}, IsAtom.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align filter.is_atom_pure Filter.isAtom_pureₓ'. -/\ntheorem isAtom_pure : IsAtom (pure a : Filter α) :=\n  (pure a : Ultrafilter α).IsAtom\n#align filter.is_atom_pure Filter.isAtom_pure\n\n/- warning: filter.ne_bot.le_pure_iff -> Filter.NeBot.le_pure_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {a : α}, (Filter.NeBot.{u1} α f) -> (Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)) (Eq.{succ u1} (Filter.{u1} α) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {a : α}, (Filter.NeBot.{u1} α f) -> (Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)) (Eq.{succ u1} (Filter.{u1} α) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)))\nCase conversion may be inaccurate. Consider using '#align filter.ne_bot.le_pure_iff Filter.NeBot.le_pure_iffₓ'. -/\nprotected theorem NeBot.le_pure_iff (hf : f.ne_bot) : f ≤ pure a ↔ f = pure a :=\n  ⟨Ultrafilter.unique (pure a), le_of_eq⟩\n#align filter.ne_bot.le_pure_iff Filter.NeBot.le_pure_iff\n\n/- warning: filter.lt_pure_iff -> Filter.lt_pure_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {a : α}, Iff (LT.lt.{u1} (Filter.{u1} α) (Preorder.toLT.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)) (Eq.{succ u1} (Filter.{u1} α) f (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {a : α}, Iff (LT.lt.{u1} (Filter.{u1} α) (Preorder.toLT.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)) (Eq.{succ u1} (Filter.{u1} α) f (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))))\nCase conversion may be inaccurate. Consider using '#align filter.lt_pure_iff Filter.lt_pure_iffₓ'. -/\n@[simp]\ntheorem lt_pure_iff : f < pure a ↔ f = ⊥ :=\n  isAtom_pure.lt_iff\n#align filter.lt_pure_iff Filter.lt_pure_iff\n\n/- warning: filter.le_pure_iff' -> Filter.le_pure_iff' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {a : α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)) (Or (Eq.{succ u1} (Filter.{u1} α) f (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α)))) (Eq.{succ u1} (Filter.{u1} α) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {a : α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)) (Or (Eq.{succ u1} (Filter.{u1} α) f (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α)))) (Eq.{succ u1} (Filter.{u1} α) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)))\nCase conversion may be inaccurate. Consider using '#align filter.le_pure_iff' Filter.le_pure_iff'ₓ'. -/\ntheorem le_pure_iff' : f ≤ pure a ↔ f = ⊥ ∨ f = pure a :=\n  isAtom_pure.le_iffₓ\n#align filter.le_pure_iff' Filter.le_pure_iff'\n\n/- warning: filter.Iic_pure -> Filter.Iic_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Set.{u1} (Filter.{u1} α)) (Set.Iic.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α)) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)) (Insert.insert.{u1, u1} (Filter.{u1} α) (Set.{u1} (Filter.{u1} α)) (Set.hasInsert.{u1} (Filter.{u1} α)) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (Singleton.singleton.{u1, u1} (Filter.{u1} α) (Set.{u1} (Filter.{u1} α)) (Set.hasSingleton.{u1} (Filter.{u1} α)) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} α a)))\nbut is expected to have type\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Set.{u1} (Filter.{u1} α)) (Set.Iic.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α)) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)) (Insert.insert.{u1, u1} (Filter.{u1} α) (Set.{u1} (Filter.{u1} α)) (Set.instInsertSet.{u1} (Filter.{u1} α)) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Singleton.singleton.{u1, u1} (Filter.{u1} α) (Set.{u1} (Filter.{u1} α)) (Set.instSingletonSet.{u1} (Filter.{u1} α)) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} α a)))\nCase conversion may be inaccurate. Consider using '#align filter.Iic_pure Filter.Iic_pureₓ'. -/\n@[simp]\ntheorem Iic_pure (a : α) : Iic (pure a : Filter α) = {⊥, pure a} :=\n  isAtom_pure.Iic_eq\n#align filter.Iic_pure Filter.Iic_pure\n\n/- warning: filter.mem_iff_ultrafilter -> Filter.mem_iff_ultrafilter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s f) (forall (g : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g) f) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s g))\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Filter.{u1} α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s f) (forall (g : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α g) f) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s g))\nCase conversion may be inaccurate. Consider using '#align filter.mem_iff_ultrafilter Filter.mem_iff_ultrafilterₓ'. -/\ntheorem mem_iff_ultrafilter : s ∈ f ↔ ∀ g : Ultrafilter α, ↑g ≤ f → s ∈ g :=\n  by\n  refine' ⟨fun hf g hg => hg hf, fun H => by_contra fun hf => _⟩\n  set g : Filter ↥(sᶜ) := comap coe f\n  haveI : ne_bot g := comap_ne_bot_iff_compl_range.2 (by simpa [compl_set_of] )\n  simpa using H ((of g).map coe) (map_le_iff_le_comap.mpr (of_le g))\n#align filter.mem_iff_ultrafilter Filter.mem_iff_ultrafilter\n\n/- warning: filter.le_iff_ultrafilter -> Filter.le_iff_ultrafilter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f₁ : Filter.{u1} α} {f₂ : Filter.{u1} α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) f₁ f₂) (forall (g : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g) f₁) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g) f₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {f₁ : Filter.{u1} α} {f₂ : Filter.{u1} α}, Iff (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) f₁ f₂) (forall (g : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α g) f₁) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α g) f₂))\nCase conversion may be inaccurate. Consider using '#align filter.le_iff_ultrafilter Filter.le_iff_ultrafilterₓ'. -/\ntheorem le_iff_ultrafilter {f₁ f₂ : Filter α} : f₁ ≤ f₂ ↔ ∀ g : Ultrafilter α, ↑g ≤ f₁ → ↑g ≤ f₂ :=\n  ⟨fun h g h₁ => h₁.trans h, fun h s hs => mem_iff_ultrafilter.2 fun g hg => h g hg hs⟩\n#align filter.le_iff_ultrafilter Filter.le_iff_ultrafilter\n\n/- warning: filter.supr_ultrafilter_le_eq -> Filter.supᵢ_ultrafilter_le_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (f : Filter.{u1} α), Eq.{succ u1} (Filter.{u1} α) (supᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasSup.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (Ultrafilter.{u1} α) (fun (g : Ultrafilter.{u1} α) => supᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toHasSup.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g) f) (fun (hg : LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g) f) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g))) f\nbut is expected to have type\n  forall {α : Type.{u1}} (f : Filter.{u1} α), Eq.{succ u1} (Filter.{u1} α) (supᵢ.{u1, succ u1} (Filter.{u1} α) (ConditionallyCompleteLattice.toSupSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Ultrafilter.{u1} α) (fun (g : Ultrafilter.{u1} α) => supᵢ.{u1, 0} (Filter.{u1} α) (ConditionallyCompleteLattice.toSupSet.{u1} (Filter.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α g) f) (fun (hg : LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α g) f) => Ultrafilter.toFilter.{u1} α g))) f\nCase conversion may be inaccurate. Consider using '#align filter.supr_ultrafilter_le_eq Filter.supᵢ_ultrafilter_le_eqₓ'. -/\n/-- A filter equals the intersection of all the ultrafilters which contain it. -/\ntheorem supᵢ_ultrafilter_le_eq (f : Filter α) :\n    (⨆ (g : Ultrafilter α) (hg : ↑g ≤ f), (g : Filter α)) = f :=\n  eq_of_forall_ge_iff fun f' => by simp only [supᵢ_le_iff, ← le_iff_ultrafilter]\n#align filter.supr_ultrafilter_le_eq Filter.supᵢ_ultrafilter_le_eq\n\n/- warning: filter.tendsto_iff_ultrafilter -> Filter.tendsto_iff_ultrafilter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (l₁ : Filter.{u1} α) (l₂ : Filter.{u2} β), Iff (Filter.Tendsto.{u1, u2} α β f l₁ l₂) (forall (g : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g) l₁) -> (Filter.Tendsto.{u1, u2} α β f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) g) l₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (l₁ : Filter.{u1} α) (l₂ : Filter.{u2} β), Iff (Filter.Tendsto.{u1, u2} α β f l₁ l₂) (forall (g : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α g) l₁) -> (Filter.Tendsto.{u1, u2} α β f (Ultrafilter.toFilter.{u1} α g) l₂))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_iff_ultrafilter Filter.tendsto_iff_ultrafilterₓ'. -/\n/-- The `tendsto` relation can be checked on ultrafilters. -/\ntheorem tendsto_iff_ultrafilter (f : α → β) (l₁ : Filter α) (l₂ : Filter β) :\n    Tendsto f l₁ l₂ ↔ ∀ g : Ultrafilter α, ↑g ≤ l₁ → Tendsto f g l₂ := by\n  simpa only [tendsto_iff_comap] using le_iff_ultrafilter\n#align filter.tendsto_iff_ultrafilter Filter.tendsto_iff_ultrafilter\n\n/- warning: filter.exists_ultrafilter_iff -> Filter.exists_ultrafilter_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Filter.{u1} α}, Iff (Exists.{succ u1} (Ultrafilter.{u1} α) (fun (u : Ultrafilter.{u1} α) => LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) u) f)) (Filter.NeBot.{u1} α f)\nbut is expected to have type\n  forall {α : Type.{u1}} {f : Filter.{u1} α}, Iff (Exists.{succ u1} (Ultrafilter.{u1} α) (fun (u : Ultrafilter.{u1} α) => LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α u) f)) (Filter.NeBot.{u1} α f)\nCase conversion may be inaccurate. Consider using '#align filter.exists_ultrafilter_iff Filter.exists_ultrafilter_iffₓ'. -/\ntheorem exists_ultrafilter_iff {f : Filter α} : (∃ u : Ultrafilter α, ↑u ≤ f) ↔ NeBot f :=\n  ⟨fun ⟨u, uf⟩ => neBot_of_le uf, fun h => @exists_ultrafilter_le _ _ h⟩\n#align filter.exists_ultrafilter_iff Filter.exists_ultrafilter_iff\n\n/- warning: filter.forall_ne_bot_le_iff -> Filter.forall_neBot_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {g : Filter.{u1} α} {p : (Filter.{u1} α) -> Prop}, (Monotone.{u1, 0} (Filter.{u1} α) Prop (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α)) (PartialOrder.toPreorder.{0} Prop Prop.partialOrder) p) -> (Iff (forall (f : Filter.{u1} α), (Filter.NeBot.{u1} α f) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) f g) -> (p f)) (forall (f : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f) g) -> (p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) f))))\nbut is expected to have type\n  forall {α : Type.{u1}} {g : Filter.{u1} α} {p : (Filter.{u1} α) -> Prop}, (Monotone.{u1, 0} (Filter.{u1} α) Prop (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α)) (PartialOrder.toPreorder.{0} Prop Prop.partialOrder) p) -> (Iff (forall (f : Filter.{u1} α), (Filter.NeBot.{u1} α f) -> (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) f g) -> (p f)) (forall (f : Ultrafilter.{u1} α), (LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α f) g) -> (p (Ultrafilter.toFilter.{u1} α f))))\nCase conversion may be inaccurate. Consider using '#align filter.forall_ne_bot_le_iff Filter.forall_neBot_le_iffₓ'. -/\ntheorem forall_neBot_le_iff {g : Filter α} {p : Filter α → Prop} (hp : Monotone p) :\n    (∀ f : Filter α, NeBot f → f ≤ g → p f) ↔ ∀ f : Ultrafilter α, ↑f ≤ g → p f :=\n  by\n  refine' ⟨fun H f hf => H f f.ne_bot hf, _⟩\n  intro H f hf hfg\n  exact hp (of_le f) (H _ ((of_le f).trans hfg))\n#align filter.forall_ne_bot_le_iff Filter.forall_neBot_le_iff\n\nsection Hyperfilter\n\nvariable (α) [Infinite α]\n\n#print Filter.hyperfilter /-\n/-- The ultrafilter extending the cofinite filter. -/\nnoncomputable def hyperfilter : Ultrafilter α :=\n  Ultrafilter.of cofinite\n#align filter.hyperfilter Filter.hyperfilter\n-/\n\nvariable {α}\n\n/- warning: filter.hyperfilter_le_cofinite -> Filter.hyperfilter_le_cofinite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α], LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) (Filter.hyperfilter.{u1} α _inst_1)) (Filter.cofinite.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α], LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α (Filter.hyperfilter.{u1} α _inst_1)) (Filter.cofinite.{u1} α)\nCase conversion may be inaccurate. Consider using '#align filter.hyperfilter_le_cofinite Filter.hyperfilter_le_cofiniteₓ'. -/\ntheorem hyperfilter_le_cofinite : ↑(hyperfilter α) ≤ @cofinite α :=\n  Ultrafilter.of_le cofinite\n#align filter.hyperfilter_le_cofinite Filter.hyperfilter_le_cofinite\n\n/- warning: filter.bot_ne_hyperfilter -> Filter.bot_ne_hyperfilter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α], Ne.{succ u1} (Filter.{u1} α) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toHasBot.{u1} (Filter.{u1} α) (Filter.completeLattice.{u1} α))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} α) (Filter.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Ultrafilter.{u1} α) (Filter.{u1} α) (Ultrafilter.Filter.hasCoeT.{u1} α))) (Filter.hyperfilter.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α], Ne.{succ u1} (Filter.{u1} α) (Bot.bot.{u1} (Filter.{u1} α) (CompleteLattice.toBot.{u1} (Filter.{u1} α) (Filter.instCompleteLatticeFilter.{u1} α))) (Ultrafilter.toFilter.{u1} α (Filter.hyperfilter.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align filter.bot_ne_hyperfilter Filter.bot_ne_hyperfilterₓ'. -/\n@[simp]\ntheorem bot_ne_hyperfilter : (⊥ : Filter α) ≠ hyperfilter α :=\n  (by infer_instance : NeBot ↑(hyperfilter α)).1.symm\n#align filter.bot_ne_hyperfilter Filter.bot_ne_hyperfilter\n\n#print Filter.nmem_hyperfilter_of_finite /-\ntheorem nmem_hyperfilter_of_finite {s : Set α} (hf : s.Finite) : s ∉ hyperfilter α := fun hy =>\n  compl_not_mem hy <| hyperfilter_le_cofinite hf.compl_mem_cofinite\n#align filter.nmem_hyperfilter_of_finite Filter.nmem_hyperfilter_of_finite\n-/\n\nalias nmem_hyperfilter_of_finite ← _root_.set.finite.nmem_hyperfilter\n#align set.finite.nmem_hyperfilter Set.Finite.nmem_hyperfilter\n\n/- warning: filter.compl_mem_hyperfilter_of_finite -> Filter.compl_mem_hyperfilter_of_finite is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α] {s : Set.{u1} α}, (Set.Finite.{u1} α s) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) (Filter.hyperfilter.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α] {s : Set.{u1} α}, (Set.Finite.{u1} α s) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) (Filter.hyperfilter.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align filter.compl_mem_hyperfilter_of_finite Filter.compl_mem_hyperfilter_of_finiteₓ'. -/\ntheorem compl_mem_hyperfilter_of_finite {s : Set α} (hf : Set.Finite s) : sᶜ ∈ hyperfilter α :=\n  compl_mem_iff_not_mem.2 hf.nmem_hyperfilter\n#align filter.compl_mem_hyperfilter_of_finite Filter.compl_mem_hyperfilter_of_finite\n\n/- warning: set.finite.compl_mem_hyperfilter -> Set.Finite.compl_mem_hyperfilter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α] {s : Set.{u1} α}, (Set.Finite.{u1} α s) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s) (Filter.hyperfilter.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α] {s : Set.{u1} α}, (Set.Finite.{u1} α s) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s) (Filter.hyperfilter.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align set.finite.compl_mem_hyperfilter Set.Finite.compl_mem_hyperfilterₓ'. -/\nalias compl_mem_hyperfilter_of_finite ← _root_.set.finite.compl_mem_hyperfilter\n#align set.finite.compl_mem_hyperfilter Set.Finite.compl_mem_hyperfilter\n\n/- warning: filter.mem_hyperfilter_of_finite_compl -> Filter.mem_hyperfilter_of_finite_compl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α] {s : Set.{u1} α}, (Set.Finite.{u1} α (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s)) -> (Membership.Mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.hasMem.{u1} α) s (Filter.hyperfilter.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Infinite.{succ u1} α] {s : Set.{u1} α}, (Set.Finite.{u1} α (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s)) -> (Membership.mem.{u1, u1} (Set.{u1} α) (Ultrafilter.{u1} α) (Ultrafilter.instMembershipSetUltrafilter.{u1} α) s (Filter.hyperfilter.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align filter.mem_hyperfilter_of_finite_compl Filter.mem_hyperfilter_of_finite_complₓ'. -/\ntheorem mem_hyperfilter_of_finite_compl {s : Set α} (hf : Set.Finite (sᶜ)) : s ∈ hyperfilter α :=\n  compl_compl s ▸ hf.compl_mem_hyperfilter\n#align filter.mem_hyperfilter_of_finite_compl Filter.mem_hyperfilter_of_finite_compl\n\nend Hyperfilter\n\nend Filter\n\nnamespace Ultrafilter\n\nopen Filter\n\nvariable {m : α → β} {s : Set α} {g : Ultrafilter β}\n\n/- warning: ultrafilter.comap_inf_principal_ne_bot_of_image_mem -> Ultrafilter.comap_inf_principal_neBot_of_image_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {m : α -> β} {s : Set.{u1} α} {g : Ultrafilter.{u2} β}, (Membership.Mem.{u2, u2} (Set.{u2} β) (Ultrafilter.{u2} β) (Ultrafilter.hasMem.{u2} β) (Set.image.{u1, u2} α β m s) g) -> (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.hasInf.{u1} α) (Filter.comap.{u1, u2} α β m ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Ultrafilter.{u2} β) (Filter.{u2} β) (HasLiftT.mk.{succ u2, succ u2} (Ultrafilter.{u2} β) (Filter.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} (Ultrafilter.{u2} β) (Filter.{u2} β) (Ultrafilter.Filter.hasCoeT.{u2} β))) g)) (Filter.principal.{u1} α s)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {m : α -> β} {s : Set.{u1} α} {g : Ultrafilter.{u2} β}, (Membership.mem.{u2, u2} (Set.{u2} β) (Ultrafilter.{u2} β) (Ultrafilter.instMembershipSetUltrafilter.{u2} β) (Set.image.{u1, u2} α β m s) g) -> (Filter.NeBot.{u1} α (Inf.inf.{u1} (Filter.{u1} α) (Filter.instInfFilter.{u1} α) (Filter.comap.{u1, u2} α β m (Ultrafilter.toFilter.{u2} β g)) (Filter.principal.{u1} α s)))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.comap_inf_principal_ne_bot_of_image_mem Ultrafilter.comap_inf_principal_neBot_of_image_memₓ'. -/\ntheorem comap_inf_principal_neBot_of_image_mem (h : m '' s ∈ g) : (Filter.comap m g ⊓ 𝓟 s).ne_bot :=\n  Filter.comap_inf_principal_neBot_of_image_mem g.ne_bot h\n#align ultrafilter.comap_inf_principal_ne_bot_of_image_mem Ultrafilter.comap_inf_principal_neBot_of_image_mem\n\n#print Ultrafilter.ofComapInfPrincipal /-\n/-- Ultrafilter extending the inf of a comapped ultrafilter and a principal ultrafilter. -/\nnoncomputable def ofComapInfPrincipal (h : m '' s ∈ g) : Ultrafilter α :=\n  @of _ (Filter.comap m g ⊓ 𝓟 s) (comap_inf_principal_neBot_of_image_mem h)\n#align ultrafilter.of_comap_inf_principal Ultrafilter.ofComapInfPrincipal\n-/\n\n#print Ultrafilter.ofComapInfPrincipal_mem /-\ntheorem ofComapInfPrincipal_mem (h : m '' s ∈ g) : s ∈ ofComapInfPrincipal h :=\n  by\n  let f := Filter.comap m g ⊓ 𝓟 s\n  haveI : f.ne_bot := comap_inf_principal_ne_bot_of_image_mem h\n  have : s ∈ f := mem_inf_of_right (mem_principal_self s)\n  exact le_def.mp (of_le _) s this\n#align ultrafilter.of_comap_inf_principal_mem Ultrafilter.ofComapInfPrincipal_mem\n-/\n\n#print Ultrafilter.ofComapInfPrincipal_eq_of_map /-\ntheorem ofComapInfPrincipal_eq_of_map (h : m '' s ∈ g) : (ofComapInfPrincipal h).map m = g :=\n  by\n  let f := Filter.comap m g ⊓ 𝓟 s\n  haveI : f.ne_bot := comap_inf_principal_ne_bot_of_image_mem h\n  apply eq_of_le\n  calc\n    Filter.map m (of f) ≤ Filter.map m f := map_mono (of_le _)\n    _ ≤ (Filter.map m <| Filter.comap m g) ⊓ Filter.map m (𝓟 s) := map_inf_le\n    _ = (Filter.map m <| Filter.comap m g) ⊓ (𝓟 <| m '' s) := by rw [map_principal]\n    _ ≤ g ⊓ (𝓟 <| m '' s) := (inf_le_inf_right _ map_comap_le)\n    _ = g := inf_of_le_left (le_principal_iff.mpr h)\n    \n#align ultrafilter.of_comap_inf_principal_eq_of_map Ultrafilter.ofComapInfPrincipal_eq_of_map\n-/\n\nend Ultrafilter\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Filter/Ultrafilter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4720856778441858}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.eq_to_hom\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ u₃ u₄ v₃ v₄ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\n`prod C D` gives the cartesian product of two categories.\n\nSee https://stacks.math.columbia.edu/tag/001K.\n-/\nprotected instance prod (C : Type u₁) [category C] (D : Type u₂) [category D] : category (C × D) :=\n  category.mk\n\n-- rfl lemmas for category.prod\n\n@[simp] theorem prod_id (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C) (Y : D) :\n    𝟙 = (𝟙, 𝟙) :=\n  rfl\n\n@[simp] theorem prod_comp (C : Type u₁) [category C] (D : Type u₂) [category D] {P : C} {Q : C}\n    {R : C} {S : D} {T : D} {U : D} (f : (P, S) ⟶ (Q, T)) (g : (Q, T) ⟶ (R, U)) :\n    f ≫ g = (prod.fst f ≫ prod.fst g, prod.snd f ≫ prod.snd g) :=\n  rfl\n\n@[simp] theorem prod_id_fst (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) :\n    prod.fst 𝟙 = 𝟙 :=\n  rfl\n\n@[simp] theorem prod_id_snd (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) :\n    prod.snd 𝟙 = 𝟙 :=\n  rfl\n\n@[simp] theorem prod_comp_fst (C : Type u₁) [category C] (D : Type u₂) [category D] {X : C × D}\n    {Y : C × D} {Z : C × D} (f : X ⟶ Y) (g : Y ⟶ Z) : prod.fst (f ≫ g) = prod.fst f ≫ prod.fst g :=\n  rfl\n\n@[simp] theorem prod_comp_snd (C : Type u₁) [category C] (D : Type u₂) [category D] {X : C × D}\n    {Y : C × D} {Z : C × D} (f : X ⟶ Y) (g : Y ⟶ Z) : prod.snd (f ≫ g) = prod.snd f ≫ prod.snd g :=\n  rfl\n\n/--\n`prod.category.uniform C D` is an additional instance specialised so both factors have the same\nuniverse levels. This helps typeclass resolution.\n-/\nprotected instance uniform_prod (C : Type u₁) [category C] (D : Type u₁) [category D] :\n    category (C × D) :=\n  category_theory.prod C D\n\n-- Next we define the natural functors into and out of product categories. For now this doesn't\n\n-- address the universal properties.\n\nnamespace prod\n\n\n/-- `sectl C Z` is the functor `C ⥤ C × D` given by `X ↦ (X, Z)`. -/\n@[simp] theorem sectl_obj (C : Type u₁) [category C] {D : Type u₂} [category D] (Z : D) (X : C) :\n    functor.obj (sectl C Z) X = (X, Z) :=\n  Eq.refl (functor.obj (sectl C Z) X)\n\n/-- `sectr Z D` is the functor `D ⥤ C × D` given by `Y ↦ (Z, Y)` . -/\ndef sectr {C : Type u₁} [category C] (Z : C) (D : Type u₂) [category D] : D ⥤ C × D :=\n  functor.mk (fun (X : D) => (Z, X)) fun (X Y : D) (f : X ⟶ Y) => (𝟙, f)\n\n/-- `fst` is the functor `(X, Y) ↦ X`. -/\n@[simp] theorem fst_obj (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) :\n    functor.obj (fst C D) X = prod.fst X :=\n  Eq.refl (functor.obj (fst C D) X)\n\n/-- `snd` is the functor `(X, Y) ↦ Y`. -/\n@[simp] theorem snd_map (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D)\n    (Y : C × D) (f : X ⟶ Y) : functor.map (snd C D) f = prod.snd f :=\n  Eq.refl (functor.map (snd C D) f)\n\n/-- The functor swapping the factors of a cartesian product of categories, `C × D ⥤ D × C`. -/\n@[simp] theorem swap_map (C : Type u₁) [category C] (D : Type u₂) [category D] (_x : C × D) :\n    ∀ (_x_1 : C × D) (f : _x ⟶ _x_1), functor.map (swap C D) f = (prod.snd f, prod.fst f) :=\n  fun (_x_1 : C × D) (f : _x ⟶ _x_1) => Eq.refl (functor.map (swap C D) f)\n\n/--\nSwapping the factors of a cartesion product of categories twice is naturally isomorphic\nto the identity functor.\n-/\n@[simp] theorem symmetry_hom_app (C : Type u₁) [category C] (D : Type u₂) [category D] (X : C × D) :\n    nat_trans.app (iso.hom (symmetry C D)) X = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.hom (symmetry C D)) X)\n\n/--\nThe equivalence, given by swapping factors, between `C × D` and `D × C`.\n-/\n@[simp] theorem braiding_counit_iso_inv_app (C : Type u₁) [category C] (D : Type u₂) [category D]\n    (X : D × C) :\n    nat_trans.app (iso.inv (equivalence.counit_iso (braiding C D))) X =\n        inv (eq_to_hom (braiding._proof_3 C D X)) :=\n  Eq.refl (inv (eq_to_hom (braiding._proof_3 C D X)))\n\nprotected instance swap_is_equivalence (C : Type u₁) [category C] (D : Type u₂) [category D] :\n    is_equivalence (swap C D) :=\n  is_equivalence.of_equivalence (braiding C D)\n\nend prod\n\n\n/--\nThe \"evaluation at `X`\" functor, such that\n`(evaluation.obj X).obj F = F.obj X`,\nwhich is functorial in both `X` and `F`.\n-/\ndef evaluation (C : Type u₁) [category C] (D : Type u₂) [category D] : C ⥤ (C ⥤ D) ⥤ D :=\n  functor.mk\n    (fun (X : C) =>\n      functor.mk (fun (F : C ⥤ D) => functor.obj F X)\n        fun (F G : C ⥤ D) (α : F ⟶ G) => nat_trans.app α X)\n    fun (X Y : C) (f : X ⟶ Y) => nat_trans.mk fun (F : C ⥤ D) => functor.map F f\n\n/--\nThe \"evaluation of `F` at `X`\" functor,\nas a functor `C × (C ⥤ D) ⥤ D`.\n-/\n@[simp] theorem evaluation_uncurried_obj (C : Type u₁) [category C] (D : Type u₂) [category D]\n    (p : C × (C ⥤ D)) :\n    functor.obj (evaluation_uncurried C D) p = functor.obj (prod.snd p) (prod.fst p) :=\n  Eq.refl (functor.obj (evaluation_uncurried C D) p)\n\nnamespace functor\n\n\n/-- The cartesian product of two functors. -/\n@[simp] theorem prod_obj {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃}\n    [category C] {D : Type u₄} [category D] (F : A ⥤ B) (G : C ⥤ D) (X : A × C) :\n    obj (prod F G) X = (obj F (prod.fst X), obj G (prod.snd X)) :=\n  Eq.refl (obj (prod F G) X)\n\n/- Because of limitations in Lean 3's handling of notations, we do not setup a notation `F × G`.\n   You can use `F.prod G` as a \"poor man's infix\", or just write `functor.prod F G`. -/\n\nend functor\n\n\nnamespace nat_trans\n\n\n/-- The cartesian product of two natural transformations. -/\n@[simp] theorem prod_app {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃}\n    [category C] {D : Type u₄} [category D] {F : A ⥤ B} {G : A ⥤ B} {H : C ⥤ D} {I : C ⥤ D}\n    (α : F ⟶ G) (β : H ⟶ I) (X : A × C) :\n    app (prod α β) X = (app α (prod.fst X), app β (prod.snd X)) :=\n  Eq.refl (app (prod α β) X)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/products/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4720856778441858}}
{"text": "import .size\nopen nnf list\n\nnamespace list\nuniverses u v w\n\nvariables {α : Type u} {β : Type v} {γ : Type w}\n\ntheorem mapp {p : β → Prop} (f : α → β) : Π (l : list α) (h : ∀ x∈l, p (f x)) x, x ∈ list.map f l → p x\n| [] h x := by simp\n| (hd::tl) h x := \nbegin\n  intro hmem, cases hmem,\n  {rw hmem, apply h, simp},\n  {apply mapp tl, intros a ha, apply h, simp [ha], exact hmem}\nend\n\ntheorem pmapp {p : β → Prop} {q : α → Prop} (f : Π a, q a → β)  : Π (l : list α) \n(h : ∀ y (hy : q y) (h₁ : y ∈ l), p (f y hy)) \n(hf : ∀ y ∈ l, q y) x, x ∈ list.pmap f l hf → p x\n| [] h hf x := by simp\n| (hd::tl) h hf x := \nbegin\n  intro hmem, \n  cases hmem,\n  {rw hmem, apply h, simp},\n  {apply pmapp tl, intros a ha hamem, \n   apply h, simp [ha], right, exact hamem, exact hmem}\nend\n\n@[simp] def ne_empty_head : Π l : list α, l ≠ [] → α\n| []       h := by contradiction\n| (a :: l) h := a\n\ntheorem mem_pmap_of_mem {p : α → Prop} (f : Π a, p a → β) {a : α} {l : list α} (h : a ∈ l) (hf : ∀ y ∈ l, p y) : \nf a (hf a h) ∈ pmap f l hf :=\nbegin\n  induction l with b l' ih,\n  {cases h},\n  {rcases h with rfl | h,\n    {exact or.inl rfl},\n    {apply or.inr,\n     have hpy : ∀ (y : α), y ∈ l' → p y, \n       {intros y hy, apply hf, right, exact hy},\n     have := ih h hpy, exact this}}\nend\n\nend list\n\n@[simp] def unbox : list nnf → list nnf\n| [] := []\n| ((box φ) :: l) := φ :: unbox l\n| (e :: l) := unbox l\n\ntheorem unbox_iff : Π {Γ φ}, box φ ∈ Γ ↔ φ ∈ unbox Γ\n| [] φ := begin split, repeat {intro h, simpa using h} end\n| (hd::tl) φ := \nbegin\n  split,\n  { intro h, cases h₁ : hd, \n    case nnf.box : ψ \n    { dsimp [unbox], cases h, \n       {left, rw h₁ at h, injection h},\n       {right, exact (@unbox_iff tl φ).1 h} },\n    all_goals \n    { dsimp [unbox], cases h, \n       {rw h₁ at h, contradiction},\n       {exact (@unbox_iff tl φ).1 h} } },\n  { intro h, cases h₁ : hd, \n    case nnf.box : ψ\n    { rw h₁ at h, dsimp [unbox] at h, cases h, \n       {simp [h]}, {right, exact (@unbox_iff tl φ).2 h} },\n    all_goals \n    { rw h₁ at h, dsimp [unbox] at h, right, exact (@unbox_iff tl φ).2 h } }\nend\n\ntheorem unbox_size_aux : Π {Γ}, node_size (unbox Γ) ≤ node_size Γ\n| [] := by simp\n| (hd::tl) := \nbegin\n  cases h : hd,\n  case nnf.box : ψ\n  { dsimp, apply add_le_add, \n     { dsimp [sizeof, has_sizeof.sizeof, nnf.sizeof], \n       rw add_comm, apply nat.le_succ }, \n     { apply unbox_size_aux } },\n  all_goals \n  { dsimp, apply le_add_of_nonneg_of_le, \n    { dsimp [sizeof, has_sizeof.sizeof, nnf.sizeof], rw add_comm, apply nat.zero_le }, \n    { apply unbox_size_aux } }\nend\n\n@[simp] def rebox : list nnf → list nnf \n| [] := []\n| (hd::tl) := box hd :: rebox tl\n\ntheorem rebox_unbox_of_mem : Π {Γ} (h : ∀ {φ}, φ ∈ unbox Γ → box φ ∈ Γ), rebox (unbox Γ) ⊆ Γ\n| [] h := by simp\n| (hd::tl) h := \nbegin\n  cases hψ : hd,\n  case nnf.box : φ {dsimp, simp [cons_subset_cons], apply subset_cons_of_subset, apply rebox_unbox_of_mem, simp [unbox_iff]},\n  all_goals {dsimp, apply subset_cons_of_subset, apply rebox_unbox_of_mem, simp [unbox_iff]}\nend\n\ntheorem unbox_rebox : Π {Γ}, unbox (rebox Γ) = Γ\n| [] := by simp\n| (hd::tl) := by simp [unbox_rebox]\n\n-- Just that I don't want to say ∃ φ s.t. ...\ndef box_only_rebox : Π {Γ}, box_only (rebox Γ)\n| [] := {no_var := by simp, \n         no_neg := by simp, \n         no_and := by simp, \n         no_or  := by simp, \n         no_dia := by simp}\n| (hd::tl) := \nbegin\n  cases h : hd,\n  all_goals {\n  exact { no_var := begin \n                      intros n h, cases h, contradiction, \n                      apply (@box_only_rebox tl).no_var, assumption \n                    end, \n          no_neg := begin \n                      intros n h, cases h, contradiction, \n                      apply (@box_only_rebox tl).no_neg, assumption \n                    end,\n          no_and := begin \n                      intros φ ψ h, cases h, contradiction, \n                      apply (@box_only_rebox tl).no_and, assumption \n                    end,\n          no_or := begin \n                     intros φ ψ h, cases h, contradiction, \n                     apply (@box_only_rebox tl).no_or, assumption \n                   end, \n          no_dia := begin \n                      intros φ h, cases h, contradiction, \n                      apply (@box_only_rebox tl).no_dia, assumption \n                    end} }\nend\n\ntheorem rebox_iff : Π {φ Γ}, box φ ∈ rebox Γ ↔ φ ∈ Γ\n| φ [] := by simp\n| φ (hd::tl) := \nbegin\n  split, \n  {intro h, cases h₁ : hd, \n   all_goals { cases h, \n               {left, rw ←h₁, injection h}, \n               {right,  have := (@rebox_iff φ tl).1, exact this h } }},\n  {intro h, cases h₁ : hd, \n   all_goals { dsimp, cases h, \n               {left, rw ←h₁, rw h}, \n               {right, have := (@rebox_iff φ tl).2, exact this h } } }\nend\n\n@[simp] def undia : list nnf → list nnf\n| [] := []\n| ((dia φ) :: l) := φ :: undia l\n| (e :: l) := undia l\n\ntheorem undia_iff : Π {Γ φ}, dia φ ∈ Γ ↔ φ ∈ undia Γ\n| [] φ := begin split, repeat {intro h, simpa using h} end\n| (hd::tl) φ := \nbegin\n  split,\n  { intro h, cases h₁ : hd, \n    case nnf.dia : ψ \n    { dsimp [undia], cases h, \n       {left, rw h₁ at h, injection h},\n       {right, exact (@undia_iff tl φ).1 h} },\n    all_goals \n    { dsimp [undia], cases h, \n       {rw h₁ at h, contradiction},\n       {exact (@undia_iff tl φ).1 h} } },\n  { intro h, cases h₁ : hd, \n    case nnf.dia : ψ\n    { rw h₁ at h, dsimp [undia] at h, cases h, \n       {simp [h]}, {right, exact (@undia_iff tl φ).2 h} },\n    all_goals \n    { rw h₁ at h, dsimp [undia] at h, right, exact (@undia_iff tl φ).2 h } }\nend\n\ndef get_contra : Π Γ : list nnf, \n                 psum {p : nat // var p ∈ Γ ∧ neg p ∈ Γ} \n                      (∀ n, var n ∈ Γ → neg n ∉ Γ)\n| []             := psum.inr $ λ _ h, absurd h $ not_mem_nil _\n| (hd :: tl)     := \nbegin\n  cases h : hd,\n  case nnf.var : n \n  {apply dite (neg n ∈ tl),\n    {intro t, \n     exact psum.inl ⟨n, ⟨mem_cons_self _ _, mem_cons_of_mem _ t⟩⟩},\n    {intro e, \n     cases (get_contra tl),\n     {left, constructor, constructor,\n     apply mem_cons_of_mem, exact val.2.1,\n     apply mem_cons_of_mem, exact val.2.2},\n     {right,\n      intros m hm hin, \n      by_cases eq : m=n,\n      {apply e, cases hin, contradiction, rw ←eq, assumption},\n      {cases hm, apply eq, injection hm, apply val, exact hm, \n       cases hin, contradiction, assumption} } }\n  },\n  case nnf.neg : n \n  { apply dite (var n ∈ tl),\n    { intro t, \n      exact psum.inl ⟨n, ⟨mem_cons_of_mem _ t, mem_cons_self _ _⟩⟩ },\n    { intro e, \n      cases (get_contra tl),\n      {left, constructor, constructor,\n      apply mem_cons_of_mem, exact val.2.1,\n      apply mem_cons_of_mem, exact val.2.2 },\n      { right,\n        intros m hm hin, \n        by_cases eq : m=n,\n        { apply e, cases hm, contradiction, rw ←eq, assumption },\n        { cases hin, apply eq, injection hin, apply val, \n          swap, exact hin, cases hm, contradiction, assumption } \n      } \n    }\n  },\n  all_goals\n  { \n  cases (get_contra tl),\n  { left, constructor, constructor,\n    apply mem_cons_of_mem, exact val.2.1,\n    apply mem_cons_of_mem, exact val.2.2  },\n  { right,\n    intros m hm hin, \n    {apply val, swap 3, exact m, \n    cases hm, contradiction, assumption,\n    cases hin, contradiction, assumption} }\n  }\nend\n\ndef get_contra_seqt : Π Γ : sseqt,\n                 psum {p : nat // var p ∈ Γ.m ∧ neg p ∈ Γ.m} \n                      (∀ n, var n ∈ Γ.m → neg n ∉ Γ.m)\n:= λ Γ, get_contra Γ.m\n\ndef get_and : Π Γ : list nnf, \n              psum {p : nnf × nnf // and p.1 p.2 ∈ Γ} \n                   (∀ φ ψ, nnf.and φ ψ ∉ Γ)\n| []               := psum.inr $ λ _ _, not_mem_nil _\n| (hd :: tl)       := \nbegin\n  cases h : hd,\n  case nnf.and : φ ψ { left, constructor,swap,\n                       constructor, exact φ, exact ψ, simp\n                     },\n  all_goals \n  { cases (get_and tl),\n    {left,\n    constructor,\n    apply mem_cons_of_mem,\n    exact val.2},\n    {right, intros γ ψ h, \n     cases h, contradiction,\n    apply val, assumption }\n  }\nend\n\ndef get_and_seqt : Π Γ : sseqt, \n              psum {p : nnf × nnf // and p.1 p.2 ∈ Γ.m} \n                   (∀ φ ψ, nnf.and φ ψ ∉ Γ.m)\n:= λ Γ, get_and Γ.m\n\ndef get_or : Π Γ : list nnf, \n              psum {p : nnf × nnf // or p.1 p.2 ∈ Γ} \n                   (∀ φ ψ, nnf.or φ ψ ∉ Γ)\n| []               := psum.inr $ λ _ _, not_mem_nil _\n| (hd :: tl)       :=\nbegin\n  cases h : hd,\n  case nnf.or : φ ψ { left, constructor,swap,\n                       constructor, exact φ, exact ψ, simp },\n  all_goals \n  { cases (get_or tl),\n    {left,\n    constructor,\n    apply mem_cons_of_mem,\n    exact val.2},\n    {right, intros γ ψ h, \n     cases h, contradiction,\n    apply val, assumption}\n  }\nend\n\ndef get_or_seqt : Π Γ : sseqt,\n              psum {p : nnf × nnf // or p.1 p.2 ∈ Γ.m} \n                   (∀ φ ψ, nnf.or φ ψ ∉ Γ.m)\n:= λ Γ, get_or Γ.m\n\ndef get_dia : Π Γ : list nnf, \n              psum {p : nnf // dia p ∈ Γ} \n                   (∀ φ, nnf.dia φ ∉ Γ)\n| []               := psum.inr $ λ _, not_mem_nil _\n| (hd :: tl)       := \nbegin\n  cases h : hd,\n  case nnf.dia : φ { left, constructor, swap, exact φ, simp },\n  all_goals \n  { cases (get_dia tl),\n    {left,\n    constructor,\n    apply mem_cons_of_mem,\n    exact val.2},\n    {right, intros γ h, \n     cases h, contradiction,\n     apply val, assumption } }\nend\n\ndef get_dia_seqt : Π Γ : sseqt,\n              psum {p : nnf // dia p ∈ Γ.m} \n                   (∀ φ, nnf.dia φ ∉ Γ.m)\n:= λ Γ, get_dia Γ.m\n\ndef get_box : Π Γ : list nnf,\n              psum {l : nnf // box l ∈ Γ} \n                   (∀ φ, nnf.box φ ∉ Γ)\n| [] := psum.inr $ λ _, not_mem_nil _\n| (hd :: tl) := \nbegin\n  cases h : hd,\n  case nnf.box : φ { left, constructor, swap, exact φ, simp },\n  all_goals \n  { cases (get_box tl),\n    {left,\n    constructor,\n    apply mem_cons_of_mem,\n    exact val.2},\n    {right, intros γ h, \n     cases h, contradiction,\n     apply val, assumption } }\nend\n\ndef get_box_seqt : Π Γ : sseqt,\n              psum {p : nnf // box p ∈ Γ.m} \n                   (∀ φ, nnf.box φ ∉ Γ.m)\n:= λ Γ, get_box Γ.m\n\n@[simp] def get_var : list nnf → list ℕ\n| [] := []\n| ((var n) :: l) := n :: get_var l\n| (e :: l) := get_var l\n\ntheorem get_var_iff : Π {Γ n}, var n ∈ Γ ↔ n ∈ get_var Γ\n| [] φ := begin split, repeat {intro h, simpa using h} end\n| (hd::tl) φ := \nbegin\n  split,\n  { intro h, cases h₁ : hd, \n    case nnf.var : n\n    { dsimp, cases h, \n       {left, rw h₁ at h, injection h},\n       {right, exact (@get_var_iff tl φ).1 h} },\n    all_goals \n    { dsimp, cases h, \n       {rw h₁ at h, contradiction},\n       {exact (@get_var_iff tl φ).1 h} } },\n  { intro h, cases h₁ : hd, \n    case nnf.var : n\n    { rw h₁ at h, dsimp at h, cases h, \n       {simp [h]}, {right, exact (@get_var_iff tl φ).2 h} },\n    all_goals \n    { rw h₁ at h, dsimp [undia] at h, right, exact (@get_var_iff tl φ).2 h } }\nend\n", "meta": {"author": "minchaowu", "repo": "ModalTab", "sha": "9bb0bf17faf0554d907ef7bdd639648742889178", "save_path": "github-repos/lean/minchaowu-ModalTab", "path": "github-repos/lean/minchaowu-ModalTab/ModalTab-9bb0bf17faf0554d907ef7bdd639648742889178/src/S4/ops.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.4720856721471345}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport order.filter.basic\nimport data.set.countable\n\n/-!\n# Filters with countable intersection property\n\nIn this file we define `countable_Inter_filter` to be the class of filters with the following\nproperty: for any countable collection of sets `s ∈ l` their intersection belongs to `l` as well.\n\nTwo main examples are the `residual` filter defined in `topology.metric_space.baire` and\nthe `measure.ae` filter defined in `measure_theory.measure_space`.\n-/\n\nopen set filter\nopen_locale filter\n\nvariables {ι α : Type*}\n\n/-- A filter `l` has the countable intersection property if for any countable collection\nof sets `s ∈ l` their intersection belongs to `l` as well. -/\nclass countable_Inter_filter (l : filter α) : Prop :=\n(countable_sInter_mem_sets' :\n  ∀ {S : set (set α)} (hSc : countable S) (hS : ∀ s ∈ S, s ∈ l), ⋂₀ S ∈ l)\n\nvariables {l : filter α} [countable_Inter_filter l]\n\nlemma countable_sInter_mem_sets {S : set (set α)} (hSc : countable S) :\n  ⋂₀ S ∈ l ↔ ∀ s ∈ S, s ∈ l :=\n⟨λ hS s hs, mem_of_superset hS (sInter_subset_of_mem hs),\n  countable_Inter_filter.countable_sInter_mem_sets' hSc⟩\n\nlemma countable_Inter_mem_sets [encodable ι] {s : ι → set α} :\n  (⋂ i, s i) ∈ l ↔ ∀ i, s i ∈ l :=\nsInter_range s ▸ (countable_sInter_mem_sets (countable_range _)).trans forall_range_iff\n\nlemma countable_bInter_mem {S : set ι} (hS : countable S) {s : Π i ∈ S, set α} :\n  (⋂ i ∈ S, s i ‹_›) ∈ l ↔  ∀ i ∈ S, s i ‹_› ∈ l :=\nbegin\n  rw [bInter_eq_Inter],\n  haveI := hS.to_encodable,\n  exact countable_Inter_mem_sets.trans subtype.forall\nend\n\nlemma eventually_countable_forall [encodable ι] {p : α → ι → Prop} :\n  (∀ᶠ x in l, ∀ i, p x i) ↔ ∀ i, ∀ᶠ x in l, p x i :=\nby simpa only [filter.eventually, set_of_forall]\n  using @countable_Inter_mem_sets _ _ l _ _ (λ i, {x | p x i})\n\nlemma eventually_countable_ball {S : set ι} (hS : countable S) {p : Π (x : α) (i ∈ S), Prop} :\n  (∀ᶠ x in l, ∀ i ∈ S, p x i ‹_›) ↔ ∀ i ∈ S, ∀ᶠ x in l, p x i ‹_› :=\nby simpa only [filter.eventually, set_of_forall]\n  using @countable_bInter_mem _ _ l _ _ hS (λ i hi, {x | p x i hi})\n\nlemma eventually_le.countable_Union [encodable ι] {s t : ι → set α} (h : ∀ i, s i ≤ᶠ[l] t i) :\n  (⋃ i, s i) ≤ᶠ[l] ⋃ i, t i :=\n(eventually_countable_forall.2 h).mono $ λ x hst hs, mem_Union.2 $\n  (mem_Union.1 hs).imp hst\n\nlemma eventually_eq.countable_Union [encodable ι] {s t : ι → set α} (h : ∀ i, s i =ᶠ[l] t i) :\n  (⋃ i, s i) =ᶠ[l] ⋃ i, t i :=\n(eventually_le.countable_Union (λ i, (h i).le)).antisymm\n  (eventually_le.countable_Union (λ i, (h i).symm.le))\n\nlemma eventually_le.countable_bUnion {S : set ι} (hS : countable S) {s t : Π i ∈ S, set α}\n  (h : ∀ i ∈ S, s i ‹_› ≤ᶠ[l] t i ‹_›) : (⋃ i ∈ S, s i ‹_›) ≤ᶠ[l] ⋃ i ∈ S, t i ‹_› :=\nbegin\n  simp only [bUnion_eq_Union],\n  haveI := hS.to_encodable,\n  exact eventually_le.countable_Union (λ i, h i i.2)\nend\n\nlemma eventually_eq.countable_bUnion {S : set ι} (hS : countable S) {s t : Π i ∈ S, set α}\n  (h : ∀ i ∈ S, s i ‹_› =ᶠ[l] t i ‹_›) : (⋃ i ∈ S, s i ‹_›) =ᶠ[l] ⋃ i ∈ S, t i ‹_› :=\n(eventually_le.countable_bUnion hS (λ i hi, (h i hi).le)).antisymm\n  (eventually_le.countable_bUnion hS (λ i hi, (h i hi).symm.le))\n\nlemma eventually_le.countable_Inter [encodable ι] {s t : ι → set α} (h : ∀ i, s i ≤ᶠ[l] t i) :\n  (⋂ i, s i) ≤ᶠ[l] ⋂ i, t i :=\n(eventually_countable_forall.2 h).mono $ λ x hst hs, mem_Inter.2 $ λ i, hst _ (mem_Inter.1 hs i)\n\nlemma eventually_eq.countable_Inter [encodable ι] {s t : ι → set α} (h : ∀ i, s i =ᶠ[l] t i) :\n  (⋂ i, s i) =ᶠ[l] ⋂ i, t i :=\n(eventually_le.countable_Inter (λ i, (h i).le)).antisymm\n  (eventually_le.countable_Inter (λ i, (h i).symm.le))\n\nlemma eventually_le.countable_bInter {S : set ι} (hS : countable S) {s t : Π i ∈ S, set α}\n  (h : ∀ i ∈ S, s i ‹_› ≤ᶠ[l] t i ‹_›) : (⋂ i ∈ S, s i ‹_›) ≤ᶠ[l] ⋂ i ∈ S, t i ‹_› :=\nbegin\n  simp only [bInter_eq_Inter],\n  haveI := hS.to_encodable,\n  exact eventually_le.countable_Inter (λ i, h i i.2)\nend\n\nlemma eventually_eq.countable_bInter {S : set ι} (hS : countable S) {s t : Π i ∈ S, set α}\n  (h : ∀ i ∈ S, s i ‹_› =ᶠ[l] t i ‹_›) : (⋂ i ∈ S, s i ‹_›) =ᶠ[l] ⋂ i ∈ S, t i ‹_› :=\n(eventually_le.countable_bInter hS (λ i hi, (h i hi).le)).antisymm\n  (eventually_le.countable_bInter hS (λ i hi, (h i hi).symm.le))\n\ninstance countable_Inter_filter_principal (s : set α) : countable_Inter_filter (𝓟 s) :=\n⟨λ S hSc hS, subset_sInter hS⟩\n\ninstance countable_Inter_filter_bot : countable_Inter_filter (⊥ : filter α) :=\nby { rw ← principal_empty, apply countable_Inter_filter_principal }\n\ninstance countable_Inter_filter_top : countable_Inter_filter (⊤ : filter α) :=\nby { rw ← principal_univ, apply countable_Inter_filter_principal }\n\n/-- Infimum of two `countable_Inter_filter`s is a `countable_Inter_filter`. This is useful, e.g.,\nto automatically get an instance for `residual α ⊓ 𝓟 s`. -/\ninstance countable_Inter_filter_inf (l₁ l₂ : filter α) [countable_Inter_filter l₁]\n  [countable_Inter_filter l₂] :\n  countable_Inter_filter (l₁ ⊓ l₂) :=\nbegin\n  refine ⟨λ S hSc hS, _⟩,\n  choose s hs t ht hst using hS,\n  replace hs : (⋂ i ∈ S, s i ‹_›) ∈ l₁ := (countable_bInter_mem hSc).2 hs,\n  replace ht : (⋂ i ∈ S, t i ‹_›) ∈ l₂ := (countable_bInter_mem hSc).2 ht,\n  refine mem_of_superset (inter_mem_inf hs ht) (subset_sInter $ λ i hi, _),\n  rw hst i hi,\n  apply inter_subset_inter ; exact Inter_subset_of_subset i (Inter_subset _ _)\nend\n\n/-- Supremum of two `countable_Inter_filter`s is a `countable_Inter_filter`. -/\ninstance countable_Inter_filter_sup (l₁ l₂ : filter α) [countable_Inter_filter l₁]\n  [countable_Inter_filter l₂] :\n  countable_Inter_filter (l₁ ⊔ l₂) :=\nbegin\n  refine ⟨λ S hSc hS, ⟨_, _⟩⟩; refine (countable_sInter_mem_sets hSc).2 (λ s hs, _),\n  exacts [(hS s hs).1, (hS s hs).2]\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/order/filter/countable_Inter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.4720856649068118}}
{"text": "/-\nCopyright (c) 2020 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.meta.rb_map\nimport Mathlib.tactic.ring\nimport Mathlib.tactic.linarith.lemmas\nimport Mathlib.PostPort\n\nuniverses l \n\nnamespace Mathlib\n\n/-!\n# Datatypes for `linarith`\n\nSome of the data structures here are used in multiple parts of the tactic.\nWe split them into their own file.\n\nThis file also contains a few convenient auxiliary functions.\n-/\n\nnamespace linarith\n\n\n/-- A shorthand for tracing when the `trace.linarith` option is set to true. -/\n/--\nA shorthand for tracing the types of a list of proof terms\nwhen the `trace.linarith` option is set to true.\n-/\n/-! ### Linear expressions -/\n\n/--\nA linear expression is a list of pairs of variable indices and coefficients,\nrepresenting the sum of the products of each coefficient with its corresponding variable.\n\nSome functions on `linexp` assume that `n : ℕ` occurs at most once as the first element of a pair,\nand that the list is sorted in decreasing order of the first argument.\nThis is not enforced by the type but the operations here preserve it.\n-/\ndef linexp :=\n  List (ℕ × ℤ)\n\nnamespace linexp\n\n\n/--\nAdd two `linexp`s together componentwise.\nPreserves sorting and uniqueness of the first argument.\n-/\n/-- `l.scale c` scales the values in `l` by `c` without modifying the order or keys. -/\ndef scale (c : ℤ) (l : linexp) : linexp :=\n  ite (c = 0) [] (ite (c = 1) l (list.map (fun (_x : ℕ × ℤ) => sorry) l))\n\n/--\n`l.get n` returns the value in `l` associated with key `n`, if it exists, and `none` otherwise.\nThis function assumes that `l` is sorted in decreasing order of the first argument,\nthat is, it will return `none` as soon as it finds a key smaller than `n`.\n-/\ndef get (n : ℕ) : linexp → Option ℤ :=\n  sorry\n\n/--\n`l.contains n` is true iff `n` is the first element of a pair in `l`.\n-/\ndef contains (n : ℕ) : linexp → Bool :=\n  option.is_some ∘ get n\n\n/--\n`l.zfind n` returns the value associated with key `n` if there is one, and 0 otherwise.\n-/\ndef zfind (n : ℕ) (l : linexp) : ℤ :=\n  sorry\n\n/-- `l.vars` returns the list of variables that occur in `l`. -/\ndef vars (l : linexp) : List ℕ :=\n  list.map prod.fst l\n\n/--\nDefines a lex ordering on `linexp`. This function is performance critical.\n-/\ndef cmp : linexp → linexp → ordering :=\n  sorry\n\nend linexp\n\n\n/-! ### Inequalities -/\n\n/-- The three-element type `ineq` is used to represent the strength of a comparison between terms. -/\ninductive ineq \nwhere\n| eq : ineq\n| le : ineq\n| lt : ineq\n\nnamespace ineq\n\n\n/--\n`max R1 R2` computes the strength of the sum of two inequalities. If `t1 R1 0` and `t2 R2 0`,\nthen `t1 + t2 (max R1 R2) 0`.\n-/\ndef max : ineq → ineq → ineq :=\n  sorry\n\n/-- `ineq` is ordered `eq < le < lt`. -/\ndef cmp : ineq → ineq → ordering :=\n  sorry\n\n/-- Prints an `ineq` as the corresponding infix symbol. -/\ndef to_string : ineq → string :=\n  sorry\n\n/-- Finds the name of a multiplicative lemma corresponding to an inequality strength. -/\nprotected instance has_to_string : has_to_string ineq :=\n  has_to_string.mk to_string\n\nend ineq\n\n\n/-! ### Comparisons with 0 -/\n\n/--\nThe main datatype for FM elimination.\nVariables are represented by natural numbers, each of which has an integer coefficient.\nIndex 0 is reserved for constants, i.e. `coeffs.find 0` is the coefficient of 1.\nThe represented term is `coeffs.sum (λ ⟨k, v⟩, v * Var[k])`.\nstr determines the strength of the comparison -- is it < 0, ≤ 0, or = 0?\n-/\nstructure comp \nwhere\n  str : ineq\n  coeffs : linexp\n\n/-- `c.vars` returns the list of variables that appear in the linear expression contained in `c`. -/\ndef comp.vars : comp → List ℕ :=\n  linexp.vars ∘ comp.coeffs\n\n/-- `comp.coeff_of c a` projects the coefficient of variable `a` out of `c`. -/\ndef comp.coeff_of (c : comp) (a : ℕ) : ℤ :=\n  linexp.zfind a (comp.coeffs c)\n\n/-- `comp.scale c n` scales the coefficients of `c` by `n`. -/\ndef comp.scale (c : comp) (n : ℕ) : comp :=\n  comp.mk (comp.str c) (linexp.scale (↑n) (comp.coeffs c))\n\n/--\n`comp.add c1 c2` adds the expressions represented by `c1` and `c2`.\nThe coefficient of variable `a` in `c1.add c2`\nis the sum of the coefficients of `a` in `c1` and `c2`.\n -/\n/-- `comp` has a lex order. First the `ineq`s are compared, then the `coeff`s. -/\n/--\nA `comp` represents a contradiction if its expression has no coefficients and its strength is <,\nthat is, it represents the fact `0 < 0`.\n -/\n/-! ### Parsing into linear form -/\n\n/-! ### Control -/\n\n/--\nA preprocessor transforms a proof of a proposition into a proof of a different propositon.\nThe return type is `list expr`, since some preprocessing steps may create multiple new hypotheses,\nand some may remove a hypothesis from the list.\nA \"no-op\" preprocessor should return its input as a singleton list.\n-/\n/--\nSome preprocessors need to examine the full list of hypotheses instead of working item by item.\nAs with `preprocessor`, the input to a `global_preprocessor` is replaced by, not added to, its output.\n-/\n/--\nSome preprocessors perform branching case splits. A `branch` is used to track one of these case\nsplits. The first component, an `expr`, is the goal corresponding to this branch of the split,\ngiven as a metavariable. The `list expr` component is the list of hypotheses for `linarith`\nin this branch. Every `expr` in this list should be type correct in the context of the associated goal.\n-/\n/--\nSome preprocessors perform branching case splits.\nA `global_branching_preprocessor` produces a list of branches to run.\nEach branch is independent, so hypotheses that appear in multiple branches should be duplicated.\nThe preprocessor is responsible for making sure that each branch contains the correct goal\nmetavariable.\n-/\n/--\nA `preprocessor` lifts to a `global_preprocessor` by folding it over the input list.\n-/\n/--\nA `global_preprocessor` lifts to a `global_branching_preprocessor` by producing only one branch.\n-/\n/--\n`process pp l` runs `pp.transform` on `l` and returns the result,\ntracing the result if `trace.linarith` is on.\n-/\n/--\nA `certificate_oracle` is a function `produce_certificate : list comp → ℕ → tactic (rb_map ℕ ℕ)`.\n`produce_certificate hyps max_var` tries to derive a contradiction from the comparisons in `hyps`\nby eliminating all variables ≤ `max_var`.\nIf successful, it returns a map `coeff : ℕ → ℕ` as a certificate.\nThis map represents that we can find a contradiction by taking the sum  `∑ (coeff i) * hyps[i]`.\n\nThe default `certificate_oracle` used by `linarith` is `linarith.fourier_motzkin.produce_certificate`\n-/\n/-- A configuration object for `linarith`. -/\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/linarith/datatypes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.47189120078311336}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n-/\nprelude\nimport Init.SimpLemmas\nimport Init.Data.Nat.Basic\nopen Decidable List\n\nuniverse u v w\n\nvariable {α : Type u} {β : Type v} {γ : Type w}\n\nnamespace List\n\n@[simp] theorem length_nil : length ([] : List α) = 0 :=\n  rfl\n\ndef reverseAux : List α → List α → List α\n  | [],   r => r\n  | a::l, r => reverseAux l (a::r)\n\ndef reverse (as : List α) :List α :=\n  reverseAux as []\n\nprotected def append (as bs : List α) : List α :=\n  reverseAux as.reverse bs\n\ninstance : Append (List α) := ⟨List.append⟩\n\ntheorem reverseAux_reverseAux_nil (as bs : List α) : reverseAux (reverseAux as bs) [] = reverseAux bs as := by\n  induction as generalizing bs with\n  | nil => rfl\n  | cons a as ih => simp [reverseAux, ih]\n\n@[simp] theorem nil_append (as : List α) : [] ++ as = as := rfl\n\n@[simp] theorem append_nil (as : List α) : as ++ [] = as := by\n  show reverseAux (reverseAux as []) [] = as\n  simp [reverseAux_reverseAux_nil, reverseAux]\n\ntheorem reverseAux_reverseAux (as bs cs : List α) : reverseAux (reverseAux as bs) cs = reverseAux bs (reverseAux (reverseAux as []) cs) := by\n  induction as generalizing bs cs with\n  | nil => rfl\n  | cons a as ih => simp [reverseAux, ih (a::bs), ih [a]]\n\n@[simp] theorem cons_append (a : α) (as bs : List α) : (a::as) ++ bs = a::(as ++ bs) :=\n  reverseAux_reverseAux as [a] bs\n\ntheorem append_assoc (as bs cs : List α) : (as ++ bs) ++ cs = as ++ (bs ++ cs) := by\n  induction as with\n  | nil => rfl\n  | cons a as ih => simp [ih]\n\ninstance : EmptyCollection (List α) := ⟨List.nil⟩\n\nprotected def erase {α} [BEq α] : List α → α → List α\n  | [],    b => []\n  | a::as, b => match a == b with\n    | true  => as\n    | false => a :: List.erase as b\n\ndef eraseIdx : List α → Nat → List α\n  | [],    _   => []\n  | a::as, 0   => as\n  | a::as, n+1 => a :: eraseIdx as n\n\ndef isEmpty : List α → Bool\n  | []     => true\n  | _ :: _ => false\n\n@[specialize] def map (f : α → β) : List α → List β\n  | []    => []\n  | a::as => f a :: map f as\n\n@[specialize] def map₂ (f : α → β → γ) : List α → List β → List γ\n  | [],    _     => []\n  | _,     []    => []\n  | a::as, b::bs => f a b :: map₂ f as bs\n\ndef join : List (List α) → List α\n  | []      => []\n  | a :: as => a ++ join as\n\n@[specialize] def filterMap (f : α → Option β) : List α → List β\n  | []   => []\n  | a::as =>\n    match f a with\n    | none   => filterMap f as\n    | some b => b :: filterMap f as\n\n@[specialize] def filterAux (p : α → Bool) : List α → List α → List α\n  | [],    rs => rs.reverse\n  | a::as, rs => match p a with\n     | true  => filterAux p as (a::rs)\n     | false => filterAux p as rs\n\n@[inline] def filter (p : α → Bool) (as : List α) : List α :=\n  filterAux p as []\n\n@[specialize] def partitionAux (p : α → Bool) : List α → List α × List α → List α × List α\n  | [],    (bs, cs) => (bs.reverse, cs.reverse)\n  | a::as, (bs, cs) =>\n    match p a with\n    | true  => partitionAux p as (a::bs, cs)\n    | false => partitionAux p as (bs, a::cs)\n\n@[inline] def partition (p : α → Bool) (as : List α) : List α × List α :=\n  partitionAux p as ([], [])\n\ndef dropWhile (p : α → Bool) : List α → List α\n  | []   => []\n  | a::l => match p a with\n    | true  => dropWhile p l\n    | false =>  a::l\n\ndef find? (p : α → Bool) : List α → Option α\n  | []    => none\n  | a::as => match p a with\n    | true  => some a\n    | false => find? p as\n\ndef findSome? (f : α → Option β) : List α → Option β\n  | []    => none\n  | a::as => match f a with\n    | some b => some b\n    | none   => findSome? f as\n\ndef replace [BEq α] : List α → α → α → List α\n  | [],    _, _ => []\n  | a::as, b, c => match a == b with\n    | true  => c::as\n    | false => a :: (replace as b c)\n\ndef elem [BEq α] (a : α) : List α → Bool\n  | []    => false\n  | b::bs => match a == b with\n    | true  => true\n    | false => elem a bs\n\ndef notElem [BEq α] (a : α) (as : List α) : Bool :=\n  !(as.elem a)\n\nabbrev contains [BEq α] (as : List α) (a : α) : Bool :=\n  elem a as\n\ndef eraseDupsAux {α} [BEq α] : List α → List α → List α\n  | [],    bs => bs.reverse\n  | a::as, bs => match bs.elem a with\n    | true  => eraseDupsAux as bs\n    | false => eraseDupsAux as (a::bs)\n\ndef eraseDups {α} [BEq α] (as : List α) : List α :=\n  eraseDupsAux as []\n\ndef eraseRepsAux {α} [BEq α] : α → List α → List α → List α\n  | a, [], rs => (a::rs).reverse\n  | a, a'::as, rs => match a == a' with\n    | true  => eraseRepsAux a as rs\n    | false => eraseRepsAux a' as (a::rs)\n\n/-- Erase repeated adjacent elements. -/\ndef eraseReps {α} [BEq α] : List α → List α\n  | []    => []\n  | a::as => eraseRepsAux a as []\n\n@[specialize] def spanAux (p : α → Bool) : List α → List α → List α × List α\n  | [],    rs => (rs.reverse, [])\n  | a::as, rs => match p a with\n    | true  => spanAux p as (a::rs)\n    | false => (rs.reverse, a::as)\n\n@[inline] def span (p : α → Bool) (as : List α) : List α × List α :=\n  spanAux p as []\n\n@[specialize] def groupByAux (eq : α → α → Bool) : List α → List (List α) → List (List α)\n  | a::as, (ag::g)::gs => match eq a ag with\n    | true  => groupByAux eq as ((a::ag::g)::gs)\n    | false => groupByAux eq as ([a]::(ag::g).reverse::gs)\n  | _, gs => gs.reverse\n\n@[specialize] def groupBy (p : α → α → Bool) : List α → List (List α)\n  | []    => []\n  | a::as => groupByAux p as [[a]]\n\ndef lookup [BEq α] : α → List (α × β) → Option β\n  | _, []        => none\n  | a, (k,b)::es => match a == k with\n    | true  => some b\n    | false => lookup a es\n\ndef removeAll [BEq α] (xs ys : List α) : List α :=\n  xs.filter (fun x => ys.notElem x)\n\ndef drop : Nat → List α → List α\n  | 0,   a     => a\n  | n+1, []    => []\n  | n+1, a::as => drop n as\n\ndef take : Nat → List α → List α\n  | 0,   a     => []\n  | n+1, []    => []\n  | n+1, a::as => a :: take n as\n\n@[specialize] def foldr (f : α → β → β) (init : β) : List α → β\n  | []     => init\n  | a :: l => f a (foldr f init l)\n\n@[inline] def any (l : List α) (p : α → Bool) : Bool :=\n  foldr (fun a r => p a || r) false l\n\n@[inline] def all (l : List α) (p : α → Bool) : Bool :=\n  foldr (fun a r => p a && r) true l\n\ndef or  (bs : List Bool) : Bool := bs.any id\n\ndef and (bs : List Bool) : Bool := bs.all id\n\ndef zipWith (f : α → β → γ) : List α → List β → List γ\n  | x::xs, y::ys => f x y :: zipWith f xs ys\n  | _,     _     => []\n\ndef zip : List α → List β → List (Prod α β) :=\n  zipWith Prod.mk\n\ndef unzip : List (α × β) → List α × List β\n  | []          => ([], [])\n  | (a, b) :: t => match unzip t with | (al, bl) => (a::al, b::bl)\n\ndef rangeAux : Nat → List Nat → List Nat\n  | 0,   ns => ns\n  | n+1, ns => rangeAux n (n::ns)\n\ndef range (n : Nat) : List Nat :=\n  rangeAux n []\n\ndef iota : Nat → List Nat\n  | 0       => []\n  | m@(n+1) => m :: iota n\n\ndef enumFrom : Nat → List α → List (Nat × α)\n  | n, [] => nil\n  | n, x :: xs   => (n, x) :: enumFrom (n + 1) xs\n\ndef enum : List α → List (Nat × α) := enumFrom 0\n\ndef init : List α → List α\n  | []   => []\n  | [a]  => []\n  | a::l => a::init l\n\ndef intersperse (sep : α) : List α → List α\n  | []    => []\n  | [x]   => [x]\n  | x::xs => x :: sep :: intersperse sep xs\n\ndef intercalate (sep : List α) (xs : List (List α)) : List α :=\n  join (intersperse sep xs)\n\n@[inline] protected def bind {α : Type u} {β : Type v} (a : List α) (b : α → List β) : List β := join (map b a)\n\n@[inline] protected def pure {α : Type u} (a : α) : List α := [a]\n\ninductive lt [LT α] : List α → List α → Prop where\n  | nil  (b : α) (bs : List α) : lt [] (b::bs)\n  | head {a : α} (as : List α) {b : α} (bs : List α) : a < b → lt (a::as) (b::bs)\n  | tail {a : α} {as : List α} {b : α} {bs : List α} : ¬ a < b → ¬ b < a → lt as bs → lt (a::as) (b::bs)\n\ninstance [LT α] : LT (List α) := ⟨List.lt⟩\n\ninstance hasDecidableLt [LT α] [h : DecidableRel (α:=α) (·<·)] : (l₁ l₂ : List α) → Decidable (l₁ < l₂)\n  | [],    []    => isFalse (fun h => nomatch h)\n  | [],    b::bs => isTrue (List.lt.nil _ _)\n  | a::as, []    => isFalse (fun h => nomatch h)\n  | a::as, b::bs =>\n    match h a b with\n    | isTrue h₁  => isTrue (List.lt.head _ _ h₁)\n    | isFalse h₁ =>\n      match h b a with\n      | isTrue h₂  => isFalse (fun h => match h with\n         | List.lt.head _ _ h₁' => absurd h₁' h₁\n         | List.lt.tail _ h₂' _ => absurd h₂ h₂')\n      | isFalse h₂ =>\n        match hasDecidableLt as bs with\n        | isTrue h₃  => isTrue (List.lt.tail h₁ h₂ h₃)\n        | isFalse h₃ => isFalse (fun h => match h with\n           | List.lt.head _ _ h₁' => absurd h₁' h₁\n           | List.lt.tail _ _ h₃' => absurd h₃' h₃)\n\n@[reducible] protected def le [LT α] (a b : List α) : Prop := ¬ b < a\n\ninstance [LT α] : LE (List α) := ⟨List.le⟩\n\ninstance [LT α] [h : DecidableRel ((· < ·) : α → α → Prop)] : (l₁ l₂ : List α) → Decidable (l₁ ≤ l₂) :=\n  fun a b => inferInstanceAs (Decidable (Not _))\n\n/--  `isPrefixOf l₁ l₂` returns `true` Iff `l₁` is a prefix of `l₂`. -/\ndef isPrefixOf [BEq α] : List α → List α → Bool\n  | [],    _     => true\n  | _,     []    => false\n  | a::as, b::bs => a == b && isPrefixOf as bs\n\n/--  `isSuffixOf l₁ l₂` returns `true` Iff `l₁` is a suffix of `l₂`. -/\ndef isSuffixOf [BEq α] (l₁ l₂ : List α) : Bool :=\n  isPrefixOf l₁.reverse l₂.reverse\n\n@[specialize] def isEqv : List α → List α → (α → α → Bool) → Bool\n  | [],    [],    _   => true\n  | a::as, b::bs, eqv => eqv a b && isEqv as bs eqv\n  | _,     _,     eqv => false\n\nprotected def beq [BEq α] : List α → List α → Bool\n  | [],    []    => true\n  | a::as, b::bs => a == b && List.beq as bs\n  | _,     _     => false\n\ninstance [BEq α] : BEq (List α) := ⟨List.beq⟩\n\ndef replicate {α : Type u} (n : Nat) (a : α) : List α :=\n  let rec loop : Nat → List α → List α\n    | 0, as => as\n    | n+1, as => loop n (a::as)\n  loop n []\n\ndef dropLast {α} : List α → List α\n  | []    => []\n  | [a]   => []\n  | a::as => a :: dropLast as\n\n@[simp] theorem length_replicate (n : Nat) (a : α) : (replicate n a).length = n :=\n  let rec aux (n : Nat) (as : List α) : (replicate.loop a n as).length = n + as.length := by\n    induction n generalizing as with\n    | zero => simp [replicate.loop]\n    | succ n ih => simp [replicate.loop, ih, Nat.succ_add, Nat.add_succ]\n  aux n []\n\n@[simp] theorem length_concat (as : List α) (a : α) : (concat as a).length = as.length + 1 := by\n  induction as with\n  | nil => rfl\n  | cons x xs ih => simp [concat, ih]\n\n@[simp] theorem length_set (as : List α) (i : Nat) (a : α) : (as.set i a).length = as.length := by\n  induction as generalizing i with\n  | nil => rfl\n  | cons x xs ih =>\n    cases i with\n    | zero => rfl\n    | succ i => simp [set, ih]\n\n@[simp] theorem length_dropLast (as : List α) : as.dropLast.length = as.length - 1 := by\n  match as with\n  | []       => rfl\n  | [a]      => rfl\n  | a::b::as =>\n    have ih := length_dropLast (b::as)\n    simp[dropLast, ih]\n    rfl\n\ndef maximum? [LT α] [DecidableRel (@LT.lt α _)] : List α → Option α\n  | []    => none\n  | a::as => some <| as.foldl max a\n\ndef minimum? [LE α] [DecidableRel (@LE.le α _)] : List α → Option α\n  | []    => none\n  | a::as => some <| as.foldl min a\n\nend List\n", "meta": {"author": "JLimperg", "repo": "lean4-aesop", "sha": "5c4b9a3e05c32f69a4357c3047c274f4b94f9c71", "save_path": "github-repos/lean/JLimperg-lean4-aesop", "path": "github-repos/lean/JLimperg-lean4-aesop/lean4-aesop-5c4b9a3e05c32f69a4357c3047c274f4b94f9c71/stage0/src/Init/Data/List/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7718434925908525, "lm_q1q2_score": 0.4718911975744449}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nWithout loss of generality tactic.\n-/\nimport data.list.perm\n\nopen expr\nsetup_tactic_parser\n\nnamespace tactic\n\nprivate meta def update_pp_name : expr → name → expr\n| (local_const n _ bi d) pp := local_const n pp bi d\n| e n := e\n\nprivate meta def elim_or : ℕ → expr → tactic (list expr)\n| 0       h := fail \"zero cases\"\n| 1       h := return [h]\n| (n + 1) h := do\n  [(_, [hl], []), (_, [hr], [])] ← induction h, -- there should be no dependent terms\n  [gl, gr] ← get_goals,\n  set_goals [gr],\n  hsr ← elim_or n hr,\n  gsr ← get_goals,\n  set_goals (gl :: gsr),\n  return (hl :: hsr)\n\nprivate meta def dest_or : expr → tactic (list expr) | e := do\n  `(%%a ∨ %%b) ← whnf e | return [e],\n  lb ← dest_or b,\n  return (a :: lb)\n\nprivate meta def match_perms (pat : pattern) : expr → tactic (list $ list expr) | t :=\n  (do\n    m ← match_pattern pat t,\n    guard (m.2.all expr.is_local_constant),\n    return [m.2]) <|>\n  (do\n    `(%%l ∨ %%r) ← whnf t,\n    m ← match_pattern pat l,\n    rs ← match_perms r,\n    return (m.2 :: rs))\n\nmeta def wlog (vars' : list expr) (h_cases fst_case : expr) (perms : list (list expr)) :\n  tactic unit := do\n  guard h_cases.is_local_constant,\n\n  -- reorder s.t. context is Γ ⬝ vars ⬝ cases ⊢ ∀deps, …\n  nr ← revert_lst (vars' ++ [h_cases]),\n  vars ← intron' vars'.length,\n  h_cases ← intro h_cases.local_pp_name,\n\n  cases ← infer_type h_cases,\n  h_fst_case ←\n    mk_local_def h_cases.local_pp_name\n      (fst_case.instantiate_locals $ (vars'.zip vars).map $ λ⟨o, n⟩, (o.local_uniq_name, n)),\n  ((), pr) ← solve_aux cases (repeat $ exact h_fst_case <|> left >> skip),\n\n  t ← target,\n  fixed_vars ← vars.mmap update_type,\n  let t' := (instantiate_local h_cases.local_uniq_name pr t).pis (fixed_vars ++ [h_fst_case]),\n\n  (h, [g]) ← local_proof `this t' (do\n    clear h_cases,\n    vars.mmap clear,\n    intron nr),\n\n  h₀ :: hs ← elim_or perms.length h_cases,\n\n  solve1 (do\n    exact (h.mk_app $ vars ++ [h₀])),\n\n  focus ((hs.zip perms.tail).map $ λ⟨h_case, perm⟩, do\n    let p_v := (vars'.zip vars).map (λ⟨p, v⟩, (p.local_uniq_name, v)),\n    let p := perm.map (λp, p.instantiate_locals p_v),\n    note `this none (h.mk_app $ p ++ [h_case]),\n    clear h,\n    return ()),\n  gs ← get_goals,\n  set_goals (g :: gs)\n\nnamespace interactive\nopen interactive interactive.types expr\n\nprivate meta def parse_permutations : option (list (list name)) → tactic (list (list expr))\n| none                    := return []\n| (some [])               := return []\n| (some perms@(p₀ :: ps)) := do\n  (guard p₀.nodup <|> fail\n    \"No permutation `xs_i` in `using [xs_1, …, xs_n]` should contain the same variable twice.\"),\n  (guard (perms.all $ λp, p.perm p₀) <|>\n    fail (\"The permutations `xs_i` in `using [xs_1, …, xs_n]` must be permutations of the same\" ++\n      \" variables.\")),\n  perms.mmap (λp, p.mmap get_local)\n\n/-- Without loss of generality: reduces to one goal under variables permutations.\n\nGiven a goal of the form `g xs`, a predicate `p` over a set of variables, as well as variable\npermutations `xs_i`. Then `wlog` produces goals of the form\n\nThe case goal, i.e. the permutation `xs_i` covers all possible cases:\n  `⊢ p xs_0 ∨ ⋯ ∨ p xs_n`\nThe main goal, i.e. the goal reduced to `xs_0`:\n  `(h : p xs_0) ⊢ g xs_0`\nThe invariant goals, i.e. `g` is invariant under `xs_i`:\n  `(h : p xs_i) (this : g xs_0) ⊢ gs xs_i`\n\nEither the permutation is provided, or a proof of the disjunction is provided to compute the\npermutation. The disjunction need to be in assoc normal form, e.g. `p₀ ∨ (p₁ ∨ p₂)`. In many cases\nthe invariant goals can be solved by AC rewriting using `cc` etc.\n\nExample:\n  On a state `(n m : ℕ) ⊢ p n m` the tactic `wlog h : n ≤ m using [n m, m n]` produces the following\n  states:\n    `(n m : ℕ) ⊢ n ≤ m ∨ m ≤ n`\n    `(n m : ℕ) (h : n ≤ m) ⊢ p n m`\n    `(n m : ℕ) (h : m ≤ n) (this : p n m) ⊢ p m n`\n\n`wlog` supports different calling conventions. The name `h` is used to give a name to the introduced\ncase hypothesis. If the name is avoided, the default will be `case`.\n\n(1) `wlog : p xs0 using [xs0, …, xsn]`\n  Results in the case goal `p xs0 ∨ ⋯ ∨ ps xsn`, the main goal `(case : p xs0) ⊢ g xs0` and the\n  invariance goals `(case : p xsi) (this : g xs0) ⊢ g xsi`.\n\n(2) `wlog : p xs0 := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 ∨ ⋯ ∨ p xsi`, it is also used to compute the\n  variable permutations.\n\n(3) `wlog := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 ∨ ⋯ ∨ p xsi`, it is also used to compute the\n  variable permutations. This is not as stable as (2), for example `p` cannot be a disjunction.\n\n(4) `wlog : R x y using x y` and `wlog : R x y`\n  Produces the case `R x y ∨ R y x`. If `R` is ≤, then the disjunction discharged using linearity.\n  If `using x y` is avoided then `x` and `y` are the last two variables appearing in the\n  expression `R x y`. -/\nmeta def wlog\n  (h : parse ident?)\n  (pat : parse (tk \":\" *> texpr)?)\n  (cases : parse (tk \":=\" *> texpr)?)\n  (perms : parse (tk \"using\" *> (list_of (ident*) <|> (λx, [x]) <$> ident*))?)\n  (discharger : tactic unit :=\n    (tactic.solve_by_elim <|> tactic.tautology {classical := tt} <|>\n      using_smt (smt_tactic.intros >> smt_tactic.solve_goals))) :\n  tactic unit := do\nperms ← parse_permutations perms,\n(pat, cases_pr, cases_goal, vars, perms) ← (match cases with\n| some r := do\n  vars::_ ← return perms |\n    fail \"At least one set of variables expected, i.e. `using x y` or `using [x y, y x]`.\",\n  cases_pr ← to_expr r,\n  cases_pr ← (if cases_pr.is_local_constant\n    then return $ match h with some n := update_pp_name cases_pr n | none := cases_pr end\n    else do\n      note (h.get_or_else `case) none cases_pr),\n  cases ← infer_type cases_pr,\n  (pat, perms') ← match pat with\n  | some pat := do\n    pat ← to_expr pat,\n    let vars' := vars.filter $ λv, v.occurs pat,\n    case_pat ← mk_pattern [] vars' pat [] vars',\n    perms' ← match_perms case_pat cases,\n    return (pat, perms')\n  | none := do\n    (p :: ps) ← dest_or cases,\n    let vars' := vars.filter $ λv, v.occurs p,\n    case_pat ← mk_pattern [] vars' p [] vars',\n    perms' ← (p :: ps).mmap (λp, do m ← match_pattern case_pat p, return m.2),\n    return (p, perms')\n  end,\n  let vars_name := vars.map local_uniq_name,\n  guard (perms'.all $ λp, p.all $ λv, v.is_local_constant ∧ v.local_uniq_name ∈ vars_name) <|>\n    fail \"Cases contains variables not declared in `using x y z`\",\n  perms ← (if perms.length = 1\n    then do\n      return (perms'.map $ λ p,\n        p ++ vars.filter (λ v, p.all (λ v', v'.local_uniq_name ≠ v.local_uniq_name)))\n    else do\n      guard (perms.length = perms'.length) <|>\n        fail \"The provided permutation list has a different length then the provided cases.\",\n      return perms),\n  return (pat, cases_pr, @none expr, vars, perms)\n\n| none   := do\n  let name_h := h.get_or_else `case,\n  some pat ← return pat | fail \"Either specify cases or a pattern with permutations\",\n  pat ← to_expr pat,\n  (do\n    [x, y] ← match perms with\n    | []  := return pat.list_local_consts\n    | [l] := return l\n    | _   := failed\n    end,\n    let cases := mk_or_lst\n      [pat, pat.instantiate_locals [(x.local_uniq_name, y), (y.local_uniq_name, x)]],\n    (do\n      `(%%x' ≤ %%y') ← return pat,\n      (cases_pr, []) ← local_proof name_h cases (exact ``(le_total %%x' %%y')),\n      return (pat, cases_pr, none, [x, y], [[x, y], [y, x]]))\n    <|>\n    (do\n      (cases_pr, [g]) ← local_proof name_h cases skip,\n      return (pat, cases_pr, some g, [x, y], [[x, y], [y, x]]))) <|>\n  (do\n    guard (perms.length ≥ 2) <|>\n      fail (\"To generate cases at least two permutations are required, i.e. `using [x y, y x]`\" ++\n        \" or exactly 0 or 2 variables\"),\n    (vars :: perms') ← return perms,\n    let names := vars.map local_uniq_name,\n    let cases := mk_or_lst (pat :: perms'.map (λp, pat.instantiate_locals (names.zip p))),\n    (cases_pr, [g]) ← local_proof name_h cases skip,\n    return (pat, cases_pr, some g, vars, perms))\nend),\nlet name_fn := if perms.length = 2 then λ _, `invariant else\n  λ i, mk_simple_name (\"invariant_\" ++ to_string (i + 1)),\nwith_enable_tags $ tactic.focus1 $ do\n  t ← get_main_tag,\n  tactic.wlog vars cases_pr pat perms,\n  tactic.focus (set_main_tag (mk_num_name `_case 0 :: `main :: t) ::\n    (list.range (perms.length - 1)).map (λi, do\n      set_main_tag (mk_num_name `_case 0 :: name_fn i :: t),\n      try discharger)),\n  match cases_goal with\n  | some g := do\n    set_tag g (mk_num_name `_case 0 :: `cases :: t),\n    gs ← get_goals,\n    set_goals (g :: gs)\n  | none := skip\n  end\n\nadd_tactic_doc\n{ name := \"wlog\",\n  category := doc_category.tactic,\n  decl_names := [``wlog],\n  tags := [\"logic\"] }\n\nend interactive\n\nend tactic\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/tactic/wlog.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.709019146082187, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.47178883086119927}}
{"text": "import set_theory.cardinal\nimport Rings.ToMathlib.fol\nimport data.W.cardinal\n\nuniverses u v\n\nnamespace fol\n\nvariables {L : Language.{u}}\n\nopen_locale cardinal\n\nopen fol.Language\n\ndef bounded_term.rec2_aux {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  Π {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n  (ih_ts : ∀s, ts.pmem s → C s), C (bd_apps t ts)\n| l (bd_var k) dvector.nil := λ _, hvar k\n| l (bd_func f)  ts := λ hs, hfunc f ts hs\n| l (bd_app t s) ts := λ hs, bounded_term.rec2_aux t (dvector.cons s ts) $\n  λ r hr, psum.cases_on hr\n    (λ hrs, eq.rec_on hrs.symm (bounded_term.rec2_aux s dvector.nil $\n      λ s₀ hs₀, false.elim $ by {cases hs₀}))\n    (hs _)\n\ndef bounded_term.rec2 {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  ∀(t : bounded_term L n), C t :=\nλt, bounded_term.rec2_aux hvar (λ _, hfunc) t dvector.nil (λ s hs, false.elim $ by {cases hs})\n\n-- have h : ∀{n l} (f : bounded_preformula L n l) (ts : dvector (bounded_term L n) l),\n--   C n (bd_apps_rel f ts),\n-- begin\n--   intros, induction f; try {rw ts.zero_eq},\n--   apply hfalsum, apply hequal, apply hrel, apply f_ih (f_t::ts),\n--   exact himp (f_ih_f₁ ([])) (f_ih_f₂ ([])), exact hall (f_ih ([]))\n-- end,\n-- λn f, h f ([])\n\ndef bounded_formula.rec2_aux {C : Πn, bounded_formula L n → Sort v}\n  (hfalsum : Π {n}, C n ⊥)\n  (hequal : Π {n} (t₁ t₂ : bounded_term L n), C n (t₁ ≃ t₂))\n  (hrel : Π {n l : ℕ} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : Π {n} {f₁ f₂ : bounded_formula L n} (ih₁ : C n f₁) (ih₂ : C n f₂), C n (f₁ ⟹ f₂))\n  (hall : Π {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (∀' f)) :\n  ∀{n l} (f : bounded_preformula L n l) (ts : dvector (bounded_term L n) l),\n  C n (bd_apps_rel f ts)\n| _ _ bd_falsum dvector.nil := hfalsum\n| _ _ (t₁ ≃ t₂) dvector.nil := hequal _ _\n| _ _ (bd_rel R)         ts := hrel _ _\n| _ _ (bd_apprel f t)    ts := by {let x := bounded_formula.rec2_aux f (dvector.cons t ts),\n  dsimp [bd_apps_rel] at x, exact x }\n| _ _ (f₁ ⟹ f₂) dvector.nil := himp (bounded_formula.rec2_aux f₁ dvector.nil)\n  (bounded_formula.rec2_aux f₂ dvector.nil)\n| _ _ (∀' f)    dvector.nil := hall (bounded_formula.rec2_aux f dvector.nil)\n\ndef bounded_formula.rec2 {C : Πn, bounded_formula L n → Sort v}\n  (hfalsum : Π {n}, C n ⊥)\n  (hequal : Π {n} (t₁ t₂ : bounded_term L n), C n (t₁ ≃ t₂))\n  (hrel : Π {n l : ℕ} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : Π {n} {f₁ f₂ : bounded_formula L n} (ih₁ : C n f₁) (ih₂ : C n f₂), C n (f₁ ⟹ f₂))\n  (hall : Π {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (∀' f)) :\n  ∀{n : ℕ} (f : bounded_formula L n), C n f :=\nλ n f, bounded_formula.rec2_aux (λ _, hfalsum) (λ _, hequal) (λ _ _, hrel) (λ _ _ _, himp)\n  (λ _ _, hall) f dvector.nil\n\n-- lemma bounded_term.rec2_aux_bd_apps {n} {C : bounded_term L n → Sort v}\n--   (hvar : ∀(k : fin n), C &k)\n--   (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n--   ∀ {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : ∀t, ts.pmem t → C t),\n--   bounded_term.rec2_aux hvar (λ _, hfunc) (bd_apps t ts)\n--     = sorry :=\n-- begin\n--   sorry\n--   -- intros l t,\n--   -- induction t,\n--   -- {\n--   --   intro ts,\n--   --   -- induction ts,\n\n\n--   -- },\n--   -- {sorry},\n-- end\n\nlemma bounded_term.rec2_bd_var {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  ∀ (k : fin n),\n  bounded_term.rec2 hvar (λ _, hfunc) &k = hvar k := λ k, rfl\n\nlemma bounded_term.rec2_bd_apps {n} {C : bounded_term L n → Sort v}\n  (hvar : ∀(k : fin n), C &k)\n  (hfunc : Π {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t), C (bd_apps (bd_func f) ts)) :\n  ∀ {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : ∀t, ts.pmem t → C t),\n  bounded_term.rec2 hvar (λ _, hfunc) (bd_apps (bd_func f) ts)\n    = hfunc f ts ih_ts :=\nbegin\n  intros l f ts,\n  induction ts with a b c hind e f g,\n  { intro ih_ts,\n    dsimp [bounded_term.rec2, bounded_term.rec2_aux],\n    apply congr_arg,\n    ext _ a,\n    cases a },\n  {\n    intro ih_ts,\n    dsimp [bd_apps, bounded_term.rec2, bounded_term.rec2_aux],\n    sorry,\n\n  },\nend\n\nnamespace cardinal\n\nvariables (L) (n : ℕ)\n\n/-- We make `bounded_term L n` as a `W_type`, viewing the `W_type` as an inductive type\n  the constructors would be indexed by the following definition.\n  For each `k < n` we have a variable `xₙ` (with arity zero given by `pempty`)\n  For each `⟨ n , f ⟩ : Σ n : ℕ, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_α := ulift.{u} (fin n) ⊕ Σ m : ulift.{u} ℕ, L.functions m.down\n\n/-- To define the arities in the `W_type` for `closed_term`.\n  For each `n : ℕ` we have a variable `xₙ` (with arity zero given by `pempty`)\n  For each `⟨ n , f ⟩ : Σ n : ℕ, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_β : Π (c : term_α.{u} L n), Type u\n| (sum.inl m) := pempty.{u+1}\n| (sum.inr ⟨ m , f ⟩) := ulift.{u} (fin m.down)\n\nvariable {L}\n\n/-- The forward map of the equivalence `W_type_term_β_equiv_closed_term` -/\n@[reducible] def bounded_term_of_W_type_term_β : W_type (term_β L n) → bounded_term L n\n| ⟨ sum.inl m , b ⟩ := x_ m.down\n| ⟨ sum.inr (⟨ n , f ⟩) , b ⟩ := bd_apps (bd_func f)\n  (dvector.of_fn (λ k, bounded_term_of_W_type_term_β $ b (ulift.up k)))\n\n/-- The forward map of the equivalence `W_type_term_β_equiv_closed_term` -/\n@[reducible] def W_type_term_β_of_bounded_term : bounded_term L n → W_type (term_β L n) :=\n  bounded_term.rec2\n    (λ m, ⟨ sum.inl ⟨m⟩ , pempty.elim ⟩) $\n    λ l f ts rec,\n    ⟨ sum.inr ⟨ ulift.up l , f ⟩, λ k : ulift (fin l), rec (dvector.nth' ts $ k.down) dvector.pmem_nth' ⟩\n\nlemma bounded_term_of_W_type_term_β_right_inv : ∀ t : bounded_term L n,\n  bounded_term_of_W_type_term_β n (W_type_term_β_of_bounded_term n t) = t :=\nbegin\n  apply bounded_term.rec2,\n  { intro k, refl },\n  { intros l f ts hind,\n    dsimp only [W_type_term_β_of_bounded_term],\n    rw bounded_term.rec2_bd_apps _ _ _ _ (λ t _, W_type_term_β_of_bounded_term n t),\n    dsimp [bounded_term_of_W_type_term_β],\n    congr,\n    rw dvector.ext,\n    intro i,\n    simp [dvector.nth'_of_fn],\n    apply hind,\n    exact dvector.pmem_nth' },\nend\n\n/- This is really an equivalence, but we only need surjectivity -/\nlemma bounded_term_of_W_type_term_β_surjective :\n  function.surjective (@bounded_term_of_W_type_term_β L n) :=\nbegin\n  intros t,\n  use W_type_term_β_of_bounded_term n t,\n  exact bounded_term_of_W_type_term_β_right_inv _ _,\nend\n\nlemma fintype_term_β : Π (a : term_α L n), fintype (term_β L n a)\n| (sum.inl ⟨ m ⟩) := by apply_instance\n| (sum.inr ⟨ m , f ⟩) := fintype.of_equiv (fin m.down) equiv.ulift.symm\n\nlocal attribute [instance] fintype_term_β\n\nlemma bounded_term_le_functions : #(bounded_term L n) ≤\n  max (cardinal.sum (λ n : ulift.{u} (ℕ), #(L.functions n.down))) ω :=\ncalc #(bounded_term L n)\n      ≤ #(W_type (term_β.{u} L n)) :\n    cardinal.mk_le_of_surjective (bounded_term_of_W_type_term_β_surjective n)\n  ... ≤ max (# (ulift.{u} (fin n) ⊕ Σ (m : ulift.{u} ℕ), L.functions m.down)) ω :\n    W_type.cardinal_mk_le_max_omega_of_fintype\n  ... ≤ max (#(Σ n : ulift.{u} ℕ, L.functions n.down)) ω :\n  begin\n    apply max_le _ (le_max_right _ _),\n    simp only [cardinal.mk_sum],\n    apply le_trans (cardinal.add_le_max _ _),\n    apply max_le _ (le_max_right _ _),\n    apply max_le (le_max_of_le_right _) (le_max_of_le_left _),\n    { apply le_of_lt, simp [cardinal.lt_omega] },\n    { simp },\n  end\n  ... = max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :\n    by {rw cardinal.mk_sigma _}\n\n/- We show that the formulas are bounded above by the terms.\n  We first construct a `W_type` for each `bounded_formula L n` as follows\n  ```\n  | constructor | multiplicity         | arity |\n  |-------------+----------------------+-------|\n  | ⊥           | unit                 | empty |\n  | t₁ ≃ t₂     | (bounded_term L n)²  | empty |\n  | ⟹           | unit                 | bool  |\n  ```\n  This gives us a way of injecting `bounded_formula L n`\n  into `W_type β n ⊕ bounded_formula L (n+1)` (to account for `∀`) (there are no relations).\n  This ultimately gives us\n  `bounded_formula L 0 ↪ Σ n : ℕ, W_type β n ` where instead of\n  mapping into `bounded_formula L (n+1)` we map into the next `W_type β (n+1)`.\n  We have bounds on each `W_type β n`, namely by `unit`, `(bounded_term L n)²` and `ω`.\n  Finally we can remove `unit` and the squaring.\n\n  The difference with the case of terms is `bd_all`\n  and the induction is captured in the following example\n  ```\n  inductive box : ℕ → Type u\n  | base {n} : box n\n  | drop {n} (f : box (n+1)) : box n\n  ```\n-/\n\nvariable (L)\n\n/-- We inject `bounded_formula L n` into the `W_type` built from this `⊕` `bounded_formula L (n+1)`.\n  This could be generalized to when `L` has relation symbols,\n  in which case more constructors should be added.\n  -/\ndef formula_α : Type u := punit.{u+1} ⊕ ((bounded_term L n) × (bounded_term L n)) ⊕ punit.{u+1}\n\n/-- The arities of the constructors `formula_α` for the `W_type` -/\ndef formula_β : formula_α L n → Type u\n| (sum.inl x)           := pempty.{u+1}\n| (sum.inr (sum.inl x)) := pempty.{u+1}\n| (sum.inr (sum.inr x)) := ulift.{u} bool\n\nvariable {L}\n\n/-- For the recursion to work, first map to the `W_type` in\n  `W_type_sum_bounded_formula_succ_of_bounded_formula` -/\n@[simp, reducible] def W_type_of_bounded_formula [is_algebraic L] {n} :\n  bounded_formula L n → W_type (formula_β L n) :=\nbounded_formula.rec2\n  (λ _, ⟨ sum.inl punit.star , pempty.elim ⟩) -- bd_falsum\n  (λ _ t s, ⟨ sum.inr $ sum.inl ⟨ t , s ⟩ , pempty.elim ⟩) -- t ≃ s\n  (λ _ l r, false.elim $ Language.is_algebraic.empty_relations l r) -- there are no relation symbols\n  (λ _ f₁ f₂ recf₁ recf₂, ⟨ sum.inr $ sum.inr punit.star , λ ⟨b⟩, bool.rec_on b recf₁ recf₂ ⟩ )\n    -- bd_imp\n  (λ _ _ _, ⟨ sum.inl punit.star , pempty.elim ⟩) -- bd_all degenerate case\n\n/-- For all `n` we make a characterizing type for `bounded_formula L n`,\n  in the sense that this should be an equivalence.\n  For the recursion to work in the `⟹` case,\n  it is important to define it without the `∀` first.\n  For the recursion to work in the `∀` case,\n  it is important to define it for all `n` at once. -/\n@[simp, reducible] def W_type_sum_bounded_formula_succ_of_bounded_formula [is_algebraic L] {n} :\n  bounded_formula L n → W_type (formula_β L n) ⊕ bounded_formula L (n+1) :=\nbounded_formula.rec2\n  (λ k, sum.inl (W_type_of_bounded_formula ⊥)) -- bd_falsum\n  (λ _ t s, sum.inl (W_type_of_bounded_formula (t ≃ s))) -- t ≃ s\n  (λ _ l r, false.elim $ Language.is_algebraic.empty_relations l r) -- there are no relation symbols\n  (λ _ f₁ f₂ recf₁ recf₂, sum.inl (W_type_of_bounded_formula (f₁ ⟹ f₂))) -- bd_imp\n  (λ _ f _, sum.inr f)\n\n/-- Mapping `W_type_oplus_bounded_formula_succ_of_bounded_formula` just on the W_type -/\n@[simp, reducible] def bounded_formula_of_W_type {n} :\n  W_type (formula_β L n) → bounded_formula L n\n| ⟨ (sum.inl x) , y ⟩ := ⊥\n| ⟨ (sum.inr (sum.inl ⟨ t , s ⟩)) , y ⟩ := t ≃ s\n| ⟨ (sum.inr (sum.inr x)) , y ⟩ :=\n  bounded_formula_of_W_type (y $ ⟨ tt ⟩) ⟹\n  bounded_formula_of_W_type (y $ ⟨ ff ⟩)\n\n/-- The supposed inverse of `W_type_oplus_bounded_formula_succ_of_bounded_formula`.\n  we want this to be surjective. -/\n@[simp, reducible] def bounded_formula_of_W_type_sum_bounded_formula_succ {n} :\n  W_type (formula_β L n) ⊕ bounded_formula L (n+1) → bounded_formula L n\n| (sum.inl x) := bounded_formula_of_W_type x\n| (sum.inr f) := ∀' f\n\nlemma bounded_formula_of_W_type_right_inv\n  [is_algebraic L] {n} : ∀ f : bounded_formula L n,\n  ((∀ g : bounded_formula L (n+1), f ≠ ∀' g) →\n    bounded_formula_of_W_type (W_type_of_bounded_formula f) = f) :=\nbegin\n  apply @bounded_formula.rec2 _\n    (λ (n : ℕ) f : bounded_formula L n, (∀ g : bounded_formula L (n+1), f ≠ ∀' g) →\n    bounded_formula_of_W_type (W_type_of_bounded_formula f) = f),\n  { intros,\n    simp [bounded_formula.rec2, bounded_formula.rec2_aux] },\n  { intros,\n    simp [bounded_formula.rec2, bounded_formula.rec2_aux] },\n  { intros n l r,\n    exfalso,\n    exact Language.is_algebraic.empty_relations l r },\n  { intros _ _ _ h1 h2 _,\n    simp only [bounded_formula_of_W_type_sum_bounded_formula_succ,\n      bounded_formula_of_W_type, W_type_of_bounded_formula,\n      W_type_sum_bounded_formula_succ_of_bounded_formula,\n      bounded_formula.rec2, bounded_formula.rec2_aux],\n    split,\n    {\n      convert h1,\n\n}\n  },\n  sorry,\nend\n\nlemma bounded_formula_of_W_type_sum_bounded_formula_right_inv\n  [is_algebraic L] {n} : ∀ f : bounded_formula L n,\n  bounded_formula_of_W_type_sum_bounded_formula_succ\n    (W_type_sum_bounded_formula_succ_of_bounded_formula f) = f :=\nbegin\n  apply bounded_formula.rec2,\n  { intro,\n    simp [bounded_formula.rec2, bounded_formula.rec2_aux] },\n  { intros,\n    simp [bounded_formula.rec2, bounded_formula.rec2_aux] },\n  { intros n l r,\n    exfalso,\n    exact Language.is_algebraic.empty_relations l r },\n  { intros _ _ _ h1 h2,\n    simp only [bounded_formula_of_W_type_sum_bounded_formula_succ,\n      bounded_formula_of_W_type, W_type_of_bounded_formula,\n      W_type_sum_bounded_formula_succ_of_bounded_formula,\n      bounded_formula.rec2, bounded_formula.rec2_aux],\n    split,\n    {\n      convert h1,\n      sorry,\n      -- simp [bounded_formula_of_W_type_sum_bounded_formula_succ,\n      --   bounded_formula_of_W_type, W_type_of_bounded_formula,\n      --   W_type_sum_bounded_formula_succ_of_bounded_formula,\n      --   bounded_formula.rec2, bounded_formula.rec2_aux],\n      -- sorry,\n    },\n    { sorry }\n    },\n  {sorry},\nend\n\nlemma bounded_formula_of_W_type_sum_bounded_formula_succ_surjective [is_algebraic L] {n}:\n  function.surjective $ @bounded_formula_of_W_type_sum_bounded_formula_succ L n :=\nbegin\n  intro f,\n  use W_type_sum_bounded_formula_succ_of_bounded_formula f,\n  -- cases f,\n  sorry\nend\n\n-- lemma W_type_oplus_bounded_formula_succ_of_bounded_formula_injective [is_algebraic L] {n} :\n--   function.injective $ @W_type_oplus_bounded_formula_succ_of_bounded_formula L _ n :=\n-- begin\n--   intros f₁ f₂,\n\n-- end\n\n-- def W_type_oplus_bounded_formula_succ_of_bounded_formula\n\nlemma bounded_formula_le_bounded_term :\n  #(bounded_formula L 0) ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(bounded_term L n.down))) ω :=\nsorry\n\nlemma sentence_le_functions :\n  #(bounded_formula L 0) ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :=\nbegin\n  apply le_trans (bounded_formula_le_bounded_term),\n  apply max_le _ (le_max_right _ _),\n  apply le_trans (cardinal.sum_le_sup _),\n  simp only [cardinal.mk_denumerable],\n  apply le_trans (cardinal.mul_le_max _ _),\n  apply max_le _ (le_max_right _ _),\n  apply max_le (le_max_right _ _),\n  rw cardinal.sup_le,\n  intro i,\n  apply bounded_term_le_functions,\nend\n\nvariable (L)\n\n/-- Applying `∀` is an injection downwards. -/\ndef bounded_formula_bd_all : bounded_formula L (n+1) → (bounded_formula L n) :=\nλ ϕ, ∀' ϕ\n\n/-- Applying `∀` n times is an injection. \"Dropbox\" -/\ndef bounded_formula_bd_alls : Π n, bounded_formula L n → (bounded_formula L 0)\n| 0 := id\n| (n+1) := (bounded_formula_bd_alls n) ∘ bounded_formula_bd_all L n\n\nvariable {L}\n\nlemma bounded_formula_bd_all_injective : function.injective (bounded_formula_bd_all L n) :=\nλ ϕ ψ, bounded_preformula.bd_all.inj\n\nlemma bounded_formula_bd_alls_injective : Π n, function.injective (bounded_formula_bd_alls L n)\n| 0 := function.injective_id\n| (n+1) := function.injective.comp (bounded_formula_bd_alls_injective n) (bounded_formula_bd_all_injective n)\n\n/- Using ∀ we can embed `bounded_formula L (n+1)` into `bounded_formula L n`,\n  hence showing they are all bounded by the function symbols\n -/\nlemma bounded_formula_le_functions (n : ℕ) :\n  #(bounded_formula L n) ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :=\ncalc #(bounded_formula L n) ≤ #(bounded_formula L 0) : cardinal.mk_le_of_injective (bounded_formula_bd_alls_injective _)\n                        ... ≤ max (cardinal.sum (λ n : ulift.{u} ℕ, #(L.functions n.down))) ω :\n                        sentence_le_functions\n\nend cardinal\n\nend fol\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/cardinal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4717888179741209}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nA basic theory of Cauchy sequences, used in the construction of the reals.\nWhere applicable, lemmas that will be reused in other contexts have\nbeen stated in extra generality.\n-/\nimport algebra.big_operators algebra.ordered_field\n\nclass is_absolute_value {α} [discrete_linear_ordered_field α]\n  {β} [ring β] (f : β → α) : Prop :=\n(abv_nonneg : ∀ x, 0 ≤ f x)\n(abv_eq_zero : ∀ {x}, f x = 0 ↔ x = 0)\n(abv_add : ∀ x y, f (x + y) ≤ f x + f y)\n(abv_mul : ∀ x y, f (x * y) = f x * f y)\n\nnamespace is_absolute_value\nvariables {α : Type*} [discrete_linear_ordered_field α]\n  {β : Type*} [ring β] (abv : β → α) [is_absolute_value abv]\n\ntheorem abv_zero : abv 0 = 0 := (abv_eq_zero abv).2 rfl\n\ntheorem abv_one' (h : (1:β) ≠ 0) : abv 1 = 1 :=\n(domain.mul_left_inj $ mt (abv_eq_zero abv).1 h).1 $\nby rw [← abv_mul abv, mul_one, mul_one]\n\ntheorem abv_one\n  {β : Type*} [domain β] (abv : β → α) [is_absolute_value abv] :\n  abv 1 = 1 := abv_one' abv one_ne_zero\n\ntheorem abv_pos {a : β} : 0 < abv a ↔ a ≠ 0 :=\nby rw [lt_iff_le_and_ne, ne, eq_comm]; simp [abv_eq_zero abv, abv_nonneg abv]\n\ntheorem abv_neg (a : β) : abv (-a) = abv a :=\nby rw [← mul_self_inj_of_nonneg (abv_nonneg abv _) (abv_nonneg abv _),\n  ← abv_mul abv, ← abv_mul abv]; simp\n\ntheorem abv_sub (a b : β) : abv (a - b) = abv (b - a) :=\nby rw [← neg_sub, abv_neg abv]\n\ntheorem abv_inv\n  {β : Type*} [discrete_field β] (abv : β → α) [is_absolute_value abv]\n  (a : β) : abv a⁻¹ = (abv a)⁻¹ :=\nclassical.by_cases\n  (λ h : a = 0, by simp [h, abv_zero abv])\n  (λ h, (domain.mul_left_inj (mt (abv_eq_zero abv).1 h)).1 $\n    by rw [← abv_mul abv]; simp [h, mt (abv_eq_zero abv).1 h, abv_one abv])\n\ntheorem abv_div\n  {β : Type*} [discrete_field β] (abv : β → α) [is_absolute_value abv]\n  (a b : β) : abv (a / b) = abv a / abv b :=\nby rw [division_def, abv_mul abv, abv_inv abv]; refl\n\nlemma abv_sub_le (a b c : β) : abv (a - c) ≤ abv (a - b) + abv (b - c) :=\nby simpa using abv_add abv (a - b) (b - c)\n\nlemma sub_abv_le_abv_sub (a b : β) : abv a - abv b ≤ abv (a - b) :=\nsub_le_iff_le_add.2 $ by simpa using abv_add abv (a - b) b\n\nlemma abs_abv_sub_le_abv_sub (a b : β) :\n  abs (abv a - abv b) ≤ abv (a - b) :=\nabs_sub_le_iff.2 ⟨sub_abv_le_abv_sub abv _ _,\n  by rw abv_sub abv; apply sub_abv_le_abv_sub abv⟩\n\nend is_absolute_value\n\ninstance abs_is_absolute_value {α} [discrete_linear_ordered_field α] :\n  is_absolute_value (abs : α → α) :=\n{ abv_nonneg  := abs_nonneg,\n  abv_eq_zero := λ _, abs_eq_zero,\n  abv_add     := abs_add,\n  abv_mul     := abs_mul }\n\nopen is_absolute_value\n\ntheorem exists_forall_ge_and {α} [linear_order α] {P Q : α → Prop} :\n  (∃ i, ∀ j ≥ i, P j) → (∃ i, ∀ j ≥ i, Q j) →\n  ∃ i, ∀ j ≥ i, P j ∧ Q j\n| ⟨a, h₁⟩ ⟨b, h₂⟩ := let ⟨c, ac, bc⟩ := exists_ge_of_linear a b in\n  ⟨c, λ j hj, ⟨h₁ _ (le_trans ac hj), h₂ _ (le_trans bc hj)⟩⟩\n\nsection\nvariables {α : Type*} [discrete_linear_ordered_field α]\n  {β : Type*} [ring β] (abv : β → α) [is_absolute_value abv]\n\ntheorem rat_add_continuous_lemma\n  {ε : α} (ε0 : 0 < ε) : ∃ δ > 0, ∀ {a₁ a₂ b₁ b₂ : β},\n  abv (a₁ - b₁) < δ → abv (a₂ - b₂) < δ → abv (a₁ + a₂ - (b₁ + b₂)) < ε :=\n⟨ε / 2, half_pos ε0, λ a₁ a₂ b₁ b₂ h₁ h₂,\n  by simpa [add_halves] using lt_of_le_of_lt (abv_add abv _ _) (add_lt_add h₁ h₂)⟩\n\ntheorem rat_mul_continuous_lemma\n  {ε K₁ K₂ : α} (ε0 : 0 < ε) (K₁0 : 0 < K₁) (K₂0 : 0 < K₂) :\n  ∃ δ > 0, ∀ {a₁ a₂ b₁ b₂ : β}, abv a₁ < K₁ → abv b₂ < K₂ →\n  abv (a₁ - b₁) < δ → abv (a₂ - b₂) < δ → abv (a₁ * a₂ - b₁ * b₂) < ε :=\nbegin\n  have K0 := lt_of_lt_of_le K₁0 (le_max_left _ K₂),\n  have εK := div_pos (half_pos ε0) K0,\n  refine ⟨_, εK, λ a₁ a₂ b₁ b₂ ha₁ hb₂ h₁ h₂, _⟩,\n  replace ha₁ := lt_of_lt_of_le ha₁ (le_max_left _ K₂),\n  replace hb₂ := lt_of_lt_of_le hb₂ (le_max_right K₁ _),\n  have := add_lt_add\n    (mul_lt_mul' (le_of_lt h₁) hb₂ (abv_nonneg abv _) εK)\n    (mul_lt_mul' (le_of_lt h₂) ha₁ (abv_nonneg abv _) εK),\n  rw [← abv_mul abv, mul_comm, div_mul_cancel _ (ne_of_gt K0), ← abv_mul abv, add_halves] at this,\n  simpa [mul_add, add_mul] using lt_of_le_of_lt (abv_add abv _ _) this\nend\n\ntheorem rat_inv_continuous_lemma\n  {β : Type*} [discrete_field β] (abv : β → α) [is_absolute_value abv]\n  {ε K : α} (ε0 : 0 < ε) (K0 : 0 < K) :\n  ∃ δ > 0, ∀ {a b : β}, K ≤ abv a → K ≤ abv b →\n  abv (a - b) < δ → abv (a⁻¹ - b⁻¹) < ε :=\nbegin\n  have KK := mul_pos K0 K0,\n  have εK := mul_pos ε0 KK,\n  refine ⟨_, εK, λ a b ha hb h, _⟩,\n  have a0 := lt_of_lt_of_le K0 ha,\n  have b0 := lt_of_lt_of_le K0 hb,\n  rw [inv_sub_inv ((abv_pos abv).1 a0) ((abv_pos abv).1 b0),\n      abv_div abv, abv_mul abv, mul_comm, abv_sub abv,\n      ← mul_div_cancel ε (ne_of_gt KK)],\n  exact div_lt_div h\n    (mul_le_mul hb ha (le_of_lt K0) (abv_nonneg abv _))\n    (le_of_lt $ mul_pos ε0 KK) KK\nend\nend\n\ndef is_cau_seq {α : Type*} [discrete_linear_ordered_field α]\n  {β : Type*} [ring β] (abv : β → α) [is_absolute_value abv] (f : ℕ → β) :=\n∀ ε > 0, ∃ i, ∀ j ≥ i, abv (f j - f i) < ε\n\nnamespace is_cau_seq\nvariables {α : Type*} [discrete_linear_ordered_field α]\n  {β : Type*} [ring β] {abv : β → α} [is_absolute_value abv] {f : ℕ → β}\n\ntheorem cauchy₂ (hf : is_cau_seq abv f) {ε:α} (ε0 : ε > 0) :\n  ∃ i, ∀ j k ≥ i, abv (f j - f k) < ε :=\nbegin\n  refine (hf _ (half_pos ε0)).imp (λ i hi j k ij ik, _),\n  rw ← add_halves ε,\n  refine lt_of_le_of_lt (abv_sub_le abv _ _ _) (add_lt_add (hi _ ij) _),\n  rw abv_sub abv, exact hi _ ik\nend\n\ntheorem cauchy₃ (hf : is_cau_seq abv f) {ε:α} (ε0 : ε > 0) :\n  ∃ i, ∀ j ≥ i, ∀ k ≥ j, abv (f k - f j) < ε :=\nlet ⟨i, H⟩ := hf.cauchy₂ ε0 in ⟨i, λ j ij k jk, H _ _ (le_trans ij jk) ij⟩\n\nend is_cau_seq\n\ndef cau_seq {α : Type*} [discrete_linear_ordered_field α]\n  (β : Type*) [ring β] (abv : β → α) [is_absolute_value abv] :=\n{f : ℕ → β // is_cau_seq abv f}\n\nnamespace cau_seq\nvariables {α : Type*} [discrete_linear_ordered_field α]\n\nsection ring\nvariables {β : Type*} [ring β] {abv : β → α} [is_absolute_value abv]\n\ninstance : has_coe_to_fun (cau_seq β abv) := ⟨_, subtype.val⟩\n\n@[simp] theorem mk_to_fun (f) (hf : is_cau_seq abv f) :\n  @coe_fn (cau_seq β abv) _ ⟨f, hf⟩ = f := rfl\n\ntheorem ext {f g : cau_seq β abv} (h : ∀ i, f i = g i) : f = g :=\nsubtype.eq (funext h)\n\ntheorem is_cau (f : cau_seq β abv) : is_cau_seq abv f := f.2\n\ntheorem cauchy (f : cau_seq β abv) :\n  ∀ {ε}, ε > 0 → ∃ i, ∀ j ≥ i, abv (f j - f i) < ε := f.2\n\ntheorem cauchy₂ (f : cau_seq β abv) {ε:α} : ε > 0 →\n  ∃ i, ∀ j k ≥ i, abv (f j - f k) < ε := f.2.cauchy₂\n\ntheorem cauchy₃ (f : cau_seq β abv) {ε:α} : ε > 0 →\n  ∃ i, ∀ j ≥ i, ∀ k ≥ j, abv (f k - f j) < ε := f.2.cauchy₃\n\ntheorem bounded (f : cau_seq β abv) : ∃ r, ∀ i, abv (f i) < r :=\nbegin\n  cases f.cauchy zero_lt_one with i h,\n  let R := (finset.range (i+1)).sum (λ j, abv (f j)),\n  have : ∀ j ≤ i, abv (f j) ≤ R,\n  { intros j ij, change (λ j, abv (f j)) j ≤ R,\n    apply finset.single_le_sum,\n    { intros, apply abv_nonneg abv },\n    { rwa [finset.mem_range, nat.lt_succ_iff] } },\n  refine ⟨R + 1, λ j, _⟩,\n  cases lt_or_le j i with ij ij,\n  { exact lt_of_le_of_lt (this _ (le_of_lt ij)) (lt_add_one _) },\n  { have := lt_of_le_of_lt (abv_add abv _ _)\n      (add_lt_add_of_le_of_lt (this _ (le_refl _)) (h _ ij)),\n    rw [add_sub, add_comm] at this, simpa }\nend\n\ntheorem bounded' (f : cau_seq β abv) (x : α) : ∃ r > x, ∀ i, abv (f i) < r :=\nlet ⟨r, h⟩ := f.bounded in\n⟨max r (x+1), lt_of_lt_of_le (lt_add_one _) (le_max_right _ _),\n  λ i, lt_of_lt_of_le (h i) (le_max_left _ _)⟩\n\ndef of_eq (f : cau_seq β abv) (g : ℕ → β) (e : ∀ i, f i = g i) : cau_seq β abv :=\n⟨g, λ ε, by rw [show g = f, from (funext e).symm]; exact f.cauchy⟩\n\ninstance : has_add (cau_seq β abv) :=\n⟨λ f g, ⟨λ i, (f i + g i : β), λ ε ε0,\n  let ⟨δ, δ0, Hδ⟩ := rat_add_continuous_lemma abv ε0,\n      ⟨i, H⟩ := exists_forall_ge_and (f.cauchy₃ δ0) (g.cauchy₃ δ0) in\n  ⟨i, λ j ij, let ⟨H₁, H₂⟩ := H _ (le_refl _) in Hδ (H₁ _ ij) (H₂ _ ij)⟩⟩⟩\n\n@[simp] theorem add_apply (f g : cau_seq β abv) (i : ℕ) : (f + g) i = f i + g i := rfl\n\nvariable (abv)\ndef const (x : β) : cau_seq β abv :=\n⟨λ i, x, λ ε ε0, ⟨0, λ j ij, by simpa [abv_zero abv] using ε0⟩⟩\nvariable {abv}\n\nlocal notation `const` := const abv\n\n@[simp] theorem const_apply (x : β) (i : ℕ) : (const x : ℕ → β) i = x := rfl\n\ntheorem const_inj {x y : β} : (const x : cau_seq β abv) = const y ↔ x = y :=\n⟨λ h, congr_arg (λ f:cau_seq β abv, (f:ℕ→β) 0) h, congr_arg _⟩\n\ninstance : has_zero (cau_seq β abv) := ⟨const 0⟩\ninstance : has_one (cau_seq β abv) := ⟨const 1⟩\n\n@[simp] theorem zero_apply (i) : (0 : cau_seq β abv) i = 0 := rfl\n@[simp] theorem one_apply (i) : (1 : cau_seq β abv) i = 1 := rfl\n\ntheorem const_add (x y : β) : const (x + y) = const x + const y :=\next $ λ i, rfl\n\ninstance : has_mul (cau_seq β abv) :=\n⟨λ f g, ⟨λ i, (f i * g i : β), λ ε ε0,\n  let ⟨F, F0, hF⟩ := f.bounded' 0, ⟨G, G0, hG⟩ := g.bounded' 0,\n      ⟨δ, δ0, Hδ⟩ := rat_mul_continuous_lemma abv ε0 F0 G0,\n      ⟨i, H⟩ := exists_forall_ge_and (f.cauchy₃ δ0) (g.cauchy₃ δ0) in\n  ⟨i, λ j ij, let ⟨H₁, H₂⟩ := H _ (le_refl _) in\n    Hδ (hF j) (hG i) (H₁ _ ij) (H₂ _ ij)⟩⟩⟩\n\n@[simp] theorem mul_apply (f g : cau_seq β abv) (i : ℕ) : (f * g) i = f i * g i := rfl\n\ntheorem const_mul (x y : β) : const (x * y) = const x * const y :=\next $ λ i, rfl\n\ninstance : has_neg (cau_seq β abv) :=\n⟨λ f, of_eq (const (-1) * f) (λ x, -f x) (λ i, by simp)⟩\n\n@[simp] theorem neg_apply (f : cau_seq β abv) (i) : (-f) i = -f i := rfl\n\ntheorem const_neg (x : β) : const (-x) = -const x :=\next $ λ i, rfl\n\ninstance : ring (cau_seq β abv) :=\nby refine {neg := has_neg.neg, add := (+), zero := 0, mul := (*), one := 1, ..};\n   { intros, apply ext, simp [mul_add, mul_assoc, add_mul] }\n\ninstance {β : Type*} [comm_ring β] {abv : β → α} [is_absolute_value abv] : comm_ring (cau_seq β abv) :=\n{ mul_comm := by intros; apply ext; simp [mul_left_comm, mul_comm],\n  ..cau_seq.ring }\n\ntheorem const_sub (x y : β) : const (x - y) = const x - const y :=\nby rw [sub_eq_add_neg, const_add, const_neg, sub_eq_add_neg]\n\n@[simp] theorem sub_apply (f g : cau_seq β abv) (i : ℕ) : (f - g) i = f i - g i := rfl\n\ndef lim_zero (f : cau_seq β abv) := ∀ ε > 0, ∃ i, ∀ j ≥ i, abv (f j) < ε\n\ntheorem add_lim_zero {f g : cau_seq β abv}\n  (hf : lim_zero f) (hg : lim_zero g) : lim_zero (f + g)\n| ε ε0 := (exists_forall_ge_and\n    (hf _ $ half_pos ε0) (hg _ $ half_pos ε0)).imp $\n  λ i H j ij, let ⟨H₁, H₂⟩ := H _ ij in\n    by simpa [add_halves ε] using lt_of_le_of_lt (abv_add abv _ _) (add_lt_add H₁ H₂)\n\ntheorem mul_lim_zero (f : cau_seq β abv) {g}\n  (hg : lim_zero g) : lim_zero (f * g)\n| ε ε0 := let ⟨F, F0, hF⟩ := f.bounded' 0 in\n  (hg _ $ div_pos ε0 F0).imp $ λ i H j ij,\n  by have := mul_lt_mul' (le_of_lt $ hF j) (H _ ij) (abv_nonneg abv _) F0;\n     rwa [mul_comm F, div_mul_cancel _ (ne_of_gt F0), ← abv_mul abv] at this\n\ntheorem neg_lim_zero {f : cau_seq β abv} (hf : lim_zero f) : lim_zero (-f) :=\nby rw ← neg_one_mul; exact mul_lim_zero _ hf\n\ntheorem sub_lim_zero {f g : cau_seq β abv}\n  (hf : lim_zero f) (hg : lim_zero g) : lim_zero (f - g) :=\nadd_lim_zero hf (neg_lim_zero hg)\n\ntheorem zero_lim_zero : lim_zero (0 : cau_seq β abv)\n| ε ε0 := ⟨0, λ j ij, by simpa [abv_zero abv] using ε0⟩\n\ntheorem const_lim_zero {x : β} : lim_zero (const x) ↔ x = 0 :=\n⟨λ H, (abv_eq_zero abv).1 $\n  eq_of_le_of_forall_le_of_dense (abv_nonneg abv _) $\n  λ ε ε0, let ⟨i, hi⟩ := H _ ε0 in le_of_lt $ hi _ (le_refl _),\nλ e, e.symm ▸ zero_lim_zero⟩\n\ninstance equiv : setoid (cau_seq β abv) :=\n⟨λ f g, lim_zero (f - g),\n⟨λ f, by simp [zero_lim_zero],\n λ f g h, by simpa using neg_lim_zero h,\n λ f g h fg gh, by simpa using add_lim_zero fg gh⟩⟩\n\ntheorem equiv_def₃ {f g : cau_seq β abv} (h : f ≈ g) {ε:α} (ε0 : 0 < ε) :\n  ∃ i, ∀ j ≥ i, ∀ k ≥ j, abv (f k - g j) < ε :=\n(exists_forall_ge_and (h _ $ half_pos ε0) (f.cauchy₃ $ half_pos ε0)).imp $\nλ i H j ij k jk, let ⟨h₁, h₂⟩ := H _ ij in\nby have := lt_of_le_of_lt (abv_add abv (f j - g j) _) (add_lt_add h₁ (h₂ _ jk));\n   rwa [sub_add_sub_cancel', add_halves] at this\n\ntheorem lim_zero_congr {f g : cau_seq β abv} (h : f ≈ g) : lim_zero f ↔ lim_zero g :=\n⟨λ l, by simpa using add_lim_zero (setoid.symm h) l,\n λ l, by simpa using add_lim_zero h l⟩\n\ntheorem abv_pos_of_not_lim_zero {f : cau_seq β abv} (hf : ¬ lim_zero f) :\n  ∃ K > 0, ∃ i, ∀ j ≥ i, K ≤ abv (f j) :=\nbegin\n  haveI := classical.prop_decidable,\n  by_contra nk,\n  refine hf (λ ε ε0, _),\n  simp [not_forall] at nk,\n  cases f.cauchy₃ (half_pos ε0) with i hi,\n  rcases nk _ (half_pos ε0) i with ⟨j, ij, hj⟩,\n  refine ⟨j, λ k jk, _⟩,\n  have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add (hi j ij k jk) hj),\n  rwa [sub_add_cancel, add_halves] at this\nend\n\ntheorem of_near (f : ℕ → β) (g : cau_seq β abv)\n  (h : ∀ ε > 0, ∃ i, ∀ j ≥ i, abv (f j - g j) < ε) : is_cau_seq abv f\n| ε ε0 :=\n  let ⟨i, hi⟩ := exists_forall_ge_and\n    (h _ (half_pos $ half_pos ε0)) (g.cauchy₃ $ half_pos ε0) in\n  ⟨i, λ j ij, begin\n    cases hi _ (le_refl _) with h₁ h₂, rw abv_sub abv at h₁,\n    have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add (hi _ ij).1 h₁),\n    have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add this (h₂ _ ij)),\n    rwa [add_halves, add_halves, add_right_comm,\n         sub_add_sub_cancel, sub_add_sub_cancel] at this\n  end⟩\n\nlemma not_lim_zero_of_not_congr_zero {f : cau_seq _ abv} (hf : ¬ f ≈ 0) : ¬ lim_zero f :=\nassume : lim_zero f,\nhave lim_zero (f - 0), by simpa,\nhf this\n\nlemma mul_equiv_zero  (g : cau_seq _ abv) {f : cau_seq _ abv} (hf : f ≈ 0) : g * f ≈ 0 :=\nhave lim_zero (f - 0), from hf,\nhave lim_zero (g*f), from mul_lim_zero _ $ by simpa,\nshow lim_zero (g*f - 0), by simpa\n\nlemma mul_not_equiv_zero {f g : cau_seq _ abv} (hf : ¬ f ≈ 0) (hg : ¬ g ≈ 0) : ¬ (f * g) ≈ 0 :=\nassume : lim_zero (f*g - 0),\nhave hlz : lim_zero (f*g), by simpa,\nhave hf' : ¬ lim_zero f, by simpa using (show ¬ lim_zero (f - 0), from hf),\nhave hg' : ¬ lim_zero g, by simpa using (show ¬ lim_zero (g - 0), from hg),\nbegin \n  rcases abv_pos_of_not_lim_zero hf' with ⟨a1, ha1, N1, hN1⟩,\n  rcases abv_pos_of_not_lim_zero hg' with ⟨a2, ha2, N2, hN2⟩,\n  have : a1 * a2 > 0, from mul_pos ha1 ha2,\n  cases hlz _ this with N hN,\n  let i := max N (max N1 N2),\n  have hN' := hN i (le_max_left _ _),\n  have hN1' := hN1 i (le_trans (le_max_left _ _) (le_max_right _ _)),\n  have hN1' := hN2 i (le_trans (le_max_right _ _) (le_max_right _ _)),\n  apply not_le_of_lt hN',\n  change _ ≤ abv (_ * _),\n  rw is_absolute_value.abv_mul abv,\n  apply mul_le_mul; try { assumption },\n    { apply le_of_lt ha2 },\n    { apply is_absolute_value.abv_nonneg abv }\nend \n\nend ring\n\nsection comm_ring \nvariables {β : Type*} [comm_ring β] {abv : β → α} [is_absolute_value abv]\n\nlemma mul_equiv_zero' (g : cau_seq _ abv) {f : cau_seq _ abv} (hf : f ≈ 0) : f * g ≈ 0 :=\nby rw mul_comm; apply mul_equiv_zero _ hf\n\nend comm_ring \n\nsection integral_domain\nvariables {β : Type*} [integral_domain β] (abv : β → α) [is_absolute_value abv]\n\nlemma one_not_equiv_zero : ¬ (const abv 1) ≈ (const abv 0) :=\nassume h,\nhave ∀ ε > 0, ∃ i, ∀ k, k ≥ i → abv (1 - 0) < ε, from h,\nhave h1 : abv 1 ≤ 0, from le_of_not_gt $\n  assume h2 : abv 1 > 0,\n  exists.elim (this _ h2) $ λ i hi,\n    lt_irrefl (abv 1) $ by simpa using hi _ (le_refl _),\nhave h2 : abv 1 ≥ 0, from is_absolute_value.abv_nonneg _ _,\nhave abv 1 = 0, from le_antisymm h1 h2,\nhave (1 : β) = 0, from (is_absolute_value.abv_eq_zero abv).1 this,\nabsurd this one_ne_zero\n\nend integral_domain\n\nsection discrete_field\nvariables {β : Type*} [discrete_field β] {abv : β → α} [is_absolute_value abv]\n\ntheorem inv_aux {f : cau_seq β abv} (hf : ¬ lim_zero f) :\n  ∀ ε > 0, ∃ i, ∀ j ≥ i, abv ((f j)⁻¹ - (f i)⁻¹) < ε | ε ε0 :=\nlet ⟨K, K0, HK⟩ := abv_pos_of_not_lim_zero hf,\n    ⟨δ, δ0, Hδ⟩ := rat_inv_continuous_lemma abv ε0 K0,\n    ⟨i, H⟩ := exists_forall_ge_and HK (f.cauchy₃ δ0) in\n⟨i, λ j ij, let ⟨iK, H'⟩ := H _ (le_refl _) in Hδ (H _ ij).1 iK (H' _ ij)⟩\n\ndef inv (f) (hf : ¬ lim_zero f) : cau_seq β abv := ⟨_, inv_aux hf⟩\n\n@[simp] theorem inv_apply {f : cau_seq β abv} (hf i) : inv f hf i = (f i)⁻¹ := rfl\n\ntheorem inv_mul_cancel {f : cau_seq β abv} (hf) : inv f hf * f ≈ 1 :=\nλ ε ε0, let ⟨K, K0, i, H⟩ := abv_pos_of_not_lim_zero hf in\n⟨i, λ j ij,\n  by simpa [(abv_pos abv).1 (lt_of_lt_of_le K0 (H _ ij)),\n    abv_zero abv] using ε0⟩\n\ntheorem const_inv {x : β} (hx : x ≠ 0) : const abv (x⁻¹) = inv (const abv x) (by rwa const_lim_zero) :=\next (assume n, by simp[inv_apply, const_apply])\n\nend discrete_field\n\nsection abs\nlocal notation `const` := const abs\n\ndef pos (f : cau_seq α abs) : Prop := ∃ K > 0, ∃ i, ∀ j ≥ i, K ≤ f j\n\ntheorem not_lim_zero_of_pos {f : cau_seq α abs} : pos f → ¬ lim_zero f\n| ⟨F, F0, hF⟩ H :=\n  let ⟨i, h⟩ := exists_forall_ge_and hF (H _ F0),\n      ⟨h₁, h₂⟩ := h _ (le_refl _) in\n  not_lt_of_le h₁ (abs_lt.1 h₂).2\n\ntheorem const_pos {x : α} : pos (const x) ↔ 0 < x :=\n⟨λ ⟨K, K0, i, h⟩, lt_of_lt_of_le K0 (h _ (le_refl _)),\n λ h, ⟨x, h, 0, λ j _, le_refl _⟩⟩\n\ntheorem add_pos {f g : cau_seq α abs} : pos f → pos g → pos (f + g)\n| ⟨F, F0, hF⟩ ⟨G, G0, hG⟩ :=\n  let ⟨i, h⟩ := exists_forall_ge_and hF hG in\n  ⟨_, _root_.add_pos F0 G0, i,\n    λ j ij, let ⟨h₁, h₂⟩ := h _ ij in add_le_add h₁ h₂⟩\n\ntheorem pos_add_lim_zero {f g : cau_seq α abs} : pos f → lim_zero g → pos (f + g)\n| ⟨F, F0, hF⟩ H :=\n  let ⟨i, h⟩ := exists_forall_ge_and hF (H _ (half_pos F0)) in\n  ⟨_, half_pos F0, i, λ j ij, begin\n    cases h j ij with h₁ h₂,\n    have := add_le_add h₁ (le_of_lt (abs_lt.1 h₂).1),\n    rwa [← sub_eq_add_neg, sub_self_div_two] at this\n  end⟩\n\ntheorem mul_pos {f g : cau_seq α abs} : pos f → pos g → pos (f * g)\n| ⟨F, F0, hF⟩ ⟨G, G0, hG⟩ :=\n  let ⟨i, h⟩ := exists_forall_ge_and hF hG in\n  ⟨_, _root_.mul_pos F0 G0, i,\n    λ j ij, let ⟨h₁, h₂⟩ := h _ ij in\n    mul_le_mul h₁ h₂ (le_of_lt G0) (le_trans (le_of_lt F0) h₁)⟩\n\ntheorem trichotomy (f : cau_seq α abs) : pos f ∨ lim_zero f ∨ pos (-f) :=\nbegin\n  cases classical.em (lim_zero f); simp *,\n  rcases abv_pos_of_not_lim_zero h with ⟨K, K0, hK⟩,\n  rcases exists_forall_ge_and hK (f.cauchy₃ K0) with ⟨i, hi⟩,\n  refine (le_total 0 (f i)).imp _ _;\n    refine (λ h, ⟨K, K0, i, λ j ij, _⟩);\n    have := (hi _ ij).1;\n    cases hi _ (le_refl _) with h₁ h₂,\n  { rwa abs_of_nonneg at this,\n    rw abs_of_nonneg h at h₁,\n    exact (le_add_iff_nonneg_right _).1\n      (le_trans h₁ $ neg_le_sub_iff_le_add'.1 $\n        le_of_lt (abs_lt.1 $ h₂ _ ij).1) },\n  { rwa abs_of_nonpos at this,\n    rw abs_of_nonpos h at h₁,\n    rw [← sub_le_sub_iff_right, zero_sub],\n    exact le_trans (le_of_lt (abs_lt.1 $ h₂ _ ij).2) h₁ }\nend\n\ninstance : has_lt (cau_seq α abs) := ⟨λ f g, pos (g - f)⟩\ninstance : has_le (cau_seq α abs) := ⟨λ f g, f < g ∨ f ≈ g⟩\n\ntheorem lt_of_lt_of_eq {f g h : cau_seq α abs}\n  (fg : f < g) (gh : g ≈ h) : f < h :=\nby simpa using pos_add_lim_zero fg (neg_lim_zero gh)\n\ntheorem lt_of_eq_of_lt {f g h : cau_seq α abs}\n  (fg : f ≈ g) (gh : g < h) : f < h :=\nby have := pos_add_lim_zero gh (neg_lim_zero fg);\n   rwa [← sub_eq_add_neg, sub_sub_sub_cancel_right] at this\n\ntheorem lt_trans {f g h : cau_seq α abs} (fg : f < g) (gh : g < h) : f < h :=\nby simpa using add_pos fg gh\n\ntheorem lt_irrefl {f : cau_seq α abs} : ¬ f < f\n| h := not_lim_zero_of_pos h (by simp [zero_lim_zero])\n\ninstance : preorder (cau_seq α abs) :=\n{ lt := (<),\n  le := λ f g, f < g ∨ f ≈ g,\n  le_refl := λ f, or.inr (setoid.refl _),\n  le_trans := λ f g h fg, match fg with\n    | or.inl fg, or.inl gh := or.inl $ lt_trans fg gh\n    | or.inl fg, or.inr gh := or.inl $ lt_of_lt_of_eq fg gh\n    | or.inr fg, or.inl gh := or.inl $ lt_of_eq_of_lt fg gh\n    | or.inr fg, or.inr gh := or.inr $ setoid.trans fg gh\n    end,\n  lt_iff_le_not_le := λ f g,\n    ⟨λ h, ⟨or.inl h,\n      not_or (mt (lt_trans h) lt_irrefl) (not_lim_zero_of_pos h)⟩,\n    λ ⟨h₁, h₂⟩, h₁.resolve_right\n      (mt (λ h, or.inr (setoid.symm h)) h₂)⟩ }\n\ntheorem le_antisymm {f g : cau_seq α abs} (fg : f ≤ g) (gf : g ≤ f) : f ≈ g :=\nfg.resolve_left (not_lt_of_le gf)\n\ntheorem lt_total (f g : cau_seq α abs) : f < g ∨ f ≈ g ∨ g < f :=\n(trichotomy (g - f)).imp_right\n  (λ h, h.imp (λ h, setoid.symm h) (λ h, by rwa neg_sub at h))\n\ntheorem le_total (f g : cau_seq α abs) : f ≤ g ∨ g ≤ f :=\n(or.assoc.2 (lt_total f g)).imp_right or.inl\n\ntheorem const_lt {x y : α} : const x < const y ↔ x < y :=\nshow pos _ ↔ _, by rw [← const_sub, const_pos, sub_pos]\n\ntheorem const_equiv {x y : α} : const x ≈ const y ↔ x = y :=\nshow lim_zero _ ↔ _, by rw [← const_sub, const_lim_zero, sub_eq_zero]\n\ntheorem const_le {x y : α} : const x ≤ const y ↔ x ≤ y :=\nby rw le_iff_lt_or_eq; exact or_congr const_lt const_equiv\n\ntheorem exists_gt (f : cau_seq α abs) : ∃ a : α, f < const a :=\nlet ⟨K, H⟩ := f.bounded in\n⟨K + 1, 1, zero_lt_one, 0, λ i _, begin\n  rw [sub_apply, const_apply, le_sub_iff_add_le', add_le_add_iff_right],\n  exact le_of_lt (abs_lt.1 (H _)).2\nend⟩\n\ntheorem exists_lt (f : cau_seq α abs) : ∃ a : α, const a < f :=\nlet ⟨a, h⟩ := (-f).exists_gt in ⟨-a, show pos _,\n  by rwa [const_neg, sub_neg_eq_add, add_comm, ← sub_neg_eq_add]⟩\n\nend abs\n\nend cau_seq\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/data/real/cau_seq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4717888179741209}}
{"text": "import syntax.syntaxCLC \nimport semantics.playability \nimport semantics.model\nimport data.fintype.basic\nimport logic.relation\n\nlocal attribute [instance] classical.prop_decidable\n\nopen formCLC set\n\n---------------------- Semantics ----------------------\n\n-- def disjunct_rel {agents : Type} {m : modelCLK agents} (G : set agents) :\n--   m.f.states →  m.f.states → Prop :=\n-- λ s t, ∃ i ∈ G, t ∈ (m.f.rel i s)\n\ndef C_path {agents : Type}  {m : modelCLK agents} : \n  list agents → list m.f.states →  m.f.states →  m.f.states → Prop\n  | list.nil  _        s t := false\n  | (i :: is) list.nil s t := t ∈ (m.f.rel i s)\n  | (i :: is)(u :: us) s t := (u ∈ (m.f.rel i s) ∧ (C_path is us u t)) \n\ndef C_path_nil {agents : Type} {m : modelCLK agents} {ss : list m.f.states} {s t : m.f.states} : \n  C_path list.nil ss s t → false :=\nbegin\n  intro hC,\n  induction ss,\n  repeat \n  { simp[C_path] at hC,\n    exact hC, },\nend\n\n-- @[simp]\n-- protected def formCLC.sizeof' (agents : Type) [agents_inst : has_sizeof agents] : formCLC agents → ℕ\n-- | bot := 1\n-- | (var n) := 1 + sizeof n\n-- | (imp φ ψ) := 1 + formCLC.sizeof' φ + formCLC.sizeof' ψ\n-- | (and φ ψ) := 1 + formCLC.sizeof' φ + formCLC.sizeof' ψ\n-- | ([G] φ) := 1 + sizeof G + formCLC.sizeof' φ\n-- | (k i φ) := 1 + sizeof i + formCLC.sizeof' φ\n-- | (e i φ) := 1 + sizeof i + formCLC.sizeof' φ + 1 -- Make recursion from E' to K' possible\n-- | (c i φ) := 1 + sizeof i + formCLC.sizeof' φ\n\n-- def formCLC.has_sizeof' {agents} : has_sizeof (formCLC agents) := ⟨formCLC.sizeof' _⟩\n-- local attribute [instance] formCLC.has_sizeof'\n\n-- Definition of semantic entailment\n-- Order of arguments is swapped to help the equation compiler find the recursive parameter\ndef s_entails_CLC {agents : Type}  : Π (m : modelCLK agents), m.f.states → formCLC agents → Prop\n  | m s bot       := false\n  | m s (var n)   := s ∈ m.v n\n  | m s (imp φ ψ) := (s_entails_CLC m s φ) → (s_entails_CLC m s ψ)\n  | m s (and φ ψ) := (s_entails_CLC m s φ) ∧ (s_entails_CLC m s ψ)\n  | m s ([G] φ)   := {t : m.f.states | s_entails_CLC m t φ} ∈ m.f.E.E (s) (G)\n  | m s (k i φ)   := ∀ t : m.f.states, t ∈ (m.f.rel i s) → s_entails_CLC m t φ\n  -- | m (e G φ)   s := ∀ i ∈ G, (s_entails_CLC.aux m (k i φ) s)\n  | m s (c G φ)   := ∀ t : m.f.states, (∃ la, (∀ a ∈ la, a ∈ G) ∧ ∃ ls, C_path la ls s t) → \n                        s_entails_CLC m t φ\n  -- | m (c G φ)   s := ∀ t : m.f.states, (relation.trans_gen (disjunct_rel G) s t) → s_entails_CLC.aux m φ t\n\n-- -- Definition of semantic entailment\n-- def s_entails_CLC {agents : Type} (m : modelCLK agents) (s : m.f.states) (φ : formCLC agents) : Prop :=\n-- s_entails_CLC.aux m φ s\n\n-- def tilde (m: modelCLC agents) (φ : formCLC agents)  :=\n-- {t: m.f.states | s_entails m t φ}\nlemma s_entails_CLC_conjunction {agents : Type} {m : modelCLK agents} {s : m.f.states} \n  {φs : list (formCLC agents)} : \n  s_entails_CLC m s (finite_conjunction φs) ↔ ∀ φ ∈ φs, s_entails_CLC m s φ :=\nbegin\n  induction φs with φ φs ih,\n  { simp [finite_conjunction],\n    show s_entails_CLC m s ⊤,\n    simp [s_entails_CLC], },\n  { unfold finite_conjunction,\n    show s_entails_CLC m s (φ & finite_conjunction φs) ↔ _,\n    simp [s_entails_CLC],\n    intros h,\n    exact ih, },\nend\n\nvariables {agents : Type}\n\n-- φ is valid in a model M = (f,v)\ndef valid_m (m: modelCLK agents) (φ : formCLC agents) := \n  ∀ s, s_entails_CLC m s φ\n\ndef global_valid (φ : formCLC agents) :=\n  ∀ m, valid_m m φ\n\n-- -- φ is valid in a frame f\n-- def f_valid (φ : formCL agents) (f : frame agents) := \n--   ∀ v s, s_entails f v s φ\n\n\n-- -- φ is valid in a class of frames F\n-- def F_valid (φ : formCL agents) (F : set (frame agents)) := \n--   ∀ f ∈ F, ∀ v s, s_entails f v s φ\n\n-- -- φ is universally valid (valid in all frames)\n-- def u_valid (φ : formCL agents) := \n--   ∀ f v s, s_entails f v s φ\n\n\n-- A context is true at a world in a model if each \n-- formula of the context is true at that world in that model\n-- def s_entails_ctx (m : modelCL agents) \n--   := ∀ φ, ∀ s, s_entails m s φ\n\n\n-- Global semantic consequence\n-- def global_sem_csq (φ : formCL agents) :=\n--   ∀ m s, s_entails m s φ\n\n\nlemma not_s_entails_imp (m : modelCLK agents) : ∀ s φ, \n  (¬ (s_entails_CLC m s φ)) ↔ (s_entails_CLC m s (¬ φ)) :=\nbegin\n  intros s φ,\n  unfold s_entails_CLC,\n  refl\nend\n\n\n-- lemma s_entails_exists {f : frame} {v : nat → f.states → Prop} {x : f.states} {φ : form} :\n--   s_entails f v x (◇φ) ↔ ∃ y : f.states, (f.rel x y ∧ s_entails f v y φ) :=\n-- begin\n-- split, intro h1,\n-- repeat {rw s_entails at h1},\n-- have h2 := not_or_of_imp h1,\n-- cases h2, push_neg at h2,\n-- cases h2 with y h2, cases h2 with h2 h3,\n-- existsi (y : f.states), split, exact h2,\n-- have h4 := (not_s_entails_imp f v y (¬φ)).mp h3,\n-- repeat {rw s_entails at h4}, repeat {rw imp_false at h4},\n-- rw not_not at h4, exact h4,\n-- exact false.elim h2,\n-- intro h1, cases h1 with y h1,\n-- cases h1 with h1 h2,\n-- intro h3,\n-- exact absurd h2 (h3 y h1)\n-- ends\n\n", "meta": {"author": "kaiobendrauf", "repo": "cl-lean", "sha": "15568f16cf57a07db6192fbd8084d59cc1aef1df", "save_path": "github-repos/lean/kaiobendrauf-cl-lean", "path": "github-repos/lean/kaiobendrauf-cl-lean/cl-lean-15568f16cf57a07db6192fbd8084d59cc1aef1df/src/semantics/semanticsCLC.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.47178881326965877}}
{"text": "/-\nCopyright (c) 2018 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Scott Morrison\n-/\nimport category_theory.opposites\n\n/-!\n# Morphisms from equations between objects.\n\nWhen working categorically, sometimes one encounters an equation `h : X = Y` between objects.\n\nYour initial aversion to this is natural and appropriate:\nyou're in for some trouble, and if there is another way to approach the problem that won't\nrely on this equality, it may be worth pursuing.\n\nYou have two options:\n1. Use the equality `h` as one normally would in Lean (e.g. using `rw` and `subst`).\n   This may immediately cause difficulties, because in category theory everything is dependently\n   typed, and equations between objects quickly lead to nasty goals with `eq.rec`.\n2. Promote `h` to a morphism using `eq_to_hom h : X ⟶ Y`, or `eq_to_iso h : X ≅ Y`.\n\nThis file introduces various `simp` lemmas which in favourable circumstances\nresult in the various `eq_to_hom` morphisms to drop out at the appropriate moment!\n-/\n\nuniverses v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen opposite\n\nvariables {C : Type u₁} [category.{v₁} C]\n\n/--\nAn equality `X = Y` gives us a morphism `X ⟶ Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `𝟙 _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_hom {X Y : C} (p : X = Y) : X ⟶ Y := by rw p; exact 𝟙 _\n\n@[simp] lemma eq_to_hom_refl (X : C) (p : X = X) : eq_to_hom p = 𝟙 X := rfl\n@[simp, reassoc] lemma eq_to_hom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) :\n  eq_to_hom p ≫ eq_to_hom q = eq_to_hom (p.trans q) :=\nby { cases p, cases q, simp, }\n\n/--\nIf we (perhaps unintentionally) perform equational rewriting on\nthe source object of a morphism,\nwe can replace the resulting `_.mpr f` term by a composition with an `eq_to_hom`.\n\nIt may be advisable to introduce any necessary `eq_to_hom` morphisms manually,\nrather than relying on this lemma firing.\n-/\n@[simp]\nlemma congr_arg_mpr_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) :\n  (congr_arg (λ W : C, W ⟶ Z) p).mpr q = eq_to_hom p ≫ q :=\nby { cases p, simp, }\n\n/--\nIf we (perhaps unintentionally) perform equational rewriting on\nthe target object of a morphism,\nwe can replace the resulting `_.mpr f` term by a composition with an `eq_to_hom`.\n\nIt may be advisable to introduce any necessary `eq_to_hom` morphisms manually,\nrather than relying on this lemma firing.\n-/\n@[simp]\nlemma congr_arg_mpr_hom_right {X Y Z : C} (p : X ⟶ Y) (q : Z = Y) :\n  (congr_arg (λ W : C, X ⟶ W) q).mpr p = p ≫ eq_to_hom q.symm :=\nby { cases q, simp, }\n\n/--\nAn equality `X = Y` gives us an isomorphism `X ≅ Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `iso.refl _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_iso {X Y : C} (p : X = Y) : X ≅ Y :=\n⟨eq_to_hom p, eq_to_hom p.symm, by simp, by simp⟩\n\n@[simp] lemma eq_to_iso.hom {X Y : C} (p : X = Y) : (eq_to_iso p).hom = eq_to_hom p :=\nrfl\n@[simp] lemma eq_to_iso.inv {X Y : C} (p : X = Y) : (eq_to_iso p).inv = eq_to_hom p.symm :=\nrfl\n\n@[simp] \n\n@[simp] lemma eq_to_hom_op {X Y : C} (h : X = Y) :\n  (eq_to_hom h).op = eq_to_hom (congr_arg op h.symm) :=\nby { cases h, refl, }\n\n@[simp] lemma eq_to_hom_unop {X Y : Cᵒᵖ} (h : X = Y) :\n  (eq_to_hom h).unop = eq_to_hom (congr_arg unop h.symm) :=\nby { cases h, refl, }\n\ninstance {X Y : C} (h : X = Y) : is_iso (eq_to_hom h) := is_iso.of_iso (eq_to_iso h)\n\n@[simp] lemma inv_eq_to_hom {X Y : C} (h : X = Y) : inv (eq_to_hom h) = eq_to_hom h.symm :=\nby { ext, simp, }\n\nvariables {D : Type u₂} [category.{v₂} D]\n\nnamespace functor\n\n/-- Proving equality between functors. This isn't an extensionality lemma,\n  because usually you don't really want to do this. -/\nlemma ext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ X Y f, F.map f = eq_to_hom (h_obj X) ≫ G.map f ≫ eq_to_hom (h_obj Y).symm) :\n  F = G :=\nbegin\n  cases F with F_obj _ _ _, cases G with G_obj _ _ _,\n  have : F_obj = G_obj, by ext X; apply h_obj,\n  subst this,\n  congr,\n  funext X Y f,\n  simpa using h_map X Y f\nend\n\n/-- Proving equality between functors using heterogeneous equality. -/\nlemma hext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ X Y (f : X ⟶ Y), F.map f == G.map f) : F = G :=\nbegin\n  cases F with F_obj _ _ _, cases G with G_obj _ _ _,\n  have : F_obj = G_obj, by ext X; apply h_obj,\n  subst this,\n  congr,\n  funext X Y f,\n  exact eq_of_heq (h_map X Y f)\nend\n\n-- Using equalities between functors.\n\nlemma congr_obj {F G : C ⥤ D} (h : F = G) (X) : F.obj X = G.obj X :=\nby subst h\n\nlemma congr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) :\n  F.map f = eq_to_hom (congr_obj h X) ≫ G.map f ≫ eq_to_hom (congr_obj h Y).symm :=\nby subst h; simp\n\nend functor\n\n@[simp] lemma eq_to_hom_map (F : C ⥤ D) {X Y : C} (p : X = Y) :\n  F.map (eq_to_hom p) = eq_to_hom (congr_arg F.obj p) :=\nby cases p; simp\n\n@[simp] lemma eq_to_iso_map (F : C ⥤ D) {X Y : C} (p : X = Y) :\n  F.map_iso (eq_to_iso p) = eq_to_iso (congr_arg F.obj p) :=\nby ext; cases p; simp\n\n@[simp] lemma eq_to_hom_app {F G : C ⥤ D} (h : F = G) (X : C) :\n  (eq_to_hom h : F ⟶ G).app X = eq_to_hom (functor.congr_obj h X) :=\nby subst h; refl\n\nlemma nat_trans.congr {F G : C ⥤ D} (α : F ⟶ G) {X Y : C} (h : X = Y) :\n  α.app X = F.map (eq_to_hom h) ≫ α.app Y ≫ G.map (eq_to_hom h.symm) :=\nby { rw [α.naturality_assoc], simp }\n\nlemma eq_conj_eq_to_hom {X Y : C} (f : X ⟶ Y) :\n  f = eq_to_hom rfl ≫ f ≫ eq_to_hom rfl :=\nby simp only [category.id_comp, eq_to_hom_refl, category.comp_id]\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/eq_to_hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.47178880856519645}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport algebraic_geometry.ringed_space\nimport algebraic_geometry.stalks\nimport logic.equiv.transfer_instance\n\n/-!\n# The category of locally ringed spaces\n\nWe define (bundled) locally ringed spaces (as `SheafedSpace CommRing` along with the fact that the\nstalks are local rings), and morphisms between these (morphisms in `SheafedSpace` with\n`is_local_ring_hom` on the stalk maps).\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.category category_theory.functor\n\nnamespace algebraic_geometry\n\n/-- A `LocallyRingedSpace` is a topological space equipped with a sheaf of commutative rings\nsuch that all the stalks are local rings.\n\nA morphism of locally ringed spaces is a morphism of ringed spaces\nsuch that the morphisms induced on stalks are local ring homomorphisms. -/\n@[nolint has_nonempty_instance]\nstructure LocallyRingedSpace extends SheafedSpace CommRing :=\n(local_ring : ∀ x, local_ring (presheaf.stalk x))\n\nattribute [instance] LocallyRingedSpace.local_ring\n\nnamespace LocallyRingedSpace\n\nvariables (X : LocallyRingedSpace)\n\n/--\nAn alias for `to_SheafedSpace`, where the result type is a `RingedSpace`.\nThis allows us to use dot-notation for the `RingedSpace` namespace.\n -/\ndef to_RingedSpace : RingedSpace := X.to_SheafedSpace\n\n/-- The underlying topological space of a locally ringed space. -/\ndef to_Top : Top := X.1.carrier\n\ninstance : has_coe_to_sort LocallyRingedSpace (Type u) :=\n⟨λ X : LocallyRingedSpace, (X.to_Top : Type u)⟩\n\ninstance (x : X) : _root_.local_ring (X.to_PresheafedSpace.stalk x) := X.local_ring x\n\n-- PROJECT: how about a typeclass \"has_structure_sheaf\" to mediate the 𝒪 notation, rather\n-- than defining it over and over for PresheafedSpace, LRS, Scheme, etc.\n\n/-- The structure sheaf of a locally ringed space. -/\ndef 𝒪 : sheaf CommRing X.to_Top := X.to_SheafedSpace.sheaf\n\n/-- A morphism of locally ringed spaces is a morphism of ringed spaces\n such that the morphims induced on stalks are local ring homomorphisms. -/\n@[ext]\nstructure hom (X Y : LocallyRingedSpace.{u}) : Type u :=\n(val : X.to_SheafedSpace ⟶ Y.to_SheafedSpace)\n(prop : ∀ x, is_local_ring_hom (PresheafedSpace.stalk_map val x))\n\ninstance : quiver LocallyRingedSpace := ⟨hom⟩\n\n/--\nThe stalk of a locally ringed space, just as a `CommRing`.\n-/\n-- TODO perhaps we should make a bundled `LocalRing` and return one here?\n-- TODO define `sheaf.stalk` so we can write `X.𝒪.stalk` here?\nnoncomputable\ndef stalk (X : LocallyRingedSpace) (x : X) : CommRing := X.presheaf.stalk x\n\n/--\nA morphism of locally ringed spaces `f : X ⟶ Y` induces\na local ring homomorphism from `Y.stalk (f x)` to `X.stalk x` for any `x : X`.\n-/\nnoncomputable\ndef stalk_map {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n  Y.stalk (f.1.1 x) ⟶ X.stalk x :=\nPresheafedSpace.stalk_map f.1 x\n\ninstance {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n  is_local_ring_hom (stalk_map f x) := f.2 x\n\ninstance {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n   is_local_ring_hom (PresheafedSpace.stalk_map f.1 x) := f.2 x\n\n/-- The identity morphism on a locally ringed space. -/\n@[simps]\ndef id (X : LocallyRingedSpace) : hom X X :=\n⟨𝟙 _, λ x, by { erw PresheafedSpace.stalk_map.id, apply is_local_ring_hom_id, }⟩\n\ninstance (X : LocallyRingedSpace) : inhabited (hom X X) := ⟨id X⟩\n\n/-- Composition of morphisms of locally ringed spaces. -/\ndef comp {X Y Z : LocallyRingedSpace} (f : hom X Y) (g : hom Y Z) : hom X Z :=\n⟨f.val ≫ g.val, λ x,\nbegin\n  erw PresheafedSpace.stalk_map.comp,\n  exact @is_local_ring_hom_comp _ _ _ _ _ _ _ _ (f.2 _) (g.2 _),\nend⟩\n\n/-- The category of locally ringed spaces. -/\ninstance : category LocallyRingedSpace :=\n{ hom := hom,\n  id := id,\n  comp := λ X Y Z f g, comp f g,\n  comp_id' := by { intros, ext1, simp [comp], },\n  id_comp' := by { intros, ext1, simp [comp], },\n  assoc' := by { intros, ext1, simp [comp], }, }.\n\n/-- The forgetful functor from `LocallyRingedSpace` to `SheafedSpace CommRing`. -/\n@[simps] def forget_to_SheafedSpace : LocallyRingedSpace ⥤ SheafedSpace CommRing :=\n{ obj := λ X, X.to_SheafedSpace,\n  map := λ X Y f, f.1, }\n\ninstance : faithful forget_to_SheafedSpace := {}\n\n/-- The forgetful functor from `LocallyRingedSpace` to `Top`. -/\n@[simps]\ndef forget_to_Top : LocallyRingedSpace ⥤ Top :=\nforget_to_SheafedSpace ⋙ SheafedSpace.forget _\n\n@[simp] lemma comp_val {X Y Z : LocallyRingedSpace} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).val = f.val ≫ g.val := rfl\n\n@[simp] lemma comp_val_c {X Y Z : LocallyRingedSpace.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).val.c = g.val.c ≫ (presheaf.pushforward _ g.val.base).map f.val.c := rfl\n\nlemma comp_val_c_app {X Y Z : LocallyRingedSpace} (f : X ⟶ Y) (g : Y ⟶ Z) (U : (opens Z)ᵒᵖ) :\n  (f ≫ g).val.c.app U = g.val.c.app U ≫ f.val.c.app (op $ (opens.map g.val.base).obj U.unop) :=\nrfl\n\n/--\nGiven two locally ringed spaces `X` and `Y`, an isomorphism between `X` and `Y` as _sheafed_\nspaces can be lifted to a morphism `X ⟶ Y` as locally ringed spaces.\n\nSee also `iso_of_SheafedSpace_iso`.\n-/\n@[simps]\ndef hom_of_SheafedSpace_hom_of_is_iso {X Y : LocallyRingedSpace}\n  (f : X.to_SheafedSpace ⟶ Y.to_SheafedSpace) [is_iso f] : X ⟶ Y :=\nhom.mk f $ λ x,\n-- Here we need to see that the stalk maps are really local ring homomorphisms.\n-- This can be solved by type class inference, because stalk maps of isomorphisms are isomorphisms\n-- and isomorphisms are local ring homomorphisms.\nshow is_local_ring_hom (PresheafedSpace.stalk_map\n  (SheafedSpace.forget_to_PresheafedSpace.map f) x),\nby apply_instance\n\n/--\nGiven two locally ringed spaces `X` and `Y`, an isomorphism between `X` and `Y` as _sheafed_\nspaces can be lifted to an isomorphism `X ⟶ Y` as locally ringed spaces.\n\nThis is related to the property that the functor `forget_to_SheafedSpace` reflects isomorphisms.\nIn fact, it is slightly stronger as we do not require `f` to come from a morphism between\n_locally_ ringed spaces.\n-/\ndef iso_of_SheafedSpace_iso {X Y : LocallyRingedSpace}\n  (f : X.to_SheafedSpace ≅ Y.to_SheafedSpace) : X ≅ Y :=\n{ hom := hom_of_SheafedSpace_hom_of_is_iso f.hom,\n  inv := hom_of_SheafedSpace_hom_of_is_iso f.inv,\n  hom_inv_id' := hom.ext _ _ f.hom_inv_id,\n  inv_hom_id' := hom.ext _ _ f.inv_hom_id }\n\ninstance : reflects_isomorphisms forget_to_SheafedSpace :=\n{ reflects := λ X Y f i,\n  { out := by exactI\n    ⟨hom_of_SheafedSpace_hom_of_is_iso (category_theory.inv (forget_to_SheafedSpace.map f)),\n      hom.ext _ _ (is_iso.hom_inv_id _), hom.ext _ _ (is_iso.inv_hom_id _)⟩ } }\n\ninstance is_SheafedSpace_iso {X Y : LocallyRingedSpace} (f : X ⟶ Y) [is_iso f] :\n  is_iso f.1 :=\nLocallyRingedSpace.forget_to_SheafedSpace.map_is_iso f\n\n/--\nThe restriction of a locally ringed space along an open embedding.\n-/\n@[simps]\ndef restrict {U : Top} (X : LocallyRingedSpace) {f : U ⟶ X.to_Top}\n  (h : open_embedding f) : LocallyRingedSpace :=\n{ local_ring :=\n  begin\n    intro x,\n    dsimp at *,\n    -- We show that the stalk of the restriction is isomorphic to the original stalk,\n    apply @ring_equiv.local_ring _ _ _ (X.local_ring (f x)),\n    exact (X.to_PresheafedSpace.restrict_stalk_iso h x).symm.CommRing_iso_to_ring_equiv,\n  end,\n  to_SheafedSpace := X.to_SheafedSpace.restrict h }\n\n/-- The canonical map from the restriction to the supspace. -/\ndef of_restrict {U : Top} (X : LocallyRingedSpace) {f : U ⟶ X.to_Top}\n  (h : open_embedding f) : X.restrict h ⟶ X :=\n⟨X.to_PresheafedSpace.of_restrict h, λ x, infer_instance⟩\n\n/--\nThe restriction of a locally ringed space `X` to the top subspace is isomorphic to `X` itself.\n-/\ndef restrict_top_iso (X : LocallyRingedSpace) :\n  X.restrict (opens.open_embedding ⊤) ≅ X :=\n@iso_of_SheafedSpace_iso (X.restrict (opens.open_embedding ⊤)) X\n  X.to_SheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : LocallyRingedSpaceᵒᵖ ⥤ CommRing :=\nforget_to_SheafedSpace.op ⋙ SheafedSpace.Γ\n\nlemma Γ_def : Γ = forget_to_SheafedSpace.op ⋙ SheafedSpace.Γ := rfl\n\n@[simp] lemma Γ_obj (X : LocallyRingedSpaceᵒᵖ) : Γ.obj X = (unop X).presheaf.obj (op ⊤) := rfl\n\nlemma Γ_obj_op (X : LocallyRingedSpace) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\n@[simp] lemma Γ_map {X Y : LocallyRingedSpaceᵒᵖ} (f : X ⟶ Y) :\n  Γ.map f = f.unop.1.c.app (op ⊤) := rfl\n\nlemma Γ_map_op {X Y : LocallyRingedSpace} (f : X ⟶ Y) :\n  Γ.map f.op = f.1.c.app (op ⊤) := rfl\n\nlemma preimage_basic_open {X Y : LocallyRingedSpace} (f : X ⟶ Y) {U : opens Y}\n  (s : Y.presheaf.obj (op U)) :\n  (opens.map f.1.base).obj (Y.to_RingedSpace.basic_open s) =\n    @RingedSpace.basic_open X.to_RingedSpace ((opens.map f.1.base).obj U) (f.1.c.app _ s) :=\nbegin\n  ext,\n  split,\n  { rintros ⟨⟨y, hyU⟩, (hy : is_unit _), (rfl : y = _)⟩,\n    erw RingedSpace.mem_basic_open _ _ ⟨x, show x ∈ (opens.map f.1.base).obj U, from hyU⟩,\n    rw ← PresheafedSpace.stalk_map_germ_apply,\n    exact (PresheafedSpace.stalk_map f.1 _).is_unit_map hy },\n  { rintros ⟨y, (hy : is_unit _), rfl⟩,\n    erw RingedSpace.mem_basic_open _ _ ⟨f.1.base y.1, y.2⟩,\n    rw ← PresheafedSpace.stalk_map_germ_apply at hy,\n    exact (is_unit_map_iff (PresheafedSpace.stalk_map f.1 _) _).mp hy }\nend\n\n-- This actually holds for all ringed spaces with nontrivial stalks.\n@[simp] lemma basic_open_zero (X : LocallyRingedSpace) (U : opens X.carrier) :\n  X.to_RingedSpace.basic_open (0 : X.presheaf.obj $ op U) = ⊥ :=\nbegin\n  simp only [RingedSpace.basic_open, is_unit_zero_iff, map_zero,\n    zero_ne_one' (X.presheaf.stalk _), set.set_of_false, set.image_empty],\n  refl\nend\n\ninstance component_nontrivial (X : LocallyRingedSpace) (U : opens X.carrier)\n  [hU : nonempty U] : nontrivial (X.presheaf.obj $ op U) :=\n(X.to_PresheafedSpace.presheaf.germ hU.some).domain_nontrivial\n\nend LocallyRingedSpace\n\nend algebraic_geometry\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_geometry/locally_ringed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.47175610034583654}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Kenny Lau\n\n! This file was ported from Lean 3 source module number_theory.basic\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GeomSum\nimport Mathbin.RingTheory.Ideal.Quotient\n\n/-!\n# Basic results in number theory\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file should contain basic results in number theory. So far, it only contains the essential\nlemma in the construction of the ring of Witt vectors.\n\n## Main statement\n\n`dvd_sub_pow_of_dvd_sub` proves that for elements `a` and `b` in a commutative ring `R` and for\nall natural numbers `p` and `k` if `p` divides `a-b` in `R`, then `p ^ (k + 1)` divides\n`a ^ (p ^ k) - b ^ (p ^ k)`.\n-/\n\n\nsection\n\nopen Ideal Ideal.Quotient\n\n/- warning: dvd_sub_pow_of_dvd_sub -> dvd_sub_pow_of_dvd_sub is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {p : Nat} {a : R} {b : R}, (Dvd.Dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (NonUnitalRing.toNonUnitalSemiring.{u1} R (NonUnitalCommRing.toNonUnitalRing.{u1} R (CommRing.toNonUnitalCommRing.{u1} R _inst_1)))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1)))))))) p) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) a b)) -> (forall (k : Nat), Dvd.Dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (NonUnitalRing.toNonUnitalSemiring.{u1} R (NonUnitalCommRing.toNonUnitalRing.{u1} R (CommRing.toNonUnitalCommRing.{u1} R _inst_1)))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddGroupWithOne.toAddMonoidWithOne.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1)))))))) p) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) k (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (SubNegMonoid.toHasSub.{u1} R (AddGroup.toSubNegMonoid.{u1} R (AddGroupWithOne.toAddGroup.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (CommRing.toRing.{u1} R _inst_1))))))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) a (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) p k)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_1)))) b (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) p k))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommRing.{u1} R] {p : Nat} {a : R} {b : R}, (Dvd.dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (NonUnitalRing.toNonUnitalSemiring.{u1} R (NonUnitalCommRing.toNonUnitalRing.{u1} R (CommRing.toNonUnitalCommRing.{u1} R _inst_1)))))) (Nat.cast.{u1} R (NonAssocRing.toNatCast.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) p) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) a b)) -> (forall (k : Nat), Dvd.dvd.{u1} R (semigroupDvd.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (NonUnitalRing.toNonUnitalSemiring.{u1} R (NonUnitalCommRing.toNonUnitalRing.{u1} R (CommRing.toNonUnitalCommRing.{u1} R _inst_1)))))) (Nat.cast.{u1} R (NonAssocRing.toNatCast.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) p (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) k (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))) (HSub.hSub.{u1, u1, u1} R R R (instHSub.{u1} R (Ring.toSub.{u1} R (CommRing.toRing.{u1} R _inst_1))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) a (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) p k)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) b (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) p k))))\nCase conversion may be inaccurate. Consider using '#align dvd_sub_pow_of_dvd_sub dvd_sub_pow_of_dvd_subₓ'. -/\ntheorem dvd_sub_pow_of_dvd_sub {R : Type _} [CommRing R] {p : ℕ} {a b : R} (h : (p : R) ∣ a - b)\n    (k : ℕ) : (p ^ (k + 1) : R) ∣ a ^ p ^ k - b ^ p ^ k :=\n  by\n  induction' k with k ih\n  · rwa [pow_one, pow_zero, pow_one, pow_one]\n  rw [pow_succ' p k, pow_mul, pow_mul, ← geom_sum₂_mul, pow_succ]\n  refine' mul_dvd_mul _ ih\n  let I : Ideal R := span {p}\n  let f : R →+* R ⧸ I := mk I\n  have hp : (p : R ⧸ I) = 0 := by rw [← map_natCast f, eq_zero_iff_mem, mem_span_singleton]\n  rw [← mem_span_singleton, ← Ideal.Quotient.eq] at h\n  rw [← mem_span_singleton, ← eq_zero_iff_mem, RingHom.map_geom_sum₂, RingHom.map_pow,\n    RingHom.map_pow, h, geom_sum₂_self, hp, MulZeroClass.zero_mul]\n#align dvd_sub_pow_of_dvd_sub dvd_sub_pow_of_dvd_sub\n\nend\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/NumberTheory/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4717560984956133}}
{"text": "import locally_constant.SemiNormedGroup\nimport normed_group.normed_with_aut\nimport analysis.normed.group.SemiNormedGroup.completion\n\n/-!\n\n# Completions of normed groups\n\nThis file contains an API for completions for seminormed groups equipped with\nan automorphism which scales norms by a constant factor `r`.\n\n## Main definitions\n\n- `normed_with_aut_Completion` : if `V` is equipped with an automorphism changing norms\n  by a factor `r` then the completion also has such an automorphism.\n- `LCC : SemiNormedGroup ⥤ Profiniteᵒᵖ ⥤ SemiNormedGroup` :\n  `LCC V S` is the seminormed group completion of the locally constant functions from `S` to `V`.\n\n## TODO\n\nPull off the stuff about completions and put it into `normed_group/SemiNormedGroup`?\nThen `system_of_complexes.basic` would not have to import this file.\n\n-/\n\nnoncomputable theory\nopen_locale nnreal\n\nuniverse u\n\nnamespace SemiNormedGroup\n\nopen uniform_space _root_.opposite _root_.category_theory Completion\n\ninstance normed_with_aut_Completion (V : SemiNormedGroup.{u}) (r : ℝ≥0) [normed_with_aut r V] :\n  normed_with_aut r (Completion.obj V) :=\n{ T := Completion.map_iso normed_with_aut.T,\n  norm_T :=\n  begin\n    rw ← function.funext_iff,\n    refine abstract_completion.funext completion.cpkg _ _ _,\n    { apply continuous_norm.comp _, exact completion.continuous_map },\n    { exact (continuous_const.mul continuous_norm : _) },\n    intro v,\n    calc _ = _ : congr_arg norm (completion.map_coe _ _)\n       ... = _ : _,\n    { exact normed_group_hom.uniform_continuous _ },\n    { erw [completion.norm_coe, normed_with_aut.norm_T, completion.norm_coe] }\n  end }\n\n@[simp] lemma Completion_T_inv_eq (V : SemiNormedGroup.{u}) (r : ℝ≥0) [normed_with_aut r V] :\n  (normed_with_aut.T.hom : Completion.obj V ⟶ _) = Completion.map normed_with_aut.T.hom := rfl\n\nlemma T_hom_incl {V : SemiNormedGroup} {r : ℝ≥0} [normed_with_aut r V] :\n  (incl : V ⟶ _) ≫ normed_with_aut.T.hom = normed_with_aut.T.hom ≫ incl :=\nbegin\n  ext x,\n  simp only [incl_apply, category_theory.comp_apply, Completion_T_inv_eq],\n  change completion.map normed_with_aut.T.hom _ = _,\n  rw completion.map_coe,\n  exact normed_group_hom.uniform_continuous _,\nend\n\nlemma T_hom_eq {V : SemiNormedGroup} {r : ℝ≥0} [normed_with_aut r V] :\n  normed_with_aut.T.hom = Completion.lift ((normed_with_aut.T.hom : V ⟶ V) ≫ incl) :=\nlift_unique _ _ T_hom_incl\n\n/-- `LCC` (Locally Constant Completion) is the bifunctor\nthat sends a seminormed group `V` and a profinite space `S` to `V-hat(S)`.\nHere `V-hat(S)` is the completion (for the sup norm) of the locally constant functions `S → V`. -/\ndef LCC : SemiNormedGroup ⥤ Profiniteᵒᵖ ⥤ SemiNormedGroup :=\ncurry.obj ((uncurry.obj LocallyConstant) ⋙ Completion)\n\nlemma LCC_obj_map' (V : SemiNormedGroup) {X Y : Profiniteᵒᵖ} (f : Y ⟶ X) :\n  (LCC.obj V).map f = Completion.map ((LocallyConstant.obj V).map f) :=\nbegin\n  delta LCC,\n  simp only [curry.obj_obj_map, LocallyConstant_obj_map, functor.comp_map, uncurry.obj_map,\n    nat_trans.id_app, functor.map_comp, functor.map_id, category_theory.functor.map_id],\n  erw [← functor.map_comp, category.id_comp]\nend\n\nlemma LCC_obj_map (V : SemiNormedGroup) {X Y : Profiniteᵒᵖ} (f : Y ⟶ X) (v : (LCC.obj V).obj Y) :\n  (LCC.obj V).map f v = completion.map (locally_constant.comap f.unop) v :=\nby { rw LCC_obj_map', refl }\n\nlemma LCC_obj_map_norm_noninc (V : SemiNormedGroup) {X Y : Profiniteᵒᵖ} (f : Y ⟶ X) :\n  ((LCC.obj V).map f).norm_noninc :=\nbegin\n  rw LCC_obj_map',\n  exact (Completion.map_norm_noninc $ LocallyConstant_obj_map_norm_noninc _ _ _ _)\nend\n\nvariables (S : Type*) [topological_space S] [compact_space S]\n\n@[simps]\ninstance normed_with_aut_LocallyConstant (V : SemiNormedGroup) (S : Profiniteᵒᵖ) (r : ℝ≥0)\n  [normed_with_aut r V] [hr : fact (0 < r)] :\n  normed_with_aut r ((LocallyConstant.obj V).obj S) :=\n{ T := (LocallyConstant.map_iso normed_with_aut.T).app S,\n  norm_T :=\n  begin\n    rw ← op_unop S,\n    rintro (f : locally_constant (unop S : Profinite) V),\n    show Sup _ = ↑r * Sup _,\n    dsimp,\n    simp only [normed_with_aut.norm_T],\n    convert real.Sup_mul r _ hr.out,\n    ext,\n    simp only [exists_prop, set.mem_range, exists_exists_eq_and, set.mem_set_of_eq]\n  end }\n\ninstance normed_with_aut_LCC (V : SemiNormedGroup) (S : Profiniteᵒᵖ) (r : ℝ≥0)\n  [normed_with_aut r V] [hr : fact (0 < r)] :\n  normed_with_aut r ((LCC.obj V).obj S) :=\nshow normed_with_aut r (Completion.obj $ (LocallyConstant.obj V).obj S), by apply_instance\n\nend SemiNormedGroup\n\n#lint- only unused_arguments def_lemma doc_blame\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/locally_constant/Vhat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4717560880852992}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.hom.group_action\nimport algebra.module.basic\nimport data.set_like.basic\nimport group_theory.group_action.basic\n/-!\n\n# Sets invariant to a `mul_action`\n\nIn this file we define `sub_mul_action R M`; a subset of a `mul_action R M` which is closed with\nrespect to scalar multiplication.\n\nFor most uses, typically `submodule R M` is more powerful.\n\n## Main definitions\n\n* `sub_mul_action.mul_action` - the `mul_action R M` transferred to the subtype.\n* `sub_mul_action.mul_action'` - the `mul_action S M` transferred to the subtype when\n  `is_scalar_tower S R M`.\n* `sub_mul_action.is_scalar_tower` - the `is_scalar_tower S R M` transferred to the subtype.\n\n## Tags\n\nsubmodule, mul_action\n-/\n\nopen function\n\nuniverses u u' u'' v\nvariables {S : Type u'} {T : Type u''} {R : Type u} {M : Type v}\n\nset_option old_structure_cmd true\n\n/-- A sub_mul_action is a set which is closed under scalar multiplication.  -/\nstructure sub_mul_action (R : Type u) (M : Type v) [has_smul R M] : Type v :=\n(carrier : set M)\n(smul_mem' : ∀ (c : R) {x : M}, x ∈ carrier → c • x ∈ carrier)\n\nnamespace sub_mul_action\n\nvariables [has_smul R M]\n\ninstance : set_like (sub_mul_action R M) M :=\n⟨sub_mul_action.carrier, λ p q h, by cases p; cases q; congr'⟩\n\n@[simp] lemma mem_carrier {p : sub_mul_action R M} {x : M} : x ∈ p.carrier ↔ x ∈ (p : set M) :=\niff.rfl\n\n@[ext] theorem ext {p q : sub_mul_action R M} (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := set_like.ext h\n\n/-- Copy of a sub_mul_action with a new `carrier` equal to the old one. Useful to fix definitional\nequalities.-/\nprotected def copy (p : sub_mul_action R M) (s : set M) (hs : s = ↑p) : sub_mul_action R M :=\n{ carrier := s,\n  smul_mem' := hs.symm ▸ p.smul_mem' }\n\n@[simp] lemma coe_copy (p : sub_mul_action R M) (s : set M) (hs : s = ↑p) :\n  (p.copy s hs : set M) = s := rfl\n\nlemma copy_eq (p : sub_mul_action R M) (s : set M) (hs : s = ↑p) : p.copy s hs = p :=\nset_like.coe_injective hs\n\ninstance : has_bot (sub_mul_action R M) :=\n⟨{ carrier := ∅, smul_mem' := λ c, set.not_mem_empty}⟩\n\ninstance : inhabited (sub_mul_action R M) := ⟨⊥⟩\n\nend sub_mul_action\n\nnamespace sub_mul_action\n\nsection has_smul\n\nvariables [has_smul R M]\nvariables (p : sub_mul_action R M)\nvariables {r : R} {x : M}\n\nlemma smul_mem (r : R) (h : x ∈ p) : r • x ∈ p := p.smul_mem' r h\n\ninstance : has_smul R p :=\n{ smul := λ c x, ⟨c • x.1, smul_mem _ c x.2⟩ }\n\nvariables {p}\n@[simp, norm_cast] lemma coe_smul (r : R) (x : p) : ((r • x : p) : M) = r • ↑x := rfl\n@[simp, norm_cast] lemma coe_mk (x : M) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : M) = x := rfl\n\nvariables (p)\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype : p →[R] M :=\nby refine {to_fun := coe, ..}; simp [coe_smul]\n\n@[simp] theorem subtype_apply (x : p) : p.subtype x = x := rfl\n\nlemma subtype_eq_val : ((sub_mul_action.subtype p) : p → M) = subtype.val := rfl\n\nend has_smul\n\nsection mul_action_monoid\n\nvariables [monoid R] [mul_action R M]\n\nsection\nvariables [has_smul S R] [has_smul S M] [is_scalar_tower S R M]\nvariables (p : sub_mul_action R M)\n\nlemma smul_of_tower_mem (s : S) {x : M} (h : x ∈ p) : s • x ∈ p :=\nby { rw [←one_smul R x, ←smul_assoc], exact p.smul_mem _ h }\n\ninstance has_smul' : has_smul S p :=\n{ smul := λ c x, ⟨c • x.1, smul_of_tower_mem _ c x.2⟩ }\n\ninstance : is_scalar_tower S R p :=\n{ smul_assoc := λ s r x, subtype.ext $ smul_assoc s r ↑x }\n\n@[simp, norm_cast] lemma coe_smul_of_tower (s : S) (x : p) : ((s • x : p) : M) = s • ↑x := rfl\n\n@[simp] lemma smul_mem_iff' {G} [group G] [has_smul G R] [mul_action G M]\n  [is_scalar_tower G R M] (g : G) {x : M} :\n  g • x ∈ p ↔ x ∈ p :=\n⟨λ h, inv_smul_smul g x ▸ p.smul_of_tower_mem g⁻¹ h, p.smul_of_tower_mem g⟩\n\ninstance [has_smul Sᵐᵒᵖ R] [has_smul Sᵐᵒᵖ M] [is_scalar_tower Sᵐᵒᵖ R M]\n  [is_central_scalar S M] : is_central_scalar S p :=\n{ op_smul_eq_smul := λ r x, subtype.ext $ op_smul_eq_smul r x }\n\nend\n\nsection\n\nvariables [monoid S] [has_smul S R] [mul_action S M] [is_scalar_tower S R M]\nvariables (p : sub_mul_action R M)\n\n/-- If the scalar product forms a `mul_action`, then the subset inherits this action -/\ninstance mul_action' : mul_action S p :=\n{ smul := (•),\n  one_smul := λ x, subtype.ext $ one_smul _ x,\n  mul_smul := λ c₁ c₂ x, subtype.ext $ mul_smul c₁ c₂ x }\n\ninstance : mul_action R p := p.mul_action'\n\nend\n\n\n/-- Orbits in a `sub_mul_action` coincide with orbits in the ambient space. -/\nlemma coe_image_orbit {p : sub_mul_action R M} (m : p) :\n  coe '' mul_action.orbit R m = mul_action.orbit R (m : M) := (set.range_comp _ _).symm\n\n/- -- Previously, the relatively useless :\nlemma orbit_of_sub_mul {p : sub_mul_action R M} (m : p) :\n  (mul_action.orbit R m : set M) = mul_action.orbit R (m : M) := rfl\n-/\n\n/-- Stabilizers in monoid sub_mul_action coincide with stabilizers in the ambient space -/\nlemma stabilizer_of_sub_mul.submonoid {p : sub_mul_action R M} (m : p) :\n  mul_action.stabilizer.submonoid R m = mul_action.stabilizer.submonoid R (m : M) :=\nbegin\n  ext,\n  simp only [mul_action.mem_stabilizer_submonoid_iff,\n      ← sub_mul_action.coe_smul, set_like.coe_eq_coe]\nend\n\nend mul_action_monoid\n\nsection mul_action_group\n\nvariables [group R] [mul_action R M]\n\n/-- Stabilizers in group sub_mul_action coincide with stabilizers in the ambient space -/\nlemma stabilizer_of_sub_mul {p : sub_mul_action R M} (m : p) :\n  mul_action.stabilizer R m = mul_action.stabilizer R (m : M) :=\nbegin\n  rw ← subgroup.to_submonoid_eq,\n  exact stabilizer_of_sub_mul.submonoid m,\nend\n\nend mul_action_group\n\n\nsection module\n\nvariables [semiring R] [add_comm_monoid M]\nvariables [module R M]\nvariables (p : sub_mul_action R M)\n\nlemma zero_mem (h : (p : set M).nonempty) : (0 : M) ∈ p :=\nlet ⟨x, hx⟩ := h in zero_smul R (x : M) ▸ p.smul_mem 0 hx\n\n/-- If the scalar product forms a `module`, and the `sub_mul_action` is not `⊥`, then the\nsubset inherits the zero. -/\ninstance [n_empty : nonempty p] : has_zero p :=\n{ zero := ⟨0, n_empty.elim $ λ x, p.zero_mem ⟨x, x.prop⟩⟩ }\n\nend module\n\nsection add_comm_group\n\nvariables [ring R] [add_comm_group M]\nvariables [module R M]\nvariables (p p' : sub_mul_action R M)\nvariables {r : R} {x y : M}\n\nlemma neg_mem (hx : x ∈ p) : -x ∈ p := by { rw ← neg_one_smul R, exact p.smul_mem _ hx }\n\n@[simp] lemma neg_mem_iff : -x ∈ p ↔ x ∈ p :=\n⟨λ h, by { rw ←neg_neg x, exact neg_mem _ h}, neg_mem _⟩\n\ninstance : has_neg p := ⟨λx, ⟨-x.1, neg_mem _ x.2⟩⟩\n\n@[simp, norm_cast] lemma coe_neg (x : p) : ((-x : p) : M) = -x := rfl\n\nend add_comm_group\n\nend sub_mul_action\n\nnamespace sub_mul_action\n\nvariables [group_with_zero S] [monoid R] [mul_action R M]\nvariables [has_smul S R] [mul_action S M] [is_scalar_tower S R M]\nvariables (p : sub_mul_action R M) {s : S} {x y : M}\n\ntheorem smul_mem_iff (s0 : s ≠ 0) : s • x ∈ p ↔ x ∈ p :=\np.smul_mem_iff' (units.mk0 s s0)\n\nend sub_mul_action\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/group_theory/group_action/sub_mul_action.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.749087201911703, "lm_q1q2_score": 0.4717560880852992}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.monoidal.braided\nimport category_theory.functor.reflects_isomorphisms\nimport category_theory.monoidal.coherence\n\n/-!\n# Half braidings and the Drinfeld center of a monoidal category\n\nWe define `center C` to be pairs `⟨X, b⟩`, where `X : C` and `b` is a half-braiding on `X`.\n\nWe show that `center C` is braided monoidal,\nand provide the monoidal functor `center.forget` from `center C` back to `C`.\n\n## Future work\n\nVerifying the various axioms here is done by tedious rewriting.\nUsing the `slice` tactic may make the proofs marginally more readable.\n\nMore exciting, however, would be to make possible one of the following options:\n1. Integration with homotopy.io / globular to give \"picture proofs\".\n2. The monoidal coherence theorem, so we can ignore associators\n   (after which most of these proofs are trivial;\n   I'm unsure if the monoidal coherence theorem is even usable in dependent type theory).\n3. Automating these proofs using `rewrite_search` or some relative.\n\n-/\n\nopen category_theory\nopen category_theory.monoidal_category\n\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u₁} [category.{v₁} C] [monoidal_category C]\n\n/--\nA half-braiding on `X : C` is a family of isomorphisms `X ⊗ U ≅ U ⊗ X`,\nmonoidally natural in `U : C`.\n\nThinking of `C` as a 2-category with a single `0`-morphism, these are the same as natural\ntransformations (in the pseudo- sense) of the identity 2-functor on `C`, which send the unique\n`0`-morphism to `X`.\n-/\n@[nolint has_inhabited_instance]\nstructure half_braiding (X : C) :=\n(β : Π U, X ⊗ U ≅ U ⊗ X)\n(monoidal' : ∀ U U', (β (U ⊗ U')).hom =\n  (α_ _ _ _).inv ≫ ((β U).hom ⊗ 𝟙 U') ≫ (α_ _ _ _).hom ≫ (𝟙 U ⊗ (β U').hom) ≫ (α_ _ _ _).inv\n  . obviously)\n(naturality' : ∀ {U U'} (f : U ⟶ U'), (𝟙 X ⊗ f) ≫ (β U').hom = (β U).hom ≫ (f ⊗ 𝟙 X) . obviously)\n\nrestate_axiom half_braiding.monoidal'\nattribute [reassoc, simp] half_braiding.monoidal -- the reassoc lemma is redundant as a simp lemma\nrestate_axiom half_braiding.naturality'\nattribute [simp, reassoc] half_braiding.naturality\n\nvariables (C)\n/--\nThe Drinfeld center of a monoidal category `C` has as objects pairs `⟨X, b⟩`, where `X : C`\nand `b` is a half-braiding on `X`.\n-/\n@[nolint has_inhabited_instance]\ndef center := Σ X : C, half_braiding X\n\nnamespace center\n\nvariables {C}\n\n/-- A morphism in the Drinfeld center of `C`. -/\n@[ext, nolint has_inhabited_instance]\nstructure hom (X Y : center C) :=\n(f : X.1 ⟶ Y.1)\n(comm' : ∀ U, (f ⊗ 𝟙 U) ≫ (Y.2.β U).hom = (X.2.β U).hom ≫ (𝟙 U ⊗ f) . obviously)\n\nrestate_axiom hom.comm'\nattribute [simp, reassoc] hom.comm\n\ninstance : category (center C) :=\n{ hom := hom,\n  id := λ X, { f := 𝟙 X.1, },\n  comp := λ X Y Z f g, { f := f.f ≫ g.f, }, }\n\n@[simp] lemma id_f (X : center C) : hom.f (𝟙 X) = 𝟙 X.1 := rfl\n@[simp] lemma comp_f {X Y Z : center C} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).f = f.f ≫ g.f := rfl\n\n@[ext]\nlemma ext {X Y : center C} (f g : X ⟶ Y) (w : f.f = g.f) : f = g :=\nby { cases f, cases g, congr, exact w, }\n\n/--\nConstruct an isomorphism in the Drinfeld center from\na morphism whose underlying morphism is an isomorphism.\n-/\n@[simps]\ndef iso_mk {X Y : center C} (f : X ⟶ Y) [is_iso f.f] : X ≅ Y :=\n{ hom := f,\n  inv := ⟨inv f.f, λ U, by simp [←cancel_epi (f.f ⊗ 𝟙 U), ←comp_tensor_id_assoc, ←id_tensor_comp]⟩ }\n\ninstance is_iso_of_f_is_iso {X Y : center C} (f : X ⟶ Y) [is_iso f.f] : is_iso f :=\nbegin\n  change is_iso (iso_mk f).hom,\n  apply_instance,\nend\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_obj (X Y : center C) : center C :=\n⟨X.1 ⊗ Y.1,\n  { β := λ U, α_ _ _ _ ≪≫ (iso.refl X.1 ⊗ Y.2.β U) ≪≫ (α_ _ _ _).symm\n      ≪≫ (X.2.β U ⊗ iso.refl Y.1) ≪≫ α_ _ _ _,\n    monoidal' := λ U U',\n    begin\n      dsimp,\n      simp only [comp_tensor_id, id_tensor_comp, category.assoc, half_braiding.monoidal],\n      -- On the RHS, we'd like to commute `((X.snd.β U).hom ⊗ 𝟙 Y.fst) ⊗ 𝟙 U'`\n      -- and `𝟙 U ⊗ 𝟙 X.fst ⊗ (Y.snd.β U').hom` past each other,\n      -- but there are some associators we need to get out of the way first.\n      slice_rhs 6 8 { rw pentagon, },\n      slice_rhs 5 6 { rw associator_naturality, },\n      slice_rhs 7 8 { rw ←associator_naturality, },\n      slice_rhs 6 7 { rw [tensor_id, tensor_id, tensor_id_comp_id_tensor, ←id_tensor_comp_tensor_id,\n        ←tensor_id, ←tensor_id], },\n      -- Now insert associators as needed to make the four half-braidings look identical\n      slice_rhs 10 10 { rw associator_inv_conjugation, },\n      slice_rhs 7 7 { rw associator_inv_conjugation, },\n      slice_rhs 6 6 { rw associator_conjugation, },\n      slice_rhs 3 3 { rw associator_conjugation, },\n      -- Finish with an application of the coherence theorem.\n      coherence,\n    end,\n    naturality' := λ U U' f,\n    begin\n      dsimp,\n      rw [category.assoc, category.assoc, category.assoc, category.assoc,\n        id_tensor_associator_naturality_assoc, ←id_tensor_comp_assoc, half_braiding.naturality,\n        id_tensor_comp_assoc, associator_inv_naturality_assoc, ←comp_tensor_id_assoc,\n        half_braiding.naturality, comp_tensor_id_assoc, associator_naturality, ←tensor_id],\n    end, }⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_hom {X₁ Y₁ X₂ Y₂ : center C} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :\n  tensor_obj X₁ X₂ ⟶ tensor_obj Y₁ Y₂ :=\n{ f := f.f ⊗ g.f,\n  comm' := λ U, begin\n    dsimp,\n    rw [category.assoc, category.assoc, category.assoc, category.assoc,\n      associator_naturality_assoc, ←tensor_id_comp_id_tensor, category.assoc,\n      ←id_tensor_comp_assoc, g.comm, id_tensor_comp_assoc, tensor_id_comp_id_tensor_assoc,\n      ←id_tensor_comp_tensor_id, category.assoc, associator_inv_naturality_assoc,\n      id_tensor_associator_inv_naturality_assoc, tensor_id,\n      id_tensor_comp_tensor_id_assoc, ←tensor_id_comp_id_tensor g.f, category.assoc,\n      ←comp_tensor_id_assoc, f.comm, comp_tensor_id_assoc, id_tensor_associator_naturality,\n      associator_naturality_assoc, ←id_tensor_comp, tensor_id_comp_id_tensor],\n  end }\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_unit : center C :=\n⟨𝟙_ C,\n  { β := λ U, (λ_ U) ≪≫ (ρ_ U).symm,\n    monoidal' := λ U U', by simp,\n    naturality' := λ U U' f, begin\n      dsimp,\n      rw [left_unitor_naturality_assoc, right_unitor_inv_naturality, category.assoc],\n    end, }⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef associator (X Y Z : center C) : tensor_obj (tensor_obj X Y) Z ≅ tensor_obj X (tensor_obj Y Z) :=\niso_mk ⟨(α_ X.1 Y.1 Z.1).hom, λ U, begin\n  dsimp,\n  simp only [comp_tensor_id, id_tensor_comp, ←tensor_id, associator_conjugation],\n  coherence,\nend⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef left_unitor (X : center C) : tensor_obj tensor_unit X ≅ X :=\niso_mk ⟨(λ_ X.1).hom, λ U, begin\n  dsimp,\n  simp only [category.comp_id, category.assoc, tensor_inv_hom_id, comp_tensor_id,\n    tensor_id_comp_id_tensor, triangle_assoc_comp_right_inv],\n  rw [←left_unitor_tensor, left_unitor_naturality, left_unitor_tensor'_assoc],\nend⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef right_unitor (X : center C) : tensor_obj X tensor_unit ≅ X :=\niso_mk ⟨(ρ_ X.1).hom, λ U, begin\n  dsimp,\n  simp only [tensor_id_comp_id_tensor_assoc, triangle_assoc, id_tensor_comp, category.assoc],\n  rw [←tensor_id_comp_id_tensor_assoc (ρ_ U).inv, cancel_epi, ←right_unitor_tensor_inv_assoc,\n    ←right_unitor_inv_naturality_assoc],\n  simp,\nend⟩\n\nsection\nlocal attribute [simp] associator_naturality left_unitor_naturality right_unitor_naturality\n  pentagon\nlocal attribute [simp] center.associator center.left_unitor center.right_unitor\n\ninstance : monoidal_category (center C) :=\n{ tensor_obj := λ X Y, tensor_obj X Y,\n  tensor_hom := λ X₁ Y₁ X₂ Y₂ f g, tensor_hom f g,\n  tensor_unit := tensor_unit,\n  associator := associator,\n  left_unitor := left_unitor,\n  right_unitor := right_unitor, }\n\n@[simp] lemma tensor_fst (X Y : center C) : (X ⊗ Y).1 = X.1 ⊗ Y.1 := rfl\n\n@[simp] lemma tensor_β (X Y : center C) (U : C) :\n  (X ⊗ Y).2.β U =\n    α_ _ _ _ ≪≫ (iso.refl X.1 ⊗ Y.2.β U) ≪≫ (α_ _ _ _).symm\n      ≪≫ (X.2.β U ⊗ iso.refl Y.1) ≪≫ α_ _ _ _ :=\nrfl\n@[simp] \n\n@[simp] lemma tensor_unit_β (U : C) : (𝟙_ (center C)).2.β U = (λ_ U) ≪≫ (ρ_ U).symm := rfl\n\n@[simp] lemma associator_hom_f (X Y Z : center C) : hom.f (α_ X Y Z).hom = (α_ X.1 Y.1 Z.1).hom :=\nrfl\n\n@[simp] lemma associator_inv_f (X Y Z : center C) : hom.f (α_ X Y Z).inv = (α_ X.1 Y.1 Z.1).inv :=\nby { ext, rw [←associator_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma left_unitor_hom_f (X : center C) : hom.f (λ_ X).hom = (λ_ X.1).hom :=\nrfl\n\n@[simp] lemma left_unitor_inv_f (X : center C) : hom.f (λ_ X).inv = (λ_ X.1).inv :=\nby { ext, rw [←left_unitor_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma right_unitor_hom_f (X : center C) : hom.f (ρ_ X).hom = (ρ_ X.1).hom :=\nrfl\n\n@[simp] lemma right_unitor_inv_f (X : center C) : hom.f (ρ_ X).inv = (ρ_ X.1).inv :=\nby { ext, rw [←right_unitor_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\nend\n\nsection\nvariables (C)\n\n/-- The forgetful monoidal functor from the Drinfeld center to the original category. -/\n@[simps]\ndef forget : monoidal_functor (center C) C :=\n{ obj := λ X, X.1,\n  map := λ X Y f, f.f,\n  ε := 𝟙 (𝟙_ C),\n  μ := λ X Y, 𝟙 (X.1 ⊗ Y.1), }\n\ninstance : reflects_isomorphisms (forget C).to_functor :=\n{ reflects := λ A B f i, by { dsimp at i, resetI, change is_iso (iso_mk f).hom, apply_instance, } }\n\nend\n\n/-- Auxiliary definition for the `braided_category` instance on `center C`. -/\n@[simps]\ndef braiding (X Y : center C) : X ⊗ Y ≅ Y ⊗ X :=\niso_mk ⟨(X.2.β Y.1).hom, λ U, begin\n  dsimp,\n  simp only [category.assoc],\n  rw [←is_iso.inv_comp_eq, is_iso.iso.inv_hom, ←half_braiding.monoidal_assoc,\n    ←half_braiding.naturality_assoc, half_braiding.monoidal],\n  simp,\nend⟩\n\ninstance braided_category_center : braided_category (center C) :=\n{ braiding := braiding,\n  braiding_naturality' := λ X Y X' Y' f g, begin\n    ext,\n    dsimp,\n    rw [←tensor_id_comp_id_tensor, category.assoc, half_braiding.naturality, f.comm_assoc,\n      id_tensor_comp_tensor_id],\n  end, } -- `obviously` handles the hexagon axioms\n\nsection\nvariables [braided_category C]\n\nopen braided_category\n\n/-- Auxiliary construction for `of_braided`. -/\n@[simps]\ndef of_braided_obj (X : C) : center C :=\n⟨X, { β := λ Y, β_ X Y,\n  monoidal' := λ U U', begin\n    rw [iso.eq_inv_comp, ←category.assoc, ←category.assoc, iso.eq_comp_inv,\n      category.assoc, category.assoc],\n    exact hexagon_forward X U U',\n  end }⟩\n\nvariables (C)\n\n/--\nThe functor lifting a braided category to its center, using the braiding as the half-braiding.\n-/\n@[simps]\ndef of_braided : monoidal_functor C (center C) :=\n{ obj := of_braided_obj,\n  map := λ X X' f,\n  { f := f,\n    comm' := λ U, braiding_naturality _ _, },\n  ε :=\n  { f := 𝟙 _,\n    comm' := λ U, begin\n      dsimp,\n      rw [tensor_id, category.id_comp, tensor_id, category.comp_id, ←braiding_right_unitor,\n        category.assoc, iso.hom_inv_id, category.comp_id],\n    end, },\n  μ := λ X Y,\n  { f := 𝟙 _,\n    comm' := λ U, begin\n      dsimp,\n      rw [tensor_id, tensor_id, category.id_comp, category.comp_id,\n        ←iso.inv_comp_eq, ←category.assoc, ←category.assoc, ←iso.comp_inv_eq,\n        category.assoc, hexagon_reverse, category.assoc],\n    end, }, }\n\nend\n\nend center\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/monoidal/center.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.4715812007678355}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.arrow\n\n/-!\n# Strong epimorphisms\n\nIn this file, we define strong epimorphisms. A strong epimorphism is an epimorphism `f`, such\nthat for every commutative square with `f` at the top and a monomorphism at the bottom, there is\na diagonal morphism making the two triangles commute. This lift is necessarily unique (as shown in\n`comma.lean`).\n\n## Main results\n\nBesides the definition, we show that\n* the composition of two strong epimorphisms is a strong epimorphism,\n* if `f ≫ g` is a strong epimorphism, then so is `g`,\n* if `f` is both a strong epimorphism and a monomorphism, then it is an isomorphism\n\n\n## TODO\n\nShow that the dual of a strong epimorphism is a strong monomorphism, and vice versa.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 1*][borceux-vol1]\n-/\n\nuniverses v u\n\nnamespace category_theory\nvariables {C : Type u} [category.{v} C]\n\nvariables {P Q : C}\n\n/-- A strong epimorphism `f` is an epimorphism such that every commutative square with `f` at the\n    top and a monomorphism at the bottom has a lift. -/\nclass strong_epi (f : P ⟶ Q) : Prop :=\n(epi : epi f)\n(has_lift : Π {X Y : C} {u : P ⟶ X} {v : Q ⟶ Y} {z : X ⟶ Y} [mono z] (h : u ≫ z = f ≫ v),\n  arrow.has_lift $ arrow.hom_mk' h)\n\n/-- A strong monomorphism `f` is a monomorphism such that every commutative square with `f` at the\n    bottom and an epimorphism at the top has a lift. -/\nclass strong_mono (f : P ⟶ Q) : Prop :=\n(mono : mono f)\n(has_lift : Π {X Y : C} {u : X ⟶ P} {v : Y ⟶ Q} {z : X ⟶ Y} [epi z] (h : u ≫ f = z ≫ v),\n  arrow.has_lift $ arrow.hom_mk' h)\n\nattribute [instance] strong_epi.has_lift\nattribute [instance] strong_mono.has_lift\n\n@[priority 100]\ninstance epi_of_strong_epi (f : P ⟶ Q) [strong_epi f] : epi f := strong_epi.epi\n\n@[priority 100]\ninstance mono_of_strong_mono (f : P ⟶ Q) [strong_mono f] : mono f := strong_mono.mono\n\nsection\nvariables {R : C} (f : P ⟶ Q) (g : Q ⟶ R)\n\n/-- The composition of two strong epimorphisms is a strong epimorphism. -/\nlemma strong_epi_comp [strong_epi f] [strong_epi g] : strong_epi (f ≫ g) :=\n{ epi := epi_comp _ _,\n  has_lift :=\n  begin\n    introsI,\n    have h₀ : u ≫ z = f ≫ g ≫ v, by simpa [category.assoc] using h,\n    let w : Q ⟶ X := arrow.lift (arrow.hom_mk' h₀),\n    have h₁ : w ≫ z = g ≫ v, by rw arrow.lift_mk'_right,\n    exact arrow.has_lift.mk ⟨(arrow.lift (arrow.hom_mk' h₁) : R ⟶ X), by simp, by simp⟩\n  end }\n\n/-- The composition of two strong monomorphisms is a strong monomorphism. -/\nlemma strong_mono_comp [strong_mono f] [strong_mono g] : strong_mono (f ≫ g) :=\n{ mono := mono_comp _ _,\n  has_lift :=\n  begin\n    introsI,\n    have h₀ : (u ≫ f) ≫ g = z ≫ v, by simpa [category.assoc] using h,\n    let w : Y ⟶ Q := arrow.lift (arrow.hom_mk' h₀),\n    have h₁ : u ≫ f = z ≫ w, by rw arrow.lift_mk'_left,\n    exact arrow.has_lift.mk ⟨(arrow.lift (arrow.hom_mk' h₁) : Y ⟶ P), by simp, by simp⟩\n  end }\n\n/-- If `f ≫ g` is a strong epimorphism, then so is `g`. -/\nlemma strong_epi_of_strong_epi [strong_epi (f ≫ g)] : strong_epi g :=\n{ epi := epi_of_epi f g,\n  has_lift :=\n  begin\n    introsI,\n    have h₀ : (f ≫ u) ≫ z = (f ≫ g) ≫ v, by simp only [category.assoc, h],\n    exact arrow.has_lift.mk\n      ⟨(arrow.lift (arrow.hom_mk' h₀) : R ⟶ X), (cancel_mono z).1 (by simp [h]), by simp⟩,\n  end }\n\n/-- If `f ≫ g` is a strong monomorphism, then so is `f`. -/\n\n\n/-- An isomorphism is in particular a strong epimorphism. -/\n@[priority 100] instance strong_epi_of_is_iso [is_iso f] : strong_epi f :=\n{ epi := by apply_instance,\n  has_lift := λ X Y u v z _ h, arrow.has_lift.mk ⟨inv f ≫ u, by simp, by simp [h]⟩ }\n\n/-- An isomorphism is in particular a strong monomorphism. -/\n@[priority 100] instance strong_mono_of_is_iso [is_iso f] : strong_mono f :=\n{ mono := by apply_instance,\n  has_lift := λ X Y u v z _ h, arrow.has_lift.mk\n    ⟨v ≫ inv f, by simp [← category.assoc, ← h], by simp⟩ }\n\nend\n\n/-- A strong epimorphism that is a monomorphism is an isomorphism. -/\nlemma is_iso_of_mono_of_strong_epi (f : P ⟶ Q) [mono f] [strong_epi f] : is_iso f :=\n⟨⟨arrow.lift $ arrow.hom_mk' $ show 𝟙 P ≫ f = f ≫ 𝟙 Q, by simp, by tidy⟩⟩\n\n/-- A strong monomorphism that is an epimorphism is an isomorphism. -/\nlemma is_iso_of_epi_of_strong_mono (f : P ⟶ Q) [epi f] [strong_mono f] : is_iso f :=\n⟨⟨arrow.lift $ arrow.hom_mk' $ show 𝟙 P ≫ f = f ≫ 𝟙 Q, by simp, by tidy⟩⟩\n\nend category_theory\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/category_theory/limits/shapes/strong_epi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4715811935642602}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Floris van Doorn\n-/\nimport order.hom.complete_lattice\nimport topology.bases\nimport topology.homeomorph\nimport topology.continuous_function.basic\nimport order.compactly_generated\nimport tactic.auto_cases\n\n/-!\n# Open sets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n## Summary\n\nWe define the subtype of open sets in a topological space.\n\n## Main Definitions\n\n### Bundled open sets\n\n- `opens α` is the type of open subsets of a topological space `α`.\n- `opens.is_basis` is a predicate saying that a set of `opens`s form a topological basis.\n- `opens.comap`: preimage of an open set under a continuous map as a `frame_hom`.\n- `homeomorph.opens_congr`: order-preserving equivalence between open sets in the domain and the\n  codomain of a homeomorphism.\n\n### Bundled open neighborhoods\n\n- `open_nhds_of x` is the type of open subsets of a topological space `α` containing `x : α`.\n- `open_nhds_of.comap f x U` is the preimage of open neighborhood `U` of `f x` under `f : C(α, β)`.\n\n## Main results\n\nWe define order structures on both `opens α` (`complete_structure`, `frame`) and `open_nhds_of x`\n(`order_top`, `distrib_lattice`).\n-/\n\nopen filter function order set\nopen_locale topology\n\nvariables {ι α β γ : Type*} [topological_space α] [topological_space β] [topological_space γ]\n\nnamespace topological_space\n\nvariable (α)\n\n/-- The type of open subsets of a topological space. -/\nstructure opens :=\n(carrier : set α)\n(is_open' : is_open carrier)\n\nvariable {α}\n\nnamespace opens\n\ninstance : set_like (opens α) α :=\n{ coe := opens.carrier,\n  coe_injective' := λ ⟨_, _⟩ ⟨_, _⟩ _, by congr; assumption }\n\ninstance : can_lift (set α) (opens α) coe is_open :=\n⟨λ s h, ⟨⟨s, h⟩, rfl⟩⟩\n\nlemma «forall» {p : opens α → Prop} : (∀ U, p U) ↔ ∀ (U : set α) (hU : is_open U), p ⟨U, hU⟩ :=\n⟨λ h _ _, h _, λ h ⟨U, hU⟩, h _ _⟩\n\n@[simp] lemma carrier_eq_coe (U : opens α) : U.1 = ↑U := rfl\n\n/-- the coercion `opens α → set α` applied to a pair is the same as taking the first component -/\n@[simp] lemma coe_mk {U : set α} {hU : is_open U} : ↑(⟨U, hU⟩ : opens α) = U := rfl\n\n@[simp] lemma mem_mk {x : α} {U : set α} {h : is_open U} :\n  @has_mem.mem _ (opens α) _ x ⟨U, h⟩ ↔ x ∈ U := iff.rfl\n\n-- todo: make it `simp` for a `set_like`?\n@[simp] protected lemma nonempty_coe_sort {U : opens α} : nonempty U ↔ (U : set α).nonempty :=\nset.nonempty_coe_sort\n\n@[ext] lemma ext {U V : opens α} (h : (U : set α) = V) : U = V := set_like.coe_injective h\n@[simp] lemma coe_inj {U V : opens α} : (U : set α) = V ↔ U = V := set_like.ext'_iff.symm\n\nprotected lemma is_open (U : opens α) : is_open (U : set α) := U.is_open'\n\n@[simp] lemma mk_coe (U : opens α) : mk ↑U U.is_open = U := by { cases U, refl }\n\n/-- See Note [custom simps projection]. -/\ndef simps.coe (U : opens α) : set α := U\n\ninitialize_simps_projections opens (carrier → coe)\n\n/-- The interior of a set, as an element of `opens`. -/\ndef interior (s : set α) : opens α := ⟨interior s, is_open_interior⟩\n\nlemma gc : galois_connection (coe : opens α → set α) interior :=\nλ U s, ⟨λ h, interior_maximal h U.is_open, λ h, le_trans h interior_subset⟩\n\n/-- The galois coinsertion between sets and opens. -/\ndef gi : galois_coinsertion coe (@interior α _) :=\n{ choice := λ s hs, ⟨s, interior_eq_iff_is_open.mp $ le_antisymm interior_subset hs⟩,\n  gc := gc,\n  u_l_le := λ _, interior_subset,\n  choice_eq := λ s hs, le_antisymm hs interior_subset }\n\ninstance : complete_lattice (opens α) :=\ncomplete_lattice.copy (galois_coinsertion.lift_complete_lattice gi)\n/- le  -/ (λ U V, (U : set α) ⊆ V) rfl\n/- top -/ ⟨univ, is_open_univ⟩ (ext interior_univ.symm)\n/- bot -/ ⟨∅, is_open_empty⟩ rfl\n/- sup -/ (λ U V, ⟨↑U ∪ ↑V, U.2.union V.2⟩) rfl\n/- inf -/ (λ U V, ⟨↑U ∩ ↑V, U.2.inter V.2⟩) (funext₂ $ λ U V, ext (U.2.inter V.2).interior_eq.symm)\n/- Sup -/ (λ S, ⟨⋃ s ∈ S, ↑s, is_open_bUnion $ λ s _, s.2⟩) (funext $ λ S, ext Sup_image.symm)\n/- Inf -/ _ rfl\n\n@[simp] lemma mk_inf_mk {U V : set α} {hU : is_open U} {hV : is_open V} :\n  (⟨U, hU⟩ ⊓ ⟨V, hV⟩ : opens α) = ⟨U ⊓ V, is_open.inter hU hV⟩ := rfl\n@[simp, norm_cast] lemma coe_inf (s t : opens α) : (↑(s ⊓ t) : set α) = s ∩ t := rfl\n@[simp, norm_cast] lemma coe_sup (s t : opens α) : (↑(s ⊔ t) : set α) = s ∪ t := rfl\n@[simp, norm_cast] lemma coe_bot : ((⊥ : opens α) : set α) = ∅ := rfl\n@[simp, norm_cast] lemma coe_top : ((⊤ : opens α) : set α) = set.univ := rfl\n@[simp, norm_cast] lemma coe_Sup {S : set (opens α)} : (↑(Sup S) : set α) = ⋃ i ∈ S, ↑i := rfl\n\n@[simp, norm_cast] lemma coe_finset_sup (f : ι → opens α) (s : finset ι) :\n  (↑(s.sup f) : set α) = s.sup (coe ∘ f) :=\nmap_finset_sup (⟨⟨coe, coe_sup⟩, coe_bot⟩ : sup_bot_hom (opens α) (set α)) _ _\n\n@[simp, norm_cast] lemma coe_finset_inf (f : ι → opens α) (s : finset ι) :\n  (↑(s.inf f) : set α) = s.inf (coe ∘ f) :=\nmap_finset_inf (⟨⟨coe, coe_inf⟩, coe_top⟩ : inf_top_hom (opens α) (set α)) _ _\n\ninstance : inhabited (opens α) := ⟨⊥⟩\n\nlemma supr_def {ι} (s : ι → opens α) : (⨆ i, s i) = ⟨⋃ i, s i, is_open_Union $ λ i, (s i).2⟩ :=\nby { ext, simp only [supr, coe_Sup, bUnion_range], refl }\n\n@[simp] lemma supr_mk {ι} (s : ι → set α) (h : Π i, is_open (s i)) :\n  (⨆ i, ⟨s i, h i⟩ : opens α) = ⟨⋃ i, s i, is_open_Union h⟩ :=\nby { rw supr_def, simp }\n\n@[simp, norm_cast] lemma coe_supr {ι} (s : ι → opens α) :\n  ((⨆ i, s i : opens α) : set α) = ⋃ i, s i :=\nby simp [supr_def]\n\n@[simp] theorem mem_supr {ι} {x : α} {s : ι → opens α} : x ∈ supr s ↔ ∃ i, x ∈ s i :=\nby { rw [← set_like.mem_coe], simp, }\n\n@[simp] lemma mem_Sup {Us : set (opens α)} {x : α} : x ∈ Sup Us ↔ ∃ u ∈ Us, x ∈ u :=\nby simp_rw [Sup_eq_supr, mem_supr]\n\ninstance : frame (opens α) :=\n{ Sup := Sup,\n  inf_Sup_le_supr_inf := λ a s,\n    (ext $ by simp only [coe_inf, coe_supr, coe_Sup, set.inter_Union₂]).le,\n  ..opens.complete_lattice }\n\nlemma open_embedding_of_le {U V : opens α} (i : U ≤ V) :\n  open_embedding (set.inclusion i) :=\n{ inj := set.inclusion_injective i,\n  induced := (@induced_compose _ _ _ _ (set.inclusion i) coe).symm,\n  open_range :=\n  begin\n    rw set.range_inclusion i,\n    exact U.is_open.preimage continuous_subtype_val\n  end, }\n\nlemma not_nonempty_iff_eq_bot (U : opens α) : ¬ set.nonempty (U : set α) ↔ U = ⊥ :=\nby rw [← coe_inj, opens.coe_bot, ← set.not_nonempty_iff_eq_empty]\n\nlemma ne_bot_iff_nonempty (U : opens α) : U ≠ ⊥ ↔ set.nonempty (U : set α) :=\nby rw [ne.def, ← opens.not_nonempty_iff_eq_bot, not_not]\n\n/-- An open set in the indiscrete topology is either empty or the whole space. -/\nlemma eq_bot_or_top {α} [t : topological_space α] (h : t = ⊤) (U : opens α) : U = ⊥ ∨ U = ⊤ :=\nbegin\n  simp only [← coe_inj],\n  unfreezingI { subst h }, letI : topological_space α := ⊤,\n  exact (is_open_top_iff _).1 U.2\nend\n\n/-- A set of `opens α` is a basis if the set of corresponding sets is a topological basis. -/\ndef is_basis (B : set (opens α)) : Prop := is_topological_basis ((coe : _ → set α) '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens α)} :\n  is_basis B ↔ ∀ {U : opens α} {x}, x ∈ U → ∃ U' ∈ B, x ∈ U' ∧ U' ≤ U :=\nbegin\n  split; intro h,\n  { rintros ⟨sU, hU⟩ x hx,\n    rcases h.mem_nhds_iff.mp (is_open.mem_nhds hU hx)\n      with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩,\n    refine ⟨V, H₁, _⟩,\n    cases V, dsimp at H₂, subst H₂, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU ⟨U, ⟨H₁, rfl⟩⟩, exact U.2 },\n    { intros x sU hx hsU,\n      rcases @h (⟨sU, hsU⟩ : opens α) x hx with ⟨V, hV, H⟩,\n      exact ⟨V, ⟨V, hV, rfl⟩, H⟩ } }\nend\n\nlemma is_basis_iff_cover {B : set (opens α)} :\n  is_basis B ↔ ∀ U : opens α, ∃ Us ⊆ B, U = Sup Us :=\nbegin\n  split,\n  { intros hB U,\n    refine ⟨{V : opens α | V ∈ B ∧ V ≤ U}, λ U hU, hU.left, _⟩,\n    apply ext,\n    rw [coe_Sup, hB.open_eq_sUnion' U.is_open],\n    simp_rw [sUnion_eq_bUnion, Union, supr_and, supr_image],\n    refl },\n  { intro h,\n    rw is_basis_iff_nbhd,\n    intros U x hx,\n    rcases h U with ⟨Us, hUs, rfl⟩,\n    rcases mem_Sup.1 hx with ⟨U, Us, xU⟩,\n    exact ⟨U, hUs Us, xU, le_Sup Us⟩ }\nend\n\n/-- If `α` has a basis consisting of compact opens, then an open set in `α` is compact open iff\n  it is a finite union of some elements in the basis -/\nlemma is_basis.is_compact_open_iff_eq_finite_Union\n  {ι : Type*} (b : ι → opens α) (hb : is_basis (set.range b))\n  (hb' : ∀ i, is_compact (b i : set α)) (U : set α) :\n  is_compact U ∧ is_open U ↔ ∃ (s : set ι), s.finite ∧ U = ⋃ i ∈ s, b i :=\nbegin\n  apply is_compact_open_iff_eq_finite_Union_of_is_topological_basis\n    (λ i : ι, (b i).1),\n  { convert hb, ext, simp },\n  { exact hb' }\nend\n\n@[simp] lemma is_compact_element_iff (s : opens α) :\n  complete_lattice.is_compact_element s ↔ is_compact (s : set α) :=\nbegin\n  rw [is_compact_iff_finite_subcover, complete_lattice.is_compact_element_iff],\n  refine ⟨_, λ H ι U hU, _⟩,\n  { introv H hU hU',\n    obtain ⟨t, ht⟩ := H ι (λ i, ⟨U i, hU i⟩) (by simpa),\n    refine ⟨t, set.subset.trans ht _⟩,\n    rw [coe_finset_sup, finset.sup_eq_supr],\n    refl },\n  { obtain ⟨t, ht⟩ := H (λ i, U i) (λ i, (U i).is_open)\n      (by simpa using (show (s : set α) ⊆ ↑(supr U), from hU)),\n    refine ⟨t, set.subset.trans ht _⟩,\n    simp only [set.Union_subset_iff],\n    show ∀ i ∈ t, U i ≤ t.sup U, from λ i, finset.le_sup }\nend\n\n/-- The preimage of an open set, as an open set. -/\ndef comap (f : C(α, β)) : frame_hom (opens β) (opens α) :=\n{ to_fun := λ s, ⟨f ⁻¹' s, s.2.preimage f.continuous⟩,\n  map_Sup' := λ s, ext $ by simp only [coe_Sup, preimage_Union, bUnion_image, coe_mk],\n  map_inf' := λ a b, rfl,\n  map_top' := rfl }\n\n@[simp] lemma comap_id : comap (continuous_map.id α) = frame_hom.id _ :=\nframe_hom.ext $ λ a, ext rfl\n\nlemma comap_mono (f : C(α, β)) {s t : opens β} (h : s ≤ t) : comap f s ≤ comap f t :=\norder_hom_class.mono (comap f) h\n\n@[simp] lemma coe_comap (f : C(α, β)) (U : opens β) : ↑(comap f U) = f ⁻¹' U := rfl\n\nprotected lemma comap_comp (g : C(β, γ)) (f : C(α, β)) :\n  comap (g.comp f) = (comap f).comp (comap g) := rfl\n\nprotected lemma comap_comap (g : C(β, γ)) (f : C(α, β)) (U : opens γ) :\n  comap f (comap g U) = comap (g.comp f) U := rfl\n\nlemma comap_injective [t0_space β] : injective (comap : C(α, β) → frame_hom (opens β) (opens α)) :=\nλ f g h, continuous_map.ext $ λ a, inseparable.eq $ inseparable_iff_forall_open.2 $ λ s hs,\nhave comap f ⟨s, hs⟩ = comap g ⟨s, hs⟩, from fun_like.congr_fun h ⟨_, hs⟩,\nshow a ∈ f ⁻¹' s ↔ a ∈ g ⁻¹' s, from set.ext_iff.1 (coe_inj.2 this) a\n\n/-- A homeomorphism induces an order-preserving equivalence on open sets, by taking comaps. -/\n@[simps apply { fully_applied := ff }]\ndef _root_.homeomorph.opens_congr (f : α ≃ₜ β) : opens α ≃o opens β :=\n{ to_fun := opens.comap f.symm.to_continuous_map,\n  inv_fun := opens.comap f.to_continuous_map,\n  left_inv := by { intro U, ext1, exact f.to_equiv.preimage_symm_preimage _ },\n  right_inv := by { intro U, ext1, exact f.to_equiv.symm_preimage_preimage _ },\n  map_rel_iff' := λ U V, by simp only [← set_like.coe_subset_coe];\n    exact f.symm.surjective.preimage_subset_preimage_iff }\n\n@[simp] lemma _root_.homeomorph.opens_congr_symm (f : α ≃ₜ β) :\n  f.opens_congr.symm = f.symm.opens_congr :=\nrfl\n\ninstance [finite α] : finite (opens α) := finite.of_injective _ set_like.coe_injective\n\nend opens\n\n/-- The open neighborhoods of a point. See also `opens` or `nhds`. -/\nstructure open_nhds_of (x : α) extends opens α :=\n(mem' : x ∈ carrier)\n\nnamespace open_nhds_of\n\nvariables {x : α}\n\nlemma to_opens_injective : injective (to_opens : open_nhds_of x → opens α)\n| ⟨_, _⟩ ⟨_, _⟩ rfl := rfl\n\ninstance : set_like (open_nhds_of x) α :=\n{ coe := λ U, U.1,\n  coe_injective' := set_like.coe_injective.comp to_opens_injective }\n\ninstance can_lift_set : can_lift (set α) (open_nhds_of x) coe (λ s, is_open s ∧ x ∈ s) :=\n⟨λ s hs, ⟨⟨⟨s, hs.1⟩, hs.2⟩, rfl⟩⟩\n\nprotected lemma mem (U : open_nhds_of x) : x ∈ U := U.mem'\nprotected lemma is_open (U : open_nhds_of x) : is_open (U : set α) := U.is_open'\n\ninstance : order_top (open_nhds_of x) :=\n{ top := ⟨⊤, set.mem_univ _⟩,\n  le_top := λ _, subset_univ _ }\n\ninstance : inhabited (open_nhds_of x) := ⟨⊤⟩\n\ninstance : has_inf (open_nhds_of x) := ⟨λ U V, ⟨U.1 ⊓ V.1, U.2, V.2⟩⟩\n\ninstance : has_sup (open_nhds_of x) := ⟨λ U V, ⟨U.1 ⊔ V.1, or.inl U.2⟩⟩\n\ninstance : distrib_lattice (open_nhds_of x) :=\nto_opens_injective.distrib_lattice _ (λ _ _, rfl) (λ _ _, rfl)\n\nlemma basis_nhds : (𝓝 x).has_basis (λ U : open_nhds_of x, true) coe :=\n(nhds_basis_opens x).to_has_basis (λ U hU, ⟨⟨⟨U, hU.2⟩, hU.1⟩, trivial, subset.rfl⟩)\n  (λ U _, ⟨U, ⟨⟨U.mem, U.is_open⟩, subset.rfl⟩⟩)\n\n/-- Preimage of an open neighborhood of `f x` under a continuous map `f` as a `lattice_hom`. -/\ndef comap (f : C(α, β)) (x : α) : lattice_hom (open_nhds_of (f x)) (open_nhds_of x) :=\n{ to_fun := λ U, ⟨opens.comap f U.1, U.mem⟩,\n  map_sup' := λ U V, rfl,\n  map_inf' := λ U V, rfl }\n\nend open_nhds_of\n\nend topological_space\n\nnamespace tactic\n\nnamespace auto_cases\n\n/-- Find an `auto_cases_tac` which matches `topological_space.opens`. -/\nmeta def opens_find_tac : expr → option auto_cases_tac\n| `(topological_space.opens _)     := tac_cases\n| _ := none\n\nend auto_cases\n\n/-- A version of `tactic.auto_cases` that works for `topological_space.opens`. -/\n@[hint_tactic]\nmeta def auto_cases_opens : tactic string :=\nauto_cases tactic.auto_cases.opens_find_tac\n\nend tactic\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/sets/opens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4715811859180772}}
{"text": "import .core\n\nnamespace tts ------------------------------------------------------------------\nnamespace exp ------------------------------------------------------------------\nvariables {V : Type} [decidable_eq V] -- Type of variable names\nvariables {v : V} -- Variable names\nvariables {x y : tagged V} -- Variables\nvariables {ea eb ed ef : exp V} -- Expressions\n\nopen occurs\n\n/-- Get the free variables of an expression -/\ndef fv : exp V → finset (tagged V)\n| (var bound _)  := ∅\n| (var free x)   := {x}\n| (app ef ea)    := fv ef ∪ fv ea\n| (lam _ eb)     := fv eb\n| (let_ _ ed eb) := fv ed ∪ fv eb\n\n@[simp] theorem fv_var_bound : x ∉ fv (var bound y) :=\nfinset.not_mem_empty x\n\n@[simp] theorem fv_var_free : x ∉ fv (var free y) ↔ x ≠ y :=\n⟨finset.not_mem_singleton.mp,\n λ p h, absurd (finset.mem_of_mem_insert_of_ne h p) (finset.not_mem_empty x)⟩\n\n@[simp] theorem fv_app : x ∉ fv (app ef ea) ↔ x ∉ fv ef ∧ x ∉ fv ea :=\nfinset.not_mem_union\n\n@[simp] theorem fv_lam : x ∉ fv (lam v eb) ↔ x ∉ fv eb :=\n⟨by rw fv; exact id, by rw fv; exact id⟩\n\n@[simp] theorem fv_let_ : x ∉ fv (let_ v ed eb) ↔ x ∉ fv ed ∧ x ∉ fv eb :=\nfinset.not_mem_union\n\nend /- namespace -/ exp --------------------------------------------------------\nend /- namespace -/ tts --------------------------------------------------------\n", "meta": {"author": "spl", "repo": "tts", "sha": "b65298fea68ce47c8ed3ba3dbce71c1a20dd3481", "save_path": "github-repos/lean/spl-tts", "path": "github-repos/lean/spl-tts/tts-b65298fea68ce47c8ed3ba3dbce71c1a20dd3481/src/exp/fv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4715599808903446}}
{"text": "import basic\n\nsection\nparameters (α : Type*) (F : Type*)\n\nstructure is_clone (C : set (op F α)) :=\n(proj_closed : ∀ k, (λ (x : F → α), x k) ∈ C)\n(comp_closed : ∀ f (g : F → op F α), f ∈ C → (∀ i, g i ∈ C) → (λ x, f (λ i, g i x)) ∈ C)\n\nparameter (X : set (op F α))\n\n-- The smallest clone containing X\ninductive clo : set (op F α)\n| proj (k) : clo (π k)\n-- there are like two different ways to make this SEGFAULT lmao\n| comp {f} {g : F → op F α} :\n    f ∈ X → (∀ i, clo (g i)) → clo (λ x, f (λ i, g i x))\n\ntheorem clo_contains : X ⊆ clo :=\nbegin\n  intros _ h,\n  apply clo.comp h,\n  apply clo.proj\nend\n\ntheorem clo_is_clone : is_clone clo :=\n{ proj_closed := clo.proj,\n  comp_closed := begin\n    intros _ _ fc gc,\n    induction fc with _ f _ _ _ ih,\n    { apply gc },\n    { apply @clo.comp f,\n      assumption,\n      apply ih }\n  end }\n\ntheorem clo_is_smallest (Y : set (op F α)) :\n  is_clone Y → X ⊆ Y → clo ⊆ Y :=\nbegin\n  intros hY hX f hf,\n  induction hf,\n  { apply hY.proj_closed },\n  { apply hY.comp_closed,\n    apply hX,\n    repeat { assumption } }\nend\n\nend\n\nsection\nparameters {S : signature} (A : algebra S)\n\n-- TODO: relate clone of term operations to term algebra\n\nend", "meta": {"author": "UniversalAlgebra", "repo": "lean-ualib", "sha": "ab9cbddbb5bdf1eeac4b0d5994bd6cad2a3665d4", "save_path": "github-repos/lean/UniversalAlgebra-lean-ualib", "path": "github-repos/lean/UniversalAlgebra-lean-ualib/lean-ualib-ab9cbddbb5bdf1eeac4b0d5994bd6cad2a3665d4/src/clone.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4715188171270417}}
{"text": "import .category\n\nnamespace homotopy_theory.topological_spaces\n\nopen category_theory topological_space\n\n--- The Sierpisnki space. It represents the (contravariant) functor\n--- taking X to its set of open subsets.\ndef sierpinski : Top := Top.mk_ob (ulift Prop)\n\ndef opens_equiv (X : Top) : opens X ≃ (X ⟶ sierpinski) :=\n⟨λ s, Top.mk_hom (λ x, ⟨x ∈ s.val⟩)\n   (continuous.comp continuous_ulift_up (continuous_Prop.mpr s.property)),\n λ f, ⟨λ x, (f x).down, continuous_Prop.mp (by continuity)⟩,\n λ s, by ext; refl,\n λ f, by ext; refl⟩\n\nlemma opens_equiv_nat {X Y : Top} (f : X ⟶ Y) (s : opens Y) :\n  f ≫ opens_equiv Y s = opens_equiv X ⟨f ⁻¹' s, f.2 s.val s.property⟩ :=\nrfl\n\n--- The two-point space with the indiscrete topology. It represents\n--- the (contravariant) functor taking X to its set of all subsets.\ndef prop_indisc := @Top.mk_ob (ulift Prop) ⊤\n\ndef set_equiv (X : Top) : set X ≃ (X ⟶ prop_indisc) :=\n⟨λ s, Top.mk_hom (λ x, ⟨x ∈ s⟩) (by continuity),\n λ f, λ x, (f x).down,\n λ s, by ext; refl,\n λ f, by ext; refl⟩\n\nlemma set_equiv_nat {X Y : Top} (f : X ⟶ Y) (s : set Y) :\n  f ≫ set_equiv Y s = set_equiv X (f ⁻¹' s) :=\nrfl\n\ndef forget_open : sierpinski ⟶ prop_indisc := Top.mk_hom id\n\ninstance forget_open_mono : mono forget_open :=\n⟨λ X f g h, by ext1; apply Top.hom_congr h⟩\n\nlemma forget_open_map {X : Top} (s : opens X) :\n  opens_equiv X s ≫ forget_open = set_equiv X s.val :=\nrfl\n\nend homotopy_theory.topological_spaces\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/homotopy_theory/topological_spaces/sierpinski.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303087996143, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4714984792948999}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.constructions\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Neighborhoods and continuity relative to a subset\n\nThis file defines relative versions\n\n* `nhds_within`           of `nhds`\n* `continuous_on`         of `continuous`\n* `continuous_within_at`  of `continuous_at`\n\nand proves their basic properties, including the relationships between\nthese restricted notions and the corresponding notions for the subtype\nequipped with the subspace topology.\n\n## Notation\n\n* `𝓝 x`: the filter of neighborhoods of a point `x`;\n* `𝓟 s`: the principal filter of a set `s`;\n* `𝓝[s] x`: the filter `nhds_within x s` of neighborhoods of a point `x` within a set `s`.\n\n-/\n\n/-- The \"neighborhood within\" filter. Elements of `𝓝[s] a` are sets containing the\nintersection of `s` and a neighborhood of `a`. -/\ndef nhds_within {α : Type u_1} [topological_space α] (a : α) (s : set α) : filter α :=\n  nhds a ⊓ filter.principal s\n\n@[simp] theorem nhds_bind_nhds_within {α : Type u_1} [topological_space α] {a : α} {s : set α} : (filter.bind (nhds a) fun (x : α) => nhds_within x s) = nhds_within a s :=\n  Eq.trans filter.bind_inf_principal (congr_arg2 has_inf.inf nhds_bind_nhds rfl)\n\n@[simp] theorem eventually_nhds_nhds_within {α : Type u_1} [topological_space α] {a : α} {s : set α} {p : α → Prop} : filter.eventually (fun (y : α) => filter.eventually (fun (x : α) => p x) (nhds_within y s)) (nhds a) ↔\n  filter.eventually (fun (x : α) => p x) (nhds_within a s) :=\n  iff.mp filter.ext_iff nhds_bind_nhds_within (set_of fun (x : α) => p x)\n\ntheorem eventually_nhds_within_iff {α : Type u_1} [topological_space α] {a : α} {s : set α} {p : α → Prop} : filter.eventually (fun (x : α) => p x) (nhds_within a s) ↔ filter.eventually (fun (x : α) => x ∈ s → p x) (nhds a) :=\n  filter.eventually_inf_principal\n\n@[simp] theorem eventually_nhds_within_nhds_within {α : Type u_1} [topological_space α] {a : α} {s : set α} {p : α → Prop} : filter.eventually (fun (y : α) => filter.eventually (fun (x : α) => p x) (nhds_within y s)) (nhds_within a s) ↔\n  filter.eventually (fun (x : α) => p x) (nhds_within a s) := sorry\n\ntheorem nhds_within_eq {α : Type u_1} [topological_space α] (a : α) (s : set α) : nhds_within a s =\n  infi fun (t : set α) => infi fun (H : t ∈ set_of fun (t : set α) => a ∈ t ∧ is_open t) => filter.principal (t ∩ s) :=\n  filter.has_basis.eq_binfi (filter.has_basis.inf_principal (nhds_basis_opens a) s)\n\ntheorem nhds_within_univ {α : Type u_1} [topological_space α] (a : α) : nhds_within a set.univ = nhds a :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (nhds_within a set.univ = nhds a)) (nhds_within.equations._eqn_1 a set.univ)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (nhds a ⊓ filter.principal set.univ = nhds a)) filter.principal_univ))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (nhds a ⊓ ⊤ = nhds a)) inf_top_eq)) (Eq.refl (nhds a))))\n\ntheorem nhds_within_has_basis {α : Type u_1} {β : Type u_2} [topological_space α] {p : β → Prop} {s : β → set α} {a : α} (h : filter.has_basis (nhds a) p s) (t : set α) : filter.has_basis (nhds_within a t) p fun (i : β) => s i ∩ t :=\n  filter.has_basis.inf_principal h t\n\ntheorem nhds_within_basis_open {α : Type u_1} [topological_space α] (a : α) (t : set α) : filter.has_basis (nhds_within a t) (fun (u : set α) => a ∈ u ∧ is_open u) fun (u : set α) => u ∩ t :=\n  nhds_within_has_basis (nhds_basis_opens a) t\n\ntheorem mem_nhds_within {α : Type u_1} [topological_space α] {t : set α} {a : α} {s : set α} : t ∈ nhds_within a s ↔ ∃ (u : set α), is_open u ∧ a ∈ u ∧ u ∩ s ⊆ t := sorry\n\ntheorem mem_nhds_within_iff_exists_mem_nhds_inter {α : Type u_1} [topological_space α] {t : set α} {a : α} {s : set α} : t ∈ nhds_within a s ↔ ∃ (u : set α), ∃ (H : u ∈ nhds a), u ∩ s ⊆ t :=\n  filter.has_basis.mem_iff (nhds_within_has_basis (filter.basis_sets (nhds a)) s)\n\ntheorem diff_mem_nhds_within_compl {X : Type u_1} [topological_space X] {x : X} {s : set X} (hs : s ∈ nhds x) (t : set X) : s \\ t ∈ nhds_within x (tᶜ) :=\n  filter.diff_mem_inf_principal_compl hs t\n\ntheorem nhds_of_nhds_within_of_nhds {α : Type u_1} [topological_space α] {s : set α} {t : set α} {a : α} (h1 : s ∈ nhds a) (h2 : t ∈ nhds_within a s) : t ∈ nhds a := sorry\n\ntheorem mem_nhds_within_of_mem_nhds {α : Type u_1} [topological_space α] {s : set α} {t : set α} {a : α} (h : s ∈ nhds a) : s ∈ nhds_within a t :=\n  filter.mem_inf_sets_of_left h\n\ntheorem self_mem_nhds_within {α : Type u_1} [topological_space α] {a : α} {s : set α} : s ∈ nhds_within a s :=\n  filter.mem_inf_sets_of_right (filter.mem_principal_self s)\n\ntheorem inter_mem_nhds_within {α : Type u_1} [topological_space α] (s : set α) {t : set α} {a : α} (h : t ∈ nhds a) : s ∩ t ∈ nhds_within a s :=\n  filter.inter_mem_sets (filter.mem_inf_sets_of_right (filter.mem_principal_self s)) (filter.mem_inf_sets_of_left h)\n\ntheorem nhds_within_mono {α : Type u_1} [topological_space α] (a : α) {s : set α} {t : set α} (h : s ⊆ t) : nhds_within a s ≤ nhds_within a t :=\n  inf_le_inf_left (nhds a) (iff.mpr filter.principal_mono h)\n\ntheorem pure_le_nhds_within {α : Type u_1} [topological_space α] {a : α} {s : set α} (ha : a ∈ s) : pure a ≤ nhds_within a s :=\n  le_inf (pure_le_nhds a) (iff.mpr filter.le_principal_iff ha)\n\ntheorem mem_of_mem_nhds_within {α : Type u_1} [topological_space α] {a : α} {s : set α} {t : set α} (ha : a ∈ s) (ht : t ∈ nhds_within a s) : a ∈ t :=\n  pure_le_nhds_within ha ht\n\ntheorem filter.eventually.self_of_nhds_within {α : Type u_1} [topological_space α] {p : α → Prop} {s : set α} {x : α} (h : filter.eventually (fun (y : α) => p y) (nhds_within x s)) (hx : x ∈ s) : p x :=\n  mem_of_mem_nhds_within hx h\n\ntheorem tendsto_const_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] {l : filter β} {s : set α} {a : α} (ha : a ∈ s) : filter.tendsto (fun (x : β) => a) l (nhds_within a s) :=\n  filter.tendsto.mono_right filter.tendsto_const_pure (pure_le_nhds_within ha)\n\ntheorem nhds_within_restrict'' {α : Type u_1} [topological_space α] {a : α} (s : set α) {t : set α} (h : t ∈ nhds_within a s) : nhds_within a s = nhds_within a (s ∩ t) :=\n  le_antisymm (le_inf inf_le_left (iff.mpr filter.le_principal_iff (filter.inter_mem_sets self_mem_nhds_within h)))\n    (inf_le_inf_left (nhds a) (iff.mpr filter.principal_mono (set.inter_subset_left s t)))\n\ntheorem nhds_within_restrict' {α : Type u_1} [topological_space α] {a : α} (s : set α) {t : set α} (h : t ∈ nhds a) : nhds_within a s = nhds_within a (s ∩ t) :=\n  nhds_within_restrict'' s (filter.mem_inf_sets_of_left h)\n\ntheorem nhds_within_restrict {α : Type u_1} [topological_space α] {a : α} (s : set α) {t : set α} (h₀ : a ∈ t) (h₁ : is_open t) : nhds_within a s = nhds_within a (s ∩ t) :=\n  nhds_within_restrict' s (mem_nhds_sets h₁ h₀)\n\ntheorem nhds_within_le_of_mem {α : Type u_1} [topological_space α] {a : α} {s : set α} {t : set α} (h : s ∈ nhds_within a t) : nhds_within a t ≤ nhds_within a s := sorry\n\ntheorem nhds_within_eq_nhds_within {α : Type u_1} [topological_space α] {a : α} {s : set α} {t : set α} {u : set α} (h₀ : a ∈ s) (h₁ : is_open s) (h₂ : t ∩ s = u ∩ s) : nhds_within a t = nhds_within a u := sorry\n\ntheorem nhds_within_eq_of_open {α : Type u_1} [topological_space α] {a : α} {s : set α} (h₀ : a ∈ s) (h₁ : is_open s) : nhds_within a s = nhds a :=\n  iff.mpr inf_eq_left (iff.mpr filter.le_principal_iff (mem_nhds_sets h₁ h₀))\n\n@[simp] theorem nhds_within_empty {α : Type u_1} [topological_space α] (a : α) : nhds_within a ∅ = ⊥ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (nhds_within a ∅ = ⊥)) (nhds_within.equations._eqn_1 a ∅)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (nhds a ⊓ filter.principal ∅ = ⊥)) filter.principal_empty))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (nhds a ⊓ ⊥ = ⊥)) inf_bot_eq)) (Eq.refl ⊥)))\n\ntheorem nhds_within_union {α : Type u_1} [topological_space α] (a : α) (s : set α) (t : set α) : nhds_within a (s ∪ t) = nhds_within a s ⊔ nhds_within a t := sorry\n\ntheorem nhds_within_inter {α : Type u_1} [topological_space α] (a : α) (s : set α) (t : set α) : nhds_within a (s ∩ t) = nhds_within a s ⊓ nhds_within a t := sorry\n\ntheorem nhds_within_inter' {α : Type u_1} [topological_space α] (a : α) (s : set α) (t : set α) : nhds_within a (s ∩ t) = nhds_within a s ⊓ filter.principal t := sorry\n\n@[simp] theorem nhds_within_singleton {α : Type u_1} [topological_space α] (a : α) : nhds_within a (singleton a) = pure a := sorry\n\n@[simp] theorem nhds_within_insert {α : Type u_1} [topological_space α] (a : α) (s : set α) : nhds_within a (insert a s) = pure a ⊔ nhds_within a s := sorry\n\ntheorem mem_nhds_within_insert {α : Type u_1} [topological_space α] {a : α} {s : set α} {t : set α} : t ∈ nhds_within a (insert a s) ↔ a ∈ t ∧ t ∈ nhds_within a s := sorry\n\ntheorem insert_mem_nhds_within_insert {α : Type u_1} [topological_space α] {a : α} {s : set α} {t : set α} (h : t ∈ nhds_within a s) : insert a t ∈ nhds_within a (insert a s) := sorry\n\ntheorem nhds_within_prod_eq {α : Type u_1} [topological_space α] {β : Type u_2} [topological_space β] (a : α) (b : β) (s : set α) (t : set β) : nhds_within (a, b) (set.prod s t) = filter.prod (nhds_within a s) (nhds_within b t) := sorry\n\ntheorem nhds_within_prod {α : Type u_1} [topological_space α] {β : Type u_2} [topological_space β] {s : set α} {u : set α} {t : set β} {v : set β} {a : α} {b : β} (hu : u ∈ nhds_within a s) (hv : v ∈ nhds_within b t) : set.prod u v ∈ nhds_within (a, b) (set.prod s t) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (set.prod u v ∈ nhds_within (a, b) (set.prod s t))) (nhds_within_prod_eq a b s t)))\n    (filter.prod_mem_prod hu hv)\n\ntheorem tendsto_if_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] {f : α → β} {g : α → β} {p : α → Prop} [decidable_pred p] {a : α} {s : set α} {l : filter β} (h₀ : filter.tendsto f (nhds_within a (s ∩ p)) l) (h₁ : filter.tendsto g (nhds_within a (s ∩ set_of fun (x : α) => ¬p x)) l) : filter.tendsto (fun (x : α) => ite (p x) (f x) (g x)) (nhds_within a s) l := sorry\n\ntheorem map_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] (f : α → β) (a : α) (s : set α) : filter.map f (nhds_within a s) =\n  infi\n    fun (t : set α) => infi fun (H : t ∈ set_of fun (t : set α) => a ∈ t ∧ is_open t) => filter.principal (f '' (t ∩ s)) :=\n  filter.has_basis.eq_binfi (filter.has_basis.map f (nhds_within_basis_open a s))\n\ntheorem tendsto_nhds_within_mono_left {α : Type u_1} {β : Type u_2} [topological_space α] {f : α → β} {a : α} {s : set α} {t : set α} {l : filter β} (hst : s ⊆ t) (h : filter.tendsto f (nhds_within a t) l) : filter.tendsto f (nhds_within a s) l :=\n  filter.tendsto.mono_left h (nhds_within_mono a hst)\n\ntheorem tendsto_nhds_within_mono_right {α : Type u_1} {β : Type u_2} [topological_space α] {f : β → α} {l : filter β} {a : α} {s : set α} {t : set α} (hst : s ⊆ t) (h : filter.tendsto f l (nhds_within a s)) : filter.tendsto f l (nhds_within a t) :=\n  filter.tendsto.mono_right h (nhds_within_mono a hst)\n\ntheorem tendsto_nhds_within_of_tendsto_nhds {α : Type u_1} {β : Type u_2} [topological_space α] {f : α → β} {a : α} {s : set α} {l : filter β} (h : filter.tendsto f (nhds a) l) : filter.tendsto f (nhds_within a s) l :=\n  filter.tendsto.mono_left h inf_le_left\n\ntheorem principal_subtype {α : Type u_1} (s : set α) (t : set (Subtype fun (x : α) => x ∈ s)) : filter.principal t = filter.comap coe (filter.principal (coe '' t)) := sorry\n\ntheorem mem_closure_iff_nhds_within_ne_bot {α : Type u_1} [topological_space α] {s : set α} {x : α} : x ∈ closure s ↔ filter.ne_bot (nhds_within x s) :=\n  mem_closure_iff_cluster_pt\n\ntheorem nhds_within_ne_bot_of_mem {α : Type u_1} [topological_space α] {s : set α} {x : α} (hx : x ∈ s) : filter.ne_bot (nhds_within x s) :=\n  iff.mp mem_closure_iff_nhds_within_ne_bot (subset_closure hx)\n\ntheorem is_closed.mem_of_nhds_within_ne_bot {α : Type u_1} [topological_space α] {s : set α} (hs : is_closed s) {x : α} (hx : filter.ne_bot (nhds_within x s)) : x ∈ s := sorry\n\ntheorem dense_range.nhds_within_ne_bot {α : Type u_1} [topological_space α] {ι : Type u_2} {f : ι → α} (h : dense_range f) (x : α) : filter.ne_bot (nhds_within x (set.range f)) :=\n  iff.mp mem_closure_iff_cluster_pt (h x)\n\ntheorem eventually_eq_nhds_within_iff {α : Type u_1} {β : Type u_2} [topological_space α] {f : α → β} {g : α → β} {s : set α} {a : α} : filter.eventually_eq (nhds_within a s) f g ↔ filter.eventually (fun (x : α) => x ∈ s → f x = g x) (nhds a) :=\n  filter.mem_inf_principal\n\ntheorem eventually_eq_nhds_within_of_eq_on {α : Type u_1} {β : Type u_2} [topological_space α] {f : α → β} {g : α → β} {s : set α} {a : α} (h : set.eq_on f g s) : filter.eventually_eq (nhds_within a s) f g :=\n  filter.mem_inf_sets_of_right h\n\ntheorem set.eq_on.eventually_eq_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] {f : α → β} {g : α → β} {s : set α} {a : α} (h : set.eq_on f g s) : filter.eventually_eq (nhds_within a s) f g :=\n  eventually_eq_nhds_within_of_eq_on h\n\ntheorem tendsto_nhds_within_congr {α : Type u_1} {β : Type u_2} [topological_space α] {f : α → β} {g : α → β} {s : set α} {a : α} {l : filter β} (hfg : ∀ (x : α), x ∈ s → f x = g x) (hf : filter.tendsto f (nhds_within a s) l) : filter.tendsto g (nhds_within a s) l :=\n  iff.mp (filter.tendsto_congr' (eventually_eq_nhds_within_of_eq_on hfg)) hf\n\ntheorem eventually_nhds_with_of_forall {α : Type u_1} [topological_space α] {s : set α} {a : α} {p : α → Prop} (h : ∀ (x : α), x ∈ s → p x) : filter.eventually (fun (x : α) => p x) (nhds_within a s) :=\n  filter.mem_inf_sets_of_right h\n\ntheorem tendsto_nhds_within_of_tendsto_nhds_of_eventually_within {α : Type u_1} [topological_space α] {β : Type u_2} {a : α} {l : filter β} {s : set α} (f : β → α) (h1 : filter.tendsto f l (nhds a)) (h2 : filter.eventually (fun (x : β) => f x ∈ s) l) : filter.tendsto f l (nhds_within a s) :=\n  iff.mpr filter.tendsto_inf { left := h1, right := iff.mpr filter.tendsto_principal h2 }\n\ntheorem filter.eventually_eq.eq_of_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] {s : set α} {f : α → β} {g : α → β} {a : α} (h : filter.eventually_eq (nhds_within a s) f g) (hmem : a ∈ s) : f a = g a :=\n  filter.eventually.self_of_nhds_within h hmem\n\ntheorem eventually_nhds_within_of_eventually_nhds {α : Type u_1} [topological_space α] {s : set α} {a : α} {p : α → Prop} (h : filter.eventually (fun (x : α) => p x) (nhds a)) : filter.eventually (fun (x : α) => p x) (nhds_within a s) :=\n  mem_nhds_within_of_mem_nhds h\n\n/-!\n### `nhds_within` and subtypes\n-/\n\ntheorem mem_nhds_within_subtype {α : Type u_1} [topological_space α] {s : set α} {a : Subtype fun (x : α) => x ∈ s} {t : set (Subtype fun (x : α) => x ∈ s)} {u : set (Subtype fun (x : α) => x ∈ s)} : t ∈ nhds_within a u ↔ t ∈ filter.comap coe (nhds_within (↑a) (coe '' u)) := sorry\n\ntheorem nhds_within_subtype {α : Type u_1} [topological_space α] (s : set α) (a : Subtype fun (x : α) => x ∈ s) (t : set (Subtype fun (x : α) => x ∈ s)) : nhds_within a t = filter.comap coe (nhds_within (↑a) (coe '' t)) :=\n  filter.ext fun (u : set (Subtype fun (x : α) => x ∈ s)) => mem_nhds_within_subtype\n\ntheorem nhds_within_eq_map_subtype_coe {α : Type u_1} [topological_space α] {s : set α} {a : α} (h : a ∈ s) : nhds_within a s = filter.map coe (nhds { val := a, property := h }) := sorry\n\ntheorem tendsto_nhds_within_iff_subtype {α : Type u_1} {β : Type u_2} [topological_space α] {s : set α} {a : α} (h : a ∈ s) (f : α → β) (l : filter β) : filter.tendsto f (nhds_within a s) l ↔ filter.tendsto (set.restrict f s) (nhds { val := a, property := h }) l := sorry\n\n/-- A function between topological spaces is continuous at a point `x₀` within a subset `s`\nif `f x` tends to `f x₀` when `x` tends to `x₀` while staying within `s`. -/\ndef continuous_within_at {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (f : α → β) (s : set α) (x : α) :=\n  filter.tendsto f (nhds_within x s) (nhds (f x))\n\n/-- If a function is continuous within `s` at `x`, then it tends to `f x` within `s` by definition.\nWe register this fact for use with the dot notation, especially to use `tendsto.comp` as\n`continuous_within_at.comp` will have a different meaning. -/\ntheorem continuous_within_at.tendsto {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} (h : continuous_within_at f s x) : filter.tendsto f (nhds_within x s) (nhds (f x)) :=\n  h\n\n/-- A function between topological spaces is continuous on a subset `s`\nwhen it's continuous at every point of `s` within `s`. -/\ndef continuous_on {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (f : α → β) (s : set α) :=\n  ∀ (x : α), x ∈ s → continuous_within_at f s x\n\ntheorem continuous_on.continuous_within_at {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} (hf : continuous_on f s) (hx : x ∈ s) : continuous_within_at f s x :=\n  hf x hx\n\ntheorem continuous_within_at_univ {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (f : α → β) (x : α) : continuous_within_at f set.univ x ↔ continuous_at f x := sorry\n\ntheorem continuous_within_at_iff_continuous_at_restrict {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (f : α → β) {x : α} {s : set α} (h : x ∈ s) : continuous_within_at f s x ↔ continuous_at (set.restrict f s) { val := x, property := h } :=\n  tendsto_nhds_within_iff_subtype h f (nhds (f x))\n\ntheorem continuous_within_at.tendsto_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {x : α} {s : set α} {t : set β} (h : continuous_within_at f s x) (ht : set.maps_to f s t) : filter.tendsto f (nhds_within x s) (nhds_within (f x) t) :=\n  iff.mpr filter.tendsto_inf\n    { left := h,\n      right := iff.mpr filter.tendsto_principal (filter.mem_inf_sets_of_right (iff.mpr filter.mem_principal_sets ht)) }\n\ntheorem continuous_within_at.tendsto_nhds_within_image {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {x : α} {s : set α} (h : continuous_within_at f s x) : filter.tendsto f (nhds_within x s) (nhds_within (f x) (f '' s)) :=\n  continuous_within_at.tendsto_nhds_within h (set.maps_to_image f s)\n\ntheorem continuous_within_at.prod_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] {f : α → γ} {g : β → δ} {s : set α} {t : set β} {x : α} {y : β} (hf : continuous_within_at f s x) (hg : continuous_within_at g t y) : continuous_within_at (prod.map f g) (set.prod s t) (x, y) := sorry\n\ntheorem continuous_on_iff {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} : continuous_on f s ↔\n  ∀ (x : α), x ∈ s → ∀ (t : set β), is_open t → f x ∈ t → ∃ (u : set α), is_open u ∧ x ∈ u ∧ u ∩ s ⊆ f ⁻¹' t := sorry\n\ntheorem continuous_on_iff_continuous_restrict {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} : continuous_on f s ↔ continuous (set.restrict f s) := sorry\n\ntheorem continuous_on_iff' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} : continuous_on f s ↔ ∀ (t : set β), is_open t → ∃ (u : set α), is_open u ∧ f ⁻¹' t ∩ s = u ∩ s := sorry\n\ntheorem continuous_on_iff_is_closed {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} : continuous_on f s ↔ ∀ (t : set β), is_closed t → ∃ (u : set α), is_closed u ∧ f ⁻¹' t ∩ s = u ∩ s := sorry\n\ntheorem continuous_on.prod_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [topological_space α] [topological_space β] [topological_space γ] [topological_space δ] {f : α → γ} {g : β → δ} {s : set α} {t : set β} (hf : continuous_on f s) (hg : continuous_on g t) : continuous_on (prod.map f g) (set.prod s t) := sorry\n\ntheorem continuous_on_empty {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (f : α → β) : continuous_on f ∅ :=\n  fun (x : α) => false.elim\n\ntheorem nhds_within_le_comap {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {x : α} {s : set α} {f : α → β} (ctsf : continuous_within_at f s x) : nhds_within x s ≤ filter.comap f (nhds_within (f x) (f '' s)) :=\n  iff.mp filter.map_le_iff_le_comap (continuous_within_at.tendsto_nhds_within_image ctsf)\n\ntheorem continuous_within_at_iff_ptendsto_res {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (f : α → β) {x : α} {s : set α} : continuous_within_at f s x ↔ filter.ptendsto (pfun.res f s) (nhds x) (nhds (f x)) :=\n  filter.tendsto_iff_ptendsto (nhds x) (nhds (f x)) s f\n\ntheorem continuous_iff_continuous_on_univ {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} : continuous f ↔ continuous_on f set.univ := sorry\n\ntheorem continuous_within_at.mono {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} {x : α} (h : continuous_within_at f t x) (hs : s ⊆ t) : continuous_within_at f s x :=\n  filter.tendsto.mono_left h (nhds_within_mono x hs)\n\ntheorem continuous_within_at.mono_of_mem {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} {x : α} (h : continuous_within_at f t x) (hs : t ∈ nhds_within x s) : continuous_within_at f s x :=\n  filter.tendsto.mono_left h (nhds_within_le_of_mem hs)\n\ntheorem continuous_within_at_inter' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} {x : α} (h : t ∈ nhds_within x s) : continuous_within_at f (s ∩ t) x ↔ continuous_within_at f s x := sorry\n\ntheorem continuous_within_at_inter {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} {x : α} (h : t ∈ nhds x) : continuous_within_at f (s ∩ t) x ↔ continuous_within_at f s x := sorry\n\ntheorem continuous_within_at_union {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} {x : α} : continuous_within_at f (s ∪ t) x ↔ continuous_within_at f s x ∧ continuous_within_at f t x := sorry\n\ntheorem continuous_within_at.union {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} {x : α} (hs : continuous_within_at f s x) (ht : continuous_within_at f t x) : continuous_within_at f (s ∪ t) x :=\n  iff.mpr continuous_within_at_union { left := hs, right := ht }\n\ntheorem continuous_within_at.mem_closure_image {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} (h : continuous_within_at f s x) (hx : x ∈ closure s) : f x ∈ closure (f '' s) :=\n  mem_closure_of_tendsto h (filter.mem_sets_of_superset self_mem_nhds_within (set.subset_preimage_image f s))\n\ntheorem continuous_within_at.mem_closure {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} {A : set β} (h : continuous_within_at f s x) (hx : x ∈ closure s) (hA : s ⊆ f ⁻¹' A) : f x ∈ closure A :=\n  closure_mono (iff.mpr set.image_subset_iff hA) (continuous_within_at.mem_closure_image h hx)\n\ntheorem continuous_within_at.image_closure {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} (hf : ∀ (x : α), x ∈ closure s → continuous_within_at f s x) : f '' closure s ⊆ closure (f '' s) := sorry\n\n@[simp] theorem continuous_within_at_singleton {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {x : α} : continuous_within_at f (singleton x) x := sorry\n\n@[simp] theorem continuous_within_at_insert_self {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {x : α} {s : set α} : continuous_within_at f (insert x s) x ↔ continuous_within_at f s x := sorry\n\ntheorem continuous_within_at.insert_self {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {x : α} {s : set α} : continuous_within_at f s x → continuous_within_at f (insert x s) x :=\n  iff.mpr continuous_within_at_insert_self\n\ntheorem continuous_within_at.diff_iff {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} {x : α} (ht : continuous_within_at f t x) : continuous_within_at f (s \\ t) x ↔ continuous_within_at f s x := sorry\n\n@[simp] theorem continuous_within_at_diff_self {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} : continuous_within_at f (s \\ singleton x) x ↔ continuous_within_at f s x :=\n  continuous_within_at.diff_iff continuous_within_at_singleton\n\ntheorem is_open_map.continuous_on_image_of_left_inv_on {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} (h : is_open_map (set.restrict f s)) {finv : β → α} (hleft : set.left_inv_on finv f s) : continuous_on finv (f '' s) := sorry\n\ntheorem is_open_map.continuous_on_range_of_left_inverse {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} (hf : is_open_map f) {finv : β → α} (hleft : function.left_inverse finv f) : continuous_on finv (set.range f) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (continuous_on finv (set.range f))) (Eq.symm set.image_univ)))\n    (is_open_map.continuous_on_image_of_left_inv_on (is_open_map.restrict hf is_open_univ)\n      fun (x : α) (_x : x ∈ set.univ) => hleft x)\n\ntheorem continuous_on.congr_mono {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {g : α → β} {s : set α} {s₁ : set α} (h : continuous_on f s) (h' : set.eq_on g f s₁) (h₁ : s₁ ⊆ s) : continuous_on g s₁ := sorry\n\ntheorem continuous_on.congr {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {g : α → β} {s : set α} (h : continuous_on f s) (h' : set.eq_on g f s) : continuous_on g s :=\n  continuous_on.congr_mono h h' (set.subset.refl s)\n\ntheorem continuous_on_congr {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {g : α → β} {s : set α} (h' : set.eq_on g f s) : continuous_on g s ↔ continuous_on f s :=\n  { mp := fun (h : continuous_on g s) => continuous_on.congr h (set.eq_on.symm h'),\n    mpr := fun (h : continuous_on f s) => continuous_on.congr h h' }\n\ntheorem continuous_at.continuous_within_at {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} (h : continuous_at f x) : continuous_within_at f s x :=\n  continuous_within_at.mono (iff.mpr (continuous_within_at_univ f x) h) (set.subset_univ s)\n\ntheorem continuous_within_at.continuous_at {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} (h : continuous_within_at f s x) (hs : s ∈ nhds x) : continuous_at f x := sorry\n\ntheorem continuous_on.continuous_at {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} (h : continuous_on f s) (hx : s ∈ nhds x) : continuous_at f x :=\n  continuous_within_at.continuous_at (h x (mem_of_nhds hx)) hx\n\ntheorem continuous_within_at.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} {s : set α} {t : set β} {x : α} (hg : continuous_within_at g t (f x)) (hf : continuous_within_at f s x) (h : s ⊆ f ⁻¹' t) : continuous_within_at (g ∘ f) s x := sorry\n\ntheorem continuous_within_at.comp' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} {s : set α} {t : set β} {x : α} (hg : continuous_within_at g t (f x)) (hf : continuous_within_at f s x) : continuous_within_at (g ∘ f) (s ∩ f ⁻¹' t) x :=\n  continuous_within_at.comp hg (continuous_within_at.mono hf (set.inter_subset_left s (f ⁻¹' t)))\n    (set.inter_subset_right s (f ⁻¹' t))\n\ntheorem continuous_on.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} {s : set α} {t : set β} (hg : continuous_on g t) (hf : continuous_on f s) (h : s ⊆ f ⁻¹' t) : continuous_on (g ∘ f) s :=\n  fun (x : α) (hx : x ∈ s) => continuous_within_at.comp (hg (f x) (h hx)) (hf x hx) h\n\ntheorem continuous_on.mono {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set α} (hf : continuous_on f s) (h : t ⊆ s) : continuous_on f t :=\n  fun (x : α) (hx : x ∈ t) => filter.tendsto.mono_left (hf x (h hx)) (nhds_within_mono x h)\n\ntheorem continuous_on.comp' {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} {s : set α} {t : set β} (hg : continuous_on g t) (hf : continuous_on f s) : continuous_on (g ∘ f) (s ∩ f ⁻¹' t) :=\n  continuous_on.comp hg (continuous_on.mono hf (set.inter_subset_left s (f ⁻¹' t))) (set.inter_subset_right s (f ⁻¹' t))\n\ntheorem continuous.continuous_on {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} (h : continuous f) : continuous_on f s :=\n  continuous_on.mono (eq.mp (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_iff_continuous_on_univ)) h)\n    (set.subset_univ s)\n\ntheorem continuous.continuous_within_at {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} (h : continuous f) : continuous_within_at f s x :=\n  continuous_at.continuous_within_at (continuous.continuous_at h)\n\ntheorem continuous.comp_continuous_on {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} {s : set α} (hg : continuous g) (hf : continuous_on f s) : continuous_on (g ∘ f) s :=\n  continuous_on.comp (continuous.continuous_on hg) hf set.subset_preimage_univ\n\ntheorem continuous_on.comp_continuous {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} {s : set β} (hg : continuous_on g s) (hf : continuous f) (hs : ∀ (x : α), f x ∈ s) : continuous (g ∘ f) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (continuous (g ∘ f))) (propext continuous_iff_continuous_on_univ)))\n    (continuous_on.comp hg (eq.mp (Eq._oldrec (Eq.refl (continuous f)) (propext continuous_iff_continuous_on_univ)) hf)\n      fun (x : α) (_x : x ∈ set.univ) => hs x)\n\ntheorem continuous_within_at.preimage_mem_nhds_within {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {x : α} {s : set α} {t : set β} (h : continuous_within_at f s x) (ht : t ∈ nhds (f x)) : f ⁻¹' t ∈ nhds_within x s :=\n  h ht\n\ntheorem continuous_within_at.preimage_mem_nhds_within' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {x : α} {s : set α} {t : set β} (h : continuous_within_at f s x) (ht : t ∈ nhds_within (f x) (f '' s)) : f ⁻¹' t ∈ nhds_within x s := sorry\n\ntheorem continuous_within_at.congr_of_eventually_eq {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {f₁ : α → β} {s : set α} {x : α} (h : continuous_within_at f s x) (h₁ : filter.eventually_eq (nhds_within x s) f₁ f) (hx : f₁ x = f x) : continuous_within_at f₁ s x := sorry\n\ntheorem continuous_within_at.congr {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {f₁ : α → β} {s : set α} {x : α} (h : continuous_within_at f s x) (h₁ : ∀ (y : α), y ∈ s → f₁ y = f y) (hx : f₁ x = f x) : continuous_within_at f₁ s x :=\n  continuous_within_at.congr_of_eventually_eq h (filter.mem_sets_of_superset self_mem_nhds_within h₁) hx\n\ntheorem continuous_within_at.congr_mono {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {g : α → β} {s : set α} {s₁ : set α} {x : α} (h : continuous_within_at f s x) (h' : set.eq_on g f s₁) (h₁ : s₁ ⊆ s) (hx : g x = f x) : continuous_within_at g s₁ x :=\n  continuous_within_at.congr (continuous_within_at.mono h h₁) h' hx\n\ntheorem continuous_on_const {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {s : set α} {c : β} : continuous_on (fun (x : α) => c) s :=\n  continuous.continuous_on continuous_const\n\ntheorem continuous_within_at_const {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {b : β} {s : set α} {x : α} : continuous_within_at (fun (_x : α) => b) s x :=\n  continuous.continuous_within_at continuous_const\n\ntheorem continuous_on_id {α : Type u_1} [topological_space α] {s : set α} : continuous_on id s :=\n  continuous.continuous_on continuous_id\n\ntheorem continuous_within_at_id {α : Type u_1} [topological_space α] {s : set α} {x : α} : continuous_within_at id s x :=\n  continuous.continuous_within_at continuous_id\n\ntheorem continuous_on_open_iff {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} (hs : is_open s) : continuous_on f s ↔ ∀ (t : set β), is_open t → is_open (s ∩ f ⁻¹' t) := sorry\n\ntheorem continuous_on.preimage_open_of_open {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set β} (hf : continuous_on f s) (hs : is_open s) (ht : is_open t) : is_open (s ∩ f ⁻¹' t) :=\n  iff.mp (continuous_on_open_iff hs) hf t ht\n\ntheorem continuous_on.preimage_closed_of_closed {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set β} (hf : continuous_on f s) (hs : is_closed s) (ht : is_closed t) : is_closed (s ∩ f ⁻¹' t) := sorry\n\ntheorem continuous_on.preimage_interior_subset_interior_preimage {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {t : set β} (hf : continuous_on f s) (hs : is_open s) : s ∩ f ⁻¹' interior t ⊆ s ∩ interior (f ⁻¹' t) := sorry\n\ntheorem continuous_on_of_locally_continuous_on {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} (h : ∀ (x : α), x ∈ s → ∃ (t : set α), is_open t ∧ x ∈ t ∧ continuous_on f (s ∩ t)) : continuous_on f s := sorry\n\ntheorem continuous_on_open_of_generate_from {α : Type u_1} [topological_space α] {β : Type u_2} {s : set α} {T : set (set β)} {f : α → β} (hs : is_open s) (h : ∀ (t : set β), t ∈ T → is_open (s ∩ f ⁻¹' t)) : continuous_on f s := sorry\n\ntheorem continuous_within_at.prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {f : α → β} {g : α → γ} {s : set α} {x : α} (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) : continuous_within_at (fun (x : α) => (f x, g x)) s x :=\n  filter.tendsto.prod_mk_nhds hf hg\n\ntheorem continuous_on.prod {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {f : α → β} {g : α → γ} {s : set α} (hf : continuous_on f s) (hg : continuous_on g s) : continuous_on (fun (x : α) => (f x, g x)) s :=\n  fun (x : α) (hx : x ∈ s) => continuous_within_at.prod (hf x hx) (hg x hx)\n\ntheorem inducing.continuous_on_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {f : α → β} {g : β → γ} (hg : inducing g) {s : set α} : continuous_on f s ↔ continuous_on (g ∘ f) s := sorry\n\ntheorem embedding.continuous_on_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {f : α → β} {g : β → γ} (hg : embedding g) {s : set α} : continuous_on f s ↔ continuous_on (g ∘ f) s :=\n  inducing.continuous_on_iff (embedding.to_inducing hg)\n\ntheorem continuous_within_at_of_not_mem_closure {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} {s : set α} {x : α} : ¬x ∈ closure s → continuous_within_at f s x := sorry\n\ntheorem continuous_on_if' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {s : set α} {p : α → Prop} {f : α → β} {g : α → β} {h : (a : α) → Decidable (p a)} (hpf : ∀ (a : α),\n  a ∈ s ∩ frontier (set_of fun (a : α) => p a) →\n    filter.tendsto f (nhds_within a (s ∩ set_of fun (a : α) => p a)) (nhds (ite (p a) (f a) (g a)))) (hpg : ∀ (a : α),\n  a ∈ s ∩ frontier (set_of fun (a : α) => p a) →\n    filter.tendsto g (nhds_within a (s ∩ set_of fun (a : α) => ¬p a)) (nhds (ite (p a) (f a) (g a)))) (hf : continuous_on f (s ∩ set_of fun (a : α) => p a)) (hg : continuous_on g (s ∩ set_of fun (a : α) => ¬p a)) : continuous_on (fun (a : α) => ite (p a) (f a) (g a)) s := sorry\n\ntheorem continuous_on_if {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {p : α → Prop} {h : (a : α) → Decidable (p a)} {s : set α} {f : α → β} {g : α → β} (hp : ∀ (a : α), a ∈ s ∩ frontier (set_of fun (a : α) => p a) → f a = g a) (hf : continuous_on f (s ∩ closure (set_of fun (a : α) => p a))) (hg : continuous_on g (s ∩ closure (set_of fun (a : α) => ¬p a))) : continuous_on (fun (a : α) => ite (p a) (f a) (g a)) s := sorry\n\ntheorem continuous_if' {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {p : α → Prop} {f : α → β} {g : α → β} {h : (a : α) → Decidable (p a)} (hpf : ∀ (a : α),\n  a ∈ frontier (set_of fun (x : α) => p x) →\n    filter.tendsto f (nhds_within a (set_of fun (x : α) => p x)) (nhds (ite (p a) (f a) (g a)))) (hpg : ∀ (a : α),\n  a ∈ frontier (set_of fun (x : α) => p x) →\n    filter.tendsto g (nhds_within a (set_of fun (x : α) => ¬p x)) (nhds (ite (p a) (f a) (g a)))) (hf : continuous_on f (set_of fun (x : α) => p x)) (hg : continuous_on g (set_of fun (x : α) => ¬p x)) : continuous fun (a : α) => ite (p a) (f a) (g a) := sorry\n\ntheorem continuous_on_fst {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {s : set (α × β)} : continuous_on prod.fst s :=\n  continuous.continuous_on continuous_fst\n\ntheorem continuous_within_at_fst {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {s : set (α × β)} {p : α × β} : continuous_within_at prod.fst s p :=\n  continuous.continuous_within_at continuous_fst\n\ntheorem continuous_on_snd {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {s : set (α × β)} : continuous_on prod.snd s :=\n  continuous.continuous_on continuous_snd\n\ntheorem continuous_within_at_snd {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {s : set (α × β)} {p : α × β} : continuous_within_at prod.snd s p :=\n  continuous.continuous_within_at continuous_snd\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/continuous_on.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.47144277970753024}}
{"text": "import Cat.Fam.Comp\n\n\n\n/-! # Equivalence for category arrows in terms of the corresponding setoid -/\n\nnamespace Cat\n\n\n\n/-- A proof that `f` is equivalent to `g` (`≋`, `\\~~~`). -/\ninductive Fam.Cat.Hom.Equiv\n  {ℂ : Cat}\n  {α β : ℂ.Obj}\n  (f : α ↠ β)\n: {γ δ : ℂ.Obj}\n  → (γ ↠ δ)\n  → Prop\nwhere\n| proof :\n  (g : α ↠ β)\n  → f ≈ g\n  → Equiv f g\n\n\n/-- Predicate for *\"`f` and `g` are equivalent\"* (`≋`, `\\~~~`). -/\nabbrev Fam.Cat.Hom.Equiv.equiv\n  {ℂ : Cat}\n  {α β γ δ : ℂ.Obj}\n  (f : α ↠ β)\n  (g : γ ↠ δ)\n: Prop :=\n  @Equiv ℂ α β f γ δ g\n\ninfix:30 \" ≋ \" =>\n  Fam.Cat.Hom.Equiv.equiv\n\n\n\ntheorem Fam.Cat.Hom.Equiv.domEq\n  {ℂ : Cat}\n  {α β γ δ : ℂ.Obj}\n  {f : α ↠ β}\n  {g : γ ↠ δ}\n  (h : f ≋ g)\n: α = γ :=\n  by\n    cases h with\n    | proof _ _ =>\n      rfl\n\ntheorem Fam.Cat.Hom.Equiv.codEq\n  {ℂ : Cat}\n  {α β γ δ : ℂ.Obj}\n  {f : α ↠ β}\n  {g : γ ↠ δ}\n  (h : f ≋ g)\n: β = δ :=\n  by\n    cases h with\n    | proof _ _ =>\n      rfl\n\n\n\n/-- Rewrites a `Equiv.proof` unifying (co)domains. -/\ntheorem Fam.Cat.Hom.Equiv.unify\n  {ℂ : Cat}\n  {α β γ δ : ℂ.Obj}\n  {f : α ↠ β}\n  {g : γ ↠ δ}\n  (h : f ≋ g)\n: (\n  @Equiv ℂ α β f α β (\n    let h_dom := domEq h\n    let h_cod := codEq h\n    by\n      rw [h_dom, h_cod]\n      exact g\n  )\n) :=\n  by\n    cases h with\n    | proof g eq =>\n      apply proof g eq\n\ntheorem Fam.Cat.Hom.Equiv.toEq\n  {ℂ : Cat}\n  {α β : ℂ.Obj}\n  {f : α ↠ β}\n  {g : α ↠ β}\n  (h : f ≋ g)\n: (f ≈ g) :=\n  match h with\n  | proof _ eq =>\n    eq\n\n\n\n/-! ## `Fam.Cat.Hom.Equiv` is an equivalence relation\n\nWe cannot build an `Equivalence` though, as it takes a `r : α → α → Prop`. `Equiv`'s arguments do\nnot have the same type in general `:/`.\n\nWe can still prove that `Equiv` is reflexive, symmetric and transitive so let's just do that.\n-/\nnamespace Fam.Cat.Hom.Equiv\n\n  theorem refl\n    {ℂ : Cat}\n    {α β : ℂ.Obj}\n    (f : α ↠ β)\n  : f ≋ f :=\n    let eq_f :=\n      ℂ.Hom α β |>.refl f\n    proof f eq_f\n\n  theorem symm\n    {ℂ : Cat}\n    {α₁ β₁ α₂ β₂ : ℂ.Obj}\n    (f₁ : α₁ ↠ β₁)\n    (f₂ : α₂ ↠ β₂)\n  : f₁ ≋ f₂ → f₂ ≋ f₁ :=\n    by\n      intro h\n      cases h\n      apply proof\n      apply ℂ.Hom α₁ β₁ |>.symm\n      assumption\n\n  theorem trans\n    {ℂ : Cat}\n    {α₁ β₁ α₂ β₂ α₃ β₃ : ℂ.Obj}\n    {f₁ : α₁ ↠ β₁}\n    {f₂ : α₂ ↠ β₂}\n    {f₃ : α₃ ↠ β₃}\n  : f₁ ≋ f₂ → f₂ ≋ f₃ → f₁ ≋ f₃ :=\n    by\n      intro h₁₂ h₂₃\n      cases h₁₂ ; cases h₂₃\n      apply proof\n      apply ℂ.Hom α₁ β₁ |>.trans\n      <;> assumption\n\nend Fam.Cat.Hom.Equiv\n\ninstance instTransHomEq\n  {ℂ : Fam.Cat}\n  {α₁ β₁ α₂ β₂ α₃ β₃ : ℂ.Obj}\n: Trans\n  (@Fam.Cat.Hom.Equiv.equiv ℂ α₁ β₁ α₂ β₂)\n  (@Fam.Cat.Hom.Equiv.equiv ℂ α₂ β₂ α₃ β₃)\n  (@Fam.Cat.Hom.Equiv.equiv ℂ α₁ β₁ α₃ β₃)\nwhere\n  trans :=\n    Fam.Cat.Hom.Equiv.trans\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/cat/Cat/Fam/HomEq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4714427756643667}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport set_theory.cardinal.basic\nimport topology.metric_space.closeds\nimport topology.metric_space.completion\nimport topology.metric_space.gromov_hausdorff_realized\nimport topology.metric_space.kuratowski\n\n/-!\n# Gromov-Hausdorff distance\n\nThis file defines the Gromov-Hausdorff distance on the space of nonempty compact metric spaces\nup to isometry.\n\nWe introduce the space of all nonempty compact metric spaces, up to isometry,\ncalled `GH_space`, and endow it with a metric space structure. The distance,\nknown as the Gromov-Hausdorff distance, is defined as follows: given two\nnonempty compact spaces `X` and `Y`, their distance is the minimum Hausdorff distance\nbetween all possible isometric embeddings of `X` and `Y` in all metric spaces.\nTo define properly the Gromov-Hausdorff space, we consider the non-empty\ncompact subsets of `ℓ^∞(ℝ)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `ℓ^∞(ℝ)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `ℓ^∞(ℝ)`, through an\nembedding called the Kuratowski embedding.\nTo prove that we have a distance, we should show that if spaces can be coupled\nto be arbitrarily close, then they are isometric. More generally, the Gromov-Hausdorff\ndistance is realized, i.e., there is a coupling for which the Hausdorff distance\nis exactly the Gromov-Hausdorff distance. This follows from a compactness\nargument, essentially following from Arzela-Ascoli.\n\n## Main results\n\nWe prove the most important properties of the Gromov-Hausdorff space: it is a polish space,\ni.e., it is complete and second countable. We also prove the Gromov compactness criterion.\n\n-/\n\nnoncomputable theory\nopen_locale classical topology ennreal\n\nlocal notation `ℓ_infty_ℝ`:= lp (λ n : ℕ, ℝ) ∞\n\nuniverses u v w\n\nopen classical set function topological_space filter metric quotient\nopen bounded_continuous_function nat int Kuratowski_embedding\nopen sum (inl inr)\n\nlocal attribute [instance] metric_space_sum\n\n\nnamespace Gromov_Hausdorff\n\nsection GH_space\n/- In this section, we define the Gromov-Hausdorff space, denoted `GH_space` as the quotient\nof nonempty compact subsets of `ℓ^∞(ℝ)` by identifying isometric sets.\nUsing the Kuratwoski embedding, we get a canonical map `to_GH_space` mapping any nonempty\ncompact type to `GH_space`. -/\n\n/-- Equivalence relation identifying two nonempty compact sets which are isometric -/\nprivate def isometry_rel : nonempty_compacts ℓ_infty_ℝ → nonempty_compacts ℓ_infty_ℝ → Prop :=\nλ x y, nonempty (x ≃ᵢ y)\n\n/-- This is indeed an equivalence relation -/\nprivate lemma is_equivalence_isometry_rel : equivalence isometry_rel :=\n⟨λ x, ⟨isometry_equiv.refl _⟩, λ x y ⟨e⟩, ⟨e.symm⟩, λ x y z ⟨e⟩ ⟨f⟩, ⟨e.trans f⟩⟩\n\n/-- setoid instance identifying two isometric nonempty compact subspaces of ℓ^∞(ℝ) -/\ninstance isometry_rel.setoid : setoid (nonempty_compacts ℓ_infty_ℝ) :=\nsetoid.mk isometry_rel is_equivalence_isometry_rel\n\n/-- The Gromov-Hausdorff space -/\ndefinition GH_space : Type := quotient (isometry_rel.setoid)\n\n/-- Map any nonempty compact type to `GH_space` -/\ndefinition to_GH_space (X : Type u) [metric_space X] [compact_space X] [nonempty X] : GH_space :=\n  ⟦nonempty_compacts.Kuratowski_embedding X⟧\n\ninstance : inhabited GH_space := ⟨quot.mk _ ⟨⟨{0}, is_compact_singleton⟩, singleton_nonempty _⟩⟩\n\n/-- A metric space representative of any abstract point in `GH_space` -/\n@[nolint has_nonempty_instance]\ndef GH_space.rep (p : GH_space) : Type := (quotient.out p : nonempty_compacts ℓ_infty_ℝ)\n\nlemma eq_to_GH_space_iff {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {p : nonempty_compacts ℓ_infty_ℝ} :\n  ⟦p⟧ = to_GH_space X ↔ ∃ Ψ : X → ℓ_infty_ℝ, isometry Ψ ∧ range Ψ = p :=\nbegin\n  simp only [to_GH_space, quotient.eq],\n  refine ⟨λ h, _, _⟩,\n  { rcases setoid.symm h with ⟨e⟩,\n    have f := (Kuratowski_embedding.isometry X).isometry_equiv_on_range.trans e,\n    use [λ x, f x, isometry_subtype_coe.comp f.isometry],\n    rw [range_comp, f.range_eq_univ, set.image_univ, subtype.range_coe],\n    refl },\n  { rintros ⟨Ψ, ⟨isomΨ, rangeΨ⟩⟩,\n    have f := ((Kuratowski_embedding.isometry X).isometry_equiv_on_range.symm.trans\n               isomΨ.isometry_equiv_on_range).symm,\n    have E : (range Ψ ≃ᵢ nonempty_compacts.Kuratowski_embedding X) =\n        (p ≃ᵢ range (Kuratowski_embedding X)),\n      by { dunfold nonempty_compacts.Kuratowski_embedding, rw [rangeΨ]; refl },\n    exact ⟨cast E f⟩ }\nend\n\nlemma eq_to_GH_space {p : nonempty_compacts ℓ_infty_ℝ} : ⟦p⟧ = to_GH_space p :=\neq_to_GH_space_iff.2 ⟨λ x, x, isometry_subtype_coe, subtype.range_coe⟩\n\nsection\nlocal attribute [reducible] GH_space.rep\n\ninstance rep_GH_space_metric_space {p : GH_space} : metric_space p.rep := by apply_instance\ninstance rep_GH_space_compact_space {p : GH_space} : compact_space p.rep := by apply_instance\ninstance rep_GH_space_nonempty {p : GH_space} : nonempty p.rep := by apply_instance\n\nend\n\nlemma GH_space.to_GH_space_rep (p : GH_space) : to_GH_space p.rep = p :=\nbegin\n  change to_GH_space (quot.out p : nonempty_compacts ℓ_infty_ℝ) = p,\n  rw ← eq_to_GH_space,\n  exact quot.out_eq p\nend\n\n/-- Two nonempty compact spaces have the same image in `GH_space` if and only if they are\nisometric. -/\n\n\n/-- Distance on `GH_space`: the distance between two nonempty compact spaces is the infimum\nHausdorff distance between isometric copies of the two spaces in a metric space. For the definition,\nwe only consider embeddings in `ℓ^∞(ℝ)`, but we will prove below that it works for all spaces. -/\ninstance : has_dist (GH_space) :=\n{ dist := λ x y, Inf $\n    (λ p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ,\n      Hausdorff_dist (p.1 : set ℓ_infty_ℝ) p.2) '' ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y}) }\n\n/-- The Gromov-Hausdorff distance between two nonempty compact metric spaces, equal by definition to\nthe distance of the equivalence classes of these spaces in the Gromov-Hausdorff space. -/\ndef GH_dist (X : Type u) (Y : Type v) [metric_space X] [nonempty X] [compact_space X]\n  [metric_space Y] [nonempty Y] [compact_space Y] : ℝ := dist (to_GH_space X) (to_GH_space Y)\n\nlemma dist_GH_dist (p q : GH_space) : dist p q = GH_dist p.rep (q.rep) :=\nby rw [GH_dist, p.to_GH_space_rep, q.to_GH_space_rep]\n\n/-- The Gromov-Hausdorff distance between two spaces is bounded by the Hausdorff distance\nof isometric copies of the spaces, in any metric space. -/\ntheorem GH_dist_le_Hausdorff_dist {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y]\n  {γ : Type w} [metric_space γ] {Φ : X → γ} {Ψ : Y → γ} (ha : isometry Φ) (hb : isometry Ψ) :\n  GH_dist X Y ≤ Hausdorff_dist (range Φ) (range Ψ) :=\nbegin\n  /- For the proof, we want to embed `γ` in `ℓ^∞(ℝ)`, to say that the Hausdorff distance is realized\n  in `ℓ^∞(ℝ)` and therefore bounded below by the Gromov-Hausdorff-distance. However, `γ` is not\n  separable in general. We restrict to the union of the images of `X` and `Y` in `γ`, which is\n  separable and therefore embeddable in `ℓ^∞(ℝ)`. -/\n  rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n  let s : set γ := (range Φ) ∪ (range Ψ),\n  let Φ' : X → subtype s := λ y, ⟨Φ y, mem_union_left _ (mem_range_self _)⟩,\n  let Ψ' : Y → subtype s := λ y, ⟨Ψ y, mem_union_right _ (mem_range_self _)⟩,\n  have IΦ' : isometry Φ' := λ x y, ha x y,\n  have IΨ' : isometry Ψ' := λ x y, hb x y,\n  have : is_compact s, from (is_compact_range ha.continuous).union (is_compact_range hb.continuous),\n  letI : metric_space (subtype s) := by apply_instance,\n  haveI : compact_space (subtype s) := ⟨is_compact_iff_is_compact_univ.1 ‹is_compact s›⟩,\n  haveI : nonempty (subtype s) := ⟨Φ' xX⟩,\n  have ΦΦ' : Φ = subtype.val ∘ Φ', by { funext, refl },\n  have ΨΨ' : Ψ = subtype.val ∘ Ψ', by { funext, refl },\n  have : Hausdorff_dist (range Φ) (range Ψ) = Hausdorff_dist (range Φ') (range Ψ'),\n  { rw [ΦΦ', ΨΨ', range_comp, range_comp],\n    exact Hausdorff_dist_image (isometry_subtype_coe) },\n  rw this,\n  -- Embed `s` in `ℓ^∞(ℝ)` through its Kuratowski embedding\n  let F := Kuratowski_embedding (subtype s),\n  have : Hausdorff_dist (F '' (range Φ')) (F '' (range Ψ')) =\n    Hausdorff_dist (range Φ') (range Ψ') := Hausdorff_dist_image (Kuratowski_embedding.isometry _),\n  rw ← this,\n  -- Let `A` and `B` be the images of `X` and `Y` under this embedding. They are in `ℓ^∞(ℝ)`, and\n  -- their Hausdorff distance is the same as in the original space.\n  let A : nonempty_compacts ℓ_infty_ℝ := ⟨⟨F '' (range Φ'), (is_compact_range IΦ'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous⟩, (range_nonempty _).image _⟩,\n  let B : nonempty_compacts ℓ_infty_ℝ := ⟨⟨F '' (range Ψ'), (is_compact_range IΨ'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous⟩, (range_nonempty _).image _⟩,\n  have AX : ⟦A⟧ = to_GH_space X,\n  { rw eq_to_GH_space_iff,\n    exact ⟨λ x, F (Φ' x), (Kuratowski_embedding.isometry _).comp IΦ', range_comp _ _⟩ },\n  have BY : ⟦B⟧ = to_GH_space Y,\n  { rw eq_to_GH_space_iff,\n    exact ⟨λ x, F (Ψ' x), (Kuratowski_embedding.isometry _).comp IΨ', range_comp _ _⟩ },\n  refine cInf_le ⟨0, _⟩ _,\n  { simp only [lower_bounds, mem_image, mem_prod, mem_set_of_eq, prod.exists, and_imp,\n      forall_exists_index],\n    assume t _ _ _ _ ht,\n    rw ← ht,\n    exact Hausdorff_dist_nonneg },\n  apply (mem_image _ _ _).2,\n  existsi (⟨A, B⟩ : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n  simp [AX, BY],\nend\n\n/-- The optimal coupling constructed above realizes exactly the Gromov-Hausdorff distance,\nessentially by design. -/\nlemma Hausdorff_dist_optimal {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y] :\n  Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) = GH_dist X Y :=\nbegin\n  inhabit X, inhabit Y,\n  /- we only need to check the inequality `≤`, as the other one follows from the previous lemma.\n     As the Gromov-Hausdorff distance is an infimum, we need to check that the Hausdorff distance\n     in the optimal coupling is smaller than the Hausdorff distance of any coupling.\n     First, we check this for couplings which already have small Hausdorff distance: in this\n     case, the induced \"distance\" on `X ⊕ Y` belongs to the candidates family introduced in the\n     definition of the optimal coupling, and the conclusion follows from the optimality\n     of the optimal coupling within this family.\n  -/\n  have A : ∀ p q : nonempty_compacts ℓ_infty_ℝ, ⟦p⟧ = to_GH_space X → ⟦q⟧ = to_GH_space Y →\n        Hausdorff_dist (p : set ℓ_infty_ℝ) q < diam (univ : set X) + 1 + diam (univ : set Y) →\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤\n        Hausdorff_dist (p : set ℓ_infty_ℝ) q,\n  { assume p q hp hq bound,\n    rcases eq_to_GH_space_iff.1 hp with ⟨Φ, ⟨Φisom, Φrange⟩⟩,\n    rcases eq_to_GH_space_iff.1 hq with ⟨Ψ, ⟨Ψisom, Ψrange⟩⟩,\n    have I : diam (range Φ ∪ range Ψ) ≤ 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y),\n    { rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n      have : ∃ y ∈ range Ψ, dist (Φ xX) y < diam (univ : set X) + 1 + diam (univ : set Y),\n      { rw Ψrange,\n        have : Φ xX ∈ ↑p := Φrange.subst (mem_range_self _),\n        exact exists_dist_lt_of_Hausdorff_dist_lt this bound\n          (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty\n            p.is_compact.bounded q.is_compact.bounded) },\n      rcases this with ⟨y, hy, dy⟩,\n      rcases mem_range.1 hy with ⟨z, hzy⟩,\n      rw ← hzy at dy,\n      have DΦ : diam (range Φ) = diam (univ : set X) := Φisom.diam_range,\n      have DΨ : diam (range Ψ) = diam (univ : set Y) := Ψisom.diam_range,\n      calc\n        diam (range Φ ∪ range Ψ) ≤ diam (range Φ) + dist (Φ xX) (Ψ z) + diam (range Ψ) :\n          diam_union (mem_range_self _) (mem_range_self _)\n        ... ≤ diam (univ : set X) + (diam (univ : set X) + 1 + diam (univ : set Y)) +\n              diam (univ : set Y) :\n          by { rw [DΦ, DΨ], apply add_le_add (add_le_add le_rfl (le_of_lt dy)) le_rfl }\n        ... = 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y) : by ring },\n\n    let f : X ⊕ Y → ℓ_infty_ℝ := λ x, match x with | inl y := Φ y | inr z := Ψ z end,\n    let F : (X ⊕ Y) × (X ⊕ Y) → ℝ := λ p, dist (f p.1) (f p.2),\n    -- check that the induced \"distance\" is a candidate\n    have Fgood : F ∈ candidates X Y,\n    { simp only [candidates, forall_const, and_true, add_comm, eq_self_iff_true, dist_eq_zero,\n                 and_self, set.mem_set_of_eq],\n      repeat {split},\n      { exact λ x y, calc\n        F (inl x, inl y) = dist (Φ x) (Φ y) : rfl\n        ... = dist x y : Φisom.dist_eq x y },\n      { exact λ x y, calc\n        F (inr x, inr y) = dist (Ψ x) (Ψ y) : rfl\n        ... = dist x y : Ψisom.dist_eq x y },\n      { exact λ x y, dist_comm _ _ },\n      { exact λ x y z, dist_triangle _ _ _ },\n      { exact λ x y, calc\n        F (x, y) ≤ diam (range Φ ∪ range Ψ) :\n        begin\n          have A : ∀ z : X ⊕ Y, f z ∈ range Φ ∪ range Ψ,\n          { assume z,\n            cases z,\n            { apply mem_union_left, apply mem_range_self },\n            { apply mem_union_right, apply mem_range_self } },\n          refine dist_le_diam_of_mem _ (A _) (A _),\n          rw [Φrange, Ψrange],\n          exact (p ⊔ q).is_compact.bounded,\n        end\n        ... ≤ 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y) : I } },\n    let Fb := candidates_b_of_candidates F Fgood,\n    have : Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤ HD Fb :=\n      Hausdorff_dist_optimal_le_HD _ _ (candidates_b_of_candidates_mem F Fgood),\n    refine le_trans this (le_of_forall_le_of_dense (λ r hr, _)),\n    have I1 : ∀ x : X, (⨅ y, Fb (inl x, inr y)) ≤ r,\n    { assume x,\n      have : f (inl x) ∈ ↑p := Φrange.subst (mem_range_self _),\n      rcases exists_dist_lt_of_Hausdorff_dist_lt this hr\n        (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty\n          p.is_compact.bounded q.is_compact.bounded)\n        with ⟨z, zq, hz⟩,\n      have : z ∈ range Ψ, by rwa [← Ψrange] at zq,\n      rcases mem_range.1 this with ⟨y, hy⟩,\n      calc (⨅ y, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :\n          cinfi_le (by simpa only [add_zero] using HD_below_aux1 0) y\n        ... = dist (Φ x) (Ψ y) : rfl\n        ... = dist (f (inl x)) z : by rw hy\n        ... ≤ r : le_of_lt hz },\n    have I2 : ∀ y : Y, (⨅ x, Fb (inl x, inr y)) ≤ r,\n    { assume y,\n      have : f (inr y) ∈ ↑q := Ψrange.subst (mem_range_self _),\n      rcases exists_dist_lt_of_Hausdorff_dist_lt' this hr\n        (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.nonempty q.nonempty\n          p.is_compact.bounded q.is_compact.bounded)\n        with ⟨z, zq, hz⟩,\n      have : z ∈ range Φ, by rwa [← Φrange] at zq,\n      rcases mem_range.1 this with ⟨x, hx⟩,\n      calc (⨅ x, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :\n          cinfi_le (by simpa only [add_zero] using HD_below_aux2 0) x\n        ... = dist (Φ x) (Ψ y) : rfl\n        ... = dist z (f (inr y)) : by rw hx\n        ... ≤ r : le_of_lt hz },\n    simp only [HD, csupr_le I1, csupr_le I2, max_le_iff, and_self] },\n  /- Get the same inequality for any coupling. If the coupling is quite good, the desired\n  inequality has been proved above. If it is bad, then the inequality is obvious. -/\n  have B : ∀ p q : nonempty_compacts ℓ_infty_ℝ, ⟦p⟧ = to_GH_space X → ⟦q⟧ = to_GH_space Y →\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤\n        Hausdorff_dist (p : set ℓ_infty_ℝ) q,\n  { assume p q hp hq,\n    by_cases h :\n      Hausdorff_dist (p : set ℓ_infty_ℝ) q < diam (univ : set X) + 1 + diam (univ : set Y),\n    { exact A p q hp hq h },\n    { calc Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y))\n               ≤ HD (candidates_b_dist X Y) :\n             Hausdorff_dist_optimal_le_HD _ _ (candidates_b_dist_mem_candidates_b)\n           ... ≤ diam (univ : set X) + 1 + diam (univ : set Y) : HD_candidates_b_dist_le\n           ... ≤ Hausdorff_dist (p : set ℓ_infty_ℝ) q : not_lt.1 h } },\n  refine le_antisymm _ _,\n  { apply le_cInf,\n    { refine (set.nonempty.prod _ _).image _; exact ⟨_, rfl⟩ },\n    { rintro b ⟨⟨p, q⟩, ⟨hp, hq⟩, rfl⟩,\n      exact B p q hp hq } },\n  { exact GH_dist_le_Hausdorff_dist (isometry_optimal_GH_injl X Y) (isometry_optimal_GH_injr X Y) }\nend\n\n/-- The Gromov-Hausdorff distance can also be realized by a coupling in `ℓ^∞(ℝ)`, by embedding\nthe optimal coupling through its Kuratowski embedding. -/\ntheorem GH_dist_eq_Hausdorff_dist (X : Type u) [metric_space X] [compact_space X] [nonempty X]\n  (Y : Type v) [metric_space Y] [compact_space Y] [nonempty Y] :\n  ∃ Φ : X → ℓ_infty_ℝ, ∃ Ψ : Y → ℓ_infty_ℝ, isometry Φ ∧ isometry Ψ ∧\n  GH_dist X Y = Hausdorff_dist (range Φ) (range Ψ) :=\nbegin\n  let F := Kuratowski_embedding (optimal_GH_coupling X Y),\n  let Φ := F ∘ optimal_GH_injl X Y,\n  let Ψ := F ∘ optimal_GH_injr X Y,\n  refine ⟨Φ, Ψ, _, _, _⟩,\n  { exact (Kuratowski_embedding.isometry _).comp (isometry_optimal_GH_injl X Y) },\n  { exact (Kuratowski_embedding.isometry _).comp (isometry_optimal_GH_injr X Y) },\n  { rw [← image_univ, ← image_univ, image_comp F, image_univ, image_comp F (optimal_GH_injr X Y),\n      image_univ, ← Hausdorff_dist_optimal],\n    exact (Hausdorff_dist_image (Kuratowski_embedding.isometry _)).symm },\nend\n\n/-- The Gromov-Hausdorff distance defines a genuine distance on the Gromov-Hausdorff space. -/\ninstance : metric_space GH_space :=\n{ dist := dist,\n  dist_self := λ x, begin\n    rcases exists_rep x with ⟨y, hy⟩,\n    refine le_antisymm _ _,\n    { apply cInf_le,\n      { exact ⟨0, by { rintro b ⟨⟨u, v⟩, ⟨hu, hv⟩, rfl⟩, exact Hausdorff_dist_nonneg } ⟩},\n      { simp only [mem_image, mem_prod, mem_set_of_eq, prod.exists],\n        existsi [y, y],\n        simpa only [and_self, Hausdorff_dist_self_zero, eq_self_iff_true, and_true]} },\n    { apply le_cInf,\n      { exact (nonempty.prod ⟨y, hy⟩ ⟨y, hy⟩).image _ },\n      { rintro b ⟨⟨u, v⟩, ⟨hu, hv⟩, rfl⟩, exact Hausdorff_dist_nonneg } },\n  end,\n  dist_comm := λ x y, begin\n    have A : (λ (p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n                 Hausdorff_dist (p.1 : set ℓ_infty_ℝ) p.2) ''\n             ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y})\n           = ((λ (p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n                 Hausdorff_dist (p.1 : set ℓ_infty_ℝ) p.2) ∘ prod.swap) ''\n                 ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y}),\n    { congr, funext, simp only [comp_app, prod.fst_swap, prod.snd_swap], rw Hausdorff_dist_comm },\n    simp only [dist, A, image_comp, image_swap_prod],\n  end,\n  eq_of_dist_eq_zero := λ x y hxy, begin\n    /- To show that two spaces at zero distance are isometric, we argue that the distance\n    is realized by some coupling. In this coupling, the two spaces are at zero Hausdorff distance,\n    i.e., they coincide. Therefore, the original spaces are isometric. -/\n    rcases GH_dist_eq_Hausdorff_dist x.rep y.rep with ⟨Φ, Ψ, Φisom, Ψisom, DΦΨ⟩,\n    rw [← dist_GH_dist, hxy] at DΦΨ,\n    have : range Φ = range Ψ,\n    { have hΦ : is_compact (range Φ) := is_compact_range Φisom.continuous,\n      have hΨ : is_compact (range Ψ) := is_compact_range Ψisom.continuous,\n      apply (is_closed.Hausdorff_dist_zero_iff_eq _ _ _).1 (DΦΨ.symm),\n      { exact hΦ.is_closed },\n      { exact hΨ.is_closed },\n      { exact Hausdorff_edist_ne_top_of_nonempty_of_bounded (range_nonempty _)\n          (range_nonempty _) hΦ.bounded hΨ.bounded } },\n    have T : ((range Ψ) ≃ᵢ y.rep) = ((range Φ) ≃ᵢ y.rep), by rw this,\n    have eΨ := cast T Ψisom.isometry_equiv_on_range.symm,\n    have e := Φisom.isometry_equiv_on_range.trans eΨ,\n    rw [← x.to_GH_space_rep, ← y.to_GH_space_rep, to_GH_space_eq_to_GH_space_iff_isometry_equiv],\n    exact ⟨e⟩\n  end,\n  dist_triangle := λ x y z, begin\n    /- To show the triangular inequality between `X`, `Y` and `Z`, realize an optimal coupling\n    between `X` and `Y` in a space `γ1`, and an optimal coupling between `Y` and `Z` in a space\n    `γ2`. Then, glue these metric spaces along `Y`. We get a new space `γ` in which `X` and `Y` are\n    optimally coupled, as well as `Y` and `Z`. Apply the triangle inequality for the Hausdorff\n    distance in `γ` to conclude. -/\n    let X := x.rep,\n    let Y := y.rep,\n    let Z := z.rep,\n    let γ1 := optimal_GH_coupling X Y,\n    let γ2 := optimal_GH_coupling Y Z,\n    let Φ : Y → γ1 := optimal_GH_injr X Y,\n    have hΦ : isometry Φ := isometry_optimal_GH_injr X Y,\n    let Ψ : Y → γ2 := optimal_GH_injl Y Z,\n    have hΨ : isometry Ψ := isometry_optimal_GH_injl Y Z,\n    let γ := glue_space hΦ hΨ,\n    have Comm : (to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y) =\n      (to_glue_r hΦ hΨ) ∘ (optimal_GH_injl Y Z) := to_glue_commute hΦ hΨ,\n    calc dist x z = dist (to_GH_space X) (to_GH_space Z) :\n        by rw [x.to_GH_space_rep, z.to_GH_space_rep]\n      ... ≤ Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injl X Y)))\n                       (range ((to_glue_r hΦ hΨ) ∘ (optimal_GH_injr Y Z))) :\n        GH_dist_le_Hausdorff_dist\n          ((to_glue_l_isometry hΦ hΨ).comp (isometry_optimal_GH_injl X Y))\n          ((to_glue_r_isometry hΦ hΨ).comp (isometry_optimal_GH_injr Y Z))\n      ... ≤ Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injl X Y)))\n                           (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y)))\n          + Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y)))\n                           (range ((to_glue_r hΦ hΨ) ∘ (optimal_GH_injr Y Z))) :\n        begin\n          refine Hausdorff_dist_triangle (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n            (range_nonempty _) (range_nonempty _) _ _),\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry hΦ hΨ).comp\n              (isometry_optimal_GH_injl X Y)))).bounded },\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry hΦ hΨ).comp\n              (isometry_optimal_GH_injr X Y)))).bounded }\n        end\n      ... = Hausdorff_dist ((to_glue_l hΦ hΨ) '' (range (optimal_GH_injl X Y)))\n                           ((to_glue_l hΦ hΨ) '' (range (optimal_GH_injr X Y)))\n          + Hausdorff_dist ((to_glue_r hΦ hΨ) '' (range (optimal_GH_injl Y Z)))\n                           ((to_glue_r hΦ hΨ) '' (range (optimal_GH_injr Y Z))) :\n        by simp only [← range_comp, Comm, eq_self_iff_true, add_right_inj]\n      ... = Hausdorff_dist (range (optimal_GH_injl X Y))\n                           (range (optimal_GH_injr X Y))\n          + Hausdorff_dist (range (optimal_GH_injl Y Z))\n                           (range (optimal_GH_injr Y Z)) :\n        by rw [Hausdorff_dist_image (to_glue_l_isometry hΦ hΨ),\n               Hausdorff_dist_image (to_glue_r_isometry hΦ hΨ)]\n      ... = dist (to_GH_space X) (to_GH_space Y) + dist (to_GH_space Y) (to_GH_space Z) :\n        by rw [Hausdorff_dist_optimal, Hausdorff_dist_optimal, GH_dist, GH_dist]\n      ... = dist x y + dist y z:\n        by rw [x.to_GH_space_rep, y.to_GH_space_rep, z.to_GH_space_rep]\n  end }\n\nend GH_space --section\nend Gromov_Hausdorff\n\n/-- In particular, nonempty compacts of a metric space map to `GH_space`. We register this\nin the topological_space namespace to take advantage of the notation `p.to_GH_space`. -/\ndefinition topological_space.nonempty_compacts.to_GH_space {X : Type u} [metric_space X]\n  (p : nonempty_compacts X) : Gromov_Hausdorff.GH_space := Gromov_Hausdorff.to_GH_space p\n\nopen topological_space\n\nnamespace Gromov_Hausdorff\n\nsection nonempty_compacts\nvariables {X : Type u} [metric_space X]\n\ntheorem GH_dist_le_nonempty_compacts_dist (p q : nonempty_compacts X) :\n  dist p.to_GH_space q.to_GH_space ≤ dist p q :=\nbegin\n  have ha : isometry (coe : p → X) := isometry_subtype_coe,\n  have hb : isometry (coe : q → X) := isometry_subtype_coe,\n  have A : dist p q = Hausdorff_dist (p : set X) q := rfl,\n  have I : ↑p = range (coe : p → X) := subtype.range_coe_subtype.symm,\n  have J : ↑q = range (coe : q → X) := subtype.range_coe_subtype.symm,\n  rw [A, I, J],\n  exact GH_dist_le_Hausdorff_dist ha hb\nend\n\nlemma to_GH_space_lipschitz :\n  lipschitz_with 1 (nonempty_compacts.to_GH_space : nonempty_compacts X → GH_space) :=\nlipschitz_with.mk_one GH_dist_le_nonempty_compacts_dist\n\nlemma to_GH_space_continuous :\n  continuous (nonempty_compacts.to_GH_space : nonempty_compacts X → GH_space) :=\nto_GH_space_lipschitz.continuous\n\nend nonempty_compacts\n\nsection\n/- In this section, we show that if two metric spaces are isometric up to `ε₂`, then their\nGromov-Hausdorff distance is bounded by `ε₂ / 2`. More generally, if there are subsets which are\n`ε₁`-dense and `ε₃`-dense in two spaces, and isometric up to `ε₂`, then the Gromov-Hausdorff\ndistance between the spaces is bounded by `ε₁ + ε₂/2 + ε₃`. For this, we construct a suitable\ncoupling between the two spaces, by gluing them (approximately) along the two matching subsets. -/\n\n\nvariables {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n          {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y]\n\n-- we want to ignore these instances in the following theorem\nlocal attribute [instance, priority 10] sum.topological_space sum.uniform_space\n/-- If there are subsets which are `ε₁`-dense and `ε₃`-dense in two spaces, and\nisometric up to `ε₂`, then the Gromov-Hausdorff distance between the spaces is bounded by\n`ε₁ + ε₂/2 + ε₃`. -/\ntheorem GH_dist_le_of_approx_subsets {s : set X} (Φ : s → Y) {ε₁ ε₂ ε₃ : ℝ}\n  (hs : ∀ x : X, ∃ y ∈ s, dist x y ≤ ε₁) (hs' : ∀ x : Y, ∃ y : s, dist x (Φ y) ≤ ε₃)\n  (H : ∀ x y : s, |dist x y - dist (Φ x) (Φ y)| ≤ ε₂) :\n  GH_dist X Y ≤ ε₁ + ε₂ / 2 + ε₃ :=\nbegin\n  refine le_of_forall_pos_le_add (λ δ δ0, _),\n  rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n  rcases hs xX with ⟨xs, hxs, Dxs⟩,\n  have sne : s.nonempty := ⟨xs, hxs⟩,\n  letI : nonempty s := sne.to_subtype,\n  have : 0 ≤ ε₂ := le_trans (abs_nonneg _) (H ⟨xs, hxs⟩ ⟨xs, hxs⟩),\n  have : ∀ p q : s, |dist p q - dist (Φ p) (Φ q)| ≤ 2 * (ε₂/2 + δ) := λ p q, calc\n    |dist p q - dist (Φ p) (Φ q)| ≤ ε₂ : H p q\n    ... ≤ 2 * (ε₂/2 + δ) : by linarith,\n  -- glue `X` and `Y` along the almost matching subsets\n  letI : metric_space (X ⊕ Y) :=\n    glue_metric_approx (λ x:s, (x:X)) (λ x, Φ x) (ε₂/2 + δ) (by linarith) this,\n  let Fl := @sum.inl X Y,\n  let Fr := @sum.inr X Y,\n  have Il : isometry Fl := isometry.of_dist_eq (λ x y, rfl),\n  have Ir : isometry Fr := isometry.of_dist_eq (λ x y, rfl),\n  /- The proof goes as follows : the `GH_dist` is bounded by the Hausdorff distance of the images\n  in the coupling, which is bounded (using the triangular inequality) by the sum of the Hausdorff\n  distances of `X` and `s` (in the coupling or, equivalently in the original space), of `s` and\n  `Φ s`, and of `Φ s` and `Y` (in the coupling or, equivalently, in the original space). The first\n  term is bounded by `ε₁`, by `ε₁`-density. The third one is bounded by `ε₃`. And the middle one is\n  bounded by `ε₂/2` as in the coupling the points `x` and `Φ x` are at distance `ε₂/2` by\n  construction of the coupling (in fact `ε₂/2 + δ` where `δ` is an arbitrarily small positive\n  constant where positivity is used to ensure that the coupling is really a metric space and not a\n  premetric space on `X ⊕ Y`). -/\n  have : GH_dist X Y ≤ Hausdorff_dist (range Fl) (range Fr) :=\n    GH_dist_le_Hausdorff_dist Il Ir,\n  have : Hausdorff_dist (range Fl) (range Fr) ≤ Hausdorff_dist (range Fl) (Fl '' s)\n                                              + Hausdorff_dist (Fl '' s) (range Fr),\n  { have B : bounded (range Fl) := (is_compact_range Il.continuous).bounded,\n    exact Hausdorff_dist_triangle (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n      (range_nonempty _) (sne.image _) B (B.mono (image_subset_range _ _))) },\n  have : Hausdorff_dist (Fl '' s) (range Fr) ≤ Hausdorff_dist (Fl '' s) (Fr '' (range Φ))\n                                             + Hausdorff_dist (Fr '' (range Φ)) (range Fr),\n  { have B : bounded (range Fr) := (is_compact_range Ir.continuous).bounded,\n    exact Hausdorff_dist_triangle' (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n      ((range_nonempty _).image _) (range_nonempty _)\n      (bounded.mono (image_subset_range _ _) B) B) },\n  have : Hausdorff_dist (range Fl) (Fl '' s) ≤ ε₁,\n  { rw [← image_univ, Hausdorff_dist_image Il],\n    have : 0 ≤ ε₁ := le_trans dist_nonneg Dxs,\n    refine Hausdorff_dist_le_of_mem_dist this (λ x hx, hs x)\n      (λ x hx, ⟨x, mem_univ _, by simpa only [dist_self]⟩) },\n  have : Hausdorff_dist (Fl '' s) (Fr '' (range Φ)) ≤ ε₂/2 + δ,\n  { refine Hausdorff_dist_le_of_mem_dist (by linarith) _ _,\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with ⟨x, ⟨x_in_s, xx'⟩⟩,\n      rw ← xx',\n      use [Fr (Φ ⟨x, x_in_s⟩), mem_image_of_mem Fr (mem_range_self _)],\n      exact le_of_eq (glue_dist_glued_points (λ x:s, (x:X)) Φ (ε₂/2 + δ) ⟨x, x_in_s⟩) },\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with ⟨y, ⟨y_in_s', yx'⟩⟩,\n      rcases mem_range.1 y_in_s' with ⟨x, xy⟩,\n      use [Fl x, mem_image_of_mem _ x.2],\n      rw [← yx', ← xy, dist_comm],\n      exact le_of_eq (glue_dist_glued_points (@subtype.val X s) Φ (ε₂/2 + δ) x) } },\n  have : Hausdorff_dist (Fr '' (range Φ)) (range Fr) ≤ ε₃,\n  { rw [← @image_univ _ _ Fr, Hausdorff_dist_image Ir],\n    rcases exists_mem_of_nonempty Y with ⟨xY, _⟩,\n    rcases hs' xY with ⟨xs', Dxs'⟩,\n    have : 0 ≤ ε₃ := le_trans dist_nonneg Dxs',\n    refine Hausdorff_dist_le_of_mem_dist this (λ x hx, ⟨x, mem_univ _, by simpa only [dist_self]⟩)\n      (λ x _, _),\n    rcases hs' x with ⟨y, Dy⟩,\n    exact ⟨Φ y, mem_range_self _, Dy⟩ },\n  linarith\nend\nend --section\n\n/-- The Gromov-Hausdorff space is second countable. -/\ninstance : second_countable_topology GH_space :=\nbegin\n  refine second_countable_of_countable_discretization (λ δ δpos, _),\n  let ε := (2/5) * δ,\n  have εpos : 0 < ε := mul_pos (by norm_num) δpos,\n  have : ∀ p:GH_space, ∃ s : set p.rep, s.finite ∧ (univ ⊆ (⋃x∈s, ball x ε)) :=\n    λ p, by simpa only [subset_univ, exists_true_left]\n      using finite_cover_balls_of_compact is_compact_univ εpos,\n  -- for each `p`, `s p` is a finite `ε`-dense subset of `p` (or rather the metric space\n  -- `p.rep` representing `p`)\n  choose s hs using this,\n  have : ∀ p:GH_space, ∀ t:set p.rep, t.finite → ∃ n:ℕ, ∃ e:equiv t (fin n), true,\n  { assume p t ht,\n    letI : fintype t := finite.fintype ht,\n    exact ⟨fintype.card t, fintype.equiv_fin t, trivial⟩ },\n  choose N e hne using this,\n  -- cardinality of the nice finite subset `s p` of `p.rep`, called `N p`\n  let N := λ p:GH_space, N p (s p) (hs p).1,\n  -- equiv from `s p`, a nice finite subset of `p.rep`, to `fin (N p)`, called `E p`\n  let E := λ p:GH_space, e p (s p) (hs p).1,\n  -- A function `F` associating to `p : GH_space` the data of all distances between points\n  -- in the `ε`-dense set `s p`.\n  let F : GH_space → Σn:ℕ, (fin n → fin n → ℤ) :=\n    λp, ⟨N p, λa b, ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋⟩,\n  refine ⟨Σ n, fin n → fin n → ℤ, by apply_instance, F, λp q hpq, _⟩,\n  /- As the target space of F is countable, it suffices to show that two points\n  `p` and `q` with `F p = F q` are at distance `≤ δ`.\n  For this, we construct a map `Φ` from `s p ⊆ p.rep` (representing `p`)\n  to `q.rep` (representing `q`) which is almost an isometry on `s p`, and\n  with image `s q`. For this, we compose the identification of `s p` with `fin (N p)`\n  and the inverse of the identification of `s q` with `fin (N q)`. Together with\n  the fact that `N p = N q`, this constructs `Ψ` between `s p` and `s q`, and then\n  composing with the canonical inclusion we get `Φ`. -/\n  have Npq : N p = N q := (sigma.mk.inj_iff.1 hpq).1,\n  let Ψ : s p → s q := λ x, (E q).symm (fin.cast Npq ((E p) x)),\n  let Φ : s p → q.rep := λ x, Ψ x,\n  -- Use the almost isometry `Φ` to show that `p.rep` and `q.rep`\n  -- are within controlled Gromov-Hausdorff distance.\n  have main : GH_dist p.rep q.rep ≤ ε + ε/2 + ε,\n  { refine GH_dist_le_of_approx_subsets Φ  _ _ _,\n    show ∀ x : p.rep, ∃ (y : p.rep) (H : y ∈ s p), dist x y ≤ ε,\n    { -- by construction, `s p` is `ε`-dense\n      assume x,\n      have : x ∈ ⋃y∈(s p), ball y ε := (hs p).2 (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      exact ⟨y, ys, le_of_lt hy⟩ },\n    show ∀ x : q.rep, ∃ (z : s p), dist x (Φ z) ≤ ε,\n    { -- by construction, `s q` is `ε`-dense, and it is the range of `Φ`\n      assume x,\n      have : x ∈ ⋃y∈(s q), ball y ε := (hs q).2 (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      let i : ℕ := E q ⟨y, ys⟩,\n      let hi := ((E q) ⟨y, ys⟩).is_lt,\n      have ihi_eq : (⟨i, hi⟩ : fin (N q)) = (E q) ⟨y, ys⟩, by rw [fin.ext_iff, fin.coe_mk],\n      have hiq : i < N q := hi,\n      have hip : i < N p, { rwa Npq.symm at hiq },\n      let z := (E p).symm ⟨i, hip⟩,\n      use z,\n      have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩,\n      have C2 : fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl,\n      have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩,\n      { rw ihi_eq, exact (E q).symm_apply_apply ⟨y, ys⟩ },\n      have : Φ z = y,\n      { simp only [Φ, Ψ], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_of_lt hy },\n    show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `Φ x` in `fin (N p) = fin (N q)`\n      let i : ℕ := E p x,\n      have hip : i < N p := ((E p) x).2,\n      have hiq : i < N q, by rwa Npq at hip,\n      have i' : i = ((E q) (Ψ x)), by { simp only [equiv.apply_symm_apply, fin.coe_cast] },\n      -- introduce `j`, that codes both `y` and `Φ y` in `fin (N p) = fin (N q)`\n      let j : ℕ := E p y,\n      have hjp : j < N p := ((E p) y).2,\n      have hjq : j < N q, by rwa Npq at hjp,\n      have j' : j = ((E q) (Ψ y)).1,\n      { simp only [equiv.apply_symm_apply, fin.val_eq_coe, fin.coe_cast] },\n      -- Express `dist x y` in terms of `F p`\n      have : (F p).2 ((E p) x) ((E p) y) = floor (ε⁻¹ * dist x y),\n        by simp only [F, (E p).symm_apply_apply],\n      have Ap : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = floor (ε⁻¹ * dist x y),\n        by { rw ← this, congr; apply fin.ext_iff.2; refl },\n      -- Express `dist (Φ x) (Φ y)` in terms of `F q`\n      have : (F q).2 ((E q) (Ψ x)) ((E q) (Ψ y)) = floor (ε⁻¹ * dist (Ψ x) (Ψ y)),\n        by simp only [F, (E q).symm_apply_apply],\n      have Aq : (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩ = floor (ε⁻¹ * dist (Ψ x) (Ψ y)),\n        by { rw ← this, congr; apply fin.ext_iff.2; [exact i', exact j'] },\n      -- use the equality between `F p` and `F q` to deduce that the distances have equal\n      -- integer parts\n      have : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩,\n      { -- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works\n        -- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`\n        -- then `subst`\n        revert hiq hjq,\n        change N q with (F q).1,\n        generalize_hyp : F q = f at hpq ⊢,\n        subst hpq,\n        intros,\n        refl },\n      rw [Ap, Aq] at this,\n      -- deduce that the distances coincide up to `ε`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| =\n          |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| : (abs_mul _ _).symm\n        ... = |(ε⁻¹ * dist x y) - (ε⁻¹ * dist (Ψ x) (Ψ y))| : by { congr, ring }\n        ... ≤ 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (Ψ x) (Ψ y)| = (ε * ε⁻¹) * |dist x y - dist (Ψ x) (Ψ y)| :\n          by rw [mul_inv_cancel (ne_of_gt εpos), one_mul]\n        ... = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]\n        ... ≤ ε * 1 : mul_le_mul_of_nonneg_left I (le_of_lt εpos)\n        ... = ε : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... ≤ ε + ε/2 + ε : main\n    ... = δ : by { simp only [ε], ring }\nend\n\n/-- Compactness criterion: a closed set of compact metric spaces is compact if the spaces have\na uniformly bounded diameter, and for all `ε` the number of balls of radius `ε` required\nto cover the spaces is uniformly bounded. This is an equivalence, but we only prove the\ninteresting direction that these conditions imply compactness. -/\nlemma totally_bounded {t : set GH_space} {C : ℝ} {u : ℕ → ℝ} {K : ℕ → ℕ}\n  (ulim : tendsto u at_top (𝓝 0))\n  (hdiam : ∀ p ∈ t, diam (univ : set (GH_space.rep p)) ≤ C)\n  (hcov : ∀ p ∈ t, ∀ n:ℕ, ∃ s : set (GH_space.rep p),\n    cardinal.mk s ≤ K n ∧ univ ⊆ ⋃x∈s, ball x (u n)) :\n  totally_bounded t :=\nbegin\n  /- Let `δ>0`, and `ε = δ/5`. For each `p`, we construct a finite subset `s p` of `p`, which\n  is `ε`-dense and has cardinality at most `K n`. Encoding the mutual distances of points in `s p`,\n  up to `ε`, we will get a map `F` associating to `p` finitely many data, and making it possible to\n  reconstruct `p` up to `ε`. This is enough to prove total boundedness. -/\n  refine metric.totally_bounded_of_finite_discretization (λ δ δpos, _),\n  let ε := (1/5) * δ,\n  have εpos : 0 < ε := mul_pos (by norm_num) δpos,\n  -- choose `n` for which `u n < ε`\n  rcases metric.tendsto_at_top.1 ulim ε εpos with ⟨n, hn⟩,\n  have u_le_ε : u n ≤ ε,\n  { have := hn n le_rfl,\n    simp only [real.dist_eq, add_zero, sub_eq_add_neg, neg_zero] at this,\n    exact le_of_lt (lt_of_le_of_lt (le_abs_self _) this) },\n  -- construct a finite subset `s p` of `p` which is `ε`-dense and has cardinal `≤ K n`\n  have : ∀ p:GH_space, ∃ s : set p.rep, ∃ N ≤ K n, ∃ E : equiv s (fin N),\n    p ∈ t → univ ⊆ ⋃x∈s, ball x (u n),\n  { assume p,\n    by_cases hp : p ∉ t,\n    { have : nonempty (equiv (∅ : set p.rep) (fin 0)),\n      { rw ← fintype.card_eq, simp only [empty_card', fintype.card_fin] },\n      use [∅, 0, bot_le, choice (this)] },\n    { rcases hcov _ (set.not_not_mem.1 hp) n with ⟨s, ⟨scard, scover⟩⟩,\n      rcases cardinal.lt_aleph_0.1 (lt_of_le_of_lt scard (cardinal.nat_lt_aleph_0 _)) with ⟨N, hN⟩,\n      rw [hN, cardinal.nat_cast_le] at scard,\n      have : cardinal.mk s = cardinal.mk (fin N), by rw [hN, cardinal.mk_fin],\n      cases quotient.exact this with E,\n      use [s, N, scard, E],\n      simp only [scover, implies_true_iff] } },\n  choose s N hN E hs using this,\n  -- Define a function `F` taking values in a finite type and associating to `p` enough data\n  -- to reconstruct it up to `ε`, namely the (discretized) distances between elements of `s p`.\n  let M := ⌊ε⁻¹ * max C 0⌋₊,\n  let F : GH_space → (Σk:fin ((K n).succ), (fin k → fin k → fin (M.succ))) :=\n    λ p, ⟨⟨N p, lt_of_le_of_lt (hN p) (nat.lt_succ_self _)⟩,\n         λ a b, ⟨min M ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋₊,\n                ( min_le_left _ _).trans_lt (nat.lt_succ_self _) ⟩ ⟩,\n  refine ⟨_, _, (λ p, F p), _⟩, apply_instance,\n  -- It remains to show that if `F p = F q`, then `p` and `q` are `ε`-close\n  rintros ⟨p, pt⟩ ⟨q, qt⟩ hpq,\n  have Npq : N p = N q := fin.ext_iff.1 (sigma.mk.inj_iff.1 hpq).1,\n  let Ψ : s p → s q := λ x, (E q).symm (fin.cast Npq ((E p) x)),\n  let Φ : s p → q.rep := λ x, Ψ x,\n  have main : GH_dist p.rep (q.rep) ≤ ε + ε/2 + ε,\n  { -- to prove the main inequality, argue that `s p` is `ε`-dense in `p`, and `s q` is `ε`-dense\n    -- in `q`, and `s p` and `s q` are almost isometric. Then closeness follows\n    -- from `GH_dist_le_of_approx_subsets`\n    refine GH_dist_le_of_approx_subsets Φ  _ _ _,\n    show ∀ x : p.rep, ∃ (y : p.rep) (H : y ∈ s p), dist x y ≤ ε,\n    { -- by construction, `s p` is `ε`-dense\n      assume x,\n      have : x ∈ ⋃y∈(s p), ball y (u n) := (hs p pt) (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      exact ⟨y, ys, le_trans (le_of_lt hy) u_le_ε⟩ },\n    show ∀ x : q.rep, ∃ (z : s p), dist x (Φ z) ≤ ε,\n    { -- by construction, `s q` is `ε`-dense, and it is the range of `Φ`\n      assume x,\n      have : x ∈ ⋃y∈(s q), ball y (u n) := (hs q qt) (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      let i : ℕ := E q ⟨y, ys⟩,\n      let hi := ((E q) ⟨y, ys⟩).2,\n      have ihi_eq : (⟨i, hi⟩ : fin (N q)) = (E q) ⟨y, ys⟩, by rw [fin.ext_iff, fin.coe_mk],\n      have hiq : i < N q := hi,\n      have hip : i < N p, { rwa Npq.symm at hiq },\n      let z := (E p).symm ⟨i, hip⟩,\n      use z,\n      have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩,\n      have C2 : fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl,\n      have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩,\n        by { rw ihi_eq, exact (E q).symm_apply_apply ⟨y, ys⟩ },\n      have : Φ z = y :=\n        by { simp only [Φ, Ψ], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_trans (le_of_lt hy) u_le_ε },\n    show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `Φ x` in `fin (N p) = fin (N q)`\n      let i : ℕ := E p x,\n      have hip : i < N p := ((E p) x).2,\n      have hiq : i < N q, by rwa Npq at hip,\n      have i' : i = ((E q) (Ψ x)), by { simp only [equiv.apply_symm_apply, fin.coe_cast] },\n      -- introduce `j`, that codes both `y` and `Φ y` in `fin (N p) = fin (N q)`\n      let j : ℕ := E p y,\n      have hjp : j < N p := ((E p) y).2,\n      have hjq : j < N q, by rwa Npq at hjp,\n      have j' : j = ((E q) (Ψ y)), by { simp only [equiv.apply_symm_apply, fin.coe_cast] },\n      -- Express `dist x y` in terms of `F p`\n      have Ap : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ⌊ε⁻¹ * dist x y⌋₊ := calc\n        ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F p).2 ((E p) x) ((E p) y)).1 :\n          by { congr; apply fin.ext_iff.2; refl }\n        ... = min M ⌊ε⁻¹ * dist x y⌋₊ :\n          by simp only [F, (E p).symm_apply_apply]\n        ... = ⌊ε⁻¹ * dist x y⌋₊ :\n        begin\n          refine min_eq_right (nat.floor_mono _),\n          refine mul_le_mul_of_nonneg_left (le_trans _ (le_max_left _ _)) ((inv_pos.2 εpos).le),\n          change dist (x : p.rep) y ≤ C,\n          refine le_trans (dist_le_diam_of_mem is_compact_univ.bounded (mem_univ _) (mem_univ _)) _,\n          exact hdiam p pt\n        end,\n      -- Express `dist (Φ x) (Φ y)` in terms of `F q`\n      have Aq : ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ := calc\n        ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ((F q).2 ((E q) (Ψ x)) ((E q) (Ψ y))).1 :\n          by { congr; apply fin.ext_iff.2; [exact i', exact j'] }\n        ... = min M ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ :\n          by simp only [F, (E q).symm_apply_apply]\n        ... = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ :\n        begin\n          refine min_eq_right (nat.floor_mono _),\n          refine mul_le_mul_of_nonneg_left (le_trans _ (le_max_left _ _)) ((inv_pos.2 εpos).le),\n          change dist (Ψ x : q.rep) (Ψ y) ≤ C,\n          refine le_trans (dist_le_diam_of_mem is_compact_univ.bounded (mem_univ _) (mem_univ _)) _,\n          exact hdiam q qt\n        end,\n      -- use the equality between `F p` and `F q` to deduce that the distances have equal\n      -- integer parts\n      have : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1,\n      { -- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works\n        -- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`\n        -- then `subst`\n        revert hiq hjq,\n        change N q with (F q).1,\n        generalize_hyp : F q = f at hpq ⊢,\n        subst hpq,\n        intros,\n        refl },\n      have : ⌊ε⁻¹ * dist x y⌋ = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋,\n      { rw [Ap, Aq] at this,\n        have D : 0 ≤ ⌊ε⁻¹ * dist x y⌋ :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg),\n        have D' : 0 ≤ ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋ :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg),\n        rw [← int.to_nat_of_nonneg D, ← int.to_nat_of_nonneg D', int.floor_to_nat,int.floor_to_nat,\n          this] },\n      -- deduce that the distances coincide up to `ε`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| =\n          |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| : (abs_mul _ _).symm\n        ... = |(ε⁻¹ * dist x y) - (ε⁻¹ * dist (Ψ x) (Ψ y))| : by { congr, ring }\n        ... ≤ 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (Ψ x) (Ψ y)| = (ε * ε⁻¹) * |dist x y - dist (Ψ x) (Ψ y)| :\n          by rw [mul_inv_cancel (ne_of_gt εpos), one_mul]\n        ... = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]\n        ... ≤ ε * 1 : mul_le_mul_of_nonneg_left I (le_of_lt εpos)\n        ... = ε : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... ≤ ε + ε/2 + ε : main\n    ... = δ/2 : by { simp only [ε, one_div], ring }\n    ... < δ : half_lt_self δpos\nend\n\nsection complete\n\n/- We will show that a sequence `u n` of compact metric spaces satisfying\n`dist (u n) (u (n+1)) < 1/2^n` converges, which implies completeness of the Gromov-Hausdorff space.\nWe need to exhibit the limiting compact metric space. For this, start from\na sequence `X n` of representatives of `u n`, and glue in an optimal way `X n` to `X (n+1)`\nfor all `n`, in a common metric space. Formally, this is done as follows.\nStart from `Y 0 = X 0`. Then, glue `X 0` to `X 1` in an optimal way, yielding a space\n`Y 1` (with an embedding of `X 1`). Then, consider an optimal gluing of `X 1` and `X 2`, and\nglue it to `Y 1` along their common subspace `X 1`. This gives a new space `Y 2`, with an\nembedding of `X 2`. Go on, to obtain a sequence of spaces `Y n`. Let `Z0` be the inductive\nlimit of the `Y n`, and finally let `Z` be the completion of `Z0`.\nThe images `X2 n` of `X n` in `Z` are at Hausdorff distance `< 1/2^n` by construction, hence they\nform a Cauchy sequence for the Hausdorff distance. By completeness (of `Z`, and therefore of its\nset of nonempty compact subsets), they converge to a limit `L`. This is the nonempty\ncompact metric space we are looking for.  -/\n\nvariables (X : ℕ → Type) [∀ n, metric_space (X n)] [∀ n, compact_space (X n)] [∀ n, nonempty (X n)]\n\n/-- Auxiliary structure used to glue metric spaces below, recording an isometric embedding\nof a type `A` in another metric space. -/\nstructure aux_gluing_struct (A : Type) [metric_space A] : Type 1 :=\n(space  : Type)\n(metric : metric_space space)\n(embed  : A → space)\n(isom   : isometry embed)\n\nlocal attribute [instance] aux_gluing_struct.metric\n\ninstance (A : Type) [metric_space A] : inhabited (aux_gluing_struct A) :=\n⟨{ space := A,\n  metric := by apply_instance,\n  embed := id,\n  isom := λ x y, rfl }⟩\n\n/-- Auxiliary sequence of metric spaces, containing copies of `X 0`, ..., `X n`, where each\n`X i` is glued to `X (i+1)` in an optimal way. The space at step `n+1` is obtained from the space\nat step `n` by adding `X (n+1)`, glued in an optimal way to the `X n` already sitting there. -/\ndef aux_gluing (n : ℕ) : aux_gluing_struct (X n) :=\nnat.rec_on n default $ λ n Y,\n  { space  := glue_space Y.isom (isometry_optimal_GH_injl (X n) (X (n+1))),\n    metric := by apply_instance,\n    embed  := (to_glue_r Y.isom (isometry_optimal_GH_injl (X n) (X (n+1))))\n              ∘ (optimal_GH_injr (X n) (X (n+1))),\n    isom   := (to_glue_r_isometry _ _).comp (isometry_optimal_GH_injr (X n) (X (n+1))) }\n\n/-- The Gromov-Hausdorff space is complete. -/\ninstance : complete_space GH_space :=\nbegin\n  have : ∀ (n : ℕ), 0 < ((1:ℝ) / 2) ^ n, by { apply pow_pos, norm_num },\n  -- start from a sequence of nonempty compact metric spaces within distance `1/2^n` of each other\n  refine metric.complete_of_convergent_controlled_sequences (λ n, (1/2)^n) this (λ u hu, _),\n  -- `X n` is a representative of `u n`\n  let X := λ n, (u n).rep,\n  -- glue them together successively in an optimal way, getting a sequence of metric spaces `Y n`\n  let Y := aux_gluing X,\n  -- this equality is true by definition but Lean unfolds some defs in the wrong order\n  have E : ∀ n : ℕ,\n    glue_space (Y n).isom (isometry_optimal_GH_injl (X n) (X (n + 1))) = (Y (n + 1)).space :=\n    λ n, by { dsimp only [Y, aux_gluing], refl },\n  let c := λ n, cast (E n),\n  have ic : ∀ n, isometry (c n) := λ n x y, by { dsimp only [Y, aux_gluing], exact rfl },\n  -- there is a canonical embedding of `Y n` in `Y (n+1)`, by construction\n  let f : Π n, (Y n).space → (Y (n + 1)).space :=\n    λ n, c n ∘ to_glue_l (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)),\n  have I : ∀ n, isometry (f n) := λ n, (ic n).comp (to_glue_l_isometry _ _),\n  -- consider the inductive limit `Z0` of the `Y n`, and then its completion `Z`\n  let Z0 := metric.inductive_limit I,\n  let Z := uniform_space.completion Z0,\n  let Φ := to_inductive_limit I,\n  let coeZ := (coe : Z0 → Z),\n  -- let `X2 n` be the image of `X n` in the space `Z`\n  let X2 := λ n, range (coeZ ∘ (Φ n) ∘ (Y n).embed),\n  have isom : ∀ n, isometry (coeZ ∘ (Φ n) ∘ (Y n).embed),\n  { assume n,\n    refine uniform_space.completion.coe_isometry.comp _,\n    exact (to_inductive_limit_isometry _ _).comp (Y n).isom },\n  -- The Hausdorff distance of `X2 n` and `X2 (n+1)` is by construction the distance between\n  -- `u n` and `u (n+1)`, therefore bounded by `1/2^n`\n  have D2 : ∀ n, Hausdorff_dist (X2 n) (X2 n.succ) < (1/2)^n,\n  { assume n,\n    have X2n : X2 n = range ((coeZ ∘ (Φ n.succ) ∘ (c n)\n      ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      ∘ (optimal_GH_injl (X n) (X n.succ))),\n    { change X2 n = range (coeZ ∘ (Φ n.succ) ∘ (c n)\n        ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)))\n        ∘ (optimal_GH_injl (X n) (X n.succ))),\n      simp only [X2, Φ],\n      rw [← to_inductive_limit_commute I],\n      simp only [f],\n      rw ← to_glue_commute },\n    rw range_comp at X2n,\n    have X2nsucc : X2 n.succ = range ((coeZ ∘ (Φ n.succ) ∘ (c n)\n      ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      ∘ (optimal_GH_injr (X n) (X n.succ))), by refl,\n    rw range_comp at X2nsucc,\n    rw [X2n, X2nsucc, Hausdorff_dist_image, Hausdorff_dist_optimal, ← dist_GH_dist],\n    { exact hu n n n.succ (le_refl n) (le_succ n) },\n    { apply uniform_space.completion.coe_isometry.comp _,\n      exact (to_inductive_limit_isometry _ _).comp ((ic n).comp (to_glue_r_isometry _ _)) } },\n  -- consider `X2 n` as a member `X3 n` of the type of nonempty compact subsets of `Z`, which\n  -- is a metric space\n  let X3 : ℕ → nonempty_compacts Z := λ n,\n    ⟨⟨X2 n, is_compact_range (isom n).continuous⟩, range_nonempty _⟩,\n  -- `X3 n` is a Cauchy sequence by construction, as the successive distances are\n  -- bounded by `(1/2)^n`\n  have : cauchy_seq X3,\n  { refine cauchy_seq_of_le_geometric (1/2) 1 (by norm_num) (λ n, _),\n    rw one_mul,\n    exact le_of_lt (D2 n) },\n  -- therefore, it converges to a limit `L`\n  rcases cauchy_seq_tendsto_of_complete this with ⟨L, hL⟩,\n  -- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L`\n  have M : tendsto (λ n, (X3 n).to_GH_space) at_top (𝓝 L.to_GH_space) :=\n    tendsto.comp (to_GH_space_continuous.tendsto _) hL,\n  -- By construction, the image of `X3 n` in the Gromov-Hausdorff space is `u n`.\n  have : ∀ n, (X3 n).to_GH_space = u n,\n  { assume n,\n    rw [nonempty_compacts.to_GH_space, ← (u n).to_GH_space_rep,\n        to_GH_space_eq_to_GH_space_iff_isometry_equiv],\n    constructor,\n    convert (isom n).isometry_equiv_on_range.symm, },\n  -- Finally, we have proved the convergence of `u n`\n  exact ⟨L.to_GH_space, by simpa only [this] using M⟩\nend\n\nend complete--section\n\nend Gromov_Hausdorff --namespace\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/metric_space/gromov_hausdorff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.47144276616433883}}
{"text": "import category_theory.category.default\nimport category_theory.isomorphism\n\nuniverses v u  -- The order in this declaration matters: v often needs to be explicitly specified while u often can be omitted\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n--rewrite this\n\n/-\n# Category world\n\n## Level 1: Isomorphisms\n\nAn isomorphism `f : X ⟶ Y` is a morphism for which there exists a morphism `g : Y ⟶ X`, such that `f ≫ g = 𝟙 X` and `g ≫ f = 𝟙 Y`.\n-/\n\n\n/- Lemma\nIf $$f : X ⟶ Y$$ and $$g : X ⟶ Y$$ are morphisms such that $$f = g$$, then $$f ≫ h = g ≫ h$$.\n-/\nlemma cancel_right_iso' {X Y Z : C} (f : X ⟶ Y) [is_iso f] {g h : Y ⟶ Z} : (f ≫ g = f ≫ h) ↔ g = h :=\nbegin\n    split,\n\n    intro hyp,\n    rw ← category.id_comp g,\n    rw ← category.id_comp h,\n    rw ← is_iso.inv_hom_id f,\n    rw category.assoc,\n    rw hyp,\n    rw category.assoc,\n\n    intro hyp,\n    rw hyp,\nend\n\nend category_theory", "meta": {"author": "agusakov", "repo": "category-theory-game", "sha": "652dd7e90ae706643b2a597e2c938403653e167d", "save_path": "github-repos/lean/agusakov-category-theory-game", "path": "github-repos/lean/agusakov-category-theory-game/category-theory-game-652dd7e90ae706643b2a597e2c938403653e167d/src/game/world2/level2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4713379136213371}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport linear_algebra.finite_dimensional\nimport geometry.manifold.smooth_manifold_with_corners\nimport analysis.inner_product_space.pi_L2\n\n/-!\n# Constructing examples of manifolds over ℝ\n\nWe introduce the necessary bits to be able to define manifolds modelled over `ℝ^n`, boundaryless\nor with boundary or with corners. As a concrete example, we construct explicitly the manifold with\nboundary structure on the real interval `[x, y]`.\n\nMore specifically, we introduce\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)` for the model space\n  used to define `n`-dimensional real manifolds with boundary\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n)` for the model space used\n  to define `n`-dimensional real manifolds with corners\n\n## Notations\n\nIn the locale `manifold`, we introduce the notations\n* `𝓡 n` for the identity model with corners on `euclidean_space ℝ (fin n)`\n* `𝓡∂ n` for `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space ℝ (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M → N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (𝓡 m) (𝓡∂ n) f` (as to why the\nmodel with corners can not be implicit, see the discussion in `smooth_manifold_with_corners.lean`).\n\n## Implementation notes\n\nThe manifold structure on the interval `[x, y] = Icc x y` requires the assumption `x < y` as a\ntypeclass. We provide it as `[fact (x < y)]`.\n-/\n\nnoncomputable theory\nopen set function\nopen_locale manifold\nlocal attribute [instance] fact_one_le_two_real\n\n/--\nThe half-space in `ℝ^n`, used to model manifolds with boundary. We only define it when\n`1 ≤ n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : ℕ) [has_zero (fin n)] : Type :=\n{x : euclidean_space ℝ (fin n) // 0 ≤ x 0}\n\n/--\nThe quadrant in `ℝ^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : ℕ) : Type := {x : euclidean_space ℝ (fin n) // ∀i:fin n, 0 ≤ x i}\n\nsection\n/- Register class instances for euclidean half-space and quadrant, that can not be noticed\nwithout the following reducibility attribute (which is only set in this section). -/\nlocal attribute [reducible] euclidean_half_space euclidean_quadrant\nvariable {n : ℕ}\n\ninstance [has_zero (fin n)] : topological_space (euclidean_half_space n) := by apply_instance\ninstance : topological_space (euclidean_quadrant n) := by apply_instance\ninstance [has_zero (fin n)] : inhabited (euclidean_half_space n) := ⟨⟨0, le_refl _⟩⟩\ninstance : inhabited (euclidean_quadrant n) := ⟨⟨0, λ i, le_refl _⟩⟩\n\nlemma range_half_space (n : ℕ) [has_zero (fin n)] :\n  range (λx : euclidean_half_space n, x.val) = {y | 0 ≤ y 0} :=\nby simp\n\nlemma range_quadrant (n : ℕ) :\n  range (λx : euclidean_quadrant n, x.val) = {y | ∀i:fin n, 0 ≤ y i} :=\nby simp\n\nend\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_half_space n)`, used as\na model for manifolds with boundary. In the locale `manifold`, use the shortcut `𝓡∂ n`.\n-/\ndef model_with_corners_euclidean_half_space (n : ℕ) [has_zero (fin n)] :\n  model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := λx, ⟨update x 0 (max (x 0) 0), by simp [le_refl]⟩,\n  source      := univ,\n  target      := {x | 0 ≤ x 0},\n  map_source' := λx hx, x.property,\n  map_target' := λx hx, mem_univ _,\n  left_inv'   := λ ⟨xval, xprop⟩ hx, begin\n    rw [subtype.mk_eq_mk, update_eq_iff],\n    exact ⟨max_eq_left xprop, λ i _, rfl⟩\n  end,\n  right_inv'  := λx hx, update_eq_iff.2 ⟨max_eq_left hx, λ i _, rfl⟩,\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on ℝ _ :=\n      unique_diff_on.pi (fin n) (λ _, ℝ) _ _ (λ i ∈ ({0} : set (fin n)), unique_diff_on_Ici 0),\n    by simpa only [singleton_pi] using this,\n  continuous_to_fun  := continuous_subtype_val,\n  continuous_inv_fun := continuous_subtype_mk _ $ continuous_id.update 0 $\n    (continuous_apply 0).max continuous_const }\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : ℕ) :\n  model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := λx, ⟨λi, max (x i) 0, λi, by simp only [le_refl, or_true, le_max_iff]⟩,\n  source      := univ,\n  target      := {x | ∀ i, 0 ≤ x i},\n  map_source' := λx hx, by simpa only [subtype.range_val] using x.property,\n  map_target' := λx hx, mem_univ _,\n  left_inv'   := λ ⟨xval, xprop⟩ hx, by { ext i, simp only [subtype.coe_mk, xprop i, max_eq_left] },\n  right_inv' := λ x hx, by { ext1 i, simp only [hx i, max_eq_left] },\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on ℝ _ :=\n      unique_diff_on.univ_pi (fin n) (λ _, ℝ) _ (λ i, unique_diff_on_Ici 0),\n    by simpa only [pi_univ_Ici] using this,\n  continuous_to_fun  := continuous_subtype_val,\n  continuous_inv_fun := continuous_subtype_mk _ $ continuous_pi $ λ i,\n    (continuous_id.max continuous_const).comp (continuous_apply i) }\n\nlocalized \"notation `𝓡 `n := model_with_corners_self ℝ (euclidean_space ℝ (fin n))\" in manifold\nlocalized \"notation `𝓡∂ `n := model_with_corners_euclidean_half_space n\" in manifold\n\n/--\nThe left chart for the topological space `[x, y]`, defined on `[x,y)` and sending `x` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_left_chart (x y : ℝ) [fact (x < y)] :\n  local_homeomorph (Icc x y) (euclidean_half_space 1) :=\n{ source      := {z : Icc x y | z.val < y},\n  target      := {z : euclidean_half_space 1 | z.val 0 < y - x},\n  to_fun      := λ(z : Icc x y), ⟨λi, z.val - x, sub_nonneg.mpr z.property.1⟩,\n  inv_fun     := λz, ⟨min (z.val 0 + x) y, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y))]⟩,\n  map_source' := by simp only [imp_self, sub_lt_sub_iff_right, mem_set_of_eq, forall_true_iff],\n  map_target' :=\n    by { simp only [min_lt_iff, mem_set_of_eq], assume z hz, left,\n         dsimp [-subtype.val_eq_coe] at hz, linarith },\n  left_inv'   := begin\n    rintros ⟨z, hz⟩ h'z,\n    simp only [mem_set_of_eq, mem_Icc] at hz h'z,\n    simp only [hz, min_eq_left, sub_add_cancel]\n  end,\n  right_inv'  := begin\n    rintros ⟨z, hz⟩ h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x + z 0 ≤ y, by linarith,\n    rw subsingleton.elim i 0,\n    simp only [A, add_comm, add_sub_cancel', min_eq_left],\n  end,\n  open_source := begin\n    have : is_open {z : ℝ | z < y} := is_open_Iio,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : ℝ | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space ℝ (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (λ _, ℝ) _ 0),\n    exact this.preimage continuous_subtype_val\n  end,\n  continuous_to_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have : continuous (λ (z : ℝ) (i : fin 1), z - x) :=\n      continuous.sub (continuous_pi $ λi, continuous_id) continuous_const,\n    exact this.comp continuous_subtype_val,\n  end,\n  continuous_inv_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have A : continuous (λ z : ℝ, min (z + x) y) :=\n      (continuous_id.add continuous_const).min continuous_const,\n    have B : continuous (λz : euclidean_space ℝ (fin 1), z 0) := continuous_apply 0,\n    exact (A.comp B).comp continuous_subtype_val\n  end }\n\n/--\nThe right chart for the topological space `[x, y]`, defined on `(x,y]` and sending `y` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_right_chart (x y : ℝ) [fact (x < y)] :\n  local_homeomorph (Icc x y) (euclidean_half_space 1) :=\n{ source      := {z : Icc x y | x < z.val},\n  target      := {z : euclidean_half_space 1 | z.val 0 < y - x},\n  to_fun      := λ(z : Icc x y), ⟨λi, y - z.val, sub_nonneg.mpr z.property.2⟩,\n  inv_fun     := λz,\n    ⟨max (y - z.val 0) x, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y)), sub_eq_add_neg]⟩,\n  map_source' := by simp only [imp_self, mem_set_of_eq, sub_lt_sub_iff_left, forall_true_iff],\n  map_target' :=\n    by { simp only [lt_max_iff, mem_set_of_eq], assume z hz, left,\n         dsimp [-subtype.val_eq_coe] at hz, linarith },\n  left_inv'   := begin\n    rintros ⟨z, hz⟩ h'z,\n    simp only [mem_set_of_eq, mem_Icc] at hz h'z,\n    simp only [hz, sub_eq_add_neg, max_eq_left, add_add_neg_cancel'_right, neg_add_rev, neg_neg]\n  end,\n  right_inv'  := begin\n    rintros ⟨z, hz⟩ h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x ≤ y - z 0, by linarith,\n    rw subsingleton.elim i 0,\n    simp only [A, sub_sub_cancel, max_eq_left],\n  end,\n  open_source := begin\n    have : is_open {z : ℝ | x < z} := is_open_Ioi,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : ℝ | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space ℝ (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (λ _, ℝ) _ 0),\n    exact this.preimage continuous_subtype_val\n  end,\n  continuous_to_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have : continuous (λ (z : ℝ) (i : fin 1), y - z) :=\n      continuous_const.sub (continuous_pi (λi, continuous_id)),\n    exact this.comp continuous_subtype_val,\n  end,\n  continuous_inv_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have A : continuous (λ z : ℝ, max (y - z) x) :=\n      (continuous_const.sub continuous_id).max continuous_const,\n    have B : continuous (λz : euclidean_space ℝ (fin 1), z 0) := continuous_apply 0,\n    exact (A.comp B).comp continuous_subtype_val\n  end }\n\n/--\nCharted space structure on `[x, y]`, using only two charts taking values in\n`euclidean_half_space 1`.\n-/\ninstance Icc_manifold (x y : ℝ) [fact (x < y)] : charted_space (euclidean_half_space 1) (Icc x y) :=\n{ atlas := {Icc_left_chart x y, Icc_right_chart x y},\n  chart_at := λz, if z.val < y then Icc_left_chart x y else Icc_right_chart x y,\n  mem_chart_source := λz, begin\n    by_cases h' : z.val < y,\n    { simp only [h', if_true],\n      exact h' },\n    { simp only [h', if_false],\n      apply lt_of_lt_of_le (fact.out (x < y)),\n      simpa only [not_lt] using h'}\n  end,\n  chart_mem_atlas := λz, by { by_cases h' : z.val < y; simp [h'] } }\n\n/--\nThe manifold structure on `[x, y]` is smooth.\n-/\ninstance Icc_smooth_manifold (x y : ℝ) [fact (x < y)] :\n  smooth_manifold_with_corners (𝓡∂ 1) (Icc x y) :=\nbegin\n  have M : times_cont_diff_on ℝ ∞ (λz : euclidean_space ℝ (fin 1), - z + (λi, y - x)) univ,\n  { rw times_cont_diff_on_univ,\n    exact times_cont_diff_id.neg.add times_cont_diff_const },\n  apply smooth_manifold_with_corners_of_times_cont_diff_on,\n  assume e e' he he',\n  simp only [atlas, mem_singleton_iff, mem_insert_iff] at he he',\n  /- We need to check that any composition of two charts gives a `C^∞` function. Each chart can be\n  either the left chart or the right chart, leaving 4 possibilities that we handle successively.\n  -/\n  rcases he with rfl | rfl; rcases he' with rfl | rfl,\n  { -- `e = left chart`, `e' = left chart`\n    exact (mem_groupoid_of_pregroupoid.mpr (symm_trans_mem_times_cont_diff_groupoid _ _ _)).1 },\n  { -- `e = left chart`, `e' = right chart`\n    apply M.congr_mono _ (subset_univ _),\n    rintro _ ⟨⟨hz₁, hz₂⟩, ⟨⟨z, hz₀⟩, rfl⟩⟩,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      update_same, max_eq_left, hz₀, lt_sub_iff_add_lt] with mfld_simps at hz₁ hz₂,\n    rw [min_eq_left hz₁.le, lt_add_iff_pos_left] at hz₂,\n    ext i,\n    rw subsingleton.elim i 0,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart, *,\n      pi_Lp.add_apply, pi_Lp.neg_apply, max_eq_left, min_eq_left hz₁.le, update_same]\n      with mfld_simps,\n    abel },\n  { -- `e = right chart`, `e' = left chart`\n    apply M.congr_mono _ (subset_univ _),\n    rintro _ ⟨⟨hz₁, hz₂⟩, ⟨z, hz₀⟩, rfl⟩,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart, max_lt_iff,\n      update_same, max_eq_left hz₀] with mfld_simps at hz₁ hz₂,\n    rw lt_sub at hz₁,\n    ext i,\n    rw subsingleton.elim i 0,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      pi_Lp.add_apply, pi_Lp.neg_apply, update_same, max_eq_left, hz₀, hz₁.le] with mfld_simps,\n    abel },\n  { -- `e = right chart`, `e' = right chart`\n    exact (mem_groupoid_of_pregroupoid.mpr (symm_trans_mem_times_cont_diff_groupoid _ _ _)).1 }\nend\n\n/-! Register the manifold structure on `Icc 0 1`, and also its zero and one. -/\nsection\n\nlemma fact_zero_lt_one : fact ((0 : ℝ) < 1) := ⟨zero_lt_one⟩\n\nlocal attribute [instance] fact_zero_lt_one\n\ninstance : charted_space (euclidean_half_space 1) (Icc (0 : ℝ) 1) := by apply_instance\ninstance : smooth_manifold_with_corners (𝓡∂ 1) (Icc (0 : ℝ) 1) := by apply_instance\n\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/geometry/manifold/instances/real.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.471337913621337}}
{"text": "/-\nCopyright (c) 2021 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Anne Baanen\n-/\nimport algebra.big_operators.finsupp\nimport algebra.floor\nimport algebraic_number_theory.class_number.admissible_absolute_value\nimport algebraic_number_theory.function_field\nimport algebraic_number_theory.number_field\nimport data.polynomial.field_division\nimport group_theory.quotient_group\nimport linear_algebra.determinant\nimport linear_algebra.free_module\nimport linear_algebra.matrix\nimport ring_theory.class_group\nimport ring_theory.dedekind_domain\nimport ring_theory.fractional_ideal\nimport algebraic_number_theory.class_number.det\nimport algebraic_number_theory.class_number.integral_closure\n\n/-!\n# Class numbers of global fields\n\nIn this file, we use the notion of \"admissible absolute value\" to prove\nfiniteness of the class group for number fields and function fields,\nand define `class_number` as the order of this group.\n\n## Main definitions\n\n - `class_group.fintype_of_admissible`: if `R` has an admissible absolute value,\n   its integral closure has a finite class group\n - `number_field.class_number`: the class number of a number field is the (finite)\n   cardinality of the class group of its ring of integers\n - `function_field.class_number`: the class number of a number field is the (finite)\n   cardinality of the class group of its ring of integers\n-/\n\nnamespace class_group\n\nopen ring\n\nopen_locale big_operators\n\nsection euclidean_domain\n\nvariables {R K L : Type*} [euclidean_domain R] [field K] [field L]\nvariables (f : fraction_map R K)\nvariables [algebra f.codomain L] [finite_dimensional f.codomain L] [is_separable f.codomain L]\nvariables [algebra R L] [is_scalar_tower R f.codomain L]\n\nvariables (L)\n\nlemma integral_closure.dim_pos : 0 < integral_closure.dim L f :=\nby { rw [← fintype.card_fin (integral_closure.dim L f), fintype.card_pos_iff],\n     exact is_basis.nonempty_of_nontrivial (integral_closure.is_basis L f) }\n\n/-- If `a : integral_closure R L` has coordinates `≤ y`, `norm a ≤ norm_bound L f abs * y ^ n`. -/\nnoncomputable def norm_bound (abs : absolute_value R ℤ) : ℤ :=\nlet n := integral_closure.dim L f,\n    h : 0 < integral_closure.dim L f := integral_closure.dim_pos L f,\n    m : ℤ := finset.max' (finset.univ.image (λ (ijk : fin _ × fin _ × fin _),\n        abs (matrix.lmul\n               (integral_closure.is_basis L f)\n               (integral_closure.basis L f ijk.1)\n               ijk.2.1\n               ijk.2.2)))\n        ⟨_, finset.mem_image.mpr ⟨⟨⟨0, h⟩, ⟨0, h⟩, ⟨0, h⟩⟩, finset.mem_univ _, rfl⟩⟩\nin nat.factorial n • (n • m) ^ n\n\nlemma norm_bound_pos (abs : absolute_value R ℤ) : 0 < norm_bound L f abs :=\nbegin\n  obtain ⟨i, j, k, hijk⟩ : ∃ i j k,\n    matrix.lmul (integral_closure.is_basis L f) (integral_closure.basis L f i) j k ≠ 0,\n  { by_contra h,\n    push_neg at h,\n    apply (integral_closure.is_basis L f).ne_zero ⟨0, integral_closure.dim_pos L f⟩,\n    apply (matrix.lmul _).injective_iff.mp (matrix.lmul_injective (integral_closure.is_basis L f)),\n    ext j k,\n    rw [h, matrix.zero_apply] },\n  simp only [norm_bound, algebra.smul_def, ring_hom.eq_nat_cast, int.nat_cast_eq_coe_nat],\n  apply mul_pos (int.coe_nat_pos.mpr (nat.factorial_pos _)),\n  apply pow_pos (mul_pos (int.coe_nat_pos.mpr (integral_closure.dim_pos L f)) _),\n  apply lt_of_lt_of_le (abs.pos hijk) (finset.le_max' _ _ _),\n  exact finset.mem_image.mpr ⟨⟨i, j, k⟩, finset.mem_univ _, rfl⟩\nend\n\nlemma norm_bound_ne_zero (abs : absolute_value R ℤ) : norm_bound L f abs ≠ 0 :=\nne_of_gt (norm_bound_pos L f abs)\n\nlemma norm_le (a : integral_closure R L) {abs : absolute_value R ℤ}\n  {y : ℤ} (hy : ∀ k, abs ((integral_closure.is_basis L f).repr a k) ≤ y) :\n  abs_norm f abs a ≤ norm_bound L f abs * y ^ (integral_closure.dim L f) :=\nbegin\n  conv_lhs { rw ← sum_repr (integral_closure.is_basis L f) a },\n  unfold abs_norm algebra.norm norm_bound,\n  rw [monoid_hom.coe_mk, matrix.to_matrix_lmul_eq],\n  simp only [alg_hom.map_sum, alg_hom.map_smul],\n  convert det_sum_le finset.univ _ hy;\n    try { simp only [finset.card_univ, fintype.card_fin] },\n  { rw [algebra.smul_mul_assoc, ← mul_pow _ _ (integral_closure.dim L f)],\n    conv_lhs { rw algebra.smul_mul_assoc } },\n  { intros i j k,\n    apply finset.le_max',\n    exact finset.mem_image.mpr ⟨⟨i, j, k⟩, finset.mem_univ _, rfl⟩ },\nend\n\nlemma norm_lt {S : Type*} [linear_ordered_comm_ring S]\n  (a : integral_closure R L) {abs : absolute_value R ℤ}\n  {y : S} (hy : ∀ k, (abs ((integral_closure.is_basis L f).repr a k) : S) < y) :\n  (abs_norm f abs a : S) < norm_bound L f abs * y ^ (integral_closure.dim L f) :=\nbegin\n  have h : 0 < integral_closure.dim L f := integral_closure.dim_pos L f,\n  have him : (finset.univ.image (λ k, abs ((integral_closure.is_basis L f).repr a k))).nonempty :=\n    ⟨_, finset.mem_image.mpr ⟨⟨0, h⟩, finset.mem_univ _, rfl⟩⟩,\n  set y' : ℤ := finset.max' _ him with y'_def,\n  have hy' : ∀ k, abs ((integral_closure.is_basis L f).repr a k) ≤ y',\n  { intro k,\n    exact finset.le_max' _ _ (finset.mem_image.mpr ⟨k, finset.mem_univ _, rfl⟩) },\n  have : (y' : S) < y,\n  { rw [y'_def, finset.map_max' (show monotone (coe : ℤ → S), from λ x y h, int.cast_le.mpr h)],\n    apply finset.max'_lt _ (him.image _),\n    simp only [finset.mem_image, exists_prop],\n    rintros _ ⟨x, ⟨k, -, rfl⟩, rfl⟩,\n    exact hy k },\n  have y'_nonneg : 0 ≤ y' := le_trans (abs.nonneg _) (hy' ⟨0, h⟩),\n  apply lt_of_le_of_lt (int.cast_le.mpr (norm_le L f a hy')),\n  simp only [int.cast_mul, int.cast_pow],\n  apply mul_lt_mul' (le_refl _),\n  { exact pow_lt_pow_of_lt_left this (int.cast_nonneg.mpr y'_nonneg) h },\n  { exact pow_nonneg (int.cast_nonneg.mpr y'_nonneg) _ },\n  { exact int.cast_pos.mpr (norm_bound_pos L f abs) },\n  { apply_instance }\nend\n\nsection\n\nvariables (L)\nvariables (abs : admissible_absolute_value R)\n\nopen admissible_absolute_value\n\ninclude L f abs\n\n/-- The `M` from the proof of thm 5.4.\n\nShould really be `abs.card (nat.ceil_nth_root _ _)`, but nth_root _ x ≤ x so this works too.\n-/\nnoncomputable def cardM : ℕ :=\n(abs.card (norm_bound L f abs ^ (-1 / (integral_closure.dim L f) : ℝ)))^(integral_closure.dim L f)\n\nvariables [infinite R]\n\n/-- In the following results, we need a large set of distinct elements of `R`. -/\nnoncomputable def distinct_elems : fin (cardM L f abs).succ ↪ R :=\nfunction.embedding.trans (fin.coe_embedding _).to_embedding (infinite.nat_embedding R)\n\n/-- `finset_approx` is a finite set such that each fractional ideal in the integral closure\ncontains an element close to `finset_approx`. -/\nnoncomputable def finset_approx [decidable_eq R] : finset R :=\n((finset.univ.product finset.univ)\n  .image (λ (xy : fin _ × fin _), distinct_elems L f abs xy.1 - distinct_elems L f abs xy.2))\n  .erase 0\n\nlemma finset_approx.zero_not_mem [decidable_eq R] : (0 : R) ∉ finset_approx L f abs :=\nfinset.not_mem_erase _ _\n\n@[simp] lemma mem_finset_approx [decidable_eq R] {x : R} :\n  x ∈ finset_approx L f abs ↔\n  ∃ i j, i ≠ j ∧ distinct_elems L f abs i - distinct_elems L f abs j = x :=\nbegin\n  simp only [finset_approx, finset.mem_erase, finset.mem_image],\n  split,\n  { rintros ⟨hx, ⟨i, j⟩, _, rfl⟩,\n    refine ⟨i, j, _, rfl⟩,\n    rintro rfl,\n    simpa using hx },\n  { rintros ⟨i, j, hij, rfl⟩,\n    refine ⟨_, ⟨i, j⟩, finset.mem_product.mpr ⟨finset.mem_univ _, finset.mem_univ _⟩, rfl⟩,\n    rw [ne.def, sub_eq_zero],\n    exact λ h, hij ((distinct_elems L f abs).injective h) }\nend\n\nsection\n\nopen real\n\nlocal attribute [-instance] real.decidable_eq\n\n/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/\ntheorem exists_mem_finset_approx [decidable_eq R]\n  (a : integral_closure R L) {b} (hb : b ≠ (0 : R)) :\n  ∃ (q : integral_closure R L) (r ∈ finset_approx L f abs),\n    abs_norm f abs (r • a - b • q) < abs_norm f abs (algebra_map R (integral_closure R L) b) :=\nbegin\n  set ε : ℝ := norm_bound L f abs ^ (-1 / (integral_closure.dim L f) : ℝ) with ε_eq,\n  have hε : 0 < ε := real.rpow_pos_of_pos (int.cast_pos.mpr (norm_bound_pos L f abs)) _,\n  have ε_le : (norm_bound L f abs : ℝ) * (abs b • ε) ^ integral_closure.dim L f ≤\n                (abs b ^ integral_closure.dim L f),\n  { have := integral_closure.dim_pos L f,\n    have := norm_bound_pos L f abs,\n    have := abs.nonneg b,\n    rw [ε_eq, algebra.smul_def, ring_hom.eq_int_cast, ← rpow_nat_cast, mul_rpow, ← rpow_mul,\n        div_mul_cancel, rpow_neg_one, mul_left_comm, mul_inv_cancel, mul_one, rpow_nat_cast];\n      try { norm_cast, linarith },\n    { apply rpow_nonneg_of_nonneg,\n      norm_cast,\n      linarith } },\n  let μ : fin (cardM L f abs).succ ↪ R := distinct_elems L f abs,\n  set s := (integral_closure.is_basis L f).repr a,\n  have s_eq : ∀ i, s i = (integral_closure.is_basis L f).repr a i := λ i, rfl,\n  set qs := λ j i, (μ j * s i) / b,\n  have q_eq : ∀ j i, qs j i = (μ j * s i) / b := λ i j, rfl,\n  set rs := λ j i, (μ j * s i) % b with r_eq,\n  have r_eq : ∀ j i, rs j i = (μ j * s i) % b := λ i j, rfl,\n  set c := integral_closure.basis L f,\n  have c_eq : ∀ i, c i = integral_closure.basis L f i := λ i, rfl,\n  have μ_eq : ∀ i j, μ j * s i = b * qs j i + rs j i,\n  { intros i j,\n    rw [q_eq, r_eq, euclidean_domain.div_add_mod], },\n  have μ_mul_a_eq : ∀ j, μ j • a = b • ∑ i, qs j i • c i + ∑ i, rs j i • c i,\n  { intro j,\n    rw ← sum_repr (integral_closure.is_basis L f) a,\n    simp only [finset.smul_sum, ← finset.sum_add_distrib],\n    refine finset.sum_congr rfl (λ i _, _),\n    rw [← c_eq, ← s_eq, ← mul_smul, μ_eq, add_smul, mul_smul] },\n\n  obtain ⟨j, k, j_ne_k, hjk⟩ :=\n    abs.exists_approx (integral_closure.dim L f) hε hb (λ j i, μ j * s i),\n  have hjk' : ∀ i, (abs (rs k i - rs j i) : ℝ) < abs b • ε,\n  { simpa only [r_eq] using hjk },\n  set q := ∑ i, (qs k i - qs j i) • c i with q_eq,\n  set r := μ k - μ j with r_eq,\n  refine ⟨q, r, (mem_finset_approx L f abs).mpr _, _⟩,\n  { exact ⟨k, j, j_ne_k.symm, rfl⟩ },\n  have : r • a - b • q = (∑ (x : fin (integral_closure.dim L f)), (rs k x • c x - rs j x • c x)),\n  { simp only [r_eq, sub_smul, μ_mul_a_eq, q_eq, finset.smul_sum, ← finset.sum_add_distrib,\n               ← finset.sum_sub_distrib, smul_sub],\n    refine finset.sum_congr rfl (λ x _, _),\n    ring },\n  rw [this, abs_norm_algebra_map],\n\n  refine int.cast_lt.mp (lt_of_lt_of_le (norm_lt L f _ (λ i, lt_of_le_of_lt _ (hjk' i))) _),\n  { apply le_of_eq,\n    congr,\n    simp_rw [linear_map.map_sum, linear_map.map_sub, linear_map.map_smul,\n             finset.sum_apply', finsupp.sub_apply, finsupp.smul_apply',\n             finset.sum_sub_distrib, is_basis.repr_self_apply, smul_eq_mul, mul_boole,\n             finset.sum_ite_eq', finset.mem_univ, if_true] },\n  { exact_mod_cast ε_le },\nend\n\n/-- We can approximate `a / b : L` with `q / r`, where `r` has finitely many options for `L`. -/\ntheorem exists_mem_finset_approx' [decidable_eq R]\n  (a : integral_closure R L) {b} (hb : b ≠ (0 : integral_closure R L)) :\n  ∃ (q : integral_closure R L) (r ∈ finset_approx L f abs),\n  abs_norm f abs (r • a - q * b) < abs_norm f abs b :=\nbegin\n  obtain ⟨a', b', hb', h⟩ := exists_eq_mul f a b hb,\n  obtain ⟨q, r, hr, hqr⟩ := exists_mem_finset_approx L f abs a' hb',\n  refine ⟨q, r, hr, _⟩,\n  apply lt_of_mul_lt_mul_left _\n    (show 0 ≤ abs_norm f abs (algebra_map R (integral_closure R L) b'), from abs.nonneg _),\n  refine lt_of_le_of_lt (le_of_eq _) (mul_lt_mul hqr (le_refl (abs_norm f abs b))\n    (abs.pos ((algebra.norm_ne_zero _).mpr hb)) (abs.nonneg _)),\n  rw [← abs_norm_mul, ← abs_norm_mul, ← algebra.smul_def, smul_sub b', sub_mul, smul_comm, h,\n      mul_comm b a', algebra.smul_mul_assoc r a' b, algebra.smul_mul_assoc b' q b]\nend\n\nend\n\nend\n\nend euclidean_domain\n\nlemma monoid_hom.range_eq_top {G H : Type*} [group G] [group H] (f : G →* H) :\n  f.range = ⊤ ↔ function.surjective f :=\n⟨ λ h y, show y ∈ f.range, from h.symm ▸ subgroup.mem_top y,\n  λ h, subgroup.ext (λ x, by simp [h x]) ⟩\n\nsection euclidean_domain\n\nvariables {R K L : Type*} [euclidean_domain R]\nvariables [field K] [field L]\nvariables (f : fraction_map R K)\nvariables [algebra f.codomain L]\nvariables [algebra R L] [is_scalar_tower R f.codomain L]\nvariables (abs : admissible_absolute_value R)\n\n/-- A nonzero ideal has an element of minimal norm. -/\nlemma exists_min [finite_dimensional f.codomain L] [is_separable f.codomain L]\n  (I : nonzero_ideal (integral_closure R L)) :\n  ∃ b ∈ I.1, b ≠ 0 ∧ ∀ c ∈ I.1, abs_norm f abs c < abs_norm f abs b → c = 0 :=\nbegin\n  haveI := classical.dec_eq L,\n  obtain ⟨_, ⟨b, b_mem, b_ne_zero, rfl⟩, min⟩ :=\n    @int.exists_least_of_bdd (λ a, ∃ b ∈ I.1, b ≠ 0 ∧ abs_norm f abs b = a) _ _,\n  { use [b, b_mem, b_ne_zero],\n    intros c hc lt,\n    by_contra c_ne_zero,\n    exact not_le_of_gt lt (min _ ⟨c, hc, c_ne_zero, rfl⟩) },\n  { use 0,\n    rintros _ ⟨b, b_mem, b_ne_zero, rfl⟩,\n    apply abs.nonneg },\n  { obtain ⟨b, b_mem, b_ne_zero⟩ := I.1.ne_bot_iff.mp I.2,\n    exact ⟨_, ⟨b, b_mem, b_ne_zero, rfl⟩⟩ }\nend\n\nlemma is_scalar_tower.algebra_map_injective {R S T : Type*}\n  [comm_semiring R] [comm_semiring S] [comm_semiring T]\n  [algebra R S] [algebra S T] [algebra R T]\n  [is_scalar_tower R S T]\n  (hRS : function.injective (algebra_map R S)) (hST : function.injective (algebra_map S T)) :\n  function.injective (algebra_map R T) :=\nby { rw is_scalar_tower.algebra_map_eq R S T, exact hST.comp hRS }\n\nlemma subalgebra.algebra_map_injective {R S : Type*} [comm_semiring R] [comm_semiring S]\n  [algebra R S] (A : subalgebra R S) (h : function.injective (algebra_map R S)) :\n  function.injective (algebra_map R A) :=\nbegin\n  intros x y hxy,\n  apply h,\n  simp only [is_scalar_tower.algebra_map_apply R A S],\n  exact congr_arg (coe : A → S) hxy\nend\n\nlemma integral_closure.algebra_map_injective :\n  function.injective (algebra_map R (integral_closure R L)) :=\n(subalgebra.algebra_map_injective _\n  (is_scalar_tower.algebra_map_injective\n    (show function.injective (algebra_map R f.codomain), from f.injective)\n    (algebra_map f.codomain L).injective))\n\nlemma cancel_monoid_with_zero.dvd_of_mul_dvd_mul_left {G₀ : Type*} [cancel_monoid_with_zero G₀]\n  {a b c : G₀} (ha : a ≠ 0) (h : a * b ∣ a * c) :\n  b ∣ c :=\nbegin\n  obtain ⟨d, hd⟩ := h,\n  refine ⟨d, mul_left_cancel' ha _⟩,\n  rwa mul_assoc at hd\nend\n\nlemma ideal.dvd_of_mul_dvd_mul_left {R : Type*} [integral_domain R] [is_dedekind_domain R]\n  {I J K : ideal R} (hI : I ≠ ⊥)\n  (h : I * J ∣ I * K) :\n  J ∣ K :=\ncancel_monoid_with_zero.dvd_of_mul_dvd_mul_left hI h\n\nlemma ideal.span_singleton_ne_bot {R : Type*} [comm_ring R] {a : R} (ha : a ≠ 0) :\n  ideal.span ({a} : set R) ≠ ⊥ :=\nbegin\n  rw [ne.def, ideal.span_eq_bot],\n  push_neg,\n  exact ⟨a, set.mem_singleton a, ha⟩\nend\n\nlemma finset.dvd_prod {ι M : Type*} [comm_monoid M] {x : ι} {s : finset ι}\n  (hx : x ∈ s) (f : ι → M) :\n  f x ∣ ∏ i in s, f i :=\nmultiset.dvd_prod (multiset.mem_map.mpr ⟨x, hx, rfl⟩)\n\nlemma prod_finset_approx_ne_zero\n  [finite_dimensional f.codomain L] [is_separable f.codomain L] [infinite R] [decidable_eq R] :\n  algebra_map R (integral_closure R L) (∏ m in finset_approx L f abs, m) ≠ 0 :=\nbegin\n  refine mt ((algebra_map R _).injective_iff.mp (integral_closure.algebra_map_injective f) _) _,\n  simp only [finset.prod_eq_zero_iff, not_exists],\n  rintros x hx rfl,\n  exact finset_approx.zero_not_mem L f abs hx\nend\n\nlemma ne_zero_of_dvd_prod_finset_approx\n  [finite_dimensional f.codomain L] [is_separable f.codomain L] [infinite R] [decidable_eq R]\n  (J : ideal (integral_closure R L))\n  (h : J ∣ ideal.span {algebra_map _ _ (∏ m in finset_approx L f abs, m)}) :\n  J ≠ 0 :=\nbegin\n  simp only [ne.def, ideal.zero_eq_bot, submodule.eq_bot_iff, not_forall, not_imp],\n  refine ⟨(algebra_map _ _) (∏ (m : R) in finset_approx L f abs, m), _, _⟩,\n  { exact ideal.le_of_dvd h (ideal.subset_span (set.mem_singleton _)) },\n  apply prod_finset_approx_ne_zero\nend\n\n/-- Each class in the class group contains an ideal `J`\nsuch that the product of `finset_approx.prod` is in `J`. -/\ntheorem exists_mk0_eq_mk0 [finite_dimensional f.codomain L] [is_separable f.codomain L]\n  [infinite R] [decidable_eq R] (I : nonzero_ideal (integral_closure R L))\n  [is_dedekind_domain (integral_closure R L)] :\n  ∃ (J : nonzero_ideal (integral_closure R L)),\n  class_group.mk0 (integral_closure.fraction_map_of_finite_extension L f) I =\n  class_group.mk0 (integral_closure.fraction_map_of_finite_extension L f) J ∧\n    J.1 ∣ ideal.span {algebra_map _ _ (∏ m in finset_approx L f abs, m)} :=\nbegin\n  set m := ∏ m in finset_approx L f abs, m with m_eq,\n  have hm : algebra_map R (integral_closure R L) m ≠ 0 := prod_finset_approx_ne_zero f abs,\n  obtain ⟨b, b_mem, b_ne_zero, b_min⟩ := exists_min f abs I,\n  suffices : ideal.span {b} ∣ ideal.span {algebra_map _ _ m} * I.1,\n  { obtain ⟨J, hJ⟩ := this,\n    refine ⟨⟨J, _⟩, _, _⟩,\n    { rintro rfl,\n      rw [ideal.mul_bot, ideal.mul_eq_bot] at hJ,\n      exact I.2 (hJ.resolve_left (mt ideal.span_singleton_eq_bot.mp hm)) },\n    { rw class_group.mk0_eq_mk0_iff,\n      exact ⟨algebra_map _ _ m, b, hm, b_ne_zero, hJ⟩ },\n    apply ideal.dvd_of_mul_dvd_mul_left (ideal.span_singleton_ne_bot b_ne_zero),\n    rw [ideal.dvd_iff_le, ← hJ, mul_comm, m_eq],\n    apply ideal.mul_mono le_rfl,\n    rw [ideal.span_le, set.singleton_subset_iff],\n    exact b_mem },\n  rw [ideal.dvd_iff_le, ideal.mul_le],\n  intros r' hr' a ha,\n  rw ideal.mem_span_singleton at ⊢ hr',\n  obtain ⟨q, r, r_mem, lt⟩ := exists_mem_finset_approx' L f abs a b_ne_zero,\n  apply @dvd_of_mul_left_dvd _ _ q,\n  simp only [algebra.smul_def] at lt,\n  rw ← sub_eq_zero.mp (b_min _ (I.1.sub_mem (I.1.mul_mem_left _ ha) (I.1.mul_mem_left _ b_mem)) lt),\n  refine mul_dvd_mul_right (dvd_trans (ring_hom.map_dvd _ _) hr') _,\n  exact finset.dvd_prod r_mem (λ x, x)\nend\n\nvariables (L)\n\n/-- `class_group.mk_dvd` is a specialization of `class_group.mk0` to (the finite set of)\nideals that contain `∏ m in finset_approx L f abs, m` -/\nnoncomputable def mk_dvd [finite_dimensional f.codomain L] [is_separable f.codomain L]\n  [infinite R] [decidable_eq R] [is_dedekind_domain (integral_closure R L)]\n  (J : {J : ideal (integral_closure R L) // J ∣\n    ideal.span {algebra_map _ _ (∏ m in finset_approx L f abs, m)}}) :\n  class_group (integral_closure.fraction_map_of_finite_extension L f) :=\nclass_group.mk0 _ ⟨J.1, ne_zero_of_dvd_prod_finset_approx f abs J.1 J.2⟩\n\nlemma mk_dvd_surjective\n  [finite_dimensional f.codomain L] [is_separable f.codomain L]\n  [infinite R] [decidable_eq R] [is_dedekind_domain (integral_closure R L)] :\n  function.surjective (class_group.mk_dvd L f abs) :=\nbegin\n  intro I',\n  obtain ⟨⟨I, hI⟩, rfl⟩ := class_group.mk0_surjective _ I',\n  obtain ⟨J, mk0_eq_mk0, J_dvd⟩ := exists_mk0_eq_mk0 f abs ⟨I, hI⟩,\n  exact ⟨⟨J, J_dvd⟩, mk0_eq_mk0.symm⟩\nend\n\ninclude abs\n\n/-- The main theorem: the class group of an integral closure is finite.\n\nRequires you to provide an \"admissible absolute value\", see `admissible_absolute_value.lean`\nfor a few constructions of those.\n-/\nnoncomputable def finite_of_admissible [infinite R]\n  [finite_dimensional f.codomain L] [is_separable f.codomain L]\n  [is_dedekind_domain (integral_closure R L)] :\n  fintype (class_group (integral_closure.fraction_map_of_finite_extension L f)) :=\nbegin\n  haveI := classical.dec_eq (class_group (integral_closure.fraction_map_of_finite_extension L f)),\n  haveI := classical.dec_eq R,\n  refine @fintype.of_surjective _ _ _\n       (ideal.finite_divisors _ _)\n       (class_group.mk_dvd L f abs)\n       (class_group.mk_dvd_surjective L f abs),\n  rw [ne.def, ideal.span_singleton_eq_bot],\n  exact prod_finset_approx_ne_zero f abs\nend\n\nend euclidean_domain\n\nsection integral_domain\n\nvariables {R K : Type*} [integral_domain R] [field K] (f : fraction_map R K)\n\nend integral_domain\n\nend class_group\n\nnamespace number_field\n\nvariables (K : Type*) [field K] [is_number_field K]\n\nnamespace ring_of_integers\n\nopen fraction_map\nlocal attribute [class] algebra.is_algebraic\n\nnoncomputable instance : fintype (class_group (ring_of_integers.fraction_map K)) :=\nclass_group.finite_of_admissible K int.fraction_map int.admissible_abs\n\nend ring_of_integers\n\n/-- The class number of a number field is the (finite) cardinality of the class group. -/\nnoncomputable def class_number : ℕ := fintype.card (class_group (ring_of_integers.fraction_map K))\n\nvariables {K}\n\n/-- The class number of a number field is `1` iff the ring of integers is a PID. -/\ntheorem class_number_eq_one_iff :\n  class_number K = 1 ↔ is_principal_ideal_ring (ring_of_integers K) :=\ncard_class_group_eq_one_iff _\n\nend number_field\n\nnamespace rat\n\nopen number_field\n\ntheorem class_number : number_field.class_number ℚ = 1 :=\nclass_number_eq_one_iff.mpr $ is_principal_ideal_ring.of_surjective _\n  (rat.ring_of_integers_equiv.symm : ℤ ≃+* ring_of_integers ℚ).surjective\n\nend rat\n\nnamespace function_field_over\n\nvariables {K L : Type*} [field K] [fintype K] [field L] (f : fraction_map (polynomial K) L)\nvariables (F : Type*) [field F] [algebra f.codomain F] [function_field_over f F]\nvariables [decidable_eq K] [is_separable f.codomain F]\n\nnamespace ring_of_integers\n\nopen function_field_over\n\nnoncomputable instance : fintype (class_group (ring_of_integers.fraction_map f F)) :=\nclass_group.finite_of_admissible F f polynomial.admissible_card_pow_degree\n\nend ring_of_integers\n\n/-- The class number in a function field is the (finite) cardinality of the class group. -/\nnoncomputable def class_number : ℕ := fintype.card (class_group (ring_of_integers.fraction_map f F))\n\n/-- The class number of a function field is `1` iff the ring of integers is a PID. -/\ntheorem class_number_eq_one_iff :\n  class_number f F = 1 ↔ is_principal_ideal_ring (ring_of_integers f F) :=\ncard_class_group_eq_one_iff _\n\nend function_field_over\n", "meta": {"author": "lean-forward", "repo": "class-number", "sha": "812ff19e6fbde86f8d71689851adaa2bbae9695e", "save_path": "github-repos/lean/lean-forward-class-number", "path": "github-repos/lean/lean-forward-class-number/class-number-812ff19e6fbde86f8d71689851adaa2bbae9695e/src/class_number.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.471337913621337}}
{"text": "import data.list.func\nimport .list2d\nimport .boolset2d\nimport .component1d\nimport .direction\n\n--         _                  _ _   _               \n--    __ _| | __ _  ___  _ __(_) |_| |__  _ __ ___  \n--   / _` | |/ _` |/ _ \\| '__| | __| '_ \\| '_ ` _ \\ \n--  | (_| | | (_| | (_) | |  | | |_| | | | | | | | |\n--   \\__,_|_|\\__, |\\___/|_|  |_|\\__|_| |_|_| |_| |_|\n--           |___/                                  \n\ndef component_extend_rows (avail ini : bset2d) : bset2d\n  := list.func.pointwise component1d avail ini\ndef component_extend_cols (avail ini : bset2d) : bset2d\n  := list2d.transpose (component_extend_rows (list2d.transpose avail) (list2d.transpose ini))\ndef component_step (avail : bset2d) : bset2d → bset2d\n  := (component_extend_cols avail) ∘ (component_extend_rows avail)\ndef comp_measure (avail ini : bset2d) : ℕ\n  := avail.count - ini.count\n\ndef component2d_aux : ℕ → bset2d → bset2d → bset2d\n| 0 _ cur := cur\n| (b0+1) avail cur := let next := (component_step avail cur) in\n  if comp_measure avail next < comp_measure avail cur\n  then component2d_aux b0 avail next\n  else cur\n\ndef component2d (avail ini : bset2d) : bset2d :=\n  let ini_pure := list2d.pointwise2d band avail ini in\n  component2d_aux (comp_measure avail ini_pure) avail ini_pure\n\n--   _           _            _   _           \n--  (_)_ __   __| |_   _  ___| |_(_)_   _____ \n--  | | '_ \\ / _` | | | |/ __| __| \\ \\ / / _ \\\n--  | | | | | (_| | |_| | (__| |_| |\\ V /  __/\n--  |_|_| |_|\\__,_|\\__,_|\\___|\\__|_| \\_/ \\___|\n--                                            \n\ninductive in_component2d (avail ini : bset2d) : ℕ×ℕ → Prop\n| triv (xy : ℕ×ℕ) (Ha : xy ∈ avail) (Hi : xy ∈ ini)\n  : in_component2d xy\n| move (d : direction) (xy : ℕ×ℕ) (Ha : xy ∈ avail)\n  (Hc : in_component2d (d.shift xy))\n  : in_component2d xy\n\ntheorem in_component2d_trans (avail ini ini2 : bset2d) :\n  (∀ xy : ℕ×ℕ, xy ∈ avail → xy ∈ ini2\n    → in_component2d avail ini xy) →\n  ∀ xy : ℕ×ℕ, in_component2d avail ini2 xy → in_component2d avail ini xy :=\nbegin\n  intros H1 xy H2, induction H2 with xy Ha Hi d xy Ha Hc IH,\n  exact H1 xy Ha Hi,\n  exact in_component2d.move d _ Ha IH,\nend\ntheorem in_component2d_transpose : ∀ (avail ini : bset2d) (xy : ℕ×ℕ),\n  in_component2d avail.transpose ini.transpose xy →\n  in_component2d avail ini (prod.swap xy) :=\nbegin\n  introv H,\n  induction H with xy Ha Hi d xy Ha Hc IH, {\n    unfold has_mem.mem at Ha Hi,\n    rw list2d.get2d_transpose at *,\n    exact in_component2d.triv _ Ha Hi,\n  }, {\n    unfold has_mem.mem at Ha Hc,\n    rw list2d.get2d_transpose at Ha,\n    apply in_component2d.move d.transpose, exact Ha,\n    simp [direction.transpose_shift], exact IH\n  }\nend\ntheorem in_component2d_subset_avail : ∀ (avail ini : bset2d) (xy : ℕ×ℕ),\n  in_component2d avail ini xy → xy ∈ avail :=\nbegin\n  introv H, cases H with xy Ha Hi d xy Ha Hi,\n  exact Ha, exact Ha,\nend\ntheorem in_component2d_of_supset : ∀ (avail ini ini2 : bset2d),\n  ini2 ⊆ ini →\n  ∀ xy : ℕ×ℕ, in_component2d avail ini2 xy →\n  in_component2d avail ini xy :=\nbegin\n  introv Hsub Ha, refine in_component2d_trans avail ini ini2 _ xy Ha,\n  clear Ha xy, introv Ha Hi,\n  exact in_component2d.triv xy Ha (Hsub xy Hi),\nend\n\n--             _                 _                           \n--    _____  _| |_ ___ _ __   __| |    _ __ _____      _____ \n--   / _ \\ \\/ / __/ _ \\ '_ \\ / _` |   | '__/ _ \\ \\ /\\ / / __|\n--  |  __/>  <| ||  __/ | | | (_| |   | | | (_) \\ V  V /\\__ \\\n--   \\___/_/\\_\\\\__\\___|_| |_|\\__,_|___|_|  \\___/ \\_/\\_/ |___/\n--                               |_____|                     \n\ntheorem component_extend_rows_valid : ∀ (avail ini : bset2d) (xy : ℕ×ℕ),\n  xy ∈ (component_extend_rows avail ini) →\n  in_component2d avail ini xy\n:=\nbegin\n  unfold component_extend_rows, introv H,\n  cases xy with x y, unfold has_mem.mem at H, unfold list2d.get2d at H,\n  rw list.func.get_pointwise at H,\n  have H1 := component1d_valid _ _ _ H, clear H,\n  induction H1 with x Ha Hi x Ha Hc IH x Ha Hc IH,\n  { apply in_component2d.triv (x,y), exact Ha, exact Hi, },\n  { apply in_component2d.move direction.right, exact Ha, exact IH, },\n  { apply in_component2d.move direction.left, exact Ha, exact IH, },\n  simp [default, component1d],\nend\ntheorem component_extend_rows_subset_avail\n  : ∀ (avail ini : bset2d), (component_extend_rows avail ini) ⊆ avail :=\nbegin\n  intros avail ini xy, cases xy with x y,\n  unfold has_mem.mem, unfold list2d.get2d,\n  unfold component_extend_rows, rw list.func.get_pointwise,\n  exact component1d_subset_avail _ _ _,\n  simp! [default, component1d],\nend\ntheorem component_extend_rows_supset\n  : ∀ (avail ini : bset2d), ini ⊆ avail →\n  ini ⊆ (component_extend_rows avail ini) :=\nbegin\n  intros avail ini H xy, cases xy with x y,\n  unfold has_mem.mem, unfold list2d.get2d,\n  unfold component_extend_rows, rw list.func.get_pointwise,\n  intro H2, exact component1d_supset _ _ _ (H (x,y) H2) H2,\n  simp! [default, component1d],\nend\n\ntheorem component_extend_rows_works {avail ini : bset2d} {xy : ℕ×ℕ}\n  : ∀ (d : direction),\n  xy ∈ avail → (d.shift xy) ∈ avail → (d.shift xy) ∈ ini →\n  (d = direction.left ∨ d = direction.right) →\n  xy ∈ (component_extend_rows avail ini) :=\nbegin\n  introv Ha Hda Hdi Hd, cases xy with x y,\n  unfold has_mem.mem, unfold list2d.get2d,\n  unfold component_extend_rows, rw list.func.get_pointwise,\n  cases Hd, {\n    simp [Hd, direction.shift, list2d.get2d] at *,\n    cases x, { exact component1d_supset _ _ _ Ha Hdi, },\n    simp at Hda Hdi, rw (component1d_succ_eq _ _ x Hda Ha),\n    exact component1d_supset _ _ _ Hda Hdi,\n  }, {\n    simp [Hd, direction.shift, list2d.get2d] at *,\n    rw ←(component1d_succ_eq _ _ x Ha Hda),\n    exact component1d_supset _ _ _ Hda Hdi,\n  },\n  simp! [default, component1d],\nend\n\n--             _                 _              _     \n--    _____  _| |_ ___ _ __   __| |    ___ ___ | |___ \n--   / _ \\ \\/ / __/ _ \\ '_ \\ / _` |   / __/ _ \\| / __|\n--  |  __/>  <| ||  __/ | | | (_| |  | (_| (_) | \\__ \\\n--   \\___/_/\\_\\\\__\\___|_| |_|\\__,_|___\\___\\___/|_|___/\n--                               |_____|              \n\n\ntheorem component_extend_cols_valid : ∀ (avail ini : bset2d) (xy : ℕ×ℕ),\n  xy ∈ (component_extend_cols avail ini) →\n  in_component2d avail ini xy\n:=\nbegin\n  unfold component_extend_cols, unfold has_mem.mem, introv,\n  rw list2d.get2d_transpose, introv H,\n  have H := component_extend_rows_valid _ _ _ H,\n  have H := in_component2d_transpose _ _ _ H,\n  simp at H, exact H,\nend\ntheorem component_extend_cols_subset_avail\n  : ∀ (avail ini : bset2d), (component_extend_cols avail ini) ⊆ avail :=\nbegin\n  intros avail ini xy H, unfold has_mem.mem at H, \n  unfold component_extend_cols at H, rw list2d.get2d_transpose at H,\n  have H := component_extend_rows_subset_avail _ _ _ H,\n  unfold has_mem.mem at H,\n  rw list2d.get2d_transpose at H, simp at H, exact H,\nend\ntheorem component_extend_cols_supset\n  : ∀ (avail ini : bset2d), ini ⊆ avail →\n  ini ⊆ (component_extend_cols avail ini) :=\nbegin\n  intros avail ini H1 xy H2, unfold component_extend_cols,\n  unfold has_mem.mem,\n  rw list2d.get2d_transpose, apply component_extend_rows_supset, {\n    intro xy, unfold has_mem.mem,\n    simp [list2d.get2d_transpose], apply H1,\n  },\n  unfold has_mem.mem,\n  rw list2d.get2d_transpose, simp, exact H2,\nend\n\ntheorem component_extend_cols_works {avail ini : bset2d} {xy : ℕ×ℕ}\n  : ∀ (d : direction),\n  xy ∈ avail → (d.shift xy) ∈ avail → (d.shift xy) ∈ ini →\n  (d = direction.up ∨ d = direction.down) →\n  xy ∈ (component_extend_cols avail ini) :=\nbegin\n  introv Ha Hda Hdi Hd,\n  unfold component_extend_cols, unfold has_mem.mem, cases xy with x y, simp,\n  apply component_extend_rows_works d.transpose,\n  { simp [has_mem.mem], exact Ha },\n  { simp [has_mem.mem, direction.transpose_shift], exact Hda },\n  { simp [has_mem.mem, direction.transpose_shift], exact Hdi },\n  { cases Hd, rw Hd, left, refl, rw Hd, right, refl, },\nend\n\n--                                    _             \n--    ___ ___  _ __ ___  _ __     ___| |_ ___ _ __  \n--   / __/ _ \\| '_ ` _ \\| '_ \\   / __| __/ _ \\ '_ \\ \n--  | (_| (_) | | | | | | |_) |  \\__ \\ ||  __/ |_) |\n--   \\___\\___/|_| |_| |_| .__/___|___/\\__\\___| .__/ \n--                      |_| |_____|          |_|    \n\ntheorem component_step_valid : ∀ (avail ini : bset2d) (xy : ℕ×ℕ),\n  xy ∈ (component_step avail ini) →\n  in_component2d avail ini xy\n:=\nbegin\n  unfold component_step, simp, introv H,\n  apply in_component2d_trans _ _ (component_extend_rows avail ini), {\n    clear H xy, intros xy H1 H2,\n    exact component_extend_rows_valid _ _ _ H2,\n  },\n  { exact component_extend_cols_valid _ _ _ H, },\nend\ntheorem component_step_subset_avail\n  : ∀ (avail ini : bset2d), (component_step avail ini) ⊆ avail :=\nbegin\n  intros, unfold component_step, simp,\n  apply component_extend_cols_subset_avail,\nend\ntheorem component_step_supset\n  : ∀ (avail ini : bset2d), ini ⊆ avail →\n  ini ⊆ (component_step avail ini) :=\nbegin\n  introv H, unfold component_step, simp,\n  apply @bset2d.subset.trans _ (component_extend_rows avail ini),\n  exact component_extend_rows_supset _ _ H,\n  apply component_extend_cols_supset,\n  exact component_extend_rows_subset_avail _ _,\nend\n\ntheorem component_step_complete_of_nlt_measure\n  : ∀ (avail ini : bset2d),\n  ini ⊆ avail →\n  (¬ comp_measure avail (component_step avail ini) < comp_measure avail ini) →\n  ∀ xy : ℕ×ℕ, in_component2d avail ini xy →\n  xy ∈ ini\n:=\nbegin\n  introv Hia_sub Hm_nlt Hin,\n  have Hsub : (component_step avail ini) ⊆ ini, {\n    clear Hin xy,\n    have Hm_ge : comp_measure avail (component_step avail ini) ≥ comp_measure avail ini\n      := not_lt.mp Hm_nlt, clear Hm_nlt,\n    unfold comp_measure at Hm_ge,\n    have Hca_le : (component_step avail ini).count ≤ avail.count\n      := bset2d.count_le_of_subset (component_step avail ini) avail\n        (component_step_subset_avail avail _),\n    have Hci_le : (component_step avail ini).count ≤ ini.count\n      := (nat.sub_le_sub_left_iff Hca_le).mp Hm_ge,\n    have Hic_sub : ini ⊆ (component_step avail ini)\n      := component_step_supset avail ini Hia_sub,\n    have Hic_le : ini.count ≤ (component_step avail ini).count\n      := bset2d.count_le_of_subset ini _ Hic_sub,\n    have Hic_eq : ini.count = (component_step avail ini).count\n      := le_antisymm Hic_le Hci_le,\n    exact bset2d.subset_eq_of_count_eq ini (component_step avail ini) Hic_sub Hic_eq,\n  },\n  induction Hin with xy Ha Hi d xy Ha Hc IH, { exact Hi, }, {\n  have Had : (d.shift xy) ∈ avail\n    := in_component2d_subset_avail avail ini (d.shift xy) Hc,\n  apply Hsub,\n  have Hlr : xy ∈ (component_extend_rows avail ini)\n    → xy ∈ (component_step avail ini)\n    := component_extend_cols_supset avail _\n      (component_extend_rows_subset_avail avail ini) xy,\n  have Hud : (d.shift xy) ∈ (component_extend_rows avail ini)\n    := component_extend_rows_supset avail _ Hia_sub (d.shift xy) IH,\n  unfold component_step, simp,\n  cases d,\n  { exact component_extend_cols_works direction.up Ha Had Hud\n      (or.intro_left _ rfl), },\n  { exact component_extend_cols_works direction.down Ha Had Hud\n      (or.intro_right _ rfl), },\n  { exact Hlr (component_extend_rows_works direction.left Ha Had IH\n      (or.intro_left _ rfl)), },\n  { exact Hlr (component_extend_rows_works direction.right Ha Had IH\n      (or.intro_right _ rfl)), },\n  },\nend\n\n--                                                \n--    ___ ___  _ __ ___  _ __     __ _ _   ___  __\n--   / __/ _ \\| '_ ` _ \\| '_ \\   / _` | | | \\ \\/ /\n--  | (_| (_) | | | | | | |_) | | (_| | |_| |>  < \n--   \\___\\___/|_| |_| |_| .__/___\\__,_|\\__,_/_/\\_\\\n--                      |_| |_____|               \n\n\ntheorem component2d_aux_valid : ∀ (b : ℕ) (avail ini : bset2d) (xy : ℕ×ℕ),\n  ini ⊆ avail →\n  xy ∈ (component2d_aux b avail ini) →\n  in_component2d avail ini xy\n:=\nbegin\n  intro b, induction b with b IH, {\n    introv Hsub H,\n    unfold component2d_aux at H,\n    exact in_component2d.triv xy (Hsub xy H) H,\n  }, {\n    introv Hsub H,\n    unfold component2d_aux at H, simp at H,\n    by_cases Hcond : (comp_measure avail (component_step avail ini) < comp_measure avail ini),\n    { rw if_pos Hcond at H, \n      apply in_component2d_trans _ _ (component_step avail ini),\n      { clear H xy, introv Ha Hc, apply component_step_valid, exact Hc, },\n      { apply IH _ _ _ _ H, apply component_step_subset_avail, },\n    }, {\n      rw if_neg Hcond at H,\n      exact in_component2d.triv xy (Hsub xy H) H,\n    }\n  }\nend\n\ntheorem component2d_aux_complete : ∀ (b : ℕ) (avail ini : bset2d) (xy : ℕ×ℕ),\n  ini ⊆ avail →\n  comp_measure avail ini ≤ b →\n  in_component2d avail ini xy →\n  xy ∈ (component2d_aux b avail ini)\n:=\nbegin\n  intro b, induction b with b IH, {\n    introv Hsub Hm Hin,\n    unfold component2d_aux,\n    refine component_step_complete_of_nlt_measure avail ini Hsub _ xy Hin,\n    { simp at Hm, rw Hm, apply nat.not_lt_zero, },\n  }, {\n    introv Hsub Hm Hin,\n    unfold component2d_aux, simp,\n    by_cases Hcond\n      : (comp_measure avail (component_step avail ini) < comp_measure avail ini), {\n      rw if_pos Hcond,\n      apply IH,\n      { apply component_step_subset_avail, },\n      { exact nat.succ_le_succ_iff.mp (le_trans (nat.succ_le_iff.mpr Hcond) Hm) },\n      { refine in_component2d_of_supset avail _ ini _ xy Hin,\n        exact component_step_supset avail ini Hsub, },\n    }, {\n      rw if_neg Hcond,\n      exact component_step_complete_of_nlt_measure avail ini Hsub Hcond xy Hin,\n    },\n  },\nend\n\n--                                                    _   ____     _ \n--    ___ ___  _ __ ___  _ __   ___  _ __   ___ _ __ | |_|___ \\ __| |\n--   / __/ _ \\| '_ ` _ \\| '_ \\ / _ \\| '_ \\ / _ \\ '_ \\| __| __) / _` |\n--  | (_| (_) | | | | | | |_) | (_) | | | |  __/ | | | |_ / __/ (_| |\n--   \\___\\___/|_| |_| |_| .__/ \\___/|_| |_|\\___|_| |_|\\__|_____\\__,_|\n--                      |_|                                          \n\ntheorem component2d_valid : ∀ (avail ini : bset2d) (xy : ℕ×ℕ),\n  xy ∈ (component2d avail ini) →\n  in_component2d avail ini xy\n:=\nbegin\n  unfold component2d, simp, introv H, \n  apply in_component2d_trans _ _ (list2d.pointwise2d band avail ini),\n  clear H xy, introv Ha Hri, {\n    unfold has_mem.mem at Hri,\n    rw list2d.get2d_pointwise at Hri, simp at Hri, cases Hri with Ha Hi,\n    apply in_component2d.triv xy Ha, exact Hi,\n    simp!,\n  }, {\n    apply component2d_aux_valid _ _ _ _ _ H, {\n      clear H, intro xy, intro H,\n      unfold has_mem.mem at H,\n      rw list2d.get2d_pointwise at H, simp at H, cases H with Ha Hi,\n      exact Ha,\n      simp!,\n    },\n  },\nend\ntheorem component2d_complete : ∀ (avail ini : bset2d) (xy : ℕ×ℕ),\n  in_component2d avail ini xy →\n  xy ∈ (component2d avail ini)\n:=\nbegin\n  introv Hin, unfold component2d, simp,\n  apply component2d_aux_complete _ avail _ xy, {\n    clear Hin xy, intros xy H,\n    unfold has_mem.mem at H,\n    simp [list2d.get2d_pointwise] at H,\n    exact H.elim_left,\n  }, exact le_refl _, {\n    refine in_component2d_trans avail _ ini _ xy Hin,\n    intros xy Ha Hi,\n    apply in_component2d.triv xy Ha,\n    simp [has_mem.mem, list2d.get2d_pointwise], exact and.intro Ha Hi,\n  },\nend\ntheorem component2d_op_closed : ∀ {avail ini : bset2d} {xy : ℕ×ℕ} {d : direction},\n  d.shift xy ∈ (component2d avail ini) →\n  xy ∈ avail →\n  xy ∈ (component2d avail ini) :=\nbegin\n  introv Hc Ha, apply component2d_complete,\n  have Hc := component2d_valid avail ini (d.shift xy) Hc,\n  exact in_component2d.move d xy Ha Hc,\nend\ntheorem component2d_closed : ∀ {avail ini : bset2d} {xy : ℕ×ℕ} {d : direction},\n  xy ∈ (component2d avail ini) →\n  d.shift xy ∈ avail →\n  d.shift xy ∈ (component2d avail ini) :=\nbegin\n  introv Hc Ha, cases direction.opposite_shift d xy with Heq Hrev,\n  { rw Heq, exact Hc, },\n  rw ←Hrev at Hc, exact component2d_op_closed Hc Ha,\nend\ntheorem component2d_subset_avail : ∀ {avail ini : bset2d},\n  (component2d avail ini) ⊆ avail :=\nλ avail ini xy Hin, in_component2d_subset_avail _ _ _ (component2d_valid _ _ _ Hin)\n\ntheorem component2d_supset : ∀ {avail ini : bset2d},\n  ini ⊆ avail → ini ⊆ (component2d avail ini) :=\nassume avail ini Hsub xy Hin,\n  component2d_complete _ _ _ (in_component2d.triv xy (Hsub xy Hin) Hin)\n", "meta": {"author": "mirefek", "repo": "sokoban.lean", "sha": "451c92308afb4d3f8e566594b9751286f93b899b", "save_path": "github-repos/lean/mirefek-sokoban.lean", "path": "github-repos/lean/mirefek-sokoban.lean/sokoban.lean-451c92308afb4d3f8e566594b9751286f93b899b/src/component2d.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.47133790705560713}}
{"text": "import linear_algebra.finite_dimensional\nimport ring_theory.ideal.basic\nimport algebra.field\nimport ring_theory.subring\nimport ring_theory.integral_closure\nimport ring_theory.fractional_ideal\nimport data.rat.basic\nimport ring_theory.algebra\nimport ring_theory.algebraic\nimport field_theory.separable\nimport field_theory.normal\nimport data.padics.padic_integers\nimport algebra.category.CommRing.basic\nimport category_theory.concrete_category.bundled\nimport algebra.free_monoid\n\nopen function\nopen_locale classical big_operators\n\ndef is_integrally_closed_domain (R : Type*) [comm_ring R] : Prop := ∀ {r s : R}, s ≠ 0 → (∃ (n : ℕ) (f : ℕ → R)\n(hf : f 0 = 1), ∑ ij in finset.nat.antidiagonal n, f ij.1 * r ^ ij.2 * s ^ ij.1 = 0) → s ∣ r\n\nclass dedekind_id (R : Type*) [integral_domain R] : Prop :=\n    (noetherian : is_noetherian_ring R)\n    (int_closed : is_integrally_closed_domain R)\n    (max_nonzero_primes : ∀ P : ideal R, P ≠ ⊥ → P.is_prime → P.is_maximal)\n\nclass number_field (K : Type*) :=\n   (fld : field K)\n   (alg : algebra ℚ K)\n   (fd : finite_dimensional ℚ K)\n\ninstance field_of_number_field (K : Type*) [number_field K] : field K := _inst_1.fld\n\ninstance algebra_of_number_field (K : Type*) [number_field K] : algebra ℚ K := _inst_1.alg\n\ninstance infinite_of_number_field (K : Type*) [number_field K] : infinite K := begin\n  let f : ℤ → K := (λ n, (n : ℚ) • (1 : K)),\n  apply infinite.of_injective f,\n  intros x y hxy,\n  have hxy2 : (x : ℚ) • (1 : K) = (y : ℚ) • (1 : K), exact hxy,\n  have h : 0 = ((x : ℚ) - (y : ℚ)) • (1 : K), calc 0 = (x : ℚ) • (1 : K) - (y : ℚ) • (1 : K) : by rw sub_eq_zero.mpr hxy\n  ... = (x : ℚ) • (1 : K) + (-((y : ℚ) • (1 : K))) : sub_eq_add_neg (↑x • 1) (↑y • 1)\n  ... = (x : ℚ) • (1 : K) + ((-(y : ℚ)) • (1 : K)) : by rw neg_smul\n  ... = ((x : ℚ) + (-(y : ℚ))) • (1 : K) : by rw add_smul\n  ... = ((x : ℚ) - (y : ℚ)) • (1 : K) : by rw sub_eq_add_neg,\n  have h2 : ((x : ℚ) - (y : ℚ)) = 0 ∨ (1 : K) = 0, {exact (@smul_eq_zero ℚ K _ _ _ ((x : ℚ) - (y : ℚ)) (1 : K)).1 (eq.symm h)},\n  cases h2, {have h3 : (x : ℚ) = (y : ℚ), exact sub_eq_zero.mp h2,\n    exact (rat.coe_int_inj (x : ℤ) (y : ℤ)).1 h3},\n  {exfalso, revert h2, simp}\nend\n\ndef number_ring (K : Type*) [number_field K] := @integral_closure ℤ K _ (@field.to_comm_ring K _inst_1.fld) _\n\ntheorem integral_domain_of_number_ring (K : Type*) [number_field K] : integral_domain (number_ring K) :=\n(number_ring K).integral_domain\n\nexample (K : Type*) [field K] (x : K) (h : x ≠ 0): x * (field.inv x) = 1 := field.mul_inv_cancel h\n\n/-- A predicate to express that a ring is a field.\n\nThis is mainly useful because such a predicate does not contain data,\nand can therefore be easily transported along ring isomorphisms. -/\nstructure is_field (R : Type*) [ring R] : Prop :=\n    (exists_pair_ne : ∃ (x y : R), x ≠ y)\n    (mul_comm : ∀ (x y : R), x * y = y * x)\n    (mul_inv_cancel' : ∀ {a : R}, a ≠ 0 → ∃ b, a * b = 1)\n\n/-- Every field satisfies the predicate for integral domains. -/\nlemma field.to_is_field (R : Type*) [field R] : is_field R :=\n    {mul_inv_cancel' := λ a ha, ⟨a⁻¹, field.mul_inv_cancel ha⟩,\n   .. (‹_› : field R) }\n\nnoncomputable def is_field.to_field (R : Type*) [ring R] (h : is_field R) : field R :=\n    {inv := (λ a, if ha : a = 0 then 0 else classical.some (is_field.mul_inv_cancel' h ha)),\n    inv_zero := (dif_pos rfl),\n    mul_inv_cancel := (λ a ha, begin\n        convert classical.some_spec (is_field.mul_inv_cancel' h ha),\n        exact dif_neg ha\n    end),\n    .._inst_1, ..h}\n\n/-- There is a unique inverse in a field.\n-/\nlemma uniq_inv_of_is_field (R : Type*) [comm_ring R] [is_field R]: ∀ (x : R), x ≠ 0 → ∃! (y : R), x * y = 1 := begin\n    intros x hx,\n    apply exists_unique_of_exists_of_unique,\n        {exact _inst_2.mul_inv_cancel' hx},\n    intros y z hxy hxz,\n    calc y = y * 1 : eq.symm (mul_one y)\n    ... = y * (x * z) : by rw hxz\n    ... = (y * x) * z : eq.symm (mul_assoc y x z)\n    ... = (x * y) * z : by rw mul_comm y x\n    ... = 1 * z : by rw hxy\n    ... = z : one_mul z\nend\n\n/-- If the quotient of a `comm_ring` by an ideal is a field, then the ideal is maximal\n-/\nlemma maximal_ideal_of_is_field_quotient (R : Type*) [comm_ring R] (I : ideal R)\n[@is_field I.quotient (comm_ring.to_ring (ideal.quotient I))] : I.is_maximal := begin\n    apply ideal.is_maximal_iff.2,\n    split, {intro h,\n        rcases (_inst_2.exists_pair_ne) with ⟨⟨x⟩, ⟨y⟩, hxy⟩,\n        apply hxy,\n        apply ideal.quotient.eq.2,\n        rw ←mul_one (x-y),\n        apply submodule.smul_mem',\n        exact h},\n    {intros J x hIJ hxnI hxJ,\n        have hxn0 : (ideal.quotient.mk I x) ≠ 0,\n        {exact @mt ((ideal.quotient.mk I x) = 0) (x ∈ I) ideal.quotient.eq_zero_iff_mem.1 hxnI},\n        have hinvx : ∃ (y : I.quotient), (ideal.quotient.mk I x) * y = 1, {exact _inst_2.mul_inv_cancel' hxn0},\n        rcases hinvx with ⟨⟨y⟩, hy⟩,\n        change (ideal.quotient.mk I x) * (ideal.quotient.mk I y) = 1 at hy,\n        rw ←((ideal.quotient.mk I).map_mul x y) at hy,\n        have hxy1I : x*y-1 ∈ I, exact ideal.quotient.eq.1 hy,\n        have hxy1J : x*y-1 ∈ J, exact hIJ hxy1I,\n        have hxyJ : x*y ∈ J, exact ideal.mul_mem_right J hxJ,\n        have hend : x*y-(x*y-1) ∈ J, exact ideal.sub_mem J hxyJ hxy1J,\n        have h1 : 1 = x*y-(x*y-1), by ring,\n        rw h1,\n        exact hend}\nend\n\n/-- The quotient of a ring by an ideal is a field iff the ideal is maximal.\n-/\ntheorem maximal_ideal_iff_is_field_quotient (R : Type*) [comm_ring R] (I : ideal R) :\nI.is_maximal ↔ (@is_field I.quotient (comm_ring.to_ring (ideal.quotient I))) := begin\n    split,\n    {intro h,\n        exact @field.to_is_field I.quotient (@ideal.quotient.field _ _ I h)},\n    {intro h,\n        exact @maximal_ideal_of_is_field_quotient R _ I h,}\nend\n\ninstance dedekind_domain_of_number_ring (K : Type*) [number_field K] : dedekind_id (number_ring K) := {\n  noetherian := sorry,\n  int_closed := sorry,\n  max_nonzero_primes := (begin\n    intros P hP hPp,\n    have hid : integral_domain P.quotient, exact @ideal.quotient.integral_domain _ _ P hPp,\n    have hfin : fintype P.quotient, {sorry},\n    have hf : is_field (P.quotient), {sorry},\n    exact @maximal_ideal_of_is_field_quotient (number_ring K) _ P hf,\n  end)}\n\nnoncomputable theory\nopen_locale classical\n\nopen finite_dimensional\nopen ring.fractional_ideal\n\nnamespace number_field\n\nvariables (K : Type*) [number_field K]\n\nvariables (g : fraction_map (number_ring K) K)\n\ndef fractional_ideal := { Q : ring.fractional_ideal g // is_unit Q }\n\n@[ext]\nlemma ext {I J : fractional_ideal K g} : (I.1 : submodule (number_ring K) g.codomain) = J.1.1 → I = J :=\nbegin\n  rw <-subtype.val_eq_coe,\n  rw subtype.ext_iff_val,\n  rw subtype.ext_iff_val,\n  rintros,\n  assumption,\nend\n\ninstance : no_zero_divisors (ring.fractional_ideal g) := \nbegin sorry, end\n\ninstance : has_mul (fractional_ideal K g) := \nbegin \n  constructor,\n  rintros a b,\n  use a.1*b.1,\n  apply is_unit.mul,\n  use a.2,\n  use b.2,\nend\n\nlemma blossom (I J : fractional_ideal K g) : (I * J).val = I.val * J.val :=\nbegin\n  split,\nend\n\nlemma blossom' (I J : ring.fractional_ideal g) : (I * J).val = I.val * J.val :=\nbegin\n  split,\nend\n\ninstance : has_one (fractional_ideal K g) :=\nbegin\n  use 1,\n  simp,\nend\n\nlemma idk (I J : ring.fractional_ideal g) : (I/J).val = I.val / J.val :=\nbegin\n  by_cases J=0,\n  subst J,\n  unfold has_div.div,\n  simp,\n  sorry,\n  sorry,\nend\n\nlemma work (I J : ring.fractional_ideal g) : I/J = I * J⁻¹ :=\nbegin\n  unfold has_div.div,\n  split_ifs,\n  rw h,\n  simp,\n  right,\n  unfold has_inv.inv,\n  unfold has_div.div,\n  split_ifs,\n  assumption,\n\n  exfalso,\n  simp at h_1,\n  assumption,\n  \n  ext x,\n  unfold has_inv.inv,\n  unfold has_div.div,\n  split_ifs,\n  split,\n\n  rintros h,\n  simp at *,\n\n  sorry,\n  sorry,\nend\n\n@[simp] lemma coe_one : (1 : fractional_ideal K g).1 = 1 := rfl\n\nlemma mul_one' (I : ring.fractional_ideal g) : I = I * 1 :=\nbegin\n  simp only [mul_one],\nend\n\nnoncomputable instance fractional_ideal_has_div :\n  has_div (fractional_ideal K g) :=\nbegin\n  constructor,\n  rintros I J,\n  use I.1 / J.1,\n  sorry,\n--  by_contra,\n--  simp at a,\n--  rw submodule.ext at a,\n\n--  apply left_ne_zero_of_mul I.1 J.1,\n\n--  cases I with I1 I2,\n--  apply I2,\n--  simp at a,\n--  rw <-mul_left_cancel_iff (ring.fractional_ideal g) J.1 (I1 / ↑J) 0 at a,\n--  rw subtype.ext_iff_val at a,\n--  rw subtype.val_eq_coe at a,\n--  rw subtype.val_eq_coe at a, \n--  simp at *,\n  \n--  rw mul_left_inj J.1.1 _ _ at a,\nend\n\nnoncomputable instance : has_inv (fractional_ideal K g) := ⟨λ I, 1 / I⟩\n\nlemma pls_work (I : ring.fractional_ideal g) (h : I ≠ 0) : I * (1 / I) = 1 :=\nbegin\n  rw [ring.fractional_ideal.div_nonzero h],\n  apply le_antisymm,\n  {\n    apply submodule.mul_le.mpr _,\n    intros x hx y hy,\n    rw [mul_comm],\n    sorry,\n--    exact submodule.mem_div_iff_forall_mul_mem.mp hy x hx,\n  },\n  {\n    sorry,\n  },\nend\n\ninstance is_group : group (fractional_ideal K g) := \nbegin\n  constructor,\n  {\n    rintros a, \n    rw subtype.ext_iff_val,\n    rw blossom,\n    have h : a⁻¹.val = a.val⁻¹,\n    split,\n    rw h, \n    rw coe_one,\n    unfold has_inv.inv, \n    simp,\n     \n    sorry,\n    \n--    rw inv_mul_eq_one,\n--    apply ring.fractional_ideal.coe_inv_of_nonzero,\n\n--    use a.2,\n  },\n  {\n    rintros a b c,\n    rw subtype.ext_iff_val,\n    repeat{rw blossom}, \n    rw subtype.ext_iff_val,\n    repeat{rw blossom'},\n    rw submodule.mul_assoc,\n  },\n  {\n    rintros a,\n    rw subtype.ext_iff_val,\n    rw subtype.ext_iff_val,\n    simp, \n    cases a,\n    sorry,\n  },\n  {\n    rintros a,\n    sorry,\n  },\nend\n\ndef principal_fractional_ideal : subgroup (fractional_ideal K g) := \n{\n  carrier := { P : fractional_ideal K g | ∃ a : K, P.1 = ring.fractional_ideal.span_singleton a },\n  one_mem' := sorry,\n  mul_mem' := sorry,\n  inv_mem' := sorry,\n} \n\ndef class_group := quotient_group.quotient (principal_fractional_ideal K g)\n\ninstance class_number_is_finite : fintype (class_group K g) :=\nbegin\n  sorry,\nend\n\ndef class_number := fintype.card (class_group K g)\n\n-- def equiv (I J : ring.fractional_ideal g) : Prop := ∃ a : number_ring K, (ideal.span{a})*I = J \n\n-- theorem symmetricity : symmetric (equiv g) :=\n\n\ndef gal_ext (F L : Type*) [field F] [field L] [algebra F L] := (is_separable F L) ∧ (normal F L)\n\ndef gal_grp (F L : Type*) [field F] [field L] [algebra F L] : (Type : Type 1) := {σ : ring_aut L | ∀ x : F, σ (x • (1:L)) = (x • (1:L)) }\n\nclass zp_ext (L : Type*) [field L] (p : ℕ) [fact p.prime] ( h : ℕ → set L ) :=\n( blah2 : ∀ i : ℕ, number_field (h i) )\n( blah : ∀ i j : ℕ, i < j ↔ (h i) ⊂ (h j) )\n( blah4 : ∀ i : ℕ, algebra (h 0) (h i) )\n( blah3 : ∀ i : ℕ, gal_ext (h 0) (h i) )\n( blah5 : ∀ i : ℕ, gal_grp (h 0) (h i) = zmod (p^i) )\n( blah6 : L = ⋃ (i : ℕ), (h i) )\n\ninstance nth_ext (L : Type*) [field L] (p : ℕ) ( n : ℕ ) [fact p.prime] ( h : ℕ → set L ) [ zp_ext L p h ] : number_field (h n) := zp_ext.blah2 p n\n\nvariables {p : ℕ} [fact p.prime]\n\nvariables (L : Type 0) [field L] ( h : ℕ → set L ) [zp_ext L p h] (n : ℕ) [ gn : (fraction_map (number_ring (h n)) (h n) ) ]\n\ninstance any_ext : ∀ m : ℕ, number_field (h m) := \nbegin\n  sorry,\nend\n\nlemma ne : ∀ m : ℕ, nonempty ( fraction_map (number_ring (h m)) (h m) ) :=\nbegin\n  sorry,\nend\n\ndef class_no_tower' : ℕ → ℕ := λ m, class_number (h m) (classical.choice (ne L h m) )\n\n-- def nth_class_no_for_tower : ℕ := class_number (h n) gn\n\ntheorem main : ∃ N : ℕ, ∀ m ≥ N, ∃ a b c : ℕ, padic_val_rat p (class_number (h m) (classical.choice (ne L h m) ) ) = a*p^m + b*m + c :=\nbegin\nsorry,\nend\n\n-- def class_no_tower : ℕ → ℕ := λ n, (nth_class_no_for_tower L h n gn)\n\n-- (localization_map (non_zero_divisors (number_ring (h n)) ) : fraction_map (number_ring (h n)) (h n) )\n-- theorem main (L : Type*) [field L] ( h : ℕ → set L ) [zp_ext L p h] [∀ n : ℕ, number_field (h n)] [f : en = class_number (h n) _ ]\n\nend number_field", "meta": {"author": "laughinggas", "repo": "Ashvni", "sha": "934229f6fd246ce1cd71597ef9a579f4cb9ef0ef", "save_path": "github-repos/lean/laughinggas-Ashvni", "path": "github-repos/lean/laughinggas-Ashvni/Ashvni-934229f6fd246ce1cd71597ef9a579f4cb9ef0ef/class group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.47133307470744684}}
{"text": "/-\nCopyright (c) 2018 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton\n\nType of continuous maps and the compact-open topology on them.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.subset_properties\nimport Mathlib.topology.continuous_map\nimport Mathlib.tactic.tidy\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\nnamespace continuous_map\n\n\ndef compact_open.gen {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (s : set α) (u : set β) : set (continuous_map α β) :=\n  set_of fun (f : continuous_map α β) => ⇑f '' s ⊆ u\n\n-- The compact-open topology on the space of continuous maps α → β.\n\nprotected instance compact_open {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] : topological_space (continuous_map α β) :=\n  topological_space.generate_from\n    (set_of\n      fun (m : set (continuous_map α β)) =>\n        ∃ (s : set α), ∃ (hs : is_compact s), ∃ (u : set β), ∃ (hu : is_open u), m = sorry)\n\ndef induced {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} (hg : continuous g) (f : continuous_map α β) : continuous_map α γ :=\n  mk (g ∘ ⇑f)\n\n/-- C(α, -) is a functor. -/\ntheorem continuous_induced {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} (hg : continuous g) : continuous (induced hg) := sorry\n\ndef ev (α : Type u_1) (β : Type u_2) [topological_space α] [topological_space β] (p : continuous_map α β × α) : β :=\n  coe_fn (prod.fst p) (prod.snd p)\n\n-- The evaluation map C(α, β) × α → β is continuous if α is locally compact.\n\ntheorem continuous_ev {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] [locally_compact_space α] : continuous (ev α β) := sorry\n\ndef coev (α : Type u_1) (β : Type u_2) [topological_space α] [topological_space β] (b : β) : continuous_map α (β × α) :=\n  mk fun (a : α) => (b, a)\n\ntheorem image_coev {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {y : β} (s : set α) : ⇑(coev α β y) '' s = set.prod (singleton y) s := sorry\n\n-- The coevaluation map β → C(α, β × α) is continuous (always).\n\ntheorem continuous_coev {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] : continuous (coev α β) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/compact_open.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.47133306867598346}}
{"text": "import quantum_lemmas\n\nopen Matrix\n\nlocal notation `|0^(` n `)⟩` := ket_zeros n\n\n------------------------------------------------------------------------------\n-- no-cloning theorem (with 1 input qubit and 1 ancilla qubit)\n\nsection no_cloning_1\n\n-- Note: lean can't detect contradiction from `/√2 = 1/2`. Convert it to reals.\nlemma no_cloning_contra_h : /√2 = 1/2 → false\n:= begin\n    intros h,\n    let c1 := eq_of_one_div_eq_one_div h,\n    norm_cast at c1,\n    have c2: (2 : ℝ) = 4, {\n        calc 2 = √2 * √2 : by {rw real.mul_self_sqrt, linarith}\n           ... = 2 * 2 : by rw c1\n           ... = (4 : ℝ) : by linarith,\n    },\n    linarith,\nend\n\nlemma no_cloning_contra : ¬ (∀ (x y : Vector 2), (x† ⬝ y) = (x† ⬝ y) ⊗ (x† ⬝ y))\n:= begin\n    intros h,\n    have f1: (|0⟩† ⬝ |+⟩) = λ _ _, /√2, {\n        unfold_qubits; grind_matrix, grind_dot_product; finish_complex_arith,\n    },\n    have f2: (|0⟩† ⬝ |+⟩) = λ _ _, 1/2, {\n        rw h,\n        rw f1,\n        unfold kron,\n        apply funext, intro i,\n        apply funext, intro j,\n        norm_cast,\n        rw div_mul_div,\n        rw real.mul_self_sqrt,\n        norm_cast, simp,\n        linarith,\n    },\n    have f1': (|0⟩† ⬝ |+⟩) 0 0 = /√2, {\n        rw f1,\n    },\n    have f2': (|0⟩† ⬝ |+⟩) 0 0 = 1/2, {\n        rw f2,\n    },\n    have c: /√2 = 1/2, {\n        rw <- f1',\n        rw <- f2',\n    },\n    apply no_cloning_contra_h c,\nend\n\ntheorem no_cloning_1\n    : ¬ (∃ (U : Matrix 4 4), U.unitary ∧ ∀ s : Vector 2, U ⬝ (s ⊗ |0⟩) = s ⊗ s)\n:= begin\n    intros h, rcases h with ⟨U, ⟨H1, H2⟩⟩,\n\n    -- Part 1: derive the main contradictory fact.\n    have f1: ∀ (x y : Vector 2), (x† ⬝ y) = (x† ⬝ y) ⊗ (x† ⬝ y), {\n        intros x y,\n        have g1: (x† ⊗ (|0⟩†)) ⬝ (U† ⬝ U) ⬝ (y ⊗ |0⟩) = (x† ⊗ (x†)) ⬝ (y ⊗ y), {\n            rw <- matrix.mul_assoc,\n            rw <- adjoint_kron,\n            rw <- adjoint_mul,\n            rw H2,\n            rw matrix.mul_assoc,\n            rw H2,\n            congr' 1,\n            rw <- adjoint_kron,\n        },\n        calc (x†) ⬝ y = (x† ⬝ y) ⊗ (|0⟩† ⬝ |0⟩) : by simp\n                  ... = (x† ⊗ (|0⟩†)) ⬝ (y ⊗ |0⟩) : by rw kron_mixed_prod\n                  ... = (x† ⊗ (|0⟩†)) ⬝ (U† ⬝ U) ⬝ (y ⊗ |0⟩) : by {rw unfold_unitary H1, simp}\n                  ... = (x† ⊗ (x†)) ⬝ (y ⊗ y) : g1\n                  ... = (x† ⬝ y) ⊗ (x† ⬝ y) : by rw kron_mixed_prod,\n    },\n\n    -- Part 2:  derive false from the `f1`.\n    apply no_cloning_contra f1,\nend\n\nend no_cloning_1\n\n\n------------------------------------------------------------------------------\n-- no-cloning theorem 2 (with n input qubit and n ancilla qubit)\n-- Similar to no_cloning_1, but generalized with n qubits.\n\nsection no_cloning_2\n\n-- Note: The vector size needs to have this formula: (2 * 2^n) to make it easier to match.\nlemma no_cloning_contra_2 (n : ℕ) : ¬ (∀ (x y : Vector 2 * (2^n)), (x† ⬝ y) = (x† ⬝ y) ⊗ (x† ⬝ y))\n:= begin\n    intros h,\n    have f1: ((|0⟩ ⊗ |0^(n)⟩)†) ⬝ (|+⟩ ⊗ |0^(n)⟩) = λ _ _, /√2, {\n        rw adjoint_kron,\n        rw kron_mixed_prod,\n        simp,\n        unfold_qubits; grind_matrix, grind_dot_product; finish_complex_arith,\n    },\n    have f2: ((|0⟩ ⊗ |0^(n)⟩)†) ⬝ (|+⟩ ⊗ |0^(n)⟩) = λ _ _, 1/2, {\n        rw h,\n        rw f1,\n        unfold kron,\n        apply funext, intro i,\n        apply funext, intro j,\n        norm_cast,\n        rw div_mul_div,\n        rw real.mul_self_sqrt,\n        norm_cast, simp,\n        linarith,\n    },\n\n    let fin0 := (⟨0, by simp⟩ : fin (1*1)),\n    have f1': (((|0⟩ ⊗ |0^(n)⟩)†) ⬝ (|+⟩ ⊗ |0^(n)⟩)) fin0 fin0 = /√2, {\n        rw f1,\n    },\n    have f2': (((|0⟩ ⊗ |0^(n)⟩)†) ⬝ (|+⟩ ⊗ |0^(n)⟩)) fin0 fin0 = 1/2, {\n        rw f2,\n    },\n    have c: /√2 = 1/2, {\n        rw <- f1',\n        rw <- f2',\n    },\n    apply no_cloning_contra_h c,\nend\n\ntheorem no_cloning_2 (n : ℕ) (npos : 0 < n)\n    : ¬ (∃ (U : Square (2^n * 2^n))\n         , U.unitary ∧ ∀ (s : Vector 2^n), U ⬝ (s ⊗ |0^(n)⟩) = s ⊗ s)\n:= begin\n    intros h, rcases h with ⟨U, ⟨H1, H2⟩⟩,\n\n    -- Part 1: derive the main contradictory fact.\n    have f1: ∀ (x y : Vector 2^n), (x† ⬝ y) = (x† ⬝ y) ⊗ (x† ⬝ y), {\n        intros x y,\n        have g1: (x† ⊗ (|0^(n)⟩†)) ⬝ (U† ⬝ U) ⬝ (y ⊗ |0^(n)⟩) = (x† ⊗ (x†)) ⬝ (y ⊗ y), {\n            rw <- matrix.mul_assoc,\n            rw <- adjoint_kron,\n            rw <- adjoint_mul,\n            rw H2,\n            rw matrix.mul_assoc,\n            rw H2,\n            congr' 1,\n            rw <- adjoint_kron,\n        },\n        calc (x†) ⬝ y = (x† ⬝ y) ⊗ (|0^(n)⟩† ⬝ |0^(n)⟩) : by simp\n                  ... = (x† ⊗ (|0^(n)⟩†)) ⬝ (y ⊗ |0^(n)⟩) : by rw kron_mixed_prod\n                  ... = (x† ⊗ (|0^(n)⟩†)) ⬝ (U† ⬝ U) ⬝ (y ⊗ |0^(n)⟩) : by {rw unfold_unitary H1, simp}\n                  ... = (x† ⊗ (x†)) ⬝ (y ⊗ y) : g1\n                  ... = (x† ⬝ y) ⊗ (x† ⬝ y) : by rw kron_mixed_prod,\n    },\n\n    -- Part 2:  derive false from the `f1`.\n    cases n, {\n        exfalso, linarith,\n    }, {\n        apply no_cloning_contra_2 _ f1,\n    },\nend\n\nend no_cloning_2\n\n\n------------------------------------------------------------------------------\n-- no-cloning theorem 3 (with 1 input qubit and (n+1) ancilla qubits)\n\nsection no_cloning_3_helpers\n\nvariables {n : ℕ}\nvariables {U : Square (2 ^ (n + 2))} {f : (Vector 2) → Vector (2^n)}\n\n-- Any `f x` must be unit, since `U` is a unitary operator.\nlemma no_cloning_3_unit {x : Vector 2} :\n    (∀ s : Vector 2, s.unit → U ⬝ (s ⊗ (|0^(n+1)⟩)) = (s ⊗ (s ⊗ (f s))))\n    → U.unitary → x.unit\n    → (f x).unit\n:= begin\n    intros h u xu,\n    have f1: (x ⊗ (x ⊗ f x)).unit, {\n        rw <- h _ xu,\n        unfold matrix.unit,\n        rw unitary_preserve_norm _ _ _ u,\n        change ((x ⊗ |0^(n + 1)⟩).unit),\n        apply unit_kron_of_unit; try {simp *},\n        unfold matrix.unit ket_zeros, simp,\n    },\n    apply unit_kron_right,\n    apply unit_kron_right f1; assumption,\n    assumption,\nend\n\n-- The contradictory formula\nlemma no_cloning_3_contradiction {x y : Vector 2} :\n    (∀ s : Vector 2, s.unit → U ⬝ (s ⊗ (|0^(n+1)⟩)) = (s ⊗ (s ⊗ (f s))))\n    → U.unitary → x.unit → y.unit\n    → (x†) ⬝ y ≠ 0\n    → (x† ⬝ y) ⬝ ((f x)† ⬝ f y) = 1\n:= begin\n    intros h u xu yu h',\n\n    have fx1: x ⊗ (x ⊗ (f x)) = U ⬝ (x ⊗ (|0^(n+1)⟩)), by rw h; assumption,\n    have fy1: y ⊗ (y ⊗ (f y)) = U ⬝ (y ⊗ (|0^(n+1)⟩)), by rw h; assumption,\n\n    have f1: ((x ⊗ (x ⊗ (f x)))†) ⬝ (y ⊗ (y ⊗ (f y))) = ((x ⊗ (|0^(n+1)⟩))†) ⬝ (y ⊗ (|0^(n+1)⟩)), {\n        rw fx1, rw fy1,\n        rw unitary_preserve_norm; assumption,\n    },\n\n    repeat { rw adjoint_kron at f1 },\n    repeat { rw kron_mixed_prod at f1 },\n    unfold ket_zeros at f1, simp at f1,\n    repeat { rw kron_one_by_one_eq_mul at f1 },\n    repeat { rw kron_square_one_eq_mul at f1 },\n\n    have f2: ((x†) ⬝ y) ⬝ (x† ⬝ y ⬝ (f x† ⬝ f y)) = (x† ⬝ y) ⬝ 1, {\n        simp, assumption,\n    },\n\n    apply matrix_mul_cancel_left_square_one f2; assumption,\nend\n\nend no_cloning_3_helpers\n\ntheorem no_cloning_3 {n}\n    : ¬ (∃ (U : Square (2 ^ (n + 2))) (f : (Vector 2) → Vector (2^n))\n         , U.unitary\n         ∧ (∀ s : Vector 2, s.unit → U ⬝ (s ⊗ (|0^(n+1)⟩)) = (s ⊗ (s ⊗ (f s)))))\n:= begin\n    by_contradiction H,\n    rcases H with ⟨U, ⟨f, H⟩⟩,\n    rcases H with ⟨u, h⟩,\n\n    -- Step 1. Derive facts about \"f\" based on the fact that\n    --         U is a unitary operatros.\n    have f_ket0_unit: (f |0⟩).unit, {\n        apply no_cloning_3_unit h u; try {solve1 {simp *}},\n    },\n    have f_ket_plus_unit: (f |+⟩).unit, {\n        apply no_cloning_3_unit h u; try {solve1 {simp *}},\n    },\n    have f1: |⟪ f |0⟩, f |+⟩ ⟫| ≤ 1, {\n        apply inner_product_bound_of_unit; assumption,\n    },\n\n    -- Step 2. Derive the contradictory fact from the expected result state.\n    have c1: (|0⟩† ⬝ |+⟩) ⬝ ((f |0⟩)† ⬝ f |+⟩) = 1, {\n        apply no_cloning_3_contradiction h; simp <|> assumption,\n        rw inner_product_zero_iff, rw inner_ket0_ket_plus, simp,\n    },\n\n    -- Step 3, combine Step #1 and #3 to deduce \"false\".\n    have c2: ⟪ f |0⟩, f |+⟩ ⟫ = √2, {\n        have c1': ⟪ |0⟩, |+⟩ ⟫ * ⟪ f |0⟩, f |+⟩ ⟫ = 1, {\n            rw <- matrix.ext_iff at c1, specialize c1 0 0,\n            rw matrix_mul_square_one at c1, simp at c1,\n            apply c1,\n        },\n        rw inner_ket0_ket_plus at c1',\n        have c2_1: (√2 * (/√2 * ⟪ f |0⟩, f |+⟩ ⟫) : ℂ) = √2 * 1, {\n            rw c1',\n        },\n        calc ⟪ f |0⟩, f |+⟩ ⟫ = √2 * (/√2 * ⟪ f |0⟩, f |+⟩ ⟫) : by {simp,}\n                         ... = √2 : by {rw c2_1, simp,},\n    },\n    have c3: |(√2 : ℂ)| ≤ 1 → false, {\n        simp, rw _root_.abs_of_nonneg, {\n            contrapose!, intro h, clear h, simp,\n        }, {\n            simp,\n        }\n    },\n    apply c3,\n    rw <- c2, assumption,\nend\n\n\n------------------------------------------------------------------------------\n-- no-cloning theorem 3 (with 1 input qubit and (n+1) ancilla qubits)\n-- Alternative proof based on partial measure.\n\nlemma no_cloning_3_alt_helper1 (i : fin 4) : (/√2 • (|0⟩ ⊗ |0⟩) i 0)† * (/√2 • (|1⟩ ⊗ |1⟩)) i 0 = 0\n:= begin\n    unfold_qubits,\n    unfold kron kron_div kron_mod,\n    repeat { destruct_fin }; simp,\nend\n\nlemma no_cloning_3_alt_helper2 : ⟦(|+⟩ ⊗ |+⟩)⟧ 1 = 1/4\n:= begin\n    unfold quantum.measure,\n    unfold_qubits,\n    unfold kron kron_div kron_mod,\n    repeat { destruct_fin }; simp; ring,\nend\n\nlemma no_cloning_3_alt_helper3 : ⟦(/√2 • (|0⟩ ⊗ |0⟩)) + (/√2 • (|1⟩ ⊗ |1⟩))⟧ 1 = 0\n:= begin\n    unfold quantum.measure,\n    unfold_qubits,\n    unfold kron kron_div kron_mod,\n    repeat { destruct_fin }; simp,\nend\n\ntheorem no_cloning_3_alt {n}\n    : ¬ (∃ (U : Square (2 ^ (n + 2))) (f : (Vector 2) → Vector (2^n))\n         , U.unitary\n         ∧ (∀ s : Vector 2, s.unit → U ⬝ (s ⊗ (|0^(n+1)⟩)) = (s ⊗ (s ⊗ (f s)))))\n:= begin\n    by_contradiction H,\n    rcases H with ⟨U, ⟨f, H⟩⟩,\n    rcases H with ⟨u, H⟩,\n\n    let U_0 := (H (|0⟩)),\n    let U_1 := (H (|1⟩)),\n    let U_plus := (H |+⟩),\n\n    -- Step 1. Compute the state after cloning |+⟩\n    have step1 : U ⬝ (|+⟩ ⊗ |0^(n+1)⟩) = /√2 • U ⬝ (|0⟩ ⊗ |0^(n+1)⟩)\n                                      + /√2 • U ⬝ (|1⟩ ⊗ |0^(n+1)⟩), {\n        iterate 2 { rw <- matrix.mul_smul },\n        iterate 2 { rw <- kron_smul_left },\n        rw <- matrix.mul_add,\n        congr' 1,\n        rw <- kron_dist_over_add_left,\n        congr' 1,\n        rw ket_plus_alt_def,\n    },\n\n    -- Step 2. Compute the state after cloning |0⟩ or |1⟩ with a 50% probability.\n    --         This should be identical to the Step #1 when combined.\n    have step2_1: /√2 • U ⬝ (|0⟩ ⊗ |0^(n+1)⟩) = /√2 • |0⟩ ⊗ (|0⟩ ⊗ f |0⟩), {\n        congr' 1, apply H, simp,\n    },\n    have step2_2: /√2 • U ⬝ (|1⟩ ⊗ |0^(n+1)⟩) = /√2 • |1⟩ ⊗ (|1⟩ ⊗ f |1⟩), {\n        congr' 1, apply H, simp,\n    },\n\n    -- Step 3. Equate the results of Step #1 and #2, which will be contradictory.\n    have step3: |+⟩ ⊗ (|+⟩ ⊗ f |+⟩) = (/√2 • |0⟩ ⊗ (|0⟩ ⊗ f |0⟩)) + (/√2 • |1⟩ ⊗ (|1⟩ ⊗ f |1⟩)), {\n        rw <- U_plus; try {solve1 {simp}},\n        rw step1,\n        rw <- step2_1,\n        rw <- step2_2,\n    },\n\n    -- Step 4. Reformulate the equation from Step #3, before making a partial measurement.\n    have step4: (|+⟩ ⊗ |+⟩) ⊗ f |+⟩ = (/√2 • (|0⟩ ⊗ |0⟩)) ⊗ f |0⟩ + (/√2 • (|1⟩ ⊗ |1⟩)) ⊗ f |1⟩, {\n        rw kron_assoc_l2r,\n        rw step3,\n        simp,\n        repeat { rw kron_assoc },\n        rw push_cast_matrix_add; try {ring},\n        iterate 2 { rw push_cast_matrix_smul; try {ring} },\n        iterate 2 { rw cast_roundtrip },\n    },\n    clear step1 step2_1 step2_2 step3 U_plus U_0 U_1,\n\n    -- Step 5. Derive facts about \"f\" based on the fact that\n    --         U is a unitary operatros.\n    have f_ket0_unit: (f |0⟩).unit, {\n        apply no_cloning_3_unit H u; try {solve1 {simp *}},\n    },\n    have f_ket1_unit: (f |1⟩).unit, {\n        apply no_cloning_3_unit H u; try {solve1 {simp *}},\n    },\n    have f_ket_plus_unit: (f |+⟩).unit, {\n        apply no_cloning_3_unit H u; try {solve1 {simp *}},\n    },\n\n    -- Step 6. Find contradiction form the partial measurements of both sides.\n    have c1: ⟦(|+⟩ ⊗ |+⟩)⟧ 1 = ⟦(/√2 • (|0⟩ ⊗ |0⟩)) + (/√2 • (|1⟩ ⊗ |1⟩))⟧ 1, {\n        have p1: ⦃ (|+⟩ ⊗ |+⟩) ⊗ f |+⟩ ⦄ = ⟦(|+⟩ ⊗ |+⟩)⟧, {\n            apply partial_measure_proj_kron,\n            apply trace_proj_eq_one_of_unit; assumption,\n        },\n        have p2: ⦃ (/√2 • (|0⟩ ⊗ |0⟩)) ⊗ f |0⟩ + (/√2 • (|1⟩ ⊗ |1⟩)) ⊗ f |1⟩ ⦄\n                = ⟦ (/√2 • (|0⟩ ⊗ |0⟩)) + (/√2 • (|1⟩ ⊗ |1⟩)) ⟧, {\n            apply partial_measure_add_kron_of_orthogonal,\n            apply trace_proj_eq_one_of_unit; assumption,\n            apply trace_proj_eq_one_of_unit; assumption, {\n                apply no_cloning_3_alt_helper1,\n            },\n        },\n        rw <- p1,\n        rw <- p2,\n        rw step4,\n    },\n    have c2: (1/4 : ℝ) = 0, {\n        rw <- no_cloning_3_alt_helper2,\n        rw <- no_cloning_3_alt_helper3,\n        apply c1,\n    },\n    norm_num at c2,\nend\n", "meta": {"author": "duckki", "repo": "lean-quantum", "sha": "160cabcbd22bf24819b72930f56578e23b109a27", "save_path": "github-repos/lean/duckki-lean-quantum", "path": "github-repos/lean/duckki-lean-quantum/lean-quantum-160cabcbd22bf24819b72930f56578e23b109a27/src/theorems/no-cloning.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.6001883592602049, "lm_q1q2_score": 0.47133306867598335}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Scott Morrison\n-/\nimport category_theory.preadditive.yoneda.basic\nimport category_theory.preadditive.projective\nimport algebra.category.Group.epi_mono\nimport algebra.category.Module.epi_mono\n\n/-!\nAn object is projective iff the preadditive coyoneda functor on it preserves epimorphisms.\n-/\n\nuniverses v u\n\nopen opposite\n\nnamespace category_theory\nvariables {C : Type u} [category.{v} C]\n\nsection preadditive\nvariables [preadditive C]\n\nnamespace projective\n\nlemma projective_iff_preserves_epimorphisms_preadditive_coyoneda_obj (P : C) :\n  projective P ↔ (preadditive_coyoneda.obj (op P)).preserves_epimorphisms :=\nbegin\n  rw projective_iff_preserves_epimorphisms_coyoneda_obj,\n  refine ⟨λ (h : (preadditive_coyoneda.obj (op P) ⋙ (forget _)).preserves_epimorphisms), _, _⟩,\n  { exactI functor.preserves_epimorphisms_of_preserves_of_reflects (preadditive_coyoneda.obj (op P))\n      (forget _) },\n  { introI,\n    exact (infer_instance : (preadditive_coyoneda.obj (op P) ⋙ forget _).preserves_epimorphisms) }\nend\n\nlemma projective_iff_preserves_epimorphisms_preadditive_coyoneda_obj' (P : C) :\n  projective P ↔ (preadditive_coyoneda_obj (op P)).preserves_epimorphisms :=\nbegin\n  rw projective_iff_preserves_epimorphisms_coyoneda_obj,\n  refine ⟨λ (h : (preadditive_coyoneda_obj (op P) ⋙ (forget _)).preserves_epimorphisms), _, _⟩,\n  { exactI functor.preserves_epimorphisms_of_preserves_of_reflects (preadditive_coyoneda_obj (op P))\n      (forget _) },\n  { introI,\n    exact (infer_instance : (preadditive_coyoneda_obj (op P) ⋙ forget _).preserves_epimorphisms) }\nend\n\nend projective\n\nend preadditive\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/preadditive/yoneda/projective.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4710625425436913}}
{"text": "/-\nCopyright (c) 2017 Daniel Selsam. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Daniel Selsam\n\nProperties of continuous functions.\n-/\nimport .tfacts .util\n\nnamespace certigrad\nnamespace T\nopen list\n\naxiom continuous_id : ∀ {ishape : S} (x : T ishape), is_continuous (λ (x₀ : T ishape), x₀) x\naxiom continuous_const : ∀ {ishape oshape : S} (y : T oshape) (x : T ishape), is_continuous (λ (x₀ : T ishape), y) x\n\naxiom continuous_add_fs {ishape oshape : S} (f g : T ishape → T oshape) (x : T ishape) :\n  is_continuous f x → is_continuous g x → is_continuous (λ x₀, f x₀ + g x₀) x\n\nlemma continuous_sumr {α : Type} {ishape oshape : S} (f : α → T ishape → T oshape) (x : T ishape) :\n  ∀ (γs : list α), (∀ (γ : α), γ ∈ γs → is_continuous (λ (x₀ : T ishape), f γ x₀) x) →\n  is_continuous (λ (x₀ : T ishape), list.sumr (map (λ γ, f γ x₀) γs)) x\n| [] H := by apply (continuous_const 0)\n\n| (γ::γs) H :=\nbegin\ndunfold sumr map,\napply (continuous_add_fs _ _ _ (H γ mem_of_cons_same)),\napply continuous_sumr,\nintros γ' H_γ',\nexact H γ' (mem_cons_of_mem _ H_γ')\nend\n\naxiom continuous_chain_full {ishape oshape fshape : S} {f : T ishape → T oshape} {g : T ishape → T oshape → T fshape} {x : T ishape} :\n  is_continuous f x → is_continuous (λ x₀, g x₀ (f x)) x → is_continuous (g x) (f x) → is_continuous (λ x₀, g x₀ (f x₀)) x\n\nlemma continuous_chain {ishape oshape fshape : S} (f : T ishape → T oshape) (g : T oshape → T fshape) (x : T ishape) :\n  is_continuous f x → is_continuous g (f x) → is_continuous (λ x, g (f x)) x :=\nassume (H_cont_f : is_continuous f x) (H_cont_g : is_continuous g (f x)),\nlet h : T ishape → T oshape → T fshape := λ x y, g y in\nhave H_cont_h₁ : is_continuous (λ x₀, h x₀ (f x)) x, by apply (continuous_const (g (f x))),\nhave H_cont_h₂ : is_continuous (h x) (f x), from H_cont_g,\ncontinuous_chain_full H_cont_f H_cont_h₁ H_cont_h₂\n\naxiom continuous_binary {ishape oshape : S} (f : T ishape → T ishape → T oshape) (θ : T ishape) :\n  is_continuous (λ θ₀, f θ₀ θ) θ → is_continuous (λ θ₀, f θ θ₀) θ → is_continuous (λ θ₀, f θ₀ θ₀) θ\n\nlemma continuous_congr {ishape oshape : S} (f g : T ishape → T oshape) (x : T ishape) :\n  (∀ x₀, g x₀ = f x₀) → is_continuous f x → is_continuous g x :=\nbegin intros H H_f, assert H_gf : g = f, { exact funext H }, rw H_gf, exact H_f end\n\naxiom continuous_lift₀ {shape : S} (α : ℝ) : is_continuous (λ α : ℝ, const α shape) α\naxiom continuous_scale {shape : S} (α : ℝ) (x : T shape) : is_continuous (λ x₀, α ⬝ x₀) x\naxiom continuous_neg {shape : S} {θ : T shape} : is_continuous neg θ\naxiom continuous_exp {shape : S} {θ : T shape} : is_continuous exp θ\naxiom continuous_log {shape : S} {θ : T shape} : θ > 0 → is_continuous log θ\naxiom continuous_sqrt {shape : S} {θ : T shape} : θ > 0 → is_continuous sqrt θ\naxiom continuous_add₁ {shape : S} {θ x : T shape} : is_continuous (λ θ₀, θ₀ + x) θ\naxiom continuous_add₂ {shape : S} {θ x : T shape} : is_continuous (λ θ₀, x + θ₀) θ\naxiom continuous_mul₁ {shape : S} {θ x : T shape} : is_continuous (λ θ₀, θ₀ * x) θ\naxiom continuous_mul₂ {shape : S} {θ x : T shape} : is_continuous (λ θ₀, x * θ₀) θ\naxiom continuous_sub₁ {shape : S} {θ x : T shape} : is_continuous (λ θ₀, θ₀ - x) θ\naxiom continuous_sub₂ {shape : S} {θ x : T shape} : is_continuous (λ θ₀, x - θ₀) θ\naxiom continuous_div₁ {shape : S} {θ x : T shape} : square x > 0 → is_continuous (λ θ₀, θ₀ / x) θ\naxiom continuous_div₂ {shape : S} {θ x : T shape} : square θ > 0 → is_continuous (λ θ₀, x / θ₀) θ\naxiom continuous_sum {shape : S} {θ : T shape} : is_continuous sum θ\naxiom continuous_gemm₁ {m n p : ℕ} (M : T [m, n]) (N : T [n, p]) : is_continuous (λ M₀, T.gemm M₀ N) M\naxiom continuous_gemm₂ {m n p : ℕ} (M : T [m, n]) (N : T [n, p]) : is_continuous (λ N₀, T.gemm M N₀) N\n\nlemma continuous_square {shape : S} (θ : T shape) : is_continuous (λ x, T.square x) θ :=\nby { apply continuous_binary (λ θ₁ θ₂, θ₁ * θ₂), apply continuous_mul₁, apply continuous_mul₂ }\n\naxiom continuous_mvn_pdf_μ {shape : S} (μ σ x : T shape) (H_σ : σ > 0) : is_continuous (λ θ, mvn_pdf θ σ x) μ\naxiom continuous_mvn_pdf_σ {shape : S} (μ σ x : T shape) (H_σ : σ > 0) : is_continuous (λ θ, mvn_pdf μ θ x) σ\n\nlemma continuous_scale_fs {ishape oshape : S} {f : T ishape → ℝ} {g : T ishape → T oshape} {θ : T ishape} :\n                          is_continuous f θ → is_continuous g θ → is_continuous (λ θ₀, f θ₀ ⬝ g θ₀) θ :=\nassume (H_cont_f : is_continuous f θ) (H_cont_g : is_continuous g θ),\nbegin\napply (continuous_binary (λ θ₁ θ₂, f θ₁ ⬝ g θ₂)),\napply (continuous_chain f (λ θ₀, θ₀ ⬝ g θ) _ H_cont_f),\nsimp [T.smul.def],\napply (continuous_chain (λ θ₀, const θ₀ oshape) (λ θ₀, g θ * θ₀) _),\napply continuous_lift₀,\napply continuous_mul₂,\napply (continuous_chain g (λ θ₀, f θ ⬝ θ₀) _ H_cont_g),\napply continuous_scale\nend\n\nlemma continuous_fscale {ishape oshape : S} {f : T ishape → ℝ} {x : T oshape} {θ : T ishape} :\n                        is_continuous f θ → is_continuous (λ θ₀, f θ₀ ⬝ x) θ :=\nassume (H_cont_f : is_continuous f θ),\nbegin\napply continuous_scale_fs,\nexact H_cont_f,\napply continuous_const\nend\n\nlemma continuous_scale_f {ishape oshape : S} (α : ℝ) (f : T ishape → T oshape) (x : T ishape) : is_continuous f x → is_continuous (λ x₀, α ⬝ f x₀) x :=\nassume (H_f_cont : is_continuous f x),\ncontinuous_scale_fs (continuous_const α x) H_f_cont\n\n-- Note: this could be proved from the `select`/`replicate` formulation,\n-- but it is arguably a more natural way of axiomatizing the property.\naxiom continuous_multiple_args :\n  ∀ (parents : list reference) (oshape : S) (tgt : reference) (m : env)\n    (f : dvec T parents^.p2 → T oshape) (θ : T tgt.2),\n    (∀ (idx : ℕ), at_idx parents idx tgt →\n    is_continuous (λ θ₀, f (dvec.update_at θ₀ (env.get_ks parents (env.insert tgt θ m)) idx)) θ)\n    →\n    is_continuous (λ θ₀, f (env.get_ks parents (env.insert tgt θ₀ m))) θ\n\nend T\n\nsection tactic\nopen tactic\n\nmeta def prove_continuous_core : tactic unit :=\nfirst [\n       applyc `certigrad.T.continuous_id\n     , applyc `certigrad.T.continuous_const\n     , applyc `certigrad.T.continuous_add_fs\n     , applyc `certigrad.T.continuous_sumr\n\n     -- TODO(dhs): bug in Lean\n     -- This causes a silent \"sorry\" in prove_continuous_core with\n     -- no explanation\n--     , applyc `certigrad.T.continuous_mvn_kl₁\n--     , applyc `certigrad.T.continuous_mvn_kl₂,\n\n     , applyc `certigrad.T.continuous_lift₀\n     , applyc `certigrad.T.continuous_scale\n     , applyc `certigrad.T.continuous_neg\n     , applyc `certigrad.T.continuous_exp\n     , applyc `certigrad.T.continuous_log\n     , applyc `certigrad.T.continuous_sqrt\n     , applyc `certigrad.T.continuous_add₁\n     , applyc `certigrad.T.continuous_add₂\n     , applyc `certigrad.T.continuous_mul₁\n     , applyc `certigrad.T.continuous_mul₂\n     , applyc `certigrad.T.continuous_sub₁\n     , applyc `certigrad.T.continuous_sub₂\n     , applyc `certigrad.T.continuous_div₁\n     , applyc `certigrad.T.continuous_div₂\n     , applyc `certigrad.T.continuous_sum\n     , applyc `certigrad.T.continuous_gemm₁\n     , applyc `certigrad.T.continuous_gemm₂\n     , applyc `certigrad.T.continuous_square\n     , applyc `certigrad.T.continuous_mvn_pdf_μ\n     , applyc `certigrad.T.continuous_mvn_pdf_σ\n     , applyc `certigrad.T.continuous_scale_fs\n     , applyc `certigrad.T.continuous_scale_f\n     , applyc `certigrad.T.continuous_chain\n     , assumption\n]\n\nmeta def prove_continuous : tactic unit := repeat (prove_continuous_core <|> prove_preconditions_core)\n\nend tactic\n\nnamespace T\n\nlemma continuous_mvn_kl₁ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : is_continuous (λ μ₀, mvn_kl μ₀ σ) μ :=\nby { dunfold mvn_kl, prove_continuous }\n\nlemma continuous_mvn_kl₂ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : is_continuous (λ σ₀, mvn_kl μ σ₀) σ :=\nhave H_σ₂ : square σ > 0, from square_pos_of_pos H_σ,\nby { dunfold mvn_kl, prove_continuous }\n\nlemma continuous_bernoulli_neglogpdf₁ {shape : S} (p x : T shape) (H_p₁ : p > 0) (H_p₂ : 1 - p > 0) :\nis_continuous (λ p₀, bernoulli_neglogpdf p₀ x) p :=\nby { dunfold bernoulli_neglogpdf, prove_continuous }\n\nlemma continuous_bernoulli_neglogpdf₂ {shape : S} (p x : T shape) (H_p₁ : p > 0) (H_p₂ : 1 - p > 0) :\nis_continuous (λ x₀, bernoulli_neglogpdf p x₀) x :=\nbegin\ndunfold bernoulli_neglogpdf,\napply continuous_binary (λ θ₁ θ₂, - T.sum (θ₁ * T.log (eps shape + p) + (1 - θ₂) * T.log (eps shape + (1 + -p)))),\ndsimp,\nprove_continuous,\n-- TODO(dhs): not sure why this is necessary\napply continuous_chain (λ x, 1 - x) (λ y, y * log (eps shape + (1 + - p))),\nprove_continuous,\nend\n\nend T\nend certigrad\n", "meta": {"author": "dselsam", "repo": "certigrad", "sha": "c9a06e93f1ec58196d6d3b8563b29868d916727f", "save_path": "github-repos/lean/dselsam-certigrad", "path": "github-repos/lean/dselsam-certigrad/certigrad-c9a06e93f1ec58196d6d3b8563b29868d916727f/src/certigrad/tcont.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4710625425436913}}
{"text": "-- Copyright © 2019 François G. Dorais. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n\nimport .basic\nimport .substitution\nimport .homomorphism\n\nnamespace universal\nvariables {τ : Type} {σ : Type*} (sig : signature τ σ)\n\nstructure identity :=\n(cod : τ)\n(dom : list τ)\n(eqn : equation sig dom cod)\n\nvariable {sig}\n\ndefinition equation.to_identity {dom} {{cod}} : equation sig dom cod → identity sig :=\nλ e, ⟨_, _, e⟩\n\ndefinition term.to_identity {dom} {{cod}} : term sig dom cod → term sig dom cod → identity sig :=\nλ x₁ x₂, ⟨_, _, ⟨x₁, x₂⟩⟩\n\nnamespace identity\nvariables {sig} (ax : identity sig)\n\nabbreviation lhs : term sig ax.dom ax.cod := ax.eqn.lhs\n\nabbreviation rhs : term sig ax.dom ax.cod := ax.eqn.rhs\n\nabbreviation subst {dom : list τ} (sub : substitution sig ax.dom dom) : identity sig :=\n{ cod := ax.cod\n, dom := dom\n, eqn := ax.eqn.subst sub\n}\n\ntheorem subst_lhs {dom : list τ} (sub : substitution sig ax.dom dom) :\n(ax.subst sub).lhs = ax.lhs.subst sub := rfl\n\ntheorem subst_rhs {dom : list τ} (sub : substitution sig ax.dom dom) :\n(ax.subst sub).rhs = ax.rhs.subst sub := rfl\n\nend identity\n\nnamespace algebra\nvariables (alg : algebra sig) {alg₁ : algebra sig} {alg₂ : algebra sig} (h : homomorphism alg₁ alg₂)\n\ndefinition satisfies (ax : identity sig) : Prop :=\n∀ (val : Π (i : index ax.dom), alg.sort i.val), alg.eval ax.lhs val = alg.eval ax.rhs val\n\ntheorem satisfies_of_injective_hom [homomorphism.injective h] (ax : identity sig) : \nalg₂.satisfies ax → alg₁.satisfies ax :=\nbegin\nintros H₂ val₁,\napply homomorphism.injective.elim h,\nrw h.eval,\nrw h.eval,\napply H₂,\nend \n\ntheorem satisfies_of_surjective_hom [homomorphism.surjective h] (ax : identity sig) : \nalg₁.satisfies ax → alg₂.satisfies ax :=\nbegin\nintros H₁ val₂,\nhave : nonempty (Π (i : index ax.dom), { x : alg₁.sort i.val // h.map i.val x = val₂ i}),\nbegin\napply index.choice,\nintro i,\ncases homomorphism.surjective.elim h i.val (val₂ i) with x hx,\nexact nonempty.intro ⟨x, hx⟩,\nend,\ncases this with pval₁,\nlet val₁ := λ i, (pval₁ i).val,\nhave : val₂ = (λ i, h.map _ (val₁ i)), from funext (λ i, eq.symm (pval₁ i).property),\nrw this,\nrw ← h.eval,\nrw ← h.eval,\napply congr_arg,\napply H₁,\nend\n\nend algebra\n\nend universal\n", "meta": {"author": "fgdorais", "repo": "lean-universal", "sha": "9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1", "save_path": "github-repos/lean/fgdorais-lean-universal", "path": "github-repos/lean/fgdorais-lean-universal/lean-universal-9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1/src/universal/identity.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4710476871355415}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module order.heyting.hom\n! leanprover-community/mathlib commit 50832daea47b195a48b5b33b1c8b2162c48c3afc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Hom.Lattice\n\n/-!\n# Heyting algebra morphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA Heyting homomorphism between two Heyting algebras is a bounded lattice homomorphism that preserves\nHeyting implication.\n\nWe use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to\nbe satisfied by itself and all stricter types.\n\n## Types of morphisms\n\n* `heyting_hom`: Heyting homomorphisms.\n* `coheyting_hom`: Co-Heyting homomorphisms.\n* `biheyting_hom`: Bi-Heyting homomorphisms.\n\n## Typeclasses\n\n* `heyting_hom_class`\n* `coheyting_hom_class`\n* `biheyting_hom_class`\n-/\n\n\nopen Function\n\nvariable {F α β γ δ : Type _}\n\n#print HeytingHom /-\n/-- The type of Heyting homomorphisms from `α` to `β`. Bounded lattice homomorphisms that preserve\nHeyting implication. -/\n@[protect_proj]\nstructure HeytingHom (α β : Type _) [HeytingAlgebra α] [HeytingAlgebra β] extends\n  LatticeHom α β where\n  map_bot' : to_fun ⊥ = ⊥\n  map_himp' : ∀ a b, to_fun (a ⇨ b) = to_fun a ⇨ to_fun b\n#align heyting_hom HeytingHom\n-/\n\n#print CoheytingHom /-\n/-- The type of co-Heyting homomorphisms from `α` to `β`. Bounded lattice homomorphisms that\npreserve difference. -/\n@[protect_proj]\nstructure CoheytingHom (α β : Type _) [CoheytingAlgebra α] [CoheytingAlgebra β] extends\n  LatticeHom α β where\n  map_top' : to_fun ⊤ = ⊤\n  map_sdiff' : ∀ a b, to_fun (a \\ b) = to_fun a \\ to_fun b\n#align coheyting_hom CoheytingHom\n-/\n\n#print BiheytingHom /-\n/-- The type of bi-Heyting homomorphisms from `α` to `β`. Bounded lattice homomorphisms that\npreserve Heyting implication and difference. -/\n@[protect_proj]\nstructure BiheytingHom (α β : Type _) [BiheytingAlgebra α] [BiheytingAlgebra β] extends\n  LatticeHom α β where\n  map_himp' : ∀ a b, to_fun (a ⇨ b) = to_fun a ⇨ to_fun b\n  map_sdiff' : ∀ a b, to_fun (a \\ b) = to_fun a \\ to_fun b\n#align biheyting_hom BiheytingHom\n-/\n\n#print HeytingHomClass /-\n/-- `heyting_hom_class F α β` states that `F` is a type of Heyting homomorphisms.\n\nYou should extend this class when you extend `heyting_hom`. -/\nclass HeytingHomClass (F : Type _) (α β : outParam <| Type _) [HeytingAlgebra α]\n  [HeytingAlgebra β] extends LatticeHomClass F α β where\n  map_bot (f : F) : f ⊥ = ⊥\n  map_himp (f : F) : ∀ a b, f (a ⇨ b) = f a ⇨ f b\n#align heyting_hom_class HeytingHomClass\n-/\n\n#print CoheytingHomClass /-\n/-- `coheyting_hom_class F α β` states that `F` is a type of co-Heyting homomorphisms.\n\nYou should extend this class when you extend `coheyting_hom`. -/\nclass CoheytingHomClass (F : Type _) (α β : outParam <| Type _) [CoheytingAlgebra α]\n  [CoheytingAlgebra β] extends LatticeHomClass F α β where\n  map_top (f : F) : f ⊤ = ⊤\n  map_sdiff (f : F) : ∀ a b, f (a \\ b) = f a \\ f b\n#align coheyting_hom_class CoheytingHomClass\n-/\n\n#print BiheytingHomClass /-\n/-- `biheyting_hom_class F α β` states that `F` is a type of bi-Heyting homomorphisms.\n\nYou should extend this class when you extend `biheyting_hom`. -/\nclass BiheytingHomClass (F : Type _) (α β : outParam <| Type _) [BiheytingAlgebra α]\n  [BiheytingAlgebra β] extends LatticeHomClass F α β where\n  map_himp (f : F) : ∀ a b, f (a ⇨ b) = f a ⇨ f b\n  map_sdiff (f : F) : ∀ a b, f (a \\ b) = f a \\ f b\n#align biheyting_hom_class BiheytingHomClass\n-/\n\nexport HeytingHomClass (map_himp)\n\nexport CoheytingHomClass (map_sdiff)\n\nattribute [simp] map_himp map_sdiff\n\n#print HeytingHomClass.toBoundedLatticeHomClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) HeytingHomClass.toBoundedLatticeHomClass [HeytingAlgebra α]\n    [HeytingAlgebra β] [HeytingHomClass F α β] : BoundedLatticeHomClass F α β :=\n  { ‹HeytingHomClass F α β› with\n    map_top := fun f => by rw [← @himp_self α _ ⊥, ← himp_self, map_himp] }\n#align heyting_hom_class.to_bounded_lattice_hom_class HeytingHomClass.toBoundedLatticeHomClass\n-/\n\n#print CoheytingHomClass.toBoundedLatticeHomClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) CoheytingHomClass.toBoundedLatticeHomClass [CoheytingAlgebra α]\n    [CoheytingAlgebra β] [CoheytingHomClass F α β] : BoundedLatticeHomClass F α β :=\n  { ‹CoheytingHomClass F α β› with\n    map_bot := fun f => by rw [← @sdiff_self α _ ⊤, ← sdiff_self, map_sdiff] }\n#align coheyting_hom_class.to_bounded_lattice_hom_class CoheytingHomClass.toBoundedLatticeHomClass\n-/\n\n#print BiheytingHomClass.toHeytingHomClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) BiheytingHomClass.toHeytingHomClass [BiheytingAlgebra α]\n    [BiheytingAlgebra β] [BiheytingHomClass F α β] : HeytingHomClass F α β :=\n  { ‹BiheytingHomClass F α β› with\n    map_bot := fun f => by rw [← @sdiff_self α _ ⊤, ← sdiff_self, BiheytingHomClass.map_sdiff] }\n#align biheyting_hom_class.to_heyting_hom_class BiheytingHomClass.toHeytingHomClass\n-/\n\n#print BiheytingHomClass.toCoheytingHomClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) BiheytingHomClass.toCoheytingHomClass [BiheytingAlgebra α]\n    [BiheytingAlgebra β] [BiheytingHomClass F α β] : CoheytingHomClass F α β :=\n  { ‹BiheytingHomClass F α β› with\n    map_top := fun f => by rw [← @himp_self α _ ⊥, ← himp_self, map_himp] }\n#align biheyting_hom_class.to_coheyting_hom_class BiheytingHomClass.toCoheytingHomClass\n-/\n\n#print OrderIsoClass.toHeytingHomClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) OrderIsoClass.toHeytingHomClass [HeytingAlgebra α] [HeytingAlgebra β]\n    [OrderIsoClass F α β] : HeytingHomClass F α β :=\n  { OrderIsoClass.toBoundedLatticeHomClass with\n    map_himp := fun f a b =>\n      eq_of_forall_le_iff fun c =>\n        by\n        simp only [← map_inv_le_iff, le_himp_iff]\n        rw [← OrderIsoClass.map_le_map_iff f]\n        simp }\n#align order_iso_class.to_heyting_hom_class OrderIsoClass.toHeytingHomClass\n-/\n\n#print OrderIsoClass.toCoheytingHomClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) OrderIsoClass.toCoheytingHomClass [CoheytingAlgebra α]\n    [CoheytingAlgebra β] [OrderIsoClass F α β] : CoheytingHomClass F α β :=\n  { OrderIsoClass.toBoundedLatticeHomClass with\n    map_sdiff := fun f a b =>\n      eq_of_forall_ge_iff fun c =>\n        by\n        simp only [← le_map_inv_iff, sdiff_le_iff]\n        rw [← OrderIsoClass.map_le_map_iff f]\n        simp }\n#align order_iso_class.to_coheyting_hom_class OrderIsoClass.toCoheytingHomClass\n-/\n\n#print OrderIsoClass.toBiheytingHomClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) OrderIsoClass.toBiheytingHomClass [BiheytingAlgebra α]\n    [BiheytingAlgebra β] [OrderIsoClass F α β] : BiheytingHomClass F α β :=\n  {\n    OrderIsoClass.toLatticeHomClass with\n    map_himp := fun f a b =>\n      eq_of_forall_le_iff fun c =>\n        by\n        simp only [← map_inv_le_iff, le_himp_iff]\n        rw [← OrderIsoClass.map_le_map_iff f]\n        simp\n    map_sdiff := fun f a b =>\n      eq_of_forall_ge_iff fun c =>\n        by\n        simp only [← le_map_inv_iff, sdiff_le_iff]\n        rw [← OrderIsoClass.map_le_map_iff f]\n        simp }\n#align order_iso_class.to_biheyting_hom_class OrderIsoClass.toBiheytingHomClass\n-/\n\n#print BoundedLatticeHomClass.toBiheytingHomClass /-\n-- See note [reducible non instances]\n/-- This can't be an instance because of typeclass loops. -/\n@[reducible]\ndef BoundedLatticeHomClass.toBiheytingHomClass [BooleanAlgebra α] [BooleanAlgebra β]\n    [BoundedLatticeHomClass F α β] : BiheytingHomClass F α β :=\n  {\n    ‹BoundedLatticeHomClass F α\n        β› with\n    map_himp := fun f a b => by rw [himp_eq, himp_eq, map_sup, (is_compl_compl.map _).compl_eq]\n    map_sdiff := fun f a b => by rw [sdiff_eq, sdiff_eq, map_inf, (is_compl_compl.map _).compl_eq] }\n#align bounded_lattice_hom_class.to_biheyting_hom_class BoundedLatticeHomClass.toBiheytingHomClass\n-/\n\nsection HeytingAlgebra\n\nvariable [HeytingAlgebra α] [HeytingAlgebra β] [HeytingHomClass F α β] (f : F)\n\ninclude β\n\n#print map_compl /-\n@[simp]\ntheorem map_compl (a : α) : f (aᶜ) = f aᶜ := by rw [← himp_bot, ← himp_bot, map_himp, map_bot]\n#align map_compl map_compl\n-/\n\n/- warning: map_bihimp -> map_bihimp is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u3} β] [_inst_3 : HeytingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : α) (b : α), Eq.{succ u3} β (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f (bihimp.{u2} α (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))) (GeneralizedHeytingAlgebra.toHasHimp.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) a b)) (bihimp.{u3} β (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))) (GeneralizedHeytingAlgebra.toHasHimp.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f a) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f b))\nbut is expected to have type\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u3} β] [_inst_3 : HeytingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : α) (b : α), Eq.{succ u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) (bihimp.{u2} α (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (GeneralizedHeytingAlgebra.toHImp.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) a b)) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f (bihimp.{u2} α (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (GeneralizedHeytingAlgebra.toHImp.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) a b)) (bihimp.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (Lattice.toInf.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (GeneralizedHeytingAlgebra.toLattice.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) _inst_2))) (GeneralizedHeytingAlgebra.toHImp.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) _inst_2)) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f a) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f b))\nCase conversion may be inaccurate. Consider using '#align map_bihimp map_bihimpₓ'. -/\n@[simp]\ntheorem map_bihimp (a b : α) : f (a ⇔ b) = f a ⇔ f b := by simp_rw [bihimp, map_inf, map_himp]\n#align map_bihimp map_bihimp\n\n-- TODO: `map_bihimp`\nend HeytingAlgebra\n\nsection CoheytingAlgebra\n\nvariable [CoheytingAlgebra α] [CoheytingAlgebra β] [CoheytingHomClass F α β] (f : F)\n\ninclude β\n\n/- warning: map_hnot -> map_hnot is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u3} β] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : α), Eq.{succ u3} β (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f (HNot.hnot.{u2} α (CoheytingAlgebra.toHasHnot.{u2} α _inst_1) a)) (HNot.hnot.{u3} β (CoheytingAlgebra.toHasHnot.{u3} β _inst_2) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f a))\nbut is expected to have type\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u3} β] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : α), Eq.{succ u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) (HNot.hnot.{u2} α (CoheytingAlgebra.toHNot.{u2} α _inst_1) a)) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f (HNot.hnot.{u2} α (CoheytingAlgebra.toHNot.{u2} α _inst_1) a)) (HNot.hnot.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (CoheytingAlgebra.toHNot.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) _inst_2) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f a))\nCase conversion may be inaccurate. Consider using '#align map_hnot map_hnotₓ'. -/\n@[simp]\ntheorem map_hnot (a : α) : f (￢a) = ￢f a := by rw [← top_sdiff', ← top_sdiff', map_sdiff, map_top]\n#align map_hnot map_hnot\n\n/- warning: map_symm_diff -> map_symmDiff is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u3} β] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : α) (b : α), Eq.{succ u3} β (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f (symmDiff.{u2} α (SemilatticeSup.toHasSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (GeneralizedCoheytingAlgebra.toHasSdiff.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) a b)) (symmDiff.{u3} β (SemilatticeSup.toHasSup.{u3} β (Lattice.toSemilatticeSup.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))) (GeneralizedCoheytingAlgebra.toHasSdiff.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f a) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F α (fun (_x : α) => β) (InfHomClass.toFunLike.{u1, u2, u3} F α β (SemilatticeInf.toHasInf.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (SemilatticeInf.toHasInf.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f b))\nbut is expected to have type\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u3} β] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : α) (b : α), Eq.{succ u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) (symmDiff.{u2} α (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (GeneralizedCoheytingAlgebra.toSDiff.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) a b)) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f (symmDiff.{u2} α (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (GeneralizedCoheytingAlgebra.toSDiff.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) a b)) (symmDiff.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (SemilatticeSup.toSup.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (Lattice.toSemilatticeSup.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (GeneralizedCoheytingAlgebra.toLattice.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) _inst_2)))) (GeneralizedCoheytingAlgebra.toSDiff.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) _inst_2)) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f a) (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3)))) f b))\nCase conversion may be inaccurate. Consider using '#align map_symm_diff map_symmDiffₓ'. -/\n@[simp]\ntheorem map_symmDiff (a b : α) : f (a ∆ b) = f a ∆ f b := by simp_rw [symmDiff, map_sup, map_sdiff]\n#align map_symm_diff map_symmDiff\n\nend CoheytingAlgebra\n\ninstance [HeytingAlgebra α] [HeytingAlgebra β] [HeytingHomClass F α β] : CoeTC F (HeytingHom α β) :=\n  ⟨fun f =>\n    { toFun := f\n      map_sup' := map_sup f\n      map_inf' := map_inf f\n      map_bot' := map_bot f\n      map_himp' := map_himp f }⟩\n\ninstance [CoheytingAlgebra α] [CoheytingAlgebra β] [CoheytingHomClass F α β] :\n    CoeTC F (CoheytingHom α β) :=\n  ⟨fun f =>\n    { toFun := f\n      map_sup' := map_sup f\n      map_inf' := map_inf f\n      map_top' := map_top f\n      map_sdiff' := map_sdiff f }⟩\n\ninstance [BiheytingAlgebra α] [BiheytingAlgebra β] [BiheytingHomClass F α β] :\n    CoeTC F (BiheytingHom α β) :=\n  ⟨fun f =>\n    { toFun := f\n      map_sup' := map_sup f\n      map_inf' := map_inf f\n      map_himp' := map_himp f\n      map_sdiff' := map_sdiff f }⟩\n\nnamespace HeytingHom\n\nvariable [HeytingAlgebra α] [HeytingAlgebra β] [HeytingAlgebra γ] [HeytingAlgebra δ]\n\ninstance : HeytingHomClass (HeytingHom α β) α β\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := f <;> obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := g <;> congr\n  map_sup f := f.map_sup'\n  map_inf f := f.map_inf'\n  map_bot f := f.map_bot'\n  map_himp := HeytingHom.map_himp'\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : CoeFun (HeytingHom α β) fun _ => α → β :=\n  FunLike.hasCoeToFun\n\n/- warning: heyting_hom.to_fun_eq_coe -> HeytingHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] {f : HeytingHom.{u1, u2} α β _inst_1 _inst_2}, Eq.{max (succ u1) (succ u2)} (α -> β) (SupHom.toFun.{u1, u2} α β (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))) (SemilatticeSup.toHasSup.{u2} β (Lattice.toSemilatticeSup.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)))) (LatticeHom.toSupHom.{u1, u2} α β (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)) (HeytingHom.toLatticeHom.{u1, u2} α β _inst_1 _inst_2 f))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u1} β] {f : HeytingHom.{u2, u1} α β _inst_1 _inst_2}, Eq.{max (succ u2) (succ u1)} (α -> β) (SupHom.toFun.{u2, u1} α β (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))) (SemilatticeSup.toSup.{u1} β (Lattice.toSemilatticeSup.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))) (LatticeHom.toSupHom.{u2, u1} α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)) (HeytingHom.toLatticeHom.{u2, u1} α β _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} α β _inst_1 _inst_2))))) f)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.to_fun_eq_coe HeytingHom.toFun_eq_coeₓ'. -/\n@[simp]\ntheorem toFun_eq_coe {f : HeytingHom α β} : f.toFun = (f : α → β) :=\n  rfl\n#align heyting_hom.to_fun_eq_coe HeytingHom.toFun_eq_coe\n\n/- warning: heyting_hom.ext -> HeytingHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] {f : HeytingHom.{u1, u2} α β _inst_1 _inst_2} {g : HeytingHom.{u1, u2} α β _inst_1 _inst_2}, (forall (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g a)) -> (Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u1} β] {f : HeytingHom.{u2, u1} α β _inst_1 _inst_2} {g : HeytingHom.{u2, u1} α β _inst_1 _inst_2}, (forall (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} α β _inst_1 _inst_2))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} α β _inst_1 _inst_2))))) g a)) -> (Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.ext HeytingHom.extₓ'. -/\n@[ext]\ntheorem ext {f g : HeytingHom α β} (h : ∀ a, f a = g a) : f = g :=\n  FunLike.ext f g h\n#align heyting_hom.ext HeytingHom.ext\n\n/- warning: heyting_hom.copy -> HeytingHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] (f : HeytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)) -> (HeytingHom.{u1, u2} α β _inst_1 _inst_2)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] (f : HeytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)))))) (BoundedOrder.toOrderTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u2} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u2} α β _inst_1 _inst_2))))) f)) -> (HeytingHom.{u1, u2} α β _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.copy HeytingHom.copyₓ'. -/\n/-- Copy of a `heyting_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : HeytingHom α β) (f' : α → β) (h : f' = f) : HeytingHom α β\n    where\n  toFun := f'\n  map_sup' := by simpa only [h] using map_sup f\n  map_inf' := by simpa only [h] using map_inf f\n  map_bot' := by simpa only [h] using map_bot f\n  map_himp' := by simpa only [h] using map_himp f\n#align heyting_hom.copy HeytingHom.copy\n\n/- warning: heyting_hom.coe_copy -> HeytingHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] (f : HeytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) (HeytingHom.copy.{u1, u2} α β _inst_1 _inst_2 f f' h)) f'\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u1} β] (f : HeytingHom.{u2, u1} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} α β _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} α β _inst_1 _inst_2))))) (HeytingHom.copy.{u2, u1} α β _inst_1 _inst_2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align heyting_hom.coe_copy HeytingHom.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (f : HeytingHom α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align heyting_hom.coe_copy HeytingHom.coe_copy\n\n/- warning: heyting_hom.copy_eq -> HeytingHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] (f : HeytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (HeytingHom.copy.{u1, u2} α β _inst_1 _inst_2 f f' h) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u1} β] (f : HeytingHom.{u2, u1} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u2} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} α β _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) (HeytingHom.copy.{u2, u1} α β _inst_1 _inst_2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align heyting_hom.copy_eq HeytingHom.copy_eqₓ'. -/\ntheorem copy_eq (f : HeytingHom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align heyting_hom.copy_eq HeytingHom.copy_eq\n\nvariable (α)\n\n#print HeytingHom.id /-\n/-- `id` as a `heyting_hom`. -/\nprotected def id : HeytingHom α α :=\n  { BotHom.id _ with\n    toLatticeHom := LatticeHom.id _\n    map_himp' := fun a b => rfl }\n#align heyting_hom.id HeytingHom.id\n-/\n\n/- warning: heyting_hom.coe_id -> HeytingHom.coe_id is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : HeytingAlgebra.{u1} α], Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) (fun (_x : HeytingHom.{u1, u1} α α _inst_1 _inst_1) => α -> α) (HeytingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (HeytingHom.id.{u1} α _inst_1)) (id.{succ u1} α)\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : HeytingAlgebra.{u1} α], Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) _x) (InfHomClass.toFunLike.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α _inst_1 _inst_1 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u1} α α _inst_1 _inst_1))))) (HeytingHom.id.{u1} α _inst_1)) (id.{succ u1} α)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.coe_id HeytingHom.coe_idₓ'. -/\n@[simp]\ntheorem coe_id : ⇑(HeytingHom.id α) = id :=\n  rfl\n#align heyting_hom.coe_id HeytingHom.coe_id\n\nvariable {α}\n\n/- warning: heyting_hom.id_apply -> HeytingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : HeytingAlgebra.{u1} α] (a : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) (fun (_x : HeytingHom.{u1, u1} α α _inst_1 _inst_1) => α -> α) (HeytingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (HeytingHom.id.{u1} α _inst_1) a) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : HeytingAlgebra.{u1} α] (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) _x) (InfHomClass.toFunLike.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} α α _inst_1 _inst_1) α α _inst_1 _inst_1 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u1} α α _inst_1 _inst_1))))) (HeytingHom.id.{u1} α _inst_1) a) a\nCase conversion may be inaccurate. Consider using '#align heyting_hom.id_apply HeytingHom.id_applyₓ'. -/\n@[simp]\ntheorem id_apply (a : α) : HeytingHom.id α a = a :=\n  rfl\n#align heyting_hom.id_apply HeytingHom.id_apply\n\ninstance : Inhabited (HeytingHom α α) :=\n  ⟨HeytingHom.id _⟩\n\ninstance : PartialOrder (HeytingHom α β) :=\n  PartialOrder.lift _ FunLike.coe_injective\n\n#print HeytingHom.comp /-\n/-- Composition of `heyting_hom`s as a `heyting_hom`. -/\ndef comp (f : HeytingHom β γ) (g : HeytingHom α β) : HeytingHom α γ :=\n  { f.toLatticeHom.comp g.toLatticeHom with\n    toFun := f ∘ g\n    map_bot' := by simp\n    map_himp' := fun a b => by simp }\n#align heyting_hom.comp HeytingHom.comp\n-/\n\nvariable {f f₁ f₂ : HeytingHom α β} {g g₁ g₂ : HeytingHom β γ}\n\n/- warning: heyting_hom.coe_comp -> HeytingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] [_inst_3 : HeytingAlgebra.{u3} γ] (f : HeytingHom.{u2, u3} β γ _inst_2 _inst_3) (g : HeytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (α -> γ) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (HeytingHom.{u1, u3} α γ _inst_1 _inst_3) (fun (_x : HeytingHom.{u1, u3} α γ _inst_1 _inst_3) => α -> γ) (HeytingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u2, succ u3} α β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (HeytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : HeytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (HeytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u3} β] [_inst_3 : HeytingAlgebra.{u2} γ] (f : HeytingHom.{u3, u2} β γ _inst_2 _inst_3) (g : HeytingHom.{u1, u3} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) ᾰ) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ _inst_1 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u2} α γ _inst_1 _inst_3))))) (HeytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} β γ _inst_2 _inst_3))))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u3} α β _inst_1 _inst_2))))) g))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.coe_comp HeytingHom.coe_compₓ'. -/\n@[simp]\ntheorem coe_comp (f : HeytingHom β γ) (g : HeytingHom α β) : ⇑(f.comp g) = f ∘ g :=\n  rfl\n#align heyting_hom.coe_comp HeytingHom.coe_comp\n\n/- warning: heyting_hom.comp_apply -> HeytingHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] [_inst_3 : HeytingAlgebra.{u3} γ] (f : HeytingHom.{u2, u3} β γ _inst_2 _inst_3) (g : HeytingHom.{u1, u2} α β _inst_1 _inst_2) (a : α), Eq.{succ u3} γ (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (HeytingHom.{u1, u3} α γ _inst_1 _inst_3) (fun (_x : HeytingHom.{u1, u3} α γ _inst_1 _inst_3) => α -> γ) (HeytingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (HeytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : HeytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (HeytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u3} β] [_inst_3 : HeytingAlgebra.{u2} γ] (f : HeytingHom.{u3, u2} β γ _inst_2 _inst_3) (g : HeytingHom.{u1, u3} α β _inst_1 _inst_2) (a : α), Eq.{succ u2} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ _inst_1 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u2} α γ _inst_1 _inst_3))))) (HeytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 f g) a) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} β γ _inst_2 _inst_3))))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u1} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u1} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u3} α β _inst_1 _inst_2))))) g a))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.comp_apply HeytingHom.comp_applyₓ'. -/\n@[simp]\ntheorem comp_apply (f : HeytingHom β γ) (g : HeytingHom α β) (a : α) : f.comp g a = f (g a) :=\n  rfl\n#align heyting_hom.comp_apply HeytingHom.comp_apply\n\n/- warning: heyting_hom.comp_assoc -> HeytingHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] [_inst_3 : HeytingAlgebra.{u3} γ] [_inst_4 : HeytingAlgebra.{u4} δ] (f : HeytingHom.{u3, u4} γ δ _inst_3 _inst_4) (g : HeytingHom.{u2, u3} β γ _inst_2 _inst_3) (h : HeytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u4)} (HeytingHom.{u1, u4} α δ _inst_1 _inst_4) (HeytingHom.comp.{u1, u2, u4} α β δ _inst_1 _inst_2 _inst_4 (HeytingHom.comp.{u2, u3, u4} β γ δ _inst_2 _inst_3 _inst_4 f g) h) (HeytingHom.comp.{u1, u3, u4} α γ δ _inst_1 _inst_3 _inst_4 f (HeytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g h))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u4}} {δ : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] [_inst_3 : HeytingAlgebra.{u4} γ] [_inst_4 : HeytingAlgebra.{u3} δ] (f : HeytingHom.{u4, u3} γ δ _inst_3 _inst_4) (g : HeytingHom.{u2, u4} β γ _inst_2 _inst_3) (h : HeytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} α δ _inst_1 _inst_4) (HeytingHom.comp.{u1, u2, u3} α β δ _inst_1 _inst_2 _inst_4 (HeytingHom.comp.{u2, u4, u3} β γ δ _inst_2 _inst_3 _inst_4 f g) h) (HeytingHom.comp.{u1, u4, u3} α γ δ _inst_1 _inst_3 _inst_4 f (HeytingHom.comp.{u1, u2, u4} α β γ _inst_1 _inst_2 _inst_3 g h))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.comp_assoc HeytingHom.comp_assocₓ'. -/\n@[simp]\ntheorem comp_assoc (f : HeytingHom γ δ) (g : HeytingHom β γ) (h : HeytingHom α β) :\n    (f.comp g).comp h = f.comp (g.comp h) :=\n  rfl\n#align heyting_hom.comp_assoc HeytingHom.comp_assoc\n\n/- warning: heyting_hom.comp_id -> HeytingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] (f : HeytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (HeytingHom.comp.{u1, u1, u2} α α β _inst_1 _inst_1 _inst_2 f (HeytingHom.id.{u1} α _inst_1)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u1} β] (f : HeytingHom.{u2, u1} α β _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) (HeytingHom.comp.{u2, u2, u1} α α β _inst_1 _inst_1 _inst_2 f (HeytingHom.id.{u2} α _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align heyting_hom.comp_id HeytingHom.comp_idₓ'. -/\n@[simp]\ntheorem comp_id (f : HeytingHom α β) : f.comp (HeytingHom.id α) = f :=\n  ext fun a => rfl\n#align heyting_hom.comp_id HeytingHom.comp_id\n\n/- warning: heyting_hom.id_comp -> HeytingHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] (f : HeytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (HeytingHom.comp.{u1, u2, u2} α β β _inst_1 _inst_2 _inst_2 (HeytingHom.id.{u2} β _inst_2) f) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} α] [_inst_2 : HeytingAlgebra.{u1} β] (f : HeytingHom.{u2, u1} α β _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} α β _inst_1 _inst_2) (HeytingHom.comp.{u2, u1, u1} α β β _inst_1 _inst_2 _inst_2 (HeytingHom.id.{u1} β _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align heyting_hom.id_comp HeytingHom.id_compₓ'. -/\n@[simp]\ntheorem id_comp (f : HeytingHom α β) : (HeytingHom.id β).comp f = f :=\n  ext fun a => rfl\n#align heyting_hom.id_comp HeytingHom.id_comp\n\n/- warning: heyting_hom.cancel_right -> HeytingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] [_inst_3 : HeytingAlgebra.{u3} γ] {f : HeytingHom.{u1, u2} α β _inst_1 _inst_2} {g₁ : HeytingHom.{u2, u3} β γ _inst_2 _inst_3} {g₂ : HeytingHom.{u2, u3} β γ _inst_2 _inst_3}, (Function.Surjective.{succ u1, succ u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (HeytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} α γ _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g₁ f) (HeytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u3)} (HeytingHom.{u2, u3} β γ _inst_2 _inst_3) g₁ g₂))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : HeytingAlgebra.{u3} α] [_inst_2 : HeytingAlgebra.{u2} β] [_inst_3 : HeytingAlgebra.{u1} γ] {f : HeytingHom.{u3, u2} α β _inst_1 _inst_2} {g₁ : HeytingHom.{u2, u1} β γ _inst_2 _inst_3} {g₂ : HeytingHom.{u2, u1} β γ _inst_2 _inst_3}, (Function.Surjective.{succ u3, succ u2} α β (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u3} α (GeneralizedHeytingAlgebra.toLattice.{u3} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u3} α (GeneralizedHeytingAlgebra.toLattice.{u3} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2))) (OrderTop.toTop.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (GeneralizedHeytingAlgebra.toLattice.{u3} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} α _inst_1)))))) (BoundedOrder.toOrderTop.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (GeneralizedHeytingAlgebra.toLattice.{u3} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} α _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u3} α _inst_1))) (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)))))) (BoundedOrder.toOrderTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u2} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} α β _inst_1 _inst_2) α β (GeneralizedHeytingAlgebra.toLattice.{u3} α (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} α _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} β _inst_2)) (HeytingAlgebra.toBoundedOrder.{u3} α _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} β _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} α β _inst_1 _inst_2))))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (HeytingHom.{u3, u1} α γ _inst_1 _inst_3) (HeytingHom.comp.{u3, u2, u1} α β γ _inst_1 _inst_2 _inst_3 g₁ f) (HeytingHom.comp.{u3, u2, u1} α β γ _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} β γ _inst_2 _inst_3) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.cancel_right HeytingHom.cancel_rightₓ'. -/\ntheorem cancel_right (hf : Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => ext <| hf.forall.2 <| FunLike.ext_iff.1 h, congr_arg _⟩\n#align heyting_hom.cancel_right HeytingHom.cancel_right\n\n/- warning: heyting_hom.cancel_left -> HeytingHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u2} β] [_inst_3 : HeytingAlgebra.{u3} γ] {f₁ : HeytingHom.{u1, u2} α β _inst_1 _inst_2} {f₂ : HeytingHom.{u1, u2} α β _inst_1 _inst_2} {g : HeytingHom.{u2, u3} β γ _inst_2 _inst_3}, (Function.Injective.{succ u2, succ u3} β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (HeytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : HeytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (HeytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} α γ _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g f₁) (HeytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α β _inst_1 _inst_2) f₁ f₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} α] [_inst_2 : HeytingAlgebra.{u3} β] [_inst_3 : HeytingAlgebra.{u2} γ] {f₁ : HeytingHom.{u1, u3} α β _inst_1 _inst_2} {f₂ : HeytingHom.{u1, u3} α β _inst_1 _inst_2} {g : HeytingHom.{u3, u2} β γ _inst_2 _inst_3}, (Function.Injective.{succ u3, succ u2} β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedHeytingAlgebra.toLattice.{u3} β (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} β _inst_2)) (GeneralizedHeytingAlgebra.toLattice.{u2} γ (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} γ _inst_3)) (HeytingAlgebra.toBoundedOrder.{u3} β _inst_2) (HeytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} β γ _inst_2 _inst_3))))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} α γ _inst_1 _inst_3) (HeytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 g f₁) (HeytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} α β _inst_1 _inst_2) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.cancel_left HeytingHom.cancel_leftₓ'. -/\ntheorem cancel_left (hg : Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => HeytingHom.ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩\n#align heyting_hom.cancel_left HeytingHom.cancel_left\n\nend HeytingHom\n\nnamespace CoheytingHom\n\nvariable [CoheytingAlgebra α] [CoheytingAlgebra β] [CoheytingAlgebra γ] [CoheytingAlgebra δ]\n\ninstance : CoheytingHomClass (CoheytingHom α β) α β\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := f <;> obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := g <;> congr\n  map_sup f := f.map_sup'\n  map_inf f := f.map_inf'\n  map_top f := f.map_top'\n  map_sdiff := CoheytingHom.map_sdiff'\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : CoeFun (CoheytingHom α β) fun _ => α → β :=\n  FunLike.hasCoeToFun\n\n/- warning: coheyting_hom.to_fun_eq_coe -> CoheytingHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] {f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2}, Eq.{max (succ u1) (succ u2)} (α -> β) (SupHom.toFun.{u1, u2} α β (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))) (SemilatticeSup.toHasSup.{u2} β (Lattice.toSemilatticeSup.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)))) (LatticeHom.toSupHom.{u1, u2} α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)) (CoheytingHom.toLatticeHom.{u1, u2} α β _inst_1 _inst_2 f))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u1} β] {f : CoheytingHom.{u2, u1} α β _inst_1 _inst_2}, Eq.{max (succ u2) (succ u1)} (α -> β) (SupHom.toFun.{u2, u1} α β (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))) (SemilatticeSup.toSup.{u1} β (Lattice.toSemilatticeSup.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))) (LatticeHom.toSupHom.{u2, u1} α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)) (CoheytingHom.toLatticeHom.{u2, u1} α β _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} α β _inst_1 _inst_2))))) f)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.to_fun_eq_coe CoheytingHom.toFun_eq_coeₓ'. -/\n@[simp]\ntheorem toFun_eq_coe {f : CoheytingHom α β} : f.toFun = (f : α → β) :=\n  rfl\n#align coheyting_hom.to_fun_eq_coe CoheytingHom.toFun_eq_coe\n\n/- warning: coheyting_hom.ext -> CoheytingHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] {f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2} {g : CoheytingHom.{u1, u2} α β _inst_1 _inst_2}, (forall (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g a)) -> (Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u1} β] {f : CoheytingHom.{u2, u1} α β _inst_1 _inst_2} {g : CoheytingHom.{u2, u1} α β _inst_1 _inst_2}, (forall (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} α β _inst_1 _inst_2))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} α β _inst_1 _inst_2))))) g a)) -> (Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.ext CoheytingHom.extₓ'. -/\n@[ext]\ntheorem ext {f g : CoheytingHom α β} (h : ∀ a, f a = g a) : f = g :=\n  FunLike.ext f g h\n#align coheyting_hom.ext CoheytingHom.ext\n\n/- warning: coheyting_hom.copy -> CoheytingHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] (f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)) -> (CoheytingHom.{u1, u2} α β _inst_1 _inst_2)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] (f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)))))) (BoundedOrder.toOrderTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u2} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u2} α β _inst_1 _inst_2))))) f)) -> (CoheytingHom.{u1, u2} α β _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.copy CoheytingHom.copyₓ'. -/\n/-- Copy of a `coheyting_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : CoheytingHom α β) (f' : α → β) (h : f' = f) : CoheytingHom α β\n    where\n  toFun := f'\n  map_sup' := by simpa only [h] using map_sup f\n  map_inf' := by simpa only [h] using map_inf f\n  map_top' := by simpa only [h] using map_top f\n  map_sdiff' := by simpa only [h] using map_sdiff f\n#align coheyting_hom.copy CoheytingHom.copy\n\n/- warning: coheyting_hom.coe_copy -> CoheytingHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] (f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) (CoheytingHom.copy.{u1, u2} α β _inst_1 _inst_2 f f' h)) f'\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u1} β] (f : CoheytingHom.{u2, u1} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} α β _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} α β _inst_1 _inst_2))))) (CoheytingHom.copy.{u2, u1} α β _inst_1 _inst_2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.coe_copy CoheytingHom.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (f : CoheytingHom α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align coheyting_hom.coe_copy CoheytingHom.coe_copy\n\n/- warning: coheyting_hom.copy_eq -> CoheytingHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] (f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (CoheytingHom.copy.{u1, u2} α β _inst_1 _inst_2 f f' h) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u1} β] (f : CoheytingHom.{u2, u1} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} α β _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) (CoheytingHom.copy.{u2, u1} α β _inst_1 _inst_2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.copy_eq CoheytingHom.copy_eqₓ'. -/\ntheorem copy_eq (f : CoheytingHom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align coheyting_hom.copy_eq CoheytingHom.copy_eq\n\nvariable (α)\n\n#print CoheytingHom.id /-\n/-- `id` as a `coheyting_hom`. -/\nprotected def id : CoheytingHom α α :=\n  { TopHom.id _ with\n    toLatticeHom := LatticeHom.id _\n    map_sdiff' := fun a b => rfl }\n#align coheyting_hom.id CoheytingHom.id\n-/\n\n/- warning: coheyting_hom.coe_id -> CoheytingHom.coe_id is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : CoheytingAlgebra.{u1} α], Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) (fun (_x : CoheytingHom.{u1, u1} α α _inst_1 _inst_1) => α -> α) (CoheytingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (CoheytingHom.id.{u1} α _inst_1)) (id.{succ u1} α)\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : CoheytingAlgebra.{u1} α], Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) _x) (InfHomClass.toFunLike.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α _inst_1 _inst_1 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u1} α α _inst_1 _inst_1))))) (CoheytingHom.id.{u1} α _inst_1)) (id.{succ u1} α)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.coe_id CoheytingHom.coe_idₓ'. -/\n@[simp]\ntheorem coe_id : ⇑(CoheytingHom.id α) = id :=\n  rfl\n#align coheyting_hom.coe_id CoheytingHom.coe_id\n\nvariable {α}\n\n/- warning: coheyting_hom.id_apply -> CoheytingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u1} α] (a : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) (fun (_x : CoheytingHom.{u1, u1} α α _inst_1 _inst_1) => α -> α) (CoheytingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (CoheytingHom.id.{u1} α _inst_1) a) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u1} α] (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) _x) (InfHomClass.toFunLike.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} α α _inst_1 _inst_1) α α _inst_1 _inst_1 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u1} α α _inst_1 _inst_1))))) (CoheytingHom.id.{u1} α _inst_1) a) a\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.id_apply CoheytingHom.id_applyₓ'. -/\n@[simp]\ntheorem id_apply (a : α) : CoheytingHom.id α a = a :=\n  rfl\n#align coheyting_hom.id_apply CoheytingHom.id_apply\n\ninstance : Inhabited (CoheytingHom α α) :=\n  ⟨CoheytingHom.id _⟩\n\ninstance : PartialOrder (CoheytingHom α β) :=\n  PartialOrder.lift _ FunLike.coe_injective\n\n#print CoheytingHom.comp /-\n/-- Composition of `coheyting_hom`s as a `coheyting_hom`. -/\ndef comp (f : CoheytingHom β γ) (g : CoheytingHom α β) : CoheytingHom α γ :=\n  { f.toLatticeHom.comp g.toLatticeHom with\n    toFun := f ∘ g\n    map_top' := by simp\n    map_sdiff' := fun a b => by simp }\n#align coheyting_hom.comp CoheytingHom.comp\n-/\n\nvariable {f f₁ f₂ : CoheytingHom α β} {g g₁ g₂ : CoheytingHom β γ}\n\n/- warning: coheyting_hom.coe_comp -> CoheytingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] [_inst_3 : CoheytingAlgebra.{u3} γ] (f : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) (g : CoheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (α -> γ) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} α γ _inst_1 _inst_3) (fun (_x : CoheytingHom.{u1, u3} α γ _inst_1 _inst_3) => α -> γ) (CoheytingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u2, succ u3} α β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (CoheytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u3} β] [_inst_3 : CoheytingAlgebra.{u2} γ] (f : CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) (g : CoheytingHom.{u1, u3} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) ᾰ) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ _inst_1 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u2} α γ _inst_1 _inst_3))))) (CoheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} β γ _inst_2 _inst_3))))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u3} α β _inst_1 _inst_2))))) g))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.coe_comp CoheytingHom.coe_compₓ'. -/\n@[simp]\ntheorem coe_comp (f : CoheytingHom β γ) (g : CoheytingHom α β) : ⇑(f.comp g) = f ∘ g :=\n  rfl\n#align coheyting_hom.coe_comp CoheytingHom.coe_comp\n\n/- warning: coheyting_hom.comp_apply -> CoheytingHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] [_inst_3 : CoheytingAlgebra.{u3} γ] (f : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) (g : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (a : α), Eq.{succ u3} γ (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} α γ _inst_1 _inst_3) (fun (_x : CoheytingHom.{u1, u3} α γ _inst_1 _inst_3) => α -> γ) (CoheytingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (CoheytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u3} β] [_inst_3 : CoheytingAlgebra.{u2} γ] (f : CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) (g : CoheytingHom.{u1, u3} α β _inst_1 _inst_2) (a : α), Eq.{succ u2} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ _inst_1 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u2} α γ _inst_1 _inst_3))))) (CoheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 f g) a) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} β γ _inst_2 _inst_3))))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u1} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u3} α β _inst_1 _inst_2))))) g a))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.comp_apply CoheytingHom.comp_applyₓ'. -/\n@[simp]\ntheorem comp_apply (f : CoheytingHom β γ) (g : CoheytingHom α β) (a : α) : f.comp g a = f (g a) :=\n  rfl\n#align coheyting_hom.comp_apply CoheytingHom.comp_apply\n\n/- warning: coheyting_hom.comp_assoc -> CoheytingHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] [_inst_3 : CoheytingAlgebra.{u3} γ] [_inst_4 : CoheytingAlgebra.{u4} δ] (f : CoheytingHom.{u3, u4} γ δ _inst_3 _inst_4) (g : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) (h : CoheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u4)} (CoheytingHom.{u1, u4} α δ _inst_1 _inst_4) (CoheytingHom.comp.{u1, u2, u4} α β δ _inst_1 _inst_2 _inst_4 (CoheytingHom.comp.{u2, u3, u4} β γ δ _inst_2 _inst_3 _inst_4 f g) h) (CoheytingHom.comp.{u1, u3, u4} α γ δ _inst_1 _inst_3 _inst_4 f (CoheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g h))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u4}} {δ : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] [_inst_3 : CoheytingAlgebra.{u4} γ] [_inst_4 : CoheytingAlgebra.{u3} δ] (f : CoheytingHom.{u4, u3} γ δ _inst_3 _inst_4) (g : CoheytingHom.{u2, u4} β γ _inst_2 _inst_3) (h : CoheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} α δ _inst_1 _inst_4) (CoheytingHom.comp.{u1, u2, u3} α β δ _inst_1 _inst_2 _inst_4 (CoheytingHom.comp.{u2, u4, u3} β γ δ _inst_2 _inst_3 _inst_4 f g) h) (CoheytingHom.comp.{u1, u4, u3} α γ δ _inst_1 _inst_3 _inst_4 f (CoheytingHom.comp.{u1, u2, u4} α β γ _inst_1 _inst_2 _inst_3 g h))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.comp_assoc CoheytingHom.comp_assocₓ'. -/\n@[simp]\ntheorem comp_assoc (f : CoheytingHom γ δ) (g : CoheytingHom β γ) (h : CoheytingHom α β) :\n    (f.comp g).comp h = f.comp (g.comp h) :=\n  rfl\n#align coheyting_hom.comp_assoc CoheytingHom.comp_assoc\n\n/- warning: coheyting_hom.comp_id -> CoheytingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] (f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (CoheytingHom.comp.{u1, u1, u2} α α β _inst_1 _inst_1 _inst_2 f (CoheytingHom.id.{u1} α _inst_1)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u1} β] (f : CoheytingHom.{u2, u1} α β _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) (CoheytingHom.comp.{u2, u2, u1} α α β _inst_1 _inst_1 _inst_2 f (CoheytingHom.id.{u2} α _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.comp_id CoheytingHom.comp_idₓ'. -/\n@[simp]\ntheorem comp_id (f : CoheytingHom α β) : f.comp (CoheytingHom.id α) = f :=\n  ext fun a => rfl\n#align coheyting_hom.comp_id CoheytingHom.comp_id\n\n/- warning: coheyting_hom.id_comp -> CoheytingHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] (f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (CoheytingHom.comp.{u1, u2, u2} α β β _inst_1 _inst_2 _inst_2 (CoheytingHom.id.{u2} β _inst_2) f) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} α] [_inst_2 : CoheytingAlgebra.{u1} β] (f : CoheytingHom.{u2, u1} α β _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} α β _inst_1 _inst_2) (CoheytingHom.comp.{u2, u1, u1} α β β _inst_1 _inst_2 _inst_2 (CoheytingHom.id.{u1} β _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.id_comp CoheytingHom.id_compₓ'. -/\n@[simp]\ntheorem id_comp (f : CoheytingHom α β) : (CoheytingHom.id β).comp f = f :=\n  ext fun a => rfl\n#align coheyting_hom.id_comp CoheytingHom.id_comp\n\n/- warning: coheyting_hom.cancel_right -> CoheytingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] [_inst_3 : CoheytingAlgebra.{u3} γ] {f : CoheytingHom.{u1, u2} α β _inst_1 _inst_2} {g₁ : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3} {g₂ : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3}, (Function.Surjective.{succ u1, succ u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (CoheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} α γ _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g₁ f) (CoheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) g₁ g₂))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u3} α] [_inst_2 : CoheytingAlgebra.{u2} β] [_inst_3 : CoheytingAlgebra.{u1} γ] {f : CoheytingHom.{u3, u2} α β _inst_1 _inst_2} {g₁ : CoheytingHom.{u2, u1} β γ _inst_2 _inst_3} {g₂ : CoheytingHom.{u2, u1} β γ _inst_2 _inst_3}, (Function.Surjective.{succ u3, succ u2} α β (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α _inst_1))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2))) (OrderTop.toTop.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α _inst_1)))))) (BoundedOrder.toOrderTop.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u3} α _inst_1))) (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)))))) (BoundedOrder.toOrderTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u2} β _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u3} α _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} β _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} α β _inst_1 _inst_2))))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (CoheytingHom.{u3, u1} α γ _inst_1 _inst_3) (CoheytingHom.comp.{u3, u2, u1} α β γ _inst_1 _inst_2 _inst_3 g₁ f) (CoheytingHom.comp.{u3, u2, u1} α β γ _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} β γ _inst_2 _inst_3) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.cancel_right CoheytingHom.cancel_rightₓ'. -/\ntheorem cancel_right (hf : Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => ext <| hf.forall.2 <| FunLike.ext_iff.1 h, congr_arg _⟩\n#align coheyting_hom.cancel_right CoheytingHom.cancel_right\n\n/- warning: coheyting_hom.cancel_left -> CoheytingHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u2} β] [_inst_3 : CoheytingAlgebra.{u3} γ] {f₁ : CoheytingHom.{u1, u2} α β _inst_1 _inst_2} {f₂ : CoheytingHom.{u1, u2} α β _inst_1 _inst_2} {g : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3}, (Function.Injective.{succ u2, succ u3} β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : CoheytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (CoheytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} α γ _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g f₁) (CoheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α β _inst_1 _inst_2) f₁ f₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} α] [_inst_2 : CoheytingAlgebra.{u3} β] [_inst_3 : CoheytingAlgebra.{u2} γ] {f₁ : CoheytingHom.{u1, u3} α β _inst_1 _inst_2} {f₂ : CoheytingHom.{u1, u3} α β _inst_1 _inst_2} {g : CoheytingHom.{u3, u2} β γ _inst_2 _inst_3}, (Function.Injective.{succ u3, succ u2} β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β _inst_2)) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u3} β _inst_2) (CoheytingAlgebra.toBoundedOrder.{u2} γ _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} β γ _inst_2 _inst_3))))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} α γ _inst_1 _inst_3) (CoheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 g f₁) (CoheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} α β _inst_1 _inst_2) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.cancel_left CoheytingHom.cancel_leftₓ'. -/\ntheorem cancel_left (hg : Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => CoheytingHom.ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩\n#align coheyting_hom.cancel_left CoheytingHom.cancel_left\n\nend CoheytingHom\n\nnamespace BiheytingHom\n\nvariable [BiheytingAlgebra α] [BiheytingAlgebra β] [BiheytingAlgebra γ] [BiheytingAlgebra δ]\n\ninstance : BiheytingHomClass (BiheytingHom α β) α β\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := f <;> obtain ⟨⟨⟨_, _⟩, _⟩, _⟩ := g <;> congr\n  map_sup f := f.map_sup'\n  map_inf f := f.map_inf'\n  map_himp f := f.map_himp'\n  map_sdiff f := f.map_sdiff'\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : CoeFun (BiheytingHom α β) fun _ => α → β :=\n  FunLike.hasCoeToFun\n\n/- warning: biheyting_hom.to_fun_eq_coe -> BiheytingHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] {f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2}, Eq.{max (succ u1) (succ u2)} (α -> β) (SupHom.toFun.{u1, u2} α β (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))) (SemilatticeSup.toHasSup.{u2} β (Lattice.toSemilatticeSup.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))))) (LatticeHom.toSupHom.{u1, u2} α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))) (BiheytingHom.toLatticeHom.{u1, u2} α β _inst_1 _inst_2 f))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} α] [_inst_2 : BiheytingAlgebra.{u1} β] {f : BiheytingHom.{u2, u1} α β _inst_1 _inst_2}, Eq.{max (succ u2) (succ u1)} (α -> β) (SupHom.toFun.{u2, u1} α β (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))) (SemilatticeSup.toSup.{u1} β (Lattice.toSemilatticeSup.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))) (LatticeHom.toSupHom.{u2, u1} α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))) (BiheytingHom.toLatticeHom.{u2, u1} α β _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} α β _inst_1 _inst_2)))))) f)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.to_fun_eq_coe BiheytingHom.toFun_eq_coeₓ'. -/\n@[simp]\ntheorem toFun_eq_coe {f : BiheytingHom α β} : f.toFun = (f : α → β) :=\n  rfl\n#align biheyting_hom.to_fun_eq_coe BiheytingHom.toFun_eq_coe\n\n/- warning: biheyting_hom.ext -> BiheytingHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] {f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2} {g : BiheytingHom.{u1, u2} α β _inst_1 _inst_2}, (forall (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g a)) -> (Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} α] [_inst_2 : BiheytingAlgebra.{u1} β] {f : BiheytingHom.{u2, u1} α β _inst_1 _inst_2} {g : BiheytingHom.{u2, u1} α β _inst_1 _inst_2}, (forall (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} α β _inst_1 _inst_2)))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} α β _inst_1 _inst_2)))))) g a)) -> (Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.ext BiheytingHom.extₓ'. -/\n@[ext]\ntheorem ext {f g : BiheytingHom α β} (h : ∀ a, f a = g a) : f = g :=\n  FunLike.ext f g h\n#align biheyting_hom.ext BiheytingHom.ext\n\n/- warning: biheyting_hom.copy -> BiheytingHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] (f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)) -> (BiheytingHom.{u1, u2} α β _inst_1 _inst_2)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] (f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))))))) (BoundedOrder.toOrderTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u2} α β _inst_1 _inst_2)))))) f)) -> (BiheytingHom.{u1, u2} α β _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.copy BiheytingHom.copyₓ'. -/\n/-- Copy of a `biheyting_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : BiheytingHom α β) (f' : α → β) (h : f' = f) : BiheytingHom α β\n    where\n  toFun := f'\n  map_sup' := by simpa only [h] using map_sup f\n  map_inf' := by simpa only [h] using map_inf f\n  map_himp' := by simpa only [h] using map_himp f\n  map_sdiff' := by simpa only [h] using map_sdiff f\n#align biheyting_hom.copy BiheytingHom.copy\n\n/- warning: biheyting_hom.coe_copy -> BiheytingHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] (f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) (BiheytingHom.copy.{u1, u2} α β _inst_1 _inst_2 f f' h)) f'\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} α] [_inst_2 : BiheytingAlgebra.{u1} β] (f : BiheytingHom.{u2, u1} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} α β _inst_1 _inst_2)))))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} α β _inst_1 _inst_2)))))) (BiheytingHom.copy.{u2, u1} α β _inst_1 _inst_2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.coe_copy BiheytingHom.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (f : BiheytingHom α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align biheyting_hom.coe_copy BiheytingHom.coe_copy\n\n/- warning: biheyting_hom.copy_eq -> BiheytingHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] (f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (BiheytingHom.copy.{u1, u2} α β _inst_1 _inst_2 f f' h) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} α] [_inst_2 : BiheytingAlgebra.{u1} β] (f : BiheytingHom.{u2, u1} α β _inst_1 _inst_2) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (Lattice.toInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (Lattice.toInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (OrderTop.toTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (BoundedOrder.toOrderTop.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)))) (OrderTop.toTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (BoundedOrder.toOrderTop.{u1} β (Preorder.toLE.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u2} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} α (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} β (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u2} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} α β _inst_1 _inst_2)))))) f)), Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) (BiheytingHom.copy.{u2, u1} α β _inst_1 _inst_2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.copy_eq BiheytingHom.copy_eqₓ'. -/\ntheorem copy_eq (f : BiheytingHom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align biheyting_hom.copy_eq BiheytingHom.copy_eq\n\nvariable (α)\n\n#print BiheytingHom.id /-\n/-- `id` as a `biheyting_hom`. -/\nprotected def id : BiheytingHom α α :=\n  { HeytingHom.id _, CoheytingHom.id _ with toLatticeHom := LatticeHom.id _ }\n#align biheyting_hom.id BiheytingHom.id\n-/\n\n/- warning: biheyting_hom.coe_id -> BiheytingHom.coe_id is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : BiheytingAlgebra.{u1} α], Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) (fun (_x : BiheytingHom.{u1, u1} α α _inst_1 _inst_1) => α -> α) (BiheytingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (BiheytingHom.id.{u1} α _inst_1)) (id.{succ u1} α)\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : BiheytingAlgebra.{u1} α], Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) _x) (InfHomClass.toFunLike.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingHomClass.toCoheytingHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α _inst_1 _inst_1 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u1} α α _inst_1 _inst_1)))))) (BiheytingHom.id.{u1} α _inst_1)) (id.{succ u1} α)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.coe_id BiheytingHom.coe_idₓ'. -/\n@[simp]\ntheorem coe_id : ⇑(BiheytingHom.id α) = id :=\n  rfl\n#align biheyting_hom.coe_id BiheytingHom.coe_id\n\nvariable {α}\n\n/- warning: biheyting_hom.id_apply -> BiheytingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u1} α] (a : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) (fun (_x : BiheytingHom.{u1, u1} α α _inst_1 _inst_1) => α -> α) (BiheytingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (BiheytingHom.id.{u1} α _inst_1) a) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u1} α] (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => α) _x) (InfHomClass.toFunLike.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingHomClass.toCoheytingHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} α α _inst_1 _inst_1) α α _inst_1 _inst_1 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u1} α α _inst_1 _inst_1)))))) (BiheytingHom.id.{u1} α _inst_1) a) a\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.id_apply BiheytingHom.id_applyₓ'. -/\n@[simp]\ntheorem id_apply (a : α) : BiheytingHom.id α a = a :=\n  rfl\n#align biheyting_hom.id_apply BiheytingHom.id_apply\n\ninstance : Inhabited (BiheytingHom α α) :=\n  ⟨BiheytingHom.id _⟩\n\ninstance : PartialOrder (BiheytingHom α β) :=\n  PartialOrder.lift _ FunLike.coe_injective\n\n#print BiheytingHom.comp /-\n/-- Composition of `biheyting_hom`s as a `biheyting_hom`. -/\ndef comp (f : BiheytingHom β γ) (g : BiheytingHom α β) : BiheytingHom α γ :=\n  { f.toLatticeHom.comp g.toLatticeHom with\n    toFun := f ∘ g\n    map_himp' := fun a b => by simp\n    map_sdiff' := fun a b => by simp }\n#align biheyting_hom.comp BiheytingHom.comp\n-/\n\nvariable {f f₁ f₂ : BiheytingHom α β} {g g₁ g₂ : BiheytingHom β γ}\n\n/- warning: biheyting_hom.coe_comp -> BiheytingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] [_inst_3 : BiheytingAlgebra.{u3} γ] (f : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) (g : BiheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (α -> γ) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} α γ _inst_1 _inst_3) (fun (_x : BiheytingHom.{u1, u3} α γ _inst_1 _inst_3) => α -> γ) (BiheytingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u2, succ u3} α β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (BiheytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u3} β] [_inst_3 : BiheytingAlgebra.{u2} γ] (f : BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) (g : BiheytingHom.{u1, u3} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) ᾰ) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ _inst_1 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u2} α γ _inst_1 _inst_3)))))) (BiheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2) (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} β γ _inst_2 _inst_3)))))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u3} α β _inst_1 _inst_2)))))) g))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.coe_comp BiheytingHom.coe_compₓ'. -/\n@[simp]\ntheorem coe_comp (f : BiheytingHom β γ) (g : BiheytingHom α β) : ⇑(f.comp g) = f ∘ g :=\n  rfl\n#align biheyting_hom.coe_comp BiheytingHom.coe_comp\n\n/- warning: biheyting_hom.comp_apply -> BiheytingHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] [_inst_3 : BiheytingAlgebra.{u3} γ] (f : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) (g : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (a : α), Eq.{succ u3} γ (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} α γ _inst_1 _inst_3) (fun (_x : BiheytingHom.{u1, u3} α γ _inst_1 _inst_3) => α -> γ) (BiheytingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (BiheytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) g a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u3} β] [_inst_3 : BiheytingAlgebra.{u2} γ] (f : BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) (g : BiheytingHom.{u1, u3} α β _inst_1 _inst_2) (a : α), Eq.{succ u2} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => γ) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) α γ _inst_1 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u2} α γ _inst_1 _inst_3)))))) (BiheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 f g) a) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2) (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} β γ _inst_2 _inst_3)))))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (Lattice.toInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (OrderTop.toTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (BoundedOrder.toOrderTop.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u1} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u1} α (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u1} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u3} α β _inst_1 _inst_2)))))) g a))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.comp_apply BiheytingHom.comp_applyₓ'. -/\n@[simp]\ntheorem comp_apply (f : BiheytingHom β γ) (g : BiheytingHom α β) (a : α) : f.comp g a = f (g a) :=\n  rfl\n#align biheyting_hom.comp_apply BiheytingHom.comp_apply\n\n/- warning: biheyting_hom.comp_assoc -> BiheytingHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] [_inst_3 : BiheytingAlgebra.{u3} γ] [_inst_4 : BiheytingAlgebra.{u4} δ] (f : BiheytingHom.{u3, u4} γ δ _inst_3 _inst_4) (g : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) (h : BiheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u4)} (BiheytingHom.{u1, u4} α δ _inst_1 _inst_4) (BiheytingHom.comp.{u1, u2, u4} α β δ _inst_1 _inst_2 _inst_4 (BiheytingHom.comp.{u2, u3, u4} β γ δ _inst_2 _inst_3 _inst_4 f g) h) (BiheytingHom.comp.{u1, u3, u4} α γ δ _inst_1 _inst_3 _inst_4 f (BiheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g h))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u4}} {δ : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] [_inst_3 : BiheytingAlgebra.{u4} γ] [_inst_4 : BiheytingAlgebra.{u3} δ] (f : BiheytingHom.{u4, u3} γ δ _inst_3 _inst_4) (g : BiheytingHom.{u2, u4} β γ _inst_2 _inst_3) (h : BiheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} α δ _inst_1 _inst_4) (BiheytingHom.comp.{u1, u2, u3} α β δ _inst_1 _inst_2 _inst_4 (BiheytingHom.comp.{u2, u4, u3} β γ δ _inst_2 _inst_3 _inst_4 f g) h) (BiheytingHom.comp.{u1, u4, u3} α γ δ _inst_1 _inst_3 _inst_4 f (BiheytingHom.comp.{u1, u2, u4} α β γ _inst_1 _inst_2 _inst_3 g h))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.comp_assoc BiheytingHom.comp_assocₓ'. -/\n@[simp]\ntheorem comp_assoc (f : BiheytingHom γ δ) (g : BiheytingHom β γ) (h : BiheytingHom α β) :\n    (f.comp g).comp h = f.comp (g.comp h) :=\n  rfl\n#align biheyting_hom.comp_assoc BiheytingHom.comp_assoc\n\n/- warning: biheyting_hom.comp_id -> BiheytingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] (f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (BiheytingHom.comp.{u1, u1, u2} α α β _inst_1 _inst_1 _inst_2 f (BiheytingHom.id.{u1} α _inst_1)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} α] [_inst_2 : BiheytingAlgebra.{u1} β] (f : BiheytingHom.{u2, u1} α β _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) (BiheytingHom.comp.{u2, u2, u1} α α β _inst_1 _inst_1 _inst_2 f (BiheytingHom.id.{u2} α _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.comp_id BiheytingHom.comp_idₓ'. -/\n@[simp]\ntheorem comp_id (f : BiheytingHom α β) : f.comp (BiheytingHom.id α) = f :=\n  ext fun a => rfl\n#align biheyting_hom.comp_id BiheytingHom.comp_id\n\n/- warning: biheyting_hom.id_comp -> BiheytingHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] (f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (BiheytingHom.comp.{u1, u2, u2} α β β _inst_1 _inst_2 _inst_2 (BiheytingHom.id.{u2} β _inst_2) f) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} α] [_inst_2 : BiheytingAlgebra.{u1} β] (f : BiheytingHom.{u2, u1} α β _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} α β _inst_1 _inst_2) (BiheytingHom.comp.{u2, u1, u1} α β β _inst_1 _inst_2 _inst_2 (BiheytingHom.id.{u1} β _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.id_comp BiheytingHom.id_compₓ'. -/\n@[simp]\ntheorem id_comp (f : BiheytingHom α β) : (BiheytingHom.id β).comp f = f :=\n  ext fun a => rfl\n#align biheyting_hom.id_comp BiheytingHom.id_comp\n\n/- warning: biheyting_hom.cancel_right -> BiheytingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] [_inst_3 : BiheytingAlgebra.{u3} γ] {f : BiheytingHom.{u1, u2} α β _inst_1 _inst_2} {g₁ : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3} {g₂ : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3}, (Function.Surjective.{succ u1, succ u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} α β _inst_1 _inst_2) => α -> β) (BiheytingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} α γ _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g₁ f) (BiheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) g₁ g₂))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u3} α] [_inst_2 : BiheytingAlgebra.{u2} β] [_inst_3 : BiheytingAlgebra.{u1} γ] {f : BiheytingHom.{u3, u2} α β _inst_1 _inst_2} {g₁ : BiheytingHom.{u2, u1} β γ _inst_2 _inst_3} {g₂ : BiheytingHom.{u2, u1} β γ _inst_2 _inst_3}, (Function.Surjective.{succ u3, succ u2} α β (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} α β _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : α) => β) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1)))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} α β _inst_1 _inst_2) α β (Lattice.toInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1)))) (Lattice.toInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)))) (OrderTop.toTop.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1))))))) (BoundedOrder.toOrderTop.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u3} α (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1)))) (OrderTop.toTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))))))) (BoundedOrder.toOrderTop.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} α β _inst_1 _inst_2) α β (GeneralizedCoheytingAlgebra.toLattice.{u3} α (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} α (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u3} α (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} β (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} α β _inst_1 _inst_2) α β (BiheytingAlgebra.toCoheytingAlgebra.{u3} α _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} β _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} α β _inst_1 _inst_2) α β _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} α β _inst_1 _inst_2)))))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (BiheytingHom.{u3, u1} α γ _inst_1 _inst_3) (BiheytingHom.comp.{u3, u2, u1} α β γ _inst_1 _inst_2 _inst_3 g₁ f) (BiheytingHom.comp.{u3, u2, u1} α β γ _inst_1 _inst_2 _inst_3 g₂ f)) (Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} β γ _inst_2 _inst_3) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.cancel_right BiheytingHom.cancel_rightₓ'. -/\ntheorem cancel_right (hf : Surjective f) : g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n  ⟨fun h => ext <| hf.forall.2 <| FunLike.ext_iff.1 h, congr_arg _⟩\n#align biheyting_hom.cancel_right BiheytingHom.cancel_right\n\n/- warning: biheyting_hom.cancel_left -> BiheytingHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u2} β] [_inst_3 : BiheytingAlgebra.{u3} γ] {f₁ : BiheytingHom.{u1, u2} α β _inst_1 _inst_2} {f₂ : BiheytingHom.{u1, u2} α β _inst_1 _inst_2} {g : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3}, (Function.Injective.{succ u2, succ u3} β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) (fun (_x : BiheytingHom.{u2, u3} β γ _inst_2 _inst_3) => β -> γ) (BiheytingHom.hasCoeToFun.{u2, u3} β γ _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} α γ _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g f₁) (BiheytingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α β _inst_1 _inst_2) f₁ f₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} α] [_inst_2 : BiheytingAlgebra.{u3} β] [_inst_3 : BiheytingAlgebra.{u2} γ] {f₁ : BiheytingHom.{u1, u3} α β _inst_1 _inst_2} {f₂ : BiheytingHom.{u1, u3} α β _inst_1 _inst_2} {g : BiheytingHom.{u3, u2} β γ _inst_2 _inst_3}, (Function.Injective.{succ u3, succ u2} β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β (fun (_x : β) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : β) => γ) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (Lattice.toInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (Lattice.toInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (OrderTop.toTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (BoundedOrder.toOrderTop.{u3} β (Preorder.toLE.{u3} β (PartialOrder.toPreorder.{u3} β (SemilatticeInf.toPartialOrder.{u3} β (Lattice.toSemilatticeInf.{u3} β (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)))) (OrderTop.toTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (BoundedOrder.toOrderTop.{u2} γ (Preorder.toLE.{u2} γ (PartialOrder.toPreorder.{u2} γ (SemilatticeInf.toPartialOrder.{u2} γ (Lattice.toSemilatticeInf.{u2} γ (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (GeneralizedCoheytingAlgebra.toLattice.{u3} β (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2))) (GeneralizedCoheytingAlgebra.toLattice.{u2} γ (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u3} β (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} γ (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ (BiheytingAlgebra.toCoheytingAlgebra.{u3} β _inst_2) (BiheytingAlgebra.toCoheytingAlgebra.{u2} γ _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} β γ _inst_2 _inst_3) β γ _inst_2 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} β γ _inst_2 _inst_3)))))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} α γ _inst_1 _inst_3) (BiheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 g f₁) (BiheytingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 g f₂)) (Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} α β _inst_1 _inst_2) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.cancel_left BiheytingHom.cancel_leftₓ'. -/\ntheorem cancel_left (hg : Injective g) : g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n  ⟨fun h => BiheytingHom.ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩\n#align biheyting_hom.cancel_left BiheytingHom.cancel_left\n\nend BiheytingHom\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Heyting/Hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4710476871355415}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.fully_faithful\n\n/-!\n# Functors which reflect isomorphisms\n\nA functor `F` reflects isomorphisms if whenever `F.map f` is an isomorphism, `f` was too.\n\nIt is formalized as a `Prop` valued typeclass `reflects_isomorphisms F`.\n\nAny fully faithful functor reflects isomorphisms.\n-/\n\nopen category_theory\n\nnamespace category_theory\n\nuniverses v₁ v₂ u₁ u₂\n\nvariables {C : Type u₁} [category.{v₁} C]\n\nsection reflects_iso\nvariables {D : Type u₂} [category.{v₂} D]\n\n/--\nDefine what it means for a functor `F : C ⥤ D` to reflect isomorphisms: for any\nmorphism `f : A ⟶ B`, if `F.map f` is an isomorphism then `f` is as well.\nNote that we do not assume or require that `F` is faithful.\n-/\nclass reflects_isomorphisms (F : C ⥤ D) : Prop :=\n(reflects : Π {A B : C} (f : A ⟶ B) [is_iso (F.map f)], is_iso f)\n\n/-- If `F` reflects isos and `F.map f` is an iso, then `f` is an iso. -/\nlemma is_iso_of_reflects_iso {A B : C} (f : A ⟶ B) (F : C ⥤ D)\n  [is_iso (F.map f)] [reflects_isomorphisms F] :\n  is_iso f :=\nreflects_isomorphisms.reflects F f\n\n@[priority 100]\ninstance of_full_and_faithful (F : C ⥤ D) [full F] [faithful F] : reflects_isomorphisms F :=\n{ reflects := λ X Y f i, by exactI\n  ⟨⟨F.preimage (inv (F.map f)), ⟨F.map_injective (by simp), F.map_injective (by simp)⟩⟩⟩ }\n\nend reflects_iso\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/reflects_isomorphisms.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.47104768234029876}}
{"text": "set_option synthInstance.etaExperiment true -- TODO: make work by default\n\nclass NonUnitalNonAssocSemiring (α : Type u)\n\nclass NonUnitalSemiring (α : Type u) extends NonUnitalNonAssocSemiring α\n\nclass Semiring (α : Type u) extends NonUnitalSemiring α\n\nclass NonUnitalCommSemiring (α : Type u) extends NonUnitalSemiring α\n\nclass CommSemiring (R : Type u) extends Semiring R\n\nclass NonUnitalNonAssocRing (α : Type u) extends NonUnitalNonAssocSemiring α\n\nclass NonUnitalRing (α : Type _) extends NonUnitalNonAssocRing α, NonUnitalSemiring α\n\nclass Ring (R : Type u) extends Semiring R\n\nclass NonUnitalCommRing (α : Type u) extends NonUnitalRing α\n\nclass CommRing (α : Type u) extends Ring α\n\ninstance (priority := 100) NonUnitalCommRing.toNonUnitalCommSemiring [s : NonUnitalCommRing α] :\n    NonUnitalCommSemiring α :=\n  { s with }\n\ninstance (priority := 100) CommRing.toCommSemiring [s : CommRing α] : CommSemiring α :=\n  { s with }\n\ninstance (priority := 100) CommSemiring.toNonUnitalCommSemiring [s : CommSemiring α] :\n    NonUnitalCommSemiring α :=\n  { s with }\n\ninstance (priority := 100) CommRing.toNonUnitalCommRing [s : CommRing α] : NonUnitalCommRing α :=\n  { s with }\n\nclass StarRing' (R : Type _) [NonUnitalSemiring R]\ndef starGizmo [CommSemiring R] [StarRing' R] : R → R := id\ntheorem starGizmo_foo [CommRing R] [StarRing' R] (x : R) : starGizmo x = x := rfl\n\nnamespace ReidMWE\n\nclass A (α : Type u)\n\nclass B (α : Type u) extends A α\n\nclass C (α : Type u) extends B α\n\nclass D (α : Type u) extends B α\n\nclass E (α : Type u) extends C α, D α\n\nclass F (α : Type u) extends A α\n\nclass G (α : Type u) extends F α, B α\n\nclass H (α : Type u) extends C α\n\nclass I (α : Type u) extends G α, D α\n\nclass J (α : Type u) extends H α, I α, E α\n\nclass StarRing' (R : Type 0) [B R]\ndef starGizmo [E R] [StarRing' R] : R → R := id\n\ntheorem starGizmo_foo [J R] [StarRing' R] (x : R) : starGizmo x = x := rfl\n\ntheorem T (i : J R) : (@D.toB.{0} R (@E.toD.{0} R (@J.toE.{0} R i))) = i.toB := rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/2074.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.47104767435036377}}
{"text": "/-\nCopyright (c) 2020. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot\n\n! This file was ported from Lean 3 source module tactic.group\n! leanprover-community/mathlib commit 0ff989e5d31dd73bcea3c52be7b601c95d4e3930\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.Ring\nimport Mathbin.Tactic.DocCommands\nimport Mathbin.Algebra.Group.Commutator\n\n/-!\n# `group`\n\nNormalizes expressions in the language of groups. The basic idea is to use the simplifier\nto put everything into a product of group powers (`zpow` which takes a group element and an\ninteger), then simplify the exponents using the `ring` tactic. The process needs to be repeated\nsince `ring` can normalize an exponent to zero, leading to a factor that can be removed\nbefore collecting exponents again. The simplifier step also uses some extra lemmas to avoid\nsome `ring` invocations.\n\n## Tags\n\ngroup_theory\n-/\n\n\n/- warning: tactic.group.zpow_trick -> Mathlib.Tactic.Group.zpow_trick is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] (a : G) (b : G) (n : Int) (m : Int), Eq.{succ u1} G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b n)) (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b m)) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) n m)))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] (a : G) (b : G) (n : Int) (m : Int), Eq.{succ u1} G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b n)) (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b m)) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) n m)))\nCase conversion may be inaccurate. Consider using '#align tactic.group.zpow_trick Mathlib.Tactic.Group.zpow_trickₓ'. -/\n-- The next four lemmas are not general purpose lemmas, they are intended for use only by\n-- the `group` tactic.\n@[to_additive]\ntheorem Mathlib.Tactic.Group.zpow_trick {G : Type _} [Group G] (a b : G) (n m : ℤ) :\n    a * b ^ n * b ^ m = a * b ^ (n + m) := by rw [mul_assoc, ← zpow_add]\n#align tactic.group.zpow_trick Mathlib.Tactic.Group.zpow_trick\n#align tactic.group.zsmul_trick Mathlib.Tactic.Group.zsmul_trick\n\n/- warning: tactic.group.zpow_trick_one -> Mathlib.Tactic.Group.zpow_trick_one is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] (a : G) (b : G) (m : Int), Eq.{succ u1} G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a b) (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b m)) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) m (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] (a : G) (b : G) (m : Int), Eq.{succ u1} G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a b) (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b m)) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) m (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))))\nCase conversion may be inaccurate. Consider using '#align tactic.group.zpow_trick_one Mathlib.Tactic.Group.zpow_trick_oneₓ'. -/\n@[to_additive]\ntheorem Mathlib.Tactic.Group.zpow_trick_one {G : Type _} [Group G] (a b : G) (m : ℤ) :\n    a * b * b ^ m = a * b ^ (m + 1) := by rw [mul_assoc, mul_self_zpow]\n#align tactic.group.zpow_trick_one Mathlib.Tactic.Group.zpow_trick_one\n#align tactic.group.zsmul_trick_zero Mathlib.Tactic.Group.zsmul_trick_zero\n\n/- warning: tactic.group.zpow_trick_one' -> Mathlib.Tactic.Group.zpow_trick_one' is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] (a : G) (b : G) (n : Int), Eq.{succ u1} G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b n)) b) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) n (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne))))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] (a : G) (b : G) (n : Int), Eq.{succ u1} G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b n)) b) (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))) a (HPow.hPow.{u1, 0, u1} G Int G (instHPow.{u1, 0} G Int (DivInvMonoid.Pow.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) b (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) n (OfNat.ofNat.{0} Int 1 (instOfNatInt 1)))))\nCase conversion may be inaccurate. Consider using '#align tactic.group.zpow_trick_one' Mathlib.Tactic.Group.zpow_trick_one'ₓ'. -/\n@[to_additive]\ntheorem Mathlib.Tactic.Group.zpow_trick_one' {G : Type _} [Group G] (a b : G) (n : ℤ) :\n    a * b ^ n * b = a * b ^ (n + 1) := by rw [mul_assoc, mul_zpow_self]\n#align tactic.group.zpow_trick_one' Mathlib.Tactic.Group.zpow_trick_one'\n#align tactic.group.zsmul_trick_zero' Mathlib.Tactic.Group.zsmul_trick_zero'\n\n@[to_additive]\ntheorem Tactic.Group.zpow_trick_sub {G : Type _} [Group G] (a b : G) (n m : ℤ) :\n    a * b ^ n * b ^ (-m) = a * b ^ (n - m) := by rw [mul_assoc, ← zpow_add] <;> rfl\n#align tactic.group.zpow_trick_sub Tactic.Group.zpow_trick_sub\n#align tactic.group.zsmul_trick_sub Tactic.Group.zsmul_trick_sub\n\nnamespace Tactic\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\nopen Tactic.SimpArgType Interactive Tactic.Group\n\n/-- Auxiliary tactic for the `group` tactic. Calls the simplifier only. -/\nunsafe def aux_group₁ (locat : Loc) : tactic Unit :=\n  simp_core { failIfUnchanged := false } skip true\n      [expr ``(commutatorElement_def), expr ``(mul_one), expr ``(one_mul), expr ``(one_pow),\n        expr ``(one_zpow), expr ``(sub_self), expr ``(add_neg_self), expr ``(neg_add_self),\n        expr ``(neg_neg), expr ``(tsub_self), expr ``(Int.ofNat_add), expr ``(Int.ofNat_mul),\n        expr ``(Int.ofNat_zero), expr ``(Int.ofNat_one), expr ``(Int.ofNat_bit0),\n        expr ``(Int.ofNat_bit1), expr ``(Int.mul_neg_eq_neg_mul_symm),\n        expr ``(Int.neg_mul_eq_neg_mul_symm), symm_expr ``(zpow_ofNat), symm_expr ``(zpow_neg_one),\n        symm_expr ``(zpow_mul), symm_expr ``(zpow_add_one), symm_expr ``(zpow_one_add),\n        symm_expr ``(zpow_add), expr ``(mul_zpow_neg_one), expr ``(zpow_zero), expr ``(mul_zpow),\n        symm_expr ``(mul_assoc), expr ``(Mathlib.Tactic.Group.zpow_trick),\n        expr ``(Mathlib.Tactic.Group.zpow_trick_one), expr ``(Mathlib.Tactic.Group.zpow_trick_one'),\n        expr ``(zpow_trick_sub), expr ``(Tactic.Ring.horner)]\n      [] locat >>\n    skip\n#align tactic.aux_group₁ tactic.aux_group₁\n\n/-- Auxiliary tactic for the `group` tactic. Calls `ring_nf` to normalize exponents. -/\nunsafe def aux_group₂ (locat : Loc) : tactic Unit :=\n  ring_nf none Tactic.Ring.NormalizeMode.raw locat\n#align tactic.aux_group₂ tactic.aux_group₂\n\nend Tactic\n\nnamespace Tactic.Interactive\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\nopen Tactic\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/-- Tactic for normalizing expressions in multiplicative groups, without assuming\ncommutativity, using only the group axioms without any information about which group\nis manipulated.\n\n(For additive commutative groups, use the `abel` tactic instead.)\n\nExample:\n```lean\nexample {G : Type} [group G] (a b c d : G) (h : c = (a*b^2)*((b*b)⁻¹*a⁻¹)*d) : a*c*d⁻¹ = a :=\nbegin\n  group at h, -- normalizes `h` which becomes `h : c = d`\n  rw h,       -- the goal is now `a*d*d⁻¹ = a`\n  group,      -- which then normalized and closed\nend\n```\n-/\nunsafe def group (locat : parse location) : tactic Unit := do\n  when locat sorry\n  aux_group₁ locat\n  repeat (andthen (aux_group₂ locat) (aux_group₁ locat))\n#align tactic.interactive.group tactic.interactive.group\n\nend Tactic.Interactive\n\nadd_tactic_doc\n  { Name := \"group\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.group]\n    tags := [\"decision procedure\", \"simplification\"] }\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/Group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4709663006529229}}
{"text": "import ..myring.order\nimport ..myring.integral_domain\n\nnamespace hidden\n\nclass myfield (α : Type) extends myring α, has_inv α :=\n(mul_inv {x : α}: x ≠ 0 → x * x⁻¹ = 1)\n(nontrivial: (0: α) ≠ 1)\n\nnamespace myfield\n\nopen myring\n\nvariables {α : Type} [myfield α] (x y z : α)\n\ntheorem one_ne_zero : (1 : α) ≠ 0 :=\nbegin\n  assume h,\n  apply @nontrivial α,\n  symmetry,\n  assumption,\nend\n\ntheorem zero_ne_one : (0 : α) ≠ 1 := nontrivial\n\ntheorem inv_mul {x : α} (hx : x ≠ 0) : x⁻¹ * x = 1 :=\nbegin\n  rw [mul_comm],\n  apply mul_inv hx,\nend\n\ntheorem nzero_impl_inv_nzero (hx : x ≠ 0) : x⁻¹ ≠ 0 :=\nbegin\n  assume hinv0,\n  apply hx,\n  apply one_eq_zero_impl_all_zero,\n  rw [←mul_inv hx, hinv0, myring.mul_zero],\nend\n\ninstance: integral_domain α := ⟨begin\n  intros a b ha hba,\n  rw [←myring.mul_one b, ←mul_inv ha, ←myring.mul_assoc, hba, myring.zero_mul],\nend⟩\n\nopen integral_domain\n\ntheorem inv_unique {x : α} (y : α) (hx : x ≠ 0) : x * y = 1 → y = x⁻¹ :=\nbegin\n  intro hxy,\n  apply mul_cancel_left x,\n    exact hx,\n  rw hxy,\n  symmetry,\n  exact mul_inv hx,\nend\n\n@[simp] theorem one_inv : 1⁻¹ = (1 : α) := begin\n  symmetry,\n  apply inv_unique,\n    exact one_ne_zero,\n  rw one_mul,\nend\n\ntheorem inv_nzero {x : α} (hx : x ≠ 0) : x⁻¹ ≠ 0 :=\nbegin\n  intro hx0,\n  apply @nontrivial α,\n  rw [←mul_inv hx, ←mul_zero x, hx0],\nend\n\ntheorem inv_inv {x : α} (hx : x ≠ 0) : x⁻¹⁻¹ = x :=\nbegin\n  apply mul_cancel_right _ x⁻¹,\n    exact inv_nzero hx,\n  rw mul_comm,\n  transitivity (1 : α),\n    apply mul_inv,\n    exact inv_nzero hx,\n  symmetry,\n  apply mul_inv hx,\nend\n\ntheorem inv_inj {x y : α} (hx : x ≠ 0) (hy : y ≠ 0): x⁻¹ = y⁻¹ → x = y :=\nbegin\n  intro hxy,\n  rw [←inv_inv hx, ←inv_inv hy],\n  congr,\n  assumption,\nend\n\ntheorem inv_distr {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) : (x * y)⁻¹ = x⁻¹ * y⁻¹ :=\nbegin\n  have hxy : x * y ≠ 0 := mul_nzero hx hy,\n  apply mul_cancel_right _ (x * y),\n    exact hxy,\n  rw [mul_comm, mul_inv hxy, mul_comm x, mul_assoc, ←mul_assoc y⁻¹, mul_comm y⁻¹,\n      mul_inv hy, one_mul, inv_mul hx],\nend\n\ndef div : α → α → α := λ a b, a * b⁻¹\ninstance: has_div α := ⟨div⟩\n\n-- -- Division\n\ntheorem div_def : x / y = x * y⁻¹ := rfl\n\n@[simp] theorem div_one : x / 1 = x :=\nbegin\n  change x * 1⁻¹ = x,\n  rw [one_inv, mul_one],\nend\n\ntheorem one_div : 1 / x = x⁻¹ :=\nbegin\n  change 1 * x⁻¹ = x⁻¹,\n  rw one_mul,\nend\n\n@[simp] theorem zero_div : 0 / x = 0 :=\nbegin\n  change 0 * x⁻¹ = 0,\n  rw zero_mul,\nend\n\ntheorem mul_div_cancel : y ≠ 0 → (x * y) / y = x :=\nbegin\n  intro hy,\n  change x * y * y⁻¹ = x,\n  rw [mul_assoc, mul_inv hy, mul_one],\nend\n\ntheorem div_mul_cancel : y ≠ 0 → (x / y) * y = x :=\nbegin\n  intro hy,\n  change x * y⁻¹ * y = x,\n  rw [mul_assoc, inv_mul hy, mul_one],\nend\n\ntheorem div_self {x : α} : x ≠ 0 → x / x = 1 :=\nbegin\n  intro hx,\n  change x * x⁻¹ = 1,\n  exact mul_inv hx,\nend\n\ntheorem div_inv_switch {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) : x / y = (y / x)⁻¹ :=\nbegin\n  change x * y⁻¹ = (y * x⁻¹)⁻¹,\n  rw [inv_distr hy (inv_nzero hx), inv_inv hx, mul_comm],\nend\n\ntheorem add_div : (x + y) / z = x / z + y / z :=\nbegin\n  change (x + y) * z⁻¹ = x * z⁻¹ + y * z⁻¹,\n  apply add_mul,\nend\n\n-- Handy\ntheorem half_plus_half (water : 2 ≠ (0 : α)) (ε : α) : ε / 2 + ε / 2 = ε :=\nbegin\n  rw [div_def, ←mul_add, ←one_div, ←add_div],\n  change ε * (2 / 2) = ε,\n  rw [div_self water, mul_one],\nend\n\ntheorem minus_half (water : 2 ≠ (0 : α)) (ε : α) : ε - ε /2 = ε / 2 := sorry\n\nend myfield\n\nend hidden\n", "meta": {"author": "Sterrs", "repo": "leaning", "sha": "3901cc953694b33adda86cb88ca30ba99594db31", "save_path": "github-repos/lean/Sterrs-leaning", "path": "github-repos/lean/Sterrs-leaning/leaning-3901cc953694b33adda86cb88ca30ba99594db31/src/principia/myfield/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4709662982153528}}
{"text": "import group_theory.group_action.sum\nimport logic.equiv.transfer_instance\nimport mathlib.group_action\nimport mathlib.logic\nimport phase0.index\nimport phase0.litter\nimport phase0.pretangle\n\n/-!\n# Structural permutations\n\nIn this file, we define the ambient groups of *structural permutations*.  These will later have\nrecursively-constructed subgroups of *semi-allowable* and *allowable permutations* which will act on\ntangles; we define these larger ambient groups in advance in order to set up their infrastructure of\nderivatives and so on independently of the recursion.\n-/\n\nopen cardinal equiv quiver quiver.path set with_bot\nopen_locale cardinal pointwise\n\nnoncomputable theory\n\nuniverse u\n\nnamespace con_nf\nvariable [params.{u}]\n\n/-- A *structural permutation* on a proper type index is defined by its derivatives,\nas well as its permutation on atoms. -/\n/- Note: perhaps should be constructed directly as *groups*, not just types. -/\ndef struct_perm : Π α : type_index, Type u\n| ⊥ := near_litter_perm\n| (α : Λ) := Π β : type_index, β < α → struct_perm β\nusing_well_founded { dec_tac := `[assumption] }\n\nnamespace struct_perm\nsection\nvariables {α β : Λ} {γ : type_index}\n\nnoncomputable! instance : Π α, inhabited (struct_perm α)\n| ⊥ := by { unfold struct_perm, exact near_litter_perm.inhabited }\n| (α : Λ) := by { unfold struct_perm,\n  exact @pi.inhabited _ _ (λ β, @pi.inhabited _ _ $ λ _ : β < ↑α, inhabited β) }\nusing_well_founded { dec_tac := `[assumption] }\n\nlemma coe_def (α : Λ) : struct_perm ↑α = Π β : type_index, β < α → struct_perm β :=\nby unfold struct_perm\n\n/-- The \"identity\" equivalence between `near_litter_perm` and `struct_perm ⊥`. -/\ndef to_bot : near_litter_perm ≃ struct_perm ⊥ := equiv.cast $ by unfold struct_perm\n\n/-- The \"identity\" equivalence between `struct_perm ⊥` and `near_litter_perm`. -/\ndef of_bot : struct_perm ⊥ ≃ near_litter_perm := equiv.cast $ by unfold struct_perm\n\n/-- The \"identity\" equivalence between `Π β < α, struct_perm β` and `struct_perm α`. -/\ndef to_coe : (Π β : type_index, β < α → struct_perm β) ≃ struct_perm α :=\nequiv.cast $ by unfold struct_perm\n\n/-- The \"identity\" equivalence between `struct_perm α` and `Π β < α, struct_perm β`. -/\ndef of_coe : struct_perm α ≃ Π β : type_index, β < α → struct_perm β :=\nequiv.cast $ by unfold struct_perm\n\n@[simp] lemma to_bot_symm : to_bot.symm = of_bot := rfl\n@[simp] lemma of_bot_symm : of_bot.symm = to_bot := rfl\n@[simp] lemma to_coe_symm : to_coe.symm = (of_coe : struct_perm α ≃ _) := rfl\n@[simp] lemma of_coe_symm : of_coe.symm = (to_coe : _ ≃ struct_perm α) := rfl\n@[simp] lemma to_bot_of_bot (a) : to_bot (of_bot a) = a := by simp [to_bot, of_bot]\n@[simp] lemma of_bot_to_bot (a) : of_bot (to_bot a) = a := by simp [to_bot, of_bot]\n@[simp] lemma to_coe_of_coe (a : struct_perm α) : to_coe (of_coe a) = a := by simp [to_coe, of_coe]\n@[simp] lemma of_coe_to_coe (a) : of_coe (to_coe a : struct_perm α) = a := by simp [to_coe, of_coe]\n@[simp] lemma to_bot_inj {a b} : to_bot a = to_bot b ↔ a = b := to_bot.injective.eq_iff\n@[simp] lemma of_bot_inj {a b} : of_bot a = of_bot b ↔ a = b := of_bot.injective.eq_iff\n@[simp] lemma to_coe_inj {a b} : (to_coe a : struct_perm α) = to_coe b ↔ a = b :=\nto_coe.injective.eq_iff\n@[simp] lemma of_coe_inj {a b : struct_perm α} : of_coe a = of_coe b ↔ a = b :=\nof_coe.injective.eq_iff\n\nnoncomputable! instance group : Π α, group (struct_perm α)\n| ⊥ := of_bot.group\n| (α : Λ) := @equiv.group _ _ of_coe $ @pi.group _ _ $ λ β,\n  @pi_Prop.group _ _ $ λ _ : β < ↑α, group β\nusing_well_founded { dec_tac := `[assumption] }\n\n/--  The isomorphism between near-litter permutations and bottom structural permutations. This holds\nby definition of `struct_perm`. -/\ndef to_bot_iso : near_litter_perm ≃* struct_perm ⊥ :=\n{ map_mul' := λ a b,\n  by { rw [show struct_perm.group ⊥ = _, by unfold struct_perm.group], congr; simp },\n  ..to_bot }\n\n@[simp] lemma coe_to_bot_iso : ⇑to_bot_iso = to_bot := rfl\n@[simp] lemma coe_to_bot_iso_symm : ⇑to_bot_iso.symm = of_bot := rfl\n\n/--  The isomorphism between the product of structural permutations under `α` and `α`-structural\npermutations. This holds by definition of `struct_perm`. -/\ndef to_coe_iso (α : Λ) : (Π β : type_index, β < α → struct_perm β) ≃* struct_perm α :=\n{ map_mul' := λ a b,\n    by { rw [show struct_perm.group α = _, by unfold struct_perm.group], congr; simp },\n  ..to_coe }\n\n@[simp] lemma coe_to_coe_iso (α : Λ) : ⇑(to_coe_iso α) = to_coe := rfl\n@[simp] lemma coe_to_coe_iso_symm (α : Λ) : ⇑(to_coe_iso α).symm = of_coe := rfl\n\n@[simp] lemma to_bot_one : to_bot 1 = 1 := to_bot_iso.map_one\n@[simp] lemma of_bot_one : of_bot 1 = 1 := to_bot_iso.symm.map_one\n@[simp] lemma to_bot_mul (a b) : to_bot (a * b) = to_bot a * to_bot b := to_bot_iso.map_mul _ _\n@[simp] lemma of_bot_mul (a b) : of_bot (a * b) = of_bot a * of_bot b := to_bot_iso.symm.map_mul _ _\n@[simp] lemma to_bot_inv (a) : to_bot a⁻¹ = (to_bot a)⁻¹ := to_bot_iso.map_inv _\n@[simp] lemma of_bot_inv (a) : of_bot a⁻¹ = (of_bot a)⁻¹ := to_bot_iso.symm.map_inv _\n\n@[simp] lemma to_coe_one : (to_coe 1 : struct_perm α) = 1 := (to_coe_iso α).map_one\n@[simp] lemma of_coe_one : of_coe (1 : struct_perm α) = 1 := (to_coe_iso α).symm.map_one\n@[simp] lemma to_coe_mul (a b) : (to_coe (a * b) : struct_perm α) = to_coe a * to_coe b :=\n(to_coe_iso α).map_mul _ _\n@[simp] lemma of_coe_mul (a b : struct_perm α) : of_coe (a * b) = of_coe a * of_coe b :=\n(to_coe_iso α).symm.map_mul _ _\n\nend\n\nvariables {α β γ : type_index}\n\n/-- Obtains the permutations on lower types induced by a structural permutation. -/\ndef lower : ∀ {α β : type_index}, β ≤ α → struct_perm α →* struct_perm β\n| ⊥ ⊥ hβ := monoid_hom.id _\n| ⊥ (β : Λ) hβ := (not_coe_le_bot _ hβ).elim\n| (α : Λ) β hβ := if h : β = α then by { subst h, exact monoid_hom.id _ } else\n  { to_fun := λ f, of_coe f _ $ hβ.lt_of_ne h,\n  map_one' := congr_fun₂ of_coe_one _ _,\n  map_mul' := λ _ _, congr_fun₂ (of_coe_mul _ _) _ _ }\n\n@[simp] lemma lower_self : lower le_rfl = monoid_hom.id (struct_perm α) :=\nby { cases α, { refl }, { exact dif_pos rfl } }\n\n/-- The near-litter permutation associated to a structural permutation. -/\ndef to_near_litter_perm : struct_perm α →* near_litter_perm :=\nto_bot_iso.symm.to_monoid_hom.comp $ lower bot_le\n\nlemma coe_to_near_litter_perm :\n  (to_near_litter_perm : struct_perm ⊥ → near_litter_perm) = of_bot :=\nby simp [to_near_litter_perm]\n\n/-- The derivative of a structural permutation at any lower level. -/\nnoncomputable def derivative : Π {β}, path α β → struct_perm α →* struct_perm β\n| _ nil := monoid_hom.id _\n| γ (cons p_αγ hβγ) := (lower $ le_of_lt hβγ).comp $ derivative p_αγ\n\n/-- The derivative along the empty path does nothing. -/\n@[simp] lemma derivative_nil (π : struct_perm α) : derivative nil π = π := rfl\n\nlemma derivative_cons (π : struct_perm α) (p : path α β) {γ : type_index} (h : γ < β) :\n  derivative (p.cons h) π = (derivative (path.nil.cons h)) (derivative p π) :=\nby simp only [derivative]; refl\n\n/-- The derivative map is functorial. -/\nlemma derivative_derivative (π : struct_perm α) (p : path α β) :\n  ∀ {γ : type_index} (q : path β γ), derivative q (derivative p π) = derivative (p.comp q) π\n| _ nil := by simp only [derivative_nil, comp_nil]\n| γ (cons q f) := by simp only [comp_cons, derivative, monoid_hom.coe_comp, function.comp_app,\n  derivative_derivative]\n\n/-- The derivative map preserves multiplication. -/\nlemma derivative_mul {β} (π₁ π₂ : struct_perm α) (A : path (α : type_index) β) :\n  derivative A (π₁ * π₂) = derivative A π₁ * derivative A π₂ := by simp only [map_mul]\n\nsection\nvariables {X : Type*} [mul_action near_litter_perm X]\n\n/-- Structural permutations act on atoms. -/\ninstance mul_action_of_near_litter_perm : mul_action (struct_perm α) X :=\nmul_action.comp_hom _ to_near_litter_perm\n\n@[simp] lemma to_near_litter_perm_smul (f : struct_perm α) (x : X) :\n  f.to_near_litter_perm • x = f • x := rfl\n\n@[simp] lemma to_bot_smul (f : near_litter_perm) (x : X) : to_bot f • x = f • x :=\nby { change to_near_litter_perm _ • _ = _ • _, rw [coe_to_near_litter_perm, of_bot_to_bot] }\n\n@[simp] lemma of_bot_smul (f : struct_perm ⊥) (x : X) : of_bot f • x = f • x :=\nby rw [←to_bot_smul, to_bot_of_bot]\n\n@[simp] lemma to_bot_inv_smul (f : near_litter_perm) (x : X) : (to_bot f)⁻¹ • x = f⁻¹ • x :=\nby rw [inv_smul_eq_iff, to_bot_smul, smul_inv_smul]\n\n@[simp] lemma of_bot_inv_smul (f : struct_perm ⊥) (x : X) : (of_bot f)⁻¹ • x = f⁻¹ • x :=\nby rw [inv_smul_eq_iff, of_bot_smul, smul_inv_smul]\n\n@[simp] lemma derivative_bot_smul {α : Λ} (f : struct_perm α) (x : X) :\n  struct_perm.derivative (nil.cons (bot_lt_coe α)) f • x = f • x := rfl\n\nlemma smul_near_litter_fst (π : struct_perm α) (N : near_litter) : (π • N).fst = π • N.fst := rfl\n\nend\n\ndef proto_smul : Π α : type_index, struct_perm α → pretangle α → pretangle α\n| ⊥ := λ π t, pretangle.to_bot $ of_bot π • t.of_bot\n| (α : Λ) := λ π t, pretangle.to_coe $ λ β (hβ : β < α), proto_smul β (of_coe π β hβ) '' pretangle.of_coe t β hβ\nusing_well_founded { dec_tac := `[assumption] }\n\ninstance has_smul_pretangle : Π α : type_index, has_smul (struct_perm α) (pretangle α) | α := ⟨proto_smul α⟩\n\n@[simp] lemma of_bot_smul_pretangle (π : struct_perm ⊥) (t : pretangle ⊥) :\n  (π • t).of_bot = of_bot π • t.of_bot :=\nbegin\ndsimp [struct_perm.has_smul_pretangle],\nhave : (proto_smul ⊥) = λ π t, pretangle.to_bot $ of_bot π • t.of_bot,\nunfold proto_smul,\nrw this,\nsimp only [pretangle.of_bot_to_bot],\nend\n\n@[simp] lemma to_bot_smul_pretangle (π : near_litter_perm) (t : atom) :\n   pretangle.to_bot (π • t) = to_bot π • pretangle.to_bot t :=\npretangle.of_bot.injective $\n  by simp_rw [of_bot_smul_pretangle, of_bot_to_bot, pretangle.of_bot_to_bot]\n\n@[simp] lemma of_coe_smul_pretangle {α : Λ} (π : struct_perm α) (t : pretangle α) :\n  (π • t).of_coe = of_coe π • t.of_coe :=\nbegin\ndsimp [struct_perm.has_smul_pretangle],\nunfold proto_smul,\nsimp only [pretangle.of_coe_to_coe],\nrefl,\n  end\n\n@[simp] lemma to_coe_smul_pretangle {α : Λ} (π : Π β : type_index, β < α → struct_perm β)\n  (t : Π β : type_index, β < α → set (pretangle β)) :\n  pretangle.to_coe (π • t) = to_coe π • pretangle.to_coe t :=\npretangle.of_coe.injective $\n  by simp_rw [of_coe_smul_pretangle, of_coe_to_coe, pretangle.of_coe_to_coe]\n\nprotected lemma one_smul : ∀ α (t : pretangle α), (1 : struct_perm α) • t = t\n| ⊥ := λ t, pretangle.of_bot.injective $ by simp\n| (α : Λ) := λ t, pretangle.of_coe.injective $\n    by { ext β hβ : 2, simp [←image_smul, one_smul β, image_id'] }\nusing_well_founded { dec_tac := `[assumption] }\n\nprotected lemma mul_smul :\n  ∀ α (π₁ π₂ : struct_perm α) (t : pretangle α), (π₁ * π₂) • t = π₁ • π₂ • t\n| ⊥ := λ π₁ π₂ t, pretangle.of_bot.injective $ by simp [mul_action.mul_smul]\n| (α : Λ) := λ π₁ π₂ t, pretangle.of_coe.injective $\n    by { ext β hβ : 2, simp only [of_coe_smul_pretangle, of_coe_mul, pi.smul_apply', pi.mul_apply,\n      pi_Prop.smul_apply', ←image_smul, image_image, ←mul_smul β], refl }\nusing_well_founded { dec_tac := `[assumption] }\n\ninstance mul_action_pretangle : mul_action (struct_perm α) (pretangle α) :=\n{ smul := (•),\n  one_smul := struct_perm.one_smul _,\n  mul_smul := struct_perm.mul_smul _ }\n\nlemma derivative_cons_nil (α : Λ) (f : struct_perm α) (β : type_index) (hβ : β < α) :\n  derivative (cons nil hβ) f = of_coe f β hβ :=\nby { unfold derivative lower, rw dif_neg hβ.ne, refl }\n\nlemma ext (α : Λ) (a b : struct_perm α)\n  (h : ∀ (β : type_index) (hβ : β < α), derivative (cons nil hβ) a = derivative (cons nil hβ) b) :\n  a = b :=\nof_coe.injective $ by { ext β hβ, simp_rw ←derivative_cons_nil, exact h _ _ }\n\ninstance : has_faithful_smul (struct_perm ⊥) atom :=\n⟨λ f g h, of_bot.injective $ near_litter_perm.ext $ eq_of_smul_eq_smul h⟩\n\nend struct_perm\nend con_nf\n", "meta": {"author": "leanprover-community", "repo": "con-nf", "sha": "f0b66bd73ca5d3bd8b744985242c4c0b5464913f", "save_path": "github-repos/lean/leanprover-community-con-nf", "path": "github-repos/lean/leanprover-community-con-nf/con-nf-f0b66bd73ca5d3bd8b744985242c4c0b5464913f/src/phase0/struct_perm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.4709662932217357}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module data.prod.pprod\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Logic.Basic\n\n/-!\n# Extra facts about `pprod`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nopen Function\n\nvariable {α β γ δ : Sort _}\n\nnamespace PProd\n\n/- warning: pprod.mk.eta -> PProd.mk.eta is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : PProd.{u1, u2} α β}, Eq.{max 1 u1 u2} (PProd.{u1, u2} α β) (PProd.mk.{u1, u2} α β (PProd.fst.{u1, u2} α β p) (PProd.snd.{u1, u2} α β p)) p\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {p : PProd.{u2, u1} α β}, Eq.{max (max 1 u2) u1} (PProd.{u2, u1} α β) (PProd.mk.{u2, u1} α β (PProd.fst.{u2, u1} α β p) (PProd.snd.{u2, u1} α β p)) p\nCase conversion may be inaccurate. Consider using '#align pprod.mk.eta PProd.mk.etaₓ'. -/\n@[simp]\ntheorem mk.eta {p : PProd α β} : PProd.mk p.1 p.2 = p :=\n  PProd.casesOn p fun a b => rfl\n#align pprod.mk.eta PProd.mk.eta\n\n/- warning: pprod.forall -> PProd.forall is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : (PProd.{u1, u2} α β) -> Prop}, Iff (forall (x : PProd.{u1, u2} α β), p x) (forall (a : α) (b : β), p (PProd.mk.{u1, u2} α β a b))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {p : (PProd.{u2, u1} α β) -> Prop}, Iff (forall (x : PProd.{u2, u1} α β), p x) (forall (a : α) (b : β), p (PProd.mk.{u2, u1} α β a b))\nCase conversion may be inaccurate. Consider using '#align pprod.forall PProd.forallₓ'. -/\n@[simp]\ntheorem forall {p : PProd α β → Prop} : (∀ x, p x) ↔ ∀ a b, p ⟨a, b⟩ :=\n  ⟨fun h a b => h ⟨a, b⟩, fun h ⟨a, b⟩ => h a b⟩\n#align pprod.forall PProd.forall\n\n/- warning: pprod.exists -> PProd.exists is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : (PProd.{u1, u2} α β) -> Prop}, Iff (Exists.{max 1 u1 u2} (PProd.{u1, u2} α β) (fun (x : PProd.{u1, u2} α β) => p x)) (Exists.{u1} α (fun (a : α) => Exists.{u2} β (fun (b : β) => p (PProd.mk.{u1, u2} α β a b))))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {p : (PProd.{u2, u1} α β) -> Prop}, Iff (Exists.{max (max 1 u2) u1} (PProd.{u2, u1} α β) (fun (x : PProd.{u2, u1} α β) => p x)) (Exists.{u2} α (fun (a : α) => Exists.{u1} β (fun (b : β) => p (PProd.mk.{u2, u1} α β a b))))\nCase conversion may be inaccurate. Consider using '#align pprod.exists PProd.existsₓ'. -/\n@[simp]\ntheorem exists {p : PProd α β → Prop} : (∃ x, p x) ↔ ∃ a b, p ⟨a, b⟩ :=\n  ⟨fun ⟨⟨a, b⟩, h⟩ => ⟨a, b, h⟩, fun ⟨a, b, h⟩ => ⟨⟨a, b⟩, h⟩⟩\n#align pprod.exists PProd.exists\n\n/- warning: pprod.forall' -> PProd.forall' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : α -> β -> Prop}, Iff (forall (x : PProd.{u1, u2} α β), p (PProd.fst.{u1, u2} α β x) (PProd.snd.{u1, u2} α β x)) (forall (a : α) (b : β), p a b)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {p : α -> β -> Prop}, Iff (forall (x : PProd.{u2, u1} α β), p (PProd.fst.{u2, u1} α β x) (PProd.snd.{u2, u1} α β x)) (forall (a : α) (b : β), p a b)\nCase conversion may be inaccurate. Consider using '#align pprod.forall' PProd.forall'ₓ'. -/\ntheorem forall' {p : α → β → Prop} : (∀ x : PProd α β, p x.1 x.2) ↔ ∀ a b, p a b :=\n  PProd.forall\n#align pprod.forall' PProd.forall'\n\n/- warning: pprod.exists' -> PProd.exists' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : α -> β -> Prop}, Iff (Exists.{max 1 u1 u2} (PProd.{u1, u2} α β) (fun (x : PProd.{u1, u2} α β) => p (PProd.fst.{u1, u2} α β x) (PProd.snd.{u1, u2} α β x))) (Exists.{u1} α (fun (a : α) => Exists.{u2} β (fun (b : β) => p a b)))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {p : α -> β -> Prop}, Iff (Exists.{max (max 1 u2) u1} (PProd.{u2, u1} α β) (fun (x : PProd.{u2, u1} α β) => p (PProd.fst.{u2, u1} α β x) (PProd.snd.{u2, u1} α β x))) (Exists.{u2} α (fun (a : α) => Exists.{u1} β (fun (b : β) => p a b)))\nCase conversion may be inaccurate. Consider using '#align pprod.exists' PProd.exists'ₓ'. -/\ntheorem exists' {p : α → β → Prop} : (∃ x : PProd α β, p x.1 x.2) ↔ ∃ a b, p a b :=\n  PProd.exists\n#align pprod.exists' PProd.exists'\n\nend PProd\n\n/- warning: function.injective.pprod_map -> Function.Injective.pprod_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {δ : Sort.{u4}} {f : α -> β} {g : γ -> δ}, (Function.Injective.{u1, u2} α β f) -> (Function.Injective.{u3, u4} γ δ g) -> (Function.Injective.{max 1 u1 u3, max 1 u2 u4} (PProd.{u1, u3} α γ) (PProd.{u2, u4} β δ) (fun (x : PProd.{u1, u3} α γ) => PProd.mk.{u2, u4} β δ (f (PProd.fst.{u1, u3} α γ x)) (g (PProd.snd.{u1, u3} α γ x))))\nbut is expected to have type\n  forall {α : Sort.{u4}} {β : Sort.{u3}} {γ : Sort.{u2}} {δ : Sort.{u1}} {f : α -> β} {g : γ -> δ}, (Function.Injective.{u4, u3} α β f) -> (Function.Injective.{u2, u1} γ δ g) -> (Function.Injective.{max (max 1 u4) u2, max (max 1 u3) u1} (PProd.{u4, u2} α γ) (PProd.{u3, u1} β δ) (fun (x : PProd.{u4, u2} α γ) => PProd.mk.{u3, u1} β δ (f (PProd.fst.{u4, u2} α γ x)) (g (PProd.snd.{u4, u2} α γ x))))\nCase conversion may be inaccurate. Consider using '#align function.injective.pprod_map Function.Injective.pprod_mapₓ'. -/\ntheorem Function.Injective.pprod_map {f : α → β} {g : γ → δ} (hf : Injective f) (hg : Injective g) :\n    Injective (fun x => ⟨f x.1, g x.2⟩ : PProd α γ → PProd β δ) := fun ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ h =>\n  have A := congr_arg PProd.fst h\n  have B := congr_arg PProd.snd h\n  congr_arg₂ PProd.mk (hf A) (hg B)\n#align function.injective.pprod_map Function.Injective.pprod_map\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Prod/Pprod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.4709662881096418}}
{"text": "import coalgebra.Coalgebra\nimport examples.kripke_structure.Kripke_Structure\nimport set_category.category_set\nimport category_theory.types\nimport help_functions\n\n\n\nnamespace Kripe_Coalgebra\n\nopen Kripke_Structure set help_functions coalgebra\n\n\nuniverses u v \n\nvariable {φ : Type v}\n\ndef F : Type u ⥤ Type (max v u) := \n    {\n        obj := λ S, (set S) × (set φ),\n        map := λ {A B} ϕ, λ ⟨U , P⟩ , ⟨image ϕ U, P⟩,\n        map_id' :=  \n            begin \n                intros X, \n                dsimp at *, \n                ext1, \n                cases x with U P, \n                dsimp at *,\n                ext1,\n                have im : image id U = U :=  by simp,\n                exact im,\n                refl\n            end ,\n        map_comp' := \n            begin\n                intros X Y Z f g,\n                dsimp at *, \n                ext1, \n                cases x with S P, \n                dsimp at *, \n                calc \n                F._match_1 (g ∘ f) (S, P)\n                    = ⟨image (g ∘ f) S, P⟩              : rfl\n                ... = ⟨image g (image f S), P⟩          : by rw [img_comp f g S] \n                ... = F._match_1 g (F._match_1 f (S, P)) : rfl\n            end\n    } \n\ndef α (K : Kripke φ): K.State → F.obj K.State := \n        λ s, ⟨K.T s,  K.v s⟩\n\ndef Kripke_Coalgebra (K : Kripke φ): Coalgebra F := \n    ⟨K.State , α K⟩ \n\nlemma Kripke_Coalgebra_hom {K₁ K₂ : Kripke φ} (ϕ : K₁ → K₂): \n    is_homomorphism φ ϕ ↔ \n    @is_coalgebra_homomorphism F \n        (Kripke_Coalgebra K₁) (Kripke_Coalgebra K₂)\n            ϕ :=\n    let 𝕂₁  := Kripke_Coalgebra K₁ in\n    let 𝕂₂ := Kripke_Coalgebra K₂ in\n    iff.intro \n    (\n    assume ⟨tr, b_a, pr⟩,\n    show 𝕂₂.α ∘ ϕ = F.map ϕ ∘ 𝕂₁.α,\n    begin \n        ext1,\n        have im_elem : ∀ s : K₂.State , \n                s ∈ image ϕ (K₁.T x) ↔ s ∈ K₂.T (ϕ x) :=   \n            begin\n                intro s,\n                split,\n                intros im_ϕ,\n                cases im_ϕ with s12 specS12,\n                rw ← specS12.2,\n                exact tr x s12 specS12.1,\n                intro s_T2,\n                exact b_a x s s_T2,\n            end,\n\n        have im : image ϕ (K₁.T x) = K₂.T (ϕ x) := \n            eq_sets.1 im_elem,\n        \n        have F_ϕ : F.map ϕ (𝕂₁.α x) = ⟨image ϕ (K₁.T x), K₁.v x⟩ \n                := rfl,\n        simp [F_ϕ],\n        have last : (⟨K₂.T (ϕ x) , K₂.v (ϕ x)⟩ : \n            (set K₂.State) × set φ) = ⟨image ϕ (K₁.T x), K₁.v x⟩ := \n                by simp [eq.symm im, eq.symm (pr x)],\n        simp [eq.symm last],\n        refl\n    end )\n    (\n    assume co_hom : 𝕂₂.α ∘ ϕ = F.map ϕ ∘ 𝕂₁.α,\n    show (∀ a₁ a₂ :K₁ , a₂ ∈ K₁.T a₁ → (ϕ a₂) ∈ K₂.T (ϕ a₁)) ∧ \n         (∀ (a : K₁) (b : K₂) , b ∈ K₂.T (ϕ a) →\n                ∃ a': K₁ ,  a' ∈ K₁.T a ∧ ϕ a' = b) ∧ \n         (∀ a : K₁ , K₁.v a = K₂.v (ϕ a)),\n    begin\n        split,\n        intros a₁ a₂ a₂_a₁,\n       \n        have h3 : (𝕂₂.α ∘ ϕ) a₁ = ((F.map ϕ) ∘ 𝕂₁.α) a₁ \n                     := by rw co_hom,\n        have h5 : (⟨K₂.T (ϕ a₁) , K₂.v (ϕ a₁)⟩ : \n            (set K₂.State) × set φ) = ⟨image ϕ (K₁.T a₁), K₁.v a₁⟩ \n                := h3,\n        have h6 : K₂.T (ϕ a₁) = image ϕ (K₁.T a₁) := by tidy,\n        have h7 : ϕ a₂ ∈ image ϕ (K₁.T a₁) := \n            by {use a₂, simp [a₂_a₁]},\n        rw h6,\n        exact h7,\n\n        split,\n        intros a₁ b b_T_ϕ_a,\n        have h3 : (𝕂₂.α ∘ ϕ) a₁ = ((F.map ϕ) ∘ 𝕂₁.α) a₁ \n                     := by rw co_hom,\n        have h4 : 𝕂₂.α (ϕ a₁) = F.map ϕ (𝕂₁.α a₁) \n                     := h3,\n        have h5 : (⟨K₂.T (ϕ a₁) , K₂.v (ϕ a₁)⟩ : \n            (set K₂.State) × set φ) = ⟨image ϕ (K₁.T a₁), K₁.v a₁⟩ \n                := h4,\n        have h6 : K₂.T (ϕ a₁) = image ϕ (K₁.T a₁) := by tidy,\n        have h7 : b ∈ image ϕ (K₁.T a₁) := h6 ▸ b_T_ϕ_a,\n        exact h7,\n        intro a₁,\n        have h3 : (𝕂₂.α ∘ ϕ) a₁ = ((F.map ϕ) ∘ 𝕂₁.α) a₁ \n                     := by rw co_hom,\n        have h5 : (⟨K₂.T (ϕ a₁) , K₂.v (ϕ a₁)⟩ : \n            (set K₂.State) × set φ) = ⟨image ϕ (K₁.T a₁), K₁.v a₁⟩ \n                := h3,\n        have h6 : K₂.v (ϕ a₁) = K₁.v a₁ := by tidy,\n        exact eq.symm h6\n    end)\n    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend Kripe_Coalgebra", "meta": {"author": "QaisHamarneh", "repo": "Coalgebra-in-Lean", "sha": "bd0452df98bc64b608e5dfd7babc42c301bb6a46", "save_path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean", "path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean/Coalgebra-in-Lean-bd0452df98bc64b608e5dfd7babc42c301bb6a46/src/examples/kripke_structure/Kripke_Coalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402812, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4708902646163594}}
{"text": "/-\nAuthors: Jáchym Šimon, Tomáš Lávička\nCzech technical university, Prague\nCreated: 2019\nwritten in Lean 3.23.0 using mathlib library\n-/\nimport data.list.basic\nimport data.bool\nimport data.nat.basic\nimport init.meta.tactic\nopen set \nopen bool\nopen list\nopen nat\n\n-- TACTIC UNITS \n\n  variables {α β γ  : Type}\n\n  meta def tac : tactic unit :=\n         `[ { repeat {{left, exact rfl}  <|> right <|> exact rfl}} <|>             \n            solve1 { repeat {{left, assumption}  <|> right <|> assumption}}]\n\n meta def mt_ax : tactic unit := \n  `[ solve1 {repeat{ {left, refine (exintro2 _ _ rfl)}   <|>\n            {left, refine (exintro3 _ _ _ rfl)}  <|>\n            right}} ]\n\n meta def mt_assump0 : tactic unit := \n  `[ repeat{{left, exact rfl} <|> right} <|> assumption ]\n\n meta def mt_assump : tactic unit := \n  `[ iterate 6 {right}, left, {simp, try{exact rfl}} <|>\n     assumption ]\n\n meta def mt_mp : tactic unit := \n  `[ {repeat{right}, existsi _,\n    split, swap, mt_assump0} ]\n\n -- TAUT, RULES\n meta def mt_rules :tactic unit :=\n    --rules with more than 1 assumption\n  `[   \n    apply (@provable1 _ _) <|>\n    apply (@provable5 _ _) <|>\n    apply (@double_neg_law _) <|>\n    apply (@transitivity _ _ _) <|>\n    apply (@RAA _ _) <|> \n    apply (@contraposition _ _) <|>\n    assumption\n    ]\n\n meta def mt_uncut : tactic unit :=\n  `[ right, left, existsi _, \n  split, swap ]\n\n meta def mt_bicut : tactic unit :=\n  `[ left, existsi _, existsi _, \n  split, tactic.swap, split, tactic.swap ]\n\n meta def mt_cut_or_taut : tactic unit :=\n    --binary cut\n  `[ solve1{left, existsi [_, _], \n  split, swap, split, swap, mt_rules, try{mt_assump0}, done } <|>\n    -- unary cut\n  solve1 {right, left, existsi _, \n  split, tactic.swap, mt_rules, try{mt_assump0}, done} <|>\n    -- tautologies\n  solve1 {right, right, left, mt_rules, try{assumption}, done} <|>\n\n  assumption ]\n\n meta def mt_verifier : tactic unit :=\n  `[try{apply provable_no_cutR}, try{existsi prf},\n   repeat{split, solve1 {mt_assump} <|>\n                 solve1 {mt_ax}     <|>\n                 solve1 {mt_mp}     <|>\n                 solve1 {mt_cut_or_taut} <|> \n                 swap},\n    try{exact rfl}]\n\n\n-- EXISTS INTRO ELIM RULES\n\n  lemma exintro2{P: α → β → Prop}(A: α)(B:β): \n    P A B →  ∃ A:α, ∃ B: β, P A B :=\n  begin intro a, repeat{apply exists.intro}, exact a end\n\n  lemma exintro3{P: α → β →γ →  Prop}(A: α)(B:β)(C:γ): \n    P A B C →  ∃ A:α, ∃ B: β,∃ C:γ, P A B C :=\n  begin intro a, repeat{apply exists.intro}, exact a end\n\n  lemma exelim2{P: α → β → Prop}{Q:Prop}: \n    (∃ A:α, ∃ B:β, P A B) → (∀ A:α, ∀ B:β, P A B → Q) → Q :=\n  begin intros a a_1, apply exists.elim a, intros _ a_3, \n  apply exists.elim a_3, intros a_4 a_5, \n  exact a_1 a_2 a_4 a_5 end \n\n  lemma exelim3{P: α → β → γ → Prop}{Q:Prop}: \n    (∃ A:α, ∃ B:β, ∃ C:γ, P A B C) → (∀ A:α, ∀ B:β, ∀ C:γ, P A B C → Q) → Q :=\n  λ hex hall, exists.elim hex \n  (λ A hex1, exists.elim hex1 \n  (λ B hex3, exists.elim hex3 \n  (λ C hP, hall A B C hP)))\n\n\n-- FORM (inducive)\n\n  -- definition of formulae\n  inductive Form : Type\n  | p : ℕ → Form\n  | imp : Form → Form → Form\n  | neg : Form → Form\n\n  local infixr ⇒ : 80 := Form.imp\n  local prefix `~` : 100 := Form.neg\n  open Form\n\n\n-- GLOBAL_VARIABLES\n\n  -- definition of evaluation\n  def eval := ℕ → bool \n  -- variables\n  variables {v v₁ v₂:eval}\n  variables {A B C D:Form}\n  variables {Γ Δ:set Form}\n  variables {m n:ℕ} \n  variables {a b:bool}\n  variables {l li:list Form}\n\n\n-- HK AXIOMS\n  -- axioms of hilbert calculus\n  def A1 (A B:Form) := A ⇒ (B ⇒ A)\n  def A2 (A B C:Form) := (A ⇒ (B ⇒ C)) ⇒ ((A ⇒ B) ⇒ (A ⇒ C))\n  def A3 (A B:Form) := (~B ⇒ ~A) ⇒ ((~B ⇒ A) ⇒ B) \n\n\n-- PROOF\n  -- formula in proof is either axiom, assumption or comes from modus ponens\n  def in_proof (A:Form)(Γ:set Form)(l:list Form) : Prop :=\n    (∃ B C, A = A1 B C)  ∨ \n    (∃ B C D, A = A2 B C D)  ∨ \n    (∃ B C, A = A3 B C)  ∨ \n    (A ∈ Γ)  ∨ \n    (∃ B, B ∈ l ∧ (B ⇒ A) ∈ l) \n\n  -- list l is a proof from set of assumptions Γ\n  def is_proof (Γ:set Form)(l:list Form) : Prop := \n    list.rec_on l tt (λ A li IH, in_proof A Γ li ∧ IH)            \n  \n  -- formula A is provable from set of assumptions Γ\n  def is_provable (Γ:set Form)(A:Form) : Prop :=  \n    ∃ l: list Form, is_proof Γ (A::l)                                   \n  \n  infixr ` ⊢ ` : 40 := is_provable\n  prefix ` ⊢ ` : 40 := is_provable {}\n\n  -- list l is a proof with either binary/unary cut or tautology (or none) used\n  def is_proof_with_cut (Γ:set Form)(l:list Form) : Prop := \n    list.rec_on l tt \n    (λ A li IH, ((∃ B C, B ∈ li ∧ C ∈ li ∧ {B,C} ⊢ A) ∨ \n                  (∃ B, B ∈ li ∧ {B} ⊢ A) ∨\n                  ({} ⊢ A) ∨\n                   in_proof A Γ li) \n                   ∧ IH )\n  -- formula A is provable from Γ using mentioned cut rules\n  def is_provable_with_cut (Γ:set Form)(A:Form) : Prop :=  \n    ∃ l: list Form, is_proof_with_cut Γ (A::l)\n\n  infixr ` ⊢cut ` : 40 := is_provable_with_cut\n  prefix ` ⊢cut ` : 40 := is_provable {}\n   \n\n-- PROOF lemmas\n  -- useful lemmas about proof definitions\n\n  lemma is_proof_ind : is_proof Γ (A::l) → is_proof Γ l := and.right      \n  lemma in_proof_extend : in_proof A Γ l → l <+ li → in_proof A Γ li :=\n    begin \n     intros a a_1, repeat {cases a, tac},\n     cases a with hl hr, repeat {right},\n     have hp: l ⊆ li, exact list.sublist.subset a_1,\n     existsi hl, split, exact hp hr.1, exact hp hr.2        \n    end\n\n  lemma is_proof_concat : is_proof Γ l → is_proof Γ li → is_proof Γ (l++li) :=\n    list.rec_on l\n      (λ h hp, hp)\n      (assume A lis IH Hl Hli, \n        ⟨ in_proof_extend Hl.1 (list.sublist_append_left lis li),\n        IH (is_proof_ind Hl) Hli ⟩)\n\n  lemma is_proof_extend : is_proof Γ l → A ∈ l → in_proof A Γ l :=\n    list.rec_on l  \n    (λ h hp, absurd rfl (list.ne_nil_of_mem hp))\n    (λ D lis IH h hp,         \n    have lem: A ∈ D::lis → A=D ∨ A∈ lis, from \n      λ h, or.elim (list.eq_or_ne_mem_of_mem h) (λ hp, or.inl hp) (λ hp, or.inr hp.2),\n    have sub: lis<+D::lis, from by simp,\n    or.elim (lem hp)                    \n      (assume H, H.symm ▸ in_proof_extend h.1 sub)         \n      (λ H, in_proof_extend  (IH (is_proof_ind h) H) sub))\n\n\n-- SEMANTICS   \n\n  -- definition of evaluation\n  def val (v:eval) : Form → bool :=\n    λ A:Form, Form.rec_on A (λ n:ℕ, v n) \n                            (λ A B:Form, λ a b:bool, !a || b) \n                            (λ A:Form, λ a:bool, !a)\n  \n  notation v `∗` := val v\n\n  -- A is tautology\n  def is_taut (A:Form) : Prop := ∀ v:eval, v∗ A = tt\n  \n  notation `⊧` := is_taut\n\n\n-- SOUNDNESS \n  -- axioms are tautologies\n  lemma A1_taut : ⊧ (A1 A B) :=\n    λ v, have A1_bool: ∀ a b: bool, !a || (!b || a) = tt, \n    from by simp, A1_bool (v∗A) (v∗B)\n    \n  lemma A2_taut : ⊧ (A2 A B C) :=\n    λ v, \n    have A2_bool: ∀ a b c: bool, \n    !(!a || (!b || c)) || (!(!a || b) || (!a || c)) = tt,\n    from by simp, A2_bool (v∗ A) (v∗ B) (v∗ C) \n    \n  lemma A3_taut : ⊧ (A3 A B):=\n    λ v, \n    have A3_bool: ∀ a b:bool, !((!!b) || (!a)) || ((!(!!b || a)) || b) = tt, \n    from by simp, A3_bool (v∗ A) (v∗ B)      \n    \n  lemma MP_taut (h1:⊧ A)(h2:⊧ (A ⇒ B)) : ⊧ B :=\n    λ v, have MP_bool: (∀ (a b:bool), (a = tt ∧ !a || b = tt) → b = tt), from  \n      ( λ a b p1,\n      have p2: ff || b = tt, from @eq.subst bool (λ x, bnot x || b = tt) a tt p1.1 p1.2,\n      or.elim (bool.dichotomy b)\n      (λ i, false.elim \n        (bool.ff_ne_tt (calc ff = ff || ff : rfl \n                             ...= tt : @eq.subst bool (λ x, ff || x = tt) b ff i p2)))\n      (λ i, i) ),\n    MP_bool (v∗A) (v∗(B)) ⟨h1 v, calc bnot (v∗A) || (v∗B) = (v∗(A ⇒ B)) : rfl \n                                                     ... = tt : (h2 v)⟩\n  \n  lemma soundness_lemma : ∀ A:Form, is_proof {} l ∧ A ∈ l → ⊧ A :=\n    list.rec_on l\n    (λ A i, forall_mem_nil ⊧ A i.2)\n    (λ B k IH,\n      (λ A, λ i_Bk: is_proof {} (B::k) ∧ A ∈ (B::k),\n      or.elim i_Bk.2\n      (begin intro j, cases i_Bk.1.1 with h,    \n            \n            apply exelim2 h, intros a b q, \n            rw [j, q], apply A1_taut, cases h,\n\n            apply exelim3 h, intros a b c r,\n            simp [j,r], apply A2_taut, cases h,\n\n            apply exelim2 h, intros a b q, \n            rw [j, q], apply A3_taut, cases h,\n\n            apply false.elim h,\n                \n            apply exists.elim h, intros b c, rw j, \n            have hb: ⊧ b, apply IH b ⟨is_proof_ind i_Bk.1, c.1⟩,\n            have hbB: ⊧ (b ⇒ B), apply IH (b ⇒ B) ⟨is_proof_ind i_Bk.1, c.2⟩,  \n            apply MP_taut hb hbB\n      end)\n    (λ j, IH A ⟨is_proof_ind i_Bk.1, j⟩)))\n\n  theorem CPL_soundness : ∀ A:Form, ⊢ A → ⊧ A :=\n    begin \n      intros a a_1, \n      apply exists.elim a_1, intros a_2 a_3, \n      exact soundness_lemma a ⟨a_3, by simp⟩ \n    end\n \n\n-- PROVABLE lemmas\n  -- monotony, cut rules, other rules\n  -- provable with cut → provable without cut\n\n  lemma modus_ponens_rule : {A, A ⇒ B} ⊢ B :=\n    let prf:= [A, A ⇒ B] in \n    by{existsi prf, \n    split, mt_mp,\n    split, iterate 3 {right}, left, simp, \n    split, iterate 3 {right}, left, simp, exact rfl}\n\n  theorem binary_cut {A B C:Form}: \n  (Γ ⊢ A) → (Γ ⊢ B) → ({A, B} ⊢ C) → (Γ ⊢ C) := \n    begin \n      intros hA hB hAB,\n      apply exists.elim hA, intros prfA is_prfA,\n      apply exists.elim hB, intros prfB is_prfB, \n      apply exists.elim hAB, intro prfAB, \n      let pr:= (A::prfA++B::prfB), \n      let prA:= (A::prfA),\n      let prB:= (B::prfB),\n\n      have lem: ∀ l:list Form, is_proof {A,B} l → is_proof Γ (l++pr), \n      intro l, apply list.rec_on l, intro a,  \n      exact (@is_proof_concat Γ (A::prfA) (B::prfB) is_prfA is_prfB),\n\n      intros D li IH hp, split,\n      cases hp.1,\n      left, exact h, \n      cases h, right, left, exact h,\n      cases h, right, right, left, exact h, \n      cases h, simp at h, cases h, \n      rw[h], \n      have ha: A ∈ li++pr, by simp,  \n      exact is_proof_extend (IH (is_proof_ind hp)) ha, \n      rw[h], \n      have ha: B ∈ li++pr, by simp,  \n      exact is_proof_extend (IH (is_proof_ind hp)) ha, \n      \n      repeat{right},\n      apply exists.elim h,\n      have s: li ⊆ (li ++ pr), by simp, \n      intros Q hQ, \n      existsi Q, split,\n      exact s hQ.1,\n      exact s hQ.2,\n      exact IH (is_proof_ind hp),\n      intro a,\n      existsi (prfAB++pr),\n      exact lem (C::prfAB) a\n    end \n\n  lemma unary_cut {A B:Form}: (Γ ⊢ A) → ({A} ⊢ B) → (Γ ⊢ B) := \n    begin  \n    have h: {A, A} = {A}, exact pair_eq_singleton A, rw[symm h],\n    intros a a_1, exact binary_cut a a a_1 \n    end\n\n  lemma monotony_help : Γ ⊆ Δ → is_proof Γ l → is_proof Δ l := \n    begin \n    intro a,\n    apply list.rec_on l, intro, exact rfl,\n    intros _ _ _ a_2, split, swap, \n    exact ih (is_proof_ind a_2), \n    cases a_2, repeat {cases a_2_left, solve1{repeat{{left, exact a_2_left} <|> right}}},\n    cases a_2_left, have h: hd ∈ Δ, exact mem_of_subset_of_mem a a_2_left, \n    all_goals {solve1{repeat{{left, assumption} <|> right <|> assumption}}}\n    end \n\n  lemma monotony : Γ ⊆ Δ → Γ ⊢ A →  Δ ⊢ A := \n    begin \n    intros a a_1, \n    apply exists.elim a_1, intros a_2 a_3, \n    existsi a_2, exact monotony_help a a_3\n    end\n \n  lemma provable_no_cutR : Γ ⊢cut A → Γ ⊢ A := \n    begin \n      have lem : ∀ l A, (is_proof_with_cut Γ l) → (A ∈ l) → (Γ ⊢ A),\n      intro l, induction l with B lis IH,\n      intros A a a_1, exact absurd rfl (list.ne_nil_of_mem a_1), \n      intros E hp ha, cases ha, rw[ha], cases hp.1, \n      apply exelim2 h, intros C D a,  \n      have HC: Γ ⊢ C, from IH C hp.2 a.1 ,\n      have HD: Γ ⊢ D, from IH D hp.2 a.2.1,\n        exact binary_cut HC HD a.2.2, \n      cases h, apply exists.elim h, intros C hC,  \n      have HC: Γ ⊢ C, from IH C hp.2 hC.1 ,       \n        exact unary_cut HC hC.2, \n      cases h, \n      have hyp: ∅ ⊆ Γ, from λ A hp, false.elim hp, \n        exact monotony hyp h,\n      cases h, apply exelim2 h, intros C D h_1,  \n      rw[h_1], let prf:=[], focus{mt_verifier}, \n      cases h, apply exelim3 h, intros C D E h_1,  \n      rw[h_1], let prf:=[], focus{mt_verifier},\n      cases h, apply exelim2 h, intros C D h_1,  \n      rw[h_1], let prf:=[], focus{mt_verifier}, \n      cases h, let prf:=[], existsi prf, split, \n      swap, exact rfl, iterate 3 {right}, left, assumption, \n      apply exists.elim h, intros G hG, \n      have Ha: Γ ⊢ G, exact  IH G hp.2 (hG.1),\n      have Hb: Γ ⊢ G ⇒ B, exact  IH (G ⇒ B) hp.2 (hG.2),\n      exact binary_cut Ha Hb modus_ponens_rule,\n      exact IH E hp.2 ha,\n      intros a, cases a with l hpp, have h: A∈ A::l, from by simp,\n      exact lem (A::l) A hpp h  \n    end\n  . \n  lemma provable1 : Γ ⊢ A ⇒ A :=\n    let prf:= [ (A ⇒ (A ⇒ A)) ⇒ (A ⇒ A), \n               A2 A (A ⇒ A) A,\n               A1 A A, \n               A1 A (A ⇒ A) ] in\n    by mt_verifier\n\n  lemma exchange : {A ⇒ B, A ⇒ B ⇒ C} ⊢ A ⇒ C:= \n    let prf:= [(A ⇒ B) ⇒ A ⇒ C, A ⇒ B, A ⇒ B ⇒ C, A2 A B C] in\n    by mt_verifier\n\n  theorem deduction_theorem : (Γ ∪ {A} ⊢ B) → (Γ ⊢ A ⇒ B) :=\n   have lem: ∀ l: list Form, is_proof (Γ ∪ {A}) l → \n                             ∀ B, B ∈ l →  \n                             (Γ ⊢ A ⇒ B), from\n   begin\n    intro l, induction l with C li IH, \n    intros _ a a_1, exact absurd rfl (list.ne_nil_of_mem a_1),\n    intros h B hp, cases hp,\n    rw[hp],                          \n    cases h.1, \n    apply exelim2 h_1, intros _ _ ax, rw[ax],   \n    focus{existsi ([_, A1 _ A]), mt_verifier}, cases h_1,\n    apply exelim3 h_1, intros _ _ _ ax, rw[ax],   \n    focus{existsi ([_, A1 _ A]), mt_verifier}, cases h_1, \n    apply exelim2 h_1, intros _ _ ax, rw[ax],   \n    focus{existsi ([_, A1 _ A]), mt_verifier}, cases h_1, \n    cases h_1, focus{let prf:= [C, A1 C A], mt_verifier},     \n    cases h_1, exact provable1, \n    cases h_1 with B hB, \n     have Hd: Γ ⊢ A ⇒ B, exact IH h.2 B hB.1, \n     have Himp: Γ ⊢ A ⇒ B ⇒ C, exact IH h.2 (B ⇒ C) hB.2,\n    exact (binary_cut Hd Himp exchange),\n    exact IH h.2 B hp  \n   end,       \n   assume h, exists.elim h (λ list hyp, \n   have is_in: B∈ B::list, from by simp,\n   lem (B::list) hyp B is_in)\n  \n  theorem deduction_theoremR : (Γ ⊢ A ⇒ B) → (Γ ∪ {A} ⊢ B) := \n    begin \n      intro h, \n      have h3: Γ ⊆ Γ ∪ {A}, simp,\n      have h21: Γ ∪ {A} ⊢ (A ⇒ B),\n      exact monotony h3 h, \n      apply exists.elim h21, intros l h2,\n      let prf:=(A::(A ⇒ B)::l), \n      existsi prf, \n      split, mt_mp, split, \n      iterate 3 {right}, left, simp,\n      exact h2\n    end \n \n  lemma double_neg_law: ⊢ ~~A ⇒ A :=\n   begin \n    apply deduction_theorem, simp,\n    let prf := \n    [\n    (~A ⇒ ~A) ⇒  A,\n    ~A ⇒ ~A,\n    ~A ⇒ ~~A, \n    A3 (~A) A, \n    A1 (~~A) (~A),\n    ~~A], mt_verifier \n   end\n\n  lemma provable2 : Γ ⊢ A ⇒ ~~A := \n    let prf := [\n                (~~~A ⇒ A) ⇒ ~~A, \n                A3 A (~~A),\n                ~~~A ⇒ ~A,\n                ~~~A ⇒ A, \n                A1 A (~~~A),\n                A] in\n    begin \n      apply monotony, \n      have h: {} ⊆ Γ, focus{simp}, exact h, \n      apply deduction_theorem, simp,\n      mt_verifier\n    end\n\n  lemma transitivity : {A ⇒ B, B ⇒ C} ⊢ A ⇒ C :=\n    let prf:= [\n      (A ⇒ B) ⇒ (A ⇒ C),\n      A ⇒ B, \n      A2 A B C, \n      A ⇒ (B ⇒ C), \n      A1 (B ⇒ C) A,\n      B ⇒ C\n    ] in by mt_verifier\n\n  lemma RAA: {A ⇒ B, A ⇒ ~B} ⊢ ~A:= \n    have h1: {A ⇒ B} ⊢ ~~A ⇒ B, from \n      by{let prf:= [~~A ⇒ A, A ⇒ B], mt_verifier},\n    have h2: {A ⇒ ~B} ⊢ ~~A ⇒ ~B, from \n      by{let prf:= [ ~~A ⇒ A, A ⇒ ~B ], mt_verifier}, \n    by{let prf:= [(~~A ⇒ B) ⇒ ~A, A3 B (~A), ~~A ⇒ ~B,~~A ⇒ B, A ⇒ B, A ⇒ ~B], mt_verifier}\n\n  lemma contraposition : {A ⇒ B} ⊢ ~B ⇒ ~A := \n    by{apply deduction_theorem, \n    let prf:= [A ⇒ ~B, ~B ⇒ (A ⇒ ~B), ~B, A ⇒ B], mt_verifier}\n                         \n  lemma provable5 : {A ⇒ B, ~A ⇒ B} ⊢ B:= \n    let prf:= [                  \n                        (~B ⇒ ~A ) ⇒ B, \n                        (~B ⇒ ~~A) ⇒ (~B ⇒ ~A) ⇒ B,            \n                        ~B ⇒ ~~A, \n                        ~A ⇒ B, \n                        ~B ⇒ ~A, \n                        A ⇒ B \n                    ] in\n    by{mt_verifier}\n\n  theorem PCP : (Γ ∪ {A} ⊢ B) → (Γ ∪ {~A} ⊢ B) → (Γ ⊢ B) := \n    assume h hneg, \n    have hp: Γ ⊢ A ⇒ B, from deduction_theorem h,\n    have hpp: Γ ⊢ ~A ⇒ B, from deduction_theorem hneg,        \n    binary_cut hp hpp (provable5)\n  \n  lemma modus_ponens : (Γ ⊢ A) → (Γ ⊢ (A ⇒ B)) → (Γ ⊢ B) :=\n    begin \n      intros a a_1, \n      apply exists.elim a, intros la prfa, \n      apply exists.elim a_1, intros lab prfab,\n      have h: is_proof Γ (A::la ++ (A⇒B)::lab), \n        from by {exact is_proof_concat prfa prfab},\n      have h3: in_proof B Γ (A::la ++ (A⇒B)::lab), \n        from by {repeat{right}, exact exists.intro A ⟨by simp, by simp⟩},\n      exact exists.intro (A::la ++ (A⇒B)::lab) ⟨h3, h⟩\n    end\n\n  lemma provable6 : (Γ ⊢ A) → (Γ ⊢ B ⇒ A) :=\n    λ hA, have p1: Γ∪{B} ⊢ A, from monotony (subset_union_left Γ {B}) hA,\n    deduction_theorem p1  \n\n  lemma provable3 : (Γ ⊢ ~A) → (Γ ⊢ A ⇒ B):= \n    λ h, \n    have h0: Γ ⊆ Γ ∪ {A}, from by simp,\n    have h1: Γ ∪ {A} ⊢ ~A, from monotony h0 h,\n    have h2: Γ ∪ {A} ⊢ A, from let prf:= [A] in by mt_verifier,\n    have h3: {~A, A} ⊢ B, from\n    let prf:= [(~B ⇒ A) ⇒ B, A3 A B, ~B ⇒ A, A, A1 A (~B), \n    (~B ⇒ ~A), ~A, A1 (~A) (~B)] in by mt_verifier,\n    deduction_theorem (binary_cut h1 h2 h3)\n\n  lemma sets_eqv: ({A,B}:set Form) = {A} ∪ {B}:= \n    begin \n      apply funext, intro x, \n      apply propext, \n      split, \n      intro a, cases a, \n      repeat{cases a, mt_assump0}, exact rfl, \n      intro a, cases a, cases a, mt_assump0, cases a, mt_assump0,\n      exact a    \n    end\n\n  lemma provable4_hlp : {A, ~B} ⊢ ~(A ⇒ B) := \n    begin \n      apply (@deduction_theoremR (~B) (~(A ⇒ B)) {A}),\n      apply unary_cut, swap, exact contraposition, \n      have h: {A} = {} ∪ {A}, exact (@empty_union Form {A}).symm, rw[h], \n      apply (@deduction_theoremR A ((A ⇒ B) ⇒ B) {}), \n      apply deduction_theorem, apply deduction_theorem, \n      have h2: {A} ∪ {A ⇒ B} = {A, A ⇒ B}, exact sets_eqv.symm,  \n      rw[h.symm, h2], \n      exact modus_ponens_rule\n    end \n\n  lemma provable4 : (Γ ⊢ A) → (Γ ⊢ ~B) → (Γ ⊢ ~(A ⇒ B)):= \n    by{intros a b, exact binary_cut a b provable4_hlp}\n\n\n-- COMPLETENESS preparation\n \n -- swap, lemmas\n -- lemmas for evaluating negation and implication\n  @[simp] def swap (A:Form)(v:eval) : Form := \n    if v∗A = tt then A else ~A\n\n  @[simp] def swap_var (n:ℕ)(v:eval): Form :=\n    if v n = tt then p n else ~(p n)\n\n  @[simp] theorem swap_tt : (v∗A = tt) → (swap A v = A) := \n    λ h, by simp [h]\n\n  @[simp] theorem swap_ff : (v∗A = ff) → (swap A v = ~A) :=\n    λ h, by simp [h]\n\n  @[simp] lemma pswap_neg_tt: (v∗A = tt) → (v∗(~A) = ff) := \n    λ h, @eq.subst bool (λ x, (v∗(~A)) = bnot x) (v∗A) tt h rfl\n  \n  @[simp] lemma pswap_neg_ff: (v∗A = ff) → (v∗(~A) = tt) := \n    λ h, @eq.subst bool (λ x, (v∗(~A)) = bnot x) (v∗A) ff h rfl\n\n  @[simp] theorem swap_neg_ff : (v∗A = ff) → swap (~A) v = ~A :=\n    λ h, by simp [h]\n \n  theorem swap_neg_tt : (v∗A = tt) → swap (~A) v = ~~A := \n    λ h, by simp[h]\n\n  @[simp] lemma pswap_imp_tt_ff : (v∗A = tt) → (v∗B = ff) → (v∗(A ⇒ B) = ff) :=\n    λ ha hb, have h2: (v∗(A ⇒ B)) = bnot (v∗A) || ff, from hb ▸ rfl,\n    @eq.subst bool (λ x, (v∗(A ⇒ B)) = bnot x || ff) (v∗A) tt ha h2\n\n  @[simp] lemma pswap_imp_tt_tt : (v∗A = tt) → (v∗B = tt) → (v∗(A ⇒ B) = tt) :=\n    λ ha hb, have h2: (v∗(A ⇒ B)) = bnot (v∗A) || tt, from hb ▸ rfl,\n    @eq.subst bool (λ x, (v∗(A ⇒ B)) = bnot x || tt) (v∗A) tt ha h2\n\n  theorem swap_imp_tt_ff : \n      (v∗A = tt) → (v∗B = ff) → (swap (A ⇒ B) v = ~(A ⇒ B)) :=\n    λ h h1, by simp[h, h1] \n\n  theorem swap_imp_tt_tt: \n      (v∗A = tt) → (v∗B = tt) → (swap (A ⇒ B) v = A ⇒ B) :=\n    λ h p, by simp[h, p] \n\n  theorem swap_imp_ff : (v∗A = ff) → (v∗(A ⇒ B)) = tt := \n    λ h, calc v∗(A ⇒ B) = bnot ff || (v∗B) : h ▸ rfl\n\n  lemma swap_var_tt : v n = tt → (swap_var n v = p n) := \n    λ h, by simp [h]\n\n  lemma swap_var_ff : v n = ff → (swap_var n v = ~p n) :=\n    λ h, by simp [h]\n \n -- svar_set set\n  def svar_set (n:ℕ)(v:eval) : set Form :=\n    { A | ∃ i:ℕ, i < n ∧ A = (swap_var i v)}\n\n  def form_index (A:Form) : ℕ := \n    Form.rec_on A (λ n:ℕ, n+1) \n                  (λ A B:Form, λ na nb:ℕ, max na nb) \n                  (λ A:Form, λ m:ℕ, m)\n\n  lemma swap_in_flae : (swap (p n) v) ∈  svar_set (form_index (p n)) v :=\n    have h: form_index (p n) = n+1, from rfl,\n    exists.intro n ⟨lt_succ_self n, rfl⟩   \n\n  lemma flae_inclusion : (∀ n ≤ m,  svar_set n v ⊆  svar_set m v) := \n    λ n h A h', exists.elim h'\n    (λ i h1, exists.intro i (show i < m ∧ A = swap_var i v, from \n    ⟨nat.le_trans h1.1 h, h1.2⟩))\n\n  lemma flae_empty :  svar_set 0 v = {} := \n    funext (λ A:Form, show  svar_set 0 v A = false, from \n    propext ⟨ (λ h: svar_set 0 v A, exists.elim h (λ i h1, \n    (nat.succ_ne_zero i (nat.eq_zero_of_le_zero h1.1 )))),\n    false.elim ⟩)\n    \n  lemma var_index_max_left : form_index A ≤ form_index (A ⇒ B) :=\n    le_max_left (form_index A) (form_index B)\n\n  lemma var_index_max_right : form_index B ≤ form_index (A ⇒ B) :=\n    le_max_right (form_index A) (form_index B)\n\n -- truth eval \n  @[simp] def g₁ (n:ℕ)(v:eval) : ℕ → bool := \n   λ m, if m<n then v m else tt\n\n  @[simp] def g₂ (n:ℕ)(v:eval) : ℕ → bool := \n   λ m, if m<n then v m else ff\n\n  lemma g₁_eq_tt (h: m = n) : (g₁ n v) m = tt := \n    have ¬( m < n), from λ h', ne_of_lt h' h,\n    by simp [this]\n \n  lemma g₂_eq_ff (h: m = n) : (g₂ n v) m = ff := \n    have ¬  m < n, from λ h', ne_of_lt h' h,\n    by simp [this]\n\n  lemma g₁_v_eq_ite (v g:eval)(n:ℕ) : v n = g n → \n    ite (v n = tt) (p n) (~ p n) = ite (g n = tt) (p n) (~ p n) := \n   λ h, (@eq.subst bool (λ x, ite (v n = tt) (p n) (~ p n) = ite (x = tt) (p n) (~ p n)) \n   (v n) (g n) h) rfl \n\n  lemma g₁_v_eq: ∀ m < n, v m = (g₁ n v) m :=\n   λ m n, by simp [n]\n\n  lemma g₂_v_eq: ∀ m < n, v m = (g₂ n v) m :=\n   λ m n, by simp [n]\n\n  lemma g₁_v_swap_var_eq (v:eval) : m < n → swap_var m v = swap_var m (g₁ n v) := \n   λ h , have h1: v m = (g₁ n v) m, from g₁_v_eq m h,\n   g₁_v_eq_ite v (g₁ n v) m h1\n\n  lemma g₂_v_swap_var_eq (v:eval) : m<n → swap_var m v = swap_var m (g₂ n v) :=\n   λ h , have h1: v m = (g₂ n v) m, from g₂_v_eq m h,\n   g₁_v_eq_ite v (g₂ n v) m h1\n\n  meta def flae_ind_tac : tactic unit := \n  `[  \n      apply funext, intro A, \n      apply propext, split, \n\n      intro h, cases h, \n      cases h, existsi h_w, \n      split, exact nat.lt_trans h_h.1 (lt_add_one n), \n      rw[h_h.2], \n      {exact g₁_v_swap_var_eq v h_h.1} <|> {exact g₂_v_swap_var_eq v h_h.1}, \n\n      cases h, \n      existsi n, split, \n      exact lt_add_one n,\n      have hp1: g₁ n v n = tt, from @g₁_eq_tt v n n rfl,\n      have hp2: g₂ n v n = ff, from @g₂_eq_ff v n n rfl, \n      {rw[(@swap_var_tt (g₁ n v) n hp1).symm]} <|> \n      {rw[(@swap_var_ff (g₂ n v) n hp2).symm]},  \n\n      intro h, cases h, \n      apply (@nat.lt_by_cases h_w n _), \n      intro h2, left, existsi _, \n      split, exact h2, \n      {rw[(g₁_v_swap_var_eq v h2)], exact h_h.2} <|> \n      {rw[(g₂_v_swap_var_eq v h2)], exact h_h.2},\n\n      intro h2, right, \n      {rw[(swap_var_tt (@g₁_eq_tt v h_w n h2)), h2] at h_h, exact h_h.2} <|> \n      {rw[(swap_var_ff (@g₂_eq_ff v h_w n h2)), h2] at h_h, exact h_h.2}, \n\n      intro h2, have h5: h_w ≤ n, from iff.elim_left lt_succ_iff h_h.1,\n      have h6: h_w ≤ n ∧ ¬h_w ≤ n, from ⟨h5, (iff.elim_left (lt_iff_not_ge n h_w)) h2⟩,\n      exact false.elim (iff.elim_left (and_not_self (h_w ≤ n)) h6)\n  ]\n\n  lemma flae_ind : (svar_set n v) ∪ {p n} =  svar_set (n+1) (g₁ n v) :=\n    by flae_ind_tac\n\n  lemma flae_ind_neg : (svar_set n v) ∪ {~p n} =  svar_set (n+1) (g₂ n v) :=\n    by flae_ind_tac\n\n \n -- induction formalization \n  def nprovable (A:Form)(n:ℕ) : Prop :=\n    ∀ v:eval, (svar_set n v) ⊢ A\n\n  lemma PCP_app : ∀ n:ℕ, nprovable A (n+1) → nprovable A n:=\n    λ n hp f, show  (svar_set n f) ⊢ A, from PCP\n    (@eq.subst (set Form) (λ Γ, Γ ⊢ A) (svar_set (n+1) (g₁ n f)) ((svar_set n f) ∪ {p n}) \n      (@flae_ind f n).symm (hp (g₁ n f)))        \n    (@eq.subst (set Form) (λ Γ, Γ ⊢  A) (svar_set (n+1) (g₂ n f)) ((svar_set n f) ∪ { ~(p n)}) \n      (@flae_ind_neg f n).symm (hp (g₂ n f)))\n\n  theorem nprov_theorem : nprovable A n → (⊢ A) :=\n    λ h, have H: nprovable A n → nprovable A 0, from  \n      nat.rec_on n (λ h, h) (assume n IH hp, IH (PCP_app n hp)), \n    (@flae_empty (λ n:ℕ, tt)) ▸ (H h) (λ n:ℕ, tt)\n\n\n-- COMPLETENESS\n\n  lemma main_lemma : ∀ v:eval, (svar_set (form_index A) v) ⊢ swap A v := \n    λ v,\n    Form.rec_on A \n    -- p constructor     \n    (λ n, exists.intro []\n      ⟨or.inr (or.inr (or.inr (or.inl swap_in_flae))), rfl⟩)\n    -- imp constructor\n    (λ A B, let Γa := (svar_set (form_index A) v),\n                Γb:set Form := (svar_set (form_index B) v),\n                Γimp := (svar_set (form_index (A ⇒ B)) v) in\n   λ IHa: Γa ⊢ swap A v, \n   λ IHb: Γb ⊢ swap B v,\n   have h: Γa ⊆ Γimp, from flae_inclusion (form_index A) var_index_max_left,\n   have hbb: Γb ⊆ Γimp, from flae_inclusion (form_index B) var_index_max_right, \n   or.elim (bool.dichotomy (v∗A))\n    -- v∗A=ff                          \n     (λ hpa, have himp: swap (A ⇒ B) v = (A ⇒ B), from swap_tt (swap_imp_ff hpa),                          \n     (calc (Γa ⊢ swap A v) → (Γa ⊢ ~A)                :  λ h, swap_ff hpa ▸ IHa\n                 ...       → (Γa ⊢ A ⇒ B)             :  λ h, provable3 h \n                 ...       → (Γimp ⊢ A ⇒ B)           :  λ hp, monotony h hp    \n                 ...       → (Γimp ⊢ swap (A ⇒ B) v)  :  λ h, himp.symm ▸ h) \n     IHa)\n              \n    -- v∗A=tt \n     (λ hpa, or.elim (bool.dichotomy (v∗ B))\n      -- v∗B=ff\n      (λ hpb, have ha: (Γimp ⊢ A), from  \n              (calc (Γa ⊢ swap A v) → (Γa ⊢ A)    : λ h5, swap_tt hpa ▸ IHa\n                          ...       → (Γimp ⊢ A)  : λ h5, monotony h h5) IHa, \n              have hb: (Γimp ⊢ ~B), from \n              (calc (Γb ⊢ swap B v) → (Γb ⊢ ~B)   : λ h5, swap_ff hpb ▸ IHb\n                           ...      → (Γimp ⊢ ~B) : λ h5, monotony hbb h5) IHb, \n              have hab: (Γimp ⊢ ~(A ⇒ B)), from provable4 ha hb, \n              (calc (Γimp ⊢ ~(A ⇒ B)) → (Γimp ⊢ swap (A ⇒ B) v) : \n               λ h5, eq.substr (swap_imp_tt_ff hpa hpb) h5) hab)\n      -- v∗B=tt\n      (λ hpb, have hb: (Γimp ⊢ B), from \n              (calc (Γb ⊢ swap B v) → (Γb ⊢ B)   : λ h5, swap_tt hpb ▸ IHb\n                           ...      →  (Γimp ⊢ B) : λ h5, monotony hbb h5) IHb, \n              have hab: (Γimp ⊢ (A ⇒ B)), from (@provable6 B A Γimp) hb, \n              (calc (Γimp ⊢ (A ⇒ B)) → (Γimp ⊢ swap (A ⇒ B) v) : \n               λ h5, (swap_imp_tt_tt hpa hpb).symm ▸ h5) hab)))\n    -- neg₁ constructor\n    (λ A,   let Γa := ( svar_set (form_index A) v) in              \n     λ ha: Γa ⊢ swap A v, \n     show Γa ⊢ swap (~A) v, from \n     or.elim (bool.dichotomy (v∗A))\n    -- v∗A=ff\n    (λ h, (calc (Γa ⊢ swap A v) → (Γa ⊢ ~A)          : λ h1, swap_ff h ▸ ha\n                       ...      → (Γa ⊢ swap (~A) v) : λ h1, (swap_neg_ff h).symm ▸ h1) ha) \n    -- v∗A=tt \n    (λ h, (calc (Γa ⊢ swap A v) → (Γa ⊢ A)           : λ h1, swap_tt h ▸ ha\n                       ...      → (Γa ⊢ ~~A)         : λ h1, modus_ponens h1 provable2\n                       ...      → (Γa ⊢ swap (~A) v) : λ h1, (swap_neg_tt h).symm ▸ h1) ha))\n  \n  theorem CPL_completeness: ⊧ A → ⊢ A :=\n    λ h, have H: nprovable A (form_index A), from             \n      (λ v:eval, @eq.subst Form \n      (λ B:Form, is_provable (svar_set (form_index A) v) B) \n      (swap A v) A (swap_tt (h v)) (main_lemma v)),\n    nprov_theorem H \n", "meta": {"author": "jachsimon", "repo": "CPL_completness_soundness-", "sha": "bd1819ddf6001c2c85285c6527e13e6a86514d69", "save_path": "github-repos/lean/jachsimon-CPL_completness_soundness-", "path": "github-repos/lean/jachsimon-CPL_completness_soundness-/CPL_completness_soundness--bd1819ddf6001c2c85285c6527e13e6a86514d69/CPL_compl_sound.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.6261241842048092, "lm_q1q2_score": 0.4708532662168892}}
{"text": "import ring_theory.adjoin_root data.equiv.algebra algebra.direct_limit\nimport set_theory.schroeder_bernstein\n\nuniverses u v w\nopen polynomial zorn set function\nvariables (K : Type u) [discrete_field K]\nnoncomputable theory\n\ninstance equiv.is_ring_hom {α β : Type*} [ring β] (e : α ≃ β) :\n  @is_ring_hom α β (equiv.ring e) _ e :=\nby split; simp [equiv.mul_def, equiv.add_def, equiv.one_def]\n\ninstance equiv.is_ring_hom.symm {α β : Type*} [ring β] (e : α ≃ β) :\n  @is_ring_hom β α _ (equiv.ring e) e.symm :=\nby letI := equiv.ring e; exact (show α ≃r β, from ⟨e, equiv.is_ring_hom e⟩).symm.2\n\ninductive in_algebraic_closure {L : Type v} [discrete_field L] (i : K → L) : L → Prop\n| of_field : ∀ x, in_algebraic_closure (i x)\n| root     : ∀ (l : L) (f : polynomial L), f ≠ 0 → (∀ n : ℕ, in_algebraic_closure (f.coeff n)) →\n  is_root f l → in_algebraic_closure l\n\ndef algebraic {L : Type v} [comm_ring L] (i : K → L) (x : L) : Prop :=\n∃ f : polynomial K, f ≠ 0 ∧ f.eval₂ i x = 0\n\nclass is_algebraically_closed :=\n(exists_root : ∀ f : polynomial K, 0 < degree f → ∃ x, is_root f x)\n\nlemma algebraic_comp {L M : Type*} [comm_ring L] [decidable_eq L] [comm_ring M] [decidable_eq M]\n  (i : K → L) (j : L → M) [is_ring_hom i] [is_ring_hom j] {x : L} :\n  algebraic K i x → algebraic K (j ∘ i) (j x) :=\nλ ⟨f, hf⟩, ⟨f, hf.1, by rw [← eval_map, function.comp, ← polynomial.map_map i j, eval_map,\n    eval₂_hom, eval_map, hf.2, is_ring_hom.map_zero j]⟩\n\nlemma algebraic_id (x : K) : algebraic K id x :=\n⟨X - C x, ne_zero_of_monic (monic_X_sub_C _), by simp⟩\n\nlemma algebraic_equiv {L : Type*} [discrete_field L] (e : K ≃ L) [is_ring_hom e] (x : L) : \n  algebraic K e x :=\n⟨X - C (e.symm x), ne_zero_of_monic (monic_X_sub_C _), \n  by rw [← eval_map, map_sub, map_X, map_C, equiv.apply_symm_apply,\n      eval_sub, eval_X, eval_C, sub_self]⟩\n\nlemma algebraic_adjoin_root (f : polynomial K) [irreducible f] :\n  ∀ x, algebraic K (adjoin_root.of : K → adjoin_root f) x := sorry\n\nlemma algebraic_comp' {L M : Type*} [discrete_field L] [discrete_field M]\n  (i : K → L) (j : L → M) [is_field_hom i] [is_field_hom j] :\n  (∀ x, algebraic K i x) → (∀ x, algebraic L j  x) → ∀ x, algebraic K (j ∘ i) x := sorry\n\nsection classical\n\nlocal attribute [instance, priority 1] classical.dec\n\ndef big_type := set (ℕ × polynomial K)\n\ndef big_type_map {L : Type*} [discrete_field L] (i : K → L) [is_ring_hom i]\n  (h : ∀ l : L, algebraic K i l) (x : L) : ℕ × polynomial K :=\nlet f := classical.some (h x) in\n⟨list.index_of x (quotient.out ((f.map i).roots.1)), f⟩\n\nlemma big_type_map_injective {L : Type*} [discrete_field L] (i : K → L) [is_ring_hom i]\n  (h : ∀ l : L, algebraic K i l) : injective (big_type_map K i h) :=\nλ x y hxy,\nlet f := classical.some (h x) in\nlet g := classical.some (h y) in\nhave hf : f ≠ 0 ∧ f.eval₂ i x = 0, from classical.some_spec (h x),\nhave hg : g ≠ 0 ∧ g.eval₂ i y = 0, from classical.some_spec (h y),\nhave hfg : f = g, from (prod.ext_iff.1 hxy).2,\nhave hfg' : list.index_of x (quotient.out ((f.map i).roots.1)) =\n    list.index_of y (quotient.out ((f.map i).roots.1)),\n  from (prod.ext_iff.1 hxy).1.trans (hfg.symm ▸ rfl),\nhave hx : x ∈ quotient.out ((f.map i).roots.1),\n  from multiset.mem_coe.1 begin\n    show x ∈ quotient.mk _,\n    rw [quotient.out_eq, ← finset.mem_def, mem_roots (mt (map_eq_zero i).1 hf.1),\n      is_root.def, eval_map, hf.2]\n  end,\nhave hy : y ∈ quotient.out ((f.map i).roots.1),\n  from multiset.mem_coe.1 begin\n    show y ∈ quotient.mk _,\n    rw [quotient.out_eq, ← finset.mem_def, mem_roots (mt (map_eq_zero i).1 hf.1),\n      is_root.def, eval_map, hfg, hg.2]\n  end,\n(list.index_of_inj hx hy).1 hfg'\n\nlemma bembedding : K ↪ big_type K :=\n⟨λ a, show set _, from {(0, X - C a)}, λ a b, by simp [C_inj]⟩\n\ninstance : discrete_field (set.range (bembedding K)) :=\nequiv.discrete_field (equiv.set.range _ (bembedding K).2).symm\n\nstructure extension : Type (u+1) :=\n(carrier : set (big_type K))\n[field : discrete_field ↥carrier]\n(range_subset : set.range (bembedding K) ⊆ carrier)\n[is_field_hom : is_field_hom (inclusion range_subset)]\n(algebraic : ∀ x, algebraic _ (inclusion (range_subset)) x)\n(lift : Π {α : Type u} [discrete_field α] (i : set.range (bembedding K) → α)\n  [by exactI _root_.is_field_hom i] [is_algebraically_closed α],\n  carrier → α)\n(lift_is_field_hom : ∀ {α : Type u} [discrete_field α] (i : set.range (bembedding K) → α)\n  [by exactI _root_.is_field_hom i] [is_algebraically_closed α],\n  by exactI _root_.is_field_hom (lift i))\n(lift_comp : ∀ {α : Type u} [discrete_field α] (i : set.range (bembedding K) → α)\n  [by exactI _root_.is_field_hom i] [is_algebraically_closed α] (x),\n  by exactI lift i (inclusion range_subset x) = i x)\n\nlocal attribute [instance] extension.field extension.is_field_hom extension.lift_is_field_hom\n\ninstance : preorder (extension K) :=\n{ le := λ s t, ∃ hst : s.carrier ⊆ t.carrier, is_field_hom (inclusion hst)\n    ∧ ∀ {α : Type u} [discrete_field α] (i : set.range (bembedding K) → α)\n    [by exactI _root_.is_field_hom i] [by exactI is_algebraically_closed α] (x : s.carrier),\n    by exactI s.lift i x = t.lift i (inclusion hst x),\n  le_refl := λ _, ⟨by refl, by simp [inclusion]; exact is_ring_hom.id,\n    by intros; simp [inclusion, subtype.coe_eta]⟩,\n  le_trans := λ s t u ⟨hst₁, hst₂, hst₃⟩ ⟨htu₁, htu₂, htu₃⟩,\n    ⟨set.subset.trans hst₁ htu₁,\n      by resetI; convert is_ring_hom.comp (inclusion hst₁) (inclusion htu₁),\n      by intros; rw [hst₃, htu₃, inclusion_inclusion]⟩ }\n\nprivate structure chain' (c : set (extension K)) : Prop :=\n(chain : chain (≤) c)\n\nlocal attribute [class] chain'\n\nlemma is_chain (c : set (extension K)) [chain' _ c]: chain (≤) c :=\nchain'.chain (by apply_instance)\n\nsection\n\nvariables (c : set (extension K)) [hcn : nonempty c]\ninclude c  hcn\n\nvariable [hcn' : chain' _ c]\ninclude hcn'\n\ninstance chain_directed_order : directed_preorder c :=\n⟨λ ⟨i, hi⟩ ⟨j, hj⟩, let ⟨k, hkc, hk⟩ := chain.directed_on\n  (is_chain _ c) i hi j hj in ⟨⟨k, hkc⟩, hk⟩⟩\n\ndef chain_map (i j : c) (hij : i ≤ j) : i.1.carrier → j.1.carrier :=\ninclusion (exists.elim hij (λ h _, h))\n\ninstance chain_field_hom (i j : c) (hij : i ≤ j) : is_field_hom (chain_map _ c i j hij) :=\nexists.elim hij (λ _, and.left)\n\ninstance chain_directed_system : directed_system (λ i : c, i.1.carrier) (chain_map _ c) :=\nby split; intros; simp [chain_map]\n\ndef chain_limit : Type (u+1) :=\n  ring.direct_limit (λ i : c, i.1.carrier) (chain_map _ c)\n\nlemma of_eq_of (x : big_type K) (i j : c) (hi : x ∈ i.1.carrier) (hj : x ∈ j.1.carrier) :\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map _ c) i ⟨x, hi⟩ =\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map _ c) j ⟨x, hj⟩ :=\nhave hij : i ≤ j ∨ j ≤ i,\n  from show i.1 ≤ j.1 ∨ j.1 ≤ i.1, from chain.total (is_chain _ c) i.2 j.2,\nhij.elim\n  (λ hij, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map _ c) _\n      _ _ _ hij,\n    simp [chain_map, inclusion]\n  end)\n  (λ hij, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map _ c) _\n      _ _ _ hij,\n    simp [chain_map, inclusion]\n  end)\n\nlemma injective_aux (i j : c)\n  (x y : ⋃ i : c, i.1.carrier) (hx : x.1 ∈ i.1.carrier) (hy : y.1 ∈ j.1.carrier) :\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map _ c) i ⟨x, hx⟩ =\n  ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map _ c) j ⟨y, hy⟩ →\n  x = y :=\nhave hij : i ≤ j ∨ j ≤ i,\n  from show i.1 ≤ j.1 ∨ j.1 ≤ i.1, from chain.total (is_chain _ c) i.2 j.2,\nhave hinj : ∀ (i j : c) (hij : i ≤ j), injective (chain_map _ c i j hij),\n  from λ _ _ _, is_field_hom.injective _,\nhij.elim\n  (λ hij h, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map _ c) _\n      _ _ _ hij at h,\n    simpa [chain_map, inclusion, subtype.coe_ext.symm] using ring.direct_limit.of_inj hinj j h,\n  end)\n  (λ hji h, begin\n    rw ← @ring.direct_limit.of_f c _ _ _ (λ i : c, i.1.carrier) _ _ (chain_map _ c) _\n      _ _ _ hji at h,\n    simpa [chain_map, inclusion, subtype.coe_ext.symm] using ring.direct_limit.of_inj hinj i h,\n  end)\n\ndef equiv_direct_limit : (⋃ (i : c), i.1.carrier) ≃\n  ring.direct_limit (λ i : c, i.1.carrier) (chain_map _ c) :=\n@equiv.of_bijective (⋃ i : c, i.1.carrier)\n  (ring.direct_limit (λ i : c, i.1.carrier) (chain_map _ c))\n  (λ x, ring.direct_limit.of _ _ (classical.some (set.mem_Union.1 x.2))\n    ⟨_, classical.some_spec (set.mem_Union.1 x.2)⟩)\n  ⟨λ x y, injective_aux _ _ _ _ _ _ _ _,\n    λ x, let ⟨i, ⟨y, hy⟩, hy'⟩ := ring.direct_limit.exists_of x in\n      ⟨⟨y, _, ⟨i, rfl⟩, hy⟩, begin\n        convert hy',\n        exact of_eq_of _ _ _ _ _ _ _\n      end⟩⟩\n\ninstance Union_field : discrete_field (⋃ i : c, i.1.carrier) :=\n@equiv.discrete_field _ _ (equiv_direct_limit _ c)\n  (field.direct_limit.discrete_field _ _)\n\ninstance is_field_hom_Union (i : c) : is_field_hom\n  (inclusion (set.subset_Union (λ i : c, i.1.carrier) i)) :=\nsuffices inclusion (set.subset_Union (λ i : c, i.1.carrier) i) =\n    ((equiv_direct_limit K c).symm ∘\n    ring.direct_limit.of (λ i : c, i.1.carrier) (chain_map _ c) i),\n  by rw this; exact is_ring_hom.comp _ _,\nfunext $ λ ⟨_, _⟩,\n  (equiv_direct_limit _ c).injective $\n    by rw [function.comp_app, equiv.apply_symm_apply];\n      exact of_eq_of _ _ _ _ _ _ _\n\ninstance is_field_hom_range_Union [hc : nonempty c]\n  (h : set.range (bembedding K) ⊆ ⋃ i : c, i.1.carrier) :\n  is_field_hom (inclusion h) :=\nlet ⟨i⟩ := hc in\nhave h₁ : i.1.carrier ⊆ ⋃ i : c, i.1.carrier, from set.subset_Union _ i,\nhave h₂ : set.range (bembedding K) ⊆ i.1.carrier, from i.1.range_subset,\nhave inclusion h = inclusion h₁ ∘ inclusion h₂, by simp [function.comp],\nby rw this; exact is_ring_hom.comp _ _\n\ndef chain_lift [nonempty c] (α : Type u) [discrete_field α] (i : set.range (bembedding K) → α)\n  [is_field_hom i] [is_algebraically_closed α] :\n  (⋃ i : c, i.1.carrier) → α :=\n(ring.direct_limit.lift (λ j : c, j.1.carrier) (chain_map _ c) _\n  (λ j : c, j.1.lift i) (λ i j ⟨_, _, h⟩, by introsI; rw [h, chain_map])) ∘\n  (equiv_direct_limit K c)\n\ndef is_field_hom_chain_lift [nonempty c] (α : Type u) [discrete_field α]\n  (i : set.range (bembedding K) → α) [is_field_hom i]\n  [is_algebraically_closed α] : is_field_hom (chain_lift K c α i) :=\nis_ring_hom.comp _ _\n\nend\n\nlemma exists_algebraic_closure : ∃ m : extension K, ∀ a, m ≤ a → a ≤ m :=\nby letI := classical.dec; exact\nzorn\n  (λ c hc, if h : nonempty c\n    then by letI : chain' K c := ⟨hc⟩; exact\n      ⟨{carrier := ⋃ (i : c), i.1.carrier,\n        range_subset := let ⟨i⟩ := h in\n          have hi : set.range (bembedding K) ⊆ i.1.carrier,\n            from extension.range_subset _,\n          set.subset.trans hi (set.subset_Union (λ i : c, i.1.carrier) i),\n        algebraic := begin\n            rintros ⟨x, hx⟩,\n            cases set.mem_Union.1 hx with i hi,\n            convert @algebraic_comp (set.range (bembedding K)) _ i.1.carrier\n              (⋃ i : c, i.1.carrier) _ _ _ _\n              (inclusion i.1.range_subset)\n              (inclusion (set.subset_Union (λ i : c, i.1.carrier) (i : c))) _ _ _\n              (i.1.algebraic ⟨x, hi⟩)\n          end,\n        lift := chain_lift _ c,\n        lift_is_field_hom := is_field_hom_chain_lift K c,\n        lift_comp := begin\n            intros,\n            dunfold chain_lift equiv_direct_limit,\n            simp,\n            erw extension.lift_comp\n          end },\n      λ e he, ⟨set.subset_Union (λ i : c, i.1.carrier) ⟨e, he⟩,\n        by apply_instance,\n        begin\n          intros,\n          dsimp [chain_lift, equiv_direct_limit],\n          erw [ring.direct_limit.lift_of],\n          cases chain.total (is_chain _ c) he (classical.some (set.mem_Union.1\n            (set.subset_Union (λ i : c, i.1.carrier) ⟨e, he⟩ x.2))).2 with h h,\n          { rw (classical.some_spec h).2, refl },\n          { erw (classical.some_spec h).2, cases x, refl }\n        end⟩⟩\n    else\n      have is_field_hom (inclusion (set.subset.refl (set.range (bembedding K)))) :=\n      by convert is_ring_hom.id; funext; simp,\n      by exactI ⟨⟨set.range (bembedding K), by refl,\n          λ _, by convert algebraic_id _ _; funext; simp, λ _ _ i _ _, i,\n          by introsI; apply_instance, by simp [inclusion]⟩,\n        λ a ha, (h ⟨⟨a, ha⟩⟩).elim⟩)\n  (λ _ _ _, le_trans)\n\ndef closed_extension := classical.some (exists_algebraic_closure K)\n\ndef algebraic_closure : Type u := ((classical.some (exists_algebraic_closure K))).carrier\n\nend classical\n\nnamespace algebraic_closure\n\ninstance : discrete_field (algebraic_closure K) :=\n{ has_decidable_eq := classical.dec_eq _,\n  ..(classical.some (exists_algebraic_closure K)).field }\n\ndef of_aux : K → set.range (bembedding K) :=\nequiv.set.range _ (bembedding K).2\n\nlemma of_aux.is_field_hom : is_ring_hom (of_aux K) :=\nequiv.is_ring_hom.symm (equiv.set.range _ (bembedding K).2).symm\n\ndef of_aux_symm : set.range (bembedding K) → K :=\n(equiv.set.range _ (bembedding K).2).symm\n\nlemma of_aux_symm.is_field_hom : is_ring_hom (of_aux_symm K) :=\nequiv.is_ring_hom (equiv.set.range _ (bembedding K).2).symm\n\nlocal attribute [instance] of_aux.is_field_hom of_aux_symm.is_field_hom\n\ndef of : K → algebraic_closure K :=\ninclusion (classical.some (exists_algebraic_closure K)).range_subset ∘ \n(of_aux K)\n\ninstance : is_ring_hom (of K) :=\nbegin \n  haveI h₁ := (classical.some (exists_algebraic_closure K)).is_field_hom,\n  letI h₂ : ring (classical.some (exists_algebraic_closure K)).carrier :=\n    show ring (algebraic_closure K), by apply_instance,\n  unfold of,\n  exact @is_ring_hom.comp _ _ _ _ _ _ _ _ _ h₁\nend\n\nlemma of_algebraic_aux (x : algebraic_closure K) : \n  @algebraic (set.range (bembedding K)) _ (algebraic_closure K) _\n  (inclusion (classical.some (exists_algebraic_closure K)).range_subset) x :=\n(classical.some (exists_algebraic_closure K)).algebraic x\n\nlemma of_algebraic (x : algebraic_closure K) : algebraic K (of K) x :=\nlet ⟨f, hf⟩ := (classical.some (exists_algebraic_closure K)).algebraic x in\n⟨f.map (of_aux_symm K), mt (map_eq_zero _).1 hf.1,\n  calc eval₂ (of K) x (f.map (of_aux_symm K)) = eval₂ (λ x, of K (of_aux_symm K x)) x f :\n    sorry\n\n  ... = 0 : sorry\n  ⟩\n -- eval₂_map (of_aux_symm K) (of K) x).trans _\n\ndef lift_aux {L : Type u} [discrete_field L] (i : set.range (bembedding K) → L)\n  [is_field_hom i] [is_algebraically_closed L] :\n  algebraic_closure K → L :=\n(classical.some (exists_algebraic_closure K)).lift i\n\nlemma lift_aux.is_field_hom {L : Type u} [discrete_field L] (i : set.range (bembedding K) → L)\n  [is_field_hom i] [is_algebraically_closed L] : is_field_hom (lift_aux K i) :=\n(classical.some (exists_algebraic_closure K)).lift_is_field_hom _\n\nlocal attribute [instance] lift_aux.is_field_hom\n\nsection map\n\nlocal attribute [instance] classical.dec\n\nlemma map_aux {X : Type u} {Y : Type v} {Z : Type w} (fxy : X ↪ Y) (fxz : X ↪ Z)\n  (hYZ : (Z ↪ Y) → false) : ↥-range fxy.1 ↪ ↥-range fxz.1 :=\nclassical.choice $ or.resolve_left embedding.total $\n  λ ⟨f⟩, hYZ $\n    calc Z ↪ range fxz ⊕ ↥-range fxz :\n      (equiv.set.sum_compl _).symm.to_embedding\n    ... ↪ range fxy ⊕ ↥-range fxy :\n      embedding.sum_congr\n        (((equiv.set.range _ fxz.2).symm.to_embedding).trans\n          (equiv.set.range _ fxy.2).to_embedding)\n        f\n    ... ↪ Y : (equiv.set.sum_compl _).to_embedding\n\ndef map {X : Type u} {Y : Type v} {Z : Type w} (fxy : X ↪ Y) (fxz : X ↪ Z)\n  (hYZ : (Z ↪ Y) → false) : Y ↪ Z :=\ncalc Y ↪ range fxy ⊕ ↥-range fxy : (equiv.set.sum_compl _).symm.to_embedding\n... ↪ range fxz ⊕ ↥-range fxz : embedding.sum_congr\n  ((equiv.set.range _ fxy.2).symm.to_embedding.trans\n    (equiv.set.range _ fxz.2).to_embedding)\n  (map_aux fxy fxz hYZ)\n... ↪ Z : (equiv.set.sum_compl _).to_embedding\n\nlemma map_commutes {X : Type u} {Y : Type v} {Z : Type w}  (fxy : X ↪ Y) (fxz : X ↪ Z)\n  (hYZ : (Z ↪ Y) → false) (x : X) : map fxy fxz hYZ (fxy x) = fxz x :=\nhave (⟨fxy x, mem_range_self _⟩ : range fxy) = equiv.set.range _ fxy.2 x, from rfl,\nbegin\n  dsimp only [map, embedding.trans_apply, equiv.trans_apply, function.comp,\n    equiv.to_embedding_coe_fn],\n  simp only [equiv.set.sum_compl_symm_apply_of_mem (mem_range_self _),\n    embedding.sum_congr_apply_inl, equiv.set.sum_compl_apply_inl,\n    embedding.trans_apply, equiv.to_embedding_coe_fn, this, equiv.symm_apply_apply],\n  refl\nend\n\nend map\n\nsection adjoin_root\nvariables (f : polynomial (algebraic_closure K)) [hif : irreducible f]\ninclude hif\n\ninstance adjoin_root_algebraic_closure.field : \n  discrete_field (adjoin_root f) := by apply_instance\n\ninstance adjoin_root_algebraic_closure.is_ring_hom : \n  is_ring_hom (@adjoin_root.of _ _ _ f) := by apply_instance\n\ninstance algebraic_closure_adjoin_root_comp.is_ring_hom : \n  is_ring_hom (@adjoin_root.of _ _ _ f ∘ of K) := is_ring_hom.comp _ _\n\ndef adjoin_root.of_embedding : algebraic_closure K ↪ adjoin_root f :=\n⟨adjoin_root.of, is_field_hom.injective _⟩\n\ndef adjoin_root_extension_map : adjoin_root f ↪ big_type K :=\n(map (adjoin_root.of_embedding K f) \n    ⟨subtype.val, subtype.val_injective⟩ \n  (λ i, cantor_injective _ (show big_type K ↪ ℕ × polynomial K,\n    from i.trans ⟨big_type_map K (@adjoin_root.of _ _ _ f ∘ of K)\n        (algebraic_comp' K _ _ (of_algebraic K) (algebraic_adjoin_root _ f)), \n      big_type_map_injective _ _ _⟩).2))\n\nlemma adjoin_root_extension_map_apply (x : algebraic_closure K) : \n  (adjoin_root_extension_map K f) (@adjoin_root.of _ _ _ f x) = x.val :=\nmap_commutes _ _ _ _\n\nlemma closure_subset_adjoin_root :\n  (closed_extension K).carrier ⊆ set.range (adjoin_root_extension_map K f) :=\n(λ x h, ⟨adjoin_root.of_embedding K f ⟨x, h⟩, \n  show (adjoin_root_extension_map K f) \n      (adjoin_root.of_embedding K f ⟨x, h⟩) = \n      (⟨x, h⟩ : algebraic_closure K).val, \n    from map_commutes _ _ _ _⟩)\n\nlemma adjoin_root_range_subset : \n  (set.range (bembedding K)) ⊆ set.range (adjoin_root_extension_map K f) :=\nset.subset.trans \n  (classical.some (exists_algebraic_closure K)).range_subset \n  (closure_subset_adjoin_root K f)\n\nlemma adjoin_root_inclusion_eq : \n  inclusion (adjoin_root_range_subset K f) = \n  (equiv.set.range _ (adjoin_root_extension_map K f).2) ∘ \n  (@adjoin_root.of (algebraic_closure K) _ _ f) ∘ \n  inclusion (classical.some (exists_algebraic_closure K)).range_subset :=\nfunext $ λ x, subtype.eq $ \n  by simp [inclusion, function.comp, adjoin_root_extension_map_apply]\n\nlemma adjoin_root_inclusion_eq' :\n  inclusion (closure_subset_adjoin_root K f) = \n  (equiv.set.range _ (adjoin_root_extension_map K f).2) ∘\n  (@adjoin_root.of (algebraic_closure K) _ _ f) :=\nfunext $ λ x, subtype.eq $ \n  by simp [inclusion, function.comp, adjoin_root_extension_map_apply]; refl\n\ninstance adjoin_root_range.discrete_field : \n  discrete_field (set.range (adjoin_root_extension_map K f)) :=\nequiv.discrete_field (equiv.set.range _ (embedding.inj _)).symm\n\ninstance adjoin_root_inclusion.is_ring_hom : \n  is_ring_hom (inclusion (adjoin_root_range_subset K f)) :=\nbegin\n  letI := (classical.some (exists_algebraic_closure K)).is_field_hom,\n  rw [adjoin_root_inclusion_eq, ← equiv.symm_symm (equiv.set.range _ _)],\n  exact @is_ring_hom.comp _ _ _ _ _ (is_ring_hom.comp _ _) _ _ _ \n    (equiv.is_ring_hom.symm _)\nend\n--set_option eqn_compiler.zeta true\n\ndef adjoin_root_lift {α : Type u} [_inst_2_1 : discrete_field α] (i : (range ⇑(bembedding K)) → α)\n  [is_field_hom i] [is_algebraically_closed α] :\n  (range ⇑(adjoin_root_extension_map K f)) → α :=\nbegin\n  have h : _ := is_algebraically_closed.exists_root \n    (f.map (lift_aux K i)) \n    (by rw degree_map; exact degree_pos_of_ne_zero_of_nonunit \n      (nonzero_of_irreducible hif) hif.1),\n  exact adjoin_root.lift (lift_aux K i) (classical.some h) (by rw [← eval_map]; \n    exact (classical.some_spec h)) ∘ \n  (equiv.set.range _ (adjoin_root_extension_map K f).2).symm\nend\n\nlemma adjoin_root_lift.is_ring_hom {α : Type u} [_inst_2_1 : discrete_field α] \n  (i : (range ⇑(bembedding K)) → α) [is_field_hom i] [is_algebraically_closed α] :\n  is_field_hom (adjoin_root_lift _ f i) :=\nbegin\n  letI := equiv.is_ring_hom.symm (equiv.set.range _ (adjoin_root_extension_map K f).2),\n  dsimp [adjoin_root_lift],\n  rw [← equiv.symm_symm (equiv.set.range _ _)],\n  exact is_ring_hom.comp _ _\nend\n\ndef adjoin_root_extension : extension K :=\n{ carrier := set.range (adjoin_root_extension_map K f),\n  range_subset := adjoin_root_range_subset _ _,\n  algebraic := begin\n    letI := (classical.some (exists_algebraic_closure K)).is_field_hom,\n    rw [adjoin_root_inclusion_eq, ← equiv.symm_symm (equiv.set.range _ _)],\n    refine @algebraic_comp' _ _ _ _ _ _ _ _ \n      (is_ring_hom.comp _ _) (by convert equiv.is_ring_hom.symm _) _ _,\n    { exact @algebraic_comp' _ _ _ _ _ \n        _ _ _ _ _ (of_algebraic_aux _) (algebraic_adjoin_root _ f) },\n    { exact algebraic_equiv _ _ }\n  end,\n  lift := @adjoin_root_lift K _ _ _,\n  lift_is_field_hom := @adjoin_root_lift.is_ring_hom K _ _ _,\n  lift_comp := begin\n    intros,\n    dsimp [adjoin_root_lift, function.comp],\n    have : inclusion (adjoin_root_range_subset K f) x =  \n      equiv.set.range _ (adjoin_root_extension_map K f).2 \n        (adjoin_root.of \n          (inclusion (classical.some (exists_algebraic_closure K)).range_subset x)),\n      by rw [adjoin_root_inclusion_eq],\n    erw [this, equiv.symm_apply_apply, adjoin_root.lift_of],\n    exactI (classical.some (exists_algebraic_closure K)).lift_comp _ _\n  end }\n\nexample : 1 + 1 = 2 := rfl\n\ninstance adjoin_root_extension.field : discrete_field (adjoin_root_extension K f).carrier := \nextension.field _\n\nlocal attribute [instance] extension.field extension.is_field_hom extension.lift_is_field_hom\n\nlemma closed_extension_le_adjoin_root_extension : \n  closed_extension K ≤ adjoin_root_extension K f :=\nby letI : discrete_field (closed_extension K).carrier := extension.field _; exact\n⟨closure_subset_adjoin_root K f, by rw [adjoin_root_inclusion_eq'];\n  exact is_ring_hom.comp _ _, begin\n  introsI,\n\nend⟩\n\ninstance : is_algebraically_closed (algebraic_closure K) :=\n⟨λ f hf0, let ⟨g, hg⟩ := is_noetherian_ring.exists_irreducible_factor \n    (show ¬ is_unit f, from λ h, by rw [is_unit_iff_degree_eq_zero] at h;\n      rw h at hf0; exact lt_irrefl _ hf0) \n    (λ h, by rw [← degree_eq_bot] at h;\n      rw h at hf0; exact absurd hf0 dec_trivial) in\n  begin\n    letI := hg.1,\n    have := classical.some_spec (exists_algebraic_closure K)\n      (adjoin_root_extension K g),\n  \n  end⟩ \n\nend adjoin_root\n\nend algebraic_closure\n", "meta": {"author": "ChrisHughes24", "repo": "leanstuff", "sha": "9efa85f72efaccd1d540385952a6acc18fce8687", "save_path": "github-repos/lean/ChrisHughes24-leanstuff", "path": "github-repos/lean/ChrisHughes24-leanstuff/leanstuff-9efa85f72efaccd1d540385952a6acc18fce8687/algebraic_closure2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125848754471, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.470853260970469}}
{"text": "import new.unordered.d\nimport algebra.homology.homological_complex\nimport algebra.category.Group.abelian\nimport algebra.homology.homology\nimport new.unordered.refinement\n\nnoncomputable theory\n\nsection\n\nopen topological_space Top Top.sheaf\nopen category_theory\nopen opposite\nopen nat\n\nopen_locale big_operators\n\nuniverse u\nvariables {X : Top.{u}} (𝓕 : sheaf Ab X) (U V : X.oc)\n\ndef d_from_to (i j : ℕ) : C 𝓕 U i ⟶ C 𝓕 U j :=\ndite (j = i + 1)\n(λ h, d 𝓕 U i ≫ eq_to_hom (by rw h))\n(λ h, 0)\n\nlemma d_to_succ {i : ℕ} (f α) :\n  d_from_to 𝓕 U i (i + 1) f α = d 𝓕 U i f α :=\nbegin\n  rw [d_from_to],\n  rw dif_pos rfl,\n  rw comp_apply,\n  refl,\nend\n\nlemma d_to_succ' (i : ℕ) :\n  d_from_to 𝓕 U i (i + 1) = d 𝓕 U i :=\nbegin\n  ext f α,\n  rw d_to_succ,\nend\n\nlemma d_not_to_succ {i j : ℕ} (h : j ≠ i + 1) (f α) :\n  d_from_to 𝓕 U i j f α = 0 :=\nbegin\n  rw [d_from_to, dif_neg h],\n  refl,\nend\n\ndef Cech_complex_wrt_cover_unordered : cochain_complex Ab.{u} ℕ :=\n{ X := λ n, C 𝓕 U (n + 1),\n  d := λ i j, d_from_to 𝓕 U (i + 1) (j + 1),\n  shape' := λ i j h, begin\n    ext f α,\n    rw d_not_to_succ,\n    rw [add_monoid_hom.zero_apply, pi.zero_apply],\n    simp only [complex_shape.up_rel] at h,\n    contrapose! h,\n    simp only [add_left_inj] at h,\n    exact h.symm,\n  end,\n  d_comp_d' := λ i j k h1 h2, begin\n    simp only [complex_shape.up_rel] at h1 h2,\n    subst' h2,\n    subst' h1,\n    ext f α,\n    rw comp_apply,\n    rw d_to_succ,\n    rw d_to_succ',\n    simp only [AddCommGroup.zero_apply, C_pre.zero_apply],\n    rw dd_eq_zero,\n  end }\n\nlemma Cech_complex_wrt_cover_unordered.d_to_rel\n  (n : ℕ) (m) (h : (complex_shape.up ℕ).prev n = some m) :\n  (Cech_complex_wrt_cover_unordered 𝓕 U).d m.1 n =\n  d 𝓕 U (m.1 + 1) ≫ eq_to_hom begin\n    have := m.2,\n    simp only [complex_shape.up_rel] at this,\n    rw this,\n    refl,\n  end :=\nbegin\n  change d_from_to 𝓕 U _ _ = _,\n  rw [d_from_to, dif_pos],\n  refl,\n  have h2 := m.2.symm,\n  rw ← h2,\nend\n\ndef Cech_Cohomology_Group_wrt_cover_unordered_nth (n : ℕ) : Ab.{u} :=\n@homological_complex.homology ℕ Ab _ _ (complex_shape.up ℕ) (abelian.has_zero_object) _ _ _\n  (Cech_complex_wrt_cover_unordered 𝓕 U) n\n\nsection\n\nvariables {U V} (r : U ⟶ V)\n\ninclude r\ndef Cech_complex_wrt_cover_unordered.prev (n : ℕ) :\n  @homological_complex.X_prev _ _ _ _ (complex_shape.up ℕ) \n    (Cech_complex_wrt_cover_unordered 𝓕 V)\n    (abelian.has_zero_object) n ⟶\n  @homological_complex.X_prev _ _ _ _ (complex_shape.up ℕ)\n    (Cech_complex_wrt_cover_unordered 𝓕 U)\n    (abelian.has_zero_object) n :=\nmatch (complex_shape.up ℕ).prev n with\n| none := 0\n| some m := begin\n  refine _ ≫ @C.refine X 𝓕 _ _ (m.1 + 1) r ≫ _,\n  refine (@@homological_complex.X_prev_iso _ _ _ (abelian.has_zero_object) m.2).hom,\n  exact (@@homological_complex.X_prev_iso _ _ (Cech_complex_wrt_cover_unordered 𝓕 U) (abelian.has_zero_object) m.2).inv,\nend\nend\n\nlemma Cech_complex_wrt_cover_unordered.prev_none (n : ℕ)\n  (h : (complex_shape.up ℕ).prev n = none) :\n  Cech_complex_wrt_cover_unordered.prev 𝓕 r n = 0 :=\nbegin\n  rw Cech_complex_wrt_cover_unordered.prev,\n  rw h,\n  refl,\nend \n\nlemma Cech_Group_wrt_cover_unordered_nth.prev_some (n : ℕ) (m)\n  (h : (complex_shape.up ℕ).prev n = some m) :\n  Cech_complex_wrt_cover_unordered.prev 𝓕 r n = \n  (@@homological_complex.X_prev_iso _ _ _ (abelian.has_zero_object) m.2).hom ≫ \n    @C.refine X 𝓕 _ _ (m.1 + 1) r ≫ \n    (@@homological_complex.X_prev_iso _ _ (Cech_complex_wrt_cover_unordered 𝓕 U) (abelian.has_zero_object) m.2).inv :=\nbegin\n  rw Cech_complex_wrt_cover_unordered.prev,\n  rw h,\n  refl,\nend  \n\nexample (n : ℕ) : (complex_shape.up ℕ).next n = some ⟨n+1, rfl⟩ :=\nbegin\n  rw [complex_shape.next_eq_some],\nend\n\ndef Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement (n : ℕ) :\n  Cech_Cohomology_Group_wrt_cover_unordered_nth 𝓕 V n ⟶\n  Cech_Cohomology_Group_wrt_cover_unordered_nth 𝓕 U n :=\nhomology.map _ _ \n{ left := Cech_complex_wrt_cover_unordered.prev 𝓕 r n,\n  right := C.refine r,\n  w' := begin\n    simp only [category_theory.functor.id_map, arrow.mk_hom],\n    ext f α,\n    rw [comp_apply, comp_apply],\n    by_cases h : (complex_shape.up ℕ).prev n = none,\n    { rw Cech_complex_wrt_cover_unordered.prev_none,\n      rw homological_complex.d_to_eq_zero,\n      rw homological_complex.d_to_eq_zero,\n      swap, exact h,\n      swap, exact h,\n      swap, exact h,\n      simp only [AddCommGroup.zero_apply, C_pre.zero_apply, map_zero], },\n    { change _ ≠ _ at h,\n      rw option.ne_none_iff_exists at h,\n      rcases h with ⟨m, hm⟩,\n      rw Cech_Group_wrt_cover_unordered_nth.prev_some,\n      swap, exact hm.symm,\n      rw homological_complex.d_to_eq,\n      swap, exact m.2,\n      rw homological_complex.d_to_eq,\n      swap, exact m.2,\n      simp only [comp_apply, coe_inv_hom_id],\n      rw Cech_complex_wrt_cover_unordered.d_to_rel,\n      swap, exact hm.symm,\n      rw Cech_complex_wrt_cover_unordered.d_to_rel,\n      swap, exact hm.symm,\n      rw comp_apply,\n      rw comp_apply,\n      rw ← C.refine_d_eq_d_refine',\n      \n      simp only [← comp_apply],\n      congr' 1,\n      simp only [category.assoc],\n      apply whisker_eq,\n      apply whisker_eq,\n      \n      rw C.refine_eq_to_hom,\n      have : _ + 1 = _ := m.2, \n      rw this, },\n  end } \n{ left := C.refine r,\n  right := (@@homological_complex.X_next_iso _ _ (Cech_complex_wrt_cover_unordered 𝓕 V) \n      (abelian.has_zero_object) \n      (rfl : n + 1 = n + 1)).hom ≫ \n      C.refine r ≫ \n      (@@homological_complex.X_next_iso _ _ (Cech_complex_wrt_cover_unordered 𝓕 U) \n        (abelian.has_zero_object) \n        (rfl : n + 1 = n + 1)).inv,\n  w' := begin\n    simp only [category_theory.functor.id_map, arrow.mk_hom],\n    ext f α,\n    simp only [comp_apply, homological_complex.d_from_comp_X_next_iso_assoc],\n    rw homological_complex.d_from_eq,\n    swap 2, exact (rfl : n + 1 = n + 1),\n    simp only [← comp_apply],\n    congr' 1,\n    simp only [← category.assoc],\n    apply eq_whisker,\n    change C.refine r ≫ d_from_to 𝓕 U _ _ = _,\n    rw d_to_succ',\n    change _ = d_from_to _ _ _ _ ≫ C.refine r,\n    rw d_to_succ',\n    rw C.refine_d_eq_d_refine,\n  end } \nrfl\n\ndef Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement_functor (n : ℕ) :\n  X.ocᵒᵖ ⥤ Ab.{u} :=\n{ obj := λ U, Cech_Cohomology_Group_wrt_cover_unordered_nth 𝓕 U.unop n,\n  map := λ U V r, Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement 𝓕 r.unop n,\n  map_id' := λ U, begin\n    rw [Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement],\n    ext f,\n    simp only [unop_id, homology.π_map, comp_apply, id_apply],\n    congr',\n    sorry\n  end,\n  map_comp' := sorry }\n\ninclude 𝓕\ndef Cech_Cohomology_Group_nth (n : ℕ) : Ab :=\nlimits.colim.obj $ (Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement_functor 𝓕 r n) ⋙ AddCommGroup.ulift_functor.{u u+1}\n\nend\n\nend", "meta": {"author": "jjaassoonn", "repo": "cc", "sha": "6d3dc6885fa012e8c18fd38ab2949d73777fb442", "save_path": "github-repos/lean/jjaassoonn-cc", "path": "github-repos/lean/jjaassoonn-cc/cc-6d3dc6885fa012e8c18fd38ab2949d73777fb442/src/new/unordered/chain.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.47085325401069184}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes Hölzl\n\nLinear structures on function with finite support `ι →₀ β`.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.mv_polynomial.default\nimport Mathlib.linear_algebra.dimension\nimport Mathlib.linear_algebra.direct_sum.finsupp\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 u v w \n\nnamespace Mathlib\n\nnamespace finsupp\n\n\ntheorem linear_independent_single {R : Type u_1} {M : Type u_2} {ι : Type u_3} [ring R] [add_comm_group M] [module R M] {φ : ι → Type u_4} {f : (ι : ι) → φ ι → M} (hf : ∀ (i : ι), linear_independent R (f i)) : linear_independent R fun (ix : sigma fun (i : ι) => φ i) => single (sigma.fst ix) (f (sigma.fst ix) (sigma.snd ix)) := sorry\n\ntheorem is_basis_single {R : Type u_1} {M : Type u_2} {ι : Type u_3} [ring R] [add_comm_group M] [module R M] {φ : ι → Type u_4} (f : (ι : ι) → φ ι → M) (hf : ∀ (i : ι), is_basis R (f i)) : is_basis R fun (ix : sigma fun (i : ι) => φ i) => single (sigma.fst ix) (f (sigma.fst ix) (sigma.snd ix)) := sorry\n\ntheorem is_basis_single_one {R : Type u_1} {ι : Type u_3} [ring R] : is_basis R fun (i : ι) => single i 1 := sorry\n\n/-- If b : ι → M and c : κ → N are bases then so is λ i, b i.1 ⊗ₜ c i.2 : ι × κ → M ⊗ N. -/\ntheorem is_basis.tensor_product {R : Type u_1} {M : Type u_2} {N : Type u_3} {ι : Type u_4} {κ : Type u_5} [comm_ring R] [add_comm_group M] [module R M] [add_comm_group N] [module R N] {b : ι → M} (hb : is_basis R b) {c : κ → N} (hc : is_basis R c) : is_basis R fun (i : ι × κ) => tensor_product.tmul R (b (prod.fst i)) (c (prod.snd i)) := sorry\n\ntheorem dim_eq {K : Type u} {V : Type v} {ι : Type v} [field K] [add_comm_group V] [vector_space K V] : vector_space.dim K (ι →₀ V) = cardinal.mk ι * vector_space.dim K V := sorry\n\nend finsupp\n\n\n/- We use `universe variables` instead of `universes` here because universes introduced by the\n   `universes` keyword do not get replaced by metavariables once a lemma has been proven. So if you\n   prove a lemma using universe `u`, you can only apply it to universe `u` in other lemmas of the\n   same section. -/\n\ntheorem equiv_of_dim_eq_lift_dim {K : Type u} {V : Type v} {V' : Type w} [field K] [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V'] (h : cardinal.lift (vector_space.dim K V) = cardinal.lift (vector_space.dim K V')) : Nonempty (linear_equiv K V V') := sorry\n\n/-- Two `K`-vector spaces are equivalent if their dimension is the same. -/\ndef equiv_of_dim_eq_dim {K : Type u} {V₁ : Type v} {V₂ : Type v} [field K] [add_comm_group V₁] [vector_space K V₁] [add_comm_group V₂] [vector_space K V₂] (h : vector_space.dim K V₁ = vector_space.dim K V₂) : linear_equiv K V₁ V₂ :=\n  Classical.choice sorry\n\n/-- An `n`-dimensional `K`-vector space is equivalent to `fin n → K`. -/\ndef fin_dim_vectorspace_equiv {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] (n : ℕ) (hn : vector_space.dim K V = ↑n) : linear_equiv K V (fin n → K) :=\n  Classical.choice sorry\n\ntheorem eq_bot_iff_dim_eq_zero {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] (p : submodule K V) (h : vector_space.dim K ↥p = 0) : p = ⊥ :=\n  let e : linear_equiv K ↥p ↥⊥ :=\n    equiv_of_dim_eq_dim (eq.mpr (id (Eq._oldrec (Eq.refl (vector_space.dim K ↥p = vector_space.dim K ↥⊥)) dim_bot)) h);\n  linear_equiv.eq_bot_of_equiv p e\n\ntheorem injective_of_surjective {K : Type u} {V₁ : Type v} {V₂ : Type v} [field K] [add_comm_group V₁] [vector_space K V₁] [add_comm_group V₂] [vector_space K V₂] (f : linear_map K V₁ V₂) (hV₁ : vector_space.dim K V₁ < cardinal.omega) (heq : vector_space.dim K V₂ = vector_space.dim K V₁) (hf : linear_map.range f = ⊤) : linear_map.ker f = ⊥ := sorry\n\ntheorem cardinal_mk_eq_cardinal_mk_field_pow_dim {K : Type u} {V : Type u} [field K] [add_comm_group V] [vector_space K V] (h : vector_space.dim K V < cardinal.omega) : cardinal.mk V = cardinal.mk K ^ vector_space.dim K V := sorry\n\ntheorem cardinal_lt_omega_of_dim_lt_omega {K : Type u} {V : Type u} [field K] [add_comm_group V] [vector_space K V] [fintype K] (h : vector_space.dim K V < cardinal.omega) : cardinal.mk V < cardinal.omega :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (cardinal.mk V < cardinal.omega)) (cardinal_mk_eq_cardinal_mk_field_pow_dim h)))\n    (cardinal.power_lt_omega (iff.mpr cardinal.lt_omega_iff_fintype (Nonempty.intro infer_instance)) h)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/finsupp_vector_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597971, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.4708532435178514}}
{"text": "/-\nCopyright (c) 2019 Seul Baek. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Seul Baek\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.omega.prove_unsats\nimport Mathlib.tactic.omega.int.dnf\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-\nMain procedure for linear integer arithmetic.\n-/\n\nnamespace omega\n\n\nnamespace int\n\n\ntheorem univ_close_of_unsat_clausify (m : ℕ) (p : preform) : clauses.unsat (dnf (preform.not p)) → univ_close p (fun (x : ℕ) => 0) m :=\n  fun (ᾰ : clauses.unsat (dnf (preform.not p))) =>\n    idRhs (univ_close p (fun (x : ℕ) => 0) m) (univ_close_of_valid (valid_of_unsat_not (unsat_of_clauses_unsat ᾰ)))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/omega/int/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8152324803738429, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.47079297896482747}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n\n! This file was ported from Lean 3 source module linear_algebra.affine_space.affine_equiv\n! leanprover-community/mathlib commit 97eab48559068f3d6313da387714ef25768fb730\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.AffineSpace.AffineMap\nimport Mathbin.LinearAlgebra.GeneralLinearGroup\nimport Mathbin.Algebra.Invertible\n\n/-!\n# Affine equivalences\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we define `affine_equiv k P₁ P₂` (notation: `P₁ ≃ᵃ[k] P₂`) to be the type of affine\nequivalences between `P₁` and `P₂, i.e., equivalences such that both forward and inverse maps are\naffine maps.\n\nWe define the following equivalences:\n\n* `affine_equiv.refl k P`: the identity map as an `affine_equiv`;\n\n* `e.symm`: the inverse map of an `affine_equiv` as an `affine_equiv`;\n\n* `e.trans e'`: composition of two `affine_equiv`s; note that the order follows `mathlib`'s\n  `category_theory` convention (apply `e`, then `e'`), not the convention used in function\n  composition and compositions of bundled morphisms.\n\nWe equip `affine_equiv k P P` with a `group` structure with multiplication corresponding to\ncomposition in `affine_equiv.group`.\n\n## Tags\n\naffine space, affine equivalence\n-/\n\n\nopen Function Set\n\nopen Affine\n\n#print AffineEquiv /-\n/-- An affine equivalence is an equivalence between affine spaces such that both forward\nand inverse maps are affine.\n\nWe define it using an `equiv` for the map and a `linear_equiv` for the linear part in order\nto allow affine equivalences with good definitional equalities. -/\n@[nolint has_nonempty_instance]\nstructure AffineEquiv (k P₁ P₂ : Type _) {V₁ V₂ : Type _} [Ring k] [AddCommGroup V₁] [Module k V₁]\n  [AddTorsor V₁ P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] extends P₁ ≃ P₂ where\n  linear : V₁ ≃ₗ[k] V₂\n  map_vadd' : ∀ (p : P₁) (v : V₁), to_equiv (v +ᵥ p) = linear v +ᵥ to_equiv p\n#align affine_equiv AffineEquiv\n-/\n\n-- mathport name: «expr ≃ᵃ[ ] »\nnotation:25 P₁ \" ≃ᵃ[\" k:25 \"] \" P₂:0 => AffineEquiv k P₁ P₂\n\nvariable {k P₁ P₂ P₃ P₄ V₁ V₂ V₃ V₄ : Type _} [Ring k] [AddCommGroup V₁] [Module k V₁]\n  [AddTorsor V₁ P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [AddCommGroup V₃]\n  [Module k V₃] [AddTorsor V₃ P₃] [AddCommGroup V₄] [Module k V₄] [AddTorsor V₄ P₄]\n\nnamespace AffineEquiv\n\ninclude V₁ V₂\n\n#print AffineEquiv.toAffineMap /-\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef toAffineMap (e : P₁ ≃ᵃ[k] P₂) : P₁ →ᵃ[k] P₂ :=\n  { e with }\n#align affine_equiv.to_affine_map AffineEquiv.toAffineMap\n-/\n\n/- warning: affine_equiv.to_affine_map_mk -> AffineEquiv.toAffineMap_mk is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (f : Equiv.{succ u2, succ u3} P₁ P₂) (f' : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (h : forall (p : P₁) (v : V₁), Eq.{succ u3} P₂ (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) f (VAdd.vadd.{u4, u2} V₁ P₁ (AddAction.toHasVadd.{u4, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u4} V₁ (AddGroup.toSubNegMonoid.{u4} V₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2))) (AddTorsor.toAddAction.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4)) v p)) (VAdd.vadd.{u5, u3} V₂ P₂ (AddAction.toHasVadd.{u5, u3} V₂ P₂ (SubNegMonoid.toAddMonoid.{u5} V₂ (AddGroup.toSubNegMonoid.{u5} V₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5))) (AddTorsor.toAddAction.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5) _inst_7)) (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (fun (_x : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) => V₁ -> V₂) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1))) f' v) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) f p))), Eq.{max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f f' h)) (AffineMap.mk.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) f) ((fun (a : Sort.{max (succ u4) (succ u5)}) (b : Sort.{max (succ u4) (succ u5)}) [self : HasLiftT.{max (succ u4) (succ u5), max (succ u4) (succ u5)} a b] => self.0) (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (HasLiftT.mk.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (CoeTCₓ.coe.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (coeBase.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearEquiv.LinearMap.hasCoe.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)))))) f') h)\nbut is expected to have type\n  forall {k : Type.{u3}} {P₁ : Type.{u5}} {P₂ : Type.{u4}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (f : Equiv.{succ u5, succ u4} P₁ P₂) (f' : LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (h : forall (p : P₁) (v : V₁), Eq.{succ u4} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) (HVAdd.hVAdd.{u2, u5, u5} V₁ P₁ P₁ (instHVAdd.{u2, u5} V₁ P₁ (AddAction.toVAdd.{u2, u5} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) f (HVAdd.hVAdd.{u2, u5, u5} V₁ P₁ P₁ (instHVAdd.{u2, u5} V₁ P₁ (AddAction.toVAdd.{u2, u5} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p)) (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) _inst_5) _inst_7))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) V₁ (fun (_x : V₁) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) _x) (SMulHomClass.toFunLike.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (SMulZeroClass.toSMul.{u3, u2} k V₁ (AddMonoid.toZero.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V₁ (AddMonoid.toAddZeroClass.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V₁ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V₂ (AddMonoid.toZero.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V₂ (AddMonoid.toAddZeroClass.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6)))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u3, u3, u2, u1} k k V₁ V₂ (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1))))))) f' v) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) f p))), Eq.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1)} (AffineMap.{u3, u2, u5, u1, u4} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f f' h)) (AffineMap.mk.{u3, u2, u5, u1, u4} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) f) (LinearEquiv.toLinearMap.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 f') h)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_affine_map_mk AffineEquiv.toAffineMap_mkₓ'. -/\n@[simp]\ntheorem toAffineMap_mk (f : P₁ ≃ P₂) (f' : V₁ ≃ₗ[k] V₂) (h) :\n    toAffineMap (mk f f' h) = ⟨f, f', h⟩ :=\n  rfl\n#align affine_equiv.to_affine_map_mk AffineEquiv.toAffineMap_mk\n\n/- warning: affine_equiv.linear_to_affine_map -> AffineEquiv.linear_toAffineMap is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u5)} (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) ((fun (a : Sort.{max (succ u4) (succ u5)}) (b : Sort.{max (succ u4) (succ u5)}) [self : HasLiftT.{max (succ u4) (succ u5), max (succ u4) (succ u5)} a b] => self.0) (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (HasLiftT.mk.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (CoeTCₓ.coe.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (coeBase.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearEquiv.LinearMap.hasCoe.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)))))) (AffineEquiv.linear.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u1)} (LinearMap.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u5, u2, u4, u1, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (LinearEquiv.toLinearMap.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (AffineEquiv.linear.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.linear_to_affine_map AffineEquiv.linear_toAffineMapₓ'. -/\n@[simp]\ntheorem linear_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : e.toAffineMap.linear = e.linear :=\n  rfl\n#align affine_equiv.linear_to_affine_map AffineEquiv.linear_toAffineMap\n\n/- warning: affine_equiv.to_affine_map_injective -> AffineEquiv.toAffineMap_injective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)], Function.Injective.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u5}} {P₂ : Type.{u4}} {V₁ : Type.{u3}} {V₂ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u2} V₂] [_inst_6 : Module.{u1, u2} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_5)] [_inst_7 : AddTorsor.{u2, u4} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_5)], Function.Injective.{max (max (max (succ u5) (succ u4)) (succ u3)) (succ u2), max (max (max (succ u5) (succ u4)) (succ u3)) (succ u2)} (AffineEquiv.{u1, u5, u4, u3, u2} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u3, u5, u2, u4} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u5, u4, u3, u2} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_affine_map_injective AffineEquiv.toAffineMap_injectiveₓ'. -/\ntheorem toAffineMap_injective : Injective (toAffineMap : (P₁ ≃ᵃ[k] P₂) → P₁ →ᵃ[k] P₂) :=\n  by\n  rintro ⟨e, el, h⟩ ⟨e', el', h'⟩ H\n  simp only [to_affine_map_mk, Equiv.coe_inj, LinearEquiv.toLinearMap_inj] at H\n  congr\n  exacts[H.1, H.2]\n#align affine_equiv.to_affine_map_injective AffineEquiv.toAffineMap_injective\n\n/- warning: affine_equiv.to_affine_map_inj -> AffineEquiv.toAffineMap_inj is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, Iff (Eq.{max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e')) (Eq.{max (succ u2) (succ u3) (succ u4) (succ u5)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, Iff (Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (AffineMap.{u5, u2, u4, u1, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e')) (Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_affine_map_inj AffineEquiv.toAffineMap_injₓ'. -/\n@[simp]\ntheorem toAffineMap_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.toAffineMap = e'.toAffineMap ↔ e = e' :=\n  toAffineMap_injective.eq_iff\n#align affine_equiv.to_affine_map_inj AffineEquiv.toAffineMap_inj\n\n#print AffineEquiv.equivLike /-\ninstance equivLike : EquivLike (P₁ ≃ᵃ[k] P₂) P₁ P₂\n    where\n  coe f := f.toFun\n  inv f := f.invFun\n  left_inv f := f.left_inv\n  right_inv f := f.right_inv\n  coe_injective' f g h _ := toAffineMap_injective (FunLike.coe_injective h)\n#align affine_equiv.equiv_like AffineEquiv.equivLike\n-/\n\ninstance : CoeFun (P₁ ≃ᵃ[k] P₂) fun _ => P₁ → P₂ :=\n  FunLike.hasCoeToFun\n\ninstance : Coe (P₁ ≃ᵃ[k] P₂) (P₁ ≃ P₂) :=\n  ⟨AffineEquiv.toEquiv⟩\n\nvariable {k P₁}\n\n/- warning: affine_equiv.map_vadd -> AffineEquiv.map_vadd is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P₁) (v : V₁), Eq.{succ u3} P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e (VAdd.vadd.{u4, u2} V₁ P₁ (AddAction.toHasVadd.{u4, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u4} V₁ (AddGroup.toSubNegMonoid.{u4} V₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2))) (AddTorsor.toAddAction.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4)) v p)) (VAdd.vadd.{u5, u3} V₂ P₂ (AddAction.toHasVadd.{u5, u3} V₂ P₂ (SubNegMonoid.toAddMonoid.{u5} V₂ (AddGroup.toSubNegMonoid.{u5} V₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5))) (AddTorsor.toAddAction.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5) _inst_7)) (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (fun (_x : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) => V₁ -> V₂) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.linear.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) v) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p))\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P₁) (v : V₁), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) (HVAdd.hVAdd.{u2, u4, u4} V₁ P₁ P₁ (instHVAdd.{u2, u4} V₁ P₁ (AddAction.toVAdd.{u2, u4} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e (HVAdd.hVAdd.{u2, u4, u4} V₁ P₁ P₁ (instHVAdd.{u2, u4} V₁ P₁ (AddAction.toVAdd.{u2, u4} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p)) (HVAdd.hVAdd.{u1, u3, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p) (instHVAdd.{u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p) (AddAction.toVAdd.{u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p) (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) _inst_5))) (AddTorsor.toAddAction.{u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) _inst_5) _inst_7))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearEquiv.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) V₁ (fun (_x : V₁) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) _x) (SMulHomClass.toFunLike.{max u2 u1, u5, u2, u1} (LinearEquiv.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (SMulZeroClass.toSMul.{u5, u2} k V₁ (AddMonoid.toZero.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribSMul.toSMulZeroClass.{u5, u2} k V₁ (AddMonoid.toAddZeroClass.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribMulAction.toDistribSMul.{u5, u2} k V₁ (MonoidWithZero.toMonoid.{u5} k (Semiring.toMonoidWithZero.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (Module.toDistribMulAction.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u5, u1} k V₂ (AddMonoid.toZero.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribSMul.toSMulZeroClass.{u5, u1} k V₂ (AddMonoid.toAddZeroClass.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribMulAction.toDistribSMul.{u5, u1} k V₂ (MonoidWithZero.toMonoid.{u5} k (Semiring.toMonoidWithZero.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6)))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u5, u2, u1} (LinearEquiv.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (MonoidWithZero.toMonoid.{u5} k (Semiring.toMonoidWithZero.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3) (Module.toDistribMulAction.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u5, u2, u1, max u2 u1} k V₁ V₂ (LinearEquiv.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u5, u5, u2, u1, max u2 u1} k k V₁ V₂ (LinearEquiv.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u5, u5, u2, u1} k k V₁ V₂ (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1))))))) (AffineEquiv.linear.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) v) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.map_vadd AffineEquiv.map_vaddₓ'. -/\n@[simp]\ntheorem map_vadd (e : P₁ ≃ᵃ[k] P₂) (p : P₁) (v : V₁) : e (v +ᵥ p) = e.linear v +ᵥ e p :=\n  e.map_vadd' p v\n#align affine_equiv.map_vadd AffineEquiv.map_vadd\n\n/- warning: affine_equiv.coe_to_equiv -> AffineEquiv.coe_toEquiv is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (P₁ -> P₂) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (forall (ᾰ : P₁), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) ᾰ) (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (Equiv.{succ u4, succ u3} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u4, succ u3} P₁ P₂) (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_to_equiv AffineEquiv.coe_toEquivₓ'. -/\n@[simp]\ntheorem coe_toEquiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.toEquiv = e :=\n  rfl\n#align affine_equiv.coe_to_equiv AffineEquiv.coe_toEquiv\n\ninstance : Coe (P₁ ≃ᵃ[k] P₂) (P₁ →ᵃ[k] P₂) :=\n  ⟨toAffineMap⟩\n\n/- warning: affine_equiv.coe_to_affine_map -> AffineEquiv.coe_toAffineMap is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} ((fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (coeFn.{max (succ u4) (succ u2) (succ u5) (succ u3), max (succ u2) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (forall (a : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) a) (FunLike.coe.{max (max (max (succ u2) (succ u4)) (succ u1)) (succ u3), succ u4, succ u3} (AffineMap.{u5, u2, u4, u1, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) _x) (AffineMap.funLike.{u5, u2, u4, u1, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_to_affine_map AffineEquiv.coe_toAffineMapₓ'. -/\n@[simp]\ntheorem coe_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : (e.toAffineMap : P₁ → P₂) = (e : P₁ → P₂) :=\n  rfl\n#align affine_equiv.coe_to_affine_map AffineEquiv.coe_toAffineMap\n\n/- warning: affine_equiv.coe_coe -> AffineEquiv.coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} ((fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) ((fun (a : Sort.{max (succ u2) (succ u3) (succ u4) (succ u5)}) (b : Sort.{max (succ u4) (succ u2) (succ u5) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} a b] => self.0) (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (HasLiftT.mk.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTCₓ.coe.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (coeBase.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)))) e)) (coeFn.{max (succ u4) (succ u2) (succ u5) (succ u3), max (succ u2) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) ((fun (a : Sort.{max (succ u2) (succ u3) (succ u4) (succ u5)}) (b : Sort.{max (succ u4) (succ u2) (succ u5) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} a b] => self.0) (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (HasLiftT.mk.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTCₓ.coe.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (coeBase.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)))) e)) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (forall (a : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) a) (FunLike.coe.{max (max (max (succ u2) (succ u4)) (succ u1)) (succ u3), succ u4, succ u3} (AffineMap.{u5, u2, u4, u1, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) _x) (AffineMap.funLike.{u5, u2, u4, u1, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_coe AffineEquiv.coe_coeₓ'. -/\n@[norm_cast, simp]\ntheorem coe_coe (e : P₁ ≃ᵃ[k] P₂) : ((e : P₁ →ᵃ[k] P₂) : P₁ → P₂) = e :=\n  rfl\n#align affine_equiv.coe_coe AffineEquiv.coe_coe\n\n/- warning: affine_equiv.coe_linear -> AffineEquiv.coe_linear is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u5)} (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 ((fun (a : Sort.{max (succ u2) (succ u3) (succ u4) (succ u5)}) (b : Sort.{max (succ u4) (succ u2) (succ u5) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} a b] => self.0) (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (HasLiftT.mk.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTCₓ.coe.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (coeBase.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)))) e)) ((fun (a : Sort.{max (succ u4) (succ u5)}) (b : Sort.{max (succ u4) (succ u5)}) [self : HasLiftT.{max (succ u4) (succ u5), max (succ u4) (succ u5)} a b] => self.0) (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (HasLiftT.mk.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (CoeTCₓ.coe.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (coeBase.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearMap.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (LinearEquiv.LinearMap.hasCoe.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)))))) (AffineEquiv.linear.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u1)} (LinearMap.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u5, u2, u4, u1, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (LinearEquiv.toLinearMap.{u5, u5, u2, u1} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (AffineEquiv.linear.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_linear AffineEquiv.coe_linearₓ'. -/\n@[simp]\ntheorem coe_linear (e : P₁ ≃ᵃ[k] P₂) : (e : P₁ →ᵃ[k] P₂).linear = e.linear :=\n  rfl\n#align affine_equiv.coe_linear AffineEquiv.coe_linear\n\n/- warning: affine_equiv.ext -> AffineEquiv.ext is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, (forall (x : P₁), Eq.{succ u3} P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e x) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e' x)) -> (Eq.{max (succ u2) (succ u3) (succ u4) (succ u5)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, (forall (x : P₁), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) x) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e x) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e' x)) -> (Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nCase conversion may be inaccurate. Consider using '#align affine_equiv.ext AffineEquiv.extₓ'. -/\n@[ext]\ntheorem ext {e e' : P₁ ≃ᵃ[k] P₂} (h : ∀ x, e x = e' x) : e = e' :=\n  FunLike.ext _ _ h\n#align affine_equiv.ext AffineEquiv.ext\n\n#print AffineEquiv.coeFn_injective /-\ntheorem coeFn_injective : @Injective (P₁ ≃ᵃ[k] P₂) (P₁ → P₂) coeFn :=\n  FunLike.coe_injective\n#align affine_equiv.coe_fn_injective AffineEquiv.coeFn_injective\n-/\n\n/- warning: affine_equiv.coe_fn_inj -> AffineEquiv.coeFn_inj is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, Iff (Eq.{max (succ u2) (succ u3)} ((fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) e) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e')) (Eq.{max (succ u2) (succ u3) (succ u4) (succ u5)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, Iff (Eq.{max (succ u4) (succ u3)} (forall (a : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) a) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e')) (Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_fn_inj AffineEquiv.coeFn_injₓ'. -/\n@[simp, norm_cast]\ntheorem coeFn_inj {e e' : P₁ ≃ᵃ[k] P₂} : (e : P₁ → P₂) = e' ↔ e = e' :=\n  coeFn_injective.eq_iff\n#align affine_equiv.coe_fn_inj AffineEquiv.coeFn_inj\n\n/- warning: affine_equiv.to_equiv_injective -> AffineEquiv.toEquiv_injective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)], Function.Injective.{max (succ u2) (succ u3) (succ u4) (succ u5), max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (Equiv.{succ u2, succ u3} P₁ P₂) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u5}} {P₂ : Type.{u4}} {V₁ : Type.{u3}} {V₂ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u2} V₂] [_inst_6 : Module.{u1, u2} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_5)] [_inst_7 : AddTorsor.{u2, u4} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_5)], Function.Injective.{max (max (max (succ u5) (succ u4)) (succ u3)) (succ u2), max (succ u5) (succ u4)} (AffineEquiv.{u1, u5, u4, u3, u2} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (Equiv.{succ u5, succ u4} P₁ P₂) (AffineEquiv.toEquiv.{u1, u5, u4, u3, u2} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_equiv_injective AffineEquiv.toEquiv_injectiveₓ'. -/\ntheorem toEquiv_injective : Injective (toEquiv : (P₁ ≃ᵃ[k] P₂) → P₁ ≃ P₂) := fun e e' H =>\n  ext <| Equiv.ext_iff.1 H\n#align affine_equiv.to_equiv_injective AffineEquiv.toEquiv_injective\n\n/- warning: affine_equiv.to_equiv_inj -> AffineEquiv.toEquiv_inj is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, Iff (Eq.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2)} (Equiv.{succ u2, succ u3} P₁ P₂) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e')) (Eq.{max (succ u2) (succ u3) (succ u4) (succ u5)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, Iff (Eq.{max (succ u4) (succ u3)} (Equiv.{succ u4, succ u3} P₁ P₂) (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e')) (Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e e')\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_equiv_inj AffineEquiv.toEquiv_injₓ'. -/\n@[simp]\ntheorem toEquiv_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.toEquiv = e'.toEquiv ↔ e = e' :=\n  toEquiv_injective.eq_iff\n#align affine_equiv.to_equiv_inj AffineEquiv.toEquiv_inj\n\n/- warning: affine_equiv.coe_mk -> AffineEquiv.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : Equiv.{succ u2, succ u3} P₁ P₂) (e' : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (h : forall (p : P₁) (v : V₁), Eq.{succ u3} P₂ (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e (VAdd.vadd.{u4, u2} V₁ P₁ (AddAction.toHasVadd.{u4, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u4} V₁ (AddGroup.toSubNegMonoid.{u4} V₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2))) (AddTorsor.toAddAction.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4)) v p)) (VAdd.vadd.{u5, u3} V₂ P₂ (AddAction.toHasVadd.{u5, u3} V₂ P₂ (SubNegMonoid.toAddMonoid.{u5} V₂ (AddGroup.toSubNegMonoid.{u5} V₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5))) (AddTorsor.toAddAction.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5) _inst_7)) (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (fun (_x : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) => V₁ -> V₂) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1))) e' v) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e p))), Eq.{max (succ u2) (succ u3)} ((fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.mk.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e e' h)) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.mk.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e e' h)) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e)\nbut is expected to have type\n  forall {k : Type.{u3}} {P₁ : Type.{u5}} {P₂ : Type.{u4}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : Equiv.{succ u5, succ u4} P₁ P₂) (e' : LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (h : forall (p : P₁) (v : V₁), Eq.{succ u4} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) (HVAdd.hVAdd.{u2, u5, u5} V₁ P₁ P₁ (instHVAdd.{u2, u5} V₁ P₁ (AddAction.toVAdd.{u2, u5} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e (HVAdd.hVAdd.{u2, u5, u5} V₁ P₁ P₁ (instHVAdd.{u2, u5} V₁ P₁ (AddAction.toVAdd.{u2, u5} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p)) (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) p) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) v) _inst_5) _inst_7))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) V₁ (fun (_x : V₁) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) _x) (SMulHomClass.toFunLike.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (SMulZeroClass.toSMul.{u3, u2} k V₁ (AddMonoid.toZero.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V₁ (AddMonoid.toAddZeroClass.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V₁ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V₂ (AddMonoid.toZero.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V₂ (AddMonoid.toAddZeroClass.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6)))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u3, u3, u2, u1} k k V₁ V₂ (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1))))))) e' v) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e p))), Eq.{max (succ u5) (succ u4)} (forall (a : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) a) (FunLike.coe.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1), succ u5, succ u4} (AffineEquiv.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1), succ u5, succ u4} (AffineEquiv.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1), succ u5, succ u4} (AffineEquiv.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) (AffineEquiv.mk.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e e' h)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_mk AffineEquiv.coe_mkₓ'. -/\n@[simp]\ntheorem coe_mk (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (h) : ((⟨e, e', h⟩ : P₁ ≃ᵃ[k] P₂) : P₁ → P₂) = e :=\n  rfl\n#align affine_equiv.coe_mk AffineEquiv.coe_mk\n\n/- warning: affine_equiv.mk' -> AffineEquiv.mk' is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : P₁ -> P₂) (e' : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_1.{u1} k _inst_1) (AffineEquiv.mk'._proof_2.{u1} k _inst_1) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (p : P₁), (forall (p' : P₁), Eq.{succ u3} P₂ (e p') (VAdd.vadd.{u5, u3} V₂ P₂ (AddAction.toHasVadd.{u5, u3} V₂ P₂ (SubNegMonoid.toAddMonoid.{u5} V₂ (AddGroup.toSubNegMonoid.{u5} V₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5))) (AddTorsor.toAddAction.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5) _inst_7)) (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_3.{u1} k _inst_1) (AffineEquiv.mk'._proof_4.{u1} k _inst_1) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (fun (_x : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_3.{u1} k _inst_1) (AffineEquiv.mk'._proof_4.{u1} k _inst_1) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) => V₁ -> V₂) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_5.{u1} k _inst_1) (AffineEquiv.mk'._proof_6.{u1} k _inst_1)) e' (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toHasVsub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) (e p))) -> (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : P₁ -> P₂) (e' : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (p : P₁), (forall (p' : P₁), Eq.{succ u3} P₂ (e p') (HVAdd.hVAdd.{u5, u3, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) P₂ P₂ (instHVAdd.{u5, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) P₂ (AddAction.toVAdd.{u5, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) P₂ (SubNegMonoid.toAddMonoid.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) (AddGroup.toSubNegMonoid.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) (AddCommGroup.toAddGroup.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) _inst_5))) (AddTorsor.toAddAction.{u5, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) P₂ (AddCommGroup.toAddGroup.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) _inst_5) _inst_7))) (FunLike.coe.{max (succ u4) (succ u5), succ u4, succ u5} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) V₁ (fun (_x : V₁) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) _x) (SMulHomClass.toFunLike.{max u4 u5, u1, u4, u5} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (SMulZeroClass.toSMul.{u1, u4} k V₁ (AddMonoid.toZero.{u4} V₁ (AddCommMonoid.toAddMonoid.{u4} V₁ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2))) (DistribSMul.toSMulZeroClass.{u1, u4} k V₁ (AddMonoid.toAddZeroClass.{u4} V₁ (AddCommMonoid.toAddMonoid.{u4} V₁ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2))) (DistribMulAction.toDistribSMul.{u1, u4} k V₁ (MonoidWithZero.toMonoid.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AddCommMonoid.toAddMonoid.{u4} V₁ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)) (Module.toDistribMulAction.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u1, u5} k V₂ (AddMonoid.toZero.{u5} V₂ (AddCommMonoid.toAddMonoid.{u5} V₂ (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5))) (DistribSMul.toSMulZeroClass.{u1, u5} k V₂ (AddMonoid.toAddZeroClass.{u5} V₂ (AddCommMonoid.toAddMonoid.{u5} V₂ (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5))) (DistribMulAction.toDistribSMul.{u1, u5} k V₂ (MonoidWithZero.toMonoid.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AddCommMonoid.toAddMonoid.{u5} V₂ (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)) (Module.toDistribMulAction.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_6)))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u5, u1, u4, u5} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (MonoidWithZero.toMonoid.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AddCommMonoid.toAddMonoid.{u4} V₁ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)) (AddCommMonoid.toAddMonoid.{u5} V₂ (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)) (Module.toDistribMulAction.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_3) (Module.toDistribMulAction.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u1, u4, u5, max u4 u5} k V₁ V₂ (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u1, u1, u4, u5, max u4 u5} k k V₁ V₂ (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1))))))) e' (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toVSub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) (e p))) -> (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.mk' AffineEquiv.mk'ₓ'. -/\n/-- Construct an affine equivalence by verifying the relation between the map and its linear part at\none base point. Namely, this function takes a map `e : P₁ → P₂`, a linear equivalence\n`e' : V₁ ≃ₗ[k] V₂`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/\ndef mk' (e : P₁ → P₂) (e' : V₁ ≃ₗ[k] V₂) (p : P₁) (h : ∀ p' : P₁, e p' = e' (p' -ᵥ p) +ᵥ e p) :\n    P₁ ≃ᵃ[k] P₂ where\n  toFun := e\n  invFun := fun q' : P₂ => e'.symm (q' -ᵥ e p) +ᵥ p\n  left_inv p' := by simp [h p']\n  right_inv q' := by simp [h (e'.symm (q' -ᵥ e p) +ᵥ p)]\n  linear := e'\n  map_vadd' p' v := by simp [h p', h (v +ᵥ p'), vadd_vsub_assoc, vadd_vadd]\n#align affine_equiv.mk' AffineEquiv.mk'\n\n/- warning: affine_equiv.coe_mk' -> AffineEquiv.coe_mk' is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : Equiv.{succ u2, succ u3} P₁ P₂) (e' : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (p : P₁) (h : forall (p' : P₁), Eq.{succ u3} P₂ (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e p') (VAdd.vadd.{u5, u3} V₂ P₂ (AddAction.toHasVadd.{u5, u3} V₂ P₂ (SubNegMonoid.toAddMonoid.{u5} V₂ (AddGroup.toSubNegMonoid.{u5} V₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5))) (AddTorsor.toAddAction.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5) _inst_7)) (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_3.{u1} k _inst_1) (AffineEquiv.mk'._proof_4.{u1} k _inst_1) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (fun (_x : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_3.{u1} k _inst_1) (AffineEquiv.mk'._proof_4.{u1} k _inst_1) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) => V₁ -> V₂) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_5.{u1} k _inst_1) (AffineEquiv.mk'._proof_6.{u1} k _inst_1)) e' (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toHasVsub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e p))), Eq.{max (succ u2) (succ u3)} (P₁ -> P₂) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.mk'.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e) e' p h)) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e)\nbut is expected to have type\n  forall {k : Type.{u3}} {P₁ : Type.{u5}} {P₂ : Type.{u4}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : Equiv.{succ u5, succ u4} P₁ P₂) (e' : LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (p : P₁) (h : forall (p' : P₁), Eq.{succ u4} P₂ (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e p') (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ P₂ (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) _inst_5) _inst_7))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) V₁ (fun (_x : V₁) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) _x) (SMulHomClass.toFunLike.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (SMulZeroClass.toSMul.{u3, u2} k V₁ (AddMonoid.toZero.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V₁ (AddMonoid.toAddZeroClass.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V₁ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V₂ (AddMonoid.toZero.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V₂ (AddMonoid.toAddZeroClass.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6)))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u3, u3, u2, u1} k k V₁ V₂ (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1))))))) e' (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e p))), Eq.{max (succ u5) (succ u4)} (forall (ᾰ : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) ᾰ) (FunLike.coe.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1), succ u5, succ u4} (AffineEquiv.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1), succ u5, succ u4} (AffineEquiv.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1), succ u5, succ u4} (AffineEquiv.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) (AffineEquiv.mk'.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e) e' p h)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_mk' AffineEquiv.coe_mk'ₓ'. -/\n@[simp]\ntheorem coe_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : ⇑(mk' e e' p h) = e :=\n  rfl\n#align affine_equiv.coe_mk' AffineEquiv.coe_mk'\n\n/- warning: affine_equiv.linear_mk' -> AffineEquiv.linear_mk' is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : Equiv.{succ u2, succ u3} P₁ P₂) (e' : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (p : P₁) (h : forall (p' : P₁), Eq.{succ u3} P₂ (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e p') (VAdd.vadd.{u5, u3} V₂ P₂ (AddAction.toHasVadd.{u5, u3} V₂ P₂ (SubNegMonoid.toAddMonoid.{u5} V₂ (AddGroup.toSubNegMonoid.{u5} V₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5))) (AddTorsor.toAddAction.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5) _inst_7)) (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_3.{u1} k _inst_1) (AffineEquiv.mk'._proof_4.{u1} k _inst_1) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (fun (_x : LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_3.{u1} k _inst_1) (AffineEquiv.mk'._proof_4.{u1} k _inst_1) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) => V₁ -> V₂) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AffineEquiv.mk'._proof_5.{u1} k _inst_1) (AffineEquiv.mk'._proof_6.{u1} k _inst_1)) e' (VSub.vsub.{u4, u2} V₁ P₁ (AddTorsor.toHasVsub.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2) _inst_4) p' p)) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e p))), Eq.{max (succ u4) (succ u5)} (LinearEquiv.{u1, u1, u4, u5} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6) (AffineEquiv.linear.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk'.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P₁ P₂) (fun (_x : Equiv.{succ u2, succ u3} P₁ P₂) => P₁ -> P₂) (Equiv.hasCoeToFun.{succ u2, succ u3} P₁ P₂) e) e' p h)) e'\nbut is expected to have type\n  forall {k : Type.{u3}} {P₁ : Type.{u5}} {P₂ : Type.{u4}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : Equiv.{succ u5, succ u4} P₁ P₂) (e' : LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (p : P₁) (h : forall (p' : P₁), Eq.{succ u4} P₂ (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e p') (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ P₂ (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) P₂ (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) _inst_5) _inst_7))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) V₁ (fun (_x : V₁) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) _x) (SMulHomClass.toFunLike.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (SMulZeroClass.toSMul.{u3, u2} k V₁ (AddMonoid.toZero.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V₁ (AddMonoid.toAddZeroClass.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V₁ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V₂ (AddMonoid.toZero.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V₂ (AddMonoid.toAddZeroClass.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6)))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u3, u3, u2, u1} k k V₁ V₂ (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1))))))) e' (VSub.vsub.{u2, u5} V₁ P₁ (AddTorsor.toVSub.{u2, u5} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) p' p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e p))), Eq.{max (succ u2) (succ u1)} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (AffineEquiv.linear.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk'.{u3, u5, u4, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P₁ P₂) P₁ (fun (_x : P₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P₁) => P₂) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P₁ P₂) e) e' p h)) e'\nCase conversion may be inaccurate. Consider using '#align affine_equiv.linear_mk' AffineEquiv.linear_mk'ₓ'. -/\n@[simp]\ntheorem linear_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : (mk' e e' p h).linear = e' :=\n  rfl\n#align affine_equiv.linear_mk' AffineEquiv.linear_mk'\n\n#print AffineEquiv.symm /-\n/-- Inverse of an affine equivalence as an affine equivalence. -/\n@[symm]\ndef symm (e : P₁ ≃ᵃ[k] P₂) : P₂ ≃ᵃ[k] P₁\n    where\n  toEquiv := e.toEquiv.symm\n  linear := e.linear.symm\n  map_vadd' v p :=\n    e.toEquiv.symm.apply_eq_iff_eq_symm_apply.2 <| by\n      simpa using (e.to_equiv.apply_symm_apply v).symm\n#align affine_equiv.symm AffineEquiv.symm\n-/\n\n/- warning: affine_equiv.symm_to_equiv -> AffineEquiv.symm_toEquiv is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max 1 (max (succ u3) (succ u2)) (succ u2) (succ u3)} (Equiv.{succ u3, succ u2} P₂ P₁) (Equiv.symm.{succ u2, succ u3} P₁ P₂ (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.toEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (Equiv.{succ u3, succ u4} P₂ P₁) (Equiv.symm.{succ u4, succ u3} P₁ P₂ (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.toEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.symm_to_equiv AffineEquiv.symm_toEquivₓ'. -/\n@[simp]\ntheorem symm_toEquiv (e : P₁ ≃ᵃ[k] P₂) : e.toEquiv.symm = e.symm.toEquiv :=\n  rfl\n#align affine_equiv.symm_to_equiv AffineEquiv.symm_toEquiv\n\n/- warning: affine_equiv.symm_linear -> AffineEquiv.symm_linear is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u5) (succ u4)} (LinearEquiv.{u1, u1, u5, u4} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₂ V₁ (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) _inst_6 _inst_3) (LinearEquiv.symm.{u1, u1, u4, u5} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (AffineEquiv.linear.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.linear.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u1)} (LinearEquiv.{u5, u5, u1, u2} k k (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) V₂ V₁ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_6 _inst_3) (LinearEquiv.symm.{u5, u5, u2, u1} k k V₁ V₂ (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHom.id.{u5} k (Semiring.toNonAssocSemiring.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (RingHomInvPair.ids.{u5} k (Ring.toSemiring.{u5} k _inst_1)) (AffineEquiv.linear.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.linear.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.symm_linear AffineEquiv.symm_linearₓ'. -/\n@[simp]\ntheorem symm_linear (e : P₁ ≃ᵃ[k] P₂) : e.linear.symm = e.symm.linear :=\n  rfl\n#align affine_equiv.symm_linear AffineEquiv.symm_linear\n\n#print AffineEquiv.Simps.apply /-\n/-- See Note [custom simps projection] -/\ndef Simps.apply (e : P₁ ≃ᵃ[k] P₂) : P₁ → P₂ :=\n  e\n#align affine_equiv.simps.apply AffineEquiv.Simps.apply\n-/\n\n#print AffineEquiv.Simps.symmApply /-\n/-- See Note [custom simps projection] -/\ndef Simps.symmApply (e : P₁ ≃ᵃ[k] P₂) : P₂ → P₁ :=\n  e.symm\n#align affine_equiv.simps.symm_apply AffineEquiv.Simps.symmApply\n-/\n\ninitialize_simps_projections AffineEquiv (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply,\n  linear → linear, as_prefix linear, -toEquiv)\n\n/- warning: affine_equiv.bijective -> AffineEquiv.bijective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Bijective.{succ u2, succ u3} P₁ P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Bijective.{succ u4, succ u3} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.bijective AffineEquiv.bijectiveₓ'. -/\nprotected theorem bijective (e : P₁ ≃ᵃ[k] P₂) : Bijective e :=\n  e.toEquiv.Bijective\n#align affine_equiv.bijective AffineEquiv.bijective\n\n/- warning: affine_equiv.surjective -> AffineEquiv.surjective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Surjective.{succ u2, succ u3} P₁ P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Surjective.{succ u4, succ u3} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.surjective AffineEquiv.surjectiveₓ'. -/\nprotected theorem surjective (e : P₁ ≃ᵃ[k] P₂) : Surjective e :=\n  e.toEquiv.Surjective\n#align affine_equiv.surjective AffineEquiv.surjective\n\n/- warning: affine_equiv.injective -> AffineEquiv.injective is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Injective.{succ u2, succ u3} P₁ P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Injective.{succ u4, succ u3} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.injective AffineEquiv.injectiveₓ'. -/\nprotected theorem injective (e : P₁ ≃ᵃ[k] P₂) : Injective e :=\n  e.toEquiv.Injective\n#align affine_equiv.injective AffineEquiv.injective\n\n#print AffineEquiv.ofBijective /-\n/-- Bijective affine maps are affine isomorphisms. -/\n@[simps]\nnoncomputable def ofBijective {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Bijective φ) : P₁ ≃ᵃ[k] P₂ :=\n  {\n    Equiv.ofBijective _\n      hφ with\n    linear := LinearEquiv.ofBijective φ.linear (φ.linear_bijective_iff.mpr hφ)\n    map_vadd' := φ.map_vadd }\n#align affine_equiv.of_bijective AffineEquiv.ofBijective\n-/\n\n/- warning: affine_equiv.of_bijective.symm_eq -> AffineEquiv.ofBijective.symm_eq is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] {φ : AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} (hφ : Function.Bijective.{succ u2, succ u3} P₁ P₂ (coeFn.{max (succ u4) (succ u2) (succ u5) (succ u3), max (succ u2) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) φ)), Eq.{max 1 (max (succ u3) (succ u2)) (succ u2) (succ u3)} (Equiv.{succ u3, succ u2} P₂ P₁) (AffineEquiv.toEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.ofBijective.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ hφ))) (Equiv.symm.{succ u2, succ u3} P₁ P₂ (Equiv.ofBijective.{succ u2, succ u3} P₁ P₂ (coeFn.{max (succ u4) (succ u2) (succ u5) (succ u3), max (succ u2) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) φ) hφ))\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u3}} {P₂ : Type.{u1}} {V₁ : Type.{u4}} {V₂ : Type.{u2}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u5, u4} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u2} V₂] [_inst_6 : Module.{u5, u2} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₂ _inst_5)] [_inst_7 : AddTorsor.{u2, u1} V₂ P₂ (AddCommGroup.toAddGroup.{u2} V₂ _inst_5)] {φ : AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} (hφ : Function.Bijective.{succ u3, succ u1} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) φ)), Eq.{max (succ u3) (succ u1)} (Equiv.{succ u1, succ u3} P₂ P₁) (AffineEquiv.toEquiv.{u5, u1, u3, u2, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u5, u3, u1, u4, u2} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.ofBijective.{u5, u3, u1, u4, u2} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 φ hφ))) (Equiv.symm.{succ u3, succ u1} P₁ P₂ (Equiv.ofBijective.{succ u3, succ u1} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u3, succ u1} (AffineMap.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₂) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) φ) hφ))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.of_bijective.symm_eq AffineEquiv.ofBijective.symm_eqₓ'. -/\ntheorem ofBijective.symm_eq {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Bijective φ) :\n    (ofBijective hφ).symm.toEquiv = (Equiv.ofBijective _ hφ).symm :=\n  rfl\n#align affine_equiv.of_bijective.symm_eq AffineEquiv.ofBijective.symm_eq\n\n/- warning: affine_equiv.range_eq -> AffineEquiv.range_eq is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{succ u3} (Set.{u3} P₂) (Set.range.{u3, succ u2} P₂ P₁ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)) (Set.univ.{u3} P₂)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{succ u3} (Set.{u3} P₂) (Set.range.{u3, succ u4} P₂ P₁ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)) (Set.univ.{u3} P₂)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.range_eq AffineEquiv.range_eqₓ'. -/\n@[simp]\ntheorem range_eq (e : P₁ ≃ᵃ[k] P₂) : range e = univ :=\n  e.Surjective.range_eq\n#align affine_equiv.range_eq AffineEquiv.range_eq\n\n/- warning: affine_equiv.apply_symm_apply -> AffineEquiv.apply_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P₂), Eq.{succ u3} P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P₂ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) p)) p\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P₂), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) (FunLike.coe.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ (fun (a : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₁) a) (EmbeddingLike.toFunLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (EquivLike.toEmbeddingLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) p)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e (FunLike.coe.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ (fun (_x : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₁) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (EquivLike.toEmbeddingLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) p)) p\nCase conversion may be inaccurate. Consider using '#align affine_equiv.apply_symm_apply AffineEquiv.apply_symm_applyₓ'. -/\n@[simp]\ntheorem apply_symm_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₂) : e (e.symm p) = p :=\n  e.toEquiv.apply_symm_apply p\n#align affine_equiv.apply_symm_apply AffineEquiv.apply_symm_apply\n\n/- warning: affine_equiv.symm_apply_apply -> AffineEquiv.symm_apply_apply is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P₁), Eq.{succ u2} P₁ (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P₂ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p)) p\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P₁), Eq.{succ u4} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₁) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (a : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) a) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p)) (FunLike.coe.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ (fun (_x : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₁) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (EquivLike.toEmbeddingLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p)) p\nCase conversion may be inaccurate. Consider using '#align affine_equiv.symm_apply_apply AffineEquiv.symm_apply_applyₓ'. -/\n@[simp]\ntheorem symm_apply_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₁) : e.symm (e p) = p :=\n  e.toEquiv.symm_apply_apply p\n#align affine_equiv.symm_apply_apply AffineEquiv.symm_apply_apply\n\n/- warning: affine_equiv.apply_eq_iff_eq_symm_apply -> AffineEquiv.apply_eq_iff_eq_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p₁ : P₁} {p₂ : P₂}, Iff (Eq.{succ u3} P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p₁) p₂) (Eq.{succ u2} P₁ p₁ (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P₂ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) p₂))\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p₁ : P₁} {p₂ : (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p₁}, Iff (Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p₁) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p₁) p₂) (Eq.{succ u4} P₁ p₁ (FunLike.coe.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ (fun (_x : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₁) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (EquivLike.toEmbeddingLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) p₂))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.apply_eq_iff_eq_symm_apply AffineEquiv.apply_eq_iff_eq_symm_applyₓ'. -/\ntheorem apply_eq_iff_eq_symm_apply (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂} : e p₁ = p₂ ↔ p₁ = e.symm p₂ :=\n  e.toEquiv.apply_eq_iff_eq_symm_apply\n#align affine_equiv.apply_eq_iff_eq_symm_apply AffineEquiv.apply_eq_iff_eq_symm_apply\n\n/- warning: affine_equiv.apply_eq_iff_eq -> AffineEquiv.apply_eq_iff_eq is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p₁ : P₁} {p₂ : P₁}, Iff (Eq.{succ u3} P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p₁) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p₂)) (Eq.{succ u2} P₁ p₁ p₂)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p₁ : P₁} {p₂ : P₁}, Iff (Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) p₁) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p₁) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p₂)) (Eq.{succ u4} P₁ p₁ p₂)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.apply_eq_iff_eq AffineEquiv.apply_eq_iff_eqₓ'. -/\n@[simp]\ntheorem apply_eq_iff_eq (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂ : P₁} : e p₁ = e p₂ ↔ p₁ = p₂ :=\n  e.toEquiv.apply_eq_iff_eq\n#align affine_equiv.apply_eq_iff_eq AffineEquiv.apply_eq_iff_eq\n\n/- warning: affine_equiv.image_symm -> AffineEquiv.image_symm is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (f : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u3} P₂), Eq.{succ u2} (Set.{u2} P₁) (Set.image.{u3, u2} P₂ P₁ (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P₂ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.preimage.{u2, u3} P₁ P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) f) s)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (f : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u3} P₂), Eq.{succ u4} (Set.{u4} P₁) (Set.image.{u3, u4} P₂ P₁ (FunLike.coe.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ (fun (_x : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₁) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (EquivLike.toEmbeddingLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.preimage.{u4, u3} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) f) s)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.image_symm AffineEquiv.image_symmₓ'. -/\n@[simp]\ntheorem image_symm (f : P₁ ≃ᵃ[k] P₂) (s : Set P₂) : f.symm '' s = f ⁻¹' s :=\n  f.symm.toEquiv.image_eq_preimage _\n#align affine_equiv.image_symm AffineEquiv.image_symm\n\n/- warning: affine_equiv.preimage_symm -> AffineEquiv.preimage_symm is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (f : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u2} P₁), Eq.{succ u3} (Set.{u3} P₂) (Set.preimage.{u3, u2} P₂ P₁ (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P₂ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.image.{u2, u3} P₁ P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) f) s)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (f : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u4} P₁), Eq.{succ u3} (Set.{u3} P₂) (Set.preimage.{u3, u4} P₂ P₁ (FunLike.coe.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ (fun (_x : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₁) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (EquivLike.toEmbeddingLike.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2), succ u3, succ u4} (AffineEquiv.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P₂ P₁ (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P₂ P₁ V₂ V₁ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.image.{u4, u3} P₁ P₂ (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) f) s)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.preimage_symm AffineEquiv.preimage_symmₓ'. -/\n@[simp]\ntheorem preimage_symm (f : P₁ ≃ᵃ[k] P₂) (s : Set P₁) : f.symm ⁻¹' s = f '' s :=\n  (f.symm.image_symm _).symm\n#align affine_equiv.preimage_symm AffineEquiv.preimage_symm\n\nvariable (k P₁)\n\nomit V₂\n\n#print AffineEquiv.refl /-\n/-- Identity map as an `affine_equiv`. -/\n@[refl]\ndef refl : P₁ ≃ᵃ[k] P₁ where\n  toEquiv := Equiv.refl P₁\n  linear := LinearEquiv.refl k V₁\n  map_vadd' _ _ := rfl\n#align affine_equiv.refl AffineEquiv.refl\n-/\n\n/- warning: affine_equiv.coe_refl -> AffineEquiv.coe_refl is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{succ u2} (P₁ -> P₁) (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (id.{succ u2} P₁)\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)], Eq.{succ u3} (forall (ᾰ : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) ᾰ) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.refl.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (id.{succ u3} P₁)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_refl AffineEquiv.coe_reflₓ'. -/\n@[simp]\ntheorem coe_refl : ⇑(refl k P₁) = id :=\n  rfl\n#align affine_equiv.coe_refl AffineEquiv.coe_refl\n\n/- warning: affine_equiv.coe_refl_to_affine_map -> AffineEquiv.coe_refl_to_affineMap is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u3) (succ u2)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u3) (succ u2)} a b] => self.0) (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (coeBase.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4)))) (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (AffineMap.id.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineMap.{u1, u2, u3, u2, u3} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.toAffineMap.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (AffineMap.id.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_refl_to_affine_map AffineEquiv.coe_refl_to_affineMapₓ'. -/\n@[simp]\ntheorem coe_refl_to_affineMap : ↑(refl k P₁) = AffineMap.id k P₁ :=\n  rfl\n#align affine_equiv.coe_refl_to_affine_map AffineEquiv.coe_refl_to_affineMap\n\n/- warning: affine_equiv.refl_apply -> AffineEquiv.refl_apply is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (x : P₁), Eq.{succ u2} P₁ (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4) x) x\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (x : P₁), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.refl.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4) x) x\nCase conversion may be inaccurate. Consider using '#align affine_equiv.refl_apply AffineEquiv.refl_applyₓ'. -/\n@[simp]\ntheorem refl_apply (x : P₁) : refl k P₁ x = x :=\n  rfl\n#align affine_equiv.refl_apply AffineEquiv.refl_apply\n\n/- warning: affine_equiv.to_equiv_refl -> AffineEquiv.toEquiv_refl is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{succ u2} (Equiv.{succ u2, succ u2} P₁ P₁) (AffineEquiv.toEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (Equiv.refl.{succ u2} P₁)\nbut is expected to have type\n  forall (k : Type.{u2}) (P₁ : Type.{u3}) {V₁ : Type.{u1}} [_inst_1 : Ring.{u2} k] [_inst_2 : AddCommGroup.{u1} V₁] [_inst_3 : Module.{u2, u1} k V₁ (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₁ _inst_2)] [_inst_4 : AddTorsor.{u1, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2)], Eq.{succ u3} (Equiv.{succ u3, succ u3} P₁ P₁) (AffineEquiv.toEquiv.{u2, u3, u3, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u2, u3, u1} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (Equiv.refl.{succ u3} P₁)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_equiv_refl AffineEquiv.toEquiv_reflₓ'. -/\n@[simp]\ntheorem toEquiv_refl : (refl k P₁).toEquiv = Equiv.refl P₁ :=\n  rfl\n#align affine_equiv.to_equiv_refl AffineEquiv.toEquiv_refl\n\n/- warning: affine_equiv.linear_refl -> AffineEquiv.linear_refl is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{succ u3} (LinearEquiv.{u1, u1, u3, u3} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₁ (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2) _inst_3 _inst_3) (AffineEquiv.linear.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (LinearEquiv.refl.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2) _inst_3)\nbut is expected to have type\n  forall (k : Type.{u2}) (P₁ : Type.{u1}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u2} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u2, u3} k V₁ (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u1} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{succ u3} (LinearEquiv.{u2, u2, u3, u3} k k (Ring.toSemiring.{u2} k _inst_1) (Ring.toSemiring.{u2} k _inst_1) (RingHom.id.{u2} k (Semiring.toNonAssocSemiring.{u2} k (Ring.toSemiring.{u2} k _inst_1))) (RingHom.id.{u2} k (Semiring.toNonAssocSemiring.{u2} k (Ring.toSemiring.{u2} k _inst_1))) (RingHomInvPair.ids.{u2} k (Ring.toSemiring.{u2} k _inst_1)) (RingHomInvPair.ids.{u2} k (Ring.toSemiring.{u2} k _inst_1)) V₁ V₁ (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2) _inst_3 _inst_3) (AffineEquiv.linear.{u2, u1, u1, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u2, u1, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (LinearEquiv.refl.{u2, u3} k V₁ (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2) _inst_3)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.linear_refl AffineEquiv.linear_reflₓ'. -/\n@[simp]\ntheorem linear_refl : (refl k P₁).linear = LinearEquiv.refl k V₁ :=\n  rfl\n#align affine_equiv.linear_refl AffineEquiv.linear_refl\n\n/- warning: affine_equiv.symm_refl -> AffineEquiv.symm_refl is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)) (AffineEquiv.refl.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.symm_refl AffineEquiv.symm_reflₓ'. -/\n@[simp]\ntheorem symm_refl : (refl k P₁).symm = refl k P₁ :=\n  rfl\n#align affine_equiv.symm_refl AffineEquiv.symm_refl\n\nvariable {k P₁}\n\ninclude V₂ V₃\n\n#print AffineEquiv.trans /-\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\n@[trans]\ndef trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : P₁ ≃ᵃ[k] P₃\n    where\n  toEquiv := e.toEquiv.trans e'.toEquiv\n  linear := e.linear.trans e'.linear\n  map_vadd' p v := by\n    simp only [LinearEquiv.trans_apply, coe_to_equiv, (· ∘ ·), Equiv.coe_trans, map_vadd]\n#align affine_equiv.trans AffineEquiv.trans\n-/\n\n/- warning: affine_equiv.coe_trans -> AffineEquiv.coe_trans is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {P₃ : Type.{u4}} {V₁ : Type.{u5}} {V₂ : Type.{u6}} {V₃ : Type.{u7}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u5} V₁] [_inst_3 : Module.{u1, u5} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₁ _inst_2)] [_inst_4 : AddTorsor.{u5, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u5} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u6} V₂] [_inst_6 : Module.{u1, u6} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V₂ _inst_5)] [_inst_7 : AddTorsor.{u6, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u6} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u7} V₃] [_inst_9 : Module.{u1, u7} k V₃ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V₃ _inst_8)] [_inst_10 : AddTorsor.{u7, u4} V₃ P₃ (AddCommGroup.toAddGroup.{u7} V₃ _inst_8)] (e : AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10), Eq.{max (succ u2) (succ u4)} (P₁ -> P₃) (coeFn.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u2) (succ u4)} (AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) => P₁ -> P₃) (AffineEquiv.hasCoeToFun.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineEquiv.trans.{u1, u2, u3, u4, u5, u6, u7} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e e')) (Function.comp.{succ u2, succ u3, succ u4} P₁ P₂ P₃ (coeFn.{max (succ u3) (succ u4) (succ u6) (succ u7), max (succ u3) (succ u4)} (AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) => P₂ -> P₃) (AffineEquiv.hasCoeToFun.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) e') (coeFn.{max (succ u2) (succ u3) (succ u5) (succ u6), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e))\nbut is expected to have type\n  forall {k : Type.{u7}} {P₁ : Type.{u6}} {P₂ : Type.{u5}} {P₃ : Type.{u2}} {V₁ : Type.{u4}} {V₂ : Type.{u3}} {V₃ : Type.{u1}} [_inst_1 : Ring.{u7} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u7, u4} k V₁ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u6} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u3} V₂] [_inst_6 : Module.{u7, u3} k V₂ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5)] [_inst_7 : AddTorsor.{u3, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u3} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u1} V₃] [_inst_9 : Module.{u7, u1} k V₃ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₃ _inst_8)] [_inst_10 : AddTorsor.{u1, u2} V₃ P₃ (AddCommGroup.toAddGroup.{u1} V₃ _inst_8)] (e : AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10), Eq.{max (succ u6) (succ u2)} (forall (ᾰ : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₃) ᾰ) (FunLike.coe.{max (max (max (succ u6) (succ u2)) (succ u4)) (succ u1), succ u6, succ u2} (AffineEquiv.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₃) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u6) (succ u2)) (succ u4)) (succ u1), succ u6, succ u2} (AffineEquiv.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P₁ P₃ (EquivLike.toEmbeddingLike.{max (max (max (succ u6) (succ u2)) (succ u4)) (succ u1), succ u6, succ u2} (AffineEquiv.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P₁ P₃ (AffineEquiv.equivLike.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10))) (AffineEquiv.trans.{u7, u6, u5, u2, u4, u3, u1} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e e')) (Function.comp.{succ u6, succ u5, succ u2} P₁ P₂ P₃ (FunLike.coe.{max (max (max (succ u5) (succ u2)) (succ u3)) (succ u1), succ u5, succ u2} (AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P₂ (fun (_x : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₃) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u5) (succ u2)) (succ u3)) (succ u1), succ u5, succ u2} (AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P₂ P₃ (EquivLike.toEmbeddingLike.{max (max (max (succ u5) (succ u2)) (succ u3)) (succ u1), succ u5, succ u2} (AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P₂ P₃ (AffineEquiv.equivLike.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10))) e') (FunLike.coe.{max (max (max (succ u6) (succ u5)) (succ u4)) (succ u3), succ u6, succ u5} (AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u6) (succ u5)) (succ u4)) (succ u3), succ u6, succ u5} (AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u6) (succ u5)) (succ u4)) (succ u3), succ u6, succ u5} (AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_trans AffineEquiv.coe_transₓ'. -/\n@[simp]\ntheorem coe_trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : ⇑(e.trans e') = e' ∘ e :=\n  rfl\n#align affine_equiv.coe_trans AffineEquiv.coe_trans\n\n/- warning: affine_equiv.coe_trans_to_affine_map -> AffineEquiv.coe_trans_to_affineMap is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {P₃ : Type.{u4}} {V₁ : Type.{u5}} {V₂ : Type.{u6}} {V₃ : Type.{u7}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u5} V₁] [_inst_3 : Module.{u1, u5} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₁ _inst_2)] [_inst_4 : AddTorsor.{u5, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u5} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u6} V₂] [_inst_6 : Module.{u1, u6} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V₂ _inst_5)] [_inst_7 : AddTorsor.{u6, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u6} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u7} V₃] [_inst_9 : Module.{u1, u7} k V₃ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V₃ _inst_8)] [_inst_10 : AddTorsor.{u7, u4} V₃ P₃ (AddCommGroup.toAddGroup.{u7} V₃ _inst_8)] (e : AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10), Eq.{max (succ u5) (succ u2) (succ u7) (succ u4)} (AffineMap.{u1, u5, u2, u7, u4} k V₁ P₁ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) ((fun (a : Sort.{max (succ u2) (succ u4) (succ u5) (succ u7)}) (b : Sort.{max (succ u5) (succ u2) (succ u7) (succ u4)}) [self : HasLiftT.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u5) (succ u2) (succ u7) (succ u4)} a b] => self.0) (AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V₁ P₁ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (HasLiftT.mk.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u5) (succ u2) (succ u7) (succ u4)} (AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V₁ P₁ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (CoeTCₓ.coe.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u5) (succ u2) (succ u7) (succ u4)} (AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V₁ P₁ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (coeBase.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u5) (succ u2) (succ u7) (succ u4)} (AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V₁ P₁ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10)))) (AffineEquiv.trans.{u1, u2, u3, u4, u5, u6, u7} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e e')) (AffineMap.comp.{u1, u5, u2, u6, u3, u7, u4} k V₁ P₁ V₂ P₂ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 ((fun (a : Sort.{max (succ u3) (succ u4) (succ u6) (succ u7)}) (b : Sort.{max (succ u6) (succ u3) (succ u7) (succ u4)}) [self : HasLiftT.{max (succ u3) (succ u4) (succ u6) (succ u7), max (succ u6) (succ u3) (succ u7) (succ u4)} a b] => self.0) (AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V₂ P₂ V₃ P₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (HasLiftT.mk.{max (succ u3) (succ u4) (succ u6) (succ u7), max (succ u6) (succ u3) (succ u7) (succ u4)} (AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V₂ P₂ V₃ P₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (CoeTCₓ.coe.{max (succ u3) (succ u4) (succ u6) (succ u7), max (succ u6) (succ u3) (succ u7) (succ u4)} (AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V₂ P₂ V₃ P₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (coeBase.{max (succ u3) (succ u4) (succ u6) (succ u7), max (succ u6) (succ u3) (succ u7) (succ u4)} (AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V₂ P₂ V₃ P₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineEquiv.AffineMap.hasCoe.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10)))) e') ((fun (a : Sort.{max (succ u2) (succ u3) (succ u5) (succ u6)}) (b : Sort.{max (succ u5) (succ u2) (succ u6) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3) (succ u5) (succ u6), max (succ u5) (succ u2) (succ u6) (succ u3)} a b] => self.0) (AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (HasLiftT.mk.{max (succ u2) (succ u3) (succ u5) (succ u6), max (succ u5) (succ u2) (succ u6) (succ u3)} (AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTCₓ.coe.{max (succ u2) (succ u3) (succ u5) (succ u6), max (succ u5) (succ u2) (succ u6) (succ u3)} (AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (coeBase.{max (succ u2) (succ u3) (succ u5) (succ u6), max (succ u5) (succ u2) (succ u6) (succ u3)} (AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V₁ P₁ V₂ P₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7)))) e))\nbut is expected to have type\n  forall {k : Type.{u7}} {P₁ : Type.{u6}} {P₂ : Type.{u5}} {P₃ : Type.{u2}} {V₁ : Type.{u4}} {V₂ : Type.{u3}} {V₃ : Type.{u1}} [_inst_1 : Ring.{u7} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u7, u4} k V₁ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u6} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u3} V₂] [_inst_6 : Module.{u7, u3} k V₂ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5)] [_inst_7 : AddTorsor.{u3, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u3} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u1} V₃] [_inst_9 : Module.{u7, u1} k V₃ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₃ _inst_8)] [_inst_10 : AddTorsor.{u1, u2} V₃ P₃ (AddCommGroup.toAddGroup.{u1} V₃ _inst_8)] (e : AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10), Eq.{max (max (max (succ u6) (succ u2)) (succ u4)) (succ u1)} (AffineMap.{u7, u4, u6, u1, u2} k V₁ P₁ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineEquiv.toAffineMap.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10 (AffineEquiv.trans.{u7, u6, u5, u2, u4, u3, u1} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e e')) (AffineMap.comp.{u7, u4, u6, u3, u5, u1, u2} k V₁ P₁ V₂ P₂ V₃ P₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 (AffineEquiv.toAffineMap.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e') (AffineEquiv.toAffineMap.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_trans_to_affine_map AffineEquiv.coe_trans_to_affineMapₓ'. -/\n@[simp]\ntheorem coe_trans_to_affineMap (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) :\n    (e.trans e' : P₁ →ᵃ[k] P₃) = (e' : P₂ →ᵃ[k] P₃).comp e :=\n  rfl\n#align affine_equiv.coe_trans_to_affine_map AffineEquiv.coe_trans_to_affineMap\n\n/- warning: affine_equiv.trans_apply -> AffineEquiv.trans_apply is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {P₃ : Type.{u4}} {V₁ : Type.{u5}} {V₂ : Type.{u6}} {V₃ : Type.{u7}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u5} V₁] [_inst_3 : Module.{u1, u5} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₁ _inst_2)] [_inst_4 : AddTorsor.{u5, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u5} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u6} V₂] [_inst_6 : Module.{u1, u6} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V₂ _inst_5)] [_inst_7 : AddTorsor.{u6, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u6} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u7} V₃] [_inst_9 : Module.{u1, u7} k V₃ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V₃ _inst_8)] [_inst_10 : AddTorsor.{u7, u4} V₃ P₃ (AddCommGroup.toAddGroup.{u7} V₃ _inst_8)] (e : AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (p : P₁), Eq.{succ u4} P₃ (coeFn.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u2) (succ u4)} (AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) => P₁ -> P₃) (AffineEquiv.hasCoeToFun.{u1, u2, u4, u5, u7} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineEquiv.trans.{u1, u2, u3, u4, u5, u6, u7} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e e') p) (coeFn.{max (succ u3) (succ u4) (succ u6) (succ u7), max (succ u3) (succ u4)} (AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) => P₂ -> P₃) (AffineEquiv.hasCoeToFun.{u1, u3, u4, u6, u7} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) e' (coeFn.{max (succ u2) (succ u3) (succ u5) (succ u6), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u5, u6} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p))\nbut is expected to have type\n  forall {k : Type.{u7}} {P₁ : Type.{u6}} {P₂ : Type.{u5}} {P₃ : Type.{u2}} {V₁ : Type.{u4}} {V₂ : Type.{u3}} {V₃ : Type.{u1}} [_inst_1 : Ring.{u7} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u7, u4} k V₁ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u6} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u3} V₂] [_inst_6 : Module.{u7, u3} k V₂ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5)] [_inst_7 : AddTorsor.{u3, u5} V₂ P₂ (AddCommGroup.toAddGroup.{u3} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u1} V₃] [_inst_9 : Module.{u7, u1} k V₃ (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₃ _inst_8)] [_inst_10 : AddTorsor.{u1, u2} V₃ P₃ (AddCommGroup.toAddGroup.{u1} V₃ _inst_8)] (e : AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (p : P₁), Eq.{succ u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₃) p) (FunLike.coe.{max (max (max (succ u6) (succ u2)) (succ u4)) (succ u1), succ u6, succ u2} (AffineEquiv.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₃) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u6) (succ u2)) (succ u4)) (succ u1), succ u6, succ u2} (AffineEquiv.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P₁ P₃ (EquivLike.toEmbeddingLike.{max (max (max (succ u6) (succ u2)) (succ u4)) (succ u1), succ u6, succ u2} (AffineEquiv.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P₁ P₃ (AffineEquiv.equivLike.{u7, u6, u2, u4, u1} k P₁ P₃ V₁ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10))) (AffineEquiv.trans.{u7, u6, u5, u2, u4, u3, u1} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e e') p) (FunLike.coe.{max (max (max (succ u5) (succ u2)) (succ u3)) (succ u1), succ u5, succ u2} (AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P₂ (fun (_x : P₂) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₂) => P₃) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u5) (succ u2)) (succ u3)) (succ u1), succ u5, succ u2} (AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P₂ P₃ (EquivLike.toEmbeddingLike.{max (max (max (succ u5) (succ u2)) (succ u3)) (succ u1), succ u5, succ u2} (AffineEquiv.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P₂ P₃ (AffineEquiv.equivLike.{u7, u5, u2, u3, u1} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10))) e' (FunLike.coe.{max (max (max (succ u6) (succ u5)) (succ u4)) (succ u3), succ u6, succ u5} (AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u6) (succ u5)) (succ u4)) (succ u3), succ u6, succ u5} (AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u6) (succ u5)) (succ u4)) (succ u3), succ u6, succ u5} (AffineEquiv.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u7, u6, u5, u4, u3} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.trans_apply AffineEquiv.trans_applyₓ'. -/\n@[simp]\ntheorem trans_apply (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) (p : P₁) : e.trans e' p = e' (e p) :=\n  rfl\n#align affine_equiv.trans_apply AffineEquiv.trans_apply\n\ninclude V₄\n\n/- warning: affine_equiv.trans_assoc -> AffineEquiv.trans_assoc is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {P₃ : Type.{u4}} {P₄ : Type.{u5}} {V₁ : Type.{u6}} {V₂ : Type.{u7}} {V₃ : Type.{u8}} {V₄ : Type.{u9}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u6} V₁] [_inst_3 : Module.{u1, u6} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V₁ _inst_2)] [_inst_4 : AddTorsor.{u6, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u6} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u7} V₂] [_inst_6 : Module.{u1, u7} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V₂ _inst_5)] [_inst_7 : AddTorsor.{u7, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u7} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u8} V₃] [_inst_9 : Module.{u1, u8} k V₃ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u8} V₃ _inst_8)] [_inst_10 : AddTorsor.{u8, u4} V₃ P₃ (AddCommGroup.toAddGroup.{u8} V₃ _inst_8)] [_inst_11 : AddCommGroup.{u9} V₄] [_inst_12 : Module.{u1, u9} k V₄ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u9} V₄ _inst_11)] [_inst_13 : AddTorsor.{u9, u5} V₄ P₄ (AddCommGroup.toAddGroup.{u9} V₄ _inst_11)] (e₁ : AffineEquiv.{u1, u2, u3, u6, u7} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e₂ : AffineEquiv.{u1, u3, u4, u7, u8} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (e₃ : AffineEquiv.{u1, u4, u5, u8, u9} k P₃ P₄ V₃ V₄ _inst_1 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13), Eq.{max (succ u2) (succ u5) (succ u6) (succ u9)} (AffineEquiv.{u1, u2, u5, u6, u9} k P₁ P₄ V₁ V₄ _inst_1 _inst_2 _inst_3 _inst_4 _inst_11 _inst_12 _inst_13) (AffineEquiv.trans.{u1, u2, u4, u5, u6, u8, u9} k P₁ P₃ P₄ V₁ V₃ V₄ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 (AffineEquiv.trans.{u1, u2, u3, u4, u6, u7, u8} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e₁ e₂) e₃) (AffineEquiv.trans.{u1, u2, u3, u5, u6, u7, u9} k P₁ P₂ P₄ V₁ V₂ V₄ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_11 _inst_12 _inst_13 e₁ (AffineEquiv.trans.{u1, u3, u4, u5, u7, u8, u9} k P₂ P₃ P₄ V₂ V₃ V₄ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 e₂ e₃))\nbut is expected to have type\n  forall {k : Type.{u9}} {P₁ : Type.{u8}} {P₂ : Type.{u7}} {P₃ : Type.{u4}} {P₄ : Type.{u2}} {V₁ : Type.{u6}} {V₂ : Type.{u5}} {V₃ : Type.{u3}} {V₄ : Type.{u1}} [_inst_1 : Ring.{u9} k] [_inst_2 : AddCommGroup.{u6} V₁] [_inst_3 : Module.{u9, u6} k V₁ (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V₁ _inst_2)] [_inst_4 : AddTorsor.{u6, u8} V₁ P₁ (AddCommGroup.toAddGroup.{u6} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u9, u5} k V₂ (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u7} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] [_inst_8 : AddCommGroup.{u3} V₃] [_inst_9 : Module.{u9, u3} k V₃ (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₃ _inst_8)] [_inst_10 : AddTorsor.{u3, u4} V₃ P₃ (AddCommGroup.toAddGroup.{u3} V₃ _inst_8)] [_inst_11 : AddCommGroup.{u1} V₄] [_inst_12 : Module.{u9, u1} k V₄ (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₄ _inst_11)] [_inst_13 : AddTorsor.{u1, u2} V₄ P₄ (AddCommGroup.toAddGroup.{u1} V₄ _inst_11)] (e₁ : AffineEquiv.{u9, u8, u7, u6, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e₂ : AffineEquiv.{u9, u7, u4, u5, u3} k P₂ P₃ V₂ V₃ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (e₃ : AffineEquiv.{u9, u4, u2, u3, u1} k P₃ P₄ V₃ V₄ _inst_1 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13), Eq.{max (max (max (succ u8) (succ u2)) (succ u6)) (succ u1)} (AffineEquiv.{u9, u8, u2, u6, u1} k P₁ P₄ V₁ V₄ _inst_1 _inst_2 _inst_3 _inst_4 _inst_11 _inst_12 _inst_13) (AffineEquiv.trans.{u9, u8, u4, u2, u6, u3, u1} k P₁ P₃ P₄ V₁ V₃ V₄ _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 (AffineEquiv.trans.{u9, u8, u7, u4, u6, u5, u3} k P₁ P₂ P₃ V₁ V₂ V₃ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e₁ e₂) e₃) (AffineEquiv.trans.{u9, u8, u7, u2, u6, u5, u1} k P₁ P₂ P₄ V₁ V₂ V₄ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_11 _inst_12 _inst_13 e₁ (AffineEquiv.trans.{u9, u7, u4, u2, u5, u3, u1} k P₂ P₃ P₄ V₂ V₃ V₄ _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 e₂ e₃))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.trans_assoc AffineEquiv.trans_assocₓ'. -/\ntheorem trans_assoc (e₁ : P₁ ≃ᵃ[k] P₂) (e₂ : P₂ ≃ᵃ[k] P₃) (e₃ : P₃ ≃ᵃ[k] P₄) :\n    (e₁.trans e₂).trans e₃ = e₁.trans (e₂.trans e₃) :=\n  ext fun _ => rfl\n#align affine_equiv.trans_assoc AffineEquiv.trans_assoc\n\nomit V₃ V₄\n\n/- warning: affine_equiv.trans_refl -> AffineEquiv.trans_refl is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3) (succ u4) (succ u5)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.trans.{u1, u2, u3, u3, u4, u5, u5} k P₁ P₂ P₂ V₁ V₂ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_5 _inst_6 _inst_7 e (AffineEquiv.refl.{u1, u3, u5} k P₂ V₂ _inst_1 _inst_5 _inst_6 _inst_7)) e\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.trans.{u5, u4, u3, u3, u2, u1, u1} k P₁ P₂ P₂ V₁ V₂ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_5 _inst_6 _inst_7 e (AffineEquiv.refl.{u5, u3, u1} k P₂ V₂ _inst_1 _inst_5 _inst_6 _inst_7)) e\nCase conversion may be inaccurate. Consider using '#align affine_equiv.trans_refl AffineEquiv.trans_reflₓ'. -/\n@[simp]\ntheorem trans_refl (e : P₁ ≃ᵃ[k] P₂) : e.trans (refl k P₂) = e :=\n  ext fun _ => rfl\n#align affine_equiv.trans_refl AffineEquiv.trans_refl\n\n/- warning: affine_equiv.refl_trans -> AffineEquiv.refl_trans is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3) (succ u4) (succ u5)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.trans.{u1, u2, u2, u3, u4, u4, u5} k P₁ P₁ P₂ V₁ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.refl.{u1, u2, u4} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4) e) e\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.trans.{u5, u4, u4, u3, u2, u2, u1} k P₁ P₁ P₂ V₁ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.refl.{u5, u4, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4) e) e\nCase conversion may be inaccurate. Consider using '#align affine_equiv.refl_trans AffineEquiv.refl_transₓ'. -/\n@[simp]\ntheorem refl_trans (e : P₁ ≃ᵃ[k] P₂) : (refl k P₁).trans e = e :=\n  ext fun _ => rfl\n#align affine_equiv.refl_trans AffineEquiv.refl_trans\n\n/- warning: affine_equiv.self_trans_symm -> AffineEquiv.self_trans_symm is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u4)} (AffineEquiv.{u1, u2, u2, u4, u4} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.trans.{u1, u2, u3, u2, u4, u5, u4} k P₁ P₂ P₁ V₁ V₂ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 e (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.refl.{u1, u2, u4} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u2)} (AffineEquiv.{u5, u4, u4, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.trans.{u5, u4, u3, u4, u2, u1, u2} k P₁ P₂ P₁ V₁ V₂ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 e (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.refl.{u5, u4, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.self_trans_symm AffineEquiv.self_trans_symmₓ'. -/\n@[simp]\ntheorem self_trans_symm (e : P₁ ≃ᵃ[k] P₂) : e.trans e.symm = refl k P₁ :=\n  ext e.symm_apply_apply\n#align affine_equiv.self_trans_symm AffineEquiv.self_trans_symm\n\n/- warning: affine_equiv.symm_trans_self -> AffineEquiv.symm_trans_self is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u3) (succ u5)} (AffineEquiv.{u1, u3, u3, u5, u5} k P₂ P₂ V₂ V₂ _inst_1 _inst_5 _inst_6 _inst_7 _inst_5 _inst_6 _inst_7) (AffineEquiv.trans.{u1, u3, u2, u3, u5, u4, u5} k P₂ P₁ P₂ V₂ V₁ V₂ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) e) (AffineEquiv.refl.{u1, u3, u5} k P₂ V₂ _inst_1 _inst_5 _inst_6 _inst_7)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u3) (succ u1)} (AffineEquiv.{u5, u3, u3, u1, u1} k P₂ P₂ V₂ V₂ _inst_1 _inst_5 _inst_6 _inst_7 _inst_5 _inst_6 _inst_7) (AffineEquiv.trans.{u5, u3, u4, u3, u1, u2, u1} k P₂ P₁ P₂ V₂ V₁ V₂ _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) e) (AffineEquiv.refl.{u5, u3, u1} k P₂ V₂ _inst_1 _inst_5 _inst_6 _inst_7)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.symm_trans_self AffineEquiv.symm_trans_selfₓ'. -/\n@[simp]\ntheorem symm_trans_self (e : P₁ ≃ᵃ[k] P₂) : e.symm.trans e = refl k P₂ :=\n  ext e.apply_symm_apply\n#align affine_equiv.symm_trans_self AffineEquiv.symm_trans_self\n\n/- warning: affine_equiv.apply_line_map -> AffineEquiv.apply_lineMap is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {P₂ : Type.{u3}} {V₁ : Type.{u4}} {V₂ : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V₁] [_inst_3 : Module.{u1, u4} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V₁ _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u4} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u5} V₂] [_inst_6 : Module.{u1, u5} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V₂ _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u5} V₂ _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (a : P₁) (b : P₁) (c : k), Eq.{succ u3} P₂ (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e (coeFn.{max (succ u1) (succ u4) (succ u2), max (succ u1) (succ u2)} (AffineMap.{u1, u1, u1, u4, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (fun (_x : AffineMap.{u1, u1, u1, u4, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) => k -> P₁) (AffineMap.hasCoeToFun.{u1, u1, u1, u4, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u1, u4, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 a b) c)) (coeFn.{max (succ u1) (succ u5) (succ u3), max (succ u1) (succ u3)} (AffineMap.{u1, u1, u1, u5, u3} k k k V₂ P₂ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u1, u1, u5, u3} k k k V₂ P₂ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_5 _inst_6 _inst_7) => k -> P₂) (AffineMap.hasCoeToFun.{u1, u1, u1, u5, u3} k k k V₂ P₂ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_5 _inst_6 _inst_7) (AffineMap.lineMap.{u1, u5, u3} k V₂ P₂ _inst_1 _inst_5 _inst_6 _inst_7 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e a) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P₁ -> P₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e b)) c)\nbut is expected to have type\n  forall {k : Type.{u5}} {P₁ : Type.{u4}} {P₂ : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u5, u2} k V₁ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u5, u1} k V₂ (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V₂ P₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (a : P₁) (b : P₁) (c : k), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) (FunLike.coe.{max (max (succ u5) (succ u2)) (succ u4), succ u5, succ u4} (AffineMap.{u5, u5, u5, u2, u4} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u5} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u5} k _inst_1) (addGroupIsAddTorsor.{u5} k (AddGroupWithOne.toAddGroup.{u5} k (Ring.toAddGroupWithOne.{u5} k _inst_1))) _inst_2 _inst_3 _inst_4) k (fun (a : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) a) (AffineMap.funLike.{u5, u5, u5, u2, u4} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u5} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u5} k _inst_1) (addGroupIsAddTorsor.{u5} k (AddGroupWithOne.toAddGroup.{u5} k (Ring.toAddGroupWithOne.{u5} k _inst_1))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u5, u2, u4} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 a b) c)) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e (FunLike.coe.{max (max (succ u5) (succ u2)) (succ u4), succ u5, succ u4} (AffineMap.{u5, u5, u5, u2, u4} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u5} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u5} k _inst_1) (addGroupIsAddTorsor.{u5} k (AddGroupWithOne.toAddGroup.{u5} k (Ring.toAddGroupWithOne.{u5} k _inst_1))) _inst_2 _inst_3 _inst_4) k (fun (_x : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) _x) (AffineMap.funLike.{u5, u5, u5, u2, u4} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u5} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u5} k _inst_1) (addGroupIsAddTorsor.{u5} k (AddGroupWithOne.toAddGroup.{u5} k (Ring.toAddGroupWithOne.{u5} k _inst_1))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u5, u2, u4} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 a b) c)) (FunLike.coe.{max (max (succ u5) (succ u1)) (succ u3), succ u5, succ u3} (AffineMap.{u5, u5, u5, u1, u3} k k k V₂ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) a) _inst_1 (Ring.toAddCommGroup.{u5} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u5} k _inst_1) (addGroupIsAddTorsor.{u5} k (AddGroupWithOne.toAddGroup.{u5} k (Ring.toAddGroupWithOne.{u5} k _inst_1))) _inst_5 _inst_6 _inst_7) k (fun (_x : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) a) _x) (AffineMap.funLike.{u5, u5, u5, u1, u3} k k k V₂ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) a) _inst_1 (Ring.toAddCommGroup.{u5} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u5} k _inst_1) (addGroupIsAddTorsor.{u5} k (AddGroupWithOne.toAddGroup.{u5} k (Ring.toAddGroupWithOne.{u5} k _inst_1))) _inst_5 _inst_6 _inst_7) (AffineMap.lineMap.{u5, u1, u3} k V₂ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) a) _inst_1 _inst_5 _inst_6 _inst_7 (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e a) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₂) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (EquivLike.toEmbeddingLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), succ u4, succ u3} (AffineEquiv.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P₁ P₂ (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P₁ P₂ V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e b)) c)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.apply_line_map AffineEquiv.apply_lineMapₓ'. -/\n@[simp]\ntheorem apply_lineMap (e : P₁ ≃ᵃ[k] P₂) (a b : P₁) (c : k) :\n    e (AffineMap.lineMap a b c) = AffineMap.lineMap (e a) (e b) c :=\n  e.toAffineMap.apply_lineMap a b c\n#align affine_equiv.apply_line_map AffineEquiv.apply_lineMap\n\nomit V₂\n\ninstance : Group (P₁ ≃ᵃ[k] P₁) where\n  one := refl k P₁\n  mul e e' := e'.trans e\n  inv := symm\n  mul_assoc e₁ e₂ e₃ := trans_assoc _ _ _\n  one_mul := trans_refl\n  mul_one := refl_trans\n  mul_left_inv := self_trans_symm\n\n/- warning: affine_equiv.one_def -> AffineEquiv.one_def is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (OfNat.ofNat.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) 1 (OfNat.mk.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) 1 (One.one.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (MulOneClass.toHasOne.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))))))) (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (OfNat.ofNat.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) 1 (One.toOfNat1.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (InvOneClass.toOne.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvOneMonoid.toInvOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivisionMonoid.toDivInvOneMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivisionMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))))))) (AffineEquiv.refl.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.one_def AffineEquiv.one_defₓ'. -/\ntheorem one_def : (1 : P₁ ≃ᵃ[k] P₁) = refl k P₁ :=\n  rfl\n#align affine_equiv.one_def AffineEquiv.one_def\n\n/- warning: affine_equiv.coe_one -> AffineEquiv.coe_one is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{succ u2} (P₁ -> P₁) (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (OfNat.ofNat.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) 1 (OfNat.mk.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) 1 (One.one.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (MulOneClass.toHasOne.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))))))))) (id.{succ u2} P₁)\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)], Eq.{succ u3} (forall (ᾰ : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) ᾰ) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (OfNat.ofNat.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) 1 (One.toOfNat1.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (InvOneClass.toOne.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvOneMonoid.toInvOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivisionMonoid.toDivInvOneMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivisionMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))))))) (id.{succ u3} P₁)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_one AffineEquiv.coe_oneₓ'. -/\n@[simp]\ntheorem coe_one : ⇑(1 : P₁ ≃ᵃ[k] P₁) = id :=\n  rfl\n#align affine_equiv.coe_one AffineEquiv.coe_one\n\n/- warning: affine_equiv.mul_def -> AffineEquiv.mul_def is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (e : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{succ (max u2 u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (MulOneClass.toHasMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))))) e e') (AffineEquiv.trans.{u1, u2, u2, u2, u3, u3, u3} k P₁ P₁ P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 e' e)\nbut is expected to have type\n  forall {k : Type.{u3}} {P₁ : Type.{u2}} {V₁ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V₁] [_inst_3 : Module.{u3, u1} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₁ _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2)] (e : AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHMul.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (MulOneClass.toMul.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u3, u2, u1} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))))) e e') (AffineEquiv.trans.{u3, u2, u2, u2, u1, u1, u1} k P₁ P₁ P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 e' e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.mul_def AffineEquiv.mul_defₓ'. -/\ntheorem mul_def (e e' : P₁ ≃ᵃ[k] P₁) : e * e' = e'.trans e :=\n  rfl\n#align affine_equiv.mul_def AffineEquiv.mul_def\n\n/- warning: affine_equiv.coe_mul -> AffineEquiv.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (e : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{succ u2} (P₁ -> P₁) (coeFn.{succ (max u2 u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (MulOneClass.toHasMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))))) e e')) (Function.comp.{succ u2, succ u2, succ u2} P₁ P₁ P₁ (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) e) (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) e'))\nbut is expected to have type\n  forall {k : Type.{u3}} {P₁ : Type.{u2}} {V₁ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V₁] [_inst_3 : Module.{u3, u1} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₁ _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2)] (e : AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{succ u2} (forall (ᾰ : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHMul.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (MulOneClass.toMul.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u3, u2, u1} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))))) e e')) (Function.comp.{succ u2, succ u2, succ u2} P₁ P₁ P₁ (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) e) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) e'))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_mul AffineEquiv.coe_mulₓ'. -/\n@[simp]\ntheorem coe_mul (e e' : P₁ ≃ᵃ[k] P₁) : ⇑(e * e') = e ∘ e' :=\n  rfl\n#align affine_equiv.coe_mul AffineEquiv.coe_mul\n\n/- warning: affine_equiv.inv_def -> AffineEquiv.inv_def is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (e : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{succ (max u2 u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Inv.inv.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toHasInv.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))) e) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 e)\nbut is expected to have type\n  forall {k : Type.{u3}} {P₁ : Type.{u2}} {V₁ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V₁] [_inst_3 : Module.{u3, u1} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₁ _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2)] (e : AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Inv.inv.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (InvOneClass.toInv.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvOneMonoid.toInvOneClass.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivisionMonoid.toDivInvOneMonoid.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivisionMonoid.{max u2 u1} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u3, u2, u1} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))))) e) (AffineEquiv.symm.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.inv_def AffineEquiv.inv_defₓ'. -/\ntheorem inv_def (e : P₁ ≃ᵃ[k] P₁) : e⁻¹ = e.symm :=\n  rfl\n#align affine_equiv.inv_def AffineEquiv.inv_def\n\n#print AffineEquiv.linearHom /-\n/-- `affine_equiv.linear` on automorphisms is a `monoid_hom`. -/\n@[simps]\ndef linearHom : (P₁ ≃ᵃ[k] P₁) →* V₁ ≃ₗ[k] V₁\n    where\n  toFun := linear\n  map_one' := rfl\n  map_mul' _ _ := rfl\n#align affine_equiv.linear_hom AffineEquiv.linearHom\n-/\n\n/- warning: affine_equiv.equiv_units_affine_map -> AffineEquiv.equivUnitsAffineMap is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], MulEquiv.{max u2 u3, max u3 u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Units.{max u3 u2} (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.monoid.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)) (MulOneClass.toHasMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))))) (MulOneClass.toHasMul.{max u3 u2} (Units.{max u3 u2} (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.monoid.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)) (Units.mulOneClass.{max u3 u2} (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.monoid.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)))\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], MulEquiv.{max u3 u2, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Units.{max u2 u3} (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.instMonoidAffineMap.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)) (MulOneClass.toMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Monoid.toMulOneClass.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))))) (MulOneClass.toMul.{max u2 u3} (Units.{max u2 u3} (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.instMonoidAffineMap.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)) (Units.instMulOneClassUnits.{max u2 u3} (AffineMap.{u1, u3, u2, u3, u2} k V₁ P₁ V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.instMonoidAffineMap.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4)))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.equiv_units_affine_map AffineEquiv.equivUnitsAffineMapₓ'. -/\n/-- The group of `affine_equiv`s are equivalent to the group of units of `affine_map`.\n\nThis is the affine version of `linear_map.general_linear_group.general_linear_equiv`. -/\n@[simps]\ndef equivUnitsAffineMap : (P₁ ≃ᵃ[k] P₁) ≃* (P₁ →ᵃ[k] P₁)ˣ\n    where\n  toFun e := ⟨e, e.symm, congr_arg coe e.symm_trans_self, congr_arg coe e.self_trans_symm⟩\n  invFun u :=\n    { toFun := (u : P₁ →ᵃ[k] P₁)\n      invFun := (↑u⁻¹ : P₁ →ᵃ[k] P₁)\n      left_inv := AffineMap.congr_fun u.inv_mul\n      right_inv := AffineMap.congr_fun u.mul_inv\n      linear :=\n        LinearMap.GeneralLinearGroup.generalLinearEquiv _ _ <| Units.map AffineMap.linearHom u\n      map_vadd' := fun _ _ => (u : P₁ →ᵃ[k] P₁).map_vadd _ _ }\n  left_inv e := AffineEquiv.ext fun x => rfl\n  right_inv u := Units.ext <| AffineMap.ext fun x => rfl\n  map_mul' e₁ e₂ := rfl\n#align affine_equiv.equiv_units_affine_map AffineEquiv.equivUnitsAffineMap\n\nvariable (k)\n\n#print AffineEquiv.vaddConst /-\n/-- The map `v ↦ v +ᵥ b` as an affine equivalence between a module `V` and an affine space `P` with\ntangent space `V`. -/\n@[simps]\ndef vaddConst (b : P₁) : V₁ ≃ᵃ[k] P₁\n    where\n  toEquiv := Equiv.vaddConst b\n  linear := LinearEquiv.refl _ _\n  map_vadd' p v := add_vadd _ _ _\n#align affine_equiv.vadd_const AffineEquiv.vaddConst\n-/\n\n#print AffineEquiv.constVSub /-\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P₁) : P₁ ≃ᵃ[k] V₁\n    where\n  toEquiv := Equiv.constVSub p\n  linear := LinearEquiv.neg k\n  map_vadd' p' v := by simp [vsub_vadd_eq_vsub_sub, neg_add_eq_sub]\n#align affine_equiv.const_vsub AffineEquiv.constVSub\n-/\n\n/- warning: affine_equiv.coe_const_vsub -> AffineEquiv.coe_constVSub is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (p : P₁), Eq.{max (succ u2) (succ u3)} (P₁ -> V₁) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u3, u3} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (fun (_x : AffineEquiv.{u1, u2, u3, u3, u3} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) => P₁ -> V₁) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u3, u3} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AffineEquiv.constVSub.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 p)) (VSub.vsub.{u3, u2} V₁ P₁ (AddTorsor.toHasVsub.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4) p)\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (p : P₁), Eq.{max (succ u3) (succ u2)} (forall (ᾰ : P₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => V₁) ᾰ) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AffineEquiv.{u1, u3, u2, u2, u2} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => V₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u2} (AffineEquiv.{u1, u3, u2, u2, u2} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) P₁ V₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u2} (AffineEquiv.{u1, u3, u2, u2, u2} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) P₁ V₁ (AffineEquiv.equivLike.{u1, u3, u2, u2, u2} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))))) (AffineEquiv.constVSub.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 p)) ((fun (x._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.6944 : P₁) (x._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.6946 : P₁) => VSub.vsub.{u2, u3} V₁ P₁ (AddTorsor.toVSub.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) x._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.6944 x._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.6946) p)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_const_vsub AffineEquiv.coe_constVSubₓ'. -/\n@[simp]\ntheorem coe_constVSub (p : P₁) : ⇑(constVSub k p) = (· -ᵥ ·) p :=\n  rfl\n#align affine_equiv.coe_const_vsub AffineEquiv.coe_constVSub\n\n/- warning: affine_equiv.coe_const_vsub_symm -> AffineEquiv.coe_constVSub_symm is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (p : P₁), Eq.{max (succ u3) (succ u2)} (V₁ -> P₁) (coeFn.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u3, u3} k V₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)) _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u3, u3} k V₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)) _inst_2 _inst_3 _inst_4) => V₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u3, u3} k V₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)) _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u3, u3} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)) (AffineEquiv.constVSub.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 p))) (fun (v : V₁) => VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) (Neg.neg.{u3} V₁ (SubNegMonoid.toHasNeg.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) v) p)\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (p : P₁), Eq.{max (succ u3) (succ u2)} (forall (ᾰ : V₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V₁) => P₁) ᾰ) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AffineEquiv.{u1, u2, u3, u2, u2} k V₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_2 _inst_3 _inst_4) V₁ (fun (_x : V₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u3), succ u2, succ u3} (AffineEquiv.{u1, u2, u3, u2, u2} k V₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_2 _inst_3 _inst_4) V₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u3), succ u2, succ u3} (AffineEquiv.{u1, u2, u3, u2, u2} k V₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_2 _inst_3 _inst_4) V₁ P₁ (AffineEquiv.equivLike.{u1, u2, u3, u2, u2} k V₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u1, u3, u2, u2, u2} k P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) (AffineEquiv.constVSub.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 p))) (fun (v : V₁) => HVAdd.hVAdd.{u2, u3, u3} V₁ P₁ P₁ (instHVAdd.{u2, u3} V₁ P₁ (AddAction.toVAdd.{u2, u3} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) (Neg.neg.{u2} V₁ (NegZeroClass.toNeg.{u2} V₁ (SubNegZeroMonoid.toNegZeroClass.{u2} V₁ (SubtractionMonoid.toSubNegZeroMonoid.{u2} V₁ (SubtractionCommMonoid.toSubtractionMonoid.{u2} V₁ (AddCommGroup.toDivisionAddCommMonoid.{u2} V₁ _inst_2))))) v) p)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_const_vsub_symm AffineEquiv.coe_constVSub_symmₓ'. -/\n@[simp]\ntheorem coe_constVSub_symm (p : P₁) : ⇑(constVSub k p).symm = fun v => -v +ᵥ p :=\n  rfl\n#align affine_equiv.coe_const_vsub_symm AffineEquiv.coe_constVSub_symm\n\nvariable (P₁)\n\n#print AffineEquiv.constVAdd /-\n/-- The map `p ↦ v +ᵥ p` as an affine automorphism of an affine space.\n\nNote that there is no need for an `affine_map.const_vadd` as it is always an equivalence.\nThis is roughly to `distrib_mul_action.to_linear_equiv` as `+ᵥ` is to `•`. -/\n@[simps apply linear]\ndef constVAdd (v : V₁) : P₁ ≃ᵃ[k] P₁\n    where\n  toEquiv := Equiv.constVAdd P₁ v\n  linear := LinearEquiv.refl _ _\n  map_vadd' p w := vadd_comm _ _ _\n#align affine_equiv.const_vadd AffineEquiv.constVAdd\n-/\n\n/- warning: affine_equiv.const_vadd_zero -> AffineEquiv.constVAdd_zero is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (OfNat.ofNat.{u3} V₁ 0 (OfNat.mk.{u3} V₁ 0 (Zero.zero.{u3} V₁ (AddZeroClass.toHasZero.{u3} V₁ (AddMonoid.toAddZeroClass.{u3} V₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))))))))) (AffineEquiv.refl.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (OfNat.ofNat.{u2} V₁ 0 (Zero.toOfNat0.{u2} V₁ (NegZeroClass.toZero.{u2} V₁ (SubNegZeroMonoid.toNegZeroClass.{u2} V₁ (SubtractionMonoid.toSubNegZeroMonoid.{u2} V₁ (SubtractionCommMonoid.toSubtractionMonoid.{u2} V₁ (AddCommGroup.toDivisionAddCommMonoid.{u2} V₁ _inst_2)))))))) (AffineEquiv.refl.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.const_vadd_zero AffineEquiv.constVAdd_zeroₓ'. -/\n@[simp]\ntheorem constVAdd_zero : constVAdd k P₁ 0 = AffineEquiv.refl _ _ :=\n  ext <| zero_vadd _\n#align affine_equiv.const_vadd_zero AffineEquiv.constVAdd_zero\n\n/- warning: affine_equiv.const_vadd_add -> AffineEquiv.constVAdd_add is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (v : V₁) (w : V₁), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (HAdd.hAdd.{u3, u3, u3} V₁ V₁ V₁ (instHAdd.{u3} V₁ (AddZeroClass.toHasAdd.{u3} V₁ (AddMonoid.toAddZeroClass.{u3} V₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)))))) v w)) (AffineEquiv.trans.{u1, u2, u2, u2, u3, u3, u3} k P₁ P₁ P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 w) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v))\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (v : V₁) (w : V₁), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (HAdd.hAdd.{u2, u2, u2} V₁ V₁ V₁ (instHAdd.{u2} V₁ (AddZeroClass.toAdd.{u2} V₁ (AddMonoid.toAddZeroClass.{u2} V₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)))))) v w)) (AffineEquiv.trans.{u1, u3, u3, u3, u2, u2, u2} k P₁ P₁ P₁ V₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 w) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.const_vadd_add AffineEquiv.constVAdd_addₓ'. -/\n@[simp]\ntheorem constVAdd_add (v w : V₁) :\n    constVAdd k P₁ (v + w) = (constVAdd k P₁ w).trans (constVAdd k P₁ v) :=\n  ext <| add_vadd _ _\n#align affine_equiv.const_vadd_add AffineEquiv.constVAdd_add\n\n/- warning: affine_equiv.const_vadd_symm -> AffineEquiv.constVAdd_symm is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (v : V₁), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v)) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (Neg.neg.{u3} V₁ (SubNegMonoid.toHasNeg.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) v))\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (v : V₁), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v)) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (Neg.neg.{u2} V₁ (NegZeroClass.toNeg.{u2} V₁ (SubNegZeroMonoid.toNegZeroClass.{u2} V₁ (SubtractionMonoid.toSubNegZeroMonoid.{u2} V₁ (SubtractionCommMonoid.toSubtractionMonoid.{u2} V₁ (AddCommGroup.toDivisionAddCommMonoid.{u2} V₁ _inst_2))))) v))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.const_vadd_symm AffineEquiv.constVAdd_symmₓ'. -/\n@[simp]\ntheorem constVAdd_symm (v : V₁) : (constVAdd k P₁ v).symm = constVAdd k P₁ (-v) :=\n  ext fun _ => rfl\n#align affine_equiv.const_vadd_symm AffineEquiv.constVAdd_symm\n\n#print AffineEquiv.constVAddHom /-\n/-- A more bundled version of `affine_equiv.const_vadd`. -/\n@[simps]\ndef constVAddHom : Multiplicative V₁ →* P₁ ≃ᵃ[k] P₁\n    where\n  toFun v := constVAdd k P₁ v.toAdd\n  map_one' := constVAdd_zero _ _\n  map_mul' := constVAdd_add _ _\n#align affine_equiv.const_vadd_hom AffineEquiv.constVAddHom\n-/\n\n/- warning: affine_equiv.const_vadd_nsmul -> AffineEquiv.constVAdd_nsmul is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (n : Nat) (v : V₁), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (SMul.smul.{0, u3} Nat V₁ (AddMonoid.SMul.{u3} V₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)))) n v)) (HPow.hPow.{max u2 u3, 0, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Nat (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHPow.{max u2 u3, 0} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Nat (Monoid.Pow.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))))) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v) n)\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (n : Nat) (v : V₁), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (HSMul.hSMul.{0, u2, u2} Nat V₁ V₁ (instHSMul.{0, u2} Nat V₁ (AddMonoid.SMul.{u2} V₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))))) n v)) (HPow.hPow.{max u3 u2, 0, max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Nat (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHPow.{max u3 u2, 0} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Nat (Monoid.Pow.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4))))) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v) n)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.const_vadd_nsmul AffineEquiv.constVAdd_nsmulₓ'. -/\ntheorem constVAdd_nsmul (n : ℕ) (v : V₁) : constVAdd k P₁ (n • v) = constVAdd k P₁ v ^ n :=\n  (constVAddHom k P₁).map_pow _ _\n#align affine_equiv.const_vadd_nsmul AffineEquiv.constVAdd_nsmul\n\n/- warning: affine_equiv.const_vadd_zsmul -> AffineEquiv.constVAdd_zsmul is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) (P₁ : Type.{u2}) {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (z : Int) (v : V₁), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (SMul.smul.{0, u3} Int V₁ (SubNegMonoid.SMulInt.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) z v)) (HPow.hPow.{max u2 u3, 0, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Int (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHPow.{max u2 u3, 0} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Int (DivInvMonoid.Pow.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))) (AffineEquiv.constVAdd.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v) z)\nbut is expected to have type\n  forall (k : Type.{u1}) (P₁ : Type.{u3}) {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (z : Int) (v : V₁), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 (HSMul.hSMul.{0, u2, u2} Int V₁ V₁ (instHSMul.{0, u2} Int V₁ (SubNegMonoid.SMulInt.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)))) z v)) (HPow.hPow.{max u3 u2, 0, max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Int (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (instHPow.{max u3 u2, 0} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Int (DivInvMonoid.Pow.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4)))) (AffineEquiv.constVAdd.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 v) z)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.const_vadd_zsmul AffineEquiv.constVAdd_zsmulₓ'. -/\ntheorem constVAdd_zsmul (z : ℤ) (v : V₁) : constVAdd k P₁ (z • v) = constVAdd k P₁ v ^ z :=\n  (constVAddHom k P₁).map_zpow _ _\n#align affine_equiv.const_vadd_zsmul AffineEquiv.constVAdd_zsmul\n\nsection Homothety\n\nomit V₁\n\nvariable {R V P : Type _} [CommRing R] [AddCommGroup V] [Module R V] [affine_space V P]\n\ninclude V\n\n/- warning: affine_equiv.homothety_units_mul_hom -> AffineEquiv.homothetyUnitsMulHom is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {V : Type.{u2}} {P : Type.{u3}} [_inst_14 : CommRing.{u1} R] [_inst_15 : AddCommGroup.{u2} V] [_inst_16 : Module.{u1, u2} R V (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V _inst_15)] [_inst_17 : AddTorsor.{u2, u3} V P (AddCommGroup.toAddGroup.{u2} V _inst_15)], P -> (MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17)))))\nbut is expected to have type\n  forall {R : Type.{u1}} {V : Type.{u2}} {P : Type.{u3}} [_inst_14 : CommRing.{u1} R] [_inst_15 : AddCommGroup.{u2} V] [_inst_16 : Module.{u1, u2} R V (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V _inst_15)] [_inst_17 : AddTorsor.{u2, u3} V P (AddCommGroup.toAddGroup.{u2} V _inst_15)], P -> (MonoidHom.{u1, max u2 u3} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_14))))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u3} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u2 u3} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u2 u3} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17)))))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.homothety_units_mul_hom AffineEquiv.homothetyUnitsMulHomₓ'. -/\n/-- Fixing a point in affine space, homothety about this point gives a group homomorphism from (the\ncentre of) the units of the scalars into the group of affine equivalences. -/\ndef homothetyUnitsMulHom (p : P) : Rˣ →* P ≃ᵃ[R] P :=\n  equivUnitsAffineMap.symm.toMonoidHom.comp <| Units.map (AffineMap.homothetyHom p)\n#align affine_equiv.homothety_units_mul_hom AffineEquiv.homothetyUnitsMulHom\n\n/- warning: affine_equiv.coe_homothety_units_mul_hom_apply -> AffineEquiv.coe_homothetyUnitsMulHom_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {V : Type.{u2}} {P : Type.{u3}} [_inst_14 : CommRing.{u1} R] [_inst_15 : AddCommGroup.{u2} V] [_inst_16 : Module.{u1, u2} R V (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V _inst_15)] [_inst_17 : AddTorsor.{u2, u3} V P (AddCommGroup.toAddGroup.{u2} V _inst_15)] (p : P) (t : Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))), Eq.{succ u3} ((fun (_x : AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) => P -> P) (coeFn.{max (succ (max u3 u2)) (succ u1), max (succ u1) (succ (max u3 u2))} (MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (fun (_x : MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) => (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) -> (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (MonoidHom.hasCoeToFun.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (AffineEquiv.homothetyUnitsMulHom.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_16 _inst_17 p) t)) (coeFn.{max (succ u3) (succ u2), succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (fun (_x : AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) => P -> P) (AffineEquiv.hasCoeToFun.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (coeFn.{max (succ (max u3 u2)) (succ u1), max (succ u1) (succ (max u3 u2))} (MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (fun (_x : MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) => (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) -> (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (MonoidHom.hasCoeToFun.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (AffineEquiv.homothetyUnitsMulHom.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_16 _inst_17 p) t)) (coeFn.{max (succ u2) (succ u3), succ u3} (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (fun (_x : AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) => P -> P) (AffineMap.hasCoeToFun.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.homothety.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_17 _inst_16 p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (coeBase.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (Units.hasCoe.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14)))))) t)))\nbut is expected to have type\n  forall {R : Type.{u3}} {V : Type.{u1}} {P : Type.{u2}} [_inst_14 : CommRing.{u3} R] [_inst_15 : AddCommGroup.{u1} V] [_inst_16 : Module.{u3, u1} R V (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u1} V _inst_15)] [_inst_17 : AddTorsor.{u1, u2} V P (AddCommGroup.toAddGroup.{u1} V _inst_15)] (p : P) (t : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))), Eq.{succ u2} (forall (a : P), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P) => P) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P (fun (_x : P) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P) => P) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P P (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P P (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17))) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), succ u3, max (succ u1) (succ u2)} (MonoidHom.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (fun (_x : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) => AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) _x) (MulHomClass.toFunLike.{max (max u1 u2) u3, u3, max u1 u2} (MonoidHom.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulOneClass.toMul.{u3} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)))))) (MulOneClass.toMul.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (MonoidHomClass.toMulHomClass.{max (max u1 u2) u3, u3, max u1 u2} (MonoidHom.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17)))) (MonoidHom.monoidHomClass.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))))) (AffineEquiv.homothetyUnitsMulHom.{u3, u1, u2} R V P _inst_14 _inst_15 _inst_16 _inst_17 p) t)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u2} (AffineMap.{u3, u1, u2, u1, u2} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P (fun (_x : P) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P) => P) _x) (AffineMap.funLike.{u3, u1, u2, u1, u2} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.homothety.{u3, u1, u2} R V P _inst_14 _inst_15 _inst_17 _inst_16 p (Units.val.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)))) t)))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_homothety_units_mul_hom_apply AffineEquiv.coe_homothetyUnitsMulHom_applyₓ'. -/\n@[simp]\ntheorem coe_homothetyUnitsMulHom_apply (p : P) (t : Rˣ) :\n    (homothetyUnitsMulHom p t : P → P) = AffineMap.homothety p (t : R) :=\n  rfl\n#align affine_equiv.coe_homothety_units_mul_hom_apply AffineEquiv.coe_homothetyUnitsMulHom_apply\n\n/- warning: affine_equiv.coe_homothety_units_mul_hom_apply_symm -> AffineEquiv.coe_homothetyUnitsMulHom_apply_symm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {V : Type.{u2}} {P : Type.{u3}} [_inst_14 : CommRing.{u1} R] [_inst_15 : AddCommGroup.{u2} V] [_inst_16 : Module.{u1, u2} R V (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V _inst_15)] [_inst_17 : AddTorsor.{u2, u3} V P (AddCommGroup.toAddGroup.{u2} V _inst_15)] (p : P) (t : Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))), Eq.{succ u3} ((fun (_x : AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) => P -> P) (AffineEquiv.symm.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17 (coeFn.{max (succ (max u3 u2)) (succ u1), max (succ u1) (succ (max u3 u2))} (MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (fun (_x : MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) => (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) -> (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (MonoidHom.hasCoeToFun.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (AffineEquiv.homothetyUnitsMulHom.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_16 _inst_17 p) t))) (coeFn.{max (succ u3) (succ u2), succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (fun (_x : AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) => P -> P) (AffineEquiv.hasCoeToFun.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.symm.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17 (coeFn.{max (succ (max u3 u2)) (succ u1), max (succ u1) (succ (max u3 u2))} (MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (fun (_x : MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) => (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) -> (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (MonoidHom.hasCoeToFun.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (AffineEquiv.homothetyUnitsMulHom.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_16 _inst_17 p) t))) (coeFn.{max (succ u2) (succ u3), succ u3} (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (fun (_x : AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) => P -> P) (AffineMap.hasCoeToFun.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.homothety.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_17 _inst_16 p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (coeBase.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (Units.hasCoe.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14)))))) (Inv.inv.{u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Units.hasInv.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) t))))\nbut is expected to have type\n  forall {R : Type.{u3}} {V : Type.{u1}} {P : Type.{u2}} [_inst_14 : CommRing.{u3} R] [_inst_15 : AddCommGroup.{u1} V] [_inst_16 : Module.{u3, u1} R V (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u1} V _inst_15)] [_inst_17 : AddTorsor.{u1, u2} V P (AddCommGroup.toAddGroup.{u1} V _inst_15)] (p : P) (t : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))), Eq.{succ u2} (forall (a : P), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P) => P) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P (fun (_x : P) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P) => P) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P P (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P P (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17))) (AffineEquiv.symm.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17 (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), succ u3, max (succ u1) (succ u2)} (MonoidHom.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (fun (_x : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) => AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) _x) (MulHomClass.toFunLike.{max (max u1 u2) u3, u3, max u1 u2} (MonoidHom.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulOneClass.toMul.{u3} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)))))) (MulOneClass.toMul.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (MonoidHomClass.toMulHomClass.{max (max u1 u2) u3, u3, max u1 u2} (MonoidHom.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17)))) (MonoidHom.monoidHomClass.{u3, max u1 u2} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u1 u2} (AffineEquiv.{u3, u2, u2, u1, u1} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u2, u1} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))))) (AffineEquiv.homothetyUnitsMulHom.{u3, u1, u2} R V P _inst_14 _inst_15 _inst_16 _inst_17 p) t))) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u2} (AffineMap.{u3, u1, u2, u1, u2} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) P (fun (_x : P) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P) => P) _x) (AffineMap.funLike.{u3, u1, u2, u1, u2} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.homothety.{u3, u1, u2} R V P _inst_14 _inst_15 _inst_17 _inst_16 p (Units.val.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)))) (Inv.inv.{u3} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Units.instInvUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) t))))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_homothety_units_mul_hom_apply_symm AffineEquiv.coe_homothetyUnitsMulHom_apply_symmₓ'. -/\n@[simp]\ntheorem coe_homothetyUnitsMulHom_apply_symm (p : P) (t : Rˣ) :\n    ((homothetyUnitsMulHom p t).symm : P → P) = AffineMap.homothety p (↑t⁻¹ : R) :=\n  rfl\n#align affine_equiv.coe_homothety_units_mul_hom_apply_symm AffineEquiv.coe_homothetyUnitsMulHom_apply_symm\n\n/- warning: affine_equiv.coe_homothety_units_mul_hom_eq_homothety_hom_coe -> AffineEquiv.coe_homothetyUnitsMulHom_eq_homothetyHom_coe is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {V : Type.{u2}} {P : Type.{u3}} [_inst_14 : CommRing.{u1} R] [_inst_15 : AddCommGroup.{u2} V] [_inst_16 : Module.{u1, u2} R V (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V _inst_15)] [_inst_17 : AddTorsor.{u2, u3} V P (AddCommGroup.toAddGroup.{u2} V _inst_15)] (p : P), Eq.{max (succ u1) (succ u2) (succ u3)} ((Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) -> (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (Function.comp.{succ u1, max (succ u3) (succ u2), max (succ u2) (succ u3)} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) ((fun (a : Sort.{max (succ u3) (succ u2)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u3) (succ u2), max (succ u2) (succ u3)} a b] => self.0) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (HasLiftT.mk.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (CoeTCₓ.coe.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (coeBase.{max (succ u3) (succ u2), max (succ u2) (succ u3)} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.AffineMap.hasCoe.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17))))) (coeFn.{max (succ (max u3 u2)) (succ u1), max (succ u1) (succ (max u3 u2))} (MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (fun (_x : MonoidHom.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) => (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) -> (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (MonoidHom.hasCoeToFun.{u1, max u3 u2} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.mulOneClass.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) (Monoid.toMulOneClass.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} R P P V V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u1, u3, u2} R P V (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))))) (AffineEquiv.homothetyUnitsMulHom.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_16 _inst_17 p))) (Function.comp.{succ u1, succ u1, max (succ u2) (succ u3)} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (coeFn.{max (succ (max u2 u3)) (succ u1), max (succ u1) (succ (max u2 u3))} (MonoidHom.{u1, max u2 u3} R (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u3} (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.monoid.{u1, u2, u3} R V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))) (fun (_x : MonoidHom.{u1, max u2 u3} R (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u3} (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.monoid.{u1, u2, u3} R V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))) => R -> (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (MonoidHom.hasCoeToFun.{u1, max u2 u3} R (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (NonAssocRing.toNonAssocSemiring.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u3} (AffineMap.{u1, u2, u3, u2, u3} R V P V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.monoid.{u1, u2, u3} R V P (CommRing.toRing.{u1} R _inst_14) _inst_15 _inst_16 _inst_17))) (AffineMap.homothetyHom.{u1, u2, u3} R V P _inst_14 _inst_15 _inst_17 _inst_16 p)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (coeBase.{succ u1, succ u1} (Units.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))) R (Units.hasCoe.{u1} R (Ring.toMonoid.{u1} R (CommRing.toRing.{u1} R _inst_14))))))))\nbut is expected to have type\n  forall {R : Type.{u3}} {V : Type.{u2}} {P : Type.{u1}} [_inst_14 : CommRing.{u3} R] [_inst_15 : AddCommGroup.{u2} V] [_inst_16 : Module.{u3, u2} R V (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V _inst_15)] [_inst_17 : AddTorsor.{u2, u1} V P (AddCommGroup.toAddGroup.{u2} V _inst_15)] (p : P), Eq.{max (max (succ u3) (succ u2)) (succ u1)} ((Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) -> (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17)) (Function.comp.{succ u3, max (succ u2) (succ u1), max (succ u2) (succ u1)} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.toAffineMap.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), succ u3, max (succ u2) (succ u1)} (MonoidHom.{u3, max u2 u1} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u1, u2} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (fun (_x : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) => AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) _x) (MulHomClass.toFunLike.{max (max u2 u1) u3, u3, max u2 u1} (MonoidHom.{u3, max u2 u1} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u1, u2} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulOneClass.toMul.{u3} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)))))) (MulOneClass.toMul.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u1, u2} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (MonoidHomClass.toMulHomClass.{max (max u2 u1) u3, u3, max u2 u1} (MonoidHom.{u3, max u2 u1} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u1, u2} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u1, u2} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17)))) (MonoidHom.monoidHomClass.{u3, max u2 u1} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Units.instMulOneClassUnits.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (DivInvMonoid.toMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Group.toDivInvMonoid.{max u2 u1} (AffineEquiv.{u3, u1, u1, u2, u2} R P P V V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineEquiv.group.{u3, u1, u2} R P V (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))))) (AffineEquiv.homothetyUnitsMulHom.{u3, u2, u1} R V P _inst_14 _inst_15 _inst_16 _inst_17 p))) (Function.comp.{succ u3, succ u3, max (succ u2) (succ u1)} (Units.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) R (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), succ u3, max (succ u2) (succ u1)} (MonoidHom.{u3, max u1 u2} R (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u3} R (NonAssocSemiring.toMulZeroOneClass.{u3} R (Semiring.toNonAssocSemiring.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.instMonoidAffineMap.{u3, u2, u1} R V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) _x) (MulHomClass.toFunLike.{max (max u2 u1) u3, u3, max u2 u1} (MonoidHom.{u3, max u1 u2} R (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u3} R (NonAssocSemiring.toMulZeroOneClass.{u3} R (Semiring.toNonAssocSemiring.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.instMonoidAffineMap.{u3, u2, u1} R V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))) R (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulOneClass.toMul.{u3} R (MulZeroOneClass.toMulOneClass.{u3} R (NonAssocSemiring.toMulZeroOneClass.{u3} R (Semiring.toNonAssocSemiring.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14)))))) (MulOneClass.toMul.{max u2 u1} (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (Monoid.toMulOneClass.{max u2 u1} (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.instMonoidAffineMap.{u3, u2, u1} R V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))) (MonoidHomClass.toMulHomClass.{max (max u2 u1) u3, u3, max u2 u1} (MonoidHom.{u3, max u1 u2} R (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u3} R (NonAssocSemiring.toMulZeroOneClass.{u3} R (Semiring.toNonAssocSemiring.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.instMonoidAffineMap.{u3, u2, u1} R V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))) R (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u3} R (NonAssocSemiring.toMulZeroOneClass.{u3} R (Semiring.toNonAssocSemiring.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.instMonoidAffineMap.{u3, u2, u1} R V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17)) (MonoidHom.monoidHomClass.{u3, max u2 u1} R (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (MulZeroOneClass.toMulOneClass.{u3} R (NonAssocSemiring.toMulZeroOneClass.{u3} R (Semiring.toNonAssocSemiring.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))) (Monoid.toMulOneClass.{max u2 u1} (AffineMap.{u3, u2, u1, u2, u1} R V P V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17 _inst_15 _inst_16 _inst_17) (AffineMap.instMonoidAffineMap.{u3, u2, u1} R V P (CommRing.toRing.{u3} R _inst_14) _inst_15 _inst_16 _inst_17))))) (AffineMap.homothetyHom.{u3, u2, u1} R V P _inst_14 _inst_15 _inst_17 _inst_16 p)) (Units.val.{u3} R (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (Ring.toSemiring.{u3} R (CommRing.toRing.{u3} R _inst_14))))))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_homothety_units_mul_hom_eq_homothety_hom_coe AffineEquiv.coe_homothetyUnitsMulHom_eq_homothetyHom_coeₓ'. -/\n@[simp]\ntheorem coe_homothetyUnitsMulHom_eq_homothetyHom_coe (p : P) :\n    (coe : (P ≃ᵃ[R] P) → P →ᵃ[R] P) ∘ homothetyUnitsMulHom p =\n      AffineMap.homothetyHom p ∘ (coe : Rˣ → R) :=\n  funext fun _ => rfl\n#align affine_equiv.coe_homothety_units_mul_hom_eq_homothety_hom_coe AffineEquiv.coe_homothetyUnitsMulHom_eq_homothetyHom_coe\n\nend Homothety\n\nvariable {P₁}\n\nopen Function\n\n#print AffineEquiv.pointReflection /-\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P₁) : P₁ ≃ᵃ[k] P₁ :=\n  (constVSub k x).trans (vaddConst k x)\n#align affine_equiv.point_reflection AffineEquiv.pointReflection\n-/\n\n/- warning: affine_equiv.point_reflection_apply -> AffineEquiv.pointReflection_apply is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (x : P₁) (y : P₁), Eq.{succ u2} P₁ (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y) (VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) (VSub.vsub.{u3, u2} V₁ P₁ (AddTorsor.toHasVsub.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4) x y) x)\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (x : P₁) (y : P₁), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) y) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y) (HVAdd.hVAdd.{u2, u3, u3} V₁ P₁ P₁ (instHVAdd.{u2, u3} V₁ P₁ (AddAction.toVAdd.{u2, u3} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) (VSub.vsub.{u2, u3} V₁ P₁ (AddTorsor.toVSub.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4) x y) x)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_apply AffineEquiv.pointReflection_applyₓ'. -/\ntheorem pointReflection_apply (x y : P₁) : pointReflection k x y = x -ᵥ y +ᵥ x :=\n  rfl\n#align affine_equiv.point_reflection_apply AffineEquiv.pointReflection_apply\n\n/- warning: affine_equiv.point_reflection_symm -> AffineEquiv.pointReflection_symm is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (x : P₁), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x)) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x)\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (x : P₁), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x)) (AffineEquiv.pointReflection.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_symm AffineEquiv.pointReflection_symmₓ'. -/\n@[simp]\ntheorem pointReflection_symm (x : P₁) : (pointReflection k x).symm = pointReflection k x :=\n  toEquiv_injective <| Equiv.pointReflection_symm x\n#align affine_equiv.point_reflection_symm AffineEquiv.pointReflection_symm\n\n/- warning: affine_equiv.to_equiv_point_reflection -> AffineEquiv.toEquiv_pointReflection is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (x : P₁), Eq.{succ u2} (Equiv.{succ u2, succ u2} P₁ P₁) (AffineEquiv.toEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x)) (Equiv.pointReflection.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4 x)\nbut is expected to have type\n  forall (k : Type.{u2}) {P₁ : Type.{u3}} {V₁ : Type.{u1}} [_inst_1 : Ring.{u2} k] [_inst_2 : AddCommGroup.{u1} V₁] [_inst_3 : Module.{u2, u1} k V₁ (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₁ _inst_2)] [_inst_4 : AddTorsor.{u1, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2)] (x : P₁), Eq.{succ u3} (Equiv.{succ u3, succ u3} P₁ P₁) (AffineEquiv.toEquiv.{u2, u3, u3, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u2, u3, u1} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x)) (Equiv.pointReflection.{u1, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2) _inst_4 x)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_equiv_point_reflection AffineEquiv.toEquiv_pointReflectionₓ'. -/\n@[simp]\ntheorem toEquiv_pointReflection (x : P₁) :\n    (pointReflection k x).toEquiv = Equiv.pointReflection x :=\n  rfl\n#align affine_equiv.to_equiv_point_reflection AffineEquiv.toEquiv_pointReflection\n\n/- warning: affine_equiv.point_reflection_self -> AffineEquiv.pointReflection_self is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (x : P₁), Eq.{succ u2} P₁ (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) x) x\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (x : P₁), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) x) x\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_self AffineEquiv.pointReflection_selfₓ'. -/\n@[simp]\ntheorem pointReflection_self (x : P₁) : pointReflection k x x = x :=\n  vsub_vadd _ _\n#align affine_equiv.point_reflection_self AffineEquiv.pointReflection_self\n\n/- warning: affine_equiv.point_reflection_involutive -> AffineEquiv.pointReflection_involutive is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (x : P₁), Function.Involutive.{succ u2} P₁ (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x))\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (x : P₁), Function.Involutive.{succ u3} P₁ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u3, u2} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_involutive AffineEquiv.pointReflection_involutiveₓ'. -/\ntheorem pointReflection_involutive (x : P₁) : Involutive (pointReflection k x : P₁ → P₁) :=\n  Equiv.pointReflection_involutive x\n#align affine_equiv.point_reflection_involutive AffineEquiv.pointReflection_involutive\n\n/- warning: affine_equiv.point_reflection_fixed_iff_of_injective_bit0 -> AffineEquiv.pointReflection_fixed_iff_of_injective_bit0 is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] {x : P₁} {y : P₁}, (Function.Injective.{succ u3, succ u3} V₁ V₁ (bit0.{u3} V₁ (AddZeroClass.toHasAdd.{u3} V₁ (AddMonoid.toAddZeroClass.{u3} V₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))))))) -> (Iff (Eq.{succ u2} P₁ (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P₁ y x))\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] {x : P₁} {y : P₁}, (Function.Injective.{succ u3, succ u3} V₁ V₁ (bit0.{u3} V₁ (AddZeroClass.toAdd.{u3} V₁ (AddMonoid.toAddZeroClass.{u3} V₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))))))) -> (Iff (Eq.{succ u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) y) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P₁ y x))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_fixed_iff_of_injective_bit0 AffineEquiv.pointReflection_fixed_iff_of_injective_bit0ₓ'. -/\n/-- `x` is the only fixed point of `point_reflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P₁} (h : Injective (bit0 : V₁ → V₁)) :\n    pointReflection k x y = y ↔ y = x :=\n  Equiv.pointReflection_fixed_iff_of_injective_bit0 h\n#align affine_equiv.point_reflection_fixed_iff_of_injective_bit0 AffineEquiv.pointReflection_fixed_iff_of_injective_bit0\n\n/- warning: affine_equiv.injective_point_reflection_left_of_injective_bit0 -> AffineEquiv.injective_pointReflection_left_of_injective_bit0 is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], (Function.Injective.{succ u3, succ u3} V₁ V₁ (bit0.{u3} V₁ (AddZeroClass.toHasAdd.{u3} V₁ (AddMonoid.toAddZeroClass.{u3} V₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))))))) -> (forall (y : P₁), Function.Injective.{succ u2, succ u2} P₁ P₁ (fun (x : P₁) => coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y))\nbut is expected to have type\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)], (Function.Injective.{succ u3, succ u3} V₁ V₁ (bit0.{u3} V₁ (AddZeroClass.toAdd.{u3} V₁ (AddMonoid.toAddZeroClass.{u3} V₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))))))) -> (forall (y : P₁), Function.Injective.{succ u2, succ u2} P₁ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) y) (fun (x : P₁) => FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.injective_point_reflection_left_of_injective_bit0 AffineEquiv.injective_pointReflection_left_of_injective_bit0ₓ'. -/\ntheorem injective_pointReflection_left_of_injective_bit0 (h : Injective (bit0 : V₁ → V₁)) (y : P₁) :\n    Injective fun x : P₁ => pointReflection k x y :=\n  Equiv.injective_pointReflection_left_of_injective_bit0 h y\n#align affine_equiv.injective_point_reflection_left_of_injective_bit0 AffineEquiv.injective_pointReflection_left_of_injective_bit0\n\n/- warning: affine_equiv.injective_point_reflection_left_of_module -> AffineEquiv.injective_pointReflection_left_of_module is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] [_inst_14 : Invertible.{u1} k (Distrib.toHasMul.{u1} k (Ring.toDistrib.{u1} k _inst_1)) (AddMonoidWithOne.toOne.{u1} k (AddGroupWithOne.toAddMonoidWithOne.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) (OfNat.ofNat.{u1} k 2 (OfNat.mk.{u1} k 2 (bit0.{u1} k (Distrib.toHasAdd.{u1} k (Ring.toDistrib.{u1} k _inst_1)) (One.one.{u1} k (AddMonoidWithOne.toOne.{u1} k (AddGroupWithOne.toAddMonoidWithOne.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1))))))))] (y : P₁), Function.Injective.{succ u2, succ u2} P₁ P₁ (fun (x : P₁) => coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y)\nbut is expected to have type\n  forall (k : Type.{u3}) {P₁ : Type.{u2}} {V₁ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V₁] [_inst_3 : Module.{u3, u1} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₁ _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2)] [_inst_14 : Invertible.{u3} k (NonUnitalNonAssocRing.toMul.{u3} k (NonUnitalRing.toNonUnitalNonAssocRing.{u3} k (Ring.toNonUnitalRing.{u3} k _inst_1))) (Semiring.toOne.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (OfNat.ofNat.{u3} k 2 (instOfNat.{u3} k 2 (Semiring.toNatCast.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))] (y : P₁), Function.Injective.{succ u2, succ u2} P₁ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) y) (fun (x : P₁) => FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u3, u2, u1} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.injective_point_reflection_left_of_module AffineEquiv.injective_pointReflection_left_of_moduleₓ'. -/\ntheorem injective_pointReflection_left_of_module [Invertible (2 : k)] :\n    ∀ y, Injective fun x : P₁ => pointReflection k x y :=\n  injective_pointReflection_left_of_injective_bit0 k fun x y h => by\n    rwa [bit0, bit0, ← two_smul k x, ← two_smul k y,\n      (isUnit_of_invertible (2 : k)).smul_left_cancel] at h\n#align affine_equiv.injective_point_reflection_left_of_module AffineEquiv.injective_pointReflection_left_of_module\n\n/- warning: affine_equiv.point_reflection_fixed_iff_of_module -> AffineEquiv.pointReflection_fixed_iff_of_module is a dubious translation:\nlean 3 declaration is\n  forall (k : Type.{u1}) {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] [_inst_14 : Invertible.{u1} k (Distrib.toHasMul.{u1} k (Ring.toDistrib.{u1} k _inst_1)) (AddMonoidWithOne.toOne.{u1} k (AddGroupWithOne.toAddMonoidWithOne.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) (OfNat.ofNat.{u1} k 2 (OfNat.mk.{u1} k 2 (bit0.{u1} k (Distrib.toHasAdd.{u1} k (Ring.toDistrib.{u1} k _inst_1)) (One.one.{u1} k (AddMonoidWithOne.toOne.{u1} k (AddGroupWithOne.toAddMonoidWithOne.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1))))))))] {x : P₁} {y : P₁}, Iff (Eq.{succ u2} P₁ (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P₁ y x)\nbut is expected to have type\n  forall (k : Type.{u3}) {P₁ : Type.{u2}} {V₁ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V₁] [_inst_3 : Module.{u3, u1} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₁ _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u1} V₁ _inst_2)] [_inst_14 : Invertible.{u3} k (NonUnitalNonAssocRing.toMul.{u3} k (NonUnitalRing.toNonUnitalNonAssocRing.{u3} k (Ring.toNonUnitalRing.{u3} k _inst_1))) (Semiring.toOne.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (OfNat.ofNat.{u3} k 2 (instOfNat.{u3} k 2 (Semiring.toNatCast.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))] {x : P₁} {y : P₁}, Iff (Eq.{succ u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) y) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P₁ P₁ V₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u3, u2, u1} k P₁ V₁ _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P₁ y x)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_fixed_iff_of_module AffineEquiv.pointReflection_fixed_iff_of_moduleₓ'. -/\ntheorem pointReflection_fixed_iff_of_module [Invertible (2 : k)] {x y : P₁} :\n    pointReflection k x y = y ↔ y = x :=\n  ((injective_pointReflection_left_of_module k y).eq_iff' (pointReflection_self k y)).trans eq_comm\n#align affine_equiv.point_reflection_fixed_iff_of_module AffineEquiv.pointReflection_fixed_iff_of_module\n\nend AffineEquiv\n\nnamespace LinearEquiv\n\n#print LinearEquiv.toAffineEquiv /-\n/-- Interpret a linear equivalence between modules as an affine equivalence. -/\ndef toAffineEquiv (e : V₁ ≃ₗ[k] V₂) : V₁ ≃ᵃ[k] V₂\n    where\n  toEquiv := e.toEquiv\n  linear := e\n  map_vadd' p v := e.map_add v p\n#align linear_equiv.to_affine_equiv LinearEquiv.toAffineEquiv\n-/\n\n/- warning: linear_equiv.coe_to_affine_equiv -> LinearEquiv.coe_toAffineEquiv is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V₁ : Type.{u2}} {V₂ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u3} V₂] [_inst_6 : Module.{u1, u3} k V₂ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5)] (e : LinearEquiv.{u1, u1, u2, u3} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5) _inst_3 _inst_6), Eq.{max (succ u2) (succ u3)} (V₁ -> V₂) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u2, u3} k V₁ V₂ V₁ V₂ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u3} V₂ (AddCommGroup.toAddGroup.{u3} V₂ _inst_5))) (fun (_x : AffineEquiv.{u1, u2, u3, u2, u3} k V₁ V₂ V₁ V₂ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u3} V₂ (AddCommGroup.toAddGroup.{u3} V₂ _inst_5))) => V₁ -> V₂) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u2, u3} k V₁ V₂ V₁ V₂ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u3} V₂ (AddCommGroup.toAddGroup.{u3} V₂ _inst_5))) (LinearEquiv.toAffineEquiv.{u1, u2, u3} k V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_5 _inst_6 e)) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearEquiv.{u1, u1, u2, u3} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5) _inst_3 _inst_6) (fun (_x : LinearEquiv.{u1, u1, u2, u3} k k (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5) _inst_3 _inst_6) => V₁ -> V₂) (LinearEquiv.hasCoeToFun.{u1, u1, u2, u3} k k V₁ V₂ (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHom.id.{u1} k (Semiring.toNonAssocSemiring.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (RingHomInvPair.ids.{u1} k (Ring.toSemiring.{u1} k _inst_1))) e)\nbut is expected to have type\n  forall {k : Type.{u3}} {V₁ : Type.{u2}} {V₂ : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_5 : AddCommGroup.{u1} V₂] [_inst_6 : Module.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)] (e : LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : V₁), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V₁) => V₂) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (AffineEquiv.{u3, u2, u1, u2, u1} k V₁ V₂ V₁ V₂ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5))) V₁ (fun (_x : V₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V₁) => V₂) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (AffineEquiv.{u3, u2, u1, u2, u1} k V₁ V₂ V₁ V₂ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5))) V₁ V₂ (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u1} (AffineEquiv.{u3, u2, u1, u2, u1} k V₁ V₂ V₁ V₂ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5))) V₁ V₂ (AffineEquiv.equivLike.{u3, u2, u1, u2, u1} k V₁ V₂ V₁ V₂ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V₂ (AddCommGroup.toAddGroup.{u1} V₂ _inst_5))))) (LinearEquiv.toAffineEquiv.{u3, u2, u1} k V₁ V₂ _inst_1 _inst_2 _inst_3 _inst_5 _inst_6 e)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) V₁ (fun (_x : V₁) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V₁) => V₂) _x) (SMulHomClass.toFunLike.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (SMulZeroClass.toSMul.{u3, u2} k V₁ (AddMonoid.toZero.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V₁ (AddMonoid.toAddZeroClass.{u2} V₁ (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V₁ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V₂ (AddMonoid.toZero.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V₂ (AddMonoid.toAddZeroClass.{u1} V₂ (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6)))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u3, u2, u1} (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) k V₁ V₂ (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V₁ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V₂ (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5)) (Module.toDistribMulAction.{u3, u2} k V₁ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V₂ (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V₁ V₂ (LinearEquiv.{u3, u3, u2, u1} k k (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) V₁ V₂ (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (LinearEquiv.instSemilinearEquivClassLinearEquiv.{u3, u3, u2, u1} k k V₁ V₂ (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V₂ _inst_5) _inst_3 _inst_6 (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHom.id.{u3} k (Semiring.toNonAssocSemiring.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1)) (RingHomInvPair.ids.{u3} k (Ring.toSemiring.{u3} k _inst_1))))))) e)\nCase conversion may be inaccurate. Consider using '#align linear_equiv.coe_to_affine_equiv LinearEquiv.coe_toAffineEquivₓ'. -/\n@[simp]\ntheorem coe_toAffineEquiv (e : V₁ ≃ₗ[k] V₂) : ⇑e.toAffineEquiv = e :=\n  rfl\n#align linear_equiv.coe_to_affine_equiv LinearEquiv.coe_toAffineEquiv\n\nend LinearEquiv\n\nnamespace AffineMap\n\nopen AffineEquiv\n\ninclude V₁\n\n/- warning: affine_map.line_map_vadd -> AffineMap.lineMap_vadd is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (v : V₁) (v' : V₁) (p : P₁) (c : k), Eq.{succ u2} P₁ (VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (AffineMap.{u1, u1, u1, u3, u3} k k k V₁ V₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (fun (_x : AffineMap.{u1, u1, u1, u3, u3} k k k V₁ V₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) => k -> V₁) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u3} k k k V₁ V₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AffineMap.lineMap.{u1, u3, u3} k V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)) v v') c) p) (coeFn.{max (succ u1) (succ u3) (succ u2), max (succ u1) (succ u2)} (AffineMap.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (fun (_x : AffineMap.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) => k -> P₁) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 (VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) v p) (VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) v' p)) c)\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (v : V₁) (v' : V₁) (p : P₁) (c : k), Eq.{succ u3} P₁ (HVAdd.hVAdd.{u2, u3, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) P₁ P₁ (instHVAdd.{u2, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) P₁ (AddAction.toVAdd.{u2, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) P₁ (SubNegMonoid.toAddMonoid.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) (AddGroup.toSubNegMonoid.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) (AddCommGroup.toAddGroup.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) _inst_2))) (AddTorsor.toAddAction.{u2, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) P₁ (AddCommGroup.toAddGroup.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) c) _inst_2) _inst_4))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (AffineMap.{u1, u1, u1, u2, u2} k k k V₁ V₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) k (fun (_x : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V₁) _x) (AffineMap.funLike.{u1, u1, u1, u2, u2} k k k V₁ V₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AffineMap.lineMap.{u1, u2, u2} k V₁ V₁ _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)) v v') c) p) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), succ u1, succ u3} (AffineMap.{u1, u1, u1, u2, u3} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 _inst_4) k (fun (_x : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) _x) (AffineMap.funLike.{u1, u1, u1, u2, u3} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 (HVAdd.hVAdd.{u2, u3, u3} V₁ P₁ P₁ (instHVAdd.{u2, u3} V₁ P₁ (AddAction.toVAdd.{u2, u3} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p) (HVAdd.hVAdd.{u2, u3, u3} V₁ P₁ P₁ (instHVAdd.{u2, u3} V₁ P₁ (AddAction.toVAdd.{u2, u3} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v' p)) c)\nCase conversion may be inaccurate. Consider using '#align affine_map.line_map_vadd AffineMap.lineMap_vaddₓ'. -/\ntheorem lineMap_vadd (v v' : V₁) (p : P₁) (c : k) :\n    lineMap v v' c +ᵥ p = lineMap (v +ᵥ p) (v' +ᵥ p) c :=\n  (vaddConst k p).apply_lineMap v v' c\n#align affine_map.line_map_vadd AffineMap.lineMap_vadd\n\n#print AffineMap.lineMap_vsub /-\ntheorem lineMap_vsub (p₁ p₂ p₃ : P₁) (c : k) :\n    lineMap p₁ p₂ c -ᵥ p₃ = lineMap (p₁ -ᵥ p₃) (p₂ -ᵥ p₃) c :=\n  (vaddConst k p₃).symm.apply_lineMap p₁ p₂ c\n#align affine_map.line_map_vsub AffineMap.lineMap_vsub\n-/\n\n#print AffineMap.vsub_lineMap /-\ntheorem vsub_lineMap (p₁ p₂ p₃ : P₁) (c : k) :\n    p₁ -ᵥ lineMap p₂ p₃ c = lineMap (p₁ -ᵥ p₂) (p₁ -ᵥ p₃) c :=\n  (constVSub k p₁).apply_lineMap p₂ p₃ c\n#align affine_map.vsub_line_map AffineMap.vsub_lineMap\n-/\n\n/- warning: affine_map.vadd_line_map -> AffineMap.vadd_lineMap is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P₁ : Type.{u2}} {V₁ : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V₁] [_inst_3 : Module.{u1, u3} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V₁ _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2)] (v : V₁) (p₁ : P₁) (p₂ : P₁) (c : k), Eq.{succ u2} P₁ (VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) v (coeFn.{max (succ u1) (succ u3) (succ u2), max (succ u1) (succ u2)} (AffineMap.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (fun (_x : AffineMap.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) => k -> P₁) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 p₁ p₂) c)) (coeFn.{max (succ u1) (succ u3) (succ u2), max (succ u1) (succ u2)} (AffineMap.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (fun (_x : AffineMap.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) => k -> P₁) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u2} k k k V₁ P₁ _inst_1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k _inst_1))) (Semiring.toModule.{u1} k (Ring.toSemiring.{u1} k _inst_1)) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (AddCommGroupWithOne.toAddGroupWithOne.{u1} k (Ring.toAddCommGroupWithOne.{u1} k _inst_1)))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u1, u3, u2} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 (VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) v p₁) (VAdd.vadd.{u3, u2} V₁ P₁ (AddAction.toHasVadd.{u3, u2} V₁ P₁ (SubNegMonoid.toAddMonoid.{u3} V₁ (AddGroup.toSubNegMonoid.{u3} V₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2))) (AddTorsor.toAddAction.{u3, u2} V₁ P₁ (AddCommGroup.toAddGroup.{u3} V₁ _inst_2) _inst_4)) v p₂)) c)\nbut is expected to have type\n  forall {k : Type.{u1}} {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V₁] [_inst_3 : Module.{u1, u2} k V₁ (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] (v : V₁) (p₁ : P₁) (p₂ : P₁) (c : k), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) c) (HVAdd.hVAdd.{u2, u3, u3} V₁ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) c) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) c) (instHVAdd.{u2, u3} V₁ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) c) (AddAction.toVAdd.{u2, u3} V₁ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) c) (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u3} V₁ ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) c) (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), succ u1, succ u3} (AffineMap.{u1, u1, u1, u2, u3} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 _inst_4) k (fun (_x : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) _x) (AffineMap.funLike.{u1, u1, u1, u2, u3} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 p₁ p₂) c)) (FunLike.coe.{max (max (succ u1) (succ u2)) (succ u3), succ u1, succ u3} (AffineMap.{u1, u1, u1, u2, u3} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 _inst_4) k (fun (_x : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P₁) _x) (AffineMap.funLike.{u1, u1, u1, u2, u3} k k k V₁ P₁ _inst_1 (Ring.toAddCommGroup.{u1} k _inst_1) (AffineMap.instModuleToSemiringToAddCommMonoidToNonUnitalNonAssocSemiringToNonUnitalNonAssocRingToNonUnitalRing.{u1} k _inst_1) (addGroupIsAddTorsor.{u1} k (AddGroupWithOne.toAddGroup.{u1} k (Ring.toAddGroupWithOne.{u1} k _inst_1))) _inst_2 _inst_3 _inst_4) (AffineMap.lineMap.{u1, u2, u3} k V₁ P₁ _inst_1 _inst_2 _inst_3 _inst_4 (HVAdd.hVAdd.{u2, u3, u3} V₁ P₁ P₁ (instHVAdd.{u2, u3} V₁ P₁ (AddAction.toVAdd.{u2, u3} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p₁) (HVAdd.hVAdd.{u2, u3, u3} V₁ P₁ P₁ (instHVAdd.{u2, u3} V₁ P₁ (AddAction.toVAdd.{u2, u3} V₁ P₁ (SubNegMonoid.toAddMonoid.{u2} V₁ (AddGroup.toSubNegMonoid.{u2} V₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2))) (AddTorsor.toAddAction.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2) _inst_4))) v p₂)) c)\nCase conversion may be inaccurate. Consider using '#align affine_map.vadd_line_map AffineMap.vadd_lineMapₓ'. -/\ntheorem vadd_lineMap (v : V₁) (p₁ p₂ : P₁) (c : k) :\n    v +ᵥ lineMap p₁ p₂ c = lineMap (v +ᵥ p₁) (v +ᵥ p₂) c :=\n  (constVAdd k P₁ v).apply_lineMap p₁ p₂ c\n#align affine_map.vadd_line_map AffineMap.vadd_lineMap\n\nvariable {R' : Type _} [CommRing R'] [Module R' V₁]\n\n/- warning: affine_map.homothety_neg_one_apply -> AffineMap.homothety_neg_one_apply is a dubious translation:\nlean 3 declaration is\n  forall {P₁ : Type.{u1}} {V₁ : Type.{u2}} [_inst_2 : AddCommGroup.{u2} V₁] [_inst_4 : AddTorsor.{u2, u1} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] {R' : Type.{u3}} [_inst_14 : CommRing.{u3} R'] [_inst_15 : Module.{u3, u2} R' V₁ (Ring.toSemiring.{u3} R' (CommRing.toRing.{u3} R' _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] (c : P₁) (p : P₁), Eq.{succ u1} P₁ (coeFn.{max (succ u2) (succ u1), succ u1} (AffineMap.{u3, u2, u1, u2, u1} R' V₁ P₁ V₁ P₁ (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) (fun (_x : AffineMap.{u3, u2, u1, u2, u1} R' V₁ P₁ V₁ P₁ (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) => P₁ -> P₁) (AffineMap.hasCoeToFun.{u3, u2, u1, u2, u1} R' V₁ P₁ V₁ P₁ (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) (AffineMap.homothety.{u3, u2, u1} R' V₁ P₁ _inst_14 _inst_2 _inst_4 _inst_15 c (Neg.neg.{u3} R' (SubNegMonoid.toHasNeg.{u3} R' (AddGroup.toSubNegMonoid.{u3} R' (AddGroupWithOne.toAddGroup.{u3} R' (AddCommGroupWithOne.toAddGroupWithOne.{u3} R' (Ring.toAddCommGroupWithOne.{u3} R' (CommRing.toRing.{u3} R' _inst_14)))))) (OfNat.ofNat.{u3} R' 1 (OfNat.mk.{u3} R' 1 (One.one.{u3} R' (AddMonoidWithOne.toOne.{u3} R' (AddGroupWithOne.toAddMonoidWithOne.{u3} R' (AddCommGroupWithOne.toAddGroupWithOne.{u3} R' (Ring.toAddCommGroupWithOne.{u3} R' (CommRing.toRing.{u3} R' _inst_14)))))))))) p) (coeFn.{max (succ u1) (succ u2), succ u1} (AffineEquiv.{u3, u1, u1, u2, u2} R' P₁ P₁ V₁ V₁ (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) (fun (_x : AffineEquiv.{u3, u1, u1, u2, u2} R' P₁ P₁ V₁ V₁ (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) => P₁ -> P₁) (AffineEquiv.hasCoeToFun.{u3, u1, u1, u2, u2} R' P₁ P₁ V₁ V₁ (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) (AffineEquiv.pointReflection.{u3, u1, u2} R' P₁ V₁ (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 c) p)\nbut is expected to have type\n  forall {P₁ : Type.{u3}} {V₁ : Type.{u2}} [_inst_2 : AddCommGroup.{u2} V₁] [_inst_4 : AddTorsor.{u2, u3} V₁ P₁ (AddCommGroup.toAddGroup.{u2} V₁ _inst_2)] {R' : Type.{u1}} [_inst_14 : CommRing.{u1} R'] [_inst_15 : Module.{u1, u2} R' V₁ (Ring.toSemiring.{u1} R' (CommRing.toRing.{u1} R' _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V₁ _inst_2)] (c : P₁) (p : P₁), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₁) p) (FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u3} (AffineMap.{u1, u2, u3, u2, u3} R' V₁ P₁ V₁ P₁ (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P₁) => P₁) _x) (AffineMap.funLike.{u1, u2, u3, u2, u3} R' V₁ P₁ V₁ P₁ (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) (AffineMap.homothety.{u1, u2, u3} R' V₁ P₁ _inst_14 _inst_2 _inst_4 _inst_15 c (Neg.neg.{u1} R' (Ring.toNeg.{u1} R' (CommRing.toRing.{u1} R' _inst_14)) (OfNat.ofNat.{u1} R' 1 (One.toOfNat1.{u1} R' (Semiring.toOne.{u1} R' (Ring.toSemiring.{u1} R' (CommRing.toRing.{u1} R' _inst_14))))))) p) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} R' P₁ P₁ V₁ V₁ (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P₁ (fun (_x : P₁) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P₁) => P₁) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} R' P₁ P₁ V₁ V₁ (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P₁ P₁ (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} R' P₁ P₁ V₁ V₁ (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P₁ P₁ (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} R' P₁ P₁ V₁ V₁ (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4))) (AffineEquiv.pointReflection.{u1, u3, u2} R' P₁ V₁ (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 c) p)\nCase conversion may be inaccurate. Consider using '#align affine_map.homothety_neg_one_apply AffineMap.homothety_neg_one_applyₓ'. -/\ntheorem homothety_neg_one_apply (c p : P₁) : homothety c (-1 : R') p = pointReflection R' c p := by\n  simp [homothety_apply, point_reflection_apply]\n#align affine_map.homothety_neg_one_apply AffineMap.homothety_neg_one_apply\n\nend AffineMap\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/AffineSpace/AffineEquiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.47073024737171754}}
{"text": "import definitions ralgebra\n\nnoncomputable theory\nopen set classical\nlocal attribute [instance] prop_decidable\n\nvariables {X : Type*} [metric_space X] [compact_space X]\n\n-- We adopt the notation of bounded countinuous function from mathlib\nlocal infixr ` →ᵇ ` : 25 := bounded_continuous_function\n\n/- This file contains all the non-proven propositions used by main.lean\n\nMost of these lemmas are rather trivial. I aim to present a text proof alongside the \nless trivial propositions. -/\n\n-- compact.elim_finite_subcover require semilattices which we will assume\ninstance : semilattice_sup_bot (X →ᵇ ℝ) := sorry\ninstance : semilattice_inf_top (X →ᵇ ℝ) := sorry\n\nvariables {M₀ : set (X →ᵇ ℝ)}\n\n-- The following 10 propositions are trivial\nlemma le_finset_sup {I : finset X} (g : X → X →ᵇ ℝ) :\n∀ i ∈ I, ∀ x : X, g i x ≤ (I.sup g) x := sorry\n\nlemma finset_sup_lt {I : finset X} {g : X → X →ᵇ ℝ} {x} {r} \n(hlt : ∀ i ∈ I, g i x < r) : (I.sup g) x < r := sorry\n\nlemma finset_sup_mem_closure₀ {I : finset X} {g : X → X →ᵇ ℝ} \n(hg : ∀ i, g i ∈ closure₀ M₀) : I.sup g ∈ closure₀ M₀ := sorry\n\nlemma finset_inf_le {I : finset X} (g : X → X →ᵇ ℝ) :\n∀ i ∈ I, ∀ x : X, (I.inf g) x ≤ g i x := sorry\n\nlemma lt_finset_inf {I : finset X} {g : X → X →ᵇ ℝ} {x} {r} \n(hlt : ∀ i ∈ I, r < g i x) : r < (I.inf g) x := sorry\n\nlemma finset_inf_mem_closure₀ {I : finset X} {g : X → X →ᵇ ℝ} \n(hg : ∀ i, g i ∈ closure₀ M₀) : I.inf g ∈ closure₀ M₀ := sorry\n\nlemma is_open_aux_set₀ {f : X →ᵇ ℝ} \n{g : X → X →ᵇ ℝ} {ε : ℝ} (hε : ε > 0) : \n∀ y : X, is_open {z : X | f z - (g y) z < ε} := sorry\n\nlemma is_open_aux_set₁ {f : X →ᵇ ℝ} \n{g : X → X →ᵇ ℝ} {ε : ℝ} (hε : ε > 0) : \n∀ x : X, is_open {z : X | g x z < f z + ε} := sorry\n\nlemma neg_inf_eq_sup {f g h : X →ᵇ ℝ} : f = g ⊔ h ↔ -f = -g ⊓ -h := sorry\nlemma neg_sup_eq_inf {f g h : X →ᵇ ℝ} : f = g ⊓ h ↔ -f = -g ⊔ -h := sorry\n\n/- Follows by choosing the same δ from hF -/\nlemma neg_unif_converges_to {f : X →ᵇ ℝ} {F : ℕ → (X →ᵇ ℝ)} \n(hF : unif_converges_to (λ n, F n) f) : unif_converges_to (λ n, -F n) (-f) := sorry\n\n/- The forward direction is true by mem_univ, the backwards is true by defining the function \nsuch that ∀ z ∈ ℝ², f : X →ᵇ ℝ, (u : X) ↦ z.1 if u = x, else z.2 -/\nlemma boundary_points_of_univ : ∀ x y : X, boundary_points univ x y = univ := sorry\n\n/- This is true since M₀' is a subalgebra ⇒ 1 ∈ M₀'.carrier and \n∀ μ ∈ ℝ, ∀ f ∈ M₀'.carrier, μf ∈ M₀'.carrier ⇒ r • 1 ∈ M₀'.carrier -/\nlemma subalgebra_closed_under_smul' {M₀' : subalgebra ℝ (X →ᵇ ℝ)} :\n∀ (α : ℝ) {x}, x ∈ M₀'.carrier → α • x ∈ M₀'.carrier := sorry\n\n-- The following 4 propositions are trivial\nlemma closure₂_of_closure₂ (M₀ : set (X →ᵇ ℝ)) : \nclosure₂ (closure₂ M₀) = closure₂ M₀ := sorry\n\nlemma closure₀_closed_with_sup {M₀ : set (X →ᵇ ℝ)} {f g} \n(hf : f ∈ closure₀ M₀) (hg : g ∈ closure₀ M₀) : f ⊔ g ∈ closure₀ M₀ := sorry\n\nlemma closure₀_closed_with_inf {M₀ : set (X →ᵇ ℝ)} {f g} \n(hf : f ∈ closure₀ M₀) (hg : g ∈ closure₀ M₀) : f ⊓ g ∈ closure₀ M₀ := sorry\n\nlemma closure_le_seq₁ {M₀ : set (X →ᵇ ℝ)} :\nclosure₀ M₀ ⊆ closure₂ M₀ := sorry\n\n/- To prove `closure₂_subalgebra` we need to first show that `closure₂ M₀'.carrier` \nforms a subring. The is easily shown since M₀'.carrier ⊆ closure₂ M₀'.carrier and \nclosure₂ M₀'.carrier is closed.\n\nWe also need to show `range_le'` but this also follows directly from M₀'.carrier \n⊆ closure₂ M₀'.carrier. -/\ndef closure₂_subalgebra (M₀' : subalgebra ℝ (X →ᵇ ℝ)) : subalgebra ℝ (X →ᵇ ℝ) := \n{ carrier := closure₂ M₀'.carrier,\n  subring := sorry,\n  range_le' := sorry}\n\n/- This is the trivial subalgebra -/\ndef univ_subalgebra : subalgebra ℝ (X →ᵇ ℝ) := \n{ carrier := univ,\n  subring := sorry,\n  range_le' := sorry }\n", "meta": {"author": "JasonKYi", "repo": "stone-weierstrass", "sha": "390affd1415cf393da55866b82fdf68747dee7a2", "save_path": "github-repos/lean/JasonKYi-stone-weierstrass", "path": "github-repos/lean/JasonKYi-stone-weierstrass/stone-weierstrass-390affd1415cf393da55866b82fdf68747dee7a2/src/assumptions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4707302442921671}}
{"text": "/-\nCopyright (c) 2016 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport data.option.defs\nimport logic.nonempty\nimport tactic.cache\n\n/-!\n# Miscellaneous function constructions and lemmas\n-/\n\nuniverses u v w\n\nnamespace function\n\nsection\nvariables {α β γ : Sort*} {f : α → β}\n\n/-- Evaluate a function at an argument. Useful if you want to talk about the partially applied\n  `function.eval x : (Π x, β x) → β x`. -/\n@[reducible] def eval {β : α → Sort*} (x : α) (f : Π x, β x) : β x := f x\n\n@[simp] lemma eval_apply {β : α → Sort*} (x : α) (f : Π x, β x) : eval x f = f x := rfl\n\nlemma comp_apply {α : Sort u} {β : Sort v} {φ : Sort w} (f : β → φ) (g : α → β) (a : α) :\n  (f ∘ g) a = f (g a) := rfl\n\nlemma const_def {y : β} : (λ x : α, y) = const α y := rfl\n\n@[simp] lemma const_apply {y : β} {x : α} : const α y x = y := rfl\n\n@[simp] lemma const_comp {f : α → β} {c : γ} : const β c ∘ f = const α c := rfl\n\n@[simp] lemma comp_const {f : β → γ} {b : β} : f ∘ const α b = const α (f b) := rfl\n\nlemma id_def : @id α = λ x, x := rfl\n\nlemma hfunext {α α': Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : Πa, β a} {f' : Πa, β' a}\n  (hα : α = α') (h : ∀a a', a == a' → f a == f' a') : f == f' :=\nbegin\n  subst hα,\n  have : ∀a, f a == f' a,\n  { intro a, exact h a a (heq.refl a) },\n  have : β = β',\n  { funext a, exact type_eq_of_heq (this a) },\n  subst this,\n  apply heq_of_eq,\n  funext a,\n  exact eq_of_heq (this a)\nend\n\nlemma funext_iff {β : α → Sort*} {f₁ f₂ : Π (x : α), β x} : f₁ = f₂ ↔ (∀ a, f₁ a = f₂ a) :=\niff.intro (assume h a, h ▸ rfl) funext\n\nlemma ne_iff {β : α → Sort*} {f₁ f₂ : Π a, β a} : f₁ ≠ f₂ ↔ ∃ a, f₁ a ≠ f₂ a :=\nfunext_iff.not.trans not_forall\n\nprotected lemma bijective.injective {f : α → β} (hf : bijective f) : injective f := hf.1\nprotected lemma bijective.surjective {f : α → β} (hf : bijective f) : surjective f := hf.2\n\ntheorem injective.eq_iff (I : injective f) {a b : α} :\n  f a = f b ↔ a = b :=\n⟨@I _ _, congr_arg f⟩\n\ntheorem injective.eq_iff' (I : injective f) {a b : α} {c : β} (h : f b = c) :\n  f a = c ↔ a = b :=\nh ▸ I.eq_iff\n\nlemma injective.ne (hf : injective f) {a₁ a₂ : α} : a₁ ≠ a₂ → f a₁ ≠ f a₂ :=\nmt (assume h, hf h)\n\nlemma injective.ne_iff (hf : injective f) {x y : α} : f x ≠ f y ↔ x ≠ y :=\n⟨mt $ congr_arg f, hf.ne⟩\n\nlemma injective.ne_iff' (hf : injective f) {x y : α} {z : β} (h : f y = z) :\n  f x ≠ z ↔ x ≠ y :=\nh ▸ hf.ne_iff\n\n/-- If the co-domain `β` of an injective function `f : α → β` has decidable equality, then\nthe domain `α` also has decidable equality. -/\ndef injective.decidable_eq [decidable_eq β] (I : injective f) : decidable_eq α :=\nλ a b, decidable_of_iff _ I.eq_iff\n\nlemma injective.of_comp {g : γ → α} (I : injective (f ∘ g)) : injective g :=\nλ x y h, I $ show f (g x) = f (g y), from congr_arg f h\n\nlemma injective.of_comp_iff {f : α → β} (hf : injective f) (g : γ → α) :\n  injective (f ∘ g) ↔ injective g :=\n⟨injective.of_comp, hf.comp⟩\n\nlemma injective.of_comp_iff' (f : α → β) {g : γ → α} (hg : bijective g) :\n  injective (f ∘ g) ↔ injective f :=\n⟨ λ h x y, let ⟨x', hx⟩ := hg.surjective x, ⟨y', hy⟩ := hg.surjective y in\n    hx ▸ hy ▸ λ hf, h hf ▸ rfl,\n  λ h, h.comp hg.injective⟩\n\n/-- Composition by an injective function on the left is itself injective. -/\nlemma injective.comp_left {g : β → γ} (hg : function.injective g) :\n  function.injective ((∘) g : (α → β) → (α → γ)) :=\nλ f₁ f₂ hgf, funext $ λ i, hg $ (congr_fun hgf i : _)\n\nlemma injective_of_subsingleton [subsingleton α] (f : α → β) :\n  injective f :=\nλ a b ab, subsingleton.elim _ _\n\nlemma injective.dite (p : α → Prop) [decidable_pred p]\n  {f : {a : α // p a} → β} {f' : {a : α // ¬ p a} → β}\n  (hf : injective f) (hf' : injective f')\n  (im_disj : ∀ {x x' : α} {hx : p x} {hx' : ¬ p x'}, f ⟨x, hx⟩ ≠ f' ⟨x', hx'⟩) :\n  function.injective (λ x, if h : p x then f ⟨x, h⟩ else f' ⟨x, h⟩) :=\nλ x₁ x₂ h, begin\n  dsimp only at h,\n  by_cases h₁ : p x₁; by_cases h₂ : p x₂,\n  { rw [dif_pos h₁, dif_pos h₂] at h, injection (hf h), },\n  { rw [dif_pos h₁, dif_neg h₂] at h, exact (im_disj h).elim, },\n  { rw [dif_neg h₁, dif_pos h₂] at h, exact (im_disj h.symm).elim, },\n  { rw [dif_neg h₁, dif_neg h₂] at h, injection (hf' h), },\nend\n\nlemma surjective.of_comp {g : γ → α} (S : surjective (f ∘ g)) : surjective f :=\nλ y, let ⟨x, h⟩ := S y in ⟨g x, h⟩\n\nlemma surjective.of_comp_iff (f : α → β) {g : γ → α} (hg : surjective g) :\n  surjective (f ∘ g) ↔ surjective f :=\n⟨surjective.of_comp, λ h, h.comp hg⟩\n\nlemma surjective.of_comp_iff' (hf : bijective f) (g : γ → α) :\n  surjective (f ∘ g) ↔ surjective g :=\n⟨λ h x, let ⟨x', hx'⟩ := h (f x) in ⟨x', hf.injective hx'⟩, hf.surjective.comp⟩\n\ninstance decidable_eq_pfun (p : Prop) [decidable p] (α : p → Type*)\n  [Π hp, decidable_eq (α hp)] : decidable_eq (Π hp, α hp)\n| f g := decidable_of_iff (∀ hp, f hp = g hp) funext_iff.symm\n\nprotected theorem surjective.forall (hf : surjective f) {p : β → Prop} :\n  (∀ y, p y) ↔ ∀ x, p (f x) :=\n⟨λ h x, h (f x), λ h y, let ⟨x, hx⟩ := hf y in hx ▸ h x⟩\n\nprotected theorem surjective.forall₂ (hf : surjective f) {p : β → β → Prop} :\n  (∀ y₁ y₂, p y₁ y₂) ↔ ∀ x₁ x₂, p (f x₁) (f x₂) :=\nhf.forall.trans $ forall_congr $ λ x, hf.forall\n\nprotected theorem surjective.forall₃ (hf : surjective f) {p : β → β → β → Prop} :\n  (∀ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∀ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\nhf.forall.trans $ forall_congr $ λ x, hf.forall₂\n\nprotected theorem surjective.exists (hf : surjective f) {p : β → Prop} :\n  (∃ y, p y) ↔ ∃ x, p (f x) :=\n⟨λ ⟨y, hy⟩, let ⟨x, hx⟩ := hf y in ⟨x, hx.symm ▸ hy⟩, λ ⟨x, hx⟩, ⟨f x, hx⟩⟩\n\nprotected theorem surjective.exists₂ (hf : surjective f) {p : β → β → Prop} :\n  (∃ y₁ y₂, p y₁ y₂) ↔ ∃ x₁ x₂, p (f x₁) (f x₂) :=\nhf.exists.trans $ exists_congr $ λ x, hf.exists\n\nprotected theorem surjective.exists₃ (hf : surjective f) {p : β → β → β → Prop} :\n  (∃ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∃ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\nhf.exists.trans $ exists_congr $ λ x, hf.exists₂\n\nlemma surjective.injective_comp_right (hf : surjective f) :\n  injective (λ g : β → γ, g ∘ f) :=\nλ g₁ g₂ h, funext $ hf.forall.2 $ congr_fun h\n\nprotected lemma surjective.right_cancellable (hf : surjective f) {g₁ g₂ : β → γ} :\n  g₁ ∘ f = g₂ ∘ f ↔ g₁ = g₂ :=\nhf.injective_comp_right.eq_iff\n\nlemma surjective_of_right_cancellable_Prop (h : ∀ g₁ g₂ : β → Prop, g₁ ∘ f = g₂ ∘ f → g₁ = g₂) :\n  surjective f :=\nbegin\n  specialize h (λ _, true) (λ y, ∃ x, f x = y) (funext $ λ x, _),\n  { simp only [(∘), exists_apply_eq_apply] },\n  { intro y,\n    have : true = ∃ x, f x = y, from congr_fun h y,\n    rw ← this, exact trivial }\nend\n\nlemma bijective_iff_exists_unique (f : α → β) : bijective f ↔\n  ∀ b : β, ∃! (a : α), f a = b :=\n⟨ λ hf b, let ⟨a, ha⟩ := hf.surjective b in ⟨a, ha, λ a' ha', hf.injective (ha'.trans ha.symm)⟩,\n  λ he, ⟨\n    λ a a' h, unique_of_exists_unique (he (f a')) h rfl,\n    λ b, exists_of_exists_unique (he b) ⟩⟩\n\n/-- Shorthand for using projection notation with `function.bijective_iff_exists_unique`. -/\nprotected lemma bijective.exists_unique {f : α → β} (hf : bijective f) (b : β) :\n  ∃! (a : α), f a = b :=\n(bijective_iff_exists_unique f).mp hf b\n\nlemma bijective.exists_unique_iff {f : α → β} (hf : bijective f) {p : β → Prop} :\n  (∃! y, p y) ↔ ∃! x, p (f x) :=\n⟨λ ⟨y, hpy, hy⟩, let ⟨x, hx⟩ := hf.surjective y in ⟨x, by rwa hx,\n  λ z (hz : p (f z)), hf.injective $ hx.symm ▸ hy _ hz⟩,\n  λ ⟨x, hpx, hx⟩, ⟨f x, hpx, λ y hy,\n    let ⟨z, hz⟩ := hf.surjective y in hz ▸ congr_arg f $ hx _ $ by rwa hz⟩⟩\n\nlemma bijective.of_comp_iff (f : α → β) {g : γ → α} (hg : bijective g) :\n  bijective (f ∘ g) ↔ bijective f :=\nand_congr (injective.of_comp_iff' _ hg) (surjective.of_comp_iff _ hg.surjective)\n\nlemma bijective.of_comp_iff' {f : α → β} (hf : bijective f) (g : γ → α) :\n  function.bijective (f ∘ g) ↔ function.bijective g :=\nand_congr (injective.of_comp_iff hf.injective _) (surjective.of_comp_iff' hf _)\n\n/-- **Cantor's diagonal argument** implies that there are no surjective functions from `α`\nto `set α`. -/\ntheorem cantor_surjective {α} (f : α → set α) : ¬ function.surjective f | h :=\nlet ⟨D, e⟩ := h (λ a, ¬ f a a) in\n(iff_not_self (f D D)).1 $ iff_of_eq (congr_fun e D)\n\n/-- **Cantor's diagonal argument** implies that there are no injective functions from `set α`\nto `α`. -/\ntheorem cantor_injective {α : Type*} (f : (set α) → α) :\n  ¬ function.injective f | i :=\ncantor_surjective (λ a b, ∀ U, a = f U → U b) $\nright_inverse.surjective (λ U, funext $ λ a, propext ⟨λ h, h U rfl, λ h' U' e, i e ▸ h'⟩)\n\n/-- There is no surjection from `α : Type u` into `Type u`. This theorem\n  demonstrates why `Type : Type` would be inconsistent in Lean. -/\ntheorem not_surjective_Type {α : Type u} (f : α → Type (max u v)) :\n  ¬ surjective f :=\nbegin\n  intro hf,\n  let T : Type (max u v) := sigma f,\n  cases hf (set T) with U hU,\n  let g : set T → T := λ s, ⟨U, cast hU.symm s⟩,\n  have hg : injective g,\n  { intros s t h,\n    suffices : cast hU (g s).2 = cast hU (g t).2,\n    { simp only [cast_cast, cast_eq] at this, assumption },\n    { congr, assumption } },\n  exact cantor_injective g hg\nend\n\n/-- `g` is a partial inverse to `f` (an injective but not necessarily\n  surjective function) if `g y = some x` implies `f x = y`, and `g y = none`\n  implies that `y` is not in the range of `f`. -/\ndef is_partial_inv {α β} (f : α → β) (g : β → option α) : Prop :=\n∀ x y, g y = some x ↔ f x = y\n\ntheorem is_partial_inv_left {α β} {f : α → β} {g} (H : is_partial_inv f g) (x) : g (f x) = some x :=\n(H _ _).2 rfl\n\ntheorem injective_of_partial_inv {α β} {f : α → β} {g} (H : is_partial_inv f g) : injective f :=\nλ a b h, option.some.inj $ ((H _ _).2 h).symm.trans ((H _ _).2 rfl)\n\ntheorem injective_of_partial_inv_right {α β} {f : α → β} {g} (H : is_partial_inv f g)\n (x y b) (h₁ : b ∈ g x) (h₂ : b ∈ g y) : x = y :=\n((H _ _).1 h₁).symm.trans ((H _ _).1 h₂)\n\ntheorem left_inverse.comp_eq_id {f : α → β} {g : β → α} (h : left_inverse f g) : f ∘ g = id :=\nfunext h\n\ntheorem left_inverse_iff_comp {f : α → β} {g : β → α} : left_inverse f g ↔ f ∘ g = id :=\n⟨left_inverse.comp_eq_id, congr_fun⟩\n\ntheorem right_inverse.comp_eq_id {f : α → β} {g : β → α} (h : right_inverse f g) : g ∘ f = id :=\nfunext h\n\ntheorem right_inverse_iff_comp {f : α → β} {g : β → α} : right_inverse f g ↔ g ∘ f = id :=\n⟨right_inverse.comp_eq_id, congr_fun⟩\n\ntheorem left_inverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β}\n  (hf : left_inverse f g) (hh : left_inverse h i) : left_inverse (h ∘ f) (g ∘ i) :=\nassume a, show h (f (g (i a))) = a, by rw [hf (i a), hh a]\n\ntheorem right_inverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β}\n  (hf : right_inverse f g) (hh : right_inverse h i) : right_inverse (h ∘ f) (g ∘ i) :=\nleft_inverse.comp hh hf\n\ntheorem left_inverse.right_inverse {f : α → β} {g : β → α} (h : left_inverse g f) :\n  right_inverse f g := h\n\ntheorem right_inverse.left_inverse {f : α → β} {g : β → α} (h : right_inverse g f) :\n  left_inverse f g := h\n\ntheorem left_inverse.surjective {f : α → β} {g : β → α} (h : left_inverse f g) :\n  surjective f :=\nh.right_inverse.surjective\n\ntheorem right_inverse.injective {f : α → β} {g : β → α} (h : right_inverse f g) :\n  injective f :=\nh.left_inverse.injective\n\ntheorem left_inverse.right_inverse_of_injective {f : α → β} {g : β → α} (h : left_inverse f g)\n  (hf : injective f) :\n  right_inverse f g :=\nλ x, hf $ h (f x)\n\ntheorem left_inverse.right_inverse_of_surjective {f : α → β} {g : β → α} (h : left_inverse f g)\n  (hg : surjective g) :\n  right_inverse f g :=\nλ x, let ⟨y, hy⟩ := hg x in hy ▸ congr_arg g (h y)\n\ntheorem left_inverse.eq_right_inverse {f : α → β} {g₁ g₂ : β → α} (h₁ : left_inverse g₁ f)\n  (h₂ : right_inverse g₂ f) :\n  g₁ = g₂ :=\ncalc g₁ = g₁ ∘ f ∘ g₂ : by rw [h₂.comp_eq_id, comp.right_id]\n    ... = g₂          : by rw [← comp.assoc, h₁.comp_eq_id, comp.left_id]\n\nlocal attribute [instance, priority 10] classical.prop_decidable\n\n/-- We can use choice to construct explicitly a partial inverse for\n  a given injective function `f`. -/\nnoncomputable def partial_inv {α β} (f : α → β) (b : β) : option α :=\nif h : ∃ a, f a = b then some (classical.some h) else none\n\ntheorem partial_inv_of_injective {α β} {f : α → β} (I : injective f) :\n  is_partial_inv f (partial_inv f) | a b :=\n⟨λ h, if h' : ∃ a, f a = b then begin\n    rw [partial_inv, dif_pos h'] at h,\n    injection h with h, subst h,\n    apply classical.some_spec h'\n  end else by rw [partial_inv, dif_neg h'] at h; contradiction,\n λ e, e ▸ have h : ∃ a', f a' = f a, from ⟨_, rfl⟩,\n   (dif_pos h).trans (congr_arg _ (I $ classical.some_spec h))⟩\n\ntheorem partial_inv_left {α β} {f : α → β} (I : injective f) : ∀ x, partial_inv f (f x) = some x :=\nis_partial_inv_left (partial_inv_of_injective I)\n\nend\n\nsection inv_fun\n\nvariables {α β : Sort*} [nonempty α] {f : α → β} {a : α} {b : β}\nlocal attribute [instance, priority 10] classical.prop_decidable\n\n/-- The inverse of a function (which is a left inverse if `f` is injective\n  and a right inverse if `f` is surjective). -/\nnoncomputable def inv_fun (f : α → β) : β → α :=\nλ y, if h : ∃ x, f x = y then h.some else classical.arbitrary α\n\ntheorem inv_fun_eq (h : ∃ a, f a = b) : f (inv_fun f b) = b :=\nby simp only [inv_fun, dif_pos h, h.some_spec]\n\nlemma inv_fun_neg (h : ¬ ∃ a, f a = b) : inv_fun f b = classical.choice ‹_› :=\ndif_neg h\n\ntheorem inv_fun_eq_of_injective_of_right_inverse {g : β → α}\n  (hf : injective f) (hg : right_inverse g f) : inv_fun f = g :=\nfunext $ assume b,\nhf begin rw [hg b], exact inv_fun_eq ⟨g b, hg b⟩ end\n\nlemma right_inverse_inv_fun (hf : surjective f) : right_inverse (inv_fun f) f :=\nassume b, inv_fun_eq $ hf b\n\nlemma left_inverse_inv_fun (hf : injective f) : left_inverse (inv_fun f) f :=\nλ b, hf $ inv_fun_eq ⟨b, rfl⟩\n\nlemma inv_fun_surjective (hf : injective f) : surjective (inv_fun f) :=\n(left_inverse_inv_fun hf).surjective\n\nlemma inv_fun_comp (hf : injective f) : inv_fun f ∘ f = id := funext $ left_inverse_inv_fun hf\n\nlemma injective.has_left_inverse (hf : injective f) : has_left_inverse f :=\n⟨inv_fun f, left_inverse_inv_fun hf⟩\n\nlemma injective_iff_has_left_inverse : injective f ↔ has_left_inverse f :=\n⟨injective.has_left_inverse, has_left_inverse.injective⟩\n\nend inv_fun\n\nsection surj_inv\nvariables {α : Sort u} {β : Sort v} {γ : Sort w} {f : α → β}\n\n/-- The inverse of a surjective function. (Unlike `inv_fun`, this does not require\n  `α` to be inhabited.) -/\nnoncomputable def surj_inv {f : α → β} (h : surjective f) (b : β) : α := classical.some (h b)\n\nlemma surj_inv_eq (h : surjective f) (b) : f (surj_inv h b) = b := classical.some_spec (h b)\n\nlemma right_inverse_surj_inv (hf : surjective f) : right_inverse (surj_inv hf) f :=\nsurj_inv_eq hf\n\nlemma left_inverse_surj_inv (hf : bijective f) : left_inverse (surj_inv hf.2) f :=\nright_inverse_of_injective_of_left_inverse hf.1 (right_inverse_surj_inv hf.2)\n\nlemma surjective.has_right_inverse (hf : surjective f) : has_right_inverse f :=\n⟨_, right_inverse_surj_inv hf⟩\n\nlemma surjective_iff_has_right_inverse : surjective f ↔ has_right_inverse f :=\n⟨surjective.has_right_inverse, has_right_inverse.surjective⟩\n\nlemma bijective_iff_has_inverse : bijective f ↔ ∃ g, left_inverse g f ∧ right_inverse g f :=\n⟨λ hf, ⟨_, left_inverse_surj_inv hf, right_inverse_surj_inv hf.2⟩,\n λ ⟨g, gl, gr⟩, ⟨gl.injective,  gr.surjective⟩⟩\n\nlemma injective_surj_inv (h : surjective f) : injective (surj_inv h) :=\n(right_inverse_surj_inv h).injective\n\nlemma surjective_to_subsingleton [na : nonempty α] [subsingleton β] (f : α → β) :\n  surjective f :=\nλ y, let ⟨a⟩ := na in ⟨a, subsingleton.elim _ _⟩\n\n/-- Composition by an surjective function on the left is itself surjective. -/\nlemma surjective.comp_left {g : β → γ} (hg : surjective g) :\n  surjective ((∘) g : (α → β) → (α → γ)) :=\nλ f, ⟨surj_inv hg ∘ f, funext $ λ x, right_inverse_surj_inv _ _⟩\n\n/-- Composition by an bijective function on the left is itself bijective. -/\nlemma bijective.comp_left {g : β → γ} (hg : bijective g) :\n  bijective ((∘) g : (α → β) → (α → γ)) :=\n⟨hg.injective.comp_left, hg.surjective.comp_left⟩\n\nend surj_inv\n\nsection update\nvariables {α : Sort u} {β : α → Sort v} {α' : Sort w} [decidable_eq α] [decidable_eq α']\n\n/-- Replacing the value of a function at a given point by a given value. -/\ndef update (f : Πa, β a) (a' : α) (v : β a') (a : α) : β a :=\nif h : a = a' then eq.rec v h.symm else f a\n\n/-- On non-dependent functions, `function.update` can be expressed as an `ite` -/\nlemma update_apply {β : Sort*} (f : α → β) (a' : α) (b : β) (a : α) :\n  update f a' b a = if a = a' then b else f a :=\nbegin\n  dunfold update,\n  congr,\n  funext,\n  rw eq_rec_constant,\nend\n\n@[simp] lemma update_same (a : α) (v : β a) (f : Πa, β a) : update f a v a = v :=\ndif_pos rfl\n\nlemma surjective_eval {α : Sort u} {β : α → Sort v} [h : Π a, nonempty (β a)] (a : α) :\n  surjective (eval a : (Π a, β a) → β a) :=\nλ b, ⟨@update _ _ (classical.dec_eq α) (λ a, (h a).some) a b,\n  @update_same _ _ (classical.dec_eq α) _ _ _⟩\n\nlemma update_injective (f : Πa, β a) (a' : α) : injective (update f a') :=\nλ v v' h, have _ := congr_fun h a', by rwa [update_same, update_same] at this\n\n@[simp] lemma update_noteq {a a' : α} (h : a ≠ a') (v : β a') (f : Πa, β a) :\n  update f a' v a = f a :=\ndif_neg h\n\nlemma forall_update_iff (f : Π a, β a) {a : α} {b : β a} (p : Π a, β a → Prop) :\n  (∀ x, p x (update f a b x)) ↔ p a b ∧ ∀ x ≠ a, p x (f x) :=\nby { rw [← and_forall_ne a, update_same], simp { contextual := tt } }\n\nlemma exists_update_iff (f : Π a, β a) {a : α} {b : β a} (p : Π a, β a → Prop) :\n  (∃ x, p x (update f a b x)) ↔ p a b ∨ ∃ x ≠ a, p x (f x) :=\nby { rw [← not_forall_not, forall_update_iff f (λ a b, ¬p a b)], simp [not_and_distrib] }\n\nlemma update_eq_iff {a : α} {b : β a} {f g : Π a, β a} :\n  update f a b = g ↔ b = g a ∧ ∀ x ≠ a, f x = g x :=\nfunext_iff.trans $ forall_update_iff _ (λ x y, y = g x)\n\nlemma eq_update_iff {a : α} {b : β a} {f g : Π a, β a} :\n  g = update f a b ↔ g a = b ∧ ∀ x ≠ a, g x = f x :=\nfunext_iff.trans $ forall_update_iff _ (λ x y, g x = y)\n\n@[simp] lemma update_eq_self (a : α) (f : Πa, β a) : update f a (f a) = f :=\nupdate_eq_iff.2 ⟨rfl, λ _ _, rfl⟩\n\nlemma update_comp_eq_of_forall_ne' {α'} (g : Π a, β a) {f : α' → α} {i : α} (a : β i)\n  (h : ∀ x, f x ≠ i) :\n  (λ j, (update g i a) (f j)) = (λ j, g (f j)) :=\nfunext $ λ x, update_noteq (h _) _ _\n\n/-- Non-dependent version of `function.update_comp_eq_of_forall_ne'` -/\nlemma update_comp_eq_of_forall_ne {α β : Sort*} (g : α' → β) {f : α → α'} {i : α'} (a : β)\n  (h : ∀ x, f x ≠ i) :\n  (update g i a) ∘ f = g ∘ f :=\nupdate_comp_eq_of_forall_ne' g a h\n\nlemma update_comp_eq_of_injective' (g : Π a, β a) {f : α' → α} (hf : function.injective f)\n  (i : α') (a : β (f i)) :\n  (λ j, update g (f i) a (f j)) = update (λ i, g (f i)) i a :=\neq_update_iff.2 ⟨update_same _ _ _, λ j hj, update_noteq (hf.ne hj) _ _⟩\n\n/-- Non-dependent version of `function.update_comp_eq_of_injective'` -/\nlemma update_comp_eq_of_injective {β : Sort*} (g : α' → β) {f : α → α'}\n  (hf : function.injective f) (i : α) (a : β) :\n  (function.update g (f i) a) ∘ f = function.update (g ∘ f) i a :=\nupdate_comp_eq_of_injective' g hf i a\n\nlemma apply_update {ι : Sort*} [decidable_eq ι] {α β : ι → Sort*}\n  (f : Π i, α i → β i) (g : Π i, α i) (i : ι) (v : α i) (j : ι) :\n  f j (update g i v j) = update (λ k, f k (g k)) i (f i v) j :=\nbegin\n  by_cases h : j = i,\n  { subst j, simp },\n  { simp [h] }\nend\n\nlemma apply_update₂ {ι : Sort*} [decidable_eq ι] {α β γ : ι → Sort*}\n  (f : Π i, α i → β i → γ i) (g : Π i, α i) (h : Π i, β i) (i : ι) (v : α i) (w : β i) (j : ι) :\n  f j (update g i v j) (update h i w j) = update (λ k, f k (g k) (h k)) i (f i v w) j :=\nbegin\n  by_cases h : j = i,\n  { subst j, simp },\n  { simp [h] }\nend\n\nlemma comp_update {α' : Sort*} {β : Sort*} (f : α' → β) (g : α → α') (i : α) (v : α') :\n  f ∘ (update g i v) = update (f ∘ g) i (f v) :=\nfunext $ apply_update _ _ _ _\n\ntheorem update_comm {α} [decidable_eq α] {β : α → Sort*}\n  {a b : α} (h : a ≠ b) (v : β a) (w : β b) (f : Πa, β a) :\n  update (update f a v) b w = update (update f b w) a v :=\nbegin\n  funext c, simp only [update],\n  by_cases h₁ : c = b; by_cases h₂ : c = a; try {simp [h₁, h₂]},\n  cases h (h₂.symm.trans h₁),\nend\n\n@[simp] theorem update_idem {α} [decidable_eq α] {β : α → Sort*}\n  {a : α} (v w : β a) (f : Πa, β a) : update (update f a v) a w = update f a w :=\nby {funext b, by_cases b = a; simp [update, h]}\n\nend update\n\nsection extend\n\nnoncomputable theory\nlocal attribute [instance, priority 10] classical.prop_decidable\n\nvariables {α β γ : Sort*} {f : α → β}\n\n/-- `extend f g e'` extends a function `g : α → γ`\nalong a function `f : α → β` to a function `β → γ`,\nby using the values of `g` on the range of `f`\nand the values of an auxiliary function `e' : β → γ` elsewhere.\n\nMostly useful when `f` is injective. -/\ndef extend (f : α → β) (g : α → γ) (e' : β → γ) : β → γ :=\nλ b, if h : ∃ a, f a = b then g (classical.some h) else e' b\n\nlemma extend_def (f : α → β) (g : α → γ) (e' : β → γ) (b : β) [decidable (∃ a, f a = b)] :\n  extend f g e' b = if h : ∃ a, f a = b then g (classical.some h) else e' b :=\nby { unfold extend, congr }\n\n@[simp] lemma extend_apply (hf : injective f) (g : α → γ) (e' : β → γ) (a : α) :\n  extend f g e' (f a) = g a :=\nbegin\n  simp only [extend_def, dif_pos, exists_apply_eq_apply],\n  exact congr_arg g (hf $ classical.some_spec (exists_apply_eq_apply f a))\nend\n\n@[simp] lemma extend_apply' (g : α → γ) (e' : β → γ) (b : β) (hb : ¬∃ a, f a = b) :\n  extend f g e' b = e' b :=\nby simp [function.extend_def, hb]\n\nlemma apply_extend {δ} (hf : injective f) (F : γ → δ) (g : α → γ) (e' : β → γ) (b : β) :\n  F (extend f g e' b) = extend f (F ∘ g) (F ∘ e') b :=\nbegin\n  by_cases hb : ∃ a, f a = b,\n  { cases hb with a ha, subst b,\n    rw [extend_apply hf, extend_apply hf] },\n  { rw [extend_apply' _ _ _ hb, extend_apply' _ _ _ hb] }\nend\n\nlemma extend_injective (hf : injective f) (e' : β → γ) :\n  injective (λ g, extend f g e') :=\nbegin\n  intros g₁ g₂ hg,\n  refine funext (λ x, _),\n  have H := congr_fun hg (f x),\n  simp only [hf, extend_apply] at H,\n  exact H\nend\n\n@[simp] lemma extend_comp (hf : injective f) (g : α → γ) (e' : β → γ) :\n  extend f g e' ∘ f = g :=\nfunext $ λ a, extend_apply hf g e' a\n\nlemma injective.surjective_comp_right' (hf : injective f) (g₀ : β → γ) :\n  surjective (λ g : β → γ, g ∘ f) :=\nλ g, ⟨extend f g g₀, extend_comp hf _ _⟩\n\nlemma injective.surjective_comp_right [nonempty γ] (hf : injective f) :\n  surjective (λ g : β → γ, g ∘ f) :=\nhf.surjective_comp_right' (λ _, classical.choice ‹_›)\n\nlemma bijective.comp_right (hf : bijective f) :\n  bijective (λ g : β → γ, g ∘ f) :=\n⟨hf.surjective.injective_comp_right,\n  λ g, ⟨g ∘ surj_inv hf.surjective,\n    by simp only [comp.assoc g _ f, (left_inverse_surj_inv hf).comp_eq_id, comp.right_id]⟩⟩\n\nend extend\n\nlemma uncurry_def {α β γ} (f : α → β → γ) : uncurry f = (λp, f p.1 p.2) :=\nrfl\n\n@[simp] lemma uncurry_apply_pair {α β γ} (f : α → β → γ) (x : α) (y : β) :\n  uncurry f (x, y) = f x y :=\nrfl\n\n@[simp] lemma curry_apply {α β γ} (f : α × β → γ) (x : α) (y : β) :\n  curry f x y = f (x, y) :=\nrfl\n\nsection bicomp\nvariables {α β γ δ ε : Type*}\n\n/-- Compose a binary function `f` with a pair of unary functions `g` and `h`.\nIf both arguments of `f` have the same type and `g = h`, then `bicompl f g g = f on g`. -/\ndef bicompl (f : γ → δ → ε) (g : α → γ) (h : β → δ) (a b) :=\nf (g a) (h b)\n\n/-- Compose an unary function `f` with a binary function `g`. -/\ndef bicompr (f : γ → δ) (g : α → β → γ) (a b) :=\nf (g a b)\n\n-- Suggested local notation:\nlocal notation f `∘₂` g := bicompr f g\n\nlemma uncurry_bicompr (f : α → β → γ) (g : γ → δ) :\n  uncurry (g ∘₂ f) = (g ∘ uncurry f) := rfl\n\n\n\nend bicomp\n\nsection uncurry\n\nvariables {α β γ δ : Type*}\n\n/-- Records a way to turn an element of `α` into a function from `β` to `γ`. The most generic use\nis to recursively uncurry. For instance `f : α → β → γ → δ` will be turned into\n`↿f : α × β × γ → δ`. One can also add instances for bundled maps. -/\nclass has_uncurry (α : Type*) (β : out_param Type*) (γ : out_param Type*) := (uncurry : α → (β → γ))\n\n/-- Uncurrying operator. The most generic use is to recursively uncurry. For instance\n`f : α → β → γ → δ` will be turned into `↿f : α × β × γ → δ`. One can also add instances\nfor bundled maps.-/\nadd_decl_doc has_uncurry.uncurry\n\nnotation `↿`:max x:max := has_uncurry.uncurry x\n\ninstance has_uncurry_base : has_uncurry (α → β) α β := ⟨id⟩\n\ninstance has_uncurry_induction [has_uncurry β γ δ] : has_uncurry (α → β) (α × γ) δ :=\n⟨λ f p, ↿(f p.1) p.2⟩\n\nend uncurry\n\n/-- A function is involutive, if `f ∘ f = id`. -/\ndef involutive {α} (f : α → α) : Prop := ∀ x, f (f x) = x\n\nlemma involutive_iff_iter_2_eq_id {α} {f : α → α} : involutive f ↔ (f^[2] = id) :=\nfunext_iff.symm\n\nnamespace involutive\nvariables {α : Sort u} {f : α → α} (h : involutive f)\ninclude h\n\n@[simp]\nlemma comp_self : f ∘ f = id := funext h\n\nprotected lemma left_inverse : left_inverse f f := h\nprotected lemma right_inverse : right_inverse f f := h\n\nprotected lemma injective : injective f := h.left_inverse.injective\nprotected lemma surjective : surjective f := λ x, ⟨f x, h x⟩\nprotected lemma bijective : bijective f := ⟨h.injective, h.surjective⟩\n\n/-- Involuting an `ite` of an involuted value `x : α` negates the `Prop` condition in the `ite`. -/\nprotected lemma ite_not (P : Prop) [decidable P] (x : α) :\n  f (ite P x (f x)) = ite (¬ P) x (f x) :=\nby rw [apply_ite f, h, ite_not]\n\n/-- An involution commutes across an equality. Compare to `function.injective.eq_iff`. -/\nprotected lemma eq_iff {x y : α} : f x = y ↔ x = f y :=\nh.injective.eq_iff' (h y)\n\nend involutive\n\n/-- The property of a binary function `f : α → β → γ` being injective.\nMathematically this should be thought of as the corresponding function `α × β → γ` being injective.\n-/\ndef injective2 {α β γ} (f : α → β → γ) : Prop :=\n∀ ⦃a₁ a₂ b₁ b₂⦄, f a₁ b₁ = f a₂ b₂ → a₁ = a₂ ∧ b₁ = b₂\n\nnamespace injective2\nvariables {α β γ : Sort*} {f : α → β → γ}\n\n/-- A binary injective function is injective when only the left argument varies. -/\nprotected lemma left (hf : injective2 f) (b : β) : function.injective (λ a, f a b) :=\nλ a₁ a₂ h, (hf h).left\n\n/-- A binary injective function is injective when only the right argument varies. -/\nprotected lemma right (hf : injective2 f) (a : α) : function.injective (f a) :=\nλ a₁ a₂ h, (hf h).right\n\nprotected lemma uncurry {α β γ : Type*} {f : α → β → γ} (hf : injective2 f) :\n  function.injective (uncurry f) :=\nλ ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ h, and.elim (hf h) (congr_arg2 _)\n\n/-- As a map from the left argument to a unary function, `f` is injective. -/\nlemma left' (hf : injective2 f) [nonempty β] : function.injective f :=\nλ a₁ a₂ h, let ⟨b⟩ := ‹nonempty β› in hf.left b $ (congr_fun h b : _)\n\n/-- As a map from the right argument to a unary function, `f` is injective. -/\nlemma right' (hf : injective2 f) [nonempty α] : function.injective (λ b a, f a b) :=\nλ b₁ b₂ h, let ⟨a⟩ := ‹nonempty α› in hf.right a $ (congr_fun h a : _)\n\nlemma eq_iff (hf : injective2 f) {a₁ a₂ b₁ b₂} : f a₁ b₁ = f a₂ b₂ ↔ a₁ = a₂ ∧ b₁ = b₂ :=\n⟨λ h, hf h, and.rec $ congr_arg2 f⟩\n\nend injective2\n\nsection sometimes\nlocal attribute [instance, priority 10] classical.prop_decidable\n\n/-- `sometimes f` evaluates to some value of `f`, if it exists. This function is especially\ninteresting in the case where `α` is a proposition, in which case `f` is necessarily a\nconstant function, so that `sometimes f = f a` for all `a`. -/\nnoncomputable def sometimes {α β} [nonempty β] (f : α → β) : β :=\nif h : nonempty α then f (classical.choice h) else classical.choice ‹_›\n\ntheorem sometimes_eq {p : Prop} {α} [nonempty α] (f : p → α) (a : p) : sometimes f = f a :=\ndif_pos ⟨a⟩\n\ntheorem sometimes_spec {p : Prop} {α} [nonempty α]\n  (P : α → Prop) (f : p → α) (a : p) (h : P (f a)) : P (sometimes f) :=\nby rwa sometimes_eq\n\nend sometimes\n\nend function\n\n/-- `s.piecewise f g` is the function equal to `f` on the set `s`, and to `g` on its complement. -/\ndef set.piecewise {α : Type u} {β : α → Sort v} (s : set α) (f g : Πi, β i)\n  [∀j, decidable (j ∈ s)] :\n  Πi, β i :=\nλi, if i ∈ s then f i else g i\n\n/-! ### Bijectivity of `eq.rec`, `eq.mp`, `eq.mpr`, and `cast` -/\n\nlemma eq_rec_on_bijective {α : Sort*} {C : α → Sort*} :\n  ∀ {a a' : α} (h : a = a'), function.bijective (@eq.rec_on _ _ C _ h)\n| _ _ rfl := ⟨λ x y, id, λ x, ⟨x, rfl⟩⟩\n\nlemma eq_mp_bijective {α β : Sort*} (h : α = β) : function.bijective (eq.mp h) :=\neq_rec_on_bijective h\n\nlemma eq_mpr_bijective {α β : Sort*} (h : α = β) : function.bijective (eq.mpr h) :=\neq_rec_on_bijective h.symm\n\nlemma cast_bijective {α β : Sort*} (h : α = β) : function.bijective (cast h) :=\neq_rec_on_bijective h\n\n/-! Note these lemmas apply to `Type*` not `Sort*`, as the latter interferes with `simp`, and\nis trivial anyway.-/\n\n@[simp]\nlemma eq_rec_inj {α : Sort*} {a a' : α} (h : a = a') {C : α → Type*} (x y : C a) :\n  (eq.rec x h : C a') = eq.rec y h ↔ x = y :=\n(eq_rec_on_bijective h).injective.eq_iff\n\n@[simp]\nlemma cast_inj {α β : Type*} (h : α = β) {x y : α} : cast h x = cast h y ↔ x = y :=\n(cast_bijective h).injective.eq_iff\n\n/-- A set of functions \"separates points\"\nif for each pair of distinct points there is a function taking different values on them. -/\ndef set.separates_points {α β : Type*} (A : set (α → β)) : Prop :=\n∀ ⦃x y : α⦄, x ≠ y → ∃ f ∈ A, (f x : β) ≠ f y\n\nlemma is_symm_op.flip_eq {α β} (op) [is_symm_op α β op] : flip op = op :=\nfunext $ λ a, funext $ λ b, (is_symm_op.symm_op a b).symm\n\nlemma inv_image.equivalence {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β)\n  (h : equivalence r) : equivalence (inv_image r f) :=\n⟨λ _, h.1 _, λ _ _ x, h.2.1 x, inv_image.trans r f h.2.2⟩\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/logic/function/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6076631698328917, "lm_q2_score": 0.7745833841649233, "lm_q1q2_score": 0.4706857945215458}}
{"text": "import Lens\n\nstructure Foo (α β : Type) where\n  x : Nat\n  y : α\n  z : List (α × β)\n  deriving Lenses\n\nvariable {α β : Type}\n\n#check (Foo.Lens.x : Lens (Foo α β) Nat)\n#check (Foo.Lens.y : Lens (Foo α β) α)\n#check (Foo.Lens.z : Lens (Foo α β) (List (α × β)))\n\nstructure Bar (α β : Type) where\n  foo : Foo α β\n  deriving Lenses\n\nnamespace Lens\nopen Foo.Lens Bar.Lens\n\nvariable (a : Bar Nat Nat)\n\ndef bar : Bar Nat Nat :=\na & foo /. x %~ (. + 3)\n\n#check (Bar.Lens.foo : Lens (Bar α β) (Foo α β))\n#check (Bar.Lens.foo /. Foo.Lens.x : Lens (Bar α β) Nat)\n\ndef test := bar ⟨ { x := 1, y := 0, z := [] } ⟩\n\ntheorem check' : test = ⟨ { x := 4, y := 0, z := [] } ⟩ :=\nrfl\n\nend Lens\n", "meta": {"author": "cipher1024", "repo": "lean4-prog", "sha": "49f7416ee19df921bfea1b4914404b9d07619d64", "save_path": "github-repos/lean/cipher1024-lean4-prog", "path": "github-repos/lean/cipher1024-lean4-prog/lean4-prog-49f7416ee19df921bfea1b4914404b9d07619d64/lens/Test/Lens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.47068579452154574}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.dold_kan.equivalence_additive\nimport for_mathlib.dold_kan.compatibility\nimport category_theory.idempotents.simplicial_object\nimport for_mathlib.idempotents.karoubi_misc\nimport for_mathlib.idempotents.homological_complex\n\n/-!\n\n# The Dold-Kan correspondence for pseudoabelian categories\n\nIn this file, for any idempotent complete additive category `C`,\nthe Dold-Kan equivalence\n`idempotents.dold_kan.equivalence C : simplicial_object C ≌ chain_complex C ℕ`\nis obtained. It is deduced from the equivalence\n`preadditive.dold_kan.equivalence` between the respective idempotent\ncompletions of these categories using the fact that when `C` is idempotent complete,\nthen both `simplicial_object C` and `chain_complex C ℕ` are idempotent complete.\n\nThe construction of `idempotents.dold_kan.equivalence` uses the tools\nintroduced in the file `compatibility.lean`. Doing so, the functor\n`idempotents.dold_kan.N` of the equivalence is\nthe composition of `N₁ : simplicial_object C ⥤ karoubi (chain_complex C ℕ)`\n(defined in `functor_n.lean`) and the inverse of the equivalence\n`chain_complex C ℕ ≌ karoubi (chain_complex C ℕ)`. The functor\n`idempotents.dold_kan.Γ` of the equivalence is by definition the functor\n`Γ₀` introduced in `functor_gamma.lean`.\n\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.category\nopen category_theory.limits\nopen category_theory.idempotents\n\nvariables {C : Type*} [category C] [is_idempotent_complete C]\n  [preadditive C] [has_finite_coproducts C]\n\nnamespace category_theory\n\nnamespace idempotents\n\nnamespace dold_kan\n\nopen algebraic_topology.dold_kan\n\n/-- The functor `N` for the equivalence is obtained by composing\n`N' : simplicial_object C ⥤ karoubi (chain_complex C ℕ)` and the inverse\nof the equivalence `chain_complex C ℕ ≌ karoubi (chain_complex C ℕ)`. -/\n@[simps, nolint unused_arguments]\ndef N : simplicial_object C ⥤ chain_complex C ℕ :=\nN₁ ⋙ (to_karoubi_equivalence _).inverse\n\n/-- The functor `Γ` for the equivalence is `Γ'`. -/\n@[simps, nolint unused_arguments]\ndef Γ : chain_complex C ℕ ⥤ simplicial_object C := Γ₀\n\nlemma hN₁ : (to_karoubi_equivalence (simplicial_object C)).functor ⋙\n  preadditive.dold_kan.equivalence.functor = N₁ :=\nfunctor.congr_obj (functor_extension₁_comp_whiskering_left_to_karoubi _ _) N₁\n\nlemma hΓ₀ : (to_karoubi_equivalence (chain_complex C ℕ)).functor ⋙\n  preadditive.dold_kan.equivalence.inverse = Γ ⋙ (to_karoubi_equivalence _).functor :=\nfunctor.congr_obj (functor_extension₂_comp_whiskering_left_to_karoubi _ _) Γ₀\n\n/-- The Dold-Kan equivalence for pseudoabelian categories given\nby the functors `N` and `Γ`. It is obtained by applying the results in\n`compatibility.lean` to the equivalence `preadditive.dold_kan.equivalence`. -/\ndef equivalence : simplicial_object C ≌ chain_complex C ℕ :=\ncompatibility.equivalence (eq_to_iso hN₁) (eq_to_iso hΓ₀)\n\nlemma equivalence_functor : (equivalence : simplicial_object C ≌ _).functor = N := by refl\nlemma equivalence_inverse : (equivalence : simplicial_object C ≌ _).inverse = Γ := by refl\n\n/-- The natural isomorphism `NΓ' satisfies the compatibility that is needed\nfor the construction of our counit isomorphism `η` -/\nlemma hη : compatibility.τ₀ =\n  compatibility.τ₁ (eq_to_iso hN₁) (eq_to_iso hΓ₀)\n  (N₁Γ₀ : Γ ⋙ N₁ ≅ (to_karoubi_equivalence (chain_complex C ℕ)).functor) :=\nbegin\n  ext K : 3,\n  simpa only [compatibility.τ₀_hom_app, compatibility.τ₁_hom_app, eq_to_iso.hom,\n    preadditive.dold_kan.equivalence_counit_iso, N₂Γ₂_to_karoubi_iso_hom, eq_to_hom_map,\n    eq_to_hom_trans_assoc, eq_to_hom_app] using N₂Γ₂_compatible_with_N₁Γ₀ K,\nend\n\n/-- The counit isomorphism induced by `N₁Γ₀` -/\n@[simps]\ndef η : Γ ⋙ N ≅ 𝟭 (chain_complex C ℕ) := compatibility.equivalence_counit_iso\n  (N₁Γ₀ : (Γ : chain_complex C ℕ ⥤ _ ) ⋙ N₁ ≅ (to_karoubi_equivalence _).functor)\n\nlemma equivalence_counit_iso :\n  dold_kan.equivalence.counit_iso = (η : Γ ⋙ N ≅ 𝟭 (chain_complex C ℕ)) :=\ncompatibility.equivalence_counit_iso_eq hη\n\nlocal attribute [-simp, reassoc] nat_trans.comp_app\n\nlemma hε : compatibility.υ (eq_to_iso hN₁) =\n  (Γ₂N₁ : (to_karoubi_equivalence _).functor ≅ (N₁ : simplicial_object C ⥤ _) ⋙\n  preadditive.dold_kan.equivalence.inverse) :=\nbegin\n  ext X : 4,\n  erw [nat_trans.comp_app, compatibility_Γ₂N₁_Γ₂N₂_nat_trans],\n  simp only [compatibility.υ_hom_app, compatibility_Γ₂N₁_Γ₂N₂,\n    preadditive.dold_kan.equivalence_unit_iso, Γ₂N₂, iso.symm_hom, as_iso_inv, assoc],\n  erw [← nat_trans.comp_app_assoc, is_iso.hom_inv_id],\n  dsimp,\n  simpa only [id_comp, eq_to_hom_app, eq_to_hom_map, eq_to_hom_trans],\nend\n\n/-- The unit isomorphism induced by `Γ₂N₁`. -/\n@[simps]\ndef ε : 𝟭 (simplicial_object C) ≅ N ⋙ Γ :=\ncompatibility.equivalence_unit_iso (eq_to_iso hΓ₀) Γ₂N₁\n\nlemma equivalence_unit_iso : dold_kan.equivalence.unit_iso =\n  (ε : 𝟭 (simplicial_object C) ≅ N ⋙ Γ) :=\ncompatibility.equivalence_unit_iso_eq hε\n\nend dold_kan\n\nend idempotents\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "dold-kan", "sha": "a083fe264275774ac49ac520caf25f2ee29debb1", "save_path": "github-repos/lean/joelriou-dold-kan", "path": "github-repos/lean/joelriou-dold-kan/dold-kan-a083fe264275774ac49ac520caf25f2ee29debb1/src/for_mathlib/dold_kan/equivalence_pseudoabelian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.47068579452154574}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.idempotents.karoubi\n\n/-!\n# Idempotent completeness and functor categories\n\nIn this file we define an instance `functor_category_is_idempotent_complete` expressing\nthat a functor category `J ⥤ C` is idempotent complete when the target category `C` is.\n\nWe also provide a fully faithful functor\n`karoubi_functor_category_embedding : karoubi (J ⥤ C)) : J ⥤ karoubi C` for all categories\n`J` and `C`.\n\n-/\n\nopen category_theory\nopen category_theory.category\nopen category_theory.idempotents.karoubi\nopen category_theory.limits\n\nnamespace category_theory\n\nnamespace idempotents\n\nvariables (J C : Type*) [category J] [category C]\n\ninstance functor_category_is_idempotent_complete [is_idempotent_complete C] :\n  is_idempotent_complete (J ⥤ C) :=\nbegin\n  refine ⟨_⟩,\n  intros F p hp,\n  have hC := (is_idempotent_complete_iff_has_equalizer_of_id_and_idempotent C).mp infer_instance,\n  haveI : ∀ (j : J), has_equalizer (𝟙 _) (p.app j) := λ j, hC _ _ (congr_app hp j),\n  /- We construct the direct factor `Y` associated to `p : F ⟶ F` by computing\n    the equalizer of the identity and `p.app j` on each object `(j : J)`.  -/\n  let Y : J ⥤ C :=\n  { obj := λ j, limits.equalizer (𝟙 _) (p.app j),\n    map := λ j j' φ, equalizer.lift (limits.equalizer.ι (𝟙 _) (p.app j) ≫ F.map φ)\n      (by rw [comp_id, assoc, p.naturality φ, ← assoc, ← limits.equalizer.condition, comp_id]),\n    map_id' := λ j, by { ext, simp only [comp_id, functor.map_id, equalizer.lift_ι, id_comp], },\n    map_comp' := λ j j' j'' φ φ', begin\n      ext,\n      simp only [assoc, functor.map_comp, equalizer.lift_ι, equalizer.lift_ι_assoc],\n    end },\n  let i : Y ⟶ F :=\n  { app := λ j, equalizer.ι _ _,\n    naturality' := λ j j' φ, by rw [equalizer.lift_ι],  },\n  let e : F ⟶ Y :=\n  { app := λ j, equalizer.lift (p.app j)\n      (by { rw comp_id, exact (congr_app hp j).symm, }),\n    naturality' := λ j j' φ, begin\n      ext,\n      simp only [assoc, equalizer.lift_ι, nat_trans.naturality, equalizer.lift_ι_assoc],\n    end },\n  use [Y, i, e],\n  split; ext j,\n  { simp only [nat_trans.comp_app, assoc, equalizer.lift_ι, nat_trans.id_app, id_comp,\n      ← equalizer.condition, comp_id], },\n  { simp only [nat_trans.comp_app, equalizer.lift_ι], },\nend\n\nnamespace karoubi_functor_category_embedding\n\nvariables {J C}\n\n/-- On objects, the functor which sends a formal direct factor `P` of a\nfunctor `F : J ⥤ C` to the functor `J ⥤ karoubi C` which sends `(j : J)` to\nthe corresponding direct factor of `F.obj j`. -/\n@[simps]\ndef obj (P : karoubi (J ⥤ C)) : J ⥤ karoubi C :=\n{ obj := λ j, ⟨P.X.obj j, P.p.app j, congr_app P.idem j⟩,\n  map := λ j j' φ,\n  { f := P.p.app j ≫ P.X.map φ,\n    comm := begin\n      simp only [nat_trans.naturality, assoc],\n      have h := congr_app P.idem j,\n      rw [nat_trans.comp_app] at h,\n      slice_rhs 1 3 { erw [h, h], },\n    end },\n  map_id' := λ j, by { ext, simp only [functor.map_id, comp_id, id_eq], },\n  map_comp' := λ j j' j'' φ φ', begin\n    ext,\n    have h := congr_app P.idem j,\n    rw [nat_trans.comp_app] at h,\n    simp only [assoc, nat_trans.naturality_assoc, functor.map_comp, comp],\n    slice_rhs 1 2 { rw h, },\n    rw [assoc],\n  end }\n\n/-- Tautological action on maps of the functor `karoubi (J ⥤ C) ⥤ (J ⥤ karoubi C)`. -/\n@[simps]\ndef map {P Q : karoubi (J ⥤ C)} (f : P ⟶ Q) : obj P ⟶ obj Q :=\n{ app := λ j, ⟨f.f.app j, congr_app f.comm j⟩,\n  naturality' := λ j j' φ, begin\n    ext,\n    simp only [comp],\n    have h := congr_app (comp_p f) j,\n    have h' := congr_app (p_comp f) j',\n    dsimp at h h' ⊢,\n    slice_rhs 1 2 { erw h, },\n    rw ← P.p.naturality,\n    slice_lhs 2 3 { erw h', },\n    rw f.f.naturality,\n  end }\n\nend karoubi_functor_category_embedding\n\nvariables (J C)\n\n/-- The tautological fully faithful functor `karoubi (J ⥤ C) ⥤ (J ⥤ karoubi C)`. -/\n@[simps]\ndef karoubi_functor_category_embedding :\n  karoubi (J ⥤ C) ⥤ (J ⥤ karoubi C) :=\n{ obj := karoubi_functor_category_embedding.obj,\n  map := λ P Q, karoubi_functor_category_embedding.map,\n  map_id' := λ P, rfl,\n  map_comp' := λ P Q R f g, rfl, }\n\ninstance : full (karoubi_functor_category_embedding J C) :=\n{ preimage := λ P Q f,\n  { f :=\n    { app := λ j, (f.app j).f,\n      naturality' := λ j j' φ, begin\n        slice_rhs 1 1 { rw ← karoubi.comp_p, },\n        have h := hom_ext.mp (f.naturality φ),\n        simp only [comp] at h,\n        dsimp [karoubi_functor_category_embedding] at h ⊢,\n        erw [assoc, ← h, ← P.p.naturality φ, assoc, p_comp (f.app j')],\n      end },\n    comm := by { ext j, exact (f.app j).comm, } },\n  witness' := λ P Q f, by { ext j, refl, }, }\n\ninstance : faithful (karoubi_functor_category_embedding J C) :=\n{ map_injective' := λ P Q f f' h, by { ext j, exact hom_ext.mp (congr_app h j), }, }\n\n/-- The composition of `(J ⥤ C) ⥤ karoubi (J ⥤ C)` and `karoubi (J ⥤ C) ⥤ (J ⥤ karoubi C)`\nequals the functor `(J ⥤ C) ⥤ (J ⥤ karoubi C)` given by the composition with\n`to_karoubi C : C ⥤ karoubi C`. -/\nlemma to_karoubi_comp_karoubi_functor_category_embedding :\n  (to_karoubi _) ⋙ karoubi_functor_category_embedding J C =\n  (whiskering_right J _ _).obj (to_karoubi C) :=\nbegin\n  refine functor.ext _ _ ,\n  { intro X,\n    refine functor.ext (λ j, rfl) _,\n    { intros j j' φ,\n      ext,\n      dsimp,\n      simpa only [comp_id, id_comp], },  },\n  { intros X Y f,\n    ext j,\n    dsimp [to_karoubi],\n    simp only [eq_to_hom_app, eq_to_hom_refl, id_comp],\n    erw [comp_id], },\nend\n\nvariables {J C}\n\n@[simp, reassoc]\nlemma app_idem (P : karoubi (J ⥤ C)) (X : J) :\n  P.p.app X ≫ P.p.app X = P.p.app X := congr_app P.idem X\n\nnamespace nat_trans\n\n@[simp, reassoc]\nlemma app_p_comp {P Q : karoubi (J ⥤ C)} (f : P ⟶ Q) (X : J) :\n  P.p.app X ≫ f.f.app X = f.f.app X :=\ncongr_app (p_comp f) X\n\n@[simp, reassoc]\nlemma app_comp_p {P Q : karoubi (J ⥤ C)} (f : P ⟶ Q) (X : J) :\n  f.f.app X ≫ Q.p.app X = f.f.app X :=\ncongr_app (comp_p f) X\n\n@[reassoc]\nlemma app_p_comm {P Q : karoubi (J ⥤ C)} (f : P ⟶ Q) (X : J) :\n  P.p.app X ≫ f.f.app X = f.f.app X ≫ Q.p.app X :=\ncongr_app (p_comm f) X\n\nend nat_trans\n\nend idempotents\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "dold-kan", "sha": "a083fe264275774ac49ac520caf25f2ee29debb1", "save_path": "github-repos/lean/joelriou-dold-kan", "path": "github-repos/lean/joelriou-dold-kan/dold-kan-a083fe264275774ac49ac520caf25f2ee29debb1/src/for_mathlib/idempotents/functor_categories.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4706757475060118}}
{"text": "import Days\nimport Days.Common\nimport Std\nimport Lean.Data.Parsec\n\nopen Days\nopen Days.Common\nopen Std (RBSet Queue RBMap)\nopen Lean.Parsec\nopen Lean (Parsec)\n\nnamespace Days.Day11\ndef day: ProblemNumber := 11\n\ndef sample := \"Monkey 0:\n  Starting items: 79, 98\n  Operation: new = old * 19\n  Test: divisible by 23\n    If true: throw to monkey 2\n    If false: throw to monkey 3\n\nMonkey 1:\n  Starting items: 54, 65, 75, 74\n  Operation: new = old + 6\n  Test: divisible by 19\n    If true: throw to monkey 2\n    If false: throw to monkey 0\n\nMonkey 2:\n  Starting items: 79, 60, 97\n  Operation: new = old * old\n  Test: divisible by 13\n    If true: throw to monkey 1\n    If false: throw to monkey 3\n\nMonkey 3:\n  Starting items: 74\n  Operation: new = old + 3\n  Test: divisible by 17\n    If true: throw to monkey 0\n    If false: throw to monkey 1\"\n\nstructure Item where\n  worry: Nat\n  deriving Inhabited\n\ninstance : Repr Item where\n  reprPrec i _ := .text s!\"w={i.worry}\"\n\ninstance : OfNat Item n where\n  ofNat := .mk n\n\nabbrev Items := Array Item\n\nabbrev MonkeyId := Nat\n\nstructure Monkey where\n  id: MonkeyId\n  items: Items\n  worryModifier: Nat → Nat\n  testVal: Nat\n  trueTarget: MonkeyId\n  falseTarget: MonkeyId\n  observedItems: Nat := 0\n\ninstance : Inhabited Monkey where\n  default := Monkey.mk 0 ∅ id 1 0 0 0\n\ninstance : Repr Monkey where\n  reprPrec m _ := .text s!\"Moneky({m.id}) \\{ items := {reprArg m.items} t:{m.trueTarget} f:{m.falseTarget} }\" \n\nabbrev Map (key: Type) [Ord key]  (value: Type) := RBMap key value compare\n\nabbrev MonkeyMap := Map MonkeyId Monkey\n\nstructure WorryState where\n  worry: Nat\n\nexport Functor (map)\n\n/--\nNeeds to parse strings like:\n- `Operation: new = old * 19`\n- `Operation: new = old * old`\n- `Operation: new = old + 6`\n- `Operation: new = old * 19`\n-/\ndef parseWorryOperation : Parsec $ Nat -> Nat := do\n  _ ← pstring \"Operation: new = \"\n  return ← operation\n  where\n    opFunction: Parsec $ Nat → Nat → Nat := do\n      let op ← ws *> (pchar '*' <|> pchar '+') <* ws\n      return match op with\n      | '*' => fun (x₁ x₂: Nat) => x₁ * x₂\n      | '+' => fun (x₁ x₂: Nat) => x₁ + x₂\n      | u => fun (_ _: Nat) => panic! s!\"Unknown op: {u}\"\n    operand : Parsec $ Nat → Nat :=\n      return match ← pstring \"old\" <|> many1Chars digit with\n      | \"old\" => id\n      | digits => \n        let num := String.toNat! digits\n        fun _ => num\n    operation : Parsec $ Nat → Nat := do\n      let op₁ ← operand\n      let f ← opFunction\n      let op₂ ← operand\n      return fun (worry: Nat) => \n        f (op₁ worry) (op₂ worry)\n\ndef parseNat : Parsec Nat := map String.toNat! $ many1Chars digit\ndef parseItemsList: Parsec $ Items := many1 (map Item.mk $ parseNat <* (attempt (pchar ',' *> ws) <|> skip))\n\n#eval \"1, 2, 3\".iter |> parseItemsList\n\n/--\nParses:\n\n```\nMonkey 0:\n  Starting items: 79, 98\n  Operation: new = old * 19\n  Test: divisible by 23\n    If true: throw to monkey 2\n    If false: throw to monkey 3\n```\n-/\ndef parseMonkey: Parsec Monkey := do\n  let monkeyNumber ← ws *> pstring \"Monkey\" *> ws *> parseNat <* pchar ':' <* ws\n  let items: Array Item ← pstring \"Starting items:\" *> ws *> parseItemsList <* ws\n  let itemQueue : Items := items -- (∅ : Items).enqueueAll items.toList\n  let op ← ws *> parseWorryOperation <* ws\n  let test ← testVal\n  let trueTarget ← pstring \"If true: throw to monkey \" *> parseNat <* ws\n  let falseTarget ← pstring \"If false: throw to monkey \" *> parseNat <* ws\n\n  return Monkey.mk monkeyNumber itemQueue op test trueTarget falseTarget 0\n  where\n    testVal := pstring \"Test: divisible by \" *> ws *> parseNat <* ws\n\ndef parseMonkeys : Parsec MonkeyMap := do\n  let allMonkeys ← many1 parseMonkey\n  return allMonkeys.foldl (init:=∅) (λ map m => \n    map.insert m.id m\n  )\n\n#eval parseMonkeys sample.iter\n\ndef monkey₀ := Monkey.mk 0 #[79, 98] (·*19) 23 2 3 0\ndef monkey₁ := Monkey.mk 1 #[54, 65, 75, 74] (·+6) 19 2 0 0\ndef monkey₂ := Monkey.mk 2 #[79, 60, 97] (λ x => x * x) 13 1 3 0\ndef monkey₃ := Monkey.mk 3 #[74] (·+3) 17 0 1 0\n\ndef monkeyExamples : MonkeyMap := \n  [\n    (0, monkey₀),\n    (1, monkey₁),\n    (2, monkey₂),\n    (3, monkey₃)\n  ].toRBMap compare\n\ndef processMonkeyItem (monkey: Monkey) (worryReducer: Nat → Nat) (map: MonkeyMap) (item: Item) : MonkeyMap := \n  let worryFromInspection := monkey.worryModifier item.worry\n  -- After each monkey inspects an item but before it tests your worry level, \n  -- your relief that the monkey's inspection didn't damage the item \n  -- causes your worry level to be divided by three and rounded down to the nearest integer.\n  let worryAfterInspection : Nat := worryReducer worryFromInspection\n\n  -- Cheat: Since all monkeys test for division using primes we can just use\n  -- modular arithmetic under the ring of (m₁.testVal * m₂.testVal * ...)\n  -- (is that the LCM? i think so since they're all primes...)\n  -- This works because modular math and at least one of the monkeys tests will always match\n  -- First i thought about finding a co-prime to be a divisor, \n  -- but then they're all primes (and the example was 3 which would have been co-prime)... \n  -- so that would be easy and also didn't work\n  let coprimeReduction (n: Nat) : Nat :=\n    let ring := map.foldl (init:=1) (λ co _ v => co * v.testVal)\n    n % ring\n  let boundedWorry := coprimeReduction worryAfterInspection\n  let target := \n    if divisibleBy monkey.testVal boundedWorry \n    then monkey.trueTarget \n    else monkey.falseTarget\n  \n  let newItem : Item := Item.mk boundedWorry\n\n  map.modify target (λ m => \n      let items: Items := #[].append m.items |>.push newItem\n      { m with items }\n  )\n  where\n    divisibleBy (n val: Nat) : Bool := val % n == 0\n\ndef processMonkey (monkey: Monkey) (map: MonkeyMap) (worryReducer: Nat → Nat := (·/3)) : MonkeyMap :=\n  monkey.items.foldl (init:=removedItems) (processMonkeyItem monkey worryReducer)\n  where \n    removedItems := map.modify monkey.id (λ m => { m with items := ∅, observedItems := monkey.observedItems + monkey.items.size })\n\n#eval monkeyExamples\n  |> processMonkey monkey₀ \n#eval monkeyExamples\n  |> processMonkey monkey₀  \n  |> processMonkey monkey₁\n#eval monkeyExamples \n  |> processMonkey monkey₀\n  |> processMonkey monkey₁\n  |> processMonkey monkey₂\n\n#eval monkeyExamples\n  |> (λ x => processMonkey (x.find? 0).get! x)\n  |> (λ x => processMonkey (x.find? 1).get! x)\n  |> (λ x => processMonkey (x.find? 2).get! x)\n  |> (λ x => processMonkey (x.find? 3).get! x)\n\n#eval monkeyExamples\n  |> processMonkey monkey₀  \n  |> processMonkey monkey₁\n  |> processMonkey monkey₂\n  |> processMonkey monkey₃\n  |>.find? 1\n\n#eval monkeyExamples\n  |> processMonkey monkey₀  \n  |> processMonkey monkey₁\n  |> processMonkey monkey₂\n  |>.find? 3\n\ndef monkeysRound (map: MonkeyMap) (worryReducer: Nat → Nat := (·/3)) : MonkeyMap :=\n  map.foldl (init:=map) (λ map id _ => \n    processMonkey (map.find? id).get! map worryReducer\n  )\n\n#eval monkeyExamples |> monkeysRound\n\ndef parseAll [ToInput i] (input: i) : MonkeyMap :=\n  match parseMonkeys (toInput input).iter with\n  | .success _ monkies => monkies\n  | .error pos msg => panic! s!\"Oops: {msg} @ {pos}\"\n\ndef runRounds (rounds: Nat) (worryReducer: Nat → Nat) : StateM (MonkeyMap × Array (Nat ×  MonkeyMap)) Unit := do\n  for _round in [1:rounds+1] do\n    let (current, history) ← get\n    let round := monkeysRound current worryReducer\n    set $ (round, history.push (_round, round))\n\nabbrev MonkeyCountMap := Map MonkeyId Nat\n\ndef roundHistory [ToInput κ] (input: κ) (rounds: Nat) (worryReducer: Nat → Nat := (·/3)) : Array $ Nat × MonkeyMap :=\n  let initialMonkeys := parseAll (toInput input)\n  let result := StateT.run (runRounds rounds worryReducer) (initialMonkeys, #[(0, initialMonkeys)]) \n  let (_, history): MonkeyMap × Array (Nat × MonkeyMap) := result.snd\n  history\n\n#eval roundHistory sample 20\n\ndef run [ToInput κ] (input: κ) (rounds: Nat) (worryReducer: Nat → Nat := (·/3)) : Array Nat :=\n  roundHistory input rounds worryReducer\n  |>.map (λ ((_, round): Nat × MonkeyMap) => \n    round.foldl (init:=∅) (λ (state: MonkeyCountMap) (k: MonkeyId) (m: Monkey) => \n      state.insert k m.observedItems\n    )\n  )\n  |>.lastD ∅\n  |>.valuesArray\n  |>.qsort (Ordering.lt == compare · ·)\n\n#eval run sample 20\n/--\n-/\ndef part₁ (input: Input) : Nat :=\n  let rounds := 20\n  run input rounds\n  |>.lastN 2\n  |> Subarray.toArray\n  |>.toList\n  |> mul 1\n\n/--\n-/\ndef part₂ (input: Input) : Nat :=\n  let rounds := 10000\n  run input rounds id\n  |>.lastN 2\n  |> Subarray.toArray\n  |>.toList\n  |> mul 1\n\ndef solution : Problem Nat := ⟨ day, part₁, part₂ ⟩ \n\n#eval testPart₁ solution sample (expect:=10605)\n-- #eval testPart₂ solution sample (expect:=0)\n\n", "meta": {"author": "jakeswenson", "repo": "advent2022", "sha": "af941092292ff0bc5552bce9c145d6b5b173c20d", "save_path": "github-repos/lean/jakeswenson-advent2022", "path": "github-repos/lean/jakeswenson-advent2022/advent2022-af941092292ff0bc5552bce9c145d6b5b173c20d/Days/Day11.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4706757407911951}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies, Kexing Ying. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Kexing Ying\n-/\nimport combinatorics.hall.basic\nimport combinatorics.simple_graph.acyclic\nimport combinatorics.simple_graph.clique\nimport data.real.sqrt\nimport set_theory.cardinal.basic\n\n/-!\n# Graph Theory, example sheet 2\n\nHere are the statements (and hopefully soon proofs!) of the questions from the second example sheet\nof the Cambridge Part II course Graph Theory.\n\nIf you solve a question in Lean, feel free to open a Pull Request on Github!\n-/\n\n/-!\n### Question 1\n\nFor a graph $$G$$, show that $$κ(G) ≤ λ(G) ≤ δ(G)$$.\n-/\n\n/-!\n### Question 2\n\nLet $$G be a graph. Show that $$e(G) > {χ(G) \\choose 2}$$.\n-/\n\n/-!\n### Question 3\n\nLet $$G$$ be a $$k$$-connected graph and let $$y, x_1, \\dots, x_k$$ be distinct vertices in $$G$$.\nShow that there exists paths $$P_1, \\dots, P_k$$, where $$P_i$$ is a $$y − x_i$$ path and\n$$P_1, \\dots, P_k$$ have no vertices in common, apart from the vertex $$y$$.\n-/\n\n/-!\n### Question 4\n\nAn independent set in a graph $$G = (V, E)$$ is a subset $$I ⊆ V$$ so that $$x ≁ y$$ for all\n$$x, y ∈ I$$. Let $$G = (V, E)$$ be a connected graph with $$∆(G) ≤ 3$$ and $$|V| ≥ 10$$. Show that\nthere exists an independent set $$I ⊆ V$$ so that every odd cycle in $$G$$ intersects $$I$$.\n-/\n\n/-!\n### Question 5\n\nDetermine the chromatic polynomial of the $$n$$-cycle $$C_n$$.\n-/\n\n/-!\n### Question 6\n\nLet $$G$$ be a graph on $$n$$ vertices, show that the coefficients of the chromatic polynomial\n$$P_G$$ alternate in sign. That is, if $$P_G = P_ni=0 cit\ni\n, Then cn−j > 0 for even j and cn−j 6 0 for odd j. Also\nshow that if G has m edges and k triangles then cn−2 =\nm\n2\n\u0001\n− k.\n-/\n\n/-!\n### Question 7\n\nDetermine $$χ(K_{n,n}$$). Determine $$χ(K_n)$$.\n-/\n\n/-!\n### Question 8\n\nLet $$G$$ be a graph that has an orientation where the longest directed path has length $$t$$ (that\nis, a sequence of oriented edges $$(v_1, v_2), \\dots, (v_t, v_{t + 1})$$. Then $$χ(G) ≤ t + 1$$.\n-/\n\n/-!\n### Question 9\n\nCan $$K_{4, 4}$$ be drawn on the torus? What about $$K_{5, 5}$$?\n-/\n\n/-!\n### Question 10\n\nLet $$G$$ be a bipartite graph with maximum degree $$∆$$. Must we have $$χ(G) = ∆(G)$$?\n-/\n\n/-!\n### Question 11\n\nLet $$G = (V, E)$$ be a graph where $$V$$, $$E$$ are countably infinite. Show that $$χ(G) ≤ k$$ if\nand only if $$χ(H) ≤ k$$ for every finite subgraph $$H$$ of $$G$$.\n-/\n\n/-!\n### Question 12\n\nFor $$k > 2$$, let $$G = (V, E)$$ be a $$k$$-connected graph and let $${x_1, \\dots, x_k} ⊆ V$$. Show\nthat there exists a cycle containing each of the vertices $$x_1, \\dots, x_k$$.\n-/\n\n/-!\n### Question 13\n\nFor each $$r > 2$$, construct a graph $$G$$ that does not contain a $$K_{r + 1}$$ and $$χ(G) > r$$.\n-/\n\n/-!\n### Question 14\n\nA graph is outer-planar if it can be drawn in the plane so that all of its vertices are on the\ninfinite face. Articulate a conjecture of the form “Let $$G$$ be a graph with $$|G| > 5$$. $$G$$ is\nouter-planar if and only if ...”. Prove your conjecture.\n-/\n\n/-!\n### Question 15\n\nShow there is a triangle free graph with chromatic number $$2022$$.\n-/\n\n/-!\n### Question 16\n\nLet $$G$$ be a triangulation (a plane graph where every face is a triangle) and let $$G◦$$ be the\nplanar dual of $$G$$: the vertices of $$G◦$$ are the faces of $$G$$ and edges in $$G◦$$ join faces\nthat share a boundary edge (in $$G$$). Prove that $$χ(G) ≤ 4$$ if and only if $$χ(G◦) ≤ 3$$.\n-/\n", "meta": {"author": "YaelDillies", "repo": "LeanCamCombi", "sha": "9f62375030cd2bd1be6ef10bba68b1b31aa98acf", "save_path": "github-repos/lean/YaelDillies-LeanCamCombi", "path": "github-repos/lean/YaelDillies-LeanCamCombi/LeanCamCombi-9f62375030cd2bd1be6ef10bba68b1b31aa98acf/src/example_sheets/graph/es2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.4706757374337867}}
{"text": "/-\nCopyright (c) 2022 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport dynamics.ergodic.measure_preserving\n\n/-!\n# Ergodic maps and measures\n\nLet `f : α → α` be measure preserving with respect to a measure `μ`. We say `f` is ergodic with\nrespect to `μ` (or `μ` is ergodic with respect to `f`) if the only measurable sets `s` such that\n`f⁻¹' s = s` are either almost empty or full.\n\nIn this file we define ergodic maps / measures together with quasi-ergodic maps / measures and\nprovide some basic API. Quasi-ergodicity is a weaker condition than ergodicity for which the measure\npreserving condition is relaxed to quasi measure preserving.\n\n# Main definitions:\n\n * `pre_ergodic`: the ergodicity condition without the measure preserving condition. This exists\n   to share code between the `ergodic` and `quasi_ergodic` definitions.\n * `ergodic`: the definition of ergodic maps / measures.\n * `quasi_ergodic`: the definition of quasi ergodic maps / measures.\n * `ergodic.quasi_ergodic`: an ergodic map / measure is quasi ergodic.\n * `quasi_ergodic.ae_empty_or_univ'`: when the map is quasi measure preserving, one may relax the\n   strict invariance condition to almost invariance in the ergodicity condition.\n\n-/\n\nopen set function filter measure_theory measure_theory.measure\nopen_locale ennreal\n\nvariables {α : Type*} {m : measurable_space α} (f : α → α) {s : set α}\ninclude m\n\n/-- A map `f : α → α` is said to be pre-ergodic with respect to a measure `μ` if any measurable\nstrictly invariant set is either almost empty or full. -/\nstructure pre_ergodic (μ : measure α . volume_tac) : Prop :=\n(ae_empty_or_univ : ∀ ⦃s⦄, measurable_set s → f⁻¹' s = s → s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ)\n\n/-- A map `f : α → α` is said to be ergodic with respect to a measure `μ` if it is measure\npreserving and pre-ergodic. -/\n@[nolint has_nonempty_instance] structure ergodic (μ : measure α . volume_tac) extends\n  measure_preserving f μ μ, pre_ergodic f μ : Prop\n\n/-- A map `f : α → α` is said to be quasi ergodic with respect to a measure `μ` if it is quasi\nmeasure preserving and pre-ergodic. -/\n@[nolint has_nonempty_instance] structure quasi_ergodic (μ : measure α . volume_tac) extends\n  quasi_measure_preserving f μ μ, pre_ergodic f μ : Prop\n\nvariables {f} {μ : measure α}\n\nnamespace pre_ergodic\n\nlemma measure_self_or_compl_eq_zero (hf : pre_ergodic f μ)\n  (hs : measurable_set s) (hs' : f⁻¹' s = s) :\n  μ s = 0 ∨ μ sᶜ = 0 :=\nby simpa using hf.ae_empty_or_univ hs hs'\n\n/-- On a probability space, the (pre)ergodicity condition is a zero one law. -/\nlemma prob_eq_zero_or_one [is_probability_measure μ] (hf : pre_ergodic f μ)\n  (hs : measurable_set s) (hs' : f⁻¹' s = s) :\n  μ s = 0 ∨ μ s = 1 :=\nby simpa [hs] using hf.measure_self_or_compl_eq_zero hs hs'\n\nlemma of_iterate (n : ℕ) (hf : pre_ergodic (f^[n]) μ) : pre_ergodic f μ :=\n⟨λ s hs hs', hf.ae_empty_or_univ hs $ is_fixed_pt.preimage_iterate hs' n⟩\n\nend pre_ergodic\n\nnamespace measure_theory.measure_preserving\n\nvariables {β : Type*} {m' : measurable_space β} {μ' : measure β} {s' : set β} {g : α → β}\n\nlemma pre_ergodic_of_pre_ergodic_conjugate (hg : measure_preserving g μ μ')\n  (hf : pre_ergodic f μ) {f' : β → β} (h_comm : g ∘ f = f' ∘ g) :\n  pre_ergodic f' μ' :=\n⟨begin\n  intros s hs₀ hs₁,\n  replace hs₁ : f⁻¹' (g⁻¹' s) = g⁻¹' s, { rw [← preimage_comp, h_comm, preimage_comp, hs₁], },\n  cases hf.ae_empty_or_univ (hg.measurable hs₀) hs₁ with hs₂ hs₂;\n  [left, right],\n  { simpa only [ae_eq_empty, hg.measure_preimage hs₀] using hs₂, },\n  { simpa only [ae_eq_univ, ← preimage_compl, hg.measure_preimage hs₀.compl] using hs₂, },\nend⟩\n\nlemma pre_ergodic_conjugate_iff {e : α ≃ᵐ β} (h : measure_preserving e μ μ') :\n  pre_ergodic (e ∘ f ∘ e.symm) μ' ↔ pre_ergodic f μ :=\nbegin\n  refine ⟨λ hf, pre_ergodic_of_pre_ergodic_conjugate (h.symm e) hf _,\n          λ hf, pre_ergodic_of_pre_ergodic_conjugate h hf _⟩,\n  { change (e.symm ∘ e) ∘ f ∘ e.symm = f ∘ e.symm,\n    rw [measurable_equiv.symm_comp_self, comp.left_id], },\n  { change e ∘ f = e ∘ f ∘ e.symm ∘ e,\n    rw [measurable_equiv.symm_comp_self, comp.right_id], },\nend\n\nlemma ergodic_conjugate_iff {e : α ≃ᵐ β} (h : measure_preserving e μ μ') :\n  ergodic (e ∘ f ∘ e.symm) μ' ↔ ergodic f μ :=\nbegin\n  have : measure_preserving (e ∘ f ∘ e.symm) μ' μ' ↔ measure_preserving f μ μ :=\n    by rw [h.comp_left_iff, (measure_preserving.symm e h).comp_right_iff],\n  replace h : pre_ergodic (e ∘ f ∘ e.symm) μ' ↔ pre_ergodic f μ := h.pre_ergodic_conjugate_iff,\n  exact ⟨λ hf, { .. this.mp hf.to_measure_preserving, .. h.mp hf.to_pre_ergodic, },\n         λ hf, { .. this.mpr hf.to_measure_preserving, .. h.mpr hf.to_pre_ergodic, }⟩,\nend\n\nend measure_theory.measure_preserving\n\nnamespace quasi_ergodic\n\n/-- For a quasi ergodic map, sets that are almost invariant (rather than strictly invariant) are\nstill either almost empty or full. -/\nlemma ae_empty_or_univ'\n  (hf : quasi_ergodic f μ) (hs : measurable_set s) (hs' : f⁻¹' s =ᵐ[μ] s) :\n  s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ :=\nbegin\n  obtain ⟨t, h₀, h₁, h₂⟩ := hf.to_quasi_measure_preserving.exists_preimage_eq_of_preimage_ae hs hs',\n  rcases hf.ae_empty_or_univ h₀ h₂ with h₃ | h₃;\n  [left, right];\n  exact ae_eq_trans h₁.symm h₃,\nend\n\nend quasi_ergodic\n\nnamespace ergodic\n\n/-- An ergodic map is quasi ergodic. -/\nlemma quasi_ergodic (hf : ergodic f μ) : quasi_ergodic f μ :=\n{ .. hf.to_pre_ergodic,\n  .. hf.to_measure_preserving.quasi_measure_preserving, }\n\n/-- See also `ergodic.ae_empty_or_univ_of_preimage_ae_le`. -/\nlemma ae_empty_or_univ_of_preimage_ae_le'\n  (hf : ergodic f μ) (hs : measurable_set s) (hs' : f⁻¹' s ≤ᵐ[μ] s) (h_fin : μ s ≠ ∞) :\n  s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ :=\nbegin\n  refine hf.quasi_ergodic.ae_empty_or_univ' hs _,\n  refine ae_eq_of_ae_subset_of_measure_ge hs' (hf.measure_preimage hs).symm.le _ h_fin,\n  exact measurable_set_preimage hf.measurable hs,\nend\n\n/-- See also `ergodic.ae_empty_or_univ_of_ae_le_preimage`. -/\nlemma ae_empty_or_univ_of_ae_le_preimage'\n  (hf : ergodic f μ) (hs : measurable_set s) (hs' : s ≤ᵐ[μ] f⁻¹' s) (h_fin : μ s ≠ ∞) :\n  s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ :=\nbegin\n  replace h_fin : μ (f⁻¹' s) ≠ ∞, { rwa hf.measure_preimage hs, },\n  refine hf.quasi_ergodic.ae_empty_or_univ' hs _,\n  exact (ae_eq_of_ae_subset_of_measure_ge hs' (hf.measure_preimage hs).le hs h_fin).symm,\nend\n\n/-- See also `ergodic.ae_empty_or_univ_of_image_ae_le`. -/\nlemma ae_empty_or_univ_of_image_ae_le'\n  (hf : ergodic f μ) (hs : measurable_set s) (hs' : f '' s ≤ᵐ[μ] s) (h_fin : μ s ≠ ∞) :\n  s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ :=\nbegin\n  replace hs' : s ≤ᵐ[μ] f ⁻¹' s :=\n    (has_subset.subset.eventually_le (subset_preimage_image f s)).trans\n    (hf.quasi_measure_preserving.preimage_mono_ae hs'),\n  exact ae_empty_or_univ_of_ae_le_preimage' hf hs hs' h_fin,\nend\n\nsection is_finite_measure\n\nvariables [is_finite_measure μ]\n\nlemma ae_empty_or_univ_of_preimage_ae_le\n  (hf : ergodic f μ) (hs : measurable_set s) (hs' : f⁻¹' s ≤ᵐ[μ] s) :\n  s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ :=\nae_empty_or_univ_of_preimage_ae_le' hf hs hs' $ measure_ne_top μ s\n\nlemma ae_empty_or_univ_of_ae_le_preimage\n  (hf : ergodic f μ) (hs : measurable_set s) (hs' : s ≤ᵐ[μ] f⁻¹' s) :\n  s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ :=\nae_empty_or_univ_of_ae_le_preimage' hf hs hs' $ measure_ne_top μ s\n\nlemma ae_empty_or_univ_of_image_ae_le\n  (hf : ergodic f μ) (hs : measurable_set s) (hs' : f '' s ≤ᵐ[μ] s) :\n  s =ᵐ[μ] (∅ : set α) ∨ s =ᵐ[μ] univ :=\nae_empty_or_univ_of_image_ae_le' hf hs hs' $ measure_ne_top μ s\n\nend is_finite_measure\n\nend ergodic\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/dynamics/ergodic/ergodic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.47067573407637825}}
{"text": "/-\nCopyright (c) 2022 Jun Yoshida. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n-/\n\nimport Mathlib.Data.List.Basic\n\nnamespace List\n\nuniverse u v w\n\ntheorem map_comp {α : Type u} {β : Type v} {γ : Type w} (g : β → γ) (f : α → β) : ∀ {as : List α}, map (g∘ f) as = map g (as.map f) := by\n  intro as\n  induction as\n  case nil => rfl\n  case cons a as h_ind =>\n    dsimp [map]\n    rw [h_ind]\n\ntheorem join_append {α : Type u} : ∀ (ass bss : List (List α)), (ass ++ bss).join = ass.join ++ bss.join\n| [], bss => rfl\n| (as::ass), bss => by\n  dsimp [join]\n  rw [List.append_assoc, join_append ass bss]\n\ntheorem join_join {α : Type u} : ∀ (asss : List (List (List α))), asss.join.join = (asss.map join).join\n| [] => rfl\n| cons as asss => by\n  dsimp [join]\n  rw [join_append, join_join asss]\n\ntheorem map_join {α : Type u} {β : Type v} (f : α → β) : ∀ {ass : List (List α)}, map f ass.join = join (map (map f) ass)\n| [] => rfl\n| (as::ass) => by\n  dsimp [join]\n  rw [map_append, map_join f (ass:=ass)]\n\nend List\n", "meta": {"author": "Junology", "repo": "Moncalc", "sha": "5c93c9eb907de01720e47397b5701754cc0e00c3", "save_path": "github-repos/lean/Junology-Moncalc", "path": "github-repos/lean/Junology-Moncalc/Moncalc-5c93c9eb907de01720e47397b5701754cc0e00c3/Moncalc/Data/List/Misc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.47060368180066886}}
{"text": "import to_mathlib\nimport data.fin\nimport Rings.ToMathlib.fin\n\nnamespace dvector\n\nvariables {α : Type*} {n : ℕ}\n\n\nlemma nil_append (as : dvector α n) :\n  dvector.append dvector.nil as = as :=\nby simp\n\n/-- Converts a dvector into an n-ary tuple -/\n@[simp] def fin_val (as : dvector α n) : fin n → α :=\nλ k, dvector.nth' as k\n @[simp] lemma cons_nth'_succ_eq_nth' {n} {x : α} {as : dvector α n} {k : fin n} :\n(dvector.cons x as).nth' (k.succ) = as.nth' k :=\nbegin\n  unfold dvector.nth',\n  simp,\nend\n\n/-- x_val is the same data as concatenation of dvectors -/\nlemma fin_val_eq_x_val {x : α} {as : dvector α n} :\n  fin_val (dvector.cons x as) = fin.x_val x (fin_val as) :=\nfunext (\n  @fin.cases n\n  (λ k, fin_val (dvector.cons x as) k = fin.x_val x (fin_val as) k)\n  rfl\n  (λ k, begin unfold fin_val, simp, end)\n  )\n\nlemma nth_eq_succ_nth : Π {k n : ℕ} {as : dvector α (n + 1)} {h : k < n},\nas.nth k (lt_trans h (by simp)) = (dvector.remove_mth (n + 2) as).nth k h\n| k nat.zero (dvector.cons a _) h := by {exfalso, simpa using h}\n| nat.zero (nat.succ n) (dvector.cons a as) h := by simp\n| (nat.succ k) (nat.succ n) (dvector.cons a as) h :=\n  by {simpa using nth_eq_succ_nth}\n\ndef of_list : Π (as : list α), dvector α (list.length as)\n| list.nil := dvector.nil\n| (list.cons a as) := dvector.cons a (of_list as)\n\ndef reverse : Π {n : ℕ} (v : dvector α n),\n  dvector α n\n| nat.zero _ := dvector.nil\n| (nat.succ n) (dvector.cons a v) := dvector.concat (reverse v) a\n\n/-- if you append and take nth its the same as just taking nth for small n-/\nlemma nth_append_small : Π {xl yl : ℕ}\n  {xs : dvector α xl} {ys : dvector α yl} {n : ℕ} (h : n < xl),\n  (dvector.append xs ys).nth n (nat.lt_of_lt_of_le h (nat.le_add_left _ _))\n  = xs.nth n h\n| 0             yl xs                  ys n h := by simpa using h\n| (nat.succ xl) yl (dvector.cons x xs) ys 0 h := by simp\n| (nat.succ xl) yl (dvector.cons x xs) ys (nat.succ n) h :=\nbegin\n  simp only [dvector.nth, dvector.append],\n  rw ← (@nth_append_small xl yl xs ys n (nat.succ_lt_succ_iff.1 h)),\n  refl,\nend\n\n/-- if you append and take nth its the same as just taking n - kth for big n-/\nlemma nth_append_big : Π {xl yl : ℕ}\n  {xs : dvector α xl} {ys : dvector α yl} {n : ℕ}\n  (hbig : xl ≤ n) (h : n < yl + xl),\n  (dvector.append xs ys).nth n h\n  = ys.nth (n - xl) ((nat.sub_lt_right_iff_lt_add hbig).2 h)\n| 0             yl nil                 ys n hbig h := by simpa\n| (nat.succ xl) yl (dvector.cons x xs) ys 0 hbig h :=\nbegin\n  exfalso,\n  exact nat.not_succ_le_zero _ hbig,\nend\n| (nat.succ xl) yl (dvector.cons x xs) ys (nat.succ n) hbig h :=\nbegin\n  simp only [nat.succ_sub_succ_eq_sub, dvector.append, dvector.nth],\n  apply nth_append_big (nat.le_of_succ_le_succ hbig),\nend\n\nlemma nth_cast : Π {xl yl k : ℕ}\n  {xs : dvector α xl}\n  (heq : xl = yl) (hk : k < yl),\n  (dvector.cast heq xs).nth k hk = xs.nth k (by simp [heq, hk])\n| 0             yl            k nil          heq hk :=\n  (k.not_lt_zero (by simp [heq, hk])).elim\n| (nat.succ xl) 0             k (cons x xs) heq hk :=\n  (nat.succ_ne_zero _ heq).elim\n| (nat.succ xl) (nat.succ yl) k (cons x xs) heq hk :=\nbegin\n  rw dvector.cast_cons heq x xs,\n  induction k with k hk,\n  {simp},\n  rw dvector.nth_cons _ _ _ (nat.lt_of_succ_lt_succ hk),\n  exact nth_cast (nat.succ_injective heq) (nat.lt_of_succ_lt_succ hk),\nend\n\nlemma nth_of_list : Π (l : list α) (k : ℕ) (h : k < l.length),\n  (dvector.of_list l).nth k h = list.nth_le l k h\n| list.nil k h :=\nbegin\n  exfalso,\n  rw list.length at h,\n  exact nat.not_lt_zero _ h,\nend\n| (a :: l) k h :=\nbegin\n  rw of_list,\n  induction k with k hk,\n  {rw [dvector.nth, list.nth_le]},\n  {simpa [dvector.nth, list.nth_le, nth_of_list l]},\nend\n\ndef of_fn : (fin n → α) → dvector α n :=\nλ f, dvector.cast (list.length_of_fn _) (dvector.of_list (list.of_fn f))\n\nlemma nth_of_fn (as : fin n → α) (k : ℕ) (hk : k < n) :\n  (dvector.of_fn as).nth k hk = as ⟨ k , hk ⟩ :=\nby rw [of_fn, nth_cast, nth_of_list, list.nth_le_of_fn']\n\nlemma nth'_of_fn (as : fin n → α) (k : fin n) :\n  (dvector.of_fn as).nth' k = as k :=\nby simp only [dvector.nth', nth_of_fn, fin.val_eq_coe, fin.eta]\n\nlemma nth'_of_fn1 (as : fin n → α) :\n  (dvector.of_fn as).nth' = as :=\nfunext $ nth'_of_fn as\n--by rw [of_fn, nth_cast, nth_of_list, list.nth_le_of_fn']\n\ndef to_list : Π {n : ℕ},\n  dvector α n → list α\n| 0            as := []\n| (nat.succ n) (dvector.cons a as) := list.cons a (to_list as)\n\nlemma to_list_length : Π {n : ℕ} {as : dvector α n},\n  list.length (to_list as) = n\n| 0            as := rfl\n| (nat.succ n) (dvector.cons a as) :=\nby simp only [to_list, list.length_cons, @to_list_length n as]\n\nlemma ith_chunk_aux {n m : ℕ} (i : fin n) (k : fin m) :\n  i.val * m + ↑k < n * m :=\nbegin\n  induction n with n hn,\n  { apply fin_zero_elim i },\n  {\n    rw nat.succ_mul,\n    cases fin.lt_or_eq_nat i with hi hi,\n    {\n      apply add_lt_add _ k.2,\n      apply lt_of_le_of_lt _ (hn ⟨ i.1 , hi ⟩),\n      apply le_add_right,\n      apply le_of_eq,\n      refl,\n    },\n    { rw [fin.val_eq_coe, hi, add_lt_add_iff_left],\n      exact k.2, }\n  }\nend\n\ndef ith_chunk {n m : ℕ} (i : fin n) (xs : dvector α (n * m)) :\n  dvector α m :=\n  of_fn (λ k, dvector.nth xs (i.1 * m + k) (dvector.ith_chunk_aux i k))\n\nlemma nth'_eq {α} {n} (ys : dvector α n) :\n  (λ (i : fin n), ys.nth i i.2) = ys.nth' :=\nbegin\n  funext, rw dvector.nth', refl,\nend\n\nlemma ith_chunk_nth {n m : ℕ} (i : fin n) (xs : dvector α (n * m))\n  (l : ℕ) (hl : l < m) :\n  dvector.nth (dvector.ith_chunk i xs) l hl =\n  xs.nth (i.1 * m + l) (dvector.ith_chunk_aux i ⟨ l , hl ⟩) :=\nby simpa only [dvector.ith_chunk, dvector.nth_of_fn]\n\nlemma nth_remove_mth_big_m : Π {n m} (xs : dvector α (n+1)) {k : ℕ}\n  (hk : k < n) (hm : k < m),\n  (dvector.remove_mth m xs).nth k hk\n  =\n  xs.nth k (lt_trans hk (nat.lt_succ_self _))\n| 0 _ _ k hk hm := false.elim (nat.not_lt_zero _ hk)\n| n 0 (dvector.cons y ys) k hk hm := false.elim (nat.not_lt_zero _ hm)\n| (n+1) (m+1) (dvector.cons y ys) 0 hk hm :=\nbegin\n  simp only [dvector.remove_mth, dvector.nth],\nend\n| (n+1) (m+1) (dvector.cons y ys) (k+1) hk hm :=\nbegin\n  rw [dvector.remove_mth,\n    dvector.nth_cons y (dvector.remove_mth m ys) _ (nat.succ_lt_succ_iff.mp hk),\n    dvector.nth_cons y ys _ (lt_trans (nat.lt_succ_self _) hk)],\n  apply nth_remove_mth_big_m,\n  rw ← nat.succ_lt_succ_iff,\n  exact hm,\nend\n\nlemma ext : Π {as bs : dvector α n},\n  as = bs ↔ ∀ (i : fin n), as.nth' i = bs.nth' i :=\nbegin\n  intros as bs,\n  induction as with n a as hind, cases bs,\n  { simp only [implies_true_iff, eq_self_iff_true] },\n  {\n    cases bs with _ b bs,\n    split,\n    {\n      intros heq i, rw heq,\n    },\n    {\n      intros heq,\n      simp only,\n      split,\n      {\n        specialize heq 0,\n        simp [dvector.nth', fin.val_zero', dvector.nth] at heq,\n        exact heq,\n      },\n      {\n        rw hind,\n        intro i,\n        specialize heq ⟨ i + 1 , nat.succ_lt_succ i.2 ⟩,\n        simp [dvector.nth', dvector.nth] at heq,\n        simp only [dvector.nth'],\n        convert heq,\n      },\n    },\n  },\nend\n\n\nlemma of_fn_eq_cons_of_fn_succ {f : ℕ → α} :\n  of_fn (λ i : fin (n+1), f i) =\n  cons (f 0) (of_fn (λ (i : fin n), f (i + 1))) :=\nbegin\n  rw ext,\n  intro i,\n  cases i with i hi,\n  cases i with i hind,\n  { simp only [nth'_of_fn, fin.mk_zero, fin.coe_eq_cast_succ,\n      fin.coe_succ_eq_succ],\n    simpa only [dvector.nth', fin.val_zero', dvector.nth], },\n  {\n    simp only [nth'_of_fn, dvector.nth', dvector.nth, nth_of_fn],\n    congr1,\n  },\nend\n\nlemma remove_mth_of_fn_last_aux (i : fin n) :\n  ((i : fin n.succ) : fin n.succ.succ) = (i : fin n.succ.succ) :=\nbegin\n  cases i with i hi,\n  simp only [fin.coe_eq_cast_succ, fin.cast_succ_mk, fin.coe_mk, coe_coe],\n  ext1,\n  simp only [fin.coe_of_nat_eq_mod],\n  rw nat.mod_eq_of_lt (lt_trans hi (nat.lt_succ_self _)),\nend\n\nlemma remove_mth_of_fn_last {n : ℕ} : Π {f : ℕ → α},\n  dvector.remove_mth n (of_fn (λ (i : fin (n+1)), f i))\n  =\n  dvector.of_fn (λ i : fin n, f i) :=\nbegin\n  induction n with n hn,\n  {intro f, refl},\n  {\n    intro f,\n    have hrw : (of_fn (λ (i : fin (n+2)), f i))\n      = cons (f 0) (of_fn (λ i : fin n.succ, f (i + 1))) :=\n    of_fn_eq_cons_of_fn_succ,\n    have hrw1 : of_fn (λ (i : fin n.succ), f i)\n      = cons (f 0) (of_fn (λ i : fin n, f (i + 1))) :=\n    of_fn_eq_cons_of_fn_succ,\n    rw hrw,\n    rw [dvector.remove_mth],\n    rw hrw1,\n    congr1,\n    rw @hn (λ n, f (n + 1)),\n  },\nend\n\nsection ulift\n\ndef ulift_up {α} {n} : dvector α n → dvector (ulift α) n :=\n  dvector.map ulift.up\n\ndef ulift_down {α} {n} : dvector (ulift α) n → dvector α n :=\n  dvector.map ulift.down\n\nend ulift\n\n\n-- #check list.of_fn\n\nend dvector\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/Rings/ToMathlib/dvector.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7185943805178138, "lm_q1q2_score": 0.47060368180066875}}
{"text": "/-\nCopyright (c) 2022 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.Data.List.Basic\n\n/-!\n# `lrat_proof` command\n\nDefines a macro for producing SAT proofs from CNF / LRAT files.\nThese files are commonly used in the SAT community for writing proofs.\n\nMost SAT solvers support export to [DRAT](https://arxiv.org/abs/1610.06229) format,\nbut this format can be expensive to reconstruct because it requires recomputing all\nunit propagation steps. The [LRAT](https://arxiv.org/abs/1612.02353) format solves this\nissue by attaching a proof to the deduction of each new clause.\n(The L in LRAT stands for Linear time verification.)\nThere are several verified checkers for the LRAT format, and the program implemented here\nmakes it possible to use the lean kernel as an LRAT checker as well and expose the results\nas a standard propositional theorem.\n\nThe input to the `lrat_proof` command is the name of the theorem to define,\nand the statement (written in CNF format) and the proof (in LRAT format).\nFor example:\n```\nlrat_proof foo\n  \"p cnf 2 4  1 2 0  -1 2 0  1 -2 0  -1 -2 0\"\n  \"5 -2 0 4 3 0  5 d 3 4 0  6 1 0 5 1 0  6 d 1 0  7 0 5 2 6 0\"\n```\nproduces a theorem:\n```\nfoo : ∀ (a a_1 : Prop), (¬a ∧ ¬a_1 ∨ a ∧ ¬a_1) ∨ ¬a ∧ a_1 ∨ a ∧ a_1\n```\n\n* You can see the theorem statement by hovering over the word `foo`.\n* You can use the `example` keyword in place of `foo` to avoid generating a theorem.\n* You can use the `include_str` macro in place of the two strings\n  to load CNF / LRAT files from disk.\n-/\n\nopen Lean hiding Literal HashMap\nopen Std\n\nnamespace Sat\n\n/-- A literal is a positive or negative occurrence of an atomic propositional variable.\n  Note that unlike DIMACS, 0 is a valid variable index. -/\ninductive Literal\n| pos : Nat → Literal\n| neg : Nat → Literal\n\n/-- Construct a literal. Positive numbers are translated to positive literals,\n  and negative numbers become negative literals. The input is assumed to be nonzero. -/\ndef Literal.ofInt (i : Int) : Literal :=\n  if i < 0 then Literal.neg (-i-1).toNat else Literal.pos (i-1).toNat\n\n/-- Swap the polarity of a literal. -/\ndef Literal.negate : Literal → Literal\n| pos i => neg i\n| neg i => pos i\n\ninstance : ToExpr Literal where\n  toTypeExpr := mkConst ``Literal\n  toExpr\n  | Literal.pos i => mkApp (mkConst ``Literal.pos) (mkRawNatLit i)\n  | Literal.neg i => mkApp (mkConst ``Literal.neg) (mkRawNatLit i)\n\n/-- A clause is a list of literals, thought of as a disjunction like `a ∨ b ∨ ¬c`. -/\ndef Clause := List Literal\n\ndef Clause.nil : Clause := []\ndef Clause.cons : Literal → Clause → Clause := List.cons\n\n/-- A formula is a list of clauses, thought of as a conjunction like `(a ∨ b) ∧ c ∧ (¬c ∨ ¬d)`. -/\nabbrev Fmla := List Clause\n\n/-- A single clause as a formula. -/\ndef Fmla.one (c : Clause) : Fmla := [c]\n\n/-- A conjunction of formulas. -/\ndef Fmla.and (a b : Fmla) : Fmla := a ++ b\n\n/-- Formula `f` subsumes `f'` if all the clauses in `f'` are in `f`.\nWe use this to prove that all clauses in the formula are subsumed by it. -/\nstructure Fmla.subsumes (f f' : Fmla) : Prop where\n  prop : ∀ x, x ∈ f' → x ∈ f\n\ntheorem Fmla.subsumes_self (f : Fmla) : f.subsumes f := ⟨fun _ h ↦ h⟩\ntheorem Fmla.subsumes_left (f f₁ f₂ : Fmla) (H : f.subsumes (f₁.and f₂)) : f.subsumes f₁ :=\n  ⟨fun _ h ↦ H.1 _ $ List.mem_append.2 $ Or.inl h⟩\ntheorem Fmla.subsumes_right (f f₁ f₂ : Fmla) (H : f.subsumes (f₁.and f₂)) : f.subsumes f₂ :=\n  ⟨fun _ h ↦ H.1 _ $ List.mem_append.2 $ Or.inr h⟩\n\n/-- A valuation is an assignment of values to all the propositional variables. -/\ndef Valuation := Nat → Prop\n\n/-- `v.neg lit` asserts that literal `lit` is falsified in the valuation. -/\ndef Valuation.neg (v : Valuation) : Literal → Prop\n| Literal.pos i => ¬ v i\n| Literal.neg i => v i\n\n/-- `v.satisfies c` asserts that clause `c` satisfied by the valuation.\nIt is written in a negative way: A clause like `a ∨ ¬b ∨ c` is rewritten as\n`¬a → b → ¬c → False`, so we are asserting that it is not the case that\nall literals in the clause are falsified. -/\ndef Valuation.satisfies (v : Valuation) : Clause → Prop\n| [] => False\n| l::c => v.neg l → v.satisfies c\n\n/-- `v.satisfies_fmla f` asserts that formula `f` is satisfied by the valuation.\nA formula is satisfied if all clauses in it are satisfied. -/\nstructure Valuation.satisfies_fmla (v : Valuation) (f : Fmla) : Prop where\n  prop : ∀ c, c ∈ f → v.satisfies c\n\n/-- `f.proof c` asserts that `c` is derivable from `f`. -/\ndef Fmla.proof (f : Fmla) (c : Clause) : Prop :=\n  ∀ v : Valuation, v.satisfies_fmla f → v.satisfies c\n\n/-- If `f` subsumes `c` (i.e. `c ∈ f`), then `f.proof c`. -/\ntheorem Fmla.proof_of_subsumes (H : Fmla.subsumes f (Fmla.one c)) : f.proof c :=\n  fun _ h ↦ h.1 _ $ H.1 _ $ List.Mem.head ..\n\n/-- The core unit-propagation step.\n\nWe have a local context of assumptions `¬l'` (sometimes called an assignment)\nand we wish to add `¬l` to the context, that is, we want to prove `l` is also falsified.\nThis is because there is a clause `a ∨ b ∨ ¬l` in the global context\nsuch that all literals in the clause are falsified except for `¬l`;\nso in the context `h₁` where we suppose that `¬l` is falsified,\nthe clause itself is falsified so we can prove `False`.\nWe continue the proof in `h₂`, with the assumption that `l` is falsified. -/\ntheorem Valuation.by_cases {v : Valuation} {l}\n  (h₁ : v.neg l.negate → False) (h₂ : v.neg l → False) : False :=\nmatch l with\n| Literal.pos _ => h₂ h₁\n| Literal.neg _ => h₁ h₂\n\n/-- `v.implies p [a, b, c] 0` definitionally unfolds to `(v 0 ↔ a) → (v 1 ↔ b) → (v 2 ↔ c) → p`.\nThis is used to introduce assumptions about the first `n` values of `v` during reification. -/\ndef Valuation.implies (v : Valuation) (p : Prop) : List Prop → Nat → Prop\n| [], _ => p\n| a::as, n => (v n ↔ a) → v.implies p as (n+1)\n\n/-- `Valuation.mk [a, b, c]` is a valuation which is `a` at 0, `b` at 1 and `c` at 2, and false\neverywhere else. -/\ndef Valuation.mk : List Prop → Valuation\n| [], _ => False\n| a::_, 0 => a\n| _::as, n+1 => mk as n\n\n/-- The fundamental relationship between `mk` and `implies`:\n`(mk ps).implies p ps 0` is equivalent to `p`. -/\ntheorem Valuation.mk_implies (as₁) : as = List.reverseAux as₁ ps →\n  (Valuation.mk as).implies p ps as₁.length → p := by\n  induction ps generalizing as₁ with\n  | nil => exact fun _ ↦ id\n  | cons a as ih =>\n    refine fun e H ↦ @ih (a::as₁) e (H ?_)\n    subst e; clear ih H\n    suffices ∀ n n', n' = List.length as₁ + n →\n      ∀ bs, mk (as₁.reverseAux bs) n' ↔ mk bs n from this 0 _ rfl (a::as)\n    induction as₁ with simp\n    | cons b as₁ ih => exact fun n bs ↦ ih (n+1) _ (Nat.succ_add ..) _\n\n/-- Asserts that `¬⟦f⟧_v` implies `p`. -/\nstructure Fmla.reify (v : Valuation) (f : Fmla) (p : Prop) : Prop where\n  prop : ¬ v.satisfies_fmla f → p\n\n/-- If `f` is unsatisfiable, and every `v` which agrees with `ps` implies `¬⟦f⟧_v → p`, then `p`.\nEquivalently, there exists a valuation `v` which agrees with `ps`,\nand every such valuation yields `¬⟦f⟧_v` because `f` is unsatisfiable. -/\ntheorem Fmla.refute (f : Fmla) (hf : f.proof [])\n  (hv : ∀ v, Valuation.implies v (Fmla.reify v f p) ps 0) : p :=\n  (Valuation.mk_implies [] rfl (hv _)).1 (hf _)\n\n/-- Negation turns AND into OR, so `¬⟦f₁ ∧ f₂⟧_v ≡ ¬⟦f₁⟧_v ∨ ¬⟦f₂⟧_v`. -/\ntheorem Fmla.reify_or (h₁ : Fmla.reify v f₁ a) (h₂ : Fmla.reify v f₂ b) :\n  Fmla.reify v (f₁.and f₂) (a ∨ b) := by\n  refine ⟨fun H ↦ by_contra fun hn ↦ H ⟨fun c h ↦ by_contra fun hn' ↦ ?_⟩⟩\n  rcases List.mem_append.1 h with h | h\n  · exact hn $ Or.inl $ h₁.1 fun Hc ↦ hn' $ Hc.1 _ h\n  · exact hn $ Or.inr $ h₂.1 fun Hc ↦ hn' $ Hc.1 _ h\n\n/-- Asserts that `¬⟦c⟧_v` implies `p`. -/\nstructure Clause.reify (v : Valuation) (c : Clause) (p : Prop) : Prop where\n  prop : ¬ v.satisfies c → p\n\n/-- Reification of a single clause formula. -/\ntheorem Fmla.reify_one (h : Clause.reify v c a) : Fmla.reify v (Fmla.one c) a :=\n  ⟨fun H ↦ h.1 fun h ↦ H ⟨fun | _, List.Mem.head .. => h⟩⟩\n\n/-- Asserts that `¬⟦l⟧_v` implies `p`. -/\nstructure Literal.reify (v : Valuation) (l : Literal) (p : Prop) : Prop where\n  prop : v.neg l → p\n\n/-- Negation turns OR into AND, so `¬⟦l ∨ c⟧_v ≡ ¬⟦l⟧_v ∧ ¬⟦c⟧_v`. -/\ntheorem Clause.reify_and (h₁ : Literal.reify v l a) (h₂ : Clause.reify v c b) :\n  Clause.reify v (Clause.cons l c) (a ∧ b) :=\n  ⟨fun H ↦ ⟨h₁.1 (by_contra fun hn ↦ H hn.elim), h₂.1 fun h ↦ H fun _ ↦ h⟩⟩\n\n/-- The reification of the empty clause is `True`: `¬⟦⊥⟧_v ≡ True`. -/\ntheorem Clause.reify_zero : Clause.reify v Clause.nil True := ⟨fun _ ↦ trivial⟩\n\n/-- The reification of a singleton clause `¬⟦l⟧_v ≡ ¬⟦l⟧_v`. -/\ntheorem Clause.reify_one (h₁ : Literal.reify v l a) : Clause.reify v (Clause.nil.cons l) a :=\n  ⟨fun H ↦ ((Clause.reify_and h₁ Clause.reify_zero).1 H).1⟩\n\n/-- The reification of a positive literal `¬⟦a⟧_v ≡ ¬a`. -/\ntheorem Literal.reify_pos (h : v n ↔ a) : (Literal.pos n).reify v ¬a := ⟨mt h.2⟩\n\n/-- The reification of a negative literal `¬⟦¬a⟧_v ≡ a`. -/\ntheorem Literal.reify_neg (h : v n ↔ a) : (Literal.neg n).reify v a := ⟨h.1⟩\n\nend Sat\n\nnamespace Mathlib.Tactic.Sat\n\n/-- The representation of a global clause. -/\nstructure Clause where\n  /-- The list of literals as read from the input file -/\n  lits : Array Int\n  /-- The clause expression of type `Clause` -/\n  expr : Expr\n  /-- A proof of `⊢ ctx.proof c`.\n  Note that we do not use `have` statements to cache these proofs:\n  this is literally the proof expression itself. As a result, the proof terms\n  rely heavily on dag-like sharing of the expression, and printing these proof terms\n  directly is likely to crash lean for larger examples. -/\n  proof : Expr\n\n/-- Construct the clause expression from the input list. For example `[1, -2]` is translated to\n`Clause.cons (Literal.pos 1) (Clause.cons (Literal.neg 2) Clause.nil)`. -/\ndef buildClause (arr : Array Int) : Expr :=\n  let nil  := mkConst ``Sat.Clause.nil\n  let cons := mkConst ``Sat.Clause.cons\n  arr.foldr (fun i e ↦ mkApp2 cons (toExpr $ Sat.Literal.ofInt i) e) nil\n\n/-- Constructs the formula expression from the input CNF, as a balanced tree of `Fmla.and` nodes. -/\npartial def buildConj (arr : Array (Array Int)) (start stop : Nat) : Expr :=\n  match stop - start with\n  | 0 => panic! \"empty\"\n  | 1 => mkApp (mkConst ``Sat.Fmla.one) (buildClause arr[start]!)\n  | len =>\n    let mid := start + len / 2\n    mkApp2 (mkConst ``Sat.Fmla.and) (buildConj arr start mid) (buildConj arr mid stop)\n\n/-- Constructs the proofs of `⊢ ctx.proof c` for each clause `c` in `ctx`.\nThe proofs are stashed in a `HashMap` keyed on the clause ID. -/\npartial def buildClauses (arr : Array (Array Int)) (ctx : Expr) (start stop : Nat)\n  (f p : Expr) (accum : Nat × HashMap Nat Clause) : Nat × HashMap Nat Clause :=\n  match stop - start with\n  | 0 => panic! \"empty\"\n  | 1 =>\n    let c := f.appArg!\n    let proof := mkApp3 (mkConst ``Sat.Fmla.proof_of_subsumes) ctx c p\n    let n := accum.1 + 1\n    (n, accum.2.insert n { lits := arr[start]!, expr := c, proof })\n  | len =>\n    let mid := start + len / 2\n    let f₁ := f.appFn!.appArg!\n    let f₂ := f.appArg!\n    let p₁ := mkApp4 (mkConst ``Sat.Fmla.subsumes_left) ctx f₁ f₂ p\n    let p₂ := mkApp4 (mkConst ``Sat.Fmla.subsumes_right) ctx f₁ f₂ p\n    let accum := buildClauses arr ctx start mid f₁ p₁ accum\n    buildClauses arr ctx mid stop f₂ p₂ accum\n\n/-- A localized clause reference.\nIt is the same as `Clause` except that the proof is now a local variable. -/\nstructure LClause where\n  /-- The list of literals as read from the input file -/\n  lits : Array Int\n  /-- The clause expression of type `Clause` -/\n  expr : Expr\n  /-- The bound variable index of the hypothesis asserting `⊢ ctx.proof c`,\n  _counting from the outside and 1-based_. (We use this numbering because we will need to\n  reference the variable from multiple binder depths.) -/\n  depth : Nat\n\n/-- Construct an individual proof step `⊢ ctx.proof c`.\n\n  * `db`: the current global context\n  * `ns`, `clause`: the new clause\n  * `pf`: the LRAT proof trace\n  * `ctx`: the main formula\n\n  The proof has three steps:\n\n  1. Introduce local assumptions `have h1 : ctx.proof c1 := p1` for each clause `c1`\n     referenced in the proof. We actually do all the introductions at once,\n     as in `(fun h1 h2 h3 ↦ ...) p1 p2 p3`, because we want `p_i` to not be under any binders\n     to avoid the cost of `instantiate` during typechecking and get the benefits of dag-like\n     sharing in the `pi` (which are themselves previous proof steps which may be large terms).\n     The hypotheses are in `gctx`, keyed on the clause ID.\n\n  2. Unfold `⊢ ctx.proof [a, b, c]` to\n     `∀ v, v.satisfies_fmla ctx → v.neg a → v.neg b → v.neg c → False` and `intro v hv ha hb hc`,\n     storing each `ha : v.neg a` in `lctx`, keyed on the literal `a`.\n\n  3. For each LRAT step `hc : ctx.proof [x, y]`, `hc v hv : v.neg x → v.neg y → False`.\n     We look for a literal that is not falsified in the clause. Since it is a unit propagation\n     step, there can be at most one such literal.\n     * If `x` is the non-falsified clause, let `x'` denote the negated literal of `x`.\n       Then `x'.negate` reduces to `x`, so `hnx : v.neg x'.negate |- hc v hv hnx hy : False`,\n       so we construct the term\n         `by_cases (fun hnx : v.neg x'.negate ↦ hc v hv hnx hy) (fun hx : v.neg x ↦ ...)`\n       and `hx` is added to the local context.\n     * If all clauses are falsified, then we are done: `hc v hv hx hy : False`.\n-/\npartial def buildProofStep (db : HashMap Nat Clause)\n  (ns pf : Array Int) (ctx clause : Expr) : Except String Expr := Id.run do\n  let mut lams := #[]\n  let mut args := #[]\n  let mut gctx : HashMap Nat LClause := {}\n  -- step 1\n  for i in pf do\n    let i := i.natAbs\n    let some cl := db.find? i | return Except.error \"missing clause\"\n    if !gctx.contains i then\n      lams := lams.push (mkApp2 (mkConst ``Sat.Fmla.proof) ctx cl.expr)\n      args := args.push cl.proof\n      gctx := gctx.insert i {\n        lits := cl.lits\n        expr := cl.expr\n        depth := args.size\n      }\n  let n := args.size\n  -- step 2\n  let mut f :=\n    (mkAppN · args) ∘\n    lams.foldr (mkLambda `c default) ∘\n    mkLambda `v default (mkConst ``Sat.Valuation) ∘\n    mkLambda `hv default (mkApp2 (mkConst ``Sat.Valuation.satisfies_fmla) (mkBVar 0) ctx)\n  let v depth := mkBVar (depth + 1)\n  let hv depth := mkBVar depth\n  lams := #[]\n  let mut clause := clause\n  let mut depth := 0\n  let mut lctx : HashMap Int Nat := {}\n  for i in ns do\n    let l := clause.appFn!.appArg!\n    clause := clause.appArg!\n    lams := lams.push (mkApp2 (mkConst ``Sat.Valuation.neg) (v depth) l)\n    depth := depth.succ\n    lctx := lctx.insert i depth\n  f := f ∘ lams.foldr (mkLambda `h default)\n  -- step 3\n  for (step : Int) in pf do\n    if step < 0 then return Except.error \"unimplemented: RAT step\"\n    let some cl := gctx.find? step.toNat | return Except.error \"missing clause\"\n    let mut unit := none\n    for i in cl.lits do\n      unless lctx.contains i do\n        if unit.isSome then return Except.error s!\"not unit: {cl.lits}\"\n        depth := depth.succ\n        unit := some i\n    let mut pr := mkApp2 (mkBVar (depth + n + 2 - cl.depth)) (v depth) (hv depth)\n    for i in cl.lits do\n      pr := mkApp pr <| mkBVar (match lctx.find? i with | some k => depth - k | _ => 0)\n    let some u := unit | return Except.ok <| f pr\n    let lit := toExpr $ Sat.Literal.ofInt u\n    let nlit := toExpr $ Sat.Literal.ofInt (-u)\n    let d1 := depth-1\n    let app := mkApp3 (mkConst ``Sat.Valuation.by_cases) (v d1) nlit <|\n      mkLambda `h default (mkApp2 (mkConst ``Sat.Valuation.neg) (v d1) lit) pr\n    let dom := mkApp2 (mkConst ``Sat.Valuation.neg) (v d1) nlit\n    f := fun e ↦ f <| mkApp app <| mkLambda `h default dom e\n    lctx := lctx.insert (-u) depth\n  return Except.error s!\"no refutation: {ns}, {pf}, {lctx.toList}\"\n\n/-- An LRAT step is either an addition or a deletion step. -/\ninductive LRATStep\n| /-- An addition step, with the clause ID, the clause literal list, and the proof trace -/\n  add (id : Nat) (lits : Array Int) (proof : Array Int) : LRATStep\n| /-- A (multiple) deletion step, which deletes all the listed clause IDs from the context -/\n  del (ids : Array Nat) : LRATStep\n\n/-- Build the main proof of `⊢ ctx.proof []` using the LRAT proof trace.\n\n  * `arr`: The input CNF\n  * `ctx`: The abbreviated formula, a constant like `foo.ctx_1`\n  * `ctx'`: The definitional expansion of the formula, a tree of `Fmla.and` nodes\n  * `steps`: The input LRAT proof trace\n-/\npartial def buildProof (arr : Array (Array Int)) (ctx ctx' : Expr)\n  (steps : Array LRATStep) : MetaM Expr := do\n  let p := mkApp (mkConst ``Sat.Fmla.subsumes_self) ctx\n  let mut db := (buildClauses arr ctx 0 arr.size ctx' p default).2\n  for step in steps do\n    match step with\n    | LRATStep.del ds => db := ds.foldl (·.erase ·) db\n    | LRATStep.add i ns pf =>\n      let e := buildClause ns\n      match buildProofStep db ns pf ctx e with\n      | Except.ok proof =>\n        if ns.isEmpty then return proof\n        db := db.insert i { lits := ns, expr := e, proof }\n      | Except.error msg => throwError msg\n  throwError \"failed to prove empty clause\"\n\n/-- Build the type and value of the reified theorem. This rewrites all the SAT definitions\ninto standard operators on `Prop`, for example if the formula is `[[1, 2], [-1, 2], [-2]]` then\nthis produces a proof of `⊢ ∀ a b : Prop, (a ∧ b) ∨ (¬a ∧ b) ∨ ¬b`. We use the input `nvars` to\ndecide how many quantifiers to use.\n\nMost of the proof is under `2 * nvars + 1` quantifiers\n`a1 .. an : Prop, v : Valuation, h1 : v 0 ↔ a1, ... hn : v (n-1) ↔ an ⊢ ...`, and we do the index\narithmetic by hand.\n\n  1. First, we call `reifyFormula ctx'` which returns `a` and `pr : reify v ctx' a`\n  2. Then we build `fun (v : Valuation) (h1 : v 0 ↔ a1) ... (hn : v (n-1) ↔ an) ↦ pr`\n  3. We have to lower expression `a` from step 1 out of the quantifiers by lowering all variable\n     indices by `nvars+1`. This is okay because `v` and `h1..hn` do not appear in `a`.\n  4. We construct the expression `ps`, which is `a1 .. an : Prop ⊢ [a1, ..., an] : List Prop`\n  5. `refute ctx (hf : ctx.proof []) (fun v h1 .. hn ↦ pr) : a` forces some definitional unfolding\n     since `fun h1 .. hn ↦ pr` should have type `implies v (reify v ctx a) [a1, ..., an] a`,\n     which involves unfolding `implies` n times as well as `ctx ↦ ctx'`.\n  6. Finally, we `intro a1 ... an` so that we have a proof of `∀ a1 ... an, a`.\n-/\npartial def buildReify (ctx ctx' proof : Expr) (nvars : Nat) : Expr × Expr := Id.run do\n  let (e, pr) := reifyFmla ctx'\n  let mut pr := pr\n  for i in [0:nvars] do\n    let j := nvars-i-1\n    let ty := mkApp2 (mkConst ``Iff) (mkApp (mkBVar j) (mkRawNatLit j)) (mkBVar nvars)\n    pr := mkLambda `h default ty pr\n  pr := mkLambda `v default (mkConst ``Sat.Valuation) pr\n  let mut e := e.lowerLooseBVars (nvars+1) (nvars+1)\n  let cons := mkApp (mkConst ``List.cons [levelZero]) (mkSort levelZero)\n  let nil := mkApp (mkConst ``List.nil [levelZero]) (mkSort levelZero)\n  let rec mkPS depth e\n  | 0 => e\n  | n+1 => mkPS (depth+1) (mkApp2 cons (mkBVar depth) e) n\n  pr := mkApp5 (mkConst ``Sat.Fmla.refute) e (mkPS 0 nil nvars) ctx proof pr\n  for _ in [0:nvars] do\n    e := mkForall `a default (mkSort levelZero) e\n    pr := mkLambda `a default (mkSort levelZero) pr\n  pure (e, pr)\nwhere\n  /-- The `v` variable under the `a1 ... an, v, h1 ... hn` context -/\n  v := mkBVar nvars\n  /-- Returns `a` and `pr : reify v f a` given a formula `f` -/\n  reifyFmla f :=\n    match f.getAppFn.constName! with\n    | ``Sat.Fmla.and =>\n      let f₁ := f.appFn!.appArg!\n      let f₂ := f.appArg!\n      let (e₁, h₁) := reifyFmla f₁\n      let (e₂, h₂) := reifyFmla f₂\n      (mkApp2 (mkConst ``Or) e₁ e₂, mkApp7 (mkConst ``Sat.Fmla.reify_or) v f₁ e₁ f₂ e₂ h₁ h₂)\n    | ``Sat.Fmla.one =>\n      let c := f.appArg!\n      let (e, h) := reifyClause c\n      (e, mkApp4 (mkConst ``Sat.Fmla.reify_one) v c e h)\n    | _ => panic! \"not a valid formula\"\n  /-- Returns `a` and `pr : reify v c a` given a clause `c` -/\n  reifyClause c :=\n    if c.appFn!.isConst then\n      (mkConst ``True, mkApp (mkConst ``Sat.Clause.reify_zero) v)\n    else reifyClause1 c\n  /-- Returns `a` and `pr : reify v c a` given a nonempty clause `c` -/\n  reifyClause1 c :=\n    let l := c.appFn!.appArg!\n    let c := c.appArg!\n    let (e₁, h₁) := reifyLiteral l\n    if c.isConst then\n      (e₁, mkApp4 (mkConst ``Sat.Clause.reify_one) v l e₁ h₁)\n    else\n      let (e₂, h₂) := reifyClause1 c\n      (mkApp2 (mkConst ``And) e₁ e₂, mkApp7 (mkConst ``Sat.Clause.reify_and) v l e₁ c e₂ h₁ h₂)\n  /-- Returns `a` and `pr : reify v l a` given a literal `c` -/\n  reifyLiteral l :=\n    let n := l.appArg!\n    let (e, h) := reifyVar n\n    match l.appFn!.constName! with\n    | ``Sat.Literal.pos =>\n      (mkApp (mkConst ``Not) e, mkApp4 (mkConst ``Sat.Literal.reify_pos) v e n h)\n    | ``Sat.Literal.neg =>\n      (e, mkApp4 (mkConst ``Sat.Literal.reify_neg) v e n h)\n    | _ => panic! \"not a valid literal\"\n  /-- Returns `a` and `pr : v n ↔ a` given a variable index `n`.\n  These are both lookups into the context\n  `(a0 .. a(n-1) : Prop) (v) (h1 : v 0 ↔ a0) ... (hn : v (n-1) ↔ a(n-1))`. -/\n  reifyVar v :=\n    let n := v.natLit?.get!\n    (mkBVar (2 * nvars - n), mkBVar (nvars - n - 1))\nopen Lean\n\nnamespace Parser\nopen Lean Parsec\n\n/-- Parse a natural number -/\ndef parseNat : Parsec Nat := Json.Parser.natMaybeZero\n\n/-- Parse an integer -/\ndef parseInt : Parsec Int := do\n  if (← peek!) = '-' then skip; pure $ -(← parseNat) else parseNat\n\n/-- Parse a list of integers terminated by 0 -/\npartial def parseInts (arr : Array Int := #[]) : Parsec (Array Int) := do\n  match ← parseInt <* ws with\n  | 0 => pure arr\n  | n => parseInts (arr.push n)\n\n/-- Parse a list of natural numbers terminated by 0 -/\npartial def parseNats (arr : Array Nat := #[]) : Parsec (Array Nat) := do\n  match ← parseNat <* ws with\n  | 0 => pure arr\n  | n => parseNats (arr.push n)\n\n/-- Parse a DIMACS format `.cnf` file.\nThis is not very robust; we assume the file has had comments stripped. -/\ndef parseDimacs : Parsec (Nat × Array (Array Int)) := do\n  pstring \"p cnf\" *> ws\n  let nvars ← parseNat <* ws\n  let nclauses ← parseNat <* ws\n  let mut clauses := Array.mkEmpty nclauses\n  for _ in [:nclauses] do\n    clauses := clauses.push (← parseInts)\n  pure (nvars, clauses)\n\n/-- Parse an LRAT file into a list of steps. -/\ndef parseLRAT : Parsec (Array LRATStep) := many do\n  let step ← parseNat <* ws\n  if (← peek!) = 'd' then skip <* ws; pure $ LRATStep.del (← parseNats)\n  else ws; pure $ LRATStep.add step (← parseInts) (← parseInts)\n\nend Parser\n\n/-- Core of `fromLRAT`. Constructs the context and main proof definitions,\nbut not the reification theorem. Returns:\n\n  * `nvars`: the number of variables specified in the CNF file\n  * `ctx`: The abbreviated formula, a constant like `foo.ctx_1`\n  * `ctx'`: The definitional expansion of the formula, a tree of `Fmla.and` nodes\n  * `proof`: A proof of `ctx.proof []`\n-/\ndef fromLRATAux (cnf lrat : String) (name : Name) : MetaM (Nat × Expr × Expr × Expr) := do\n  let Parsec.ParseResult.success _ (nvars, arr) := Parser.parseDimacs cnf.mkIterator\n    | throwError \"parse CNF failed\"\n  if arr.isEmpty then throwError \"empty CNF\"\n  let ctx' := buildConj arr 0 arr.size\n  let ctxName ← mkAuxName (name ++ `ctx) 1\n  addDecl $ Declaration.defnDecl {\n    name := ctxName\n    levelParams := []\n    type        := mkConst ``Sat.Fmla\n    value       := ctx'\n    hints       := ReducibilityHints.regular 0\n    safety      := DefinitionSafety.safe\n  }\n  let ctx := mkConst ctxName\n  let Parsec.ParseResult.success _ steps := Parser.parseLRAT lrat.mkIterator\n    | throwError \"parse LRAT failed\"\n  let proof ← buildProof arr ctx ctx' steps\n  let declName ← mkAuxName (name ++ `proof) 1\n  addDecl $ Declaration.thmDecl {\n    name := declName\n    levelParams := []\n    type        := mkApp2 (mkConst ``Sat.Fmla.proof) ctx (buildClause #[])\n    value       := proof\n  }\n  return (nvars, ctx, ctx', mkConst declName)\n\n/-- Main entry point. Given strings `cnf` and `lrat` with unparsed file data, and a name `name`,\nadds `theorem name : type := proof` where `type` is a propositional theorem like\n`∀ (a a_1 : Prop), (¬a ∧ ¬a_1 ∨ a ∧ ¬a_1) ∨ ¬a ∧ a_1 ∨ a ∧ a_1`.\n\nAlso creates auxiliaries named `name.ctx_1` (for the CNF formula)\nand `name.proof_1` (for the LRAT proof), with `name` itself containing the reification proof. -/\ndef fromLRAT (cnf lrat : String) (name : Name) : MetaM Unit := do\n  let (nvars, ctx, ctx', proof) ← fromLRATAux cnf lrat name\n  let (type, value) := buildReify ctx ctx' proof nvars\n  addDecl $ Declaration.thmDecl { name, levelParams := [], type, value }\n\nopen Elab Term\n\n\n/--\nA macro for producing SAT proofs from CNF / LRAT files.\nThese files are commonly used in the SAT community for writing proofs.\n\nThe input to the `lrat_proof` command is the name of the theorem to define,\nand the statement (written in CNF format) and the proof (in LRAT format).\nFor example:\n```\nlrat_proof foo\n  \"p cnf 2 4  1 2 0  -1 2 0  1 -2 0  -1 -2 0\"\n  \"5 -2 0 4 3 0  5 d 3 4 0  6 1 0 5 1 0  6 d 1 0  7 0 5 2 6 0\"\n```\nproduces a theorem:\n```\nfoo : ∀ (a a_1 : Prop), (¬a ∧ ¬a_1 ∨ a ∧ ¬a_1) ∨ ¬a ∧ a_1 ∨ a ∧ a_1\n```\n\n* You can see the theorem statement by hovering over the word `foo`.\n* You can use the `example` keyword in place of `foo` to avoid generating a theorem.\n* You can use the `include_str` macro in place of the two strings\n  to load CNF / LRAT files from disk.\n-/\nelab \"lrat_proof\" n:(ident <|> \"example\") cnf:term:max lrat:term:max : command => do\n  let name := (← getCurrNamespace) ++ if n.1.isIdent then n.1.getId else `_example\n  Command.liftTermElabM do\n    let cnf ← unsafe evalTerm String (mkConst ``String) cnf\n    let lrat ← unsafe evalTerm String (mkConst ``String) lrat\n    let go := do\n      fromLRAT cnf lrat name\n      withSaveInfoContext do\n        Term.addTermInfo' n (mkConst name) (isBinder := true)\n    if n.1.isIdent then go else withoutModifyingEnv go\n\nlrat_proof example\n  -- The CNF file\n  \"p cnf 2 4\n   1 2 0\n   -1 2 0\n   1 -2 0\n   -1 -2 0\"\n  -- The LRAT file\n  \"5 -2 0 4 3 0\n   5 d 3 4 0\n   6 1 0 5 1 0\n   6 d 1 0\n   7 0 5 2 6 0\"\n\n-- lrat_proof full2\n--   (include_str \"full2.cnf\")\n--   (include_str \"full2.lrat\")\n\n/--\nA macro for producing SAT proofs from CNF / LRAT files.\nThese files are commonly used in the SAT community for writing proofs.\n\nThe input to the `from_lrat` term syntax is two string expressions with\nthe statement (written in CNF format) and the proof (in LRAT format).\nFor example:\n```\ndef foo := from_lrat\n  \"p cnf 2 4  1 2 0  -1 2 0  1 -2 0  -1 -2 0\"\n  \"5 -2 0 4 3 0  5 d 3 4 0  6 1 0 5 1 0  6 d 1 0  7 0 5 2 6 0\"\n```\nproduces a theorem:\n```\nfoo : ∀ (a a_1 : Prop), (¬a ∧ ¬a_1 ∨ a ∧ ¬a_1) ∨ ¬a ∧ a_1 ∨ a ∧ a_1\n```\n\n* You can use this term after `have :=` or in `def foo :=` to produce the term\n  without constraining the type.\n* You can use it when a specific type is expected, but it currently does not\n  pay any attention to the shape of the goal and always produces the same theorem,\n  so you can only use this to do alpha renaming.\n* You can use the `include_str` macro in place of the two strings\n  to load CNF / LRAT files from disk.\n-/\nelab \"from_lrat\" cnf:term:max lrat:term:max : term => do\n  let cnf ← unsafe evalTerm String (mkConst ``String) cnf\n  let lrat ← unsafe evalTerm String (mkConst ``String) lrat\n  let name ← mkAuxName `lrat\n  fromLRAT cnf lrat name\n  return mkConst name\n\nexample : ∀ (a b : Prop), (¬a ∧ ¬b ∨ a ∧ ¬b) ∨ ¬a ∧ b ∨ a ∧ b := from_lrat\n  \"p cnf 2 4  1 2 0  -1 2 0  1 -2 0  -1 -2 0\"\n  \"5 -2 0 4 3 0  5 d 3 4 0  6 1 0 5 1 0  6 d 1 0  7 0 5 2 6 0\"\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Tactic/Sat/FromLRAT.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4706036800138831}}
{"text": "import data.set.basic data.real.basic tactic.ring\nimport analysis.topology.continuity\nimport analysis.real\nimport data.vector\n\nopen set\n\nnamespace set_theory_review\n\ndef sin (x : ℝ) : ℝ := sorry\ndef cos (x : ℝ) : ℝ := sorry\n\nnamespace problem1\n\n-- (1) Consider the sine function defined by f(x) = sin x for (−∞ < x < ∞).\n\n-- uhm we don't actually have the sin function in Lean yet ...\ndef f (x : ℝ) : ℝ := sin x\n-- nor pi\ndef pi : ℝ := sorry\n\n-- but if we did, we could prove this!\n\nnamespace part_a\n\n-- What is the image of π/2 under f?\nlemma answer_proof : f (pi / 2) = 1 := sorry\n\nend part_a\n\nnamespace part_b\n\n-- Find f⁻¹(1).\n\n-- so we uh just take the inverse of the function, right?\n-- -- lemma part_b : function.inv_fun f 1 = pi/2\n-- wrong, that's not well defined, we can't prove anything about it ...\n\n-- might as well just repeat ourselves:\nlemma answer_proof : f (pi / 2) = 1 := part_a.answer_proof\n-- or give the precise set\ndef answer : set ℝ := {x | f x = 1}\n-- aka the preimage\nlemma proof_preimage : answer = f ⁻¹' {1} :=\n  begin\n  apply set.ext, intro x, simpa,\n  end\n-- which does include pi/2, by part a\nlemma includes_half_pi : pi / 2 ∈ answer := part_a.answer_proof\n\nend part_b\n\nlemma sin_pi_6 : f (pi/6) = 1/2 := sorry\n\nnamespace part_c\n\n-- Find f([0, π/6]), f([π/6, π/2]), f([0, π/2]).\nlemma part_i : f '' Icc 0 (pi/6) = Icc 0 (1/2) := sorry\nlemma part_ii : f '' Icc (pi/6) (pi/2) = Icc (1/2) 1 := sorry\nlemma part_iii : f '' Icc 0 (pi/2) = Icc 0 1 := sorry\n\nend part_c\n\nnamespace part_d\n\n-- (d) Interpret the result of part (c) in view of the theorem:\n--       If f : A → B and if X ⊂ A and Y ⊂ A, then f(X ∪ Y) = f(X) ∪ f(Y).\n\n-- we do have that theorem already:\n#check set.image_union\n\n-- I'll just reprove it quickly:\ntheorem reproof {A B : Type} (f : A → B) (X Y : set A) :\n  f '' (X ∪ Y) = f '' X ∪ f '' Y :=\n  begin\n  unfold set.image,\n  unfold has_union.union set.union,\n  apply set.ext, intro b, simp,\n  constructor,\n  intro e, apply exists.elim e, intro a, intro h,\n  cases h, cases h_left,\n  { left, existsi a, tauto },\n  { right, existsi a, tauto },\n  intro e, cases e,\n  { apply exists.elim e, intro a, intro h,\n    existsi a, constructor, left, tauto, tauto\n  },\n  { apply exists.elim e, intro a, intro h,\n    existsi a, constructor, right, tauto, tauto\n  },\n  end\n\n-- helper theorem: [a, b] ∪ [c, d] = [a, d], given the following assumptions\ntheorem Icc_union {α : Type*} [linear_order α] (a b c d : α) :\n  a ≤ c → b ≥ c → b ≤ d →\n  Icc a b ∪ Icc c d = Icc a d :=\n    begin\n    intros,\n    unfold Icc, apply set.ext, intro x, simp,\n    constructor,\n    {\n      intro h, cases h,\n      constructor, exact h.1, transitivity, exact h.2, assumption,\n      constructor, transitivity, assumption, exact h.1, exact h.2,\n    }, {\n      intro h,\n      have m : x ≤ b ∨ b ≤ x := linear_order.le_total x b,\n      cases m,\n      left, constructor, exact h.1, exact m,\n      right, constructor, transitivity, assumption, exact m, exact h.2,\n    }\n    end\n\n-- so we can get part_c.part_iii from the previous two\ntheorem proof : f '' Icc 0 (pi/2) = Icc 0 1 :=\n  begin\n  have : Icc 0 (pi/6) ∪ Icc (pi/6) (pi/2) = Icc 0 (pi/2),\n  {\n    apply Icc_union,\n    /-\n    3 goals\n    ⊢ 0 ≤ pi / 6\n    ⊢ pi / 6 ≥ pi / 6\n    ⊢ pi / 6 ≤ pi / 2\n    -/\n    -- but we can't prove the ordering of pi since pi isn't defined here\n    admit, exact le_refl (pi/6), admit,\n  },\n  rw ← this, rw reproof, rw part_c.part_i, rw part_c.part_ii,\n  apply Icc_union,\n  exact le_of_lt one_half_pos,\n  exact le_refl (1/2),\n  exact le_of_lt one_half_lt_one,\n  end\n\nend part_d\n\nnamespace part_e\n\n-- (e) Let A = [0, π/6], B = [5π/6, π]. Does f(A ∩ B) = f(A) ∩ f(B)?\n\n-- nope, because A ∩ B = ∅, but f(A) = f(B) = [0, 1/2]\n\ndef A := Icc 0 (pi/6)\ndef B := Icc (5*pi/6) (pi)\nlemma A_image : f '' A = Icc 0 (1/2) := sorry\nlemma B_image : f '' B = Icc 0 (1/2) := sorry\n\ntheorem proof : f '' (A ∩ B) ≠ f '' A ∩ f '' B :=\n  begin\n  rw [A_image, B_image],\n  have : A ∩ B = ∅,\n  {\n    apply set.ext, intro x, simp,\n    show 0 ≤ x ∧ x ≤ pi/6 → ¬ (5*pi/6 ≤ x ∧ x ≤ pi),\n    suffices : x ≤ pi/6 → x < 5*pi/6,\n    {\n      intro h, apply not_and_of_not_left,\n      apply not_le_of_lt,\n      exact this h.2,\n    },\n    intro h,\n    apply lt_of_le_of_lt,\n    exact h,\n    show pi / 6 < 5 * pi / 6, admit,\n  },\n  rw this, simp [-one_div_eq_inv],\n  rw set.ext_iff,\n  -- proof by contradiction, essentially\n  -- (to prove (¬ p) you need to prove (p → false))\n  -- (actually, that is true by definition: not p := p → false)\n  intro empty_eq_Icc,\n  -- 0 is an element in the interval\n  exact (empty_eq_Icc 0).2 ⟨le_refl 0, le_of_lt one_half_pos⟩\n  end\n\nend part_e\n\nend problem1\n\nnamespace problem2\n\n-- (2) Can you give a geometric interpretation for the Cartesian product of\n-- (a) A line segment and a triangle?\n\n-- A triangular prism?\n\n-- (b) A large circle and a small circle?\n\n-- An ellipsoid??? Or maybe something in 4d space, since the circles are\n-- each 2d ...\n-- (My roommate: \"Prolly ... a bigger circle?\")\n\nend problem2\n\nnamespace problem3\n\n-- (3) If f : (−1, 1) → ℝ is defined by f(x) = arcsin x and\n--     g : (−π/2, π/2) → ℝ by g(x) = tan x, let h = g ◦ f. Write a simple\n--     formula for h. What are the domain and range of h?\n\n-- h x = g (f x) = tan (arcsin x) = sin (arcsin x) / cos (arcsin x)\n--     = x / cos (arcsin x) = x / sqrt(1 - x²)\n--     = sqrt(x² / (1 - x²))\n--     = if x = 0 then 0 else (x⁻² - 1)^(-1/2)\n\n-- aux proof of cos (arcsin x) = sqrt(1 - x^2):\n--   forall y:\n--   (cos y)^2 + (sin y)^2 = 1\n--   cos y = sqrt(1 - (sin y)^2)\n--   rewrite y = arcsin x:\n--   cos (arcsin x) = sqrt(1 - (sin (arcsin x))^2)\n--   cos (arcsin x) = sqrt(1 - x^2)\n\n-- domain of f : (-1, 1), range of f : (-π/2, π/2),\n--   since f is continuous and monotonic between f(-1) = -π/2 and f(1) = π/2\n-- domain of g : (-π/2, π/2), range of g : (-∞, ∞),\n--   since f is continuous and lim[x → ­±π/2] f = ±∞\n-- so domain of h : (-1, 1), range of h : (-∞, ∞)\n\nend problem3\n\nnamespace problem4\n\n-- (4) Let f : ℝ → ℝ be defined by f(x) = 2x. Can you think of functions g\n--     and h which satisfy these two equations?\n-- g ◦ f = 2 * g * h\n-- h ◦ f = h^2 − g^2\n\ndef f (x : ℝ) := 2*x\n\ndef problem := ∃ (g h : ℝ → ℝ), ∀ x,\n  g (f x) = 2 * g x * h x ∧\n  h (f x) = (h x)^2 - (g x)^2\n\ndef g (x : ℝ) := sin x\ndef h (x : ℝ) := cos x\n\n-- graph it! obviously can't prove it here ...\nlemma sin_two_eq_two_sin_cos :\n  ∀ x, sin (2 * x) = 2 * sin x * cos x := sorry\nlemma sin_two_eq_cos_sqr_sub_sin_sqr :\n  ∀ x, cos (2 * x) = (cos x)^2 - (sin x)^2 := sorry\n\n-- our proof is just a term with type defined by the problem\n-- (that is, it is a proof of the existence of such functions)\ndef proof : problem :=\n  begin\n  existsi g,\n  existsi h,\n  intro x,\n  constructor,\n  exact sin_two_eq_two_sin_cos x,\n  exact sin_two_eq_cos_sqr_sub_sin_sqr x,\n  end\n\nend problem4\n\n-- The next few questions concern the notion of the characteristic function\n-- of a set, which we now define. Let A be a subset of the real numbers ℝ.\n-- Define the characteristic function of A χ_A : ℝ → ℝ to be\n\n-- χ_A(x) = 1 if x ∈ A; 0 if x ∈ ℝ \\ A.\n\n-- this is the same spirit, in particular it works for\n-- a set of any type (which is also how it was assumed\n-- to be generalized in the examples), mapping\n-- 1 to true and 0 to false\ndef χ {α : Type} (A : set α) (a : α) := a ∈ A\n-- but really it's just the identity function\n-- (this is because sets in set theory are represented as functions\n-- α → Prop, for some α : Type, where the proposition returned\n-- is true for only the (a : α) in the set.)\n-- (in HoTT, a set also means that it has no path constructors.)\n@[simp] lemma χ_id {α : Type} (A : set α) : χ A = A := rfl\n\n\nnamespace problem5\n\n-- (5) If f : ℝ → ℝ is defined by f(x) = x^2 and χ_[0,9] is the\n--     characteristic function of [0, 9], of what subset of ℝ is\n--     χ[0,9] ◦ f the characteristic function?\n\ndef real.sqr (x : ℝ) := x ^ 2\ndef zero_through_nine : set ℝ := Icc 0 9\n\ndef answer : set ℝ := Icc (-3) 3\n\ntheorem proof : answer = χ zero_through_nine ∘ real.sqr :=\n  begin\n  apply set.ext, intro x,\n  show -3 ≤ x ∧ x ≤ 3 ↔ 0 ≤ x^2 ∧ x^2 ≤ 9,\n  unfold has_pow.pow monoid.pow, simp,\n  rw (by ring : (9 : ℝ) = 3 * 3),\n  constructor,\n  {\n    intro h,\n    have : x * x = abs x * abs x,\n      by_cases x = 0, { rw h, simp },\n      apply (mul_self_eq_mul_self_iff _ _).2,\n      apply abs_by_cases (λ y, x = y ∨ x = -y),\n      left, tauto, right, rw neg_neg,\n    rw this,\n    constructor,\n    exact mul_self_nonneg (abs x),\n    apply mul_self_le_mul_self,\n    exact abs_nonneg x,\n    apply abs_le.2, exact h,\n  }, {\n    intro h,\n    rw ← abs_le,\n    have : (0 : ℝ) ≤ 3,\n      { change real.of_rat 0 ≤ real.of_rat 3\n      , apply le_of_lt\n      , rw real.of_rat_lt\n      , from dec_trivial\n      },\n    rw ((by rw @real.sqrt_sqr (3 : ℝ); assumption) : 3 = real.sqrt (3^2)),\n    unfold has_pow.pow monoid.pow, simp,\n    rw ← real.sqrt_mul_self_eq_abs x,\n    rw real.sqrt_le,\n    exact h.2, exact h.1,\n    apply le_of_lt,\n    change real.of_rat 0 < real.of_rat (3 * 3),\n    rw real.of_rat_lt,\n    from dec_trivial\n  }\n  end\n\nend problem5\n\nnamespace problem6\n\n-- (6) If f : A → B is a function and χ_E is the characteristic function of\n-- E ⊂ B, of what subset of A is χ_E ◦ f the characteristic function?\n\n-- that's just the preimage of f over E, the set of points in the domain such\n-- that their image under f is in E: { x : A | f x ∈ E }\ndef answer {A B : Type} (f : A → B) (E : set B) := f ⁻¹' E\n#print set.preimage\ntheorem proof {A B : Type} (f : A → B) (E : set B)\n  : χ E ∘ f = answer f E :=\n  begin apply set.ext, intro x, simpa end\n\nend problem6\n\nnamespace problem7\n\n-- (7) Using whatever concept of continuity you possess, answer the\n--     following questions (the answer is supposed to be intuitive,\n--     and is not meant to include a rigorous proof):\n\n-- (a) Is there a continuous characteristic function on ℝ? That is, is there\n--     a subset A of ℝ such that χ_A is continuous?\n\n-- Yes, there are two: A = ℝ, and A = ∅.\n\n-- (b) Are there three such functions?\n\n-- No, any deviation from a constant function produces a discontinuity.\n\nend problem7\n\nnamespace problem8\n\n-- (8) Draw the graphs of two continuous functions f and g with the same\n--     domain. Would you guess that the functions\n--     M := max(f, g) and m := min(f, g) are continuous?\n\n-- [insert graphs badly drawn with crayons as if penned by a 5yo] jk\n\n-- Yes, I would guess so.\n-- And it's this is actually a theorem already ...\n-- The gist of it is this lemma\n#check continuous_if\n-- which basically says that piecewise functions, in order to be continuous,\n-- must be equal when the if  statement switches between true and false (and\n-- of course, the functions should be continuous otherwise). The if\n-- statement does indeed switch between true and false when the functions\n-- are equal, by the definition of `max` and `min`.\n\ndef pointwise {A B I O : Type} (f : A → B → O) (g : I → A) (h : I → B) :=\n  λ i, f (g i) (h i)\n\ntheorem proof (f g : ℝ → ℝ) : continuous f → continuous g → continuous (pointwise max f g) ∧ continuous (pointwise min f g) :=\n  begin\n  intros cf cg,\n  constructor,\n  exact continuous_max cf cg,\n  exact continuous_min cf cg,\n  end\n\nend problem8\n\nnamespace problem9\n\n-- (9) (a) If f : A → B and g : B → C and both f and g are injective,\n--         is g ◦ f also injective?\n--     (b) If f is not injective, is it still possible that g ◦ f is\n--         injective?\n--     (c) Give an example in which f is injective, g is not injective,\n--         but g ◦ f is injective.\nopen function\n\n-- it's very straightforward ...\ntheorem part_a {A B C : Type} (f : A → B) (g : B → C) : function.injective f → function.injective g → function.injective (g ∘ f) :=\n  flip function.injective_comp\n\ntheorem part_b {A B C : Type} (f : A → B) (g : B → C) : ¬ function.injective f → function.injective g → ¬ function.injective (g ∘ f) :=\n  begin\n  intros f_ninj g_inj comp_inj,\n  apply f_ninj,\n  intros a b e,\n  unfold function.injective function.comp at comp_inj,\n  apply comp_inj (congr_arg _ e),\n  end\n\nnamespace part_c\n\ndef A := unit\ndef B := bool\ndef C := unit\ndef f : A → B := λ _, ff\ndef g : B → C := λ _, unit.star\ntheorem proof : injective f ∧ ¬ injective g ∧ injective (g ∘ f) :=\n  begin\n  constructor,\n  intros _ _ _, apply @subsingleton.elim unit,\n  constructor,\n  intro f,\n  exact bool.no_confusion (@f tt ff (by apply @subsingleton.elim unit)),\n  intros _ _ _, apply @subsingleton.elim unit,\n  end\n\nend part_c\n\nend problem9\n\nnamespace problem10\n\n-- (10) Let P_n be the set of polynomial functions f of degree n,\n--          f(x) = a_0 + a_1 * x + · · · a_n * x^n\n--      where n is a fixed non-negative integer and the coefficients\n--      a0, . . . , an are integers. Prove that P_n is countable.\n\n-- In this problem I'll use `encodable α` instead of `countable α`, which is\n-- defined as `nonempty (encodable α)` (that is, the mere proposition\n-- that there exists an encoding for the type).\n\n-- A vector of numbers of size n essentially represents the data of a\n-- polynomial of degree (n-1); that is, there is a bijection between these\n-- mathematical objects. So I'll prove that a vector of encodables is\n-- encodable.\n\n-- The gist of the proof is induction on n, using cartesian products\n-- to add another layer to the vector.\n\ntheorem encodable_equiv {α β : Type} : α ≃ β → encodable α → encodable β :=\n  begin\n  intros eqv c,\n  apply encodable.mk (c.encode ∘ eqv.2) (option.map eqv.1 ∘ c.decode),\n  intro b, simp, existsi (eqv.2 b),\n  rw c.encodek, simp, exact eqv.4 b,\n  end\n\ntheorem encodable_array {α : Type} : encodable α → ∀ n : ℕ, encodable (vector α n) :=\n  begin\n  intros c n, induction n with n ih,\n  suffices : unit ≃ vector α 0,\n  {\n    apply encodable_equiv this, apply_instance,\n  },\n  apply equiv.mk (λ _, vector.nil) (λ _, unit.star),\n  intro _, apply subsingleton.elim,\n  intro _, rw vector.eq_nil x,\n  suffices : (α × vector α n) ≃ vector α (n+1),\n  {\n    apply encodable_equiv this,\n    apply @encodable.prod _ _ c ih,\n  },\n  apply equiv.mk\n    (λ (p : α × vector α n), vector.cons p.1 p.2)\n    (λ a, begin\n    cases a with l p,\n    cases l, exfalso, exact nat.succ_ne_zero _ (eq.symm p),\n    constructor, exact l_hd,\n    apply subtype.mk l_tl,\n    exact nat.succ.inj p,\n    end),\n  intro a, cases a, cases a_snd, simpa,\n  intro a, cases a, simp,\n  cases a_val, exfalso, exact nat.succ_ne_zero _ (eq.symm a_property),\n  simpa,\n  end\n\nend problem10\n\nnamespace problem11\n\n-- (11) Prove that if B is a countable subset of an uncountable set A, then\n-- A \\ B is uncountable.\ntheorem proof {α : Type} (A B : set α)\n  (H : B ⊆ A) (HA : ¬(countable A)) (HB : countable B) : ¬(countable (A \\ B)) :=\n  λ HC,\n  have this : (A \\ B) ∪ B = A :=\n    eq.trans diff_union_self (union_eq_self_of_subset_right H),\n  HA (eq.mp (congr_arg countable this) (countable_union HC HB))\n\nend problem11\n\nend set_theory_review\n", "meta": {"author": "MonoidMusician", "repo": "lean-math-stuff", "sha": "56e6ae80b4a634f23a90989a7156ce053a012acf", "save_path": "github-repos/lean/MonoidMusician-lean-math-stuff", "path": "github-repos/lean/MonoidMusician-lean-math-stuff/lean-math-stuff-56e6ae80b4a634f23a90989a7156ce053a012acf/src/MATH361/set_theory_review.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4706036800138831}}
{"text": "import classes.context_free.closure_properties.union\nimport classes.context_free.closure_properties.intersection\n\n\n/-- The class of context-free languages isn't closed under complement. -/\ntheorem nnyCF_of_complement_CF : ¬ (∀ T : Type, ∀ L : language T,\n    is_CF L  →  is_CF (Lᶜ)\n) :=\nbegin\n  intro h,\n  have nny := nnyCF_of_CF_i_CF,\n  push_neg at nny,\n  rcases nny with ⟨T, L₁, L₂, ⟨hL₁, hL₂⟩, hyp_neg⟩,\n  specialize h T,\n  have hu := CF_of_CF_u_CF (L₁ᶜ) (L₂ᶜ) ⟨h L₁ hL₁, h L₂ hL₂⟩,\n  have contra := h (L₁ᶜ + L₂ᶜ) hu,\n  apply hyp_neg,\n  -- golfed by Eric Wieser\n  rwa [language.add_def, set.compl_union, compl_compl, compl_compl] at contra,\nend\n", "meta": {"author": "madvorak", "repo": "grammars", "sha": "5ab26130eb76d5f7cde0f6c2f9c6f3107ff8d34f", "save_path": "github-repos/lean/madvorak-grammars", "path": "github-repos/lean/madvorak-grammars/grammars-5ab26130eb76d5f7cde0f6c2f9c6f3107ff8d34f/src/classes/context_free/closure_properties/complement.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.47060368001388303}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.monoidal.CommMon_\n! leanprover-community/mathlib commit a836c6dba9bd1ee2a0cdc9af0006a596f243031c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Monoidal.Braided\nimport Mathbin.CategoryTheory.Monoidal.Mon_\n\n/-!\n# The category of commutative monoids in a braided monoidal category.\n-/\n\n\nuniverse v₁ v₂ u₁ u₂ u\n\nopen CategoryTheory\n\nopen CategoryTheory.MonoidalCategory\n\nvariable (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] [BraidedCategory.{v₁} C]\n\n/-- A commutative monoid object internal to a monoidal category.\n-/\nstructure CommMon_ extends Mon_ C where\n  mul_comm' : (β_ _ _).Hom ≫ mul = mul := by obviously\n#align CommMon_ CommMon_\n\nrestate_axiom CommMon_.mul_comm'\n\nattribute [simp, reassoc.1] CommMon_.mul_comm\n\nnamespace CommMon_\n\n/-- The trivial commutative monoid object. We later show this is initial in `CommMon_ C`.\n-/\n@[simps]\ndef trivial : CommMon_ C :=\n  { Mon_.trivial C with mul_comm' := by dsimp; rw [braiding_left_unitor, unitors_equal] }\n#align CommMon_.trivial CommMon_.trivial\n\ninstance : Inhabited (CommMon_ C) :=\n  ⟨trivial C⟩\n\nvariable {C} {M : CommMon_ C}\n\ninstance : Category (CommMon_ C) :=\n  InducedCategory.category CommMon_.toMon_\n\n@[simp]\ntheorem id_hom (A : CommMon_ C) : Mon_.Hom.hom (𝟙 A) = 𝟙 A.pt :=\n  rfl\n#align CommMon_.id_hom CommMon_.id_hom\n\n@[simp]\ntheorem comp_hom {R S T : CommMon_ C} (f : R ⟶ S) (g : S ⟶ T) :\n    Mon_.Hom.hom (f ≫ g) = f.Hom ≫ g.Hom :=\n  rfl\n#align CommMon_.comp_hom CommMon_.comp_hom\n\nsection\n\nvariable (C)\n\n/-- The forgetful functor from commutative monoid objects to monoid objects. -/\ndef forget₂Mon_ : CommMon_ C ⥤ Mon_ C :=\n  inducedFunctor CommMon_.toMon_ deriving Full, Faithful\n#align CommMon_.forget₂_Mon_ CommMon_.forget₂Mon_\n\n@[simp]\ntheorem forget₂_Mon_obj_one (A : CommMon_ C) : ((forget₂Mon_ C).obj A).one = A.one :=\n  rfl\n#align CommMon_.forget₂_Mon_obj_one CommMon_.forget₂_Mon_obj_one\n\n@[simp]\ntheorem forget₂_Mon_obj_mul (A : CommMon_ C) : ((forget₂Mon_ C).obj A).mul = A.mul :=\n  rfl\n#align CommMon_.forget₂_Mon_obj_mul CommMon_.forget₂_Mon_obj_mul\n\n@[simp]\ntheorem forget₂_Mon_map_hom {A B : CommMon_ C} (f : A ⟶ B) : ((forget₂Mon_ C).map f).Hom = f.Hom :=\n  rfl\n#align CommMon_.forget₂_Mon_map_hom CommMon_.forget₂_Mon_map_hom\n\nend\n\ninstance uniqueHomFromTrivial (A : CommMon_ C) : Unique (trivial C ⟶ A) :=\n  Mon_.uniqueHomFromTrivial A.toMon_\n#align CommMon_.unique_hom_from_trivial CommMon_.uniqueHomFromTrivial\n\nopen CategoryTheory.Limits\n\ninstance : HasInitial (CommMon_ C) :=\n  hasInitial_of_unique (trivial C)\n\nend CommMon_\n\nnamespace CategoryTheory.LaxBraidedFunctor\n\nvariable {C} {D : Type u₂} [Category.{v₂} D] [MonoidalCategory.{v₂} D] [BraidedCategory.{v₂} D]\n\n/-- A lax braided functor takes commutative monoid objects to commutative monoid objects.\n\nThat is, a lax braided functor `F : C ⥤ D` induces a functor `CommMon_ C ⥤ CommMon_ D`.\n-/\n@[simps]\ndef mapCommMon (F : LaxBraidedFunctor C D) : CommMon_ C ⥤ CommMon_ D\n    where\n  obj A :=\n    { F.toLaxMonoidalFunctor.mapMon.obj A.toMon_ with\n      mul_comm' := by\n        dsimp\n        have := F.braided\n        slice_lhs 1 2 => rw [← this]\n        slice_lhs 2 3 => rw [← CategoryTheory.Functor.map_comp, A.mul_comm] }\n  map A B f := F.toLaxMonoidalFunctor.mapMon.map f\n#align category_theory.lax_braided_functor.map_CommMon CategoryTheory.LaxBraidedFunctor.mapCommMon\n\nvariable (C) (D)\n\n/-- `map_CommMon` is functorial in the lax braided functor. -/\ndef mapCommMonFunctor : LaxBraidedFunctor C D ⥤ CommMon_ C ⥤ CommMon_ D\n    where\n  obj := mapCommMon\n  map F G α := { app := fun A => { Hom := α.app A.pt } }\n#align category_theory.lax_braided_functor.map_CommMon_functor CategoryTheory.LaxBraidedFunctor.mapCommMonFunctor\n\nend CategoryTheory.LaxBraidedFunctor\n\nnamespace CommMon_\n\nopen CategoryTheory.LaxBraidedFunctor\n\nnamespace EquivLaxBraidedFunctorPunit\n\n/-- Implementation of `CommMon_.equiv_lax_braided_functor_punit`. -/\n@[simps]\ndef laxBraidedToCommMon : LaxBraidedFunctor (Discrete PUnit.{u + 1}) C ⥤ CommMon_ C\n    where\n  obj F := (F.mapCommMon : CommMon_ _ ⥤ CommMon_ C).obj (trivial (Discrete PUnit))\n  map F G α := ((mapCommMonFunctor (Discrete PUnit) C).map α).app _\n#align CommMon_.equiv_lax_braided_functor_punit.lax_braided_to_CommMon CommMon_.EquivLaxBraidedFunctorPunit.laxBraidedToCommMon\n\n/-- Implementation of `CommMon_.equiv_lax_braided_functor_punit`. -/\n@[simps]\ndef commMonToLaxBraided : CommMon_ C ⥤ LaxBraidedFunctor (Discrete PUnit.{u + 1}) C\n    where\n  obj A :=\n    { obj := fun _ => A.pt\n      map := fun _ _ _ => 𝟙 _\n      ε := A.one\n      μ := fun _ _ => A.mul\n      map_id' := fun _ => rfl\n      map_comp' := fun _ _ _ _ _ => (Category.id_comp (𝟙 A.pt)).symm }\n  map A B f :=\n    { app := fun _ => f.Hom\n      naturality' := fun _ _ _ => by\n        dsimp\n        rw [category.id_comp, category.comp_id]\n      unit' := f.OneHom\n      tensor' := fun _ _ => f.MulHom }\n#align CommMon_.equiv_lax_braided_functor_punit.CommMon_to_lax_braided CommMon_.EquivLaxBraidedFunctorPunit.commMonToLaxBraided\n\nattribute [local tidy] tactic.discrete_cases\n\nattribute [local simp] eq_to_iso_map\n\n/-- Implementation of `CommMon_.equiv_lax_braided_functor_punit`. -/\n@[simps]\ndef unitIso :\n    𝟭 (LaxBraidedFunctor (Discrete PUnit.{u + 1}) C) ≅\n      laxBraidedToCommMon C ⋙ commMonToLaxBraided C :=\n  NatIso.ofComponents\n    (fun F =>\n      LaxBraidedFunctor.mkIso\n        (MonoidalNatIso.ofComponents\n          (fun _ => F.toLaxMonoidalFunctor.toFunctor.mapIso (eqToIso (by ext))) (by tidy) (by tidy)\n          (by tidy)))\n    (by tidy)\n#align CommMon_.equiv_lax_braided_functor_punit.unit_iso CommMon_.EquivLaxBraidedFunctorPunit.unitIso\n\n/-- Implementation of `CommMon_.equiv_lax_braided_functor_punit`. -/\n@[simps]\ndef counitIso : commMonToLaxBraided C ⋙ laxBraidedToCommMon C ≅ 𝟭 (CommMon_ C) :=\n  NatIso.ofComponents\n    (fun F =>\n      { Hom := { Hom := 𝟙 _ }\n        inv := { Hom := 𝟙 _ } })\n    (by tidy)\n#align CommMon_.equiv_lax_braided_functor_punit.counit_iso CommMon_.EquivLaxBraidedFunctorPunit.counitIso\n\nend EquivLaxBraidedFunctorPunit\n\nopen EquivLaxBraidedFunctorPunit\n\nattribute [local simp] eq_to_iso_map\n\n/-- Commutative monoid objects in `C` are \"just\" braided lax monoidal functors from the trivial\nbraided monoidal category to `C`.\n-/\n@[simps]\ndef equivLaxBraidedFunctorPunit : LaxBraidedFunctor (Discrete PUnit.{u + 1}) C ≌ CommMon_ C\n    where\n  Functor := laxBraidedToCommMon C\n  inverse := commMonToLaxBraided C\n  unitIso := unitIso C\n  counitIso := counitIso C\n#align CommMon_.equiv_lax_braided_functor_punit CommMon_.equivLaxBraidedFunctorPunit\n\nend CommMon_\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Monoidal/CommMon_.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.47060367212040927}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport topology.bornology.basic\n\n/-!\n# Locally bounded maps\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines locally bounded maps between bornologies.\n\nWe use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to\nbe satisfied by itself and all stricter types.\n\n## Types of morphisms\n\n* `locally_bounded_map`: Locally bounded maps. Maps which preserve boundedness.\n\n## Typeclasses\n\n* `locally_bounded_map_class`\n-/\n\nopen bornology filter function set\n\nvariables {F α β γ δ : Type*}\n\n/-- The type of bounded maps from `α` to `β`, the maps which send a bounded set to a bounded set. -/\nstructure locally_bounded_map (α β : Type*) [bornology α] [bornology β] :=\n(to_fun : α → β)\n(comap_cobounded_le' : (cobounded β).comap to_fun ≤ cobounded α)\n\nsection\nset_option old_structure_cmd true\n\n/-- `locally_bounded_map_class F α β` states that `F` is a type of bounded maps.\n\nYou should extend this class when you extend `locally_bounded_map`. -/\nclass locally_bounded_map_class (F : Type*) (α β : out_param $ Type*) [bornology α]\n  [bornology β]\n  extends fun_like F α (λ _, β) :=\n(comap_cobounded_le (f : F) : (cobounded β).comap f ≤ cobounded α)\n\nend\n\nexport locally_bounded_map_class (comap_cobounded_le)\n\nlemma is_bounded.image [bornology α] [bornology β] [locally_bounded_map_class F α β] {f : F}\n  {s : set α} (hs : is_bounded s) : is_bounded (f '' s) :=\ncomap_cobounded_le_iff.1 (comap_cobounded_le f) hs\n\ninstance [bornology α] [bornology β] [locally_bounded_map_class F α β] :\n  has_coe_t F (locally_bounded_map α β) :=\n⟨λ f, ⟨f, comap_cobounded_le f⟩⟩\n\nnamespace locally_bounded_map\nvariables [bornology α] [bornology β] [bornology γ]\n  [bornology δ]\n\ninstance : locally_bounded_map_class (locally_bounded_map α β) α β :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h, by { cases f, cases g, congr' },\n  comap_cobounded_le := λ f, f.comap_cobounded_le' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (locally_bounded_map α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : locally_bounded_map α β} : f.to_fun = (f : α → β) := rfl\n\n@[ext] lemma ext {f g : locally_bounded_map α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of a `locally_bounded_map` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\nprotected def copy (f : locally_bounded_map α β) (f' : α → β) (h : f' = f) :\n  locally_bounded_map α β :=\n⟨f', h.symm ▸ f.comap_cobounded_le'⟩\n\n@[simp] lemma coe_copy (f : locally_bounded_map α β) (f' : α → β) (h : f' = f) :\n  ⇑(f.copy f' h) = f' :=\nrfl\n\nlemma copy_eq (f : locally_bounded_map α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\nfun_like.ext' h\n\n/-- Construct a `locally_bounded_map` from the fact that the function maps bounded sets to bounded\nsets. -/\ndef of_map_bounded (f : α → β) (h) : locally_bounded_map α β := ⟨f, comap_cobounded_le_iff.2 h⟩\n\n@[simp] lemma coe_of_map_bounded (f : α → β) {h} : ⇑(of_map_bounded f h) = f := rfl\n@[simp] lemma of_map_bounded_apply (f : α → β) {h} (a : α) : of_map_bounded f h a = f a := rfl\n\nvariables (α)\n\n/-- `id` as a `locally_bounded_map`. -/\nprotected def id : locally_bounded_map α α := ⟨id, comap_id.le⟩\n\ninstance : inhabited (locally_bounded_map α α) := ⟨locally_bounded_map.id α⟩\n\n@[simp] lemma coe_id : ⇑(locally_bounded_map.id α) = id := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : locally_bounded_map.id α a = a := rfl\n\n/-- Composition of `locally_bounded_map`s as a `locally_bounded_map`. -/\ndef comp (f : locally_bounded_map β γ) (g : locally_bounded_map α β) : locally_bounded_map α γ :=\n{ to_fun := f ∘ g,\n  comap_cobounded_le' :=\n    comap_comap.ge.trans $ (comap_mono f.comap_cobounded_le').trans g.comap_cobounded_le' }\n\n@[simp] lemma coe_comp (f : locally_bounded_map β γ) (g : locally_bounded_map α β) :\n  ⇑(f.comp g) = f ∘ g := rfl\n@[simp] lemma comp_apply (f : locally_bounded_map β γ) (g : locally_bounded_map α β) (a : α) :\n  f.comp g a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : locally_bounded_map γ δ) (g : locally_bounded_map β γ)\n  (h : locally_bounded_map α β) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : locally_bounded_map α β) :\n  f.comp (locally_bounded_map.id α) = f := ext $ λ a, rfl\n@[simp] lemma id_comp (f : locally_bounded_map α β) :\n  (locally_bounded_map.id β).comp f = f := ext $ λ a, rfl\n\nlemma cancel_right {g₁ g₂ : locally_bounded_map β γ} {f : locally_bounded_map α β}\n  (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : locally_bounded_map β γ} {f₁ f₂ : locally_bounded_map α β}\n  (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, ext $ λ a, hg $ by rw [←comp_apply, h, comp_apply], congr_arg _⟩\n\nend locally_bounded_map\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/bornology/hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710234, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.47060366638688633}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\n\nimport data.set.disjointed data.set.countable\nimport data.set.lattice data.set.finite\nimport formal_ml.nat\n\n/-\n  Theorems about sets. The best repository of theorems about sets is\n  /mathlib/src/data/set/basic.lean. \n -/\n\n--Novel, used: move to mathlib?\n--Alternately, look into topological_space.lean, and see what is necessary.\nlemma set.preimage_fst_def {α β:Type*} {Bα:set (set α)}:\n    (@set.preimage (α × β) α (@prod.fst α β) '' Bα) =\n    {U : set (α × β) | ∃ (A : set α) (H : A ∈ Bα), U = @set.prod α β A (@set.univ β)} :=\nbegin\n  ext,split;intros A1A,\n  {\n    simp at A1A,\n    cases A1A with A A1A,\n    cases A1A with A1B A1C,\n    subst x,\n    split,\n    simp,\n    split,\n    apply A1B,\n    unfold set.prod,\n    simp,\n    refl,\n  },\n  {\n    simp at A1A,\n    cases A1A with A A1A,\n    cases A1A with A1B A1C,\n    subst x,\n    split,\n    split,\n    apply A1B,\n    unfold set.prod,\n    simp,\n    refl\n  }\nend\n\n\n--Novel, used.\nlemma set.preimage_snd_def {α β:Type*} {Bβ:set (set β)}:\n    (@set.preimage (α × β) β (@prod.snd α β) '' Bβ) =\n    {U : set (α × β) | ∃ (B : set β) (H : B ∈ Bβ), U = @set.prod α β (@set.univ α) B} :=\nbegin\n    ext,split;intros A1A,\n    {\n      simp at A1A,\n      cases A1A with A A1A,\n      cases A1A with A1B A1C,\n      subst x,\n      split,\n      simp,\n      split,\n      apply A1B,\n      unfold set.prod,\n      simp,\n      refl,\n    },\n    {\n      simp at A1A,\n      cases A1A with A A1A,\n      cases A1A with A1B A1C,\n      subst x,\n      split,\n      split,\n      apply A1B,\n      unfold set.prod,\n      simp,\n      refl\n    }\nend\n\n\n--Novel, used.\n--Similar, but not identical to set.preimage_sUnion.\n--Could probably replace it.\nlemma set.preimage_sUnion' {α β:Type*} (f:α → β) (T:set (set β)):\n (f ⁻¹' ⋃₀ T)=⋃₀ (set.image (set.preimage f)  T) :=\nbegin\n  rw set.preimage_sUnion,  \n  ext,split;intros A1;simp;simp at A1;apply A1,\nend\n\n\n\n--Novel, used.\nlemma set.prod_sUnion_right {α:Type*} (A:set α) {β:Type*} (B:set (set β)):\n  (set.prod A (⋃₀ B)) = ⋃₀  {C:set (α× β)|∃ b∈ B, C=(set.prod A b)} :=\nbegin\n  ext,split;intro A1,\n  {\n    cases A1 with A2 A3,\n    cases A3 with b A4,\n    cases A4 with A5 A6,\n    simp,\n    apply exists.intro (set.prod A b),\n    split,\n    {\n      apply exists.intro b,\n      split,\n      exact A5,\n      refl,\n    },\n    {\n      split;assumption,\n    }\n  },\n  {\n    cases A1 with Ab A2,\n    cases A2 with A3 A4,\n    cases A3 with b A5,\n    cases A5 with A6 A7,\n    subst Ab,\n    cases A4 with A8 A9,\n    split,\n    {\n      exact A8,\n    },\n    {\n      simp,\n      apply exists.intro b,\n      split;assumption,\n    }\n  }\nend\n\n\n--Novel, used.\nlemma set.prod_sUnion_left {α:Type*} (A:set (set α)) {β:Type*} (B:set β):\n  (set.prod (⋃₀ A) B) = ⋃₀  {C:set (α× β)|∃ a∈ A, C=(set.prod a B)} :=\nbegin\n  ext,split;intro A1,\n  {\n    cases A1 with A2 A3,\n    cases A2 with a A4,\n    cases A4 with A5 A6,\n    simp,\n    apply exists.intro (set.prod a B),\n    split,\n    {\n      apply exists.intro a,\n      split,\n      exact A5,\n      refl,\n    },\n    {\n      split;assumption,\n    }\n  },\n  {\n    cases A1 with Ab A2,\n    cases A2 with A3 A4,\n    cases A3 with b A5,\n    cases A5 with A6 A7,\n    subst Ab,\n    cases A4 with A8 A9,\n    split,\n    {\n      simp,\n      apply exists.intro b,\n      split;assumption,\n    },\n    {\n      exact A9,\n    }\n  }\nend\n\n--Novel, used.\nlemma union_trichotomy {β:Type*} [decidable_eq β] {b:β} {S S2:finset β}:\n  b∈ (S ∪ S2) ↔ (\n      ((b∈  S) ∧ (b∉ S2)) ∨ \n      ((b∈ S) ∧ (b ∈ S2)) ∨ \n      ((b∉ S) ∧ (b∈ S2))) :=\nbegin\n  have B1:(b∈ S)∨ (b∉ S),\n  {\n    apply classical.em,\n  },\n  have B2:(b∈ S2)∨ (b∉ S2),\n  {\n    apply classical.em,\n  },\n  split;intro A1,\n  {\n    simp at A1,\n    cases A1,\n    {\n      cases B2,\n      {\n        right,left,\n        apply and.intro A1 B2,  \n      },\n      {\n        left,\n        apply and.intro A1 B2,\n      },\n    },\n    {\n      right,\n      cases B1,\n      {\n        left,\n        apply and.intro B1 A1,\n      },\n      {\n        right,\n        apply and.intro B1 A1,\n      },\n    },\n  },\n  {\n    simp,\n    cases A1,\n    {\n      left,\n      apply A1.left,\n    },\n    cases A1,\n    {\n      left,\n      apply A1.left,\n    },\n    {\n      right,\n      apply A1.right,\n    },\n  },\nend\n\n/-\n  There are theorems about disjoint properties, but not about disjoint sets.\n  It would be good to figure out a long-term strategy of dealing with \n  disjointedness, as it is pervasive through measure theory and probability\n  theory. Disjoint is defined on lattices, and sets are basically the canonical\n  complete lattice. However, the relationship between complementary sets and\n  disjointedness is lost, as complementarity doesn't exist in a generic complete\n  lattice.\n\n  SIDE NOTE: lattice.lean now has a ton of theorems. Follow set.disjoint_compl_right\n -/\n--Replace with disjoint.symm\n\n\nlemma set.disjoint.symm {α:Type*} {A B:set α}:disjoint A B → disjoint B A :=\nbegin\n  apply @disjoint.symm (set α) _,\nend\n\n--Unused, but there are parallels in mathlib for finset and list.\n--Too trivial now.\nlemma set.disjoint_comm {α:Type*} {A B:set α}:disjoint A B ↔ disjoint B A :=\nbegin\n  apply @disjoint.comm (set α) _,\nend\n\nlemma set.disjoint_compl_right {α:Type*} (B:set α):disjoint B Bᶜ :=\nbegin\n  rw disjoint_iff,\n  simp,\nend \n\nlemma set.disjoint_inter_compl {α:Type*} (A B C:set α):disjoint (A ∩ B) (C∩ Bᶜ) :=\nbegin\n  apply set.disjoint_of_subset_left (set.inter_subset_right A B),\n  apply set.disjoint_of_subset_right (set.inter_subset_right C Bᶜ),\n  simp [disjoint_iff],\nend\n\n--In general, disjoint A C → disjoint (A ⊓ B) C\nlemma set.disjoint_inter_left {α:Type*} {A B C:set α}:\n  disjoint A C →\n  disjoint (A ∩ B) (C) :=\nbegin\n  intros A1,\n  apply set.disjoint_of_subset_left _ A1,\n  apply set.inter_subset_left,\nend\n\n--In general, disjoint A C → disjoint A (B ⊓ C)\nlemma set.disjoint_inter_right {α:Type*} {A B C:set α}:\n  disjoint A C →\n  disjoint A (B ∩ C) :=\nbegin\n  intros A1,\n  apply set.disjoint_of_subset_right _ A1,\n  apply set.inter_subset_right,\nend\n\n/-\n  The connection between Union and supremum comes in \n  useful in measure theory. The next three theorems\n  do this directly.\n -/\nlemma set.le_Union {α:Type*} {f:ℕ → set α} {n:ℕ}:\n    f n ≤ set.Union f :=\nbegin\n  rw set.le_eq_subset,\n  rw set.subset_def,\n  intros a A3,\n  simp,\n  apply exists.intro n A3,\nend\n\nlemma set.Union_le {α:Type*} {f:ℕ → set α} {S:set α}:\n    (∀ i, f i ≤ S) → \n    set.Union f ≤ S :=\nbegin\n  intro A1,\n  rw set.le_eq_subset,\n  rw set.subset_def,\n  intros x A2,\n  simp at A2,\n  cases A2 with n A2,\n  apply A1 n A2,\nend\n\nlemma supr_eq_Union {α:Type*}\n    {f:ℕ → set α}:\n    supr f = set.Union f :=\nbegin\n  apply le_antisymm,\n  {\n    apply @supr_le (set α) _ _,\n    intro i,\n    apply set.le_Union,\n  },\n  {\n    apply set.Union_le,\n    intros n,\n    apply @le_supr (set α) _ _,\n  },\nend\n\nlemma empty_of_subset_empty {α:Type*} (X:set α):\n    X ⊆ ∅ → X = ∅ :=\nbegin\n  have A1:(∅:set α) = ⊥ := rfl,\n  rw A1,\n  rw ← set.le_eq_subset,\n  intro A2,\n  rw le_bot_iff at A2,\n  apply A2,\nend\n\nlemma subset_empty_iff {α:Type*} (X:set α):\n    X ⊆ ∅ ↔ X = ∅ :=\nbegin\n  have A1:(∅:set α) = ⊥ := rfl,\n  rw A1,\n  rw ← set.le_eq_subset,\n  apply le_bot_iff,\nend\n\nlemma set.eq_univ_iff_univ_subset {α:Type*} {S:set α}:\n  set.univ ⊆ S ↔ S = set.univ :=\nbegin\n  have A1:@set.univ α = ⊤ := rfl,\n  rw A1,\n  rw ← set.le_eq_subset,\n  apply top_le_iff,\nend\n\nlemma preimage_if {α β:Type*}\n  {E:set α} {D:decidable_pred E}\n  {X Y:α → β} {S:set β}:\n  set.preimage (λ a:α, if (E a) then (X a) else (Y a)) S =\n  (E ∩ set.preimage X S) ∪ (Eᶜ ∩ set.preimage Y S) :=\nbegin\n  ext a;split;intros A1,\n  {\n    cases (classical.em (a∈ E)) with A2 A2,\n    {\n      rw set.mem_preimage at A1,\n      rw if_pos at A1,\n      apply set.mem_union_left,\n      apply set.mem_inter A2,\n      rw set.mem_preimage,\n      apply A1,\n      rw set.mem_def at A2,\n      apply A2,\n    },\n    {\n      rw set.mem_preimage at A1,\n      rw if_neg at A1,\n      apply set.mem_union_right,\n      apply set.mem_inter,\n      apply set.mem_compl,\n      apply A2,\n      rw set.mem_preimage,\n      apply A1,\n      rw set.mem_def at A2,\n      apply A2,\n    },\n  },\n  {\n    rw set.mem_preimage,\n    rw set.mem_union at A1,\n    cases A1 with A1 A1;\n    rw set.mem_inter_eq at A1;\n    cases A1 with A2 A3;\n    rw set.mem_preimage at A3;  \n    rw set.mem_def at A2,\n    {\n      rw if_pos,\n      apply A3,\n      apply A2,\n    },\n    {\n      rw if_neg,\n      apply A3,\n      apply A2,\n    },\n  },\nend\n\nlemma set.insert_inter_of_not_mem {α:Type*} {A B:set α} {x:α}:(x∉ B) → ((insert x A) ∩ B = A ∩ B) :=\nbegin\n  intros A1,\n  ext a,\n  split;intros A2;simp at A2;simp,\n  {\n    cases A2 with A2 A3,\n    cases A2 with A2 A4,\n    {\n      subst A2,\n      exfalso,\n      apply A1 A3,\n    },\n    {\n      apply and.intro A4 A3,\n    },\n  },\n  {\n    apply and.intro (or.inr A2.left) A2.right, \n  },\nend\n\nlemma set.inter_insert_of_not_mem {α:Type*} {A B:set α} {x:α}:(x∉ A) → (A ∩ (insert x B) = A ∩ B) :=\nbegin\n  intros A1,\n  rw set.inter_comm,\n  rw set.insert_inter_of_not_mem A1,\n  rw set.inter_comm,\nend\n\nlemma set.not_mem_of_inter_insert {α:Type*} {A B:set α} {x:α}:(x∉ A) → (A ∩ (insert x B) = A ∩ B) :=\nbegin\n  intros A1,\n  rw set.inter_comm,\n  rw set.insert_inter_of_not_mem A1,\n  rw set.inter_comm,\nend\n\n\nlemma set.inter_insert_of_mem {α:Type*} {A B:set α} {x:α}:(x∈ A) → (A ∩ (insert x B) = insert x (A ∩ B)) :=\nbegin\n  intros A1,\n  rw set.insert_inter,\n  rw set.insert_eq_of_mem A1,\nend\n\nlemma set.mem_of_inter_insert {α:Type*} {A B C:set α} {x:α}:\n  (A ∩ (insert x B) = insert x (C)) → (x ∈ A) :=\nbegin\n  intros A1,\n  have B1 := set.mem_insert x (C),\n  rw ← A1 at B1,\n  simp at B1,\n  apply B1,\nend\n\n\nlemma set.eq_of_insert_of_not_mem {α:Type*} {A B:set α} {x:α}:(x∉ A) → (x∉ B) → (insert x A  = insert x B)\n  → A = B :=\nbegin\n  intros A1 A3 A2,\n  ext a;split;intros B1;have C1 := set.mem_insert_of_mem x B1,\n  {\n    rw A2 at C1,\n    apply set.mem_of_mem_insert_of_ne C1,\n    intros C2,\n    subst a,\n    apply A1 B1,\n  },\n  {\n    rw ← A2 at C1,\n    apply set.mem_of_mem_insert_of_ne C1,\n    intros C2,\n    subst a,\n    apply A3 B1,\n  },\nend\n\nlemma directed_superset_of_monotone_dual {α:Type*} {f:ℕ → set α}:\n  (@monotone ℕ (set α) _ (order_dual.preorder (set α)) f) → (directed superset f) \n := begin\n  intros h_mono,\n  intros i j,\n  cases (le_total i j) with h_i_le_j h_j_le_i,\n  { apply exists.intro j,\n    split,\n    apply h_mono,\n    apply h_i_le_j,\n    apply set.subset.refl },\n  { apply exists.intro i,\n    split,\n    apply set.subset.refl,\n    apply h_mono,\n    apply h_j_le_i },\nend\n\nlemma monotone_of_monotone_nat_dual_iff {α:Type*} {f:ℕ → set α}:\n  (@monotone ℕ (set α) _ (order_dual.preorder (set α)) f) ↔ (∀ (n:ℕ), f (n.succ) ⊆ f n) := begin\n  split,\n  { intros h_mono,\n    intros n,\n    apply h_mono,\n    apply le_of_lt (nat.lt_succ_self _) },\n  { intros h_mono_nat,\n    apply @monotone_of_monotone_nat (set α) (order_dual.preorder (set α)),\n    intros n,\n    apply h_mono_nat },\nend\n\nlemma directed_superset_of_monotone_nat_dual {α:Type*} {f:ℕ → set α}:\n  (∀ (n:ℕ), f (n.succ) ⊆ f n) → (directed superset f) := begin\n  rw ← monotone_of_monotone_nat_dual_iff,\n  apply directed_superset_of_monotone_dual,\nend\n\n/- Note: monotone is a stronger property than directed.\n   e.g., directed can be increasing or decreasing, or \n   have a single maximal element in the middle. -/\nlemma directed_subset_of_monotone {α:Type*} {f:ℕ → set α}:\n  monotone f → (directed set.subset f) := begin\n  intros h_mono,\n  intros i j,\n  cases  (le_total i j),\n  { apply exists.intro j,\n    split,\n    apply h_mono h,\n    apply set.subset.refl },\n  { apply exists.intro i,\n    split,\n    apply set.subset.refl,\n    apply h_mono h },\nend\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/set.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.47052665482603645}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport data.multiset.nodup\n\n/-!\n# The cartesian product of multisets\n-/\n\nnamespace multiset\n\nsection pi\nvariables {α : Type*}\nopen function\n\n/-- Given `δ : α → Type*`, `pi.empty δ` is the trivial dependent function out of the empty\nmultiset. -/\ndef pi.empty (δ : α → Type*) : (Πa∈(0:multiset α), δ a) .\n\nvariables [decidable_eq α] {δ : α → Type*}\n\n/-- Given `δ : α → Type*`, a multiset `m` and a term `a`, as well as a term `b : δ a` and a\nfunction `f` such that `f a' : δ a'` for all `a'` in `m`, `pi.cons m a b f` is a function `g` such\nthat `g a'' : δ a''` for all `a''` in `a ::ₘ m`. -/\ndef pi.cons (m : multiset α) (a : α) (b : δ a) (f : Πa∈m, δ a) : Πa'∈a ::ₘ m, δ a' :=\nλa' ha', if h : a' = a then eq.rec b h.symm else f a' $ (mem_cons.1 ha').resolve_left h\n\nlemma pi.cons_same {m : multiset α} {a : α} {b : δ a} {f : Πa∈m, δ a} (h : a ∈ a ::ₘ m) :\n  pi.cons m a b f a h = b :=\ndif_pos rfl\n\nlemma pi.cons_ne {m : multiset α} {a a' : α} {b : δ a} {f : Πa∈m, δ a}\n  (h' : a' ∈ a ::ₘ m) (h : a' ≠ a) :\n  pi.cons m a b f a' h' = f a' ((mem_cons.1 h').resolve_left h) :=\ndif_neg h\n\nlemma pi.cons_swap {a a' : α} {b : δ a} {b' : δ a'} {m : multiset α} {f : Πa∈m, δ a} (h : a ≠ a') :\n  pi.cons (a' ::ₘ m) a b (pi.cons m a' b' f) == pi.cons (a ::ₘ m) a' b' (pi.cons m a b f) :=\nbegin\n  apply hfunext rfl,\n  rintro a'' _ rfl,\n  refine hfunext (by rw [cons_swap]) (λ ha₁ ha₂ _, _),\n  rcases ne_or_eq a'' a with h₁ | rfl,\n  rcases eq_or_ne a'' a' with rfl | h₂,\n  all_goals { simp [*, pi.cons_same, pi.cons_ne] },\nend\n\n/-- `pi m t` constructs the Cartesian product over `t` indexed by `m`. -/\ndef pi (m : multiset α) (t : Πa, multiset (δ a)) : multiset (Πa∈m, δ a) :=\nm.rec_on {pi.empty δ} (λa m (p : multiset (Πa∈m, δ a)), (t a).bind $ λb, p.map $ pi.cons m a b)\nbegin\n  intros a a' m n,\n  by_cases eq : a = a',\n  { subst eq },\n  { simp [map_bind, bind_bind (t a') (t a)],\n    apply bind_hcongr, { rw [cons_swap a a'] },\n    intros b hb,\n    apply bind_hcongr, { rw [cons_swap a a'] },\n    intros b' hb',\n    apply map_hcongr, { rw [cons_swap a a'] },\n    intros f hf,\n    exact pi.cons_swap eq }\nend\n\n@[simp] lemma pi_zero (t : Πa, multiset (δ a)) : pi 0 t = {pi.empty δ} := rfl\n\n@[simp] lemma pi_cons (m : multiset α) (t : Πa, multiset (δ a)) (a : α) :\n  pi (a ::ₘ m) t = ((t a).bind $ λb, (pi m t).map $ pi.cons m a b) :=\nrec_on_cons a m\n\nlemma pi_cons_injective {a : α} {b : δ a} {s : multiset α} (hs : a ∉ s) :\n  function.injective (pi.cons s a b) :=\nassume f₁ f₂ eq, funext $ assume a', funext $ assume h',\nhave ne : a ≠ a', from assume h, hs $ h.symm ▸ h',\nhave a' ∈ a ::ₘ s, from mem_cons_of_mem h',\ncalc f₁ a' h' = pi.cons s a b f₁ a' this : by rw [pi.cons_ne this ne.symm]\n  ... = pi.cons s a b f₂ a' this : by rw [eq]\n  ... = f₂ a' h' : by rw [pi.cons_ne this ne.symm]\n\nlemma card_pi (m : multiset α) (t : Πa, multiset (δ a)) :\n  card (pi m t) = prod (m.map $ λa, card (t a)) :=\nmultiset.induction_on m (by simp) (by simp [mul_comm] {contextual := tt})\n\nprotected lemma nodup.pi {s : multiset α} {t : Π a, multiset (δ a)} :\n  nodup s → (∀a∈s, nodup (t a)) → nodup (pi s t) :=\nmultiset.induction_on s (assume _ _, nodup_singleton _)\nbegin\n  assume a s ih hs ht,\n  have has : a ∉ s, by simp at hs; exact hs.1,\n  have hs : nodup s, by simp at hs; exact hs.2,\n  simp,\n  refine ⟨λ b hb, (ih hs $ λ a' h', ht a' $ mem_cons_of_mem h').map (pi_cons_injective has), _⟩,\n  refine (ht a $ mem_cons_self _ _).pairwise _,\n  from assume b₁ hb₁ b₂ hb₂ neb, disjoint_map_map.2 (assume f hf g hg eq,\n    have pi.cons s a b₁ f a (mem_cons_self _ _) = pi.cons s a b₂ g a (mem_cons_self _ _),\n      by rw [eq],\n    neb $ show b₁ = b₂, by rwa [pi.cons_same, pi.cons_same] at this)\nend\n\n@[simp]\nlemma pi.cons_ext {m : multiset α} {a : α} (f : Π a' ∈ a ::ₘ m, δ a') :\n  pi.cons m a (f _ (mem_cons_self _ _)) (λ a' ha', f a' (mem_cons_of_mem ha')) = f :=\nbegin\n  ext a' h',\n  by_cases a' = a,\n  { subst h, rw [pi.cons_same] },\n  { rw [pi.cons_ne _ h] }\nend\n\nlemma mem_pi (m : multiset α) (t : Πa, multiset (δ a)) :\n  ∀f:Πa∈m, δ a, (f ∈ pi m t) ↔ (∀a (h : a ∈ m), f a h ∈ t a) :=\nbegin\n  intro f,\n  induction m using multiset.induction_on with a m ih,\n  { simpa using show f = pi.empty δ, by funext a ha; exact ha.elim },\n  simp_rw [pi_cons, mem_bind, mem_map, ih],\n  split,\n  { rintro ⟨b, hb, f', hf', rfl⟩ a' ha',\n    by_cases a' = a,\n    { subst h, rwa [pi.cons_same] },\n    { rw [pi.cons_ne _ h], apply hf' } },\n  { intro hf,\n    refine ⟨_, hf a (mem_cons_self _ _), _, λ a ha, hf a (mem_cons_of_mem ha), _⟩,\n    rw pi.cons_ext }\nend\n\nend pi\n\nend multiset\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/data/multiset/pi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.47052665482603634}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport data.fintype.order\nimport order.category.LinearOrder\n\n/-!\n# Nonempty finite linear orders\n\nThis defines `NonemptyFinLinOrd`, the category of nonempty finite linear orders with monotone maps.\nThis is the index category for simplicial objects.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- A typeclass for nonempty finite linear orders. -/\nclass nonempty_fin_lin_ord (α : Type*) extends fintype α, linear_order α :=\n(nonempty : nonempty α . tactic.apply_instance)\n\nattribute [instance] nonempty_fin_lin_ord.nonempty\n\n@[priority 100]\ninstance nonempty_fin_lin_ord.to_bounded_order (α : Type*) [nonempty_fin_lin_ord α] :\n  bounded_order α :=\nfintype.to_bounded_order α\n\ninstance punit.nonempty_fin_lin_ord : nonempty_fin_lin_ord punit :=\n{ .. punit.linear_ordered_cancel_add_comm_monoid,\n  .. punit.fintype }\n\ninstance fin.nonempty_fin_lin_ord (n : ℕ) : nonempty_fin_lin_ord (fin (n+1)) :=\n{ .. fin.fintype _,\n  .. fin.linear_order }\n\ninstance ulift.nonempty_fin_lin_ord (α : Type u) [nonempty_fin_lin_ord α] :\n  nonempty_fin_lin_ord (ulift.{v} α) :=\n{ nonempty := ⟨ulift.up ⊥⟩,\n  .. linear_order.lift equiv.ulift (equiv.injective _),\n  .. ulift.fintype _ }\n\ninstance (α : Type*) [nonempty_fin_lin_ord α] : nonempty_fin_lin_ord (order_dual α) :=\n{ ..order_dual.fintype α }\n\n/-- The category of nonempty finite linear orders. -/\ndef NonemptyFinLinOrd := bundled nonempty_fin_lin_ord\n\nnamespace NonemptyFinLinOrd\n\ninstance : bundled_hom.parent_projection @nonempty_fin_lin_ord.to_linear_order := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] NonemptyFinLinOrd\n\ninstance : has_coe_to_sort NonemptyFinLinOrd Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `NonemptyFinLinOrd` from the underlying type and typeclass. -/\ndef of (α : Type*) [nonempty_fin_lin_ord α] : NonemptyFinLinOrd := bundled.of α\n\n@[simp] lemma coe_of (α : Type*) [nonempty_fin_lin_ord α] : ↥(of α) = α := rfl\n\ninstance : inhabited NonemptyFinLinOrd := ⟨of punit⟩\n\ninstance (α : NonemptyFinLinOrd) : nonempty_fin_lin_ord α := α.str\n\ninstance has_forget_to_LinearOrder : has_forget₂ NonemptyFinLinOrd LinearOrder :=\nbundled_hom.forget₂ _ _\n\n/-- Constructs an equivalence between nonempty finite linear orders from an order isomorphism\nbetween them. -/\n@[simps] def iso.mk {α β : NonemptyFinLinOrd.{u}} (e : α ≃o β) : α ≅ β :=\n{ hom := e,\n  inv := e.symm,\n  hom_inv_id' := by { ext, exact e.symm_apply_apply x },\n  inv_hom_id' := by { ext, exact e.apply_symm_apply x } }\n\n/-- `order_dual` as a functor. -/\n@[simps] def dual : NonemptyFinLinOrd ⥤ NonemptyFinLinOrd :=\n{ obj := λ X, of (order_dual X), map := λ X Y, order_hom.dual }\n\n/-- The equivalence between `FinPartialOrder` and itself induced by `order_dual` both ways. -/\n@[simps functor inverse] def dual_equiv : NonemptyFinLinOrd ≌ NonemptyFinLinOrd :=\nequivalence.mk dual dual\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n\nend NonemptyFinLinOrd\n\nlemma NonemptyFinLinOrd_dual_comp_forget_to_LinearOrder :\n  NonemptyFinLinOrd.dual ⋙ forget₂ NonemptyFinLinOrd LinearOrder =\n    forget₂ NonemptyFinLinOrd LinearOrder ⋙ LinearOrder.dual := rfl\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/order/category/NonemptyFinLinOrd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.47052665482603606}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport .mathlib\n\n/-!\n# Constructions of `finpartition`\n-/\n\nopen finpartition finset\n\nvariables {α : Type*}\n\nsection\nvariables [decidable_eq α] {s : finset α}\n\nlemma equitabilise_aux1' {m a b : ℕ} (hs : a*m + b*(m+1) = s.card) (A : finpartition s)\n  (h : s = ∅) :\n  ∃ (P : finpartition s),\n    (∀ (x : finset α), x ∈ P.parts → x.card = m ∨ x.card = m + 1) ∧\n    (∀ x, x ∈ A.parts → (x \\ finset.bUnion (P.parts.filter (λ y, y ⊆ x)) id).card ≤ m) ∧\n    ((P.parts.filter (λ i, finset.card i = m+1)).card = b) :=\nbegin\n  subst h,\n  rw unique.eq_default A,\n  refine ⟨finpartition.empty _, by simp, by simp, _⟩,\n  simp only [finset.card_empty, nat.mul_eq_zero, nat.succ_ne_zero, or_false,\n    add_eq_zero_iff, and_false] at hs,\n  simp [hs.2.symm],\nend\n\nlemma equitabilise_aux2' {m a b : ℕ} (hs : a*m + b*(m+1) = s.card) (A : finset (finset α))\n  (subs : ∀ i ∈ A, i ⊆ s) (h : m = 0) :\n  ∃ (P : finpartition s),\n    (∀ (x : finset α), x ∈ P.parts → x.card = m ∨ x.card = m+1) ∧\n    (∀ x, x ∈ A → (x \\ finset.bUnion (P.parts.filter (λ y, y ⊆ x)) id).card ≤ m) ∧\n    ((P.parts.filter (λ i, finset.card i = m+1)).card = b) :=\nbegin\n  subst h,\n  simp only [mul_one, zero_add, mul_zero] at hs,\n  simp only [exists_prop, finset.card_eq_zero, zero_add, le_zero_iff, sdiff_eq_empty_iff_subset],\n  refine ⟨⊥, by simp, λ x hx i hi, _, _⟩,\n  { simp only [mem_bUnion, exists_prop, mem_filter, id.def, and_assoc],\n    exact ⟨{i}, mem_map_of_mem _ (subs x hx hi), by simpa, by simp⟩ },\n  { rw [filter_true_of_mem, card_bot, hs],\n    simp }\nend\n\nlemma equitabilise_aux' {m a b : ℕ} (hs : a*m + b*(m+1) = s.card) (A : finpartition s) :\n  ∃ (P : finpartition s),\n    (∀ (x : finset α), x ∈ P.parts → x.card = m ∨ x.card = m + 1) ∧\n    (∀ x, x ∈ A.parts → (x \\ finset.bUnion (P.parts.filter (λ y, y ⊆ x)) id).card ≤ m) ∧\n    ((P.parts.filter (λ i, finset.card i = m+1)).card = b) :=\nbegin\n  induction s using finset.strong_induction with s ih generalizing A a b,\n  cases s.eq_empty_or_nonempty with h hs_ne,\n  { apply equitabilise_aux1' hs _ h },\n  cases m.eq_zero_or_pos with h m_pos,\n  { apply equitabilise_aux2' hs _ (λ i hi, A.le hi) h },\n  have : 0 < a ∨ 0 < b,\n  { by_contra,\n    push_neg at h,\n    simp only [le_zero_iff] at h,\n    rw [h.1, h.2] at hs,\n    simp only [add_zero, zero_mul, eq_comm, finset.card_eq_zero] at hs,\n    exact hs_ne.ne_empty hs },\n  set p'_size := if 0 < a then m else m+1 with h',\n  have : 0 < p'_size,\n  { rw h',\n    split_ifs,\n    { apply m_pos },\n    exact nat.succ_pos' },\n  by_cases ∃ p ∈ A.parts, m+1 ≤ finset.card p,\n  { rcases h with ⟨p, hp₁, hp₂⟩,\n    have : p'_size ≤ p.card,\n    { apply le_trans _ hp₂,\n      rw h',\n      split_ifs,\n      { apply nat.le_succ },\n      refl },\n    obtain ⟨p', hp'₁, hp'₂⟩ := exists_smaller_set _ _ this,\n    have hcard : ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = (s \\ p').card,\n    { rw [card_sdiff (hp'₁.trans (A.le hp₁)), ←hs, hp'₂, h'],\n      split_ifs,\n      { rw [nat.mul_sub_right_distrib, one_mul, tsub_add_eq_add_tsub (nat.le_mul_of_pos_left h)] },\n      { rw [nat.mul_sub_right_distrib, one_mul, ←nat.add_sub_assoc],\n        apply nat.le_mul_of_pos_left (‹0 < a ∨ 0 < b›.resolve_left h) } },\n    have : p'.nonempty,\n    { rwa [←card_pos, hp'₂] },\n    obtain ⟨P', hP'₁, hP'₂, hP'₃⟩ :=\n      @ih (s \\ p') (sdiff_ssubset (hp'₁.trans (A.le hp₁)) this)\n        (A.avoid p')\n        (if 0 < a then a-1 else a)\n        (if 0 < a then b else b-1)\n        hcard,\n    refine ⟨P'.extend this.ne_empty sdiff_disjoint (sdiff_sup_cancel $ hp'₁.trans $ A.le hp₁),\n      _,  _, _⟩,\n    { simp only [mem_insert, forall_eq_or_imp, extend_parts, and_iff_left hP'₁, hp'₂, h'],\n      apply ite_eq_or_eq },\n    { conv in (_ ∈ _) {rw ←finset.insert_erase hp₁},\n      simp only [and_imp, mem_insert, forall_eq_or_imp, ne.def, extend_parts],\n      split,\n      { simp only [filter_insert, if_pos hp'₁, bUnion_insert, mem_erase, id.def],\n        rcases eq_or_ne p p',\n        { cases h.symm,\n          rw sdiff_eq_empty_iff_subset.2,\n          { simp },\n          apply subset_union_left },\n        apply le_trans (card_le_of_subset _) (hP'₂ (p \\ p') _),\n        { intros i,\n          simp only [not_exists, mem_bUnion, and_imp, mem_union, mem_filter, mem_sdiff, id.def,\n            not_or_distrib],\n          intros hi₁ hi₂ hi₃,\n          exact ⟨⟨hi₁, hi₂⟩, λ x hx hx', hi₃ _ hx (finset.subset.trans hx' (sdiff_subset _ _))⟩ },\n        { simp only [avoid, sdiff_eq_empty_iff_subset, mem_image, exists_prop, of_erase, mem_erase,\n            bot_eq_empty, ne.def],\n          exact ⟨λ i, h (i.antisymm hp'₁), _, hp₁, rfl⟩ }},\n      intros x hx,\n      apply (card_le_of_subset _).trans (hP'₂ x _),\n      { apply sdiff_subset_sdiff (finset.subset.refl _) (bUnion_subset_bUnion_of_subset_left _ _),\n        refine filter_subset_filter _ (subset_insert _ _) },\n      { simp only [avoid, of_erase, mem_erase, mem_image, bot_eq_empty],\n        refine ⟨(nonempty_of_mem_parts _ (mem_of_mem_erase hx)).ne_empty, _,\n          mem_of_mem_erase hx, _⟩,\n        rw finset.sdiff_eq_self_iff_disjoint,\n        refine disjoint.mono_right hp'₁ _,\n        apply A.disjoint (mem_of_mem_erase hx) hp₁ (ne_of_mem_erase hx) } },\n    simp only [extend_parts, filter_insert, hp'₂, h', nat.one_ne_zero, ite_eq_right_iff,\n      self_eq_add_right],\n    split_ifs,\n    { rw [card_insert_of_not_mem, hP'₃, if_neg h, nat.sub_add_cancel],\n      apply ‹0 < a ∨ 0 < b›.resolve_left h,\n      simp only [mem_filter, hp'₂, h', if_neg h, eq_self_iff_true, and_true],\n      intro t,\n      obtain ⟨i, hi⟩ := ‹p'.nonempty›,\n      apply (mem_sdiff.1 (P'.le t hi)).2 hi },\n    { rw [hP'₃, if_pos],\n      simpa using h } },\n  push_neg at h,\n  have : p'_size ≤ s.card,\n  { rw [←hs, h'],\n    split_ifs,\n    { apply le_add_right (nat.le_mul_of_pos_left ‹0 < a›) },\n    exact le_add_left (nat.le_mul_of_pos_left (‹0 < a ∨ 0 < b›.resolve_left ‹¬0 < a›)) },\n  obtain ⟨s', hs'₁, hs'₂⟩ := exists_smaller_set _ _ this,\n  have hs' : s'.nonempty,\n  { rwa [←card_pos, hs'₂] },\n  have : ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = (s \\ s').card,\n  { rw [card_sdiff ‹s' ⊆ s›, hs'₂, h', ←hs],\n    split_ifs,\n    { rw [nat.mul_sub_right_distrib, one_mul,\n        tsub_add_eq_add_tsub (nat.le_mul_of_pos_left ‹0 < a›)] },\n    rw [nat.mul_sub_right_distrib, one_mul, ←nat.add_sub_assoc],\n    exact nat.le_mul_of_pos_left (‹0 < a ∨ 0 < b›.resolve_left ‹¬0 < a›) },\n  obtain ⟨P', hP'₁, hP'₂, hP'₃⟩ := @ih (s \\ s') (sdiff_ssubset hs'₁ ‹s'.nonempty›) (A.avoid s')\n    (if 0 < a then a-1 else a)\n    (if 0 < a then b else b-1)\n    this,\n  refine ⟨P'.extend hs'.ne_empty sdiff_disjoint (sdiff_sup_cancel hs'₁), _, _, _⟩,\n  { simp only [extend_parts, mem_insert, forall_eq_or_imp, and_iff_left hP'₁, hs'₂, h'],\n    apply ite_eq_or_eq },\n  { intros x hx,\n    refine le_trans (card_le_of_subset (sdiff_subset _ _)) _,\n    rw ←nat.lt_succ_iff,\n    exact h _ hx },\n  rw [extend_parts, filter_insert, hs'₂, h'],\n  simp only [nat.one_ne_zero, ite_eq_right_iff, self_eq_add_right],\n  split_ifs,\n  { rw [card_insert_of_not_mem, hP'₃, if_neg h_1, nat.sub_add_cancel],\n    { apply ‹0 < a ∨ 0 < b›.resolve_left h_1 },\n    simp only [mem_filter, hs'₂, h', if_neg h_1, eq_self_iff_true, and_true],\n    intro t,\n    obtain ⟨i, hi⟩ := ‹s'.nonempty›,\n    exact (mem_sdiff.1 (P'.le t hi)).2 hi },\n  { rw [hP'₃, if_pos],\n    simpa using h_1 }\nend\n\n/-! ### Equitabilise -/\n\nnamespace finpartition\n\n/-- Given a partition `Q` of `s`, as well as a proof that `a*m + b*(m+1) = s.card`, build a new\npartition `P` of `s` where each part has size `m` or `m+1`, every part of `Q` is the union of\nparts of `P` plus at most `m` extra elements, there are `b` parts of size `m+1` and provided\n`m > 0`, there are `a` parts of size `m` and hence `a+b` parts in total.\nThe `m > 0` condition is required since there may be zero or one parts of size `0`, while `a` could\nbe arbitrary. -/\nnoncomputable def equitabilise (Q : finpartition s) {m a b : ℕ} (h : a * m + b * (m + 1) = s.card) :\n  finpartition s :=\n(equitabilise_aux' h Q).some\n\nlemma card_eq_of_mem_parts_equitabilise {Q : finpartition s} {m a b : ℕ}\n  (h : a*m + b*(m+1) = s.card) {u : finset α} (hu : u ∈ (Q.equitabilise h).parts) :\n  u.card = m ∨ u.card = m + 1 :=\n(equitabilise_aux' h Q).some_spec.1 _ hu\n\nlemma equitabilise.is_equipartition (Q : finpartition s) {m a b : ℕ}\n  (h : a*m + b*(m+1) = s.card) :\n  (Q.equitabilise h).is_equipartition :=\nset.equitable_on_iff_exists_eq_eq_add_one.2 ⟨m, λ u hu, card_eq_of_mem_parts_equitabilise h hu⟩\n\nlemma card_filter_equitabilise_big (Q : finpartition s) {m a b : ℕ}\n  (h : a*m + b*(m+1) = s.card) :\n  ((Q.equitabilise h).parts.filter (λ u : finset α, u.card = m + 1)).card = b :=\n(equitabilise_aux' h Q).some_spec.2.2\n\nlemma card_filter_equitabilise_small (Q : finpartition s) {m a b : ℕ} (hm : 0 < m)\n  (h : a*m + b*(m+1) = s.card) :\n  ((Q.equitabilise h).parts.filter (λ u : finset α, u.card = m)).card = a :=\nbegin\n  refine (mul_eq_mul_right_iff.1 ((add_left_inj (b * (m + 1))).1 _)).resolve_right hm.ne',\n  rw [h, ←(Q.equitabilise h).sum_card_parts],\n  have hunion : (Q.equitabilise h).parts = (Q.equitabilise h).parts.filter (λ u, u.card = m) ∪\n    (Q.equitabilise h).parts.filter (λ u, u.card = m + 1),\n  { rw [←filter_or, filter_true_of_mem],\n    exact λ x hx, card_eq_of_mem_parts_equitabilise h hx },\n  nth_rewrite 1 hunion,\n  rw [sum_union, sum_const_nat (λ x hx, (mem_filter.1 hx).2),\n    sum_const_nat (λ x hx, (mem_filter.1 hx).2), Q.card_filter_equitabilise_big],\n  refine λ x hx, nat.succ_ne_self m _,\n  rw [inf_eq_inter, mem_inter, mem_filter, mem_filter] at hx,\n  rw [nat.succ_eq_add_one, ←hx.2.2, hx.1.2],\nend\n\nlemma equitabilise.parts_card {Q : finpartition s} {m a b : ℕ} (hm : 0 < m)\n  (h : a * m + b * (m + 1) = s.card) :\n  (Q.equitabilise h).parts.card = a + b :=\nbegin\n  have hunion : (Q.equitabilise h).parts = (Q.equitabilise h).parts.filter (λ u, u.card = m) ∪\n    (Q.equitabilise h).parts.filter (λ u, u.card = m + 1),\n  { rw [←filter_or, filter_true_of_mem],\n    exact λ x hx, card_eq_of_mem_parts_equitabilise h hx },\n  rw [hunion, card_union_eq, Q.card_filter_equitabilise_small hm, Q.card_filter_equitabilise_big],\n  refine λ x hx, nat.succ_ne_self m _,\n  rw [inf_eq_inter, mem_inter, mem_filter, mem_filter] at hx,\n  rw [nat.succ_eq_add_one, ←hx.2.2, hx.1.2],\nend\n\nlemma almost_in_atoms_of_mem_parts_equitabilise {Q : finpartition s} {m a b : ℕ}\n  (h : a * m + b * (m + 1) = s.card) {u : finset α} (hu : u ∈ Q.parts) :\n  (u \\ ((Q.equitabilise h).parts.filter $ λ x, x ⊆ u).bUnion id).card ≤ m :=\nbegin\n  refine (card_le_of_subset _).trans ((classical.some_spec (equitabilise_aux' h Q)).2.1 u hu),\n  intros x,\n  simp only [not_exists, mem_bUnion, and_imp, mem_filter, mem_sdiff, id.def, ne.def],\n  refine λ hxu hx, ⟨hxu, λ a ha hau, _⟩,\n  obtain rfl | hanemp := eq_or_ne a ∅,\n  { exact not_mem_empty _ },\n  { apply hx _ ha hau },\nend\n\nend finpartition\n\nend\n\n/-! ### Atomise -/\n\nopen finpartition\n\nsection atomise\nvariables [decidable_eq α] {s : finset α}\n\nlemma union_of_atoms_aux {s : finset α} {Q : finset (finset α)} {A : finset α}\n  (hA : A ∈ Q) (hs : A ⊆ s) (i : α) :\n  (∃ (B ∈ (atomise s Q).parts), B ⊆ A ∧ i ∈ B) ↔ i ∈ A :=\nbegin\n  split,\n  { rintro ⟨B, hB₁, hB₂, hB₃⟩,\n    exact hB₂ hB₃ },\n  intro hi,\n  obtain ⟨B, hB₁, hB₂⟩ := (atomise s Q).exists_mem (hs hi),\n  refine ⟨B, hB₁, λ j hj, _, hB₂⟩,\n  obtain ⟨P, hP, rfl⟩ := (mem_atomise.1 hB₁).2,\n  simp only [mem_filter] at hB₂ hj,\n  rwa [←hj.2 _ hA, hB₂.2 _ hA]\nend\n\nopen_locale classical\n\nlemma union_of_atoms' {s : finset α} {Q : finset (finset α)} (A : finset α)\n  (hx : A ∈ Q) (hs : A ⊆ s) :\n  ((atomise s Q).parts.filter (λ B, B ⊆ A ∧ B.nonempty)).bUnion id = A :=\nbegin\n  ext x,\n  simp only [mem_bUnion, exists_prop, mem_filter, id.def, and_assoc],\n  rw ←union_of_atoms_aux hx hs,\n  simp only [exists_prop, finset.nonempty],\n  tauto,\nend\n\nlemma partial_atomise {s : finset α} {Q : finset (finset α)} (A : finset α) (hA : A ∈ Q) :\n  ((atomise s Q).parts.filter (λ B, B ⊆ A ∧ B.nonempty)).card ≤ 2^(Q.card - 1) :=\nbegin\n  suffices h :\n    (atomise s Q).parts.filter (λ B, B ⊆ A ∧ B.nonempty) ⊆\n      (Q.erase A).powerset.image (λ P, s.filter (λ i, ∀ x ∈ Q, x ∈ insert A P ↔ i ∈ x)),\n  { apply (card_le_of_subset h).trans (card_image_le.trans _),\n    rw [card_powerset, card_erase_of_mem hA, nat.pred_eq_sub_one] },\n  rw subset_iff,\n  simp only [mem_erase, mem_sdiff, mem_powerset, mem_image, exists_prop, mem_filter, and_assoc,\n    finset.nonempty, exists_imp_distrib, and_imp, mem_atomise, forall_apply_eq_imp_iff₂],\n  rintro P' i hi P PQ rfl hy₂ j hj,\n  refine ⟨P.erase A, erase_subset_erase _ PQ, _⟩,\n  have : A ∈ P,\n  { rw mem_filter at hi,\n    rw hi.2 _ hA,\n    apply hy₂ (mem_filter.2 hi) },\n  simp only [insert_erase this, filter_congr_decidable],\nend\n\nend atomise\n\n/-! ### Dummy -/\n\n/-- Arbitrary equipartition into `t` parts -/\nlemma dummy_equipartition [decidable_eq α] (s : finset α) {t : ℕ} (ht : 0 < t) (hs : t ≤ s.card) :\n  ∃ (P : finpartition s), P.is_equipartition ∧ P.parts.card = t :=\nbegin\n  have : (t - s.card % t) * (s.card / t) + (s.card % t) * (s.card / t + 1) = s.card,\n  { rw [nat.mul_sub_right_distrib, mul_add, ←add_assoc, nat.sub_add_cancel, mul_one, add_comm,\n      nat.mod_add_div],\n    exact nat.mul_le_mul_right _ ((nat.mod_lt _ ht).le) },\n  refine ⟨(finpartition.indiscrete (finset.card_pos.1 $ ht.trans_le hs).ne_empty).equitabilise this,\n    equitabilise.is_equipartition _ _, _⟩,\n  rw [equitabilise.parts_card (nat.div_pos hs ht), nat.sub_add_cancel (nat.mod_lt _ ht).le],\nend\n", "meta": {"author": "b-mehta", "repo": "regularity-lemma", "sha": "cf26082b0c88fa54276e6fdc3338c15e607c52c6", "save_path": "github-repos/lean/b-mehta-regularity-lemma", "path": "github-repos/lean/b-mehta-regularity-lemma/regularity-lemma-cf26082b0c88fa54276e6fdc3338c15e607c52c6/src/finpartitions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.47050191790256585}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n\n! This file was ported from Lean 3 source module linear_algebra.affine_space.affine_equiv\n! leanprover-community/mathlib commit bd1fc183335ea95a9519a1630bcf901fe9326d83\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.LinearAlgebra.AffineSpace.AffineMap\nimport Mathlib.LinearAlgebra.GeneralLinearGroup\nimport Mathlib.Algebra.Invertible\n\n/-!\n# Affine equivalences\n\nIn this file we define `AffineEquiv k P₁ P₂` (notation: `P₁ ≃ᵃ[k] P₂`) to be the type of affine\nequivalences between `P₁` and `P₂`, i.e., equivalences such that both forward and inverse maps are\naffine maps.\n\nWe define the following equivalences:\n\n* `AffineEquiv.refl k P`: the identity map as an `AffineEquiv`;\n\n* `e.symm`: the inverse map of an `AffineEquiv` as an `AffineEquiv`;\n\n* `e.trans e'`: composition of two `AffineEquiv`s; note that the order follows `mathlib`'s\n  `CategoryTheory` convention (apply `e`, then `e'`), not the convention used in function\n  composition and compositions of bundled morphisms.\n\nWe equip `AffineEquiv k P P` with a `Group` structure with multiplication corresponding to\ncomposition in `AffineEquiv.group`.\n\n## Tags\n\naffine space, affine equivalence\n-/\n\nopen Function Set\n\nopen Affine\n\n-- Porting note: this is needed because of lean4#2074\nattribute [-instance] Ring.toNonAssocRing\n\n/-- An affine equivalence is an equivalence between affine spaces such that both forward\nand inverse maps are affine.\n\nWe define it using an `Equiv` for the map and a `LinearEquiv` for the linear part in order\nto allow affine equivalences with good definitional equalities. -/\n--@[nolint has_nonempty_instance]\nstructure AffineEquiv (k P₁ P₂ : Type _) {V₁ V₂ : Type _} [Ring k] [AddCommGroup V₁] [Module k V₁]\n  [AddTorsor V₁ P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] extends P₁ ≃ P₂ where\n  linear : V₁ ≃ₗ[k] V₂\n  map_vadd' : ∀ (p : P₁) (v : V₁), toEquiv (v +ᵥ p) = linear v +ᵥ toEquiv p\n#align affine_equiv AffineEquiv\n\nnotation:25 P₁ \" ≃ᵃ[\" k:25 \"] \" P₂:0 => AffineEquiv k P₁ P₂\n\nvariable {k P₁ P₂ P₃ P₄ V₁ V₂ V₃ V₄ : Type _} [Ring k] [AddCommGroup V₁] [Module k V₁]\n  [AddTorsor V₁ P₁] [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂] [AddCommGroup V₃]\n  [Module k V₃] [AddTorsor V₃ P₃] [AddCommGroup V₄] [Module k V₄] [AddTorsor V₄ P₄]\n\nnamespace AffineEquiv\n\n/-- Reinterpret an `AffineEquiv` as an `AffineMap`. -/\n@[coe]\ndef toAffineMap (e : P₁ ≃ᵃ[k] P₂) : P₁ →ᵃ[k] P₂ :=\n  { e with }\n#align affine_equiv.to_affine_map AffineEquiv.toAffineMap\n\n@[simp]\ntheorem toAffineMap_mk (f : P₁ ≃ P₂) (f' : V₁ ≃ₗ[k] V₂) (h) :\n    toAffineMap (mk f f' h) = ⟨f, f', h⟩ :=\n  rfl\n#align affine_equiv.to_affine_map_mk AffineEquiv.toAffineMap_mk\n\n@[simp]\ntheorem linear_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : e.toAffineMap.linear = e.linear :=\n  rfl\n#align affine_equiv.linear_to_affine_map AffineEquiv.linear_toAffineMap\n\ntheorem toAffineMap_injective : Injective (toAffineMap : (P₁ ≃ᵃ[k] P₂) → P₁ →ᵃ[k] P₂) := by\n  rintro ⟨e, el, h⟩ ⟨e', el', h'⟩ H\n  -- porting note: added `()`s and `AffineMap.mk.injEq`\n  simp only [(toAffineMap_mk), (AffineMap.mk.injEq), Equiv.coe_inj,\n    LinearEquiv.toLinearMap_inj] at H\n  congr\n  exacts [H.1, H.2]\n#align affine_equiv.to_affine_map_injective AffineEquiv.toAffineMap_injective\n\n@[simp]\ntheorem toAffineMap_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.toAffineMap = e'.toAffineMap ↔ e = e' :=\n  toAffineMap_injective.eq_iff\n#align affine_equiv.to_affine_map_inj AffineEquiv.toAffineMap_inj\n\ninstance equivLike : EquivLike (P₁ ≃ᵃ[k] P₂) P₁ P₂ where\n  coe f := f.toFun\n  inv f := f.invFun\n  left_inv f := f.left_inv\n  right_inv f := f.right_inv\n  coe_injective' _ _ h _ := toAffineMap_injective (FunLike.coe_injective h)\n#align affine_equiv.equiv_like AffineEquiv.equivLike\n\ninstance : CoeFun (P₁ ≃ᵃ[k] P₂) fun _ => P₁ → P₂ :=\n  FunLike.hasCoeToFun\n\n@[nolint dangerousInstance] -- Porting note: this was not a problem in Lean 3\ninstance : Coe (P₁ ≃ᵃ[k] P₂) (P₁ ≃ P₂) :=\n  ⟨AffineEquiv.toEquiv⟩\n\n@[simp]\ntheorem map_vadd (e : P₁ ≃ᵃ[k] P₂) (p : P₁) (v : V₁) : e (v +ᵥ p) = e.linear v +ᵥ e p :=\n  e.map_vadd' p v\n#align affine_equiv.map_vadd AffineEquiv.map_vadd\n\n@[simp]\ntheorem coe_toEquiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.toEquiv = e :=\n  rfl\n#align affine_equiv.coe_to_equiv AffineEquiv.coe_toEquiv\n\ninstance : Coe (P₁ ≃ᵃ[k] P₂) (P₁ →ᵃ[k] P₂) :=\n  ⟨toAffineMap⟩\n\n@[simp]\ntheorem coe_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : (e.toAffineMap : P₁ → P₂) = (e : P₁ → P₂) :=\n  rfl\n#align affine_equiv.coe_to_affine_map AffineEquiv.coe_toAffineMap\n\n@[norm_cast, simp]\ntheorem coe_coe (e : P₁ ≃ᵃ[k] P₂) : ((e : P₁ →ᵃ[k] P₂) : P₁ → P₂) = e :=\n  rfl\n#align affine_equiv.coe_coe AffineEquiv.coe_coe\n\n@[simp]\ntheorem coe_linear (e : P₁ ≃ᵃ[k] P₂) : (e : P₁ →ᵃ[k] P₂).linear = e.linear :=\n  rfl\n#align affine_equiv.coe_linear AffineEquiv.coe_linear\n\n@[ext]\ntheorem ext {e e' : P₁ ≃ᵃ[k] P₂} (h : ∀ x, e x = e' x) : e = e' :=\n  FunLike.ext _ _ h\n#align affine_equiv.ext AffineEquiv.ext\n\ntheorem coeFn_injective : @Injective (P₁ ≃ᵃ[k] P₂) (P₁ → P₂) (⇑) :=\n  FunLike.coe_injective\n#align affine_equiv.coe_fn_injective AffineEquiv.coeFn_injective\n\n@[norm_cast]\n-- Porting note: removed `simp`: proof is `simp only [FunLike.coe_fn_eq]`\ntheorem coeFn_inj {e e' : P₁ ≃ᵃ[k] P₂} : (e : P₁ → P₂) = e' ↔ e = e' :=\n  coeFn_injective.eq_iff\n#align affine_equiv.coe_fn_inj AffineEquiv.coeFn_inj\n\ntheorem toEquiv_injective : Injective (toEquiv : (P₁ ≃ᵃ[k] P₂) → P₁ ≃ P₂) := fun _ _ H =>\n  ext <| Equiv.ext_iff.1 H\n#align affine_equiv.to_equiv_injective AffineEquiv.toEquiv_injective\n\n@[simp]\n\n\n@[simp]\ntheorem coe_mk (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (h) : ((⟨e, e', h⟩ : P₁ ≃ᵃ[k] P₂) : P₁ → P₂) = e :=\n  rfl\n#align affine_equiv.coe_mk AffineEquiv.coe_mk\n\n/-- Construct an affine equivalence by verifying the relation between the map and its linear part at\none base point. Namely, this function takes a map `e : P₁ → P₂`, a linear equivalence\n`e' : V₁ ≃ₗ[k] V₂`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/\ndef mk' (e : P₁ → P₂) (e' : V₁ ≃ₗ[k] V₂) (p : P₁) (h : ∀ p' : P₁, e p' = e' (p' -ᵥ p) +ᵥ e p) :\n    P₁ ≃ᵃ[k] P₂ where\n  toFun := e\n  invFun := fun q' : P₂ => e'.symm (q' -ᵥ e p) +ᵥ p\n  -- Porting note: `simp` needs `()`\n  left_inv p' := by simp [h p', (vadd_vsub), (vsub_vadd)]\n  -- Porting note: `simp` needs `()`\n  right_inv q' := by simp [h (e'.symm (q' -ᵥ e p) +ᵥ p), (vadd_vsub), (vsub_vadd)]\n  linear := e'\n  -- Porting note: `simp` needs `()`\n  map_vadd' p' v := by simp [h p', h (v +ᵥ p'), (vadd_vsub_assoc), (vadd_vadd)]\n#align affine_equiv.mk' AffineEquiv.mk'\n\n@[simp]\ntheorem coe_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : ⇑(mk' e e' p h) = e :=\n  rfl\n#align affine_equiv.coe_mk' AffineEquiv.coe_mk'\n\n@[simp]\ntheorem linear_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : (mk' e e' p h).linear = e' :=\n  rfl\n#align affine_equiv.linear_mk' AffineEquiv.linear_mk'\n\n/-- Inverse of an affine equivalence as an affine equivalence. -/\n@[symm]\ndef symm (e : P₁ ≃ᵃ[k] P₂) : P₂ ≃ᵃ[k] P₁ where\n  toEquiv := e.toEquiv.symm\n  linear := e.linear.symm\n  map_vadd' p v :=\n    e.toEquiv.symm.apply_eq_iff_eq_symm_apply.2 <| by\n      rw [Equiv.symm_symm, e.map_vadd' ((Equiv.symm e.toEquiv) p) ((LinearEquiv.symm e.linear) v),\n        LinearEquiv.apply_symm_apply, Equiv.apply_symm_apply]\n#align affine_equiv.symm AffineEquiv.symm\n\n@[simp]\ntheorem symm_toEquiv (e : P₁ ≃ᵃ[k] P₂) : e.toEquiv.symm = e.symm.toEquiv :=\n  rfl\n#align affine_equiv.symm_to_equiv AffineEquiv.symm_toEquiv\n\n@[simp]\ntheorem symm_linear (e : P₁ ≃ᵃ[k] P₂) : e.linear.symm = e.symm.linear :=\n  rfl\n#align affine_equiv.symm_linear AffineEquiv.symm_linear\n\n/-- See Note [custom simps projection] -/\ndef Simps.apply (e : P₁ ≃ᵃ[k] P₂) : P₁ → P₂ :=\n  e\n#align affine_equiv.simps.apply AffineEquiv.Simps.apply\n\n/-- See Note [custom simps projection] -/\ndef Simps.symmApply (e : P₁ ≃ᵃ[k] P₂) : P₂ → P₁ :=\n  e.symm\n#align affine_equiv.simps.symm_apply AffineEquiv.Simps.symmApply\n\ninitialize_simps_projections AffineEquiv (toEquiv_toFun → apply, toEquiv_invFun → symmApply,\n  linear → linear, as_prefix linear, -toEquiv)\n\nprotected theorem bijective (e : P₁ ≃ᵃ[k] P₂) : Bijective e :=\n  e.toEquiv.bijective\n#align affine_equiv.bijective AffineEquiv.bijective\n\nprotected theorem surjective (e : P₁ ≃ᵃ[k] P₂) : Surjective e :=\n  e.toEquiv.surjective\n#align affine_equiv.surjective AffineEquiv.surjective\n\nprotected theorem injective (e : P₁ ≃ᵃ[k] P₂) : Injective e :=\n  e.toEquiv.injective\n#align affine_equiv.injective AffineEquiv.injective\n\n/-- Bijective affine maps are affine isomorphisms. -/\n@[simps! linear apply]\nnoncomputable def ofBijective {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Bijective φ) : P₁ ≃ᵃ[k] P₂ :=\n  { Equiv.ofBijective _ hφ with\n    linear := LinearEquiv.ofBijective φ.linear (φ.linear_bijective_iff.mpr hφ)\n    map_vadd' := φ.map_vadd }\n#align affine_equiv.of_bijective AffineEquiv.ofBijective\n\ntheorem ofBijective.symm_eq {φ : P₁ →ᵃ[k] P₂} (hφ : Function.Bijective φ) :\n    (ofBijective hφ).symm.toEquiv = (Equiv.ofBijective _ hφ).symm :=\n  rfl\n#align affine_equiv.of_bijective.symm_eq AffineEquiv.ofBijective.symm_eq\n\n@[simp]\ntheorem range_eq (e : P₁ ≃ᵃ[k] P₂) : range e = univ :=\n  e.surjective.range_eq\n#align affine_equiv.range_eq AffineEquiv.range_eq\n\n@[simp]\ntheorem apply_symm_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₂) : e (e.symm p) = p :=\n  e.toEquiv.apply_symm_apply p\n#align affine_equiv.apply_symm_apply AffineEquiv.apply_symm_apply\n\n@[simp]\ntheorem symm_apply_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₁) : e.symm (e p) = p :=\n  e.toEquiv.symm_apply_apply p\n#align affine_equiv.symm_apply_apply AffineEquiv.symm_apply_apply\n\ntheorem apply_eq_iff_eq_symm_apply (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂} : e p₁ = p₂ ↔ p₁ = e.symm p₂ :=\n  e.toEquiv.apply_eq_iff_eq_symm_apply\n#align affine_equiv.apply_eq_iff_eq_symm_apply AffineEquiv.apply_eq_iff_eq_symm_apply\n\n-- Porting note: removed `simp`, proof is `by simp only [@EmbeddingLike.apply_eq_iff_eq]`\ntheorem apply_eq_iff_eq (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂ : P₁} : e p₁ = e p₂ ↔ p₁ = p₂ :=\n  e.toEquiv.apply_eq_iff_eq\n#align affine_equiv.apply_eq_iff_eq AffineEquiv.apply_eq_iff_eq\n\n@[simp]\ntheorem image_symm (f : P₁ ≃ᵃ[k] P₂) (s : Set P₂) : f.symm '' s = f ⁻¹' s :=\n  f.symm.toEquiv.image_eq_preimage _\n#align affine_equiv.image_symm AffineEquiv.image_symm\n\n@[simp]\ntheorem preimage_symm (f : P₁ ≃ᵃ[k] P₂) (s : Set P₁) : f.symm ⁻¹' s = f '' s :=\n  (f.symm.image_symm _).symm\n#align affine_equiv.preimage_symm AffineEquiv.preimage_symm\n\nvariable (k P₁)\n\n/-- Identity map as an `AffineEquiv`. -/\n-- @[refl] -- Porting note: removed attribute\ndef refl : P₁ ≃ᵃ[k] P₁ where\n  toEquiv := Equiv.refl P₁\n  linear := LinearEquiv.refl k V₁\n  map_vadd' _ _ := rfl\n#align affine_equiv.refl AffineEquiv.refl\n\n@[simp]\ntheorem coe_refl : ⇑(refl k P₁) = id :=\n  rfl\n#align affine_equiv.coe_refl AffineEquiv.coe_refl\n\n@[simp]\ntheorem coe_refl_to_affineMap : ↑(refl k P₁) = AffineMap.id k P₁ :=\n  rfl\n#align affine_equiv.coe_refl_to_affine_map AffineEquiv.coe_refl_to_affineMap\n\n@[simp]\ntheorem refl_apply (x : P₁) : refl k P₁ x = x :=\n  rfl\n#align affine_equiv.refl_apply AffineEquiv.refl_apply\n\n@[simp]\ntheorem toEquiv_refl : (refl k P₁).toEquiv = Equiv.refl P₁ :=\n  rfl\n#align affine_equiv.to_equiv_refl AffineEquiv.toEquiv_refl\n\n@[simp]\ntheorem linear_refl : (refl k P₁).linear = LinearEquiv.refl k V₁ :=\n  rfl\n#align affine_equiv.linear_refl AffineEquiv.linear_refl\n\n@[simp]\ntheorem symm_refl : (refl k P₁).symm = refl k P₁ :=\n  rfl\n#align affine_equiv.symm_refl AffineEquiv.symm_refl\n\nvariable {k P₁}\n\n/-- Composition of two `AffineEquiv`alences, applied left to right. -/\n@[trans]\ndef trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : P₁ ≃ᵃ[k] P₃ where\n  toEquiv := e.toEquiv.trans e'.toEquiv\n  linear := e.linear.trans e'.linear\n  map_vadd' p v := by\n    -- porting note: added `()`\n    simp only [LinearEquiv.trans_apply, (coe_toEquiv), (· ∘ ·), Equiv.coe_trans, (map_vadd)]\n#align affine_equiv.trans AffineEquiv.trans\n\n@[simp]\ntheorem coe_trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : ⇑(e.trans e') = e' ∘ e :=\n  rfl\n#align affine_equiv.coe_trans AffineEquiv.coe_trans\n\n@[simp]\ntheorem coe_trans_to_affineMap (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) :\n    (e.trans e' : P₁ →ᵃ[k] P₃) = (e' : P₂ →ᵃ[k] P₃).comp e :=\n  rfl\n#align affine_equiv.coe_trans_to_affine_map AffineEquiv.coe_trans_to_affineMap\n\n@[simp]\ntheorem trans_apply (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) (p : P₁) : e.trans e' p = e' (e p) :=\n  rfl\n#align affine_equiv.trans_apply AffineEquiv.trans_apply\n\ntheorem trans_assoc (e₁ : P₁ ≃ᵃ[k] P₂) (e₂ : P₂ ≃ᵃ[k] P₃) (e₃ : P₃ ≃ᵃ[k] P₄) :\n    (e₁.trans e₂).trans e₃ = e₁.trans (e₂.trans e₃) :=\n  ext fun _ => rfl\n#align affine_equiv.trans_assoc AffineEquiv.trans_assoc\n\n@[simp]\ntheorem trans_refl (e : P₁ ≃ᵃ[k] P₂) : e.trans (refl k P₂) = e :=\n  ext fun _ => rfl\n#align affine_equiv.trans_refl AffineEquiv.trans_refl\n\n@[simp]\ntheorem refl_trans (e : P₁ ≃ᵃ[k] P₂) : (refl k P₁).trans e = e :=\n  ext fun _ => rfl\n#align affine_equiv.refl_trans AffineEquiv.refl_trans\n\n@[simp]\ntheorem self_trans_symm (e : P₁ ≃ᵃ[k] P₂) : e.trans e.symm = refl k P₁ :=\n  ext e.symm_apply_apply\n#align affine_equiv.self_trans_symm AffineEquiv.self_trans_symm\n\n@[simp]\ntheorem symm_trans_self (e : P₁ ≃ᵃ[k] P₂) : e.symm.trans e = refl k P₂ :=\n  ext e.apply_symm_apply\n#align affine_equiv.symm_trans_self AffineEquiv.symm_trans_self\n\n@[simp]\ntheorem apply_lineMap (e : P₁ ≃ᵃ[k] P₂) (a b : P₁) (c : k) :\n    e (AffineMap.lineMap a b c) = AffineMap.lineMap (e a) (e b) c :=\n  e.toAffineMap.apply_lineMap a b c\n#align affine_equiv.apply_line_map AffineEquiv.apply_lineMap\n\ninstance group : Group (P₁ ≃ᵃ[k] P₁) where\n  one := refl k P₁\n  mul e e' := e'.trans e\n  inv := symm\n  mul_assoc e₁ e₂ e₃ := trans_assoc _ _ _\n  one_mul := trans_refl\n  mul_one := refl_trans\n  mul_left_inv := self_trans_symm\n#align affine_equiv.group AffineEquiv.group\n\ntheorem one_def : (1 : P₁ ≃ᵃ[k] P₁) = refl k P₁ :=\n  rfl\n#align affine_equiv.one_def AffineEquiv.one_def\n\n@[simp]\ntheorem coe_one : ⇑(1 : P₁ ≃ᵃ[k] P₁) = id :=\n  rfl\n#align affine_equiv.coe_one AffineEquiv.coe_one\n\ntheorem mul_def (e e' : P₁ ≃ᵃ[k] P₁) : e * e' = e'.trans e :=\n  rfl\n#align affine_equiv.mul_def AffineEquiv.mul_def\n\n@[simp]\ntheorem coe_mul (e e' : P₁ ≃ᵃ[k] P₁) : ⇑(e * e') = e ∘ e' :=\n  rfl\n#align affine_equiv.coe_mul AffineEquiv.coe_mul\n\ntheorem inv_def (e : P₁ ≃ᵃ[k] P₁) : e⁻¹ = e.symm :=\n  rfl\n#align affine_equiv.inv_def AffineEquiv.inv_def\n\n/-- `AffineEquiv.linear` on automorphisms is a `MonoidHom`. -/\n@[simps]\ndef linearHom : (P₁ ≃ᵃ[k] P₁) →* V₁ ≃ₗ[k] V₁ where\n  toFun := linear\n  map_one' := rfl\n  map_mul' _ _ := rfl\n#align affine_equiv.linear_hom AffineEquiv.linearHom\n\n/-- The group of `AffineEquiv`s are equivalent to the group of units of `AffineMap`.\n\nThis is the affine version of `LinearMap.GeneralLinearGroup.generalLinearEquiv`. -/\n@[simps]\ndef equivUnitsAffineMap : (P₁ ≃ᵃ[k] P₁) ≃* (P₁ →ᵃ[k] P₁)ˣ where\n  toFun e :=\n    { val := e, inv := e.symm,\n      val_inv := congr_arg toAffineMap e.symm_trans_self\n      inv_val := congr_arg toAffineMap e.self_trans_symm }\n  invFun u :=\n    { toFun := (u : P₁ →ᵃ[k] P₁)\n      invFun := (↑u⁻¹ : P₁ →ᵃ[k] P₁)\n      left_inv := AffineMap.congr_fun u.inv_mul\n      right_inv := AffineMap.congr_fun u.mul_inv\n      linear :=\n        LinearMap.GeneralLinearGroup.generalLinearEquiv _ _ <| Units.map AffineMap.linearHom u\n      map_vadd' := fun _ _ => (u : P₁ →ᵃ[k] P₁).map_vadd _ _ }\n  left_inv _ := AffineEquiv.ext fun _ => rfl\n  right_inv _ := Units.ext <| AffineMap.ext fun _ => rfl\n  map_mul' _ _ := rfl\n#align affine_equiv.equiv_units_affine_map AffineEquiv.equivUnitsAffineMap\n\nvariable (k)\n\n/-- The map `v ↦ v +ᵥ b` as an affine equivalence between a module `V` and an affine space `P` with\ntangent space `V`. -/\n@[simps! linear apply]\ndef vaddConst (b : P₁) : V₁ ≃ᵃ[k] P₁ where\n  toEquiv := Equiv.vaddConst b\n  linear := LinearEquiv.refl _ _\n  map_vadd' _ _ := add_vadd _ _ _\n#align affine_equiv.vadd_const AffineEquiv.vaddConst\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P₁) : P₁ ≃ᵃ[k] V₁ where\n  toEquiv := Equiv.constVSub p\n  linear := LinearEquiv.neg k\n  -- porting note: added `coe_constVSub` and `()`s\n  map_vadd' p' v := by simp [(Equiv.coe_constVSub), (vsub_vadd_eq_vsub_sub), neg_add_eq_sub]\n#align affine_equiv.const_vsub AffineEquiv.constVSub\n\n@[simp]\ntheorem coe_constVSub (p : P₁) : ⇑(constVSub k p) = (· -ᵥ ·) p :=\n  rfl\n#align affine_equiv.coe_const_vsub AffineEquiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P₁) : ⇑(constVSub k p).symm = fun v : V₁ => -v +ᵥ p :=\n  rfl\n#align affine_equiv.coe_const_vsub_symm AffineEquiv.coe_constVSub_symm\n\nvariable (P₁)\n\n/-- The map `p ↦ v +ᵥ p` as an affine automorphism of an affine space.\n\nNote that there is no need for an `AffineMap.constVAdd` as it is always an equivalence.\nThis is roughly to `DistribMulAction.toLinearEquiv` as `+ᵥ` is to `•`. -/\n@[simps! apply linear]\ndef constVAdd (v : V₁) : P₁ ≃ᵃ[k] P₁ where\n  toEquiv := Equiv.constVAdd P₁ v\n  linear := LinearEquiv.refl _ _\n  map_vadd' _ _ := vadd_comm _ _ _\n#align affine_equiv.const_vadd AffineEquiv.constVAdd\n\n@[simp]\ntheorem constVAdd_zero : constVAdd k P₁ 0 = AffineEquiv.refl _ _ :=\n  ext <| zero_vadd _\n#align affine_equiv.const_vadd_zero AffineEquiv.constVAdd_zero\n\n@[simp]\ntheorem constVAdd_add (v w : V₁) :\n    constVAdd k P₁ (v + w) = (constVAdd k P₁ w).trans (constVAdd k P₁ v) :=\n  ext <| add_vadd _ _\n#align affine_equiv.const_vadd_add AffineEquiv.constVAdd_add\n\n@[simp]\ntheorem constVAdd_symm (v : V₁) : (constVAdd k P₁ v).symm = constVAdd k P₁ (-v) :=\n  ext fun _ => rfl\n#align affine_equiv.const_vadd_symm AffineEquiv.constVAdd_symm\n\n/-- A more bundled version of `AffineEquiv.constVAdd`. -/\n@[simps]\ndef constVAddHom : Multiplicative V₁ →* P₁ ≃ᵃ[k] P₁ where\n  toFun v := constVAdd k P₁ (Multiplicative.toAdd v)\n  map_one' := constVAdd_zero _ _\n  map_mul' := constVAdd_add _ P₁\n#align affine_equiv.const_vadd_hom AffineEquiv.constVAddHom\n\ntheorem constVAdd_nsmul (n : ℕ) (v : V₁) : constVAdd k P₁ (n • v) = constVAdd k P₁ v ^ n :=\n  (constVAddHom k P₁).map_pow _ _\n#align affine_equiv.const_vadd_nsmul AffineEquiv.constVAdd_nsmul\n\ntheorem constVAdd_zsmul (z : ℤ) (v : V₁) : constVAdd k P₁ (z • v) = constVAdd k P₁ v ^ z :=\n  (constVAddHom k P₁).map_zpow _ _\n#align affine_equiv.const_vadd_zsmul AffineEquiv.constVAdd_zsmul\n\nsection Homothety\n\nvariable {R V P : Type _} [CommRing R] [AddCommGroup V] [Module R V] [AffineSpace V P]\n\n/-- Fixing a point in affine space, homothety about this point gives a group homomorphism from (the\ncentre of) the units of the scalars into the group of affine equivalences. -/\ndef homothetyUnitsMulHom (p : P) : Rˣ →* P ≃ᵃ[R] P :=\n  equivUnitsAffineMap.symm.toMonoidHom.comp <| Units.map (AffineMap.homothetyHom p)\n#align affine_equiv.homothety_units_mul_hom AffineEquiv.homothetyUnitsMulHom\n\n@[simp]\ntheorem coe_homothetyUnitsMulHom_apply (p : P) (t : Rˣ) :\n    (homothetyUnitsMulHom p t : P → P) = AffineMap.homothety p (t : R) :=\n  rfl\n#align affine_equiv.coe_homothety_units_mul_hom_apply AffineEquiv.coe_homothetyUnitsMulHom_apply\n\n@[simp]\ntheorem coe_homothetyUnitsMulHom_apply_symm (p : P) (t : Rˣ) :\n    ((homothetyUnitsMulHom p t).symm : P → P) = AffineMap.homothety p (↑t⁻¹ : R) :=\n  rfl\n#align affine_equiv.coe_homothety_units_mul_hom_apply_symm AffineEquiv.coe_homothetyUnitsMulHom_apply_symm\n\n@[simp]\ntheorem coe_homothetyUnitsMulHom_eq_homothetyHom_coe (p : P) :\n    ((↑) : (P ≃ᵃ[R] P) → P →ᵃ[R] P) ∘ homothetyUnitsMulHom p =\n      AffineMap.homothetyHom p ∘ ((↑) : Rˣ → R) :=\n  funext fun _ => rfl\n#align affine_equiv.coe_homothety_units_mul_hom_eq_homothety_hom_coe AffineEquiv.coe_homothetyUnitsMulHom_eq_homothetyHom_coe\n\nend Homothety\n\nvariable {P₁}\n\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P₁) : P₁ ≃ᵃ[k] P₁ :=\n  (constVSub k x).trans (vaddConst k x)\n#align affine_equiv.point_reflection AffineEquiv.pointReflection\n\ntheorem pointReflection_apply (x y : P₁) : pointReflection k x y = x -ᵥ y +ᵥ x :=\n  rfl\n#align affine_equiv.point_reflection_apply AffineEquiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_symm (x : P₁) : (pointReflection k x).symm = pointReflection k x :=\n  toEquiv_injective <| Equiv.pointReflection_symm x\n#align affine_equiv.point_reflection_symm AffineEquiv.pointReflection_symm\n\n@[simp]\ntheorem toEquiv_pointReflection (x : P₁) :\n    (pointReflection k x).toEquiv = Equiv.pointReflection x :=\n  rfl\n#align affine_equiv.to_equiv_point_reflection AffineEquiv.toEquiv_pointReflection\n\n@[simp]\ntheorem pointReflection_self (x : P₁) : pointReflection k x x = x :=\n  vsub_vadd _ _\n#align affine_equiv.point_reflection_self AffineEquiv.pointReflection_self\n\ntheorem pointReflection_involutive (x : P₁) : Involutive (pointReflection k x : P₁ → P₁) :=\n  Equiv.pointReflection_involutive x\n#align affine_equiv.point_reflection_involutive AffineEquiv.pointReflection_involutive\n\nset_option linter.deprecated false in\n/-- `x` is the only fixed point of `pointReflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P₁} (h : Injective (bit0 : V₁ → V₁)) :\n    pointReflection k x y = y ↔ y = x :=\n  Equiv.pointReflection_fixed_iff_of_injective_bit0 h\n#align affine_equiv.point_reflection_fixed_iff_of_injective_bit0 AffineEquiv.pointReflection_fixed_iff_of_injective_bit0\n\nset_option linter.deprecated false in\ntheorem injective_pointReflection_left_of_injective_bit0 (h : Injective (bit0 : V₁ → V₁)) (y : P₁) :\n    Injective fun x : P₁ => pointReflection k x y :=\n  Equiv.injective_pointReflection_left_of_injective_bit0 h y\n#align affine_equiv.injective_point_reflection_left_of_injective_bit0 AffineEquiv.injective_pointReflection_left_of_injective_bit0\n\ntheorem injective_pointReflection_left_of_module [Invertible (2 : k)] :\n    ∀ y, Injective fun x : P₁ => pointReflection k x y :=\n  injective_pointReflection_left_of_injective_bit0 k fun x y h => by\n    rwa [bit0, bit0, ← two_smul k x, ← two_smul k y,\n      (isUnit_of_invertible (2 : k)).smul_left_cancel] at h\n#align affine_equiv.injective_point_reflection_left_of_module AffineEquiv.injective_pointReflection_left_of_module\n\ntheorem pointReflection_fixed_iff_of_module [Invertible (2 : k)] {x y : P₁} :\n    pointReflection k x y = y ↔ y = x :=\n  ((injective_pointReflection_left_of_module k y).eq_iff' (pointReflection_self k y)).trans eq_comm\n#align affine_equiv.point_reflection_fixed_iff_of_module AffineEquiv.pointReflection_fixed_iff_of_module\n\nend AffineEquiv\n\nnamespace LinearEquiv\n\n/-- Interpret a linear equivalence between modules as an affine equivalence. -/\ndef toAffineEquiv (e : V₁ ≃ₗ[k] V₂) : V₁ ≃ᵃ[k] V₂ where\n  toEquiv := e.toEquiv\n  linear := e\n  map_vadd' p v := e.map_add v p\n#align linear_equiv.to_affine_equiv LinearEquiv.toAffineEquiv\n\n@[simp]\ntheorem coe_toAffineEquiv (e : V₁ ≃ₗ[k] V₂) : ⇑e.toAffineEquiv = e :=\n  rfl\n#align linear_equiv.coe_to_affine_equiv LinearEquiv.coe_toAffineEquiv\n\nend LinearEquiv\n\nnamespace AffineMap\n\nopen AffineEquiv\n\ntheorem lineMap_vadd (v v' : V₁) (p : P₁) (c : k) :\n    lineMap v v' c +ᵥ p = lineMap (v +ᵥ p) (v' +ᵥ p) c :=\n  (vaddConst k p).apply_lineMap v v' c\n#align affine_map.line_map_vadd AffineMap.lineMap_vadd\n\ntheorem lineMap_vsub (p₁ p₂ p₃ : P₁) (c : k) :\n    lineMap p₁ p₂ c -ᵥ p₃ = lineMap (p₁ -ᵥ p₃) (p₂ -ᵥ p₃) c :=\n  (vaddConst k p₃).symm.apply_lineMap p₁ p₂ c\n#align affine_map.line_map_vsub AffineMap.lineMap_vsub\n\ntheorem vsub_lineMap (p₁ p₂ p₃ : P₁) (c : k) :\n    p₁ -ᵥ lineMap p₂ p₃ c = lineMap (p₁ -ᵥ p₂) (p₁ -ᵥ p₃) c :=\n  (constVSub k p₁).apply_lineMap p₂ p₃ c\n#align affine_map.vsub_line_map AffineMap.vsub_lineMap\n\ntheorem vadd_lineMap (v : V₁) (p₁ p₂ : P₁) (c : k) :\n    v +ᵥ lineMap p₁ p₂ c = lineMap (v +ᵥ p₁) (v +ᵥ p₂) c :=\n  (constVAdd k P₁ v).apply_lineMap p₁ p₂ c\n#align affine_map.vadd_line_map AffineMap.vadd_lineMap\n\nvariable {R' : Type _} [CommRing R'] [Module R' V₁]\n\ntheorem homothety_neg_one_apply (c p : P₁) : homothety c (-1 : R') p = pointReflection R' c p := by\n  -- porting note: added `()`, `_`, and `neg_vsub_eq_vsub_rev`\n  simp [(homothety_apply), pointReflection_apply _, (neg_vsub_eq_vsub_rev)]\n#align affine_map.homothety_neg_one_apply AffineMap.homothety_neg_one_apply\n\nend AffineMap\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/LinearAlgebra/AffineSpace/AffineEquiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.47050191345159925}}
{"text": "class One (α : Type u) where\n  one : α\n\ninstance One.toOfNat1 {α} [One α] : OfNat α (nat_lit 1) where\n  ofNat := ‹One α›.1\n\nclass MulOneClass (M : Type u) extends One M, Mul M\n\nclass FunLike (F : Sort _) (α : outParam (Sort _)) (β : outParam <| α → Sort _) where\n  coe : F → ∀ a : α, β a\n\ninstance (priority := 100) [FunLike F α β] : CoeFun F fun _ => ∀ a : α, β a where coe := FunLike.coe\n\nsection One\n\nvariable [One M] [One N]\n\nstructure OneHom (M : Type _) (N : Type _) [One M] [One N] where\n  toFun : M → N\n  map_one' : toFun 1 = 1\n\nclass OneHomClass (F : Type _) (M N : outParam (Type _)) [One M] [One N]\n  extends FunLike F M fun _ => N where\n  map_one : ∀ f : F, f 1 = 1\n\n@[simp]\ntheorem map_one [OneHomClass F M N] (f : F) : f 1 = 1 :=\n  OneHomClass.map_one f\n\nend One\n\nsection Mul\n\nvariable [Mul M] [Mul N]\n\nstructure MulHom (M : Type _) (N : Type _) [Mul M] [Mul N] where\n  toFun : M → N\n  map_mul' : ∀ x y, toFun (x * y) = toFun x * toFun y\n\ninfixr:25 \" →ₙ* \" => MulHom\n\nclass MulHomClass (F : Type _) (M N : outParam (Type _)) [Mul M] [Mul N]\n  extends FunLike F M fun _ => N where\n  map_mul : ∀ (f : F) (x y : M), f (x * y) = f x * f y\n\n@[simp]\ntheorem map_mul [MulHomClass F M N] (f : F) (x y : M) : f (x * y) = f x * f y :=\n  MulHomClass.map_mul f x y\n\nend Mul\n\nsection mul_one\n\nvariable [MulOneClass M] [MulOneClass N]\n\nstructure MonoidHom (M : Type _) (N : Type _) [MulOneClass M] [MulOneClass N] extends\n  OneHom M N, M →ₙ* N\n\ninfixr:25 \" →* \" => MonoidHom\n\nclass MonoidHomClass (F : Type _) (M N : outParam (Type _)) [MulOneClass M] [MulOneClass N] extends MulHomClass F M N, OneHomClass F M N\n\ninstance (F : Type _) (M N : outParam (Type _)) [MulOneClass M] [MulOneClass N] [MonoidHomClass F M N] : CoeTC F (M →* N) :=\n  ⟨fun f => {\n   toFun := f,\n   map_one' := map_one f,\n   map_mul' := map_mul f\n  }⟩\n\n-- Now we reverse the order of the parents in the extends clause:\nclass MonoidHomClass' (F : Type _) (M N : outParam (Type _)) [MulOneClass M] [MulOneClass N] extends OneHomClass F M N, MulHomClass F M N\n\ninstance [MonoidHomClass' F M N] : CoeTC F (M →* N) :=\n  ⟨fun f => {\n    toFun := f,\n    map_one' := map_one f,\n    map_mul' := map_mul f\n  }⟩\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/1907.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056040203136, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.47050190473845493}}
{"text": "/- -----------------------------------------------------------------------\nDependent lists.\n----------------------------------------------------------------------- -/\n\nimport .c1_fin\n\nnamespace qp\nnamespace stdaux\n\nuniverse variables ℓ₁ ℓ₂\n\n/-! #brief A dependent list.\n-/\ninductive dlist {A : Type ℓ₁} (B : A → Sort ℓ₂) : list A → Type (max ℓ₁ ℓ₂)\n| nil : dlist []\n| cons : ∀ (a : A) (b : B a) (aa : list A) (bb : dlist aa)\n         , dlist (a :: aa)\n\n-- notation `][` := dlist.nil _\n-- notation h ` :Σ: ` t  := dlist.cons _ h _ t\n\n/-! #brief Equality of dlists.\n-/\ndefinition dlist.eq {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {a : A} {aa : list A}\n         {b₁ b₂ : B a}\n         {bb₁ bb₂ : dlist B aa}\n         (ωb : b₁ = b₂)\n         (ωbb : bb₁ = bb₂)\n       , dlist.cons a b₁ aa bb₁ = dlist.cons a b₂ aa bb₂\n| a aa b .(b) bb .(bb) (eq.refl .(b)) (eq.refl .(bb)) := rfl\n\n-- /-! #brief The head of a dlist.\n-- -/\n-- definition dlist.head {A : Type ℓ₁} {B : A → Sort ℓ₂}\n--     : ∀ {a:  A} {aa : list A}\n--         (bb : dlist B (a :: aa))\n--       , B a\n-- | a aa (dlist.cons .a b .aa bb) := b\n\n/-! #brief Mapping across a dependent list.\n-/\ndefinition dlist.map {A : Type ℓ₁} {B₁ B₂ : A → Sort ℓ₂} (f : ∀ {a : A}, B₁ a → B₂ a)\n    : ∀ {aa : list A}\n      , dlist B₁ aa → dlist B₂ aa\n| [] bb := dlist.nil B₂\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) := dlist.cons a (f b) aa (dlist.map bb)\n\n/-! #brief Mapping a map.\n-/\ntheorem dlist.map_map {A : Type ℓ₁} {B₁ B₂ B₃ : A → Sort ℓ₂}\n    (g : ∀ {a : A}, B₂ a → B₃ a)\n    (f : ∀ {a : A}, B₁ a → B₂ a)\n    : ∀ {aa : list A} {bb : dlist B₁ aa}\n      , dlist.map @g (dlist.map @f bb) = dlist.map (λ a b, g (f b)) bb\n| [] bb := rfl\n| (a :: aa) (dlist.cons .(a) b .(aa) bb)\n:= begin\n     apply dlist.eq,\n     { trivial },\n     { apply dlist.map_map }\n   end\n\n/-! #brief Getting an item out of a dependent list.\n-/\ndefinition dlist.get {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa : list A}\n        (bb : dlist B aa)\n        (n : fin (list.length aa))\n      , B (list.get aa n)\n| [] bb n := fin.zero_elim n\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) (fin.mk 0 ω) := b\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) (fin.mk (nat.succ n) ω)\n:= dlist.get bb { val := n, is_lt := nat.lt_of_succ_lt_succ ω }\n\ntheorem dlist.get.simp {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    (a : A) (b : B a) (aa : list A) (bb : dlist B aa)\n    (n : ℕ) (ω : nat.succ n < list.length (a :: aa))\n    : dlist.get (dlist.cons a b aa bb) { val := nat.succ n, is_lt := ω }\n       == dlist.get bb { val := n, is_lt := nat.lt_of_succ_lt_succ ω }\n:= heq.refl _\n\n/-! #brief Congruence for dlist.get.\n-/\ntheorem dlist.congr_get {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    {aa : list A} {bb₁ bb₂ : dlist B aa}\n    (ωbb : bb₁ = bb₂) (n : fin (list.length aa))\n    : dlist.get bb₁ n = dlist.get bb₂ n\n:= by rw ωbb\n\n/-! #brief Getting an item out of a map.\n-/\ntheorem dlist.get_map {A : Type ℓ₁} {B₁ B₂ : A → Sort ℓ₂} (f : ∀ {a : A}, B₁ a → B₂ a)\n    : ∀ {aa : list A} (bb : dlist B₁ aa)\n        (n : fin (list.length aa))\n      , dlist.get (dlist.map @f bb) n = f (dlist.get bb n)\n| [] bb n := fin.zero_elim n\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) (fin.mk 0 ω) := rfl\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) (fin.mk (nat.succ n) ω)\n:= begin\n     dsimp [dlist.map],\n     apply eq_of_heq,\n     apply heq.trans (dlist.get.simp a (f b) aa (dlist.map @f bb) n ω),\n     apply heq_of_eq,\n     apply dlist.get_map\n   end\n\n/-! #brief Dropping the bottom out of a finite function.\n-/\ndefinition fin.drop {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    {a : A} {aa : list A}\n    (f : ∀ (n : fin (list.length (a :: aa))), B (list.get (a :: aa) n))\n    : ∀ (n : fin (list.length aa))\n      , B (list.get aa n)\n| (fin.mk n ω) := f { val := nat.succ n, is_lt := nat.succ_lt_succ ω }\n\n/-! #brief Dropping on get.\n-/\ntheorem dlist.drop_get {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {a : A} {b : B a} {aa : list A} {bb : dlist B aa}\n         {n : ℕ} {ω : n < list.length aa}\n      , dlist.get (dlist.cons a b aa bb) (fin.mk (nat.succ n) (nat.succ_lt_succ ω)) == dlist.get bb (fin.mk n ω)\n| a b [] bb n ω := fin.zero_elim (fin.mk n ω)\n| a₁ b₁ (a₂ :: aa) (dlist.cons .(a₂) b₂ .(aa) bb) 0 ω := heq.refl _\n| a₁ b₁ (a₂ :: aa) (dlist.cons .(a₂) b₂ .(aa) bb) (nat.succ n) ω\n:= begin\n     refine heq.trans (dlist.get.simp _ _ _ _ _ _) _,\n     refine heq.trans (@dlist.drop_get _ _ _ _ n (nat.lt_of_succ_lt_succ ω)) _,\n     apply heq.symm,\n     apply dlist.get.simp\n   end\n\n/-! #brief Inverse of dlist.get.\n-/\ndefinition dlist.enum {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa : list A}\n        (f : ∀ (n : fin (list.length aa)), B (list.get aa n))\n      , dlist B aa\n| [] f := dlist.nil B\n| (a :: aa) f := dlist.cons a (f fin.zero) aa (dlist.enum (fin.drop f))\n\n/-! #brief When an enum is equal to a map.\n-/\ntheorem dlist.enum_eq_map {A : Type ℓ₁} {B₁ B₂ : A → Sort ℓ₂} (f : ∀ {a : A}, B₁ a → B₂ a)\n    : ∀ {aa : list A} (bb : dlist B₁ aa)\n        (h : ∀ (n : fin (list.length aa)), B₂ (list.get aa n))\n        (ωh : ∀ (n : fin (list.length aa)), h n = f (dlist.get bb n))\n      , dlist.enum h = @dlist.map A B₁ B₂ @f aa bb\n| [] bb h ωh := rfl\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) h ωh\n:= begin\n     dsimp [dlist.enum, dlist.map],\n     rw ωh,\n     apply congr_arg,\n     apply dlist.enum_eq_map,\n     intro n, cases n with n ωn,\n     dsimp [fin.drop],\n     rw ωh,\n     trivial\n   end\n\n/-! #brief Getting an item out of an enumerated dlist.\n-/\ntheorem dlist.get_enum {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa : list A}\n        (f : ∀ (n : fin (list.length aa)), B (list.get aa n))\n        (n : fin (list.length aa))\n      , dlist.get (dlist.enum f) n = f n\n| [] f n := fin.zero_elim n\n| (a :: aa) f (fin.mk 0 ω) := rfl\n| (a :: aa) f (fin.mk (nat.succ n) ω)\n:= begin\n     dsimp [dlist.enum, dlist.get],\n     apply eq_of_heq,\n     apply heq.trans (dlist.get.simp a (f fin.zero) aa _ n ω),\n     apply heq_of_eq,\n     apply eq.trans (dlist.get_enum (fin.drop f) _),\n     trivial\n   end\n\n/-! #brief Enumerating the dlist.get function.\n-/\ntheorem dlist.enum_get {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa : list A}\n        {bb : dlist B aa}\n      , dlist.enum (dlist.get bb) = bb\n| [] bb := begin cases bb, trivial end\n| (a :: aa) (dlist.cons .(a) b .(aa) bb)\n:= begin\n     apply dlist.eq,\n     { trivial },\n     { refine eq.trans _ dlist.enum_get,\n       apply congr_arg dlist.enum,\n       apply funext,\n       intro n, cases n with n ωn,\n       unfold fin.drop,\n       apply eq_of_heq,\n       apply dlist.drop_get\n     }\n   end\n\n/-! #brief dlist.get is injective.\n-/\ntheorem dlist.get.inj {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    {aa : list A}\n    {bb₁ bb₂ : dlist B aa}\n    (ω : dlist.get bb₁ = dlist.get bb₂)\n    : bb₁ = bb₂\n:= by calc bb₁ = dlist.enum (dlist.get bb₁) : eq.symm dlist.enum_get\n           ... = dlist.enum (dlist.get bb₂) : by rw ω\n           ... = bb₂                        : dlist.enum_get\n\n\n/-! #brief Appending dlists.\n-/\ndefinition dlist.append {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa₁ : list A} (bb₁ : dlist B aa₁)\n        {aa₂ : list A} (bb₂ : dlist B aa₂)\n      , dlist B (aa₁ ++ aa₂)\n| [] bb₁ aa₂ bb₂ := bb₂\n| (a :: aa₁) (dlist.cons .(a) b .(aa₁) bb₁) aa₂ bb₂ := dlist.cons a b (aa₁ ++ aa₂) (dlist.append bb₁ bb₂)\n\n/-! #brief Splitting apart a dlist at an append (left part).\n-/\ndefinition dlist.split_left {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ (aa₁ : list A) {aa₂ : list A}\n        (bb : dlist B (aa₁ ++ aa₂))\n      , dlist B aa₁\n:= λ aa₁ aa₂ bb\n   , begin\n       induction aa₁ with a aa₁ rec,\n       { exact dlist.nil B },\n       { cases bb with a b aa₁ bb', apply dlist.cons _ b _, exact rec bb' }\n     end\n\n/-! #brief Splitting apart a dlist at an append (right part).\n-/\ndefinition dlist.split_right {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ (aa₁ : list A) {aa₂ : list A}\n        (bb : dlist B (aa₁ ++ aa₂))\n      , dlist B aa₂\n:= λ aa₁ aa₂ bb\n   , begin\n       induction aa₁ with a aa₁ rec,\n       { exact bb },\n       { cases bb with a b aa₁ bb', exact rec bb'}\n     end\n\n/-! #brief Appending the splits.\n-/\ntheorem dlist.append_split {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa₁ aa₂ : list A}\n        {bb : dlist B (aa₁ ++ aa₂)}\n      , dlist.append (dlist.split_left _ bb) (dlist.split_right _ bb)\n         = bb\n:= λ aa₁ aa₂ bb\n   , begin\n       induction aa₁ with a aa₁ rec,\n       { trivial },\n       { cases bb with a b aa₁ bb',\n         apply dlist.eq,\n         { trivial },\n         { apply rec }\n       }\n     end\n\n/-! #brief Equality of appended dlists.\n-/\ntheorem dlist.append_eq {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    {aa₁ aa₂ : list A}\n    {bb₁ bb₂ : dlist B (aa₁ ++ aa₂)}\n    (ωleft : dlist.split_left _ bb₁ = dlist.split_left _ bb₂)\n    (ωright : dlist.split_right _ bb₁ = dlist.split_right _ bb₂)\n    : bb₁ = bb₂\n:= begin\n     refine eq.trans (eq.symm dlist.append_split) _,\n     refine eq.trans _ (dlist.append_split),\n     rw [ωleft, ωright]\n   end\n\n/-! #brief Splitting an append.\n-/\ntheorem dlist.split_left_append {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa₁ aa₂ : list A}\n        {bb₁ : dlist B aa₁} {bb₂ : dlist B aa₂}\n      , dlist.split_left aa₁ (dlist.append bb₁ bb₂)\n         = bb₁\n| aa₁ aa₂ bb₁ bb₂\n:= begin\n     induction aa₁ with a aa₁ rec,\n     { cases bb₁ with a b aa₁ bb₁, trivial },\n     { cases bb₁ with a b aa₁ bb₁,\n       apply dlist.eq,\n       { trivial },\n       { apply rec }\n     }\n   end\n\n/-! #brief Splitting an append.\n-/\ntheorem dlist.split_right_append {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa₁ aa₂ : list A}\n        {bb₁ : dlist B aa₁} {bb₂ : dlist B aa₂}\n      , dlist.split_right aa₁ (dlist.append bb₁ bb₂)\n         = bb₂\n| aa₁ aa₂ bb₁ bb₂\n:= begin\n     induction aa₁ with a aa₁ rec,\n     { cases bb₁ with a b aa₁ bb₁, trivial },\n     { cases bb₁ with a b aa₁ bb₁,\n       apply rec\n     }\n   end\n\n/-! #brief Splitting a map.\n-/\ntheorem dlist.split_left_map {A : Type ℓ₁} {B₁ B₂ : A → Sort ℓ₂} (f : ∀ {a : A}, B₁ a → B₂ a)\n    : ∀ {aa₁ aa₂ : list A}\n        {bb : dlist B₁ (aa₁ ++ aa₂)}\n      , dlist.split_left aa₁ (dlist.map @f bb) = dlist.map @f (dlist.split_left aa₁ bb)\n| aa₁ aa₂ bb\n:= begin\n     induction aa₁ with a aa₁ rec,\n     { trivial },\n     { cases bb with a b aa₁ bb',\n       apply dlist.eq,\n       { trivial },\n       { apply rec }\n     }\n   end\n\n/-! #brief Splitting a map.\n-/\ntheorem dlist.split_right_map {A : Type ℓ₁} {B₁ B₂ : A → Sort ℓ₂} (f : ∀ {a : A}, B₁ a → B₂ a)\n    : ∀ {aa₁ aa₂ : list A}\n        {bb : dlist B₁ (aa₁ ++ aa₂)}\n      , dlist.split_right aa₁ (dlist.map @f bb) = dlist.map @f (dlist.split_right aa₁ bb)\n| aa₁ aa₂ bb\n:= begin\n     induction aa₁ with a aa₁ rec,\n     { trivial },\n     { cases bb with a b aa₁ bb',\n       apply rec\n     }\n   end\n\n/-! #brief Getting out of an append.\n-/\ntheorem dlist.get_append {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa₁ aa₂ : list A}\n        {bb₁ : dlist B aa₁} {bb₂ : dlist B aa₂}\n        {n : ℕ} {ωn : n < list.length aa₁}\n      , dlist.get (dlist.append bb₁ bb₂) (fin.mk n (list.length.grow_left ωn))\n         == dlist.get bb₁ (fin.mk n ωn)\n| aa₁ aa₂ bb₁ bb₂ n ωn\n:= sorry\n\n/-! #brief Getting out of a split.\n-/\ntheorem dlist.get_split_left {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa₁ aa₂ : list A}\n        {bb : dlist B (aa₁ ++ aa₂)}\n        {n : ℕ} {ωn : n < list.length aa₁}\n      , dlist.get (dlist.split_left aa₁ bb) (fin.mk n ωn)\n         == dlist.get bb (fin.mk n (list.length.grow_left ωn))\n:= λ aa₁ aa₂ bb n ωn\n   , sorry\n\n/-! #brief Getting out of a split.\n-/\ntheorem dlist.get_split_right {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    : ∀ {aa₁ aa₂ : list A}\n        {bb : dlist B (aa₁ ++ aa₂)}\n        {n : ℕ} {ωn : n < list.length aa₂}\n      , dlist.get (dlist.split_right aa₁ bb) (fin.mk n ωn)\n         == dlist.get bb (fin.mk (n + list.length aa₁) (list.length.grow_right ωn))\n:= λ aa₁ aa₂ bb n ωn\n   , sorry\n\n/-! #brief Repeating an item as a dlist.\n-/\ndefinition dlist.repeat {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    {a : A} (b : B a)\n    : ∀ (N : ℕ)\n      , dlist B (list.repeat a N)\n| 0 := dlist.nil B\n| (nat.succ n) := dlist.cons a b (list.repeat a n) (dlist.repeat n)\n\n/-! #brief Action of get on repeat.\n-/\ntheorem dlist.get_repeat {A : Type ℓ₁} {B : A → Sort ℓ₂}\n    {a : A} {b : B a}\n    : ∀ {N : ℕ} {n : fin N}\n      , dlist.get (dlist.repeat b N) (fin.mk n^.val begin rw list.length_repeat, exact n^.is_lt end)\n         == b\n| 0 n := fin.zero_elim n\n| (nat.succ N) (fin.mk 0 ω0) := heq.refl _\n| (nat.succ N) (fin.mk (nat.succ n) ωn) := @dlist.get_repeat N (fin.mk n (nat.le_of_lt_succ ωn))\n\nend stdaux\nend qp\n", "meta": {"author": "intoverflow", "repo": "qvr", "sha": "0cfcd33fe4bf8d93851a00cec5bfd21e77105d74", "save_path": "github-repos/lean/intoverflow-qvr", "path": "github-repos/lean/intoverflow-qvr/qvr-0cfcd33fe4bf8d93851a00cec5bfd21e77105d74/qp/p0_stdlib/c5_dlist.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.4705019046440602}}
{"text": "/-\nCopyright (c) 2021 Paula Neeley. All rights reserved.\nAuthor: Paula Neeley\nFollowing the textbook \"Dynamic Epistemic Logic\" by \nHans van Ditmarsch, Wiebe van der Hoek, and Barteld Kooi\n-/\n\nimport del.languageDEL del.syntax.syntaxDEL data.set.basic\nlocal attribute [instance] classical.prop_decidable\n\nvariables {agents : Type}\nopen prfS5\n\n\n---------------------- Helper Lemmas ----------------------\n\nnamespace S5lemma\n\n\nlemma iden {Γ : ctx agents} {φ : form agents} :\n  prfS5 Γ (φ ⊃ φ) :=\nbegin\nexact mp (mp (@pl2 _ _ φ (φ ⊃ φ) φ) pl1) pl1\nend\n\n\nlemma prtrue {Γ : ctx agents} : prfS5 Γ ¬⊥ := iden\n\n\nlemma weak {Γ : ctx agents} {φ ψ : form agents} :\n  prfS5 Γ φ → prfS5 (Γ ∪ ψ) φ :=\nbegin\nintro h,\ninduction h,\n{apply ax, exact (set.mem_insert_of_mem _ h_h)},\n{exact pl1},\n{exact pl2},\n{exact pl3},\n{exact pl4},\n{exact pl5},\n{exact pl6},\n{exact pl7},\n{exact kdist},\n{exact truth},\n{exact posintro},\n{exact negintro},\n{apply mp,\n  {exact h_ih_hpq},\n  {exact h_ih_hp}},\n{exact nec h_ih}\nend\n\n\nlemma pr {Γ : ctx agents} {φ : form agents} :\n  prfS5 (Γ ∪ φ) φ :=\nbegin\napply ax;\napply or.intro_left;\nsimp\nend\n\n\nlemma cut {Γ : ctx agents} {φ ψ χ : form agents} :\n  prfS5 Γ (φ ⊃ ψ) → prfS5 Γ (ψ ⊃ χ) → prfS5 Γ (φ ⊃ χ) :=\nbegin\nintros h1 h2,\nexact mp (mp pl2 (mp pl1 h2)) h1\nend\n\n\nlemma conv_deduction {Γ : ctx agents} {φ ψ : form agents} :\n  prfS5 Γ (φ ⊃ ψ) → prfS5 (Γ ∪ φ) ψ :=\nbegin\nintro h, \nexact mp (weak h) pr \nend\n\n\nlemma hs1 {Γ : ctx agents} {φ ψ χ : form agents} :\n  prfS5 Γ ((ψ ⊃ χ) ⊃ ((φ ⊃ ψ) ⊃ (φ ⊃ χ))) :=\nbegin\nexact (mp (mp pl2 (mp pl1 pl2)) pl1)\nend\n\n\nlemma likemp {Γ : ctx agents} {φ ψ : form agents} : \n  prfS5 Γ (φ ⊃ ((φ ⊃ ψ) ⊃ ψ)) :=\nbegin\nexact (mp (mp hs1 (mp pl2 iden)) pl1)\nend\n\n\nlemma dne {Γ : ctx agents} {φ : form agents} :\nprfS5 Γ ((¬¬φ) ⊃ φ) :=\nbegin\nhave h1 : prfS5 Γ (φ ⊃ (φ ⊃ φ)), from pl1,\nexact (cut (cut pl1 (cut pl7 pl7)) (mp likemp h1))\nend\n\n\nlemma dni {Γ : ctx agents} {φ : form agents} : prfS5 Γ (φ ⊃ ¬¬φ) :=\nbegin\nexact mp pl7 dne\nend\n\n\nlemma imp_if_imp_imp {Γ : ctx agents} {φ ψ χ : form agents} : prfS5 Γ (φ ⊃ χ) → prfS5 Γ (φ ⊃ (ψ ⊃ χ)) :=\nbegin\nintro h1,\nexact mp (mp pl2 (mp pl1 pl1)) h1\nend\n\n\nlemma cut1 {Γ : ctx agents} {φ ψ χ θ : form agents} :\n  prfS5 Γ (θ ⊃ (φ ⊃ ψ)) → prfS5 Γ (ψ ⊃ χ) → prfS5 Γ (θ ⊃ (φ ⊃ χ)) :=\nbegin\nintros h1 h2,\nexact (cut h1) (mp pl2 (mp pl1 h2))\nend\n\n\nlemma imp_switch {Γ : ctx agents} {φ ψ χ : form agents} : prfS5 Γ (φ ⊃ (ψ ⊃ χ)) → prfS5 Γ (ψ ⊃ (φ ⊃ χ)) :=\nbegin\nintro h1,\nexact mp (mp pl2 (mp pl1 (mp pl2 h1))) pl1\nend\n\n\nlemma l2 {Γ : ctx agents} {φ ψ χ : form agents} : prfS5 Γ ((φ ⊃ (ψ ⊃ χ)) ⊃ (ψ ⊃ (φ ⊃ χ))) :=\nbegin\nexact (mp (mp pl2 (cut pl2 hs1)) (mp pl1 pl1))\nend\n\n\nlemma hs2 {Γ : ctx agents} {φ ψ χ : form agents} :\n  prfS5 Γ ((φ ⊃ ψ) ⊃ ((ψ ⊃ χ) ⊃ (φ ⊃ χ))) :=\nbegin\nexact (mp l2 hs1)\nend\n\n\nlemma cut2 {Γ : ctx agents} {φ ψ χ θ : form agents} :\n  prfS5 Γ (φ ⊃ ψ) → prfS5 Γ (θ ⊃ (ψ ⊃ χ)) → prfS5 Γ (θ ⊃ (φ ⊃ χ)) :=\nbegin\nintros h1 h2,\nexact imp_switch (cut h1 (imp_switch h2))\nend\n\n\nlemma double_imp {Γ : ctx agents} {φ ψ : form agents} :\n  prfS5 Γ ((φ ⊃ (φ ⊃ ψ)) ⊃ (φ ⊃ ψ)) :=\nbegin\nexact mp pl2 (imp_switch iden)\nend\n\n\nlemma imp_imp_iff_imp {Γ : ctx agents} {θ φ ψ : form agents} : \n  prfS5 Γ (θ ⊃ (φ ⊃ (φ ⊃ ψ))) ↔ prfS5 Γ (θ ⊃ (φ ⊃ ψ)) :=\nbegin\nsplit,\n{intro h1,\nexact cut h1 double_imp},\n{intro h1,\nexact cut h1 pl1}\nend\n\n\nlemma imp_shift {Γ : ctx agents} {θ φ ψ χ : form agents} : \n  prfS5 Γ (θ ⊃ (φ ⊃ (ψ ⊃ χ))) ↔ prfS5 Γ (θ ⊃ (ψ ⊃ (φ ⊃ χ))) :=\nbegin\nsplit,\nrepeat {intro h1, exact cut h1 (cut2 pl1 pl2)}\nend\n\n\nlemma left_and_imp {Γ : ctx agents} {φ ψ χ : form agents} :\n  prfS5 Γ (ψ ⊃ ((φ & ψ) ⊃ χ)) → prfS5 Γ ((φ & ψ) ⊃ χ) :=\nbegin\nintro h1,\nexact mp double_imp (cut pl6 h1)\nend\n\n\nlemma and_right_imp {Γ : ctx agents} {φ ψ χ : form agents} : \n  prfS5 Γ ((φ & ψ) ⊃ χ) ↔ prfS5 Γ (ψ ⊃ (φ ⊃ χ)) :=\nbegin\nsplit, \n{intro h1,\nexact mp (cut2 pl1 pl2) (cut1 pl4 h1)},\nintro h1,\nexact left_and_imp (cut2 pl5 h1)\nend\n\n\nlemma not_and_subst {φ ψ χ : form agents} {Γ : ctx agents} : prfS5 Γ (φ ↔ ψ) → (prfS5 Γ ¬(χ & φ) ↔ prfS5 Γ ¬(χ & ψ)) :=\nbegin\nintro h1, split, \n{intro h2,\nexact mp (mp pl3 (mp pl1 h2)) (cut dne (mp double_imp (cut2 (cut pl6 (mp pl6 h1)) (cut pl5 pl4))))},\n{intro h2,\nexact mp (mp pl3 (mp pl1 h2)) (cut dne (mp double_imp (cut2 (cut pl6 (mp pl5 h1)) (cut pl5 pl4))))},\nend\n\n\nlemma not_contra {Γ : ctx agents} {φ : form agents} : \n  prfS5 Γ ¬(φ & ¬φ) :=\nbegin\nexact mp (mp pl3 (cut dne pl6)) (cut dne pl5)\nend\n\n\nlemma phi_and_true {Γ : ctx agents} {φ : form agents} : prfS5 Γ ((φ&(¬⊥)) ↔ φ) :=\nbegin\nexact (mp (mp pl4 pl5) (mp (imp_switch pl4) prtrue))\nend\n\n\nlemma imp_and_and_imp {Γ : ctx agents} {φ ψ χ θ : form agents} : \n  prfS5 Γ (((φ ⊃ ψ) & (χ ⊃ θ))) → prfS5 Γ (((φ & χ) ⊃ (ψ & θ))) :=\nbegin\nintro h,\nexact (mp double_imp (cut (cut pl5 (mp pl5 h)) (cut2 (cut pl6 (mp pl6 h)) pl4)))\nend\n\n\nlemma not_contra_equiv_true {Γ : ctx agents} {φ : form agents} : \n  prfS5 Γ (¬(φ & ¬φ) ↔ ¬⊥) :=\nbegin\nexact (mp (mp pl4 (mp pl1 prtrue)) (mp pl1 not_contra))\nend\n\n\nlemma contrapos {Γ : ctx agents} {φ ψ : form agents} :\n  prfS5 Γ ((¬ψ) ⊃ (¬φ)) ↔ prfS5 Γ (φ ⊃ ψ) :=\nbegin\nsplit,\nintro h1,\nexact mp pl7 h1,\nintro h1,\nexact mp (cut (cut (mp hs1 dni) (mp hs2 dne)) pl7) h1,\nend\n\n\nlemma iff_not {Γ : ctx agents} {φ ψ : form agents} :\n  prfS5 Γ (φ ↔ ψ) → prfS5 Γ (¬ψ ↔ ¬φ) :=\nbegin\nintro h1,\nhave h2 : prfS5 Γ (φ ⊃ ψ), from mp pl5 h1,\nhave h3 : prfS5 Γ (ψ ⊃ φ), from mp pl6 h1,\nrw ←contrapos at h2,\nrw ←contrapos at h3,\nexact (mp (mp pl4 h2) h3)\nend\n\n\nlemma contra_equiv_false {Γ : ctx agents} {φ : form agents} : \n  prfS5 Γ ((φ & ¬φ) ↔ ⊥) :=\nbegin\nhave h1 := iff_not not_contra_equiv_true,\nexact (mp (mp pl4 (cut dni (cut (mp pl6 h1) dne))) (cut dni (cut (mp pl5 h1) dne)))\nend\n\n\nlemma and_switch {Γ : ctx agents} {φ ψ : form agents} : prfS5 Γ ((φ & ψ) ↔ (ψ & φ)) :=\nbegin\nexact (mp (mp pl4 (mp double_imp (cut pl5 (imp_switch (cut pl6 pl4))))) \n(mp double_imp (cut pl5 (imp_switch (cut pl6 pl4)))))\nend\n\n\nlemma imp_and_imp {Γ : ctx agents} {φ ψ χ : form agents} : \n  prfS5 Γ (φ ⊃ ψ) → prfS5 Γ  ((χ & φ) ⊃ (χ & ψ)) :=\nbegin\nintros h1,\nexact imp_and_and_imp (mp (mp pl4 iden) h1)\nend\n\n\nlemma iff_iff_and_iff {Γ : ctx agents} {φ ψ χ θ : form agents} : \n  prfS5 Γ (φ ↔ χ) → prfS5 Γ (ψ ↔ θ) → prfS5 Γ ((φ & ψ) ↔ (χ & θ)) := \nbegin\nintros h1 h2,\nexact mp (mp pl4 (imp_and_and_imp (mp (mp pl4 (mp pl5 h1)) (mp pl5 h2)))) \n  (imp_and_and_imp (mp (mp pl4 (mp pl6 h1)) (mp pl6 h2)))\nend\n\n\nlemma and_commute {Γ : ctx agents} {φ ψ χ : form agents} : prfS5 Γ (((φ & ψ) & χ) ↔ (φ & (ψ & χ))) :=\nbegin\nexact mp (mp pl4 (mp double_imp (imp_imp_iff_imp.mp \n  (cut (cut pl5 pl6) (cut2 pl6 (cut1 pl4 (imp_switch (cut (cut pl5 pl5) pl4)))))))) \n  (mp double_imp (imp_imp_iff_imp.mp (cut (cut pl6 pl5) \n  (imp_switch (cut pl5 (cut1 pl4 (cut2 (cut pl6 pl6) pl4)))))))\nend\n\n\nlemma demorgans {Γ : ctx agents} {φ ψ : form agents} : \n  prfS5 Γ (¬(φ & ψ)) ↔ prfS5 Γ (φ ⊃ ¬ψ) :=\nbegin\nsplit,\nintro h1,\nexact (and_right_imp.mp (mp (contrapos.mpr (mp pl5 and_switch)) h1)),\nintro h1,\nexact (mp (contrapos.mpr (mp pl5 and_switch)) (and_right_imp.mpr h1))\nend\n\n\nlemma explosion {Γ : ctx agents} {ψ : form agents} : prfS5 Γ (⊥ ⊃ ψ) :=\nbegin\napply contrapos.mp, exact (mp pl1 iden)\nend\n\n\nlemma exfalso {Γ : ctx agents} {φ ψ : form agents} : prfS5 Γ ((φ & ¬φ) ⊃ ψ) :=\nbegin\nexact cut not_contra explosion\nend\n\n\nlemma box_dn {Γ : ctx agents} {φ : form agents} {a : agents}  : prfS5 Γ ((¬K a φ) ↔ ¬(K a (¬¬φ))) :=\nbegin\nexact mp (mp pl4 (contrapos.mpr (mp kdist (nec dne)))) (contrapos.mpr (mp kdist (nec dni)))\nend\n\n\nlemma dual_equiv1 {Γ : ctx agents} {φ : form agents} {a : agents} : prfS5 Γ ((K a φ) ↔ (¬(¬K a ¬(¬φ)))) :=\nbegin\nexact mp (mp pl4 (cut (contrapos.mp (mp pl6 box_dn)) dni)) \n  (cut dne (contrapos.mp (mp pl5 box_dn)))\nend\n\n\nend S5lemma\n", "meta": {"author": "paulaneeley", "repo": "modal", "sha": "ee5d149d4ecb337005b850bddf4453e56a5daf04", "save_path": "github-repos/lean/paulaneeley-modal", "path": "github-repos/lean/paulaneeley-modal/modal-ee5d149d4ecb337005b850bddf4453e56a5daf04/src/del/syntax/syntaxlemmasDEL.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6825737214979746, "lm_q1q2_score": 0.4705019000986986}}
{"text": "/-\nCopyright (c) 2021 Bryan Gin-ge Chen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bryan Gin-ge Chen, Yury Kudryashov\n-/\nimport algebra.hom.group\n\n/-!\n# Extensionality lemmas for monoid and group structures\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we prove extensionality lemmas for `monoid` and higher algebraic structures with one\nbinary operation. Extensionality lemmas for structures that are lower in the hierarchy can be found\nin `algebra.group.defs`.\n\n## Implementation details\n\nTo get equality of `npow` etc, we define a monoid homomorphism between two monoid structures on the\nsame type, then apply lemmas like `monoid_hom.map_div`, `monoid_hom.map_pow` etc.\n\n## Tags\nmonoid, group, extensionality\n-/\n\nuniverse u\n\n@[ext, to_additive]\nlemma monoid.ext {M : Type u} ⦃m₁ m₂ : monoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\nbegin\n  have h₁ : (@monoid.to_mul_one_class _ m₁).one = (@monoid.to_mul_one_class _ m₂).one,\n    from congr_arg (@mul_one_class.one M) (mul_one_class.ext h_mul),\n  set f : @monoid_hom M M (@monoid.to_mul_one_class _ m₁) (@monoid.to_mul_one_class _ m₂) :=\n    { to_fun := id, map_one' := h₁, map_mul' := λ x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : m₁.npow = m₂.npow, by { ext n x, exact @monoid_hom.map_pow M M m₁ m₂ f x n },\n  unfreezingI { cases m₁, cases m₂ },\n  congr; assumption\nend\n\n@[to_additive]\nlemma comm_monoid.to_monoid_injective {M : Type u} :\n  function.injective (@comm_monoid.to_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma comm_monoid.ext {M : Type*} ⦃m₁ m₂ : comm_monoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\ncomm_monoid.to_monoid_injective $ monoid.ext h_mul\n\n@[to_additive]\nlemma left_cancel_monoid.to_monoid_injective {M : Type u} :\n  function.injective (@left_cancel_monoid.to_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma left_cancel_monoid.ext {M : Type u} ⦃m₁ m₂ : left_cancel_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\nleft_cancel_monoid.to_monoid_injective $ monoid.ext h_mul\n\n@[to_additive]\nlemma right_cancel_monoid.to_monoid_injective {M : Type u} :\n  function.injective (@right_cancel_monoid.to_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma right_cancel_monoid.ext {M : Type u} ⦃m₁ m₂ : right_cancel_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\nright_cancel_monoid.to_monoid_injective $ monoid.ext h_mul\n\n@[to_additive]\nlemma cancel_monoid.to_left_cancel_monoid_injective {M : Type u} :\n  function.injective (@cancel_monoid.to_left_cancel_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_monoid.ext {M : Type*} ⦃m₁ m₂ : cancel_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\ncancel_monoid.to_left_cancel_monoid_injective $ left_cancel_monoid.ext h_mul\n\n@[to_additive]\nlemma cancel_comm_monoid.to_comm_monoid_injective {M : Type u} :\n  function.injective (@cancel_comm_monoid.to_comm_monoid M) :=\nbegin\n  rintros ⟨⟩ ⟨⟩ h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_comm_monoid.ext {M : Type*} ⦃m₁ m₂ : cancel_comm_monoid M⦄\n  (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=\ncancel_comm_monoid.to_comm_monoid_injective $ comm_monoid.ext h_mul\n\n@[ext, to_additive]\nlemma div_inv_monoid.ext {M : Type*} ⦃m₁ m₂ : div_inv_monoid M⦄ (h_mul : m₁.mul = m₂.mul)\n  (h_inv : m₁.inv = m₂.inv) : m₁ = m₂ :=\nbegin\n  have h₁ : (@div_inv_monoid.to_monoid _ m₁).one = (@div_inv_monoid.to_monoid _ m₂).one,\n    from congr_arg (@monoid.one M) (monoid.ext h_mul),\n  set f : @monoid_hom M M (by letI := m₁; apply_instance) (by letI := m₂; apply_instance) :=\n    { to_fun := id, map_one' := h₁, map_mul' := λ x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : (@div_inv_monoid.to_monoid _ m₁).npow = (@div_inv_monoid.to_monoid _ m₂).npow :=\n    congr_arg (@monoid.npow M) (monoid.ext h_mul),\n  have hzpow : m₁.zpow = m₂.zpow,\n  { ext m x,\n    exact @monoid_hom.map_zpow' M M m₁ m₂ f (congr_fun h_inv) x m },\n  have hdiv : m₁.div = m₂.div,\n  { ext a b,\n    exact @map_div' M M _ m₁ m₂ _ f (congr_fun h_inv) a b },\n  unfreezingI { cases m₁, cases m₂ },\n  congr, exacts [h_mul, h₁, hpow, h_inv, hdiv, hzpow]\nend\n\n@[ext, to_additive]\nlemma group.ext {G : Type*} ⦃g₁ g₂ : group G⦄ (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ :=\nbegin\n  set f := @monoid_hom.mk' G G (by letI := g₁; apply_instance) g₂ id\n    (λ a b, congr_fun (congr_fun h_mul a) b),\n  exact group.to_div_inv_monoid_injective (div_inv_monoid.ext h_mul\n    (funext $ @monoid_hom.map_inv G G g₁ (@group.to_division_monoid _ g₂) f))\nend\n\n@[ext, to_additive]\nlemma comm_group.ext {G : Type*} ⦃g₁ g₂ : comm_group G⦄\n  (h_mul : g₁.mul = g₂.mul) : g₁ = g₂ :=\ncomm_group.to_group_injective $ group.ext h_mul\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/group/ext.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979746, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.4705018957421266}}
{"text": "lemma maze (P Q R S T U: Prop)\n(p : P)\n(h : P → Q)\n(i : Q → R)\n(j : Q → T)\n(k : S → T)\n(l : T → U)\n: U :=\nbegin\n    have q := h(p),\n    have t := j(q),\n    have u := l(t),\n    exact u,\nend", "meta": {"author": "nomoid", "repo": "lean-proofs", "sha": "b9f03a24623d1a1d111d6c2bbf53c617e2596d6a", "save_path": "github-repos/lean/nomoid-lean-proofs", "path": "github-repos/lean/nomoid-lean-proofs/lean-proofs-b9f03a24623d1a1d111d6c2bbf53c617e2596d6a/src/world6/level3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.831143031127974, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.47044236101750364}}
{"text": "import Lean\nimport Advent.List\n\nclass QueueData (α : Type u) where\n  init: List α \n  tail: List α\n\nnamespace QueueData\ndef toList (q: QueueData α): List α := q.init ++ q.tail.reverse\n\ndef send (q: QueueData α) (a: α): QueueData α := {q with tail := a :: q.tail}\n\ndef pull (q: QueueData α) : Option (α × QueueData α) :=\n  match q.init with\n  | x :: xs  => some (x, ⟨xs, tail⟩)\n  | [] => match q.tail.reverse with \n    | x :: xs => some (x, ⟨xs, []⟩)\n    | []      => none\n\ndef isEmpty (q: QueueData α) : Bool := \n  q.init.isEmpty && q.tail.isEmpty\n\n\ndef rel (a b : QueueData α): Prop := a.toList = b.toList\n\ntheorem nonEmptyAppend {xs ys: List α} {x: α} (p: xs ++ (x :: ys) = []) : False := \n  by cases xs <;> simp at p\n\ntheorem isEmptyToList (q: QueueData α): q.isEmpty <-> q.toList = [] := by\n  simp [isEmpty, toList, List.isEmpty]\n  cases q.init <;> cases q.tail <;> simp\n  case cons h t => \n  simp\n  intro p\n  apply nonEmptyAppend p\n\ntheorem emptyPull {q: QueueData α}: q.toList = [] <-> q.pull = none := by\n  simp [toList, pull]\n  cases q.init <;> cases q.tail <;> simp\n  case cons h t => \n  constructor\n  generalize t.reverse = rt\n  . intro q\n    let u := nonEmptyAppend q\n    contradiction\n  . generalize up: List.reverse t ++ [h] = u\n    intro q\n    cases u <;> simp at q <;> simp\n\ntheorem nonEmptyPull {q: QueueData α} {x : α} {xs: List α}: \n  q.toList = x :: xs  <-> (exists (qt: QueueData α), qt.toList = xs ∧ q.pull = some (x, qt)) := by\n  simp [toList, pull]\n  cases q.init \n  generalize p : q.tail.reverse = tr\n  . cases tr <;> simp\n    . intro e\n      cases e\n      assumption\n    . case cons h t => \n      constructor\n      . intro p1 \n        exists ⟨ t , []⟩\n        simp [*]\n      . intro qe\n        cases qe with | intro qt p1 => \n        cases qt with | mk qi qt =>\n        simp [*]\n        let p2 := p1.right.right\n        simp at p1\n        let p3 := congrArg (·.init) p2\n        let p4 := congrArg (·.tail) p2\n        simp at p3 p4\n        rw [← p3, ← p4] at p1\n        simp at p1\n        simp [p1]\n\n  . case cons h t => \n    simp\n    constructor\n    . intro pp\n      let qt: QueueData α := ⟨ t, q.tail ⟩\n      exists qt\n      simp\n      rw [pp.left, pp.right]    \n      simp\n    . intro qe\n      cases qe with | intro qt pp =>  \n      cases pp with | intro p1 p2 =>\n      cases p2 with | intro p2 p3 => \n      cases qt with | mk qti qtt => \n      rw [p2, ← p1]\n      simp\n      let p4 := congrArg (·.init) p3\n      let p5 := congrArg (·.tail) p3\n      simp at p4 p5\n      rw [p4, p5]\n\nend QueueData\n\ndef EqvSetoid {α : Type u} (f: α -> β): Setoid α := {\n  r := λ x y => f x = f y\n  iseqv := {\n    refl := by simp [QueueData.rel]\n    symm := by intros _ _ p; simp [QueueData.rel]; rw [p]\n    trans := by intros _ _ _ p q; simp [QueueData.rel]; rw [p, q] \n  }\n}\n\ndef QueueIsEqualUnderToList (α : Type u): Setoid (QueueData α) := EqvSetoid <| QueueData.toList\n\ndef Queue (α : Type u) := Quotient (QueueIsEqualUnderToList α) \n\nnamespace Queue\n\nvariable (q: Queue α)\n\ndef toList: List α := \n  q.lift (·.toList) <| by intros; assumption\n\ndef send (x: α): Queue α := \n  q.lift (fun qd => Quot.mk _ (qd.send x)) <| by\n    simp [HasEquiv.Equiv]\n    unfold Setoid.r\n    intros a b p\n    cases a; case mk ia ta =>\n    cases b; case mk ib tb => \n    simp [QueueData.send]\n    apply Quot.sound\n    simp [QueueIsEqualUnderToList, EqvSetoid, QueueData.rel, QueueData.toList]\n    repeat rw [← List.append_assoc]\n    simp [QueueIsEqualUnderToList, EqvSetoid, QueueData.rel, QueueData.toList] at p\n    rw [p]\n    \ndef pull: Option (α × Queue α) :=\n  q.lift (fun qd => qd.pull.map (fun (a, xs) => (a, Quot.mk _ xs))) <| by\n  intros a b p\n  simp \n  generalize p1: a.isEmpty = aempty\n  cases aempty\n  . generalize p2 : a.toList = al \n    cases al\n    . rw [← QueueData.isEmptyToList, p1] at p2\n      contradiction\n    . case cons h t => \n      let p3 := p2\n      rw [QueueData.nonEmptyPull] at p3\n      rw [p, QueueData.nonEmptyPull] at p2\n      cases p3 with | intro bqa p5 =>\n      cases p2 with | intro bqt p6 =>\n      simp [p5, p6, Option.map]\n      apply Quot.sound\n      simp [QueueIsEqualUnderToList, EqvSetoid, QueueData.rel]\n      rw [p5.left, p6.left]\n  . rw [QueueData.isEmptyToList] at p1\n    let p2 := p1\n    rw [QueueData.emptyPull] at p2\n    rw [p, QueueData.emptyPull] at p1\n    rw [p1, p2]\n\ndef isEmpty: Bool := \n  q.lift (·.isEmpty) <| by\n  intros a b p\n  simp\n  generalize pe: a.isEmpty = ae\n  cases ae\n  . generalize pl: a.toList = al\n    cases al\n    . rewrite [←QueueData.isEmptyToList] at pl\n      rw [pe] at pl\n      contradiction\n    . rw [p] at pl\n      generalize pe2: b.isEmpty = be\n      cases be <;> simp\n      rw [QueueData.isEmptyToList, pl] at pe2\n      contradiction\n  . rw [QueueData.isEmptyToList, p, ←QueueData.isEmptyToList] at pe\n    rw [pe]\n\ndef empty: Queue α :=   Quot.mk _ ⟨[], []⟩\n\ndef peak: Option α := q.pull.map (·.1)\n\ndef tail: Queue α := (q.pull.map (·.2) ).getD empty\n\ndef sendMany [ForIn Id ρ α](xs: ρ) : Id (Queue α) := do\n  let mut q := q\n  for x in xs do\n    q := q.send x\n  return q\n\ninstance: Inhabited (Queue α) where\n  default := empty\n\ninstance [ToString α]: ToString (Queue α) where\n  toString q := \"Queue\" ++ q.toList.toString   \n\ninstance [Lean.ToJson α]: Lean.ToJson (Queue α) where\n  toJson q := Lean.ToJson.toJson q.toList\n\ninstance : ForIn m (Queue α) α where\n  forIn q b f := q.toList.forIn b f\n\ninstance [BEq α] : BEq (Queue α) where\n  beq xs ys := xs.toList == ys.toList\n\nend Queue", "meta": {"author": "Odomontois", "repo": "advent2022-lean", "sha": "75634a2257287ec1536690f8dbd92573f670e0e2", "save_path": "github-repos/lean/Odomontois-advent2022-lean", "path": "github-repos/lean/Odomontois-advent2022-lean/advent2022-lean-75634a2257287ec1536690f8dbd92573f670e0e2/Advent/Queue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.470427685597577}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport algebra.group.inj_surj\nimport algebra.group.commute\nimport algebra.hom.equiv\nimport algebra.opposites\nimport data.int.cast.defs\n\n/-!\n# Group structures on the multiplicative and additive opposites\n-/\nuniverses u v\nvariables (α : Type u)\n\nnamespace mul_opposite\n\n/-!\n### Additive structures on `αᵐᵒᵖ`\n-/\n\ninstance [add_semigroup α] : add_semigroup (αᵐᵒᵖ) :=\nunop_injective.add_semigroup _ (λ x y, rfl)\n\ninstance [add_left_cancel_semigroup α] : add_left_cancel_semigroup αᵐᵒᵖ :=\nunop_injective.add_left_cancel_semigroup _ (λ x y, rfl)\n\ninstance [add_right_cancel_semigroup α] : add_right_cancel_semigroup αᵐᵒᵖ :=\nunop_injective.add_right_cancel_semigroup _ (λ x y, rfl)\n\ninstance [add_comm_semigroup α] : add_comm_semigroup αᵐᵒᵖ :=\nunop_injective.add_comm_semigroup _ (λ x y, rfl)\n\ninstance [add_zero_class α] : add_zero_class αᵐᵒᵖ :=\nunop_injective.add_zero_class _ rfl (λ x y, rfl)\n\ninstance [add_monoid α] : add_monoid αᵐᵒᵖ :=\nunop_injective.add_monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_monoid_with_one α] : add_monoid_with_one αᵐᵒᵖ :=\n{ nat_cast := λ n, op n,\n  nat_cast_zero := show op ((0 : ℕ) : α) = 0, by simp,\n  nat_cast_succ := show ∀ n, op ((n + 1 : ℕ) : α) = op (n : ℕ) + 1, by simp,\n  .. mul_opposite.add_monoid α, .. mul_opposite.has_one α }\n\ninstance [add_comm_monoid α] : add_comm_monoid αᵐᵒᵖ :=\nunop_injective.add_comm_monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [sub_neg_monoid α] : sub_neg_monoid αᵐᵒᵖ :=\nunop_injective.sub_neg_monoid _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_group α] : add_group αᵐᵒᵖ :=\nunop_injective.add_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [add_group_with_one α] : add_group_with_one αᵐᵒᵖ :=\n{ int_cast := λ n, op n,\n  int_cast_of_nat := λ n, show op ((n : ℤ) : α) = op n, by rw int.cast_coe_nat,\n  int_cast_neg_succ_of_nat := λ n, show op _ = op (- unop (op ((n + 1 : ℕ) : α))),\n    by erw [unop_op, int.cast_neg_succ_of_nat]; refl,\n  .. mul_opposite.add_monoid_with_one α, .. mul_opposite.add_group α }\n\ninstance [add_comm_group α] : add_comm_group αᵐᵒᵖ :=\nunop_injective.add_comm_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\n/-!\n### Multiplicative structures on `αᵐᵒᵖ`\n\nWe also generate additive structures on `αᵃᵒᵖ` using `to_additive`\n-/\n\n@[to_additive] instance [semigroup α] : semigroup αᵐᵒᵖ :=\n{ mul_assoc := λ x y z, unop_injective $ eq.symm $ mul_assoc (unop z) (unop y) (unop x),\n  .. mul_opposite.has_mul α }\n\n@[to_additive] instance [right_cancel_semigroup α] : left_cancel_semigroup αᵐᵒᵖ :=\n{ mul_left_cancel := λ x y z H, unop_injective $ mul_right_cancel $ op_injective H,\n  .. mul_opposite.semigroup α }\n\n@[to_additive] instance [left_cancel_semigroup α] : right_cancel_semigroup αᵐᵒᵖ :=\n{ mul_right_cancel := λ x y z H, unop_injective $ mul_left_cancel $ op_injective H,\n  .. mul_opposite.semigroup α }\n\n@[to_additive] instance [comm_semigroup α] : comm_semigroup αᵐᵒᵖ :=\n{ mul_comm := λ x y, unop_injective $ mul_comm (unop y) (unop x),\n  .. mul_opposite.semigroup α }\n\n@[to_additive] instance [mul_one_class α] : mul_one_class αᵐᵒᵖ :=\n{ one_mul := λ x, unop_injective $ mul_one $ unop x,\n  mul_one := λ x, unop_injective $ one_mul $ unop x,\n  .. mul_opposite.has_mul α, .. mul_opposite.has_one α }\n\n@[to_additive] instance [monoid α] : monoid αᵐᵒᵖ :=\n{ npow := λ n x, op $ x.unop ^ n,\n  npow_zero' := λ x, unop_injective $ monoid.npow_zero' x.unop,\n  npow_succ' := λ n x, unop_injective $ pow_succ' x.unop n,\n  .. mul_opposite.semigroup α, .. mul_opposite.mul_one_class α }\n\n@[to_additive] instance [right_cancel_monoid α] : left_cancel_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.left_cancel_semigroup α, .. mul_opposite.monoid α }\n\n@[to_additive] instance [left_cancel_monoid α] : right_cancel_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.right_cancel_semigroup α, .. mul_opposite.monoid α }\n\n@[to_additive] instance [cancel_monoid α] : cancel_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.right_cancel_monoid α, .. mul_opposite.left_cancel_monoid α }\n\n@[to_additive] instance [comm_monoid α] : comm_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.monoid α, .. mul_opposite.comm_semigroup α }\n\n@[to_additive] instance [cancel_comm_monoid α] : cancel_comm_monoid αᵐᵒᵖ :=\n{ .. mul_opposite.cancel_monoid α, .. mul_opposite.comm_monoid α }\n\n@[to_additive add_opposite.sub_neg_monoid] instance [div_inv_monoid α] : div_inv_monoid αᵐᵒᵖ :=\n{ zpow := λ n x, op $ x.unop ^ n,\n  zpow_zero' := λ x, unop_injective $ div_inv_monoid.zpow_zero' x.unop,\n  zpow_succ' := λ n x, unop_injective $\n    by rw [unop_op, zpow_of_nat, zpow_of_nat, pow_succ', unop_mul, unop_op],\n  zpow_neg' := λ z x, unop_injective $ div_inv_monoid.zpow_neg' z x.unop,\n  .. mul_opposite.monoid α, .. mul_opposite.has_inv α }\n\n@[to_additive add_opposite.subtraction_monoid] instance [division_monoid α] :\n  division_monoid αᵐᵒᵖ :=\n{ mul_inv_rev := λ a b, unop_injective $ mul_inv_rev _ _,\n  inv_eq_of_mul := λ a b h, unop_injective $ inv_eq_of_mul_eq_one_left $ congr_arg unop h,\n  .. mul_opposite.div_inv_monoid α, .. mul_opposite.has_involutive_inv α }\n\n@[to_additive add_opposite.subtraction_comm_monoid] instance [division_comm_monoid α] :\n  division_comm_monoid αᵐᵒᵖ :=\n{ ..mul_opposite.division_monoid α, ..mul_opposite.comm_semigroup α }\n\n@[to_additive] instance [group α] : group αᵐᵒᵖ :=\n{ mul_left_inv := λ x, unop_injective $ mul_inv_self $ unop x,\n  .. mul_opposite.div_inv_monoid α, }\n\n@[to_additive] instance [comm_group α] : comm_group αᵐᵒᵖ :=\n{ .. mul_opposite.group α, .. mul_opposite.comm_monoid α }\n\nvariable {α}\n\n@[simp, to_additive] lemma unop_div [div_inv_monoid α] (x y : αᵐᵒᵖ) :\n  unop (x / y) = (unop y)⁻¹ * unop x :=\nrfl\n\n@[simp, to_additive] lemma op_div [div_inv_monoid α] (x y : α) :\n  op (x / y) = (op y)⁻¹ * op x :=\nby simp [div_eq_mul_inv]\n\n@[simp, to_additive] lemma semiconj_by_op [has_mul α] {a x y : α} :\n  semiconj_by (op a) (op y) (op x) ↔ semiconj_by a x y :=\nby simp only [semiconj_by, ← op_mul, op_inj, eq_comm]\n\n@[simp, to_additive] lemma semiconj_by_unop [has_mul α] {a x y : αᵐᵒᵖ} :\n  semiconj_by (unop a) (unop y) (unop x) ↔ semiconj_by a x y :=\nby conv_rhs { rw [← op_unop a, ← op_unop x, ← op_unop y, semiconj_by_op] }\n\n@[to_additive] lemma _root_.semiconj_by.op [has_mul α] {a x y : α} (h : semiconj_by a x y) :\n  semiconj_by (op a) (op y) (op x) :=\nsemiconj_by_op.2 h\n\n@[to_additive] lemma _root_.semiconj_by.unop [has_mul α] {a x y : αᵐᵒᵖ} (h : semiconj_by a x y) :\n  semiconj_by (unop a) (unop y) (unop x) :=\nsemiconj_by_unop.2 h\n\n@[to_additive] lemma _root_.commute.op [has_mul α] {x y : α} (h : commute x y) :\n  commute (op x) (op y) := h.op\n\n@[to_additive] lemma commute.unop [has_mul α] {x y : αᵐᵒᵖ} (h : commute x y) :\n  commute (unop x) (unop y) := h.unop\n\n@[simp, to_additive] lemma commute_op [has_mul α] {x y : α} :\n  commute (op x) (op y) ↔ commute x y :=\nsemiconj_by_op\n\n@[simp, to_additive] lemma commute_unop [has_mul α] {x y : αᵐᵒᵖ} :\n  commute (unop x) (unop y) ↔ commute x y :=\nsemiconj_by_unop\n\n/-- The function `mul_opposite.op` is an additive equivalence. -/\n@[simps { fully_applied := ff, simp_rhs := tt }]\ndef op_add_equiv [has_add α] : α ≃+ αᵐᵒᵖ :=\n{ map_add' := λ a b, rfl, .. op_equiv }\n\n@[simp] lemma op_add_equiv_to_equiv [has_add α] :\n  (op_add_equiv : α ≃+ αᵐᵒᵖ).to_equiv = op_equiv :=\nrfl\n\nend mul_opposite\n\n/-!\n### Multiplicative structures on `αᵃᵒᵖ`\n-/\n\nnamespace add_opposite\n\ninstance [semigroup α] : semigroup (αᵃᵒᵖ) :=\nunop_injective.semigroup _ (λ x y, rfl)\n\ninstance [left_cancel_semigroup α] : left_cancel_semigroup αᵃᵒᵖ :=\nunop_injective.left_cancel_semigroup _ (λ x y, rfl)\n\ninstance [right_cancel_semigroup α] : right_cancel_semigroup αᵃᵒᵖ :=\nunop_injective.right_cancel_semigroup _ (λ x y, rfl)\n\ninstance [comm_semigroup α] : comm_semigroup αᵃᵒᵖ :=\nunop_injective.comm_semigroup _ (λ x y, rfl)\n\ninstance [mul_one_class α] : mul_one_class αᵃᵒᵖ :=\nunop_injective.mul_one_class _ rfl (λ x y, rfl)\n\ninstance {β} [has_pow α β] : has_pow αᵃᵒᵖ β := { pow := λ a b, op (unop a ^ b) }\n\n@[simp] lemma op_pow {β} [has_pow α β] (a : α) (b : β) : op (a ^ b) = op a ^ b := rfl\n@[simp] lemma unop_pow {β} [has_pow α β] (a : αᵃᵒᵖ) (b : β) : unop (a ^ b) = unop a ^ b := rfl\n\ninstance [monoid α] : monoid αᵃᵒᵖ :=\nunop_injective.monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [comm_monoid α] : comm_monoid αᵃᵒᵖ :=\nunop_injective.comm_monoid _ rfl (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [div_inv_monoid α] : div_inv_monoid αᵃᵒᵖ :=\nunop_injective.div_inv_monoid _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [group α] : group αᵃᵒᵖ :=\nunop_injective.group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [comm_group α] : comm_group αᵃᵒᵖ :=\nunop_injective.comm_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\nvariable {α}\n\n/-- The function `add_opposite.op` is a multiplicative equivalence. -/\n@[simps { fully_applied := ff, simp_rhs := tt }]\ndef op_mul_equiv [has_mul α] : α ≃* αᵃᵒᵖ :=\n{ map_mul' := λ a b, rfl, .. op_equiv }\n\n@[simp] lemma op_mul_equiv_to_equiv [has_mul α] :\n  (op_mul_equiv : α ≃* αᵃᵒᵖ).to_equiv = op_equiv :=\nrfl\n\nend add_opposite\n\nopen mul_opposite\n\n/-- Inversion on a group is a `mul_equiv` to the opposite group. When `G` is commutative, there is\n`mul_equiv.inv`. -/\n@[to_additive \"Negation on an additive group is an `add_equiv` to the opposite group. When `G`\nis commutative, there is `add_equiv.inv`.\", simps { fully_applied := ff, simp_rhs := tt }]\ndef mul_equiv.inv' (G : Type*) [division_monoid G] : G ≃* Gᵐᵒᵖ :=\n{ map_mul' := λ x y, unop_injective $ mul_inv_rev x y,\n  .. (equiv.inv G).trans op_equiv }\n\n/-- A semigroup homomorphism `f : M →ₙ* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism to `Nᵐᵒᵖ`. -/\n@[to_additive \"An additive semigroup homomorphism `f : add_hom M N` such that `f x` additively\ncommutes with `f y` for all `x, y` defines an additive semigroup homomorphism to `Sᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.to_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M →ₙ* N)\n  (hf : ∀ x y, commute (f x) (f y)) : M →ₙ* Nᵐᵒᵖ :=\n{ to_fun := mul_opposite.op ∘ f,\n  map_mul' := λ x y, by simp [(hf x y).eq] }\n\n/-- A semigroup homomorphism `f : M →ₙ* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism from `Mᵐᵒᵖ`. -/\n@[to_additive \"An additive semigroup homomorphism `f : add_hom M N` such that `f x` additively\ncommutes with `f y` for all `x`, `y` defines an additive semigroup homomorphism from `Mᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.from_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M →ₙ* N)\n  (hf : ∀ x y, commute (f x) (f y)) : Mᵐᵒᵖ →ₙ* N :=\n{ to_fun := f ∘ mul_opposite.unop,\n  map_mul' := λ x y, (f.map_mul _ _).trans (hf _ _).eq }\n\n/-- A monoid homomorphism `f : M →* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism to `Nᵐᵒᵖ`. -/\n@[to_additive \"An additive monoid homomorphism `f : M →+ N` such that `f x` additively commutes\nwith `f y` for all `x, y` defines an additive monoid homomorphism to `Sᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.to_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M →* N)\n  (hf : ∀ x y, commute (f x) (f y)) : M →* Nᵐᵒᵖ :=\n{ to_fun := mul_opposite.op ∘ f,\n  map_one' := congr_arg op f.map_one,\n  map_mul' := λ x y, by simp [(hf x y).eq] }\n\n/-- A monoid homomorphism `f : M →* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism from `Mᵐᵒᵖ`. -/\n@[to_additive \"An additive monoid homomorphism `f : M →+ N` such that `f x` additively commutes\nwith `f y` for all `x`, `y` defines an additive monoid homomorphism from `Mᵃᵒᵖ`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.from_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M →* N)\n  (hf : ∀ x y, commute (f x) (f y)) : Mᵐᵒᵖ →* N :=\n{ to_fun := f ∘ mul_opposite.unop,\n  map_one' := f.map_one,\n  map_mul' := λ x y, (f.map_mul _ _).trans (hf _ _).eq }\n\n/-- The units of the opposites are equivalent to the opposites of the units. -/\n@[to_additive \"The additive units of the additive opposites are equivalent to the additive opposites\nof the additive units.\"]\ndef units.op_equiv {M} [monoid M] : (Mᵐᵒᵖ)ˣ ≃* (Mˣ)ᵐᵒᵖ :=\n{ to_fun := λ u, op ⟨unop u, unop ↑(u⁻¹), op_injective u.4, op_injective u.3⟩,\n  inv_fun := mul_opposite.rec $ λ u, ⟨op ↑(u), op ↑(u⁻¹), unop_injective $ u.4, unop_injective u.3⟩,\n  map_mul' := λ x y, unop_injective $ units.ext $ rfl,\n  left_inv := λ x, units.ext $ by simp,\n  right_inv := λ x, unop_injective $ units.ext $ rfl }\n\n@[simp, to_additive]\nlemma units.coe_unop_op_equiv {M} [monoid M] (u : (Mᵐᵒᵖ)ˣ) :\n  ((units.op_equiv u).unop : M) = unop (u : Mᵐᵒᵖ) :=\nrfl\n\n@[simp, to_additive]\nlemma units.coe_op_equiv_symm {M} [monoid M] (u : (Mˣ)ᵐᵒᵖ) :\n  (units.op_equiv.symm u : Mᵐᵒᵖ) = op (u.unop : M) :=\nrfl\n\n/-- A semigroup homomorphism `M →ₙ* N` can equivalently be viewed as a semigroup homomorphism\n`Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[to_additive \"An additive semigroup homomorphism `add_hom M N` can equivalently be viewed as an\nadditive semigroup homomorphism `add_hom Mᵃᵒᵖ Nᵃᵒᵖ`. This is the action of the (fully faithful)\n`ᵃᵒᵖ`-functor on morphisms.\", simps]\ndef mul_hom.op {M N} [has_mul M] [has_mul N] :\n  (M →ₙ* N) ≃ (Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun   := op ∘ f ∘ unop,\n                      map_mul' := λ x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := λ f, { to_fun   := unop ∘ f ∘ op,\n                      map_mul' := λ x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext x, simp } }\n\n/-- The 'unopposite' of a semigroup homomorphism `Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ`. Inverse to `mul_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive semigroup homomorphism `Mᵃᵒᵖ →ₙ+ Nᵃᵒᵖ`. Inverse\nto `add_hom.op`.\"]\ndef mul_hom.unop {M N} [has_mul M] [has_mul N] :\n  (Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ) ≃ (M →ₙ* N) := mul_hom.op.symm\n\n/-- An additive semigroup homomorphism `add_hom M N` can equivalently be viewed as an additive\nhomomorphism `add_hom Mᵐᵒᵖ Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on\nmorphisms. -/\n@[simps]\ndef add_hom.mul_op {M N} [has_add M] [has_add N] :\n  (add_hom M N) ≃ (add_hom Mᵐᵒᵖ Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun    := op ∘ f ∘ unop,\n                      map_add'  := λ x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := λ f, { to_fun    := unop ∘ f ∘ op,\n                      map_add'  := λ x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive semigroup hom `αᵐᵒᵖ →+ βᵐᵒᵖ`. Inverse to\n`add_hom.mul_op`. -/\n@[simp] def add_hom.mul_unop {α β} [has_add α] [has_add β] :\n  (add_hom αᵐᵒᵖ βᵐᵒᵖ) ≃ (add_hom α β) := add_hom.mul_op.symm\n\n/-- A monoid homomorphism `M →* N` can equivalently be viewed as a monoid homomorphism\n`Mᵐᵒᵖ →* Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[to_additive \"An additive monoid homomorphism `M →+ N` can equivalently be viewed as an\nadditive monoid homomorphism `Mᵃᵒᵖ →+ Nᵃᵒᵖ`. This is the action of the (fully faithful)\n`ᵃᵒᵖ`-functor on morphisms.\", simps]\ndef monoid_hom.op {M N} [mul_one_class M] [mul_one_class N] :\n  (M →* N) ≃ (Mᵐᵒᵖ →* Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun   := op ∘ f ∘ unop,\n                      map_one' := congr_arg op f.map_one,\n                      map_mul' := λ x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := λ f, { to_fun   := unop ∘ f ∘ op,\n                      map_one' := congr_arg unop f.map_one,\n                      map_mul' := λ x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext x, simp } }\n\n/-- The 'unopposite' of a monoid homomorphism `Mᵐᵒᵖ →* Nᵐᵒᵖ`. Inverse to `monoid_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive monoid homomorphism `Mᵃᵒᵖ →+ Nᵃᵒᵖ`. Inverse to\n`add_monoid_hom.op`.\"]\ndef monoid_hom.unop {M N} [mul_one_class M] [mul_one_class N] :\n  (Mᵐᵒᵖ →* Nᵐᵒᵖ) ≃ (M →* N) := monoid_hom.op.symm\n\n/-- An additive homomorphism `M →+ N` can equivalently be viewed as an additive homomorphism\n`Mᵐᵒᵖ →+ Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[simps]\ndef add_monoid_hom.mul_op {M N} [add_zero_class M] [add_zero_class N] :\n  (M →+ N) ≃ (Mᵐᵒᵖ →+ Nᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun    := op ∘ f ∘ unop,\n                      map_zero' := unop_injective f.map_zero,\n                      map_add'  := λ x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := λ f, { to_fun    := unop ∘ f ∘ op,\n                      map_zero' := congr_arg unop f.map_zero,\n                      map_add'  := λ x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive monoid hom `αᵐᵒᵖ →+ βᵐᵒᵖ`. Inverse to\n`add_monoid_hom.mul_op`. -/\n@[simp] def add_monoid_hom.mul_unop {α β} [add_zero_class α] [add_zero_class β] :\n  (αᵐᵒᵖ →+ βᵐᵒᵖ) ≃ (α →+ β) := add_monoid_hom.mul_op.symm\n\n/-- A iso `α ≃+ β` can equivalently be viewed as an iso `αᵐᵒᵖ ≃+ βᵐᵒᵖ`. -/\n@[simps]\ndef add_equiv.mul_op {α β} [has_add α] [has_add β] :\n  (α ≃+ β) ≃ (αᵐᵒᵖ ≃+ βᵐᵒᵖ) :=\n{ to_fun    := λ f, op_add_equiv.symm.trans (f.trans op_add_equiv),\n  inv_fun   := λ f, op_add_equiv.trans (f.trans op_add_equiv.symm),\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `αᵐᵒᵖ ≃+ βᵐᵒᵖ`. Inverse to `add_equiv.mul_op`. -/\n@[simp] def add_equiv.mul_unop {α β} [has_add α] [has_add β] :\n  (αᵐᵒᵖ ≃+ βᵐᵒᵖ) ≃ (α ≃+ β) := add_equiv.mul_op.symm\n\n/-- A iso `α ≃* β` can equivalently be viewed as an iso `αᵐᵒᵖ ≃* βᵐᵒᵖ`. -/\n@[to_additive \"A iso `α ≃+ β` can equivalently be viewed as an iso `αᵃᵒᵖ ≃+ βᵃᵒᵖ`.\", simps]\ndef mul_equiv.op {α β} [has_mul α] [has_mul β] :\n  (α ≃* β) ≃ (αᵐᵒᵖ ≃* βᵐᵒᵖ) :=\n{ to_fun    := λ f, { to_fun   := op ∘ f ∘ unop,\n                      inv_fun  := op ∘ f.symm ∘ unop,\n                      left_inv := λ x, unop_injective (f.symm_apply_apply x.unop),\n                      right_inv := λ x, unop_injective (f.apply_symm_apply x.unop),\n                      map_mul' := λ x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := λ f, { to_fun   := unop ∘ f ∘ op,\n                      inv_fun  := unop ∘ f.symm ∘ op,\n                      left_inv := λ x, by simp,\n                      right_inv := λ x, by simp,\n                      map_mul' := λ x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := λ f, by { ext, refl },\n  right_inv := λ f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `αᵐᵒᵖ ≃* βᵐᵒᵖ`. Inverse to `mul_equiv.op`. -/\n@[simp, to_additive \"The 'unopposite' of an iso `αᵃᵒᵖ ≃+ βᵃᵒᵖ`. Inverse to `add_equiv.op`.\"]\ndef mul_equiv.unop {α β} [has_mul α] [has_mul β] :\n  (αᵐᵒᵖ ≃* βᵐᵒᵖ) ≃ (α ≃* β) := mul_equiv.op.symm\n\nsection ext\n\n/-- This ext lemma change equalities on `αᵐᵒᵖ →+ β` to equalities on `α →+ β`.\nThis is useful because there are often ext lemmas for specific `α`s that will apply\nto an equality of `α →+ β` such as `finsupp.add_hom_ext'`. -/\n@[ext]\nlemma add_monoid_hom.mul_op_ext {α β} [add_zero_class α] [add_zero_class β]\n  (f g : αᵐᵒᵖ →+ β)\n  (h : f.comp (op_add_equiv : α ≃+ αᵐᵒᵖ).to_add_monoid_hom =\n       g.comp (op_add_equiv : α ≃+ αᵐᵒᵖ).to_add_monoid_hom) : f = g :=\nadd_monoid_hom.ext $ mul_opposite.rec $ λ x, (add_monoid_hom.congr_fun h : _) x\n\nend ext\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/group/opposite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.47042768109971456}}
{"text": "/-\nCopyright (c) 2021 Alex J. Best. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alex J. Best\n-/\n-- Note: This is https://github.com/leanprover-community/flt-regular/blob/master/src/ring_theory/polynomial/homogenization.lean\n\nimport data.mv_polynomial.comm_ring\nimport data.set.finite\nimport ring_theory.polynomial.homogeneous\nimport ring_theory.polynomial.basic\nimport order.symm_diff\nimport tactic.omega\n-- import home_finder\n\n/-!\n# Homogenization\n\n## Main definitions\n\n* `mv_polynomial.homogenization`\n\n## Main statements\n\n* foo_bar_unique\n\n## Notation\n\n\n\n## Implementation details\n\n* We homogenize polynomials over a given ground set of variables, rather than adjoining an extra\n  variable to give the user more choice in the type of the polynomials involved.\n\n## References\n\n* [F. Bar, *Quuxes*][]\n\n## Tags\n\n\n-/\n\nvariables {R ι : Type*} [comm_semiring R]\n\nopen polynomial finset mv_polynomial\n\nopen_locale big_operators\nnoncomputable theory\nnamespace mv_polynomial\n\nsection leading_terms\n-- TODO is this the best def?\n/-- The sum of the monomials of highest degree of a multivariate polynomial. -/\ndef leading_terms (p : mv_polynomial ι R) : mv_polynomial ι R :=\nhomogeneous_component p.total_degree p\n\nlemma leading_terms_apply (p : mv_polynomial ι R) : p.leading_terms =\n  ∑ d in p.support.filter (λ d, ∑ i in d.support, d i = p.total_degree), monomial d (coeff d p) :=\nhomogeneous_component_apply _ _\n-- (p.support.filter (λ s : ι →₀ ℕ, s.sum (λ _ e, e) = p.total_degree)).sum $\n--   λ s, monomial s (p.coeff s)\n\n@[simp]\nlemma leading_terms_zero : (0 : mv_polynomial ι R).leading_terms = 0 :=\nby simp [leading_terms]\n\nlemma finset.filter_eq_self_iff {α : Type*} (S : finset α) (h : α → Prop) [decidable_pred h] :\n  S.filter h = S ↔ ∀ s ∈ S, h s :=\nbegin\n  cases S,\n  simp only [finset.filter, finset.mem_mk, multiset.filter_eq_self],\nend\n\n-- TODO for non-zero polys this is true that p.lead = p iff p.is_homogenous n for a fixed n\n-- TODO generalize to p.homog comp = n\nlemma leading_terms_eq_self_iff_is_homogeneous (p : mv_polynomial ι R) :\n  p.leading_terms = p ↔ p.is_homogeneous p.total_degree :=\nbegin\n  split; intro h,\n  { rw is_homogeneous,\n    contrapose! h,\n    rcases h with ⟨h_w, h_h₁, h_h₂⟩,\n    rw [leading_terms, ne.def, mv_polynomial.ext_iff],\n    push_neg,\n    use h_w,\n    classical,\n    change ¬ h_w.sum (λ (_x : ι) (e : ℕ), e) = p.total_degree at h_h₂,\n    simp only [h_h₁.symm, coeff_homogeneous_component, exists_prop, and_true, ne.def, not_false_iff,\n      not_forall, ite_eq_left_iff],\n    convert h_h₂, },\n  { rw [leading_terms_apply],\n    rw (_ : p.support.filter (λ (s : ι →₀ ℕ), ∑ (i : ι) in s.support, s i = p.total_degree)\n            = p.support),\n    { rw support_sum_monomial_coeff p, },\n    { rw finset.filter_eq_self_iff,\n      intros s hs,\n      rw [mem_support_iff] at hs,\n      rw ← h hs, }, },\nend\n\n@[simp]\nlemma leading_terms_C (r : R) : (C r : mv_polynomial ι R).leading_terms = C r :=\nbegin\n  rw leading_terms_eq_self_iff_is_homogeneous,\n  convert is_homogeneous_C _ _,\n  simp,\nend\n\nlemma is_homogeneous_leading_terms (p : mv_polynomial ι R) :\n  p.leading_terms.is_homogeneous p.total_degree :=\nhomogeneous_component_is_homogeneous (total_degree p) p\n\nlemma exists_coeff_ne_zero_total_degree {p : mv_polynomial ι R} (hp : p ≠ 0) :\n  ∃ (v : ι →₀ ℕ), v.sum (λ _ e, e) = p.total_degree ∧ p.coeff v ≠ 0 :=\nbegin\n  obtain ⟨b, hb₁, hb₂⟩ := p.support.exists_mem_eq_sup (finsupp.support_nonempty_iff.mpr hp)\n    (λ (m : ι →₀ ℕ), m.to_multiset.card),\n  use b,\n  split,\n  { rw ← total_degree_eq p at hb₂,\n    rw hb₂,\n    dsimp, -- TODO break this out as a lemma\n    funext m,\n    exact (finsupp.card_to_multiset _).symm, },\n  { exact mem_support_iff.mp hb₁, },\nend\n\n-- TODO mathlib\n@[simp] lemma support_eq_empty {f : mv_polynomial ι R} : f.support = ∅ ↔ f = 0 :=\nfinsupp.support_eq_empty\n\nlemma support_add_eq [decidable_eq ι] {g₁ g₂ : mv_polynomial ι R}\n  (h : disjoint g₁.support g₂.support) : (g₁ + g₂).support = g₁.support ∪ g₂.support :=\nfinsupp.support_add_eq h\n\nlemma support_sum_monomial_subset (S : finset (ι →₀ ℕ)) (f : (ι →₀ ℕ) → R) :\n  support (∑ v in S, monomial v (f v)) ⊆ S :=\nbegin\n  classical,\n  induction S using finset.induction with s S hs hsi,\n  { simp, },\n  { rw finset.sum_insert hs,\n    apply finset.subset.trans support_add,\n    apply finset.union_subset,\n    { apply finset.subset.trans support_monomial_subset (finset.subset_union_left _ S), },\n    { apply finset.subset.trans hsi (finset.subset_insert _ _), }, },\nend\n\nlemma support_sum_monomial_eq [decidable_eq R] (S : finset (ι →₀ ℕ)) (f : (ι →₀ ℕ) → R) :\n  support (∑ v in S, monomial v (f v)) = S.filter (λ v, f v ≠ 0) :=\nbegin\n  letI := classical.dec_eq ι,\n  induction S using finset.induction with s S hs hsi,\n  { simp, },\n  rw [finset.sum_insert hs, support_add_eq],\n  { rw [hsi, filter_congr_decidable, filter_insert, support_monomial],\n    split_ifs with h;\n    { simp [h, insert_eq], }, },\n  { apply disjoint_of_subset_left support_monomial_subset,\n    apply disjoint_of_subset_right (support_sum_monomial_subset _ _),\n    simp [support_sum_monomial_subset, hs], },\nend\n\nlemma sum_monomial_ne_zero_of_exists_mem_ne_zero (S : finset (ι →₀ ℕ)) (f : (ι →₀ ℕ) → R)\n  (h : ∃ (s) (hs : s ∈ S), f s ≠ 0) : ∑ (s : ι →₀ ℕ) in S, monomial s (f s) ≠ 0 :=\nbegin\n  classical,\n  simp only [← support_eq_empty, support_sum_monomial_eq, filter_congr_decidable, ne.def],\n  rcases h with ⟨s, h_S, h_s⟩,\n  exact ne_empty_of_mem (mem_filter.mpr ⟨h_S, h_s⟩),\nend\n\nlemma leading_terms_ne_zero {p : mv_polynomial ι R} (hp : p ≠ 0) : p.leading_terms ≠ 0 :=\nbegin\n  classical,\n  rw leading_terms_apply,\n  apply sum_monomial_ne_zero_of_exists_mem_ne_zero,\n  simp only [exists_prop, mem_support_iff, finset.mem_filter],\n  convert exists_coeff_ne_zero_total_degree hp,\n  ext v,\n  change v.sum (λ (_x : ι) (e : ℕ), e) with v.support.sum v,\n  simp [and_comm],\nend\n\n@[simp]\nlemma total_degree_homogenous_component_of_ne_zero {n : ℕ} {p : mv_polynomial ι R}\n  (hp : homogeneous_component n p ≠ 0) :\n  (homogeneous_component n p).total_degree = n :=\nis_homogeneous.total_degree (homogeneous_component_is_homogeneous n p) hp\n\n@[simp]\nlemma total_degree_leading_terms (p : mv_polynomial ι R) :\n  p.leading_terms.total_degree = p.total_degree :=\nbegin\n  by_cases hp : p = 0,\n  { simp [hp], },\n  exact total_degree_homogenous_component_of_ne_zero (leading_terms_ne_zero hp),\nend\n\n-- TODO generalize this to homogeneous component idempotent?\nlemma leading_terms_idempotent (p : mv_polynomial ι R) :\n  p.leading_terms.leading_terms = p.leading_terms :=\nbegin\n  rw [leading_terms_eq_self_iff_is_homogeneous, total_degree_leading_terms],\n  exact is_homogeneous_leading_terms p,\nend\n\nlemma homogeneous_component_add (m  : ℕ) (p q : mv_polynomial ι R) :\n  homogeneous_component m (p + q) = homogeneous_component m p + homogeneous_component m q :=\nby rw [homogeneous_component, linear_map.comp_apply, linear_map.comp_apply, linear_map.comp_apply,\n    linear_map.map_add, linear_map.map_add]\n\nlemma coeff_leading_terms (p : mv_polynomial ι R) (d : ι →₀ ℕ) :\n  coeff d p.leading_terms = if ∑ i in d.support, d i = p.total_degree then coeff d p else 0 :=\ncoeff_homogeneous_component _ _ _\n\nlemma support_homogeneous_component (n : ℕ) (p : mv_polynomial ι R) :\n  (homogeneous_component n p).support = p.support.filter (λ d, d.sum (λ _ m, m) = n) :=\nbegin\n  rw homogeneous_component,\n  simp only [finsupp.restrict_dom_apply, submodule.subtype_apply, function.comp_app,\n    linear_map.coe_comp, set.mem_set_of_eq],\n  erw ← finsupp.support_filter,\n  refl,\nend\n\nlemma support_homogeneous_component_subset (n : ℕ) (p : mv_polynomial ι R) :\n  (homogeneous_component n p).support ⊆ p.support :=\nbegin\n  rw support_homogeneous_component,\n  exact finset.filter_subset _ _,\nend\n\nlemma support_leading_terms (p : mv_polynomial ι R) :\n  p.leading_terms.support = p.support.filter (λ d, d.sum (λ _ m, m) = p.total_degree) :=\nsupport_homogeneous_component _ _\n\nlemma support_leading_terms_subset (p : mv_polynomial ι R) : p.leading_terms.support ⊆ p.support :=\nsupport_homogeneous_component_subset _ _\n\nlemma eq_leading_terms_add (p : mv_polynomial ι R) (hp : p.total_degree ≠ 0) :\n  ∃ p_rest : mv_polynomial ι R,\n    p = p.leading_terms + p_rest ∧ p_rest.total_degree < p.total_degree :=\nbegin\n  letI := classical.dec_eq ι,\n  existsi (∑ (v : ι →₀ ℕ) in p.support \\ p.leading_terms.support, (monomial v) (coeff v p)),\n  split,\n  { nth_rewrite 0 p.leading_terms.as_sum,\n    have : ∀ (x : ι →₀ ℕ) (hx : x ∈ p.leading_terms.support), x.support.sum x = p.total_degree,\n    { intros x hx,\n      rw support_leading_terms at hx,\n      simp at hx,\n      exact hx.2, },\n    simp_rw coeff_leading_terms,\n    conv in (ite _ _ _)\n    { rw [if_pos (this x H)], },\n    have : p.leading_terms.support ⊆ p.support,\n    from support_leading_terms_subset _,\n    have : p.leading_terms.support ∩ p.support = p.leading_terms.support,\n    { rw finset.inter_eq_left_iff_subset,\n      exact this },\n    nth_rewrite 0 ← this,\n    rw [finset.inter_comm, finset.sum_inter_add_sum_diff],\n    exact p.as_sum, },\n  { rw [total_degree, finset.sup_lt_iff],\n    intros b hb,\n    rw support_leading_terms at hb,\n    rw ← finset.filter_not at hb, -- TODO this was also hard to find maybe a negated version is good\n    have := support_sum_monomial_subset _ _ hb,\n    simp only [finset.mem_filter] at this,\n    cases this,\n    rw total_degree,\n    exact lt_of_le_of_ne (finset.le_sup this_left) this_right,\n    rw [bot_eq_zero],\n    exact pos_iff_ne_zero.mpr hp, },\nend\n\nlemma finset.sup_eq_bot_iff {α β : Type*} [semilattice_sup β] [order_bot β] (f : α → β)\n  (S : finset α) : S.sup f = ⊥ ↔ ∀ s ∈ S, f s = ⊥ :=\nbegin\n  classical,\n  induction S using finset.induction with a S haS hi,\n  { simp, },\n  simp [hi],\nend\n\nlemma leading_terms_add_of_total_degree_lt (p q : mv_polynomial ι R)\n  (h : q.total_degree < p.total_degree) : (p + q).leading_terms = p.leading_terms :=\nby rw [leading_terms, leading_terms, total_degree_add_eq_left_of_total_degree_lt h,\n  homogeneous_component_add, homogeneous_component_eq_zero _ q h, add_zero]\n\nlemma finsupp.support_smul_eq {α M R : Type*} [semiring R] [add_comm_monoid M] [module R M]\n  [no_zero_smul_divisors R M] {b : R} (hb : b ≠ 0) {g : α →₀ M} :\n  (b • g).support = g.support :=\nbegin\n  ext a,\n  simp [finsupp.smul_apply, mem_support_iff, ne.def, hb],\nend\n\n@[simp]\nlemma leading_terms_C_mul [no_zero_smul_divisors R R] (p : mv_polynomial ι R) (r : R) :\n  (C r * p).leading_terms = C r * p.leading_terms :=\nbegin\n  by_cases hr : r = 0,\n  { simp [hr], },\n  have : (C r * p).support = p.support,\n  { rw C_mul',\n    exact finsupp.support_smul_eq hr, },\n  rw [leading_terms, leading_terms, total_degree, this, homogeneous_component_C_mul],\n  refl,\nend\n\nlemma eq_C_of_total_degree_zero {p : mv_polynomial ι R} (hp : p.total_degree = 0) :\n  ∃ r : R, p = C r :=\nbegin\n  letI := classical.dec_eq ι,\n  erw finset.sup_eq_bot_iff at hp,\n  simp only [mem_support_iff] at hp,\n  use coeff 0 p,\n  ext,\n  by_cases hm : m = 0,\n  { simp [hm], },\n  rw [coeff_C, if_neg (ne.symm hm)],\n  classical,\n  by_contradiction h,\n  specialize hp m h,\n  apply hm,\n  rw finsupp.sum at hp, -- TODO this and line below could be a lemma, finsupp.sum_eq_zero_iff?\n  simp only [not_imp_self, bot_eq_zero, finsupp.mem_support_iff, finset.sum_eq_zero_iff] at hp,\n  ext,\n  simp [hp],\nend\n\n-- TODO can things be generalized to no_zero_divisors (would require an instance for mv_poly)\n-- sadly this adds some imports and requirements not needed in rest of file\n@[simp]\nlemma leading_terms_mul {S : Type*} [comm_ring S] [is_domain S] (p q : mv_polynomial ι S) :\n  (p * q).leading_terms = p.leading_terms * q.leading_terms :=\nbegin\n  by_cases hp : p.total_degree = 0,\n  { rcases eq_C_of_total_degree_zero hp with ⟨rp, rfl⟩,\n    rw [leading_terms_C_mul, leading_terms_C], },\n  by_cases hq : q.total_degree = 0,\n  { rcases eq_C_of_total_degree_zero hq with ⟨rq, rfl⟩,\n    rw [mul_comm, leading_terms_C_mul, leading_terms_C, mul_comm], },\n  have : (p.leading_terms * q.leading_terms).total_degree = p.total_degree + q.total_degree,\n  { rw is_homogeneous.total_degree,\n    apply is_homogeneous.mul (is_homogeneous_leading_terms p) (is_homogeneous_leading_terms q),\n    apply mul_ne_zero,\n    { apply leading_terms_ne_zero, -- TODO maybe this can be a lemma ne_zero_of_total_degree_ne_zero\n      intro hh,\n      subst hh,\n      simpa, },\n    { apply leading_terms_ne_zero, -- TODO maybe this can be a lemma ne_zero_of_total_degree_ne_zero\n      intro hh,\n      subst hh,\n      simpa, }, },\n  rcases eq_leading_terms_add p hp with ⟨wp, hp, tp⟩,\n  rw hp,\n  rcases eq_leading_terms_add q hq with ⟨wq, hq, tq⟩,\n  rw hq,\n  simp only [add_mul, mul_add],\n  rw [add_assoc, leading_terms_add_of_total_degree_lt, leading_terms_add_of_total_degree_lt,\n    leading_terms_add_of_total_degree_lt, leading_terms_idempotent, leading_terms_idempotent,\n    leading_terms_eq_self_iff_is_homogeneous],\n  { convert is_homogeneous.mul (is_homogeneous_leading_terms _) (is_homogeneous_leading_terms _), },\n  { rwa total_degree_leading_terms, },\n  { rwa total_degree_leading_terms, },\n  { rw this,\n    calc _ ≤ max (wp * q.leading_terms).total_degree (p.leading_terms * wq + wp * wq).total_degree :\n              total_degree_add _ _\n       ... ≤ max (wp * q.leading_terms).total_degree\n              (max (p.leading_terms * wq).total_degree (wp * wq).total_degree) :\n                max_le_max (le_refl _) (total_degree_add _ _)\n       ... ≤ max (wp.total_degree + q.leading_terms.total_degree)\n              (max (p.leading_terms * wq).total_degree (wp * wq).total_degree) :\n                max_le_max (total_degree_mul _ _) (le_refl _)\n       ... ≤ max (wp.total_degree + q.leading_terms.total_degree)\n              (max (p.leading_terms.total_degree + wq.total_degree)\n                (wp.total_degree + wq.total_degree)) :\n                  max_le_max (le_refl _) (max_le_max (total_degree_mul _ _) (total_degree_mul _ _))\n       ... < p.total_degree + q.total_degree : _,\n    simp only [total_degree_leading_terms, max_lt_iff, add_lt_add_iff_right, add_lt_add_iff_left],\n    exact ⟨tp, tq, add_lt_add tp tq⟩, },\nend\n\nlemma total_degree_mul_eq {S : Type*} [comm_ring S] [is_domain S] {p q : mv_polynomial ι S}\n  (hp : p ≠ 0) (hq : q ≠ 0) : (p * q).total_degree = p.total_degree + q.total_degree :=\nbegin\n  rw [← total_degree_leading_terms, ← total_degree_leading_terms p, ← total_degree_leading_terms q,\n    leading_terms_mul, is_homogeneous.total_degree],\n  apply is_homogeneous.mul;\n  simp [is_homogeneous_leading_terms],\n  apply mul_ne_zero (leading_terms_ne_zero hp) (leading_terms_ne_zero hq),\nend\n\nend leading_terms\n\nend mv_polynomial\n\nnamespace mv_polynomial\nsection\n\n-- generalized version of the unprimed version\nlemma support_sum_monomial_subset' [decidable_eq ι] {α : Type*} (S : finset α) (g : α → ι →₀ ℕ)\n  (f : α → R) : support (∑ v in S, monomial (g v) (f v)) ⊆ S.image g :=\nbegin\n  letI := classical.dec_eq α,\n  induction S using finset.induction with s S hs hsi,\n  { simp, },\n  { rw finset.sum_insert hs,\n    apply finset.subset.trans support_add,\n    apply finset.union_subset,\n    { apply finset.subset.trans support_monomial_subset _,\n      rw finset.image_insert,\n      convert finset.subset_union_left _ (finset.image g S), },\n    { apply finset.subset.trans hsi _,\n      rw finset.image_insert,\n      exact finset.subset_insert (g s) (finset.image g S), }, },\nend\nopen_locale pointwise\n\nlemma support_mul' [decidable_eq ι] (p q : mv_polynomial ι R) :\n  (p * q).support ⊆ p.support + q.support :=\nbegin\n  -- TODO this was really hard to find, maybe needs a docstring or alias?\n  rw [p.as_sum, q.as_sum, finset.sum_mul_sum],\n  simp_rw [monomial_mul],\n  rw [support_sum_monomial_coeff, support_sum_monomial_coeff],\n  exact finset.subset.trans (support_sum_monomial_subset' _ _ _) (finset.subset.refl _),\nend\n\nend\n\nend mv_polynomial", "meta": {"author": "isadofschi", "repo": "combinatorial_nullstellensatz", "sha": "b5f2e75d51c3c8b9345d698a3ff4964c95bb5028", "save_path": "github-repos/lean/isadofschi-combinatorial_nullstellensatz", "path": "github-repos/lean/isadofschi-combinatorial_nullstellensatz/combinatorial_nullstellensatz-b5f2e75d51c3c8b9345d698a3ff4964c95bb5028/src/from_flt_regular/homogenization.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.47042767697935794}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport data.lazy_list.basic\nimport data.tree\nimport data.int.basic\nimport control.bifunctor\nimport control.ulift\nimport tactic.linarith\nimport testing.slim_check.gen\n\n/-!\n# `sampleable` Class\n\nThis class permits the creation samples of a given type\ncontrolling the size of those values using the `gen` monad`. It also\nhelps minimize examples by creating smaller versions of given values.\n\nWhen testing a proposition like `∀ n : ℕ, prime n → n ≤ 100`,\n`slim_check` requires that `ℕ` have an instance of `sampleable` and for\n`prime n` to be decidable.  `slim_check` will then use the instance of\n`sampleable` to generate small examples of ℕ and progressively increase\nin size. For each example `n`, `prime n` is tested. If it is false,\nthe example will be rejected (not a test success nor a failure) and\n`slim_check` will move on to other examples. If `prime n` is true, `n\n≤ 100` will be tested. If it is false, `n` is a counter-example of `∀\nn : ℕ, prime n → n ≤ 100` and the test fails. If `n ≤ 100` is true,\nthe test passes and `slim_check` moves on to trying more examples.\n\nThis is a port of the Haskell QuickCheck library.\n\n## Main definitions\n  * `sampleable` class\n  * `sampleable_functor` and `sampleable_bifunctor` class\n  * `sampleable_ext` class\n\n### `sampleable`\n\n`sampleable α` provides ways of creating examples of type `α`,\nand given such an example `x : α`, gives us a way to shrink it\nand find simpler examples.\n\n### `sampleable_ext`\n\n`sampleable_ext` generalizes the behavior of `sampleable`\nand makes it possible to express instances for types that\ndo not lend themselves to introspection, such as `ℕ → ℕ`.\nIf we test a quantification over functions the\ncounter-examples cannot be shrunken or printed meaningfully.\n\nFor that purpose, `sampleable_ext` provides a proxy representation\n`proxy_repr` that can be printed and shrunken as well\nas interpreted (using `interp`) as an object of the right type.\n\n### `sampleable_functor` and `sampleable_bifunctor`\n\n`sampleable_functor F` and `sampleable_bifunctor F` makes it possible\nto create samples of and shrink `F α` given a sampling function and a\nshrinking function for arbitrary `α`.\n\nThis allows us to separate the logic for generating the shape of a\ncollection from the logic for generating its contents. Specifically,\nthe contents could be generated using either `sampleable` or\n`sampleable_ext` instance and the `sampleable_(bi)functor` does not\nneed to use that information\n\n## Shrinking\n\nShrinking happens when `slim_check` find a counter-example to a\nproperty.  It is likely that the example will be more complicated than\nnecessary so `slim_check` proceeds to shrink it as much as\npossible. Although equally valid, a smaller counter-example is easier\nfor a user to understand and use.\n\nThe `sampleable` class, beside having the `sample` function, has a\n`shrink` function so that we can use specialized knowledge while\nshrinking a value. It is not responsible for the whole shrinking process\nhowever. It only has to take one step in the shrinking process.\n`slim_check` will repeatedly call `shrink` until no more steps can\nbe taken. Because `shrink` guarantees that the size of the candidates\nit produces is strictly smaller than the argument, we know that\n`slim_check` is guaranteed to terminate.\n\n## Tags\n\nrandom testing\n\n## References\n\n  * https://hackage.haskell.org/package/QuickCheck\n\n-/\nuniverses u v w\n\nnamespace slim_check\n\nvariables (α : Type u)\n\nlocal infix ` ≺ `:50 := has_well_founded.r\n\n/-- `sizeof_lt x y` compares the sizes of `x` and `y`. -/\ndef sizeof_lt {α} [has_sizeof α] (x y : α) := sizeof x < sizeof y\n\n/-- `shrink_fn α` is the type of functions that shrink an\nargument of type `α` -/\n@[reducible]\ndef shrink_fn (α : Type*) [has_sizeof α] := Π x : α, lazy_list { y : α // sizeof_lt y x }\n\n/-- `sampleable α` provides ways of creating examples of type `α`,\nand given such an example `x : α`, gives us a way to shrink it\nand find simpler examples.  -/\nclass sampleable :=\n[wf : has_sizeof α]\n(sample [] : gen α)\n(shrink : Π x : α, lazy_list { y : α // @sizeof _ wf y < @sizeof _ wf x } := λ _, lazy_list.nil)\n\nattribute [instance, priority 100] has_well_founded_of_has_sizeof default_has_sizeof\nattribute [instance, priority 200] sampleable.wf\n\n/-- `sampleable_functor F` makes it possible to create samples of and\nshrink `F α` given a sampling function and a shrinking function for\narbitrary `α` -/\nclass sampleable_functor (F : Type u → Type v) [functor F] :=\n[wf : Π α [has_sizeof α], has_sizeof (F α)]\n(sample [] : ∀ {α}, gen α → gen (F α))\n(shrink : ∀ α [has_sizeof α], shrink_fn α → shrink_fn (F α))\n(p_repr : ∀ α, has_repr α → has_repr (F α))\n\n/-- `sampleable_bifunctor F` makes it possible to create samples of\nand shrink `F α β` given a sampling function and a shrinking function\nfor arbitrary `α` and `β` -/\nclass sampleable_bifunctor (F : Type u → Type v → Type w) [bifunctor F] :=\n[wf : Π α β [has_sizeof α] [has_sizeof β], has_sizeof (F α β)]\n(sample [] : ∀ {α β}, gen α → gen β → gen (F α β))\n(shrink : ∀ α β [has_sizeof α] [has_sizeof β], shrink_fn α → shrink_fn β → shrink_fn (F α β))\n(p_repr : ∀ α β, has_repr α → has_repr β → has_repr (F α β))\n\nexport sampleable (sample shrink)\n\n/-- This function helps infer the proxy representation and\ninterpretation in `sampleable_ext` instances. -/\nmeta def sampleable.mk_trivial_interp : tactic unit :=\ntactic.refine ``(id)\n\n/-- `sampleable_ext` generalizes the behavior of `sampleable`\nand makes it possible to express instances for types that\ndo not lend themselves to introspection, such as `ℕ → ℕ`.\nIf we test a quantification over functions the\ncounter-examples cannot be shrunken or printed meaningfully.\n\nFor that purpose, `sampleable_ext` provides a proxy representation\n`proxy_repr` that can be printed and shrunken as well\nas interpreted (using `interp`) as an object of the right type. -/\nclass sampleable_ext (α : Sort u) :=\n(proxy_repr : Type v)\n[wf : has_sizeof proxy_repr]\n(interp [] : proxy_repr → α . sampleable.mk_trivial_interp)\n[p_repr : has_repr proxy_repr]\n(sample [] : gen proxy_repr)\n(shrink : shrink_fn proxy_repr)\n\nattribute [instance, priority 100] sampleable_ext.p_repr sampleable_ext.wf\n\nopen nat lazy_list\n\nsection prio\n\nopen sampleable_ext\n\nset_option default_priority 50\n\ninstance sampleable_ext.of_sampleable {α} [sampleable α] [has_repr α] : sampleable_ext α :=\n{ proxy_repr := α,\n  sample := sampleable.sample α,\n  shrink := shrink }\n\ninstance sampleable.functor {α} {F} [functor F] [sampleable_functor F] [sampleable α] :\n  sampleable (F α) :=\n{ wf := _,\n  sample := sampleable_functor.sample F (sampleable.sample α),\n  shrink := sampleable_functor.shrink α sampleable.shrink }\n\ninstance sampleable.bifunctor {α β} {F} [bifunctor F] [sampleable_bifunctor F] [sampleable α]\n  [sampleable β] : sampleable (F α β) :=\n{ wf := _,\n  sample := sampleable_bifunctor.sample F (sampleable.sample α) (sampleable.sample β),\n  shrink := sampleable_bifunctor.shrink α β sampleable.shrink sampleable.shrink }\n\nset_option default_priority 100\n\ninstance sampleable_ext.functor {α} {F} [functor F] [sampleable_functor F] [sampleable_ext α] :\n  sampleable_ext (F α) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr α),\n  interp := functor.map (interp _),\n  sample := sampleable_functor.sample F (sampleable_ext.sample α),\n  shrink := sampleable_functor.shrink _ sampleable_ext.shrink,\n  p_repr := sampleable_functor.p_repr _ sampleable_ext.p_repr }\n\ninstance sampleable_ext.bifunctor {α β} {F} [bifunctor F] [sampleable_bifunctor F]\n  [sampleable_ext α] [sampleable_ext β] : sampleable_ext (F α β) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr α) (proxy_repr β),\n  interp := bifunctor.bimap (interp _) (interp _),\n  sample := sampleable_bifunctor.sample F (sampleable_ext.sample α) (sampleable_ext.sample β),\n  shrink := sampleable_bifunctor.shrink _ _ sampleable_ext.shrink sampleable_ext.shrink,\n  p_repr := sampleable_bifunctor.p_repr _ _ sampleable_ext.p_repr sampleable_ext.p_repr }\n\nend prio\n\n/-- `nat.shrink' k n` creates a list of smaller natural numbers by\nsuccessively dividing `n` by 2 and subtracting the difference from\n`k`. For example, `nat.shrink 100 = [50, 75, 88, 94, 97, 99]`. -/\ndef nat.shrink' (k : ℕ) : Π n : ℕ, n ≤ k →\n  list { m : ℕ // has_well_founded.r m k } → list { m : ℕ // has_well_founded.r m k }\n| n hn ls :=\nif h : n ≤ 1\n  then ls.reverse\n  else\n    have h₂ : 0 < n, by linarith,\n    have 1 * n / 2 < n,\n      from nat.div_lt_of_lt_mul (nat.mul_lt_mul_of_pos_right (by norm_num) h₂),\n    have n / 2 < n, by simpa,\n    let m := n / 2 in\n    have h₀ : m ≤ k, from le_trans (le_of_lt this) hn,\n    have h₃ : 0 < m,\n      by simp only [m, lt_iff_add_one_le, zero_add]; rw [nat.le_div_iff_mul_le]; linarith,\n    have h₁ : k - m < k,\n      from nat.sub_lt (lt_of_lt_of_le h₂ hn) h₃,\n    nat.shrink' m h₀ (⟨k - m, h₁⟩ :: ls)\n\n/-- `nat.shrink n` creates a list of smaller natural numbers by\nsuccessively dividing by 2 and subtracting the difference from\n`n`. For example, `nat.shrink 100 = [50, 75, 88, 94, 97, 99]`. -/\ndef nat.shrink (n : ℕ) : list { m : ℕ // has_well_founded.r m n } :=\nif h : n > 0 then\n  have ∀ k, 1 < k → n / k < n, from\n    λ k hk,\n     nat.div_lt_of_lt_mul\n       (suffices 1 * n < k * n, by simpa,\n        nat.mul_lt_mul_of_pos_right hk h),\n  ⟨n/11, this _ (by norm_num)⟩ :: ⟨n/3, this _ (by norm_num)⟩ :: nat.shrink' n n (le_refl _) []\nelse\n  []\n\nopen gen\n\n/--\nTransport a `sampleable` instance from a type `α` to a type `β` using\nfunctions between the two, going in both directions.\n\nFunction `g` is used to define the well-founded order that\n`shrink` is expected to follow.\n-/\ndef sampleable.lift (α : Type u) {β : Type u} [sampleable α] (f : α → β) (g : β → α)\n  (h : ∀ (a : α), sizeof (g (f a)) ≤ sizeof a) : sampleable β :=\n{ wf := ⟨ sizeof ∘ g ⟩,\n  sample := f <$> sample α,\n  shrink := λ x,\n    have ∀ a,  sizeof a < sizeof (g x) → sizeof (g (f a)) < sizeof (g x),\n      by introv h'; solve_by_elim [lt_of_le_of_lt],\n    subtype.map f this <$> shrink (g x) }\n\ninstance nat.sampleable : sampleable ℕ :=\n{ sample := sized $ λ sz, freq [(1, coe <$> choose_any (fin $ succ (sz^3))),\n                                (3, coe <$> choose_any (fin $ succ sz))] dec_trivial,\n  shrink :=  λ x, lazy_list.of_list $ nat.shrink x }\n\n/-- `iterate_shrink p x` takes a decidable predicate `p` and a\nvalue `x` of some sampleable type and recursively shrinks `x`.\nIt first calls `shrink x` to get a list of candidate sample,\nfinds the first that satisfies `p` and recursively tries\nto shrink that one. -/\ndef iterate_shrink {α} [has_to_string α] [sampleable α]\n  (p : α → Prop) [decidable_pred p] :\n  α → option α :=\nwell_founded.fix has_well_founded.wf $ λ x f_rec,\n  do trace sformat!\"{x} : {(shrink x).to_list}\" $ pure (),\n     y ← (shrink x).find (λ a, p a),\n     f_rec y y.property <|> some y.val .\n\ninstance fin.sampleable {n} [fact $ 0 < n] : sampleable (fin n) :=\nsampleable.lift ℕ fin.of_nat' subtype.val $\nλ i, (mod_le _ _ : i % n ≤ i)\n\n@[priority 100]\ninstance fin.sampleable' {n} : sampleable (fin (succ n)) :=\nsampleable.lift ℕ fin.of_nat subtype.val $\nλ i, (mod_le _ _ : i % succ n ≤ i)\n\ninstance pnat.sampleable : sampleable ℕ+ :=\nsampleable.lift ℕ nat.succ_pnat pnat.nat_pred $ λ a,\nby unfold_wf; simp only [pnat.nat_pred, succ_pnat, pnat.mk_coe, tsub_zero, succ_sub_succ_eq_sub]\n\n/-- Redefine `sizeof` for `int` to make it easier to use with `nat` -/\ndef int.has_sizeof : has_sizeof ℤ := ⟨ int.nat_abs ⟩\n\nlocal attribute [instance, priority 2000] int.has_sizeof\n\ninstance int.sampleable : sampleable ℤ :=\n{ wf := _,\n  sample := sized $ λ sz,\n          freq [(1, subtype.val <$> choose (-(sz^3 + 1) : ℤ) (sz^3 + 1) (neg_le_self dec_trivial)),\n                (3, subtype.val <$> choose (-(sz + 1)) (sz + 1) (neg_le_self dec_trivial))]\n               dec_trivial,\n  shrink :=\n    λ x, lazy_list.of_list $ (nat.shrink $ int.nat_abs x).bind $\n    λ ⟨y,h⟩, [⟨y, h⟩, ⟨-y, by dsimp [sizeof,has_sizeof.sizeof]; rw int.nat_abs_neg; exact h ⟩] }\n\ninstance bool.sampleable : sampleable bool :=\n{ wf := ⟨ λ b, if b then 1 else 0 ⟩,\n  sample := do { x ← choose_any bool,\n                 return x },\n  shrink := λ b, if h : b then lazy_list.singleton ⟨ff, by cases h; unfold_wf⟩\n                          else lazy_list.nil }\n\n/--\nProvided two shrinking functions `prod.shrink` shrinks a pair `(x, y)` by\nfirst shrinking `x` and pairing the results with `y` and then shrinking\n`y` and pairing the results with `x`.\n\nAll pairs either contain `x` untouched or `y` untouched. We rely on\nshrinking being repeated for `x` to get maximally shrunken and then\nfor `y` to get shrunken too.\n-/\ndef prod.shrink {α β} [has_sizeof α] [has_sizeof β]\n  (shr_a : shrink_fn α) (shr_b : shrink_fn β) : shrink_fn (α × β)\n| ⟨x₀,x₁⟩ :=\n  let xs₀ : lazy_list { y : α × β // sizeof_lt y (x₀,x₁) } :=\n          (shr_a x₀).map $ subtype.map (λ a, (a, x₁))\n                           (λ x h, by dsimp [sizeof_lt]; unfold_wf; apply h),\n      xs₁ : lazy_list { y : α × β // sizeof_lt y (x₀,x₁) } :=\n          (shr_b x₁).map $ subtype.map (λ a, (x₀, a))\n                           (λ x h, by dsimp [sizeof_lt]; unfold_wf; apply h) in\n  xs₀.append xs₁\n\ninstance prod.sampleable : sampleable_bifunctor.{u v} prod :=\n{ wf := _,\n  sample := λ α β sama samb, do\n              { ⟨x⟩ ← (uliftable.up $ sama : gen (ulift.{max u v} α)),\n                ⟨y⟩ ← (uliftable.up $ samb : gen (ulift.{max u v} β)),\n                pure (x,y) },\n  shrink := @prod.shrink,\n  p_repr := @prod.has_repr }\n\ninstance sigma.sampleable {α β} [sampleable α] [sampleable β] : sampleable (Σ _ : α, β) :=\nsampleable.lift (α × β) (λ ⟨x,y⟩, ⟨x,y⟩) (λ ⟨x,y⟩, ⟨x,y⟩) $ λ ⟨x,y⟩, le_refl _\n\n/-- shrinking function for sum types -/\ndef sum.shrink {α β} [has_sizeof α] [has_sizeof β] (shrink_α : shrink_fn α)\n  (shrink_β : shrink_fn β) : shrink_fn (α ⊕ β)\n| (sum.inr x) := (shrink_β x).map $ subtype.map sum.inr $ λ a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n| (sum.inl x) := (shrink_α x).map $ subtype.map sum.inl $ λ a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n\ninstance sum.sampleable : sampleable_bifunctor.{u v} sum :=\n{ wf := _,\n  sample := λ (α : Type u) (β : Type v) sam_α sam_β,\n            (@uliftable.up_map gen.{u} gen.{max u v} _ _ _ _ (@sum.inl α β) sam_α <|>\n             @uliftable.up_map gen.{v} gen.{max v u} _ _ _ _ (@sum.inr α β) sam_β),\n  shrink := λ α β Iα Iβ shr_α shr_β, @sum.shrink _ _ Iα Iβ shr_α shr_β,\n  p_repr := @sum.has_repr }\n\ninstance rat.sampleable : sampleable ℚ :=\nsampleable.lift (ℤ × ℕ+) (λ x, prod.cases_on x rat.mk_pnat) (λ r, (r.num, ⟨r.denom, r.pos⟩)) $\nbegin\n  intro i,\n  rcases i with ⟨x,⟨y,hy⟩⟩; unfold_wf;\n  dsimp [rat.mk_pnat],\n  mono*,\n  { rw [← int.coe_nat_le, ← int.abs_eq_nat_abs, ← int.abs_eq_nat_abs],\n    apply int.abs_div_le_abs },\n  { change _ - 1 ≤ y-1,\n    apply tsub_le_tsub_right,\n    apply nat.div_le_of_le_mul,\n    suffices : 1 * y ≤ x.nat_abs.gcd y * y, { simpa },\n    apply nat.mul_le_mul_right,\n    apply gcd_pos_of_pos_right _ hy }\nend\n\n/-- `sampleable_char` can be specialized into customized `sampleable char` instances.\n\nThe resulting instance has `1 / length` chances of making an unrestricted choice of characters\nand it otherwise chooses a character from `characters` with uniform probabilities.  -/\ndef sampleable_char (length : nat) (characters : string) : sampleable char :=\n{ sample := do { x ← choose_nat 0 length dec_trivial,\n                 if x.val = 0 then do\n                   n ← sample ℕ,\n                   pure $ char.of_nat n\n                 else do\n                   i ← choose_nat 0 (characters.length - 1) dec_trivial,\n                   pure (characters.mk_iterator.nextn i).curr },\n  shrink := λ _, lazy_list.nil }\n\ninstance char.sampleable : sampleable char :=\nsampleable_char 3 \" 0123abcABC:,;`\\\\/\"\n\nvariables {α}\n\nsection list_shrink\n\nvariables [has_sizeof α] (shr : Π x : α, lazy_list { y : α // sizeof_lt y x })\n\n\n\nlemma list.sizeof_cons_lt_right (a b : α) {xs : list α} (h : sizeof a < sizeof b) :\n  sizeof (a :: xs) < sizeof (b :: xs) :=\nby unfold_wf; assumption\n\nlemma list.sizeof_cons_lt_left (x : α) {xs xs' : list α} (h : sizeof xs < sizeof xs') :\n  sizeof (x :: xs) < sizeof (x :: xs') :=\nby unfold_wf; assumption\n\nlemma list.sizeof_append_lt_left {xs ys ys' : list α} (h : sizeof ys < sizeof ys') :\n  sizeof (xs ++ ys) < sizeof (xs ++ ys') :=\nbegin\n  induction xs,\n  { apply h },\n  { unfold_wf,\n    simp only [list.sizeof, add_lt_add_iff_left],\n    exact xs_ih }\nend\n\nlemma list.one_le_sizeof (xs : list α) : 1 ≤ sizeof xs :=\nby cases xs; unfold_wf; linarith\n\n/--\n`list.shrink_removes` shrinks a list by removing chunks of size `k` in\nthe middle of the list.\n-/\ndef list.shrink_removes (k : ℕ) (hk : 0 < k) : Π (xs : list α) n,\n  n = xs.length → lazy_list { ys : list α // sizeof_lt ys xs }\n| xs n hn :=\n  if hkn : k > n then lazy_list.nil\n  else\n  if hkn' : k = n then\n    have 1 < xs.sizeof,\n      by { subst_vars, cases xs, { contradiction },\n           unfold_wf, apply lt_of_lt_of_le,\n           show 1 < 1 + has_sizeof.sizeof xs_hd + 1, { linarith },\n           { mono, apply list.one_le_sizeof, } },\n    lazy_list.singleton ⟨[], this ⟩\n  else\n    have h₂ : k < xs.length, from hn ▸ lt_of_le_of_ne (le_of_not_gt hkn) hkn',\n    match list.split_at k xs, rfl : Π ys, ys = list.split_at k xs → _ with\n    |  ⟨xs₁,xs₂⟩, h :=\n      have h₄ : xs₁ = xs.take k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have h₃ : xs₂ = xs.drop k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have sizeof xs₂ < sizeof xs,\n        by rw h₃; solve_by_elim [list.sizeof_drop_lt_sizeof_of_lt_length],\n      have h₁ : n - k = xs₂.length,\n        by simp only [h₃, ←hn, list.length_drop],\n      have h₅ : ∀ (a : list α), sizeof_lt a xs₂ → sizeof_lt (xs₁ ++ a) xs,\n        by intros a h; rw [← list.take_append_drop k xs, ← h₃, ← h₄];\n          solve_by_elim [list.sizeof_append_lt_left],\n      lazy_list.cons ⟨xs₂, this⟩ $ subtype.map ((++) xs₁) h₅ <$> list.shrink_removes xs₂ (n - k) h₁\n    end\n\n/--\n`list.shrink_one xs` shrinks list `xs` by shrinking only one item in\nthe list.\n-/\ndef list.shrink_one : shrink_fn (list α)\n| [] := lazy_list.nil\n| (x :: xs) :=\n  lazy_list.append\n    (subtype.map (λ x', x' :: xs) (λ a,  list.sizeof_cons_lt_right _ _) <$> shr x)\n    (subtype.map ((::) x) (λ _, list.sizeof_cons_lt_left _) <$> list.shrink_one xs)\n\n\n/-- `list.shrink_with shrink_f xs` shrinks `xs` by first\nconsidering `xs` with chunks removed in the middle (starting with\nchunks of size `xs.length` and halving down to `1`) and then\nshrinks only one element of the list.\n\nThis strategy is taken directly from Haskell's QuickCheck -/\ndef list.shrink_with (xs : list α) :\n  lazy_list { ys : list α // sizeof_lt ys xs } :=\nlet n := xs.length in\nlazy_list.append\n  ((lazy_list.cons n $ (shrink n).reverse.map subtype.val).bind (λ k,\n    if hk : 0 < k\n    then list.shrink_removes k hk xs n rfl\n    else lazy_list.nil ))\n  (list.shrink_one shr _)\n\nend list_shrink\n\ninstance list.sampleable : sampleable_functor list.{u} :=\n{ wf := _,\n  sample := λ α sam_α, list_of sam_α,\n  shrink := λ α Iα shr_α, @list.shrink_with _ Iα shr_α,\n  p_repr := @list.has_repr }\n\ninstance Prop.sampleable_ext : sampleable_ext Prop :=\n{ proxy_repr := bool,\n  interp := coe,\n  sample := choose_any bool,\n  shrink := λ _, lazy_list.nil }\n\n/-- `no_shrink` is a type annotation to signal that\na certain type is not to be shrunk. It can be useful in\ncombination with other types: e.g. `xs : list (no_shrink ℤ)`\nwill result in the list being cut down but individual\nintegers being kept as is. -/\ndef no_shrink (α : Type*) := α\n\ninstance no_shrink.inhabited {α} [inhabited α] : inhabited (no_shrink α) :=\n⟨ (default α : α) ⟩\n\n/-- Introduction of the `no_shrink` type. -/\ndef no_shrink.mk {α} (x : α) : no_shrink α := x\n\n/-- Selector of the `no_shrink` type. -/\ndef no_shrink.get {α} (x : no_shrink α) : α := x\n\ninstance no_shrink.sampleable {α} [sampleable α] : sampleable (no_shrink α) :=\n{ sample := no_shrink.mk <$> sample α }\n\ninstance string.sampleable : sampleable string :=\n{ sample := do { x ← list_of (sample char), pure x.as_string },\n  .. sampleable.lift (list char) list.as_string string.to_list $ λ _, le_refl _ }\n\n/-- implementation of `sampleable (tree α)` -/\ndef tree.sample (sample : gen α) : ℕ → gen (tree α) | n :=\nif h : n > 0\nthen have n / 2 < n, from div_lt_self h (by norm_num),\n     tree.node <$> sample <*> tree.sample (n / 2) <*> tree.sample (n / 2)\nelse pure tree.nil\n\n/-- `rec_shrink x f_rec` takes the recursive call `f_rec` introduced\nby `well_founded.fix` and turns it into a shrinking function whose\nresult is adequate to use in a recursive call. -/\ndef rec_shrink {α : Type*} [has_sizeof α] (t : α)\n  (sh : Π x : α, sizeof_lt x t → lazy_list { y : α // sizeof_lt y x }) :\n  shrink_fn { t' : α // sizeof_lt t' t }\n| ⟨t',ht'⟩ := (λ t'' : { y : α // sizeof_lt y t' },\n    ⟨⟨t''.val, lt_trans t''.property ht'⟩, t''.property⟩ ) <$> sh t' ht'\n\nlemma tree.one_le_sizeof {α} [has_sizeof α] (t : tree α) : 1 ≤ sizeof t :=\nby cases t; unfold_wf; linarith\n\ninstance : functor tree :=\n{ map := @tree.map }\n\n/--\nRecursion principle for shrinking tree-like structures.\n-/\ndef rec_shrink_with [has_sizeof α]\n  (shrink_a : Π x : α, shrink_fn { y : α // sizeof_lt y x } →\n    list (lazy_list { y : α // sizeof_lt y x })) :\n  shrink_fn α :=\nwell_founded.fix (sizeof_measure_wf _) $ λ t f_rec,\nlazy_list.join\n    (lazy_list.of_list $\n      shrink_a t $ λ ⟨t', h⟩, rec_shrink _ f_rec _)\n\nlemma rec_shrink_with_eq [has_sizeof α]\n  (shrink_a : Π x : α, shrink_fn { y : α // sizeof_lt y x } →\n    list (lazy_list { y : α // sizeof_lt y x }))\n  (x : α) :\n  rec_shrink_with shrink_a x =\n  lazy_list.join\n    (lazy_list.of_list $ shrink_a x $ λ t', rec_shrink _ (λ x h', rec_shrink_with shrink_a x) _) :=\nbegin\n  conv_lhs { rw [rec_shrink_with, well_founded.fix_eq], },\n  congr, ext ⟨y, h⟩, refl\nend\n\n/-- `tree.shrink_with shrink_f t` shrinks `xs` by using the empty tree,\neach subtrees, and by shrinking the subtree to recombine them.\n\nThis strategy is taken directly from Haskell's QuickCheck -/\ndef tree.shrink_with [has_sizeof α] (shrink_a : shrink_fn α) : shrink_fn (tree α) :=\nrec_shrink_with $ λ t,\nmatch t with\n| tree.nil := λ f_rec, []\n| (tree.node x t₀ t₁) :=\nλ f_rec,\n  have h₂ : sizeof_lt tree.nil (tree.node x t₀ t₁),\n    by clear _match; have := tree.one_le_sizeof t₀;\n       dsimp [sizeof_lt, sizeof, has_sizeof.sizeof] at *;\n       unfold_wf; linarith,\n  have h₀ : sizeof_lt t₀ (tree.node x t₀ t₁),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  have h₁ : sizeof_lt t₁ (tree.node x t₀ t₁),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  [lazy_list.of_list [⟨tree.nil, h₂⟩, ⟨t₀, h₀⟩, ⟨t₁, h₁⟩],\n   (prod.shrink shrink_a (prod.shrink f_rec f_rec) (x, ⟨t₀, h₀⟩, ⟨t₁, h₁⟩)).map\n    $ λ ⟨⟨y,⟨t'₀, _⟩,⟨t'₁, _⟩⟩,hy⟩, ⟨tree.node y t'₀ t'₁,\n      by revert hy; dsimp [sizeof_lt]; unfold_wf; intro; linarith⟩]\nend\n\ninstance sampleable_tree : sampleable_functor tree :=\n{ wf := _,\n  sample := λ α sam_α, sized $ tree.sample sam_α,\n  shrink := λ α Iα shr_α, @tree.shrink_with _ Iα shr_α,\n  p_repr := @tree.has_repr }\n\n/-- Type tag that signals to `slim_check` to use small values for a given type. -/\ndef small (α : Type*) := α\n\n/-- Add the `small` type tag -/\ndef small.mk {α} (x : α) : small α := x\n\n/-- Type tag that signals to `slim_check` to use large values for a given type. -/\ndef large (α : Type*) := α\n\n/-- Add the `large` type tag -/\ndef large.mk {α} (x : α) : large α := x\n\ninstance small.functor : functor small := id.monad.to_functor\ninstance large.functor : functor large := id.monad.to_functor\ninstance small.inhabited [inhabited α] : inhabited (small α) := ⟨ (default α : α) ⟩\ninstance large.inhabited [inhabited α] : inhabited (large α) := ⟨ (default α : α) ⟩\n\ninstance small.sampleable_functor : sampleable_functor small :=\n{ wf := _,\n  sample := λ α samp, gen.resize (λ n, n / 5 + 5) samp,\n  shrink := λ α _, id,\n  p_repr := λ α, id }\n\ninstance large.sampleable_functor : sampleable_functor large :=\n{ wf := _,\n  sample := λ α samp, gen.resize (λ n, n * 5) samp,\n  shrink := λ α _, id,\n  p_repr := λ α, id }\n\ninstance ulift.sampleable_functor : sampleable_functor ulift.{u v} :=\n{ wf := λ α h, ⟨ λ ⟨x⟩, @sizeof α h x ⟩,\n  sample := λ α samp, uliftable.up_map ulift.up $ samp,\n  shrink := λ α _ shr ⟨x⟩, (shr x).map (subtype.map ulift.up (λ a h, h)),\n  p_repr := λ α h, ⟨ @repr α h ∘ ulift.down ⟩ }\n\n/-!\n## Subtype instances\n\nThe following instances are meant to improve the testing of properties of the form\n`∀ i j, i ≤ j, ...`\n\nThe naive way to test them is to choose two numbers `i` and `j` and check that\nthe proper ordering is satisfied. Instead, the following instances make it\nso that `j` will be chosen with considerations to the required ordering\nconstraints. The benefit is that we will not have to discard any choice\nof `j`.\n -/\n\n/-! ### Subtypes of `ℕ` -/\n\ninstance nat_le.sampleable {y} : slim_check.sampleable { x : ℕ // x ≤ y } :=\n{ sample :=\n         do { ⟨x,h⟩ ← slim_check.gen.choose_nat 0 y dec_trivial,\n              pure ⟨x, h.2⟩},\n  shrink := λ ⟨x, h⟩, (λ a : subtype _, subtype.rec_on a $\n    λ x' h', ⟨⟨x', le_trans (le_of_lt h') h⟩, h'⟩) <$> shrink x }\n\ninstance nat_ge.sampleable {x} : slim_check.sampleable { y : ℕ // x ≤ y } :=\n{ sample :=\n         do { (y : ℕ) ← slim_check.sampleable.sample ℕ,\n              pure ⟨x+y, by norm_num⟩ },\n  shrink := λ ⟨y, h⟩, (λ a : { y' // sizeof y' < sizeof (y - x) },\n    subtype.rec_on a $ λ δ h', ⟨⟨x + δ, nat.le_add_right _ _⟩, lt_tsub_iff_left.mp h'⟩) <$>\n      shrink (y - x) }\n\n/- there is no `nat_lt.sampleable` instance because if `y = 0`, there is no valid choice\nto satisfy `x < y` -/\n\ninstance nat_gt.sampleable {x} : slim_check.sampleable { y : ℕ // x < y } :=\n{ sample :=\n         do { (y : ℕ) ← slim_check.sampleable.sample ℕ,\n              pure ⟨x+y+1, by linarith⟩ },\n  shrink := λ x, shrink _ }\n\n/-! ### Subtypes of any `linear_ordered_add_comm_group` -/\n\ninstance le.sampleable {y : α} [sampleable α] [linear_ordered_add_comm_group α] :\n  slim_check.sampleable { x : α // x ≤ y } :=\n{ sample :=\n         do { x ← sample α,\n              pure ⟨y - |x|, sub_le_self _ (abs_nonneg _) ⟩ },\n  shrink := λ _, lazy_list.nil }\n\ninstance ge.sampleable {x : α}  [sampleable α] [linear_ordered_add_comm_group α] :\n  slim_check.sampleable { y : α // x ≤ y } :=\n{ sample :=\n         do { y ← sample α,\n              pure ⟨x + |y|, by norm_num [abs_nonneg]⟩ },\n  shrink := λ _, lazy_list.nil }\n\n\n/-!\n### Subtypes of `ℤ`\n\nSpecializations of `le.sampleable` and `ge.sampleable` for `ℤ` to help instance search.\n-/\n\ninstance int_le.sampleable {y : ℤ} : slim_check.sampleable { x : ℤ // x ≤ y } :=\nsampleable.lift ℕ (λ n, ⟨y - n, int.sub_left_le_of_le_add $ by simp⟩) (λ ⟨i, h⟩, (y - i).nat_abs)\n  (λ n, by unfold_wf; simp [int_le.sampleable._match_1]; ring)\n\ninstance int_ge.sampleable {x : ℤ} : slim_check.sampleable { y : ℤ // x ≤ y } :=\nsampleable.lift ℕ (λ n, ⟨x + n, by simp⟩) (λ ⟨i, h⟩, (i - x).nat_abs)\n  (λ n, by unfold_wf; simp [int_ge.sampleable._match_1]; ring)\n\ninstance int_lt.sampleable {y} : slim_check.sampleable { x : ℤ // x < y } :=\nsampleable.lift ℕ (λ n, ⟨y - (n+1), int.sub_left_lt_of_lt_add $\n    by linarith [int.coe_nat_nonneg n]⟩)\n  (λ ⟨i, h⟩, (y - i - 1).nat_abs)\n  (λ n, by unfold_wf; simp [int_lt.sampleable._match_1]; ring)\n\ninstance int_gt.sampleable {x} : slim_check.sampleable { y : ℤ // x < y } :=\nsampleable.lift ℕ (λ n, ⟨x + (n+1), by linarith⟩) (λ ⟨i, h⟩, (i - x - 1).nat_abs)\n  (λ n, by unfold_wf; simp [int_gt.sampleable._match_1]; ring)\n\n/-! ### Subtypes of any `list` -/\n\ninstance perm.slim_check {xs : list α} : slim_check.sampleable { ys : list α // list.perm xs ys } :=\n{ sample := permutation_of xs,\n  shrink := λ _, lazy_list.nil }\n\ninstance perm'.slim_check {xs : list α} :\n  slim_check.sampleable { ys : list α // list.perm ys xs } :=\n{ sample := subtype.map id (@list.perm.symm α _) <$> permutation_of xs,\n  shrink := λ _, lazy_list.nil }\n\nsetup_tactic_parser\nopen tactic\n\n/--\nPrint (at most) 10 samples of a given type to stdout for debugging.\n-/\ndef print_samples {t : Type u} [has_repr t] (g : gen t) : io unit := do\nxs ← io.run_rand $ uliftable.down $\n  do { xs ← (list.range 10).mmap $ g.run ∘ ulift.up,\n       pure ⟨xs.map repr⟩ },\nxs.mmap' io.put_str_ln\n\n/-- Create a `gen α` expression from the argument of `#sample` -/\nmeta def mk_generator (e : expr) : tactic (expr × expr) := do\nt ← infer_type e,\nmatch t with\n| `(gen %%t) := do\n  repr_inst ← mk_app ``has_repr [t] >>= mk_instance,\n  pure (repr_inst, e)\n| _ := do\n  samp_inst ← to_expr ``(sampleable_ext %%e) >>= mk_instance,\n  repr_inst ← mk_mapp ``sampleable_ext.p_repr [e, samp_inst],\n  gen ← mk_mapp ``sampleable_ext.sample [none, samp_inst],\n  pure (repr_inst, gen)\nend\n\n/--\n`#sample my_type`, where `my_type` has an instance of `sampleable`, prints ten random\nvalues of type `my_type` of using an increasing size parameter.\n\n```lean\n#sample nat\n-- prints\n-- 0\n-- 0\n-- 2\n-- 24\n-- 64\n-- 76\n-- 5\n-- 132\n-- 8\n-- 449\n-- or some other sequence of numbers\n\n#sample list int\n-- prints\n-- []\n-- [1, 1]\n-- [-7, 9, -6]\n-- [36]\n-- [-500, 105, 260]\n-- [-290]\n-- [17, 156]\n-- [-2364, -7599, 661, -2411, -3576, 5517, -3823, -968]\n-- [-643]\n-- [11892, 16329, -15095, -15461]\n-- or whatever\n```\n-/\n@[user_command]\nmeta def sample_cmd (_ : parse $ tk \"#sample\") : lean.parser unit :=\ndo e ← texpr,\n   of_tactic $ do\n     e ← i_to_expr e,\n     (repr_inst, gen) ← mk_generator e,\n     print_samples ← mk_mapp ``print_samples [none, repr_inst, gen],\n     sample ← eval_expr (io unit) print_samples,\n     unsafe_run_io sample\n\nend slim_check\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/testing/slim_check/sampleable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.47042767697935794}}
{"text": "import category_theory.quotient\nimport category_theory.groupoid\nimport group_theory.subgroup.basic\n\n\nopen set\nopen classical function relation\nlocal attribute [instance] prop_decidable\n\n\nnamespace category_theory\nnamespace groupoid\nnamespace free\n\nuniverses u v u' v'\n\nvariable {V : Type u}\nvariable [quiver.{v+1} V]\n\ninductive word : V → V → Sort*\n| nil {c : V} : word c c\n| cons_p {c d e : V} (p : c ⟶ d) (w : word d e) : word c e\n| cons_n {c d e : V} (p : d ⟶ c) (w : word d e) : word c e\n\ndef word.length : Π {c d : V}, word c d → ℕ\n| _ _ word.nil := 0\n| _ _ (word.cons_p _ t) := t.length.succ\n| _ _ (word.cons_n _ t) := t.length.succ \n\n@[pattern]\ndef letter_p {c d : V} (p : c ⟶ d) : word c d := (word.cons_p p word.nil)\n@[pattern]\ndef letter_n {c d : V} (p : c ⟶ d) : word d c := (word.cons_n p word.nil)\n\ndef word.append  : Π {c d e : V}, word c d → word d e → word c e\n| _ _ _ (word.nil) w := w\n| _ _ _ (word.cons_p p u) w := word.cons_p p (u.append w)\n| _ _ _ (word.cons_n p u) w := word.cons_n p (u.append w)\n\n\n@[simp] lemma word.nil_append {c d : V} {p : word c d} : word.nil.append p = p := rfl\n\n@[simp] lemma word.append_nil {c d : V} {p : word c d} : p.append word.nil = p := by \n{ induction p, refl, all_goals { dsimp only [word.append], rw p_ih, }, }\n\n@[simp] lemma word.cons_p_append {c d e b : V} (f : c ⟶ d) (u : word d e) (w : word e b) : \n  (word.cons_p f u).append w = word.cons_p f (u.append w) := rfl\n\n@[simp] lemma word.cons_n_append {c d e b : V} (f : d ⟶ c) (u : word d e) (w : word e b) : \n  (word.cons_n f u).append w = word.cons_n f (u.append w) := rfl\n\n@[simp] lemma word.append_assoc {c d e f : V} {p : word c d} {q : word d e} {r : word e f} : \n  (p.append q).append r = p.append (q.append r) := by\n{ induction p, refl, all_goals { dsimp only [word.append], rw p_ih, }, }\n\ninfix ` ≫* `:100 := word.append\n\ndef word.reverse : Π {c d : V}, word c d → word d c\n| _ _ (word.nil) := word.nil\n| _ _ (word.cons_p p u) := (u.reverse.append (letter_n p))\n| _ _ (word.cons_n p u) := (u.reverse.append (letter_p p))\n\n@[simp] def word.reverse_nil (c : V) : (word.nil : word c c).reverse = word.nil := rfl \n\n@[simp] lemma word.reverse_letter_p {c d : V} (p : c ⟶ d) : (letter_p p).reverse = letter_n p := by \n{ dsimp only [letter_p, letter_n, word.reverse], simp, }\n\n@[simp] lemma word.reverse_letter_n {c d : V} (p : d ⟶ c) : (letter_n p).reverse = letter_p p := by\n{ dsimp only [letter_p, letter_n, word.reverse], simp, }\n\n@[simp] lemma word.reverse_cons_p {c d e : V} (p : c ⟶ d) (w : word d e) : \n  (word.cons_p p w).reverse =  w.reverse.append (letter_n p) := rfl\n\n@[simp] lemma word.reverse_cons_n {c d e : V} (p : d ⟶ c) (w : word d e) : \n  (word.cons_n p w).reverse =  w.reverse.append (letter_p p) := rfl\n\n@[simp] lemma word.reverse_append {c d e : V} (u : word c d) (w : word d e) : \n  (u.append w).reverse =  w.reverse.append (u.reverse) := by \n{ induction u, \n  { simp only [word.nil_append, word.reverse_nil, word.append_nil], },\n  { unfold word.append, -- should that be made into a lemma word.cons_p_append ?\n    simp only [u_ih, word.reverse_cons_p, word.append_assoc], },\n  { unfold word.append,\n    simp only [u_ih, word.reverse_cons_n, word.append_assoc], }, }\n\n\n@[simp] lemma word.reverse_reverse  {c d : V} (w : word c d) : w.reverse.reverse = w := by\n{ induction w, \n  { dsimp only [word.reverse], refl, },\n  { simp only [w_ih, word.reverse_cons_p, word.reverse_append, word.reverse_letter_n], refl, },\n  { simp only [w_ih, word.reverse_cons_n, word.reverse_append, word.reverse_letter_p], refl, }, }\n \ndef red_step {c  d : V} (p : word c d) (q : word c d) : Prop :=\n  (∃ (a b : V) (q₀ : word c a) (q₁ : word a d) (f : a ⟶ b), p = q₀ ≫*  (letter_p f) ≫* (letter_n f) ≫* q₁ ∧ q = q₀ ≫* q₁)\n∨ (∃ (a b : V) (q₀ : word c a) (q₁ : word a d) (f : b ⟶ a), p = q₀ ≫* (letter_n f) ≫* (letter_p f) ≫* q₁ ∧ q = q₀ ≫* q₁)\n\n@[simp]\nlemma red_step.reverse {c d : V} (p₀ p₁ : word c d) : red_step p₀.reverse p₁.reverse ↔ red_step p₀ p₁ :=\nbegin\n  suffices : ∀ c d (p₀ p₁ : word c d),  red_step p₀ p₁ → red_step p₀.reverse p₁.reverse, \n  { split, rotate, exact this c d p₀ p₁,\n    rintro h,\n    rw  [←word.reverse_reverse p₀, ←word.reverse_reverse p₁],\n    exact this d c _ _ h, },\n  rintro c d p₀ p₁ (⟨u,v,r₀,r₁,f,rfl,rfl⟩|⟨u,v,r₀,r₁,f,rfl,rfl⟩),\n  { left, use [u,v,r₁.reverse,r₀.reverse,f], simp, },\n  { right, use [u,v,r₁.reverse,r₀.reverse,f], simp, },\nend\n\n@[simp]\nlemma red_step.append_left_congr  {c d e : V} {p₀ p₁ : word c d} {q : word d e} : \n  red_step p₀ p₁ → red_step (p₀ ≫* q) (p₁ ≫* q) :=\nbegin \n  rintro (⟨u,v,r₀,r₁,f,rfl,rfl⟩|⟨u,v,r₀,r₁,f,rfl,rfl⟩),\n  { left, use [u,v,r₀,r₁.append q,f],simp, },\n  { right, use [u,v,r₀,r₁.append q,f],simp, },\nend\n\n@[simp]\nlemma red_step.append_right_congr  {c d e : V} {p : word c d} {q₀ q₁ : word d e} :  \n  red_step q₀ q₁ → red_step (p ≫* q₀) (p ≫* q₁) :=\nbegin \n  rintro (⟨u,v,r₀,r₁,f,rfl,rfl⟩|⟨u,v,r₀,r₁,f,rfl,rfl⟩),\n  { left, use [u,v,p.append r₀,r₁,f],simp, },\n  { right, use [u,v,p.append r₀,r₁,f],simp, },\nend\n\ndef free_groupoid (V : Type u) [Q : quiver.{v+1} V] := V\ninstance free_groupoid_quiver : quiver (free_groupoid V) := { hom := λ c d, quot (@red_step V _ c d) }\n\ndef quot_comp { c d e : free_groupoid V} (p : c ⟶ d) (q : d ⟶ e) : c ⟶ e :=\nquot.lift_on \n  p \n  (λ pp, quot.lift_on q \n    (λ qq, quot.mk _ (pp ≫* qq))\n    (λ q₀ q₁ redq, quot.sound $ red_step.append_right_congr redq))\n  (λ p₀ p₁ redp, quot.induction_on q $ λ qq, quot.sound $ red_step.append_left_congr redp)\n\ndef quot_id (c : free_groupoid V)  := quot.mk (@red_step V _ c c) (word.nil)\n\ninstance free_groupoid_category_struct : category_struct (free_groupoid V)  := \n{ to_quiver := free.free_groupoid_quiver\n, id := quot_id\n, comp := λ a b c p q, quot_comp p q }\n\nlemma id_quot_comp { c d : free_groupoid V} (p : c ⟶ d) : quot_comp (𝟙 c) p = p :=\nquot.induction_on p $ λ pp, quot.eqv_gen_sound $ eqv_gen.refl pp\n\nlemma quot_comp_id { c d : free_groupoid V} (p : c ⟶ d) : quot_comp p (𝟙 d) = p :=\nquot.induction_on p $ λ pp, quot.eqv_gen_sound $  by {simp, exact eqv_gen.refl pp}\n\nlemma quot_comp_assoc { c d e f : free_groupoid V} \n  (p : c ⟶ d) (q : d ⟶ e)  (r : e ⟶ f) :\n  quot_comp (quot_comp p q) r = quot_comp p (quot_comp q r) :=\nquot.induction_on₃ p q r $ λ pp qq rr, by {dsimp [quot_comp], simp,}\n\ninstance free_groupoid_category : category (free_groupoid V)  := \n{ to_category_struct := free.free_groupoid_category_struct\n  , id_comp' := λ a b p, id_quot_comp p\n  , comp_id' := λ a b p, quot_comp_id p\n  , assoc' := λ a b c d p q r, quot_comp_assoc p q r }\n\ndef quot_inv {c d : free_groupoid V} (p : c ⟶ d) : d  ⟶ c :=\nquot.lift_on p\n  (λ pp, quot.mk (@red_step V (_inst_1) d c) pp.reverse)\n  (λ p₀ p₁ redp , quot.sound $ by {simp only [red_step.reverse], exact redp })\n\nlemma quot_inv_inv {c d : free_groupoid V} (p : c ⟶ d) : (quot_inv $ quot_inv p) = p :=\nbegin\n  apply quot.induction_on p,\n  rintro pp,\n  apply quot.eqv_gen_sound, \n  simp only [word.reverse_reverse],\n  exact eqv_gen.refl _,\nend\n\nlemma quot_comp_inv {c d : free_groupoid V} (p : c ⟶ d)  : (quot_inv p) ≫ p = 𝟙 d :=\nbegin\n  apply quot.induction_on p,\n  rintro pp,\n  dsimp only [quot_comp, quot_inv], \n  simp only [quot.lift_on_mk], \n  apply quot.eqv_gen_sound,\n  induction pp with _ c d e f w ih c d e f w ih,\n  { exact eqv_gen.refl _ },\n  { refine eqv_gen.trans _ (w.reverse ≫* w) _ _ _, \n    { apply eqv_gen.rel,  \n      right,\n      use [d,c,w.reverse,w,f], \n      unfold letter_p, \n      simp only [word.reverse_cons_p, word.append_assoc, word.cons_p_append, word.nil_append, eq_self_iff_true, and_self], }, \n    { apply ih (quot.mk _ w) }, },\n  { refine eqv_gen.trans _ (w.reverse ≫* w) _ _ _, \n    { apply eqv_gen.rel,  \n      left,\n      use [d,c,w.reverse,w,f], \n      unfold letter_n, \n      simp only [word.append_assoc, word.nil_append, eq_self_iff_true, word.reverse_cons_n, and_true, word.cons_n_append], }, \n    { apply ih (quot.mk _ w) }, },\n\nend\n\nlemma quot_inv_comp {c d : free_groupoid V} (p : c ⟶ d)  : quot_comp p (quot_inv p) = 𝟙 c :=\nbegin\n  nth_rewrite 0 ←quot_inv_inv p,\n  apply quot_comp_inv,\nend\n\ninstance : groupoid (free_groupoid V) :=\n{ to_category := free.free_groupoid_category\n, inv := λ a b p, quot_inv p\n, inv_comp' := λ a b p, (quot_comp_inv p)\n, comp_inv' := λ a b p, quot_inv_comp p }\n\n@[simp]\nlemma quot_cons_p {c d e : V} (f : c ⟶ d) (w : word d e) : \n  (quot.mk (@red_step V _ c e) (word.cons_p f w)) = \n  quot_comp (quot.mk (@red_step V _ c d) (letter_p f )) (quot.mk (@red_step V _ d e) w) := rfl\n\n@[simp]\nlemma quot_cons_n {c d e : V} (f : d ⟶ c) (w : word d e) : \n  (quot.mk (@red_step V _ c e) (word.cons_n f w)) = \n  quot_comp (quot.mk (@red_step V _ c d) (letter_n f )) (quot.mk (@red_step V _ d e) w) := rfl\n\ndef ι : prefunctor V (free_groupoid V) := \n{ obj := λ x, x \n, map := λ x y p, quot.mk _ (letter_p p)}\n\ndef lift_word {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') : Π {x y : V} (w : word x y), (φ.obj x) ⟶ (φ.obj y)\n| x _ (word.nil) := 𝟙 (φ.obj x)\n| x z (@word.cons_p _ _ _ y _ p w) := (φ.map p) ≫ (lift_word w)\n| x z (@word.cons_n _ _ _ y _ p w) := (G'.inv $ φ.map p) ≫ (lift_word w)\n\n@[simp]\nlemma lift_word_nil {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') : Π (x : V),  (lift_word φ (word.nil : word x x)) = 𝟙 (φ.obj x) :=\nby { rintro x, dsimp only [lift_word], refl, }\n\n@[simp]\nlemma lift_word_cons_p {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') {x y z : V} (f : x ⟶ y) (w : word y z): (lift_word φ $ word.cons_p f w) = (φ.map f) ≫ (lift_word φ w) := rfl\n\n@[simp]\nlemma lift_word_cons_n {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') {x y z : V} (f : y ⟶ x) (w : word y z): (lift_word φ $ word.cons_n f w) = (inv $ φ.map f) ≫ (lift_word φ w) := rfl\n\n\n@[simp]\nlemma lift_word_letter_p {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') : Π (x y : V) (u : x ⟶ y),  (lift_word φ ( letter_p u : word x y)) = φ.map u :=\nby { rintro x y p, dsimp [lift_word, letter_p, lift_word_nil], simp, }\n\n@[simp]\nlemma lift_word_letter_n {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') : Π (x y : V) (u : y ⟶ x),  (lift_word φ (letter_n u : word x y)) = G'.inv (φ.map u) :=\nby { rintro x y p, dsimp [lift_word, letter_n, lift_word_nil], simp, }\n\n\n@[simp]\nlemma lift_word_append {V' : Type u'} [G' : groupoid V'] (φ : prefunctor V V') \n  {x y z : V} (u : word x y) (w : word y z) : lift_word φ (u ≫* w) = (lift_word φ u) ≫ (lift_word φ w) :=\nbegin \n  induction u, \n  { simp only [word.nil_append, lift_word_nil, category.id_comp], },\n  { simp only [u_ih, word.cons_p_append, lift_word_cons_p, category.assoc], },\n  { simp only [u_ih, word.cons_n_append, lift_word_cons_n, category.assoc], }, \nend\n\n--mathlib\n@[simp] lemma _root_.category_theory.groupoid.inv_id {V : Type*} [G : groupoid V] (v : V) : G.inv (𝟙 v) = 𝟙 v := sorry\n@[simp] lemma _root_.category_theory.groupoid.inv_comp'' {V : Type*} [G : groupoid V] \n  {u v w : V} (f : u ⟶ v) (g : v ⟶ w) : G.inv (f ≫ g) = (G.inv g) ≫ (G.inv f) := sorry\n@[simp] lemma _root_.category_theory.groupoid.inv_inv {V : Type*} [G : groupoid V] (u v : V) [f : u ⟶ v] : G.inv (G.inv f) = f := \n  calc G.inv (G.inv f) = (G.inv (G.inv f)) ≫ (𝟙 v) : by rw category.comp_id\n                  ... = (G.inv (G.inv f)) ≫ (G.inv f ≫ f) : by rw ←groupoid.inv_comp\n                  ... = (G.inv (G.inv f) ≫ G.inv f) ≫ f : by rw ←category.assoc\n                  ... = (𝟙 u) ≫ f : by rw groupoid.inv_comp\n                  ... = f : by rw category.id_comp \n\n\n\n@[simp]\nlemma lift_word_reverse {V' : Type u'} [G' : groupoid V'] (φ : prefunctor V V')\n  {x y : V} (u : word x y) : lift_word φ (u.reverse) = G'.inv (lift_word φ u) := \nbegin\n  induction u,\n  { simp only [word.reverse_nil, lift_word_nil, inv_id], },\n  { simp only [u_ih, word.reverse_cons_p, lift_word_append, lift_word_letter_n, lift_word_cons_p, inv_comp''], },\n  { simp only [u_ih, word.reverse_cons_n, lift_word_append, lift_word_letter_p, lift_word_cons_n, inv_comp'', inv_inv], },\nend\n\n\ndef lift_word_congr {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') : Π {x y : V} (w₀ w₁ : word x y) (redw : red_step w₀ w₁), lift_word φ w₀ = lift_word φ w₁ :=\nbegin\n  rintros x y w₀ w₁ redw,\n  dsimp [red_step] at redw,\n  rcases redw with (⟨u,v,r₀,r₁,p,rfl,rfl⟩|⟨u,v,r₀,r₁,p,rfl,rfl⟩),\n  { rw [←word.reverse_letter_p p],\n    simp only [word.append_assoc, lift_word_append, lift_word_reverse],\n    nth_rewrite_lhs 1 ←category.assoc, \n    rw groupoid.comp_inv, simp only [category.id_comp], },\n  { rw [←word.reverse_letter_n p],\n    simp only [word.append_assoc, lift_word_append, lift_word_reverse],\n    nth_rewrite_lhs 1 ←category.assoc, \n    rw groupoid.comp_inv, simp only [category.id_comp], },\nend\n\ndef lift {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') : free_groupoid V ⥤ V' :=\n{ obj := φ.obj\n, map := λ x y, quot.lift (λ p, lift_word φ p) (λ p₀ p₁ (redp : red_step p₀ p₁), lift_word_congr φ p₀ p₁ redp)\n, map_id' := λ x, by { dsimp only [lift_word,category_struct.id], refl,  }\n, map_comp' := λ x y z f g, by { refine quot.induction_on₂ f g _, rintro ff gg, dsimp only [lift_word,category_struct.comp,quot_comp], simp only [lift_word_append], }, }\n\n\n--mathlib (stolen from functor.ext)\nlemma _root_.category_theory.functor.ext' {C D : Type*} [category C] [category D] {F G : C ⥤ D} \n  (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ (X Y : C) (f : X ⟶ Y), F.map f = by {rw [h_obj X, h_obj Y], exact G.map f}) :\n  F = G :=\nbegin\n  cases F with F_obj _ _ _, cases G with G_obj _ _ _,\n  obtain rfl : F_obj = G_obj, by { ext X, apply h_obj },\n  congr,\n  funext X Y f,\n  simpa using h_map X Y f\nend\n\n--mathlib (stolen from functor.ext), \n@[ext] lemma ext {V : Type u} [Q : quiver.{v+1} V] {V' : Type u'} [Q' : quiver.{v'+1} V'] {F G : prefunctor V V'} \n  (h_obj : ∀ X, F.obj X = G.obj X)\n  (h_map : ∀ (X Y : V) (f : X ⟶ Y), F.map f = by {rw [h_obj X, h_obj Y], exact G.map f}) : F = G :=\nbegin\n  cases F with F_obj _, cases G with G_obj _,\n  obtain rfl : F_obj = G_obj, by { ext X, apply h_obj },\n  congr,\n  funext X Y f,\n  simpa using h_map X Y f,\nend\n\nlemma lift_spec {V : Type u} [Q : quiver.{v+1} V] {V' : Type u'} [G' : groupoid V']\n  (φ : prefunctor V V') : ι.comp (lift φ).to_prefunctor = φ :=\nbegin\n  ext, rotate,\n  rcases φ with ⟨φo,φm⟩,\n  { rintro x, dsimp only, refl, },\n  { subst_vars, apply lift_word_letter_p, },\nend\n\n\n-- mathlib?\n@[simp]\nlemma _root_.category_theory.functor.groupoid_map_inv  {C D : Type*} [G : groupoid C] [H : groupoid D] (φ : C ⥤ D)\n  {c d : C} (f : c ⟶ d) :  \n  φ.map (G.inv f) = H.inv (φ.map f) := \ncalc φ.map (G.inv f) = (φ.map $ G.inv f) ≫ (𝟙 $ φ.obj c) : by rw [category.comp_id]\n                 ... = (φ.map $ G.inv f) ≫ ((φ.map f) ≫ (H.inv $ φ.map f)) : by rw [comp_inv]\n                 ... = ((φ.map $ G.inv f) ≫ (φ.map f)) ≫ (H.inv $ φ.map f) : by rw [category.assoc]\n                 ... = (φ.map $ G.inv f ≫ f) ≫ (H.inv $ φ.map f) : by rw [functor.map_comp']\n                 ... = (H.inv $ φ.map f) : by rw [inv_comp,functor.map_id,category.id_comp]            \n\n\nlemma lift_unique (V' : Type u') [G' : groupoid V']\n  (φ : prefunctor V V') (Φ : free_groupoid V ⥤ V') : (ι.comp Φ.to_prefunctor) = φ → Φ = (lift φ) :=\nbegin\n  rintro h, subst h,\n  fapply functor.ext',\n  { rintro x, dsimp [lift,ι], refl, },\n  { rintro X Y f, \n    simp only [eq_mpr_eq_cast, cast_eq],\n    refine quot.induction_on f _,\n    refine word.rec _ _ _,\n    { rintro x, convert functor.map_id Φ x, },\n    { rintro x y z p w IHw, \n      rw [quot_cons_p],\n      have : Φ.map (quot_comp (quot.mk red_step  $ letter_p p ) (quot.mk red_step w)) = Φ.map ((quot.mk red_step  $ letter_p p ) ≫  (quot.mk red_step w)), by refl,\n      simp only [this, functor.map_comp, IHw],\n      congr, }, \n    { rintro x y z p w IHw, \n      rw [quot_cons_n],\n      have : Φ.map (quot_comp (quot.mk red_step  $ letter_n p ) (quot.mk red_step w)) = Φ.map ((quot.mk red_step $ letter_n p ) ≫  (quot.mk red_step w)), by refl,\n      simp only [this, functor.map_comp, IHw, functor.map_comp], \n      apply congr_arg2,\n      { dsimp [lift,ι], rw ←word.reverse_letter_p,  \n        convert functor.groupoid_map_inv Φ (quot.mk red_step  $ letter_p p ) , },\n      { refl, }, }, },\n\nend\n\nend free\nend groupoid\nend category_theory", "meta": {"author": "bottine", "repo": "Bass-Serre", "sha": "e190368ec9313113f1b8795bd5770a20d42efce0", "save_path": "github-repos/lean/bottine-Bass-Serre", "path": "github-repos/lean/bottine-Bass-Serre/Bass-Serre-e190368ec9313113f1b8795bd5770a20d42efce0/src/free_groupoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.4704276767906052}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n\nCasts and heterogeneous equality. See also init.datatypes and init.logic.\n-/\n\nimport logic.eq logic.quantifiers\nopen eq.ops\n\nnamespace heq\n  universe variable u\n  variables {A B C : Type.{u}} {a a' : A} {b b' : B} {c : C}\n\n  theorem drec_on {C : Π {B : Type} (b : B), a == b → Type} (H₁ : a == b) (H₂ : C a (refl a)) :\n    C b H₁ :=\n  heq.rec (λ H₁ : a == a, show C a H₁, from H₂) H₁ H₁\n\n  theorem to_cast_eq (H : a == b) : cast (type_eq_of_heq H) a = b :=\n  drec_on H !cast_eq\nend heq\n\nsection\n  universe variables u v\n  variables {A A' B C : Type.{u}} {P P' : A → Type.{v}} {a a' : A} {b : B}\n\n  theorem hcongr_fun {f : Π x, P x} {f' : Π x, P' x} (a : A) (H₁ : f == f') (H₂ : P = P') :\n    f a == f' a :=\n  begin\n    cases H₂, cases H₁, reflexivity\n  end\n\n  theorem hcongr {P' : A' → Type} {f : Π a, P a} {f' : Π a', P' a'} {a : A} {a' : A'}\n      (Hf : f == f') (HP : P == P') (Ha : a == a') : f a == f' a' :=\n  begin\n    cases Ha, cases HP, cases Hf, reflexivity\n  end\n\n  theorem hcongr_arg (f : Πx, P x) {a b : A} (H : a = b) : f a == f b :=\n  H ▸ (heq.refl (f a))\nend\n\nsection\n  variables {A : Type} {B : A → Type} {C : Πa, B a → Type} {D : Πa b, C a b → Type}\n  variables {a a' : A} {b : B a} {b' : B a'} {c : C a b} {c' : C a' b'}\n\n  theorem hcongr_arg2 (f : Πa b, C a b) (Ha : a = a') (Hb : b == b') : f a b == f a' b' :=\n  hcongr (hcongr_arg f Ha) (hcongr_arg C Ha) Hb\n\n  theorem hcongr_arg3 (f : Πa b c, D a b c) (Ha : a = a') (Hb : b == b') (Hc : c == c')\n      : f a b c == f a' b' c' :=\n  hcongr (hcongr_arg2 f Ha Hb) (hcongr_arg2 D Ha Hb) Hc\nend\n\nsection\n  universe variables u v\n  variables {A A' B C : Type.{u}} {P P' : A → Type.{v}} {a a' : A} {b : B}\n\n  -- should H₁ be explicit (useful in e.g. hproof_irrel)\n  theorem eq_rec_to_heq {H₁ : a = a'} {p : P a} {p' : P a'} (H₂ : eq.rec_on H₁ p = p') : p == p' :=\n  by subst H₁; subst H₂\n\n  theorem cast_to_heq {H₁ : A = B} (H₂ : cast H₁ a = b) : a == b :=\n  eq_rec_to_heq H₂\n\n  theorem hproof_irrel {a b : Prop} (H : a = b) (H₁ : a) (H₂ : b) : H₁ == H₂ :=\n  eq_rec_to_heq (proof_irrel (cast H H₁) H₂)\n\n  --TODO: generalize to eq.rec. This is a special case of rec_on_comp in eq.lean\n  theorem cast_trans (Hab : A = B) (Hbc : B = C) (a : A) :\n    cast Hbc (cast Hab a) = cast (Hab ⬝ Hbc) a :=\n  by subst Hab\n\n  theorem pi_eq (H : P = P') : (Π x, P x) = (Π x, P' x) :=\n  by subst H\n\n  theorem rec_on_app (H : P = P') (f : Π x, P x) (a : A) : eq.rec_on H f a == f a :=\n  by subst H\n\n  theorem rec_on_pull (H : P = P') (f : Π x, P x) (a : A) :\n    eq.rec_on H f a = eq.rec_on (congr_fun H a) (f a) :=\n  eq_of_heq (calc\n    eq.rec_on H f a == f a                   : rec_on_app H f a\n      ... == eq.rec_on (congr_fun H a) (f a) : heq.symm (eq_rec_heq (congr_fun H a) (f a)))\n\n  theorem cast_app (H : P = P') (f : Π x, P x) (a : A) : cast (pi_eq H) f a == f a :=\n  by subst H\nend\n\n-- function extensionality wrt heterogeneous equality\ntheorem hfunext {A : Type} {B : A → Type} {B' : A → Type} {f : Π x, B x} {g : Π x, B' x}\n                (H : ∀ a, f a == g a) : f == g :=\ncast_to_heq (funext (λ a, eq_of_heq (heq.trans (cast_app (funext (λ x, type_eq_of_heq (H x))) f a) (H a))))\n\nsection\n  variables {A : Type} {B : A → Type} {C : Πa, B a → Type} {D : Πa b, C a b → Type}\n            {E : Πa b c, D a b c → Type} {F : Type}\n  variables {a a' : A}\n            {b : B a} {b' : B a'}\n            {c : C a b} {c' : C a' b'}\n            {d : D a b c} {d' : D a' b' c'}\n\n  theorem hcongr_arg4 (f : Πa b c d, E a b c d)\n    (Ha : a = a') (Hb : b == b') (Hc : c == c') (Hd : d == d') : f a b c d == f a' b' c' d' :=\n  hcongr (hcongr_arg3 f Ha Hb Hc) (hcongr_arg3 E Ha Hb Hc) Hd\n\n  theorem dcongr_arg2 (f : Πa, B a → F) (Ha : a = a') (Hb : eq.rec_on Ha b = b')\n      : f a b = f a' b' :=\n  eq_of_heq (hcongr_arg2 f Ha (eq_rec_to_heq Hb))\n\n  theorem dcongr_arg3 (f : Πa b, C a b → F) (Ha : a = a') (Hb : eq.rec_on Ha b = b')\n      (Hc : cast (dcongr_arg2 C Ha Hb) c = c') : f a b c = f a' b' c' :=\n  eq_of_heq (hcongr_arg3 f Ha (eq_rec_to_heq Hb) (eq_rec_to_heq Hc))\n\n  theorem dcongr_arg4 (f : Πa b c, D a b c → F) (Ha : a = a') (Hb : eq.rec_on Ha b = b')\n      (Hc : cast (dcongr_arg2 C Ha Hb) c = c')\n      (Hd : cast (dcongr_arg3 D Ha Hb Hc) d = d') : f a b c d = f a' b' c' d' :=\n  eq_of_heq (hcongr_arg4 f Ha (eq_rec_to_heq Hb) (eq_rec_to_heq Hc) (eq_rec_to_heq Hd))\n\n  -- mixed versions (we want them for example if C a' b' is a subsingleton, like a proposition.\n  -- Then proving eq is easier than proving heq)\n  theorem hdcongr_arg3 (f : Πa b, C a b → F) (Ha : a = a') (Hb : b == b')\n      (Hc : cast (eq_of_heq (hcongr_arg2 C Ha Hb)) c = c')\n        : f a b c = f a' b' c' :=\n  eq_of_heq (hcongr_arg3 f Ha Hb (eq_rec_to_heq Hc))\n\n  theorem hhdcongr_arg4 (f : Πa b c, D a b c → F) (Ha : a = a') (Hb : b == b')\n      (Hc : c == c')\n      (Hd : cast (dcongr_arg3 D Ha (!eq.rec_on_irrel_arg ⬝ heq.to_cast_eq Hb)\n                                   (!eq.rec_on_irrel_arg ⬝ heq.to_cast_eq Hc)) d = d')\n        : f a b c d = f a' b' c' d' :=\n  eq_of_heq (hcongr_arg4 f Ha Hb Hc (eq_rec_to_heq Hd))\n\n  theorem hddcongr_arg4 (f : Πa b c, D a b c → F) (Ha : a = a') (Hb : b == b')\n      (Hc : cast (eq_of_heq (hcongr_arg2 C Ha Hb)) c = c')\n      (Hd : cast (hdcongr_arg3 D Ha Hb Hc) d = d')\n        : f a b c d = f a' b' c' d' :=\n  eq_of_heq (hcongr_arg4 f Ha Hb (eq_rec_to_heq Hc) (eq_rec_to_heq Hd))\nend\n", "meta": {"author": "Bolt64", "repo": "lean2-aur", "sha": "1d7148e58a17b2d326b032ed1ebf8c5217320242", "save_path": "github-repos/lean/Bolt64-lean2-aur", "path": "github-repos/lean/Bolt64-lean2-aur/lean2-aur-1d7148e58a17b2d326b032ed1ebf8c5217320242/library/logic/cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786991753931, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4704276767906052}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport tactic.wlog\n\nsection wlog\n\nexample {x y : ℕ} (a : x = 1) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x = y,\n  { guard_target x = y ∨ y = x,\n    admit },\n  { guard_hyp h : x = y,\n    guard_hyp a : x = 1,\n    admit }\nend\n\nexample {x y : ℕ} : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x ≤ y,\n  { guard_hyp h : x ≤ y,\n    guard_target false,\n    admit }\nend\n\nexample {x y z : ℕ} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : x ≤ y + z using x y,\n  { guard_target x ≤ y + z ∨ y ≤ x + z,\n    admit },\n  { guard_hyp case : x ≤ y + z,\n    guard_target false,\n    admit },\nend\n\nexample {x : ℕ} (S₀ S₁ : set ℕ) (P : ℕ → Prop)\n  (h : x ∈ S₀ ∪ S₁) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h' : x ∈ S₀ using S₀ S₁,\n  { guard_target x ∈ S₀ ∨ x ∈ S₁,\n    admit },\n  { guard_hyp h  : x ∈ S₀ ∪ S₁,\n    guard_hyp h' : x ∈ S₀,\n    admit }\nend\n\nexample {n m i : ℕ} {p : ℕ → ℕ → ℕ → Prop} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : p n m i using [n m i, n i m, i n m],\n  { guard_target p n m i ∨ p n i m ∨ p i n m,\n    admit },\n  { guard_hyp case : p n m i,\n    admit }\nend\n\nexample {n m i : ℕ} {p : ℕ → Prop} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : p n using [n m i, m n i, i n m],\n  { guard_target p n ∨ p m ∨ p i,\n    admit },\n  { guard_hyp case : p n,\n    admit }\nend\n\nexample {n m i : ℕ} {p : ℕ → ℕ → Prop} {q : ℕ → ℕ → ℕ → Prop} : true :=\nbegin\n  suffices : q n m i, trivial,\n  have h : p n i ∨ p i m ∨ p m i, from sorry,\n  wlog : p n i := h using n m i,\n  { guard_hyp h : p n i,\n    guard_target q n m i,\n    admit },\n  { guard_hyp h : p i m,\n    guard_hyp this : q i m n,\n    guard_target q n m i,\n    admit },\n  { guard_hyp h : p m i,\n    guard_hyp this : q m i n,\n    guard_target q n m i,\n    admit },\nend\n\nexample (X : Type) (A B C : set X) : A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x ∈ B using B C,\n    { assumption },\n    { exact or.inl ⟨hyp_left, x_in⟩ } },\n  { intro hyp,\n    wlog x_in : x ∈ A ∩ B using B C,\n    { assumption },\n    { exact ⟨x_in.left, or.inl x_in.right⟩ } }\nend\n\nexample (X : Type) (A B C : set X) : A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    wlog x_in : x ∈ B := hyp.2 using B C,\n    { exact or.inl ⟨hyp.1, x_in⟩ } },\n  { intro hyp,\n    wlog x_in : x ∈ A ∩ B := hyp using B C,\n    { exact ⟨x_in.left, or.inl x_in.right⟩ } }\nend\n\nexample (X : Type) (A B C : set X) : A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x ∈ B := hyp_right using B C,\n    { exact or.inl ⟨hyp_left, x_in⟩ }, },\n  { intro hyp,\n    wlog x_in : x ∈ A ∩ B := hyp using B C,\n    { exact ⟨x_in.left, or.inl x_in.right⟩ } }\nend\n\nend wlog\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/wlog.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.47042767210398945}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Markus Himmel, Bhavik Mehta\n-/\nimport category_theory.limits.shapes.wide_pullbacks\nimport category_theory.limits.shapes.binary_products\n\n/-!\n# Pullbacks\n\nWe define a category `walking_cospan` (resp. `walking_span`), which is the index category\nfor the given data for a pullback (resp. pushout) diagram. Convenience methods `cospan f g`\nand `span f g` construct functors from the walking (co)span, hitting the given morphisms.\n\nWe define `pullback f g` and `pushout f g` as limits and colimits of such functors.\n\n## References\n* [Stacks: Fibre products](https://stacks.math.columbia.edu/tag/001U)\n* [Stacks: Pushouts](https://stacks.math.columbia.edu/tag/0025)\n-/\n\nnoncomputable theory\n\nopen category_theory\n\nnamespace category_theory.limits\n\nuniverses v u u₂\n\nlocal attribute [tidy] tactic.case_bash\n\n/--\nThe type of objects for the diagram indexing a pullback, defined as a special case of\n`wide_pullback_shape`.\n-/\nabbreviation walking_cospan : Type v := wide_pullback_shape walking_pair\n\n/-- The left point of the walking cospan. -/\n@[pattern] abbreviation walking_cospan.left : walking_cospan := some walking_pair.left\n/-- The right point of the walking cospan. -/\n@[pattern] abbreviation walking_cospan.right : walking_cospan := some walking_pair.right\n/-- The central point of the walking cospan. -/\n@[pattern] abbreviation walking_cospan.one : walking_cospan := none\n\n/--\nThe type of objects for the diagram indexing a pushout, defined as a special case of\n`wide_pushout_shape`.\n-/\nabbreviation walking_span : Type v := wide_pushout_shape walking_pair\n\n/-- The left point of the walking span. -/\n@[pattern] abbreviation walking_span.left : walking_span := some walking_pair.left\n/-- The right point of the walking span. -/\n@[pattern] abbreviation walking_span.right : walking_span := some walking_pair.right\n/-- The central point of the walking span. -/\n@[pattern] abbreviation walking_span.zero : walking_span := none\n\nnamespace walking_cospan\n\n/-- The type of arrows for the diagram indexing a pullback. -/\nabbreviation hom : walking_cospan → walking_cospan → Type v := wide_pullback_shape.hom\n\n/-- The left arrow of the walking cospan. -/\n@[pattern] abbreviation hom.inl : left ⟶ one := wide_pullback_shape.hom.term _\n/-- The right arrow of the walking cospan. -/\n@[pattern] abbreviation hom.inr : right ⟶ one := wide_pullback_shape.hom.term _\n/-- The identity arrows of the walking cospan. -/\n@[pattern] abbreviation hom.id (X : walking_cospan) : X ⟶ X := wide_pullback_shape.hom.id X\n\ninstance (X Y : walking_cospan) : subsingleton (X ⟶ Y) := by tidy\n\nend walking_cospan\n\nnamespace walking_span\n\n/-- The type of arrows for the diagram indexing a pushout. -/\nabbreviation hom : walking_span → walking_span → Type v := wide_pushout_shape.hom\n\n/-- The left arrow of the walking span. -/\n@[pattern] abbreviation hom.fst : zero ⟶ left := wide_pushout_shape.hom.init _\n/-- The right arrow of the walking span. -/\n@[pattern] abbreviation hom.snd : zero ⟶ right := wide_pushout_shape.hom.init _\n/-- The identity arrows of the walking span. -/\n@[pattern] abbreviation hom.id (X : walking_span) : X ⟶ X := wide_pushout_shape.hom.id X\n\ninstance (X Y : walking_span) : subsingleton (X ⟶ Y) := by tidy\n\nend walking_span\n\nopen walking_span.hom walking_cospan.hom wide_pullback_shape.hom wide_pushout_shape.hom\n\nvariables {C : Type u} [category.{v} C]\n\n/-- `cospan f g` is the functor from the walking cospan hitting `f` and `g`. -/\ndef cospan {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : walking_cospan ⥤ C :=\nwide_pullback_shape.wide_cospan Z\n  (λ j, walking_pair.cases_on j X Y) (λ j, walking_pair.cases_on j f g)\n\n/-- `span f g` is the functor from the walking span hitting `f` and `g`. -/\ndef span {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : walking_span ⥤ C :=\nwide_pushout_shape.wide_span X\n  (λ j, walking_pair.cases_on j Y Z) (λ j, walking_pair.cases_on j f g)\n\n@[simp] lemma cospan_left {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n  (cospan f g).obj walking_cospan.left = X := rfl\n@[simp] lemma span_left {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :\n  (span f g).obj walking_span.left = Y := rfl\n\n@[simp] lemma cospan_right {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n  (cospan f g).obj walking_cospan.right = Y := rfl\n@[simp] lemma span_right {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :\n  (span f g).obj walking_span.right = Z := rfl\n\n@[simp] lemma cospan_one {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n  (cospan f g).obj walking_cospan.one = Z := rfl\n@[simp] lemma span_zero {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :\n  (span f g).obj walking_span.zero = X := rfl\n\n@[simp] lemma cospan_map_inl {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n  (cospan f g).map walking_cospan.hom.inl = f := rfl\n@[simp] lemma span_map_fst {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :\n  (span f g).map walking_span.hom.fst = f := rfl\n\n@[simp] lemma cospan_map_inr {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n  (cospan f g).map walking_cospan.hom.inr = g := rfl\n@[simp] lemma span_map_snd {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :\n  (span f g).map walking_span.hom.snd = g := rfl\n\nlemma cospan_map_id {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (w : walking_cospan) :\n  (cospan f g).map (walking_cospan.hom.id w) = 𝟙 _ := rfl\nlemma span_map_id {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) (w : walking_span) :\n  (span f g).map (walking_span.hom.id w) = 𝟙 _ := rfl\n\n/-- Every diagram indexing an pullback is naturally isomorphic (actually, equal) to a `cospan` -/\n@[simps {rhs_md := semireducible}]\ndef diagram_iso_cospan (F : walking_cospan ⥤ C) :\n  F ≅ cospan (F.map inl) (F.map inr) :=\nnat_iso.of_components (λ j, eq_to_iso (by tidy)) (by tidy)\n\n/-- Every diagram indexing a pushout is naturally isomorphic (actually, equal) to a `span` -/\n@[simps {rhs_md := semireducible}]\ndef diagram_iso_span (F : walking_span ⥤ C) :\n  F ≅ span (F.map fst) (F.map snd) :=\nnat_iso.of_components (λ j, eq_to_iso (by tidy)) (by tidy)\n\nvariables {X Y Z : C}\n\n/-- A pullback cone is just a cone on the cospan formed by two morphisms `f : X ⟶ Z` and\n    `g : Y ⟶ Z`.-/\nabbreviation pullback_cone (f : X ⟶ Z) (g : Y ⟶ Z) := cone (cospan f g)\n\nnamespace pullback_cone\nvariables {f : X ⟶ Z} {g : Y ⟶ Z}\n\n/-- The first projection of a pullback cone. -/\nabbreviation fst (t : pullback_cone f g) : t.X ⟶ X := t.π.app walking_cospan.left\n\n/-- The second projection of a pullback cone. -/\nabbreviation snd (t : pullback_cone f g) : t.X ⟶ Y := t.π.app walking_cospan.right\n\n/-- This is a slightly more convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content -/\ndef is_limit_aux (t : pullback_cone f g) (lift : Π (s : pullback_cone f g), s.X ⟶ t.X)\n  (fac_left : ∀ (s : pullback_cone f g), lift s ≫ t.fst = s.fst)\n  (fac_right : ∀ (s : pullback_cone f g), lift s ≫ t.snd = s.snd)\n  (uniq : ∀ (s : pullback_cone f g) (m : s.X ⟶ t.X)\n    (w : ∀ j : walking_cospan, m ≫ t.π.app j = s.π.app j), m = lift s) :\n  is_limit t :=\n{ lift := lift,\n  fac' := λ s j, option.cases_on j\n    (by { rw [← s.w inl, ← t.w inl, ←category.assoc], congr, exact fac_left s, } )\n    (λ j', walking_pair.cases_on j' (fac_left s) (fac_right s)),\n  uniq' := uniq }\n\n/-- This is another convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef is_limit_aux' (t : pullback_cone f g)\n  (create : Π (s : pullback_cone f g),\n    {l // l ≫ t.fst = s.fst ∧ l ≫ t.snd = s.snd ∧\n            ∀ {m}, m ≫ t.fst = s.fst → m ≫ t.snd = s.snd → m = l}) :\nlimits.is_limit t :=\npullback_cone.is_limit_aux t\n  (λ s, (create s).1)\n  (λ s, (create s).2.1)\n  (λ s, (create s).2.2.1)\n  (λ s m w, (create s).2.2.2 (w walking_cospan.left) (w walking_cospan.right))\n\n/-- A pullback cone on `f` and `g` is determined by morphisms `fst : W ⟶ X` and `snd : W ⟶ Y`\n    such that `fst ≫ f = snd ≫ g`. -/\n@[simps]\ndef mk {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : pullback_cone f g :=\n{ X := W,\n  π := { app := λ j, option.cases_on j (fst ≫ f) (λ j', walking_pair.cases_on j' fst snd) } }\n\n@[simp] lemma mk_π_app_left {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n  (mk fst snd eq).π.app walking_cospan.left = fst := rfl\n@[simp] lemma mk_π_app_right {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n  (mk fst snd eq).π.app walking_cospan.right = snd := rfl\n@[simp] lemma mk_π_app_one {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n  (mk fst snd eq).π.app walking_cospan.one = fst ≫ f := rfl\n\n@[simp] lemma mk_fst {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n  (mk fst snd eq).fst = fst := rfl\n@[simp] lemma mk_snd {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n  (mk fst snd eq).snd = snd := rfl\n\n@[reassoc] lemma condition (t : pullback_cone f g) : fst t ≫ f = snd t ≫ g :=\n(t.w inl).trans (t.w inr).symm\n\n/-- To check whether a morphism is equalized by the maps of a pullback cone, it suffices to check\n  it for `fst t` and `snd t` -/\nlemma equalizer_ext (t : pullback_cone f g) {W : C} {k l : W ⟶ t.X}\n  (h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) :\n  ∀ (j : walking_cospan), k ≫ t.π.app j = l ≫ t.π.app j\n| (some walking_pair.left) := h₀\n| (some walking_pair.right) := h₁\n| none := by rw [← t.w inl, reassoc_of h₀]\n\nlemma is_limit.hom_ext {t : pullback_cone f g} (ht : is_limit t) {W : C} {k l : W ⟶ t.X}\n  (h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) : k = l :=\nht.hom_ext $ equalizer_ext _ h₀ h₁\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W ⟶ X` and `k : W ⟶ Y` are such that\n    `h ≫ f = k ≫ g`, then we have `l : W ⟶ t.X` satisfying `l ≫ fst t = h` and `l ≫ snd t = k`.\n    -/\ndef is_limit.lift' {t : pullback_cone f g} (ht : is_limit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)\n  (w : h ≫ f = k ≫ g) : {l : W ⟶ t.X // l ≫ fst t = h ∧ l ≫ snd t = k} :=\n⟨ht.lift $ pullback_cone.mk _ _ w, ht.fac _ _, ht.fac _ _⟩\n\n/--\nThis is a more convenient formulation to show that a `pullback_cone` constructed using\n`pullback_cone.mk` is a limit cone.\n-/\ndef is_limit.mk {W : C} {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g)\n  (lift : Π (s : pullback_cone f g), s.X ⟶ W)\n  (fac_left : ∀ (s : pullback_cone f g), lift s ≫ fst = s.fst)\n  (fac_right : ∀ (s : pullback_cone f g), lift s ≫ snd = s.snd)\n  (uniq : ∀ (s : pullback_cone f g) (m : s.X ⟶ W)\n    (w_fst : m ≫ fst = s.fst) (w_snd : m ≫ snd = s.snd), m = lift s) :\n  is_limit (mk fst snd eq) :=\nis_limit_aux _ lift fac_left fac_right\n  (λ s m w, uniq s m (w walking_cospan.left) (w walking_cospan.right))\n\n/-- The flip of a pullback square is a pullback square. -/\ndef flip_is_limit {W : C} {h : W ⟶ X} {k : W ⟶ Y}\n  {comm : h ≫ f = k ≫ g} (t : is_limit (mk _ _ comm.symm)) :\n  is_limit (mk _ _ comm) :=\nis_limit_aux' _ $ λ s,\nbegin\n  refine ⟨(is_limit.lift' t _ _ s.condition.symm).1,\n          (is_limit.lift' t _ _ _).2.2,\n          (is_limit.lift' t _ _ _).2.1, λ m m₁ m₂, t.hom_ext _⟩,\n  apply (mk k h _).equalizer_ext,\n  { rwa (is_limit.lift' t _ _ _).2.1 },\n  { rwa (is_limit.lift' t _ _ _).2.2 },\nend\n\n/--\nThe pullback cone `(𝟙 X, 𝟙 X)` for the pair `(f, f)` is a limit if `f` is a mono. The converse is\nshown in `mono_of_pullback_is_id`.\n-/\ndef is_limit_mk_id_id (f : X ⟶ Y) [mono f] :\n  is_limit (mk (𝟙 X) (𝟙 X) rfl : pullback_cone f f) :=\nis_limit.mk _\n  (λ s, s.fst)\n  (λ s, category.comp_id _)\n  (λ s, by rw [←cancel_mono f, category.comp_id, s.condition])\n  (λ s m m₁ m₂, by simpa using m₁)\n\n/--\n`f` is a mono if the pullback cone `(𝟙 X, 𝟙 X)` is a limit for the pair `(f, f)`. The converse is\ngiven in `pullback_cone.is_id_of_mono`.\n-/\nlemma mono_of_is_limit_mk_id_id (f : X ⟶ Y)\n  (t : is_limit (mk (𝟙 X) (𝟙 X) rfl : pullback_cone f f)) :\n  mono f :=\n⟨λ Z g h eq, by { rcases pullback_cone.is_limit.lift' t _ _ eq with ⟨_, rfl, rfl⟩, refl } ⟩\n\nend pullback_cone\n\n/-- A pushout cocone is just a cocone on the span formed by two morphisms `f : X ⟶ Y` and\n    `g : X ⟶ Z`.-/\nabbreviation pushout_cocone (f : X ⟶ Y) (g : X ⟶ Z) := cocone (span f g)\n\nnamespace pushout_cocone\n\nvariables {f : X ⟶ Y} {g : X ⟶ Z}\n\n/-- The first inclusion of a pushout cocone. -/\nabbreviation inl (t : pushout_cocone f g) : Y ⟶ t.X := t.ι.app walking_span.left\n\n/-- The second inclusion of a pushout cocone. -/\nabbreviation inr (t : pushout_cocone f g) : Z ⟶ t.X := t.ι.app walking_span.right\n\n/-- This is a slightly more convenient method to verify that a pushout cocone is a colimit cocone.\n    It only asks for a proof of facts that carry any mathematical content -/\ndef is_colimit_aux (t : pushout_cocone f g) (desc : Π (s : pushout_cocone f g), t.X ⟶ s.X)\n  (fac_left : ∀ (s : pushout_cocone f g), t.inl ≫ desc s = s.inl)\n  (fac_right : ∀ (s : pushout_cocone f g), t.inr ≫ desc s = s.inr)\n  (uniq : ∀ (s : pushout_cocone f g) (m : t.X ⟶ s.X)\n    (w : ∀ j : walking_span, t.ι.app j ≫ m = s.ι.app j), m = desc s) :\n  is_colimit t :=\n{ desc := desc,\n  fac' := λ s j, option.cases_on j (by { simp [← s.w fst, ← t.w fst, fac_left s] } )\n                    (λ j', walking_pair.cases_on j' (fac_left s) (fac_right s)),\n  uniq' := uniq }\n\n/-- This is another convenient method to verify that a pushout cocone is a colimit cocone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef is_colimit_aux' (t : pushout_cocone f g)\n  (create : Π (s : pushout_cocone f g),\n    {l // t.inl ≫ l = s.inl ∧ t.inr ≫ l = s.inr ∧\n            ∀ {m}, t.inl ≫ m = s.inl → t.inr ≫ m = s.inr → m = l}) :\nis_colimit t :=\nis_colimit_aux t\n  (λ s, (create s).1)\n  (λ s, (create s).2.1)\n  (λ s, (create s).2.2.1)\n  (λ s m w, (create s).2.2.2 (w walking_cospan.left) (w walking_cospan.right))\n\n/-- A pushout cocone on `f` and `g` is determined by morphisms `inl : Y ⟶ W` and `inr : Z ⟶ W` such\n    that `f ≫ inl = g ↠ inr`. -/\n@[simps]\ndef mk {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : pushout_cocone f g :=\n{ X := W,\n  ι := { app := λ j, option.cases_on j (f ≫ inl) (λ j', walking_pair.cases_on j' inl inr) } }\n\n@[simp] lemma mk_ι_app_left {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n  (mk inl inr eq).ι.app walking_span.left = inl := rfl\n@[simp] lemma mk_ι_app_right {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n  (mk inl inr eq).ι.app walking_span.right = inr := rfl\n@[simp] lemma mk_ι_app_zero {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n  (mk inl inr eq).ι.app walking_span.zero = f ≫ inl := rfl\n\n@[simp] lemma mk_inl {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n  (mk inl inr eq).inl = inl := rfl\n@[simp] lemma mk_inr {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n  (mk inl inr eq).inr = inr := rfl\n\n@[reassoc] lemma condition (t : pushout_cocone f g) : f ≫ (inl t) = g ≫ (inr t) :=\n(t.w fst).trans (t.w snd).symm\n\n/-- To check whether a morphism is coequalized by the maps of a pushout cocone, it suffices to check\n  it for `inl t` and `inr t` -/\nlemma coequalizer_ext (t : pushout_cocone f g) {W : C} {k l : t.X ⟶ W}\n  (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) :\n  ∀ (j : walking_span), t.ι.app j ≫ k = t.ι.app j ≫ l\n| (some walking_pair.left) := h₀\n| (some walking_pair.right) := h₁\n| none := by rw [← t.w fst, category.assoc, category.assoc, h₀]\n\nlemma is_colimit.hom_ext {t : pushout_cocone f g} (ht : is_colimit t) {W : C} {k l : t.X ⟶ W}\n  (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) : k = l :=\nht.hom_ext $ coequalizer_ext _ h₀ h₁\n\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y ⟶ W` and `k : Z ⟶ W` are\n    morphisms satisfying `f ≫ h = g ≫ k`, then we have a factorization `l : t.X ⟶ W` such that\n    `inl t ≫ l = h` and `inr t ≫ l = k`. -/\ndef is_colimit.desc' {t : pushout_cocone f g} (ht : is_colimit t) {W : C} (h : Y ⟶ W) (k : Z ⟶ W)\n  (w : f ≫ h = g ≫ k) : {l : t.X ⟶ W // inl t ≫ l = h ∧ inr t ≫ l = k } :=\n⟨ht.desc $ pushout_cocone.mk _ _ w, ht.fac _ _, ht.fac _ _⟩\n\n/--\nThis is a more convenient formulation to show that a `pushout_cocone` constructed using\n`pushout_cocone.mk` is a colimit cocone.\n-/\ndef is_colimit.mk {W : C} {inl : Y ⟶ W} {inr : Z ⟶ W} (eq : f ≫ inl = g ≫ inr)\n  (desc : Π (s : pushout_cocone f g), W ⟶ s.X)\n  (fac_left : ∀ (s : pushout_cocone f g), inl ≫ desc s = s.inl)\n  (fac_right : ∀ (s : pushout_cocone f g), inr ≫ desc s = s.inr)\n  (uniq : ∀ (s : pushout_cocone f g) (m : W ⟶ s.X)\n    (w_inl : inl ≫ m = s.inl) (w_inr : inr ≫ m = s.inr), m = desc s) :\n  is_colimit (mk inl inr eq) :=\nis_colimit_aux _ desc fac_left fac_right\n  (λ s m w, uniq s m (w walking_cospan.left) (w walking_cospan.right))\n\n/-- The flip of a pushout square is a pushout square. -/\ndef flip_is_colimit {W : C} {h : Y ⟶ W} {k : Z ⟶ W}\n  {comm : f ≫ h = g ≫ k} (t : is_colimit (mk _ _ comm.symm)) :\n  is_colimit (mk _ _ comm) :=\nis_colimit_aux' _ $ λ s,\nbegin\n  refine ⟨(is_colimit.desc' t _ _ s.condition.symm).1,\n          (is_colimit.desc' t _ _ _).2.2,\n          (is_colimit.desc' t _ _ _).2.1, λ m m₁ m₂, t.hom_ext _⟩,\n  apply (mk k h _).coequalizer_ext,\n  { rwa (is_colimit.desc' t _ _ _).2.1 },\n  { rwa (is_colimit.desc' t _ _ _).2.2 },\nend\n\nend pushout_cocone\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pullbacks. Given `F : walking_cospan ⥤ C`, which is really the same as\n    `cospan (F.map inl) (F.map inr)`, and a pullback cone on `F.map inl` and `F.map inr`, we\n    get a cone on `F`.\n\n    If you're thinking about using this, have a look at `has_pullbacks_of_has_limit_cospan`,\n    which you may find to be an easier way of achieving your goal. -/\n@[simps]\ndef cone.of_pullback_cone\n  {F : walking_cospan ⥤ C} (t : pullback_cone (F.map inl) (F.map inr)) : cone F :=\n{ X := t.X,\n  π := t.π ≫ (diagram_iso_cospan F).inv }\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pushout. Given `F : walking_span ⥤ C`, which is really the same as\n    `span (F.map fst) (F.mal snd)`, and a pushout cocone on `F.map fst` and `F.map snd`,\n    we get a cocone on `F`.\n\n    If you're thinking about using this, have a look at `has_pushouts_of_has_colimit_span`, which\n    you may find to be an easiery way of achieving your goal.  -/\n@[simps]\ndef cocone.of_pushout_cocone\n  {F : walking_span ⥤ C} (t : pushout_cocone (F.map fst) (F.map snd)) : cocone F :=\n{ X := t.X,\n  ι := (diagram_iso_span F).hom ≫ t.ι }\n\n/-- Given `F : walking_cospan ⥤ C`, which is really the same as `cospan (F.map inl) (F.map inr)`,\n    and a cone on `F`, we get a pullback cone on `F.map inl` and `F.map inr`. -/\n@[simps]\ndef pullback_cone.of_cone\n  {F : walking_cospan ⥤ C} (t : cone F) : pullback_cone (F.map inl) (F.map inr) :=\n{ X := t.X,\n  π := t.π ≫ (diagram_iso_cospan F).hom }\n\n/-- Given `F : walking_span ⥤ C`, which is really the same as `span (F.map fst) (F.map snd)`,\n    and a cocone on `F`, we get a pushout cocone on `F.map fst` and `F.map snd`. -/\n@[simps]\ndef pushout_cocone.of_cocone\n  {F : walking_span ⥤ C} (t : cocone F) : pushout_cocone (F.map fst) (F.map snd) :=\n{ X := t.X,\n  ι := (diagram_iso_span F).inv ≫ t.ι }\n\n/--\n`has_pullback f g` represents a particular choice of limiting cone\nfor the pair of morphisms `f : X ⟶ Z` and `g : Y ⟶ Z`.\n-/\nabbreviation has_pullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) := has_limit (cospan f g)\n/--\n`has_pushout f g` represents a particular choice of colimiting cocone\nfor the pair of morphisms `f : X ⟶ Y` and `g : X ⟶ Z`.\n-/\nabbreviation has_pushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) := has_colimit (span f g)\n\n/-- `pullback f g` computes the pullback of a pair of morphisms with the same target. -/\nabbreviation pullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] :=\nlimit (cospan f g)\n/-- `pushout f g` computes the pushout of a pair of morphisms with the same source. -/\nabbreviation pushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) [has_pushout f g] :=\ncolimit (span f g)\n\n/-- The first projection of the pullback of `f` and `g`. -/\nabbreviation pullback.fst {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] :\n  pullback f g ⟶ X :=\nlimit.π (cospan f g) walking_cospan.left\n\n/-- The second projection of the pullback of `f` and `g`. -/\nabbreviation pullback.snd {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] :\n  pullback f g ⟶ Y :=\nlimit.π (cospan f g) walking_cospan.right\n\n/-- The first inclusion into the pushout of `f` and `g`. -/\nabbreviation pushout.inl {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] :\n  Y ⟶ pushout f g :=\ncolimit.ι (span f g) walking_span.left\n\n/-- The second inclusion into the pushout of `f` and `g`. -/\nabbreviation pushout.inr {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] :\n  Z ⟶ pushout f g :=\ncolimit.ι (span f g) walking_span.right\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `pullback.lift : W ⟶ pullback f g`. -/\nabbreviation pullback.lift {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g]\n  (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : W ⟶ pullback f g :=\nlimit.lift _ (pullback_cone.mk h k w)\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `pushout.desc : pushout f g ⟶ W`. -/\nabbreviation pushout.desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g]\n  (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout f g ⟶ W :=\ncolimit.desc _ (pushout_cocone.mk h k w)\n\n@[simp, reassoc]\nlemma pullback.lift_fst {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g]\n  (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : pullback.lift h k w ≫ pullback.fst = h :=\nlimit.lift_π _ _\n\n@[simp, reassoc]\nlemma pullback.lift_snd {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g]\n  (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : pullback.lift h k w ≫ pullback.snd = k :=\nlimit.lift_π _ _\n\n@[simp, reassoc]\nlemma pushout.inl_desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g]\n  (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout.inl ≫ pushout.desc h k w = h :=\ncolimit.ι_desc _ _\n\n@[simp, reassoc]\nlemma pushout.inr_desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g]\n  (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout.inr ≫ pushout.desc h k w = k :=\ncolimit.ι_desc _ _\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `l : W ⟶ pullback f g` such that `l ≫ pullback.fst = h` and `l ≫ pullback.snd = k`. -/\ndef pullback.lift' {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g]\n  (h : W ⟶ X) (k : W ⟶ Y) (w : h ≫ f = k ≫ g) :\n  {l : W ⟶ pullback f g // l ≫ pullback.fst = h ∧ l ≫ pullback.snd = k} :=\n⟨pullback.lift h k w, pullback.lift_fst _ _ _, pullback.lift_snd _ _ _⟩\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `l : pushout f g ⟶ W` such that `pushout.inl ≫ l = h` and `pushout.inr ≫ l = k`. -/\ndef pullback.desc' {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g]\n  (h : Y ⟶ W) (k : Z ⟶ W) (w : f ≫ h = g ≫ k) :\n  {l : pushout f g ⟶ W // pushout.inl ≫ l = h ∧ pushout.inr ≫ l = k} :=\n⟨pushout.desc h k w, pushout.inl_desc _ _ _, pushout.inr_desc _ _ _⟩\n\n@[reassoc]\nlemma pullback.condition {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g] :\n  (pullback.fst : pullback f g ⟶ X) ≫ f = pullback.snd ≫ g :=\npullback_cone.condition _\n\n@[reassoc]\nlemma pushout.condition {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] :\n  f ≫ (pushout.inl : Y ⟶ pushout f g) = g ≫ pushout.inr :=\npushout_cocone.condition _\n\n/-- Two morphisms into a pullback are equal if their compositions with the pullback morphisms are\n    equal -/\n@[ext] lemma pullback.hom_ext {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g]\n  {W : C} {k l : W ⟶ pullback f g} (h₀ : k ≫ pullback.fst = l ≫ pullback.fst)\n  (h₁ : k ≫ pullback.snd = l ≫ pullback.snd) : k = l :=\nlimit.hom_ext $ pullback_cone.equalizer_ext _ h₀ h₁\n\n/-- The pullback cone built from the pullback projections is a pullback. -/\ndef pullback_is_pullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [has_pullback f g] :\n  is_limit (pullback_cone.mk (pullback.fst : pullback f g ⟶ _) pullback.snd pullback.condition) :=\npullback_cone.is_limit.mk _ (λ s, pullback.lift s.fst s.snd s.condition)\n  (by simp) (by simp) (by tidy)\n\n/-- The pullback of a monomorphism is a monomorphism -/\ninstance pullback.fst_of_mono {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g]\n  [mono g] : mono (pullback.fst : pullback f g ⟶ X) :=\n⟨λ W u v h, pullback.hom_ext h $ (cancel_mono g).1 $ by simp [← pullback.condition, reassoc_of h]⟩\n\n/-- The pullback of a monomorphism is a monomorphism -/\ninstance pullback.snd_of_mono {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [has_pullback f g]\n  [mono f] : mono (pullback.snd : pullback f g ⟶ Y) :=\n⟨λ W u v h, pullback.hom_ext ((cancel_mono f).1 $ by simp [pullback.condition, reassoc_of h]) h⟩\n\n/-- Two morphisms out of a pushout are equal if their compositions with the pushout morphisms are\n    equal -/\n@[ext] lemma pushout.hom_ext {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g]\n  {W : C} {k l : pushout f g ⟶ W} (h₀ : pushout.inl ≫ k = pushout.inl ≫ l)\n  (h₁ : pushout.inr ≫ k = pushout.inr ≫ l) : k = l :=\ncolimit.hom_ext $ pushout_cocone.coequalizer_ext _ h₀ h₁\n\n/-- The pushout of an epimorphism is an epimorphism -/\ninstance pushout.inl_of_epi {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] [epi g] :\n  epi (pushout.inl : Y ⟶ pushout f g) :=\n⟨λ W u v h, pushout.hom_ext h $ (cancel_epi g).1 $ by simp [← pushout.condition_assoc, h] ⟩\n\n/-- The pushout of an epimorphism is an epimorphism -/\ninstance pushout.inr_of_epi {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [has_pushout f g] [epi f] :\n  epi (pushout.inr : Z ⟶ pushout f g) :=\n⟨λ W u v h, pushout.hom_ext ((cancel_epi f).1 $ by simp [pushout.condition_assoc, h]) h⟩\n\nsection\n\nvariables {D : Type u₂} [category.{v} D] (G : C ⥤ D)\n\n/--\nThe comparison morphism for the pullback of `f,g`.\nThis is an isomorphism iff `G` preserves the pullback of `f,g`; see\n`category_theory/limits/preserves/shapes/pullbacks.lean`\n-/\ndef pullback_comparison (f : X ⟶ Z) (g : Y ⟶ Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)] :\n  G.obj (pullback f g) ⟶ pullback (G.map f) (G.map g) :=\npullback.lift (G.map pullback.fst) (G.map pullback.snd)\n  (by simp only [←G.map_comp, pullback.condition])\n\n@[simp, reassoc]\nlemma pullback_comparison_comp_fst (f : X ⟶ Z) (g : Y ⟶ Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)] :\n  pullback_comparison G f g ≫ pullback.fst = G.map pullback.fst :=\npullback.lift_fst _ _ _\n\n@[simp, reassoc]\nlemma pullback_comparison_comp_snd (f : X ⟶ Z) (g : Y ⟶ Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)] :\n  pullback_comparison G f g ≫ pullback.snd = G.map pullback.snd :=\npullback.lift_snd _ _ _\n\n@[simp, reassoc]\nlemma map_lift_pullback_comparison (f : X ⟶ Z) (g : Y ⟶ Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)]\n  {W : C} {h : W ⟶ X} {k : W ⟶ Y} (w : h ≫ f = k ≫ g) :\n    G.map (pullback.lift _ _ w) ≫ pullback_comparison G f g =\n      pullback.lift (G.map h) (G.map k) (by simp only [←G.map_comp, w]) :=\nby { ext; simp [← G.map_comp] }\n\nend\n\nvariables (C)\n\n/--\n`has_pullbacks` represents a choice of pullback for every pair of morphisms\n\nSee https://stacks.math.columbia.edu/tag/001W.\n-/\nabbreviation has_pullbacks := has_limits_of_shape walking_cospan C\n\n/-- `has_pushouts` represents a choice of pushout for every pair of morphisms -/\nabbreviation has_pushouts := has_colimits_of_shape walking_span C\n\n/-- If `C` has all limits of diagrams `cospan f g`, then it has all pullbacks -/\nlemma has_pullbacks_of_has_limit_cospan\n  [Π {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}, has_limit (cospan f g)] :\n  has_pullbacks C :=\n{ has_limit := λ F, has_limit_of_iso (diagram_iso_cospan F).symm }\n\n/-- If `C` has all colimits of diagrams `span f g`, then it has all pushouts -/\nlemma has_pushouts_of_has_colimit_span\n  [Π {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z}, has_colimit (span f g)] :\n  has_pushouts C :=\n{ has_colimit := λ F, has_colimit_of_iso (diagram_iso_span F) }\n\nend category_theory.limits\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/shapes/pullbacks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6791786926816161, "lm_q1q2_score": 0.4704276679836333}}
{"text": "/-\nCopyright (c) 2015 Nathaniel Thomas. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.big_operators.basic\nimport Mathlib.algebra.group.hom\nimport Mathlib.algebra.ring.basic\nimport Mathlib.data.rat.cast\nimport Mathlib.group_theory.group_action.group\nimport Mathlib.tactic.nth_rewrite.default\nimport Mathlib.PostPort\n\nuniverses u v l w x z u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Modules over a ring\n\nIn this file we define\n\n* `semimodule R M` : an additive commutative monoid `M` is a `semimodule` over a\n  `semiring` `R` if for `r : R` and `x : M` their \"scalar multiplication `r • x : M` is defined, and\n  the operation `•` satisfies some natural associativity and distributivity axioms similar to those\n  on a ring.\n\n* `module R M` : same as `semimodule R M` but assumes that `R` is a `ring` and `M` is an\n  additive commutative group.\n\n* `vector_space k M` : same as `semimodule k M` and `module k M` but assumes that `k` is a `field`\n  and `M` is an additive commutative group.\n\n* `linear_map R M M₂`, `M →ₗ[R] M₂` : a linear map between two R-`semimodule`s.\n\n## Implementation notes\n\n* `vector_space` and `module` are abbreviations for `semimodule R M`.\n\n## Tags\n\nsemimodule, module, vector space\n-/\n\n/-- A semimodule is a generalization of vector spaces to a scalar semiring.\n  It consists of a scalar semiring `R` and an additive monoid of \"vectors\" `M`,\n  connected by a \"scalar multiplication\" operation `r • x : M`\n  (where `r : R` and `x : M`) with some natural associativity and\n  distributivity axioms similar to those on a ring. -/\nclass semimodule (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M] \nextends distrib_mul_action R M\nwhere\n  add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x\n  zero_smul : ∀ (x : M), 0 • x = 0\n\ntheorem add_smul {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (r : R) (s : R) (x : M) : (r + s) • x = r • x + s • x :=\n  semimodule.add_smul r s x\n\n@[simp] theorem zero_smul (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (x : M) : 0 • x = 0 :=\n  semimodule.zero_smul x\n\ntheorem two_smul (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (x : M) : bit0 1 • x = x + x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (bit0 1 • x = x + x)) (bit0.equations._eqn_1 1)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((1 + 1) • x = x + x)) (add_smul 1 1 x)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 • x + 1 • x = x + x)) (one_smul R x))) (Eq.refl (x + x))))\n\ntheorem two_smul' (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (x : M) : bit0 1 • x = bit0 x :=\n  two_smul R x\n\n/-- Pullback a `semimodule` structure along an injective additive monoid homomorphism. -/\nprotected def function.injective.semimodule (R : Type u) {M : Type w} {M₂ : Type x} [semiring R] [add_comm_monoid M] [semimodule R M] [add_comm_monoid M₂] [has_scalar R M₂] (f : M₂ →+ M) (hf : function.injective ⇑f) (smul : ∀ (c : R) (x : M₂), coe_fn f (c • x) = c • coe_fn f x) : semimodule R M₂ :=\n  semimodule.mk sorry sorry\n\n/-- Pushforward a `semimodule` structure along a surjective additive monoid homomorphism. -/\nprotected def function.surjective.semimodule (R : Type u) {M : Type w} {M₂ : Type x} [semiring R] [add_comm_monoid M] [semimodule R M] [add_comm_monoid M₂] [has_scalar R M₂] (f : M →+ M₂) (hf : function.surjective ⇑f) (smul : ∀ (c : R) (x : M), coe_fn f (c • x) = c • coe_fn f x) : semimodule R M₂ :=\n  semimodule.mk sorry sorry\n\n/-- `(•)` as an `add_monoid_hom`. -/\ndef smul_add_hom (R : Type u) (M : Type w) [semiring R] [add_comm_monoid M] [semimodule R M] : R →+ M →+ M :=\n  add_monoid_hom.mk (const_smul_hom M) sorry sorry\n\n@[simp] theorem smul_add_hom_apply {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (r : R) (x : M) : coe_fn (coe_fn (smul_add_hom R M) r) x = r • x :=\n  rfl\n\ntheorem semimodule.eq_zero_of_zero_eq_one {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (x : M) (zero_eq_one : 0 = 1) : x = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (x = 0)) (Eq.symm (one_smul R x))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (1 • x = 0)) (Eq.symm zero_eq_one)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 • x = 0)) (zero_smul R x))) (Eq.refl 0)))\n\ntheorem list.sum_smul {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] {l : List R} {x : M} : list.sum l • x = list.sum (list.map (fun (r : R) => r • x) l) :=\n  add_monoid_hom.map_list_sum (coe_fn (add_monoid_hom.flip (smul_add_hom R M)) x) l\n\ntheorem multiset.sum_smul {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] {l : multiset R} {x : M} : multiset.sum l • x = multiset.sum (multiset.map (fun (r : R) => r • x) l) :=\n  add_monoid_hom.map_multiset_sum (coe_fn (add_monoid_hom.flip (smul_add_hom R M)) x) l\n\ntheorem finset.sum_smul {R : Type u} {M : Type w} {ι : Type z} [semiring R] [add_comm_monoid M] [semimodule R M] {f : ι → R} {s : finset ι} {x : M} : (finset.sum s fun (i : ι) => f i) • x = finset.sum s fun (i : ι) => f i • x :=\n  add_monoid_hom.map_sum (coe_fn (add_monoid_hom.flip (smul_add_hom R M)) x) f s\n\n/-- An `add_comm_monoid` that is a `semimodule` over a `ring` carries a natural `add_comm_group`\nstructure. -/\ndef semimodule.add_comm_monoid_to_add_comm_group (R : Type u) {M : Type w} [ring R] [add_comm_monoid M] [semimodule R M] : add_comm_group M :=\n  add_comm_group.mk add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry (fun (a : M) => -1 • a)\n    (add_group.sub._default add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry fun (a : M) => -1 • a) sorry sorry\n\n/-- A structure containing most informations as in a semimodule, except the fields `zero_smul`\nand `smul_zero`. As these fields can be deduced from the other ones when `M` is an `add_comm_group`,\nthis provides a way to construct a semimodule structure by checking less properties, in\n`semimodule.of_core`. -/\nstructure semimodule.core (R : Type u) (M : Type w) [semiring R] [add_comm_group M] \nextends has_scalar R M\nwhere\n  smul_add : ∀ (r : R) (x y : M), r • (x + y) = r • x + r • y\n  add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x\n  mul_smul : ∀ (r s : R) (x : M), (r * s) • x = r • s • x\n  one_smul : ∀ (x : M), 1 • x = x\n\n/-- Define `semimodule` without proving `zero_smul` and `smul_zero` by using an auxiliary\nstructure `semimodule.core`, when the underlying space is an `add_comm_group`. -/\ndef semimodule.of_core {R : Type u} {M : Type w} [semiring R] [add_comm_group M] (H : semimodule.core R M) : semimodule R M :=\n  semimodule.mk (semimodule.core.add_smul H) sorry\n\n/--\nModules are defined as an `abbreviation` for semimodules,\nif the base semiring is a ring.\n(A previous definition made `module` a structure\ndefined to be `semimodule`.)\nThis has as advantage that modules are completely transparent\nfor type class inference, which means that all instances for semimodules\nare immediately picked up for modules as well.\nA cosmetic disadvantage is that one can not extend modules as such,\nin definitions such as `normed_space`.\nThe solution is to extend `semimodule` instead.\n-/\n/-- A module is the same as a semimodule, except the scalar semiring is actually\n  a ring.\n  This is the traditional generalization of spaces like `ℤ^n`, which have a natural\n  addition operation and a way to multiply them by elements of a ring, but no multiplication\n  operation between vectors. -/\ndef module (R : Type u) (M : Type v) [ring R] [add_comm_group M] :=\n  semimodule R M\n\n/--\nTo prove two semimodule structures on a fixed `add_comm_monoid` agree,\nit suffices to check the scalar multiplications agree.\n-/\n-- We'll later use this to show `semimodule ℕ M` and `module ℤ M` are subsingletons.\n\ntheorem semimodule_ext {R : Type u_1} [semiring R] {M : Type u_2} [add_comm_monoid M] (P : semimodule R M) (Q : semimodule R M) (w : ∀ (r : R) (m : M), r • m = r • m) : P = Q := sorry\n\n@[simp] theorem neg_smul {R : Type u} {M : Type w} [ring R] [add_comm_group M] [module R M] (r : R) (x : M) : -r • x = -(r • x) := sorry\n\ntheorem neg_one_smul (R : Type u) {M : Type w} [ring R] [add_comm_group M] [module R M] (x : M) : -1 • x = -x := sorry\n\ntheorem sub_smul {R : Type u} {M : Type w} [ring R] [add_comm_group M] [module R M] (r : R) (s : R) (y : M) : (r - s) • y = r • y - s • y := sorry\n\ntheorem smul_eq_zero {R : Type u_1} {E : Type u_2} [division_ring R] [add_comm_group E] [module R E] {c : R} {x : E} : c • x = 0 ↔ c = 0 ∨ x = 0 := sorry\n\n/-- A semimodule over a `subsingleton` semiring is a `subsingleton`. We cannot register this\nas an instance because Lean has no way to guess `R`. -/\ntheorem semimodule.subsingleton (R : Type u_1) (M : Type u_2) [semiring R] [subsingleton R] [add_comm_monoid M] [semimodule R M] : subsingleton M := sorry\n\nprotected instance semiring.to_semimodule {R : Type u} [semiring R] : semimodule R R :=\n  semimodule.mk sorry sorry\n\n@[simp] theorem smul_eq_mul {R : Type u} [semiring R] {a : R} {a' : R} : a • a' = a * a' :=\n  rfl\n\n/-- A ring homomorphism `f : R →+* M` defines a module structure by `r • x = f r * x`. -/\ndef ring_hom.to_semimodule {R : Type u} {S : Type v} [semiring R] [semiring S] (f : R →+* S) : semimodule R S :=\n  semimodule.mk sorry sorry\n\n/--\nVector spaces are defined as an `abbreviation` for semimodules,\nif the base ring is a field.\n(A previous definition made `vector_space` a structure\ndefined to be `module`.)\nThis has as advantage that vector spaces are completely transparent\nfor type class inference, which means that all instances for semimodules\nare immediately picked up for vector spaces as well.\nA cosmetic disadvantage is that one can not extend vector spaces as such,\nin definitions such as `normed_space`.\nThe solution is to extend `semimodule` instead.\n-/\n/-- A vector space is the same as a module, except the scalar ring is actually\n  a field. (This adds commutativity of the multiplication and existence of inverses.)\n  This is the traditional generalization of spaces like `ℝ^n`, which have a natural\n  addition operation and a way to multiply them by real numbers, but no multiplication\n  operation between vectors. -/\ndef vector_space (R : Type u) (M : Type v) [field R] [add_comm_group M] :=\n  semimodule R M\n\n/-- The natural ℕ-semimodule structure on any `add_comm_monoid`. -/\n-- We don't make this a global instance, as it results in too many instances,\n\n-- and confusing ambiguity in the notation `n • x` when `n : ℕ`.\n\ninstance add_comm_monoid.nat_semimodule {M : Type w} [add_comm_monoid M] : semimodule ℕ M :=\n  semimodule.mk sorry sorry\n\n/-- `nsmul` is defined as the `smul` action of `add_comm_monoid.nat_semimodule`. -/\ntheorem nsmul_def {M : Type w} [add_comm_monoid M] (n : ℕ) (x : M) : n •ℕ x = n • x :=\n  rfl\n\n/-- `nsmul` is equal to any other semimodule structure via a cast. -/\ntheorem nsmul_eq_smul_cast (R : Type u) {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] (n : ℕ) (b : M) : n •ℕ b = ↑n • b := sorry\n\n/-- `nsmul` is equal to any `ℕ`-semimodule structure. -/\ntheorem nsmul_eq_smul {M : Type w} [add_comm_monoid M] [semimodule ℕ M] (n : ℕ) (b : M) : n •ℕ b = n • b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n •ℕ b = n • b)) (nsmul_eq_smul_cast ℕ n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑n • b = n • b)) (nat.cast_id n))) (Eq.refl (n • b)))\n\n/-- All `ℕ`-semimodule structures are equal. -/\nprotected instance add_comm_monoid.nat_semimodule.subsingleton {M : Type w} [add_comm_monoid M] : subsingleton (semimodule ℕ M) :=\n  subsingleton.intro\n    fun (P Q : semimodule ℕ M) =>\n      semimodule_ext P Q\n        fun (n : ℕ) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n • m = n • m)) (Eq.symm (nsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n •ℕ m = n • m)) (Eq.symm (nsmul_eq_smul n m)))) (Eq.refl (n •ℕ m)))\n\n/-- Note this does not depend on the `nat_semimodule` definition above, to avoid issues when\ndiamonds occur in finding `semimodule ℕ M` instances. -/\nprotected instance add_comm_monoid.nat_is_scalar_tower {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] [semimodule ℕ R] [semimodule ℕ M] : is_scalar_tower ℕ R M := sorry\n\nprotected instance add_comm_monoid.nat_smul_comm_class {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] [semimodule ℕ M] : smul_comm_class ℕ R M := sorry\n\n-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop\n\nprotected instance add_comm_monoid.nat_smul_comm_class' {R : Type u} {M : Type w} [semiring R] [add_comm_monoid M] [semimodule R M] [semimodule ℕ M] : smul_comm_class R ℕ M :=\n  smul_comm_class.symm ℕ R M\n\n/-- The natural ℤ-module structure on any `add_comm_group`. -/\n-- We don't immediately make this a global instance, as it results in too many instances,\n\n-- and confusing ambiguity in the notation `n • x` when `n : ℤ`.\n\n-- We do turn it into a global instance, but only at the end of this file,\n\n-- and I remain dubious whether this is a good idea.\n\ninstance add_comm_group.int_module {M : Type w} [add_comm_group M] : module ℤ M :=\n  semimodule.mk sorry sorry\n\n/-- `gsmul` is defined as the `smul` action of `add_comm_group.int_module`. -/\ntheorem gsmul_def {M : Type w} [add_comm_group M] (n : ℤ) (x : M) : n •ℤ x = n • x :=\n  rfl\n\n/-- `gsmul` is equal to any other module structure via a cast. -/\ntheorem gsmul_eq_smul_cast (R : Type u) {M : Type w} [ring R] [add_comm_group M] [semimodule R M] (n : ℤ) (b : M) : n •ℤ b = ↑n • b := sorry\n\n/-- `gsmul` is equal to any `ℤ`-module structure. -/\ntheorem gsmul_eq_smul {M : Type w} [add_comm_group M] [semimodule ℤ M] (n : ℤ) (b : M) : n •ℤ b = n • b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n •ℤ b = n • b)) (gsmul_eq_smul_cast ℤ n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (↑n • b = n • b)) (int.cast_id n))) (Eq.refl (n • b)))\n\n/-- All `ℤ`-module structures are equal. -/\nprotected instance add_comm_group.int_module.subsingleton {M : Type w} [add_comm_group M] : subsingleton (semimodule ℤ M) :=\n  subsingleton.intro\n    fun (P Q : semimodule ℤ M) =>\n      semimodule_ext P Q\n        fun (n : ℤ) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n • m = n • m)) (Eq.symm (gsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n •ℤ m = n • m)) (Eq.symm (gsmul_eq_smul n m)))) (Eq.refl (n •ℤ m)))\n\nprotected instance add_comm_group.int_is_scalar_tower {R : Type u} {M : Type w} [ring R] [add_comm_group M] [semimodule R M] [semimodule ℤ R] [semimodule ℤ M] : is_scalar_tower ℤ R M := sorry\n\nprotected instance add_comm_group.int_smul_comm_class {S : Type v} {M : Type w} [semiring S] [add_comm_group M] [semimodule S M] [semimodule ℤ M] : smul_comm_class ℤ S M := sorry\n\n-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop\n\nprotected instance add_comm_group.int_smul_comm_class' {S : Type v} {M : Type w} [semiring S] [add_comm_group M] [semimodule S M] [semimodule ℤ M] : smul_comm_class S ℤ M :=\n  smul_comm_class.symm ℤ S M\n\nnamespace add_monoid_hom\n\n\n-- We prove this without using the `add_comm_group.int_module` instance, so the `•`s here\n\n-- come from whatever the local `module ℤ` structure actually is.\n\ntheorem map_int_module_smul {M : Type w} {M₂ : Type x} [add_comm_group M] [add_comm_group M₂] [module ℤ M] [module ℤ M₂] (f : M →+ M₂) (x : ℤ) (a : M) : coe_fn f (x • a) = x • coe_fn f a := sorry\n\ntheorem map_int_cast_smul {R : Type u} {M : Type w} {M₂ : Type x} [ring R] [add_comm_group M] [add_comm_group M₂] [module R M] [module R M₂] (f : M →+ M₂) (x : ℤ) (a : M) : coe_fn f (↑x • a) = ↑x • coe_fn f a := sorry\n\ntheorem map_nat_cast_smul {R : Type u} {M : Type w} {M₂ : Type x} [semiring R] [add_comm_monoid M] [add_comm_monoid M₂] [semimodule R M] [semimodule R M₂] (f : M →+ M₂) (x : ℕ) (a : M) : coe_fn f (↑x • a) = ↑x • coe_fn f a := sorry\n\ntheorem map_rat_cast_smul {R : Type u_1} [division_ring R] [char_zero R] {E : Type u_2} [add_comm_group E] [module R E] {F : Type u_3} [add_comm_group F] [module R F] (f : E →+ F) (c : ℚ) (x : E) : coe_fn f (↑c • x) = ↑c • coe_fn f x := sorry\n\ntheorem map_rat_module_smul {E : Type u_1} [add_comm_group E] [vector_space ℚ E] {F : Type u_2} [add_comm_group F] [module ℚ F] (f : E →+ F) (c : ℚ) (x : E) : coe_fn f (c • x) = c • coe_fn f x :=\n  rat.cast_id c ▸ map_rat_cast_smul f c x\n\n@[simp] theorem nat_smul_apply {M : Type w} {M₂ : Type x} [add_monoid M] [add_comm_monoid M₂] [semimodule ℕ (M →+ M₂)] [semimodule ℕ M₂] (n : ℕ) (f : M →+ M₂) (a : M) : coe_fn (n • f) a = n • coe_fn f a := sorry\n\n@[simp] theorem int_smul_apply {M : Type w} {M₂ : Type x} [add_monoid M] [add_comm_group M₂] [module ℤ (M →+ M₂)] [module ℤ M₂] (n : ℤ) (f : M →+ M₂) (a : M) : coe_fn (n • f) a = n • coe_fn f a := sorry\n\nend add_monoid_hom\n\n\n/-! Some tests for the vanishing of elements in modules over division rings. -/\n\ntheorem smul_nat_eq_zero (R : Type u) {M : Type w} [division_ring R] [add_comm_group M] [module R M] [semimodule ℕ M] [char_zero R] {v : M} {n : ℕ} : n • v = 0 ↔ n = 0 ∨ v = 0 := sorry\n\ntheorem eq_zero_of_smul_two_eq_zero (R : Type u) {M : Type w} [division_ring R] [add_comm_group M] [module R M] [semimodule ℕ M] [char_zero R] {v : M} (hv : bit0 1 • v = 0) : v = 0 := sorry\n\ntheorem eq_zero_of_eq_neg (R : Type u) {M : Type w} [division_ring R] [add_comm_group M] [module R M] [char_zero R] {v : M} (hv : v = -v) : v = 0 := sorry\n\ntheorem ne_neg_of_ne_zero (R : Type u) [division_ring R] [char_zero R] {v : R} (hv : v ≠ 0) : v ≠ -v :=\n  fun (h : v = -v) => (fun (this : semimodule ℕ R) => hv (eq_zero_of_eq_neg R h)) add_comm_monoid.nat_semimodule\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/module/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6757645879592641, "lm_q1q2_score": 0.47030399927603866}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nExtends the theory on functors, applicatives and monads.\n-/\n\nuniverses u v w\nvariables {α β γ : Type u}\n\nnotation a ` $< `:1 f:1 := f a\n\nsection functor\nvariables {f : Type u → Type v} [functor f] [is_lawful_functor f]\n\nrun_cmd mk_simp_attr `functor_norm\nrun_cmd tactic.add_doc_string `simp_attr.functor_norm \"Simp set for functor_norm\"\n\n@[functor_norm] theorem functor.map_map (m : α → β) (g : β → γ) (x : f α) :\n  g <$> (m <$> x) = (g ∘ m) <$> x :=\n(comp_map _ _ _).symm\n\n@[simp] theorem id_map' (x : f α) : (λa, a) <$> x = x := id_map _\n\nend functor\n\nsection applicative\nvariables {F : Type u → Type v} [applicative F]\n\ndef mzip_with\n  {α₁ α₂ φ : Type u}\n  (f : α₁ → α₂ → F φ) :\n  Π (ma₁ : list α₁) (ma₂: list α₂), F (list φ)\n| (x :: xs) (y :: ys) := (::) <$> f x y <*> mzip_with xs ys\n| _ _ := pure []\n\ndef mzip_with'  (f : α → β → F γ) : list α → list β → F punit\n| (x :: xs) (y :: ys) := f x y *> mzip_with' xs ys\n| [] _ := pure punit.star\n| _ [] := pure punit.star\n\nvariables [is_lawful_applicative F]\n\nattribute [functor_norm] seq_assoc pure_seq_eq_map\n\n@[simp] theorem pure_id'_seq (x : F α) : pure (λx, x) <*> x = x :=\npure_id_seq x\n\nattribute [functor_norm] seq_assoc pure_seq_eq_map\n\n@[functor_norm] theorem seq_map_assoc (x : F (α → β)) (f : γ → α) (y : F γ) :\n  (x <*> (f <$> y)) = (λ(m:α→β), m ∘ f) <$> x <*> y :=\nbegin\n  simp [(pure_seq_eq_map _ _).symm],\n  simp [seq_assoc, (comp_map _ _ _).symm, (∘)],\n  simp [pure_seq_eq_map]\nend\n\n@[functor_norm] theorem map_seq (f : β → γ) (x : F (α → β)) (y : F α) :\n  (f <$> (x <*> y)) = ((∘) f) <$> x <*> y :=\nby simp [(pure_seq_eq_map _ _).symm]; simp [seq_assoc]\n\nend applicative\n\n-- TODO: setup `functor_norm` for `monad` laws\nattribute [functor_norm] pure_bind bind_assoc bind_pure\n\nsection monad\nvariables {m : Type u → Type v} [monad m] [is_lawful_monad m]\n\nopen list\n\ndef list.mpartition {f : Type → Type} [monad f] {α : Type} (p : α → f bool) :\n  list α → f (list α × list α)\n| [] := pure ([],[])\n| (x :: xs) :=\nmcond (p x) (prod.map (cons x) id <$> list.mpartition xs)\n            (prod.map id (cons x) <$> list.mpartition xs)\n\nlemma map_bind (x : m α) {g : α → m β} {f : β → γ} : f <$> (x >>= g) = (x >>= λa, f <$> g a) :=\nby rw [← bind_pure_comp_eq_map,bind_assoc]; simp [bind_pure_comp_eq_map]\n\nlemma seq_bind_eq (x : m α) {g : β → m γ} {f : α → β} : (f <$> x) >>= g = (x >>= g ∘ f) :=\nshow bind (f <$> x) g = bind x (g ∘ f),\nby rw [← bind_pure_comp_eq_map, bind_assoc]; simp [pure_bind]\n\nlemma seq_eq_bind_map {x : m α} {f : m (α → β)} : f <*> x = (f >>= (<$> x)) :=\n(bind_map_eq_seq f x).symm\n\n/-- This is the Kleisli composition -/\n@[reducible] def fish {m} [monad m] {α β γ} (f : α → m β) (g : β → m γ) := λ x, f x >>= g\n\n-- >=> is already defined in the core library but it is unusable\n-- because of its precedence (it is defined with precedence 2) and\n-- because it is defined as a lambda instead of having a named\n-- function\ninfix ` >=> `:55 := fish\n\n@[functor_norm]\nlemma fish_pure {α β} (f : α → m β) : f >=> pure = f :=\nby simp only [(>=>)] with functor_norm\n\n@[functor_norm]\nlemma fish_pipe {α β} (f : α → m β) : pure >=> f = f :=\nby simp only [(>=>)] with functor_norm\n\n@[functor_norm]\nlemma fish_assoc {α β γ φ} (f : α → m β) (g : β → m γ) (h : γ → m φ) :\n  (f >=> g) >=> h = f >=> (g >=> h) :=\nby simp only [(>=>)] with functor_norm\n\nvariables {β' γ' : Type v}\nvariables {m' : Type v → Type w} [monad m']\n\ndef list.mmap_accumr (f : α → β' → m' (β' × γ')) : β' → list α → m' (β' × list γ')\n| a [] := pure (a,[])\n| a (x :: xs) :=\n  do (a',ys) ← list.mmap_accumr a xs,\n     (a'',y) ← f x a',\n     pure (a'',y::ys)\n\ndef list.mmap_accuml (f : β' → α → m' (β' × γ')) : β' → list α → m' (β' × list γ')\n| a [] := pure (a,[])\n| a (x :: xs) :=\n  do (a',y) ← f a x,\n     (a'',ys) ← list.mmap_accuml a' xs,\n     pure (a'',y :: ys)\n\nend monad\n\nsection\nvariables {m : Type u → Type u} [monad m] [is_lawful_monad m]\n\nlemma mjoin_map_map {α β : Type u} (f : α → β) (a : m (m α)) :\n  mjoin (functor.map f <$> a) = f <$> (mjoin a) :=\nby simp only [mjoin, (∘), id.def,\n  (bind_pure_comp_eq_map _ _).symm, bind_assoc, map_bind, pure_bind]\n\nlemma mjoin_map_mjoin {α : Type u} (a : m (m (m α))) :\n  mjoin (mjoin <$> a) = mjoin (mjoin a) :=\nby simp only [mjoin, (∘), id.def,\n  map_bind, (bind_pure_comp_eq_map _ _).symm, bind_assoc, pure_bind]\n\n@[simp] lemma mjoin_map_pure {α : Type u} (a : m α) :\n  mjoin (pure <$> a) = a :=\nby simp only [mjoin, (∘), id.def,\n  map_bind, (bind_pure_comp_eq_map _ _).symm, bind_assoc, pure_bind, bind_pure]\n\n@[simp] lemma mjoin_pure {α : Type u} (a : m α) : mjoin (pure a) = a :=\nis_lawful_monad.pure_bind a id\n\nend\n\nsection alternative\nvariables {F : Type → Type v} [alternative F]\n\ndef succeeds {α} (x : F α) : F bool := (x $> tt) <|> pure ff\n\ndef mtry {α} (x : F α) : F unit := (x $> ()) <|> pure ()\n\n@[simp] theorem guard_true {h : decidable true} :\n  @guard F _ true h = pure () := by simp [guard]\n\n@[simp] theorem guard_false {h : decidable false} :\n  @guard F _ false h = failure := by simp [guard]\n\nend alternative\n\nnamespace sum\n\nvariables {e : Type v}\n\nprotected def bind {α β} : e ⊕ α → (α → e ⊕ β) → e ⊕ β\n| (inl x) _ := inl x\n| (inr x) f := f x\n\ninstance : monad (sum.{v u} e) :=\n{ pure := @sum.inr e,\n  bind := @sum.bind e }\n\ninstance : is_lawful_functor (sum.{v u} e) :=\nby refine { .. }; intros; casesm _ ⊕ _; refl\n\ninstance : is_lawful_monad (sum.{v u} e) :=\n{ bind_assoc := by { intros, casesm _ ⊕ _; refl },\n  pure_bind  := by { intros, refl },\n  bind_pure_comp_eq_map := by { intros, casesm _ ⊕ _; refl },\n  bind_map_eq_seq := by { intros, cases f; refl } }\n\nend sum\n\nclass is_comm_applicative (m : Type* → Type*) [applicative m] extends is_lawful_applicative m :\n  Prop :=\n(commutative_prod : ∀{α β} (a : m α) (b : m β), prod.mk <$> a <*> b = (λb a, (a, b)) <$> b <*> a)\n\nopen functor\n\nlemma is_comm_applicative.commutative_map\n  {m : Type* → Type*} [applicative m] [is_comm_applicative m]\n  {α β γ} (a : m α) (b : m β) {f : α → β → γ} :\n  f <$> a <*> b = flip f <$> b <*> a :=\ncalc f <$> a <*> b = (λp:α×β, f p.1 p.2) <$> (prod.mk <$> a <*> b) :\n    by simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map]\n  ... = (λb a, f a b) <$> b <*> a :\n    by rw [is_comm_applicative.commutative_prod];\n        simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map]\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/control/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.47030399558062147}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Joey van Langen, Casper Putz\n-/\nimport tactic.apply_fun\nimport algebra.ring.equiv\nimport data.zmod.algebra\nimport linear_algebra.finite_dimensional\nimport ring_theory.integral_domain\nimport field_theory.separable\n\n/-!\n# Finite fields\n\nThis file contains basic results about finite fields.\nThroughout most of this file, `K` denotes a finite field\nand `q` is notation for the cardinality of `K`.\n\nSee `ring_theory.integral_domain` for the fact that the unit group of a finite field is a\ncyclic group, as well as the fact that every finite integral domain is a field\n(`fintype.field_of_domain`).\n\n## Main results\n\n1. `fintype.card_units`: The unit group of a finite field is has cardinality `q - 1`.\n2. `sum_pow_units`: The sum of `x^i`, where `x` ranges over the units of `K`, is\n   - `q-1` if `q-1 ∣ i`\n   - `0`   otherwise\n3. `finite_field.card`: The cardinality `q` is a power of the characteristic of `K`.\n   See `card'` for a variant.\n\n## Notation\n\nThroughout most of this file, `K` denotes a finite field\nand `q` is notation for the cardinality of `K`.\n\n## Implementation notes\n\nWhile `fintype Kˣ` can be inferred from `fintype K` in the presence of `decidable_eq K`,\nin this file we take the `fintype Kˣ` argument directly to reduce the chance of typeclass\ndiamonds, as `fintype` carries data.\n\n-/\n\nvariables {K : Type*} {R : Type*}\nlocal notation `q` := fintype.card K\n\nopen_locale big_operators polynomial\n\nnamespace finite_field\nopen finset function\n\nsection polynomial\n\nvariables [comm_ring R] [is_domain R]\n\nopen polynomial\n\n/-- The cardinality of a field is at most `n` times the cardinality of the image of a degree `n`\n  polynomial -/\nlemma card_image_polynomial_eval [decidable_eq R] [fintype R] {p : R[X]}\n  (hp : 0 < p.degree) : fintype.card R ≤ nat_degree p * (univ.image (λ x, eval x p)).card :=\nfinset.card_le_mul_card_image _ _\n  (λ a _, calc _ = (p - C a).roots.to_finset.card : congr_arg card\n    (by simp [finset.ext_iff, mem_roots_sub_C hp])\n    ... ≤ (p - C a).roots.card : multiset.to_finset_card_le _\n    ... ≤ _ : card_roots_sub_C' hp)\n\n/-- If `f` and `g` are quadratic polynomials, then the `f.eval a + g.eval b = 0` has a solution. -/\nlemma exists_root_sum_quadratic [fintype R] {f g : R[X]} (hf2 : degree f = 2)\n  (hg2 : degree g = 2) (hR : fintype.card R % 2 = 1) : ∃ a b, f.eval a + g.eval b = 0 :=\nby letI := classical.dec_eq R; exact\nsuffices ¬ disjoint (univ.image (λ x : R, eval x f)) (univ.image (λ x : R, eval x (-g))),\nbegin\n  simp only [disjoint_left, mem_image] at this,\n  push_neg at this,\n  rcases this with ⟨x, ⟨a, _, ha⟩, ⟨b, _, hb⟩⟩,\n  exact ⟨a, b, by rw [ha, ← hb, eval_neg, neg_add_self]⟩\nend,\nassume hd : disjoint _ _,\nlt_irrefl (2 * ((univ.image (λ x : R, eval x f)) ∪ (univ.image (λ x : R, eval x (-g)))).card) $\ncalc 2 * ((univ.image (λ x : R, eval x f)) ∪ (univ.image (λ x : R, eval x (-g)))).card\n    ≤ 2 * fintype.card R : nat.mul_le_mul_left _ (finset.card_le_univ _)\n... = fintype.card R + fintype.card R : two_mul _\n... < nat_degree f * (univ.image (λ x : R, eval x f)).card +\n      nat_degree (-g) * (univ.image (λ x : R, eval x (-g))).card :\n    add_lt_add_of_lt_of_le\n      (lt_of_le_of_ne\n        (card_image_polynomial_eval (by rw hf2; exact dec_trivial))\n        (mt (congr_arg (%2)) (by simp [nat_degree_eq_of_degree_eq_some hf2, hR])))\n      (card_image_polynomial_eval (by rw [degree_neg, hg2]; exact dec_trivial))\n... = 2 * (univ.image (λ x : R, eval x f) ∪ univ.image (λ x : R, eval x (-g))).card :\n  by rw [card_disjoint_union hd]; simp [nat_degree_eq_of_degree_eq_some hf2,\n    nat_degree_eq_of_degree_eq_some hg2, bit0, mul_add]\n\nend polynomial\n\nlemma prod_univ_units_id_eq_neg_one [comm_ring K] [is_domain K] [fintype Kˣ] :\n  (∏ x : Kˣ, x) = (-1 : Kˣ) :=\nbegin\n  classical,\n  have : (∏ x in (@univ Kˣ _).erase (-1), x) = 1,\n  from prod_involution (λ x _, x⁻¹) (by simp)\n    (λ a, by simp [units.inv_eq_self_iff] {contextual := tt})\n    (λ a, by simp [@inv_eq_iff_inv_eq _ _ a, eq_comm])\n    (by simp),\n  rw [← insert_erase (mem_univ (-1 : Kˣ)), prod_insert (not_mem_erase _ _),\n      this, mul_one]\nend\n\nsection\nvariables [group_with_zero K] [fintype K]\n\nlemma pow_card_sub_one_eq_one (a : K) (ha : a ≠ 0) : a ^ (q - 1) = 1 :=\ncalc a ^ (fintype.card K - 1) = (units.mk0 a ha ^ (fintype.card K - 1) : Kˣ) :\n    by rw [units.coe_pow, units.coe_mk0]\n  ... = 1 : by { classical, rw [← fintype.card_units, pow_card_eq_one], refl }\n\nlemma pow_card (a : K) : a ^ q = a :=\nbegin\n  have hp : 0 < fintype.card K := lt_trans zero_lt_one fintype.one_lt_card,\n  by_cases h : a = 0, { rw h, apply zero_pow hp },\n  rw [← nat.succ_pred_eq_of_pos hp, pow_succ, nat.pred_eq_sub_one,\n    pow_card_sub_one_eq_one a h, mul_one],\nend\n\nlemma pow_card_pow (n : ℕ) (a : K) : a ^ q ^ n = a :=\nbegin\n  induction n with n ih,\n  { simp, },\n  { simp [pow_succ, pow_mul, ih, pow_card], },\nend\n\nend\n\nvariables (K) [field K] [fintype K]\n\ntheorem card (p : ℕ) [char_p K p] : ∃ (n : ℕ+), nat.prime p ∧ q = p^(n : ℕ) :=\nbegin\n  haveI hp : fact p.prime := ⟨char_p.char_is_prime K p⟩,\n  letI : module (zmod p) K := { .. (zmod.cast_hom dvd_rfl K : zmod p →+* _).to_module },\n  obtain ⟨n, h⟩ := vector_space.card_fintype (zmod p) K,\n  rw zmod.card at h,\n  refine ⟨⟨n, _⟩, hp.1, h⟩,\n  apply or.resolve_left (nat.eq_zero_or_pos n),\n  rintro rfl,\n  rw pow_zero at h,\n  have : (0 : K) = 1, { apply fintype.card_le_one_iff.mp (le_of_eq h) },\n  exact absurd this zero_ne_one,\nend\n\n-- this statement doesn't use `q` because we want `K` to be an explicit parameter\ntheorem card' : ∃ (p : ℕ) (n : ℕ+), nat.prime p ∧ fintype.card K = p^(n : ℕ) :=\nlet ⟨p, hc⟩ := char_p.exists K in ⟨p, @finite_field.card K _ _ p hc⟩\n\n@[simp] lemma cast_card_eq_zero : (q : K) = 0 :=\nbegin\n  rcases char_p.exists K with ⟨p, _char_p⟩, resetI,\n  rcases card K p with ⟨n, hp, hn⟩,\n  simp only [char_p.cast_eq_zero_iff K p, hn],\n  conv { congr, rw [← pow_one p] },\n  exact pow_dvd_pow _ n.2,\nend\n\nlemma forall_pow_eq_one_iff (i : ℕ) :\n  (∀ x : Kˣ, x ^ i = 1) ↔ q - 1 ∣ i :=\nbegin\n  classical,\n  obtain ⟨x, hx⟩ := is_cyclic.exists_generator Kˣ,\n  rw [←fintype.card_units, ←order_of_eq_card_of_forall_mem_zpowers hx, order_of_dvd_iff_pow_eq_one],\n  split,\n  { intro h, apply h },\n  { intros h y,\n    simp_rw ← mem_powers_iff_mem_zpowers at hx,\n    rcases hx y with ⟨j, rfl⟩,\n    rw [← pow_mul, mul_comm, pow_mul, h, one_pow], }\nend\n\n/-- The sum of `x ^ i` as `x` ranges over the units of a finite field of cardinality `q`\nis equal to `0` unless `(q - 1) ∣ i`, in which case the sum is `q - 1`. -/\nlemma sum_pow_units [fintype Kˣ] (i : ℕ) :\n  ∑ x : Kˣ, (x ^ i : K) = if (q - 1) ∣ i then -1 else 0 :=\nbegin\n  let φ : Kˣ →* K :=\n  { to_fun   := λ x, x ^ i,\n    map_one' := by rw [units.coe_one, one_pow],\n    map_mul' := by { intros, rw [units.coe_mul, mul_pow] } },\n  haveI : decidable (φ = 1), { classical, apply_instance },\n  calc ∑ x : Kˣ, φ x = if φ = 1 then fintype.card Kˣ else 0 : sum_hom_units φ\n                      ... = if (q - 1) ∣ i then -1 else 0 : _,\n  suffices : (q - 1) ∣ i ↔ φ = 1,\n  { simp only [this],\n    split_ifs with h h, swap, refl,\n    rw [fintype.card_units, nat.cast_sub, cast_card_eq_zero, nat.cast_one, zero_sub],\n    show 1 ≤ q, from fintype.card_pos_iff.mpr ⟨0⟩ },\n  rw [← forall_pow_eq_one_iff, monoid_hom.ext_iff],\n  apply forall_congr, intro x,\n  rw [units.ext_iff, units.coe_pow, units.coe_one, monoid_hom.one_apply],\n  refl,\nend\n\n/-- The sum of `x ^ i` as `x` ranges over a finite field of cardinality `q`\nis equal to `0` if `i < q - 1`. -/\nlemma sum_pow_lt_card_sub_one (i : ℕ) (h : i < q - 1) :\n  ∑ x : K, x ^ i = 0 :=\nbegin\n  by_cases hi : i = 0,\n  { simp only [hi, nsmul_one, sum_const, pow_zero, card_univ, cast_card_eq_zero], },\n  classical,\n  have hiq : ¬ (q - 1) ∣ i, { contrapose! h,  exact nat.le_of_dvd (nat.pos_of_ne_zero hi) h },\n  let φ : Kˣ ↪ K := ⟨coe, units.ext⟩,\n  have : univ.map φ = univ \\ {0},\n  { ext x,\n    simp only [true_and, embedding.coe_fn_mk, mem_sdiff, units.exists_iff_ne_zero,\n               mem_univ, mem_map, exists_prop_of_true, mem_singleton] },\n  calc ∑ x : K, x ^ i = ∑ x in univ \\ {(0 : K)}, x ^ i :\n    by rw [← sum_sdiff ({0} : finset K).subset_univ, sum_singleton,\n           zero_pow (nat.pos_of_ne_zero hi), add_zero]\n    ... = ∑ x : Kˣ, x ^ i : by { rw [← this, univ.sum_map φ], refl }\n    ... = 0 : by { rw [sum_pow_units K i, if_neg], exact hiq, }\nend\n\nsection is_splitting_field\nopen polynomial\n\nsection\n\nvariables (K' : Type*) [field K'] {p n : ℕ}\n\nlemma X_pow_card_sub_X_nat_degree_eq (hp : 1 < p) :\n  (X ^ p - X : K'[X]).nat_degree = p :=\nbegin\n  have h1 : (X : K'[X]).degree < (X ^ p : K'[X]).degree,\n  { rw [degree_X_pow, degree_X],\n    exact_mod_cast hp },\n  rw [nat_degree_eq_of_degree_eq (degree_sub_eq_left_of_degree_lt h1), nat_degree_X_pow],\nend\n\nlemma X_pow_card_pow_sub_X_nat_degree_eq (hn : n ≠ 0) (hp : 1 < p) :\n  (X ^ p ^ n - X : K'[X]).nat_degree = p ^ n :=\nX_pow_card_sub_X_nat_degree_eq K' $ nat.one_lt_pow _ _ (nat.pos_of_ne_zero hn) hp\n\nlemma X_pow_card_sub_X_ne_zero (hp : 1 < p) : (X ^ p - X : K'[X]) ≠ 0 :=\nne_zero_of_nat_degree_gt $\ncalc 1 < _ : hp\n... = _ : (X_pow_card_sub_X_nat_degree_eq K' hp).symm\n\nlemma X_pow_card_pow_sub_X_ne_zero (hn : n ≠ 0) (hp : 1 < p) :\n  (X ^ p ^ n - X : K'[X]) ≠ 0 :=\nX_pow_card_sub_X_ne_zero K' $ nat.one_lt_pow _ _ (nat.pos_of_ne_zero hn) hp\n\nend\n\nvariables (p : ℕ) [fact p.prime] [algebra (zmod p) K]\nlemma roots_X_pow_card_sub_X : roots (X^q - X : K[X]) = finset.univ.val :=\nbegin\n  classical,\n  have aux : (X^q - X : K[X]) ≠ 0 := X_pow_card_sub_X_ne_zero K fintype.one_lt_card,\n  have : (roots (X^q - X : K[X])).to_finset = finset.univ,\n  { rw eq_univ_iff_forall,\n    intro x,\n    rw [multiset.mem_to_finset, mem_roots aux, is_root.def, eval_sub, eval_pow, eval_X, sub_eq_zero,\n      pow_card] },\n  rw [←this, multiset.to_finset_val, eq_comm, multiset.dedup_eq_self],\n  apply nodup_roots,\n  rw separable_def,\n  convert is_coprime_one_right.neg_right using 1,\n  { rw [derivative_sub, derivative_X, derivative_X_pow, ←C_eq_nat_cast,\n    C_eq_zero.mpr (char_p.cast_card_eq_zero K), zero_mul, zero_sub], },\n  end\n\ninstance (F : Type*) [field F] [algebra F K] : is_splitting_field F K (X^q - X) :=\n{ splits :=\n  begin\n    have h : (X^q - X : K[X]).nat_degree = q :=\n      X_pow_card_sub_X_nat_degree_eq K fintype.one_lt_card,\n    rw [←splits_id_iff_splits, splits_iff_card_roots, polynomial.map_sub, polynomial.map_pow,\n      map_X, h, roots_X_pow_card_sub_X K, ←finset.card_def, finset.card_univ],\n  end,\n  adjoin_roots :=\n  begin\n    classical,\n    transitivity algebra.adjoin F ((roots (X^q - X : K[X])).to_finset : set K),\n    { simp only [polynomial.map_pow, map_X, polynomial.map_sub], },\n    { rw [roots_X_pow_card_sub_X, val_to_finset, coe_univ, algebra.adjoin_univ], }\n  end }\n\nend is_splitting_field\n\nvariables {K}\n\ntheorem frobenius_pow {p : ℕ} [fact p.prime] [char_p K p] {n : ℕ} (hcard : q = p^n) :\n  (frobenius K p) ^ n = 1 :=\nbegin\n  ext, conv_rhs { rw [ring_hom.one_def, ring_hom.id_apply, ← pow_card x, hcard], }, clear hcard,\n  induction n, {simp},\n  rw [pow_succ, pow_succ', pow_mul, ring_hom.mul_def, ring_hom.comp_apply, frobenius_def, n_ih]\nend\n\nopen polynomial\n\nlemma expand_card (f : K[X]) :\n  expand K q f = f ^ q :=\nbegin\n  cases char_p.exists K with p hp,\n  letI := hp,\n  rcases finite_field.card K p with ⟨⟨n, npos⟩, ⟨hp, hn⟩⟩,\n  haveI : fact p.prime := ⟨hp⟩,\n  dsimp at hn,\n  rw [hn, ← map_expand_pow_char, frobenius_pow hn, ring_hom.one_def, map_id]\nend\n\nend finite_field\n\nnamespace zmod\n\nopen finite_field polynomial\n\nlemma sq_add_sq (p : ℕ) [hp : fact p.prime] (x : zmod p) :\n  ∃ a b : zmod p, a^2 + b^2 = x :=\nbegin\n  cases hp.1.eq_two_or_odd with hp2 hp_odd,\n  { substI p, change fin 2 at x, fin_cases x, { use 0, simp }, { use [0, 1], simp } },\n  let f : (zmod p)[X] := X^2,\n  let g : (zmod p)[X] := X^2 - C x,\n  obtain ⟨a, b, hab⟩ : ∃ a b, f.eval a + g.eval b = 0 :=\n    @exists_root_sum_quadratic _ _ _ _ f g\n      (degree_X_pow 2) (degree_X_pow_sub_C dec_trivial _) (by rw [zmod.card, hp_odd]),\n  refine ⟨a, b, _⟩,\n  rw ← sub_eq_zero,\n  simpa only [eval_C, eval_X, eval_pow, eval_sub, ← add_sub_assoc] using hab,\nend\n\nend zmod\n\nnamespace char_p\n\nlemma sq_add_sq (R : Type*) [comm_ring R] [is_domain R]\n  (p : ℕ) [fact (0 < p)] [char_p R p] (x : ℤ) :\n  ∃ a b : ℕ, (a^2 + b^2 : R) = x :=\nbegin\n  haveI := char_is_prime_of_pos R p,\n  obtain ⟨a, b, hab⟩ := zmod.sq_add_sq p x,\n  refine ⟨a.val, b.val, _⟩,\n  simpa using congr_arg (zmod.cast_hom dvd_rfl R) hab\nend\n\nend char_p\n\nopen_locale nat\nopen zmod\n\n/-- The **Fermat-Euler totient theorem**. `nat.modeq.pow_totient` is an alternative statement\n  of the same theorem. -/\n@[simp] lemma zmod.pow_totient {n : ℕ} [fact (0 < n)] (x : (zmod n)ˣ) : x ^ φ n = 1 :=\nby rw [← card_units_eq_totient, pow_card_eq_one]\n\n/-- The **Fermat-Euler totient theorem**. `zmod.pow_totient` is an alternative statement\n  of the same theorem. -/\nlemma nat.modeq.pow_totient {x n : ℕ} (h : nat.coprime x n) : x ^ φ n ≡ 1 [MOD n] :=\nbegin\n  cases n, {simp},\n  rw ← zmod.eq_iff_modeq_nat,\n  let x' : units (zmod (n+1)) := zmod.unit_of_coprime _ h,\n  have := zmod.pow_totient x',\n  apply_fun (coe : units (zmod (n+1)) → zmod (n+1)) at this,\n  simpa only [-zmod.pow_totient, nat.succ_eq_add_one, nat.cast_pow, units.coe_one,\n    nat.cast_one, coe_unit_of_coprime, units.coe_pow],\nend\n\nsection\n\nvariables {V : Type*} [fintype K] [division_ring K] [add_comm_group V] [module K V]\n\n-- should this go in a namespace?\n-- finite_dimensional would be natural,\n-- but we don't assume it...\nlemma card_eq_pow_finrank [fintype V] :\n  fintype.card V = q ^ (finite_dimensional.finrank K V) :=\nbegin\n  let b := is_noetherian.finset_basis K V,\n  rw [module.card_fintype b, ← finite_dimensional.finrank_eq_card_basis b],\nend\n\nend\n\nopen finite_field\nnamespace zmod\n\n/-- A variation on Fermat's little theorem. See `zmod.pow_card_sub_one_eq_one` -/\n@[simp] lemma pow_card {p : ℕ} [fact p.prime] (x : zmod p) : x ^ p = x :=\nby { have h := finite_field.pow_card x, rwa zmod.card p at h }\n\n@[simp] lemma pow_card_pow {n p : ℕ} [fact p.prime] (x : zmod p) : x ^ p ^ n = x :=\nbegin\n  induction n with n ih,\n  { simp, },\n  { simp [pow_succ, pow_mul, ih, pow_card], },\nend\n\n@[simp] lemma frobenius_zmod (p : ℕ) [fact p.prime] :\n  frobenius (zmod p) p = ring_hom.id _ :=\nby { ext a, rw [frobenius_def, zmod.pow_card, ring_hom.id_apply] }\n\n@[simp] lemma card_units (p : ℕ) [fact p.prime] : fintype.card ((zmod p)ˣ) = p - 1 :=\nby rw [fintype.card_units, card]\n\n/-- **Fermat's Little Theorem**: for every unit `a` of `zmod p`, we have `a ^ (p - 1) = 1`. -/\ntheorem units_pow_card_sub_one_eq_one (p : ℕ) [fact p.prime] (a : (zmod p)ˣ) :\n  a ^ (p - 1) = 1 :=\nby rw [← card_units p, pow_card_eq_one]\n\n/-- **Fermat's Little Theorem**: for all nonzero `a : zmod p`, we have `a ^ (p - 1) = 1`. -/\ntheorem pow_card_sub_one_eq_one {p : ℕ} [fact p.prime] {a : zmod p} (ha : a ≠ 0) :\n  a ^ (p - 1) = 1 :=\nby { have h := pow_card_sub_one_eq_one a ha, rwa zmod.card p at h }\n\nopen polynomial\n\nlemma expand_card {p : ℕ} [fact p.prime] (f : polynomial (zmod p)) :\n  expand (zmod p) p f = f ^ p :=\nby { have h := finite_field.expand_card f, rwa zmod.card p at h }\n\nend zmod\n\n/-- **Fermat's Little Theorem**: for all `a : ℤ` coprime to `p`, we have\n`a ^ (p - 1) ≡ 1 [ZMOD p]`. -/\nlemma int.modeq.pow_card_sub_one_eq_one {p : ℕ} (hp : nat.prime p) {n : ℤ} (hpn : is_coprime n p) :\n  n ^ (p - 1) ≡ 1 [ZMOD p] :=\nbegin\n  haveI : fact p.prime := ⟨hp⟩,\n  have : ¬ (n : zmod p) = 0,\n  { rw [char_p.int_cast_eq_zero_iff _ p, ← (nat.prime_iff_prime_int.mp hp).coprime_iff_not_dvd],\n    { exact hpn.symm },\n    exact zmod.char_p p },\n  simpa [← zmod.int_coe_eq_int_coe_iff] using zmod.pow_card_sub_one_eq_one this\nend\n\nsection\n\nnamespace finite_field\n\nvariables {F : Type*} [field F] [fintype F]\n\n/-- In a finite field of characteristic `2`, all elements are squares. -/\nlemma is_square_of_char_two (hF : ring_char F = 2) (a : F) : is_square a :=\nbegin\n  haveI hF' : char_p F 2 := ring_char.of_eq hF,\n  exact is_square_of_char_two' a,\nend\n\n/-- The finite field `F` has even cardinality iff it has characteristic `2`. -/\nlemma even_card_iff_char_two : ring_char F = 2 ↔ fintype.card F % 2 = 0 :=\nbegin\n  rcases finite_field.card F (ring_char F) with ⟨n, hp, h⟩,\n  rw [h, nat.pow_mod],\n  split,\n  { intro hF,\n    rw hF,\n    simp only [nat.bit0_mod_two, zero_pow', ne.def, pnat.ne_zero, not_false_iff, nat.zero_mod], },\n  { rw [← nat.even_iff, nat.even_pow],\n    rintros ⟨hev, hnz⟩,\n    rw [nat.even_iff, nat.mod_mod] at hev,\n    exact (nat.prime.eq_two_or_odd hp).resolve_right (ne_of_eq_of_ne hev zero_ne_one), },\nend\n\nlemma even_card_of_char_two (hF : ring_char F = 2) : fintype.card F % 2 = 0 :=\neven_card_iff_char_two.mp hF\n\nlemma odd_card_of_char_ne_two (hF : ring_char F ≠ 2) : fintype.card F % 2 = 1 :=\nnat.mod_two_ne_zero.mp (mt even_card_iff_char_two.mpr hF)\n\n/-- If `F` has odd characteristic, then for nonzero `a : F`, we have that `a ^ (#F / 2) = ±1`. -/\nlemma pow_dichotomy (hF : ring_char F ≠ 2) {a : F} (ha : a ≠ 0) :\n  a ^ (fintype.card F / 2) = 1 ∨ a ^ (fintype.card F / 2) = -1 :=\nbegin\n  have h₁ := finite_field.pow_card_sub_one_eq_one a ha,\n  rw [← nat.two_mul_odd_div_two (finite_field.odd_card_of_char_ne_two hF),\n      mul_comm, pow_mul, pow_two] at h₁,\n  exact mul_self_eq_one_iff.mp h₁,\nend\n\n/-- A unit `a` of a finite field `F` of odd characteristic is a square\nif and only if `a ^ (#F / 2) = 1`. -/\nlemma unit_is_square_iff (hF : ring_char F ≠ 2) (a : Fˣ) :\n  is_square a ↔ a ^ (fintype.card F / 2) = 1 :=\nbegin\n  classical,\n  obtain ⟨g, hg⟩ := is_cyclic.exists_generator Fˣ,\n  obtain ⟨n, hn⟩ : a ∈ submonoid.powers g, { rw mem_powers_iff_mem_zpowers, apply hg },\n  have hodd := nat.two_mul_odd_div_two (finite_field.odd_card_of_char_ne_two hF),\n  split,\n  { rintro ⟨y, rfl⟩,\n    rw [← pow_two, ← pow_mul, hodd],\n    apply_fun (@coe Fˣ F _) using units.ext,\n    { push_cast,\n      exact finite_field.pow_card_sub_one_eq_one (y : F) (units.ne_zero y), }, },\n  { subst a, assume h,\n    have key : 2 * (fintype.card F / 2) ∣ n * (fintype.card F / 2),\n    { rw [← pow_mul] at h,\n      rw [hodd, ← fintype.card_units, ← order_of_eq_card_of_forall_mem_zpowers hg],\n      apply order_of_dvd_of_pow_eq_one h },\n    have : 0 < fintype.card F / 2 := nat.div_pos fintype.one_lt_card (by norm_num),\n    obtain ⟨m, rfl⟩ := nat.dvd_of_mul_dvd_mul_right this key,\n    refine ⟨g ^ m, _⟩,\n    rw [mul_comm, pow_mul, pow_two], },\nend\n\n/-- A non-zero `a : F` is a square if and only if `a ^ (#F / 2) = 1`. -/\nlemma is_square_iff (hF : ring_char F ≠ 2) {a : F} (ha : a ≠ 0) :\n  is_square a ↔ a ^ (fintype.card F / 2) = 1 :=\nbegin\n  apply (iff_congr _ (by simp [units.ext_iff])).mp\n        (finite_field.unit_is_square_iff hF (units.mk0 a ha)),\n  simp only [is_square, units.ext_iff, units.coe_mk0, units.coe_mul],\n  split,\n  { rintro ⟨y, hy⟩, exact ⟨y, hy⟩ },\n  { rintro ⟨y, rfl⟩,\n    have hy : y ≠ 0, { rintro rfl, simpa [zero_pow] using ha, },\n    refine ⟨units.mk0 y hy, _⟩, simp, }\nend\n\n/-- In a finite field of odd characteristic, not every element is a square. -/\nlemma exists_nonsquare (hF : ring_char F ≠ 2) : ∃ (a : F), ¬ is_square a :=\nbegin\n  -- idea: the squaring map on `F` is not injetive, hence not surjective\n  let sq : F → F := λ x, x ^ 2,\n  have h : ¬ function.injective sq,\n  { simp only [function.injective, not_forall, exists_prop],\n    use [-1, 1],\n    split,\n    { simp only [sq, one_pow, neg_one_sq], },\n    { exact ring.neg_one_ne_one_of_char_ne_two hF, }, },\n  have h₁ := mt (fintype.injective_iff_surjective.mpr) h, -- sq not surjective\n  push_neg at h₁,\n  cases h₁ with a h₁,\n  use a,\n  simp only [is_square, sq, not_exists, ne.def] at h₁ ⊢,\n  intros b hb,\n  rw ← pow_two at hb,\n  exact h₁ b hb.symm,\nend\n\nend finite_field\n\nend\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/field_theory/finite/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6757645944891558, "lm_q1q2_score": 0.47030399529758316}}
{"text": "/-\nA two's complement representation of signed integers, implemented as a struct pulling back\non the prelude's signed integer types. For example, the relationship between\nunsigned (UInt8) and signed (Int8) is:\n\nunsigned (UInt8) : 0, 1 ............ 127,  128 ............ 254, 255\nsigned   (Int8)  : 0, 1 ............ 127, -128 ............  -2, -1\n-/\nstructure Int8 where\n  val : UInt8\nderiving DecidableEq\n\n\ndef Int8.ofNat (n : Nat) : Int8 := ⟨OfNat.ofNat n⟩\n\ninstance (n : Nat) : OfNat Int8 n := ⟨Int8.ofNat n⟩\n\ndef Int8.neg : Int8 -> Int8\n| ⟨⟨a, isLt⟩⟩ => ⟨(UInt8.size - a) % UInt8.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)⟩\n\ninstance : Neg Int8 := ⟨Int8.neg⟩\n\ndef Int8.max : Int8 := 127\ndef Int8.min : Int8 := -128\n\ntheorem Int8.eq_of_val_eq : ∀ {a b : Int8}, a.val = b.val -> a = b\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int8.ne_of_val_ne : ∀ {a b : Int8}, a.val ≠ b.val -> a ≠ b\n| _, _, h => fun a_eq_b => Int8.noConfusion a_eq_b h\n\ntheorem Int8.val_eq_of_eq : ∀ {a b : Int8}, a = b -> a.val = b.val\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int8.val_ne_of_ne : ∀ {a b : Int8}, a ≠ b -> a.val ≠ b.val\n| _, _, h => fun h' => absurd (Int8.eq_of_val_eq h') h\n\ndef Int8.isPositive (a : Int8) : Bool := a.val.val < (UInt8.size / 2)\n\ndef Int8.isNegative (a : Int8) : Bool := ¬a.isPositive\n\ndef Int8.toInt (a : Int8) : Int :=\n  if a.isPositive\n  then Int.ofNat a.val.toNat\n  else Int.subNatNat a.val.toNat UInt8.size\n\ndef Int8.toString (a : Int8) : String := s!\"{a.toInt}\"\n\ninstance : ToString Int8 := ⟨Int8.toString⟩\n\n\ndef Int8.ofInt : Int -> Int8\n| Int.ofNat n => Int8.ofNat n\n| Int.negSucc n => -(Int8.ofNat n.succ)\n\ndef Int8.modn (a : Int8) (n : Nat) : Int8 := Int8.ofInt <| a.toInt % (Int.ofNat n)\n\ndef Int8.shiftLeft (a b : Int8) : Int8 := ⟨a.val.shiftLeft b.val⟩\n\ndef Int8.shiftRight (a b : Int8) : Int8 := ⟨a.val.shiftRight b.val⟩\n\ndef Int8.land (a b : Int8) : Int8 := ⟨a.val.land b.val⟩\n\ndef Int8.lor (a b : Int8) : Int8 := ⟨a.val.lor b.val⟩\n\ndef Int8.xor (a b : Int8) : Int8 := ⟨a.val.xor b.val⟩\n\ninstance : HMod Int8 Nat Int8 := ⟨Int8.modn⟩\ninstance : AndOp Int8     := ⟨Int8.land⟩\ninstance : OrOp Int8      := ⟨Int8.lor⟩\ninstance : Xor Int8       := ⟨Int8.xor⟩\ninstance : ShiftLeft Int8  := ⟨Int8.shiftLeft⟩\ninstance : ShiftRight Int8 := ⟨Int8.shiftRight⟩\n\ndef Int8.add : Int8 -> Int8 -> Int8\n| ⟨a⟩, ⟨b⟩ => ⟨a + b⟩\n\ninstance : Add Int8 := ⟨Int8.add⟩\n\ndef Int8.sub (a b : Int8) : Int8 := a + -b\n\ndef Int8.mul : Int8 -> Int8 -> Int8\n| ⟨a⟩, ⟨b⟩ => ⟨a * b⟩\n\ndef Int8.mod (a m : Int8) : Int8 := Int8.ofInt (a.toInt % m.toInt)\n\ndef Int8.div (a b : Int8) : Int8 := Int8.ofInt (a.toInt / b.toInt)\n\ninstance : Sub Int8 := ⟨Int8.sub⟩\n\ninstance : Mul Int8 := ⟨Int8.mul⟩\n\ninstance : Mod Int8 := ⟨Int8.mod⟩\n\ninstance : Div Int8 := ⟨Int8.div⟩\n\ndef Int8.le (a b : Int8) : Prop := a.toInt <= b.toInt\ndef Int8.lt (a b : Int8) : Prop := a.toInt < b.toInt\n\ninstance : LE Int8 := ⟨Int8.le⟩\n\ninstance : LT Int8 := ⟨Int8.lt⟩\n\ninstance (a b : Int8) : Decidable (a <= b) :=\n  dite (a.toInt <= b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\ninstance (a b : Int8) : Decidable (a < b) :=\n  dite (a.toInt < b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\nstructure Int16 where\n  val : UInt16\nderiving DecidableEq\n\ndef Int16.ofNat (n : Nat) : Int16 := ⟨OfNat.ofNat n⟩\n\ninstance (n : Nat) : OfNat Int16 n := ⟨Int16.ofNat n⟩\n\ndef Int16.neg : Int16 -> Int16\n| ⟨⟨a, isLt⟩⟩ => ⟨(UInt16.size - a) % UInt16.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)⟩\n\ninstance : Neg Int16 := ⟨Int16.neg⟩\n\ndef Int16.max : Int16 := -32767\ndef Int16.min : Int16 := -32768\n\ntheorem Int16.eq_of_val_eq : ∀ {a b : Int16}, a.val = b.val -> a = b\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int16.ne_of_val_ne : ∀ {a b : Int16}, a.val ≠ b.val -> a ≠ b\n| _, _, h => fun a_eq_b => Int16.noConfusion a_eq_b h\n\ntheorem Int16.val_eq_of_eq : ∀ {a b : Int16}, a = b -> a.val = b.val\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int16.val_ne_of_ne : ∀ {a b : Int16}, a ≠ b -> a.val ≠ b.val\n| _, _, h => fun h' => absurd (Int16.eq_of_val_eq h') h\n\ndef Int16.isPositive (a : Int16) : Bool := a.val.val < (UInt16.size / 2)\n\ndef Int16.isNegative (a : Int16) : Bool := ¬a.isPositive\n\ndef Int16.toInt (a : Int16) : Int :=\n  if a.isPositive\n  then Int.ofNat a.val.toNat\n  else Int.subNatNat a.val.toNat UInt16.size\n\ndef Int16.toString (a : Int16) : String := s!\"{a.toInt}\"\n\ninstance : ToString Int16 := ⟨Int16.toString⟩\n\n\n\ndef Int16.ofInt : Int -> Int16\n| Int.ofNat n => Int16.ofNat n\n| Int.negSucc n => -(Int16.ofNat n.succ)\n\ndef Int16.modn (a : Int16) (n : Nat) : Int16 := Int16.ofInt <| a.toInt % (Int.ofNat n)\n\ndef Int16.shiftLeft (a b : Int16) : Int16 := ⟨a.val.shiftLeft b.val⟩\n\ndef Int16.shiftRight (a b : Int16) : Int16 := ⟨a.val.shiftRight b.val⟩\n\ndef Int16.land (a b : Int16) : Int16 := ⟨a.val.land b.val⟩\n\ndef Int16.lor (a b : Int16) : Int16 := ⟨a.val.lor b.val⟩\n\ndef Int16.xor (a b : Int16) : Int16 := ⟨a.val.xor b.val⟩\n\ninstance : HMod Int16 Nat Int16 := ⟨Int16.modn⟩\ninstance : AndOp Int16     := ⟨Int16.land⟩\ninstance : OrOp Int16      := ⟨Int16.lor⟩\ninstance : Xor Int16       := ⟨Int16.xor⟩\ninstance : ShiftLeft Int16  := ⟨Int16.shiftLeft⟩\ninstance : ShiftRight Int16 := ⟨Int16.shiftRight⟩\n\ndef Int16.add : Int16 -> Int16 -> Int16\n| ⟨a⟩, ⟨b⟩ => ⟨a + b⟩\n\ninstance : Add Int16 := ⟨Int16.add⟩\n\ndef Int16.sub (a b : Int16) : Int16 := a + -b\n\ninstance : Sub Int16 := ⟨Int16.sub⟩\n\ndef Int16.mul : Int16 -> Int16 -> Int16\n| ⟨a⟩, ⟨b⟩ => ⟨a * b⟩\n\ndef Int16.div (a b : Int16) : Int16 := Int16.ofInt (a.toInt / b.toInt)\ndef Int16.mod (a m : Int16) : Int16 := Int16.ofInt (a.toInt % m.toInt)\n\ninstance : Mul Int16 := ⟨Int16.mul⟩\n\ninstance : Mod Int16 := ⟨Int16.mod⟩\n\ninstance : Div Int16 := ⟨Int16.div⟩\n\ndef Int16.le (a b : Int16) : Prop := a.toInt <= b.toInt\ndef Int16.lt (a b : Int16) : Prop := a.toInt < b.toInt\n\ninstance : LE Int16 := ⟨Int16.le⟩\n\ninstance : LT Int16 := ⟨Int16.lt⟩\n\ninstance (a b : Int16) : Decidable (a <= b) :=\n  dite (a.toInt <= b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\ninstance (a b : Int16) : Decidable (a < b) :=\n  dite (a.toInt < b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\nstructure Int32 where\n  val : UInt32\nderiving DecidableEq\n\ndef Int32.ofNat (n : Nat) : Int32 := ⟨OfNat.ofNat n⟩\n\ninstance (n : Nat) : OfNat Int32 n := ⟨Int32.ofNat n⟩\n\n\ndef Int32.neg : Int32 -> Int32\n| ⟨⟨a, isLt⟩⟩ => ⟨(UInt32.size - a) % UInt32.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)⟩\n\ninstance : Neg Int32 := ⟨Int32.neg⟩\n\ndef Int32.min : Int32 := -2147483648\ndef Int32.max : Int32 := 2147483647\n\ntheorem Int32.eq_of_val_eq : ∀ {a b : Int32}, a.val = b.val -> a = b\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int32.ne_of_val_ne : ∀ {a b : Int32}, a.val ≠ b.val -> a ≠ b\n| _, _, h => fun a_eq_b => Int32.noConfusion a_eq_b h\n\ntheorem Int32.val_eq_of_eq : ∀ {a b : Int32}, a = b -> a.val = b.val\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int32.val_ne_of_ne : ∀ {a b : Int32}, a ≠ b -> a.val ≠ b.val\n| _, _, h => fun h' => absurd (Int32.eq_of_val_eq h') h\n\ndef Int32.isPositive (a : Int32) : Bool := a.val.val < (UInt32.size / 2)\n\ndef Int32.isNegative (a : Int32) : Bool := ¬a.isPositive\n\ndef Int32.toInt (a : Int32) : Int :=\n  if a.isPositive\n  then Int.ofNat a.val.toNat\n  else Int.subNatNat a.val.toNat UInt32.size\n\ndef Int32.toString (a : Int32) : String := s!\"{a.toInt}\"\n\ninstance : ToString Int32 := ⟨Int32.toString⟩\n\n\ndef Int32.ofInt : Int -> Int32\n| Int.ofNat n => Int32.ofNat n\n| Int.negSucc n => -(Int32.ofNat n.succ)\n\ndef Int32.modn (a : Int32) (n : Nat) : Int32 := Int32.ofInt <| a.toInt % (Int.ofNat n)\n\ndef Int32.shiftLeft (a b : Int32) : Int32 := ⟨a.val.shiftLeft b.val⟩\n\ndef Int32.shiftRight (a b : Int32) : Int32 := ⟨a.val.shiftRight b.val⟩\n\ndef Int32.land (a b : Int32) : Int32 := ⟨a.val.land b.val⟩\n\ndef Int32.lor (a b : Int32) : Int32 := ⟨a.val.lor b.val⟩\n\ndef Int32.xor (a b : Int32) : Int32 := ⟨a.val.xor b.val⟩\n\ninstance : HMod Int32 Nat Int32 := ⟨Int32.modn⟩\ninstance : AndOp Int32     := ⟨Int32.land⟩\ninstance : OrOp Int32      := ⟨Int32.lor⟩\ninstance : Xor Int32       := ⟨Int32.xor⟩\ninstance : ShiftLeft Int32  := ⟨Int32.shiftLeft⟩\ninstance : ShiftRight Int32 := ⟨Int32.shiftRight⟩\n\ndef Int32.add : Int32 -> Int32 -> Int32\n| ⟨a⟩, ⟨b⟩ => ⟨a + b⟩\n\ninstance : Add Int32 := ⟨Int32.add⟩\n\ndef Int32.sub (a b : Int32) : Int32 := a + -b\n\ninstance : Sub Int32 := ⟨Int32.sub⟩\n\ndef Int32.mul : Int32 -> Int32 -> Int32\n| ⟨a⟩, ⟨b⟩ => ⟨a * b⟩\n\ndef Int32.div (a b : Int32) : Int32 := Int32.ofInt (a.toInt / b.toInt)\ndef Int32.mod (a m : Int32) : Int32 := Int32.ofInt (a.toInt % m.toInt)\n\ninstance : Mul Int32 := ⟨Int32.mul⟩\n\ninstance : Mod Int32 := ⟨Int32.mod⟩\n\ninstance : Div Int32 := ⟨Int32.div⟩\n\ndef Int32.le (a b : Int32) : Prop := a.toInt <= b.toInt\ndef Int32.lt (a b : Int32) : Prop := a.toInt < b.toInt\n\ninstance : LE Int32 := ⟨Int32.le⟩\n\ninstance : LT Int32 := ⟨Int32.lt⟩\n\ninstance (a b : Int32) : Decidable (a <= b) :=\n  dite (a.toInt <= b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\ninstance (a b : Int32) : Decidable (a < b) :=\n  dite (a.toInt < b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\nstructure Int64 where\n  val : UInt64\nderiving DecidableEq\n\ndef Int64.ofNat (n : Nat) : Int64 := ⟨OfNat.ofNat n⟩\n\ninstance (n : Nat) : OfNat Int64 n := ⟨Int64.ofNat n⟩\n\ntheorem Int64.eq_of_val_eq : ∀ {a b : Int64}, a.val = b.val -> a = b\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int64.ne_of_val_ne : ∀ {a b : Int64}, a.val ≠ b.val -> a ≠ b\n| _, _, h => fun a_eq_b => Int64.noConfusion a_eq_b h\n\ntheorem Int64.val_eq_of_eq : ∀ {a b : Int64}, a = b -> a.val = b.val\n| ⟨_⟩, _, rfl => rfl\n\ntheorem Int64.val_ne_of_ne : ∀ {a b : Int64}, a ≠ b -> a.val ≠ b.val\n| _, _, h => fun h' => absurd (Int64.eq_of_val_eq h') h\n\ndef Int64.neg : Int64 -> Int64\n| ⟨⟨a, isLt⟩⟩ => ⟨(UInt64.size - a) % UInt64.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)⟩\n\ninstance : Neg Int64 := ⟨Int64.neg⟩\n\nabbrev Int64.min : Int64 := -9223372036854775808\nabbrev Int64.max : Int64 := 9223372036854775807\n/-\nFin.val <= 9223372036854775807\n-/\n/-\nNot sure whether it's an issue to cast all the way to `nat` here.\n-/\n--def Int64.isPositive (a : Int64) : Bool := a.val.val.val < (UInt64.size / 2)\ndef Int64.isPositive (a : Int64) : Bool := a.val <= (9223372036854775807 : UInt64)\n\ntheorem Int64.isPositive_eq_true_iff (a : Int64) : a.isPositive = true ↔ a.val <= (9223372036854775807 : UInt64) := by\n  simp [Int64.isPositive]\n\ndef Int64.isNegative (a : Int64) : Bool := ¬a.isPositive\n\n/-\nThere's probably a better way to do this.\n-/\ndef Int64.toInt (a : Int64) : Int :=\n  if a.isPositive\n  then Int.ofNat a.val.toNat\n  else Int.subNatNat a.val.toNat UInt64.size\n\ndef Int64.toString (a : Int64) : String := s!\"{a.toInt}\"\n\ninstance : ToString Int64 := ⟨Int64.toString⟩\n\n\ndef Int64.ofInt : Int → Int64\n| Int.ofNat n => Int64.ofNat n\n| Int.negSucc n => -(Int64.ofNat n.succ)\n\ndef Int64.modn (a : Int64) (n : Nat) : Int64 := Int64.ofInt <| a.toInt % (Int.ofNat n)\n\ndef Int64.shiftLeft (a b : Int64) : Int64 := ⟨a.val.shiftLeft b.val⟩\n\ndef Int64.shiftRight (a b : Int64) : Int64 := ⟨a.val.shiftRight b.val⟩\n\ndef Int64.land (a b : Int64) : Int64 := ⟨a.val.land b.val⟩\n\ndef Int64.lor (a b : Int64) : Int64 := ⟨a.val.lor b.val⟩\n\ndef Int64.xor (a b : Int64) : Int64 := ⟨a.val.xor b.val⟩\n\ninstance : HMod Int64 Nat Int64 := ⟨Int64.modn⟩\ninstance : AndOp Int64     := ⟨Int64.land⟩\ninstance : OrOp Int64      := ⟨Int64.lor⟩\ninstance : Xor Int64       := ⟨Int64.xor⟩\ninstance : ShiftLeft Int64  := ⟨Int64.shiftLeft⟩\ninstance : ShiftRight Int64 := ⟨Int64.shiftRight⟩\n\ndef Int64.add : Int64 -> Int64 -> Int64\n| ⟨a⟩, ⟨b⟩ => ⟨a + b⟩\n\ninstance : Add Int64 := ⟨Int64.add⟩\n\ndef Int64.sub (a b : Int64) : Int64 := a + -b\n\ninstance : Sub Int64 := ⟨Int64.sub⟩\n\ndef Int64.mul : Int64 -> Int64 -> Int64\n| ⟨a⟩, ⟨b⟩ => ⟨a * b⟩\n\n\ndef Int64.div (a b : Int64) : Int64 := Int64.ofInt (a.toInt / b.toInt)\ndef Int64.mod (a m : Int64) : Int64 := Int64.ofInt (a.toInt % m.toInt)\n\ninstance : Mul Int64 := ⟨Int64.mul⟩\n\ninstance : Mod Int64 := ⟨Int64.mod⟩\n\ninstance : Div Int64 := ⟨Int64.div⟩\n\ndef Int64.le (a b : Int64) : Prop := a.toInt <= b.toInt\ndef Int64.lt (a b : Int64) : Prop := a.toInt < b.toInt\n\ninstance : LE Int64 := ⟨Int64.le⟩\n\ninstance : LT Int64 := ⟨Int64.lt⟩\n\ninstance (a b : Int64) : Decidable (a <= b) :=\n  dite (a.toInt <= b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\ninstance (a b : Int64) : Decidable (a < b) :=\n  dite (a.toInt < b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\n/-\nsameSign a b ∧ differentSign a out\n-/\ndef Int64.wrappingAdd (a b : Int64) : (Bool × Int64) := \n  let sum := a + b\n  let oob :=\n    if a.isPositive \n    then \n      if b.isPositive\n      then sum.isNegative\n      else false\n    else \n      if b.isNegative\n      then sum.isPositive\n      else false\n  (oob, sum)\n\ndef Int64.checkedAdd (a b : Int64) : Option Int64 :=\n  match a.wrappingAdd b with\n  | (true, _) => none\n  | (false, sum) => some sum\n\nstructure ISize where\n  val : USize\nderiving DecidableEq\n\ndef ISize.ofNat (n : Nat) : ISize := ⟨OfNat.ofNat n⟩\n\ninstance (n : Nat) : OfNat ISize n := ⟨ISize.ofNat n⟩\n\ntheorem ISize.eq_of_val_eq : ∀ {a b : ISize}, a.val = b.val -> a = b\n| _, _, h => congrArg ISize.mk h\n\ntheorem ISize.ne_of_val_ne : ∀ {a b : ISize}, a.val ≠ b.val -> a ≠ b\n| _, _, h => fun a_eq_b => ISize.noConfusion a_eq_b h\n\ntheorem ISize.val_eq_of_eq : ∀ {a b : ISize}, a = b -> a.val = b.val\n| _, _, h => congrArg ISize.val h\n\ntheorem ISize.val_ne_of_ne : ∀ {a b : ISize}, a ≠ b -> a.val ≠ b.val\n| _, _, h => fun h' => absurd (ISize.eq_of_val_eq h') h\n\ndef ISize.isPositive (a : ISize) : Bool := a.val.val < (USize.size / 2)\n\ndef ISize.isNegative (a : ISize) : Bool := ¬a.isPositive\n\ndef ISize.toInt (a : ISize) : Int :=\n  if a.isPositive\n  then Int.ofNat a.val.toNat\n  else Int.subNatNat a.val.toNat USize.size\n\ndef ISize.toString (a : ISize) : String := s!\"{a.toInt}\"\n\ninstance : ToString ISize := ⟨ISize.toString⟩\n\ndef ISize.neg : ISize -> ISize\n| ⟨⟨a, isLt⟩⟩ => ⟨(USize.size - a) % USize.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)⟩\n\ninstance : Neg ISize := ⟨ISize.neg⟩\n\ndef ISize.ofInt : Int -> ISize\n| Int.ofNat n => ISize.ofNat n\n| Int.negSucc n => -(ISize.ofNat n.succ)\n\ndef ISize.modn (a : ISize) (n : Nat) : ISize := ISize.ofInt <| a.toInt % (Int.ofNat n)\n\ndef ISize.shiftLeft (a b : ISize) : ISize := ⟨a.val.shiftLeft b.val⟩\n\ndef ISize.shiftRight (a b : ISize) : ISize := ⟨a.val.shiftRight b.val⟩\n\ndef ISize.land (a b : ISize) : ISize := ⟨a.val.land b.val⟩\n\ndef ISize.lor (a b : ISize) : ISize := ⟨a.val.lor b.val⟩\n\ndef ISize.xor (a b : ISize) : ISize := ⟨a.val.xor b.val⟩\n\ninstance : HMod ISize Nat ISize := ⟨ISize.modn⟩\ninstance : AndOp ISize     := ⟨ISize.land⟩\ninstance : OrOp ISize      := ⟨ISize.lor⟩\ninstance : Xor ISize       := ⟨ISize.xor⟩\ninstance : ShiftLeft ISize  := ⟨ISize.shiftLeft⟩\ninstance : ShiftRight ISize := ⟨ISize.shiftRight⟩\n\ndef ISize.add : ISize -> ISize -> ISize\n| ⟨a⟩, ⟨b⟩ => ⟨a + b⟩\n\ninstance : Add ISize := ⟨ISize.add⟩\n\ndef ISize.sub (a b : ISize) : ISize := a + -b\n\ninstance : Sub ISize := ⟨ISize.sub⟩\n\ndef ISize.mul : ISize -> ISize -> ISize\n| ⟨a⟩, ⟨b⟩ => ⟨a * b⟩\n\ndef ISize.div (a b : ISize) : ISize := ISize.ofInt (a.toInt / b.toInt)\ndef ISize.mod (a m : ISize) : ISize := ISize.ofInt (a.toInt % m.toInt)\n\ninstance : Mul ISize := ⟨ISize.mul⟩\n\ninstance : Mod ISize := ⟨ISize.mod⟩\n\ninstance : Div ISize := ⟨ISize.div⟩\n\ndef ISize.le (a b : ISize) : Prop := a.toInt <= b.toInt\ndef ISize.lt (a b : ISize) : Prop := a.toInt < b.toInt\n\ninstance : LE ISize := ⟨ISize.le⟩\n\ninstance : LT ISize := ⟨ISize.lt⟩\n\ninstance : DecidableEq ISize\n| a, b =>\n  dite\n    (a.val = b.val)\n    (fun h => isTrue <| ISize.eq_of_val_eq h)\n    (fun h => isFalse <| fun h' => absurd (ISize.val_eq_of_eq h') h)\n\ninstance (a b : ISize) : Decidable (a <= b) :=\n  dite (a.toInt <= b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n\ninstance (a b : ISize) : Decidable (a < b) :=\n  dite (a.toInt < b.toInt) isTrue (fun h => isFalse <| fun h' => absurd h' h)\n", "meta": {"author": "ammkrn", "repo": "timelib", "sha": "185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15", "save_path": "github-repos/lean/ammkrn-timelib", "path": "github-repos/lean/ammkrn-timelib/timelib-185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15/Timelib/SignedInt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6757645879592642, "lm_q1q2_score": 0.47030399075305074}}
{"text": "-- VOCABULARY\n\nimport tactic.norm_num\n\nimport syntax\nimport setsimp\n\ndef vocabOfFormula : formula → finset char\n| (⊥)      := set.to_finset { }\n| ( (· c)) := { c }\n| (~ φ)    := vocabOfFormula φ\n| (φ ⋏ ψ ) := vocabOfFormula φ ∪ vocabOfFormula ψ\n| (□ φ)    := vocabOfFormula φ\n\ndef vocabOfSetFormula : finset formula → finset char\n| X := finset.bUnion X vocabOfFormula\n\nclass hasVocabulary (α : Type) := (voc : α → finset char)\nopen hasVocabulary\ninstance formula_hasVocabulary : hasVocabulary formula := hasVocabulary.mk vocabOfFormula\ninstance setFormula_hasVocabulary : hasVocabulary (finset formula) := hasVocabulary.mk vocabOfSetFormula\n\n@[simp]\nlemma vocOfNeg {ϕ} : vocabOfFormula (~ϕ) = vocabOfFormula ϕ := by split\n\nlemma vocElem_subs_vocSet {ϕ X} : ϕ ∈ X → vocabOfFormula ϕ ⊆ vocabOfSetFormula X :=\nbegin\n  apply finset.induction_on X,\n  -- case ∅:\n  intro phi_in_X, cases phi_in_X,\n  -- case insert:\n  intros ψ S psi_not_in_S IH psi_in_insert,\n  unfold vocabOfSetFormula at *,\n  simp,\n  intros a aIn,\n  simp at *,\n  cases psi_in_insert,\n  { subst psi_in_insert, left, exact aIn, },\n  { tauto, },\nend\n\nlemma vocMonotone {X Y : finset formula} (hyp : X ⊆ Y) : voc X ⊆ voc Y :=\nbegin\n  unfold voc, unfold vocabOfSetFormula at *,\n  intros a aIn,\n  unfold finset.bUnion at *,\n  simp at *,\n  tauto,\nend\n\nlemma vocErase {X : finset formula} {ϕ : formula} : voc (X \\ {ϕ}) ⊆ voc X :=\nbegin\n  apply vocMonotone,\n  rw sdiff_singleton_is_erase,\n  intros a aIn,\n  exact finset.mem_of_mem_erase aIn,\nend\n\nlemma vocUnion {X Y : finset formula} : voc (X ∪ Y) = voc X ∪ voc Y :=\nbegin\n  unfold voc vocabOfSetFormula,\n  ext1,\n  simp,\n  split ; { intro _, finish, },\nend\n\nlemma vocPreserved (X : finset formula) (ψ ϕ) :\n  ψ ∈ X → voc ϕ = voc ψ → voc X = voc (X \\ {ψ} ∪ {ϕ}) :=\nbegin\n  intros psi_in_X eq_voc,\n  unfold voc at *,\n  unfold vocabOfSetFormula,\n  ext1,\n  split,\n  all_goals { intro a_in, norm_num at *, },\n  { rcases a_in with ⟨θ,_,a_in_vocTheta⟩,\n    by_cases h : θ = ψ,\n    { left, rw eq_voc, rw ← h, exact a_in_vocTheta, },\n    { right, use θ, tauto, },\n  },\n  { cases a_in,\n    { use ψ, rw ← eq_voc, tauto, },\n    { rcases a_in with ⟨θ,_,a_in_vocTheta⟩, use θ, tauto, }\n  },\nend\n\nlemma vocPreservedTwo {X : finset formula} (ψ ϕ1 ϕ2) :\n  ψ ∈ X → voc ({ϕ1,ϕ2} : finset formula) = voc ψ → voc X = voc (X \\ {ψ} ∪ {ϕ1,ϕ2}) :=\nbegin\n  intros psi_in_X eq_voc,\n  rw vocUnion,\n  unfold voc at *,\n  unfold vocabOfSetFormula,\n  ext1,\n  split,\n  all_goals { intro a_in, norm_num at *, },\n  { rcases a_in with ⟨θ,theta_in_X,a_in_vocTheta⟩,\n    by_cases h : θ = ψ,\n    { right, subst h, unfold vocabOfSetFormula vocabOfFormula at *, simp at *, rw ← eq_voc at a_in_vocTheta, simp at a_in_vocTheta, tauto, },\n    { use θ, itauto, },\n  },\n  cases a_in,\n  { rcases a_in with ⟨θ,theta_in_X,a_in_vocTheta⟩, use θ, itauto, },\n  { use ψ, split, itauto, rw ← eq_voc, unfold vocabOfSetFormula, simp, itauto, },\nend\n\nlemma vocPreservedSub {X : finset formula} (ψ ϕ) :\n  ψ ∈ X → voc ϕ ⊆ voc ψ → voc (X \\ {ψ} ∪ {ϕ}) ⊆ voc X :=\nbegin\n  intros psi_in_X sub_voc,\n  unfold voc at *,\n  unfold vocabOfSetFormula,\n  intros a a_in, norm_num at *,\n  cases a_in,\n  { use ψ, rw finset.subset_iff at sub_voc, tauto, },\n  { rcases a_in with ⟨θ,_,a_in_vocTheta⟩, use θ, tauto, },\nend\n", "meta": {"author": "m4lvin", "repo": "tablean", "sha": "836202612fc2bfacb5545696412e7d27f7704141", "save_path": "github-repos/lean/m4lvin-tablean", "path": "github-repos/lean/m4lvin-tablean/tablean-836202612fc2bfacb5545696412e7d27f7704141/src/vocabulary.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6757645879592641, "lm_q1q2_score": 0.4703039822300624}}
{"text": "/-\nCopyright (c) 2022 Heather Macbeth. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Heather Macbeth\n\n! This file was ported from Lean 3 source module order.complete_lattice_intervals\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.ConditionallyCompleteLattice.Basic\nimport Mathbin.Data.Set.Intervals.OrdConnected\n\n/-! # Subtypes of conditionally complete linear orders\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we give conditions on a subset of a conditionally complete linear order, to ensure that\nthe subtype is itself conditionally complete.\n\nWe check that an `ord_connected` set satisfies these conditions.\n\n## TODO\n\nAdd appropriate instances for all `set.Ixx`. This requires a refactor that will allow different\ndefault values for `Sup` and `Inf`.\n-/\n\n\nopen Classical\n\nopen Set\n\nvariable {α : Type _} (s : Set α)\n\nsection SupSet\n\nvariable [SupSet α]\n\n#print subsetSupSet /-\n/-- `has_Sup` structure on a nonempty subset `s` of an object with `has_Sup`. This definition is\nnon-canonical (it uses `default s`); it should be used only as here, as an auxiliary instance in the\nconstruction of the `conditionally_complete_linear_order` structure. -/\nnoncomputable def subsetSupSet [Inhabited s] : SupSet s\n    where supₛ t :=\n    if ht : supₛ (coe '' t : Set α) ∈ s then ⟨supₛ (coe '' t : Set α), ht⟩ else default\n#align subset_has_Sup subsetSupSet\n-/\n\nattribute [local instance] subsetSupSet\n\n#print subset_supₛ_def /-\n@[simp]\ntheorem subset_supₛ_def [Inhabited s] :\n    @supₛ s _ = fun t =>\n      if ht : supₛ (coe '' t : Set α) ∈ s then ⟨supₛ (coe '' t : Set α), ht⟩ else default :=\n  rfl\n#align subset_Sup_def subset_supₛ_def\n-/\n\n#print subset_supₛ_of_within /-\ntheorem subset_supₛ_of_within [Inhabited s] {t : Set s} (h : supₛ (coe '' t : Set α) ∈ s) :\n    supₛ (coe '' t : Set α) = (@supₛ s _ t : α) := by simp [dif_pos h]\n#align subset_Sup_of_within subset_supₛ_of_within\n-/\n\nend SupSet\n\nsection InfSet\n\nvariable [InfSet α]\n\n#print subsetInfSet /-\n/-- `has_Inf` structure on a nonempty subset `s` of an object with `has_Inf`. This definition is\nnon-canonical (it uses `default s`); it should be used only as here, as an auxiliary instance in the\nconstruction of the `conditionally_complete_linear_order` structure. -/\nnoncomputable def subsetInfSet [Inhabited s] : InfSet s\n    where infₛ t :=\n    if ht : infₛ (coe '' t : Set α) ∈ s then ⟨infₛ (coe '' t : Set α), ht⟩ else default\n#align subset_has_Inf subsetInfSet\n-/\n\nattribute [local instance] subsetInfSet\n\n#print subset_infₛ_def /-\n@[simp]\ntheorem subset_infₛ_def [Inhabited s] :\n    @infₛ s _ = fun t =>\n      if ht : infₛ (coe '' t : Set α) ∈ s then ⟨infₛ (coe '' t : Set α), ht⟩ else default :=\n  rfl\n#align subset_Inf_def subset_infₛ_def\n-/\n\n#print subset_infₛ_of_within /-\ntheorem subset_infₛ_of_within [Inhabited s] {t : Set s} (h : infₛ (coe '' t : Set α) ∈ s) :\n    infₛ (coe '' t : Set α) = (@infₛ s _ t : α) := by simp [dif_pos h]\n#align subset_Inf_of_within subset_infₛ_of_within\n-/\n\nend InfSet\n\nvariable [ConditionallyCompleteLinearOrder α]\n\nattribute [local instance] subsetSupSet\n\nattribute [local instance] subsetInfSet\n\n/- warning: subset_conditionally_complete_linear_order -> subsetConditionallyCompleteLinearOrder is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (s : Set.{u1} α) [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : Inhabited.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)], (forall {t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) t) -> (BddAbove.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)) t) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) t)) s)) -> (forall {t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) t) -> (BddBelow.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)) t) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) t)) s)) -> (ConditionallyCompleteLinearOrder.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s))\nbut is expected to have type\n  forall {α : Type.{u1}} (s : Set.{u1} α) [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] [_inst_2 : Inhabited.{succ u1} (Set.Elem.{u1} α s)], (forall {t : Set.{u1} (Set.Elem.{u1} α s)}, (Set.Nonempty.{u1} (Set.Elem.{u1} α s) t) -> (BddAbove.{u1} (Set.Elem.{u1} α s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} α s) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t)) s)) -> (forall {t : Set.{u1} (Set.Elem.{u1} α s)}, (Set.Nonempty.{u1} (Set.Elem.{u1} α s) t) -> (BddBelow.{u1} (Set.Elem.{u1} α s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} α s) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t)) s)) -> (ConditionallyCompleteLinearOrder.{u1} (Set.Elem.{u1} α s))\nCase conversion may be inaccurate. Consider using '#align subset_conditionally_complete_linear_order subsetConditionallyCompleteLinearOrderₓ'. -/\n/-- For a nonempty subset of a conditionally complete linear order to be a conditionally complete\nlinear order, it suffices that it contain the `Sup` of all its nonempty bounded-above subsets, and\nthe `Inf` of all its nonempty bounded-below subsets.\nSee note [reducible non-instances]. -/\n@[reducible]\nnoncomputable def subsetConditionallyCompleteLinearOrder [Inhabited s]\n    (h_Sup : ∀ {t : Set s} (ht : t.Nonempty) (h_bdd : BddAbove t), supₛ (coe '' t : Set α) ∈ s)\n    (h_Inf : ∀ {t : Set s} (ht : t.Nonempty) (h_bdd : BddBelow t), infₛ (coe '' t : Set α) ∈ s) :\n    ConditionallyCompleteLinearOrder s :=\n  {-- The following would be a more natural way to finish, but gives a \"deep recursion\" error:\n      -- simpa [subset_Sup_of_within (h_Sup t)] using\n      --   (strict_mono_coe s).monotone.le_cSup_image hct h_bdd,\n      subsetSupSet\n      s,\n    subsetInfSet s, DistribLattice.toLattice s,\n    (inferInstance :\n      LinearOrder\n        s) with\n    le_cSup := by\n      rintro t c h_bdd hct\n      have := (Subtype.mono_coe s).le_csupₛ_image hct h_bdd\n      rwa [subset_supₛ_of_within s (h_Sup ⟨c, hct⟩ h_bdd)] at this\n    cSup_le := by\n      rintro t B ht hB\n      have := (Subtype.mono_coe s).csupₛ_image_le ht hB\n      rwa [subset_supₛ_of_within s (h_Sup ht ⟨B, hB⟩)] at this\n    le_cInf := by\n      intro t B ht hB\n      have := (Subtype.mono_coe s).le_cinfₛ_image ht hB\n      rwa [subset_infₛ_of_within s (h_Inf ht ⟨B, hB⟩)] at this\n    cInf_le := by\n      rintro t c h_bdd hct\n      have := (Subtype.mono_coe s).cinfₛ_image_le hct h_bdd\n      rwa [subset_infₛ_of_within s (h_Inf ⟨c, hct⟩ h_bdd)] at this }\n#align subset_conditionally_complete_linear_order subsetConditionallyCompleteLinearOrder\n\nsection OrdConnected\n\n/- warning: Sup_within_of_ord_connected -> supₛ_within_of_ordConnected is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] {s : Set.{u1} α} [hs : Set.OrdConnected.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s] {{t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)}}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) t) -> (BddAbove.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)) t) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toHasSup.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) t)) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] {s : Set.{u1} α} [hs : Set.OrdConnected.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s] {{t : Set.{u1} (Set.Elem.{u1} α s)}}, (Set.Nonempty.{u1} (Set.Elem.{u1} α s) t) -> (BddAbove.{u1} (Set.Elem.{u1} α s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (SupSet.supₛ.{u1} α (ConditionallyCompleteLattice.toSupSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} α s) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t)) s)\nCase conversion may be inaccurate. Consider using '#align Sup_within_of_ord_connected supₛ_within_of_ordConnectedₓ'. -/\n/-- The `Sup` function on a nonempty `ord_connected` set `s` in a conditionally complete linear\norder takes values within `s`, for all nonempty bounded-above subsets of `s`. -/\ntheorem supₛ_within_of_ordConnected {s : Set α} [hs : OrdConnected s] ⦃t : Set s⦄ (ht : t.Nonempty)\n    (h_bdd : BddAbove t) : supₛ (coe '' t : Set α) ∈ s :=\n  by\n  obtain ⟨c, hct⟩ : ∃ c, c ∈ t := ht\n  obtain ⟨B, hB⟩ : ∃ B, B ∈ upperBounds t := h_bdd\n  refine' hs.out c.2 B.2 ⟨_, _⟩\n  · exact (Subtype.mono_coe s).le_csupₛ_image hct ⟨B, hB⟩\n  · exact (Subtype.mono_coe s).csupₛ_image_le ⟨c, hct⟩ hB\n#align Sup_within_of_ord_connected supₛ_within_of_ordConnected\n\n/- warning: Inf_within_of_ord_connected -> infₛ_within_of_ordConnected is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] {s : Set.{u1} α} [hs : Set.OrdConnected.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s] {{t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)}}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) t) -> (BddBelow.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)) t) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toHasInf.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s)))))) t)) s)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} α] {s : Set.{u1} α} [hs : Set.OrdConnected.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) s] {{t : Set.{u1} (Set.Elem.{u1} α s)}}, (Set.Nonempty.{u1} (Set.Elem.{u1} α s) t) -> (BddBelow.{u1} (Set.Elem.{u1} α s) (Subtype.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (ConditionallyCompleteLattice.toLattice.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1))))) (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) (InfSet.infₛ.{u1} α (ConditionallyCompleteLattice.toInfSet.{u1} α (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} α _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} α s) α (Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s)) t)) s)\nCase conversion may be inaccurate. Consider using '#align Inf_within_of_ord_connected infₛ_within_of_ordConnectedₓ'. -/\n/-- The `Inf` function on a nonempty `ord_connected` set `s` in a conditionally complete linear\norder takes values within `s`, for all nonempty bounded-below subsets of `s`. -/\ntheorem infₛ_within_of_ordConnected {s : Set α} [hs : OrdConnected s] ⦃t : Set s⦄ (ht : t.Nonempty)\n    (h_bdd : BddBelow t) : infₛ (coe '' t : Set α) ∈ s :=\n  by\n  obtain ⟨c, hct⟩ : ∃ c, c ∈ t := ht\n  obtain ⟨B, hB⟩ : ∃ B, B ∈ lowerBounds t := h_bdd\n  refine' hs.out B.2 c.2 ⟨_, _⟩\n  · exact (Subtype.mono_coe s).le_cinfₛ_image ⟨c, hct⟩ hB\n  · exact (Subtype.mono_coe s).cinfₛ_image_le hct ⟨B, hB⟩\n#align Inf_within_of_ord_connected infₛ_within_of_ordConnected\n\n#print ordConnectedSubsetConditionallyCompleteLinearOrder /-\n/-- A nonempty `ord_connected` set in a conditionally complete linear order is naturally a\nconditionally complete linear order. -/\nnoncomputable instance ordConnectedSubsetConditionallyCompleteLinearOrder [Inhabited s]\n    [OrdConnected s] : ConditionallyCompleteLinearOrder s :=\n  subsetConditionallyCompleteLinearOrder s supₛ_within_of_ordConnected infₛ_within_of_ordConnected\n#align ord_connected_subset_conditionally_complete_linear_order ordConnectedSubsetConditionallyCompleteLinearOrder\n-/\n\nend OrdConnected\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/CompleteLatticeIntervals.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.47030330819738037}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\n\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.ennreal\nimport formal_ml.sum\nimport formal_ml.lattice\nimport formal_ml.measurable_space\nimport formal_ml.classical\nimport formal_ml.core\nimport formal_ml.characteristic\nimport formal_ml.measure\nimport data.equiv.list\n\n\nnoncomputable def pi.outer_measure {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ a, measurable_space (β a)] \n  (μ:Π a, measure_theory.outer_measure (β a)):measure_theory.outer_measure (Π a, β a) := \n  measure_theory.outer_measure.of_function\n  (λ P:set (Π a, β a), finset.univ.prod (λ (a:α), (μ a) ((λ (p:Π a, β a), p a) '' P)))\nbegin\n  simp,\n  rw finset.card_pos,\n  rw finset.univ_nonempty_iff,\n  apply N,\nend \n\nsection pi\n\nopen_locale classical\n\n\nlemma ennreal.prod_le_prod {α:Type*} {f g:α → ennreal} {s:finset α}:(∀ a∈ s, f a ≤ g a) → s.prod f ≤ s.prod g :=\nbegin\n  apply finset.induction_on s,\n  { intros h_le, simp, apply le_refl _ },\n  { intros a s' h_not_mem h_ind h_le,\n    rw finset.prod_insert h_not_mem, rw finset.prod_insert h_not_mem,\n    apply ennreal.mul_le_mul,\n    apply h_le, simp,\n    apply h_ind, intros a' h_le_a',\n    apply h_le, simp [h_le_a'], },\nend\n\n\nlemma finset.insert_erase_univ {α:Type*} [F:fintype α] {d:α}:\ninsert d (finset.univ.erase d) = finset.univ :=\nbegin\n  rw finset.insert_erase,\n  apply finset.mem_univ,\nend\n\n\nnoncomputable def pi.measure {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ a, measurable_space (β a)] \n  (μ:Π a, measure_theory.measure (β a)):measure_theory.measure (Π a, β a) := \n  (pi.outer_measure (λ a, (μ a).to_outer_measure)).to_measure begin\n  unfold measurable_space.pi,\n  simp,\n  intros d,\n  intros P A1,\n  unfold measurable_space.comap at A1,\n  simp at A1,\n  cases A1 with s A1,\n  cases A1 with A1 A2,\n  subst P,\n  apply measure_theory.outer_measure.of_function_caratheodory,\n  simp,\n  intros t,\n  have D1:finset.univ = insert d (finset.univ.erase d),\n  { rw finset.insert_erase_univ },\n  rw D1,\n  rw finset.prod_insert,\n  rw finset.prod_insert,\n  rw finset.prod_insert,\n  have B1:(μ d) ((λ (p : Π (a : α), (λ (a : α), β a) a), p d) '' t∩ s) +\n          (μ d) ((λ (p : Π (a : α), (λ (a : α), β a) a), p d) '' t\\ s) =\n          (μ d) ((λ (p : Π (a : α), (λ (a : α), β a) a), p d) '' t),\n  { rw ← measure_theory.measure_eq_inter_diff', apply A1 },\n   rw ← B1,\n  clear B1,\n  rw right_distrib,\n  apply @add_le_add ennreal _;\n  apply ennreal.mul_le_mul;\n  try {apply measure_theory.measure_mono};\n  try { simp, apply set.subset.trans,\n    apply set.inter_subset_left, apply set.subset_preimage_image };\n  try { apply ennreal.prod_le_prod, intros a h_a_mem,\n    apply measure_theory.measure_mono, simp, apply set.subset.trans,\n    apply set.inter_subset_left, apply set.subset_preimage_image },\n  { simp, apply set.diff_subset_diff_left, apply set.subset_preimage_image },\n  repeat {simp},\nend \n\n\ndef cast.pi {α:Type*} {β:α → Type*} {a a':α} (b:β a) (h:a = a'):β a' := cast begin\nrw h end b  \n\n\ndef subst.pi {α:Type*} [decidable_eq α] {β:α → Type*} (f:Π (a:α), β a) (a':α) (b:β a'):Π (a:α), β a :=\n  λ (a:α), @dite (a' = a) _ (β a) (λ h, cast.pi b h) (λ h, f a)\n\n\nlemma subst.pi_eq {α:Type*} [decidable_eq α] {β:α → Type*} (f:Π (a:α), β a) (a':α) (b:β a'):\n  (subst.pi f a' b) a' = b := begin\n  simp [subst.pi],\n  refl,\nend\n\n\nlemma subst.pi_ne {α:Type*} [decidable_eq α] {β:α → Type*} (f:Π (a:α), β a) (a a':α) (b:β a')\n (h:a' ≠ a):\n  (subst.pi f a' b) a = f a := begin\n  simp [subst.pi],\n  rw dif_neg,\n  apply h,\nend\n\n\nlemma set.project_pi {α:Type*} {β:α → Type*} {f:Π (a:α), set (β a)} (h:∀ a, (f a).nonempty) \n  {a':α}:\n      ((λ (p : Π (a : α), β a), p a') '' (set.pi set.univ f)) = f a' :=\nbegin\n  ext x,\n  split;intros A1,\n  simp [set.pi] at A1,\n  { cases A1 with y A1,\n    cases A1 with A1 A2,\n    subst x,\n    apply A1 },\n  { simp [set.pi],\n    have h2:∀ (a:α), ∃ b:β a, b ∈ (f a),\n    { intros a, rw ← set.nonempty_def,\n      apply h },\n    rw classical.skolem at h2,\n    cases h2 with g h2,\n    apply exists.intro (subst.pi g a' x),\n    split,\n    intros q,\n    cases (classical.em (a' = q)) with A3 A3,\n    { subst q,\n      rw subst.pi_eq, apply A1 },\n    { rw subst.pi_ne,\n      apply h2,\n      apply A3, },\n    rw subst.pi_eq },\nend\n\n\n\nlemma set.pi_empty {α:Type*} {β:α → Type*} {f:Π (a:α), set (β a)}  \n  {a':α} (h2:f a' = ∅):\n  (set.pi set.univ f) = ∅ :=\nbegin\n  ext x, simp, split,\n  { have h3:x a' ∉ f a',\n    { simp [h2] },\n    apply h3, },\nend\n\n\nlemma pi.outer_measure.Inf_sum {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ a, measurable_space (β a)] \n  (μ:Π a, measure_theory.outer_measure (β a)) {P:set (Π a, β a)}:\n  pi.outer_measure μ P =\n  (⨅ (f:ℕ → (Π (a:α), set (β a))) (h₁:P ⊆ ⋃ (n:ℕ), set.pi set.univ (f n)), \n  ∑' (n:ℕ), finset.univ.prod (λ (m:α), μ m (f n m))) := begin\n  unfold pi.outer_measure measure_theory.outer_measure.of_function,\n  rw ← measure_theory.outer_measure.measure_of_eq_coe,\n  simp,\n  apply le_antisymm,\n  { simp,\n  intros f B1,\n  apply @infi_le_of_le ennreal  _ _ _ _ (λ (n:ℕ), set.pi set.univ ((f n))),\n  apply @infi_le_of_le ennreal  _ _ _ _ _,\n  apply ennreal.tsum_le_tsum,\n  intros n,  \n  cases (classical.em (∀ (a:α), (f n a).nonempty)) with B2 B2,\n  { have D1:(λ (a : α), (μ a) ((λ (p : Π (a : α), β a), p a) '' (λ (n : ℕ), set.pi set.univ (f n)) n)) = (λ (m : α), (μ m) (f n m)),\n    { ext1 a, simp [set.project_pi], rw set.project_pi, apply B2 },\n    rw D1, apply le_refl _, },\n  { rw classical.not_forall_iff_exists_not at B2,\n    cases B2 with a B2, rw set.not_nonempty_iff_eq_empty at B2,\n    rw @finset.prod_eq_zero _ _ _ a,\n    rw @finset.prod_eq_zero _ _ _ a,\n    apply le_refl _,\n    apply finset.mem_univ,\n    rw B2,\n    apply measure_theory.outer_measure.empty,\n    apply finset.mem_univ,\n    simp,\n    rw set.pi_empty B2,\n    simp },\n    apply B1 },\n  { simp,\n    intros f A1,\n    let f':ℕ → (Π (a:α), set (β a)) := (λ n m, ((λ (p:Π (a:α), β a), p m) '' (f n))),\n    begin\n      apply @infi_le_of_le ennreal (ℕ → (Π (a:α), set (β a))) _ _ _ f',  \n      rw infi_prop_def,\n      simp [f'],\n      apply le_refl _,\n      apply @set.subset.trans (Π a, β a) P (set.Union f) (⋃ (n : ℕ), set.pi set.univ (f' n))  A1,\n      apply set.Union_subset_Union,\n      intros i,\n      rw set.subset_def,\n      intros x A1,\n      simp,\n      intros a,\n      apply exists.intro x,\n      simp [A1],\n    end },\nend\n\n\nlemma set.pi_subset_pi {α:Type*} {β:α → Type*} {S:Π (a:α), set (β a)} {T:Π (a:α), set (β a)}:\n    (∀ a, S a ⊆ T a) → set.pi set.univ S ⊆ set.pi set.univ T :=\nbegin\n  rw set.subset_def,\n  intros A0 x A1,\n  simp,\n  intros a,\n  simp at A1,\n  apply A0,\n  apply A1,\nend\n \n\nlemma pi.outer_measure.Inf_sum2 {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ (a:α), measurable_space (β a)] \n  (μ:Π (a:α), measure_theory.measure (β a)) {P:set (Π (a:α), β a)}:\n  pi.outer_measure (λ (a:α), (μ a).to_outer_measure) P = \n\n  (⨅ (f:ℕ → (Π (a:α), set (β a))) (h₁:∀ n m, measurable_set (f n m))\n  (h₃:P ⊆ ⋃ (n:ℕ), set.pi set.univ (f n)), \n  ∑' (n:ℕ), finset.univ.prod (λ (m:α), μ m (f n m))) := begin\n  rw pi.outer_measure.Inf_sum,\n  apply le_antisymm,\n  { simp,\n    intros f h₁ h₃,\n    apply @infi_le_trans (ℕ→ Π (a:α), set (β a)) ennreal _ f,\n    rw infi_prop_def,\n    apply le_refl _,\n    apply h₃ },\n  { simp,\n    intros f h₁,\n   have h4_2 := λ (n:ℕ) (m:α), measure_theory.measurable_eq (μ m) (f n m),\n    have h4:∀ n, ∃ (g:Π (a:α), set (β a)), ∀ (a:α), measurable_set (g a) ∧ (μ a) (g a) = (μ a) (f n a) ∧ f n a ⊆ g a,\n    { intros n, have h5_1 := h4_2 n,\n      apply classical.axiom_of_choice h5_1, },\n    rw classical.skolem at h4,\n\n    cases h4 with f' h4,\n\n\n    apply @infi_le_trans (ℕ→ (Π (a:α), set (β a))) ennreal _ f',\n    rw infi_prop_def,\n    rw infi_prop_def,\n    { apply ennreal.tsum_le_tsum,\n      intro n,\n      apply ennreal.prod_le_prod,\n      intros a h_dummy,\n      rw (h4 n a).right.left, apply le_refl _, },\n    apply set.subset.trans,\n    apply h₁,\n    apply set.Union_subset_Union,\n    intro n,\n    apply set.pi_subset_pi,\n    intros a,\n    apply (h4 n a).right.right,\n    intros n m,\n    apply (h4 n m).left,\n    },\nend\n\n\n/-\n  If we can make this into an equality, we're home free. \n  See https://www.math.ucdavis.edu/~hunter/measure_theory/measure_notes_ch5.pdf\n  Those notes focus on measurable sets. We could theoretically do the same. However,\n  it would make the rest of the analysis much more complex.\n  I wonder if using an \"outer measure lower integral\" would make this useful. \n-/\nlemma pi.outer_measure.apply_prod_le {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ a, measurable_space (β a)] \n  (μ:Π a, measure_theory.outer_measure (β a)) {P:(Π a, set (β a))}:\n  pi.outer_measure μ (set.pi set.univ P) ≤ finset.univ.prod (λ a, μ a (P a)) :=\nbegin\n  rw pi.outer_measure.Inf_sum,\n  { apply @infi_le_of_le ennreal _ _ _ _ (λ (n:ℕ) (a:α), ite (n = 0) (P a) ∅),\n    apply @infi_le_of_le ennreal _ _ _ _ _,\n    rw tsum_eq_single 0,\n    {simp [le_refl]},\n    intros b' B1,\n    simp [B1],\n    rw finset.card_pos,\n    rw finset.univ_nonempty_iff,\n    apply N,\n  apply ennreal.t2_space,\n  rw set.subset_def,\n  intros p B2,\n  simp,\n  apply exists.intro 0,\n  {simp at B2,simp [B2]}},\nend\n\n\nlemma set.characteristic.pi {α:Type*} [F:fintype α] {β:α → Type*} {P:Π a, set (β a)}\n  {x:Π a, β a}:(set.pi set.univ P).characteristic x = \nfinset.univ.prod (λ a, (P a).characteristic (x a)) :=\nbegin\n  have A1:∀ S:finset α, (set.pi (↑S) P).characteristic x = \n       S.prod (λ a, (P a).characteristic (x a)),\n  { intros S,\n    apply finset.induction_on S,\n    { simp },\n    { intros a T h_not_mem h_ind,\n      rw finset.prod_insert h_not_mem,\n      rw ← h_ind,\n      cases classical.em ((x a) ∈ (P a)) with A1 A1,\n      rw set.characteristic.of_mem A1,\n      rw one_mul,\n      cases classical.em (x ∈ (set.pi (↑T) P)) with A2 A2,\n      { rw set.characteristic.of_mem A2,\n        rw set.characteristic.of_mem,\n        simp at A2, simp [A1,A2], apply A2, },\n      { rw set.characteristic.of_not_mem A2,\n        rw set.characteristic.of_not_mem,\n        simp at A2,\n        simp [A1,A2], },\n      { rw set.characteristic.of_not_mem A1,\n        rw zero_mul,\n        rw set.characteristic.of_not_mem,\n        simp [A1], } } },\n  have A2:set.univ = ↑(finset.univ),\n  { ext x, split; intros A1, rw  @finset.mem_coe α x, simp, simp },\n  rw A2,\n  apply A1,\nend\n\n\nlemma finset.prod_univ_diff_insert {α:Type*} [fintype α] (f:α → ennreal) (A:finset α) (a:α) (h:a∉ A):\n(finset.univ \\ A).prod f = f a * (finset.univ \\ (insert a A)).prod f :=\nbegin\n  have A1:finset.univ \\ A = (insert a (finset.univ \\ (insert a A))),\n  { ext x, split;intros A1_1; simp at A1_1; simp [A1_1], apply classical.em (x = a),\n    cases A1_1,\n    subst x,\n    apply h,\n    intros contra,\n    apply A1_1,\n    right,\n    apply contra },\n  rw A1,\n  rw finset.prod_insert,\n  simp,\nend\n\n \nlemma pi.outer_measure.le_apply_prod {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ a, measurable_space (β a)] \n  (μ:Π a, measure_theory.measure (β a)) {P:(Π a, set (β a))}:(∀ (a:α), measurable_set (P a)) →\n  finset.univ.prod (λ a, μ a (P a)) ≤\n  pi.outer_measure (λ a, (μ a).to_outer_measure) (set.pi set.univ P) :=\nbegin\n  intro A4,\n  /- Due to an implementation detail, it is best to consider an empty set separately. -/\n  cases (classical.em (∀ (a:α), (P a).nonempty)) with h_all_nonempty h_exists_empty,\n\n  rw pi.outer_measure.Inf_sum2,\n  simp,\n  intros f A2 A3,\n  have h2:(set.pi set.univ P).characteristic ≤ ∑' (n : ℕ), (set.pi set.univ (f n)).characteristic,\n  { apply function.le_trans (set.characteristic.subset A3),\n    apply set.characteristic.Union },\n  have h3:∀ (x:Π (a:α), β a), finset.univ.prod (λ a, (P a).characteristic (x a))  ≤ \n          ∑' (n : ℕ), finset.univ.prod (λ a, (f n a).characteristic (x a)),\n  { intros x,\n    rw ← set.characteristic.pi,\n    have h3a: (λ n, (finset.univ.prod (λ a, (f n a).characteristic (x a)))) =\n              (λ n, (set.pi (set.univ) (f n)).characteristic x),\n    { ext1 n, rw set.characteristic.pi },\n    rw h3a,\n    have h3b:((∑' (n : ℕ), (set.pi set.univ (f n)).characteristic) x) =\n        (∑' (n : ℕ), (set.pi set.univ (f n)).characteristic x) ,\n    { apply ennreal.tsum_apply }, \n    rw ← h3b,\n    apply h2 },\n  have h4:∀ (A:finset α), ∀ (x:Π (a:α), β a),\n    (A.prod (λ a, μ a (P a))) * ((finset.univ \\ A).prod (λ a, (P a).characteristic (x a))) ≤\n    ∑' (n:ℕ), (A.prod (λ a, μ a (f n a))) * ((finset.univ \\ A).prod (λ a, (f n a).characteristic (x a))),\n  { intros A, apply finset.induction_on A,\n    { intros x, simp, apply h3 },\n    { intros a' s h_not_mem h_ind x,\n      have h4_1:(λ (x':β a'), (P a').characteristic (x') *\n      (s.prod (λ (a : α), (μ a) (P a)) *\n         (finset.univ \\ insert a' s).prod (λ (a : α), (P a).characteristic (x a)))) ≤\n    (λ (x':β a'), ∑' (n : ℕ),\n      (f n a').characteristic (x') *\n        (s.prod (λ (a : α), (μ a) (f n a)) *\n           (finset.univ \\ insert a' s).prod (λ (a : α), (f n a).characteristic (x a)))),\n      { rw has_le_fun_def, intros x',\n        have h4_1_1 := h_ind (subst.pi x a' x'),\n        have h4_1_2 :s.prod (λ (a : α), (μ a) (P a)) * (finset.univ \\ s).prod (λ (a : α), (P a).characteristic (subst.pi x a' x' a)) =  \n (P a').characteristic (x') *\n(s.prod (λ (a : α), (μ a) (P a)) *\n       (finset.univ \\ insert a' s).prod (λ (a : α), (P a).characteristic (x a))),\n      { \n        have h4_1_2_1:\n      (finset.univ \\ (insert  a' s)).prod (λ (a : α), (P a).characteristic (subst.pi x a' x' a)) =\n      (finset.univ \\ (insert a' s)).prod (λ ⦃a' : α⦄, (P a').characteristic (x a')),\n       { apply finset.prod_congr,\n         refl, intros a'' h4_1_2_1_1, rw subst.pi_ne, simp at h4_1_2_1_1, intros contra, apply\n         h4_1_2_1_1, left, rw contra,  },\n        rw ← h4_1_2_1,\n        clear h4_1_2_1,\n        rw ← mul_assoc, rw mul_comm ((P a').characteristic (x')),\n        rw mul_assoc,\n        have h4_1_2_2:(P a').characteristic x' = (λ a, (P a).characteristic (subst.pi x a' x' a)) a',\n        { simp, rw subst.pi_eq x a' x' },\n        rw h4_1_2_2,\n        rw finset.prod_univ_diff_insert _ _ a' h_not_mem,\n         },\n      rw h4_1_2 at h4_1_1,\n      clear h4_1_2,\n     have h4_1_3:(λ \n(n : ℕ),\n      s.prod (λ (a : α), (μ a) (f n a)) *\n        (finset.univ \\ s).prod (λ (a : α), (f n a).characteristic (subst.pi x a' x' a))) =\n(λ (n:ℕ), \n      (f n a').characteristic x' *\n        (s.prod (λ (a : α), (μ a) (f n a)) *\n           (finset.univ \\ insert a' s).prod (λ (a : α), (f n a).characteristic (x a)))),\n      { ext1 n,\n        have h4_1_2_1:\n      (finset.univ \\ (insert  a' s)).prod (λ (a : α), (f n a).characteristic (subst.pi x a' x' a)) =\n      (finset.univ \\ (insert a' s)).prod (λ ⦃a' : α⦄, (f n a').characteristic (x a')),\n       { apply finset.prod_congr,\n         refl, intros a'' h4_1_2_1_1, rw subst.pi_ne, simp at h4_1_2_1_1, intros contra, apply\n         h4_1_2_1_1, left, rw contra,  },\n        rw ← h4_1_2_1,\n        clear h4_1_2_1,\n        rw ← mul_assoc, rw mul_comm ((f n a').characteristic (x')),\n        rw mul_assoc,\n        have h4_1_2_2:(f n a').characteristic x' = (λ a, (f n a).characteristic (subst.pi x a' x' a)) a',\n        { simp, rw subst.pi_eq x a' x' },\n        rw h4_1_2_2,\n        rw finset.prod_univ_diff_insert _ _ a' h_not_mem,\n        \n         },\n    rw h4_1_3 at h4_1_1,\n    clear h4_1_3,\n    apply h4_1_1,\n  },\n      have h4_2:measure_theory.lintegral (μ a') (λ (x':β a'), (P a').characteristic (x') *\n      (s.prod (λ (a : α), (μ a) (P a)) *\n         (finset.univ \\ insert a' s).prod (λ (a : α), (P a).characteristic (x a)))) ≤\n         measure_theory.lintegral (μ a')\n    (λ (x':β a'), ∑' (n : ℕ),\n      (f n a').characteristic (x') *\n        (s.prod (λ (a : α), (μ a) (f n a)) *\n           (finset.univ \\ insert a' s).prod (λ (a : α), (f n a).characteristic (x a)))),\n      { apply measure_theory.lintegral_mono, apply h4_1, },\n      clear h4_1,\n      have h4_3:measure_theory.lintegral (μ a') (λ (x':β a'), (P a').characteristic (x') *\n      (s.prod (λ (a : α), (μ a) (P a)) *\n         (finset.univ \\ insert a' s).prod (λ (a : α), (P a).characteristic (x a)))) =\n         (insert a' s).prod (λ (a : α), (μ a) (P a)) *\n         (finset.univ \\ insert a' s).prod (λ (a : α), (P a).characteristic (x a)),\n      { rw measure_theory.lintegral_mul_const,\n        rw measure_theory.lintegral_characteristic,\n        rw ← mul_assoc,\n        rw finset.prod_insert h_not_mem, apply A4, apply measurable.characteristic,\n        apply A4 },\n      rw h4_3 at h4_2,\n      clear h4_3,\n      have h4_4:(∫⁻ (x' : β a'),\n      (∑' (n : ℕ),\n         (f n a').characteristic x' *\n           (s.prod (λ (a : α), (μ a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (λ (a : α), (f n a).characteristic (x a)))) ∂μ a')\n        = \n      (∑' (n : ℕ),\n∫⁻ (x' : β a'),\n(f n a').characteristic x' *\n           (s.prod (λ (a : α), (μ a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (λ (a : α), (f n a).characteristic (x a))) ∂μ a'),\n      { rw measure_theory.lintegral_tsum,\n        intros n, apply measurable.ennreal_mul,\n        apply measurable.characteristic,\n        apply A2,\n        apply measurable_const },\n      rw h4_4 at h4_2,\n      clear h4_4,\n      have h4_5:(λ (n : ℕ),\n∫⁻ (x' : β a'),\n(f n a').characteristic x' *\n           (s.prod (λ (a : α), (μ a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (λ (a : α), (f n a).characteristic (x a))) ∂μ a') =\n(λ (n : ℕ),\n           (insert a' s).prod (λ (a : α), (μ a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (λ (a : α), (f n a).characteristic (x a))),\n      { ext1 n,\n        rw measure_theory.lintegral_mul_const,\n        rw measure_theory.lintegral_characteristic,\n        rw ← mul_assoc,\n        rw finset.prod_insert h_not_mem,\n        apply A2, apply measurable.characteristic, apply A2, },\n   rw h4_5 at h4_2,\n   clear h4_5,\n   apply h4_2,\n } },\n\n  have h7:∀ (a:α), ∃ x, x ∈ P a,\n  { intros a, rw ← set.nonempty_def, apply h_all_nonempty },\n  have h8 := classical.axiom_of_choice h7,\n  cases h8 with g h8,\n  have h6 := h4 finset.univ g,\n  simp at h6,\n  apply h6,\n  rw classical.not_forall_iff_exists_not at h_exists_empty,\n  cases h_exists_empty with a h_empty,\n  rw set.not_nonempty_iff_eq_empty at h_empty,\n  rw @finset.prod_eq_zero _ _ _ a,\n  { simp },\n  { simp },\n  simp [h_empty],  \nend\n\n\n\nlemma pi.measure_apply \n{α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ a, measurable_space (β a)] \n  (μ:Π a, measure_theory.measure (β a)) {P:set (Π a, β a)}:measurable_set P →\n  pi.measure μ P =\n  pi.outer_measure (λ a, (μ a).to_outer_measure) P :=\nbegin\n  intro h,\n  simp [pi.measure],\n  rw measure_theory.to_measure_apply,\n  apply h,\nend\n\nlemma measurable_set.pi'' {α:Type*} [F:fintype α] {β:α → Type*} [M:∀ a, measurable_space (β a)]\n  {P:Π a, set (β a)}:(∀ a, measurable_set (P a)) →\n  measurable_set (set.pi set.univ P) := begin\n  intros A0,\n  have A1:(set.pi set.univ P) = ⋂ a, ((λ (p:Π a, β a), p a) ⁻¹' (P a)),\n  { ext x, simp,  },\n  rw A1,\n  have A3:trunc (encodable α) := encodable.trunc_encodable_of_fintype α,\n  trunc_cases A3,\n  haveI:encodable α := A3,\n  apply measurable_set.Inter,\n  intros a',\n  have A2:measurable_space.comap (λ (p:Π a, β a), p a') (M a') ≤ measurable_space.pi,\n  { simp [measurable_space.pi], apply @le_supr (measurable_space (Π a, β a)) _ _ _ (a') },\n  apply A2,\n  simp [measurable_space.comap],\n  apply exists.intro (P a'),\n  simp,\n  apply A0 a',\nend\n \n\nlemma pi.measure.apply_prod\n{α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} [M:∀ a, measurable_space (β a)] \n  (μ:Π a, measure_theory.measure (β a)) {P:Π a, set (β a)}:(∀ a, measurable_set (P a)) →\n  pi.measure μ (set.pi set.univ P) =\n  finset.univ.prod (λ a, μ a (P a)) :=\nbegin\n  intros A1,\n  rw pi.measure_apply,\n  apply le_antisymm,\n  { apply pi.outer_measure.apply_prod_le },\n  apply pi.outer_measure.le_apply_prod,\n  apply A1,\n  apply measurable_set.pi'' A1,\nend\n\nend pi\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/finite_pi_measure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4703032981235909}}
{"text": "import data.bool.misc\nimport data.list.misc\nimport logic.misc\nimport logic.finite\nimport tactic.unirewrite\nimport .basic .hom .bool\n\nnamespace binary_module\n\nopen binary_module\n\nlocal attribute [instance] binary_abelian\n\n@[reducible]\nprotected\ndefinition has_finite_support (α : Type _) [decidable_eq α] (φ : Type _) [decidable_eq φ] [model binary_module φ] : inv_pred binary_module (α → φ) :=\n{\n  p := λ f, is_finite {x // f x ≠ 0},\n  hinv :=\n    begin\n      intros n μ fs hall,\n      cases μ,\n      case ops.zero {\n        cases fs,\n        apply is_finite.of_empty,\n        intros x,\n        exact not_not_intro rfl\n      },\n      case ops.add {\n        cases fs with _ f fs; cases fs with _ g gs; cases gs,\n        dsimp [vect.is_all] at hall,\n        let hfin := hall.left.of_union hall.right.left,\n        let hfin' := hfin.of_subrestrict (λ x, f x + g x ≠ 0),\n        dsimp at hfin',\n        refine is_finite.of_iff _ hfin',\n        intros x,\n        have : @premodel.act binary_module _ _ _ ops.add ⁅f,g⁆ x = f x + g x,\n          by refl,\n        rw [this],\n        split,\n        exact and.right,\n        intros hfgx,\n        split; try { assumption },\n        refine dite (f x = 0) _ _,\n        show f x = 0 → _, {\n          intros hfx,\n          rw [hfx, _root_.zero_add] at hfgx,\n          exact or.inr hfgx\n        },\n        show f x ≠ 0 → _, {\n          exact or.inl\n        }\n      }\n    end\n}\n\n@[reducible]\ndefinition finsupp_fun (α : Type _) [decidable_eq α] (φ : Type _) [decidable_eq φ] [model binary_module φ] :=\n  submodel binary_module (binary_module.has_finite_support α φ)\n\n@[reducible,inline]\ndefinition finsupp_bits (α : Type _) [decidable_eq α] :=\n  finsupp_fun α bool\n\n@[reducible]\ndefinition singlebit {α : Type _} [decidable_eq α] : α → finsupp_bits α :=\n  λ a, subtype.mk (λ x, to_bool (a=x)) $\n    begin\n      dunfold binary_module.has_finite_support,\n      dsimp *,\n      apply is_finite.of_exhaustive_list,\n      have ha : to_bool (a = a) ≠ 0,\n        by rw [to_bool_tt rfl]; intro h; exact bool.ff_ne_tt h.symm,\n      refine subtype.mk [⟨a,ha⟩] ⟨list.nodup.nil.cons (list.not_mem_nil _), _⟩,\n      intros x,\n      refine dite (a = x.val) _ _,\n      show a = x.val → _, {\n        intros hax,\n        exact or.inl (subtype.eq hax.symm)\n      },\n      show a ≠ x.val → _, {\n        intros hax,\n        have : ff ≠ 0,\n          by let h := x.property; rw [to_bool_ff hax] at h; exact h,\n        exact false.elim (this rfl)\n      }\n    end\n\n--- `singlebit a` classifies `a`.\nlemma singlebit_nonzero_iff {α : Type _} [decidable_eq α] {a : α} : ∀ x, (singlebit a).val x ≠ 0 ↔ x = a :=\n  λ x, iff.intro\n    (λ h,\n      begin\n        dsimp [singlebit] at h,\n        by_cases hax: a=x,\n        exact hax.symm,\n        rw [to_bool_ff hax] at h,\n        injection ((neq_ff_iff ff).mp h),\n      end\n    )\n    (λ hxa h,\n      begin\n        dsimp [singlebit] at h;\n        rw [to_bool_tt hxa.symm] at h;\n        injection h\n      end\n    )\n\n--- Support of `singlebit a` consists of only `a`.\nlemma singlebit_support {α : Type _} [decidable_eq α] {a : α} : ∀ (l : exhaustive_list {x // (singlebit a).val x ≠ 0}), l.underlying = [a] :=\n  begin\n    intros l,\n    calc\n      l.underlying\n          = (l.of_iff singlebit_nonzero_iff).underlying\n            : (l.of_iff_underlying _).symm\n      ... = (exhaustive_list.singleton a).underlying\n            : by rw [(l.of_iff singlebit_nonzero_iff).singleton_unique]\n      ... = [a] : rfl\n  end\n\n--- If `a` lies in the support of `w : finsupp_bits α`, then the support of `w + singlebit a` is exactly the support of `w` minus `a`.\nlemma support_of_add_singlebit_of_nonzero {α : Type _} [decidable_eq α] {w : finsupp_bits α} {a : α} : w.val a ≠ 0 → ∀ (l : exhaustive_list {x // w.val x ≠ 0}) (la : exhaustive_list {x // w.val x + (singlebit a).val x ≠ 0}), list.perm l.underlying (a :: la.underlying) :=\n  begin\n    intros hwa l la,\n    dsimp [singlebit] at la,\n    have ha : a ∉ la.underlying, {\n      intros h,\n      let h' := (la.underlying_mem_iff a).mpr h,\n      rw [(neq_ff_iff _).mp hwa, to_bool_tt rfl] at h',\n      exact h' rfl\n    },\n    apply list.nodup_perm_of_mem\n      l.underlying_nodup\n      (list.nodup.cons ha la.underlying_nodup),\n    intros x,\n    split,\n    show x ∈ l.underlying → _, {\n      intros hx,\n      by_cases hxa: a = x; try { exact or.inl hxa.symm },\n      right,\n      apply (la.underlying_mem_iff x).mp,\n      apply (neq_ff_iff _).mpr,\n      have : w.val x = tt,\n        from (neq_ff_iff _).mp ((l.underlying_mem_iff x).mpr hx),\n      rw [this, to_bool_ff hxa],\n      refl\n    },\n    show x ∈ a :: la.underlying → _, {\n      refine implies.trans _ (l.underlying_mem_iff x).mp,\n      intros hx; cases hx,\n      case or.inl { rw [hx]; exact hwa },\n      case or.inr {\n        have hax: a ≠ x,\n          from (λ h, ha (by rw [←h] at hx; exact hx)),\n        let hwxa := (la.underlying_mem_iff x).mpr hx,\n        rw [to_bool_ff hax] at hwxa,\n        intros h,\n        rw [h] at hwxa,\n        exact hwxa rfl\n      }\n    }\n  end\n\n--- The functional relation that represents the accumuration of a `binary_module`-valued function with boolean weights.\ndefinition waccum_funrel {α : Type _} [decidable_eq α] {φ : Type _} [model binary_module φ] (f : α → φ) : finsupp_bits α ⇒ φ :=\n{\n  p := λ w y, ∀ (l : exhaustive_list {a // w.val a ≠ 0}), accum f l.underlying = y,\n  huniq :=\n    begin\n      intros w; cases w,\n      dunfold binary_module.has_finite_support at w_property,\n      dsimp * at w_property,\n      cases @is_finite.has_exhaustive_list _ w_property with l,\n      existsi accum f l.underlying,\n      dsimp *,\n      split,\n      show ∀ (l' : exhaustive_list _), accum f l'.underlying = accum f l.underlying, {\n        intros l',\n        exact accum_perm (l'.underlying_perm l)\n      },\n      show ∀ y h, y = _, {\n        intros y h; rw [h]\n      }\n    end\n}\n\n--- `waccum` with zero weight equals zero.\nlemma waccum_funrel_zero {α : Type _} [decidable_eq α] {φ : Type _} [model binary_module φ] (f : α → φ) : (waccum_funrel f).p (binary_module.zero _) 0 :=\n  begin\n    dsimp [waccum_funrel],\n    intros l,\n    suffices : l.underlying = [], {\n      rw [this]; exact accum_nil\n    },\n    refine l.of_empty_underlying _,\n    intros x,\n    apply not_not_intro,\n    refl\n  end\n\n--- `waccum` is just an evaluation on `singlebit`.\nlemma waccum_funrel_single {α : Type _} [decidable_eq α] {φ : Type _} [model binary_module φ] (f : α → φ) : ∀ (a : α), (waccum_funrel f).p (singlebit a) (f a) :=\n  begin\n    intros a,\n    dsimp [waccum_funrel],\n    intros l,\n    rw [singlebit_support],\n    dsimp [accum],\n    rw [add_zero]\n  end\n\n--- `waccum` respects the addition of weights.\nlemma waccum_funrel_add {α : Type _} [decidable_eq α] {φ : Type _} [model binary_module φ] (f : α → φ) : ∀ (v w : finsupp_bits α) (y z : φ), (waccum_funrel f).p v y → (waccum_funrel f).p w z → (waccum_funrel f).p (binary_module.add v w) (y+z) :=\n  begin\n    dsimp [waccum_funrel],\n    intros v w y z hvy hwz l,\n    have : ∀ a, (binary_module.add v w).val a ≠ 0 ↔ (v.val a ≠ 0 ∧ ¬w.val a ≠ 0) ∨ (¬v.val a ≠ 0 ∧ w.val a ≠ 0), {\n      intros a,\n      dsimp [binary_module.add, premodel.act],\n      dsimp [vect.unzip_fam, vect.map, vect.foldl],\n      rw [ff_bxor_safe],\n      calc\n        bxor (v.val a) (w.val a) ≠ 0\n            ↔ bxor (v.val a) (w.val a) = tt : neq_ff_iff _\n        ... ↔ v.val a ≠ w.val a : bxor_eq_tt_iff _ _\n        ... ↔ (v.val a = tt ∧ w.val a = 0) ∨ (v.val a = 0 ∧ w.val a = tt)\n            : bool.neq_iff (v.val a) (w.val a)\n        ... ↔ (v.val a ≠ 0 ∧ ¬w.val a ≠ 0) ∨ (¬v.val a ≠ 0 ∧ w.val a ≠ ff)\n            : or_congr\n              (and_congr (neq_ff_iff _) (@decidable.not_not_iff (w.val a=0) (bool.decidable_eq _ _))).symm\n              (and_congr (@decidable.not_not_iff (v.val a=0) (bool.decidable_eq _ _)) (neq_ff_iff _)).symm\n    },\n    let suppvw := l.of_iff this,\n    cases @is_finite.has_exhaustive_list {x // v.val x ≠ 0} v.property with suppv,\n    cases @is_finite.has_exhaustive_list {x // w.val x ≠ 0} w.property with suppw,\n    specialize hvy suppv,\n    specialize hwz suppw,\n    rw [accum_partition (λ x, w.val x ≠ 0)] at hvy,\n    rw [accum_partition (λ x, v.val x ≠ 0)] at hwz,\n    rw [←suppv.subrestrict_underlying (λ x, w.val x≠ 0)] at hvy,\n    rw [←suppv.subrestrict_underlying (λ x, ¬w.val x≠ 0)] at hvy,\n    rw [←suppw.subrestrict_underlying (λ x, v.val x≠ 0)] at hwz,\n    rw [←suppw.subrestrict_underlying (λ x, ¬v.val x≠ 0)] at hwz,\n    let suppv_only := suppv.subrestrict (λ x, ¬w.val x≠0),\n    let suppv_w := suppv.subrestrict (λ x, w.val x≠0),\n    unirewrite suppv.subrestrict (λ x, ¬w.val x≠0) with suppv_only at hvy,\n    unirewrite suppv.subrestrict (λ x, w.val x≠0) with suppv_w at hvy,\n    let suppw_only := suppw.subrestrict (λ x, ¬v.val x≠0),\n    let suppw_v := suppw.subrestrict (λ x, v.val x≠0),\n    unirewrite suppw.subrestrict (λ x, ¬v.val x≠0) with suppw_only at hwz,\n    unirewrite suppw.subrestrict (λ x, v.val x≠0) with suppw_v at hwz,\n    dsimp only [] at hvy hwz,\n    let suppw_only' := suppw_only.of_iff (λ x, @and.comm (w.val x≠ 0) (¬v.val x≠ 0)),\n    rw [←suppw_only.of_iff_underlying _] at hwz,\n    unirewrite (suppw_only.of_iff _) with suppw_only' at hwz,\n    have : list.perm suppv_w.underlying suppw_v.underlying, {\n      rw [←suppw_v.of_iff_underlying (λ x, @and.comm (w.val x≠0) (v.val x≠0))],\n      exact suppv_w.underlying_perm _\n    },\n    symmetry,\n    calc\n      y+z = (accum f suppv_w.underlying + accum f suppv_only.underlying)\n            + (accum f suppw_v.underlying + accum f suppw_only'.underlying)\n            : by rw [←hvy,←hwz]\n      ... = (accum f suppv_w.underlying + accum f suppv_only.underlying)\n            + (accum f suppv_w.underlying + accum f suppw_only'.underlying)\n            : by rw [accum_perm this]\n      ... = (accum f suppv_w.underlying + accum f suppv_only.underlying)\n            + (-accum f suppv_w.underlying + accum f suppw_only'.underlying)\n            : rfl\n      ... = accum f suppv_only.underlying + accum f suppw_only'.underlying\n            : by rw [add_comm (accum f suppv_w.underlying) _];\n                 rw [add_assoc,←_root_.add_assoc (accum f suppv_w.underlying)];\n                 rw [add_neg (accum f suppv_w.underlying)];\n                 rw [zero_add]\n      ... = accum f (suppv_only.union suppw_only').underlying\n            : by rw [exhaustive_list.disjoint_union_underlying (λ x (h : (¬v.val x = 0 ∧ ¬¬w.val x = 0) ∧ ¬v.val x ≠ 0 ∧ w.val x ≠ 0), h.left.right h.right.right)];\n                 rw [←accum_append]\n      ... = accum f suppvw.underlying\n            : accum_perm (suppvw.underlying_perm (suppv_only.union (suppw_only.of_iff (λ x, @and.comm (w.val x≠ 0) (¬v.val x≠ 0))))).symm\n      ... = accum f l.underlying : congr_arg (accum f) (l.of_iff_underlying _)\n  --/\n  end\n\nnamespace unsafe\n\nopen funrel.unsafe\n\nlocal attribute [instance] model.unsafe.pi\n\nvariables {α : Type _} [decidable_eq α]\n\n--- `finsupp_bits` is non-zero precisely if it has at least one `tt` bit.\nlemma finsupp_bits.nonzero (w : finsupp_bits α) : w ≠ 0 → ∃ a, w.val a = tt :=\n  begin\n    intros hw,\n    cases @is_finite.has_exhaustive_list _ w.property with l,\n    cases hl: l.underlying with a tl,\n    case nil {\n      suffices : w = 0,\n        by exfalso; exact hw this,\n      unirewrite @has_zero.zero (finsupp_bits α) _ with binary_module.zero _,\n      dsimp [binary_module.zero],\n      apply subtype.eq,\n      funext,\n      dsimp [premodel.act],\n      dsimp [vect.map, vect.unzip_fam, vect.foldl],\n      cases (bool.decidable_eq (w.val x) ff),\n      case is_false {\n        exfalso,\n        have : x ∈ l.underlying,\n          from (l.underlying_mem_iff x).mp h,\n        rw [hl] at this,\n        exact list.not_mem_nil _ this\n      },\n      case is_true { exact h }\n    },\n    case cons {\n      existsi a,\n      apply (neq_ff_iff (w.val a)).mp,\n      have : a ∈ l.underlying,\n        by let h := list.mem_cons_self a tl; rw [←hl] at h; exact h,\n      exact (l.underlying_mem_iff a).mpr this\n    }\n  end\n\n-- Realization of the weighted accumuration `waccum_funrel` using `definite_description`.\nnoncomputable definition waccum {φ : Type _} [model binary_module φ] (f : α → φ) : finsupp_bits α → φ :=\n  reify (waccum_funrel f)\n\nnoncomputable definition waccum_hom {φ : Type _} [model binary_module φ] (f : α → φ) : hom (finsupp_bits α) φ :=\n  subtype.mk (waccum f) $\n    begin\n      intros _ μ as,\n      dunfold waccum,\n      cases μ,\n      case ops.zero {\n        cases as,\n        dunfold vect.map,\n        drefold binary_module.zero _,\n        rw [iff.mp (reify_eq (waccum_funrel f)) (waccum_funrel_zero f)],\n        refl\n      },\n      case ops.add {\n        cases as with _ v vs; cases vs with _ w ws; cases ws,\n        dunfold vect.map,\n        drefold binary_module.add _ _,\n        drefold binary_module.add _ _,\n        unirewrite binary_module.add v w with has_add.add v w,\n        let y := funrel.unsafe.reify (waccum_funrel f) v,\n        let z := funrel.unsafe.reify (waccum_funrel f) w,\n        unirewrite funrel.unsafe.reify (waccum_funrel f) v with y,\n        unirewrite funrel.unsafe.reify (waccum_funrel f) w with z,\n        have hvy : (waccum_funrel f).p v y,\n          from iff.mpr (reify_eq (waccum_funrel f)) rfl,\n        have hwz : (waccum_funrel f).p w z,\n          from iff.mpr (reify_eq (waccum_funrel f)) rfl,\n        apply iff.mp (reify_eq (waccum_funrel f)),\n        apply waccum_funrel_add f v w y z hvy hwz\n      }\n    end\n\n--- `waccum` is just the evaluation at `singlebit a`.\nlemma waccum_single {φ : Type _} [model binary_module φ] (f : α → φ) : ∀ (a : α), waccum f (singlebit a) = f a :=\n  begin\n    intros a,\n    apply iff.mp (reify_eq (waccum_funrel f)),\n    exact waccum_funrel_single f a\n  end\n\n---`finsupp_bits α` is free with basis `α` provided `decidable_eq α`.\ntheorem finsupp_bits_free {φ : Type _} [model binary_module φ] (f : α → φ) : ∃! (g : morphism binary_module (finsupp_bits α) φ), ∀ a, g.val (singlebit a) = f a :=\n  begin\n    existsi waccum_hom f,\n    dsimp [waccum_hom],\n    split,\n    show ∀ (a : α), _ = f a,\n      from waccum_single f,\n    show ∀ (g : morphism binary_module (finsupp_bits α) _), _, {\n      intros g hg,\n      apply subtype.eq; dsimp *,\n      apply funext,\n      suffices : ∀ (n : ℕ) (w : finsupp_bits α) (l : exhaustive_list {x // w.val x ≠ 0}), l.underlying.length = n → g.val w = waccum f w, {\n        intros w,\n        cases @is_finite.has_exhaustive_list _ w.property with l,\n        exact this l.underlying.length w l rfl,\n      },\n      intros n,\n      induction n with k h_ind,\n      case zero {\n        intros w l hl,\n        suffices : w = binary_module.zero _, {\n          repeat { rw [this] },\n          unirewrite waccum f with (waccum_hom f).val,\n          rw [g.property ops.zero, (waccum_hom f).property ops.zero],\n          dsimp [vect.map],\n          refl\n        },\n        apply subtype.eq,\n        funext,\n        dsimp [binary_module.zero, premodel.act],\n        dsimp [vect.map, vect.unzip_fam, vect.foldl],\n        cases bool.decidable_eq (w.val x) ff,\n        case is_true { exact h },\n        exfalso,\n        have hx : x ∈ l.underlying,\n          from (l.underlying_mem_iff x).mp h,\n        have : l.underlying = [],\n          from list.eq_nil_of_length_eq_zero hl,\n        rw [this] at hx,\n        exact list.not_mem_nil x hx\n      },\n      case succ {\n        intros w l hl_len,\n        cases hl: l.underlying with a tl,\n        case nil {\n          exfalso,\n          rw [hl] at hl_len,\n          exact nat.succ_ne_zero _ hl_len.symm\n        },\n        have ha : w.val a ≠ 0, {\n          apply (l.underlying_mem_iff a).mpr,\n          rw [hl]; exact list.mem_cons_self _ _\n        },\n        have hwa : g.val (w + singlebit a) = waccum f (w + singlebit a), {\n          cases @is_finite.has_exhaustive_list _ (w + singlebit a).property with la,\n          apply h_ind _ la,\n          apply nat.succ.inj,\n          refine eq.trans _ hl_len,\n          unirewrite nat.succ _ with _+1,\n          drefold list.length (a::la.underlying),\n          apply list.perm.length,\n          symmetry,\n          exact support_of_add_singlebit_of_nonzero ha l la,\n        },\n        calc\n          g.val w\n              = g.val (w + (singlebit a - singlebit a))\n                : by rw [sub_self, add_zero]\n          ... = g.val (w + (singlebit a + singlebit a))\n                : by refl\n          ... = g.val (w + singlebit a) + g.val (singlebit a)\n                : by rw [←add_assoc, morphism.respect_add g]\n          ... = waccum f (w + singlebit a) + f a\n                : by rw [hwa,hg]\n          ... = waccum f (w + singlebit a) + waccum f (singlebit a)\n                : by rw [waccum_single f a]\n          ... = waccum f (w + singlebit a + singlebit a)\n                : by unirewrite waccum f with (waccum_hom f).val;\n                     rw [←morphism.respect_add (waccum_hom f)]\n          ... = waccum f (w + (singlebit a + singlebit a))\n                : by rw [add_assoc]\n          ... = waccum f w\n                : by unirewrite @has_add.add (finsupp_bits α) _ (singlebit a) (singlebit a) with @has_sub.sub (finsupp_bits α) _ (singlebit a) (singlebit a);\n                     rw [sub_self, add_zero]\n      }\n    --/\n    }\n  end\n\n---`finsupp_bits α` is free with basis `α` provided `decidable_eq α`.\ntheorem finsupp_bits.is_free : is_free binary_module (@singlebit α _) :=\n  @finsupp_bits_free α _\n\nend unsafe\n\nend binary_module\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/algebra/binary_module/decfree.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.769080247656264, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.47020179943364115}}
{"text": "-- Copyright (c) 2017 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Stephen Morgan, Scott Morrison\n\nimport category_theory.functor_category\nimport category_theory.isomorphism\nimport tactic.interactive\n\nnamespace category_theory\n\nuniverses u₁ v₁ u₂ v₂ u₃ v₃ u₄ v₄\n\nsection\nvariables (C : Type u₁) [𝒞 : category.{u₁ v₁} C] (D : Type u₂) [𝒟 : category.{u₂ v₂} D]\ninclude 𝒞 𝒟\n\n/--\n`prod.category C D` gives the cartesian product of two categories.\n-/\ninstance prod : category.{(max u₁ u₂) (max v₁ v₂)} (C × D) :=\n{ hom     := λ X Y, ((X.1) ⟶ (Y.1)) × ((X.2) ⟶ (Y.2)),\n  id      := λ X, ⟨ 𝟙 (X.1), 𝟙 (X.2) ⟩,\n  comp    := λ _ _ _ f g, (f.1 ≫ g.1, f.2 ≫ g.2) }\n\n-- rfl lemmas for category.prod\n@[simp] lemma prod_id (X : C) (Y : D) : 𝟙 (X, Y) = (𝟙 X, 𝟙 Y) := rfl\n@[simp] lemma prod_comp {P Q R : C} {S T U : D} (f : (P, S) ⟶ (Q, T)) (g : (Q, T) ⟶ (R, U)) : f ≫ g = (f.1 ≫ g.1, f.2 ≫ g.2) := rfl\nend\n\nsection\nvariables (C : Type u₁) [𝒞 : category.{u₁ v₁} C] (D : Type u₁) [𝒟 : category.{u₁ v₁} D]\ninclude 𝒞 𝒟 \n/--\n`prod.category.uniform C D` is an additional instance specialised so both factors have the same universe levels. This helps typeclass resolution.\n-/\ninstance uniform_prod : category (C × D) := category_theory.prod C D\nend\n-- Next we define the natural functors into and out of product categories. For now this doesn't address the universal properties.\n\nnamespace prod\n\nvariables (C : Type u₁) [𝒞 : category.{u₁ v₁} C] (D : Type u₂) [𝒟 : category.{u₂ v₂} D]\ninclude 𝒞 𝒟\n\n/-- `inl C Z` is the functor `X ↦ (X, Z)`. -/\ndef inl (Z : D) : C ⥤ (C × D) :=\n{ obj      := λ X, (X, Z),\n  map'     := λ X Y f, (f, 𝟙 Z) }\n\n/-- `inr D Z` is the functor `X ↦ (Z, X)`. -/\ndef inr (Z : C) : D ⥤ (C × D) :=\n{ obj      := λ X, (Z, X),\n  map'     := λ X Y f, (𝟙 Z, f) }\n\n/-- `fst` is the functor `(X, Y) ↦ X`. -/\ndef fst : (C × D) ⥤ C :=\n{ obj      := λ X, X.1,\n  map'     := λ X Y f, f.1 }\n\n/-- `snd` is the functor `(X, Y) ↦ Y`. -/\ndef snd : (C × D) ⥤ D :=\n{ obj      := λ X, X.2,\n  map'     := λ X Y f, f.2 }\n\ndef swap : (C × D) ⥤ (D × C) :=\n{ obj := λ X, (X.2, X.1),\n  map' := λ _ _ f, (f.2, f.1) }\n\ndef symmetry : ((swap C D) ⋙ (swap D C)) ≅ (functor.id (C × D)) :=\n{ hom := { app := λ X, 𝟙 X, \n           naturality' := begin intros, erw [category.comp_id (C × D), category.id_comp (C × D)], dsimp [swap], simp, end },\n  inv := { app := λ X, 𝟙 X, \n           naturality' := begin intros, erw [category.comp_id (C × D), category.id_comp (C × D)], dsimp [swap], simp, end } }\n\nend prod\n\nsection\nvariables (C : Type u₁) [𝒞 : category.{u₁ v₁} C] (D : Type u₂) [𝒟 : category.{u₂ v₂} D]\ninclude 𝒞 𝒟 \n\n-- TODO, later this can be defined by uncurrying `functor.id (C ⥤ D)`\ndef evaluation : ((C ⥤ D) × C) ⥤ D := \n{ obj := λ p, p.1 p.2,\n  map' := λ x y f, (x.1.map f.2) ≫ (f.1 y.2),\n  map_comp' := begin \n                 intros X Y Z f g, cases g, cases f, cases Z, cases Y, cases X, dsimp at *, simp at *, \n                 erw [←nat_trans.vcomp_app, nat_trans.naturality, category.assoc, nat_trans.naturality] \n               end }\nend\n\nvariables {A : Type u₁} [𝒜 : category.{u₁ v₁} A] {B : Type u₂} [ℬ : category.{u₂ v₂} B] {C : Type u₃} [𝒞 : category.{u₃ v₃} C] {D : Type u₄} [𝒟 : category.{u₄ v₄} D]\ninclude 𝒜 ℬ 𝒞 𝒟\n\nnamespace functor\n/-- The cartesian product of two functors. -/\ndef prod (F : A ⥤ B) (G : C ⥤ D) : (A × C) ⥤ (B × D) :=\n{ obj  := λ X, (F X.1, G X.2),\n  map' := λ _ _ f, (F.map f.1, G.map f.2) }\n  \n/- Because of limitations in Lean 3's handling of notations, we do not setup a notation `F × G`. \n   You can use `F.prod G` as a \"poor man's infix\", or just write `functor.prod F G`. -/\n\n@[simp] lemma prod_obj  (F : A ⥤ B) (G : C ⥤ D) (a : A) (c : C) : (F.prod G) (a, c) = (F a, G c) := rfl\n@[simp] lemma prod_map  (F : A ⥤ B) (G : C ⥤ D) {a a' : A} {c c' : C} (f : (a, c) ⟶ (a', c')) : (F.prod G).map f = (F.map f.1, G.map f.2) := rfl\nend functor\n\nnamespace nat_trans\n\n/-- The cartesian product of two natural transformations. -/\ndef prod {F G : A ⥤ B} {H I : C ⥤ D} (α : F ⟹ G) (β : H ⟹ I) : F.prod H ⟹ G.prod I :=\n{ app         := λ X, (α X.1, β X.2),\n  naturality' := begin /- `obviously'` says: -/ intros, cases f, cases Y, cases X, dsimp at *, simp, split, rw naturality, rw naturality end }\n\n/- Again, it is inadvisable in Lean 3 to setup a notation `α × β`; use instead `α.prod β` or `nat_trans.prod α β`. -/\n\n@[simp] lemma prod_app  {F G : A ⥤ B} {H I : C ⥤ D} (α : F ⟹ G) (β : H ⟹ I) (a : A) (c : C) : (nat_trans.prod α β) (a, c) = (α a, β c) := rfl\nend nat_trans\n\nend category_theory", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/category_theory/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4702017929618353}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module data.prod.basic\n! leanprover-community/mathlib commit bd9851ca476957ea4549eb19b40e7b5ade9428cc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Init.Core\nimport Mathlib.Init.Data.Prod\nimport Mathlib.Init.Function\nimport Mathlib.Logic.Function.Basic\nimport Mathlib.Tactic.Inhabit\n\n/-!\n# Extra facts about `prod`\n\nThis file defines `prod.swap : α × β → β × α` and proves various simple lemmas about `prod`.\n-/\n\nvariable {α : Type _} {β : Type _} {γ : Type _} {δ : Type _}\n\n@[simp]\ntheorem Prod_map (f : α → γ) (g : β → δ) (p : α × β) : Prod.map f g p = (f p.1, g p.2) :=\n  rfl\n#align prod_map Prod_map\n\nnamespace Prod\n\n@[simp]\ntheorem «forall» {p : α × β → Prop} : (∀ x, p x) ↔ ∀ a b, p (a, b) :=\n  ⟨fun h a b ↦ h (a, b), fun h ⟨a, b⟩ ↦ h a b⟩\n#align prod.forall Prod.forall\n\n@[simp]\ntheorem «exists» {p : α × β → Prop} : (∃ x, p x) ↔ ∃ a b, p (a, b) :=\n  ⟨fun ⟨⟨a, b⟩, h⟩ ↦ ⟨a, b, h⟩, fun ⟨a, b, h⟩ ↦ ⟨⟨a, b⟩, h⟩⟩\n#align prod.exists Prod.exists\n\ntheorem forall' {p : α → β → Prop} : (∀ x : α × β, p x.1 x.2) ↔ ∀ a b, p a b :=\n  Prod.forall\n#align prod.forall' Prod.forall'\n\ntheorem exists' {p : α → β → Prop} : (∃ x : α × β, p x.1 x.2) ↔ ∃ a b, p a b :=\n  Prod.exists\n#align prod.exists' Prod.exists'\n\n@[simp]\ntheorem snd_comp_mk (x : α) : Prod.snd ∘ (Prod.mk x : β → α × β) = id :=\n  rfl\n#align prod.snd_comp_mk Prod.snd_comp_mk\n\n@[simp]\ntheorem fst_comp_mk (x : α) : Prod.fst ∘ (Prod.mk x : β → α × β) = Function.const β x :=\n  rfl\n#align prod.fst_comp_mk Prod.fst_comp_mk\n\n@[simp]\ntheorem map_mk (f : α → γ) (g : β → δ) (a : α) (b : β) : map f g (a, b) = (f a, g b) :=\n  rfl\n#align prod.map_mk Prod.map_mk\n\ntheorem map_fst (f : α → γ) (g : β → δ) (p : α × β) : (map f g p).1 = f p.1 :=\n  rfl\n#align prod.map_fst Prod.map_fst\n\ntheorem map_snd (f : α → γ) (g : β → δ) (p : α × β) : (map f g p).2 = g p.2 :=\n  rfl\n#align prod.map_snd Prod.map_snd\n\ntheorem map_fst' (f : α → γ) (g : β → δ) : Prod.fst ∘ map f g = f ∘ Prod.fst :=\n  funext <| map_fst f g\n#align prod.map_fst' Prod.map_fst'\n\ntheorem map_snd' (f : α → γ) (g : β → δ) : Prod.snd ∘ map f g = g ∘ Prod.snd :=\n  funext <| map_snd f g\n#align prod.map_snd' Prod.map_snd'\n\n/-- Composing a `Prod.map` with another `Prod.map` is equal to\na single `Prod.map` of composed functions.\n-/\ntheorem map_comp_map {ε ζ : Type _} (f : α → β) (f' : γ → δ) (g : β → ε) (g' : δ → ζ) :\n    Prod.map g g' ∘ Prod.map f f' = Prod.map (g ∘ f) (g' ∘ f') :=\n  rfl\n#align prod.map_comp_map Prod.map_comp_map\n\n/-- Composing a `Prod.map` with another `Prod.map` is equal to\na single `Prod.map` of composed functions, fully applied.\n-/\ntheorem map_map {ε ζ : Type _} (f : α → β) (f' : γ → δ) (g : β → ε) (g' : δ → ζ) (x : α × γ) :\n    Prod.map g g' (Prod.map f f' x) = Prod.map (g ∘ f) (g' ∘ f') x :=\n  rfl\n#align prod.map_map Prod.map_map\n\n-- Porting note: mathlib3 proof uses `by cc` for the mpr direction\n-- Porting note: `@[simp]` tag removed because auto-generated `mk.injEq` simplifies LHS\n-- @[simp]\ntheorem mk.inj_iff {a₁ a₂ : α} {b₁ b₂ : β} : (a₁, b₁) = (a₂, b₂) ↔ a₁ = a₂ ∧ b₁ = b₂ :=\n  Iff.of_eq (mk.injEq _ _ _ _)\n#align prod.mk.inj_iff Prod.mk.inj_iff\n\ntheorem mk.inj_left {α β : Type _} (a : α) : Function.Injective (Prod.mk a : β → α × β) := by\n  intro b₁ b₂ h\n  simpa only [true_and, Prod.mk.inj_iff, eq_self_iff_true] using h\n#align prod.mk.inj_left Prod.mk.inj_left\n\n\n\nlemma mk_inj_left : (a, b₁) = (a, b₂) ↔ b₁ = b₂ := (mk.inj_left _).eq_iff\nlemma mk_inj_right : (a₁, b) = (a₂, b) ↔ a₁ = a₂ := (mk.inj_right _).eq_iff\n#align prod.mk_inj_right Prod.mk_inj_right\n#align prod.mk_inj_left Prod.mk_inj_left\n\ntheorem ext_iff {p q : α × β} : p = q ↔ p.1 = q.1 ∧ p.2 = q.2 := by\n  rw [← @mk.eta _ _ p, ← @mk.eta _ _ q, mk.inj_iff]\n#align prod.ext_iff Prod.ext_iff\n\n@[ext]\ntheorem ext {α β} {p q : α × β} (h₁ : p.1 = q.1) (h₂ : p.2 = q.2) : p = q :=\n  ext_iff.2 ⟨h₁, h₂⟩\n#align prod.ext Prod.ext\n\ntheorem map_def {f : α → γ} {g : β → δ} : Prod.map f g = fun p : α × β ↦ (f p.1, g p.2) :=\n  funext fun p ↦ ext (map_fst f g p) (map_snd f g p)\n#align prod.map_def Prod.map_def\n\ntheorem id_prod : (fun p : α × β ↦ (p.1, p.2)) = id :=\n  rfl\n#align prod.id_prod Prod.id_prod\n\ntheorem map_id : Prod.map (@id α) (@id β) = id :=\n  id_prod\n#align prod.map_id Prod.map_id\n\ntheorem fst_surjective [h : Nonempty β] : Function.Surjective (@fst α β) :=\n  fun x ↦ h.elim fun y ↦ ⟨⟨x, y⟩, rfl⟩\n#align prod.fst_surjective Prod.fst_surjective\n\ntheorem snd_surjective [h : Nonempty α] : Function.Surjective (@snd α β) :=\n  fun y ↦ h.elim fun x ↦ ⟨⟨x, y⟩, rfl⟩\n#align prod.snd_surjective Prod.snd_surjective\n\ntheorem fst_injective [Subsingleton β] : Function.Injective (@fst α β) :=\n  fun _ _ h ↦ ext h (Subsingleton.elim _ _)\n#align prod.fst_injective Prod.fst_injective\n\ntheorem snd_injective [Subsingleton α] : Function.Injective (@snd α β) :=\n  fun _ _ h ↦ ext (Subsingleton.elim _ _) h\n#align prod.snd_injective Prod.snd_injective\n\n/-- Swap the factors of a product. `swap (a, b) = (b, a)` -/\ndef swap : α × β → β × α := fun p ↦ (p.2, p.1)\n#align prod.swap Prod.swap\n\n@[simp]\ntheorem swap_swap : ∀ x : α × β, swap (swap x) = x\n  | ⟨_, _⟩ => rfl\n#align prod.swap_swap Prod.swap_swap\n\n@[simp]\ntheorem fst_swap {p : α × β} : (swap p).1 = p.2 :=\n  rfl\n#align prod.fst_swap Prod.fst_swap\n\n@[simp]\ntheorem snd_swap {p : α × β} : (swap p).2 = p.1 :=\n  rfl\n#align prod.snd_swap Prod.snd_swap\n\n@[simp]\ntheorem swap_prod_mk {a : α} {b : β} : swap (a, b) = (b, a) :=\n  rfl\n#align prod.swap_prod_mk Prod.swap_prod_mk\n\n@[simp]\ntheorem swap_swap_eq : swap ∘ swap = @id (α × β) :=\n  funext swap_swap\n#align prod.swap_swap_eq Prod.swap_swap_eq\n\n@[simp]\ntheorem swap_leftInverse : Function.LeftInverse (@swap α β) swap :=\n  swap_swap\n#align prod.swap_left_inverse Prod.swap_leftInverse\n\n@[simp]\ntheorem swap_rightInverse : Function.RightInverse (@swap α β) swap :=\n  swap_swap\n#align prod.swap_right_inverse Prod.swap_rightInverse\n\ntheorem swap_injective : Function.Injective (@swap α β) :=\n  swap_leftInverse.injective\n#align prod.swap_injective Prod.swap_injective\n\ntheorem swap_surjective : Function.Surjective (@swap α β) :=\n  swap_leftInverse.surjective\n#align prod.swap_surjective Prod.swap_surjective\n\ntheorem swap_bijective : Function.Bijective (@swap α β) :=\n  ⟨swap_injective, swap_surjective⟩\n#align prod.swap_bijective Prod.swap_bijective\n\n@[simp]\ntheorem swap_inj {p q : α × β} : swap p = swap q ↔ p = q :=\n  swap_injective.eq_iff\n#align prod.swap_inj Prod.swap_inj\n\ntheorem eq_iff_fst_eq_snd_eq : ∀ {p q : α × β}, p = q ↔ p.1 = q.1 ∧ p.2 = q.2\n  | ⟨p₁, p₂⟩, ⟨q₁, q₂⟩ => by simp\n#align prod.eq_iff_fst_eq_snd_eq Prod.eq_iff_fst_eq_snd_eq\n\ntheorem fst_eq_iff : ∀ {p : α × β} {x : α}, p.1 = x ↔ p = (x, p.2)\n  | ⟨a, b⟩, x => by simp\n#align prod.fst_eq_iff Prod.fst_eq_iff\n\ntheorem snd_eq_iff : ∀ {p : α × β} {x : β}, p.2 = x ↔ p = (p.1, x)\n  | ⟨a, b⟩, x => by simp\n#align prod.snd_eq_iff Prod.snd_eq_iff\n\nvariable {r : α → α → Prop} {s : β → β → Prop} {x y : α × β}\n\ntheorem lex_def (r : α → α → Prop) (s : β → β → Prop) {p q : α × β} :\n    Prod.Lex r s p q ↔ r p.1 q.1 ∨ p.1 = q.1 ∧ s p.2 q.2 :=\n  ⟨fun h ↦ by cases h <;> simp [*], fun h ↦\n    match p, q, h with\n    | (a, b), (c, d), Or.inl h => Lex.left _ _ h\n    | (a, b), (c, d), Or.inr ⟨e, h⟩ => by subst e; exact Lex.right _ h⟩\n#align prod.lex_def Prod.lex_def\n\nlemma lex_iff : Prod.Lex r s x y ↔ r x.1 y.1 ∨ x.1 = y.1 ∧ s x.2 y.2 := lex_def _ _\n#align prod.lex_iff Prod.lex_iff\n\ninstance Lex.decidable [DecidableEq α]\n    (r : α → α → Prop) (s : β → β → Prop) [DecidableRel r] [DecidableRel s] :\n    DecidableRel (Prod.Lex r s) :=\n  fun _ _ ↦ decidable_of_decidable_of_iff (lex_def r s).symm\n\n@[refl]\ntheorem Lex.refl_left (r : α → α → Prop) (s : β → β → Prop) [IsRefl α r] : ∀ x, Prod.Lex r s x x\n  | (_, _) => Lex.left _ _ (refl _)\n#align prod.lex.refl_left Prod.Lex.refl_left\n\ninstance {r : α → α → Prop} {s : β → β → Prop} [IsRefl α r] : IsRefl (α × β) (Prod.Lex r s) :=\n  ⟨Lex.refl_left _ _⟩\n\n@[refl]\ntheorem Lex.refl_right (r : α → α → Prop) (s : β → β → Prop) [IsRefl β s] : ∀ x, Prod.Lex r s x x\n  | (_, _) => Lex.right _ (refl _)\n#align prod.lex.refl_right Prod.Lex.refl_right\n\ninstance {r : α → α → Prop} {s : β → β → Prop} [IsRefl β s] : IsRefl (α × β) (Prod.Lex r s) :=\n  ⟨Lex.refl_right _ _⟩\n\ninstance isIrrefl [IsIrrefl α r] [IsIrrefl β s] : IsIrrefl (α × β) (Prod.Lex r s) :=\n⟨by rintro ⟨i, a⟩ (⟨_, _, h⟩ | ⟨_, h⟩) <;> exact irrefl _ h⟩\n\n@[trans]\ntheorem Lex.trans {r : α → α → Prop} {s : β → β → Prop} [IsTrans α r] [IsTrans β s] :\n    ∀ {x y z : α × β}, Prod.Lex r s x y → Prod.Lex r s y z → Prod.Lex r s x z\n  | (_, _), (_, _), (_, _), left  _ _ hxy₁, left  _ _ hyz₁ => left  _ _ (_root_.trans hxy₁ hyz₁)\n  | (_, _), (_, _), (_, _), left  _ _ hxy₁, right _ _      => left  _ _ hxy₁\n  | (_, _), (_, _), (_, _), right _ _,      left  _ _ hyz₁ => left  _ _ hyz₁\n  | (_, _), (_, _), (_, _), right _ hxy₂,   right _ hyz₂   => right _ (_root_.trans hxy₂ hyz₂)\n#align prod.lex.trans Prod.Lex.trans\n\ninstance {r : α → α → Prop} {s : β → β → Prop} [IsTrans α r] [IsTrans β s] :\n  IsTrans (α × β) (Prod.Lex r s) :=\n  ⟨fun _ _ _ ↦ Lex.trans⟩\n\ninstance {r : α → α → Prop} {s : β → β → Prop} [IsStrictOrder α r] [IsAntisymm β s] :\n    IsAntisymm (α × β) (Prod.Lex r s) :=\n  ⟨fun x₁ x₂ h₁₂ h₂₁ ↦\n    match x₁, x₂, h₁₂, h₂₁ with\n    | (a, _), (_, _), .left  _ _ hr₁, .left  _ _ hr₂ => (irrefl a (_root_.trans hr₁ hr₂)).elim\n    | (_, _), (_, _), .left  _ _ hr₁, .right _ _     => (irrefl _ hr₁).elim\n    | (_, _), (_, _), .right _ _,     .left  _ _ hr₂ => (irrefl _ hr₂).elim\n    | (_, _), (_, _), .right _ hs₁,   .right _ hs₂   => antisymm hs₁ hs₂ ▸ rfl⟩\n\ninstance isTotal_left {r : α → α → Prop} {s : β → β → Prop} [IsTotal α r] :\n    IsTotal (α × β) (Prod.Lex r s) :=\n  ⟨fun ⟨a₁, _⟩ ⟨a₂, _⟩ ↦ (IsTotal.total a₁ a₂).imp (Lex.left _ _) (Lex.left _ _)⟩\n#align prod.is_total_left Prod.isTotal_left\n\ninstance isTotal_right {r : α → α → Prop} {s : β → β → Prop} [IsTrichotomous α r] [IsTotal β s] :\n    IsTotal (α × β) (Prod.Lex r s) :=\n  ⟨fun ⟨i, a⟩ ⟨j, b⟩ ↦ by\n    obtain hij | rfl | hji := trichotomous_of r i j\n    · exact Or.inl (.left _ _ hij)\n    · exact (total_of s a b).imp (.right _) (.right _)\n    · exact Or.inr (.left _ _ hji) ⟩\n#align prod.is_total_right Prod.isTotal_right\n\ninstance IsTrichotomous [IsTrichotomous α r] [IsTrichotomous β s] :\n  IsTrichotomous (α × β) (Prod.Lex r s) :=\n⟨fun ⟨i, a⟩ ⟨j, b⟩ ↦ by\n  obtain hij | rfl | hji := trichotomous_of r i j\n  { exact Or.inl (Lex.left _ _ hij) }\n  { exact (trichotomous_of (s) a b).imp3 (Lex.right _) (congr_arg _) (Lex.right _) }\n  { exact Or.inr (Or.inr $ Lex.left _ _ hji) }⟩\n\nend Prod\n\nopen Prod\n\nnamespace Function\n\nvariable {f : α → γ} {g : β → δ} {f₁ : α → β} {g₁ : γ → δ} {f₂ : β → α} {g₂ : δ → γ}\n\ntheorem Injective.Prod_map (hf : Injective f) (hg : Injective g) : Injective (map f g) :=\n  fun _ _ h ↦ ext (hf (ext_iff.1 h).1) (hg <| (ext_iff.1 h).2)\n#align function.injective.prod_map Function.Injective.Prod_map\n\ntheorem Surjective.Prod_map (hf : Surjective f) (hg : Surjective g) : Surjective (map f g) :=\n  fun p ↦\n  let ⟨x, hx⟩ := hf p.1\n  let ⟨y, hy⟩ := hg p.2\n  ⟨(x, y), Prod.ext hx hy⟩\n#align function.surjective.prod_map Function.Surjective.Prod_map\n\ntheorem Bijective.Prod_map (hf : Bijective f) (hg : Bijective g) : Bijective (map f g) :=\n  ⟨hf.1.Prod_map hg.1, hf.2.Prod_map hg.2⟩\n#align function.bijective.prod_map Function.Bijective.Prod_map\n\ntheorem LeftInverse.Prod_map (hf : LeftInverse f₁ f₂) (hg : LeftInverse g₁ g₂) :\n    LeftInverse (map f₁ g₁) (map f₂ g₂) :=\n  fun a ↦ by rw [Prod.map_map, hf.comp_eq_id, hg.comp_eq_id, map_id, id]\n#align function.left_inverse.prod_map Function.LeftInverse.Prod_map\n\ntheorem RightInverse.Prod_map :\n    RightInverse f₁ f₂ → RightInverse g₁ g₂ → RightInverse (map f₁ g₁) (map f₂ g₂) :=\n  LeftInverse.Prod_map\n#align function.right_inverse.prod_map Function.RightInverse.Prod_map\n\ntheorem Involutive.Prod_map {f : α → α} {g : β → β} :\n    Involutive f → Involutive g → Involutive (map f g) :=\n  LeftInverse.Prod_map\n#align function.involutive.prod_map Function.Involutive.Prod_map\n\nend Function\n\nnamespace Prod\n\nopen Function\n\n@[simp]\ntheorem map_injective [Nonempty α] [Nonempty β] {f : α → γ} {g : β → δ} :\n    Injective (map f g) ↔ Injective f ∧ Injective g :=\n  ⟨fun h =>\n    ⟨fun a₁ a₂ ha => by\n      inhabit β\n      injection\n        @h (a₁, default) (a₂, default) (congr_arg (fun c : γ => Prod.mk c (g default)) ha : _),\n      fun b₁ b₂ hb => by\n      inhabit α\n      injection @h (default, b₁) (default, b₂) (congr_arg (Prod.mk (f default)) hb : _)⟩,\n    fun h => h.1.Prod_map h.2⟩\n#align prod.map_injective Prod.map_injective\n\n@[simp]\ntheorem map_surjective [Nonempty γ] [Nonempty δ] {f : α → γ} {g : β → δ} :\n    Surjective (map f g) ↔ Surjective f ∧ Surjective g :=\n  ⟨fun h =>\n    ⟨fun c => by\n      inhabit δ\n      obtain ⟨⟨a, b⟩, h⟩ := h (c, default)\n      exact ⟨a, congr_arg Prod.fst h⟩,\n      fun d => by\n      inhabit γ\n      obtain ⟨⟨a, b⟩, h⟩ := h (default, d)\n      exact ⟨b, congr_arg Prod.snd h⟩⟩,\n    fun h => h.1.Prod_map h.2⟩\n#align prod.map_surjective Prod.map_surjective\n\n@[simp]\ntheorem map_bijective [Nonempty α] [Nonempty β] {f : α → γ} {g : β → δ} :\n    Bijective (map f g) ↔ Bijective f ∧ Bijective g := by\n  haveI := Nonempty.map f ‹_›\n  haveI := Nonempty.map g ‹_›\n  exact (map_injective.and map_surjective).trans (and_and_and_comm)\n#align prod.map_bijective Prod.map_bijective\n\n@[simp]\ntheorem map_leftInverse [Nonempty β] [Nonempty δ] {f₁ : α → β} {g₁ : γ → δ} {f₂ : β → α}\n    {g₂ : δ → γ} : LeftInverse (map f₁ g₁) (map f₂ g₂) ↔ LeftInverse f₁ f₂ ∧ LeftInverse g₁ g₂ :=\n  ⟨fun h =>\n    ⟨fun b => by\n      inhabit δ\n      exact congr_arg Prod.fst (h (b, default)),\n      fun d => by\n      inhabit β\n      exact congr_arg Prod.snd (h (default, d))⟩,\n    fun h => h.1.Prod_map h.2 ⟩\n#align prod.map_left_inverse Prod.map_leftInverse\n\n@[simp]\ntheorem map_rightInverse [Nonempty α] [Nonempty γ] {f₁ : α → β} {g₁ : γ → δ} {f₂ : β → α}\n    {g₂ : δ → γ} : RightInverse (map f₁ g₁) (map f₂ g₂) ↔ RightInverse f₁ f₂ ∧ RightInverse g₁ g₂ :=\n  map_leftInverse\n#align prod.map_right_inverse Prod.map_rightInverse\n\n@[simp]\ntheorem map_involutive [Nonempty α] [Nonempty β] {f : α → α} {g : β → β} :\n    Involutive (map f g) ↔ Involutive f ∧ Involutive g :=\n  map_leftInverse\n#align prod.map_involutive Prod.map_involutive\n\nend Prod\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Prod/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7690802317779601, "lm_q1q2_score": 0.47020178972593235}}
{"text": "/-\nCopyright (c) 2021 Ashvni Narayanan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ashvni Narayanan\n-/\nimport general_bernoulli_number.lim_even_character\nimport dirichlet_character.dvd_conductor_mul\n\n/-!\n# A convergence property regarding (ℤ/dp^n ℤ)ˣ\nThis file proves Proposition 7.11 in Introduction to Cyclotomic Fields, Washington. \nIt gives a convergence property relating to generalized Bernoulli numbers.\n\n# Main Theorems\n * `U` \n * `helper_U_3`\n\n## Tags\np-adic, L-function, Bernoulli measure, Dirichlet character\n-/\n\nopen_locale big_operators\nlocal attribute [instance] zmod.topological_space\n\nopen filter ind_fn dirichlet_character\nopen_locale topological_space\n\nopen_locale big_operators\n\nvariables {p : ℕ} [fact (nat.prime p)] {d : ℕ} [fact (0 < d)] {R : Type*} [normed_comm_ring R] (m : ℕ)\n(hd : d.gcd p = 1) (χ : dirichlet_character R (d*(p^m))) {c : ℕ} (hc : c.gcd p = 1)\n(hc' : c.gcd d = 1) (na : ∀ (n : ℕ) (f : ℕ → R),\n  ∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)\n(w : continuous_monoid_hom (units (zmod d) × units ℤ_[p]) R)\nvariables (p d R) [complete_space R] [char_zero R]\nopen continuous_map\n\nvariables [normed_algebra ℚ_[p] R] [fact (0 < m)]\nopen clopen_from\nvariable [fact (0 < d)]\n\nopen eventually_constant_seq clopen_from\n\n/-- The first sum in the proof of Theorem 12.2. -/\nnoncomputable def U_def [algebra ℚ R] [norm_one_class R] (n : ℕ) (k : ℕ) :=\n  ∑ (x : (zmod (d * p ^ k))ˣ),\n  ((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R^n)) x : R) *\n  ((((x : zmod (d * p^k))).val)^(n - 1) : R)) •\n  (algebra_map ℚ R) (int.fract (↑x / (↑d * ↑p ^ k)))\n-- Idea 1 : replacing k by m + k so we can remove (hk : m ≤ k)\n-- Idea 2 : Use `asso_dirichlet_character` instead to get rid of hk, since coercion on non-units\n-- can be anywhere\n\n-- not needed?\nlemma set.finite_of_finite_inter {α : Type*} (s : finset α) (t : set α) :\n  set.finite ((s : set α) ∩ t : set α) := set.finite.inter_of_left (finset.finite_to_set s) t\n\nlemma sum_units_eq {x : ℕ} (hx : 0 < x) (f : ℕ → R) :\n  ∑ (i : units (zmod (d * p^x))), f (i : zmod (d * p^x)).val =\n  ∑ i in set.finite.to_finset (set.finite_of_finite_inter (finset.range (d * p^x))\n  ({x | x.coprime d} ∩ {x | x.coprime p})), f i :=\nbegin\n  apply finset.sum_bij,\n  swap 5, { refine λ a ha, (a : zmod (d * p^x)).val, },\n  { intros a ha,\n    simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n      set.mem_set_of_eq],\n    refine ⟨zmod.val_lt _, _⟩,\n    set b := zmod.units_equiv_coprime a,\n    have := nat.coprime_mul_iff_right.1 b.2,\n    rw nat.coprime_pow_right_iff hx at this,\n    apply this, },\n  { intros a ha, refl, },\n  { intros a₁ a₂ ha₁ ha₂ h,\n    --haveI : fact (0 < d * p^x) := imp p d x,\n    rw units.ext_iff, rw zmod.val_injective _ h, },\n  { intros b hb,\n    simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n      set.mem_set_of_eq] at hb,\n    refine ⟨zmod.units_equiv_coprime.inv_fun ⟨b, (zmod.val_cast_of_lt hb.1).symm ▸\n      (nat.coprime.mul_right hb.2.1 (nat.coprime.pow_right _ hb.2.2)) ⟩, finset.mem_univ _, _⟩,\n    rw zmod.units_equiv_coprime,\n    simp only [zmod.coe_unit_of_coprime, zmod.nat_cast_val, zmod.cast_nat_cast'],\n    rw zmod.val_cast_of_lt hb.1, },\nend\n\nlemma helper_U_3' [algebra ℚ R] [norm_one_class R] {n : ℕ} (hn : 1 < n) (x : ℕ) :\n  ∑ (x_1 : ℕ) in finset.range (d * p ^ x), (1 / ↑(d * p ^ x : ℕ) : ℚ) •\n  ((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) (↑p * ↑x_1) *\n  (↑p ^ (n - 1) * ↑x_1 ^ n)) = ∑ y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x.succ)) ({x | ¬ x.coprime p})), ((asso_dirichlet_character\n  (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑y * ↑y ^ (n - 1)) •\n  (algebra_map ℚ R) (↑y / (↑d * ↑p ^ x.succ)) :=\nbegin\n  symmetry,\n  apply finset.sum_bij,\n  swap 5, { refine λ a ha, _,\n    simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n      set.mem_set_of_eq] at ha,\n    refine classical.some (nat.prime_dvd_of_not_coprime p ha.2), },\n  { intros a ha,\n    simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n      set.mem_set_of_eq] at ha,\n    simp only [finset.mem_range],\n    apply lt_of_mul_lt_mul_right', swap, { exact p, },\n    rw mul_assoc, rw ← pow_succ', rw mul_comm,\n    rw ← classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2), apply ha.1, },\n  { intros a ha,\n    have h1 : ∀ x : ℕ, ((d * p^x : ℕ) : ℚ) ≠ 0 := λ x, nat.cast_ne_zero.2 (nat.ne_zero_of_lt' 0),\n    simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n      set.mem_set_of_eq] at ha,\n    simp_rw [← nat.cast_pow, ← nat.cast_mul],\n    rw ← classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2),\n    rw ← mul_smul_comm, rw smul_eq_mul, rw mul_assoc, congr,\n    rw ← algebra_map_smul R, rw smul_eq_mul,\n    conv_rhs { congr, skip, congr, congr, skip, rw ← nat.succ_pred_eq_of_pos\n      (lt_trans zero_lt_one hn), rw pow_succ', },\n    rw ← mul_assoc (p ^ (n - 1)) _ _, rw nat.pred_eq_sub_one, rw ← mul_pow,\n    rw ← classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2), rw nat.cast_mul (a ^ (n - 1)) _,\n    rw mul_comm ((algebra_map ℚ R) (1 / ↑(d * p ^ x))) _,\n    rw mul_assoc, congr, rw ← map_nat_cast (algebra_map ℚ R), rw ← ring_hom.map_mul,\n    apply congr_arg, rw mul_one_div, rw div_eq_div_iff (h1 _) (h1 _), norm_cast,\n    rw mul_comm _ (d * p^x.succ),\n    conv_rhs { congr, congr, skip, rw nat.succ_eq_add_one x, rw pow_succ' p x, },\n    rw ← mul_assoc d _ _, rw mul_assoc (d * p^x) _ _,\n    rw ← classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2), rw mul_comm _ a,\n    { apply_instance, }, },\n  { intros a b ha hb h,\n    simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n      set.mem_set_of_eq] at ha,\n    simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n      set.mem_set_of_eq] at hb,\n    have h2 : p * (classical.some (nat.prime_dvd_of_not_coprime p ha.2)) =\n      p * (classical.some (nat.prime_dvd_of_not_coprime p hb.2)),\n    { congr, apply h, },\n    rw ← classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2) at h2,\n    rw ← classical.some_spec (nat.prime_dvd_of_not_coprime p hb.2) at h2, rw h2, },\n  { intros b hb, refine ⟨p * b, _, _⟩,\n    { simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n        set.mem_set_of_eq], split,\n      { rw mul_comm p, rw pow_succ', rw ← mul_assoc,\n        apply nat.mul_lt_mul (finset.mem_range.1 hb) le_rfl (nat.prime.pos (fact.out _)),\n        apply_instance, },\n      { rw nat.prime.not_coprime_iff_dvd, refine ⟨p, fact.out _, dvd_mul_right p b, dvd_rfl⟩, }, },\n    { apply nat.eq_of_mul_eq_mul_left (nat.prime.pos (fact.out _)) _,\n      { exact p, },\n      { apply_instance, },\n      { rw ← classical.some_spec (nat.prime_dvd_of_not_coprime p _), }, }, },\nend\n\nopen dirichlet_character\nvariable (hd)\n\nlemma helper_U_2' [no_zero_divisors R] [algebra ℚ R] [norm_one_class R] (n : ℕ) (hn : 1 < n)\n  (hχ : χ.is_even) (hp : 2 < p)\n  (na : ∀ (n : ℕ) (f : ℕ → R), ∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥) :\n  tendsto (λ x : ℕ, ∑ y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x.succ)) ({x | ¬ x.coprime p})), ((asso_dirichlet_character\n  (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑y * ↑y ^ (n - 1)) •\n  (algebra_map ℚ R) (↑y / (↑d * ↑p ^ x.succ)) ) at_top (nhds ((asso_dirichlet_character\n  (dirichlet_character.mul χ (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1)) *\n  (general_bernoulli_number (dirichlet_character.mul χ\n  (teichmuller_character_mod_p' p R^n)) n))) :=\nbegin\n  conv { congr, funext, rw ← helper_U_3' p d R m χ hn, },\n  apply (tendsto_congr _).1 (tendsto.const_mul ((asso_dirichlet_character\n    (dirichlet_character.mul χ (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1)))\n    (lim_even_character' p d R m χ hn hχ hp na)),\n  intro x, rw mul_smul_comm, rw finset.mul_sum, rw finset.smul_sum,\n  apply finset.sum_congr rfl,\n  intros x hx, rw monoid_hom.map_mul, rw div_smul_eq_div_smul p R, apply congr_arg, ring,\nend\n\nlemma helper_U_1' [no_zero_divisors R] [algebra ℚ R] [norm_one_class R] (n : ℕ) (hn : 1 < n)\n  (hχ : χ.is_even) (hp : 2 < p)\n  (na : ∀ (n : ℕ) (f : ℕ → R), ∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥) :\n  tendsto (λ x : ℕ, ∑ y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | ¬ x.coprime p})), ((asso_dirichlet_character\n  (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑y * ↑y ^ (n - 1)) •\n  (algebra_map ℚ R) (↑y / (↑d * ↑p ^ x)) ) at_top (nhds ((asso_dirichlet_character\n  (dirichlet_character.mul χ (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1) ) *\n  (general_bernoulli_number (dirichlet_character.mul χ\n  (teichmuller_character_mod_p' p R^n)) n))) :=\nbegin\n  have h1 := helper_U_2' p d R m χ n hn hχ hp na,\n  have h2 : tendsto nat.pred at_top at_top,\n  { rw tendsto_at_top, intro b, simp, refine ⟨b.succ, λ c hc, _⟩,\n    rw nat.pred_eq_sub_one,\n    apply (nat.add_le_to_le_sub _ _).1 _,\n    { apply le_trans (nat.one_le_iff_ne_zero.2 (nat.succ_ne_zero _)) hc, },\n    { apply hc, }, },\n  have h3 : function.comp (λ x : ℕ, ∑ y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x.succ)) ({x | ¬ x.coprime p})), ((asso_dirichlet_character\n  (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑y * ↑y ^ (n - 1)) •\n  (algebra_map ℚ R) (↑y / (↑d * ↑p ^ x.succ)) ) nat.pred =ᶠ[at_top] (λ x : ℕ, ∑ y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | ¬ x.coprime p})), ((asso_dirichlet_character\n  (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑y * ↑y ^ (n - 1)) •\n  (algebra_map ℚ R) (↑y / (↑d * ↑p ^ x)) ),\n  { rw eventually_eq, rw eventually_at_top,\n    refine ⟨1, λ x hx, _⟩, rw function.comp_apply,\n    rw nat.succ_pred_eq_of_pos (nat.succ_le_iff.1 hx), },\n  apply (tendsto_congr' h3).1 _, clear h3,\n  apply tendsto.comp h1 h2,\nend\n\nopen zmod\nlemma helper_U_2 [no_zero_divisors R] [algebra ℚ R] [norm_one_class R] (n : ℕ)\n  (hd : d.coprime p) (hχ : d ∣ χ.conductor) :\n  tendsto (λ x : ℕ, ∑ y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | ¬ x.coprime d})), ((asso_dirichlet_character\n  (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑y * ↑y ^ (n - 1)) •\n  (algebra_map ℚ R) (↑y / (↑d * ↑p ^ x))) at_top (nhds 0) :=\nbegin\n  apply (tendsto_congr _).2 (tendsto_const_nhds),\n  intro x,\n  apply finset.sum_eq_zero,\n  intros y hy,\n  rw smul_eq_mul,\n  rw mul_eq_zero, left,\n  rw mul_eq_zero, left,\n  simp only [set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe, finset.mem_range,\n    set.mem_set_of_eq] at hy,\n  cases hy with h1 h2,\n  rw asso_dirichlet_character_eq_zero,\n  contrapose h2, rw not_not at *, apply zmod.coprime_of_is_unit,\n  obtain ⟨k, hk⟩ := dvd_mul_of_dvd_conductor p d R m χ n hd hχ,\n  rw (is_primitive_def _).1 (is_primitive.mul _ _) at hk,\n  rw hk at h2,\n  apply is_unit_of_is_unit_mul y h2,\nend\n\nlemma helper_U_4 [algebra ℚ R] [no_zero_divisors R] (hd : d.coprime p) (hχ : d ∣ χ.conductor) (n x : ℕ) : ∑ (x_1 : ℕ) in (set.finite_of_finite_inter\n  (finset.range (d * p ^ x)) {x : ℕ | ¬x.coprime d}).to_finset ∩ (set.finite_of_finite_inter\n  (finset.range (d * p ^ x)) {x : ℕ | ¬x.coprime p}).to_finset,\n  ((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑x_1 *\n  ↑x_1 ^ (n - 1)) • (algebra_map ℚ R) (↑x_1 / (↑d * ↑p ^ x)) = 0 :=\nbegin\n  apply finset.sum_eq_zero, intros y hy,\n  simp only [finset.mem_inter, set.finite.mem_to_finset, set.mem_inter_eq, finset.mem_coe,\n    finset.mem_range, set.mem_set_of_eq] at hy,\n  convert zero_smul R _, rw mul_eq_zero, left,\n  rw asso_dirichlet_character_eq_zero,\n  cases hy with p1 p3,\n  cases p1 with p1 p2,\n  cases p3 with p3 p4,\n  contrapose p2, rw not_not at *, apply coprime_of_is_unit,\n  obtain ⟨k, hk⟩ := dvd_mul_of_dvd_conductor p d R m χ n hd hχ,\n  rw (is_primitive_def _).1 (is_primitive.mul _ _) at hk,\n  rw hk at p2,\n  apply is_unit_of_is_unit_mul y p2,\nend\n\nlemma helper_U_3 (x : ℕ) : finset.range (d * p^x) = set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | ¬ x.coprime d})) ∪ ((set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | ¬ x.coprime p}))) ∪ set.finite.to_finset (set.finite_of_finite_inter (finset.range (d * p^x))\n  ({x | x.coprime d} ∩ {x | x.coprime p}))) :=\nbegin\n  ext,\n  simp only [finset.mem_range, finset.mem_union, set.finite.mem_to_finset, set.mem_inter_eq,\n    finset.mem_coe, set.mem_set_of_eq],\n  split, -- better way to do this?\n  { intro h,\n    by_cases h' : a.coprime d ∧ a.coprime p, { right, right, refine ⟨h, h'⟩, },\n    { rw not_and_distrib at h', cases h',\n      { left, refine ⟨h, h'⟩, },\n      { right, left, refine ⟨h, h'⟩, }, }, },\n  { intro h, cases h, apply h.1,\n    cases h, apply h.1, apply h.1, },\nend\n\nopen zmod\nlemma U [algebra ℚ R] [norm_one_class R] [no_zero_divisors R] [is_scalar_tower ℚ ℚ_[p] R]\n  (hd : d.coprime p) (n : ℕ) (hn : 1 < n) (hχ : χ.is_even) (hχ' : d ∣ χ.conductor) (hp : 2 < p)\n  (na : ∀ (n : ℕ) (f : ℕ → R), ∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥) :\n  filter.tendsto (λ j : ℕ, U_def p d R m χ n j)\n  filter.at_top (nhds ((1 - asso_dirichlet_character (dirichlet_character.mul χ\n  (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1) ) *\n  (general_bernoulli_number (dirichlet_character.mul χ\n  (teichmuller_character_mod_p' p R^n)) n)) ) :=\nbegin\n  delta U_def,\n  convert (tendsto_congr' _).2 (filter.tendsto.sub (filter.tendsto.sub\n    (lim_even_character' p d R m χ hn hχ hp na) (helper_U_2 p d R m χ n hd hχ')) (helper_U_1' p d R m χ n hn hχ hp na)), -- might need a tendsto_congr' here\n  { rw sub_zero, rw ← one_sub_mul, },\n  { rw eventually_eq, rw eventually_at_top,\n    refine ⟨m, λ x hx, _⟩,\n    --simp only,\n    have h1 : d * p^m ∣ d * p^x := mul_dvd_mul_left d (pow_dvd_pow p hx),\n    rw finset.smul_sum,\n    conv_lhs { apply_congr, skip, rw coe_coe, rw coe_coe,\n      rw ← zmod.nat_cast_val (x_1 : zmod (d * p^x)),\n      rw ← zmod.nat_cast_val (x_1 : zmod (d * p^x)),\n      rw ← nat.cast_pow p, rw ← nat.cast_mul,\n      rw int.fract_eq_self.2 (@zero_le_div_and_div_lt_one (d * p^x) _ _), -- (zero_le_div_and_div_lt_one p d _ _).2,\n      rw nat.cast_mul, rw nat.cast_pow p,\n      /-conv { congr, rw ← dirichlet_character.mul_eq_mul R χ\n        (teichmuller_character_mod_p' p R ^ n) (zmod.is_unit_val_of_unit h1 x_1), }, -/ },\n    convert sum_units_eq p d R _ (λ (y : ℕ), ((asso_dirichlet_character\n      (χ.mul (teichmuller_character_mod_p' p R ^ n))) ↑y * ↑y ^ (n - 1)) •\n      (algebra_map ℚ R) (((y : ℚ) / (↑d * ↑p ^ x)))),\n    -- ext, congr,\n    rw sub_sub, rw ← finset.sum_union_inter, rw add_comm,\n    apply sub_eq_of_eq_add', rw add_assoc, rw ← finset.sum_union _,\n    rw helper_U_4 p d R m χ hd hχ', rw zero_add,\n--    apply sub_eq_of_eq_add', rw ← finset.sum_union _,\n    { apply finset.sum_congr,\n      { rw finset.union_assoc, rw ← helper_U_3, },\n      { intros y hy, rw ←algebra_map_smul R (1 / ↑(d * p ^ x : ℕ) : ℚ_[p]),\n        rw smul_eq_mul, rw smul_eq_mul,\n        { rw mul_comm, rw ← mul_one (y : ℚ), rw ← mul_div, rw ring_hom.map_mul, rw map_nat_cast,\n          rw ← mul_assoc, rw [nat.cast_mul d _, nat.cast_pow p], apply congr_arg2 _ _ _,\n          rw mul_assoc, apply congr_arg2 _ rfl _, rw ← pow_succ', rw nat.sub_add_cancel (le_of_lt hn),\n          rw is_scalar_tower.algebra_map_apply ℚ ℚ_[p] R,\n          simp_rw [← nat.cast_pow, ← nat.cast_mul],\n          apply congr_arg,\n          symmetry,\n          apply eq_one_div_of_mul_eq_one_left,\n          rw ←smul_eq_mul, rw algebra_map_smul,\n          rw one_div_smul_self _ (nat.ne_zero_of_lt' 0),\n          apply_instance, },\n        { apply_instance, }, }, },\n    { rw finset.disjoint_union_left, simp_rw finset.disjoint_iff_inter_eq_empty,\n      refine ⟨_, _⟩,\n      { ext,\n        simp only [finset.mem_inter, set.finite.mem_to_finset, set.mem_inter_eq,\n          finset.mem_coe, finset.mem_range, set.mem_set_of_eq, finset.not_mem_empty, iff_false,\n          not_and, and_imp],\n        intros p1 p2 p3 p4 p5,\n        apply p2 p4, },\n      { ext,\n        simp only [finset.mem_inter, set.finite.mem_to_finset, set.mem_inter_eq,\n          finset.mem_coe, finset.mem_range, set.mem_set_of_eq, finset.not_mem_empty, iff_false,\n          not_and, and_imp],\n        intros p1 p2 p3 p4 p5,\n        apply p2 p5, }, },\n    { apply lt_of_lt_of_le (fact.out _) hx, apply_instance, }, },\nend\n", "meta": {"author": "laughinggas", "repo": "p-adic-L-functions", "sha": "bfc0c84fabe9b89e3da79f95d7a8eacabe8a5bb7", "save_path": "github-repos/lean/laughinggas-p-adic-L-functions", "path": "github-repos/lean/laughinggas-p-adic-L-functions/p-adic-L-functions-bfc0c84fabe9b89e3da79f95d7a8eacabe8a5bb7/src/general_bernoulli_number/lim_even_character_of_units.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4702017864900293}}
{"text": "import M4R.Algebra.Ring.MaxPrimeIdeal\nimport M4R.Algebra.Ring.Prod\n\nnamespace M4R\n  open Monoid NCSemiring Semiring\n\n  namespace Ideal\n    variable [Ring α] (I : Ideal α)\n\n    protected def is_radical : Prop := ∀ (x : α) (n : Nat), n ≠ 0 → x^n ∈ I → x ∈ I\n\n    def radical : Ideal α where\n      subset     := {x | ∃ n : Nat, n ≠ 0 ∧ x^n ∈ I}\n      has_zero   := ⟨1, Nat.one_ne_zero, by rw [pow_nat_1]; exact I.has_zero⟩\n      add_closed := by\n        intro a b ⟨m, hm, ham⟩ ⟨n, hn, hbn⟩; exact ⟨m+n-1,\n          ⟨by\n            apply Nat.ge_one_iff_ne_zero.mp\n            apply Nat.le_of_succ_le_succ\n            rw [Nat.sub_one, Nat.succ_pred_eq_of_pos (Nat.add_zero 0 ▸\n              (Nat.add_lt_add (Nat.pos_iff_ne_zero.mpr hm) (Nat.pos_iff_ne_zero.mpr hn)))]\n            exact Nat.add_le_add (Nat.ge_one_iff_ne_zero.mpr hm) (Nat.ge_one_iff_ne_zero.mpr hn),\n          by\n            rw [Semiring.binomial, Finset.map_sum.antidiagonal_eq_range, Finset.range_eq_range',\n              Finset.map_sum.range'_split m (by\n                rw [Nat.sub_one, Nat.succ_pred_eq_of_pos (Nat.add_zero 0 ▸\n                  Nat.add_lt_add (Nat.pos_iff_ne_zero.mpr hm) (Nat.pos_iff_ne_zero.mpr hn))]\n                exact Nat.le_add_right m n)]\n            exact I.add_closed (Ideal.div_mem.mpr ⟨b^n, hbn,\n              Finset.map_sum.prop_sum _ _ _ (divides_zero _) (fun k hk =>\n                ⟨((m + n - 1).choose k) * a ^ k * b ^ (m - 1 - k), by\n                  rw [Semiring.mul_comm, NCSemiring.mul_assoc, ←NCSemiring.pow_nat_add_distrib]\n                  have : m - 1 - k + n = m + n - 1 - k := by\n                    rw [Nat.add_sub_comm (Nat.ge_one_iff_ne_zero.mpr hm), Nat.add_sub_comm (by\n                      apply Nat.lt_succ_if_le.mp\n                      rw [Nat.sub_one, Nat.succ_pred_eq_of_pos (Nat.pos_iff_ne_zero.mpr hm), ←Nat.zero_add m]\n                      exact (Finset.range'.mem_range'.mp hk).right)]\n                  rw [this]⟩) (@divides_add _ _ (b^n))⟩)\n              (Ideal.div_mem.mpr ⟨a^m, ham,\n              Finset.map_sum.prop_sum _ _ _ (divides_zero _) (fun k hk =>\n                ⟨((m + n - 1).choose k) * a ^ (k - m) * b ^ (m + n - 1 - k), by\n                  rw [Semiring.mul_comm, NCSemiring.mul_assoc, Semiring.mul_comm _ (a^m),\n                    NCSemiring.mul_assoc, ←NCSemiring.mul_assoc (a^_),\n                    ←NCSemiring.pow_nat_add_distrib, ←NCSemiring.mul_assoc,\n                    Nat.sub_add_cancel (Nat.zero_add m ▸ (Finset.range'.mem_range'.mp hk).left)]⟩)\n                  (@divides_add _ _ (a^m))⟩)⟩⟩\n      mul_closed := fun a b ⟨m, ⟨hm, hbm⟩⟩ => ⟨m, ⟨hm, by rw [pow_nat_mul_distrib]; exact I.mul_closed (a^m) hbm⟩⟩\n\n    namespace radical\n      protected theorem is_radical : I.radical.is_radical :=\n        fun x n hn ⟨m, hm, hx⟩ => ⟨n * m, (Nat.mul_neq_zero _ _).mpr ⟨hn, hm⟩,\n          by rw [←pow_nat_comp]; exact hx⟩\n\n      protected theorem sub_self : I ⊆ I.radical := fun x hx =>\n        ⟨1, Nat.one_ne_zero, NCSemiring.pow_nat_1 x ▸ hx⟩\n\n      theorem subset {I J : Ideal α} (h : I ⊆ J) : I.radical ⊆ J.radical :=\n        fun x ⟨n, hn0, hxn⟩ => ⟨n, hn0, h hxn⟩\n\n      protected theorem of_unit (α) [Ring α] : (1 : Ideal α).radical = 1 :=\n        unit_ideal_in (radical.sub_self 1)\n\n      protected theorem repeat : I.radical.radical = I.radical :=\n        Ideal.ext'.mpr fun x => ⟨fun ⟨n, hn, m, hm, hxm⟩ => ⟨n * m, (Nat.mul_neq_zero n m).mpr ⟨hn, hm⟩,\n          pow_nat_comp x n m ▸ hxm⟩, (radical.sub_self _ ·)⟩\n\n      protected theorem add (J : Ideal α) : (I + J).radical = (I.radical + J.radical).radical :=\n        Ideal.ext'.mpr fun x => ⟨fun ⟨n, hn, i, hi, j, hj, hij⟩ => ⟨n, hn, i, radical.sub_self I hi, j,\n          radical.sub_self J hj, hij⟩, fun ⟨n, hn, i, hi, j, hj, hij⟩ => radical.repeat _ ▸ ⟨n, hn, hij ▸\n            (I + J).radical.add_closed (radical.subset (Ideal.add.subset I J) hi) (radical.subset (Ideal.add.subset' I J) hj)⟩⟩\n\n      protected theorem eq_unit_ideal_iff {I : Ideal α} : I.radical = 1 ↔ I = 1 :=\n        ⟨fun h => let ⟨n, hn, h1n⟩ := is_unit_ideal.mp h; is_unit_ideal.mpr (pow_nat_one n ▸ h1n),\n          (· ▸ radical.of_unit α)⟩\n\n      protected theorem proper_iff {I : Ideal α} : I.radical.proper_ideal ↔ I.proper_ideal :=\n        not_iff_not.mpr radical.eq_unit_ideal_iff\n\n      protected theorem add_eq_one {I J : Ideal α} (h : I.radical + J.radical = 1) : I + J = 1 := by\n        have := congrArg Ideal.radical h\n        rw [←radical.add, radical.of_unit] at this\n        exact radical.eq_unit_ideal_iff.mp this\n    end radical\n\n    protected theorem is_radical.eq_rad {I : Ideal α} (hI : I.is_radical) : I.radical = I :=\n      Ideal.antisymm (fun x hx => let ⟨n, hn0, hxn⟩ := hx; hI x n hn0 hxn) (radical.sub_self I)\n\n    theorem prime_radical {P : Ideal α} (hP : P.is_prime) : P.is_radical := fun x n hn hxn => by\n      induction n with\n      | zero   => contradiction\n      | succ n ih =>\n        byCases hn' : n = 0\n        { rw [hn', pow_nat_1] at hxn; exact hxn }\n        { exact Or.elim (hP.right (x^n) x (pow_nat_succ x n ▸ hxn)) (ih hn') id }\n\n    def is_primary : Prop := I.proper_ideal ∧ ∀ a b : α, a * b ∈ I → a ∈ I ∨ b ∈ I.radical\n\n    theorem is_primary_of_prime {I : Ideal α} (hI : I.is_prime) : I.is_primary :=\n      And.imp_right (fun h a b hab => Or.imp_right (Ideal.radical.sub_self I ·) (h a b hab)) hI\n\n    theorem is_primary_of_radical_maximal {I : Ideal α} (h : I.radical.is_maximal) : I.is_primary :=\n      ⟨Ideal.proper_ideal_subset (radical.sub_self I) h.left, fun a b hab => by\n        apply or_iff_not_imp_right.mpr; intro hb\n        have := (h.right (Ideal.add.subset I.radical (principal b))).resolve_left\n          fun h => hb (h ▸ Ideal.add.subset' _ _ (generator_in_principal b))\n        have : I.radical + (principal b).radical = 1 :=\n          unit_ideal_in (this ▸ Ideal.add.subset_add_subset (Subset.refl _) (radical.sub_self _))\n        let ⟨i, hi, j, ⟨k, hk⟩, hij⟩ := is_unit_ideal.mp (radical.add_eq_one this)\n        rw [←mul_one a, ←hij, ←hk, mul_distrib_left, ←mul_assoc]\n        exact I.add_closed (I.mul_closed a hi) (I.mul_closed' hab k)⟩\n\n    theorem contraction_radical [Ring β] (f : α →ᵣ₁ β) (I : Ideal β) : contractionᵣ₁ f I.radical = (contractionᵣ₁ f I).radical :=\n      Ideal.ext'.mpr fun x => ⟨fun ⟨n, hn, hnx⟩ => ⟨n, hn, by rw [←f.preserve_pow x n] at hnx; exact hnx⟩,\n        fun ⟨n, hn, hnx⟩ => ⟨n, hn, f.preserve_pow x n ▸ hnx⟩⟩\n\n    theorem contraction_is_primary [Ring β] (f : α →ᵣ₁ β) {I : Ideal β} (hI : I.is_primary) : (contractionᵣ₁ f I).is_primary :=\n      ⟨contraction.proper_of_preserve_one f.preserve_mul_right f.preserve_one hI.left, fun a b hab =>\n        (hI.right (f a) (f b) (f.preserve_mul a b ▸ hab)).imp_right (fun h => contraction_radical f I ▸ h)⟩\n\n    theorem radical_prime_of_primary {I : Ideal α} (hI : I.is_primary) : I.radical.is_prime :=\n      ⟨radical.proper_iff.mpr hI.left, fun a b ⟨n, hn, habn⟩ => or_iff_not_imp_left.mpr fun ha =>\n        radical.is_radical I b n hn ((hI.right (a ^ n) (b ^ n) (pow_nat_mul_distrib a b n\n          ▸ habn)).resolve_left (fun ha' => ha (radical.is_radical I a n hn (radical.sub_self I ha'))))⟩\n\n    theorem radical_minimal_prime_of_primary {I : Ideal α} (hI : I.is_primary) : I.radical.minimal_prime_ideal_of I :=\n      ⟨radical_prime_of_primary hI, radical.sub_self I, fun hJ hIJ hJI => Ideal.antisymm hJI (is_radical.eq_rad (prime_radical hJ) ▸ radical.subset hIJ)⟩\n\n    theorem radical_pow_of_prime {P : Ideal α} (hP : P.is_prime) (n : Nat) (hn : n ≠ 0) : (P ^ n).radical = P :=\n      Ideal.antisymm (fun x ⟨k, hk, hkx⟩ => prime_radical hP x k hk (product.pow_subset P n hn hkx)) (fun x hx => ⟨n, hn, product.pow_contains n hx⟩)\n\n\n  end Ideal\n\n  namespace Ring\n    open QuotientRing\n    variable (α : Type _) [Ring α]\n\n    def nil_radical : Ideal α := (0 : Ideal α).radical\n\n    protected theorem nil_radical.def : (0 : Ideal α).radical = nil_radical α := rfl\n\n    def is_reduced : Prop := nil_radical α = 0\n\n    abbrev reduced := QClass (nil_radical α)\n\n    theorem reduced_reduced : is_reduced (reduced α) :=\n      Ideal.is_zero_ideal.mpr fun a ⟨n, hn0, han⟩ =>\n        @Quotient.ind α (QSetoid _) (fun (x : QClass _) => x^n = 0 → x = 0) (fun x (hxn : toQuotient _ _ ^ n = 0) =>\n          let ⟨m, hm0, hxnm⟩ : x^n ∈ nil_radical α := is_zero.mp (preserve_pow_nat _ x n ▸ hxn)\n          is_zero.mpr ⟨n * m, (Nat.mul_neq_zero n m).mpr ⟨hn0, hm0⟩, pow_nat_comp x n m ▸ hxnm⟩) a han\n\n    noncomputable def jacobson_radical : Ideal α := ⋂₀ Ring.MaxSpec α\n\n    variable {α}\n\n    theorem nil_radical_proper (h : Ring.is_NonTrivial α) : (nil_radical α).proper_ideal :=\n      fun h' => let ⟨n, hn, h1n⟩ := Ideal.is_unit_ideal.mp h'; absurd (pow_nat_one n ▸ h1n) h\n\n    theorem maximal_subset_jacobson {M : Ideal α} (hM : M.is_maximal) : jacobson_radical α ⊆ M :=\n      fun x hx => Ideal.sIntersection.mem.mp hx M hM\n\n  end Ring\nend M4R\n", "meta": {"author": "Hop311", "repo": "M4R", "sha": "ebd1b04af344f9737d290bf8b48b3cde35e9787b", "save_path": "github-repos/lean/Hop311-M4R", "path": "github-repos/lean/Hop311-M4R/M4R-ebd1b04af344f9737d290bf8b48b3cde35e9787b/M4R/Algebra/Ring/Radical.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127529517043, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.47017065129968244}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.bases\nimport Mathlib.topology.homeomorph\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Open sets\n\n## Summary\n\nWe define the subtype of open sets in a topological space.\n\n## Main Definitions\n\n- `opens α` is the type of open subsets of a topological space `α`.\n- `open_nhds_of x` is the type of open subsets of a topological space `α` containing `x : α`.\n-\n-/\n\nnamespace topological_space\n\n\n/-- The type of open subsets of a topological space. -/\ndef opens (α : Type u_1) [topological_space α] :=\n  Subtype fun (s : set α) => is_open s\n\nnamespace opens\n\n\nprotected instance set.has_coe {α : Type u_1} [topological_space α] : has_coe (opens α) (set α) :=\n  has_coe.mk subtype.val\n\ntheorem val_eq_coe {α : Type u_1} [topological_space α] (U : opens α) : subtype.val U = ↑U :=\n  rfl\n\n/-- the coercion `opens α → set α` applied to a pair is the same as taking the first component -/\ntheorem coe_mk {α : Type u_1} [topological_space α] {U : set α} {hU : is_open U} : ↑{ val := U, property := hU } = U :=\n  rfl\n\nprotected instance has_subset {α : Type u_1} [topological_space α] : has_subset (opens α) :=\n  has_subset.mk fun (U V : opens α) => ↑U ⊆ ↑V\n\nprotected instance has_mem {α : Type u_1} [topological_space α] : has_mem α (opens α) :=\n  has_mem.mk fun (a : α) (U : opens α) => a ∈ ↑U\n\n@[simp] theorem subset_coe {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} : ↑U ⊆ ↑V = (U ⊆ V) :=\n  rfl\n\n@[simp] theorem mem_coe {α : Type u_1} [topological_space α] {x : α} {U : opens α} : x ∈ ↑U = (x ∈ U) :=\n  rfl\n\ntheorem ext {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} (h : ↑U = ↑V) : U = V :=\n  iff.mpr subtype.ext_iff h\n\ntheorem ext_iff {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} : ↑U = ↑V ↔ U = V :=\n  { mp := ext, mpr := congr_arg coe }\n\nprotected instance partial_order {α : Type u_1} [topological_space α] : partial_order (opens α) :=\n  subtype.partial_order fun (s : set α) => is_open s\n\n/-- The interior of a set, as an element of `opens`. -/\ndef interior {α : Type u_1} [topological_space α] (s : set α) : opens α :=\n  { val := interior s, property := is_open_interior }\n\ntheorem gc {α : Type u_1} [topological_space α] : galois_connection coe interior :=\n  fun (U : opens α) (s : set α) =>\n    { mp := fun (h : ↑U ≤ s) => interior_maximal h (subtype.property U),\n      mpr := fun (h : U ≤ interior s) => le_trans h interior_subset }\n\n/-- The galois insertion between sets and opens, but ordered by reverse inclusion. -/\ndef gi {α : Type u_1} [topological_space α] : galois_insertion interior subtype.val :=\n  galois_insertion.mk\n    (fun (s : order_dual (set α)) (hs : subtype.val (interior s) ≤ s) => { val := s, property := sorry }) sorry sorry\n    sorry\n\n@[simp] theorem gi_choice_val {α : Type u_1} [topological_space α] {s : order_dual (set α)} {hs : subtype.val (interior s) ≤ s} : subtype.val (galois_insertion.choice gi s hs) = s :=\n  rfl\n\nprotected instance complete_lattice {α : Type u_1} [topological_space α] : complete_lattice (opens α) :=\n  complete_lattice.copy (order_dual.complete_lattice (order_dual (opens α))) (fun (U V : opens α) => U ⊆ V) sorry\n    { val := set.univ, property := is_open_univ } sorry { val := ∅, property := is_open_empty } sorry\n    (fun (U V : opens α) => { val := ↑U ∪ ↑V, property := sorry }) sorry\n    (fun (U V : opens α) => { val := ↑U ∩ ↑V, property := sorry }) sorry\n    (fun (Us : set (opens α)) => { val := ⋃₀(coe '' Us), property := sorry }) sorry complete_lattice.Inf sorry\n\n/- le  -/ (λ U V, U ⊆ V) rfl\n/- top -/ ⟨set.univ, is_open_univ⟩ (subtype.ext_iff_val.mpr interior_univ.symm)\n/- bot -/ ⟨∅, is_open_empty⟩ rfl\n/- sup -/ (λ U V, ⟨↑U ∪ ↑V, is_open_union U.2 V.2⟩) rfl\n/- inf -/ (λ U V, ⟨↑U ∩ ↑V, is_open_inter U.2 V.2⟩)\nbegin\n  funext,\n  apply subtype.ext_iff_val.mpr,\n  exact (is_open_inter U.2 V.2).interior_eq.symm,\nend\n/- Sup -/ (λ Us, ⟨⋃₀ (coe '' Us), is_open_sUnion $ λ U hU,\nby { rcases hU with ⟨⟨V, hV⟩, h, h'⟩, dsimp at h', subst h', exact hV}⟩)\nbegin\n  funext,\n  apply subtype.ext_iff_val.mpr,\n  simp [Sup_range],\n  refl,\nend\n/- Inf -/ _ rfl\n\nlemma le_def {U V : opens α} : U ≤ V ↔ (U : set α) ≤ (V : set α) :=\nby refl\ntheorem le_def {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} : U ≤ V ↔ ↑U ≤ ↑V :=\n  iff.refl (U ≤ V)\n\n\n@[simp] lemma mk_inf_mk {U V : set α} {hU : is_open U} {hV : is_open V} :\n  (⟨U, hU⟩ ⊓ ⟨V, hV⟩ : opens α) = ⟨U ⊓ V, is_open_inter hU hV⟩ := rfl\n@[simp] theorem mk_inf_mk {α : Type u_1} [topological_space α] {U : set α} {V : set α} {hU : is_open U} {hV : is_open V} : { val := U, property := hU } ⊓ { val := V, property := hV } = { val := U ⊓ V, property := is_open_inter hU hV } :=\n  rfl\n\n@[simp,norm_cast] lemma coe_inf {U V : opens α} :\n  ((U ⊓ V : opens α) : set α) = (U : set α) ⊓ (V : set α) := rfl\n@[simp] theorem coe_inf {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} : ↑(U ⊓ V) = ↑U ⊓ ↑V :=\n  rfl\n\n\ninstance : has_inter (opens α) := ⟨λ U V, U ⊓ V⟩\ninstance : has_union (opens α) := ⟨λ U V, U ⊔ V⟩\nprotected instance has_inter {α : Type u_1} [topological_space α] : has_inter (opens α) :=\n  has_inter.mk fun (U V : opens α) => U ⊓ V\n\ninstance : has_emptyc (opens α) := ⟨⊥⟩\nprotected instance has_union {α : Type u_1} [topological_space α] : has_union (opens α) :=\n  has_union.mk fun (U V : opens α) => U ⊔ V\n\ninstance : inhabited (opens α) := ⟨∅⟩\nprotected instance has_emptyc {α : Type u_1} [topological_space α] : has_emptyc (opens α) :=\n  has_emptyc.mk ⊥\n\n\nprotected instance inhabited {α : Type u_1} [topological_space α] : Inhabited (opens α) :=\n  { default := ∅ }\n\n@[simp] lemma inter_eq (U V : opens α) : U ∩ V = U ⊓ V := rfl\n@[simp] lemma union_eq (U V : opens α) : U ∪ V = U ⊔ V := rfl\n@[simp] theorem inter_eq {α : Type u_1} [topological_space α] (U : opens α) (V : opens α) : U ∩ V = U ⊓ V :=\n  rfl\n\n@[simp] lemma empty_eq : (∅ : opens α) = ⊥ := rfl\n@[simp] theorem union_eq {α : Type u_1} [topological_space α] (U : opens α) (V : opens α) : U ∪ V = U ⊔ V :=\n  rfl\n\n\n@[simp] theorem empty_eq {α : Type u_1} [topological_space α] : ∅ = ⊥ :=\n  rfl\n\n@[simp] lemma Sup_s {Us : set (opens α)} : ↑(Sup Us) = ⋃₀ ((coe : _ → set α) '' Us) :=\nbegin\n@[simp] theorem Sup_s {α : Type u_1} [topological_space α] {Us : set (opens α)} : ↑(Sup Us) = ⋃₀(coe '' Us) := sorry\n\n  rw [@galois_connection.l_Sup (opens α) (set α) _ _ (coe : opens α → set α) interior gc Us],\n  rw [set.sUnion_image]\nend\n\nlemma supr_def {ι} (s : ι → opens α) : (⨆ i, s i) = ⟨⋃ i, s i, is_open_Union $ λ i, (s i).2⟩ :=\nby { ext, simp only [supr, opens.Sup_s, sUnion_image, bUnion_range], refl }\ntheorem supr_def {α : Type u_1} [topological_space α] {ι : Sort u_2} (s : ι → opens α) : (supr fun (i : ι) => s i) =\n  { val := set.Union fun (i : ι) => ↑(s i), property := is_open_Union fun (i : ι) => subtype.property (s i) } := sorry\n\n\n@[simp] lemma supr_mk {ι} (s : ι → set α) (h : Π i, is_open (s i)) :\n  (⨆ i, ⟨s i, h i⟩ : opens α) = ⟨⨆ i, s i, is_open_Union h⟩ :=\n@[simp] theorem supr_mk {α : Type u_1} [topological_space α] {ι : Sort u_2} (s : ι → set α) (h : ∀ (i : ι), is_open (s i)) : (supr fun (i : ι) => { val := s i, property := h i }) = { val := supr fun (i : ι) => s i, property := is_open_Union h } := sorry\n\nby { rw supr_def, simp }\n\n@[simp] lemma supr_s {ι} (s : ι → opens α) : ((⨆ i, s i : opens α) : set α) = ⋃ i, s i :=\nby simp [supr_def]\n@[simp] theorem supr_s {α : Type u_1} [topological_space α] {ι : Sort u_2} (s : ι → opens α) : ↑(supr fun (i : ι) => s i) = set.Union fun (i : ι) => ↑(s i) := sorry\n\n\ntheorem mem_supr {ι} {x : α} {s : ι → opens α} : x ∈ supr s ↔ ∃ i, x ∈ s i :=\nby { rw [←mem_coe], simp, }\ntheorem mem_supr {α : Type u_1} [topological_space α] {ι : Sort u_2} {x : α} {s : ι → opens α} : x ∈ supr s ↔ ∃ (i : ι), x ∈ s i := sorry\n\n\nlemma open_embedding_of_le {U V : opens α} (i : U ≤ V) :\n  open_embedding (set.inclusion i) :=\ntheorem open_embedding_of_le {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} (i : U ≤ V) : open_embedding (set.inclusion i) :=\n  open_embedding.mk (embedding.mk (inducing.mk (Eq.symm induced_compose)) (set.inclusion_injective i))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (is_open (set.range (set.inclusion i)))) (set.range_inclusion i)))\n      (is_open.preimage continuous_subtype_val (subtype.property U)))\n\n{ inj := set.inclusion_injective i,\n  induced := (@induced_compose _ _ _ _ (set.inclusion i) coe).symm,\n  open_range :=\n  begin\n    rw set.range_inclusion i,\n    exact U.property.preimage continuous_subtype_val\n  end, }\n\ndef is_basis (B : set (opens α)) : Prop := is_topological_basis ((coe : _ → set α) '' B)\n\ndef is_basis {α : Type u_1} [topological_space α] (B : set (opens α)) :=\n  is_topological_basis (coe '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens α)} :\n  is_basis B ↔ ∀ {U : opens α} {x}, x ∈ U → ∃ U' ∈ B, x ∈ U' ∧ U' ⊆ U :=\ntheorem is_basis_iff_nbhd {α : Type u_1} [topological_space α] {B : set (opens α)} : is_basis B ↔ ∀ {U : opens α} {x : α}, x ∈ U → ∃ (U' : opens α), ∃ (H : U' ∈ B), x ∈ U' ∧ U' ⊆ U := sorry\n\nbegin\n  split; intro h,\n  { rintros ⟨sU, hU⟩ x hx,\n    rcases (mem_nhds_of_is_topological_basis h).mp (mem_nhds_sets hU hx)\n      with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩,\n    refine ⟨V, H₁, _⟩,\n    cases V, dsimp at H₂, subst H₂, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU ⟨U, ⟨H₁, H₂⟩⟩, subst H₂, exact U.property },\n    { intros x sU hx hsU,\n      rcases @h (⟨sU, hsU⟩ : opens α) x hx with ⟨V, hV, H⟩,\n      exact ⟨V, ⟨V, hV, rfl⟩, H⟩ } }\nend\n\nlemma is_basis_iff_cover {B : set (opens α)} :\n  is_basis B ↔ ∀ U : opens α, ∃ Us ⊆ B, U = Sup Us :=\ntheorem is_basis_iff_cover {α : Type u_1} [topological_space α] {B : set (opens α)} : is_basis B ↔ ∀ (U : opens α), ∃ (Us : set (opens α)), ∃ (H : Us ⊆ B), U = Sup Us := sorry\n\nbegin\n  split,\n  { intros hB U,\n    rcases sUnion_basis_of_is_open hB U.prop with ⟨sUs, H, hU⟩,\n    existsi {U : opens α | U ∈ B ∧ ↑U ∈ sUs},\n    split,\n    { intros U hU, exact hU.left },\n    { apply ext,\n      rw [Sup_s, hU],\n      congr' with s; split; intro hs,\n      { rcases H hs with ⟨V, hV⟩,\n        rw ← hV.right at hs,\n        refine ⟨V, ⟨⟨hV.left, hs⟩, hV.right⟩⟩ },\n      { rcases hs with ⟨V, ⟨⟨H₁, H₂⟩, H₃⟩⟩,\n        subst H₃, exact H₂ } } },\n  { intro h,\n    rw is_basis_iff_nbhd,\n    intros U x hx,\n    rcases h U with ⟨Us, hUs, H⟩,\n    replace H := congr_arg (coe : _ → set α) H,\n    rw Sup_s at H,\n    change x ∈ ↑U at hx,\n    rw H at hx,\n    rcases set.mem_sUnion.mp hx with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩,\n    refine ⟨V,hUs H₁,_⟩,\n    cases V with V hV,\n    dsimp at H₂, subst H₂,\n    refine ⟨hsV,_⟩,\n    change V ⊆ U, rw H,\n    exact set.subset_sUnion_of_mem ⟨⟨V, _⟩, ⟨H₁, rfl⟩⟩ }\nend\n\n/-- The preimage of an open set, as an open set. -/\n\ndef comap {f : α → β} (hf : continuous f) (V : opens β) : opens α :=\n⟨f ⁻¹' V.1, V.2.preimage hf⟩\ndef comap {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} (hf : continuous f) (V : opens β) : opens α :=\n  { val := f ⁻¹' subtype.val V, property := sorry }\n\n\n@[simp] lemma comap_id (U : opens α) : U.comap continuous_id = U := by { ext, refl }\n\n@[simp] theorem comap_id {α : Type u_1} [topological_space α] (U : opens α) : comap continuous_id U = U :=\n  ext (set.ext fun (x : α) => iff.refl (x ∈ ↑(comap continuous_id U)))\n\nlemma comap_mono {f : α → β} (hf : continuous f) {V W : opens β} (hVW : V ⊆ W) :\n  V.comap hf ⊆ W.comap hf :=\ntheorem comap_mono {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} (hf : continuous f) {V : opens β} {W : opens β} (hVW : V ⊆ W) : comap hf V ⊆ comap hf W :=\n  fun (_x : α) (h : _x ∈ ↑(comap hf V)) => hVW h\n\nλ _ h, hVW h\n\n@[simp] lemma coe_comap {f : α → β} (hf : continuous f) (U : opens β) :\n  ↑(U.comap hf) = f ⁻¹' U := rfl\n@[simp] theorem coe_comap {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} (hf : continuous f) (U : opens β) : ↑(comap hf U) = f ⁻¹' ↑U :=\n  rfl\n\n\n@[simp] lemma comap_val {f : α → β} (hf : continuous f) (U : opens β) :\n  (U.comap hf).1 = f ⁻¹' U := rfl\n@[simp] theorem comap_val {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β} (hf : continuous f) (U : opens β) : subtype.val (comap hf U) = f ⁻¹' ↑U :=\n  rfl\n\n\nprotected lemma comap_comp {g : β → γ} {f : α → β} (hg : continuous g) (hf : continuous f)\n  (U : opens γ) : U.comap (hg.comp hf) = (U.comap hg).comap hf :=\nprotected theorem comap_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} (hg : continuous g) (hf : continuous f) (U : opens γ) : comap (continuous.comp hg hf) U = comap hf (comap hg U) := sorry\n\nby { ext1, simp only [coe_comap, preimage_preimage] }\n\n/-- A homeomorphism induces an equivalence on open sets, by taking comaps. -/\n@[simp] protected def equiv {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (f : α ≃ₜ β) : opens α ≃ opens β :=\n  equiv.mk (comap sorry) (comap (homeomorph.continuous f)) sorry sorry\n\nend opens\n\n\n/-- The open neighborhoods of a point. See also `opens` or `nhds`. -/\ndef open_nhds_of {α : Type u_1} [topological_space α] (x : α) :=\n  Subtype fun (s : set α) => is_open s ∧ x ∈ s\n\nprotected instance open_nhds_of.inhabited {α : Type u_1} [topological_space α] (x : α) : Inhabited (open_nhds_of x) :=\n  { default := { val := set.univ, property := sorry } }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/opens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.47013092149655134}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.filter.pointwise\nimport Mathlib.group_theory.quotient_group\nimport Mathlib.topology.algebra.monoid\nimport Mathlib.topology.homeomorph\nimport Mathlib.PostPort\n\nuniverses w u l u_1 x u_2 \n\nnamespace Mathlib\n\n/-!\n# Theory of topological groups\n\nThis file defines the following typeclasses:\n\n* `topological_group`, `topological_add_group`: multiplicative and additive topological groups,\n  i.e., groups with continuous `(*)` and `(⁻¹)` / `(+)` and `(-)`;\n\n* `has_continuous_sub G` means that `G` has a continuous subtraction operation.\n\nThere is an instance deducing `has_continuous_sub` from `topological_group` but we use a separate\ntypeclass because, e.g., `ℕ` and `ℝ≥0` have continuous subtraction but are not additive groups.\n\nWe also define `homeomorph` versions of several `equiv`s: `homeomorph.mul_left`,\n`homeomorph.mul_right`, `homeomorph.inv`, and prove a few facts about neighbourhood filters in\ngroups.\n\n## Tags\n\ntopological space, group, topological group\n-/\n\n/-!\n### Groups with continuous multiplication\n\nIn this section we prove a few statements about groups with continuous `(*)`.\n-/\n\n/-- Multiplication from the left in a topological group as a homeomorphism. -/\nprotected def homeomorph.add_left {G : Type w} [topological_space G] [add_group G] [has_continuous_add G] (a : G) : G ≃ₜ G :=\n  homeomorph.mk (equiv.mk (equiv.to_fun (equiv.add_left a)) (equiv.inv_fun (equiv.add_left a)) sorry sorry)\n\n@[simp] theorem homeomorph.coe_mul_left {G : Type w} [topological_space G] [group G] [has_continuous_mul G] (a : G) : ⇑(homeomorph.mul_left a) = Mul.mul a :=\n  rfl\n\ntheorem homeomorph.add_left_symm {G : Type w} [topological_space G] [add_group G] [has_continuous_add G] (a : G) : homeomorph.symm (homeomorph.add_left a) = homeomorph.add_left (-a) :=\n  homeomorph.ext fun (x : G) => Eq.refl (coe_fn (homeomorph.symm (homeomorph.add_left a)) x)\n\ntheorem is_open_map_mul_left {G : Type w} [topological_space G] [group G] [has_continuous_mul G] (a : G) : is_open_map fun (x : G) => a * x :=\n  homeomorph.is_open_map (homeomorph.mul_left a)\n\ntheorem is_closed_map_mul_left {G : Type w} [topological_space G] [group G] [has_continuous_mul G] (a : G) : is_closed_map fun (x : G) => a * x :=\n  homeomorph.is_closed_map (homeomorph.mul_left a)\n\n/-- Multiplication from the right in a topological group as a homeomorphism. -/\nprotected def homeomorph.mul_right {G : Type w} [topological_space G] [group G] [has_continuous_mul G] (a : G) : G ≃ₜ G :=\n  homeomorph.mk (equiv.mk (equiv.to_fun (equiv.mul_right a)) (equiv.inv_fun (equiv.mul_right a)) sorry sorry)\n\ntheorem is_open_map_add_right {G : Type w} [topological_space G] [add_group G] [has_continuous_add G] (a : G) : is_open_map fun (x : G) => x + a :=\n  homeomorph.is_open_map (homeomorph.add_right a)\n\ntheorem is_closed_map_mul_right {G : Type w} [topological_space G] [group G] [has_continuous_mul G] (a : G) : is_closed_map fun (x : G) => x * a :=\n  homeomorph.is_closed_map (homeomorph.mul_right a)\n\ntheorem is_open_map_div_right {G : Type w} [topological_space G] [group G] [has_continuous_mul G] (a : G) : is_open_map fun (x : G) => x / a := sorry\n\ntheorem is_closed_map_div_right {G : Type w} [topological_space G] [group G] [has_continuous_mul G] (a : G) : is_closed_map fun (x : G) => x / a := sorry\n\n/-!\n### Topological groups\n\nA topological group is a group in which the multiplication and inversion operations are\ncontinuous. Topological additive groups are defined in the same way. Equivalently, we can require\nthat the division operation `λ x y, x * y⁻¹` (resp., subtraction) is continuous.\n-/\n\n/-- A topological (additive) group is a group in which the addition and negation operations are\ncontinuous. -/\nclass topological_add_group (G : Type u) [topological_space G] [add_group G] \nextends has_continuous_add G\nwhere\n  continuous_neg : continuous fun (a : G) => -a\n\n/-- A topological group is a group in which the multiplication and inversion operations are\ncontinuous. -/\nclass topological_group (G : Type u_1) [topological_space G] [group G] \nextends has_continuous_mul G\nwhere\n  continuous_inv : continuous has_inv.inv\n\ntheorem continuous_on_neg {G : Type w} [topological_space G] [add_group G] [topological_add_group G] {s : set G} : continuous_on Neg.neg s :=\n  continuous.continuous_on continuous_neg\n\ntheorem continuous_within_at_neg {G : Type w} [topological_space G] [add_group G] [topological_add_group G] {s : set G} {x : G} : continuous_within_at Neg.neg s x :=\n  continuous.continuous_within_at continuous_neg\n\ntheorem continuous_at_inv {G : Type w} [topological_space G] [group G] [topological_group G] {x : G} : continuous_at has_inv.inv x :=\n  continuous.continuous_at continuous_inv\n\ntheorem tendsto_neg {G : Type w} [topological_space G] [add_group G] [topological_add_group G] (a : G) : filter.tendsto Neg.neg (nhds a) (nhds (-a)) :=\n  continuous_at_neg\n\n/-- If a function converges to a value in a multiplicative topological group, then its inverse\nconverges to the inverse of this value. For the version in normed fields assuming additionally\nthat the limit is nonzero, use `tendsto.inv'`. -/\ntheorem filter.tendsto.inv {α : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] {f : α → G} {l : filter α} {y : G} (h : filter.tendsto f l (nhds y)) : filter.tendsto (fun (x : α) => f x⁻¹) l (nhds (y⁻¹)) :=\n  filter.tendsto.comp (continuous.tendsto continuous_inv y) h\n\ntheorem continuous.inv {α : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] [topological_space α] {f : α → G} (hf : continuous f) : continuous fun (x : α) => f x⁻¹ :=\n  continuous.comp continuous_inv hf\n\ntheorem continuous_on.inv {α : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] [topological_space α] {f : α → G} {s : set α} (hf : continuous_on f s) : continuous_on (fun (x : α) => f x⁻¹) s :=\n  continuous.comp_continuous_on continuous_inv hf\n\ntheorem continuous_within_at.inv {α : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] [topological_space α] {f : α → G} {s : set α} {x : α} (hf : continuous_within_at f s x) : continuous_within_at (fun (x : α) => f x⁻¹) s x :=\n  filter.tendsto.inv hf\n\nprotected instance prod.topological_add_group {G : Type w} {H : Type x} [topological_space G] [add_group G] [topological_add_group G] [topological_space H] [add_group H] [topological_add_group H] : topological_add_group (G × H) :=\n  topological_add_group.mk (continuous.prod_map continuous_neg continuous_neg)\n\n/-- Inversion in a topological group as a homeomorphism. -/\nprotected def homeomorph.neg (G : Type w) [topological_space G] [add_group G] [topological_add_group G] : G ≃ₜ G :=\n  homeomorph.mk (equiv.mk (equiv.to_fun (equiv.neg G)) (equiv.inv_fun (equiv.neg G)) sorry sorry)\n\ntheorem nhds_zero_symm (G : Type w) [topological_space G] [add_group G] [topological_add_group G] : filter.comap Neg.neg (nhds 0) = nhds 0 :=\n  Eq.trans (homeomorph.comap_nhds_eq (homeomorph.neg G) 0) (congr_arg nhds neg_zero)\n\n/-- The map `(x, y) ↦ (x, xy)` as a homeomorphism. This is a shear mapping. -/\nprotected def homeomorph.shear_add_right (G : Type w) [topological_space G] [add_group G] [topological_add_group G] : G × G ≃ₜ G × G :=\n  homeomorph.mk\n    (equiv.mk (equiv.to_fun (equiv.prod_shear (equiv.refl G) equiv.add_left))\n      (equiv.inv_fun (equiv.prod_shear (equiv.refl G) equiv.add_left)) sorry sorry)\n\n@[simp] theorem homeomorph.shear_mul_right_coe (G : Type w) [topological_space G] [group G] [topological_group G] : ⇑(homeomorph.shear_mul_right G) = fun (z : G × G) => (prod.fst z, prod.fst z * prod.snd z) :=\n  rfl\n\n@[simp] theorem homeomorph.shear_mul_right_symm_coe (G : Type w) [topological_space G] [group G] [topological_group G] : ⇑(homeomorph.symm (homeomorph.shear_mul_right G)) = fun (z : G × G) => (prod.fst z, prod.fst z⁻¹ * prod.snd z) :=\n  rfl\n\ntheorem inv_closure {G : Type w} [topological_space G] [group G] [topological_group G] (s : set G) : closure s⁻¹ = closure (s⁻¹) :=\n  homeomorph.preimage_closure (homeomorph.inv G) s\n\ntheorem exists_nhds_half_neg {G : Type w} [topological_space G] [add_group G] [topological_add_group G] {s : set G} (hs : s ∈ nhds 0) : ∃ (V : set G), ∃ (H : V ∈ nhds 0), ∀ (v : G), v ∈ V → ∀ (w : G), w ∈ V → v - w ∈ s := sorry\n\ntheorem nhds_translation_mul_inv {G : Type w} [topological_space G] [group G] [topological_group G] (x : G) : filter.comap (fun (y : G) => y * (x⁻¹)) (nhds 1) = nhds x := sorry\n\n@[simp] theorem map_mul_left_nhds {G : Type w} [topological_space G] [group G] [topological_group G] (x : G) (y : G) : filter.map (Mul.mul x) (nhds y) = nhds (x * y) :=\n  homeomorph.map_nhds_eq (homeomorph.mul_left x) y\n\ntheorem map_mul_left_nhds_one {G : Type w} [topological_space G] [group G] [topological_group G] (x : G) : filter.map (Mul.mul x) (nhds 1) = nhds x := sorry\n\ntheorem topological_group.ext {G : Type u_1} [group G] {t : topological_space G} {t' : topological_space G} (tg : topological_group G) (tg' : topological_group G) (h : nhds 1 = nhds 1) : t = t' := sorry\n\ntheorem topological_group.of_nhds_aux {G : Type u_1} [group G] [topological_space G] (hinv : filter.tendsto (fun (x : G) => x⁻¹) (nhds 1) (nhds 1)) (hleft : ∀ (x₀ : G), nhds x₀ = filter.map (fun (x : G) => x₀ * x) (nhds 1)) (hconj : ∀ (x₀ : G), filter.map (fun (x : G) => x₀ * x * (x₀⁻¹)) (nhds 1) ≤ nhds 1) : continuous fun (x : G) => x⁻¹ := sorry\n\ntheorem topological_add_group.of_nhds_zero' {G : Type (max u_1 u_2)} [add_group G] [topological_space G] (hmul : filter.tendsto (function.uncurry Add.add) (filter.prod (nhds 0) (nhds 0)) (nhds 0)) (hinv : filter.tendsto (fun (x : G) => -x) (nhds 0) (nhds 0)) (hleft : ∀ (x₀ : G), nhds x₀ = filter.map (fun (x : G) => x₀ + x) (nhds 0)) (hright : ∀ (x₀ : G), nhds x₀ = filter.map (fun (x : G) => x + x₀) (nhds 0)) : topological_add_group G := sorry\n\ntheorem topological_add_group.of_nhds_zero {G : Type (max u_1 u_2)} [add_group G] [topological_space G] (hmul : filter.tendsto (function.uncurry Add.add) (filter.prod (nhds 0) (nhds 0)) (nhds 0)) (hinv : filter.tendsto (fun (x : G) => -x) (nhds 0) (nhds 0)) (hleft : ∀ (x₀ : G), nhds x₀ = filter.map (fun (x : G) => x₀ + x) (nhds 0)) (hconj : ∀ (x₀ : G), filter.tendsto (fun (x : G) => x₀ + x + -x₀) (nhds 0) (nhds 0)) : topological_add_group G :=\n  topological_add_group.mk (topological_add_group.of_nhds_aux hinv hleft hconj)\n\ntheorem topological_add_group.of_comm_of_nhds_zero {G : Type (max u_1 u_2)} [add_comm_group G] [topological_space G] (hmul : filter.tendsto (function.uncurry Add.add) (filter.prod (nhds 0) (nhds 0)) (nhds 0)) (hinv : filter.tendsto (fun (x : G) => -x) (nhds 0) (nhds 0)) (hleft : ∀ (x₀ : G), nhds x₀ = filter.map (fun (x : G) => x₀ + x) (nhds 0)) : topological_add_group G := sorry\n\nprotected instance quotient_group.quotient.topological_space {G : Type u_1} [group G] [topological_space G] (N : subgroup G) : topological_space (quotient_group.quotient N) :=\n  quotient.topological_space\n\ntheorem quotient_group.is_open_map_coe {G : Type w} [topological_space G] [group G] [topological_group G] (N : subgroup G) : is_open_map coe := sorry\n\nprotected instance topological_add_group_quotient {G : Type w} [topological_space G] [add_group G] [topological_add_group G] (N : add_subgroup G) [add_subgroup.normal N] : topological_add_group (quotient_add_group.quotient N) :=\n  topological_add_group.mk\n    (eq.mpr\n      ((fun (f f_1 : quotient_add_group.quotient N → quotient_add_group.quotient N) (e_3 : f = f_1) =>\n          congr_arg continuous e_3)\n        Neg.neg (quotient.lift (coe ∘ fun (a : G) => -a) (quotient_add_group.div_inv_monoid._proof_5 N))\n        (Eq.refl Neg.neg))\n      (continuous_quotient_lift (quotient_add_group.div_inv_monoid._proof_5 N)\n        (continuous.comp continuous_quot_mk continuous_neg)))\n\n/-- A typeclass saying that `λ p : G × G, p.1 - p.2` is a continuous function. This property\nautomatically holds for topological additive groups but it also holds, e.g., for `ℝ≥0`. -/\nclass has_continuous_sub (G : Type u_1) [topological_space G] [Sub G] \nwhere\n  continuous_sub : continuous fun (p : G × G) => prod.fst p - prod.snd p\n\nprotected instance topological_add_group.to_has_continuous_sub {G : Type w} [topological_space G] [add_group G] [topological_add_group G] : has_continuous_sub G :=\n  has_continuous_sub.mk\n    (eq.mpr\n      (id\n        ((fun (f f_1 : G × G → G) (e_3 : f = f_1) => congr_arg continuous e_3)\n          (fun (p : G × G) => prod.fst p - prod.snd p) (fun (p : G × G) => prod.fst p + -prod.snd p)\n          (funext fun (p : G × G) => sub_eq_add_neg (prod.fst p) (prod.snd p))))\n      (continuous.add continuous_fst (continuous.neg continuous_snd)))\n\ntheorem filter.tendsto.sub {α : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] {f : α → G} {g : α → G} {l : filter α} {a : G} {b : G} (hf : filter.tendsto f l (nhds a)) (hg : filter.tendsto g l (nhds b)) : filter.tendsto (fun (x : α) => f x - g x) l (nhds (a - b)) :=\n  filter.tendsto.comp (continuous.tendsto continuous_sub (a, b)) (filter.tendsto.prod_mk_nhds hf hg)\n\ntheorem continuous.sub {α : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] [topological_space α] {f : α → G} {g : α → G} (hf : continuous f) (hg : continuous g) : continuous fun (x : α) => f x - g x :=\n  continuous.comp continuous_sub (continuous.prod_mk hf hg)\n\ntheorem continuous_within_at.sub {α : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] [topological_space α] {f : α → G} {g : α → G} {s : set α} {x : α} (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) : continuous_within_at (fun (x : α) => f x - g x) s x :=\n  filter.tendsto.sub hf hg\n\ntheorem continuous_on.sub {α : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] [topological_space α] {f : α → G} {g : α → G} {s : set α} (hf : continuous_on f s) (hg : continuous_on g s) : continuous_on (fun (x : α) => f x - g x) s :=\n  fun (x : α) (hx : x ∈ s) => continuous_within_at.sub (hf x hx) (hg x hx)\n\ntheorem nhds_translation {G : Type w} [topological_space G] [add_group G] [topological_add_group G] (x : G) : filter.comap (fun (y : G) => y - x) (nhds 0) = nhds x := sorry\n\n/-- additive group with a neighbourhood around 0.\nOnly used to construct a topology and uniform space.\n\nThis is currently only available for commutative groups, but it can be extended to\nnon-commutative groups too.\n-/\nclass add_group_with_zero_nhd (G : Type u) \nextends add_comm_group G\nwhere\n  Z : filter G\n  zero_Z : pure 0 ≤ Z\n  sub_Z : filter.tendsto (fun (p : G × G) => prod.fst p - prod.snd p) (filter.prod Z Z) Z\n\nnamespace add_group_with_zero_nhd\n\n\nprotected instance topological_space (G : Type w) [add_group_with_zero_nhd G] : topological_space G :=\n  topological_space.mk_of_nhds fun (a : G) => filter.map (fun (x : G) => x + a) (Z G)\n\ntheorem neg_Z {G : Type w} [add_group_with_zero_nhd G] : filter.tendsto (fun (a : G) => -a) (Z G) (Z G) := sorry\n\ntheorem add_Z {G : Type w} [add_group_with_zero_nhd G] : filter.tendsto (fun (p : G × G) => prod.fst p + prod.snd p) (filter.prod (Z G) (Z G)) (Z G) := sorry\n\ntheorem exists_Z_half {G : Type w} [add_group_with_zero_nhd G] {s : set G} (hs : s ∈ Z G) : ∃ (V : set G), ∃ (H : V ∈ Z G), ∀ (v : G), v ∈ V → ∀ (w : G), w ∈ V → v + w ∈ s := sorry\n\ntheorem nhds_eq {G : Type w} [add_group_with_zero_nhd G] (a : G) : nhds a = filter.map (fun (x : G) => x + a) (Z G) := sorry\n\ntheorem nhds_zero_eq_Z {G : Type w} [add_group_with_zero_nhd G] : nhds 0 = Z G := sorry\n\nprotected instance has_continuous_add {G : Type w} [add_group_with_zero_nhd G] : has_continuous_add G :=\n  has_continuous_add.mk (iff.mpr continuous_iff_continuous_at fun (_x : G × G) => sorry)\n\nprotected instance topological_add_group {G : Type w} [add_group_with_zero_nhd G] : topological_add_group G := sorry\n\nend add_group_with_zero_nhd\n\n\ntheorem is_open.add_left {G : Type w} [topological_space G] [add_group G] [topological_add_group G] {s : set G} {t : set G} : is_open t → is_open (s + t) :=\n  fun (ht : is_open t) =>\n    eq.mpr (id (Eq._oldrec (Eq.refl (is_open (s + t))) (Eq.symm set.Union_add_left_image)))\n      (is_open_Union fun (a : G) => is_open_Union fun (ha : a ∈ s) => (fun (a : G) => is_open_map_add_left a t ht) a)\n\ntheorem is_open.add_right {G : Type w} [topological_space G] [add_group G] [topological_add_group G] {s : set G} {t : set G} : is_open s → is_open (s + t) :=\n  fun (hs : is_open s) =>\n    eq.mpr (id (Eq._oldrec (Eq.refl (is_open (s + t))) (Eq.symm set.Union_add_right_image)))\n      (is_open_Union fun (a : G) => is_open_Union fun (ha : a ∈ t) => (fun (a : G) => is_open_map_add_right a s hs) a)\n\ntheorem topological_group.t1_space (G : Type w) [topological_space G] [group G] [topological_group G] (h : is_closed (singleton 1)) : t1_space G := sorry\n\ntheorem topological_group.regular_space (G : Type w) [topological_space G] [group G] [topological_group G] [t1_space G] : regular_space G := sorry\n\ntheorem topological_group.t2_space (G : Type w) [topological_space G] [group G] [topological_group G] [t1_space G] : t2_space G :=\n  regular_space.t2_space G\n\n/-! Some results about an open set containing the product of two sets in a topological group. -/\n\n/-- Given a compact set `K` inside an open set `U`, there is a open neighborhood `V` of `1`\n  such that `KV ⊆ U`. -/\ntheorem compact_open_separated_add {G : Type w} [topological_space G] [add_group G] [topological_add_group G] {K : set G} {U : set G} (hK : is_compact K) (hU : is_open U) (hKU : K ⊆ U) : ∃ (V : set G), is_open V ∧ 0 ∈ V ∧ K + V ⊆ U := sorry\n\n/-- A compact set is covered by finitely many left multiplicative translates of a set\n  with non-empty interior. -/\ntheorem compact_covered_by_add_left_translates {G : Type w} [topological_space G] [add_group G] [topological_add_group G] {K : set G} {V : set G} (hK : is_compact K) (hV : set.nonempty (interior V)) : ∃ (t : finset G), K ⊆ set.Union fun (g : G) => set.Union fun (H : g ∈ t) => (fun (h : G) => g + h) ⁻¹' V := sorry\n\n/-- Every locally compact separable topological group is σ-compact.\n  Note: this is not true if we drop the topological group hypothesis. -/\nprotected instance separable_locally_compact_group.sigma_compact_space {G : Type w} [topological_space G] [group G] [topological_group G] [topological_space.separable_space G] [locally_compact_space G] : sigma_compact_space G := sorry\n\ntheorem nhds_add {G : Type w} [topological_space G] [add_comm_group G] [topological_add_group G] (x : G) (y : G) : nhds (x + y) = nhds x + nhds y := sorry\n\ntheorem nhds_is_mul_hom {G : Type w} [topological_space G] [comm_group G] [topological_group G] : is_mul_hom fun (x : G) => nhds x :=\n  is_mul_hom.mk fun (_x _x_1 : G) => nhds_mul _x _x_1\n\nprotected instance additive.topological_add_group {G : Type u_1} [h : topological_space G] [group G] [topological_group G] : topological_add_group (additive G) :=\n  topological_add_group.mk continuous_inv\n\nprotected instance multiplicative.topological_group {G : Type u_1} [h : topological_space G] [add_group G] [topological_add_group G] : topological_group (multiplicative G) :=\n  topological_group.mk continuous_neg\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.47011094846161594}}
{"text": "-- 6.4 Attributes\n\nvariable {α : Type*}\n\ndef is_prefix (l₁ : list α) (l₂ : list α ) : Prop :=\n∃ t, l₁ ++ t = l₂\n\ninfix ` <+: `:50 := is_prefix\n\nattribute [simp]\ntheorem list.is_prefix_refl (l : list α) : l <+: l :=\n⟨[], by simp⟩\n\nexample : [1, 2, 3] <+: [1, 2, 3] := by simp\n\n@[simp]\ntheorem list.is_prefix_refl' (l : list α) : l <+: l :=\n⟨[], by simp⟩\n\ntheorem list.is_prefix_refl'' (l : list α) : l <+: l :=\n⟨[], by simp⟩\n\nattribute [simp] list.is_prefix_refl''\n", "meta": {"author": "agryman", "repo": "theorem-proving-in-lean", "sha": "cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9", "save_path": "github-repos/lean/agryman-theorem-proving-in-lean", "path": "github-repos/lean/agryman-theorem-proving-in-lean/theorem-proving-in-lean-cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9/src/06-Interacting-with-Lean/example-6.4-1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.47011094066463904}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.homology.image_to_kernel\nimport algebra.homology.homological_complex\nimport category_theory.graded_object\n\n/-!\n# The homology of a complex\n\nGiven `C : homological_complex V c`, we have `C.cycles i` and `C.boundaries i`,\nboth defined as subobjects of `C.X i`.\n\nWe show these are functorial with respect to chain maps,\nas `C.cycles_map f i` and `C.boundaries_map f i`.\n\nAs a consequence we construct `homology_functor i : homological_complex V c ⥤ V`,\ncomputing the `i`-th homology.\n-/\n\nuniverses v u\n\nopen category_theory category_theory.limits\n\nvariables {ι : Type*}\nvariables {V : Type u} [category.{v} V] [has_zero_morphisms V]\nvariables {c : complex_shape ι} (C : homological_complex V c)\n\nopen_locale classical zero_object\nnoncomputable theory\n\nnamespace homological_complex\n\nvariables [has_zero_object V]\n\nsection cycles\nvariables [has_kernels V]\n\n/-- The cycles at index `i`, as a subobject. -/\ndef cycles (i : ι) : subobject (C.X i) :=\nkernel_subobject (C.d_from i)\n\n@[simp, reassoc]\nlemma cycles_arrow_d_from (i : ι) : (C.cycles i).arrow ≫ C.d_from i = 0 :=\nby { dsimp [cycles], simp, }\n\nlemma cycles_eq_kernel_subobject {i j : ι} (r : c.rel i j) :\n  C.cycles i = kernel_subobject (C.d i j) :=\nC.kernel_from_eq_kernel r\n\n/--\nThe underlying object of `C.cycles i` is isomorphic to `kernel (C.d i j)`,\nfor any `j` such that `rel i j`.\n-/\ndef cycles_iso_kernel {i j : ι} (r : c.rel i j) :\n  (C.cycles i : V) ≅ kernel (C.d i j) :=\nsubobject.iso_of_eq _ _ (C.cycles_eq_kernel_subobject r) ≪≫\n  kernel_subobject_iso (C.d i j)\n\nlemma cycles_eq_top {i} (h : c.next i = none) : C.cycles i = ⊤ :=\nbegin\n  rw eq_top_iff,\n  apply le_kernel_subobject,\n  rw [C.d_from_eq_zero h, comp_zero],\nend\n\nend cycles\n\nsection boundaries\nvariables [has_images V]\n\n/-- The boundaries at index `i`, as a subobject. -/\nabbreviation boundaries (C : homological_complex V c) (j : ι) : subobject (C.X j) :=\nimage_subobject (C.d_to j)\n\nlemma boundaries_eq_image_subobject [has_equalizers V] {i j : ι} (r : c.rel i j) :\n  C.boundaries j = image_subobject (C.d i j) :=\nC.image_to_eq_image r\n\n/--\nThe underlying object of `C.boundaries j` is isomorphic to `image (C.d i j)`,\nfor any `i` such that `rel i j`.\n-/\ndef boundaries_iso_image [has_equalizers V] {i j : ι} (r : c.rel i j) :\n  (C.boundaries j : V) ≅ image (C.d i j) :=\nsubobject.iso_of_eq _ _ (C.boundaries_eq_image_subobject r) ≪≫\n  image_subobject_iso (C.d i j)\n\nlemma boundaries_eq_bot {j} (h : c.prev j = none) : C.boundaries j = ⊥ :=\nbegin\n  rw eq_bot_iff,\n  refine image_subobject_le _ 0 _,\n  rw [C.d_to_eq_zero h, zero_comp],\nend\n\nend boundaries\n\nsection\nvariables [has_kernels V] [has_images V]\n\nlemma boundaries_le_cycles (C : homological_complex V c) (i : ι) :\n  C.boundaries i ≤ C.cycles i :=\nimage_le_kernel _ _ (C.d_to_comp_d_from i)\n\n/--\nThe canonical map from `boundaries i` to `cycles i`.\n-/\nabbreviation boundaries_to_cycles (C : homological_complex V c) (i : ι) :\n  (C.boundaries i : V) ⟶ (C.cycles i : V) :=\nimage_to_kernel _ _ (C.d_to_comp_d_from i)\n\n/-- Prefer `boundaries_to_cycles`. -/\n@[simp] lemma image_to_kernel_as_boundaries_to_cycles (C : homological_complex V c) (i : ι) (h) :\n  (C.boundaries i).of_le (C.cycles i) h = C.boundaries_to_cycles i :=\nrfl\n\n@[simp, reassoc]\nlemma boundaries_to_cycles_arrow (C : homological_complex V c) (i : ι) :\n  C.boundaries_to_cycles i ≫ (C.cycles i).arrow = (C.boundaries i).arrow :=\nby { dsimp [cycles], simp, }\n\nvariables [has_cokernels V]\n\n/--\nThe homology of a complex at index `i`.\n-/\nabbreviation homology (C : homological_complex V c) (i : ι) : V :=\nhomology (C.d_to i) (C.d_from i) (C.d_to_comp_d_from i)\n\nend\n\nend homological_complex\n\nopen homological_complex\n\n/-! Computing the cycles is functorial. -/\nsection\nvariables [has_zero_object V] [has_kernels V]\nvariables {C₁ C₂ C₃ : homological_complex V c} (f : C₁ ⟶ C₂)\n\n/--\nThe morphism between cycles induced by a chain map.\n-/\nabbreviation cycles_map (f : C₁ ⟶ C₂) (i : ι) : (C₁.cycles i : V) ⟶ (C₂.cycles i : V) :=\nsubobject.factor_thru _ ((C₁.cycles i).arrow ≫ f.f i) (kernel_subobject_factors _ _ (by simp))\n\n@[simp] lemma cycles_map_arrow (f : C₁ ⟶ C₂) (i : ι) :\n  (cycles_map f i) ≫ (C₂.cycles i).arrow = (C₁.cycles i).arrow ≫ f.f i :=\nby { simp, }\n\n@[simp] lemma cycles_map_id (i : ι) : cycles_map (𝟙 C₁) i = 𝟙 _ :=\nby { dunfold cycles_map, simp, }\n\n@[simp] lemma cycles_map_comp (f : C₁ ⟶ C₂) (g : C₂ ⟶ C₃) (i : ι) :\n  cycles_map (f ≫ g) i = cycles_map f i ≫ cycles_map g i :=\nby { dunfold cycles_map, simp [subobject.factor_thru_right], }\n\nvariables (V c)\n\n/-- Cycles as a functor. -/\n@[simps]\ndef cycles_functor (i : ι) : homological_complex V c ⥤ V :=\n{ obj := λ C, C.cycles i,\n  map := λ C₁ C₂ f, cycles_map f i, }\n\nend\n\n/-! Computing the boundaries is functorial. -/\nsection\nvariables [has_zero_object V] [has_images V] [has_image_maps V]\nvariables {C₁ C₂ C₃ : homological_complex V c} (f : C₁ ⟶ C₂)\n\n/--\nThe morphism between boundaries induced by a chain map.\n-/\nabbreviation boundaries_map (f : C₁ ⟶ C₂) (i : ι) : (C₁.boundaries i : V) ⟶ (C₂.boundaries i : V) :=\nimage_subobject_map (f.sq_to i)\n\nvariables (V c)\n\n/-- Boundaries as a functor. -/\n@[simps]\ndef boundaries_functor (i : ι) : homological_complex V c ⥤ V :=\n{ obj := λ C, C.boundaries i,\n  map := λ C₁ C₂ f, image_subobject_map (f.sq_to i), }\n\nend\n\nsection\n\n/-! The `boundaries_to_cycles` morphisms are natural. -/\nvariables [has_zero_object V] [has_equalizers V] [has_images V] [has_image_maps V]\nvariables {C₁ C₂ : homological_complex V c} (f : C₁ ⟶ C₂)\n\n@[simp, reassoc]\nlemma boundaries_to_cycles_naturality (i : ι) :\n  boundaries_map f i ≫ C₂.boundaries_to_cycles i = C₁.boundaries_to_cycles i ≫ cycles_map f i :=\nby { ext, simp, }\n\nvariables (V c)\n\n/-- The natural transformation from the boundaries functor to the cycles functor. -/\n@[simps] def boundaries_to_cycles_nat_trans (i : ι) :\n  boundaries_functor V c i ⟶ cycles_functor V c i :=\n{ app := λ C, C.boundaries_to_cycles i,\n  naturality' := λ C₁ C₂ f, boundaries_to_cycles_naturality f i, }\n\n/-- The `i`-th homology, as a functor to `V`. -/\n@[simps]\ndef homology_functor [has_cokernels V] (i : ι) :\n  homological_complex V c ⥤ V :=\n-- It would be nice if we could just write\n-- `cokernel (boundaries_to_cycles_nat_trans V c i)`\n-- here, but universe implementation details get in the way...\n{ obj := λ C, C.homology i,\n  map := λ C₁ C₂ f, _root_.homology.map _ _ (f.sq_to i) (f.sq_from i) rfl,\n  map_id' :=\n  begin\n    intros, ext1,\n    simp only [homology.π_map, kernel_subobject_map_id, hom.sq_from_id,\n      category.id_comp, category.comp_id]\n  end,\n  map_comp' :=\n  begin\n    intros, ext1,\n    simp only [hom.sq_from_comp, kernel_subobject_map_comp, homology.π_map_assoc,\n      homology.π_map, category.assoc]\n  end }\n\n/-- The homology functor from `ι`-indexed complexes to `ι`-graded objects in `V`. -/\n@[simps] def graded_homology_functor [has_cokernels V] :\n  homological_complex V c ⥤ graded_object ι V :=\n{ obj := λ C i, C.homology i,\n  map := λ C C' f i, (homology_functor V c i).map f,\n  map_id' :=\n  begin\n    intros, ext,\n    simp only [pi.id_apply, homology.π_map, homology_functor_map, kernel_subobject_map_id,\n      hom.sq_from_id, category.id_comp, category.comp_id]\n  end,\n  map_comp' :=\n  begin\n    intros, ext,\n    simp only [hom.sq_from_comp, kernel_subobject_map_comp, homology.π_map_assoc,\n      pi.comp_apply, homology.π_map, homology_functor_map, category.assoc]\n  end }\n\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/homology/homology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.47011093869230164}}
{"text": "-- La_funcion_relacionP_es_inversa_por_la_izquierda_de_la_funcion_cociente.lean\n-- La función relacionP es inversa por la izquierda de la función cociente\n-- José A. Alonso Jiménez\n-- Sevilla, 13 de octubre de 2021\n-- ---------------------------------------------------------------------\n\n-- ---------------------------------------------------------------------\n-- Demostrar que relacionP es inversa por la izquierda de cociente.\n-- ---------------------------------------------------------------------\n\nimport tactic\n\n@[ext] structure particion (A : Type) :=\n(Bloques    : set (set A))\n(Hno_vacios : ∀ X ∈ Bloques, (X : set A).nonempty)\n(Hrecubren  : ∀ a, ∃ X ∈ Bloques, a ∈ X)\n(Hdisjuntos : ∀ X Y ∈ Bloques, (X ∩ Y : set A).nonempty → X = Y)\n\nnamespace particion\n\nvariable  {A : Type}\nvariables {X Y : set A}\nvariable  {P : particion A}\nvariable  (R : A → A → Prop)\n\ndef clase (a : A) :=\n  {b : A | R b a}\n\ndef clases : (A → A → Prop) → set (set A) :=\n  λ R, {B : set A | ∃ x : A, B = clase R x}\n\nlemma pertenece_clase_syss\n  {a b : A}\n  : b ∈ clase R a ↔ R b a :=\nby refl\n\nlemma clases_no_vacias\n  (hR: equivalence R)\n  : ∀ (X : set A), X ∈ clases R → X.nonempty :=\nbegin\n  rintros _ ⟨a, rfl⟩,\n  use a,\n  rw pertenece_clase_syss,\n  apply hR.1,\nend\n\nlemma clases_recubren\n  (hR: equivalence R)\n  : ∀ a, ∃ X ∈ clases R, a ∈ X :=\nbegin\n  intro a,\n  use clase R a,\n  split,\n  { use a, },\n  { exact hR.1 a, },\nend\n\nlemma subclase_si_pertenece\n  {R : A → A → Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a ∈ clase R b → clase R a ⊆ clase R b :=\nλ hab z hza, hR.2.2 hza hab\n\nlemma clases_iguales_si_pertenece\n  {R : A → A → Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a ∈ clase R b → clase R a = clase R b :=\nλ hab, set.subset.antisymm\n        (subclase_si_pertenece hR hab)\n        (subclase_si_pertenece hR (hR.2.1 hab))\n\nlemma clases_disjuntas\n  (hR: equivalence R)\n  : ∀ X Y ∈ clases R, (X ∩ Y : set A).nonempty → X = Y :=\nbegin\n  rintros X ⟨a, rfl⟩ Y ⟨b, rfl⟩ ⟨c, hca, hcb⟩,\n  exact clases_iguales_si_pertenece hR (hR.2.2 (hR.2.1 hca) hcb),\nend\n\ndef cociente : {R : A → A → Prop // equivalence R} → particion A :=\n  λ R, { Bloques    := {B : set A | ∃ x : A, B = clase R.1 x},\n         Hno_vacios := clases_no_vacias R.1 R.2,\n         Hrecubren  := clases_recubren R.1 R.2,\n         Hdisjuntos := clases_disjuntas R.1 R.2, }\n\ndef relacion : (particion A) → (A → A → Prop) :=\n  λ P a b, ∀ X ∈ Bloques P, a ∈ X → b ∈ X\n\nlemma reflexiva\n  (P : particion A)\n  : reflexive (relacion P) :=\nλ a X hXC haX, haX\n\nlemma iguales_si_comun\n  (hX : X ∈ Bloques P)\n  (hY : Y ∈ Bloques P)\n  {a : A}\n  (haX : a ∈ X)\n  (haY : a ∈ Y)\n  : X = Y :=\nHdisjuntos P X hX Y hY ⟨a, haX, haY⟩\n\nlemma pertenece_si_pertenece\n  (hX : X ∈ Bloques P)\n  (hY : Y ∈ Bloques P)\n  {a b : A}\n  (haX : a ∈ X)\n  (haY : a ∈ Y)\n  (hbX : b ∈ X)\n  : b ∈ Y :=\nbegin\n  convert hbX,\n  exact iguales_si_comun hY hX haY haX,\nend\n\nlemma simetrica\n  (P : particion A)\n  : symmetric (relacion P) :=\nbegin\n  intros a b h X hX hbX,\n  obtain ⟨Y, hY, haY⟩ := Hrecubren P a,\n  specialize h Y hY haY,\n  exact pertenece_si_pertenece hY hX h hbX haY,\nend\n\nlemma transitiva\n  (P : particion A)\n  : transitive (relacion P) :=\nλ a b c hab hbc X hX haX, hbc X hX (hab X hX haX)\n\ndef relacionP : particion A → {R : A → A → Prop // equivalence R} :=\n  λ P, ⟨λ a b, ∀ X ∈ Bloques P, a ∈ X → b ∈ X,\n        ⟨reflexiva P, simetrica P, transitiva P⟩⟩\n\n-- 1ª demostración\nexample :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  unfold function.left_inverse,\n  intro S,\n  cases S with R hR,\n  unfold relacionP cociente relacion,\n  simp,\n  ext a b,\n  split,\n  { intros hab,\n    apply hR.2.1,\n    unfold clase at hab,\n    dsimp at hab,\n    apply hab,\n    apply hR.1, },\n  { intros hab c hac,\n    unfold clase at *,\n    dsimp at *,\n    apply hR.2.2 (hR.2.1 hab) hac, },\nend\n\n-- 2ª demostración\nexample :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro ⟨R, hR⟩,\n  simp [relacionP, cociente],\n  ext a b,\n  split,\n  { intros hab,\n    apply hR.2.1,\n    apply hab,\n    apply hR.1, },\n  { intros hab c hac,\n    apply hR.2.2 (hR.2.1 hab) hac, },\nend\n\n-- 3ª demostración\nexample :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro ⟨R, hR⟩,\n  simp [relacionP, cociente],\n  ext a b,\n  split,\n  { intros hab,\n    exact hR.2.1 (hab a (hR.1 a)), },\n  { intros hab c hac,\n    exact hR.2.2 (hR.2.1 hab) hac, },\nend\n\n-- 4ª demostración\nexample :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro ⟨R, hR⟩,\n  simp [relacionP, cociente],\n  ext a b,\n  split,\n  { exact λ hab, hR.2.1 (hab a (hR.1 a)), },\n  { exact λ hab c hac, hR.2.2 (hR.2.1 hab) hac, },\nend\n\n-- 5ª demostración\nlemma inversa_izq :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro ⟨R, hR⟩,\n  simp [relacionP, cociente],\n  ext a b,\n  exact ⟨λ hab, hR.2.1 (hab a (hR.1 a)),\n         λ hab c hac, hR.2.2 (hR.2.1 hab) hac⟩,\nend\n\nend particion\n", "meta": {"author": "jaalonso", "repo": "Calculemus", "sha": "0fb664ab298c0e90b4b8034729a2cdad20503e18", "save_path": "github-repos/lean/jaalonso-Calculemus", "path": "github-repos/lean/jaalonso-Calculemus/Calculemus-0fb664ab298c0e90b4b8034729a2cdad20503e18/src/La_funcion_relacionP_es_inversa_por_la_izquierda_de_la_funcion_cociente.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548511303338, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.47011093869230164}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\n! This file was ported from Lean 3 source module measure_theory.measure.measure_space\n! leanprover-community/mathlib commit 97d1aa955750bd57a7eeef91de310e633881670b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.MeasureTheory.Measure.NullMeasurable\nimport Mathbin.MeasureTheory.MeasurableSpace\nimport Mathbin.Topology.Algebra.Order.LiminfLimsup\n\n/-!\n# Measure spaces\n\nThe definition of a measure and a measure space are in `measure_theory.measure_space_def`, with\nonly a few basic properties. This file provides many more properties of these objects.\nThis separation allows the measurability tactic to import only the file `measure_space_def`, and to\nbe available in `measure_space` (through `measurable_space`).\n\nGiven a measurable space `α`, a measure on `α` is a function that sends measurable sets to the\nextended nonnegative reals that satisfies the following conditions:\n1. `μ ∅ = 0`;\n2. `μ` is countably additive. This means that the measure of a countable union of pairwise disjoint\n   sets is equal to the measure of the individual sets.\n\nEvery measure can be canonically extended to an outer measure, so that it assigns values to\nall subsets, not just the measurable subsets. On the other hand, a measure that is countably\nadditive on measurable sets can be restricted to measurable sets to obtain a measure.\nIn this file a measure is defined to be an outer measure that is countably additive on\nmeasurable sets, with the additional assumption that the outer measure is the canonical\nextension of the restricted measure.\n\nMeasures on `α` form a complete lattice, and are closed under scalar multiplication with `ℝ≥0∞`.\n\nWe introduce the following typeclasses for measures:\n\n* `is_probability_measure μ`: `μ univ = 1`;\n* `is_finite_measure μ`: `μ univ < ∞`;\n* `sigma_finite μ`: there exists a countable collection of sets that cover `univ`\n  where `μ` is finite;\n* `is_locally_finite_measure μ` : `∀ x, ∃ s ∈ 𝓝 x, μ s < ∞`;\n* `has_no_atoms μ` : `∀ x, μ {x} = 0`; possibly should be redefined as\n  `∀ s, 0 < μ s → ∃ t ⊆ s, 0 < μ t ∧ μ t < μ s`.\n\nGiven a measure, the null sets are the sets where `μ s = 0`, where `μ` denotes the corresponding\nouter measure (so `s` might not be measurable). We can then define the completion of `μ` as the\nmeasure on the least `σ`-algebra that also contains all null sets, by defining the measure to be `0`\non the null sets.\n\n## Main statements\n\n* `completion` is the completion of a measure to all null measurable sets.\n* `measure.of_measurable` and `outer_measure.to_measure` are two important ways to define a measure.\n\n## Implementation notes\n\nGiven `μ : measure α`, `μ s` is the value of the *outer measure* applied to `s`.\nThis conveniently allows us to apply the measure to sets without proving that they are measurable.\nWe get countable subadditivity for all sets, but only countable additivity for measurable sets.\n\nYou often don't want to define a measure via its constructor.\nTwo ways that are sometimes more convenient:\n* `measure.of_measurable` is a way to define a measure by only giving its value on measurable sets\n  and proving the properties (1) and (2) mentioned above.\n* `outer_measure.to_measure` is a way of obtaining a measure from an outer measure by showing that\n  all measurable sets in the measurable space are Carathéodory measurable.\n\nTo prove that two measures are equal, there are multiple options:\n* `ext`: two measures are equal if they are equal on all measurable sets.\n* `ext_of_generate_from_of_Union`: two measures are equal if they are equal on a π-system generating\n  the measurable sets, if the π-system contains a spanning increasing sequence of sets where the\n  measures take finite value (in particular the measures are σ-finite). This is a special case of\n  the more general `ext_of_generate_from_of_cover`\n* `ext_of_generate_finite`: two finite measures are equal if they are equal on a π-system\n  generating the measurable sets. This is a special case of `ext_of_generate_from_of_Union` using\n  `C ∪ {univ}`, but is easier to work with.\n\nA `measure_space` is a class that is a measurable space with a canonical measure.\nThe measure is denoted `volume`.\n\n## References\n\n* <https://en.wikipedia.org/wiki/Measure_(mathematics)>\n* <https://en.wikipedia.org/wiki/Complete_measure>\n* <https://en.wikipedia.org/wiki/Almost_everywhere>\n\n## Tags\n\nmeasure, almost everywhere, measure space, completion, null set, null measurable set\n-/\n\n\nnoncomputable section\n\nopen Set\n\nopen Filter hiding map\n\nopen Function MeasurableSpace\n\nopen TopologicalSpace (SecondCountableTopology)\n\nopen Classical Topology BigOperators Filter ENNReal NNReal Interval MeasureTheory\n\nvariable {α β γ δ ι R R' : Type _}\n\nnamespace MeasureTheory\n\nsection\n\nvariable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}\n\ninstance ae_isMeasurablyGenerated : IsMeasurablyGenerated μ.ae :=\n  ⟨fun s hs =>\n    let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs\n    ⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩\n#align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated\n\n/-- See also `measure_theory.ae_restrict_uIoc_iff`. -/\ntheorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :\n    (∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by\n  simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]\n#align measure_theory.ae_uIoc_iff MeasureTheory.ae_uIoc_iff\n\ntheorem measure_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=\n  measure_union₀ h.NullMeasurableSet hd.AeDisjoint\n#align measure_theory.measure_union MeasureTheory.measure_union\n\ntheorem measure_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=\n  measure_union₀' h.NullMeasurableSet hd.AeDisjoint\n#align measure_theory.measure_union' MeasureTheory.measure_union'\n\ntheorem measure_inter_add_diff (s : Set α) (ht : MeasurableSet t) : μ (s ∩ t) + μ (s \\ t) = μ s :=\n  measure_inter_add_diff₀ _ ht.NullMeasurableSet\n#align measure_theory.measure_inter_add_diff MeasureTheory.measure_inter_add_diff\n\ntheorem measure_diff_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s \\ t) + μ (s ∩ t) = μ s :=\n  (add_comm _ _).trans (measure_inter_add_diff s ht)\n#align measure_theory.measure_diff_add_inter MeasureTheory.measure_diff_add_inter\n\ntheorem measure_union_add_inter (s : Set α) (ht : MeasurableSet t) :\n    μ (s ∪ t) + μ (s ∩ t) = μ s + μ t :=\n  by\n  rw [← measure_inter_add_diff (s ∪ t) ht, Set.union_inter_cancel_right, union_diff_right, ←\n    measure_inter_add_diff s ht]\n  ac_rfl\n#align measure_theory.measure_union_add_inter MeasureTheory.measure_union_add_inter\n\ntheorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) :\n    μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by\n  rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm]\n#align measure_theory.measure_union_add_inter' MeasureTheory.measure_union_add_inter'\n\ntheorem measure_add_measure_compl (h : MeasurableSet s) : μ s + μ (sᶜ) = μ univ :=\n  measure_add_measure_compl₀ h.NullMeasurableSet\n#align measure_theory.measure_add_measure_compl MeasureTheory.measure_add_measure_compl\n\ntheorem measure_bUnion₀ {s : Set β} {f : β → Set α} (hs : s.Countable)\n    (hd : s.Pairwise (AeDisjoint μ on f)) (h : ∀ b ∈ s, NullMeasurableSet (f b) μ) :\n    μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=\n  by\n  haveI := hs.to_encodable\n  rw [bUnion_eq_Union]\n  exact measure_Union₀ (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2\n#align measure_theory.measure_bUnion₀ MeasureTheory.measure_bUnion₀\n\ntheorem measure_bUnion {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.PairwiseDisjoint f)\n    (h : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=\n  measure_bUnion₀ hs hd.AeDisjoint fun b hb => (h b hb).NullMeasurableSet\n#align measure_theory.measure_bUnion MeasureTheory.measure_bUnion\n\ntheorem measure_sUnion₀ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise (AeDisjoint μ))\n    (h : ∀ s ∈ S, NullMeasurableSet s μ) : μ (⋃₀ S) = ∑' s : S, μ s := by\n  rw [sUnion_eq_bUnion, measure_bUnion₀ hs hd h]\n#align measure_theory.measure_sUnion₀ MeasureTheory.measure_sUnion₀\n\ntheorem measure_unionₛ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise Disjoint)\n    (h : ∀ s ∈ S, MeasurableSet s) : μ (⋃₀ S) = ∑' s : S, μ s := by\n  rw [sUnion_eq_bUnion, measure_bUnion hs hd h]\n#align measure_theory.measure_sUnion MeasureTheory.measure_unionₛ\n\ntheorem measure_bUnion_finset₀ {s : Finset ι} {f : ι → Set α}\n    (hd : Set.Pairwise (↑s) (AeDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) :\n    μ (⋃ b ∈ s, f b) = ∑ p in s, μ (f p) :=\n  by\n  rw [← Finset.sum_attach, Finset.attach_eq_univ, ← tsum_fintype]\n  exact measure_bUnion₀ s.countable_to_set hd hm\n#align measure_theory.measure_bUnion_finset₀ MeasureTheory.measure_bUnion_finset₀\n\ntheorem measure_bUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f)\n    (hm : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑ p in s, μ (f p) :=\n  measure_bUnion_finset₀ hd.AeDisjoint fun b hb => (hm b hb).NullMeasurableSet\n#align measure_theory.measure_bUnion_finset MeasureTheory.measure_bUnion_finset\n\n/-- The measure of a disjoint union (even uncountable) of measurable sets is at least the sum of\nthe measures of the sets. -/\ntheorem tsum_meas_le_meas_unionᵢ_of_disjoint {ι : Type _} [MeasurableSpace α] (μ : Measure α)\n    {As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) :=\n  by\n  rcases show Summable fun i => μ (As i) from ENNReal.summable with ⟨S, hS⟩\n  rw [hS.tsum_eq]\n  refine' tendsto_le_of_eventuallyLE hS tendsto_const_nhds (eventually_of_forall _)\n  intro s\n  rw [← measure_bUnion_finset (fun i hi j hj hij => As_disj hij) fun i _ => As_mble i]\n  exact measure_mono (Union₂_subset_Union (fun i : ι => i ∈ s) fun i : ι => As i)\n#align measure_theory.tsum_meas_le_meas_Union_of_disjoint MeasureTheory.tsum_meas_le_meas_unionᵢ_of_disjoint\n\n/-- If `s` is a countable set, then the measure of its preimage can be found as the sum of measures\nof the fibers `f ⁻¹' {y}`. -/\ntheorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α → β}\n    (hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑' b : s, μ (f ⁻¹' {↑b})) = μ (f ⁻¹' s) := by\n  rw [← Set.bunionᵢ_preimage_singleton, measure_bUnion hs (pairwise_disjoint_fiber _ _) hf]\n#align measure_theory.tsum_measure_preimage_singleton MeasureTheory.tsum_measure_preimage_singleton\n\n/-- If `s` is a `finset`, then the measure of its preimage can be found as the sum of measures\nof the fibers `f ⁻¹' {y}`. -/\ntheorem sum_measure_preimage_singleton (s : Finset β) {f : α → β}\n    (hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑ b in s, μ (f ⁻¹' {b})) = μ (f ⁻¹' ↑s) := by\n  simp only [← measure_bUnion_finset (pairwise_disjoint_fiber _ _) hf,\n    Finset.set_bunionᵢ_preimage_singleton]\n#align measure_theory.sum_measure_preimage_singleton MeasureTheory.sum_measure_preimage_singleton\n\ntheorem measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \\ s₂) = μ s₁ :=\n  measure_congr <| diff_ae_eq_self.2 h\n#align measure_theory.measure_diff_null' MeasureTheory.measure_diff_null'\n\ntheorem measure_diff_null (h : μ s₂ = 0) : μ (s₁ \\ s₂) = μ s₁ :=\n  measure_diff_null' <| measure_mono_null (inter_subset_right _ _) h\n#align measure_theory.measure_diff_null MeasureTheory.measure_diff_null\n\ntheorem measure_add_diff (hs : MeasurableSet s) (t : Set α) : μ s + μ (t \\ s) = μ (s ∪ t) := by\n  rw [← measure_union' disjoint_sdiff_right hs, union_diff_self]\n#align measure_theory.measure_add_diff MeasureTheory.measure_add_diff\n\ntheorem measure_diff' (s : Set α) (hm : MeasurableSet t) (h_fin : μ t ≠ ∞) :\n    μ (s \\ t) = μ (s ∪ t) - μ t :=\n  Eq.symm <| ENNReal.sub_eq_of_add_eq h_fin <| by rw [add_comm, measure_add_diff hm, union_comm]\n#align measure_theory.measure_diff' MeasureTheory.measure_diff'\n\ntheorem measure_diff (h : s₂ ⊆ s₁) (h₂ : MeasurableSet s₂) (h_fin : μ s₂ ≠ ∞) :\n    μ (s₁ \\ s₂) = μ s₁ - μ s₂ := by rw [measure_diff' _ h₂ h_fin, union_eq_self_of_subset_right h]\n#align measure_theory.measure_diff MeasureTheory.measure_diff\n\ntheorem le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \\ s₂) :=\n  tsub_le_iff_left.2 <|\n    calc\n      μ s₁ ≤ μ (s₂ ∪ s₁) := measure_mono (subset_union_right _ _)\n      _ = μ (s₂ ∪ s₁ \\ s₂) := (congr_arg μ union_diff_self.symm)\n      _ ≤ μ s₂ + μ (s₁ \\ s₂) := measure_union_le _ _\n      \n#align measure_theory.le_measure_diff MeasureTheory.le_measure_diff\n\ntheorem measure_diff_lt_of_lt_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞}\n    (h : μ t < μ s + ε) : μ (t \\ s) < ε :=\n  by\n  rw [measure_diff hst hs hs']; rw [add_comm] at h\n  exact ENNReal.sub_lt_of_lt_add (measure_mono hst) h\n#align measure_theory.measure_diff_lt_of_lt_add MeasureTheory.measure_diff_lt_of_lt_add\n\ntheorem measure_diff_le_iff_le_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} :\n    μ (t \\ s) ≤ ε ↔ μ t ≤ μ s + ε := by rwa [measure_diff hst hs hs', tsub_le_iff_left]\n#align measure_theory.measure_diff_le_iff_le_add MeasureTheory.measure_diff_le_iff_le_add\n\ntheorem measure_eq_measure_of_null_diff {s t : Set α} (hst : s ⊆ t) (h_nulldiff : μ (t \\ s) = 0) :\n    μ s = μ t :=\n  measure_congr (hst.EventuallyLE.antisymm <| ae_le_set.mpr h_nulldiff)\n#align measure_theory.measure_eq_measure_of_null_diff MeasureTheory.measure_eq_measure_of_null_diff\n\ntheorem measure_eq_measure_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃)\n    (h_nulldiff : μ (s₃ \\ s₁) = 0) : μ s₁ = μ s₂ ∧ μ s₂ = μ s₃ :=\n  by\n  have le12 : μ s₁ ≤ μ s₂ := measure_mono h12\n  have le23 : μ s₂ ≤ μ s₃ := measure_mono h23\n  have key : μ s₃ ≤ μ s₁ :=\n    calc\n      μ s₃ = μ (s₃ \\ s₁ ∪ s₁) := by rw [diff_union_of_subset (h12.trans h23)]\n      _ ≤ μ (s₃ \\ s₁) + μ s₁ := (measure_union_le _ _)\n      _ = μ s₁ := by simp only [h_nulldiff, zero_add]\n      \n  exact ⟨le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)⟩\n#align measure_theory.measure_eq_measure_of_between_null_diff MeasureTheory.measure_eq_measure_of_between_null_diff\n\ntheorem measure_eq_measure_smaller_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)\n    (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \\ s₁) = 0) : μ s₁ = μ s₂ :=\n  (measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1\n#align measure_theory.measure_eq_measure_smaller_of_between_null_diff MeasureTheory.measure_eq_measure_smaller_of_between_null_diff\n\ntheorem measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)\n    (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \\ s₁) = 0) : μ s₂ = μ s₃ :=\n  (measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2\n#align measure_theory.measure_eq_measure_larger_of_between_null_diff MeasureTheory.measure_eq_measure_larger_of_between_null_diff\n\ntheorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ (sᶜ) = μ univ - μ s :=\n  by\n  rw [compl_eq_univ_diff]\n  exact measure_diff (subset_univ s) h₁ h_fin\n#align measure_theory.measure_compl MeasureTheory.measure_compl\n\n@[simp]\ntheorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ᵐ[μ] s :=\n  by\n  rw [ae_le_set]\n  refine'\n    ⟨fun h => by simpa only [union_diff_left] using (ae_eq_set.mp h).1, fun h =>\n      eventually_le_antisymm_iff.mpr\n        ⟨by rwa [ae_le_set, union_diff_left],\n          HasSubset.Subset.eventuallyLE <| subset_union_left s t⟩⟩\n#align measure_theory.union_ae_eq_left_iff_ae_subset MeasureTheory.union_ae_eq_left_iff_ae_subset\n\n@[simp]\ntheorem union_ae_eq_right_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] t ↔ s ≤ᵐ[μ] t := by\n  rw [union_comm, union_ae_eq_left_iff_ae_subset]\n#align measure_theory.union_ae_eq_right_iff_ae_subset MeasureTheory.union_ae_eq_right_iff_ae_subset\n\ntheorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)\n    (ht : μ t ≠ ∞) : s =ᵐ[μ] t :=\n  by\n  refine' eventually_le_antisymm_iff.mpr ⟨h₁, ae_le_set.mpr _⟩\n  replace h₂ : μ t = μ s; exact h₂.antisymm (measure_mono_ae h₁)\n  replace ht : μ s ≠ ∞; exact h₂ ▸ ht\n  rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h₁), h₂, tsub_self]\n#align measure_theory.ae_eq_of_ae_subset_of_measure_ge MeasureTheory.ae_eq_of_ae_subset_of_measure_ge\n\n/-- If `s ⊆ t`, `μ t ≤ μ s`, `μ t ≠ ∞`, and `s` is measurable, then `s =ᵐ[μ] t`. -/\ntheorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)\n    (ht : μ t ≠ ∞) : s =ᵐ[μ] t :=\n  ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h₁) h₂ hsm ht\n#align measure_theory.ae_eq_of_subset_of_measure_ge MeasureTheory.ae_eq_of_subset_of_measure_ge\n\ntheorem measure_unionᵢ_congr_of_subset [Countable β] {s : β → Set α} {t : β → Set α}\n    (hsub : ∀ b, s b ⊆ t b) (h_le : ∀ b, μ (t b) ≤ μ (s b)) : μ (⋃ b, s b) = μ (⋃ b, t b) :=\n  by\n  rcases em (∃ b, μ (t b) = ∞) with (⟨b, hb⟩ | htop)\n  ·\n    calc\n      μ (⋃ b, s b) = ∞ := top_unique (hb ▸ (h_le b).trans <| measure_mono <| subset_Union _ _)\n      _ = μ (⋃ b, t b) := Eq.symm <| top_unique <| hb ▸ measure_mono <| subset_Union _ _\n      \n  push_neg  at htop\n  refine' le_antisymm (measure_mono (Union_mono hsub)) _\n  set M := to_measurable μ\n  have H : ∀ b, (M (t b) ∩ M (⋃ b, s b) : Set α) =ᵐ[μ] M (t b) :=\n    by\n    refine' fun b => ae_eq_of_subset_of_measure_ge (inter_subset_left _ _) _ _ _\n    ·\n      calc\n        μ (M (t b)) = μ (t b) := measure_to_measurable _\n        _ ≤ μ (s b) := (h_le b)\n        _ ≤ μ (M (t b) ∩ M (⋃ b, s b)) :=\n          measure_mono <|\n            subset_inter ((hsub b).trans <| subset_to_measurable _ _)\n              ((subset_Union _ _).trans <| subset_to_measurable _ _)\n        \n    · exact (measurable_set_to_measurable _ _).inter (measurable_set_to_measurable _ _)\n    · rw [measure_to_measurable]\n      exact htop b\n  calc\n    μ (⋃ b, t b) ≤ μ (⋃ b, M (t b)) := measure_mono (Union_mono fun b => subset_to_measurable _ _)\n    _ = μ (⋃ b, M (t b) ∩ M (⋃ b, s b)) := (measure_congr (EventuallyEq.countable_unionᵢ H).symm)\n    _ ≤ μ (M (⋃ b, s b)) := (measure_mono (Union_subset fun b => inter_subset_right _ _))\n    _ = μ (⋃ b, s b) := measure_to_measurable _\n    \n#align measure_theory.measure_Union_congr_of_subset MeasureTheory.measure_unionᵢ_congr_of_subset\n\ntheorem measure_union_congr_of_subset {t₁ t₂ : Set α} (hs : s₁ ⊆ s₂) (hsμ : μ s₂ ≤ μ s₁)\n    (ht : t₁ ⊆ t₂) (htμ : μ t₂ ≤ μ t₁) : μ (s₁ ∪ t₁) = μ (s₂ ∪ t₂) :=\n  by\n  rw [union_eq_Union, union_eq_Union]\n  exact measure_Union_congr_of_subset (Bool.forall_bool.2 ⟨ht, hs⟩) (Bool.forall_bool.2 ⟨htμ, hsμ⟩)\n#align measure_theory.measure_union_congr_of_subset MeasureTheory.measure_union_congr_of_subset\n\n@[simp]\ntheorem measure_unionᵢ_toMeasurable [Countable β] (s : β → Set α) :\n    μ (⋃ b, toMeasurable μ (s b)) = μ (⋃ b, s b) :=\n  Eq.symm <|\n    measure_unionᵢ_congr_of_subset (fun b => subset_toMeasurable _ _) fun b =>\n      (measure_toMeasurable _).le\n#align measure_theory.measure_Union_to_measurable MeasureTheory.measure_unionᵢ_toMeasurable\n\ntheorem measure_bUnion_toMeasurable {I : Set β} (hc : I.Countable) (s : β → Set α) :\n    μ (⋃ b ∈ I, toMeasurable μ (s b)) = μ (⋃ b ∈ I, s b) :=\n  by\n  haveI := hc.to_encodable\n  simp only [bUnion_eq_Union, measure_Union_to_measurable]\n#align measure_theory.measure_bUnion_to_measurable MeasureTheory.measure_bUnion_toMeasurable\n\n@[simp]\ntheorem measure_toMeasurable_union : μ (toMeasurable μ s ∪ t) = μ (s ∪ t) :=\n  Eq.symm <|\n    measure_union_congr_of_subset (subset_toMeasurable _ _) (measure_toMeasurable _).le Subset.rfl\n      le_rfl\n#align measure_theory.measure_to_measurable_union MeasureTheory.measure_toMeasurable_union\n\n@[simp]\ntheorem measure_union_toMeasurable : μ (s ∪ toMeasurable μ t) = μ (s ∪ t) :=\n  Eq.symm <|\n    measure_union_congr_of_subset Subset.rfl le_rfl (subset_toMeasurable _ _)\n      (measure_toMeasurable _).le\n#align measure_theory.measure_union_to_measurable MeasureTheory.measure_union_toMeasurable\n\ntheorem sum_measure_le_measure_univ {s : Finset ι} {t : ι → Set α}\n    (h : ∀ i ∈ s, MeasurableSet (t i)) (H : Set.PairwiseDisjoint (↑s) t) :\n    (∑ i in s, μ (t i)) ≤ μ (univ : Set α) :=\n  by\n  rw [← measure_bUnion_finset H h]\n  exact measure_mono (subset_univ _)\n#align measure_theory.sum_measure_le_measure_univ MeasureTheory.sum_measure_le_measure_univ\n\ntheorem tsum_measure_le_measure_univ {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))\n    (H : Pairwise (Disjoint on s)) : (∑' i, μ (s i)) ≤ μ (univ : Set α) :=\n  by\n  rw [ENNReal.tsum_eq_supᵢ_sum]\n  exact supᵢ_le fun s => sum_measure_le_measure_univ (fun i hi => hs i) fun i hi j hj hij => H hij\n#align measure_theory.tsum_measure_le_measure_univ MeasureTheory.tsum_measure_le_measure_univ\n\n/-- Pigeonhole principle for measure spaces: if `∑' i, μ (s i) > μ univ`, then\none of the intersections `s i ∩ s j` is not empty. -/\ntheorem exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : MeasurableSpace α}\n    (μ : Measure α) {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))\n    (H : μ (univ : Set α) < ∑' i, μ (s i)) : ∃ (i j : _)(h : i ≠ j), (s i ∩ s j).Nonempty :=\n  by\n  contrapose! H\n  apply tsum_measure_le_measure_univ hs\n  intro i j hij\n  rw [Function.onFun, disjoint_iff_inf_le]\n  exact fun x hx => H i j hij ⟨x, hx⟩\n#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure\n\n/-- Pigeonhole principle for measure spaces: if `s` is a `finset` and\n`∑ i in s, μ (t i) > μ univ`, then one of the intersections `t i ∩ t j` is not empty. -/\ntheorem exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : MeasurableSpace α} (μ : Measure α)\n    {s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i))\n    (H : μ (univ : Set α) < ∑ i in s, μ (t i)) :\n    ∃ i ∈ s, ∃ j ∈ s, ∃ h : i ≠ j, (t i ∩ t j).Nonempty :=\n  by\n  contrapose! H\n  apply sum_measure_le_measure_univ h\n  intro i hi j hj hij\n  rw [Function.onFun, disjoint_iff_inf_le]\n  exact fun x hx => H i hi j hj hij ⟨x, hx⟩\n#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_sum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_sum_measure\n\n/-- If two sets `s` and `t` are included in a set `u`, and `μ s + μ t > μ u`,\nthen `s` intersects `t`. Version assuming that `t` is measurable. -/\ntheorem nonempty_inter_of_measure_lt_add {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}\n    (ht : MeasurableSet t) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) : (s ∩ t).Nonempty :=\n  by\n  rw [← Set.not_disjoint_iff_nonempty_inter]\n  contrapose! h\n  calc\n    μ s + μ t = μ (s ∪ t) := (measure_union h ht).symm\n    _ ≤ μ u := measure_mono (union_subset h's h't)\n    \n#align measure_theory.nonempty_inter_of_measure_lt_add MeasureTheory.nonempty_inter_of_measure_lt_add\n\n/-- If two sets `s` and `t` are included in a set `u`, and `μ s + μ t > μ u`,\nthen `s` intersects `t`. Version assuming that `s` is measurable. -/\ntheorem nonempty_inter_of_measure_lt_add' {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}\n    (hs : MeasurableSet s) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) : (s ∩ t).Nonempty :=\n  by\n  rw [add_comm] at h\n  rw [inter_comm]\n  exact nonempty_inter_of_measure_lt_add μ hs h't h's h\n#align measure_theory.nonempty_inter_of_measure_lt_add' MeasureTheory.nonempty_inter_of_measure_lt_add'\n\n/-- Continuity from below: the measure of the union of a directed sequence of (not necessarily\n-measurable) sets is the supremum of the measures. -/\ntheorem measure_unionᵢ_eq_supᵢ [Countable ι] {s : ι → Set α} (hd : Directed (· ⊆ ·) s) :\n    μ (⋃ i, s i) = ⨆ i, μ (s i) := by\n  cases nonempty_encodable ι\n  -- WLOG, `ι = ℕ`\n  generalize ht : Function.extend Encodable.encode s ⊥ = t\n  replace hd : Directed (· ⊆ ·) t := ht ▸ hd.extend_bot Encodable.encode_injective\n  suffices μ (⋃ n, t n) = ⨆ n, μ (t n)\n    by\n    simp only [← ht, encodable.encode_injective.apply_extend μ, ← supr_eq_Union,\n      supᵢ_extend_bot Encodable.encode_injective, (· ∘ ·), Pi.bot_apply, bot_eq_empty,\n      measure_empty] at this\n    exact this.trans (supᵢ_extend_bot Encodable.encode_injective _)\n  clear! ι\n  -- The `≥` inequality is trivial\n  refine' le_antisymm _ (supᵢ_le fun i => measure_mono <| subset_Union _ _)\n  -- Choose `T n ⊇ t n` of the same measure, put `Td n = disjointed T`\n  set T : ℕ → Set α := fun n => to_measurable μ (t n)\n  set Td : ℕ → Set α := disjointed T\n  have hm : ∀ n, MeasurableSet (Td n) :=\n    MeasurableSet.disjointed fun n => measurable_set_to_measurable _ _\n  calc\n    μ (⋃ n, t n) ≤ μ (⋃ n, T n) := measure_mono (Union_mono fun i => subset_to_measurable _ _)\n    _ = μ (⋃ n, Td n) := by rw [unionᵢ_disjointed]\n    _ ≤ ∑' n, μ (Td n) := (measure_Union_le _)\n    _ = ⨆ I : Finset ℕ, ∑ n in I, μ (Td n) := ENNReal.tsum_eq_supᵢ_sum\n    _ ≤ ⨆ n, μ (t n) := supᵢ_le fun I => _\n    \n  rcases hd.finset_le I with ⟨N, hN⟩\n  calc\n    (∑ n in I, μ (Td n)) = μ (⋃ n ∈ I, Td n) :=\n      (measure_bUnion_finset ((disjoint_disjointed T).set_pairwise I) fun n _ => hm n).symm\n    _ ≤ μ (⋃ n ∈ I, T n) := (measure_mono (Union₂_mono fun n hn => disjointed_subset _ _))\n    _ = μ (⋃ n ∈ I, t n) := (measure_bUnion_to_measurable I.countable_to_set _)\n    _ ≤ μ (t N) := (measure_mono (Union₂_subset hN))\n    _ ≤ ⨆ n, μ (t n) := le_supᵢ (μ ∘ t) N\n    \n#align measure_theory.measure_Union_eq_supr MeasureTheory.measure_unionᵢ_eq_supᵢ\n\ntheorem measure_bUnion_eq_supᵢ {s : ι → Set α} {t : Set ι} (ht : t.Countable)\n    (hd : DirectedOn ((· ⊆ ·) on s) t) : μ (⋃ i ∈ t, s i) = ⨆ i ∈ t, μ (s i) :=\n  by\n  haveI := ht.to_encodable\n  rw [bUnion_eq_Union, measure_Union_eq_supr hd.directed_coe, ← supᵢ_subtype'']\n#align measure_theory.measure_bUnion_eq_supr MeasureTheory.measure_bUnion_eq_supᵢ\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s k) -/\n/-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable\nsets is the infimum of the measures. -/\ntheorem measure_interᵢ_eq_infᵢ [Countable ι] {s : ι → Set α} (h : ∀ i, MeasurableSet (s i))\n    (hd : Directed (· ⊇ ·) s) (hfin : ∃ i, μ (s i) ≠ ∞) : μ (⋂ i, s i) = ⨅ i, μ (s i) :=\n  by\n  rcases hfin with ⟨k, hk⟩\n  have : ∀ (t) (_ : t ⊆ s k), μ t ≠ ∞ := fun t ht => ne_top_of_le_ne_top hk (measure_mono ht)\n  rw [← ENNReal.sub_sub_cancel hk (infᵢ_le _ k), ENNReal.sub_infᵢ, ←\n    ENNReal.sub_sub_cancel hk (measure_mono (Inter_subset _ k)), ←\n    measure_diff (Inter_subset _ k) (MeasurableSet.interᵢ h) (this _ (Inter_subset _ k)),\n    diff_Inter, measure_Union_eq_supr]\n  · congr 1\n    refine' le_antisymm (supᵢ_mono' fun i => _) (supᵢ_mono fun i => _)\n    · rcases hd i k with ⟨j, hji, hjk⟩\n      use j\n      rw [← measure_diff hjk (h _) (this _ hjk)]\n      exact measure_mono (diff_subset_diff_right hji)\n    · rw [tsub_le_iff_right, ← measure_union disjoint_sdiff_left (h i), Set.union_comm]\n      exact measure_mono (diff_subset_iff.1 <| subset.refl _)\n  · exact hd.mono_comp _ fun _ _ => diff_subset_diff_right\n#align measure_theory.measure_Inter_eq_infi MeasureTheory.measure_interᵢ_eq_infᵢ\n\n/-- Continuity from below: the measure of the union of an increasing sequence of measurable sets\nis the limit of the measures. -/\ntheorem tendsto_measure_unionᵢ [SemilatticeSup ι] [Countable ι] {s : ι → Set α} (hm : Monotone s) :\n    Tendsto (μ ∘ s) atTop (𝓝 (μ (⋃ n, s n))) :=\n  by\n  rw [measure_Union_eq_supr (directed_of_sup hm)]\n  exact tendsto_atTop_supᵢ fun n m hnm => measure_mono <| hm hnm\n#align measure_theory.tendsto_measure_Union MeasureTheory.tendsto_measure_unionᵢ\n\n/-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable\nsets is the limit of the measures. -/\ntheorem tendsto_measure_interᵢ [Countable ι] [SemilatticeSup ι] {s : ι → Set α}\n    (hs : ∀ n, MeasurableSet (s n)) (hm : Antitone s) (hf : ∃ i, μ (s i) ≠ ∞) :\n    Tendsto (μ ∘ s) atTop (𝓝 (μ (⋂ n, s n))) :=\n  by\n  rw [measure_Inter_eq_infi hs (directed_of_sup hm) hf]\n  exact tendsto_atTop_infᵢ fun n m hnm => measure_mono <| hm hnm\n#align measure_theory.tendsto_measure_Inter MeasureTheory.tendsto_measure_interᵢ\n\n/-- The measure of the intersection of a decreasing sequence of measurable\nsets indexed by a linear order with first countable topology is the limit of the measures. -/\ntheorem tendsto_measure_bInter_gt {ι : Type _} [LinearOrder ι] [TopologicalSpace ι]\n    [OrderTopology ι] [DenselyOrdered ι] [TopologicalSpace.FirstCountableTopology ι] {s : ι → Set α}\n    {a : ι} (hs : ∀ r > a, MeasurableSet (s r)) (hm : ∀ i j, a < i → i ≤ j → s i ⊆ s j)\n    (hf : ∃ r > a, μ (s r) ≠ ∞) : Tendsto (μ ∘ s) (𝓝[Ioi a] a) (𝓝 (μ (⋂ r > a, s r))) :=\n  by\n  refine' tendsto_order.2 ⟨fun l hl => _, fun L hL => _⟩\n  ·\n    filter_upwards [self_mem_nhdsWithin]with r hr using hl.trans_le\n        (measure_mono (bInter_subset_of_mem hr))\n  obtain ⟨u, u_anti, u_pos, u_lim⟩ :\n    ∃ u : ℕ → ι, StrictAnti u ∧ (∀ n : ℕ, a < u n) ∧ tendsto u at_top (𝓝 a) :=\n    by\n    rcases hf with ⟨r, ar, hr⟩\n    rcases exists_seq_strictAnti_tendsto' ar with ⟨w, w_anti, w_mem, w_lim⟩\n    exact ⟨w, w_anti, fun n => (w_mem n).1, w_lim⟩\n  have A : tendsto (μ ∘ s ∘ u) at_top (𝓝 (μ (⋂ n, s (u n)))) :=\n    by\n    refine' tendsto_measure_Inter (fun n => hs _ (u_pos n)) _ _\n    · intro m n hmn\n      exact hm _ _ (u_pos n) (u_anti.antitone hmn)\n    · rcases hf with ⟨r, rpos, hr⟩\n      obtain ⟨n, hn⟩ : ∃ n : ℕ, u n < r := ((tendsto_order.1 u_lim).2 r rpos).exists\n      refine' ⟨n, ne_of_lt (lt_of_le_of_lt _ hr.lt_top)⟩\n      exact measure_mono (hm _ _ (u_pos n) hn.le)\n  have B : (⋂ n, s (u n)) = ⋂ r > a, s r :=\n    by\n    apply subset.antisymm\n    · simp only [subset_Inter_iff, gt_iff_lt]\n      intro r rpos\n      obtain ⟨n, hn⟩ : ∃ n, u n < r := ((tendsto_order.1 u_lim).2 _ rpos).exists\n      exact subset.trans (Inter_subset _ n) (hm (u n) r (u_pos n) hn.le)\n    · simp only [subset_Inter_iff, gt_iff_lt]\n      intro n\n      apply bInter_subset_of_mem\n      exact u_pos n\n  rw [B] at A\n  obtain ⟨n, hn⟩ : ∃ n, μ (s (u n)) < L := ((tendsto_order.1 A).2 _ hL).exists\n  have : Ioc a (u n) ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, u_pos n⟩\n  filter_upwards [this]with r hr using lt_of_le_of_lt (measure_mono (hm _ _ hr.1 hr.2)) hn\n#align measure_theory.tendsto_measure_bInter_gt MeasureTheory.tendsto_measure_bInter_gt\n\n/-- One direction of the **Borel-Cantelli lemma**: if (sᵢ) is a sequence of sets such\nthat `∑ μ sᵢ` is finite, then the limit superior of the `sᵢ` is a null set. -/\ntheorem measure_limsup_eq_zero {s : ℕ → Set α} (hs : (∑' i, μ (s i)) ≠ ∞) :\n    μ (limsup s atTop) = 0 :=\n  by\n  -- First we replace the sequence `sₙ` with a sequence of measurable sets `tₙ ⊇ sₙ` of the same\n  -- measure.\n  set t : ℕ → Set α := fun n => to_measurable μ (s n)\n  have ht : (∑' i, μ (t i)) ≠ ∞ := by simpa only [t, measure_to_measurable] using hs\n  suffices μ (limsup t at_top) = 0\n    by\n    have A : s ≤ t := fun n => subset_to_measurable μ (s n)\n    -- TODO default args fail\n    exact\n      measure_mono_null\n        (limsup_le_limsup (eventually_of_forall (pi.le_def.mp A)) is_cobounded_le_of_bot\n          is_bounded_le_of_top)\n        this\n  -- Next we unfold `limsup` for sets and replace equality with an inequality\n  simp only [limsup_eq_infi_supr_of_nat', Set.infᵢ_eq_interᵢ, Set.supᵢ_eq_unionᵢ, ←\n    nonpos_iff_eq_zero]\n  -- Finally, we estimate `μ (⋃ i, t (i + n))` by `∑ i', μ (t (i + n))`\n  refine'\n    le_of_tendsto_of_tendsto'\n      (tendsto_measure_Inter\n        (fun i => MeasurableSet.unionᵢ fun b => measurable_set_to_measurable _ _) _\n        ⟨0, ne_top_of_le_ne_top ht (measure_Union_le t)⟩)\n      (ENNReal.tendsto_sum_nat_add (μ ∘ t) ht) fun n => measure_Union_le _\n  intro n m hnm x\n  simp only [Set.mem_unionᵢ]\n  exact fun ⟨i, hi⟩ => ⟨i + (m - n), by simpa only [add_assoc, tsub_add_cancel_of_le hnm] using hi⟩\n#align measure_theory.measure_limsup_eq_zero MeasureTheory.measure_limsup_eq_zero\n\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic filter.is_bounded_default -/\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic filter.is_bounded_default -/\ntheorem measure_liminf_eq_zero {s : ℕ → Set α} (h : (∑' i, μ (s i)) ≠ ⊤) : μ (liminf s atTop) = 0 :=\n  by\n  rw [← le_zero_iff]\n  have : liminf s at_top ≤ limsup s at_top :=\n    liminf_le_limsup\n      (by\n        run_tac\n          is_bounded_default)\n      (by\n        run_tac\n          is_bounded_default)\n  exact (μ.mono this).trans (by simp [measure_limsup_eq_zero h])\n#align measure_theory.measure_liminf_eq_zero MeasureTheory.measure_liminf_eq_zero\n\ntheorem limsup_ae_eq_of_forall_ae_eq (s : ℕ → Set α) {t : Set α}\n    (h : ∀ n, s n =ᵐ[μ] t) :-- Need `@` below because of diamond; see gh issue #16932\n        @limsup\n        (Set α) ℕ _ s atTop =ᵐ[μ]\n      t :=\n  by\n  simp_rw [ae_eq_set] at h⊢\n  constructor\n  · rw [at_top.limsup_sdiff s t]\n    apply measure_limsup_eq_zero\n    simp [h]\n  · rw [at_top.sdiff_limsup s t]\n    apply measure_liminf_eq_zero\n    simp [h]\n#align measure_theory.limsup_ae_eq_of_forall_ae_eq MeasureTheory.limsup_ae_eq_of_forall_ae_eq\n\ntheorem liminf_ae_eq_of_forall_ae_eq (s : ℕ → Set α) {t : Set α}\n    (h : ∀ n, s n =ᵐ[μ] t) :-- Need `@` below because of diamond; see gh issue #16932\n        @liminf\n        (Set α) ℕ _ s atTop =ᵐ[μ]\n      t :=\n  by\n  simp_rw [ae_eq_set] at h⊢\n  constructor\n  · rw [at_top.liminf_sdiff s t]\n    apply measure_liminf_eq_zero\n    simp [h]\n  · rw [at_top.sdiff_liminf s t]\n    apply measure_limsup_eq_zero\n    simp [h]\n#align measure_theory.liminf_ae_eq_of_forall_ae_eq MeasureTheory.liminf_ae_eq_of_forall_ae_eq\n\ntheorem measure_if {x : β} {t : Set β} {s : Set α} :\n    μ (if x ∈ t then s else ∅) = indicator t (fun _ => μ s) x := by split_ifs <;> simp [h]\n#align measure_theory.measure_if MeasureTheory.measure_if\n\nend\n\nsection OuterMeasure\n\nvariable [ms : MeasurableSpace α] {s t : Set α}\n\ninclude ms\n\n/-- Obtain a measure by giving an outer measure where all sets in the σ-algebra are\n  Carathéodory measurable. -/\ndef OuterMeasure.toMeasure (m : OuterMeasure α) (h : ms ≤ m.caratheodory) : Measure α :=\n  Measure.ofMeasurable (fun s _ => m s) m.Empty fun f hf hd =>\n    m.unionᵢ_eq_of_caratheodory (fun i => h _ (hf i)) hd\n#align measure_theory.outer_measure.to_measure MeasureTheory.OuterMeasure.toMeasure\n\ntheorem le_toOuterMeasure_caratheodory (μ : Measure α) : ms ≤ μ.toOuterMeasure.caratheodory :=\n  fun s hs t => (measure_inter_add_diff _ hs).symm\n#align measure_theory.le_to_outer_measure_caratheodory MeasureTheory.le_toOuterMeasure_caratheodory\n\n@[simp]\ntheorem toMeasure_toOuterMeasure (m : OuterMeasure α) (h : ms ≤ m.caratheodory) :\n    (m.toMeasure h).toOuterMeasure = m.trim :=\n  rfl\n#align measure_theory.to_measure_to_outer_measure MeasureTheory.toMeasure_toOuterMeasure\n\n@[simp]\ntheorem toMeasure_apply (m : OuterMeasure α) (h : ms ≤ m.caratheodory) {s : Set α}\n    (hs : MeasurableSet s) : m.toMeasure h s = m s :=\n  m.trim_eq hs\n#align measure_theory.to_measure_apply MeasureTheory.toMeasure_apply\n\ntheorem le_toMeasure_apply (m : OuterMeasure α) (h : ms ≤ m.caratheodory) (s : Set α) :\n    m s ≤ m.toMeasure h s :=\n  m.le_trim s\n#align measure_theory.le_to_measure_apply MeasureTheory.le_toMeasure_apply\n\ntheorem toMeasure_apply₀ (m : OuterMeasure α) (h : ms ≤ m.caratheodory) {s : Set α}\n    (hs : NullMeasurableSet s (m.toMeasure h)) : m.toMeasure h s = m s :=\n  by\n  refine' le_antisymm _ (le_to_measure_apply _ _ _)\n  rcases hs.exists_measurable_subset_ae_eq with ⟨t, hts, htm, heq⟩\n  calc\n    m.to_measure h s = m.to_measure h t := measure_congr HEq.symm\n    _ = m t := (to_measure_apply m h htm)\n    _ ≤ m s := m.mono hts\n    \n#align measure_theory.to_measure_apply₀ MeasureTheory.toMeasure_apply₀\n\n@[simp]\ntheorem toOuterMeasure_toMeasure {μ : Measure α} :\n    μ.toOuterMeasure.toMeasure (le_toOuterMeasure_caratheodory _) = μ :=\n  Measure.ext fun s => μ.toOuterMeasure.trim_eq\n#align measure_theory.to_outer_measure_to_measure MeasureTheory.toOuterMeasure_toMeasure\n\n@[simp]\ntheorem boundedBy_measure (μ : Measure α) : OuterMeasure.boundedBy μ = μ.toOuterMeasure :=\n  μ.toOuterMeasure.boundedBy_eq_self\n#align measure_theory.bounded_by_measure MeasureTheory.boundedBy_measure\n\nend OuterMeasure\n\nvariable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ]\n\nvariable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α}\n\nnamespace Measure\n\n/-- If `u` is a superset of `t` with the same (finite) measure (both sets possibly non-measurable),\nthen for any measurable set `s` one also has `μ (t ∩ s) = μ (u ∩ s)`. -/\ntheorem measure_inter_eq_of_measure_eq {s t u : Set α} (hs : MeasurableSet s) (h : μ t = μ u)\n    (htu : t ⊆ u) (ht_ne_top : μ t ≠ ∞) : μ (t ∩ s) = μ (u ∩ s) :=\n  by\n  rw [h] at ht_ne_top\n  refine' le_antisymm (measure_mono (inter_subset_inter_left _ htu)) _\n  have A : μ (u ∩ s) + μ (u \\ s) ≤ μ (t ∩ s) + μ (u \\ s) :=\n    calc\n      μ (u ∩ s) + μ (u \\ s) = μ u := measure_inter_add_diff _ hs\n      _ = μ t := h.symm\n      _ = μ (t ∩ s) + μ (t \\ s) := (measure_inter_add_diff _ hs).symm\n      _ ≤ μ (t ∩ s) + μ (u \\ s) :=\n        add_le_add le_rfl (measure_mono (diff_subset_diff htu subset.rfl))\n      \n  have B : μ (u \\ s) ≠ ∞ := (lt_of_le_of_lt (measure_mono (diff_subset _ _)) ht_ne_top.lt_top).Ne\n  exact ENNReal.le_of_add_le_add_right B A\n#align measure_theory.measure.measure_inter_eq_of_measure_eq MeasureTheory.Measure.measure_inter_eq_of_measure_eq\n\n/-- The measurable superset `to_measurable μ t` of `t` (which has the same measure as `t`)\nsatisfies, for any measurable set `s`, the equality `μ (to_measurable μ t ∩ s) = μ (u ∩ s)`.\nHere, we require that the measure of `t` is finite. The conclusion holds without this assumption\nwhen the measure is sigma_finite, see `measure_to_measurable_inter_of_sigma_finite`. -/\ntheorem measure_toMeasurable_inter {s t : Set α} (hs : MeasurableSet s) (ht : μ t ≠ ∞) :\n    μ (toMeasurable μ t ∩ s) = μ (t ∩ s) :=\n  (measure_inter_eq_of_measure_eq hs (measure_toMeasurable t).symm (subset_toMeasurable μ t)\n      ht).symm\n#align measure_theory.measure.measure_to_measurable_inter MeasureTheory.Measure.measure_toMeasurable_inter\n\n/-! ### The `ℝ≥0∞`-module of measures -/\n\n\ninstance [MeasurableSpace α] : Zero (Measure α) :=\n  ⟨{  toOuterMeasure := 0\n      m_unionᵢ := fun f hf hd => tsum_zero.symm\n      trimmed := OuterMeasure.trim_zero }⟩\n\n@[simp]\ntheorem zero_toOuterMeasure {m : MeasurableSpace α} : (0 : Measure α).toOuterMeasure = 0 :=\n  rfl\n#align measure_theory.measure.zero_to_outer_measure MeasureTheory.Measure.zero_toOuterMeasure\n\n@[simp, norm_cast]\ntheorem coe_zero {m : MeasurableSpace α} : ⇑(0 : Measure α) = 0 :=\n  rfl\n#align measure_theory.measure.coe_zero MeasureTheory.Measure.coe_zero\n\ninstance [IsEmpty α] {m : MeasurableSpace α} : Subsingleton (Measure α) :=\n  ⟨fun μ ν => by\n    ext1 s hs\n    simp only [eq_empty_of_is_empty s, measure_empty]⟩\n\ntheorem eq_zero_of_isEmpty [IsEmpty α] {m : MeasurableSpace α} (μ : Measure α) : μ = 0 :=\n  Subsingleton.elim μ 0\n#align measure_theory.measure.eq_zero_of_is_empty MeasureTheory.Measure.eq_zero_of_isEmpty\n\ninstance [MeasurableSpace α] : Inhabited (Measure α) :=\n  ⟨0⟩\n\ninstance [MeasurableSpace α] : Add (Measure α) :=\n  ⟨fun μ₁ μ₂ =>\n    { toOuterMeasure := μ₁.toOuterMeasure + μ₂.toOuterMeasure\n      m_unionᵢ := fun s hs hd =>\n        show μ₁ (⋃ i, s i) + μ₂ (⋃ i, s i) = ∑' i, μ₁ (s i) + μ₂ (s i) by\n          rw [ENNReal.tsum_add, measure_Union hd hs, measure_Union hd hs]\n      trimmed := by rw [outer_measure.trim_add, μ₁.trimmed, μ₂.trimmed] }⟩\n\n@[simp]\ntheorem add_toOuterMeasure {m : MeasurableSpace α} (μ₁ μ₂ : Measure α) :\n    (μ₁ + μ₂).toOuterMeasure = μ₁.toOuterMeasure + μ₂.toOuterMeasure :=\n  rfl\n#align measure_theory.measure.add_to_outer_measure MeasureTheory.Measure.add_toOuterMeasure\n\n@[simp, norm_cast]\ntheorem coe_add {m : MeasurableSpace α} (μ₁ μ₂ : Measure α) : ⇑(μ₁ + μ₂) = μ₁ + μ₂ :=\n  rfl\n#align measure_theory.measure.coe_add MeasureTheory.Measure.coe_add\n\ntheorem add_apply {m : MeasurableSpace α} (μ₁ μ₂ : Measure α) (s : Set α) :\n    (μ₁ + μ₂) s = μ₁ s + μ₂ s :=\n  rfl\n#align measure_theory.measure.add_apply MeasureTheory.Measure.add_apply\n\nsection SMul\n\nvariable [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]\n\nvariable [SMul R' ℝ≥0∞] [IsScalarTower R' ℝ≥0∞ ℝ≥0∞]\n\ninstance [MeasurableSpace α] : SMul R (Measure α) :=\n  ⟨fun c μ =>\n    { toOuterMeasure := c • μ.toOuterMeasure\n      m_unionᵢ := fun s hs hd =>\n        by\n        rw [← smul_one_smul ℝ≥0∞ c (_ : outer_measure α)]\n        dsimp\n        simp_rw [measure_Union hd hs, ENNReal.tsum_mul_left]\n      trimmed := by rw [outer_measure.trim_smul, μ.trimmed] }⟩\n\n@[simp]\ntheorem smul_toOuterMeasure {m : MeasurableSpace α} (c : R) (μ : Measure α) :\n    (c • μ).toOuterMeasure = c • μ.toOuterMeasure :=\n  rfl\n#align measure_theory.measure.smul_to_outer_measure MeasureTheory.Measure.smul_toOuterMeasure\n\n@[simp, norm_cast]\ntheorem coe_smul {m : MeasurableSpace α} (c : R) (μ : Measure α) : ⇑(c • μ) = c • μ :=\n  rfl\n#align measure_theory.measure.coe_smul MeasureTheory.Measure.coe_smul\n\n@[simp]\ntheorem smul_apply {m : MeasurableSpace α} (c : R) (μ : Measure α) (s : Set α) :\n    (c • μ) s = c • μ s :=\n  rfl\n#align measure_theory.measure.smul_apply MeasureTheory.Measure.smul_apply\n\ninstance [SMulCommClass R R' ℝ≥0∞] [MeasurableSpace α] : SMulCommClass R R' (Measure α) :=\n  ⟨fun _ _ _ => ext fun _ _ => smul_comm _ _ _⟩\n\ninstance [SMul R R'] [IsScalarTower R R' ℝ≥0∞] [MeasurableSpace α] :\n    IsScalarTower R R' (Measure α) :=\n  ⟨fun _ _ _ => ext fun _ _ => smul_assoc _ _ _⟩\n\ninstance [SMul Rᵐᵒᵖ ℝ≥0∞] [IsCentralScalar R ℝ≥0∞] [MeasurableSpace α] :\n    IsCentralScalar R (Measure α) :=\n  ⟨fun _ _ => ext fun _ _ => op_smul_eq_smul _ _⟩\n\nend SMul\n\ninstance [Monoid R] [MulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] [MeasurableSpace α] :\n    MulAction R (Measure α) :=\n  Injective.mulAction _ toOuterMeasure_injective smul_toOuterMeasure\n\ninstance addCommMonoid [MeasurableSpace α] : AddCommMonoid (Measure α) :=\n  toOuterMeasure_injective.AddCommMonoid toOuterMeasure zero_toOuterMeasure add_toOuterMeasure\n    fun _ _ => smul_toOuterMeasure _ _\n#align measure_theory.measure.add_comm_monoid MeasureTheory.Measure.addCommMonoid\n\n/-- Coercion to function as an additive monoid homomorphism. -/\ndef coeAddHom {m : MeasurableSpace α} : Measure α →+ Set α → ℝ≥0∞ :=\n  ⟨coeFn, coe_zero, coe_add⟩\n#align measure_theory.measure.coe_add_hom MeasureTheory.Measure.coeAddHom\n\n@[simp]\ntheorem coe_finset_sum {m : MeasurableSpace α} (I : Finset ι) (μ : ι → Measure α) :\n    ⇑(∑ i in I, μ i) = ∑ i in I, μ i :=\n  (@coeAddHom α m).map_sum _ _\n#align measure_theory.measure.coe_finset_sum MeasureTheory.Measure.coe_finset_sum\n\ntheorem finset_sum_apply {m : MeasurableSpace α} (I : Finset ι) (μ : ι → Measure α) (s : Set α) :\n    (∑ i in I, μ i) s = ∑ i in I, μ i s := by rw [coe_finset_sum, Finset.sum_apply]\n#align measure_theory.measure.finset_sum_apply MeasureTheory.Measure.finset_sum_apply\n\ninstance [Monoid R] [DistribMulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] [MeasurableSpace α] :\n    DistribMulAction R (Measure α) :=\n  Injective.distribMulAction ⟨toOuterMeasure, zero_toOuterMeasure, add_toOuterMeasure⟩\n    toOuterMeasure_injective smul_toOuterMeasure\n\ninstance [Semiring R] [Module R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] [MeasurableSpace α] :\n    Module R (Measure α) :=\n  Injective.module R ⟨toOuterMeasure, zero_toOuterMeasure, add_toOuterMeasure⟩\n    toOuterMeasure_injective smul_toOuterMeasure\n\n@[simp]\ntheorem coe_nNReal_smul_apply {m : MeasurableSpace α} (c : ℝ≥0) (μ : Measure α) (s : Set α) :\n    (c • μ) s = c * μ s :=\n  rfl\n#align measure_theory.measure.coe_nnreal_smul_apply MeasureTheory.Measure.coe_nNReal_smul_apply\n\ntheorem ae_smul_measure_iff {p : α → Prop} {c : ℝ≥0∞} (hc : c ≠ 0) :\n    (∀ᵐ x ∂c • μ, p x) ↔ ∀ᵐ x ∂μ, p x := by simp [ae_iff, hc]\n#align measure_theory.measure.ae_smul_measure_iff MeasureTheory.Measure.ae_smul_measure_iff\n\ntheorem measure_eq_left_of_subset_of_measure_add_eq {s t : Set α} (h : (μ + ν) t ≠ ∞) (h' : s ⊆ t)\n    (h'' : (μ + ν) s = (μ + ν) t) : μ s = μ t :=\n  by\n  refine' le_antisymm (measure_mono h') _\n  have : μ t + ν t ≤ μ s + ν t :=\n    calc\n      μ t + ν t = μ s + ν s := h''.symm\n      _ ≤ μ s + ν t := add_le_add le_rfl (measure_mono h')\n      \n  apply ENNReal.le_of_add_le_add_right _ this\n  simp only [not_or, ENNReal.add_eq_top, Pi.add_apply, Ne.def, coe_add] at h\n  exact h.2\n#align measure_theory.measure.measure_eq_left_of_subset_of_measure_add_eq MeasureTheory.Measure.measure_eq_left_of_subset_of_measure_add_eq\n\ntheorem measure_eq_right_of_subset_of_measure_add_eq {s t : Set α} (h : (μ + ν) t ≠ ∞) (h' : s ⊆ t)\n    (h'' : (μ + ν) s = (μ + ν) t) : ν s = ν t :=\n  by\n  rw [add_comm] at h'' h\n  exact measure_eq_left_of_subset_of_measure_add_eq h h' h''\n#align measure_theory.measure.measure_eq_right_of_subset_of_measure_add_eq MeasureTheory.Measure.measure_eq_right_of_subset_of_measure_add_eq\n\ntheorem measure_toMeasurable_add_inter_left {s t : Set α} (hs : MeasurableSet s)\n    (ht : (μ + ν) t ≠ ∞) : μ (toMeasurable (μ + ν) t ∩ s) = μ (t ∩ s) :=\n  by\n  refine' (measure_inter_eq_of_measure_eq hs _ (subset_to_measurable _ _) _).symm\n  · refine'\n      measure_eq_left_of_subset_of_measure_add_eq _ (subset_to_measurable _ _)\n        (measure_to_measurable t).symm\n    rwa [measure_to_measurable t]\n  · simp only [not_or, ENNReal.add_eq_top, Pi.add_apply, Ne.def, coe_add] at ht\n    exact ht.1\n#align measure_theory.measure.measure_to_measurable_add_inter_left MeasureTheory.Measure.measure_toMeasurable_add_inter_left\n\ntheorem measure_toMeasurable_add_inter_right {s t : Set α} (hs : MeasurableSet s)\n    (ht : (μ + ν) t ≠ ∞) : ν (toMeasurable (μ + ν) t ∩ s) = ν (t ∩ s) :=\n  by\n  rw [add_comm] at ht⊢\n  exact measure_to_measurable_add_inter_left hs ht\n#align measure_theory.measure.measure_to_measurable_add_inter_right MeasureTheory.Measure.measure_toMeasurable_add_inter_right\n\n/-! ### The complete lattice of measures -/\n\n\n/-- Measures are partially ordered.\n\nThe definition of less equal here is equivalent to the definition without the\nmeasurable set condition, and this is shown by `measure.le_iff'`. It is defined\nthis way since, to prove `μ ≤ ν`, we may simply `intros s hs` instead of rewriting followed\nby `intros s hs`. -/\ninstance [MeasurableSpace α] : PartialOrder (Measure α)\n    where\n  le m₁ m₂ := ∀ s, MeasurableSet s → m₁ s ≤ m₂ s\n  le_refl m s hs := le_rfl\n  le_trans m₁ m₂ m₃ h₁ h₂ s hs := le_trans (h₁ s hs) (h₂ s hs)\n  le_antisymm m₁ m₂ h₁ h₂ := ext fun s hs => le_antisymm (h₁ s hs) (h₂ s hs)\n\ntheorem le_iff : μ₁ ≤ μ₂ ↔ ∀ s, MeasurableSet s → μ₁ s ≤ μ₂ s :=\n  Iff.rfl\n#align measure_theory.measure.le_iff MeasureTheory.Measure.le_iff\n\ntheorem toOuterMeasure_le : μ₁.toOuterMeasure ≤ μ₂.toOuterMeasure ↔ μ₁ ≤ μ₂ := by\n  rw [← μ₂.trimmed, outer_measure.le_trim_iff] <;> rfl\n#align measure_theory.measure.to_outer_measure_le MeasureTheory.Measure.toOuterMeasure_le\n\ntheorem le_iff' : μ₁ ≤ μ₂ ↔ ∀ s, μ₁ s ≤ μ₂ s :=\n  toOuterMeasure_le.symm\n#align measure_theory.measure.le_iff' MeasureTheory.Measure.le_iff'\n\ntheorem lt_iff : μ < ν ↔ μ ≤ ν ∧ ∃ s, MeasurableSet s ∧ μ s < ν s :=\n  lt_iff_le_not_le.trans <|\n    and_congr Iff.rfl <| by simp only [le_iff, not_forall, not_le, exists_prop]\n#align measure_theory.measure.lt_iff MeasureTheory.Measure.lt_iff\n\ntheorem lt_iff' : μ < ν ↔ μ ≤ ν ∧ ∃ s, μ s < ν s :=\n  lt_iff_le_not_le.trans <| and_congr Iff.rfl <| by simp only [le_iff', not_forall, not_le]\n#align measure_theory.measure.lt_iff' MeasureTheory.Measure.lt_iff'\n\ninstance covariant_add_le [MeasurableSpace α] :\n    CovariantClass (Measure α) (Measure α) (· + ·) (· ≤ ·) :=\n  ⟨fun ν μ₁ μ₂ hμ s hs => add_le_add_left (hμ s hs) _⟩\n#align measure_theory.measure.covariant_add_le MeasureTheory.Measure.covariant_add_le\n\nprotected theorem le_add_left (h : μ ≤ ν) : μ ≤ ν' + ν := fun s hs => le_add_left (h s hs)\n#align measure_theory.measure.le_add_left MeasureTheory.Measure.le_add_left\n\nprotected theorem le_add_right (h : μ ≤ ν) : μ ≤ ν + ν' := fun s hs => le_add_right (h s hs)\n#align measure_theory.measure.le_add_right MeasureTheory.Measure.le_add_right\n\nsection Inf\n\nvariable {m : Set (Measure α)}\n\ntheorem infₛ_caratheodory (s : Set α) (hs : MeasurableSet s) :\n    measurable_set[(infₛ (toOuterMeasure '' m)).caratheodory] s :=\n  by\n  rw [outer_measure.Inf_eq_bounded_by_Inf_gen]\n  refine' outer_measure.bounded_by_caratheodory fun t => _\n  simp only [outer_measure.Inf_gen, le_infᵢ_iff, ball_image_iff, coe_to_outer_measure,\n    measure_eq_infi t]\n  intro μ hμ u htu hu\n  have hm : ∀ {s t}, s ⊆ t → outer_measure.Inf_gen (to_outer_measure '' m) s ≤ μ t :=\n    by\n    intro s t hst\n    rw [outer_measure.Inf_gen_def]\n    refine' infᵢ_le_of_le μ.to_outer_measure (infᵢ_le_of_le (mem_image_of_mem _ hμ) _)\n    rw [to_outer_measure_apply]\n    refine' measure_mono hst\n  rw [← measure_inter_add_diff u hs]\n  refine' add_le_add (hm <| inter_subset_inter_left _ htu) (hm <| diff_subset_diff_left htu)\n#align measure_theory.measure.Inf_caratheodory MeasureTheory.Measure.infₛ_caratheodory\n\ninstance [MeasurableSpace α] : InfSet (Measure α) :=\n  ⟨fun m => (infₛ (toOuterMeasure '' m)).toMeasure <| infₛ_caratheodory⟩\n\ntheorem infₛ_apply (hs : MeasurableSet s) : infₛ m s = infₛ (toOuterMeasure '' m) s :=\n  toMeasure_apply _ _ hs\n#align measure_theory.measure.Inf_apply MeasureTheory.Measure.infₛ_apply\n\nprivate theorem measure_Inf_le (h : μ ∈ m) : infₛ m ≤ μ :=\n  have : infₛ (toOuterMeasure '' m) ≤ μ.toOuterMeasure := infₛ_le (mem_image_of_mem _ h)\n  fun s hs => by rw [infₛ_apply hs, ← to_outer_measure_apply] <;> exact this s\n#align measure_theory.measure.measure_Inf_le measure_theory.measure.measure_Inf_le\n\nprivate theorem measure_le_Inf (h : ∀ μ' ∈ m, μ ≤ μ') : μ ≤ infₛ m :=\n  have : μ.toOuterMeasure ≤ infₛ (toOuterMeasure '' m) :=\n    le_infₛ <| ball_image_of_ball fun μ hμ => toOuterMeasure_le.2 <| h _ hμ\n  fun s hs => by rw [infₛ_apply hs, ← to_outer_measure_apply] <;> exact this s\n#align measure_theory.measure.measure_le_Inf measure_theory.measure.measure_le_Inf\n\ninstance [MeasurableSpace α] : CompleteSemilatticeInf (Measure α) :=\n  { (by infer_instance : PartialOrder (Measure α)),\n    (by infer_instance :\n      InfSet (Measure α)) with\n    inf_le := fun s a => measure_infₛ_le\n    le_inf := fun s a => measure_le_infₛ }\n\ninstance [MeasurableSpace α] : CompleteLattice (Measure α) :=\n  {/- Adding an explicit `top` makes `leanchecker` fail, see lean#364, disable for now\n      \n        top := (⊤ : outer_measure α).to_measure (by rw [outer_measure.top_caratheodory]; exact le_top),\n        le_top := λ a s hs,\n          by cases s.eq_empty_or_nonempty with h  h;\n            simp [h, to_measure_apply ⊤ _ hs, outer_measure.top_apply],\n      -/\n      completeLatticeOfCompleteSemilatticeInf\n      (Measure α) with\n    bot := 0\n    bot_le := fun a s hs => bot_le }\n\nend Inf\n\n@[simp]\ntheorem top_add : ⊤ + μ = ⊤ :=\n  top_unique <| Measure.le_add_right le_rfl\n#align measure_theory.measure.top_add MeasureTheory.Measure.top_add\n\n@[simp]\ntheorem add_top : μ + ⊤ = ⊤ :=\n  top_unique <| Measure.le_add_left le_rfl\n#align measure_theory.measure.add_top MeasureTheory.Measure.add_top\n\nprotected theorem zero_le {m0 : MeasurableSpace α} (μ : Measure α) : 0 ≤ μ :=\n  bot_le\n#align measure_theory.measure.zero_le MeasureTheory.Measure.zero_le\n\ntheorem nonpos_iff_eq_zero' : μ ≤ 0 ↔ μ = 0 :=\n  μ.zero_le.le_iff_eq\n#align measure_theory.measure.nonpos_iff_eq_zero' MeasureTheory.Measure.nonpos_iff_eq_zero'\n\n@[simp]\ntheorem measure_univ_eq_zero : μ univ = 0 ↔ μ = 0 :=\n  ⟨fun h => bot_unique fun s hs => trans_rel_left (· ≤ ·) (measure_mono (subset_univ s)) h, fun h =>\n    h.symm ▸ rfl⟩\n#align measure_theory.measure.measure_univ_eq_zero MeasureTheory.Measure.measure_univ_eq_zero\n\n/-! ### Pushforward and pullback -/\n\n\n/-- Lift a linear map between `outer_measure` spaces such that for each measure `μ` every measurable\nset is caratheodory-measurable w.r.t. `f μ` to a linear map between `measure` spaces. -/\ndef liftLinear {m0 : MeasurableSpace α} (f : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β)\n    (hf : ∀ μ : Measure α, ‹_› ≤ (f μ.toOuterMeasure).caratheodory) : Measure α →ₗ[ℝ≥0∞] Measure β\n    where\n  toFun μ := (f μ.toOuterMeasure).toMeasure (hf μ)\n  map_add' μ₁ μ₂ := ext fun s hs => by simp [hs]\n  map_smul' c μ := ext fun s hs => by simp [hs]\n#align measure_theory.measure.lift_linear MeasureTheory.Measure.liftLinear\n\n@[simp]\ntheorem liftLinear_apply {f : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β} (hf) {s : Set β}\n    (hs : MeasurableSet s) : liftLinear f hf μ s = f μ.toOuterMeasure s :=\n  toMeasure_apply _ _ hs\n#align measure_theory.measure.lift_linear_apply MeasureTheory.Measure.liftLinear_apply\n\ntheorem le_liftLinear_apply {f : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β} (hf) (s : Set β) :\n    f μ.toOuterMeasure s ≤ liftLinear f hf μ s :=\n  le_toMeasure_apply _ _ s\n#align measure_theory.measure.le_lift_linear_apply MeasureTheory.Measure.le_liftLinear_apply\n\n/-- The pushforward of a measure as a linear map. It is defined to be `0` if `f` is not\na measurable function. -/\ndef mapₗ [MeasurableSpace α] (f : α → β) : Measure α →ₗ[ℝ≥0∞] Measure β :=\n  if hf : Measurable f then\n    liftLinear (OuterMeasure.map f) fun μ s hs t =>\n      le_toOuterMeasure_caratheodory μ _ (hf hs) (f ⁻¹' t)\n  else 0\n#align measure_theory.measure.mapₗ MeasureTheory.Measure.mapₗ\n\ntheorem mapₗ_congr {f g : α → β} (hf : Measurable f) (hg : Measurable g) (h : f =ᵐ[μ] g) :\n    mapₗ f μ = mapₗ g μ := by\n  ext1 s hs\n  simpa only [mapₗ, hf, hg, hs, dif_pos, lift_linear_apply, outer_measure.map_apply,\n    coe_to_outer_measure] using measure_congr (h.preimage s)\n#align measure_theory.measure.mapₗ_congr MeasureTheory.Measure.mapₗ_congr\n\n/-- The pushforward of a measure. It is defined to be `0` if `f` is not an almost everywhere\nmeasurable function. -/\nirreducible_def map [MeasurableSpace α] (f : α → β) (μ : Measure α) : Measure β :=\n  if hf : AeMeasurable f μ then mapₗ (hf.mk f) μ else 0\n#align measure_theory.measure.map MeasureTheory.Measure.map\n\ninclude m0\n\ntheorem mapₗ_mk_apply_of_aeMeasurable {f : α → β} (hf : AeMeasurable f μ) :\n    mapₗ (hf.mk f) μ = map f μ := by simp [map, hf]\n#align measure_theory.measure.mapₗ_mk_apply_of_ae_measurable MeasureTheory.Measure.mapₗ_mk_apply_of_aeMeasurable\n\ntheorem mapₗ_apply_of_measurable {f : α → β} (hf : Measurable f) (μ : Measure α) :\n    mapₗ f μ = map f μ :=\n  by\n  simp only [← mapₗ_mk_apply_of_ae_measurable hf.ae_measurable]\n  exact mapₗ_congr hf hf.ae_measurable.measurable_mk hf.ae_measurable.ae_eq_mk\n#align measure_theory.measure.mapₗ_apply_of_measurable MeasureTheory.Measure.mapₗ_apply_of_measurable\n\n@[simp]\ntheorem map_add (μ ν : Measure α) {f : α → β} (hf : Measurable f) :\n    (μ + ν).map f = μ.map f + ν.map f := by simp [← mapₗ_apply_of_measurable hf]\n#align measure_theory.measure.map_add MeasureTheory.Measure.map_add\n\n@[simp]\ntheorem map_zero (f : α → β) : (0 : Measure α).map f = 0 := by\n  by_cases hf : AeMeasurable f (0 : Measure α) <;> simp [map, hf]\n#align measure_theory.measure.map_zero MeasureTheory.Measure.map_zero\n\ntheorem map_of_not_aeMeasurable {f : α → β} {μ : Measure α} (hf : ¬AeMeasurable f μ) :\n    μ.map f = 0 := by simp [map, hf]\n#align measure_theory.measure.map_of_not_ae_measurable MeasureTheory.Measure.map_of_not_aeMeasurable\n\ntheorem map_congr {f g : α → β} (h : f =ᵐ[μ] g) : Measure.map f μ = Measure.map g μ :=\n  by\n  by_cases hf : AeMeasurable f μ\n  · have hg : AeMeasurable g μ := hf.congr h\n    simp only [← mapₗ_mk_apply_of_ae_measurable hf, ← mapₗ_mk_apply_of_ae_measurable hg]\n    exact\n      mapₗ_congr hf.measurable_mk hg.measurable_mk (hf.ae_eq_mk.symm.trans (h.trans hg.ae_eq_mk))\n  · have hg : ¬AeMeasurable g μ := by simpa [← aeMeasurable_congr h] using hf\n    simp [map_of_not_ae_measurable, hf, hg]\n#align measure_theory.measure.map_congr MeasureTheory.Measure.map_congr\n\n@[simp]\nprotected theorem map_smul (c : ℝ≥0∞) (μ : Measure α) (f : α → β) : (c • μ).map f = c • μ.map f :=\n  by\n  rcases eq_or_ne c 0 with (rfl | hc); · simp\n  by_cases hf : AeMeasurable f μ\n  · have hfc : AeMeasurable f (c • μ) :=\n      ⟨hf.mk f, hf.measurable_mk, (ae_smul_measure_iff hc).2 hf.ae_eq_mk⟩\n    simp only [← mapₗ_mk_apply_of_ae_measurable hf, ← mapₗ_mk_apply_of_ae_measurable hfc,\n      LinearMap.map_smulₛₗ, RingHom.id_apply]\n    congr 1\n    apply mapₗ_congr hfc.measurable_mk hf.measurable_mk\n    exact eventually_eq.trans ((ae_smul_measure_iff hc).1 hfc.ae_eq_mk.symm) hf.ae_eq_mk\n  · have hfc : ¬AeMeasurable f (c • μ) := by\n      intro hfc\n      exact hf ⟨hfc.mk f, hfc.measurable_mk, (ae_smul_measure_iff hc).1 hfc.ae_eq_mk⟩\n    simp [map_of_not_ae_measurable hf, map_of_not_ae_measurable hfc]\n#align measure_theory.measure.map_smul MeasureTheory.Measure.map_smul\n\n@[simp]\nprotected theorem map_smul_nNReal (c : ℝ≥0) (μ : Measure α) (f : α → β) :\n    (c • μ).map f = c • μ.map f :=\n  μ.map_smul (c : ℝ≥0∞) f\n#align measure_theory.measure.map_smul_nnreal MeasureTheory.Measure.map_smul_nNReal\n\n/-- We can evaluate the pushforward on measurable sets. For non-measurable sets, see\n  `measure_theory.measure.le_map_apply` and `measurable_equiv.map_apply`. -/\n@[simp]\ntheorem map_apply_of_aeMeasurable {f : α → β} (hf : AeMeasurable f μ) {s : Set β}\n    (hs : MeasurableSet s) : μ.map f s = μ (f ⁻¹' s) := by\n  simpa only [mapₗ, hf.measurable_mk, hs, dif_pos, lift_linear_apply, outer_measure.map_apply,\n    coe_to_outer_measure, ← mapₗ_mk_apply_of_ae_measurable hf] using\n    measure_congr (hf.ae_eq_mk.symm.preimage s)\n#align measure_theory.measure.map_apply_of_ae_measurable MeasureTheory.Measure.map_apply_of_aeMeasurable\n\n@[simp]\ntheorem map_apply {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :\n    μ.map f s = μ (f ⁻¹' s) :=\n  map_apply_of_aeMeasurable hf.AeMeasurable hs\n#align measure_theory.measure.map_apply MeasureTheory.Measure.map_apply\n\ntheorem map_toOuterMeasure {f : α → β} (hf : AeMeasurable f μ) :\n    (μ.map f).toOuterMeasure = (OuterMeasure.map f μ.toOuterMeasure).trim :=\n  by\n  rw [← trimmed, outer_measure.trim_eq_trim_iff]\n  intro s hs\n  rw [coe_to_outer_measure, map_apply_of_ae_measurable hf hs, outer_measure.map_apply,\n    coe_to_outer_measure]\n#align measure_theory.measure.map_to_outer_measure MeasureTheory.Measure.map_toOuterMeasure\n\n@[simp]\ntheorem map_id : map id μ = μ :=\n  ext fun s => map_apply measurable_id\n#align measure_theory.measure.map_id MeasureTheory.Measure.map_id\n\n@[simp]\ntheorem map_id' : map (fun x => x) μ = μ :=\n  map_id\n#align measure_theory.measure.map_id' MeasureTheory.Measure.map_id'\n\ntheorem map_map {g : β → γ} {f : α → β} (hg : Measurable g) (hf : Measurable f) :\n    (μ.map f).map g = μ.map (g ∘ f) :=\n  ext fun s hs => by simp [hf, hg, hs, hg hs, hg.comp hf, ← preimage_comp]\n#align measure_theory.measure.map_map MeasureTheory.Measure.map_map\n\n@[mono]\ntheorem map_mono {f : α → β} (h : μ ≤ ν) (hf : Measurable f) : μ.map f ≤ ν.map f := fun s hs => by\n  simp [hf.ae_measurable, hs, h _ (hf hs)]\n#align measure_theory.measure.map_mono MeasureTheory.Measure.map_mono\n\n/-- Even if `s` is not measurable, we can bound `map f μ s` from below.\n  See also `measurable_equiv.map_apply`. -/\ntheorem le_map_apply {f : α → β} (hf : AeMeasurable f μ) (s : Set β) : μ (f ⁻¹' s) ≤ μ.map f s :=\n  calc\n    μ (f ⁻¹' s) ≤ μ (f ⁻¹' toMeasurable (μ.map f) s) :=\n      measure_mono <| preimage_mono <| subset_toMeasurable _ _\n    _ = μ.map f (toMeasurable (μ.map f) s) :=\n      (map_apply_of_aeMeasurable hf <| measurableSet_toMeasurable _ _).symm\n    _ = μ.map f s := measure_toMeasurable _\n    \n#align measure_theory.measure.le_map_apply MeasureTheory.Measure.le_map_apply\n\n/-- Even if `s` is not measurable, `map f μ s = 0` implies that `μ (f ⁻¹' s) = 0`. -/\ntheorem preimage_null_of_map_null {f : α → β} (hf : AeMeasurable f μ) {s : Set β}\n    (hs : μ.map f s = 0) : μ (f ⁻¹' s) = 0 :=\n  nonpos_iff_eq_zero.mp <| (le_map_apply hf s).trans_eq hs\n#align measure_theory.measure.preimage_null_of_map_null MeasureTheory.Measure.preimage_null_of_map_null\n\ntheorem tendsto_ae_map {f : α → β} (hf : AeMeasurable f μ) : Tendsto f μ.ae (μ.map f).ae :=\n  fun s hs => preimage_null_of_map_null hf hs\n#align measure_theory.measure.tendsto_ae_map MeasureTheory.Measure.tendsto_ae_map\n\nomit m0\n\n/-- Pullback of a `measure` as a linear map. If `f` sends each measurable set to a measurable\nset, then for each measurable set `s` we have `comapₗ f μ s = μ (f '' s)`.\n\nIf the linearity is not needed, please use `comap` instead, which works for a larger class of\nfunctions. -/\ndef comapₗ [MeasurableSpace α] (f : α → β) : Measure β →ₗ[ℝ≥0∞] Measure α :=\n  if hf : Injective f ∧ ∀ s, MeasurableSet s → MeasurableSet (f '' s) then\n    liftLinear (OuterMeasure.comap f) fun μ s hs t =>\n      by\n      simp only [coe_to_outer_measure, outer_measure.comap_apply, image_inter hf.1, image_diff hf.1]\n      apply le_to_outer_measure_caratheodory\n      exact hf.2 s hs\n  else 0\n#align measure_theory.measure.comapₗ MeasureTheory.Measure.comapₗ\n\ntheorem comapₗ_apply {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β)\n    (hfi : Injective f) (hf : ∀ s, MeasurableSet s → MeasurableSet (f '' s)) (μ : Measure β)\n    (hs : MeasurableSet s) : comapₗ f μ s = μ (f '' s) :=\n  by\n  rw [comapₗ, dif_pos, lift_linear_apply _ hs, outer_measure.comap_apply, coe_to_outer_measure]\n  exact ⟨hfi, hf⟩\n#align measure_theory.measure.comapₗ_apply MeasureTheory.Measure.comapₗ_apply\n\n/-- Pullback of a `measure`. If `f` sends each measurable set to a null-measurable set,\nthen for each measurable set `s` we have `comap f μ s = μ (f '' s)`. -/\ndef comap [MeasurableSpace α] (f : α → β) (μ : Measure β) : Measure α :=\n  if hf : Injective f ∧ ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ then\n    (OuterMeasure.comap f μ.toOuterMeasure).toMeasure fun s hs t =>\n      by\n      simp only [coe_to_outer_measure, outer_measure.comap_apply, image_inter hf.1, image_diff hf.1]\n      exact (measure_inter_add_diff₀ _ (hf.2 s hs)).symm\n  else 0\n#align measure_theory.measure.comap MeasureTheory.Measure.comap\n\ntheorem comap_apply₀ [MeasurableSpace α] (f : α → β) (μ : Measure β) (hfi : Injective f)\n    (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ)\n    (hs : NullMeasurableSet s (comap f μ)) : comap f μ s = μ (f '' s) :=\n  by\n  rw [comap, dif_pos (And.intro hfi hf)] at hs⊢\n  rw [to_measure_apply₀ _ _ hs, outer_measure.comap_apply, coe_to_outer_measure]\n#align measure_theory.measure.comap_apply₀ MeasureTheory.Measure.comap_apply₀\n\ntheorem le_comap_apply {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β) (μ : Measure β)\n    (hfi : Injective f) (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ) (s : Set α) :\n    μ (f '' s) ≤ comap f μ s :=\n  by\n  rw [comap, dif_pos (And.intro hfi hf)]\n  exact le_to_measure_apply _ _ _\n#align measure_theory.measure.le_comap_apply MeasureTheory.Measure.le_comap_apply\n\ntheorem comap_apply {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β) (hfi : Injective f)\n    (hf : ∀ s, MeasurableSet s → MeasurableSet (f '' s)) (μ : Measure β) (hs : MeasurableSet s) :\n    comap f μ s = μ (f '' s) :=\n  comap_apply₀ f μ hfi (fun s hs => (hf s hs).NullMeasurableSet) hs.NullMeasurableSet\n#align measure_theory.measure.comap_apply MeasureTheory.Measure.comap_apply\n\ntheorem comapₗ_eq_comap {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β)\n    (hfi : Injective f) (hf : ∀ s, MeasurableSet s → MeasurableSet (f '' s)) (μ : Measure β)\n    (hs : MeasurableSet s) : comapₗ f μ s = comap f μ s :=\n  (comapₗ_apply f hfi hf μ hs).trans (comap_apply f hfi hf μ hs).symm\n#align measure_theory.measure.comapₗ_eq_comap MeasureTheory.Measure.comapₗ_eq_comap\n\ntheorem measure_image_eq_zero_of_comap_eq_zero {β} [MeasurableSpace α] {mβ : MeasurableSpace β}\n    (f : α → β) (μ : Measure β) (hfi : Injective f)\n    (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ) {s : Set α} (hs : comap f μ s = 0) :\n    μ (f '' s) = 0 :=\n  le_antisymm ((le_comap_apply f μ hfi hf s).trans hs.le) (zero_le _)\n#align measure_theory.measure.measure_image_eq_zero_of_comap_eq_zero MeasureTheory.Measure.measure_image_eq_zero_of_comap_eq_zero\n\ntheorem ae_eq_image_of_ae_eq_comap {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β)\n    (μ : Measure β) (hfi : Injective f) (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ)\n    {s t : Set α} (hst : s =ᵐ[comap f μ] t) : f '' s =ᵐ[μ] f '' t :=\n  by\n  rw [eventually_eq, ae_iff] at hst⊢\n  have h_eq_α : { a : α | ¬s a = t a } = s \\ t ∪ t \\ s :=\n    by\n    ext1 x\n    simp only [eq_iff_iff, mem_set_of_eq, mem_union, mem_diff]\n    tauto\n  have h_eq_β : { a : β | ¬(f '' s) a = (f '' t) a } = f '' s \\ f '' t ∪ f '' t \\ f '' s :=\n    by\n    ext1 x\n    simp only [eq_iff_iff, mem_set_of_eq, mem_union, mem_diff]\n    tauto\n  rw [← Set.image_diff hfi, ← Set.image_diff hfi, ← Set.image_union] at h_eq_β\n  rw [h_eq_β]\n  rw [h_eq_α] at hst\n  exact measure_image_eq_zero_of_comap_eq_zero f μ hfi hf hst\n#align measure_theory.measure.ae_eq_image_of_ae_eq_comap MeasureTheory.Measure.ae_eq_image_of_ae_eq_comap\n\ntheorem NullMeasurableSet.image {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β)\n    (μ : Measure β) (hfi : Injective f) (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ)\n    {s : Set α} (hs : NullMeasurableSet s (μ.comap f)) : NullMeasurableSet (f '' s) μ :=\n  by\n  refine' ⟨to_measurable μ (f '' to_measurable (μ.comap f) s), measurable_set_to_measurable _ _, _⟩\n  refine' eventually_eq.trans _ (null_measurable_set.to_measurable_ae_eq _).symm\n  swap\n  · exact hf _ (measurable_set_to_measurable _ _)\n  have h : to_measurable (comap f μ) s =ᵐ[comap f μ] s :=\n    @null_measurable_set.to_measurable_ae_eq _ _ (μ.comap f : Measure α) s hs\n  exact ae_eq_image_of_ae_eq_comap f μ hfi hf h.symm\n#align measure_theory.measure.null_measurable_set.image MeasureTheory.Measure.NullMeasurableSet.image\n\ntheorem comap_preimage {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β) (μ : Measure β)\n    {s : Set β} (hf : Injective f) (hf' : Measurable f)\n    (h : ∀ t, MeasurableSet t → NullMeasurableSet (f '' t) μ) (hs : MeasurableSet s) :\n    μ.comap f (f ⁻¹' s) = μ (s ∩ range f) := by\n  rw [comap_apply₀ _ _ hf h (hf' hs).NullMeasurableSet, image_preimage_eq_inter_range]\n#align measure_theory.measure.comap_preimage MeasureTheory.Measure.comap_preimage\n\nsection Subtype\n\n/-! ### Subtype of a measure space -/\n\n\nsection ComapAnyMeasure\n\ntheorem MeasurableSet.nullMeasurableSetSubtypeCoe {t : Set s} (hs : NullMeasurableSet s μ)\n    (ht : MeasurableSet t) : NullMeasurableSet ((coe : s → α) '' t) μ :=\n  by\n  rw [Subtype.measurableSpace, comap_eq_generate_from] at ht\n  refine'\n    generate_from_induction (fun t : Set s => null_measurable_set (coe '' t) μ)\n      { t : Set s | ∃ s' : Set α, MeasurableSet s' ∧ coe ⁻¹' s' = t } _ _ _ _ ht\n  · rintro t' ⟨s', hs', rfl⟩\n    rw [Subtype.image_preimage_coe]\n    exact hs'.null_measurable_set.inter hs\n  · simp only [image_empty, null_measurable_set_empty]\n  · intro t'\n    simp only [← range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, set_of_mem_eq]\n    exact hs.diff\n  · intro f\n    rw [image_Union]\n    exact null_measurable_set.Union\n#align measure_theory.measure.measurable_set.null_measurable_set_subtype_coe MeasureTheory.Measure.MeasurableSet.nullMeasurableSetSubtypeCoe\n\ntheorem NullMeasurableSet.subtypeCoe {t : Set s} (hs : NullMeasurableSet s μ)\n    (ht : NullMeasurableSet t (μ.comap Subtype.val)) : NullMeasurableSet ((coe : s → α) '' t) μ :=\n  NullMeasurableSet.image coe μ Subtype.coe_injective\n    (fun t => MeasurableSet.nullMeasurableSetSubtypeCoe hs) ht\n#align measure_theory.measure.null_measurable_set.subtype_coe MeasureTheory.Measure.NullMeasurableSet.subtypeCoe\n\ntheorem measure_subtype_coe_le_comap (hs : NullMeasurableSet s μ) (t : Set s) :\n    μ ((coe : s → α) '' t) ≤ μ.comap Subtype.val t :=\n  le_comap_apply _ _ Subtype.coe_injective (fun t => MeasurableSet.nullMeasurableSetSubtypeCoe hs) _\n#align measure_theory.measure.measure_subtype_coe_le_comap MeasureTheory.Measure.measure_subtype_coe_le_comap\n\ntheorem measure_subtype_coe_eq_zero_of_comap_eq_zero (hs : NullMeasurableSet s μ) {t : Set s}\n    (ht : μ.comap Subtype.val t = 0) : μ ((coe : s → α) '' t) = 0 :=\n  eq_bot_iff.mpr <| (measure_subtype_coe_le_comap hs t).trans ht.le\n#align measure_theory.measure.measure_subtype_coe_eq_zero_of_comap_eq_zero MeasureTheory.Measure.measure_subtype_coe_eq_zero_of_comap_eq_zero\n\nend ComapAnyMeasure\n\nsection MeasureSpace\n\nvariable [MeasureSpace α] {p : α → Prop}\n\ninstance Subtype.measureSpace : MeasureSpace (Subtype p) :=\n  { Subtype.measurableSpace with volume := Measure.comap Subtype.val volume }\n#align measure_theory.measure.subtype.measure_space MeasureTheory.Measure.Subtype.measureSpace\n\ntheorem Subtype.volume_def : (volume : Measure s) = volume.comap Subtype.val :=\n  rfl\n#align measure_theory.measure.subtype.volume_def MeasureTheory.Measure.Subtype.volume_def\n\ntheorem Subtype.volume_univ (hs : NullMeasurableSet s) : volume (univ : Set s) = volume s :=\n  by\n  rw [subtype.volume_def, comap_apply₀ _ _ _ _ measurable_set.univ.null_measurable_set]\n  · congr\n    simp only [Subtype.val_eq_coe, image_univ, Subtype.range_coe_subtype, set_of_mem_eq]\n  · exact Subtype.coe_injective\n  · exact fun t => measurable_set.null_measurable_set_subtype_coe hs\n#align measure_theory.measure.subtype.volume_univ MeasureTheory.Measure.Subtype.volume_univ\n\ntheorem volume_subtype_coe_le_volume (hs : NullMeasurableSet s) (t : Set s) :\n    volume ((coe : s → α) '' t) ≤ volume t :=\n  measure_subtype_coe_le_comap hs t\n#align measure_theory.measure.volume_subtype_coe_le_volume MeasureTheory.Measure.volume_subtype_coe_le_volume\n\ntheorem volume_subtype_coe_eq_zero_of_volume_eq_zero (hs : NullMeasurableSet s) {t : Set s}\n    (ht : volume t = 0) : volume ((coe : s → α) '' t) = 0 :=\n  measure_subtype_coe_eq_zero_of_comap_eq_zero hs ht\n#align measure_theory.measure.volume_subtype_coe_eq_zero_of_volume_eq_zero MeasureTheory.Measure.volume_subtype_coe_eq_zero_of_volume_eq_zero\n\nend MeasureSpace\n\nend Subtype\n\n/-! ### Restricting a measure -/\n\n\n/-- Restrict a measure `μ` to a set `s` as an `ℝ≥0∞`-linear map. -/\ndef restrictₗ {m0 : MeasurableSpace α} (s : Set α) : Measure α →ₗ[ℝ≥0∞] Measure α :=\n  liftLinear (OuterMeasure.restrict s) fun μ s' hs' t =>\n    by\n    suffices μ (s ∩ t) = μ (s ∩ t ∩ s') + μ ((s ∩ t) \\ s') by\n      simpa [← Set.inter_assoc, Set.inter_comm _ s, ← inter_diff_assoc]\n    exact le_to_outer_measure_caratheodory _ _ hs' _\n#align measure_theory.measure.restrictₗ MeasureTheory.Measure.restrictₗ\n\n/-- Restrict a measure `μ` to a set `s`. -/\ndef restrict {m0 : MeasurableSpace α} (μ : Measure α) (s : Set α) : Measure α :=\n  restrictₗ s μ\n#align measure_theory.measure.restrict MeasureTheory.Measure.restrict\n\n@[simp]\ntheorem restrictₗ_apply {m0 : MeasurableSpace α} (s : Set α) (μ : Measure α) :\n    restrictₗ s μ = μ.restrict s :=\n  rfl\n#align measure_theory.measure.restrictₗ_apply MeasureTheory.Measure.restrictₗ_apply\n\n/-- This lemma shows that `restrict` and `to_outer_measure` commute. Note that the LHS has a\nrestrict on measures and the RHS has a restrict on outer measures. -/\ntheorem restrict_toOuterMeasure_eq_toOuterMeasure_restrict (h : MeasurableSet s) :\n    (μ.restrict s).toOuterMeasure = OuterMeasure.restrict s μ.toOuterMeasure := by\n  simp_rw [restrict, restrictₗ, lift_linear, LinearMap.coe_mk, to_measure_to_outer_measure,\n    outer_measure.restrict_trim h, μ.trimmed]\n#align measure_theory.measure.restrict_to_outer_measure_eq_to_outer_measure_restrict MeasureTheory.Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict\n\ntheorem restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : μ.restrict s t = μ (t ∩ s) :=\n  (toMeasure_apply₀ _ _ ht).trans <| by\n    simp only [coe_to_outer_measure, outer_measure.restrict_apply]\n#align measure_theory.measure.restrict_apply₀ MeasureTheory.Measure.restrict_apply₀\n\n/-- If `t` is a measurable set, then the measure of `t` with respect to the restriction of\n  the measure to `s` equals the outer measure of `t ∩ s`. An alternate version requiring that `s`\n  be measurable instead of `t` exists as `measure.restrict_apply'`. -/\n@[simp]\ntheorem restrict_apply (ht : MeasurableSet t) : μ.restrict s t = μ (t ∩ s) :=\n  restrict_apply₀ ht.NullMeasurableSet\n#align measure_theory.measure.restrict_apply MeasureTheory.Measure.restrict_apply\n\n/-- Restriction of a measure to a subset is monotone both in set and in measure. -/\ntheorem restrict_mono' {m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s')\n    (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := fun t ht =>\n  calc\n    μ.restrict s t = μ (t ∩ s) := restrict_apply ht\n    _ ≤ μ (t ∩ s') := (measure_mono_ae <| hs.mono fun x hx ⟨hxt, hxs⟩ => ⟨hxt, hx hxs⟩)\n    _ ≤ ν (t ∩ s') := (le_iff'.1 hμν (t ∩ s'))\n    _ = ν.restrict s' t := (restrict_apply ht).symm\n    \n#align measure_theory.measure.restrict_mono' MeasureTheory.Measure.restrict_mono'\n\n/-- Restriction of a measure to a subset is monotone both in set and in measure. -/\n@[mono]\ntheorem restrict_mono {m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄\n    (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' :=\n  restrict_mono' (ae_of_all _ hs) hμν\n#align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono\n\ntheorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t :=\n  restrict_mono' h (le_refl μ)\n#align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae\n\ntheorem restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t :=\n  le_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le)\n#align measure_theory.measure.restrict_congr_set MeasureTheory.Measure.restrict_congr_set\n\n/-- If `s` is a measurable set, then the outer measure of `t` with respect to the restriction of\nthe measure to `s` equals the outer measure of `t ∩ s`. This is an alternate version of\n`measure.restrict_apply`, requiring that `s` is measurable instead of `t`. -/\n@[simp]\ntheorem restrict_apply' (hs : MeasurableSet s) : μ.restrict s t = μ (t ∩ s) := by\n  rw [← coe_to_outer_measure, measure.restrict_to_outer_measure_eq_to_outer_measure_restrict hs,\n    outer_measure.restrict_apply s t _, coe_to_outer_measure]\n#align measure_theory.measure.restrict_apply' MeasureTheory.Measure.restrict_apply'\n\ntheorem restrict_apply₀' (hs : NullMeasurableSet s μ) : μ.restrict s t = μ (t ∩ s) := by\n  rw [← restrict_congr_set hs.to_measurable_ae_eq,\n    restrict_apply' (measurable_set_to_measurable _ _),\n    measure_congr ((ae_eq_refl t).inter hs.to_measurable_ae_eq)]\n#align measure_theory.measure.restrict_apply₀' MeasureTheory.Measure.restrict_apply₀'\n\ntheorem restrict_le_self : μ.restrict s ≤ μ := fun t ht =>\n  calc\n    μ.restrict s t = μ (t ∩ s) := restrict_apply ht\n    _ ≤ μ t := measure_mono <| inter_subset_left t s\n    \n#align measure_theory.measure.restrict_le_self MeasureTheory.Measure.restrict_le_self\n\nvariable (μ)\n\ntheorem restrict_eq_self (h : s ⊆ t) : μ.restrict t s = μ s :=\n  (le_iff'.1 restrict_le_self s).antisymm <|\n    calc\n      μ s ≤ μ (toMeasurable (μ.restrict t) s ∩ t) :=\n        measure_mono (subset_inter (subset_toMeasurable _ _) h)\n      _ = μ.restrict t s := by\n        rw [← restrict_apply (measurable_set_to_measurable _ _), measure_to_measurable]\n      \n#align measure_theory.measure.restrict_eq_self MeasureTheory.Measure.restrict_eq_self\n\n@[simp]\ntheorem restrict_apply_self (s : Set α) : (μ.restrict s) s = μ s :=\n  restrict_eq_self μ Subset.rfl\n#align measure_theory.measure.restrict_apply_self MeasureTheory.Measure.restrict_apply_self\n\nvariable {μ}\n\ntheorem restrict_apply_univ (s : Set α) : μ.restrict s univ = μ s := by\n  rw [restrict_apply MeasurableSet.univ, Set.univ_inter]\n#align measure_theory.measure.restrict_apply_univ MeasureTheory.Measure.restrict_apply_univ\n\ntheorem le_restrict_apply (s t : Set α) : μ (t ∩ s) ≤ μ.restrict s t :=\n  calc\n    μ (t ∩ s) = μ.restrict s (t ∩ s) := (restrict_eq_self μ (inter_subset_right _ _)).symm\n    _ ≤ μ.restrict s t := measure_mono (inter_subset_left _ _)\n    \n#align measure_theory.measure.le_restrict_apply MeasureTheory.Measure.le_restrict_apply\n\ntheorem restrict_apply_superset (h : s ⊆ t) : μ.restrict s t = μ s :=\n  ((measure_mono (subset_univ _)).trans_eq <| restrict_apply_univ _).antisymm\n    ((restrict_apply_self μ s).symm.trans_le <| measure_mono h)\n#align measure_theory.measure.restrict_apply_superset MeasureTheory.Measure.restrict_apply_superset\n\n@[simp]\ntheorem restrict_add {m0 : MeasurableSpace α} (μ ν : Measure α) (s : Set α) :\n    (μ + ν).restrict s = μ.restrict s + ν.restrict s :=\n  (restrictₗ s).map_add μ ν\n#align measure_theory.measure.restrict_add MeasureTheory.Measure.restrict_add\n\n@[simp]\ntheorem restrict_zero {m0 : MeasurableSpace α} (s : Set α) : (0 : Measure α).restrict s = 0 :=\n  (restrictₗ s).map_zero\n#align measure_theory.measure.restrict_zero MeasureTheory.Measure.restrict_zero\n\n@[simp]\ntheorem restrict_smul {m0 : MeasurableSpace α} (c : ℝ≥0∞) (μ : Measure α) (s : Set α) :\n    (c • μ).restrict s = c • μ.restrict s :=\n  (restrictₗ s).map_smul c μ\n#align measure_theory.measure.restrict_smul MeasureTheory.Measure.restrict_smul\n\ntheorem restrict_restrict₀ (hs : NullMeasurableSet s (μ.restrict t)) :\n    (μ.restrict t).restrict s = μ.restrict (s ∩ t) :=\n  ext fun u hu => by\n    simp only [Set.inter_assoc, restrict_apply hu,\n      restrict_apply₀ (hu.null_measurable_set.inter hs)]\n#align measure_theory.measure.restrict_restrict₀ MeasureTheory.Measure.restrict_restrict₀\n\n@[simp]\ntheorem restrict_restrict (hs : MeasurableSet s) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) :=\n  restrict_restrict₀ hs.NullMeasurableSet\n#align measure_theory.measure.restrict_restrict MeasureTheory.Measure.restrict_restrict\n\ntheorem restrict_restrict_of_subset (h : s ⊆ t) : (μ.restrict t).restrict s = μ.restrict s :=\n  by\n  ext1 u hu\n  rw [restrict_apply hu, restrict_apply hu, restrict_eq_self]\n  exact (inter_subset_right _ _).trans h\n#align measure_theory.measure.restrict_restrict_of_subset MeasureTheory.Measure.restrict_restrict_of_subset\n\ntheorem restrict_restrict₀' (ht : NullMeasurableSet t μ) :\n    (μ.restrict t).restrict s = μ.restrict (s ∩ t) :=\n  ext fun u hu => by simp only [restrict_apply hu, restrict_apply₀' ht, inter_assoc]\n#align measure_theory.measure.restrict_restrict₀' MeasureTheory.Measure.restrict_restrict₀'\n\ntheorem restrict_restrict' (ht : MeasurableSet t) :\n    (μ.restrict t).restrict s = μ.restrict (s ∩ t) :=\n  restrict_restrict₀' ht.NullMeasurableSet\n#align measure_theory.measure.restrict_restrict' MeasureTheory.Measure.restrict_restrict'\n\ntheorem restrict_comm (hs : MeasurableSet s) :\n    (μ.restrict t).restrict s = (μ.restrict s).restrict t := by\n  rw [restrict_restrict hs, restrict_restrict' hs, inter_comm]\n#align measure_theory.measure.restrict_comm MeasureTheory.Measure.restrict_comm\n\ntheorem restrict_apply_eq_zero (ht : MeasurableSet t) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by\n  rw [restrict_apply ht]\n#align measure_theory.measure.restrict_apply_eq_zero MeasureTheory.Measure.restrict_apply_eq_zero\n\ntheorem measure_inter_eq_zero_of_restrict (h : μ.restrict s t = 0) : μ (t ∩ s) = 0 :=\n  nonpos_iff_eq_zero.1 (h ▸ le_restrict_apply _ _)\n#align measure_theory.measure.measure_inter_eq_zero_of_restrict MeasureTheory.Measure.measure_inter_eq_zero_of_restrict\n\ntheorem restrict_apply_eq_zero' (hs : MeasurableSet s) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by\n  rw [restrict_apply' hs]\n#align measure_theory.measure.restrict_apply_eq_zero' MeasureTheory.Measure.restrict_apply_eq_zero'\n\n@[simp]\ntheorem restrict_eq_zero : μ.restrict s = 0 ↔ μ s = 0 := by\n  rw [← measure_univ_eq_zero, restrict_apply_univ]\n#align measure_theory.measure.restrict_eq_zero MeasureTheory.Measure.restrict_eq_zero\n\ntheorem restrict_zero_set {s : Set α} (h : μ s = 0) : μ.restrict s = 0 :=\n  restrict_eq_zero.2 h\n#align measure_theory.measure.restrict_zero_set MeasureTheory.Measure.restrict_zero_set\n\n@[simp]\ntheorem restrict_empty : μ.restrict ∅ = 0 :=\n  restrict_zero_set measure_empty\n#align measure_theory.measure.restrict_empty MeasureTheory.Measure.restrict_empty\n\n@[simp]\ntheorem restrict_univ : μ.restrict univ = μ :=\n  ext fun s hs => by simp [hs]\n#align measure_theory.measure.restrict_univ MeasureTheory.Measure.restrict_univ\n\ntheorem restrict_inter_add_diff₀ (s : Set α) (ht : NullMeasurableSet t μ) :\n    μ.restrict (s ∩ t) + μ.restrict (s \\ t) = μ.restrict s :=\n  by\n  ext1 u hu\n  simp only [add_apply, restrict_apply hu, ← inter_assoc, diff_eq]\n  exact measure_inter_add_diff₀ (u ∩ s) ht\n#align measure_theory.measure.restrict_inter_add_diff₀ MeasureTheory.Measure.restrict_inter_add_diff₀\n\ntheorem restrict_inter_add_diff (s : Set α) (ht : MeasurableSet t) :\n    μ.restrict (s ∩ t) + μ.restrict (s \\ t) = μ.restrict s :=\n  restrict_inter_add_diff₀ s ht.NullMeasurableSet\n#align measure_theory.measure.restrict_inter_add_diff MeasureTheory.Measure.restrict_inter_add_diff\n\ntheorem restrict_union_add_inter₀ (s : Set α) (ht : NullMeasurableSet t μ) :\n    μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t := by\n  rw [← restrict_inter_add_diff₀ (s ∪ t) ht, union_inter_cancel_right, union_diff_right, ←\n    restrict_inter_add_diff₀ s ht, add_comm, ← add_assoc, add_right_comm]\n#align measure_theory.measure.restrict_union_add_inter₀ MeasureTheory.Measure.restrict_union_add_inter₀\n\ntheorem restrict_union_add_inter (s : Set α) (ht : MeasurableSet t) :\n    μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t :=\n  restrict_union_add_inter₀ s ht.NullMeasurableSet\n#align measure_theory.measure.restrict_union_add_inter MeasureTheory.Measure.restrict_union_add_inter\n\ntheorem restrict_union_add_inter' (hs : MeasurableSet s) (t : Set α) :\n    μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t := by\n  simpa only [union_comm, inter_comm, add_comm] using restrict_union_add_inter t hs\n#align measure_theory.measure.restrict_union_add_inter' MeasureTheory.Measure.restrict_union_add_inter'\n\ntheorem restrict_union₀ (h : AeDisjoint μ s t) (ht : NullMeasurableSet t μ) :\n    μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t := by\n  simp [← restrict_union_add_inter₀ s ht, restrict_zero_set h]\n#align measure_theory.measure.restrict_union₀ MeasureTheory.Measure.restrict_union₀\n\ntheorem restrict_union (h : Disjoint s t) (ht : MeasurableSet t) :\n    μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t :=\n  restrict_union₀ h.AeDisjoint ht.NullMeasurableSet\n#align measure_theory.measure.restrict_union MeasureTheory.Measure.restrict_union\n\ntheorem restrict_union' (h : Disjoint s t) (hs : MeasurableSet s) :\n    μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t := by\n  rw [union_comm, restrict_union h.symm hs, add_comm]\n#align measure_theory.measure.restrict_union' MeasureTheory.Measure.restrict_union'\n\n@[simp]\ntheorem restrict_add_restrict_compl (hs : MeasurableSet s) : μ.restrict s + μ.restrict (sᶜ) = μ :=\n  by\n  rw [← restrict_union (@disjoint_compl_right (Set α) _ _) hs.compl, union_compl_self,\n    restrict_univ]\n#align measure_theory.measure.restrict_add_restrict_compl MeasureTheory.Measure.restrict_add_restrict_compl\n\n@[simp]\ntheorem restrict_compl_add_restrict (hs : MeasurableSet s) : μ.restrict (sᶜ) + μ.restrict s = μ :=\n  by rw [add_comm, restrict_add_restrict_compl hs]\n#align measure_theory.measure.restrict_compl_add_restrict MeasureTheory.Measure.restrict_compl_add_restrict\n\ntheorem restrict_union_le (s s' : Set α) : μ.restrict (s ∪ s') ≤ μ.restrict s + μ.restrict s' :=\n  by\n  intro t ht\n  suffices μ (t ∩ s ∪ t ∩ s') ≤ μ (t ∩ s) + μ (t ∩ s') by simpa [ht, inter_union_distrib_left]\n  apply measure_union_le\n#align measure_theory.measure.restrict_union_le MeasureTheory.Measure.restrict_union_le\n\ntheorem restrict_unionᵢ_apply_ae [Countable ι] {s : ι → Set α} (hd : Pairwise (AeDisjoint μ on s))\n    (hm : ∀ i, NullMeasurableSet (s i) μ) {t : Set α} (ht : MeasurableSet t) :\n    μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t :=\n  by\n  simp only [restrict_apply, ht, inter_Union]\n  exact\n    measure_Union₀ (hd.mono fun i j h => h.mono (inter_subset_right _ _) (inter_subset_right _ _))\n      fun i => ht.null_measurable_set.inter (hm i)\n#align measure_theory.measure.restrict_Union_apply_ae MeasureTheory.Measure.restrict_unionᵢ_apply_ae\n\ntheorem restrict_unionᵢ_apply [Countable ι] {s : ι → Set α} (hd : Pairwise (Disjoint on s))\n    (hm : ∀ i, MeasurableSet (s i)) {t : Set α} (ht : MeasurableSet t) :\n    μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t :=\n  restrict_unionᵢ_apply_ae hd.AeDisjoint (fun i => (hm i).NullMeasurableSet) ht\n#align measure_theory.measure.restrict_Union_apply MeasureTheory.Measure.restrict_unionᵢ_apply\n\ntheorem restrict_unionᵢ_apply_eq_supᵢ [Countable ι] {s : ι → Set α} (hd : Directed (· ⊆ ·) s)\n    {t : Set α} (ht : MeasurableSet t) : μ.restrict (⋃ i, s i) t = ⨆ i, μ.restrict (s i) t :=\n  by\n  simp only [restrict_apply ht, inter_Union]\n  rw [measure_Union_eq_supr]\n  exacts[hd.mono_comp _ fun s₁ s₂ => inter_subset_inter_right _]\n#align measure_theory.measure.restrict_Union_apply_eq_supr MeasureTheory.Measure.restrict_unionᵢ_apply_eq_supᵢ\n\n/-- The restriction of the pushforward measure is the pushforward of the restriction. For a version\nassuming only `ae_measurable`, see `restrict_map_of_ae_measurable`. -/\ntheorem restrict_map {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :\n    (μ.map f).restrict s = (μ.restrict <| f ⁻¹' s).map f :=\n  ext fun t ht => by simp [*, hf ht]\n#align measure_theory.measure.restrict_map MeasureTheory.Measure.restrict_map\n\ntheorem restrict_toMeasurable (h : μ s ≠ ∞) : μ.restrict (toMeasurable μ s) = μ.restrict s :=\n  ext fun t ht => by\n    rw [restrict_apply ht, restrict_apply ht, inter_comm, measure_to_measurable_inter ht h,\n      inter_comm]\n#align measure_theory.measure.restrict_to_measurable MeasureTheory.Measure.restrict_toMeasurable\n\ntheorem restrict_eq_self_of_ae_mem {m0 : MeasurableSpace α} ⦃s : Set α⦄ ⦃μ : Measure α⦄\n    (hs : ∀ᵐ x ∂μ, x ∈ s) : μ.restrict s = μ :=\n  calc\n    μ.restrict s = μ.restrict univ := restrict_congr_set (eventuallyEq_univ.mpr hs)\n    _ = μ := restrict_univ\n    \n#align measure_theory.measure.restrict_eq_self_of_ae_mem MeasureTheory.Measure.restrict_eq_self_of_ae_mem\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/\ntheorem restrict_congr_meas (hs : MeasurableSet s) :\n    μ.restrict s = ν.restrict s ↔ ∀ (t) (_ : t ⊆ s), MeasurableSet t → μ t = ν t :=\n  ⟨fun H t hts ht => by\n    rw [← inter_eq_self_of_subset_left hts, ← restrict_apply ht, H, restrict_apply ht], fun H =>\n    ext fun t ht => by\n      rw [restrict_apply ht, restrict_apply ht, H _ (inter_subset_right _ _) (ht.inter hs)]⟩\n#align measure_theory.measure.restrict_congr_meas MeasureTheory.Measure.restrict_congr_meas\n\ntheorem restrict_congr_mono (hs : s ⊆ t) (h : μ.restrict t = ν.restrict t) :\n    μ.restrict s = ν.restrict s := by\n  rw [← restrict_restrict_of_subset hs, h, restrict_restrict_of_subset hs]\n#align measure_theory.measure.restrict_congr_mono MeasureTheory.Measure.restrict_congr_mono\n\n/-- If two measures agree on all measurable subsets of `s` and `t`, then they agree on all\nmeasurable subsets of `s ∪ t`. -/\ntheorem restrict_union_congr :\n    μ.restrict (s ∪ t) = ν.restrict (s ∪ t) ↔\n      μ.restrict s = ν.restrict s ∧ μ.restrict t = ν.restrict t :=\n  by\n  refine'\n    ⟨fun h =>\n      ⟨restrict_congr_mono (subset_union_left _ _) h,\n        restrict_congr_mono (subset_union_right _ _) h⟩,\n      _⟩\n  rintro ⟨hs, ht⟩\n  ext1 u hu\n  simp only [restrict_apply hu, inter_union_distrib_left]\n  rcases exists_measurable_superset₂ μ ν (u ∩ s) with ⟨US, hsub, hm, hμ, hν⟩\n  calc\n    μ (u ∩ s ∪ u ∩ t) = μ (US ∪ u ∩ t) := measure_union_congr_of_subset hsub hμ.le subset.rfl le_rfl\n    _ = μ US + μ ((u ∩ t) \\ US) := (measure_add_diff hm _).symm\n    _ = restrict μ s u + restrict μ t (u \\ US) := by\n      simp only [restrict_apply, hu, hu.diff hm, hμ, ← inter_comm t, inter_diff_assoc]\n    _ = restrict ν s u + restrict ν t (u \\ US) := by rw [hs, ht]\n    _ = ν US + ν ((u ∩ t) \\ US) := by\n      simp only [restrict_apply, hu, hu.diff hm, hν, ← inter_comm t, inter_diff_assoc]\n    _ = ν (US ∪ u ∩ t) := (measure_add_diff hm _)\n    _ = ν (u ∩ s ∪ u ∩ t) := Eq.symm <| measure_union_congr_of_subset hsub hν.le subset.rfl le_rfl\n    \n#align measure_theory.measure.restrict_union_congr MeasureTheory.Measure.restrict_union_congr\n\ntheorem restrict_finset_bUnion_congr {s : Finset ι} {t : ι → Set α} :\n    μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔\n      ∀ i ∈ s, μ.restrict (t i) = ν.restrict (t i) :=\n  by\n  induction' s using Finset.induction_on with i s hi hs; · simp\n  simp only [forall_eq_or_imp, Union_Union_eq_or_left, Finset.mem_insert]\n  rw [restrict_union_congr, ← hs]\n#align measure_theory.measure.restrict_finset_bUnion_congr MeasureTheory.Measure.restrict_finset_bUnion_congr\n\ntheorem restrict_unionᵢ_congr [Countable ι] {s : ι → Set α} :\n    μ.restrict (⋃ i, s i) = ν.restrict (⋃ i, s i) ↔ ∀ i, μ.restrict (s i) = ν.restrict (s i) :=\n  by\n  refine' ⟨fun h i => restrict_congr_mono (subset_Union _ _) h, fun h => _⟩\n  ext1 t ht\n  have D : Directed (· ⊆ ·) fun t : Finset ι => ⋃ i ∈ t, s i :=\n    directed_of_sup fun t₁ t₂ ht => bUnion_subset_bUnion_left ht\n  rw [Union_eq_Union_finset]\n  simp only [restrict_Union_apply_eq_supr D ht, restrict_finset_bUnion_congr.2 fun i hi => h i]\n#align measure_theory.measure.restrict_Union_congr MeasureTheory.Measure.restrict_unionᵢ_congr\n\ntheorem restrict_bUnion_congr {s : Set ι} {t : ι → Set α} (hc : s.Countable) :\n    μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔\n      ∀ i ∈ s, μ.restrict (t i) = ν.restrict (t i) :=\n  by\n  haveI := hc.to_encodable\n  simp only [bUnion_eq_Union, SetCoe.forall', restrict_Union_congr]\n#align measure_theory.measure.restrict_bUnion_congr MeasureTheory.Measure.restrict_bUnion_congr\n\ntheorem restrict_unionₛ_congr {S : Set (Set α)} (hc : S.Countable) :\n    μ.restrict (⋃₀ S) = ν.restrict (⋃₀ S) ↔ ∀ s ∈ S, μ.restrict s = ν.restrict s := by\n  rw [sUnion_eq_bUnion, restrict_bUnion_congr hc]\n#align measure_theory.measure.restrict_sUnion_congr MeasureTheory.Measure.restrict_unionₛ_congr\n\n/-- This lemma shows that `Inf` and `restrict` commute for measures. -/\ntheorem restrict_infₛ_eq_infₛ_restrict {m0 : MeasurableSpace α} {m : Set (Measure α)}\n    (hm : m.Nonempty) (ht : MeasurableSet t) :\n    (infₛ m).restrict t = infₛ ((fun μ : Measure α => μ.restrict t) '' m) :=\n  by\n  ext1 s hs\n  simp_rw [infₛ_apply hs, restrict_apply hs, infₛ_apply (MeasurableSet.inter hs ht),\n    Set.image_image, restrict_to_outer_measure_eq_to_outer_measure_restrict ht, ←\n    Set.image_image _ to_outer_measure, ← outer_measure.restrict_Inf_eq_Inf_restrict _ (hm.image _),\n    outer_measure.restrict_apply]\n#align measure_theory.measure.restrict_Inf_eq_Inf_restrict MeasureTheory.Measure.restrict_infₛ_eq_infₛ_restrict\n\ntheorem exists_mem_of_measure_ne_zero_of_ae (hs : μ s ≠ 0) {p : α → Prop}\n    (hp : ∀ᵐ x ∂μ.restrict s, p x) : ∃ x, x ∈ s ∧ p x :=\n  by\n  rw [← μ.restrict_apply_self, ← frequently_ae_mem_iff] at hs\n  exact (hs.and_eventually hp).exists\n#align measure_theory.measure.exists_mem_of_measure_ne_zero_of_ae MeasureTheory.Measure.exists_mem_of_measure_ne_zero_of_ae\n\n/-! ### Extensionality results -/\n\n\n/-- Two measures are equal if they have equal restrictions on a spanning collection of sets\n  (formulated using `Union`). -/\ntheorem ext_iff_of_unionᵢ_eq_univ [Countable ι] {s : ι → Set α} (hs : (⋃ i, s i) = univ) :\n    μ = ν ↔ ∀ i, μ.restrict (s i) = ν.restrict (s i) := by\n  rw [← restrict_Union_congr, hs, restrict_univ, restrict_univ]\n#align measure_theory.measure.ext_iff_of_Union_eq_univ MeasureTheory.Measure.ext_iff_of_unionᵢ_eq_univ\n\nalias ext_iff_of_Union_eq_univ ↔ _ ext_of_Union_eq_univ\n#align measure_theory.measure.ext_of_Union_eq_univ MeasureTheory.Measure.ext_of_unionᵢ_eq_univ\n\n/-- Two measures are equal if they have equal restrictions on a spanning collection of sets\n  (formulated using `bUnion`). -/\ntheorem ext_iff_of_bUnion_eq_univ {S : Set ι} {s : ι → Set α} (hc : S.Countable)\n    (hs : (⋃ i ∈ S, s i) = univ) : μ = ν ↔ ∀ i ∈ S, μ.restrict (s i) = ν.restrict (s i) := by\n  rw [← restrict_bUnion_congr hc, hs, restrict_univ, restrict_univ]\n#align measure_theory.measure.ext_iff_of_bUnion_eq_univ MeasureTheory.Measure.ext_iff_of_bUnion_eq_univ\n\nalias ext_iff_of_bUnion_eq_univ ↔ _ ext_of_bUnion_eq_univ\n#align measure_theory.measure.ext_of_bUnion_eq_univ MeasureTheory.Measure.ext_of_bUnion_eq_univ\n\n/-- Two measures are equal if they have equal restrictions on a spanning collection of sets\n  (formulated using `sUnion`). -/\ntheorem ext_iff_of_unionₛ_eq_univ {S : Set (Set α)} (hc : S.Countable) (hs : ⋃₀ S = univ) :\n    μ = ν ↔ ∀ s ∈ S, μ.restrict s = ν.restrict s :=\n  ext_iff_of_bUnion_eq_univ hc <| by rwa [← sUnion_eq_bUnion]\n#align measure_theory.measure.ext_iff_of_sUnion_eq_univ MeasureTheory.Measure.ext_iff_of_unionₛ_eq_univ\n\nalias ext_iff_of_sUnion_eq_univ ↔ _ ext_of_sUnion_eq_univ\n#align measure_theory.measure.ext_of_sUnion_eq_univ MeasureTheory.Measure.ext_of_unionₛ_eq_univ\n\ntheorem ext_of_generateFrom_of_cover {S T : Set (Set α)} (h_gen : ‹_› = generateFrom S)\n    (hc : T.Countable) (h_inter : IsPiSystem S) (hU : ⋃₀ T = univ) (htop : ∀ t ∈ T, μ t ≠ ∞)\n    (ST_eq : ∀ t ∈ T, ∀ s ∈ S, μ (s ∩ t) = ν (s ∩ t)) (T_eq : ∀ t ∈ T, μ t = ν t) : μ = ν :=\n  by\n  refine' ext_of_sUnion_eq_univ hc hU fun t ht => _\n  ext1 u hu\n  simp only [restrict_apply hu]\n  refine' induction_on_inter h_gen h_inter _ (ST_eq t ht) _ _ hu\n  · simp only [Set.empty_inter, measure_empty]\n  · intro v hv hvt\n    have := T_eq t ht\n    rw [Set.inter_comm] at hvt⊢\n    rwa [← measure_inter_add_diff t hv, ← measure_inter_add_diff t hv, ← hvt,\n      ENNReal.add_right_inj] at this\n    exact ne_top_of_le_ne_top (htop t ht) (measure_mono <| Set.inter_subset_left _ _)\n  · intro f hfd hfm h_eq\n    simp only [← restrict_apply (hfm _), ← restrict_apply (MeasurableSet.unionᵢ hfm)] at h_eq⊢\n    simp only [measure_Union hfd hfm, h_eq]\n#align measure_theory.measure.ext_of_generate_from_of_cover MeasureTheory.Measure.ext_of_generateFrom_of_cover\n\n/-- Two measures are equal if they are equal on the π-system generating the σ-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the π-system.\n  This lemma is formulated using `sUnion`. -/\ntheorem ext_of_generateFrom_of_cover_subset {S T : Set (Set α)} (h_gen : ‹_› = generateFrom S)\n    (h_inter : IsPiSystem S) (h_sub : T ⊆ S) (hc : T.Countable) (hU : ⋃₀ T = univ)\n    (htop : ∀ s ∈ T, μ s ≠ ∞) (h_eq : ∀ s ∈ S, μ s = ν s) : μ = ν :=\n  by\n  refine' ext_of_generate_from_of_cover h_gen hc h_inter hU htop _ fun t ht => h_eq t (h_sub ht)\n  intro t ht s hs; cases' (s ∩ t).eq_empty_or_nonempty with H H\n  · simp only [H, measure_empty]\n  · exact h_eq _ (h_inter _ hs _ (h_sub ht) H)\n#align measure_theory.measure.ext_of_generate_from_of_cover_subset MeasureTheory.Measure.ext_of_generateFrom_of_cover_subset\n\n/-- Two measures are equal if they are equal on the π-system generating the σ-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the π-system.\n  This lemma is formulated using `Union`.\n  `finite_spanning_sets_in.ext` is a reformulation of this lemma. -/\ntheorem ext_of_generateFrom_of_unionᵢ (C : Set (Set α)) (B : ℕ → Set α) (hA : ‹_› = generateFrom C)\n    (hC : IsPiSystem C) (h1B : (⋃ i, B i) = univ) (h2B : ∀ i, B i ∈ C) (hμB : ∀ i, μ (B i) ≠ ∞)\n    (h_eq : ∀ s ∈ C, μ s = ν s) : μ = ν :=\n  by\n  refine' ext_of_generate_from_of_cover_subset hA hC _ (countable_range B) h1B _ h_eq\n  · rintro _ ⟨i, rfl⟩\n    apply h2B\n  · rintro _ ⟨i, rfl⟩\n    apply hμB\n#align measure_theory.measure.ext_of_generate_from_of_Union MeasureTheory.Measure.ext_of_generateFrom_of_unionᵢ\n\nsection Dirac\n\nvariable [MeasurableSpace α]\n\n/-- The dirac measure. -/\ndef dirac (a : α) : Measure α :=\n  (OuterMeasure.dirac a).toMeasure (by simp)\n#align measure_theory.measure.dirac MeasureTheory.Measure.dirac\n\ninstance : MeasureSpace PUnit :=\n  ⟨dirac PUnit.unit⟩\n\ntheorem le_dirac_apply {a} : s.indicator 1 a ≤ dirac a s :=\n  OuterMeasure.dirac_apply a s ▸ le_toMeasure_apply _ _ _\n#align measure_theory.measure.le_dirac_apply MeasureTheory.Measure.le_dirac_apply\n\n@[simp]\ntheorem dirac_apply' (a : α) (hs : MeasurableSet s) : dirac a s = s.indicator 1 a :=\n  toMeasure_apply _ _ hs\n#align measure_theory.measure.dirac_apply' MeasureTheory.Measure.dirac_apply'\n\n@[simp]\ntheorem dirac_apply_of_mem {a : α} (h : a ∈ s) : dirac a s = 1 :=\n  by\n  have : ∀ t : Set α, a ∈ t → t.indicator (1 : α → ℝ≥0∞) a = 1 := fun t ht => indicator_of_mem ht 1\n  refine' le_antisymm (this univ trivial ▸ _) (this s h ▸ le_dirac_apply)\n  rw [← dirac_apply' a MeasurableSet.univ]\n  exact measure_mono (subset_univ s)\n#align measure_theory.measure.dirac_apply_of_mem MeasureTheory.Measure.dirac_apply_of_mem\n\n@[simp]\ntheorem dirac_apply [MeasurableSingletonClass α] (a : α) (s : Set α) :\n    dirac a s = s.indicator 1 a := by\n  by_cases h : a ∈ s; · rw [dirac_apply_of_mem h, indicator_of_mem h, Pi.one_apply]\n  rw [indicator_of_not_mem h, ← nonpos_iff_eq_zero]\n  calc\n    dirac a s ≤ dirac a ({a}ᶜ) := measure_mono (subset_compl_comm.1 <| singleton_subset_iff.2 h)\n    _ = 0 := by simp [dirac_apply' _ (measurable_set_singleton _).compl]\n    \n#align measure_theory.measure.dirac_apply MeasureTheory.Measure.dirac_apply\n\ntheorem map_dirac {f : α → β} (hf : Measurable f) (a : α) : (dirac a).map f = dirac (f a) :=\n  ext fun s hs => by simp [hs, map_apply hf hs, hf hs, indicator_apply]\n#align measure_theory.measure.map_dirac MeasureTheory.Measure.map_dirac\n\n@[simp]\ntheorem restrict_singleton (μ : Measure α) (a : α) : μ.restrict {a} = μ {a} • dirac a :=\n  by\n  ext1 s hs\n  by_cases ha : a ∈ s\n  · have : s ∩ {a} = {a} := by simpa\n    simp [*]\n  · have : s ∩ {a} = ∅ := inter_singleton_eq_empty.2 ha\n    simp [*]\n#align measure_theory.measure.restrict_singleton MeasureTheory.Measure.restrict_singleton\n\nend Dirac\n\nsection Sum\n\ninclude m0\n\n/-- Sum of an indexed family of measures. -/\ndef sum (f : ι → Measure α) : Measure α :=\n  (OuterMeasure.sum fun i => (f i).toOuterMeasure).toMeasure <|\n    le_trans (le_infᵢ fun i => le_to_outer_measure_caratheodory _)\n      (OuterMeasure.le_sum_caratheodory _)\n#align measure_theory.measure.sum MeasureTheory.Measure.sum\n\ntheorem le_sum_apply (f : ι → Measure α) (s : Set α) : (∑' i, f i s) ≤ sum f s :=\n  le_toMeasure_apply _ _ _\n#align measure_theory.measure.le_sum_apply MeasureTheory.Measure.le_sum_apply\n\n@[simp]\ntheorem sum_apply (f : ι → Measure α) {s : Set α} (hs : MeasurableSet s) : sum f s = ∑' i, f i s :=\n  toMeasure_apply _ _ hs\n#align measure_theory.measure.sum_apply MeasureTheory.Measure.sum_apply\n\ntheorem le_sum (μ : ι → Measure α) (i : ι) : μ i ≤ sum μ := fun s hs => by\n  simp only [sum_apply μ hs, ENNReal.le_tsum i]\n#align measure_theory.measure.le_sum MeasureTheory.Measure.le_sum\n\n@[simp]\ntheorem sum_apply_eq_zero [Countable ι] {μ : ι → Measure α} {s : Set α} :\n    sum μ s = 0 ↔ ∀ i, μ i s = 0 :=\n  by\n  refine'\n    ⟨fun h i => nonpos_iff_eq_zero.1 <| h ▸ le_iff'.1 (le_sum μ i) _, fun h =>\n      nonpos_iff_eq_zero.1 _⟩\n  rcases exists_measurable_superset_forall_eq μ s with ⟨t, hst, htm, ht⟩\n  calc\n    Sum μ s ≤ Sum μ t := measure_mono hst\n    _ = 0 := by simp [*]\n    \n#align measure_theory.measure.sum_apply_eq_zero MeasureTheory.Measure.sum_apply_eq_zero\n\ntheorem sum_apply_eq_zero' {μ : ι → Measure α} {s : Set α} (hs : MeasurableSet s) :\n    sum μ s = 0 ↔ ∀ i, μ i s = 0 := by simp [hs]\n#align measure_theory.measure.sum_apply_eq_zero' MeasureTheory.Measure.sum_apply_eq_zero'\n\ntheorem sum_comm {ι' : Type _} (μ : ι → ι' → Measure α) :\n    (sum fun n => sum (μ n)) = sum fun m => sum fun n => μ n m :=\n  by\n  ext1 s hs\n  simp_rw [sum_apply _ hs]\n  rw [ENNReal.tsum_comm]\n#align measure_theory.measure.sum_comm MeasureTheory.Measure.sum_comm\n\ntheorem ae_sum_iff [Countable ι] {μ : ι → Measure α} {p : α → Prop} :\n    (∀ᵐ x ∂sum μ, p x) ↔ ∀ i, ∀ᵐ x ∂μ i, p x :=\n  sum_apply_eq_zero\n#align measure_theory.measure.ae_sum_iff MeasureTheory.Measure.ae_sum_iff\n\ntheorem ae_sum_iff' {μ : ι → Measure α} {p : α → Prop} (h : MeasurableSet { x | p x }) :\n    (∀ᵐ x ∂sum μ, p x) ↔ ∀ i, ∀ᵐ x ∂μ i, p x :=\n  sum_apply_eq_zero' h.compl\n#align measure_theory.measure.ae_sum_iff' MeasureTheory.Measure.ae_sum_iff'\n\n@[simp]\ntheorem sum_fintype [Fintype ι] (μ : ι → Measure α) : sum μ = ∑ i, μ i :=\n  by\n  ext1 s hs\n  simp only [sum_apply, finset_sum_apply, hs, tsum_fintype]\n#align measure_theory.measure.sum_fintype MeasureTheory.Measure.sum_fintype\n\n@[simp]\ntheorem sum_coe_finset (s : Finset ι) (μ : ι → Measure α) :\n    (sum fun i : s => μ i) = ∑ i in s, μ i := by rw [sum_fintype, Finset.sum_coe_sort s μ]\n#align measure_theory.measure.sum_coe_finset MeasureTheory.Measure.sum_coe_finset\n\n@[simp]\ntheorem ae_sum_eq [Countable ι] (μ : ι → Measure α) : (sum μ).ae = ⨆ i, (μ i).ae :=\n  Filter.ext fun s => ae_sum_iff.trans mem_supᵢ.symm\n#align measure_theory.measure.ae_sum_eq MeasureTheory.Measure.ae_sum_eq\n\n@[simp]\ntheorem sum_bool (f : Bool → Measure α) : sum f = f true + f false := by\n  rw [sum_fintype, Fintype.sum_bool]\n#align measure_theory.measure.sum_bool MeasureTheory.Measure.sum_bool\n\n@[simp]\ntheorem sum_cond (μ ν : Measure α) : (sum fun b => cond b μ ν) = μ + ν :=\n  sum_bool _\n#align measure_theory.measure.sum_cond MeasureTheory.Measure.sum_cond\n\n@[simp]\ntheorem restrict_sum (μ : ι → Measure α) {s : Set α} (hs : MeasurableSet s) :\n    (sum μ).restrict s = sum fun i => (μ i).restrict s :=\n  ext fun t ht => by simp only [sum_apply, restrict_apply, ht, ht.inter hs]\n#align measure_theory.measure.restrict_sum MeasureTheory.Measure.restrict_sum\n\n@[simp]\ntheorem sum_of_empty [IsEmpty ι] (μ : ι → Measure α) : sum μ = 0 := by\n  rw [← measure_univ_eq_zero, sum_apply _ MeasurableSet.univ, tsum_empty]\n#align measure_theory.measure.sum_of_empty MeasureTheory.Measure.sum_of_empty\n\ntheorem sum_add_sum_compl (s : Set ι) (μ : ι → Measure α) :\n    ((sum fun i : s => μ i) + sum fun i : sᶜ => μ i) = sum μ :=\n  by\n  ext1 t ht\n  simp only [add_apply, sum_apply _ ht]\n  exact @tsum_add_tsum_compl ℝ≥0∞ ι _ _ _ (fun i => μ i t) _ s ENNReal.summable ENNReal.summable\n#align measure_theory.measure.sum_add_sum_compl MeasureTheory.Measure.sum_add_sum_compl\n\ntheorem sum_congr {μ ν : ℕ → Measure α} (h : ∀ n, μ n = ν n) : sum μ = sum ν :=\n  congr_arg sum (funext h)\n#align measure_theory.measure.sum_congr MeasureTheory.Measure.sum_congr\n\ntheorem sum_add_sum (μ ν : ℕ → Measure α) : sum μ + sum ν = sum fun n => μ n + ν n :=\n  by\n  ext1 s hs\n  simp only [add_apply, sum_apply _ hs, Pi.add_apply, coe_add,\n    tsum_add ENNReal.summable ENNReal.summable]\n#align measure_theory.measure.sum_add_sum MeasureTheory.Measure.sum_add_sum\n\n/-- If `f` is a map with countable codomain, then `μ.map f` is a sum of Dirac measures. -/\ntheorem map_eq_sum [Countable β] [MeasurableSingletonClass β] (μ : Measure α) (f : α → β)\n    (hf : Measurable f) : μ.map f = sum fun b : β => μ (f ⁻¹' {b}) • dirac b :=\n  by\n  ext1 s hs\n  have : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y}) := fun y _ => hf (measurable_set_singleton _)\n  simp [← tsum_measure_preimage_singleton (to_countable s) this, *,\n    tsum_subtype s fun b => μ (f ⁻¹' {b}), ← indicator_mul_right s fun b => μ (f ⁻¹' {b})]\n#align measure_theory.measure.map_eq_sum MeasureTheory.Measure.map_eq_sum\n\n/-- A measure on a countable type is a sum of Dirac measures. -/\n@[simp]\ntheorem sum_smul_dirac [Countable α] [MeasurableSingletonClass α] (μ : Measure α) :\n    (sum fun a => μ {a} • dirac a) = μ := by simpa using (map_eq_sum μ id measurable_id).symm\n#align measure_theory.measure.sum_smul_dirac MeasureTheory.Measure.sum_smul_dirac\n\n/-- Given that `α` is a countable, measurable space with all singleton sets measurable,\nwrite the measure of a set `s` as the sum of the measure of `{x}` for all `x ∈ s`. -/\ntheorem tsum_indicator_apply_singleton [Countable α] [MeasurableSingletonClass α] (μ : Measure α)\n    (s : Set α) (hs : MeasurableSet s) : (∑' x : α, s.indicator (fun x => μ {x}) x) = μ s :=\n  calc\n    (∑' x : α, s.indicator (fun x => μ {x}) x) = Measure.sum (fun a => μ {a} • Measure.dirac a) s :=\n      by\n      simp only [measure.sum_apply _ hs, measure.smul_apply, smul_eq_mul, measure.dirac_apply,\n        Set.indicator_apply, mul_ite, Pi.one_apply, mul_one, MulZeroClass.mul_zero]\n    _ = μ s := by rw [μ.sum_smul_dirac]\n    \n#align measure_theory.measure.tsum_indicator_apply_singleton MeasureTheory.Measure.tsum_indicator_apply_singleton\n\nomit m0\n\nend Sum\n\ntheorem restrict_unionᵢ_ae [Countable ι] {s : ι → Set α} (hd : Pairwise (AeDisjoint μ on s))\n    (hm : ∀ i, NullMeasurableSet (s i) μ) : μ.restrict (⋃ i, s i) = sum fun i => μ.restrict (s i) :=\n  ext fun t ht => by simp only [sum_apply _ ht, restrict_Union_apply_ae hd hm ht]\n#align measure_theory.measure.restrict_Union_ae MeasureTheory.Measure.restrict_unionᵢ_ae\n\ntheorem restrict_unionᵢ [Countable ι] {s : ι → Set α} (hd : Pairwise (Disjoint on s))\n    (hm : ∀ i, MeasurableSet (s i)) : μ.restrict (⋃ i, s i) = sum fun i => μ.restrict (s i) :=\n  restrict_unionᵢ_ae hd.AeDisjoint fun i => (hm i).NullMeasurableSet\n#align measure_theory.measure.restrict_Union MeasureTheory.Measure.restrict_unionᵢ\n\ntheorem restrict_unionᵢ_le [Countable ι] {s : ι → Set α} :\n    μ.restrict (⋃ i, s i) ≤ sum fun i => μ.restrict (s i) :=\n  by\n  intro t ht\n  suffices μ (⋃ i, t ∩ s i) ≤ ∑' i, μ (t ∩ s i) by simpa [ht, inter_Union]\n  apply measure_Union_le\n#align measure_theory.measure.restrict_Union_le MeasureTheory.Measure.restrict_unionᵢ_le\n\nsection Count\n\nvariable [MeasurableSpace α]\n\n/-- Counting measure on any measurable space. -/\ndef count : Measure α :=\n  sum dirac\n#align measure_theory.measure.count MeasureTheory.Measure.count\n\ntheorem le_count_apply : (∑' i : s, 1 : ℝ≥0∞) ≤ count s :=\n  calc\n    (∑' i : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i := tsum_subtype s 1\n    _ ≤ ∑' i, dirac i s := (ENNReal.tsum_le_tsum fun x => le_dirac_apply)\n    _ ≤ count s := le_sum_apply _ _\n    \n#align measure_theory.measure.le_count_apply MeasureTheory.Measure.le_count_apply\n\ntheorem count_apply (hs : MeasurableSet s) : count s = ∑' i : s, 1 := by\n  simp only [count, sum_apply, hs, dirac_apply', ← tsum_subtype s 1, Pi.one_apply]\n#align measure_theory.measure.count_apply MeasureTheory.Measure.count_apply\n\n@[simp]\ntheorem count_empty : count (∅ : Set α) = 0 := by rw [count_apply MeasurableSet.empty, tsum_empty]\n#align measure_theory.measure.count_empty MeasureTheory.Measure.count_empty\n\n@[simp]\ntheorem count_apply_finset' {s : Finset α} (s_mble : MeasurableSet (s : Set α)) :\n    count (↑s : Set α) = s.card :=\n  calc\n    count (↑s : Set α) = ∑' i : (↑s : Set α), 1 := count_apply s_mble\n    _ = ∑ i in s, 1 := (s.tsum_subtype 1)\n    _ = s.card := by simp\n    \n#align measure_theory.measure.count_apply_finset' MeasureTheory.Measure.count_apply_finset'\n\n@[simp]\ntheorem count_apply_finset [MeasurableSingletonClass α] (s : Finset α) :\n    count (↑s : Set α) = s.card :=\n  count_apply_finset' s.MeasurableSet\n#align measure_theory.measure.count_apply_finset MeasureTheory.Measure.count_apply_finset\n\ntheorem count_apply_finite' {s : Set α} (s_fin : s.Finite) (s_mble : MeasurableSet s) :\n    count s = s_fin.toFinset.card := by\n  simp [←\n    @count_apply_finset' _ _ s_fin.to_finset (by simpa only [finite.coe_to_finset] using s_mble)]\n#align measure_theory.measure.count_apply_finite' MeasureTheory.Measure.count_apply_finite'\n\ntheorem count_apply_finite [MeasurableSingletonClass α] (s : Set α) (hs : s.Finite) :\n    count s = hs.toFinset.card := by rw [← count_apply_finset, finite.coe_to_finset]\n#align measure_theory.measure.count_apply_finite MeasureTheory.Measure.count_apply_finite\n\n/-- `count` measure evaluates to infinity at infinite sets. -/\ntheorem count_apply_infinite (hs : s.Infinite) : count s = ∞ :=\n  by\n  refine' top_unique (le_of_tendsto' ENNReal.tendsto_nat_nhds_top fun n => _)\n  rcases hs.exists_subset_card_eq n with ⟨t, ht, rfl⟩\n  calc\n    (t.card : ℝ≥0∞) = ∑ i in t, 1 := by simp\n    _ = ∑' i : (t : Set α), 1 := (t.tsum_subtype 1).symm\n    _ ≤ count (t : Set α) := le_count_apply\n    _ ≤ count s := measure_mono ht\n    \n#align measure_theory.measure.count_apply_infinite MeasureTheory.Measure.count_apply_infinite\n\n@[simp]\ntheorem count_apply_eq_top' (s_mble : MeasurableSet s) : count s = ∞ ↔ s.Infinite :=\n  by\n  by_cases hs : s.finite\n  · simp [Set.Infinite, hs, count_apply_finite' hs s_mble]\n  · change s.infinite at hs\n    simp [hs, count_apply_infinite]\n#align measure_theory.measure.count_apply_eq_top' MeasureTheory.Measure.count_apply_eq_top'\n\n@[simp]\ntheorem count_apply_eq_top [MeasurableSingletonClass α] : count s = ∞ ↔ s.Infinite :=\n  by\n  by_cases hs : s.finite\n  · exact count_apply_eq_top' hs.measurable_set\n  · change s.infinite at hs\n    simp [hs, count_apply_infinite]\n#align measure_theory.measure.count_apply_eq_top MeasureTheory.Measure.count_apply_eq_top\n\n@[simp]\ntheorem count_apply_lt_top' (s_mble : MeasurableSet s) : count s < ∞ ↔ s.Finite :=\n  calc\n    count s < ∞ ↔ count s ≠ ∞ := lt_top_iff_ne_top\n    _ ↔ ¬s.Infinite := (not_congr (count_apply_eq_top' s_mble))\n    _ ↔ s.Finite := Classical.not_not\n    \n#align measure_theory.measure.count_apply_lt_top' MeasureTheory.Measure.count_apply_lt_top'\n\n@[simp]\ntheorem count_apply_lt_top [MeasurableSingletonClass α] : count s < ∞ ↔ s.Finite :=\n  calc\n    count s < ∞ ↔ count s ≠ ∞ := lt_top_iff_ne_top\n    _ ↔ ¬s.Infinite := (not_congr count_apply_eq_top)\n    _ ↔ s.Finite := Classical.not_not\n    \n#align measure_theory.measure.count_apply_lt_top MeasureTheory.Measure.count_apply_lt_top\n\ntheorem empty_of_count_eq_zero' (s_mble : MeasurableSet s) (hsc : count s = 0) : s = ∅ :=\n  by\n  have hs : s.finite := by\n    rw [← count_apply_lt_top' s_mble, hsc]\n    exact WithTop.zero_lt_top\n  simpa [count_apply_finite' hs s_mble] using hsc\n#align measure_theory.measure.empty_of_count_eq_zero' MeasureTheory.Measure.empty_of_count_eq_zero'\n\ntheorem empty_of_count_eq_zero [MeasurableSingletonClass α] (hsc : count s = 0) : s = ∅ :=\n  by\n  have hs : s.finite := by\n    rw [← count_apply_lt_top, hsc]\n    exact WithTop.zero_lt_top\n  simpa [count_apply_finite _ hs] using hsc\n#align measure_theory.measure.empty_of_count_eq_zero MeasureTheory.Measure.empty_of_count_eq_zero\n\n@[simp]\ntheorem count_eq_zero_iff' (s_mble : MeasurableSet s) : count s = 0 ↔ s = ∅ :=\n  ⟨empty_of_count_eq_zero' s_mble, fun h => h.symm ▸ count_empty⟩\n#align measure_theory.measure.count_eq_zero_iff' MeasureTheory.Measure.count_eq_zero_iff'\n\n@[simp]\ntheorem count_eq_zero_iff [MeasurableSingletonClass α] : count s = 0 ↔ s = ∅ :=\n  ⟨empty_of_count_eq_zero, fun h => h.symm ▸ count_empty⟩\n#align measure_theory.measure.count_eq_zero_iff MeasureTheory.Measure.count_eq_zero_iff\n\ntheorem count_ne_zero' (hs' : s.Nonempty) (s_mble : MeasurableSet s) : count s ≠ 0 :=\n  by\n  rw [Ne.def, count_eq_zero_iff' s_mble]\n  exact hs'.ne_empty\n#align measure_theory.measure.count_ne_zero' MeasureTheory.Measure.count_ne_zero'\n\ntheorem count_ne_zero [MeasurableSingletonClass α] (hs' : s.Nonempty) : count s ≠ 0 :=\n  by\n  rw [Ne.def, count_eq_zero_iff]\n  exact hs'.ne_empty\n#align measure_theory.measure.count_ne_zero MeasureTheory.Measure.count_ne_zero\n\n@[simp]\ntheorem count_singleton' {a : α} (ha : MeasurableSet ({a} : Set α)) : count ({a} : Set α) = 1 :=\n  by\n  rw [count_apply_finite' (Set.finite_singleton a) ha, Set.Finite.toFinset]\n  simp\n#align measure_theory.measure.count_singleton' MeasureTheory.Measure.count_singleton'\n\n@[simp]\ntheorem count_singleton [MeasurableSingletonClass α] (a : α) : count ({a} : Set α) = 1 :=\n  count_singleton' (measurableSet_singleton a)\n#align measure_theory.measure.count_singleton MeasureTheory.Measure.count_singleton\n\ntheorem count_injective_image' {f : β → α} (hf : Function.Injective f) {s : Set β}\n    (s_mble : MeasurableSet s) (fs_mble : MeasurableSet (f '' s)) : count (f '' s) = count s :=\n  by\n  by_cases hs : s.finite\n  · lift s to Finset β using hs\n    rw [← Finset.coe_image, count_apply_finset' _, count_apply_finset' s_mble,\n      s.card_image_of_injective hf]\n    simpa only [Finset.coe_image] using fs_mble\n  rw [count_apply_infinite hs]\n  rw [← finite_image_iff <| hf.inj_on _] at hs\n  rw [count_apply_infinite hs]\n#align measure_theory.measure.count_injective_image' MeasureTheory.Measure.count_injective_image'\n\ntheorem count_injective_image [MeasurableSingletonClass α] [MeasurableSingletonClass β] {f : β → α}\n    (hf : Function.Injective f) (s : Set β) : count (f '' s) = count s :=\n  by\n  by_cases hs : s.finite\n  · exact count_injective_image' hf hs.measurable_set (finite.image f hs).MeasurableSet\n  rw [count_apply_infinite hs]\n  rw [← finite_image_iff <| hf.inj_on _] at hs\n  rw [count_apply_infinite hs]\n#align measure_theory.measure.count_injective_image MeasureTheory.Measure.count_injective_image\n\nend Count\n\n/-! ### Absolute continuity -/\n\n\n/-- We say that `μ` is absolutely continuous with respect to `ν`, or that `μ` is dominated by `ν`,\n  if `ν(A) = 0` implies that `μ(A) = 0`. -/\ndef AbsolutelyContinuous {m0 : MeasurableSpace α} (μ ν : Measure α) : Prop :=\n  ∀ ⦃s : Set α⦄, ν s = 0 → μ s = 0\n#align measure_theory.measure.absolutely_continuous MeasureTheory.Measure.AbsolutelyContinuous\n\n-- mathport name: measure.absolutely_continuous\nscoped[MeasureTheory] infixl:50 \" ≪ \" => MeasureTheory.Measure.AbsolutelyContinuous\n\ntheorem absolutelyContinuousOfLe (h : μ ≤ ν) : μ ≪ ν := fun s hs =>\n  nonpos_iff_eq_zero.1 <| hs ▸ le_iff'.1 h s\n#align measure_theory.measure.absolutely_continuous_of_le MeasureTheory.Measure.absolutelyContinuousOfLe\n\nalias absolutely_continuous_of_le ← _root_.has_le.le.absolutely_continuous\n#align has_le.le.absolutely_continuous LE.le.absolutelyContinuous\n\ntheorem absolutelyContinuousOfEq (h : μ = ν) : μ ≪ ν :=\n  h.le.AbsolutelyContinuous\n#align measure_theory.measure.absolutely_continuous_of_eq MeasureTheory.Measure.absolutelyContinuousOfEq\n\nalias absolutely_continuous_of_eq ← _root_.eq.absolutely_continuous\n#align eq.absolutely_continuous Eq.absolutelyContinuous\n\nnamespace AbsolutelyContinuous\n\ntheorem mk (h : ∀ ⦃s : Set α⦄, MeasurableSet s → ν s = 0 → μ s = 0) : μ ≪ ν :=\n  by\n  intro s hs\n  rcases exists_measurable_superset_of_null hs with ⟨t, h1t, h2t, h3t⟩\n  exact measure_mono_null h1t (h h2t h3t)\n#align measure_theory.measure.absolutely_continuous.mk MeasureTheory.Measure.AbsolutelyContinuous.mk\n\n@[refl]\nprotected theorem refl {m0 : MeasurableSpace α} (μ : Measure α) : μ ≪ μ :=\n  rfl.AbsolutelyContinuous\n#align measure_theory.measure.absolutely_continuous.refl MeasureTheory.Measure.AbsolutelyContinuous.refl\n\nprotected theorem rfl : μ ≪ μ := fun s hs => hs\n#align measure_theory.measure.absolutely_continuous.rfl MeasureTheory.Measure.AbsolutelyContinuous.rfl\n\ninstance [MeasurableSpace α] : IsRefl (Measure α) (· ≪ ·) :=\n  ⟨fun μ => AbsolutelyContinuous.rfl⟩\n\n@[trans]\nprotected theorem trans (h1 : μ₁ ≪ μ₂) (h2 : μ₂ ≪ μ₃) : μ₁ ≪ μ₃ := fun s hs => h1 <| h2 hs\n#align measure_theory.measure.absolutely_continuous.trans MeasureTheory.Measure.AbsolutelyContinuous.trans\n\n@[mono]\nprotected theorem map (h : μ ≪ ν) {f : α → β} (hf : Measurable f) : μ.map f ≪ ν.map f :=\n  AbsolutelyContinuous.mk fun s hs => by simpa [hf, hs] using @h _\n#align measure_theory.measure.absolutely_continuous.map MeasureTheory.Measure.AbsolutelyContinuous.map\n\nprotected theorem smul [Monoid R] [DistribMulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (h : μ ≪ ν)\n    (c : R) : c • μ ≪ ν := fun s hνs => by simp only [h hνs, smul_eq_mul, smul_apply, smul_zero]\n#align measure_theory.measure.absolutely_continuous.smul MeasureTheory.Measure.AbsolutelyContinuous.smul\n\nend AbsolutelyContinuous\n\ntheorem absolutelyContinuousOfLeSmul {μ' : Measure α} {c : ℝ≥0∞} (hμ'_le : μ' ≤ c • μ) : μ' ≪ μ :=\n  (Measure.absolutelyContinuousOfLe hμ'_le).trans (Measure.AbsolutelyContinuous.rfl.smul c)\n#align measure_theory.measure.absolutely_continuous_of_le_smul MeasureTheory.Measure.absolutelyContinuousOfLeSmul\n\ntheorem ae_le_iff_absolutelyContinuous : μ.ae ≤ ν.ae ↔ μ ≪ ν :=\n  ⟨fun h s => by\n    rw [measure_zero_iff_ae_nmem, measure_zero_iff_ae_nmem]\n    exact fun hs => h hs, fun h s hs => h hs⟩\n#align measure_theory.measure.ae_le_iff_absolutely_continuous MeasureTheory.Measure.ae_le_iff_absolutelyContinuous\n\nalias ae_le_iff_absolutely_continuous ↔\n  _root_.has_le.le.absolutely_continuous_of_ae absolutely_continuous.ae_le\n#align has_le.le.absolutely_continuous_of_ae LE.le.absolutelyContinuousOfAe\n#align measure_theory.measure.absolutely_continuous.ae_le MeasureTheory.Measure.AbsolutelyContinuous.ae_le\n\nalias absolutely_continuous.ae_le ← ae_mono'\n#align measure_theory.measure.ae_mono' MeasureTheory.Measure.ae_mono'\n\ntheorem AbsolutelyContinuous.ae_eq (h : μ ≪ ν) {f g : α → δ} (h' : f =ᵐ[ν] g) : f =ᵐ[μ] g :=\n  h.ae_le h'\n#align measure_theory.measure.absolutely_continuous.ae_eq MeasureTheory.Measure.AbsolutelyContinuous.ae_eq\n\n/-! ### Quasi measure preserving maps (a.k.a. non-singular maps) -/\n\n\n/-- A map `f : α → β` is said to be *quasi measure preserving* (a.k.a. non-singular) w.r.t. measures\n`μa` and `μb` if it is measurable and `μb s = 0` implies `μa (f ⁻¹' s) = 0`. -/\n@[protect_proj]\nstructure QuasiMeasurePreserving {m0 : MeasurableSpace α} (f : α → β)\n  (μa : Measure α := by exact MeasureTheory.MeasureSpace.volume)\n  (μb : Measure β := by exact MeasureTheory.MeasureSpace.volume) : Prop where\n  Measurable : Measurable f\n  AbsolutelyContinuous : μa.map f ≪ μb\n#align measure_theory.measure.quasi_measure_preserving MeasureTheory.Measure.QuasiMeasurePreserving\n\nnamespace QuasiMeasurePreserving\n\nprotected theorem id {m0 : MeasurableSpace α} (μ : Measure α) : QuasiMeasurePreserving id μ μ :=\n  ⟨measurable_id, map_id.AbsolutelyContinuous⟩\n#align measure_theory.measure.quasi_measure_preserving.id MeasureTheory.Measure.QuasiMeasurePreserving.id\n\nvariable {μa μa' : Measure α} {μb μb' : Measure β} {μc : Measure γ} {f : α → β}\n\nprotected theorem Measurable.quasiMeasurePreserving {m0 : MeasurableSpace α} (hf : Measurable f)\n    (μ : Measure α) : QuasiMeasurePreserving f μ (μ.map f) :=\n  ⟨hf, AbsolutelyContinuous.rfl⟩\n#align measurable.quasi_measure_preserving Measurable.quasiMeasurePreserving\n\ntheorem monoLeft (h : QuasiMeasurePreserving f μa μb) (ha : μa' ≪ μa) :\n    QuasiMeasurePreserving f μa' μb :=\n  ⟨h.1, (ha.map h.1).trans h.2⟩\n#align measure_theory.measure.quasi_measure_preserving.mono_left MeasureTheory.Measure.QuasiMeasurePreserving.monoLeft\n\ntheorem monoRight (h : QuasiMeasurePreserving f μa μb) (ha : μb ≪ μb') :\n    QuasiMeasurePreserving f μa μb' :=\n  ⟨h.1, h.2.trans ha⟩\n#align measure_theory.measure.quasi_measure_preserving.mono_right MeasureTheory.Measure.QuasiMeasurePreserving.monoRight\n\n@[mono]\ntheorem mono (ha : μa' ≪ μa) (hb : μb ≪ μb') (h : QuasiMeasurePreserving f μa μb) :\n    QuasiMeasurePreserving f μa' μb' :=\n  (h.mono_left ha).mono_right hb\n#align measure_theory.measure.quasi_measure_preserving.mono MeasureTheory.Measure.QuasiMeasurePreserving.mono\n\nprotected theorem comp {g : β → γ} {f : α → β} (hg : QuasiMeasurePreserving g μb μc)\n    (hf : QuasiMeasurePreserving f μa μb) : QuasiMeasurePreserving (g ∘ f) μa μc :=\n  ⟨hg.Measurable.comp hf.Measurable, by\n    rw [← map_map hg.1 hf.1]\n    exact (hf.2.map hg.1).trans hg.2⟩\n#align measure_theory.measure.quasi_measure_preserving.comp MeasureTheory.Measure.QuasiMeasurePreserving.comp\n\nprotected theorem iterate {f : α → α} (hf : QuasiMeasurePreserving f μa μa) :\n    ∀ n, QuasiMeasurePreserving (f^[n]) μa μa\n  | 0 => QuasiMeasurePreserving.id μa\n  | n + 1 => (iterate n).comp hf\n#align measure_theory.measure.quasi_measure_preserving.iterate MeasureTheory.Measure.QuasiMeasurePreserving.iterate\n\nprotected theorem aeMeasurable (hf : QuasiMeasurePreserving f μa μb) : AeMeasurable f μa :=\n  hf.1.AeMeasurable\n#align measure_theory.measure.quasi_measure_preserving.ae_measurable MeasureTheory.Measure.QuasiMeasurePreserving.aeMeasurable\n\ntheorem ae_map_le (h : QuasiMeasurePreserving f μa μb) : (μa.map f).ae ≤ μb.ae :=\n  h.2.ae_le\n#align measure_theory.measure.quasi_measure_preserving.ae_map_le MeasureTheory.Measure.QuasiMeasurePreserving.ae_map_le\n\ntheorem tendsto_ae (h : QuasiMeasurePreserving f μa μb) : Tendsto f μa.ae μb.ae :=\n  (tendsto_ae_map h.AeMeasurable).mono_right h.ae_map_le\n#align measure_theory.measure.quasi_measure_preserving.tendsto_ae MeasureTheory.Measure.QuasiMeasurePreserving.tendsto_ae\n\ntheorem ae (h : QuasiMeasurePreserving f μa μb) {p : β → Prop} (hg : ∀ᵐ x ∂μb, p x) :\n    ∀ᵐ x ∂μa, p (f x) :=\n  h.tendsto_ae hg\n#align measure_theory.measure.quasi_measure_preserving.ae MeasureTheory.Measure.QuasiMeasurePreserving.ae\n\ntheorem ae_eq (h : QuasiMeasurePreserving f μa μb) {g₁ g₂ : β → δ} (hg : g₁ =ᵐ[μb] g₂) :\n    g₁ ∘ f =ᵐ[μa] g₂ ∘ f :=\n  h.ae hg\n#align measure_theory.measure.quasi_measure_preserving.ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.ae_eq\n\ntheorem preimage_null (h : QuasiMeasurePreserving f μa μb) {s : Set β} (hs : μb s = 0) :\n    μa (f ⁻¹' s) = 0 :=\n  preimage_null_of_map_null h.AeMeasurable (h.2 hs)\n#align measure_theory.measure.quasi_measure_preserving.preimage_null MeasureTheory.Measure.QuasiMeasurePreserving.preimage_null\n\ntheorem preimage_mono_ae {s t : Set β} (hf : QuasiMeasurePreserving f μa μb) (h : s ≤ᵐ[μb] t) :\n    f ⁻¹' s ≤ᵐ[μa] f ⁻¹' t :=\n  eventually_map.mp <|\n    Eventually.filter_mono (tendsto_ae_map hf.AeMeasurable) (Eventually.filter_mono hf.ae_map_le h)\n#align measure_theory.measure.quasi_measure_preserving.preimage_mono_ae MeasureTheory.Measure.QuasiMeasurePreserving.preimage_mono_ae\n\ntheorem preimage_ae_eq {s t : Set β} (hf : QuasiMeasurePreserving f μa μb) (h : s =ᵐ[μb] t) :\n    f ⁻¹' s =ᵐ[μa] f ⁻¹' t :=\n  EventuallyLE.antisymm (hf.preimage_mono_ae h.le) (hf.preimage_mono_ae h.symm.le)\n#align measure_theory.measure.quasi_measure_preserving.preimage_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.preimage_ae_eq\n\ntheorem preimage_iterate_ae_eq {s : Set α} {f : α → α} (hf : QuasiMeasurePreserving f μ μ) (k : ℕ)\n    (hs : f ⁻¹' s =ᵐ[μ] s) : f^[k] ⁻¹' s =ᵐ[μ] s :=\n  by\n  induction' k with k ih; · simp\n  rw [iterate_succ, preimage_comp]\n  exact eventually_eq.trans (hf.preimage_ae_eq ih) hs\n#align measure_theory.measure.quasi_measure_preserving.preimage_iterate_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.preimage_iterate_ae_eq\n\ntheorem image_zpow_ae_eq {s : Set α} {e : α ≃ α} (he : QuasiMeasurePreserving e μ μ)\n    (he' : QuasiMeasurePreserving e.symm μ μ) (k : ℤ) (hs : e '' s =ᵐ[μ] s) :\n    ⇑(e ^ k) '' s =ᵐ[μ] s := by\n  rw [Equiv.image_eq_preimage]\n  obtain ⟨k, rfl | rfl⟩ := k.eq_coe_or_neg\n  · replace hs : ⇑e⁻¹ ⁻¹' s =ᵐ[μ] s\n    · rwa [Equiv.image_eq_preimage] at hs\n    replace he' : ⇑e⁻¹^[k] ⁻¹' s =ᵐ[μ] s := he'.preimage_iterate_ae_eq k hs\n    rwa [Equiv.Perm.iterate_eq_pow e⁻¹ k, inv_pow e k] at he'\n  · rw [zpow_neg, zpow_ofNat]\n    replace hs : e ⁻¹' s =ᵐ[μ] s\n    · convert he.preimage_ae_eq hs.symm\n      rw [Equiv.preimage_image]\n    replace he : ⇑e^[k] ⁻¹' s =ᵐ[μ] s := he.preimage_iterate_ae_eq k hs\n    rwa [Equiv.Perm.iterate_eq_pow e k] at he\n#align measure_theory.measure.quasi_measure_preserving.image_zpow_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.image_zpow_ae_eq\n\ntheorem limsup_preimage_iterate_ae_eq {f : α → α} (hf : QuasiMeasurePreserving f μ μ)\n    (hs : f ⁻¹' s =ᵐ[μ] s) :-- Need `@` below because of diamond; see gh issue #16932\n        @limsup\n        (Set α) ℕ _ (fun n => (preimage f^[n]) s) atTop =ᵐ[μ]\n      s :=\n  haveI : ∀ n, (preimage f^[n]) s =ᵐ[μ] s := by\n    intro n\n    induction' n with n ih\n    · simp\n    simpa only [iterate_succ', comp_app] using ae_eq_trans (hf.ae_eq ih) hs\n  (limsup_ae_eq_of_forall_ae_eq (fun n => (preimage f^[n]) s) this).trans (ae_eq_refl _)\n#align measure_theory.measure.quasi_measure_preserving.limsup_preimage_iterate_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.limsup_preimage_iterate_ae_eq\n\ntheorem liminf_preimage_iterate_ae_eq {f : α → α} (hf : QuasiMeasurePreserving f μ μ)\n    (hs : f ⁻¹' s =ᵐ[μ] s) :-- Need `@` below because of diamond; see gh issue #16932\n        @liminf\n        (Set α) ℕ _ (fun n => (preimage f^[n]) s) atTop =ᵐ[μ]\n      s :=\n  by\n  -- Need `@` below because of diamond; see gh issue #16932\n  rw [← ae_eq_set_compl_compl, @Filter.liminf_compl (Set α)]\n  rw [← ae_eq_set_compl_compl, ← preimage_compl] at hs\n  convert hf.limsup_preimage_iterate_ae_eq hs\n  ext1 n\n  simp only [← Set.preimage_iterate_eq, comp_app, preimage_compl]\n#align measure_theory.measure.quasi_measure_preserving.liminf_preimage_iterate_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.liminf_preimage_iterate_ae_eq\n\n/-- By replacing a measurable set that is almost invariant with the `limsup` of its preimages, we\nobtain a measurable set that is almost equal and strictly invariant.\n\n(The `liminf` would work just as well.) -/\ntheorem exists_preimage_eq_of_preimage_ae {f : α → α} (h : QuasiMeasurePreserving f μ μ)\n    (hs : MeasurableSet s) (hs' : f ⁻¹' s =ᵐ[μ] s) :\n    ∃ t : Set α, MeasurableSet t ∧ t =ᵐ[μ] s ∧ f ⁻¹' t = t :=\n  ⟨limsup (fun n => (preimage f^[n]) s) atTop,\n    MeasurableSet.measurableSet_limsup fun n =>\n      @preimage_iterate_eq α f n ▸ h.Measurable.iterate n hs,\n    h.limsup_preimage_iterate_ae_eq hs', (CompleteLatticeHom.setPreimage f).apply_limsup_iterate s⟩\n#align measure_theory.measure.quasi_measure_preserving.exists_preimage_eq_of_preimage_ae MeasureTheory.Measure.QuasiMeasurePreserving.exists_preimage_eq_of_preimage_ae\n\nopen Pointwise\n\n@[to_additive]\ntheorem smul_ae_eq_of_ae_eq {G α : Type _} [Group G] [MulAction G α] [MeasurableSpace α]\n    {s t : Set α} {μ : Measure α} (g : G) (h_qmp : QuasiMeasurePreserving ((· • ·) g⁻¹ : α → α) μ μ)\n    (h_ae_eq : s =ᵐ[μ] t) : (g • s : Set α) =ᵐ[μ] (g • t : Set α) := by\n  simpa only [← preimage_smul_inv] using h_qmp.ae_eq h_ae_eq\n#align measure_theory.measure.quasi_measure_preserving.smul_ae_eq_of_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.smul_ae_eq_of_ae_eq\n#align measure_theory.measure.quasi_measure_preserving.vadd_ae_eq_of_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.vadd_ae_eq_of_ae_eq\n\nend QuasiMeasurePreserving\n\nsection Pointwise\n\nopen Pointwise\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (g «expr ≠ » (1 : G)) -/\n@[to_additive]\ntheorem pairwise_aeDisjoint_of_aeDisjoint_forall_ne_one {G α : Type _} [Group G] [MulAction G α]\n    [MeasurableSpace α] {μ : Measure α} {s : Set α}\n    (h_ae_disjoint : ∀ (g) (_ : g ≠ (1 : G)), AeDisjoint μ (g • s) s)\n    (h_qmp : ∀ g : G, QuasiMeasurePreserving ((· • ·) g : α → α) μ μ) :\n    Pairwise (AeDisjoint μ on fun g : G => g • s) :=\n  by\n  intro g₁ g₂ hg\n  let g := g₂⁻¹ * g₁\n  replace hg : g ≠ 1\n  · rw [Ne.def, inv_mul_eq_one]\n    exact hg.symm\n  have : (· • ·) g₂⁻¹ ⁻¹' (g • s ∩ s) = g₁ • s ∩ g₂ • s := by\n    rw [preimage_eq_iff_eq_image (MulAction.bijective g₂⁻¹), image_smul, smul_set_inter, smul_smul,\n      smul_smul, inv_mul_self, one_smul]\n  change μ (g₁ • s ∩ g₂ • s) = 0\n  exact this ▸ (h_qmp g₂⁻¹).preimage_null (h_ae_disjoint g hg)\n#align measure_theory.measure.pairwise_ae_disjoint_of_ae_disjoint_forall_ne_one MeasureTheory.Measure.pairwise_aeDisjoint_of_aeDisjoint_forall_ne_one\n#align measure_theory.measure.pairwise_ae_disjoint_of_ae_disjoint_forall_ne_zero MeasureTheory.Measure.pairwise_ae_disjoint_of_ae_disjoint_forall_ne_zero\n\nend Pointwise\n\n/-! ### The `cofinite` filter -/\n\n\n/-- The filter of sets `s` such that `sᶜ` has finite measure. -/\ndef cofinite {m0 : MeasurableSpace α} (μ : Measure α) : Filter α\n    where\n  sets := { s | μ (sᶜ) < ∞ }\n  univ_sets := by simp\n  inter_sets s t hs ht := by\n    simp only [compl_inter, mem_set_of_eq]\n    calc\n      μ (sᶜ ∪ tᶜ) ≤ μ (sᶜ) + μ (tᶜ) := measure_union_le _ _\n      _ < ∞ := ENNReal.add_lt_top.2 ⟨hs, ht⟩\n      \n  sets_of_superset s t hs hst := lt_of_le_of_lt (measure_mono <| compl_subset_compl.2 hst) hs\n#align measure_theory.measure.cofinite MeasureTheory.Measure.cofinite\n\ntheorem mem_cofinite : s ∈ μ.cofinite ↔ μ (sᶜ) < ∞ :=\n  Iff.rfl\n#align measure_theory.measure.mem_cofinite MeasureTheory.Measure.mem_cofinite\n\ntheorem compl_mem_cofinite : sᶜ ∈ μ.cofinite ↔ μ s < ∞ := by rw [mem_cofinite, compl_compl]\n#align measure_theory.measure.compl_mem_cofinite MeasureTheory.Measure.compl_mem_cofinite\n\ntheorem eventually_cofinite {p : α → Prop} : (∀ᶠ x in μ.cofinite, p x) ↔ μ { x | ¬p x } < ∞ :=\n  Iff.rfl\n#align measure_theory.measure.eventually_cofinite MeasureTheory.Measure.eventually_cofinite\n\nend Measure\n\nopen Measure\n\nopen MeasureTheory\n\n/-- The preimage of a null measurable set under a (quasi) measure preserving map is a null\nmeasurable set. -/\ntheorem NullMeasurableSet.preimage {ν : Measure β} {f : α → β} {t : Set β}\n    (ht : NullMeasurableSet t ν) (hf : QuasiMeasurePreserving f μ ν) :\n    NullMeasurableSet (f ⁻¹' t) μ :=\n  ⟨f ⁻¹' toMeasurable ν t, hf.Measurable (measurableSet_toMeasurable _ _),\n    hf.ae_eq ht.toMeasurable_ae_eq.symm⟩\n#align measure_theory.null_measurable_set.preimage MeasureTheory.NullMeasurableSet.preimage\n\ntheorem NullMeasurableSet.monoAc (h : NullMeasurableSet s μ) (hle : ν ≪ μ) :\n    NullMeasurableSet s ν :=\n  h.Preimage <| (QuasiMeasurePreserving.id μ).mono_left hle\n#align measure_theory.null_measurable_set.mono_ac MeasureTheory.NullMeasurableSet.monoAc\n\ntheorem NullMeasurableSet.mono (h : NullMeasurableSet s μ) (hle : ν ≤ μ) : NullMeasurableSet s ν :=\n  h.monoAc hle.AbsolutelyContinuous\n#align measure_theory.null_measurable_set.mono MeasureTheory.NullMeasurableSet.mono\n\ntheorem AeDisjoint.preimage {ν : Measure β} {f : α → β} {s t : Set β} (ht : AeDisjoint ν s t)\n    (hf : QuasiMeasurePreserving f μ ν) : AeDisjoint μ (f ⁻¹' s) (f ⁻¹' t) :=\n  hf.preimage_null ht\n#align measure_theory.ae_disjoint.preimage MeasureTheory.AeDisjoint.preimage\n\n@[simp]\ntheorem ae_eq_bot : μ.ae = ⊥ ↔ μ = 0 := by\n  rw [← empty_mem_iff_bot, mem_ae_iff, compl_empty, measure_univ_eq_zero]\n#align measure_theory.ae_eq_bot MeasureTheory.ae_eq_bot\n\n@[simp]\ntheorem ae_neBot : μ.ae.ne_bot ↔ μ ≠ 0 :=\n  neBot_iff.trans (not_congr ae_eq_bot)\n#align measure_theory.ae_ne_bot MeasureTheory.ae_neBot\n\n@[simp]\ntheorem ae_zero {m0 : MeasurableSpace α} : (0 : Measure α).ae = ⊥ :=\n  ae_eq_bot.2 rfl\n#align measure_theory.ae_zero MeasureTheory.ae_zero\n\n@[mono]\ntheorem ae_mono (h : μ ≤ ν) : μ.ae ≤ ν.ae :=\n  h.AbsolutelyContinuous.ae_le\n#align measure_theory.ae_mono MeasureTheory.ae_mono\n\ntheorem mem_ae_map_iff {f : α → β} (hf : AeMeasurable f μ) {s : Set β} (hs : MeasurableSet s) :\n    s ∈ (μ.map f).ae ↔ f ⁻¹' s ∈ μ.ae := by\n  simp only [mem_ae_iff, map_apply_of_ae_measurable hf hs.compl, preimage_compl]\n#align measure_theory.mem_ae_map_iff MeasureTheory.mem_ae_map_iff\n\ntheorem mem_ae_of_mem_ae_map {f : α → β} (hf : AeMeasurable f μ) {s : Set β}\n    (hs : s ∈ (μ.map f).ae) : f ⁻¹' s ∈ μ.ae :=\n  (tendsto_ae_map hf).Eventually hs\n#align measure_theory.mem_ae_of_mem_ae_map MeasureTheory.mem_ae_of_mem_ae_map\n\ntheorem ae_map_iff {f : α → β} (hf : AeMeasurable f μ) {p : β → Prop}\n    (hp : MeasurableSet { x | p x }) : (∀ᵐ y ∂μ.map f, p y) ↔ ∀ᵐ x ∂μ, p (f x) :=\n  mem_ae_map_iff hf hp\n#align measure_theory.ae_map_iff MeasureTheory.ae_map_iff\n\ntheorem ae_of_ae_map {f : α → β} (hf : AeMeasurable f μ) {p : β → Prop} (h : ∀ᵐ y ∂μ.map f, p y) :\n    ∀ᵐ x ∂μ, p (f x) :=\n  mem_ae_of_mem_ae_map hf h\n#align measure_theory.ae_of_ae_map MeasureTheory.ae_of_ae_map\n\ntheorem ae_map_mem_range {m0 : MeasurableSpace α} (f : α → β) (hf : MeasurableSet (range f))\n    (μ : Measure α) : ∀ᵐ x ∂μ.map f, x ∈ range f :=\n  by\n  by_cases h : AeMeasurable f μ\n  · change range f ∈ (μ.map f).ae\n    rw [mem_ae_map_iff h hf]\n    apply eventually_of_forall\n    exact mem_range_self\n  · simp [map_of_not_ae_measurable h]\n#align measure_theory.ae_map_mem_range MeasureTheory.ae_map_mem_range\n\n@[simp]\ntheorem ae_restrict_unionᵢ_eq [Countable ι] (s : ι → Set α) :\n    (μ.restrict (⋃ i, s i)).ae = ⨆ i, (μ.restrict (s i)).ae :=\n  le_antisymm ((ae_sum_eq fun i => μ.restrict (s i)) ▸ ae_mono restrict_unionᵢ_le) <|\n    supᵢ_le fun i => ae_mono <| restrict_mono (subset_unionᵢ s i) le_rfl\n#align measure_theory.ae_restrict_Union_eq MeasureTheory.ae_restrict_unionᵢ_eq\n\n@[simp]\ntheorem ae_restrict_union_eq (s t : Set α) :\n    (μ.restrict (s ∪ t)).ae = (μ.restrict s).ae ⊔ (μ.restrict t).ae := by\n  simp [union_eq_Union, supᵢ_bool_eq]\n#align measure_theory.ae_restrict_union_eq MeasureTheory.ae_restrict_union_eq\n\ntheorem ae_restrict_bUnion_eq (s : ι → Set α) {t : Set ι} (ht : t.Countable) :\n    (μ.restrict (⋃ i ∈ t, s i)).ae = ⨆ i ∈ t, (μ.restrict (s i)).ae :=\n  by\n  haveI := ht.to_subtype\n  rw [bUnion_eq_Union, ae_restrict_Union_eq, ← supᵢ_subtype'']\n#align measure_theory.ae_restrict_bUnion_eq MeasureTheory.ae_restrict_bUnion_eq\n\ntheorem ae_restrict_bUnion_finset_eq (s : ι → Set α) (t : Finset ι) :\n    (μ.restrict (⋃ i ∈ t, s i)).ae = ⨆ i ∈ t, (μ.restrict (s i)).ae :=\n  ae_restrict_bUnion_eq s t.countable_toSet\n#align measure_theory.ae_restrict_bUnion_finset_eq MeasureTheory.ae_restrict_bUnion_finset_eq\n\ntheorem ae_restrict_unionᵢ_iff [Countable ι] (s : ι → Set α) (p : α → Prop) :\n    (∀ᵐ x ∂μ.restrict (⋃ i, s i), p x) ↔ ∀ i, ∀ᵐ x ∂μ.restrict (s i), p x := by simp\n#align measure_theory.ae_restrict_Union_iff MeasureTheory.ae_restrict_unionᵢ_iff\n\ntheorem ae_restrict_union_iff (s t : Set α) (p : α → Prop) :\n    (∀ᵐ x ∂μ.restrict (s ∪ t), p x) ↔ (∀ᵐ x ∂μ.restrict s, p x) ∧ ∀ᵐ x ∂μ.restrict t, p x := by simp\n#align measure_theory.ae_restrict_union_iff MeasureTheory.ae_restrict_union_iff\n\ntheorem ae_restrict_bUnion_iff (s : ι → Set α) {t : Set ι} (ht : t.Countable) (p : α → Prop) :\n    (∀ᵐ x ∂μ.restrict (⋃ i ∈ t, s i), p x) ↔ ∀ i ∈ t, ∀ᵐ x ∂μ.restrict (s i), p x := by\n  simp_rw [Filter.Eventually, ae_restrict_bUnion_eq s ht, mem_supr]\n#align measure_theory.ae_restrict_bUnion_iff MeasureTheory.ae_restrict_bUnion_iff\n\n@[simp]\ntheorem ae_restrict_bUnion_finset_iff (s : ι → Set α) (t : Finset ι) (p : α → Prop) :\n    (∀ᵐ x ∂μ.restrict (⋃ i ∈ t, s i), p x) ↔ ∀ i ∈ t, ∀ᵐ x ∂μ.restrict (s i), p x := by\n  simp_rw [Filter.Eventually, ae_restrict_bUnion_finset_eq s, mem_supr]\n#align measure_theory.ae_restrict_bUnion_finset_iff MeasureTheory.ae_restrict_bUnion_finset_iff\n\ntheorem ae_eq_restrict_unionᵢ_iff [Countable ι] (s : ι → Set α) (f g : α → δ) :\n    f =ᵐ[μ.restrict (⋃ i, s i)] g ↔ ∀ i, f =ᵐ[μ.restrict (s i)] g := by\n  simp_rw [eventually_eq, ae_restrict_Union_eq, eventually_supr]\n#align measure_theory.ae_eq_restrict_Union_iff MeasureTheory.ae_eq_restrict_unionᵢ_iff\n\ntheorem ae_eq_restrict_bUnion_iff (s : ι → Set α) {t : Set ι} (ht : t.Countable) (f g : α → δ) :\n    f =ᵐ[μ.restrict (⋃ i ∈ t, s i)] g ↔ ∀ i ∈ t, f =ᵐ[μ.restrict (s i)] g := by\n  simp_rw [ae_restrict_bUnion_eq s ht, eventually_eq, eventually_supr]\n#align measure_theory.ae_eq_restrict_bUnion_iff MeasureTheory.ae_eq_restrict_bUnion_iff\n\ntheorem ae_eq_restrict_bUnion_finset_iff (s : ι → Set α) (t : Finset ι) (f g : α → δ) :\n    f =ᵐ[μ.restrict (⋃ i ∈ t, s i)] g ↔ ∀ i ∈ t, f =ᵐ[μ.restrict (s i)] g :=\n  ae_eq_restrict_bUnion_iff s t.countable_toSet f g\n#align measure_theory.ae_eq_restrict_bUnion_finset_iff MeasureTheory.ae_eq_restrict_bUnion_finset_iff\n\ntheorem ae_restrict_uIoc_eq [LinearOrder α] (a b : α) :\n    (μ.restrict (Ι a b)).ae = (μ.restrict (Ioc a b)).ae ⊔ (μ.restrict (Ioc b a)).ae := by\n  simp only [uIoc_eq_union, ae_restrict_union_eq]\n#align measure_theory.ae_restrict_uIoc_eq MeasureTheory.ae_restrict_uIoc_eq\n\n/-- See also `measure_theory.ae_uIoc_iff`. -/\ntheorem ae_restrict_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :\n    (∀ᵐ x ∂μ.restrict (Ι a b), P x) ↔\n      (∀ᵐ x ∂μ.restrict (Ioc a b), P x) ∧ ∀ᵐ x ∂μ.restrict (Ioc b a), P x :=\n  by rw [ae_restrict_uIoc_eq, eventually_sup]\n#align measure_theory.ae_restrict_uIoc_iff MeasureTheory.ae_restrict_uIoc_iff\n\ntheorem ae_restrict_iff {p : α → Prop} (hp : MeasurableSet { x | p x }) :\n    (∀ᵐ x ∂μ.restrict s, p x) ↔ ∀ᵐ x ∂μ, x ∈ s → p x :=\n  by\n  simp only [ae_iff, ← compl_set_of, restrict_apply hp.compl]\n  congr with x; simp [and_comm']\n#align measure_theory.ae_restrict_iff MeasureTheory.ae_restrict_iff\n\ntheorem ae_imp_of_ae_restrict {s : Set α} {p : α → Prop} (h : ∀ᵐ x ∂μ.restrict s, p x) :\n    ∀ᵐ x ∂μ, x ∈ s → p x := by\n  simp only [ae_iff] at h⊢\n  simpa [set_of_and, inter_comm] using measure_inter_eq_zero_of_restrict h\n#align measure_theory.ae_imp_of_ae_restrict MeasureTheory.ae_imp_of_ae_restrict\n\ntheorem ae_restrict_iff' {p : α → Prop} (hs : MeasurableSet s) :\n    (∀ᵐ x ∂μ.restrict s, p x) ↔ ∀ᵐ x ∂μ, x ∈ s → p x :=\n  by\n  simp only [ae_iff, ← compl_set_of, restrict_apply_eq_zero' hs]\n  congr with x; simp [and_comm']\n#align measure_theory.ae_restrict_iff' MeasureTheory.ae_restrict_iff'\n\ntheorem Filter.EventuallyEq.restrict {f g : α → δ} {s : Set α} (hfg : f =ᵐ[μ] g) :\n    f =ᵐ[μ.restrict s] g :=\n  by\n  -- note that we cannot use `ae_restrict_iff` since we do not require measurability\n  refine' hfg.filter_mono _\n  rw [measure.ae_le_iff_absolutely_continuous]\n  exact measure.absolutely_continuous_of_le measure.restrict_le_self\n#align filter.eventually_eq.restrict Filter.EventuallyEq.restrict\n\ntheorem ae_restrict_mem (hs : MeasurableSet s) : ∀ᵐ x ∂μ.restrict s, x ∈ s :=\n  (ae_restrict_iff' hs).2 (Filter.eventually_of_forall fun x => id)\n#align measure_theory.ae_restrict_mem MeasureTheory.ae_restrict_mem\n\ntheorem ae_restrict_mem₀ (hs : NullMeasurableSet s μ) : ∀ᵐ x ∂μ.restrict s, x ∈ s :=\n  by\n  rcases hs.exists_measurable_subset_ae_eq with ⟨t, hts, htm, ht_eq⟩\n  rw [← restrict_congr_set ht_eq]\n  exact (ae_restrict_mem htm).mono hts\n#align measure_theory.ae_restrict_mem₀ MeasureTheory.ae_restrict_mem₀\n\ntheorem ae_restrict_of_ae {s : Set α} {p : α → Prop} (h : ∀ᵐ x ∂μ, p x) : ∀ᵐ x ∂μ.restrict s, p x :=\n  Eventually.filter_mono (ae_mono Measure.restrict_le_self) h\n#align measure_theory.ae_restrict_of_ae MeasureTheory.ae_restrict_of_ae\n\ntheorem ae_restrict_iff'₀ {p : α → Prop} (hs : NullMeasurableSet s μ) :\n    (∀ᵐ x ∂μ.restrict s, p x) ↔ ∀ᵐ x ∂μ, x ∈ s → p x :=\n  by\n  refine' ⟨fun h => ae_imp_of_ae_restrict h, fun h => _⟩\n  filter_upwards [ae_restrict_mem₀ hs, ae_restrict_of_ae h]with x hx h'x using h'x hx\n#align measure_theory.ae_restrict_iff'₀ MeasureTheory.ae_restrict_iff'₀\n\ntheorem ae_restrict_of_ae_restrict_of_subset {s t : Set α} {p : α → Prop} (hst : s ⊆ t)\n    (h : ∀ᵐ x ∂μ.restrict t, p x) : ∀ᵐ x ∂μ.restrict s, p x :=\n  h.filter_mono (ae_mono <| Measure.restrict_mono hst (le_refl μ))\n#align measure_theory.ae_restrict_of_ae_restrict_of_subset MeasureTheory.ae_restrict_of_ae_restrict_of_subset\n\ntheorem ae_of_ae_restrict_of_ae_restrict_compl (t : Set α) {p : α → Prop}\n    (ht : ∀ᵐ x ∂μ.restrict t, p x) (htc : ∀ᵐ x ∂μ.restrict (tᶜ), p x) : ∀ᵐ x ∂μ, p x :=\n  nonpos_iff_eq_zero.1 <|\n    calc\n      μ { x | ¬p x } = μ ({ x | ¬p x } ∩ t ∪ { x | ¬p x } ∩ tᶜ) := by\n        rw [← inter_union_distrib_left, union_compl_self, inter_univ]\n      _ ≤ μ ({ x | ¬p x } ∩ t) + μ ({ x | ¬p x } ∩ tᶜ) := (measure_union_le _ _)\n      _ ≤ μ.restrict t { x | ¬p x } + μ.restrict (tᶜ) { x | ¬p x } :=\n        (add_le_add (le_restrict_apply _ _) (le_restrict_apply _ _))\n      _ = 0 := by rw [ae_iff.1 ht, ae_iff.1 htc, zero_add]\n      \n#align measure_theory.ae_of_ae_restrict_of_ae_restrict_compl MeasureTheory.ae_of_ae_restrict_of_ae_restrict_compl\n\ntheorem mem_map_restrict_ae_iff {β} {s : Set α} {t : Set β} {f : α → β} (hs : MeasurableSet s) :\n    t ∈ Filter.map f (μ.restrict s).ae ↔ μ ((f ⁻¹' t)ᶜ ∩ s) = 0 := by\n  rw [mem_map, mem_ae_iff, measure.restrict_apply' hs]\n#align measure_theory.mem_map_restrict_ae_iff MeasureTheory.mem_map_restrict_ae_iff\n\ntheorem ae_smul_measure {p : α → Prop} [Monoid R] [DistribMulAction R ℝ≥0∞]\n    [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (h : ∀ᵐ x ∂μ, p x) (c : R) : ∀ᵐ x ∂c • μ, p x :=\n  ae_iff.2 <| by rw [smul_apply, ae_iff.1 h, smul_zero]\n#align measure_theory.ae_smul_measure MeasureTheory.ae_smul_measure\n\ntheorem ae_add_measure_iff {p : α → Prop} {ν} :\n    (∀ᵐ x ∂μ + ν, p x) ↔ (∀ᵐ x ∂μ, p x) ∧ ∀ᵐ x ∂ν, p x :=\n  add_eq_zero_iff\n#align measure_theory.ae_add_measure_iff MeasureTheory.ae_add_measure_iff\n\ntheorem ae_eq_comp' {ν : Measure β} {f : α → β} {g g' : β → δ} (hf : AeMeasurable f μ)\n    (h : g =ᵐ[ν] g') (h2 : μ.map f ≪ ν) : g ∘ f =ᵐ[μ] g' ∘ f :=\n  (tendsto_ae_map hf).mono_right h2.ae_le h\n#align measure_theory.ae_eq_comp' MeasureTheory.ae_eq_comp'\n\ntheorem Measure.QuasiMeasurePreserving.ae_eq_comp {ν : Measure β} {f : α → β} {g g' : β → δ}\n    (hf : QuasiMeasurePreserving f μ ν) (h : g =ᵐ[ν] g') : g ∘ f =ᵐ[μ] g' ∘ f :=\n  ae_eq_comp' hf.AeMeasurable h hf.AbsolutelyContinuous\n#align measure_theory.measure.quasi_measure_preserving.ae_eq_comp MeasureTheory.Measure.QuasiMeasurePreserving.ae_eq_comp\n\ntheorem ae_eq_comp {f : α → β} {g g' : β → δ} (hf : AeMeasurable f μ) (h : g =ᵐ[μ.map f] g') :\n    g ∘ f =ᵐ[μ] g' ∘ f :=\n  ae_eq_comp' hf h AbsolutelyContinuous.rfl\n#align measure_theory.ae_eq_comp MeasureTheory.ae_eq_comp\n\ntheorem sub_ae_eq_zero {β} [AddGroup β] (f g : α → β) : f - g =ᵐ[μ] 0 ↔ f =ᵐ[μ] g :=\n  by\n  refine' ⟨fun h => h.mono fun x hx => _, fun h => h.mono fun x hx => _⟩\n  · rwa [Pi.sub_apply, Pi.zero_apply, sub_eq_zero] at hx\n  · rwa [Pi.sub_apply, Pi.zero_apply, sub_eq_zero]\n#align measure_theory.sub_ae_eq_zero MeasureTheory.sub_ae_eq_zero\n\ntheorem le_ae_restrict : μ.ae ⊓ 𝓟 s ≤ (μ.restrict s).ae := fun s hs =>\n  eventually_inf_principal.2 (ae_imp_of_ae_restrict hs)\n#align measure_theory.le_ae_restrict MeasureTheory.le_ae_restrict\n\n@[simp]\ntheorem ae_restrict_eq (hs : MeasurableSet s) : (μ.restrict s).ae = μ.ae ⊓ 𝓟 s :=\n  by\n  ext t\n  simp only [mem_inf_principal, mem_ae_iff, restrict_apply_eq_zero' hs, compl_set_of, not_imp,\n    and_comm' (_ ∈ s)]\n  rfl\n#align measure_theory.ae_restrict_eq MeasureTheory.ae_restrict_eq\n\n@[simp]\ntheorem ae_restrict_eq_bot {s} : (μ.restrict s).ae = ⊥ ↔ μ s = 0 :=\n  ae_eq_bot.trans restrict_eq_zero\n#align measure_theory.ae_restrict_eq_bot MeasureTheory.ae_restrict_eq_bot\n\n@[simp]\ntheorem ae_restrict_neBot {s} : (μ.restrict s).ae.ne_bot ↔ 0 < μ s :=\n  neBot_iff.trans <| (not_congr ae_restrict_eq_bot).trans pos_iff_ne_zero.symm\n#align measure_theory.ae_restrict_ne_bot MeasureTheory.ae_restrict_neBot\n\ntheorem self_mem_ae_restrict {s} (hs : MeasurableSet s) : s ∈ (μ.restrict s).ae := by\n  simp only [ae_restrict_eq hs, exists_prop, mem_principal, mem_inf_iff] <;>\n    exact ⟨_, univ_mem, s, subset.rfl, (univ_inter s).symm⟩\n#align measure_theory.self_mem_ae_restrict MeasureTheory.self_mem_ae_restrict\n\n/-- If two measurable sets are ae_eq then any proposition that is almost everywhere true on one\nis almost everywhere true on the other -/\ntheorem ae_restrict_of_ae_eq_of_ae_restrict {s t} (hst : s =ᵐ[μ] t) {p : α → Prop} :\n    (∀ᵐ x ∂μ.restrict s, p x) → ∀ᵐ x ∂μ.restrict t, p x := by simp [measure.restrict_congr_set hst]\n#align measure_theory.ae_restrict_of_ae_eq_of_ae_restrict MeasureTheory.ae_restrict_of_ae_eq_of_ae_restrict\n\n/-- If two measurable sets are ae_eq then any proposition that is almost everywhere true on one\nis almost everywhere true on the other -/\ntheorem ae_restrict_congr_set {s t} (hst : s =ᵐ[μ] t) {p : α → Prop} :\n    (∀ᵐ x ∂μ.restrict s, p x) ↔ ∀ᵐ x ∂μ.restrict t, p x :=\n  ⟨ae_restrict_of_ae_eq_of_ae_restrict hst, ae_restrict_of_ae_eq_of_ae_restrict hst.symm⟩\n#align measure_theory.ae_restrict_congr_set MeasureTheory.ae_restrict_congr_set\n\n/-- A version of the **Borel-Cantelli lemma**: if `pᵢ` is a sequence of predicates such that\n`∑ μ {x | pᵢ x}` is finite, then the measure of `x` such that `pᵢ x` holds frequently as `i → ∞` (or\nequivalently, `pᵢ x` holds for infinitely many `i`) is equal to zero. -/\ntheorem measure_setOf_frequently_eq_zero {p : ℕ → α → Prop} (hp : (∑' i, μ { x | p i x }) ≠ ∞) :\n    μ { x | ∃ᶠ n in atTop, p n x } = 0 := by\n  simpa only [limsup_eq_infi_supr_of_nat, frequently_at_top, set_of_forall, set_of_exists] using\n    measure_limsup_eq_zero hp\n#align measure_theory.measure_set_of_frequently_eq_zero MeasureTheory.measure_setOf_frequently_eq_zero\n\n/-- A version of the **Borel-Cantelli lemma**: if `sᵢ` is a sequence of sets such that\n`∑ μ sᵢ` exists, then for almost all `x`, `x` does not belong to almost all `sᵢ`. -/\ntheorem ae_eventually_not_mem {s : ℕ → Set α} (hs : (∑' i, μ (s i)) ≠ ∞) :\n    ∀ᵐ x ∂μ, ∀ᶠ n in atTop, x ∉ s n :=\n  measure_setOf_frequently_eq_zero hs\n#align measure_theory.ae_eventually_not_mem MeasureTheory.ae_eventually_not_mem\n\nsection Intervals\n\ntheorem bsupr_measure_Iic [Preorder α] {s : Set α} (hsc : s.Countable)\n    (hst : ∀ x : α, ∃ y ∈ s, x ≤ y) (hdir : DirectedOn (· ≤ ·) s) : (⨆ x ∈ s, μ (Iic x)) = μ univ :=\n  by\n  rw [← measure_bUnion_eq_supr hsc]\n  · congr\n    exact Union₂_eq_univ_iff.2 hst\n  · exact directedOn_iff_directed.2 (hdir.directed_coe.mono_comp _ fun x y => Iic_subset_Iic.2)\n#align measure_theory.bsupr_measure_Iic MeasureTheory.bsupr_measure_Iic\n\nvariable [PartialOrder α] {a b : α}\n\ntheorem Iio_ae_eq_Iic' (ha : μ {a} = 0) : Iio a =ᵐ[μ] Iic a := by\n  rw [← Iic_diff_right, diff_ae_eq_self, measure_mono_null (Set.inter_subset_right _ _) ha]\n#align measure_theory.Iio_ae_eq_Iic' MeasureTheory.Iio_ae_eq_Iic'\n\ntheorem Ioi_ae_eq_Ici' (ha : μ {a} = 0) : Ioi a =ᵐ[μ] Ici a :=\n  @Iio_ae_eq_Iic' αᵒᵈ ‹_› ‹_› _ _ ha\n#align measure_theory.Ioi_ae_eq_Ici' MeasureTheory.Ioi_ae_eq_Ici'\n\ntheorem Ioo_ae_eq_Ioc' (hb : μ {b} = 0) : Ioo a b =ᵐ[μ] Ioc a b :=\n  (ae_eq_refl _).inter (Iio_ae_eq_Iic' hb)\n#align measure_theory.Ioo_ae_eq_Ioc' MeasureTheory.Ioo_ae_eq_Ioc'\n\ntheorem Ioc_ae_eq_Icc' (ha : μ {a} = 0) : Ioc a b =ᵐ[μ] Icc a b :=\n  (Ioi_ae_eq_Ici' ha).inter (ae_eq_refl _)\n#align measure_theory.Ioc_ae_eq_Icc' MeasureTheory.Ioc_ae_eq_Icc'\n\ntheorem Ioo_ae_eq_Ico' (ha : μ {a} = 0) : Ioo a b =ᵐ[μ] Ico a b :=\n  (Ioi_ae_eq_Ici' ha).inter (ae_eq_refl _)\n#align measure_theory.Ioo_ae_eq_Ico' MeasureTheory.Ioo_ae_eq_Ico'\n\ntheorem Ioo_ae_eq_Icc' (ha : μ {a} = 0) (hb : μ {b} = 0) : Ioo a b =ᵐ[μ] Icc a b :=\n  (Ioi_ae_eq_Ici' ha).inter (Iio_ae_eq_Iic' hb)\n#align measure_theory.Ioo_ae_eq_Icc' MeasureTheory.Ioo_ae_eq_Icc'\n\ntheorem Ico_ae_eq_Icc' (hb : μ {b} = 0) : Ico a b =ᵐ[μ] Icc a b :=\n  (ae_eq_refl _).inter (Iio_ae_eq_Iic' hb)\n#align measure_theory.Ico_ae_eq_Icc' MeasureTheory.Ico_ae_eq_Icc'\n\ntheorem Ico_ae_eq_Ioc' (ha : μ {a} = 0) (hb : μ {b} = 0) : Ico a b =ᵐ[μ] Ioc a b :=\n  (Ioo_ae_eq_Ico' ha).symm.trans (Ioo_ae_eq_Ioc' hb)\n#align measure_theory.Ico_ae_eq_Ioc' MeasureTheory.Ico_ae_eq_Ioc'\n\nend Intervals\n\nsection Dirac\n\nvariable [MeasurableSpace α]\n\ntheorem mem_ae_dirac_iff {a : α} (hs : MeasurableSet s) : s ∈ (dirac a).ae ↔ a ∈ s := by\n  by_cases a ∈ s <;> simp [mem_ae_iff, dirac_apply', hs.compl, indicator_apply, *]\n#align measure_theory.mem_ae_dirac_iff MeasureTheory.mem_ae_dirac_iff\n\ntheorem ae_dirac_iff {a : α} {p : α → Prop} (hp : MeasurableSet { x | p x }) :\n    (∀ᵐ x ∂dirac a, p x) ↔ p a :=\n  mem_ae_dirac_iff hp\n#align measure_theory.ae_dirac_iff MeasureTheory.ae_dirac_iff\n\n@[simp]\ntheorem ae_dirac_eq [MeasurableSingletonClass α] (a : α) : (dirac a).ae = pure a :=\n  by\n  ext s\n  simp [mem_ae_iff, imp_false]\n#align measure_theory.ae_dirac_eq MeasureTheory.ae_dirac_eq\n\ntheorem ae_eq_dirac' [MeasurableSingletonClass β] {a : α} {f : α → β} (hf : Measurable f) :\n    f =ᵐ[dirac a] const α (f a) :=\n  (ae_dirac_iff <| show MeasurableSet (f ⁻¹' {f a}) from hf <| measurableSet_singleton _).2 rfl\n#align measure_theory.ae_eq_dirac' MeasureTheory.ae_eq_dirac'\n\ntheorem ae_eq_dirac [MeasurableSingletonClass α] {a : α} (f : α → δ) :\n    f =ᵐ[dirac a] const α (f a) := by simp [Filter.EventuallyEq]\n#align measure_theory.ae_eq_dirac MeasureTheory.ae_eq_dirac\n\nend Dirac\n\nsection IsFiniteMeasure\n\ninclude m0\n\n/-- A measure `μ` is called finite if `μ univ < ∞`. -/\nclass IsFiniteMeasure (μ : Measure α) : Prop where\n  measure_univ_lt_top : μ univ < ∞\n#align measure_theory.is_finite_measure MeasureTheory.IsFiniteMeasure\n\ntheorem not_isFiniteMeasure_iff : ¬IsFiniteMeasure μ ↔ μ Set.univ = ∞ :=\n  by\n  refine' ⟨fun h => _, fun h => fun h' => h'.measure_univ_lt_top.ne h⟩\n  by_contra h'\n  exact h ⟨lt_top_iff_ne_top.mpr h'⟩\n#align measure_theory.not_is_finite_measure_iff MeasureTheory.not_isFiniteMeasure_iff\n\ninstance Restrict.isFiniteMeasure (μ : Measure α) [hs : Fact (μ s < ∞)] :\n    IsFiniteMeasure (μ.restrict s) :=\n  ⟨by simp [hs.elim]⟩\n#align measure_theory.restrict.is_finite_measure MeasureTheory.Restrict.isFiniteMeasure\n\ntheorem measure_lt_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s < ∞ :=\n  (measure_mono (subset_univ s)).trans_lt IsFiniteMeasure.measure_univ_lt_top\n#align measure_theory.measure_lt_top MeasureTheory.measure_lt_top\n\ninstance isFiniteMeasureRestrict (μ : Measure α) (s : Set α) [h : IsFiniteMeasure μ] :\n    IsFiniteMeasure (μ.restrict s) :=\n  ⟨by simp [measure_lt_top μ s]⟩\n#align measure_theory.is_finite_measure_restrict MeasureTheory.isFiniteMeasureRestrict\n\ntheorem measure_ne_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s ≠ ∞ :=\n  ne_of_lt (measure_lt_top μ s)\n#align measure_theory.measure_ne_top MeasureTheory.measure_ne_top\n\ntheorem measure_compl_le_add_of_le_add [IsFiniteMeasure μ] (hs : MeasurableSet s)\n    (ht : MeasurableSet t) {ε : ℝ≥0∞} (h : μ s ≤ μ t + ε) : μ (tᶜ) ≤ μ (sᶜ) + ε :=\n  by\n  rw [measure_compl ht (measure_ne_top μ _), measure_compl hs (measure_ne_top μ _),\n    tsub_le_iff_right]\n  calc\n    μ univ = μ univ - μ s + μ s := (tsub_add_cancel_of_le <| measure_mono s.subset_univ).symm\n    _ ≤ μ univ - μ s + (μ t + ε) := (add_le_add_left h _)\n    _ = _ := by rw [add_right_comm, add_assoc]\n    \n#align measure_theory.measure_compl_le_add_of_le_add MeasureTheory.measure_compl_le_add_of_le_add\n\ntheorem measure_compl_le_add_iff [IsFiniteMeasure μ] (hs : MeasurableSet s) (ht : MeasurableSet t)\n    {ε : ℝ≥0∞} : μ (sᶜ) ≤ μ (tᶜ) + ε ↔ μ t ≤ μ s + ε :=\n  ⟨fun h => compl_compl s ▸ compl_compl t ▸ measure_compl_le_add_of_le_add hs.compl ht.compl h,\n    measure_compl_le_add_of_le_add ht hs⟩\n#align measure_theory.measure_compl_le_add_iff MeasureTheory.measure_compl_le_add_iff\n\n/-- The measure of the whole space with respect to a finite measure, considered as `ℝ≥0`. -/\ndef measureUnivNnreal (μ : Measure α) : ℝ≥0 :=\n  (μ univ).toNNReal\n#align measure_theory.measure_univ_nnreal MeasureTheory.measureUnivNnreal\n\n@[simp]\ntheorem coe_measureUnivNnreal (μ : Measure α) [IsFiniteMeasure μ] :\n    ↑(measureUnivNnreal μ) = μ univ :=\n  ENNReal.coe_toNNReal (measure_ne_top μ univ)\n#align measure_theory.coe_measure_univ_nnreal MeasureTheory.coe_measureUnivNnreal\n\ninstance isFiniteMeasureZero : IsFiniteMeasure (0 : Measure α) :=\n  ⟨by simp⟩\n#align measure_theory.is_finite_measure_zero MeasureTheory.isFiniteMeasureZero\n\ninstance (priority := 100) isFiniteMeasureOfIsEmpty [IsEmpty α] : IsFiniteMeasure μ :=\n  by\n  rw [eq_zero_of_is_empty μ]\n  infer_instance\n#align measure_theory.is_finite_measure_of_is_empty MeasureTheory.isFiniteMeasureOfIsEmpty\n\n@[simp]\ntheorem measureUnivNnreal_zero : measureUnivNnreal (0 : Measure α) = 0 :=\n  rfl\n#align measure_theory.measure_univ_nnreal_zero MeasureTheory.measureUnivNnreal_zero\n\nomit m0\n\ninstance isFiniteMeasureAdd [IsFiniteMeasure μ] [IsFiniteMeasure ν] : IsFiniteMeasure (μ + ν)\n    where measure_univ_lt_top :=\n    by\n    rw [measure.coe_add, Pi.add_apply, ENNReal.add_lt_top]\n    exact ⟨measure_lt_top _ _, measure_lt_top _ _⟩\n#align measure_theory.is_finite_measure_add MeasureTheory.isFiniteMeasureAdd\n\ninstance isFiniteMeasureSmulNnreal [IsFiniteMeasure μ] {r : ℝ≥0} : IsFiniteMeasure (r • μ)\n    where measure_univ_lt_top := ENNReal.mul_lt_top ENNReal.coe_ne_top (measure_ne_top _ _)\n#align measure_theory.is_finite_measure_smul_nnreal MeasureTheory.isFiniteMeasureSmulNnreal\n\ninstance isFiniteMeasureSmulOfNnrealTower {R} [SMul R ℝ≥0] [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0 ℝ≥0∞]\n    [IsScalarTower R ℝ≥0∞ ℝ≥0∞] [IsFiniteMeasure μ] {r : R} : IsFiniteMeasure (r • μ) :=\n  by\n  rw [← smul_one_smul ℝ≥0 r μ]\n  infer_instance\n#align measure_theory.is_finite_measure_smul_of_nnreal_tower MeasureTheory.isFiniteMeasureSmulOfNnrealTower\n\ntheorem isFiniteMeasureOfLe (μ : Measure α) [IsFiniteMeasure μ] (h : ν ≤ μ) : IsFiniteMeasure ν :=\n  { measure_univ_lt_top := lt_of_le_of_lt (h Set.univ MeasurableSet.univ) (measure_lt_top _ _) }\n#align measure_theory.is_finite_measure_of_le MeasureTheory.isFiniteMeasureOfLe\n\n@[instance]\ntheorem Measure.isFiniteMeasureMap {m : MeasurableSpace α} (μ : Measure α) [IsFiniteMeasure μ]\n    (f : α → β) : IsFiniteMeasure (μ.map f) :=\n  by\n  by_cases hf : AeMeasurable f μ\n  · constructor\n    rw [map_apply_of_ae_measurable hf MeasurableSet.univ]\n    exact measure_lt_top μ _\n  · rw [map_of_not_ae_measurable hf]\n    exact MeasureTheory.isFiniteMeasureZero\n#align measure_theory.measure.is_finite_measure_map MeasureTheory.Measure.isFiniteMeasureMap\n\n@[simp]\ntheorem measureUnivNnreal_eq_zero [IsFiniteMeasure μ] : measureUnivNnreal μ = 0 ↔ μ = 0 :=\n  by\n  rw [← MeasureTheory.Measure.measure_univ_eq_zero, ← coe_measure_univ_nnreal]\n  norm_cast\n#align measure_theory.measure_univ_nnreal_eq_zero MeasureTheory.measureUnivNnreal_eq_zero\n\ntheorem measureUnivNnreal_pos [IsFiniteMeasure μ] (hμ : μ ≠ 0) : 0 < measureUnivNnreal μ :=\n  by\n  contrapose! hμ\n  simpa [measure_univ_nnreal_eq_zero, le_zero_iff] using hμ\n#align measure_theory.measure_univ_nnreal_pos MeasureTheory.measureUnivNnreal_pos\n\n/-- `le_of_add_le_add_left` is normally applicable to `ordered_cancel_add_comm_monoid`,\nbut it holds for measures with the additional assumption that μ is finite. -/\ntheorem Measure.le_of_add_le_add_left [IsFiniteMeasure μ] (A2 : μ + ν₁ ≤ μ + ν₂) : ν₁ ≤ ν₂ :=\n  fun S B1 => ENNReal.le_of_add_le_add_left (MeasureTheory.measure_ne_top μ S) (A2 S B1)\n#align measure_theory.measure.le_of_add_le_add_left MeasureTheory.Measure.le_of_add_le_add_left\n\ntheorem summable_measure_toReal [hμ : IsFiniteMeasure μ] {f : ℕ → Set α}\n    (hf₁ : ∀ i : ℕ, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) :\n    Summable fun x => (μ (f x)).toReal :=\n  by\n  apply ENNReal.summable_toReal\n  rw [← MeasureTheory.measure_unionᵢ hf₂ hf₁]\n  exact ne_of_lt (measure_lt_top _ _)\n#align measure_theory.summable_measure_to_real MeasureTheory.summable_measure_toReal\n\ntheorem ae_eq_univ_iff_measure_eq [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ) :\n    s =ᵐ[μ] univ ↔ μ s = μ univ :=\n  by\n  refine' ⟨measure_congr, fun h => _⟩\n  obtain ⟨t, -, ht₁, ht₂⟩ := hs.exists_measurable_subset_ae_eq\n  exact\n    ht₂.symm.trans\n      (ae_eq_of_subset_of_measure_ge (subset_univ t) (Eq.le ((measure_congr ht₂).trans h).symm) ht₁\n        (measure_ne_top μ univ))\n#align measure_theory.ae_eq_univ_iff_measure_eq MeasureTheory.ae_eq_univ_iff_measure_eq\n\ntheorem ae_iff_measure_eq [IsFiniteMeasure μ] {p : α → Prop}\n    (hp : NullMeasurableSet { a | p a } μ) : (∀ᵐ a ∂μ, p a) ↔ μ { a | p a } = μ univ := by\n  rw [← ae_eq_univ_iff_measure_eq hp, eventually_eq_univ, eventually_iff]\n#align measure_theory.ae_iff_measure_eq MeasureTheory.ae_iff_measure_eq\n\ntheorem ae_mem_iff_measure_eq [IsFiniteMeasure μ] {s : Set α} (hs : NullMeasurableSet s μ) :\n    (∀ᵐ a ∂μ, a ∈ s) ↔ μ s = μ univ :=\n  ae_iff_measure_eq hs\n#align measure_theory.ae_mem_iff_measure_eq MeasureTheory.ae_mem_iff_measure_eq\n\ninstance [Finite α] [MeasurableSpace α] : IsFiniteMeasure (Measure.count : Measure α) :=\n  ⟨by\n    cases nonempty_fintype α\n    simpa [measure.count_apply, tsum_fintype] using (ENNReal.nat_ne_top _).lt_top⟩\n\nend IsFiniteMeasure\n\nsection IsProbabilityMeasure\n\ninclude m0\n\n/-- A measure `μ` is called a probability measure if `μ univ = 1`. -/\nclass IsProbabilityMeasure (μ : Measure α) : Prop where\n  measure_univ : μ univ = 1\n#align measure_theory.is_probability_measure MeasureTheory.IsProbabilityMeasure\n\nexport IsProbabilityMeasure (measure_univ)\n\nattribute [simp] is_probability_measure.measure_univ\n\ninstance (priority := 100) IsProbabilityMeasure.toIsFiniteMeasure (μ : Measure α)\n    [IsProbabilityMeasure μ] : IsFiniteMeasure μ :=\n  ⟨by simp only [measure_univ, ENNReal.one_lt_top]⟩\n#align measure_theory.is_probability_measure.to_is_finite_measure MeasureTheory.IsProbabilityMeasure.toIsFiniteMeasure\n\ntheorem IsProbabilityMeasure.ne_zero (μ : Measure α) [IsProbabilityMeasure μ] : μ ≠ 0 :=\n  mt measure_univ_eq_zero.2 <| by simp [measure_univ]\n#align measure_theory.is_probability_measure.ne_zero MeasureTheory.IsProbabilityMeasure.ne_zero\n\ninstance (priority := 200) IsProbabilityMeasure.ae_neBot [IsProbabilityMeasure μ] : NeBot μ.ae :=\n  ae_neBot.2 (IsProbabilityMeasure.ne_zero μ)\n#align measure_theory.is_probability_measure.ae_ne_bot MeasureTheory.IsProbabilityMeasure.ae_neBot\n\nomit m0\n\ninstance Measure.dirac.isProbabilityMeasure [MeasurableSpace α] {x : α} :\n    IsProbabilityMeasure (dirac x) :=\n  ⟨dirac_apply_of_mem <| mem_univ x⟩\n#align measure_theory.measure.dirac.is_probability_measure MeasureTheory.Measure.dirac.isProbabilityMeasure\n\ntheorem prob_add_prob_compl [IsProbabilityMeasure μ] (h : MeasurableSet s) : μ s + μ (sᶜ) = 1 :=\n  (measure_add_measure_compl h).trans measure_univ\n#align measure_theory.prob_add_prob_compl MeasureTheory.prob_add_prob_compl\n\ntheorem prob_le_one [IsProbabilityMeasure μ] : μ s ≤ 1 :=\n  (measure_mono <| Set.subset_univ _).trans_eq measure_univ\n#align measure_theory.prob_le_one MeasureTheory.prob_le_one\n\ntheorem isProbabilityMeasureSmul [IsFiniteMeasure μ] (h : μ ≠ 0) :\n    IsProbabilityMeasure ((μ univ)⁻¹ • μ) :=\n  by\n  constructor\n  rw [smul_apply, smul_eq_mul, ENNReal.inv_mul_cancel]\n  · rwa [Ne, measure_univ_eq_zero]\n  · exact measure_ne_top _ _\n#align measure_theory.is_probability_measure_smul MeasureTheory.isProbabilityMeasureSmul\n\ntheorem isProbabilityMeasureMap [IsProbabilityMeasure μ] {f : α → β} (hf : AeMeasurable f μ) :\n    IsProbabilityMeasure (map f μ) :=\n  ⟨by simp [map_apply_of_ae_measurable, hf]⟩\n#align measure_theory.is_probability_measure_map MeasureTheory.isProbabilityMeasureMap\n\n@[simp]\ntheorem one_le_prob_iff [IsProbabilityMeasure μ] : 1 ≤ μ s ↔ μ s = 1 :=\n  ⟨fun h => le_antisymm prob_le_one h, fun h => h ▸ le_refl _⟩\n#align measure_theory.one_le_prob_iff MeasureTheory.one_le_prob_iff\n\n/-- Note that this is not quite as useful as it looks because the measure takes values in `ℝ≥0∞`.\nThus the subtraction appearing is the truncated subtraction of `ℝ≥0∞`, rather than the\nbetter-behaved subtraction of `ℝ`. -/\ntheorem prob_compl_eq_one_sub [IsProbabilityMeasure μ] (hs : MeasurableSet s) : μ (sᶜ) = 1 - μ s :=\n  by simpa only [measure_univ] using measure_compl hs (measure_lt_top μ s).Ne\n#align measure_theory.prob_compl_eq_one_sub MeasureTheory.prob_compl_eq_one_sub\n\n@[simp]\ntheorem prob_compl_eq_zero_iff [IsProbabilityMeasure μ] (hs : MeasurableSet s) :\n    μ (sᶜ) = 0 ↔ μ s = 1 := by\n  simp only [prob_compl_eq_one_sub hs, tsub_eq_zero_iff_le, one_le_prob_iff]\n#align measure_theory.prob_compl_eq_zero_iff MeasureTheory.prob_compl_eq_zero_iff\n\n@[simp]\ntheorem prob_compl_eq_one_iff [IsProbabilityMeasure μ] (hs : MeasurableSet s) :\n    μ (sᶜ) = 1 ↔ μ s = 0 := by rwa [← prob_compl_eq_zero_iff hs.compl, compl_compl]\n#align measure_theory.prob_compl_eq_one_iff MeasureTheory.prob_compl_eq_one_iff\n\nend IsProbabilityMeasure\n\nsection NoAtoms\n\n/-- Measure `μ` *has no atoms* if the measure of each singleton is zero.\n\nNB: Wikipedia assumes that for any measurable set `s` with positive `μ`-measure,\nthere exists a measurable `t ⊆ s` such that `0 < μ t < μ s`. While this implies `μ {x} = 0`,\nthe converse is not true. -/\nclass HasNoAtoms {m0 : MeasurableSpace α} (μ : Measure α) : Prop where\n  measure_singleton : ∀ x, μ {x} = 0\n#align measure_theory.has_no_atoms MeasureTheory.HasNoAtoms\n\nexport HasNoAtoms (measure_singleton)\n\nattribute [simp] measure_singleton\n\nvariable [HasNoAtoms μ]\n\ntheorem Set.Subsingleton.measure_zero {α : Type _} {m : MeasurableSpace α} {s : Set α}\n    (hs : s.Subsingleton) (μ : Measure α) [HasNoAtoms μ] : μ s = 0 :=\n  hs.inductionOn measure_empty measure_singleton\n#align set.subsingleton.measure_zero Set.Subsingleton.measure_zero\n\ntheorem Measure.restrict_singleton' {a : α} : μ.restrict {a} = 0 := by\n  simp only [measure_singleton, measure.restrict_eq_zero]\n#align measure_theory.measure.restrict_singleton' MeasureTheory.Measure.restrict_singleton'\n\ninstance (s : Set α) : HasNoAtoms (μ.restrict s) :=\n  by\n  refine' ⟨fun x => _⟩\n  obtain ⟨t, hxt, ht1, ht2⟩ := exists_measurable_superset_of_null (measure_singleton x : μ {x} = 0)\n  apply measure_mono_null hxt\n  rw [measure.restrict_apply ht1]\n  apply measure_mono_null (inter_subset_left t s) ht2\n\ntheorem Set.Countable.measure_zero {α : Type _} {m : MeasurableSpace α} {s : Set α}\n    (h : s.Countable) (μ : Measure α) [HasNoAtoms μ] : μ s = 0 :=\n  by\n  rw [← bUnion_of_singleton s, ← nonpos_iff_eq_zero]\n  refine' le_trans (measure_bUnion_le h _) _\n  simp\n#align set.countable.measure_zero Set.Countable.measure_zero\n\ntheorem Set.Countable.ae_not_mem {α : Type _} {m : MeasurableSpace α} {s : Set α} (h : s.Countable)\n    (μ : Measure α) [HasNoAtoms μ] : ∀ᵐ x ∂μ, x ∉ s := by\n  simpa only [ae_iff, Classical.not_not] using h.measure_zero μ\n#align set.countable.ae_not_mem Set.Countable.ae_not_mem\n\ntheorem Set.Finite.measure_zero {α : Type _} {m : MeasurableSpace α} {s : Set α} (h : s.Finite)\n    (μ : Measure α) [HasNoAtoms μ] : μ s = 0 :=\n  h.Countable.measure_zero μ\n#align set.finite.measure_zero Set.Finite.measure_zero\n\ntheorem Finset.measure_zero {α : Type _} {m : MeasurableSpace α} (s : Finset α) (μ : Measure α)\n    [HasNoAtoms μ] : μ s = 0 :=\n  s.finite_toSet.measure_zero μ\n#align finset.measure_zero Finset.measure_zero\n\ntheorem insert_ae_eq_self (a : α) (s : Set α) : (insert a s : Set α) =ᵐ[μ] s :=\n  union_ae_eq_right.2 <| measure_mono_null (diff_subset _ _) (measure_singleton _)\n#align measure_theory.insert_ae_eq_self MeasureTheory.insert_ae_eq_self\n\nsection\n\nvariable [PartialOrder α] {a b : α}\n\ntheorem Iio_ae_eq_Iic : Iio a =ᵐ[μ] Iic a :=\n  Iio_ae_eq_Iic' (measure_singleton a)\n#align measure_theory.Iio_ae_eq_Iic MeasureTheory.Iio_ae_eq_Iic\n\ntheorem Ioi_ae_eq_Ici : Ioi a =ᵐ[μ] Ici a :=\n  Ioi_ae_eq_Ici' (measure_singleton a)\n#align measure_theory.Ioi_ae_eq_Ici MeasureTheory.Ioi_ae_eq_Ici\n\ntheorem Ioo_ae_eq_Ioc : Ioo a b =ᵐ[μ] Ioc a b :=\n  Ioo_ae_eq_Ioc' (measure_singleton b)\n#align measure_theory.Ioo_ae_eq_Ioc MeasureTheory.Ioo_ae_eq_Ioc\n\ntheorem Ioc_ae_eq_Icc : Ioc a b =ᵐ[μ] Icc a b :=\n  Ioc_ae_eq_Icc' (measure_singleton a)\n#align measure_theory.Ioc_ae_eq_Icc MeasureTheory.Ioc_ae_eq_Icc\n\ntheorem Ioo_ae_eq_Ico : Ioo a b =ᵐ[μ] Ico a b :=\n  Ioo_ae_eq_Ico' (measure_singleton a)\n#align measure_theory.Ioo_ae_eq_Ico MeasureTheory.Ioo_ae_eq_Ico\n\ntheorem Ioo_ae_eq_Icc : Ioo a b =ᵐ[μ] Icc a b :=\n  Ioo_ae_eq_Icc' (measure_singleton a) (measure_singleton b)\n#align measure_theory.Ioo_ae_eq_Icc MeasureTheory.Ioo_ae_eq_Icc\n\ntheorem Ico_ae_eq_Icc : Ico a b =ᵐ[μ] Icc a b :=\n  Ico_ae_eq_Icc' (measure_singleton b)\n#align measure_theory.Ico_ae_eq_Icc MeasureTheory.Ico_ae_eq_Icc\n\ntheorem Ico_ae_eq_Ioc : Ico a b =ᵐ[μ] Ioc a b :=\n  Ico_ae_eq_Ioc' (measure_singleton a) (measure_singleton b)\n#align measure_theory.Ico_ae_eq_Ioc MeasureTheory.Ico_ae_eq_Ioc\n\nend\n\nopen Interval\n\ntheorem uIoc_ae_eq_interval [LinearOrder α] {a b : α} : Ι a b =ᵐ[μ] [a, b] :=\n  Ioc_ae_eq_Icc\n#align measure_theory.uIoc_ae_eq_interval MeasureTheory.uIoc_ae_eq_interval\n\nend NoAtoms\n\ntheorem ite_ae_eq_of_measure_zero {γ} (f : α → γ) (g : α → γ) (s : Set α) (hs_zero : μ s = 0) :\n    (fun x => ite (x ∈ s) (f x) (g x)) =ᵐ[μ] g :=\n  by\n  have h_ss : sᶜ ⊆ { a : α | ite (a ∈ s) (f a) (g a) = g a } := fun x hx => by\n    simp [(Set.mem_compl_iff _ _).mp hx]\n  refine' measure_mono_null _ hs_zero\n  nth_rw 1 [← compl_compl s]\n  rwa [Set.compl_subset_compl]\n#align measure_theory.ite_ae_eq_of_measure_zero MeasureTheory.ite_ae_eq_of_measure_zero\n\ntheorem ite_ae_eq_of_measure_compl_zero {γ} (f : α → γ) (g : α → γ) (s : Set α)\n    (hs_zero : μ (sᶜ) = 0) : (fun x => ite (x ∈ s) (f x) (g x)) =ᵐ[μ] f :=\n  by\n  filter_upwards [hs_zero]\n  intros\n  split_ifs\n  rfl\n#align measure_theory.ite_ae_eq_of_measure_compl_zero MeasureTheory.ite_ae_eq_of_measure_compl_zero\n\nnamespace Measure\n\n/-- A measure is called finite at filter `f` if it is finite at some set `s ∈ f`.\nEquivalently, it is eventually finite at `s` in `f.small_sets`. -/\ndef FiniteAtFilter {m0 : MeasurableSpace α} (μ : Measure α) (f : Filter α) : Prop :=\n  ∃ s ∈ f, μ s < ∞\n#align measure_theory.measure.finite_at_filter MeasureTheory.Measure.FiniteAtFilter\n\ntheorem finiteAtFilterOfFinite {m0 : MeasurableSpace α} (μ : Measure α) [IsFiniteMeasure μ]\n    (f : Filter α) : μ.FiniteAtFilter f :=\n  ⟨univ, univ_mem, measure_lt_top μ univ⟩\n#align measure_theory.measure.finite_at_filter_of_finite MeasureTheory.Measure.finiteAtFilterOfFinite\n\ntheorem FiniteAtFilter.exists_mem_basis {f : Filter α} (hμ : FiniteAtFilter μ f) {p : ι → Prop}\n    {s : ι → Set α} (hf : f.HasBasis p s) : ∃ (i : _)(hi : p i), μ (s i) < ∞ :=\n  (hf.exists_iff fun s t hst ht => (measure_mono hst).trans_lt ht).1 hμ\n#align measure_theory.measure.finite_at_filter.exists_mem_basis MeasureTheory.Measure.FiniteAtFilter.exists_mem_basis\n\ntheorem finiteAtBot {m0 : MeasurableSpace α} (μ : Measure α) : μ.FiniteAtFilter ⊥ :=\n  ⟨∅, mem_bot, by simp only [measure_empty, WithTop.zero_lt_top]⟩\n#align measure_theory.measure.finite_at_bot MeasureTheory.Measure.finiteAtBot\n\n/-- `μ` has finite spanning sets in `C` if there is a countable sequence of sets in `C` that have\n  finite measures. This structure is a type, which is useful if we want to record extra properties\n  about the sets, such as that they are monotone.\n  `sigma_finite` is defined in terms of this: `μ` is σ-finite if there exists a sequence of\n  finite spanning sets in the collection of all measurable sets. -/\n@[protect_proj, nolint has_nonempty_instance]\nstructure FiniteSpanningSetsIn {m0 : MeasurableSpace α} (μ : Measure α) (C : Set (Set α)) where\n  Set : ℕ → Set α\n  set_mem : ∀ i, Set i ∈ C\n  Finite : ∀ i, μ (Set i) < ∞\n  spanning : (⋃ i, Set i) = univ\n#align measure_theory.measure.finite_spanning_sets_in MeasureTheory.Measure.FiniteSpanningSetsIn\n\nend Measure\n\nopen Measure\n\n/-- A measure `μ` is called σ-finite if there is a countable collection of sets\n `{ A i | i ∈ ℕ }` such that `μ (A i) < ∞` and `⋃ i, A i = s`. -/\nclass SigmaFinite {m0 : MeasurableSpace α} (μ : Measure α) : Prop where\n  out' : Nonempty (μ.FiniteSpanningSetsIn univ)\n#align measure_theory.sigma_finite MeasureTheory.SigmaFinite\n\ntheorem sigmaFinite_iff : SigmaFinite μ ↔ Nonempty (μ.FiniteSpanningSetsIn univ) :=\n  ⟨fun h => h.1, fun h => ⟨h⟩⟩\n#align measure_theory.sigma_finite_iff MeasureTheory.sigmaFinite_iff\n\ntheorem SigmaFinite.out (h : SigmaFinite μ) : Nonempty (μ.FiniteSpanningSetsIn univ) :=\n  h.1\n#align measure_theory.sigma_finite.out MeasureTheory.SigmaFinite.out\n\ninclude m0\n\n/-- If `μ` is σ-finite it has finite spanning sets in the collection of all measurable sets. -/\ndef Measure.toFiniteSpanningSetsIn (μ : Measure α) [h : SigmaFinite μ] :\n    μ.FiniteSpanningSetsIn { s | MeasurableSet s }\n    where\n  Set n := toMeasurable μ (h.out.some.Set n)\n  set_mem n := measurableSet_toMeasurable _ _\n  Finite n := by\n    rw [measure_to_measurable]\n    exact h.out.some.finite n\n  spanning := eq_univ_of_subset (unionᵢ_mono fun n => subset_toMeasurable _ _) h.out.some.spanning\n#align measure_theory.measure.to_finite_spanning_sets_in MeasureTheory.Measure.toFiniteSpanningSetsIn\n\n/-- A noncomputable way to get a monotone collection of sets that span `univ` and have finite\n  measure using `classical.some`. This definition satisfies monotonicity in addition to all other\n  properties in `sigma_finite`. -/\ndef spanningSets (μ : Measure α) [SigmaFinite μ] (i : ℕ) : Set α :=\n  Accumulate μ.toFiniteSpanningSetsIn.Set i\n#align measure_theory.spanning_sets MeasureTheory.spanningSets\n\ntheorem monotone_spanningSets (μ : Measure α) [SigmaFinite μ] : Monotone (spanningSets μ) :=\n  monotone_accumulate\n#align measure_theory.monotone_spanning_sets MeasureTheory.monotone_spanningSets\n\ntheorem measurable_spanningSets (μ : Measure α) [SigmaFinite μ] (i : ℕ) :\n    MeasurableSet (spanningSets μ i) :=\n  MeasurableSet.unionᵢ fun j => MeasurableSet.unionᵢ fun hij => μ.toFiniteSpanningSetsIn.set_mem j\n#align measure_theory.measurable_spanning_sets MeasureTheory.measurable_spanningSets\n\ntheorem measure_spanningSets_lt_top (μ : Measure α) [SigmaFinite μ] (i : ℕ) :\n    μ (spanningSets μ i) < ∞ :=\n  measure_bUnion_lt_top (finite_le_nat i) fun j _ => (μ.toFiniteSpanningSetsIn.Finite j).Ne\n#align measure_theory.measure_spanning_sets_lt_top MeasureTheory.measure_spanningSets_lt_top\n\ntheorem unionᵢ_spanningSets (μ : Measure α) [SigmaFinite μ] : (⋃ i : ℕ, spanningSets μ i) = univ :=\n  by simp_rw [spanning_sets, Union_accumulate, μ.to_finite_spanning_sets_in.spanning]\n#align measure_theory.Union_spanning_sets MeasureTheory.unionᵢ_spanningSets\n\ntheorem isCountablySpanning_spanningSets (μ : Measure α) [SigmaFinite μ] :\n    IsCountablySpanning (range (spanningSets μ)) :=\n  ⟨spanningSets μ, mem_range_self, unionᵢ_spanningSets μ⟩\n#align measure_theory.is_countably_spanning_spanning_sets MeasureTheory.isCountablySpanning_spanningSets\n\n/-- `spanning_sets_index μ x` is the least `n : ℕ` such that `x ∈ spanning_sets μ n`. -/\ndef spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) : ℕ :=\n  Nat.find <| unionᵢ_eq_univ_iff.1 (unionᵢ_spanningSets μ) x\n#align measure_theory.spanning_sets_index MeasureTheory.spanningSetsIndex\n\ntheorem measurable_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] :\n    Measurable (spanningSetsIndex μ) :=\n  measurable_find _ <| measurable_spanningSets μ\n#align measure_theory.measurable_spanning_sets_index MeasureTheory.measurable_spanningSetsIndex\n\ntheorem preimage_spanningSetsIndex_singleton (μ : Measure α) [SigmaFinite μ] (n : ℕ) :\n    spanningSetsIndex μ ⁻¹' {n} = disjointed (spanningSets μ) n :=\n  preimage_find_eq_disjointed _ _ _\n#align measure_theory.preimage_spanning_sets_index_singleton MeasureTheory.preimage_spanningSetsIndex_singleton\n\ntheorem spanningSetsIndex_eq_iff (μ : Measure α) [SigmaFinite μ] {x : α} {n : ℕ} :\n    spanningSetsIndex μ x = n ↔ x ∈ disjointed (spanningSets μ) n := by\n  convert Set.ext_iff.1 (preimage_spanning_sets_index_singleton μ n) x\n#align measure_theory.spanning_sets_index_eq_iff MeasureTheory.spanningSetsIndex_eq_iff\n\ntheorem mem_disjointed_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) :\n    x ∈ disjointed (spanningSets μ) (spanningSetsIndex μ x) :=\n  (spanningSetsIndex_eq_iff μ).1 rfl\n#align measure_theory.mem_disjointed_spanning_sets_index MeasureTheory.mem_disjointed_spanningSetsIndex\n\ntheorem mem_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) :\n    x ∈ spanningSets μ (spanningSetsIndex μ x) :=\n  disjointed_subset _ _ (mem_disjointed_spanningSetsIndex μ x)\n#align measure_theory.mem_spanning_sets_index MeasureTheory.mem_spanningSetsIndex\n\ntheorem mem_spanningSets_of_index_le (μ : Measure α) [SigmaFinite μ] (x : α) {n : ℕ}\n    (hn : spanningSetsIndex μ x ≤ n) : x ∈ spanningSets μ n :=\n  monotone_spanningSets μ hn (mem_spanningSetsIndex μ x)\n#align measure_theory.mem_spanning_sets_of_index_le MeasureTheory.mem_spanningSets_of_index_le\n\ntheorem eventually_mem_spanningSets (μ : Measure α) [SigmaFinite μ] (x : α) :\n    ∀ᶠ n in atTop, x ∈ spanningSets μ n :=\n  eventually_atTop.2 ⟨spanningSetsIndex μ x, fun b => mem_spanningSets_of_index_le μ x⟩\n#align measure_theory.eventually_mem_spanning_sets MeasureTheory.eventually_mem_spanningSets\n\nomit m0\n\nnamespace Measure\n\ntheorem supᵢ_restrict_spanningSets [SigmaFinite μ] (hs : MeasurableSet s) :\n    (⨆ i, μ.restrict (spanningSets μ i) s) = μ s :=\n  calc\n    (⨆ i, μ.restrict (spanningSets μ i) s) = μ.restrict (⋃ i, spanningSets μ i) s :=\n      (restrict_unionᵢ_apply_eq_supᵢ (directed_of_sup (monotone_spanningSets μ)) hs).symm\n    _ = μ s := by rw [Union_spanning_sets, restrict_univ]\n    \n#align measure_theory.measure.supr_restrict_spanning_sets MeasureTheory.Measure.supᵢ_restrict_spanningSets\n\n/-- In a σ-finite space, any measurable set of measure `> r` contains a measurable subset of\nfinite measure `> r`. -/\ntheorem exists_subset_measure_lt_top [SigmaFinite μ] {r : ℝ≥0∞} (hs : MeasurableSet s)\n    (h's : r < μ s) : ∃ t, MeasurableSet t ∧ t ⊆ s ∧ r < μ t ∧ μ t < ∞ :=\n  by\n  rw [← supr_restrict_spanning_sets hs,\n    @lt_supᵢ_iff _ _ _ r fun i : ℕ => μ.restrict (spanning_sets μ i) s] at h's\n  rcases h's with ⟨n, hn⟩\n  simp only [restrict_apply hs] at hn\n  refine'\n    ⟨s ∩ spanning_sets μ n, hs.inter (measurable_spanning_sets _ _), inter_subset_left _ _, hn, _⟩\n  exact (measure_mono (inter_subset_right _ _)).trans_lt (measure_spanning_sets_lt_top _ _)\n#align measure_theory.measure.exists_subset_measure_lt_top MeasureTheory.Measure.exists_subset_measure_lt_top\n\n/-- A set in a σ-finite space has zero measure if and only if its intersection with\nall members of the countable family of finite measure spanning sets has zero measure. -/\ntheorem forall_measure_inter_spanningSets_eq_zero [MeasurableSpace α] {μ : Measure α}\n    [SigmaFinite μ] (s : Set α) : (∀ n, μ (s ∩ spanningSets μ n) = 0) ↔ μ s = 0 :=\n  by\n  nth_rw 1 [show s = ⋃ n, s ∩ spanning_sets μ n by\n      rw [← inter_Union, Union_spanning_sets, inter_univ]]\n  rw [measure_Union_null_iff]\n#align measure_theory.measure.forall_measure_inter_spanning_sets_eq_zero MeasureTheory.Measure.forall_measure_inter_spanningSets_eq_zero\n\n/-- A set in a σ-finite space has positive measure if and only if its intersection with\nsome member of the countable family of finite measure spanning sets has positive measure. -/\ntheorem exists_measure_inter_spanningSets_pos [MeasurableSpace α] {μ : Measure α} [SigmaFinite μ]\n    (s : Set α) : (∃ n, 0 < μ (s ∩ spanningSets μ n)) ↔ 0 < μ s :=\n  by\n  rw [← not_iff_not]\n  simp only [not_exists, not_lt, nonpos_iff_eq_zero]\n  exact forall_measure_inter_spanning_sets_eq_zero s\n#align measure_theory.measure.exists_measure_inter_spanning_sets_pos MeasureTheory.Measure.exists_measure_inter_spanningSets_pos\n\n/-- If the union of disjoint measurable sets has finite measure, then there are only\nfinitely many members of the union whose measure exceeds any given positive number. -/\ntheorem finite_const_le_meas_of_disjoint_unionᵢ {ι : Type _} [MeasurableSpace α] (μ : Measure α)\n    {ε : ℝ≥0∞} (ε_pos : 0 < ε) {As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) (Union_As_finite : μ (⋃ i, As i) ≠ ∞) :\n    Set.Finite { i : ι | ε ≤ μ (As i) } := by\n  by_contra con\n  have aux :=\n    lt_of_le_of_lt (tsum_meas_le_meas_Union_of_disjoint μ As_mble As_disj)\n      (lt_top_iff_ne_top.mpr Union_As_finite)\n  exact Con (ENNReal.finite_const_le_of_tsum_ne_top aux.ne ε_pos.ne.symm)\n#align measure_theory.measure.finite_const_le_meas_of_disjoint_Union MeasureTheory.Measure.finite_const_le_meas_of_disjoint_unionᵢ\n\n/-- If the union of disjoint measurable sets has finite measure, then there are only\ncountably many members of the union whose measure is positive. -/\ntheorem countable_meas_pos_of_disjoint_of_meas_unionᵢ_ne_top {ι : Type _} [MeasurableSpace α]\n    (μ : Measure α) {As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) (Union_As_finite : μ (⋃ i, As i) ≠ ∞) :\n    Set.Countable { i : ι | 0 < μ (As i) } :=\n  by\n  set posmeas := { i : ι | 0 < μ (As i) } with posmeas_def\n  rcases exists_seq_strictAnti_tendsto' (zero_lt_one : (0 : ℝ≥0∞) < 1) with\n    ⟨as, as_decr, as_mem, as_lim⟩\n  set fairmeas := fun n : ℕ => { i : ι | as n ≤ μ (As i) } with fairmeas_def\n  have countable_union : posmeas = ⋃ n, fairmeas n :=\n    by\n    have fairmeas_eq : ∀ n, fairmeas n = (fun i => μ (As i)) ⁻¹' Ici (as n) := fun n => by\n      simpa only [fairmeas_def]\n    simpa only [fairmeas_eq, posmeas_def, ← preimage_Union,\n      unionᵢ_Ici_eq_Ioi_of_lt_of_tendsto (0 : ℝ≥0∞) (fun n => (as_mem n).1) as_lim]\n  rw [countable_union]\n  refine' countable_Union fun n => finite.countable _\n  refine' finite_const_le_meas_of_disjoint_Union μ (as_mem n).1 As_mble As_disj Union_As_finite\n#align measure_theory.measure.countable_meas_pos_of_disjoint_of_meas_Union_ne_top MeasureTheory.Measure.countable_meas_pos_of_disjoint_of_meas_unionᵢ_ne_top\n\n/-- In a σ-finite space, among disjoint measurable sets, only countably many can have positive\nmeasure. -/\ntheorem countable_meas_pos_of_disjoint_Union {ι : Type _} [MeasurableSpace α] {μ : Measure α}\n    [SigmaFinite μ] {As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) : Set.Countable { i : ι | 0 < μ (As i) } :=\n  by\n  have obs : { i : ι | 0 < μ (As i) } ⊆ ⋃ n, { i : ι | 0 < μ (As i ∩ spanning_sets μ n) } :=\n    by\n    intro i i_in_nonzeroes\n    by_contra con\n    simp only [mem_Union, mem_set_of_eq, not_exists, not_lt, nonpos_iff_eq_zero] at *\n    simpa [(forall_measure_inter_spanning_sets_eq_zero _).mp Con] using i_in_nonzeroes\n  apply countable.mono obs\n  refine' countable_Union fun n => countable_meas_pos_of_disjoint_of_meas_Union_ne_top μ _ _ _\n  · exact fun i => MeasurableSet.inter (As_mble i) (measurable_spanning_sets μ n)\n  ·\n    exact fun i j i_ne_j b hbi hbj =>\n      As_disj i_ne_j (hbi.trans (inter_subset_left _ _)) (hbj.trans (inter_subset_left _ _))\n  · refine' (lt_of_le_of_lt (measure_mono _) (measure_spanning_sets_lt_top μ n)).Ne\n    exact Union_subset fun i => inter_subset_right _ _\n#align measure_theory.measure.countable_meas_pos_of_disjoint_Union MeasureTheory.Measure.countable_meas_pos_of_disjoint_Union\n\ntheorem countable_meas_level_set_pos {α β : Type _} [MeasurableSpace α] {μ : Measure α}\n    [SigmaFinite μ] [MeasurableSpace β] [MeasurableSingletonClass β] {g : α → β}\n    (g_mble : Measurable g) : Set.Countable { t : β | 0 < μ { a : α | g a = t } } :=\n  haveI level_sets_disjoint : Pairwise (Disjoint on fun t : β => { a : α | g a = t }) :=\n    fun s t hst => Disjoint.preimage g (disjoint_singleton.mpr hst)\n  measure.countable_meas_pos_of_disjoint_Union\n    (fun b => g_mble (‹MeasurableSingletonClass β›.measurableSet_singleton b)) level_sets_disjoint\n#align measure_theory.measure.countable_meas_level_set_pos MeasureTheory.Measure.countable_meas_level_set_pos\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t' «expr ⊇ » t) -/\n/-- If a set `t` is covered by a countable family of finite measure sets, then its measurable\nsuperset `to_measurable μ t` (which has the same measure as `t`) satisfies,\nfor any measurable set `s`, the equality `μ (to_measurable μ t ∩ s) = μ (t ∩ s)`. -/\ntheorem measure_toMeasurable_inter_of_cover {s : Set α} (hs : MeasurableSet s) {t : Set α}\n    {v : ℕ → Set α} (hv : t ⊆ ⋃ n, v n) (h'v : ∀ n, μ (t ∩ v n) ≠ ∞) :\n    μ (toMeasurable μ t ∩ s) = μ (t ∩ s) :=\n  by\n  -- we show that there is a measurable superset of `t` satisfying the conclusion for any\n  -- measurable set `s`. It is built on each member of a spanning family using `to_measurable`\n  -- (which is well behaved for finite measure sets thanks to `measure_to_measurable_inter`), and\n  -- the desired property passes to the union.\n  have A :\n    ∃ (t' : _)(_ : t' ⊇ t), MeasurableSet t' ∧ ∀ u, MeasurableSet u → μ (t' ∩ u) = μ (t ∩ u) :=\n    by\n    let w n := to_measurable μ (t ∩ v n)\n    have hw : ∀ n, μ (w n) < ∞ := by\n      intro n\n      simp_rw [w, measure_to_measurable]\n      exact (h'v n).lt_top\n    set t' := ⋃ n, to_measurable μ (t ∩ disjointed w n) with ht'\n    have tt' : t ⊆ t' :=\n      calc\n        t ⊆ ⋃ n, t ∩ disjointed w n :=\n          by\n          rw [← inter_Union, unionᵢ_disjointed, inter_Union]\n          intro x hx\n          rcases mem_Union.1 (hv hx) with ⟨n, hn⟩\n          refine' mem_Union.2 ⟨n, _⟩\n          have : x ∈ t ∩ v n := ⟨hx, hn⟩\n          exact ⟨hx, subset_to_measurable μ _ this⟩\n        _ ⊆ ⋃ n, to_measurable μ (t ∩ disjointed w n) :=\n          Union_mono fun n => subset_to_measurable _ _\n        \n    refine' ⟨t', tt', MeasurableSet.unionᵢ fun n => measurable_set_to_measurable μ _, fun u hu => _⟩\n    apply le_antisymm _ (measure_mono (inter_subset_inter tt' subset.rfl))\n    calc\n      μ (t' ∩ u) ≤ ∑' n, μ (to_measurable μ (t ∩ disjointed w n) ∩ u) :=\n        by\n        rw [ht', Union_inter]\n        exact measure_Union_le _\n      _ = ∑' n, μ (t ∩ disjointed w n ∩ u) := by\n        congr 1\n        ext1 n\n        apply measure_to_measurable_inter hu\n        apply ne_of_lt\n        calc\n          μ (t ∩ disjointed w n) ≤ μ (t ∩ w n) :=\n            measure_mono (inter_subset_inter_right _ (disjointed_le w n))\n          _ ≤ μ (w n) := (measure_mono (inter_subset_right _ _))\n          _ < ∞ := hw n\n          \n      _ = ∑' n, μ.restrict (t ∩ u) (disjointed w n) :=\n        by\n        congr 1\n        ext1 n\n        rw [restrict_apply, inter_comm t _, inter_assoc]\n        apply MeasurableSet.disjointed fun n => _\n        exact measurable_set_to_measurable _ _\n      _ = μ.restrict (t ∩ u) (⋃ n, disjointed w n) :=\n        by\n        rw [measure_Union]\n        · exact disjoint_disjointed _\n        · intro i\n          apply MeasurableSet.disjointed fun n => _\n          exact measurable_set_to_measurable _ _\n      _ ≤ μ.restrict (t ∩ u) univ := (measure_mono (subset_univ _))\n      _ = μ (t ∩ u) := by rw [restrict_apply MeasurableSet.univ, univ_inter]\n      \n  -- thanks to the definition of `to_measurable`, the previous property will also be shared\n  -- by `to_measurable μ t`, which is enough to conclude the proof.\n  rw [to_measurable]\n  split_ifs with ht\n  · apply measure_congr\n    exact ae_eq_set_inter ht.some_spec.snd.2 (ae_eq_refl _)\n  · exact A.some_spec.snd.2 s hs\n#align measure_theory.measure.measure_to_measurable_inter_of_cover MeasureTheory.Measure.measure_toMeasurable_inter_of_cover\n\ntheorem restrict_toMeasurable_of_cover {s : Set α} {v : ℕ → Set α} (hv : s ⊆ ⋃ n, v n)\n    (h'v : ∀ n, μ (s ∩ v n) ≠ ∞) : μ.restrict (toMeasurable μ s) = μ.restrict s :=\n  ext fun t ht => by\n    simp only [restrict_apply ht, inter_comm t, measure_to_measurable_inter_of_cover ht hv h'v]\n#align measure_theory.measure.restrict_to_measurable_of_cover MeasureTheory.Measure.restrict_toMeasurable_of_cover\n\n/-- The measurable superset `to_measurable μ t` of `t` (which has the same measure as `t`)\nsatisfies, for any measurable set `s`, the equality `μ (to_measurable μ t ∩ s) = μ (t ∩ s)`.\nThis only holds when `μ` is σ-finite. For a version without this assumption (but requiring\nthat `t` has finite measure), see `measure_to_measurable_inter`. -/\ntheorem measure_toMeasurable_inter_of_sigmaFinite [SigmaFinite μ] {s : Set α} (hs : MeasurableSet s)\n    (t : Set α) : μ (toMeasurable μ t ∩ s) = μ (t ∩ s) :=\n  by\n  have : t ⊆ ⋃ n, spanning_sets μ n :=\n    by\n    rw [Union_spanning_sets]\n    exact subset_univ _\n  apply measure_to_measurable_inter_of_cover hs this fun n => ne_of_lt _\n  calc\n    μ (t ∩ spanning_sets μ n) ≤ μ (spanning_sets μ n) := measure_mono (inter_subset_right _ _)\n    _ < ∞ := measure_spanning_sets_lt_top μ n\n    \n#align measure_theory.measure.measure_to_measurable_inter_of_sigma_finite MeasureTheory.Measure.measure_toMeasurable_inter_of_sigmaFinite\n\n@[simp]\ntheorem restrict_toMeasurable_of_sigmaFinite [SigmaFinite μ] (s : Set α) :\n    μ.restrict (toMeasurable μ s) = μ.restrict s :=\n  ext fun t ht => by\n    simp only [restrict_apply ht, inter_comm t, measure_to_measurable_inter_of_sigma_finite ht]\n#align measure_theory.measure.restrict_to_measurable_of_sigma_finite MeasureTheory.Measure.restrict_toMeasurable_of_sigmaFinite\n\nnamespace FiniteSpanningSetsIn\n\nvariable {C D : Set (Set α)}\n\n/-- If `μ` has finite spanning sets in `C` and `C ∩ {s | μ s < ∞} ⊆ D` then `μ` has finite spanning\nsets in `D`. -/\nprotected def mono' (h : μ.FiniteSpanningSetsIn C) (hC : C ∩ { s | μ s < ∞ } ⊆ D) :\n    μ.FiniteSpanningSetsIn D :=\n  ⟨h.Set, fun i => hC ⟨h.set_mem i, h.Finite i⟩, h.Finite, h.spanning⟩\n#align measure_theory.measure.finite_spanning_sets_in.mono' MeasureTheory.Measure.FiniteSpanningSetsIn.mono'\n\n/-- If `μ` has finite spanning sets in `C` and `C ⊆ D` then `μ` has finite spanning sets in `D`. -/\nprotected def mono (h : μ.FiniteSpanningSetsIn C) (hC : C ⊆ D) : μ.FiniteSpanningSetsIn D :=\n  h.mono' fun s hs => hC hs.1\n#align measure_theory.measure.finite_spanning_sets_in.mono MeasureTheory.Measure.FiniteSpanningSetsIn.mono\n\n/-- If `μ` has finite spanning sets in the collection of measurable sets `C`, then `μ` is σ-finite.\n-/\nprotected theorem sigmaFinite (h : μ.FiniteSpanningSetsIn C) : SigmaFinite μ :=\n  ⟨⟨h.mono <| subset_univ C⟩⟩\n#align measure_theory.measure.finite_spanning_sets_in.sigma_finite MeasureTheory.Measure.FiniteSpanningSetsIn.sigmaFinite\n\n/-- An extensionality for measures. It is `ext_of_generate_from_of_Union` formulated in terms of\n`finite_spanning_sets_in`. -/\nprotected theorem ext {ν : Measure α} {C : Set (Set α)} (hA : ‹_› = generateFrom C)\n    (hC : IsPiSystem C) (h : μ.FiniteSpanningSetsIn C) (h_eq : ∀ s ∈ C, μ s = ν s) : μ = ν :=\n  ext_of_generateFrom_of_unionᵢ C _ hA hC h.spanning h.set_mem (fun i => (h.Finite i).Ne) h_eq\n#align measure_theory.measure.finite_spanning_sets_in.ext MeasureTheory.Measure.FiniteSpanningSetsIn.ext\n\nprotected theorem isCountablySpanning (h : μ.FiniteSpanningSetsIn C) : IsCountablySpanning C :=\n  ⟨h.Set, h.set_mem, h.spanning⟩\n#align measure_theory.measure.finite_spanning_sets_in.is_countably_spanning MeasureTheory.Measure.FiniteSpanningSetsIn.isCountablySpanning\n\nend FiniteSpanningSetsIn\n\ntheorem sigmaFiniteOfCountable {S : Set (Set α)} (hc : S.Countable) (hμ : ∀ s ∈ S, μ s < ∞)\n    (hU : ⋃₀ S = univ) : SigmaFinite μ :=\n  by\n  obtain ⟨s, hμ, hs⟩ : ∃ s : ℕ → Set α, (∀ n, μ (s n) < ∞) ∧ (⋃ n, s n) = univ\n  exact (@exists_seq_cover_iff_countable _ (fun x => μ x < ⊤) ⟨∅, by simp⟩).2 ⟨S, hc, hμ, hU⟩\n  exact ⟨⟨⟨fun n => s n, fun n => trivial, hμ, hs⟩⟩⟩\n#align measure_theory.measure.sigma_finite_of_countable MeasureTheory.Measure.sigmaFiniteOfCountable\n\n/-- Given measures `μ`, `ν` where `ν ≤ μ`, `finite_spanning_sets_in.of_le` provides the induced\n`finite_spanning_set` with respect to `ν` from a `finite_spanning_set` with respect to `μ`. -/\ndef FiniteSpanningSetsIn.ofLe (h : ν ≤ μ) {C : Set (Set α)} (S : μ.FiniteSpanningSetsIn C) :\n    ν.FiniteSpanningSetsIn C where\n  Set := S.Set\n  set_mem := S.set_mem\n  Finite n := lt_of_le_of_lt (le_iff'.1 h _) (S.Finite n)\n  spanning := S.spanning\n#align measure_theory.measure.finite_spanning_sets_in.of_le MeasureTheory.Measure.FiniteSpanningSetsIn.ofLe\n\ntheorem sigmaFiniteOfLe (μ : Measure α) [hs : SigmaFinite μ] (h : ν ≤ μ) : SigmaFinite ν :=\n  ⟨hs.out.map <| FiniteSpanningSetsIn.ofLe h⟩\n#align measure_theory.measure.sigma_finite_of_le MeasureTheory.Measure.sigmaFiniteOfLe\n\nend Measure\n\n/-- Every finite measure is σ-finite. -/\ninstance (priority := 100) IsFiniteMeasure.toSigmaFinite {m0 : MeasurableSpace α} (μ : Measure α)\n    [IsFiniteMeasure μ] : SigmaFinite μ :=\n  ⟨⟨⟨fun _ => univ, fun _ => trivial, fun _ => measure_lt_top μ _, unionᵢ_const _⟩⟩⟩\n#align measure_theory.is_finite_measure.to_sigma_finite MeasureTheory.IsFiniteMeasure.toSigmaFinite\n\ntheorem sigmaFinite_bot_iff (μ : @Measure α ⊥) : SigmaFinite μ ↔ IsFiniteMeasure μ :=\n  by\n  refine'\n    ⟨fun h => ⟨_⟩, fun h => by\n      haveI := h\n      infer_instance⟩\n  haveI : sigma_finite μ := h\n  let s := spanning_sets μ\n  have hs_univ : (⋃ i, s i) = Set.univ := Union_spanning_sets μ\n  have hs_meas : ∀ i, measurable_set[⊥] (s i) := measurable_spanning_sets μ\n  simp_rw [MeasurableSpace.measurableSet_bot_iff] at hs_meas\n  by_cases h_univ_empty : Set.univ = ∅\n  · rw [h_univ_empty, measure_empty]\n    exact ennreal.zero_ne_top.lt_top\n  obtain ⟨i, hsi⟩ : ∃ i, s i = Set.univ :=\n    by\n    by_contra h_not_univ\n    push_neg  at h_not_univ\n    have h_empty : ∀ i, s i = ∅ := by simpa [h_not_univ] using hs_meas\n    simp [h_empty] at hs_univ\n    exact h_univ_empty hs_univ.symm\n  rw [← hsi]\n  exact measure_spanning_sets_lt_top μ i\n#align measure_theory.sigma_finite_bot_iff MeasureTheory.sigmaFinite_bot_iff\n\ninclude m0\n\ninstance Restrict.sigmaFinite (μ : Measure α) [SigmaFinite μ] (s : Set α) :\n    SigmaFinite (μ.restrict s) :=\n  by\n  refine' ⟨⟨⟨spanning_sets μ, fun _ => trivial, fun i => _, Union_spanning_sets μ⟩⟩⟩\n  rw [restrict_apply (measurable_spanning_sets μ i)]\n  exact (measure_mono <| inter_subset_left _ _).trans_lt (measure_spanning_sets_lt_top μ i)\n#align measure_theory.restrict.sigma_finite MeasureTheory.Restrict.sigmaFinite\n\ninstance Sum.sigmaFinite {ι} [Finite ι] (μ : ι → Measure α) [∀ i, SigmaFinite (μ i)] :\n    SigmaFinite (Sum μ) := by\n  cases nonempty_fintype ι\n  have : ∀ n, MeasurableSet (⋂ i : ι, spanning_sets (μ i) n) := fun n =>\n    MeasurableSet.interᵢ fun i => measurable_spanning_sets (μ i) n\n  refine' ⟨⟨⟨fun n => ⋂ i, spanning_sets (μ i) n, fun _ => trivial, fun n => _, _⟩⟩⟩\n  · rw [sum_apply _ (this n), tsum_fintype, ENNReal.sum_lt_top_iff]\n    rintro i -\n    exact (measure_mono <| Inter_subset _ i).trans_lt (measure_spanning_sets_lt_top (μ i) n)\n  · rw [Union_Inter_of_monotone]\n    simp_rw [Union_spanning_sets, Inter_univ]\n    exact fun i => monotone_spanning_sets (μ i)\n#align measure_theory.sum.sigma_finite MeasureTheory.Sum.sigmaFinite\n\ninstance Add.sigmaFinite (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν] : SigmaFinite (μ + ν) :=\n  by\n  rw [← sum_cond]\n  refine' @sum.sigma_finite _ _ _ _ _ (Bool.rec _ _) <;> simpa\n#align measure_theory.add.sigma_finite MeasureTheory.Add.sigmaFinite\n\ntheorem SigmaFinite.ofMap (μ : Measure α) {f : α → β} (hf : AeMeasurable f μ)\n    (h : SigmaFinite (μ.map f)) : SigmaFinite μ :=\n  ⟨⟨⟨fun n => f ⁻¹' spanningSets (μ.map f) n, fun n => trivial, fun n => by\n        simp only [← map_apply_of_ae_measurable hf, measurable_spanning_sets,\n          measure_spanning_sets_lt_top],\n        by rw [← preimage_Union, Union_spanning_sets, preimage_univ]⟩⟩⟩\n#align measure_theory.sigma_finite.of_map MeasureTheory.SigmaFinite.ofMap\n\ntheorem MeasurableEquiv.sigmaFiniteMap {μ : Measure α} (f : α ≃ᵐ β) (h : SigmaFinite μ) :\n    SigmaFinite (μ.map f) :=\n  by\n  refine' sigma_finite.of_map _ f.symm.measurable.ae_measurable _\n  rwa [map_map f.symm.measurable f.measurable, f.symm_comp_self, measure.map_id]\n#align measurable_equiv.sigma_finite_map MeasurableEquiv.sigmaFiniteMap\n\n/-- Similar to `ae_of_forall_measure_lt_top_ae_restrict`, but where you additionally get the\n  hypothesis that another σ-finite measure has finite values on `s`. -/\ntheorem ae_of_forall_measure_lt_top_ae_restrict' {μ : Measure α} (ν : Measure α) [SigmaFinite μ]\n    [SigmaFinite ν] (P : α → Prop)\n    (h : ∀ s, MeasurableSet s → μ s < ∞ → ν s < ∞ → ∀ᵐ x ∂μ.restrict s, P x) : ∀ᵐ x ∂μ, P x :=\n  by\n  have : ∀ n, ∀ᵐ x ∂μ, x ∈ spanning_sets (μ + ν) n → P x :=\n    by\n    intro n\n    have := h (spanning_sets (μ + ν) n) (measurable_spanning_sets _ _) _ _\n    exacts[(ae_restrict_iff' (measurable_spanning_sets _ _)).mp this,\n      (self_le_add_right _ _).trans_lt (measure_spanning_sets_lt_top (μ + ν) _),\n      (self_le_add_left _ _).trans_lt (measure_spanning_sets_lt_top (μ + ν) _)]\n  filter_upwards [ae_all_iff.2 this]with _ hx using hx _ (mem_spanning_sets_index _ _)\n#align measure_theory.ae_of_forall_measure_lt_top_ae_restrict' MeasureTheory.ae_of_forall_measure_lt_top_ae_restrict'\n\n/-- To prove something for almost all `x` w.r.t. a σ-finite measure, it is sufficient to show that\n  this holds almost everywhere in sets where the measure has finite value. -/\ntheorem ae_of_forall_measure_lt_top_ae_restrict {μ : Measure α} [SigmaFinite μ] (P : α → Prop)\n    (h : ∀ s, MeasurableSet s → μ s < ∞ → ∀ᵐ x ∂μ.restrict s, P x) : ∀ᵐ x ∂μ, P x :=\n  ae_of_forall_measure_lt_top_ae_restrict' μ P fun s hs h2s _ => h s hs h2s\n#align measure_theory.ae_of_forall_measure_lt_top_ae_restrict MeasureTheory.ae_of_forall_measure_lt_top_ae_restrict\n\n/-- A measure is called locally finite if it is finite in some neighborhood of each point. -/\nclass IsLocallyFiniteMeasure [TopologicalSpace α] (μ : Measure α) : Prop where\n  finiteAtNhds : ∀ x, μ.FiniteAtFilter (𝓝 x)\n#align measure_theory.is_locally_finite_measure MeasureTheory.IsLocallyFiniteMeasure\n\n-- see Note [lower instance priority]\ninstance (priority := 100) IsFiniteMeasure.toIsLocallyFiniteMeasure [TopologicalSpace α]\n    (μ : Measure α) [IsFiniteMeasure μ] : IsLocallyFiniteMeasure μ :=\n  ⟨fun x => finiteAtFilterOfFinite _ _⟩\n#align measure_theory.is_finite_measure.to_is_locally_finite_measure MeasureTheory.IsFiniteMeasure.toIsLocallyFiniteMeasure\n\ntheorem Measure.finiteAtNhds [TopologicalSpace α] (μ : Measure α) [IsLocallyFiniteMeasure μ]\n    (x : α) : μ.FiniteAtFilter (𝓝 x) :=\n  IsLocallyFiniteMeasure.finiteAtNhds x\n#align measure_theory.measure.finite_at_nhds MeasureTheory.Measure.finiteAtNhds\n\ntheorem Measure.smulFinite (μ : Measure α) [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) :\n    IsFiniteMeasure (c • μ) := by\n  lift c to ℝ≥0 using hc\n  exact MeasureTheory.isFiniteMeasureSmulNnreal\n#align measure_theory.measure.smul_finite MeasureTheory.Measure.smulFinite\n\ntheorem Measure.exists_isOpen_measure_lt_top [TopologicalSpace α] (μ : Measure α)\n    [IsLocallyFiniteMeasure μ] (x : α) : ∃ s : Set α, x ∈ s ∧ IsOpen s ∧ μ s < ∞ := by\n  simpa only [exists_prop, and_assoc] using\n    (μ.finite_at_nhds x).exists_mem_basis (nhds_basis_opens x)\n#align measure_theory.measure.exists_is_open_measure_lt_top MeasureTheory.Measure.exists_isOpen_measure_lt_top\n\ninstance isLocallyFiniteMeasureSmulNnreal [TopologicalSpace α] (μ : Measure α)\n    [IsLocallyFiniteMeasure μ] (c : ℝ≥0) : IsLocallyFiniteMeasure (c • μ) :=\n  by\n  refine' ⟨fun x => _⟩\n  rcases μ.exists_is_open_measure_lt_top x with ⟨o, xo, o_open, μo⟩\n  refine' ⟨o, o_open.mem_nhds xo, _⟩\n  apply ENNReal.mul_lt_top _ μo.ne\n  simp only [RingHom.toMonoidHom_eq_coe, [anonymous], ENNReal.coe_ne_top, ENNReal.coe_ofNNRealHom,\n    Ne.def, not_false_iff]\n#align measure_theory.is_locally_finite_measure_smul_nnreal MeasureTheory.isLocallyFiniteMeasureSmulNnreal\n\nprotected theorem Measure.isTopologicalBasis_isOpen_lt_top [TopologicalSpace α] (μ : Measure α)\n    [IsLocallyFiniteMeasure μ] : TopologicalSpace.IsTopologicalBasis { s | IsOpen s ∧ μ s < ∞ } :=\n  by\n  refine' TopologicalSpace.isTopologicalBasis_of_open_of_nhds (fun s hs => hs.1) _\n  intro x s xs hs\n  rcases μ.exists_is_open_measure_lt_top x with ⟨v, xv, hv, μv⟩\n  refine' ⟨v ∩ s, ⟨hv.inter hs, lt_of_le_of_lt _ μv⟩, ⟨xv, xs⟩, inter_subset_right _ _⟩\n  exact measure_mono (inter_subset_left _ _)\n#align measure_theory.measure.is_topological_basis_is_open_lt_top MeasureTheory.Measure.isTopologicalBasis_isOpen_lt_top\n\n/-- A measure `μ` is finite on compacts if any compact set `K` satisfies `μ K < ∞`. -/\n@[protect_proj]\nclass IsFiniteMeasureOnCompacts [TopologicalSpace α] (μ : Measure α) : Prop where\n  lt_top_of_isCompact : ∀ ⦃K : Set α⦄, IsCompact K → μ K < ∞\n#align measure_theory.is_finite_measure_on_compacts MeasureTheory.IsFiniteMeasureOnCompacts\n\n/-- A compact subset has finite measure for a measure which is finite on compacts. -/\ntheorem IsCompact.measure_lt_top [TopologicalSpace α] {μ : Measure α} [IsFiniteMeasureOnCompacts μ]\n    ⦃K : Set α⦄ (hK : IsCompact K) : μ K < ∞ :=\n  IsFiniteMeasureOnCompacts.lt_top_of_isCompact hK\n#align is_compact.measure_lt_top IsCompact.measure_lt_top\n\n/-- A bounded subset has finite measure for a measure which is finite on compact sets, in a\nproper space. -/\ntheorem Metric.Bounded.measure_lt_top [PseudoMetricSpace α] [ProperSpace α] {μ : Measure α}\n    [IsFiniteMeasureOnCompacts μ] ⦃s : Set α⦄ (hs : Metric.Bounded s) : μ s < ∞ :=\n  calc\n    μ s ≤ μ (closure s) := measure_mono subset_closure\n    _ < ∞ := (Metric.isCompact_of_isClosed_bounded isClosed_closure hs.closure).measure_lt_top\n    \n#align metric.bounded.measure_lt_top Metric.Bounded.measure_lt_top\n\ntheorem measure_closedBall_lt_top [PseudoMetricSpace α] [ProperSpace α] {μ : Measure α}\n    [IsFiniteMeasureOnCompacts μ] {x : α} {r : ℝ} : μ (Metric.closedBall x r) < ∞ :=\n  Metric.bounded_closedBall.measure_lt_top\n#align measure_theory.measure_closed_ball_lt_top MeasureTheory.measure_closedBall_lt_top\n\ntheorem measure_ball_lt_top [PseudoMetricSpace α] [ProperSpace α] {μ : Measure α}\n    [IsFiniteMeasureOnCompacts μ] {x : α} {r : ℝ} : μ (Metric.ball x r) < ∞ :=\n  Metric.bounded_ball.measure_lt_top\n#align measure_theory.measure_ball_lt_top MeasureTheory.measure_ball_lt_top\n\nprotected theorem IsFiniteMeasureOnCompacts.smul [TopologicalSpace α] (μ : Measure α)\n    [IsFiniteMeasureOnCompacts μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : IsFiniteMeasureOnCompacts (c • μ) :=\n  ⟨fun K hK => ENNReal.mul_lt_top hc hK.measure_lt_top.Ne⟩\n#align measure_theory.is_finite_measure_on_compacts.smul MeasureTheory.IsFiniteMeasureOnCompacts.smul\n\n/-- Note this cannot be an instance because it would form a typeclass loop with\n`is_finite_measure_on_compacts_of_is_locally_finite_measure`. -/\ntheorem CompactSpace.isFiniteMeasure [TopologicalSpace α] [CompactSpace α]\n    [IsFiniteMeasureOnCompacts μ] : IsFiniteMeasure μ :=\n  ⟨IsFiniteMeasureOnCompacts.lt_top_of_isCompact isCompact_univ⟩\n#align measure_theory.compact_space.is_finite_measure MeasureTheory.CompactSpace.isFiniteMeasure\n\nomit m0\n\n-- see Note [lower instance priority]\ninstance (priority := 100) sigmaFiniteOfLocallyFinite [TopologicalSpace α]\n    [SecondCountableTopology α] [IsLocallyFiniteMeasure μ] : SigmaFinite μ :=\n  by\n  choose s hsx hsμ using μ.finite_at_nhds\n  rcases TopologicalSpace.countable_cover_nhds hsx with ⟨t, htc, htU⟩\n  refine' measure.sigma_finite_of_countable (htc.image s) (ball_image_iff.2 fun x hx => hsμ x) _\n  rwa [sUnion_image]\n#align measure_theory.sigma_finite_of_locally_finite MeasureTheory.sigmaFiniteOfLocallyFinite\n\n/-- A measure which is finite on compact sets in a locally compact space is locally finite.\nNot registered as an instance to avoid a loop with the other direction. -/\ntheorem isLocallyFiniteMeasureOfIsFiniteMeasureOnCompacts [TopologicalSpace α]\n    [LocallyCompactSpace α] [IsFiniteMeasureOnCompacts μ] : IsLocallyFiniteMeasure μ :=\n  ⟨by\n    intro x\n    rcases exists_compact_mem_nhds x with ⟨K, K_compact, K_mem⟩\n    exact ⟨K, K_mem, K_compact.measure_lt_top⟩⟩\n#align measure_theory.is_locally_finite_measure_of_is_finite_measure_on_compacts MeasureTheory.isLocallyFiniteMeasureOfIsFiniteMeasureOnCompacts\n\ntheorem exists_pos_measure_of_cover [Countable ι] {U : ι → Set α} (hU : (⋃ i, U i) = univ)\n    (hμ : μ ≠ 0) : ∃ i, 0 < μ (U i) := by\n  contrapose! hμ with H\n  rw [← measure_univ_eq_zero, ← hU]\n  exact measure_Union_null fun i => nonpos_iff_eq_zero.1 (H i)\n#align measure_theory.exists_pos_measure_of_cover MeasureTheory.exists_pos_measure_of_cover\n\ntheorem exists_pos_preimage_ball [PseudoMetricSpace δ] (f : α → δ) (x : δ) (hμ : μ ≠ 0) :\n    ∃ n : ℕ, 0 < μ (f ⁻¹' Metric.ball x n) :=\n  exists_pos_measure_of_cover (by rw [← preimage_Union, Metric.unionᵢ_ball_nat, preimage_univ]) hμ\n#align measure_theory.exists_pos_preimage_ball MeasureTheory.exists_pos_preimage_ball\n\ntheorem exists_pos_ball [PseudoMetricSpace α] (x : α) (hμ : μ ≠ 0) :\n    ∃ n : ℕ, 0 < μ (Metric.ball x n) :=\n  exists_pos_preimage_ball id x hμ\n#align measure_theory.exists_pos_ball MeasureTheory.exists_pos_ball\n\n/-- If a set has zero measure in a neighborhood of each of its points, then it has zero measure\nin a second-countable space. -/\ntheorem null_of_locally_null [TopologicalSpace α] [SecondCountableTopology α] (s : Set α)\n    (hs : ∀ x ∈ s, ∃ u ∈ 𝓝[s] x, μ u = 0) : μ s = 0 :=\n  μ.toOuterMeasure.null_of_locally_null s hs\n#align measure_theory.null_of_locally_null MeasureTheory.null_of_locally_null\n\ntheorem exists_mem_forall_mem_nhdsWithin_pos_measure [TopologicalSpace α]\n    [SecondCountableTopology α] {s : Set α} (hs : μ s ≠ 0) : ∃ x ∈ s, ∀ t ∈ 𝓝[s] x, 0 < μ t :=\n  μ.toOuterMeasure.exists_mem_forall_mem_nhdsWithin_pos hs\n#align measure_theory.exists_mem_forall_mem_nhds_within_pos_measure MeasureTheory.exists_mem_forall_mem_nhdsWithin_pos_measure\n\ntheorem exists_ne_forall_mem_nhds_pos_measure_preimage {β} [TopologicalSpace β] [T1Space β]\n    [SecondCountableTopology β] [Nonempty β] {f : α → β} (h : ∀ b, ∃ᵐ x ∂μ, f x ≠ b) :\n    ∃ a b : β, a ≠ b ∧ (∀ s ∈ 𝓝 a, 0 < μ (f ⁻¹' s)) ∧ ∀ t ∈ 𝓝 b, 0 < μ (f ⁻¹' t) :=\n  by\n  -- We use an `outer_measure` so that the proof works without `measurable f`\n  set m : outer_measure β := outer_measure.map f μ.to_outer_measure\n  replace h : ∀ b : β, m ({b}ᶜ) ≠ 0 := fun b => not_eventually.mpr (h b)\n  inhabit β\n  have : m univ ≠ 0 := ne_bot_of_le_ne_bot (h default) (m.mono' <| subset_univ _)\n  rcases m.exists_mem_forall_mem_nhds_within_pos this with ⟨b, -, hb⟩\n  simp only [nhdsWithin_univ] at hb\n  rcases m.exists_mem_forall_mem_nhds_within_pos (h b) with ⟨a, hab : a ≠ b, ha⟩\n  simp only [is_open_compl_singleton.nhds_within_eq hab] at ha\n  exact ⟨a, b, hab, ha, hb⟩\n#align measure_theory.exists_ne_forall_mem_nhds_pos_measure_preimage MeasureTheory.exists_ne_forall_mem_nhds_pos_measure_preimage\n\n/-- If two finite measures give the same mass to the whole space and coincide on a π-system made\nof measurable sets, then they coincide on all sets in the σ-algebra generated by the π-system. -/\ntheorem ext_on_measurableSpace_of_generate_finite {α} (m₀ : MeasurableSpace α) {μ ν : Measure α}\n    [IsFiniteMeasure μ] (C : Set (Set α)) (hμν : ∀ s ∈ C, μ s = ν s) {m : MeasurableSpace α}\n    (h : m ≤ m₀) (hA : m = MeasurableSpace.generateFrom C) (hC : IsPiSystem C)\n    (h_univ : μ Set.univ = ν Set.univ) {s : Set α} (hs : measurable_set[m] s) : μ s = ν s :=\n  by\n  haveI : is_finite_measure ν := by\n    constructor\n    rw [← h_univ]\n    apply is_finite_measure.measure_univ_lt_top\n  refine' induction_on_inter hA hC (by simp) hμν _ _ hs\n  · intro t h1t h2t\n    have h1t_ : @MeasurableSet α m₀ t := h _ h1t\n    rw [@measure_compl α m₀ μ t h1t_ (@measure_ne_top α m₀ μ _ t),\n      @measure_compl α m₀ ν t h1t_ (@measure_ne_top α m₀ ν _ t), h_univ, h2t]\n  · intro f h1f h2f h3f\n    have h2f_ : ∀ i : ℕ, @MeasurableSet α m₀ (f i) := fun i => h _ (h2f i)\n    have h_Union : @MeasurableSet α m₀ (⋃ i : ℕ, f i) := @MeasurableSet.unionᵢ α ℕ m₀ _ f h2f_\n    simp [measure_Union, h_Union, h1f, h3f, h2f_]\n#align measure_theory.ext_on_measurable_space_of_generate_finite MeasureTheory.ext_on_measurableSpace_of_generate_finite\n\n/-- Two finite measures are equal if they are equal on the π-system generating the σ-algebra\n  (and `univ`). -/\ntheorem ext_of_generate_finite (C : Set (Set α)) (hA : m0 = generateFrom C) (hC : IsPiSystem C)\n    [IsFiniteMeasure μ] (hμν : ∀ s ∈ C, μ s = ν s) (h_univ : μ univ = ν univ) : μ = ν :=\n  Measure.ext fun s hs => ext_on_measurableSpace_of_generate_finite m0 C hμν le_rfl hA hC h_univ hs\n#align measure_theory.ext_of_generate_finite MeasureTheory.ext_of_generate_finite\n\nnamespace Measure\n\nsection disjointed\n\ninclude m0\n\n/-- Given `S : μ.finite_spanning_sets_in {s | measurable_set s}`,\n`finite_spanning_sets_in.disjointed` provides a `finite_spanning_sets_in {s | measurable_set s}`\nsuch that its underlying sets are pairwise disjoint. -/\nprotected def FiniteSpanningSetsIn.disjointed {μ : Measure α}\n    (S : μ.FiniteSpanningSetsIn { s | MeasurableSet s }) :\n    μ.FiniteSpanningSetsIn { s | MeasurableSet s } :=\n  ⟨disjointed S.Set, MeasurableSet.disjointed S.set_mem, fun n =>\n    lt_of_le_of_lt (measure_mono (disjointed_subset S.Set n)) (S.Finite _),\n    S.spanning ▸ unionᵢ_disjointed⟩\n#align measure_theory.measure.finite_spanning_sets_in.disjointed MeasureTheory.Measure.FiniteSpanningSetsIn.disjointed\n\ntheorem FiniteSpanningSetsIn.disjointed_set_eq {μ : Measure α}\n    (S : μ.FiniteSpanningSetsIn { s | MeasurableSet s }) : S.disjointed.Set = disjointed S.Set :=\n  rfl\n#align measure_theory.measure.finite_spanning_sets_in.disjointed_set_eq MeasureTheory.Measure.FiniteSpanningSetsIn.disjointed_set_eq\n\ntheorem exists_eq_disjoint_finiteSpanningSetsIn (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν] :\n    ∃ (S : μ.FiniteSpanningSetsIn { s | MeasurableSet s })(T :\n      ν.FiniteSpanningSetsIn { s | MeasurableSet s }),\n      S.Set = T.Set ∧ Pairwise (Disjoint on S.Set) :=\n  let S := (μ + ν).toFiniteSpanningSetsIn.disjointed\n  ⟨S.of_le (Measure.le_add_right le_rfl), S.of_le (Measure.le_add_left le_rfl), rfl,\n    disjoint_disjointed _⟩\n#align measure_theory.measure.exists_eq_disjoint_finite_spanning_sets_in MeasureTheory.Measure.exists_eq_disjoint_finiteSpanningSetsIn\n\nend disjointed\n\nnamespace FiniteAtFilter\n\nvariable {f g : Filter α}\n\ntheorem filterMono (h : f ≤ g) : μ.FiniteAtFilter g → μ.FiniteAtFilter f := fun ⟨s, hs, hμ⟩ =>\n  ⟨s, h hs, hμ⟩\n#align measure_theory.measure.finite_at_filter.filter_mono MeasureTheory.Measure.FiniteAtFilter.filterMono\n\ntheorem infOfLeft (h : μ.FiniteAtFilter f) : μ.FiniteAtFilter (f ⊓ g) :=\n  h.filter_mono inf_le_left\n#align measure_theory.measure.finite_at_filter.inf_of_left MeasureTheory.Measure.FiniteAtFilter.infOfLeft\n\ntheorem infOfRight (h : μ.FiniteAtFilter g) : μ.FiniteAtFilter (f ⊓ g) :=\n  h.filter_mono inf_le_right\n#align measure_theory.measure.finite_at_filter.inf_of_right MeasureTheory.Measure.FiniteAtFilter.infOfRight\n\n@[simp]\ntheorem inf_ae_iff : μ.FiniteAtFilter (f ⊓ μ.ae) ↔ μ.FiniteAtFilter f :=\n  by\n  refine' ⟨_, fun h => h.filter_mono inf_le_left⟩\n  rintro ⟨s, ⟨t, ht, u, hu, rfl⟩, hμ⟩\n  suffices : μ t ≤ μ (t ∩ u); exact ⟨t, ht, this.trans_lt hμ⟩\n  exact measure_mono_ae (mem_of_superset hu fun x hu ht => ⟨ht, hu⟩)\n#align measure_theory.measure.finite_at_filter.inf_ae_iff MeasureTheory.Measure.FiniteAtFilter.inf_ae_iff\n\nalias inf_ae_iff ↔ of_inf_ae _\n#align measure_theory.measure.finite_at_filter.of_inf_ae MeasureTheory.Measure.FiniteAtFilter.ofInfAe\n\ntheorem filterMonoAe (h : f ⊓ μ.ae ≤ g) (hg : μ.FiniteAtFilter g) : μ.FiniteAtFilter f :=\n  inf_ae_iff.1 (hg.filter_mono h)\n#align measure_theory.measure.finite_at_filter.filter_mono_ae MeasureTheory.Measure.FiniteAtFilter.filterMonoAe\n\nprotected theorem measureMono (h : μ ≤ ν) : ν.FiniteAtFilter f → μ.FiniteAtFilter f :=\n  fun ⟨s, hs, hν⟩ => ⟨s, hs, (Measure.le_iff'.1 h s).trans_lt hν⟩\n#align measure_theory.measure.finite_at_filter.measure_mono MeasureTheory.Measure.FiniteAtFilter.measureMono\n\n@[mono]\nprotected theorem mono (hf : f ≤ g) (hμ : μ ≤ ν) : ν.FiniteAtFilter g → μ.FiniteAtFilter f :=\n  fun h => (h.filter_mono hf).measure_mono hμ\n#align measure_theory.measure.finite_at_filter.mono MeasureTheory.Measure.FiniteAtFilter.mono\n\nprotected theorem eventually (h : μ.FiniteAtFilter f) : ∀ᶠ s in f.smallSets, μ s < ∞ :=\n  (eventually_small_sets' fun s t hst ht => (measure_mono hst).trans_lt ht).2 h\n#align measure_theory.measure.finite_at_filter.eventually MeasureTheory.Measure.FiniteAtFilter.eventually\n\ntheorem filterSup : μ.FiniteAtFilter f → μ.FiniteAtFilter g → μ.FiniteAtFilter (f ⊔ g) :=\n  fun ⟨s, hsf, hsμ⟩ ⟨t, htg, htμ⟩ =>\n  ⟨s ∪ t, union_mem_sup hsf htg, (measure_union_le s t).trans_lt (ENNReal.add_lt_top.2 ⟨hsμ, htμ⟩)⟩\n#align measure_theory.measure.finite_at_filter.filter_sup MeasureTheory.Measure.FiniteAtFilter.filterSup\n\nend FiniteAtFilter\n\ntheorem finiteAtNhdsWithin [TopologicalSpace α] {m0 : MeasurableSpace α} (μ : Measure α)\n    [IsLocallyFiniteMeasure μ] (x : α) (s : Set α) : μ.FiniteAtFilter (𝓝[s] x) :=\n  (finiteAtNhds μ x).inf_of_left\n#align measure_theory.measure.finite_at_nhds_within MeasureTheory.Measure.finiteAtNhdsWithin\n\n@[simp]\ntheorem finite_at_principal : μ.FiniteAtFilter (𝓟 s) ↔ μ s < ∞ :=\n  ⟨fun ⟨t, ht, hμ⟩ => (measure_mono ht).trans_lt hμ, fun h => ⟨s, mem_principal_self s, h⟩⟩\n#align measure_theory.measure.finite_at_principal MeasureTheory.Measure.finite_at_principal\n\ntheorem isLocallyFiniteMeasureOfLe [TopologicalSpace α] {m : MeasurableSpace α} {μ ν : Measure α}\n    [H : IsLocallyFiniteMeasure μ] (h : ν ≤ μ) : IsLocallyFiniteMeasure ν :=\n  let F := H.finiteAtNhds\n  ⟨fun x => (F x).measure_mono h⟩\n#align measure_theory.measure.is_locally_finite_measure_of_le MeasureTheory.Measure.isLocallyFiniteMeasureOfLe\n\nend Measure\n\nend MeasureTheory\n\nopen MeasureTheory MeasureTheory.Measure\n\nnamespace MeasurableEmbedding\n\nvariable {m0 : MeasurableSpace α} {m1 : MeasurableSpace β} {f : α → β} (hf : MeasurableEmbedding f)\n\ninclude hf\n\ntheorem map_apply (μ : Measure α) (s : Set β) : μ.map f s = μ (f ⁻¹' s) :=\n  by\n  refine' le_antisymm _ (le_map_apply hf.measurable.ae_measurable s)\n  set t := f '' to_measurable μ (f ⁻¹' s) ∪ range fᶜ\n  have htm : MeasurableSet t :=\n    (hf.measurable_set_image.2 <| measurable_set_to_measurable _ _).union\n      hf.measurable_set_range.compl\n  have hst : s ⊆ t :=\n    by\n    rw [subset_union_compl_iff_inter_subset, ← image_preimage_eq_inter_range]\n    exact image_subset _ (subset_to_measurable _ _)\n  have hft : f ⁻¹' t = to_measurable μ (f ⁻¹' s) := by\n    rw [preimage_union, preimage_compl, preimage_range, compl_univ, union_empty,\n      hf.injective.preimage_image]\n  calc\n    μ.map f s ≤ μ.map f t := measure_mono hst\n    _ = μ (f ⁻¹' s) := by rw [map_apply hf.measurable htm, hft, measure_to_measurable]\n    \n#align measurable_embedding.map_apply MeasurableEmbedding.map_apply\n\ntheorem map_comap (μ : Measure β) : (comap f μ).map f = μ.restrict (range f) :=\n  by\n  ext1 t ht\n  rw [hf.map_apply, comap_apply f hf.injective hf.measurable_set_image' _ (hf.measurable ht),\n    image_preimage_eq_inter_range, restrict_apply ht]\n#align measurable_embedding.map_comap MeasurableEmbedding.map_comap\n\ntheorem comap_apply (μ : Measure β) (s : Set α) : comap f μ s = μ (f '' s) :=\n  calc\n    comap f μ s = comap f μ (f ⁻¹' (f '' s)) := by rw [hf.injective.preimage_image]\n    _ = (comap f μ).map f (f '' s) := (hf.map_apply _ _).symm\n    _ = μ (f '' s) := by\n      rw [hf.map_comap, restrict_apply' hf.measurable_set_range,\n        inter_eq_self_of_subset_left (image_subset_range _ _)]\n    \n#align measurable_embedding.comap_apply MeasurableEmbedding.comap_apply\n\ntheorem ae_map_iff {p : β → Prop} {μ : Measure α} : (∀ᵐ x ∂μ.map f, p x) ↔ ∀ᵐ x ∂μ, p (f x) := by\n  simp only [ae_iff, hf.map_apply, preimage_set_of_eq]\n#align measurable_embedding.ae_map_iff MeasurableEmbedding.ae_map_iff\n\ntheorem restrict_map (μ : Measure α) (s : Set β) :\n    (μ.map f).restrict s = (μ.restrict <| f ⁻¹' s).map f :=\n  Measure.ext fun t ht => by simp [hf.map_apply, ht, hf.measurable ht]\n#align measurable_embedding.restrict_map MeasurableEmbedding.restrict_map\n\nprotected theorem comap_preimage (μ : Measure β) {s : Set β} (hs : MeasurableSet s) :\n    μ.comap f (f ⁻¹' s) = μ (s ∩ range f) :=\n  comap_preimage _ _ hf.Injective hf.Measurable\n    (fun t ht => (hf.measurableSet_image' ht).NullMeasurableSet) hs\n#align measurable_embedding.comap_preimage MeasurableEmbedding.comap_preimage\n\nend MeasurableEmbedding\n\nsection Subtype\n\ntheorem comap_subtype_coe_apply {m0 : MeasurableSpace α} {s : Set α} (hs : MeasurableSet s)\n    (μ : Measure α) (t : Set s) : comap coe μ t = μ (coe '' t) :=\n  (MeasurableEmbedding.subtype_coe hs).comap_apply _ _\n#align comap_subtype_coe_apply comap_subtype_coe_apply\n\ntheorem map_comap_subtype_coe {m0 : MeasurableSpace α} {s : Set α} (hs : MeasurableSet s)\n    (μ : Measure α) : (comap coe μ).map (coe : s → α) = μ.restrict s := by\n  rw [(MeasurableEmbedding.subtype_coe hs).map_comap, Subtype.range_coe]\n#align map_comap_subtype_coe map_comap_subtype_coe\n\ntheorem ae_restrict_iff_subtype {m0 : MeasurableSpace α} {μ : Measure α} {s : Set α}\n    (hs : MeasurableSet s) {p : α → Prop} :\n    (∀ᵐ x ∂μ.restrict s, p x) ↔ ∀ᵐ x ∂comap (coe : s → α) μ, p ↑x := by\n  rw [← map_comap_subtype_coe hs, (MeasurableEmbedding.subtype_coe hs).ae_map_iff]\n#align ae_restrict_iff_subtype ae_restrict_iff_subtype\n\nvariable [MeasureSpace α] {s t : Set α}\n\n/-!\n### Volume on `s : set α`\n-/\n\n\ninstance SetCoe.measureSpace (s : Set α) : MeasureSpace s :=\n  ⟨comap (coe : s → α) volume⟩\n#align set_coe.measure_space SetCoe.measureSpace\n\ntheorem volume_set_coe_def (s : Set α) : (volume : Measure s) = comap (coe : s → α) volume :=\n  rfl\n#align volume_set_coe_def volume_set_coe_def\n\ntheorem MeasurableSet.map_coe_volume {s : Set α} (hs : MeasurableSet s) :\n    volume.map (coe : s → α) = restrict volume s := by\n  rw [volume_set_coe_def, (MeasurableEmbedding.subtype_coe hs).map_comap volume, Subtype.range_coe]\n#align measurable_set.map_coe_volume MeasurableSet.map_coe_volume\n\ntheorem volume_image_subtype_coe {s : Set α} (hs : MeasurableSet s) (t : Set s) :\n    volume (coe '' t : Set α) = volume t :=\n  (comap_subtype_coe_apply hs volume t).symm\n#align volume_image_subtype_coe volume_image_subtype_coe\n\n@[simp]\ntheorem volume_preimage_coe (hs : NullMeasurableSet s) (ht : MeasurableSet t) :\n    volume ((coe : s → α) ⁻¹' t) = volume (t ∩ s) := by\n  rw [volume_set_coe_def,\n    comap_apply₀ _ _ Subtype.coe_injective\n      (fun h => measurable_set.null_measurable_set_subtype_coe hs)\n      (measurable_subtype_coe ht).NullMeasurableSet,\n    image_preimage_eq_inter_range, Subtype.range_coe]\n#align volume_preimage_coe volume_preimage_coe\n\nend Subtype\n\nnamespace MeasurableEquiv\n\n/-! Interactions of measurable equivalences and measures -/\n\n\nopen Equiv MeasureTheory.Measure\n\nvariable [MeasurableSpace α] [MeasurableSpace β] {μ : Measure α} {ν : Measure β}\n\n/-- If we map a measure along a measurable equivalence, we can compute the measure on all sets\n  (not just the measurable ones). -/\nprotected theorem map_apply (f : α ≃ᵐ β) (s : Set β) : μ.map f s = μ (f ⁻¹' s) :=\n  f.MeasurableEmbedding.map_apply _ _\n#align measurable_equiv.map_apply MeasurableEquiv.map_apply\n\n@[simp]\ntheorem map_symm_map (e : α ≃ᵐ β) : (μ.map e).map e.symm = μ := by\n  simp [map_map e.symm.measurable e.measurable]\n#align measurable_equiv.map_symm_map MeasurableEquiv.map_symm_map\n\n@[simp]\ntheorem map_map_symm (e : α ≃ᵐ β) : (ν.map e.symm).map e = ν := by\n  simp [map_map e.measurable e.symm.measurable]\n#align measurable_equiv.map_map_symm MeasurableEquiv.map_map_symm\n\ntheorem map_measurableEquiv_injective (e : α ≃ᵐ β) : Injective (map e) :=\n  by\n  intro μ₁ μ₂ hμ\n  apply_fun map e.symm  at hμ\n  simpa [map_symm_map e] using hμ\n#align measurable_equiv.map_measurable_equiv_injective MeasurableEquiv.map_measurableEquiv_injective\n\ntheorem map_apply_eq_iff_map_symm_apply_eq (e : α ≃ᵐ β) : μ.map e = ν ↔ ν.map e.symm = μ := by\n  rw [← (map_measurable_equiv_injective e).eq_iff, map_map_symm, eq_comm]\n#align measurable_equiv.map_apply_eq_iff_map_symm_apply_eq MeasurableEquiv.map_apply_eq_iff_map_symm_apply_eq\n\ntheorem restrict_map (e : α ≃ᵐ β) (s : Set β) :\n    (μ.map e).restrict s = (μ.restrict <| e ⁻¹' s).map e :=\n  e.MeasurableEmbedding.restrict_map _ _\n#align measurable_equiv.restrict_map MeasurableEquiv.restrict_map\n\ntheorem map_ae (f : α ≃ᵐ β) (μ : Measure α) : Filter.map f μ.ae = (map f μ).ae :=\n  by\n  ext s\n  simp_rw [mem_map, mem_ae_iff, ← preimage_compl, f.map_apply]\n#align measurable_equiv.map_ae MeasurableEquiv.map_ae\n\ntheorem quasiMeasurePreservingSymm (μ : Measure α) (e : α ≃ᵐ β) :\n    QuasiMeasurePreserving e.symm (map e μ) μ :=\n  ⟨e.symm.Measurable, by rw [measure.map_map, e.symm_comp_self, measure.map_id] <;> measurability⟩\n#align measurable_equiv.quasi_measure_preserving_symm MeasurableEquiv.quasiMeasurePreservingSymm\n\nend MeasurableEquiv\n\nnamespace MeasureTheory\n\ntheorem OuterMeasure.toMeasure_zero [MeasurableSpace α] :\n    (0 : OuterMeasure α).toMeasure (le_top.trans OuterMeasure.zero_caratheodory.symm.le) = 0 := by\n  rw [← measure.measure_univ_eq_zero, to_measure_apply _ _ MeasurableSet.univ,\n    outer_measure.coe_zero, Pi.zero_apply]\n#align measure_theory.outer_measure.to_measure_zero MeasureTheory.OuterMeasure.toMeasure_zero\n\nsection Trim\n\n/-- Restriction of a measure to a sub-sigma algebra.\nIt is common to see a measure `μ` on a measurable space structure `m0` as being also a measure on\nany `m ≤ m0`. Since measures in mathlib have to be trimmed to the measurable space, `μ` itself\ncannot be a measure on `m`, hence the definition of `μ.trim hm`.\n\nThis notion is related to `outer_measure.trim`, see the lemma\n`to_outer_measure_trim_eq_trim_to_outer_measure`. -/\ndef Measure.trim {m m0 : MeasurableSpace α} (μ : @Measure α m0) (hm : m ≤ m0) : @Measure α m :=\n  @OuterMeasure.toMeasure α m μ.toOuterMeasure (hm.trans (le_toOuterMeasure_caratheodory μ))\n#align measure_theory.measure.trim MeasureTheory.Measure.trim\n\n@[simp]\ntheorem trim_eq_self [MeasurableSpace α] {μ : Measure α} : μ.trim le_rfl = μ := by\n  simp [measure.trim]\n#align measure_theory.trim_eq_self MeasureTheory.trim_eq_self\n\nvariable {m m0 : MeasurableSpace α} {μ : Measure α} {s : Set α}\n\ntheorem toOuterMeasure_trim_eq_trim_toOuterMeasure (μ : Measure α) (hm : m ≤ m0) :\n    @Measure.toOuterMeasure _ m (μ.trim hm) = @OuterMeasure.trim _ m μ.toOuterMeasure := by\n  rw [measure.trim, to_measure_to_outer_measure]\n#align measure_theory.to_outer_measure_trim_eq_trim_to_outer_measure MeasureTheory.toOuterMeasure_trim_eq_trim_toOuterMeasure\n\n@[simp]\ntheorem zero_trim (hm : m ≤ m0) : (0 : Measure α).trim hm = (0 : @Measure α m) := by\n  simp [measure.trim, outer_measure.to_measure_zero]\n#align measure_theory.zero_trim MeasureTheory.zero_trim\n\ntheorem trim_measurableSet_eq (hm : m ≤ m0) (hs : @MeasurableSet α m s) : μ.trim hm s = μ s := by\n  simp [measure.trim, hs]\n#align measure_theory.trim_measurable_set_eq MeasureTheory.trim_measurableSet_eq\n\ntheorem le_trim (hm : m ≤ m0) : μ s ≤ μ.trim hm s :=\n  by\n  simp_rw [measure.trim]\n  exact @le_to_measure_apply _ m _ _ _\n#align measure_theory.le_trim MeasureTheory.le_trim\n\ntheorem measure_eq_zero_of_trim_eq_zero (hm : m ≤ m0) (h : μ.trim hm s = 0) : μ s = 0 :=\n  le_antisymm ((le_trim hm).trans (le_of_eq h)) (zero_le _)\n#align measure_theory.measure_eq_zero_of_trim_eq_zero MeasureTheory.measure_eq_zero_of_trim_eq_zero\n\ntheorem measure_trim_toMeasurable_eq_zero {hm : m ≤ m0} (hs : μ.trim hm s = 0) :\n    μ (@toMeasurable α m (μ.trim hm) s) = 0 :=\n  measure_eq_zero_of_trim_eq_zero hm (by rwa [measure_to_measurable])\n#align measure_theory.measure_trim_to_measurable_eq_zero MeasureTheory.measure_trim_toMeasurable_eq_zero\n\ntheorem ae_of_ae_trim (hm : m ≤ m0) {μ : Measure α} {P : α → Prop} (h : ∀ᵐ x ∂μ.trim hm, P x) :\n    ∀ᵐ x ∂μ, P x :=\n  measure_eq_zero_of_trim_eq_zero hm h\n#align measure_theory.ae_of_ae_trim MeasureTheory.ae_of_ae_trim\n\ntheorem ae_eq_of_ae_eq_trim {E} {hm : m ≤ m0} {f₁ f₂ : α → E}\n    (h12 : f₁ =ᶠ[@Measure.ae α m (μ.trim hm)] f₂) : f₁ =ᵐ[μ] f₂ :=\n  measure_eq_zero_of_trim_eq_zero hm h12\n#align measure_theory.ae_eq_of_ae_eq_trim MeasureTheory.ae_eq_of_ae_eq_trim\n\ntheorem ae_le_of_ae_le_trim {E} [LE E] {hm : m ≤ m0} {f₁ f₂ : α → E}\n    (h12 : f₁ ≤ᶠ[@Measure.ae α m (μ.trim hm)] f₂) : f₁ ≤ᵐ[μ] f₂ :=\n  measure_eq_zero_of_trim_eq_zero hm h12\n#align measure_theory.ae_le_of_ae_le_trim MeasureTheory.ae_le_of_ae_le_trim\n\ntheorem trim_trim {m₁ m₂ : MeasurableSpace α} {hm₁₂ : m₁ ≤ m₂} {hm₂ : m₂ ≤ m0} :\n    (μ.trim hm₂).trim hm₁₂ = μ.trim (hm₁₂.trans hm₂) :=\n  by\n  ext1 t ht\n  rw [trim_measurable_set_eq hm₁₂ ht, trim_measurable_set_eq (hm₁₂.trans hm₂) ht,\n    trim_measurable_set_eq hm₂ (hm₁₂ t ht)]\n#align measure_theory.trim_trim MeasureTheory.trim_trim\n\ntheorem restrict_trim (hm : m ≤ m0) (μ : Measure α) (hs : @MeasurableSet α m s) :\n    @Measure.restrict α m (μ.trim hm) s = (μ.restrict s).trim hm :=\n  by\n  ext1 t ht\n  rw [@measure.restrict_apply α m _ _ _ ht, trim_measurable_set_eq hm ht,\n    measure.restrict_apply (hm t ht),\n    trim_measurable_set_eq hm (@MeasurableSet.inter α m t s ht hs)]\n#align measure_theory.restrict_trim MeasureTheory.restrict_trim\n\ninstance isFiniteMeasureTrim (hm : m ≤ m0) [IsFiniteMeasure μ] : IsFiniteMeasure (μ.trim hm)\n    where measure_univ_lt_top :=\n    by\n    rw [trim_measurable_set_eq hm (@MeasurableSet.univ _ m)]\n    exact measure_lt_top _ _\n#align measure_theory.is_finite_measure_trim MeasureTheory.isFiniteMeasureTrim\n\ntheorem sigmaFiniteTrimMono {m m₂ m0 : MeasurableSpace α} {μ : Measure α} (hm : m ≤ m0)\n    (hm₂ : m₂ ≤ m) [SigmaFinite (μ.trim (hm₂.trans hm))] : SigmaFinite (μ.trim hm) :=\n  by\n  have h := measure.finite_spanning_sets_in (μ.trim (hm₂.trans hm)) Set.univ\n  refine' measure.finite_spanning_sets_in.sigma_finite _\n  · use Set.univ\n  · refine'\n      { Set := spanning_sets (μ.trim (hm₂.trans hm))\n        set_mem := fun _ => Set.mem_univ _\n        Finite := fun i => _\n        -- This is the only one left to prove\n        spanning := Union_spanning_sets _ }\n    calc\n      (μ.trim hm) (spanning_sets (μ.trim (hm₂.trans hm)) i) =\n          ((μ.trim hm).trim hm₂) (spanning_sets (μ.trim (hm₂.trans hm)) i) :=\n        by rw [@trim_measurable_set_eq α m₂ m (μ.trim hm) _ hm₂ (measurable_spanning_sets _ _)]\n      _ = (μ.trim (hm₂.trans hm)) (spanning_sets (μ.trim (hm₂.trans hm)) i) := by\n        rw [@trim_trim _ _ μ _ _ hm₂ hm]\n      _ < ∞ := measure_spanning_sets_lt_top _ _\n      \n#align measure_theory.sigma_finite_trim_mono MeasureTheory.sigmaFiniteTrimMono\n\ntheorem sigmaFinite_trim_bot_iff : SigmaFinite (μ.trim bot_le) ↔ IsFiniteMeasure μ :=\n  by\n  rw [sigma_finite_bot_iff]\n  refine' ⟨fun h => ⟨_⟩, fun h => ⟨_⟩⟩ <;> have h_univ := h.measure_univ_lt_top\n  · rwa [trim_measurable_set_eq bot_le MeasurableSet.univ] at h_univ\n  · rwa [trim_measurable_set_eq bot_le MeasurableSet.univ]\n#align measure_theory.sigma_finite_trim_bot_iff MeasureTheory.sigmaFinite_trim_bot_iff\n\nend Trim\n\nend MeasureTheory\n\nnamespace IsCompact\n\nvariable [TopologicalSpace α] [MeasurableSpace α] {μ : Measure α} {s : Set α}\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (U «expr ⊇ » s) -/\n/-- If `s` is a compact set and `μ` is finite at `𝓝 x` for every `x ∈ s`, then `s` admits an open\nsuperset of finite measure. -/\ntheorem exists_open_superset_measure_lt_top' (h : IsCompact s)\n    (hμ : ∀ x ∈ s, μ.FiniteAtFilter (𝓝 x)) : ∃ (U : _)(_ : U ⊇ s), IsOpen U ∧ μ U < ∞ :=\n  by\n  refine' IsCompact.induction_on h _ _ _ _\n  · use ∅\n    simp [Superset]\n  · rintro s t hst ⟨U, htU, hUo, hU⟩\n    exact ⟨U, hst.trans htU, hUo, hU⟩\n  · rintro s t ⟨U, hsU, hUo, hU⟩ ⟨V, htV, hVo, hV⟩\n    refine'\n      ⟨U ∪ V, union_subset_union hsU htV, hUo.union hVo,\n        (measure_union_le _ _).trans_lt <| ENNReal.add_lt_top.2 ⟨hU, hV⟩⟩\n  · intro x hx\n    rcases(hμ x hx).exists_mem_basis (nhds_basis_opens _) with ⟨U, ⟨hx, hUo⟩, hU⟩\n    exact ⟨U, nhdsWithin_le_nhds (hUo.mem_nhds hx), U, subset.rfl, hUo, hU⟩\n#align is_compact.exists_open_superset_measure_lt_top' IsCompact.exists_open_superset_measure_lt_top'\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (U «expr ⊇ » s) -/\n/-- If `s` is a compact set and `μ` is a locally finite measure, then `s` admits an open superset of\nfinite measure. -/\ntheorem exists_open_superset_measure_lt_top (h : IsCompact s) (μ : Measure α)\n    [IsLocallyFiniteMeasure μ] : ∃ (U : _)(_ : U ⊇ s), IsOpen U ∧ μ U < ∞ :=\n  h.exists_open_superset_measure_lt_top' fun x hx => μ.finiteAtNhds x\n#align is_compact.exists_open_superset_measure_lt_top IsCompact.exists_open_superset_measure_lt_top\n\ntheorem measure_lt_top_of_nhdsWithin (h : IsCompact s) (hμ : ∀ x ∈ s, μ.FiniteAtFilter (𝓝[s] x)) :\n    μ s < ∞ :=\n  IsCompact.induction_on h (by simp) (fun s t hst ht => (measure_mono hst).trans_lt ht)\n    (fun s t hs ht => (measure_union_le s t).trans_lt (ENNReal.add_lt_top.2 ⟨hs, ht⟩)) hμ\n#align is_compact.measure_lt_top_of_nhds_within IsCompact.measure_lt_top_of_nhdsWithin\n\ntheorem measure_zero_of_nhdsWithin (hs : IsCompact s) :\n    (∀ a ∈ s, ∃ t ∈ 𝓝[s] a, μ t = 0) → μ s = 0 := by\n  simpa only [← compl_mem_ae_iff] using hs.compl_mem_sets_of_nhds_within\n#align is_compact.measure_zero_of_nhds_within IsCompact.measure_zero_of_nhdsWithin\n\nend IsCompact\n\n-- see Note [lower instance priority]\ninstance (priority := 100) isFiniteMeasureOnCompactsOfIsLocallyFiniteMeasure [TopologicalSpace α]\n    {m : MeasurableSpace α} {μ : Measure α} [IsLocallyFiniteMeasure μ] :\n    IsFiniteMeasureOnCompacts μ :=\n  ⟨fun s hs => hs.measure_lt_top_of_nhdsWithin fun x hx => μ.finiteAtNhdsWithin _ _⟩\n#align is_finite_measure_on_compacts_of_is_locally_finite_measure isFiniteMeasureOnCompactsOfIsLocallyFiniteMeasure\n\ntheorem isFiniteMeasure_iff_isFiniteMeasureOnCompacts_of_compactSpace [TopologicalSpace α]\n    [MeasurableSpace α] {μ : Measure α} [CompactSpace α] :\n    IsFiniteMeasure μ ↔ IsFiniteMeasureOnCompacts μ :=\n  by\n  constructor <;> intros\n  · infer_instance\n  · exact compact_space.is_finite_measure\n#align is_finite_measure_iff_is_finite_measure_on_compacts_of_compact_space isFiniteMeasure_iff_isFiniteMeasureOnCompacts_of_compactSpace\n\n/-- Compact covering of a `σ`-compact topological space as\n`measure_theory.measure.finite_spanning_sets_in`. -/\ndef MeasureTheory.Measure.finiteSpanningSetsInCompact [TopologicalSpace α] [SigmaCompactSpace α]\n    {m : MeasurableSpace α} (μ : Measure α) [IsLocallyFiniteMeasure μ] :\n    μ.FiniteSpanningSetsIn { K | IsCompact K }\n    where\n  Set := compactCovering α\n  set_mem := isCompact_compactCovering α\n  Finite n := (isCompact_compactCovering α n).measure_lt_top\n  spanning := unionᵢ_compactCovering α\n#align measure_theory.measure.finite_spanning_sets_in_compact MeasureTheory.Measure.finiteSpanningSetsInCompact\n\n/-- A locally finite measure on a `σ`-compact topological space admits a finite spanning sequence\nof open sets. -/\ndef MeasureTheory.Measure.finiteSpanningSetsInOpen [TopologicalSpace α] [SigmaCompactSpace α]\n    {m : MeasurableSpace α} (μ : Measure α) [IsLocallyFiniteMeasure μ] :\n    μ.FiniteSpanningSetsIn { K | IsOpen K }\n    where\n  Set n := ((isCompact_compactCovering α n).exists_open_superset_measure_lt_top μ).some\n  set_mem n :=\n    ((isCompact_compactCovering α n).exists_open_superset_measure_lt_top μ).choose_spec.snd.1\n  Finite n :=\n    ((isCompact_compactCovering α n).exists_open_superset_measure_lt_top μ).choose_spec.snd.2\n  spanning :=\n    eq_univ_of_subset\n      (unionᵢ_mono fun n =>\n        ((isCompact_compactCovering α n).exists_open_superset_measure_lt_top μ).choose_spec.fst)\n      (unionᵢ_compactCovering α)\n#align measure_theory.measure.finite_spanning_sets_in_open MeasureTheory.Measure.finiteSpanningSetsInOpen\n\nopen TopologicalSpace\n\n/-- A locally finite measure on a second countable topological space admits a finite spanning\nsequence of open sets. -/\nirreducible_def MeasureTheory.Measure.finiteSpanningSetsInOpen' [TopologicalSpace α]\n  [SecondCountableTopology α] {m : MeasurableSpace α} (μ : Measure α) [IsLocallyFiniteMeasure μ] :\n  μ.FiniteSpanningSetsIn { K | IsOpen K } :=\n  by\n  suffices H : Nonempty (μ.finite_spanning_sets_in { K | IsOpen K })\n  exact H.some\n  cases isEmpty_or_nonempty α\n  ·\n    exact\n      ⟨{  Set := fun n => ∅\n          set_mem := fun n => by simp\n          Finite := fun n => by simp\n          spanning := by simp }⟩\n  inhabit α\n  let S : Set (Set α) := { s | IsOpen s ∧ μ s < ∞ }\n  obtain ⟨T, T_count, TS, hT⟩ : ∃ T : Set (Set α), T.Countable ∧ T ⊆ S ∧ ⋃₀ T = ⋃₀ S :=\n    is_open_sUnion_countable S fun s hs => hs.1\n  rw [μ.is_topological_basis_is_open_lt_top.sUnion_eq] at hT\n  have T_ne : T.nonempty := by\n    by_contra h'T\n    simp only [not_nonempty_iff_eq_empty.1 h'T, sUnion_empty] at hT\n    simpa only [← hT] using mem_univ (default : α)\n  obtain ⟨f, hf⟩ : ∃ f : ℕ → Set α, T = range f\n  exact T_count.exists_eq_range T_ne\n  have fS : ∀ n, f n ∈ S := by\n    intro n\n    apply TS\n    rw [hf]\n    exact mem_range_self n\n  refine'\n    ⟨{  Set := f\n        set_mem := fun n => (fS n).1\n        Finite := fun n => (fS n).2\n        spanning := _ }⟩\n  apply eq_univ_of_forall fun x => _\n  obtain ⟨t, tT, xt⟩ : ∃ t : Set α, t ∈ range f ∧ x ∈ t :=\n    by\n    have : x ∈ ⋃₀ T := by simp only [hT]\n    simpa only [mem_sUnion, exists_prop, ← hf]\n  obtain ⟨n, rfl⟩ : ∃ n : ℕ, f n = t := by simpa only using tT\n  exact mem_Union_of_mem _ xt\n#align measure_theory.measure.finite_spanning_sets_in_open' MeasureTheory.Measure.finiteSpanningSetsInOpen'\n\nsection MeasureIxx\n\nvariable [Preorder α] [TopologicalSpace α] [CompactIccSpace α] {m : MeasurableSpace α}\n  {μ : Measure α} [IsLocallyFiniteMeasure μ] {a b : α}\n\ntheorem measure_Icc_lt_top : μ (Icc a b) < ∞ :=\n  isCompact_Icc.measure_lt_top\n#align measure_Icc_lt_top measure_Icc_lt_top\n\ntheorem measure_Ico_lt_top : μ (Ico a b) < ∞ :=\n  (measure_mono Ico_subset_Icc_self).trans_lt measure_Icc_lt_top\n#align measure_Ico_lt_top measure_Ico_lt_top\n\ntheorem measure_Ioc_lt_top : μ (Ioc a b) < ∞ :=\n  (measure_mono Ioc_subset_Icc_self).trans_lt measure_Icc_lt_top\n#align measure_Ioc_lt_top measure_Ioc_lt_top\n\ntheorem measure_Ioo_lt_top : μ (Ioo a b) < ∞ :=\n  (measure_mono Ioo_subset_Icc_self).trans_lt measure_Icc_lt_top\n#align measure_Ioo_lt_top measure_Ioo_lt_top\n\nend MeasureIxx\n\nsection Piecewise\n\nvariable [MeasurableSpace α] {μ : Measure α} {s t : Set α} {f g : α → β}\n\ntheorem piecewise_ae_eq_restrict (hs : MeasurableSet s) : piecewise s f g =ᵐ[μ.restrict s] f :=\n  by\n  rw [ae_restrict_eq hs]\n  exact (piecewise_eq_on s f g).EventuallyEq.filter_mono inf_le_right\n#align piecewise_ae_eq_restrict piecewise_ae_eq_restrict\n\ntheorem piecewise_ae_eq_restrict_compl (hs : MeasurableSet s) :\n    piecewise s f g =ᵐ[μ.restrict (sᶜ)] g :=\n  by\n  rw [ae_restrict_eq hs.compl]\n  exact (piecewise_eq_on_compl s f g).EventuallyEq.filter_mono inf_le_right\n#align piecewise_ae_eq_restrict_compl piecewise_ae_eq_restrict_compl\n\ntheorem piecewise_ae_eq_of_ae_eq_set (hst : s =ᵐ[μ] t) : s.piecewise f g =ᵐ[μ] t.piecewise f g :=\n  hst.mem_iff.mono fun x hx => by simp [piecewise, hx]\n#align piecewise_ae_eq_of_ae_eq_set piecewise_ae_eq_of_ae_eq_set\n\nend Piecewise\n\nsection IndicatorFunction\n\nvariable [MeasurableSpace α] {μ : Measure α} {s t : Set α} {f : α → β}\n\ntheorem mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem [Zero β] {t : Set β}\n    (ht : (0 : β) ∈ t) (hs : MeasurableSet s) :\n    t ∈ Filter.map (s.indicator f) μ.ae ↔ t ∈ Filter.map f (μ.restrict s).ae :=\n  by\n  simp_rw [mem_map, mem_ae_iff]\n  rw [measure.restrict_apply' hs, Set.indicator_preimage, Set.ite]\n  simp_rw [Set.compl_union, Set.compl_inter]\n  change μ (((f ⁻¹' t)ᶜ ∪ sᶜ) ∩ ((fun x => (0 : β)) ⁻¹' t \\ s)ᶜ) = 0 ↔ μ ((f ⁻¹' t)ᶜ ∩ s) = 0\n  simp only [ht, ← Set.compl_eq_univ_diff, compl_compl, Set.compl_union, if_true,\n    Set.preimage_const]\n  simp_rw [Set.union_inter_distrib_right, Set.compl_inter_self s, Set.union_empty]\n#align mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem\n\ntheorem mem_map_indicator_ae_iff_of_zero_nmem [Zero β] {t : Set β} (ht : (0 : β) ∉ t) :\n    t ∈ Filter.map (s.indicator f) μ.ae ↔ μ ((f ⁻¹' t)ᶜ ∪ sᶜ) = 0 :=\n  by\n  rw [mem_map, mem_ae_iff, Set.indicator_preimage, Set.ite, Set.compl_union, Set.compl_inter]\n  change μ (((f ⁻¹' t)ᶜ ∪ sᶜ) ∩ ((fun x => (0 : β)) ⁻¹' t \\ s)ᶜ) = 0 ↔ μ ((f ⁻¹' t)ᶜ ∪ sᶜ) = 0\n  simp only [ht, if_false, Set.compl_empty, Set.empty_diff, Set.inter_univ, Set.preimage_const]\n#align mem_map_indicator_ae_iff_of_zero_nmem mem_map_indicator_ae_iff_of_zero_nmem\n\ntheorem map_restrict_ae_le_map_indicator_ae [Zero β] (hs : MeasurableSet s) :\n    Filter.map f (μ.restrict s).ae ≤ Filter.map (s.indicator f) μ.ae :=\n  by\n  intro t\n  by_cases ht : (0 : β) ∈ t\n  · rw [mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem ht hs]\n    exact id\n  rw [mem_map_indicator_ae_iff_of_zero_nmem ht, mem_map_restrict_ae_iff hs]\n  exact fun h => measure_mono_null ((Set.inter_subset_left _ _).trans (Set.subset_union_left _ _)) h\n#align map_restrict_ae_le_map_indicator_ae map_restrict_ae_le_map_indicator_ae\n\nvariable [Zero β]\n\ntheorem indicator_ae_eq_restrict (hs : MeasurableSet s) : indicator s f =ᵐ[μ.restrict s] f :=\n  piecewise_ae_eq_restrict hs\n#align indicator_ae_eq_restrict indicator_ae_eq_restrict\n\ntheorem indicator_ae_eq_restrict_compl (hs : MeasurableSet s) :\n    indicator s f =ᵐ[μ.restrict (sᶜ)] 0 :=\n  piecewise_ae_eq_restrict_compl hs\n#align indicator_ae_eq_restrict_compl indicator_ae_eq_restrict_compl\n\ntheorem indicator_ae_eq_of_restrict_compl_ae_eq_zero (hs : MeasurableSet s)\n    (hf : f =ᵐ[μ.restrict (sᶜ)] 0) : s.indicator f =ᵐ[μ] f :=\n  by\n  rw [Filter.EventuallyEq, ae_restrict_iff' hs.compl] at hf\n  filter_upwards [hf]with x hx\n  by_cases hxs : x ∈ s\n  · simp only [hxs, Set.indicator_of_mem]\n  · simp only [hx hxs, Pi.zero_apply, Set.indicator_apply_eq_zero, eq_self_iff_true, imp_true_iff]\n#align indicator_ae_eq_of_restrict_compl_ae_eq_zero indicator_ae_eq_of_restrict_compl_ae_eq_zero\n\ntheorem indicator_ae_eq_zero_of_restrict_ae_eq_zero (hs : MeasurableSet s)\n    (hf : f =ᵐ[μ.restrict s] 0) : s.indicator f =ᵐ[μ] 0 :=\n  by\n  rw [Filter.EventuallyEq, ae_restrict_iff' hs] at hf\n  filter_upwards [hf]with x hx\n  by_cases hxs : x ∈ s\n  · simp only [hxs, hx hxs, Set.indicator_of_mem]\n  · simp [hx, hxs]\n#align indicator_ae_eq_zero_of_restrict_ae_eq_zero indicator_ae_eq_zero_of_restrict_ae_eq_zero\n\ntheorem indicator_ae_eq_of_ae_eq_set (hst : s =ᵐ[μ] t) : s.indicator f =ᵐ[μ] t.indicator f :=\n  piecewise_ae_eq_of_ae_eq_set hst\n#align indicator_ae_eq_of_ae_eq_set indicator_ae_eq_of_ae_eq_set\n\ntheorem indicator_meas_zero (hs : μ s = 0) : indicator s f =ᵐ[μ] 0 :=\n  indicator_empty' f ▸ indicator_ae_eq_of_ae_eq_set (ae_eq_empty.2 hs)\n#align indicator_meas_zero indicator_meas_zero\n\ntheorem ae_eq_restrict_iff_indicator_ae_eq {g : α → β} (hs : MeasurableSet s) :\n    f =ᵐ[μ.restrict s] g ↔ s.indicator f =ᵐ[μ] s.indicator g :=\n  by\n  rw [Filter.EventuallyEq, ae_restrict_iff' hs]\n  refine' ⟨fun h => _, fun h => _⟩ <;> filter_upwards [h]with x hx\n  · by_cases hxs : x ∈ s\n    · simp [hxs, hx hxs]\n    · simp [hxs]\n  · intro hxs\n    simpa [hxs] using hx\n#align ae_eq_restrict_iff_indicator_ae_eq ae_eq_restrict_iff_indicator_ae_eq\n\nend IndicatorFunction\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/MeasureTheory/Measure/MeasureSpace.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.4701109357799819}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.uniform_space.uniform_embedding\nimport Mathlib.topology.uniform_space.complete_separated\nimport Mathlib.topology.algebra.group\nimport Mathlib.tactic.abel\nimport Mathlib.PostPort\n\nuniverses u_3 l u_1 u_2 u u_4 u_5 \n\nnamespace Mathlib\n\n/-!\n# Uniform structure on topological groups\n\n* `topological_add_group.to_uniform_space` and `topological_add_group_is_uniform` can be used to\n  construct a canonical uniformity for a topological add group.\n\n* extension of ℤ-bilinear maps to complete groups (useful for ring completions)\n\n* `add_group_with_zero_nhd`: construct the topological structure from a group with a neighbourhood\n  around zero. Then with `topological_add_group.to_uniform_space` one can derive a `uniform_space`.\n-/\n\n/-- A uniform (additive) group is a group in which the addition and negation are\n  uniformly continuous. -/\nclass uniform_add_group (α : Type u_3) [uniform_space α] [add_group α] \nwhere\n  uniform_continuous_sub : uniform_continuous fun (p : α × α) => prod.fst p - prod.snd p\n\ntheorem uniform_add_group.mk' {α : Type u_1} [uniform_space α] [add_group α] (h₁ : uniform_continuous fun (p : α × α) => prod.fst p + prod.snd p) (h₂ : uniform_continuous fun (p : α) => -p) : uniform_add_group α := sorry\n\ntheorem uniform_continuous_sub {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : uniform_continuous fun (p : α × α) => prod.fst p - prod.snd p :=\n  uniform_add_group.uniform_continuous_sub\n\ntheorem uniform_continuous.sub {α : Type u_1} {β : Type u_2} [uniform_space α] [add_group α] [uniform_add_group α] [uniform_space β] {f : β → α} {g : β → α} (hf : uniform_continuous f) (hg : uniform_continuous g) : uniform_continuous fun (x : β) => f x - g x :=\n  uniform_continuous.comp uniform_continuous_sub (uniform_continuous.prod_mk hf hg)\n\ntheorem uniform_continuous.neg {α : Type u_1} {β : Type u_2} [uniform_space α] [add_group α] [uniform_add_group α] [uniform_space β] {f : β → α} (hf : uniform_continuous f) : uniform_continuous fun (x : β) => -f x := sorry\n\ntheorem uniform_continuous_neg {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : uniform_continuous fun (x : α) => -x :=\n  uniform_continuous.neg uniform_continuous_id\n\ntheorem uniform_continuous.add {α : Type u_1} {β : Type u_2} [uniform_space α] [add_group α] [uniform_add_group α] [uniform_space β] {f : β → α} {g : β → α} (hf : uniform_continuous f) (hg : uniform_continuous g) : uniform_continuous fun (x : β) => f x + g x := sorry\n\ntheorem uniform_continuous_add {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : uniform_continuous fun (p : α × α) => prod.fst p + prod.snd p :=\n  uniform_continuous.add uniform_continuous_fst uniform_continuous_snd\n\nprotected instance uniform_add_group.to_topological_add_group {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : topological_add_group α :=\n  topological_add_group.mk (uniform_continuous.continuous uniform_continuous_neg)\n\nprotected instance prod.uniform_add_group {α : Type u_1} {β : Type u_2} [uniform_space α] [add_group α] [uniform_add_group α] [uniform_space β] [add_group β] [uniform_add_group β] : uniform_add_group (α × β) :=\n  uniform_add_group.mk\n    (uniform_continuous.prod_mk\n      (uniform_continuous.sub (uniform_continuous.comp uniform_continuous_fst uniform_continuous_fst)\n        (uniform_continuous.comp uniform_continuous_fst uniform_continuous_snd))\n      (uniform_continuous.sub (uniform_continuous.comp uniform_continuous_snd uniform_continuous_fst)\n        (uniform_continuous.comp uniform_continuous_snd uniform_continuous_snd)))\n\ntheorem uniformity_translate {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] (a : α) : filter.map (fun (x : α × α) => (prod.fst x + a, prod.snd x + a)) (uniformity α) = uniformity α := sorry\n\ntheorem uniform_embedding_translate {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] (a : α) : uniform_embedding fun (x : α) => x + a := sorry\n\ntheorem uniformity_eq_comap_nhds_zero (α : Type u_1) [uniform_space α] [add_group α] [uniform_add_group α] : uniformity α = filter.comap (fun (x : α × α) => prod.snd x - prod.fst x) (nhds 0) := sorry\n\ntheorem group_separation_rel {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] (x : α) (y : α) : (x, y) ∈ Mathlib.separation_rel α ↔ x - y ∈ closure (singleton 0) := sorry\n\ntheorem uniform_continuous_of_tendsto_zero {α : Type u_1} {β : Type u_2} [uniform_space α] [add_group α] [uniform_add_group α] [uniform_space β] [add_group β] [uniform_add_group β] {f : α → β} [is_add_group_hom f] (h : filter.tendsto f (nhds 0) (nhds 0)) : uniform_continuous f := sorry\n\ntheorem uniform_continuous_of_continuous {α : Type u_1} {β : Type u_2} [uniform_space α] [add_group α] [uniform_add_group α] [uniform_space β] [add_group β] [uniform_add_group β] {f : α → β} [is_add_group_hom f] (h : continuous f) : uniform_continuous f := sorry\n\n/-- The right uniformity on a topological group. -/\ndef topological_add_group.to_uniform_space (G : Type u) [add_comm_group G] [topological_space G] [topological_add_group G] : uniform_space G :=\n  uniform_space.mk\n    (uniform_space.core.mk (filter.comap (fun (p : G × G) => prod.snd p - prod.fst p) (nhds 0)) sorry sorry sorry) sorry\n\ntheorem uniformity_eq_comap_nhds_zero' (G : Type u) [add_comm_group G] [topological_space G] [topological_add_group G] : uniformity G = filter.comap (fun (p : G × G) => prod.snd p - prod.fst p) (nhds 0) :=\n  rfl\n\ntheorem topological_add_group_is_uniform {G : Type u} [add_comm_group G] [topological_space G] [topological_add_group G] : uniform_add_group G := sorry\n\ntheorem to_uniform_space_eq {G : Type u} [u : uniform_space G] [add_comm_group G] [uniform_add_group G] : topological_add_group.to_uniform_space G = u := sorry\n\nnamespace add_comm_group\n\n\n/- TODO: when modules are changed to have more explicit base ring, then change replace `is_Z_bilin`\nby using `is_bilinear_map ℤ` from `tensor_product`. -/\n\n/-- `ℤ`-bilinearity for maps between additive commutative groups. -/\nclass is_Z_bilin {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) \nwhere\n  add_left : ∀ (a a' : α) (b : β), f (a + a', b) = f (a, b) + f (a', b)\n  add_right : ∀ (a : α) (b b' : β), f (a, b + b') = f (a, b) + f (a, b')\n\ntheorem is_Z_bilin.comp_hom {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] {g : γ → δ} [add_comm_group δ] [is_add_group_hom g] : is_Z_bilin (g ∘ f) := sorry\n\nprotected instance is_Z_bilin.comp_swap {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] : is_Z_bilin (f ∘ prod.swap) :=\n  is_Z_bilin.mk (fun (a a' : β) (b : α) => is_Z_bilin.add_right f b a a')\n    fun (a : β) (b b' : α) => is_Z_bilin.add_left f b b' a\n\ntheorem is_Z_bilin.zero_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] (b : β) : f (0, b) = 0 := sorry\n\ntheorem is_Z_bilin.zero_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] (a : α) : f (a, 0) = 0 :=\n  is_Z_bilin.zero_left (f ∘ prod.swap)\n\ntheorem is_Z_bilin.zero {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] : f (0, 0) = 0 :=\n  is_Z_bilin.zero_left f 0\n\ntheorem is_Z_bilin.neg_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] (a : α) (b : β) : f (-a, b) = -f (a, b) := sorry\n\ntheorem is_Z_bilin.neg_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] (a : α) (b : β) : f (a, -b) = -f (a, b) :=\n  is_Z_bilin.neg_left (f ∘ prod.swap) b a\n\ntheorem is_Z_bilin.sub_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] (a : α) (a' : α) (b : β) : f (a - a', b) = f (a, b) - f (a', b) := sorry\n\ntheorem is_Z_bilin.sub_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group α] [add_comm_group β] [add_comm_group γ] (f : α × β → γ) [is_Z_bilin f] (a : α) (b : β) (b' : β) : f (a, b - b') = f (a, b) - f (a, b') :=\n  is_Z_bilin.sub_left (f ∘ prod.swap) b b' a\n\nend add_comm_group\n\n\n-- α, β and G are abelian topological groups, G is a uniform space\n\ntheorem is_Z_bilin.tendsto_zero_left {α : Type u_1} {β : Type u_2} [topological_space α] [add_comm_group α] [topological_space β] [add_comm_group β] {G : Type u_5} [uniform_space G] [add_comm_group G] {ψ : α × β → G} (hψ : continuous ψ) [ψbilin : add_comm_group.is_Z_bilin ψ] (x₁ : α) : filter.tendsto ψ (nhds (x₁, 0)) (nhds 0) := sorry\n\ntheorem is_Z_bilin.tendsto_zero_right {α : Type u_1} {β : Type u_2} [topological_space α] [add_comm_group α] [topological_space β] [add_comm_group β] {G : Type u_5} [uniform_space G] [add_comm_group G] {ψ : α × β → G} (hψ : continuous ψ) [ψbilin : add_comm_group.is_Z_bilin ψ] (y₁ : β) : filter.tendsto ψ (nhds (0, y₁)) (nhds 0) :=\n  eq.mp\n    (Eq._oldrec (Eq.refl (filter.tendsto ψ (nhds (0, y₁)) (nhds (ψ (0, y₁))))) (add_comm_group.is_Z_bilin.zero_left ψ y₁))\n    (continuous.tendsto hψ (0, y₁))\n\n-- β is a dense subgroup of α, inclusion is denoted by e\n\ntheorem tendsto_sub_comap_self {α : Type u_1} {β : Type u_2} [topological_space α] [add_comm_group α] [topological_add_group α] [topological_space β] [add_comm_group β] {e : β → α} [is_add_group_hom e] (de : dense_inducing e) (x₀ : α) : filter.tendsto (fun (t : β × β) => prod.snd t - prod.fst t)\n  (filter.comap (fun (p : β × β) => (e (prod.fst p), e (prod.snd p))) (nhds (x₀, x₀))) (nhds 0) := sorry\n\nnamespace dense_inducing\n\n\n-- β is a dense subgroup of α, inclusion is denoted by e\n\n-- δ is a dense subgroup of γ, inclusion is denoted by f\n\n/-- Bourbaki GT III.6.5 Theorem I:\nℤ-bilinear continuous maps from dense images into a complete Hausdorff group extend by continuity.\nNote: Bourbaki assumes that α and β are also complete Hausdorff, but this is not necessary. -/\ntheorem extend_Z_bilin {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {G : Type u_5} [topological_space α] [add_comm_group α] [topological_add_group α] [topological_space β] [add_comm_group β] [topological_add_group β] [topological_space γ] [add_comm_group γ] [topological_add_group γ] [topological_space δ] [add_comm_group δ] [topological_add_group δ] [uniform_space G] [add_comm_group G] [uniform_add_group G] [separated_space G] [complete_space G] {e : β → α} [is_add_group_hom e] (de : dense_inducing e) {f : δ → γ} [is_add_group_hom f] (df : dense_inducing f) {φ : β × δ → G} (hφ : continuous φ) [bilin : add_comm_group.is_Z_bilin φ] : continuous (extend (dense_inducing.prod de df) φ) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/uniform_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312006227324, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4699482850274801}}
{"text": "import graphs.composition\n\nlemma id_compatability (G : graph) : G.endpoints ∘ id = sym2.map id ∘ G.endpoints :=\nbegin\n  rw sym2.map_id,\n  refl,\nend", "meta": {"author": "barriecooper", "repo": "lean-graphs", "sha": "3f7be961f99fe084f950f52fe17c53e8093b5337", "save_path": "github-repos/lean/barriecooper-lean-graphs", "path": "github-repos/lean/barriecooper-lean-graphs/lean-graphs-3f7be961f99fe084f950f52fe17c53e8093b5337/src/graphs/id.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031737869342623, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.46993790976101696}}
{"text": "/-\nCopyright (c) 2021 Fox Thomson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fox Thomson, Yaël Dillies\n\n! This file was ported from Lean 3 source module computability.epsilon_NFA\n! leanprover-community/mathlib commit 28aa996fc6fb4317f0083c4e6daf79878d81be33\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Computability.NFA\n\n/-!\n# Epsilon Nondeterministic Finite Automata\n\nThis file contains the definition of an epsilon Nondeterministic Finite Automaton (`εNFA`), a state\nmachine which determines whether a string (implemented as a list over an arbitrary alphabet) is in a\nregular set by evaluating the string over every possible path, also having access to ε-transitons,\nwhich can be followed without reading a character.\nSince this definition allows for automata with infinite states, a `Fintype` instance must be\nsupplied for true `εNFA`'s.\n-/\n\n\nopen Set\n\nopen Computability\n\n-- \"ε_NFA\"\nset_option linter.uppercaseLean3 false\n\nuniverse u v\n\n/-- An `εNFA` is a set of states (`σ`), a transition function from state to state labelled by the\n  alphabet (`step`), a starting state (`start`) and a set of acceptance states (`accept`).\n  Note the transition function sends a state to a `Set` of states and can make ε-transitions by\n  inputing `none`.\n  Since this definition allows for Automata with infinite states, a `Fintype` instance must be\n  supplied for true `εNFA`'s. -/\nstructure εNFA (α : Type u) (σ : Type v) where\n  step : σ → Option α → Set σ\n  start : Set σ\n  accept : Set σ\n#align ε_NFA εNFA\n\nvariable {α : Type u} {σ σ' : Type v} (M : εNFA α σ) {S : Set σ} {x : List α} {s : σ} {a : α}\n\nnamespace εNFA\n\n/-- The `εClosure` of a set is the set of states which can be reached by taking a finite string of\nε-transitions from an element of the set. -/\ninductive εClosure (S : Set σ) : Set σ\n  | base : ∀ s ∈ S, εClosure S s\n  | step : ∀ (s), ∀ t ∈ M.step s none, εClosure S s → εClosure S t\n#align ε_NFA.ε_closure εNFA.εClosure\n\n@[simp]\ntheorem subset_εClosure (S : Set σ) : S ⊆ M.εClosure S :=\n  εClosure.base\n#align ε_NFA.subset_ε_closure εNFA.subset_εClosure\n\n@[simp]\ntheorem εClosure_empty : M.εClosure ∅ = ∅ :=\n  eq_empty_of_forall_not_mem fun s hs ↦ by induction hs <;> assumption\n#align ε_NFA.ε_closure_empty εNFA.εClosure_empty\n\n@[simp]\ntheorem εClosure_univ : M.εClosure univ = univ :=\n  eq_univ_of_univ_subset <| subset_εClosure _ _\n#align ε_NFA.ε_closure_univ εNFA.εClosure_univ\n\n/-- `M.stepSet S a` is the union of the ε-closure of `M.step s a` for all `s ∈ S`. -/\ndef stepSet (S : Set σ) (a : α) : Set σ :=\n  ⋃ s ∈ S, M.εClosure <| M.step s a\n#align ε_NFA.step_set εNFA.stepSet\n\nvariable {M}\n\n@[simp]\ntheorem mem_stepSet_iff : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.εClosure (M.step t a) := by\n  simp_rw [stepSet, mem_unionᵢ₂, exists_prop]\n#align ε_NFA.mem_step_set_iff εNFA.mem_stepSet_iff\n\n@[simp]\ntheorem stepSet_empty (a : α) : M.stepSet ∅ a = ∅ := by\n  simp_rw [stepSet, mem_empty_iff_false, unionᵢ_false, unionᵢ_empty]\n#align ε_NFA.step_set_empty εNFA.stepSet_empty\n\nvariable (M)\n\n/-- `M.evalFrom S x` computes all possible paths through `M` with input `x` starting at an element\nof `S`. -/\ndef evalFrom (start : Set σ) : List α → Set σ :=\n  List.foldl M.stepSet (M.εClosure start)\n#align ε_NFA.eval_from εNFA.evalFrom\n\n@[simp]\ntheorem evalFrom_nil (S : Set σ) : M.evalFrom S [] = M.εClosure S :=\n  rfl\n#align ε_NFA.eval_from_nil εNFA.evalFrom_nil\n\n@[simp]\ntheorem evalFrom_singleton (S : Set σ) (a : α) : M.evalFrom S [a] = M.stepSet (M.εClosure S) a :=\n  rfl\n#align ε_NFA.eval_from_singleton εNFA.evalFrom_singleton\n\n@[simp]\ntheorem evalFrom_append_singleton (S : Set σ) (x : List α) (a : α) :\n    M.evalFrom S (x ++ [a]) = M.stepSet (M.evalFrom S x) a := by\n  rw [evalFrom, List.foldl_append, List.foldl_cons, List.foldl_nil]\n#align ε_NFA.eval_from_append_singleton εNFA.evalFrom_append_singleton\n\n@[simp]\ntheorem evalFrom_empty (x : List α) : M.evalFrom ∅ x = ∅ := by\n  induction' x using List.reverseRecOn with x a ih\n  · rw [evalFrom_nil, εClosure_empty]\n  · rw [evalFrom_append_singleton, ih, stepSet_empty]\n#align ε_NFA.eval_from_empty εNFA.evalFrom_empty\n\n/-- `M.eval x` computes all possible paths through `M` with input `x` starting at an element of\n`M.start`. -/\ndef eval :=\n  M.evalFrom M.start\n#align ε_NFA.eval εNFA.eval\n\n@[simp]\ntheorem eval_nil : M.eval [] = M.εClosure M.start :=\n  rfl\n#align ε_NFA.eval_nil εNFA.eval_nil\n\n@[simp]\ntheorem eval_singleton (a : α) : M.eval [a] = M.stepSet (M.εClosure M.start) a :=\n  rfl\n#align ε_NFA.eval_singleton εNFA.eval_singleton\n\n@[simp]\ntheorem eval_append_singleton (x : List α) (a : α) : M.eval (x ++ [a]) = M.stepSet (M.eval x) a :=\n  evalFrom_append_singleton _ _ _ _\n#align ε_NFA.eval_append_singleton εNFA.eval_append_singleton\n\n/-- `M.accepts` is the language of `x` such that there is an accept state in `M.eval x`. -/\ndef accepts : Language α :=\n  { x | ∃ S ∈ M.accept, S ∈ M.eval x }\n#align ε_NFA.accepts εNFA.accepts\n\n/-! ### Conversions between `εNFA` and `NFA` -/\n\n\n/-- `M.toNFA` is an `NFA` constructed from an `εNFA` `M`. -/\ndef toNFA : NFA α σ where\n  step S a := M.εClosure (M.step S a)\n  start := M.εClosure M.start\n  accept := M.accept\n#align ε_NFA.to_NFA εNFA.toNFA\n\n@[simp]\ntheorem toNFA_evalFrom_match (start : Set σ) :\n    M.toNFA.evalFrom (M.εClosure start) = M.evalFrom start :=\n  rfl\n#align ε_NFA.to_NFA_eval_from_match εNFA.toNFA_evalFrom_match\n\n@[simp]\ntheorem toNFA_correct : M.toNFA.accepts = M.accepts :=\n  rfl\n#align ε_NFA.to_NFA_correct εNFA.toNFA_correct\n\ntheorem pumping_lemma [Fintype σ] {x : List α} (hx : x ∈ M.accepts)\n    (hlen : Fintype.card (Set σ) ≤ List.length x) :\n    ∃ a b c, x = a ++ b ++ c ∧\n      a.length + b.length ≤ Fintype.card (Set σ) ∧ b ≠ [] ∧ {a} * {b}∗ * {c} ≤ M.accepts :=\n  M.toNFA.pumping_lemma hx hlen\n#align ε_NFA.pumping_lemma εNFA.pumping_lemma\n\nend εNFA\n\nnamespace NFA\n\n/-- `M.toεNFA` is an `εNFA` constructed from an `NFA` `M` by using the same start and accept\n  states and transition functions. -/\ndef toεNFA (M : NFA α σ) : εNFA α σ where\n  step s a := a.casesOn' ∅ fun a ↦ M.step s a\n  start := M.start\n  accept := M.accept\n#align NFA.to_ε_NFA NFA.toεNFA\n\n@[simp]\ntheorem toεNFA_εClosure (M : NFA α σ) (S : Set σ) : M.toεNFA.εClosure S = S := by\n  ext a\n  refine' ⟨_, εNFA.εClosure.base _⟩\n  rintro (⟨_, h⟩ | ⟨_, _, h, _⟩)\n  · exact h\n  · cases h\n#align NFA.to_ε_NFA_ε_closure NFA.toεNFA_εClosure\n\n@[simp]\ntheorem toεNFA_evalFrom_match (M : NFA α σ) (start : Set σ) :\n    M.toεNFA.evalFrom start = M.evalFrom start := by\n  rw [evalFrom, εNFA.evalFrom, toεNFA_εClosure]\n  suffices εNFA.stepSet (toεNFA M) = stepSet M by rw [this]\n  ext S s\n  simp only [stepSet, εNFA.stepSet, exists_prop, Set.mem_unionᵢ]\n  apply exists_congr\n  simp only [and_congr_right_iff]\n  intro _ _\n  rw [M.toεNFA_εClosure]\n  rfl\n#align NFA.to_ε_NFA_eval_from_match NFA.toεNFA_evalFrom_match\n\n@[simp]\ntheorem toεNFA_correct (M : NFA α σ) : M.toεNFA.accepts = M.accepts := by\n  rw [εNFA.accepts, εNFA.eval, toεNFA_evalFrom_match]\n  rfl\n#align NFA.to_ε_NFA_correct NFA.toεNFA_correct\n\nend NFA\n\n/-! ### Regex-like operations -/\n\n\nnamespace εNFA\n\ninstance : Zero (εNFA α σ) :=\n  ⟨⟨fun _ _ ↦ ∅, ∅, ∅⟩⟩\n\ninstance : One (εNFA α σ) :=\n  ⟨⟨fun _ _ ↦ ∅, univ, univ⟩⟩\n\ninstance : Inhabited (εNFA α σ) :=\n  ⟨0⟩\n\nvariable (P : εNFA α σ) (Q : εNFA α σ')\n\n@[simp]\ntheorem step_zero (s a) : (0 : εNFA α σ).step s a = ∅ :=\n  rfl\n#align ε_NFA.step_zero εNFA.step_zero\n\n@[simp]\ntheorem step_one (s a) : (1 : εNFA α σ).step s a = ∅ :=\n  rfl\n#align ε_NFA.step_one εNFA.step_one\n\n@[simp]\ntheorem start_zero : (0 : εNFA α σ).start = ∅ :=\n  rfl\n#align ε_NFA.start_zero εNFA.start_zero\n\n@[simp]\ntheorem start_one : (1 : εNFA α σ).start = univ :=\n  rfl\n#align ε_NFA.start_one εNFA.start_one\n\n@[simp]\ntheorem accept_zero : (0 : εNFA α σ).accept = ∅ :=\n  rfl\n#align ε_NFA.accept_zero εNFA.accept_zero\n\n@[simp]\ntheorem accept_one : (1 : εNFA α σ).accept = univ :=\n  rfl\n#align ε_NFA.accept_one εNFA.accept_one\n\nend εNFA\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Computability/EpsilonNFA.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.4699085011490848}}
{"text": "/-\n-- Copyright (c) 2020 Bhavik Mehta. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Bhavik Mehta, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.equalizers\nimport Mathlib.category_theory.limits.shapes.finite_products\nimport Mathlib.category_theory.limits.preserves.shapes.products\nimport Mathlib.category_theory.limits.preserves.shapes.equalizers\nimport Mathlib.PostPort\n\nuniverses u v u₂ \n\nnamespace Mathlib\n\n/-!\n# Constructing limits from products and equalizers.\n\nIf a category has all products, and all equalizers, then it has all limits.\nSimilarly, if it has all finite products, and all equalizers, then it has all finite limits.\n\nIf a functor preserves all products and equalizers, then it preserves all limits.\nSimilarly, if it preserves all finite products and equalizers, then it preserves all finite limits.\n\n# TODO\n\nProvide the dual results.\nShow the analogous results for functors which reflect or create (co)limits.\n-/\n\nnamespace category_theory.limits\n\n\n-- We hide the \"implementation details\" inside a namespace\n\nnamespace has_limit_of_has_products_of_has_equalizers\n\n\n/--\n(Implementation) Given the appropriate product and equalizer cones, build the cone for `F` which is\nlimiting if the given cones are also.\n-/\ndef build_limit {C : Type u} [category C] {J : Type v} [small_category J] {F : J ⥤ C}\n    {c₁ : fan (functor.obj F)}\n    {c₂ :\n      fan\n        fun (f : sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p) =>\n          functor.obj F (prod.snd (sigma.fst f))}\n    (s : cone.X c₁ ⟶ cone.X c₂) (t : cone.X c₁ ⟶ cone.X c₂)\n    (hs :\n      ∀ (f : sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p),\n        s ≫ nat_trans.app (cone.π c₂) f =\n          nat_trans.app (cone.π c₁) (prod.fst (sigma.fst f)) ≫ functor.map F (sigma.snd f))\n    (ht :\n      ∀ (f : sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p),\n        t ≫ nat_trans.app (cone.π c₂) f = nat_trans.app (cone.π c₁) (prod.snd (sigma.fst f)))\n    (i : fork s t) : cone F :=\n  cone.mk (cone.X i) (nat_trans.mk fun (j : J) => fork.ι i ≫ nat_trans.app (cone.π c₁) j)\n\n/--\n(Implementation) Show the cone constructed in `build_limit` is limiting, provided the cones used in\nits construction are.\n-/\ndef build_is_limit {C : Type u} [category C] {J : Type v} [small_category J] {F : J ⥤ C}\n    {c₁ : fan (functor.obj F)}\n    {c₂ :\n      fan\n        fun (f : sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p) =>\n          functor.obj F (prod.snd (sigma.fst f))}\n    (s : cone.X c₁ ⟶ cone.X c₂) (t : cone.X c₁ ⟶ cone.X c₂)\n    (hs :\n      ∀ (f : sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p),\n        s ≫ nat_trans.app (cone.π c₂) f =\n          nat_trans.app (cone.π c₁) (prod.fst (sigma.fst f)) ≫ functor.map F (sigma.snd f))\n    (ht :\n      ∀ (f : sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p),\n        t ≫ nat_trans.app (cone.π c₂) f = nat_trans.app (cone.π c₁) (prod.snd (sigma.fst f)))\n    {i : fork s t} (t₁ : is_limit c₁) (t₂ : is_limit c₂) (hi : is_limit i) :\n    is_limit (build_limit s t hs ht i) :=\n  is_limit.mk\n    fun (q : cone F) =>\n      is_limit.lift hi\n        (fork.of_ι (is_limit.lift t₁ (fan.mk (cone.X q) fun (j : J) => nat_trans.app (cone.π q) j))\n          sorry)\n\nend has_limit_of_has_products_of_has_equalizers\n\n\n/--\nGiven the existence of the appropriate (possibly finite) products and equalizers, we know a limit of\n`F` exists.\n(This assumes the existence of all equalizers, which is technically stronger than needed.)\n-/\ntheorem has_limit_of_equalizer_and_product {C : Type u} [category C] {J : Type v} [small_category J]\n    (F : J ⥤ C) [has_limit (discrete.functor (functor.obj F))]\n    [has_limit\n        (discrete.functor\n          fun (f : sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p) =>\n            functor.obj F (prod.snd (sigma.fst f)))]\n    [has_equalizers C] : has_limit F :=\n  sorry\n\n/--\nAny category with products and equalizers has all limits.\n\nSee https://stacks.math.columbia.edu/tag/002N.\n-/\ntheorem limits_from_equalizers_and_products {C : Type u} [category C] [has_products C]\n    [has_equalizers C] : has_limits C :=\n  has_limits.mk\n    fun (J : Type v) (𝒥 : small_category J) =>\n      has_limits_of_shape.mk fun (F : J ⥤ C) => has_limit_of_equalizer_and_product F\n\n/--\nAny category with finite products and equalizers has all finite limits.\n\nSee https://stacks.math.columbia.edu/tag/002O.\n-/\ntheorem finite_limits_from_equalizers_and_finite_products {C : Type u} [category C]\n    [has_finite_products C] [has_equalizers C] : has_finite_limits C :=\n  fun (J : Type v) (_x : small_category J) (_x_1 : fin_category J) =>\n    has_limits_of_shape.mk fun (F : J ⥤ C) => has_limit_of_equalizer_and_product F\n\n/-- If a functor preserves equalizers and the appropriate products, it preserves limits. -/\ndef preserves_limit_of_preserves_equalizers_and_product {C : Type u} [category C] {J : Type v}\n    [small_category J] {D : Type u₂} [category D] [has_limits_of_shape (discrete J) C]\n    [has_limits_of_shape (discrete (sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p)) C]\n    [has_equalizers C] (G : C ⥤ D) [preserves_limits_of_shape walking_parallel_pair G]\n    [preserves_limits_of_shape (discrete J) G]\n    [preserves_limits_of_shape (discrete (sigma fun (p : J × J) => prod.fst p ⟶ prod.snd p)) G] :\n    preserves_limits_of_shape J G :=\n  sorry\n\n/-- If G preserves equalizers and finite products, it preserves finite limits. -/\ndef preserves_finite_limits_of_preserves_equalizers_and_finite_products {C : Type u} [category C]\n    {D : Type u₂} [category D] [has_equalizers C] [has_finite_products C] (G : C ⥤ D)\n    [preserves_limits_of_shape walking_parallel_pair G]\n    [(J : Type v) → [_inst_8 : fintype J] → preserves_limits_of_shape (discrete J) G] (J : Type v)\n    [small_category J] [fin_category J] : preserves_limits_of_shape J G :=\n  preserves_limit_of_preserves_equalizers_and_product G\n\n/-- If G preserves equalizers and products, it preserves all limits. -/\ndef preserves_limits_of_preserves_equalizers_and_products {C : Type u} [category C] {D : Type u₂}\n    [category D] [has_equalizers C] [has_products C] (G : C ⥤ D)\n    [preserves_limits_of_shape walking_parallel_pair G]\n    [(J : Type v) → preserves_limits_of_shape (discrete J) G] : preserves_limits G :=\n  preserves_limits.mk\n    fun (J : Type v) (𝒥 : small_category J) => preserves_limit_of_preserves_equalizers_and_product G\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/constructions/limits_of_products_and_equalizers_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.46990850067784073}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.functor_category\nimport Mathlib.category_theory.isomorphism\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ u₃ v₃ \n\nnamespace Mathlib\n\n/-!\n# Natural isomorphisms\n\nFor the most part, natural isomorphisms are just another sort of isomorphism.\n\nWe provide some special support for extracting components:\n* if `α : F ≅ G`, then `a.app X : F.obj X ≅ G.obj X`,\nand building natural isomorphisms from components:\n*\n```\nnat_iso.of_components\n  (app : ∀ X : C, F.obj X ≅ G.obj X)\n  (naturality : ∀ {X Y : C} (f : X ⟶ Y), F.map f ≫ (app Y).hom = (app X).hom ≫ G.map f) :\nF ≅ G\n```\nonly needing to check naturality in one direction.\n\n## Implementation\n\nNote that `nat_iso` is a namespace without a corresponding definition;\nwe put some declarations that are specifically about natural isomorphisms in the `iso`\nnamespace so that they are available using dot notation.\n-/\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\n\nnamespace category_theory\n\n\nnamespace iso\n\n\n/-- The application of a natural isomorphism to an object. We put this definition in a different\nnamespace, so that we can use `α.app` -/\n@[simp] theorem app_hom {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) : hom (app α X) = nat_trans.app (hom α) X :=\n  Eq.refl (hom (app α X))\n\n@[simp] theorem hom_inv_id_app_assoc {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) {X' : D} (f' : functor.obj F X ⟶ X') : nat_trans.app (hom α) X ≫ nat_trans.app (inv α) X ≫ f' = f' := sorry\n\n@[simp] theorem inv_hom_id_app_assoc {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) {X' : D} (f' : functor.obj G X ⟶ X') : nat_trans.app (inv α) X ≫ nat_trans.app (hom α) X ≫ f' = f' := sorry\n\nend iso\n\n\nnamespace nat_iso\n\n\n@[simp] theorem trans_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} {H : C ⥤ D} (α : F ≅ G) (β : G ≅ H) (X : C) : iso.app (α ≪≫ β) X = iso.app α X ≪≫ iso.app β X :=\n  rfl\n\ntheorem app_hom {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) : iso.hom (iso.app α X) = nat_trans.app (iso.hom α) X :=\n  rfl\n\ntheorem app_inv {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) : iso.inv (iso.app α X) = nat_trans.app (iso.inv α) X :=\n  rfl\n\nprotected instance hom_app_is_iso {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) : is_iso (nat_trans.app (iso.hom α) X) :=\n  is_iso.mk (nat_trans.app (iso.inv α) X)\n\nprotected instance inv_app_is_iso {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) (X : C) : is_iso (nat_trans.app (iso.inv α) X) :=\n  is_iso.mk (nat_trans.app (iso.hom α) X)\n\n/-!\nUnfortunately we need a separate set of cancellation lemmas for components of natural isomorphisms,\nbecause the `simp` normal form is `α.hom.app X`, rather than `α.app.hom X`.\n\n(With the later, the morphism would be visibly part of an isomorphism, so general lemmas about\nisomorphisms would apply.)\n\nIn the future, we should consider a redesign that changes this simp norm form,\nbut for now it breaks too many proofs.\n-/\n\n@[simp] theorem cancel_nat_iso_hom_left {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : C} {Z : D} (g : functor.obj G X ⟶ Z) (g' : functor.obj G X ⟶ Z) : nat_trans.app (iso.hom α) X ≫ g = nat_trans.app (iso.hom α) X ≫ g' ↔ g = g' := sorry\n\n@[simp] theorem cancel_nat_iso_inv_left {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : C} {Z : D} (g : functor.obj F X ⟶ Z) (g' : functor.obj F X ⟶ Z) : nat_trans.app (iso.inv α) X ≫ g = nat_trans.app (iso.inv α) X ≫ g' ↔ g = g' := sorry\n\n@[simp] theorem cancel_nat_iso_hom_right {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : D} {Y : C} (f : X ⟶ functor.obj F Y) (f' : X ⟶ functor.obj F Y) : f ≫ nat_trans.app (iso.hom α) Y = f' ≫ nat_trans.app (iso.hom α) Y ↔ f = f' := sorry\n\n@[simp] theorem cancel_nat_iso_inv_right {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {X : D} {Y : C} (f : X ⟶ functor.obj G Y) (f' : X ⟶ functor.obj G Y) : f ≫ nat_trans.app (iso.inv α) Y = f' ≫ nat_trans.app (iso.inv α) Y ↔ f = f' := sorry\n\n@[simp] theorem cancel_nat_iso_hom_right_assoc {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {W : D} {X : D} {X' : D} {Y : C} (f : W ⟶ X) (g : X ⟶ functor.obj F Y) (f' : W ⟶ X') (g' : X' ⟶ functor.obj F Y) : f ≫ g ≫ nat_trans.app (iso.hom α) Y = f' ≫ g' ≫ nat_trans.app (iso.hom α) Y ↔ f ≫ g = f' ≫ g' := sorry\n\n@[simp] theorem cancel_nat_iso_inv_right_assoc {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ≅ G) {W : D} {X : D} {X' : D} {Y : C} (f : W ⟶ X) (g : X ⟶ functor.obj G Y) (f' : W ⟶ X') (g' : X' ⟶ functor.obj G Y) : f ≫ g ≫ nat_trans.app (iso.inv α) Y = f' ≫ g' ≫ nat_trans.app (iso.inv α) Y ↔ f ≫ g = f' ≫ g' := sorry\n\ntheorem naturality_1 {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} {X : C} {Y : C} (α : F ≅ G) (f : X ⟶ Y) : nat_trans.app (iso.inv α) X ≫ functor.map F f ≫ nat_trans.app (iso.hom α) Y = functor.map G f := sorry\n\ntheorem naturality_2 {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} {X : C} {Y : C} (α : F ≅ G) (f : X ⟶ Y) : nat_trans.app (iso.hom α) X ≫ functor.map G f ≫ nat_trans.app (iso.inv α) Y = functor.map F f := sorry\n\n/--\nA natural transformation is an isomorphism if all its components are isomorphisms.\n-/\n-- Making this an instance would cause a typeclass inference loop with `is_iso_app_of_is_iso`.\n\ndef is_iso_of_is_iso_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ⟶ G) [(X : C) → is_iso (nat_trans.app α X)] : is_iso α :=\n  is_iso.mk (nat_trans.mk fun (X : C) => inv (nat_trans.app α X))\n\n/--\nThe components of a natural isomorphism are isomorphisms.\n-/\nprotected instance is_iso_app_of_is_iso {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (α : F ⟶ G) [is_iso α] (X : C) : is_iso (nat_trans.app α X) :=\n  is_iso.mk (nat_trans.app (inv α) X)\n\n/--\nConstruct a natural isomorphism between functors by giving object level isomorphisms,\nand checking naturality only in the forward direction.\n-/\ndef of_components {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (app : (X : C) → functor.obj F X ≅ functor.obj G X) (naturality : ∀ {X Y : C} (f : X ⟶ Y), functor.map F f ≫ iso.hom (app Y) = iso.hom (app X) ≫ functor.map G f) : F ≅ G :=\n  iso.mk (nat_trans.mk fun (X : C) => iso.hom (app X)) (inv (nat_trans.mk fun (X : C) => iso.hom (app X)))\n\n@[simp] theorem of_components.app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (app' : (X : C) → functor.obj F X ≅ functor.obj G X) (naturality : ∀ {X Y : C} (f : X ⟶ Y), functor.map F f ≫ iso.hom (app' Y) = iso.hom (app' X) ≫ functor.map G f) (X : C) : iso.app (of_components app' naturality) X = app' X :=\n  iso.ext (Eq.refl (iso.hom (iso.app (of_components app' naturality) X)))\n\n@[simp] theorem of_components.hom_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (app : (X : C) → functor.obj F X ≅ functor.obj G X) (naturality : ∀ {X Y : C} (f : X ⟶ Y), functor.map F f ≫ iso.hom (app Y) = iso.hom (app X) ≫ functor.map G f) (X : C) : nat_trans.app (iso.hom (of_components app naturality)) X = iso.hom (app X) :=\n  rfl\n\n@[simp] theorem of_components.inv_app {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D} {G : C ⥤ D} (app : (X : C) → functor.obj F X ≅ functor.obj G X) (naturality : ∀ {X Y : C} (f : X ⟶ Y), functor.map F f ≫ iso.hom (app Y) = iso.hom (app X) ≫ functor.map G f) (X : C) : nat_trans.app (iso.inv (of_components app naturality)) X = iso.inv (app X) :=\n  rfl\n\n/-- Horizontal composition of natural isomorphisms. -/\ndef hcomp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {F : C ⥤ D} {G : C ⥤ D} {H : D ⥤ E} {I : D ⥤ E} (α : F ≅ G) (β : H ≅ I) : F ⋙ H ≅ G ⋙ I :=\n  iso.mk (iso.hom α ◫ iso.hom β) (iso.inv α ◫ iso.inv β)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/natural_isomorphism.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4699084960407192}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\n\nimport measure_theory.measurable_space\n\n/-!\n# Sequence of measurable functions associated to a sequence of a.e.-measurable functions\n\nWe define here tools to prove statements about limits (infi, supr...) of sequences of\n`ae_measurable` functions.\nGiven a sequence of a.e.-measurable functions `f : ι → α → β` with hypothesis\n`hf : ∀ i, ae_measurable (f i) μ`, and a pointwise property `p : α → (ι → β) → Prop` such that we\nhave `hp : ∀ᵐ x ∂μ, p x (λ n, f n x)`, we define a sequence of measurable functions `ae_seq hf p`\nand a measurable set `ae_seq_set hf p`, such that\n* `μ (ae_seq_set hf p)ᶜ = 0`\n* `x ∈ ae_seq_set hf p → ∀ i : ι, ae_seq hf hp i x = f i x`\n* `x ∈ ae_seq_set hf p → p x (λ n, f n x)`\n-/\n\nopen measure_theory\nopen_locale classical\n\nvariables {ι : Sort*} {α β γ : Type*} [measurable_space α] [measurable_space β]\n  {f : ι → α → β} {μ : measure α} {p : α → (ι → β) → Prop}\n\n/-- If we have the additional hypothesis `∀ᵐ x ∂μ, p x (λ n, f n x)`, this is a measurable set\nwhose complement has measure 0 such that for all `x ∈ ae_seq_set`, `f i x` is equal to\n`(hf i).mk (f i) x` for all `i` and we have the pointwise property `p x (λ n, f n x)`. -/\ndef ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) (p : α → (ι → β) → Prop) : set α :=\n(to_measurable μ {x | (∀ i, f i x = (hf i).mk (f i) x) ∧ p x (λ n, f n x)}ᶜ)ᶜ\n\n/-- A sequence of measurable functions that are equal to `f` and verify property `p` on the\nmeasurable set `ae_seq_set hf p`. -/\nnoncomputable\ndef ae_seq (hf : ∀ i, ae_measurable (f i) μ) (p : α → (ι → β) → Prop) : ι → α → β :=\nλ i x, ite (x ∈ ae_seq_set hf p) ((hf i).mk (f i) x) (⟨f i x⟩ : nonempty β).some\n\nnamespace ae_seq\n\nsection mem_ae_seq_set\n\nlemma mk_eq_fun_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) {x : α}\n  (hx : x ∈ ae_seq_set hf p) (i : ι) :\n  (hf i).mk (f i) x = f i x :=\nbegin\n  have h_ss : ae_seq_set hf p ⊆ {x | ∀ i, f i x = (hf i).mk (f i) x},\n  { rw [ae_seq_set, ←compl_compl {x | ∀ i, f i x = (hf i).mk (f i) x}, set.compl_subset_compl],\n    refine set.subset.trans (set.compl_subset_compl.mpr (λ x h, _)) (subset_to_measurable _ _),\n    exact h.1, },\n  exact (h_ss hx i).symm,\nend\n\nlemma ae_seq_eq_mk_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) {x : α}\n  (hx : x ∈ ae_seq_set hf p) (i : ι) :\n  ae_seq hf p i x = (hf i).mk (f i) x :=\nby simp only [ae_seq, hx, if_true]\n\nlemma ae_seq_eq_fun_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ) {x : α}\n  (hx : x ∈ ae_seq_set hf p) (i : ι) :\n  ae_seq hf p i x = f i x :=\nby simp only [ae_seq_eq_mk_of_mem_ae_seq_set hf hx i, mk_eq_fun_of_mem_ae_seq_set hf hx i]\n\nlemma prop_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ)\n  {x : α} (hx : x ∈ ae_seq_set hf p) :\n  p x (λ n, ae_seq hf p n x) :=\nbegin\n  simp only [ae_seq, hx, if_true],\n  rw funext (λ n, mk_eq_fun_of_mem_ae_seq_set hf hx n),\n  have h_ss : ae_seq_set hf p ⊆ {x | p x (λ n, f n x)},\n  { rw [←compl_compl {x | p x (λ n, f n x)}, ae_seq_set, set.compl_subset_compl],\n    refine set.subset.trans (set.compl_subset_compl.mpr _) (subset_to_measurable _ _),\n    exact λ x hx, hx.2, },\n  have hx' := set.mem_of_subset_of_mem h_ss hx,\n  exact hx',\nend\n\nlemma fun_prop_of_mem_ae_seq_set (hf : ∀ i, ae_measurable (f i) μ)\n  {x : α} (hx : x ∈ ae_seq_set hf p) :\n  p x (λ n, f n x) :=\nbegin\n  have h_eq : (λ n, f n x) = λ n, ae_seq hf p n x,\n    from funext (λ n, (ae_seq_eq_fun_of_mem_ae_seq_set hf hx n).symm),\n  rw h_eq,\n  exact prop_of_mem_ae_seq_set hf hx,\nend\n\nend mem_ae_seq_set\n\n\n\nlemma measurable (hf : ∀ i, ae_measurable (f i) μ) (p : α → (ι → β) → Prop)\n  (i : ι) :\n  measurable (ae_seq hf p i) :=\nmeasurable.ite ae_seq_set_measurable_set (hf i).measurable_mk $ measurable_const' $\n  λ x y, rfl\n\nlemma measure_compl_ae_seq_set_eq_zero [countable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  μ (ae_seq_set hf p)ᶜ = 0 :=\nbegin\n  rw [ae_seq_set, compl_compl, measure_to_measurable],\n  have hf_eq := λ i, (hf i).ae_eq_mk,\n  simp_rw [filter.eventually_eq, ←ae_all_iff] at hf_eq,\n  exact filter.eventually.and hf_eq hp,\nend\n\nlemma ae_seq_eq_mk_ae [countable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  ∀ᵐ (a : α) ∂μ, ∀ (i : ι), ae_seq hf p i a = (hf i).mk (f i) a :=\nbegin\n  have h_ss : ae_seq_set hf p ⊆ {a : α | ∀ i, ae_seq hf p i a = (hf i).mk (f i) a},\n    from λ x hx i, by simp only [ae_seq, hx, if_true],\n  exact le_antisymm (le_trans (measure_mono (set.compl_subset_compl.mpr h_ss))\n    (le_of_eq (measure_compl_ae_seq_set_eq_zero hf hp))) (zero_le _),\nend\n\nlemma ae_seq_eq_fun_ae [countable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  ∀ᵐ (a : α) ∂μ, ∀ (i : ι), ae_seq hf p i a = f i a :=\nbegin\n  have h_ss : {a : α | ¬∀ (i : ι), ae_seq hf p i a = f i a} ⊆ (ae_seq_set hf p)ᶜ,\n    from λ x, mt (λ hx i, (ae_seq_eq_fun_of_mem_ae_seq_set hf hx i)),\n  exact measure_mono_null h_ss (measure_compl_ae_seq_set_eq_zero hf hp),\nend\n\nlemma ae_seq_n_eq_fun_n_ae [countable ι] (hf : ∀ i, ae_measurable (f i) μ)\n  (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) (n : ι) :\n  ae_seq hf p n =ᵐ[μ] f n:=\nae_all_iff.mp (ae_seq_eq_fun_ae hf hp) n\n\nlemma supr [complete_lattice β] [countable ι]\n  (hf : ∀ i, ae_measurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x (λ n, f n x)) :\n  (⨆ n, ae_seq hf p n) =ᵐ[μ] ⨆ n, f n :=\nbegin\n  simp_rw [filter.eventually_eq, ae_iff, supr_apply],\n  have h_ss : ae_seq_set hf p ⊆ {a : α | (⨆ (i : ι), ae_seq hf p i a) = ⨆ (i : ι), f i a},\n  { intros x hx,\n    congr,\n    exact funext (λ i, ae_seq_eq_fun_of_mem_ae_seq_set hf hx i), },\n  exact measure_mono_null (set.compl_subset_compl.mpr h_ss)\n    (measure_compl_ae_seq_set_eq_zero hf hp),\nend\n\nend ae_seq\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/measure_theory/function/ae_measurable_sequence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.4699084960407192}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\nFree groups as a quotient over the reduction relation `a * x * x⁻¹ * b = a * b`.\n\nFirst we introduce the one step reduction relation\n  `free_group.red.step`:  w * x * x⁻¹ * v   ~>   w * v\nits reflexive transitive closure:\n  `free_group.red.trans`\nand proof that its join is an equivalence relation.\n\nThen we introduce `free_group α` as a quotient over `free_group.red.step`.\n-/\nimport logic.relation\nimport algebra.group algebra.group_power\nimport data.fintype data.list.basic data.quot\nimport group_theory.subgroup\nopen relation\nvariables {α : Type*}\n\nlocal attribute [simp] list.append_eq_has_append\n\nnamespace free_group\nvariables {L L₁ L₂ L₃ L₄ : list (α × bool)}\n\n/-- Reduction step: `w * x * x⁻¹ * v ~> w * v` -/\ninductive red.step : list (α × bool) → list (α × bool) → Prop\n| bnot {L₁ L₂ x b} : red.step (L₁ ++ (x, b) :: (x, bnot b) :: L₂) (L₁ ++ L₂)\nattribute [simp] red.step.bnot\n\n/-- Reflexive-transitive closure of red.step -/\ndef red : list (α × bool) → list (α × bool) → Prop := refl_trans_gen red.step\n\n@[refl] lemma red.refl : red L L := refl_trans_gen.refl\n@[trans] lemma red.trans : red L₁ L₂ → red L₂ L₃ → red L₁ L₃ := refl_trans_gen.trans\n\nnamespace red\n\n/-- Predicate asserting that word `w₁` can be reduced to `w₂` in one step, i.e. there are words\n`w₃ w₄` and letter `x` such that `w₁ = w₃xx⁻¹w₄` and `w₂ = w₃w₄`  -/\ntheorem step.length : ∀ {L₁ L₂ : list (α × bool)}, step L₁ L₂ → L₂.length + 2 = L₁.length\n| _ _ (@red.step.bnot _ L1 L2 x b) := by rw [list.length_append, list.length_append]; refl\n\n@[simp] lemma step.bnot_rev {x b} : step (L₁ ++ (x, bnot b) :: (x, b) :: L₂) (L₁ ++ L₂) :=\nby cases b; from step.bnot\n\n@[simp] lemma step.cons_bnot {x b} : red.step ((x, b) :: (x, bnot b) :: L) L :=\n@step.bnot _ [] _ _ _\n\n@[simp] lemma step.cons_bnot_rev {x b} : red.step ((x, bnot b) :: (x, b) :: L) L :=\n@red.step.bnot_rev _ [] _ _ _\n\ntheorem step.append_left : ∀ {L₁ L₂ L₃ : list (α × bool)}, step L₂ L₃ → step (L₁ ++ L₂) (L₁ ++ L₃)\n| _ _ _ red.step.bnot := by rw [← list.append_assoc, ← list.append_assoc]; constructor\n\ntheorem step.cons {x} (H : red.step L₁ L₂) : red.step (x :: L₁) (x :: L₂) :=\n@step.append_left _ [x] _ _ H\n\ntheorem step.append_right : ∀ {L₁ L₂ L₃ : list (α × bool)}, step L₁ L₂ → step (L₁ ++ L₃) (L₂ ++ L₃)\n| _ _ _ red.step.bnot := by simp\n\nlemma not_step_nil : ¬ step [] L :=\nbegin\n  generalize h' : [] = L',\n  assume h,\n  cases h with L₁ L₂,\n  simp [list.nil_eq_append_iff] at h',\n  contradiction\nend\n\nlemma step.cons_left_iff {a : α} {b : bool} :\n  step ((a, b) :: L₁) L₂ ↔ (∃L, step L₁ L ∧ L₂ = (a, b) :: L) ∨ (L₁ = (a, bnot b)::L₂) :=\nbegin\n  split,\n  { generalize hL : ((a, b) :: L₁ : list _) = L,\n    assume h,\n    rcases h with ⟨_ | ⟨p, s'⟩, e, a', b'⟩,\n    { simp at hL, simp [*] },\n    { simp at hL,\n      rcases hL with ⟨rfl, rfl⟩,\n      refine or.inl ⟨s' ++ e, step.bnot, _⟩,\n      simp } },\n  { assume h,\n    rcases h with ⟨L, h, rfl⟩ | rfl,\n    { exact step.cons h },\n    { exact step.cons_bnot } }\nend\n\nlemma not_step_singleton : ∀ {p : α × bool}, ¬ step [p] L\n| (a, b) := by simp [step.cons_left_iff, not_step_nil]\n\nlemma step.cons_cons_iff : ∀{p : α × bool}, step (p :: L₁) (p :: L₂) ↔ step L₁ L₂ :=\nby simp [step.cons_left_iff, iff_def, or_imp_distrib] {contextual := tt}\n\nlemma step.append_left_iff : ∀L, step (L ++ L₁) (L ++ L₂) ↔ step L₁ L₂\n| [] := by simp\n| (p :: l) := by simp [step.append_left_iff l, step.cons_cons_iff]\n\nprivate theorem step.diamond_aux : ∀ {L₁ L₂ L₃ L₄ : list (α × bool)} {x1 b1 x2 b2},\n  L₁ ++ (x1, b1) :: (x1, bnot b1) :: L₂ = L₃ ++ (x2, b2) :: (x2, bnot b2) :: L₄ →\n  L₁ ++ L₂ = L₃ ++ L₄ ∨ ∃ L₅, red.step (L₁ ++ L₂) L₅ ∧ red.step (L₃ ++ L₄) L₅\n| []        _ []        _ _ _ _ _ H := by injections; subst_vars; simp\n| []        _ [(x3,b3)] _ _ _ _ _ H := by injections; subst_vars; simp\n| [(x3,b3)] _ []        _ _ _ _ _ H := by injections; subst_vars; simp\n| []                     _ ((x3,b3)::(x4,b4)::tl) _ _ _ _ _ H :=\n  by injections; subst_vars; simp; right; exact ⟨_, red.step.bnot, red.step.cons_bnot⟩\n| ((x3,b3)::(x4,b4)::tl) _ []                     _ _ _ _ _ H :=\n  by injections; subst_vars; simp; right; exact ⟨_, red.step.cons_bnot, red.step.bnot⟩\n| ((x3,b3)::tl) _ ((x4,b4)::tl2) _ _ _ _ _ H :=\n  let ⟨H1, H2⟩ := list.cons.inj H in\n  match step.diamond_aux H2 with\n    | or.inl H3 := or.inl $ by simp [H1, H3]\n    | or.inr ⟨L₅, H3, H4⟩ := or.inr\n      ⟨_, step.cons H3, by simpa [H1] using step.cons H4⟩\n  end\n\ntheorem step.diamond : ∀ {L₁ L₂ L₃ L₄ : list (α × bool)},\n  red.step L₁ L₃ → red.step L₂ L₄ → L₁ = L₂ →\n  L₃ = L₄ ∨ ∃ L₅, red.step L₃ L₅ ∧ red.step L₄ L₅\n| _ _ _ _ red.step.bnot red.step.bnot H := step.diamond_aux H\n\nlemma step.to_red : step L₁ L₂ → red L₁ L₂ :=\nrefl_trans_gen.single\n\n/-- Church-Rosser theorem for word reduction: If `w1 w2 w3` are words such that `w1` reduces to `w2`\nand `w3` respectively, then there is a word `w4` such that `w2` and `w3` reduce to `w4` respectively. -/\ntheorem church_rosser : red L₁ L₂ → red L₁ L₃ → join red L₂ L₃ :=\nrelation.church_rosser (assume a b c hab hac,\nmatch b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := ⟨b, by refl, by refl⟩\n| b, c, or.inr ⟨d, hbd, hcd⟩ := ⟨d, refl_gen.single hbd, hcd.to_red⟩\nend)\n\nlemma cons_cons {p} : red L₁ L₂ → red (p :: L₁) (p :: L₂) :=\nrefl_trans_gen_lift (list.cons p) (assume a b, step.cons)\n\nlemma cons_cons_iff (p) : red (p :: L₁) (p :: L₂) ↔ red L₁ L₂ :=\niff.intro\n  begin\n    generalize eq₁ : (p :: L₁ : list _) = LL₁,\n    generalize eq₂ : (p :: L₂ : list _) = LL₂,\n    assume h,\n    induction h using relation.refl_trans_gen.head_induction_on\n      with L₁ L₂ h₁₂ h ih\n      generalizing L₁ L₂,\n    { subst_vars, cases eq₂, constructor },\n    { subst_vars,\n      cases p with a b,\n      rw [step.cons_left_iff] at h₁₂,\n      rcases h₁₂ with ⟨L, h₁₂, rfl⟩ | rfl,\n      { exact (ih rfl rfl).head h₁₂ },\n      { exact (cons_cons h).tail step.cons_bnot_rev } }\n  end\n  cons_cons\n\nlemma append_append_left_iff : ∀L, red (L ++ L₁) (L ++ L₂) ↔ red L₁ L₂\n| []       := iff.refl _\n| (p :: L) := by simp [append_append_left_iff L, cons_cons_iff]\n\nlemma append_append (h₁ : red L₁ L₃) (h₂ : red L₂ L₄) : red (L₁ ++ L₂) (L₃ ++ L₄) :=\n(refl_trans_gen_lift (λL, L ++ L₂) (assume a b, step.append_right) h₁).trans\n  ((append_append_left_iff _).2 h₂)\n\nlemma to_append_iff : red L (L₁ ++ L₂) ↔ (∃L₃ L₄, L = L₃ ++ L₄ ∧ red L₃ L₁ ∧ red L₄ L₂) :=\niff.intro\n  begin\n    generalize eq : L₁ ++ L₂ = L₁₂,\n    assume h,\n    induction h with L' L₁₂ hLL' h ih generalizing L₁ L₂,\n    { exact ⟨_, _, eq.symm, by refl, by refl⟩ },\n    { cases h with s e a b,\n      rcases list.append_eq_append_iff.1 eq with ⟨s', rfl, rfl⟩ | ⟨e', rfl, rfl⟩,\n      { have : L₁ ++ (s' ++ ((a, b) :: (a, bnot b) :: e)) = (L₁ ++ s') ++ ((a, b) :: (a, bnot b) :: e),\n        { simp },\n        rcases ih this with ⟨w₁, w₂, rfl, h₁, h₂⟩,\n        exact ⟨w₁, w₂, rfl, h₁, h₂.tail step.bnot⟩ },\n      { have : (s ++ ((a, b) :: (a, bnot b) :: e')) ++ L₂ = s ++ ((a, b) :: (a, bnot b) :: (e' ++ L₂)),\n        { simp },\n        rcases ih this with ⟨w₁, w₂, rfl, h₁, h₂⟩,\n        exact ⟨w₁, w₂, rfl, h₁.tail step.bnot, h₂⟩ }, }\n  end\n  (assume ⟨L₃, L₄, eq, h₃, h₄⟩, eq.symm ▸ append_append h₃ h₄)\n\n/-- The empty word `[]` only reduces to itself. -/\ntheorem nil_iff : red [] L ↔ L = [] :=\nrefl_trans_gen_iff_eq (assume l, red.not_step_nil)\n\n/-- A letter only reduces to itself. -/\ntheorem singleton_iff {x} : red [x] L₁ ↔ L₁ = [x] :=\nrefl_trans_gen_iff_eq (assume l, not_step_singleton)\n\n/-- If `x` is a letter and `w` is a word such that `xw` reduces to the empty word, then `w` reduces\nto `x⁻¹` -/\ntheorem cons_nil_iff_singleton {x b} : red ((x, b) :: L) [] ↔ red L [(x, bnot b)] :=\niff.intro\n  (assume h,\n    have h₁ : red ((x, bnot b) :: (x, b) :: L) [(x, bnot b)], from cons_cons h,\n    have h₂ : red ((x, bnot b) :: (x, b) :: L) L, from refl_trans_gen.single step.cons_bnot_rev,\n    let ⟨L', h₁, h₂⟩ := church_rosser h₁ h₂ in\n    by rw [singleton_iff] at h₁; subst L'; assumption)\n  (assume h, (cons_cons h).tail step.cons_bnot)\n\ntheorem red_iff_irreducible {x1 b1 x2 b2} (h : (x1, b1) ≠ (x2, b2)) :\n  red [(x1, bnot b1), (x2, b2)] L ↔ L = [(x1, bnot b1), (x2, b2)] :=\nbegin\n  apply refl_trans_gen_iff_eq,\n  generalize eq : [(x1, bnot b1), (x2, b2)] = L',\n  assume L h',\n  cases h',\n  simp [list.cons_eq_append_iff, list.nil_eq_append_iff] at eq,\n  rcases eq with ⟨rfl, ⟨rfl, rfl⟩, ⟨rfl, rfl⟩, rfl⟩, subst_vars,\n  simp at h,\n  contradiction\nend\n\n/-- If `x` and `y` are distinct letters and `w₁ w₂` are words such that `xw₁` reduces to `yw₂`, then\n`w₁` reduces to `x⁻¹yw₂`. -/\ntheorem inv_of_red_of_ne {x1 b1 x2 b2}\n  (H1 : (x1, b1) ≠ (x2, b2))\n  (H2 : red ((x1, b1) :: L₁) ((x2, b2) :: L₂)) :\n  red L₁ ((x1, bnot b1) :: (x2, b2) :: L₂) :=\nbegin\n  have : red ((x1, b1) :: L₁) ([(x2, b2)] ++ L₂), from H2,\n  rcases to_append_iff.1 this with ⟨_ | ⟨p, L₃⟩, L₄, eq, h₁, h₂⟩,\n  { simp [nil_iff] at h₁, contradiction },\n  { cases eq,\n    show red (L₃ ++ L₄) ([(x1, bnot b1), (x2, b2)] ++ L₂),\n    apply append_append _ h₂,\n    have h₁ : red ((x1, bnot b1) :: (x1, b1) :: L₃) [(x1, bnot b1), (x2, b2)],\n    { exact cons_cons h₁ },\n    have h₂ : red ((x1, bnot b1) :: (x1, b1) :: L₃) L₃,\n    { exact step.cons_bnot_rev.to_red },\n    rcases church_rosser h₁ h₂ with ⟨L', h₁, h₂⟩,\n    rw [red_iff_irreducible H1] at h₁,\n    rwa [h₁] at h₂ }\nend\n\ntheorem step.sublist (H : red.step L₁ L₂) : L₂ <+ L₁ :=\nby cases H; simp; constructor; constructor; refl\n\n/-- If `w₁ w₂` are words such that `w₁` reduces to `w₂`, then `w₂` is a sublist of `w₁`. -/\ntheorem sublist : red L₁ L₂ → L₂ <+ L₁ :=\nrefl_trans_gen_of_transitive_reflexive\n  (λl, list.sublist.refl l) (λa b c hab hbc, list.sublist.trans hbc hab) (λa b, red.step.sublist)\n\ntheorem sizeof_of_step : ∀ {L₁ L₂ : list (α × bool)}, step L₁ L₂ → L₂.sizeof < L₁.sizeof\n| _ _ (@step.bnot _ L1 L2 x b) :=\n  begin\n    induction L1 with hd tl ih,\n    case list.nil\n    { dsimp [list.sizeof],\n      have H : 1 + sizeof (x, b) + (1 + sizeof (x, bnot b) + list.sizeof L2)\n        = (list.sizeof L2 + 1) + (sizeof (x, b) + sizeof (x, bnot b) + 1),\n      { ac_refl },\n      rw H,\n      exact nat.le_add_right _ _ },\n    case list.cons\n    { dsimp [list.sizeof],\n      exact nat.add_lt_add_left ih _ }\n  end\n\ntheorem length (h : red L₁ L₂) : ∃ n, L₁.length = L₂.length + 2 * n :=\nbegin\n  induction h with L₂ L₃ h₁₂ h₂₃ ih,\n  { exact ⟨0, rfl⟩ },\n  { rcases ih with ⟨n, eq⟩,\n    existsi (1 + n),\n    simp [mul_add, eq, (step.length h₂₃).symm] }\nend\n\ntheorem antisymm (h₁₂ : red L₁ L₂) : red L₂ L₁ → L₁ = L₂ :=\nmatch L₁, h₁₂.cases_head with\n| _,  or.inl rfl            := assume h, rfl\n| L₁, or.inr ⟨L₃, h₁₃, h₃₂⟩ := assume h₂₁,\n  let ⟨n, eq⟩ := length (h₃₂.trans h₂₁) in\n  have list.length L₃ + 0 = list.length L₃ + (2 * n + 2),\n    by simpa [(step.length h₁₃).symm, add_comm, add_assoc] using eq,\n  (nat.no_confusion $ nat.add_left_cancel this)\nend\n\nend red\n\ntheorem equivalence_join_red : equivalence (join (@red α)) :=\nequivalence_join_refl_trans_gen $ assume a b c hab hac,\n(match b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := ⟨b, by refl, by refl⟩\n| b, c, or.inr ⟨d, hbd, hcd⟩ := ⟨d, refl_gen.single hbd, refl_trans_gen.single hcd⟩\nend)\n\ntheorem join_red_of_step (h : red.step L₁ L₂) : join red L₁ L₂ :=\njoin_of_single reflexive_refl_trans_gen h.to_red\n\ntheorem eqv_gen_step_iff_join_red : eqv_gen red.step L₁ L₂ ↔ join red L₁ L₂ :=\niff.intro\n  (assume h,\n    have eqv_gen (join red) L₁ L₂ := eqv_gen_mono (assume a b, join_red_of_step) h,\n    (eqv_gen_iff_of_equivalence $ equivalence_join_red).1 this)\n  (join_of_equivalence (eqv_gen.is_equivalence _) $ assume a b,\n    refl_trans_gen_of_equivalence (eqv_gen.is_equivalence _) eqv_gen.rel)\n\nend free_group\n\n/-- The free group over a type, i.e. the words formed by the elements of the type and their formal\ninverses, quotient by one step reduction. -/\ndef free_group (α : Type*) : Type* :=\nquot $ @free_group.red.step α\n\nnamespace free_group\n\nvariables {α} {L L₁ L₂ L₃ L₄ : list (α × bool)}\n\ndef mk (L) : free_group α := quot.mk red.step L\n\n@[simp] lemma quot_mk_eq_mk : quot.mk red.step L = mk L := rfl\n\n@[simp] lemma quot_lift_mk (β : Type*) (f : list (α × bool) → β)\n  (H : ∀ L₁ L₂, red.step L₁ L₂ → f L₁ = f L₂) :\nquot.lift f H (mk L) = f L := rfl\n\n@[simp] lemma quot_lift_on_mk (β : Type*) (f : list (α × bool) → β)\n  (H : ∀ L₁ L₂, red.step L₁ L₂ → f L₁ = f L₂) :\nquot.lift_on (mk L) f H = f L := rfl\n\ninstance : has_one (free_group α) := ⟨mk []⟩\nlemma one_eq_mk : (1 : free_group α) = mk [] := rfl\n\ninstance : has_mul (free_group α) :=\n⟨λ x y, quot.lift_on x\n    (λ L₁, quot.lift_on y (λ L₂, mk $ L₁ ++ L₂) (λ L₂ L₃ H, quot.sound $ red.step.append_left H))\n    (λ L₁ L₂ H, quot.induction_on y $ λ L₃, quot.sound $ red.step.append_right H)⟩\n@[simp] lemma mul_mk : mk L₁ * mk L₂ = mk (L₁ ++ L₂) := rfl\n\ninstance : has_inv (free_group α) :=\n⟨λx, quot.lift_on x (λ L, mk (L.map $ λ x : α × bool, (x.1, bnot x.2)).reverse)\n  (assume a b h, quot.sound $ by cases h; simp)⟩\n@[simp] lemma inv_mk : (mk L)⁻¹ = mk (L.map $ λ x : α × bool, (x.1, bnot x.2)).reverse := rfl\n\ninstance : group (free_group α) :=\n{ mul := (*),\n  one := 1,\n  inv := has_inv.inv,\n  mul_assoc := by rintros ⟨L₁⟩ ⟨L₂⟩ ⟨L₃⟩; simp,\n  one_mul := by rintros ⟨L⟩; refl,\n  mul_one := by rintros ⟨L⟩; simp [one_eq_mk],\n  mul_left_inv := by rintros ⟨L⟩; exact (list.rec_on L rfl $\n    λ ⟨x, b⟩ tl ih, eq.trans (quot.sound $ by simp [one_eq_mk]) ih) }\n\n/-- `of x` is the canonical injection from the type to the free group over that type by sending each\nelement to the equivalence class of the letter that is the element. -/\ndef of (x : α) : free_group α :=\nmk [(x, tt)]\n\ntheorem red.exact : mk L₁ = mk L₂ ↔ join red L₁ L₂ :=\ncalc (mk L₁ = mk L₂) ↔ eqv_gen red.step L₁ L₂ : iff.intro (quot.exact _) quot.eqv_gen_sound\n  ... ↔ join red L₁ L₂ : eqv_gen_step_iff_join_red\n\n/-- The canonical injection from the type to the free group is an injection. -/\ntheorem of.inj {x y : α} (H : of x = of y) : x = y :=\nlet ⟨L₁, hx, hy⟩ := red.exact.1 H in\nby simp [red.singleton_iff] at hx hy; cc\n\nsection to_group\n\nvariables {β : Type*} [group β] (f : α → β) {x y : free_group α}\n\ndef to_group.aux : list (α × bool) → β :=\nλ L, list.prod $ L.map $ λ x, cond x.2 (f x.1) (f x.1)⁻¹\n\ntheorem red.step.to_group {f : α → β} (H : red.step L₁ L₂) :\n  to_group.aux f L₁ = to_group.aux f L₂ :=\nby cases H with _ _ _ b; cases b; simp [to_group.aux]\n\n/-- If `β` is a group, then any function from `α` to `β`\nextends uniquely to a group homomorphism from\nthe free group over `α` to `β` -/\ndef to_group : free_group α → β :=\nquot.lift (to_group.aux f) $ λ L₁ L₂ H, red.step.to_group H\n\nvariable {f}\n\n@[simp] lemma to_group.mk : to_group f (mk L) =\n  list.prod (L.map $ λ x, cond x.2 (f x.1) (f x.1)⁻¹) :=\nrfl\n\n@[simp] lemma to_group.of {x} : to_group f (of x) = f x :=\none_mul _\n\ninstance to_group.is_group_hom : is_group_hom (to_group f) :=\n⟨by rintros ⟨L₁⟩ ⟨L₂⟩; simp⟩\n\n@[simp] lemma to_group.mul : to_group f (x * y) = to_group f x * to_group f y :=\nis_group_hom.mul _ _ _\n\n@[simp] lemma to_group.one : to_group f 1 = 1 :=\nis_group_hom.one _\n\n@[simp] lemma to_group.inv : to_group f x⁻¹ = (to_group f x)⁻¹ :=\nis_group_hom.inv _ _\n\ntheorem to_group.unique (g : free_group α → β) [is_group_hom g]\n  (hg : ∀ x, g (of x) = f x) : ∀{x}, g x = to_group f x :=\nby rintros ⟨L⟩; exact list.rec_on L (is_group_hom.one g)\n(λ ⟨x, b⟩ t (ih : g (mk t) = _), bool.rec_on b\n  (show g ((of x)⁻¹ * mk t) = to_group f (mk ((x, ff) :: t)),\n     by simp [is_group_hom.mul g, is_group_hom.inv g, hg, ih, to_group, to_group.aux])\n  (show g (of x * mk t) = to_group f (mk ((x, tt) :: t)),\n     by simp [is_group_hom.mul g, is_group_hom.inv g, hg, ih, to_group, to_group.aux]))\n\n\ntheorem to_group.of_eq (x : free_group α) : to_group of x = x :=\neq.symm $ to_group.unique id (λ x, rfl)\n\ntheorem to_group.range_subset {s : set β} [is_subgroup s] (H : set.range f ⊆ s) :\n  set.range (to_group f) ⊆ s :=\nby rintros _ ⟨⟨L⟩, rfl⟩; exact list.rec_on L (is_submonoid.one_mem s)\n(λ ⟨x, b⟩ tl ih, bool.rec_on b\n    (by simp at ih ⊢; from is_submonoid.mul_mem\n      (is_subgroup.inv_mem $ H ⟨x, rfl⟩) ih)\n    (by simp at ih ⊢; from is_submonoid.mul_mem (H ⟨x, rfl⟩) ih))\n\ntheorem to_group.range_eq_closure :\n  set.range (to_group f) = group.closure (set.range f) :=\nset.subset.antisymm\n  (to_group.range_subset group.subset_closure)\n  (group.closure_subset $ λ y ⟨x, hx⟩, ⟨of x, by simpa⟩)\n\nend to_group\n\nsection map\n\nvariables {β : Type*} (f : α → β) {x y : free_group α}\n\ndef map.aux (L : list (α × bool)) : list (β × bool) :=\nL.map $ λ x, (f x.1, x.2)\n\n/-- Any function from `α` to `β` extends uniquely\nto a group homomorphism from the free group\nver `α` to the free group over `β`. -/\ndef map (x : free_group α) : free_group β :=\nx.lift_on (λ L, mk $ map.aux f L) $\nλ L₁ L₂ H, quot.sound $ by cases H; simp [map.aux]\n\ninstance map.is_group_hom : is_group_hom (map f) :=\n⟨by rintros ⟨L₁⟩ ⟨L₂⟩; simp [map, map.aux]⟩\n\nvariable {f}\n\n@[simp] lemma map.mk : map f (mk L) = mk (L.map (λ x, (f x.1, x.2))) :=\nrfl\n\n@[simp] lemma map.id : map id x = x :=\nhave H1 : (λ (x : α × bool), x) = id := rfl,\nby rcases x with ⟨L⟩; simp [H1]\n\n@[simp] lemma map.id' : map (λ z, z) x = x := map.id\n\ntheorem map.comp {γ : Type*} {f : α → β} {g : β → γ} {x} :\n  map g (map f x) = map (g ∘ f) x :=\nby rcases x with ⟨L⟩; simp\n\n@[simp] lemma map.of {x} : map f (of x) = of (f x) := rfl\n\n@[simp] lemma map.mul : map f (x * y) = map f x * map f y :=\nis_group_hom.mul _ x y\n\n@[simp] lemma map.one : map f 1 = 1 :=\nis_group_hom.one _\n\n@[simp] lemma map.inv : map f x⁻¹ = (map f x)⁻¹ :=\nis_group_hom.inv _ x\n\ntheorem map.unique (g : free_group α → free_group β) [is_group_hom g]\n  (hg : ∀ x, g (of x) = of (f x)) : ∀{x}, g x = map f x :=\nby rintros ⟨L⟩; exact list.rec_on L (is_group_hom.one g)\n(λ ⟨x, b⟩ t (ih : g (mk t) = map f (mk t)), bool.rec_on b\n  (show g ((of x)⁻¹ * mk t) = map f ((of x)⁻¹ * mk t),\n     by simp [is_group_hom.mul g, is_group_hom.inv g, hg, ih])\n  (show g (of x * mk t) = map f (of x * mk t),\n     by simp [is_group_hom.mul g, hg, ih]))\n\n/-- Equivalent types give rise to equivalent free groups. -/\ndef free_group_congr {α β} (e : α ≃ β) : free_group α ≃ free_group β :=\n⟨map e, map e.symm,\n λ x, by simp [function.comp, map.comp],\n λ x, by simp [function.comp, map.comp]⟩\n\ntheorem map_eq_to_group : map f x = to_group (of ∘ f) x :=\neq.symm $ map.unique _ $ λ x, by simp\n\nend map\n\nsection prod\n\nvariables [group α] (x y : free_group α)\n\n/-- If `α` is a group, then any function from `α` to `α`\nextends uniquely to a homomorphism from the\nfree group over `α` to `α`. This is the multiplicative\nversion of `sum`. -/\ndef prod : α :=\nto_group id x\n\nvariables {x y}\n\n@[simp] lemma prod_mk :\n  prod (mk L) = list.prod (L.map $ λ x, cond x.2 x.1 x.1⁻¹) :=\nrfl\n\n@[simp] lemma prod.of {x : α} : prod (of x) = x :=\nto_group.of\n\ninstance prod.is_group_hom : is_group_hom (@prod α _) :=\nto_group.is_group_hom\n\n@[simp] lemma prod.mul : prod (x * y) = prod x * prod y :=\nto_group.mul\n\n@[simp] lemma prod.one : prod (1:free_group α) = 1 :=\nto_group.one\n\n@[simp] lemma prod.inv : prod x⁻¹ = (prod x)⁻¹ :=\nto_group.inv\n\nlemma prod.unique (g : free_group α → α) [is_group_hom g]\n  (hg : ∀ x, g (of x) = x) {x} :\n  g x = prod x :=\nto_group.unique g hg\n\nend prod\n\ntheorem to_group_eq_prod_map {β : Type*} [group β] {f : α → β} {x} :\n  to_group f x = prod (map f x) :=\neq.symm $ to_group.unique (prod ∘ map f) $ λ _, by simp\n\nsection sum\n\nvariables [add_group α] (x y : free_group α)\n\n/-- If `α` is a group, then any function from `α` to `α`\nextends uniquely to a homomorphism from the\nfree group over `α` to `α`. This is the additive\nversion of `prod`. -/\ndef sum : α :=\n@prod (multiplicative _) _ x\n\nvariables {x y}\n\n@[simp] lemma sum_mk :\n  sum (mk L) = list.sum (L.map $ λ x, cond x.2 x.1 (-x.1)) :=\nrfl\n\n@[simp] lemma sum.of {x : α} : sum (of x) = x :=\nprod.of\n\ninstance sum.is_group_hom : is_group_hom (@sum α _) :=\nprod.is_group_hom\n\n@[simp] lemma sum.sum : sum (x * y) = sum x + sum y :=\nprod.mul\n\n@[simp] lemma sum.one : sum (1:free_group α) = 0 :=\nprod.one\n\n@[simp] lemma sum.inv : sum x⁻¹ = -sum x :=\nprod.inv\n\nend sum\n\ndef free_group_empty_equiv_unit : free_group empty ≃ unit :=\n{ to_fun    := λ _, (),\n  inv_fun   := λ _, 1,\n  left_inv  := by rintros ⟨_ | ⟨⟨⟨⟩, _⟩, _⟩⟩; refl,\n  right_inv := λ ⟨⟩, rfl }\n\ndef free_group_unit_equiv_int : free_group unit ≃ int :=\n{ to_fun    := λ x, sum $ map (λ _, 1) x,\n  inv_fun   := λ x, of () ^ x,\n  left_inv  := by rintros ⟨L⟩; exact list.rec_on L rfl\n    (λ ⟨⟨⟩, b⟩ tl ih, by cases b; simp [gpow_add] at ih ⊢; rw ih; refl),\n  right_inv := λ x, int.induction_on x (by simp)\n    (λ i ih, by simp at ih; simp [gpow_add, ih])\n    (λ i ih, by simp at ih; simp [gpow_add, ih]) }\n\nsection reduce\n\nvariable [decidable_eq α]\n\n/-- The maximal reduction of a word. It is computable\niff `α` has decidable equality. -/\ndef reduce (L : list (α × bool)) : list (α × bool) :=\nlist.rec_on L [] $ λ hd1 tl1 ih,\nlist.cases_on ih [hd1] $ λ hd2 tl2,\nif hd1.1 = hd2.1 ∧ hd1.2 = bnot hd2.2 then tl2\nelse hd1 :: hd2 :: tl2\n\n@[simp] lemma reduce.cons (x) : reduce (x :: L) =\n  list.cases_on (reduce L) [x] (λ hd tl,\n  if x.1 = hd.1 ∧ x.2 = bnot hd.2 then tl\n  else x :: hd :: tl) := rfl\n\n/-- The first theorem that characterises the function\n`reduce`: a word reduces to its maximal reduction. -/\ntheorem reduce.red : red L (reduce L) :=\nbegin\n  induction L with hd1 tl1 ih,\n  case list.nil\n  { constructor },\n  case list.cons\n  { dsimp,\n    revert ih,\n    generalize htl : reduce tl1 = TL,\n    intro ih,\n    cases TL with hd2 tl2,\n    case list.nil\n    { exact red.cons_cons ih },\n    case list.cons\n    { dsimp,\n      by_cases h : hd1.fst = hd2.fst ∧ hd1.snd = bnot (hd2.snd),\n      { rw [if_pos h],\n        transitivity,\n        { exact red.cons_cons ih },\n        { cases hd1, cases hd2, cases h,\n          dsimp at *, subst_vars,\n          exact red.step.cons_bnot_rev.to_red } },\n      { rw [if_neg h],\n        exact red.cons_cons ih } } }\nend\n\ntheorem reduce.not {p : Prop} : ∀ {L₁ L₂ L₃ : list (α × bool)} {x b}, reduce L₁ = L₂ ++ (x, b) :: (x, bnot b) :: L₃ → p\n| [] L2 L3 _ _ := λ h, by cases L2; injections\n| ((x,b)::L1) L2 L3 x' b' := begin\n  dsimp,\n  cases r : reduce L1,\n  { dsimp, intro h,\n    have := congr_arg list.length h,\n    simp [-add_comm] at this,\n    exact absurd this dec_trivial },\n  cases hd with y c,\n  by_cases x = y ∧ b = bnot c; simp [h]; intro H,\n  { rw H at r,\n    exact @reduce.not L1 ((y,c)::L2) L3 x' b' r },\n  rcases L2 with _|⟨a, L2⟩,\n  { injections, subst_vars,\n    simp at h, cc },\n  { refine @reduce.not L1 L2 L3 x' b' _,\n    injection H with _ H,\n    rw [r, H], refl }\nend\n\n/-- The second theorem that characterises the\nfunction `reduce`: the maximal reduction of a word\nonly reduces to itself. -/\ntheorem reduce.min (H : red (reduce L₁) L₂) : reduce L₁ = L₂ :=\nbegin\n  induction H with L1 L' L2 H1 H2 ih,\n  { refl },\n  { cases H1 with L4 L5 x b,\n    exact reduce.not H2 }\nend\n\n/-- `reduce` is idempotent, i.e. the maximal reduction\nof the maximal reduction of a word is the maximal\nreduction of the word. -/\ntheorem reduce.idem : reduce (reduce L) = reduce L :=\neq.symm $ reduce.min reduce.red\n\ntheorem reduce.step.eq (H : red.step L₁ L₂) : reduce L₁ = reduce L₂ :=\nlet ⟨L₃, HR13, HR23⟩ := red.church_rosser reduce.red (reduce.red.head H) in\n(reduce.min HR13).trans (reduce.min HR23).symm\n\n/-- If a word reduces to another word, then they have\na common maximal reduction. -/\ntheorem reduce.eq_of_red (H : red L₁ L₂) : reduce L₁ = reduce L₂ :=\nlet ⟨L₃, HR13, HR23⟩ := red.church_rosser reduce.red (red.trans H reduce.red) in\n(reduce.min HR13).trans (reduce.min HR23).symm\n\n/-- If two words correspond to the same element in\nthe free group, then they have a common maximal\nreduction. This is the proof that the function that\nsends an element of the free group to its maximal\nreduction is well-defined. -/\ntheorem reduce.sound (H : mk L₁ = mk L₂) : reduce L₁ = reduce L₂ :=\nlet ⟨L₃, H13, H23⟩ := red.exact.1 H in\n(reduce.eq_of_red H13).trans (reduce.eq_of_red H23).symm\n\n/-- If two words have a common maximal reduction,\nthen they correspond to the same element in the free group. -/\ntheorem reduce.exact (H : reduce L₁ = reduce L₂) : mk L₁ = mk L₂ :=\nred.exact.2 ⟨reduce L₂, H ▸ reduce.red, reduce.red⟩\n\n/-- A word and its maximal reduction correspond to\nthe same element of the free group. -/\ntheorem reduce.self : mk (reduce L) = mk L :=\nreduce.exact reduce.idem\n\n/-- If words `w₁ w₂` are such that `w₁` reduces to `w₂`,\nthen `w₂` reduces to the maximal reduction of `w₁`. -/\ntheorem reduce.rev (H : red L₁ L₂) : red L₂ (reduce L₁) :=\n(reduce.eq_of_red H).symm ▸ reduce.red\n\n/-- The function that sends an element of the free\ngroup to its maximal reduction. -/\ndef to_word : free_group α → list (α × bool) :=\nquot.lift reduce $ λ L₁ L₂ H, reduce.step.eq H\n\ndef to_word.mk : ∀{x : free_group α}, mk (to_word x) = x :=\nby rintros ⟨L⟩; exact reduce.self\n\ndef to_word.inj : ∀(x y : free_group α), to_word x = to_word y → x = y :=\nby rintros ⟨L₁⟩ ⟨L₂⟩; exact reduce.exact\n\n/-- Constructive Church-Rosser theorem (compare `church_rosser`). -/\ndef reduce.church_rosser (H12 : red L₁ L₂) (H13 : red L₁ L₃) :\n  { L₄ // red L₂ L₄ ∧ red L₃ L₄ } :=\n⟨reduce L₁, reduce.rev H12, reduce.rev H13⟩\n\ninstance : decidable_eq (free_group α) :=\nfunction.injective.decidable_eq to_word.inj\n\ninstance red.decidable_rel : decidable_rel (@red α)\n| [] []          := is_true red.refl\n| [] (hd2::tl2)  := is_false $ λ H, list.no_confusion (red.nil_iff.1 H)\n| ((x,b)::tl) [] := match red.decidable_rel tl [(x, bnot b)] with\n  | is_true H  := is_true $ red.trans (red.cons_cons H) $\n    (@red.step.bnot _ [] [] _ _).to_red\n  | is_false H := is_false $ λ H2, H $ red.cons_nil_iff_singleton.1 H2\n  end\n| ((x1,b1)::tl1) ((x2,b2)::tl2) := if h : (x1, b1) = (x2, b2)\n  then match red.decidable_rel tl1 tl2 with\n    | is_true H  := is_true $ h ▸ red.cons_cons H\n    | is_false H := is_false $ λ H2, H $ h ▸ (red.cons_cons_iff _).1 $ H2\n    end\n  else match red.decidable_rel tl1 ((x1,bnot b1)::(x2,b2)::tl2) with\n    | is_true H  := is_true $ (red.cons_cons H).tail red.step.cons_bnot\n    | is_false H := is_false $ λ H2, H $ red.inv_of_red_of_ne h H2\n    end\n\n/-- A list containing every word that `w₁` reduces to. -/\ndef red.enum (L₁ : list (α × bool)) : list (list (α × bool)) :=\nlist.filter (λ L₂, red L₁ L₂) (list.sublists L₁)\n\ntheorem red.enum.sound (H : L₂ ∈ red.enum L₁) : red L₁ L₂ :=\nlist.of_mem_filter H\n\ntheorem red.enum.complete (H : red L₁ L₂) : L₂ ∈ red.enum L₁ :=\nlist.mem_filter_of_mem (list.mem_sublists.2 $ red.sublist H) H\n\ninstance : fintype { L₂ // red L₁ L₂ } :=\nfintype.subtype (list.to_finset $ red.enum L₁) $\nλ L₂, ⟨λ H, red.enum.sound $ list.mem_to_finset.1 H,\n  λ H, list.mem_to_finset.2 $ red.enum.complete H⟩\n\nend reduce\n\nend free_group\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/group_theory/free_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802735722128, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.46990849281732977}}
{"text": "import Mt.Utils.Fin\n\nnamespace Mt.Utils.List\n\ntheorem get_in {T : Type u} (l : List T) (idx : Fin l.length)\n  : (l.get idx) ∈ l :=match l, idx with\n  | a::_, ⟨0, _⟩ => List.Mem.head a _\n  | _::as, ⟨n + 1, isLt⟩ => List.Mem.tail _ <| get_in as ⟨n, Nat.le_of_succ_le_succ isLt⟩\n\ntheorem get_of_set {T : Type u} (l : List T) (idx : Nat) (a : T)\n  (isLt : idx < (l.set idx a).length)\n  : (l.set idx a).get ⟨idx, isLt⟩ = a :=match l, idx with\n  | _::_, 0 => rfl\n  | _::xs, n + 1 => get_of_set xs n a <| Nat.lt_of_succ_lt_succ isLt\n\ntheorem erase_subset {T : Type u} {a : T} (l : List T) (idx : Nat) \n  : a ∈ (l.eraseIdx idx) → a ∈ l :=match l, idx with\n  | [], _ => id\n  | x::xs, 0 => fun h => List.Mem.tail _ h\n  | x::xs, n+1 => by\n    intro h ; cases h\n    . exact List.Mem.head ..\n    . exact List.Mem.tail x <| erase_subset xs n (by assumption)\n\ntheorem set_subset {T : Type u} {a : T} (l : List T) (idx : Nat) (new_value : T)\n  : a ∈ (l.set idx new_value) → a = new_value ∨ a ∈ l :=match l, idx with\n  | [], _ => Or.inr\n  | x::xs, 0 => by\n    intro h ; cases h\n    . exact Or.inl rfl\n    . exact Or.inr <| List.Mem.tail _ (by assumption)\n  | x::xs, n+1 => by\n    intro h ; cases h\n    . exact Or.inr <| List.Mem.head ..\n    . cases set_subset xs n new_value (by assumption)\n      . exact Or.inl (by assumption)\n      . exact Or.inr <| List.Mem.tail _ (by assumption)\n\ntheorem index_exists {T : Type u} {a : T} (l : List T)\n  : a ∈ l → ∃ i : Fin l.length, l.get i = a :=fun a_in_l => match l, a_in_l with\n    | x::xs, a_in_l => by\n      cases a_in_l\n      . exists ⟨0, by simp_arith⟩\n      . apply (index_exists xs (by assumption)).elim\n        intro i xs_get_i\n        exists ⟨i.val + 1, by simp_arith only [List.length] ; exact i.isLt⟩\n\ntheorem erase_set {T : Type u} (l : List T) (idx : Nat) (new_value : T)\n  : (l.set idx new_value).eraseIdx idx = l.eraseIdx idx :=match l, idx with\n  | [], _ => rfl\n  | _::_, 0 => rfl\n  | x::xs, n+1 => congrArg (x :: .) <| erase_set xs n new_value\n\ntheorem eq_of_in_map {U V : Type u} {f : U -> V} {l : List U} {v : V}\n  : v ∈ (l.map f) → ∃ u, u ∈ l ∧ v = f u :=by\n  intro v_in_map\n  induction l\n  . contradiction\n  . rename_i head tail IH\n    cases v_in_map\n    . exact ⟨head, List.Mem.head .., rfl⟩\n    . rename_i v_in_map_of_tail\n      cases IH v_in_map_of_tail\n      rename_i u u_hyp\n      exact ⟨u, List.Mem.tail _ u_hyp.left, u_hyp.right⟩\n\ntheorem get_congr {T : Type u} {l l' : List T} (idx : Fin l.length)\n  (eq : l = l')\n  : l.get idx = l'.get (Fin.cast idx (congrArg _ eq)) :=Eq.rec\n    (motive :=λ l' eq => l.get idx = l'.get (Fin.cast idx (congrArg _ eq)))\n    rfl eq\n\ntheorem get_congr' {T : Type u} {l l' : List T}\n  {i : Fin l.length}\n  {j : Fin l'.length}\n  (l_eq : l = l')\n  (i_eq : i.val = j.val)\n  : l.get i = l'.get j :=by\n  have : j = Fin.cast i (congrArg _ l_eq) :=Fin.eq_of_val_eq i_eq.symm\n  rw [this]\n  exact get_congr _ l_eq\n\ntheorem get_of_map {U V : Type u} {f : U -> V} {l : List U}\n  {idx : Fin (l.map f).length}\n  : (l.map f).get idx = f (l.get (Fin.cast idx (List.length_map l f))) :=\n  match l, idx with\n  | head :: tail, ⟨0, isLt⟩ => rfl\n  | head :: tail, ⟨n + 1, isLt⟩ => by\n    simp only [List.map, List.get]\n    rw [get_of_map]\n    rfl\n\ntheorem set_map_commutes {U V : Type u} (f : U -> V) (l : List U)\n  (idx : Nat) (new_val : U) :\n  (l.set idx new_val).map f = (l.map f).set idx (f new_val) :=by\n  revert idx\n  induction l\n  . intros ; rfl\n  . rename_i head tail IH\n    intro idx\n    cases idx\n    . rfl\n    . simp only [List.set, List.map]\n      rename_i n\n      rw [IH n]\n\ntheorem erase_map_commutes {U V : Type u} (f : U -> V) (l : List U)\n  (idx : Nat) :\n  (l.eraseIdx idx).map f = (l.map f).eraseIdx idx :=by\n  revert idx\n  induction l\n  . intros ; rfl\n  . rename_i head tail IH\n    intro idx\n    cases idx\n    . rfl\n    . simp only [List.eraseIdx, List.map]\n      rename_i n\n      rw [IH n]\n\nend Mt.Utils.List", "meta": {"author": "mirkootter", "repo": "lean-mt", "sha": "027a16555d487e46a0a00611b8039655378dfdd5", "save_path": "github-repos/lean/mirkootter-lean-mt", "path": "github-repos/lean/mirkootter-lean-mt/lean-mt-027a16555d487e46a0a00611b8039655378dfdd5/Mt/Utils/List.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.4699084877089644}}
{"text": "/-\nCopyright (c) 2020 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot\n-/\nimport analysis.specific_limits.basic\n\n/-!\n# Hofer's lemma\n\nThis is an elementary lemma about complete metric spaces. It is motivated by an\napplication to the bubbling-off analysis for holomorphic curves in symplectic topology.\nWe are *very* far away from having these applications, but the proof here is a nice\nexample of a proof needing to construct a sequence by induction in the middle of the proof.\n\n## References:\n\n* H. Hofer and C. Viterbo, *The Weinstein conjecture in the presence of holomorphic spheres*\n-/\n\nopen_locale classical topology big_operators\nopen filter finset\n\nlocal notation `d` := dist\n\n@[simp] lemma pos_div_pow_pos {α : Type*} [linear_ordered_semifield α] {a b : α} (ha : 0 < a)\n  (hb : 0 < b) (k : ℕ) : 0 < a/b^k :=\ndiv_pos ha (pow_pos hb k)\n\nlemma hofer {X: Type*} [metric_space X] [complete_space X]\n  (x : X) (ε : ℝ) (ε_pos : 0 < ε)\n  {ϕ : X → ℝ} (cont : continuous ϕ) (nonneg : ∀ y, 0 ≤ ϕ y) :\n  ∃ (ε' > 0) (x' : X), ε' ≤ ε ∧\n                       d x' x ≤ 2*ε ∧\n                       ε * ϕ(x) ≤ ε' * ϕ x' ∧\n                       ∀ y, d x' y ≤ ε' → ϕ y ≤ 2*ϕ x' :=\nbegin\n  by_contradiction H,\n  have reformulation : ∀ x' (k : ℕ), ε * ϕ x ≤ ε / 2 ^ k * ϕ x' ↔ 2^k * ϕ x ≤ ϕ x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left ε_pos, mul_comm],\n    positivity },\n  -- Now let's specialize to `ε/2^k`\n  replace H : ∀ k : ℕ, ∀ x', d x' x ≤ 2 * ε ∧ 2^k * ϕ x ≤ ϕ x' →\n    ∃ y, d x' y ≤ ε/2^k ∧ 2 * ϕ x' < ϕ y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using H (ε/2^k) (by simp [ε_pos]) x' (by simp [ε_pos.le, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := ⟨x⟩,\n  choose! F hF using H,  -- Use the axiom of choice\n  -- Now define u by induction starting at x, with u_{n+1} = F(n, u_n)\n  let u : ℕ → X := λ n, nat.rec_on n x F,\n  have hu0 : u 0 = x := rfl,\n  -- The properties of F translate to properties of u\n  have hu :\n    ∀ n,\n      d (u n) x ≤ 2 * ε ∧ 2^n * ϕ x ≤ ϕ (u n) →\n      d (u n) (u $ n + 1) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u $ n + 1),\n  { intro n,\n    exact hF n (u n) },\n  clear hF,\n  -- Key properties of u, to be proven by induction\n  have key : ∀ n, d (u n) (u (n + 1)) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u (n + 1)),\n  { intro n,\n    induction n using nat.case_strong_induction_on with n IH,\n    { specialize hu 0,\n      simpa [hu0, mul_nonneg_iff, zero_le_one, ε_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x ≤ 2 * ε,\n    { rw [dist_comm],\n      let r := range (n+1), -- range (n+1) = {0, ..., n}\n      calc\n      d (u 0) (u (n + 1))\n          ≤ ∑ i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... ≤ ∑ i in r, ε/2^i             : sum_le_sum (λ i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = ∑ i in r, (1/2)^i*ε         : by { congr' with i, field_simp }\n      ... = (∑ i in r, (1/2)^i)*ε       : finset.sum_mul.symm\n      ... ≤ 2*ε                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt ε_pos), },\n    have B : 2^(n+1) * ϕ x ≤ ϕ (u (n + 1)),\n    { refine @geom_le (ϕ ∘ u) _ zero_le_two (n + 1) (λ m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) ⟨A, B⟩, },\n  cases forall_and_distrib.mp key with key₁ key₂,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ ε one_half_lt_one (λ n, _),\n    simpa only [one_div, inv_pow] using key₁ n },\n  -- So u converges to some y\n  obtain ⟨y, limy⟩ : ∃ y, tendsto u at_top (𝓝 y),\n    from complete_space.complete cauchy_u,\n  -- And ϕ ∘ u goes to +∞\n  have lim_top : tendsto (ϕ ∘ u) at_top at_top,\n  { let v := λ n, (ϕ ∘ u) (n+1),\n    suffices : tendsto v at_top at_top,\n      by rwa tendsto_add_at_top_iff_nat at this,\n    have hv₀ : 0 < v 0,\n    { have : 0 ≤ ϕ (u 0) := nonneg x,\n      calc 0 ≤ 2 * ϕ (u 0) : by linarith\n      ... < ϕ (u (0 + 1)) : key₂ 0 },\n    apply tendsto_at_top_of_geom_le hv₀ one_lt_two,\n    exact λ n, (key₂ (n+1)).le },\n  -- But ϕ ∘ u also needs to go to ϕ(y)\n  have lim : tendsto (ϕ ∘ u) at_top (𝓝 (ϕ y)),\n    from tendsto.comp cont.continuous_at limy,\n  -- So we have our contradiction!\n  exact not_tendsto_at_top_of_tendsto_nhds lim lim_top,\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/analysis/hofer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6688802669716106, "lm_q1q2_score": 0.46990848401433083}}
{"text": "import data.finset\nimport algebra.group.defs\nimport to_mathlib\nimport data.mv_polynomial\nimport Rings.Notation\nimport field_theory.subfield\nimport data.mv_polynomial.rename\nimport data.equiv.fin\nimport data.polynomial.algebra_map\nimport data.list\nimport Rings.ToMathlib.fin\n\nuniverses u v\n\nlemma with_bot.succ_lt_succ_succ {n : ℕ} : (n + 1 : with_bot ℕ) < ↑n.succ + 1 := by tidy\n\n-- More general version of monoid.has_pow\n-- instance has_pow_of_has_one_has_mul (A : Type u) [has_one A] [has_mul A] :\n--   has_pow A ℕ := ⟨ λ t k, npow_rec k t ⟩\n\nnamespace mv_polynomial\n  variables\n    {A B : Type*}\n    [comm_ring A] [comm_ring B] [algebra A B] {σ : Type*}\n\n  open dvector\n\n  noncomputable instance coe_mv_poly_A_to_mv_poly_B :\n  has_coe (mv_polynomial σ A) (mv_polynomial σ B) :=\n  ⟨ mv_polynomial.map (algebra_map A B)⟩\n\n  noncomputable instance coe_mv_poly_Z_to_mv_poly_A :\n  has_coe (mv_polynomial σ ℤ) (mv_polynomial σ A) :=\n  ⟨ mv_polynomial.map (int.cast_ring_hom A) ⟩\n\n  noncomputable instance coe_mv_poly_A_to_mv_poly_poly_A :\n  has_coe (mv_polynomial σ A) (mv_polynomial σ (polynomial A)) :=\n  ⟨ @mv_polynomial.map A (polynomial A) σ _ _ polynomial.C ⟩\n\n  @[simp] lemma coe_mv_poly_X {k : σ} :\n    ↑(mv_polynomial.X k : mv_polynomial σ ℤ) = (mv_polynomial.X k : mv_polynomial σ A) :=\n  begin unfold_coes, simp, end\n\n  @[simp] lemma coe_mv_poly_one : ↑ (1 : mv_polynomial σ ℤ) = (1 : mv_polynomial σ A) :=\n  begin unfold_coes, simp, end\n\n  @[simp] lemma coe_mv_poly_neg {t}: ↑ - (t : mv_polynomial σ ℤ) = - (↑t : mv_polynomial σ A) :=\n  begin unfold_coes, simp, end\n\n  @[simp] noncomputable def to_polynomial {n} (val : fin n → A)\n    (p : mv_polynomial (fin n.succ) A) :\n    polynomial A :=\n  mv_polynomial.eval (fin.x_val polynomial.X (polynomial.C ∘ val)) p\n\n  lemma eval_eq_poly_eval_mv_coeffs_X\n  {n : ℕ} {val : fin n → A} (x : A) : Π {k},\n    @mv_polynomial.eval A (fin n.succ) _ (fin.x_val x val) (mv_polynomial.X k)\n    = polynomial.eval x (to_polynomial val (mv_polynomial.X k)) :=\n  @fin.cases n\n  (λ k, @mv_polynomial.eval A (fin n.succ) _ (fin.x_val x val) (mv_polynomial.X k)\n    = polynomial.eval x (to_polynomial val (mv_polynomial.X k)))\n  (begin\n    simp only [mv_polynomial.eval_X, fin.cases_zero,\n      function.comp_app, fin.x_val, to_polynomial],\n    unfold_coes,\n    simp,\n  end)\n  (begin\n    simp only [mv_polynomial.eval_X, fin.cases_succ,\n      function.comp_app, fin.x_val, to_polynomial],\n    unfold_coes,\n    simp,\n  end)\n\n  lemma eval_eq_poly_eval_mv_coeffs\n  {n : ℕ} {p : mv_polynomial (fin n.succ) A} {val : fin n → A} (x : A) :\n    @mv_polynomial.eval A (fin n.succ) _ (fin.x_val x val) p\n    = polynomial.eval x (to_polynomial val p) :=\n  @mv_polynomial.induction_on A (fin n.succ) _\n    (λ q, @mv_polynomial.eval A (fin n.succ) _ (fin.x_val x val) q\n    = polynomial.eval x (to_polynomial val q))\n    p\n  (begin\n    intro a,\n    simp only [mv_polynomial.eval_C, function.comp_app, fin.x_val, to_polynomial],\n    unfold_coes,\n    simp,\n  end)\n  (begin\n    intros p q,\n    simp only [to_polynomial],\n    intros hp hq,\n    unfold_coes,\n    simp only [ring_hom.map_add, ring_hom.to_fun_eq_coe,\n    function.comp_app, fin.x_val, polynomial.eval_add],\n    simp only [ring_hom.to_fun_eq_coe, function.comp_app, fin.x_val] at hp hq,\n    rw [hp, hq],\n    refl,\n  end)\n  (begin\n    intros p k,\n    simp only [to_polynomial],\n    unfold_coes,\n    simp only [mv_polynomial.eval_X, ring_hom.to_fun_eq_coe,\n      function.comp_app, polynomial.eval_mul, fin.x_val, mv_polynomial.eval_map,\n      ring_hom.map_mul, mv_polynomial.map_X],\n    intro hp,\n    rw ← hp,\n    have hx := @mv_polynomial.eval_eq_poly_eval_mv_coeffs_X _ _ _ val x k,\n    simp only [mv_polynomial.eval_X, function.comp_app, fin.x_val, to_polynomial] at hx,\n    rw hx,\n    unfold_coes,\n    simp,\n  end)\n\n  lemma eval_add {val : σ → A} {p q : mv_polynomial σ A} :\n  mv_polynomial.eval val (p + q) = mv_polynomial.eval val p + mv_polynomial.eval val q :=\n  by simp\n\n\n  -- section equiv\n\n  /-- The algebra isomorphism between multivariable polynomials in no variables\n  and the ground ring. -/\n\n  -- LIBRARY ---- mv_polynomial.rename_equiv\n  --\n  -- variables {R : Type u} [comm_semiring R]\n\n  -- @[simp] noncomputable def var_equiv {σ τ : Type v} (hequiv : equiv σ τ) :\n  --   mv_polynomial σ R ≃ₐ[R] mv_polynomial τ R :=\n  -- let f : mv_polynomial σ R →+* mv_polynomial τ R :=\n  --     ring_hom.of (eval₂ C (λ s,X (hequiv.to_fun s))),\n  --     g : mv_polynomial τ R →+* mv_polynomial σ R :=\n  --     ring_hom.of (eval₂ C (λ s, X (hequiv.inv_fun s)))\n  -- in\n  -- { to_fun    := eval₂ C (λ s, X (hequiv.to_fun s)),\n  --   inv_fun   := eval₂ C (λ t, X (hequiv.inv_fun t)),\n  --   left_inv  :=\n  --   begin\n  --     show ∀ p, g.comp f p = p,\n  --     apply is_id,\n  --     { intro a, simp },\n  --     { intro n, simp }\n  --   end,\n  --   right_inv :=\n  --   begin\n  --     show ∀ p, f.comp g p = p,\n  --     apply is_id,\n  --     { intro a, simp },\n  --     { intro n, simp }\n  --   end,\n  --   map_mul'  := λ _ _, eval₂_mul _ _,\n  --   map_add'  := λ _ _, eval₂_add _ _,\n  --   commutes' := λ _, eval₂_C _ _ _ }\n  -- end equiv\n\n  lemma is_empty {R : Type u} {σ : Type v} [comm_ring R] (h : is_empty σ)\n    (f : mv_polynomial σ R) (as : σ → R) :\n    f = mv_polynomial.C (mv_polynomial.eval as f) :=\n  @mv_polynomial.induction_on R σ _\n  (λ p, p = mv_polynomial.C (mv_polynomial.eval as p))\n  f\n  (begin\n    intro a,\n    rw (mv_polynomial.C_inj R),\n    simp,\n  end)\n  (begin\n    intros p q hp hq,\n    rw [hp, hq],\n    simp,\n  end)\n  (\n  begin\n    intros p n hp,\n    apply is_empty.elim h n,\n  end\n  )\n\nend mv_polynomial\n\nnamespace zorn\n\nopen classical\nlocal attribute [instance] prop_decidable\n\n  lemma fin_range_sub_mem_chain_of_sub_union\n    {α : Type u} {c : set (set α)} (hchain : zorn.chain has_subset.subset c) (hc0 : c.nonempty) :\n    Π {n : ℕ} (F : fin n → α), (Π k, F k ∈ ⋃₀ c)\n      → ∃ (Y : set α), Y ∈ c ∧ (Π k, F k ∈ Y)\n  | nat.zero :=\n  begin\n    intros F hF,\n    cases hc0 with Y hY,\n    use Y,\n    split,\n    {exact hY},\n    {exact is_empty.elim fin.is_empty}\n  end\n  | (nat.succ n) :=\n  begin\n    intros Fsucc hFsucc,\n    have F : fin n → α := λ k, Fsucc (k.succ),\n    have hF : Π (k : fin n), Fsucc k.succ ∈ ⋃₀ c := λ k, hFsucc (fin.succ k),\n    cases fin_range_sub_mem_chain_of_sub_union (λk, Fsucc (k.succ)) hF with Y hY,\n    have h0cup : Fsucc 0 ∈ ⋃₀ c := hFsucc 0,\n    rw set.mem_sUnion at h0cup,\n    cases h0cup with Y0 hY0,\n    cases hY0 with hY0c hY0,\n    cases hY with hYc hY,\n    by_cases hYY0 : Y = Y0,\n    {\n      use Y,\n      split,\n      {exact hYc},\n      {\n        intro k,\n        apply @fin.cases n (λ l, Fsucc l ∈ Y),\n        {rw hYY0, exact hY0},\n        {intro i, apply hY i},\n      }\n    },\n    {\n      cases hchain Y hYc Y0 hY0c hYY0 with hsub hsub,\n      {\n        use Y0,\n        split,\n        {exact hY0c},\n        {\n          intro k,\n          apply @fin.cases n (λ l, Fsucc l ∈ Y0),\n          {exact hY0},\n          {intro i, apply hsub, apply hY i},\n        }\n      },\n      {\n        use Y,\n        split,\n        {exact hYc},\n        {\n          intro k,\n          apply @fin.cases n (λ l, Fsucc l ∈ Y),\n          {apply hsub, exact hY0},\n          {intro i, apply hY i},\n        },\n      },\n    }\n  end\n\n  lemma fin_sub_mem_chain_of_sub_union\n    {α : Type u} {c : set (set α)} (hchain : zorn.chain has_subset.subset c) (hc0 : c.nonempty) :\n    Π (F : finset α), (↑F ⊆ ⋃₀ c) → ∃ (Y : set α), Y ∈ c ∧ ↑F ⊆ Y :=\n  @finset.induction α (λ (F : finset α), (↑F ⊆ ⋃₀ c) → ∃ (Y : set α), Y ∈ c ∧ ↑F ⊆ Y)\n  _\n  (begin\n    intro h0sub,\n    cases hc0 with Y hY,\n    use Y,\n    split,\n    exact hY,\n    simp,\n  end)\n  (begin\n    intros a F haF hind hFasub,\n    have hacup : a ∈ ⋃₀ c,\n    {apply hFasub, simp},\n    rw set.mem_sUnion at hacup,\n    cases hacup with Z hZ,\n    cases hZ with hZc haZ,\n    have hFsub : ↑F ⊆ ⋃₀ c,\n    {apply set.subset.trans _ hFasub, simp},\n    have Y := (hind hFsub),\n    cases Y with Y hY,\n    by_cases hYZ : Y = Z,\n    {\n      use Y,\n      split,\n      {exact hY.1},\n      {\n        simp only [finset.coe_insert, set.insert_subset],\n        split,\n        {rw hYZ, exact haZ,},\n        {exact hY.2}\n      }\n    },\n    cases hY with hYc hFY,\n    cases hchain Y hYc Z hZc hYZ with hl hr,\n    {\n      use Z,\n      split,\n      {exact hZc},\n      simp only [finset.coe_insert, set.insert_subset],\n      split,\n      {exact haZ},\n      {exact set.subset.trans hFY hl},\n    },\n    {\n      use Y,\n      split,\n      {exact hYc},\n      {\n        simp only [finset.coe_insert, set.insert_subset],\n        split,\n        {exact hr haZ},\n        {exact hFY}\n      },\n    }\n  end)\n\nend zorn\n\nnamespace set\n  lemma union_sdiff {α : Type u} {B : set α} {x y} :\n    ¬x = y → (B ∪ {x}) \\ {y} = B \\ {y} ∪ {x} :=\n  begin\n    intro hxy,\n    apply set.ext,\n    intro b,\n    split,\n    {\n      intro hb,\n      by_cases hbx : b = x,\n      {\n        right,\n        simpa,\n      },\n      {\n        left,\n        split,\n        cases hb with hl hr,\n        cases hl,\n        {exact hl},\n        {exfalso, apply hbx, simpa using hl},\n        {exact hb.2},\n      },\n    },\n    {\n      intro hb,\n      cases hb,\n      {\n        split,\n        {left, exact hb.1},\n        {simpa using hb.2},\n      },\n      {\n        split,\n        {right, exact hb},\n        {intro hbot, apply hxy, tidy},\n      },\n    },\n  end\n\n\n  lemma remove_insert {α : Type u} {B : set α} {y} : y ∈ B → B \\ {y} ∪ {y} = B :=\n  begin\n    intro hyB,\n    apply set.ext,\n    intro b,\n    split,\n    {\n      intro hb,\n      cases hb,\n      {exact hb.1},\n      {rw set.mem_singleton_iff at hb, rw hb, exact hyB},\n    },\n    {\n      intro hbB,\n      by_cases hby : b = y,\n      {\n        rw hby,\n        right,\n        simp,\n      },\n      {\n        left,\n        split,\n        {exact hbB},\n        {simpa using hby},\n      },\n    },\n  end\n\n  lemma remove_insert_not_mem {α : Type u} {B : set α} {x} : x ∉ B → B = (B ∪ {x}) \\ {x} :=\n  begin\n    intro hxB,\n    simp only [set.mem_singleton, set.insert_diff_of_mem, set.union_singleton],\n    apply set.ext,\n    intro b,\n    split,\n    {\n      intro hb, split,\n      {exact hb},\n      {intro hbot,\n      rw set.mem_singleton_iff at hbot,\n      rw hbot at hb,\n      exact hxB hb,}\n    },\n    {intro hb, cases hb, cc},\n  end\nend set\n\nnamespace subfield\n\n  variables\n    (L : Type u) [field L]\n\n  -- lemma closure_subset (U V : set L) (hUV : U ⊆ V) :\n  --   (subfield.closure U : set L) ⊆ subfield.closure V :=\n  -- begin\n  --   simp only [set_like.coe_subset_coe, closure_le],\n  --   apply set.subset.trans hUV subset_closure,\n  -- end\n\nend subfield\n\n-- couldn't find in the library\ndef big_add {A : Type u} [has_add A] [has_zero A] : Π {n : ℕ}, (fin n → A) → A\n| nat.zero := 0\n| (nat.succ n) := λ as, (big_add (λ k : fin n, as k)) + as n\n\ndef big_mul {A : Type u} [has_mul A] [has_one A] : Π {n : ℕ}, (fin n → A) → A\n| nat.zero := 1\n| (nat.succ n) := λ as, (big_mul (λ k : fin n, as k)) * as n\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/Rings/ToMathlib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.46990847937720953}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Johannes Hölzl, Reid Barton, Sean Leather, Yury Kudryashov\n-/\nimport category_theory.types\nimport category_theory.functor.epi_mono\nimport category_theory.limits.constructions.epi_mono\n\n/-!\n# Concrete categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA concrete category is a category `C` with a fixed faithful functor\n`forget : C ⥤ Type*`.  We define concrete categories using `class\nconcrete_category`.  In particular, we impose no restrictions on the\ncarrier type `C`, so `Type` is a concrete category with the identity\nforgetful functor.\n\nEach concrete category `C` comes with a canonical faithful functor\n`forget C : C ⥤ Type*`.  We say that a concrete category `C` admits a\n*forgetful functor* to a concrete category `D`, if it has a functor\n`forget₂ C D : C ⥤ D` such that `(forget₂ C D) ⋙ (forget D) = forget C`,\nsee `class has_forget₂`.  Due to `faithful.div_comp`, it suffices\nto verify that `forget₂.obj` and `forget₂.map` agree with the equality\nabove; then `forget₂` will satisfy the functor laws automatically, see\n`has_forget₂.mk'`.\n\nTwo classes helping construct concrete categories in the two most\ncommon cases are provided in the files `bundled_hom` and\n`unbundled_hom`, see their documentation for details.\n\n## References\n\nSee [Ahrens and Lumsdaine, *Displayed Categories*][ahrens2017] for\nrelated work.\n-/\n\nuniverses w v v' u\n\nnamespace category_theory\n\nopen category_theory.limits\n\n/--\nA concrete category is a category `C` with a fixed faithful functor `forget : C ⥤ Type`.\n\nNote that `concrete_category` potentially depends on three independent universe levels,\n* the universe level `w` appearing in `forget : C ⥤ Type w`\n* the universe level `v` of the morphisms (i.e. we have a `category.{v} C`)\n* the universe level `u` of the objects (i.e `C : Type u`)\nThey are specified that order, to avoid unnecessary universe annotations.\n-/\nclass concrete_category (C : Type u) [category.{v} C] :=\n(forget [] : C ⥤ Type w)\n[forget_faithful : faithful forget]\n\nattribute [instance] concrete_category.forget_faithful\n\n/-- The forgetful functor from a concrete category to `Type u`. -/\n@[reducible] def forget (C : Type v) [category C] [concrete_category.{u} C] : C ⥤ Type u :=\nconcrete_category.forget C\n\ninstance concrete_category.types : concrete_category (Type u) :=\n{ forget := 𝟭 _ }\n\n/--\nProvide a coercion to `Type u` for a concrete category. This is not marked as an instance\nas it could potentially apply to every type, and so is too expensive in typeclass search.\n\nYou can use it on particular examples as:\n```\ninstance : has_coe_to_sort X := concrete_category.has_coe_to_sort X\n```\n-/\ndef concrete_category.has_coe_to_sort (C : Type v) [category C] [concrete_category C] :\n  has_coe_to_sort C (Type u) :=\n⟨(concrete_category.forget C).obj⟩\n\nsection\nlocal attribute [instance] concrete_category.has_coe_to_sort\n\nvariables {C : Type v} [category C] [concrete_category C]\n\n@[simp] lemma forget_obj_eq_coe {X : C} : (forget C).obj X = X := rfl\n\n/-- Usually a bundled hom structure already has a coercion to function\nthat works with different universes. So we don't use this as a global instance. -/\ndef concrete_category.has_coe_to_fun {X Y : C} : has_coe_to_fun (X ⟶ Y) (λ f, X → Y) :=\n⟨λ f, (forget _).map f⟩\n\nlocal attribute [instance] concrete_category.has_coe_to_fun\n\n/-- In any concrete category, we can test equality of morphisms by pointwise evaluations.-/\nlemma concrete_category.hom_ext {X Y : C} (f g : X ⟶ Y) (w : ∀ x : X, f x = g x) : f = g :=\nbegin\n  apply faithful.map_injective (forget C),\n  ext,\n  exact w x,\nend\n\n@[simp] lemma forget_map_eq_coe {X Y : C} (f : X ⟶ Y) : (forget C).map f = f := rfl\n\n/--\nAnalogue of `congr_fun h x`,\nwhen `h : f = g` is an equality between morphisms in a concrete category.\n-/\n\n\nlemma coe_id {X : C} : ((𝟙 X) : X → X) = id :=\n(forget _).map_id X\n\nlemma coe_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g : X → Z) = g ∘ f :=\n(forget _).map_comp f g\n\n@[simp] lemma id_apply {X : C} (x : X) : ((𝟙 X) : X → X) x = x :=\ncongr_fun ((forget _).map_id X) x\n\n@[simp] lemma comp_apply {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :\n  (f ≫ g) x = g (f x) :=\ncongr_fun ((forget _).map_comp _ _) x\n\nlemma concrete_category.congr_hom {X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x :=\ncongr_fun (congr_arg (λ f : X ⟶ Y, (f : X → Y)) h) x\n\nlemma concrete_category.congr_arg {X Y : C} (f : X ⟶ Y) {x x' : X} (h : x = x') : f x = f x' :=\ncongr_arg (f : X → Y) h\n\n/-- In any concrete category, injective morphisms are monomorphisms. -/\nlemma concrete_category.mono_of_injective {X Y : C} (f : X ⟶ Y) (i : function.injective f) :\n  mono f :=\n(forget C).mono_of_mono_map ((mono_iff_injective f).2 i)\n\nlemma concrete_category.injective_of_mono_of_preserves_pullback {X Y : C} (f : X ⟶ Y) [mono f]\n  [preserves_limits_of_shape walking_cospan (forget C)] : function.injective f :=\n(mono_iff_injective ((forget C).map f)).mp infer_instance\n\nlemma concrete_category.mono_iff_injective_of_preserves_pullback {X Y : C} (f : X ⟶ Y)\n  [preserves_limits_of_shape walking_cospan (forget C)] : mono f ↔ function.injective f :=\n((forget C).mono_map_iff_mono _).symm.trans (mono_iff_injective _)\n\n/-- In any concrete category, surjective morphisms are epimorphisms. -/\nlemma concrete_category.epi_of_surjective {X Y : C} (f : X ⟶ Y) (s : function.surjective f) :\n  epi f :=\n(forget C).epi_of_epi_map ((epi_iff_surjective f).2 s)\n\nlemma concrete_category.surjective_of_epi_of_preserves_pushout {X Y : C} (f : X ⟶ Y) [epi f]\n  [preserves_colimits_of_shape walking_span (forget C)] : function.surjective f :=\n(epi_iff_surjective ((forget C).map f)).mp infer_instance\n\nlemma concrete_category.epi_iff_surjective_of_preserves_pushout {X Y : C} (f : X ⟶ Y)\n  [preserves_colimits_of_shape walking_span (forget C)] : epi f ↔ function.surjective f :=\n((forget C).epi_map_iff_epi _).symm.trans (epi_iff_surjective _)\n\nlemma concrete_category.bijective_of_is_iso {X Y : C} (f : X ⟶ Y) [is_iso f] :\n  function.bijective ((forget C).map f) :=\nby { rw ← is_iso_iff_bijective, apply_instance, }\n\n@[simp] lemma concrete_category.has_coe_to_fun_Type {X Y : Type u} (f : X ⟶ Y) :\n  coe_fn f = f :=\nrfl\n\nend\n\n/--\n`has_forget₂ C D`, where `C` and `D` are both concrete categories, provides a functor\n`forget₂ C D : C ⥤ D` and a proof that `forget₂ ⋙ (forget D) = forget C`.\n-/\nclass has_forget₂ (C : Type v) (D : Type v') [category C] [concrete_category.{u} C] [category D]\n  [concrete_category.{u} D] :=\n(forget₂ : C ⥤ D)\n(forget_comp : forget₂ ⋙ (forget D) = forget C . obviously)\n\n/-- The forgetful functor `C ⥤ D` between concrete categories for which we have an instance\n`has_forget₂ C `. -/\n@[reducible] def forget₂ (C : Type v) (D : Type v') [category C] [concrete_category C] [category D]\n  [concrete_category D] [has_forget₂ C D] : C ⥤ D :=\nhas_forget₂.forget₂\n\ninstance forget₂_faithful (C : Type v) (D : Type v') [category C] [concrete_category C] [category D]\n  [concrete_category D] [has_forget₂ C D] : faithful (forget₂ C D) :=\nhas_forget₂.forget_comp.faithful_of_comp\n\ninstance forget₂_preserves_monomorphisms (C : Type v) (D : Type v') [category C]\n  [concrete_category C] [category D] [concrete_category D] [has_forget₂ C D]\n  [(forget C).preserves_monomorphisms] : (forget₂ C D).preserves_monomorphisms :=\nhave (forget₂ C D ⋙ forget D).preserves_monomorphisms,\n  by { simp only [has_forget₂.forget_comp], apply_instance },\nby exactI functor.preserves_monomorphisms_of_preserves_of_reflects _ (forget D)\n\ninstance forget₂_preserves_epimorphisms (C : Type v) (D : Type v') [category C]\n  [concrete_category C] [category D] [concrete_category D] [has_forget₂ C D]\n  [(forget C).preserves_epimorphisms] : (forget₂ C D).preserves_epimorphisms :=\nhave (forget₂ C D ⋙ forget D).preserves_epimorphisms,\n  by { simp only [has_forget₂.forget_comp], apply_instance },\nby exactI functor.preserves_epimorphisms_of_preserves_of_reflects _ (forget D)\n\ninstance induced_category.concrete_category {C : Type v} {D : Type v'} [category D]\n  [concrete_category D] (f : C → D) :\n  concrete_category (induced_category D f) :=\n{ forget := induced_functor f ⋙ forget D }\n\ninstance induced_category.has_forget₂ {C : Type v} {D : Type v'} [category D] [concrete_category D]\n  (f : C → D) :\n  has_forget₂ (induced_category D f) D :=\n{ forget₂ := induced_functor f,\n  forget_comp := rfl }\n\ninstance full_subcategory.concrete_category {C : Type v} [category C] [concrete_category C]\n  (Z : C → Prop) : concrete_category (full_subcategory Z) :=\n{ forget := full_subcategory_inclusion Z ⋙ forget C }\n\ninstance full_subcategory.has_forget₂ {C : Type v} [category C] [concrete_category C]\n  (Z : C → Prop) : has_forget₂ (full_subcategory Z) C :=\n{ forget₂ := full_subcategory_inclusion Z,\n  forget_comp := rfl }\n\n/--\nIn order to construct a “partially forgetting” functor, we do not need to verify functor laws;\nit suffices to ensure that compositions agree with `forget₂ C D ⋙ forget D = forget C`.\n-/\ndef has_forget₂.mk' {C : Type v} {D : Type v'} [category C] [concrete_category C] [category D]\n  [concrete_category D] (obj : C → D) (h_obj : ∀ X, (forget D).obj (obj X) = (forget C).obj X)\n  (map : Π {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))\n  (h_map : ∀ {X Y} {f : X ⟶ Y}, (forget D).map (map f) == (forget C).map f) :\nhas_forget₂ C D :=\n{ forget₂ := faithful.div _ _ _ @h_obj _ @h_map,\n  forget_comp := by apply faithful.div_comp }\n\n/-- Every forgetful functor factors through the identity functor. This is not a global instance as\n    it is prone to creating type class resolution loops. -/\ndef has_forget_to_Type (C : Type v) [category C] [concrete_category C] :\n  has_forget₂ C (Type u) :=\n{ forget₂ := forget C,\n  forget_comp := functor.comp_id _ }\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/concrete_category/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6688802537704064, "lm_q1q2_score": 0.46990847474008823}}
{"text": "/-\nCopyright (c) 2019 The Flypitch Project. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n\nAuthors: Jesse Han, Floris van Doorn\n-/\n/- theorems which we should (maybe) backport to mathlib -/\n\nimport algebra.ordered_group data.set.disjointed data.set.countable set_theory.cofinality\n       topology.opens --topology.maps\n       tactic\n       tactic.lint\n\nuniverse variables u v w w'\n\nnamespace function\nlemma injective.ne_iff {α β} {f : α → β} (hf : function.injective f) {a₁ a₂ : α} :\n  f a₁ ≠ f a₂ ↔ a₁ ≠ a₂ :=\nnot_congr hf.eq_iff\nend function\n\n\ninductive dvector (α : Type u) : ℕ → Type u\n| nil {} : dvector 0\n| cons : ∀{n} (x : α) (xs : dvector n), dvector (n+1)\n\ninductive dfin : ℕ → Type\n| fz {n} : dfin (n+1)\n| fs {n} : dfin n → dfin (n+1)\n\ninstance has_zero_dfin {n} : has_zero $ dfin (n+1) := ⟨dfin.fz⟩\n\n-- note from Mario --- use dfin to synergize with dvector\nnamespace dvector\nsection dvectors\nlocal notation h :: t  := dvector.cons h t\nlocal notation `[` l:(foldr `, ` (h t, dvector.cons h t) dvector.nil `]`) := l\nvariables {α : Type u} {β : Type v} {γ : Type w} {n : ℕ}\n\n@[simp] protected lemma zero_eq : ∀(xs : dvector α 0), xs = []\n| [] := rfl\n\n@[simp] protected def concat : ∀{n : ℕ} (xs : dvector α n) (x : α), dvector α (n+1)\n| _ []      x' := [x']\n| _ (x::xs) x' := x::concat xs x'\n\n@[simp] protected def nth : ∀{n : ℕ} (xs : dvector α n) (m : ℕ) (h : m < n), α\n| _ []      m     h := by { exfalso, exact nat.not_lt_zero m h }\n| _ (x::xs) 0     h := x\n| _ (x::xs) (m+1) h := nth xs m (lt_of_add_lt_add_right h)\n\nprotected lemma nth_cons {n : ℕ} (x : α) (xs : dvector α n) (m : ℕ) (h : m < n) :\n  dvector.nth (x::xs) (m+1) (nat.succ_lt_succ h) = dvector.nth xs m h :=\nby refl\n\n@[reducible, simp] protected def last {n : ℕ} (xs : dvector α (n+1)) : α :=\n  xs.nth n (by {repeat{constructor}})\n\nprotected def nth' {n : ℕ} (xs : dvector α n) (m : fin n) : α :=\nxs.nth m.1 m.2\n\nprotected def nth'' : ∀ {n : ℕ} (xs : dvector α n) (m : dfin n), α\n| _ (x::xs) dfin.fz       := x\n| _ (x::xs) (dfin.fs (m)) := nth'' xs m\n\nprotected def mem : ∀{n : ℕ} (x : α) (xs : dvector α n), Prop\n| _ x []       := false\n| _ x (x'::xs) := x = x' ∨ mem x xs\ninstance {n : ℕ} : has_mem α (dvector α n) := ⟨dvector.mem⟩\n\nprotected def pmem : ∀{n : ℕ} (x : α) (xs : dvector α n), Type\n| _ x []       := empty\n| _ x (x'::xs) := psum (x = x') (pmem x xs)\n\nprotected lemma mem_of_pmem : ∀{n : ℕ} {x : α} {xs : dvector α n} (hx : xs.pmem x), x ∈ xs\n| _ x []       hx := by cases hx\n| _ x (x'::xs) hx := by cases hx;[exact or.inl hx, exact or.inr (mem_of_pmem hx)]\n\n@[simp] protected def map (f : α → β) : ∀{n : ℕ}, dvector α n → dvector β n\n| _ []      := []\n| _ (x::xs) := f x :: map xs\n\n@[simp] protected def map2 (f : α → β → γ) : ∀{n : ℕ}, dvector α n → dvector β n → dvector γ n\n| _ []      []      := []\n| _ (x::xs) (y::ys) := f x y :: map2 xs ys\n\n@[simp] protected lemma map_id : ∀{n : ℕ} (xs : dvector α n), xs.map (λx, x) = xs\n| _ []      := rfl\n| _ (x::xs) := by { dsimp, simp* }\n\n@[simp] protected lemma map_congr_pmem {f g : α → β} :\n  ∀{n : ℕ} {xs : dvector α n} (h : ∀x, xs.pmem x → f x = g x), xs.map f = xs.map g\n| _ []      h := rfl\n| _ (x::xs) h :=\n  begin\n    dsimp, congr' 1, exact h x (psum.inl rfl), apply map_congr_pmem,\n    intros x hx, apply h, right, exact hx\n  end\n\n@[simp] protected lemma map_congr_mem {f g : α → β} {n : ℕ} {xs : dvector α n}\n  (h : ∀x, x ∈ xs → f x = g x) : xs.map f = xs.map g :=\ndvector.map_congr_pmem $ λx hx, h x $ dvector.mem_of_pmem hx\n\n@[simp] protected lemma map_congr {f g : α → β} (h : ∀x, f x = g x) :\n  ∀{n : ℕ} (xs : dvector α n), xs.map f = xs.map g\n| _ []      := rfl\n| _ (x::xs) := by { dsimp, simp* }\n\n@[simp] protected lemma map_map (g : β → γ) (f : α → β): ∀{n : ℕ} (xs : dvector α n),\n  (xs.map f).map g = xs.map (λx, g (f x))\n  | _ []      := rfl\n  | _ (x::xs) := by { dsimp, simp* }\n\nprotected lemma map_inj {f : α → β} (hf : ∀{{x x'}}, f x = f x' → x = x') {n : ℕ}\n  {xs xs' : dvector α n} (h : xs.map f = xs'.map f) : xs = xs' :=\nbegin\n  induction xs; cases xs', refl, simp at h, congr;[apply hf, apply xs_ih]; simp [h]\nend\n\n@[simp] protected lemma map_concat (f : α → β) : ∀{n : ℕ} (xs : dvector α n) (x : α),\n  (xs.concat x).map f = (xs.map f).concat (f x)\n| _ []      x' := by refl\n| _ (x::xs) x' := by { dsimp, congr' 1, exact map_concat xs x' }\n\n@[simp] protected lemma map_nth (f : α → β) : ∀{n : ℕ} (xs : dvector α n) (m : ℕ) (h : m < n),\n  (xs.map f).nth m h = f (xs.nth m h)\n| _ []      m     h := by { exfalso, exact nat.not_lt_zero m h }\n| _ (x::xs) 0     h := by refl\n| _ (x::xs) (m+1) h := by exact map_nth xs m _\n\nprotected lemma concat_nth : ∀{n : ℕ} (xs : dvector α n) (x : α) (m : ℕ) (h' : m < n+1)\n  (h : m < n), (xs.concat x).nth m h' = xs.nth m h\n| _ []      x' m     h' h := by { exfalso, exact nat.not_lt_zero m h }\n| _ (x::xs) x' 0     h' h := by refl\n| _ (x::xs) x' (m+1) h' h := by { dsimp, exact concat_nth xs x' m _ _ }\n\n@[simp] protected lemma concat_nth_last : ∀{n : ℕ} (xs : dvector α n) (x : α) (h : n < n+1),\n  (xs.concat x).nth n h = x\n| _ []      x' h := by refl\n| _ (x::xs) x' h := by { dsimp, exact concat_nth_last xs x' _ }\n\n@[simp] protected lemma concat_nth_last' : ∀{n : ℕ} (xs : dvector α n) (x : α) (h : n < n+1),\n  (xs.concat x).last = x\n:= by apply dvector.concat_nth_last\n\n@[simp] protected def append : ∀{n m : ℕ} (xs : dvector α n) (xs' : dvector α m), dvector α (m+n)\n| _ _ []       xs := xs\n| _ _ (x'::xs) xs' := x'::append xs xs'\n\n@[simp]protected def insert : ∀{n : ℕ} (x : α) (k : ℕ) (xs : dvector α n), dvector α (n+1)\n| n x 0 xs := (x::xs)\n| 0 x k xs := (x::xs)\n| (n+1) x (k+1) (y::ys) := (y::insert x k ys)\n\n@[simp] protected lemma insert_at_zero : ∀{n : ℕ} (x : α) (xs : dvector α n), dvector.insert x 0 xs = (x::xs) := by {intros, induction n; refl} -- why doesn't {intros, refl} work?\n\n@[simp] protected lemma insert_nth : ∀{n : ℕ} (x : α) (k : ℕ) (xs : dvector α n) (h : k < n+1), (dvector.insert x k xs).nth k h = x\n| 0 x k xs h := by {cases h, refl, exfalso, apply nat.not_lt_zero, exact h_a}\n| n x 0 xs h := by {induction n, refl, simp*}\n| (n+1) x (k+1) (y::ys) h := by simp*\n\nprotected lemma insert_cons {n k} {x y : α} {v : dvector α n} : (x::(v.insert y k)) = (x::v).insert y (k+1) :=\nby {induction v, refl, simp*}\n\n/- Given a proof that n ≤ m, return the nth initial segment of -/\n@[simp]protected def trunc : ∀ (n) {m : ℕ} (h : n ≤ m) (xs : dvector α m), dvector α n\n| 0 0 _ xs := []\n| 0 (m+1) _ xs := []\n| (n+1) 0 _ xs := by {exfalso, cases _x}\n| (n+1) (m+1) h (x::xs) := (x::@trunc n m (by { simp at h, exact h }) xs)\n\n@[simp]protected lemma trunc_n_n {n : ℕ} {h : n ≤ n} {v : dvector α n} : dvector.trunc n h v = v :=\n  by {induction v, refl, solve_by_elim}\n\n@[simp]protected lemma trunc_0_n {n : ℕ} {h : 0 ≤ n} {v : dvector α n} : dvector.trunc 0 h v = [] :=\n  by {induction v, refl, simp}\n\n@[simp]protected lemma trunc_nth {n m l: ℕ} {h : n ≤ m} {h' : l < n} {v : dvector α m} : (v.trunc n h).nth l h' = v.nth l (lt_of_lt_of_le h' h) :=\nbegin\n  induction m generalizing n l, have : n = 0, by cases h; simp, subst this, cases h',\n  cases n; cases l, {cases h'}, {cases h'}, {cases v, refl},\n  cases v, simp only [m_ih, dvector.nth, dvector.trunc]\nend\n\nprotected lemma nth_irrel1 : ∀{n k : ℕ} {h : k < n + 1} {h' : k < n + 1 + 1} (v : dvector α (n+1)) (x : α),\n  (x :: (v.trunc n (nat.le_succ n))).nth k h = (x::v).nth k h' :=\nby {intros, apply @dvector.trunc_nth _ _ _ _ (by {simp, exact dec_trivial}) h (x::v)}\n\nprotected def cast {n m} (p : n = m) : dvector α n → dvector α m :=\nby { subst p, exact id }\n\n@[simp] protected lemma cast_irrel {n m} {p p' : n = m} {v : dvector α n} : v.cast p = v.cast p' := by refl\n\n@[simp] protected lemma cast_rfl {n m} {p : n = m} {q : m = n} {v : dvector α n} : (v.cast p).cast q = v := by {subst p, refl}\n\nprotected lemma cast_hrfl {n m} {p : n = m} {v : dvector α n} : v.cast p == v :=\nby { subst p, refl }\n\n@[simp] protected lemma cast_trans {n m o} {p : n = m} {q : m = o} {v : dvector α n} : (v.cast p).cast q = v.cast (trans p q) :=\nby { subst p, subst q, refl }\n\n@[simp] lemma cast_cons {α} : ∀{n m} (h : n + 1 = m + 1) (x : α) (v : dvector α n),\n  (x::v).cast h = x :: v.cast (nat.succ_inj h) :=\nby { intros, cases h, refl }\n\n@[simp] lemma cast_append_nil {α} : ∀{n} (v : dvector α n) (h : 0 + n = n),\n  (v.append ([])).cast h = v\n| _ ([])   h := by refl\n| _ (x::v) h := by { simp only [true_and, dvector.append, cast_cons, eq_self_iff_true],\n  exact cast_append_nil v (by simp only [zero_add]) }\n\n@[simp] protected def remove_mth : ∀ {n : ℕ} (m : ℕ) (xs : dvector α (n+1)) , dvector α (n)\n  | 0 _ _  := dvector.nil\n  | n 0 (dvector.cons y ys) := ys\n  | (n+1) (k+1) (dvector.cons y ys) := dvector.cons y (remove_mth k ys)\n\n@[simp]protected def replace : ∀{n : ℕ} (x : α) (k : ℕ) (xs : dvector α n), dvector α (n)\n| n x 0 (y::ys) := (x::ys)\n| 0 x k ys := ys\n| (n+1) x (k+1) (y::ys) := (y::replace x k ys)\n\nprotected lemma insert_nth_lt {α} : ∀{n k l : ℕ} (x : α) (xs : dvector α n) (h : l < n)\n  (h' : l < n + 1) (h2 : l < k), (xs.insert x k).nth l h' = xs.nth l h\n| n     0     l     x xs h h' h2 := by cases h2\n| 0     (k+1) l     x xs h h' h2 := by cases h\n| (n+1) (k+1) 0     x (x'::xs) h h' h2 := by refl\n| (n+1) (k+1) (l+1) x (x'::xs) h h' h2 :=\n  by { simp, apply insert_nth_lt, apply nat.lt_of_succ_lt_succ h2 }\n\nprotected lemma insert_nth_gt' {α} : ∀{n k l : ℕ} (x : α) (xs : dvector α n) (h : l - 1 < n)\n  (h' : l < n + 1) (h2 : k < l), (xs.insert x k).nth l h' = xs.nth (l-1) h\n| n     0     0     x xs h h' h2 := by cases h2\n| n     0     (l+1) x xs h h' h2 := by { simp }\n| 0     (k+1) 0     x xs h h' h2 := by { cases h }\n| 0     (k+1) (l+1) x xs h h' h2 := by { cases h' with _ h', cases h' }\n| (n+1) (k+1) 0     x (x'::xs) h h' h2 := by cases h2\n| (n+1) (k+1) 1     x (x'::xs) h h' h2 := by { cases h2 with _ h2, cases h2 }\n| (n+1) (k+1) (l+2) x (x'::xs) h h' h2 :=\n  by { simp, convert insert_nth_gt' x xs _ _ _, apply nat.lt_of_succ_lt_succ h2 }\n\n@[simp] protected lemma insert_nth_gt_simp {α} : ∀{n k l : ℕ} (x : α) (xs : dvector α n)\n  (h' : l < n + 1)\n  (h2 : k < l), (xs.insert x k).nth l h' =\n  xs.nth (l-1) ((nat.sub_lt_right_iff_lt_add (nat.one_le_of_lt h2)).mpr h') :=\nλ n k l x xs h' h2, dvector.insert_nth_gt' x xs _ h' h2\n\nprotected lemma insert_nth_gt {α} : ∀{n k l : ℕ} (x : α) (xs : dvector α n) (h : l < n) (h' : l + 1 < n + 1)\n  (h2 : k < l + 1), (xs.insert x k).nth (l+1) h' = xs.nth l h :=\nλ n k l x xs h h' h2, dvector.insert_nth_gt' x xs h h' h2\n\n@[simp]lemma replace_head {n x z} {xs : dvector α n} : (x::xs).replace z 0 = z::xs := rfl\n\n@[simp]lemma replace_neck {n x y z} {xs : dvector α n} : (x::y::xs).replace z 1 = x::z::xs := rfl\n\n@[simp] def foldr (f : α → β → β) (b : β) : ∀{n}, dvector α n → β\n| _ []       := b\n| _ (a :: l) := f a (foldr l)\n\n@[simp] def zip : ∀{n}, dvector α n → dvector β n → dvector (α × β) n\n| _ [] []               := []\n| _ (x :: xs) (y :: ys) := ⟨x, y⟩ :: zip xs ys\n\nopen lattice\n/-- The finitary infimum -/\ndef fInf [semilattice_inf_top α] (xs : dvector α n) : α :=\nxs.foldr (λ(x b : α), x ⊓ b) ⊤\n\n@[simp] lemma fInf_nil [semilattice_inf_top α] : fInf [] = (⊤ : α) := by refl\n@[simp] lemma fInf_cons [semilattice_inf_top α] (x : α) (xs : dvector α n) :\n  fInf (x::xs) = x ⊓ fInf xs := by refl\n\n/-- The finitary supremum -/\ndef fSup [semilattice_sup_bot α] (xs : dvector α n) : α :=\nxs.foldr (λ(x b : α), x ⊔ b) ⊥\n\n@[simp] lemma fSup_nil [semilattice_sup_bot α] : fSup [] = (⊥ : α) := by refl\n@[simp] lemma fSup_cons [semilattice_sup_bot α] (x : α) (xs : dvector α n) :\n  fSup (x::xs) = x ⊔ fSup xs := by refl\n\n/- how to make this protected? -/\ninductive rel [setoid α] : ∀{n}, dvector α n → dvector α n → Prop\n| rnil : rel [] []\n| rcons {n} {x x' : α} {xs xs' : dvector α n} (hx : x ≈ x') (hxs : rel xs xs') :\n    rel (x::xs) (x'::xs')\nopen dvector.rel\n\nprotected lemma rel_refl [setoid α] : ∀{n} (xs : dvector α n), xs.rel xs\n| _ []      := rnil\n| _ (x::xs) := rcons (setoid.refl _) (rel_refl xs)\n\nprotected lemma rel_symm [setoid α] {n} {{xs xs' : dvector α n}} (h : xs.rel xs') : xs'.rel xs :=\nby { induction h; constructor, exact setoid.symm h_hx, exact h_ih }\n\nprotected lemma rel_trans [setoid α] {n} {{xs₁ xs₂ xs₃ : dvector α n}}\n  (h₁ : xs₁.rel xs₂) (h₂ : xs₂.rel xs₃) : xs₁.rel xs₃ :=\nbegin\n  induction h₁ generalizing h₂, exact h₂,\n  cases h₂, constructor, exact setoid.trans h₁_hx h₂_hx, exact h₁_ih h₂_hxs\nend\n\n-- protected def rel [setoid α] : ∀{n}, dvector α n → dvector α n → Prop\n-- | _ []      []        := true\n-- | _ (x::xs) (x'::xs') := x ≈ x' ∧ rel xs xs'\n\n-- protected def rel_refl [setoid α] : ∀{n} (xs : dvector α n), xs.rel xs\n-- | _ []      := trivial\n-- | _ (x::xs) := ⟨by refl, rel_refl xs⟩\n\n-- protected def rel_symm [setoid α] : ∀{n} {{xs xs' : dvector α n}}, xs.rel xs' → xs'.rel xs\n-- | _ []      []        h := trivial\n-- | _ (x::xs) (x'::xs') h := ⟨setoid.symm h.1, rel_symm h.2⟩\n\n-- protected def rel_trans [setoid α] : ∀{n} {{xs₁ xs₂ xs₃ : dvector α n}},\n--   xs₁.rel xs₂ → xs₂.rel xs₃ → xs₁.rel xs₃\n-- | _ []        []        []        h₁ h₂ := trivial\n-- | _ (x₁::xs₁) (x₂::xs₂) (x₃::xs₃) h₁ h₂ := ⟨setoid.trans h₁.1 h₂.1, rel_trans h₁.2 h₂.2⟩\n\ninstance setoid [setoid α] : setoid (dvector α n) :=\n⟨dvector.rel, dvector.rel_refl, dvector.rel_symm, dvector.rel_trans⟩\n\ndef quotient_lift {α : Type u} {β : Sort v} {R : setoid α} : ∀{n} (f : dvector α n → β)\n  (h : ∀{{xs xs'}}, xs ≈ xs' → f xs = f xs') (xs : dvector (quotient R) n), β\n| _     f h []      := f ([])\n| (n+1) f h (x::xs) :=\n  begin\n    refine quotient.lift\n      (λx, quotient_lift (λ xs, f $ x::xs) (λxs xs' hxs, h (rcons (setoid.refl x) hxs)) xs) _ x,\n    intros x x' hx, dsimp, congr, apply funext, intro xs, apply h, exact rcons hx xs.rel_refl\n  end\n\nlemma quotient_beta {α : Type u} {β : Sort v} {R : setoid α} {n} (f : dvector α n → β)\n  (h : ∀{{xs xs'}}, xs ≈ xs' → f xs = f xs') (xs : dvector α n) :\n  (xs.map quotient.mk).quotient_lift f h = f xs :=\nbegin\n  induction xs, refl, apply xs_ih\nend\nend dvectors\nend dvector\n\nnamespace set\nlemma disjoint_iff_eq_empty {α} {s t : set α} : disjoint s t ↔ s ∩ t = ∅ := disjoint_iff\n\n@[simp] lemma not_nonempty_iff {α} {s : set α} : ¬nonempty s ↔ s = ∅ :=\nby rw [coe_nonempty_iff_ne_empty, classical.not_not]\n\nlemma neq_neg_of_nonempty {α : Type*} {P : set α} (H_nonempty : nonempty α) : P ≠ - P :=\nbegin\n  intro H_eq, let a : α := classical.choice (by apply_instance),\n  have := congr_fun H_eq a,\n  classical, by_cases HP : P a,\n    {from absurd HP (by rwa this at HP)},\n    {from absurd (by rwa this) HP}\nend\n\n@[simp] lemma subset_bInter_iff {α β} {s : set α} {t : set β} {u : α → set β} :\n  t ⊆ (⋂ x ∈ s, u x) ↔ ∀ x ∈ s, t ⊆ u x :=\n⟨λ h x hx y hy, by { have := h hy, rw mem_bInter_iff at this, exact this x hx }, subset_bInter⟩\n\n@[simp] lemma subset_sInter_iff {α} {s : set α} {C : set (set α)} :\n  s ⊆ ⋂₀ C ↔ ∀ t ∈ C, s ⊆ t :=\nby simp [sInter_eq_bInter]\n\nlemma ne_empty_of_subset {α} {s t : set α} (h : s ⊆ t) (hs : s ≠ ∅) : t ≠ ∅ :=\nby { rw [set.ne_empty_iff_exists_mem] at hs ⊢, cases hs with x hx, exact ⟨x, h hx⟩ }\n\nend set\n\nsection topological_space\nopen lattice filter topological_space set\nvariables {α : Type u} {β : Type v} {ι : Type w} {π : ι → Type w'} [∀x, topological_space (π x)]\n\nvariables [t : topological_space α] [topological_space β]\n\nlemma subbasis_subset_basis {s : set (set α)} :\n  s \\ {∅} ⊆ ((λf, ⋂₀ f) '' {f:set (set α) | finite f ∧ f ⊆ s ∧ ⋂₀ f ≠ ∅}) :=\nbegin\n  intros o ho, refine ⟨{o}, ⟨finite_singleton o, _, _⟩, _⟩,\n  { rw [singleton_subset_iff], exact ho.1 },\n  { rw [sInter_singleton], refine mt mem_singleton_iff.mpr ho.2 },\n  dsimp only, rw [sInter_singleton]\nend\n\ninclude t\n\nlemma mem_opens {x : α} {o : opens α} : x ∈ o ↔ x ∈ o.1 := by refl\n\nlemma is_open_map_of_is_topological_basis {s : set (set α)}\n  (hs : is_topological_basis s) (f : α → β) (hf : ∀x ∈ s, is_open (f '' x)) :\n  is_open_map f :=\nbegin\n  intros o ho,\n  rcases Union_basis_of_is_open hs ho with ⟨γ, g, rfl, hg⟩,\n  rw [image_Union], apply is_open_Union, intro i, apply hf, apply hg\nend\n\nlemma interior_bInter_subset {β} {s : set β} (f : β → set α) :\n  interior (⋂i ∈ s, f i) ⊆ ⋂i ∈ s, interior (f i) :=\nbegin\n  intros x hx, rw [mem_interior] at hx, rcases hx with ⟨t, h1t, h2t, h3t⟩,\n  rw [subset_bInter_iff] at h1t,\n  rw [mem_bInter_iff], intros y hy, rw [mem_interior],\n  refine ⟨t, h1t y hy, h2t, h3t⟩\nend\n\nlemma nonempty_basis_subset {b : set (set α)}\n  (hb : is_topological_basis b) {u : set α} (hu : u ≠ ∅) (ou : _root_.is_open u) :\n  ∃v ∈ b, v ≠ ∅ ∧ v ⊆ u :=\nbegin\n  simp only [set.ne_empty_iff_exists_mem] at hu ⊢, cases hu with x hx,\n  rcases mem_basis_subset_of_mem_open hb hx ou with ⟨o, h1o, h2x, h2o⟩,\n  exact ⟨o, h1o, ⟨x, h2x⟩, h2o⟩\nend\n\nend topological_space\n\nnamespace ordinal\nvariable {σ : Type*}\n\ntheorem well_ordering_thm : ∃ (r : σ → σ → Prop), is_well_order σ r :=\n⟨_, (order_embedding.preimage embedding_to_cardinal (<)).is_well_order⟩\n\ntheorem enum_typein' {α : Type u} (r : α → α → Prop) [is_well_order α r] (a : α) :\n  enum r (typein r a) (typein_lt_type r a) = a :=\nenum_typein r a\n\nend ordinal\n\nnamespace cardinal\n\nsection cardinal_lemmas\n\nlocal prefix `#`:65 := cardinal.mk\n\ntheorem mk_union_le {α : Type u} {S T : set α} : mk (S ∪ T : set α) ≤ mk S + mk T :=\nby { rw [← mk_union_add_mk_inter], apply le_add_right }\n\n\nlemma exists_mem_compl_of_mk_lt_mk {α} (P : set α) (H_lt : cardinal.mk P  < cardinal.mk α) : ∃ x : α, x ∈ (- P) :=\nbegin\n  haveI : decidable (∃ (x : α), x ∈ - P) := classical.prop_decidable _,\n  by_contra, push_neg at a,\n  replace a := (by finish : ∀ x, x ∈ P),\n  suffices : mk α ≤ mk P ,\n    by {exact absurd H_lt (not_lt.mpr ‹_›)},\n  refine mk_le_of_injective _, from λ _, ⟨‹_›, a ‹_›⟩, tidy\nend\n\n@[simp]lemma mk_union_countable_of_countable {α} {P Q : set α} (HP : #P ≤ omega) (HQ : #Q ≤ omega) :\n  #((P ∪ Q : set α)) ≤ omega :=\nbegin\n  have this₁ := @mk_union_add_mk_inter _ (P) (Q),\n  transitivity (#↥(P ∪ Q)) + #↥(P ∩ Q),\n    { apply cardinal.le_add_right },\n    { rw[this₁], rw[<-(add_eq_self (by refl : cardinal.omega ≤ cardinal.omega))],\n      refine cardinal.add_le_add _ _; from ‹_› }\nend\n\nlemma nonzero_of_regular {κ : cardinal} (H_reg : cardinal.is_regular κ) : 0 < κ.ord :=\nby {rw cardinal.lt_ord, from lt_of_lt_of_le omega_pos H_reg.left}\n\nlemma injection_of_mk_le {α β : Type u} (H_le : #α ≤ #β) : ∃ f : α → β, function.injective f :=\nbegin\n  rw cardinal.out_embedding at H_le,\n  have := classical.choice H_le,\n  cases this with f Hf,\n  suffices : ∃ g₁ : α → quotient.out (#α), function.injective g₁ ∧ ∃ g₂ : quotient.out (#β) → β, function.injective g₂,\n    by {rcases this with ⟨g₁,Hg₁,g₂,Hg₂⟩, use g₂ ∘ f ∘ g₁, simp[function.injective_comp, *] },\n  have this₁ : #(quotient.out (#α)) = #α := mk_out _, have this₂ : #(quotient.out _) = #β := mk_out _,\n  erw quotient.eq' at this₁ this₂, replace this₁ := classical.choice this₁, replace this₂ := classical.choice this₂,\n  cases this₁, cases this₂,\n  refine ⟨this₁_inv_fun, _, this₂_to_fun, _⟩; apply function.injective_of_left_inverse; from ‹_›\nend\n\nend cardinal_lemmas\n\nend cardinal\n\n------------------------------------------------------- maybe not move to mathlib ------------------\n\n/- theorems which we should not backport to mathlib, because they are duplicates or which need to\n  be cleaned up first -/\n\nnamespace nat\nprotected lemma pred_lt_iff_lt_succ {m n : ℕ} (H : 1 ≤ m) : pred m < n ↔ m < succ n :=\nnat.sub_lt_right_iff_lt_add H\n\n@[simp]lemma le_of_le_and_ne_succ {x y : ℕ} (H : x ≤ y + 1) (H' : x ≠ y + 1) : x ≤ y :=\nby simp only [*, nat.lt_of_le_and_ne, nat.le_of_lt_succ, ne.def, not_false_iff]\n\nend nat\n\nnamespace tactic\nnamespace interactive\n/- maybe we should use congr' 1 instead? -/\nmeta def congr1 : tactic unit :=\ndo focus1 (congr_core >> all_goals (try reflexivity >> try assumption))\n\nopen interactive interactive.types\n\n/-- a variant of `exact` which elaborates its argument before unifying it with the target. This variant might succeed if `exact` fails because a lot of definitional reduction is needed to verify that the term has the correct type. Metavariables which are not synthesized become new subgoals. This is similar to have := q, exact this. Another approach to obtain (rougly) the same is `apply q` -/\nmeta def rexact (q : parse texpr) : tactic unit :=\ndo n ← mk_fresh_name,\np ← i_to_expr q,\ne ← note n none p,\ntactic.exact e\n\nend interactive\nend tactic\n\n/- logic -/\nnamespace classical\n\nnoncomputable def psigma_of_exists {α : Type u} {p : α → Prop} (h : ∃x, p x) : Σ' x, p x :=\nbegin\n  haveI : nonempty α := nonempty_of_exists h,\n  exact ⟨epsilon p, epsilon_spec h⟩\nend\n\n/- this is a special case of `some_spec2` -/\nlemma some_eq {α : Type u} {p : α → Prop} {h : ∃ (a : α), p a} (x : α)\n  (hx : ∀y, p y → y = x) : classical.some h = x :=\nclassical.some_spec2 _ hx\n\nlemma or_not_iff_true (p : Prop) : (p ∨ ¬ p) ↔ true :=\n⟨λ_, trivial, λ_, or_not⟩\n\nlemma nonempty_of_not_empty {α : Type u} (s : set α) (h : ¬ s = ∅) : nonempty s :=\nset.coe_nonempty_iff_ne_empty.mpr h\n\nlemma nonempty_of_not_empty_finset {α : Type u} (s : finset α) (h : ¬ s = ∅) : nonempty s.to_set :=\n(finset.nonempty_iff_ne_empty s).mpr h\n\nend classical\n\nnamespace list\n@[simp] protected def to_set {α : Type u} (l : list α) : set α := { x | x ∈ l }\n\nlemma to_set_map {α : Type u} {β : Type v} (f : α → β) (l : list α) :\n  (l.map f).to_set = f '' l.to_set :=\nby apply set.ext; intro b; simp [list.to_set]\n\nlemma exists_of_to_set_subset_image {α : Type u} {β : Type v} {f : α → β} {l : list β}\n  {t : set α} (h : l.to_set ⊆ f '' t) : ∃(l' : list α), l'.to_set ⊆ t ∧ map f l' = l :=\nbegin\n  induction l,\n  { exact ⟨[], set.empty_subset t, rfl⟩ },\n  { rcases h (mem_cons_self _ _) with ⟨x, hx, rfl⟩,\n    rcases l_ih (λx hx, h $ mem_cons_of_mem _ hx) with ⟨xs, hxs, hxs'⟩,\n    exact ⟨x::xs, set.union_subset (λy hy, by induction hy; exact hx) hxs, by simp*⟩ }\nend\n\nend list\n\nnamespace nat\n/- nat.sub_add_comm -/\nlemma add_sub_swap {n k : ℕ} (h : k ≤ n) (m : ℕ) : n + m - k = n - k + m :=\nby rw [add_comm, nat.add_sub_assoc h, add_comm]\n\nend nat\n\nlemma imp_eq_congr {a b c d : Prop} (h₁ : a = b) (h₂ : c = d) : (a → c) = (b → d) :=\nby subst h₁; subst h₂; refl\n\nlemma forall_eq_congr {α : Sort u} {p q : α → Prop} (h : ∀ a, p a = q a) :\n  (∀ a, p a) = ∀ a, q a :=\nhave h' : p = q, from funext h, by subst h'; refl\n\nnamespace set\n/- Some of these lemmas might be duplicates of those in data.set.lattice -/\n\nvariables {α : Type u} {β : Type v} {γ : Type w}\n\n/-set.ne_empty_iff_exists_mem.mpr-/\nlemma ne_empty_of_exists_mem {s : set α} : ∀(h : ∃x, x ∈ s), s ≠ ∅\n| ⟨x, hx⟩ := ne_empty_of_mem hx\n\nlemma inter_sUnion_ne_empty_of_exists_mem {b : set α} {𝓕 : set $ set α} (H : ∃ f ∈ 𝓕, b ∩ f ≠ ∅) : b ∩ ⋃₀ 𝓕 ≠ ∅ :=\nbegin\n  apply ne_empty_of_exists_mem, safe, change _ ≠ _ at h_1, rw ne_empty_iff_exists_mem at h_1,\n  rcases h_1 with ⟨x, H₁, H₂⟩, specialize a x, finish\nend\n\n@[simp]lemma mem_image_univ {f : α → β} {x} : f x ∈ f '' set.univ := ⟨x, ⟨trivial, rfl⟩⟩\n\n-- todo: only use image_preimage_eq_of_subset\nlemma image_preimage_eq_of_subset_image {f : α → β} {s : set β}\n  {t : set α} (h : s ⊆ f '' t) : f '' (f ⁻¹' s) = s :=\nsubset.antisymm\n  (image_preimage_subset f s)\n  (λ x hx, begin rcases h hx with ⟨a, ha, rfl⟩, apply mem_image_of_mem f, exact hx end)\n\nlemma subset_union_left_of_subset {s t : set α} (h : s ⊆ t) (u : set α) : s ⊆ t ∪ u :=\nsubset.trans h (subset_union_left t u)\n\nlemma subset_union_right_of_subset {s u : set α} (h : s ⊆ u) (t : set α) : s ⊆ t ∪ u :=\nsubset.trans h (subset_union_right t u)\n\n/- subset_sUnion_of_mem -/\nlemma subset_sUnion {s : set α} {t : set (set α)} (h : s ∈ t) : s ⊆ ⋃₀ t :=\nλx hx, ⟨s, ⟨h, hx⟩⟩\n\nlemma subset_union2_left {s t u : set α} : s ⊆ s ∪ t ∪ u :=\nsubset.trans (subset_union_left _ _) (subset_union_left _ _)\n\nlemma subset_union2_middle {s t u : set α} : t ⊆ s ∪ t ∪ u :=\nsubset.trans (subset_union_right _ _) (subset_union_left _ _)\n\n\ndef change {π : α → Type*} [decidable_eq α] (f : Πa, π a) {x : α} (z : π x) (y : α) : π y :=\nif h : x = y then (@eq.rec _ _ π z _ h) else f y\n\nlemma dif_mem_pi {π : α → Type*} (i : set α) (s : Πa, set (π a)) [decidable_eq α]\n  (f : Πa, π a) (hf : f ∈ pi i s) {x : α} (z : π x) (h : x ∈ i → z ∈ s x) :\n  change f z ∈ pi i s :=\nbegin\n  intros y hy, dsimp only,\n  by_cases hxy : x = y,\n  { rw [change, dif_pos hxy], subst hxy, exact h hy },\n  { rw [change, dif_neg hxy], apply hf y hy }\nend\n\nlemma image_pi_pos {π : α → Type*} (i : set α) (s : Πa, set (π a)) [decidable_eq α]\n  (hp : nonempty (pi i s)) (x : α) (hx : x ∈ i) : (λ(f : Πa, π a), f x) '' pi i s = s x :=\nbegin\n  apply subset.antisymm,\n  { rintro _ ⟨f, hf, rfl⟩, exact hf x hx },\n  intros z hz, have := hp, rcases this with ⟨f, hf⟩,\n  refine ⟨_, dif_mem_pi i s f hf z (λ _, hz), _⟩,\n  simp only [change, dif_pos rfl]\nend\n\nlemma image_pi_neg {π : α → Type*} (i : set α) (s : Πa, set (π a)) [decidable_eq α]\n  (hp : nonempty (pi i s)) (x : α) (hx : x ∉ i) : (λ(f : Πa, π a), f x) '' pi i s = univ :=\nbegin\n  rw [eq_univ_iff_forall], intro z, have := hp, rcases this with ⟨f, hf⟩,\n  refine ⟨_, dif_mem_pi i s f hf z _, _⟩,\n  intro hx', exfalso, exact hx hx',\n  simp only [change, dif_pos rfl]\nend\n\nend set\nopen nat\n\n\nnamespace nonempty\nvariables {α : Sort u} {β : Sort v} {γ : Sort w}\n\nprotected lemma iff (mp : α → β) (mpr : β → α) : nonempty α ↔ nonempty β :=\n⟨nonempty.map mp, nonempty.map mpr⟩\n\nend nonempty\n\n/-- The type α → (α → ... (α → β)...) with n α's. We require that α and β live in the same universe, otherwise we have to use ulift. -/\ndef arity' (α β : Type u) : ℕ → Type u\n| 0     := β\n| (n+1) := α → arity' n\n\nnamespace arity'\nsection arity'\nlocal notation h :: t  := dvector.cons h t\nlocal notation `[` l:(foldr `, ` (h t, dvector.cons h t) dvector.nil `]`) := l\ndef arity'_constant {α β : Type u} : ∀{n : ℕ}, β → arity' α β n\n| 0     b := b\n| (n+1) b := λ_, arity'_constant b\n\n@[simp] def of_dvector_map {α β : Type u} : ∀{l} (f : dvector α l → β), arity' α β l\n| 0     f := f ([])\n| (l+1) f := λx, of_dvector_map $ λxs, f $ x::xs\n\n@[simp] def arity'_app {α β : Type u} : ∀{l}, arity' α β l → dvector α l → β\n| _ b []      := b\n| _ f (x::xs) := arity'_app (f x) xs\n\n@[simp] lemma arity'_app_zero {α β : Type u} (f : arity' α β 0) (xs : dvector α 0) :\n  arity'_app f xs = f :=\nby cases xs; refl\n\ndef arity'_postcompose {α β γ : Type u} (g : β → γ) : ∀{n} (f : arity' α β n), arity' α γ n\n| 0     b := g b\n| (n+1) f := λx, arity'_postcompose (f x)\n\ndef arity'_postcompose2 {α β γ δ : Type u} (h : β → γ → δ) :\n  ∀{n} (f : arity' α β n) (g : arity' α γ n), arity' α δ n\n| 0     b c := h b c\n| (n+1) f g := λx, arity'_postcompose2 (f x) (g x)\n\ndef arity'_precompose {α β γ : Type u} : ∀{n} (g : arity' β γ n) (f : α → β), arity' α γ n\n| 0     c f := c\n| (n+1) g f := λx, arity'_precompose (g (f x)) f\n\ninductive arity'_respect_setoid {α β : Type u} [R : setoid α] : ∀{n}, arity' α β n → Type u\n| r_zero (b : β) : @arity'_respect_setoid 0 b\n| r_succ (n : ℕ) (f : arity' α β (n+1)) (h₁ : ∀{{a a'}}, a ≈ a' → f a = f a')\n  (h₂ : ∀a, arity'_respect_setoid (f a)) : arity'_respect_setoid f\nopen arity'_respect_setoid\n\ninstance subsingleton_arity'_respect_setoid {α β : Type u} [R : setoid α] {n} (f : arity' α β n) :\n  subsingleton (arity'_respect_setoid f) :=\nbegin\n  constructor, intros h h', induction h generalizing h'; cases h'; try {refl}; congr,\n  apply funext, intro x, apply h_ih\nend\n\n-- def arity'_quotient_lift {α β : Type u} {R : setoid α} :\n--   ∀{n}, (Σ(f : arity' α β n), arity'_respect_setoid f) → arity' (quotient R) β n\n-- | _ ⟨_, r_zero b⟩         := b\n-- | _ ⟨_, r_succ n f h₁ h₂⟩ :=\n--   begin\n--     apply quotient.lift (λx, arity'_quotient_lift ⟨f x, h₂ x⟩),\n--     intros x x' r, dsimp,\n--     apply congr_arg, exact sigma.eq (h₁ r) (subsingleton.elim _ _)\n--   end\n\n-- def arity'_quotient_beta {α β : Type u} {R : setoid α} {n} (f : arity' α β n)\n--   (hf : arity'_respect_setoid f) (xs : dvector α n) :\n--   arity'_app (arity'_quotient_lift ⟨f, hf⟩) (xs.map quotient.mk) = arity'_app f xs :=\n-- begin\n--   induction hf,\n--   { simp [arity'_quotient_lift] },\n--   dsimp [arity'_app], sorry\n-- end\n\ndef for_all {α : Type u} (P : α → Prop) : Prop := ∀x, P x\n\n@[simp] def arity'_map2 {α β : Type u} (q : (α → β) → β) (f : β → β → β) :\n  ∀{n}, arity' α β n → arity' α β n → β\n| 0     x y := f x y\n| (n+1) x y := q (λz, arity'_map2 (x z) (y z))\n\n@[simp] lemma arity'_map2_refl {α : Type} {f : Prop → Prop → Prop} (r : ∀A, f A A) :\n  ∀{n} (x : arity' α Prop n), arity'_map2 for_all f x x\n| 0     x := r x\n| (n+1) x := λy, arity'_map2_refl (x y)\n\ndef arity'_imp {α : Type} {n : ℕ} (f₁ f₂ : arity' α Prop n) : Prop :=\narity'_map2 for_all (λP Q, P → Q) f₁ f₂\n\ndef arity'_iff {α : Type} {n : ℕ} (f₁ f₂ : arity' α Prop n) : Prop :=\narity'_map2 for_all iff f₁ f₂\n\nlemma arity'_iff_refl {α : Type} {n : ℕ} (f : arity' α Prop n) : arity'_iff f f :=\narity'_map2_refl iff.refl f\n\nlemma arity'_iff_rfl {α : Type} {n : ℕ} {f : arity' α Prop n} : arity'_iff f f :=\narity'_iff_refl f\n\nend arity'\nend arity'\n\n@[simp]lemma lt_irrefl' {α} [preorder α] {Γ : α} (H_lt : Γ < Γ) : false := lt_irrefl _ ‹_›\n\nnamespace lattice\n\n\n\ninstance complete_degenerate_boolean_algebra : complete_boolean_algebra unit :=\n{ sup := λ _ _, (),\n  le := λ _ _, true,\n  lt := λ _ _, false,\n  le_refl := by tidy,\n  le_trans := by tidy,\n  lt_iff_le_not_le := by tidy,\n  le_antisymm := by tidy,\n  le_sup_left :=  by tidy,\n  le_sup_right :=  by tidy,\n  sup_le :=  by tidy,\n  inf := λ _ _, (),\n  inf_le_left :=  by tidy,\n  inf_le_right :=  by tidy,\n  le_inf :=  by tidy,\n  le_sup_inf :=  by tidy,\n  top := (),\n  le_top :=  by tidy,\n  bot := (),\n  bot_le :=  by tidy,\n  neg := λ _, (),\n  sub := λ _ _, (),\n  inf_neg_eq_bot :=  by tidy,\n  sup_neg_eq_top :=  by tidy,\n  sub_eq :=  by tidy,\n  Sup := λ _, (),\n  Inf := λ _, (),\n  le_Sup := by tidy,\n  Sup_le := by tidy,\n  Inf_le := by tidy,\n  le_Inf := by tidy,\n  infi_sup_le_sup_Inf := by tidy,\n  inf_Sup_le_supr_inf := by tidy}\n\nclass nontrivial_complete_boolean_algebra (α : Type*) extends complete_boolean_algebra α :=\n  {bot_lt_top : (⊥ : α) < (⊤ : α)}\n\n@[simp]lemma nontrivial.bot_lt_top {α : Type*} [H : nontrivial_complete_boolean_algebra α] : (⊥ : α) < ⊤ :=\nH.bot_lt_top\n\n@[simp]lemma nontrivial.bot_neq_top {α : Type*} [H : nontrivial_complete_boolean_algebra α] : ¬ (⊥ = (⊤ : α)) :=\nby {change _ ≠ _, rw[lt_top_iff_ne_top.symm], simp}\n\n@[simp]lemma nontrivial.top_neq_bot {α : Type*} [H : nontrivial_complete_boolean_algebra α] : ¬ (⊤ = (⊥ : α)) :=\nλ _, nontrivial.bot_neq_top $ eq.symm ‹_›\n\ndef antichain {β : Type*} [bounded_lattice β] (s : set β) :=\n  ∀ x ∈ s, ∀ y ∈ s, x ≠ y → x ⊓ y = (⊥ : β)\n\ntheorem inf_supr_eq {α ι : Type*} [complete_distrib_lattice α] {a : α} {s : ι → α} :\n  a ⊓ (⨆(i:ι), s i) = ⨆(i:ι), a ⊓ s i :=\n  eq.trans inf_Sup_eq $\n    begin\n      rw[<-inf_Sup_eq], suffices : (⨆(i:ι), a ⊓ s i) = ⨆(b∈(set.range s)), a ⊓ b,\n      by {rw[this], apply inf_Sup_eq}, simp, apply le_antisymm,\n      apply supr_le, intro i, apply le_supr_of_le (s i), apply le_supr_of_le i,\n      apply le_supr_of_le rfl, refl,\n      repeat{apply supr_le, intro}, rw[<-i_2], apply le_supr_of_le i_1, refl\n    end\n\ntheorem supr_inf_eq {α ι : Type*} [complete_distrib_lattice α] {a : α} {s : ι → α} :\n  (⨆(i:ι), s i) ⊓ a = ⨆(i:ι), (s i ⊓ a) :=\nby simp[inf_comm,inf_supr_eq]\n\ntheorem sup_infi_eq {α ι : Type*} [complete_distrib_lattice α] {a : α} {s : ι → α} :\n  a ⊔ (⨅(i:ι), s i) = ⨅(i:ι), a ⊔ s i :=\n  eq.trans sup_Inf_eq $\n    begin\n      rw[<-sup_Inf_eq], suffices : (⨅(i:ι), a ⊔ s i) = ⨅(b∈(set.range s)), a ⊔ b,\n      by {rw[this], apply sup_Inf_eq}, simp, apply le_antisymm,\n      repeat{apply le_infi, intro}, rw[<-i_2], apply infi_le_of_le i_1, refl,\n      repeat{apply infi_le_of_le}, show ι, from ‹ι›, show α, exact s i, refl, refl\n    end\n\ntheorem infi_sup_eq {α ι : Type*} [complete_distrib_lattice α] {a : α} {s : ι → α} :\n (⨅(i:ι), s i) ⊔ a = ⨅(i:ι), s i ⊔ a :=\nby {rw[sup_comm], conv{to_rhs, simp[sup_comm]}, apply sup_infi_eq}\n\n/- These next two lemmas are duplicates, but with better names -/\n@[simp]lemma inf_self {α : Type*} [lattice α] {a : α} : a ⊓ a = a :=\n  inf_idem\n\n@[simp]lemma sup_self {α : Type*} [lattice α] {a : α} : a ⊔ a = a :=\n  sup_idem\n\nlemma bot_lt_iff_not_le_bot {α} [bounded_lattice α] {a : α} : ⊥ < a ↔ (¬ a ≤ ⊥) :=\nby rw[le_bot_iff]; exact bot_lt_iff_ne_bot\n\nlemma false_of_bot_lt_and_le_bot {α} [bounded_lattice α] {a : α} (H_lt : ⊥ < a) (H_le : a ≤ ⊥) : false :=\nabsurd H_le (bot_lt_iff_not_le_bot.mp ‹_›)\n\nlemma lt_top_iff_not_top_le {α} [bounded_lattice α] {a : α} : a < ⊤ ↔ (¬ ⊤ ≤ a) :=\nby rw[top_le_iff]; exact lt_top_iff_ne_top\n\nlemma bot_lt_resolve_left {𝔹} [bounded_lattice 𝔹] {a b : 𝔹} (H_lt' : ⊥ < a ⊓ b) : ⊥ < b :=\nbegin\n  haveI := classical.prop_decidable, by_contra H, rw[bot_lt_iff_not_le_bot] at H H_lt',\n  apply H_lt', simp at H, simp*\nend\n\nlemma bot_lt_resolve_right {𝔹} [bounded_lattice 𝔹] {a b : 𝔹} (H_lt : ⊥ < b)\n  (H_lt' : ⊥ < a ⊓ b) : ⊥ < a :=\nby rw[inf_comm] at H_lt'; exact bot_lt_resolve_left ‹_›\n\nlemma le_bot_iff_not_bot_lt {𝔹} [bounded_lattice 𝔹] {a : 𝔹} : ¬ ⊥ < a ↔ a ≤ ⊥ :=\nby { rw bot_lt_iff_not_le_bot, tauto! }\n\n/--\n  Given an indexed supremum (⨆i, s i) and (H : Γ ≤ ⨆i, s i), there exists some i such that ⊥ < Γ ⊓ s i.\n-/\nlemma nonzero_inf_of_nonzero_le_supr {α : Type*} [complete_distrib_lattice α] {ι : Type*} {s : ι → α} {Γ : α} (H_nonzero : ⊥ < Γ) (H : Γ ≤ ⨆i, s i) : ∃ i, ⊥ < Γ ⊓ s i :=\nbegin\n  haveI := classical.prop_decidable, by_contra H', push_neg at H',\n  simp [bot_lt_iff_not_le_bot, -le_bot_iff] at H', replace H' := supr_le_iff.mpr H',\n  have H_absorb : Γ ⊓ (⨆(i : ι), s i) = Γ,\n    by {exact le_antisymm (inf_le_left) (le_inf (by refl) ‹_›)},\n  suffices this : (Γ ⊓ ⨆ (i : ι), s i) ≤ ⊥,\n    by {rw[H_absorb, le_bot_iff] at this, simpa[this] using H_nonzero},\n  rwa[inf_supr_eq]\nend\n\n/--\n  Material implication in a Boolean algebra\n-/\ndef imp {α : Type*} [boolean_algebra α] : α → α → α :=\n  λ a₁ a₂, (- a₁) ⊔ a₂\n\nlocal infix ` ⟹ `:65 := lattice.imp\n\n@[reducible, simp]def biimp {α : Type*} [boolean_algebra α] : α → α → α :=\n  λ a₁ a₂, (a₁ ⟹ a₂) ⊓ (a₂ ⟹ a₁)\n\nlocal infix ` ⇔ `:50 := lattice.biimp\n\nlemma biimp_mp {α : Type*} [boolean_algebra α] {a₁ a₂ : α} : (a₁ ⇔ a₂) ≤ (a₁ ⟹ a₂) :=\n  by apply inf_le_left\n\nlemma biimp_mpr {α : Type*} [boolean_algebra α] {a₁ a₂ : α} : (a₁ ⇔ a₂) ≤ (a₂ ⟹ a₁) :=\n  by apply inf_le_right\n\nlemma biimp_comm {α : Type*} [boolean_algebra α] {a₁ a₂ : α} : (a₁ ⇔ a₂) = (a₂ ⇔ a₁) :=\nby {unfold biimp, rw lattice.inf_comm}\n\nlemma biimp_symm {α : Type*} [boolean_algebra α] {a₁ a₂ : α} {Γ : α} : Γ ≤ (a₁ ⇔ a₂) ↔ Γ ≤ (a₂ ⇔ a₁) :=\nby rw biimp_comm\n\n@[simp]lemma imp_le_of_right_le {α : Type*} [boolean_algebra α] {a a₁ a₂ : α} {h : a₁ ≤ a₂} : a ⟹ a₁ ≤ (a ⟹ a₂) :=\nsup_le (by apply le_sup_left) $ le_sup_right_of_le h\n\n@[simp]lemma imp_le_of_left_le {α : Type*} [boolean_algebra α] {a a₁ a₂ : α} {h : a₂ ≤ a₁} : a₁ ⟹ a ≤ (a₂ ⟹ a) :=\nsup_le (le_sup_left_of_le $ neg_le_neg h) (by apply le_sup_right)\n\n@[simp]lemma imp_le_of_left_right_le {α : Type*} [boolean_algebra α] {a₁ a₂ b₁ b₂ : α}\n{h₁ : b₁ ≤ a₁} {h₂ : a₂ ≤ b₂} :\n  a₁ ⟹ a₂ ≤ b₁ ⟹ b₂ :=\nsup_le (le_sup_left_of_le (neg_le_neg h₁)) (le_sup_right_of_le h₂)\n\nlemma neg_le_neg' {α : Type*} [boolean_algebra α] {a b : α} : b ≤ -a → a ≤ -b :=\nby {intro H, rw[show b = - - b, by simp] at H, rwa[<-neg_le_neg_iff_le]}\n\nlemma inf_imp_eq {α : Type*} [boolean_algebra α] {a b c : α} :\n  a ⊓ (b ⟹ c) = (a ⟹ b) ⟹ (a ⊓ c) :=\nby unfold imp; simp[inf_sup_left]\n\n@[simp]lemma imp_bot {α : Type*} [boolean_algebra α]  {a : α} : a ⟹ ⊥ = - a := by simp[imp]\n\n@[simp]lemma top_imp {α : Type*} [boolean_algebra α] {a : α} : ⊤ ⟹ a = a := by simp[imp]\n\n@[simp]lemma imp_self {α : Type*} [boolean_algebra α] {a : α} : a ⟹ a = ⊤ := by simp[imp]\n\nlemma imp_neg_sub {α : Type*} [boolean_algebra α] {a₁ a₂ : α} :  -(a₁ ⟹ a₂) = a₁ - a₂ :=\n  by rw[sub_eq, imp]; simp*\n\nlemma inf_eq_of_le {α : Type*} [distrib_lattice α] {a b : α} (h : a ≤ b) : a ⊓ b = a :=\n  by apply le_antisymm; simp[*,le_inf]\n\nlemma imp_inf_le {α : Type*} [boolean_algebra α] (a b : α) : (a ⟹ b) ⊓ a ≤ b :=\nby { unfold imp, rw [inf_sup_right], simp }\n\nlemma le_of_sub_eq_bot {α : Type*} [boolean_algebra α] {a b : α} (h : - b ⊓ a = ⊥) : a ≤ b :=\nbegin\n  apply le_of_inf_eq, rw [←@neg_neg _ b _, ←sub_eq], apply sub_eq_left, rwa [inf_comm]\nend\n\nlemma le_neg_of_inf_eq_bot {α : Type*} [boolean_algebra α] {a b : α} (h : b ⊓ a = ⊥) : a ≤ - b :=\nby { apply le_of_sub_eq_bot, rwa [neg_neg] }\n\nlemma sub_eq_bot_of_le {α : Type*} [boolean_algebra α] {a b : α} (h : a ≤ b) : - b ⊓ a = ⊥ :=\nby rw [←inf_eq_of_le h, inf_comm, inf_assoc, inf_neg_eq_bot, inf_bot_eq]\n\nlemma inf_eq_bot_of_le_neg {α : Type*} [boolean_algebra α] {a b : α} (h : a ≤ - b) : b ⊓ a = ⊥ :=\nby { rw [←@neg_neg _ b], exact sub_eq_bot_of_le h }\n\n/-- the deduction theorem in β -/\n@[simp]lemma imp_top_iff_le {α : Type*} [boolean_algebra α] {a₁ a₂ : α} : (a₁ ⟹ a₂ = ⊤) ↔ a₁ ≤ a₂ :=\nbegin\n  unfold imp, refine ⟨_,_⟩; intro H,\n    { have := congr_arg (λ x, x ⊓ a₁) H, rw[sup_comm] at this,\n      finish[inf_sup_right] },\n    { have := sup_le_sup_right H (-a₁), finish }\nend\n/- ∀ {α : Type u_1} [_inst_1 : boolean_algebra α] {a₁ a₂ : α}, a₁ ⟹ a₂ = ⊤ ↔ a₁ ≤ a₂ -/\n\nlemma curry_uncurry {α : Type*} [boolean_algebra α] {a b c : α} : ((a ⊓ b) ⟹ c) = (a ⟹ (b ⟹ c)) :=\n  by simp[imp]; ac_refl\n\n/-- the actual deduction theorem in β, thinking of ≤ as a turnstile -/\n@[ematch]lemma deduction {α : Type*} [boolean_algebra α] {a b c : α} : a ⊓ b ≤ c ↔ a ≤ (b ⟹ c) :=\n  by {[smt] eblast_using [curry_uncurry, imp_top_iff_le]}\n\nlemma deduction_simp {α : Type*} [boolean_algebra α] {a b c : α} : a ≤ (b ⟹ c) ↔ a ⊓ b ≤ c := deduction.symm\n\nlemma imp_top {α : Type*} [complete_boolean_algebra α] (a : α) : a ≤ a ⟹ ⊤ :=\nby {rw[<-deduction]; simp}\n\n/-- Given an η : option α → β, where β is a complete lattice, we have that the supremum of η\n    is equal to (η none) ⊔ ⨆(a:α) η (some a)-/\n@[simp]lemma supr_option {α β : Type*} [complete_lattice β] {η : option α → β} : (⨆(x : option α), η x) = (η none) ⊔ ⨆(a : α), η (some a) :=\nbegin\n  apply le_antisymm, tidy, cases i, apply le_sup_left,\n  apply le_sup_right_of_le, apply le_supr (λ x, η (some x)) i, apply le_supr, apply le_supr\nend\n\n/-- Given an η : option α → β, where β is a complete lattice, we have that the infimum of η\n    is equal to (η none) ⊓ ⨅(a:α) η (some a)-/\n@[simp]lemma infi_option {α β : Type*} [complete_lattice β] {η : option α → β} : (⨅(x : option α), η x) = (η none) ⊓ ⨅(a : α), η (some a) :=\nbegin\n  apply le_antisymm, tidy, tactic.rotate 2, cases i, apply inf_le_left,\n  apply inf_le_right_of_le, apply infi_le (λ x, η (some x)) i, apply infi_le, apply infi_le\nend\n\nlemma supr_option' {α β : Type*} [complete_lattice β] {η : α → β} {b : β} : (⨆(x : option α), (option.rec b η x : β) : β) = b ⊔ ⨆(a : α), η a :=\n  by rw[supr_option]\n\nlemma infi_option' {α β : Type*} [complete_lattice β] {η : α → β} {b : β} : (⨅(x : option α), (option.rec b η x : β) : β) = b ⊓ ⨅(a : α), η a :=\n  by rw[infi_option]\n\n/-- Let A : α → β such that b = ⨆(a : α) A a. Let c < b. If, for all a : α, A a ≠ b → A a ≤ c,\nthen there exists some x : α such that A x = b. -/\nlemma supr_max_of_bounded {α β : Type*} [complete_lattice β] {A : α → β} {b c : β}\n{h : b = ⨆(a:α), A a} {h_lt : c < b} {h_bounded : ∀ a : α, A a ≠ b → A a ≤ c} :\n  ∃ x : α, A x = b :=\nbegin\n  haveI : decidable ∃ (x : α), A x = b := classical.prop_decidable _,\n  by_contra, rw[h] at a, simp at a,\n  suffices : b ≤ c, by {suffices : c < c, by {exfalso, have this' := lt_irrefl,\n  show Type*, exact β, show preorder (id β), by {dsimp, apply_instance}, exact this' c this},\n  exact lt_of_lt_of_le h_lt this},\n  rw[h], apply supr_le, intro a', from h_bounded a' (by convert a a')\nend\n\n/-- Let A : α → β such that b ≤ ⨆(a : α) A a. Let c < b. If, for all a : α, A a ≠ b → A a ≤ c,\nthen there exists some x : α such that b ≤ A x. -/\nlemma supr_max_of_bounded' {α β : Type*} [complete_lattice β] {A : α → β} {b c : β}\n{h : b ≤ ⨆(a:α), A a} {h_lt : c < b} {h_bounded : ∀ a : α, (¬ b ≤ A a) → A a ≤ c} :\n  ∃ x : α, b ≤ A x :=\nbegin\n  haveI : decidable ∃ (x : α), b ≤ A x := classical.prop_decidable _,\n  by_contra, simp at a,\n  suffices : b ≤ c, by {suffices : c < c, by {exfalso, have this' := lt_irrefl,\n  show Type*, exact β, show preorder (id β), by {dsimp, apply_instance}, exact this' c this},\n  exact lt_of_lt_of_le h_lt this},\n  apply le_trans h, apply supr_le, intro a', from h_bounded a' (a a')\nend\n\n/-- As a consequence of the previous lemma, if ⨆(a : α), A a = ⊤ such that whenever A a ≠ ⊤ → A α = ⊥, there exists some x : α such that A x = ⊤. -/\nlemma supr_eq_top_max {α β : Type*} [complete_lattice β] {A : α → β} {h_nondeg : ⊥ < (⊤ : β)}\n{h_top : (⨆(a : α), A a) = ⊤} {h_bounded : ∀ a : α, A a ≠ ⊤ → A a = ⊥} : ∃ x : α, A x = ⊤ :=\n  by {apply supr_max_of_bounded, cc, exact h_nondeg, tidy}\n\nlemma supr_eq_Gamma_max {α β : Type*} [complete_lattice β] {A : α → β} {Γ : β} (h_nonzero : ⊥ < Γ)\n(h_Γ : Γ ≤ (⨆a, A a)) (h_bounded : ∀ a, (¬ Γ ≤ A a) → A a = ⊥) : ∃ x : α, Γ ≤ A x :=\nbegin\n  apply supr_max_of_bounded', from ‹_›, from ‹_›, intros a H,\n  specialize h_bounded a ‹_›, rwa[le_bot_iff]\nend\n\n/-- \"eoc\" means the opposite of \"coe\", of course -/\nlemma eoc_supr {ι β : Type*} {s : ι → β} [complete_lattice β] {X : set ι} :\n  (⨆(i : X), s i) = ⨆(i ∈ X), s i :=\nbegin\n  apply le_antisymm; repeat{apply supr_le; intro},\n  apply le_supr_of_le i.val, apply le_supr_of_le, exact i.property, refl,\n  apply le_supr_of_le, swap, use i, assumption, refl\nend\n\n/- Can reindex sup over all sets -/\nlemma supr_all_sets {ι β : Type*} {s : ι → β} [complete_lattice β] :\n  (⨆(i:ι), s i) = ⨆(X : set ι), (⨆(x : X), s x) :=\nbegin\n  apply le_antisymm,\n    {apply supr_le, intro i, apply le_supr_of_le {i}, apply le_supr_of_le, swap,\n     use i, from set.mem_singleton i, simp},\n    {apply supr_le, intro X, apply supr_le, intro i, apply le_supr}\nend\n\nlemma supr_all_sets' {ι β : Type*} {s : ι → β} [complete_lattice β] :\n  (⨆(i:ι), s i) = ⨆(X : set ι), (⨆(x ∈ X), s x) :=\nby {convert supr_all_sets using 1, simp[eoc_supr]}\n\n-- `b ≤ ⨆(i:ι) c i` if there exists an s : set ι such that b ≤ ⨆ (i : s), c s\nlemma le_supr_of_le' {ι β : Type*} {s : ι → β} {b : β} [complete_lattice β]\n  (H : ∃ X : set ι, b ≤ ⨆(x:X), s x) : b ≤ ⨆(i:ι), s i :=\nbegin\n  rcases H with ⟨X, H_X⟩, apply le_trans H_X,\n  conv{to_rhs, rw[supr_all_sets]},\n  from le_supr_of_le X (by refl)\nend\n\nlemma le_supr_of_le'' {ι β : Type*} {s : ι → β} {b : β} [complete_lattice β]\n  (H : ∃ X : set ι, b ≤ ⨆(x ∈ X), s x) : b ≤ ⨆(i:ι), s i :=\nby {apply le_supr_of_le', convert H using 1, simp[eoc_supr]}\n\nlemma infi_congr {ι β : Type*} {s₁ s₂ : ι → β} [complete_lattice β] {h : ∀ i : ι, s₁ i = s₂ i} :\n  (⨅(i:ι), s₁ i) = ⨅(i:ι), s₂ i :=\nby simp*\n\n@[simp]lemma supr_congr {ι β : Type*} {s₁ s₂ : ι → β} [complete_lattice β] {h : ∀ i : ι, s₁ i = s₂ i} :\n  (⨆(i:ι), s₁ i) = ⨆(i:ι), s₂ i :=\nby simp*\n\nlemma imp_iff {β : Type*} {a b : β} [complete_boolean_algebra β] : a ⟹ b = -a ⊔ b := by refl\n\nlemma sup_inf_left_right_eq {β} [distrib_lattice β] {a b c d : β} :\n  (a ⊓ b) ⊔ (c ⊓ d) = (a ⊔ c) ⊓ (a ⊔ d) ⊓ (b ⊔ c) ⊓ (b ⊔ d) :=\nby {rw[sup_inf_right, sup_inf_left, sup_inf_left]; ac_refl}\n\nlemma inf_sup_right_left_eq {β} [distrib_lattice β] {a b c d : β} :\n  (a ⊔ b) ⊓ (c ⊔ d) = (a ⊓ c) ⊔ (a ⊓ d) ⊔ (b ⊓ c) ⊔ (b ⊓ d) :=\nby {rw[inf_sup_right, inf_sup_left, inf_sup_left], ac_refl}\n\n-- by {[smt] eblast_using[sup_inf_right, sup_inf_left]}\n-- interesting, this takes like 5 seconds\n-- probably because both of those rules can be applied pretty much everywhere in the goal\n-- and eblast is trying all of them\n\nlemma eq_neg_of_partition {β} [boolean_algebra β] {a₁ a₂ : β} (h_anti : a₁ ⊓ a₂ = ⊥) (h_partition : a₁ ⊔ a₂ = ⊤) :\n  a₂ = - a₁ :=\nbegin\n  rw[show -a₁ = ⊤ ⊓ -a₁, by simp], rw[<-sub_eq],\n  rw[<-h_partition,sub_eq], rw[inf_sup_right],\n  simp*, rw[<-sub_eq], rw[inf_comm] at h_anti,\n  from (sub_eq_left h_anti).symm\nend\n\nlemma le_trans' {β} [lattice β] {a₁ a₂ a₃ : β} (h₁ : a₁ ≤ a₂) {h₂ : a₁ ⊓ a₂ ≤ a₃} : a₁ ≤ a₃ :=\nbegin\n  suffices : a₁ ≤ a₁ ⊓ a₂, from le_trans this ‹_›,\n  rw[show a₁ = a₁ ⊓ a₁, by simp], conv {to_rhs, rw[inf_assoc]},\n  apply inf_le_inf, refl, apply le_inf, refl, assumption\nend\n\n@[simp]lemma top_le_imp_top {β : Type*} {b : β} [boolean_algebra β] : ⊤ ≤ b ⟹ ⊤ :=\nby rw[<-deduction]; apply le_top\n\nlemma poset_yoneda_iff {β : Type*} [partial_order β] {a b : β} : a ≤ b ↔ (∀ {Γ : β}, Γ ≤ a → Γ ≤ b) := ⟨λ _, by finish, λ H, by specialize @H a; finish⟩\n\nlemma poset_yoneda_top {β : Type*} [bounded_lattice β] {b : β} : ⊤ ≤ b ↔ (∀ {Γ : β}, Γ ≤ b) := ⟨λ _, by finish, λ H, by apply H⟩\n\nlemma poset_yoneda {β : Type*} [partial_order β] {a b : β} (H : ∀ Γ : β, Γ ≤ a → Γ ≤ b) : a ≤ b :=\nby rwa poset_yoneda_iff\n\nlemma poset_yoneda_inv {β : Type*} [partial_order β] {a b : β} (Γ : β) (H : a ≤ b) :\n  Γ ≤ a → Γ ≤ b := by rw poset_yoneda_iff at H; apply H\n\nlemma split_context {β : Type*} [lattice β] {a₁ a₂ b : β} {H : ∀ Γ : β, Γ ≤ a₁ ∧ Γ ≤ a₂ → Γ ≤ b} : a₁ ⊓ a₂ ≤ b :=\nby {apply poset_yoneda, intros Γ H', apply H, finish}\n\nexample {β : Type*} [bounded_lattice β] : ⊤ ⊓ (⊤ : β) ⊓ ⊤ ≤ ⊤ :=\nbegin\n  apply split_context, intros, simp only [le_inf_iff] at a, auto.split_hyps, from ‹_›\nend\n\nlemma context_Or_elim {β : Type*} [complete_boolean_algebra β] {ι} {s : ι → β} {Γ b : β}\n  (h : Γ ≤ ⨆(i:ι), s i) {h' : ∀ i, s i ⊓ Γ ≤ s i → s i ⊓ Γ ≤ b} : Γ ≤ b :=\nbegin\n  apply le_trans' h, rw[inf_comm], rw[deduction], apply supr_le, intro i, rw[<-deduction],\n  specialize h' i, apply h', apply inf_le_left\nend\n\nlemma context_or_elim {β : Type*} [complete_boolean_algebra β] {Γ a₁ a₂ b : β}\n  (H : Γ ≤ a₁ ⊔ a₂) {H₁ : a₁ ⊓ Γ ≤ a₁ → a₁ ⊓ Γ ≤ b} {H₂ : a₂ ⊓ Γ ≤ a₂ → a₂ ⊓ Γ ≤ b} : Γ ≤ b :=\nbegin\n  apply le_trans' H, rw[inf_comm], rw[deduction], apply sup_le; rw[<-deduction];\n  [apply H₁, apply H₂]; from inf_le_left\nend\n\nlemma bv_em_aux {β : Type*} [complete_boolean_algebra β] (Γ : β) (b : β) : Γ ≤ b ⊔ -b :=\nle_trans le_top $ by simp\n\nlemma bv_em {β : Type*} [complete_boolean_algebra β] {Γ : β} (b : β) : Γ ≤ b ⊔ -b :=\nbv_em_aux _ _\n\nlemma diagonal_supr_le_supr {α} [complete_lattice α] {ι} {s : ι → ι → α} {Γ : α} (H : Γ ≤ ⨆ i, s i i) : Γ ≤ ⨆ i j, s i j :=\n le_trans H $ supr_le $ λ i,  le_supr_of_le i $ le_supr_of_le i $ by refl\n\nlemma diagonal_infi_le_infi {α} [complete_lattice α] {ι} {s : ι → ι → α} {Γ : α} (H : Γ ≤ ⨅ i j, s i j) : Γ ≤ ⨅ i, s i i :=\n  le_trans H $ le_infi $ λ i, infi_le_of_le i $ infi_le_of_le i $ by refl\n\nlemma context_and_intro {β : Type*} [lattice β] {Γ} {a₁ a₂ : β}\n  (H₁ : Γ ≤ a₁) (H₂ : Γ ≤ a₂) : Γ ≤ a₁ ⊓ a₂ := le_inf ‹_› ‹_›\n\nlemma specialize_context {β : Type*} [partial_order β] {Γ b : β} (Γ' : β) {H_le : Γ' ≤ Γ} (H : Γ ≤ b)\n  : Γ' ≤ b :=\nle_trans H_le H\n\nlemma context_specialize_aux {β : Type*} [complete_boolean_algebra β] {ι : Type*} {s : ι → β}\n  (j : ι) {Γ : β} {H : Γ ≤ (⨅ i, s i)} : Γ ≤ (⨅i, s i) ⟹ s j :=\nby {apply le_trans H, rw[<-deduction], apply inf_le_right_of_le, apply infi_le}\n\nlemma context_specialize {β : Type*} [complete_lattice β] {ι : Type*} {s : ι → β}\n  {Γ : β} (H : Γ ≤ (⨅ i, s i)) (j : ι) : Γ ≤ s j :=\nle_trans H (infi_le _ _)\n\nlemma context_specialize_strict {β : Type*} [complete_lattice β] {ι : Type*} {s : ι → β}\n  {Γ : β} (H : Γ < (⨅ i, s i)) (j : ι) : Γ < s j :=\nbegin\n  apply lt_iff_le_and_ne.mpr, split, from le_trans (le_of_lt H) (infi_le _ _),\n  intro H', apply @lt_irrefl β _ _, show β, from (⨅ i, s i),\n  apply lt_of_le_of_lt, show β, from Γ, rw[H'], apply infi_le, from ‹_›\nend\n\nlemma context_split_inf_left {β : Type*} [complete_lattice β] {a₁ a₂ Γ: β} (H : Γ ≤ a₁ ⊓ a₂) : Γ ≤ a₁ :=\nby {rw[le_inf_iff] at H, finish}\n\nlemma context_split_inf_right {β : Type*} [complete_lattice β] {a₁ a₂ Γ: β} (H : Γ ≤ a₁ ⊓ a₂) :\n  Γ ≤ a₂ :=\nby {rw[le_inf_iff] at H, finish}\n\nlemma context_imp_elim {β : Type*} [complete_boolean_algebra β] {a b Γ: β} (H₁ : Γ ≤ a ⟹ b) (H₂ : Γ ≤ a) : Γ ≤ b :=\nbegin\n  apply le_trans' H₁, apply le_trans, apply inf_le_inf H₂, refl,\n  rw[inf_comm], simp[imp, inf_sup_right]\nend\n\nlemma context_imp_intro {β : Type*} [complete_boolean_algebra β] {a b Γ : β} (H : a ⊓ Γ ≤ a → a ⊓ Γ ≤ b) : Γ ≤ a ⟹ b :=\nby {rw[<-deduction, inf_comm], from H (inf_le_left)}\n\ninstance imp_to_pi {β } [complete_boolean_algebra β] {Γ a b : β} : has_coe_to_fun (Γ ≤ a ⟹ b) :=\n{ F := λ x, Γ ≤ a → Γ ≤ b,\n  coe := λ H₁ H₂, by {apply context_imp_elim; from ‹_›}}\n\ninstance infi_to_pi {ι β} [complete_boolean_algebra β] {Γ : β} {ϕ : ι → β} : has_coe_to_fun (Γ ≤ infi ϕ) :=\n{ F := λ x, Π i : ι, Γ ≤ ϕ i,\n  coe := λ H₁ i, by {change Γ ≤ ϕ i, change Γ ≤ _ at H₁, finish}}\n\nlemma bv_absurd {β} [boolean_algebra β] {Γ : β} (b : β) (H₁ : Γ ≤ b) (H₂ : Γ ≤ -b) : Γ ≤ ⊥ :=\n@le_trans _ _ _ (b ⊓ -b) _ (le_inf ‹_› ‹_›) (by simp)\n\nlemma neg_imp {β : Type*} [boolean_algebra β] {a b : β} : -(a ⟹ b) = a ⊓ (-b) :=\nby simp[imp]\n\nlemma nonzero_wit {β : Type*} [complete_lattice β] {ι : Type*} {s : ι → β} :\n  (⊥ < (⨆i, s i)) → ∃ j, (⊥ < s j) :=\nbegin\n  intro H, have := bot_lt_iff_not_le_bot.mp ‹_›,\n  haveI : decidable (∃ (j : ι), ⊥ < s j) := classical.prop_decidable _,\n  by_contra, apply this, apply supr_le, intro i, rw[not_exists] at a,\n  specialize a i, haveI : decidable (s i ≤ ⊥) := classical.prop_decidable _,\n  by_contra, have := @bot_lt_iff_not_le_bot β _ (s i), tauto\nend\n\nlemma nonzero_wit' {β : Type*} [complete_distrib_lattice β] {ι : Type*} {s : ι → β} {Γ : β}\n  (H_nonzero : ⊥ < Γ) (H_le : Γ ≤ ⨆ i , s i ):\n  ∃ j, (⊥ < s j ⊓ Γ) :=\nbegin\n  haveI : decidable (∃ j, (⊥ < s j ⊓ Γ)) := classical.prop_decidable _,\n  by_contra H, push_neg at H, simp only [(not_congr bot_lt_iff_not_le_bot)] at H,\n  have this : (⨆j, s j ⊓ Γ) ≤ ⊥ := supr_le (λ i, classical.by_contradiction $ H ‹_›),\n  rw[<-supr_inf_eq] at this,\n  suffices H_bad : Γ ⊓ Γ ≤ ⊥,\n    by {[smt] eblast_using [bot_lt_iff_not_le_bot, inf_self]},\n  exact le_trans (inf_le_inf ‹_› (by refl)) ‹_›,\nend\n\ndef CCC (𝔹 : Type u) [boolean_algebra 𝔹] : Prop :=\n  ∀ ι : Type u, ∀ 𝓐 : ι → 𝔹, (∀ i, ⊥ < 𝓐 i) →\n    (∀ i j, i ≠ j → 𝓐 i ⊓ 𝓐 j ≤ ⊥) → (cardinal.mk ι) ≤ cardinal.omega\n\n@[reducible]noncomputable def Prop_to_bot_top {𝔹 : Type u} [has_bot 𝔹] [has_top 𝔹] : Prop → 𝔹 :=\nλ p, by {haveI : decidable p := classical.prop_decidable _, by_cases p, from ⊤, from ⊥}\n\n@[simp]lemma Prop_to_bot_top_true {𝔹 : Type u} [has_bot 𝔹] [has_top 𝔹] {p : Prop} {H : p} : Prop_to_bot_top p = (⊤ : 𝔹) := by simp[*, Prop_to_bot_top]\n\n@[simp]lemma Prop_to_bot_top_false {𝔹 : Type u} [has_bot 𝔹] [has_top 𝔹] {p : Prop} {H : ¬ p} : Prop_to_bot_top p = (⊥ : 𝔹) := by simp[*, Prop_to_bot_top]\n\nlemma bv_by_contra {𝔹} [boolean_algebra 𝔹] {Γ b : 𝔹} (H : Γ ≤ -b ⟹ ⊥) : Γ ≤ b := by simpa using H\n\n-- noncomputable def to_boolean_valued_set {𝔹} [has_bot 𝔹] [has_top 𝔹] {α} : set α → (α → 𝔹) :=\n-- λ s, Prop_to_bot_top ∘ s\n\nrun_cmd mk_simp_attr `bv_push_neg\n\nattribute [bv_push_neg] neg_infi neg_supr neg_Inf neg_Sup neg_inf neg_sup neg_top neg_bot lattice.neg_neg lattice.neg_imp\n\nend lattice\n\nnamespace tactic\nnamespace interactive\n\nmeta def back_chaining : tactic unit := local_context >>= tactic.back_chaining_core skip (`[simp*])\n\nsection natded_tactics\nopen tactic interactive tactic.tidy\nopen lean.parser lean interactive.types\n\nlocal postfix `?`:9001 := optional\nmeta def bv_intro : parse ident_? → tactic unit\n| none := propagate_tags (`[refine lattice.le_infi _] >> intro1 >> tactic.skip)\n| (some n) := propagate_tags (`[refine lattice.le_infi _] >> tactic.intro n >> tactic.skip)\n\nmeta def get_name : ∀(e : expr), name\n| (expr.const c [])          := c\n| (expr.local_const _ c _ _) := c\n| _                          := name.anonymous\n\nmeta def lhs_rhs_of_le (e : expr) : tactic (expr × expr) :=\ndo `(%%x ≤ %%y) <- pure e,\n   return (x,y)\n\nmeta def lhs_of_le (e : expr) : tactic expr :=\nlhs_rhs_of_le e >>= λ x, return x.1\n\nmeta def rhs_of_le (e : expr) : tactic expr :=\nlhs_rhs_of_le e >>= λ x, return x.2\n\n-- meta def lhs_of_le (e : expr) : tactic expr :=\n-- do v_a <- mk_mvar,\n--    e' <- to_expr ``(%%v_a ≤ _),\n--    unify e e',\n--    return v_a\n\nmeta def goal_is_bot : tactic bool :=\ndo b <- get_goal >>= rhs_of_le,\n   succeeds $ to_expr ``(by refl : %%b = ⊥)\n\nmeta def hyp_is_ineq (e : expr) : tactic bool :=\n  (do `(%%x ≤ %%y) <- infer_type e,\n     return tt)<|> return ff\n\nmeta def hyp_is_neg_ineq (e : expr) : tactic bool :=\n  (do `(%%x ≤ - %%y) <- infer_type e,\n     return tt) <|> return ff\n\nmeta def trace_inequalities : tactic unit :=\n  (local_context >>= λ l, l.mfilter (hyp_is_ineq)) >>= trace\n\nmeta def hyp_is_ineq_sup (e : expr) : tactic bool :=\n  (do `(%%x ≤ %%y ⊔ %%z) <- infer_type e,\n     return tt)<|> return ff\n\nmeta def get_current_context : tactic expr := target >>= lhs_of_le\n\nmeta def trace_sup_inequalities : tactic unit :=\n  (local_context >>= λ l, l.mfilter (hyp_is_ineq_sup)) >>= trace\n\nmeta def specialize_context_at (H : parse ident) (Γ : parse texpr) : tactic unit :=\ndo e <- resolve_name H,\n   tactic.replace H ``(lattice.specialize_context %%Γ %%e),\n   swap >> try `[refine lattice.le_top] >> skip\n\nmeta def specialize_context_core (Γ_old : expr) : tactic unit :=\ndo  v_a <- target >>= lhs_of_le,\n    tp <- infer_type Γ_old,\n    Γ_name <- get_unused_name \"Γ\",\n    v <- mk_mvar, v' <- mk_mvar,\n    Γ_new <- pose Γ_name none v,\n    -- TODO(jesse) try replacing to_expr with an expression via mk_app instead\n    new_goal <- to_expr ``((%%Γ_new : %%tp) ≤ %%v'),\n    tactic.change new_goal,\n    ctx <- local_context,\n    ctx' <- ctx.mfilter\n      (λ e, (do infer_type e >>= lhs_of_le >>= λ e', succeeds $ is_def_eq Γ_old e') <|> return ff),\n      ctx'.mmap' (λ H, tactic.replace (get_name H) ``(le_trans (by exact inf_le_right <|> simp : %%Γ_new ≤ _) %%H)),\n    ctx2 <- local_context,\n    ctx2' <- ctx.mfilter (λ e, (do infer_type e >>= lhs_of_le >>= instantiate_mvars >>= λ e', succeeds $ is_def_eq Γ_new e') <|> return ff),\n    -- trace ctx2',\n    ctx2'.mmap' (λ H, do H_tp <- infer_type H,\n                         e'' <- lhs_of_le H_tp,\n                         succeeds (unify Γ_new e'') >>\n                   tactic.replace (get_name H) ``(_ : %%Γ_new ≤ _) >> swap >> assumption)\n\nmeta def specialize_context_core' (Γ_old : expr) : tactic unit :=\ndo  v_a <- target >>= lhs_of_le,\n    tp <- infer_type Γ_old,\n    Γ_name <- get_unused_name \"Γ\",\n    v <- mk_mvar, v' <- mk_mvar,\n    Γ_new <- pose Γ_name none v,\n    -- TODO(jesse) try replacing to_expr with an expression via mk_app instead\n    new_goal <- to_expr ``((%%Γ_new : %%tp) ≤ %%v'),\n    tactic.change new_goal,\n    ctx <- local_context,\n    ctx' <- ctx.mfilter\n      (λ e, (do infer_type e >>= lhs_of_le >>= λ e', succeeds $ is_def_eq Γ_old e') <|> return ff),\n      ctx'.mmap' (λ H, to_expr ``(le_trans (by exact inf_le_right <|> simp : %%Γ_new ≤ _) %%H) >>= λ foo, tactic.note (get_name H) none foo),\n    ctx2 <- local_context,\n    ctx2' <- ctx.mfilter (λ e, (do infer_type e >>= lhs_of_le >>= instantiate_mvars >>= λ e', succeeds $ is_def_eq Γ_new e') <|> return ff),\n    -- trace ctx2',\n    ctx2'.mmap' (λ H, do H_tp <- infer_type H,\n                         e'' <- lhs_of_le H_tp,\n                         succeeds (unify Γ_new e'') >>\n                   tactic.replace (get_name H) ``(_ : %%Γ_new ≤ _) >> swap >> assumption)\n\nmeta def specialize_context_assumption_core (Γ_old : expr) : tactic unit :=\ndo  v_a <- target >>= lhs_of_le,\n    tp <- infer_type Γ_old,\n    Γ_name <- get_unused_name \"Γ\",\n    v <- mk_mvar, v' <- mk_mvar,\n    Γ_new <- pose Γ_name none v,\n    -- TODO(jesse) try replacing to_expr with an expression via mk_app instead\n    new_goal <- to_expr ``((%%Γ_new : %%tp) ≤ %%v'),\n    tactic.change new_goal,\n    ctx <- local_context,\n    ctx' <- ctx.mfilter\n      (λ e, (do infer_type e >>= lhs_of_le >>= λ e', succeeds $ is_def_eq Γ_old e') <|> return ff),\n      ctx'.mmap' (λ H, tactic.replace (get_name H) ``(le_trans (by exact inf_le_right <|> assumption : %%Γ_new ≤ _) %%H)),\n    ctx2 <- local_context,\n    ctx2' <- ctx.mfilter (λ e, (do infer_type e >>= lhs_of_le >>= instantiate_mvars >>= λ e', succeeds $ is_def_eq Γ_new e') <|> return ff),\n    -- trace ctx2',\n    ctx2'.mmap' (λ H, do H_tp <- infer_type H,\n                         e'' <- lhs_of_le H_tp,\n                         succeeds (unify Γ_new e'') >>\n                   tactic.replace (get_name H) ``(_ : %%Γ_new ≤ _) >> swap >> assumption)\n\n\n\n/-- If the goal is an inequality `a ≤ b`, extracts `a` and attempts to specialize all\n  facts in context of the form `Γ ≤ d` to `a ≤ d` (this requires a ≤ Γ) -/\nmeta def specialize_context (Γ : parse texpr) : tactic unit :=\ndo\n  Γ_old <- i_to_expr Γ,\n  specialize_context_core Γ_old\n\nmeta def specialize_context_assumption (Γ : parse texpr) : tactic unit :=\ndo\n  Γ_old <- i_to_expr Γ,\n  specialize_context_assumption_core Γ_old\n\nmeta def specialize_context' (Γ : parse texpr) : tactic unit :=\ndo\n  Γ_old <- i_to_expr Γ,\n  specialize_context_core' Γ_old\n\nexample {β : Type u} [lattice.bounded_lattice β] {a b : β} {H : ⊤ ≤ b} : a ≤ b :=\nby {specialize_context (⊤ : β), assumption}\n\nmeta def bv_exfalso : tactic unit :=\n  `[refine le_trans _ (_root_.lattice.bot_le)]\n\nmeta def bv_cases_at (H : parse ident) (i : parse ident_) (H_i : parse ident?)  : tactic unit :=\ndo\n  e₀ <- resolve_name H,\n  e₀' <- to_expr e₀,\n  Γ_old <- target >>= lhs_of_le,\n  `[refine lattice.context_Or_elim %%e₀'],\n  match H_i with\n  | none :=  tactic.intro i >> ((get_unused_name H) >>= tactic.intro)\n  | (some n) := tactic.intro i >> (tactic.intro n)\n  end,\n  specialize_context_core Γ_old\n\n\nmeta def bv_cases_at' (H : parse ident) (i : parse ident_) (H_i : parse ident?)  : tactic unit :=\ndo\n  e₀ <- resolve_name H,\n  e₀' <- to_expr e₀,\n  Γ_old <- target >>= lhs_of_le,\n  `[refine lattice.context_Or_elim %%e₀'],\n  match H_i with\n  | none :=  tactic.intro i >> ((get_unused_name H) >>= tactic.intro)\n  | (some n) := tactic.intro i >> (tactic.intro n)\n  end,\n  specialize_context_core' Γ_old\n\nmeta def bv_cases_at'' (H : parse ident) (i : parse ident_)  : tactic unit :=\ndo\n  e₀ <- resolve_name H,\n  e₀' <- to_expr e₀,\n  Γ_old <- target >>= lhs_of_le,\n  `[refine lattice.context_Or_elim %%e₀'],\n  tactic.intro i >> ((get_unused_name H) >>= tactic.intro) >>\n  skip\n\n-- here `e` is the proof of Γ ≤ a ⊔ b\nmeta def bv_or_elim_at_core (e : expr) (Γ_old : expr) (n_H : name) : tactic unit :=\ndo\n   n <- get_unused_name (n_H ++ \"left\"),\n   n' <- get_unused_name (n_H ++ \"right\"),\n   `[apply lattice.context_or_elim %%e],\n   (tactic.intro n) >> specialize_context_core Γ_old, swap,\n   (tactic.intro n') >> specialize_context_core Γ_old, swap\n\nmeta def bv_or_elim_at_core' (e : expr) (Γ_old : expr) (n_H : name) : tactic unit :=\ndo\n   n <- get_unused_name (n_H ++ \"left\"),\n   n' <- get_unused_name (n_H ++ \"right\"),\n   `[apply lattice.context_or_elim %%e],\n   (tactic.intro n) >> specialize_context_core' Γ_old, swap,\n   (tactic.intro n') >> specialize_context_core' Γ_old, swap\n\nmeta def bv_or_elim_at_core'' (e : expr) (Γ_old : expr) (n_H : name) : tactic unit :=\ndo\n   n <- get_unused_name (n_H ++ \"left\"),\n   n' <- get_unused_name (n_H ++ \"right\"),\n   `[apply lattice.context_or_elim %%e]; tactic.clear e,\n   (tactic.intro n) >> specialize_context_core' Γ_old, swap,\n   (tactic.intro n') >> specialize_context_core' Γ_old, swap\n\nmeta def bv_or_elim_at (H : parse ident) : tactic unit :=\ndo Γ_old <- target >>= lhs_of_le,\n   e <- resolve_name H >>= to_expr,\n   bv_or_elim_at_core e Γ_old H\n\n-- `px` is a term of type `𝔹`; this cases on \"`px ∨ ¬ px`\"\nmeta def bv_cases_on (px : parse texpr) (opt_id : parse (tk \"with\" *> ident)?) : tactic unit :=\ndo Γ_old ← target >>= lhs_of_le,\n   e ← to_expr ``(lattice.bv_em_aux %%Γ_old %%px),\n   let nm := option.get_or_else opt_id \"H\",\n   get_unused_name nm >>= bv_or_elim_at_core e Γ_old\n\nmeta def bv_or_elim_at' (H : parse ident) : tactic unit :=\ndo Γ_old <- target >>= lhs_of_le,\n   e <- resolve_name H >>= to_expr,\n   bv_or_elim_at_core' e Γ_old H\n\n-- `px` is a term of type `𝔹`; this cases on \"`px ∨ ¬ px`\"\nmeta def bv_cases_on' (px : parse texpr) (opt_id : parse (tk \"with\" *> ident)?) : tactic unit :=\ndo Γ_old ← target >>= lhs_of_le,\n   e ← to_expr ``(lattice.bv_em_aux %%Γ_old %%px),\n   let nm := option.get_or_else opt_id \"H\",\n   get_unused_name nm >>= bv_or_elim_at_core' e Γ_old\n\nexample {β : Type*} [lattice.nontrivial_complete_boolean_algebra β] {Γ : β} : Γ ≤ ⊤ :=\nbegin\n  bv_cases_on ⊤,\n    { from ‹_› },\n    { by simp* }\nend\n\n-- TODO(jesse) debug these\n-- meta def auto_or_elim_step : tactic unit :=\n-- do  ctx <- local_context >>= (λ l, l.mfilter hyp_is_ineq_sup),\n--     if ctx.length > 0 then\n--     ctx.mmap' (λ e, do Γ_old <- target >>= lhs_of_le, bv_or_elim_at_core e Γ_old)\n--     else tactic.failed\n\n-- meta def auto_or_elim : tactic unit := tactic.repeat auto_or_elim_step\n\n-- example {β ι : Type u} [lattice.complete_boolean_algebra β] {s : ι → β} {H' : ⊤ ≤ ⨆i, s i} {b : β} : b ≤ ⊤ :=\n-- by {specialize_context ⊤, bv_cases_at H' i, specialize_context Γ, sorry }\n\nmeta def bv_exists_intro (i : parse texpr): tactic unit :=\n  `[refine le_supr_of_le %%i _]\n\ndef eta_beta_cfg : dsimp_config :=\n{ md := reducible,\n  max_steps := simp.default_max_steps,\n  canonize_instances := tt,\n  single_pass := ff,\n  fail_if_unchanged := ff,\n  eta := tt,\n  zeta := ff,\n  beta := tt,\n  proj := ff,\n  iota := ff,\n  unfold_reducible := ff,\n  memoize := tt }\n\nmeta def bv_specialize_at (H : parse ident) (j : parse texpr) : tactic unit :=\ndo n <- get_unused_name H,\n   e_H <- resolve_name H,\n   e <- to_expr ``(lattice.context_specialize %%e_H %%j),\n   note n none e >>= λ h, dsimp_hyp h none [] eta_beta_cfg\n\nmeta def bv_to_pi (H : parse ident) : tactic unit :=\ndo   e_H <- resolve_name H,\n     e_rhs <- to_expr e_H >>= infer_type >>= rhs_of_le,\n     (tactic.replace H  ``(lattice.context_specialize %%e_H) <|>\n     tactic.replace H ``(lattice.context_imp_elim %%e_H)) <|>\n     tactic.fail \"target is not a ⨅ or an ⟹\"\n\nmeta def bv_to_pi' : tactic unit :=\ndo ctx <- (local_context >>= (λ l, l.mfilter hyp_is_ineq)),\n   ctx.mmap' (λ e, try ((tactic.replace (get_name e)  ``(lattice.context_specialize %%e) <|>\n     tactic.replace (get_name e) ``(lattice.context_imp_elim %%e))))\n\nmeta def bv_split_at (H : parse ident) : tactic unit :=\ndo e_H <- resolve_name H,\n   tactic.replace H ``(lattice.le_inf_iff.mp %%e_H),\n   resolve_name H >>= to_expr >>= cases_core\n\nmeta def bv_split : tactic unit :=\ndo ctx <- (local_context >>= (λ l, l.mfilter hyp_is_ineq)),\n   ctx.mmap' (λ e, try (tactic.replace (get_name e) ``(lattice.le_inf_iff.mp %%e))),\n   auto_cases >> skip\n\nmeta def bv_and_intro (H₁ H₂ : parse ident) : tactic unit :=\ndo\n  H₁ <- resolve_name H₁,\n  H₂ <- resolve_name H₂,\n  e <- to_expr ``(lattice.context_and_intro %%H₁ %%H₂),\n   n <- get_unused_name \"H\",\n   note n none e >> skip\n\nmeta def bv_imp_elim_at (H₁ : parse ident) (H₂ : parse texpr) : tactic unit :=\ndo n <- get_unused_name \"H\",\n   e₁ <- resolve_name H₁,\n   e <- to_expr ``(lattice.context_imp_elim %%e₁ %%H₂),\n   note n none e >>= λ h, dsimp_hyp h none [] eta_beta_cfg\n\nmeta def bv_mp (H : parse ident) (H₂ : parse texpr) : tactic unit :=\ndo\n   n <- get_unused_name H,\n   e_H <- resolve_name H,\n   e_L <- to_expr H₂,\n   pr <- to_expr ``(le_trans %%e_H %%e_L),\n   note n none pr >>= λ h, dsimp_hyp h none [] eta_beta_cfg\n\nmeta def bv_imp_intro (nm : parse $ optional ident_) : tactic unit :=\nmatch nm with\n| none := do Γ_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (get_unused_name \"H\" >>= tactic.intro) >> skip,\n  specialize_context_core Γ_old\n| (some n) := do Γ_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (tactic.intro n) >> skip,\n  specialize_context_core Γ_old\nend\n\nmeta def bv_imp_intro' (nm : parse $ optional ident_) : tactic unit :=\nmatch nm with\n| none := do Γ_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (get_unused_name \"H\" >>= tactic.intro) >> skip,\n  specialize_context_core' Γ_old\n| (some n) := do Γ_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (tactic.intro n) >> skip,\n  specialize_context_core' Γ_old\nend\n\nmeta def tidy_context_tactics : list (tactic string) :=\n[ reflexivity                                 >> pure \"refl\",\n  propositional_goal >> assumption            >> pure \"assumption\",\n  intros1                                     >>= λ ns, pure (\"intros \" ++ (\" \".intercalate (ns.map (λ e, e.to_string)))),\n  auto_cases,\n  `[simp only [_root_.lattice.le_inf_iff] at *]                                >> pure \"simp only [le_inf_iff] at *\",\n  propositional_goal >> (`[solve_by_elim])    >> pure \"solve_by_elim\"\n]\n\nmeta def tidy_split_goals_tactics : list (tactic string) :=\n[ reflexivity >> pure \"refl\",\n propositional_goal >> assumption >> pure \"assumption\",\n  propositional_goal >> (`[solve_by_elim])    >> pure \"solve_by_elim\",\n  `[refine lattice.le_inf _ _] >> pure \"refine lattice.le_inf _ _\",\n  `[exact bv_refl]        >> pure \"exact bv_refl _\",\n  `[rw[bSet.bv_eq_symm]] >> assumption >> pure \"rw[bSet.bv_eq_symm], assumption\",\n   bv_intro none >> pure \"bv_intro\"\n]\n\nmeta def bv_split_goal (trace : parse $ optional (tk \"?\")) : tactic unit :=\n  tactic.tidy {trace_result := trace.is_some, tactics := tidy_split_goals_tactics}\n\nmeta def bv_or_inr : tactic unit := `[refine le_sup_right_of_le _]\nmeta def bv_or_inl : tactic unit := `[refine le_sup_left_of_le _]\n\n/--\nSucceeds on `e` iff `e` can be matched to the pattern x ≤ - y\n-/\nprivate meta def is_le_neg (e : expr) : tactic (expr × expr) :=\ndo `(%%x ≤ - %%y) <- pure e, return (x,y)\n\n-- private meta def le_not (lhs : expr) (rhs : expr) : expr → tactic expr := λ e,\n-- do `(%%x ≤ - %%y) <- pure e,\n--    is_def_eq x lhs >> is_def_eq y rhs >> return e\n\n/--\nGiven an expr `e` such that the type of `e` is `x ≤ -y`, succeed if an expression of type `x ≤ y` is in context and return it.\n-/\nprivate meta def find_dual_of (ctx_le : list expr) (ctx_le_negated : list expr) (e : expr) : tactic expr :=\ndo `(%%y₁ ≤ - %%y₂) <- (infer_type e),\n   match ctx_le with\n   | [] := tactic.fail \"there are no hypotheses\"\n   | hd :: tl := do b <- (succeeds (do `(%%x₁ ≤ %%x₂) <- (infer_type hd),\n                                       is_def_eq x₁ y₁, is_def_eq x₂ y₂)),\n                    if b then return hd else by exact _match tl\n   end\n\nprivate meta def find_dual (xs : list expr) : tactic (expr × expr) :=\ndo xs' <- (xs.mfilter (λ x, succeeds (do `(- %%y) <- ((infer_type x) >>= (rhs_of_le)), skip))),\n   match xs' with\n   | list.nil := tactic.fail \"no negated terms found\"\n   | (hd :: tl) := (do hd' <- find_dual_of xs xs' hd, return (hd', hd)) <|> by exact _match tl\n   end\n\nmeta def bv_contradiction  : tactic unit :=\ndo ctx <- (local_context >>= λ l, l.mfilter (hyp_is_ineq)),\n   (h₁,h₂) <- find_dual ctx,\n   bv_exfalso >> mk_app (`lattice.bv_absurd) [h₁,h₂] >>= tactic.exact\n\nmeta structure context_cfg :=\n(trace_result : bool := ff)\n(trace_result_prefix : string := \"/- `tidy_context` says -/ refine poset_yoneda _, \")\n(tactics : list(tactic string) := tidy_context_tactics)\n\nmeta def cfg_of_context_cfg : context_cfg → cfg :=\nλ X, { trace_result := X.trace_result,\n  trace_result_prefix := X.trace_result_prefix,\n  tactics := X.tactics}\n\nmeta def tidy_context (cfg : context_cfg := {}) : tactic unit :=\n`[refine _root_.lattice.poset_yoneda _] >> tactic.tidy (cfg_of_context_cfg cfg)\n\ndef with_h_asms {𝔹} [lattice.lattice 𝔹] (Γ : 𝔹) : Π (xs : list (𝔹)) (g : 𝔹), Prop\n | [] x := Γ ≤ x\n | (x :: xs) y := Γ ≤ x → with_h_asms xs y\n\n-- intended purpose is to make specialized contexts opaque with have-statements\n\n-- suppose we eliminate an existential quantification over S : ι → 𝔹\n\n-- this introduces a new index i : ι into context, and now we have to add additionally the assumption that Γ ≤ S i.\n\n-- Therefore, the next step is to revert all dependences except for i, so that we then have\n\n-- ∀ Γ'', with_h_asms Γ'' [p,q,r,S i] g → (Γ' ≤ p → Γ' ≤ q → Γ' ≤ r → Γ' ≤ S i → Γ' ≤ g)\n-- some work still has to be done in showing\n-- that Γ' ≤ Γ and applying le_trans, but this should be cleaner because the specific substitutions are no longer accessible.\n\nend natded_tactics\nend interactive\nend tactic\n\nnamespace lattice\n\nlocal infix ` ⟹ `:75 := lattice.imp\n\nexample {𝔹} [complete_boolean_algebra 𝔹] {a b c : 𝔹} :\n ( a ⟹ b ) ⊓ ( b ⟹ c ) ≤ a ⟹ c :=\nby {tidy_context, bv_imp_intro Ha, exact a_1_right (a_1_left Ha)}\n-- tactic state before final step:\n-- a b c Γ : β,\n-- Γ_1 : β := a ⊓ Γ,\n-- a_1_left : Γ_1 ≤ a ⟹ b,\n-- a_1_right : Γ_1 ≤ b ⟹ c,\n-- Ha : Γ_1 ≤ a\n-- ⊢ Γ_1 ≤ c\n\n\nexample {β : Type*} [complete_boolean_algebra β] {a b c : β} :\n ( a ⟹ b ) ⊓ ( b ⟹ c ) ≤ a ⟹ c :=\nbegin\n  rw[<-deduction], unfold imp, rw[inf_sup_right, inf_sup_right],\n  simp only [inf_assoc, sup_assoc], refine sup_le _ _,\n  ac_change (-a ⊓ a) ⊓ (-b ⊔ c) ≤ c,\n  from inf_le_left_of_le (by simp), rw[inf_sup_right],\n  let x := _, let y := _, change b ⊓ (x ⊔ y) ≤ _,\n  rw[inf_sup_left], apply sup_le,\n  { simp[x, inf_assoc.symm] },\n  { from inf_le_right_of_le (by simp) }\nend\n\nend lattice\n", "meta": {"author": "flypitch", "repo": "flypitch", "sha": "aea5800db1f4cce53fc4a113711454b27388ecf8", "save_path": "github-repos/lean/flypitch-flypitch", "path": "github-repos/lean/flypitch-flypitch/flypitch-aea5800db1f4cce53fc4a113711454b27388ecf8/src/to_mathlib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.746138993030751, "lm_q1q2_score": 0.46989940177440725}}
{"text": "import combinatorics.simple_graph.subgraph\nimport combinatorics.simple_graph.connectivity\nimport combinatorics.simple_graph.matching\nimport combinatorics.simple_graph.coloring\nimport data.finset.basic\nimport set_theory.cardinal.basic\nimport set_theory.cardinal.finite\nimport set_theory.cardinal.ordinal\nimport local.cardinal\nimport local.set\nimport local.subgraph\nimport local.matching\nimport local.connectivity\nuniverse univ\n\nvariables {V : Type univ} {α : Type*} {G : simple_graph V} {M : G.subgraph}\nvariables {u v : V}\nvariables {p: G.path u v}\n\nlemma sym2.mem_exists: ∀ xy: sym2 V, ∃ x : V, x ∈ xy :=\nbegin\n  rw sym2.forall,\n  exact λ x y, ⟨x, sym2.mem_mk_left _ _⟩,\nend\n\nnoncomputable\ndef sym2.left (xy: sym2 V): V := classical.some (sym2.mem_exists xy)\n\ntheorem sym2.left.mem (xy: sym2 V): sym2.left xy ∈ xy := classical.some_spec (sym2.mem_exists xy)\n\ntheorem sym2.left.mem_of_eq {xy: sym2 V}: sym2.left xy = v → v ∈ xy :=\nbegin\n  intro h,\n  rw [← h],\n  exact sym2.left.mem _\nend\n\ntheorem sym2.or_of_left (x y: V): x = sym2.left ⟦(x, y)⟧ ∨ y = sym2.left ⟦(x, y)⟧ :=\nbegin\n  cases sym2.mem_iff.mp (sym2.left.mem ⟦(x, y)⟧); rw [h],\n  exact or.inl rfl,\n  exact or.inr rfl,\nend\n\ntheorem sym2.or_of_left_eq {x y z: V}: sym2.left ⟦(x, y)⟧ = z → x = z ∨ y = z :=\nbegin\n  cases sym2.mem_iff.mp (sym2.left.mem ⟦(x, y)⟧); rw [h],\n  exact or.inl,\n  exact or.inr\nend\n\nnamespace simple_graph\nnamespace subgraph\n\ndef is_matching.left (hM: M.is_matching): set V := set.image sym2.left M.edge_set\n\ndef is_matching.right (hM: M.is_matching): set V := set.image hM.other hM.left\n\ntheorem is_matching.right_of_left (hM: M.is_matching): hM.right = set.image hM.other hM.left := rfl\n\ntheorem is_matching.left_of_right (hM: M.is_matching):\n  hM.left = set.image hM.other hM.right :=\nby ext1; simp [is_matching.right, set.mem_image, is_matching.other_inverse]\n\ntheorem is_matching.left_def (hM: M.is_matching) {e: sym2 V}: e ∈ M.edge_set → e.left ∈ hM.left := set.mem_image_of_mem _\n\ntheorem is_matching.left_mem (hM: M.is_matching) {v: V}: v ∈ hM.left → v ∈ M.verts :=\nbegin\n  simp only [is_matching.left, set.mem_image, forall_exists_index, and_imp, sym2.forall],\n  exact λ x y hxy hv, (hv.symm ▸ mem_verts_if_mem_edge) hxy (sym2.left.mem _),\nend\n\ntheorem is_matching.left_subset (hM: M.is_matching): hM.left ⊆ M.verts := λ _, hM.left_mem\n\ntheorem is_matching.left_mem_of_right (hM: M.is_matching) {v: V}: v ∈ hM.right → hM.other v ∈ hM.left :=\nby simp [hM.left_of_right, hM.other_inj_iff]\n\ntheorem is_matching.left_mem_of_right' (hM: M.is_matching) {v: V}: hM.other v ∈ hM.right → v ∈ hM.left :=\nby simp [hM.left_of_right, hM.other_inj_iff']\n\n\ntheorem is_matching.right_mem_of_left (hM: M.is_matching) {v: V}: v ∈ hM.left → hM.other v ∈ hM.right :=\nby simp [is_matching.right, hM.other_inj_iff]\n\ntheorem is_matching.right_mem_of_left' (hM: M.is_matching) {v: V}: hM.other v ∈ hM.left → v ∈ hM.right :=\nby simp [is_matching.right, hM.other_inj_iff']\n\ntheorem is_matching.right_mem (hM: M.is_matching) {v: V}: v ∈ hM.right → v ∈ M.verts :=\nbegin\n  simp only [is_matching.right, set.mem_image, forall_exists_index, and_imp, sym2.forall],\n  exact λ x hxM hxv, hxv ▸ hM.other_mem_verts (hM.left_mem hxM)\nend\n\ntheorem is_matching.left_unique_edge  (hM: M.is_matching) {v: V}: v ∈ hM.left → ∃! u : sym2 V, u ∈ M.edge_set ∧ u.left = v :=\nbegin\n  unfold is_matching.left,\n  rw [set.mem_image],\n  intro h,\n  rcases h with ⟨x, hxM, hxv⟩,\n  refine exists_unique_of_exists_of_unique ⟨x, hxM, hxv⟩ _,\n  simp only [and_imp],\n  intros y z hyM hyv hzM hzv,\n  exact hM.unique_edge hyM hzM (sym2.left.mem_of_eq hyv) (sym2.left.mem_of_eq hzv),\nend\n\ntheorem is_matching.left_unique_edge' (hM: M.is_matching) {v: V}: v ∈ hM.left → ∃! u : sym2 V, u ∈ M.edge_set ∧ v ∈ u :=\nbegin\n  unfold is_matching.left,\n  rw [set.mem_image],\n  intro h,\n  rcases h with ⟨x, hxM, hxv⟩,\n  refine exists_unique_of_exists_of_unique ⟨x, hxM, sym2.left.mem_of_eq hxv⟩ _,\n  simp only [and_imp],\n  intros y z hyM hyv hzM hzv,\n  exact hM.unique_edge hyM hzM hyv hzv,\nend\n\ntheorem is_matching.left_of_edge (hM: M.is_matching) {v: V} {e: sym2 V}: v ∈ hM.left → v ∈ e → e ∈ M.edge_set → e.left = v :=\nbegin\n  intros hvM hve heM,\n  rcases exists_unique.exists (hM.left_unique_edge hvM) with ⟨x, hxM, hxv⟩,\n  rwa exists_unique.unique (hM.left_unique_edge' hvM) (and.intro heM hve) (and.intro hxM (sym2.left.mem_of_eq hxv)),\nend\n\ntheorem is_matching.left_other (hM: M.is_matching) {v: V}: v ∈ hM.left → hM.other v ∉ hM.left :=\nbegin\n  intros hv hv',\n  rcases hM.left_unique_edge' hv with ⟨e, ⟨hm, hve⟩, hu ⟩,\n  rcases exists_unique.exists (hM.left_unique_edge' hv') with ⟨e', hm', hve'⟩,\n  apply hM.ne_of_mem (hM.left_mem hv),\n  rw [← hM.left_of_edge hv' hve' hm', ← hM.left_of_edge hv hve hm, hu e' (and.intro hm' (hM.edge_of_other hve' hm'))],\nend\n\ntheorem is_matching.left_other' (hM: M.is_matching) {v: V}: hM.other v ∈ hM.left → v ∉ hM.left :=\n   λ h, hM.other_inverse v ▸ (hM.left_other h)\n  \ntheorem is_matching.right_other (hM: M.is_matching) {v: V}: v ∈ hM.right → hM.other v ∉ hM.right :=\nλ hl hr, hM.left_other (hM.left_mem_of_right hl) (hM.left_mem_of_right hr)\n\n\ntheorem is_matching.right_other' (hM: M.is_matching) {v: V}: hM.other v ∈ hM.right → v ∉ hM.right :=\n  λ h, hM.other_inverse v ▸ (hM.right_other h)\n\ntheorem is_matching.left_independent (hM: M.is_matching) (x y: V): x ∈ hM.left → y ∈ hM.left → ¬ M.adj x y :=\nbegin\n  intros hx hy he,\n  rw [hM.other_of_adj_iff (hM.left_mem hy)] at he,\n  apply hM.left_other hy,\n  rwa [← he]\nend\n\ntheorem is_matching.left_is_antichain (hM: M.is_matching): is_antichain M.adj hM.left :=\nbegin\n  intros x hx y hy _,\n  unfold has_compl.compl,\n  rw [hM.other_of_adj_iff (hM.left_mem hy)],\n  intro heq,\n  apply hM.left_other hy,\n  rwa [← heq],\nend\n\ntheorem is_matching.left_edge_cover (hM: M.is_matching) {x y: V}:\n  M.adj x y → x ∈ hM.left ∨ y ∈ hM.left :=\nbegin\n  rw [← mem_edge_set],\n  intro p,\n  cases sym2.or_of_left x y with h h;\n  rw [h],\n  exact or.inl (hM.left_def p),\n  exact or.inr (hM.left_def p),\nend\n\ntheorem is_matching.left_other_cover (hM: M.is_matching) {x: V}:\n  x ∈ M.verts → x ∈ hM.left ∨ hM.other x ∈ hM.left := hM.left_edge_cover ∘ hM.other_adj\n\ntheorem is_matching.other_card (hM: M.is_matching) {s: set V}:\n  cardinal.mk s = cardinal.mk (s.image hM.other) :=\nbegin\n  rw cardinal.eq,\n  refine ⟨⟨\n    λ x, ⟨hM.other x, (set.mem_image _ _ _).mpr ⟨x, x.property, rfl⟩⟩,\n    λ x, ⟨hM.other x, _, ⟩,\n      _, _⟩⟩,\n    { rcases x.property with ⟨y, hys, hyx⟩,\n      unfold_coes,\n      rwa [← hyx, hM.other_inverse] },\n  all_goals { intro; simp [hM.other_inverse] },\nend\n\ntheorem is_matching.left_right_card (hM: M.is_matching):\n  cardinal.mk hM.left = cardinal.mk hM.right :=\nbegin\n  rw cardinal.eq,\n  refine ⟨⟨\n    λ x, ⟨hM.other x, (set.mem_image _ _ _).mpr ⟨x, x.property, rfl⟩⟩,\n    λ x, ⟨hM.other x, hM.left_of_right.symm ▸ (set.mem_image _ _ _).mpr ⟨x, x.property, rfl⟩⟩,\n    _, _ ⟩⟩,\n    all_goals { intro; simp [hM.other_inverse] },\nend\n\ntheorem is_matching.left_right_total (hM: M.is_matching):\n  M.verts = hM.left ∪ hM.right :=\nset.ext (λ x, ⟨\n    λ hx, or.elim (hM.left_other_cover hx)\n      (λ h, or.inl h)\n      (λ h, or.inr ((set.mem_image _ _ _).mpr ⟨hM.other x, h, hM.other_inverse _⟩)),\n    λ h, or.elim h hM.left_mem hM.right_mem ⟩)\n\ntheorem is_matching.left_right_disjoint (hM: M.is_matching):\n  disjoint hM.left hM.right :=\nbegin\n  rw [set.disjoint_left],\n  exact λ _ h, hM.right_other' (hM.right_mem_of_left h)\nend\n\ntheorem is_matching.other_disjoint (hM: M.is_matching) {s: set V}:\n  s ⊆ M.verts → is_antichain M.adj s → disjoint s (s.image hM.other) :=\nbegin\n  intros hsub hanti,\n  rw [set.disjoint_left],\n  intros x hx hx',\n  have hxM := set.mem_of_subset_of_mem hsub hx,\n  exact is_antichain.not_mem hanti hx (hM.ne_of_mem hxM) (hM.other_adj hxM) (hM.other_image hx'),\nend\n\ntheorem is_matching.delete_pair (hM: M.is_matching) (v: M.verts):\n  (M.delete_verts {v, hM.other v}).is_matching :=\nbegin\n  intros u hu,\n  have hv : u ≠ v,\n  by contrapose! hu; simp [hu],\n  have hv' : u ≠ hM.other v,\n  by contrapose! hu; simp [hu],\n  have hMu := set.mem_of_mem_diff hu,\n  rw [exists_unique_congr],\n  apply hM hMu,\n  simp [hv, hv', hMu,\n    set.mem_diff, set.mem_insert_iff, set.mem_singleton_iff,\n    induce_verts, induce_adj, delete_verts, hM.other_of_adj_iff',\n    hM.other_inverse, hM.other_mem_verts, hM.other_inj_iff, hM.other_inj_iff',\n    not_or_distrib]\nend\n\ntheorem is_matching.is_matching_induce (hM: M.is_matching) {s: set V} (hs: s ⊆ M.verts):\n  (∀ {v}, v ∈ s → ∃ u, u ∈ s ∧ M.adj v u) → (M.induce s).is_matching :=\nbegin\n  intros h v hv,\n  have hv' := set.mem_of_subset_of_mem hs hv,\n  rw [exists_unique_congr],\n  { exact hM hv' },\n  refine λ x, ⟨ and.right ∘ and.right, λ hadj, ⟨ hv, _, hadj ⟩ ⟩,\n  rcases h hv with ⟨u, hu, hadj'⟩,\n  rwa [exists_unique.unique (hM hv') hadj hadj'],\nend\n\ntheorem is_matching.exists_smaller (hM: M.is_matching) {c: cardinal} (hc: c ≤ cardinal.mk M.verts) (hc': even c):\n  ∃ M': G.subgraph, M'.verts ⊆ M.verts ∧ cardinal.mk M'.verts = c ∧ M'.is_matching :=\nbegin\n  cases hc' with d hd,\n  rcases @set.cardinal_embedding _ hM.left d  _ with ⟨s, hcard, hsub⟩,\n  refine ⟨M.induce (s ⊔ set.image hM.other s), _, _, _⟩,\n  { simp only [set.union_subset_iff, set.image_subset_iff, set.sup_eq_union, simple_graph.subgraph.induce_verts],\n    exact ⟨ set.subset.trans hsub hM.left_subset, λ x hx, hM.other_mem_verts (hM.left_mem (hsub hx)) ⟩ },\n  { rwa [set.sup_eq_union, simple_graph.subgraph.induce_verts, cardinal.mk_union_of_disjoint, ← hM.other_card, hcard, @eq_comm _ _ c],\n    exact hM.other_disjoint (subset_trans hsub hM.left_subset) (is_antichain.subset hM.left_is_antichain hsub) },\n  { refine hM.is_matching_induce _ _,\n    { exact λ v  hv, or.elim hv\n        (set.mem_of_subset_of_mem (trans hsub hM.left_subset))\n        (λ h, hM.other_mem_verts' (hM.other_image (set.mem_of_subset_of_mem\n          (trans (set.image_subset hM.other hsub)\n          (set.image_subset hM.other hM.left_subset)) h))),\n    },\n    { exact λ v hv, or.elim hv\n      (λ hv, ⟨hM.other v, or.inr ((set.mem_image _ _ _).mpr ⟨_, hv, rfl⟩),\n        hM.other_adj (set.mem_of_subset_of_mem (trans hsub hM.left_subset) hv) ⟩)\n      (λ hv, ⟨hM.other v, or.inl (hM.other_image' hv),\n        hM.other_adj (hM.other_mem_verts' (set.mem_of_subset_of_mem\n          (trans hsub hM.left_subset) (hM.other_image' hv))) ⟩) },\n  },\n  { apply cardinal.nat_cast_left_mul_le_mul _ _ (show 0 < 2, by simp),\n    simp only [algebra_map.coe_one, one_mul, coe_is_add_hom.coe_add, ← hd, add_mul, (show 2 = 1 + 1, by refl)],\n    conv {\n      to_rhs,\n      congr,\n      skip,\n      rw [hM.other_card, ← hM.right_of_left],\n    },\n    rwa [← cardinal.mk_union_of_disjoint hM.left_right_disjoint, ← hM.left_right_total],\n  },\nend\n\nstructure alternating_path (p: path G u v) (M: G.subgraph): Prop :=\n  (start_inv: u ∉ M.verts)\n  (alt_inv: ∀ {x y z}, y ≠ z → (p:G.subgraph).adj x y → (p:G.subgraph).adj x z →\n    (xor (M.adj x y) (M.adj x z)))\n\nnamespace alternating_path\n\ntheorem mem_verts (ap: alternating_path p M) {x: V}:\n  x ∈ (p: G.subgraph).verts → u = x ∨ v = x ∨ x ∈ M.verts :=\nbegin\n  simp only [p.coe_verts_iff_get_vert, exists_imp_distrib],\n  intros n hn h,\n  induction h,\n  cases eq_or_lt_of_le hn with hn hn,\n  { simp [hn] },\n  cases n,\n  { simp },\n  right, right,\n  cases ap.alt_inv _(walk.adj_get_vert_succ' _ hn) (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn)),\n  exact M.edge_vert h.left,\n  exact M.edge_vert h.left,\n  apply p.get_vert_inj_ne (nat.succ_le_of_lt hn) (trans (nat.sub_le _ _) (le_of_lt hn)),\n  rw [nat.succ_sub_one, nat.succ_eq_add_one, nat.succ_eq_add_one],\n  linarith,\nend\n\n-- theorem maintains_is_matching (ap: alternating_path p M):\n--   M.is_matching → (M ∆ p).is_matching :=\n-- begin\n--   intro hM,\n--   intro x,\n--   intro hx,\n--   by_cases x ∈ (p:G.subgraph).verts,\n--   { rw [p.coe_verts_iff_get_vert] at h,\n--     rcases h with ⟨n, hn, h⟩,\n--     rw [← h],\n--     cases eq_or_lt_of_le hn with hn hn,\n--     { rw [hn, walk.get_vert_length],\n--       exact subgraph.symm_diff_adj_unique_right' _ _ _ (λ _, not_imp_not.mpr M.edge_vert ap.end_inv) (p.end_unique_adj ap.not_nil) },\n--     cases n,\n--     { rw [walk.get_vert_zero],\n--       exact subgraph.symm_diff_adj_unique_right' _ _ _ (λ _, not_imp_not.mpr M.edge_vert ap.start_inv) (p.start_unique_adj ap.not_nil) },\n--     cases ap.alt_inv _ (walk.adj_get_vert_succ' _ hn) (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn)),\n--     { apply hM.unique_symm_diff\n--       h_1.left h_1.right\n--       (walk.adj_get_vert_succ' _ hn)\n--       (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn))\n--       (λ _, p.neighbors' (le_of_lt hn)) },\n--     { apply hM.unique_symm_diff\n--         h_1.left h_1.right\n--         (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn))\n--         (walk.adj_get_vert_succ' _ hn),\n--       intro y,\n--       simpa [or.comm] using p.neighbors' (le_of_lt hn) },\n--     apply p.get_vert_inj_ne (nat.succ_le_of_lt hn) (trans (nat.sub_le _ _) (le_of_lt hn)),\n--     rw [nat.succ_sub_one, nat.succ_eq_add_one, nat.succ_eq_add_one],\n--     linarith },\n--   { apply M.symm_diff_adj_unique_left' _ _ _ (hM (M.symm_diff_verts_not_right _ h hx)),\n--     intro y,\n--     contrapose! h,\n--     exact subgraph.edge_vert _ h }\n-- end\n\nend alternating_path\n\nstructure augmenting_path (p: path G u v) (M: G.subgraph) extends alternating_path p M: Prop :=\n  (not_nil: u ≠ v)\n  (end_inv: v ∉ M.verts)\n\nnamespace augmenting_path\n\ntheorem mem_verts (ap: augmenting_path p M) {x: V}:\n  x ∈ (p: G.subgraph).verts → u = x ∨ v = x ∨ x ∈ M.verts :=\nbegin\n  simp only [p.coe_verts_iff_get_vert, exists_imp_distrib],\n  intros n hn h,\n  induction h,\n  cases eq_or_lt_of_le hn with hn hn,\n  { simp [hn] },\n  cases n,\n  { simp },\n  right, right,\n  cases ap.alt_inv _(walk.adj_get_vert_succ' _ hn) (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn)),\n  exact M.edge_vert h.left,\n  exact M.edge_vert h.left,\n  apply p.get_vert_inj_ne (nat.succ_le_of_lt hn) (trans (nat.sub_le _ _) (le_of_lt hn)),\n  rw [nat.succ_sub_one, nat.succ_eq_add_one, nat.succ_eq_add_one],\n  linarith,\nend\n\ntheorem maintains_is_matching (ap: augmenting_path p M):\n  M.is_matching → (M ∆ p).is_matching :=\nbegin\n  intro hM,\n  intro x,\n  intro hx,\n  by_cases x ∈ (p:G.subgraph).verts,\n  { rw [p.coe_verts_iff_get_vert] at h,\n    rcases h with ⟨n, hn, h⟩,\n    rw [← h],\n    cases eq_or_lt_of_le hn with hn hn,\n    { rw [hn, walk.get_vert_length],\n      exact subgraph.symm_diff_adj_unique_right' _ _ _ (λ _, not_imp_not.mpr M.edge_vert ap.end_inv) (p.end_unique_adj ap.not_nil) },\n    cases n,\n    { rw [walk.get_vert_zero],\n      exact subgraph.symm_diff_adj_unique_right' _ _ _ (λ _, not_imp_not.mpr M.edge_vert ap.start_inv) (p.start_unique_adj ap.not_nil) },\n    cases ap.alt_inv _ (walk.adj_get_vert_succ' _ hn) (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn)),\n    { apply hM.unique_symm_diff\n      h_1.left h_1.right\n      (walk.adj_get_vert_succ' _ hn)\n      (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn))\n      (λ _, p.neighbors' (le_of_lt hn)) },\n    { apply hM.unique_symm_diff\n        h_1.left h_1.right\n        (walk.adj_get_vert_pred' _ (nat.zero_lt_succ _) (le_of_lt hn))\n        (walk.adj_get_vert_succ' _ hn),\n      intro y,\n      simpa [or.comm] using p.neighbors' (le_of_lt hn) },\n    apply p.get_vert_inj_ne (nat.succ_le_of_lt hn) (trans (nat.sub_le _ _) (le_of_lt hn)),\n    rw [nat.succ_sub_one, nat.succ_eq_add_one, nat.succ_eq_add_one],\n    linarith },\n  { apply M.symm_diff_adj_unique_left' _ _ _ (hM (M.symm_diff_verts_not_right _ h hx)),\n    intro y,\n    contrapose! h,\n    exact subgraph.edge_vert _ h }\nend\n\ntheorem or_of_not_and {p q: Prop}: (¬ p ∧ q) → p ∨ q := by tauto\n\ntheorem augmented_verts (ap: augmenting_path p M):\n  (M ∆ p).verts = insert u (insert v M.verts) :=\nbegin\n  simp only [symm_diff_verts, set.ext_iff, coe_coe, set.mem_insert_iff],\n  intro x,\n  split; intro h,\n  { cases h,\n    { exact or.inr (or.inr h) },\n    { simpa only [@eq_comm _ x] using ap.mem_verts h } },\n  obtain h|h|h := h;\n  { simp [h] },\nend\n\ntheorem augmented_cardinality (ap: augmenting_path p M):\n  cardinal.mk (M ∆ p).verts = (cardinal.mk M.verts) + 2 :=\nbegin\n  rw [ap.augmented_verts, cardinal.mk_insert, cardinal.mk_insert ap.end_inv],\n  { ring },\n  rw [set.mem_insert_iff, not_or_distrib],\n  exact ⟨ap.not_nil, ap.start_inv⟩,\nend\nend augmenting_path\n\n-- theorem bergs_lemma_helper\n--   (M: G.subgraph) [finset M.verts]\n\n\n-- theorem is_matching.bergs_lemma_helper\n--     (hM: is_matching M) (n: ℕ) (hn: cardinal.mk M.verts = 2 * n) {N: subgraph G} (hN: is_matching N):\n--     ∀ (u: V), u ∉ M.verts → u ∈ N.verts → ∃ (v: V) (p: path G u v), augmenting_path p M :=\n-- begin\n--   induction n generalizing M N,\n--   { simp only [algebra_map.coe_zero, nat.nat_zero_eq_zero, mul_zero, cardinal.mk_emptyc_iff] at hn,\n--     intros u huM huN,\n--     refine ⟨ hN.other u, path.singleton (N.adj_sub (hN.other_adj huN)), hN.ne_of_mem huN, huM, _, _⟩,\n--     { simp only [hn, set.mem_empty_iff_false, not_false_iff] },\n--     intros x y z hyz,\n--     unfold_coes,\n--     unfold walk.to_subgraph,\n--     simp,\n--     intros hxy hxz,\n--     exfalso,\n--     cases hxy;\n--     simp only [hxy, hN.ne_of_mem huN, (hN.ne_of_mem huN).symm,\n--       false_and, or_false, false_or, eq_self_iff_true, true_and] at hxz;\n--     apply hyz;\n--     rw [hxy.right, hxz] },\n--   intros u huM huN,\n--   by_cases huM': hN.other u ∈ M.verts,\n--   { specialize n_ih (hM.delete_pair ⟨_, huM'⟩) _ (hN.delete_pair ⟨_, huN⟩) (hM.other (hN.other)),\n    \n\n--   },\n--   { refine ⟨ hN.other u, path.singleton (N.adj_sub (hN.other_adj huN)), hN.ne_of_mem huN, huM, huM', _⟩,\n--     intros x y z hyz,\n--     unfold_coes,\n--     unfold walk.to_subgraph,\n--     simp,\n--     intros hxy hxz,\n--     exfalso,\n--     cases hxy;\n--     simp only [hxy, hN.ne_of_mem huN, (hN.ne_of_mem huN).symm,\n--       false_and, or_false, false_or, eq_self_iff_true, true_and] at hxz;\n--     apply hyz;\n--     rw [hxy.right, hxz]\n--   },\n-- end\n\n-- theorem is_matching.bergs_lemma (hM: is_matching M) (hf: cardinal.mk M.verts < cardinal.aleph_0):\n--   (∃ {u v: V} (p: path G u v), augmenting_path p M) ↔ ¬ hM.is_maximal :=\n-- begin\n--   simp only [is_matching.is_maximal, not_forall, not_le],\n--   split,\n--   { intro h,\n--     rcases h with ⟨u, v, p, ap⟩,\n--     use ap.augmented_subgraph,\n--     refine ⟨ ap.maintains_is_matching hM, _⟩,\n--     rw [augmenting_path.augmented_cardinality],\n--     cases cardinal.lt_aleph_0.mp hf with n hn,\n--     rw [eq_comm] at hn,\n--     induction hn,\n--     rw [← nat.cast_two, ← cardinal.nat_cast_add, cardinal.nat_cast_lt],\n--     simp },\n--   { rw[cardinal.lt_aleph_0] at hf,\n--     intro h,\n--     rcases h with ⟨N, hN, h⟩,\n--     cases hf with n hn,\n--     have hn' := hN.exists_smaller _ _,\n\n\n--   }\n-- end\n\nend subgraph\nend simple_graph", "meta": {"author": "calcu16", "repo": "lean_complexity", "sha": "0dcb73bde8d1d4237f782f4790166365ac3209fe", "save_path": "github-repos/lean/calcu16-lean_complexity", "path": "github-repos/lean/calcu16-lean_complexity/lean_complexity-0dcb73bde8d1d4237f782f4790166365ac3209fe/src/local/maximal_matching.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.46989938814590987}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Filippo A. E. Nuccio\n-/\nimport algebra.big_operators.finprod\nimport ring_theory.integral_closure\nimport ring_theory.localization.integer\nimport ring_theory.localization.submodule\nimport ring_theory.noetherian\nimport ring_theory.principal_ideal_domain\nimport tactic.field_simp\n\n/-!\n# Fractional ideals\n\nThis file defines fractional ideals of an integral domain and proves basic facts about them.\n\n## Main definitions\nLet `S` be a submonoid of an integral domain `R`, `P` the localization of `R` at `S`, and `f` the\nnatural ring hom from `R` to `P`.\n * `is_fractional` defines which `R`-submodules of `P` are fractional ideals\n * `fractional_ideal S P` is the type of fractional ideals in `P`\n * `has_coe_t (ideal R) (fractional_ideal S P)` instance\n * `comm_semiring (fractional_ideal S P)` instance:\n   the typical ideal operations generalized to fractional ideals\n * `lattice (fractional_ideal S P)` instance\n * `map` is the pushforward of a fractional ideal along an algebra morphism\n\nLet `K` be the localization of `R` at `R⁰ = R \\ {0}` (i.e. the field of fractions).\n * `fractional_ideal R⁰ K` is the type of fractional ideals in the field of fractions\n * `has_div (fractional_ideal R⁰ K)` instance:\n   the ideal quotient `I / J` (typically written $I : J$, but a `:` operator cannot be defined)\n\n## Main statements\n\n  * `mul_left_mono` and `mul_right_mono` state that ideal multiplication is monotone\n  * `prod_one_self_div_eq` states that `1 / I` is the inverse of `I` if one exists\n  * `is_noetherian` states that every fractional ideal of a noetherian integral domain is noetherian\n\n## Implementation notes\n\nFractional ideals are considered equal when they contain the same elements,\nindependent of the denominator `a : R` such that `a I ⊆ R`.\nThus, we define `fractional_ideal` to be the subtype of the predicate `is_fractional`,\ninstead of having `fractional_ideal` be a structure of which `a` is a field.\n\nMost definitions in this file specialize operations from submodules to fractional ideals,\nproving that the result of this operation is fractional if the input is fractional.\nExceptions to this rule are defining `(+) := (⊔)` and `⊥ := 0`,\nin order to re-use their respective proof terms.\nWe can still use `simp` to show `↑I + ↑J = ↑(I + J)` and `↑⊥ = ↑0`.\n\nMany results in fact do not need that `P` is a localization, only that `P` is an\n`R`-algebra. We omit the `is_localization` parameter whenever this is practical.\nSimilarly, we don't assume that the localization is a field until we need it to\ndefine ideal quotients. When this assumption is needed, we replace `S` with `R⁰`,\nmaking the localization a field.\n\n## References\n\n  * https://en.wikipedia.org/wiki/Fractional_ideal\n\n## Tags\n\nfractional ideal, fractional ideals, invertible ideal\n-/\n\nopen is_localization\nopen_locale pointwise\n\nopen_locale non_zero_divisors\n\nsection defs\n\nvariables {R : Type*} [comm_ring R] {S : submonoid R} {P : Type*} [comm_ring P]\nvariables [algebra R P]\n\nvariables (S)\n\n/-- A submodule `I` is a fractional ideal if `a I ⊆ R` for some `a ≠ 0`. -/\ndef is_fractional (I : submodule R P) :=\n∃ a ∈ S, ∀ b ∈ I, is_integer R (a • b)\n\nvariables (S P)\n\n/-- The fractional ideals of a domain `R` are ideals of `R` divided by some `a ∈ R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I ⊆ P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I ⊆ R`.\n-/\ndef fractional_ideal :=\n{I : submodule R P // is_fractional S I}\n\nend defs\n\nnamespace fractional_ideal\n\nopen set\nopen submodule\n\nvariables {R : Type*} [comm_ring R] {S : submonoid R} {P : Type*} [comm_ring P]\nvariables [algebra R P] [loc : is_localization S P]\n\n/-- Map a fractional ideal `I` to a submodule by forgetting that `∃ a, a I ⊆ R`.\n\nThis coercion is typically called `coe_to_submodule` in lemma names\n(or `coe` when the coercion is clear from the context),\nnot to be confused with `is_localization.coe_submodule : ideal R → submodule R P`\n(which we use to define `coe : ideal R → fractional_ideal S P`).\n-/\ninstance : has_coe (fractional_ideal S P) (submodule R P) := ⟨λ I, I.val⟩\n\nprotected lemma is_fractional (I : fractional_ideal S P) :\n  is_fractional S (I : submodule R P) :=\nI.prop\n\nsection set_like\n\ninstance : set_like (fractional_ideal S P) P :=\n{ coe := λ I, ↑(I : submodule R P),\n  coe_injective' := set_like.coe_injective.comp subtype.coe_injective }\n\n@[simp] lemma mem_coe {I : fractional_ideal S P} {x : P} :\n  x ∈ (I : submodule R P) ↔ x ∈ I :=\niff.rfl\n\n@[ext] lemma ext {I J : fractional_ideal S P} : (∀ x, x ∈ I ↔ x ∈ J) → I = J := set_like.ext\n\n/-- Copy of a `fractional_ideal` with a new underlying set equal to the old one.\nUseful to fix definitional equalities. -/\nprotected def copy (p : fractional_ideal S P) (s : set P) (hs : s = ↑p) : fractional_ideal S P :=\n⟨submodule.copy p s hs, by { convert p.is_fractional, ext, simp only [hs], refl }⟩\n\n@[simp] lemma coe_copy (p : fractional_ideal S P) (s : set P) (hs : s = ↑p) :\n  ↑(p.copy s hs) = s :=\nrfl\n\nlemma coe_eq (p : fractional_ideal S P) (s : set P) (hs : s = ↑p) : p.copy s hs = p :=\nset_like.coe_injective hs\n\nend set_like\n\n@[simp] lemma val_eq_coe (I : fractional_ideal S P) : I.val = I := rfl\n\n@[simp, norm_cast] lemma coe_mk (I : submodule R P) (hI : is_fractional S I) :\n  (subtype.mk I hI : submodule R P) = I := rfl\n\n/-! Transfer instances from `submodule R P` to `fractional_ideal S P`. -/\ninstance (I : fractional_ideal S P) : add_comm_group I := submodule.add_comm_group ↑I\ninstance (I : fractional_ideal S P) : module R I := submodule.module ↑I\n\nlemma coe_to_submodule_injective :\n  function.injective (coe : fractional_ideal S P → submodule R P) :=\nsubtype.coe_injective\n\nlemma coe_to_submodule_inj {I J : fractional_ideal S P} : (I : submodule R P) = J ↔ I = J :=\ncoe_to_submodule_injective.eq_iff\n\nlemma is_fractional_of_le_one (I : submodule R P) (h : I ≤ 1) : is_fractional S I :=\nbegin\n  use [1, S.one_mem],\n  intros b hb,\n  rw one_smul,\n  obtain ⟨b', b'_mem, rfl⟩ := h hb,\n  exact set.mem_range_self b',\nend\n\nlemma is_fractional_of_le {I : submodule R P} {J : fractional_ideal S P} (hIJ : I ≤ J) :\n  is_fractional S I :=\nbegin\n  obtain ⟨a, a_mem, ha⟩ := J.is_fractional,\n  use [a, a_mem],\n  intros b b_mem,\n  exact ha b (hIJ b_mem)\nend\n\n/-- Map an ideal `I` to a fractional ideal by forgetting `I` is integral.\n\nThis is a bundled version of `is_localization.coe_submodule : ideal R → submodule R P`,\nwhich is not to be confused with the `coe : fractional_ideal S P → submodule R P`,\nalso called `coe_to_submodule` in theorem names.\n\nThis map is available as a ring hom, called `fractional_ideal.coe_ideal_hom`.\n-/\n-- Is a `coe_t` rather than `coe` to speed up failing inference, see library note [use has_coe_t]\ninstance : has_coe_t (ideal R) (fractional_ideal S P) :=\n⟨λ I, ⟨coe_submodule P I,\n  is_fractional_of_le_one _ $ by simpa using coe_submodule_mono P (le_top : I ≤ ⊤)⟩⟩\n\n@[simp, norm_cast] lemma coe_coe_ideal (I : ideal R) :\n  ((I : fractional_ideal S P) : submodule R P) = coe_submodule P I := rfl\n\nvariables (S)\n\n@[simp] lemma mem_coe_ideal {x : P} {I : ideal R} :\n  x ∈ (I : fractional_ideal S P) ↔ ∃ x', x' ∈ I ∧ algebra_map R P x' = x :=\nmem_coe_submodule _ _\n\nlemma mem_coe_ideal_of_mem {x : R} {I : ideal R} (hx : x ∈ I) :\n  algebra_map R P x ∈ (I : fractional_ideal S P) :=\n(mem_coe_ideal S).mpr ⟨x, hx, rfl⟩\n\nlemma coe_ideal_le_coe_ideal' [is_localization S P] (h : S ≤ non_zero_divisors R)\n  {I J : ideal R} : (I : fractional_ideal S P) ≤ J ↔ I ≤ J :=\ncoe_submodule_le_coe_submodule h\n\n@[simp] lemma coe_ideal_le_coe_ideal (K : Type*) [comm_ring K] [algebra R K] [is_fraction_ring R K]\n  {I J : ideal R} : (I : fractional_ideal R⁰ K) ≤ J ↔ I ≤ J :=\nis_fraction_ring.coe_submodule_le_coe_submodule\n\ninstance : has_zero (fractional_ideal S P) := ⟨(0 : ideal R)⟩\n\n@[simp] lemma mem_zero_iff {x : P} : x ∈ (0 : fractional_ideal S P) ↔ x = 0 :=\n⟨(λ ⟨x', x'_mem_zero, x'_eq_x⟩,\n   have x'_eq_zero : x' = 0 := x'_mem_zero,\n   by simp [x'_eq_x.symm, x'_eq_zero]),\n (λ hx, ⟨0, rfl, by simp [hx]⟩)⟩\n\nvariables {S}\n\n@[simp, norm_cast] lemma coe_zero : ↑(0 : fractional_ideal S P) = (⊥ : submodule R P) :=\nsubmodule.ext $ λ _, mem_zero_iff S\n\n@[simp, norm_cast] lemma coe_ideal_bot : ((⊥ : ideal R) : fractional_ideal S P) = 0 := rfl\n\nvariables (P)\n\ninclude loc\n\n@[simp] lemma exists_mem_to_map_eq {x : R} {I : ideal R} (h : S ≤ non_zero_divisors R) :\n  (∃ x', x' ∈ I ∧ algebra_map R P x' = algebra_map R P x) ↔ x ∈ I :=\n⟨λ ⟨x', hx', eq⟩, is_localization.injective _ h eq ▸ hx', λ h, ⟨x, h, rfl⟩⟩\n\nvariables {P}\n\nlemma coe_ideal_injective' (h : S ≤ non_zero_divisors R) :\n  function.injective (coe : ideal R → fractional_ideal S P) :=\nλ _ _ h', ((coe_ideal_le_coe_ideal' S h).mp h'.le).antisymm ((coe_ideal_le_coe_ideal' S h).mp h'.ge)\n\nlemma coe_ideal_inj' (h : S ≤ non_zero_divisors R) {I J : ideal R} :\n  (I : fractional_ideal S P) = J ↔ I = J :=\n(coe_ideal_injective' h).eq_iff\n\n@[simp] lemma coe_ideal_eq_zero' {I : ideal R} (h : S ≤ non_zero_divisors R) :\n  (I : fractional_ideal S P) = 0 ↔ I = (⊥ : ideal R) :=\ncoe_ideal_inj' h\n\nlemma coe_ideal_ne_zero' {I : ideal R} (h : S ≤ non_zero_divisors R) :\n  (I : fractional_ideal S P) ≠ 0 ↔ I ≠ (⊥ : ideal R) :=\nnot_iff_not.mpr $ coe_ideal_eq_zero' h\n\nomit loc\n\nlemma coe_to_submodule_eq_bot {I : fractional_ideal S P} :\n  (I : submodule R P) = ⊥ ↔ I = 0 :=\n⟨λ h, coe_to_submodule_injective (by simp [h]),\n λ h, by simp [h]⟩\n\nlemma coe_to_submodule_ne_bot {I : fractional_ideal S P} :\n  ↑I ≠ (⊥ : submodule R P) ↔ I ≠ 0 :=\nnot_iff_not.mpr coe_to_submodule_eq_bot\n\ninstance : inhabited (fractional_ideal S P) := ⟨0⟩\n\ninstance : has_one (fractional_ideal S P) :=\n⟨(⊤ : ideal R)⟩\n\nvariables (S)\n\n@[simp, norm_cast] lemma coe_ideal_top : ((⊤ : ideal R) : fractional_ideal S P) = 1 := rfl\n\nlemma mem_one_iff {x : P} : x ∈ (1 : fractional_ideal S P) ↔ ∃ x' : R, algebra_map R P x' = x :=\niff.intro (λ ⟨x', _, h⟩, ⟨x', h⟩) (λ ⟨x', h⟩, ⟨x', ⟨⟩, h⟩)\n\nlemma coe_mem_one (x : R) : algebra_map R P x ∈ (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr ⟨x, rfl⟩\n\nlemma one_mem_one : (1 : P) ∈ (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr ⟨1, ring_hom.map_one _⟩\n\nvariables {S}\n\n/-- `(1 : fractional_ideal S P)` is defined as the R-submodule `f(R) ≤ P`.\n\nHowever, this is not definitionally equal to `1 : submodule R P`,\nwhich is proved in the actual `simp` lemma `coe_one`. -/\nlemma coe_one_eq_coe_submodule_top :\n  ↑(1 : fractional_ideal S P) = coe_submodule P (⊤ : ideal R) :=\nrfl\n\n@[simp, norm_cast] lemma coe_one :\n  (↑(1 : fractional_ideal S P) : submodule R P) = 1 :=\nby rw [coe_one_eq_coe_submodule_top, coe_submodule_top]\n\nsection lattice\n\n/-!\n### `lattice` section\n\nDefines the order on fractional ideals as inclusion of their underlying sets,\nand ports the lattice structure on submodules to fractional ideals.\n-/\n\n@[simp] lemma coe_le_coe {I J : fractional_ideal S P} :\n  (I : submodule R P) ≤ (J : submodule R P) ↔ I ≤ J :=\niff.rfl\n\nlemma zero_le (I : fractional_ideal S P) : 0 ≤ I :=\nbegin\n  intros x hx,\n  convert submodule.zero_mem _,\n  simpa using hx\nend\n\ninstance order_bot : order_bot (fractional_ideal S P) :=\n{ bot := 0,\n  bot_le := zero_le }\n\n@[simp] lemma bot_eq_zero : (⊥ : fractional_ideal S P) = 0 :=\nrfl\n\n@[simp] lemma le_zero_iff {I : fractional_ideal S P} : I ≤ 0 ↔ I = 0 :=\nle_bot_iff\n\nlemma eq_zero_iff {I : fractional_ideal S P} : I = 0 ↔ (∀ x ∈ I, x = (0 : P)) :=\n⟨ (λ h x hx, by simpa [h, mem_zero_iff] using hx),\n  (λ h, le_bot_iff.mp (λ x hx, (mem_zero_iff S).mpr (h x hx))) ⟩\n\nlemma _root_.is_fractional.sup {I J : submodule R P} :\n  is_fractional S I → is_fractional S J → is_fractional S (I ⊔ J)\n| ⟨aI, haI, hI⟩ ⟨aJ, haJ, hJ⟩ := ⟨aI * aJ, S.mul_mem haI haJ, λ b hb, begin\n  rcases mem_sup.mp hb with ⟨bI, hbI, bJ, hbJ, rfl⟩,\n  rw smul_add,\n  apply is_integer_add,\n  { rw [mul_smul, smul_comm],\n    exact is_integer_smul (hI bI hbI), },\n  { rw mul_smul,\n    exact is_integer_smul (hJ bJ hbJ) }\nend⟩\n\nlemma _root_.is_fractional.inf_right {I : submodule R P} :\n  is_fractional S I → ∀ J, is_fractional S (I ⊓ J)\n| ⟨aI, haI, hI⟩ J := ⟨aI, haI, λ b hb, begin\n  rcases mem_inf.mp hb with ⟨hbI, hbJ⟩,\n  exact hI b hbI\nend⟩\n\ninstance : has_inf (fractional_ideal S P) := ⟨λ I J, ⟨I ⊓ J, I.is_fractional.inf_right J⟩⟩\n\n@[simp, norm_cast]\nlemma coe_inf (I J : fractional_ideal S P) : ↑(I ⊓ J) = (I ⊓ J : submodule R P) := rfl\n\ninstance : has_sup (fractional_ideal S P) := ⟨λ I J, ⟨I ⊔ J, I.is_fractional.sup J.is_fractional⟩⟩\n\n@[norm_cast]\nlemma coe_sup (I J : fractional_ideal S P) : ↑(I ⊔ J) = (I ⊔ J : submodule R P) := rfl\n\ninstance lattice : lattice (fractional_ideal S P) :=\nfunction.injective.lattice _ subtype.coe_injective coe_sup coe_inf\n\ninstance : semilattice_sup (fractional_ideal S P) :=\n{ ..fractional_ideal.lattice }\n\nend lattice\n\nsection semiring\n\ninstance : has_add (fractional_ideal S P) := ⟨(⊔)⟩\n\n@[simp]\nlemma sup_eq_add (I J : fractional_ideal S P) : I ⊔ J = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_add (I J : fractional_ideal S P) : (↑(I + J) : submodule R P) = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_ideal_sup (I J : ideal R) : ↑(I ⊔ J) = (I + J : fractional_ideal S P) :=\ncoe_to_submodule_injective $ coe_submodule_sup _ _ _\n\nlemma _root_.is_fractional.nsmul {I : submodule R P} :\n  Π n : ℕ, is_fractional S I → is_fractional S (n • I : submodule R P)\n| 0 _ := begin\n    rw [zero_smul],\n    convert ((0 : ideal R) : fractional_ideal S P).is_fractional,\n    simp,\n  end\n| (n + 1) h := begin\n  rw succ_nsmul,\n  exact h.sup (_root_.is_fractional.nsmul n h)\nend\n\ninstance : has_smul ℕ (fractional_ideal S P) :=\n{ smul := λ n I, ⟨n • I, I.is_fractional.nsmul n⟩}\n\n@[norm_cast]\nlemma coe_nsmul (n : ℕ) (I : fractional_ideal S P) : (↑(n • I) : submodule R P) = n • I := rfl\n\nlemma _root_.is_fractional.mul {I J : submodule R P} :\n  is_fractional S I → is_fractional S J → is_fractional S (I * J : submodule R P)\n| ⟨aI, haI, hI⟩ ⟨aJ, haJ, hJ⟩ := ⟨aI * aJ, S.mul_mem haI haJ, λ b hb, begin\n  apply submodule.mul_induction_on hb,\n  { intros m hm n hn,\n    obtain ⟨n', hn'⟩ := hJ n hn,\n    rw [mul_smul, mul_comm m, ← smul_mul_assoc, ← hn', ← algebra.smul_def],\n    apply hI,\n    exact submodule.smul_mem _ _ hm },\n  { intros x y hx hy,\n    rw smul_add,\n    apply is_integer_add hx hy },\nend⟩\n\nlemma _root_.is_fractional.pow {I : submodule R P} (h : is_fractional S I) :\n  ∀ n : ℕ, is_fractional S (I ^ n : submodule R P)\n| 0 := is_fractional_of_le_one _ (pow_zero _).le\n| (n + 1) := (pow_succ I n).symm ▸ h.mul (_root_.is_fractional.pow n)\n\n/-- `fractional_ideal.mul` is the product of two fractional ideals,\nused to define the `has_mul` instance.\n\nThis is only an auxiliary definition: the preferred way of writing `I.mul J` is `I * J`.\n\nElaborated terms involving `fractional_ideal` tend to grow quite large,\nso by making definitions irreducible, we hope to avoid deep unfolds.\n-/\n@[irreducible]\ndef mul (I J : fractional_ideal S P) : fractional_ideal S P :=\n⟨I * J, I.is_fractional.mul J.is_fractional⟩\n\n-- local attribute [semireducible] mul\n\ninstance : has_mul (fractional_ideal S P) := ⟨λ I J, mul I J⟩\n\n@[simp] lemma mul_eq_mul (I J : fractional_ideal S P) : mul I J = I * J := rfl\n\nlemma mul_def (I J : fractional_ideal S P) : I * J = ⟨I * J, I.is_fractional.mul J.is_fractional⟩ :=\nby simp only [← mul_eq_mul, mul]\n\n@[simp, norm_cast]\nlemma coe_mul (I J : fractional_ideal S P) : (↑(I * J) : submodule R P) = I * J :=\nby { simp only [mul_def], refl }\n\n@[simp, norm_cast]\nlemma coe_ideal_mul (I J : ideal R) : (↑(I * J) : fractional_ideal S P) = I * J :=\nbegin\n  simp only [mul_def],\n  exact coe_to_submodule_injective (coe_submodule_mul _ _ _)\nend\n\nlemma mul_left_mono (I : fractional_ideal S P) : monotone ((*) I) :=\nbegin\n  intros J J' h,\n  simp only [mul_def],\n  exact mul_le.mpr (λ x hx y hy, mul_mem_mul hx (h hy))\nend\n\nlemma mul_right_mono (I : fractional_ideal S P) : monotone (λ J, J * I) :=\nbegin\n  intros J J' h,\n  simp only [mul_def],\n  exact mul_le.mpr (λ x hx y hy, mul_mem_mul (h hx) hy)\nend\n\nlemma mul_mem_mul {I J : fractional_ideal S P} {i j : P} (hi : i ∈ I) (hj : j ∈ J) :\n  i * j ∈ I * J :=\nby { simp only [mul_def], exact submodule.mul_mem_mul hi hj }\n\nlemma mul_le {I J K : fractional_ideal S P} :\n  I * J ≤ K ↔ (∀ (i ∈ I) (j ∈ J), i * j ∈ K) :=\nby { simp only [mul_def], exact submodule.mul_le }\n\ninstance : has_pow (fractional_ideal S P) ℕ := ⟨λ I n, ⟨I^n, I.is_fractional.pow n⟩⟩\n\n@[simp, norm_cast]\nlemma coe_pow (I : fractional_ideal S P) (n : ℕ) : ↑(I ^ n) = (I ^ n : submodule R P) := rfl\n\n@[elab_as_eliminator] protected theorem mul_induction_on\n  {I J : fractional_ideal S P}\n  {C : P → Prop} {r : P} (hr : r ∈ I * J)\n  (hm : ∀ (i ∈ I) (j ∈ J), C (i * j))\n  (ha : ∀ x y, C x → C y → C (x + y)) : C r :=\nbegin\n  simp only [mul_def] at hr,\n  exact submodule.mul_induction_on hr hm ha\nend\n\ninstance : has_nat_cast (fractional_ideal S P) := ⟨nat.unary_cast⟩\n\nlemma coe_nat_cast (n : ℕ) : ((n : fractional_ideal S P) : submodule R P) = n :=\nshow ↑n.unary_cast = ↑n, by induction n; simp [*, nat.unary_cast]\n\ninstance : comm_semiring (fractional_ideal S P) :=\nfunction.injective.comm_semiring coe subtype.coe_injective\n  coe_zero coe_one coe_add coe_mul (λ _ _, coe_nsmul _ _) coe_pow coe_nat_cast\n\nvariables (S P)\n/-- `fractional_ideal.submodule.has_coe` as a bundled `ring_hom`. -/\n@[simps] def coe_submodule_hom : fractional_ideal S P →+* submodule R P :=\n⟨coe, coe_one, coe_mul, coe_zero, coe_add⟩\nvariables {S P}\n\nsection order\n\nlemma add_le_add_left {I J : fractional_ideal S P} (hIJ : I ≤ J) (J' : fractional_ideal S P) :\n  J' + I ≤ J' + J :=\nsup_le_sup_left hIJ J'\n\nlemma mul_le_mul_left {I J : fractional_ideal S P} (hIJ : I ≤ J) (J' : fractional_ideal S P) :\n  J' * I ≤ J' * J :=\nmul_le.mpr (λ k hk j hj, mul_mem_mul hk (hIJ hj))\n\nlemma le_self_mul_self {I : fractional_ideal S P} (hI: 1 ≤ I) : I ≤ I * I :=\nbegin\n  convert mul_left_mono I hI,\n  exact (mul_one I).symm\nend\n\nlemma mul_self_le_self {I : fractional_ideal S P} (hI: I ≤ 1) : I * I ≤ I :=\nbegin\n  convert mul_left_mono I hI,\n  exact (mul_one I).symm\nend\n\nlemma coe_ideal_le_one {I : ideal R} : (I : fractional_ideal S P) ≤ 1 :=\nλ x hx, let ⟨y, _, hy⟩ := (mem_coe_ideal S).mp hx in (mem_one_iff S).mpr ⟨y, hy⟩\n\nlemma le_one_iff_exists_coe_ideal {J : fractional_ideal S P} :\n  J ≤ (1 : fractional_ideal S P) ↔ ∃ (I : ideal R), ↑I = J :=\nbegin\n  split,\n  { intro hJ,\n    refine ⟨⟨{x : R | algebra_map R P x ∈ J}, _, _, _⟩, _⟩,\n    { intros a b ha hb,\n      rw [mem_set_of_eq, ring_hom.map_add],\n      exact J.val.add_mem ha hb },\n    { rw [mem_set_of_eq, ring_hom.map_zero],\n      exact J.val.zero_mem },\n    { intros c x hx,\n      rw [smul_eq_mul, mem_set_of_eq, ring_hom.map_mul, ← algebra.smul_def],\n      exact J.val.smul_mem c hx },\n    { ext x,\n      split,\n      { rintros ⟨y, hy, eq_y⟩,\n        rwa ← eq_y },\n      { intro hx,\n        obtain ⟨y, eq_x⟩ := (mem_one_iff S).mp (hJ hx),\n        rw ← eq_x at *,\n        exact ⟨y, hx, rfl⟩ } } },\n  { rintro ⟨I, hI⟩,\n    rw ← hI,\n    apply coe_ideal_le_one },\nend\n\n@[simp] lemma one_le {I : fractional_ideal S P} :\n  1 ≤ I ↔ (1 : P) ∈ I :=\nby rw [← coe_le_coe, coe_one, submodule.one_le, mem_coe]\n\nvariables (S P)\n\n/-- `coe_ideal_hom (S : submonoid R) P` is `coe : ideal R → fractional_ideal S P` as a ring hom -/\n@[simps]\ndef coe_ideal_hom : ideal R →+* fractional_ideal S P :=\n{ to_fun := coe,\n  map_add' := coe_ideal_sup,\n  map_mul' := coe_ideal_mul,\n  map_one' := by rw [ideal.one_eq_top, coe_ideal_top],\n  map_zero' := coe_ideal_bot }\n\nlemma coe_ideal_pow (I : ideal R) (n : ℕ) : (↑(I^n) : fractional_ideal S P) = I^n :=\n(coe_ideal_hom S P).map_pow _ n\n\nopen_locale big_operators\nlemma coe_ideal_finprod [is_localization S P] {α : Sort*} {f : α → ideal R}\n  (hS : S ≤ non_zero_divisors R) :\n  ((∏ᶠ a : α, f a : ideal R) : fractional_ideal S P) = ∏ᶠ a : α, (f a : fractional_ideal S P) :=\nmonoid_hom.map_finprod_of_injective (coe_ideal_hom S P).to_monoid_hom (coe_ideal_injective' hS) f\n\nend order\n\nvariables {P' : Type*} [comm_ring P'] [algebra R P'] [loc' : is_localization S P']\nvariables {P'' : Type*} [comm_ring P''] [algebra R P''] [loc'' : is_localization S P'']\n\nlemma _root_.is_fractional.map (g : P →ₐ[R] P') {I : submodule R P} :\n  is_fractional S I → is_fractional S (submodule.map g.to_linear_map I)\n| ⟨a, a_nonzero, hI⟩ := ⟨a, a_nonzero, λ b hb, begin\n  obtain ⟨b', b'_mem, hb'⟩ := submodule.mem_map.mp hb,\n  obtain ⟨x, hx⟩ := hI b' b'_mem,\n  use x,\n  erw [←g.commutes, hx, g.map_smul, hb']\nend⟩\n\n/-- `I.map g` is the pushforward of the fractional ideal `I` along the algebra morphism `g` -/\ndef map (g : P →ₐ[R] P') :\n  fractional_ideal S P → fractional_ideal S P' :=\nλ I, ⟨submodule.map g.to_linear_map I, I.is_fractional.map g⟩\n\n@[simp, norm_cast] lemma coe_map (g : P →ₐ[R] P') (I : fractional_ideal S P) :\n  ↑(map g I) = submodule.map g.to_linear_map I := rfl\n\n@[simp] lemma mem_map {I : fractional_ideal S P} {g : P →ₐ[R] P'}\n  {y : P'} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y :=\nsubmodule.mem_map\n\nvariables (I J : fractional_ideal S P) (g : P →ₐ[R] P')\n\n@[simp] lemma map_id : I.map (alg_hom.id _ _) = I :=\ncoe_to_submodule_injective (submodule.map_id I)\n\n@[simp] lemma map_comp (g' : P' →ₐ[R] P'') :\n  I.map (g'.comp g) = (I.map g).map g' :=\ncoe_to_submodule_injective (submodule.map_comp g.to_linear_map g'.to_linear_map I)\n\n@[simp, norm_cast] lemma map_coe_ideal (I : ideal R) :\n  (I : fractional_ideal S P).map g = I :=\nbegin\n  ext x,\n  simp only [mem_coe_ideal],\n  split,\n  { rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩,\n    exact ⟨y, hy, (g.commutes y).symm⟩ },\n  { rintro ⟨y, hy, rfl⟩,\n    exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ },\nend\n\n@[simp] lemma map_one :\n  (1 : fractional_ideal S P).map g = 1 :=\nmap_coe_ideal g ⊤\n\n@[simp] lemma map_zero :\n  (0 : fractional_ideal S P).map g = 0 :=\nmap_coe_ideal g 0\n\n@[simp] lemma map_add : (I + J).map g = I.map g + J.map g :=\ncoe_to_submodule_injective (submodule.map_sup _ _ _)\n\n@[simp] lemma map_mul : (I * J).map g = I.map g * J.map g :=\nbegin\n  simp only [mul_def],\n  exact coe_to_submodule_injective (submodule.map_mul _ _ _)\nend\n\n@[simp] lemma map_map_symm (g : P ≃ₐ[R] P') :\n  (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I :=\nby rw [←map_comp, g.symm_comp, map_id]\n\n@[simp] lemma map_symm_map (I : fractional_ideal S P') (g : P ≃ₐ[R] P') :\n  (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I :=\nby rw [←map_comp, g.comp_symm, map_id]\n\nlemma map_mem_map {f : P →ₐ[R] P'} (h : function.injective f) {x : P} {I : fractional_ideal S P} :\n  f x ∈ map f I ↔ x ∈ I :=\nmem_map.trans ⟨λ ⟨x', hx', x'_eq⟩, h x'_eq ▸ hx', λ h, ⟨x, h, rfl⟩⟩\n\nlemma map_injective (f : P →ₐ[R] P') (h : function.injective f) :\n  function.injective (map f : fractional_ideal S P → fractional_ideal S P') :=\nλ I J hIJ, ext (λ x, (map_mem_map h).symm.trans (hIJ.symm ▸ map_mem_map h))\n\n/-- If `g` is an equivalence, `map g` is an isomorphism -/\ndef map_equiv (g : P ≃ₐ[R] P') :\n  fractional_ideal S P ≃+* fractional_ideal S P' :=\n{ to_fun := map g,\n  inv_fun := map g.symm,\n  map_add' := λ I J, map_add I J _,\n  map_mul' := λ I J, map_mul I J _,\n  left_inv := λ I, by { rw [←map_comp, alg_equiv.symm_comp, map_id] },\n  right_inv := λ I, by { rw [←map_comp, alg_equiv.comp_symm, map_id] } }\n\n@[simp] lemma coe_fun_map_equiv (g : P ≃ₐ[R] P') :\n  (map_equiv g : fractional_ideal S P → fractional_ideal S P') = map g :=\nrfl\n\n@[simp] lemma map_equiv_apply (g : P ≃ₐ[R] P') (I : fractional_ideal S P) :\n  map_equiv g I = map ↑g I := rfl\n\n@[simp] lemma map_equiv_symm (g : P ≃ₐ[R] P') :\n  ((map_equiv g).symm : fractional_ideal S P' ≃+* _) = map_equiv g.symm := rfl\n\n@[simp] lemma map_equiv_refl :\n  map_equiv alg_equiv.refl = ring_equiv.refl (fractional_ideal S P) :=\nring_equiv.ext (λ x, by simp)\n\nlemma is_fractional_span_iff {s : set P} :\n  is_fractional S (span R s) ↔ ∃ a ∈ S, ∀ (b : P), b ∈ s → is_integer R (a • b) :=\n⟨λ ⟨a, a_mem, h⟩, ⟨a, a_mem, λ b hb, h b (subset_span hb)⟩,\n λ ⟨a, a_mem, h⟩, ⟨a, a_mem, λ b hb, span_induction hb\n   h\n   (by { rw smul_zero, exact is_integer_zero })\n   (λ x y hx hy, by { rw smul_add, exact is_integer_add hx hy })\n   (λ s x hx, by { rw smul_comm, exact is_integer_smul hx })⟩⟩\n\ninclude loc\n\nlemma is_fractional_of_fg {I : submodule R P} (hI : I.fg) :\n  is_fractional S I :=\nbegin\n  rcases hI with ⟨I, rfl⟩,\n  rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩,\n  rw is_fractional_span_iff,\n  exact ⟨s, hs1, hs⟩,\nend\n\nomit loc\n\nlemma mem_span_mul_finite_of_mem_mul {I J : fractional_ideal S P} {x : P} (hx : x ∈ I * J) :\n  ∃ (T T' : finset P), (T : set P) ⊆ I ∧ (T' : set P) ⊆ J ∧ x ∈ span R (T * T' : set P) :=\nsubmodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx)\n\nvariables (S)\n\nlemma coe_ideal_fg (inj : function.injective (algebra_map R P)) (I : ideal R) :\n  fg ((I : fractional_ideal S P) : submodule R P) ↔ I.fg :=\ncoe_submodule_fg _ inj _\n\nvariables {S}\n\nlemma fg_unit (I : (fractional_ideal S P)ˣ) :\n  fg (I : submodule R P) :=\nsubmodule.fg_unit $ units.map (coe_submodule_hom S P).to_monoid_hom I\n\nlemma fg_of_is_unit (I : fractional_ideal S P) (h : is_unit I) :\n  fg (I : submodule R P) :=\nfg_unit h.unit\n\nlemma _root_.ideal.fg_of_is_unit (inj : function.injective (algebra_map R P))\n  (I : ideal R) (h : is_unit (I : fractional_ideal S P)) :\n  I.fg :=\nby { rw ← coe_ideal_fg S inj I, exact fg_of_is_unit I h }\n\nvariables (S P P')\n\ninclude loc loc'\n\n/-- `canonical_equiv f f'` is the canonical equivalence between the fractional\nideals in `P` and in `P'` -/\n@[irreducible]\nnoncomputable def canonical_equiv :\n  fractional_ideal S P ≃+* fractional_ideal S P' :=\nmap_equiv\n  { commutes' := λ r, ring_equiv_of_ring_equiv_eq _ _,\n    ..ring_equiv_of_ring_equiv P P' (ring_equiv.refl R)\n      (show S.map _ = S, by rw [ring_equiv.to_monoid_hom_refl, submonoid.map_id]) }\n\n@[simp] lemma mem_canonical_equiv_apply {I : fractional_ideal S P} {x : P'} :\n  x ∈ canonical_equiv S P P' I ↔\n    ∃ y ∈ I, is_localization.map P' (ring_hom.id R)\n      (λ y (hy : y ∈ S), show ring_hom.id R y ∈ S, from hy) (y : P) = x :=\nbegin\n  rw [canonical_equiv, map_equiv_apply, mem_map],\n  exact ⟨λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩, λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩⟩\nend\n\n@[simp] lemma canonical_equiv_symm :\n  (canonical_equiv S P P').symm = canonical_equiv S P' P :=\nring_equiv.ext $ λ I, set_like.ext_iff.mpr $ λ x,\nby { rw [mem_canonical_equiv_apply, canonical_equiv, map_equiv_symm, map_equiv,\n         ring_equiv.coe_mk, mem_map],\n    exact ⟨λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩, λ ⟨y, mem, eq⟩, ⟨y, mem, eq⟩⟩ }\n\nlemma canonical_equiv_flip (I) :\n  canonical_equiv S P P' (canonical_equiv S P' P I) = I :=\nby rw [←canonical_equiv_symm, ring_equiv.symm_apply_apply]\n\n@[simp]\nlemma canonical_equiv_canonical_equiv (P'' : Type*) [comm_ring P''] [algebra R P'']\n  [is_localization S P''] (I : fractional_ideal S P) :\n  canonical_equiv S P' P'' (canonical_equiv S P P' I) = canonical_equiv S P P'' I :=\nbegin\n  ext,\n  simp only [is_localization.map_map, ring_hom_inv_pair.comp_eq₂, mem_canonical_equiv_apply,\n      exists_prop, exists_exists_and_eq_and],\n  refl\nend\n\nlemma canonical_equiv_trans_canonical_equiv (P'' : Type*) [comm_ring P'']\n  [algebra R P''] [is_localization S P''] :\n  (canonical_equiv S P P').trans (canonical_equiv S P' P'') = canonical_equiv S P P'' :=\nring_equiv.ext (canonical_equiv_canonical_equiv S P P' P'')\n\n@[simp]\nlemma canonical_equiv_coe_ideal (I : ideal R) :\n  canonical_equiv S P P' I = I :=\nby { ext, simp [is_localization.map_eq] }\n\nomit loc'\n\n@[simp]\nlemma canonical_equiv_self : canonical_equiv S P P = ring_equiv.refl _ :=\nbegin\n  rw ← canonical_equiv_trans_canonical_equiv S P P,\n  convert (canonical_equiv S P P).symm_trans_self,\n  exact (canonical_equiv_symm S P P).symm\nend\n\nend semiring\n\nsection is_fraction_ring\n\n/-!\n### `is_fraction_ring` section\n\nThis section concerns fractional ideals in the field of fractions,\ni.e. the type `fractional_ideal R⁰ K` where `is_fraction_ring R K`.\n-/\n\nvariables {K K' : Type*} [field K] [field K']\nvariables [algebra R K] [is_fraction_ring R K] [algebra R K'] [is_fraction_ring R K']\nvariables {I J : fractional_ideal R⁰ K} (h : K →ₐ[R] K')\n\n/-- Nonzero fractional ideals contain a nonzero integer. -/\nlemma exists_ne_zero_mem_is_integer [nontrivial R] (hI : I ≠ 0) :\n  ∃ x ≠ (0 : R), algebra_map R K x ∈ I :=\nbegin\n  obtain ⟨y, y_mem, y_not_mem⟩ := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr hI),\n  have y_ne_zero : y ≠ 0 := by simpa using y_not_mem,\n  obtain ⟨z, ⟨x, hx⟩⟩ := exists_integer_multiple R⁰ y,\n  refine ⟨x, _, _⟩,\n  { rw [ne.def, ← @is_fraction_ring.to_map_eq_zero_iff R _ K, hx, algebra.smul_def],\n    exact mul_ne_zero (is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors z.2) y_ne_zero },\n  { rw hx,\n    exact smul_mem _ _ y_mem }\nend\n\nlemma map_ne_zero [nontrivial R] (hI : I ≠ 0) : I.map h ≠ 0 :=\nbegin\n  obtain ⟨x, x_ne_zero, hx⟩ := exists_ne_zero_mem_is_integer hI,\n  contrapose! x_ne_zero with map_eq_zero,\n  refine is_fraction_ring.to_map_eq_zero_iff.mp (eq_zero_iff.mp map_eq_zero _ (mem_map.mpr _)),\n  exact ⟨algebra_map R K x, hx, h.commutes x⟩,\nend\n\n@[simp] lemma map_eq_zero_iff [nontrivial R] : I.map h = 0 ↔ I = 0 :=\n⟨imp_of_not_imp_not _ _ (map_ne_zero _), λ hI, hI.symm ▸ map_zero h⟩\n\nlemma coe_ideal_injective : function.injective (coe : ideal R → fractional_ideal R⁰ K) :=\ncoe_ideal_injective' le_rfl\n\nlemma coe_ideal_inj {I J : ideal R} :\n  (I : fractional_ideal R⁰ K) = (J : fractional_ideal R⁰ K) ↔ I = J :=\ncoe_ideal_inj' le_rfl\n\n@[simp] lemma coe_ideal_eq_zero {I : ideal R} : (I : fractional_ideal R⁰ K) = 0 ↔ I = ⊥ :=\ncoe_ideal_eq_zero' le_rfl\n\nlemma coe_ideal_ne_zero {I : ideal R} : (I : fractional_ideal R⁰ K) ≠ 0 ↔ I ≠ ⊥ :=\ncoe_ideal_ne_zero' le_rfl\n\n@[simp] lemma coe_ideal_eq_one {I : ideal R} : (I : fractional_ideal R⁰ K) = 1 ↔ I = 1 :=\nby simpa only [ideal.one_eq_top] using coe_ideal_inj\n\nlemma coe_ideal_ne_one {I : ideal R} : (I : fractional_ideal R⁰ K) ≠ 1 ↔ I ≠ 1 :=\nnot_iff_not.mpr coe_ideal_eq_one\n\nend is_fraction_ring\n\nsection quotient\n\n/-!\n### `quotient` section\n\nThis section defines the ideal quotient of fractional ideals.\n\nIn this section we need that each non-zero `y : R` has an inverse in\nthe localization, i.e. that the localization is a field. We satisfy this\nassumption by taking `S = non_zero_divisors R`, `R`'s localization at which\nis a field because `R` is a domain.\n-/\n\nopen_locale classical\n\nvariables {R₁ : Type*} [comm_ring R₁] {K : Type*} [field K]\nvariables [algebra R₁ K] [frac : is_fraction_ring R₁ K]\n\ninstance : nontrivial (fractional_ideal R₁⁰ K) :=\n⟨⟨0, 1, λ h,\n  have this : (1 : K) ∈ (0 : fractional_ideal R₁⁰ K) :=\n    by { rw ← (algebra_map R₁ K).map_one, simpa only [h] using coe_mem_one R₁⁰ 1 },\n  one_ne_zero ((mem_zero_iff _).mp this)⟩⟩\n\nlemma ne_zero_of_mul_eq_one (I J : fractional_ideal R₁⁰ K) (h : I * J = 1) : I ≠ 0 :=\nλ hI, zero_ne_one' (fractional_ideal R₁⁰ K) (by { convert h, simp [hI], })\n\nvariables [is_domain R₁]\n\ninclude frac\n\nlemma _root_.is_fractional.div_of_nonzero {I J : submodule R₁ K} :\n  is_fractional R₁⁰ I → is_fractional R₁⁰ J → J ≠ 0 → is_fractional R₁⁰ (I / J)\n| ⟨aI, haI, hI⟩ ⟨aJ, haJ, hJ⟩ h := begin\n  obtain ⟨y, mem_J, not_mem_zero⟩ := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr h),\n  obtain ⟨y', hy'⟩ := hJ y mem_J,\n  use (aI * y'),\n  split,\n  { apply (non_zero_divisors R₁).mul_mem haI (mem_non_zero_divisors_iff_ne_zero.mpr _),\n    intro y'_eq_zero,\n    have : algebra_map R₁ K aJ * y = 0,\n    { rw [← algebra.smul_def, ←hy', y'_eq_zero, ring_hom.map_zero] },\n    have y_zero := (mul_eq_zero.mp this).resolve_left\n      (mt ((injective_iff_map_eq_zero (algebra_map R₁ K)).1 (is_fraction_ring.injective _ _) _)\n          (mem_non_zero_divisors_iff_ne_zero.mp haJ)),\n    apply not_mem_zero,\n    simpa only using (mem_zero_iff R₁⁰).mpr y_zero, },\n  intros b hb,\n  convert hI _ (hb _ (submodule.smul_mem _ aJ mem_J)) using 1,\n  rw [← hy', mul_comm b, ← algebra.smul_def, mul_smul]\nend\n\nlemma fractional_div_of_nonzero {I J : fractional_ideal R₁⁰ K} (h : J ≠ 0) :\n  is_fractional R₁⁰ (I / J : submodule R₁ K) :=\nI.is_fractional.div_of_nonzero J.is_fractional $ λ H, h $\n  coe_to_submodule_injective $ H.trans coe_zero.symm\n\nnoncomputable instance : has_div (fractional_ideal R₁⁰ K) :=\n⟨ λ I J, if h : J = 0 then 0 else ⟨I / J, fractional_div_of_nonzero h⟩ ⟩\n\nvariables {I J : fractional_ideal R₁⁰ K} [ J ≠ 0 ]\n\n@[simp] lemma div_zero {I : fractional_ideal R₁⁰ K} :\n  I / 0 = 0 :=\ndif_pos rfl\n\nlemma div_nonzero {I J : fractional_ideal R₁⁰ K} (h : J ≠ 0) :\n  (I / J) = ⟨I / J, fractional_div_of_nonzero h⟩ :=\ndif_neg h\n\n@[simp] lemma coe_div {I J : fractional_ideal R₁⁰ K} (hJ : J ≠ 0) :\n  (↑(I / J) : submodule R₁ K) = ↑I / (↑J : submodule R₁ K) :=\ncongr_arg _ (dif_neg hJ)\n\n\n\nlemma mul_one_div_le_one {I : fractional_ideal R₁⁰ K} : I * (1 / I) ≤ 1 :=\nbegin\n  by_cases hI : I = 0,\n  { rw [hI, div_zero, mul_zero],\n    exact zero_le 1 },\n  { rw [← coe_le_coe, coe_mul, coe_div hI, coe_one],\n    apply submodule.mul_one_div_le_one },\nend\n\nlemma le_self_mul_one_div {I : fractional_ideal R₁⁰ K} (hI : I ≤ (1 : fractional_ideal R₁⁰ K)) :\n  I ≤ I * (1 / I) :=\nbegin\n  by_cases hI_nz : I = 0,\n  { rw [hI_nz, div_zero, mul_zero], exact zero_le 0 },\n  { rw [← coe_le_coe, coe_mul, coe_div hI_nz, coe_one],\n    rw [← coe_le_coe, coe_one] at hI,\n    exact submodule.le_self_mul_one_div hI },\nend\n\nlemma le_div_iff_of_nonzero {I J J' : fractional_ideal R₁⁰ K} (hJ' : J' ≠ 0) :\n  I ≤ J / J' ↔ ∀ (x ∈ I) (y ∈ J'), x * y ∈ J :=\n⟨ λ h x hx, (mem_div_iff_of_nonzero hJ').mp (h hx),\n  λ h x hx, (mem_div_iff_of_nonzero hJ').mpr (h x hx) ⟩\n\nlemma le_div_iff_mul_le {I J J' : fractional_ideal R₁⁰ K} (hJ' : J' ≠ 0) :\n  I ≤ J / J' ↔ I * J' ≤ J :=\nbegin\n  rw div_nonzero hJ',\n  convert submodule.le_div_iff_mul_le using 1,\n  rw [← coe_mul, coe_le_coe]\nend\n\n@[simp] lemma div_one {I : fractional_ideal R₁⁰ K} : I / 1 = I :=\nbegin\n  rw [div_nonzero (one_ne_zero' (fractional_ideal R₁⁰ K))],\n  ext,\n  split; intro h,\n  { simpa using mem_div_iff_forall_mul_mem.mp h 1\n      ((algebra_map R₁ K).map_one ▸ coe_mem_one R₁⁰ 1) },\n  { apply mem_div_iff_forall_mul_mem.mpr,\n    rintros y ⟨y', _, rfl⟩,\n    rw mul_comm,\n    convert submodule.smul_mem _ y' h,\n    exact (algebra.smul_def _ _).symm }\nend\n\ntheorem eq_one_div_of_mul_eq_one_right (I J : fractional_ideal R₁⁰ K) (h : I * J = 1) :\n  J = 1 / I :=\nbegin\n  have hI : I ≠ 0 := ne_zero_of_mul_eq_one I J h,\n  suffices h' : I * (1 / I) = 1,\n  { exact (congr_arg units.inv $\n      @units.ext _ _ (units.mk_of_mul_eq_one _ _ h) (units.mk_of_mul_eq_one _ _ h') rfl) },\n  apply le_antisymm,\n  { apply mul_le.mpr _,\n    intros x hx y hy,\n    rw mul_comm,\n    exact (mem_div_iff_of_nonzero hI).mp hy x hx },\n  rw ← h,\n  apply mul_left_mono I,\n  apply (le_div_iff_of_nonzero hI).mpr _,\n  intros y hy x hx,\n  rw mul_comm,\n  exact mul_mem_mul hx hy,\nend\n\ntheorem mul_div_self_cancel_iff {I : fractional_ideal R₁⁰ K} :\n  I * (1 / I) = 1 ↔ ∃ J, I * J = 1 :=\n⟨λ h, ⟨(1 / I), h⟩, λ ⟨J, hJ⟩, by rwa [← eq_one_div_of_mul_eq_one_right I J hJ]⟩\n\nvariables {K' : Type*} [field K'] [algebra R₁ K'] [is_fraction_ring R₁ K']\n\n@[simp] lemma map_div (I J : fractional_ideal R₁⁰ K) (h : K ≃ₐ[R₁] K') :\n  (I / J).map (h : K →ₐ[R₁] K') = I.map h / J.map h :=\nbegin\n  by_cases H : J = 0,\n  { rw [H, div_zero, map_zero, div_zero] },\n  { apply coe_to_submodule_injective,\n    simp [div_nonzero H, div_nonzero (map_ne_zero _ H), submodule.map_div] }\nend\n\n@[simp] lemma map_one_div (I : fractional_ideal R₁⁰ K) (h : K ≃ₐ[R₁] K') :\n  (1 / I).map (h : K →ₐ[R₁] K') = 1 / I.map h :=\nby rw [map_div, map_one]\n\nend quotient\n\nsection field\n\nvariables {R₁ K L : Type*} [comm_ring R₁] [field K] [field L]\nvariables [algebra R₁ K] [is_fraction_ring R₁ K] [algebra K L] [is_fraction_ring K L]\n\nlemma eq_zero_or_one (I : fractional_ideal K⁰ L) : I = 0 ∨ I = 1 :=\nbegin\n  rw or_iff_not_imp_left,\n  intro hI,\n  simp_rw [@set_like.ext_iff _ _ _ I 1, mem_one_iff],\n  intro x,\n  split,\n  { intro x_mem,\n    obtain ⟨n, d, rfl⟩ := is_localization.mk'_surjective K⁰ x,\n    refine ⟨n / d, _⟩,\n    rw [map_div₀, is_fraction_ring.mk'_eq_div] },\n  { rintro ⟨x, rfl⟩,\n    obtain ⟨y, y_ne, y_mem⟩ := exists_ne_zero_mem_is_integer hI,\n    rw [← div_mul_cancel x y_ne, ring_hom.map_mul, ← algebra.smul_def],\n    exact submodule.smul_mem I _ y_mem }\nend\n\nlemma eq_zero_or_one_of_is_field (hF : is_field R₁) (I : fractional_ideal R₁⁰ K) : I = 0 ∨ I = 1 :=\nby letI : field R₁ := hF.to_field; exact eq_zero_or_one I\n\nend field\n\nsection principal_ideal_ring\n\nvariables {R₁ : Type*} [comm_ring R₁] {K : Type*} [field K]\nvariables [algebra R₁ K] [is_fraction_ring R₁ K]\n\nopen_locale classical\n\nvariables (R₁)\n\n/-- `fractional_ideal.span_finset R₁ s f` is the fractional ideal of `R₁` generated by `f '' s`. -/\n@[simps] def span_finset {ι : Type*} (s : finset ι) (f : ι → K) : fractional_ideal R₁⁰ K :=\n⟨submodule.span R₁ (f '' s), begin\n  obtain ⟨a', ha'⟩ := is_localization.exist_integer_multiples R₁⁰ s f,\n  refine ⟨a', a'.2, λ x hx, submodule.span_induction hx _ _ _ _⟩,\n  { rintro _ ⟨i, hi, rfl⟩, exact ha' i hi },\n  { rw smul_zero, exact is_localization.is_integer_zero },\n  { intros x y hx hy, rw smul_add, exact is_localization.is_integer_add hx hy },\n  { intros c x hx, rw smul_comm, exact is_localization.is_integer_smul hx }\nend⟩\n\nvariables {R₁}\n\n@[simp] lemma span_finset_eq_zero {ι : Type*} {s : finset ι} {f : ι → K} :\n  span_finset R₁ s f = 0 ↔ ∀ j ∈ s, f j = 0 :=\nby simp only [← coe_to_submodule_inj, span_finset_coe, coe_zero, submodule.span_eq_bot,\n  set.mem_image, finset.mem_coe, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]\n\nlemma span_finset_ne_zero {ι : Type*} {s : finset ι} {f : ι → K} :\n  span_finset R₁ s f ≠ 0 ↔ ∃ j ∈ s, f j ≠ 0 :=\nby simp\n\nopen submodule.is_principal\n\ninclude loc\n\nlemma is_fractional_span_singleton (x : P) : is_fractional S (span R {x} : submodule R P) :=\nlet ⟨a, ha⟩ := exists_integer_multiple S x in\nis_fractional_span_iff.mpr ⟨a, a.2, λ x' hx', (set.mem_singleton_iff.mp hx').symm ▸ ha⟩\n\nvariables (S)\n\n/-- `span_singleton x` is the fractional ideal generated by `x` if `0 ∉ S` -/\n@[irreducible]\ndef span_singleton (x : P) : fractional_ideal S P :=\n⟨span R {x}, is_fractional_span_singleton x⟩\n\n-- local attribute [semireducible] span_singleton\n\n@[simp] lemma coe_span_singleton (x : P) :\n  (span_singleton S x : submodule R P) = span R {x} :=\nby { rw span_singleton, refl }\n\n@[simp] lemma mem_span_singleton {x y : P} :\n  x ∈ span_singleton S y ↔ ∃ (z : R), z • y = x :=\nby { rw span_singleton, exact submodule.mem_span_singleton }\n\nlemma mem_span_singleton_self (x : P) :\n  x ∈ span_singleton S x :=\n(mem_span_singleton S).mpr ⟨1, one_smul _ _⟩\n\nvariables {S}\n\n@[simp] lemma span_singleton_le_iff_mem {x : P} {I : fractional_ideal S P} :\n  span_singleton S x ≤ I ↔ x ∈ I :=\nby rw [← coe_le_coe, coe_span_singleton, submodule.span_singleton_le_iff_mem x ↑I, mem_coe]\n\nlemma span_singleton_eq_span_singleton [no_zero_smul_divisors R P] {x y : P} :\n  span_singleton S x = span_singleton S y ↔ ∃ z : Rˣ, z • x = y :=\nby { rw [← submodule.span_singleton_eq_span_singleton, span_singleton, span_singleton],\n  exact subtype.mk_eq_mk }\n\nlemma eq_span_singleton_of_principal (I : fractional_ideal S P)\n  [is_principal (I : submodule R P)] :\n  I = span_singleton S (generator (I : submodule R P)) :=\nby { rw span_singleton, exact coe_to_submodule_injective (span_singleton_generator ↑I).symm }\n\nlemma is_principal_iff (I : fractional_ideal S P) :\n  is_principal (I : submodule R P) ↔ ∃ x, I = span_singleton S x :=\n⟨λ h, ⟨@generator _ _ _ _ _ ↑I h, @eq_span_singleton_of_principal _ _ _ _ _ _ _ I h⟩,\n λ ⟨x, hx⟩, { principal := ⟨x, trans (congr_arg _ hx) (coe_span_singleton _ x)⟩ } ⟩\n\n@[simp] lemma span_singleton_zero : span_singleton S (0 : P) = 0 :=\nby { ext, simp [submodule.mem_span_singleton, eq_comm] }\n\nlemma span_singleton_eq_zero_iff {y : P} : span_singleton S y = 0 ↔ y = 0 :=\n⟨λ h, span_eq_bot.mp (by simpa using congr_arg subtype.val h : span R {y} = ⊥) y (mem_singleton y),\n λ h, by simp [h] ⟩\n\nlemma span_singleton_ne_zero_iff {y : P} : span_singleton S y ≠ 0 ↔ y ≠ 0 :=\nnot_congr span_singleton_eq_zero_iff\n\n@[simp] lemma span_singleton_one : span_singleton S (1 : P) = 1 :=\nbegin\n  ext,\n  refine (mem_span_singleton S).trans ((exists_congr _).trans (mem_one_iff S).symm),\n  intro x',\n  rw [algebra.smul_def, mul_one]\nend\n\n@[simp]\nlemma span_singleton_mul_span_singleton (x y : P) :\n  span_singleton S x * span_singleton S y = span_singleton S (x * y) :=\nbegin\n  apply coe_to_submodule_injective,\n  simp only [coe_mul, coe_span_singleton, span_mul_span, singleton_mul_singleton],\nend\n\n@[simp]\nlemma span_singleton_pow (x : P) (n : ℕ) : span_singleton S x ^ n = span_singleton S (x ^ n) :=\nbegin\n  induction n with n hn,\n  { rw [pow_zero, pow_zero, span_singleton_one] },\n  { rw [pow_succ, hn, span_singleton_mul_span_singleton, pow_succ] }\nend\n\n@[simp]\nlemma coe_ideal_span_singleton (x : R) :\n  (↑(ideal.span {x} : ideal R) : fractional_ideal S P) = span_singleton S (algebra_map R P x) :=\nbegin\n  ext y,\n  refine (mem_coe_ideal S).trans (iff.trans _ (mem_span_singleton S).symm),\n  split,\n  { rintros ⟨y', hy', rfl⟩,\n    obtain ⟨x', rfl⟩ := submodule.mem_span_singleton.mp hy',\n    use x',\n    rw [smul_eq_mul, ring_hom.map_mul, algebra.smul_def] },\n  { rintros ⟨y', rfl⟩,\n    refine ⟨y' * x, submodule.mem_span_singleton.mpr ⟨y', rfl⟩, _⟩,\n    rw [ring_hom.map_mul, algebra.smul_def] }\nend\n\n@[simp]\nlemma canonical_equiv_span_singleton {P'} [comm_ring P'] [algebra R P'] [is_localization S P']\n  (x : P) :\n  canonical_equiv S P P' (span_singleton S x) =\n    span_singleton S (is_localization.map P' (ring_hom.id R)\n      (λ y (hy : y ∈ S), show ring_hom.id R y ∈ S, from hy) x) :=\nbegin\n  apply set_like.ext_iff.mpr,\n  intro y,\n  split; intro h,\n  { rw mem_span_singleton,\n    obtain ⟨x', hx', rfl⟩ := (mem_canonical_equiv_apply _ _ _).mp h,\n    obtain ⟨z, rfl⟩ := (mem_span_singleton _).mp hx',\n    use z,\n    rw is_localization.map_smul,\n    refl },\n  { rw mem_canonical_equiv_apply,\n    obtain ⟨z, rfl⟩ := (mem_span_singleton _).mp h,\n    use z • x,\n    use (mem_span_singleton _).mpr ⟨z, rfl⟩,\n    simp [is_localization.map_smul] }\nend\n\nlemma mem_singleton_mul {x y : P} {I : fractional_ideal S P} :\n  y ∈ span_singleton S x * I ↔ ∃ y' ∈ I, y = x * y' :=\nbegin\n  split,\n  { intro h,\n    apply fractional_ideal.mul_induction_on h,\n    { intros x' hx' y' hy',\n      obtain ⟨a, ha⟩ := (mem_span_singleton S).mp hx',\n      use [a • y', submodule.smul_mem I a hy'],\n      rw [←ha, algebra.mul_smul_comm, algebra.smul_mul_assoc] },\n    { rintros _ _ ⟨y, hy, rfl⟩ ⟨y', hy', rfl⟩,\n      exact ⟨y + y', submodule.add_mem I hy hy', (mul_add _ _ _).symm⟩ } },\n  { rintros ⟨y', hy', rfl⟩,\n    exact mul_mem_mul ((mem_span_singleton S).mpr ⟨1, one_smul _ _⟩) hy' }\nend\n\nomit loc\n\nvariables (K)\n\nlemma mk'_mul_coe_ideal_eq_coe_ideal {I J : ideal R₁} {x y : R₁} (hy : y ∈ R₁⁰) :\n  span_singleton R₁⁰ (is_localization.mk' K x ⟨y, hy⟩) * I = (J : fractional_ideal R₁⁰ K) ↔\n  ideal.span {x} * I = ideal.span {y} * J :=\nbegin\n  have : span_singleton R₁⁰ (is_localization.mk' _ (1 : R₁) ⟨y, hy⟩) *\n           span_singleton R₁⁰ (algebra_map R₁ K y) = 1,\n  { rw [span_singleton_mul_span_singleton, mul_comm, ← is_localization.mk'_eq_mul_mk'_one,\n        is_localization.mk'_self, span_singleton_one] },\n  let y' : (fractional_ideal R₁⁰ K)ˣ := units.mk_of_mul_eq_one _ _ this,\n  have coe_y' : ↑y' = span_singleton R₁⁰ (is_localization.mk' K (1 : R₁) ⟨y, hy⟩) := rfl,\n  refine iff.trans _ (y'.mul_right_inj.trans coe_ideal_inj),\n  rw [coe_y', coe_ideal_mul, coe_ideal_span_singleton, coe_ideal_mul, coe_ideal_span_singleton,\n    ←mul_assoc, span_singleton_mul_span_singleton, ←mul_assoc, span_singleton_mul_span_singleton,\n    mul_comm (mk' _ _ _), ← is_localization.mk'_eq_mul_mk'_one,\n    mul_comm (mk' _ _ _), ← is_localization.mk'_eq_mul_mk'_one,\n    is_localization.mk'_self, span_singleton_one, one_mul],\nend\n\nvariables {K}\n\nlemma span_singleton_mul_coe_ideal_eq_coe_ideal {I J : ideal R₁} {z : K} :\n  span_singleton R₁⁰ z * (I : fractional_ideal R₁⁰ K) = J ↔\n  ideal.span {((is_localization.sec R₁⁰ z).1 : R₁)} * I =\n    ideal.span {(is_localization.sec R₁⁰ z).2} * J :=\n-- `erw` to deal with the distinction between `y` and `⟨y.1, y.2⟩`\nby erw [← mk'_mul_coe_ideal_eq_coe_ideal K (is_localization.sec R₁⁰ z).2.prop,\n        is_localization.mk'_sec K z]\n\nvariables [is_domain R₁]\n\nlemma one_div_span_singleton (x : K) :\n  1 / span_singleton R₁⁰ x = span_singleton R₁⁰ (x⁻¹) :=\nif h : x = 0 then by simp [h] else (eq_one_div_of_mul_eq_one_right _ _ (by simp [h])).symm\n\n@[simp] lemma div_span_singleton (J : fractional_ideal R₁⁰ K) (d : K) :\n  J / span_singleton R₁⁰ d = span_singleton R₁⁰ (d⁻¹) * J :=\nbegin\n  rw ← one_div_span_singleton,\n  by_cases hd : d = 0,\n  { simp only [hd, span_singleton_zero, div_zero, zero_mul] },\n  have h_spand : span_singleton R₁⁰ d ≠ 0 := mt span_singleton_eq_zero_iff.mp hd,\n  apply le_antisymm,\n  { intros x hx,\n    rw [← mem_coe, coe_div h_spand, submodule.mem_div_iff_forall_mul_mem] at hx,\n    specialize hx d (mem_span_singleton_self R₁⁰ d),\n    have h_xd : x = d⁻¹ * (x * d), { field_simp },\n    rw [← mem_coe, coe_mul, one_div_span_singleton, h_xd],\n    exact submodule.mul_mem_mul (mem_span_singleton_self R₁⁰ _) hx },\n  { rw [le_div_iff_mul_le h_spand, mul_assoc, mul_left_comm, one_div_span_singleton,\n    span_singleton_mul_span_singleton, inv_mul_cancel hd, span_singleton_one, mul_one],\n    exact le_refl J },\nend\n\nlemma exists_eq_span_singleton_mul (I : fractional_ideal R₁⁰ K) :\n  ∃ (a : R₁) (aI : ideal R₁), a ≠ 0 ∧ I = span_singleton R₁⁰ (algebra_map R₁ K a)⁻¹ * aI :=\nbegin\n  obtain ⟨a_inv, nonzero, ha⟩ := I.is_fractional,\n  have nonzero := mem_non_zero_divisors_iff_ne_zero.mp nonzero,\n  have map_a_nonzero : algebra_map R₁ K a_inv ≠ 0 :=\n    mt is_fraction_ring.to_map_eq_zero_iff.mp nonzero,\n  refine ⟨a_inv,\n          submodule.comap (algebra.linear_map R₁ K)\n            ↑(span_singleton R₁⁰ (algebra_map R₁ K a_inv) * I),\n          nonzero,\n          ext (λ x, iff.trans ⟨_, _⟩ mem_singleton_mul.symm)⟩,\n  { intro hx,\n    obtain ⟨x', hx'⟩ := ha x hx,\n    rw algebra.smul_def at hx',\n    refine ⟨algebra_map R₁ K x', (mem_coe_ideal _).mpr ⟨x', mem_singleton_mul.mpr _, rfl⟩, _⟩,\n    { exact ⟨x, hx, hx'⟩ },\n    { rw [hx', ← mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] } },\n  { rintros ⟨y, hy, rfl⟩,\n    obtain ⟨x', hx', rfl⟩ := (mem_coe_ideal _).mp hy,\n    obtain ⟨y', hy', hx'⟩ := mem_singleton_mul.mp hx',\n    rw algebra.linear_map_apply at hx',\n    rwa [hx', ←mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] }\nend\n\ninstance is_principal {R} [comm_ring R] [is_domain R] [is_principal_ideal_ring R]\n  [algebra R K] [is_fraction_ring R K]\n  (I : fractional_ideal R⁰ K) : (I : submodule R K).is_principal :=\nbegin\n  obtain ⟨a, aI, -, ha⟩ := exists_eq_span_singleton_mul I,\n  use (algebra_map R K a)⁻¹ * algebra_map R K (generator aI),\n  suffices : I = span_singleton R⁰ ((algebra_map R K a)⁻¹ * algebra_map R K (generator aI)),\n  { rw span_singleton at this, exact congr_arg subtype.val this },\n  conv_lhs { rw [ha, ←span_singleton_generator aI] },\n  rw [ideal.submodule_span_eq, coe_ideal_span_singleton (generator aI),\n      span_singleton_mul_span_singleton]\nend\n\ninclude loc\n\nlemma le_span_singleton_mul_iff {x : P} {I J : fractional_ideal S P} :\n  I ≤ span_singleton S x * J ↔ ∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI :=\nshow (∀ {zI} (hzI : zI ∈ I), zI ∈ span_singleton _ x * J) ↔ ∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI,\nby simp only [mem_singleton_mul, eq_comm]\n\nlemma span_singleton_mul_le_iff {x : P} {I J : fractional_ideal S P} :\n  span_singleton _ x * I ≤ J ↔ ∀ z ∈ I, x * z ∈ J :=\nbegin\n  simp only [mul_le, mem_singleton_mul, mem_span_singleton],\n  split,\n  { intros h zI hzI,\n    exact h x ⟨1, one_smul _ _⟩ zI hzI },\n  { rintros h _ ⟨z, rfl⟩ zI hzI,\n    rw [algebra.smul_mul_assoc],\n    exact submodule.smul_mem J.1 _ (h zI hzI) },\nend\n\nlemma eq_span_singleton_mul {x : P} {I J : fractional_ideal S P} :\n  I = span_singleton _ x * J ↔ (∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI) ∧ ∀ z ∈ J, x * z ∈ I :=\nby simp only [le_antisymm_iff, le_span_singleton_mul_iff, span_singleton_mul_le_iff]\n\nend principal_ideal_ring\n\nvariables {R₁ : Type*} [comm_ring R₁]\nvariables {K : Type*} [field K] [algebra R₁ K] [frac : is_fraction_ring R₁ K]\n\nlocal attribute [instance] classical.prop_decidable\n\nlemma is_noetherian_zero : is_noetherian R₁ (0 : fractional_ideal R₁⁰ K) :=\nis_noetherian_submodule.mpr (λ I (hI : I ≤ (0 : fractional_ideal R₁⁰ K)),\n  by { rw coe_zero at hI, rw le_bot_iff.mp hI, exact fg_bot })\n\nlemma is_noetherian_iff {I : fractional_ideal R₁⁰ K} :\n  is_noetherian R₁ I ↔ ∀ J ≤ I, (J : submodule R₁ K).fg :=\nis_noetherian_submodule.trans ⟨λ h J hJ, h _ hJ, λ h J hJ, h ⟨J, is_fractional_of_le hJ⟩ hJ⟩\n\nlemma is_noetherian_coe_ideal [_root_.is_noetherian_ring R₁] (I : ideal R₁) :\n  is_noetherian R₁ (I : fractional_ideal R₁⁰ K) :=\nbegin\n  rw is_noetherian_iff,\n  intros J hJ,\n  obtain ⟨J, rfl⟩ := le_one_iff_exists_coe_ideal.mp (le_trans hJ coe_ideal_le_one),\n  exact (is_noetherian.noetherian J).map _,\nend\n\ninclude frac\nvariables [is_domain R₁]\n\nlemma is_noetherian_span_singleton_inv_to_map_mul (x : R₁) {I : fractional_ideal R₁⁰ K}\n  (hI : is_noetherian R₁ I) :\n  is_noetherian R₁ (span_singleton R₁⁰ (algebra_map R₁ K x)⁻¹ * I : fractional_ideal R₁⁰ K) :=\nbegin\n  by_cases hx : x = 0,\n  { rw [hx, ring_hom.map_zero, _root_.inv_zero, span_singleton_zero, zero_mul],\n    exact is_noetherian_zero },\n  have h_gx : algebra_map R₁ K x ≠ 0,\n  from mt ((injective_iff_map_eq_zero (algebra_map R₁ K)).mp\n    (is_fraction_ring.injective _ _) x) hx,\n  have h_spanx : span_singleton R₁⁰ (algebra_map R₁ K x) ≠ 0,\n    from span_singleton_ne_zero_iff.mpr h_gx,\n\n  rw is_noetherian_iff at ⊢ hI,\n  intros J hJ,\n  rw [← div_span_singleton, le_div_iff_mul_le h_spanx] at hJ,\n  obtain ⟨s, hs⟩ := hI _ hJ,\n  use s * {(algebra_map R₁ K x)⁻¹},\n  rw [finset.coe_mul, finset.coe_singleton, ← span_mul_span, hs, ← coe_span_singleton R₁⁰,\n      ← coe_mul, mul_assoc, span_singleton_mul_span_singleton, mul_inv_cancel h_gx,\n      span_singleton_one, mul_one],\nend\n\n/-- Every fractional ideal of a noetherian integral domain is noetherian. -/\ntheorem is_noetherian [_root_.is_noetherian_ring R₁] (I : fractional_ideal R₁⁰ K) :\n  is_noetherian R₁ I :=\nbegin\n  obtain ⟨d, J, h_nzd, rfl⟩ := exists_eq_span_singleton_mul I,\n  apply is_noetherian_span_singleton_inv_to_map_mul,\n  apply is_noetherian_coe_ideal\nend\n\nsection adjoin\n\ninclude loc\nomit frac\n\nvariables {R P} (S) (x : P) (hx : is_integral R x)\n\n/-- `A[x]` is a fractional ideal for every integral `x`. -/\nlemma is_fractional_adjoin_integral :\n  is_fractional S (algebra.adjoin R ({x} : set P)).to_submodule :=\nis_fractional_of_fg (fg_adjoin_singleton_of_integral x hx)\n\n/-- `fractional_ideal.adjoin_integral (S : submonoid R) x hx` is `R[x]` as a fractional ideal,\nwhere `hx` is a proof that `x : P` is integral over `R`. -/\n@[simps]\ndef adjoin_integral : fractional_ideal S P :=\n⟨_, is_fractional_adjoin_integral S x hx⟩\n\nlemma mem_adjoin_integral_self :\n  x ∈ adjoin_integral S x hx :=\nalgebra.subset_adjoin (set.mem_singleton x)\n\nend adjoin\n\nend fractional_ideal\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/fractional_ideal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4698993862203947}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n\n! This file was ported from Lean 3 source module category_theory.with_terminal\n! leanprover-community/mathlib commit 14b69e9f3c16630440a2cbd46f1ddad0d561dee7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Shapes.Terminal\n\n/-!\n\n# `with_initial` and `with_terminal`\n\nGiven a category `C`, this file constructs two objects:\n1. `with_terminal C`, the category built from `C` by formally adjoining a terminal object.\n2. `with_initial C`, the category built from `C` by formally adjoining an initial object.\n\nThe terminal resp. initial object is `with_terminal.star` resp. `with_initial.star`, and\nthe proofs that these are terminal resp. initial are in `with_terminal.star_terminal`\nand `with_initial.star_initial`.\n\nThe inclusion from `C` intro `with_terminal C` resp. `with_initial C` is denoted\n`with_terminal.incl` resp. `with_initial.incl`.\n\nThe relevant constructions needed for the universal properties of these constructions are:\n1. `lift`, which lifts `F : C ⥤ D` to a functor from `with_terminal C` resp. `with_initial C` in\n  the case where an object `Z : D` is provided satisfying some additional conditions.\n2. `incl_lift` shows that the composition of `lift` with `incl` is isomorphic to the\n  functor which was lifted.\n3. `lift_unique` provides the uniqueness property of `lift`.\n\nIn addition to this, we provide `with_terminal.map` and `with_initinal.map` providing the\nfunctoriality of these constructions with respect to functors on the base categories.\n\n-/\n\n\nnamespace CategoryTheory\n\nuniverse v u\n\nvariable (C : Type u) [Category.{v} C]\n\n/-- Formally adjoin a terminal object to a category. -/\ninductive WithTerminal : Type u\n  | of : C → with_terminal\n  | star : with_terminal\n  deriving Inhabited\n#align category_theory.with_terminal CategoryTheory.WithTerminal\n\n/-- Formally adjoin an initial object to a category. -/\ninductive WithInitial : Type u\n  | of : C → with_initial\n  | star : with_initial\n  deriving Inhabited\n#align category_theory.with_initial CategoryTheory.WithInitial\n\nnamespace WithTerminal\n\nattribute [local tidy] tactic.case_bash\n\nvariable {C}\n\n/- warning: category_theory.with_terminal.hom -> CategoryTheory.WithTerminal.Hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], (CategoryTheory.WithTerminal.{u1, u2} C _inst_1) -> (CategoryTheory.WithTerminal.{u1, u2} C _inst_1) -> Type.{u1}\nbut is expected to have type\n  forall {C : Type.{u1}} [_inst_1 : CategoryTheory.Category.{u2, u1} C], (CategoryTheory.WithTerminal.{u2, u1} C _inst_1) -> (CategoryTheory.WithTerminal.{u2, u1} C _inst_1) -> Type.{u2}\nCase conversion may be inaccurate. Consider using '#align category_theory.with_terminal.hom CategoryTheory.WithTerminal.Homₓ'. -/\n/-- Morphisms for `with_terminal C`. -/\n@[simp, nolint has_nonempty_instance]\ndef Hom : WithTerminal C → WithTerminal C → Type v\n  | of X, of Y => X ⟶ Y\n  | star, of X => PEmpty\n  | _, star => PUnit\n#align category_theory.with_terminal.hom CategoryTheory.WithTerminal.Hom\n\n/- warning: category_theory.with_terminal.id -> CategoryTheory.WithTerminal.id is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] (X : CategoryTheory.WithTerminal.{u1, u2} C _inst_1), CategoryTheory.WithTerminal.Hom.{u1, u2} C _inst_1 X X\nbut is expected to have type\n  PUnit.{max (succ (succ u1)) (succ (succ u2))}\nCase conversion may be inaccurate. Consider using '#align category_theory.with_terminal.id CategoryTheory.WithTerminal.idₓ'. -/\n/-- Identity morphisms for `with_terminal C`. -/\n@[simp]\ndef id : ∀ X : WithTerminal C, Hom X X\n  | of X => 𝟙 _\n  | star => PUnit.unit\n#align category_theory.with_terminal.id CategoryTheory.WithTerminal.id\n\n/- warning: category_theory.with_terminal.comp -> CategoryTheory.WithTerminal.comp is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {X : CategoryTheory.WithTerminal.{u1, u2} C _inst_1} {Y : CategoryTheory.WithTerminal.{u1, u2} C _inst_1} {Z : CategoryTheory.WithTerminal.{u1, u2} C _inst_1}, (CategoryTheory.WithTerminal.Hom.{u1, u2} C _inst_1 X Y) -> (CategoryTheory.WithTerminal.Hom.{u1, u2} C _inst_1 Y Z) -> (CategoryTheory.WithTerminal.Hom.{u1, u2} C _inst_1 X Z)\nbut is expected to have type\n  PUnit.{max (succ (succ u1)) (succ (succ u2))}\nCase conversion may be inaccurate. Consider using '#align category_theory.with_terminal.comp CategoryTheory.WithTerminal.compₓ'. -/\n/-- Composition of morphisms for `with_terminal C`. -/\n@[simp]\ndef comp : ∀ {X Y Z : WithTerminal C}, Hom X Y → Hom Y Z → Hom X Z\n  | of X, of Y, of Z => fun f g => f ≫ g\n  | of X, _, star => fun f g => PUnit.unit\n  | star, of X, _ => fun f g => PEmpty.elim f\n  | _, star, of Y => fun f g => PEmpty.elim g\n  | star, star, star => fun _ _ => PUnit.unit\n#align category_theory.with_terminal.comp CategoryTheory.WithTerminal.comp\n\ninstance : Category.{v} (WithTerminal C)\n    where\n  Hom X Y := Hom X Y\n  id X := id _\n  comp X Y Z f g := comp f g\n\n/-- The inclusion from `C` into `with_terminal C`. -/\ndef incl : C ⥤ WithTerminal C where\n  obj := of\n  map X Y f := f\n#align category_theory.with_terminal.incl CategoryTheory.WithTerminal.incl\n\ninstance : Full (incl : C ⥤ _) where preimage X Y f := f\n\ninstance : Faithful (incl : C ⥤ _) where\n\n/-- Map `with_terminal` with respect to a functor `F : C ⥤ D`. -/\ndef map {D : Type _} [Category D] (F : C ⥤ D) : WithTerminal C ⥤ WithTerminal D\n    where\n  obj X :=\n    match X with\n    | of x => of <| F.obj x\n    | star => star\n  map X Y f :=\n    match X, Y, f with\n    | of x, of y, f => F.map f\n    | of x, star, PUnit.unit => PUnit.unit\n    | star, star, PUnit.unit => PUnit.unit\n#align category_theory.with_terminal.map CategoryTheory.WithTerminal.map\n\ninstance {X : WithTerminal C} : Unique (X ⟶ star)\n    where\n  default :=\n    match X with\n    | of x => PUnit.unit\n    | star => PUnit.unit\n  uniq := by tidy\n\n/-- `with_terminal.star` is terminal. -/\ndef starTerminal : Limits.IsTerminal (star : WithTerminal C) :=\n  Limits.IsTerminal.ofUnique _\n#align category_theory.with_terminal.star_terminal CategoryTheory.WithTerminal.starTerminal\n\n/-- Lift a functor `F : C ⥤ D` to `with_term C ⥤ D`. -/\n@[simps]\ndef lift {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, F.obj x ⟶ Z)\n    (hM : ∀ (x y : C) (f : x ⟶ y), F.map f ≫ M y = M x) : WithTerminal C ⥤ D\n    where\n  obj X :=\n    match X with\n    | of x => F.obj x\n    | star => Z\n  map X Y f :=\n    match X, Y, f with\n    | of x, of y, f => F.map f\n    | of x, star, PUnit.unit => M x\n    | star, star, PUnit.unit => 𝟙 Z\n#align category_theory.with_terminal.lift CategoryTheory.WithTerminal.lift\n\n/-- The isomorphism between `incl ⋙ lift F _ _` with `F`. -/\n@[simps]\ndef inclLift {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, F.obj x ⟶ Z)\n    (hM : ∀ (x y : C) (f : x ⟶ y), F.map f ≫ M y = M x) : incl ⋙ lift F M hM ≅ F\n    where\n  Hom := { app := fun X => 𝟙 _ }\n  inv := { app := fun X => 𝟙 _ }\n#align category_theory.with_terminal.incl_lift CategoryTheory.WithTerminal.inclLift\n\n/-- The isomorphism between `(lift F _ _).obj with_terminal.star` with `Z`. -/\n@[simps]\ndef liftStar {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, F.obj x ⟶ Z)\n    (hM : ∀ (x y : C) (f : x ⟶ y), F.map f ≫ M y = M x) : (lift F M hM).obj star ≅ Z :=\n  eqToIso rfl\n#align category_theory.with_terminal.lift_star CategoryTheory.WithTerminal.liftStar\n\ntheorem lift_map_liftStar {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, F.obj x ⟶ Z)\n    (hM : ∀ (x y : C) (f : x ⟶ y), F.map f ≫ M y = M x) (x : C) :\n    (lift F M hM).map (starTerminal.from (incl.obj x)) ≫ (liftStar F M hM).Hom =\n      (inclLift F M hM).Hom.app x ≫ M x :=\n  by\n  erw [category.id_comp, category.comp_id]\n  rfl\n#align category_theory.with_terminal.lift_map_lift_star CategoryTheory.WithTerminal.lift_map_liftStar\n\n/-- The uniqueness of `lift`. -/\n@[simp]\ndef liftUnique {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, F.obj x ⟶ Z)\n    (hM : ∀ (x y : C) (f : x ⟶ y), F.map f ≫ M y = M x) (G : WithTerminal C ⥤ D) (h : incl ⋙ G ≅ F)\n    (hG : G.obj star ≅ Z)\n    (hh : ∀ x : C, G.map (starTerminal.from (incl.obj x)) ≫ hG.Hom = h.Hom.app x ≫ M x) :\n    G ≅ lift F M hM :=\n  NatIso.ofComponents\n    (fun X =>\n      match X with\n      | of x => h.app x\n      | star => hG)\n    (by\n      rintro (X | X) (Y | Y) f\n      · apply h.hom.naturality\n      · cases f\n        exact hh _\n      · cases f\n      · cases f\n        change G.map (𝟙 _) ≫ hG.hom = hG.hom ≫ 𝟙 _\n        simp)\n#align category_theory.with_terminal.lift_unique CategoryTheory.WithTerminal.liftUnique\n\n/-- A variant of `lift` with `Z` a terminal object. -/\n@[simps]\ndef liftToTerminal {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (hZ : Limits.IsTerminal Z) :\n    WithTerminal C ⥤ D :=\n  lift F (fun x => hZ.from _) fun x y f => hZ.hom_ext _ _\n#align category_theory.with_terminal.lift_to_terminal CategoryTheory.WithTerminal.liftToTerminal\n\n/-- A variant of `incl_lift` with `Z` a terminal object. -/\n@[simps]\ndef inclLiftToTerminal {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (hZ : Limits.IsTerminal Z) :\n    incl ⋙ liftToTerminal F hZ ≅ F :=\n  inclLift _ _ _\n#align category_theory.with_terminal.incl_lift_to_terminal CategoryTheory.WithTerminal.inclLiftToTerminal\n\n/-- A variant of `lift_unique` with `Z` a terminal object. -/\n@[simps]\ndef liftToTerminalUnique {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (hZ : Limits.IsTerminal Z)\n    (G : WithTerminal C ⥤ D) (h : incl ⋙ G ≅ F) (hG : G.obj star ≅ Z) : G ≅ liftToTerminal F hZ :=\n  liftUnique F (fun z => hZ.from _) (fun x y f => hZ.hom_ext _ _) G h hG fun x => hZ.hom_ext _ _\n#align category_theory.with_terminal.lift_to_terminal_unique CategoryTheory.WithTerminal.liftToTerminalUnique\n\n/-- Constructs a morphism to `star` from `of X`. -/\n@[simp]\ndef homFrom (X : C) : incl.obj X ⟶ star :=\n  starTerminal.from _\n#align category_theory.with_terminal.hom_from CategoryTheory.WithTerminal.homFrom\n\ninstance isIso_of_from_star {X : WithTerminal C} (f : star ⟶ X) : IsIso f := by tidy\n#align category_theory.with_terminal.is_iso_of_from_star CategoryTheory.WithTerminal.isIso_of_from_star\n\nend WithTerminal\n\nnamespace WithInitial\n\nattribute [local tidy] tactic.case_bash\n\nvariable {C}\n\n/- warning: category_theory.with_initial.hom -> CategoryTheory.WithInitial.Hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C], (CategoryTheory.WithInitial.{u1, u2} C _inst_1) -> (CategoryTheory.WithInitial.{u1, u2} C _inst_1) -> Type.{u1}\nbut is expected to have type\n  forall {C : Type.{u1}} [_inst_1 : CategoryTheory.Category.{u2, u1} C], (CategoryTheory.WithInitial.{u2, u1} C _inst_1) -> (CategoryTheory.WithInitial.{u2, u1} C _inst_1) -> Type.{u2}\nCase conversion may be inaccurate. Consider using '#align category_theory.with_initial.hom CategoryTheory.WithInitial.Homₓ'. -/\n/-- Morphisms for `with_initial C`. -/\n@[simp, nolint has_nonempty_instance]\ndef Hom : WithInitial C → WithInitial C → Type v\n  | of X, of Y => X ⟶ Y\n  | of X, _ => PEmpty\n  | star, _ => PUnit\n#align category_theory.with_initial.hom CategoryTheory.WithInitial.Hom\n\n/- warning: category_theory.with_initial.id -> CategoryTheory.WithInitial.id is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] (X : CategoryTheory.WithInitial.{u1, u2} C _inst_1), CategoryTheory.WithInitial.Hom.{u1, u2} C _inst_1 X X\nbut is expected to have type\n  PUnit.{max (succ (succ u1)) (succ (succ u2))}\nCase conversion may be inaccurate. Consider using '#align category_theory.with_initial.id CategoryTheory.WithInitial.idₓ'. -/\n/-- Identity morphisms for `with_initial C`. -/\n@[simp]\ndef id : ∀ X : WithInitial C, Hom X X\n  | of X => 𝟙 _\n  | star => PUnit.unit\n#align category_theory.with_initial.id CategoryTheory.WithInitial.id\n\n/- warning: category_theory.with_initial.comp -> CategoryTheory.WithInitial.comp is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] {X : CategoryTheory.WithInitial.{u1, u2} C _inst_1} {Y : CategoryTheory.WithInitial.{u1, u2} C _inst_1} {Z : CategoryTheory.WithInitial.{u1, u2} C _inst_1}, (CategoryTheory.WithInitial.Hom.{u1, u2} C _inst_1 X Y) -> (CategoryTheory.WithInitial.Hom.{u1, u2} C _inst_1 Y Z) -> (CategoryTheory.WithInitial.Hom.{u1, u2} C _inst_1 X Z)\nbut is expected to have type\n  PUnit.{max (succ (succ u1)) (succ (succ u2))}\nCase conversion may be inaccurate. Consider using '#align category_theory.with_initial.comp CategoryTheory.WithInitial.compₓ'. -/\n/-- Composition of morphisms for `with_initial C`. -/\n@[simp]\ndef comp : ∀ {X Y Z : WithInitial C}, Hom X Y → Hom Y Z → Hom X Z\n  | of X, of Y, of Z => fun f g => f ≫ g\n  | star, _, of X => fun f g => PUnit.unit\n  | _, of X, star => fun f g => PEmpty.elim g\n  | of Y, star, _ => fun f g => PEmpty.elim f\n  | star, star, star => fun _ _ => PUnit.unit\n#align category_theory.with_initial.comp CategoryTheory.WithInitial.comp\n\ninstance : Category.{v} (WithInitial C)\n    where\n  Hom X Y := Hom X Y\n  id X := id _\n  comp X Y Z f g := comp f g\n\n/-- The inclusion of `C` into `with_initial C`. -/\ndef incl : C ⥤ WithInitial C where\n  obj := of\n  map X Y f := f\n#align category_theory.with_initial.incl CategoryTheory.WithInitial.incl\n\ninstance : Full (incl : C ⥤ _) where preimage X Y f := f\n\ninstance : Faithful (incl : C ⥤ _) where\n\n/-- Map `with_initial` with respect to a functor `F : C ⥤ D`. -/\ndef map {D : Type _} [Category D] (F : C ⥤ D) : WithInitial C ⥤ WithInitial D\n    where\n  obj X :=\n    match X with\n    | of x => of <| F.obj x\n    | star => star\n  map X Y f :=\n    match X, Y, f with\n    | of x, of y, f => F.map f\n    | star, of x, PUnit.unit => PUnit.unit\n    | star, star, PUnit.unit => PUnit.unit\n#align category_theory.with_initial.map CategoryTheory.WithInitial.map\n\ninstance {X : WithInitial C} : Unique (star ⟶ X)\n    where\n  default :=\n    match X with\n    | of x => PUnit.unit\n    | star => PUnit.unit\n  uniq := by tidy\n\n/-- `with_initial.star` is initial. -/\ndef starInitial : Limits.IsInitial (star : WithInitial C) :=\n  Limits.IsInitial.ofUnique _\n#align category_theory.with_initial.star_initial CategoryTheory.WithInitial.starInitial\n\n/-- Lift a functor `F : C ⥤ D` to `with_initial C ⥤ D`. -/\n@[simps]\ndef lift {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, Z ⟶ F.obj x)\n    (hM : ∀ (x y : C) (f : x ⟶ y), M x ≫ F.map f = M y) : WithInitial C ⥤ D\n    where\n  obj X :=\n    match X with\n    | of x => F.obj x\n    | star => Z\n  map X Y f :=\n    match X, Y, f with\n    | of x, of y, f => F.map f\n    | star, of x, PUnit.unit => M _\n    | star, star, PUnit.unit => 𝟙 _\n#align category_theory.with_initial.lift CategoryTheory.WithInitial.lift\n\n/-- The isomorphism between `incl ⋙ lift F _ _` with `F`. -/\n@[simps]\ndef inclLift {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, Z ⟶ F.obj x)\n    (hM : ∀ (x y : C) (f : x ⟶ y), M x ≫ F.map f = M y) : incl ⋙ lift F M hM ≅ F\n    where\n  Hom := { app := fun X => 𝟙 _ }\n  inv := { app := fun X => 𝟙 _ }\n#align category_theory.with_initial.incl_lift CategoryTheory.WithInitial.inclLift\n\n/-- The isomorphism between `(lift F _ _).obj with_term.star` with `Z`. -/\n@[simps]\ndef liftStar {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, Z ⟶ F.obj x)\n    (hM : ∀ (x y : C) (f : x ⟶ y), M x ≫ F.map f = M y) : (lift F M hM).obj star ≅ Z :=\n  eqToIso rfl\n#align category_theory.with_initial.lift_star CategoryTheory.WithInitial.liftStar\n\ntheorem liftStar_lift_map {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, Z ⟶ F.obj x)\n    (hM : ∀ (x y : C) (f : x ⟶ y), M x ≫ F.map f = M y) (x : C) :\n    (liftStar F M hM).Hom ≫ (lift F M hM).map (starInitial.to (incl.obj x)) =\n      M x ≫ (inclLift F M hM).Hom.app x :=\n  by\n  erw [category.id_comp, category.comp_id]\n  rfl\n#align category_theory.with_initial.lift_star_lift_map CategoryTheory.WithInitial.liftStar_lift_map\n\n/-- The uniqueness of `lift`. -/\n@[simp]\ndef liftUnique {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (M : ∀ x : C, Z ⟶ F.obj x)\n    (hM : ∀ (x y : C) (f : x ⟶ y), M x ≫ F.map f = M y) (G : WithInitial C ⥤ D) (h : incl ⋙ G ≅ F)\n    (hG : G.obj star ≅ Z)\n    (hh : ∀ x : C, hG.symm.Hom ≫ G.map (starInitial.to (incl.obj x)) = M x ≫ h.symm.Hom.app x) :\n    G ≅ lift F M hM :=\n  NatIso.ofComponents\n    (fun X =>\n      match X with\n      | of x => h.app x\n      | star => hG)\n    (by\n      rintro (X | X) (Y | Y) f\n      · apply h.hom.naturality\n      · cases f\n      · cases f\n        change G.map _ ≫ h.hom.app _ = hG.hom ≫ _\n        symm\n        erw [← iso.eq_inv_comp, ← category.assoc, hh]\n        simpa\n      · cases f\n        change G.map (𝟙 _) ≫ hG.hom = hG.hom ≫ 𝟙 _\n        simp)\n#align category_theory.with_initial.lift_unique CategoryTheory.WithInitial.liftUnique\n\n/-- A variant of `lift` with `Z` an initial object. -/\n@[simps]\ndef liftToInitial {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (hZ : Limits.IsInitial Z) :\n    WithInitial C ⥤ D :=\n  lift F (fun x => hZ.to _) fun x y f => hZ.hom_ext _ _\n#align category_theory.with_initial.lift_to_initial CategoryTheory.WithInitial.liftToInitial\n\n/-- A variant of `incl_lift` with `Z` an initial object. -/\n@[simps]\ndef inclLiftToInitial {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (hZ : Limits.IsInitial Z) :\n    incl ⋙ liftToInitial F hZ ≅ F :=\n  inclLift _ _ _\n#align category_theory.with_initial.incl_lift_to_initial CategoryTheory.WithInitial.inclLiftToInitial\n\n/-- A variant of `lift_unique` with `Z` an initial object. -/\n@[simps]\ndef liftToInitialUnique {D : Type _} [Category D] {Z : D} (F : C ⥤ D) (hZ : Limits.IsInitial Z)\n    (G : WithInitial C ⥤ D) (h : incl ⋙ G ≅ F) (hG : G.obj star ≅ Z) : G ≅ liftToInitial F hZ :=\n  liftUnique F (fun z => hZ.to _) (fun x y f => hZ.hom_ext _ _) G h hG fun x => hZ.hom_ext _ _\n#align category_theory.with_initial.lift_to_initial_unique CategoryTheory.WithInitial.liftToInitialUnique\n\n/-- Constructs a morphism from `star` to `of X`. -/\n@[simp]\ndef homTo (X : C) : star ⟶ incl.obj X :=\n  starInitial.to _\n#align category_theory.with_initial.hom_to CategoryTheory.WithInitial.homTo\n\ninstance isIso_of_to_star {X : WithInitial C} (f : X ⟶ star) : IsIso f := by tidy\n#align category_theory.with_initial.is_iso_of_to_star CategoryTheory.WithInitial.isIso_of_to_star\n\nend WithInitial\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/WithTerminal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4698993842948791}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Jeremy Avigad, Simon Hudon\n\n! This file was ported from Lean 3 source module data.part\n! leanprover-community/mathlib commit 80c43012d26f63026d362c3aba28f3c3bafb07e6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Basic\nimport Mathbin.Logic.Equiv.Defs\n\n/-!\n# Partial values of a type\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines `part α`, the partial values of a type.\n\n`o : part α` carries a proposition `o.dom`, its domain, along with a function `get : o.dom → α`, its\nvalue. The rule is then that every partial value has a value but, to access it, you need to provide\na proof of the domain.\n\n`part α` behaves the same as `option α` except that `o : option α` is decidably `none` or `some a`\nfor some `a : α`, while the domain of `o : part α` doesn't have to be decidable. That means you can\ntranslate back and forth between a partial value with a decidable domain and an option, and\n`option α` and `part α` are classically equivalent. In general, `part α` is bigger than `option α`.\n\nIn current mathlib, `part ℕ`, aka `part_enat`, is used to move decidability of the order to\ndecidability of `part_enat.find` (which is the smallest natural satisfying a predicate, or `∞` if\nthere's none).\n\n## Main declarations\n\n`option`-like declarations:\n* `part.none`: The partial value whose domain is `false`.\n* `part.some a`: The partial value whose domain is `true` and whose value is `a`.\n* `part.of_option`: Converts an `option α` to a `part α` by sending `none` to `none` and `some a` to\n  `some a`.\n* `part.to_option`: Converts a `part α` with a decidable domain to an `option α`.\n* `part.equiv_option`: Classical equivalence between `part α` and `option α`.\n\nMonadic structure:\n* `part.bind`: `o.bind f` has value `(f (o.get _)).get _` (`f o` morally) and is defined when `o`\n  and `f (o.get _)` are defined.\n* `part.map`: Maps the value and keeps the same domain.\n\nOther:\n* `part.restrict`: `part.restrict p o` replaces the domain of `o : part α` by `p : Prop` so long as\n  `p → o.dom`.\n* `part.assert`: `assert p f` appends `p` to the domains of the values of a partial function.\n* `part.unwrap`: Gets the value of a partial value regardless of its domain. Unsound.\n\n## Notation\n\nFor `a : α`, `o : part α`, `a ∈ o` means that `o` is defined and equal to `a`. Formally, it means\n`o.dom` and `o.get _ = a`.\n-/\n\n\nopen Function\n\n#print Part /-\n/-- `part α` is the type of \"partial values\" of type `α`. It\n  is similar to `option α` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure Part.{u} (α : Type u) : Type u where\n  Dom : Prop\n  get : dom → α\n#align part Part\n-/\n\nnamespace Part\n\nvariable {α : Type _} {β : Type _} {γ : Type _}\n\n#print Part.toOption /-\n/-- Convert a `part α` with a decidable domain to an option -/\ndef toOption (o : Part α) [Decidable o.Dom] : Option α :=\n  if h : Dom o then some (o.get h) else none\n#align part.to_option Part.toOption\n-/\n\n#print Part.toOption_isSome /-\n@[simp]\ntheorem toOption_isSome (o : Part α) [Decidable o.Dom] : o.toOption.isSome ↔ o.Dom := by\n  by_cases o.dom <;> simp [h, Part.toOption]\n#align part.to_option_is_some Part.toOption_isSome\n-/\n\n#print Part.toOption_isNone /-\n@[simp]\ntheorem toOption_isNone (o : Part α) [Decidable o.Dom] : o.toOption.isNone ↔ ¬o.Dom := by\n  by_cases o.dom <;> simp [h, Part.toOption]\n#align part.to_option_is_none Part.toOption_isNone\n-/\n\n#print Part.ext' /-\n/-- `part` extensionality -/\ntheorem ext' : ∀ {o p : Part α} (H1 : o.Dom ↔ p.Dom) (H2 : ∀ h₁ h₂, o.get h₁ = p.get h₂), o = p\n  | ⟨od, o⟩, ⟨pd, p⟩, H1, H2 => by\n    have t : od = pd := propext H1\n    cases t <;> rw [show o = p from funext fun p => H2 p p]\n#align part.ext' Part.ext'\n-/\n\n#print Part.eta /-\n/-- `part` eta expansion -/\n@[simp]\ntheorem eta : ∀ o : Part α, (⟨o.Dom, fun h => o.get h⟩ : Part α) = o\n  | ⟨h, f⟩ => rfl\n#align part.eta Part.eta\n-/\n\n#print Part.Mem /-\n/-- `a ∈ o` means that `o` is defined and equal to `a` -/\nprotected def Mem (a : α) (o : Part α) : Prop :=\n  ∃ h, o.get h = a\n#align part.mem Part.Mem\n-/\n\ninstance : Membership α (Part α) :=\n  ⟨Part.Mem⟩\n\n#print Part.mem_eq /-\ntheorem mem_eq (a : α) (o : Part α) : (a ∈ o) = ∃ h, o.get h = a :=\n  rfl\n#align part.mem_eq Part.mem_eq\n-/\n\n#print Part.dom_iff_mem /-\ntheorem dom_iff_mem : ∀ {o : Part α}, o.Dom ↔ ∃ y, y ∈ o\n  | ⟨p, f⟩ => ⟨fun h => ⟨f h, h, rfl⟩, fun ⟨_, h, rfl⟩ => h⟩\n#align part.dom_iff_mem Part.dom_iff_mem\n-/\n\n#print Part.get_mem /-\ntheorem get_mem {o : Part α} (h) : get o h ∈ o :=\n  ⟨_, rfl⟩\n#align part.get_mem Part.get_mem\n-/\n\n#print Part.mem_mk_iff /-\n@[simp]\ntheorem mem_mk_iff {p : Prop} {o : p → α} {a : α} : a ∈ Part.mk p o ↔ ∃ h, o h = a :=\n  Iff.rfl\n#align part.mem_mk_iff Part.mem_mk_iff\n-/\n\n#print Part.ext /-\n/-- `part` extensionality -/\n@[ext]\ntheorem ext {o p : Part α} (H : ∀ a, a ∈ o ↔ a ∈ p) : o = p :=\n  ext' ⟨fun h => ((H _).1 ⟨h, rfl⟩).fst, fun h => ((H _).2 ⟨h, rfl⟩).fst⟩ fun a b =>\n    ((H _).2 ⟨_, rfl⟩).snd\n#align part.ext Part.ext\n-/\n\n#print Part.none /-\n/-- The `none` value in `part` has a `false` domain and an empty function. -/\ndef none : Part α :=\n  ⟨False, False.ndrec _⟩\n#align part.none Part.none\n-/\n\ninstance : Inhabited (Part α) :=\n  ⟨none⟩\n\n#print Part.not_mem_none /-\n@[simp]\ntheorem not_mem_none (a : α) : a ∉ @none α := fun h => h.fst\n#align part.not_mem_none Part.not_mem_none\n-/\n\n#print Part.some /-\n/-- The `some a` value in `part` has a `true` domain and the\n  function returns `a`. -/\ndef some (a : α) : Part α :=\n  ⟨True, fun _ => a⟩\n#align part.some Part.some\n-/\n\n#print Part.some_dom /-\n@[simp]\ntheorem some_dom (a : α) : (some a).Dom :=\n  trivial\n#align part.some_dom Part.some_dom\n-/\n\n#print Part.mem_unique /-\ntheorem mem_unique : ∀ {a b : α} {o : Part α}, a ∈ o → b ∈ o → a = b\n  | _, _, ⟨p, f⟩, ⟨h₁, rfl⟩, ⟨h₂, rfl⟩ => rfl\n#align part.mem_unique Part.mem_unique\n-/\n\n#print Part.Mem.left_unique /-\ntheorem Mem.left_unique : Relator.LeftUnique ((· ∈ ·) : α → Part α → Prop) := fun a o b =>\n  mem_unique\n#align part.mem.left_unique Part.Mem.left_unique\n-/\n\n#print Part.get_eq_of_mem /-\ntheorem get_eq_of_mem {o : Part α} {a} (h : a ∈ o) (h') : get o h' = a :=\n  mem_unique ⟨_, rfl⟩ h\n#align part.get_eq_of_mem Part.get_eq_of_mem\n-/\n\n#print Part.subsingleton /-\nprotected theorem subsingleton (o : Part α) : Set.Subsingleton { a | a ∈ o } := fun a ha b hb =>\n  mem_unique ha hb\n#align part.subsingleton Part.subsingleton\n-/\n\n#print Part.get_some /-\n@[simp]\ntheorem get_some {a : α} (ha : (some a).Dom) : get (some a) ha = a :=\n  rfl\n#align part.get_some Part.get_some\n-/\n\n#print Part.mem_some /-\ntheorem mem_some (a : α) : a ∈ some a :=\n  ⟨trivial, rfl⟩\n#align part.mem_some Part.mem_some\n-/\n\n#print Part.mem_some_iff /-\n@[simp]\ntheorem mem_some_iff {a b} : b ∈ (some a : Part α) ↔ b = a :=\n  ⟨fun ⟨h, e⟩ => e.symm, fun e => ⟨trivial, e.symm⟩⟩\n#align part.mem_some_iff Part.mem_some_iff\n-/\n\n#print Part.eq_some_iff /-\ntheorem eq_some_iff {a : α} {o : Part α} : o = some a ↔ a ∈ o :=\n  ⟨fun e => e.symm ▸ mem_some _, fun ⟨h, e⟩ => e ▸ ext' (iff_true_intro h) fun _ _ => rfl⟩\n#align part.eq_some_iff Part.eq_some_iff\n-/\n\n#print Part.eq_none_iff /-\ntheorem eq_none_iff {o : Part α} : o = none ↔ ∀ a, a ∉ o :=\n  ⟨fun e => e.symm ▸ not_mem_none, fun h => ext (by simpa)⟩\n#align part.eq_none_iff Part.eq_none_iff\n-/\n\n#print Part.eq_none_iff' /-\ntheorem eq_none_iff' {o : Part α} : o = none ↔ ¬o.Dom :=\n  ⟨fun e => e.symm ▸ id, fun h => eq_none_iff.2 fun a h' => h h'.fst⟩\n#align part.eq_none_iff' Part.eq_none_iff'\n-/\n\n#print Part.not_none_dom /-\n@[simp]\ntheorem not_none_dom : ¬(none : Part α).Dom :=\n  id\n#align part.not_none_dom Part.not_none_dom\n-/\n\n#print Part.some_ne_none /-\n@[simp]\ntheorem some_ne_none (x : α) : some x ≠ none :=\n  by\n  intro h\n  change none.dom\n  rw [← h]\n  trivial\n#align part.some_ne_none Part.some_ne_none\n-/\n\n#print Part.none_ne_some /-\n@[simp]\ntheorem none_ne_some (x : α) : none ≠ some x :=\n  (some_ne_none x).symm\n#align part.none_ne_some Part.none_ne_some\n-/\n\n#print Part.ne_none_iff /-\ntheorem ne_none_iff {o : Part α} : o ≠ none ↔ ∃ x, o = some x :=\n  by\n  constructor\n  · rw [Ne, eq_none_iff', Classical.not_not]\n    exact fun h => ⟨o.get h, eq_some_iff.2 (get_mem h)⟩\n  · rintro ⟨x, rfl⟩\n    apply some_ne_none\n#align part.ne_none_iff Part.ne_none_iff\n-/\n\n#print Part.eq_none_or_eq_some /-\ntheorem eq_none_or_eq_some (o : Part α) : o = none ∨ ∃ x, o = some x :=\n  or_iff_not_imp_left.2 ne_none_iff.1\n#align part.eq_none_or_eq_some Part.eq_none_or_eq_some\n-/\n\n#print Part.some_injective /-\ntheorem some_injective : Injective (@Part.some α) := fun a b h =>\n  congr_fun (eq_of_hEq (Part.mk.inj h).2) trivial\n#align part.some_injective Part.some_injective\n-/\n\n#print Part.some_inj /-\n@[simp]\ntheorem some_inj {a b : α} : Part.some a = some b ↔ a = b :=\n  some_injective.eq_iff\n#align part.some_inj Part.some_inj\n-/\n\n#print Part.some_get /-\n@[simp]\ntheorem some_get {a : Part α} (ha : a.Dom) : Part.some (Part.get a ha) = a :=\n  Eq.symm (eq_some_iff.2 ⟨ha, rfl⟩)\n#align part.some_get Part.some_get\n-/\n\n#print Part.get_eq_iff_eq_some /-\ntheorem get_eq_iff_eq_some {a : Part α} {ha : a.Dom} {b : α} : a.get ha = b ↔ a = some b :=\n  ⟨fun h => by simp [h.symm], fun h => by simp [h]⟩\n#align part.get_eq_iff_eq_some Part.get_eq_iff_eq_some\n-/\n\n#print Part.get_eq_get_of_eq /-\ntheorem get_eq_get_of_eq (a : Part α) (ha : a.Dom) {b : Part α} (h : a = b) :\n    a.get ha = b.get (h ▸ ha) := by\n  congr\n  exact h\n#align part.get_eq_get_of_eq Part.get_eq_get_of_eq\n-/\n\n#print Part.get_eq_iff_mem /-\ntheorem get_eq_iff_mem {o : Part α} {a : α} (h : o.Dom) : o.get h = a ↔ a ∈ o :=\n  ⟨fun H => ⟨h, H⟩, fun ⟨h', H⟩ => H⟩\n#align part.get_eq_iff_mem Part.get_eq_iff_mem\n-/\n\n#print Part.eq_get_iff_mem /-\ntheorem eq_get_iff_mem {o : Part α} {a : α} (h : o.Dom) : a = o.get h ↔ a ∈ o :=\n  eq_comm.trans (get_eq_iff_mem h)\n#align part.eq_get_iff_mem Part.eq_get_iff_mem\n-/\n\n#print Part.none_toOption /-\n@[simp]\ntheorem none_toOption [Decidable (@none α).Dom] : (none : Part α).toOption = Option.none :=\n  dif_neg id\n#align part.none_to_option Part.none_toOption\n-/\n\n#print Part.some_toOption /-\n@[simp]\ntheorem some_toOption (a : α) [Decidable (some a).Dom] : (some a).toOption = Option.some a :=\n  dif_pos trivial\n#align part.some_to_option Part.some_toOption\n-/\n\n#print Part.noneDecidable /-\ninstance noneDecidable : Decidable (@none α).Dom :=\n  Decidable.false\n#align part.none_decidable Part.noneDecidable\n-/\n\n#print Part.someDecidable /-\ninstance someDecidable (a : α) : Decidable (some a).Dom :=\n  Decidable.true\n#align part.some_decidable Part.someDecidable\n-/\n\n#print Part.getOrElse /-\n/-- Retrieves the value of `a : part α` if it exists, and return the provided default value\notherwise. -/\ndef getOrElse (a : Part α) [Decidable a.Dom] (d : α) :=\n  if ha : a.Dom then a.get ha else d\n#align part.get_or_else Part.getOrElse\n-/\n\n#print Part.getOrElse_of_dom /-\ntheorem getOrElse_of_dom (a : Part α) (h : a.Dom) [Decidable a.Dom] (d : α) :\n    getOrElse a d = a.get h :=\n  dif_pos h\n#align part.get_or_else_of_dom Part.getOrElse_of_dom\n-/\n\n#print Part.getOrElse_of_not_dom /-\ntheorem getOrElse_of_not_dom (a : Part α) (h : ¬a.Dom) [Decidable a.Dom] (d : α) :\n    getOrElse a d = d :=\n  dif_neg h\n#align part.get_or_else_of_not_dom Part.getOrElse_of_not_dom\n-/\n\n#print Part.getOrElse_none /-\n@[simp]\ntheorem getOrElse_none (d : α) [Decidable (none : Part α).Dom] : getOrElse none d = d :=\n  none.getOrElse_of_not_dom not_none_dom d\n#align part.get_or_else_none Part.getOrElse_none\n-/\n\n#print Part.getOrElse_some /-\n@[simp]\ntheorem getOrElse_some (a : α) (d : α) [Decidable (some a).Dom] : getOrElse (some a) d = a :=\n  (some a).getOrElse_of_dom (some_dom a) d\n#align part.get_or_else_some Part.getOrElse_some\n-/\n\n#print Part.mem_toOption /-\n@[simp]\ntheorem mem_toOption {o : Part α} [Decidable o.Dom] {a : α} : a ∈ toOption o ↔ a ∈ o :=\n  by\n  unfold to_option\n  by_cases h : o.dom <;> simp [h]\n  · exact ⟨fun h => ⟨_, h⟩, fun ⟨_, h⟩ => h⟩\n  · exact mt Exists.fst h\n#align part.mem_to_option Part.mem_toOption\n-/\n\n#print Part.Dom.toOption /-\nprotected theorem Dom.toOption {o : Part α} [Decidable o.Dom] (h : o.Dom) : o.toOption = o.get h :=\n  dif_pos h\n#align part.dom.to_option Part.Dom.toOption\n-/\n\n#print Part.toOption_eq_none_iff /-\ntheorem toOption_eq_none_iff {a : Part α} [Decidable a.Dom] : a.toOption = Option.none ↔ ¬a.Dom :=\n  Ne.dite_eq_right_iff fun h => Option.some_ne_none _\n#align part.to_option_eq_none_iff Part.toOption_eq_none_iff\n-/\n\n/- warning: part.elim_to_option -> Part.elim_toOption is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (a : Part.{u1} α) [_inst_1 : Decidable (Part.Dom.{u1} α a)] (b : β) (f : α -> β), Eq.{succ u2} β (Option.elim'.{u1, u2} α β b f (Part.toOption.{u1} α a _inst_1)) (dite.{succ u2} β (Part.Dom.{u1} α a) _inst_1 (fun (h : Part.Dom.{u1} α a) => f (Part.get.{u1} α a h)) (fun (h : Not (Part.Dom.{u1} α a)) => b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (a : Part.{u2} α) [_inst_1 : Decidable (Part.Dom.{u2} α a)] (b : β) (f : α -> β), Eq.{succ u1} β (Option.elim.{u2, succ u1} α β (Part.toOption.{u2} α a _inst_1) b f) (dite.{succ u1} β (Part.Dom.{u2} α a) _inst_1 (fun (h : Part.Dom.{u2} α a) => f (Part.get.{u2} α a h)) (fun (h : Not (Part.Dom.{u2} α a)) => b))\nCase conversion may be inaccurate. Consider using '#align part.elim_to_option Part.elim_toOptionₓ'. -/\n@[simp]\ntheorem elim_toOption {α β : Type _} (a : Part α) [Decidable a.Dom] (b : β) (f : α → β) :\n    a.toOption.elim b f = if h : a.Dom then f (a.get h) else b :=\n  by\n  split_ifs\n  · rw [h.to_option]\n    rfl\n  · rw [Part.toOption_eq_none_iff.2 h]\n    rfl\n#align part.elim_to_option Part.elim_toOption\n\n#print Part.ofOption /-\n/-- Converts an `option α` into a `part α`. -/\ndef ofOption : Option α → Part α\n  | Option.none => none\n  | Option.some a => some a\n#align part.of_option Part.ofOption\n-/\n\n#print Part.mem_ofOption /-\n@[simp]\ntheorem mem_ofOption {a : α} : ∀ {o : Option α}, a ∈ ofOption o ↔ a ∈ o\n  | Option.none => ⟨fun h => h.fst.elim, fun h => Option.noConfusion h⟩\n  | Option.some b => ⟨fun h => congr_arg Option.some h.snd, fun h => ⟨trivial, Option.some.inj h⟩⟩\n#align part.mem_of_option Part.mem_ofOption\n-/\n\n#print Part.ofOption_dom /-\n@[simp]\ntheorem ofOption_dom {α} : ∀ o : Option α, (ofOption o).Dom ↔ o.isSome\n  | Option.none => by simp [of_option, none]\n  | Option.some a => by simp [of_option]\n#align part.of_option_dom Part.ofOption_dom\n-/\n\n#print Part.ofOption_eq_get /-\ntheorem ofOption_eq_get {α} (o : Option α) : ofOption o = ⟨_, @Option.get _ o⟩ :=\n  Part.ext' (ofOption_dom o) fun h₁ h₂ => by cases o <;> [cases h₁, rfl]\n#align part.of_option_eq_get Part.ofOption_eq_get\n-/\n\ninstance : Coe (Option α) (Part α) :=\n  ⟨ofOption⟩\n\n#print Part.mem_coe /-\n@[simp]\ntheorem mem_coe {a : α} {o : Option α} : a ∈ (o : Part α) ↔ a ∈ o :=\n  mem_ofOption\n#align part.mem_coe Part.mem_coe\n-/\n\n#print Part.coe_none /-\n@[simp]\ntheorem coe_none : (@Option.none α : Part α) = none :=\n  rfl\n#align part.coe_none Part.coe_none\n-/\n\n#print Part.coe_some /-\n@[simp]\ntheorem coe_some (a : α) : (Option.some a : Part α) = some a :=\n  rfl\n#align part.coe_some Part.coe_some\n-/\n\n#print Part.induction_on /-\n@[elab_as_elim]\nprotected theorem induction_on {P : Part α → Prop} (a : Part α) (hnone : P none)\n    (hsome : ∀ a : α, P (some a)) : P a :=\n  (Classical.em a.Dom).elim (fun h => Part.some_get h ▸ hsome _) fun h =>\n    (eq_none_iff'.2 h).symm ▸ hnone\n#align part.induction_on Part.induction_on\n-/\n\n#print Part.ofOptionDecidable /-\ninstance ofOptionDecidable : ∀ o : Option α, Decidable (ofOption o).Dom\n  | Option.none => Part.noneDecidable\n  | Option.some a => Part.someDecidable a\n#align part.of_option_decidable Part.ofOptionDecidable\n-/\n\n#print Part.to_ofOption /-\n@[simp]\ntheorem to_ofOption (o : Option α) : toOption (ofOption o) = o := by cases o <;> rfl\n#align part.to_of_option Part.to_ofOption\n-/\n\n#print Part.of_toOption /-\n@[simp]\ntheorem of_toOption (o : Part α) [Decidable o.Dom] : ofOption (toOption o) = o :=\n  ext fun a => mem_ofOption.trans mem_toOption\n#align part.of_to_option Part.of_toOption\n-/\n\n#print Part.equivOption /-\n/-- `part α` is (classically) equivalent to `option α`. -/\nnoncomputable def equivOption : Part α ≃ Option α :=\n  haveI := Classical.dec\n  ⟨fun o => to_option o, of_option, fun o => of_to_option o, fun o =>\n    Eq.trans (by dsimp <;> congr ) (to_of_option o)⟩\n#align part.equiv_option Part.equivOption\n-/\n\n/-- We give `part α` the order where everything is greater than `none`. -/\ninstance : PartialOrder (Part α)\n    where\n  le x y := ∀ i, i ∈ x → i ∈ y\n  le_refl x y := id\n  le_trans x y z f g i := g _ ∘ f _\n  le_antisymm x y f g := Part.ext fun z => ⟨f _, g _⟩\n\ninstance : OrderBot (Part α) where\n  bot := none\n  bot_le := by\n    introv x\n    rintro ⟨⟨_⟩, _⟩\n\n/- warning: part.le_total_of_le_of_le -> Part.le_total_of_le_of_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {x : Part.{u1} α} {y : Part.{u1} α} (z : Part.{u1} α), (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.partialOrder.{u1} α))) x z) -> (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.partialOrder.{u1} α))) y z) -> (Or (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.partialOrder.{u1} α))) x y) (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.partialOrder.{u1} α))) y x))\nbut is expected to have type\n  forall {α : Type.{u1}} {x : Part.{u1} α} {y : Part.{u1} α} (z : Part.{u1} α), (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.instPartialOrderPart.{u1} α))) x z) -> (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.instPartialOrderPart.{u1} α))) y z) -> (Or (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.instPartialOrderPart.{u1} α))) x y) (LE.le.{u1} (Part.{u1} α) (Preorder.toLE.{u1} (Part.{u1} α) (PartialOrder.toPreorder.{u1} (Part.{u1} α) (Part.instPartialOrderPart.{u1} α))) y x))\nCase conversion may be inaccurate. Consider using '#align part.le_total_of_le_of_le Part.le_total_of_le_of_leₓ'. -/\ntheorem le_total_of_le_of_le {x y : Part α} (z : Part α) (hx : x ≤ z) (hy : y ≤ z) :\n    x ≤ y ∨ y ≤ x := by\n  rcases Part.eq_none_or_eq_some x with (h | ⟨b, h₀⟩)\n  · rw [h]\n    left\n    apply OrderBot.bot_le _\n  right; intro b' h₁\n  rw [Part.eq_some_iff] at h₀\n  replace hx := hx _ h₀; replace hy := hy _ h₁\n  replace hx := Part.mem_unique hx hy; subst hx\n  exact h₀\n#align part.le_total_of_le_of_le Part.le_total_of_le_of_le\n\n#print Part.assert /-\n/-- `assert p f` is a bind-like operation which appends an additional condition\n  `p` to the domain and uses `f` to produce the value. -/\ndef assert (p : Prop) (f : p → Part α) : Part α :=\n  ⟨∃ h : p, (f h).Dom, fun ha => (f ha.fst).get ha.snd⟩\n#align part.assert Part.assert\n-/\n\n#print Part.bind /-\n/-- The bind operation has value `g (f.get)`, and is defined when all the\n  parts are defined. -/\nprotected def bind (f : Part α) (g : α → Part β) : Part β :=\n  assert (Dom f) fun b => g (f.get b)\n#align part.bind Part.bind\n-/\n\n#print Part.map /-\n/-- The map operation for `part` just maps the value and maintains the same domain. -/\n@[simps]\ndef map (f : α → β) (o : Part α) : Part β :=\n  ⟨o.Dom, f ∘ o.get⟩\n#align part.map Part.map\n-/\n\n/- warning: part.mem_map -> Part.mem_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) {o : Part.{u1} α} {a : α}, (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a o) -> (Membership.Mem.{u2, u2} β (Part.{u2} β) (Part.hasMem.{u2} β) (f a) (Part.map.{u1, u2} α β f o))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) {o : Part.{u2} α} {a : α}, (Membership.mem.{u2, u2} α (Part.{u2} α) (Part.instMembershipPart.{u2} α) a o) -> (Membership.mem.{u1, u1} β (Part.{u1} β) (Part.instMembershipPart.{u1} β) (f a) (Part.map.{u2, u1} α β f o))\nCase conversion may be inaccurate. Consider using '#align part.mem_map Part.mem_mapₓ'. -/\ntheorem mem_map (f : α → β) {o : Part α} : ∀ {a}, a ∈ o → f a ∈ map f o\n  | _, ⟨h, rfl⟩ => ⟨_, rfl⟩\n#align part.mem_map Part.mem_map\n\n/- warning: part.mem_map_iff -> Part.mem_map_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) {o : Part.{u1} α} {b : β}, Iff (Membership.Mem.{u2, u2} β (Part.{u2} β) (Part.hasMem.{u2} β) b (Part.map.{u1, u2} α β f o)) (Exists.{succ u1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a o) (fun (H : Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a o) => Eq.{succ u2} β (f a) b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) {o : Part.{u2} α} {b : β}, Iff (Membership.mem.{u1, u1} β (Part.{u1} β) (Part.instMembershipPart.{u1} β) b (Part.map.{u2, u1} α β f o)) (Exists.{succ u2} α (fun (a : α) => And (Membership.mem.{u2, u2} α (Part.{u2} α) (Part.instMembershipPart.{u2} α) a o) (Eq.{succ u1} β (f a) b)))\nCase conversion may be inaccurate. Consider using '#align part.mem_map_iff Part.mem_map_iffₓ'. -/\n@[simp]\ntheorem mem_map_iff (f : α → β) {o : Part α} {b} : b ∈ map f o ↔ ∃ a ∈ o, f a = b :=\n  ⟨match b with\n    | _, ⟨h, rfl⟩ => ⟨_, ⟨_, rfl⟩, rfl⟩,\n    fun ⟨a, h₁, h₂⟩ => h₂ ▸ mem_map f h₁⟩\n#align part.mem_map_iff Part.mem_map_iff\n\n#print Part.map_none /-\n@[simp]\ntheorem map_none (f : α → β) : map f none = none :=\n  eq_none_iff.2 fun a => by simp\n#align part.map_none Part.map_none\n-/\n\n#print Part.map_some /-\n@[simp]\ntheorem map_some (f : α → β) (a : α) : map f (some a) = some (f a) :=\n  eq_some_iff.2 <| mem_map f <| mem_some _\n#align part.map_some Part.map_some\n-/\n\n#print Part.mem_assert /-\ntheorem mem_assert {p : Prop} {f : p → Part α} : ∀ {a} (h : p), a ∈ f h → a ∈ assert p f\n  | _, x, ⟨h, rfl⟩ => ⟨⟨x, h⟩, rfl⟩\n#align part.mem_assert Part.mem_assert\n-/\n\n#print Part.mem_assert_iff /-\n@[simp]\ntheorem mem_assert_iff {p : Prop} {f : p → Part α} {a} : a ∈ assert p f ↔ ∃ h : p, a ∈ f h :=\n  ⟨match a with\n    | _, ⟨h, rfl⟩ => ⟨_, ⟨_, rfl⟩⟩,\n    fun ⟨a, h⟩ => mem_assert _ h⟩\n#align part.mem_assert_iff Part.mem_assert_iff\n-/\n\n#print Part.assert_pos /-\ntheorem assert_pos {p : Prop} {f : p → Part α} (h : p) : assert p f = f h :=\n  by\n  dsimp [assert]\n  cases h' : f h\n  simp only [h', h, true_and_iff, iff_self_iff, exists_prop_of_true, eq_iff_iff]\n  apply Function.hfunext\n  · simp only [h, h', exists_prop_of_true]\n  · cc\n#align part.assert_pos Part.assert_pos\n-/\n\n#print Part.assert_neg /-\ntheorem assert_neg {p : Prop} {f : p → Part α} (h : ¬p) : assert p f = none :=\n  by\n  dsimp [assert, none]; congr\n  · simp only [h, not_false_iff, exists_prop_of_false]\n  · apply Function.hfunext\n    · simp only [h, not_false_iff, exists_prop_of_false]\n    cc\n#align part.assert_neg Part.assert_neg\n-/\n\n/- warning: part.mem_bind -> Part.mem_bind is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : Part.{u1} α} {g : α -> (Part.{u2} β)} {a : α} {b : β}, (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a f) -> (Membership.Mem.{u2, u2} β (Part.{u2} β) (Part.hasMem.{u2} β) b (g a)) -> (Membership.Mem.{u2, u2} β (Part.{u2} β) (Part.hasMem.{u2} β) b (Part.bind.{u1, u2} α β f g))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {f : Part.{u2} α} {g : α -> (Part.{u1} β)} {a : α} {b : β}, (Membership.mem.{u2, u2} α (Part.{u2} α) (Part.instMembershipPart.{u2} α) a f) -> (Membership.mem.{u1, u1} β (Part.{u1} β) (Part.instMembershipPart.{u1} β) b (g a)) -> (Membership.mem.{u1, u1} β (Part.{u1} β) (Part.instMembershipPart.{u1} β) b (Part.bind.{u2, u1} α β f g))\nCase conversion may be inaccurate. Consider using '#align part.mem_bind Part.mem_bindₓ'. -/\ntheorem mem_bind {f : Part α} {g : α → Part β} : ∀ {a b}, a ∈ f → b ∈ g a → b ∈ f.bind g\n  | _, _, ⟨h, rfl⟩, ⟨h₂, rfl⟩ => ⟨⟨h, h₂⟩, rfl⟩\n#align part.mem_bind Part.mem_bind\n\n/- warning: part.mem_bind_iff -> Part.mem_bind_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : Part.{u1} α} {g : α -> (Part.{u2} β)} {b : β}, Iff (Membership.Mem.{u2, u2} β (Part.{u2} β) (Part.hasMem.{u2} β) b (Part.bind.{u1, u2} α β f g)) (Exists.{succ u1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a f) (fun (H : Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a f) => Membership.Mem.{u2, u2} β (Part.{u2} β) (Part.hasMem.{u2} β) b (g a))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {f : Part.{u2} α} {g : α -> (Part.{u1} β)} {b : β}, Iff (Membership.mem.{u1, u1} β (Part.{u1} β) (Part.instMembershipPart.{u1} β) b (Part.bind.{u2, u1} α β f g)) (Exists.{succ u2} α (fun (a : α) => And (Membership.mem.{u2, u2} α (Part.{u2} α) (Part.instMembershipPart.{u2} α) a f) (Membership.mem.{u1, u1} β (Part.{u1} β) (Part.instMembershipPart.{u1} β) b (g a))))\nCase conversion may be inaccurate. Consider using '#align part.mem_bind_iff Part.mem_bind_iffₓ'. -/\n@[simp]\ntheorem mem_bind_iff {f : Part α} {g : α → Part β} {b} : b ∈ f.bind g ↔ ∃ a ∈ f, b ∈ g a :=\n  ⟨match b with\n    | _, ⟨⟨h₁, h₂⟩, rfl⟩ => ⟨_, ⟨_, rfl⟩, ⟨_, rfl⟩⟩,\n    fun ⟨a, h₁, h₂⟩ => mem_bind h₁ h₂⟩\n#align part.mem_bind_iff Part.mem_bind_iff\n\n/- warning: part.dom.bind -> Part.Dom.bind is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {o : Part.{u1} α} (h : Part.Dom.{u1} α o) (f : α -> (Part.{u2} β)), Eq.{succ u2} (Part.{u2} β) (Part.bind.{u1, u2} α β o f) (f (Part.get.{u1} α o h))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {o : Part.{u2} α} (h : Part.Dom.{u2} α o) (f : α -> (Part.{u1} β)), Eq.{succ u1} (Part.{u1} β) (Part.bind.{u2, u1} α β o f) (f (Part.get.{u2} α o h))\nCase conversion may be inaccurate. Consider using '#align part.dom.bind Part.Dom.bindₓ'. -/\nprotected theorem Dom.bind {o : Part α} (h : o.Dom) (f : α → Part β) : o.bind f = f (o.get h) :=\n  by\n  ext b\n  simp only [Part.mem_bind_iff, exists_prop]\n  refine' ⟨_, fun hb => ⟨o.get h, Part.get_mem _, hb⟩⟩\n  rintro ⟨a, ha, hb⟩\n  rwa [Part.get_eq_of_mem ha]\n#align part.dom.bind Part.Dom.bind\n\n#print Part.Dom.of_bind /-\ntheorem Dom.of_bind {f : α → Part β} {a : Part α} (h : (a.bind f).Dom) : a.Dom :=\n  h.some\n#align part.dom.of_bind Part.Dom.of_bind\n-/\n\n#print Part.bind_none /-\n@[simp]\ntheorem bind_none (f : α → Part β) : none.bind f = none :=\n  eq_none_iff.2 fun a => by simp\n#align part.bind_none Part.bind_none\n-/\n\n#print Part.bind_some /-\n@[simp]\ntheorem bind_some (a : α) (f : α → Part β) : (some a).bind f = f a :=\n  ext <| by simp\n#align part.bind_some Part.bind_some\n-/\n\n/- warning: part.bind_of_mem -> Part.bind_of_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {o : Part.{u1} α} {a : α}, (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a o) -> (forall (f : α -> (Part.{u2} β)), Eq.{succ u2} (Part.{u2} β) (Part.bind.{u1, u2} α β o f) (f a))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {o : Part.{u2} α} {a : α}, (Membership.mem.{u2, u2} α (Part.{u2} α) (Part.instMembershipPart.{u2} α) a o) -> (forall (f : α -> (Part.{u1} β)), Eq.{succ u1} (Part.{u1} β) (Part.bind.{u2, u1} α β o f) (f a))\nCase conversion may be inaccurate. Consider using '#align part.bind_of_mem Part.bind_of_memₓ'. -/\ntheorem bind_of_mem {o : Part α} {a : α} (h : a ∈ o) (f : α → Part β) : o.bind f = f a := by\n  rw [eq_some_iff.2 h, bind_some]\n#align part.bind_of_mem Part.bind_of_mem\n\n/- warning: part.bind_some_eq_map -> Part.bind_some_eq_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (x : Part.{u1} α), Eq.{succ u2} (Part.{u2} β) (Part.bind.{u1, u2} α β x (Function.comp.{succ u1, succ u2, succ u2} α β (Part.{u2} β) (Part.some.{u2} β) f)) (Part.map.{u1, u2} α β f x)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (x : Part.{u2} α), Eq.{succ u1} (Part.{u1} β) (Part.bind.{u2, u1} α β x (Function.comp.{succ u2, succ u1, succ u1} α β (Part.{u1} β) (Part.some.{u1} β) f)) (Part.map.{u2, u1} α β f x)\nCase conversion may be inaccurate. Consider using '#align part.bind_some_eq_map Part.bind_some_eq_mapₓ'. -/\ntheorem bind_some_eq_map (f : α → β) (x : Part α) : x.bind (some ∘ f) = map f x :=\n  ext <| by simp [eq_comm]\n#align part.bind_some_eq_map Part.bind_some_eq_map\n\n#print Part.bind_toOption /-\ntheorem bind_toOption (f : α → Part β) (o : Part α) [Decidable o.Dom] [∀ a, Decidable (f a).Dom]\n    [Decidable (o.bind f).Dom] :\n    (o.bind f).toOption = o.toOption.elim Option.none fun a => (f a).toOption :=\n  by\n  by_cases o.dom\n  · simp_rw [h.to_option, h.bind]\n    rfl\n  · rw [Part.toOption_eq_none_iff.2 h]\n    exact Part.toOption_eq_none_iff.2 fun ho => h ho.of_bind\n#align part.bind_to_option Part.bind_toOption\n-/\n\n/- warning: part.bind_assoc -> Part.bind_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : Part.{u1} α) (g : α -> (Part.{u2} β)) (k : β -> (Part.{u3} γ)), Eq.{succ u3} (Part.{u3} γ) (Part.bind.{u2, u3} β γ (Part.bind.{u1, u2} α β f g) k) (Part.bind.{u1, u3} α γ f (fun (x : α) => Part.bind.{u2, u3} β γ (g x) k))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} (f : Part.{u2} α) (g : α -> (Part.{u1} β)) (k : β -> (Part.{u3} γ)), Eq.{succ u3} (Part.{u3} γ) (Part.bind.{u1, u3} β γ (Part.bind.{u2, u1} α β f g) k) (Part.bind.{u2, u3} α γ f (fun (x : α) => Part.bind.{u1, u3} β γ (g x) k))\nCase conversion may be inaccurate. Consider using '#align part.bind_assoc Part.bind_assocₓ'. -/\ntheorem bind_assoc {γ} (f : Part α) (g : α → Part β) (k : β → Part γ) :\n    (f.bind g).bind k = f.bind fun x => (g x).bind k :=\n  ext fun a => by\n    simp <;>\n      exact\n        ⟨fun ⟨_, ⟨_, h₁, h₂⟩, h₃⟩ => ⟨_, h₁, _, h₂, h₃⟩, fun ⟨_, h₁, _, h₂, h₃⟩ =>\n          ⟨_, ⟨_, h₁, h₂⟩, h₃⟩⟩\n#align part.bind_assoc Part.bind_assoc\n\n/- warning: part.bind_map -> Part.bind_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (f : α -> β) (x : Part.{u1} α) (g : β -> (Part.{u3} γ)), Eq.{succ u3} (Part.{u3} γ) (Part.bind.{u2, u3} β γ (Part.map.{u1, u2} α β f x) g) (Part.bind.{u1, u3} α γ x (fun (y : α) => g (f y)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} (f : α -> β) (x : Part.{u2} α) (g : β -> (Part.{u3} γ)), Eq.{succ u3} (Part.{u3} γ) (Part.bind.{u1, u3} β γ (Part.map.{u2, u1} α β f x) g) (Part.bind.{u2, u3} α γ x (fun (y : α) => g (f y)))\nCase conversion may be inaccurate. Consider using '#align part.bind_map Part.bind_mapₓ'. -/\n@[simp]\ntheorem bind_map {γ} (f : α → β) (x) (g : β → Part γ) :\n    (map f x).bind g = x.bind fun y => g (f y) := by rw [← bind_some_eq_map, bind_assoc] <;> simp\n#align part.bind_map Part.bind_map\n\n#print Part.map_bind /-\n@[simp]\ntheorem map_bind {γ} (f : α → Part β) (x : Part α) (g : β → γ) :\n    map g (x.bind f) = x.bind fun y => map g (f y) := by\n  rw [← bind_some_eq_map, bind_assoc] <;> simp [bind_some_eq_map]\n#align part.map_bind Part.map_bind\n-/\n\n/- warning: part.map_map -> Part.map_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (g : β -> γ) (f : α -> β) (o : Part.{u1} α), Eq.{succ u3} (Part.{u3} γ) (Part.map.{u2, u3} β γ g (Part.map.{u1, u2} α β f o)) (Part.map.{u1, u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ g f) o)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} (g : β -> γ) (f : α -> β) (o : Part.{u3} α), Eq.{succ u2} (Part.{u2} γ) (Part.map.{u1, u2} β γ g (Part.map.{u3, u1} α β f o)) (Part.map.{u3, u2} α γ (Function.comp.{succ u3, succ u1, succ u2} α β γ g f) o)\nCase conversion may be inaccurate. Consider using '#align part.map_map Part.map_mapₓ'. -/\ntheorem map_map (g : β → γ) (f : α → β) (o : Part α) : map g (map f o) = map (g ∘ f) o := by\n  rw [← bind_some_eq_map, bind_map, bind_some_eq_map]\n#align part.map_map Part.map_map\n\ninstance : Monad Part where\n  pure := @some\n  map := @map\n  bind := @Part.bind\n\ninstance : LawfulMonad Part\n    where\n  bind_pure_comp_eq_map := @bind_some_eq_map\n  id_map β f := by cases f <;> rfl\n  pure_bind := @bind_some\n  bind_assoc := @bind_assoc\n\n#print Part.map_id' /-\ntheorem map_id' {f : α → α} (H : ∀ x : α, f x = x) (o) : map f o = o := by\n  rw [show f = id from funext H] <;> exact id_map o\n#align part.map_id' Part.map_id'\n-/\n\n#print Part.bind_some_right /-\n@[simp]\ntheorem bind_some_right (x : Part α) : x.bind some = x := by\n  rw [bind_some_eq_map] <;> simp [map_id']\n#align part.bind_some_right Part.bind_some_right\n-/\n\n/- warning: part.pure_eq_some -> Part.pure_eq_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Part.{u1} α) (Pure.pure.{u1, u1} Part.{u1} (Applicative.toHasPure.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.monad.{u1})) α a) (Part.some.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Part.{u1} α) (Pure.pure.{u1, u1} Part.{u1} (Applicative.toPure.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.instMonadPart.{u1})) α a) (Part.some.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.pure_eq_some Part.pure_eq_someₓ'. -/\n@[simp]\ntheorem pure_eq_some (a : α) : pure a = some a :=\n  rfl\n#align part.pure_eq_some Part.pure_eq_some\n\n/- warning: part.ret_eq_some -> Part.ret_eq_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Part.{u1} α) (return.{u1, u1} Part.{u1} Part.monad.{u1} α a) (Part.some.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} (a : α), Eq.{succ u1} (Part.{u1} α) (Pure.pure.{u1, u1} Part.{u1} (Applicative.toPure.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.instMonadPart.{u1})) α a) (Part.some.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.ret_eq_some Part.ret_eq_someₓ'. -/\n@[simp]\ntheorem ret_eq_some (a : α) : return a = some a :=\n  rfl\n#align part.ret_eq_some Part.ret_eq_some\n\n/- warning: part.map_eq_map -> Part.map_eq_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u1}} (f : α -> β) (o : Part.{u1} α), Eq.{succ u1} (Part.{u1} β) (Functor.map.{u1, u1} (fun {α : Type.{u1}} => Part.{u1} α) (Applicative.toFunctor.{u1, u1} (fun {α : Type.{u1}} => Part.{u1} α) (Monad.toApplicative.{u1, u1} (fun {α : Type.{u1}} => Part.{u1} α) Part.monad.{u1})) α β f o) (Part.map.{u1, u1} α β f o)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u1}} (f : α -> β) (o : Part.{u1} α), Eq.{succ u1} (Part.{u1} β) (Functor.map.{u1, u1} Part.{u1} (Applicative.toFunctor.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.instMonadPart.{u1})) α β f o) (Part.map.{u1, u1} α β f o)\nCase conversion may be inaccurate. Consider using '#align part.map_eq_map Part.map_eq_mapₓ'. -/\n@[simp]\ntheorem map_eq_map {α β} (f : α → β) (o : Part α) : f <$> o = map f o :=\n  rfl\n#align part.map_eq_map Part.map_eq_map\n\n/- warning: part.bind_eq_bind -> Part.bind_eq_bind is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u1}} (f : Part.{u1} α) (g : α -> (Part.{u1} β)), Eq.{succ u1} (Part.{u1} β) (Bind.bind.{u1, u1} Part.{u1} (Monad.toHasBind.{u1, u1} Part.{u1} Part.monad.{u1}) α β f g) (Part.bind.{u1, u1} α β f g)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u1}} (f : Part.{u1} α) (g : α -> (Part.{u1} β)), Eq.{succ u1} (Part.{u1} β) (Bind.bind.{u1, u1} Part.{u1} (Monad.toBind.{u1, u1} Part.{u1} Part.instMonadPart.{u1}) α β f g) (Part.bind.{u1, u1} α β f g)\nCase conversion may be inaccurate. Consider using '#align part.bind_eq_bind Part.bind_eq_bindₓ'. -/\n@[simp]\ntheorem bind_eq_bind {α β} (f : Part α) (g : α → Part β) : f >>= g = f.bind g :=\n  rfl\n#align part.bind_eq_bind Part.bind_eq_bind\n\n/- warning: part.bind_le -> Part.bind_le is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} {α : Type.{u1}} (x : Part.{u1} α) (f : α -> (Part.{u1} β)) (y : Part.{u1} β), Iff (LE.le.{u1} (Part.{u1} β) (Preorder.toLE.{u1} (Part.{u1} β) (PartialOrder.toPreorder.{u1} (Part.{u1} β) (Part.partialOrder.{u1} β))) (Bind.bind.{u1, u1} Part.{u1} (Monad.toHasBind.{u1, u1} Part.{u1} Part.monad.{u1}) α β x f) y) (forall (a : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) a x) -> (LE.le.{u1} (Part.{u1} β) (Preorder.toLE.{u1} (Part.{u1} β) (PartialOrder.toPreorder.{u1} (Part.{u1} β) (Part.partialOrder.{u1} β))) (f a) y))\nbut is expected to have type\n  forall {β : Type.{u1}} {α : Type.{u1}} (x : Part.{u1} α) (f : α -> (Part.{u1} β)) (y : Part.{u1} β), Iff (LE.le.{u1} (Part.{u1} β) (Preorder.toLE.{u1} (Part.{u1} β) (PartialOrder.toPreorder.{u1} (Part.{u1} β) (Part.instPartialOrderPart.{u1} β))) (Bind.bind.{u1, u1} Part.{u1} (Monad.toBind.{u1, u1} Part.{u1} Part.instMonadPart.{u1}) α β x f) y) (forall (a : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) a x) -> (LE.le.{u1} (Part.{u1} β) (Preorder.toLE.{u1} (Part.{u1} β) (PartialOrder.toPreorder.{u1} (Part.{u1} β) (Part.instPartialOrderPart.{u1} β))) (f a) y))\nCase conversion may be inaccurate. Consider using '#align part.bind_le Part.bind_leₓ'. -/\ntheorem bind_le {α} (x : Part α) (f : α → Part β) (y : Part β) :\n    x >>= f ≤ y ↔ ∀ a, a ∈ x → f a ≤ y :=\n  by\n  constructor <;> intro h\n  · intro a h' b\n    replace h := h b\n    simp only [and_imp, exists_prop, bind_eq_bind, mem_bind_iff, exists_imp] at h\n    apply h _ h'\n  · intro b h'\n    simp only [exists_prop, bind_eq_bind, mem_bind_iff] at h'\n    rcases h' with ⟨a, h₀, h₁⟩\n    apply h _ h₀ _ h₁\n#align part.bind_le Part.bind_le\n\ninstance : MonadFail Part :=\n  { Part.monad with fail := fun _ _ => none }\n\n#print Part.restrict /-\n/-- `restrict p o h` replaces the domain of `o` with `p`, and is well defined when\n  `p` implies `o` is defined. -/\ndef restrict (p : Prop) (o : Part α) (H : p → o.Dom) : Part α :=\n  ⟨p, fun h => o.get (H h)⟩\n#align part.restrict Part.restrict\n-/\n\n#print Part.mem_restrict /-\n@[simp]\ntheorem mem_restrict (p : Prop) (o : Part α) (h : p → o.Dom) (a : α) :\n    a ∈ restrict p o h ↔ p ∧ a ∈ o :=\n  by\n  dsimp [restrict, mem_eq]; constructor\n  · rintro ⟨h₀, h₁⟩\n    exact ⟨h₀, ⟨_, h₁⟩⟩\n  rintro ⟨h₀, h₁, h₂⟩; exact ⟨h₀, h₂⟩\n#align part.mem_restrict Part.mem_restrict\n-/\n\n#print Part.unwrap /-\n/-- `unwrap o` gets the value at `o`, ignoring the condition. This function is unsound. -/\nunsafe def unwrap (o : Part α) : α :=\n  o.get undefined\n#align part.unwrap Part.unwrap\n-/\n\n#print Part.assert_defined /-\ntheorem assert_defined {p : Prop} {f : p → Part α} : ∀ h : p, (f h).Dom → (assert p f).Dom :=\n  Exists.intro\n#align part.assert_defined Part.assert_defined\n-/\n\n/- warning: part.bind_defined -> Part.bind_defined is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : Part.{u1} α} {g : α -> (Part.{u2} β)} (h : Part.Dom.{u1} α f), (Part.Dom.{u2} β (g (Part.get.{u1} α f h))) -> (Part.Dom.{u2} β (Part.bind.{u1, u2} α β f g))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {f : Part.{u2} α} {g : α -> (Part.{u1} β)} (h : Part.Dom.{u2} α f), (Part.Dom.{u1} β (g (Part.get.{u2} α f h))) -> (Part.Dom.{u1} β (Part.bind.{u2, u1} α β f g))\nCase conversion may be inaccurate. Consider using '#align part.bind_defined Part.bind_definedₓ'. -/\ntheorem bind_defined {f : Part α} {g : α → Part β} :\n    ∀ h : f.Dom, (g (f.get h)).Dom → (f.bind g).Dom :=\n  assert_defined\n#align part.bind_defined Part.bind_defined\n\n/- warning: part.bind_dom -> Part.bind_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : Part.{u1} α} {g : α -> (Part.{u2} β)}, Iff (Part.Dom.{u2} β (Part.bind.{u1, u2} α β f g)) (Exists.{0} (Part.Dom.{u1} α f) (fun (h : Part.Dom.{u1} α f) => Part.Dom.{u2} β (g (Part.get.{u1} α f h))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {f : Part.{u2} α} {g : α -> (Part.{u1} β)}, Iff (Part.Dom.{u1} β (Part.bind.{u2, u1} α β f g)) (Exists.{0} (Part.Dom.{u2} α f) (fun (h : Part.Dom.{u2} α f) => Part.Dom.{u1} β (g (Part.get.{u2} α f h))))\nCase conversion may be inaccurate. Consider using '#align part.bind_dom Part.bind_domₓ'. -/\n@[simp]\ntheorem bind_dom {f : Part α} {g : α → Part β} : (f.bind g).Dom ↔ ∃ h : f.Dom, (g (f.get h)).Dom :=\n  Iff.rfl\n#align part.bind_dom Part.bind_dom\n\nsection Instances\n\n-- We define several instances for constants and operations on `part α` inherited from `α`.\n@[to_additive]\ninstance [One α] : One (Part α) where one := pure 1\n\n@[to_additive]\ninstance [Mul α] : Mul (Part α) where mul a b := (· * ·) <$> a <*> b\n\n@[to_additive]\ninstance [Inv α] : Inv (Part α) where inv := map Inv.inv\n\n@[to_additive]\ninstance [Div α] : Div (Part α) where div a b := (· / ·) <$> a <*> b\n\ninstance [Mod α] : Mod (Part α) where mod a b := (· % ·) <$> a <*> b\n\ninstance [Append α] : Append (Part α) where append a b := (· ++ ·) <$> a <*> b\n\ninstance [Inter α] : Inter (Part α) where inter a b := (· ∩ ·) <$> a <*> b\n\ninstance [Union α] : Union (Part α) where union a b := (· ∪ ·) <$> a <*> b\n\ninstance [SDiff α] : SDiff (Part α) where sdiff a b := (· \\ ·) <$> a <*> b\n\n/- warning: part.one_mem_one -> Part.one_mem_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α], Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) (OfNat.ofNat.{u1} (Part.{u1} α) 1 (OfNat.mk.{u1} (Part.{u1} α) 1 (One.one.{u1} (Part.{u1} α) (Part.hasOne.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α], Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)) (OfNat.ofNat.{u1} (Part.{u1} α) 1 (One.toOfNat1.{u1} (Part.{u1} α) (Part.instOnePart.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align part.one_mem_one Part.one_mem_oneₓ'. -/\n@[to_additive]\ntheorem one_mem_one [One α] : (1 : α) ∈ (1 : Part α) :=\n  ⟨trivial, rfl⟩\n#align part.one_mem_one Part.one_mem_one\n#align part.zero_mem_zero Part.zero_mem_zero\n\n/- warning: part.mul_mem_mul -> Part.mul_mem_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) ma a) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) mb b) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) ma mb) (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.hasMul.{u1} α _inst_1)) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) ma a) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) mb b) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) ma mb) (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.instMulPart.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.mul_mem_mul Part.mul_mem_mulₓ'. -/\n@[to_additive]\ntheorem mul_mem_mul [Mul α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma * mb ∈ a * b := by tidy\n#align part.mul_mem_mul Part.mul_mem_mul\n#align part.add_mem_add Part.add_mem_add\n\n/- warning: part.left_dom_of_mul_dom -> Part.left_dom_of_mul_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.hasMul.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.instMulPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_mul_dom Part.left_dom_of_mul_domₓ'. -/\n@[to_additive]\ntheorem left_dom_of_mul_dom [Mul α] {a b : Part α} (hab : Dom (a * b)) : a.Dom := by tidy\n#align part.left_dom_of_mul_dom Part.left_dom_of_mul_dom\n#align part.left_dom_of_add_dom Part.left_dom_of_add_dom\n\n/- warning: part.right_dom_of_mul_dom -> Part.right_dom_of_mul_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.hasMul.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.instMulPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_mul_dom Part.right_dom_of_mul_domₓ'. -/\n@[to_additive]\ntheorem right_dom_of_mul_dom [Mul α] {a b : Part α} (hab : Dom (a * b)) : b.Dom := by tidy\n#align part.right_dom_of_mul_dom Part.right_dom_of_mul_dom\n#align part.right_dom_of_add_dom Part.right_dom_of_add_dom\n\n/- warning: part.mul_get_eq -> Part.mul_get_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.hasMul.{u1} α _inst_1)) a b)), Eq.{succ u1} α (Part.get.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.hasMul.{u1} α _inst_1)) a b) hab) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) (Part.get.{u1} α a (Part.left_dom_of_mul_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_mul_dom.{u1} α _inst_1 a b hab)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.instMulPart.{u1} α _inst_1)) a b)), Eq.{succ u1} α (Part.get.{u1} α (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.instMulPart.{u1} α _inst_1)) a b) hab) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) (Part.get.{u1} α a (Part.left_dom_of_mul_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_mul_dom.{u1} α _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.mul_get_eq Part.mul_get_eqₓ'. -/\n@[simp, to_additive]\ntheorem mul_get_eq [Mul α] (a b : Part α) (hab : Dom (a * b)) :\n    (a * b).get hab = a.get (left_dom_of_mul_dom hab) * b.get (right_dom_of_mul_dom hab) := by tidy\n#align part.mul_get_eq Part.mul_get_eq\n#align part.add_get_eq Part.add_get_eq\n\n/- warning: part.some_mul_some -> Part.some_mul_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.hasMul.{u1} α _inst_1)) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mul.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (HMul.hMul.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMul.{u1} (Part.{u1} α) (Part.instMulPart.{u1} α _inst_1)) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_mul_some Part.some_mul_someₓ'. -/\n@[to_additive]\ntheorem some_mul_some [Mul α] (a b : α) : some a * some b = some (a * b) := by tidy\n#align part.some_mul_some Part.some_mul_some\n#align part.some_add_some Part.some_add_some\n\n#print Part.inv_mem_inv /-\n@[to_additive]\ntheorem inv_mem_inv [Inv α] (a : Part α) (ma : α) (ha : ma ∈ a) : ma⁻¹ ∈ a⁻¹ := by tidy\n#align part.inv_mem_inv Part.inv_mem_inv\n#align part.neg_mem_neg Part.neg_mem_neg\n-/\n\n#print Part.inv_some /-\n@[to_additive]\ntheorem inv_some [Inv α] (a : α) : (some a)⁻¹ = some a⁻¹ :=\n  rfl\n#align part.inv_some Part.inv_some\n#align part.neg_some Part.neg_some\n-/\n\n/- warning: part.div_mem_div -> Part.div_mem_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) ma a) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) mb b) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α _inst_1) ma mb) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.hasDiv.{u1} α _inst_1)) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) ma a) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) mb b) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α _inst_1) ma mb) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.instDivPart.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.div_mem_div Part.div_mem_divₓ'. -/\n@[to_additive]\ntheorem div_mem_div [Div α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma / mb ∈ a / b := by tidy\n#align part.div_mem_div Part.div_mem_div\n#align part.sub_mem_sub Part.sub_mem_sub\n\n/- warning: part.left_dom_of_div_dom -> Part.left_dom_of_div_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.hasDiv.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.instDivPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_div_dom Part.left_dom_of_div_domₓ'. -/\n@[to_additive]\ntheorem left_dom_of_div_dom [Div α] {a b : Part α} (hab : Dom (a / b)) : a.Dom := by tidy\n#align part.left_dom_of_div_dom Part.left_dom_of_div_dom\n#align part.left_dom_of_sub_dom Part.left_dom_of_sub_dom\n\n/- warning: part.right_dom_of_div_dom -> Part.right_dom_of_div_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.hasDiv.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.instDivPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_div_dom Part.right_dom_of_div_domₓ'. -/\n@[to_additive]\ntheorem right_dom_of_div_dom [Div α] {a b : Part α} (hab : Dom (a / b)) : b.Dom := by tidy\n#align part.right_dom_of_div_dom Part.right_dom_of_div_dom\n#align part.right_dom_of_sub_dom Part.right_dom_of_sub_dom\n\n/- warning: part.div_get_eq -> Part.div_get_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.hasDiv.{u1} α _inst_1)) a b)), Eq.{succ u1} α (Part.get.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.hasDiv.{u1} α _inst_1)) a b) hab) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α _inst_1) (Part.get.{u1} α a (Part.left_dom_of_div_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_div_dom.{u1} α _inst_1 a b hab)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.instDivPart.{u1} α _inst_1)) a b)), Eq.{succ u1} α (Part.get.{u1} α (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.instDivPart.{u1} α _inst_1)) a b) hab) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α _inst_1) (Part.get.{u1} α a (Part.left_dom_of_div_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_div_dom.{u1} α _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.div_get_eq Part.div_get_eqₓ'. -/\n@[simp, to_additive]\ntheorem div_get_eq [Div α] (a b : Part α) (hab : Dom (a / b)) :\n    (a / b).get hab = a.get (left_dom_of_div_dom hab) / b.get (right_dom_of_div_dom hab) := by tidy\n#align part.div_get_eq Part.div_get_eq\n#align part.sub_get_eq Part.sub_get_eq\n\n/- warning: part.some_div_some -> Part.some_div_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.hasDiv.{u1} α _inst_1)) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α _inst_1) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Div.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHDiv.{u1} (Part.{u1} α) (Part.instDivPart.{u1} α _inst_1)) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_div_some Part.some_div_someₓ'. -/\n@[to_additive]\ntheorem some_div_some [Div α] (a b : α) : some a / some b = some (a / b) := by tidy\n#align part.some_div_some Part.some_div_some\n#align part.some_sub_some Part.some_sub_some\n\n/- warning: part.mod_mem_mod -> Part.mod_mem_mod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) ma a) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) mb b) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (HMod.hMod.{u1, u1, u1} α α α (instHMod.{u1} α _inst_1) ma mb) (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.hasMod.{u1} α _inst_1)) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) ma a) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) mb b) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (HMod.hMod.{u1, u1, u1} α α α (instHMod.{u1} α _inst_1) ma mb) (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.instModPart.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.mod_mem_mod Part.mod_mem_modₓ'. -/\ntheorem mod_mem_mod [Mod α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma % mb ∈ a % b := by tidy\n#align part.mod_mem_mod Part.mod_mem_mod\n\n/- warning: part.left_dom_of_mod_dom -> Part.left_dom_of_mod_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.hasMod.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.instModPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_mod_dom Part.left_dom_of_mod_domₓ'. -/\ntheorem left_dom_of_mod_dom [Mod α] {a b : Part α} (hab : Dom (a % b)) : a.Dom := by tidy\n#align part.left_dom_of_mod_dom Part.left_dom_of_mod_dom\n\n/- warning: part.right_dom_of_mod_dom -> Part.right_dom_of_mod_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.hasMod.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.instModPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_mod_dom Part.right_dom_of_mod_domₓ'. -/\ntheorem right_dom_of_mod_dom [Mod α] {a b : Part α} (hab : Dom (a % b)) : b.Dom := by tidy\n#align part.right_dom_of_mod_dom Part.right_dom_of_mod_dom\n\n/- warning: part.mod_get_eq -> Part.mod_get_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.hasMod.{u1} α _inst_1)) a b)), Eq.{succ u1} α (Part.get.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.hasMod.{u1} α _inst_1)) a b) hab) (HMod.hMod.{u1, u1, u1} α α α (instHMod.{u1} α _inst_1) (Part.get.{u1} α a (Part.left_dom_of_mod_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_mod_dom.{u1} α _inst_1 a b hab)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.instModPart.{u1} α _inst_1)) a b)), Eq.{succ u1} α (Part.get.{u1} α (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.instModPart.{u1} α _inst_1)) a b) hab) (HMod.hMod.{u1, u1, u1} α α α (instHMod.{u1} α _inst_1) (Part.get.{u1} α a (Part.left_dom_of_mod_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_mod_dom.{u1} α _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.mod_get_eq Part.mod_get_eqₓ'. -/\n@[simp]\ntheorem mod_get_eq [Mod α] (a b : Part α) (hab : Dom (a % b)) :\n    (a % b).get hab = a.get (left_dom_of_mod_dom hab) % b.get (right_dom_of_mod_dom hab) := by tidy\n#align part.mod_get_eq Part.mod_get_eq\n\n/- warning: part.some_mod_some -> Part.some_mod_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.hasMod.{u1} α _inst_1)) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (HMod.hMod.{u1, u1, u1} α α α (instHMod.{u1} α _inst_1) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Mod.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (HMod.hMod.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHMod.{u1} (Part.{u1} α) (Part.instModPart.{u1} α _inst_1)) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (HMod.hMod.{u1, u1, u1} α α α (instHMod.{u1} α _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_mod_some Part.some_mod_someₓ'. -/\ntheorem some_mod_some [Mod α] (a b : α) : some a % some b = some (a % b) := by tidy\n#align part.some_mod_some Part.some_mod_some\n\n/- warning: part.append_mem_append -> Part.append_mem_append is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) ma a) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) mb b) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (Append.append.{u1} α _inst_1 ma mb) (Append.append.{u1} (Part.{u1} α) (Part.hasAppend.{u1} α _inst_1) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) ma a) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) mb b) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (HAppend.hAppend.{u1, u1, u1} α α α (instHAppend.{u1} α _inst_1) ma mb) (HAppend.hAppend.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHAppend.{u1} (Part.{u1} α) (Part.instAppendPart.{u1} α _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.append_mem_append Part.append_mem_appendₓ'. -/\ntheorem append_mem_append [Append α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma ++ mb ∈ a ++ b := by tidy\n#align part.append_mem_append Part.append_mem_append\n\n/- warning: part.left_dom_of_append_dom -> Part.left_dom_of_append_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Append.append.{u1} (Part.{u1} α) (Part.hasAppend.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HAppend.hAppend.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHAppend.{u1} (Part.{u1} α) (Part.instAppendPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_append_dom Part.left_dom_of_append_domₓ'. -/\ntheorem left_dom_of_append_dom [Append α] {a b : Part α} (hab : Dom (a ++ b)) : a.Dom := by tidy\n#align part.left_dom_of_append_dom Part.left_dom_of_append_dom\n\n/- warning: part.right_dom_of_append_dom -> Part.right_dom_of_append_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Append.append.{u1} (Part.{u1} α) (Part.hasAppend.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (HAppend.hAppend.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHAppend.{u1} (Part.{u1} α) (Part.instAppendPart.{u1} α _inst_1)) a b)) -> (Part.Dom.{u1} α b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_append_dom Part.right_dom_of_append_domₓ'. -/\ntheorem right_dom_of_append_dom [Append α] {a b : Part α} (hab : Dom (a ++ b)) : b.Dom := by tidy\n#align part.right_dom_of_append_dom Part.right_dom_of_append_dom\n\n/- warning: part.append_get_eq -> Part.append_get_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (Append.append.{u1} (Part.{u1} α) (Part.hasAppend.{u1} α _inst_1) a b)), Eq.{succ u1} α (Part.get.{u1} α (Append.append.{u1} (Part.{u1} α) (Part.hasAppend.{u1} α _inst_1) a b) hab) (Append.append.{u1} α _inst_1 (Part.get.{u1} α a (Part.left_dom_of_append_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_append_dom.{u1} α _inst_1 a b hab)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (HAppend.hAppend.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHAppend.{u1} (Part.{u1} α) (Part.instAppendPart.{u1} α _inst_1)) a b)), Eq.{succ u1} α (Part.get.{u1} α (HAppend.hAppend.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHAppend.{u1} (Part.{u1} α) (Part.instAppendPart.{u1} α _inst_1)) a b) hab) (HAppend.hAppend.{u1, u1, u1} α α α (instHAppend.{u1} α _inst_1) (Part.get.{u1} α a (Part.left_dom_of_append_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_append_dom.{u1} α _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.append_get_eq Part.append_get_eqₓ'. -/\n@[simp]\ntheorem append_get_eq [Append α] (a b : Part α) (hab : Dom (a ++ b)) :\n    (a ++ b).get hab = a.get (left_dom_of_append_dom hab) ++ b.get (right_dom_of_append_dom hab) :=\n  by tidy\n#align part.append_get_eq Part.append_get_eq\n\n/- warning: part.some_append_some -> Part.some_append_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (Append.append.{u1} (Part.{u1} α) (Part.hasAppend.{u1} α _inst_1) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (Append.append.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Append.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (HAppend.hAppend.{u1, u1, u1} (Part.{u1} α) (Part.{u1} α) (Part.{u1} α) (instHAppend.{u1} (Part.{u1} α) (Part.instAppendPart.{u1} α _inst_1)) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (HAppend.hAppend.{u1, u1, u1} α α α (instHAppend.{u1} α _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_append_some Part.some_append_someₓ'. -/\ntheorem some_append_some [Append α] (a b : α) : some a ++ some b = some (a ++ b) := by tidy\n#align part.some_append_some Part.some_append_some\n\n/- warning: part.inter_mem_inter -> Part.inter_mem_inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) ma a) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) mb b) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (Inter.inter.{u1} α _inst_1 ma mb) (Inter.inter.{u1} (Part.{u1} α) (Part.hasInter.{u1} α _inst_1) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) ma a) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) mb b) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (Inter.inter.{u1} α _inst_1 ma mb) (Inter.inter.{u1} (Part.{u1} α) (Part.instInterPart.{u1} α _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.inter_mem_inter Part.inter_mem_interₓ'. -/\ntheorem inter_mem_inter [Inter α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma ∩ mb ∈ a ∩ b := by tidy\n#align part.inter_mem_inter Part.inter_mem_inter\n\n/- warning: part.left_dom_of_inter_dom -> Part.left_dom_of_inter_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.hasInter.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.instInterPart.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_inter_dom Part.left_dom_of_inter_domₓ'. -/\ntheorem left_dom_of_inter_dom [Inter α] {a b : Part α} (hab : Dom (a ∩ b)) : a.Dom := by tidy\n#align part.left_dom_of_inter_dom Part.left_dom_of_inter_dom\n\n/- warning: part.right_dom_of_inter_dom -> Part.right_dom_of_inter_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.hasInter.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.instInterPart.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_inter_dom Part.right_dom_of_inter_domₓ'. -/\ntheorem right_dom_of_inter_dom [Inter α] {a b : Part α} (hab : Dom (a ∩ b)) : b.Dom := by tidy\n#align part.right_dom_of_inter_dom Part.right_dom_of_inter_dom\n\n/- warning: part.inter_get_eq -> Part.inter_get_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.hasInter.{u1} α _inst_1) a b)), Eq.{succ u1} α (Part.get.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.hasInter.{u1} α _inst_1) a b) hab) (Inter.inter.{u1} α _inst_1 (Part.get.{u1} α a (Part.left_dom_of_inter_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_inter_dom.{u1} α _inst_1 a b hab)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.instInterPart.{u1} α _inst_1) a b)), Eq.{succ u1} α (Part.get.{u1} α (Inter.inter.{u1} (Part.{u1} α) (Part.instInterPart.{u1} α _inst_1) a b) hab) (Inter.inter.{u1} α _inst_1 (Part.get.{u1} α a (Part.left_dom_of_inter_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_inter_dom.{u1} α _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.inter_get_eq Part.inter_get_eqₓ'. -/\n@[simp]\ntheorem inter_get_eq [Inter α] (a b : Part α) (hab : Dom (a ∩ b)) :\n    (a ∩ b).get hab = a.get (left_dom_of_inter_dom hab) ∩ b.get (right_dom_of_inter_dom hab) := by\n  tidy\n#align part.inter_get_eq Part.inter_get_eq\n\n/- warning: part.some_inter_some -> Part.some_inter_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (Inter.inter.{u1} (Part.{u1} α) (Part.hasInter.{u1} α _inst_1) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (Inter.inter.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Inter.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (Inter.inter.{u1} (Part.{u1} α) (Part.instInterPart.{u1} α _inst_1) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (Inter.inter.{u1} α _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align part.some_inter_some Part.some_inter_someₓ'. -/\ntheorem some_inter_some [Inter α] (a b : α) : some a ∩ some b = some (a ∩ b) := by tidy\n#align part.some_inter_some Part.some_inter_some\n\n/- warning: part.union_mem_union -> Part.union_mem_union is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) ma a) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) mb b) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (Union.union.{u1} α _inst_1 ma mb) (Union.union.{u1} (Part.{u1} α) (Part.hasUnion.{u1} α _inst_1) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) ma a) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) mb b) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (Union.union.{u1} α _inst_1 ma mb) (Union.union.{u1} (Part.{u1} α) (Part.instUnionPart.{u1} α _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.union_mem_union Part.union_mem_unionₓ'. -/\ntheorem union_mem_union [Union α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma ∪ mb ∈ a ∪ b := by tidy\n#align part.union_mem_union Part.union_mem_union\n\n/- warning: part.left_dom_of_union_dom -> Part.left_dom_of_union_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.hasUnion.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.instUnionPart.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_union_dom Part.left_dom_of_union_domₓ'. -/\ntheorem left_dom_of_union_dom [Union α] {a b : Part α} (hab : Dom (a ∪ b)) : a.Dom := by tidy\n#align part.left_dom_of_union_dom Part.left_dom_of_union_dom\n\n/- warning: part.right_dom_of_union_dom -> Part.right_dom_of_union_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.hasUnion.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.instUnionPart.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_union_dom Part.right_dom_of_union_domₓ'. -/\ntheorem right_dom_of_union_dom [Union α] {a b : Part α} (hab : Dom (a ∪ b)) : b.Dom := by tidy\n#align part.right_dom_of_union_dom Part.right_dom_of_union_dom\n\n/- warning: part.union_get_eq -> Part.union_get_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.hasUnion.{u1} α _inst_1) a b)), Eq.{succ u1} α (Part.get.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.hasUnion.{u1} α _inst_1) a b) hab) (Union.union.{u1} α _inst_1 (Part.get.{u1} α a (Part.left_dom_of_union_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_union_dom.{u1} α _inst_1 a b hab)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.instUnionPart.{u1} α _inst_1) a b)), Eq.{succ u1} α (Part.get.{u1} α (Union.union.{u1} (Part.{u1} α) (Part.instUnionPart.{u1} α _inst_1) a b) hab) (Union.union.{u1} α _inst_1 (Part.get.{u1} α a (Part.left_dom_of_union_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_union_dom.{u1} α _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.union_get_eq Part.union_get_eqₓ'. -/\n@[simp]\ntheorem union_get_eq [Union α] (a b : Part α) (hab : Dom (a ∪ b)) :\n    (a ∪ b).get hab = a.get (left_dom_of_union_dom hab) ∪ b.get (right_dom_of_union_dom hab) := by\n  tidy\n#align part.union_get_eq Part.union_get_eq\n\n/- warning: part.some_union_some -> Part.some_union_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (Union.union.{u1} (Part.{u1} α) (Part.hasUnion.{u1} α _inst_1) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (Union.union.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Union.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (Union.union.{u1} (Part.{u1} α) (Part.instUnionPart.{u1} α _inst_1) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (Union.union.{u1} α _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align part.some_union_some Part.some_union_someₓ'. -/\ntheorem some_union_some [Union α] (a b : α) : some a ∪ some b = some (a ∪ b) := by tidy\n#align part.some_union_some Part.some_union_some\n\n/- warning: part.sdiff_mem_sdiff -> Part.sdiff_mem_sdiff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) ma a) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) mb b) -> (Membership.Mem.{u1, u1} α (Part.{u1} α) (Part.hasMem.{u1} α) (SDiff.sdiff.{u1} α _inst_1 ma mb) (SDiff.sdiff.{u1} (Part.{u1} α) (Part.hasSdiff.{u1} α _inst_1) a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (ma : α) (mb : α), (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) ma a) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) mb b) -> (Membership.mem.{u1, u1} α (Part.{u1} α) (Part.instMembershipPart.{u1} α) (SDiff.sdiff.{u1} α _inst_1 ma mb) (SDiff.sdiff.{u1} (Part.{u1} α) (Part.instSDiffPart.{u1} α _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.sdiff_mem_sdiff Part.sdiff_mem_sdiffₓ'. -/\ntheorem sdiff_mem_sdiff [SDiff α] (a b : Part α) (ma mb : α) (ha : ma ∈ a) (hb : mb ∈ b) :\n    ma \\ mb ∈ a \\ b := by tidy\n#align part.sdiff_mem_sdiff Part.sdiff_mem_sdiff\n\n/- warning: part.left_dom_of_sdiff_dom -> Part.left_dom_of_sdiff_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.hasSdiff.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.instSDiffPart.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_sdiff_dom Part.left_dom_of_sdiff_domₓ'. -/\ntheorem left_dom_of_sdiff_dom [SDiff α] {a b : Part α} (hab : Dom (a \\ b)) : a.Dom := by tidy\n#align part.left_dom_of_sdiff_dom Part.left_dom_of_sdiff_dom\n\n/- warning: part.right_dom_of_sdiff_dom -> Part.right_dom_of_sdiff_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.hasSdiff.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α b)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] {a : Part.{u1} α} {b : Part.{u1} α}, (Part.Dom.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.instSDiffPart.{u1} α _inst_1) a b)) -> (Part.Dom.{u1} α b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_sdiff_dom Part.right_dom_of_sdiff_domₓ'. -/\ntheorem right_dom_of_sdiff_dom [SDiff α] {a b : Part α} (hab : Dom (a \\ b)) : b.Dom := by tidy\n#align part.right_dom_of_sdiff_dom Part.right_dom_of_sdiff_dom\n\n/- warning: part.sdiff_get_eq -> Part.sdiff_get_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.hasSdiff.{u1} α _inst_1) a b)), Eq.{succ u1} α (Part.get.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.hasSdiff.{u1} α _inst_1) a b) hab) (SDiff.sdiff.{u1} α _inst_1 (Part.get.{u1} α a (Part.left_dom_of_sdiff_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_sdiff_dom.{u1} α _inst_1 a b hab)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] (a : Part.{u1} α) (b : Part.{u1} α) (hab : Part.Dom.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.instSDiffPart.{u1} α _inst_1) a b)), Eq.{succ u1} α (Part.get.{u1} α (SDiff.sdiff.{u1} (Part.{u1} α) (Part.instSDiffPart.{u1} α _inst_1) a b) hab) (SDiff.sdiff.{u1} α _inst_1 (Part.get.{u1} α a (Part.left_dom_of_sdiff_dom.{u1} α _inst_1 a b hab)) (Part.get.{u1} α b (Part.right_dom_of_sdiff_dom.{u1} α _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.sdiff_get_eq Part.sdiff_get_eqₓ'. -/\n@[simp]\ntheorem sdiff_get_eq [SDiff α] (a b : Part α) (hab : Dom (a \\ b)) :\n    (a \\ b).get hab = a.get (left_dom_of_sdiff_dom hab) \\ b.get (right_dom_of_sdiff_dom hab) := by\n  tidy\n#align part.sdiff_get_eq Part.sdiff_get_eq\n\n/- warning: part.some_sdiff_some -> Part.some_sdiff_some is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (SDiff.sdiff.{u1} (Part.{u1} α) (Part.hasSdiff.{u1} α _inst_1) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (SDiff.sdiff.{u1} α _inst_1 a b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : SDiff.{u1} α] (a : α) (b : α), Eq.{succ u1} (Part.{u1} α) (SDiff.sdiff.{u1} (Part.{u1} α) (Part.instSDiffPart.{u1} α _inst_1) (Part.some.{u1} α a) (Part.some.{u1} α b)) (Part.some.{u1} α (SDiff.sdiff.{u1} α _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align part.some_sdiff_some Part.some_sdiff_someₓ'. -/\ntheorem some_sdiff_some [SDiff α] (a b : α) : some a \\ some b = some (a \\ b) := by tidy\n#align part.some_sdiff_some Part.some_sdiff_some\n\nend Instances\n\nend Part\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Part.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105720171531, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.46963682321207956}}
{"text": "/-\nCopyright (c) 2022 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Aaron Anderson\n-/\nimport model_theory.substructures\n\n/-!\n# Finitely Generated First-Order Structures\nThis file defines what it means for a first-order (sub)structure to be finitely or countably\ngenerated, similarly to other finitely-generated objects in the algebra library.\n\n## Main Definitions\n* `first_order.language.substructure.fg` indicates that a substructure is finitely generated.\n* `first_order.language.Structure.fg` indicates that a structure is finitely generated.\n* `first_order.language.substructure.cg` indicates that a substructure is countably generated.\n* `first_order.language.Structure.cg` indicates that a structure is countably generated.\n\n\n## TODO\nDevelop a more unified definition of finite generation using the theory of closure operators, or use\nthis definition of finite generation to define the others.\n\n-/\n\nopen_locale first_order\nopen set\n\nnamespace first_order\nnamespace language\nopen Structure\n\nvariables {L : language} {M : Type*} [L.Structure M]\n\nnamespace substructure\n\n/-- A substructure of `M` is finitely generated if it is the closure of a finite subset of `M`. -/\ndef fg (N : L.substructure M) : Prop := ∃ S : finset M, closure L ↑S = N\n\ntheorem fg_def {N : L.substructure M} :\n  N.fg ↔ ∃ S : set M, S.finite ∧ closure L S = N :=\n⟨λ ⟨t, h⟩, ⟨_, finset.finite_to_set t, h⟩, begin\n  rintro ⟨t', h, rfl⟩,\n  rcases finite.exists_finset_coe h with ⟨t, rfl⟩,\n  exact ⟨t, rfl⟩\nend⟩\n\nlemma fg_iff_exists_fin_generating_family {N : L.substructure M} :\n  N.fg ↔ ∃ (n : ℕ) (s : fin n → M), closure L (range s) = N :=\nbegin\n  rw fg_def,\n  split,\n  { rintros ⟨S, Sfin, hS⟩,\n    obtain ⟨n, f, rfl⟩ := Sfin.fin_embedding,\n    exact ⟨n, f, hS⟩, },\n  { rintros ⟨n, s, hs⟩,\n    refine ⟨range s, finite_range s, hs⟩ },\nend\n\ntheorem fg_bot : (⊥ : L.substructure M).fg :=\n⟨∅, by rw [finset.coe_empty, closure_empty]⟩\n\ntheorem fg_closure {s : set M} (hs : finite s) : fg (closure L s) :=\n⟨hs.to_finset, by rw [hs.coe_to_finset]⟩\n\ntheorem fg_closure_singleton (x : M) : fg (closure L ({x} : set M)) :=\nfg_closure (finite_singleton x)\n\ntheorem fg.sup {N₁ N₂ : L.substructure M}\n  (hN₁ : N₁.fg) (hN₂ : N₂.fg) : (N₁ ⊔ N₂).fg :=\nlet ⟨t₁, ht₁⟩ := fg_def.1 hN₁, ⟨t₂, ht₂⟩ := fg_def.1 hN₂ in\nfg_def.2 ⟨t₁ ∪ t₂, ht₁.1.union ht₂.1, by rw [closure_union, ht₁.2, ht₂.2]⟩\n\ntheorem fg.map {N : Type*} [L.Structure N] (f : M →[L] N) {s : L.substructure M} (hs : s.fg) :\n  (s.map f).fg :=\nlet ⟨t, ht⟩ := fg_def.1 hs in fg_def.2 ⟨f '' t, ht.1.image _, by rw [closure_image, ht.2]⟩\n\ntheorem fg.of_map_embedding {N : Type*} [L.Structure N] (f : M ↪[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).fg) : s.fg :=\nbegin\n  rcases hs with ⟨t, h⟩,\n  rw fg_def,\n  refine ⟨f ⁻¹' t, t.finite_to_set.preimage (f.injective.inj_on _), _⟩,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [← h, map_closure, embedding.coe_to_hom, image_preimage_eq_of_subset],\n  intros x hx,\n  have h' := subset_closure hx,\n  rw h at h',\n  exact hom.map_le_range h'\nend\n\n/-- A substructure of `M` is countably generated if it is the closure of a countable subset of `M`.\n-/\ndef cg (N : L.substructure M) : Prop := ∃ S : set M, S.countable ∧ closure L S = N\n\n\n\ntheorem fg.cg {N : L.substructure M} (h : N.fg) : N.cg :=\nbegin\n  obtain ⟨s, hf, rfl⟩ := fg_def.1 h,\n  refine ⟨s, hf.countable, rfl⟩,\nend\n\nlemma cg_iff_empty_or_exists_nat_generating_family {N : L.substructure M} :\n  N.cg ↔ (↑N = (∅ : set M)) ∨ ∃ (s : ℕ → M), closure L (range s) = N :=\nbegin\n  rw cg_def,\n  split,\n  { rintros ⟨S, Scount, hS⟩,\n    cases eq_empty_or_nonempty ↑N with h h,\n    { exact or.intro_left _ h },\n    obtain ⟨f, h'⟩ := (Scount.union (set.countable_singleton h.some)).exists_surjective\n      (singleton_nonempty h.some).inr,\n    refine or.intro_right _ ⟨f, _⟩,\n    rw [← h', closure_union, hS, sup_eq_left, closure_le],\n    exact singleton_subset_iff.2 h.some_mem },\n  { intro h,\n    cases h with h h,\n    { refine ⟨∅, countable_empty, closure_eq_of_le (empty_subset _) _⟩,\n      rw [← set_like.coe_subset_coe, h],\n      exact empty_subset _ },\n    { obtain ⟨f, rfl⟩ := h,\n      exact ⟨range f, countable_range _, rfl⟩ } },\nend\n\ntheorem cg_bot : (⊥ : L.substructure M).cg := fg_bot.cg\n\ntheorem cg_closure {s : set M} (hs : s.countable) : cg (closure L s) :=\n⟨s, hs, rfl⟩\n\ntheorem cg_closure_singleton (x : M) : cg (closure L ({x} : set M)) := (fg_closure_singleton x).cg\n\ntheorem cg.sup {N₁ N₂ : L.substructure M}\n  (hN₁ : N₁.cg) (hN₂ : N₂.cg) : (N₁ ⊔ N₂).cg :=\nlet ⟨t₁, ht₁⟩ := cg_def.1 hN₁, ⟨t₂, ht₂⟩ := cg_def.1 hN₂ in\ncg_def.2 ⟨t₁ ∪ t₂, ht₁.1.union ht₂.1, by rw [closure_union, ht₁.2, ht₂.2]⟩\n\ntheorem cg.map {N : Type*} [L.Structure N] (f : M →[L] N) {s : L.substructure M} (hs : s.cg) :\n  (s.map f).cg :=\nlet ⟨t, ht⟩ := cg_def.1 hs in cg_def.2 ⟨f '' t, ht.1.image _, by rw [closure_image, ht.2]⟩\n\ntheorem cg.of_map_embedding {N : Type*} [L.Structure N] (f : M ↪[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).cg) : s.cg :=\nbegin\n  rcases hs with ⟨t, h1, h2⟩,\n  rw cg_def,\n  refine ⟨f ⁻¹' t, h1.preimage f.injective, _⟩,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [← h2, map_closure, embedding.coe_to_hom, image_preimage_eq_of_subset],\n  intros x hx,\n  have h' := subset_closure hx,\n  rw h2 at h',\n  exact hom.map_le_range h'\nend\n\ntheorem cg_iff_countable [L.countable_functions] {s : L.substructure M} :\n  s.cg ↔ nonempty (encodable s) :=\nbegin\n  refine ⟨_, λ h, ⟨s, h, s.closure_eq⟩⟩,\n  rintro ⟨s, h, rfl⟩,\n  exact h.substructure_closure L\nend\n\nend substructure\n\nopen substructure\n\nnamespace Structure\n\nvariables (L) (M)\n\n/-- A structure is finitely generated if it is the closure of a finite subset. -/\nclass fg : Prop := (out : (⊤ : L.substructure M).fg)\n\n/-- A structure is countably generated if it is the closure of a countable subset. -/\nclass cg : Prop := (out : (⊤ : L.substructure M).cg)\n\nvariables {L M}\n\nlemma fg_def : fg L M ↔ (⊤ : L.substructure M).fg := ⟨λ h, h.1, λ h, ⟨h⟩⟩\n\n/-- An equivalent expression of `Structure.fg` in terms of `set.finite` instead of `finset`. -/\nlemma fg_iff : fg L M ↔ ∃ S : set M, S.finite ∧ closure L S = (⊤ : L.substructure M) :=\nby rw [fg_def, substructure.fg_def]\n\nlemma fg.range {N : Type*} [L.Structure N] (h : fg L M) (f : M →[L] N) :\n  f.range.fg :=\nbegin\n  rw [hom.range_eq_map],\n  exact (fg_def.1 h).map f,\nend\n\nlemma fg.map_of_surjective {N : Type*} [L.Structure N] (h : fg L M) (f : M →[L] N)\n  (hs : function.surjective f) :\n  fg L N :=\nbegin\n  rw ← hom.range_eq_top at hs,\n  rw [fg_def, ← hs],\n  exact h.range f,\nend\n\n\n\n/-- An equivalent expression of `Structure.cg`. -/\nlemma cg_iff : cg L M ↔ ∃ S : set M, S.countable ∧ closure L S = (⊤ : L.substructure M) :=\nby rw [cg_def, substructure.cg_def]\n\nlemma cg.range {N : Type*} [L.Structure N] (h : cg L M) (f : M →[L] N) :\n  f.range.cg :=\nbegin\n  rw [hom.range_eq_map],\n  exact (cg_def.1 h).map f,\nend\n\nlemma cg.map_of_surjective {N : Type*} [L.Structure N] (h : cg L M) (f : M →[L] N)\n  (hs : function.surjective f) :\n  cg L N :=\nbegin\n  rw ← hom.range_eq_top at hs,\n  rw [cg_def, ← hs],\n  exact h.range f,\nend\n\nlemma cg_iff_countable [L.countable_functions] :\n  cg L M ↔ nonempty (encodable M) :=\nby rw [cg_def, cg_iff_countable, cardinal.encodable_iff, cardinal.encodable_iff,\n  top_equiv.to_equiv.cardinal_eq]\n\nlemma fg.cg (h : fg L M) : cg L M :=\ncg_def.2 (fg_def.1 h).cg\n\n@[priority 100] instance cg_of_fg [h : fg L M] : cg L M := h.cg\n\nend Structure\n\nlemma equiv.fg_iff {N : Type*} [L.Structure N] (f : M ≃[L] N) :\n  Structure.fg L M ↔ Structure.fg L N :=\n⟨λ h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  λ h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective⟩\n\nlemma substructure.fg_iff_Structure_fg (S : L.substructure M) :\n  S.fg ↔ Structure.fg L S :=\nbegin\n  rw Structure.fg_def,\n  refine ⟨λ h, fg.of_map_embedding S.subtype _, λ h, _⟩,\n  { rw [← hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [← hom.range_eq_map, range_subtype] at h,\n    exact h }\nend\n\nlemma equiv.cg_iff {N : Type*} [L.Structure N] (f : M ≃[L] N) :\n  Structure.cg L M ↔ Structure.cg L N :=\n⟨λ h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  λ h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective⟩\n\nlemma substructure.cg_iff_Structure_cg (S : L.substructure M) :\n  S.cg ↔ Structure.cg L S :=\nbegin\n  rw Structure.cg_def,\n  refine ⟨λ h, cg.of_map_embedding S.subtype _, λ h, _⟩,\n  { rw [← hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [← hom.range_eq_map, range_subtype] at h,\n    exact h }\nend\n\nend language\nend first_order\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/model_theory/finitely_generated.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4696368097281613}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nInfinite sum over a topological monoid\n\nThis sum is known as unconditionally convergent, as it sums to the same value under all possible\npermutations. For Euclidean spaces (finite dimensional Banach spaces) this is equivalent to absolute\nconvergence.\n\nNote: There are summable sequences which are not unconditionally convergent! The other way holds\ngenerally, see `tendsto_sum_nat_of_is_sum`.\n\nReference:\n* Bourbaki: General Topology (1995), Chapter 3 §5 (Infinite sums in commutative groups)\n\n-/\nimport logic.function algebra.big_operators data.set data.finset\n       topology.metric_space.basic topology.algebra.uniform_group topology.algebra.ring\n       topology.algebra.ordered topology.instances.real\n\nnoncomputable theory\nopen lattice finset filter function classical\nlocal attribute [instance] prop_decidable\n\ndef option.cases_on' {α β} : option α → β → (α → β) → β\n| none     n s := n\n| (some a) n s := s a\n\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\nsection is_sum\nvariables [add_comm_monoid α] [topological_space α] [topological_add_monoid α]\n\n/-- Infinite sum on a topological monoid\nThe `at_top` filter on `finset α` is the limit of all finite sets towards the entire type. So we sum\nup bigger and bigger sets. This sum operation is still invariant under reordering, and a absolute\nsum operator.\n\nThis is based on Mario Carneiro's infinite sum in Metamath.\n-/\ndef is_sum (f : β → α) (a : α) : Prop := tendsto (λs:finset β, s.sum f) at_top (nhds a)\n\n/-- `has_sum f` means that `f` has some (infinite) sum. Use `tsum` to get the value. -/\ndef has_sum (f : β → α) : Prop := ∃a, is_sum f a\n\n/-- `tsum f` is the sum of `f` it exists, or 0 otherwise -/\ndef tsum (f : β → α) := if h : has_sum f then classical.some h else 0\n\nnotation `∑` binders `, ` r:(scoped f, tsum f) := r\n\nvariables {f g : β → α} {a b : α} {s : finset β}\n\nlemma is_sum_tsum (ha : has_sum f) : is_sum f (∑b, f b) :=\nby simp [ha, tsum]; exact some_spec ha\n\nlemma has_sum_spec (ha : is_sum f a) : has_sum f := ⟨a, ha⟩\n\nlemma is_sum_zero : is_sum (λb, 0 : β → α) 0 :=\nby simp [is_sum, tendsto_const_nhds]\n\nlemma has_sum_zero : has_sum (λb, 0 : β → α) := has_sum_spec is_sum_zero\n\nlemma is_sum_add (hf : is_sum f a) (hg : is_sum g b) : is_sum (λb, f b + g b) (a + b) :=\nby simp [is_sum, sum_add_distrib]; exact tendsto_add hf hg\n\nlemma has_sum_add (hf : has_sum f) (hg : has_sum g) : has_sum (λb, f b + g b) :=\nhas_sum_spec $ is_sum_add (is_sum_tsum hf)(is_sum_tsum hg)\n\nlemma is_sum_sum {f : γ → β → α} {a : γ → α} {s : finset γ} :\n  (∀i∈s, is_sum (f i) (a i)) → is_sum (λb, s.sum $ λi, f i b) (s.sum a) :=\nfinset.induction_on s (by simp [is_sum_zero]) (by simp [is_sum_add] {contextual := tt})\n\nlemma has_sum_sum {f : γ → β → α} {s : finset γ} (hf : ∀i∈s, has_sum (f i)) :\n  has_sum (λb, s.sum $ λi, f i b) :=\nhas_sum_spec $ is_sum_sum $ assume i hi, is_sum_tsum $ hf i hi\n\nlemma is_sum_sum_of_ne_finset_zero (hf : ∀b∉s, f b = 0) : is_sum f (s.sum f) :=\ntendsto_infi' s $ tendsto.congr'\n  (assume t (ht : s ⊆ t), show s.sum f = t.sum f, from sum_subset ht $ assume x _, hf _)\n  tendsto_const_nhds\n\nlemma has_sum_sum_of_ne_finset_zero (hf : ∀b∉s, f b = 0) : has_sum f :=\nhas_sum_spec $ is_sum_sum_of_ne_finset_zero hf\n\nlemma is_sum_ite_eq (b : β) (a : α) : is_sum (λb', if b' = b then a else 0) a :=\nsuffices\n  is_sum (λb', if b' = b then a else 0) (({b} : finset β).sum (λb', if b' = b then a else 0)), from\n  by simpa,\nis_sum_sum_of_ne_finset_zero $ assume b' hb,\n  have b' ≠ b, by simpa using hb,\n  by rw [if_neg this]\n\nlemma is_sum_of_iso {j : γ → β} {i : β → γ}\n  (hf : is_sum f a) (h₁ : ∀x, i (j x) = x) (h₂ : ∀x, j (i x) = x) : is_sum (f ∘ j) a :=\nhave ∀x y, j x = j y → x = y,\n  from assume x y h,\n  have i (j x) = i (j y), by rw [h],\n  by rwa [h₁, h₁] at this,\nhave (λs:finset γ, s.sum (f ∘ j)) = (λs:finset β, s.sum f) ∘ (λs:finset γ, s.image j),\n  from funext $ assume s, (sum_image $ assume x _ y _, this x y).symm,\nshow tendsto (λs:finset γ, s.sum (f ∘ j)) at_top (nhds a),\n   by rw [this]; apply (tendsto_finset_image_at_top_at_top h₂).comp hf\n\nlemma is_sum_iff_is_sum_of_iso {j : γ → β} (i : β → γ)\n  (h₁ : ∀x, i (j x) = x) (h₂ : ∀x, j (i x) = x) :\n  is_sum (f ∘ j) a ↔ is_sum f a :=\niff.intro\n  (assume hfj,\n    have is_sum ((f ∘ j) ∘ i) a, from is_sum_of_iso hfj h₂ h₁,\n    by simp [(∘), h₂] at this; assumption)\n  (assume hf, is_sum_of_iso hf h₁ h₂)\n\nlemma is_sum_hom (g : α → γ) [add_comm_monoid γ] [topological_space γ] [topological_add_monoid γ]\n  [is_add_monoid_hom g] (h₃ : continuous g) (hf : is_sum f a) :\n  is_sum (g ∘ f) (g a) :=\nhave (λs:finset β, s.sum (g ∘ f)) = g ∘ (λs:finset β, s.sum f),\n  from funext $ assume s, sum_hom g,\nshow tendsto (λs:finset β, s.sum (g ∘ f)) at_top (nhds (g a)),\n  by rw [this]; exact hf.comp (continuous_iff_continuous_at.mp h₃ a)\n\nlemma tendsto_sum_nat_of_is_sum {f : ℕ → α} (h : is_sum f a) :\n  tendsto (λn:ℕ, (range n).sum f) at_top (nhds a) :=\nsuffices map (λ (n : ℕ), sum (range n) f) at_top ≤ map (λ (s : finset ℕ), sum s f) at_top,\n  from le_trans this h,\nassume s (hs : {t : finset ℕ | t.sum f ∈ s} ∈ at_top),\nlet ⟨t, ht⟩ := mem_at_top_sets.mp hs, ⟨n, hn⟩ := @exists_nat_subset_range t in\nmem_at_top_sets.mpr ⟨n, assume n' hn', ht _ $ finset.subset.trans hn $ range_subset.mpr hn'⟩\n\nlemma is_sum_sigma [regular_space α] {γ : β → Type*} {f : (Σ b:β, γ b) → α} {g : β → α} {a : α}\n  (hf : ∀b, is_sum (λc, f ⟨b, c⟩) (g b)) (ha : is_sum f a) : is_sum g a :=\nassume s' hs',\nlet\n  ⟨s, hs, hss', hsc⟩ := nhds_is_closed hs',\n  ⟨u, hu⟩ := mem_at_top_sets.mp $ ha $ hs,\n  fsts := u.image sigma.fst,\n  snds := λb, u.bind (λp, (if h : p.1 = b then {cast (congr_arg γ h) p.2} else ∅ : finset (γ b)))\nin\nhave u_subset : u ⊆ fsts.sigma snds,\n  from subset_iff.mpr $ assume ⟨b, c⟩ hu,\n  have hb : b ∈ fsts, from finset.mem_image.mpr ⟨_, hu, rfl⟩,\n  have hc : c ∈ snds b, from mem_bind.mpr ⟨_, hu, by simp; refl⟩,\n  by simp [mem_sigma, hb, hc] ,\nmem_at_top_sets.mpr $ exists.intro fsts $ assume bs (hbs : fsts ⊆ bs),\n  have h : ∀cs : Π b ∈ bs, finset (γ b),\n      (⋂b (hb : b ∈ bs), (λp:Πb, finset (γ b), p b) ⁻¹' {cs' | cs b hb ⊆ cs' }) ∩\n      (λp, bs.sum (λb, (p b).sum (λc, f ⟨b, c⟩))) ⁻¹' s ≠ ∅,\n    from assume cs,\n    let cs' := λb, (if h : b ∈ bs then cs b h else ∅) ∪ snds b in\n    have sum_eq : bs.sum (λb, (cs' b).sum (λc, f ⟨b, c⟩)) = (bs.sigma cs').sum f,\n      from sum_sigma.symm,\n    have (bs.sigma cs').sum f ∈ s,\n      from hu _ $ finset.subset.trans u_subset $ sigma_mono hbs $\n        assume b, @finset.subset_union_right (γ b) _ _ _,\n    set.ne_empty_iff_exists_mem.mpr $ exists.intro cs' $\n    by simp [sum_eq, this]; { intros b hb, simp [cs', hb, finset.subset_union_right] },\n  have tendsto (λp:(Πb:β, finset (γ b)), bs.sum (λb, (p b).sum (λc, f ⟨b, c⟩)))\n      (⨅b (h : b ∈ bs), at_top.comap (λp, p b)) (nhds (bs.sum g)),\n    from tendsto_finset_sum bs $\n      assume c hc, tendsto_infi' c $ tendsto_infi' hc $ tendsto_comap.comp (hf c),\n  have bs.sum g ∈ s,\n    from mem_of_closed_of_tendsto' this hsc $ forall_sets_neq_empty_iff_neq_bot.mp $\n      by simp [mem_inf_sets, exists_imp_distrib, and_imp, forall_and_distrib,\n               filter.mem_infi_sets_finset, mem_comap_sets, skolem, mem_at_top_sets,\n               and_comm];\n      from\n        assume s₁ s₂ s₃ hs₁ hs₃ p hs₂ p' hp cs hp',\n        have (⋂b (h : b ∈ bs), (λp:(Πb, finset (γ b)), p b) ⁻¹' {cs' | cs b h ⊆ cs' }) ≤ (⨅b∈bs, p b),\n          from infi_le_infi $ assume b, infi_le_infi $ assume hb,\n            le_trans (set.preimage_mono $ hp' b hb) (hp b hb),\n        neq_bot_of_le_neq_bot (h _) (le_trans (set.inter_subset_inter (le_trans this hs₂) hs₃) hs₁),\n  hss' this\n\nlemma has_sum_sigma [regular_space α] {γ : β → Type*} {f : (Σb:β, γ b) → α}\n  (hf : ∀b, has_sum (λc, f ⟨b, c⟩)) (ha : has_sum f) : has_sum (λb, ∑c, f ⟨b, c⟩):=\nhas_sum_spec $ is_sum_sigma (assume b, is_sum_tsum $ hf b) (is_sum_tsum ha)\n\nend is_sum\n\nsection is_sum_iff_is_sum_of_iso_ne_zero\nvariables [add_comm_monoid α] [topological_space α] [topological_add_monoid α]\nvariables {f : β → α} {g : γ → α} {a : α}\n\nlemma is_sum_of_is_sum\n  (h_eq : ∀u:finset γ, ∃v:finset β, ∀v', v ⊆ v' → ∃u', u ⊆ u' ∧ u'.sum g = v'.sum f)\n  (hf : is_sum g a) : is_sum f a :=\nsuffices at_top.map (λs:finset β, s.sum f) ≤ at_top.map (λs:finset γ, s.sum g),\n  from le_trans this hf,\nby rw [map_at_top_eq, map_at_top_eq];\nfrom (le_infi $ assume b, let ⟨v, hv⟩ := h_eq b in infi_le_of_le v $\n  by simp [set.image_subset_iff]; exact hv)\n\nlemma is_sum_iff_is_sum\n  (h₁ : ∀u:finset γ, ∃v:finset β, ∀v', v ⊆ v' → ∃u', u ⊆ u' ∧ u'.sum g = v'.sum f)\n  (h₂ : ∀v:finset β, ∃u:finset γ, ∀u', u ⊆ u' → ∃v', v ⊆ v' ∧ v'.sum f = u'.sum g) :\n  is_sum f a ↔ is_sum g a :=\n⟨is_sum_of_is_sum h₂, is_sum_of_is_sum h₁⟩\n\nvariables\n  (i : Π⦃c⦄, g c ≠ 0 → β) (hi : ∀⦃c⦄ (h : g c ≠ 0), f (i h) ≠ 0)\n  (j : Π⦃b⦄, f b ≠ 0 → γ) (hj : ∀⦃b⦄ (h : f b ≠ 0), g (j h) ≠ 0)\n  (hji : ∀⦃c⦄ (h : g c ≠ 0), j (hi h) = c)\n  (hij : ∀⦃b⦄ (h : f b ≠ 0), i (hj h) = b)\n  (hgj : ∀⦃b⦄ (h : f b ≠ 0), g (j h) = f b)\ninclude hi hj hji hij hgj\n\nlemma is_sum_of_is_sum_ne_zero : is_sum g a → is_sum f a :=\nhave j_inj : ∀x y (hx : f x ≠ 0) (hy : f y ≠ 0), (j hx = j hy ↔ x = y),\n  from assume x y hx hy,\n  ⟨assume h,\n    have i (hj hx) = i (hj hy), by simp [h],\n    by rwa [hij, hij] at this; assumption,\n  by simp {contextual := tt}⟩,\nlet ii : finset γ → finset β := λu, u.bind $ λc, if h : g c = 0 then ∅ else {i h} in\nlet jj : finset β → finset γ := λv, v.bind $ λb, if h : f b = 0 then ∅ else {j h} in\nis_sum_of_is_sum $ assume u, exists.intro (ii u) $\n  assume v hv, exists.intro (u ∪ jj v) $ and.intro (subset_union_left _ _) $\n  have ∀c:γ, c ∈ u ∪ jj v → c ∉ jj v → g c = 0,\n    from assume c hc hnc, classical.by_contradiction $ assume h : g c ≠ 0,\n    have c ∈ u,\n      from (finset.mem_union.1 hc).resolve_right hnc,\n    have i h ∈ v,\n      from hv $ by simp [mem_bind]; existsi c; simp [h, this],\n    have j (hi h) ∈ jj v,\n      by simp [mem_bind]; existsi i h; simp [h, hi, this],\n    by rw [hji h] at this; exact hnc this,\n  calc (u ∪ jj v).sum g = (jj v).sum g : (sum_subset (subset_union_right _ _) this).symm\n    ... = v.sum _ : sum_bind $ by intros x hx y hy hxy; by_cases f x = 0; by_cases f y = 0; simp [*]\n    ... = v.sum f : sum_congr rfl $ by intros x hx; by_cases f x = 0; simp [*]\n\nlemma is_sum_iff_is_sum_of_ne_zero : is_sum f a ↔ is_sum g a :=\niff.intro\n  (is_sum_of_is_sum_ne_zero j hj i hi hij hji $ assume b hb, by rw [←hgj (hi _), hji])\n  (is_sum_of_is_sum_ne_zero i hi j hj hji hij hgj)\n\nlemma has_sum_iff_has_sum_ne_zero : has_sum g ↔ has_sum f :=\nexists_congr $\n  assume a, is_sum_iff_is_sum_of_ne_zero j hj i hi hij hji $\n    assume b hb, by rw [←hgj (hi _), hji]\n\nend is_sum_iff_is_sum_of_iso_ne_zero\n\nsection is_sum_iff_is_sum_of_bij_ne_zero\nvariables [add_comm_monoid α] [topological_space α] [topological_add_monoid α]\nvariables {f : β → α} {g : γ → α} {a : α}\n  (i : Π⦃c⦄, g c ≠ 0 → β)\n  (h₁ : ∀⦃c₁ c₂⦄ (h₁ : g c₁ ≠ 0) (h₂ : g c₂ ≠ 0), i h₁ = i h₂ → c₁ = c₂)\n  (h₂ : ∀⦃b⦄, f b ≠ 0 → ∃c (h : g c ≠ 0), i h = b)\n  (h₃ : ∀⦃c⦄ (h : g c ≠ 0), f (i h) = g c)\ninclude i h₁ h₂ h₃\n\nlemma is_sum_iff_is_sum_of_ne_zero_bij : is_sum f a ↔ is_sum g a :=\nhave hi : ∀⦃c⦄ (h : g c ≠ 0), f (i h) ≠ 0,\n  from assume c h, by simp [h₃, h],\nlet j : Π⦃b⦄, f b ≠ 0 → γ := λb h, some $ h₂ h in\nhave hj : ∀⦃b⦄ (h : f b ≠ 0), ∃(h : g (j h) ≠ 0), i h = b,\n  from assume b h, some_spec $ h₂ h,\nhave hj₁ : ∀⦃b⦄ (h : f b ≠ 0), g (j h) ≠ 0,\n  from assume b h, let ⟨h₁, _⟩ := hj h in h₁,\nhave hj₂ : ∀⦃b⦄ (h : f b ≠ 0), i (hj₁ h) = b,\n  from assume b h, let ⟨h₁, h₂⟩ := hj h in h₂,\nis_sum_iff_is_sum_of_ne_zero i hi j hj₁\n  (assume c h, h₁ (hj₁ _) h $ hj₂ _) hj₂ (assume b h, by rw [←h₃ (hj₁ _), hj₂])\n\nlemma has_sum_iff_has_sum_ne_zero_bij : has_sum f ↔ has_sum g :=\nexists_congr $\n  assume a, is_sum_iff_is_sum_of_ne_zero_bij @i h₁ h₂ h₃\n\nend is_sum_iff_is_sum_of_bij_ne_zero\n\nsection tsum\nvariables [add_comm_monoid α] [topological_space α] [topological_add_monoid α] [t2_space α]\nvariables {f g : β → α} {a a₁ a₂ : α}\n\nlemma is_sum_unique : is_sum f a₁ → is_sum f a₂ → a₁ = a₂ := tendsto_nhds_unique at_top_ne_bot\n\nlemma tsum_eq_is_sum (ha : is_sum f a) : (∑b, f b) = a := is_sum_unique (is_sum_tsum ⟨a, ha⟩) ha\n\nlemma is_sum_iff_of_has_sum (h : has_sum f) : is_sum f a ↔ (∑b, f b) = a :=\niff.intro tsum_eq_is_sum (assume eq, eq ▸ is_sum_tsum h)\n\n@[simp] lemma tsum_zero : (∑b:β, 0:α) = 0 := tsum_eq_is_sum is_sum_zero\n\nlemma tsum_add (hf : has_sum f) (hg : has_sum g) : (∑b, f b + g b) = (∑b, f b) + (∑b, g b) :=\ntsum_eq_is_sum $ is_sum_add (is_sum_tsum hf) (is_sum_tsum hg)\n\nlemma tsum_sum {f : γ → β → α} {s : finset γ} (hf : ∀i∈s, has_sum (f i)) :\n  (∑b, s.sum (λi, f i b)) = s.sum (λi, ∑b, f i b) :=\ntsum_eq_is_sum $ is_sum_sum $ assume i hi, is_sum_tsum $ hf i hi\n\nlemma tsum_eq_sum {f : β → α} {s : finset β} (hf : ∀b∉s, f b = 0)  :\n  (∑b, f b) = s.sum f :=\ntsum_eq_is_sum $ is_sum_sum_of_ne_finset_zero hf\n\nlemma tsum_fintype [fintype β] (f : β → α) : (∑b, f b) = finset.univ.sum f :=\ntsum_eq_sum $ λ a h, h.elim (mem_univ _)\n\nlemma tsum_eq_single {f : β → α} (b : β) (hf : ∀b' ≠ b, f b' = 0)  :\n  (∑b, f b) = f b :=\ncalc (∑b, f b) = (finset.singleton b).sum f : tsum_eq_sum $ by simp [hf] {contextual := tt}\n  ... = f b : by simp\n\nlemma tsum_sigma [regular_space α] {γ : β → Type*} {f : (Σb:β, γ b) → α}\n  (h₁ : ∀b, has_sum (λc, f ⟨b, c⟩)) (h₂ : has_sum f) : (∑p, f p) = (∑b c, f ⟨b, c⟩):=\n(tsum_eq_is_sum $ is_sum_sigma (assume b, is_sum_tsum $ h₁ b) $ is_sum_tsum h₂).symm\n\n@[simp] lemma tsum_ite_eq (b : β) (a : α) : (∑b', if b' = b then a else 0) = a :=\ntsum_eq_is_sum (is_sum_ite_eq b a)\n\nlemma tsum_eq_tsum_of_is_sum_iff_is_sum {f : β → α} {g : γ → α}\n  (h : ∀{a}, is_sum f a ↔ is_sum g a) : (∑b, f b) = (∑c, g c) :=\nby_cases\n  (assume : ∃a, is_sum f a,\n    let ⟨a, hfa⟩ := this in\n    have hga : is_sum g a, from h.mp hfa,\n    by rw [tsum_eq_is_sum hfa, tsum_eq_is_sum hga])\n  (assume hf : ¬ has_sum f,\n    have hg : ¬ has_sum g, from assume ⟨a, hga⟩, hf ⟨a, h.mpr hga⟩,\n    by simp [tsum, hf, hg])\n\nlemma tsum_eq_tsum_of_ne_zero {f : β → α} {g : γ → α}\n  (i : Π⦃c⦄, g c ≠ 0 → β) (hi : ∀⦃c⦄ (h : g c ≠ 0), f (i h) ≠ 0)\n  (j : Π⦃b⦄, f b ≠ 0 → γ) (hj : ∀⦃b⦄ (h : f b ≠ 0), g (j h) ≠ 0)\n  (hji : ∀⦃c⦄ (h : g c ≠ 0), j (hi h) = c)\n  (hij : ∀⦃b⦄ (h : f b ≠ 0), i (hj h) = b)\n  (hgj : ∀⦃b⦄ (h : f b ≠ 0), g (j h) = f b) :\n  (∑i, f i) = (∑j, g j) :=\ntsum_eq_tsum_of_is_sum_iff_is_sum $ assume a, is_sum_iff_is_sum_of_ne_zero i hi j hj hji hij hgj\n\nlemma tsum_eq_tsum_of_ne_zero_bij {f : β → α} {g : γ → α}\n  (i : Π⦃c⦄, g c ≠ 0 → β)\n  (h₁ : ∀⦃c₁ c₂⦄ (h₁ : g c₁ ≠ 0) (h₂ : g c₂ ≠ 0), i h₁ = i h₂ → c₁ = c₂)\n  (h₂ : ∀⦃b⦄, f b ≠ 0 → ∃c (h : g c ≠ 0), i h = b)\n  (h₃ : ∀⦃c⦄ (h : g c ≠ 0), f (i h) = g c) :\n  (∑i, f i) = (∑j, g j) :=\ntsum_eq_tsum_of_is_sum_iff_is_sum $ assume a, is_sum_iff_is_sum_of_ne_zero_bij i h₁ h₂ h₃\n\nlemma tsum_eq_tsum_of_iso (j : γ → β) (i : β → γ)\n  (h₁ : ∀x, i (j x) = x) (h₂ : ∀x, j (i x) = x) :\n  (∑c, f (j c)) = (∑b, f b) :=\ntsum_eq_tsum_of_is_sum_iff_is_sum $ assume a, is_sum_iff_is_sum_of_iso i h₁ h₂\n\nlemma tsum_equiv (j : γ ≃ β) : (∑c, f (j c)) = (∑b, f b) :=\ntsum_eq_tsum_of_iso j j.symm (by simp) (by simp)\n\nend tsum\n\nsection topological_group\nvariables [add_comm_group α] [topological_space α] [topological_add_group α]\nvariables {f g : β → α} {a a₁ a₂ : α}\n\nlemma is_sum_neg : is_sum f a → is_sum (λb, - f b) (- a) :=\nis_sum_hom has_neg.neg continuous_neg'\n\nlemma has_sum_neg (hf : has_sum f) : has_sum (λb, - f b) :=\nhas_sum_spec $ is_sum_neg $ is_sum_tsum $ hf\n\nlemma is_sum_sub (hf : is_sum f a₁) (hg : is_sum g a₂) : is_sum (λb, f b - g b) (a₁ - a₂) :=\nby simp; exact is_sum_add hf (is_sum_neg hg)\n\nlemma has_sum_sub (hf : has_sum f) (hg : has_sum g) : has_sum (λb, f b - g b) :=\nhas_sum_spec $ is_sum_sub (is_sum_tsum hf) (is_sum_tsum hg)\n\nsection tsum\nvariables [t2_space α]\n\nlemma tsum_neg (hf : has_sum f) : (∑b, - f b) = - (∑b, f b) :=\ntsum_eq_is_sum $ is_sum_neg $ is_sum_tsum $ hf\n\nlemma tsum_sub (hf : has_sum f) (hg : has_sum g) : (∑b, f b - g b) = (∑b, f b) - (∑b, g b) :=\ntsum_eq_is_sum $ is_sum_sub (is_sum_tsum hf) (is_sum_tsum hg)\n\nend tsum\n\nend topological_group\n\nsection topological_semiring\nvariables [semiring α] [topological_space α] [topological_semiring α]\nvariables {f g : β → α} {a a₁ a₂ : α}\n\nlemma is_sum_mul_left (a₂) : is_sum f a₁ → is_sum (λb, a₂ * f b) (a₂ * a₁) :=\nis_sum_hom _ (continuous_mul continuous_const continuous_id)\n\nlemma is_sum_mul_right (a₂) (hf : is_sum f a₁) : is_sum (λb, f b * a₂) (a₁ * a₂) :=\n@is_sum_hom _ _ _ _ _ _ f a₁ (λa, a * a₂) _ _ _ _\n  (continuous_mul continuous_id continuous_const) hf\n\nlemma has_sum_mul_left (a) (hf : has_sum f) : has_sum (λb, a * f b) :=\nhas_sum_spec $ is_sum_mul_left _ $ is_sum_tsum hf\n\nlemma has_sum_mul_right (a) (hf : has_sum f) : has_sum (λb, f b * a) :=\nhas_sum_spec $ is_sum_mul_right _ $ is_sum_tsum hf\n\nsection tsum\nvariables [t2_space α]\n\nlemma tsum_mul_left (a) (hf : has_sum f) : (∑b, a * f b) = a * (∑b, f b) :=\ntsum_eq_is_sum $ is_sum_mul_left _ $ is_sum_tsum hf\n\nlemma tsum_mul_right (a) (hf : has_sum f) : (∑b, f b * a) = (∑b, f b) * a :=\ntsum_eq_is_sum $ is_sum_mul_right _ $ is_sum_tsum hf\n\nend tsum\n\nend topological_semiring\n\nsection order_topology\nvariables [ordered_comm_monoid α] [topological_space α] [ordered_topology α]\n  [topological_add_monoid α]\nvariables {f g : β → α} {a a₁ a₂ : α}\n\nlemma is_sum_le (h : ∀b, f b ≤ g b) (hf : is_sum f a₁) (hg : is_sum g a₂) : a₁ ≤ a₂ :=\nle_of_tendsto_of_tendsto at_top_ne_bot hf hg $ univ_mem_sets' $\n  assume s, sum_le_sum' $ assume b _, h b\n\nlemma is_sum_le_inj {g : γ → α} (i : β → γ) (hi : injective i) (hs : ∀c∉set.range i, 0 ≤ g c)\n  (h : ∀b, f b ≤ g (i b)) (hf : is_sum f a₁) (hg : is_sum g a₂) : a₁ ≤ a₂ :=\nhave is_sum (λc, (partial_inv i c).cases_on' 0 f) a₁,\nbegin\n  refine (is_sum_iff_is_sum_of_ne_zero_bij (λb _, i b) _ _ _).2 hf,\n  { assume c₁ c₂ h₁ h₂ eq, exact hi eq },\n  { assume c hc,\n    cases eq : partial_inv i c with b; rw eq at hc,\n    { contradiction },\n    { rw [partial_inv_of_injective hi] at eq,\n      exact ⟨b, hc, eq⟩ } },\n  { assume c hc, rw [partial_inv_left hi, option.cases_on'] }\nend,\nbegin\n  refine is_sum_le (assume c, _) this hg,\n  by_cases c ∈ set.range i,\n  { rcases h with ⟨b, rfl⟩,\n    rw [partial_inv_left hi, option.cases_on'],\n    exact h _ },\n  { have : partial_inv i c = none := dif_neg h,\n    rw [this, option.cases_on'],\n    exact hs _ h }\nend\n\nlemma tsum_le_tsum (h : ∀b, f b ≤ g b) (hf : has_sum f) (hg : has_sum g) : (∑b, f b) ≤ (∑b, g b) :=\nis_sum_le h (is_sum_tsum hf) (is_sum_tsum hg)\n\nend order_topology\n\nsection uniform_group\n\nvariables [add_comm_group α] [uniform_space α] [complete_space α] [uniform_add_group α]\nvariables (f g : β → α) {a a₁ a₂ : α}\n\nlemma has_sum_iff_cauchy : has_sum f ↔ cauchy (map (λ (s : finset β), sum s f) at_top) :=\n(cauchy_map_iff_exists_tendsto at_top_ne_bot).symm\n\nlemma has_sum_iff_vanishing :\n  has_sum f ↔ ∀ e ∈ nhds (0:α), (∃s:finset β, ∀t, disjoint t s → t.sum f ∈ e) :=\nbegin\n  simp only [has_sum_iff_cauchy, cauchy_map_iff, and_iff_right at_top_ne_bot,\n    prod_at_top_at_top_eq, uniformity_eq_comap_nhds_zero α, tendsto_comap_iff, (∘)],\n  rw [tendsto_at_top' (_ : finset β × finset β → α)],\n  split,\n  { assume h e he,\n    rcases h e he with ⟨⟨s₁, s₂⟩, h⟩,\n    use [s₁ ∪ s₂],\n    assume t ht,\n    have : (s₁ ∪ s₂) ∩ t = ∅ := finset.disjoint_iff_inter_eq_empty.1 ht.symm,\n    specialize h (s₁ ∪ s₂, (s₁ ∪ s₂) ∪ t) ⟨le_sup_left, le_sup_left_of_le le_sup_right⟩,\n    simpa only [finset.sum_union this, add_sub_cancel'] using h },\n  { assume h e he,\n    rcases exists_nhds_half_neg he with ⟨d, hd, hde⟩,\n    rcases h d hd with ⟨s, h⟩,\n    use [(s, s)],\n    rintros ⟨t₁, t₂⟩ ⟨ht₁, ht₂⟩,\n    have : t₂.sum f - t₁.sum f = (t₂ \\ s).sum f - (t₁ \\ s).sum f,\n    { simp only [(finset.sum_sdiff ht₁).symm, (finset.sum_sdiff ht₂).symm,\n        add_sub_add_right_eq_sub] },\n    simp only [this],\n    exact hde _ _ (h _ finset.sdiff_disjoint) (h _ finset.sdiff_disjoint) }\nend\n\n/- TODO: generalize to monoid with a uniform continuous subtraction operator: `(a + b) - b = a` -/\nlemma has_sum_of_has_sum_of_sub (hf : has_sum f) (h : ∀b, g b = 0 ∨ g b = f b) : has_sum g :=\n(has_sum_iff_vanishing g).2 $\n  assume e he,\n  let ⟨s, hs⟩ := (has_sum_iff_vanishing f).1 hf e he in\n  ⟨s, assume t ht,\n    have eq : (t.filter (λb, g b = f b)).sum f = t.sum g :=\n      calc (t.filter (λb, g b = f b)).sum f = (t.filter (λb, g b = f b)).sum g :\n          finset.sum_congr rfl (assume b hb, (finset.mem_filter.1 hb).2.symm)\n        ... = t.sum g :\n        begin\n          refine finset.sum_subset (finset.filter_subset _) _,\n          assume b hbt hb,\n          simp only [(∉), finset.mem_filter, and_iff_right hbt] at hb,\n          exact (h b).resolve_right hb\n        end,\n    eq ▸ hs _ $ finset.disjoint_of_subset_left (finset.filter_subset _) ht⟩\n\nlemma has_sum_comp_of_has_sum_of_injective {i : γ → β} (hf : has_sum f) (hi : injective i) :\n  has_sum (f ∘ i) :=\nsuffices has_sum (λb, if b ∈ set.range i then f b else 0),\nbegin\n  refine (has_sum_iff_has_sum_ne_zero_bij (λc _, i c) _ _ _).1 this,\n  { assume c₁ c₂ hc₁ hc₂ eq, exact hi eq },\n  { assume b hb,\n    split_ifs at hb,\n    { rcases h with ⟨c, rfl⟩,\n      exact ⟨c, hb, rfl⟩ },\n    { contradiction } },\n  { assume c hc, exact if_pos (set.mem_range_self _) }\nend,\nhas_sum_of_has_sum_of_sub _ _ hf $ assume b, by by_cases b ∈ set.range i; simp [h]\n\nend uniform_group\n\nsection cauchy_seq\nopen finset.Ico filter\n\nlemma cauchy_seq_of_has_sum_dist [metric_space α] {f : ℕ → α}\n  (h : has_sum (λn, dist (f n) (f n.succ))) : cauchy_seq f :=\nbegin\n  let d := λn, dist (f n) (f (n+1)),\n  refine metric.cauchy_seq_iff'.2 (λε εpos, _),\n  rcases (has_sum_iff_vanishing _).1 h {x : ℝ | x < ε} (gt_mem_nhds εpos) with ⟨s, hs⟩,\n  have : ∃N:ℕ, ∀x ∈ s, x < N,\n  { by_cases h : s = ∅,\n    { use 0, simp [h]},\n    { use s.max' h + 1,\n      exact λx hx, lt_of_le_of_lt (s.le_max' h x hx) (nat.lt_succ_self _) }},\n  rcases this with ⟨N, hN⟩,\n  refine ⟨N, λn hn, _⟩,\n  have : ∀n, n ≥ N → dist (f N) (f n) ≤ (Ico N n).sum d,\n  { apply nat.le_induction,\n    { simp },\n    { assume n hn hrec,\n      calc dist (f N) (f (n+1)) ≤ dist (f N) (f n) + d n : dist_triangle _ _ _\n        ... ≤ (Ico N n).sum d + d n : add_le_add hrec (le_refl _)\n        ... = (Ico N (n+1)).sum d : by rw [succ_top hn, sum_insert, add_comm]; simp }},\n  calc dist (f n) (f N) ≤ (Ico N n).sum d : by rw dist_comm; apply this n hn\n    ... < ε : hs _ (finset.disjoint_iff_ne.2\n                     (λa ha b hb, ne_of_gt (lt_of_lt_of_le (hN _ hb) (mem.1 ha).1)))\nend\n\nend cauchy_seq\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/topology/algebra/infinite_sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.4696368097281613}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.nat.basic\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# Partial predecessor and partial subtraction on the natural numbers\n\nThe usual definition of natural number subtraction (`nat.sub`) returns 0 as a \"garbage value\" for\n`a - b` when `a < b`. Similarly, `nat.pred 0` is defined to be `0`. The functions in this file\nwrap the result in an `option` type instead:\n\n## Main definitions\n\n- `nat.ppred`: a partial predecessor operation\n- `nat.psub`: a partial subtraction operation\n\n-/\n\nnamespace nat\n\n\n/-- Partial predecessor operation. Returns `ppred n = some m`\n  if `n = m + 1`, otherwise `none`. -/\n@[simp] def ppred : ℕ → Option ℕ :=\n  sorry\n\n/-- Partial subtraction operation. Returns `psub m n = some k`\n  if `m = n + k`, otherwise `none`. -/\n@[simp] def psub (m : ℕ) : ℕ → Option ℕ :=\n  sorry\n\ntheorem pred_eq_ppred (n : ℕ) : Nat.pred n = option.get_or_else (ppred n) 0 :=\n  nat.cases_on n (Eq.refl (Nat.pred 0)) fun (n : ℕ) => Eq.refl (Nat.pred (Nat.succ n))\n\ntheorem sub_eq_psub (m : ℕ) (n : ℕ) : m - n = option.get_or_else (psub m n) 0 := sorry\n\n@[simp] theorem ppred_eq_some {m : ℕ} {n : ℕ} : ppred n = some m ↔ Nat.succ m = n := sorry\n\n@[simp] theorem ppred_eq_none {n : ℕ} : ppred n = none ↔ n = 0 := sorry\n\ntheorem psub_eq_some {m : ℕ} {n : ℕ} {k : ℕ} : psub m n = some k ↔ k + n = m := sorry\n\ntheorem psub_eq_none {m : ℕ} {n : ℕ} : psub m n = none ↔ m < n := sorry\n\ntheorem ppred_eq_pred {n : ℕ} (h : 0 < n) : ppred n = some (Nat.pred n) :=\n  iff.mpr ppred_eq_some (succ_pred_eq_of_pos h)\n\ntheorem psub_eq_sub {m : ℕ} {n : ℕ} (h : n ≤ m) : psub m n = some (m - n) :=\n  iff.mpr psub_eq_some (nat.sub_add_cancel h)\n\ntheorem psub_add (m : ℕ) (n : ℕ) (k : ℕ) : psub m (n + k) =\n  do \n    let x ← psub m n \n    psub x k := sorry\n\n/-- Same as `psub`, but with a more efficient implementation. -/\ndef psub' (m : ℕ) (n : ℕ) : Option ℕ :=\n  ite (n ≤ m) (some (m - n)) none\n\ntheorem psub'_eq_psub (m : ℕ) (n : ℕ) : psub' m n = psub m n := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/nat/psub.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6654105454764746, "lm_q1q2_score": 0.46963680036215444}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport data.set.finite group_theory.coset data.nat.totient\nopen function\n\nvariables {α : Type*} {s : set α} {a a₁ a₂ b c: α}\n\n-- TODO this lemma isn't used anywhere in this file, and should be moved elsewhere.\nnamespace finset\nopen finset\n\nlemma mem_range_iff_mem_finset_range_of_mod_eq [decidable_eq α] {f : ℤ → α} {a : α} {n : ℕ}\n  (hn : 0 < n) (h : ∀i, f (i % n) = f i) :\n  a ∈ set.range f ↔ a ∈ (finset.range n).image (λi, f i) :=\nsuffices (∃i, f (i % n) = a) ↔ ∃i, i < n ∧ f ↑i = a, by simpa [h],\nhave hn' : 0 < (n : ℤ), from int.coe_nat_lt.mpr hn,\niff.intro\n  (assume ⟨i, hi⟩,\n    have 0 ≤ i % ↑n, from int.mod_nonneg _ (ne_of_gt hn'),\n    ⟨int.to_nat (i % n),\n      by rw [←int.coe_nat_lt, int.to_nat_of_nonneg this]; exact ⟨int.mod_lt_of_pos i hn', hi⟩⟩)\n  (assume ⟨i, hi, ha⟩,\n    ⟨i, by rw [int.mod_eq_of_lt (int.coe_zero_le _) (int.coe_nat_lt_coe_nat_of_lt hi), ha]⟩)\n\nend finset\n\nlemma conj_inj [group α] {x : α} : function.injective (λ (g : α), x * g * x⁻¹) :=\nλ a b h, by simpa [mul_left_inj, mul_right_inj] using h\n\nlemma mem_normalizer_fintype [group α] {s : set α} [fintype s] {x : α}\n  (h : ∀ n, n ∈ s → x * n * x⁻¹ ∈ s) : x ∈ is_subgroup.normalizer s :=\nby haveI := classical.prop_decidable;\nhaveI := set.fintype_image s (λ n, x * n * x⁻¹); exact\nλ n, ⟨h n, λ h₁,\nhave heq : (λ n, x * n * x⁻¹) '' s = s := set.eq_of_subset_of_card_le\n  (λ n ⟨y, hy⟩, hy.2 ▸ h y hy.1) (by rw set.card_image_of_injective s conj_inj),\nhave x * n * x⁻¹ ∈ (λ n, x * n * x⁻¹) '' s := heq.symm ▸ h₁,\nlet ⟨y, hy⟩ := this in conj_inj hy.2 ▸ hy.1⟩\n\nsection order_of\nvariables [group α] [fintype α] [decidable_eq α]\nopen quotient_group set\n\ninstance quotient_group.fintype (s : set α) [is_subgroup s] [d : decidable_pred s] :\n  fintype (quotient s) :=\n@quotient.fintype _ _ (left_rel s) (λ _ _, d _)\n\nlemma card_eq_card_quotient_mul_card_subgroup (s : set α) [hs : is_subgroup s] [fintype s]\n  [decidable_pred s] : fintype.card α = fintype.card (quotient s) * fintype.card s :=\nby rw ← fintype.card_prod;\n  exact fintype.card_congr (is_subgroup.group_equiv_quotient_times_subgroup hs)\n\nlemma card_subgroup_dvd_card (s : set α) [is_subgroup s] [fintype s] :\n  fintype.card s ∣ fintype.card α :=\nby haveI := classical.prop_decidable; simp [card_eq_card_quotient_mul_card_subgroup s]\n\nlemma card_quotient_dvd_card (s : set α) [is_subgroup s] [decidable_pred s] [fintype s] :\n  fintype.card (quotient s) ∣ fintype.card α :=\nby simp [card_eq_card_quotient_mul_card_subgroup s]\n\n@[simp] lemma card_trivial [fintype (is_subgroup.trivial α)] :\n  fintype.card (is_subgroup.trivial α) = 1 :=\nfintype.card_eq_one_iff.2\n  ⟨⟨(1 : α), by simp⟩, λ ⟨y, hy⟩, subtype.eq $ is_subgroup.mem_trivial.1 hy⟩\n\nlemma exists_gpow_eq_one (a : α) : ∃i≠0, a ^ (i:ℤ) = 1 :=\nhave ¬ injective (λi, a ^ i),\n  from not_injective_int_fintype,\nlet ⟨i, j, a_eq, ne⟩ := show ∃(i j : ℤ), a ^ i = a ^ j ∧ i ≠ j,\n  by rw [injective] at this; simpa [classical.not_forall] in\nhave a ^ (i - j) = 1,\n  by simp [gpow_add, gpow_neg, a_eq],\n⟨i - j, sub_ne_zero.mpr ne, this⟩\n\nlemma exists_pow_eq_one (a : α) : ∃i > 0, a ^ i = 1 :=\nlet ⟨i, hi, eq⟩ := exists_gpow_eq_one a in\nbegin\n  cases i,\n  { exact ⟨i, nat.pos_of_ne_zero (by simp [int.of_nat_eq_coe, *] at *), eq⟩ },\n  { exact ⟨i + 1, dec_trivial, inv_eq_one.1 eq⟩ }\nend\n\n/-- `order_of a` is the order of the element `a`, i.e. the `n ≥ 1`, s.t. `a ^ n = 1` -/\ndef order_of (a : α) : ℕ := nat.find (exists_pow_eq_one a)\n\nlemma pow_order_of_eq_one (a : α) : a ^ order_of a = 1 :=\nlet ⟨h₁, h₂⟩ := nat.find_spec (exists_pow_eq_one a) in h₂\n\nlemma order_of_pos (a : α) : order_of a > 0 :=\nlet ⟨h₁, h₂⟩ := nat.find_spec (exists_pow_eq_one a) in h₁\n\nprivate lemma pow_injective_aux {n m : ℕ} (a : α) (h : n ≤ m)\n  (hn : n < order_of a) (hm : m < order_of a) (eq : a ^ n = a ^ m) : n = m :=\ndecidable.by_contradiction $ assume ne : n ≠ m,\n  have h₁ : m - n > 0, from nat.pos_of_ne_zero (by simp [nat.sub_eq_iff_eq_add h, ne.symm]),\n  have h₂ : a ^ (m - n) = 1, by simp [pow_sub _ h, eq],\n  have le : order_of a ≤ m - n, from nat.find_min' (exists_pow_eq_one a) ⟨h₁, h₂⟩,\n  have lt : m - n < order_of a,\n    from (nat.sub_lt_left_iff_lt_add h).mpr $ nat.lt_add_left _ _ _ hm,\n  lt_irrefl _ (lt_of_le_of_lt le lt)\n\nlemma pow_injective_of_lt_order_of {n m : ℕ} (a : α)\n  (hn : n < order_of a) (hm : m < order_of a) (eq : a ^ n = a ^ m) : n = m :=\n(le_total n m).elim\n  (assume h, pow_injective_aux a h hn hm eq)\n  (assume h, (pow_injective_aux a h hm hn eq.symm).symm)\n\nlemma order_of_le_card_univ : order_of a ≤ fintype.card α :=\nfinset.card_le_of_inj_on ((^) a)\n  (assume n _, fintype.complete _)\n  (assume i j, pow_injective_of_lt_order_of a)\n\nlemma pow_eq_mod_order_of {n : ℕ} : a ^ n = a ^ (n % order_of a) :=\ncalc a ^ n = a ^ (n % order_of a + order_of a * (n / order_of a)) :\n    by rw [nat.mod_add_div]\n  ... = a ^ (n % order_of a) :\n    by simp [pow_add, pow_mul, pow_order_of_eq_one]\n\nlemma gpow_eq_mod_order_of {i : ℤ} : a ^ i = a ^ (i % order_of a) :=\ncalc a ^ i = a ^ (i % order_of a + order_of a * (i / order_of a)) :\n    by rw [int.mod_add_div]\n  ... = a ^ (i % order_of a) :\n    by simp [gpow_add, gpow_mul, pow_order_of_eq_one]\n\nlemma mem_gpowers_iff_mem_range_order_of {a a' : α} :\n  a' ∈ gpowers a ↔ a' ∈ (finset.range (order_of a)).image ((^) a : ℕ → α) :=\nfinset.mem_range_iff_mem_finset_range_of_mod_eq\n  (order_of_pos a)\n  (assume i, gpow_eq_mod_order_of.symm)\n\ninstance decidable_gpowers : decidable_pred (gpowers a) :=\nassume a', decidable_of_iff'\n  (a' ∈ (finset.range (order_of a)).image ((^) a))\n  mem_gpowers_iff_mem_range_order_of\n\nlemma order_of_dvd_of_pow_eq_one {n : ℕ} (h : a ^ n = 1) : order_of a ∣ n :=\nby_contradiction\n  (λ h₁, nat.find_min _ (show n % order_of a < order_of a,\n    from nat.mod_lt _ (order_of_pos _))\n      ⟨nat.pos_of_ne_zero (mt nat.dvd_of_mod_eq_zero h₁), by rwa ← pow_eq_mod_order_of⟩)\n\nlemma order_of_le_of_pow_eq_one {n : ℕ} (hn : 0 < n) (h : a ^ n = 1) : order_of a ≤ n :=\nnat.find_min' (exists_pow_eq_one a) ⟨hn, h⟩\n\nlemma sum_card_order_of_eq_card_pow_eq_one {n : ℕ} (hn : 0 < n) :\n  ((finset.range n.succ).filter (∣ n)).sum (λ m, (finset.univ.filter (λ a : α, order_of a = m)).card)\n  = (finset.univ.filter (λ a : α, a ^ n = 1)).card :=\ncalc ((finset.range n.succ).filter (∣ n)).sum (λ m, (finset.univ.filter (λ a : α, order_of a = m)).card)\n    = _ : (finset.card_bind (by simp [finset.ext]; cc)).symm\n... = _ : congr_arg finset.card (finset.ext.2 (begin\n  assume a,\n  suffices : order_of a ≤ n ∧ order_of a ∣ n ↔ a ^ n = 1,\n  { simpa [nat.lt_succ_iff], },\n  exact ⟨λ h, let ⟨m, hm⟩ := h.2 in by rw [hm, pow_mul, pow_order_of_eq_one, _root_.one_pow],\n    λ h, ⟨order_of_le_of_pow_eq_one hn h, order_of_dvd_of_pow_eq_one h⟩⟩\nend))\n\nsection\nlocal attribute [instance] set_fintype\n\nlemma order_eq_card_gpowers : order_of a = fintype.card (gpowers a) :=\nbegin\n  refine (finset.card_eq_of_bijective _ _ _ _).symm,\n  { exact λn hn, ⟨gpow a n, ⟨n, rfl⟩⟩ },\n  { exact assume ⟨_, i, rfl⟩ _,\n    have pos: (0:int) < order_of a,\n      from int.coe_nat_lt.mpr $ order_of_pos a,\n    have 0 ≤ i % (order_of a),\n      from int.mod_nonneg _ $ ne_of_gt pos,\n    ⟨int.to_nat (i % order_of a),\n      by rw [← int.coe_nat_lt, int.to_nat_of_nonneg this];\n        exact ⟨int.mod_lt_of_pos _ pos, subtype.eq gpow_eq_mod_order_of.symm⟩⟩ },\n  { intros, exact finset.mem_univ _ },\n  { exact assume i j hi hj eq, pow_injective_of_lt_order_of a hi hj $ by simpa using eq }\nend\n\n@[simp] lemma order_of_one : order_of (1 : α) = 1 :=\nby rw [order_eq_card_gpowers, fintype.card_eq_one_iff];\n  exact ⟨⟨1, 0, rfl⟩, λ ⟨a, i, ha⟩, by simp [ha.symm]⟩\n\n@[simp] lemma order_of_eq_one_iff : order_of a = 1 ↔ a = 1 :=\n⟨λ h, by conv { to_lhs, rw [← pow_one a, ← h, pow_order_of_eq_one] }, λ h, by simp [h]⟩\n\nsection classical\nlocal attribute [instance] classical.prop_decidable\nopen quotient_group\n\n/- TODO: use cardinal theory, introduce `card : set α → ℕ`, or setup decidability for cosets -/\nlemma order_of_dvd_card_univ : order_of a ∣ fintype.card α :=\nhave ft_prod : fintype (quotient (gpowers a) × (gpowers a)),\n  from fintype.of_equiv α (gpowers.is_subgroup a).group_equiv_quotient_times_subgroup,\nhave ft_s : fintype (gpowers a),\n  from @fintype.fintype_prod_right _ _ _ ft_prod _,\nhave ft_cosets : fintype (quotient (gpowers a)),\n  from @fintype.fintype_prod_left _ _ _ ft_prod ⟨⟨1, is_submonoid.one_mem (gpowers a)⟩⟩,\nhave ft : fintype (quotient (gpowers a) × (gpowers a)),\n  from @prod.fintype _ _ ft_cosets ft_s,\nhave eq₁ : fintype.card α = @fintype.card _ ft_cosets * @fintype.card _ ft_s,\n  from calc fintype.card α = @fintype.card _ ft_prod :\n      @fintype.card_congr _ _ _ ft_prod (gpowers.is_subgroup a).group_equiv_quotient_times_subgroup\n    ... = @fintype.card _ (@prod.fintype _ _ ft_cosets ft_s) :\n      congr_arg (@fintype.card _) $ subsingleton.elim _ _\n    ... = @fintype.card _ ft_cosets * @fintype.card _ ft_s :\n      @fintype.card_prod _ _ ft_cosets ft_s,\nhave eq₂ : order_of a = @fintype.card _ ft_s,\n  from calc order_of a = _ : order_eq_card_gpowers\n    ... = _ : congr_arg (@fintype.card _) $ subsingleton.elim _ _,\ndvd.intro (@fintype.card (quotient (gpowers a)) ft_cosets) $\n  by rw [eq₁, eq₂, mul_comm]\n\n\nend classical\n\n@[simp] lemma pow_card_eq_one (a : α) : a ^ fintype.card α = 1 :=\nlet ⟨m, hm⟩ := @order_of_dvd_card_univ _ a _ _ _ in\nby simp [hm, pow_mul, pow_order_of_eq_one]\n\nlemma powers_eq_gpowers (a : α) : powers a = gpowers a :=\nset.ext (λ x, ⟨λ ⟨n, hn⟩, ⟨n, by simp * at *⟩,\n  λ ⟨i, hi⟩, ⟨(i % order_of a).nat_abs,\n    by rwa [← gpow_coe_nat, int.nat_abs_of_nonneg (int.mod_nonneg _\n      (int.coe_nat_ne_zero_iff_pos.2 (order_of_pos _))), ← gpow_eq_mod_order_of]⟩⟩)\n\nopen nat\n\nlemma order_of_pow (a : α) (n : ℕ) : order_of (a ^ n) = order_of a / gcd (order_of a) n :=\ndvd_antisymm\n  (order_of_dvd_of_pow_eq_one\n    (by rw [← pow_mul, ← nat.mul_div_assoc _ (gcd_dvd_left _ _), mul_comm,\n      nat.mul_div_assoc _ (gcd_dvd_right _ _), pow_mul, pow_order_of_eq_one, _root_.one_pow]))\n  (have gcd_pos : 0 < gcd (order_of a) n, from gcd_pos_of_pos_left n (order_of_pos a),\n    have hdvd : order_of a ∣ n * order_of (a ^ n),\n      from order_of_dvd_of_pow_eq_one (by rw [pow_mul, pow_order_of_eq_one]),\n    coprime.dvd_of_dvd_mul_right (coprime_div_gcd_div_gcd gcd_pos)\n      (dvd_of_mul_dvd_mul_right gcd_pos\n        (by rwa [nat.div_mul_cancel (gcd_dvd_left _ _), mul_assoc,\n            nat.div_mul_cancel (gcd_dvd_right _ _), mul_comm])))\n\nlemma pow_gcd_card_eq_one_iff {n : ℕ} {a : α} :\n  a ^ n = 1 ↔ a ^ (gcd n (fintype.card α)) = 1 :=\n⟨λ h, have hn : order_of a ∣ n, from dvd_of_mod_eq_zero $\n      by_contradiction (λ ha, by rw pow_eq_mod_order_of at h;\n        exact (not_le_of_gt (nat.mod_lt n (order_of_pos a)))\n          (order_of_le_of_pow_eq_one (nat.pos_of_ne_zero ha) h)),\n    let ⟨m, hm⟩ := dvd_gcd hn order_of_dvd_card_univ in\n    by rw [hm, pow_mul, pow_order_of_eq_one, _root_.one_pow],\n  λ h, let ⟨m, hm⟩ := gcd_dvd_left n (fintype.card α) in\n    by rw [hm, pow_mul, h, _root_.one_pow]⟩\n\nend\n\nend order_of\n\nsection cyclic\n\nlocal attribute [instance] set_fintype\n\nclass is_cyclic (α : Type*) [group α] : Prop :=\n(exists_generator : ∃ g : α, ∀ x, x ∈ gpowers g)\n\ndef is_cyclic.comm_group [hg : group α] [is_cyclic α] : comm_group α :=\n{ mul_comm := λ x y, show x * y = y * x,\n    from let ⟨g, hg⟩ := is_cyclic.exists_generator α in\n    let ⟨n, hn⟩ := hg x in let ⟨m, hm⟩ := hg y in\n    hm ▸ hn ▸ gpow_mul_comm _ _ _,\n  ..hg }\n\nlemma is_cyclic_of_order_of_eq_card [group α] [fintype α] [decidable_eq α]\n  (x : α) (hx : order_of x = fintype.card α) : is_cyclic α :=\n⟨⟨x, set.eq_univ_iff_forall.1 $ set.eq_of_subset_of_card_le\n  (set.subset_univ _)\n  (by rw [fintype.card_congr (equiv.set.univ α), ← hx, order_eq_card_gpowers])⟩⟩\n\nlemma order_of_eq_card_of_forall_mem_gpowers [group α] [fintype α] [decidable_eq α]\n  {g : α} (hx : ∀ x, x ∈ gpowers g) : order_of g = fintype.card α :=\nby rw [← fintype.card_congr (equiv.set.univ α), order_eq_card_gpowers];\n  simp [hx]; congr\n\ninstance [group α] : is_cyclic (is_subgroup.trivial α) :=\n⟨⟨(1 : is_subgroup.trivial α), λ x, ⟨0, subtype.eq $ eq.symm (is_subgroup.mem_trivial.1 x.2)⟩⟩⟩\n\ninstance is_subgroup.is_cyclic [group α] [is_cyclic α] (H : set α) [is_subgroup H] : is_cyclic H :=\nby haveI := classical.prop_decidable; exact\nlet ⟨g, hg⟩ := is_cyclic.exists_generator α in\nif hx : ∃ (x : α), x ∈ H ∧ x ≠ (1 : α) then\n  let ⟨x, hx₁, hx₂⟩ := hx in\n  let ⟨k, hk⟩ := hg x in\n  have hex : ∃ n : ℕ, 0 < n ∧ g ^ n ∈ H,\n    from ⟨k.nat_abs, nat.pos_of_ne_zero\n      (λ h, hx₂ $ by rw [← hk, int.eq_zero_of_nat_abs_eq_zero h, gpow_zero]),\n        match k, hk with\n        | (k : ℕ), hk := by rw [int.nat_abs_of_nat, ← gpow_coe_nat, hk]; exact hx₁\n        | -[1+ k], hk := by rw [int.nat_abs_of_neg_succ_of_nat,\n          ← is_subgroup.inv_mem_iff H]; simp * at *\n        end⟩,\n  ⟨⟨⟨g ^ nat.find hex, (nat.find_spec hex).2⟩,\n    λ ⟨x, hx⟩, let ⟨k, hk⟩ := hg x in\n      have hk₁ : g ^ ((nat.find hex : ℤ) * (k / nat.find hex)) ∈ gpowers (g ^ nat.find hex),\n        from ⟨k / nat.find hex, eq.symm $ gpow_mul _ _ _⟩,\n      have hk₂ : g ^ ((nat.find hex : ℤ) * (k / nat.find hex)) ∈ H,\n        by rw gpow_mul; exact is_subgroup.gpow_mem (nat.find_spec hex).2,\n      have hk₃ : g ^ (k % nat.find hex) ∈ H,\n        from (is_subgroup.mul_mem_cancel_left H hk₂).1 $\n          by rw [← gpow_add, int.mod_add_div, hk]; exact hx,\n      have hk₄ : k % nat.find hex = (k % nat.find hex).nat_abs,\n        by rw int.nat_abs_of_nonneg (int.mod_nonneg _\n          (int.coe_nat_ne_zero_iff_pos.2 (nat.find_spec hex).1)),\n      have hk₅ : g ^ (k % nat.find hex ).nat_abs ∈ H,\n        by rwa [← gpow_coe_nat, ← hk₄],\n      have hk₆ : (k % (nat.find hex : ℤ)).nat_abs = 0,\n        from by_contradiction (λ h,\n          nat.find_min hex (int.coe_nat_lt.1 $ by rw [← hk₄];\n            exact int.mod_lt_of_pos _ (int.coe_nat_pos.2 (nat.find_spec hex).1))\n          ⟨nat.pos_of_ne_zero h, hk₅⟩),\n      ⟨k / (nat.find hex : ℤ), subtype.coe_ext.2 begin\n        suffices : g ^ ((nat.find hex : ℤ) * (k / nat.find hex)) = x,\n        { simpa [gpow_mul] },\n        rw [int.mul_div_cancel' (int.dvd_of_mod_eq_zero (int.eq_zero_of_nat_abs_eq_zero hk₆)), hk]\n      end⟩⟩⟩\nelse\n  have H = is_subgroup.trivial α,\n    from set.ext $ λ x, ⟨λ h, by simp at *; tauto,\n      λ h, by rw [is_subgroup.mem_trivial.1 h]; exact is_submonoid.one_mem _⟩,\n  by clear _let_match; subst this; apply_instance\n\nopen finset nat\n\nlemma is_cyclic.card_pow_eq_one_le [group α] [fintype α] [decidable_eq α] [is_cyclic α] {n : ℕ}\n  (hn0 : 0 < n) : (univ.filter (λ a : α, a ^ n = 1)).card ≤ n :=\nlet ⟨g, hg⟩ := is_cyclic.exists_generator α in\ncalc (univ.filter (λ a : α, a ^ n = 1)).card ≤ (gpowers (g ^ (fintype.card α / (gcd n (fintype.card α))))).to_finset.card :\n  card_le_of_subset (λ x hx, let ⟨m, hm⟩ := show x ∈ powers g, from (powers_eq_gpowers g).symm ▸ hg x in\n    set.mem_to_finset.2 ⟨(m / (fintype.card α / (gcd n (fintype.card α))) : ℕ),\n      have hgmn : g ^ (m * gcd n (fintype.card α)) = 1,\n        by rw [pow_mul, hm, ← pow_gcd_card_eq_one_iff]; exact (mem_filter.1 hx).2,\n      begin\n        rw [gpow_coe_nat, ← pow_mul, nat.mul_div_cancel_left', hm],\n        refine dvd_of_mul_dvd_mul_right (gcd_pos_of_pos_left (fintype.card α) hn0) _,\n        conv {to_lhs, rw [nat.div_mul_cancel (gcd_dvd_right _ _), ← order_of_eq_card_of_forall_mem_gpowers hg]},\n        exact order_of_dvd_of_pow_eq_one hgmn\n      end⟩)\n... ≤ n :\n  let ⟨m, hm⟩ := gcd_dvd_right n (fintype.card α) in\n  have hm0 : 0 < m, from nat.pos_of_ne_zero\n    (λ hm0, (by rw [hm0, mul_zero, fintype.card_eq_zero_iff] at hm; exact hm 1)),\n  begin\n    rw [← set.card_fintype_of_finset' _ (λ _, set.mem_to_finset), ← order_eq_card_gpowers,\n      order_of_pow, order_of_eq_card_of_forall_mem_gpowers hg],\n    rw [hm] {occs := occurrences.pos [2,3]},\n    rw [nat.mul_div_cancel_left _  (gcd_pos_of_pos_left _ hn0), gcd_mul_left_left,\n      hm, nat.mul_div_cancel _ hm0],\n    exact le_of_dvd hn0 (gcd_dvd_left _ _)\n  end\n\nsection totient\n\nvariables [group α] [fintype α] [decidable_eq α] (hn : ∀ n : ℕ, 0 < n → (univ.filter (λ a : α, a ^ n = 1)).card ≤ n)\ninclude hn\n\nlemma card_pow_eq_one_eq_order_of_aux (a : α) :\n  (finset.univ.filter (λ b : α, b ^ order_of a = 1)).card = order_of a :=\nle_antisymm\n  (hn _ (order_of_pos _))\n  (calc order_of a = @fintype.card (gpowers a) (id _) : order_eq_card_gpowers\n    ... ≤ @fintype.card (↑(univ.filter (λ b : α, b ^ order_of a = 1)) : set α)\n    (set.fintype_of_finset _ (λ _, iff.rfl)) :\n      @fintype.card_le_of_injective (gpowers a) (↑(univ.filter (λ b : α, b ^ order_of a = 1)) : set α)\n        (id _) (id _) (λ b, ⟨b.1, mem_filter.2 ⟨mem_univ _,\n          let ⟨i, hi⟩ := b.2 in\n          by rw [← hi, ← gpow_coe_nat, ← gpow_mul, mul_comm, gpow_mul, gpow_coe_nat,\n            pow_order_of_eq_one, one_gpow]⟩⟩) (λ _ _ h, subtype.eq (subtype.mk.inj h))\n    ... = (univ.filter (λ b : α, b ^ order_of a = 1)).card : set.card_fintype_of_finset _ _)\n\nlocal notation `φ` := nat.totient\n\nprivate lemma card_order_of_eq_totient_aux₁ :\n  ∀ {d : ℕ}, d ∣ fintype.card α → 0 < (univ.filter (λ a : α, order_of a = d)).card →\n  (univ.filter (λ a : α, order_of a = d)).card = φ d\n| 0     := λ hd hd0, absurd hd0 (mt card_pos.1\n  (by simp [finset.ext, nat.pos_iff_ne_zero.1 (order_of_pos _)]))\n| (d+1) := λ hd hd0,\nlet ⟨a, ha⟩ := exists_mem_of_ne_empty (card_pos.1 hd0) in\nhave ha : order_of a = d.succ, from (mem_filter.1 ha).2,\nhave h : ((range d.succ).filter (∣ d.succ)).sum\n    (λ m, (univ.filter (λ a : α, order_of a = m)).card) =\n    ((range d.succ).filter (∣ d.succ)).sum φ, from\n  finset.sum_congr rfl\n    (λ m hm, have hmd : m < d.succ, from mem_range.1 (mem_filter.1 hm).1,\n      have hm : m ∣ d.succ, from (mem_filter.1 hm).2,\n      card_order_of_eq_totient_aux₁ (dvd.trans hm hd) (finset.card_pos.2\n        (ne_empty_of_mem (show a ^ (d.succ / m) ∈ _,\n          from mem_filter.2 ⟨mem_univ _,\n          by rw [order_of_pow, ha, gcd_eq_right (div_dvd_of_dvd hm),\n            nat.div_div_self hm (succ_pos _)]⟩)))),\nhave hinsert : insert d.succ ((range d.succ).filter (∣ d.succ))\n    = (range d.succ.succ).filter (∣ d.succ),\n  from (finset.ext.2 $ λ x, ⟨λ h, (mem_insert.1 h).elim (λ h, by simp [h, range_succ])\n    (by clear _let_match; simp [range_succ]; tauto), by clear _let_match; simp [range_succ] {contextual := tt}; tauto⟩),\nhave hinsert₁ : d.succ ∉ (range d.succ).filter (∣ d.succ),\n  by simp [mem_range, zero_le_one, le_succ],\n(add_right_inj (((range d.succ).filter (∣ d.succ)).sum\n  (λ m, (univ.filter (λ a : α, order_of a = m)).card))).1\n  (calc _ = (insert d.succ (filter (∣ d.succ) (range d.succ))).sum\n        (λ m, (univ.filter (λ a : α, order_of a = m)).card) :\n    eq.symm (finset.sum_insert (by simp [mem_range, zero_le_one, le_succ]))\n  ... = ((range d.succ.succ).filter (∣ d.succ)).sum (λ m,\n      (univ.filter (λ a : α, order_of a = m)).card) :\n    sum_congr hinsert (λ _ _, rfl)\n  ... = (univ.filter (λ a : α, a ^ d.succ = 1)).card :\n    sum_card_order_of_eq_card_pow_eq_one (succ_pos d)\n  ... = ((range d.succ.succ).filter (∣ d.succ)).sum φ :\n    ha ▸ (card_pow_eq_one_eq_order_of_aux hn a).symm ▸ (sum_totient _).symm\n  ... = _ : by rw [h, ← sum_insert hinsert₁];\n      exact finset.sum_congr hinsert.symm (λ _ _, rfl))\n\nlemma card_order_of_eq_totient_aux₂ {d : ℕ} (hd : d ∣ fintype.card α) :\n  (univ.filter (λ a : α, order_of a = d)).card = φ d :=\nby_contradiction $ λ h,\nhave h0 : (univ.filter (λ a : α , order_of a = d)).card = 0 :=\n  not_not.1 (mt nat.pos_iff_ne_zero.2 (mt (card_order_of_eq_totient_aux₁ hn hd) h)),\nlet c := fintype.card α in\nhave hc0 : 0 < c, from fintype.card_pos_iff.2 ⟨1⟩,\nlt_irrefl c $\n  calc c = (univ.filter (λ a : α, a ^ c = 1)).card :\n    congr_arg card $ by simp [finset.ext, c]\n  ... = ((range c.succ).filter (∣ c)).sum\n      (λ m, (univ.filter (λ a : α, order_of a = m)).card) :\n    (sum_card_order_of_eq_card_pow_eq_one hc0).symm\n  ... = (((range c.succ).filter (∣ c)).erase d).sum\n      (λ m, (univ.filter (λ a : α, order_of a = m)).card) :\n    eq.symm (sum_subset (erase_subset _ _) (λ m hm₁ hm₂,\n      have m = d, by simp at *; cc,\n      by simp [*, finset.ext] at *; exact h0))\n  ... ≤ (((range c.succ).filter (∣ c)).erase d).sum φ :\n    sum_le_sum (λ m hm,\n      have hmc : m ∣ c, by simp at hm; tauto,\n      (imp_iff_not_or.1 (card_order_of_eq_totient_aux₁ hn hmc)).elim\n        (λ h, by simp [nat.le_zero_iff.1 (le_of_not_gt h), nat.zero_le])\n        (by simp [le_refl] {contextual := tt}))\n  ... < φ d + (((range c.succ).filter (∣ c)).erase d).sum φ :\n    lt_add_of_pos_left _ (totient_pos (nat.pos_of_ne_zero\n      (λ h, nat.pos_iff_ne_zero.1 hc0 (eq_zero_of_zero_dvd $ h ▸ hd))))\n  ... = (insert d (((range c.succ).filter (∣ c)).erase d)).sum φ : eq.symm (sum_insert (by simp))\n  ... = ((range c.succ).filter (∣ c)).sum φ : finset.sum_congr\n      (finset.insert_erase (mem_filter.2 ⟨mem_range.2 (lt_succ_of_le (le_of_dvd hc0 hd)), hd⟩)) (λ _ _, rfl)\n  ... = c : sum_totient _\n\nlemma is_cyclic_of_card_pow_eq_one_le : is_cyclic α :=\nhave ∃ x, x ∈ univ.filter (λ a : α, order_of a = fintype.card α),\nfrom exists_mem_of_ne_empty (card_pos.1 $\n  by rw [card_order_of_eq_totient_aux₂ hn (dvd_refl _)];\n  exact totient_pos (fintype.card_pos_iff.2 ⟨1⟩)),\nlet ⟨x, hx⟩ := this in\nis_cyclic_of_order_of_eq_card x (finset.mem_filter.1 hx).2\n\nend totient\n\nlemma is_cyclic.card_order_of_eq_totient [group α] [is_cyclic α] [fintype α] [decidable_eq α]\n  {d : ℕ} (hd : d ∣ fintype.card α) : (univ.filter (λ a : α, order_of a = d)).card = totient d :=\ncard_order_of_eq_totient_aux₂ (λ n, is_cyclic.card_pow_eq_one_le) hd\n\nend cyclic\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/group_theory/order_of_element.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6654105454764747, "lm_q1q2_score": 0.4696367921263317}}
{"text": "import data.fintype.basic\nimport data.set.lattice\nimport DFA\n\nuniverses u v\n\nvariable {α : Type}\n\nstructure NFA (alphabet : Type u) := \n[alphabet_fintype : fintype alphabet]\n(state : Type v)\n[state_fintype : fintype state]\n[state_dec : decidable_eq state]\n(step : state → alphabet → finset state)\n(start : finset state)\n(accept_states : finset state)\nnamespace NFA\n\n-- @[reducible] def start_dec (M : NFA α) := decidable_pred M.start\n-- @[reducible] def step_dec (M : NFA α) := Π (S : M.state) (a : α), decidable_pred (M.step S a)\n-- instance dec₁ (M : NFA α) := M.start_dec\n-- instance dec₂ (M : NFA α) := M.step_dec\n-- instance dec₃ (M : NFA α) := M.accept_dec\ninstance dec (M : NFA α) := M.state_dec\n\ninstance fin₁ (M : NFA α) := M.alphabet_fintype\ninstance fin₂ (M : NFA α) := M.state_fintype\n\ndef step_set (M : NFA α) : finset M.state → α → finset M.state :=\nλ Ss a, finset.bind Ss (λ S, (M.step S a))\n\ndef eval (M : NFA α) : list α → finset M.state := list.foldl M.step_set M.start\n\ndef accepts (M : NFA α) (s : list α) : Prop :=\n∃ S ∈ M.accept_states, S ∈ M.eval s\n\ndef NFA_of_DFA (M : DFA α) : NFA α :=\n{ alphabet_fintype := M.alphabet_fintype,\n  state := M.state,\n  state_fintype := M.state_fintype,\n  step := λ S a, {M.step S a},\n  start := {M.start},\n  accept_states := M.accept_states }\n\nlemma NFA_of_DFA_eval_match (M : DFA α) [decidable_eq M.state] (s : list α) :\n  {M.eval s} = (NFA_of_DFA M).eval s :=\nbegin\n  change {list.foldl M.step M.start s} = list.foldl (NFA_of_DFA M).step_set {M.start} s,\n  generalize : M.start = start,\n  revert start,\n  induction s with a s ih,\n  { tauto },\n  { intro start,\n    rw [list.foldl, list.foldl],\n    have : (NFA_of_DFA M).step_set {start} a = {M.step start a},\n    { rw step_set,\n      finish },\n    rw this,\n    tauto }\nend\n\nlemma NFA_of_DFA_correct (M : DFA α) (s : list α) :\n  M.accepts s ↔ (NFA_of_DFA M).accepts s :=\nbegin\n  rw [accepts, DFA.accepts, ←NFA_of_DFA_eval_match],\n  split,\n  { intro h,\n    use M.eval s,\n    finish },\n  { rintro ⟨ S, hS₁, hS₂ ⟩,\n    rw finset.mem_singleton at hS₂,\n    rw hS₂ at hS₁,\n    assumption }\nend\n\ndef DFA_of_NFA (M : NFA α) : DFA α :=\n{ alphabet_fintype := M.alphabet_fintype,\n  state := finset M.state,\n  step := M.step_set,\n  start := M.start,\n  accept_states := finset.univ.filter (λ S, ∃ s ∈ S, s ∈ M.accept_states) }\n\nlemma DFA_of_NFA_correct (M : NFA α) (s : list α) :\n  M.accepts s ↔ M.DFA_of_NFA.accepts s :=\nbegin\n  rw [accepts, DFA.accepts, eval, DFA.eval],\n  change (∃ (S : M.state) (H : S ∈ M.accept_states), S ∈ list.foldl M.step_set M.start s) ↔ list.foldl M.step_set M.start s ∈ finset.univ.filter (λ S : finset M.state, ∃ s ∈ S, s ∈ M.accept_states),\n  rw finset.mem_filter,\n  finish\nend\n\nend NFA\n\nstructure ε_NFA (alphabet : Type u) :=\n[alphabet_fintype : fintype alphabet]\n(state : Type v)\n[state_fintype : fintype state]\n[state_dec : decidable_eq state]\n(step : state → option alphabet → finset state)\n(start : finset state)\n(accept_states : finset state)\n\nnamespace ε_NFA\n\ninstance dec (M : ε_NFA α) := M.state_dec\n\ninstance fin₁ (M : ε_NFA α) : fintype α := M.alphabet_fintype\ninstance fin₂ (M : ε_NFA α) : fintype M.state := M.state_fintype\n\ndef step_set' (M : ε_NFA α) : finset M.state → option α → finset M.state :=\nλ Ss a, finset.bind Ss (λ S, M.step S a)\n\ninductive ε_closure_set (M : ε_NFA α) (Ss : finset M.state) : M.state → Prop\n| base : ∀ (S ∈ Ss), ε_closure_set S\n| step : ∀ S T, ε_closure_set S → T ∈ M.step S option.none → ε_closure_set T\n\ndef sub_of_compl {β : Type u} [fintype β] [decidable_eq β] : ∀ T U : finset β, Tᶜ ⊆ Uᶜ → U ⊆ T :=\nbegin\n  intros T U h x hxU,\n  by_contra hTc,\n  rw ←finset.mem_compl at hTc,\n  have hUc := finset.mem_of_subset h hTc,\n  finish\nend\n\ninstance ε_NFA_has_well_founded {β : Type u} [fintype β] [decidable_eq β] : has_well_founded (finset β) :=\n{ r := (λ S₁ S₂ : finset β, S₁ᶜ < S₂ᶜ), \n  wf := \n  inv_image.wf _ finset.lt_wf } \n\ndef ε_closure (M : ε_NFA α) : finset M.state → finset M.state\n| S :=\nbegin\n  let S' := S ∪ M.step_set' S none,\n  by_cases heq : S' = S,\n  { exact S },\n  { let : S'ᶜ < Sᶜ,\n    { have hsub : S'ᶜ ⊆ Sᶜ,\n      { intros s hs,\n        rw finset.mem_compl at hs ⊢,\n        finish },\n      use hsub,\n      { intro hS,\n        apply heq, \n        rw finset.subset.antisymm_iff,\n        split;\n        apply sub_of_compl;\n        assumption } }, \n    exact ε_closure S' }\nend\nusing_well_founded {dec_tac := tactic.assumption}\n\nlemma step_set'_wf (M : ε_NFA α) (S : finset M.state) (hneq : S ∪ M.step_set' S none ≠ S) :\n  (S ∪ M.step_set' S none)ᶜ < Sᶜ :=\nbegin\n  have hsub : (S ∪ M.step_set' S none)ᶜ ⊆ Sᶜ,\n  { intros s hs,\n    rw finset.mem_compl at hs ⊢,\n    finish },\n  use hsub,\n  intro hS,\n  apply hneq, \n  rw finset.subset.antisymm_iff,\n  split;\n  apply sub_of_compl,\n  assumption'\nend\n\nlemma ε_closure_equiv_ε_closure_set (M : ε_NFA α) :\n  Π (S : finset M.state) (s : M.state), s ∈ M.ε_closure S ↔ M.ε_closure_set S s\n| S :=\nbegin\n  have IH := λ T (h : Tᶜ < Sᶜ), ε_closure_equiv_ε_closure_set T,\n  intro s,\n  split,\n  { intro h,\n    rw ε_closure at h,\n    dsimp at h,\n    split_ifs at h with heq,\n    { apply ε_closure_set.base,\n      assumption },\n    { have hwf : (S ∪ M.step_set' S none)ᶜ < Sᶜ := M.step_set'_wf S heq,\n      have h' : M.ε_closure_set (S ∪ M.step_set' S none) s,\n        rwa ← IH (S ∪ M.step_set' S none) hwf,\n      induction h' with t ht t' t d e ih,\n      { simp at ht,\n        cases ht,\n        { apply ε_closure_set.base,\n          assumption },\n        { rw step_set' at ht,\n          simp only [exists_prop, finset.mem_bind] at ht,\n          cases ht with t' ht,\n          apply ε_closure_set.step t' t,\n          { apply ε_closure_set.base,\n            tauto },\n          { tauto } } },\n      { apply ε_closure_set.step t' t,\n        { apply ih,\n          rwa IH (S ∪ M.step_set' S none) hwf },\n        assumption } } },\n  { intro h,\n    rw ε_closure,\n    dsimp,\n    split_ifs with heq;\n    induction h with t ht t' t ht' ht ih,\n    { assumption },\n    { rw ←heq,\n      simp only [finset.mem_union],\n      right,\n      rw step_set',\n      simp only [exists_prop, finset.mem_bind],\n      use t',\n      tauto },\n    all_goals\n    { have hwf : (S ∪ M.step_set' S none)ᶜ < Sᶜ := M.step_set'_wf S heq },\n    { rw IH (S ∪ M.step_set' S none) hwf,\n      apply ε_closure_set.base,\n      rw finset.mem_union,\n      left,\n      assumption },\n    { rw IH (S ∪ M.step_set' S none) hwf,\n      apply ε_closure_set.step t' t,\n      rwa ←IH (S ∪ M.step_set' S none) hwf,\n      assumption } }\nend\nusing_well_founded {dec_tac := tactic.assumption}\n\ndef step_set (M : ε_NFA α) : finset M.state → α → finset M.state :=\nλ Ss a, M.ε_closure $ finset.bind Ss (λ S, M.step S (option.some a))\n\ndef eval (M : ε_NFA α) : list α → finset M.state := \n  list.foldl M.step_set (M.ε_closure M.start)\n\ndef accepts (M : ε_NFA α) (s : list α) : Prop :=\n∃ S ∈ M.accept_states, S ∈ M.eval s\n\ninstance accepts_dec (M : ε_NFA α) : decidable_pred M.accepts :=\nbegin\n  intro s,\n  exact fintype.decidable_exists_fintype\nend\n\ndef NFA_of_ε_NFA (M : ε_NFA α) : NFA α :=\n{ alphabet_fintype := M.alphabet_fintype,\n  state := M.state,\n  step := λ S a, M.ε_closure (M.step S (some a)),\n  start := M.ε_closure M.start,\n  accept_states := M.accept_states }\n\nlemma NFA_of_ε_NFA_step_set_match (M : ε_NFA α) (Ss : finset M.state) (a : α) :\n  M.step_set Ss a = M.NFA_of_ε_NFA.step_set Ss a :=\nbegin\n  rw [step_set, NFA.step_set],\n  simp,\n  ext b,\n  rw ε_closure_equiv_ε_closure_set,\n  split,\n  { intro h,\n    -- generalize_hyp hT : (Ss.bind (λ (S : M.state), M.step S (some a))) = Ts at h,\n    induction h with s h U T hU h ih,\n    { \n      -- rw ←hT at h,\n      simp only [exists_prop, finset.mem_bind] at h ⊢,\n      cases h with i hi,\n      rw @finset.mem_bind _ M.state M.state_dec,\n      use i,\n      use hi.1,\n      change s ∈ M.ε_closure (M.step i (some a)),\n      rw ε_closure_equiv_ε_closure_set,\n      apply ε_closure_set.base,\n      tauto },\n    { rw @finset.mem_bind _ M.state M.state_dec at ⊢ ih,\n      rcases ih with ⟨ i, h₁, h₂ ⟩,\n      existsi i,\n      existsi h₁,\n      change T ∈ M.ε_closure (M.step i (some a)),\n      rw ε_closure_equiv_ε_closure_set,\n      apply ε_closure_set.step U _,\n      change U ∈ M.ε_closure (M.step _ (some _)) at h₂,\n      rw ←ε_closure_equiv_ε_closure_set,\n      assumption' } },\n  { rw @finset.mem_bind _ M.state M.state_dec,\n    rintro ⟨ s, hsSs, hba ⟩,\n    change b ∈ M.ε_closure (M.step _ (some _)) at hba,\n    rw ε_closure_equiv_ε_closure_set at hba,\n    induction hba with s h U T hU h ih,\n    { apply ε_closure_set.base,\n      finish },\n    { specialize ih,\n      apply ε_closure_set.step,\n      assumption' } }\nend\n\nlemma NFA_of_ε_NFA_eval_match (M : ε_NFA α) (s : list α) :\n  M.eval s = (NFA_of_ε_NFA M).eval s :=\nbegin\n  change list.foldl M.step_set (M.ε_closure M.start) s = list.foldl M.NFA_of_ε_NFA.step_set (M.ε_closure M.start) s,\n  congr,\n  ext1,\n  ext1,\n  rw NFA_of_ε_NFA_step_set_match\nend\n\nlemma NFA_of_ε_NFA_correct (M : ε_NFA α) (s : list α) :\n  M.accepts s ↔ M.NFA_of_ε_NFA.accepts s :=\nbegin\n  rw [accepts, NFA.accepts, NFA_of_ε_NFA_eval_match],\n  tauto\nend\n\nend ε_NFA\n", "meta": {"author": "foxthomson", "repo": "regular", "sha": "6c7c691eb226eb0e33a0995b027ba8641f1611bf", "save_path": "github-repos/lean/foxthomson-regular", "path": "github-repos/lean/foxthomson-regular/regular-6c7c691eb226eb0e33a0995b027ba8641f1611bf/src/NFA.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.46960959084594533}}
{"text": "-- main theorem: add_iter_sound\nimport algebra\nimport combinators\nimport add_monotonic\nimport add_finite\n\nnamespace iter\n\nsection params_unary\nvariables {σ I V : Type} [linear_order I]\nvariables (s t : σ) {a : iter σ I V}\n\nsection semantics\nvariables [add_monoid V]\n\n@[simp] lemma terminal_semantics₁_zero (h : a.terminal t) : a.semantics₁ t = 0 := by simp *\n\n@[simp]\ntheorem terminal_zero {t} {a : iter σ I V} (m : a.monotonic) (h : a.terminal t) (j:ℕ) : a.semantics t j = 0 := begin\ninduction j with _ jh generalizing t,\nall_goals {simp *}\nend\n\nlemma succ_of_ge_succ : ∀ {i i' : ℕ}, i.succ ≤ i' → ∃ i'':ℕ, i' = i''.succ\n| i (nat.succ i'') hle := ⟨_, rfl⟩\n\ntheorem semantics_mono {i i'} {s} : a.monotonic → a.terminal_by s i → i ≤ i' → a.semantics s i = a.semantics s i' := λ mono fin hle, begin\ninduction i with i hi generalizing i' s,\n{ simp * at * },\nobtain ⟨i'', h1⟩ := succ_of_ge_succ hle,\nrw h1 at *,\nsimp only [semantics],\nhave : i ≤ i'' := nat.le_of_succ_le_succ hle,\nrw hi (step_progress fin) this,\nend\n\nend semantics\nend params_unary\n\nsection params_binary\n\nvariables {σ₁ σ₂ I V : Type} [linear_order I] [decidable_eq σ₁] [decidable_eq σ₂] [add_comm_monoid V]\n{a : iter σ₁ I V} {b : iter σ₂ I V}\n{s₁ : σ₁} {s₂ : σ₂}\n\ntheorem add_iter_sound {i j}\n: a.monotonic → b.monotonic → a.terminal_by s₁ i → b.terminal_by s₂ j →\n  (a +' b).semantics (s₁,s₂) (i+j) = a.semantics s₁ i + b.semantics s₂ j :=\nλ amono bmono afin bfin, begin\ngeneralize hnij : i+j = n,\ninduction n with n hn generalizing s₁ s₂ i j,\n{ obtain ⟨i0, j0⟩ := sum_zero.1 hnij.symm,\n  simp only [*, semantics, sum_zero, add_zero],\n},\n\nobtain (⟨hs,nta,h⟩|⟨hs,ntdi,h⟩|⟨hs,ntb,h⟩) := step_sem_trichotomy a b s₁ s₂,\n\n{ -- a.δ\n  obtain ⟨i', hisucc⟩ := not_terminal_succ nta afin,\n  rw hisucc at *,\n  simp only [semantics],\n  rw [hs,h],\n  rw hn (step_progress afin) bfin _,\n  { rw add_assoc },\n  { simp [*, nat.succ_add] at * },\n},\n\n{ -- a.δ, b.δ\n  obtain (⟨ta, tb⟩|⟨nta,ntb⟩) := ntdi,\n\n  { simp only [*, terminal_zero, add_zero, add_iter_monotonic, add_iter_terminal] },\n\n  { obtain ⟨i', hisucc⟩ := not_terminal_succ nta afin,\n    obtain ⟨j', hjsucc⟩ := not_terminal_succ ntb bfin,\n    simp only [hisucc, hjsucc] at *,\n    simp only [semantics, hs, h],\n    replace afin := step_progress afin,\n    rw semantics_mono amono afin (nat.le_succ _),\n    have afin' := terminal_by_mono i' i'.succ amono afin (nat.le_succ _),\n    have := hn afin' (step_progress bfin) (nat.succ.inj hnij),\n    rw this,\n    abel,\n  },\n},\n\n{ -- b.δ\n  obtain ⟨j', hjsucc⟩ := not_terminal_succ ntb bfin,\n  rw hjsucc at *,\n  simp only [iter.semantics],\n  rw [hs, h],\n  rw hn afin (step_progress bfin) _,\n  { abel },\n  { simp [*, nat.add_succ] at * },\n},\nend\n\nvariables (u : stream σ₁ I V) (v : stream σ₂ I V)\n\ntheorem add_stream_sound  {i j} : u.monotonic → v.monotonic → u.terminal_by i → v.terminal_by j →\n⟦mk_add u v, i+j⟧ = ⟦u, i⟧ + ⟦v, j⟧ := add_iter_sound\n\nend params_binary\nend iter\n", "meta": {"author": "kovach", "repo": "etch", "sha": "26ef67eb83cf7c5cfd1667059e16c3873b9098ca", "save_path": "github-repos/lean/kovach-etch", "path": "github-repos/lean/kovach-etch/etch-26ef67eb83cf7c5cfd1667059e16c3873b9098ca/src/old_formalization/add_semantics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4696095908459453}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Filippo A. E. Nuccio\n\n! This file was ported from Lean 3 source module ring_theory.fractional_ideal\n! leanprover-community/mathlib commit ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.BigOperators.Finprod\nimport Mathbin.RingTheory.IntegralClosure\nimport Mathbin.RingTheory.Localization.Integer\nimport Mathbin.RingTheory.Localization.Submodule\nimport Mathbin.RingTheory.Noetherian\nimport Mathbin.RingTheory.PrincipalIdealDomain\nimport Mathbin.Tactic.FieldSimp\n\n/-!\n# Fractional ideals\n\nThis file defines fractional ideals of an integral domain and proves basic facts about them.\n\n## Main definitions\nLet `S` be a submonoid of an integral domain `R`, `P` the localization of `R` at `S`, and `f` the\nnatural ring hom from `R` to `P`.\n * `is_fractional` defines which `R`-submodules of `P` are fractional ideals\n * `fractional_ideal S P` is the type of fractional ideals in `P`\n * `has_coe_t (ideal R) (fractional_ideal S P)` instance\n * `comm_semiring (fractional_ideal S P)` instance:\n   the typical ideal operations generalized to fractional ideals\n * `lattice (fractional_ideal S P)` instance\n * `map` is the pushforward of a fractional ideal along an algebra morphism\n\nLet `K` be the localization of `R` at `R⁰ = R \\ {0}` (i.e. the field of fractions).\n * `fractional_ideal R⁰ K` is the type of fractional ideals in the field of fractions\n * `has_div (fractional_ideal R⁰ K)` instance:\n   the ideal quotient `I / J` (typically written $I : J$, but a `:` operator cannot be defined)\n\n## Main statements\n\n  * `mul_left_mono` and `mul_right_mono` state that ideal multiplication is monotone\n  * `prod_one_self_div_eq` states that `1 / I` is the inverse of `I` if one exists\n  * `is_noetherian` states that every fractional ideal of a noetherian integral domain is noetherian\n\n## Implementation notes\n\nFractional ideals are considered equal when they contain the same elements,\nindependent of the denominator `a : R` such that `a I ⊆ R`.\nThus, we define `fractional_ideal` to be the subtype of the predicate `is_fractional`,\ninstead of having `fractional_ideal` be a structure of which `a` is a field.\n\nMost definitions in this file specialize operations from submodules to fractional ideals,\nproving that the result of this operation is fractional if the input is fractional.\nExceptions to this rule are defining `(+) := (⊔)` and `⊥ := 0`,\nin order to re-use their respective proof terms.\nWe can still use `simp` to show `↑I + ↑J = ↑(I + J)` and `↑⊥ = ↑0`.\n\nMany results in fact do not need that `P` is a localization, only that `P` is an\n`R`-algebra. We omit the `is_localization` parameter whenever this is practical.\nSimilarly, we don't assume that the localization is a field until we need it to\ndefine ideal quotients. When this assumption is needed, we replace `S` with `R⁰`,\nmaking the localization a field.\n\n## References\n\n  * https://en.wikipedia.org/wiki/Fractional_ideal\n\n## Tags\n\nfractional ideal, fractional ideals, invertible ideal\n-/\n\n\nopen IsLocalization\n\nopen Pointwise\n\nopen nonZeroDivisors\n\nsection Defs\n\nvariable {R : Type _} [CommRing R] {S : Submonoid R} {P : Type _} [CommRing P]\n\nvariable [Algebra R P]\n\nvariable (S)\n\n/-- A submodule `I` is a fractional ideal if `a I ⊆ R` for some `a ≠ 0`. -/\ndef IsFractional (I : Submodule R P) :=\n  ∃ a ∈ S, ∀ b ∈ I, IsInteger R (a • b)\n#align is_fractional IsFractional\n\nvariable (S P)\n\n/-- The fractional ideals of a domain `R` are ideals of `R` divided by some `a ∈ R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I ⊆ P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I ⊆ R`.\n-/\ndef FractionalIdeal :=\n  { I : Submodule R P // IsFractional S I }\n#align fractional_ideal FractionalIdeal\n\nend Defs\n\nnamespace FractionalIdeal\n\nopen Set\n\nopen Submodule\n\nvariable {R : Type _} [CommRing R] {S : Submonoid R} {P : Type _} [CommRing P]\n\nvariable [Algebra R P] [loc : IsLocalization S P]\n\n/-- Map a fractional ideal `I` to a submodule by forgetting that `∃ a, a I ⊆ R`.\n\nThis coercion is typically called `coe_to_submodule` in lemma names\n(or `coe` when the coercion is clear from the context),\nnot to be confused with `is_localization.coe_submodule : ideal R → submodule R P`\n(which we use to define `coe : ideal R → fractional_ideal S P`).\n-/\ninstance : Coe (FractionalIdeal S P) (Submodule R P) :=\n  ⟨fun I => I.val⟩\n\nprotected theorem isFractional (I : FractionalIdeal S P) : IsFractional S (I : Submodule R P) :=\n  I.Prop\n#align fractional_ideal.is_fractional FractionalIdeal.isFractional\n\nsection SetLike\n\ninstance : SetLike (FractionalIdeal S P) P\n    where\n  coe I := ↑(I : Submodule R P)\n  coe_injective' := SetLike.coe_injective.comp Subtype.coe_injective\n\n@[simp]\ntheorem mem_coe {I : FractionalIdeal S P} {x : P} : x ∈ (I : Submodule R P) ↔ x ∈ I :=\n  Iff.rfl\n#align fractional_ideal.mem_coe FractionalIdeal.mem_coe\n\n@[ext]\ntheorem ext {I J : FractionalIdeal S P} : (∀ x, x ∈ I ↔ x ∈ J) → I = J :=\n  SetLike.ext\n#align fractional_ideal.ext FractionalIdeal.ext\n\n/-- Copy of a `fractional_ideal` with a new underlying set equal to the old one.\nUseful to fix definitional equalities. -/\nprotected def copy (p : FractionalIdeal S P) (s : Set P) (hs : s = ↑p) : FractionalIdeal S P :=\n  ⟨Submodule.copy p s hs, by\n    convert p.is_fractional\n    ext\n    simp only [hs]\n    rfl⟩\n#align fractional_ideal.copy FractionalIdeal.copy\n\n@[simp]\ntheorem coe_copy (p : FractionalIdeal S P) (s : Set P) (hs : s = ↑p) : ↑(p.copy s hs) = s :=\n  rfl\n#align fractional_ideal.coe_copy FractionalIdeal.coe_copy\n\ntheorem coe_eq (p : FractionalIdeal S P) (s : Set P) (hs : s = ↑p) : p.copy s hs = p :=\n  SetLike.coe_injective hs\n#align fractional_ideal.coe_eq FractionalIdeal.coe_eq\n\nend SetLike\n\n@[simp]\ntheorem val_eq_coe (I : FractionalIdeal S P) : I.val = I :=\n  rfl\n#align fractional_ideal.val_eq_coe FractionalIdeal.val_eq_coe\n\n@[simp, norm_cast]\ntheorem coe_mk (I : Submodule R P) (hI : IsFractional S I) :\n    (Subtype.mk I hI : Submodule R P) = I :=\n  rfl\n#align fractional_ideal.coe_mk FractionalIdeal.coe_mk\n\n/-! Transfer instances from `submodule R P` to `fractional_ideal S P`. -/\n\n\ninstance (I : FractionalIdeal S P) : AddCommGroup I :=\n  Submodule.addCommGroup ↑I\n\ninstance (I : FractionalIdeal S P) : Module R I :=\n  Submodule.module ↑I\n\ntheorem coe_to_submodule_injective :\n    Function.Injective (coe : FractionalIdeal S P → Submodule R P) :=\n  Subtype.coe_injective\n#align fractional_ideal.coe_to_submodule_injective FractionalIdeal.coe_to_submodule_injective\n\ntheorem coe_to_submodule_inj {I J : FractionalIdeal S P} : (I : Submodule R P) = J ↔ I = J :=\n  coe_to_submodule_injective.eq_iff\n#align fractional_ideal.coe_to_submodule_inj FractionalIdeal.coe_to_submodule_inj\n\ntheorem isFractional_of_le_one (I : Submodule R P) (h : I ≤ 1) : IsFractional S I :=\n  by\n  use 1, S.one_mem\n  intro b hb\n  rw [one_smul]\n  obtain ⟨b', b'_mem, rfl⟩ := h hb\n  exact Set.mem_range_self b'\n#align fractional_ideal.is_fractional_of_le_one FractionalIdeal.isFractional_of_le_one\n\ntheorem isFractional_of_le {I : Submodule R P} {J : FractionalIdeal S P} (hIJ : I ≤ J) :\n    IsFractional S I := by\n  obtain ⟨a, a_mem, ha⟩ := J.is_fractional\n  use a, a_mem\n  intro b b_mem\n  exact ha b (hIJ b_mem)\n#align fractional_ideal.is_fractional_of_le FractionalIdeal.isFractional_of_le\n\n-- Is a `coe_t` rather than `coe` to speed up failing inference, see library note [use has_coe_t]\n/-- Map an ideal `I` to a fractional ideal by forgetting `I` is integral.\n\nThis is a bundled version of `is_localization.coe_submodule : ideal R → submodule R P`,\nwhich is not to be confused with the `coe : fractional_ideal S P → submodule R P`,\nalso called `coe_to_submodule` in theorem names.\n\nThis map is available as a ring hom, called `fractional_ideal.coe_ideal_hom`.\n-/\ninstance : CoeTC (Ideal R) (FractionalIdeal S P) :=\n  ⟨fun I =>\n    ⟨coeSubmodule P I,\n      isFractional_of_le_one _ <| by simpa using coe_submodule_mono P (le_top : I ≤ ⊤)⟩⟩\n\n@[simp, norm_cast]\ntheorem coe_coe_ideal (I : Ideal R) :\n    ((I : FractionalIdeal S P) : Submodule R P) = coeSubmodule P I :=\n  rfl\n#align fractional_ideal.coe_coe_ideal FractionalIdeal.coe_coe_ideal\n\nvariable (S)\n\n@[simp]\ntheorem mem_coe_ideal {x : P} {I : Ideal R} :\n    x ∈ (I : FractionalIdeal S P) ↔ ∃ x', x' ∈ I ∧ algebraMap R P x' = x :=\n  mem_coeSubmodule _ _\n#align fractional_ideal.mem_coe_ideal FractionalIdeal.mem_coe_ideal\n\ntheorem mem_coe_ideal_of_mem {x : R} {I : Ideal R} (hx : x ∈ I) :\n    algebraMap R P x ∈ (I : FractionalIdeal S P) :=\n  (mem_coe_ideal S).mpr ⟨x, hx, rfl⟩\n#align fractional_ideal.mem_coe_ideal_of_mem FractionalIdeal.mem_coe_ideal_of_mem\n\ntheorem coe_ideal_le_coe_ideal' [IsLocalization S P] (h : S ≤ nonZeroDivisors R) {I J : Ideal R} :\n    (I : FractionalIdeal S P) ≤ J ↔ I ≤ J :=\n  coeSubmodule_le_coeSubmodule h\n#align fractional_ideal.coe_ideal_le_coe_ideal' FractionalIdeal.coe_ideal_le_coe_ideal'\n\n@[simp]\ntheorem coe_ideal_le_coe_ideal (K : Type _) [CommRing K] [Algebra R K] [IsFractionRing R K]\n    {I J : Ideal R} : (I : FractionalIdeal R⁰ K) ≤ J ↔ I ≤ J :=\n  IsFractionRing.coeSubmodule_le_coeSubmodule\n#align fractional_ideal.coe_ideal_le_coe_ideal FractionalIdeal.coe_ideal_le_coe_ideal\n\ninstance : Zero (FractionalIdeal S P) :=\n  ⟨(0 : Ideal R)⟩\n\n@[simp]\ntheorem mem_zero_iff {x : P} : x ∈ (0 : FractionalIdeal S P) ↔ x = 0 :=\n  ⟨fun ⟨x', x'_mem_zero, x'_eq_x⟩ =>\n    by\n    have x'_eq_zero : x' = 0 := x'_mem_zero\n    simp [x'_eq_x.symm, x'_eq_zero], fun hx => ⟨0, rfl, by simp [hx]⟩⟩\n#align fractional_ideal.mem_zero_iff FractionalIdeal.mem_zero_iff\n\nvariable {S}\n\n@[simp, norm_cast]\ntheorem coe_zero : ↑(0 : FractionalIdeal S P) = (⊥ : Submodule R P) :=\n  Submodule.ext fun _ => mem_zero_iff S\n#align fractional_ideal.coe_zero FractionalIdeal.coe_zero\n\n@[simp, norm_cast]\ntheorem coe_ideal_bot : ((⊥ : Ideal R) : FractionalIdeal S P) = 0 :=\n  rfl\n#align fractional_ideal.coe_ideal_bot FractionalIdeal.coe_ideal_bot\n\nvariable (P)\n\ninclude loc\n\n@[simp]\ntheorem exists_mem_to_map_eq {x : R} {I : Ideal R} (h : S ≤ nonZeroDivisors R) :\n    (∃ x', x' ∈ I ∧ algebraMap R P x' = algebraMap R P x) ↔ x ∈ I :=\n  ⟨fun ⟨x', hx', Eq⟩ => IsLocalization.injective _ h Eq ▸ hx', fun h => ⟨x, h, rfl⟩⟩\n#align fractional_ideal.exists_mem_to_map_eq FractionalIdeal.exists_mem_to_map_eq\n\nvariable {P}\n\ntheorem coe_ideal_injective' (h : S ≤ nonZeroDivisors R) :\n    Function.Injective (coe : Ideal R → FractionalIdeal S P) := fun _ _ h' =>\n  ((coe_ideal_le_coe_ideal' S h).mp h'.le).antisymm ((coe_ideal_le_coe_ideal' S h).mp h'.ge)\n#align fractional_ideal.coe_ideal_injective' FractionalIdeal.coe_ideal_injective'\n\ntheorem coe_ideal_inj' (h : S ≤ nonZeroDivisors R) {I J : Ideal R} :\n    (I : FractionalIdeal S P) = J ↔ I = J :=\n  (coe_ideal_injective' h).eq_iff\n#align fractional_ideal.coe_ideal_inj' FractionalIdeal.coe_ideal_inj'\n\n@[simp]\ntheorem coe_ideal_eq_zero' {I : Ideal R} (h : S ≤ nonZeroDivisors R) :\n    (I : FractionalIdeal S P) = 0 ↔ I = (⊥ : Ideal R) :=\n  coe_ideal_inj' h\n#align fractional_ideal.coe_ideal_eq_zero' FractionalIdeal.coe_ideal_eq_zero'\n\ntheorem coe_ideal_ne_zero' {I : Ideal R} (h : S ≤ nonZeroDivisors R) :\n    (I : FractionalIdeal S P) ≠ 0 ↔ I ≠ (⊥ : Ideal R) :=\n  not_iff_not.mpr <| coe_ideal_eq_zero' h\n#align fractional_ideal.coe_ideal_ne_zero' FractionalIdeal.coe_ideal_ne_zero'\n\nomit loc\n\ntheorem coe_to_submodule_eq_bot {I : FractionalIdeal S P} : (I : Submodule R P) = ⊥ ↔ I = 0 :=\n  ⟨fun h => coe_to_submodule_injective (by simp [h]), fun h => by simp [h]⟩\n#align fractional_ideal.coe_to_submodule_eq_bot FractionalIdeal.coe_to_submodule_eq_bot\n\ntheorem coe_to_submodule_ne_bot {I : FractionalIdeal S P} : ↑I ≠ (⊥ : Submodule R P) ↔ I ≠ 0 :=\n  not_iff_not.mpr coe_to_submodule_eq_bot\n#align fractional_ideal.coe_to_submodule_ne_bot FractionalIdeal.coe_to_submodule_ne_bot\n\ninstance : Inhabited (FractionalIdeal S P) :=\n  ⟨0⟩\n\ninstance : One (FractionalIdeal S P) :=\n  ⟨(⊤ : Ideal R)⟩\n\nvariable (S)\n\n@[simp, norm_cast]\ntheorem coe_ideal_top : ((⊤ : Ideal R) : FractionalIdeal S P) = 1 :=\n  rfl\n#align fractional_ideal.coe_ideal_top FractionalIdeal.coe_ideal_top\n\ntheorem mem_one_iff {x : P} : x ∈ (1 : FractionalIdeal S P) ↔ ∃ x' : R, algebraMap R P x' = x :=\n  Iff.intro (fun ⟨x', _, h⟩ => ⟨x', h⟩) fun ⟨x', h⟩ => ⟨x', ⟨⟩, h⟩\n#align fractional_ideal.mem_one_iff FractionalIdeal.mem_one_iff\n\ntheorem coe_mem_one (x : R) : algebraMap R P x ∈ (1 : FractionalIdeal S P) :=\n  (mem_one_iff S).mpr ⟨x, rfl⟩\n#align fractional_ideal.coe_mem_one FractionalIdeal.coe_mem_one\n\ntheorem one_mem_one : (1 : P) ∈ (1 : FractionalIdeal S P) :=\n  (mem_one_iff S).mpr ⟨1, RingHom.map_one _⟩\n#align fractional_ideal.one_mem_one FractionalIdeal.one_mem_one\n\nvariable {S}\n\n/-- `(1 : fractional_ideal S P)` is defined as the R-submodule `f(R) ≤ P`.\n\nHowever, this is not definitionally equal to `1 : submodule R P`,\nwhich is proved in the actual `simp` lemma `coe_one`. -/\ntheorem coe_one_eq_coeSubmodule_top : ↑(1 : FractionalIdeal S P) = coeSubmodule P (⊤ : Ideal R) :=\n  rfl\n#align fractional_ideal.coe_one_eq_coe_submodule_top FractionalIdeal.coe_one_eq_coeSubmodule_top\n\n@[simp, norm_cast]\ntheorem coe_one : (↑(1 : FractionalIdeal S P) : Submodule R P) = 1 := by\n  rw [coe_one_eq_coe_submodule_top, coe_submodule_top]\n#align fractional_ideal.coe_one FractionalIdeal.coe_one\n\nsection Lattice\n\n/-!\n### `lattice` section\n\nDefines the order on fractional ideals as inclusion of their underlying sets,\nand ports the lattice structure on submodules to fractional ideals.\n-/\n\n\n@[simp]\ntheorem coe_le_coe {I J : FractionalIdeal S P} :\n    (I : Submodule R P) ≤ (J : Submodule R P) ↔ I ≤ J :=\n  Iff.rfl\n#align fractional_ideal.coe_le_coe FractionalIdeal.coe_le_coe\n\ntheorem zero_le (I : FractionalIdeal S P) : 0 ≤ I :=\n  by\n  intro x hx\n  convert Submodule.zero_mem _\n  simpa using hx\n#align fractional_ideal.zero_le FractionalIdeal.zero_le\n\ninstance orderBot : OrderBot (FractionalIdeal S P)\n    where\n  bot := 0\n  bot_le := zero_le\n#align fractional_ideal.order_bot FractionalIdeal.orderBot\n\n@[simp]\ntheorem bot_eq_zero : (⊥ : FractionalIdeal S P) = 0 :=\n  rfl\n#align fractional_ideal.bot_eq_zero FractionalIdeal.bot_eq_zero\n\n@[simp]\ntheorem le_zero_iff {I : FractionalIdeal S P} : I ≤ 0 ↔ I = 0 :=\n  le_bot_iff\n#align fractional_ideal.le_zero_iff FractionalIdeal.le_zero_iff\n\ntheorem eq_zero_iff {I : FractionalIdeal S P} : I = 0 ↔ ∀ x ∈ I, x = (0 : P) :=\n  ⟨fun h x hx => by simpa [h, mem_zero_iff] using hx, fun h =>\n    le_bot_iff.mp fun x hx => (mem_zero_iff S).mpr (h x hx)⟩\n#align fractional_ideal.eq_zero_iff FractionalIdeal.eq_zero_iff\n\ntheorem IsFractional.sup {I J : Submodule R P} :\n    IsFractional S I → IsFractional S J → IsFractional S (I ⊔ J)\n  | ⟨aI, haI, hI⟩, ⟨aJ, haJ, hJ⟩ =>\n    ⟨aI * aJ, S.mul_mem haI haJ, fun b hb =>\n      by\n      rcases mem_sup.mp hb with ⟨bI, hbI, bJ, hbJ, rfl⟩\n      rw [smul_add]\n      apply is_integer_add\n      · rw [mul_smul, smul_comm]\n        exact is_integer_smul (hI bI hbI)\n      · rw [mul_smul]\n        exact is_integer_smul (hJ bJ hbJ)⟩\n#align is_fractional.sup IsFractional.sup\n\ntheorem IsFractional.inf_right {I : Submodule R P} : IsFractional S I → ∀ J, IsFractional S (I ⊓ J)\n  | ⟨aI, haI, hI⟩, J =>\n    ⟨aI, haI, fun b hb => by\n      rcases mem_inf.mp hb with ⟨hbI, hbJ⟩\n      exact hI b hbI⟩\n#align is_fractional.inf_right IsFractional.inf_right\n\ninstance : Inf (FractionalIdeal S P) :=\n  ⟨fun I J => ⟨I ⊓ J, I.IsFractional.inf_right J⟩⟩\n\n@[simp, norm_cast]\ntheorem coe_inf (I J : FractionalIdeal S P) : ↑(I ⊓ J) = (I ⊓ J : Submodule R P) :=\n  rfl\n#align fractional_ideal.coe_inf FractionalIdeal.coe_inf\n\ninstance : Sup (FractionalIdeal S P) :=\n  ⟨fun I J => ⟨I ⊔ J, I.IsFractional.sup J.IsFractional⟩⟩\n\n@[norm_cast]\ntheorem coe_sup (I J : FractionalIdeal S P) : ↑(I ⊔ J) = (I ⊔ J : Submodule R P) :=\n  rfl\n#align fractional_ideal.coe_sup FractionalIdeal.coe_sup\n\ninstance lattice : Lattice (FractionalIdeal S P) :=\n  Function.Injective.lattice _ Subtype.coe_injective coe_sup coe_inf\n#align fractional_ideal.lattice FractionalIdeal.lattice\n\ninstance : SemilatticeSup (FractionalIdeal S P) :=\n  { FractionalIdeal.lattice with }\n\nend Lattice\n\nsection Semiring\n\ninstance : Add (FractionalIdeal S P) :=\n  ⟨(· ⊔ ·)⟩\n\n@[simp]\ntheorem sup_eq_add (I J : FractionalIdeal S P) : I ⊔ J = I + J :=\n  rfl\n#align fractional_ideal.sup_eq_add FractionalIdeal.sup_eq_add\n\n@[simp, norm_cast]\ntheorem coe_add (I J : FractionalIdeal S P) : (↑(I + J) : Submodule R P) = I + J :=\n  rfl\n#align fractional_ideal.coe_add FractionalIdeal.coe_add\n\n@[simp, norm_cast]\ntheorem coe_ideal_sup (I J : Ideal R) : ↑(I ⊔ J) = (I + J : FractionalIdeal S P) :=\n  coe_to_submodule_injective <| coeSubmodule_sup _ _ _\n#align fractional_ideal.coe_ideal_sup FractionalIdeal.coe_ideal_sup\n\ntheorem IsFractional.nsmul {I : Submodule R P} :\n    ∀ n : ℕ, IsFractional S I → IsFractional S (n • I : Submodule R P)\n  | 0, _ => by\n    rw [zero_smul]\n    convert((0 : Ideal R) : FractionalIdeal S P).IsFractional\n    simp\n  | n + 1, h => by\n    rw [succ_nsmul]\n    exact h.sup (_root_.is_fractional.nsmul n h)\n#align is_fractional.nsmul IsFractional.nsmul\n\ninstance : SMul ℕ (FractionalIdeal S P) where smul n I := ⟨n • I, I.IsFractional.nsmul n⟩\n\n@[norm_cast]\ntheorem coe_nsmul (n : ℕ) (I : FractionalIdeal S P) : (↑(n • I) : Submodule R P) = n • I :=\n  rfl\n#align fractional_ideal.coe_nsmul FractionalIdeal.coe_nsmul\n\ntheorem IsFractional.mul {I J : Submodule R P} :\n    IsFractional S I → IsFractional S J → IsFractional S (I * J : Submodule R P)\n  | ⟨aI, haI, hI⟩, ⟨aJ, haJ, hJ⟩ =>\n    ⟨aI * aJ, S.mul_mem haI haJ, fun b hb =>\n      by\n      apply Submodule.mul_induction_on hb\n      · intro m hm n hn\n        obtain ⟨n', hn'⟩ := hJ n hn\n        rw [mul_smul, mul_comm m, ← smul_mul_assoc, ← hn', ← Algebra.smul_def]\n        apply hI\n        exact Submodule.smul_mem _ _ hm\n      · intro x y hx hy\n        rw [smul_add]\n        apply is_integer_add hx hy⟩\n#align is_fractional.mul IsFractional.mul\n\ntheorem IsFractional.pow {I : Submodule R P} (h : IsFractional S I) :\n    ∀ n : ℕ, IsFractional S (I ^ n : Submodule R P)\n  | 0 => isFractional_of_le_one _ (pow_zero _).le\n  | n + 1 => (pow_succ I n).symm ▸ h.mul (_root_.is_fractional.pow n)\n#align is_fractional.pow IsFractional.pow\n\n/-- `fractional_ideal.mul` is the product of two fractional ideals,\nused to define the `has_mul` instance.\n\nThis is only an auxiliary definition: the preferred way of writing `I.mul J` is `I * J`.\n\nElaborated terms involving `fractional_ideal` tend to grow quite large,\nso by making definitions irreducible, we hope to avoid deep unfolds.\n-/\nirreducible_def mul (I J : FractionalIdeal S P) : FractionalIdeal S P :=\n  ⟨I * J, I.IsFractional.mul J.IsFractional⟩\n#align fractional_ideal.mul FractionalIdeal.mul\n\n-- local attribute [semireducible] mul\ninstance : Mul (FractionalIdeal S P) :=\n  ⟨fun I J => mul I J⟩\n\n@[simp]\ntheorem mul_eq_mul (I J : FractionalIdeal S P) : mul I J = I * J :=\n  rfl\n#align fractional_ideal.mul_eq_mul FractionalIdeal.mul_eq_mul\n\ntheorem mul_def (I J : FractionalIdeal S P) : I * J = ⟨I * J, I.IsFractional.mul J.IsFractional⟩ :=\n  by simp only [← mul_eq_mul, mul]\n#align fractional_ideal.mul_def FractionalIdeal.mul_def\n\n@[simp, norm_cast]\ntheorem coe_mul (I J : FractionalIdeal S P) : (↑(I * J) : Submodule R P) = I * J :=\n  by\n  simp only [mul_def]\n  rfl\n#align fractional_ideal.coe_mul FractionalIdeal.coe_mul\n\n@[simp, norm_cast]\ntheorem coe_ideal_mul (I J : Ideal R) : (↑(I * J) : FractionalIdeal S P) = I * J :=\n  by\n  simp only [mul_def]\n  exact coe_to_submodule_injective (coe_submodule_mul _ _ _)\n#align fractional_ideal.coe_ideal_mul FractionalIdeal.coe_ideal_mul\n\ntheorem mul_left_mono (I : FractionalIdeal S P) : Monotone ((· * ·) I) :=\n  by\n  intro J J' h\n  simp only [mul_def]\n  exact mul_le.mpr fun x hx y hy => mul_mem_mul hx (h hy)\n#align fractional_ideal.mul_left_mono FractionalIdeal.mul_left_mono\n\ntheorem mul_right_mono (I : FractionalIdeal S P) : Monotone fun J => J * I :=\n  by\n  intro J J' h\n  simp only [mul_def]\n  exact mul_le.mpr fun x hx y hy => mul_mem_mul (h hx) hy\n#align fractional_ideal.mul_right_mono FractionalIdeal.mul_right_mono\n\ntheorem mul_mem_mul {I J : FractionalIdeal S P} {i j : P} (hi : i ∈ I) (hj : j ∈ J) :\n    i * j ∈ I * J := by\n  simp only [mul_def]\n  exact Submodule.mul_mem_mul hi hj\n#align fractional_ideal.mul_mem_mul FractionalIdeal.mul_mem_mul\n\ntheorem mul_le {I J K : FractionalIdeal S P} : I * J ≤ K ↔ ∀ i ∈ I, ∀ j ∈ J, i * j ∈ K :=\n  by\n  simp only [mul_def]\n  exact Submodule.mul_le\n#align fractional_ideal.mul_le FractionalIdeal.mul_le\n\ninstance : Pow (FractionalIdeal S P) ℕ :=\n  ⟨fun I n => ⟨I ^ n, I.IsFractional.pow n⟩⟩\n\n@[simp, norm_cast]\ntheorem coe_pow (I : FractionalIdeal S P) (n : ℕ) : ↑(I ^ n) = (I ^ n : Submodule R P) :=\n  rfl\n#align fractional_ideal.coe_pow FractionalIdeal.coe_pow\n\n@[elab_as_elim]\nprotected theorem mul_induction_on {I J : FractionalIdeal S P} {C : P → Prop} {r : P}\n    (hr : r ∈ I * J) (hm : ∀ i ∈ I, ∀ j ∈ J, C (i * j)) (ha : ∀ x y, C x → C y → C (x + y)) : C r :=\n  by\n  simp only [mul_def] at hr\n  exact Submodule.mul_induction_on hr hm ha\n#align fractional_ideal.mul_induction_on FractionalIdeal.mul_induction_on\n\ninstance : NatCast (FractionalIdeal S P) :=\n  ⟨Nat.unaryCast⟩\n\ntheorem coe_nat_cast (n : ℕ) : ((n : FractionalIdeal S P) : Submodule R P) = n :=\n  show ↑n.unaryCast = ↑n by induction n <;> simp [*, Nat.unaryCast]\n#align fractional_ideal.coe_nat_cast FractionalIdeal.coe_nat_cast\n\ninstance : CommSemiring (FractionalIdeal S P) :=\n  Function.Injective.commSemiring coe Subtype.coe_injective coe_zero coe_one coe_add coe_mul\n    (fun _ _ => coe_nsmul _ _) coe_pow coe_nat_cast\n\nvariable (S P)\n\n/-- `fractional_ideal.submodule.has_coe` as a bundled `ring_hom`. -/\n@[simps]\ndef coeSubmoduleHom : FractionalIdeal S P →+* Submodule R P :=\n  ⟨coe, coe_one, coe_mul, coe_zero, coe_add⟩\n#align fractional_ideal.coe_submodule_hom FractionalIdeal.coeSubmoduleHom\n\nvariable {S P}\n\nsection Order\n\ntheorem add_le_add_left {I J : FractionalIdeal S P} (hIJ : I ≤ J) (J' : FractionalIdeal S P) :\n    J' + I ≤ J' + J :=\n  sup_le_sup_left hIJ J'\n#align fractional_ideal.add_le_add_left FractionalIdeal.add_le_add_left\n\ntheorem mul_le_mul_left {I J : FractionalIdeal S P} (hIJ : I ≤ J) (J' : FractionalIdeal S P) :\n    J' * I ≤ J' * J :=\n  mul_le.mpr fun k hk j hj => mul_mem_mul hk (hIJ hj)\n#align fractional_ideal.mul_le_mul_left FractionalIdeal.mul_le_mul_left\n\ntheorem le_self_mul_self {I : FractionalIdeal S P} (hI : 1 ≤ I) : I ≤ I * I :=\n  by\n  convert mul_left_mono I hI\n  exact (mul_one I).symm\n#align fractional_ideal.le_self_mul_self FractionalIdeal.le_self_mul_self\n\ntheorem mul_self_le_self {I : FractionalIdeal S P} (hI : I ≤ 1) : I * I ≤ I :=\n  by\n  convert mul_left_mono I hI\n  exact (mul_one I).symm\n#align fractional_ideal.mul_self_le_self FractionalIdeal.mul_self_le_self\n\ntheorem coe_ideal_le_one {I : Ideal R} : (I : FractionalIdeal S P) ≤ 1 := fun x hx =>\n  let ⟨y, _, hy⟩ := (mem_coe_ideal S).mp hx\n  (mem_one_iff S).mpr ⟨y, hy⟩\n#align fractional_ideal.coe_ideal_le_one FractionalIdeal.coe_ideal_le_one\n\ntheorem le_one_iff_exists_coe_ideal {J : FractionalIdeal S P} :\n    J ≤ (1 : FractionalIdeal S P) ↔ ∃ I : Ideal R, ↑I = J :=\n  by\n  constructor\n  · intro hJ\n    refine' ⟨⟨{ x : R | algebraMap R P x ∈ J }, _, _, _⟩, _⟩\n    · intro a b ha hb\n      rw [mem_set_of_eq, RingHom.map_add]\n      exact J.val.add_mem ha hb\n    · rw [mem_set_of_eq, RingHom.map_zero]\n      exact J.val.zero_mem\n    · intro c x hx\n      rw [smul_eq_mul, mem_set_of_eq, RingHom.map_mul, ← Algebra.smul_def]\n      exact J.val.smul_mem c hx\n    · ext x\n      constructor\n      · rintro ⟨y, hy, eq_y⟩\n        rwa [← eq_y]\n      · intro hx\n        obtain ⟨y, eq_x⟩ := (mem_one_iff S).mp (hJ hx)\n        rw [← eq_x] at *\n        exact ⟨y, hx, rfl⟩\n  · rintro ⟨I, hI⟩\n    rw [← hI]\n    apply coe_ideal_le_one\n#align fractional_ideal.le_one_iff_exists_coe_ideal FractionalIdeal.le_one_iff_exists_coe_ideal\n\n@[simp]\ntheorem one_le {I : FractionalIdeal S P} : 1 ≤ I ↔ (1 : P) ∈ I := by\n  rw [← coe_le_coe, coe_one, Submodule.one_le, mem_coe]\n#align fractional_ideal.one_le FractionalIdeal.one_le\n\nvariable (S P)\n\n/-- `coe_ideal_hom (S : submonoid R) P` is `coe : ideal R → fractional_ideal S P` as a ring hom -/\n@[simps]\ndef coeIdealHom : Ideal R →+* FractionalIdeal S P\n    where\n  toFun := coe\n  map_add' := coe_ideal_sup\n  map_mul' := coe_ideal_mul\n  map_one' := by rw [Ideal.one_eq_top, coe_ideal_top]\n  map_zero' := coe_ideal_bot\n#align fractional_ideal.coe_ideal_hom FractionalIdeal.coeIdealHom\n\ntheorem coe_ideal_pow (I : Ideal R) (n : ℕ) : (↑(I ^ n) : FractionalIdeal S P) = I ^ n :=\n  (coeIdealHom S P).map_pow _ n\n#align fractional_ideal.coe_ideal_pow FractionalIdeal.coe_ideal_pow\n\nopen BigOperators\n\ntheorem coe_ideal_finprod [IsLocalization S P] {α : Sort _} {f : α → Ideal R}\n    (hS : S ≤ nonZeroDivisors R) :\n    ((∏ᶠ a : α, f a : Ideal R) : FractionalIdeal S P) = ∏ᶠ a : α, (f a : FractionalIdeal S P) :=\n  MonoidHom.map_finprod_of_injective (coeIdealHom S P).toMonoidHom (coe_ideal_injective' hS) f\n#align fractional_ideal.coe_ideal_finprod FractionalIdeal.coe_ideal_finprod\n\nend Order\n\nvariable {P' : Type _} [CommRing P'] [Algebra R P'] [loc' : IsLocalization S P']\n\nvariable {P'' : Type _} [CommRing P''] [Algebra R P''] [loc'' : IsLocalization S P'']\n\ntheorem IsFractional.map (g : P →ₐ[R] P') {I : Submodule R P} :\n    IsFractional S I → IsFractional S (Submodule.map g.toLinearMap I)\n  | ⟨a, a_nonzero, hI⟩ =>\n    ⟨a, a_nonzero, fun b hb =>\n      by\n      obtain ⟨b', b'_mem, hb'⟩ := submodule.mem_map.mp hb\n      obtain ⟨x, hx⟩ := hI b' b'_mem\n      use x\n      erw [← g.commutes, hx, g.map_smul, hb']⟩\n#align is_fractional.map IsFractional.map\n\n/-- `I.map g` is the pushforward of the fractional ideal `I` along the algebra morphism `g` -/\ndef map (g : P →ₐ[R] P') : FractionalIdeal S P → FractionalIdeal S P' := fun I =>\n  ⟨Submodule.map g.toLinearMap I, I.IsFractional.map g⟩\n#align fractional_ideal.map FractionalIdeal.map\n\n@[simp, norm_cast]\ntheorem coe_map (g : P →ₐ[R] P') (I : FractionalIdeal S P) :\n    ↑(map g I) = Submodule.map g.toLinearMap I :=\n  rfl\n#align fractional_ideal.coe_map FractionalIdeal.coe_map\n\n@[simp]\ntheorem mem_map {I : FractionalIdeal S P} {g : P →ₐ[R] P'} {y : P'} :\n    y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y :=\n  Submodule.mem_map\n#align fractional_ideal.mem_map FractionalIdeal.mem_map\n\nvariable (I J : FractionalIdeal S P) (g : P →ₐ[R] P')\n\n@[simp]\ntheorem map_id : I.map (AlgHom.id _ _) = I :=\n  coe_to_submodule_injective (Submodule.map_id I)\n#align fractional_ideal.map_id FractionalIdeal.map_id\n\n@[simp]\ntheorem map_comp (g' : P' →ₐ[R] P'') : I.map (g'.comp g) = (I.map g).map g' :=\n  coe_to_submodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I)\n#align fractional_ideal.map_comp FractionalIdeal.map_comp\n\n@[simp, norm_cast]\ntheorem map_coe_ideal (I : Ideal R) : (I : FractionalIdeal S P).map g = I :=\n  by\n  ext x\n  simp only [mem_coe_ideal]\n  constructor\n  · rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩\n    exact ⟨y, hy, (g.commutes y).symm⟩\n  · rintro ⟨y, hy, rfl⟩\n    exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩\n#align fractional_ideal.map_coe_ideal FractionalIdeal.map_coe_ideal\n\n@[simp]\ntheorem map_one : (1 : FractionalIdeal S P).map g = 1 :=\n  map_coe_ideal g ⊤\n#align fractional_ideal.map_one FractionalIdeal.map_one\n\n@[simp]\ntheorem map_zero : (0 : FractionalIdeal S P).map g = 0 :=\n  map_coe_ideal g 0\n#align fractional_ideal.map_zero FractionalIdeal.map_zero\n\n@[simp]\ntheorem map_add : (I + J).map g = I.map g + J.map g :=\n  coe_to_submodule_injective (Submodule.map_sup _ _ _)\n#align fractional_ideal.map_add FractionalIdeal.map_add\n\n@[simp]\ntheorem map_mul : (I * J).map g = I.map g * J.map g :=\n  by\n  simp only [mul_def]\n  exact coe_to_submodule_injective (Submodule.map_mul _ _ _)\n#align fractional_ideal.map_mul FractionalIdeal.map_mul\n\n@[simp]\ntheorem map_map_symm (g : P ≃ₐ[R] P') : (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I := by\n  rw [← map_comp, g.symm_comp, map_id]\n#align fractional_ideal.map_map_symm FractionalIdeal.map_map_symm\n\n@[simp]\ntheorem map_symm_map (I : FractionalIdeal S P') (g : P ≃ₐ[R] P') :\n    (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I := by\n  rw [← map_comp, g.comp_symm, map_id]\n#align fractional_ideal.map_symm_map FractionalIdeal.map_symm_map\n\ntheorem map_mem_map {f : P →ₐ[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} :\n    f x ∈ map f I ↔ x ∈ I :=\n  mem_map.trans ⟨fun ⟨x', hx', x'_eq⟩ => h x'_eq ▸ hx', fun h => ⟨x, h, rfl⟩⟩\n#align fractional_ideal.map_mem_map FractionalIdeal.map_mem_map\n\ntheorem map_injective (f : P →ₐ[R] P') (h : Function.Injective f) :\n    Function.Injective (map f : FractionalIdeal S P → FractionalIdeal S P') := fun I J hIJ =>\n  ext fun x => (map_mem_map h).symm.trans (hIJ.symm ▸ map_mem_map h)\n#align fractional_ideal.map_injective FractionalIdeal.map_injective\n\n/-- If `g` is an equivalence, `map g` is an isomorphism -/\ndef mapEquiv (g : P ≃ₐ[R] P') : FractionalIdeal S P ≃+* FractionalIdeal S P'\n    where\n  toFun := map g\n  invFun := map g.symm\n  map_add' I J := map_add I J _\n  map_mul' I J := map_mul I J _\n  left_inv I := by rw [← map_comp, AlgEquiv.symm_comp, map_id]\n  right_inv I := by rw [← map_comp, AlgEquiv.comp_symm, map_id]\n#align fractional_ideal.map_equiv FractionalIdeal.mapEquiv\n\n@[simp]\ntheorem coe_fun_mapEquiv (g : P ≃ₐ[R] P') :\n    (mapEquiv g : FractionalIdeal S P → FractionalIdeal S P') = map g :=\n  rfl\n#align fractional_ideal.coe_fun_map_equiv FractionalIdeal.coe_fun_mapEquiv\n\n@[simp]\ntheorem mapEquiv_apply (g : P ≃ₐ[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (↑g) I :=\n  rfl\n#align fractional_ideal.map_equiv_apply FractionalIdeal.mapEquiv_apply\n\n@[simp]\ntheorem mapEquiv_symm (g : P ≃ₐ[R] P') :\n    ((mapEquiv g).symm : FractionalIdeal S P' ≃+* _) = mapEquiv g.symm :=\n  rfl\n#align fractional_ideal.map_equiv_symm FractionalIdeal.mapEquiv_symm\n\n@[simp]\ntheorem mapEquiv_refl : mapEquiv AlgEquiv.refl = RingEquiv.refl (FractionalIdeal S P) :=\n  RingEquiv.ext fun x => by simp\n#align fractional_ideal.map_equiv_refl FractionalIdeal.mapEquiv_refl\n\ntheorem isFractional_span_iff {s : Set P} :\n    IsFractional S (span R s) ↔ ∃ a ∈ S, ∀ b : P, b ∈ s → IsInteger R (a • b) :=\n  ⟨fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => h b (subset_span hb)⟩, fun ⟨a, a_mem, h⟩ =>\n    ⟨a, a_mem, fun b hb =>\n      span_induction hb h\n        (by\n          rw [smul_zero]\n          exact is_integer_zero)\n        (fun x y hx hy => by\n          rw [smul_add]\n          exact is_integer_add hx hy)\n        fun s x hx => by\n        rw [smul_comm]\n        exact is_integer_smul hx⟩⟩\n#align fractional_ideal.is_fractional_span_iff FractionalIdeal.isFractional_span_iff\n\ninclude loc\n\ntheorem isFractional_of_fg {I : Submodule R P} (hI : I.Fg) : IsFractional S I :=\n  by\n  rcases hI with ⟨I, rfl⟩\n  rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩\n  rw [is_fractional_span_iff]\n  exact ⟨s, hs1, hs⟩\n#align fractional_ideal.is_fractional_of_fg FractionalIdeal.isFractional_of_fg\n\nomit loc\n\ntheorem mem_span_mul_finite_of_mem_mul {I J : FractionalIdeal S P} {x : P} (hx : x ∈ I * J) :\n    ∃ T T' : Finset P, (T : Set P) ⊆ I ∧ (T' : Set P) ⊆ J ∧ x ∈ span R (T * T' : Set P) :=\n  Submodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx)\n#align fractional_ideal.mem_span_mul_finite_of_mem_mul FractionalIdeal.mem_span_mul_finite_of_mem_mul\n\nvariable (S)\n\ntheorem coe_ideal_fg (inj : Function.Injective (algebraMap R P)) (I : Ideal R) :\n    Fg ((I : FractionalIdeal S P) : Submodule R P) ↔ I.Fg :=\n  coeSubmodule_fg _ inj _\n#align fractional_ideal.coe_ideal_fg FractionalIdeal.coe_ideal_fg\n\nvariable {S}\n\ntheorem fg_unit (I : (FractionalIdeal S P)ˣ) : Fg (I : Submodule R P) :=\n  Submodule.fg_unit <| Units.map (coeSubmoduleHom S P).toMonoidHom I\n#align fractional_ideal.fg_unit FractionalIdeal.fg_unit\n\ntheorem fg_of_isUnit (I : FractionalIdeal S P) (h : IsUnit I) : Fg (I : Submodule R P) :=\n  fg_unit h.Unit\n#align fractional_ideal.fg_of_is_unit FractionalIdeal.fg_of_isUnit\n\ntheorem Ideal.fg_of_isUnit (inj : Function.Injective (algebraMap R P)) (I : Ideal R)\n    (h : IsUnit (I : FractionalIdeal S P)) : I.Fg :=\n  by\n  rw [← coe_ideal_fg S inj I]\n  exact fg_of_is_unit I h\n#align ideal.fg_of_is_unit Ideal.fg_of_isUnit\n\nvariable (S P P')\n\ninclude loc loc'\n\n/-- `canonical_equiv f f'` is the canonical equivalence between the fractional\nideals in `P` and in `P'` -/\nnoncomputable irreducible_def canonicalEquiv : FractionalIdeal S P ≃+* FractionalIdeal S P' :=\n  mapEquiv\n    {\n      ringEquivOfRingEquiv P P' (RingEquiv.refl R)\n        (show S.map _ = S by rw [RingEquiv.toMonoidHom_refl, Submonoid.map_id]) with\n      commutes' := fun r => ringEquivOfRingEquiv_eq _ _ }\n#align fractional_ideal.canonical_equiv FractionalIdeal.canonicalEquiv\n\n@[simp]\ntheorem mem_canonicalEquiv_apply {I : FractionalIdeal S P} {x : P'} :\n    x ∈ canonicalEquiv S P P' I ↔\n      ∃ y ∈ I,\n        IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy)\n            (y : P) =\n          x :=\n  by\n  rw [canonical_equiv, map_equiv_apply, mem_map]\n  exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩\n#align fractional_ideal.mem_canonical_equiv_apply FractionalIdeal.mem_canonicalEquiv_apply\n\n@[simp]\ntheorem canonicalEquiv_symm : (canonicalEquiv S P P').symm = canonicalEquiv S P' P :=\n  RingEquiv.ext fun I =>\n    SetLike.ext_iff.mpr fun x =>\n      by\n      rw [mem_canonical_equiv_apply, canonical_equiv, map_equiv_symm, map_equiv, RingEquiv.coe_mk,\n        mem_map]\n      exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩\n#align fractional_ideal.canonical_equiv_symm FractionalIdeal.canonicalEquiv_symm\n\ntheorem canonicalEquiv_flip (I) : canonicalEquiv S P P' (canonicalEquiv S P' P I) = I := by\n  rw [← canonical_equiv_symm, RingEquiv.symm_apply_apply]\n#align fractional_ideal.canonical_equiv_flip FractionalIdeal.canonicalEquiv_flip\n\n@[simp]\ntheorem canonicalEquiv_canonicalEquiv (P'' : Type _) [CommRing P''] [Algebra R P'']\n    [IsLocalization S P''] (I : FractionalIdeal S P) :\n    canonicalEquiv S P' P'' (canonicalEquiv S P P' I) = canonicalEquiv S P P'' I :=\n  by\n  ext\n  simp only [IsLocalization.map_map, RingHomInvPair.comp_eq₂, mem_canonical_equiv_apply,\n    exists_prop, exists_exists_and_eq_and]\n  rfl\n#align fractional_ideal.canonical_equiv_canonical_equiv FractionalIdeal.canonicalEquiv_canonicalEquiv\n\ntheorem canonicalEquiv_trans_canonicalEquiv (P'' : Type _) [CommRing P''] [Algebra R P'']\n    [IsLocalization S P''] :\n    (canonicalEquiv S P P').trans (canonicalEquiv S P' P'') = canonicalEquiv S P P'' :=\n  RingEquiv.ext (canonicalEquiv_canonicalEquiv S P P' P'')\n#align fractional_ideal.canonical_equiv_trans_canonical_equiv FractionalIdeal.canonicalEquiv_trans_canonicalEquiv\n\n@[simp]\ntheorem canonicalEquiv_coe_ideal (I : Ideal R) : canonicalEquiv S P P' I = I :=\n  by\n  ext\n  simp [IsLocalization.map_eq]\n#align fractional_ideal.canonical_equiv_coe_ideal FractionalIdeal.canonicalEquiv_coe_ideal\n\nomit loc'\n\n@[simp]\ntheorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ :=\n  by\n  rw [← canonical_equiv_trans_canonical_equiv S P P]\n  convert(canonical_equiv S P P).symm_trans_self\n  exact (canonical_equiv_symm S P P).symm\n#align fractional_ideal.canonical_equiv_self FractionalIdeal.canonicalEquiv_self\n\nend Semiring\n\nsection IsFractionRing\n\n/-!\n### `is_fraction_ring` section\n\nThis section concerns fractional ideals in the field of fractions,\ni.e. the type `fractional_ideal R⁰ K` where `is_fraction_ring R K`.\n-/\n\n\nvariable {K K' : Type _} [Field K] [Field K']\n\nvariable [Algebra R K] [IsFractionRing R K] [Algebra R K'] [IsFractionRing R K']\n\nvariable {I J : FractionalIdeal R⁰ K} (h : K →ₐ[R] K')\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » (0 : R)) -/\n/-- Nonzero fractional ideals contain a nonzero integer. -/\ntheorem exists_ne_zero_mem_is_integer [Nontrivial R] (hI : I ≠ 0) :\n    ∃ (x : _)(_ : x ≠ (0 : R)), algebraMap R K x ∈ I :=\n  by\n  obtain ⟨y, y_mem, y_not_mem⟩ :=\n    SetLike.exists_of_lt (by simpa only using bot_lt_iff_ne_bot.mpr hI)\n  have y_ne_zero : y ≠ 0 := by simpa using y_not_mem\n  obtain ⟨z, ⟨x, hx⟩⟩ := exists_integer_multiple R⁰ y\n  refine' ⟨x, _, _⟩\n  · rw [Ne.def, ← @IsFractionRing.to_map_eq_zero_iff R _ K, hx, Algebra.smul_def]\n    exact mul_ne_zero (IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors z.2) y_ne_zero\n  · rw [hx]\n    exact smul_mem _ _ y_mem\n#align fractional_ideal.exists_ne_zero_mem_is_integer FractionalIdeal.exists_ne_zero_mem_is_integer\n\ntheorem map_ne_zero [Nontrivial R] (hI : I ≠ 0) : I.map h ≠ 0 :=\n  by\n  obtain ⟨x, x_ne_zero, hx⟩ := exists_ne_zero_mem_is_integer hI\n  contrapose! x_ne_zero with map_eq_zero\n  refine' is_fraction_ring.to_map_eq_zero_iff.mp (eq_zero_iff.mp map_eq_zero _ (mem_map.mpr _))\n  exact ⟨algebraMap R K x, hx, h.commutes x⟩\n#align fractional_ideal.map_ne_zero FractionalIdeal.map_ne_zero\n\n@[simp]\ntheorem map_eq_zero_iff [Nontrivial R] : I.map h = 0 ↔ I = 0 :=\n  ⟨imp_of_not_imp_not _ _ (map_ne_zero _), fun hI => hI.symm ▸ map_zero h⟩\n#align fractional_ideal.map_eq_zero_iff FractionalIdeal.map_eq_zero_iff\n\ntheorem coe_ideal_injective : Function.Injective (coe : Ideal R → FractionalIdeal R⁰ K) :=\n  coe_ideal_injective' le_rfl\n#align fractional_ideal.coe_ideal_injective FractionalIdeal.coe_ideal_injective\n\ntheorem coe_ideal_inj {I J : Ideal R} :\n    (I : FractionalIdeal R⁰ K) = (J : FractionalIdeal R⁰ K) ↔ I = J :=\n  coe_ideal_inj' le_rfl\n#align fractional_ideal.coe_ideal_inj FractionalIdeal.coe_ideal_inj\n\n@[simp]\ntheorem coe_ideal_eq_zero {I : Ideal R} : (I : FractionalIdeal R⁰ K) = 0 ↔ I = ⊥ :=\n  coe_ideal_eq_zero' le_rfl\n#align fractional_ideal.coe_ideal_eq_zero FractionalIdeal.coe_ideal_eq_zero\n\ntheorem coe_ideal_ne_zero {I : Ideal R} : (I : FractionalIdeal R⁰ K) ≠ 0 ↔ I ≠ ⊥ :=\n  coe_ideal_ne_zero' le_rfl\n#align fractional_ideal.coe_ideal_ne_zero FractionalIdeal.coe_ideal_ne_zero\n\n@[simp]\ntheorem coe_ideal_eq_one {I : Ideal R} : (I : FractionalIdeal R⁰ K) = 1 ↔ I = 1 := by\n  simpa only [Ideal.one_eq_top] using coe_ideal_inj\n#align fractional_ideal.coe_ideal_eq_one FractionalIdeal.coe_ideal_eq_one\n\ntheorem coe_ideal_ne_one {I : Ideal R} : (I : FractionalIdeal R⁰ K) ≠ 1 ↔ I ≠ 1 :=\n  not_iff_not.mpr coe_ideal_eq_one\n#align fractional_ideal.coe_ideal_ne_one FractionalIdeal.coe_ideal_ne_one\n\nend IsFractionRing\n\nsection Quotient\n\n/-!\n### `quotient` section\n\nThis section defines the ideal quotient of fractional ideals.\n\nIn this section we need that each non-zero `y : R` has an inverse in\nthe localization, i.e. that the localization is a field. We satisfy this\nassumption by taking `S = non_zero_divisors R`, `R`'s localization at which\nis a field because `R` is a domain.\n-/\n\n\nopen Classical\n\nvariable {R₁ : Type _} [CommRing R₁] {K : Type _} [Field K]\n\nvariable [Algebra R₁ K] [frac : IsFractionRing R₁ K]\n\ninstance : Nontrivial (FractionalIdeal R₁⁰ K) :=\n  ⟨⟨0, 1, fun h =>\n      have this : (1 : K) ∈ (0 : FractionalIdeal R₁⁰ K) :=\n        by\n        rw [← (algebraMap R₁ K).map_one]\n        simpa only [h] using coe_mem_one R₁⁰ 1\n      one_ne_zero ((mem_zero_iff _).mp this)⟩⟩\n\ntheorem ne_zero_of_mul_eq_one (I J : FractionalIdeal R₁⁰ K) (h : I * J = 1) : I ≠ 0 := fun hI =>\n  zero_ne_one' (FractionalIdeal R₁⁰ K)\n    (by\n      convert h\n      simp [hI])\n#align fractional_ideal.ne_zero_of_mul_eq_one FractionalIdeal.ne_zero_of_mul_eq_one\n\nvariable [IsDomain R₁]\n\ninclude frac\n\ntheorem IsFractional.div_of_nonzero {I J : Submodule R₁ K} :\n    IsFractional R₁⁰ I → IsFractional R₁⁰ J → J ≠ 0 → IsFractional R₁⁰ (I / J)\n  | ⟨aI, haI, hI⟩, ⟨aJ, haJ, hJ⟩, h =>\n    by\n    obtain ⟨y, mem_J, not_mem_zero⟩ :=\n      SetLike.exists_of_lt (by simpa only using bot_lt_iff_ne_bot.mpr h)\n    obtain ⟨y', hy'⟩ := hJ y mem_J\n    use aI * y'\n    constructor\n    · apply (nonZeroDivisors R₁).mul_mem haI (mem_non_zero_divisors_iff_ne_zero.mpr _)\n      intro y'_eq_zero\n      have : algebraMap R₁ K aJ * y = 0 := by\n        rw [← Algebra.smul_def, ← hy', y'_eq_zero, RingHom.map_zero]\n      have y_zero :=\n        (mul_eq_zero.mp this).resolve_left\n          (mt ((injective_iff_map_eq_zero (algebraMap R₁ K)).1 (IsFractionRing.injective _ _) _)\n            (mem_non_zero_divisors_iff_ne_zero.mp haJ))\n      apply not_mem_zero\n      simpa only using (mem_zero_iff R₁⁰).mpr y_zero\n    intro b hb\n    convert hI _ (hb _ (Submodule.smul_mem _ aJ mem_J)) using 1\n    rw [← hy', mul_comm b, ← Algebra.smul_def, mul_smul]\n#align is_fractional.div_of_nonzero IsFractional.div_of_nonzero\n\ntheorem fractional_div_of_nonzero {I J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) :\n    IsFractional R₁⁰ (I / J : Submodule R₁ K) :=\n  I.IsFractional.div_of_nonzero J.IsFractional fun H =>\n    h <| coe_to_submodule_injective <| H.trans coe_zero.symm\n#align fractional_ideal.fractional_div_of_nonzero FractionalIdeal.fractional_div_of_nonzero\n\nnoncomputable instance : Div (FractionalIdeal R₁⁰ K) :=\n  ⟨fun I J => if h : J = 0 then 0 else ⟨I / J, fractional_div_of_nonzero h⟩⟩\n\nvariable {I J : FractionalIdeal R₁⁰ K} [J ≠ 0]\n\n@[simp]\ntheorem div_zero {I : FractionalIdeal R₁⁰ K} : I / 0 = 0 :=\n  dif_pos rfl\n#align fractional_ideal.div_zero FractionalIdeal.div_zero\n\ntheorem div_nonzero {I J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) :\n    I / J = ⟨I / J, fractional_div_of_nonzero h⟩ :=\n  dif_neg h\n#align fractional_ideal.div_nonzero FractionalIdeal.div_nonzero\n\n@[simp]\ntheorem coe_div {I J : FractionalIdeal R₁⁰ K} (hJ : J ≠ 0) :\n    (↑(I / J) : Submodule R₁ K) = ↑I / (↑J : Submodule R₁ K) :=\n  congr_arg _ (dif_neg hJ)\n#align fractional_ideal.coe_div FractionalIdeal.coe_div\n\ntheorem mem_div_iff_of_nonzero {I J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) {x} :\n    x ∈ I / J ↔ ∀ y ∈ J, x * y ∈ I := by\n  rw [div_nonzero h]\n  exact Submodule.mem_div_iff_forall_mul_mem\n#align fractional_ideal.mem_div_iff_of_nonzero FractionalIdeal.mem_div_iff_of_nonzero\n\ntheorem mul_one_div_le_one {I : FractionalIdeal R₁⁰ K} : I * (1 / I) ≤ 1 :=\n  by\n  by_cases hI : I = 0\n  · rw [hI, div_zero, MulZeroClass.mul_zero]\n    exact zero_le 1\n  · rw [← coe_le_coe, coe_mul, coe_div hI, coe_one]\n    apply Submodule.mul_one_div_le_one\n#align fractional_ideal.mul_one_div_le_one FractionalIdeal.mul_one_div_le_one\n\ntheorem le_self_mul_one_div {I : FractionalIdeal R₁⁰ K} (hI : I ≤ (1 : FractionalIdeal R₁⁰ K)) :\n    I ≤ I * (1 / I) := by\n  by_cases hI_nz : I = 0\n  · rw [hI_nz, div_zero, MulZeroClass.mul_zero]\n    exact zero_le 0\n  · rw [← coe_le_coe, coe_mul, coe_div hI_nz, coe_one]\n    rw [← coe_le_coe, coe_one] at hI\n    exact Submodule.le_self_mul_one_div hI\n#align fractional_ideal.le_self_mul_one_div FractionalIdeal.le_self_mul_one_div\n\ntheorem le_div_iff_of_nonzero {I J J' : FractionalIdeal R₁⁰ K} (hJ' : J' ≠ 0) :\n    I ≤ J / J' ↔ ∀ x ∈ I, ∀ y ∈ J', x * y ∈ J :=\n  ⟨fun h x hx => (mem_div_iff_of_nonzero hJ').mp (h hx), fun h x hx =>\n    (mem_div_iff_of_nonzero hJ').mpr (h x hx)⟩\n#align fractional_ideal.le_div_iff_of_nonzero FractionalIdeal.le_div_iff_of_nonzero\n\ntheorem le_div_iff_mul_le {I J J' : FractionalIdeal R₁⁰ K} (hJ' : J' ≠ 0) :\n    I ≤ J / J' ↔ I * J' ≤ J := by\n  rw [div_nonzero hJ']\n  convert Submodule.le_div_iff_mul_le using 1\n  rw [← coe_mul, coe_le_coe]\n#align fractional_ideal.le_div_iff_mul_le FractionalIdeal.le_div_iff_mul_le\n\n@[simp]\ntheorem div_one {I : FractionalIdeal R₁⁰ K} : I / 1 = I :=\n  by\n  rw [div_nonzero (one_ne_zero' (FractionalIdeal R₁⁰ K))]\n  ext\n  constructor <;> intro h\n  · simpa using mem_div_iff_forall_mul_mem.mp h 1 ((algebraMap R₁ K).map_one ▸ coe_mem_one R₁⁰ 1)\n  · apply mem_div_iff_forall_mul_mem.mpr\n    rintro y ⟨y', _, rfl⟩\n    rw [mul_comm]\n    convert Submodule.smul_mem _ y' h\n    exact (Algebra.smul_def _ _).symm\n#align fractional_ideal.div_one FractionalIdeal.div_one\n\ntheorem eq_one_div_of_mul_eq_one_right (I J : FractionalIdeal R₁⁰ K) (h : I * J = 1) : J = 1 / I :=\n  by\n  have hI : I ≠ 0 := ne_zero_of_mul_eq_one I J h\n  suffices h' : I * (1 / I) = 1\n  ·\n    exact\n      congr_arg Units.inv <|\n        @Units.ext _ _ (Units.mkOfMulEqOne _ _ h) (Units.mkOfMulEqOne _ _ h') rfl\n  apply le_antisymm\n  · apply mul_le.mpr _\n    intro x hx y hy\n    rw [mul_comm]\n    exact (mem_div_iff_of_nonzero hI).mp hy x hx\n  rw [← h]\n  apply mul_left_mono I\n  apply (le_div_iff_of_nonzero hI).mpr _\n  intro y hy x hx\n  rw [mul_comm]\n  exact mul_mem_mul hx hy\n#align fractional_ideal.eq_one_div_of_mul_eq_one_right FractionalIdeal.eq_one_div_of_mul_eq_one_right\n\ntheorem mul_div_self_cancel_iff {I : FractionalIdeal R₁⁰ K} : I * (1 / I) = 1 ↔ ∃ J, I * J = 1 :=\n  ⟨fun h => ⟨1 / I, h⟩, fun ⟨J, hJ⟩ => by rwa [← eq_one_div_of_mul_eq_one_right I J hJ]⟩\n#align fractional_ideal.mul_div_self_cancel_iff FractionalIdeal.mul_div_self_cancel_iff\n\nvariable {K' : Type _} [Field K'] [Algebra R₁ K'] [IsFractionRing R₁ K']\n\n@[simp]\ntheorem map_div (I J : FractionalIdeal R₁⁰ K) (h : K ≃ₐ[R₁] K') :\n    (I / J).map (h : K →ₐ[R₁] K') = I.map h / J.map h :=\n  by\n  by_cases H : J = 0\n  · rw [H, div_zero, map_zero, div_zero]\n  · apply coe_to_submodule_injective\n    simp [div_nonzero H, div_nonzero (map_ne_zero _ H), Submodule.map_div]\n#align fractional_ideal.map_div FractionalIdeal.map_div\n\n@[simp]\ntheorem map_one_div (I : FractionalIdeal R₁⁰ K) (h : K ≃ₐ[R₁] K') :\n    (1 / I).map (h : K →ₐ[R₁] K') = 1 / I.map h := by rw [map_div, map_one]\n#align fractional_ideal.map_one_div FractionalIdeal.map_one_div\n\nend Quotient\n\nsection Field\n\nvariable {R₁ K L : Type _} [CommRing R₁] [Field K] [Field L]\n\nvariable [Algebra R₁ K] [IsFractionRing R₁ K] [Algebra K L] [IsFractionRing K L]\n\ntheorem eq_zero_or_one (I : FractionalIdeal K⁰ L) : I = 0 ∨ I = 1 :=\n  by\n  rw [or_iff_not_imp_left]\n  intro hI\n  simp_rw [@SetLike.ext_iff _ _ _ I 1, mem_one_iff]\n  intro x\n  constructor\n  · intro x_mem\n    obtain ⟨n, d, rfl⟩ := IsLocalization.mk'_surjective K⁰ x\n    refine' ⟨n / d, _⟩\n    rw [map_div₀, IsFractionRing.mk'_eq_div]\n  · rintro ⟨x, rfl⟩\n    obtain ⟨y, y_ne, y_mem⟩ := exists_ne_zero_mem_is_integer hI\n    rw [← div_mul_cancel x y_ne, RingHom.map_mul, ← Algebra.smul_def]\n    exact Submodule.smul_mem I _ y_mem\n#align fractional_ideal.eq_zero_or_one FractionalIdeal.eq_zero_or_one\n\ntheorem eq_zero_or_one_of_isField (hF : IsField R₁) (I : FractionalIdeal R₁⁰ K) : I = 0 ∨ I = 1 :=\n  letI : Field R₁ := hF.to_field\n  eq_zero_or_one I\n#align fractional_ideal.eq_zero_or_one_of_is_field FractionalIdeal.eq_zero_or_one_of_isField\n\nend Field\n\nsection PrincipalIdealRing\n\nvariable {R₁ : Type _} [CommRing R₁] {K : Type _} [Field K]\n\nvariable [Algebra R₁ K] [IsFractionRing R₁ K]\n\nopen Classical\n\nvariable (R₁)\n\n/-- `fractional_ideal.span_finset R₁ s f` is the fractional ideal of `R₁` generated by `f '' s`. -/\n@[simps]\ndef spanFinset {ι : Type _} (s : Finset ι) (f : ι → K) : FractionalIdeal R₁⁰ K :=\n  ⟨Submodule.span R₁ (f '' s),\n    by\n    obtain ⟨a', ha'⟩ := IsLocalization.exist_integer_multiples R₁⁰ s f\n    refine' ⟨a', a'.2, fun x hx => Submodule.span_induction hx _ _ _ _⟩\n    · rintro _ ⟨i, hi, rfl⟩\n      exact ha' i hi\n    · rw [smul_zero]\n      exact IsLocalization.isInteger_zero\n    · intro x y hx hy\n      rw [smul_add]\n      exact IsLocalization.isInteger_add hx hy\n    · intro c x hx\n      rw [smul_comm]\n      exact IsLocalization.isInteger_smul hx⟩\n#align fractional_ideal.span_finset FractionalIdeal.spanFinset\n\nvariable {R₁}\n\n@[simp]\ntheorem spanFinset_eq_zero {ι : Type _} {s : Finset ι} {f : ι → K} :\n    spanFinset R₁ s f = 0 ↔ ∀ j ∈ s, f j = 0 := by\n  simp only [← coe_to_submodule_inj, span_finset_coe, coe_zero, Submodule.span_eq_bot,\n    Set.mem_image, Finset.mem_coe, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]\n#align fractional_ideal.span_finset_eq_zero FractionalIdeal.spanFinset_eq_zero\n\ntheorem spanFinset_ne_zero {ι : Type _} {s : Finset ι} {f : ι → K} :\n    spanFinset R₁ s f ≠ 0 ↔ ∃ j ∈ s, f j ≠ 0 := by simp\n#align fractional_ideal.span_finset_ne_zero FractionalIdeal.spanFinset_ne_zero\n\nopen Submodule.IsPrincipal\n\ninclude loc\n\ntheorem isFractional_span_singleton (x : P) : IsFractional S (span R {x} : Submodule R P) :=\n  let ⟨a, ha⟩ := exists_integer_multiple S x\n  isFractional_span_iff.mpr ⟨a, a.2, fun x' hx' => (Set.mem_singleton_iff.mp hx').symm ▸ ha⟩\n#align fractional_ideal.is_fractional_span_singleton FractionalIdeal.isFractional_span_singleton\n\nvariable (S)\n\n/-- `span_singleton x` is the fractional ideal generated by `x` if `0 ∉ S` -/\nirreducible_def spanSingleton (x : P) : FractionalIdeal S P :=\n  ⟨span R {x}, isFractional_span_singleton x⟩\n#align fractional_ideal.span_singleton FractionalIdeal.spanSingleton\n\n-- local attribute [semireducible] span_singleton\n@[simp]\ntheorem coe_spanSingleton (x : P) : (spanSingleton S x : Submodule R P) = span R {x} :=\n  by\n  rw [span_singleton]\n  rfl\n#align fractional_ideal.coe_span_singleton FractionalIdeal.coe_spanSingleton\n\n@[simp]\ntheorem mem_spanSingleton {x y : P} : x ∈ spanSingleton S y ↔ ∃ z : R, z • y = x :=\n  by\n  rw [span_singleton]\n  exact Submodule.mem_span_singleton\n#align fractional_ideal.mem_span_singleton FractionalIdeal.mem_spanSingleton\n\ntheorem mem_spanSingleton_self (x : P) : x ∈ spanSingleton S x :=\n  (mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩\n#align fractional_ideal.mem_span_singleton_self FractionalIdeal.mem_spanSingleton_self\n\nvariable {S}\n\n@[simp]\ntheorem spanSingleton_le_iff_mem {x : P} {I : FractionalIdeal S P} :\n    spanSingleton S x ≤ I ↔ x ∈ I := by\n  rw [← coe_le_coe, coe_span_singleton, Submodule.span_singleton_le_iff_mem x ↑I, mem_coe]\n#align fractional_ideal.span_singleton_le_iff_mem FractionalIdeal.spanSingleton_le_iff_mem\n\ntheorem spanSingleton_eq_spanSingleton [NoZeroSMulDivisors R P] {x y : P} :\n    spanSingleton S x = spanSingleton S y ↔ ∃ z : Rˣ, z • x = y :=\n  by\n  rw [← Submodule.span_singleton_eq_span_singleton, span_singleton, span_singleton]\n  exact Subtype.mk_eq_mk\n#align fractional_ideal.span_singleton_eq_span_singleton FractionalIdeal.spanSingleton_eq_spanSingleton\n\ntheorem eq_spanSingleton_of_principal (I : FractionalIdeal S P) [IsPrincipal (I : Submodule R P)] :\n    I = spanSingleton S (generator (I : Submodule R P)) :=\n  by\n  rw [span_singleton]\n  exact coe_to_submodule_injective (span_singleton_generator ↑I).symm\n#align fractional_ideal.eq_span_singleton_of_principal FractionalIdeal.eq_spanSingleton_of_principal\n\ntheorem isPrincipal_iff (I : FractionalIdeal S P) :\n    IsPrincipal (I : Submodule R P) ↔ ∃ x, I = spanSingleton S x :=\n  ⟨fun h => ⟨@generator _ _ _ _ _ (↑I) h, @eq_spanSingleton_of_principal _ _ _ _ _ _ _ I h⟩,\n    fun ⟨x, hx⟩ => { principal := ⟨x, trans (congr_arg _ hx) (coe_spanSingleton _ x)⟩ }⟩\n#align fractional_ideal.is_principal_iff FractionalIdeal.isPrincipal_iff\n\n@[simp]\ntheorem spanSingleton_zero : spanSingleton S (0 : P) = 0 :=\n  by\n  ext\n  simp [Submodule.mem_span_singleton, eq_comm]\n#align fractional_ideal.span_singleton_zero FractionalIdeal.spanSingleton_zero\n\ntheorem spanSingleton_eq_zero_iff {y : P} : spanSingleton S y = 0 ↔ y = 0 :=\n  ⟨fun h =>\n    span_eq_bot.mp (by simpa using congr_arg Subtype.val h : span R {y} = ⊥) y (mem_singleton y),\n    fun h => by simp [h]⟩\n#align fractional_ideal.span_singleton_eq_zero_iff FractionalIdeal.spanSingleton_eq_zero_iff\n\ntheorem spanSingleton_ne_zero_iff {y : P} : spanSingleton S y ≠ 0 ↔ y ≠ 0 :=\n  not_congr spanSingleton_eq_zero_iff\n#align fractional_ideal.span_singleton_ne_zero_iff FractionalIdeal.spanSingleton_ne_zero_iff\n\n@[simp]\ntheorem spanSingleton_one : spanSingleton S (1 : P) = 1 :=\n  by\n  ext\n  refine' (mem_span_singleton S).trans ((exists_congr _).trans (mem_one_iff S).symm)\n  intro x'\n  rw [Algebra.smul_def, mul_one]\n#align fractional_ideal.span_singleton_one FractionalIdeal.spanSingleton_one\n\n@[simp]\ntheorem spanSingleton_mul_spanSingleton (x y : P) :\n    spanSingleton S x * spanSingleton S y = spanSingleton S (x * y) :=\n  by\n  apply coe_to_submodule_injective\n  simp only [coe_mul, coe_span_singleton, span_mul_span, singleton_mul_singleton]\n#align fractional_ideal.span_singleton_mul_span_singleton FractionalIdeal.spanSingleton_mul_spanSingleton\n\n@[simp]\ntheorem spanSingleton_pow (x : P) (n : ℕ) : spanSingleton S x ^ n = spanSingleton S (x ^ n) :=\n  by\n  induction' n with n hn\n  · rw [pow_zero, pow_zero, span_singleton_one]\n  · rw [pow_succ, hn, span_singleton_mul_span_singleton, pow_succ]\n#align fractional_ideal.span_singleton_pow FractionalIdeal.spanSingleton_pow\n\n@[simp]\ntheorem coe_ideal_spanSingleton (x : R) :\n    (↑(Ideal.span {x} : Ideal R) : FractionalIdeal S P) = spanSingleton S (algebraMap R P x) :=\n  by\n  ext y\n  refine' (mem_coe_ideal S).trans (Iff.trans _ (mem_span_singleton S).symm)\n  constructor\n  · rintro ⟨y', hy', rfl⟩\n    obtain ⟨x', rfl⟩ := submodule.mem_span_singleton.mp hy'\n    use x'\n    rw [smul_eq_mul, RingHom.map_mul, Algebra.smul_def]\n  · rintro ⟨y', rfl⟩\n    refine' ⟨y' * x, submodule.mem_span_singleton.mpr ⟨y', rfl⟩, _⟩\n    rw [RingHom.map_mul, Algebra.smul_def]\n#align fractional_ideal.coe_ideal_span_singleton FractionalIdeal.coe_ideal_spanSingleton\n\n@[simp]\ntheorem canonicalEquiv_spanSingleton {P'} [CommRing P'] [Algebra R P'] [IsLocalization S P']\n    (x : P) :\n    canonicalEquiv S P P' (spanSingleton S x) =\n      spanSingleton S\n        (IsLocalization.map P' (RingHom.id R)\n          (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) x) :=\n  by\n  apply set_like.ext_iff.mpr\n  intro y\n  constructor <;> intro h\n  · rw [mem_span_singleton]\n    obtain ⟨x', hx', rfl⟩ := (mem_canonical_equiv_apply _ _ _).mp h\n    obtain ⟨z, rfl⟩ := (mem_span_singleton _).mp hx'\n    use z\n    rw [IsLocalization.map_smul]\n    rfl\n  · rw [mem_canonical_equiv_apply]\n    obtain ⟨z, rfl⟩ := (mem_span_singleton _).mp h\n    use z • x\n    use (mem_span_singleton _).mpr ⟨z, rfl⟩\n    simp [IsLocalization.map_smul]\n#align fractional_ideal.canonical_equiv_span_singleton FractionalIdeal.canonicalEquiv_spanSingleton\n\ntheorem mem_singleton_mul {x y : P} {I : FractionalIdeal S P} :\n    y ∈ spanSingleton S x * I ↔ ∃ y' ∈ I, y = x * y' :=\n  by\n  constructor\n  · intro h\n    apply FractionalIdeal.mul_induction_on h\n    · intro x' hx' y' hy'\n      obtain ⟨a, ha⟩ := (mem_span_singleton S).mp hx'\n      use a • y', Submodule.smul_mem I a hy'\n      rw [← ha, Algebra.mul_smul_comm, Algebra.smul_mul_assoc]\n    · rintro _ _ ⟨y, hy, rfl⟩ ⟨y', hy', rfl⟩\n      exact ⟨y + y', Submodule.add_mem I hy hy', (mul_add _ _ _).symm⟩\n  · rintro ⟨y', hy', rfl⟩\n    exact mul_mem_mul ((mem_span_singleton S).mpr ⟨1, one_smul _ _⟩) hy'\n#align fractional_ideal.mem_singleton_mul FractionalIdeal.mem_singleton_mul\n\nomit loc\n\nvariable (K)\n\ntheorem mk'_mul_coe_ideal_eq_coe_ideal {I J : Ideal R₁} {x y : R₁} (hy : y ∈ R₁⁰) :\n    spanSingleton R₁⁰ (IsLocalization.mk' K x ⟨y, hy⟩) * I = (J : FractionalIdeal R₁⁰ K) ↔\n      Ideal.span {x} * I = Ideal.span {y} * J :=\n  by\n  have :\n    span_singleton R₁⁰ (IsLocalization.mk' _ (1 : R₁) ⟨y, hy⟩) *\n        span_singleton R₁⁰ (algebraMap R₁ K y) =\n      1 :=\n    by\n    rw [span_singleton_mul_span_singleton, mul_comm, ← IsLocalization.mk'_eq_mul_mk'_one,\n      IsLocalization.mk'_self, span_singleton_one]\n  let y' : (FractionalIdeal R₁⁰ K)ˣ := Units.mkOfMulEqOne _ _ this\n  have coe_y' : ↑y' = span_singleton R₁⁰ (IsLocalization.mk' K (1 : R₁) ⟨y, hy⟩) := rfl\n  refine' Iff.trans _ (y'.mul_right_inj.trans coe_ideal_inj)\n  rw [coe_y', coe_ideal_mul, coe_ideal_span_singleton, coe_ideal_mul, coe_ideal_span_singleton, ←\n    mul_assoc, span_singleton_mul_span_singleton, ← mul_assoc, span_singleton_mul_span_singleton,\n    mul_comm (mk' _ _ _), ← IsLocalization.mk'_eq_mul_mk'_one, mul_comm (mk' _ _ _), ←\n    IsLocalization.mk'_eq_mul_mk'_one, IsLocalization.mk'_self, span_singleton_one, one_mul]\n#align fractional_ideal.mk'_mul_coe_ideal_eq_coe_ideal FractionalIdeal.mk'_mul_coe_ideal_eq_coe_ideal\n\nvariable {K}\n\ntheorem spanSingleton_mul_coe_ideal_eq_coe_ideal {I J : Ideal R₁} {z : K} :\n    spanSingleton R₁⁰ z * (I : FractionalIdeal R₁⁰ K) = J ↔\n      Ideal.span {((IsLocalization.sec R₁⁰ z).1 : R₁)} * I =\n        Ideal.span {(IsLocalization.sec R₁⁰ z).2} * J :=\n  by-- `erw` to deal with the distinction between `y` and `⟨y.1, y.2⟩`\n  erw [← mk'_mul_coe_ideal_eq_coe_ideal K (IsLocalization.sec R₁⁰ z).2.Prop,\n    IsLocalization.mk'_sec K z]\n#align fractional_ideal.span_singleton_mul_coe_ideal_eq_coe_ideal FractionalIdeal.spanSingleton_mul_coe_ideal_eq_coe_ideal\n\nvariable [IsDomain R₁]\n\ntheorem one_div_spanSingleton (x : K) : 1 / spanSingleton R₁⁰ x = spanSingleton R₁⁰ x⁻¹ :=\n  if h : x = 0 then by simp [h] else (eq_one_div_of_mul_eq_one_right _ _ (by simp [h])).symm\n#align fractional_ideal.one_div_span_singleton FractionalIdeal.one_div_spanSingleton\n\n@[simp]\ntheorem div_spanSingleton (J : FractionalIdeal R₁⁰ K) (d : K) :\n    J / spanSingleton R₁⁰ d = spanSingleton R₁⁰ d⁻¹ * J :=\n  by\n  rw [← one_div_span_singleton]\n  by_cases hd : d = 0\n  · simp only [hd, span_singleton_zero, div_zero, MulZeroClass.zero_mul]\n  have h_spand : span_singleton R₁⁰ d ≠ 0 := mt span_singleton_eq_zero_iff.mp hd\n  apply le_antisymm\n  · intro x hx\n    rw [← mem_coe, coe_div h_spand, Submodule.mem_div_iff_forall_mul_mem] at hx\n    specialize hx d (mem_span_singleton_self R₁⁰ d)\n    have h_xd : x = d⁻¹ * (x * d) := by field_simp\n    rw [← mem_coe, coe_mul, one_div_span_singleton, h_xd]\n    exact Submodule.mul_mem_mul (mem_span_singleton_self R₁⁰ _) hx\n  · rw [le_div_iff_mul_le h_spand, mul_assoc, mul_left_comm, one_div_span_singleton,\n      span_singleton_mul_span_singleton, inv_mul_cancel hd, span_singleton_one, mul_one]\n    exact le_refl J\n#align fractional_ideal.div_span_singleton FractionalIdeal.div_spanSingleton\n\ntheorem exists_eq_spanSingleton_mul (I : FractionalIdeal R₁⁰ K) :\n    ∃ (a : R₁)(aI : Ideal R₁), a ≠ 0 ∧ I = spanSingleton R₁⁰ (algebraMap R₁ K a)⁻¹ * aI :=\n  by\n  obtain ⟨a_inv, nonzero, ha⟩ := I.is_fractional\n  have nonzero := mem_non_zero_divisors_iff_ne_zero.mp nonzero\n  have map_a_nonzero : algebraMap R₁ K a_inv ≠ 0 :=\n    mt is_fraction_ring.to_map_eq_zero_iff.mp nonzero\n  refine'\n    ⟨a_inv,\n      Submodule.comap (Algebra.linearMap R₁ K) ↑(span_singleton R₁⁰ (algebraMap R₁ K a_inv) * I),\n      nonzero, ext fun x => Iff.trans ⟨_, _⟩ mem_singleton_mul.symm⟩\n  · intro hx\n    obtain ⟨x', hx'⟩ := ha x hx\n    rw [Algebra.smul_def] at hx'\n    refine' ⟨algebraMap R₁ K x', (mem_coe_ideal _).mpr ⟨x', mem_singleton_mul.mpr _, rfl⟩, _⟩\n    · exact ⟨x, hx, hx'⟩\n    · rw [hx', ← mul_assoc, inv_mul_cancel map_a_nonzero, one_mul]\n  · rintro ⟨y, hy, rfl⟩\n    obtain ⟨x', hx', rfl⟩ := (mem_coe_ideal _).mp hy\n    obtain ⟨y', hy', hx'⟩ := mem_singleton_mul.mp hx'\n    rw [Algebra.linearMap_apply] at hx'\n    rwa [hx', ← mul_assoc, inv_mul_cancel map_a_nonzero, one_mul]\n#align fractional_ideal.exists_eq_span_singleton_mul FractionalIdeal.exists_eq_spanSingleton_mul\n\ninstance isPrincipal {R} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R] [Algebra R K]\n    [IsFractionRing R K] (I : FractionalIdeal R⁰ K) : (I : Submodule R K).IsPrincipal :=\n  by\n  obtain ⟨a, aI, -, ha⟩ := exists_eq_span_singleton_mul I\n  use (algebraMap R K a)⁻¹ * algebraMap R K (generator aI)\n  suffices I = span_singleton R⁰ ((algebraMap R K a)⁻¹ * algebraMap R K (generator aI))\n    by\n    rw [span_singleton] at this\n    exact congr_arg Subtype.val this\n  conv_lhs => rw [ha, ← span_singleton_generator aI]\n  rw [Ideal.submodule_span_eq, coe_ideal_span_singleton (generator aI),\n    span_singleton_mul_span_singleton]\n#align fractional_ideal.is_principal FractionalIdeal.isPrincipal\n\ninclude loc\n\ntheorem le_spanSingleton_mul_iff {x : P} {I J : FractionalIdeal S P} :\n    I ≤ spanSingleton S x * J ↔ ∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI :=\n  show (∀ {zI} (hzI : zI ∈ I), zI ∈ spanSingleton _ x * J) ↔ ∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI by\n    simp only [mem_singleton_mul, eq_comm]\n#align fractional_ideal.le_span_singleton_mul_iff FractionalIdeal.le_spanSingleton_mul_iff\n\ntheorem spanSingleton_mul_le_iff {x : P} {I J : FractionalIdeal S P} :\n    spanSingleton _ x * I ≤ J ↔ ∀ z ∈ I, x * z ∈ J :=\n  by\n  simp only [mul_le, mem_singleton_mul, mem_span_singleton]\n  constructor\n  · intro h zI hzI\n    exact h x ⟨1, one_smul _ _⟩ zI hzI\n  · rintro h _ ⟨z, rfl⟩ zI hzI\n    rw [Algebra.smul_mul_assoc]\n    exact Submodule.smul_mem J.1 _ (h zI hzI)\n#align fractional_ideal.span_singleton_mul_le_iff FractionalIdeal.spanSingleton_mul_le_iff\n\ntheorem eq_spanSingleton_mul {x : P} {I J : FractionalIdeal S P} :\n    I = spanSingleton _ x * J ↔ (∀ zI ∈ I, ∃ zJ ∈ J, x * zJ = zI) ∧ ∀ z ∈ J, x * z ∈ I := by\n  simp only [le_antisymm_iff, le_span_singleton_mul_iff, span_singleton_mul_le_iff]\n#align fractional_ideal.eq_span_singleton_mul FractionalIdeal.eq_spanSingleton_mul\n\nend PrincipalIdealRing\n\nvariable {R₁ : Type _} [CommRing R₁]\n\nvariable {K : Type _} [Field K] [Algebra R₁ K] [frac : IsFractionRing R₁ K]\n\nattribute [local instance] Classical.propDecidable\n\ntheorem isNoetherian_zero : IsNoetherian R₁ (0 : FractionalIdeal R₁⁰ K) :=\n  isNoetherian_submodule.mpr fun I (hI : I ≤ (0 : FractionalIdeal R₁⁰ K)) =>\n    by\n    rw [coe_zero] at hI\n    rw [le_bot_iff.mp hI]\n    exact fg_bot\n#align fractional_ideal.is_noetherian_zero FractionalIdeal.isNoetherian_zero\n\ntheorem isNoetherian_iff {I : FractionalIdeal R₁⁰ K} :\n    IsNoetherian R₁ I ↔ ∀ J ≤ I, (J : Submodule R₁ K).Fg :=\n  isNoetherian_submodule.trans ⟨fun h J hJ => h _ hJ, fun h J hJ => h ⟨J, isFractional_of_le hJ⟩ hJ⟩\n#align fractional_ideal.is_noetherian_iff FractionalIdeal.isNoetherian_iff\n\ntheorem isNoetherian_coe_ideal [IsNoetherianRing R₁] (I : Ideal R₁) :\n    IsNoetherian R₁ (I : FractionalIdeal R₁⁰ K) :=\n  by\n  rw [is_noetherian_iff]\n  intro J hJ\n  obtain ⟨J, rfl⟩ := le_one_iff_exists_coe_ideal.mp (le_trans hJ coe_ideal_le_one)\n  exact (IsNoetherian.noetherian J).map _\n#align fractional_ideal.is_noetherian_coe_ideal FractionalIdeal.isNoetherian_coe_ideal\n\ninclude frac\n\nvariable [IsDomain R₁]\n\ntheorem isNoetherian_spanSingleton_inv_to_map_mul (x : R₁) {I : FractionalIdeal R₁⁰ K}\n    (hI : IsNoetherian R₁ I) :\n    IsNoetherian R₁ (spanSingleton R₁⁰ (algebraMap R₁ K x)⁻¹ * I : FractionalIdeal R₁⁰ K) :=\n  by\n  by_cases hx : x = 0\n  · rw [hx, RingHom.map_zero, _root_.inv_zero, span_singleton_zero, MulZeroClass.zero_mul]\n    exact is_noetherian_zero\n  have h_gx : algebraMap R₁ K x ≠ 0 :=\n    mt ((injective_iff_map_eq_zero (algebraMap R₁ K)).mp (IsFractionRing.injective _ _) x) hx\n  have h_spanx : span_singleton R₁⁰ (algebraMap R₁ K x) ≠ 0 := span_singleton_ne_zero_iff.mpr h_gx\n  rw [is_noetherian_iff] at hI⊢\n  intro J hJ\n  rw [← div_span_singleton, le_div_iff_mul_le h_spanx] at hJ\n  obtain ⟨s, hs⟩ := hI _ hJ\n  use s * {(algebraMap R₁ K x)⁻¹}\n  rw [Finset.coe_mul, Finset.coe_singleton, ← span_mul_span, hs, ← coe_span_singleton R₁⁰, ←\n    coe_mul, mul_assoc, span_singleton_mul_span_singleton, mul_inv_cancel h_gx, span_singleton_one,\n    mul_one]\n#align fractional_ideal.is_noetherian_span_singleton_inv_to_map_mul FractionalIdeal.isNoetherian_spanSingleton_inv_to_map_mul\n\n/-- Every fractional ideal of a noetherian integral domain is noetherian. -/\ntheorem isNoetherian [IsNoetherianRing R₁] (I : FractionalIdeal R₁⁰ K) : IsNoetherian R₁ I :=\n  by\n  obtain ⟨d, J, h_nzd, rfl⟩ := exists_eq_span_singleton_mul I\n  apply is_noetherian_span_singleton_inv_to_map_mul\n  apply is_noetherian_coe_ideal\n#align fractional_ideal.is_noetherian FractionalIdeal.isNoetherian\n\nsection Adjoin\n\ninclude loc\n\nomit frac\n\nvariable {R P} (S) (x : P) (hx : IsIntegral R x)\n\n/-- `A[x]` is a fractional ideal for every integral `x`. -/\ntheorem isFractional_adjoin_integral :\n    IsFractional S (Algebra.adjoin R ({x} : Set P)).toSubmodule :=\n  isFractional_of_fg (fg_adjoin_singleton_of_integral x hx)\n#align fractional_ideal.is_fractional_adjoin_integral FractionalIdeal.isFractional_adjoin_integral\n\n/-- `fractional_ideal.adjoin_integral (S : submonoid R) x hx` is `R[x]` as a fractional ideal,\nwhere `hx` is a proof that `x : P` is integral over `R`. -/\n@[simps]\ndef adjoinIntegral : FractionalIdeal S P :=\n  ⟨_, isFractional_adjoin_integral S x hx⟩\n#align fractional_ideal.adjoin_integral FractionalIdeal.adjoinIntegral\n\ntheorem mem_adjoinIntegral_self : x ∈ adjoinIntegral S x hx :=\n  Algebra.subset_adjoin (Set.mem_singleton x)\n#align fractional_ideal.mem_adjoin_integral_self FractionalIdeal.mem_adjoinIntegral_self\n\nend Adjoin\n\nend FractionalIdeal\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/FractionalIdeal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4696095908459453}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl\n\n! This file was ported from Lean 3 source module algebra.order.monoid.type_tags\n! leanprover-community/mathlib commit 2258b40dacd2942571c8ce136215350c702dc78f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Group.TypeTags\nimport Mathlib.Algebra.Order.Monoid.Cancel.Defs\nimport Mathlib.Algebra.Order.Monoid.Canonical.Defs\n\n/-! # Ordered monoid structures on `Multiplicative α` and `Additive α`. -/\n\n\ninstance : ∀ [LE α], LE (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance : ∀ [LE α], LE (Additive α) :=\n  fun {inst} => inst\n\ninstance : ∀ [LT α], LT (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance : ∀ [LT α], LT (Additive α) :=\n  fun {inst} => inst\n\ninstance Multiplicative.preorder : ∀ [Preorder α], Preorder (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance Additive.preorder : ∀ [Preorder α], Preorder (Additive α) :=\n  fun {inst} => inst\n\ninstance Multiplicative.partialOrder : ∀ [PartialOrder α], PartialOrder (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance Additive.partialOrder : ∀ [PartialOrder α], PartialOrder (Additive α) :=\n  fun {inst} => inst\n\ninstance Multiplicative.linearOrder : ∀ [LinearOrder α], LinearOrder (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance Additive.linearOrder : ∀ [LinearOrder α], LinearOrder (Additive α) :=\n  fun {inst} => inst\n\ninstance Multiplicative.orderBot [LE α] : ∀ [OrderBot α], OrderBot (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance Additive.orderBot [LE α] : ∀ [OrderBot α], OrderBot (Additive α) :=\n  fun {inst} => inst\n\ninstance Multiplicative.orderTop [LE α] : ∀ [OrderTop α], OrderTop (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance Additive.orderTop [LE α] : ∀ [OrderTop α], OrderTop (Additive α) :=\n  fun {inst} => inst\n\ninstance Multiplicative.boundedOrder [LE α] : ∀ [BoundedOrder α], BoundedOrder (Multiplicative α) :=\n  fun {inst} => inst\n\ninstance Additive.boundedOrder [LE α] : ∀ [BoundedOrder α], BoundedOrder (Additive α) :=\n  fun {inst} => inst\n\ninstance Multiplicative.orderedCommMonoid [OrderedAddCommMonoid α] :\n    OrderedCommMonoid (Multiplicative α) :=\n  { Multiplicative.partialOrder, Multiplicative.commMonoid with\n    mul_le_mul_left := @OrderedAddCommMonoid.add_le_add_left α _ }\n\ninstance Additive.orderedAddCommMonoid [OrderedCommMonoid α] :\n    OrderedAddCommMonoid (Additive α) :=\n  { Additive.partialOrder, Additive.addCommMonoid with\n    add_le_add_left := @OrderedCommMonoid.mul_le_mul_left α _ }\n\ninstance Multiplicative.orderedCancelAddCommMonoid [OrderedCancelAddCommMonoid α] :\n    OrderedCancelCommMonoid (Multiplicative α) :=\n  { Multiplicative.orderedCommMonoid with\n    le_of_mul_le_mul_left := @OrderedCancelAddCommMonoid.le_of_add_le_add_left α _ }\n\ninstance Additive.orderedCancelAddCommMonoid [OrderedCancelCommMonoid α] :\n    OrderedCancelAddCommMonoid (Additive α) :=\n  { Additive.orderedAddCommMonoid with\n    le_of_add_le_add_left := @OrderedCancelCommMonoid.le_of_mul_le_mul_left α _ }\n\ninstance Multiplicative.linearOrderedCommMonoid [LinearOrderedAddCommMonoid α] :\n    LinearOrderedCommMonoid (Multiplicative α) :=\n  { Multiplicative.linearOrder, Multiplicative.orderedCommMonoid with }\n\ninstance Additive.linearOrderedAddCommMonoid [LinearOrderedCommMonoid α] :\n    LinearOrderedAddCommMonoid (Additive α) :=\n  { Additive.linearOrder, Additive.orderedAddCommMonoid with }\n\ninstance Multiplicative.existsMulOfLe [Add α] [LE α] [ExistsAddOfLE α] :\n    ExistsMulOfLE (Multiplicative α) :=\n  ⟨@exists_add_of_le α _ _ _⟩\n\ninstance Additive.existsAddOfLe [Mul α] [LE α] [ExistsMulOfLE α] : ExistsAddOfLE (Additive α) :=\n  ⟨@exists_mul_of_le α _ _ _⟩\n\ninstance Multiplicative.canonicallyOrderedMonoid [CanonicallyOrderedAddMonoid α] :\n    CanonicallyOrderedMonoid (Multiplicative α) :=\n  { Multiplicative.orderedCommMonoid, Multiplicative.orderBot,\n    Multiplicative.existsMulOfLe with le_self_mul := @le_self_add α _ }\n\ninstance Additive.canonicallyOrderedAddMonoid [CanonicallyOrderedMonoid α] :\n    CanonicallyOrderedAddMonoid (Additive α) :=\n  { Additive.orderedAddCommMonoid, Additive.orderBot, Additive.existsAddOfLe with\n    le_self_add := @le_self_mul α _ }\n\ninstance Multiplicative.canonicallyLinearOrderedMonoid [CanonicallyLinearOrderedAddMonoid α] :\n    CanonicallyLinearOrderedMonoid (Multiplicative α) :=\n  { Multiplicative.canonicallyOrderedMonoid, Multiplicative.linearOrder with }\n\ninstance [CanonicallyLinearOrderedMonoid α] : CanonicallyLinearOrderedAddMonoid (Additive α) :=\n  { Additive.canonicallyOrderedAddMonoid, Additive.linearOrder with }\n\nnamespace Additive\n\nvariable [Preorder α]\n\n@[simp]\ntheorem ofMul_le {a b : α} : ofMul a ≤ ofMul b ↔ a ≤ b :=\n  Iff.rfl\n#align additive.of_mul_le Additive.ofMul_le\n\n@[simp]\n\n\n@[simp]\ntheorem toMul_le {a b : Additive α} : toMul a ≤ toMul b ↔ a ≤ b :=\n  Iff.rfl\n#align additive.to_mul_le Additive.toMul_le\n\n@[simp]\ntheorem toMul_lt {a b : Additive α} : toMul a < toMul b ↔ a < b :=\n  Iff.rfl\n#align additive.to_mul_lt Additive.toMul_lt\n\nend Additive\n\nnamespace Multiplicative\n\nvariable [Preorder α]\n\n@[simp]\ntheorem ofAdd_le {a b : α} : ofAdd a ≤ ofAdd b ↔ a ≤ b :=\n  Iff.rfl\n#align multiplicative.of_add_le Multiplicative.ofAdd_le\n\n@[simp]\ntheorem ofAdd_lt {a b : α} : ofAdd a < ofAdd b ↔ a < b :=\n  Iff.rfl\n#align multiplicative.of_add_lt Multiplicative.ofAdd_lt\n\n@[simp]\ntheorem toAdd_le {a b : Multiplicative α} : toAdd a ≤ toAdd b ↔ a ≤ b :=\n  Iff.rfl\n#align multiplicative.to_add_le Multiplicative.toAdd_le\n\n@[simp]\ntheorem toAdd_lt {a b : Multiplicative α} : toAdd a < toAdd b ↔ a < b :=\n  Iff.rfl\n#align multiplicative.to_add_lt Multiplicative.toAdd_lt\n\nend Multiplicative\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/Order/Monoid/TypeTags.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4695924499970496}}
{"text": "import algebra.category.Group\nimport category_theory.limits.shapes.kernels\n\nuniverses u v\n\nnamespace AddCommGroup\n\nopen ulift\n\nvariable (X : Ab.{u})\n\nnamespace ulift\n\ninstance : has_add (ulift.{v} X.α) :=\n{ add := λ x y, ulift.rec_on x $ ulift.rec_on y $ λ a b, up (b + a) }\n\n@[simp] lemma add_down (x y : ulift.{v} X.α) : down (x + y) = down x + down y := begin\n  induction x,\n  induction y,\n  refl,\nend\n\ninstance : has_zero (ulift.{v} X.α) :=\n{ zero := up 0 }\n\n@[simp] lemma zero_down : (0 : ulift.{v} X.α) .down = 0 := rfl\n\ninstance : add_zero_class (ulift.{v} X.α) :=\n{ zero := 0,\n  add := (+),\n  zero_add := λ x, by induction x; ext; simp,\n  add_zero := λ x, by induction x; ext; simp }\n\ninstance : add_semigroup (ulift.{v} X.α) :=\n{ add := (+),\n  add_assoc := λ a b c, by induction a; induction b; induction c; ext; simp [add_assoc] }\n\ninstance : add_monoid (ulift.{v} X.α) := \n{ ..(_ : add_zero_class (ulift.{v} X.α)),\n  ..(_ : add_semigroup (ulift.{v} X.α)) }\n\ninstance : add_comm_monoid (ulift.{v} X.α) :=\n{ add_comm := λ a b, by induction a; induction b; ext; simp [add_comm],\n  ..(_ : add_monoid (ulift.{v} X.α)) }\n\ninstance : sub_neg_monoid (ulift.{v} X.α) :=\n{ neg := λ x, ulift.rec_on x $ λ a, up (-a),\n  nsmul := λ n x, ulift.rec_on x $ λ a, up (n • a),\n  nsmul_zero' := λ x, by { induction x, dsimp only, ext, simp, },\n  nsmul_succ' := λ n x, by { induction x, dsimp only, ext, simp [succ_nsmul], },\n  zsmul := λ n x, ulift.rec_on x $ λ a, up (n • a),\n  zsmul_zero' := λ x, by { induction x, dsimp only, ext, simp, },\n  zsmul_succ' := λ n x, begin\n    induction x,\n    ext,\n    dsimp only,\n    simp [add_smul, add_comm],\n  end,\n  zsmul_neg' := λ n x, begin\n    induction x,\n    ext,\n    dsimp only,\n    simp only [zsmul_neg_succ_of_nat, int.coe_nat_succ, add_smul, one_nsmul, coe_nat_zsmul, one_zsmul],  \n  end,\n  ..(_ : add_monoid (ulift.{v} X.α)) }\n\n@[simp] lemma neg_down (x : ulift.{v} X.α) : (-x).down = - x.down :=\nbegin\n  induction x,\n  dsimp,\n  refl,\nend\n\ninstance : add_group (ulift.{v} X.α) :=\n{ add_left_neg := λ a, by induction a; ext; simp,\n  ..(_ : sub_neg_monoid (ulift.{v} X.α))}\n\ninstance : add_comm_group (ulift.{v} X.α) := \n{ ..(_ : add_comm_monoid (ulift.{v} X.α)),\n  ..(_ : add_group (ulift.{v} X.α))}\n\nend ulift\n\ndef ulift (X : Ab.{u}) : Ab.{max u v} :=\n{ α := ulift.{v} X.α,\n  str := infer_instance }\n\ndef ulift_functor : Ab.{u} ⥤ Ab.{max u v} :=\n{ obj := λ X, X.ulift,\n  map := λ X Y f, \n  { to_fun := λ x, up $ f x.down,\n    map_zero' := by ext; simp,\n    map_add' := λ x y, by ext; simp },\n  map_id' := λ X, by ext x; simp,\n  map_comp' := λ X Y Z h g, by ext; simp }\n\nlemma ulift_functor_map_down {X Y : Ab.{u}} (h : X ⟶ Y) (x : X.ulift) :\n  (ulift_functor.map h x).down = h x.down := rfl\n\nsection\n\nopen category_theory.limits\n\ndef ulift_iso {X Y : Ab.{u}} (h : X ≅ Y) :\n  ulift_functor.obj X ≅ ulift_functor.obj Y :=\n{ hom := ulift_functor.map h.hom,\n  inv := ulift_functor.map h.inv,\n  hom_inv_id' := begin\n    rw [← category_theory.functor.map_comp],\n    simp only [category_theory.iso.hom_inv_id, category_theory.functor.map_id],\n  end,\n  inv_hom_id' := begin\n    rw [← category_theory.functor.map_comp],\n    simp only [category_theory.iso.inv_hom_id, category_theory.functor.map_id],\n  end }\n\nnoncomputable def ulift_kernel_iso_kernel_ulift {X Y : Ab.{u}} (h : X ⟶ Y) :\n  kernel (ulift_functor.map h) ≅ ulift_functor.obj (kernel h) :=\nbegin\n  refine kernel_iso_ker _ ≪≫ _,\n  refine _ ≪≫(ulift_iso (kernel_iso_ker h)).symm,\n  refine { hom := _, inv := _, hom_inv_id' := _, inv_hom_id' := _ },\n  { refine { to_fun := _, map_zero' := _, map_add' := _ },\n    { intros x,\n      refine up ⟨x.1.down, _⟩,\n      have := x.2,\n      rw add_monoid_hom.mem_ker at this ⊢,\n      apply_fun ulift.down at this,\n      rw ulift_functor_map_down at this,\n      exact this, },\n    { refl, },\n    { intros x y, \n      apply_fun ulift.down,\n      dsimp only,\n      rw ulift.add_down,\n      simp only [subtype.val_eq_coe, add_subgroup.coe_add, ulift.add_down, add_submonoid.mk_add_mk, subtype.mk_eq_mk],\n      intros x y h,\n      ext1,\n      exact h, } },\n    { refine { to_fun := _, map_zero' := _, map_add' := _ },\n      { intros x,\n        refine ⟨up x.down.1, _⟩,\n        have := x.down.2,\n        rw add_monoid_hom.mem_ker at this ⊢,\n        ext,\n        rw ulift_functor_map_down,\n        exact this, },\n      { refl },\n      { intros x y,\n        rw subtype.ext_iff_val,\n        simp only [ulift.add_down],\n        refl, }, },\n    { ext1 x,\n      simp only [subtype.val_eq_coe, add_subgroup.coe_mk, category_theory.comp_apply, add_monoid_hom.coe_mk, category_theory.id_apply],\n      rw subtype.ext_iff_val,\n      dsimp only,\n      ext1,\n      refl, },\n    { ext1 x,\n      simp only [subtype.val_eq_coe, category_theory.comp_apply, add_monoid_hom.coe_mk, add_subgroup.coe_mk, set_like.eta,\n  category_theory.id_apply],\n      ext1,\n      refl, },\nend\n\nend\n\nend AddCommGroup", "meta": {"author": "jjaassoonn", "repo": "cc", "sha": "6d3dc6885fa012e8c18fd38ab2949d73777fb442", "save_path": "github-repos/lean/jjaassoonn-cc", "path": "github-repos/lean/jjaassoonn-cc/cc-6d3dc6885fa012e8c18fd38ab2949d73777fb442/src/lemmas/ulift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6370307875894138, "lm_q1q2_score": 0.46959244491731533}}
{"text": "import convex convex_body multiset brunn_minkowski microid set_pi\n  lfe init.data.fin.ops\n\nopen_locale pointwise\nopen_locale topological_space\nopen_locale nat\n\n-- needed to get decidable_eq for sets!\nopen classical\nlocal attribute [instance] prop_decidable\n\nvariables {V : Type} [inner_product_space ℝ V] [finite_dimensional ℝ V]\n\nnoncomputable def translate_gen {k : ℕ} (v : V) (G : unbounded_microid_generator V k) :\nunbounded_microid_generator V k :=\nλ l, G l + v\n\nnoncomputable def scale_gen {k : ℕ} (c : ℝ) (G : unbounded_microid_generator V k) :\nunbounded_microid_generator V k :=\nλ l, c • G l\n\nnoncomputable def scale_translate_gen {k : ℕ} (c : ℝ) (v : V) (G : unbounded_microid_generator V k) :\nunbounded_microid_generator V k :=\nscale_gen c (translate_gen v G)\n\ndef chop_generator' {k₁ k₂ : ℕ}\n(φ : fin k₁.succ → fin k₂.succ)\n(G : unbounded_microid_generator V k₂) :\nunbounded_microid_generator V k₁ := G ∘ φ\n\ndef chop_generator {k : ℕ} {c : ℕ}\n(φ : fin c.succ → fin k.succ)\n(G : microid_generator_space V k) :\nmicroid_generator_space V c :=\nbegin\n  have Gprop := G.property,\n  refine ⟨chop_generator' φ G, _⟩,\n  simp only [chop_generator', subtype.val_eq_coe, mem_ball_zero_iff],\n  simp only [metric.mem_closed_ball, dist_zero_right] at Gprop ⊢,\n  rw [pi_norm_le_iff zero_le_one] at Gprop ⊢,\n  intro b,\n  apply Gprop,\nend\n\nlemma chop_def {k : ℕ} {c : ℕ}\n{φ : fin c.succ → fin k.succ} :\n(chop_generator φ : microid_generator_space V k → microid_generator_space V c)\n= (λ G, chop_generator φ G) := rfl\n\n/- lemma chop_smul {k₁ k₂ : ℕ}  {c : ℝ}\n(φ : fin k₁.succ → fin k₂.succ)\n(G : microid_generator_space V k₂) :\nchop -/\n\nnoncomputable def diam_generator' {k : ℕ}\n(G : unbounded_microid_generator V k) : ℝ :=\nmetric.diam (G '' set.univ)\n\nlemma pi_range_bounded {α : Type} [fintype α]\n(f : α → V) : metric.bounded (set.range f) :=\nbegin\n  let C := finset.sup finset.univ (has_nnnorm.nnnorm ∘f),\n  refine ⟨C + C, _⟩,\n  intros x hx y hy,\n  rcases set.mem_range.mp hx with ⟨x, rfl⟩,\n  rcases set.mem_range.mp hy with ⟨y, rfl⟩,\n  have nx : ∥ f x ∥₊ ≤ C := finset.le_sup (finset.mem_univ x),\n  have ny : ∥ f y ∥₊ ≤ C := finset.le_sup (finset.mem_univ y),\n  refine le_trans _ (add_le_add nx ny),\n  apply dist_le_norm_add_norm,\nend\n\nlemma generator_range_bounded {k : ℕ}\n(G : microid_generator_space V k) :\nmetric.bounded (set.range G.val) :=\nbegin\n  apply pi_range_bounded,\nend\n\nlemma h_diam_continuous {k : ℕ} {ε : ℝ} (hε : ε > 0)\n(x y : unbounded_microid_generator V k) (h : dist x y < ε / 4) :\ndiam_generator' x < ε + diam_generator' y :=\nbegin\n  have hh : ε / 2 < ε := half_lt_self hε,\n  have hδ' : 0 ≤ ε / 2 := div_nonneg (le_of_lt hε) (by simp only [zero_le_bit0, zero_le_one]),\n  refine lt_of_le_of_lt _ (add_lt_add_right hh (diam_generator' y)),\n  simp only [diam_generator'],\n  apply metric.diam_le_of_forall_dist_le,\n  {\n    rw [←@add_zero ℝ _ 0],\n    exact add_le_add hδ' metric.diam_nonneg,\n  },\n  {\n    intros u hu v hv,\n    rcases (set.mem_image _ _ _).mp hu with ⟨pu, hpu, rfl⟩,\n    rcases (set.mem_image _ _ _).mp hv with ⟨pv, hpv, rfl⟩,\n    simp only [dist_eq_norm],\n    have : x pu - x pv = ((x - y) pu - (x - y) pv) + (y pu - y pv),\n    {\n      simp only [pi.sub_apply],\n      abel,\n    },\n    rw [this],\n    refine le_trans (norm_add_le _ _) _,\n    refine add_le_add _ _,\n    {\n      refine le_trans (norm_sub_le _ _) _,\n      refine le_trans (add_le_add (norm_le_pi_norm _ _) (norm_le_pi_norm _ _)) _,\n      -- have : ∀ x : ℝ, x + x = 2 * x := sorry,\n      -- have two_gt: 2 > 0 := by positivity,\n      -- rw [this],\n      rw [←dist_eq_norm],\n      have := metric.mem_ball.mp h,\n      -- rw [dist_comm] at this,\n      change dist x y + dist x y ≤ ε / 2,\n      refine le_of_lt (lt_of_lt_of_le (add_lt_add this this) _),\n      apply le_of_eq,\n      ring,\n    },\n    {\n      rw[←dist_eq_norm],\n      refine metric.dist_le_diam_of_mem _ _ _,\n      {\n        simp only [set.image_univ],\n        apply pi_range_bounded,\n      },\n      all_goals {\n        refine (set.mem_image _ _ _).mp _,\n        simp only [set.image_univ, set.mem_range_self],\n      },\n    },\n  },\nend\n\nlemma diam_continuous (k : ℕ) :\ncontinuous (diam_generator' : unbounded_microid_generator V k → ℝ) :=\nbegin\n  simp only [continuous_def],\n  simp only [metric.is_open_iff],\n  intros U hU x hxU,\n  replace hxU := set.mem_preimage.mp hxU,\n  rcases hU _ hxU with ⟨ε, hε, hx⟩,\n  let δ := ε / 2,\n  have hδ : δ > 0 := half_pos hε,\n  have hδ' : δ ≥ 0 := le_of_lt hδ,\n  let γ := ε / 4,\n  have hγ : γ > 0,\n  {\n    apply div_pos hε,\n    simp only [zero_lt_bit0, zero_lt_one],\n  },\n  have hγ' : γ ≥ 0 := le_of_lt hγ,\n  have hh : δ < ε := half_lt_self hε,\n  refine ⟨γ, hγ, _⟩,\n  intros y hy,\n  simp only [set.mem_preimage],\n  apply hx,\n  simp only [metric.mem_ball, real.dist_eq],\n  refine abs_lt.mpr ⟨_, _⟩,\n  {\n    simp only [neg_lt_sub_iff_lt_add],\n    replace hy := metric.mem_ball.mp hy,\n    rw [dist_comm] at hy,\n    refine h_diam_continuous hε _ _ hy,\n  },\n  {\n    simp only [sub_lt_iff_lt_add],\n    replace hy := metric.mem_ball.mp hy,\n    refine h_diam_continuous hε _ _ hy,\n  },\nend\n\nlemma const_of_diam_zero {k : ℕ}\n{G : unbounded_microid_generator V k}\n(h : diam_generator' G = 0) (m n : fin k.succ) :\nG m = G n :=\nbegin\n  simp only [diam_generator', set.image_univ] at h,\n  apply dist_le_zero.mp,\n  {\n    rw [←h],\n    refine metric.dist_le_diam_of_mem _ _ _,\n    {apply pi_range_bounded},\n    {simp only [set.mem_range_self]},\n    {simp only [set.mem_range_self]},\n  },\nend\n\nnoncomputable def norm_generator' {k : ℕ}\n(G : unbounded_microid_generator V k) : unbounded_microid_generator V k :=\nscale_translate_gen (diam_generator' G)⁻¹ (-(G 0)) G\n\nnoncomputable def norm_generator {k : ℕ}\n(G : microid_generator_space V k) : microid_generator_space V k :=\nbegin\n  refine ⟨norm_generator' G.val, _⟩,\n  simp only [norm_generator', set.image_univ, one_div, mem_closed_ball_zero_iff],\n  simp only [pi.norm_def, nnnorm_smul],\n  have : ∀ b : fin k.succ, ∥G.val b - G.val 0∥ ≤ diam_generator' G.val,\n  {\n    intro b,\n    rw [←dist_eq_norm],\n    refine metric.dist_le_diam_of_mem _ _ _,\n    {rw [set.image_univ], apply generator_range_bounded},\n    all_goals {\n      rw [set.image_univ],\n      simp only [subtype.val_eq_coe, set.mem_range_self],\n    },\n  },\n  rw [←real.coe_to_nnreal 1 zero_le_one],\n  rw [nnreal.coe_le_coe],\n  simp only [real.to_nnreal_one, finset.sup_le_iff, finset.mem_univ, forall_true_left],\n  intro b,\n  simp only [scale_translate_gen, scale_gen, translate_gen],\n  rw [nnnorm_smul, nnnorm_inv, ←sub_eq_add_neg],\n  have lem: ∀ r : nnreal, r⁻¹ * r ≤ 1,\n  {\n    intro r,\n    by_cases hr : r = 0,\n    {\n      simp only [hr, mul_zero, zero_le'],\n    },\n    {\n      rw [inv_mul_cancel hr],\n    },\n  },\n  refine le_trans _ (lem ∥diam_generator' G.val∥₊),\n  apply mul_le_mul_of_nonneg_left,\n  {\n    rw [←nnreal.coe_le_coe, coe_nnnorm, coe_nnnorm],\n    rw [real.norm_eq_abs],\n    refine le_trans (this b) _,\n    apply le_abs_self,\n  },\n  {\n    rw [←nnreal.coe_le_coe],\n    simp only [nonneg.coe_zero, nonneg.coe_inv, coe_nnnorm,\n      real.norm_eq_abs, inv_nonneg, abs_nonneg],\n  },\nend\n\nlemma norm_generator_factor {k : ℕ}\n(G : unbounded_microid_generator V k) :\nnorm_generator' G =\nscale_translate_gen (diam_generator' G)⁻¹ (-(G 0)) G :=\nbegin\n  funext,\n  simp only [norm_generator', one_div, pi.smul_apply, pi.sub_apply],\nend\n\nlemma norm_generator_positive_factor₁ {k : ℕ}\n(G : unbounded_microid_generator V k) (h : diam_generator' G = 0) :\nnorm_generator' G = scale_translate_gen 1 (-(G 0)) G :=\nbegin\n  funext,\n  simp only [norm_generator', scale_translate_gen, scale_gen, translate_gen,\n    one_div, pi.sub_apply,\n    function.const_apply, one_smul],\n  rw [←sub_eq_add_neg],\n  have : G l - G 0 = 0,\n  {\n    rw [const_of_diam_zero h _ 0],\n    simp only [sub_self],\n  },\n  simp only [this, smul_zero],\nend\n\nlemma norm_generator_positive_factor₂ {k : ℕ}\n(G : unbounded_microid_generator V k) (h : diam_generator' G ≠ 0) :\n(diam_generator' G)⁻¹ > 0 ∧\nnorm_generator' G =\nscale_translate_gen (diam_generator' G)⁻¹ (-(G 0)) G :=\nbegin\n  replace h : diam_generator' G > 0,\n  {\n    simp only [diam_generator'] at h,\n    exact ne.lt_of_le' h metric.diam_nonneg,\n  },\n  refine ⟨_, _⟩,\n  {\n    exact inv_pos_of_pos h,\n  },\n  {\n    funext,\n    simp only [norm_generator', one_div, pi.smul_apply, pi.sub_apply],\n  },\nend\n\nlemma norm_generator_positive_factor {k : ℕ}\n(G : unbounded_microid_generator V k) :\n∃ c : ℝ, c > 0 ∧\nnorm_generator' G = scale_translate_gen c (-(G 0)) G :=\nbegin\n  by_cases h : diam_generator' G = 0,\n  {\n    refine ⟨1, zero_lt_one, _⟩,\n    exact norm_generator_positive_factor₁ G h,\n  },\n  {\n    refine ⟨(diam_generator' G)⁻¹, _⟩,\n    exact norm_generator_positive_factor₂ G h,\n  }\nend\n\nlemma scale_translate_scale_translate {k : ℕ}\n{c₁ c₂ : ℝ} {v₁ v₂ : V} {G : unbounded_microid_generator V k} (hc₂ : c₂ ≠ 0) :\nscale_translate_gen c₁ v₁ (scale_translate_gen c₂ v₂ G) =\nscale_translate_gen (c₁ * c₂) (c₂⁻¹ • v₁ + v₂) G :=\nbegin\n  funext,\n  simp only [scale_translate_gen, scale_gen, translate_gen],\n  rw [←smul_eq_mul, smul_assoc],\n  congr,\n  simp only [smul_add, smul_inv_smul₀ hc₂],\n  ac_refl,\nend\n\nlemma scale_translate_scale_translate' {k : ℕ}\n{c₁ c₂ : ℝ} {v₁ v₂ : V} {G : unbounded_microid_generator V k} :\nscale_translate_gen c₁ v₁ (scale_translate_gen c₂ v₂ G) =\ntranslate_gen (c₁ • v₁ + (c₁ • c₂ • v₂)) (scale_gen (c₁ * c₂) G) :=\nbegin\n  funext,\n  simp only [scale_translate_gen, scale_gen, translate_gen],\n  simp only [←smul_eq_mul, smul_assoc, smul_add],\n  ac_refl,\nend\n\nlemma scale_translate_eq_translate_scale {k : ℕ}\n{c : ℝ} {v : V} {G : unbounded_microid_generator V k} :\nscale_gen c (translate_gen v G) = translate_gen (c • v) (scale_gen c G) :=\nbegin\n  funext,\n  simp only [scale_gen, translate_gen],\n  simp only [←smul_eq_mul, smul_assoc, smul_add],\nend\n\nlemma scale_scale {k : ℕ}\n{c₁ c₂ : ℝ} {G : unbounded_microid_generator V k} :\nscale_gen c₁ (scale_gen c₂ G) = scale_gen (c₁ * c₂) G :=\nbegin\n  funext,\n  simp only [scale_gen],\n  simp only [←smul_eq_mul, smul_assoc],\nend\n\nlemma translate_translate {k : ℕ}\n{v₁ v₂ : V} {G : unbounded_microid_generator V k} :\ntranslate_gen v₁ (translate_gen v₂ G) = translate_gen (v₁ + v₂) G :=\nbegin\n  funext,\n  simp only [translate_gen],\n  ac_refl,\nend\n\nlemma translate_zero_scale_1 {k : ℕ}\n(G : unbounded_microid_generator V k) :\nG = translate_gen 0 (scale_gen 1 G) :=\nbegin\n  funext,\n  simp only [translate_gen, scale_gen],\n  simp only [one_smul, add_zero],\nend\n\nlemma translate_zero {k : ℕ}\n(G : unbounded_microid_generator V k) :\nG = translate_gen 0 G :=\nbegin\n  funext,\n  simp only [translate_gen, add_zero],\nend\n\nlemma dist_times_norm {k : ℕ}\n(G : unbounded_microid_generator V k) :\n∃ v : V, G = translate_gen v (scale_gen (diam_generator' G) (norm_generator' G)) :=\nbegin\n  simp only [norm_generator', scale_translate_gen],\n  rw [scale_scale, scale_translate_eq_translate_scale],\n  simp only [translate_translate], -- rw not working...\n  by_cases h : diam_generator' G = 0,\n  {\n    refine ⟨_, _⟩, rotate,\n    {\n      simp only [translate_gen, scale_gen],\n      simp only [h, zero_mul, zero_smul, add_zero, zero_add],\n      funext,\n      exact const_of_diam_zero h x 0,\n    },\n  },\n  {\n    refine ⟨_, _⟩, rotate,\n    {\n      convert translate_zero_scale_1 G,\n      {refine neg_add_self _},\n      {\n        exact mul_inv_cancel h,\n      },\n    },\n  },\nend\n\n\n\nlemma smul_set_bounded (c : ℝ) {A : set V} (hA : metric.bounded A) :\nmetric.bounded (c • A) :=\nbegin\n  rcases hA with ⟨C, hC⟩,\n  refine ⟨∥c∥ * C, _⟩,\n  intros x hx y hy,\n  rcases set.mem_smul_set.mp hx with ⟨px, hpx, rfl⟩,\n  rcases set.mem_smul_set.mp hy with ⟨py, hpy, rfl⟩,\n  rw [dist_smul],\n  refine mul_le_mul_of_nonneg_left _ _,\n  {exact hC px hpx py hpy},\n  {apply norm_nonneg},\nend\n\nlemma set_bounded_of_smul {c : ℝ} (h : c > 0) {A : set V} (hA : metric.bounded (c • A)) :\nmetric.bounded A :=\nbegin\n  convert smul_set_bounded c⁻¹ hA,\n  rw [inv_smul_smul₀ (ne_of_gt h)],\nend\n\nlemma translate_set_bounded {A : set V} (hA : metric.bounded A) (v : V) :\nmetric.bounded (A + {v}) :=\nbegin\n  rcases hA with ⟨C, hC⟩,\n  refine ⟨C, _⟩,\n  intros x hx y hy,\n  rcases hx with ⟨xa, xv, hxa, hxv, rfl⟩,\n  rcases hy with ⟨ya, yv, hya, hyv, rfl⟩,\n  cases set.eq_of_mem_singleton hxv,\n  cases set.eq_of_mem_singleton hyv,\n  rw [dist_add_right],\n  tauto,\nend\n\n\nlemma diam_smul {A : set V}  (hA : metric.bounded A) {c : ℝ} (h : c ≥ 0) :\nmetric.diam (c • A) = c * (metric.diam A) :=\nbegin\n  revert A c,\n  suffices hle : ∀ {A : set V} (hA : metric.bounded A) {c : ℝ}, c ≥ 0 → metric.diam (c • A) ≤ c * metric.diam A,\n  {\n    intros A c hA hc,\n    apply le_antisymm,\n    {exact hle hA hc},\n    {\n      by_cases h : c = 0,\n      {\n        rw [h, zero_mul],\n        exact metric.diam_nonneg,\n      },\n      {\n        replace hc := ne.lt_of_le (h ∘ eq.symm) hc,\n        have := hle (smul_set_bounded c hA) (le_of_lt (inv_pos_of_pos hc)),\n        rw [←mul_le_mul_left (inv_pos_of_pos hc), ←mul_assoc],\n        rw [inv_mul_cancel (ne_of_gt hc), one_mul],\n        convert this,\n        rw [inv_smul_smul₀ (ne_of_gt hc)],\n      }\n    },\n  },\n  {\n    intros A hA c hc,\n    refine metric.diam_le_of_forall_dist_le _ _,\n    {\n      have : metric.diam A ≥ 0 := metric.diam_nonneg,\n      positivity,\n    },\n    {\n      intros x hx y hy,\n      rcases set.mem_smul_set.mp hx with ⟨px, hpx, rfl⟩,\n      rcases set.mem_smul_set.mp hy with ⟨py, hpy, rfl⟩,\n      rw [dist_smul, real.norm_eq_abs, abs_of_nonneg hc],\n      apply mul_le_mul_of_nonneg_left _ hc,\n      exact metric.dist_le_diam_of_mem hA hpx hpy,\n    },\n  },\nend\n\nlemma diam_translate {A : set V} (hA : metric.bounded A) (v : V) :\nmetric.diam (A + {v}) = metric.diam A :=\nbegin\n  revert A v,\n  suffices h : ∀ {A : set V} (hA : metric.bounded A) (v : V), metric.diam (A + {v}) ≤ metric.diam A,\n  {\n    intros A v hA,\n    apply le_antisymm,\n    {\n      exact h hA v,\n    },\n    {\n      convert h (translate_set_bounded hA v) (-v),\n      simp only [add_assoc, set.singleton_add_singleton, add_neg_self],\n      simp only [set.add_singleton, add_zero, set.image_id'],\n    },\n  },\n  {\n    intros A hA v,\n    refine metric.diam_le_of_forall_dist_le _ _,\n    {exact metric.diam_nonneg},\n    {\n      intros x hx y hy,\n      rcases hx with ⟨xa, xv, hxa, hxv, rfl⟩,\n      rcases hy with ⟨ya, yv, hya, hyv, rfl⟩,\n      cases set.eq_of_mem_singleton hxv,\n      cases set.eq_of_mem_singleton hyv,\n      rw [dist_add_right],\n      exact metric.dist_le_diam_of_mem hA hxa hya,\n    },\n  },\nend\n\nlemma chop_scale_translate {k₁ k₂ : ℕ} {c : ℝ} (v : V)\n(φ : fin k₁.succ → fin k₂.succ)\n(G : unbounded_microid_generator V k₂) :\nchop_generator' φ (scale_translate_gen c v G) = scale_translate_gen c v (chop_generator' φ G) :=\nbegin\n  simp only [chop_generator', scale_translate_gen, scale_gen, translate_gen],\nend\n\nlemma chop_scale_translate' {k₁ k₂ : ℕ} {c : ℝ} (v : V)\n(φ : fin k₁.succ → fin k₂.succ)\n(G : unbounded_microid_generator V k₂) :\n(scale_translate_gen c v G) ∘ φ = scale_translate_gen c v (G ∘ φ) :=\nbegin\n  simp only [chop_generator', scale_translate_gen, scale_gen, translate_gen],\nend\n\nlemma diam_scale_translate {k : ℕ} {c : ℝ} (hc : c ≥ 0) (v : V)\n(G : unbounded_microid_generator V k) :\ndiam_generator' (scale_translate_gen c v G) = c * diam_generator' G :=\nbegin\n  simp only [scale_translate_gen, scale_gen, translate_gen],\n  simp only [←pi.smul_def, diam_generator'],\n  simp only [set_image_smul'],\n  simp only [diam_generator', set.image_univ],\n  rw [diam_smul (pi_range_bounded (λ i, G i + v)) hc, set.image_univ.symm],\n  simp only [set_image_translate],\n  rw [set.image_univ, diam_translate (pi_range_bounded G)],\nend\n\nlemma diam_chop_zero_of_diam_zero {k₁ k₂ : ℕ}\n(φ : fin k₁.succ → fin k₂.succ)\n(G : unbounded_microid_generator V k₂) :\ndiam_generator' G = 0 → diam_generator' (chop_generator' φ G) = 0 :=\nbegin\n  simp only [diam_generator', chop_generator'],\n  rw [set.image_comp],\n  intro h,\n  refine le_antisymm _ metric.diam_nonneg,\n  refine le_trans (metric.diam_mono _ _) (le_of_eq h),\n  {\n    simp only [function.comp_app, set.image_univ, set.range_id'],\n    apply set.range_comp_subset_range,\n  },\n  {\n    rw [←set.image_comp, set.image_univ],\n    apply pi_range_bounded,\n  }\nend\n\nlemma scale_translate_zero {k : ℕ} {v : V} {G : unbounded_microid_generator V k} :\nscale_translate_gen 0 v G = 0 :=\nbegin\n  simp only [scale_translate_gen, scale_gen, translate_gen, zero_smul],\n  refl,\nend\n\nlemma norm_chop_norm_eq_norm_chop {k₁ k₂ : ℕ}\n(φ : fin k₁.succ → fin k₂.succ)\n(G : unbounded_microid_generator V k₂) :\nnorm_generator' (chop_generator' φ (norm_generator' G)) = norm_generator' (chop_generator' φ G) :=\nbegin\n  simp only [norm_generator_factor, chop_scale_translate, diam_scale_translate],\n  by_cases h : diam_generator' G = 0,\n  {\n    simp only [h, inv_zero, zero_mul, diam_chop_zero_of_diam_zero _ _ h,\n      scale_translate_zero],\n    simp only [scale_translate_gen, translate_gen],\n    simp only [pi.zero_apply, neg_zero, add_zero],\n    simp only [scale_gen, smul_zero],\n    refl,\n  },\n  {\n    rw [scale_translate_scale_translate (inv_ne_zero h)],\n    congr,\n    {\n      simp only [mul_inv, inv_inv],\n      rw [diam_scale_translate _],\n      rw [mul_comm, mul_inv, inv_inv],\n      rw [←mul_assoc, inv_mul_cancel h, one_mul],\n      apply inv_nonneg_of_nonneg,\n      exact metric.diam_nonneg,\n    },\n    {\n      rw [inv_inv],\n      simp only [scale_translate_gen, scale_gen, translate_gen],\n      simp only [chop_generator'],\n      simp only [smul_neg, smul_inv_smul₀ h, neg_add, neg_neg, add_assoc,\n        add_neg_self, add_zero],\n    },\n  },\nend\n\nnoncomputable def prunenorm_generator {k : ℕ} {c : ℕ}\n(φ : fin c.succ → fin k.succ)\n(G : microid_generator_space V k) : microid_generator_space V c :=\nnorm_generator (chop_generator φ G)\n\nlemma prunenorm_def {k : ℕ} {c : ℕ}\n(φ : fin c.succ → fin k.succ) :\n(prunenorm_generator φ : microid_generator_space V k → microid_generator_space V c) =\nnorm_generator ∘ chop_generator φ := rfl\n\nlemma norm_generator_idempotent {k : ℕ} (G : unbounded_microid_generator V k) :\nnorm_generator' (norm_generator' G) = norm_generator' G :=\nbegin\n  simp only [norm_generator'],\n  by_cases h : diam_generator' G = 0,\n  {\n    simp only [inv_zero, h],\n    simp only [diam_generator'],\n    simp only [set.image_univ],\n    simp only [scale_translate_zero, pi.zero_apply, neg_zero],\n    simp only [scale_translate_gen, scale_gen, translate_gen],\n    simp only [pi.zero_apply, add_zero, smul_zero],\n    refl,\n  },\n  {\n    simp only [scale_translate_scale_translate (inv_ne_zero h)],\n    congr,\n    {\n      have dnn: diam_generator' G ≥ 0 := metric.diam_nonneg,\n      have idnn: (diam_generator' G)⁻¹ ≥ 0,\n      {\n        apply inv_nonneg_of_nonneg,\n        exact metric.diam_nonneg,\n      },\n      rw [diam_scale_translate idnn, mul_inv, inv_inv],\n      rw [←inv_inv (diam_generator' G)],\n      generalize : (diam_generator' G)⁻¹ = x,\n      rw [inv_inv],\n      apply inv_mul_mul_self,\n    },\n    {\n      rw [inv_inv, scale_translate_gen, scale_gen, translate_gen],\n      simp only [add_right_neg, smul_zero, neg_zero, zero_add],\n    },\n  },\nend\n\nlemma diam_norm_generator {k : ℕ}\n(G : unbounded_microid_generator V k) :\ndiam_generator' (norm_generator' G) = 1 ∨ diam_generator' G = 0 :=\nbegin\n  simp only [norm_generator_factor],\n  rw [diam_scale_translate _],\n  {\n    by_cases h : diam_generator' G = 0,\n    {\n      right,\n      exact h,\n    },\n    {\n      left,\n      exact inv_mul_cancel h,\n    },\n  },\n  {\n    exact inv_nonneg_of_nonneg metric.diam_nonneg,\n  },\nend\n\nlemma norm_generator_apply_zero {k : ℕ}\n(G : unbounded_microid_generator V k) :\n(norm_generator' G) 0 = 0 :=\nbegin\n  simp only [norm_generator', scale_translate_gen, scale_gen, translate_gen],\n  rw [←sub_eq_add_neg, sub_self, smul_zero],\nend\n\n/- lemma translate_scale_eq_norm_generator {k : ℕ}\n{c : ℝ} (hc : c ≥ 0) (v : V) (G : unbounded_microid_generator V k) :\ndiam_generator' (scale_translate_gen c v G) = 1 ∧ (scale_translate_gen c v G 0 = 0) →\ntranslate_gen v (scale_gen c G) = norm_generator' G :=\nbegin\n  admit,\nend -/\n\nlemma translate_scale_eq_norm_generator' {k : ℕ} {c : ℝ} {v : V}\n(G H : unbounded_microid_generator V k)\n(h : H = translate_gen v (scale_gen c G)) (hc : c ≥ 0) :\n(diam_generator' H = 1 ∨ diam_generator' G = 0) → H 0 = 0 → H = norm_generator' G :=\nbegin\n  intros hd hz,\n  cases hd,\n  {\n    simp only [h, norm_generator_factor, scale_translate_gen, scale_gen, translate_gen] at hz hd ⊢,\n    replace hz := eq_neg_of_add_eq_zero_right hz,\n    simp only [hz],\n    funext,\n    rw [←sub_eq_add_neg],\n    rw [←sub_eq_add_neg],\n    rw [←smul_sub],\n    congr,\n    apply eq_inv_of_mul_eq_one_left,\n    rw [diam_generator', set.image_univ, ←diam_smul (pi_range_bounded _) hc],\n    rw [←set.image_univ],\n    rw [←set_image_smul', set.image_univ],\n    rw [←diam_translate (pi_range_bounded _), ←set.image_univ],\n    simp only [set_image_translate, diam_generator'] at hd,\n    exact hd,\n    all_goals {apply_instance},\n  },\n  {\n    simp only [norm_generator', hd, h, scale_translate_gen, scale_gen, translate_gen] at hz ⊢,\n    replace hz := eq_neg_of_add_eq_zero_right hz,\n    simp only [hz],\n    funext,\n    rw [const_of_diam_zero hd l 0, ←sub_eq_add_neg, ←sub_eq_add_neg],\n    simp only [sub_self, smul_zero],\n  }\nend\n\nlemma diam_zero_of_diam_norm_zero {k : ℕ}\n(G : unbounded_microid_generator V k) :\ndiam_generator' (norm_generator' G) = 0 → diam_generator' G = 0 :=\nbegin\n  intro h,\n  rcases diam_norm_generator G,\n  {linarith},\n  {assumption},\nend\n\nlemma diam_norm_one_of_diam_ne_zero {k : ℕ}\n(G : unbounded_microid_generator V k) :\ndiam_generator' G ≠ 0 → diam_generator' (norm_generator' G) = 1 :=\nbegin\n  intro h,\n  rcases diam_norm_generator G,\n  {assumption},\n  {contradiction},\nend\n\n--set_option pp.all true\nlemma prunenorm_prunenorm {c₁ c₂ c₃: ℕ}\n(φ₁ : fin c₁.succ → fin c₂.succ) (φ₂ : fin c₂.succ → fin c₃.succ)\n(G : microid_generator_space V c₃) :\nprunenorm_generator φ₁ (prunenorm_generator φ₂ G) =\nprunenorm_generator (φ₂ ∘ φ₁) G :=\nbegin\n  simp only [prunenorm_generator, norm_generator, chop_generator],\n  simp only [subtype.coe_mk, subtype.mk_eq_mk],\n  simp only [norm_chop_norm_eq_norm_chop, chop_generator'],\n  refine translate_scale_eq_norm_generator' _ _\n    _ _ _ _, rotate, rotate,\n  {\n    conv {to_lhs, simp only [norm_generator']},\n    have := chop_scale_translate,\n    simp only [chop_generator'] at this,\n    rw [this],\n    rw [scale_translate_scale_translate'],\n  },\n  {\n    simp only [diam_generator'],\n    refine mul_nonneg _ _,\n    all_goals {exact inv_nonneg_of_nonneg metric.diam_nonneg},\n  },\n  {\n    by_cases h: diam_generator' (↑G ∘ φ₂ ∘ φ₁) = 0,\n    {\n      right,\n      exact h,\n    },\n    {\n      left,\n      apply diam_norm_one_of_diam_ne_zero,\n      simp only [norm_generator'],\n      have : diam_generator' ((coe G : fin c₃.succ → V) ∘ φ₂) > 0,\n      {\n        simp only [diam_generator', set.image_univ],\n        rw [diam_generator'] at h,\n        replace h := ne.lt_of_le' h metric.diam_nonneg,\n        rw [set.image_univ, ←function.comp.assoc] at h,\n        refine lt_of_lt_of_le h _,\n        refine metric.diam_mono _ (pi_range_bounded _),\n        apply set.range_comp_subset_range,\n      },\n      rw [chop_scale_translate', diam_scale_translate],\n      {\n        apply mul_ne_zero,\n        {exact ne_of_gt (inv_pos_of_pos this)},\n        {rw [function.comp.assoc], exact h},\n      },\n      {exact le_of_lt (inv_pos_of_pos this)},\n    },\n  },\n  {\n    apply norm_generator_apply_zero,\n  },\nend\n\nlemma sub_singleton_eq_add_singleton (A : set V) (v : V) :\nA - {v} = A + {-v} :=\nbegin\n  ext,\n  simp only [set.mem_add, set.mem_sub, set.mem_singleton_iff],\n  split,\n  all_goals {\n    intro h,\n    rcases h with ⟨a, vv, ha, rfl, rfl⟩,\n    refine ⟨a, _, ha, rfl, _⟩,\n    rw [←sub_eq_add_neg],\n  },\nend\n\nlemma diam_norm_generator_eq {k : ℕ}\n(G : unbounded_microid_generator V k) :\ndiam_generator' G ≠ 0 → diam_generator' (norm_generator' G) = 1 :=\nbegin\n  intro h,\n  rcases norm_generator_positive_factor₂ G h with ⟨hgt, heq⟩,\n  simp only [diam_generator', scale_translate_gen, scale_gen, translate_gen, heq],\n  rw [←pi.smul_def, set_image_smul'],\n  rw [diam_smul],\n  {\n    simp only [←sub_eq_add_neg],\n    simp only [←pi.sub_def],\n    rw [set_image_sub'],\n    rw [sub_singleton_eq_add_singleton],\n    rw [diam_translate],\n    {\n      convert inv_mul_cancel h,\n    },\n    {\n      convert (pi_range_bounded G),\n      exact set.image_univ,\n    }\n  },\n  {\n    rw [set.image_univ],\n    refine pi_range_bounded _,\n  },\n  {\n    apply inv_nonneg_of_nonneg,\n    exact metric.diam_nonneg,\n  },\nend\n\nlemma range_scale_translate {k : ℕ}\n{c : ℝ} {v : V} {G : unbounded_microid_generator V k} :\n(scale_translate_gen c v G) '' set.univ = c • ((G '' set.univ) + {v}) :=\nbegin\n  simp only [scale_translate_gen, scale_gen, translate_gen],\n  ext,\n  simp only [set.mem_image, set.mem_smul, set.mem_add],\n  split,\n  {\n    intro h,\n    rcases h with ⟨l, -, rfl⟩,\n    apply set.smul_mem_smul_set,\n    refine ⟨G l, v, _, _, rfl⟩,\n    {exact ⟨l, set.mem_univ _, rfl⟩},\n    {apply set.mem_singleton},\n  },\n  {\n    intro h,\n    rcases h with ⟨y, ⟨py, vv, ⟨ppy, -, rfl⟩, hvv, rfl⟩, rfl⟩,\n    cases set.eq_of_mem_singleton hvv,\n    refine ⟨ppy, set.mem_univ _, rfl⟩,\n  },\nend\n\nlemma polytope_of_norm_generator_smul {k : ℕ}\n(G : microid_generator_space V k) :\n∃ c : ℝ, c > 0 ∧\n(polytope_of_microid_generator (norm_generator G)).val =\nc • ((polytope_of_microid_generator G).val + {-(G.val 0)}) :=\nbegin\n  rcases norm_generator_positive_factor G.val with ⟨c, hc₁, hc₂⟩,\n  refine ⟨c, hc₁, _⟩,\n  simp only [polytope_of_microid_generator, hc₂, norm_generator],\n  rw [←set.image_univ],\n  rw [range_scale_translate],\n  rw [/- set_image_smul', -/ convex_hull_smul],\n  congr,\n  conv {to_rhs, rw [←@convex_hull_singleton ℝ V _ _ _ (-(G.val 0))]},\n  rw [←convex_hull_add, set.image_univ],\nend\n\nlemma h_vector_span_homothety (A : set V) {c : ℝ} (v : V)\n(h : c > 0) :\nvector_span ℝ A ≥ vector_span ℝ (c • (A + {v})) :=\nbegin\n  refine submodule.span_le.mpr _,\n  simp only [vector_span],\n  rintro x ⟨a₁, a₂, ha₁, ha₂, rfl⟩,\n  rcases set.mem_smul_set.mp ha₁ with ⟨d₁, ⟨e₁, v₁, he₁, hv₁, rfl⟩, rfl⟩,\n  rcases set.mem_smul_set.mp ha₂ with ⟨d₂, ⟨e₂, v₂, he₂, hv₂, rfl⟩, rfl⟩,\n  rcases set.eq_of_mem_singleton hv₁,\n  rcases set.eq_of_mem_singleton hv₂,\n  simp only [vsub_eq_sub],\n  rw [←smul_sub],\n  change c • (e₁ + v - (e₂ + v)) ∈ /- need change to remove ↑ here -/ (submodule.span ℝ (A -ᵥ A)),\n  refine submodule.smul_mem _ c _,\n  rw [add_sub_add_right_eq_sub],\n  apply submodule.subset_span,\n  refine ⟨e₁, e₂, he₁, he₂, rfl⟩,\nend\n\nlemma vector_span_homothety {A : set V} {c : ℝ} (v : V)\n(h : c > 0) :\nvector_span ℝ (c • (A + {v})) = vector_span ℝ A :=\nbegin\n  apply le_antisymm,\n  {\n    exact h_vector_span_homothety A v h,\n  },\n  {\n    -- might become a separate lemma!\n    have : A = c⁻¹ • ((c • (A + {v})) + {-c • v}),\n    {\n      simp only [smul_add, neg_smul, set.smul_set_singleton, smul_neg],\n      simp only [inv_smul_smul₀ (ne_of_gt h)],\n      rw [add_assoc],\n      -- Worked with squeeze_simp, but doesn't work now: simp only [set.singleton_add_singleton, set.singleton_add_singleton, add_right_neg, set.add_singleton, add_zero, set.image_id', eq_self_iff_true],\n      simp only [set.singleton_add_singleton, add_right_neg, add_zero],\n      simp only [set.add_singleton, add_zero, set.image_id'],\n    },\n    convert h_vector_span_homothety (c • (A + {v})) (-c • v) (inv_pos_of_pos h),\n  },\nend\n\nlemma gen_lfe_norm {k : ℕ}\n(G : microid_generator_space V k) :\nlfe ⊤ (polytope_of_microid_generator G) (polytope_of_microid_generator (norm_generator G)) :=\nbegin\n  apply lfe_symm,\n  rcases polytope_of_norm_generator_smul G with ⟨c, hc₁, hc₂⟩,\n  refine ⟨c • (-G.val 0), c, hc₁, _⟩,\n  simp only [bm.τ, convex_body_of_polytope, hc₂],\n  --simp only [face_smul hc₁, face_translate],\n  simp only [normal_face_homothety _ hc₁],\n  simp only [smul_add],\n  simp only [set.smul_set_Union₂],\n  simp only [set.add_Union₂],\n  simp only [set.smul_set_singleton],\n  congr, funext, congr, funext,\n  nth_rewrite 0 [add_comm],\nend\n\nlemma lim_norm_gen {k : ℕ}\n{t : ℕ → unbounded_microid_generator V k}\n{tl : unbounded_microid_generator V k }\n(htt : filter.tendsto t filter.at_top (𝓝 tl))\n(hd : ∀ n : ℕ, diam_generator' (t n) = 1) :\ndiam_generator' tl = 1 :=\nbegin\n  simp only [diam_generator'],\n  have tt₁ : filter.tendsto (λ n : ℕ, diam_generator' (t n)) filter.at_top (𝓝 (diam_generator' tl)),\n  {\n    have := @continuous.continuous_at (unbounded_microid_generator V k) ℝ _ _ _ _ (diam_continuous k),\n    convert (filter.tendsto.comp this htt),\n  },\n  have tt₂ : filter.tendsto (λ n : ℕ, diam_generator' (t n)) filter.at_top (𝓝 1),\n  {\n    simp only [hd],\n    exact tendsto_const_nhds,\n  },\n  exact tendsto_nhds_unique tt₁ tt₂,\nend\n\nlemma prunenorm_id_eq_norm {k : ℕ} :\n(prunenorm_generator id : microid_generator_space V k → microid_generator_space V k) =\nnorm_generator :=\nbegin\n  funext,\n  simp only [prunenorm_generator, chop_generator, subtype.val_eq_coe,\n  function.comp.right_id, subtype.coe_eta],\n  simp only [chop_generator', function.comp.right_id, subtype.coe_eta],\nend", "meta": {"author": "datokrat", "repo": "triangle-bodies", "sha": "532a2820a0cb3686afddb60051340acf2f03db9e", "save_path": "github-repos/lean/datokrat-triangle-bodies", "path": "github-repos/lean/datokrat-triangle-bodies/triangle-bodies-532a2820a0cb3686afddb60051340acf2f03db9e/src/microid_ops.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.469592439837581}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nAdditional theorems about the `vector` type.\n-/\nimport data.vector data.list.basic data.sigma data.equiv.basic\n       category.traversable\n\nnamespace vector\nvariables {α : Type*} {n : ℕ}\n\nattribute [simp] head_cons tail_cons\n\ninstance [inhabited α] : inhabited (vector α n) :=\n⟨of_fn (λ _, default α)⟩\n\ntheorem to_list_injective : function.injective (@to_list α n) :=\nsubtype.val_injective\n\n@[simp] theorem to_list_of_fn : ∀ {n} (f : fin n → α), to_list (of_fn f) = list.of_fn f\n| 0     f := rfl\n| (n+1) f := by rw [of_fn, list.of_fn_succ, to_list_cons, to_list_of_fn]\n\n@[simp] theorem mk_to_list :\n  ∀ (v : vector α n) h, (⟨to_list v, h⟩ : vector α n) = v\n| ⟨l, h₁⟩ h₂ := rfl\n\ntheorem nth_eq_nth_le : ∀ (v : vector α n) (i),\n  nth v i = v.to_list.nth_le i.1 (by rw to_list_length; exact i.2)\n| ⟨l, h⟩ i := rfl\n\n@[simp] theorem nth_of_fn {n} (f : fin n → α) (i) : nth (of_fn f) i = f i :=\nby rw [nth_eq_nth_le, ← list.nth_le_of_fn f];\n   congr; apply to_list_of_fn\n\n@[simp] theorem of_fn_nth (v : vector α n) : of_fn (nth v) = v :=\nbegin\n  rcases v with ⟨l, rfl⟩,\n  apply to_list_injective,\n  change nth ⟨l, eq.refl _⟩ with λ i, nth ⟨l, rfl⟩ i,\n  simp [nth, list.of_fn_nth_le]\nend\n\n@[simp] theorem nth_tail : ∀ (v : vector α n.succ) (i : fin n),\n  nth (tail v) i = nth v i.succ\n| ⟨a::l, e⟩ ⟨i, h⟩ := by simp [nth_eq_nth_le]; refl\n\n@[simp] theorem tail_of_fn {n : ℕ} (f : fin n.succ → α) :\n  tail (of_fn f) = of_fn (λ i, f i.succ) :=\n(of_fn_nth _).symm.trans $ by congr; funext i; simp\n\ntheorem head'_to_list : ∀ (v : vector α n.succ),\n  (to_list v).head' = some (head v)\n| ⟨a::l, e⟩ := rfl\n\ndef reverse (v : vector α n) : vector α n :=\n⟨v.to_list.reverse, by simp⟩\n\n@[simp] theorem nth_zero : ∀ (v : vector α n.succ), nth v 0 = head v\n| ⟨a::l, e⟩ := rfl\n\n@[simp] theorem head_of_fn\n  {n : ℕ} (f : fin n.succ → α) : head (of_fn f) = f 0 :=\nby rw [← nth_zero, nth_of_fn]\n\n@[simp] theorem nth_cons_zero\n  (a : α) (v : vector α n) : nth (a :: v) 0 = a :=\nby simp [nth_zero]\n\n@[simp] theorem nth_cons_succ\n  (a : α) (v : vector α n) (i : fin n) : nth (a :: v) i.succ = nth v i :=\nby rw [← nth_tail, tail_cons]\n\ndef {u} m_of_fn {m} [monad m] {α : Type u} : ∀ {n}, (fin n → m α) → m (vector α n)\n| 0     f := pure nil\n| (n+1) f := do a ← f 0, v ← m_of_fn (λi, f i.succ), pure (a :: v)\n\ntheorem m_of_fn_pure {m} [monad m] [is_lawful_monad m] {α} :\n  ∀ {n} (f : fin n → α), @m_of_fn m _ _ _ (λ i, pure (f i)) = pure (of_fn f)\n| 0     f := rfl\n| (n+1) f := by simp [m_of_fn, @m_of_fn_pure n, of_fn]\n\ndef {u} mmap {m} [monad m] {α} {β : Type u} (f : α → m β) :\n  ∀ {n}, vector α n → m (vector β n)\n| _ ⟨[], rfl⟩   := pure nil\n| _ ⟨a::l, rfl⟩ := do h' ← f a, t' ← mmap ⟨l, rfl⟩, pure (h' :: t')\n\n@[simp] theorem mmap_nil {m} [monad m] {α β} (f : α → m β) :\n  mmap f nil = pure nil := rfl\n\n@[simp] theorem mmap_cons {m} [monad m] {α β} (f : α → m β) (a) :\n  ∀ {n} (v : vector α n), mmap f (a::v) =\n  do h' ← f a, t' ← mmap f v, pure (h' :: t')\n| _ ⟨l, rfl⟩ := rfl\n\n@[extensionality] theorem ext : ∀ {v w : vector α n}\n  (h : ∀ m : fin n, vector.nth v m = vector.nth w m), v = w\n| ⟨v, hv⟩ ⟨w, hw⟩ h := subtype.eq (list.ext_le (by rw [hv, hw])\n  (λ m hm hn, h ⟨m, hv ▸ hm⟩))\n\ndef to_array : vector α n → array n α\n| ⟨xs, h⟩ := cast (by rw h) xs.to_array\n\nend vector\n\nnamespace vector\n\nuniverses u\nvariables {n : ℕ}\n\nsection traverse\n\nvariables {F G : Type u → Type u}\nvariables [applicative F] [applicative G]\n\nopen applicative functor\nopen list (cons) nat\n\nprivate def traverse_aux {α β : Type u} (f : α → F β) :\n  Π (x : list α), F (vector β x.length)\n| []      := pure vector.nil\n| (x::xs) := vector.cons <$> f x <*> traverse_aux xs\n\nprotected def traverse {α β : Type u} (f : α → F β) : vector α n → F (vector β n)\n| ⟨v, Hv⟩ := cast (by rw Hv) $ traverse_aux f v\n\nvariables [is_lawful_applicative F] [is_lawful_applicative G]\nvariables {α β γ : Type u}\n\n@[simp] protected lemma traverse_def\n  (f : α → F β) (x : α) : ∀ (xs : vector α n),\n  (x :: xs).traverse f = cons <$> f x <*> xs.traverse f :=\nby rintro ⟨xs, rfl⟩; refl\n\nprotected lemma id_traverse : ∀ (x : vector α n), x.traverse id.mk = x :=\nbegin\n  rintro ⟨x, rfl⟩, dsimp [vector.traverse, cast],\n  induction x with x xs IH, {refl},\n  simp! [IH], refl\nend\n\nopen function\n\nprotected lemma comp_traverse (f : β → F γ) (g : α → G β) : ∀ (x : vector α n),\n  vector.traverse (comp.mk ∘ functor.map f ∘ g) x =\n  comp.mk (vector.traverse f <$> vector.traverse g x) :=\nby rintro ⟨x, rfl⟩; dsimp [vector.traverse, cast];\n   induction x with x xs; simp! [cast, *] with functor_norm;\n   [refl, simp [(∘)]]\n\nprotected lemma traverse_eq_map_id {α β} (f : α → β) : ∀ (x : vector α n),\n  x.traverse (id.mk ∘ f) = id.mk (map f x) :=\nby rintro ⟨x, rfl⟩; simp!;\n   induction x; simp! * with functor_norm; refl\n\nvariable (η : applicative_transformation F G)\n\nprotected lemma naturality {α β : Type*}\n  (f : α → F β) : ∀ (x : vector α n),\n  η (x.traverse f) = x.traverse (@η _ ∘ f) :=\nby rintro ⟨x, rfl⟩; simp! [cast];\n   induction x with x xs IH; simp! * with functor_norm\n\nend traverse\n\ninstance : traversable.{u} (flip vector n) :=\n{ traverse := @vector.traverse n,\n  map := λ α β, @vector.map.{u u} α β n }\n\ninstance : is_lawful_traversable.{u} (flip vector n) :=\n{ id_traverse := @vector.id_traverse n,\n  comp_traverse := @vector.comp_traverse n,\n  traverse_eq_map_id := @vector.traverse_eq_map_id n,\n  naturality := @vector.naturality n,\n  id_map := by intros; cases x; simp! [(<$>)],\n  comp_map := by intros; cases x; simp! [(<$>)] }\n\nend vector\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/data/vector2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.7248702702332475, "lm_q1q2_score": 0.46956967916117365}}
{"text": "/-\nCopyright (c) 2022 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\nimport Init.Data.Array.Basic\nimport Init.Data.Nat.Linear\nimport Init.Data.List.BasicAux\n\ntheorem List.sizeOf_get_lt [SizeOf α] (as : List α) (i : Fin as.length) : sizeOf (as.get i) < sizeOf as := by\n  match as, i with\n  | [],    i      => apply Fin.elim0 i\n  | a::as, ⟨0, _⟩ => simp_arith [get]\n  | a::as, ⟨i+1, h⟩ =>\n    simp [get]\n    have h : i < as.length := Nat.lt_of_succ_lt_succ h\n    have ih := sizeOf_get_lt as ⟨i, h⟩\n    exact Nat.lt_of_lt_of_le ih (Nat.le_add_left ..)\n\nnamespace Array\n\ninstance [DecidableEq α] : Membership α (Array α) where\n  mem a as := as.contains a\n\ntheorem sizeOf_get_lt [SizeOf α] (as : Array α) (i : Fin as.size) : sizeOf (as.get i) < sizeOf as := by\n  cases as; rename_i as\n  simp [get]\n  have ih := List.sizeOf_get_lt as i\n  exact Nat.lt_trans ih (by simp_arith)\n\ntheorem sizeOf_lt_of_mem [DecidableEq α] [SizeOf α] {as : Array α} (h : a ∈ as) : sizeOf a < sizeOf as := by\n  simp [Membership.mem, contains, any, Id.run, BEq.beq, anyM] at h\n  let rec aux (j : Nat) (h : anyM.loop (m := Id) (fun b => decide (a = b)) as as.size (Nat.le_refl ..) j = true) : sizeOf a < sizeOf as := by\n    unfold anyM.loop at h\n    split at h\n    · simp [Bind.bind, pure] at h; split at h\n      next he => subst a; apply sizeOf_get_lt\n      next => have ih := aux (j+1) h; assumption\n    · contradiction\n  apply aux 0 h\ntermination_by aux j _ => as.size - j\n\n@[simp] theorem sizeOf_get [SizeOf α] (as : Array α) (i : Fin as.size) : sizeOf (as.get i) < sizeOf as := by\n  cases as\n  simp [get]\n  apply Nat.lt_trans (List.sizeOf_get ..)\n  simp_arith\n\n/-- This tactic, added to the `decreasing_trivial` toolbox, proves that\n`sizeOf arr[i] < sizeOf arr`, which is useful for well founded recursions\nover a nested inductive like `inductive T | mk : Array T → T`. -/\nmacro \"array_get_dec\" : tactic =>\n  `(tactic| first\n    | apply sizeOf_get\n    | apply Nat.lt_trans (sizeOf_get ..); simp_arith)\n\nmacro_rules | `(tactic| decreasing_trivial) => `(tactic| array_get_dec)\n\nend Array\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/src/Init/Data/Array/Mem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.46956967808260686}}
{"text": "/-\nCopyright (c) 2015 Leonardo de Moura. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n\nFinite type (type class).\n-/\nimport data.list.perm data.list.as_type data.bool data.equiv\nopen list bool unit decidable option function\n\nstructure fintype [class] (A : Type) : Type :=\n(elems : list A) (unique : nodup elems) (complete : ∀ a, a ∈ elems)\n\ndefinition elements_of (A : Type) [h : fintype A] : list A :=\n@fintype.elems A h\n\nsection\nopen equiv\ndefinition fintype_of_equiv {A B : Type} [h : fintype A] : A ≃ B → fintype B\n| (mk f g l r) :=\n  fintype.mk\n    (map f (elements_of A))\n    (nodup_map (injective_of_left_inverse l) !fintype.unique)\n    (λ b,\n      have g b ∈ elements_of A, from fintype.complete (g b),\n      have f (g b) ∈ map f (elements_of A), from mem_map f this,\n      by rewrite r at this; exact this)\nend\n\ndefinition fintype_unit [instance] : fintype unit :=\nfintype.mk [star] dec_trivial (λ u, match u with star := dec_trivial end)\n\ndefinition fintype_bool [instance] : fintype bool :=\nfintype.mk [ff, tt]\n  dec_trivial\n  (λ b, match b with | tt := dec_trivial | ff := dec_trivial end)\n\ndefinition fintype_product [instance] {A B : Type} : Π [h₁ : fintype A] [h₂ : fintype B], fintype (A × B)\n| (fintype.mk e₁ u₁ c₁) (fintype.mk e₂ u₂ c₂) :=\n  fintype.mk\n    (product e₁ e₂)\n    (nodup_product u₁ u₂)\n    (λ p,\n      match p with\n      (a, b) := mem_product (c₁ a) (c₂ b)\n      end)\n\n/- auxiliary function for finding 'a' s.t. f a ≠ g a -/\nsection find_discr\nvariables {A B : Type}\nvariable  [h : decidable_eq B]\ninclude h\ndefinition find_discr (f g : A → B) : list A → option A\n| []     := none\n| (a::l) := if f a = g a then find_discr l else some a\n\ntheorem find_discr_nil (f g : A → B) : find_discr f g [] = none :=\nrfl\n\ntheorem find_discr_cons_of_ne {f g : A → B} {a : A} (l : list A) : f a ≠ g a → find_discr f g (a::l) = some a :=\nassume ne, if_neg ne\n\ntheorem find_discr_cons_of_eq {f g : A → B} {a : A} (l : list A) : f a = g a → find_discr f g (a::l) = find_discr f g l :=\nassume eq, if_pos eq\n\ntheorem ne_of_find_discr_eq_some {f g : A → B} {a : A} : ∀ {l}, find_discr f g l = some a → f a ≠ g a\n| []     e := by contradiction\n| (x::l) e := by_cases\n  (suppose f x = g x,\n     have find_discr f g l = some a, by rewrite [find_discr_cons_of_eq l this at e]; exact e,\n     ne_of_find_discr_eq_some this)\n  (assume h : f x ≠ g x,\n     have some x = some a, by rewrite [find_discr_cons_of_ne l h at e]; exact e,\n     by clear ne_of_find_discr_eq_some; injection this; subst a; exact h)\n\ntheorem all_eq_of_find_discr_eq_none {f g : A → B} : ∀ {l}, find_discr f g l = none → ∀ a, a ∈ l → f a = g a\n| []     e a i := absurd i !not_mem_nil\n| (x::l) e a i := by_cases\n  (assume fx_eq_gx : f x = g x,\n    or.elim (eq_or_mem_of_mem_cons i)\n      (suppose a = x, by rewrite [-this at fx_eq_gx]; exact fx_eq_gx)\n      (suppose a ∈ l,\n        have aux : find_discr f g l = none, by rewrite [find_discr_cons_of_eq l fx_eq_gx at e]; exact e,\n        all_eq_of_find_discr_eq_none aux a this))\n  (suppose f x ≠ g x,\n    by rewrite [find_discr_cons_of_ne l this at e]; contradiction)\nend find_discr\n\ndefinition decidable_eq_fun [instance] {A B : Type} [h₁ : fintype A] [h₂ : decidable_eq B] : decidable_eq (A → B) :=\nλ f g,\n  match h₁ with\n  | fintype.mk e u c :=\n    match find_discr f g e with\n    | some a := λ h : find_discr f g e = some a, inr (λ f_eq_g : f = g, absurd (by rewrite f_eq_g; reflexivity) (ne_of_find_discr_eq_some h))\n    | none   := λ h : find_discr f g e = none, inl (show f = g, from funext (λ a : A, all_eq_of_find_discr_eq_none h a (c a)))\n    end rfl\n  end\n\nsection check_pred\nvariables {A : Type}\n\ndefinition check_pred (p : A → Prop) [h : decidable_pred p] : list A → bool\n| []     := tt\n| (a::l) := if p a then check_pred l else ff\n\ntheorem check_pred_cons_of_pos {p : A → Prop} [h : decidable_pred p] {a : A} (l : list A) : p a → check_pred p (a::l) = check_pred p l :=\nassume pa, if_pos pa\n\ntheorem check_pred_cons_of_neg {p : A → Prop} [h : decidable_pred p] {a : A} (l : list A) : ¬ p a → check_pred p (a::l) = ff :=\nassume npa, if_neg npa\n\ntheorem all_of_check_pred_eq_tt {p : A → Prop} [h : decidable_pred p] : ∀ {l : list A}, check_pred p l = tt → ∀ {a}, a ∈ l → p a\n| []     eqtt a ainl := absurd ainl !not_mem_nil\n| (b::l) eqtt a ainbl := by_cases\n  (suppose p b, or.elim (eq_or_mem_of_mem_cons ainbl)\n    (suppose a = b, by rewrite [this]; exact `p b`)\n    (suppose a ∈ l,\n      have check_pred p l = tt, by rewrite [check_pred_cons_of_pos _ `p b` at eqtt]; exact eqtt,\n      all_of_check_pred_eq_tt this `a ∈ l`))\n  (suppose ¬ p b,\n    by rewrite [check_pred_cons_of_neg _ this at eqtt]; exact (bool.no_confusion eqtt))\n\ntheorem ex_of_check_pred_eq_ff {p : A → Prop} [h : decidable_pred p] : ∀ {l : list A}, check_pred p l = ff → ∃ w, ¬ p w\n| []     eqtt := bool.no_confusion eqtt\n| (a::l) eqtt := by_cases\n  (suppose p a,\n    have check_pred p l = ff, by rewrite [check_pred_cons_of_pos _ this at eqtt]; exact eqtt,\n    ex_of_check_pred_eq_ff this)\n  (suppose ¬ p a, exists.intro a this)\nend check_pred\n\ndefinition decidable_forall_finite [instance] {A : Type} {p : A → Prop} [h₁ : fintype A] [h₂ : decidable_pred p]\n           : decidable (∀ x : A, p x) :=\nmatch h₁ with\n| fintype.mk e u c :=\n  match check_pred p e with\n  | tt := suppose check_pred p e = tt, inl (take a : A, all_of_check_pred_eq_tt this (c a))\n  | ff := suppose check_pred p e = ff,\n    inr (suppose ∀ x, p x,\n         obtain (a : A) (w : ¬ p a), from ex_of_check_pred_eq_ff `check_pred p e = ff`,\n         absurd (this a) w)\n  end rfl\nend\n\ndefinition decidable_exists_finite [instance] {A : Type} {p : A → Prop} [h₁ : fintype A] [h₂ : decidable_pred p]\n           : decidable (∃ x : A, p x) :=\nmatch h₁ with\n| fintype.mk e u c :=\n  match check_pred (λ a, ¬ p a) e with\n  | tt := λ h : check_pred (λ a, ¬ p a) e = tt, inr (λ ex : (∃ x, p x),\n          obtain x px, from ex,\n          absurd px (all_of_check_pred_eq_tt h (c x)))\n  | ff := λ h : check_pred (λ a, ¬ p a) e = ff, inl (\n          have ∃ x, ¬¬p x, from ex_of_check_pred_eq_ff h,\n          obtain x nnpx, from this, exists.intro x (not_not_elim nnpx))\n  end rfl\nend\n\nopen list.as_type\n-- Auxiliary function for returning a list with all elements of the type: (list.as_type l)\n-- Remark ⟪s⟫ is notation for (list.as_type l)\n-- We use this function to define the instance for (fintype ⟪s⟫)\nprivate definition ltype_elems {A : Type} {s : list A} : Π {l : list A}, l ⊆ s → list ⟪s⟫\n| []     h := []\n| (a::l) h := lval a (h a !mem_cons) :: ltype_elems (sub_of_cons_sub h)\n\nprivate theorem mem_of_mem_ltype_elems {A : Type} {a : A} {s : list A}\n                : Π {l : list A} {h : l ⊆ s} {m : a ∈ s}, mk a m ∈ ltype_elems h → a ∈ l\n| []     h m lin := absurd lin !not_mem_nil\n| (b::l) h m lin := or.elim (eq_or_mem_of_mem_cons lin)\n  (suppose mk a m = mk b (h b (mem_cons b l)),\n     as_type.no_confusion this (λ aeqb em, by rewrite [aeqb]; exact !mem_cons))\n  (suppose mk a m ∈ ltype_elems (sub_of_cons_sub h),\n     have a ∈ l, from mem_of_mem_ltype_elems this,\n     mem_cons_of_mem _ this)\n\nprivate theorem nodup_ltype_elems {A : Type} {s : list A} : Π {l : list A} (d : nodup l) (h : l ⊆ s), nodup (ltype_elems h)\n| []     d h := nodup_nil\n| (a::l) d h :=\n  have d₁    : nodup l, from nodup_of_nodup_cons d,\n  have nainl : a ∉ l, from not_mem_of_nodup_cons d,\n  let  h₁    : l ⊆ s := sub_of_cons_sub h in\n  have d₂    : nodup (ltype_elems h₁), from nodup_ltype_elems d₁ h₁,\n  have nin   : mk a (h a (mem_cons a l)) ∉ ltype_elems h₁, from\n    assume ab, absurd (mem_of_mem_ltype_elems ab) nainl,\n  nodup_cons nin d₂\n\nprivate theorem mem_ltype_elems {A : Type} {s : list A} {a : ⟪s⟫}\n                : Π {l : list A} (h : l ⊆ s), value a ∈ l → a ∈ ltype_elems h\n| []     h vainl  := absurd vainl !not_mem_nil\n| (b::l) h vainbl := or.elim (eq_or_mem_of_mem_cons vainbl)\n  (λ vaeqb : value a = b,\n   begin\n      revert vaeqb h,\n      -- TODO(Leo): check why 'cases a with va, ma' produces an incorrect proof\n      eapply as_type.cases_on a,\n      intro va ma vaeqb,\n      rewrite -vaeqb, intro h,\n      apply mem_cons\n   end)\n  (λ vainl : value a ∈ l,\n     have aux : a ∈ ltype_elems (sub_of_cons_sub h), from mem_ltype_elems (sub_of_cons_sub h) vainl,\n     mem_cons_of_mem _ aux)\n\ndefinition fintype_list_as_type [instance] {A : Type} [h : decidable_eq A] {s : list A} : fintype ⟪s⟫ :=\nlet  nds   : list A := erase_dup s in\nhave sub₁  : nds ⊆ s,   from erase_dup_sub s,\nhave sub₂  : s ⊆ nds,   from sub_erase_dup s,\nhave dnds  : nodup nds, from nodup_erase_dup s,\nlet  e     : list ⟪s⟫ := ltype_elems sub₁ in\nfintype.mk\n  e\n  (nodup_ltype_elems dnds sub₁)\n  (take a : ⟪s⟫,\n   show a ∈ e, from\n     have value a ∈ s,   from is_member a,\n     have value a ∈ nds, from sub₂ this,\n     mem_ltype_elems sub₁ this)\n", "meta": {"author": "Bolt64", "repo": "lean2-aur", "sha": "1d7148e58a17b2d326b032ed1ebf8c5217320242", "save_path": "github-repos/lean/Bolt64-lean2-aur", "path": "github-repos/lean/Bolt64-lean2-aur/lean2-aur-1d7148e58a17b2d326b032ed1ebf8c5217320242/library/data/fintype/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.724870282120402, "lm_q1q2_score": 0.4695696770040399}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.real.cau_seq\n! leanprover-community/mathlib commit 9116dd6709f303dcf781632e15fdef382b0fc579\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.GroupPower.Lemmas\nimport Mathlib.Algebra.Order.AbsoluteValue\nimport Mathlib.Algebra.Order.Group.MinMax\nimport Mathlib.Algebra.Order.Field.Basic\nimport Mathlib.Algebra.Ring.Pi\nimport Mathlib.GroupTheory.GroupAction.Pi\nimport Mathlib.Tactic.Ring\nimport Mathlib.Tactic.Set\n\n/-!\n# Cauchy sequences\n\nA basic theory of Cauchy sequences, used in the construction of the reals and p-adic numbers. Where\napplicable, lemmas that will be reused in other contexts have been stated in extra generality.\nThere are other \"versions\" of Cauchyness in the library, in particular Cauchy filters in topology.\nThis is a concrete implementation that is useful for simplicity and computability reasons.\n\n## Important definitions\n\n* `IsCauSeq`: a predicate that says `f : ℕ → β` is Cauchy.\n* `CauSeq`: the type of Cauchy sequences valued in type `β` with respect to an absolute value\n  function `abv`.\n\n## Tags\n\nsequence, cauchy, abs val, absolute value\n-/\n\n\nopen IsAbsoluteValue\n\ntheorem exists_forall_ge_and {α} [LinearOrder α] {P Q : α → Prop} :\n    (∃ i, ∀ j ≥ i, P j) → (∃ i, ∀ j ≥ i, Q j) → ∃ i, ∀ j ≥ i, P j ∧ Q j\n  | ⟨a, h₁⟩, ⟨b, h₂⟩ =>\n    let ⟨c, ac, bc⟩ := exists_ge_of_linear a b\n    ⟨c, fun _ hj => ⟨h₁ _ (le_trans ac hj), h₂ _ (le_trans bc hj)⟩⟩\n#align exists_forall_ge_and exists_forall_ge_and\n\nsection\n\nvariable [LinearOrderedField α] [Ring β] (abv : β → α) [IsAbsoluteValue abv]\n\ntheorem rat_add_continuous_lemma {ε : α} (ε0 : 0 < ε) :\n    ∃ δ > 0, ∀ {a₁ a₂ b₁ b₂ : β}, abv (a₁ - b₁) < δ → abv (a₂ - b₂) < δ →\n      abv (a₁ + a₂ - (b₁ + b₂)) < ε :=\n  ⟨ε / 2, half_pos ε0, fun {a₁ a₂ b₁ b₂} h₁ h₂ => by\n    simpa [add_halves, sub_eq_add_neg, add_comm, add_left_comm, add_assoc] using\n      lt_of_le_of_lt (abv_add abv _ _) (add_lt_add h₁ h₂)⟩\n#align rat_add_continuous_lemma rat_add_continuous_lemma\n\ntheorem rat_mul_continuous_lemma {ε K₁ K₂ : α} (ε0 : 0 < ε) :\n    ∃ δ > 0, ∀ {a₁ a₂ b₁ b₂ : β}, abv a₁ < K₁ → abv b₂ < K₂ → abv (a₁ - b₁) < δ →\n      abv (a₂ - b₂) < δ → abv (a₁ * a₂ - b₁ * b₂) < ε := by\n  have K0 : (0 : α) < max 1 (max K₁ K₂) := lt_of_lt_of_le zero_lt_one (le_max_left _ _)\n  have εK := div_pos (half_pos ε0) K0\n  refine' ⟨_, εK, fun {a₁ a₂ b₁ b₂} ha₁ hb₂ h₁ h₂ => _⟩\n  replace ha₁ := lt_of_lt_of_le ha₁ (le_trans (le_max_left _ K₂) (le_max_right 1 _))\n  replace hb₂ := lt_of_lt_of_le hb₂ (le_trans (le_max_right K₁ _) (le_max_right 1 _))\n  have :=\n    add_lt_add (mul_lt_mul' (le_of_lt h₁) hb₂ (abv_nonneg abv _) εK)\n      (mul_lt_mul' (le_of_lt h₂) ha₁ (abv_nonneg abv _) εK)\n  rw [← abv_mul abv, mul_comm, div_mul_cancel _ (ne_of_gt K0), ← abv_mul abv, add_halves] at this\n  simpa [sub_eq_add_neg, mul_add, add_mul, add_left_comm] using\n    lt_of_le_of_lt (abv_add abv _ _) this\n#align rat_mul_continuous_lemma rat_mul_continuous_lemma\n\ntheorem rat_inv_continuous_lemma {β : Type _} [DivisionRing β] (abv : β → α) [IsAbsoluteValue abv]\n    {ε K : α} (ε0 : 0 < ε) (K0 : 0 < K) :\n    ∃ δ > 0, ∀ {a b : β}, K ≤ abv a → K ≤ abv b → abv (a - b) < δ → abv (a⁻¹ - b⁻¹) < ε := by\n  refine' ⟨K * ε * K, mul_pos (mul_pos K0 ε0) K0, fun {a b} ha hb h => _⟩\n  have a0 := K0.trans_le ha\n  have b0 := K0.trans_le hb\n  rw [inv_sub_inv' ((abv_pos abv).1 a0) ((abv_pos abv).1 b0), abv_mul abv, abv_mul abv, abv_inv abv,\n    abv_inv abv, abv_sub abv]\n  refine' lt_of_mul_lt_mul_left (lt_of_mul_lt_mul_right _ b0.le) a0.le\n  rw [mul_assoc, inv_mul_cancel_right₀ b0.ne', ← mul_assoc, mul_inv_cancel a0.ne', one_mul]\n  refine' h.trans_le _\n  exact mul_le_mul (mul_le_mul ha le_rfl ε0.le a0.le) hb K0.le (mul_nonneg a0.le ε0.le)\n#align rat_inv_continuous_lemma rat_inv_continuous_lemma\n\nend\n\n/-- A sequence is Cauchy if the distance between its entries tends to zero. -/\ndef IsCauSeq {α : Type _} [LinearOrderedField α] {β : Type _} [Ring β] (abv : β → α) (f : ℕ → β) :\n    Prop :=\n  ∀ ε > 0, ∃ i, ∀ j ≥ i, abv (f j - f i) < ε\n#align is_cau_seq IsCauSeq\n\nnamespace IsCauSeq\n\nvariable [LinearOrderedField α] [Ring β] {abv : β → α} [IsAbsoluteValue abv] {f g : ℕ → β}\n\n-- see Note [nolint_ge]\n--@[nolint ge_or_gt] -- Porting note: restore attribute\ntheorem cauchy₂ (hf : IsCauSeq abv f) {ε : α} (ε0 : 0 < ε) :\n    ∃ i, ∀ j ≥ i, ∀ k ≥ i, abv (f j - f k) < ε := by\n  refine' (hf _ (half_pos ε0)).imp fun i hi j ij k ik => _\n  rw [← add_halves ε]\n  refine' lt_of_le_of_lt (abv_sub_le abv _ _ _) (add_lt_add (hi _ ij) _)\n  rw [abv_sub abv]; exact hi _ ik\n#align is_cau_seq.cauchy₂ IsCauSeq.cauchy₂\n\ntheorem cauchy₃ (hf : IsCauSeq abv f) {ε : α} (ε0 : 0 < ε) :\n    ∃ i, ∀ j ≥ i, ∀ k ≥ j, abv (f k - f j) < ε :=\n  let ⟨i, H⟩ := hf.cauchy₂ ε0\n  ⟨i, fun _ ij _ jk => H _ (le_trans ij jk) _ ij⟩\n#align is_cau_seq.cauchy₃ IsCauSeq.cauchy₃\n\ntheorem add (hf : IsCauSeq abv f) (hg : IsCauSeq abv g) : IsCauSeq abv (f + g) := fun _ ε0 =>\n  let ⟨_, δ0, Hδ⟩ := rat_add_continuous_lemma abv ε0\n  let ⟨i, H⟩ := exists_forall_ge_and (hf.cauchy₃ δ0) (hg.cauchy₃ δ0)\n  ⟨i, fun _ ij =>\n    let ⟨H₁, H₂⟩ := H _ le_rfl\n    Hδ (H₁ _ ij) (H₂ _ ij)⟩\n#align is_cau_seq.add IsCauSeq.add\n\nend IsCauSeq\n\n/-- `CauSeq β abv` is the type of `β`-valued Cauchy sequences, with respect to the absolute value\nfunction `abv`. -/\ndef CauSeq {α : Type _} [LinearOrderedField α] (β : Type _) [Ring β] (abv : β → α) : Type _ :=\n  { f : ℕ → β // IsCauSeq abv f }\n#align cau_seq CauSeq\n\nnamespace CauSeq\n\nvariable [LinearOrderedField α]\n\nsection Ring\n\nvariable [Ring β] {abv : β → α}\n\ninstance : CoeFun (CauSeq β abv) fun _ => ℕ → β :=\n  ⟨Subtype.val⟩\n\n-- Porting note: Remove coeFn theorem\n/-@[simp]\ntheorem mk_to_fun (f) (hf : IsCauSeq abv f) : @coeFn (CauSeq β abv) _ _ ⟨f, hf⟩ = f :=\n  rfl -/\n#noalign cau_seq.mk_to_fun\n\ntheorem ext {f g : CauSeq β abv} (h : ∀ i, f i = g i) : f = g :=\n  Subtype.eq (funext h)\n#align cau_seq.ext CauSeq.ext\n\ntheorem isCauSeq (f : CauSeq β abv) : IsCauSeq abv f :=\n  f.2\n#align cau_seq.is_cau CauSeq.isCauSeq\n\ntheorem cauchy (f : CauSeq β abv) : ∀ {ε}, 0 < ε → ∃ i, ∀ j ≥ i, abv (f j - f i) < ε := @f.2\n#align cau_seq.cauchy CauSeq.cauchy\n\n/-- Given a Cauchy sequence `f`, create a Cauchy sequence from a sequence `g` with\nthe same values as `f`. -/\ndef ofEq (f : CauSeq β abv) (g : ℕ → β) (e : ∀ i, f i = g i) : CauSeq β abv :=\n  ⟨g, fun ε => by rw [show g = f from (funext e).symm]; exact f.cauchy⟩\n#align cau_seq.of_eq CauSeq.ofEq\n\nvariable [IsAbsoluteValue abv]\n\n-- see Note [nolint_ge]\n-- @[nolint ge_or_gt] -- Porting note: restore attribute\ntheorem cauchy₂ (f : CauSeq β abv) {ε} :\n    0 < ε → ∃ i, ∀ (j) (_ : j ≥ i) (k) (_ : k ≥ i), abv (f j - f k) < ε :=\n  f.2.cauchy₂\n#align cau_seq.cauchy₂ CauSeq.cauchy₂\n\ntheorem cauchy₃ (f : CauSeq β abv) {ε} : 0 < ε → ∃ i, ∀ j ≥ i, ∀ k ≥ j, abv (f k - f j) < ε :=\n  f.2.cauchy₃\n#align cau_seq.cauchy₃ CauSeq.cauchy₃\n\ntheorem bounded (f : CauSeq β abv) : ∃ r, ∀ i, abv (f i) < r := by\n  cases' f.cauchy zero_lt_one with i h\n  set R : ℕ → α := @Nat.rec (fun _ => α) (abv (f 0)) fun i c => max c (abv (f i.succ)) with hR\n  have : ∀ i, ∀ j ≤ i, abv (f j) ≤ R i := by\n    refine' Nat.rec (by simp [hR]) _\n    rintro i hi j (rfl | hj)\n    · simp\n    exact (hi j hj).trans (le_max_left _ _)\n  refine' ⟨R i + 1, fun j => _⟩\n  cases' lt_or_le j i with ij ij\n  · exact lt_of_le_of_lt (this i _ (le_of_lt ij)) (lt_add_one _)\n  · have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add_of_le_of_lt (this i _ le_rfl) (h _ ij))\n    rw [add_sub, add_comm] at this\n    simpa using this\n#align cau_seq.bounded CauSeq.bounded\n\ntheorem bounded' (f : CauSeq β abv) (x : α) : ∃ r > x, ∀ i, abv (f i) < r :=\n  let ⟨r, h⟩ := f.bounded\n  ⟨max r (x + 1), lt_of_lt_of_le (lt_add_one _) (le_max_right _ _), fun i =>\n    lt_of_lt_of_le (h i) (le_max_left _ _)⟩\n#align cau_seq.bounded' CauSeq.bounded'\n\ninstance : Add (CauSeq β abv) :=\n  ⟨fun f g => ⟨f + g, f.2.add g.2⟩⟩\n\n@[simp, norm_cast]\ntheorem coe_add (f g : CauSeq β abv) : ⇑(f + g) = (f : ℕ → β) + g :=\n  rfl\n#align cau_seq.coe_add CauSeq.coe_add\n\n@[simp, norm_cast]\ntheorem add_apply (f g : CauSeq β abv) (i : ℕ) : (f + g) i = f i + g i :=\n  rfl\n#align cau_seq.add_apply CauSeq.add_apply\n\nvariable (abv)\n\n/-- The constant Cauchy sequence. -/\ndef const (x : β) : CauSeq β abv :=\n  ⟨fun _ => x, fun ε ε0 => ⟨0, fun j _ => by simpa [abv_zero] using ε0⟩⟩\n#align cau_seq.const CauSeq.const\n\nvariable {abv}\n\n/-- The constant Cauchy sequence -/\nlocal notation \"const\" => const abv\n\n@[simp, norm_cast]\ntheorem coe_const (x : β) : (const x : ℕ → β) = Function.const ℕ x :=\n  rfl\n#align cau_seq.coe_const CauSeq.coe_const\n\n@[simp, norm_cast]\ntheorem const_apply (x : β) (i : ℕ) : (const x : ℕ → β) i = x :=\n  rfl\n#align cau_seq.const_apply CauSeq.const_apply\n\ntheorem const_inj {x y : β} : (const x : CauSeq β abv) = const y ↔ x = y :=\n  ⟨fun h => congr_arg (fun f : CauSeq β abv => (f : ℕ → β) 0) h, congr_arg _⟩\n#align cau_seq.const_inj CauSeq.const_inj\n\ninstance : Zero (CauSeq β abv) :=\n  ⟨const 0⟩\n\ninstance : One (CauSeq β abv) :=\n  ⟨const 1⟩\n\ninstance : Inhabited (CauSeq β abv) :=\n  ⟨0⟩\n\n@[simp, norm_cast]\ntheorem coe_zero : ⇑(0 : CauSeq β abv) = 0 :=\n  rfl\n#align cau_seq.coe_zero CauSeq.coe_zero\n\n@[simp, norm_cast]\ntheorem coe_one : ⇑(1 : CauSeq β abv) = 1 :=\n  rfl\n#align cau_seq.coe_one CauSeq.coe_one\n\n@[simp, norm_cast]\ntheorem zero_apply (i) : (0 : CauSeq β abv) i = 0 :=\n  rfl\n#align cau_seq.zero_apply CauSeq.zero_apply\n\n@[simp, norm_cast]\ntheorem one_apply (i) : (1 : CauSeq β abv) i = 1 :=\n  rfl\n#align cau_seq.one_apply CauSeq.one_apply\n\n@[simp]\ntheorem const_zero : const 0 = 0 :=\n  rfl\n#align cau_seq.const_zero CauSeq.const_zero\n\n@[simp]\ntheorem const_one : const 1 = 1 :=\n  rfl\n#align cau_seq.const_one CauSeq.const_one\n\ntheorem const_add (x y : β) : const (x + y) = const x + const y :=\n  rfl\n#align cau_seq.const_add CauSeq.const_add\n\ninstance : Mul (CauSeq β abv) :=\n  ⟨fun f g =>\n    ⟨f * g, fun _ ε0 =>\n      let ⟨_, _, hF⟩ := f.bounded' 0\n      let ⟨_, _, hG⟩ := g.bounded' 0\n      let ⟨_, δ0, Hδ⟩ := rat_mul_continuous_lemma abv ε0\n      let ⟨i, H⟩ := exists_forall_ge_and (f.cauchy₃ δ0) (g.cauchy₃ δ0)\n      ⟨i, fun j ij =>\n        let ⟨H₁, H₂⟩ := H _ le_rfl\n        Hδ (hF j) (hG i) (H₁ _ ij) (H₂ _ ij)⟩⟩⟩\n\n@[simp, norm_cast]\ntheorem coe_mul (f g : CauSeq β abv) : ⇑(f * g) = (f : ℕ → β) * g :=\n  rfl\n#align cau_seq.coe_mul CauSeq.coe_mul\n\n@[simp, norm_cast]\ntheorem mul_apply (f g : CauSeq β abv) (i : ℕ) : (f * g) i = f i * g i :=\n  rfl\n#align cau_seq.mul_apply CauSeq.mul_apply\n\ntheorem const_mul (x y : β) : const (x * y) = const x * const y :=\n  rfl\n#align cau_seq.const_mul CauSeq.const_mul\n\ninstance : Neg (CauSeq β abv) :=\n  ⟨fun f => ofEq (const (-1) * f) (fun x => -f x) fun i => by simp⟩\n\n@[simp, norm_cast]\ntheorem coe_neg (f : CauSeq β abv) : ⇑(-f) = -f :=\n  rfl\n#align cau_seq.coe_neg CauSeq.coe_neg\n\n@[simp, norm_cast]\ntheorem neg_apply (f : CauSeq β abv) (i) : (-f) i = -f i :=\n  rfl\n#align cau_seq.neg_apply CauSeq.neg_apply\n\ntheorem const_neg (x : β) : const (-x) = -const x :=\n  rfl\n#align cau_seq.const_neg CauSeq.const_neg\n\ninstance : Sub (CauSeq β abv) :=\n  ⟨fun f g => ofEq (f + -g) (fun x => f x - g x) fun i => by simp [sub_eq_add_neg]⟩\n\n@[simp, norm_cast]\ntheorem coe_sub (f g : CauSeq β abv) : ⇑(f - g) = (f : ℕ → β) - g :=\n  rfl\n#align cau_seq.coe_sub CauSeq.coe_sub\n\n@[simp, norm_cast]\ntheorem sub_apply (f g : CauSeq β abv) (i : ℕ) : (f - g) i = f i - g i :=\n  rfl\n#align cau_seq.sub_apply CauSeq.sub_apply\n\ntheorem const_sub (x y : β) : const (x - y) = const x - const y :=\n  rfl\n#align cau_seq.const_sub CauSeq.const_sub\n\nsection SMul\n\nvariable [SMul G β] [IsScalarTower G β β]\n\ninstance : SMul G (CauSeq β abv) :=\n  ⟨fun a f => (ofEq (const (a • (1 : β)) * f) (a • (f : ℕ → β))) fun _ => smul_one_mul _ _⟩\n\n@[simp, norm_cast]\ntheorem coe_smul (a : G) (f : CauSeq β abv) : ⇑(a • f) = a • (f : ℕ → β) :=\n  rfl\n#align cau_seq.coe_smul CauSeq.coe_smul\n\n@[simp, norm_cast]\ntheorem smul_apply (a : G) (f : CauSeq β abv) (i : ℕ) : (a • f) i = a • f i :=\n  rfl\n#align cau_seq.smul_apply CauSeq.smul_apply\n\ntheorem const_smul (a : G) (x : β) : const (a • x) = a • const x :=\n  rfl\n#align cau_seq.const_smul CauSeq.const_smul\n\ninstance : IsScalarTower G (CauSeq β abv) (CauSeq β abv) :=\n  ⟨fun a f g => Subtype.ext <| smul_assoc a (f : ℕ → β) (g : ℕ → β)⟩\n\nend SMul\n\ninstance addGroup : AddGroup (CauSeq β abv) :=\n  Function.Injective.addGroup Subtype.val Subtype.val_injective rfl coe_add coe_neg coe_sub\n    (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _\n\ninstance instNatCast : NatCast (CauSeq β abv) := ⟨fun n => const n⟩\n\ninstance instIntCast : IntCast (CauSeq β abv) := ⟨fun n => const n⟩\n\ninstance addGroupWithOne : AddGroupWithOne (CauSeq β abv) :=\n  Function.Injective.addGroupWithOne Subtype.val Subtype.val_injective rfl rfl\n  coe_add coe_neg coe_sub\n  (by intros; rfl)\n  (by intros; rfl)\n  (by intros; rfl)\n  (by intros; rfl)\n\ninstance : Pow (CauSeq β abv) ℕ :=\n  ⟨fun f n =>\n    (ofEq (npowRec n f) fun i => f i ^ n) <| by induction n <;> simp [*, npowRec, pow_succ]⟩\n\n@[simp, norm_cast]\ntheorem coe_pow (f : CauSeq β abv) (n : ℕ) : ⇑(f ^ n) = (f : ℕ → β) ^ n :=\n  rfl\n#align cau_seq.coe_pow CauSeq.coe_pow\n\n@[simp, norm_cast]\ntheorem pow_apply (f : CauSeq β abv) (n i : ℕ) : (f ^ n) i = f i ^ n :=\n  rfl\n#align cau_seq.pow_apply CauSeq.pow_apply\n\ntheorem const_pow (x : β) (n : ℕ) : const (x ^ n) = const x ^ n :=\n  rfl\n#align cau_seq.const_pow CauSeq.const_pow\n\ninstance ring : Ring (CauSeq β abv) :=\n  Function.Injective.ring Subtype.val Subtype.val_injective rfl rfl coe_add coe_mul coe_neg coe_sub\n    (fun _ _ => coe_smul _ _) (fun _ _ => coe_smul _ _) coe_pow (fun _ => rfl) fun _ => rfl\n\ninstance {β : Type _} [CommRing β] {abv : β → α} [IsAbsoluteValue abv] : CommRing (CauSeq β abv) :=\n  { CauSeq.ring with\n    mul_comm := fun a b => ext $ fun n => by simp [mul_left_comm, mul_comm] }\n\n/-- `LimZero f` holds when `f` approaches 0. -/\ndef LimZero {abv : β → α} (f : CauSeq β abv) : Prop :=\n  ∀ ε > 0, ∃ i, ∀ j ≥ i, abv (f j) < ε\n#align cau_seq.lim_zero CauSeq.LimZero\n\ntheorem add_limZero {f g : CauSeq β abv} (hf : LimZero f) (hg : LimZero g) : LimZero (f + g)\n  | ε, ε0 =>\n    (exists_forall_ge_and (hf _ <| half_pos ε0) (hg _ <| half_pos ε0)).imp fun i H j ij => by\n      let ⟨H₁, H₂⟩ := H _ ij\n      simpa [add_halves ε] using lt_of_le_of_lt (abv_add abv _ _) (add_lt_add H₁ H₂)\n#align cau_seq.add_lim_zero CauSeq.add_limZero\n\ntheorem mul_limZero_right (f : CauSeq β abv) {g} (hg : LimZero g) : LimZero (f * g)\n  | ε, ε0 =>\n    let ⟨F, F0, hF⟩ := f.bounded' 0\n    (hg _ <| div_pos ε0 F0).imp fun i H j ij => by\n      have := mul_lt_mul' (le_of_lt <| hF j) (H _ ij) (abv_nonneg abv _) F0\n      rwa [mul_comm F, div_mul_cancel _ (ne_of_gt F0), ← abv_mul] at this\n#align cau_seq.mul_lim_zero_right CauSeq.mul_limZero_right\n\ntheorem mul_limZero_left {f} (g : CauSeq β abv) (hg : LimZero f) : LimZero (f * g)\n  | ε, ε0 =>\n    let ⟨G, G0, hG⟩ := g.bounded' 0\n    (hg _ <| div_pos ε0 G0).imp fun i H j ij => by\n      have := mul_lt_mul'' (H _ ij) (hG j) (abv_nonneg abv _) (abv_nonneg abv _)\n      rwa [div_mul_cancel _ (ne_of_gt G0), ← abv_mul] at this\n#align cau_seq.mul_lim_zero_left CauSeq.mul_limZero_left\n\ntheorem neg_limZero {f : CauSeq β abv} (hf : LimZero f) : LimZero (-f) := by\n  rw [← neg_one_mul f]\n  exact mul_limZero_right _ hf\n#align cau_seq.neg_lim_zero CauSeq.neg_limZero\n\ntheorem sub_limZero {f g : CauSeq β abv} (hf : LimZero f) (hg : LimZero g) : LimZero (f - g) := by\n  simpa only [sub_eq_add_neg] using add_limZero hf (neg_limZero hg)\n#align cau_seq.sub_lim_zero CauSeq.sub_limZero\n\ntheorem limZero_sub_rev {f g : CauSeq β abv} (hfg : LimZero (f - g)) : LimZero (g - f) := by\n  simpa using neg_limZero hfg\n#align cau_seq.lim_zero_sub_rev CauSeq.limZero_sub_rev\n\ntheorem zero_limZero : LimZero (0 : CauSeq β abv)\n  | ε, ε0 => ⟨0, fun j _ => by simpa [abv_zero abv] using ε0⟩\n#align cau_seq.zero_lim_zero CauSeq.zero_limZero\n\ntheorem const_limZero {x : β} : LimZero (const x) ↔ x = 0 :=\n  ⟨fun H =>\n    (abv_eq_zero abv).1 <|\n      (eq_of_le_of_forall_le_of_dense (abv_nonneg abv _)) fun _ ε0 =>\n        let ⟨_, hi⟩ := H _ ε0\n        le_of_lt <| hi _ le_rfl,\n    fun e => e.symm ▸ zero_limZero⟩\n#align cau_seq.const_lim_zero CauSeq.const_limZero\n\ninstance equiv : Setoid (CauSeq β abv) :=\n  ⟨fun f g => LimZero (f - g),\n    ⟨fun f => by simp [zero_limZero],\n    fun f ε hε => by simpa using neg_limZero f ε hε,\n    fun fg gh => by simpa using add_limZero fg gh⟩⟩\n#align cau_seq.equiv CauSeq.equiv\n\ntheorem add_equiv_add {f1 f2 g1 g2 : CauSeq β abv} (hf : f1 ≈ f2) (hg : g1 ≈ g2) :\n    f1 + g1 ≈ f2 + g2 := by simpa only [← add_sub_add_comm] using add_limZero hf hg\n#align cau_seq.add_equiv_add CauSeq.add_equiv_add\n\ntheorem neg_equiv_neg {f g : CauSeq β abv} (hf : f ≈ g) : -f ≈ -g := by\n  simpa only [neg_sub'] using neg_limZero hf\n#align cau_seq.neg_equiv_neg CauSeq.neg_equiv_neg\n\ntheorem sub_equiv_sub {f1 f2 g1 g2 : CauSeq β abv} (hf : f1 ≈ f2) (hg : g1 ≈ g2) :\n    f1 - g1 ≈ f2 - g2 := by simpa only [sub_eq_add_neg] using add_equiv_add hf (neg_equiv_neg hg)\n#align cau_seq.sub_equiv_sub CauSeq.sub_equiv_sub\n\ntheorem equiv_def₃ {f g : CauSeq β abv} (h : f ≈ g) {ε : α} (ε0 : 0 < ε) :\n    ∃ i, ∀ j ≥ i, ∀ k ≥ j, abv (f k - g j) < ε :=\n  (exists_forall_ge_and (h _ <| half_pos ε0) (f.cauchy₃ <| half_pos ε0)).imp fun i H j ij k jk => by\n    let ⟨h₁, h₂⟩ := H _ ij\n    have := lt_of_le_of_lt (abv_add abv (f j - g j) _) (add_lt_add h₁ (h₂ _ jk))\n    rwa [sub_add_sub_cancel', add_halves] at this\n#align cau_seq.equiv_def₃ CauSeq.equiv_def₃\n\ntheorem limZero_congr {f g : CauSeq β abv} (h : f ≈ g) : LimZero f ↔ LimZero g :=\n  ⟨fun l => by simpa using add_limZero (Setoid.symm h) l, fun l => by simpa using add_limZero h l⟩\n#align cau_seq.lim_zero_congr CauSeq.limZero_congr\n\ntheorem abv_pos_of_not_limZero {f : CauSeq β abv} (hf : ¬LimZero f) :\n    ∃ K > 0, ∃ i, ∀ j ≥ i, K ≤ abv (f j) := by\n  haveI := Classical.propDecidable\n  by_contra nk\n  refine' hf fun ε ε0 => _\n  simp [not_forall] at nk\n  cases' f.cauchy₃ (half_pos ε0) with i hi\n  rcases nk _ (half_pos ε0) i with ⟨j, ij, hj⟩\n  refine' ⟨j, fun k jk => _⟩\n  have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add (hi j ij k jk) hj)\n  rwa [sub_add_cancel, add_halves] at this\n#align cau_seq.abv_pos_of_not_lim_zero CauSeq.abv_pos_of_not_limZero\n\ntheorem of_near (f : ℕ → β) (g : CauSeq β abv) (h : ∀ ε > 0, ∃ i, ∀ j ≥ i, abv (f j - g j) < ε) :\n    IsCauSeq abv f\n  | ε, ε0 =>\n    let ⟨i, hi⟩ := exists_forall_ge_and (h _ (half_pos <| half_pos ε0)) (g.cauchy₃ <| half_pos ε0)\n    ⟨i, fun j ij => by\n      cases' hi _ le_rfl with h₁ h₂; rw [abv_sub abv] at h₁\n      have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add (hi _ ij).1 h₁)\n      have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add this (h₂ _ ij))\n      rwa [add_halves, add_halves, add_right_comm, sub_add_sub_cancel, sub_add_sub_cancel] at this⟩\n#align cau_seq.of_near CauSeq.of_near\n\ntheorem not_limZero_of_not_congr_zero {f : CauSeq _ abv} (hf : ¬f ≈ 0) : ¬LimZero f := by\n  intro h\n  have : LimZero (f - 0) := by simp [h]\n  exact hf this\n#align cau_seq.not_lim_zero_of_not_congr_zero CauSeq.not_limZero_of_not_congr_zero\n\ntheorem mul_equiv_zero (g : CauSeq _ abv) {f : CauSeq _ abv} (hf : f ≈ 0) : g * f ≈ 0 :=\n  have : LimZero (f - 0) := hf\n  have : LimZero (g * f) := mul_limZero_right _ <| by simpa\n  show LimZero (g * f - 0) by simpa\n#align cau_seq.mul_equiv_zero CauSeq.mul_equiv_zero\n\ntheorem mul_equiv_zero' (g : CauSeq _ abv) {f : CauSeq _ abv} (hf : f ≈ 0) : f * g ≈ 0 :=\n  have : LimZero (f - 0) := hf\n  have : LimZero (f * g) := mul_limZero_left _ <| by simpa\n  show LimZero (f * g - 0) by simpa\n#align cau_seq.mul_equiv_zero' CauSeq.mul_equiv_zero'\n\ntheorem mul_not_equiv_zero {f g : CauSeq _ abv} (hf : ¬f ≈ 0) (hg : ¬g ≈ 0) : ¬f * g ≈ 0 :=\n  fun (this : LimZero (f * g - 0)) => by\n  have hlz : LimZero (f * g) := by simpa\n  have hf' : ¬LimZero f := by simpa using show ¬LimZero (f - 0) from hf\n  have hg' : ¬LimZero g := by simpa using show ¬LimZero (g - 0) from hg\n  rcases abv_pos_of_not_limZero hf' with ⟨a1, ha1, N1, hN1⟩\n  rcases abv_pos_of_not_limZero hg' with ⟨a2, ha2, N2, hN2⟩\n  have : 0 < a1 * a2 := mul_pos ha1 ha2\n  cases' hlz _ this with N hN\n  let i := max N (max N1 N2)\n  have hN' := hN i (le_max_left _ _)\n  have hN1' := hN1 i (le_trans (le_max_left _ _) (le_max_right _ _))\n  have hN1' := hN2 i (le_trans (le_max_right _ _) (le_max_right _ _))\n  apply not_le_of_lt hN'\n  change _ ≤ abv (_ * _)\n  rw [abv_mul abv]\n  apply mul_le_mul <;> try assumption\n  · exact le_of_lt ha2\n  · exact abv_nonneg abv _\n#align cau_seq.mul_not_equiv_zero CauSeq.mul_not_equiv_zero\n\ntheorem const_equiv {x y : β} : const x ≈ const y ↔ x = y :=\n  show LimZero _ ↔ _ by rw [← const_sub, const_limZero, sub_eq_zero]\n#align cau_seq.const_equiv CauSeq.const_equiv\n\ntheorem mul_equiv_mul {f1 f2 g1 g2 : CauSeq β abv} (hf : f1 ≈ f2) (hg : g1 ≈ g2) :\n    f1 * g1 ≈ f2 * g2 := by\n  change LimZero (f1 * g1 - f2 * g2)\n  convert add_limZero (mul_limZero_left g1 hf) (mul_limZero_right f2 hg) using 1\n  rw [mul_sub, sub_mul]\n  -- Porting note: doesn't work with `rw`, but did in Lean 3\n  exact (sub_add_sub_cancel (f1*g1) (f2*g1) (f2*g2)).symm\n  -- Porting note: was\n  /-\n  simpa only [mul_sub, sub_mul, sub_add_sub_cancel] using\n    add_lim_zero (mul_limZero_left g1 hf) (mul_limZero_right f2 hg)\n  -/\n#align cau_seq.mul_equiv_mul CauSeq.mul_equiv_mul\n\ntheorem smul_equiv_smul [SMul G β] [IsScalarTower G β β] {f1 f2 : CauSeq β abv} (c : G)\n    (hf : f1 ≈ f2) : c • f1 ≈ c • f2 := by\n  simpa [const_smul, smul_one_mul _ _] using\n    mul_equiv_mul (const_equiv.mpr <| Eq.refl <| c • (1 : β)) hf\n#align cau_seq.smul_equiv_smul CauSeq.smul_equiv_smul\n\ntheorem pow_equiv_pow {f1 f2 : CauSeq β abv} (hf : f1 ≈ f2) (n : ℕ) : f1 ^ n ≈ f2 ^ n := by\n  induction' n with n ih\n  · simp only [Nat.zero_eq, pow_zero, Setoid.refl]\n  · simpa only [pow_succ] using mul_equiv_mul hf ih\n#align cau_seq.pow_equiv_pow CauSeq.pow_equiv_pow\n\nend Ring\n\nsection IsDomain\n\nvariable [Ring β] [IsDomain β] (abv : β → α) [IsAbsoluteValue abv]\n\ntheorem one_not_equiv_zero : ¬const abv 1 ≈ const abv 0 := fun h =>\n  have : ∀ ε > 0, ∃ i, ∀ k, i ≤ k → abv (1 - 0) < ε := h\n  have h1 : abv 1 ≤ 0 :=\n    le_of_not_gt fun h2 : 0 < abv 1 =>\n      (Exists.elim (this _ h2)) fun i hi => lt_irrefl (abv 1) <| by simpa using hi _ le_rfl\n  have h2 : 0 ≤ abv 1 := abv_nonneg abv _\n  have : abv 1 = 0 := le_antisymm h1 h2\n  have : (1 : β) = 0 := (abv_eq_zero abv).mp this\n  absurd this one_ne_zero\n#align cau_seq.one_not_equiv_zero CauSeq.one_not_equiv_zero\n\nend IsDomain\n\nsection DivisionRing\n\nvariable [DivisionRing β] {abv : β → α} [IsAbsoluteValue abv]\n\ntheorem inv_aux {f : CauSeq β abv} (hf : ¬LimZero f) :\n    ∀ ε > 0, ∃ i, ∀ j ≥ i, abv ((f j)⁻¹ - (f i)⁻¹) < ε\n  | _, ε0 =>\n    let ⟨_, K0, HK⟩ := abv_pos_of_not_limZero hf\n    let ⟨_, δ0, Hδ⟩ := rat_inv_continuous_lemma abv ε0 K0\n    let ⟨i, H⟩ := exists_forall_ge_and HK (f.cauchy₃ δ0)\n    ⟨i, fun _ ij =>\n      let ⟨iK, H'⟩ := H _ le_rfl\n      Hδ (H _ ij).1 iK (H' _ ij)⟩\n#align cau_seq.inv_aux CauSeq.inv_aux\n\n/-- Given a Cauchy sequence `f` with nonzero limit, create a Cauchy sequence with values equal to\nthe inverses of the values of `f`. -/\ndef inv (f : CauSeq β abv) (hf : ¬LimZero f) : CauSeq β abv :=\n  ⟨_, inv_aux hf⟩\n#align cau_seq.inv CauSeq.inv\n\n@[simp, norm_cast]\ntheorem coe_inv {f : CauSeq β abv} (hf) : ⇑(inv f hf) = (f : ℕ → β)⁻¹ :=\n  rfl\n#align cau_seq.coe_inv CauSeq.coe_inv\n\n@[simp, norm_cast]\ntheorem inv_apply {f : CauSeq β abv} (hf i) : inv f hf i = (f i)⁻¹ :=\n  rfl\n#align cau_seq.inv_apply CauSeq.inv_apply\n\ntheorem inv_mul_cancel {f : CauSeq β abv} (hf) : inv f hf * f ≈ 1 := fun ε ε0 =>\n  let ⟨K, K0, i, H⟩ := abv_pos_of_not_limZero hf\n  ⟨i, fun j ij => by simpa [(abv_pos abv).1 (lt_of_lt_of_le K0 (H _ ij)), abv_zero abv] using ε0⟩\n#align cau_seq.inv_mul_cancel CauSeq.inv_mul_cancel\n\ntheorem mul_inv_cancel {f : CauSeq β abv} (hf) : f * inv f hf ≈ 1 := fun ε ε0 =>\n  let ⟨K, K0, i, H⟩ := abv_pos_of_not_limZero hf\n  ⟨i, fun j ij => by simpa [(abv_pos abv).1 (lt_of_lt_of_le K0 (H _ ij)), abv_zero abv] using ε0⟩\n#align cau_seq.mul_inv_cancel CauSeq.mul_inv_cancel\n\ntheorem const_inv {x : β} (hx : x ≠ 0) :\n    const abv x⁻¹ = inv (const abv x) (by rwa [const_limZero]) :=\n  rfl\n#align cau_seq.const_inv CauSeq.const_inv\n\nend DivisionRing\n\nsection Abs\n\n/-- The constant Cauchy sequence -/\nlocal notation \"const\" => const abs\n\n/-- The entries of a positive Cauchy sequence eventually have a positive lower bound. -/\ndef Pos (f : CauSeq α abs) : Prop :=\n  ∃ K > 0, ∃ i, ∀ j ≥ i, K ≤ f j\n#align cau_seq.pos CauSeq.Pos\n\ntheorem not_limZero_of_pos {f : CauSeq α abs} : Pos f → ¬LimZero f\n  | ⟨_, F0, hF⟩, H =>\n    let ⟨_, h⟩ := exists_forall_ge_and hF (H _ F0)\n    let ⟨h₁, h₂⟩ := h _ le_rfl\n    not_lt_of_le h₁ (abs_lt.1 h₂).2\n#align cau_seq.not_lim_zero_of_pos CauSeq.not_limZero_of_pos\n\ntheorem const_pos {x : α} : Pos (const x) ↔ 0 < x :=\n  ⟨fun ⟨_, K0, _, h⟩ => lt_of_lt_of_le K0 (h _ le_rfl), fun h => ⟨x, h, 0, fun _ _ => le_rfl⟩⟩\n#align cau_seq.const_pos CauSeq.const_pos\n\ntheorem add_pos {f g : CauSeq α abs} : Pos f → Pos g → Pos (f + g)\n  | ⟨_, F0, hF⟩, ⟨_, G0, hG⟩ =>\n    let ⟨i, h⟩ := exists_forall_ge_and hF hG\n    ⟨_, _root_.add_pos F0 G0, i, fun _ ij =>\n      let ⟨h₁, h₂⟩ := h _ ij\n      add_le_add h₁ h₂⟩\n#align cau_seq.add_pos CauSeq.add_pos\n\ntheorem pos_add_limZero {f g : CauSeq α abs} : Pos f → LimZero g → Pos (f + g)\n  | ⟨F, F0, hF⟩, H =>\n    let ⟨i, h⟩ := exists_forall_ge_and hF (H _ (half_pos F0))\n    ⟨_, half_pos F0, i, fun j ij => by\n      cases' h j ij with h₁ h₂\n      have := add_le_add h₁ (le_of_lt (abs_lt.1 h₂).1)\n      rwa [← sub_eq_add_neg, sub_self_div_two] at this⟩\n#align cau_seq.pos_add_lim_zero CauSeq.pos_add_limZero\n\nprotected theorem mul_pos {f g : CauSeq α abs} : Pos f → Pos g → Pos (f * g)\n  | ⟨_, F0, hF⟩, ⟨_, G0, hG⟩ =>\n    let ⟨i, h⟩ := exists_forall_ge_and hF hG\n    ⟨_, mul_pos F0 G0, i, fun _ ij =>\n      let ⟨h₁, h₂⟩ := h _ ij\n      mul_le_mul h₁ h₂ (le_of_lt G0) (le_trans (le_of_lt F0) h₁)⟩\n#align cau_seq.mul_pos CauSeq.mul_pos\n\ntheorem trichotomy (f : CauSeq α abs) : Pos f ∨ LimZero f ∨ Pos (-f) := by\n  cases' Classical.em (LimZero f) with h h <;> simp [*]\n  rcases abv_pos_of_not_limZero h with ⟨K, K0, hK⟩\n  rcases exists_forall_ge_and hK (f.cauchy₃ K0) with ⟨i, hi⟩\n  refine' (le_total 0 (f i)).imp _ _ <;>\n    refine' fun h => ⟨K, K0, i, fun j ij => _⟩ <;>\n    have := (hi _ ij).1 <;>\n    cases' hi _ le_rfl with h₁ h₂\n  · rwa [abs_of_nonneg] at this\n    rw [abs_of_nonneg h] at h₁\n    exact\n      (le_add_iff_nonneg_right _).1\n        (le_trans h₁ <| neg_le_sub_iff_le_add'.1 <| le_of_lt (abs_lt.1 <| h₂ _ ij).1)\n  · rwa [abs_of_nonpos] at this\n    rw [abs_of_nonpos h] at h₁\n    rw [← sub_le_sub_iff_right, zero_sub]\n    exact le_trans (le_of_lt (abs_lt.1 <| h₂ _ ij).2) h₁\n#align cau_seq.trichotomy CauSeq.trichotomy\n\ninstance : LT (CauSeq α abs) :=\n  ⟨fun f g => Pos (g - f)⟩\n\ninstance : LE (CauSeq α abs) :=\n  ⟨fun f g => f < g ∨ f ≈ g⟩\n\ntheorem lt_of_lt_of_eq {f g h : CauSeq α abs} (fg : f < g) (gh : g ≈ h) : f < h :=\n  show Pos (h - f) by\n    convert pos_add_limZero fg (neg_limZero gh) using 1\n    simp\n\n#align cau_seq.lt_of_lt_of_eq CauSeq.lt_of_lt_of_eq\n\ntheorem lt_of_eq_of_lt {f g h : CauSeq α abs} (fg : f ≈ g) (gh : g < h) : f < h := by\n  have := pos_add_limZero gh (neg_limZero fg)\n  rwa [← sub_eq_add_neg, sub_sub_sub_cancel_right] at this\n#align cau_seq.lt_of_eq_of_lt CauSeq.lt_of_eq_of_lt\n\ntheorem lt_trans {f g h : CauSeq α abs} (fg : f < g) (gh : g < h) : f < h :=\n  show Pos (h - f) by\n    convert add_pos fg gh using 1\n    simp\n#align cau_seq.lt_trans CauSeq.lt_trans\n\ntheorem lt_irrefl {f : CauSeq α abs} : ¬f < f\n  | h => not_limZero_of_pos h (by simp [zero_limZero])\n#align cau_seq.lt_irrefl CauSeq.lt_irrefl\n\ntheorem le_of_eq_of_le {f g h : CauSeq α abs} (hfg : f ≈ g) (hgh : g ≤ h) : f ≤ h :=\n  hgh.elim (Or.inl ∘ CauSeq.lt_of_eq_of_lt hfg) (Or.inr ∘ Setoid.trans hfg)\n#align cau_seq.le_of_eq_of_le CauSeq.le_of_eq_of_le\n\ntheorem le_of_le_of_eq {f g h : CauSeq α abs} (hfg : f ≤ g) (hgh : g ≈ h) : f ≤ h :=\n  hfg.elim (fun h => Or.inl (CauSeq.lt_of_lt_of_eq h hgh)) fun h => Or.inr (Setoid.trans h hgh)\n#align cau_seq.le_of_le_of_eq CauSeq.le_of_le_of_eq\n\ninstance : Preorder (CauSeq α abs) where\n  lt := (· < ·)\n  le f g := f < g ∨ f ≈ g\n  le_refl _ := Or.inr (Setoid.refl _)\n  le_trans _ _ _ fg gh :=\n    match fg, gh with\n    | Or.inl fg, Or.inl gh => Or.inl <| lt_trans fg gh\n    | Or.inl fg, Or.inr gh => Or.inl <| lt_of_lt_of_eq fg gh\n    | Or.inr fg, Or.inl gh => Or.inl <| lt_of_eq_of_lt fg gh\n    | Or.inr fg, Or.inr gh => Or.inr <| Setoid.trans fg gh\n  lt_iff_le_not_le _ _ :=\n    ⟨fun h => ⟨Or.inl h, not_or_of_not (mt (lt_trans h) lt_irrefl) (not_limZero_of_pos h)⟩,\n      fun ⟨h₁, h₂⟩ => h₁.resolve_right (mt (fun h => Or.inr (Setoid.symm h)) h₂)⟩\n\ntheorem le_antisymm {f g : CauSeq α abs} (fg : f ≤ g) (gf : g ≤ f) : f ≈ g :=\n  fg.resolve_left (not_lt_of_le gf)\n#align cau_seq.le_antisymm CauSeq.le_antisymm\n\ntheorem lt_total (f g : CauSeq α abs) : f < g ∨ f ≈ g ∨ g < f :=\n  (trichotomy (g - f)).imp_right fun h =>\n    h.imp (fun h => Setoid.symm h) fun h => by rwa [neg_sub] at h\n#align cau_seq.lt_total CauSeq.lt_total\n\ntheorem le_total (f g : CauSeq α abs) : f ≤ g ∨ g ≤ f :=\n  (or_assoc.2 (lt_total f g)).imp_right Or.inl\n#align cau_seq.le_total CauSeq.le_total\n\ntheorem const_lt {x y : α} : const x < const y ↔ x < y :=\n  show Pos _ ↔ _ by rw [← const_sub, const_pos, sub_pos]\n#align cau_seq.const_lt CauSeq.const_lt\n\ntheorem const_le {x y : α} : const x ≤ const y ↔ x ≤ y := by\n  rw [le_iff_lt_or_eq]; exact or_congr const_lt const_equiv\n#align cau_seq.const_le CauSeq.const_le\n\ntheorem le_of_exists {f g : CauSeq α abs} (h : ∃ i, ∀ j ≥ i, f j ≤ g j) : f ≤ g :=\n  let ⟨i, hi⟩ := h\n  (or_assoc.2 (CauSeq.lt_total f g)).elim id fun hgf =>\n    False.elim\n      (let ⟨_, hK0, j, hKj⟩ := hgf\n      not_lt_of_ge (hi (max i j) (le_max_left _ _))\n        (sub_pos.1 (lt_of_lt_of_le hK0 (hKj _ (le_max_right _ _)))))\n#align cau_seq.le_of_exists CauSeq.le_of_exists\n\ntheorem exists_gt (f : CauSeq α abs) : ∃ a : α, f < const a :=\n  let ⟨K, H⟩ := f.bounded\n  ⟨K + 1, 1, zero_lt_one, 0, fun i _ => by\n    rw [sub_apply, const_apply, le_sub_iff_add_le', add_le_add_iff_right]\n    exact le_of_lt (abs_lt.1 (H _)).2⟩\n#align cau_seq.exists_gt CauSeq.exists_gt\n\ntheorem exists_lt (f : CauSeq α abs) : ∃ a : α, const a < f :=\n  let ⟨a, h⟩ := (-f).exists_gt\n  ⟨-a, show Pos _ by rwa [const_neg, sub_neg_eq_add, add_comm, ← sub_neg_eq_add]⟩\n#align cau_seq.exists_lt CauSeq.exists_lt\n\n-- so named to match `rat_add_continuous_lemma`\ntheorem rat_sup_continuous_lemma {ε : α} {a₁ a₂ b₁ b₂ : α} :\n    abs (a₁ - b₁) < ε → abs (a₂ - b₂) < ε → abs (a₁ ⊔ a₂ - b₁ ⊔ b₂) < ε := fun h₁ h₂ =>\n  (abs_max_sub_max_le_max _ _ _ _).trans_lt (max_lt h₁ h₂)\n#align rat_sup_continuous_lemma CauSeq.rat_sup_continuous_lemma\n\n-- so named to match `rat_add_continuous_lemma`\ntheorem rat_inf_continuous_lemma {ε : α} {a₁ a₂ b₁ b₂ : α} :\n    abs (a₁ - b₁) < ε → abs (a₂ - b₂) < ε → abs (a₁ ⊓ a₂ - b₁ ⊓ b₂) < ε := fun h₁ h₂ =>\n  (abs_min_sub_min_le_max _ _ _ _).trans_lt (max_lt h₁ h₂)\n#align rat_inf_continuous_lemma CauSeq.rat_inf_continuous_lemma\n\ninstance : Sup (CauSeq α abs) :=\n  ⟨fun f g =>\n    ⟨f ⊔ g, fun _ ε0 =>\n      (exists_forall_ge_and (f.cauchy₃ ε0) (g.cauchy₃ ε0)).imp fun _ H _ ij =>\n        let ⟨H₁, H₂⟩ := H _ le_rfl\n        rat_sup_continuous_lemma (H₁ _ ij) (H₂ _ ij)⟩⟩\n\ninstance : Inf (CauSeq α abs) :=\n  ⟨fun f g =>\n    ⟨f ⊓ g, fun _ ε0 =>\n      (exists_forall_ge_and (f.cauchy₃ ε0) (g.cauchy₃ ε0)).imp fun _ H _ ij =>\n        let ⟨H₁, H₂⟩ := H _ le_rfl\n        rat_inf_continuous_lemma (H₁ _ ij) (H₂ _ ij)⟩⟩\n\n@[simp, norm_cast]\ntheorem coe_sup (f g : CauSeq α abs) : ⇑(f ⊔ g) = (f : ℕ → α) ⊔ g :=\n  rfl\n#align cau_seq.coe_sup CauSeq.coe_sup\n\n@[simp, norm_cast]\ntheorem coe_inf (f g : CauSeq α abs) : ⇑(f ⊓ g) = (f : ℕ → α) ⊓ g :=\n  rfl\n#align cau_seq.coe_inf CauSeq.coe_inf\n\ntheorem sup_limZero {f g : CauSeq α abs} (hf : LimZero f) (hg : LimZero g) : LimZero (f ⊔ g)\n  | ε, ε0 =>\n    (exists_forall_ge_and (hf _ ε0) (hg _ ε0)).imp fun i H j ij => by\n      let ⟨H₁, H₂⟩ := H _ ij\n      rw [abs_lt] at H₁ H₂⊢\n      exact ⟨lt_sup_iff.mpr (Or.inl H₁.1), sup_lt_iff.mpr ⟨H₁.2, H₂.2⟩⟩\n#align cau_seq.sup_lim_zero CauSeq.sup_limZero\n\ntheorem inf_limZero {f g : CauSeq α abs} (hf : LimZero f) (hg : LimZero g) : LimZero (f ⊓ g)\n  | ε, ε0 =>\n    (exists_forall_ge_and (hf _ ε0) (hg _ ε0)).imp fun i H j ij => by\n      let ⟨H₁, H₂⟩ := H _ ij\n      rw [abs_lt] at H₁ H₂⊢\n      exact ⟨lt_inf_iff.mpr ⟨H₁.1, H₂.1⟩, inf_lt_iff.mpr (Or.inl H₁.2)⟩\n#align cau_seq.inf_lim_zero CauSeq.inf_limZero\n\ntheorem sup_equiv_sup {a₁ b₁ a₂ b₂ : CauSeq α abs} (ha : a₁ ≈ a₂) (hb : b₁ ≈ b₂) :\n    a₁ ⊔ b₁ ≈ a₂ ⊔ b₂ := by\n  intro ε ε0\n  obtain ⟨ai, hai⟩ := ha ε ε0\n  obtain ⟨bi, hbi⟩ := hb ε ε0\n  exact\n    ⟨ai ⊔ bi, fun i hi =>\n      (abs_max_sub_max_le_max (a₁ i) (b₁ i) (a₂ i) (b₂ i)).trans_lt\n        (max_lt (hai i (sup_le_iff.mp hi).1) (hbi i (sup_le_iff.mp hi).2))⟩\n#align cau_seq.sup_equiv_sup CauSeq.sup_equiv_sup\n\n\n\nprotected theorem sup_lt {a b c : CauSeq α abs} (ha : a < c) (hb : b < c) : a ⊔ b < c := by\n  obtain ⟨⟨εa, εa0, ia, ha⟩, ⟨εb, εb0, ib, hb⟩⟩ := ha, hb\n  refine' ⟨εa ⊓ εb, lt_inf_iff.mpr ⟨εa0, εb0⟩, ia ⊔ ib, fun i hi => _⟩\n  have := min_le_min (ha _ (sup_le_iff.mp hi).1) (hb _ (sup_le_iff.mp hi).2)\n  exact this.trans_eq (min_sub_sub_left _ _ _)\n#align cau_seq.sup_lt CauSeq.sup_lt\n\nprotected theorem lt_inf {a b c : CauSeq α abs} (hb : a < b) (hc : a < c) : a < b ⊓ c := by\n  obtain ⟨⟨εb, εb0, ib, hb⟩, ⟨εc, εc0, ic, hc⟩⟩ := hb, hc\n  refine' ⟨εb ⊓ εc, lt_inf_iff.mpr ⟨εb0, εc0⟩, ib ⊔ ic, fun i hi => _⟩\n  have := min_le_min (hb _ (sup_le_iff.mp hi).1) (hc _ (sup_le_iff.mp hi).2)\n  exact this.trans_eq (min_sub_sub_right _ _ _)\n#align cau_seq.lt_inf CauSeq.lt_inf\n\n@[simp]\nprotected theorem sup_idem (a : CauSeq α abs) : a ⊔ a = a :=\n  Subtype.ext sup_idem\n#align cau_seq.sup_idem CauSeq.sup_idem\n\n@[simp]\nprotected theorem inf_idem (a : CauSeq α abs) : a ⊓ a = a :=\n  Subtype.ext inf_idem\n#align cau_seq.inf_idem CauSeq.inf_idem\n\nprotected theorem sup_comm (a b : CauSeq α abs) : a ⊔ b = b ⊔ a :=\n  Subtype.ext sup_comm\n#align cau_seq.sup_comm CauSeq.sup_comm\n\nprotected theorem inf_comm (a b : CauSeq α abs) : a ⊓ b = b ⊓ a :=\n  Subtype.ext inf_comm\n#align cau_seq.inf_comm CauSeq.inf_comm\n\nprotected theorem sup_eq_right {a b : CauSeq α abs} (h : a ≤ b) : a ⊔ b ≈ b := by\n  obtain ⟨ε, ε0 : _ < _, i, h⟩ | h := h\n  · intro _ _\n    refine' ⟨i, fun j hj => _⟩\n    dsimp\n    erw [← max_sub_sub_right]\n    rwa [sub_self, max_eq_right, abs_zero]\n    rw [sub_nonpos, ← sub_nonneg]\n    exact ε0.le.trans (h _ hj)\n  · refine' Setoid.trans (sup_equiv_sup h (Setoid.refl _)) _\n    rw [CauSeq.sup_idem]\n    exact Setoid.refl _\n#align cau_seq.sup_eq_right CauSeq.sup_eq_right\n\nprotected theorem inf_eq_right {a b : CauSeq α abs} (h : b ≤ a) : a ⊓ b ≈ b := by\n  obtain ⟨ε, ε0 : _ < _, i, h⟩ | h := h\n  · intro _ _\n    refine' ⟨i, fun j hj => _⟩\n    dsimp\n    erw [← min_sub_sub_right]\n    rwa [sub_self, min_eq_right, abs_zero]\n    exact ε0.le.trans (h _ hj)\n  · refine' Setoid.trans (inf_equiv_inf (Setoid.symm h) (Setoid.refl _)) _\n    rw [CauSeq.inf_idem]\n    exact Setoid.refl _\n#align cau_seq.inf_eq_right CauSeq.inf_eq_right\n\nprotected theorem sup_eq_left {a b : CauSeq α abs} (h : b ≤ a) : a ⊔ b ≈ a := by\n  simpa only [CauSeq.sup_comm] using CauSeq.sup_eq_right h\n#align cau_seq.sup_eq_left CauSeq.sup_eq_left\n\nprotected theorem inf_eq_left {a b : CauSeq α abs} (h : a ≤ b) : a ⊓ b ≈ a := by\n  simpa only [CauSeq.inf_comm] using CauSeq.inf_eq_right h\n#align cau_seq.inf_eq_left CauSeq.inf_eq_left\n\nprotected theorem le_sup_left {a b : CauSeq α abs} : a ≤ a ⊔ b :=\n  le_of_exists ⟨0, fun _ _ => le_sup_left⟩\n#align cau_seq.le_sup_left CauSeq.le_sup_left\n\nprotected theorem inf_le_left {a b : CauSeq α abs} : a ⊓ b ≤ a :=\n  le_of_exists ⟨0, fun _ _ => inf_le_left⟩\n#align cau_seq.inf_le_left CauSeq.inf_le_left\n\nprotected theorem le_sup_right {a b : CauSeq α abs} : b ≤ a ⊔ b :=\n  le_of_exists ⟨0, fun _ _ => le_sup_right⟩\n#align cau_seq.le_sup_right CauSeq.le_sup_right\n\nprotected theorem inf_le_right {a b : CauSeq α abs} : a ⊓ b ≤ b :=\n  le_of_exists ⟨0, fun _ _ => inf_le_right⟩\n#align cau_seq.inf_le_right CauSeq.inf_le_right\n\nprotected theorem sup_le {a b c : CauSeq α abs} (ha : a ≤ c) (hb : b ≤ c) : a ⊔ b ≤ c := by\n  cases' ha with ha ha\n  · cases' hb with hb hb\n    · exact Or.inl (CauSeq.sup_lt ha hb)\n    · replace ha := le_of_le_of_eq ha.le (Setoid.symm hb)\n      refine' le_of_le_of_eq (Or.inr _) hb\n      exact CauSeq.sup_eq_right ha\n  · replace hb := le_of_le_of_eq hb (Setoid.symm ha)\n    refine' le_of_le_of_eq (Or.inr _) ha\n    exact CauSeq.sup_eq_left hb\n#align cau_seq.sup_le CauSeq.sup_le\n\nprotected theorem le_inf {a b c : CauSeq α abs} (hb : a ≤ b) (hc : a ≤ c) : a ≤ b ⊓ c := by\n  cases' hb with hb hb\n  · cases' hc with hc hc\n    · exact Or.inl (CauSeq.lt_inf hb hc)\n    · replace hb := le_of_eq_of_le (Setoid.symm hc) hb.le\n      refine' le_of_eq_of_le hc (Or.inr _)\n      exact Setoid.symm (CauSeq.inf_eq_right hb)\n  · replace hc := le_of_eq_of_le (Setoid.symm hb) hc\n    refine' le_of_eq_of_le hb (Or.inr _)\n    exact Setoid.symm (CauSeq.inf_eq_left hc)\n#align cau_seq.le_inf CauSeq.le_inf\n\n/-! Note that `DistribLattice (CauSeq α abs)` is not true because there is no `PartialOrder`. -/\n\n\nprotected theorem sup_inf_distrib_left (a b c : CauSeq α abs) : a ⊔ b ⊓ c = (a ⊔ b) ⊓ (a ⊔ c) :=\n  Subtype.ext <| funext fun _ => max_min_distrib_left\n#align cau_seq.sup_inf_distrib_left CauSeq.sup_inf_distrib_left\n\nprotected theorem sup_inf_distrib_right (a b c : CauSeq α abs) : a ⊓ b ⊔ c = (a ⊔ c) ⊓ (b ⊔ c) :=\n  Subtype.ext <| funext fun _ => max_min_distrib_right\n#align cau_seq.sup_inf_distrib_right CauSeq.sup_inf_distrib_right\n\nend Abs\n\nend CauSeq\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Real/CauSeq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.4695696753109347}}
{"text": "/-\nCopyright (c) 2018 Michael Jendrusch. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Jendrusch, Scott Morrison, Bhavik Mehta, Jakob von Raumer\n-/\nimport category_theory.monoidal.coherence\n\n/-!\n# Lemmas which are consequences of monoidal coherence\n\nThese lemmas are all proved `by coherence`.\n\n## Future work\nInvestigate whether these lemmas are really needed,\nor if they can be replaced by use of the `coherence` tactic.\n-/\n\nopen category_theory\nopen category_theory.category\nopen category_theory.iso\n\nnamespace category_theory.monoidal_category\n\nvariables {C : Type*} [category C] [monoidal_category C]\n\n-- See Proposition 2.2.4 of <http://www-math.mit.edu/~etingof/egnobookfinal.pdf>\n@[reassoc]\nlemma left_unitor_tensor' (X Y : C) :\n  ((α_ (𝟙_ C) X Y).hom) ≫ ((λ_ (X ⊗ Y)).hom) = ((λ_ X).hom ⊗ (𝟙 Y)) :=\nby coherence\n\n@[reassoc, simp]\nlemma left_unitor_tensor (X Y : C) :\n  ((λ_ (X ⊗ Y)).hom) = ((α_ (𝟙_ C) X Y).inv) ≫ ((λ_ X).hom ⊗ (𝟙 Y)) :=\nby coherence\n\n@[reassoc]\nlemma left_unitor_tensor_inv (X Y : C) :\n  (λ_ (X ⊗ Y)).inv = ((λ_ X).inv ⊗ (𝟙 Y)) ≫ (α_ (𝟙_ C) X Y).hom :=\nby coherence\n\n@[reassoc]\nlemma id_tensor_right_unitor_inv (X Y : C) : 𝟙 X ⊗ (ρ_ Y).inv = (ρ_ _).inv ≫ (α_ _ _ _).hom :=\nby coherence\n\n@[reassoc]\nlemma left_unitor_inv_tensor_id (X Y : C) : (λ_ X).inv ⊗ 𝟙 Y = (λ_ _).inv ≫ (α_ _ _ _).inv :=\nby coherence\n\n@[reassoc]\nlemma pentagon_inv_inv_hom (W X Y Z : C) :\n  (α_ W (X ⊗ Y) Z).inv ≫ ((α_ W X Y).inv ⊗ (𝟙 Z)) ≫ (α_ (W ⊗ X) Y Z).hom\n  = ((𝟙 W) ⊗ (α_ X Y Z).hom) ≫ (α_ W X (Y ⊗ Z)).inv :=\nby coherence\n\n@[simp, reassoc] lemma triangle_assoc_comp_right_inv (X Y : C) :\n  ((ρ_ X).inv ⊗ 𝟙 Y) ≫ (α_ X (𝟙_ C) Y).hom = ((𝟙 X) ⊗ (λ_ Y).inv) :=\nby coherence\n\nlemma unitors_equal : (λ_ (𝟙_ C)).hom = (ρ_ (𝟙_ C)).hom :=\nby coherence\n\nlemma unitors_inv_equal : (λ_ (𝟙_ C)).inv = (ρ_ (𝟙_ C)).inv :=\nby coherence\n\n@[reassoc]\nlemma pentagon_hom_inv {W X Y Z : C} :\n  (α_ W X (Y ⊗ Z)).hom ≫ (𝟙 W ⊗ (α_ X Y Z).inv)\n  = (α_ (W ⊗ X) Y Z).inv ≫ ((α_ W X Y).hom ⊗ 𝟙 Z) ≫ (α_ W (X ⊗ Y) Z).hom :=\nby coherence\n\n@[reassoc]\nlemma pentagon_inv_hom (W X Y Z : C) :\n  (α_ (W ⊗ X) Y Z).inv ≫ ((α_ W X Y).hom ⊗ 𝟙 Z)\n  = (α_ W X (Y ⊗ Z)).hom ≫ (𝟙 W ⊗ (α_ X Y Z).inv) ≫ (α_ W (X ⊗ Y) Z).inv :=\nby coherence\n\nend category_theory.monoidal_category\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/monoidal/coherence_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.46956966329618965}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Yaël Dillies\n-/\n\nimport algebra.order.group.defs\nimport algebra.order.monoid.cancel.defs\nimport algebra.order.monoid.canonical.defs\nimport algebra.order.monoid.nat_cast\nimport algebra.order.monoid.with_zero.defs\nimport algebra.order.ring.lemmas\nimport algebra.ring.defs\nimport order.min_max\nimport tactic.nontriviality\nimport data.pi.algebra\nimport algebra.group.units\n\n/-!\n# Ordered rings and semirings\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file develops the basics of ordered (semi)rings.\n\nEach typeclass here comprises\n* an algebraic class (`semiring`, `comm_semiring`, `ring`, `comm_ring`)\n* an order class (`partial_order`, `linear_order`)\n* assumptions on how both interact ((strict) monotonicity, canonicity)\n\nFor short,\n* \"`+` respects `≤`\" means \"monotonicity of addition\"\n* \"`+` respects `<`\" means \"strict monotonicity of addition\"\n* \"`*` respects `≤`\" means \"monotonicity of multiplication by a nonnegative number\".\n* \"`*` respects `<`\" means \"strict monotonicity of multiplication by a positive number\".\n\n## Typeclasses\n\n* `ordered_semiring`: Semiring with a partial order such that `+` and `*` respect `≤`.\n* `strict_ordered_semiring`: Nontrivial semiring with a partial order such that `+` and `*` respects\n  `<`.\n* `ordered_comm_semiring`: Commutative semiring with a partial order such that `+` and `*` respect\n  `≤`.\n* `strict_ordered_comm_semiring`: Nontrivial commutative semiring with a partial order such that `+`\n  and `*` respect `<`.\n* `ordered_ring`: Ring with a partial order such that `+` respects `≤` and `*` respects `<`.\n* `ordered_comm_ring`: Commutative ring with a partial order such that `+` respects `≤` and\n  `*` respects `<`.\n* `linear_ordered_semiring`: Nontrivial semiring with a linear order such that `+` respects `≤` and\n  `*` respects `<`.\n* `linear_ordered_comm_semiring`: Nontrivial commutative semiring with a linear order such that `+`\n  respects `≤` and `*` respects `<`.\n* `linear_ordered_ring`: Nontrivial ring with a linear order such that `+` respects `≤` and `*`\n  respects `<`.\n* `linear_ordered_comm_ring`: Nontrivial commutative ring with a linear order such that `+` respects\n  `≤` and `*` respects `<`.\n* `canonically_ordered_comm_semiring`: Commutative semiring with a partial order such that `+`\n  respects `≤`, `*` respects `<`, and `a ≤ b ↔ ∃ c, b = a + c`.\n\n## Hierarchy\n\nThe hardest part of proving order lemmas might be to figure out the correct generality and its\ncorresponding typeclass. Here's an attempt at demystifying it. For each typeclass, we list its\nimmediate predecessors and what conditions are added to each of them.\n\n* `ordered_semiring`\n  - `ordered_add_comm_monoid` & multiplication & `*` respects `≤`\n  - `semiring` & partial order structure & `+` respects `≤` & `*` respects `≤`\n* `strict_ordered_semiring`\n  - `ordered_cancel_add_comm_monoid` & multiplication & `*` respects `<` & nontriviality\n  - `ordered_semiring` & `+` respects `<` & `*` respects `<` & nontriviality\n* `ordered_comm_semiring`\n  - `ordered_semiring` & commutativity of multiplication\n  - `comm_semiring` & partial order structure & `+` respects `≤` & `*` respects `<`\n* `strict_ordered_comm_semiring`\n  - `strict_ordered_semiring` & commutativity of multiplication\n  - `ordered_comm_semiring` & `+` respects `<` & `*` respects `<` & nontriviality\n* `ordered_ring`\n  - `ordered_semiring` & additive inverses\n  - `ordered_add_comm_group` & multiplication & `*` respects `<`\n  - `ring` & partial order structure & `+` respects `≤` & `*` respects `<`\n* `strict_ordered_ring`\n  - `strict_ordered_semiring` & additive inverses\n  - `ordered_semiring` & `+` respects `<` & `*` respects `<` & nontriviality\n* `ordered_comm_ring`\n  - `ordered_ring` & commutativity of multiplication\n  - `ordered_comm_semiring` & additive inverses\n  - `comm_ring` & partial order structure & `+` respects `≤` & `*` respects `<`\n* `strict_ordered_comm_ring`\n  - `strict_ordered_comm_semiring` & additive inverses\n  - `strict_ordered_ring` & commutativity of multiplication\n  - `ordered_comm_ring` & `+` respects `<` & `*` respects `<` & nontriviality\n* `linear_ordered_semiring`\n  - `strict_ordered_semiring` & totality of the order\n  - `linear_ordered_add_comm_monoid` & multiplication & nontriviality & `*` respects `<`\n* `linear_ordered_comm_semiring`\n  - `strict_ordered_comm_semiring` & totality of the order\n  - `linear_ordered_semiring` & commutativity of multiplication\n* `linear_ordered_ring`\n  - `strict_ordered_ring` & totality of the order\n  - `linear_ordered_semiring` & additive inverses\n  - `linear_ordered_add_comm_group` & multiplication & `*` respects `<`\n  - `domain` & linear order structure\n* `linear_ordered_comm_ring`\n  - `strict_ordered_comm_ring` & totality of the order\n  - `linear_ordered_ring` & commutativity of multiplication\n  - `linear_ordered_comm_semiring` & additive inverses\n  - `is_domain` & linear order structure\n\n-/\n\nopen function\n\nset_option old_structure_cmd true\n\nuniverse u\nvariables {α : Type u} {β : Type*}\n\n/-! Note that `order_dual` does not satisfy any of the ordered ring typeclasses due to the\n`zero_le_one` field. -/\n\nlemma add_one_le_two_mul [has_le α] [semiring α] [covariant_class α α (+) (≤)]\n  {a : α} (a1 : 1 ≤ a) :\n  a + 1 ≤ 2 * a :=\ncalc  a + 1 ≤ a + a : add_le_add_left a1 a\n        ... = 2 * a : (two_mul _).symm\n\n/-- An `ordered_semiring` is a semiring with a partial order such that addition is monotone and\nmultiplication by a nonnegative number is monotone. -/\n@[protect_proj, ancestor semiring ordered_add_comm_monoid]\nclass ordered_semiring (α : Type u) extends semiring α, ordered_add_comm_monoid α :=\n(zero_le_one : (0 : α) ≤ 1)\n(mul_le_mul_of_nonneg_left  : ∀ a b c : α, a ≤ b → 0 ≤ c → c * a ≤ c * b)\n(mul_le_mul_of_nonneg_right : ∀ a b c : α, a ≤ b → 0 ≤ c → a * c ≤ b * c)\n\n/-- An `ordered_comm_semiring` is a commutative semiring with a partial order such that addition is\nmonotone and multiplication by a nonnegative number is monotone. -/\n@[protect_proj, ancestor ordered_semiring comm_semiring]\nclass ordered_comm_semiring (α : Type u) extends ordered_semiring α, comm_semiring α\n\n/-- An `ordered_ring` is a ring with a partial order such that addition is monotone and\nmultiplication by a nonnegative number is monotone. -/\n@[protect_proj, ancestor ring ordered_add_comm_group]\nclass ordered_ring (α : Type u) extends ring α, ordered_add_comm_group α :=\n(zero_le_one : 0 ≤ (1 : α))\n(mul_nonneg : ∀ a b : α, 0 ≤ a → 0 ≤ b → 0 ≤ a * b)\n\n/-- An `ordered_comm_ring` is a commutative ring with a partial order such that addition is monotone\nand multiplication by a nonnegative number is monotone. -/\n@[protect_proj, ancestor ordered_ring comm_ring]\nclass ordered_comm_ring (α : Type u) extends ordered_ring α, comm_ring α\n\n/-- A `strict_ordered_semiring` is a nontrivial semiring with a partial order such that addition is\nstrictly monotone and multiplication by a positive number is strictly monotone. -/\n@[protect_proj, ancestor semiring ordered_cancel_add_comm_monoid nontrivial]\nclass strict_ordered_semiring (α : Type u)\n  extends semiring α, ordered_cancel_add_comm_monoid α, nontrivial α :=\n(zero_le_one : (0 : α) ≤ 1)\n(mul_lt_mul_of_pos_left  : ∀ a b c : α, a < b → 0 < c → c * a < c * b)\n(mul_lt_mul_of_pos_right : ∀ a b c : α, a < b → 0 < c → a * c < b * c)\n\n/-- A `strict_ordered_comm_semiring` is a commutative semiring with a partial order such that\naddition is strictly monotone and multiplication by a positive number is strictly monotone. -/\n@[protect_proj, ancestor strict_ordered_semiring comm_semiring]\nclass strict_ordered_comm_semiring (α : Type u) extends strict_ordered_semiring α, comm_semiring α\n\n/-- A `strict_ordered_ring` is a ring with a partial order such that addition is strictly monotone\nand multiplication by a positive number is strictly monotone. -/\n@[protect_proj, ancestor ring ordered_add_comm_group nontrivial]\nclass strict_ordered_ring (α : Type u) extends ring α, ordered_add_comm_group α, nontrivial α :=\n(zero_le_one : 0 ≤ (1 : α))\n(mul_pos     : ∀ a b : α, 0 < a → 0 < b → 0 < a * b)\n\n/-- A `strict_ordered_comm_ring` is a commutative ring with a partial order such that addition is\nstrictly monotone and multiplication by a positive number is strictly monotone. -/\n@[protect_proj, ancestor strict_ordered_ring comm_ring]\nclass strict_ordered_comm_ring (α : Type*) extends strict_ordered_ring α, comm_ring α\n\n/-- A `linear_ordered_semiring` is a nontrivial semiring with a linear order such that\naddition is monotone and multiplication by a positive number is strictly monotone. -/\n/- It's not entirely clear we should assume `nontrivial` at this point; it would be reasonable to\nexplore changing this, but be warned that the instances involving `domain` may cause typeclass\nsearch loops. -/\n@[protect_proj, ancestor strict_ordered_semiring linear_ordered_add_comm_monoid nontrivial]\nclass linear_ordered_semiring (α : Type u)\n  extends strict_ordered_semiring α, linear_ordered_add_comm_monoid α\n\n/-- A `linear_ordered_comm_semiring` is a nontrivial commutative semiring with a linear order such\nthat addition is monotone and multiplication by a positive number is strictly monotone. -/\n@[protect_proj, ancestor ordered_comm_semiring linear_ordered_semiring]\nclass linear_ordered_comm_semiring (α : Type*)\n  extends strict_ordered_comm_semiring α, linear_ordered_semiring α\n\n/-- A `linear_ordered_ring` is a ring with a linear order such that addition is monotone and\nmultiplication by a positive number is strictly monotone. -/\n@[protect_proj, ancestor strict_ordered_ring linear_order]\nclass linear_ordered_ring (α : Type u) extends strict_ordered_ring α, linear_order α\n\n/-- A `linear_ordered_comm_ring` is a commutative ring with a linear order such that addition is\nmonotone and multiplication by a positive number is strictly monotone. -/\n@[protect_proj, ancestor linear_ordered_ring comm_monoid]\nclass linear_ordered_comm_ring (α : Type u) extends linear_ordered_ring α, comm_monoid α\n\n\nsection ordered_semiring\nvariables [ordered_semiring α] {a b c d : α}\n\n@[priority 100] -- see Note [lower instance priority]\ninstance ordered_semiring.zero_le_one_class : zero_le_one_class α :=\n{ ..‹ordered_semiring α› }\n\n@[priority 200] -- see Note [lower instance priority]\ninstance ordered_semiring.to_pos_mul_mono : pos_mul_mono α :=\n⟨λ x a b h, ordered_semiring.mul_le_mul_of_nonneg_left _ _ _ h x.2⟩\n\n@[priority 200] -- see Note [lower instance priority]\ninstance ordered_semiring.to_mul_pos_mono : mul_pos_mono α :=\n⟨λ x a b h, ordered_semiring.mul_le_mul_of_nonneg_right _ _ _ h x.2⟩\n\nlemma bit1_mono : monotone (bit1 : α → α) := λ a b h, add_le_add_right (bit0_mono h) _\n\n@[simp] lemma pow_nonneg (H : 0 ≤ a) : ∀ (n : ℕ), 0 ≤ a ^ n\n| 0     := by { rw pow_zero, exact zero_le_one}\n| (n+1) := by { rw pow_succ, exact mul_nonneg H (pow_nonneg _) }\n\nlemma add_le_mul_two_add (a2 : 2 ≤ a) (b0 : 0 ≤ b) : a + (2 + b) ≤ a * (2 + b) :=\ncalc a + (2 + b) ≤ a + (a + a * b) :\n      add_le_add_left (add_le_add a2 $ le_mul_of_one_le_left b0 $ one_le_two.trans a2) a\n             ... ≤ a * (2 + b) : by rw [mul_add, mul_two, add_assoc]\n\nlemma one_le_mul_of_one_le_of_one_le (ha : 1 ≤ a) (hb : 1 ≤ b) : (1 : α) ≤ a * b :=\nleft.one_le_mul_of_le_of_le ha hb $ zero_le_one.trans ha\n\nsection monotone\nvariables [preorder β] {f g : β → α}\n\nlemma monotone_mul_left_of_nonneg (ha : 0 ≤ a) : monotone (λ x, a * x) :=\nλ b c h, mul_le_mul_of_nonneg_left h ha\n\nlemma monotone_mul_right_of_nonneg (ha : 0 ≤ a) : monotone (λ x, x * a) :=\nλ b c h, mul_le_mul_of_nonneg_right h ha\n\nlemma monotone.mul_const (hf : monotone f) (ha : 0 ≤ a) : monotone (λ x, f x * a) :=\n(monotone_mul_right_of_nonneg ha).comp hf\n\nlemma monotone.const_mul (hf : monotone f) (ha : 0 ≤ a) : monotone (λ x, a * f x) :=\n(monotone_mul_left_of_nonneg ha).comp hf\n\nlemma antitone.mul_const (hf : antitone f) (ha : 0 ≤ a) : antitone (λ x, f x * a) :=\n(monotone_mul_right_of_nonneg ha).comp_antitone hf\n\nlemma antitone.const_mul (hf : antitone f) (ha : 0 ≤ a) : antitone (λ x, a * f x) :=\n(monotone_mul_left_of_nonneg ha).comp_antitone hf\n\nlemma monotone.mul (hf : monotone f) (hg : monotone g) (hf₀ : ∀ x, 0 ≤ f x) (hg₀ : ∀ x, 0 ≤ g x) :\n  monotone (f * g) :=\nλ b c h, mul_le_mul (hf h) (hg h) (hg₀ _) (hf₀ _)\n\nend monotone\n\nlemma bit1_pos [nontrivial α] (h : 0 ≤ a) : 0 < bit1 a :=\nzero_lt_one.trans_le $ bit1_zero.symm.trans_le $ bit1_mono h\n\nlemma bit1_pos' (h : 0 < a) : 0 < bit1 a := by { nontriviality, exact bit1_pos h.le }\n\nlemma mul_le_one (ha : a ≤ 1) (hb' : 0 ≤ b) (hb : b ≤ 1) : a * b ≤ 1 :=\none_mul (1 : α) ▸ mul_le_mul ha hb hb' zero_le_one\n\nlemma one_lt_mul_of_le_of_lt (ha : 1 ≤ a) (hb : 1 < b) : 1 < a * b :=\nhb.trans_le $ le_mul_of_one_le_left (zero_le_one.trans hb.le) ha\n\nlemma one_lt_mul_of_lt_of_le (ha : 1 < a) (hb : 1 ≤ b) : 1 < a * b :=\nha.trans_le $ le_mul_of_one_le_right (zero_le_one.trans ha.le) hb\n\nalias one_lt_mul_of_le_of_lt ← one_lt_mul\n\nlemma mul_lt_one_of_nonneg_of_lt_one_left (ha₀ : 0 ≤ a) (ha : a < 1) (hb : b ≤ 1) : a * b < 1 :=\n(mul_le_of_le_one_right ha₀ hb).trans_lt ha\n\nlemma mul_lt_one_of_nonneg_of_lt_one_right (ha : a ≤ 1) (hb₀ : 0 ≤ b) (hb : b < 1) : a * b < 1 :=\n(mul_le_of_le_one_left hb₀ ha).trans_lt hb\n\nend ordered_semiring\n\nsection ordered_ring\nvariables [ordered_ring α] {a b c d : α}\n\n@[priority 100] -- see Note [lower instance priority]\ninstance ordered_ring.to_ordered_semiring : ordered_semiring α :=\n{ mul_le_mul_of_nonneg_left := λ a b c h hc,\n    by simpa only [mul_sub, sub_nonneg] using ordered_ring.mul_nonneg _ _ hc (sub_nonneg.2 h),\n  mul_le_mul_of_nonneg_right := λ a b c h hc,\n    by simpa only [sub_mul, sub_nonneg] using ordered_ring.mul_nonneg _ _ (sub_nonneg.2 h) hc,\n  ..‹ordered_ring α›, ..ring.to_semiring }\n\nlemma mul_le_mul_of_nonpos_left (h : b ≤ a) (hc : c ≤ 0) : c * a ≤ c * b :=\nby simpa only [neg_mul, neg_le_neg_iff] using mul_le_mul_of_nonneg_left h (neg_nonneg.2 hc)\n\nlemma mul_le_mul_of_nonpos_right (h : b ≤ a) (hc : c ≤ 0) : a * c ≤ b * c :=\nby simpa only [mul_neg, neg_le_neg_iff] using mul_le_mul_of_nonneg_right h (neg_nonneg.2 hc)\n\nlemma mul_nonneg_of_nonpos_of_nonpos (ha : a ≤ 0) (hb : b ≤ 0) : 0 ≤ a * b :=\nby simpa only [zero_mul] using mul_le_mul_of_nonpos_right ha hb\n\nlemma mul_le_mul_of_nonneg_of_nonpos (hca : c ≤ a) (hbd : b ≤ d) (hc : 0 ≤ c) (hb : b ≤ 0) :\n  a * b ≤ c * d :=\n(mul_le_mul_of_nonpos_right hca hb).trans $ mul_le_mul_of_nonneg_left hbd hc\n\nlemma mul_le_mul_of_nonneg_of_nonpos' (hca : c ≤ a) (hbd : b ≤ d) (ha : 0 ≤ a) (hd : d ≤ 0) :\n  a * b ≤ c * d :=\n(mul_le_mul_of_nonneg_left hbd ha).trans $ mul_le_mul_of_nonpos_right hca hd\n\nlemma mul_le_mul_of_nonpos_of_nonneg (hac : a ≤ c) (hdb : d ≤ b) (hc : c ≤ 0) (hb : 0 ≤ b) :\n  a * b ≤ c * d :=\n(mul_le_mul_of_nonneg_right hac hb).trans $ mul_le_mul_of_nonpos_left hdb hc\n\nlemma mul_le_mul_of_nonpos_of_nonneg' (hca : c ≤ a) (hbd : b ≤ d) (ha : 0 ≤ a) (hd : d ≤ 0) :\n  a * b ≤ c * d :=\n(mul_le_mul_of_nonneg_left hbd ha).trans $ mul_le_mul_of_nonpos_right hca hd\n\nlemma mul_le_mul_of_nonpos_of_nonpos (hca : c ≤ a) (hdb : d ≤ b) (hc : c ≤ 0) (hb : b ≤ 0) :\n  a * b ≤ c * d :=\n(mul_le_mul_of_nonpos_right hca hb).trans $ mul_le_mul_of_nonpos_left hdb hc\n\nlemma mul_le_mul_of_nonpos_of_nonpos' (hca : c ≤ a) (hdb : d ≤ b) (ha : a ≤ 0) (hd : d ≤ 0) :\n  a * b ≤ c * d :=\n(mul_le_mul_of_nonpos_left hdb ha).trans $ mul_le_mul_of_nonpos_right hca hd\n\nsection monotone\nvariables [preorder β] {f g : β → α}\n\nlemma antitone_mul_left {a : α} (ha : a ≤ 0) : antitone ((*) a) :=\nλ b c b_le_c, mul_le_mul_of_nonpos_left b_le_c ha\n\nlemma antitone_mul_right {a : α} (ha : a ≤ 0) : antitone (λ x, x * a) :=\nλ b c b_le_c, mul_le_mul_of_nonpos_right b_le_c ha\n\nlemma monotone.const_mul_of_nonpos (hf : monotone f) (ha : a ≤ 0) : antitone (λ x, a * f x) :=\n(antitone_mul_left ha).comp_monotone hf\n\nlemma monotone.mul_const_of_nonpos (hf : monotone f) (ha : a ≤ 0) : antitone (λ x, f x * a) :=\n(antitone_mul_right ha).comp_monotone hf\n\nlemma antitone.const_mul_of_nonpos (hf : antitone f) (ha : a ≤ 0) : monotone (λ x, a * f x) :=\n(antitone_mul_left ha).comp hf\n\nlemma antitone.mul_const_of_nonpos (hf : antitone f) (ha : a ≤ 0) : monotone (λ x, f x * a) :=\n(antitone_mul_right ha).comp hf\n\nlemma antitone.mul_monotone (hf : antitone f) (hg : monotone g) (hf₀ : ∀ x, f x ≤ 0)\n  (hg₀ : ∀ x, 0 ≤ g x) :\n  antitone (f * g) :=\nλ b c h, mul_le_mul_of_nonpos_of_nonneg (hf h) (hg h) (hf₀ _) (hg₀ _)\n\nlemma monotone.mul_antitone (hf : monotone f) (hg : antitone g) (hf₀ : ∀ x, 0 ≤ f x)\n  (hg₀ : ∀ x, g x ≤ 0) :\n  antitone (f * g) :=\nλ b c h, mul_le_mul_of_nonneg_of_nonpos (hf h) (hg h) (hf₀ _) (hg₀ _)\n\nlemma antitone.mul (hf : antitone f) (hg : antitone g) (hf₀ : ∀ x, f x ≤ 0) (hg₀ : ∀ x, g x ≤ 0) :\n  monotone (f * g) :=\nλ b c h, mul_le_mul_of_nonpos_of_nonpos (hf h) (hg h) (hf₀ _) (hg₀ _)\n\nend monotone\n\nlemma le_iff_exists_nonneg_add (a b : α) : a ≤ b ↔ ∃ c ≥ 0, b = a + c :=\n⟨λ h, ⟨b - a, sub_nonneg.mpr h, by simp⟩,\n  λ ⟨c, hc, h⟩, by { rw [h, le_add_iff_nonneg_right], exact hc }⟩\n\nend ordered_ring\n\nsection ordered_comm_ring\nvariables [ordered_comm_ring α]\n\n@[priority 100] -- See note [lower instance priority]\ninstance ordered_comm_ring.to_ordered_comm_semiring : ordered_comm_semiring α :=\n{ ..ordered_ring.to_ordered_semiring, ..‹ordered_comm_ring α› }\n\nend ordered_comm_ring\n\nsection strict_ordered_semiring\nvariables [strict_ordered_semiring α] {a b c d : α}\n\n@[priority 200] -- see Note [lower instance priority]\ninstance strict_ordered_semiring.to_pos_mul_strict_mono : pos_mul_strict_mono α :=\n⟨λ x a b h, strict_ordered_semiring.mul_lt_mul_of_pos_left _ _ _ h x.prop⟩\n\n@[priority 200] -- see Note [lower instance priority]\ninstance strict_ordered_semiring.to_mul_pos_strict_mono : mul_pos_strict_mono α :=\n⟨λ x a b h, strict_ordered_semiring.mul_lt_mul_of_pos_right _ _ _ h x.prop⟩\n\n/-- A choice-free version of `strict_ordered_semiring.to_ordered_semiring` to avoid using choice in\nbasic `nat` lemmas. -/\n@[reducible] -- See note [reducible non-instances]\ndef strict_ordered_semiring.to_ordered_semiring' [@decidable_rel α (≤)] : ordered_semiring α :=\n{ mul_le_mul_of_nonneg_left := λ a b c hab hc, begin\n    obtain rfl | hab := decidable.eq_or_lt_of_le hab,\n    { refl },\n    obtain rfl | hc := decidable.eq_or_lt_of_le hc,\n    { simp },\n    { exact (mul_lt_mul_of_pos_left hab hc).le }\n  end,\n  mul_le_mul_of_nonneg_right := λ a b c hab hc, begin\n    obtain rfl | hab := decidable.eq_or_lt_of_le hab,\n    { refl },\n    obtain rfl | hc := decidable.eq_or_lt_of_le hc,\n    { simp },\n    { exact (mul_lt_mul_of_pos_right hab hc).le }\n  end,\n  ..‹strict_ordered_semiring α› }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_semiring.to_ordered_semiring : ordered_semiring α :=\n{ mul_le_mul_of_nonneg_left := λ _ _ _, begin\n    letI := @strict_ordered_semiring.to_ordered_semiring' α _ (classical.dec_rel _),\n    exact mul_le_mul_of_nonneg_left,\n  end,\n  mul_le_mul_of_nonneg_right := λ _ _ _, begin\n    letI := @strict_ordered_semiring.to_ordered_semiring' α _ (classical.dec_rel _),\n    exact mul_le_mul_of_nonneg_right,\n  end,\n  ..‹strict_ordered_semiring α› }\n\nlemma mul_lt_mul (hac : a < c) (hbd : b ≤ d) (hb : 0 < b) (hc : 0 ≤ c) : a * b < c * d :=\n(mul_lt_mul_of_pos_right hac hb).trans_le $ mul_le_mul_of_nonneg_left hbd hc\n\nlemma mul_lt_mul' (hac : a ≤ c) (hbd : b < d) (hb : 0 ≤ b) (hc : 0 < c) : a * b < c * d :=\n(mul_le_mul_of_nonneg_right hac hb).trans_lt $ mul_lt_mul_of_pos_left hbd hc\n\n@[simp] theorem pow_pos (H : 0 < a) : ∀ (n : ℕ), 0 < a ^ n\n| 0     := by { nontriviality, rw pow_zero, exact zero_lt_one }\n| (n+1) := by { rw pow_succ, exact mul_pos H (pow_pos _) }\n\nlemma mul_self_lt_mul_self (h1 : 0 ≤ a) (h2 : a < b) : a * a < b * b :=\nmul_lt_mul' h2.le h2 h1 $ h1.trans_lt h2\n\n-- In the next lemma, we used to write `set.Ici 0` instead of `{x | 0 ≤ x}`.\n-- As this lemma is not used outside this file,\n-- and the import for `set.Ici` is not otherwise needed until later,\n-- we choose not to use it here.\nlemma strict_mono_on_mul_self : strict_mono_on (λ x : α, x * x) {x | 0 ≤ x} :=\nλ x hx y hy hxy, mul_self_lt_mul_self hx hxy\n\n-- See Note [decidable namespace]\nprotected lemma decidable.mul_lt_mul'' [@decidable_rel α (≤)]\n  (h1 : a < c) (h2 : b < d) (h3 : 0 ≤ a) (h4 : 0 ≤ b) : a * b < c * d :=\nh4.lt_or_eq_dec.elim\n  (λ b0, mul_lt_mul h1 h2.le b0 $ h3.trans h1.le)\n  (λ b0, by rw [← b0, mul_zero]; exact\n    mul_pos (h3.trans_lt h1) (h4.trans_lt h2))\n\nlemma mul_lt_mul'' : a < c → b < d → 0 ≤ a → 0 ≤ b → a * b < c * d :=\nby classical; exact decidable.mul_lt_mul''\n\nlemma lt_mul_left (hn : 0 < a) (hm : 1 < b) : a < b * a :=\nby { convert mul_lt_mul_of_pos_right hm hn, rw one_mul }\n\nlemma lt_mul_right (hn : 0 < a) (hm : 1 < b) : a < a * b :=\nby { convert mul_lt_mul_of_pos_left hm hn, rw mul_one }\n\nlemma lt_mul_self (hn : 1 < a) : a < a * a :=\nlt_mul_left (hn.trans_le' zero_le_one) hn\n\nsection monotone\nvariables [preorder β] {f g : β → α}\n\nlemma strict_mono_mul_left_of_pos (ha : 0 < a) : strict_mono (λ x, a * x) :=\nassume b c b_lt_c, mul_lt_mul_of_pos_left b_lt_c ha\n\nlemma strict_mono_mul_right_of_pos (ha : 0 < a) : strict_mono (λ x, x * a) :=\nassume b c b_lt_c, mul_lt_mul_of_pos_right b_lt_c ha\n\nlemma strict_mono.mul_const (hf : strict_mono f) (ha : 0 < a) :\n  strict_mono (λ x, (f x) * a) :=\n(strict_mono_mul_right_of_pos ha).comp hf\n\nlemma strict_mono.const_mul (hf : strict_mono f) (ha : 0 < a) :\n  strict_mono (λ x, a * (f x)) :=\n(strict_mono_mul_left_of_pos ha).comp hf\n\nlemma strict_anti.mul_const (hf : strict_anti f) (ha : 0 < a) : strict_anti (λ x, f x * a) :=\n(strict_mono_mul_right_of_pos ha).comp_strict_anti hf\n\nlemma strict_anti.const_mul (hf : strict_anti f) (ha : 0 < a) : strict_anti (λ x, a * f x) :=\n(strict_mono_mul_left_of_pos ha).comp_strict_anti hf\n\nlemma strict_mono.mul_monotone (hf : strict_mono f) (hg : monotone g) (hf₀ : ∀ x, 0 ≤ f x)\n  (hg₀ : ∀ x, 0 < g x) :\n  strict_mono (f * g) :=\nλ b c h, mul_lt_mul (hf h) (hg h.le) (hg₀ _) (hf₀ _)\n\nlemma monotone.mul_strict_mono (hf : monotone f) (hg : strict_mono g) (hf₀ : ∀ x, 0 < f x)\n  (hg₀ : ∀ x, 0 ≤ g x) :\n  strict_mono (f * g) :=\nλ b c h, mul_lt_mul' (hf h.le) (hg h) (hg₀ _) (hf₀ _)\n\nlemma strict_mono.mul (hf : strict_mono f) (hg : strict_mono g) (hf₀ : ∀ x, 0 ≤ f x)\n  (hg₀ : ∀ x, 0 ≤ g x) :\n  strict_mono (f * g) :=\nλ b c h, mul_lt_mul'' (hf h) (hg h) (hf₀ _) (hg₀ _)\n\nend monotone\n\nlemma lt_two_mul_self (ha : 0 < a) : a < 2 * a := lt_mul_of_one_lt_left ha one_lt_two\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_semiring.to_no_max_order : no_max_order α :=\n⟨λ a, ⟨a + 1, lt_add_of_pos_right _ one_pos⟩⟩\n\nend strict_ordered_semiring\n\nsection strict_ordered_comm_semiring\nvariables [strict_ordered_comm_semiring α]\n\n/-- A choice-free version of `strict_ordered_comm_semiring.to_ordered_comm_semiring` to avoid using\nchoice in basic `nat` lemmas. -/\n@[reducible] -- See note [reducible non-instances]\ndef strict_ordered_comm_semiring.to_ordered_comm_semiring' [@decidable_rel α (≤)] :\n  ordered_comm_semiring α :=\n{ ..‹strict_ordered_comm_semiring α›, ..strict_ordered_semiring.to_ordered_semiring' }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_comm_semiring.to_ordered_comm_semiring : ordered_comm_semiring α :=\n{ ..‹strict_ordered_comm_semiring α›, ..strict_ordered_semiring.to_ordered_semiring }\n\nend strict_ordered_comm_semiring\n\nsection strict_ordered_ring\nvariables [strict_ordered_ring α] {a b c : α}\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_ring.to_strict_ordered_semiring : strict_ordered_semiring α :=\n{ le_of_add_le_add_left := @le_of_add_le_add_left α _ _ _,\n  mul_lt_mul_of_pos_left := λ a b c h hc,\n    by simpa only [mul_sub, sub_pos] using strict_ordered_ring.mul_pos _ _ hc (sub_pos.2 h),\n  mul_lt_mul_of_pos_right := λ a b c h hc,\n    by simpa only [sub_mul, sub_pos] using strict_ordered_ring.mul_pos _ _ (sub_pos.2 h) hc,\n  ..‹strict_ordered_ring α›,  ..ring.to_semiring }\n\n/-- A choice-free version of `strict_ordered_ring.to_ordered_ring` to avoid using choice in basic\n`int` lemmas. -/\n@[reducible] -- See note [reducible non-instances]\ndef strict_ordered_ring.to_ordered_ring' [@decidable_rel α (≤)] : ordered_ring α :=\n{ mul_nonneg := λ a b ha hb, begin\n    obtain ha | ha := decidable.eq_or_lt_of_le ha,\n    { rw [←ha, zero_mul] },\n    obtain hb | hb := decidable.eq_or_lt_of_le hb,\n    { rw [←hb, mul_zero] },\n    { exact (strict_ordered_ring.mul_pos _ _ ha hb).le }\n  end,\n  ..‹strict_ordered_ring α›,  ..ring.to_semiring }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_ring.to_ordered_ring : ordered_ring α :=\n{ mul_nonneg := λ a b, begin\n    letI := @strict_ordered_ring.to_ordered_ring' α _ (classical.dec_rel _),\n    exact mul_nonneg,\n  end,\n  ..‹strict_ordered_ring α› }\n\nlemma mul_lt_mul_of_neg_left (h : b < a) (hc : c < 0) : c * a < c * b :=\nby simpa only [neg_mul, neg_lt_neg_iff] using mul_lt_mul_of_pos_left h (neg_pos_of_neg hc)\n\nlemma mul_lt_mul_of_neg_right (h : b < a) (hc : c < 0) : a * c < b * c :=\nby simpa only [mul_neg, neg_lt_neg_iff] using mul_lt_mul_of_pos_right h (neg_pos_of_neg hc)\n\nlemma mul_pos_of_neg_of_neg {a b : α} (ha : a < 0) (hb : b < 0) : 0 < a * b :=\nby simpa only [zero_mul] using mul_lt_mul_of_neg_right ha hb\n\nsection monotone\nvariables [preorder β] {f g : β → α}\n\nlemma strict_anti_mul_left {a : α} (ha : a < 0) : strict_anti ((*) a) :=\nλ b c b_lt_c, mul_lt_mul_of_neg_left b_lt_c ha\n\nlemma strict_anti_mul_right {a : α} (ha : a < 0) : strict_anti (λ x, x * a) :=\nλ b c b_lt_c, mul_lt_mul_of_neg_right b_lt_c ha\n\nlemma strict_mono.const_mul_of_neg (hf : strict_mono f) (ha : a < 0) : strict_anti (λ x, a * f x) :=\n(strict_anti_mul_left ha).comp_strict_mono hf\n\nlemma strict_mono.mul_const_of_neg (hf : strict_mono f) (ha : a < 0) : strict_anti (λ x, f x * a) :=\n(strict_anti_mul_right ha).comp_strict_mono hf\n\nlemma strict_anti.const_mul_of_neg (hf : strict_anti f) (ha : a < 0) : strict_mono (λ x, a * f x) :=\n(strict_anti_mul_left ha).comp hf\n\nlemma strict_anti.mul_const_of_neg (hf : strict_anti f) (ha : a < 0) : strict_mono (λ x, f x * a) :=\n(strict_anti_mul_right ha).comp hf\n\nend monotone\nend strict_ordered_ring\n\nsection strict_ordered_comm_ring\nvariables [strict_ordered_comm_ring α]\n\n/-- A choice-free version of `strict_ordered_comm_ring.to_ordered_comm_semiring'` to avoid using\nchoice in basic `int` lemmas. -/\n@[reducible] -- See note [reducible non-instances]\ndef strict_ordered_comm_ring.to_ordered_comm_ring' [@decidable_rel α (≤)] : ordered_comm_ring α :=\n{ ..‹strict_ordered_comm_ring α›, ..strict_ordered_ring.to_ordered_ring' }\n\n@[priority 100] -- See note [lower instance priority]\ninstance strict_ordered_comm_ring.to_strict_ordered_comm_semiring :\n  strict_ordered_comm_semiring α :=\n{ ..‹strict_ordered_comm_ring α›, ..strict_ordered_ring.to_strict_ordered_semiring }\n\n@[priority 100] -- See note [lower instance priority]\ninstance strict_ordered_comm_ring.to_ordered_comm_ring : ordered_comm_ring α :=\n{ ..‹strict_ordered_comm_ring α›, ..strict_ordered_ring.to_ordered_ring }\n\nend strict_ordered_comm_ring\n\nsection linear_ordered_semiring\nvariables [linear_ordered_semiring α] {a b c d : α}\n\n@[priority 200] -- see Note [lower instance priority]\ninstance linear_ordered_semiring.to_pos_mul_reflect_lt : pos_mul_reflect_lt α :=\n⟨λ a b c, (monotone_mul_left_of_nonneg a.2).reflect_lt⟩\n\n@[priority 200] -- see Note [lower instance priority]\ninstance linear_ordered_semiring.to_mul_pos_reflect_lt : mul_pos_reflect_lt α :=\n⟨λ a b c, (monotone_mul_right_of_nonneg a.2).reflect_lt⟩\n\nlocal attribute [instance] linear_ordered_semiring.decidable_le linear_ordered_semiring.decidable_lt\n\nlemma nonneg_and_nonneg_or_nonpos_and_nonpos_of_mul_nnonneg (hab : 0 ≤ a * b) :\n    (0 ≤ a ∧ 0 ≤ b) ∨ (a ≤ 0 ∧ b ≤ 0) :=\nbegin\n  refine decidable.or_iff_not_and_not.2 _,\n  simp only [not_and, not_le], intros ab nab, apply not_lt_of_le hab _,\n  rcases lt_trichotomy 0 a with (ha|rfl|ha),\n  exacts [mul_neg_of_pos_of_neg ha (ab ha.le), ((ab le_rfl).asymm (nab le_rfl)).elim,\n    mul_neg_of_neg_of_pos ha (nab ha.le)]\nend\n\nlemma nonneg_of_mul_nonneg_left (h : 0 ≤ a * b) (hb : 0 < b) : 0 ≤ a :=\nle_of_not_gt $ λ ha, (mul_neg_of_neg_of_pos ha hb).not_le h\n\nlemma nonneg_of_mul_nonneg_right (h : 0 ≤ a * b) (ha : 0 < a) : 0 ≤ b :=\nle_of_not_gt $ λ hb, (mul_neg_of_pos_of_neg ha hb).not_le h\n\nlemma neg_of_mul_neg_left (h : a * b < 0) (hb : 0 ≤ b) : a < 0 :=\nlt_of_not_ge $ λ ha, (mul_nonneg ha hb).not_lt h\n\nlemma neg_of_mul_neg_right (h : a * b < 0) (ha : 0 ≤ a) : b < 0 :=\nlt_of_not_ge $ λ hb, (mul_nonneg ha hb).not_lt h\n\nlemma nonpos_of_mul_nonpos_left (h : a * b ≤ 0) (hb : 0 < b) : a ≤ 0 :=\nle_of_not_gt (assume ha : a > 0, (mul_pos ha hb).not_le h)\n\nlemma nonpos_of_mul_nonpos_right (h : a * b ≤ 0) (ha : 0 < a) : b ≤ 0 :=\nle_of_not_gt (assume hb : b > 0, (mul_pos ha hb).not_le h)\n\n@[simp] lemma zero_le_mul_left (h : 0 < c) : 0 ≤ c * b ↔ 0 ≤ b :=\nby { convert mul_le_mul_left h, simp }\n\n@[simp] lemma zero_le_mul_right (h : 0 < c) : 0 ≤ b * c ↔ 0 ≤ b :=\nby { convert mul_le_mul_right h, simp }\n\nlemma add_le_mul_of_left_le_right (a2 : 2 ≤ a) (ab : a ≤ b) : a + b ≤ a * b :=\nhave 0 < b, from\ncalc 0 < 2 : zero_lt_two\n   ... ≤ a : a2\n   ... ≤ b : ab,\ncalc a + b ≤ b + b : add_le_add_right ab b\n       ... = 2 * b : (two_mul b).symm\n       ... ≤ a * b : (mul_le_mul_right this).mpr a2\n\nlemma add_le_mul_of_right_le_left (b2 : 2 ≤ b) (ba : b ≤ a) : a + b ≤ a * b :=\nhave 0 < a, from\ncalc 0 < 2 : zero_lt_two\n   ... ≤ b : b2\n   ... ≤ a : ba,\ncalc a + b ≤ a + a : add_le_add_left ba a\n       ... = a * 2 : (mul_two a).symm\n       ... ≤ a * b : (mul_le_mul_left this).mpr b2\n\nlemma add_le_mul (a2 : 2 ≤ a) (b2 : 2 ≤ b) : a + b ≤ a * b :=\nif hab : a ≤ b then add_le_mul_of_left_le_right a2 hab\n               else add_le_mul_of_right_le_left b2 (le_of_not_le hab)\n\nlemma add_le_mul' (a2 : 2 ≤ a) (b2 : 2 ≤ b) : a + b ≤ b * a :=\n(le_of_eq (add_comm _ _)).trans (add_le_mul b2 a2)\n\nsection\n\n@[simp] lemma bit0_le_bit0 : bit0 a ≤ bit0 b ↔ a ≤ b :=\nby rw [bit0, bit0, ← two_mul, ← two_mul, mul_le_mul_left (zero_lt_two : 0 < (2:α))]\n\n@[simp] lemma bit0_lt_bit0 : bit0 a < bit0 b ↔ a < b :=\nby rw [bit0, bit0, ← two_mul, ← two_mul, mul_lt_mul_left (zero_lt_two : 0 < (2:α))]\n\n@[simp] lemma bit1_le_bit1 : bit1 a ≤ bit1 b ↔ a ≤ b :=\n(add_le_add_iff_right 1).trans bit0_le_bit0\n\n@[simp] lemma bit1_lt_bit1 : bit1 a < bit1 b ↔ a < b :=\n(add_lt_add_iff_right 1).trans bit0_lt_bit0\n\n@[simp] lemma one_le_bit1 : (1 : α) ≤ bit1 a ↔ 0 ≤ a :=\nby rw [bit1, le_add_iff_nonneg_left, bit0, ← two_mul, zero_le_mul_left (zero_lt_two : 0 < (2:α))]\n\n@[simp] lemma one_lt_bit1 : (1 : α) < bit1 a ↔ 0 < a :=\nby rw [bit1, lt_add_iff_pos_left, bit0, ← two_mul, zero_lt_mul_left (zero_lt_two : 0 < (2:α))]\n\n@[simp] lemma zero_le_bit0 : (0 : α) ≤ bit0 a ↔ 0 ≤ a :=\nby rw [bit0, ← two_mul, zero_le_mul_left (zero_lt_two : 0 < (2:α))]\n\n@[simp] lemma zero_lt_bit0 : (0 : α) < bit0 a ↔ 0 < a :=\nby rw [bit0, ← two_mul, zero_lt_mul_left (zero_lt_two : 0 < (2:α))]\n\nend\n\ntheorem mul_nonneg_iff_right_nonneg_of_pos (ha : 0 < a) : 0 ≤ a * b ↔ 0 ≤ b :=\n⟨λ h, nonneg_of_mul_nonneg_right h ha, mul_nonneg ha.le⟩\n\ntheorem mul_nonneg_iff_left_nonneg_of_pos (hb : 0 < b) : 0 ≤ a * b ↔ 0 ≤ a :=\n⟨λ h, nonneg_of_mul_nonneg_left h hb, λ h, mul_nonneg h hb.le⟩\n\nlemma nonpos_of_mul_nonneg_left (h : 0 ≤ a * b) (hb : b < 0) : a ≤ 0 :=\nle_of_not_gt (λ ha, absurd h (mul_neg_of_pos_of_neg ha hb).not_le)\n\nlemma nonpos_of_mul_nonneg_right (h : 0 ≤ a * b) (ha : a < 0) : b ≤ 0 :=\nle_of_not_gt (λ hb, absurd h (mul_neg_of_neg_of_pos ha hb).not_le)\n\n@[simp] lemma units.inv_pos {u : αˣ} : (0 : α) < ↑u⁻¹ ↔ (0 : α) < u :=\nhave ∀ {u : αˣ}, (0 : α) < u → (0 : α) < ↑u⁻¹ := λ u h,\n  (zero_lt_mul_left h).mp $ u.mul_inv.symm ▸ zero_lt_one,\n⟨this, this⟩\n\n@[simp] lemma units.inv_neg {u : αˣ} : ↑u⁻¹ < (0 : α) ↔ ↑u < (0 : α) :=\nhave ∀ {u : αˣ}, ↑u < (0 : α) → ↑u⁻¹ < (0 : α) := λ u h,\n  neg_of_mul_pos_right (by exact (u.mul_inv.symm ▸ zero_lt_one)) h.le,\n⟨this, this⟩\n\nlemma cmp_mul_pos_left (ha : 0 < a) (b c : α) : cmp (a * b) (a * c) = cmp b c :=\n(strict_mono_mul_left_of_pos ha).cmp_map_eq b c\n\nlemma cmp_mul_pos_right (ha : 0 < a) (b c : α) : cmp (b * a) (c * a) = cmp b c :=\n(strict_mono_mul_right_of_pos ha).cmp_map_eq b c\n\nlemma mul_max_of_nonneg (b c : α) (ha : 0 ≤ a) : a * max b c = max (a * b) (a * c) :=\n(monotone_mul_left_of_nonneg ha).map_max\n\nlemma mul_min_of_nonneg (b c : α) (ha : 0 ≤ a) : a * min b c = min (a * b) (a * c) :=\n(monotone_mul_left_of_nonneg ha).map_min\n\nlemma max_mul_of_nonneg (a b : α) (hc : 0 ≤ c) : max a b * c = max (a * c) (b * c) :=\n(monotone_mul_right_of_nonneg hc).map_max\n\nlemma min_mul_of_nonneg (a b : α) (hc : 0 ≤ c) : min a b * c = min (a * c) (b * c) :=\n(monotone_mul_right_of_nonneg hc).map_min\n\nlemma le_of_mul_le_of_one_le {a b c : α} (h : a * c ≤ b) (hb : 0 ≤ b) (hc : 1 ≤ c) : a ≤ b :=\nle_of_mul_le_mul_right (h.trans $ le_mul_of_one_le_right hb hc) $ zero_lt_one.trans_le hc\n\nlemma nonneg_le_nonneg_of_sq_le_sq {a b : α} (hb : 0 ≤ b) (h : a * a ≤ b * b) : a ≤ b :=\nle_of_not_gt $ λ hab, (mul_self_lt_mul_self hb hab).not_le h\n\nlemma mul_self_le_mul_self_iff {a b : α} (h1 : 0 ≤ a) (h2 : 0 ≤ b) : a ≤ b ↔ a * a ≤ b * b :=\n⟨mul_self_le_mul_self h1, nonneg_le_nonneg_of_sq_le_sq h2⟩\n\nlemma mul_self_lt_mul_self_iff {a b : α} (h1 : 0 ≤ a) (h2 : 0 ≤ b) : a < b ↔ a * a < b * b :=\n((@strict_mono_on_mul_self α _).lt_iff_lt h1 h2).symm\n\nlemma mul_self_inj {a b : α} (h1 : 0 ≤ a) (h2 : 0 ≤ b) : a * a = b * b ↔ a = b :=\n(@strict_mono_on_mul_self α _).eq_iff_eq h1 h2\n\nend linear_ordered_semiring\n\n@[priority 100] -- See note [lower instance priority]\ninstance linear_ordered_comm_semiring.to_linear_ordered_cancel_add_comm_monoid\n  [linear_ordered_comm_semiring α] : linear_ordered_cancel_add_comm_monoid α :=\n{ ..‹linear_ordered_comm_semiring α› }\n\nsection linear_ordered_ring\nvariables [linear_ordered_ring α] {a b c : α}\n\nlocal attribute [instance] linear_ordered_ring.decidable_le linear_ordered_ring.decidable_lt\n\n@[priority 100] -- see Note [lower instance priority]\ninstance linear_ordered_ring.to_linear_ordered_semiring : linear_ordered_semiring α :=\n{ ..‹linear_ordered_ring α›, ..strict_ordered_ring.to_strict_ordered_semiring }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance linear_ordered_ring.to_linear_ordered_add_comm_group : linear_ordered_add_comm_group α :=\n{ ..‹linear_ordered_ring α› }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance linear_ordered_ring.no_zero_divisors : no_zero_divisors α :=\n{ eq_zero_or_eq_zero_of_mul_eq_zero :=\n    begin\n      intros a b hab,\n      refine decidable.or_iff_not_and_not.2 (λ h, _), revert hab,\n      cases lt_or_gt_of_ne h.1 with ha ha; cases lt_or_gt_of_ne h.2 with hb hb,\n      exacts [(mul_pos_of_neg_of_neg ha hb).ne.symm, (mul_neg_of_neg_of_pos ha hb).ne,\n        (mul_neg_of_pos_of_neg ha hb).ne, (mul_pos ha hb).ne.symm]\n    end,\n  .. ‹linear_ordered_ring α› }\n\n@[priority 100] -- see Note [lower instance priority]\n--We don't want to import `algebra.ring.basic`, so we cannot use `no_zero_divisors.to_is_domain`.\ninstance linear_ordered_ring.is_domain : is_domain α :=\n{ mul_left_cancel_of_ne_zero := λ a b c ha h,\n  begin\n    rw [← sub_eq_zero, ← mul_sub] at h,\n    exact sub_eq_zero.1 ((eq_zero_or_eq_zero_of_mul_eq_zero h).resolve_left ha)\n  end,\n  mul_right_cancel_of_ne_zero := λ a b c hb h,\n  begin\n    rw [← sub_eq_zero, ← sub_mul] at h,\n    exact sub_eq_zero.1 ((eq_zero_or_eq_zero_of_mul_eq_zero h).resolve_right hb)\n  end,\n  .. (infer_instance : nontrivial α) }\n\nlemma mul_pos_iff : 0 < a * b ↔ 0 < a ∧ 0 < b ∨ a < 0 ∧ b < 0 :=\n⟨pos_and_pos_or_neg_and_neg_of_mul_pos,\n  λ h, h.elim (and_imp.2 mul_pos) (and_imp.2 mul_pos_of_neg_of_neg)⟩\n\nlemma mul_neg_iff : a * b < 0 ↔ 0 < a ∧ b < 0 ∨ a < 0 ∧ 0 < b :=\nby rw [← neg_pos, neg_mul_eq_mul_neg, mul_pos_iff, neg_pos, neg_lt_zero]\n\nlemma mul_nonneg_iff : 0 ≤ a * b ↔ 0 ≤ a ∧ 0 ≤ b ∨ a ≤ 0 ∧ b ≤ 0 :=\n⟨nonneg_and_nonneg_or_nonpos_and_nonpos_of_mul_nnonneg,\n  λ h, h.elim (and_imp.2 mul_nonneg) (and_imp.2 mul_nonneg_of_nonpos_of_nonpos)⟩\n\n/-- Out of three elements of a `linear_ordered_ring`, two must have the same sign. -/\nlemma mul_nonneg_of_three (a b c : α) :\n  0 ≤ a * b ∨ 0 ≤ b * c ∨ 0 ≤ c * a :=\nby iterate 3 { rw mul_nonneg_iff };\n  have := le_total 0 a; have := le_total 0 b; have := le_total 0 c; itauto\n\nlemma mul_nonpos_iff : a * b ≤ 0 ↔ 0 ≤ a ∧ b ≤ 0 ∨ a ≤ 0 ∧ 0 ≤ b :=\nby rw [← neg_nonneg, neg_mul_eq_mul_neg, mul_nonneg_iff, neg_nonneg, neg_nonpos]\n\nlemma mul_self_nonneg (a : α) : 0 ≤ a * a :=\n(le_total 0 a).elim (λ h, mul_nonneg h h) (λ h, mul_nonneg_of_nonpos_of_nonpos h h)\n\n@[simp] lemma neg_le_self_iff : -a ≤ a ↔ 0 ≤ a :=\nby simp [neg_le_iff_add_nonneg, ← two_mul, mul_nonneg_iff, zero_le_one, (zero_lt_two' α).not_le]\n\n@[simp] lemma neg_lt_self_iff : -a < a ↔ 0 < a :=\nby simp [neg_lt_iff_pos_add, ← two_mul, mul_pos_iff, zero_lt_one, (zero_lt_two' α).not_lt]\n\n@[simp] lemma le_neg_self_iff : a ≤ -a ↔ a ≤ 0 :=\ncalc a ≤ -a ↔ -(-a) ≤ -a : by rw neg_neg\n... ↔ 0 ≤ -a : neg_le_self_iff\n... ↔ a ≤ 0 : neg_nonneg\n\n@[simp] lemma lt_neg_self_iff : a < -a ↔ a < 0 :=\ncalc a < -a ↔ -(-a) < -a : by rw neg_neg\n... ↔ 0 < -a : neg_lt_self_iff\n... ↔ a < 0 : neg_pos\n\nlemma neg_one_lt_zero : -1 < (0:α) := neg_lt_zero.2 zero_lt_one\n\n@[simp] lemma mul_le_mul_left_of_neg {a b c : α} (h : c < 0) : c * a ≤ c * b ↔ b ≤ a :=\n(strict_anti_mul_left h).le_iff_le\n\n@[simp] lemma mul_le_mul_right_of_neg {a b c : α} (h : c < 0) : a * c ≤ b * c ↔ b ≤ a :=\n(strict_anti_mul_right h).le_iff_le\n\n@[simp] lemma mul_lt_mul_left_of_neg {a b c : α} (h : c < 0) : c * a < c * b ↔ b < a :=\n(strict_anti_mul_left h).lt_iff_lt\n\n@[simp] lemma mul_lt_mul_right_of_neg {a b c : α} (h : c < 0) : a * c < b * c ↔ b < a :=\n(strict_anti_mul_right h).lt_iff_lt\n\nlemma lt_of_mul_lt_mul_of_nonpos_left (h : c * a < c * b) (hc : c ≤ 0) : b < a :=\nlt_of_mul_lt_mul_left (by rwa [neg_mul, neg_mul, neg_lt_neg_iff]) $ neg_nonneg.2 hc\n\nlemma lt_of_mul_lt_mul_of_nonpos_right (h : a * c < b * c) (hc : c ≤ 0) : b < a :=\nlt_of_mul_lt_mul_right (by rwa [mul_neg, mul_neg, neg_lt_neg_iff]) $ neg_nonneg.2 hc\n\nlemma cmp_mul_neg_left {a : α} (ha : a < 0) (b c : α) : cmp (a * b) (a * c) = cmp c b :=\n(strict_anti_mul_left ha).cmp_map_eq b c\n\nlemma cmp_mul_neg_right {a : α} (ha : a < 0) (b c : α) : cmp (b * a) (c * a) = cmp c b :=\n(strict_anti_mul_right ha).cmp_map_eq b c\n\nlemma sub_one_lt (a : α) : a - 1 < a :=\nsub_lt_iff_lt_add.2 (lt_add_one a)\n\n@[simp] lemma mul_self_pos {a : α} : 0 < a * a ↔ a ≠ 0 :=\nbegin\n  split,\n  { rintro h rfl, rw mul_zero at h, exact h.false },\n  { intro h,\n    cases h.lt_or_lt with h h,\n    exacts [mul_pos_of_neg_of_neg h h, mul_pos h h] }\nend\n\nlemma mul_self_le_mul_self_of_le_of_neg_le {x y : α} (h₁ : x ≤ y) (h₂ : -x ≤ y) : x * x ≤ y * y :=\n(le_total 0 x).elim (λ h, mul_le_mul h₁ h₁ h (h.trans h₁))\n  (λ h, le_of_eq_of_le (neg_mul_neg x x).symm\n    (mul_le_mul h₂ h₂ (neg_nonneg.mpr h) ((neg_nonneg.mpr h).trans h₂)))\n\nlemma nonneg_of_mul_nonpos_left {a b : α} (h : a * b ≤ 0) (hb : b < 0) : 0 ≤ a :=\nle_of_not_gt (λ ha, absurd h (mul_pos_of_neg_of_neg ha hb).not_le)\n\nlemma nonneg_of_mul_nonpos_right {a b : α} (h : a * b ≤ 0) (ha : a < 0) : 0 ≤ b :=\nle_of_not_gt (λ hb, absurd h (mul_pos_of_neg_of_neg ha hb).not_le)\n\nlemma pos_of_mul_neg_left {a b : α} (h : a * b < 0) (hb : b ≤ 0) : 0 < a :=\nlt_of_not_ge (λ ha, absurd h (mul_nonneg_of_nonpos_of_nonpos ha hb).not_lt)\n\nlemma pos_of_mul_neg_right {a b : α} (h : a * b < 0) (ha : a ≤ 0) : 0 < b :=\nlt_of_not_ge (λ hb, absurd h (mul_nonneg_of_nonpos_of_nonpos ha hb).not_lt)\n\nlemma neg_iff_pos_of_mul_neg (hab : a * b < 0) : a < 0 ↔ 0 < b :=\n⟨pos_of_mul_neg_right hab ∘ le_of_lt, neg_of_mul_neg_left hab ∘ le_of_lt⟩\n\nlemma pos_iff_neg_of_mul_neg (hab : a * b < 0) : 0 < a ↔ b < 0 :=\n⟨neg_of_mul_neg_right hab ∘ le_of_lt, pos_of_mul_neg_left hab ∘ le_of_lt⟩\n\n/-- The sum of two squares is zero iff both elements are zero. -/\nlemma mul_self_add_mul_self_eq_zero {x y : α} : x * x + y * y = 0 ↔ x = 0 ∧ y = 0 :=\nby rw [add_eq_zero_iff', mul_self_eq_zero, mul_self_eq_zero]; apply mul_self_nonneg\n\nlemma eq_zero_of_mul_self_add_mul_self_eq_zero (h : a * a + b * b = 0) : a = 0 :=\n(mul_self_add_mul_self_eq_zero.mp h).left\n\nend linear_ordered_ring\n\n@[priority 100] -- see Note [lower instance priority]\ninstance linear_ordered_comm_ring.to_strict_ordered_comm_ring [d : linear_ordered_comm_ring α] :\n  strict_ordered_comm_ring α :=\n{ ..d }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance linear_ordered_comm_ring.to_linear_ordered_comm_semiring [d : linear_ordered_comm_ring α] :\n   linear_ordered_comm_semiring α :=\n{ .. d, ..linear_ordered_ring.to_linear_ordered_semiring }\n\nsection linear_ordered_comm_ring\n\nvariables [linear_ordered_comm_ring α] {a b c d : α}\n\nlemma max_mul_mul_le_max_mul_max (b c : α) (ha : 0 ≤ a) (hd: 0 ≤ d) :\n  max (a * b) (d * c) ≤ max a c * max d b :=\nhave ba : b * a ≤ max d b * max c a, from\n  mul_le_mul (le_max_right d b) (le_max_right c a) ha (le_trans hd (le_max_left d b)),\nhave cd : c * d ≤ max a c * max b d, from\n  mul_le_mul (le_max_right a c) (le_max_right b d) hd (le_trans ha (le_max_left a c)),\nmax_le\n  (by simpa [mul_comm, max_comm] using ba)\n  (by simpa [mul_comm, max_comm] using cd)\n\nend linear_ordered_comm_ring\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/order/ring/defs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.46956966329618965}}
{"text": "def g (x : Nat) : List (Nat × List Nat) :=\n[(x, [x, x]), (x, [])]\n\ndef h (x : Nat) : List Nat :=\nlet xs := g x |>.filter (fun ⟨_, xs⟩ => xs.isEmpty)\nxs.map (·.1)\n\ntheorem ex1 : g 10 = [(10, [10, 10]), (10, [])] :=\nrfl\n\ntheorem ex2 : h 10 = [10] :=\nrfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/matchDiscrType.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.46943613051416405}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport algebraic_geometry.ringed_space\nimport algebraic_geometry.stalks\nimport data.equiv.transfer_instance\n\n/-!\n# The category of locally ringed spaces\n\nWe define (bundled) locally ringed spaces (as `SheafedSpace CommRing` along with the fact that the\nstalks are local rings), and morphisms between these (morphisms in `SheafedSpace` with\n`is_local_ring_hom` on the stalk maps).\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.category category_theory.functor\n\nnamespace algebraic_geometry\n\n/-- A `LocallyRingedSpace` is a topological space equipped with a sheaf of commutative rings\nsuch that all the stalks are local rings.\n\nA morphism of locally ringed spaces is a morphism of ringed spaces\nsuch that the morphisms induced on stalks are local ring homomorphisms. -/\n@[nolint has_inhabited_instance]\nstructure LocallyRingedSpace extends SheafedSpace CommRing :=\n(local_ring : ∀ x, local_ring (presheaf.stalk x))\n\nattribute [instance] LocallyRingedSpace.local_ring\n\nnamespace LocallyRingedSpace\n\nvariables (X : LocallyRingedSpace)\n\n/--\nAn alias for `to_SheafedSpace`, where the result type is a `RingedSpace`.\nThis allows us to use dot-notation for the `RingedSpace` namespace.\n -/\ndef to_RingedSpace : RingedSpace := X.to_SheafedSpace\n\n/-- The underlying topological space of a locally ringed space. -/\ndef to_Top : Top := X.1.carrier\n\ninstance : has_coe_to_sort LocallyRingedSpace (Type u) :=\n⟨λ X : LocallyRingedSpace, (X.to_Top : Type u)⟩\n\ninstance (x : X) : _root_.local_ring (X.to_PresheafedSpace.stalk x) := X.local_ring x\n\n-- PROJECT: how about a typeclass \"has_structure_sheaf\" to mediate the 𝒪 notation, rather\n-- than defining it over and over for PresheafedSpace, LRS, Scheme, etc.\n\n/-- The structure sheaf of a locally ringed space. -/\ndef 𝒪 : sheaf CommRing X.to_Top := X.to_SheafedSpace.sheaf\n\n/-- A morphism of locally ringed spaces is a morphism of ringed spaces\n such that the morphims induced on stalks are local ring homomorphisms. -/\ndef hom (X Y : LocallyRingedSpace) : Type* :=\n{ f : X.to_SheafedSpace ⟶ Y.to_SheafedSpace //\n    ∀ x, is_local_ring_hom (PresheafedSpace.stalk_map f x) }\n\ninstance : quiver LocallyRingedSpace := ⟨hom⟩\n\n@[ext] lemma hom_ext {X Y : LocallyRingedSpace} (f g : hom X Y) (w : f.1 = g.1) : f = g :=\nsubtype.eq w\n\n/--\nThe stalk of a locally ringed space, just as a `CommRing`.\n-/\n-- TODO perhaps we should make a bundled `LocalRing` and return one here?\n-- TODO define `sheaf.stalk` so we can write `X.𝒪.stalk` here?\nnoncomputable\ndef stalk (X : LocallyRingedSpace) (x : X) : CommRing := X.presheaf.stalk x\n\n/--\nA morphism of locally ringed spaces `f : X ⟶ Y` induces\na local ring homomorphism from `Y.stalk (f x)` to `X.stalk x` for any `x : X`.\n-/\nnoncomputable\ndef stalk_map {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n  Y.stalk (f.1.1 x) ⟶ X.stalk x :=\nPresheafedSpace.stalk_map f.1 x\n\ninstance {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n  is_local_ring_hom (stalk_map f x) := f.2 x\n\ninstance {X Y : LocallyRingedSpace} (f : X ⟶ Y) (x : X) :\n   is_local_ring_hom (PresheafedSpace.stalk_map f.1 x) := f.2 x\n\n/-- The identity morphism on a locally ringed space. -/\n@[simps]\ndef id (X : LocallyRingedSpace) : hom X X :=\n⟨𝟙 _, λ x, by { erw PresheafedSpace.stalk_map.id, apply is_local_ring_hom_id, }⟩\n\ninstance (X : LocallyRingedSpace) : inhabited (hom X X) := ⟨id X⟩\n\n/-- Composition of morphisms of locally ringed spaces. -/\n@[simps]\ndef comp {X Y Z : LocallyRingedSpace} (f : hom X Y) (g : hom Y Z) : hom X Z :=\n⟨f.val ≫ g.val, λ x,\nbegin\n  erw PresheafedSpace.stalk_map.comp,\n  exact @is_local_ring_hom_comp _ _ _ _ _ _ _ _ (f.2 _) (g.2 _),\nend⟩\n\n/-- The category of locally ringed spaces. -/\ninstance : category LocallyRingedSpace :=\n{ hom := hom,\n  id := id,\n  comp := λ X Y Z f g, comp f g,\n  comp_id' := by { intros, ext1, simp, },\n  id_comp' := by { intros, ext1, simp, },\n  assoc' := by { intros, ext1, simp, }, }.\n\n/-- The forgetful functor from `LocallyRingedSpace` to `SheafedSpace CommRing`. -/\n@[simps] def forget_to_SheafedSpace : LocallyRingedSpace ⥤ SheafedSpace CommRing :=\n{ obj := λ X, X.to_SheafedSpace,\n  map := λ X Y f, f.1, }\n\ninstance : faithful forget_to_SheafedSpace := {}\n\n/-- The forgetful functor from `LocallyRingedSpace` to `Top`. -/\n@[simps]\ndef forget_to_Top : LocallyRingedSpace ⥤ Top :=\nforget_to_SheafedSpace ⋙ SheafedSpace.forget _\n\n@[simp] lemma comp_val {X Y Z : LocallyRingedSpace} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).val = f.val ≫ g.val := rfl\n\n@[simp] lemma comp_val_c {X Y Z : LocallyRingedSpace} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).val.c = g.val.c ≫ (presheaf.pushforward _ g.val.base).map f.val.c := rfl\n\nlemma comp_val_c_app {X Y Z : LocallyRingedSpace} (f : X ⟶ Y) (g : Y ⟶ Z) (U : (opens Z)ᵒᵖ) :\n  (f ≫ g).val.c.app U = g.val.c.app U ≫ f.val.c.app (op $ (opens.map g.val.base).obj U.unop) :=\nrfl\n\n/--\nGiven two locally ringed spaces `X` and `Y`, an isomorphism between `X` and `Y` as _sheafed_\nspaces can be lifted to a morphism `X ⟶ Y` as locally ringed spaces.\n\nSee also `iso_of_SheafedSpace_iso`.\n-/\n@[simps]\ndef hom_of_SheafedSpace_hom_of_is_iso {X Y : LocallyRingedSpace}\n  (f : X.to_SheafedSpace ⟶ Y.to_SheafedSpace) [is_iso f] : X ⟶ Y :=\nsubtype.mk f $ λ x,\n-- Here we need to see that the stalk maps are really local ring homomorphisms.\n-- This can be solved by type class inference, because stalk maps of isomorphisms are isomorphisms\n-- and isomorphisms are local ring homomorphisms.\nshow is_local_ring_hom (PresheafedSpace.stalk_map\n  (SheafedSpace.forget_to_PresheafedSpace.map f) x),\nby apply_instance\n\n/--\nGiven two locally ringed spaces `X` and `Y`, an isomorphism between `X` and `Y` as _sheafed_\nspaces can be lifted to an isomorphism `X ⟶ Y` as locally ringed spaces.\n\nThis is related to the property that the functor `forget_to_SheafedSpace` reflects isomorphisms.\nIn fact, it is slightly stronger as we do not require `f` to come from a morphism between\n_locally_ ringed spaces.\n-/\ndef iso_of_SheafedSpace_iso {X Y : LocallyRingedSpace}\n  (f : X.to_SheafedSpace ≅ Y.to_SheafedSpace) : X ≅ Y :=\n{ hom := hom_of_SheafedSpace_hom_of_is_iso f.hom,\n  inv := hom_of_SheafedSpace_hom_of_is_iso f.inv,\n  hom_inv_id' := hom_ext _ _ f.hom_inv_id,\n  inv_hom_id' := hom_ext _ _ f.inv_hom_id }\n\ninstance : reflects_isomorphisms forget_to_SheafedSpace :=\n{ reflects := λ X Y f i,\n  { out := by exactI\n    ⟨hom_of_SheafedSpace_hom_of_is_iso (category_theory.inv (forget_to_SheafedSpace.map f)),\n      hom_ext _ _ (is_iso.hom_inv_id _), hom_ext _ _ (is_iso.inv_hom_id _)⟩ } }\n\ninstance is_SheafedSpace_iso {X Y : LocallyRingedSpace} (f : X ⟶ Y) [is_iso f] :\n  is_iso f.1 :=\nLocallyRingedSpace.forget_to_SheafedSpace.map_is_iso f\n\n/--\nThe restriction of a locally ringed space along an open embedding.\n-/\n@[simps]\ndef restrict {U : Top} (X : LocallyRingedSpace) {f : U ⟶ X.to_Top}\n  (h : open_embedding f) : LocallyRingedSpace :=\n{ local_ring :=\n  begin\n    intro x,\n    dsimp at *,\n    -- We show that the stalk of the restriction is isomorphic to the original stalk,\n    apply @ring_equiv.local_ring _ _ _ (X.local_ring (f x)),\n    exact (X.to_PresheafedSpace.restrict_stalk_iso h x).symm.CommRing_iso_to_ring_equiv,\n  end,\n  to_SheafedSpace := X.to_SheafedSpace.restrict h }\n\n/-- The canonical map from the restriction to the supspace. -/\ndef of_restrict {U : Top} (X : LocallyRingedSpace) {f : U ⟶ X.to_Top}\n  (h : open_embedding f) : X.restrict h ⟶ X :=\n⟨X.to_PresheafedSpace.of_restrict h, λ x, infer_instance⟩\n\n/--\nThe restriction of a locally ringed space `X` to the top subspace is isomorphic to `X` itself.\n-/\ndef restrict_top_iso (X : LocallyRingedSpace) :\n  X.restrict (opens.open_embedding ⊤) ≅ X :=\n@iso_of_SheafedSpace_iso (X.restrict (opens.open_embedding ⊤)) X\n  X.to_SheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : LocallyRingedSpaceᵒᵖ ⥤ CommRing :=\nforget_to_SheafedSpace.op ⋙ SheafedSpace.Γ\n\nlemma Γ_def : Γ = forget_to_SheafedSpace.op ⋙ SheafedSpace.Γ := rfl\n\n@[simp] lemma Γ_obj (X : LocallyRingedSpaceᵒᵖ) : Γ.obj X = (unop X).presheaf.obj (op ⊤) := rfl\n\nlemma Γ_obj_op (X : LocallyRingedSpace) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\n@[simp] lemma Γ_map {X Y : LocallyRingedSpaceᵒᵖ} (f : X ⟶ Y) :\n  Γ.map f = f.unop.1.c.app (op ⊤) := rfl\n\nlemma Γ_map_op {X Y : LocallyRingedSpace} (f : X ⟶ Y) :\n  Γ.map f.op = f.1.c.app (op ⊤) := rfl\n\nlemma preimage_basic_open {X Y : LocallyRingedSpace} (f : X ⟶ Y) {U : opens Y}\n  (s : Y.presheaf.obj (op U)) :\n  (opens.map f.1.base).obj (Y.to_RingedSpace.basic_open s) =\n    @RingedSpace.basic_open X.to_RingedSpace ((opens.map f.1.base).obj U) (f.1.c.app _ s) :=\nbegin\n  ext,\n  split,\n  { rintros ⟨⟨y, hyU⟩, (hy : is_unit _), (rfl : y = _)⟩,\n    erw RingedSpace.mem_basic_open _ _ ⟨x, show x ∈ (opens.map f.1.base).obj U, from hyU⟩,\n    rw ← PresheafedSpace.stalk_map_germ_apply,\n    exact (PresheafedSpace.stalk_map f.1 _).is_unit_map hy },\n  { rintros ⟨y, (hy : is_unit _), rfl⟩,\n    erw RingedSpace.mem_basic_open _ _ ⟨f.1.base y.1, y.2⟩,\n    rw ← PresheafedSpace.stalk_map_germ_apply at hy,\n    exact (is_unit_map_iff (PresheafedSpace.stalk_map f.1 _) _).mp hy }\nend\n\n-- This actually holds for all ringed spaces with nontrivial stalks.\n@[simp] lemma basic_open_zero (X : LocallyRingedSpace) (U : opens X.carrier) :\n  X.to_RingedSpace.basic_open (0 : X.presheaf.obj $ op U) = ∅ :=\nbegin\n  ext,\n  simp only [set.mem_empty_eq, topological_space.opens.empty_eq, topological_space.opens.mem_coe,\n    opens.coe_bot, iff_false, RingedSpace.basic_open, is_unit_zero_iff, set.mem_set_of_eq,\n    map_zero],\n  rintro ⟨⟨y, _⟩, h, e⟩,\n  exact @zero_ne_one (X.presheaf.stalk y) _ _ h,\nend\n\ninstance component_nontrivial (X : LocallyRingedSpace) (U : opens X.carrier)\n  [hU : nonempty U] : nontrivial (X.presheaf.obj $ op U) :=\n(X.to_PresheafedSpace.presheaf.germ hU.some).domain_nontrivial\n\nend LocallyRingedSpace\n\nend algebraic_geometry\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebraic_geometry/locally_ringed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4694361242828862}}
{"text": "import .lawvere\n\nnamespace lob\n    open function\n\n    open util lawvere\n\n    -- diagonal lemma:\n    def S0: Type := Prop\n\n    def S1: Type := S0 → S0\n\n    def up (ψ: S0): S1 :=\n        const S0 ψ\n\n    theorem diag {f: S1 → S1 → S0} (sur_f: surjective f):\n        ∀ φ: S1,\n        ∃ ψ: S0,\n        ψ = f φ (up ψ) :=\n            assume φ: S1,\n            let h: S0 → S0 := f φ ∘ up in\n            simple_lawvere.{0 0} sur_f h\n\n\n    -- lob axioms:\n    constant Bew: S0 → S0\n\n    constant godnum: S1 → S0\n\n    def box: S0 → S0 := Bew ∘ godnum ∘ up\n\n    def proves: S0 → Prop := box\n\n    namespace hilbert_bernay\n        axiom a:\n            ∀ {φ: S0},\n            proves φ → proves (box φ)\n\n        axiom b:\n            ∀ {φ: S0},\n            proves (box φ → box (box φ))\n\n        axiom c:\n            ∀ {φ ψ: S0},\n            proves (box (φ → ψ) → box φ → box ψ)\n    end hilbert_bernay\n\n    def f (φ: S1) (ψ: S1): S0 :=\n        φ (godnum ψ)\n\n    @[instance] axiom f.sur: surjective f\n\n    axiom proves.mp:\n        ∀ {φ ψ: S0},\n        proves (φ → ψ) → proves φ → proves ψ\n\n    axiom proves.implies_trans:\n        ∀ {a b c: S0},\n        proves (a → b) → proves (b → c) → proves (a → c)\n\n    axiom proves.implies_middleman_elim:\n        ∀ {a b c: S0},\n        proves (a → b → c) → proves (a → b) → proves (a → c)\n\n    axiom proves.diag:\n        ∀ φ: S1,\n        ∃ ψ: S0,\n        proves (ψ ↔ f φ (up ψ))\n\n    axiom proves.iff_mp:\n        ∀ {a b: S0},\n        proves (a ↔ b) → proves (a → b)\n\n    axiom proves.iff_mpr:\n        ∀ {a b: S0},\n        proves (a ↔ b) → proves (b → a)\n\n\n    -- lob's theorem:\n    def h (ψ: S0) (x: S0): S0 :=\n        Bew x → ψ\n\n    @[simp] theorem f_of_h:\n        ∀ {ψ φ: S0},\n        f (h ψ) (up φ) = (box φ → ψ) :=\n            assume ψ φ: S0,\n            rfl\n\n    theorem lob {ψ: S0} (h0: proves (box ψ → ψ)): proves ψ :=\n        exists.elim (proves.diag (h ψ)) (\n            assume φ: S0,\n            assume heq: proves (φ ↔ f (h ψ) (up φ)),\n            have h1: proves (φ ↔ (box φ → ψ)),\n                by {simp at heq, exact heq},\n            have h1_forward: proves (φ → (box φ → ψ)),\n                from h1.iff_mp,\n            have h1_reverse: proves ((box φ → ψ) → φ),\n                from h1.iff_mpr,\n            have h2: proves (box (φ → (box φ → ψ))),\n                from hilbert_bernay.a h1_forward,\n            have h3: proves (box φ → box (box φ → ψ)),\n                from hilbert_bernay.c.mp h2,\n            have h4: proves (box φ → box (box φ) → box ψ),\n                from h3.implies_trans hilbert_bernay.c,\n            have h5: proves (box φ → box (box φ)),\n                from hilbert_bernay.b,\n            have h6: proves (box φ → box ψ),\n                from h4.implies_middleman_elim h5,\n            have h7: proves (box φ → ψ),\n                from h6.implies_trans h0,\n            have h8: proves φ,\n                from h1_reverse.mp h7,\n            have h9: proves (box φ),\n                from hilbert_bernay.a h8,\n            show proves ψ,\n                from h7.mp h9\n        )\n\n\n    -- godel's second incompleteness theorem:\n    theorem godel: proves (¬box false) → proves false := lob\nend lob\n", "meta": {"author": "evhub", "repo": "lean-math-examples", "sha": "dec44bf581a1e9d5bf0b5261803a43fe8fd350e1", "save_path": "github-repos/lean/evhub-lean-math-examples", "path": "github-repos/lean/evhub-lean-math-examples/lean-math-examples-dec44bf581a1e9d5bf0b5261803a43fe8fd350e1/lob.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4694271085622208}}
{"text": "\nuniverse variables u v w u' v' w'\n\nclass functor_pair (f : Type u → Type v) (g : Type u' → Type v') :=\n (f_functor : functor f)\n (g_functor : functor g)\n (map : ∀ {α β}, (α → β) → f α → g β)\n (map_fmap_comm : ∀ {α β β' γ}\n            (h : β → γ)    (hp : α → β)\n            (hp' : β' → γ) (h' : α → β')\n            (x : f α),\n    h ∘ hp = hp' ∘ h' →\n    functor.map h (map hp x) = map hp' (functor.map h' x))\n\nsection thms\n\nvariables {F : Type u → Type v}\nvariables {α β γ : Type u}\nvariables [functor F] [is_lawful_functor F]\n\nlemma functor.id_map' : functor.map id = (id : F α → F α) :=\nby { apply funext, apply is_lawful_functor.id_map }\n\nlemma functor.comp_map' (f : α → β) (g : β → γ)\n: functor.map (g ∘ f) = (functor.map g ∘ functor.map f : F α → F γ) :=\nby { apply funext, intro, apply is_lawful_functor.comp_map }\n\n@[norm]\nlemma functor.map_map (f : α → β) (g : β → γ) (x : F α) :\n  g <$> f <$> x = (g ∘ f) <$> x :=\nby rw ← comp_map\n\nend thms\n\n/- identity functor -/\n\nstructure identity (α : Type u) : Type u :=\n  (run_identity : α)\n\nnamespace identity\n\nopen function\n\nvariables {α : Type u} {β : Type v} {γ : Type u'}\n\ndef map (f : α → β) : identity α → identity β\n  | ⟨ x ⟩ := ⟨ f x ⟩\n\nlocal infixr <$> := map\n\nlemma id_map : ∀ (x : identity α), map id x = x\n | ⟨ x ⟩ := rfl\n\nlemma comp_map (f : α → β) (g : β → γ)\n: ∀ (x : identity α), map (g ∘ f) x = g <$> f <$> x\n | ⟨ x ⟩ := rfl\n\nend identity\n\ninstance identity_functor : functor identity :=\n{ map := @identity.map }\ninstance identity_lawful_functor : is_lawful_functor identity :=\n{ id_map := @identity.id_map\n, comp_map := @identity.comp_map }\n\ninstance : functor_pair identity identity :=\n{ f_functor := identity_functor\n, g_functor := identity_functor\n, map := @identity.map\n, map_fmap_comm :=\n  begin\n    intros α β β' γ,\n    intros h hp hp' h' x,\n    intros H,\n    rw [← identity.comp_map,← identity.comp_map,H],\n  end }\n\nlemma identity.fmap_mk {α β : Type v}  (f : α → β) (x : α)\n: f <$> identity.mk x = identity.mk (f x) := rfl\n\n/- compose functor instance -/\n\nstructure compose (f : Type u → Type u') (g : Type v → Type u) (α : Type v) : Type u' :=\n  (run : f $ g α)\n\nnamespace compose\n\nsection functor\n\nvariables {f : Type u → Type u'} {g : Type v → Type u}\n\nvariables [functor f] [functor g]\nvariables {α β γ : Type v}\n\ndef map (h : α → β) : compose f g α → compose f g β\n  | ⟨ x ⟩ := ⟨ functor.map h <$> x ⟩\n\nlocal infix ` <$> ` := map\n\nvariables [is_lawful_functor f] [is_lawful_functor g]\nvariables {α β γ}\n\nlemma id_map : ∀ (x : compose f g α), map id x = x\n  | ⟨ x ⟩ :=\nby simp! [functor.id_map']\n\nlemma comp_map (g_1 : α → β) (h : β → γ) : ∀ (x : compose f g α),\n           map (h ∘ g_1) x = map h (map g_1 x)\n  | ⟨ x ⟩ :=\nby simp [map,functor.comp_map' g_1 h,is_lawful_functor.comp_map (functor.map g_1)]\n          { single_pass := tt }\n\nend functor\nsection functor_pair\n\nvariables {f  : Type v  → Type w}  {g :  Type u  → Type v}\nvariables {f' : Type v' → Type w'} {g' : Type u' → Type v'}\n\nvariables [functor_pair f f'] [functor_pair g g']\nvariables {α : Type u} {β : Type u'}\n\ndef map_pair (h : α → β) : compose f g α → compose f' g' β\n  | ⟨ x ⟩ := ⟨ functor_pair.map f' (functor_pair.map g' h) x ⟩\n\nend functor_pair\nend compose\n\ninstance functor_compose {f : Type u → Type u'} {g : Type v → Type u}\n  [functor f] [functor g]\n: functor (compose f g) :=\n{ map := @compose.map f g _ _ }\n\ninstance lawful_functor_compose {f : Type u → Type u'} {g : Type v → Type u}\n  [functor f] [functor g]\n  [is_lawful_functor f] [is_lawful_functor g]\n: is_lawful_functor (compose f g) :=\n{ id_map := λ _, @compose.id_map f g _ _ _ _ _\n, comp_map := λ _ _ _, @compose.comp_map f g _ _ _ _ _ _ _ }\n\ninstance compose_functor_pair\n  {f :  Type v  → Type w}  {g  : Type u  → Type v}\n  {f' : Type v' → Type w'} {g' : Type u' → Type v'}\n  [functor_pair f f'] [functor_pair g g']\n: functor_pair (compose f g) (compose f' g') :=\n{ f_functor := @functor_compose f g\n       (functor_pair.f_functor f f')\n       (functor_pair.f_functor g g')\n, g_functor := @functor_compose f' g'\n       (functor_pair.g_functor f f')\n       (functor_pair.g_functor g g')\n, map := @compose.map_pair f g _ _ _ _\n, map_fmap_comm :=\n  begin\n    intros α β β' γ,\n    intros h hp hp' h' x H,\n    unfold functor.map,\n    cases x with x,\n    unfold compose.map_pair compose.map,\n    apply congr_arg,\n    rw [functor_pair.map_fmap_comm],\n    apply funext, intro i, unfold function.comp functor.map,\n    rw [functor_pair.map_fmap_comm],\n    apply H,\n  end }\n\n@[norm]\nlemma compose.fmap_mk {α β : Type u'}\n  {f : Type u → Type v} {g : Type u' → Type u}\n  [functor f] [functor g]\n  (h : α → β) (x : f (g α))\n: h <$> compose.mk x = compose.mk (functor.map h <$> x) := rfl\n", "meta": {"author": "unitb", "repo": "lean-lib", "sha": "439b80e606b4ebe4909a08b1d77f4f5c0ee3dee9", "save_path": "github-repos/lean/unitb-lean-lib", "path": "github-repos/lean/unitb-lean-lib/lean-lib-439b80e606b4ebe4909a08b1d77f4f5c0ee3dee9/src/util/data/functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.4693159827502573}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport data.rat\nimport formal_ml.int\n\nlemma rat.nonpos_of_num_nonpos {q:ℚ}:q.num ≤ 0 → q ≤ 0  :=\nbegin\n  intro A1,\n  have A3:(0:ℤ) < (((0:rat).denom):ℤ),\n  {\n    simp,\n    apply (0:rat).pos,     \n  },\n  rw ← @rat.num_denom q,\n  rw ← @rat.num_denom 0,\n  rw rat.le_def,\n  simp,\n  have A4:(0:ℤ) < (((q:rat).denom):ℤ),\n  {\n    simp,\n    apply (q:rat).pos,     \n  },\n  apply mul_nonpos_of_nonpos_of_nonneg,\n  apply A1,\n  apply le_of_lt,\n  apply A3,\n  {\n    simp,\n    apply q.pos,\n  },\n  apply A3,    \nend\n\n\nlemma rat.num_nonneg_of_nonneg {q:ℚ}:q≤ 0 → q.num ≤ 0 :=\nbegin\n  intro A1,\n  have A3:(0:ℤ) < (((0:rat).denom):ℤ),\n  {\n    simp,\n    apply (0:rat).pos,     \n  },\n  have A4:(0:ℤ) < (((q:rat).denom):ℤ),\n  {\n    simp,\n    apply (q:rat).pos,     \n  },  \n  rw ← @rat.num_denom q at A1,\n  rw ← @rat.num_denom 0 at A1,\n  rw rat.le_def at A1,\n  simp at A1,\n  apply nonpos_of_mul_nonpos_right A1 A3,\n  apply A4,\n  apply A3,\nend\n\n\nlemma rat.nonpos_iff_num_nonpos {q:ℚ}:q.num ≤ 0 ↔ q ≤ 0  :=\nbegin\n  have A3:(0:ℤ) < (((0:rat).denom):ℤ),\n  {\n    simp,\n    apply (0:rat).pos,     \n  },\n  have A4:(0:ℤ) < (((q:rat).denom):ℤ),\n  {\n    simp,\n    apply (q:rat).pos,     \n  },\n\n  rw ← @rat.num_denom q,\n  rw ← @rat.num_denom 0,\n  rw rat.le_def,\n  simp,\n  split;intros A1,\n  {\n    apply mul_nonpos_of_nonpos_of_nonneg,\n    apply A1,\n    apply le_of_lt,\n    apply A3,\n  },\n  {\n    have B1:(0:ℤ) * ↑((0:ℚ).denom) = (0:ℤ) := zero_mul _,\n    rw ← B1 at A1,\n    apply le_of_mul_le_mul_right,\n    apply A1,\n    apply A3,\n  },\n  apply A4,\n  apply A3,\nend\n\nlemma rat.num_pos_of_pos {q:ℚ}:0 < q → 0 < q.num :=\nbegin\n  intro A1,\n  apply lt_of_not_ge,\n  rw lt_iff_not_ge at A1,\n  intro A2,\n  apply A1,\n  apply rat.nonpos_of_num_nonpos A2,\nend\n\nlemma rat.pos_iff_num_pos {q:ℚ}:0 < q ↔ 0 < q.num :=\nbegin\n  split;intro A1,\n  {\n    apply lt_of_not_ge,\n    rw lt_iff_not_ge at A1,\n    intro A2,\n    apply A1,\n    apply rat.nonpos_of_num_nonpos A2,\n  },\n  {\n    apply lt_of_not_ge,\n    rw lt_iff_not_ge at A1,\n    intro A2,\n    apply A1,\n    apply rat.num_nonneg_of_nonneg A2,\n  },\nend\n\n\n\ndef monoid_hom_int_rat:monoid_hom int rat := {\n  to_fun := rat.of_int,\n  map_mul' := begin\n    intros x y,\n    repeat {rw rat.of_int_eq_mk},\n    rw rat.mul_def one_ne_zero one_ne_zero,\n    simp,\n  end,\n  map_one' := rfl,\n}\n\ndef add_monoid_hom_int_rat:add_monoid_hom int rat := {\n  to_fun := rat.of_int,\n  map_add' := begin\n    intros x y,\n    repeat {rw rat.of_int_eq_mk},\n    rw rat.add_def one_ne_zero one_ne_zero,\n    simp,\n  end,\n  map_zero' := rfl,\n}\n\n\ndef ring_hom_int_rat:ring_hom int rat := {\n  ..monoid_hom_int_rat,\n  ..add_monoid_hom_int_rat,\n}\n\nlemma ring_hom_int_rat_to_fun_def {n:ℤ}:\n    ring_hom_int_rat.to_fun n = rat.of_int n := rfl\n\n\nlemma ring_hom_int_rat_to_fun_def2 {n:ℤ}:\n    ring_hom_int_rat.to_fun n = n :=\nbegin\n  rw rat.coe_int_eq_of_int,\n  rw ring_hom_int_rat_to_fun_def,\nend\n\n\nlemma ring_hom_int_rat_eq {a b:ℤ}:(ring_hom_int_rat.to_fun a)=(ring_hom_int_rat.to_fun b) ↔ (a = b) :=\nbegin\n  repeat {rw ring_hom_int_rat_to_fun_def2},\n  simp,\nend\n\n\n\n\ndef ring_hom_nat_rat:=\n  ring_hom.comp ring_hom_int_rat ring_hom_nat_int\n\n\n\n\nlemma ring_hom_nat_rat_to_fun_def {n:ℕ}:\n    ring_hom_nat_rat.to_fun n = ring_hom_int_rat.to_fun ( ring_hom_nat_int.to_fun n) :=\nbegin\n  refl,\nend\n\nlemma ring_hom_nat_rat_to_fun_def2 {n:ℕ}:\n    ring_hom_nat_rat.to_fun n = n :=\nbegin\n  rw ring_hom_nat_rat_to_fun_def,\n  rw ring_hom_nat_int_to_fun_def,\n  rw ring_hom_int_rat_to_fun_def2,\n  simp,\nend\n\n\nlemma ring_hom_nat_rat_eq {a b:ℕ}:(ring_hom_nat_rat.to_fun a)=(ring_hom_nat_rat.to_fun b) ↔ a = b :=\nbegin\n  repeat {rw ring_hom_nat_rat_to_fun_def},\n  rw ring_hom_int_rat_eq,\n  rw ring_hom_nat_int_eq,\nend\n\nlemma nat.one_le_iff_zero_lt {a:ℕ}:1 ≤ a ↔ 0 < a :=\nbegin\n  rw ← nat.succ_le_iff_lt,\nend\n\nlemma rat.exists_unit_frac_le_pos {q:ℚ}:0 < q → (∃ n:ℕ, (1/((n:rat) + 1)) ≤ q) := \nbegin\n  intro A1,\n  have A3 := @rat.num_denom q,\n  rw ← A3,\n  \n  apply exists.intro (q.denom.pred),\n  \n  have A2:(((nat.pred q.denom):rat) + 1) = q.denom,\n  {\n    have A2A:((@has_one.one ℕ _):ℚ) = 1 := rfl,\n    rw ← A2A,\n    repeat {rw ← ring_hom_nat_rat_to_fun_def2},\n    rw ← ring_hom_nat_rat.map_add',\n    rw ring_hom_nat_rat_eq,\n    have A2B:nat.pred q.denom + 1 = nat.succ (nat.pred q.denom) := rfl,\n    rw A2B,\n    rw nat.succ_pred_eq_of_pos,\n    apply q.pos,\n  },\n  rw A2,\n  have A3:(1/(q.denom:rat))= rat.mk 1 q.denom,\n  {\n    have A3A:((1:nat):rat) = 1 := rfl,\n    have A3B:((1:ℤ):rat)/((q.denom:ℤ):rat)=1/(q.denom:rat),\n    {\n      refl,\n    },\n    rw ← A3B,\n    rw ← rat.mk_eq_div,\n  },\n  rw A3,\n  rw rat.le_def,\n  {\n    simp,\n    rw le_mul_iff_one_le_left,\n    have B1:(int.succ 0) = 1 := rfl,\n    rw ← B1,\n    rw @int.succ_le_iff 0 q.num,\n    apply rat.num_pos_of_pos A1,\n    simp,\n    apply q.pos,\n  },\n  repeat {\n    simp,\n    apply q.pos,\n  },\nend\n\nlemma rat.mk_pos_denom {p:ℤ} {n:pnat}:(rat.mk p (n:ℤ))=\n  rat.mk_pnat p n :=\nbegin\n  cases n,\n  rw rat.mk_pnat_eq,\n  simp,\nend\n\n\nlemma rat.pos_mk {p q:ℤ}:(0 < p) → (1 ≤ q) → \n  0 < (rat.mk p q) :=\nbegin\n  intros A1 A2,\n  cases q,\n  {\n    cases q,\n    {\n      -- q cannot be zero.\n      exfalso,\n      simp at A2,\n      apply not_lt_of_le A2,\n      apply zero_lt_one,\n    },\n    let n := q.succ_pnat,\n    begin\n      have B1:(n:ℤ) = int.of_nat q.succ := rfl,\n      rw ← B1,\n      rw rat.mk_pos_denom,\n      rw ← rat.num_pos_iff_pos,\n      rw rat.mk_pnat_num,\n      simp,\n      cases p,\n      {\n        simp, \n        rw ← int.coe_nat_div,\n        have B2:((0:ℕ):ℤ) = (0:ℤ) := rfl,\n        rw ← B2,\n        rw int.coe_nat_lt, \n        apply nat.div_pos,\n        apply nat.gcd_le_left,\n        simp at A1,\n        apply A1,\n        apply nat.gcd_pos_of_pos_right,\n        simp,\n      },\n      {\n        -- p cannot be negative.\n        exfalso,\n        apply not_le_of_lt A1,\n        apply le_of_lt,\n        apply int.neg_succ_of_nat_lt_zero p,\n      },\n    end \n  },\n  -- q cannot be negative.\n  rw ← rat.num_pos_iff_pos,\n  unfold rat.mk,\n  {\n    exfalso,\n    apply not_le_of_lt (int.neg_succ_of_nat_lt_zero q),\n    apply le_of_lt,\n    apply lt_of_lt_of_le,\n    apply zero_lt_one,\n    apply A2,\n  },\nend\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/rat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.661922862511608, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.469315966470802}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from\n    assume (i j : ℤ) (hij : i ≠ j),\n    have h2 : α * ↑i - ↑(int.floor (α * ↑i)) = int.fract (α * ↑i), from by {\n      rw int.fract_def,\n      ring,\n    },\n    have h3 : α * ↑j - ↑(int.floor (α * ↑j)) = int.fract (α * ↑j), from by {\n      rw int.fract_def,\n      ring,\n    },\n    have h4 : α * ↑i - ↑(int.floor (α * ↑i)) = α * ↑j - ↑(int.floor (α * ↑j)), from by {\n      rw h2, rw h3,\n    },\n    have h5 : α = (int.floor (α * ↑i) - int.floor (α * ↑j)) / (i - j), from by {\n      rw ← int.fract_add_floor_eq_of_lt (α * ↑i) (by {norm_num}),\n      rw ← int.fract_add_floor_eq_of_lt (α * ↑j) (by {norm_num}),\n      rw h4,\n      rw int.fract_add_floor_eq_of_lt (α * ↑i) (by {norm_num}),\n      rw int.fract_add_floor_eq_of_lt (α * ↑j) (by {norm_num}),\n      rw ← int.fract_add_floor_eq_of_lt (α * ↑i) (by {norm_num}),\n      rw ← int.fract_add_floor_eq_of_lt (α * ↑j) (by {norm_num}),\n      rw int.fract_add_floor_eq_of_lt (α * ↑i) (by {norm_num}),\n      rw int.fract_add_floor_eq_of_lt (α * ↑j) (by {norm_num}),\n      ring,\n    },\n    have h6 : α ∈ ℚ, from by {\n      rw ← h5,\n      apply int.cast_ne_zero.1 hij,\n    },\n    have h7 : irrational α, from hα_irrat,\n    have h8 : ¬(α ∈ ℚ), from h7,\n    have h9 : false, from by {\n      apply h8 h6,\n    },\n    show (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from by {\n      apply h9,\n    },\n\n  have h2 : ∀ (i : ℤ), int.fract (α * ↑i) ∈ set.Icc 0 1, from \n    assume (i : ℤ),\n    have h3 : 0 ≤ int.fract (α * ↑i), from by {\n      rw int.fract_def,\n      apply int.cast_nonneg,\n    },\n    have h4 : int.fract (α * ↑i) < 1, from by {\n      rw int.fract_def,\n      have h5 : α * ↑i - ↑(int.floor (α * ↑i)) < 1, from by {\n        apply int.cast_lt.2,\n        rw ← int.coe_nat_lt_coe_nat_iff,\n        apply int.fract_lt_one,\n      },\n      have h6 : 0 < α * ↑i - ↑(int.floor (α * ↑i)), from by {\n        apply int.cast_pos,\n        rw ← int.coe_nat_lt_coe_nat_iff,\n        apply int.fract_pos,\n        norm_num,\n      },\n      have h7 : 0 ≤ ↑(int.floor (α * ↑i)), from by {\n        apply int.cast_nonneg,\n      },\n      linarith,\n    },\n    show int.fract (α * ↑i) ∈ set.Icc 0 1, from by {\n      apply set.mem_Icc.2,\n      split,\n      exact h3,\n      exact h4,\n    },\n\n  have h3 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from h1,\n  have h4 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ∉ set.range (λ (m : ℤ), int.fract (α * ↑m)), from\n    assume (i j : ℤ) (hij : i ≠ j),\n    have h5 : int.fract (α * ↑i) ≠ int.fract (α * ↑j), from h3 i j hij,\n    show int.fract (α * ↑i) ∉ set.range (λ (m : ℤ), int.fract (α * ↑m)), from by {\n      rw set.mem_range,\n      rw set.mem_range at h5,\n      exact h5,\n    },\n\n  have h5 : ∀ (i : ℤ), int.fract (α * ↑i) ∉ set.range (λ (m : ℤ), int.fract (α * ↑m)), from \n    assume (i : ℤ),\n    have h6 : ∃ (j : ℤ), i ≠ j, from by {\n      have h7 : ∀ (j : ℤ), i ≠ j → ∃ (k : ℤ), i ≠ k, from by {\n        assume (j : ℤ) (hij : i ≠ j),\n        have h8 : ∃ (k : ℤ), k ≠ j, from by {\n          use j,\n          norm_num,\n        },\n        cases h8 with k hk,\n        use k,\n        exact hk,\n      },\n      have h9 : ∃ (j : ℤ), ∀ (k : ℤ), i ≠ k → i ≠ j, from by {\n        use i,\n        assume (k : ℤ) (hik : i ≠ k),\n        exact hik,\n      },\n      cases h9 with j hj,\n      use j,\n      exact hj j (hj j),\n    },\n    cases h6 with j hj,\n    h4 i j hj,\n\n  have h6 : ∀ (i : ℤ), int.fract (α * ↑i) ∈ closure (set.range (λ (m : ℤ), int.fract (α * ↑m))), from \n    assume (i : ℤ),\n    have h7 : ∀ (j : ℤ), i ≠ j → int.fract (α * ↑i) ∈ closure (set.range (λ (m : ℤ), int.fract (α * ↑m))), from by {\n      assume (j : ℤ) (hij : i ≠ j),\n      have h8 : int.fract (α * ↑i) ∈ set.range (λ (m : ℤ), int.fract (α * ↑m)), from by {\n        rw set.mem_range,\n        use i,\n        refl,\n      },\n      have h9 : int.fract (α * ↑i) ∉ closure (set.range (λ (m : ℤ), int.fract (α * ↑m))), from by {\n        rw set.mem_closure_iff,\n        rw set.mem_range at h8,\n        cases h8 with k hk,\n        rw hk,\n        use int.fract (α * ↑k),\n        assume h10,\n        have h11 : int.fract (α * ↑i) ∉ set.range (λ (m : ℤ), int.fract (α * ↑m)), from by {\n          rw set.mem_range at h10,\n          cases h10 with l hl,\n          rw hl,\n         \nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n    assume i j h,\n    assume h2 : int.fract (α * ↑i) = int.fract (α * ↑j),\n    have h3 : (α * ↑i) - (int.floor (α * ↑i)) = (int.floor (α * ↑j)) - (int.floor (α * ↑j)),\n    from by {rw h2, ring},\n    have h4 : (α * ↑i) - (int.floor (α * ↑i)) = (α * ↑j) - (int.floor (α * ↑j)),\n    from by {rw h3, ring},\n    have h5 : (α * ↑i) - (int.floor (α * ↑i)) = (α * ↑j) - (int.floor (α * ↑j)),\n    from by {rw h3, ring},\n    have h6 : α = (int.floor (α * ↑i)) - (int.floor (α * ↑j)) / (i - j),\n    from by {rw h4, ring},\n    have h7 : (int.floor (α * ↑i)) - (int.floor (α * ↑j)) / (i - j) ∈ ℚ,\n    from by {apply int.cast_div,},\n    have h8 : α ∈ ℚ, from by {rw h6, exact h7,},\n    have h9 : irrational α, from hα_irrat,\n    contradiction,\n  },\n  have h2 : set.finite (set.range (λ (m : ℤ), int.fract (α * ↑m))), from by {\n    apply set.finite_range,\n  },\n  have h3 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ≠ 0, from by {\n    assume x h,\n    assume h2 : int.fract (α * ↑x) = 0,\n    have h3 : (α * ↑x) - (int.floor (α * ↑x)) = 0,\n    from by {rw h2, ring},\n    have h4 : (α * ↑x) - (int.floor (α * ↑x)) = 0,\n    from by {rw h3, ring},\n    have h5 : α = (int.floor (α * ↑x)) / x,\n    from by {rw h4, ring},\n    have h6 : (int.floor (α * ↑x)) / x ∈ ℚ,\n    from by {apply int.cast_div,},\n    have h7 : α ∈ ℚ, from by {rw h5, exact h6,},\n    have h8 : irrational α, from hα_irrat,\n    contradiction,\n  },\n  have h4 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ≠ 1, from by {\n    assume x h,\n    assume h2 : int.fract (α * ↑x) = 1,\n    have h3 : (α * ↑x) - (int.floor (α * ↑x)) = 1,\n    from by {rw h2, ring},\n    have h4 : (α * ↑x) - (int.floor (α * ↑x)) = 1,\n    from by {rw h3, ring},\n    have h5 : α = (int.floor (α * ↑x) + 1) / x,\n    from by {rw h4, ring},\n    have h6 : (int.floor (α * ↑x) + 1) / x ∈ ℚ,\n    from by {apply int.cast_div,},\n    have h7 : α ∈ ℚ, from by {rw h5, exact h6,},\n    have h8 : irrational α, from hα_irrat,\n    contradiction,\n  },\n  have h5 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ∈ set.Icc 0 1, from by {\n    assume x h,\n    have h2 : int.fract (α * ↑x) ≠ 0, from h3 x h,\n    have h3 : int.fract (α * ↑x) ≠ 1, from h4 x h,\n    rw set.mem_Icc,\n    split,\n    exact h2,\n    exact h3,\n  },\n  have h6 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ∈ set.range (λ (m : ℤ), int.fract (α * ↑m)), from by {\n    assume x h,\n    use x,\n    simp [h],\n  },\n  have h7 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ∈ (set.range (λ (m : ℤ), int.fract (α * ↑m))) ∩ set.Icc 0 1, from by {\n    assume x h,\n    split,\n    exact h6 x h,\n    exact h5 x h,\n  },\n  have h8 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ∈ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), from by {\n    assume x h,\n    have h2 : int.fract (α * ↑x) ∈ (set.range (λ (m : ℤ), int.fract (α * ↑m))) ∩ set.Icc 0 1, from h7 x h,\n    have h3 : (set.range (λ (m : ℤ), int.fract (α * ↑m))) ∩ set.Icc 0 1 ⊆ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), from by {\n      assume x h,\n      have h2 : x ∈ (set.range (λ (m : ℤ), int.fract (α * ↑m))) ∩ set.Icc 0 1, from h,\n      have h3 : x ∈ set.range (λ (m : ℤ), int.fract (α * ↑m)), from h2.left,\n      have h4 : x ∈ set.Icc 0 1, from h2.right,\n      rw set.mem_closure,\n      use (set.range (λ (m : ℤ), int.fract (α * ↑m))),\n      split,\n      exact h3,\n      use set.univ,\n      split,\n      exact set.mem_univ x,\n      exact h4,\n    },\n    exact h3 h2,\n  },\n  have h9 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ∈ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), from h8,\n  have h10 : ∀ x : ℤ, x ≠ 0 → int.fract (α * ↑x) ∈ set.Icc 0 1, from by {\n    assume x h,\n    have h2 : int.fract (α * ↑x) ∈ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), from h9 x h,\n    have h3 : closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)) ⊆ set.Icc 0 1, from by {\n      assume x h,\n      have h2 : x ∈ closure ((λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)), from h,\n      rw set.mem_Icc,\n      rw set.mem_closure at h2,\n      cases h2 with (h2_1 : x ∈ (λ (m : ℤ), int.fract (α * ↑m)) '' (@set.univ ℤ)) (h2_2 : ∀ ε > 0, ∃ (y : ℤ), y\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ i j : ℤ, i ≠ j → (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from by {\n    assume (i j : ℤ) (h : i ≠ j),\n    have h1 : (int.fract (α * ↑i)) = (int.fract (α * ↑j)) → α = (i - j)⁻¹ * (int.nat_abs (α * ↑i) - int.nat_abs (α * ↑j)) ∈ ℚ, from by {\n      assume h2 : (int.fract (α * ↑i)) = (int.fract (α * ↑j)),\n      rw [h2,int.fract_mul,int.fract_mul] at h2,\n      rw [int.fract_eq_iff_nat_abs_sub_lt_one,int.fract_eq_iff_nat_abs_sub_lt_one] at h2,\n      have h3 : α = (i - j)⁻¹ * (int.nat_abs (α * ↑i) - int.nat_abs (α * ↑j)), from by {\n        rw [int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.mul_sub,int.\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {\n    assume (i j : ℤ) (hne : i ≠ j),\n    have h2 : α ∉ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n      assume h3 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)),\n      cases h3 with i0 h4,\n      have h5 : α = ↑i0 / ↑(i0 - j), from by {rw ← h4, refl},\n      have h6 : ↑i0 / ↑(i0 - j) ∈ ℚ, from by {\n        have h7 : ↑i0 / ↑(i0 - j) = ↑i0 / ↑(i0 - j), from by refl,\n        have h8 : ↑i0 / ↑(i0 - j) ∈ ℝ, from by {rw h7, apply_instance},\n        have h9 : ↑i0 / ↑(i0 - j) ∈ ℚ, from by {rw h7, apply_instance},\n        exact h9,\n      },\n      have h10 : ↑i0 / ↑(i0 - j) = ↑i / ↑(i - j), from by rw h5,\n      have h11 : ↑i0 / ↑(i0 - j) = α, from by {rw h10, refl},\n      have h12 : α ∈ ℚ, from by {rw h11, exact h6},\n      have h13 : α ∉ ℚ, from by {exact hα_irrat},\n      contradiction,\n    },\n    have h3 : ∀ (i : ℤ), i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume (i : ℤ) (hne : i ≠ j),\n      have h4 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h5 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h6 : ↑i / ↑(i - j) = α,\n        have h7 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h6, exact h4},\n        contradiction,\n      },\n      exact h5,\n    },\n    have h4 : ∀ (i : ℤ), i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume (i : ℤ) (hne : i ≠ j),\n      have h5 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h6 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h7 : ↑i / ↑(i - j) = α,\n        have h8 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h7, exact h5},\n        contradiction,\n      },\n      exact h6,\n    },\n    have h5 : i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume hne : i ≠ j,\n      have h6 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h7 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h8 : ↑i / ↑(i - j) = α,\n        have h9 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h8, exact h6},\n        contradiction,\n      },\n      exact h7,\n    },\n    have h6 : i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume hne : i ≠ j,\n      have h7 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h8 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h9 : ↑i / ↑(i - j) = α,\n        have h10 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h9, exact h7},\n        contradiction,\n      },\n      exact h8,\n    },\n    have h7 : i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume hne : i ≠ j,\n      have h8 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h9 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h10 : ↑i / ↑(i - j) = α,\n        have h11 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h10, exact h8},\n        contradiction,\n      },\n      exact h9,\n    },\n    have h8 : i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume hne : i ≠ j,\n      have h9 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h10 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h11 : ↑i / ↑(i - j) = α,\n        have h12 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h11, exact h9},\n        contradiction,\n      },\n      exact h10,\n    },\n    have h9 : i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume hne : i ≠ j,\n      have h10 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h11 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h12 : ↑i / ↑(i - j) = α,\n        have h13 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h12, exact h10},\n        contradiction,\n      },\n      exact h11,\n    },\n    have h10 : i ≠ j → α ≠ ↑i / ↑(i - j), from by {\n      assume hne : i ≠ j,\n      have h11 : ↑i / ↑(i - j) ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h12 : ¬(↑i / ↑(i - j) = α), from by {\n        assume h13 : ↑i / ↑(i - j) = α,\n        have h14 : α ∈ set.range (λ (i : ℤ), ↑i / ↑(i - j)), from by {rw ← h13, exact h11},\n        contradiction,\n      },\n      exact h12,\n    },\n\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from begin\n    assume (i j : ℤ) (hij : i ≠ j),\n    have h2 : (α * ↑i) - (int.floor (α * ↑i)) = int.fract (α * ↑i), from by {rw int.fract_def, ring},\n    have h3 : (α * ↑j) - (int.floor (α * ↑j)) = int.fract (α * ↑j), from by {rw int.fract_def, ring},\n    have h4 : (α * ↑i) - (int.floor (α * ↑i)) = (α * ↑j) - (int.floor (α * ↑j)), from by {rw [h2, h3]},\n    have h5 : α = (int.floor (α * ↑i) - int.floor (α * ↑j)) / (i - j), from by {rw [h4, div_sub_div_same, div_self hij], ring},\n    have h6 : α ∈ ℚ, from by {apply q_of_rat, exact h5},\n    have h7 : irrational α, from hα_irrat,\n    have h8 : ¬ (α ∈ ℚ), from h7,\n    have h9 : ¬ (α ∈ ℚ), from h8,\n    exact absurd h6 h9,\n  end,\n\n  have h2 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from h1,\n\n  have h3 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) - int.fract (α * ↑j) ≠ 0, from begin\n    assume (i j : ℤ) (hij : i ≠ j),\n    have h4 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * ↑i) + - int.fract (α * ↑j), from by ring,\n    have h5 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * ↑i) + - (int.fract (α * ↑j)), from by {rw h4},\n    have h6 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * ↑i) + int.fract (-(α * ↑j)), from by {rw ← int.fract_neg, rw h5},\n    have h7 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * ↑i - (α * ↑j)), from by {rw h6},\n    have h8 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (↑i - ↑j)), from by {rw h7},\n    have h9 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h8},\n    have h10 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h9},\n    have h11 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract ((α * i) - (α * j)), from by {rw h10},\n    have h12 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract ((α * i) - (α * j)), from by {rw h11},\n    have h13 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * i - α * j), from by {rw h12},\n    have h14 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * i - α * j), from by {rw h13},\n    have h15 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h14},\n    have h16 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h15},\n    have h17 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h16},\n    have h18 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h17},\n    have h19 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h18},\n    have h20 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h19},\n    have h21 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h20},\n    have h22 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h21},\n    have h23 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h22},\n    have h24 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h23},\n    have h25 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h24},\n    have h26 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h25},\n    have h27 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h26},\n    have h28 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h27},\n    have h29 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h28},\n    have h30 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h29},\n    have h31 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h30},\n    have h32 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h31},\n    have h33 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h32},\n    have h34 : int.fract (α * ↑i) - int.fract (α * ↑j) = int.fract (α * (i - j)), from by {rw h33},\n    have h35 : int.\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nbegin\n  have h1 : ∀ i j : ℤ, i ≠ j → (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from by {\n    assume i j hne,\n    have h2 : (α * ↑i) - ↑(int.floor (α * ↑i)) = (int.fract (α * ↑i)), from by {rw int.fract_eq_sub_floor},\n    have h3 : (α * ↑j) - ↑(int.floor (α * ↑j)) = (int.fract (α * ↑j)), from by {rw int.fract_eq_sub_floor},\n    have h4 : (int.fract (α * ↑i)) = (int.fract (α * ↑j)), from by {rw h2, rw h3, linarith},\n    have h5 : (α * ↑i) - ↑(int.floor (α * ↑i)) = (α * ↑j) - ↑(int.floor (α * ↑j)), from by {rw h4},\n    have h6 : (α * ↑i) - (α * ↑j) = ↑(int.floor (α * ↑i)) - ↑(int.floor (α * ↑j)), from by {linarith},\n    have h7 : α = (↑(int.floor (α * ↑i)) - ↑(int.floor (α * ↑j))) / ↑(i - j), from by {rw h6, rw mul_comm α i, rw mul_comm α j, rw mul_sub, rw mul_sub, rw mul_comm, rw mul_assoc, rw mul_comm, rw mul_assoc, rw mul_comm, rw mul_comm, rw div_eq_mul_inv, rw mul_comm, rw mul_assoc, rw mul_comm, rw mul_assoc, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm, rw mul_comm\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n  have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n  show (A ∩ B) ∈  𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n  ... = x*(x+y) + y*(x+y) : by rw add_mul\n  ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}\n  ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n    assume a b : G, use a⁻¹ * b, obviously, },\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n    assume a b : G, use b * a⁻¹, obviously, }, \n\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n    exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n    (mul_one a),\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n    exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n        exists_unique.unique (h3 a) (hident a).right\n        (classical.some_spec (exists_unique.exists (h3 a))), \n      have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n        exists_unique.unique (h4 a) (hident a).left\n        (classical.some_spec (exists_unique.exists (h4 a))),\n      show e = (1 : G), from eq.trans (h9 e) (h6 _),     \n    },\n    exact ⟨by obviously, h7⟩,\n  }\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n  from by \n  {\n    intro x0,\n    have h6 : |x0 - l| < ε ↔ ((x0 - l) < ε) ∧ ((l - x0) < ε), \n    from abs_sub_lt_iff, rw h6,\n    split, \n    rintro ⟨ S_1, S_2 ⟩, \n    split; linarith, \n    rintro ⟨ S_3, S_4 ⟩, \n    split; linarith,\n    },\n  \n  assume (h7 : ε > 0),\n  cases h2 ε h7 with N1 h8,\n  cases h3 ε h7 with N2 h9,\n\n  let N := max N1 N2,\n  use N,\n\n  have h10 : ∀ n > N, n > N1 ∧ n > N2 := by {\n    assume n h,\n    split,\n    exact lt_of_le_of_lt (le_max_left N1 N2) h, \n    exact lt_of_le_of_lt (le_max_right N1 N2) h,\n  },\n  \n  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n  from by {\n    intros n h12,\n    split,\n    {\n\n      have h13 := (h8 n (h10 n h12).left), rw h5 (y n) at h13,\n      split,\n      exact h13.left,\n      exact (h4 n).left,\n    },\n    {        \n      have h14 := (h9 n (h10 n h12).right),rw h5 (z n) at h14,\n      split,\n      exact (h4 n).right,\n      exact h14.right,\n    },\n    \n  },\n\n  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n  from by {\n    intros n1 h16, cases (h11 n1 h16);\n    split; linarith,\n  },\n\n  show  ∀ (n : ℕ), n > N → |x n - l| < ε, \n  from by {\n    intros n h17,\n    cases h5 (x n) with h18 h19,\n    apply h19, exact h15 n h17,\n  },\nend\n\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n\nTo show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n\nQED\n-/\ntheorem  irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof-Natural-Language-Proof-Translation/Correct_statement-lean_proof-4_few_shot_temperature_0.4_max_tokens_2000_n_6/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744673038221, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4690248183766906}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison\n\nDefines a functor between categories.\n\n(As it is a 'bundled' object rather than the `is_functorial` typeclass parametrised\nby the underlying function on objects, the name is capitalised.)\n\nIntroduces notations\n  `C ⥤ D` for the type of all functors from `C` to `D`.\n    (I would like a better arrow here, unfortunately ⇒ (`\\functor`) is taken by core.)\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.reassoc_axiom\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l u₃ v₃ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\n`functor C D` represents a functor between categories `C` and `D`.\n\nTo apply a functor `F` to an object use `F.obj X`, and to a morphism use `F.map f`.\n\nThe axiom `map_id` expresses preservation of identities, and\n`map_comp` expresses functoriality.\n\nSee https://stacks.math.columbia.edu/tag/001B.\n-/\nstructure functor (C : Type u₁) [category C] (D : Type u₂) [category D] \nwhere\n  obj : C → D\n  map : {X Y : C} → (X ⟶ Y) → (obj X ⟶ obj Y)\n  map_id' : autoParam (C → map 𝟙 = 𝟙)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  map_comp' : autoParam (∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = map f ≫ map g)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n    (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\ninfixr:26 \" ⥤ \" => Mathlib.category_theory.functor\n\n-- A functor is basically a function, so give ⥤ a similar precedence to → (25).\n\n-- For example, `C × D ⥤ E` should parse as `(C × D) ⥤ E` not `C × (D ⥤ E)`.\n\n@[simp] theorem functor.map_id {C : Type u₁} [category C] {D : Type u₂} [category D] (c : C ⥤ D) (X : C) : functor.map c 𝟙 = 𝟙 := sorry\n\n@[simp] theorem functor.map_comp {C : Type u₁} [category C] {D : Type u₂} [category D] (c : C ⥤ D) {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) : functor.map c (f ≫ g) = functor.map c f ≫ functor.map c g := sorry\n\ntheorem functor.map_comp_assoc {C : Type u₁} [category C] {D : Type u₂} [category D] (c : C ⥤ D) {X : C} {Y : C} {Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) {X' : D} (f' : functor.obj c Z ⟶ X') : functor.map c (f ≫ g) ≫ f' = functor.map c f ≫ functor.map c g ≫ f' := sorry\n\nnamespace functor\n\n\n/-- `𝟭 C` is the identity functor on a category `C`. -/\nprotected def id (C : Type u₁) [category C] : C ⥤ C :=\n  mk (fun (X : C) => X) fun (_x _x_1 : C) (f : _x ⟶ _x_1) => f\n\nnotation:1024 \"𝟭\" => Mathlib.category_theory.functor.id\n\nprotected instance inhabited (C : Type u₁) [category C] : Inhabited (C ⥤ C) :=\n  { default := 𝟭 }\n\n@[simp] theorem id_obj {C : Type u₁} [category C] (X : C) : obj 𝟭 X = X :=\n  rfl\n\n@[simp] theorem id_map {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y) : map 𝟭 f = f :=\n  rfl\n\n/--\n`F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) (G : D ⥤ E) : C ⥤ E :=\n  mk (fun (X : C) => obj G (obj F X)) fun (_x _x_1 : C) (f : _x ⟶ _x_1) => map G (map F f)\n\ninfixr:80 \" ⋙ \" => Mathlib.category_theory.functor.comp\n\n@[simp] theorem comp_obj {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) (G : D ⥤ E) (X : C) : obj (F ⋙ G) X = obj G (obj F X) :=\n  rfl\n\n@[simp] theorem comp_map {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) (G : D ⥤ E) {X : C} {Y : C} (f : X ⟶ Y) : map (F ⋙ G) f = map G (map F f) :=\n  rfl\n\n-- These are not simp lemmas because rewriting along equalities between functors\n\n-- is not necessarily a good idea.\n\n-- Natural isomorphisms are also provided in `whiskering.lean`.\n\nprotected theorem comp_id {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) : F ⋙ 𝟭 = F := sorry\n\nprotected theorem id_comp {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D) : 𝟭 ⋙ F = F := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872243177518, "lm_q2_score": 0.6261241772283035, "lm_q1q2_score": 0.4690216219981859}}
{"text": "/-\nCopyright (c) 2022 Ian Wood. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ian Wood\n-/\nimport tactic.basic\nimport tactic.expand_exists\n\n@[expand_exists nat_greater nat_greater_spec]\nlemma nat_greater_exists (n : ℕ) : ∃ m : ℕ, n < m := ⟨n + 1, by fconstructor⟩\n\nnoncomputable def nat_greater_res : ℕ → ℕ := nat_greater\nlemma nat_greater_spec_res : ∀ (n : ℕ), n < nat_greater n := nat_greater_spec\n\n@[expand_exists dependent_type dependent_type_val dependent_type_spec]\nlemma dependent_type_exists {α : Type*} (a : α) : ∃ {β : Type} (b : β), (a, b) = (a, b) :=\n⟨unit, (), rfl⟩\n\ndef dependent_type_res {α : Type*} (a : α) : Type := dependent_type a\nnoncomputable def dependent_type_val_res {α : Type*} (a : α) : dependent_type a :=\ndependent_type_val a\nlemma dependent_type_spec_res\n{α : Type*} (a : α) : (a, dependent_type_val a) = (a, dependent_type_val a) := dependent_type_spec a\n\n@[expand_exists nat_greater_nosplit nat_greater_nosplit_spec,\n  expand_exists nat_greater_split nat_greater_split_lt nat_greater_split_neq]\nlemma nat_greater_exists₂ (n : ℕ) : ∃ m : ℕ, n < m ∧ m ≠ 0 := begin\n  use n + 1,\n  split,\n  fconstructor,\n  finish,\nend\n\nnoncomputable def nat_greater_nosplit_res : ℕ → ℕ := nat_greater_nosplit\nnoncomputable def nat_greater_split_res : ℕ → ℕ := nat_greater_split\n\nlemma nat_greater_nosplit_spec_res :\n∀ (n : ℕ), n < nat_greater_nosplit n ∧ nat_greater_nosplit n ≠ 0 := nat_greater_nosplit_spec\n\nlemma nat_greater_split_spec_lt_res : ∀ (n : ℕ), n < nat_greater_nosplit n := nat_greater_split_lt\nlemma nat_greater_split_spec_neq_res : ∀ (n : ℕ), nat_greater_nosplit n ≠ 0 := nat_greater_split_neq\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/expand_exists.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.4690216114764593}}
{"text": "import tactic.transport\nimport order.bounded_lattice\nimport algebra.lie.basic\n\n-- We verify that `transport` can move a `semiring` across an equivalence.\n-- Note that we've never even mentioned the idea of addition or multiplication to `transport`.\ndef semiring.map {α : Type} [semiring α] {β : Type} (e : α ≃ β) : semiring β :=\nby transport using e\n\n-- Indeed, it can equally well move a `semilattice_sup_top`.\ndef sup_top.map {α : Type} [semilattice_sup_top α] {β : Type} (e : α ≃ β) : semilattice_sup_top β :=\nby transport using e\n\n-- Verify definitional equality of the new structure data.\nexample {α : Type} [semilattice_sup_top α] {β : Type} (e : α ≃ β) (x y : β) :\nbegin\n  haveI := sup_top.map e,\n  exact (x ≤ y) = (e.symm x ≤ e.symm y),\nend :=\nrfl\n\n-- Below we verify in more detail that the transported structure for `semiring`\n-- is definitionally what you would hope for.\n\ninductive mynat : Type\n| zero : mynat\n| succ : mynat → mynat\n\ndef mynat_equiv : ℕ ≃ mynat :=\n{ to_fun := λ n, nat.rec_on n mynat.zero (λ n, mynat.succ),\n  inv_fun := λ n, mynat.rec_on n nat.zero (λ n, nat.succ),\n  left_inv := λ n, begin induction n, refl, exact congr_arg nat.succ n_ih, end,\n  right_inv := λ n, begin induction n, refl, exact congr_arg mynat.succ n_ih, end }\n\n@[simp] lemma mynat_equiv_apply_zero : mynat_equiv 0 = mynat.zero := rfl\n@[simp] lemma mynat_equiv_apply_succ (n : ℕ) :\n  mynat_equiv (n + 1) = mynat.succ (mynat_equiv n) := rfl\n@[simp] lemma mynat_equiv_symm_apply_zero : mynat_equiv.symm mynat.zero = 0:= rfl\n@[simp] lemma mynat_equiv_symm_apply_succ (n : mynat) :\n  mynat_equiv.symm (mynat.succ n) = (mynat_equiv.symm n) + 1 := rfl\n\ninstance semiring_mynat : semiring mynat :=\nsemiring.map mynat_equiv\n\nlemma mynat_add_def (a b : mynat) : a + b = mynat_equiv (mynat_equiv.symm a + mynat_equiv.symm b) :=\nrfl\n\n-- Verify that we can do computations with the transported structure.\nexample :\n  (mynat.succ (mynat.succ mynat.zero)) + (mynat.succ mynat.zero) =\n    (mynat.succ (mynat.succ (mynat.succ mynat.zero))) :=\nrfl\n\nlemma mynat_zero_def : (0 : mynat) = mynat_equiv 0 :=\nrfl\n\nlemma mynat_one_def : (1 : mynat) = mynat_equiv 1 :=\nrfl\n\nlemma mynat_mul_def (a b : mynat) : a * b = mynat_equiv (mynat_equiv.symm a * mynat_equiv.symm b) :=\nrfl\n\nexample : (3 : mynat) + (7 : mynat) = (10 : mynat) :=\nrfl\n\nexample : (2 : mynat) * (2 : mynat) = (4 : mynat) :=\nrfl\n\nexample : (3 : mynat) + (7 : mynat) * (2 : mynat) = (17 : mynat) :=\nrfl\n\nexample : (2 : ℕ) • (3 : mynat) = (6 : mynat) :=\nrfl\n\nexample : (3 : mynat) ^ 2 = (9 : mynat) :=\nrfl\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/transport/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.46898006606347326}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.eq_to_hom\nimport data.ulift\n\n/-!\n# Discrete categories\n\nWe define `discrete α := α` for any type `α`, and use this type alias\nto provide a `small_category` instance whose only morphisms are the identities.\n\nThere is an annoying technical difficulty that it has turned out to be inconvenient\nto allow categories with morphisms living in `Prop`,\nso instead of defining `X ⟶ Y` in `discrete α` as `X = Y`,\none might define it as `plift (X = Y)`.\nIn fact, to allow `discrete α` to be a `small_category`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X ⟶ Y` as `ulift (plift (X = Y))`.\n\n`discrete.functor` promotes a function `f : I → C` (for any category `C`) to a functor\n`discrete.functor f : discrete I ⥤ C`.\n\nSimilarly, `discrete.nat_trans` and `discrete.nat_iso` promote `I`-indexed families of morphisms,\nor `I`-indexed families of isomorphisms to natural transformations or natural isomorphism.\n\nWe show equivalences of types are the same as (categorical) equivalences of the corresponding\ndiscrete categories.\n-/\n\nnamespace category_theory\n\nuniverses v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\n\n/--\nA type synonym for promoting any type to a category,\nwith the only morphisms being equalities.\n-/\ndef discrete (α : Type u₁) := α\n\n/--\nThe \"discrete\" category on a type, whose morphisms are equalities.\n\nBecause we do not allow morphisms in `Prop` (only in `Type`),\nsomewhat annoyingly we have to define `X ⟶ Y` as `ulift (plift (X = Y))`.\n\nSee https://stacks.math.columbia.edu/tag/001A\n-/\ninstance discrete_category (α : Type u₁) : small_category (discrete α) :=\n{ hom  := λ X Y, ulift (plift (X = Y)),\n  id   := λ X, ulift.up (plift.up rfl),\n  comp := λ X Y Z g f, by { rcases f with ⟨⟨rfl⟩⟩, exact g } }\n\nnamespace discrete\n\nvariables {α : Type u₁}\n\ninstance [inhabited α] : inhabited (discrete α) :=\nby { dsimp [discrete], apply_instance }\n\ninstance [subsingleton α] : subsingleton (discrete α) :=\nby { dsimp [discrete], apply_instance }\n\n/-- Extract the equation from a morphism in a discrete category. -/\n\n\n@[simp] lemma id_def (X : discrete α) : ulift.up (plift.up (eq.refl X)) = 𝟙 X := rfl\n\nvariables {C : Type u₂} [category.{v₂} C]\n\ninstance {I : Type u₁} {i j : discrete I} (f : i ⟶ j) : is_iso f :=\n⟨⟨eq_to_hom (eq_of_hom f).symm, by tidy⟩⟩\n\n/--\nAny function `I → C` gives a functor `discrete I ⥤ C`.\n-/\ndef functor {I : Type u₁} (F : I → C) : discrete I ⥤ C :=\n{ obj := F,\n  map := λ X Y f, begin cases f, cases f, cases f, exact 𝟙 (F X) end }\n\n@[simp] lemma functor_obj  {I : Type u₁} (F : I → C) (i : I) :\n  (discrete.functor F).obj i = F i := rfl\n\nlemma functor_map  {I : Type u₁} (F : I → C) {i : discrete I} (f : i ⟶ i) :\n  (discrete.functor F).map f = 𝟙 (F i) :=\nby { cases f, cases f, cases f, refl }\n\n/--\nFor functors out of a discrete category,\na natural transformation is just a collection of maps,\nas the naturality squares are trivial.\n-/\ndef nat_trans {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ⟶ G.obj i) : F ⟶ G :=\n{ app := f }\n\n@[simp] lemma nat_trans_app  {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ⟶ G.obj i) (i) : (discrete.nat_trans f).app i = f i :=\nrfl\n\n/--\nFor functors out of a discrete category,\na natural isomorphism is just a collection of isomorphisms,\nas the naturality squares are trivial.\n-/\ndef nat_iso {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) : F ≅ G :=\nnat_iso.of_components f (by tidy)\n\n@[simp]\nlemma nat_iso_hom_app {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) (i : I) :\n  (discrete.nat_iso f).hom.app i = (f i).hom :=\nrfl\n\n@[simp]\nlemma nat_iso_inv_app {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) (i : I) :\n  (discrete.nat_iso f).inv.app i = (f i).inv :=\nrfl\n\n@[simp]\nlemma nat_iso_app {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) (i : I) :\n  (discrete.nat_iso f).app i = f i :=\nby tidy\n\n/-- Every functor `F` from a discrete category is naturally isomorphic (actually, equal) to\n  `discrete.functor (F.obj)`. -/\ndef nat_iso_functor {I : Type u₁} {F : discrete I ⥤ C} : F ≅ discrete.functor (F.obj) :=\nnat_iso $ λ i, iso.refl _\n\n/--\nWe can promote a type-level `equiv` to\nan equivalence between the corresponding `discrete` categories.\n-/\n@[simps]\ndef equivalence {I : Type u₁} {J : Type u₂} (e : I ≃ J) : discrete I ≌ discrete J :=\n{ functor := discrete.functor (e : I → J),\n  inverse := discrete.functor (e.symm : J → I),\n  unit_iso := discrete.nat_iso (λ i, eq_to_iso (by simp)),\n  counit_iso := discrete.nat_iso (λ j, eq_to_iso (by simp)), }\n\n/-- We can convert an equivalence of `discrete` categories to a type-level `equiv`. -/\n@[simps]\ndef equiv_of_equivalence {α : Type u₁} {β : Type u₂} (h : discrete α ≌ discrete β) : α ≃ β :=\n{ to_fun := h.functor.obj,\n  inv_fun := h.inverse.obj,\n  left_inv := λ a, eq_of_hom (h.unit_iso.app a).2,\n  right_inv := λ a, eq_of_hom (h.counit_iso.app a).1 }\n\nend discrete\n\nnamespace discrete\nvariables {J : Type v₁}\n\nopen opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\nprotected def opposite (α : Type u₁) : (discrete α)ᵒᵖ ≌ discrete α :=\nlet F : discrete α ⥤ (discrete α)ᵒᵖ := discrete.functor (λ x, op x) in\nbegin\n  refine equivalence.mk (functor.left_op F) F _ (discrete.nat_iso $ λ X, by simp [F]),\n  refine nat_iso.of_components (λ X, by simp [F]) _,\n  tidy\nend\n\nvariables {C : Type u₂} [category.{v₂} C]\n\n@[simp] lemma functor_map_id\n  (F : discrete J ⥤ C) {j : discrete J} (f : j ⟶ j) : F.map f = 𝟙 (F.obj j) :=\nbegin\n  have h : f = 𝟙 j, { cases f, cases f, ext, },\n  rw h,\n  simp,\nend\n\nend discrete\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/discrete_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.4689461521573976}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\n! This file was ported from Lean 3 source module logic.embedding.basic\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.FunLike.Embedding\nimport Mathbin.Data.Prod.Pprod\nimport Mathbin.Data.Sigma.Basic\nimport Mathbin.Data.Option.Basic\nimport Mathbin.Data.Subtype\nimport Mathbin.Logic.Equiv.Basic\n\n/-!\n# Injective functions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nuniverse u v w x\n\nnamespace Function\n\n/- warning: function.embedding -> Function.Embedding is a dubious translation:\nlean 3 declaration is\n  Sort.{u1} -> Sort.{u2} -> Sort.{max 1 (imax u1 u2)}\nbut is expected to have type\n  Sort.{u1} -> Sort.{u2} -> Sort.{max (max 1 u1) u2}\nCase conversion may be inaccurate. Consider using '#align function.embedding Function.Embeddingₓ'. -/\n-- depending on cardinalities, an injective function may not exist\n/-- `α ↪ β` is a bundled injective function. -/\n@[nolint has_nonempty_instance]\nstructure Embedding (α : Sort _) (β : Sort _) where\n  toFun : α → β\n  inj' : Injective to_fun\n#align function.embedding Function.Embedding\n\n-- mathport name: «expr ↪ »\ninfixr:25 \" ↪ \" => Embedding\n\ninstance {α : Sort u} {β : Sort v} : CoeFun (α ↪ β) fun _ => α → β :=\n  ⟨Embedding.toFun⟩\n\ninitialize_simps_projections Embedding (toFun → apply)\n\ninstance {α : Sort u} {β : Sort v} : EmbeddingLike (α ↪ β) α β\n    where\n  coe := Embedding.toFun\n  injective' := Embedding.inj'\n  coe_injective' f g h := by\n    cases f\n    cases g\n    congr\n\ninstance {α β : Sort _} : CanLift (α → β) (α ↪ β) coeFn Injective where prf f hf := ⟨⟨f, hf⟩, rfl⟩\n\nend Function\n\nsection Equiv\n\nvariable {α : Sort u} {β : Sort v} (f : α ≃ β)\n\n#print Equiv.toEmbedding /-\n/-- Convert an `α ≃ β` to `α ↪ β`.\n\nThis is also available as a coercion `equiv.coe_embedding`.\nThe explicit `equiv.to_embedding` version is preferred though, since the coercion can have issues\ninferring the type of the resulting embedding. For example:\n\n```lean\n-- Works:\nexample (s : finset (fin 3)) (f : equiv.perm (fin 3)) : s.map f.to_embedding = s.map f := by simp\n-- Error, `f` has type `fin 3 ≃ fin 3` but is expected to have type `fin 3 ↪ ?m_1 : Type ?`\nexample (s : finset (fin 3)) (f : equiv.perm (fin 3)) : s.map f = s.map f.to_embedding := by simp\n```\n-/\nprotected def Equiv.toEmbedding : α ↪ β :=\n  ⟨f, f.Injective⟩\n#align equiv.to_embedding Equiv.toEmbedding\n-/\n\n#print Equiv.coe_toEmbedding /-\n@[simp]\ntheorem Equiv.coe_toEmbedding : ⇑f.toEmbedding = f :=\n  rfl\n#align equiv.coe_to_embedding Equiv.coe_toEmbedding\n-/\n\n#print Equiv.toEmbedding_apply /-\ntheorem Equiv.toEmbedding_apply (a : α) : f.toEmbedding a = f a :=\n  rfl\n#align equiv.to_embedding_apply Equiv.toEmbedding_apply\n-/\n\n/- warning: equiv.coe_embedding -> Equiv.coeEmbedding is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}}, Coe.{max 1 (imax u1 u2) (imax u2 u1), max 1 (imax u1 u2)} (Equiv.{u1, u2} α β) (Function.Embedding.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Sort.{u1}} {β : Sort.{u2}}, Coe.{max (max 1 u2) u1, max (max 1 u2) u1} (Equiv.{u1, u2} α β) (Function.Embedding.{u1, u2} α β)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_embedding Equiv.coeEmbeddingₓ'. -/\ninstance Equiv.coeEmbedding : Coe (α ≃ β) (α ↪ β) :=\n  ⟨Equiv.toEmbedding⟩\n#align equiv.coe_embedding Equiv.coeEmbedding\n\n#print Equiv.Perm.coeEmbedding /-\n@[reducible]\ninstance Equiv.Perm.coeEmbedding : Coe (Equiv.Perm α) (α ↪ α) :=\n  Equiv.coeEmbedding\n#align equiv.perm.coe_embedding Equiv.Perm.coeEmbedding\n-/\n\n@[simp]\ntheorem Equiv.coe_eq_toEmbedding : ↑f = f.toEmbedding :=\n  rfl\n#align equiv.coe_eq_to_embedding Equiv.coe_eq_toEmbedding\n\n/- warning: equiv.as_embedding -> Equiv.asEmbedding is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : β -> Prop}, (Equiv.{u1, max 1 u2} α (Subtype.{u2} β p)) -> (Function.Embedding.{u1, u2} α β)\nbut is expected to have type\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {p : α -> Prop}, (Equiv.{u2, max 1 u1} β (Subtype.{u1} α p)) -> (Function.Embedding.{u2, u1} β α)\nCase conversion may be inaccurate. Consider using '#align equiv.as_embedding Equiv.asEmbeddingₓ'. -/\n/-- Given an equivalence to a subtype, produce an embedding to the elements of the corresponding\nset. -/\n@[simps]\ndef Equiv.asEmbedding {p : β → Prop} (e : α ≃ Subtype p) : α ↪ β :=\n  ⟨coe ∘ e, Subtype.coe_injective.comp e.Injective⟩\n#align equiv.as_embedding Equiv.asEmbedding\n\nend Equiv\n\nnamespace Function\n\nnamespace Embedding\n\n/- warning: function.embedding.coe_injective -> Function.Embedding.coe_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}}, Function.Injective.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (α -> β) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (ᾰ : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}}, Function.Injective.{max (max 1 u1) u2, imax u2 u1} (Function.Embedding.{u2, u1} α β) (α -> β) (fun (f : Function.Embedding.{u2, u1} α β) => FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) a) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_injective Function.Embedding.coe_injectiveₓ'. -/\ntheorem coe_injective {α β} : @Function.Injective (α ↪ β) (α → β) coeFn :=\n  FunLike.coe_injective\n#align function.embedding.coe_injective Function.Embedding.coe_injective\n\n/- warning: function.embedding.ext -> Function.Embedding.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {f : Function.Embedding.{u1, u2} α β} {g : Function.Embedding.{u1, u2} α β}, (forall (x : α), Eq.{u2} β (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) f x) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) g x)) -> (Eq.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} α β) f g)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {f : Function.Embedding.{u2, u1} α β} {g : Function.Embedding.{u2, u1} α β}, (forall (x : α), Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) g x)) -> (Eq.{max (max 1 u1) u2} (Function.Embedding.{u2, u1} α β) f g)\nCase conversion may be inaccurate. Consider using '#align function.embedding.ext Function.Embedding.extₓ'. -/\n@[ext]\ntheorem ext {α β} {f g : Embedding α β} (h : ∀ x, f x = g x) : f = g :=\n  FunLike.ext f g h\n#align function.embedding.ext Function.Embedding.ext\n\n/- warning: function.embedding.ext_iff -> Function.Embedding.ext_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {f : Function.Embedding.{u1, u2} α β} {g : Function.Embedding.{u1, u2} α β}, Iff (forall (x : α), Eq.{u2} β (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) f x) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) g x)) (Eq.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} α β) f g)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {f : Function.Embedding.{u2, u1} α β} {g : Function.Embedding.{u2, u1} α β}, Iff (forall (x : α), Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) g x)) (Eq.{max (max 1 u1) u2} (Function.Embedding.{u2, u1} α β) f g)\nCase conversion may be inaccurate. Consider using '#align function.embedding.ext_iff Function.Embedding.ext_iffₓ'. -/\ntheorem ext_iff {α β} {f g : Embedding α β} : (∀ x, f x = g x) ↔ f = g :=\n  FunLike.ext_iff.symm\n#align function.embedding.ext_iff Function.Embedding.ext_iff\n\n/- warning: function.embedding.to_fun_eq_coe -> Function.Embedding.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (f : Function.Embedding.{u1, u2} α β), Eq.{imax u1 u2} (α -> β) (Function.Embedding.toFun.{u1, u2} α β f) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) f)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (f : Function.Embedding.{u2, u1} α β), Eq.{imax u2 u1} (α -> β) (Function.Embedding.toFun.{u2, u1} α β f) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.to_fun_eq_coe Function.Embedding.toFun_eq_coeₓ'. -/\n@[simp]\ntheorem toFun_eq_coe {α β} (f : α ↪ β) : toFun f = f :=\n  rfl\n#align function.embedding.to_fun_eq_coe Function.Embedding.toFun_eq_coe\n\n/- warning: function.embedding.coe_fn_mk -> Function.Embedding.coeFn_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (f : α -> β) (i : Function.Injective.{u1, u2} α β f), Eq.{imax u1 u2} ((fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.mk.{u1, u2} α β f i)) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) (Function.Embedding.mk.{u1, u2} α β f i)) f\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (f : α -> β) (i : Function.Injective.{u2, u1} α β f), Eq.{imax u2 u1} (forall (a : α), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) a) (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u2) u1, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) (Function.Embedding.mk.{u2, u1} α β f i)) f\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_fn_mk Function.Embedding.coeFn_mkₓ'. -/\n@[simp]\ntheorem coeFn_mk {α β} (f : α → β) (i) : (@mk _ _ f i : α → β) = f :=\n  rfl\n#align function.embedding.coe_fn_mk Function.Embedding.coeFn_mk\n\n/- warning: function.embedding.mk_coe -> Function.Embedding.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : Function.Embedding.{succ u1, succ u2} α β) (inj : Function.Injective.{succ u1, succ u2} α β (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f)), Eq.{max 1 (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (Function.Embedding.mk.{succ u1, succ u2} α β (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f) inj) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : Function.Embedding.{succ u2, succ u1} α β) (inj : Function.Injective.{succ u2, succ u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f)), Eq.{max (succ u2) (succ u1)} (Function.Embedding.{succ u2, succ u1} α β) (Function.Embedding.mk.{succ u2, succ u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f) inj) f\nCase conversion may be inaccurate. Consider using '#align function.embedding.mk_coe Function.Embedding.mk_coeₓ'. -/\n@[simp]\ntheorem mk_coe {α β : Type _} (f : α ↪ β) (inj) : (⟨f, inj⟩ : α ↪ β) = f :=\n  by\n  ext\n  simp\n#align function.embedding.mk_coe Function.Embedding.mk_coe\n\n/- warning: function.embedding.injective -> Function.Embedding.injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (f : Function.Embedding.{u1, u2} α β), Function.Injective.{u1, u2} α β (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) f)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (f : Function.Embedding.{u2, u1} α β), Function.Injective.{u2, u1} α β (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.injective Function.Embedding.injectiveₓ'. -/\nprotected theorem injective {α β} (f : α ↪ β) : Injective f :=\n  EmbeddingLike.injective f\n#align function.embedding.injective Function.Embedding.injective\n\n/- warning: function.embedding.apply_eq_iff_eq -> Function.Embedding.apply_eq_iff_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (f : Function.Embedding.{u1, u2} α β) (x : α) (y : α), Iff (Eq.{u2} β (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) f x) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) f y)) (Eq.{u1} α x y)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (f : Function.Embedding.{u2, u1} α β) (x : α) (y : α), Iff (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f y)) (Eq.{u2} α x y)\nCase conversion may be inaccurate. Consider using '#align function.embedding.apply_eq_iff_eq Function.Embedding.apply_eq_iff_eqₓ'. -/\ntheorem apply_eq_iff_eq {α β} (f : α ↪ β) (x y : α) : f x = f y ↔ x = y :=\n  EmbeddingLike.apply_eq_iff_eq f\n#align function.embedding.apply_eq_iff_eq Function.Embedding.apply_eq_iff_eq\n\n#print Function.Embedding.refl /-\n/-- The identity map as a `function.embedding`. -/\n@[refl, simps (config := { simpRhs := true })]\nprotected def refl (α : Sort _) : α ↪ α :=\n  ⟨id, injective_id⟩\n#align function.embedding.refl Function.Embedding.refl\n-/\n\n#print Function.Embedding.trans /-\n/-- Composition of `f : α ↪ β` and `g : β ↪ γ`. -/\n@[trans, simps (config := { simpRhs := true })]\nprotected def trans {α β γ} (f : α ↪ β) (g : β ↪ γ) : α ↪ γ :=\n  ⟨g ∘ f, g.Injective.comp f.Injective⟩\n#align function.embedding.trans Function.Embedding.trans\n-/\n\n/- warning: function.embedding.equiv_to_embedding_trans_symm_to_embedding -> Function.Embedding.equiv_toEmbedding_trans_symm_toEmbedding is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (e : Equiv.{u1, u2} α β), Eq.{max 1 u1} (Function.Embedding.{u1, u1} α α) (Function.Embedding.trans.{u1, u2, u1} α β α (Equiv.toEmbedding.{u1, u2} α β e) (Equiv.toEmbedding.{u2, u1} β α (Equiv.symm.{u1, u2} α β e))) (Function.Embedding.refl.{u1} α)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (e : Equiv.{u2, u1} α β), Eq.{max 1 u2} (Function.Embedding.{u2, u2} α α) (Function.Embedding.trans.{u2, u1, u2} α β α (Equiv.toEmbedding.{u2, u1} α β e) (Equiv.toEmbedding.{u1, u2} β α (Equiv.symm.{u2, u1} α β e))) (Function.Embedding.refl.{u2} α)\nCase conversion may be inaccurate. Consider using '#align function.embedding.equiv_to_embedding_trans_symm_to_embedding Function.Embedding.equiv_toEmbedding_trans_symm_toEmbeddingₓ'. -/\n@[simp]\ntheorem equiv_toEmbedding_trans_symm_toEmbedding {α β : Sort _} (e : α ≃ β) :\n    e.toEmbedding.trans e.symm.toEmbedding = Embedding.refl _ :=\n  by\n  ext\n  simp\n#align function.embedding.equiv_to_embedding_trans_symm_to_embedding Function.Embedding.equiv_toEmbedding_trans_symm_toEmbedding\n\n/- warning: function.embedding.equiv_symm_to_embedding_trans_to_embedding -> Function.Embedding.equiv_symm_toEmbedding_trans_toEmbedding is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (e : Equiv.{u1, u2} α β), Eq.{max 1 u2} (Function.Embedding.{u2, u2} β β) (Function.Embedding.trans.{u2, u1, u2} β α β (Equiv.toEmbedding.{u2, u1} β α (Equiv.symm.{u1, u2} α β e)) (Equiv.toEmbedding.{u1, u2} α β e)) (Function.Embedding.refl.{u2} β)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (e : Equiv.{u2, u1} α β), Eq.{max 1 u1} (Function.Embedding.{u1, u1} β β) (Function.Embedding.trans.{u1, u2, u1} β α β (Equiv.toEmbedding.{u1, u2} β α (Equiv.symm.{u2, u1} α β e)) (Equiv.toEmbedding.{u2, u1} α β e)) (Function.Embedding.refl.{u1} β)\nCase conversion may be inaccurate. Consider using '#align function.embedding.equiv_symm_to_embedding_trans_to_embedding Function.Embedding.equiv_symm_toEmbedding_trans_toEmbeddingₓ'. -/\n@[simp]\ntheorem equiv_symm_toEmbedding_trans_toEmbedding {α β : Sort _} (e : α ≃ β) :\n    e.symm.toEmbedding.trans e.toEmbedding = Embedding.refl _ :=\n  by\n  ext\n  simp\n#align function.embedding.equiv_symm_to_embedding_trans_to_embedding Function.Embedding.equiv_symm_toEmbedding_trans_toEmbedding\n\n#print Function.Embedding.congr /-\n/-- Transfer an embedding along a pair of equivalences. -/\n@[simps (config := { fullyApplied := false })]\nprotected def congr {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort x} (e₁ : α ≃ β) (e₂ : γ ≃ δ)\n    (f : α ↪ γ) : β ↪ δ :=\n  (Equiv.toEmbedding e₁.symm).trans (f.trans e₂.toEmbedding)\n#align function.embedding.congr Function.Embedding.congr\n-/\n\n#print Function.Embedding.ofSurjective /-\n/-- A right inverse `surj_inv` of a surjective function as an `embedding`. -/\nprotected noncomputable def ofSurjective {α β} (f : β → α) (hf : Surjective f) : α ↪ β :=\n  ⟨surjInv hf, injective_surjInv _⟩\n#align function.embedding.of_surjective Function.Embedding.ofSurjective\n-/\n\n#print Function.Embedding.equivOfSurjective /-\n/-- Convert a surjective `embedding` to an `equiv` -/\nprotected noncomputable def equivOfSurjective {α β} (f : α ↪ β) (hf : Surjective f) : α ≃ β :=\n  Equiv.ofBijective f ⟨f.Injective, hf⟩\n#align function.embedding.equiv_of_surjective Function.Embedding.equivOfSurjective\n-/\n\n#print Function.Embedding.ofIsEmpty /-\n/-- There is always an embedding from an empty type. -/\nprotected def ofIsEmpty {α β} [IsEmpty α] : α ↪ β :=\n  ⟨isEmptyElim, isEmptyElim⟩\n#align function.embedding.of_is_empty Function.Embedding.ofIsEmpty\n-/\n\n#print Function.Embedding.setValue /-\n/-- Change the value of an embedding `f` at one point. If the prescribed image\nis already occupied by some `f a'`, then swap the values at these two points. -/\ndef setValue {α β} (f : α ↪ β) (a : α) (b : β) [∀ a', Decidable (a' = a)]\n    [∀ a', Decidable (f a' = b)] : α ↪ β :=\n  ⟨fun a' => if a' = a then b else if f a' = b then f a else f a',\n    by\n    intro x y h\n    dsimp at h\n    split_ifs  at h <;> try subst b <;> try simp only [f.injective.eq_iff] at * <;> cc⟩\n#align function.embedding.set_value Function.Embedding.setValue\n-/\n\n/- warning: function.embedding.set_value_eq -> Function.Embedding.setValue_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} (f : Function.Embedding.{u1, u2} α β) (a : α) (b : β) [_inst_1 : forall (a' : α), Decidable (Eq.{u1} α a' a)] [_inst_2 : forall (a' : α), Decidable (Eq.{u2} β (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) f a') b)], Eq.{u2} β (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} α β) (fun (_x : Function.Embedding.{u1, u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{u1, u2} α β) (Function.Embedding.setValue.{u1, u2} α β f a b (fun (a' : α) => _inst_1 a') (fun (a' : α) => _inst_2 a')) a) b\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} (f : Function.Embedding.{u2, u1} α β) (a : α) (b : β) [_inst_1 : forall (a' : α), Decidable (Eq.{u2} α a' a)] [_inst_2 : forall (a' : α), Decidable (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) a') (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) f a') b)], Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) a) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} α β) α β (Function.instEmbeddingLikeEmbedding.{u2, u1} α β)) (Function.Embedding.setValue.{u2, u1} α β f a b (fun (a' : α) => _inst_1 a') (fun (a' : α) => _inst_2 a')) a) b\nCase conversion may be inaccurate. Consider using '#align function.embedding.set_value_eq Function.Embedding.setValue_eqₓ'. -/\ntheorem setValue_eq {α β} (f : α ↪ β) (a : α) (b : β) [∀ a', Decidable (a' = a)]\n    [∀ a', Decidable (f a' = b)] : setValue f a b a = b := by simp [set_value]\n#align function.embedding.set_value_eq Function.Embedding.setValue_eq\n\n#print Function.Embedding.some /-\n/-- Embedding into `option α` using `some`. -/\n@[simps (config := { fullyApplied := false })]\nprotected def some {α} : α ↪ Option α :=\n  ⟨some, Option.some_injective α⟩\n#align function.embedding.some Function.Embedding.some\n-/\n\n/- warning: function.embedding.coe_option clashes with function.embedding.some -> Function.Embedding.some\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_option Function.Embedding.someₓ'. -/\n#print Function.Embedding.some /-\n/-- Embedding into `option α` using `coe`. Usually the correct synctatical form for `simp`. -/\n@[simps (config := { fullyApplied := false })]\ndef some {α} : α ↪ Option α :=\n  ⟨coe, Option.some_injective α⟩\n#align function.embedding.coe_option Function.Embedding.some\n-/\n\n#print Function.Embedding.optionMap /-\n/-- A version of `option.map` for `function.embedding`s. -/\n@[simps (config := { fullyApplied := false })]\ndef optionMap {α β} (f : α ↪ β) : Option α ↪ Option β :=\n  ⟨Option.map f, Option.map_injective f.Injective⟩\n#align function.embedding.option_map Function.Embedding.optionMap\n-/\n\n#print Function.Embedding.subtype /-\n/-- Embedding of a `subtype`. -/\ndef subtype {α} (p : α → Prop) : Subtype p ↪ α :=\n  ⟨coe, fun _ _ => Subtype.ext_val⟩\n#align function.embedding.subtype Function.Embedding.subtype\n-/\n\n#print Function.Embedding.coe_subtype /-\n@[simp]\ntheorem coe_subtype {α} (p : α → Prop) : ⇑(subtype p) = coe :=\n  rfl\n#align function.embedding.coe_subtype Function.Embedding.coe_subtype\n-/\n\n#print Function.Embedding.quotientOut /-\n/-- `quotient.out` as an embedding. -/\nnoncomputable def quotientOut (α) [s : Setoid α] : Quotient s ↪ α :=\n  ⟨_, Quotient.out_injective⟩\n#align function.embedding.quotient_out Function.Embedding.quotientOut\n-/\n\n#print Function.Embedding.coe_quotientOut /-\n@[simp]\ntheorem coe_quotientOut (α) [s : Setoid α] : ⇑(quotientOut α) = Quotient.out :=\n  rfl\n#align function.embedding.coe_quotient_out Function.Embedding.coe_quotientOut\n-/\n\n#print Function.Embedding.punit /-\n/-- Choosing an element `b : β` gives an embedding of `punit` into `β`. -/\ndef punit {β : Sort _} (b : β) : PUnit ↪ β :=\n  ⟨fun _ => b, by\n    rintro ⟨⟩ ⟨⟩ _\n    rfl⟩\n#align function.embedding.punit Function.Embedding.punit\n-/\n\n#print Function.Embedding.sectl /-\n/-- Fixing an element `b : β` gives an embedding `α ↪ α × β`. -/\n@[simps]\ndef sectl (α : Sort _) {β : Sort _} (b : β) : α ↪ α × β :=\n  ⟨fun a => (a, b), fun a a' h => congr_arg Prod.fst h⟩\n#align function.embedding.sectl Function.Embedding.sectl\n-/\n\n#print Function.Embedding.sectr /-\n/-- Fixing an element `a : α` gives an embedding `β ↪ α × β`. -/\n@[simps]\ndef sectr {α : Sort _} (a : α) (β : Sort _) : β ↪ α × β :=\n  ⟨fun b => (a, b), fun b b' h => congr_arg Prod.snd h⟩\n#align function.embedding.sectr Function.Embedding.sectr\n-/\n\n#print Function.Embedding.prodMap /-\n/-- If `e₁` and `e₂` are embeddings, then so is `prod.map e₁ e₂ : (a, b) ↦ (e₁ a, e₂ b)`. -/\ndef prodMap {α β γ δ : Type _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : α × γ ↪ β × δ :=\n  ⟨Prod.map e₁ e₂, e₁.Injective.Prod_map e₂.Injective⟩\n#align function.embedding.prod_map Function.Embedding.prodMap\n-/\n\n/- warning: function.embedding.coe_prod_map -> Function.Embedding.coe_prodMap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (e₁ : Function.Embedding.{succ u1, succ u2} α β) (e₂ : Function.Embedding.{succ u3, succ u4} γ δ), Eq.{max (max (succ u1) (succ u3)) (succ u2) (succ u4)} ((Prod.{u1, u3} α γ) -> (Prod.{u2, u4} β δ)) (coeFn.{max 1 (max (succ u1) (succ u3)) (succ u2) (succ u4), max (max (succ u1) (succ u3)) (succ u2) (succ u4)} (Function.Embedding.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Prod.{u1, u3} α γ) (Prod.{u2, u4} β δ)) (fun (_x : Function.Embedding.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Prod.{u1, u3} α γ) (Prod.{u2, u4} β δ)) => (Prod.{u1, u3} α γ) -> (Prod.{u2, u4} β δ)) (Function.Embedding.hasCoeToFun.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Prod.{u1, u3} α γ) (Prod.{u2, u4} β δ)) (Function.Embedding.prodMap.{u1, u2, u3, u4} α β γ δ e₁ e₂)) (Prod.map.{u1, u2, u3, u4} α β γ δ (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) e₁) (coeFn.{max 1 (succ u3) (succ u4), max (succ u3) (succ u4)} (Function.Embedding.{succ u3, succ u4} γ δ) (fun (_x : Function.Embedding.{succ u3, succ u4} γ δ) => γ -> δ) (Function.Embedding.hasCoeToFun.{succ u3, succ u4} γ δ) e₂))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u3}} {γ : Type.{u2}} {δ : Type.{u1}} (e₁ : Function.Embedding.{succ u4, succ u3} α β) (e₂ : Function.Embedding.{succ u2, succ u1} γ δ), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (forall (ᾰ : Prod.{u4, u2} α γ), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u4, u2} α γ) => Prod.{u3, u1} β δ) ᾰ) (FunLike.coe.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), max (succ u4) (succ u2), max (succ u3) (succ u1)} (Function.Embedding.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Prod.{u4, u2} α γ) (Prod.{u3, u1} β δ)) (Prod.{u4, u2} α γ) (fun (_x : Prod.{u4, u2} α γ) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u4, u2} α γ) => Prod.{u3, u1} β δ) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1), max (succ u4) (succ u2), max (succ u3) (succ u1)} (Function.Embedding.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Prod.{u4, u2} α γ) (Prod.{u3, u1} β δ)) (Prod.{u4, u2} α γ) (Prod.{u3, u1} β δ) (Function.instEmbeddingLikeEmbedding.{max (succ u4) (succ u2), max (succ u3) (succ u1)} (Prod.{u4, u2} α γ) (Prod.{u3, u1} β δ))) (Function.Embedding.prodMap.{u4, u3, u2, u1} α β γ δ e₁ e₂)) (Prod.map.{u4, u3, u2, u1} α β γ δ (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u4) (succ u3), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u4, succ u3} α β)) e₁) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} γ δ) γ (fun (_x : γ) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : γ) => δ) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} γ δ) γ δ (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} γ δ)) e₂))\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_prod_map Function.Embedding.coe_prodMapₓ'. -/\n@[simp]\ntheorem coe_prodMap {α β γ δ : Type _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) :\n    ⇑(e₁.Prod_map e₂) = Prod.map e₁ e₂ :=\n  rfl\n#align function.embedding.coe_prod_map Function.Embedding.coe_prodMap\n\n#print Function.Embedding.pprodMap /-\n/-- If `e₁` and `e₂` are embeddings, then so is `λ ⟨a, b⟩, ⟨e₁ a, e₂ b⟩ : pprod α γ → pprod β δ`. -/\ndef pprodMap {α β γ δ : Sort _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : PProd α γ ↪ PProd β δ :=\n  ⟨fun x => ⟨e₁ x.1, e₂ x.2⟩, e₁.Injective.pprod_map e₂.Injective⟩\n#align function.embedding.pprod_map Function.Embedding.pprodMap\n-/\n\nsection Sum\n\nopen Sum\n\n#print Function.Embedding.sumMap /-\n/-- If `e₁` and `e₂` are embeddings, then so is `sum.map e₁ e₂`. -/\ndef sumMap {α β γ δ : Type _} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : Sum α γ ↪ Sum β δ :=\n  ⟨Sum.map e₁ e₂, fun s₁ s₂ h =>\n    match s₁, s₂, h with\n    | inl a₁, inl a₂, h => congr_arg inl <| e₁.Injective <| inl.inj h\n    | inr b₁, inr b₂, h => congr_arg inr <| e₂.Injective <| inr.inj h⟩\n#align function.embedding.sum_map Function.Embedding.sumMap\n-/\n\n/- warning: function.embedding.coe_sum_map -> Function.Embedding.coe_sumMap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (e₁ : Function.Embedding.{succ u1, succ u2} α β) (e₂ : Function.Embedding.{succ u3, succ u4} γ δ), Eq.{max (max (succ u1) (succ u3)) (succ u2) (succ u4)} ((Sum.{u1, u3} α γ) -> (Sum.{u2, u4} β δ)) (coeFn.{max 1 (max (succ u1) (succ u3)) (succ u2) (succ u4), max (max (succ u1) (succ u3)) (succ u2) (succ u4)} (Function.Embedding.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u1, u3} α γ) (Sum.{u2, u4} β δ)) (fun (_x : Function.Embedding.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u1, u3} α γ) (Sum.{u2, u4} β δ)) => (Sum.{u1, u3} α γ) -> (Sum.{u2, u4} β δ)) (Function.Embedding.hasCoeToFun.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u1, u3} α γ) (Sum.{u2, u4} β δ)) (Function.Embedding.sumMap.{u1, u2, u3, u4} α β γ δ e₁ e₂)) (Sum.map.{u1, u3, u2, u4} α β γ δ (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) e₁) (coeFn.{max 1 (succ u3) (succ u4), max (succ u3) (succ u4)} (Function.Embedding.{succ u3, succ u4} γ δ) (fun (_x : Function.Embedding.{succ u3, succ u4} γ δ) => γ -> δ) (Function.Embedding.hasCoeToFun.{succ u3, succ u4} γ δ) e₂))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u3}} {γ : Type.{u2}} {δ : Type.{u1}} (e₁ : Function.Embedding.{succ u4, succ u3} α β) (e₂ : Function.Embedding.{succ u2, succ u1} γ δ), Eq.{max (max (max (succ u1) (succ u2)) (succ u3)) (succ u4)} (forall (ᾰ : Sum.{u4, u2} α γ), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Sum.{u4, u2} α γ) => Sum.{u3, u1} β δ) ᾰ) (FunLike.coe.{max (max (max (succ u1) (succ u2)) (succ u3)) (succ u4), max (succ u2) (succ u4), max (succ u1) (succ u3)} (Function.Embedding.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Sum.{u4, u2} α γ) (Sum.{u3, u1} β δ)) (Sum.{u4, u2} α γ) (fun (_x : Sum.{u4, u2} α γ) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Sum.{u4, u2} α γ) => Sum.{u3, u1} β δ) _x) (EmbeddingLike.toFunLike.{max (max (max (succ u1) (succ u2)) (succ u3)) (succ u4), max (succ u2) (succ u4), max (succ u1) (succ u3)} (Function.Embedding.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Sum.{u4, u2} α γ) (Sum.{u3, u1} β δ)) (Sum.{u4, u2} α γ) (Sum.{u3, u1} β δ) (Function.instEmbeddingLikeEmbedding.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Sum.{u4, u2} α γ) (Sum.{u3, u1} β δ))) (Function.Embedding.sumMap.{u4, u3, u2, u1} α β γ δ e₁ e₂)) (Sum.map.{u4, u2, u3, u1} α β γ δ (FunLike.coe.{max (succ u3) (succ u4), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u4), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u4, succ u3} α β)) e₁) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} γ δ) γ (fun (_x : γ) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : γ) => δ) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} γ δ) γ δ (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} γ δ)) e₂))\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_sum_map Function.Embedding.coe_sumMapₓ'. -/\n@[simp]\ntheorem coe_sumMap {α β γ δ} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : ⇑(sumMap e₁ e₂) = Sum.map e₁ e₂ :=\n  rfl\n#align function.embedding.coe_sum_map Function.Embedding.coe_sumMap\n\n#print Function.Embedding.inl /-\n/-- The embedding of `α` into the sum `α ⊕ β`. -/\n@[simps]\ndef inl {α β : Type _} : α ↪ Sum α β :=\n  ⟨Sum.inl, fun a b => Sum.inl.inj⟩\n#align function.embedding.inl Function.Embedding.inl\n-/\n\n#print Function.Embedding.inr /-\n/-- The embedding of `β` into the sum `α ⊕ β`. -/\n@[simps]\ndef inr {α β : Type _} : β ↪ Sum α β :=\n  ⟨Sum.inr, fun a b => Sum.inr.inj⟩\n#align function.embedding.inr Function.Embedding.inr\n-/\n\nend Sum\n\nsection Sigma\n\nvariable {α α' : Type _} {β : α → Type _} {β' : α' → Type _}\n\n#print Function.Embedding.sigmaMk /-\n/-- `sigma.mk` as an `function.embedding`. -/\n@[simps apply]\ndef sigmaMk (a : α) : β a ↪ Σx, β x :=\n  ⟨Sigma.mk a, sigma_mk_injective⟩\n#align function.embedding.sigma_mk Function.Embedding.sigmaMk\n-/\n\n#print Function.Embedding.sigmaMap /-\n/-- If `f : α ↪ α'` is an embedding and `g : Π a, β α ↪ β' (f α)` is a family\nof embeddings, then `sigma.map f g` is an embedding. -/\n@[simps apply]\ndef sigmaMap (f : α ↪ α') (g : ∀ a, β a ↪ β' (f a)) : (Σa, β a) ↪ Σa', β' a' :=\n  ⟨Sigma.map f fun a => g a, f.Injective.sigma_map fun a => (g a).Injective⟩\n#align function.embedding.sigma_map Function.Embedding.sigmaMap\n-/\n\nend Sigma\n\n#print Function.Embedding.piCongrRight /-\n/-- Define an embedding `(Π a : α, β a) ↪ (Π a : α, γ a)` from a family of embeddings\n`e : Π a, (β a ↪ γ a)`. This embedding sends `f` to `λ a, e a (f a)`. -/\n@[simps]\ndef piCongrRight {α : Sort _} {β γ : α → Sort _} (e : ∀ a, β a ↪ γ a) : (∀ a, β a) ↪ ∀ a, γ a :=\n  ⟨fun f a => e a (f a), fun f₁ f₂ h => funext fun a => (e a).Injective (congr_fun h a)⟩\n#align function.embedding.Pi_congr_right Function.Embedding.piCongrRight\n-/\n\n#print Function.Embedding.arrowCongrRight /-\n/-- An embedding `e : α ↪ β` defines an embedding `(γ → α) ↪ (γ → β)` that sends each `f`\nto `e ∘ f`. -/\ndef arrowCongrRight {α : Sort u} {β : Sort v} {γ : Sort w} (e : α ↪ β) : (γ → α) ↪ γ → β :=\n  piCongrRight fun _ => e\n#align function.embedding.arrow_congr_right Function.Embedding.arrowCongrRight\n-/\n\n#print Function.Embedding.arrowCongrRight_apply /-\n@[simp]\ntheorem arrowCongrRight_apply {α : Sort u} {β : Sort v} {γ : Sort w} (e : α ↪ β) (f : γ ↪ α) :\n    arrowCongrRight e f = e ∘ f :=\n  rfl\n#align function.embedding.arrow_congr_right_apply Function.Embedding.arrowCongrRight_apply\n-/\n\n#print Function.Embedding.arrowCongrLeft /-\n/-- An embedding `e : α ↪ β` defines an embedding `(α → γ) ↪ (β → γ)` for any inhabited type `γ`.\nThis embedding sends each `f : α → γ` to a function `g : β → γ` such that `g ∘ e = f` and\n`g y = default` whenever `y ∉ range e`. -/\nnoncomputable def arrowCongrLeft {α : Sort u} {β : Sort v} {γ : Sort w} [Inhabited γ] (e : α ↪ β) :\n    (α → γ) ↪ β → γ :=\n  ⟨fun f => extend e f default, fun f₁ f₂ h =>\n    funext fun x => by simpa only [e.injective.extend_apply] using congr_fun h (e x)⟩\n#align function.embedding.arrow_congr_left Function.Embedding.arrowCongrLeft\n-/\n\n#print Function.Embedding.subtypeMap /-\n/-- Restrict both domain and codomain of an embedding. -/\nprotected def subtypeMap {α β} {p : α → Prop} {q : β → Prop} (f : α ↪ β)\n    (h : ∀ ⦃x⦄, p x → q (f x)) : { x : α // p x } ↪ { y : β // q y } :=\n  ⟨Subtype.map f h, Subtype.map_injective h f.2⟩\n#align function.embedding.subtype_map Function.Embedding.subtypeMap\n-/\n\nopen Set\n\n/- warning: function.embedding.swap_apply -> Function.Embedding.swap_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] (f : Function.Embedding.{succ u1, succ u2} α β) (x : α) (y : α) (z : α), Eq.{succ u2} β (coeFn.{succ u2, succ u2} (Equiv.Perm.{succ u2} β) (fun (_x : Equiv.{succ u2, succ u2} β β) => β -> β) (Equiv.hasCoeToFun.{succ u2, succ u2} β β) (Equiv.swap.{succ u2} β (fun (a : β) (b : β) => _inst_2 a b) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f x) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f y)) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f z)) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f (coeFn.{succ u1, succ u1} (Equiv.Perm.{succ u1} α) (fun (_x : Equiv.{succ u1, succ u1} α α) => α -> α) (Equiv.hasCoeToFun.{succ u1, succ u1} α α) (Equiv.swap.{succ u1} α (fun (a : α) (b : α) => _inst_1 a b) x y) z))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β] (f : Function.Embedding.{succ u2, succ u1} α β) (x : α) (y : α) (z : α), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (a : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) a) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f z)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.Perm.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x)) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x)) (Equiv.swap.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (fun (a : β) (b : β) => _inst_2 a b) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f y)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f z)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.Perm.{succ u2} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} α α) (Equiv.swap.{succ u2} α (fun (a : α) (b : α) => _inst_1 a b) x y) z))\nCase conversion may be inaccurate. Consider using '#align function.embedding.swap_apply Function.Embedding.swap_applyₓ'. -/\ntheorem swap_apply {α β : Type _} [DecidableEq α] [DecidableEq β] (f : α ↪ β) (x y z : α) :\n    Equiv.swap (f x) (f y) (f z) = f (Equiv.swap x y z) :=\n  f.Injective.swap_apply x y z\n#align function.embedding.swap_apply Function.Embedding.swap_apply\n\n/- warning: function.embedding.swap_comp -> Function.Embedding.swap_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] (f : Function.Embedding.{succ u1, succ u2} α β) (x : α) (y : α), Eq.{max (succ u1) (succ u2)} (α -> β) (Function.comp.{succ u1, succ u2, succ u2} α β β (coeFn.{succ u2, succ u2} (Equiv.Perm.{succ u2} β) (fun (_x : Equiv.{succ u2, succ u2} β β) => β -> β) (Equiv.hasCoeToFun.{succ u2, succ u2} β β) (Equiv.swap.{succ u2} β (fun (a : β) (b : β) => _inst_2 a b) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f x) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f y))) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f)) (Function.comp.{succ u1, succ u1, succ u2} α α β (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f) (coeFn.{succ u1, succ u1} (Equiv.Perm.{succ u1} α) (fun (_x : Equiv.{succ u1, succ u1} α α) => α -> α) (Equiv.hasCoeToFun.{succ u1, succ u1} α α) (Equiv.swap.{succ u1} α (fun (a : α) (b : α) => _inst_1 a b) x y)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} β] (f : Function.Embedding.{succ u2, succ u1} α β) (x : α) (y : α), Eq.{max (succ u2) (succ u1)} (α -> ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x)) (Function.comp.{succ u2, succ u1, succ u1} α ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.Perm.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x)) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (fun (_x : β) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x)) (Equiv.swap.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) x) (fun (a : β) (b : β) => _inst_2 a b) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f y))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f)) (Function.comp.{succ u2, succ u2, succ u1} α α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.Perm.{succ u2} α) α (fun (_x : α) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : α) => α) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} α α) (Equiv.swap.{succ u2} α (fun (a : α) (b : α) => _inst_1 a b) x y)))\nCase conversion may be inaccurate. Consider using '#align function.embedding.swap_comp Function.Embedding.swap_compₓ'. -/\ntheorem swap_comp {α β : Type _} [DecidableEq α] [DecidableEq β] (f : α ↪ β) (x y : α) :\n    Equiv.swap (f x) (f y) ∘ f = f ∘ Equiv.swap x y :=\n  f.Injective.swap_comp x y\n#align function.embedding.swap_comp Function.Embedding.swap_comp\n\nend Embedding\n\nend Function\n\nnamespace Equiv\n\nopen Function.Embedding\n\n/- warning: equiv.subtype_injective_equiv_embedding -> Equiv.subtypeInjectiveEquivEmbedding is a dubious translation:\nlean 3 declaration is\n  forall (α : Sort.{u1}) (β : Sort.{u2}), Equiv.{max 1 (imax u1 u2), max 1 (imax u1 u2)} (Subtype.{imax u1 u2} (α -> β) (fun (f : α -> β) => Function.Injective.{u1, u2} α β f)) (Function.Embedding.{u1, u2} α β)\nbut is expected to have type\n  forall (α : Sort.{u1}) (β : Sort.{u2}), Equiv.{max 1 (imax u1 u2), max (max 1 u2) u1} (Subtype.{imax u1 u2} (α -> β) (fun (f : α -> β) => Function.Injective.{u1, u2} α β f)) (Function.Embedding.{u1, u2} α β)\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_injective_equiv_embedding Equiv.subtypeInjectiveEquivEmbeddingₓ'. -/\n/-- The type of embeddings `α ↪ β` is equivalent to\n    the subtype of all injective functions `α → β`. -/\ndef subtypeInjectiveEquivEmbedding (α β : Sort _) : { f : α → β // Function.Injective f } ≃ (α ↪ β)\n    where\n  toFun f := ⟨f.val, f.property⟩\n  invFun f := ⟨f, f.Injective⟩\n  left_inv f := by simp\n  right_inv f := by\n    ext\n    rfl\n#align equiv.subtype_injective_equiv_embedding Equiv.subtypeInjectiveEquivEmbedding\n\n/- warning: equiv.embedding_congr -> Equiv.embeddingCongr is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {δ : Sort.{u4}}, (Equiv.{u1, u2} α β) -> (Equiv.{u3, u4} γ δ) -> (Equiv.{max 1 (imax u1 u3), max 1 (imax u2 u4)} (Function.Embedding.{u1, u3} α γ) (Function.Embedding.{u2, u4} β δ))\nbut is expected to have type\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {δ : Sort.{u4}}, (Equiv.{u1, u2} α β) -> (Equiv.{u3, u4} γ δ) -> (Equiv.{max (max 1 u3) u1, max (max 1 u4) u2} (Function.Embedding.{u1, u3} α γ) (Function.Embedding.{u2, u4} β δ))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr Equiv.embeddingCongrₓ'. -/\n/-- If `α₁ ≃ α₂` and `β₁ ≃ β₂`, then the type of embeddings `α₁ ↪ β₁`\nis equivalent to the type of embeddings `α₂ ↪ β₂`. -/\n@[congr, simps apply]\ndef embeddingCongr {α β γ δ : Sort _} (h : α ≃ β) (h' : γ ≃ δ) : (α ↪ γ) ≃ (β ↪ δ)\n    where\n  toFun f := f.congr h h'\n  invFun f := f.congr h.symm h'.symm\n  left_inv x := by\n    ext\n    simp\n  right_inv x := by\n    ext\n    simp\n#align equiv.embedding_congr Equiv.embeddingCongr\n\n/- warning: equiv.embedding_congr_refl -> Equiv.embeddingCongr_refl is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}}, Eq.{max 1 (imax u1 u2)} (Equiv.{max 1 (imax u1 u2), max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} α β) (Function.Embedding.{u1, u2} α β)) (Equiv.embeddingCongr.{u1, u1, u2, u2} α α β β (Equiv.refl.{u1} α) (Equiv.refl.{u2} β)) (Equiv.refl.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} α β))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}}, Eq.{max (max 1 u2) u1} (Equiv.{max (max 1 u1) u2, max (max 1 u1) u2} (Function.Embedding.{u2, u1} α β) (Function.Embedding.{u2, u1} α β)) (Equiv.embeddingCongr.{u2, u2, u1, u1} α α β β (Equiv.refl.{u2} α) (Equiv.refl.{u1} β)) (Equiv.refl.{max (max 1 u1) u2} (Function.Embedding.{u2, u1} α β))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_refl Equiv.embeddingCongr_reflₓ'. -/\n@[simp]\ntheorem embeddingCongr_refl {α β : Sort _} :\n    embeddingCongr (Equiv.refl α) (Equiv.refl β) = Equiv.refl (α ↪ β) :=\n  by\n  ext\n  rfl\n#align equiv.embedding_congr_refl Equiv.embeddingCongr_refl\n\n/- warning: equiv.embedding_congr_trans -> Equiv.embeddingCongr_trans is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Sort.{u1}} {β₁ : Sort.{u2}} {α₂ : Sort.{u3}} {β₂ : Sort.{u4}} {α₃ : Sort.{u5}} {β₃ : Sort.{u6}} (e₁ : Equiv.{u1, u3} α₁ α₂) (e₁' : Equiv.{u2, u4} β₁ β₂) (e₂ : Equiv.{u3, u5} α₂ α₃) (e₂' : Equiv.{u4, u6} β₂ β₃), Eq.{max 1 (max (max 1 (imax u1 u2)) 1 (imax u5 u6)) (max 1 (imax u5 u6)) 1 (imax u1 u2)} (Equiv.{max 1 (imax u1 u2), max 1 (imax u5 u6)} (Function.Embedding.{u1, u2} α₁ β₁) (Function.Embedding.{u5, u6} α₃ β₃)) (Equiv.embeddingCongr.{u1, u5, u2, u6} α₁ α₃ β₁ β₃ (Equiv.trans.{u1, u3, u5} α₁ α₂ α₃ e₁ e₂) (Equiv.trans.{u2, u4, u6} β₁ β₂ β₃ e₁' e₂')) (Equiv.trans.{max 1 (imax u1 u2), max 1 (imax u3 u4), max 1 (imax u5 u6)} (Function.Embedding.{u1, u2} α₁ β₁) (Function.Embedding.{u3, u4} α₂ β₂) (Function.Embedding.{u5, u6} α₃ β₃) (Equiv.embeddingCongr.{u1, u3, u2, u4} α₁ α₂ β₁ β₂ e₁ e₁') (Equiv.embeddingCongr.{u3, u5, u4, u6} α₂ α₃ β₂ β₃ e₂ e₂'))\nbut is expected to have type\n  forall {α₁ : Sort.{u6}} {β₁ : Sort.{u5}} {α₂ : Sort.{u4}} {β₂ : Sort.{u3}} {α₃ : Sort.{u2}} {β₃ : Sort.{u1}} (e₁ : Equiv.{u6, u4} α₁ α₂) (e₁' : Equiv.{u5, u3} β₁ β₂) (e₂ : Equiv.{u4, u2} α₂ α₃) (e₂' : Equiv.{u3, u1} β₂ β₃), Eq.{max (max (max (max 1 u6) u5) u2) u1} (Equiv.{max (max 1 u5) u6, max (max 1 u1) u2} (Function.Embedding.{u6, u5} α₁ β₁) (Function.Embedding.{u2, u1} α₃ β₃)) (Equiv.embeddingCongr.{u6, u2, u5, u1} α₁ α₃ β₁ β₃ (Equiv.trans.{u6, u4, u2} α₁ α₂ α₃ e₁ e₂) (Equiv.trans.{u5, u3, u1} β₁ β₂ β₃ e₁' e₂')) (Equiv.trans.{max (max 1 u6) u5, max (max 1 u4) u3, max (max 1 u1) u2} (Function.Embedding.{u6, u5} α₁ β₁) (Function.Embedding.{u4, u3} α₂ β₂) (Function.Embedding.{u2, u1} α₃ β₃) (Equiv.embeddingCongr.{u6, u4, u5, u3} α₁ α₂ β₁ β₂ e₁ e₁') (Equiv.embeddingCongr.{u4, u2, u3, u1} α₂ α₃ β₂ β₃ e₂ e₂'))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_trans Equiv.embeddingCongr_transₓ'. -/\n@[simp]\ntheorem embeddingCongr_trans {α₁ β₁ α₂ β₂ α₃ β₃ : Sort _} (e₁ : α₁ ≃ α₂) (e₁' : β₁ ≃ β₂)\n    (e₂ : α₂ ≃ α₃) (e₂' : β₂ ≃ β₃) :\n    embeddingCongr (e₁.trans e₂) (e₁'.trans e₂') =\n      (embeddingCongr e₁ e₁').trans (embeddingCongr e₂ e₂') :=\n  rfl\n#align equiv.embedding_congr_trans Equiv.embeddingCongr_trans\n\n/- warning: equiv.embedding_congr_symm -> Equiv.embeddingCongr_symm is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Sort.{u1}} {β₁ : Sort.{u2}} {α₂ : Sort.{u3}} {β₂ : Sort.{u4}} (e₁ : Equiv.{u1, u3} α₁ α₂) (e₂ : Equiv.{u2, u4} β₁ β₂), Eq.{max 1 (max (max 1 (imax u3 u4)) 1 (imax u1 u2)) (max 1 (imax u1 u2)) 1 (imax u3 u4)} (Equiv.{max 1 (imax u3 u4), max 1 (imax u1 u2)} (Function.Embedding.{u3, u4} α₂ β₂) (Function.Embedding.{u1, u2} α₁ β₁)) (Equiv.symm.{max 1 (imax u1 u2), max 1 (imax u3 u4)} (Function.Embedding.{u1, u2} α₁ β₁) (Function.Embedding.{u3, u4} α₂ β₂) (Equiv.embeddingCongr.{u1, u3, u2, u4} α₁ α₂ β₁ β₂ e₁ e₂)) (Equiv.embeddingCongr.{u3, u1, u4, u2} α₂ α₁ β₂ β₁ (Equiv.symm.{u1, u3} α₁ α₂ e₁) (Equiv.symm.{u2, u4} β₁ β₂ e₂))\nbut is expected to have type\n  forall {α₁ : Sort.{u4}} {β₁ : Sort.{u3}} {α₂ : Sort.{u2}} {β₂ : Sort.{u1}} (e₁ : Equiv.{u4, u2} α₁ α₂) (e₂ : Equiv.{u3, u1} β₁ β₂), Eq.{max (max (max (max 1 u4) u3) u2) u1} (Equiv.{max (max 1 u2) u1, max (max 1 u4) u3} (Function.Embedding.{u2, u1} α₂ β₂) (Function.Embedding.{u4, u3} α₁ β₁)) (Equiv.symm.{max (max 1 u4) u3, max (max 1 u2) u1} (Function.Embedding.{u4, u3} α₁ β₁) (Function.Embedding.{u2, u1} α₂ β₂) (Equiv.embeddingCongr.{u4, u2, u3, u1} α₁ α₂ β₁ β₂ e₁ e₂)) (Equiv.embeddingCongr.{u2, u4, u1, u3} α₂ α₁ β₂ β₁ (Equiv.symm.{u4, u2} α₁ α₂ e₁) (Equiv.symm.{u3, u1} β₁ β₂ e₂))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_symm Equiv.embeddingCongr_symmₓ'. -/\n@[simp]\ntheorem embeddingCongr_symm {α₁ β₁ α₂ β₂ : Sort _} (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) :\n    (embeddingCongr e₁ e₂).symm = embeddingCongr e₁.symm e₂.symm :=\n  rfl\n#align equiv.embedding_congr_symm Equiv.embeddingCongr_symm\n\n/- warning: equiv.embedding_congr_apply_trans -> Equiv.embeddingCongr_apply_trans is a dubious translation:\nlean 3 declaration is\n  forall {α₁ : Sort.{u1}} {β₁ : Sort.{u2}} {γ₁ : Sort.{u3}} {α₂ : Sort.{u4}} {β₂ : Sort.{u5}} {γ₂ : Sort.{u6}} (ea : Equiv.{u1, u4} α₁ α₂) (eb : Equiv.{u2, u5} β₁ β₂) (ec : Equiv.{u3, u6} γ₁ γ₂) (f : Function.Embedding.{u1, u2} α₁ β₁) (g : Function.Embedding.{u2, u3} β₁ γ₁), Eq.{max 1 (imax u4 u6)} (Function.Embedding.{u4, u6} α₂ γ₂) (coeFn.{max 1 (max (max 1 (imax u1 u3)) 1 (imax u4 u6)) (max 1 (imax u4 u6)) 1 (imax u1 u3), max (max 1 (imax u1 u3)) 1 (imax u4 u6)} (Equiv.{max 1 (imax u1 u3), max 1 (imax u4 u6)} (Function.Embedding.{u1, u3} α₁ γ₁) (Function.Embedding.{u4, u6} α₂ γ₂)) (fun (_x : Equiv.{max 1 (imax u1 u3), max 1 (imax u4 u6)} (Function.Embedding.{u1, u3} α₁ γ₁) (Function.Embedding.{u4, u6} α₂ γ₂)) => (Function.Embedding.{u1, u3} α₁ γ₁) -> (Function.Embedding.{u4, u6} α₂ γ₂)) (Equiv.hasCoeToFun.{max 1 (imax u1 u3), max 1 (imax u4 u6)} (Function.Embedding.{u1, u3} α₁ γ₁) (Function.Embedding.{u4, u6} α₂ γ₂)) (Equiv.embeddingCongr.{u1, u4, u3, u6} α₁ α₂ γ₁ γ₂ ea ec) (Function.Embedding.trans.{u1, u2, u3} α₁ β₁ γ₁ f g)) (Function.Embedding.trans.{u4, u5, u6} α₂ β₂ γ₂ (coeFn.{max 1 (max (max 1 (imax u1 u2)) 1 (imax u4 u5)) (max 1 (imax u4 u5)) 1 (imax u1 u2), max (max 1 (imax u1 u2)) 1 (imax u4 u5)} (Equiv.{max 1 (imax u1 u2), max 1 (imax u4 u5)} (Function.Embedding.{u1, u2} α₁ β₁) (Function.Embedding.{u4, u5} α₂ β₂)) (fun (_x : Equiv.{max 1 (imax u1 u2), max 1 (imax u4 u5)} (Function.Embedding.{u1, u2} α₁ β₁) (Function.Embedding.{u4, u5} α₂ β₂)) => (Function.Embedding.{u1, u2} α₁ β₁) -> (Function.Embedding.{u4, u5} α₂ β₂)) (Equiv.hasCoeToFun.{max 1 (imax u1 u2), max 1 (imax u4 u5)} (Function.Embedding.{u1, u2} α₁ β₁) (Function.Embedding.{u4, u5} α₂ β₂)) (Equiv.embeddingCongr.{u1, u4, u2, u5} α₁ α₂ β₁ β₂ ea eb) f) (coeFn.{max 1 (max (max 1 (imax u2 u3)) 1 (imax u5 u6)) (max 1 (imax u5 u6)) 1 (imax u2 u3), max (max 1 (imax u2 u3)) 1 (imax u5 u6)} (Equiv.{max 1 (imax u2 u3), max 1 (imax u5 u6)} (Function.Embedding.{u2, u3} β₁ γ₁) (Function.Embedding.{u5, u6} β₂ γ₂)) (fun (_x : Equiv.{max 1 (imax u2 u3), max 1 (imax u5 u6)} (Function.Embedding.{u2, u3} β₁ γ₁) (Function.Embedding.{u5, u6} β₂ γ₂)) => (Function.Embedding.{u2, u3} β₁ γ₁) -> (Function.Embedding.{u5, u6} β₂ γ₂)) (Equiv.hasCoeToFun.{max 1 (imax u2 u3), max 1 (imax u5 u6)} (Function.Embedding.{u2, u3} β₁ γ₁) (Function.Embedding.{u5, u6} β₂ γ₂)) (Equiv.embeddingCongr.{u2, u5, u3, u6} β₁ β₂ γ₁ γ₂ eb ec) g))\nbut is expected to have type\n  forall {α₁ : Sort.{u6}} {β₁ : Sort.{u5}} {γ₁ : Sort.{u4}} {α₂ : Sort.{u3}} {β₂ : Sort.{u2}} {γ₂ : Sort.{u1}} (ea : Equiv.{u6, u3} α₁ α₂) (eb : Equiv.{u5, u2} β₁ β₂) (ec : Equiv.{u4, u1} γ₁ γ₂) (f : Function.Embedding.{u6, u5} α₁ β₁) (g : Function.Embedding.{u5, u4} β₁ γ₁), Eq.{max (max 1 u3) u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u6, u4} α₁ γ₁) => Function.Embedding.{u3, u1} α₂ γ₂) (Function.Embedding.trans.{u6, u5, u4} α₁ β₁ γ₁ f g)) (FunLike.coe.{max (max (max (max 1 u6) u4) u3) u1, max (max 1 u6) u4, max (max 1 u3) u1} (Equiv.{max (max 1 u4) u6, max (max 1 u1) u3} (Function.Embedding.{u6, u4} α₁ γ₁) (Function.Embedding.{u3, u1} α₂ γ₂)) (Function.Embedding.{u6, u4} α₁ γ₁) (fun (_x : Function.Embedding.{u6, u4} α₁ γ₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u6, u4} α₁ γ₁) => Function.Embedding.{u3, u1} α₂ γ₂) _x) (Equiv.instFunLikeEquiv.{max (max 1 u6) u4, max (max 1 u3) u1} (Function.Embedding.{u6, u4} α₁ γ₁) (Function.Embedding.{u3, u1} α₂ γ₂)) (Equiv.embeddingCongr.{u6, u3, u4, u1} α₁ α₂ γ₁ γ₂ ea ec) (Function.Embedding.trans.{u6, u5, u4} α₁ β₁ γ₁ f g)) (Function.Embedding.trans.{u3, u2, u1} α₂ β₂ γ₂ (FunLike.coe.{max (max (max (max 1 u6) u5) u3) u2, max (max 1 u6) u5, max (max 1 u3) u2} (Equiv.{max (max 1 u5) u6, max (max 1 u2) u3} (Function.Embedding.{u6, u5} α₁ β₁) (Function.Embedding.{u3, u2} α₂ β₂)) (Function.Embedding.{u6, u5} α₁ β₁) (fun (_x : Function.Embedding.{u6, u5} α₁ β₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u6, u5} α₁ β₁) => Function.Embedding.{u3, u2} α₂ β₂) _x) (Equiv.instFunLikeEquiv.{max (max 1 u6) u5, max (max 1 u3) u2} (Function.Embedding.{u6, u5} α₁ β₁) (Function.Embedding.{u3, u2} α₂ β₂)) (Equiv.embeddingCongr.{u6, u3, u5, u2} α₁ α₂ β₁ β₂ ea eb) f) (FunLike.coe.{max (max (max (max 1 u5) u4) u2) u1, max (max 1 u5) u4, max (max 1 u2) u1} (Equiv.{max (max 1 u4) u5, max (max 1 u1) u2} (Function.Embedding.{u5, u4} β₁ γ₁) (Function.Embedding.{u2, u1} β₂ γ₂)) (Function.Embedding.{u5, u4} β₁ γ₁) (fun (_x : Function.Embedding.{u5, u4} β₁ γ₁) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u5, u4} β₁ γ₁) => Function.Embedding.{u2, u1} β₂ γ₂) _x) (Equiv.instFunLikeEquiv.{max (max 1 u5) u4, max (max 1 u2) u1} (Function.Embedding.{u5, u4} β₁ γ₁) (Function.Embedding.{u2, u1} β₂ γ₂)) (Equiv.embeddingCongr.{u5, u2, u4, u1} β₁ β₂ γ₁ γ₂ eb ec) g))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_apply_trans Equiv.embeddingCongr_apply_transₓ'. -/\ntheorem embeddingCongr_apply_trans {α₁ β₁ γ₁ α₂ β₂ γ₂ : Sort _} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂)\n    (ec : γ₁ ≃ γ₂) (f : α₁ ↪ β₁) (g : β₁ ↪ γ₁) :\n    Equiv.embeddingCongr ea ec (f.trans g) =\n      (Equiv.embeddingCongr ea eb f).trans (Equiv.embeddingCongr eb ec g) :=\n  by\n  ext\n  simp\n#align equiv.embedding_congr_apply_trans Equiv.embeddingCongr_apply_trans\n\n#print Equiv.refl_toEmbedding /-\n@[simp]\ntheorem refl_toEmbedding {α : Type _} : (Equiv.refl α).toEmbedding = Function.Embedding.refl α :=\n  rfl\n#align equiv.refl_to_embedding Equiv.refl_toEmbedding\n-/\n\n/- warning: equiv.trans_to_embedding -> Equiv.trans_toEmbedding is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (e : Equiv.{succ u1, succ u2} α β) (f : Equiv.{succ u2, succ u3} β γ), Eq.{max 1 (succ u1) (succ u3)} (Function.Embedding.{succ u1, succ u3} α γ) (Equiv.toEmbedding.{succ u1, succ u3} α γ (Equiv.trans.{succ u1, succ u2, succ u3} α β γ e f)) (Function.Embedding.trans.{succ u1, succ u2, succ u3} α β γ (Equiv.toEmbedding.{succ u1, succ u2} α β e) (Equiv.toEmbedding.{succ u2, succ u3} β γ f))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} (e : Equiv.{succ u3, succ u2} α β) (f : Equiv.{succ u2, succ u1} β γ), Eq.{max (succ u3) (succ u1)} (Function.Embedding.{succ u3, succ u1} α γ) (Equiv.toEmbedding.{succ u3, succ u1} α γ (Equiv.trans.{succ u3, succ u2, succ u1} α β γ e f)) (Function.Embedding.trans.{succ u3, succ u2, succ u1} α β γ (Equiv.toEmbedding.{succ u3, succ u2} α β e) (Equiv.toEmbedding.{succ u2, succ u1} β γ f))\nCase conversion may be inaccurate. Consider using '#align equiv.trans_to_embedding Equiv.trans_toEmbeddingₓ'. -/\n@[simp]\ntheorem trans_toEmbedding {α β γ : Type _} (e : α ≃ β) (f : β ≃ γ) :\n    (e.trans f).toEmbedding = e.toEmbedding.trans f.toEmbedding :=\n  rfl\n#align equiv.trans_to_embedding Equiv.trans_toEmbedding\n\nend Equiv\n\nsection Subtype\n\nvariable {α : Type _}\n\n#print subtypeOrLeftEmbedding /-\n/-- A subtype `{x // p x ∨ q x}` over a disjunction of `p q : α → Prop` can be injectively split\ninto a sum of subtypes `{x // p x} ⊕ {x // q x}` such that `¬ p x` is sent to the right. -/\ndef subtypeOrLeftEmbedding (p q : α → Prop) [DecidablePred p] :\n    { x // p x ∨ q x } ↪ Sum { x // p x } { x // q x } :=\n  ⟨fun x => if h : p x then Sum.inl ⟨x, h⟩ else Sum.inr ⟨x, x.Prop.resolve_left h⟩,\n    by\n    intro x y\n    dsimp only\n    split_ifs <;> simp [Subtype.ext_iff]⟩\n#align subtype_or_left_embedding subtypeOrLeftEmbedding\n-/\n\n#print subtypeOrLeftEmbedding_apply_left /-\ntheorem subtypeOrLeftEmbedding_apply_left {p q : α → Prop} [DecidablePred p]\n    (x : { x // p x ∨ q x }) (hx : p x) : subtypeOrLeftEmbedding p q x = Sum.inl ⟨x, hx⟩ :=\n  dif_pos hx\n#align subtype_or_left_embedding_apply_left subtypeOrLeftEmbedding_apply_left\n-/\n\n#print subtypeOrLeftEmbedding_apply_right /-\ntheorem subtypeOrLeftEmbedding_apply_right {p q : α → Prop} [DecidablePred p]\n    (x : { x // p x ∨ q x }) (hx : ¬p x) :\n    subtypeOrLeftEmbedding p q x = Sum.inr ⟨x, x.Prop.resolve_left hx⟩ :=\n  dif_neg hx\n#align subtype_or_left_embedding_apply_right subtypeOrLeftEmbedding_apply_right\n-/\n\n#print Subtype.impEmbedding /-\n/-- A subtype `{x // p x}` can be injectively sent to into a subtype `{x // q x}`,\nif `p x → q x` for all `x : α`. -/\n@[simps]\ndef Subtype.impEmbedding (p q : α → Prop) (h : ∀ x, p x → q x) : { x // p x } ↪ { x // q x } :=\n  ⟨fun x => ⟨x, h x x.Prop⟩, fun x y => by simp [Subtype.ext_iff]⟩\n#align subtype.imp_embedding Subtype.impEmbedding\n-/\n\nend Subtype\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Logic/Embedding/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.46894613858794754}}
{"text": "/-\nCopyright (c) 2021 Ashvni Narayanan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ashvni Narayanan\n-/\nimport number_theory.padics.padic_integers\nimport topology.continuous_function.compact\nimport topology.continuous_function.locally_constant\n\n/-!\n# p-adic measure theory\n\nThis file defines p-adic distributions and measure on the space of locally constant functions\nfrom a profinite space to a normed ring. We then use the measure to construct the p-adic integral.\nIn fact, we prove that this integral is linearly and continuously extended on `C(X, A`.\n\n## Main definitions and theorems\n * `exists_finset_clopen`\n * `measures`\n * `integral`\n\n## Implementation notes\nTODO (optional)\n\n## References\nIntroduction to Cyclotomic Fields, Washington (Chapter 12)\n\n## Tags\np-adic L-function, p-adic integral, measure, totally disconnected, locally constant, compact,\nHausdorff\n\n\n###############\nNote (jmc): this file was copied with permission of Ashvni Narayan from\nhttps://github.com/leanprover-community/mathlib/blob/f2fd1fb4507431cf2f2a873db4b97d360633fb69/src/number_theory/L_functions.lean#L453\nand subsequently mildly modified.\n###############\n\n\n-/\n\nvariables (X : Type*) [topological_space X]\nvariables (A : Type*) [normed_group A]\n\nvariable {X}\nvariables [compact_space X]\n\nnamespace set\nlemma diff_inter_eq_empty {α : Type*} (a : set α) {b c : set α} (h : c ⊆ b) :\n  a \\ b ∩ c = ∅ :=\nbegin\n  ext x,\n  simp only [and_imp, mem_empty_eq, mem_inter_eq, not_and, mem_diff, iff_false],\n  intro _,\n  exact mt (@h x),\nend\n\n\nlemma diff_inter_mem_sUnion {α : Type*} {s : set (set α)} (a y : set α) (h : y ∈ s) :\n  (a \\ ⋃₀ s) ∩ y = ∅ :=\ndiff_inter_eq_empty a $ subset_sUnion_of_mem h\n\nend set\n\nnamespace is_clopen\n\nlemma is_closed_sUnion {H : Type*} [topological_space H]\n  {s : finset(set H)} (hs : ∀ x ∈ s, is_closed x) :\n  is_closed ⋃₀ (s : set(set H)) :=\nby { simpa only [← is_open_compl_iff, set.compl_sUnion, set.sInter_image] using is_open_bInter\n    (finset.finite_to_set s) (λ i hi, _), apply is_open_compl_iff.2 (hs i hi), }\n\nlemma is_clopen_sUnion {H : Type*} [topological_space H]\n  (s : finset(set H)) (hs : ∀ x ∈ s, is_clopen x) :\n  is_clopen ⋃₀ (s : set(set H)) :=\n⟨is_open_sUnion (λ t ht, (hs t ht).1), is_closed_sUnion (λ t ht, (hs t ht).2) ⟩\n\n/-- The finite union of clopen sets is clopen. -/\nlemma clopen_finite_Union {H : Type*} [topological_space H]\n  (s : finset(set H)) (hs : ∀ x ∈ s, is_clopen x) :\n  is_clopen ⋃₀ (s : set(set H)) :=\n  by { rw set.sUnion_eq_bUnion, apply is_clopen_bUnion hs, }\n\n/-- Given a finite set of clopens, one can find a finite disjoint set of clopens contained in\n  it. -/\nlemma clopen_Union_disjoint {H : Type*} [topological_space H]\n  (s : finset(set H)) (hs : ∀ x ∈ s, is_clopen x) :\n  ∃ (t : finset (set H)),\n  (∀ (x ∈ (t : set (set H))), is_clopen x) ∧\n  ⋃₀ (s : set(set H)) = ⋃₀ (t : set(set H)) ∧\n  (∀ (x : set H) (hx : x ∈ t), ∃ z ∈ s, x ⊆ z) ∧\n  ∀ (x y : set H) (hx : x ∈ t) (hy : y ∈ t) (h : x ≠ y), x ∩ y = ∅ :=\nbegin\n  classical,\n  apply finset.induction_on' s,\n  { use ∅, simp only [finset.not_mem_empty, forall_false_left, set.mem_empty_eq, forall_const,\n      finset.coe_empty, eq_self_iff_true, and_self], },\n  { rintros a S h's hS aS ⟨t, clo, union, sub, disj⟩,\n    set b := a \\ ⋃₀ S with hb,\n    refine ⟨insert b t, _, _, ⟨λ x hx, _, λ x y hx hy ne, _⟩⟩,\n    { rintros x hx,\n      simp only [finset.coe_insert, set.mem_insert_iff, finset.mem_coe] at hx,\n      cases hx,\n      { rw hx, apply is_clopen.diff (hs a h's) (clopen_finite_Union _ (λ y hy, (hs y (hS hy)))), },\n      { apply clo x hx, }, },\n    { simp only [finset.coe_insert, set.sUnion_insert], rw [←union, set.diff_union_self], },\n    { simp only [finset.mem_insert] at hx, cases hx,\n      { use a, rw hx, simp only [true_and, true_or, eq_self_iff_true, finset.mem_insert],\n        apply set.diff_subset, },\n      { rcases sub x hx with ⟨z, hz, xz⟩, refine ⟨z, _, xz⟩,\n        rw finset.mem_insert, right, assumption, }, },\n    { rw finset.mem_insert at hx, rw finset.mem_insert at hy,\n      have : ∀ y ∈ t, b ∩ y = ∅,\n      { rintros y hy, rw [hb, union], apply set.diff_inter_mem_sUnion, assumption, },\n      cases hx,\n      { cases hy,\n        { exfalso, apply ne, rw [hx, hy], },\n        { rw hx, apply this y hy, }, },\n      { cases hy,\n        { rw set.inter_comm, rw hy, apply this x hx, },\n        { apply disj x y hx hy ne, }, }, }, },\nend\n\nend is_clopen\n\nnamespace locally_constant.density\n\nvariables (ε : ℝ)\n\n/-- Takes an element of `A` to an `ε/4`-ball centered around it. -/\nabbreviation h {A : Type*} [normed_group A] : A → set A :=\n  λ (x : A), metric.ball x (ε / 4)\n\n/-- The set of (ε/4)-balls. -/\nabbreviation S {A : Type*} [normed_group A] : set (set A) := set.range (h ε)\n\nvariables {A} (f : C(X, A))\n\n/-- Preimage of (ε/4)-balls. -/\nabbreviation B : set(set X) := { j : set X | ∃ (U ∈ ((S ε) : set(set A))), j = f ⁻¹' U }\n\nlemma opens {j : set X} (hj : j ∈ (B ε f)) : is_open j :=\nbegin\n  rcases hj with ⟨hj_w, ⟨hj_h_w_w, rfl⟩, rfl⟩,\n  exact continuous.is_open_preimage f.2 _ (metric.is_open_ball),\nend\n\nvariable [fact (0 < ε)]\n/-- `X` is covered by a union of preimage of finitely many elements of `S` under `f` -/\nlemma exists_finset_univ_sub : ∃ (t : finset (set A)), set.univ ⊆ ⨆ (i : set A) (H : i ∈ t)\n  (H : i ∈ ((S ε) : set(set A))), f ⁻¹' i :=\nbegin\n  have g : (⋃₀ S ε) = (set.univ : set A),\n  { rw set.sUnion_eq_univ_iff, rintros, refine ⟨metric.ball a (ε/4), _, _⟩,\n    { simp only [set.mem_range, exists_apply_eq_apply], },\n    { simp only [metric.mem_ball, dist_self],\n      refine div_pos (fact.out _) zero_lt_four, }, },\n  have g' : set.preimage f (⋃₀ S ε) = set.univ,\n  { rw g, exact set.preimage_univ, },\n  rw [set.preimage_sUnion, set.subset.antisymm_iff] at g',\n  refine is_compact.elim_finite_subcover compact_univ _ (λ i, is_open_Union\n    (λ hi, continuous.is_open_preimage (continuous_map.continuous f) i _)) g'.2,\n  cases hi with y hy, rw [←hy], refine @metric.is_open_ball A _ y (ε/4),\nend\n\n/-- Choosing a finset as given in `exists_finset_univ_sub` -/\nnoncomputable abbreviation t : finset (set A) := classical.some (exists_finset_univ_sub ε f)\n\nlemma exists_finset_univ_sub_prop : set.univ ⊆ ⨆ (i : set A) (H : i ∈ t ε f)\n  (H : i ∈ ((S ε) : set(set A))), f ⁻¹' i := classical.some_spec (exists_finset_univ_sub ε f)\n\n/-- If there is a finite set of sets from `S` whose preimage forms a cover for `X`,\n  then the union of the preimages of all the sets from `S` also forms a cover. -/\nlemma sUnion_sub_of_finset_sub : set.univ ⊆ set.sUnion (B ε f) :=\nbegin\n  rintros x hx,\n  obtain ⟨-, ⟨j, rfl⟩, -, ⟨hj, rfl⟩, -, ⟨⟨a, jS⟩, rfl⟩, fj⟩ := (exists_finset_univ_sub_prop ε f) hx,\n  exact ⟨f⁻¹' j, ⟨j, ⟨_, jS⟩, rfl⟩, fj⟩,\nend\n\nvariables [t2_space X] [totally_disconnected_space X]\n\n/-- If there is a finite set of sets from `S` whose preimage forms a cover for `X`,\n  then there is a cover of `X` by clopen sets, with the image of each set being\n  contained in an element of `S`. -/\ndef set_clopen : set (set X) := {j : set X | ∃ (U : set X) (hU : U ∈ (B ε f)),\n    j ∈ classical.some (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens ε f hU))}\n\nlemma mem_set_clopen {x : set X} : x ∈ (set_clopen ε f) ↔ ∃ (U : set X) (hU : U ∈ (B ε f)),\n    x ∈ classical.some (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens ε f hU)) := iff.rfl\n\n/-- Elements of `set_clopen` are clopen. -/\nlemma set_clopen_sub_clopen_set : (set_clopen ε f) ⊆ {s : set X | is_clopen s} :=\nbegin\n  intros j hj,\n  obtain ⟨W, hW, hj⟩ := (mem_set_clopen ε f).1 hj,\n  obtain ⟨H, -⟩ := classical.some_spec (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens ε f hW)),\n  exact H hj,\nend\n\n/-- `set_clopen` covers X. -/\nlemma univ_sub_sUnion_set_clopen : set.univ ⊆ ⋃₀ (set_clopen ε f) :=\nbegin\n  rintros x hx, rw set.mem_sUnion,\n  have f' := @loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _,\n  have sUnion_sub_of_finset_sub := sUnion_sub_of_finset_sub ε f,\n-- writing `f⁻¹' U` as a union of basis elements (clopen sets)\n  conv at sUnion_sub_of_finset_sub { congr, skip, rw set.sUnion_eq_Union, congr, funext,\n    apply_congr classical.some_spec (classical.some_spec\n    (topological_space.is_topological_basis.open_eq_sUnion f' (opens ε f i.prop))), },\n  rw set.Union at sUnion_sub_of_finset_sub,\n  have g3 := sUnion_sub_of_finset_sub hx,\n  simp only [exists_prop, set.mem_Union, set.mem_range, set_coe.exists, exists_exists_eq_and,\n    set.supr_eq_Union, set.mem_set_of_eq, subtype.coe_mk] at g3,\n  rcases g3 with ⟨U, hU, a, ha, xa⟩,\n  refine ⟨a, _, xa⟩,\n  rw mem_set_clopen,\n  simp only [exists_prop, set.mem_range, exists_exists_eq_and, set.mem_set_of_eq],\n  refine ⟨U, hU, ha⟩,\nend\n\n/-- The image of each element of `set_clopen` is contained in an element of `S`. -/\nlemma exists_B_of_mem_clopen {x : set X} (hx : x ∈ set_clopen ε f) :\n  ∃ (U : set X) (H : U ∈ B ε f), x ⊆ U :=\nbegin\n  rcases hx with ⟨U, hU, xU⟩, refine ⟨U, hU, _⟩,\n  obtain ⟨H, H1⟩ := classical.some_spec\n    (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens ε f hU)),\n  rw H1, intros u hu, simp only [exists_prop, set.mem_set_of_eq],\n  refine ⟨x, _, hu⟩,\n  convert xU,\n  ext, simp only [exists_prop, iff_self],\nend\n\n/-- Every element of `set_clopen` is open. -/\nlemma mem_set_clopen_is_open (i : (set_clopen ε f)) : is_open (i : set X) :=\n topological_space.is_topological_basis.is_open (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _)\n  ((set_clopen_sub_clopen_set ε f) i.2)\n\n/-- A restatement of `univ_sub_sUnion_set_clopen`. -/\nlemma cover : (set.univ : set X) ⊆ ⋃ (i : (set_clopen ε f)), ↑i :=\nby { convert univ_sub_sUnion_set_clopen ε f, rw set.sUnion_eq_Union, }\n\n/-- Obtain a finite subcover of `set_clopen` using the compactness of `X`. -/\nnoncomputable abbreviation s' := classical.some (is_compact.elim_finite_subcover\n  (@compact_univ X _ _) _ (mem_set_clopen_is_open ε f) (cover ε f))\n\n/-- Coercing a subset of `set_clopen` in `s'` to `set X`. -/\nabbreviation s1 := λ (x : s' ε f), (x.1 : set X)\n\n/-- The range of `s1` is finite. -/\nlemma fin : (set.range (s1 ε f)).finite :=\nby { apply set.finite_range _, exact plift.fintype (s' ε f), }\n\n/-- Any element in the range of `s1` is clopen. -/\nlemma is_clopen_x {x : set X} (hx : x ∈ (fin ε f).to_finset) : is_clopen x :=\nbegin\n  simp only [set.mem_range, set_coe.exists, set.finite.mem_to_finset, finset.mem_coe] at hx,\n  rcases hx with ⟨⟨⟨v, hv⟩, hw⟩, hU⟩,\n  convert (set_clopen_sub_clopen_set ε f) hv,\n  rw ←hU,\n  delta s1,\n  simp,\nend\n\n/-- If there is a finite set of sets from `S` whose preimage forms a cover for `X`,\n  then there is a finset of `sets X` containing clopen sets, with the image of each set being\n  contained in an element of `S`. We use `s'` to get a finite disjoint clopen cover of `X`;\n  note : it is not a partition -/\nnoncomputable def finset_clopen : finset (set X) :=\n  classical.some (is_clopen.clopen_Union_disjoint\n    (set.finite.to_finset (fin ε f)) (λ x hx, (is_clopen_x ε f hx)))\n\n/-- Elements of `finset_clopen` are clopen. -/\nlemma finset_clopen_is_clopen {x : set X} (hx : x ∈ finset_clopen ε f) : is_clopen x :=\n  (classical.some_spec (is_clopen.clopen_Union_disjoint (set.finite.to_finset (fin ε f))\n    (λ x hx, (is_clopen_x ε f hx)))).1 x hx\n\n/-- The image of every element of `finset_clopen` is contained in some element of `S`. -/\nlemma exists_sub_S {x : set X} (hx : x ∈ finset_clopen ε f) :\n  ∃ U ∈ ((S ε) : set(set A)), (set.image f x : set A) ⊆ U :=\nbegin\n  rcases (classical.some_spec (is_clopen.clopen_Union_disjoint\n    (set.finite.to_finset (fin ε f)) (λ x hx, (is_clopen_x ε f hx)))).2.2.1 x hx with ⟨z, hz, wz⟩,\n  simp only [set.mem_range, set_coe.exists, set.finite.mem_to_finset, finset.mem_coe] at hz,\n  -- `z'` is a lift of `x` in `V`\n  rcases hz with ⟨⟨⟨z', h1⟩, h2⟩, h3⟩,\n  rcases exists_B_of_mem_clopen ε f h1 with ⟨U, BU, xU⟩,\n  simp only [exists_prop, exists_exists_eq_and, set.mem_set_of_eq] at BU,\n  cases BU with U' h4,\n  refine ⟨U', h4.1, _⟩, transitivity (set.image f z),\n  { apply set.image_subset _ wz, },\n  { simp only [set.image_subset_iff], rw [←h4.2, ←h3],\n    delta s1,\n    simp only [xU, subtype.coe_mk], },\nend\n\n/-- Showing that `finset_clopen` is a disjoint cover of `X`. -/\nlemma finset_clopen_prop (a : X) : ∃! (b ∈ finset_clopen ε f), a ∈ b :=\nbegin\n-- proving that every element `a : X` is contained in a unique element `j` of `s`\n  obtain ⟨j, hj, aj⟩ : ∃ j ∈ finset_clopen ε f, a ∈ j,\n  { -- `s'` covers `X`\n    have ha := classical.some_spec (is_compact.elim_finite_subcover\n      (@compact_univ X _ _) _ (mem_set_clopen_is_open ε f) (cover ε f)) (set.mem_univ a),\n    have hs := (classical.some_spec (is_clopen.clopen_Union_disjoint\n      (set.finite.to_finset (fin ε f)) (λ x hx, (is_clopen_x ε f hx)))).2.1,\n    delta s1 at hs,\n    suffices : a ∈ ⋃₀ (finset_clopen ε f : set(set X)),\n    { simp only [exists_prop, set.mem_set_of_eq, finset.mem_coe] at this,\n      cases this with j hj, refine ⟨j, hj.1, hj.2⟩, },\n    { rw finset_clopen,\n      rw ←hs,\n      simp only [set.mem_Union, set.finite.coe_to_finset, subtype.val_eq_coe, set.sUnion_range],\n      simp only [exists_prop, set.mem_Union, set_coe.exists, exists_and_distrib_right,\n        subtype.coe_mk] at ha,\n      -- have the element `U` of `V`, now translate it to `s`\n      rcases ha with ⟨U, ⟨hU, s'U⟩, aU⟩,\n      delta s',\n      refine ⟨⟨⟨U, hU⟩, s'U⟩, aU⟩, }, },\n  refine ⟨j, _, λ y hy, _⟩,\n  { -- existence\n    simp only [exists_prop, set.image_subset_iff, set.mem_range, exists_exists_eq_and,\n      exists_unique_iff_exists],\n    refine ⟨hj, aj⟩, },\n  { -- uniqueness, coming from the disjointness of the clopen cover, `disj`\n    simp only [exists_prop, exists_unique_iff_exists] at hy,\n    cases hy with h1 h2,\n    have disj := (classical.some_spec (is_clopen.clopen_Union_disjoint\n      (set.finite.to_finset (fin ε f)) (λ x hx, (is_clopen_x ε f hx)))).2.2.2 j y hj h1,\n    by_cases h : j = y,\n    { rw h.symm, },\n    { exfalso, specialize disj h, rw ←set.mem_empty_eq, rw ←disj,\n      apply set.mem_inter aj _,\n      simp only [and_true, implies_true_iff, eq_iff_true_of_subsingleton] at h2,\n      exact h2, }, },\nend\n\n/-- Takes a nonempty `s` in `finset_clopen` and returns an element of it. -/\nnoncomputable abbreviation c' := λ (s : set X) (H : s ∈ (finset_clopen ε f) ∧ nonempty s),\n  classical.choice (H.2)\n\n/-- Any `x` in `X` must belong to a unique `s` in `finset_clopen`. `c2` takes `x` to the image of\n  any element of `s` under `f`, which is the same `f x`. -/\nnoncomputable abbreviation c2 (f : C(X, A)) : X → A :=\nλ x, f (c' ε f (classical.some (exists_of_exists_unique (finset_clopen_prop ε f x)) )\nbegin\n  have := (exists_prop.1 (exists_of_exists_unique (classical.some_spec\n    (exists_of_exists_unique (finset_clopen_prop ε f x))))),\n  split,\n  refine finset.mem_coe.1 (this).1,\n  apply set.nonempty.to_subtype,\n  refine ⟨x, this.2⟩,\nend).\n\n/-- Any element of `finset_clopen` is open. -/\nlemma mem_finset_clopen_is_open {U : set X} (hU : U ∈ finset_clopen ε f) : is_open U :=\nby { rw finset_clopen at hU, apply (finset_clopen_is_clopen ε f hU).1, }\n\n/-- An equivalent version of `disj`. -/\nlemma mem_finset_clopen_unique' {U V : set X} {y : X}\n  (hU : U ∈ finset_clopen ε f) (hUy : y ∈ U) (hVy : y ∈ V) (hV : V ∈ finset_clopen ε f) : V = U :=\nbegin\n  by_contra,\n  have := (classical.some_spec (is_clopen.clopen_Union_disjoint\n    (set.finite.to_finset (fin ε f)) (λ x hx, (is_clopen_x ε f hx)))).2.2.2 _ _ hV hU h,\n  revert this,\n  --change (V ∩ U) ≠ ∅,\n  refine set.nonempty.ne_empty ⟨y, set.mem_inter hVy hUy⟩,\nend\n\n/-- Given `x` in `X`, there is a unique element `U` of `finset_clopen` such that `x ∈ U`. For any\n  `y ∈ U`, `y` is contained in any other element `V` of `finset_clopen` containing `x`. -/\nlemma mem_finset_clopen_unique {U V : set X} {x y : X}\n  (U_prop : (U ∈ finset_clopen ε f ∧ x ∈ U) ∧ ∀ (y : set X), y ∈ finset_clopen ε f →\n    x ∈ y → y = U) (hy : y ∈ U) (hV : V ∈ finset_clopen ε f) : x ∈ V ↔ y ∈ V :=\nbegin\n  obtain ⟨W, hW⟩ := finset_clopen_prop ε f y,\n  simp only [and_imp, exists_prop, exists_unique_iff_exists] at hW,\n  split; intro h,\n  { rw U_prop.2 V hV h, assumption, },\n  { rw hW.2 V hV h, rw ←(hW.2 U U_prop.1.1 hy), apply U_prop.1.2, },\nend\n\n/-- `c2` is locally constant -/\nlemma loc_const : is_locally_constant (c2 ε f) :=\nbegin\n  rw is_locally_constant.iff_exists_open, rintros x,\n  obtain ⟨U, hU⟩ := finset_clopen_prop ε f x,\n  simp only [and_imp, exists_prop, exists_unique_iff_exists] at hU,\n  refine ⟨U, mem_finset_clopen_is_open ε f hU.1.1, hU.1.2, λ x' hx', _⟩,\n  delta c2,\n  congr',\n  swap 4, ext y, revert y, rw ←set.ext_iff, congr, -- is there a better way to do this?\n  any_goals\n  { ext y, simp only [exists_prop, and.congr_right_iff, exists_unique_iff_exists],\n    intro hy, symmetry, apply mem_finset_clopen_unique ε f hU hx' hy, },\nend\n\n/-- Given an `f ∈ C(X, A)` and an `ε > 0`, one can find a locally constant function `b` which is in\n  an ε-ball with center `f`, `b` is precisely `c2`. -/\ntheorem loc_const_dense' : ∃ (b : C(X, A))\n  (H : b ∈ set.range (@locally_constant.to_continuous_map X A _ _)),\n  dist f b < ε := ⟨@locally_constant.to_continuous_map X A _ _ ⟨c2 ε f, loc_const ε f⟩, ⟨⟨c2 ε f, loc_const ε f⟩, rfl⟩,\n  gt_of_gt_of_ge (half_lt_self (fact.out _))\nbegin\n-- showing that the distance between `f` and `c2` is less than or equal to `ε/2`\n  rw [dist_eq_norm, continuous_map.norm_eq_supr_norm],\n  -- empty type is special case\n  cases is_empty_or_nonempty X with hempty hnonempty,\n  { change _ ≥ dite _ _ _,\n    split_ifs with h,\n    { rcases h with ⟨⟨_, x, _⟩, _⟩,\n      exact (@is_empty.false _ hempty x).elim },\n    exact le_of_lt (half_pos (fact.out _)) },\n-- writing the distance in terms of the sup norm\n  refine cSup_le _ (λ m hm, _),\n  { rw set.range_nonempty_iff_nonempty, assumption, }, -- this is where `nonempty X` is needed\n  { cases hm with y hy,\n    simp only [continuous_map.coe_sub, locally_constant.coe_mk,\n      locally_constant.to_continuous_map_linear_map_apply, pi.sub_apply,\n      locally_constant.coe_continuous_map] at hy,\n    rw ←hy,\n    -- reduced to proving ∥f(y) - c2(y)∥ ≤ ε/2\n    obtain ⟨w, wT, hw⟩ := finset_clopen_prop ε f y,\n    -- `w` is the unique element of `finset_clopen` to which `y` belongs\n    simp only [exists_prop, exists_unique_iff_exists] at wT,\n    simp only [and_imp, exists_prop, exists_unique_iff_exists] at hw,\n    have : c2 ε f y = f (c' ε f w ⟨wT.1, ⟨⟨y, wT.2⟩⟩⟩),\n    -- showing that `w` is the same as the `classical.some _` used in `c2`\n    { delta c2, congr',\n      any_goals\n      { have := classical.some_spec (exists_of_exists_unique (finset_clopen_prop ε f y)),\n        simp only [exists_prop, exists_unique_iff_exists] at *,\n        apply hw _ (this.1) (this.2), }, },\n    dsimp,\n    rw this,\n    obtain ⟨U, hU, wU⟩ := exists_sub_S ε f wT.1,\n    -- `U` is a set of `A` which is an element of `S` and contains `f(w)`\n    cases hU with z hz,\n    -- `U` is the `ε/4`-ball centered at `z`\n    have mem_U : f (c' ε f w ⟨wT.1, ⟨⟨y, wT.2⟩⟩⟩) ∈ U :=\n      wU ⟨(c' ε f w ⟨wT.1, ⟨⟨y, wT.2⟩⟩⟩), subtype.coe_prop _, rfl⟩,\n    have tS : f y ∈ U := wU ⟨y, wT.2, rfl⟩,\n    rw [hz.symm, mem_ball_iff_norm] at *,\n    conv_lhs { rw sub_eq_sub_add_sub _ _ z, },\n    -- unfolding everything in terms of `z`, and then using `mem_U` and `tS`\n    have : ε/2 = ε/4 + ε/4, { rw div_add_div_same, linarith, },\n    rw this, apply norm_add_le_of_le (le_of_lt _) (le_of_lt tS),\n    rw ←norm_neg _, simp only [mem_U, neg_sub], },\nend ⟩\n\nvariable (X)\n/-- The locally constant functions from `X` to `A` (viewed as a subset of C(X, A)) are dense\n  in C(X, A). -/\ntheorem loc_const_dense : dense (set.range (@locally_constant.to_continuous_map X A _ _)) :=\n  λ f, begin\n  rw metric.mem_closure_iff,\n  rintros ε hε,\n  haveI : fact (0 < ε) := fact.mk hε,\n-- we have all the ingredients from `loc_const_dense'`, only need `exists_finset_univ_sub_prop`\n  apply loc_const_dense' ε f,\nend\n\nend locally_constant.density\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/locally_constant/completion_aux.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.46894613858794754}}
{"text": "/-\nCopyright (c) 2021 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker, Bhavik Mehta\n\n! This file was ported from Lean 3 source module measure_theory.integral.integral_eq_improper\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.MeasureTheory.Integral.IntervalIntegral\nimport Mathbin.Order.Filter.AtTopBot\nimport Mathbin.MeasureTheory.Function.Jacobian\n\n/-!\n# Links between an integral and its \"improper\" version\n\nIn its current state, mathlib only knows how to talk about definite (\"proper\") integrals,\nin the sense that it treats integrals over `[x, +∞)` the same as it treats integrals over\n`[y, z]`. For example, the integral over `[1, +∞)` is **not** defined to be the limit of\nthe integral over `[1, x]` as `x` tends to `+∞`, which is known as an **improper integral**.\n\nIndeed, the \"proper\" definition is stronger than the \"improper\" one. The usual counterexample\nis `x ↦ sin(x)/x`, which has an improper integral over `[1, +∞)` but no definite integral.\n\nAlthough definite integrals have better properties, they are hardly usable when it comes to\ncomputing integrals on unbounded sets, which is much easier using limits. Thus, in this file,\nwe prove various ways of studying the proper integral by studying the improper one.\n\n## Definitions\n\nThe main definition of this file is `measure_theory.ae_cover`. It is a rather technical\ndefinition whose sole purpose is generalizing and factoring proofs. Given an index type `ι`, a\ncountably generated filter `l` over `ι`, and an `ι`-indexed family `φ` of subsets of a measurable\nspace `α` equipped with a measure `μ`, one should think of a hypothesis `hφ : ae_cover μ l φ` as\na sufficient condition for being able to interpret `∫ x, f x ∂μ` (if it exists) as the limit\nof `∫ x in φ i, f x ∂μ` as `i` tends to `l`.\n\nWhen using this definition with a measure restricted to a set `s`, which happens fairly often,\none should not try too hard to use a `ae_cover` of subsets of `s`, as it often makes proofs\nmore complicated than necessary. See for example the proof of\n`measure_theory.integrable_on_Iic_of_interval_integral_norm_tendsto` where we use `(λ x, Ioi x)`\nas an `ae_cover` w.r.t. `μ.restrict (Iic b)`, instead of using `(λ x, Ioc x b)`.\n\n## Main statements\n\n- `measure_theory.ae_cover.lintegral_tendsto_of_countably_generated` : if `φ` is a `ae_cover μ l`,\n  where `l` is a countably generated filter, and if `f` is a measurable `ennreal`-valued function,\n  then `∫⁻ x in φ n, f x ∂μ` tends to `∫⁻ x, f x ∂μ` as `n` tends to `l`\n- `measure_theory.ae_cover.integrable_of_integral_norm_tendsto` : if `φ` is a `ae_cover μ l`,\n  where `l` is a countably generated filter, if `f` is measurable and integrable on each `φ n`,\n  and if `∫ x in φ n, ‖f x‖ ∂μ` tends to some `I : ℝ` as n tends to `l`, then `f` is integrable\n- `measure_theory.ae_cover.integral_tendsto_of_countably_generated` : if `φ` is a `ae_cover μ l`,\n  where `l` is a countably generated filter, and if `f` is measurable and integrable (globally),\n  then `∫ x in φ n, f x ∂μ` tends to `∫ x, f x ∂μ` as `n` tends to `+∞`.\n\nWe then specialize these lemmas to various use cases involving intervals, which are frequent\nin analysis.\n-/\n\n\nopen MeasureTheory Filter Set TopologicalSpace\n\nopen ENNReal NNReal Topology\n\nnamespace MeasureTheory\n\nsection AeCover\n\nvariable {α ι : Type _} [MeasurableSpace α] (μ : Measure α) (l : Filter ι)\n\n/-- A sequence `φ` of subsets of `α` is a `ae_cover` w.r.t. a measure `μ` and a filter `l`\n    if almost every point (w.r.t. `μ`) of `α` eventually belongs to `φ n` (w.r.t. `l`), and if\n    each `φ n` is measurable.\n    This definition is a technical way to avoid duplicating a lot of proofs.\n    It should be thought of as a sufficient condition for being able to interpret\n    `∫ x, f x ∂μ` (if it exists) as the limit of `∫ x in φ n, f x ∂μ` as `n` tends to `l`.\n\n    See for example `measure_theory.ae_cover.lintegral_tendsto_of_countably_generated`,\n    `measure_theory.ae_cover.integrable_of_integral_norm_tendsto` and\n    `measure_theory.ae_cover.integral_tendsto_of_countably_generated`. -/\nstructure AeCover (φ : ι → Set α) : Prop where\n  ae_eventually_mem : ∀ᵐ x ∂μ, ∀ᶠ i in l, x ∈ φ i\n  Measurable : ∀ i, MeasurableSet <| φ i\n#align measure_theory.ae_cover MeasureTheory.AeCover\n\nvariable {μ} {l}\n\nsection Preorderα\n\nvariable [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [OpensMeasurableSpace α]\n  {a b : ι → α} (ha : Tendsto a l atBot) (hb : Tendsto b l atTop)\n\ntheorem aeCoverIcc : AeCover μ l fun i => Icc (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x =>\n        (ha.Eventually <| eventually_le_atBot x).mp <|\n          (hb.Eventually <| eventually_ge_atTop x).mono fun i hbi hai => ⟨hai, hbi⟩\n    Measurable := fun i => measurableSet_Icc }\n#align measure_theory.ae_cover_Icc MeasureTheory.aeCoverIcc\n\ntheorem aeCoverIci : AeCover μ l fun i => Ici <| a i :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x => (ha.Eventually <| eventually_le_atBot x).mono fun i hai => hai\n    Measurable := fun i => measurableSet_Ici }\n#align measure_theory.ae_cover_Ici MeasureTheory.aeCoverIci\n\ntheorem aeCoverIic : AeCover μ l fun i => Iic <| b i :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x => (hb.Eventually <| eventually_ge_atTop x).mono fun i hbi => hbi\n    Measurable := fun i => measurableSet_Iic }\n#align measure_theory.ae_cover_Iic MeasureTheory.aeCoverIic\n\nend Preorderα\n\nsection LinearOrderα\n\nvariable [LinearOrder α] [TopologicalSpace α] [OrderClosedTopology α] [OpensMeasurableSpace α]\n  {a b : ι → α} (ha : Tendsto a l atBot) (hb : Tendsto b l atTop)\n\ntheorem aeCoverIoo [NoMinOrder α] [NoMaxOrder α] : AeCover μ l fun i => Ioo (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x =>\n        (ha.Eventually <| eventually_lt_atBot x).mp <|\n          (hb.Eventually <| eventually_gt_atTop x).mono fun i hbi hai => ⟨hai, hbi⟩\n    Measurable := fun i => measurableSet_Ioo }\n#align measure_theory.ae_cover_Ioo MeasureTheory.aeCoverIoo\n\ntheorem aeCoverIoc [NoMinOrder α] : AeCover μ l fun i => Ioc (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x =>\n        (ha.Eventually <| eventually_lt_atBot x).mp <|\n          (hb.Eventually <| eventually_ge_atTop x).mono fun i hbi hai => ⟨hai, hbi⟩\n    Measurable := fun i => measurableSet_Ioc }\n#align measure_theory.ae_cover_Ioc MeasureTheory.aeCoverIoc\n\ntheorem aeCoverIco [NoMaxOrder α] : AeCover μ l fun i => Ico (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x =>\n        (ha.Eventually <| eventually_le_atBot x).mp <|\n          (hb.Eventually <| eventually_gt_atTop x).mono fun i hbi hai => ⟨hai, hbi⟩\n    Measurable := fun i => measurableSet_Ico }\n#align measure_theory.ae_cover_Ico MeasureTheory.aeCoverIco\n\ntheorem aeCoverIoi [NoMinOrder α] : AeCover μ l fun i => Ioi <| a i :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x => (ha.Eventually <| eventually_lt_atBot x).mono fun i hai => hai\n    Measurable := fun i => measurableSet_Ioi }\n#align measure_theory.ae_cover_Ioi MeasureTheory.aeCoverIoi\n\ntheorem aeCoverIio [NoMaxOrder α] : AeCover μ l fun i => Iio <| b i :=\n  { ae_eventually_mem :=\n      ae_of_all μ fun x => (hb.Eventually <| eventually_gt_atTop x).mono fun i hbi => hbi\n    Measurable := fun i => measurableSet_Iio }\n#align measure_theory.ae_cover_Iio MeasureTheory.aeCoverIio\n\nend LinearOrderα\n\nsection FiniteIntervals\n\nvariable [LinearOrder α] [TopologicalSpace α] [OrderClosedTopology α] [OpensMeasurableSpace α]\n  {a b : ι → α} {A B : α} (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B))\n\ntheorem aeCoverIooOfIcc : AeCover (μ.restrict <| Ioo A B) l fun i => Icc (a i) (b i) :=\n  { ae_eventually_mem :=\n      (ae_restrict_iff' measurableSet_Ioo).mpr\n        (ae_of_all μ fun x hx =>\n          (ha.Eventually <| eventually_le_nhds hx.left).mp <|\n            (hb.Eventually <| eventually_ge_nhds hx.right).mono fun i hbi hai => ⟨hai, hbi⟩)\n    Measurable := fun i => measurableSet_Icc }\n#align measure_theory.ae_cover_Ioo_of_Icc MeasureTheory.aeCoverIooOfIcc\n\ntheorem aeCoverIooOfIco : AeCover (μ.restrict <| Ioo A B) l fun i => Ico (a i) (b i) :=\n  { ae_eventually_mem :=\n      (ae_restrict_iff' measurableSet_Ioo).mpr\n        (ae_of_all μ fun x hx =>\n          (ha.Eventually <| eventually_le_nhds hx.left).mp <|\n            (hb.Eventually <| eventually_gt_nhds hx.right).mono fun i hbi hai => ⟨hai, hbi⟩)\n    Measurable := fun i => measurableSet_Ico }\n#align measure_theory.ae_cover_Ioo_of_Ico MeasureTheory.aeCoverIooOfIco\n\ntheorem aeCoverIooOfIoc : AeCover (μ.restrict <| Ioo A B) l fun i => Ioc (a i) (b i) :=\n  { ae_eventually_mem :=\n      (ae_restrict_iff' measurableSet_Ioo).mpr\n        (ae_of_all μ fun x hx =>\n          (ha.Eventually <| eventually_lt_nhds hx.left).mp <|\n            (hb.Eventually <| eventually_ge_nhds hx.right).mono fun i hbi hai => ⟨hai, hbi⟩)\n    Measurable := fun i => measurableSet_Ioc }\n#align measure_theory.ae_cover_Ioo_of_Ioc MeasureTheory.aeCoverIooOfIoc\n\ntheorem aeCoverIooOfIoo : AeCover (μ.restrict <| Ioo A B) l fun i => Ioo (a i) (b i) :=\n  { ae_eventually_mem :=\n      (ae_restrict_iff' measurableSet_Ioo).mpr\n        (ae_of_all μ fun x hx =>\n          (ha.Eventually <| eventually_lt_nhds hx.left).mp <|\n            (hb.Eventually <| eventually_gt_nhds hx.right).mono fun i hbi hai => ⟨hai, hbi⟩)\n    Measurable := fun i => measurableSet_Ioo }\n#align measure_theory.ae_cover_Ioo_of_Ioo MeasureTheory.aeCoverIooOfIoo\n\nvariable [HasNoAtoms μ]\n\ntheorem aeCoverIocOfIcc (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ioc A B) l fun i => Icc (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ioc.symm, ae_cover_Ioo_of_Icc ha hb]\n#align measure_theory.ae_cover_Ioc_of_Icc MeasureTheory.aeCoverIocOfIcc\n\ntheorem aeCoverIocOfIco (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ioc A B) l fun i => Ico (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ioc.symm, ae_cover_Ioo_of_Ico ha hb]\n#align measure_theory.ae_cover_Ioc_of_Ico MeasureTheory.aeCoverIocOfIco\n\ntheorem aeCoverIocOfIoc (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ioc A B) l fun i => Ioc (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ioc.symm, ae_cover_Ioo_of_Ioc ha hb]\n#align measure_theory.ae_cover_Ioc_of_Ioc MeasureTheory.aeCoverIocOfIoc\n\ntheorem aeCoverIocOfIoo (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ioc A B) l fun i => Ioo (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ioc.symm, ae_cover_Ioo_of_Ioo ha hb]\n#align measure_theory.ae_cover_Ioc_of_Ioo MeasureTheory.aeCoverIocOfIoo\n\ntheorem aeCoverIcoOfIcc (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ico A B) l fun i => Icc (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ico.symm, ae_cover_Ioo_of_Icc ha hb]\n#align measure_theory.ae_cover_Ico_of_Icc MeasureTheory.aeCoverIcoOfIcc\n\ntheorem aeCoverIcoOfIco (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ico A B) l fun i => Ico (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ico.symm, ae_cover_Ioo_of_Ico ha hb]\n#align measure_theory.ae_cover_Ico_of_Ico MeasureTheory.aeCoverIcoOfIco\n\ntheorem aeCoverIcoOfIoc (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ico A B) l fun i => Ioc (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ico.symm, ae_cover_Ioo_of_Ioc ha hb]\n#align measure_theory.ae_cover_Ico_of_Ioc MeasureTheory.aeCoverIcoOfIoc\n\ntheorem aeCoverIcoOfIoo (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Ico A B) l fun i => Ioo (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Ico.symm, ae_cover_Ioo_of_Ioo ha hb]\n#align measure_theory.ae_cover_Ico_of_Ioo MeasureTheory.aeCoverIcoOfIoo\n\ntheorem aeCoverIccOfIcc (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Icc A B) l fun i => Icc (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Icc.symm, ae_cover_Ioo_of_Icc ha hb]\n#align measure_theory.ae_cover_Icc_of_Icc MeasureTheory.aeCoverIccOfIcc\n\ntheorem aeCoverIccOfIco (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Icc A B) l fun i => Ico (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Icc.symm, ae_cover_Ioo_of_Ico ha hb]\n#align measure_theory.ae_cover_Icc_of_Ico MeasureTheory.aeCoverIccOfIco\n\ntheorem aeCoverIccOfIoc (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Icc A B) l fun i => Ioc (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Icc.symm, ae_cover_Ioo_of_Ioc ha hb]\n#align measure_theory.ae_cover_Icc_of_Ioc MeasureTheory.aeCoverIccOfIoc\n\ntheorem aeCoverIccOfIoo (ha : Tendsto a l (𝓝 A)) (hb : Tendsto b l (𝓝 B)) :\n    AeCover (μ.restrict <| Icc A B) l fun i => Ioo (a i) (b i) := by\n  simp [measure.restrict_congr_set Ioo_ae_eq_Icc.symm, ae_cover_Ioo_of_Ioo ha hb]\n#align measure_theory.ae_cover_Icc_of_Ioo MeasureTheory.aeCoverIccOfIoo\n\nend FiniteIntervals\n\ntheorem AeCover.restrict {φ : ι → Set α} (hφ : AeCover μ l φ) {s : Set α} :\n    AeCover (μ.restrict s) l φ :=\n  { ae_eventually_mem := ae_restrict_of_ae hφ.ae_eventually_mem\n    Measurable := hφ.Measurable }\n#align measure_theory.ae_cover.restrict MeasureTheory.AeCover.restrict\n\ntheorem aeCoverRestrictOfAeImp {s : Set α} {φ : ι → Set α} (hs : MeasurableSet s)\n    (ae_eventually_mem : ∀ᵐ x ∂μ, x ∈ s → ∀ᶠ n in l, x ∈ φ n)\n    (measurable : ∀ n, MeasurableSet <| φ n) : AeCover (μ.restrict s) l φ :=\n  { ae_eventually_mem := by rwa [ae_restrict_iff' hs]\n    Measurable }\n#align measure_theory.ae_cover_restrict_of_ae_imp MeasureTheory.aeCoverRestrictOfAeImp\n\ntheorem AeCover.interRestrict {φ : ι → Set α} (hφ : AeCover μ l φ) {s : Set α}\n    (hs : MeasurableSet s) : AeCover (μ.restrict s) l fun i => φ i ∩ s :=\n  aeCoverRestrictOfAeImp hs\n    (hφ.ae_eventually_mem.mono fun x hx hxs => hx.mono fun i hi => ⟨hi, hxs⟩) fun i =>\n    (hφ.Measurable i).inter hs\n#align measure_theory.ae_cover.inter_restrict MeasureTheory.AeCover.interRestrict\n\ntheorem AeCover.ae_tendsto_indicator {β : Type _} [Zero β] [TopologicalSpace β] (f : α → β)\n    {φ : ι → Set α} (hφ : AeCover μ l φ) :\n    ∀ᵐ x ∂μ, Tendsto (fun i => (φ i).indicator f x) l (𝓝 <| f x) :=\n  hφ.ae_eventually_mem.mono fun x hx =>\n    tendsto_const_nhds.congr' <| hx.mono fun n hn => (indicator_of_mem hn _).symm\n#align measure_theory.ae_cover.ae_tendsto_indicator MeasureTheory.AeCover.ae_tendsto_indicator\n\ntheorem AeCover.aeMeasurable {β : Type _} [MeasurableSpace β] [l.IsCountablyGenerated] [l.ne_bot]\n    {f : α → β} {φ : ι → Set α} (hφ : AeCover μ l φ)\n    (hfm : ∀ i, AeMeasurable f (μ.restrict <| φ i)) : AeMeasurable f μ :=\n  by\n  obtain ⟨u, hu⟩ := l.exists_seq_tendsto\n  have := ae_measurable_Union_iff.mpr fun n : ℕ => hfm (u n)\n  rwa [measure.restrict_eq_self_of_ae_mem] at this\n  filter_upwards [hφ.ae_eventually_mem]with x hx using let ⟨i, hi⟩ := (hu.eventually hx).exists\n    mem_Union.mpr ⟨i, hi⟩\n#align measure_theory.ae_cover.ae_measurable MeasureTheory.AeCover.aeMeasurable\n\ntheorem AeCover.aeStronglyMeasurable {β : Type _} [TopologicalSpace β] [PseudoMetrizableSpace β]\n    [l.IsCountablyGenerated] [l.ne_bot] {f : α → β} {φ : ι → Set α} (hφ : AeCover μ l φ)\n    (hfm : ∀ i, AeStronglyMeasurable f (μ.restrict <| φ i)) : AeStronglyMeasurable f μ :=\n  by\n  obtain ⟨u, hu⟩ := l.exists_seq_tendsto\n  have := ae_strongly_measurable_Union_iff.mpr fun n : ℕ => hfm (u n)\n  rwa [measure.restrict_eq_self_of_ae_mem] at this\n  filter_upwards [hφ.ae_eventually_mem]with x hx using let ⟨i, hi⟩ := (hu.eventually hx).exists\n    mem_Union.mpr ⟨i, hi⟩\n#align measure_theory.ae_cover.ae_strongly_measurable MeasureTheory.AeCover.aeStronglyMeasurable\n\nend AeCover\n\ntheorem AeCover.compTendsto {α ι ι' : Type _} [MeasurableSpace α] {μ : Measure α} {l : Filter ι}\n    {l' : Filter ι'} {φ : ι → Set α} (hφ : AeCover μ l φ) {u : ι' → ι} (hu : Tendsto u l' l) :\n    AeCover μ l' (φ ∘ u) :=\n  { ae_eventually_mem := hφ.ae_eventually_mem.mono fun x hx => hu.Eventually hx\n    Measurable := fun i => hφ.Measurable (u i) }\n#align measure_theory.ae_cover.comp_tendsto MeasureTheory.AeCover.compTendsto\n\nsection AeCoverUnionInterCountable\n\nvariable {α ι : Type _} [Countable ι] [MeasurableSpace α] {μ : Measure α}\n\ntheorem AeCover.bUnionIicAeCover [Preorder ι] {φ : ι → Set α} (hφ : AeCover μ atTop φ) :\n    AeCover μ atTop fun n : ι => ⋃ (k) (h : k ∈ Iic n), φ k :=\n  { ae_eventually_mem :=\n      hφ.ae_eventually_mem.mono fun x h => h.mono fun i hi => mem_bunionᵢ right_mem_Iic hi\n    Measurable := fun i => MeasurableSet.bunionᵢ (to_countable _) fun n _ => hφ.Measurable n }\n#align measure_theory.ae_cover.bUnion_Iic_ae_cover MeasureTheory.AeCover.bUnionIicAeCover\n\ntheorem AeCover.bInterIciAeCover [SemilatticeSup ι] [Nonempty ι] {φ : ι → Set α}\n    (hφ : AeCover μ atTop φ) : AeCover μ atTop fun n : ι => ⋂ (k) (h : k ∈ Ici n), φ k :=\n  { ae_eventually_mem :=\n      hφ.ae_eventually_mem.mono\n        (by\n          intro x h\n          rw [eventually_at_top] at *\n          rcases h with ⟨i, hi⟩\n          use i\n          intro j hj\n          exact mem_bInter fun k hk => hi k (le_trans hj hk))\n    Measurable := fun i => MeasurableSet.binterᵢ (to_countable _) fun n _ => hφ.Measurable n }\n#align measure_theory.ae_cover.bInter_Ici_ae_cover MeasureTheory.AeCover.bInterIciAeCover\n\nend AeCoverUnionInterCountable\n\nsection Lintegral\n\nvariable {α ι : Type _} [MeasurableSpace α] {μ : Measure α} {l : Filter ι}\n\nprivate theorem lintegral_tendsto_of_monotone_of_nat {φ : ℕ → Set α} (hφ : AeCover μ atTop φ)\n    (hmono : Monotone φ) {f : α → ℝ≥0∞} (hfm : AeMeasurable f μ) :\n    Tendsto (fun i => ∫⁻ x in φ i, f x ∂μ) atTop (𝓝 <| ∫⁻ x, f x ∂μ) :=\n  let F n := (φ n).indicator f\n  have key₁ : ∀ n, AeMeasurable (F n) μ := fun n => hfm.indicator (hφ.Measurable n)\n  have key₂ : ∀ᵐ x : α ∂μ, Monotone fun n => F n x :=\n    ae_of_all _ fun x i j hij =>\n      indicator_le_indicator_of_subset (hmono hij) (fun x => zero_le <| f x) x\n  have key₃ : ∀ᵐ x : α ∂μ, Tendsto (fun n => F n x) atTop (𝓝 (f x)) := hφ.ae_tendsto_indicator f\n  (lintegral_tendsto_of_tendsto_of_monotone key₁ key₂ key₃).congr fun n =>\n    lintegral_indicator f (hφ.Measurable n)\n#align measure_theory.lintegral_tendsto_of_monotone_of_nat measure_theory.lintegral_tendsto_of_monotone_of_nat\n\ntheorem AeCover.lintegral_tendsto_of_nat {φ : ℕ → Set α} (hφ : AeCover μ atTop φ) {f : α → ℝ≥0∞}\n    (hfm : AeMeasurable f μ) : Tendsto (fun i => ∫⁻ x in φ i, f x ∂μ) atTop (𝓝 <| ∫⁻ x, f x ∂μ) :=\n  by\n  have lim₁ :=\n    lintegral_tendsto_of_monotone_of_nat hφ.bInter_Ici_ae_cover\n      (fun i j hij => bInter_subset_bInter_left (Ici_subset_Ici.mpr hij)) hfm\n  have lim₂ :=\n    lintegral_tendsto_of_monotone_of_nat hφ.bUnion_Iic_ae_cover\n      (fun i j hij => bUnion_subset_bUnion_left (Iic_subset_Iic.mpr hij)) hfm\n  have le₁ := fun n => lintegral_mono_set (bInter_subset_of_mem left_mem_Ici)\n  have le₂ := fun n => lintegral_mono_set (subset_bUnion_of_mem right_mem_Iic)\n  exact tendsto_of_tendsto_of_tendsto_of_le_of_le lim₁ lim₂ le₁ le₂\n#align measure_theory.ae_cover.lintegral_tendsto_of_nat MeasureTheory.AeCover.lintegral_tendsto_of_nat\n\ntheorem AeCover.lintegral_tendsto_of_countably_generated [l.IsCountablyGenerated] {φ : ι → Set α}\n    (hφ : AeCover μ l φ) {f : α → ℝ≥0∞} (hfm : AeMeasurable f μ) :\n    Tendsto (fun i => ∫⁻ x in φ i, f x ∂μ) l (𝓝 <| ∫⁻ x, f x ∂μ) :=\n  tendsto_of_seq_tendsto fun u hu => (hφ.comp_tendsto hu).lintegral_tendsto_of_nat hfm\n#align measure_theory.ae_cover.lintegral_tendsto_of_countably_generated MeasureTheory.AeCover.lintegral_tendsto_of_countably_generated\n\ntheorem AeCover.lintegral_eq_of_tendsto [l.ne_bot] [l.IsCountablyGenerated] {φ : ι → Set α}\n    (hφ : AeCover μ l φ) {f : α → ℝ≥0∞} (I : ℝ≥0∞) (hfm : AeMeasurable f μ)\n    (htendsto : Tendsto (fun i => ∫⁻ x in φ i, f x ∂μ) l (𝓝 I)) : (∫⁻ x, f x ∂μ) = I :=\n  tendsto_nhds_unique (hφ.lintegral_tendsto_of_countably_generated hfm) htendsto\n#align measure_theory.ae_cover.lintegral_eq_of_tendsto MeasureTheory.AeCover.lintegral_eq_of_tendsto\n\ntheorem AeCover.supᵢ_lintegral_eq_of_countably_generated [Nonempty ι] [l.ne_bot]\n    [l.IsCountablyGenerated] {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → ℝ≥0∞}\n    (hfm : AeMeasurable f μ) : (⨆ i : ι, ∫⁻ x in φ i, f x ∂μ) = ∫⁻ x, f x ∂μ :=\n  by\n  have := hφ.lintegral_tendsto_of_countably_generated hfm\n  refine'\n    csupᵢ_eq_of_forall_le_of_forall_lt_exists_gt\n      (fun i => lintegral_mono' measure.restrict_le_self le_rfl) fun w hw => _\n  rcases exists_between hw with ⟨m, hm₁, hm₂⟩\n  rcases(eventually_ge_of_tendsto_gt hm₂ this).exists with ⟨i, hi⟩\n  exact ⟨i, lt_of_lt_of_le hm₁ hi⟩\n#align measure_theory.ae_cover.supr_lintegral_eq_of_countably_generated MeasureTheory.AeCover.supᵢ_lintegral_eq_of_countably_generated\n\nend Lintegral\n\nsection Integrable\n\nvariable {α ι E : Type _} [MeasurableSpace α] {μ : Measure α} {l : Filter ι} [NormedAddCommGroup E]\n\ntheorem AeCover.integrableOfLintegralNnnormBounded [l.ne_bot] [l.IsCountablyGenerated]\n    {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → E} (I : ℝ) (hfm : AeStronglyMeasurable f μ)\n    (hbounded : ∀ᶠ i in l, (∫⁻ x in φ i, ‖f x‖₊ ∂μ) ≤ ENNReal.ofReal I) : Integrable f μ :=\n  by\n  refine' ⟨hfm, (le_of_tendsto _ hbounded).trans_lt ENNReal.ofReal_lt_top⟩\n  exact hφ.lintegral_tendsto_of_countably_generated hfm.ennnorm\n#align measure_theory.ae_cover.integrable_of_lintegral_nnnorm_bounded MeasureTheory.AeCover.integrableOfLintegralNnnormBounded\n\ntheorem AeCover.integrableOfLintegralNnnormTendsto [l.ne_bot] [l.IsCountablyGenerated]\n    {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → E} (I : ℝ) (hfm : AeStronglyMeasurable f μ)\n    (htendsto : Tendsto (fun i => ∫⁻ x in φ i, ‖f x‖₊ ∂μ) l (𝓝 <| ENNReal.ofReal I)) :\n    Integrable f μ :=\n  by\n  refine' hφ.integrable_of_lintegral_nnnorm_bounded (max 1 (I + 1)) hfm _\n  refine' htendsto.eventually (ge_mem_nhds _)\n  refine' (ENNReal.ofReal_lt_ofReal_iff (lt_max_of_lt_left zero_lt_one)).2 _\n  exact lt_max_of_lt_right (lt_add_one I)\n#align measure_theory.ae_cover.integrable_of_lintegral_nnnorm_tendsto MeasureTheory.AeCover.integrableOfLintegralNnnormTendsto\n\ntheorem AeCover.integrableOfLintegralNnnormBounded' [l.ne_bot] [l.IsCountablyGenerated]\n    {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → E} (I : ℝ≥0) (hfm : AeStronglyMeasurable f μ)\n    (hbounded : ∀ᶠ i in l, (∫⁻ x in φ i, ‖f x‖₊ ∂μ) ≤ I) : Integrable f μ :=\n  hφ.integrableOfLintegralNnnormBounded I hfm\n    (by simpa only [ENNReal.ofReal_coe_nnreal] using hbounded)\n#align measure_theory.ae_cover.integrable_of_lintegral_nnnorm_bounded' MeasureTheory.AeCover.integrableOfLintegralNnnormBounded'\n\ntheorem AeCover.integrableOfLintegralNnnormTendsto' [l.ne_bot] [l.IsCountablyGenerated]\n    {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → E} (I : ℝ≥0) (hfm : AeStronglyMeasurable f μ)\n    (htendsto : Tendsto (fun i => ∫⁻ x in φ i, ‖f x‖₊ ∂μ) l (𝓝 I)) : Integrable f μ :=\n  hφ.integrableOfLintegralNnnormTendsto I hfm\n    (by simpa only [ENNReal.ofReal_coe_nnreal] using htendsto)\n#align measure_theory.ae_cover.integrable_of_lintegral_nnnorm_tendsto' MeasureTheory.AeCover.integrableOfLintegralNnnormTendsto'\n\ntheorem AeCover.integrableOfIntegralNormBounded [l.ne_bot] [l.IsCountablyGenerated] {φ : ι → Set α}\n    (hφ : AeCover μ l φ) {f : α → E} (I : ℝ) (hfi : ∀ i, IntegrableOn f (φ i) μ)\n    (hbounded : ∀ᶠ i in l, (∫ x in φ i, ‖f x‖ ∂μ) ≤ I) : Integrable f μ :=\n  by\n  have hfm : ae_strongly_measurable f μ :=\n    hφ.ae_strongly_measurable fun i => (hfi i).AeStronglyMeasurable\n  refine' hφ.integrable_of_lintegral_nnnorm_bounded I hfm _\n  conv at hbounded in integral _ _ =>\n    rw [integral_eq_lintegral_of_nonneg_ae (ae_of_all _ fun x => @norm_nonneg E _ (f x))\n        hfm.norm.restrict]\n  conv at hbounded in ENNReal.ofReal _ =>\n    dsimp\n    rw [← coe_nnnorm]\n    rw [ENNReal.ofReal_coe_nnreal]\n  refine' hbounded.mono fun i hi => _\n  rw [← ENNReal.ofReal_toReal (ne_top_of_lt (hfi i).2)]\n  apply ENNReal.ofReal_le_ofReal hi\n#align measure_theory.ae_cover.integrable_of_integral_norm_bounded MeasureTheory.AeCover.integrableOfIntegralNormBounded\n\ntheorem AeCover.integrableOfIntegralNormTendsto [l.ne_bot] [l.IsCountablyGenerated] {φ : ι → Set α}\n    (hφ : AeCover μ l φ) {f : α → E} (I : ℝ) (hfi : ∀ i, IntegrableOn f (φ i) μ)\n    (htendsto : Tendsto (fun i => ∫ x in φ i, ‖f x‖ ∂μ) l (𝓝 I)) : Integrable f μ :=\n  let ⟨I', hI'⟩ := htendsto.isBoundedUnder_le\n  hφ.integrableOfIntegralNormBounded I' hfi hI'\n#align measure_theory.ae_cover.integrable_of_integral_norm_tendsto MeasureTheory.AeCover.integrableOfIntegralNormTendsto\n\ntheorem AeCover.integrableOfIntegralBoundedOfNonnegAe [l.ne_bot] [l.IsCountablyGenerated]\n    {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → ℝ} (I : ℝ) (hfi : ∀ i, IntegrableOn f (φ i) μ)\n    (hnng : ∀ᵐ x ∂μ, 0 ≤ f x) (hbounded : ∀ᶠ i in l, (∫ x in φ i, f x ∂μ) ≤ I) : Integrable f μ :=\n  hφ.integrableOfIntegralNormBounded I hfi <|\n    hbounded.mono fun i hi =>\n      (integral_congr_ae <| ae_restrict_of_ae <| hnng.mono fun x => Real.norm_of_nonneg).le.trans hi\n#align measure_theory.ae_cover.integrable_of_integral_bounded_of_nonneg_ae MeasureTheory.AeCover.integrableOfIntegralBoundedOfNonnegAe\n\ntheorem AeCover.integrableOfIntegralTendstoOfNonnegAe [l.ne_bot] [l.IsCountablyGenerated]\n    {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → ℝ} (I : ℝ) (hfi : ∀ i, IntegrableOn f (φ i) μ)\n    (hnng : ∀ᵐ x ∂μ, 0 ≤ f x) (htendsto : Tendsto (fun i => ∫ x in φ i, f x ∂μ) l (𝓝 I)) :\n    Integrable f μ :=\n  let ⟨I', hI'⟩ := htendsto.isBoundedUnder_le\n  hφ.integrableOfIntegralBoundedOfNonnegAe I' hfi hnng hI'\n#align measure_theory.ae_cover.integrable_of_integral_tendsto_of_nonneg_ae MeasureTheory.AeCover.integrableOfIntegralTendstoOfNonnegAe\n\nend Integrable\n\nsection Integral\n\nvariable {α ι E : Type _} [MeasurableSpace α] {μ : Measure α} {l : Filter ι} [NormedAddCommGroup E]\n  [NormedSpace ℝ E] [CompleteSpace E]\n\ntheorem AeCover.integral_tendsto_of_countably_generated [l.IsCountablyGenerated] {φ : ι → Set α}\n    (hφ : AeCover μ l φ) {f : α → E} (hfi : Integrable f μ) :\n    Tendsto (fun i => ∫ x in φ i, f x ∂μ) l (𝓝 <| ∫ x, f x ∂μ) :=\n  suffices h : Tendsto (fun i => ∫ x : α, (φ i).indicator f x ∂μ) l (𝓝 (∫ x : α, f x ∂μ)) from\n    by\n    convert h\n    ext n\n    rw [integral_indicator (hφ.measurable n)]\n  tendsto_integral_filter_of_dominated_convergence (fun x => ‖f x‖)\n    (eventually_of_forall fun i => hfi.AeStronglyMeasurable.indicator <| hφ.Measurable i)\n    (eventually_of_forall fun i => ae_of_all _ fun x => norm_indicator_le_norm_self _ _) hfi.norm\n    (hφ.ae_tendsto_indicator f)\n#align measure_theory.ae_cover.integral_tendsto_of_countably_generated MeasureTheory.AeCover.integral_tendsto_of_countably_generated\n\n/-- Slight reformulation of\n    `measure_theory.ae_cover.integral_tendsto_of_countably_generated`. -/\ntheorem AeCover.integral_eq_of_tendsto [l.ne_bot] [l.IsCountablyGenerated] {φ : ι → Set α}\n    (hφ : AeCover μ l φ) {f : α → E} (I : E) (hfi : Integrable f μ)\n    (h : Tendsto (fun n => ∫ x in φ n, f x ∂μ) l (𝓝 I)) : (∫ x, f x ∂μ) = I :=\n  tendsto_nhds_unique (hφ.integral_tendsto_of_countably_generated hfi) h\n#align measure_theory.ae_cover.integral_eq_of_tendsto MeasureTheory.AeCover.integral_eq_of_tendsto\n\ntheorem AeCover.integral_eq_of_tendsto_of_nonneg_ae [l.ne_bot] [l.IsCountablyGenerated]\n    {φ : ι → Set α} (hφ : AeCover μ l φ) {f : α → ℝ} (I : ℝ) (hnng : 0 ≤ᵐ[μ] f)\n    (hfi : ∀ n, IntegrableOn f (φ n) μ) (htendsto : Tendsto (fun n => ∫ x in φ n, f x ∂μ) l (𝓝 I)) :\n    (∫ x, f x ∂μ) = I :=\n  have hfi' : Integrable f μ := hφ.integrableOfIntegralTendstoOfNonnegAe I hfi hnng htendsto\n  hφ.integral_eq_of_tendsto I hfi' htendsto\n#align measure_theory.ae_cover.integral_eq_of_tendsto_of_nonneg_ae MeasureTheory.AeCover.integral_eq_of_tendsto_of_nonneg_ae\n\nend Integral\n\nsection IntegrableOfIntervalIntegral\n\nvariable {ι E : Type _} {μ : Measure ℝ} {l : Filter ι} [Filter.NeBot l] [IsCountablyGenerated l]\n  [NormedAddCommGroup E] {a b : ι → ℝ} {f : ℝ → E}\n\ntheorem integrableOfIntervalIntegralNormBounded (I : ℝ)\n    (hfi : ∀ i, IntegrableOn f (Ioc (a i) (b i)) μ) (ha : Tendsto a l atBot)\n    (hb : Tendsto b l atTop) (h : ∀ᶠ i in l, (∫ x in a i..b i, ‖f x‖ ∂μ) ≤ I) : Integrable f μ :=\n  by\n  have hφ : ae_cover μ l _ := ae_cover_Ioc ha hb\n  refine' hφ.integrable_of_integral_norm_bounded I hfi (h.mp _)\n  filter_upwards [ha.eventually (eventually_le_at_bot 0),\n    hb.eventually (eventually_ge_at_top 0)]with i hai hbi ht\n  rwa [← intervalIntegral.integral_of_le (hai.trans hbi)]\n#align measure_theory.integrable_of_interval_integral_norm_bounded MeasureTheory.integrableOfIntervalIntegralNormBounded\n\n/-- If `f` is integrable on intervals `Ioc (a i) (b i)`,\nwhere `a i` tends to -∞ and `b i` tends to ∞, and\n`∫ x in a i .. b i, ‖f x‖ ∂μ` converges to `I : ℝ` along a filter `l`,\nthen `f` is integrable on the interval (-∞, ∞) -/\ntheorem integrableOfIntervalIntegralNormTendsto (I : ℝ)\n    (hfi : ∀ i, IntegrableOn f (Ioc (a i) (b i)) μ) (ha : Tendsto a l atBot)\n    (hb : Tendsto b l atTop) (h : Tendsto (fun i => ∫ x in a i..b i, ‖f x‖ ∂μ) l (𝓝 I)) :\n    Integrable f μ :=\n  let ⟨I', hI'⟩ := h.isBoundedUnder_le\n  integrableOfIntervalIntegralNormBounded I' hfi ha hb hI'\n#align measure_theory.integrable_of_interval_integral_norm_tendsto MeasureTheory.integrableOfIntervalIntegralNormTendsto\n\ntheorem integrableOnIicOfIntervalIntegralNormBounded (I b : ℝ)\n    (hfi : ∀ i, IntegrableOn f (Ioc (a i) b) μ) (ha : Tendsto a l atBot)\n    (h : ∀ᶠ i in l, (∫ x in a i..b, ‖f x‖ ∂μ) ≤ I) : IntegrableOn f (Iic b) μ :=\n  by\n  have hφ : ae_cover (μ.restrict <| Iic b) l _ := ae_cover_Ioi ha\n  have hfi : ∀ i, integrable_on f (Ioi (a i)) (μ.restrict <| Iic b) :=\n    by\n    intro i\n    rw [integrable_on, measure.restrict_restrict (hφ.measurable i)]\n    exact hfi i\n  refine' hφ.integrable_of_integral_norm_bounded I hfi (h.mp _)\n  filter_upwards [ha.eventually (eventually_le_at_bot b)]with i hai\n  rw [intervalIntegral.integral_of_le hai, measure.restrict_restrict (hφ.measurable i)]\n  exact id\n#align measure_theory.integrable_on_Iic_of_interval_integral_norm_bounded MeasureTheory.integrableOnIicOfIntervalIntegralNormBounded\n\n/-- If `f` is integrable on intervals `Ioc (a i) b`,\nwhere `a i` tends to -∞, and\n`∫ x in a i .. b, ‖f x‖ ∂μ` converges to `I : ℝ` along a filter `l`,\nthen `f` is integrable on the interval (-∞, b) -/\ntheorem integrableOnIicOfIntervalIntegralNormTendsto (I b : ℝ)\n    (hfi : ∀ i, IntegrableOn f (Ioc (a i) b) μ) (ha : Tendsto a l atBot)\n    (h : Tendsto (fun i => ∫ x in a i..b, ‖f x‖ ∂μ) l (𝓝 I)) : IntegrableOn f (Iic b) μ :=\n  let ⟨I', hI'⟩ := h.isBoundedUnder_le\n  integrableOnIicOfIntervalIntegralNormBounded I' b hfi ha hI'\n#align measure_theory.integrable_on_Iic_of_interval_integral_norm_tendsto MeasureTheory.integrableOnIicOfIntervalIntegralNormTendsto\n\ntheorem integrableOnIoiOfIntervalIntegralNormBounded (I a : ℝ)\n    (hfi : ∀ i, IntegrableOn f (Ioc a (b i)) μ) (hb : Tendsto b l atTop)\n    (h : ∀ᶠ i in l, (∫ x in a..b i, ‖f x‖ ∂μ) ≤ I) : IntegrableOn f (Ioi a) μ :=\n  by\n  have hφ : ae_cover (μ.restrict <| Ioi a) l _ := ae_cover_Iic hb\n  have hfi : ∀ i, integrable_on f (Iic (b i)) (μ.restrict <| Ioi a) :=\n    by\n    intro i\n    rw [integrable_on, measure.restrict_restrict (hφ.measurable i), inter_comm]\n    exact hfi i\n  refine' hφ.integrable_of_integral_norm_bounded I hfi (h.mp _)\n  filter_upwards [hb.eventually (eventually_ge_at_top a)]with i hbi\n  rw [intervalIntegral.integral_of_le hbi, measure.restrict_restrict (hφ.measurable i), inter_comm]\n  exact id\n#align measure_theory.integrable_on_Ioi_of_interval_integral_norm_bounded MeasureTheory.integrableOnIoiOfIntervalIntegralNormBounded\n\n/-- If `f` is integrable on intervals `Ioc a (b i)`,\nwhere `b i` tends to ∞, and\n`∫ x in a .. b i, ‖f x‖ ∂μ` converges to `I : ℝ` along a filter `l`,\nthen `f` is integrable on the interval (a, ∞) -/\ntheorem integrableOnIoiOfIntervalIntegralNormTendsto (I a : ℝ)\n    (hfi : ∀ i, IntegrableOn f (Ioc a (b i)) μ) (hb : Tendsto b l atTop)\n    (h : Tendsto (fun i => ∫ x in a..b i, ‖f x‖ ∂μ) l (𝓝 <| I)) : IntegrableOn f (Ioi a) μ :=\n  let ⟨I', hI'⟩ := h.isBoundedUnder_le\n  integrableOnIoiOfIntervalIntegralNormBounded I' a hfi hb hI'\n#align measure_theory.integrable_on_Ioi_of_interval_integral_norm_tendsto MeasureTheory.integrableOnIoiOfIntervalIntegralNormTendsto\n\ntheorem integrableOnIocOfIntervalIntegralNormBounded {I a₀ b₀ : ℝ}\n    (hfi : ∀ i, IntegrableOn f <| Ioc (a i) (b i)) (ha : Tendsto a l <| 𝓝 a₀)\n    (hb : Tendsto b l <| 𝓝 b₀) (h : ∀ᶠ i in l, (∫ x in Ioc (a i) (b i), ‖f x‖) ≤ I) :\n    IntegrableOn f (Ioc a₀ b₀) :=\n  by\n  refine'\n    (ae_cover_Ioc_of_Ioc ha hb).integrableOfIntegralNormBounded I\n      (fun i => (hfi i).restrict measurableSet_Ioc) (eventually.mono h _)\n  intro i hi; simp only [measure.restrict_restrict measurableSet_Ioc]\n  refine' le_trans (set_integral_mono_set (hfi i).norm _ _) hi\n  · apply ae_of_all\n    simp only [Pi.zero_apply, norm_nonneg, forall_const]\n  · apply ae_of_all\n    intro c hc\n    exact hc.1\n#align measure_theory.integrable_on_Ioc_of_interval_integral_norm_bounded MeasureTheory.integrableOnIocOfIntervalIntegralNormBounded\n\ntheorem integrableOnIocOfIntervalIntegralNormBoundedLeft {I a₀ b : ℝ}\n    (hfi : ∀ i, IntegrableOn f <| Ioc (a i) b) (ha : Tendsto a l <| 𝓝 a₀)\n    (h : ∀ᶠ i in l, (∫ x in Ioc (a i) b, ‖f x‖) ≤ I) : IntegrableOn f (Ioc a₀ b) :=\n  integrableOnIocOfIntervalIntegralNormBounded hfi ha tendsto_const_nhds h\n#align measure_theory.integrable_on_Ioc_of_interval_integral_norm_bounded_left MeasureTheory.integrableOnIocOfIntervalIntegralNormBoundedLeft\n\ntheorem integrableOnIocOfIntervalIntegralNormBoundedRight {I a b₀ : ℝ}\n    (hfi : ∀ i, IntegrableOn f <| Ioc a (b i)) (hb : Tendsto b l <| 𝓝 b₀)\n    (h : ∀ᶠ i in l, (∫ x in Ioc a (b i), ‖f x‖) ≤ I) : IntegrableOn f (Ioc a b₀) :=\n  integrableOnIocOfIntervalIntegralNormBounded hfi tendsto_const_nhds hb h\n#align measure_theory.integrable_on_Ioc_of_interval_integral_norm_bounded_right MeasureTheory.integrableOnIocOfIntervalIntegralNormBoundedRight\n\nend IntegrableOfIntervalIntegral\n\nsection IntegralOfIntervalIntegral\n\nvariable {ι E : Type _} {μ : Measure ℝ} {l : Filter ι} [IsCountablyGenerated l]\n  [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {a b : ι → ℝ} {f : ℝ → E}\n\ntheorem intervalIntegral_tendsto_integral (hfi : Integrable f μ) (ha : Tendsto a l atBot)\n    (hb : Tendsto b l atTop) : Tendsto (fun i => ∫ x in a i..b i, f x ∂μ) l (𝓝 <| ∫ x, f x ∂μ) :=\n  by\n  let φ i := Ioc (a i) (b i)\n  have hφ : ae_cover μ l φ := ae_cover_Ioc ha hb\n  refine' (hφ.integral_tendsto_of_countably_generated hfi).congr' _\n  filter_upwards [ha.eventually (eventually_le_at_bot 0),\n    hb.eventually (eventually_ge_at_top 0)]with i hai hbi\n  exact (intervalIntegral.integral_of_le (hai.trans hbi)).symm\n#align measure_theory.interval_integral_tendsto_integral MeasureTheory.intervalIntegral_tendsto_integral\n\ntheorem intervalIntegral_tendsto_integral_Iic (b : ℝ) (hfi : IntegrableOn f (Iic b) μ)\n    (ha : Tendsto a l atBot) :\n    Tendsto (fun i => ∫ x in a i..b, f x ∂μ) l (𝓝 <| ∫ x in Iic b, f x ∂μ) :=\n  by\n  let φ i := Ioi (a i)\n  have hφ : ae_cover (μ.restrict <| Iic b) l φ := ae_cover_Ioi ha\n  refine' (hφ.integral_tendsto_of_countably_generated hfi).congr' _\n  filter_upwards [ha.eventually (eventually_le_at_bot <| b)]with i hai\n  rw [intervalIntegral.integral_of_le hai, measure.restrict_restrict (hφ.measurable i)]\n  rfl\n#align measure_theory.interval_integral_tendsto_integral_Iic MeasureTheory.intervalIntegral_tendsto_integral_Iic\n\ntheorem intervalIntegral_tendsto_integral_Ioi (a : ℝ) (hfi : IntegrableOn f (Ioi a) μ)\n    (hb : Tendsto b l atTop) :\n    Tendsto (fun i => ∫ x in a..b i, f x ∂μ) l (𝓝 <| ∫ x in Ioi a, f x ∂μ) :=\n  by\n  let φ i := Iic (b i)\n  have hφ : ae_cover (μ.restrict <| Ioi a) l φ := ae_cover_Iic hb\n  refine' (hφ.integral_tendsto_of_countably_generated hfi).congr' _\n  filter_upwards [hb.eventually (eventually_ge_at_top <| a)]with i hbi\n  rw [intervalIntegral.integral_of_le hbi, measure.restrict_restrict (hφ.measurable i), inter_comm]\n  rfl\n#align measure_theory.interval_integral_tendsto_integral_Ioi MeasureTheory.intervalIntegral_tendsto_integral_Ioi\n\nend IntegralOfIntervalIntegral\n\nsection IoiChangeVariables\n\nopen Real\n\nopen Interval\n\nvariable {E : Type _} {μ : Measure ℝ} {f : ℝ → E} [NormedAddCommGroup E] [NormedSpace ℝ E]\n  [CompleteSpace E]\n\n/-- Change-of-variables formula for `Ioi` integrals of vector-valued functions, proved by taking\nlimits from the result for finite intervals. -/\ntheorem integral_comp_smul_deriv_Ioi {f f' : ℝ → ℝ} {g : ℝ → E} {a : ℝ}\n    (hf : ContinuousOn f <| Ici a) (hft : Tendsto f atTop atTop)\n    (hff' : ∀ x ∈ Ioi a, HasDerivWithinAt f (f' x) (Ioi x) x)\n    (hg_cont : ContinuousOn g <| f '' Ioi a) (hg1 : IntegrableOn g <| f '' Ici a)\n    (hg2 : IntegrableOn (fun x => f' x • (g ∘ f) x) (Ici a)) :\n    (∫ x in Ioi a, f' x • (g ∘ f) x) = ∫ u in Ioi (f a), g u :=\n  by\n  have eq : ∀ b : ℝ, a < b → (∫ x in a..b, f' x • (g ∘ f) x) = ∫ u in f a..f b, g u :=\n    by\n    intro b hb\n    have i1 : Ioo (min a b) (max a b) ⊆ Ioi a :=\n      by\n      rw [min_eq_left hb.le]\n      exact Ioo_subset_Ioi_self\n    have i2 : [a, b] ⊆ Ici a := by\n      rw [uIcc_of_le hb.le]\n      exact Icc_subset_Ici_self\n    refine'\n      intervalIntegral.integral_comp_smul_deriv''' (hf.mono i2)\n        (fun x hx => hff' x <| mem_of_mem_of_subset hx i1) (hg_cont.mono <| image_subset _ _)\n        (hg1.mono_set <| image_subset _ _) (hg2.mono_set i2)\n    · rw [min_eq_left hb.le]\n      exact Ioo_subset_Ioi_self\n    · rw [uIcc_of_le hb.le]\n      exact Icc_subset_Ici_self\n  rw [integrableOn_Ici_iff_integrableOn_Ioi] at hg2\n  have t2 := interval_integral_tendsto_integral_Ioi _ hg2 tendsto_id\n  have : Ioi (f a) ⊆ f '' Ici a :=\n    Ioi_subset_Ici_self.trans <|\n      IsPreconnected.intermediate_value_Ici isPreconnected_Ici left_mem_Ici\n        (le_principal_iff.mpr <| Ici_mem_at_top _) hf hft\n  have t1 := (interval_integral_tendsto_integral_Ioi _ (hg1.mono_set this) tendsto_id).comp hft\n  exact tendsto_nhds_unique (tendsto.congr' (eventually_eq_of_mem (Ioi_mem_at_top a) Eq) t2) t1\n#align measure_theory.integral_comp_smul_deriv_Ioi MeasureTheory.integral_comp_smul_deriv_Ioi\n\n/-- Change-of-variables formula for `Ioi` integrals of scalar-valued functions -/\ntheorem integral_comp_mul_deriv_Ioi {f f' : ℝ → ℝ} {g : ℝ → ℝ} {a : ℝ}\n    (hf : ContinuousOn f <| Ici a) (hft : Tendsto f atTop atTop)\n    (hff' : ∀ x ∈ Ioi a, HasDerivWithinAt f (f' x) (Ioi x) x)\n    (hg_cont : ContinuousOn g <| f '' Ioi a) (hg1 : IntegrableOn g <| f '' Ici a)\n    (hg2 : IntegrableOn (fun x => (g ∘ f) x * f' x) (Ici a)) :\n    (∫ x in Ioi a, (g ∘ f) x * f' x) = ∫ u in Ioi (f a), g u :=\n  by\n  have hg2' : integrable_on (fun x => f' x • (g ∘ f) x) (Ici a) := by simpa [mul_comm] using hg2\n  simpa [mul_comm] using integral_comp_smul_deriv_Ioi hf hft hff' hg_cont hg1 hg2'\n#align measure_theory.integral_comp_mul_deriv_Ioi MeasureTheory.integral_comp_mul_deriv_Ioi\n\n/-- Substitution `y = x ^ p` in integrals over `Ioi 0` -/\ntheorem integral_comp_rpow_Ioi (g : ℝ → E) {p : ℝ} (hp : p ≠ 0) :\n    (∫ x in Ioi 0, (|p| * x ^ (p - 1)) • g (x ^ p)) = ∫ y in Ioi 0, g y :=\n  by\n  let S := Ioi (0 : ℝ)\n  have a1 : ∀ x : ℝ, x ∈ S → HasDerivWithinAt (fun t : ℝ => t ^ p) (p * x ^ (p - 1)) S x :=\n    fun x hx => (has_deriv_at_rpow_const (Or.inl (mem_Ioi.mp hx).ne')).HasDerivWithinAt\n  have a2 : inj_on (fun x : ℝ => x ^ p) S :=\n    by\n    rcases lt_or_gt_of_ne hp with ⟨⟩\n    · apply StrictAntiOn.injOn\n      intro x hx y hy hxy\n      rw [← inv_lt_inv (rpow_pos_of_pos hx p) (rpow_pos_of_pos hy p), ← rpow_neg (le_of_lt hx), ←\n        rpow_neg (le_of_lt hy)]\n      exact rpow_lt_rpow (le_of_lt hx) hxy (neg_pos.mpr h)\n    exact StrictMonoOn.injOn fun x hx y hy hxy => rpow_lt_rpow (mem_Ioi.mp hx).le hxy h\n  have a3 : (fun t : ℝ => t ^ p) '' S = S := by\n    ext1\n    rw [mem_image]\n    constructor\n    · rintro ⟨y, hy, rfl⟩\n      exact rpow_pos_of_pos hy p\n    · intro hx\n      refine' ⟨x ^ (1 / p), rpow_pos_of_pos hx _, _⟩\n      rw [← rpow_mul (le_of_lt hx), one_div_mul_cancel hp, rpow_one]\n  have := integral_image_eq_integral_abs_deriv_smul measurableSet_Ioi a1 a2 g\n  rw [a3] at this\n  rw [this]\n  refine' set_integral_congr measurableSet_Ioi _\n  intro x hx\n  dsimp only\n  rw [abs_mul, abs_of_nonneg (rpow_nonneg_of_nonneg (le_of_lt hx) _)]\n#align measure_theory.integral_comp_rpow_Ioi MeasureTheory.integral_comp_rpow_Ioi\n\ntheorem integral_comp_rpow_Ioi_of_pos {g : ℝ → E} {p : ℝ} (hp : 0 < p) :\n    (∫ x in Ioi 0, (p * x ^ (p - 1)) • g (x ^ p)) = ∫ y in Ioi 0, g y :=\n  by\n  convert integral_comp_rpow_Ioi g hp.ne'\n  funext; congr ; rw [abs_of_nonneg hp.le]\n#align measure_theory.integral_comp_rpow_Ioi_of_pos MeasureTheory.integral_comp_rpow_Ioi_of_pos\n\nend IoiChangeVariables\n\nend MeasureTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/MeasureTheory/Integral/IntegralEqImproper.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7122321720225279, "lm_q1q2_score": 0.46894612652269146}}
{"text": "/-\nCopyright (c) 2018 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n\nInteger power operation on fields.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.group_with_zero.power\nimport Mathlib.tactic.linarith.default\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u \n\nnamespace Mathlib\n\n@[simp] theorem ring_hom.map_fpow {K : Type u_1} {L : Type u_2} [division_ring K] [division_ring L]\n    (f : K →+* L) (a : K) (n : ℤ) : coe_fn f (a ^ n) = coe_fn f a ^ n :=\n  monoid_with_zero_hom.map_fpow (ring_hom.to_monoid_with_zero_hom f)\n\n@[simp] theorem neg_fpow_bit0 {K : Type u_1} [division_ring K] (x : K) (n : ℤ) :\n    (-x) ^ bit0 n = x ^ bit0 n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl ((-x) ^ bit0 n = x ^ bit0 n)) (fpow_bit0' (-x) n)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((-x * -x) ^ n = x ^ bit0 n)) (fpow_bit0' x n)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl ((-x * -x) ^ n = (x * x) ^ n)) (neg_mul_neg x x)))\n        (Eq.refl ((x * x) ^ n))))\n\n@[simp] theorem neg_fpow_bit1 {K : Type u_1} [division_ring K] (x : K) (n : ℤ) :\n    (-x) ^ bit1 n = -x ^ bit1 n :=\n  sorry\n\ntheorem fpow_nonneg_of_nonneg {K : Type u} [linear_ordered_field K] {a : K} (ha : 0 ≤ a) (z : ℤ) :\n    0 ≤ a ^ z :=\n  int.cases_on z (fun (z : ℕ) => idRhs (0 ≤ a ^ z) (pow_nonneg ha z))\n    fun (z : ℕ) => idRhs (0 ≤ (a ^ Nat.succ z⁻¹)) (iff.mpr inv_nonneg (pow_nonneg ha (Nat.succ z)))\n\ntheorem fpow_pos_of_pos {K : Type u} [linear_ordered_field K] {a : K} (ha : 0 < a) (z : ℤ) :\n    0 < a ^ z :=\n  int.cases_on z (fun (z : ℕ) => idRhs (0 < a ^ z) (pow_pos ha z))\n    fun (z : ℕ) => idRhs (0 < (a ^ Nat.succ z⁻¹)) (iff.mpr inv_pos (pow_pos ha (Nat.succ z)))\n\ntheorem fpow_le_of_le {K : Type u} [linear_ordered_field K] {x : K} (hx : 1 ≤ x) {a : ℤ} {b : ℤ}\n    (h : a ≤ b) : x ^ a ≤ x ^ b :=\n  sorry\n\ntheorem pow_le_max_of_min_le {K : Type u} [linear_ordered_field K] {x : K} (hx : 1 ≤ x) {a : ℤ}\n    {b : ℤ} {c : ℤ} (h : min a b ≤ c) : x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) :=\n  sorry\n\ntheorem fpow_le_one_of_nonpos {K : Type u} [linear_ordered_field K] {p : K} (hp : 1 ≤ p) {z : ℤ}\n    (hz : z ≤ 0) : p ^ z ≤ 1 :=\n  sorry\n\ntheorem one_le_fpow_of_nonneg {K : Type u} [linear_ordered_field K] {p : K} (hp : 1 ≤ p) {z : ℤ}\n    (hz : 0 ≤ z) : 1 ≤ p ^ z :=\n  sorry\n\ntheorem one_lt_pow {K : Type u_1} [linear_ordered_semiring K] {p : K} (hp : 1 < p) {n : ℕ} :\n    1 ≤ n → 1 < p ^ n :=\n  sorry\n\ntheorem one_lt_fpow {K : Type u_1} [linear_ordered_field K] {p : K} (hp : 1 < p) (z : ℤ) :\n    0 < z → 1 < p ^ z :=\n  sorry\n\ntheorem nat.fpow_pos_of_pos {K : Type u_1} [linear_ordered_field K] {p : ℕ} (h : 0 < p) (n : ℤ) :\n    0 < ↑p ^ n :=\n  sorry\n\ntheorem nat.fpow_ne_zero_of_pos {K : Type u_1} [linear_ordered_field K] {p : ℕ} (h : 0 < p)\n    (n : ℤ) : ↑p ^ n ≠ 0 :=\n  ne_of_gt (nat.fpow_pos_of_pos h n)\n\ntheorem fpow_strict_mono {K : Type u_1} [linear_ordered_field K] {x : K} (hx : 1 < x) :\n    strict_mono fun (n : ℤ) => x ^ n :=\n  sorry\n\n@[simp] theorem fpow_lt_iff_lt {K : Type u_1} [linear_ordered_field K] {x : K} (hx : 1 < x) {m : ℤ}\n    {n : ℤ} : x ^ m < x ^ n ↔ m < n :=\n  strict_mono.lt_iff_lt (fpow_strict_mono hx)\n\n@[simp] theorem fpow_le_iff_le {K : Type u_1} [linear_ordered_field K] {x : K} (hx : 1 < x) {m : ℤ}\n    {n : ℤ} : x ^ m ≤ x ^ n ↔ m ≤ n :=\n  strict_mono.le_iff_le (fpow_strict_mono hx)\n\n@[simp] theorem pos_div_pow_pos {K : Type u_1} [linear_ordered_field K] {a : K} {b : K} (ha : 0 < a)\n    (hb : 0 < b) (k : ℕ) : 0 < a / b ^ k :=\n  div_pos ha (pow_pos hb k)\n\n@[simp] theorem div_pow_le {K : Type u_1} [linear_ordered_field K] {a : K} {b : K} (ha : 0 < a)\n    (hb : 1 ≤ b) (k : ℕ) : a / b ^ k ≤ a :=\n  iff.mpr (div_le_iff (pow_pos (lt_of_lt_of_le zero_lt_one hb) k))\n    (trans_rel_right LessEq (Eq.symm (mul_one a))\n      (iff.mpr (mul_le_mul_left ha) (one_le_pow_of_one_le hb k)))\n\ntheorem fpow_injective {K : Type u_1} [linear_ordered_field K] {x : K} (h₀ : 0 < x) (h₁ : x ≠ 1) :\n    function.injective (pow x) :=\n  sorry\n\n@[simp] theorem fpow_inj {K : Type u_1} [linear_ordered_field K] {x : K} (h₀ : 0 < x) (h₁ : x ≠ 1)\n    {m : ℤ} {n : ℤ} : x ^ m = x ^ n ↔ m = n :=\n  function.injective.eq_iff (fpow_injective h₀ h₁)\n\n@[simp] theorem rat.cast_fpow {K : Type u_1} [field K] [char_zero K] (q : ℚ) (n : ℤ) :\n    ↑(q ^ n) = ↑q ^ n :=\n  ring_hom.map_fpow (rat.cast_hom K) q n\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/field_power_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4689461265226914}}
{"text": "/-\nCopyright (c) 2021 Justus Springer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Justus Springer\n\n! This file was ported from Lean 3 source module topology.sheaves.sheaf_condition.sites\n! leanprover-community/mathlib commit d39590fc8728fbf6743249802486f8c91ffe07bc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Sites.Spaces\nimport Mathbin.Topology.Sheaves.Sheaf\nimport Mathbin.CategoryTheory.Sites.DenseSubsite\n\n/-!\n\n# Coverings and sieves; from sheaves on sites and sheaves on spaces\n\nIn this file, we connect coverings in a topological space to sieves in the associated Grothendieck\ntopology, in preparation of connecting the sheaf condition on sites to the various sheaf conditions\non spaces.\n\nWe also specialize results about sheaves on sites to sheaves on spaces; we show that the inclusion\nfunctor from a topological basis to `topological_space.opens` is cover_dense, that open maps\ninduce cover_preserving functors, and that open embeddings induce compatible_preserving functors.\n\n-/\n\n\nnoncomputable section\n\nuniverse w v u\n\nopen CategoryTheory TopologicalSpace\n\nnamespace TopCat.Presheaf\n\nvariable {X : TopCat.{w}}\n\n/-- Given a presieve `R` on `U`, we obtain a covering family of open sets in `X`, by taking as index\ntype the type of dependent pairs `(V, f)`, where `f : V ⟶ U` is in `R`.\n-/\ndef coveringOfPresieve (U : Opens X) (R : Presieve U) : (ΣV, { f : V ⟶ U // R f }) → Opens X :=\n  fun f => f.1\n#align Top.presheaf.covering_of_presieve TopCat.Presheaf.coveringOfPresieve\n\n@[simp]\ntheorem coveringOfPresieve_apply (U : Opens X) (R : Presieve U) (f : ΣV, { f : V ⟶ U // R f }) :\n    coveringOfPresieve U R f = f.1 :=\n  rfl\n#align Top.presheaf.covering_of_presieve_apply TopCat.Presheaf.coveringOfPresieve_apply\n\nnamespace CoveringOfPresieve\n\nvariable (U : Opens X) (R : Presieve U)\n\n/--\nIf `R` is a presieve in the grothendieck topology on `opens X`, the covering family associated to\n`R` really is _covering_, i.e. the union of all open sets equals `U`.\n-/\ntheorem supᵢ_eq_of_mem_grothendieck (hR : Sieve.generate R ∈ Opens.grothendieckTopology X U) :\n    supᵢ (coveringOfPresieve U R) = U := by\n  apply le_antisymm\n  · refine' supᵢ_le _\n    intro f\n    exact f.2.1.le\n  intro x hxU\n  rw [opens.mem_supr]\n  obtain ⟨V, iVU, ⟨W, iVW, iWU, hiWU, -⟩, hxV⟩ := hR x hxU\n  exact ⟨⟨W, ⟨iWU, hiWU⟩⟩, iVW.le hxV⟩\n#align Top.presheaf.covering_of_presieve.supr_eq_of_mem_grothendieck TopCat.Presheaf.coveringOfPresieve.supᵢ_eq_of_mem_grothendieck\n\nend CoveringOfPresieve\n\n/-- Given a family of opens `U : ι → opens X` and any open `Y : opens X`, we obtain a presieve\non `Y` by declaring that a morphism `f : V ⟶ Y` is a member of the presieve if and only if\nthere exists an index `i : ι` such that `V = U i`.\n-/\ndef presieveOfCoveringAux {ι : Type v} (U : ι → Opens X) (Y : Opens X) : Presieve Y := fun V f =>\n  ∃ i, V = U i\n#align Top.presheaf.presieve_of_covering_aux TopCat.Presheaf.presieveOfCoveringAux\n\n/-- Take `Y` to be `supr U` and obtain a presieve over `supr U`. -/\ndef presieveOfCovering {ι : Type v} (U : ι → Opens X) : Presieve (supᵢ U) :=\n  presieveOfCoveringAux U (supᵢ U)\n#align Top.presheaf.presieve_of_covering TopCat.Presheaf.presieveOfCovering\n\n/-- Given a presieve `R` on `Y`, if we take its associated family of opens via\n    `covering_of_presieve` (which may not cover `Y` if `R` is not covering), and take\n    the presieve on `Y` associated to the family of opens via `presieve_of_covering_aux`,\n    then we get back the original presieve `R`. -/\n@[simp]\ntheorem covering_presieve_eq_self {Y : Opens X} (R : Presieve Y) :\n    presieveOfCoveringAux (coveringOfPresieve Y R) Y = R :=\n  by\n  ext (Z f)\n  exact ⟨fun ⟨⟨_, _, h⟩, rfl⟩ => by convert h, fun h => ⟨⟨Z, f, h⟩, rfl⟩⟩\n#align Top.presheaf.covering_presieve_eq_self TopCat.Presheaf.covering_presieve_eq_self\n\nnamespace PresieveOfCovering\n\nvariable {ι : Type v} (U : ι → Opens X)\n\n/-- The sieve generated by `presieve_of_covering U` is a member of the grothendieck topology.\n-/\ntheorem mem_grothendieckTopology :\n    Sieve.generate (presieveOfCovering U) ∈ Opens.grothendieckTopology X (supᵢ U) :=\n  by\n  intro x hx\n  obtain ⟨i, hxi⟩ := opens.mem_supr.mp hx\n  exact ⟨U i, opens.le_supr U i, ⟨U i, 𝟙 _, opens.le_supr U i, ⟨i, rfl⟩, category.id_comp _⟩, hxi⟩\n#align Top.presheaf.presieve_of_covering.mem_grothendieck_topology TopCat.Presheaf.presieveOfCovering.mem_grothendieckTopology\n\n/-- An index `i : ι` can be turned into a dependent pair `(V, f)`, where `V` is an open set and\n`f : V ⟶ supr U` is a member of `presieve_of_covering U f`.\n-/\ndef homOfIndex (i : ι) : ΣV, { f : V ⟶ supᵢ U // presieveOfCovering U f } :=\n  ⟨U i, Opens.leSupr U i, i, rfl⟩\n#align Top.presheaf.presieve_of_covering.hom_of_index TopCat.Presheaf.presieveOfCovering.homOfIndex\n\n/-- By using the axiom of choice, a dependent pair `(V, f)` where `f : V ⟶ supr U` is a member of\n`presieve_of_covering U f` can be turned into an index `i : ι`, such that `V = U i`.\n-/\ndef indexOfHom (f : ΣV, { f : V ⟶ supᵢ U // presieveOfCovering U f }) : ι :=\n  f.2.2.some\n#align Top.presheaf.presieve_of_covering.index_of_hom TopCat.Presheaf.presieveOfCovering.indexOfHom\n\ntheorem indexOfHom_spec (f : ΣV, { f : V ⟶ supᵢ U // presieveOfCovering U f }) :\n    f.1 = U (indexOfHom U f) :=\n  f.2.2.choose_spec\n#align Top.presheaf.presieve_of_covering.index_of_hom_spec TopCat.Presheaf.presieveOfCovering.indexOfHom_spec\n\nend PresieveOfCovering\n\nend TopCat.Presheaf\n\nnamespace TopCat.Opens\n\nvariable {X : TopCat} {ι : Type _}\n\ntheorem coverDense_iff_isBasis [Category ι] (B : ι ⥤ Opens X) :\n    CoverDense (Opens.grothendieckTopology X) B ↔ Opens.IsBasis (Set.range B.obj) :=\n  by\n  rw [opens.is_basis_iff_nbhd]\n  constructor; intro hd U x hx; rcases hd.1 U x hx with ⟨V, f, ⟨i, f₁, f₂, hc⟩, hV⟩\n  exact ⟨B.obj i, ⟨i, rfl⟩, f₁.le hV, f₂.le⟩\n  intro hb; constructor; intro U x hx; rcases hb hx with ⟨_, ⟨i, rfl⟩, hx, hi⟩\n  exact ⟨B.obj i, ⟨⟨hi⟩⟩, ⟨⟨i, 𝟙 _, ⟨⟨hi⟩⟩, rfl⟩⟩, hx⟩\n#align Top.opens.cover_dense_iff_is_basis TopCat.Opens.coverDense_iff_isBasis\n\ntheorem coverDense_inducedFunctor {B : ι → Opens X} (h : Opens.IsBasis (Set.range B)) :\n    CoverDense (Opens.grothendieckTopology X) (inducedFunctor B) :=\n  (coverDense_iff_isBasis _).2 h\n#align Top.opens.cover_dense_induced_functor TopCat.Opens.coverDense_inducedFunctor\n\nend TopCat.Opens\n\nsection OpenEmbedding\n\nopen TopCat.Presheaf Opposite\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {X Y : TopCat.{w}} {f : X ⟶ Y} {F : Y.Presheaf C}\n\ntheorem OpenEmbedding.compatiblePreserving (hf : OpenEmbedding f) :\n    CompatiblePreserving (Opens.grothendieckTopology Y) hf.IsOpenMap.Functor :=\n  by\n  haveI : mono f := (TopCat.mono_iff_injective f).mpr hf.inj\n  apply compatible_preserving_of_downwards_closed\n  intro U V i\n  refine'\n    ⟨(opens.map f).obj V, eq_to_iso <| opens.ext <| Set.image_preimage_eq_of_subset fun x h => _⟩\n  obtain ⟨_, _, rfl⟩ := i.le h\n  exact ⟨_, rfl⟩\n#align open_embedding.compatible_preserving OpenEmbedding.compatiblePreserving\n\ntheorem IsOpenMap.coverPreserving (hf : IsOpenMap f) :\n    CoverPreserving (Opens.grothendieckTopology X) (Opens.grothendieckTopology Y) hf.Functor :=\n  by\n  constructor\n  rintro U S hU _ ⟨x, hx, rfl⟩\n  obtain ⟨V, i, hV, hxV⟩ := hU x hx\n  exact ⟨_, hf.functor.map i, ⟨_, i, 𝟙 _, hV, rfl⟩, Set.mem_image_of_mem f hxV⟩\n#align is_open_map.cover_preserving IsOpenMap.coverPreserving\n\ntheorem TopCat.Presheaf.isSheaf_of_openEmbedding (h : OpenEmbedding f) (hF : F.IsSheaf) :\n    IsSheaf (h.IsOpenMap.Functor.op ⋙ F) :=\n  pullback_isSheaf_of_coverPreserving h.CompatiblePreserving h.IsOpenMap.CoverPreserving ⟨_, hF⟩\n#align Top.presheaf.is_sheaf_of_open_embedding TopCat.Presheaf.isSheaf_of_openEmbedding\n\nend OpenEmbedding\n\nnamespace TopCat.Sheaf\n\nopen TopCat Opposite\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {X : TopCat.{w}} {ι : Type _} {B : ι → Opens X}\n\nvariable (F : X.Presheaf C) (F' : Sheaf C X) (h : Opens.IsBasis (Set.range B))\n\n/-- The empty component of a sheaf is terminal -/\ndef isTerminalOfEmpty (F : Sheaf C X) : Limits.IsTerminal (F.val.obj (op ⊥)) :=\n  F.isTerminalOfBotCover ⊥ (by tidy)\n#align Top.sheaf.is_terminal_of_empty TopCat.Sheaf.isTerminalOfEmpty\n\n/-- A variant of `is_terminal_of_empty` that is easier to `apply`. -/\ndef isTerminalOfEqEmpty (F : X.Sheaf C) {U : Opens X} (h : U = ⊥) :\n    Limits.IsTerminal (F.val.obj (op U)) := by convert F.is_terminal_of_empty\n#align Top.sheaf.is_terminal_of_eq_empty TopCat.Sheaf.isTerminalOfEqEmpty\n\n/-- If a family `B` of open sets forms a basis of the topology on `X`, and if `F'`\n    is a sheaf on `X`, then a homomorphism between a presheaf `F` on `X` and `F'`\n    is equivalent to a homomorphism between their restrictions to the indexing type\n    `ι` of `B`, with the induced category structure on `ι`. -/\ndef restrictHomEquivHom : ((inducedFunctor B).op ⋙ F ⟶ (inducedFunctor B).op ⋙ F'.1) ≃ (F ⟶ F'.1) :=\n  @CoverDense.restrictHomEquivHom _ _ _ _ _ _ _ _ (Opens.coverDense_inducedFunctor h) _ F F'\n#align Top.sheaf.restrict_hom_equiv_hom TopCat.Sheaf.restrictHomEquivHom\n\n@[simp]\ntheorem extend_hom_app (α : (inducedFunctor B).op ⋙ F ⟶ (inducedFunctor B).op ⋙ F'.1) (i : ι) :\n    (restrictHomEquivHom F F' h α).app (op (B i)) = α.app (op i) :=\n  by\n  nth_rw 2 [← (restrict_hom_equiv_hom F F' h).left_inv α]\n  rfl\n#align Top.sheaf.extend_hom_app TopCat.Sheaf.extend_hom_app\n\ninclude h\n\ntheorem hom_ext {α β : F ⟶ F'.1} (he : ∀ i, α.app (op (B i)) = β.app (op (B i))) : α = β :=\n  by\n  apply (restrict_hom_equiv_hom F F' h).symm.Injective\n  ext i\n  exact he i.unop\n#align Top.sheaf.hom_ext TopCat.Sheaf.hom_ext\n\nend TopCat.Sheaf\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Sheaves/SheafCondition/Sites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225279, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.4689461217488425}}
{"text": "import .atom \n\nvariables {α β : Type}\n\n/-\nRequires : qfree arg0\nEnsures : nqfree ret\n-/\ndef nnf (β) [@atom_type α β] : fm α → fm α \n| (fm.true α) := ⊤'  \n| (fm.false α) := ⊥' \n| (fm.atom a) := A' a\n| (fm.not (fm.true α)) := ⊥' \n| (fm.not (fm.false α)) := ⊤' \n| (fm.not (fm.atom a)) := atom_type.neg β a\n| (fm.not (fm.not p)) := nnf p\n| (fm.not (fm.or p q)) := fm.and (nnf (¬' p)) (nnf (¬' q))\n| (fm.not (fm.and p q)) := fm.or (nnf (¬' p)) (nnf (¬' q))\n| (fm.not (fm.ex p)) := ⊥' -- Invalid input\n| (fm.or p q) := fm.or (nnf p) (nnf q)\n| (fm.and p q) := fm.and (nnf p) (nnf q)\n| (fm.ex p) := ⊥' -- Invalid input\n\nlemma nnf_exp_and [atom_type α β] (p q : fm α) :\n@nnf α β _ (fm.and p q) = fm.and (@nnf α β _ p) (@nnf α β _ q) := \nby unfold nnf\n\nlemma nnf_exp_or [atom_type α β] (p q : fm α) : \n@nnf α β _ (p ∨' q) = (@nnf α β _ p ∨' @nnf α β _ q) := by unfold nnf\n\nlemma nnf_exp_not_and [H : atom_type α β] (p q : fm α) : \n@nnf α β _ (¬' (p ∧' q)) = (@nnf α β _ (¬' p) ∨' @nnf α β _ (¬' q)) := \nby unfold nnf\n\nlemma nnf_exp_not_or [H : atom_type α β] (p q : fm α) : \n@nnf α β _ (¬' (p ∨' q)) = (@nnf α β _ (¬' p) ∧' @nnf α β _ (¬' q)) := \nby unfold nnf\n\nlemma nqfree_not_eq_nqfree [atom_type α β] : ∀ (p : fm α) (Hp : qfree p), \nnqfree (@nnf α β _ (¬' p)) = nqfree (@nnf α β _  p) :=\nλ p, fm.rec_on p \n  (λ _, eq.refl _) \n  (λ _, eq.refl _) \n  (λ _ a, propext (iff.intro (λ _, trivial) (λ H, atom_type.neg_nqfree _ _)))\n  (λ q r Hq Hr Hqr,  \n    begin\n       unfold nnf, unfold nqfree, \n        rw [Hq Hqr^.elim_left, Hr Hqr^.elim_right]\n    end)\n  (λ q r Hq Hr Hqr,  \n    begin\n       unfold nnf, unfold nqfree, \n        rw [Hq Hqr^.elim_left, Hr Hqr^.elim_right]\n    end)\n  (λ q Hq Hp, begin rewrite (Hq Hp), unfold nnf end) \n  (λ _ _ Hp, \n    begin \n      unfold qfree at Hp,\n      cases Hp \n    end)\n\nlemma nnf_nqfree [atom_type α β] : \n  ∀ (p : fm α), qfree p → nqfree (@nnf α β _ p) := \nλ p, fm.rec_on p  \n(λ _, trivial) \n(λ _, trivial) \n(λ _ _, trivial) \n(λ q r Hq Hr Hqr, \n  begin\n    rewrite nnf_exp_and, cases Hqr with hqr1 hqr2, \n    apply (and.intro (Hq hqr1) (Hr hqr2))\n  end)\n(λ q r Hq Hr Hqr, \n  begin\n    rewrite nnf_exp_or, cases Hqr with hqr1 hqr2, \n    apply (and.intro (Hq hqr1) (Hr hqr2))\n  end)\n(λ q, fm.rec_on q \n  (λ _ _, trivial) \n  (λ _ _, trivial) \n  (λ _ _ _, by apply atom_type.neg_nqfree) \n  (λ r s Hr Hs H1 H2, \n    begin\n      rewrite nnf_exp_not_and,\n      rewrite nnf_exp_and at H1, \n      apply (and.intro \n              (Hr (λ _, (H1 H2)^.left) H2^.left) \n              (Hs (λ _, (H1 H2)^.right) H2^.right)),\n    end) \n  (λ r s Hr Hs H1 H2, \n    begin\n      rewrite nnf_exp_not_or,\n      rewrite nnf_exp_or at H1, \n      apply (and.intro \n              (Hr (λ _, (H1 H2)^.left) H2^.left) \n              (Hs (λ _, (H1 H2)^.right) H2^.right)),\n    end) \n  (λ r Hr1 Hr2 Hr3, \n    begin\n      unfold nnf, \n      rewrite nqfree_not_eq_nqfree at Hr2,\n      apply (Hr2 Hr3), apply Hr3\n    end\n    ) \n  (λ _ _ _ Hr, by cases Hr)) \n(λ _ _ Hr, by cases Hr)\n\nmeta def nnf_prsv_lit : tactic unit := \n`[apply and.intro, refl, unfold nnf, \n  unfold I, unfold interp, simp]\n\nmeta def nnf_prsv_normal_core_tac := \n  `[unfold nnf, unfold fnormal, \n    unfold fnormal at hnm, cases hnm with hnmp hnmq, \n    cases (@nnf_prsv_normal_core p hnmp) with ihp1 ihp2,  \n    cases (@nnf_prsv_normal_core q hnmq) with ihq1 ihq2,\n    apply and.intro;  apply and.intro; assumption]\n\nlemma nnf_prsv_normal_core [atom_type α β] : \n  ∀ {p : fm α}, fnormal β p → fnormal β (nnf β p) ∧ fnormal β (nnf β ¬' p)\n| (fm.true α) hnm := and.intro trivial trivial \n| (fm.false α) hnm := and.intro trivial trivial \n| (fm.atom a) hnm := \n  begin\n    apply and.intro hnm, \n    unfold nnf, rewrite fnormal_iff_fnormal_alt,\n    apply atom_type.neg_prsv_normal, apply hnm\n  end\n| (fm.not p) hnm := \n  begin\n    cases (@nnf_prsv_normal_core p _) with ih1 ih2,  \n    unfold nnf,apply and.intro; assumption, apply hnm\n  end\n| (fm.or p q) hnm := by nnf_prsv_normal_core_tac\n| (fm.and p q) hnm := by nnf_prsv_normal_core_tac\n| (fm.ex p) hnm := \n  begin unfold nnf, apply and.intro; trivial end\n\nlemma nnf_prsv_normal [atom_type α β] {p : fm α} (h : fnormal β p) : fnormal β (nnf β p) :=\n(nnf_prsv_normal_core h)^.elim_left\n\nlemma nnf_prsv_core [atom_type α β] : ∀ (p : fm α), qfree p → \n  (∀ (xs : list β), (I (@nnf α β _ p) xs ↔ I p xs) ∧ (I (@nnf α β _ ¬' p) xs ↔ I (¬' p) xs))   \n| (fm.true α)  Hp xs := by nnf_prsv_lit\n| (fm.false α) Hp xs := by nnf_prsv_lit\n| (fm.atom a)  Hp xs := \n  by {apply and.intro, refl, \n      unfold nnf, apply atom_type.neg_prsv} \n| (fm.and p q) Hp xs := \n  and.intro\n    (begin\n      unfold nnf, rewrite exp_I_and,   \n      rewrite (nnf_prsv_core p _ xs)^.elim_left,\n      rewrite (nnf_prsv_core q _ xs)^.elim_left, refl, \n      apply Hp^.elim_right, apply Hp^.elim_left\n     end)\n    (begin\n      unfold nnf, rewrite exp_I_or, \n      rewrite (nnf_prsv_core p _ xs)^.elim_right,\n      rewrite (nnf_prsv_core q _ xs)^.elim_right,\n      repeat {rewrite exp_I_not}, rewrite exp_I_and, \n      apply iff_not_and, \n      apply Hp^.elim_right, apply Hp^.elim_left\n     end)\n| (fm.or p q)  Hp xs := \n  and.intro\n    (begin\n      unfold nnf, rewrite exp_I_or,  \n      rewrite (nnf_prsv_core p _ xs)^.elim_left,\n      rewrite (nnf_prsv_core q _ xs)^.elim_left, refl, \n      apply Hp^.elim_right, apply Hp^.elim_left\n     end)\n    (begin\n      unfold nnf, rewrite exp_I_and, \n      rewrite (nnf_prsv_core p _ xs)^.elim_right,\n      rewrite (nnf_prsv_core q _ xs)^.elim_right,\n      repeat {rewrite exp_I_not}, rewrite exp_I_or, \n      apply iff_not_or, \n      apply Hp^.elim_right, apply Hp^.elim_left\n     end)\n| (fm.not p) Hp xs := \n  and.intro \n    (nnf_prsv_core p Hp xs)^.elim_right \n    (begin \n      unfold nnf, repeat {rewrite exp_I_not}, \n      rewrite (nnf_prsv_core p Hp xs)^.elim_left, \n      apply iff_not_not\n     end)\n| (fm.ex p) Hp xs := by cases Hp\n\nlemma nnf_prsv [atom_type α β] (p : fm α) (Hp : qfree p) (xs : list β) : \nI (@nnf α β _ p) xs ↔ I p xs := (nnf_prsv_core p Hp xs)^.elim_left\n\n", "meta": {"author": "avigad", "repo": "qelim", "sha": "b7d22864f1f0a2d21adad0f4fb3fc7ba665f8e60", "save_path": "github-repos/lean/avigad-qelim", "path": "github-repos/lean/avigad-qelim/qelim-b7d22864f1f0a2d21adad0f4fb3fc7ba665f8e60/common/nnf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.46890832974597024}}
{"text": "import .order .split_ifs\n\nnamespace rb\nuniverses u v w\ninductive col |Red|Black\ninductive node (k : Type u) (α : Type v) : Type max u v\n|Leaf {}: node\n|Node (c:col) (l:node) (v:k×α) (r:node) : node\nopen node col\nnotation `Rd` := (Node Red)\nnotation `Bk` := (Node Black)\n\nnamespace node\nvariables {k : Type u} [has_lt k] [decidable_rel ((<) : k → k → Prop)]\nvariables {α : Type v}\n\ndef empty : node k α := Leaf\ninstance : has_emptyc (node k α) := ⟨empty⟩\n\ndef mk_black : node k α → node k α\n|(Leaf) := Leaf\n|(Node _ l a r) := Node Black l a r\n\ndef mk_red : node k α → node k α \n|Leaf := Leaf\n|(Node _ l a r) := Node Red l a r\n\n@[simp] def lbal : node k α → k×α → node k α → node k α\n| (Rd (Rd a x b) y c) v r := Rd (Bk a x b) y (Bk c v r)\n| (Rd a x (Rd b y c)) v r := Rd (Bk a x b) y (Bk c v r)\n| l v r := Bk l v r\n\nvariables (a b c r : node k α) (x y v : k×α)\n\ndef rbal : node k α → k×α → node k α → node k α\n| l v (Rd (Rd b w c) z d) := Rd (Bk l v b) w (Bk c z d)\n| l v (Rd b w (Rd c z d)) := Rd (Bk l v b) w (Bk c z d)\n| l v r := Bk l v r\n\n/--Same as `rbal` but cases swapped.-/\ndef rbal' : node k α → k×α → node k α → node k α\n| l v (Rd b w (Rd c z d)) := Rd (Bk l v b) w (Bk c z d)\n| l v (Rd (Rd b w c) z d) := Rd (Bk l v b) w (Bk c z d)\n| l v r := Bk l v r\n\ndef lbalS : node k α → k×α → node k α → node k α\n | (Rd a x b) v r := Rd (Bk a x b) v r\n | l v (Bk a w b) := rbal' l v (Rd a w b)\n | l v (Rd (Bk a w b) z c) := Rd (Bk l v a) w (rbal' b z (mk_red c))\n | l v r := Rd l v r /- impossible -/\n\ndef rbalS : node k α → k×α → node k α → node k α\n| l v (Rd b w c) := Rd l v (Bk b w c)\n| (Bk a v b) w r := lbal (Rd a v b) w r\n| (Rd a v₁ (Bk b v₂ c)) v₃ r := Rd (lbal (mk_red a) v₁ b) v₂ (Bk c v₃ r)\n| l v r := Rd l v r /- impossible -/\n\ndef ins_aux (key : k) (a : α) : node k α → node k α \n|Leaf := Rd Leaf ⟨key,a⟩ Leaf\n|(Rd l v r) := -- l and r are both Black.\n    if key < v.1 then Rd (ins_aux l) v r -- [FIXME] `Leaf` is `Black`, but `ins_aux Leaf` is `Red`, but (Red (Red)) is not wf.\n    else if key > v.1 then Rd l v (ins_aux r) -- R\n    else Rd l ⟨key,a⟩ r -- R\n|(Bk l v r) :=\n    if key < v.1 then lbal (ins_aux l) v r -- BR\n    else if key > v.1 then rbal l v (ins_aux r) --BR\n    else Bk l ⟨key,a⟩ r -- B\n\ndef insert : k → α → node k α → node k α := \n    λ key x s, mk_black (ins_aux key x s)\ninstance : has_insert (k×α) (node k α) := ⟨λ ⟨key,a⟩ t, insert key a t⟩ \n\n/--Used to get the `append` method to be well-founded-/\ninstance custom_wf : has_well_founded (node k α × node k α) := \nhas_well_founded_of_has_sizeof (node k α × node k α) \n\ndef append : (node k α × node k α) → node k α\n|⟨Leaf, r⟩ := r\n|⟨ l,  Leaf⟩  := l\n|⟨(Rd ll lx lr),(Rd rl rx rr) ⟩ :=\n    match append ⟨lr, rl⟩ with\n    |Rd lr x rl := Rd (Rd ll lx lr) x (Rd rl rx rr)\n    |lrl := Rd ll lx (Rd lrl rx rr)\n    end\n|⟨ (Bk ll lx lr) ,(Bk rl rx rr) ⟩ :=\n    match append ⟨lr, rl⟩ with\n    |Rd lr x rl := Rd (Bk ll lx lr) x (Bk rl rx rr)\n    |lrl := lbalS ll lx (Bk lrl rx rr)\n    end\n|⟨(Rd ll lx lr), r⟩ :=  Rd ll lx (append ⟨lr, r⟩)\n|⟨ l, (Rd rl rx rr)⟩ := Rd (append ⟨l, rl⟩) rx rr\n\ndef erase_aux (key : k) : node k α → node k α\n|Leaf := Leaf\n|(Node _ l y r) :=\n    if key < y.1 then\n        match l with\n        | (Bk _ _ _) := lbalS (erase_aux l) y r\n        | _ := Rd (erase_aux l) y r\n        end\n    else if key > y.1 then\n        match r with\n        | (Bk _ _ _) := rbalS l y (erase_aux r)\n        | _ := Rd l y (erase_aux r)\n        end\n    else append ⟨l, r⟩\n\ndef erase (key : k) (t : node k α) : node k α := \nmk_black (erase_aux key t)\n\ndef pop_min_aux : node k α → k×α → node k α → k × α × node k α\n|Leaf ⟨k,x⟩ r := ⟨k,x,r⟩\n|(Node lc ll lx lr) y r :=\n    let ⟨k,x,l⟩ := pop_min_aux ll lx lr in\n    match lc with\n    |Black := ⟨k,x, lbalS l y r⟩\n    |Red := ⟨k,x, Rd l y r⟩\n    end\n\n/-- Remove the minimal element and key from the table. -/\ndef pop_min : node k α → option (k × α × node k α)\n|Leaf := none\n|(Node _ l y r) :=\n    let ⟨k,x,t⟩ := pop_min_aux l y r in\n    some ⟨k,x, mk_black t⟩\n\ndef fold {β : Type w} (f : k → α → β → β) : β → node k α → β \n|b Leaf := b\n|b (Node _ l ⟨k,a⟩ r) := fold (f k a $ fold b l) r\n\ndef mfold {T : Type u → Type u} [monad T] {β} \n  (f : k → α → β → T β) : β → node k α → T β\n|b Leaf := pure b\n|b (Node _ l ⟨k,a⟩ r) := do\n    b ← mfold b l,\n    b ← f k a b,\n    mfold b r\n/-- Get the number of black nodes between the root and the leaves of the trees. -/\ndef height : node k α → ℕ\n|Leaf := 0\n|(Rd l _ _ ) := height l\n|(Bk l _ _ ) := nat.succ $ height l\n\n\nnamespace treeify \n    def bogus : node k α × list (k×α) := ⟨Leaf, []⟩\n    def treeify_t (k : Type u) (α : Type v) : Type max u v := list (k×α) → (node k α × list (k×α))\n    def treeify_zero : treeify_t k α := λ acc, ⟨Leaf, acc⟩\n    def treeify_one : treeify_t k α \n    |(x::acc) := ⟨Rd Leaf x Leaf, acc⟩\n    |_ := bogus\n    def treeify_cont (f g : treeify_t k α) : treeify_t k α :=\n    λ acc, match f acc with\n    |⟨l, x::acc⟩ := let ⟨r, acc⟩ := g acc in ⟨Bk l x r, acc⟩\n    |_ := bogus\n    end\n    def positive := list bool\n    def treeify_aux : bool → positive → treeify_t k α\n    |pred [] := if pred then treeify_zero else treeify_one\n    |pred (ff::n) := treeify_cont (treeify_aux pred n) (treeify_aux tt n)\n    |pred (tt::n) := treeify_cont (treeify_aux ff n) (treeify_aux pred n)\n    def succ : positive → positive \n    |[] := [ff]\n    |(ff::tail) := tt::tail\n    |(tt::tail) := ff :: (succ tail)\n    def plength_aux : list α → positive → positive\n    |[] p := p\n    |(_::t) p := plength_aux t $ succ p\n    def plength (l : list α) := plength_aux l []\nend treeify\n/--Take an __ordered__ list and convert it to a node tree.-/\ndef treeify (l : list (k×α)) : node k α := \nprod.fst $ treeify.treeify_aux tt (treeify.plength l) l\n\ndef filter (p : k → α → bool) : node k α → node k α := \ntreeify ∘ fold (λ key a l, ite (p key a) (⟨key,a⟩::l) l) []\n\ndef get (key:k) : node k α → option α\n|Leaf := none\n|(Node _ l y r) :=\n    if key < y.1 then get l else\n    if y.1 < key then get r else\n    some (y.2)\n\ndef contains (key:k): node k α → bool\n:= option.is_some ∘ get key\n\ninstance : has_mem (k) (node k α) := ⟨λ key t, contains key t⟩\n\ndef min : node k α → option (k×α)\n|Leaf := none\n|(Node _ l x _) := (min l) <|> some x\ndef max : node k α → option (k× α ) \n|Leaf := none\n|(Node _ _ x r) := (max r) <|> some x\n\n/-- Asssign each member of `r` to `l`, if there is a key clash then choose the entry in `r` and clobber `l`. -/\ndef merge  : node k α → node k α → node k α := fold insert\n\ndef table (k : Type u) : Type u := node k unit\n\ndef intersect (t₁ t₂ : table k) : table k :=\n    if height t₁ < height t₂ \n    then filter (λ k _, contains k t₂) t₁\n    else filter (λ k _, contains k t₁) t₂\ninstance : has_inter (table k) := ⟨intersect⟩ \n\ndef union (l r : table k) : table k :=\n    if height l < height r \n    then fold insert r l\n    else fold insert l r\ninstance : has_union (table k) := ⟨union⟩\n\n/--Remove all of the keys found in the table `r` from the dictionary `l`. -/\ndef subtract (l : node k α) (r : table k) : node k α := fold (λ k _ l, erase k l) l r\n--instance : has_sub (table k) := ⟨subtract⟩\n\ndef map {β : Type w} (f : α → β) : node k α → node k β\n|Leaf := Leaf\n|(Node c l ⟨k,a⟩ r) := Node c (map l) ⟨k, f a⟩ (map r)\ninstance : functor (node k) :=\n{ map := λ _ _ f t, map f t\n}\ndef keys_of : (node k α) → table k := map (λ a, ⟨⟩)\nend node\n\nnamespace proofs\nopen nat node\nvariables {k : Type u} {α : Type v}\nvariables [decidable_linear_order k]\ninductive is_rb : node k α → col → nat → Prop\n|leaf_rb {} : is_rb Leaf Black 0\n|red_rb {l v r n} (rb_l : is_rb l Black n) (rb_r : is_rb r Black n) : is_rb (Rd l v r) Red n\n|black_rb {l c₁ v r c₂ n} (rb_l : is_rb l c₁ n) (rb_r : is_rb r c₂ n) : is_rb(Bk l v r) Black (succ n)\n\ninductive mem (key:k) : node k α → Prop\n|left {c l v r} : mem l → mem (Node c l v r)\n|mid {c l v r} : (v:k×α).1 = key → mem (Node c l v r)\n|right {c l v r} : mem r → mem (Node c l v r)\ninstance : has_mem (k) (node k α) := ⟨mem⟩\nlemma leaf_empty {key : k} : key ∉ (@Leaf k α) := λ h, by cases h\n\ndef dominates (k₁ : k) (t : node k α) : Prop\n:= ∀ k₂ ∈ t, k₁ > k₂\ndef dominated_by (k₁ : k) (t : node k α) : Prop\n:= ∀ k₂ ∈ t, k₁ < k₂\ninfix ` ⋗ `: 50 := dominates\ninfix ` ⋖ `: 50 := dominated_by\n\ninductive ordered : node k α → Prop\n|o_leaf {} : ordered (Leaf) \n|o_node {c l} {v:k×α} {r} (ol:ordered l) (vdl :  v.1 ⋗ l) (rdv : v.1 ⋖ r) (or : ordered r) : ordered (Node c l v r)\nlemma ordered.ol {c l v r} : ordered (Node c l v r : node k α) → ordered l := begin intros, cases a, assumption end\nlemma ordered.or {c l v r} : ordered (Node c l v r : node k α) → ordered r := begin intros, cases a, assumption end\nopen ordered\n@[simp] def is_wf (t: node k α) :  Prop := (∃ n, is_rb t Black n) ∧ ordered t\n\n\nvariables {key k₁ k₂ :k} {a:α} {v v₁ v₂ : k × α} {l r t : node k α} {c : col}\n\n@[trans] lemma dominates.trans : k₁ > k₂ → k₂ ⋗ t → k₁ ⋗ t\n:= λ p q k₃ kt, lt.trans (q _ kt) p \nlemma dominates.leaf : k₁ ⋗ (@Leaf k α) := λ k₂ kt, false.rec_on _ $ leaf_empty kt\nlemma dominates.node (hl : k₁ ⋗ l) (hv : k₁ > v.1) (hr : k₁ ⋗ r) : k₁ ⋗ (Node c l v r)\n|k₂ (mem.left xl) := hl _ xl\n|k₂ (mem.mid xm) := xm ▸ hv\n|k₂ (mem.right xr) := hr _ xr\nlemma dominates.l : k₁ ⋗ (Node c l v r) → k₁ ⋗ l := λ h k₂ hl, h k₂ (mem.left hl)\nlemma dominates.r : k₁ ⋗ (Node c l v r) → k₁ ⋗ r := λ h k₂ hr, h k₂ (mem.right hr)\nlemma dominates.v : k₁ ⋗ (Node c l v r) → k₁ > v.1 := λ h, h v.1 $ mem.mid rfl\n@[trans] lemma dominated_by.trans : k₁ < k₂ → k₂ ⋖ t → k₁ ⋖ t\n:= λ p q k₃ kt, lt.trans p (q _ kt)\nlemma dominated_by.leaf : k₁ ⋖ (@Leaf k α) := λ k₂ kt, false.rec_on _ $ leaf_empty kt\nlemma dominated_by.node (hl : k₁ ⋖ l) (hv : k₁ < v.1) (hr : k₁ ⋖ r) : k₁ ⋖ (Node c l v r)\n|k₂ (mem.left xl) := hl _ xl\n|k₂ (mem.mid xm) := xm ▸ hv\n|k₂ (mem.right xr) := hr _ xr\nlemma dominated_by.l : k₁ ⋖ (Node c l v r) → k₁ ⋖ l := λ h k₂ hl, h k₂ (mem.left hl)\nlemma dominated_by.r : k₁ ⋖ (Node c l v r) → k₁ ⋖ r := λ h k₂ hr, h k₂ (mem.right hr)\nlemma dominated_by.v : k₁ ⋖ (Node c l v r) → k₁ < v.1 := λ h, h v.1 $ mem.mid rfl\n\ndef all_below := λ (t₁ t₂ : node k α), ∀ (k₁ ∈ t₁) (k₂ ∈ t₂), k₁ < k₂\ninfix ` ⊏ `: 100 := all_below\n\nopen tactic\n\n/- Look at the target, find all occurences of the name,  -/\n\nmeta def expand (n : name) : tactic unit := \ndo delta_target [n]\n\nmeta def get_cases_candidate_single (e : expr) : tactic expr :=\ndo\n    --e ← tactic.to_expr pe,\n    s_l ← get_simp_lemmas_or_default none,\n    e ← simp_lemmas.dsimplify s_l [`rec_on, `cases_on] e {fail_if_unchanged := ff}, -- rewrite alternative definitions of recursion.\n    --e ← whnf e,\n    (fn,args) ← pure $ expr.get_app_fn_args e,\n    fn_name ← pure $ expr.const_name fn,\n    env ← get_env,\n    is_rec ← pure $ environment.is_recursor env fn_name,\n    -- hopefully, the last argument of the recursor is always the thing being recursed on.\n    rec_arg ← pure $ expr.app_arg e,\n    is_local ← pure $ expr.is_local_constant rec_arg,\n    -- trace fn_name,\n    -- trace args,\n    -- trace is_rec,\n    -- trace rec_arg,\n    -- trace is_local,\n    -- trace \"\\n\",\n    guard is_rec,\n    guard is_local, \n    pure rec_arg\n\nmeta def get_cases_candidate : expr → tactic expr := λ e,\nget_cases_candidate_single e <|> list.any_of (expr.get_app_args e) get_cases_candidate\n\nmeta def recursion_cases : tactic unit :=\ndo\n     t ← target >>= instantiate_mvars,\n     cand ← get_cases_candidate t,\n     --trace cand,\n     tactic.cases_core cand,\n     --dsimp_target none [] {fail_if_unchanged := ff},\n     all_goals $ try $ dsimp_target,\n     --(dsimp_target none []) <|> pure ⟨⟩,\n    --  args ← pure $ expr.get_app_args e,\n    --  list.any_of args cases_on_variable\n    --tactic.dsimplify (λ e, pure ⟨e,tt⟩) (dsimp_post) t,\n    pure ⟨⟩\n\n#check node.cases_on\n#check node.rec_on\n\nmeta def cases_all : expr → tactic (list expr) := λ h,\ndo \n    --h ← get_local h_name,\n    --trace h,\n    ty ← infer_type h >>= instantiate_mvars >>= whnf,\n    --trace ty,\n    --[c] ← get_constructors_for ty | pure [],\n    -- count the number of non-named arguments\n    [(case_name,new_hyps,new_subs)] ← cases_core h | fail \"more than one constructor\",\n    list.mfoldl (λ l h, list.append l <$> ((cases_all h) <|> (pure [h]))) [] new_hyps\n\nmeta def one_of : list (tactic unit) → tactic unit\n|(h::t) := h <|> one_of t\n|[] := skip\n\nmeta def apply_pexpr : pexpr → tactic unit :=\nλ p, ((to_expr p) >>= apply) $> ⟨⟩\n\ninductive growth : node k α → nat → Prop\n|stay {c n t} : is_rb t c n → growth t n\n|sprout_l {n l v r} : is_rb l Red n → is_rb r Black n → growth (Rd l v r) n\n|sprout_r {n l v r} : is_rb l Black n → is_rb r Red n → growth (Rd l v r) n\n/- We have to consider way more cases than the written definition \n    of `rbal` because the equation compiler has to transform the match expression into a series of\n    `cases_on` calls which is less flexible than match.\n    As far as I can tell these are the solutions to avoiding having to do all of the cases\n    - Write a `rbal_ind` helper lemma: like below.\n    - Write some really clever automation that reduces the problem to a few cases for you.\n    - Write your proofs inline with the function - \n        this tends to obfuscate what your underlying data transformation is \n        and makes everything quite bloaty. It is very hard to pull off.\n        -/\nlemma rbal_ind {P Q : node k α → Prop} {q : Q r}\n    (c₁ : Π  {b c d w z}, Q(Rd (Rd b w c) z d) → P(Rd (Bk l v b) w (Bk c z d)))\n    (c₂ : Π  {b c d w z}, Q(Rd b w (Rd c z d)) → P(Rd (Bk l v b) w (Bk c z d)))\n    (c₃ : P(Bk l v r))\n    : P(rbal l v r)\n    := \n    begin\n        expand ``rbal, dsimp_target none [`id_rhs],\n        repeat{one_of [\n            recursion_cases,\n            apply_pexpr ```(c₁ q),\n            apply_pexpr ```(c₂ q),\n            apply_pexpr ```(c₃)  \n        ]},\n    end\n\n-- lemma ins_aux_ind {P Q : node k α → Prop} (q : Q t)\n--     (c₁ : P(Rd Leaf ⟨key,a⟩ Leaf))\n--     (c₂ : Π {l v r}, Q(Bk l v r) → key < v.1 → P(ins_aux key a l) → P(lbal (ins_aux key a l) v r))\n--     (c₃ : Π {l v r}, Q(Bk l v r) → key > v.1 → P(ins_aux key a r) → P(rbal l v (ins_aux key a r)))\n--     (c₄ : Π {l v r}, Q(Bk l v r) → key = v.1 → P(Bk l ⟨key,a⟩ r))\n--     (c₅ : Π {l v r}, Q(Rd l v r) → key < v.1 → P(ins_aux key a l) → P(Rd (ins_aux key a l) v r))\n--     (c₆ : Π {l v r}, Q(Rd l v r) → key > v.1 → P(ins_aux key a r) → P(Rd l v (ins_aux key a r)))\n--     (c₇ : Π {l v r}, Q(Rd l v r) → key = v.1 → P(Rd l ⟨key,a⟩ r))\n--     : P(ins_aux key a t) :=\n-- begin\n--   induction t with c l v r, apply c₁, cases c,\n--   simp [ins_aux],\n--   --expand ``ins_aux, simp, dsimp_target none [`id_rhs],\n--   focus {\n--       split_ifs, apply c₅ _ _ (t_ih_l _), repeat {assumption}, \n--   }\n\n-- end\n\nlemma rbal.ordered (ol : ordered l) (vdl : v.1 ⋗ l) (rdv : v.1 ⋖ r) (or : ordered r) : ordered (rbal l v r) :=\nbegin\n   apply rbal_ind, apply and.intro or rdv,\n   focus {\n        intros _ _ _ _ _ a, (get_local `a >>= cases_all), apply o_node (o_node _ _ _ _) _ _ (o_node _ _ _ _), repeat {assumption},\n        apply a_right.l.l, \n        apply dominates.node, apply dominates.trans, apply a_right.l.v, assumption, apply a_right.l.v, assumption,\n        apply dominated_by.node, assumption, apply a_left_vdl.v, apply dominated_by.trans, apply a_left_vdl.v, assumption, apply a_left_vdl.r\n      },\n    focus {\n        intros _ _ _ _ _ a, (get_local `a >>= cases_all), apply o_node (o_node _ _ _ _) _ _ (o_node _ _ _ _), repeat {assumption},\n        apply a_right.l,\n        apply dominates.node, apply dominates.trans, apply a_right.v, assumption, apply a_right.v, assumption,\n        apply dominated_by.node, apply a_left_rdv.l, apply a_left_rdv.v, apply dominated_by.trans, apply a_left_rdv.v, assumption\n    },\n    focus {\n        apply o_node ol vdl rdv or, \n    }\nend\n\nlemma rbal_mem : (key ∈ r) → (key ∈ rbal l v r) := begin \n    intros,\n    apply rbal_ind, apply a, focus {intros _ _ _ _ _ h, cases h, cases h_a, \n        apply (mem.left $ mem.right _),assumption, \n        apply (mem.mid _), assumption,\n        apply (mem.right $ mem.left _), assumption,\n        apply (mem.right $ mem.mid _), assumption,\n        apply (mem.right $ mem.right _), assumption,\n    }, \n    focus {intros, cases a_1,\n        apply (mem.left $ mem.right _), assumption,\n    apply (mem.mid _), assumption,\n    cases a_1_a,\n    apply (mem.right $ mem.left _), assumption,\n    apply (mem.right $ mem.mid _), assumption,\n    apply (mem.right $ mem.right _), assumption,\n     },\n    focus {\n        apply mem.right, assumption,\n    }\nend\n\nlemma rbal_rb {cl n} : is_rb l cl n → growth r n → ∃ c', is_rb (rbal l v r) c' (succ n) := \nbegin\n    intros lrb rrg,\n    apply @rbal_ind k _ _ _ _ _  (λ t, ∃ c', is_rb (t) c' (succ n)) (λ t, growth t n), apply rrg, \n    focus {intros, cases a, cases a_a, cases a_a_rb_l, split, apply is_rb.red_rb, apply is_rb.black_rb, assumption, cases a_a, assumption, apply is_rb.black_rb,    },  \n    focus {intros, cases a, cases a_rb_r, },\n    focus {existsi Black, apply is_rb.black_rb, assumption, assumption}\nend\n\n-- [TODO] repeat for lbal.\n\nlemma eq_of_nlt {a b : k} : (¬ a < b) → ¬(b < a) → a = b := λ p q,\nmatch lt_trichotomy a b with\n|(or.inl h) := absurd h p\n|(or.inr (or.inl h)) := h\n|(or.inr (or.inr h)) := absurd h q\nend\n\nlemma lbal.ordered : ordered l → v.1 ⋗ l → v.1 ⋖ r → ordered r → ordered (lbal l v r) := sorry\nlemma lbal.mem : (key ∈ l) → (key ∈ lbal l v r) := sorry\nlemma lbal.rb {cl cr n} : is_rb l cl n → is_rb r cr n → ∃ c', is_rb (lbal l v r) c' (succ n) := sorry\nlemma ins_aux.mem : (k₁ ∈ ins_aux key a t) ↔ (k₁ ∈ t ∨ k₁ = key) := sorry\nlemma ins_aux.is_rb {n} : is_rb t c n → ∃ c', is_rb (ins_aux key a t) c' n :=\nbegin\n    intro rb,\n    induction rb with l v r n hl hr il ir l c₁ v r c₂ n hl hr il ir,\n    case rb.proofs.is_rb.leaf_rb {\n        simp [ins_aux], split,\n        apply is_rb.red_rb, all_goals {apply is_rb.leaf_rb},\n    },\n    case rb.proofs.is_rb.red_rb {\n        simp [ins_aux], split_ifs,\n        split, apply is_rb.red_rb,\n    }\nend\nlemma ins_aux.ordered :  ordered t → ordered (ins_aux key a t) :=\nbegin\n    intro o, \n    induction t with c l v r lq rq,\n    case rb.node.Leaf {\n        simp [ins_aux], apply o_node, assumption, apply dominates.leaf, apply dominated_by.leaf, assumption,\n    },\n    case rb.node.Node {\n        cases o,\n        have hl := lq o_ol, clear lq,\n        have hr := rq o_or, clear rq,\n        cases c,\n        all_goals {simp[ins_aux] },\n        case rb.col.Red {\n            split_ifs,\n            apply o_node,\n            any_goals {assumption},\n            focus {\n                intros k₁ ki,\n                have h₂ := ins_aux.mem.1 ki, cases h₂,\n                apply o_vdl, assumption,\n                cases h₂, assumption,\n            },\n            split_ifs, focus {\n                apply o_node, any_goals {assumption}, intros k₁ ki,\n                cases (ins_aux.mem.1 ki),\n                apply o_rdv, assumption,\n                cases h_2, assumption\n            },\n            split_ifs,\n            have e := eq_of_nlt h h_1, subst e, \n            apply o_node, any_goals {assumption}\n        },\n        case rb.col.Black {\n            split_ifs, apply lbal.ordered, any_goals {assumption},\n            intros k₁ ki,  cases (ins_aux.mem.1 ki),\n            apply o_vdl _ h_1, subst h_1, assumption,\n            split_ifs, apply rbal.ordered, any_goals {assumption},\n            intros k₁ ki, cases (ins_aux.mem.1 ki),\n            apply o_rdv _ h_2, subst h_2, assumption,\n            split_ifs,\n            have e := eq_of_nlt h h_1, subst e,\n            apply o_node, any_goals {assumption} \n        }\n    }\nend\n\n/- Now that I have worked this out, \nI am 100% sure that I can write some automation for this, probably in the same vain as auto2\n so I don't have to redesign anything.\n   It will be some non-trivial amount of work.\n -/\n\nlemma empty_is_wf : is_wf (@node.empty k _ _ α) := sorry\n\nlemma insert_is_wf :is_wf t → is_wf (insert key a t) := sorry\nlemma insert_works :  is_wf t → get key (insert key a t) = some a := sorry\n\nlemma erase_is_wf : is_wf t → is_wf (erase key t) := sorry \nlemma erase_works : is_wf t → get key (erase key t) = none := sorry\n\n/- [TODO] from mathlib -/\ninductive sorted (R : α → α → Prop) : list α → Prop\n|nil {} : sorted []\n|cons {a} {l:list α} : (∀ b∈l, R a b) → sorted l → sorted (a::l)\nlemma treeify_works : ∀ {l : list (k×α)}, sorted ((<) on prod.fst) l → is_wf (treeify l) := sorry\nlemma filter_works {p} : is_wf t → is_wf (filter p t) := sorry\n\nend proofs\nend rb\n\n\n\n", "meta": {"author": "EdAyers", "repo": "edlib", "sha": "78b8c5d91f023f939c102837d748868e2f3ed27d", "save_path": "github-repos/lean/EdAyers-edlib", "path": "github-repos/lean/EdAyers-edlib/edlib-78b8c5d91f023f939c102837d748868e2f3ed27d/rb.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4688340450874563}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.module.linear_map\nimport Mathlib.algebra.opposites\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# Module operations on `Mᵒᵖ`\n\nThis file contains definitions that could not be placed into `algebra.opposites` due to import\ncycles.\n-/\n\nnamespace opposite\n\n\n/-- `opposite.distrib_mul_action` extends to a `semimodule` -/\nprotected instance semimodule (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : semimodule R (Mᵒᵖ) :=\n  semimodule.mk sorry sorry\n\n/-- The function `op` is a linear equivalence. -/\ndef op_linear_equiv (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : linear_equiv R M (Mᵒᵖ) :=\n  linear_equiv.mk (add_equiv.to_fun op_add_equiv) sorry sorry (add_equiv.inv_fun op_add_equiv) sorry sorry\n\n@[simp] theorem coe_op_linear_equiv (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : ⇑(op_linear_equiv R) = op :=\n  rfl\n\n@[simp] theorem coe_op_linear_equiv_symm (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : ⇑(linear_equiv.symm (op_linear_equiv R)) = unop :=\n  rfl\n\n@[simp] theorem coe_op_linear_equiv_to_linear_map (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : ⇑(linear_equiv.to_linear_map (op_linear_equiv R)) = op :=\n  rfl\n\n@[simp] theorem coe_op_linear_equiv_symm_to_linear_map (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : ⇑(linear_equiv.to_linear_map (linear_equiv.symm (op_linear_equiv R))) = unop :=\n  rfl\n\n@[simp] theorem op_linear_equiv_to_add_equiv (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : linear_equiv.to_add_equiv (op_linear_equiv R) = op_add_equiv :=\n  rfl\n\n@[simp] theorem op_linear_equiv_symm_to_add_equiv (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] : linear_equiv.to_add_equiv (linear_equiv.symm (op_linear_equiv R)) = add_equiv.symm op_add_equiv :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/module/opposites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390162, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.46883404294882797}}
{"text": "/-\nCopyright (c) 2018 Michael Jendrusch. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Michael Jendrusch, Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.monoidal.category\nimport category_theory.adjunction.basic\n\n/-!\n# (Lax) monoidal functors\n\nA lax monoidal functor `F` between monoidal categories `C` and `D`\nis a functor between the underlying categories equipped with morphisms\n* `ε : 𝟙_ D ⟶ F.obj (𝟙_ C)` (called the unit morphism)\n* `μ X Y : (F.obj X) ⊗ (F.obj Y) ⟶ F.obj (X ⊗ Y)` (called the tensorator, or strength).\nsatisfying various axioms.\n\nA monoidal functor is a lax monoidal functor for which `ε` and `μ` are isomorphisms.\n\nWe show that the composition of (lax) monoidal functors gives a (lax) monoidal functor.\n\nSee also `category_theory.monoidal.functorial` for a typeclass decorating an object-level\nfunction with the additional data of a monoidal functor.\nThis is useful when stating that a pre-existing functor is monoidal.\n\nSee `category_theory.monoidal.natural_transformation` for monoidal natural transformations.\n\nWe show in `category_theory.monoidal.Mon_` that lax monoidal functors take monoid objects\nto monoid objects.\n\n## Future work\n* Oplax monoidal functors.\n\n## References\n\nSee https://stacks.math.columbia.edu/tag/0FFL.\n-/\n\nopen category_theory\n\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\nopen category_theory.category\nopen category_theory.functor\n\nnamespace category_theory\n\nsection\n\nopen monoidal_category\n\nvariables (C : Type u₁) [category.{v₁} C] [monoidal_category.{v₁} C]\n          (D : Type u₂) [category.{v₂} D] [monoidal_category.{v₂} D]\n\n/-- A lax monoidal functor is a functor `F : C ⥤ D` between monoidal categories,\nequipped with morphisms `ε : 𝟙 _D ⟶ F.obj (𝟙_ C)` and `μ X Y : F.obj X ⊗ F.obj Y ⟶ F.obj (X ⊗ Y)`,\nsatisfying the appropriate coherences. -/\n-- The direction of `left_unitality` and `right_unitality` as simp lemmas may look strange:\n-- remember the rule of thumb that component indices of natural transformations\n-- \"weigh more\" than structural maps.\n-- (However by this argument `associativity` is currently stated backwards!)\nstructure lax_monoidal_functor extends C ⥤ D :=\n-- unit morphism\n(ε               : 𝟙_ D ⟶ obj (𝟙_ C))\n-- tensorator\n(μ                : Π X Y : C, (obj X) ⊗ (obj Y) ⟶ obj (X ⊗ Y))\n(μ_natural'       : ∀ {X Y X' Y' : C}\n  (f : X ⟶ Y) (g : X' ⟶ Y'),\n  ((map f) ⊗ (map g)) ≫ μ Y Y' = μ X X' ≫ map (f ⊗ g)\n  . obviously)\n-- associativity of the tensorator\n(associativity'   : ∀ (X Y Z : C),\n    (μ X Y ⊗ 𝟙 (obj Z)) ≫ μ (X ⊗ Y) Z ≫ map (α_ X Y Z).hom\n  = (α_ (obj X) (obj Y) (obj Z)).hom ≫ (𝟙 (obj X) ⊗ μ Y Z) ≫ μ X (Y ⊗ Z)\n  . obviously)\n-- unitality\n(left_unitality'  : ∀ X : C,\n    (λ_ (obj X)).hom\n  = (ε ⊗ 𝟙 (obj X)) ≫ μ (𝟙_ C) X ≫ map (λ_ X).hom\n  . obviously)\n(right_unitality' : ∀ X : C,\n    (ρ_ (obj X)).hom\n  = (𝟙 (obj X) ⊗ ε) ≫ μ X (𝟙_ C) ≫ map (ρ_ X).hom\n  . obviously)\n\nrestate_axiom lax_monoidal_functor.μ_natural'\nattribute [simp, reassoc] lax_monoidal_functor.μ_natural\nrestate_axiom lax_monoidal_functor.left_unitality'\nattribute [simp] lax_monoidal_functor.left_unitality\nrestate_axiom lax_monoidal_functor.right_unitality'\nattribute [simp] lax_monoidal_functor.right_unitality\nrestate_axiom lax_monoidal_functor.associativity'\nattribute [simp, reassoc] lax_monoidal_functor.associativity\n\n-- When `rewrite_search` lands, add @[search] attributes to\n-- lax_monoidal_functor.μ_natural lax_monoidal_functor.left_unitality\n-- lax_monoidal_functor.right_unitality lax_monoidal_functor.associativity\n\nsection\nvariables {C D}\n\n@[simp, reassoc]\nlemma lax_monoidal_functor.left_unitality_inv (F : lax_monoidal_functor C D) (X : C) :\n  (λ_ (F.obj X)).inv ≫ (F.ε ⊗ 𝟙 (F.obj X)) ≫ F.μ (𝟙_ C) X = F.map (λ_ X).inv :=\nbegin\n  rw [iso.inv_comp_eq, F.left_unitality, category.assoc, category.assoc,\n    ←F.to_functor.map_comp, iso.hom_inv_id, F.to_functor.map_id, comp_id],\nend\n\n@[simp, reassoc]\nlemma lax_monoidal_functor.right_unitality_inv (F : lax_monoidal_functor C D) (X : C) :\n  (ρ_ (F.obj X)).inv ≫ (𝟙 (F.obj X) ⊗ F.ε) ≫ F.μ X (𝟙_ C) = F.map (ρ_ X).inv :=\nbegin\n  rw [iso.inv_comp_eq, F.right_unitality, category.assoc, category.assoc,\n    ←F.to_functor.map_comp, iso.hom_inv_id, F.to_functor.map_id, comp_id],\nend\n\n@[simp, reassoc]\nlemma lax_monoidal_functor.associativity_inv (F : lax_monoidal_functor C D) (X Y Z : C) :\n  (𝟙 (F.obj X) ⊗ F.μ Y Z) ≫ F.μ X (Y ⊗ Z) ≫ F.map (α_ X Y Z).inv =\n    (α_ (F.obj X) (F.obj Y) (F.obj Z)).inv ≫ (F.μ X Y ⊗ 𝟙 (F.obj Z)) ≫ F.μ (X ⊗ Y) Z :=\nbegin\n  rw [iso.eq_inv_comp, ←F.associativity_assoc,\n    ←F.to_functor.map_comp, iso.hom_inv_id, F.to_functor.map_id, comp_id],\nend\n\nend\n\n/--\nA monoidal functor is a lax monoidal functor for which the tensorator and unitor as isomorphisms.\n\nSee https://stacks.math.columbia.edu/tag/0FFL.\n-/\nstructure monoidal_functor\nextends lax_monoidal_functor.{v₁ v₂} C D :=\n(ε_is_iso            : is_iso ε . tactic.apply_instance)\n(μ_is_iso            : Π X Y : C, is_iso (μ X Y) . tactic.apply_instance)\n\nattribute [instance] monoidal_functor.ε_is_iso monoidal_functor.μ_is_iso\n\nvariables {C D}\n\n/--\nThe unit morphism of a (strong) monoidal functor as an isomorphism.\n-/\nnoncomputable\ndef monoidal_functor.ε_iso (F : monoidal_functor.{v₁ v₂} C D) :\n  tensor_unit D ≅ F.obj (tensor_unit C) :=\nas_iso F.ε\n\n/--\nThe tensorator of a (strong) monoidal functor as an isomorphism.\n-/\nnoncomputable\ndef monoidal_functor.μ_iso (F : monoidal_functor.{v₁ v₂} C D) (X Y : C) :\n  (F.obj X) ⊗ (F.obj Y) ≅ F.obj (X ⊗ Y) :=\nas_iso (F.μ X Y)\n\nend\n\nopen monoidal_category\n\nnamespace lax_monoidal_functor\n\nvariables (C : Type u₁) [category.{v₁} C] [monoidal_category.{v₁} C]\n\n/-- The identity lax monoidal functor. -/\n@[simps] def id : lax_monoidal_functor.{v₁ v₁} C C :=\n{ ε := 𝟙 _,\n  μ := λ X Y, 𝟙 _,\n  .. 𝟭 C }\n\ninstance : inhabited (lax_monoidal_functor C C) := ⟨id C⟩\n\nend lax_monoidal_functor\n\nnamespace monoidal_functor\n\nsection\nvariables {C : Type u₁} [category.{v₁} C] [monoidal_category.{v₁} C]\nvariables {D : Type u₂} [category.{v₂} D] [monoidal_category.{v₂} D]\n\nlemma map_tensor (F : monoidal_functor.{v₁ v₂} C D) {X Y X' Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') :\n  F.map (f ⊗ g) = inv (F.μ X X') ≫ ((F.map f) ⊗ (F.map g)) ≫ F.μ Y Y' :=\nby simp\n\nlemma map_left_unitor (F : monoidal_functor.{v₁ v₂} C D) (X : C) :\n  F.map (λ_ X).hom = inv (F.μ (𝟙_ C) X) ≫ (inv F.ε ⊗ 𝟙 (F.obj X)) ≫ (λ_ (F.obj X)).hom :=\nbegin\n  simp only [lax_monoidal_functor.left_unitality],\n  slice_rhs 2 3 { rw ←comp_tensor_id, simp, },\n  simp,\nend\n\nlemma map_right_unitor (F : monoidal_functor.{v₁ v₂} C D) (X : C) :\n  F.map (ρ_ X).hom = inv (F.μ X (𝟙_ C)) ≫ (𝟙 (F.obj X) ⊗ inv F.ε) ≫ (ρ_ (F.obj X)).hom :=\nbegin\n  simp only [lax_monoidal_functor.right_unitality],\n  slice_rhs 2 3 { rw ←id_tensor_comp, simp, },\n  simp,\nend\n\n/-- The tensorator as a natural isomorphism. -/\nnoncomputable\ndef μ_nat_iso (F : monoidal_functor.{v₁ v₂} C D) :\n  (functor.prod F.to_functor F.to_functor) ⋙ (tensor D) ≅ (tensor C) ⋙ F.to_functor :=\nnat_iso.of_components\n  (by { intros, apply F.μ_iso })\n  (by { intros, apply F.to_lax_monoidal_functor.μ_natural })\nend\n\nsection\nvariables (C : Type u₁) [category.{v₁} C] [monoidal_category.{v₁} C]\n\n/-- The identity monoidal functor. -/\n@[simps] def id : monoidal_functor.{v₁ v₁} C C :=\n{ ε := 𝟙 _,\n  μ := λ X Y, 𝟙 _,\n  .. 𝟭 C }\n\ninstance : inhabited (monoidal_functor C C) := ⟨id C⟩\n\nend\n\nend monoidal_functor\n\nvariables {C : Type u₁} [category.{v₁} C] [monoidal_category.{v₁} C]\nvariables {D : Type u₂} [category.{v₂} D] [monoidal_category.{v₂} D]\nvariables {E : Type u₃} [category.{v₃} E] [monoidal_category.{v₃} E]\n\nnamespace lax_monoidal_functor\nvariables (F : lax_monoidal_functor.{v₁ v₂} C D) (G : lax_monoidal_functor.{v₂ v₃} D E)\n\n-- The proofs here are horrendous; rewrite_search helps a lot.\n/-- The composition of two lax monoidal functors is again lax monoidal. -/\n@[simps] def comp : lax_monoidal_functor.{v₁ v₃} C E :=\n{ ε                := G.ε ≫ (G.map F.ε),\n  μ                := λ X Y, G.μ (F.obj X) (F.obj Y) ≫ G.map (F.μ X Y),\n  μ_natural'       := λ _ _ _ _ f g,\n  begin\n    simp only [functor.comp_map, assoc],\n    rw [←category.assoc, lax_monoidal_functor.μ_natural, category.assoc, ←map_comp, ←map_comp,\n        ←lax_monoidal_functor.μ_natural]\n  end,\n  associativity'   := λ X Y Z,\n  begin\n    dsimp,\n    rw id_tensor_comp,\n    slice_rhs 3 4 { rw [← G.to_functor.map_id, G.μ_natural], },\n    slice_rhs 1 3 { rw ←G.associativity, },\n    rw comp_tensor_id,\n    slice_lhs 2 3 { rw [← G.to_functor.map_id, G.μ_natural], },\n    rw [category.assoc, category.assoc, category.assoc, category.assoc, category.assoc,\n        ←G.to_functor.map_comp, ←G.to_functor.map_comp, ←G.to_functor.map_comp,\n        ←G.to_functor.map_comp, F.associativity],\n  end,\n  left_unitality'  := λ X,\n  begin\n    dsimp,\n    rw [G.left_unitality, comp_tensor_id, category.assoc, category.assoc],\n    apply congr_arg,\n    rw [F.left_unitality, map_comp, ←nat_trans.id_app, ←category.assoc,\n        ←lax_monoidal_functor.μ_natural, nat_trans.id_app, map_id, ←category.assoc, map_comp],\n  end,\n  right_unitality' := λ X,\n  begin\n    dsimp,\n    rw [G.right_unitality, id_tensor_comp, category.assoc, category.assoc],\n    apply congr_arg,\n    rw [F.right_unitality, map_comp, ←nat_trans.id_app, ←category.assoc,\n        ←lax_monoidal_functor.μ_natural, nat_trans.id_app, map_id, ←category.assoc, map_comp],\n  end,\n  .. (F.to_functor) ⋙ (G.to_functor) }.\n\ninfixr ` ⊗⋙ `:80 := comp\n\nend lax_monoidal_functor\n\nnamespace monoidal_functor\n\nvariables (F : monoidal_functor.{v₁ v₂} C D) (G : monoidal_functor.{v₂ v₃} D E)\n\n/-- The composition of two monoidal functors is again monoidal. -/\n@[simps]\ndef comp : monoidal_functor.{v₁ v₃} C E :=\n{ ε_is_iso := by { dsimp, apply_instance },\n  μ_is_iso := by { dsimp, apply_instance },\n  .. (F.to_lax_monoidal_functor).comp (G.to_lax_monoidal_functor) }.\n\ninfixr ` ⊗⋙ `:80 := comp -- We overload notation; potentially dangerous, but it seems to work.\n\nend monoidal_functor\n\n/--\nIf we have a right adjoint functor `G` to a monoidal functor `F`, then `G` has a lax monoidal\nstructure as well.\n-/\n@[simps]\nnoncomputable\ndef monoidal_adjoint (F : monoidal_functor C D) {G : D ⥤ C} (h : F.to_functor ⊣ G) :\n  lax_monoidal_functor D C :=\n{ to_functor := G,\n  ε := h.hom_equiv _ _ (inv F.ε),\n  μ := λ X Y,\n    h.hom_equiv _ (X ⊗ Y) (inv (F.μ (G.obj X) (G.obj Y)) ≫ (h.counit.app X ⊗ h.counit.app Y)),\n  μ_natural' := λ X Y X' Y' f g,\n  begin\n    rw [←h.hom_equiv_naturality_left, ←h.hom_equiv_naturality_right, equiv.apply_eq_iff_eq, assoc,\n      is_iso.eq_inv_comp, ←F.to_lax_monoidal_functor.μ_natural_assoc, is_iso.hom_inv_id_assoc,\n      ←tensor_comp, adjunction.counit_naturality, adjunction.counit_naturality, tensor_comp],\n  end,\n  associativity' := λ X Y Z,\n  begin\n    rw [←h.hom_equiv_naturality_right, ←h.hom_equiv_naturality_left, ←h.hom_equiv_naturality_left,\n      ←h.hom_equiv_naturality_left, equiv.apply_eq_iff_eq,\n      ← cancel_epi (F.to_lax_monoidal_functor.μ (G.obj X ⊗ G.obj Y) (G.obj Z)),\n      ← cancel_epi (F.to_lax_monoidal_functor.μ (G.obj X) (G.obj Y) ⊗ 𝟙 (F.obj (G.obj Z))),\n      F.to_lax_monoidal_functor.associativity_assoc (G.obj X) (G.obj Y) (G.obj Z),\n      ←F.to_lax_monoidal_functor.μ_natural_assoc, assoc, is_iso.hom_inv_id_assoc,\n      ←F.to_lax_monoidal_functor.μ_natural_assoc, is_iso.hom_inv_id_assoc, ←tensor_comp,\n      ←tensor_comp, id_comp, functor.map_id, functor.map_id, id_comp, ←tensor_comp_assoc,\n      ←tensor_comp_assoc, id_comp, id_comp, h.hom_equiv_unit, h.hom_equiv_unit, functor.map_comp,\n      assoc, assoc, h.counit_naturality, h.left_triangle_components_assoc, is_iso.hom_inv_id_assoc,\n      functor.map_comp, assoc, h.counit_naturality, h.left_triangle_components_assoc,\n      is_iso.hom_inv_id_assoc],\n    exact associator_naturality (h.counit.app X) (h.counit.app Y) (h.counit.app Z),\n  end,\n  left_unitality' := λ X,\n  begin\n    rw [←h.hom_equiv_naturality_right, ←h.hom_equiv_naturality_left, ←equiv.symm_apply_eq,\n      h.hom_equiv_counit, F.map_left_unitor, h.hom_equiv_unit, assoc, assoc, assoc, F.map_tensor,\n      assoc, assoc, is_iso.hom_inv_id_assoc, ←tensor_comp_assoc, functor.map_id, id_comp,\n      functor.map_comp, assoc, h.counit_naturality, h.left_triangle_components_assoc,\n      ←left_unitor_naturality, ←tensor_comp_assoc, id_comp, comp_id],\n  end,\n  right_unitality' := λ X,\n  begin\n    rw [←h.hom_equiv_naturality_right, ←h.hom_equiv_naturality_left, ←equiv.symm_apply_eq,\n      h.hom_equiv_counit, F.map_right_unitor, assoc, assoc, ←right_unitor_naturality,\n      ←tensor_comp_assoc, comp_id, id_comp, h.hom_equiv_unit, F.map_tensor, assoc, assoc, assoc,\n      is_iso.hom_inv_id_assoc, functor.map_comp, functor.map_id, ←tensor_comp_assoc, assoc,\n      h.counit_naturality, h.left_triangle_components_assoc, id_comp],\n  end }.\n\n/-- If a monoidal functor `F` is an equivalence of categories then its inverse is also monoidal. -/\nnoncomputable\ndef monoidal_inverse (F : monoidal_functor C D) [is_equivalence F.to_functor] :\n  monoidal_functor D C :=\n{ to_lax_monoidal_functor := monoidal_adjoint F (as_equivalence _).to_adjunction,\n  ε_is_iso := by { dsimp [equivalence.to_adjunction], apply_instance },\n  μ_is_iso := λ X Y, by { dsimp [equivalence.to_adjunction], apply_instance } }\n\n@[simp]\nlemma monoidal_inverse_to_functor (F : monoidal_functor C D) [is_equivalence F.to_functor] :\n  (monoidal_inverse F).to_functor = F.to_functor.inv := rfl\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/monoidal/functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.46883403270459284}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl (CMU)\n\n! This file was ported from Lean 3 source module meta.coinductive_predicates\n! leanprover-community/mathlib commit 3d7987cda72abc473c7cdbbb075170e9ac620042\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.Core\n\nsection\n\nuniverse u\n\n@[user_attribute]\nunsafe def monotonicity : user_attribute\n    where\n  Name := `monotonicity\n  descr := \"Monotonicity rules for predicates\"\n#align monotonicity monotonicity\n\ntheorem Monotonicity.pi {α : Sort u} {p q : α → Prop} (h : ∀ a, Implies (p a) (q a)) :\n    Implies (∀ a, p a) (∀ a, q a) := fun h' a => h a (h' a)\n#align monotonicity.pi Monotonicity.pi\n\ntheorem Monotonicity.imp {p p' q q' : Prop} (h₁ : Implies p' q') (h₂ : Implies q p) :\n    Implies (p → p') (q → q') := fun h => h₁ ∘ h ∘ h₂\n#align monotonicity.imp Monotonicity.imp\n\n@[monotonicity]\ntheorem Monotonicity.const (p : Prop) : Implies p p :=\n  id\n#align monotonicity.const Monotonicity.const\n\n@[monotonicity]\ntheorem Monotonicity.true (p : Prop) : Implies p True := fun _ => trivial\n#align monotonicity.true Monotonicity.true\n\n@[monotonicity]\ntheorem Monotonicity.false (p : Prop) : Implies False p :=\n  False.elim\n#align monotonicity.false Monotonicity.false\n\n@[monotonicity]\ntheorem Monotonicity.exists {α : Sort u} {p q : α → Prop} (h : ∀ a, Implies (p a) (q a)) :\n    Implies (∃ a, p a) (∃ a, q a) :=\n  Exists.imp h\n#align monotonicity.exists Monotonicity.exists\n\n@[monotonicity]\ntheorem Monotonicity.and {p p' q q' : Prop} (hp : Implies p p') (hq : Implies q q') :\n    Implies (p ∧ q) (p' ∧ q') :=\n  And.imp hp hq\n#align monotonicity.and Monotonicity.and\n\n@[monotonicity]\ntheorem Monotonicity.or {p p' q q' : Prop} (hp : Implies p p') (hq : Implies q q') :\n    Implies (p ∨ q) (p' ∨ q') :=\n  Or.imp hp hq\n#align monotonicity.or Monotonicity.or\n\n@[monotonicity]\ntheorem Monotonicity.not {p q : Prop} (h : Implies p q) : Implies (¬q) ¬p :=\n  mt h\n#align monotonicity.not Monotonicity.not\n\nend\n\nnamespace Tactic\n\nopen Expr Tactic\n\n-- TODO: use backchaining\nprivate unsafe def mono_aux (ns : List Name) (hs : List expr) : tactic Unit := do\n  intros\n  (do\n        let q(Implies $(p) $(q)) ← target\n        (do\n              is_def_eq p q\n              eapplyc `monotone.const) <|>\n            do\n            let expr.pi pn pbi pd pb ← whnf p\n            let expr.pi qn qbi qd qb ← whnf q\n            let sort u ← infer_type pd\n            (do\n                  is_def_eq pd qd\n                  let p' := expr.lam pn pbi pd pb\n                  let q' := expr.lam qn qbi qd qb\n                  eapply ((const `monotonicity.pi [u] : expr) pd p' q')\n                  skip) <|>\n                do\n                guard <| u = level.zero ∧ is_arrow p ∧ is_arrow q\n                let p' := pb 0 1\n                let q' := qb 0 1\n                eapply ((const `monotonicity.imp [] : expr) pd p' qd q')\n                skip) <|>\n      first\n          (hs fun h =>\n            apply_core h\n                { md := transparency.none\n                  NewGoals := new_goals.non_dep_only } >>\n              skip) <|>\n        first\n          (ns fun n => do\n            let c ← mk_const n\n            apply_core c\n                { md := transparency.none\n                  NewGoals := new_goals.non_dep_only }\n            skip)\n  all_goals' mono_aux\n#align tactic.mono_aux tactic.mono_aux\n\nunsafe def mono (e : expr) (hs : List expr) : tactic Unit := do\n  let t ← target\n  let t' ← infer_type e\n  let ns ← attribute.get_instances `monotonicity\n  let ((), p) ← solve_aux q(Implies $(t') $(t)) (mono_aux ns hs)\n  exact (p e)\n#align tactic.mono tactic.mono\n\nend Tactic\n\n/-\nThe coinductive predicate `pred`:\n\n  coinductive {u} pred (A) : a → Prop\n  | r : ∀A b, pred A p\n\nwhere\n  `u` is a list of universe parameters\n  `A` is a list of global parameters\n  `pred` is a list predicates to be defined\n  `a` are the indices for each `pred`\n  `r` is a list of introduction rules for each `pred`\n  `b` is a list of parameters for each rule in `r` and `pred`\n  `p` is are the instances of `a` using `A` and `b`\n\n`pred` is compiled to the following defintions:\n\n  inductive {u} pred.functional (A) ([pred'] : a → Prop) : a → Prop\n  | r : ∀a [f], b[pred/pred'] → pred.functional a [f] p\n\n  lemma {u} pred.functional.mono (A) ([pred₁] [pred₂] : a → Prop) [(h : ∀b, pred₁ b → pred₂ b)] :\n    ∀p, pred.functional A pred₁ p → pred.functional A pred₂ p\n\n  def {u} pred_i (A) (a) : Prop :=\n  ∃[pred'], (Λi, ∀a, pred_i a → pred_i.functional A [pred] a) ∧ pred'_i a\n\n  lemma {u} pred_i.corec_functional (A) [Λi, C_i : a_i → Prop]\n    [Λi, h : ∀a, C_i a → pred_i.functional A C_i a] :\n    ∀a, C_i a → pred_i A a\n\n  lemma {u} pred_i.destruct (A) (a) : pred A a → pred.functional A [pred A] a\n\n  lemma {u} pred_i.construct (A) : ∀a, pred_i.functional A [pred A] a → pred_i A a\n\n  lemma {u} pred_i.cases_on (A) (C : a → Prop) {a} (h : pred_i a) [Λi, ∀a, b → C p] → C a\n\n  lemma {u} pred_i.corec_on (A) [(C : a → Prop)] (a) (h : C_i a)\n    [Λi, h_i : ∀a, C_i a → [V j ∃b, a = p]] : pred_i A a\n\n  lemma {u} pred.r (A) (b) : pred_i A p\n-/\nnamespace Tactic\n\nopen Level Expr Tactic\n\nnamespace AddCoinductivePredicate\n\n-- private\nunsafe structure coind_rule : Type where\n  orig_nm : Name\n  func_nm : Name\n  type : expr\n  loc_type : expr\n  args : List expr\n  loc_args : List expr\n  concl : expr\n  insts : List expr\n#align tactic.add_coinductive_predicate.coind_rule tactic.add_coinductive_predicate.coind_rule\n\n-- private\nunsafe structure coind_pred : Type where\n  u_names : List Name\n  params : List expr\n  pd_name : Name\n  type : expr\n  intros : List coind_rule\n  locals : List expr\n  (f₁ f₂ : expr)\n  u_f : level\n#align tactic.add_coinductive_predicate.coind_pred tactic.add_coinductive_predicate.coind_pred\n\nnamespace CoindPred\n\nunsafe def u_params (pd : coind_pred) : List level :=\n  pd.u_names.map param\n#align tactic.add_coinductive_predicate.coind_pred.u_params tactic.add_coinductive_predicate.coind_pred.u_params\n\nunsafe def f₁_l (pd : coind_pred) : expr :=\n  pd.f₁.app_of_list pd.locals\n#align tactic.add_coinductive_predicate.coind_pred.f₁_l tactic.add_coinductive_predicate.coind_pred.f₁_l\n\nunsafe def f₂_l (pd : coind_pred) : expr :=\n  pd.f₂.app_of_list pd.locals\n#align tactic.add_coinductive_predicate.coind_pred.f₂_l tactic.add_coinductive_predicate.coind_pred.f₂_l\n\nunsafe def pred (pd : coind_pred) : expr :=\n  const pd.pd_name pd.u_params\n#align tactic.add_coinductive_predicate.coind_pred.pred tactic.add_coinductive_predicate.coind_pred.pred\n\nunsafe def func (pd : coind_pred) : expr :=\n  const (pd.pd_name ++ \"functional\") pd.u_params\n#align tactic.add_coinductive_predicate.coind_pred.func tactic.add_coinductive_predicate.coind_pred.func\n\nunsafe def func_g (pd : coind_pred) : expr :=\n  pd.func.app_of_list <| pd.params\n#align tactic.add_coinductive_predicate.coind_pred.func_g tactic.add_coinductive_predicate.coind_pred.func_g\n\nunsafe def pred_g (pd : coind_pred) : expr :=\n  pd.pred.app_of_list <| pd.params\n#align tactic.add_coinductive_predicate.coind_pred.pred_g tactic.add_coinductive_predicate.coind_pred.pred_g\n\nunsafe def impl_locals (pd : coind_pred) : List expr :=\n  pd.locals.map to_implicit_binder\n#align tactic.add_coinductive_predicate.coind_pred.impl_locals tactic.add_coinductive_predicate.coind_pred.impl_locals\n\nunsafe def impl_params (pd : coind_pred) : List expr :=\n  pd.params.map to_implicit_binder\n#align tactic.add_coinductive_predicate.coind_pred.impl_params tactic.add_coinductive_predicate.coind_pred.impl_params\n\nunsafe def le (pd : coind_pred) (f₁ f₂ : expr) : expr :=\n  (imp (f₁.app_of_list pd.locals) (f₂.app_of_list pd.locals)).pis pd.impl_locals\n#align tactic.add_coinductive_predicate.coind_pred.le tactic.add_coinductive_predicate.coind_pred.le\n\nunsafe def corec_functional (pd : coind_pred) : expr :=\n  const (pd.pd_name ++ \"corec_functional\") pd.u_params\n#align tactic.add_coinductive_predicate.coind_pred.corec_functional tactic.add_coinductive_predicate.coind_pred.corec_functional\n\nunsafe def mono (pd : coind_pred) : expr :=\n  const (pd.func.const_name ++ \"mono\") pd.u_params\n#align tactic.add_coinductive_predicate.coind_pred.mono tactic.add_coinductive_predicate.coind_pred.mono\n\nunsafe def rec' (pd : coind_pred) : tactic expr := do\n  let c := pd.func.const_name ++ \"rec\"\n  let env ← get_env\n  let decl ← env.get c\n  let num := decl.univ_params.length\n  return (const c <| if Num = pd then pd else level.zero :: pd)\n#align tactic.add_coinductive_predicate.coind_pred.rec' tactic.add_coinductive_predicate.coind_pred.rec'\n\n-- ^^ `rec`'s universes are not always `u_params`, e.g. eq, wf, false\nunsafe def construct (pd : coind_pred) : expr :=\n  const (pd.pd_name ++ \"construct\") pd.u_params\n#align tactic.add_coinductive_predicate.coind_pred.construct tactic.add_coinductive_predicate.coind_pred.construct\n\nunsafe def destruct (pd : coind_pred) : expr :=\n  const (pd.pd_name ++ \"destruct\") pd.u_params\n#align tactic.add_coinductive_predicate.coind_pred.destruct tactic.add_coinductive_predicate.coind_pred.destruct\n\nunsafe def add_theorem (pd : coind_pred) (n : Name) (type : expr) (tac : tactic Unit) :\n    tactic expr :=\n  add_theorem_by n pd.u_names type tac\n#align tactic.add_coinductive_predicate.coind_pred.add_theorem tactic.add_coinductive_predicate.coind_pred.add_theorem\n\nend CoindPred\n\nend AddCoinductivePredicate\n\nopen AddCoinductivePredicate\n\n/-- compact_relation bs as_ps: Product a relation of the form:\n  R := λ as, ∃ bs, Λ_i a_i = p_i[bs]\nThis relation is user visible, so we compact it by removing each `b_j` where a `p_i = b_j`, and\nhence `a_i = b_j`. We need to take care when there are `p_i` and `p_j` with `p_i = p_j = b_k`. -/\nunsafe def compact_relation : List expr → List (expr × expr) → List expr × List (expr × expr)\n  | [], ps => ([], ps)\n  | List.cons b bs, ps =>\n    match ps.spanₓ fun ap : expr × expr => ¬ap.2 == b with\n    | (_, []) =>\n      let (bs, ps) := compact_relation bs ps\n      (b :: bs, ps)\n    | (ps₁, List.cons (a, _) ps₂) =>\n      let i := a.instantiate_local b.local_uniq_name\n      compact_relation (bs.map i) ((ps₁ ++ ps₂).map fun ⟨a, p⟩ => (a, i p))\n#align tactic.compact_relation tactic.compact_relation\n\nunsafe def add_coinductive_predicate (u_names : List Name) (params : List expr)\n    (preds : List <| expr × List expr) : Tactic := do\n  let params_names := params.map local_pp_name\n  let u_params := u_names.map param\n  let pre_info ←\n    preds.mapM fun ⟨c, is⟩ => do\n        let (ls, t) ← open_pis c.local_type\n        is_def_eq t q(Prop) <|>\n            fail\n              ((f! \"Type of {c} is not Prop. Currently only \") ++\n                \"coinductive predicates are supported.\")\n        let n := if preds.length = 1 then \"\" else \"_\" ++ c.local_pp_name.lastString\n        let f₁ ← mk_local_def (mkSimpleName <| \"C\" ++ n) c.local_type\n        let f₂ ← mk_local_def (mkSimpleName <| \"C₂\" ++ n) c.local_type\n        return (ls, (f₁, f₂))\n  let fs := pre_info.map Prod.snd\n  let fs₁ := fs.map Prod.fst\n  let fs₂ := fs.map Prod.snd\n  let pds ←\n    (preds.zip pre_info).mapM fun ⟨⟨c, is⟩, ls, f₁, f₂⟩ => do\n        let sort u_f ← infer_type f₁ >>= infer_type\n        let pred_g := fun c : expr => (const c.local_uniq_name u_params : expr).app_of_list params\n        let intros ←\n          is.mapM fun i => do\n              let (args, t') ← open_pis i.local_type\n              let Name.mk_string sub p ← return i.local_uniq_name\n              let loc_args :=\n                args.map fun e =>\n                  (fs₁.zip preds).foldl (fun (e : expr) ⟨f, c, _⟩ => e.replace_with (pred_g c) f) e\n              let t' := t'.replace_with (pred_g c) f₂\n              return\n                  { orig_nm := i\n                    func_nm := p ++ \"functional\" ++ sub\n                    type := i\n                    loc_type := t' loc_args\n                    concl := t'\n                    loc_args\n                    args\n                    insts := t' }\n        return\n            { pd_name := c\n              type := c\n              f₁\n              f₂\n              u_f\n              intros\n              locals := ls\n              params\n              u_names }\n  -- Introduce all functionals\n      pds\n      fun pd : coind_pred => do\n      let func_f₁ := pd <| fs₁\n      let func_f₂ := pd <| fs₂\n      let func_intros\n        ←-- Define functional for `pd` as inductive predicate\n            pd\n            fun r : coind_rule => do\n            let t := instantiate_local pd (pd fs₁) r\n            return (r, r, t <| params ++ fs₁)\n      add_inductive pd u_names (params + preds) (pd <| params ++ fs₁)\n          (func_intros fun ⟨t, _, r⟩ => (t, r))\n      let mono_params\n        ←-- Prove monotonicity rule\n            pds\n            fun pd => do\n            let h ← mk_local_def `h <| pd pd pd\n            return [pd, pd, h]\n      pd (pd ++ \"mono\") ((pd func_f₁ func_f₂).pis <| params ++ mono_params) do\n          let ps ← intro_lst <| params expr.local_pp_name\n          let fs ←\n            pds fun pd => do\n                let [f₁, f₂, h] ← intro_lst [pd, pd, `h]\n                let-- the type of h' reduces to h\n                h' :=\n                  local_const h h h <|\n                    (((const `implies [] : expr) (f₁ pd) (f₂ pd)).pis pd).instantiate_locals <|\n                      (ps params).map fun ⟨lv, p⟩ => (p, lv)\n                return (f₂, h')\n          let m ← pd\n          eapply <| m ps\n          -- somehow `induction` / `cases` doesn't work?\n              func_intros\n              fun ⟨n, pp_n, t⟩ =>\n              solve1 do\n                let bs ← intros\n                let ms ←\n                  apply_core ((const n u_params).app_of_list <| ps ++ fs Prod.fst)\n                      { NewGoals := new_goals.all }\n                let params ← (ms bs).enum.filterM fun ⟨n, m, d⟩ => not <$> is_assigned m.2\n                params fun ⟨n, m, d⟩ =>\n                    mono d (fs Prod.snd) <|>\n                      fail\n                        f!\"failed to prove montonoicity of {(n +\n                            1)}. parameter of intro-rule {pp_n}\"\n  pds fun pd => do\n      let func_f := fun pd : coind_pred => pd <| pds coind_pred.f₁\n      let pred_body\n        ←-- define final predicate\n              mk_exists_lst\n              (pds coind_pred.f₁) <|\n            mk_and_lst <| (pds fun pd => pd pd (func_f pd)) ++ [pd pd]\n      add_decl <| mk_definition pd u_names (pd <| params) <| pred_body <| params ++ pd\n      let hs\n        ←-- prove `corec_functional` rule\n            pds\n            fun pd : coind_pred => mk_local_def `hc <| pd pd (func_f pd)\n      pd (pd ++ \"corec_functional\") ((pd pd pd).pis <| params ++ fs₁ ++ hs) do\n          intro_lst <| params local_pp_name\n          let fs ← intro_lst <| fs₁ local_pp_name\n          let hs ← intro_lst <| hs local_pp_name\n          let ls ← intro_lst <| pd local_pp_name\n          let h ← intro `h\n          whnf_target\n          fs existsi\n          hs fun f => econstructor >> exact f\n          exact h\n  let func_f := fun pd : coind_pred => pd.func_g.app_of_list <| pds.map coind_pred.pred_g\n  -- prove `destruct` rules\n      pds\n      fun ⟨n, pd⟩ => do\n      let destruct := pd pd (func_f pd)\n      pd (pd ++ \"destruct\") (destruct params) do\n          let ps ← intro_lst <| params local_pp_name\n          let ls ← intro_lst <| pd local_pp_name\n          let h ← intro `h\n          let (fs, h, _) ← elim_gen_prod pds h [] []\n          let (hs, h, _) ← elim_gen_prod pds h [] []\n          eapply <| pd ps\n          pds fun pd : coind_pred =>\n              focus1 do\n                eapply <| pd\n                focus <| hs exact\n          let some h' ← return <| hs n\n          eapply h'\n          exact h\n  -- prove `construct` rules\n      pds\n      fun pd =>\n      pd (pd ++ \"construct\") ((pd (func_f pd) pd).pis params) do\n        let ps ← intro_lst <| params local_pp_name\n        let func_pred_g := fun pd : coind_pred => pd <| ps ++ pds fun pd : coind_pred => pd ps\n        eapply <| pd <| ps ++ pds func_pred_g\n        pds fun pd : coind_pred =>\n            solve1 do\n              eapply <| pd ps\n              pds fun pd => solve1 <| eapply (pd ps) >> skip\n  -- prove `cases_on` rules\n      pds\n      fun pd => do\n      let C := pd\n      let h ← mk_local_def `h <| pd pd\n      let rules ←\n        pd fun r : coind_rule => do\n            mk_local_def (mkSimpleName r) <| (C r).pis r\n      let cases_on ←\n        pd (pd ++ \"cases_on\") ((C pd).pis <| params ++ [C] ++ pd ++ [h] ++ rules) do\n            let ps ← intro_lst <| params local_pp_name\n            let C ← intro `C\n            let ls ← intro_lst <| pd local_pp_name\n            let h ← intro `h\n            let rules ← intro_lst <| rules local_pp_name\n            let func_rec ← pd\n            eapply <| func_rec <| (ps ++ pds fun pd => pd ps) ++ [C] ++ rules\n            eapply <| pd\n            exact h\n      set_basic_attribute `elab_as_eliminator cases_on\n  -- prove `corec_on` rules\n      pds\n      fun pd => do\n      let rules ←\n        pds fun pd => do\n            let intros ←\n              pd fun r => do\n                  let (bs, eqs) := compact_relation r <| pd r\n                  let eqs ←\n                    eqs fun ⟨l, i⟩ => do\n                        let sort u ← infer_type l\n                        return <| (const `eq [u] : expr) l i l\n                  match bs, eqs with\n                    | [], [] => return ((0, 0), mk_true)\n                    | _, [] => Prod.mk (bs, 0) <$> mk_exists_lst bs bs\n                    | _, _ => Prod.mk (bs, eqs) <$> mk_exists_lst bs (mk_and_lst eqs)\n            let shape := intros Prod.fst\n            let intros := intros Prod.snd\n            Prod.mk shape <$>\n                mk_local_def (mkSimpleName <| \"h_\" ++ pd) (((pd pd).imp (mk_or_lst intros)).pis pd)\n      let shape := rules Prod.fst\n      let rules := rules Prod.snd\n      let h ← mk_local_def `h <| pd pd\n      pd (pd ++ \"corec_on\") ((pd <| pd).pis <| params ++ fs₁ ++ pd ++ [h] ++ rules) do\n          let ps ← intro_lst <| params local_pp_name\n          let fs ← intro_lst <| fs₁ local_pp_name\n          let ls ← intro_lst <| pd local_pp_name\n          let h ← intro `h\n          let rules ← intro_lst <| rules local_pp_name\n          eapply <| pd <| ps ++ fs\n          (pds <| rules shape).mapM fun ⟨pd, hr, s⟩ =>\n              solve1 do\n                let ls ← intro_lst <| pd local_pp_name\n                let h' ← intro `h\n                let h' ← note `h' none <| hr ls h'\n                match s with\n                  | 0 => induction h' >> skip\n                  |-- h' : false\n                      n +\n                      1 =>\n                    do\n                    let hs ← elim_gen_sum n h'\n                    (hs <| pd s).mapM' fun ⟨h, r, n_bs, n_eqs⟩ =>\n                        solve1 do\n                          let (as, h, _) ← elim_gen_prod (n_bs - if n_eqs = 0 then 1 else 0) h [] []\n                          if n_eqs > 0 then do\n                              let (eqs, eq', _) ← elim_gen_prod (n_eqs - 1) h [] []\n                              (eqs ++ [eq']).mapM' subst\n                            else skip\n                          eapply ((const r u_params).app_of_list <| ps ++ fs)\n                          iterate assumption\n          exact h\n  -- prove constructors\n      pds\n      fun pd =>\n      pd fun r =>\n        pd r (r params) do\n          let ps ← intro_lst <| params local_pp_name\n          let bs ← intros\n          eapply <| pd\n          exact <| (const r u_params).app_of_list <| (ps ++ pds fun pd => pd ps) ++ bs\n  pds fun pd : coind_pred => set_basic_attribute `irreducible pd\n  try triv\n#align tactic.add_coinductive_predicate tactic.add_coinductive_predicate\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\n-- we setup a trivial goal for the tactic framework\n@[user_command]\nunsafe def coinductive_predicate (meta_info : decl_meta_info) (_ : parse <| tk \"coinductive\") :\n    lean.parser Unit := do\n  let decl ← inductive_decl.parse meta_info\n  add_coinductive_predicate decl decl <| decl fun d => (d, d)\n  decl fun d => do\n      get_env >>= fun env => set_env <| env d\n      meta_info d\n      d d\n      let some doc_string ← pure meta_info |\n        skip\n      add_doc_string d doc_string\n#align tactic.coinductive_predicate tactic.coinductive_predicate\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `hs -/\n/-- Prepares coinduction proofs. This tactic constructs the coinduction invariant from\nthe quantifiers in the current goal.\n\nCurrent version: do not support mutual inductive rules -/\nunsafe def coinduction (rule : expr) (ns : List Name) : tactic Unit :=\n  focus1 do\n    let ctxts' ← intros\n    let ctxts ←\n      ctxts'.mapM fun v =>\n          local_const v.local_uniq_name v.local_pp_name v.local_binding_info <$> infer_type v\n    let mvars ←\n      apply_core rule\n          { approx := false\n            NewGoals := NewGoals.all }\n    let g\n      ←-- analyse relation\n          List.headI <$>\n          get_goals\n    let List.cons _ m_is ← return <| mvars.dropWhileₓ fun v => v.2 ≠ g\n    let tgt ← target\n    let (is, ty) ← open_pis tgt\n    let-- construct coinduction predicate\n      (bs, eqs)\n      ←\n      compact_relation ctxts <$>\n          (is.zip m_is).mapM fun ⟨i, m⟩ => Prod.mk i <$> instantiate_mvars m.2\n    solve1 do\n        let eqs ←\n          (mk_and_lst <$> eqs fun ⟨i, m⟩ => mk_app `eq [m, i] >>= instantiate_mvars) <|> do\n              let x ← mk_psigma (eqs Prod.fst)\n              let y ← mk_psigma (eqs Prod.snd)\n              let t ← infer_type x\n              mk_mapp `eq [t, x, y]\n        let rel ← mk_exists_lst bs eqs\n        exact (Rel is)\n    -- prove predicate\n        solve1\n        do\n        target >>= instantiate_mvars >>= change\n        -- TODO: bug in existsi & constructor when mvars in hyptohesis\n            bs\n            existsi\n        iterate' (econstructor >> skip)\n    -- clean up remaining coinduction steps\n        all_goals'\n        do\n        ctxts' clear\n        target >>= instantiate_mvars >>= change\n        let is\n          ←-- TODO: bug in subst when mvars in hyptohesis\n              intro_lst <|\n              is expr.local_pp_name\n        let h ← intro1\n        let (_, h, ns) ← elim_gen_prod (bs - if eqs = 0 then 1 else 0) h [] ns\n        match eqs with\n          | [] => clear h\n          | e :: eqs => do\n            let (hs, h, ns) ← elim_gen_prod eqs h [] ns\n            (h :: hs hs.reverse : List _).foldlM\n                (fun (hs : List Name) (h : expr) => do\n                  let [(_, hs', σ)] ← cases_core h hs\n                  clear (h σ)\n                  pure <| hs hs')\n                ns\n            skip\n#align tactic.coinduction tactic.coinduction\n\nnamespace Interactive\n\nopen Interactive Interactive.Types Expr Lean.Parser\n\n-- mathport name: «expr ?»\nlocal postfix:1024 \"?\" => optional\n\n-- mathport name: parser.many\nlocal postfix:1024 \"*\" => many\n\nunsafe def coinduction (corec_name : parse ident) (ns : parse with_ident_list)\n    (revert : parse <| (tk \"generalizing\" *> ident*)?) : tactic Unit := do\n  let rule ← mk_const corec_name\n  let locals ← mapM tactic.get_local <| revert.getD []\n  revert_lst locals\n  tactic.coinduction rule ns\n  skip\n#align tactic.interactive.coinduction tactic.interactive.coinduction\n\nend Interactive\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Meta/CoinductivePredicates.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4688340305659644}}
{"text": "/-\nCopyright (c) 2022 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport data.vector.mem\nimport computational_monads.constructions.product\nimport computational_monads.distribution_semantics.defs.prob_event\n\n/-!\n# Repeated Independent Runs of an Oracle Computation\n\nThis file defines a construction `repeat oa n` to represent running `oa` independently `n` times,\nreturning the result as a `vector` of length `n`, by using induction on the input `n`.\n\n`support_repeat_eq_all₂` shows that the possible outputs of `oa.repeat n` are exactly the\nvectors such that each element in the vector are possible outputs of `oa`.\n`eval_dist_repeat_apply` shows that the probability of getting a given output from `oa.repeat n`\nis the product over the vector of the probabilities of getting the individual outputs from `oa`.\n-/\n\nnamespace oracle_comp\n\nopen oracle_spec\n\nvariables {α β γ : Type} {spec spec' : oracle_spec}\n\n/-- Repeat the computation `oa` independently `n` times to get a length `n` vector of results. -/\ndef repeat (oa : oracle_comp spec α) : Π (n : ℕ), oracle_comp spec (vector α n)\n| 0 := return vector.nil\n| (n + 1) := do { a ← oa, as ← repeat n, return (a ::ᵥ as) }\n\nvariables (oa : oracle_comp spec α) (n : ℕ) {m : ℕ} (x x' : α) (xs : vector α m)\n  (xs₀ : vector α 0) (xsₛ : vector α m.succ)\n\nlemma repeat_zero : oa.repeat 0 = return vector.nil := rfl\n\nlemma repeat_succ : oa.repeat n.succ = do {a ← oa, as ← oa.repeat n, return (a ::ᵥ as)} := rfl\n\ninstance repeat.decidable [hoa : oa.decidable] : (oa.repeat n).decidable :=\nbegin\n  induction n with n hn,\n  { exact oracle_comp.decidable_return vector.nil },\n  { haveI : decidable_eq α := decidable_eq_of_decidable oa,\n    refine decidable.decidable_bind' _ _ _ _ hoa (λ _, decidable.decidable_bind' _ _ _ _ hn\n      (λ _, decidable.decidable_pure' _ _ (by apply_instance))) }\nend\n\nsection support\n\n/-- The support of `oa.repeat n` is the set of vectors where every element is in `oa.support`. -/\n@[simp] theorem support_repeat_eq_all₂ :\n  (oa.repeat n).support = {xs | xs.to_list.all₂ (∈ oa.support)} :=\nbegin\n  induction n with n hn,\n  { exact set.ext (λ x, by simp only [list.all₂, repeat_zero, support_return, set.set_of_true,\n      set.mem_singleton_iff, eq_iff_true_of_subsingleton, vector.to_list_empty, set.mem_univ]) },\n  { ext xs,\n    obtain ⟨x, xs, rfl⟩ := vector.exists_eq_cons xs,\n    simp only [hn, vector.eq_cons_iff, repeat_succ, support_bind, support_bind_return,\n      set.mem_Union, set.mem_image, set.mem_set_of_eq, vector.cons_head, vector.cons_tail,\n      exists_eq_right_right, exists_prop, vector.to_list_cons, list.all₂_cons] }\nend\n\nlemma support_repeat_eq_forall : (oa.repeat n).support = {xs | ∀ x ∈ xs.to_list, x ∈ oa.support} :=\nby simp_rw [support_repeat_eq_all₂, list.all₂_iff_forall]\n\nlemma mem_support_repeat_iff_all₂ : xs ∈ (oa.repeat m).support ↔ xs.to_list.all₂ (∈ oa.support) :=\nby rw [support_repeat_eq_all₂, set.mem_set_of_eq]\n\nlemma mem_support_repeat_iff_forall :\n  xs ∈ (oa.repeat m).support ↔ ∀ x ∈ xs.to_list, x ∈ oa.support :=\nby rw [support_repeat_eq_forall, set.mem_set_of_eq]\n\n@[simp] lemma support_repeat_zero : (oa.repeat 0).support = {vector.nil} :=\nby rw [repeat_zero, support_return]\n\n/-- Any empty vector is in the support of a computation that is run zero times. -/\nlemma mem_support_repeat_zero : xs₀ ∈ (oa.repeat 0).support :=\nby simp only [repeat_zero, support_return, set.mem_singleton_iff, eq_iff_true_of_subsingleton]\n\n/-- The support of running a computation `n + 1` is the set of vectors where the head is in\nthe computation's support and the tail is in the support of running it `n` times. -/\n@[simp] lemma support_repeat_succ : (oa.repeat n.succ).support =\n  {xs | xs.head ∈ oa.support ∧ xs.tail ∈ (oa.repeat n).support} :=\nbegin\n  refine set.ext (λ xs, _),\n  obtain ⟨x, xs, rfl⟩ := vector.exists_eq_cons xs,\n  simpa only [support_repeat_eq_all₂, set.mem_set_of_eq, vector.to_list_cons,\n    vector.head_cons, vector.tail_cons, list.all₂_cons]\nend\n\nlemma support_repeat_succ_eq_Union_image : (oa.repeat n.succ).support =\n  ⋃ x ∈ oa.support, (vector.cons x) '' (oa.repeat n).support :=\nbegin\n  refine set.ext (λ xs, _),\n  obtain ⟨x, xs, rfl⟩ := vector.exists_eq_cons xs,\n  simp_rw [set.mem_Union, support_repeat_succ, set.mem_set_of,\n    vector.head_cons, vector.tail_cons, set.mem_image],\n  refine ⟨λ h, ⟨x, h.1, xs, h.2, rfl⟩, λ h, _⟩,\n  obtain ⟨y, hy, ys, hys, h⟩ := h,\n  rw [vector.cons_eq_cons] at h,\n  refine ⟨h.1 ▸ hy, h.2 ▸ hys⟩,\nend\n\nlemma mem_support_repeat_succ_iff : xsₛ ∈ (oa.repeat m.succ).support ↔\n  xsₛ.head ∈ oa.support ∧ xsₛ.tail ∈ (oa.repeat m).support :=\nby rw [support_repeat_succ, set.mem_set_of_eq]\n\nlemma cons_mem_support_repeat_succ_iff : (x ::ᵥ xs) ∈ (oa.repeat m.succ).support ↔\n  x ∈ oa.support ∧ xs ∈ (oa.repeat m).support :=\nby rw [mem_support_repeat_succ_iff oa, vector.head_cons, vector.tail_cons]\n\n/-- If a vector is in the support of `oa.repeat m` then any of its members is in `oa.support`. -/\nlemma mem_support_of_mem_of_support_repeat {oa : oracle_comp spec α} {x : α} {xs : vector α m}\n  (hxs : xs ∈ (oa.repeat m).support) (hx : x ∈ xs.to_list) : x ∈ oa.support :=\nby { rw mem_support_repeat_iff_forall at hxs, exact hxs x hx }\n\nlemma repeat_mem_support_repeat {oa : oracle_comp spec α} {x : α} (n : ℕ) (hx : x ∈ oa.support) :\n  vector.repeat x n ∈ (oa.repeat n).support :=\nby { rw [mem_support_repeat_iff_forall], exact (λ y hy, (list.eq_of_mem_repeat hy).symm ▸ hx) }\n\nend support\n\nsection fin_support\n\nlemma mem_fin_support_repeat_iff_all₂ [oa.decidable] :\n  xs ∈ (oa.repeat m).fin_support ↔ xs.to_list.all₂ (∈ oa.fin_support) :=\nby simp only [mem_fin_support_iff_mem_support, mem_support_repeat_iff_all₂]\n\nlemma mem_fin_support_repeat_iff_forall [oa.decidable] :\n  xs ∈ (oa.repeat m).fin_support ↔ ∀ x ∈ xs.to_list, x ∈ oa.fin_support :=\nby simp only [mem_fin_support_iff_mem_support, mem_support_repeat_iff_forall]\n\nend fin_support\n\nsection eval_dist\n\n/-- The probability of getting `xs` after `oa.repeat n` is the product of the probability\nof getting each individual output, since each computation runs independently. -/\n@[simp] theorem eval_dist_repeat_apply : ⁅oa.repeat m⁆ xs = (xs.map ⁅oa⁆).to_list.prod :=\nbegin\n  induction m with m hm,\n  { simp only [vector.eq_nil xs, repeat_zero oa, eval_dist_return, pmf.pure_apply,\n      if_true, vector.map_nil, vector.to_list_nil, list.prod_nil, eq_self_iff_true] },\n  { obtain ⟨x, xs, rfl⟩ := vector.exists_eq_cons xs,\n    calc ⁅oa.repeat m.succ⁆ (x ::ᵥ xs) =\n      ∑' y ys, ⁅oa⁆ y * ⁅oa.repeat m⁆ ys * set.indicator {y ::ᵥ ys} (λ _, 1) (x ::ᵥ xs) :\n        by simp only [repeat_succ, eval_dist_bind_apply_eq_tsum, ← ennreal.tsum_mul_left,\n          eval_dist_return_apply_eq_indicator, hm, list.map, vector.to_list_map,\n          vector.to_list_cons, list.prod_cons, mul_assoc]\n      ... = ⁅oa⁆ x * ⁅oa.repeat m⁆ xs * set.indicator {x ::ᵥ xs} (λ _, 1) (x ::ᵥ xs) :\n        begin\n          refine tsum_tsum_eq_single _ x xs (λ y hy, mul_eq_zero_of_right _ $\n            set.indicator_apply_eq_zero.2 (λ h, (hy _).elim)) (λ y ys hys, mul_eq_zero_of_right _ $\n            set.indicator_apply_eq_zero.2 (λ h, (hys _).elim)),\n          { rw [set.mem_singleton_iff, vector.cons_eq_cons] at h,\n            exact h.1.symm },\n          { rw [set.mem_singleton_iff, vector.cons_eq_cons] at h,\n            exact h.2.symm }\n        end\n      ... = ⁅oa⁆ x * ⁅oa.repeat m⁆ xs :\n        by simp only [set.indicator_of_mem, set.mem_singleton, mul_one]\n      ... = (vector.map ⁅oa⁆ (x ::ᵥ xs)).to_list.prod :\n        by rw [vector.map_cons, vector.to_list_cons, list.prod_cons, hm] }\nend\n\nlemma eval_dist_repeat_zero' : ⁅oa.repeat 0⁆ = ⁅(return vector.nil : oracle_comp spec _)⁆ := rfl\n\n@[simp] lemma eval_dist_repeat_zero : ⁅oa.repeat 0⁆ = pmf.pure vector.nil :=\nby simp only [repeat_zero, eval_dist_return]\n\nlemma eval_dist_repeat_zero_apply : ⁅oa.repeat 0⁆ xs₀ = 1 :=\nby simp only [repeat_zero, eval_dist_return, pmf.pure_apply, eq_iff_true_of_subsingleton, if_true]\n\nlemma eval_dist_repeat_succ' :\n  ⁅oa.repeat n.succ⁆ = ⁅(λ (x : α × vector α n), x.1 ::ᵥ x.2) <$> (oa ×ₘ oa.repeat n)⁆ :=\nby rw [repeat_succ, map_eq_bind_return_comp, (prod_bind_equiv_bind_bind _ _ _).eval_dist_eq]\n\n@[simp] lemma eval_dist_repeat_succ :\n  ⁅oa.repeat n.succ⁆ = ⁅oa ×ₘ oa.repeat n⁆.map (λ x, x.1 ::ᵥ x.2) :=\n(oa.eval_dist_repeat_succ' n).trans (eval_dist_map _ _)\n\nlemma eval_dist_repeat_succ_apply :\n  ⁅oa.repeat m.succ⁆ xsₛ = ⁅oa⁆ xsₛ.head * ⁅oa.repeat m⁆ xsₛ.tail :=\ncalc ⁅oa.repeat m.succ⁆ xsₛ = ⁅(λ (x : α × vector α m), x.1 ::ᵥ x.2) <$> (oa ×ₘ oa.repeat m)⁆ xsₛ :\n    by rw eval_dist_repeat_succ' oa m\n  ... = ⁅oa ×ₘ oa.repeat m⁆ (xsₛ.head, xsₛ.tail) :\n    eval_dist_map_apply_eq_single' _ _ xsₛ (xsₛ.head, xsₛ.tail) (xsₛ.cons_head_tail)\n      (λ x hx hx', by rw [← hx', vector.head_cons, vector.tail_cons, prod.mk.eta])\n  ... = ⁅oa⁆ xsₛ.head * ⁅oa.repeat m⁆ xsₛ.tail : by rw eval_dist_product_apply\n\nlemma eval_dist_map_nth_repeat (i : fin m) :\n  ⁅(λ xs, vector.nth xs i) <$> oa.repeat m⁆ = ⁅oa⁆ :=\nbegin\n  induction m with m hm,\n  {\n    refine fin.elim0 i,\n  },\n  {\n    rw [eval_dist_map, eval_dist_repeat_succ, pmf.map_comp],\n    by_cases hi : i = 0,\n    {\n      simp [hi], sorry,\n    },\n    {\n      sorry,\n    }\n  }\nend\n\nend eval_dist\n\nsection prob_event\n\nlemma prob_event_succ_thing (e : set (vector α m.succ)) :\n  ⁅e | oa.repeat m.succ⁆ = ∑' (x : α) (xs : vector α m), e.indicator ⁅oa.repeat m.succ⁆ (x ::ᵥ xs) :=\nbegin\n  sorry\nend\n\n/-- After repeating a computation the probability of an event holding on any single\nresult is the same as the probability of the event holding after running the computation once. -/\n@[simp] lemma prob_event_nth_repeat (e : set α) (i : fin m) :\n  ⁅λ xs, xs.nth i ∈ e | oa.repeat m⁆ = ⁅e | oa⁆ :=\ntrans (by simpa only [prob_event_map])\n  (prob_event_eq_of_eval_dist_eq (eval_dist_map_nth_repeat oa i) e)\n\n@[simp] lemma prob_event_head_repeat (e : set α) :\n  ⁅λ xs, xs.head ∈ e | oa.repeat m.succ⁆ = ⁅e | oa⁆ :=\ncalc ⁅λ xs, xs.head ∈ e | oa.repeat m.succ⁆ = ⁅λ xs, xs.nth 0 ∈ e | oa.repeat m.succ⁆ :\n    by simp only [vector.nth_zero]\n  ... = ⁅e | oa⁆ : prob_event_nth_repeat oa e 0\n\nlemma prob_event_all₂ (p : α → Prop) :\n  ⁅λ xs, xs.to_list.all₂ p | oa.repeat m⁆ = ⁅p | oa⁆ ^ m :=\nbegin\n  sorry\nend\n\nend prob_event\n\nend oracle_comp", "meta": {"author": "dtumad", "repo": "lean-crypto-formalization", "sha": "f975a9a9882120b509553a7ced9aa05b745ff154", "save_path": "github-repos/lean/dtumad-lean-crypto-formalization", "path": "github-repos/lean/dtumad-lean-crypto-formalization/lean-crypto-formalization-f975a9a9882120b509553a7ced9aa05b745ff154/src/computational_monads/constructions/repeat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.46852742145359105}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n\n! This file was ported from Lean 3 source module ring_theory.subsemiring.basic\n! leanprover-community/mathlib commit 13a5329a8625701af92e9a96ffc90fa787fff24d\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Module.Basic\nimport Mathbin.Algebra.Ring.Equiv\nimport Mathbin.Algebra.Ring.Prod\nimport Mathbin.Algebra.Order.Ring.InjSurj\nimport Mathbin.Algebra.GroupRingAction.Subobjects\nimport Mathbin.Data.Set.Finite\nimport Mathbin.GroupTheory.Submonoid.Centralizer\nimport Mathbin.GroupTheory.Submonoid.Membership\n\n/-!\n# Bundled subsemirings\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define bundled subsemirings and some standard constructions: `complete_lattice` structure,\n`subtype` and `inclusion` ring homomorphisms, subsemiring `map`, `comap` and range (`srange`) of\na `ring_hom` etc.\n-/\n\n\nopen BigOperators\n\nuniverse u v w\n\nsection AddSubmonoidWithOneClass\n\n#print AddSubmonoidWithOneClass /-\n/-- `add_submonoid_with_one_class S R` says `S` is a type of subsets `s ≤ R` that contain `0`, `1`,\nand are closed under `(+)` -/\nclass AddSubmonoidWithOneClass (S : Type _) (R : Type _) [AddMonoidWithOne R] [SetLike S R] extends\n  AddSubmonoidClass S R, OneMemClass S R : Prop\n#align add_submonoid_with_one_class AddSubmonoidWithOneClass\n-/\n\nvariable {S R : Type _} [AddMonoidWithOne R] [SetLike S R] (s : S)\n\n/- warning: nat_cast_mem -> natCast_mem is a dubious translation:\nlean 3 declaration is\n  forall {S : Type.{u1}} {R : Type.{u2}} [_inst_1 : AddMonoidWithOne.{u2} R] [_inst_2 : SetLike.{u1, u2} S R] (s : S) [_inst_3 : AddSubmonoidWithOneClass.{u1, u2} S R _inst_1 _inst_2] (n : Nat), Membership.Mem.{u2, u1} R S (SetLike.hasMem.{u1, u2} S R _inst_2) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u2} Nat R (CoeTCₓ.coe.{1, succ u2} Nat R (Nat.castCoe.{u2} R (AddMonoidWithOne.toNatCast.{u2} R _inst_1)))) n) s\nbut is expected to have type\n  forall {S : Type.{u2}} {R : Type.{u1}} [_inst_1 : AddMonoidWithOne.{u1} R] [_inst_2 : SetLike.{u2, u1} S R] (s : S) [_inst_3 : AddSubmonoidWithOneClass.{u2, u1} S R _inst_1 _inst_2] (n : Nat), Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) (Nat.cast.{u1} R (AddMonoidWithOne.toNatCast.{u1} R _inst_1) n) s\nCase conversion may be inaccurate. Consider using '#align nat_cast_mem natCast_memₓ'. -/\ntheorem natCast_mem [AddSubmonoidWithOneClass S R] (n : ℕ) : (n : R) ∈ s := by\n  induction n <;> simp [zero_mem, add_mem, one_mem, *]\n#align nat_cast_mem natCast_mem\n\n#print AddSubmonoidWithOneClass.toAddMonoidWithOne /-\ninstance (priority := 74) AddSubmonoidWithOneClass.toAddMonoidWithOne\n    [AddSubmonoidWithOneClass S R] : AddMonoidWithOne s :=\n  { AddSubmonoidClass.toAddMonoid s with\n    one := ⟨_, one_mem s⟩\n    natCast := fun n => ⟨n, natCast_mem s n⟩\n    natCast_zero := Subtype.ext Nat.cast_zero\n    natCast_succ := fun n => Subtype.ext (Nat.cast_succ _) }\n#align add_submonoid_with_one_class.to_add_monoid_with_one AddSubmonoidWithOneClass.toAddMonoidWithOne\n-/\n\nend AddSubmonoidWithOneClass\n\nvariable {R : Type u} {S : Type v} {T : Type w} [NonAssocSemiring R] (M : Submonoid R)\n\nsection SubsemiringClass\n\n#print SubsemiringClass /-\n/-- `subsemiring_class S R` states that `S` is a type of subsets `s ⊆ R` that\nare both a multiplicative and an additive submonoid. -/\nclass SubsemiringClass (S : Type _) (R : Type u) [NonAssocSemiring R] [SetLike S R] extends\n  SubmonoidClass S R, AddSubmonoidClass S R : Prop\n#align subsemiring_class SubsemiringClass\n-/\n\n#print SubsemiringClass.addSubmonoidWithOneClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) SubsemiringClass.addSubmonoidWithOneClass (S : Type _) (R : Type u)\n    [NonAssocSemiring R] [SetLike S R] [h : SubsemiringClass S R] : AddSubmonoidWithOneClass S R :=\n  { h with }\n#align subsemiring_class.add_submonoid_with_one_class SubsemiringClass.addSubmonoidWithOneClass\n-/\n\nvariable [SetLike S R] [hSR : SubsemiringClass S R] (s : S)\n\ninclude hSR\n\n#print coe_nat_mem /-\ntheorem coe_nat_mem (n : ℕ) : (n : R) ∈ s :=\n  by\n  rw [← nsmul_one]\n  exact nsmul_mem (one_mem _) _\n#align coe_nat_mem coe_nat_mem\n-/\n\nnamespace SubsemiringClass\n\n#print SubsemiringClass.toNonAssocSemiring /-\n-- Prefer subclasses of `non_assoc_semiring` over subclasses of `subsemiring_class`.\n/-- A subsemiring of a `non_assoc_semiring` inherits a `non_assoc_semiring` structure -/\ninstance (priority := 75) toNonAssocSemiring : NonAssocSemiring s :=\n  Subtype.coe_injective.NonAssocSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_non_assoc_semiring SubsemiringClass.toNonAssocSemiring\n-/\n\n#print SubsemiringClass.nontrivial /-\ninstance nontrivial [Nontrivial R] : Nontrivial s :=\n  nontrivial_of_ne 0 1 fun H => zero_ne_one (congr_arg Subtype.val H)\n#align subsemiring_class.nontrivial SubsemiringClass.nontrivial\n-/\n\n/- warning: subsemiring_class.no_zero_divisors -> SubsemiringClass.noZeroDivisors is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : SetLike.{u2, u1} S R] [hSR : SubsemiringClass.{u1, u2} S R _inst_1 _inst_2] (s : S) [_inst_3 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))], NoZeroDivisors.{u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) (MulMemClass.mul.{u1, u2} R S (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) _inst_2 (SubmonoidClass.to_mulMemClass.{u2, u1} S R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) _inst_2 (SubsemiringClass.to_submonoidClass.{u1, u2} S R _inst_1 _inst_2 hSR)) s) (ZeroMemClass.zero.{u2, u1} S R _inst_2 (AddZeroClass.toHasZero.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (AddSubmonoidClass.to_zeroMemClass.{u2, u1} S R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) _inst_2 (SubsemiringClass.to_addSubmonoidClass.{u1, u2} S R _inst_1 _inst_2 hSR)) s)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : SetLike.{u2, u1} S R] [hSR : SubsemiringClass.{u1, u2} S R _inst_1 _inst_2] (s : S) [_inst_3 : NoZeroDivisors.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))], NoZeroDivisors.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) (NonUnitalNonAssocSemiring.toMul.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s))) (ZeroMemClass.zero.{u2, u1} S R _inst_2 (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (AddSubmonoidClass.toZeroMemClass.{u2, u1} S R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) _inst_2 (SubsemiringClass.toAddSubmonoidClass.{u1, u2} S R _inst_1 _inst_2 hSR)) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring_class.no_zero_divisors SubsemiringClass.noZeroDivisorsₓ'. -/\ninstance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s\n    where eq_zero_or_eq_zero_of_mul_eq_zero x y h :=\n    Or.cases_on (eq_zero_or_eq_zero_of_mul_eq_zero <| Subtype.ext_iff.mp h)\n      (fun h => Or.inl <| Subtype.eq h) fun h => Or.inr <| Subtype.eq h\n#align subsemiring_class.no_zero_divisors SubsemiringClass.noZeroDivisors\n\n#print SubsemiringClass.subtype /-\n/-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/\ndef subtype : s →+* R :=\n  { SubmonoidClass.Subtype s, AddSubmonoidClass.Subtype s with toFun := coe }\n#align subsemiring_class.subtype SubsemiringClass.subtype\n-/\n\n/- warning: subsemiring_class.coe_subtype -> SubsemiringClass.coe_subtype is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : SetLike.{u2, u1} S R] [hSR : SubsemiringClass.{u1, u2} S R _inst_1 _inst_2] (s : S), Eq.{succ u1} ((fun (_x : RingHom.{u1, u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) => (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) -> R) (SubsemiringClass.subtype.{u1, u2} R S _inst_1 _inst_2 hSR s)) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) (fun (_x : RingHom.{u1, u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) => (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) -> R) (RingHom.hasCoeToFun.{u1, u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) (SubsemiringClass.subtype.{u1, u2} R S _inst_1 _inst_2 hSR s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S R _inst_2) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u2} R S (SetLike.hasMem.{u2, u1} S R _inst_2) x s))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : SetLike.{u2, u1} S R] [hSR : SubsemiringClass.{u1, u2} S R _inst_1 _inst_2] (s : S), Eq.{succ u1} (forall (a : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) => R) a) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) (fun (_x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) => R) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (NonUnitalNonAssocSemiring.toMul.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1 (RingHom.instRingHomClassRingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_2) x s)) R (SubsemiringClass.toNonAssocSemiring.{u1, u2} R S _inst_1 _inst_2 hSR s) _inst_1)))) (SubsemiringClass.subtype.{u1, u2} R S _inst_1 _inst_2 hSR s)) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u2, u1} S R _inst_2 s)))\nCase conversion may be inaccurate. Consider using '#align subsemiring_class.coe_subtype SubsemiringClass.coe_subtypeₓ'. -/\n@[simp]\ntheorem coe_subtype : (subtype s : s → R) = coe :=\n  rfl\n#align subsemiring_class.coe_subtype SubsemiringClass.coe_subtype\n\nomit hSR\n\n#print SubsemiringClass.toSemiring /-\n-- Prefer subclasses of `semiring` over subclasses of `subsemiring_class`.\n/-- A subsemiring of a `semiring` is a `semiring`. -/\ninstance (priority := 75) toSemiring {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] :\n    Semiring s :=\n  Subtype.coe_injective.Semiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_semiring SubsemiringClass.toSemiring\n-/\n\n/- warning: subsemiring_class.coe_pow -> SubsemiringClass.coe_pow is a dubious translation:\nlean 3 declaration is\n  forall {S : Type.{u1}} (s : S) {R : Type.{u2}} [_inst_3 : Semiring.{u2} R] [_inst_4 : SetLike.{u1, u2} S R] [_inst_5 : SubsemiringClass.{u2, u1} S R (Semiring.toNonAssocSemiring.{u2} R _inst_3) _inst_4] (x : coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) (n : Nat), Eq.{succ u2} R ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (coeBase.{succ u2, succ u2} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (coeSubtype.{succ u2} R (fun (x : R) => Membership.Mem.{u2, u1} R S (SetLike.hasMem.{u1, u2} S R _inst_4) x s))))) (HPow.hPow.{u2, 0, u2} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) Nat (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) (instHPow.{u2, 0} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) Nat (SubmonoidClass.nPow.{u2, u1} R (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R _inst_3)) S _inst_4 (SubsemiringClass.to_submonoidClass.{u2, u1} S R (Semiring.toNonAssocSemiring.{u2} R _inst_3) _inst_4 _inst_5) s)) x n)) (HPow.hPow.{u2, 0, u2} R Nat R (instHPow.{u2, 0} R Nat (Monoid.Pow.{u2} R (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R _inst_3)))) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (coeBase.{succ u2, succ u2} (coeSort.{succ u1, succ (succ u2)} S Type.{u2} (SetLike.hasCoeToSort.{u1, u2} S R _inst_4) s) R (coeSubtype.{succ u2} R (fun (x : R) => Membership.Mem.{u2, u1} R S (SetLike.hasMem.{u1, u2} S R _inst_4) x s))))) x) n)\nbut is expected to have type\n  forall {S : Type.{u2}} (s : S) {R : Type.{u1}} [_inst_3 : Semiring.{u1} R] [_inst_4 : SetLike.{u2, u1} S R] [_inst_5 : SubsemiringClass.{u1, u2} S R (Semiring.toNonAssocSemiring.{u1} R _inst_3) _inst_4] (x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_4) x s)) (n : Nat), Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u2, u1} S R _inst_4 s)) (HPow.hPow.{u1, 0, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_4) x s)) Nat (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_4) x s)) (instHPow.{u1, 0} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u2} R S (SetLike.instMembership.{u2, u1} S R _inst_4) x s)) Nat (SubmonoidClass.nPow.{u1, u2} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_3)) S _inst_4 (SubsemiringClass.toSubmonoidClass.{u1, u2} S R (Semiring.toNonAssocSemiring.{u1} R _inst_3) _inst_4 _inst_5) s)) x n)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_3)))) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u2, u1} S R _inst_4 s)) x) n)\nCase conversion may be inaccurate. Consider using '#align subsemiring_class.coe_pow SubsemiringClass.coe_powₓ'. -/\n@[simp, norm_cast]\ntheorem coe_pow {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] (x : s) (n : ℕ) :\n    ((x ^ n : s) : R) = (x ^ n : R) :=\n  by\n  induction' n with n ih\n  · simp\n  · simp [pow_succ, ih]\n#align subsemiring_class.coe_pow SubsemiringClass.coe_pow\n\n#print SubsemiringClass.toCommSemiring /-\n/-- A subsemiring of a `comm_semiring` is a `comm_semiring`. -/\ninstance toCommSemiring {R} [CommSemiring R] [SetLike S R] [SubsemiringClass S R] :\n    CommSemiring s :=\n  Subtype.coe_injective.CommSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_comm_semiring SubsemiringClass.toCommSemiring\n-/\n\n#print SubsemiringClass.toOrderedSemiring /-\n/-- A subsemiring of an `ordered_semiring` is an `ordered_semiring`. -/\ninstance toOrderedSemiring {R} [OrderedSemiring R] [SetLike S R] [SubsemiringClass S R] :\n    OrderedSemiring s :=\n  Subtype.coe_injective.OrderedSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_ordered_semiring SubsemiringClass.toOrderedSemiring\n-/\n\n#print SubsemiringClass.toStrictOrderedSemiring /-\n/-- A subsemiring of an `strict_ordered_semiring` is an `strict_ordered_semiring`. -/\ninstance toStrictOrderedSemiring {R} [StrictOrderedSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : StrictOrderedSemiring s :=\n  Subtype.coe_injective.StrictOrderedSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_strict_ordered_semiring SubsemiringClass.toStrictOrderedSemiring\n-/\n\n#print SubsemiringClass.toOrderedCommSemiring /-\n/-- A subsemiring of an `ordered_comm_semiring` is an `ordered_comm_semiring`. -/\ninstance toOrderedCommSemiring {R} [OrderedCommSemiring R] [SetLike S R] [SubsemiringClass S R] :\n    OrderedCommSemiring s :=\n  Subtype.coe_injective.OrderedCommSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_ordered_comm_semiring SubsemiringClass.toOrderedCommSemiring\n-/\n\n#print SubsemiringClass.toStrictOrderedCommSemiring /-\n/-- A subsemiring of an `strict_ordered_comm_semiring` is an `strict_ordered_comm_semiring`. -/\ninstance toStrictOrderedCommSemiring {R} [StrictOrderedCommSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : StrictOrderedCommSemiring s :=\n  Subtype.coe_injective.StrictOrderedCommSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring_class.to_strict_ordered_comm_semiring SubsemiringClass.toStrictOrderedCommSemiring\n-/\n\n#print SubsemiringClass.toLinearOrderedSemiring /-\n/-- A subsemiring of a `linear_ordered_semiring` is a `linear_ordered_semiring`. -/\ninstance toLinearOrderedSemiring {R} [LinearOrderedSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : LinearOrderedSemiring s :=\n  Subtype.coe_injective.LinearOrderedSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring_class.to_linear_ordered_semiring SubsemiringClass.toLinearOrderedSemiring\n-/\n\n#print SubsemiringClass.toLinearOrderedCommSemiring /-\n/-- A subsemiring of a `linear_ordered_comm_semiring` is a `linear_ordered_comm_semiring`. -/\ninstance toLinearOrderedCommSemiring {R} [LinearOrderedCommSemiring R] [SetLike S R]\n    [SubsemiringClass S R] : LinearOrderedCommSemiring s :=\n  Subtype.coe_injective.LinearOrderedCommSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring_class.to_linear_ordered_comm_semiring SubsemiringClass.toLinearOrderedCommSemiring\n-/\n\nend SubsemiringClass\n\nend SubsemiringClass\n\nvariable [NonAssocSemiring S] [NonAssocSemiring T]\n\n#print Subsemiring /-\n/-- A subsemiring of a semiring `R` is a subset `s` that is both a multiplicative and an additive\nsubmonoid. -/\nstructure Subsemiring (R : Type u) [NonAssocSemiring R] extends Submonoid R, AddSubmonoid R\n#align subsemiring Subsemiring\n-/\n\n/-- Reinterpret a `subsemiring` as a `submonoid`. -/\nadd_decl_doc Subsemiring.toSubmonoid\n\n/-- Reinterpret a `subsemiring` as an `add_submonoid`. -/\nadd_decl_doc Subsemiring.toAddSubmonoid\n\nnamespace Subsemiring\n\ninstance : SetLike (Subsemiring R) R\n    where\n  coe := Subsemiring.carrier\n  coe_injective' p q h := by cases p <;> cases q <;> congr\n\ninstance : SubsemiringClass (Subsemiring R) R\n    where\n  zero_mem := zero_mem'\n  add_mem := add_mem'\n  one_mem := one_mem'\n  mul_mem := mul_mem'\n\n/- warning: subsemiring.mem_carrier -> Subsemiring.mem_carrier is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) x (Subsemiring.carrier.{u1} R _inst_1 s)) (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (Subsemigroup.carrier.{u1} R (MulOneClass.toMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Submonoid.toSubsemigroup.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)))) (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_carrier Subsemiring.mem_carrierₓ'. -/\n@[simp]\ntheorem mem_carrier {s : Subsemiring R} {x : R} : x ∈ s.carrier ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_carrier Subsemiring.mem_carrier\n\n/- warning: subsemiring.ext -> Subsemiring.ext is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Subsemiring.{u1} R _inst_1} {T : Subsemiring.{u1} R _inst_1}, (forall (x : R), Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x S) (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x T)) -> (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) S T)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Subsemiring.{u1} R _inst_1} {T : Subsemiring.{u1} R _inst_1}, (forall (x : R), Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x S) (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x T)) -> (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) S T)\nCase conversion may be inaccurate. Consider using '#align subsemiring.ext Subsemiring.extₓ'. -/\n/-- Two subsemirings are equal if they have the same elements. -/\n@[ext]\ntheorem ext {S T : Subsemiring R} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=\n  SetLike.ext h\n#align subsemiring.ext Subsemiring.ext\n\n/- warning: subsemiring.copy -> Subsemiring.copy is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Subsemiring.{u1} R _inst_1) (s : Set.{u1} R), (Eq.{succ u1} (Set.{u1} R) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) S)) -> (Subsemiring.{u1} R _inst_1)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Subsemiring.{u1} R _inst_1) (s : Set.{u1} R), (Eq.{succ u1} (Set.{u1} R) s (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) S)) -> (Subsemiring.{u1} R _inst_1)\nCase conversion may be inaccurate. Consider using '#align subsemiring.copy Subsemiring.copyₓ'. -/\n/-- Copy of a subsemiring with a new `carrier` equal to the old one. Useful to fix definitional\nequalities.-/\nprotected def copy (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : Subsemiring R :=\n  { S.toAddSubmonoid.copy s hs, S.toSubmonoid.copy s hs with carrier := s }\n#align subsemiring.copy Subsemiring.copy\n\n/- warning: subsemiring.coe_copy -> Subsemiring.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Subsemiring.{u1} R _inst_1) (s : Set.{u1} R) (hs : Eq.{succ u1} (Set.{u1} R) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) S)), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.copy.{u1} R _inst_1 S s hs)) s\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Subsemiring.{u1} R _inst_1) (s : Set.{u1} R) (hs : Eq.{succ u1} (Set.{u1} R) s (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) S)), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.copy.{u1} R _inst_1 S s hs)) s\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_copy Subsemiring.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : (S.copy s hs : Set R) = s :=\n  rfl\n#align subsemiring.coe_copy Subsemiring.coe_copy\n\n/- warning: subsemiring.copy_eq -> Subsemiring.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Subsemiring.{u1} R _inst_1) (s : Set.{u1} R) (hs : Eq.{succ u1} (Set.{u1} R) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) S)), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.copy.{u1} R _inst_1 S s hs) S\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Subsemiring.{u1} R _inst_1) (s : Set.{u1} R) (hs : Eq.{succ u1} (Set.{u1} R) s (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) S)), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.copy.{u1} R _inst_1 S s hs) S\nCase conversion may be inaccurate. Consider using '#align subsemiring.copy_eq Subsemiring.copy_eqₓ'. -/\ntheorem copy_eq (S : Subsemiring R) (s : Set R) (hs : s = ↑S) : S.copy s hs = S :=\n  SetLike.coe_injective hs\n#align subsemiring.copy_eq Subsemiring.copy_eq\n\n#print Subsemiring.toSubmonoid_injective /-\ntheorem toSubmonoid_injective : Function.Injective (toSubmonoid : Subsemiring R → Submonoid R)\n  | r, s, h => ext (SetLike.ext_iff.mp h : _)\n#align subsemiring.to_submonoid_injective Subsemiring.toSubmonoid_injective\n-/\n\n/- warning: subsemiring.to_submonoid_strict_mono -> Subsemiring.toSubmonoid_strictMono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], StrictMono.{u1, u1} (Subsemiring.{u1} R _inst_1) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))))) (Subsemiring.toSubmonoid.{u1} R _inst_1)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], StrictMono.{u1, u1} (Subsemiring.{u1} R _inst_1) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) (Subsemiring.toSubmonoid.{u1} R _inst_1)\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_submonoid_strict_mono Subsemiring.toSubmonoid_strictMonoₓ'. -/\n@[mono]\ntheorem toSubmonoid_strictMono : StrictMono (toSubmonoid : Subsemiring R → Submonoid R) :=\n  fun _ _ => id\n#align subsemiring.to_submonoid_strict_mono Subsemiring.toSubmonoid_strictMono\n\n/- warning: subsemiring.to_submonoid_mono -> Subsemiring.toSubmonoid_mono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Monotone.{u1, u1} (Subsemiring.{u1} R _inst_1) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))))) (Subsemiring.toSubmonoid.{u1} R _inst_1)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Monotone.{u1, u1} (Subsemiring.{u1} R _inst_1) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) (Subsemiring.toSubmonoid.{u1} R _inst_1)\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_submonoid_mono Subsemiring.toSubmonoid_monoₓ'. -/\n@[mono]\ntheorem toSubmonoid_mono : Monotone (toSubmonoid : Subsemiring R → Submonoid R) :=\n  toSubmonoid_strictMono.Monotone\n#align subsemiring.to_submonoid_mono Subsemiring.toSubmonoid_mono\n\n#print Subsemiring.toAddSubmonoid_injective /-\ntheorem toAddSubmonoid_injective :\n    Function.Injective (toAddSubmonoid : Subsemiring R → AddSubmonoid R)\n  | r, s, h => ext (SetLike.ext_iff.mp h : _)\n#align subsemiring.to_add_submonoid_injective Subsemiring.toAddSubmonoid_injective\n-/\n\n/- warning: subsemiring.to_add_submonoid_strict_mono -> Subsemiring.toAddSubmonoid_strictMono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], StrictMono.{u1, u1} (Subsemiring.{u1} R _inst_1) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], StrictMono.{u1, u1} (Subsemiring.{u1} R _inst_1) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1)\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_add_submonoid_strict_mono Subsemiring.toAddSubmonoid_strictMonoₓ'. -/\n@[mono]\ntheorem toAddSubmonoid_strictMono : StrictMono (toAddSubmonoid : Subsemiring R → AddSubmonoid R) :=\n  fun _ _ => id\n#align subsemiring.to_add_submonoid_strict_mono Subsemiring.toAddSubmonoid_strictMono\n\n/- warning: subsemiring.to_add_submonoid_mono -> Subsemiring.toAddSubmonoid_mono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Monotone.{u1, u1} (Subsemiring.{u1} R _inst_1) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (SetLike.partialOrder.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Monotone.{u1, u1} (Subsemiring.{u1} R _inst_1) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1))) (PartialOrder.toPreorder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (CompleteSemilatticeInf.toPartialOrder.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (AddSubmonoid.instCompleteLatticeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1)\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_add_submonoid_mono Subsemiring.toAddSubmonoid_monoₓ'. -/\n@[mono]\ntheorem toAddSubmonoid_mono : Monotone (toAddSubmonoid : Subsemiring R → AddSubmonoid R) :=\n  toAddSubmonoid_strictMono.Monotone\n#align subsemiring.to_add_submonoid_mono Subsemiring.toAddSubmonoid_mono\n\n/- warning: subsemiring.mk' -> Subsemiring.mk' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Set.{u1} R) (sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))), (Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) sm) s) -> (forall (sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))), (Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) sa) s) -> (Subsemiring.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Set.{u1} R) (sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))), (Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) sm) s) -> (forall (sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))), (Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) sa) s) -> (Subsemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mk' Subsemiring.mk'ₓ'. -/\n/-- Construct a `subsemiring R` from a set `s`, a submonoid `sm`, and an additive\nsubmonoid `sa` such that `x ∈ s ↔ x ∈ sm ↔ x ∈ sa`. -/\nprotected def mk' (s : Set R) (sm : Submonoid R) (hm : ↑sm = s) (sa : AddSubmonoid R)\n    (ha : ↑sa = s) : Subsemiring R where\n  carrier := s\n  zero_mem' := ha ▸ sa.zero_mem\n  one_mem' := hm ▸ sm.one_mem\n  add_mem' x y := by simpa only [← ha] using sa.add_mem\n  mul_mem' x y := by simpa only [← hm] using sm.mul_mem\n#align subsemiring.mk' Subsemiring.mk'\n\n/- warning: subsemiring.coe_mk' -> Subsemiring.coe_mk' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) sa) s), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) s\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) sa) s), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) s\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_mk' Subsemiring.coe_mk'ₓ'. -/\n@[simp]\ntheorem coe_mk' {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R} (ha : ↑sa = s) :\n    (Subsemiring.mk' s sm hm sa ha : Set R) = s :=\n  rfl\n#align subsemiring.coe_mk' Subsemiring.coe_mk'\n\n/- warning: subsemiring.mem_mk' -> Subsemiring.mem_mk' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) sa) s) {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) x s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) sa) s) {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_mk' Subsemiring.mem_mk'ₓ'. -/\n@[simp]\ntheorem mem_mk' {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R} (ha : ↑sa = s)\n    {x : R} : x ∈ Subsemiring.mk' s sm hm sa ha ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_mk' Subsemiring.mem_mk'\n\n/- warning: subsemiring.mk'_to_submonoid -> Subsemiring.mk'_toSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) sa) s), Eq.{succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.toSubmonoid.{u1} R _inst_1 (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) sm\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) sa) s), Eq.{succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.toSubmonoid.{u1} R _inst_1 (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) sm\nCase conversion may be inaccurate. Consider using '#align subsemiring.mk'_to_submonoid Subsemiring.mk'_toSubmonoidₓ'. -/\n@[simp]\ntheorem mk'_toSubmonoid {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R}\n    (ha : ↑sa = s) : (Subsemiring.mk' s sm hm sa ha).toSubmonoid = sm :=\n  SetLike.coe_injective hm.symm\n#align subsemiring.mk'_to_submonoid Subsemiring.mk'_toSubmonoid\n\n/- warning: subsemiring.mk'_to_add_submonoid -> Subsemiring.mk'_toAddSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) sa) s), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1 (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) sa\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {sm : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))} (hm : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) sm) s) {sa : AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))} (ha : Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) sa) s), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1 (Subsemiring.mk'.{u1} R _inst_1 s sm hm sa ha)) sa\nCase conversion may be inaccurate. Consider using '#align subsemiring.mk'_to_add_submonoid Subsemiring.mk'_toAddSubmonoidₓ'. -/\n@[simp]\ntheorem mk'_toAddSubmonoid {s : Set R} {sm : Submonoid R} (hm : ↑sm = s) {sa : AddSubmonoid R}\n    (ha : ↑sa = s) : (Subsemiring.mk' s sm hm sa ha).toAddSubmonoid = sa :=\n  SetLike.coe_injective ha.symm\n#align subsemiring.mk'_to_add_submonoid Subsemiring.mk'_toAddSubmonoid\n\nend Subsemiring\n\nnamespace Subsemiring\n\nvariable (s : Subsemiring R)\n\n/- warning: subsemiring.one_mem -> Subsemiring.one_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) s\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocSemiring.toOne.{u1} R _inst_1))) s\nCase conversion may be inaccurate. Consider using '#align subsemiring.one_mem Subsemiring.one_memₓ'. -/\n/-- A subsemiring contains the semiring's 1. -/\nprotected theorem one_mem : (1 : R) ∈ s :=\n  one_mem s\n#align subsemiring.one_mem Subsemiring.one_mem\n\n/- warning: subsemiring.zero_mem -> Subsemiring.zero_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))))) s\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))) s\nCase conversion may be inaccurate. Consider using '#align subsemiring.zero_mem Subsemiring.zero_memₓ'. -/\n/-- A subsemiring contains the semiring's 0. -/\nprotected theorem zero_mem : (0 : R) ∈ s :=\n  zero_mem s\n#align subsemiring.zero_mem Subsemiring.zero_mem\n\n/- warning: subsemiring.mul_mem -> Subsemiring.mul_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {x : R} {y : R}, (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) y s) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x y) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {x : R} {y : R}, (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) y s) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) x y) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.mul_mem Subsemiring.mul_memₓ'. -/\n/-- A subsemiring is closed under multiplication. -/\nprotected theorem mul_mem {x y : R} : x ∈ s → y ∈ s → x * y ∈ s :=\n  mul_mem\n#align subsemiring.mul_mem Subsemiring.mul_mem\n\n/- warning: subsemiring.add_mem -> Subsemiring.add_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {x : R} {y : R}, (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) y s) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x y) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {x : R} {y : R}, (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) y s) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x y) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.add_mem Subsemiring.add_memₓ'. -/\n/-- A subsemiring is closed under addition. -/\nprotected theorem add_mem {x y : R} : x ∈ s → y ∈ s → x + y ∈ s :=\n  add_mem\n#align subsemiring.add_mem Subsemiring.add_mem\n\n/- warning: subsemiring.list_prod_mem -> Subsemiring.list_prod_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) {l : List.{u1} R}, (forall (x : R), (Membership.Mem.{u1, u1} R (List.{u1} R) (List.hasMem.{u1} R) x l) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) (List.prod.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) l) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) {l : List.{u1} R}, (forall (x : R), (Membership.mem.{u1, u1} R (List.{u1} R) (List.instMembershipList.{u1} R) x l) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s)) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) (List.prod.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) (Semiring.toOne.{u1} R _inst_4) l) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.list_prod_mem Subsemiring.list_prod_memₓ'. -/\n/-- Product of a list of elements in a `subsemiring` is in the `subsemiring`. -/\ntheorem list_prod_mem {R : Type _} [Semiring R] (s : Subsemiring R) {l : List R} :\n    (∀ x ∈ l, x ∈ s) → l.Prod ∈ s :=\n  list_prod_mem\n#align subsemiring.list_prod_mem Subsemiring.list_prod_mem\n\n/- warning: subsemiring.list_sum_mem -> Subsemiring.list_sum_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {l : List.{u1} R}, (forall (x : R), (Membership.Mem.{u1, u1} R (List.{u1} R) (List.hasMem.{u1} R) x l) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (List.sum.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) l) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {l : List.{u1} R}, (forall (x : R), (Membership.mem.{u1, u1} R (List.{u1} R) (List.instMembershipList.{u1} R) x l) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (List.sum.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) l) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.list_sum_mem Subsemiring.list_sum_memₓ'. -/\n/-- Sum of a list of elements in a `subsemiring` is in the `subsemiring`. -/\nprotected theorem list_sum_mem {l : List R} : (∀ x ∈ l, x ∈ s) → l.Sum ∈ s :=\n  list_sum_mem\n#align subsemiring.list_sum_mem Subsemiring.list_sum_mem\n\n/- warning: subsemiring.multiset_prod_mem -> Subsemiring.multiset_prod_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : CommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (m : Multiset.{u1} R), (forall (a : R), (Membership.Mem.{u1, u1} R (Multiset.{u1} R) (Multiset.hasMem.{u1} R) a m) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) a s)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) (Multiset.prod.{u1} R (CommSemiring.toCommMonoid.{u1} R _inst_4) m) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : CommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (m : Multiset.{u1} R), (forall (a : R), (Membership.mem.{u1, u1} R (Multiset.{u1} R) (Multiset.instMembershipMultiset.{u1} R) a m) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) a s)) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) (Multiset.prod.{u1} R (CommSemiring.toCommMonoid.{u1} R _inst_4) m) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.multiset_prod_mem Subsemiring.multiset_prod_memₓ'. -/\n/-- Product of a multiset of elements in a `subsemiring` of a `comm_semiring`\n    is in the `subsemiring`. -/\nprotected theorem multiset_prod_mem {R} [CommSemiring R] (s : Subsemiring R) (m : Multiset R) :\n    (∀ a ∈ m, a ∈ s) → m.Prod ∈ s :=\n  multiset_prod_mem m\n#align subsemiring.multiset_prod_mem Subsemiring.multiset_prod_mem\n\n/- warning: subsemiring.multiset_sum_mem -> Subsemiring.multiset_sum_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) (m : Multiset.{u1} R), (forall (a : R), (Membership.Mem.{u1, u1} R (Multiset.{u1} R) (Multiset.hasMem.{u1} R) a m) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) a s)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (Multiset.sum.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) m) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) (m : Multiset.{u1} R), (forall (a : R), (Membership.mem.{u1, u1} R (Multiset.{u1} R) (Multiset.instMembershipMultiset.{u1} R) a m) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) a s)) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (Multiset.sum.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) m) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.multiset_sum_mem Subsemiring.multiset_sum_memₓ'. -/\n/-- Sum of a multiset of elements in a `subsemiring` of a `semiring` is\nin the `add_subsemiring`. -/\nprotected theorem multiset_sum_mem (m : Multiset R) : (∀ a ∈ m, a ∈ s) → m.Sum ∈ s :=\n  multiset_sum_mem m\n#align subsemiring.multiset_sum_mem Subsemiring.multiset_sum_mem\n\n/- warning: subsemiring.prod_mem -> Subsemiring.prod_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : CommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) {ι : Type.{u2}} {t : Finset.{u2} ι} {f : ι -> R}, (forall (c : ι), (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) c t) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) (f c) s)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R _inst_4) t (fun (i : ι) => f i)) s)\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_4 : CommSemiring.{u2} R] (s : Subsemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_4))) {ι : Type.{u1}} {t : Finset.{u1} ι} {f : ι -> R}, (forall (c : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) c t) -> (Membership.mem.{u2, u2} R (Subsemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_4))) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_4))) R (Subsemiring.instSetLikeSubsemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_4)))) (f c) s)) -> (Membership.mem.{u2, u2} R (Subsemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_4))) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_4))) R (Subsemiring.instSetLikeSubsemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_4)))) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R _inst_4) t (fun (i : ι) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_mem Subsemiring.prod_memₓ'. -/\n/-- Product of elements of a subsemiring of a `comm_semiring` indexed by a `finset` is in the\n    subsemiring. -/\nprotected theorem prod_mem {R : Type _} [CommSemiring R] (s : Subsemiring R) {ι : Type _}\n    {t : Finset ι} {f : ι → R} (h : ∀ c ∈ t, f c ∈ s) : (∏ i in t, f i) ∈ s :=\n  prod_mem h\n#align subsemiring.prod_mem Subsemiring.prod_mem\n\n/- warning: subsemiring.sum_mem -> Subsemiring.sum_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {ι : Type.{u2}} {t : Finset.{u2} ι} {f : ι -> R}, (forall (c : ι), (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) c t) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (f c) s)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (Finset.sum.{u1, u2} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) t (fun (i : ι) => f i)) s)\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_1 : NonAssocSemiring.{u2} R] (s : Subsemiring.{u2} R _inst_1) {ι : Type.{u1}} {t : Finset.{u1} ι} {f : ι -> R}, (forall (c : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) c t) -> (Membership.mem.{u2, u2} R (Subsemiring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u2} R _inst_1)) (f c) s)) -> (Membership.mem.{u2, u2} R (Subsemiring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u2} R _inst_1)) (Finset.sum.{u2, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) t (fun (i : ι) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.sum_mem Subsemiring.sum_memₓ'. -/\n/-- Sum of elements in an `subsemiring` of an `semiring` indexed by a `finset`\nis in the `add_subsemiring`. -/\nprotected theorem sum_mem (s : Subsemiring R) {ι : Type _} {t : Finset ι} {f : ι → R}\n    (h : ∀ c ∈ t, f c ∈ s) : (∑ i in t, f i) ∈ s :=\n  sum_mem h\n#align subsemiring.sum_mem Subsemiring.sum_mem\n\n/- warning: subsemiring.to_non_assoc_semiring -> Subsemiring.toNonAssocSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), NonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), NonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_non_assoc_semiring Subsemiring.toNonAssocSemiringₓ'. -/\n/-- A subsemiring of a `non_assoc_semiring` inherits a `non_assoc_semiring` structure -/\ninstance toNonAssocSemiring : NonAssocSemiring s :=\n  { s.toSubmonoid.toMulOneClass,\n    s.toAddSubmonoid.toAddCommMonoid with\n    mul_zero := fun x => Subtype.eq <| MulZeroClass.mul_zero x\n    zero_mul := fun x => Subtype.eq <| MulZeroClass.zero_mul x\n    right_distrib := fun x y z => Subtype.eq <| right_distrib x y z\n    left_distrib := fun x y z => Subtype.eq <| left_distrib x y z\n    natCast := fun n => ⟨n, coe_nat_mem s n⟩\n    natCast_zero := by simp [Nat.cast] <;> rfl\n    natCast_succ := fun _ => by simp [Nat.cast] <;> rfl }\n#align subsemiring.to_non_assoc_semiring Subsemiring.toNonAssocSemiring\n\n#print Subsemiring.coe_one /-\n@[simp, norm_cast]\ntheorem coe_one : ((1 : s) : R) = (1 : R) :=\n  rfl\n#align subsemiring.coe_one Subsemiring.coe_one\n-/\n\n/- warning: subsemiring.coe_zero -> Subsemiring.coe_zero is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) (OfNat.ofNat.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) 0 (OfNat.mk.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) 0 (Zero.zero.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (ZeroMemClass.zero.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1) (AddZeroClass.toHasZero.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (AddSubmonoidClass.to_zeroMemClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (Subsemiring.setLike.{u1} R _inst_1) (SubsemiringClass.to_addSubmonoidClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R _inst_1 (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.subsemiringClass.{u1} R _inst_1))) s))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) (OfNat.ofNat.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) 0 (Zero.toOfNat0.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (ZeroMemClass.zero.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (AddSubmonoidClass.toZeroMemClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (SubsemiringClass.toAddSubmonoidClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R _inst_1 (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.instSubsemiringClassSubsemiringInstSetLikeSubsemiring.{u1} R _inst_1))) s)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_zero Subsemiring.coe_zeroₓ'. -/\n@[simp, norm_cast]\ntheorem coe_zero : ((0 : s) : R) = (0 : R) :=\n  rfl\n#align subsemiring.coe_zero Subsemiring.coe_zero\n\n/- warning: subsemiring.coe_add -> Subsemiring.coe_add is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (y : coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s), Eq.{succ u1} R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) (HAdd.hAdd.{u1, u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (instHAdd.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (AddSubmonoidClass.to_addMemClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (Subsemiring.setLike.{u1} R _inst_1) (SubsemiringClass.to_addSubmonoidClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R _inst_1 (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.subsemiringClass.{u1} R _inst_1))) s)) x y)) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) (x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (y : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)), Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) (HAdd.hAdd.{u1, u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (instHAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s))))) x y)) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) x) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) y))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_add Subsemiring.coe_addₓ'. -/\n@[simp, norm_cast]\ntheorem coe_add (x y : s) : ((x + y : s) : R) = (x + y : R) :=\n  rfl\n#align subsemiring.coe_add Subsemiring.coe_add\n\n/- warning: subsemiring.coe_mul -> Subsemiring.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (y : coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s), Eq.{succ u1} R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) (HMul.hMul.{u1, u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (instHMul.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (SubmonoidClass.to_mulMemClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.setLike.{u1} R _inst_1) (SubsemiringClass.to_submonoidClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R _inst_1 (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.subsemiringClass.{u1} R _inst_1))) s)) x y)) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) y))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) (x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (y : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)), Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) (HMul.hMul.{u1, u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (instHMul.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s))) x y)) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) x) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) y))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_mul Subsemiring.coe_mulₓ'. -/\n@[simp, norm_cast]\ntheorem coe_mul (x y : s) : ((x * y : s) : R) = (x * y : R) :=\n  rfl\n#align subsemiring.coe_mul Subsemiring.coe_mul\n\n/- warning: subsemiring.nontrivial -> Subsemiring.nontrivial is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) [_inst_4 : Nontrivial.{u1} R], Nontrivial.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) [_inst_4 : Nontrivial.{u1} R], Nontrivial.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.nontrivial Subsemiring.nontrivialₓ'. -/\ninstance nontrivial [Nontrivial R] : Nontrivial s :=\n  nontrivial_of_ne 0 1 fun H => zero_ne_one (congr_arg Subtype.val H)\n#align subsemiring.nontrivial Subsemiring.nontrivial\n\n/- warning: subsemiring.pow_mem -> Subsemiring.pow_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) {x : R}, (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s) -> (forall (n : Nat), Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_4)))) x n) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) {x : R}, (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s) -> (forall (n : Nat), Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_4)))) x n) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.pow_mem Subsemiring.pow_memₓ'. -/\nprotected theorem pow_mem {R : Type _} [Semiring R] (s : Subsemiring R) {x : R} (hx : x ∈ s)\n    (n : ℕ) : x ^ n ∈ s :=\n  pow_mem hx n\n#align subsemiring.pow_mem Subsemiring.pow_mem\n\n/- warning: subsemiring.no_zero_divisors -> Subsemiring.noZeroDivisors is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) [_inst_4 : NoZeroDivisors.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))], NoZeroDivisors.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (SubmonoidClass.to_mulMemClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.setLike.{u1} R _inst_1) (SubsemiringClass.to_submonoidClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R _inst_1 (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.subsemiringClass.{u1} R _inst_1))) s) (ZeroMemClass.zero.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1) (AddZeroClass.toHasZero.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (AddSubmonoidClass.to_zeroMemClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (Subsemiring.setLike.{u1} R _inst_1) (SubsemiringClass.to_addSubmonoidClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R _inst_1 (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.subsemiringClass.{u1} R _inst_1))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) [_inst_4 : NoZeroDivisors.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))], NoZeroDivisors.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (ZeroMemClass.zero.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (AddSubmonoidClass.toZeroMemClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (SubsemiringClass.toAddSubmonoidClass.{u1, u1} (Subsemiring.{u1} R _inst_1) R _inst_1 (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.instSubsemiringClassSubsemiringInstSetLikeSubsemiring.{u1} R _inst_1))) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.no_zero_divisors Subsemiring.noZeroDivisorsₓ'. -/\ninstance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s\n    where eq_zero_or_eq_zero_of_mul_eq_zero x y h :=\n    Or.cases_on (eq_zero_or_eq_zero_of_mul_eq_zero <| Subtype.ext_iff.mp h)\n      (fun h => Or.inl <| Subtype.eq h) fun h => Or.inr <| Subtype.eq h\n#align subsemiring.no_zero_divisors Subsemiring.noZeroDivisors\n\n/- warning: subsemiring.to_semiring -> Subsemiring.toSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)), Semiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)), Semiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_semiring Subsemiring.toSemiringₓ'. -/\n/-- A subsemiring of a `semiring` is a `semiring`. -/\ninstance toSemiring {R} [Semiring R] (s : Subsemiring R) : Semiring s :=\n  { s.toNonAssocSemiring, s.toSubmonoid.toMonoid with }\n#align subsemiring.to_semiring Subsemiring.toSemiring\n\n/- warning: subsemiring.coe_pow -> Subsemiring.coe_pow is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (x : coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) (n : Nat), Eq.{succ u1} R ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s))))) (HPow.hPow.{u1, 0, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) Nat (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) (instHPow.{u1, 0} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) Nat (SubmonoidClass.nPow.{u1, u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_4)) (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SubsemiringClass.to_submonoidClass.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Semiring.toNonAssocSemiring.{u1} R _inst_4) (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Subsemiring.subsemiringClass.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s)) x n)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_4)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s))))) x) n)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s)) (n : Nat), Eq.{succ u1} R (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) s)) (HPow.hPow.{u1, 0, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s)) Nat (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s)) (instHPow.{u1, 0} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x s)) Nat (SubmonoidClass.nPow.{u1, u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_4)) (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SubsemiringClass.toSubmonoidClass.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Semiring.toNonAssocSemiring.{u1} R _inst_4) (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Subsemiring.instSubsemiringClassSubsemiringInstSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) s)) x n)) (HPow.hPow.{u1, 0, u1} R Nat R (instHPow.{u1, 0} R Nat (Monoid.Pow.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_4)))) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) s)) x) n)\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_pow Subsemiring.coe_powₓ'. -/\n@[simp, norm_cast]\ntheorem coe_pow {R} [Semiring R] (s : Subsemiring R) (x : s) (n : ℕ) :\n    ((x ^ n : s) : R) = (x ^ n : R) :=\n  by\n  induction' n with n ih\n  · simp\n  · simp [pow_succ, ih]\n#align subsemiring.coe_pow Subsemiring.coe_pow\n\n/- warning: subsemiring.to_comm_semiring -> Subsemiring.toCommSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : CommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))), CommSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : CommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))), CommSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_comm_semiring Subsemiring.toCommSemiringₓ'. -/\n/-- A subsemiring of a `comm_semiring` is a `comm_semiring`. -/\ninstance toCommSemiring {R} [CommSemiring R] (s : Subsemiring R) : CommSemiring s :=\n  { s.toSemiring with mul_comm := fun _ _ => Subtype.eq <| mul_comm _ _ }\n#align subsemiring.to_comm_semiring Subsemiring.toCommSemiring\n\n/- warning: subsemiring.subtype -> Subsemiring.subtype is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1\nCase conversion may be inaccurate. Consider using '#align subsemiring.subtype Subsemiring.subtypeₓ'. -/\n/-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/\ndef subtype : s →+* R :=\n  { s.toSubmonoid.Subtype, s.toAddSubmonoid.Subtype with toFun := coe }\n#align subsemiring.subtype Subsemiring.subtype\n\n/- warning: subsemiring.coe_subtype -> Subsemiring.coe_subtype is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} ((coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) -> R) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1) (fun (_x : RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1) => (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) -> R) (RingHom.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1) (Subsemiring.subtype.{u1} R _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (forall (ᾰ : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) => R) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (fun (_x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) => R) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (NonUnitalNonAssocSemiring.toMul.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1 (RingHom.instRingHomClassRingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1)))) (Subsemiring.subtype.{u1} R _inst_1 s)) (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_subtype Subsemiring.coe_subtypeₓ'. -/\n@[simp]\ntheorem coe_subtype : ⇑s.Subtype = coe :=\n  rfl\n#align subsemiring.coe_subtype Subsemiring.coe_subtype\n\n/- warning: subsemiring.to_ordered_semiring -> Subsemiring.toOrderedSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : OrderedSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4))), OrderedSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4)))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : OrderedSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4))), OrderedSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R _inst_4)))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_ordered_semiring Subsemiring.toOrderedSemiringₓ'. -/\n/-- A subsemiring of an `ordered_semiring` is an `ordered_semiring`. -/\ninstance toOrderedSemiring {R} [OrderedSemiring R] (s : Subsemiring R) : OrderedSemiring s :=\n  Subtype.coe_injective.OrderedSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_ordered_semiring Subsemiring.toOrderedSemiring\n\n/- warning: subsemiring.to_strict_ordered_semiring -> Subsemiring.toStrictOrderedSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : StrictOrderedSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))), StrictOrderedSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : StrictOrderedSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))), StrictOrderedSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_strict_ordered_semiring Subsemiring.toStrictOrderedSemiringₓ'. -/\n/-- A subsemiring of a `strict_ordered_semiring` is a `strict_ordered_semiring`. -/\ninstance toStrictOrderedSemiring {R} [StrictOrderedSemiring R] (s : Subsemiring R) :\n    StrictOrderedSemiring s :=\n  Subtype.coe_injective.StrictOrderedSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_strict_ordered_semiring Subsemiring.toStrictOrderedSemiring\n\n/- warning: subsemiring.to_ordered_comm_semiring -> Subsemiring.toOrderedCommSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : OrderedCommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4)))), OrderedCommSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4)))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4))))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : OrderedCommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4)))), OrderedCommSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4)))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4)))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_4))))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_ordered_comm_semiring Subsemiring.toOrderedCommSemiringₓ'. -/\n/-- A subsemiring of an `ordered_comm_semiring` is an `ordered_comm_semiring`. -/\ninstance toOrderedCommSemiring {R} [OrderedCommSemiring R] (s : Subsemiring R) :\n    OrderedCommSemiring s :=\n  Subtype.coe_injective.OrderedCommSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_ordered_comm_semiring Subsemiring.toOrderedCommSemiring\n\n/- warning: subsemiring.to_strict_ordered_comm_semiring -> Subsemiring.toStrictOrderedCommSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : StrictOrderedCommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))), StrictOrderedCommSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4))))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : StrictOrderedCommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))), StrictOrderedCommSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_4))))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_strict_ordered_comm_semiring Subsemiring.toStrictOrderedCommSemiringₓ'. -/\n/-- A subsemiring of a `strict_ordered_comm_semiring` is a `strict_ordered_comm_semiring`. -/\ninstance toStrictOrderedCommSemiring {R} [StrictOrderedCommSemiring R] (s : Subsemiring R) :\n    StrictOrderedCommSemiring s :=\n  Subtype.coe_injective.StrictOrderedCommSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl\n#align subsemiring.to_strict_ordered_comm_semiring Subsemiring.toStrictOrderedCommSemiring\n\n/- warning: subsemiring.to_linear_ordered_semiring -> Subsemiring.toLinearOrderedSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : LinearOrderedSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))), LinearOrderedSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4))))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : LinearOrderedSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))), LinearOrderedSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4)))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R _inst_4))))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_linear_ordered_semiring Subsemiring.toLinearOrderedSemiringₓ'. -/\n/-- A subsemiring of a `linear_ordered_semiring` is a `linear_ordered_semiring`. -/\ninstance toLinearOrderedSemiring {R} [LinearOrderedSemiring R] (s : Subsemiring R) :\n    LinearOrderedSemiring s :=\n  Subtype.coe_injective.LinearOrderedSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring.to_linear_ordered_semiring Subsemiring.toLinearOrderedSemiring\n\n/- warning: subsemiring.to_linear_ordered_comm_semiring -> Subsemiring.toLinearOrderedCommSemiring is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : LinearOrderedCommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4))))), LinearOrderedCommSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4))))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4))))) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4)))))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : LinearOrderedCommSemiring.{u1} R] (s : Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4))))), LinearOrderedCommSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4))))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4))))) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} R (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} R _inst_4)))))) x s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.to_linear_ordered_comm_semiring Subsemiring.toLinearOrderedCommSemiringₓ'. -/\n/-- A subsemiring of a `linear_ordered_comm_semiring` is a `linear_ordered_comm_semiring`. -/\ninstance toLinearOrderedCommSemiring {R} [LinearOrderedCommSemiring R] (s : Subsemiring R) :\n    LinearOrderedCommSemiring s :=\n  Subtype.coe_injective.LinearOrderedCommSemiring coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subsemiring.to_linear_ordered_comm_semiring Subsemiring.toLinearOrderedCommSemiring\n\n/- warning: subsemiring.nsmul_mem -> Subsemiring.nsmul_mem is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {x : R}, (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s) -> (forall (n : Nat), Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (SMul.smul.{0, u1} Nat R (AddMonoid.SMul.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) n x) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1) {x : R}, (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s) -> (forall (n : Nat), Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (HSMul.hSMul.{0, u1, u1} Nat R R (instHSMul.{0, u1} Nat R (AddMonoid.SMul.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) n x) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.nsmul_mem Subsemiring.nsmul_memₓ'. -/\nprotected theorem nsmul_mem {x : R} (hx : x ∈ s) (n : ℕ) : n • x ∈ s :=\n  nsmul_mem hx n\n#align subsemiring.nsmul_mem Subsemiring.nsmul_mem\n\n/- warning: subsemiring.mem_to_submonoid -> Subsemiring.mem_toSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.Mem.{u1, u1} R (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))) x (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.mem.{u1, u1} R (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))) x (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_to_submonoid Subsemiring.mem_toSubmonoidₓ'. -/\n@[simp]\ntheorem mem_toSubmonoid {s : Subsemiring R} {x : R} : x ∈ s.toSubmonoid ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_to_submonoid Subsemiring.mem_toSubmonoid\n\n/- warning: subsemiring.coe_to_submonoid -> Subsemiring.coe_toSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_to_submonoid Subsemiring.coe_toSubmonoidₓ'. -/\n@[simp]\ntheorem coe_toSubmonoid (s : Subsemiring R) : (s.toSubmonoid : Set R) = s :=\n  rfl\n#align subsemiring.coe_to_submonoid Subsemiring.coe_toSubmonoid\n\n/- warning: subsemiring.mem_to_add_submonoid -> Subsemiring.mem_toAddSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) x (Subsemiring.toAddSubmonoid.{u1} R _inst_1 s)) (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) x (Subsemiring.toAddSubmonoid.{u1} R _inst_1 s)) (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_to_add_submonoid Subsemiring.mem_toAddSubmonoidₓ'. -/\n@[simp]\ntheorem mem_toAddSubmonoid {s : Subsemiring R} {x : R} : x ∈ s.toAddSubmonoid ↔ x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_to_add_submonoid Subsemiring.mem_toAddSubmonoid\n\n/- warning: subsemiring.coe_to_add_submonoid -> Subsemiring.coe_toAddSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1 s)) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_to_add_submonoid Subsemiring.coe_toAddSubmonoidₓ'. -/\n@[simp]\ntheorem coe_toAddSubmonoid (s : Subsemiring R) : (s.toAddSubmonoid : Set R) = s :=\n  rfl\n#align subsemiring.coe_to_add_submonoid Subsemiring.coe_toAddSubmonoid\n\n/-- The subsemiring `R` of the semiring `R`. -/\ninstance : Top (Subsemiring R) :=\n  ⟨{ (⊤ : Submonoid R), (⊤ : AddSubmonoid R) with }⟩\n\n/- warning: subsemiring.mem_top -> Subsemiring.mem_top is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (x : R), Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (x : R), Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_top Subsemiring.mem_topₓ'. -/\n@[simp]\ntheorem mem_top (x : R) : x ∈ (⊤ : Subsemiring R) :=\n  Set.mem_univ x\n#align subsemiring.mem_top Subsemiring.mem_top\n\n/- warning: subsemiring.coe_top -> Subsemiring.coe_top is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))) (Set.univ.{u1} R)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))) (Set.univ.{u1} R)\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_top Subsemiring.coe_topₓ'. -/\n@[simp]\ntheorem coe_top : ((⊤ : Subsemiring R) : Set R) = Set.univ :=\n  rfl\n#align subsemiring.coe_top Subsemiring.coe_top\n\n/- warning: subsemiring.top_equiv -> Subsemiring.topEquiv is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], RingEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))) R (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.topEquiv._proof_1.{u1} R _inst_1) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.topEquiv._proof_2.{u1} R _inst_1) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], RingEquiv.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))) R (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.top_equiv Subsemiring.topEquivₓ'. -/\n/-- The ring equiv between the top element of `subsemiring R` and `R`. -/\n@[simps]\ndef topEquiv : (⊤ : Subsemiring R) ≃+* R\n    where\n  toFun r := r\n  invFun r := ⟨r, Subsemiring.mem_top r⟩\n  left_inv r := SetLike.eta r _\n  right_inv r := [anonymous] r _\n  map_mul' := (⊤ : Subsemiring R).coe_mul\n  map_add' := (⊤ : Subsemiring R).val_add\n#align subsemiring.top_equiv Subsemiring.topEquiv\n\n#print Subsemiring.comap /-\n/-- The preimage of a subsemiring along a ring homomorphism is a subsemiring. -/\ndef comap (f : R →+* S) (s : Subsemiring S) : Subsemiring R :=\n  { s.toSubmonoid.comap (f : R →* S), s.toAddSubmonoid.comap (f : R →+ S) with carrier := f ⁻¹' s }\n#align subsemiring.comap Subsemiring.comap\n-/\n\n/- warning: subsemiring.coe_comap -> Subsemiring.coe_comap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u2} S _inst_2) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f s)) (Set.preimage.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (HasLiftT.mk.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (CoeTCₓ.coe.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (SetLike.Set.hasCoeT.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)))) s))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u2} S _inst_2) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f s)) (Set.preimage.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f) (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_comap Subsemiring.coe_comapₓ'. -/\n@[simp]\ntheorem coe_comap (s : Subsemiring S) (f : R →+* S) : (s.comap f : Set R) = f ⁻¹' s :=\n  rfl\n#align subsemiring.coe_comap Subsemiring.coe_comap\n\n/- warning: subsemiring.mem_comap -> Subsemiring.mem_comap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {s : Subsemiring.{u2} S _inst_2} {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f s)) (Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) s)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {s : Subsemiring.{u2} S _inst_2} {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f s)) (Membership.mem.{u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_comap Subsemiring.mem_comapₓ'. -/\n@[simp]\ntheorem mem_comap {s : Subsemiring S} {f : R →+* S} {x : R} : x ∈ s.comap f ↔ f x ∈ s :=\n  Iff.rfl\n#align subsemiring.mem_comap Subsemiring.mem_comap\n\n#print Subsemiring.comap_comap /-\ntheorem comap_comap (s : Subsemiring T) (g : S →+* T) (f : R →+* S) :\n    (s.comap g).comap f = s.comap (g.comp f) :=\n  rfl\n#align subsemiring.comap_comap Subsemiring.comap_comap\n-/\n\n#print Subsemiring.map /-\n/-- The image of a subsemiring along a ring homomorphism is a subsemiring. -/\ndef map (f : R →+* S) (s : Subsemiring R) : Subsemiring S :=\n  { s.toSubmonoid.map (f : R →* S), s.toAddSubmonoid.map (f : R →+ S) with carrier := f '' s }\n#align subsemiring.map Subsemiring.map\n-/\n\n/- warning: subsemiring.coe_map -> Subsemiring.coe_map is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : Subsemiring.{u1} R _inst_1), Eq.{succ u2} (Set.{u2} S) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (HasLiftT.mk.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (CoeTCₓ.coe.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (SetLike.Set.hasCoeT.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)))) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (Set.image.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : Subsemiring.{u1} R _inst_1), Eq.{succ u2} (Set.{u2} S) (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (Set.image.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_map Subsemiring.coe_mapₓ'. -/\n@[simp]\ntheorem coe_map (f : R →+* S) (s : Subsemiring R) : (s.map f : Set S) = f '' s :=\n  rfl\n#align subsemiring.coe_map Subsemiring.coe_map\n\n/- warning: subsemiring.mem_map -> Subsemiring.mem_map is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {s : Subsemiring.{u1} R _inst_1} {y : S}, Iff (Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) y (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (Exists.{succ u1} R (fun (x : R) => Exists.{0} (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s) (fun (H : Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s) => Eq.{succ u2} S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) y)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {s : Subsemiring.{u1} R _inst_1} {y : S}, Iff (Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) y (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (Exists.{succ u1} R (fun (x : R) => And (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s) (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (a : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) a) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x) y)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_map Subsemiring.mem_mapₓ'. -/\n@[simp]\ntheorem mem_map {f : R →+* S} {s : Subsemiring R} {y : S} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=\n  Set.mem_image_iff_bex\n#align subsemiring.mem_map Subsemiring.mem_map\n\n#print Subsemiring.map_id /-\n@[simp]\ntheorem map_id : s.map (RingHom.id R) = s :=\n  SetLike.coe_injective <| Set.image_id _\n#align subsemiring.map_id Subsemiring.map_id\n-/\n\n#print Subsemiring.map_map /-\ntheorem map_map (g : S →+* T) (f : R →+* S) : (s.map f).map g = s.map (g.comp f) :=\n  SetLike.coe_injective <| Set.image_image _ _ _\n#align subsemiring.map_map Subsemiring.map_map\n-/\n\n/- warning: subsemiring.map_le_iff_le_comap -> Subsemiring.map_le_iff_le_comap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {s : Subsemiring.{u1} R _inst_1} {t : Subsemiring.{u2} S _inst_2}, Iff (LE.le.{u2} (Subsemiring.{u2} S _inst_2) (Preorder.toLE.{u2} (Subsemiring.{u2} S _inst_2) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (SetLike.partialOrder.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)))) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s) t) (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f t))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {s : Subsemiring.{u1} R _inst_1} {t : Subsemiring.{u2} S _inst_2}, Iff (LE.le.{u2} (Subsemiring.{u2} S _inst_2) (Preorder.toLE.{u2} (Subsemiring.{u2} S _inst_2) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (SetLike.instPartialOrder.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)))) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s) t) (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)))) s (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f t))\nCase conversion may be inaccurate. Consider using '#align subsemiring.map_le_iff_le_comap Subsemiring.map_le_iff_le_comapₓ'. -/\ntheorem map_le_iff_le_comap {f : R →+* S} {s : Subsemiring R} {t : Subsemiring S} :\n    s.map f ≤ t ↔ s ≤ t.comap f :=\n  Set.image_subset_iff\n#align subsemiring.map_le_iff_le_comap Subsemiring.map_le_iff_le_comap\n\n/- warning: subsemiring.gc_map_comap -> Subsemiring.gc_map_comap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), GaloisConnection.{u1, u2} (Subsemiring.{u1} R _inst_1) (Subsemiring.{u2} S _inst_2) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (SetLike.partialOrder.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2))) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), GaloisConnection.{u1, u2} (Subsemiring.{u1} R _inst_1) (Subsemiring.{u2} S _inst_2) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1))) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (SetLike.instPartialOrder.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2))) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align subsemiring.gc_map_comap Subsemiring.gc_map_comapₓ'. -/\ntheorem gc_map_comap (f : R →+* S) : GaloisConnection (map f) (comap f) := fun S T =>\n  map_le_iff_le_comap\n#align subsemiring.gc_map_comap Subsemiring.gc_map_comap\n\n/- warning: subsemiring.equiv_map_of_injective -> Subsemiring.equivMapOfInjective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), (Function.Injective.{succ u1, succ u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f)) -> (RingEquiv.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_1.{u1} R _inst_1) s) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_2.{u1} R _inst_1) s) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_3.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_4.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), (Function.Injective.{succ u1, succ u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f)) -> (RingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.equiv_map_of_injective Subsemiring.equivMapOfInjectiveₓ'. -/\n/-- A subsemiring is isomorphic to its image under an injective function -/\nnoncomputable def equivMapOfInjective (f : R →+* S) (hf : Function.Injective f) : s ≃+* s.map f :=\n  {\n    Equiv.Set.image f s\n      hf with\n    map_mul' := fun _ _ => Subtype.ext (f.map_mul _ _)\n    map_add' := fun _ _ => Subtype.ext (f.map_add _ _) }\n#align subsemiring.equiv_map_of_injective Subsemiring.equivMapOfInjective\n\n/- warning: subsemiring.coe_equiv_map_of_injective_apply -> Subsemiring.coe_equivMapOfInjective_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (hf : Function.Injective.{succ u1, succ u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f)) (x : coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s), Eq.{succ u2} S ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) S (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) S (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) S (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) S (coeSubtype.{succ u2} S (fun (x : S) => Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_1.{u1} R _inst_1) s) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_2.{u1} R _inst_1) s) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_3.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_4.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (fun (_x : RingEquiv.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_1.{u1} R _inst_1) s) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_2.{u1} R _inst_1) s) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_3.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_4.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) => (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) -> (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (RingEquiv.hasCoeToFun.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_1.{u1} R _inst_1) s) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.equivMapOfInjective._proof_2.{u1} R _inst_1) s) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_3.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.equivMapOfInjective._proof_4.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.equivMapOfInjective.{u1, u2} R S _inst_1 _inst_2 s f hf) x)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))) x))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (hf : Function.Injective.{succ u1, succ u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f)) (x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)), Eq.{succ u2} S (Subtype.val.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Set.{u2} S) (Set.instMembershipSet.{u2} S) x (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))))) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (fun (_x : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) => Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (RingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))))) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (EquivLike.toEmbeddingLike.{max (succ u1) (succ u2), succ u1, succ u2} (RingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))))) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (MulEquivClass.toEquivLike.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))))) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (RingEquivClass.toMulEquivClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))))) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))))) (RingEquiv.instRingEquivClassRingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s)))))))))) (Subsemiring.equivMapOfInjective.{u1, u2} R S _inst_1 _inst_2 s f hf) x)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f (Subtype.val.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)) x))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_equiv_map_of_injective_apply Subsemiring.coe_equivMapOfInjective_applyₓ'. -/\n@[simp]\ntheorem coe_equivMapOfInjective_apply (f : R →+* S) (hf : Function.Injective f) (x : s) :\n    (equivMapOfInjective s f hf x : S) = f x :=\n  rfl\n#align subsemiring.coe_equiv_map_of_injective_apply Subsemiring.coe_equivMapOfInjective_apply\n\nend Subsemiring\n\nnamespace RingHom\n\nvariable (g : S →+* T) (f : R →+* S)\n\n#print RingHom.rangeS /-\n/-- The range of a ring homomorphism is a subsemiring. See Note [range copy pattern]. -/\ndef rangeS : Subsemiring S :=\n  ((⊤ : Subsemiring R).map f).copy (Set.range f) Set.image_univ.symm\n#align ring_hom.srange RingHom.rangeS\n-/\n\n/- warning: ring_hom.coe_srange -> RingHom.coe_rangeS is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u2} (Set.{u2} S) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (HasLiftT.mk.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (CoeTCₓ.coe.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (SetLike.Set.hasCoeT.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)))) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Set.range.{u2, succ u1} S R (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u2} (Set.{u2} S) (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Set.range.{u2, succ u1} S R (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_srange RingHom.coe_rangeSₓ'. -/\n@[simp]\ntheorem coe_rangeS : (f.srange : Set S) = Set.range f :=\n  rfl\n#align ring_hom.coe_srange RingHom.coe_rangeS\n\n/- warning: ring_hom.mem_srange -> RingHom.mem_rangeS is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {y : S}, Iff (Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) y (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Exists.{succ u1} R (fun (x : R) => Eq.{succ u2} S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) y))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {y : S}, Iff (Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) y (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Exists.{succ u1} R (fun (x : R) => Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x) y))\nCase conversion may be inaccurate. Consider using '#align ring_hom.mem_srange RingHom.mem_rangeSₓ'. -/\n@[simp]\ntheorem mem_rangeS {f : R →+* S} {y : S} : y ∈ f.srange ↔ ∃ x, f x = y :=\n  Iff.rfl\n#align ring_hom.mem_srange RingHom.mem_rangeS\n\n/- warning: ring_hom.srange_eq_map -> RingHom.rangeS_eq_map is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.srange_eq_map RingHom.rangeS_eq_mapₓ'. -/\ntheorem rangeS_eq_map (f : R →+* S) : f.srange = (⊤ : Subsemiring R).map f :=\n  by\n  ext\n  simp\n#align ring_hom.srange_eq_map RingHom.rangeS_eq_map\n\n/- warning: ring_hom.mem_srange_self -> RingHom.mem_rangeS_self is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (x : R), Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (x : R), Membership.mem.{u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.mem_srange_self RingHom.mem_rangeS_selfₓ'. -/\ntheorem mem_rangeS_self (f : R →+* S) (x : R) : f x ∈ f.srange :=\n  mem_rangeS.mpr ⟨x, rfl⟩\n#align ring_hom.mem_srange_self RingHom.mem_rangeS_self\n\n#print RingHom.map_rangeS /-\ntheorem map_rangeS : f.srange.map g = (g.comp f).srange := by\n  simpa only [srange_eq_map] using (⊤ : Subsemiring R).map_map g f\n#align ring_hom.map_srange RingHom.map_rangeS\n-/\n\n/- warning: ring_hom.fintype_srange -> RingHom.fintypeRangeS is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_4 : Fintype.{u1} R] [_inst_5 : DecidableEq.{succ u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Fintype.{u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] [_inst_4 : Fintype.{u1} R] [_inst_5 : DecidableEq.{succ u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Fintype.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.fintype_srange RingHom.fintypeRangeSₓ'. -/\n/-- The range of a morphism of semirings is a fintype, if the domain is a fintype.\nNote: this instance can form a diamond with `subtype.fintype` in the\n  presence of `fintype S`.-/\ninstance fintypeRangeS [Fintype R] [DecidableEq S] (f : R →+* S) : Fintype (rangeS f) :=\n  Set.fintypeRange f\n#align ring_hom.fintype_srange RingHom.fintypeRangeS\n\nend RingHom\n\nnamespace Subsemiring\n\ninstance : Bot (Subsemiring R) :=\n  ⟨(Nat.castRingHom R).srange⟩\n\ninstance : Inhabited (Subsemiring R) :=\n  ⟨⊥⟩\n\n/- warning: subsemiring.coe_bot -> Subsemiring.coe_bot is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Bot.bot.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasBot.{u1} R _inst_1))) (Set.range.{u1, 1} R Nat ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Bot.bot.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instBotSubsemiring.{u1} R _inst_1))) (Set.range.{u1, 1} R Nat (Nat.cast.{u1} R (NonAssocSemiring.toNatCast.{u1} R _inst_1)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_bot Subsemiring.coe_botₓ'. -/\ntheorem coe_bot : ((⊥ : Subsemiring R) : Set R) = Set.range (coe : ℕ → R) :=\n  (Nat.castRingHom R).coe_srange\n#align subsemiring.coe_bot Subsemiring.coe_bot\n\n/- warning: subsemiring.mem_bot -> Subsemiring.mem_bot is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Bot.bot.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasBot.{u1} R _inst_1))) (Exists.{1} Nat (fun (n : Nat) => Eq.{succ u1} R ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) n) x))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Bot.bot.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instBotSubsemiring.{u1} R _inst_1))) (Exists.{1} Nat (fun (n : Nat) => Eq.{succ u1} R (Nat.cast.{u1} R (NonAssocSemiring.toNatCast.{u1} R _inst_1) n) x))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_bot Subsemiring.mem_botₓ'. -/\ntheorem mem_bot {x : R} : x ∈ (⊥ : Subsemiring R) ↔ ∃ n : ℕ, ↑n = x :=\n  RingHom.mem_rangeS\n#align subsemiring.mem_bot Subsemiring.mem_bot\n\n/-- The inf of two subsemirings is their intersection. -/\ninstance : Inf (Subsemiring R) :=\n  ⟨fun s t =>\n    { s.toSubmonoid ⊓ t.toSubmonoid, s.toAddSubmonoid ⊓ t.toAddSubmonoid with carrier := s ∩ t }⟩\n\n/- warning: subsemiring.coe_inf -> Subsemiring.coe_inf is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (p : Subsemiring.{u1} R _inst_1) (p' : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Inf.inf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) p p')) (Inter.inter.{u1} (Set.{u1} R) (Set.hasInter.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) p) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) p'))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (p : Subsemiring.{u1} R _inst_1) (p' : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Inf.inf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instInfSubsemiring.{u1} R _inst_1) p p')) (Inter.inter.{u1} (Set.{u1} R) (Set.instInterSet.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) p) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) p'))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_inf Subsemiring.coe_infₓ'. -/\n@[simp]\ntheorem coe_inf (p p' : Subsemiring R) : ((p ⊓ p' : Subsemiring R) : Set R) = p ∩ p' :=\n  rfl\n#align subsemiring.coe_inf Subsemiring.coe_inf\n\n/- warning: subsemiring.mem_inf -> Subsemiring.mem_inf is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {p : Subsemiring.{u1} R _inst_1} {p' : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Inf.inf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) p p')) (And (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x p) (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x p'))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {p : Subsemiring.{u1} R _inst_1} {p' : Subsemiring.{u1} R _inst_1} {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Inf.inf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instInfSubsemiring.{u1} R _inst_1) p p')) (And (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x p) (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x p'))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_inf Subsemiring.mem_infₓ'. -/\n@[simp]\ntheorem mem_inf {p p' : Subsemiring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=\n  Iff.rfl\n#align subsemiring.mem_inf Subsemiring.mem_inf\n\ninstance : InfSet (Subsemiring R) :=\n  ⟨fun s =>\n    Subsemiring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, Subsemiring.toSubmonoid t) (by simp)\n      (⨅ t ∈ s, Subsemiring.toAddSubmonoid t) (by simp)⟩\n\n/- warning: subsemiring.coe_Inf -> Subsemiring.coe_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Set.{u1} (Subsemiring.{u1} R _inst_1)), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (InfSet.infₛ.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) S)) (Set.interᵢ.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.interᵢ.{u1, 0} R (Membership.Mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.hasMem.{u1} (Subsemiring.{u1} R _inst_1)) s S) (fun (H : Membership.Mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.hasMem.{u1} (Subsemiring.{u1} R _inst_1)) s S) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (S : Set.{u1} (Subsemiring.{u1} R _inst_1)), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (InfSet.infₛ.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instInfSetSubsemiring.{u1} R _inst_1) S)) (Set.interᵢ.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.interᵢ.{u1, 0} R (Membership.mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.instMembershipSet.{u1} (Subsemiring.{u1} R _inst_1)) s S) (fun (H : Membership.mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.instMembershipSet.{u1} (Subsemiring.{u1} R _inst_1)) s S) => SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_Inf Subsemiring.coe_infₛₓ'. -/\n@[simp, norm_cast]\ntheorem coe_infₛ (S : Set (Subsemiring R)) : ((infₛ S : Subsemiring R) : Set R) = ⋂ s ∈ S, ↑s :=\n  rfl\n#align subsemiring.coe_Inf Subsemiring.coe_infₛ\n\n/- warning: subsemiring.mem_Inf -> Subsemiring.mem_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Set.{u1} (Subsemiring.{u1} R _inst_1)} {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (InfSet.infₛ.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) S)) (forall (p : Subsemiring.{u1} R _inst_1), (Membership.Mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.hasMem.{u1} (Subsemiring.{u1} R _inst_1)) p S) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x p))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Set.{u1} (Subsemiring.{u1} R _inst_1)} {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (InfSet.infₛ.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instInfSetSubsemiring.{u1} R _inst_1) S)) (forall (p : Subsemiring.{u1} R _inst_1), (Membership.mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.instMembershipSet.{u1} (Subsemiring.{u1} R _inst_1)) p S) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x p))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_Inf Subsemiring.mem_infₛₓ'. -/\ntheorem mem_infₛ {S : Set (Subsemiring R)} {x : R} : x ∈ infₛ S ↔ ∀ p ∈ S, x ∈ p :=\n  Set.mem_interᵢ₂\n#align subsemiring.mem_Inf Subsemiring.mem_infₛ\n\n#print Subsemiring.infₛ_toSubmonoid /-\n@[simp]\ntheorem infₛ_toSubmonoid (s : Set (Subsemiring R)) :\n    (infₛ s).toSubmonoid = ⨅ t ∈ s, Subsemiring.toSubmonoid t :=\n  mk'_toSubmonoid _ _\n#align subsemiring.Inf_to_submonoid Subsemiring.infₛ_toSubmonoid\n-/\n\n#print Subsemiring.infₛ_toAddSubmonoid /-\n@[simp]\ntheorem infₛ_toAddSubmonoid (s : Set (Subsemiring R)) :\n    (infₛ s).toAddSubmonoid = ⨅ t ∈ s, Subsemiring.toAddSubmonoid t :=\n  mk'_toAddSubmonoid _ _\n#align subsemiring.Inf_to_add_submonoid Subsemiring.infₛ_toAddSubmonoid\n-/\n\n/-- Subsemirings of a semiring form a complete lattice. -/\ninstance : CompleteLattice (Subsemiring R) :=\n  {\n    completeLatticeOfInf (Subsemiring R) fun s =>\n      IsGLB.of_image (fun s t => show (s : Set R) ≤ t ↔ s ≤ t from SetLike.coe_subset_coe)\n        isGLB_binfᵢ with\n    bot := ⊥\n    bot_le := fun s x hx =>\n      let ⟨n, hn⟩ := mem_bot.1 hx\n      hn ▸ coe_nat_mem s n\n    top := ⊤\n    le_top := fun s x hx => trivial\n    inf := (· ⊓ ·)\n    inf_le_left := fun s t x => And.left\n    inf_le_right := fun s t x => And.right\n    le_inf := fun s t₁ t₂ h₁ h₂ x hx => ⟨h₁ hx, h₂ hx⟩ }\n\n/- warning: subsemiring.eq_top_iff' -> Subsemiring.eq_top_iff' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (A : Subsemiring.{u1} R _inst_1), Iff (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) A (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))) (forall (x : R), Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x A)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (A : Subsemiring.{u1} R _inst_1), Iff (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) A (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))) (forall (x : R), Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x A)\nCase conversion may be inaccurate. Consider using '#align subsemiring.eq_top_iff' Subsemiring.eq_top_iff'ₓ'. -/\ntheorem eq_top_iff' (A : Subsemiring R) : A = ⊤ ↔ ∀ x : R, x ∈ A :=\n  eq_top_iff.trans ⟨fun h m => h <| mem_top m, fun h m _ => h m⟩\n#align subsemiring.eq_top_iff' Subsemiring.eq_top_iff'\n\nsection Center\n\n#print Subsemiring.center /-\n/-- The center of a semiring `R` is the set of elements that commute with everything in `R` -/\ndef center (R) [Semiring R] : Subsemiring R :=\n  { Submonoid.center R with\n    carrier := Set.center R\n    zero_mem' := Set.zero_mem_center R\n    add_mem' := fun a b => Set.add_mem_center }\n#align subsemiring.center Subsemiring.center\n-/\n\n/- warning: subsemiring.coe_center -> Subsemiring.coe_center is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_4 : Semiring.{u1} R], Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) (Subsemiring.center.{u1} R _inst_4)) (Set.center.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_4 : Semiring.{u1} R], Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Subsemiring.center.{u1} R _inst_4)) (Set.center.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_center Subsemiring.coe_centerₓ'. -/\ntheorem coe_center (R) [Semiring R] : ↑(center R) = Set.center R :=\n  rfl\n#align subsemiring.coe_center Subsemiring.coe_center\n\n#print Subsemiring.center_toSubmonoid /-\n@[simp]\ntheorem center_toSubmonoid (R) [Semiring R] : (center R).toSubmonoid = Submonoid.center R :=\n  rfl\n#align subsemiring.center_to_submonoid Subsemiring.center_toSubmonoid\n-/\n\n/- warning: subsemiring.mem_center_iff -> Subsemiring.mem_center_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] {z : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) z (Subsemiring.center.{u1} R _inst_4)) (forall (g : R), Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) g z) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) z g))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] {z : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) z (Subsemiring.center.{u1} R _inst_4)) (forall (g : R), Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) g z) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) z g))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_center_iff Subsemiring.mem_center_iffₓ'. -/\ntheorem mem_center_iff {R} [Semiring R] {z : R} : z ∈ center R ↔ ∀ g, g * z = z * g :=\n  Iff.rfl\n#align subsemiring.mem_center_iff Subsemiring.mem_center_iff\n\n/- warning: subsemiring.decidable_mem_center -> Subsemiring.decidableMemCenter is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] [_inst_5 : DecidableEq.{succ u1} R] [_inst_6 : Fintype.{u1} R], DecidablePred.{succ u1} R (fun (_x : R) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) _x (Subsemiring.center.{u1} R _inst_4))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] [_inst_5 : DecidableEq.{succ u1} R] [_inst_6 : Fintype.{u1} R], DecidablePred.{succ u1} R (fun (_x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) _x (Subsemiring.center.{u1} R _inst_4))\nCase conversion may be inaccurate. Consider using '#align subsemiring.decidable_mem_center Subsemiring.decidableMemCenterₓ'. -/\ninstance decidableMemCenter {R} [Semiring R] [DecidableEq R] [Fintype R] :\n    DecidablePred (· ∈ center R) := fun _ => decidable_of_iff' _ mem_center_iff\n#align subsemiring.decidable_mem_center Subsemiring.decidableMemCenter\n\n/- warning: subsemiring.center_eq_top -> Subsemiring.center_eq_top is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_4 : CommSemiring.{u1} R], Eq.{succ u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (Subsemiring.center.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)) (Top.top.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (Subsemiring.hasTop.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_4 : CommSemiring.{u1} R], Eq.{succ u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (Subsemiring.center.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4)) (Top.top.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))) (Subsemiring.instTopSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_4))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.center_eq_top Subsemiring.center_eq_topₓ'. -/\n@[simp]\ntheorem center_eq_top (R) [CommSemiring R] : center R = ⊤ :=\n  SetLike.coe_injective (Set.center_eq_univ R)\n#align subsemiring.center_eq_top Subsemiring.center_eq_top\n\n/-- The center is commutative. -/\ninstance {R} [Semiring R] : CommSemiring (center R) :=\n  { Submonoid.center.commMonoid, (center R).toSemiring with }\n\nend Center\n\nsection Centralizer\n\n#print Subsemiring.centralizer /-\n/-- The centralizer of a set as subsemiring. -/\ndef centralizer {R} [Semiring R] (s : Set R) : Subsemiring R :=\n  { Submonoid.centralizer s with\n    carrier := s.centralizer\n    zero_mem' := Set.zero_mem_centralizer _\n    add_mem' := fun x y hx hy => Set.add_mem_centralizer hx hy }\n#align subsemiring.centralizer Subsemiring.centralizer\n-/\n\n/- warning: subsemiring.coe_centralizer -> Subsemiring.coe_centralizer is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Set.{u1} R), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) (Subsemiring.centralizer.{u1} R _inst_4 s)) (Set.centralizer.{u1} R s (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Set.{u1} R), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Subsemiring.centralizer.{u1} R _inst_4 s)) (Set.centralizer.{u1} R s (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_centralizer Subsemiring.coe_centralizerₓ'. -/\n@[simp, norm_cast]\ntheorem coe_centralizer {R} [Semiring R] (s : Set R) : (centralizer s : Set R) = s.centralizer :=\n  rfl\n#align subsemiring.coe_centralizer Subsemiring.coe_centralizer\n\n#print Subsemiring.centralizer_toSubmonoid /-\ntheorem centralizer_toSubmonoid {R} [Semiring R] (s : Set R) :\n    (centralizer s).toSubmonoid = Submonoid.centralizer s :=\n  rfl\n#align subsemiring.centralizer_to_submonoid Subsemiring.centralizer_toSubmonoid\n-/\n\n/- warning: subsemiring.mem_centralizer_iff -> Subsemiring.mem_centralizer_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] {s : Set.{u1} R} {z : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) z (Subsemiring.centralizer.{u1} R _inst_4 s)) (forall (g : R), (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) g s) -> (Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) g z) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) z g)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] {s : Set.{u1} R} {z : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) z (Subsemiring.centralizer.{u1} R _inst_4 s)) (forall (g : R), (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) g s) -> (Eq.{succ u1} R (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) g z) (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) z g)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_centralizer_iff Subsemiring.mem_centralizer_iffₓ'. -/\ntheorem mem_centralizer_iff {R} [Semiring R] {s : Set R} {z : R} :\n    z ∈ centralizer s ↔ ∀ g ∈ s, g * z = z * g :=\n  Iff.rfl\n#align subsemiring.mem_centralizer_iff Subsemiring.mem_centralizer_iff\n\n/- warning: subsemiring.centralizer_le -> Subsemiring.centralizer_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Set.{u1} R) (t : Set.{u1} R), (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) s t) -> (LE.le.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Preorder.toLE.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) (Subsemiring.centralizer.{u1} R _inst_4 t) (Subsemiring.centralizer.{u1} R _inst_4 s))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] (s : Set.{u1} R) (t : Set.{u1} R), (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) s t) -> (LE.le.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Preorder.toLE.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))))) (Subsemiring.centralizer.{u1} R _inst_4 t) (Subsemiring.centralizer.{u1} R _inst_4 s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.centralizer_le Subsemiring.centralizer_leₓ'. -/\ntheorem centralizer_le {R} [Semiring R] (s t : Set R) (h : s ⊆ t) : centralizer t ≤ centralizer s :=\n  Set.centralizer_subset h\n#align subsemiring.centralizer_le Subsemiring.centralizer_le\n\n#print Subsemiring.centralizer_univ /-\n@[simp]\ntheorem centralizer_univ {R} [Semiring R] : centralizer Set.univ = center R :=\n  SetLike.ext' (Set.centralizer_univ R)\n#align subsemiring.centralizer_univ Subsemiring.centralizer_univ\n-/\n\nend Centralizer\n\n#print Subsemiring.closure /-\n/-- The `subsemiring` generated by a set. -/\ndef closure (s : Set R) : Subsemiring R :=\n  infₛ { S | s ⊆ S }\n#align subsemiring.closure Subsemiring.closure\n-/\n\n/- warning: subsemiring.mem_closure -> Subsemiring.mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {x : R} {s : Set.{u1} R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) (forall (S : Subsemiring.{u1} R _inst_1), (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) S)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x S))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {x : R} {s : Set.{u1} R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) (forall (S : Subsemiring.{u1} R _inst_1), (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) s (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) S)) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x S))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_closure Subsemiring.mem_closureₓ'. -/\ntheorem mem_closure {x : R} {s : Set R} : x ∈ closure s ↔ ∀ S : Subsemiring R, s ⊆ S → x ∈ S :=\n  mem_infₛ\n#align subsemiring.mem_closure Subsemiring.mem_closure\n\n/- warning: subsemiring.subset_closure -> Subsemiring.subset_closure is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.closure.{u1} R _inst_1 s))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R}, HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) s (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.subset_closure Subsemiring.subset_closureₓ'. -/\n/-- The subsemiring generated by a set includes the set. -/\n@[simp]\ntheorem subset_closure {s : Set R} : s ⊆ closure s := fun x hx => mem_closure.2 fun S hS => hS hx\n#align subsemiring.subset_closure Subsemiring.subset_closure\n\n/- warning: subsemiring.not_mem_of_not_mem_closure -> Subsemiring.not_mem_of_not_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {P : R}, (Not (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) P (Subsemiring.closure.{u1} R _inst_1 s))) -> (Not (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) P s))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {P : R}, (Not (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) P (Subsemiring.closure.{u1} R _inst_1 s))) -> (Not (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) P s))\nCase conversion may be inaccurate. Consider using '#align subsemiring.not_mem_of_not_mem_closure Subsemiring.not_mem_of_not_mem_closureₓ'. -/\ntheorem not_mem_of_not_mem_closure {s : Set R} {P : R} (hP : P ∉ closure s) : P ∉ s := fun h =>\n  hP (subset_closure h)\n#align subsemiring.not_mem_of_not_mem_closure Subsemiring.not_mem_of_not_mem_closure\n\n/- warning: subsemiring.closure_le -> Subsemiring.closure_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {t : Subsemiring.{u1} R _inst_1}, Iff (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.closure.{u1} R _inst_1 s) t) (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) t))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {t : Subsemiring.{u1} R _inst_1}, Iff (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) (Subsemiring.closure.{u1} R _inst_1 s) t) (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) s (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) t))\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_le Subsemiring.closure_leₓ'. -/\n/-- A subsemiring `S` includes `closure s` if and only if it includes `s`. -/\n@[simp]\ntheorem closure_le {s : Set R} {t : Subsemiring R} : closure s ≤ t ↔ s ⊆ t :=\n  ⟨Set.Subset.trans subset_closure, fun h => infₛ_le h⟩\n#align subsemiring.closure_le Subsemiring.closure_le\n\n/- warning: subsemiring.closure_mono -> Subsemiring.closure_mono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {{s : Set.{u1} R}} {{t : Set.{u1} R}}, (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) s t) -> (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.closure.{u1} R _inst_1 s) (Subsemiring.closure.{u1} R _inst_1 t))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {{s : Set.{u1} R}} {{t : Set.{u1} R}}, (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) s t) -> (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) (Subsemiring.closure.{u1} R _inst_1 s) (Subsemiring.closure.{u1} R _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_mono Subsemiring.closure_monoₓ'. -/\n/-- Subsemiring closure of a set is monotone in its argument: if `s ⊆ t`,\nthen `closure s ≤ closure t`. -/\ntheorem closure_mono ⦃s t : Set R⦄ (h : s ⊆ t) : closure s ≤ closure t :=\n  closure_le.2 <| Set.Subset.trans h subset_closure\n#align subsemiring.closure_mono Subsemiring.closure_mono\n\n/- warning: subsemiring.closure_eq_of_le -> Subsemiring.closure_eq_of_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {t : Subsemiring.{u1} R _inst_1}, (HasSubset.Subset.{u1} (Set.{u1} R) (Set.hasSubset.{u1} R) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) t)) -> (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) t (Subsemiring.closure.{u1} R _inst_1 s)) -> (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 s) t)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {t : Subsemiring.{u1} R _inst_1}, (HasSubset.Subset.{u1} (Set.{u1} R) (Set.instHasSubsetSet.{u1} R) s (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) t)) -> (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) t (Subsemiring.closure.{u1} R _inst_1 s)) -> (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 s) t)\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_eq_of_le Subsemiring.closure_eq_of_leₓ'. -/\ntheorem closure_eq_of_le {s : Set R} {t : Subsemiring R} (h₁ : s ⊆ t) (h₂ : t ≤ closure s) :\n    closure s = t :=\n  le_antisymm (closure_le.2 h₁) h₂\n#align subsemiring.closure_eq_of_le Subsemiring.closure_eq_of_le\n\n/- warning: subsemiring.mem_map_equiv -> Subsemiring.mem_map_equiv is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))} {K : Subsemiring.{u1} R _inst_1} {x : S}, Iff (Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (RingHom.hasCoeT.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquivClass.toRingHomClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquiv.ringEquivClass.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))))))) f) K)) (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (fun (_x : RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) => S -> R) (RingEquiv.hasCoeToFun.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingEquiv.symm.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) f) x) K)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))} {K : Subsemiring.{u1} R _inst_1} {x : S}, Iff (Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingHomClass.toRingHom.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquivClass.toRingHomClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquiv.instRingEquivClassRingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))) f) K)) (Membership.mem.{u1, u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : S) => R) x) (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S (fun (_x : S) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : S) => R) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u2, succ u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R (EquivLike.toEmbeddingLike.{max (succ u1) (succ u2), succ u2, succ u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R (MulEquivClass.toEquivLike.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (RingEquivClass.toMulEquivClass.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))))))) (RingEquiv.symm.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) f) x) K)\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_map_equiv Subsemiring.mem_map_equivₓ'. -/\ntheorem mem_map_equiv {f : R ≃+* S} {K : Subsemiring R} {x : S} :\n    x ∈ K.map (f : R →+* S) ↔ f.symm x ∈ K :=\n  @Set.mem_image_equiv _ _ (↑K) f.toEquiv x\n#align subsemiring.mem_map_equiv Subsemiring.mem_map_equiv\n\n/- warning: subsemiring.map_equiv_eq_comap_symm -> Subsemiring.map_equiv_eq_comap_symm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (K : Subsemiring.{u1} R _inst_1), Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (RingHom.hasCoeT.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquivClass.toRingHomClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquiv.ringEquivClass.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))))))) f) K) (Subsemiring.comap.{u2, u1} S R _inst_2 _inst_1 ((fun (a : Sort.{max (succ u2) (succ u1)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u2) (succ u1), max (succ u2) (succ u1)} a b] => self.0) (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingHom.{u2, u1} S R _inst_2 _inst_1) (HasLiftT.mk.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingHom.{u2, u1} S R _inst_2 _inst_1) (CoeTCₓ.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingHom.{u2, u1} S R _inst_2 _inst_1) (RingHom.hasCoeT.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquivClass.toRingHomClass.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquiv.ringEquivClass.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))))))) (RingEquiv.symm.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) f)) K)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (K : Subsemiring.{u1} R _inst_1), Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingHomClass.toRingHom.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquivClass.toRingHomClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquiv.instRingEquivClassRingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))) f) K) (Subsemiring.comap.{u2, u1} S R _inst_2 _inst_1 (RingHomClass.toRingHom.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquivClass.toRingHomClass.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingEquiv.symm.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) f)) K)\nCase conversion may be inaccurate. Consider using '#align subsemiring.map_equiv_eq_comap_symm Subsemiring.map_equiv_eq_comap_symmₓ'. -/\ntheorem map_equiv_eq_comap_symm (f : R ≃+* S) (K : Subsemiring R) :\n    K.map (f : R →+* S) = K.comap f.symm :=\n  SetLike.coe_injective (f.toEquiv.image_eq_preimage K)\n#align subsemiring.map_equiv_eq_comap_symm Subsemiring.map_equiv_eq_comap_symm\n\n/- warning: subsemiring.comap_equiv_eq_map_symm -> Subsemiring.comap_equiv_eq_map_symm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (K : Subsemiring.{u2} S _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (RingHom.{u1, u2} R S _inst_1 _inst_2) (RingHom.hasCoeT.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquivClass.toRingHomClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquiv.ringEquivClass.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))))))) f) K) (Subsemiring.map.{u2, u1} S R _inst_2 _inst_1 ((fun (a : Sort.{max (succ u2) (succ u1)}) (b : Sort.{max (succ u2) (succ u1)}) [self : HasLiftT.{max (succ u2) (succ u1), max (succ u2) (succ u1)} a b] => self.0) (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingHom.{u2, u1} S R _inst_2 _inst_1) (HasLiftT.mk.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingHom.{u2, u1} S R _inst_2 _inst_1) (CoeTCₓ.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingHom.{u2, u1} S R _inst_2 _inst_1) (RingHom.hasCoeT.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquivClass.toRingHomClass.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquiv.ringEquivClass.{u2, u1} S R (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))))))) (RingEquiv.symm.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) f)) K)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (K : Subsemiring.{u2} S _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 (RingHomClass.toRingHom.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquivClass.toRingHomClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) R S _inst_1 _inst_2 (RingEquiv.instRingEquivClassRingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))))) f) K) (Subsemiring.map.{u2, u1} S R _inst_2 _inst_1 (RingHomClass.toRingHom.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquivClass.toRingHomClass.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) S R _inst_2 _inst_1 (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} S R (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))) (RingEquiv.symm.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) f)) K)\nCase conversion may be inaccurate. Consider using '#align subsemiring.comap_equiv_eq_map_symm Subsemiring.comap_equiv_eq_map_symmₓ'. -/\ntheorem comap_equiv_eq_map_symm (f : R ≃+* S) (K : Subsemiring S) :\n    K.comap (f : R →+* S) = K.map f.symm :=\n  (map_equiv_eq_comap_symm f.symm K).symm\n#align subsemiring.comap_equiv_eq_map_symm Subsemiring.comap_equiv_eq_map_symm\n\nend Subsemiring\n\nnamespace Submonoid\n\n#print Submonoid.subsemiringClosure /-\n/-- The additive closure of a submonoid is a subsemiring. -/\ndef subsemiringClosure (M : Submonoid R) : Subsemiring R :=\n  {\n    AddSubmonoid.closure\n      (M : Set\n          R) with\n    one_mem' := AddSubmonoid.mem_closure.mpr fun y hy => hy M.one_mem\n    mul_mem' := fun x y => MulMemClass.mul_mem_add_closure }\n#align submonoid.subsemiring_closure Submonoid.subsemiringClosure\n-/\n\n/- warning: submonoid.subsemiring_closure_coe -> Submonoid.subsemiringClosure_coe is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (M : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Submonoid.subsemiringClosure.{u1} R _inst_1 M)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) M)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (M : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Submonoid.subsemiringClosure.{u1} R _inst_1 M)) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) M)))\nCase conversion may be inaccurate. Consider using '#align submonoid.subsemiring_closure_coe Submonoid.subsemiringClosure_coeₓ'. -/\ntheorem subsemiringClosure_coe :\n    (M.subsemiringClosure : Set R) = AddSubmonoid.closure (M : Set R) :=\n  rfl\n#align submonoid.subsemiring_closure_coe Submonoid.subsemiringClosure_coe\n\n/- warning: submonoid.subsemiring_closure_to_add_submonoid -> Submonoid.subsemiringClosure_toAddSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (M : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1 (Submonoid.subsemiringClosure.{u1} R _inst_1 M)) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) M))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (M : Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))), Eq.{succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.toAddSubmonoid.{u1} R _inst_1 (Submonoid.subsemiringClosure.{u1} R _inst_1 M)) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) M))\nCase conversion may be inaccurate. Consider using '#align submonoid.subsemiring_closure_to_add_submonoid Submonoid.subsemiringClosure_toAddSubmonoidₓ'. -/\ntheorem subsemiringClosure_toAddSubmonoid :\n    M.subsemiringClosure.toAddSubmonoid = AddSubmonoid.closure (M : Set R) :=\n  rfl\n#align submonoid.subsemiring_closure_to_add_submonoid Submonoid.subsemiringClosure_toAddSubmonoid\n\n#print Submonoid.subsemiringClosure_eq_closure /-\n/-- The `subsemiring` generated by a multiplicative submonoid coincides with the\n`subsemiring.closure` of the submonoid itself . -/\ntheorem subsemiringClosure_eq_closure : M.subsemiringClosure = Subsemiring.closure (M : Set R) :=\n  by\n  ext\n  refine'\n        ⟨fun hx => _, fun hx =>\n          (subsemiring.mem_closure.mp hx) M.subsemiring_closure fun s sM => _⟩ <;>\n      rintro - ⟨H1, rfl⟩ <;>\n    rintro - ⟨H2, rfl⟩\n  · exact add_submonoid.mem_closure.mp hx H1.to_add_submonoid H2\n  · exact H2 sM\n#align submonoid.subsemiring_closure_eq_closure Submonoid.subsemiringClosure_eq_closure\n-/\n\nend Submonoid\n\nnamespace Subsemiring\n\n#print Subsemiring.closure_submonoid_closure /-\n@[simp]\ntheorem closure_submonoid_closure (s : Set R) : closure ↑(Submonoid.closure s) = closure s :=\n  le_antisymm\n    (closure_le.mpr fun y hy =>\n      (Submonoid.mem_closure.mp hy) (closure s).toSubmonoid subset_closure)\n    (closure_mono Submonoid.subset_closure)\n#align subsemiring.closure_submonoid_closure Subsemiring.closure_submonoid_closure\n-/\n\n/- warning: subsemiring.coe_closure_eq -> Subsemiring.coe_closure_eq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Set.{u1} R), Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.closure.{u1} R _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))))) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) (Submonoid.closure.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) s))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Set.{u1} R), Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 s)) (SetLike.coe.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Submonoid.closure.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) s))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_closure_eq Subsemiring.coe_closure_eqₓ'. -/\n/-- The elements of the subsemiring closure of `M` are exactly the elements of the additive closure\nof a multiplicative submonoid `M`. -/\ntheorem coe_closure_eq (s : Set R) :\n    (closure s : Set R) = AddSubmonoid.closure (Submonoid.closure s : Set R) := by\n  simp [← Submonoid.subsemiringClosure_toAddSubmonoid, Submonoid.subsemiringClosure_eq_closure]\n#align subsemiring.coe_closure_eq Subsemiring.coe_closure_eq\n\n/- warning: subsemiring.mem_closure_iff -> Subsemiring.mem_closure_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) (Membership.Mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (SetLike.hasMem.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.setLike.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) x (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))))) (Submonoid.closure.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) s))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) (Membership.mem.{u1, u1} R (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (SetLike.instMembership.{u1, u1} (AddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) R (AddSubmonoid.instSetLikeAddSubmonoid.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) x (AddSubmonoid.closure.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))) (SetLike.coe.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Submonoid.closure.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) s))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_closure_iff Subsemiring.mem_closure_iffₓ'. -/\ntheorem mem_closure_iff {s : Set R} {x} :\n    x ∈ closure s ↔ x ∈ AddSubmonoid.closure (Submonoid.closure s : Set R) :=\n  Set.ext_iff.mp (coe_closure_eq s) x\n#align subsemiring.mem_closure_iff Subsemiring.mem_closure_iff\n\n#print Subsemiring.closure_addSubmonoid_closure /-\n@[simp]\ntheorem closure_addSubmonoid_closure {s : Set R} : closure ↑(AddSubmonoid.closure s) = closure s :=\n  by\n  ext x\n  refine' ⟨fun hx => _, fun hx => closure_mono AddSubmonoid.subset_closure hx⟩\n  rintro - ⟨H, rfl⟩\n  rintro - ⟨J, rfl⟩\n  refine' (add_submonoid.mem_closure.mp (mem_closure_iff.mp hx)) H.to_add_submonoid fun y hy => _\n  refine' (submonoid.mem_closure.mp hy) H.to_submonoid fun z hz => _\n  exact (add_submonoid.mem_closure.mp hz) H.to_add_submonoid fun w hw => J hw\n#align subsemiring.closure_add_submonoid_closure Subsemiring.closure_addSubmonoid_closure\n-/\n\n/- warning: subsemiring.closure_induction -> Subsemiring.closure_induction is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {p : R -> Prop} {x : R}, (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) -> (forall (x : R), (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))))) -> (p (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))))) -> (forall (x : R) (y : R), (p x) -> (p y) -> (p (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x y))) -> (forall (x : R) (y : R), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x y))) -> (p x)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {p : R -> Prop} {x : R}, (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) -> (forall (x : R), (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))))) -> (p (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocSemiring.toOne.{u1} R _inst_1)))) -> (forall (x : R) (y : R), (p x) -> (p y) -> (p (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x y))) -> (forall (x : R) (y : R), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) x y))) -> (p x)\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_induction Subsemiring.closure_inductionₓ'. -/\n/-- An induction principle for closure membership. If `p` holds for `0`, `1`, and all elements\nof `s`, and is preserved under addition and multiplication, then `p` holds for all elements\nof the closure of `s`. -/\n@[elab_as_elim]\ntheorem closure_induction {s : Set R} {p : R → Prop} {x} (h : x ∈ closure s) (Hs : ∀ x ∈ s, p x)\n    (H0 : p 0) (H1 : p 1) (Hadd : ∀ x y, p x → p y → p (x + y))\n    (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=\n  (@closure_le _ _ _ ⟨p, Hmul, H1, Hadd, H0⟩).2 Hs h\n#align subsemiring.closure_induction Subsemiring.closure_induction\n\n/- warning: subsemiring.closure_induction₂ -> Subsemiring.closure_induction₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {p : R -> R -> Prop} {x : R} {y : R}, (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) -> (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) y (Subsemiring.closure.{u1} R _inst_1 s)) -> (forall (x : R), (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) x s) -> (forall (y : R), (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) y s) -> (p x y))) -> (forall (x : R), p (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))))) x) -> (forall (x : R), p x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))))))) -> (forall (x : R), p (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1)))))) x) -> (forall (x : R), p x (OfNat.ofNat.{u1} R 1 (OfNat.mk.{u1} R 1 (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))))) -> (forall (x₁ : R) (x₂ : R) (y : R), (p x₁ y) -> (p x₂ y) -> (p (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x₁ x₂) y)) -> (forall (x : R) (y₁ : R) (y₂ : R), (p x y₁) -> (p x y₂) -> (p x (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) y₁ y₂))) -> (forall (x₁ : R) (x₂ : R) (y : R), (p x₁ y) -> (p x₂ y) -> (p (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x₁ x₂) y)) -> (forall (x : R) (y₁ : R) (y₂ : R), (p x y₁) -> (p x y₂) -> (p x (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) y₁ y₂))) -> (p x y)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Set.{u1} R} {p : R -> R -> Prop} {x : R} {y : R}, (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (Subsemiring.closure.{u1} R _inst_1 s)) -> (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) y (Subsemiring.closure.{u1} R _inst_1 s)) -> (forall (x : R), (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) x s) -> (forall (y : R), (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) y s) -> (p x y))) -> (forall (x : R), p (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)))) x) -> (forall (x : R), p x (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MulZeroOneClass.toZero.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))))) -> (forall (x : R), p (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocSemiring.toOne.{u1} R _inst_1))) x) -> (forall (x : R), p x (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (NonAssocSemiring.toOne.{u1} R _inst_1)))) -> (forall (x₁ : R) (x₂ : R) (y : R), (p x₁ y) -> (p x₂ y) -> (p (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) x₁ x₂) y)) -> (forall (x : R) (y₁ : R) (y₂ : R), (p x y₁) -> (p x y₂) -> (p x (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) y₁ y₂))) -> (forall (x₁ : R) (x₂ : R) (y : R), (p x₁ y) -> (p x₂ y) -> (p (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) x₁ x₂) y)) -> (forall (x : R) (y₁ : R) (y₂ : R), (p x y₁) -> (p x y₂) -> (p x (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) y₁ y₂))) -> (p x y)\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_induction₂ Subsemiring.closure_induction₂ₓ'. -/\n/-- An induction principle for closure membership for predicates with two arguments. -/\n@[elab_as_elim]\ntheorem closure_induction₂ {s : Set R} {p : R → R → Prop} {x} {y : R} (hx : x ∈ closure s)\n    (hy : y ∈ closure s) (Hs : ∀ x ∈ s, ∀ y ∈ s, p x y) (H0_left : ∀ x, p 0 x)\n    (H0_right : ∀ x, p x 0) (H1_left : ∀ x, p 1 x) (H1_right : ∀ x, p x 1)\n    (Hadd_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y)\n    (Hadd_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂))\n    (Hmul_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ * x₂) y)\n    (Hmul_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ * y₂)) : p x y :=\n  closure_induction hx\n    (fun x₁ x₁s =>\n      closure_induction hy (Hs x₁ x₁s) (H0_right x₁) (H1_right x₁) (Hadd_right x₁) (Hmul_right x₁))\n    (H0_left y) (H1_left y) (fun z z' => Hadd_left z z' y) fun z z' => Hmul_left z z' y\n#align subsemiring.closure_induction₂ Subsemiring.closure_induction₂\n\n/- warning: subsemiring.mem_closure_iff_exists_list -> Subsemiring.mem_closure_iff_exists_list is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] {s : Set.{u1} R} {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.setLike.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x (Subsemiring.closure.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4) s)) (Exists.{succ u1} (List.{u1} (List.{u1} R)) (fun (L : List.{u1} (List.{u1} R)) => And (forall (t : List.{u1} R), (Membership.Mem.{u1, u1} (List.{u1} R) (List.{u1} (List.{u1} R)) (List.hasMem.{u1} (List.{u1} R)) t L) -> (forall (y : R), (Membership.Mem.{u1, u1} R (List.{u1} R) (List.hasMem.{u1} R) y t) -> (Membership.Mem.{u1, u1} R (Set.{u1} R) (Set.hasMem.{u1} R) y s))) (Eq.{succ u1} R (List.sum.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) (List.map.{u1, u1} (List.{u1} R) R (List.prod.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))))) L)) x)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : Semiring.{u1} R] {s : Set.{u1} R} {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)) R (Subsemiring.instSetLikeSubsemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) x (Subsemiring.closure.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4) s)) (Exists.{succ u1} (List.{u1} (List.{u1} R)) (fun (L : List.{u1} (List.{u1} R)) => And (forall (t : List.{u1} R), (Membership.mem.{u1, u1} (List.{u1} R) (List.{u1} (List.{u1} R)) (List.instMembershipList.{u1} (List.{u1} R)) t L) -> (forall (y : R), (Membership.mem.{u1, u1} R (List.{u1} R) (List.instMembershipList.{u1} R) y t) -> (Membership.mem.{u1, u1} R (Set.{u1} R) (Set.instMembershipSet.{u1} R) y s))) (Eq.{succ u1} R (List.sum.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4)))) (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_4)) (List.map.{u1, u1} (List.{u1} R) R (List.prod.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_4))) (Semiring.toOne.{u1} R _inst_4)) L)) x)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_closure_iff_exists_list Subsemiring.mem_closure_iff_exists_listₓ'. -/\ntheorem mem_closure_iff_exists_list {R} [Semiring R] {s : Set R} {x} :\n    x ∈ closure s ↔ ∃ L : List (List R), (∀ t ∈ L, ∀ y ∈ t, y ∈ s) ∧ (L.map List.prod).Sum = x :=\n  ⟨fun hx =>\n    AddSubmonoid.closure_induction (mem_closure_iff.1 hx)\n      (fun x hx =>\n        suffices ∃ t : List R, (∀ y ∈ t, y ∈ s) ∧ t.Prod = x from\n          let ⟨t, ht1, ht2⟩ := this\n          ⟨[t], List.forall_mem_singleton.2 ht1, by\n            rw [List.map_singleton, List.sum_singleton, ht2]⟩\n        Submonoid.closure_induction hx\n          (fun x hx => ⟨[x], List.forall_mem_singleton.2 hx, one_mul x⟩)\n          ⟨[], List.forall_mem_nil _, rfl⟩ fun x y ⟨t, ht1, ht2⟩ ⟨u, hu1, hu2⟩ =>\n          ⟨t ++ u, List.forall_mem_append.2 ⟨ht1, hu1⟩, by rw [List.prod_append, ht2, hu2]⟩)\n      ⟨[], List.forall_mem_nil _, rfl⟩ fun x y ⟨L, HL1, HL2⟩ ⟨M, HM1, HM2⟩ =>\n      ⟨L ++ M, List.forall_mem_append.2 ⟨HL1, HM1⟩, by\n        rw [List.map_append, List.sum_append, HL2, HM2]⟩,\n    fun ⟨L, HL1, HL2⟩ =>\n    HL2 ▸\n      list_sum_mem fun r hr =>\n        let ⟨t, ht1, ht2⟩ := List.mem_map.1 hr\n        ht2 ▸ list_prod_mem _ fun y hy => subset_closure <| HL1 t ht1 y hy⟩\n#align subsemiring.mem_closure_iff_exists_list Subsemiring.mem_closure_iff_exists_list\n\nvariable (R)\n\n/- warning: subsemiring.gi -> Subsemiring.gi is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : NonAssocSemiring.{u1} R], GaloisInsertion.{u1, u1} (Set.{u1} R) (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Set.{u1} R) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} R) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} R) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} R) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} R) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} R) (Set.completeBooleanAlgebra.{u1} R))))))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))) (Subsemiring.closure.{u1} R _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : NonAssocSemiring.{u1} R], GaloisInsertion.{u1, u1} (Set.{u1} R) (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Set.{u1} R) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} R) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} R) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} R) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} R) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} R) (Set.instCompleteBooleanAlgebraSet.{u1} R))))))) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)))) (Subsemiring.closure.{u1} R _inst_1) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align subsemiring.gi Subsemiring.giₓ'. -/\n/-- `closure` forms a Galois insertion with the coercion to set. -/\nprotected def gi : GaloisInsertion (@closure R _) coe\n    where\n  choice s _ := closure s\n  gc s t := closure_le\n  le_l_u s := subset_closure\n  choice_eq s h := rfl\n#align subsemiring.gi Subsemiring.gi\n\nvariable {R}\n\n#print Subsemiring.closure_eq /-\n/-- Closure of a subsemiring `S` equals `S`. -/\ntheorem closure_eq (s : Subsemiring R) : closure (s : Set R) = s :=\n  (Subsemiring.gi R).l_u_eq s\n#align subsemiring.closure_eq Subsemiring.closure_eq\n-/\n\n#print Subsemiring.closure_empty /-\n@[simp]\ntheorem closure_empty : closure (∅ : Set R) = ⊥ :=\n  (Subsemiring.gi R).gc.l_bot\n#align subsemiring.closure_empty Subsemiring.closure_empty\n-/\n\n/- warning: subsemiring.closure_univ -> Subsemiring.closure_univ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 (Set.univ.{u1} R)) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R], Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 (Set.univ.{u1} R)) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_univ Subsemiring.closure_univₓ'. -/\n@[simp]\ntheorem closure_univ : closure (Set.univ : Set R) = ⊤ :=\n  @coe_top R _ ▸ closure_eq ⊤\n#align subsemiring.closure_univ Subsemiring.closure_univ\n\n#print Subsemiring.closure_union /-\ntheorem closure_union (s t : Set R) : closure (s ∪ t) = closure s ⊔ closure t :=\n  (Subsemiring.gi R).gc.l_sup\n#align subsemiring.closure_union Subsemiring.closure_union\n-/\n\n/- warning: subsemiring.closure_Union -> Subsemiring.closure_unionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {ι : Sort.{u2}} (s : ι -> (Set.{u1} R)), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 (Set.unionᵢ.{u1, u2} R ι (fun (i : ι) => s i))) (supᵢ.{u1, u2} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) ι (fun (i : ι) => Subsemiring.closure.{u1} R _inst_1 (s i)))\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_1 : NonAssocSemiring.{u2} R] {ι : Sort.{u1}} (s : ι -> (Set.{u2} R)), Eq.{succ u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.closure.{u2} R _inst_1 (Set.unionᵢ.{u2, u1} R ι (fun (i : ι) => s i))) (supᵢ.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) ι (fun (i : ι) => Subsemiring.closure.{u2} R _inst_1 (s i)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_Union Subsemiring.closure_unionᵢₓ'. -/\ntheorem closure_unionᵢ {ι} (s : ι → Set R) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=\n  (Subsemiring.gi R).gc.l_supᵢ\n#align subsemiring.closure_Union Subsemiring.closure_unionᵢ\n\n/- warning: subsemiring.closure_sUnion -> Subsemiring.closure_unionₛ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Set.{u1} (Set.{u1} R)), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 (Set.unionₛ.{u1} R s)) (supᵢ.{u1, succ u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) (Set.{u1} R) (fun (t : Set.{u1} R) => supᵢ.{u1, 0} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) (Membership.Mem.{u1, u1} (Set.{u1} R) (Set.{u1} (Set.{u1} R)) (Set.hasMem.{u1} (Set.{u1} R)) t s) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} R) (Set.{u1} (Set.{u1} R)) (Set.hasMem.{u1} (Set.{u1} R)) t s) => Subsemiring.closure.{u1} R _inst_1 t)))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Set.{u1} (Set.{u1} R)), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 (Set.unionₛ.{u1} R s)) (supᵢ.{u1, succ u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toSupSet.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)) (Set.{u1} R) (fun (t : Set.{u1} R) => supᵢ.{u1, 0} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toSupSet.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)) (Membership.mem.{u1, u1} (Set.{u1} R) (Set.{u1} (Set.{u1} R)) (Set.instMembershipSet.{u1} (Set.{u1} R)) t s) (fun (H : Membership.mem.{u1, u1} (Set.{u1} R) (Set.{u1} (Set.{u1} R)) (Set.instMembershipSet.{u1} (Set.{u1} R)) t s) => Subsemiring.closure.{u1} R _inst_1 t)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_sUnion Subsemiring.closure_unionₛₓ'. -/\ntheorem closure_unionₛ (s : Set (Set R)) : closure (⋃₀ s) = ⨆ t ∈ s, closure t :=\n  (Subsemiring.gi R).gc.l_supₛ\n#align subsemiring.closure_sUnion Subsemiring.closure_unionₛ\n\n/- warning: subsemiring.map_sup -> Subsemiring.map_sup is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u1} R _inst_1) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f (Sup.sup.{u1} (Subsemiring.{u1} R _inst_1) (SemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (Lattice.toSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toLattice.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1)))) s t)) (Sup.sup.{u2} (Subsemiring.{u2} S _inst_2) (SemilatticeSup.toHasSup.{u2} (Subsemiring.{u2} S _inst_2) (Lattice.toSemilatticeSup.{u2} (Subsemiring.{u2} S _inst_2) (CompleteLattice.toLattice.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.completeLattice.{u2} S _inst_2)))) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f t))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u1} R _inst_1) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f (Sup.sup.{u1} (Subsemiring.{u1} R _inst_1) (SemilatticeSup.toSup.{u1} (Subsemiring.{u1} R _inst_1) (Lattice.toSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toLattice.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)))) s t)) (Sup.sup.{u2} (Subsemiring.{u2} S _inst_2) (SemilatticeSup.toSup.{u2} (Subsemiring.{u2} S _inst_2) (Lattice.toSemilatticeSup.{u2} (Subsemiring.{u2} S _inst_2) (CompleteLattice.toLattice.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instCompleteLatticeSubsemiring.{u2} S _inst_2)))) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f s) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f t))\nCase conversion may be inaccurate. Consider using '#align subsemiring.map_sup Subsemiring.map_supₓ'. -/\ntheorem map_sup (s t : Subsemiring R) (f : R →+* S) : (s ⊔ t).map f = s.map f ⊔ t.map f :=\n  (gc_map_comap f).l_sup\n#align subsemiring.map_sup Subsemiring.map_sup\n\n/- warning: subsemiring.map_supr -> Subsemiring.map_supᵢ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {ι : Sort.{u3}} (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : ι -> (Subsemiring.{u1} R _inst_1)), Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f (supᵢ.{u1, u3} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) ι s)) (supᵢ.{u2, u3} (Subsemiring.{u2} S _inst_2) (CompleteSemilatticeSup.toHasSup.{u2} (Subsemiring.{u2} S _inst_2) (CompleteLattice.toCompleteSemilatticeSup.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.completeLattice.{u2} S _inst_2))) ι (fun (i : ι) => Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 f (s i)))\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u3} S] {ι : Sort.{u1}} (f : RingHom.{u2, u3} R S _inst_1 _inst_2) (s : ι -> (Subsemiring.{u2} R _inst_1)), Eq.{succ u3} (Subsemiring.{u3} S _inst_2) (Subsemiring.map.{u2, u3} R S _inst_1 _inst_2 f (supᵢ.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) ι s)) (supᵢ.{u3, u1} (Subsemiring.{u3} S _inst_2) (CompleteLattice.toSupSet.{u3} (Subsemiring.{u3} S _inst_2) (Subsemiring.instCompleteLatticeSubsemiring.{u3} S _inst_2)) ι (fun (i : ι) => Subsemiring.map.{u2, u3} R S _inst_1 _inst_2 f (s i)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.map_supr Subsemiring.map_supᵢₓ'. -/\ntheorem map_supᵢ {ι : Sort _} (f : R →+* S) (s : ι → Subsemiring R) :\n    (supᵢ s).map f = ⨆ i, (s i).map f :=\n  (gc_map_comap f).l_supᵢ\n#align subsemiring.map_supr Subsemiring.map_supᵢ\n\n/- warning: subsemiring.comap_inf -> Subsemiring.comap_inf is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u2} S _inst_2) (t : Subsemiring.{u2} S _inst_2) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (Inf.inf.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasInf.{u2} S _inst_2) s t)) (Inf.inf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f s) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f t))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u2} S _inst_2) (t : Subsemiring.{u2} S _inst_2) (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (Inf.inf.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instInfSubsemiring.{u2} S _inst_2) s t)) (Inf.inf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instInfSubsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f s) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f t))\nCase conversion may be inaccurate. Consider using '#align subsemiring.comap_inf Subsemiring.comap_infₓ'. -/\ntheorem comap_inf (s t : Subsemiring S) (f : R →+* S) : (s ⊓ t).comap f = s.comap f ⊓ t.comap f :=\n  (gc_map_comap f).u_inf\n#align subsemiring.comap_inf Subsemiring.comap_inf\n\n/- warning: subsemiring.comap_infi -> Subsemiring.comap_infᵢ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {ι : Sort.{u3}} (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : ι -> (Subsemiring.{u2} S _inst_2)), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (infᵢ.{u2, u3} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasInf.{u2} S _inst_2) ι s)) (infᵢ.{u1, u3} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) ι (fun (i : ι) => Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (s i)))\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u3} S] {ι : Sort.{u1}} (f : RingHom.{u2, u3} R S _inst_1 _inst_2) (s : ι -> (Subsemiring.{u3} S _inst_2)), Eq.{succ u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.comap.{u2, u3} R S _inst_1 _inst_2 f (infᵢ.{u3, u1} (Subsemiring.{u3} S _inst_2) (Subsemiring.instInfSetSubsemiring.{u3} S _inst_2) ι s)) (infᵢ.{u2, u1} (Subsemiring.{u2} R _inst_1) (Subsemiring.instInfSetSubsemiring.{u2} R _inst_1) ι (fun (i : ι) => Subsemiring.comap.{u2, u3} R S _inst_1 _inst_2 f (s i)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.comap_infi Subsemiring.comap_infᵢₓ'. -/\ntheorem comap_infᵢ {ι : Sort _} (f : R →+* S) (s : ι → Subsemiring S) :\n    (infᵢ s).comap f = ⨅ i, (s i).comap f :=\n  (gc_map_comap f).u_infᵢ\n#align subsemiring.comap_infi Subsemiring.comap_infᵢ\n\n#print Subsemiring.map_bot /-\n@[simp]\ntheorem map_bot (f : R →+* S) : (⊥ : Subsemiring R).map f = ⊥ :=\n  (gc_map_comap f).l_bot\n#align subsemiring.map_bot Subsemiring.map_bot\n-/\n\n/- warning: subsemiring.comap_top -> Subsemiring.comap_top is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasTop.{u2} S _inst_2))) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instTopSubsemiring.{u2} S _inst_2))) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align subsemiring.comap_top Subsemiring.comap_topₓ'. -/\n@[simp]\ntheorem comap_top (f : R →+* S) : (⊤ : Subsemiring S).comap f = ⊤ :=\n  (gc_map_comap f).u_top\n#align subsemiring.comap_top Subsemiring.comap_top\n\n/- warning: subsemiring.prod -> Subsemiring.prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], (Subsemiring.{u1} R _inst_1) -> (Subsemiring.{u2} S _inst_2) -> (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], (Subsemiring.{u1} R _inst_1) -> (Subsemiring.{u2} S _inst_2) -> (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod Subsemiring.prodₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Given `subsemiring`s `s`, `t` of semirings `R`, `S` respectively, `s.prod t` is `s × t`\nas a subsemiring of `R × S`. -/\ndef prod (s : Subsemiring R) (t : Subsemiring S) : Subsemiring (R × S) :=\n  { s.toSubmonoid.Prod t.toSubmonoid, s.toAddSubmonoid.Prod t.toAddSubmonoid with\n    carrier := s ×ˢ t }\n#align subsemiring.prod Subsemiring.prod\n\n/- warning: subsemiring.coe_prod -> Subsemiring.coe_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u2} S _inst_2), Eq.{succ (max u1 u2)} (Set.{max u1 u2} (Prod.{u1, u2} R S)) ((fun (a : Type.{max u1 u2}) (b : Type.{max u1 u2}) [self : HasLiftT.{succ (max u1 u2), succ (max u1 u2)} a b] => self.0) (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Set.{max u1 u2} (Prod.{u1, u2} R S)) (HasLiftT.mk.{succ (max u1 u2), succ (max u1 u2)} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Set.{max u1 u2} (Prod.{u1, u2} R S)) (CoeTCₓ.coe.{succ (max u1 u2), succ (max u1 u2)} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Set.{max u1 u2} (Prod.{u1, u2} R S)) (SetLike.Set.hasCoeT.{max u1 u2, max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2))))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)) (Set.prod.{u1, u2} R S ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (HasLiftT.mk.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (CoeTCₓ.coe.{succ u2, succ u2} (Subsemiring.{u2} S _inst_2) (Set.{u2} S) (SetLike.Set.hasCoeT.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)))) t))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u2} S _inst_2), Eq.{max (succ u1) (succ u2)} (Set.{max u1 u2} (Prod.{u1, u2} R S)) (SetLike.coe.{max u1 u2, max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.instSetLikeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)) (Set.prod.{u1, u2} R S (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s) (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) t))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_prod Subsemiring.coe_prodₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[norm_cast]\ntheorem coe_prod (s : Subsemiring R) (t : Subsemiring S) : (s.Prod t : Set (R × S)) = s ×ˢ t :=\n  rfl\n#align subsemiring.coe_prod Subsemiring.coe_prod\n\n/- warning: subsemiring.mem_prod -> Subsemiring.mem_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {s : Subsemiring.{u1} R _inst_1} {t : Subsemiring.{u2} S _inst_2} {p : Prod.{u1, u2} R S}, Iff (Membership.Mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (SetLike.hasMem.{max u1 u2, max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2))) p (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)) (And (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) (Prod.fst.{u1, u2} R S p) s) (Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Prod.snd.{u1, u2} R S p) t))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {s : Subsemiring.{u1} R _inst_1} {t : Subsemiring.{u2} S _inst_2} {p : Prod.{u1, u2} R S}, Iff (Membership.mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (SetLike.instMembership.{max u1 u2, max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.instSetLikeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))) p (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)) (And (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) (Prod.fst.{u1, u2} R S p) s) (Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) (Prod.snd.{u1, u2} R S p) t))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_prod Subsemiring.mem_prodₓ'. -/\ntheorem mem_prod {s : Subsemiring R} {t : Subsemiring S} {p : R × S} :\n    p ∈ s.Prod t ↔ p.1 ∈ s ∧ p.2 ∈ t :=\n  Iff.rfl\n#align subsemiring.mem_prod Subsemiring.mem_prod\n\n/- warning: subsemiring.prod_mono -> Subsemiring.prod_mono is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {{s₁ : Subsemiring.{u1} R _inst_1}} {{s₂ : Subsemiring.{u1} R _inst_1}}, (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s₁ s₂) -> (forall {{t₁ : Subsemiring.{u2} S _inst_2}} {{t₂ : Subsemiring.{u2} S _inst_2}}, (LE.le.{u2} (Subsemiring.{u2} S _inst_2) (Preorder.toLE.{u2} (Subsemiring.{u2} S _inst_2) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (SetLike.partialOrder.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)))) t₁ t₂) -> (LE.le.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Preorder.toLE.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (PartialOrder.toPreorder.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (SetLike.partialOrder.{max u1 u2, max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2))))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s₁ t₁) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s₂ t₂)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {{s₁ : Subsemiring.{u1} R _inst_1}} {{s₂ : Subsemiring.{u1} R _inst_1}}, (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) s₁ s₂) -> (forall {{t₁ : Subsemiring.{u2} S _inst_2}} {{t₂ : Subsemiring.{u2} S _inst_2}}, (LE.le.{u2} (Subsemiring.{u2} S _inst_2) (Preorder.toLE.{u2} (Subsemiring.{u2} S _inst_2) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Subsemiring.{u2} S _inst_2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instCompleteLatticeSubsemiring.{u2} S _inst_2))))) t₁ t₂) -> (LE.le.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Preorder.toLE.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (PartialOrder.toPreorder.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.instCompleteLatticeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)))))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s₁ t₁) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s₂ t₂)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_mono Subsemiring.prod_monoₓ'. -/\n@[mono]\ntheorem prod_mono ⦃s₁ s₂ : Subsemiring R⦄ (hs : s₁ ≤ s₂) ⦃t₁ t₂ : Subsemiring S⦄ (ht : t₁ ≤ t₂) :\n    s₁.Prod t₁ ≤ s₂.Prod t₂ :=\n  Set.prod_mono hs ht\n#align subsemiring.prod_mono Subsemiring.prod_mono\n\n/- warning: subsemiring.prod_mono_right -> Subsemiring.prod_mono_right is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1), Monotone.{u2, max u1 u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (SetLike.partialOrder.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2))) (PartialOrder.toPreorder.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (SetLike.partialOrder.{max u1 u2, max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)))) (fun (t : Subsemiring.{u2} S _inst_2) => Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1), Monotone.{u2, max u1 u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} S _inst_2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Subsemiring.{u2} S _inst_2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instCompleteLatticeSubsemiring.{u2} S _inst_2)))) (PartialOrder.toPreorder.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.instCompleteLatticeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))))) (fun (t : Subsemiring.{u2} S _inst_2) => Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_mono_right Subsemiring.prod_mono_rightₓ'. -/\ntheorem prod_mono_right (s : Subsemiring R) : Monotone fun t : Subsemiring S => s.Prod t :=\n  prod_mono (le_refl s)\n#align subsemiring.prod_mono_right Subsemiring.prod_mono_right\n\n/- warning: subsemiring.prod_mono_left -> Subsemiring.prod_mono_left is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (t : Subsemiring.{u2} S _inst_2), Monotone.{u1, max u1 u2} (Subsemiring.{u1} R _inst_1) (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))) (PartialOrder.toPreorder.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (SetLike.partialOrder.{max u1 u2, max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)))) (fun (s : Subsemiring.{u1} R _inst_1) => Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (t : Subsemiring.{u2} S _inst_2), Monotone.{u1, max u1 u2} (Subsemiring.{u1} R _inst_1) (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)))) (PartialOrder.toPreorder.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (CompleteSemilatticeInf.toPartialOrder.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (CompleteLattice.toCompleteSemilatticeInf.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.instCompleteLatticeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))))) (fun (s : Subsemiring.{u1} R _inst_1) => Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_mono_left Subsemiring.prod_mono_leftₓ'. -/\ntheorem prod_mono_left (t : Subsemiring S) : Monotone fun s : Subsemiring R => s.Prod t :=\n  fun s₁ s₂ hs => prod_mono hs (le_refl t)\n#align subsemiring.prod_mono_left Subsemiring.prod_mono_left\n\n/- warning: subsemiring.prod_top -> Subsemiring.prod_top is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1), Eq.{succ (max u1 u2)} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasTop.{u2} S _inst_2))) (Subsemiring.comap.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1 (RingHom.fst.{u1, u2} R S _inst_1 _inst_2) s)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1), Eq.{max (succ u1) (succ u2)} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instTopSubsemiring.{u2} S _inst_2))) (Subsemiring.comap.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_1 (RingHom.fst.{u1, u2} R S _inst_1 _inst_2) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_top Subsemiring.prod_topₓ'. -/\ntheorem prod_top (s : Subsemiring R) : s.Prod (⊤ : Subsemiring S) = s.comap (RingHom.fst R S) :=\n  ext fun x => by simp [mem_prod, MonoidHom.coe_fst]\n#align subsemiring.prod_top Subsemiring.prod_top\n\n/- warning: subsemiring.top_prod -> Subsemiring.top_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u2} S _inst_2), Eq.{succ (max u1 u2)} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1)) s) (Subsemiring.comap.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2 (RingHom.snd.{u1, u2} R S _inst_1 _inst_2) s)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u2} S _inst_2), Eq.{max (succ u1) (succ u2)} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)) s) (Subsemiring.comap.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_2 (RingHom.snd.{u1, u2} R S _inst_1 _inst_2) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.top_prod Subsemiring.top_prodₓ'. -/\ntheorem top_prod (s : Subsemiring S) : (⊤ : Subsemiring R).Prod s = s.comap (RingHom.snd R S) :=\n  ext fun x => by simp [mem_prod, MonoidHom.coe_snd]\n#align subsemiring.top_prod Subsemiring.top_prod\n\n/- warning: subsemiring.top_prod_top -> Subsemiring.top_prod_top is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{succ (max u1 u2)} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1)) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasTop.{u2} S _inst_2))) (Top.top.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.hasTop.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{max (succ u1) (succ u2)} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instTopSubsemiring.{u2} S _inst_2))) (Top.top.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.instTopSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.top_prod_top Subsemiring.top_prod_topₓ'. -/\n@[simp]\ntheorem top_prod_top : (⊤ : Subsemiring R).Prod (⊤ : Subsemiring S) = ⊤ :=\n  (top_prod _).trans <| comap_top _\n#align subsemiring.top_prod_top Subsemiring.top_prod_top\n\n/- warning: subsemiring.prod_equiv -> Subsemiring.prodEquiv is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u2} S _inst_2), RingEquiv.{max u1 u2, max u1 u2} (coeSort.{succ (max u1 u2), succ (succ (max u1 u2))} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) Type.{max u1 u2} (SetLike.hasCoeToSort.{max u1 u2, max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)) (Prod.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) t)) (MulMemClass.mul.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (MulOneClass.toHasMul.{max u1 u2} (Prod.{u1, u2} R S) (MulZeroOneClass.toMulOneClass.{max u1 u2} (Prod.{u1, u2} R S) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)))) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prodEquiv._proof_1.{u1, u2} R S _inst_1 _inst_2) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)) (AddMemClass.add.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (AddZeroClass.toHasAdd.{max u1 u2} (Prod.{u1, u2} R S) (AddMonoid.toAddZeroClass.{max u1 u2} (Prod.{u1, u2} R S) (AddMonoidWithOne.toAddMonoid.{max u1 u2} (Prod.{u1, u2} R S) (AddCommMonoidWithOne.toAddMonoidWithOne.{max u1 u2} (Prod.{u1, u2} R S) (NonAssocSemiring.toAddCommMonoidWithOne.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)))))) (Subsemiring.setLike.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.prodEquiv._proof_2.{u1, u2} R S _inst_1 _inst_2) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)) (Prod.hasMul.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) t) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.prodEquiv._proof_3.{u1} R _inst_1) s) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.prodEquiv._proof_4.{u2} S _inst_2) t)) (Prod.hasAdd.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) t) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (Subsemiring.prodEquiv._proof_5.{u1} R _inst_1) s) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (Subsemiring.prodEquiv._proof_6.{u2} S _inst_2) t))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u2} S _inst_2), RingEquiv.{max u1 u2, max u2 u1} (Subtype.{succ (max u1 u2)} (Prod.{u1, u2} R S) (fun (x : Prod.{u1, u2} R S) => Membership.mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (SetLike.instMembership.{max u1 u2, max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.instSetLikeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))) x (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t))) (Prod.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x t))) (Submonoid.mul.{max u1 u2} (Prod.{u1, u2} R S) (MulZeroOneClass.toMulOneClass.{max u1 u2} (Prod.{u1, u2} R S) (NonAssocSemiring.toMulZeroOneClass.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))) (Subsemiring.toSubmonoid.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t))) (Prod.instMulProd.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x t)) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 t))) (Distrib.toAdd.{max u1 u2} (Subtype.{succ (max u1 u2)} (Prod.{u1, u2} R S) (fun (x : Prod.{u1, u2} R S) => Membership.mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (SetLike.instMembership.{max u1 u2, max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.instSetLikeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))) x (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t))) (NonUnitalNonAssocSemiring.toDistrib.{max u1 u2} (Subtype.{succ (max u1 u2)} (Prod.{u1, u2} R S) (fun (x : Prod.{u1, u2} R S) => Membership.mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (SetLike.instMembership.{max u1 u2, max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.instSetLikeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))) x (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u2} (Subtype.{succ (max u1 u2)} (Prod.{u1, u2} R S) (fun (x : Prod.{u1, u2} R S) => Membership.mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} R S) (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (SetLike.instMembership.{max u1 u2, max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Prod.{u1, u2} R S) (Subsemiring.instSetLikeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))) x (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t))) (Subsemiring.toNonAssocSemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t))))) (Prod.instAddSum.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x t)) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x t)) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x t)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x t)) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 t)))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_equiv Subsemiring.prodEquivₓ'. -/\n/-- Product of subsemirings is isomorphic to their product as monoids. -/\ndef prodEquiv (s : Subsemiring R) (t : Subsemiring S) : s.Prod t ≃+* s × t :=\n  { Equiv.Set.prod ↑s ↑t with\n    map_mul' := fun x y => rfl\n    map_add' := fun x y => rfl }\n#align subsemiring.prod_equiv Subsemiring.prodEquiv\n\n/- warning: subsemiring.mem_supr_of_directed -> Subsemiring.mem_supᵢ_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {ι : Sort.{u2}} [hι : Nonempty.{u2} ι] {S : ι -> (Subsemiring.{u1} R _inst_1)}, (Directed.{u1, u2} (Subsemiring.{u1} R _inst_1) ι (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))))) S) -> (forall {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (supᵢ.{u1, u2} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) ι (fun (i : ι) => S i))) (Exists.{u2} ι (fun (i : ι) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (S i))))\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_1 : NonAssocSemiring.{u2} R] {ι : Sort.{u1}} [hι : Nonempty.{u1} ι] {S : ι -> (Subsemiring.{u2} R _inst_1)}, (Directed.{u2, u1} (Subsemiring.{u2} R _inst_1) ι (fun (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.9727 : Subsemiring.{u2} R _inst_1) (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.9729 : Subsemiring.{u2} R _inst_1) => LE.le.{u2} (Subsemiring.{u2} R _inst_1) (Preorder.toLE.{u2} (Subsemiring.{u2} R _inst_1) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1))))) x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.9727 x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.9729) S) -> (forall {x : R}, Iff (Membership.mem.{u2, u2} R (Subsemiring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u2} R _inst_1)) x (supᵢ.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) ι (fun (i : ι) => S i))) (Exists.{u1} ι (fun (i : ι) => Membership.mem.{u2, u2} R (Subsemiring.{u2} R _inst_1) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u2} R _inst_1)) x (S i))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_supr_of_directed Subsemiring.mem_supᵢ_of_directedₓ'. -/\ntheorem mem_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → Subsemiring R} (hS : Directed (· ≤ ·) S)\n    {x : R} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i :=\n  by\n  refine' ⟨_, fun ⟨i, hi⟩ => (SetLike.le_def.1 <| le_supᵢ S i) hi⟩\n  let U : Subsemiring R :=\n    Subsemiring.mk' (⋃ i, (S i : Set R)) (⨆ i, (S i).toSubmonoid)\n      (Submonoid.coe_supᵢ_of_directed <| hS.mono_comp _ fun _ _ => id) (⨆ i, (S i).toAddSubmonoid)\n      (AddSubmonoid.coe_supᵢ_of_directed <| hS.mono_comp _ fun _ _ => id)\n  suffices (⨆ i, S i) ≤ U by simpa using @this x\n  exact supᵢ_le fun i x hx => Set.mem_unionᵢ.2 ⟨i, hx⟩\n#align subsemiring.mem_supr_of_directed Subsemiring.mem_supᵢ_of_directed\n\n/- warning: subsemiring.coe_supr_of_directed -> Subsemiring.coe_supᵢ_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {ι : Sort.{u2}} [hι : Nonempty.{u2} ι] {S : ι -> (Subsemiring.{u1} R _inst_1)}, (Directed.{u1, u2} (Subsemiring.{u1} R _inst_1) ι (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))))) S) -> (Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (supᵢ.{u1, u2} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) ι (fun (i : ι) => S i))) (Set.unionᵢ.{u1, u2} R ι (fun (i : ι) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (S i))))\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_1 : NonAssocSemiring.{u2} R] {ι : Sort.{u1}} [hι : Nonempty.{u1} ι] {S : ι -> (Subsemiring.{u2} R _inst_1)}, (Directed.{u2, u1} (Subsemiring.{u2} R _inst_1) ι (fun (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10015 : Subsemiring.{u2} R _inst_1) (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10017 : Subsemiring.{u2} R _inst_1) => LE.le.{u2} (Subsemiring.{u2} R _inst_1) (Preorder.toLE.{u2} (Subsemiring.{u2} R _inst_1) (PartialOrder.toPreorder.{u2} (Subsemiring.{u2} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1))))) x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10015 x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10017) S) -> (Eq.{succ u2} (Set.{u2} R) (SetLike.coe.{u2, u2} (Subsemiring.{u2} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u2} R _inst_1) (supᵢ.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) ι (fun (i : ι) => S i))) (Set.unionᵢ.{u2, u1} R ι (fun (i : ι) => SetLike.coe.{u2, u2} (Subsemiring.{u2} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u2} R _inst_1) (S i))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_supr_of_directed Subsemiring.coe_supᵢ_of_directedₓ'. -/\ntheorem coe_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → Subsemiring R}\n    (hS : Directed (· ≤ ·) S) : ((⨆ i, S i : Subsemiring R) : Set R) = ⋃ i, ↑(S i) :=\n  Set.ext fun x => by simp [mem_supr_of_directed hS]\n#align subsemiring.coe_supr_of_directed Subsemiring.coe_supᵢ_of_directed\n\n/- warning: subsemiring.mem_Sup_of_directed_on -> Subsemiring.mem_supₛ_of_directedOn is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Set.{u1} (Subsemiring.{u1} R _inst_1)}, (Set.Nonempty.{u1} (Subsemiring.{u1} R _inst_1) S) -> (DirectedOn.{u1} (Subsemiring.{u1} R _inst_1) (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))))) S) -> (forall {x : R}, Iff (Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x (SupSet.supₛ.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) S)) (Exists.{succ u1} (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Exists.{0} (Membership.Mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.hasMem.{u1} (Subsemiring.{u1} R _inst_1)) s S) (fun (H : Membership.Mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.hasMem.{u1} (Subsemiring.{u1} R _inst_1)) s S) => Membership.Mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) x s))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Set.{u1} (Subsemiring.{u1} R _inst_1)}, (Set.Nonempty.{u1} (Subsemiring.{u1} R _inst_1) S) -> (DirectedOn.{u1} (Subsemiring.{u1} R _inst_1) (fun (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10112 : Subsemiring.{u1} R _inst_1) (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10114 : Subsemiring.{u1} R _inst_1) => LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10112 x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10114) S) -> (forall {x : R}, Iff (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x (SupSet.supₛ.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toSupSet.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)) S)) (Exists.{succ u1} (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => And (Membership.mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.instMembershipSet.{u1} (Subsemiring.{u1} R _inst_1)) s S) (Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.mem_Sup_of_directed_on Subsemiring.mem_supₛ_of_directedOnₓ'. -/\ntheorem mem_supₛ_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (· ≤ ·) S) {x : R} : x ∈ supₛ S ↔ ∃ s ∈ S, x ∈ s :=\n  by\n  haveI : Nonempty S := Sne.to_subtype\n  simp only [supₛ_eq_supᵢ', mem_supr_of_directed hS.directed_coe, SetCoe.exists, Subtype.coe_mk]\n#align subsemiring.mem_Sup_of_directed_on Subsemiring.mem_supₛ_of_directedOn\n\n/- warning: subsemiring.coe_Sup_of_directed_on -> Subsemiring.coe_supₛ_of_directedOn is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Set.{u1} (Subsemiring.{u1} R _inst_1)}, (Set.Nonempty.{u1} (Subsemiring.{u1} R _inst_1) S) -> (DirectedOn.{u1} (Subsemiring.{u1} R _inst_1) (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1))))) S) -> (Eq.{succ u1} (Set.{u1} R) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (SupSet.supₛ.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeSup.toHasSup.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeSup.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.completeLattice.{u1} R _inst_1))) S)) (Set.unionᵢ.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.unionᵢ.{u1, 0} R (Membership.Mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.hasMem.{u1} (Subsemiring.{u1} R _inst_1)) s S) (fun (H : Membership.Mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.hasMem.{u1} (Subsemiring.{u1} R _inst_1)) s S) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) s))))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Set.{u1} (Subsemiring.{u1} R _inst_1)}, (Set.Nonempty.{u1} (Subsemiring.{u1} R _inst_1) S) -> (DirectedOn.{u1} (Subsemiring.{u1} R _inst_1) (fun (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10209 : Subsemiring.{u1} R _inst_1) (x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10211 : Subsemiring.{u1} R _inst_1) => LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10209 x._@.Mathlib.RingTheory.Subsemiring.Basic._hyg.10211) S) -> (Eq.{succ u1} (Set.{u1} R) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (SupSet.supₛ.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toSupSet.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)) S)) (Set.unionᵢ.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.unionᵢ.{u1, 0} R (Membership.mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.instMembershipSet.{u1} (Subsemiring.{u1} R _inst_1)) s S) (fun (H : Membership.mem.{u1, u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} (Subsemiring.{u1} R _inst_1)) (Set.instMembershipSet.{u1} (Subsemiring.{u1} R _inst_1)) s S) => SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) s))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.coe_Sup_of_directed_on Subsemiring.coe_supₛ_of_directedOnₓ'. -/\ntheorem coe_supₛ_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (· ≤ ·) S) : (↑(supₛ S) : Set R) = ⋃ s ∈ S, ↑s :=\n  Set.ext fun x => by simp [mem_Sup_of_directed_on Sne hS]\n#align subsemiring.coe_Sup_of_directed_on Subsemiring.coe_supₛ_of_directedOn\n\nend Subsemiring\n\nnamespace RingHom\n\nvariable [NonAssocSemiring T] {s : Subsemiring R}\n\nvariable {σR σS : Type _}\n\nvariable [SetLike σR R] [SetLike σS S] [SubsemiringClass σR R] [SubsemiringClass σS S]\n\nopen Subsemiring\n\n#print RingHom.domRestrict /-\n/-- Restriction of a ring homomorphism to a subsemiring of the domain. -/\ndef domRestrict (f : R →+* S) (s : σR) : s →+* S :=\n  f.comp <| SubsemiringClass.subtype s\n#align ring_hom.dom_restrict RingHom.domRestrict\n-/\n\n/- warning: ring_hom.restrict_apply -> RingHom.restrict_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {σR : Type.{u3}} [_inst_5 : SetLike.{u3, u1} σR R] [_inst_7 : SubsemiringClass.{u1, u3} σR R _inst_1 _inst_5] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) {s : σR} (x : coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s), Eq.{succ u2} S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s) _inst_2) (fun (_x : RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s) _inst_2) => (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) -> S) (RingHom.hasCoeToFun.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s) _inst_2) (RingHom.domRestrict.{u1, u2, u3} R S _inst_1 _inst_2 σR _inst_5 _inst_7 f s) x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u3} R σR (SetLike.hasMem.{u3, u1} σR R _inst_5) x s))))) x))\nbut is expected to have type\n  forall {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} R] [_inst_2 : NonAssocSemiring.{u3} S] {σR : Type.{u1}} [_inst_5 : SetLike.{u1, u2} σR R] [_inst_7 : SubsemiringClass.{u2, u1} σR R _inst_1 _inst_5] (f : RingHom.{u2, u3} R S _inst_1 _inst_2) {s : σR} (x : Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) => S) x) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) (fun (_x : Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) => S) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (NonUnitalNonAssocSemiring.toMul.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s))) (NonUnitalNonAssocSemiring.toMul.{u3} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s) _inst_2 (RingHom.instRingHomClassRingHom.{u2, u3} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R σR (SetLike.instMembership.{u1, u2} σR R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R σR _inst_1 _inst_5 _inst_7 s) _inst_2)))) (RingHom.domRestrict.{u2, u3, u1} R S _inst_1 _inst_2 σR _inst_5 _inst_7 f s) x) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u3} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u2, u3} R S _inst_1 _inst_2)))) f (Subtype.val.{succ u2} R (fun (x : R) => Membership.mem.{u2, u2} R (Set.{u2} R) (Set.instMembershipSet.{u2} R) x (SetLike.coe.{u1, u2} σR R _inst_5 s)) x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.restrict_apply RingHom.restrict_applyₓ'. -/\n@[simp]\ntheorem restrict_apply (f : R →+* S) {s : σR} (x : s) : f.domRestrict s x = f x :=\n  rfl\n#align ring_hom.restrict_apply RingHom.restrict_apply\n\n/- warning: ring_hom.cod_restrict -> RingHom.codRestrict is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {σS : Type.{u3}} [_inst_6 : SetLike.{u3, u2} σS S] [_inst_8 : SubsemiringClass.{u2, u3} σS S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : σS), (forall (x : R), Membership.Mem.{u2, u3} S σS (SetLike.hasMem.{u3, u2} σS S _inst_6) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) s) -> (RingHom.{u1, u2} R (coeSort.{succ u3, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u3, u2} σS S _inst_6) s) _inst_1 (SubsemiringClass.toNonAssocSemiring.{u2, u3} S σS _inst_2 _inst_6 _inst_8 s))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {σS : Type.{u3}} [_inst_6 : SetLike.{u3, u2} σS S] [_inst_8 : SubsemiringClass.{u2, u3} σS S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : σS), (forall (x : R), Membership.mem.{u2, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) σS (SetLike.instMembership.{u3, u2} σS S _inst_6) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x) s) -> (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u3} S σS (SetLike.instMembership.{u3, u2} σS S _inst_6) x s)) _inst_1 (SubsemiringClass.toNonAssocSemiring.{u2, u3} S σS _inst_2 _inst_6 _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align ring_hom.cod_restrict RingHom.codRestrictₓ'. -/\n/-- Restriction of a ring homomorphism to a subsemiring of the codomain. -/\ndef codRestrict (f : R →+* S) (s : σS) (h : ∀ x, f x ∈ s) : R →+* s :=\n  { (f : R →* S).codRestrict s h, (f : R →+ S).codRestrict s h with toFun := fun n => ⟨f n, h n⟩ }\n#align ring_hom.cod_restrict RingHom.codRestrict\n\n/- warning: ring_hom.restrict -> RingHom.restrict is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {σR : Type.{u3}} {σS : Type.{u4}} [_inst_5 : SetLike.{u3, u1} σR R] [_inst_6 : SetLike.{u4, u2} σS S] [_inst_7 : SubsemiringClass.{u1, u3} σR R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} σS S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : σR) (s : σS), (forall (x : R), (Membership.Mem.{u1, u3} R σR (SetLike.hasMem.{u3, u1} σR R _inst_5) x s') -> (Membership.Mem.{u2, u4} S σS (SetLike.hasMem.{u4, u2} σS S _inst_6) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) s)) -> (RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S σS _inst_2 _inst_6 _inst_8 s))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {σR : Type.{u3}} {σS : Type.{u4}} [_inst_5 : SetLike.{u3, u1} σR R] [_inst_6 : SetLike.{u4, u2} σS S] [_inst_7 : SubsemiringClass.{u1, u3} σR R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} σS S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : σR) (s : σS), (forall (x : R), (Membership.mem.{u1, u3} R σR (SetLike.instMembership.{u3, u1} σR R _inst_5) x s') -> (Membership.mem.{u2, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) σS (SetLike.instMembership.{u4, u2} σS S _inst_6) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x) s)) -> (RingHom.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u3} R σR (SetLike.instMembership.{u3, u1} σR R _inst_5) x s')) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u4} S σS (SetLike.instMembership.{u4, u2} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S σS _inst_2 _inst_6 _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align ring_hom.restrict RingHom.restrictₓ'. -/\n/-- The ring homomorphism from the preimage of `s` to `s`. -/\ndef restrict (f : R →+* S) (s' : σR) (s : σS) (h : ∀ x ∈ s', f x ∈ s) : s' →+* s :=\n  (f.domRestrict s').codRestrict s fun x => h x x.2\n#align ring_hom.restrict RingHom.restrict\n\n/- warning: ring_hom.coe_restrict_apply -> RingHom.coe_restrict_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {σR : Type.{u3}} {σS : Type.{u4}} [_inst_5 : SetLike.{u3, u1} σR R] [_inst_6 : SetLike.{u4, u2} σS S] [_inst_7 : SubsemiringClass.{u1, u3} σR R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} σS S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : σR) (s : σS) (h : forall (x : R), (Membership.Mem.{u1, u3} R σR (SetLike.hasMem.{u3, u1} σR R _inst_5) x s') -> (Membership.Mem.{u2, u4} S σS (SetLike.hasMem.{u4, u2} σS S _inst_6) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) s)) (x : coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s'), Eq.{succ u2} S ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) S (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) S (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) S (coeBase.{succ u2, succ u2} (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) S (coeSubtype.{succ u2} S (fun (x : S) => Membership.Mem.{u2, u4} S σS (SetLike.hasMem.{u4, u2} σS S _inst_6) x s))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S σS _inst_2 _inst_6 _inst_8 s)) (fun (_x : RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S σS _inst_2 _inst_6 _inst_8 s)) => (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') -> (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s)) (RingHom.hasCoeToFun.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S σS _inst_2 _inst_6 _inst_8 s)) (RingHom.restrict.{u1, u2, u3, u4} R S _inst_1 _inst_2 σR σS _inst_5 _inst_6 _inst_7 _inst_8 f s' s h) x)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') R (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') R (coeBase.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u3} R σR (SetLike.hasMem.{u3, u1} σR R _inst_5) x s'))))) x))\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u4}} [_inst_1 : NonAssocSemiring.{u3} R] [_inst_2 : NonAssocSemiring.{u4} S] {σR : Type.{u2}} {σS : Type.{u1}} [_inst_5 : SetLike.{u2, u3} σR R] [_inst_6 : SetLike.{u1, u4} σS S] [_inst_7 : SubsemiringClass.{u3, u2} σR R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u4, u1} σS S _inst_2 _inst_6] (f : RingHom.{u3, u4} R S _inst_1 _inst_2) (s' : σR) (s : σS) (h : forall (x : R), (Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s') -> (Membership.mem.{u4, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) σS (SetLike.instMembership.{u1, u4} σS S _inst_6) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u4} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u3, u4} R S _inst_1 _inst_2)))) f x) s)) (x : Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')), Eq.{succ u4} S (Subtype.val.{succ u4} S (fun (x : S) => Membership.mem.{u4, u4} S (Set.{u4} S) (Set.instMembershipSet.{u4} S) x (SetLike.coe.{u1, u4} σS S _inst_6 s)) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (RingHom.{u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (fun (_x : Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) => Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) _x) (MulHomClass.toFunLike.{max u3 u4, u3, u4} (RingHom.{u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (NonUnitalNonAssocSemiring.toMul.{u3} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s'))) (NonUnitalNonAssocSemiring.toMul.{u4} (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s')) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s)) (RingHomClass.toNonUnitalRingHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s) (RingHom.instRingHomClassRingHom.{u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s))))) (RingHom.restrict.{u3, u4, u2, u1} R S _inst_1 _inst_2 σR σS _inst_5 _inst_6 _inst_7 _inst_8 f s' s h) x)) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u4} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u3, u4} R S _inst_1 _inst_2)))) f (Subtype.val.{succ u3} R (fun (x : R) => Membership.mem.{u3, u3} R (Set.{u3} R) (Set.instMembershipSet.{u3} R) x (SetLike.coe.{u2, u3} σR R _inst_5 s')) x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_restrict_apply RingHom.coe_restrict_applyₓ'. -/\n@[simp]\ntheorem coe_restrict_apply (f : R →+* S) (s' : σR) (s : σS) (h : ∀ x ∈ s', f x ∈ s) (x : s') :\n    (f.restrict s' s h x : S) = f x :=\n  rfl\n#align ring_hom.coe_restrict_apply RingHom.coe_restrict_apply\n\n/- warning: ring_hom.comp_restrict -> RingHom.comp_restrict is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {σR : Type.{u3}} {σS : Type.{u4}} [_inst_5 : SetLike.{u3, u1} σR R] [_inst_6 : SetLike.{u4, u2} σS S] [_inst_7 : SubsemiringClass.{u1, u3} σR R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} σS S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : σR) (s : σS) (h : forall (x : R), (Membership.Mem.{u1, u3} R σR (SetLike.hasMem.{u3, u1} σR R _inst_5) x s') -> (Membership.Mem.{u2, u4} S σS (SetLike.hasMem.{u4, u2} σS S _inst_6) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x) s)), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') _inst_2) (RingHom.comp.{u1, u2, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} σS Type.{u2} (SetLike.hasCoeToSort.{u4, u2} σS S _inst_6) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S σS _inst_2 _inst_6 _inst_8 s) _inst_2 (SubsemiringClass.subtype.{u2, u4} S σS _inst_2 _inst_6 _inst_8 s) (RingHom.restrict.{u1, u2, u3, u4} R S _inst_1 _inst_2 σR σS _inst_5 _inst_6 _inst_7 _inst_8 f s' s h)) (RingHom.comp.{u1, u1, u2} (coeSort.{succ u3, succ (succ u1)} σR Type.{u1} (SetLike.hasCoeToSort.{u3, u1} σR R _inst_5) s') R S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s') _inst_1 _inst_2 f (SubsemiringClass.subtype.{u1, u3} R σR _inst_1 _inst_5 _inst_7 s'))\nbut is expected to have type\n  forall {R : Type.{u3}} {S : Type.{u4}} [_inst_1 : NonAssocSemiring.{u3} R] [_inst_2 : NonAssocSemiring.{u4} S] {σR : Type.{u2}} {σS : Type.{u1}} [_inst_5 : SetLike.{u2, u3} σR R] [_inst_6 : SetLike.{u1, u4} σS S] [_inst_7 : SubsemiringClass.{u3, u2} σR R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u4, u1} σS S _inst_2 _inst_6] (f : RingHom.{u3, u4} R S _inst_1 _inst_2) (s' : σR) (s : σS) (h : forall (x : R), (Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s') -> (Membership.mem.{u4, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) σS (SetLike.instMembership.{u1, u4} σS S _inst_6) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u4} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u3 u4, u3, u4} (RingHom.{u3, u4} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u3, u4} R S _inst_1 _inst_2)))) f x) s)), Eq.{max (succ u3) (succ u4)} (RingHom.{u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) S (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') _inst_2) (RingHom.comp.{u3, u4, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S σS (SetLike.instMembership.{u1, u4} σS S _inst_6) x s)) S (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s) _inst_2 (SubsemiringClass.subtype.{u4, u1} S σS _inst_2 _inst_6 _inst_8 s) (RingHom.restrict.{u3, u4, u2, u1} R S _inst_1 _inst_2 σR σS _inst_5 _inst_6 _inst_7 _inst_8 f s' s h)) (RingHom.comp.{u3, u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R σR (SetLike.instMembership.{u2, u3} σR R _inst_5) x s')) R S (SubsemiringClass.toNonAssocSemiring.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s') _inst_1 _inst_2 f (SubsemiringClass.subtype.{u3, u2} R σR _inst_1 _inst_5 _inst_7 s'))\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_restrict RingHom.comp_restrictₓ'. -/\n@[simp]\ntheorem comp_restrict (f : R →+* S) (s' : σR) (s : σS) (h : ∀ x ∈ s', f x ∈ s) :\n    (SubsemiringClass.subtype s).comp (f.restrict s' s h) = f.comp (SubsemiringClass.subtype s') :=\n  rfl\n#align ring_hom.comp_restrict RingHom.comp_restrict\n\n/- warning: ring_hom.srange_restrict -> RingHom.rangeSRestrict is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), RingHom.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))\nCase conversion may be inaccurate. Consider using '#align ring_hom.srange_restrict RingHom.rangeSRestrictₓ'. -/\n/-- Restriction of a ring homomorphism to its range interpreted as a subsemiring.\n\nThis is the bundled version of `set.range_factorization`. -/\ndef rangeSRestrict (f : R →+* S) : R →+* f.srange :=\n  f.codRestrict f.srange f.mem_rangeS_self\n#align ring_hom.srange_restrict RingHom.rangeSRestrict\n\n/- warning: ring_hom.coe_srange_restrict -> RingHom.coe_rangeSRestrict is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (x : R), Eq.{succ u2} S ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (coeSubtype.{succ u2} S (fun (x : S) => Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (fun (_x : RingHom.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) => R -> (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingHom.hasCoeToFun.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingHom.rangeSRestrict.{u1, u2} R S _inst_1 _inst_2 f) x)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (x : R), Eq.{succ u2} S (Subtype.val.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Set.{u2} S) (Set.instMembershipSet.{u2} S) x (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (RingHom.instRingHomClassRingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) (RingHom.rangeSRestrict.{u1, u2} R S _inst_1 _inst_2 f) x)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_srange_restrict RingHom.coe_rangeSRestrictₓ'. -/\n@[simp]\ntheorem coe_rangeSRestrict (f : R →+* S) (x : R) : (f.srangeRestrict x : S) = f x :=\n  rfl\n#align ring_hom.coe_srange_restrict RingHom.coe_rangeSRestrict\n\n/- warning: ring_hom.srange_restrict_surjective -> RingHom.rangeSRestrict_surjective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Function.Surjective.{succ u1, succ u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (fun (_x : RingHom.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) => R -> (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingHom.hasCoeToFun.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingHom.rangeSRestrict.{u1, u2} R S _inst_1 _inst_2 f))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Function.Surjective.{succ u1, succ u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (RingHom.instRingHomClassRingHom.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _inst_1 (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) (RingHom.rangeSRestrict.{u1, u2} R S _inst_1 _inst_2 f))\nCase conversion may be inaccurate. Consider using '#align ring_hom.srange_restrict_surjective RingHom.rangeSRestrict_surjectiveₓ'. -/\ntheorem rangeSRestrict_surjective (f : R →+* S) : Function.Surjective f.srangeRestrict :=\n  fun ⟨y, hy⟩ =>\n  let ⟨x, hx⟩ := mem_rangeS.mp hy\n  ⟨x, Subtype.ext hx⟩\n#align ring_hom.srange_restrict_surjective RingHom.rangeSRestrict_surjective\n\n/- warning: ring_hom.srange_top_iff_surjective -> RingHom.rangeS_top_iff_surjective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2}, Iff (Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasTop.{u2} S _inst_2))) (Function.Surjective.{succ u1, succ u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2}, Iff (Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instTopSubsemiring.{u2} S _inst_2))) (Function.Surjective.{succ u1, succ u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f))\nCase conversion may be inaccurate. Consider using '#align ring_hom.srange_top_iff_surjective RingHom.rangeS_top_iff_surjectiveₓ'. -/\ntheorem rangeS_top_iff_surjective {f : R →+* S} :\n    f.srange = (⊤ : Subsemiring S) ↔ Function.Surjective f :=\n  SetLike.ext'_iff.trans <| Iff.trans (by rw [coe_srange, coe_top]) Set.range_iff_surjective\n#align ring_hom.srange_top_iff_surjective RingHom.rangeS_top_iff_surjective\n\n/- warning: ring_hom.srange_top_of_surjective -> RingHom.rangeS_top_of_surjective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), (Function.Surjective.{succ u1, succ u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f)) -> (Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasTop.{u2} S _inst_2)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), (Function.Surjective.{succ u1, succ u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f)) -> (Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instTopSubsemiring.{u2} S _inst_2)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.srange_top_of_surjective RingHom.rangeS_top_of_surjectiveₓ'. -/\n/-- The range of a surjective ring homomorphism is the whole of the codomain. -/\ntheorem rangeS_top_of_surjective (f : R →+* S) (hf : Function.Surjective f) :\n    f.srange = (⊤ : Subsemiring S) :=\n  rangeS_top_iff_surjective.2 hf\n#align ring_hom.srange_top_of_surjective RingHom.rangeS_top_of_surjective\n\n#print RingHom.eqLocusS /-\n/-- The subsemiring of elements `x : R` such that `f x = g x` -/\ndef eqLocusS (f g : R →+* S) : Subsemiring R :=\n  { (f : R →* S).eqLocus g, (f : R →+ S).eqLocus g with carrier := { x | f x = g x } }\n#align ring_hom.eq_slocus RingHom.eqLocusS\n-/\n\n/- warning: ring_hom.eq_slocus_same -> RingHom.eqLocusS_same is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (RingHom.eqLocusS.{u1, u2} R S _inst_1 _inst_2 f f) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (RingHom.eqLocusS.{u1, u2} R S _inst_1 _inst_2 f f) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align ring_hom.eq_slocus_same RingHom.eqLocusS_sameₓ'. -/\n@[simp]\ntheorem eqLocusS_same (f : R →+* S) : f.eqLocusS f = ⊤ :=\n  SetLike.ext fun _ => eq_self_iff_true _\n#align ring_hom.eq_slocus_same RingHom.eqLocusS_same\n\n/- warning: ring_hom.eq_on_sclosure -> RingHom.eqOn_sclosure is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {g : RingHom.{u1, u2} R S _inst_1 _inst_2} {s : Set.{u1} R}, (Set.EqOn.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) g) s) -> (Set.EqOn.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) g) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.closure.{u1} R _inst_1 s)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {g : RingHom.{u1, u2} R S _inst_1 _inst_2} {s : Set.{u1} R}, (Set.EqOn.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) g) s) -> (Set.EqOn.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) g) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 s)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.eq_on_sclosure RingHom.eqOn_sclosureₓ'. -/\n/-- If two ring homomorphisms are equal on a set, then they are equal on its subsemiring closure. -/\ntheorem eqOn_sclosure {f g : R →+* S} {s : Set R} (h : Set.EqOn f g s) : Set.EqOn f g (closure s) :=\n  show closure s ≤ f.eqLocusS g from closure_le.2 h\n#align ring_hom.eq_on_sclosure RingHom.eqOn_sclosure\n\n/- warning: ring_hom.eq_of_eq_on_stop -> RingHom.eq_of_eqOn_stop is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {g : RingHom.{u1, u2} R S _inst_1 _inst_2}, (Set.EqOn.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) g) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (HasLiftT.mk.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (CoeTCₓ.coe.{succ u1, succ u1} (Subsemiring.{u1} R _inst_1) (Set.{u1} R) (SetLike.Set.hasCoeT.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1)))) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {g : RingHom.{u1, u2} R S _inst_1 _inst_2}, (Set.EqOn.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) g) (SetLike.coe.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1)))) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.eq_of_eq_on_stop RingHom.eq_of_eqOn_stopₓ'. -/\ntheorem eq_of_eqOn_stop {f g : R →+* S} (h : Set.EqOn f g (⊤ : Subsemiring R)) : f = g :=\n  ext fun x => h trivial\n#align ring_hom.eq_of_eq_on_stop RingHom.eq_of_eqOn_stop\n\n/- warning: ring_hom.eq_of_eq_on_sdense -> RingHom.eq_of_eqOn_sdense is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {s : Set.{u1} R}, (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 s) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))) -> (forall {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {g : RingHom.{u1, u2} R S _inst_1 _inst_2}, (Set.EqOn.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) g) s) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) f g))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {s : Set.{u1} R}, (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 s) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))) -> (forall {f : RingHom.{u1, u2} R S _inst_1 _inst_2} {g : RingHom.{u1, u2} R S _inst_1 _inst_2}, (Set.EqOn.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) g) s) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) f g))\nCase conversion may be inaccurate. Consider using '#align ring_hom.eq_of_eq_on_sdense RingHom.eq_of_eqOn_sdenseₓ'. -/\ntheorem eq_of_eqOn_sdense {s : Set R} (hs : closure s = ⊤) {f g : R →+* S} (h : s.EqOn f g) :\n    f = g :=\n  eq_of_eqOn_stop <| hs ▸ eqOn_sclosure h\n#align ring_hom.eq_of_eq_on_sdense RingHom.eq_of_eqOn_sdense\n\n/- warning: ring_hom.sclosure_preimage_le -> RingHom.sclosure_preimage_le is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : Set.{u2} S), LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) (Subsemiring.closure.{u1} R _inst_1 (Set.preimage.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f) s)) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (Subsemiring.closure.{u2} S _inst_2 s))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : Set.{u2} S), LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) (Subsemiring.closure.{u1} R _inst_1 (Set.preimage.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f) s)) (Subsemiring.comap.{u1, u2} R S _inst_1 _inst_2 f (Subsemiring.closure.{u2} S _inst_2 s))\nCase conversion may be inaccurate. Consider using '#align ring_hom.sclosure_preimage_le RingHom.sclosure_preimage_leₓ'. -/\ntheorem sclosure_preimage_le (f : R →+* S) (s : Set S) : closure (f ⁻¹' s) ≤ (closure s).comap f :=\n  closure_le.2 fun x hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx\n#align ring_hom.sclosure_preimage_le RingHom.sclosure_preimage_le\n\n#print RingHom.map_closureS /-\n/-- The image under a ring homomorphism of the subsemiring generated by a set equals\nthe subsemiring generated by the image of the set. -/\ntheorem map_closureS (f : R →+* S) (s : Set R) : (closure s).map f = closure (f '' s) :=\n  le_antisymm\n    (map_le_iff_le_comap.2 <|\n      le_trans (closure_mono <| Set.subset_preimage_image _ _) (sclosure_preimage_le _ _))\n    (closure_le.2 <| Set.image_subset _ subset_closure)\n#align ring_hom.map_sclosure RingHom.map_closureS\n-/\n\nend RingHom\n\nnamespace Subsemiring\n\nopen RingHom\n\n/- warning: subsemiring.inclusion -> Subsemiring.inclusion is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Subsemiring.{u1} R _inst_1} {T : Subsemiring.{u1} R _inst_1}, (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (SetLike.partialOrder.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)))) S T) -> (RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) S) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) T) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 S) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 T))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {S : Subsemiring.{u1} R _inst_1} {T : Subsemiring.{u1} R _inst_1}, (LE.le.{u1} (Subsemiring.{u1} R _inst_1) (Preorder.toLE.{u1} (Subsemiring.{u1} R _inst_1) (PartialOrder.toPreorder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1))))) S T) -> (RingHom.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x S)) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x T)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 S) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 T))\nCase conversion may be inaccurate. Consider using '#align subsemiring.inclusion Subsemiring.inclusionₓ'. -/\n/-- The ring homomorphism associated to an inclusion of subsemirings. -/\ndef inclusion {S T : Subsemiring R} (h : S ≤ T) : S →+* T :=\n  S.Subtype.codRestrict _ fun x => h x.2\n#align subsemiring.inclusion Subsemiring.inclusion\n\n/- warning: subsemiring.srange_subtype -> Subsemiring.rangeS_subtype is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (RingHom.rangeS.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1 (Subsemiring.subtype.{u1} R _inst_1 s)) s\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] (s : Subsemiring.{u1} R _inst_1), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (RingHom.rangeS.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) R (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s) _inst_1 (Subsemiring.subtype.{u1} R _inst_1 s)) s\nCase conversion may be inaccurate. Consider using '#align subsemiring.srange_subtype Subsemiring.rangeS_subtypeₓ'. -/\n@[simp]\ntheorem rangeS_subtype (s : Subsemiring R) : s.Subtype.srange = s :=\n  SetLike.coe_injective <| (coe_rangeS _).trans Subtype.range_coe\n#align subsemiring.srange_subtype Subsemiring.rangeS_subtype\n\n/- warning: subsemiring.range_fst -> Subsemiring.range_fst is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (RingHom.rangeS.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_1 (RingHom.fst.{u1, u2} R S _inst_1 _inst_2)) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasTop.{u1} R _inst_1))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (RingHom.rangeS.{max u1 u2, u1} (Prod.{u1, u2} R S) R (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_1 (RingHom.fst.{u1, u2} R S _inst_1 _inst_2)) (Top.top.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instTopSubsemiring.{u1} R _inst_1))\nCase conversion may be inaccurate. Consider using '#align subsemiring.range_fst Subsemiring.range_fstₓ'. -/\n@[simp]\ntheorem range_fst : (fst R S).srange = ⊤ :=\n  (fst R S).srange_top_of_surjective <| Prod.fst_surjective\n#align subsemiring.range_fst Subsemiring.range_fst\n\n/- warning: subsemiring.range_snd -> Subsemiring.range_snd is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2) _inst_2 (RingHom.snd.{u1, u2} R S _inst_1 _inst_2)) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasTop.{u2} S _inst_2))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S], Eq.{succ u2} (Subsemiring.{u2} S _inst_2) (RingHom.rangeS.{max u1 u2, u2} (Prod.{u1, u2} R S) S (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2) _inst_2 (RingHom.snd.{u1, u2} R S _inst_1 _inst_2)) (Top.top.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instTopSubsemiring.{u2} S _inst_2))\nCase conversion may be inaccurate. Consider using '#align subsemiring.range_snd Subsemiring.range_sndₓ'. -/\n@[simp]\ntheorem range_snd : (snd R S).srange = ⊤ :=\n  (snd R S).srange_top_of_surjective <| Prod.snd_surjective\n#align subsemiring.range_snd Subsemiring.range_snd\n\n/- warning: subsemiring.prod_bot_sup_bot_prod -> Subsemiring.prod_bot_sup_bot_prod is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u2} S _inst_2), Eq.{succ (max u1 u2)} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Sup.sup.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (SemilatticeSup.toHasSup.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Lattice.toSemilatticeSup.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (CompleteLattice.toLattice.{max u1 u2} (Subsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.completeLattice.{max u1 u2} (Prod.{u1, u2} R S) (Prod.nonAssocSemiring.{u1, u2} R S _inst_1 _inst_2))))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s (Bot.bot.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasBot.{u2} S _inst_2))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 (Bot.bot.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasBot.{u1} R _inst_1)) t)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (s : Subsemiring.{u1} R _inst_1) (t : Subsemiring.{u2} S _inst_2), Eq.{max (succ u1) (succ u2)} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Sup.sup.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (SemilatticeSup.toSup.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Lattice.toSemilatticeSup.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (CompleteLattice.toLattice.{max u1 u2} (Subsemiring.{max u2 u1} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2)) (Subsemiring.instCompleteLatticeSubsemiring.{max u1 u2} (Prod.{u1, u2} R S) (Prod.instNonAssocSemiringProd.{u1, u2} R S _inst_1 _inst_2))))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s (Bot.bot.{u2} (Subsemiring.{u2} S _inst_2) (Subsemiring.instBotSubsemiring.{u2} S _inst_2))) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 (Bot.bot.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instBotSubsemiring.{u1} R _inst_1)) t)) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s t)\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_bot_sup_bot_prod Subsemiring.prod_bot_sup_bot_prodₓ'. -/\n@[simp]\ntheorem prod_bot_sup_bot_prod (s : Subsemiring R) (t : Subsemiring S) :\n    s.Prod ⊥ ⊔ prod ⊥ t = s.Prod t :=\n  le_antisymm (sup_le (prod_mono_right s bot_le) (prod_mono_left t bot_le)) fun p hp =>\n    Prod.fst_mul_snd p ▸\n      mul_mem\n        ((le_sup_left : s.Prod ⊥ ≤ s.Prod ⊥ ⊔ prod ⊥ t) ⟨hp.1, SetLike.mem_coe.2 <| one_mem ⊥⟩)\n        ((le_sup_right : prod ⊥ t ≤ s.Prod ⊥ ⊔ prod ⊥ t) ⟨SetLike.mem_coe.2 <| one_mem ⊥, hp.2⟩)\n#align subsemiring.prod_bot_sup_bot_prod Subsemiring.prod_bot_sup_bot_prod\n\nend Subsemiring\n\nnamespace RingEquiv\n\nvariable {s t : Subsemiring R}\n\n/- warning: ring_equiv.subsemiring_congr -> RingEquiv.subsemiringCongr is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {t : Subsemiring.{u1} R _inst_1}, (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) s t) -> (RingEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) t) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (RingEquiv.subsemiringCongr._proof_1.{u1} R _inst_1) s) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (RingEquiv.subsemiringCongr._proof_2.{u1} R _inst_1) s) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (RingEquiv.subsemiringCongr._proof_3.{u1} R _inst_1) t) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (RingEquiv.subsemiringCongr._proof_4.{u1} R _inst_1) t))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {s : Subsemiring.{u1} R _inst_1} {t : Subsemiring.{u1} R _inst_1}, (Eq.{succ u1} (Subsemiring.{u1} R _inst_1) s t) -> (RingEquiv.{u1, u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x t)) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 t)) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x t)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x t)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x t)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 t)))))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.subsemiring_congr RingEquiv.subsemiringCongrₓ'. -/\n/-- Makes the identity isomorphism from a proof two subsemirings of a multiplicative\n    monoid are equal. -/\ndef subsemiringCongr (h : s = t) : s ≃+* t :=\n  {\n    Equiv.setCongr <| congr_arg _ h with\n    map_mul' := fun _ _ => rfl\n    map_add' := fun _ _ => rfl }\n#align ring_equiv.subsemiring_congr RingEquiv.subsemiringCongr\n\n/- warning: ring_equiv.sof_left_inverse -> RingEquiv.ofLeftInverseS is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {g : S -> R} {f : RingHom.{u1, u2} R S _inst_1 _inst_2}, (Function.LeftInverse.{succ u1, succ u2} R S g (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f)) -> (RingEquiv.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {g : S -> R} {f : RingHom.{u1, u2} R S _inst_1 _inst_2}, (Function.LeftInverse.{succ u1, succ u2} R S g (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f)) -> (RingEquiv.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.sof_left_inverse RingEquiv.ofLeftInverseSₓ'. -/\n/-- Restrict a ring homomorphism with a left inverse to a ring isomorphism to its\n`ring_hom.srange`. -/\ndef ofLeftInverseS {g : S → R} {f : R →+* S} (h : Function.LeftInverse g f) : R ≃+* f.srange :=\n  { f.srangeRestrict with\n    toFun := fun x => f.srangeRestrict x\n    invFun := fun x => (g ∘ f.srange.Subtype) x\n    left_inv := h\n    right_inv := fun x =>\n      Subtype.ext <|\n        let ⟨x', hx'⟩ := RingHom.mem_rangeS.mp x.Prop\n        show f (g x) = x by rw [← hx', h x'] }\n#align ring_equiv.sof_left_inverse RingEquiv.ofLeftInverseS\n\n/- warning: ring_equiv.sof_left_inverse_apply -> RingEquiv.ofLeftInverseS_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {g : S -> R} {f : RingHom.{u1, u2} R S _inst_1 _inst_2} (h : Function.LeftInverse.{succ u1, succ u2} R S g (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f)) (x : R), Eq.{succ u2} S ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (coeSubtype.{succ u2} S (fun (x : S) => Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (fun (_x : RingEquiv.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) => R -> (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingEquiv.hasCoeToFun.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingEquiv.ofLeftInverseS.{u1, u2} R S _inst_1 _inst_2 g f h) x)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f x)\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {g : S -> R} {f : RingHom.{u1, u2} R S _inst_1 _inst_2} (h : Function.LeftInverse.{succ u1, succ u2} R S g (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f)) (x : R), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) (Subtype.val.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Set.{u2} S) (Set.instMembershipSet.{u2} S) x (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingEquiv.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) R (fun (_x : R) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : R) => Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (RingEquiv.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (EquivLike.toEmbeddingLike.{max (succ u1) (succ u2), succ u1, succ u2} (RingEquiv.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (MulEquivClass.toEquivLike.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (RingEquivClass.toMulEquivClass.{max u1 u2, u1, u2} (RingEquiv.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (RingEquiv.instRingEquivClassRingEquiv.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))))))) (RingEquiv.ofLeftInverseS.{u1, u2} R S _inst_1 _inst_2 g f h) x)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f x)\nCase conversion may be inaccurate. Consider using '#align ring_equiv.sof_left_inverse_apply RingEquiv.ofLeftInverseS_applyₓ'. -/\n@[simp]\ntheorem ofLeftInverseS_apply {g : S → R} {f : R →+* S} (h : Function.LeftInverse g f) (x : R) :\n    ↑(ofLeftInverseS h x) = f x :=\n  rfl\n#align ring_equiv.sof_left_inverse_apply RingEquiv.ofLeftInverseS_apply\n\n/- warning: ring_equiv.sof_left_inverse_symm_apply -> RingEquiv.ofLeftInverseS_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {g : S -> R} {f : RingHom.{u1, u2} R S _inst_1 _inst_2} (h : Function.LeftInverse.{succ u1, succ u2} R S g (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S _inst_1 _inst_2) (fun (_x : RingHom.{u1, u2} R S _inst_1 _inst_2) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S _inst_1 _inst_2) f)) (x : coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)), Eq.{succ u1} R (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingEquiv.{u2, u1} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) R (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (fun (_x : RingEquiv.{u2, u1} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) R (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) => (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) -> R) (RingEquiv.hasCoeToFun.{u2, u1} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) R (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (RingEquiv.symm.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_1.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.ofLeftInverseS._proof_2.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) (RingEquiv.ofLeftInverseS.{u1, u2} R S _inst_1 _inst_2 g f h)) x) (g ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)) S (coeSubtype.{succ u2} S (fun (x : S) => Membership.Mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.hasMem.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f)))))) x))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] {g : S -> R} {f : RingHom.{u1, u2} R S _inst_1 _inst_2} (h : Function.LeftInverse.{succ u1, succ u2} R S g (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S _inst_1 _inst_2) R S _inst_1 _inst_2 (RingHom.instRingHomClassRingHom.{u1, u2} R S _inst_1 _inst_2)))) f)) (x : Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))), Eq.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) => R) x) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (RingEquiv.{u2, u1} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (fun (_x : Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) => R) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u2, succ u1} (RingEquiv.{u2, u1} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (EquivLike.toEmbeddingLike.{max (succ u1) (succ u2), succ u2, succ u1} (RingEquiv.{u2, u1} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (MulEquivClass.toEquivLike.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (RingEquivClass.toMulEquivClass.{max u1 u2, u2, u1} (RingEquiv.{u2, u1} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) R (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)))))))) (RingEquiv.symm.{u1, u2} R (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))))) (RingEquiv.ofLeftInverseS.{u1, u2} R S _inst_1 _inst_2 g f h)) x) (g (Subtype.val.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Set.{u2} S) (Set.instMembershipSet.{u2} S) x (SetLike.coe.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2) (RingHom.rangeS.{u1, u2} R S _inst_1 _inst_2 f))) x))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.sof_left_inverse_symm_apply RingEquiv.ofLeftInverseS_symm_applyₓ'. -/\n@[simp]\ntheorem ofLeftInverseS_symm_apply {g : S → R} {f : R →+* S} (h : Function.LeftInverse g f)\n    (x : f.srange) : (ofLeftInverseS h).symm x = g x :=\n  rfl\n#align ring_equiv.sof_left_inverse_symm_apply RingEquiv.ofLeftInverseS_symm_apply\n\n/- warning: ring_equiv.subsemiring_map -> RingEquiv.subsemiringMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (e : RingEquiv.{u1, u2} R S (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2))) (Distrib.toHasAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (s : Subsemiring.{u1} R _inst_1), RingEquiv.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.setLike.{u1} R _inst_1)) s) (coeSort.{succ u2, succ (succ u2)} (Subsemiring.{u2} S _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.setLike.{u2} S _inst_2)) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s)) (MulMemClass.mul.{u1, u1} R (Subsemiring.{u1} R _inst_1) (MulOneClass.toHasMul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1))) (Subsemiring.setLike.{u1} R _inst_1) (RingEquiv.subsemiringMap._proof_1.{u1} R _inst_1) s) (AddMemClass.add.{u1, u1} R (Subsemiring.{u1} R _inst_1) (AddZeroClass.toHasAdd.{u1} R (AddMonoid.toAddZeroClass.{u1} R (AddMonoidWithOne.toAddMonoid.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R _inst_1))))) (Subsemiring.setLike.{u1} R _inst_1) (RingEquiv.subsemiringMap._proof_2.{u1} R _inst_1) s) (MulMemClass.mul.{u2, u2} S (Subsemiring.{u2} S _inst_2) (MulOneClass.toHasMul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.subsemiringMap._proof_3.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s)) (AddMemClass.add.{u2, u2} S (Subsemiring.{u2} S _inst_2) (AddZeroClass.toHasAdd.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddMonoidWithOne.toAddMonoid.{u2} S (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} S (NonAssocSemiring.toAddCommMonoidWithOne.{u2} S _inst_2))))) (Subsemiring.setLike.{u2} S _inst_2) (RingEquiv.subsemiringMap._proof_4.{u2} S _inst_2) (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} R] [_inst_2 : NonAssocSemiring.{u2} S] (e : RingEquiv.{u1, u2} R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)) (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S _inst_2)))) (s : Subsemiring.{u1} R _inst_1), RingEquiv.{u1, u2} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s))) (Submonoid.mul.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R _inst_1)) (Subsemiring.toSubmonoid.{u1} R _inst_1 s)) (Submonoid.mul.{u2} S (MulZeroOneClass.toMulOneClass.{u2} S (NonAssocSemiring.toMulZeroOneClass.{u2} S _inst_2)) (Subsemiring.toSubmonoid.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s))) (Distrib.toAdd.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} R (fun (x : R) => Membership.mem.{u1, u1} R (Subsemiring.{u1} R _inst_1) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R _inst_1) R (Subsemiring.instSetLikeSubsemiring.{u1} R _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} R _inst_1 s)))) (Distrib.toAdd.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s))) (NonUnitalNonAssocSemiring.toDistrib.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u2} S (Subsemiring.{u2} S _inst_2) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} S _inst_2) S (Subsemiring.instSetLikeSubsemiring.{u2} S _inst_2)) x (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s))) (Subsemiring.toNonAssocSemiring.{u2} S _inst_2 (Subsemiring.map.{u1, u2} R S _inst_1 _inst_2 (RingEquiv.toRingHom.{u1, u2} R S _inst_1 _inst_2 e) s)))))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.subsemiring_map RingEquiv.subsemiringMapₓ'. -/\n/-- Given an equivalence `e : R ≃+* S` of semirings and a subsemiring `s` of `R`,\n`subsemiring_map e s` is the induced equivalence between `s` and `s.map e` -/\n@[simps]\ndef subsemiringMap (e : R ≃+* S) (s : Subsemiring R) : s ≃+* s.map e.toRingHom :=\n  { e.toAddEquiv.addSubmonoidMap s.toAddSubmonoid, e.toMulEquiv.submonoidMap s.toSubmonoid with }\n#align ring_equiv.subsemiring_map RingEquiv.subsemiringMap\n\nend RingEquiv\n\n/-! ### Actions by `subsemiring`s\n\nThese are just copies of the definitions about `submonoid` starting from `submonoid.mul_action`.\nThe only new result is `subsemiring.module`.\n\nWhen `R` is commutative, `algebra.of_subsemiring` provides a stronger result than those found in\nthis file, which uses the same scalar action.\n-/\n\n\nsection Actions\n\nnamespace Subsemiring\n\nvariable {R' α β : Type _}\n\nsection NonAssocSemiring\n\nvariable [NonAssocSemiring R']\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [SMul R' α] (S : Subsemiring R') : SMul S α :=\n  S.toSubmonoid.SMul\n\n/- warning: subsemiring.smul_def -> Subsemiring.smul_def is a dubious translation:\nlean 3 declaration is\n  forall {R' : Type.{u1}} {α : Type.{u2}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u1, u2} R' α] {S : Subsemiring.{u1} R' _inst_4} (g : coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) (m : α), Eq.{succ u2} α (SMul.smul.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) α (Subsemiring.hasSmul.{u1, u2} R' α _inst_4 _inst_5 S) g m) (SMul.smul.{u1, u2} R' α _inst_5 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) R' (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) R' (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) R' (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) R' (coeSubtype.{succ u1} R' (fun (x : R') => Membership.Mem.{u1, u1} R' (Subsemiring.{u1} R' _inst_4) (SetLike.hasMem.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) x S))))) g) m)\nbut is expected to have type\n  forall {R' : Type.{u2}} {α : Type.{u1}} [_inst_4 : NonAssocSemiring.{u2} R'] [_inst_5 : SMul.{u2, u1} R' α] {S : Subsemiring.{u2} R' _inst_4} (g : Subtype.{succ u2} R' (fun (x : R') => Membership.mem.{u2, u2} R' (Subsemiring.{u2} R' _inst_4) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R' _inst_4) R' (Subsemiring.instSetLikeSubsemiring.{u2} R' _inst_4)) x S)) (m : α), Eq.{succ u1} α (HSMul.hSMul.{u2, u1, u1} (Subtype.{succ u2} R' (fun (x : R') => Membership.mem.{u2, u2} R' (Subsemiring.{u2} R' _inst_4) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R' _inst_4) R' (Subsemiring.instSetLikeSubsemiring.{u2} R' _inst_4)) x S)) α α (instHSMul.{u2, u1} (Subtype.{succ u2} R' (fun (x : R') => Membership.mem.{u2, u2} R' (Subsemiring.{u2} R' _inst_4) (SetLike.instMembership.{u2, u2} (Subsemiring.{u2} R' _inst_4) R' (Subsemiring.instSetLikeSubsemiring.{u2} R' _inst_4)) x S)) α (Subsemiring.smul.{u2, u1} R' α _inst_4 _inst_5 S)) g m) (HSMul.hSMul.{u2, u1, u1} R' α α (instHSMul.{u2, u1} R' α _inst_5) (Subtype.val.{succ u2} R' (fun (x : R') => Membership.mem.{u2, u2} R' (Set.{u2} R') (Set.instMembershipSet.{u2} R') x (SetLike.coe.{u2, u2} (Subsemiring.{u2} R' _inst_4) R' (Subsemiring.instSetLikeSubsemiring.{u2} R' _inst_4) S)) g) m)\nCase conversion may be inaccurate. Consider using '#align subsemiring.smul_def Subsemiring.smul_defₓ'. -/\ntheorem smul_def [SMul R' α] {S : Subsemiring R'} (g : S) (m : α) : g • m = (g : R') • m :=\n  rfl\n#align subsemiring.smul_def Subsemiring.smul_def\n\n/- warning: subsemiring.smul_comm_class_left -> Subsemiring.smulCommClass_left is a dubious translation:\nlean 3 declaration is\n  forall {R' : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u1, u3} R' β] [_inst_6 : SMul.{u2, u3} α β] [_inst_7 : SMulCommClass.{u1, u2, u3} R' α β _inst_5 _inst_6] (S : Subsemiring.{u1} R' _inst_4), SMulCommClass.{u1, u2, u3} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) α β (Subsemiring.hasSmul.{u1, u3} R' β _inst_4 _inst_5 S) _inst_6\nbut is expected to have type\n  forall {R' : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u1, u3} R' β] [_inst_6 : SMul.{u2, u3} α β] [_inst_7 : SMulCommClass.{u1, u2, u3} R' α β _inst_5 _inst_6] (S : Subsemiring.{u1} R' _inst_4), SMulCommClass.{u1, u2, u3} (Subtype.{succ u1} R' (fun (x : R') => Membership.mem.{u1, u1} R' (Subsemiring.{u1} R' _inst_4) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.instSetLikeSubsemiring.{u1} R' _inst_4)) x S)) α β (Subsemiring.smul.{u1, u3} R' β _inst_4 _inst_5 S) _inst_6\nCase conversion may be inaccurate. Consider using '#align subsemiring.smul_comm_class_left Subsemiring.smulCommClass_leftₓ'. -/\ninstance smulCommClass_left [SMul R' β] [SMul α β] [SMulCommClass R' α β] (S : Subsemiring R') :\n    SMulCommClass S α β :=\n  S.toSubmonoid.smulCommClass_left\n#align subsemiring.smul_comm_class_left Subsemiring.smulCommClass_left\n\n/- warning: subsemiring.smul_comm_class_right -> Subsemiring.smulCommClass_right is a dubious translation:\nlean 3 declaration is\n  forall {R' : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u2, u3} α β] [_inst_6 : SMul.{u1, u3} R' β] [_inst_7 : SMulCommClass.{u2, u1, u3} α R' β _inst_5 _inst_6] (S : Subsemiring.{u1} R' _inst_4), SMulCommClass.{u2, u1, u3} α (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' _inst_4) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.setLike.{u1} R' _inst_4)) S) β _inst_5 (Subsemiring.hasSmul.{u1, u3} R' β _inst_4 _inst_6 S)\nbut is expected to have type\n  forall {R' : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u2, u3} α β] [_inst_6 : SMul.{u1, u3} R' β] [_inst_7 : SMulCommClass.{u2, u1, u3} α R' β _inst_5 _inst_6] (S : Subsemiring.{u1} R' _inst_4), SMulCommClass.{u2, u1, u3} α (Subtype.{succ u1} R' (fun (x : R') => Membership.mem.{u1, u1} R' (Subsemiring.{u1} R' _inst_4) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R' _inst_4) R' (Subsemiring.instSetLikeSubsemiring.{u1} R' _inst_4)) x S)) β _inst_5 (Subsemiring.smul.{u1, u3} R' β _inst_4 _inst_6 S)\nCase conversion may be inaccurate. Consider using '#align subsemiring.smul_comm_class_right Subsemiring.smulCommClass_rightₓ'. -/\ninstance smulCommClass_right [SMul α β] [SMul R' β] [SMulCommClass α R' β] (S : Subsemiring R') :\n    SMulCommClass α S β :=\n  S.toSubmonoid.smulCommClass_right\n#align subsemiring.smul_comm_class_right Subsemiring.smulCommClass_right\n\n/-- Note that this provides `is_scalar_tower S R R` which is needed by `smul_mul_assoc`. -/\ninstance [SMul α β] [SMul R' α] [SMul R' β] [IsScalarTower R' α β] (S : Subsemiring R') :\n    IsScalarTower S α β :=\n  S.toSubmonoid.IsScalarTower\n\ninstance [SMul R' α] [FaithfulSMul R' α] (S : Subsemiring R') : FaithfulSMul S α :=\n  S.toSubmonoid.FaithfulSMul\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Zero α] [SMulWithZero R' α] (S : Subsemiring R') : SMulWithZero S α :=\n  SMulWithZero.compHom _ S.Subtype.toMonoidWithZeroHom.toZeroHom\n\nend NonAssocSemiring\n\nvariable [Semiring R']\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [MulAction R' α] (S : Subsemiring R') : MulAction S α :=\n  S.toSubmonoid.MulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [AddMonoid α] [DistribMulAction R' α] (S : Subsemiring R') : DistribMulAction S α :=\n  S.toSubmonoid.DistribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Monoid α] [MulDistribMulAction R' α] (S : Subsemiring R') : MulDistribMulAction S α :=\n  S.toSubmonoid.MulDistribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Zero α] [MulActionWithZero R' α] (S : Subsemiring R') : MulActionWithZero S α :=\n  MulActionWithZero.compHom _ S.Subtype.toMonoidWithZeroHom\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [AddCommMonoid α] [Module R' α] (S : Subsemiring R') : Module S α :=\n  { Module.compHom _ S.Subtype with smul := (· • ·) }\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Semiring α] [MulSemiringAction R' α] (S : Subsemiring R') : MulSemiringAction S α :=\n  S.toSubmonoid.MulSemiringAction\n\n/- warning: subsemiring.center.smul_comm_class_left -> Subsemiring.center.smulCommClass_left is a dubious translation:\nlean 3 declaration is\n  forall {R' : Type.{u1}} [_inst_4 : Semiring.{u1} R'], SMulCommClass.{u1, u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) R' (Subsemiring.setLike.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))) (Subsemiring.center.{u1} R' _inst_4)) R' R' (Subsemiring.hasSmul.{u1, u1} R' R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4) (Mul.toSMul.{u1} R' (Distrib.toHasMul.{u1} R' (NonUnitalNonAssocSemiring.toDistrib.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))))) (Subsemiring.center.{u1} R' _inst_4)) (Mul.toSMul.{u1} R' (Distrib.toHasMul.{u1} R' (NonUnitalNonAssocSemiring.toDistrib.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)))))\nbut is expected to have type\n  forall {R' : Type.{u1}} [_inst_4 : Semiring.{u1} R'], SMulCommClass.{u1, u1, u1} (Subtype.{succ u1} R' (fun (x : R') => Membership.mem.{u1, u1} R' (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) R' (Subsemiring.instSetLikeSubsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))) x (Subsemiring.center.{u1} R' _inst_4))) R' R' (Subsemiring.smul.{u1, u1} R' R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4) (SMulZeroClass.toSMul.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MulZeroClass.toSMulWithZero.{u1} R' (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)))))) (Subsemiring.center.{u1} R' _inst_4)) (SMulZeroClass.toSMul.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MulZeroClass.toSMulWithZero.{u1} R' (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.center.smul_comm_class_left Subsemiring.center.smulCommClass_leftₓ'. -/\n/-- The center of a semiring acts commutatively on that semiring. -/\ninstance center.smulCommClass_left : SMulCommClass (center R') R' R' :=\n  Submonoid.center.smulCommClass_left\n#align subsemiring.center.smul_comm_class_left Subsemiring.center.smulCommClass_left\n\n/- warning: subsemiring.center.smul_comm_class_right -> Subsemiring.center.smulCommClass_right is a dubious translation:\nlean 3 declaration is\n  forall {R' : Type.{u1}} [_inst_4 : Semiring.{u1} R'], SMulCommClass.{u1, u1, u1} R' (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) R' (Subsemiring.setLike.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))) (Subsemiring.center.{u1} R' _inst_4)) R' (Mul.toSMul.{u1} R' (Distrib.toHasMul.{u1} R' (NonUnitalNonAssocSemiring.toDistrib.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))))) (Subsemiring.hasSmul.{u1, u1} R' R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4) (Mul.toSMul.{u1} R' (Distrib.toHasMul.{u1} R' (NonUnitalNonAssocSemiring.toDistrib.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))))) (Subsemiring.center.{u1} R' _inst_4))\nbut is expected to have type\n  forall {R' : Type.{u1}} [_inst_4 : Semiring.{u1} R'], SMulCommClass.{u1, u1, u1} R' (Subtype.{succ u1} R' (fun (x : R') => Membership.mem.{u1, u1} R' (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) R' (Subsemiring.instSetLikeSubsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))) x (Subsemiring.center.{u1} R' _inst_4))) R' (SMulZeroClass.toSMul.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MulZeroClass.toSMulWithZero.{u1} R' (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)))))) (Subsemiring.smul.{u1, u1} R' R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4) (SMulZeroClass.toSMul.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u1} R' R' (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MonoidWithZero.toZero.{u1} R' (Semiring.toMonoidWithZero.{u1} R' _inst_4)) (MulZeroClass.toSMulWithZero.{u1} R' (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)))))) (Subsemiring.center.{u1} R' _inst_4))\nCase conversion may be inaccurate. Consider using '#align subsemiring.center.smul_comm_class_right Subsemiring.center.smulCommClass_rightₓ'. -/\n/-- The center of a semiring acts commutatively on that semiring. -/\ninstance center.smulCommClass_right : SMulCommClass R' (center R') R' :=\n  Submonoid.center.smulCommClass_right\n#align subsemiring.center.smul_comm_class_right Subsemiring.center.smulCommClass_right\n\n/- warning: subsemiring.closure_comm_semiring_of_comm -> Subsemiring.closureCommSemiringOfComm is a dubious translation:\nlean 3 declaration is\n  forall {R' : Type.{u1}} [_inst_4 : Semiring.{u1} R'] {s : Set.{u1} R'}, (forall (a : R'), (Membership.Mem.{u1, u1} R' (Set.{u1} R') (Set.hasMem.{u1} R') a s) -> (forall (b : R'), (Membership.Mem.{u1, u1} R' (Set.{u1} R') (Set.hasMem.{u1} R') b s) -> (Eq.{succ u1} R' (HMul.hMul.{u1, u1, u1} R' R' R' (instHMul.{u1} R' (Distrib.toHasMul.{u1} R' (NonUnitalNonAssocSemiring.toDistrib.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))))) a b) (HMul.hMul.{u1, u1, u1} R' R' R' (instHMul.{u1} R' (Distrib.toHasMul.{u1} R' (NonUnitalNonAssocSemiring.toDistrib.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))))) b a)))) -> (CommSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) R' (Subsemiring.setLike.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))) (Subsemiring.closure.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4) s)))\nbut is expected to have type\n  forall {R' : Type.{u1}} [_inst_4 : Semiring.{u1} R'] {s : Set.{u1} R'}, (forall (a : R'), (Membership.mem.{u1, u1} R' (Set.{u1} R') (Set.instMembershipSet.{u1} R') a s) -> (forall (b : R'), (Membership.mem.{u1, u1} R' (Set.{u1} R') (Set.instMembershipSet.{u1} R') b s) -> (Eq.{succ u1} R' (HMul.hMul.{u1, u1, u1} R' R' R' (instHMul.{u1} R' (NonUnitalNonAssocSemiring.toMul.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)))) a b) (HMul.hMul.{u1, u1, u1} R' R' R' (instHMul.{u1} R' (NonUnitalNonAssocSemiring.toMul.{u1} R' (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)))) b a)))) -> (CommSemiring.{u1} (Subtype.{succ u1} R' (fun (x : R') => Membership.mem.{u1, u1} R' (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4)) R' (Subsemiring.instSetLikeSubsemiring.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4))) x (Subsemiring.closure.{u1} R' (Semiring.toNonAssocSemiring.{u1} R' _inst_4) s))))\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_comm_semiring_of_comm Subsemiring.closureCommSemiringOfCommₓ'. -/\n/-- If all the elements of a set `s` commute, then `closure s` is a commutative monoid. -/\ndef closureCommSemiringOfComm {s : Set R'} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) :\n    CommSemiring (closure s) :=\n  { (closure s).toSemiring with\n    mul_comm := fun x y => by\n      ext\n      simp only [Subsemiring.coe_mul]\n      refine'\n        closure_induction₂ x.prop y.prop hcomm\n          (fun x => by simp only [MulZeroClass.zero_mul, MulZeroClass.mul_zero])\n          (fun x => by simp only [MulZeroClass.zero_mul, MulZeroClass.mul_zero])\n          (fun x => by simp only [one_mul, mul_one]) (fun x => by simp only [one_mul, mul_one])\n          (fun x y z h₁ h₂ => by simp only [add_mul, mul_add, h₁, h₂])\n          (fun x y z h₁ h₂ => by simp only [add_mul, mul_add, h₁, h₂])\n          (fun x y z h₁ h₂ => by rw [mul_assoc, h₂, ← mul_assoc, h₁, mul_assoc]) fun x y z h₁ h₂ =>\n          by rw [← mul_assoc, h₁, mul_assoc, h₂, ← mul_assoc] }\n#align subsemiring.closure_comm_semiring_of_comm Subsemiring.closureCommSemiringOfComm\n\nend Subsemiring\n\nend Actions\n\n#print posSubmonoid /-\n-- While this definition is not about `subsemiring`s, this is the earliest we have\n-- both `strict_ordered_semiring` and `submonoid` available.\n/-- Submonoid of positive elements of an ordered semiring. -/\ndef posSubmonoid (R : Type _) [StrictOrderedSemiring R] : Submonoid R\n    where\n  carrier := { x | 0 < x }\n  one_mem' := show (0 : R) < 1 from zero_lt_one\n  mul_mem' x y (hx : 0 < x) (hy : 0 < y) := mul_pos hx hy\n#align pos_submonoid posSubmonoid\n-/\n\n/- warning: mem_pos_monoid -> mem_posSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_4 : StrictOrderedSemiring.{u1} R] (u : Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))), Iff (Membership.Mem.{u1, u1} R (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))))) R (Submonoid.setLike.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (coeBase.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (Units.hasCoe.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))))))) u) (posSubmonoid.{u1} R _inst_4)) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedCancelAddCommMonoid.toPartialOrder.{u1} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} R _inst_4)))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (coeBase.{succ u1, succ u1} (Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))) R (Units.hasCoe.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))))))) u))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_4 : StrictOrderedSemiring.{u1} R] (u : Units.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))), Iff (Membership.mem.{u1, u1} R (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))))) R (Submonoid.instSetLikeSubmonoid.{u1} R (MulZeroOneClass.toMulOneClass.{u1} R (NonAssocSemiring.toMulZeroOneClass.{u1} R (Semiring.toNonAssocSemiring.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4)))))) (Units.val.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))) u) (posSubmonoid.{u1} R _inst_4)) (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R _inst_4))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))))) (Units.val.{u1} R (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (StrictOrderedSemiring.toSemiring.{u1} R _inst_4))) u))\nCase conversion may be inaccurate. Consider using '#align mem_pos_monoid mem_posSubmonoidₓ'. -/\n@[simp]\ntheorem mem_posSubmonoid {R : Type _} [StrictOrderedSemiring R] (u : Rˣ) :\n    ↑u ∈ posSubmonoid R ↔ (0 : R) < u :=\n  Iff.rfl\n#align mem_pos_monoid mem_posSubmonoid\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/Subsemiring/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.4685274095328119}}
{"text": "\nimport pq_like_equalizer_util\n\nuniverse u\n\nsection pq_like_equalizer_split\n\n-- Show that Gr Q' ~= ker phi x Gr Q\n\nvariables {Q : Type u} [power_quandle Q]\n\ndef eq_left_split_fun : (pq_group (eta_equalizer Q)) → (eta_equalizer_iso_forward : pq_group (eta_equalizer Q) →* pq_group Q).ker :=\nbegin\n  intro x,\n  fconstructor,\n  exact x * ((eta_equalizer_iso_backward) (eta_equalizer_iso_forward x))⁻¹,\n  refine eta_equalizer_iso_forward.mem_ker.mpr _,\n  simp only [monoid_hom.map_mul, monoid_hom.map_inv],\n  rw eta_equalizer_iso_forward_of_backward,\n  simp only [mul_right_inv],\nend\n\nlemma eq_left_split_fun_def (x : pq_group (eta_equalizer Q)) : x * ((eta_equalizer_iso_backward) (eta_equalizer_iso_forward x))⁻¹  = ↑(eq_left_split_fun x) := rfl\n\nlemma eq_left_split_coe_commutes (x y : pq_group (eta_equalizer Q)) : x * ↑(eq_left_split_fun y) = ↑(eq_left_split_fun y) * x :=\nbegin\n  rw ←eq_left_split_fun_def,\n  revert x y,\n  refine pq_group_word_induction _ _,\n  {\n    intros y,\n    simp only [mul_one, one_mul],\n  },\n  {\n    intros x a hx y,\n    assoc_rw hx,\n    rw ←mul_assoc,\n    simp only [mul_left_inj],\n    clear hx x _inst,\n    sorry,\n  },\n  /-\n  rw ←eq_left_split_fun_def,\n  revert y x,\n  refine pq_group_word_induction _ _,\n  {\n    intro y,\n    simp only [one_inv, mul_one, one_mul, monoid_hom.map_one],\n  },\n  {\n    intros y a hy x,\n    simp only [mul_inv_rev, monoid_hom.map_mul],\n    assoc_rw hy,\n    assoc_rw hy,\n    assoc_rw hy,\n    clear _inst,\n    suffices : x * of a * (eta_equalizer_iso_backward (eta_equalizer_iso_forward (of a)))⁻¹ =  of a * (eta_equalizer_iso_backward (eta_equalizer_iso_forward (of a)))⁻¹ * x,\n    assoc_rw this,\n    clear hy y,\n    rw eta_equalizer_iso_forward_of,\n    cases a with a ha,\n    simp only,\n    revert a,\n    refine pq_group_word_induction _ _,\n    {\n      intro ha,\n      simp only [one_inv, mul_one, monoid_hom.map_one],\n      suffices : of (⟨1, ha⟩ : eta_equalizer Q) = 1,\n      rw this,\n      simp only [mul_one, one_mul],\n      simp_rw ←of_one,\n      congr,\n      rw of_one,\n    },\n    {\n      intros z y hz haz,\n      simp only [mul_inv_rev, monoid_hom.map_mul],\n      rw eta_equalizer_iso_backward_of,\n      sorry,\n    },\n  },\n  -/\nend\n\ndef eq_left_split_hom : (pq_group (pq_group Q)) →* (counit : pq_group (pq_group Q) →* (pq_group Q)).ker :=\nbegin\n  fconstructor,\n  exact left_split_fun,\n  {\n    unfold left_split_fun,\n    simp only [one_inv, mul_one, monoid_hom.map_one],\n    refl,\n  },\n  {\n    intros a b,\n    unfold left_split_fun,\n    ext1,\n    simp only [mul_inv_rev, monoid_hom.map_mul, subgroup.coe_mul, subtype.coe_mk],\n    rw mul_assoc,\n    rw ←mul_assoc b, \n    rw left_split_fun_def b,\n    rw ←mul_assoc,\n    rw left_split_coe_commutes,\n    rw left_split_coe_commutes,\n    rw mul_assoc,\n  },\nend\n\n\ntheorem eq_left_split_hom_is_left_split (x : (counit : pq_group (pq_group Q) →* (pq_group Q)).ker) : left_split_hom (↑x) = x :=\nbegin\n  cases x with x hx,\n  unfold left_split_hom,\n  simp only [monoid_hom.coe_mk, subtype.coe_mk],\n  unfold left_split_fun,\n  ext1,\n  simp only [subtype.coe_mk],\n  suffices : counit x = 1,\n  rw this,\n  simp only [mul_one, monoid_hom.map_one],\n  simp only [one_inv, mul_one],\n  exact hx,\nend\n\n\ndef eq_pq_group_prod_ker_G : pq_group (pq_group Q) ≃* pq_group Q × (counit : pq_group (pq_group Q) →* pq_group Q).ker := { \n  to_fun := λ x, ⟨counit x, left_split_hom x⟩,\n  inv_fun := λ a, a.2 * (L_of_morph of of_is_pq_morphism a.1),\n  left_inv := begin \n    intro x,\n    simp only,\n    unfold left_split_hom,\n    simp only [monoid_hom.coe_mk],\n    unfold left_split_fun,\n    simp only [subgroup.coe_mk, inv_mul_cancel_right],\n  end,\n  right_inv := begin \n    intro x,\n    cases x with x1 x2,\n    simp only [monoid_hom.map_mul],\n    ext1,\n    {\n      simp only,\n      rw counit_L_of,\n      simp only [mul_left_eq_self],\n      cases x2 with x2 hx2,\n      simp only [subtype.coe_mk],\n      exact hx2,\n    },\n    {\n      simp only,\n      rw left_split_hom_is_left_split,\n      simp only [mul_right_eq_self],\n      unfold left_split_hom,\n      simp only [monoid_hom.coe_mk],\n      unfold left_split_fun,\n      simp_rw counit_L_of,\n      group,\n      refl,\n    },\n  end,\n  map_mul' := begin \n    intros x y,\n    ext1,\n    simp only [monoid_hom.map_mul, prod.mk_mul_mk],\n    simp only [monoid_hom.map_mul, prod.mk_mul_mk],\n  end }\n\nend pq_like_equalizer_split\n", "meta": {"author": "torstein-vik", "repo": "power-quandle-lean", "sha": "452437602c4be2e6c5ad5f5224b068baabfdf9e1", "save_path": "github-repos/lean/torstein-vik-power-quandle-lean", "path": "github-repos/lean/torstein-vik-power-quandle-lean/power-quandle-lean-452437602c4be2e6c5ad5f5224b068baabfdf9e1/src/pq_like_equalizer_split.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219503, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.46852665599183385}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.category.Cat\nimport Mathlib.category_theory.groupoid\nimport Mathlib.PostPort\n\nuniverses v u \n\nnamespace Mathlib\n\n/-!\n# Objects of a category up to an isomorphism\n\n`is_isomorphic X Y := nonempty (X ≅ Y)` is an equivalence relation on the objects of a category.\nThe quotient with respect to this relation defines a functor from our category to `Type`.\n-/\n\nnamespace category_theory\n\n\n/-- An object `X` is isomorphic to an object `Y`, if `X ≅ Y` is not empty. -/\ndef is_isomorphic {C : Type u} [category C] : C → C → Prop := fun (X Y : C) => Nonempty (X ≅ Y)\n\n/-- `is_isomorphic` defines a setoid. -/\ndef is_isomorphic_setoid (C : Type u) [category C] : setoid C := setoid.mk is_isomorphic sorry\n\n/--\nThe functor that sends each category to the quotient space of its objects up to an isomorphism.\n-/\ndef isomorphism_classes : Cat ⥤ Type u :=\n  functor.mk (fun (C : Cat) => quotient (is_isomorphic_setoid (bundled.α C)))\n    fun (C D : Cat) (F : C ⟶ D) => quot.map (functor.obj F) sorry\n\ntheorem groupoid.is_isomorphic_iff_nonempty_hom {C : Type u} [groupoid C] {X : C} {Y : C} :\n    is_isomorphic X Y ↔ Nonempty (X ⟶ Y) :=\n  equiv.nonempty_iff_nonempty (groupoid.iso_equiv_hom X Y)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/isomorphism_classes_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303285397349, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4685209219762184}}
{"text": "/-\nCopyright (c) 2015 Nathaniel Thomas. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro\n-/\nimport algebra.module.linear_map\nimport data.equiv.module\nimport group_theory.group_action.sub_mul_action\n/-!\n\n# Submodules of a module\n\nIn this file we define\n\n* `submodule R M` : a subset of a `module` `M` that contains zero and is closed with respect to\n  addition and scalar multiplication.\n\n* `subspace k M` : an abbreviation for `submodule` assuming that `k` is a `field`.\n\n## Tags\n\nsubmodule, subspace, linear map\n-/\n\nopen function\nopen_locale big_operators\n\nuniverses u'' u' u v w\nvariables {G : Type u''} {S : Type u'} {R : Type u} {M : Type v} {ι : Type w}\n\nset_option old_structure_cmd true\n\n/-- A submodule of a module is one which is closed under vector operations.\n  This is a sufficient condition for the subset of vectors in the submodule\n  to themselves form a module. -/\nstructure submodule (R : Type u) (M : Type v) [semiring R]\n  [add_comm_monoid M] [module R M] extends add_submonoid M, sub_mul_action R M : Type v.\n\n/-- Reinterpret a `submodule` as an `add_submonoid`. -/\nadd_decl_doc submodule.to_add_submonoid\n\n/-- Reinterpret a `submodule` as an `sub_mul_action`. -/\nadd_decl_doc submodule.to_sub_mul_action\n\nnamespace submodule\n\nvariables [semiring R] [add_comm_monoid M] [module R M]\n\ninstance : set_like (submodule R M) M :=\n⟨submodule.carrier, λ p q h, by cases p; cases q; congr'⟩\n\n@[simp] theorem mem_to_add_submonoid (p : submodule R M) (x : M) : x ∈ p.to_add_submonoid ↔ x ∈ p :=\niff.rfl\n\nvariables {p q : submodule R M}\n\n@[simp]\nlemma mem_mk {S : set M} {x : M} (h₁ h₂ h₃) : x ∈ (⟨S, h₁, h₂, h₃⟩ : submodule R M) ↔ x ∈ S :=\niff.rfl\n\n@[simp] lemma coe_set_mk (S : set M) (h₁ h₂ h₃) :\n  ((⟨S, h₁, h₂, h₃⟩ : submodule R M) : set M) = S := rfl\n\n@[simp]\nlemma mk_le_mk {S S' : set M} (h₁ h₂ h₃ h₁' h₂' h₃') :\n  (⟨S, h₁, h₂, h₃⟩ : submodule R M) ≤ (⟨S', h₁', h₂', h₃'⟩ : submodule R M) ↔ S ⊆ S' := iff.rfl\n\n@[ext] theorem ext (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := set_like.ext h\n\n/-- Copy of a submodule with a new `carrier` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (p : submodule R M) (s : set M) (hs : s = ↑p) : submodule R M :=\n{ carrier := s,\n  zero_mem' := hs.symm ▸ p.zero_mem',\n  add_mem' := hs.symm ▸ p.add_mem',\n  smul_mem' := hs.symm ▸ p.smul_mem' }\n\n@[simp] lemma coe_copy (S : submodule R M) (s : set M) (hs : s = ↑S) :\n  (S.copy s hs : set M) = s := rfl\n\nlemma copy_eq (S : submodule R M) (s : set M) (hs : s = ↑S) : S.copy s hs = S :=\nset_like.coe_injective hs\n\ntheorem to_add_submonoid_injective :\n  injective (to_add_submonoid : submodule R M → add_submonoid M) :=\nλ p q h, set_like.ext'_iff.2 (show _, from set_like.ext'_iff.1 h)\n\n@[simp] theorem to_add_submonoid_eq : p.to_add_submonoid = q.to_add_submonoid ↔ p = q :=\nto_add_submonoid_injective.eq_iff\n\n@[mono] lemma to_add_submonoid_strict_mono :\n  strict_mono (to_add_submonoid : submodule R M → add_submonoid M) := λ _ _, id\n\n@[mono]\nlemma to_add_submonoid_mono : monotone (to_add_submonoid : submodule R M → add_submonoid M) :=\nto_add_submonoid_strict_mono.monotone\n\n@[simp] theorem coe_to_add_submonoid (p : submodule R M) :\n  (p.to_add_submonoid : set M) = p := rfl\n\ntheorem to_sub_mul_action_injective :\n  injective (to_sub_mul_action : submodule R M → sub_mul_action R M) :=\nλ p q h, set_like.ext'_iff.2 (show _, from set_like.ext'_iff.1 h)\n\n@[simp] theorem to_sub_mul_action_eq : p.to_sub_mul_action = q.to_sub_mul_action ↔ p = q :=\nto_sub_mul_action_injective.eq_iff\n\n@[mono] lemma to_sub_mul_action_strict_mono :\n  strict_mono (to_sub_mul_action : submodule R M → sub_mul_action R M) := λ _ _, id\n\n@[mono]\nlemma to_sub_mul_action_mono : monotone (to_sub_mul_action : submodule R M → sub_mul_action R M) :=\nto_sub_mul_action_strict_mono.monotone\n\n@[simp] theorem coe_to_sub_mul_action (p : submodule R M) :\n  (p.to_sub_mul_action : set M) = p := rfl\n\nend submodule\n\nnamespace submodule\n\nsection add_comm_monoid\n\nvariables [semiring R] [add_comm_monoid M]\n\n-- We can infer the module structure implicitly from the bundled submodule,\n-- rather than via typeclass resolution.\nvariables {module_M : module R M}\nvariables {p q : submodule R M}\nvariables {r : R} {x y : M}\n\nvariables (p)\n@[simp] lemma mem_carrier : x ∈ p.carrier ↔ x ∈ (p : set M) := iff.rfl\n\n@[simp] lemma zero_mem : (0 : M) ∈ p := p.zero_mem'\n\nlemma add_mem (h₁ : x ∈ p) (h₂ : y ∈ p) : x + y ∈ p := p.add_mem' h₁ h₂\n\nlemma smul_mem (r : R) (h : x ∈ p) : r • x ∈ p := p.smul_mem' r h\nlemma smul_of_tower_mem [has_scalar S R] [has_scalar S M] [is_scalar_tower S R M]\n  (r : S) (h : x ∈ p) : r • x ∈ p :=\np.to_sub_mul_action.smul_of_tower_mem r h\n\nlemma sum_mem {t : finset ι} {f : ι → M} : (∀c∈t, f c ∈ p) → (∑ i in t, f i) ∈ p :=\np.to_add_submonoid.sum_mem\n\nlemma sum_smul_mem {t : finset ι} {f : ι → M} (r : ι → R)\n    (hyp : ∀ c ∈ t, f c ∈ p) : (∑ i in t, r i • f i) ∈ p :=\nsubmodule.sum_mem _ (λ i hi, submodule.smul_mem  _ _ (hyp i hi))\n\n@[simp] lemma smul_mem_iff' [group G] [mul_action G M] [has_scalar G R] [is_scalar_tower G R M]\n  (g : G) : g • x ∈ p ↔ x ∈ p :=\np.to_sub_mul_action.smul_mem_iff' g\n\ninstance : has_add p := ⟨λx y, ⟨x.1 + y.1, add_mem _ x.2 y.2⟩⟩\ninstance : has_zero p := ⟨⟨0, zero_mem _⟩⟩\ninstance : inhabited p := ⟨0⟩\ninstance [has_scalar S R] [has_scalar S M] [is_scalar_tower S R M] :\n  has_scalar S p := ⟨λ c x, ⟨c • x.1, smul_of_tower_mem _ c x.2⟩⟩\n\ninstance [has_scalar S R] [has_scalar S M] [is_scalar_tower S R M] : is_scalar_tower S R p :=\np.to_sub_mul_action.is_scalar_tower\n\nprotected lemma nonempty : (p : set M).nonempty := ⟨0, p.zero_mem⟩\n\n@[simp] lemma mk_eq_zero {x} (h : x ∈ p) : (⟨x, h⟩ : p) = 0 ↔ x = 0 := subtype.ext_iff_val\n\nvariables {p}\n@[simp, norm_cast] lemma coe_eq_zero {x : p} : (x : M) = 0 ↔ x = 0 :=\n(set_like.coe_eq_coe : (x : M) = (0 : p) ↔ x = 0)\n@[simp, norm_cast] lemma coe_add (x y : p) : (↑(x + y) : M) = ↑x + ↑y := rfl\n@[simp, norm_cast] lemma coe_zero : ((0 : p) : M) = 0 := rfl\n@[norm_cast] lemma coe_smul (r : R) (x : p) : ((r • x : p) : M) = r • ↑x := rfl\n@[simp, norm_cast] lemma coe_smul_of_tower [has_scalar S R] [has_scalar S M] [is_scalar_tower S R M]\n  (r : S) (x : p) : ((r • x : p) : M) = r • ↑x := rfl\n@[simp, norm_cast] lemma coe_mk (x : M) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : M) = x := rfl\n@[simp] lemma coe_mem (x : p) : (x : M) ∈ p := x.2\n\nvariables (p)\n\ninstance : add_comm_monoid p :=\n{ add := (+), zero := 0, .. p.to_add_submonoid.to_add_comm_monoid }\n\ninstance module' [semiring S] [has_scalar S R] [module S M] [is_scalar_tower S R M] : module S p :=\nby refine {smul := (•), ..p.to_sub_mul_action.mul_action', ..};\n   { intros, apply set_coe.ext, simp [smul_add, add_smul, mul_smul] }\ninstance : module R p := p.module'\n\ninstance no_zero_smul_divisors [no_zero_smul_divisors R M] : no_zero_smul_divisors R p :=\n⟨λ c x h,\n  have c = 0 ∨ (x : M) = 0,\n  from eq_zero_or_eq_zero_of_smul_eq_zero (congr_arg coe h),\n  this.imp_right (@subtype.ext_iff _ _ x 0).mpr⟩\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype : p →ₗ[R] M :=\nby refine {to_fun := coe, ..}; simp [coe_smul]\n\n@[simp] theorem subtype_apply (x : p) : p.subtype x = x := rfl\n\nlemma subtype_eq_val : ((submodule.subtype p) : p → M) = subtype.val := rfl\n\n/-- Note the `add_submonoid` version of this lemma is called `add_submonoid.coe_finset_sum`. -/\n@[simp] lemma coe_sum (x : ι → p) (s : finset ι) : ↑(∑ i in s, x i) = ∑ i in s, (x i : M) :=\np.subtype.map_sum\n\nsection restrict_scalars\nvariables (S) [semiring S] [module S M] [module R M] [has_scalar S R] [is_scalar_tower S R M]\n\n/--\n`V.restrict_scalars S` is the `S`-submodule of the `S`-module given by restriction of scalars,\ncorresponding to `V`, an `R`-submodule of the original `R`-module.\n-/\ndef restrict_scalars (V : submodule R M) : submodule S M :=\n{ carrier := V,\n  zero_mem' := V.zero_mem,\n  smul_mem' := λ c m h, V.smul_of_tower_mem c h,\n  add_mem' := λ x y hx hy, V.add_mem hx hy }\n\n@[simp]\nlemma coe_restrict_scalars (V : submodule R M) : (V.restrict_scalars S : set M) = V :=\nrfl\n\n@[simp]\nlemma restrict_scalars_mem (V : submodule R M) (m : M) : m ∈ V.restrict_scalars S ↔ m ∈ V :=\niff.refl _\n\n@[simp]\nlemma restrict_scalars_self (V : submodule R M) : V.restrict_scalars R = V :=\nset_like.coe_injective rfl\n\nvariables (R S M)\n\nlemma restrict_scalars_injective :\n  function.injective (restrict_scalars S : submodule R M → submodule S M) :=\nλ V₁ V₂ h, ext $ set.ext_iff.1 (set_like.ext'_iff.1 h : _)\n\n@[simp] lemma restrict_scalars_inj {V₁ V₂ : submodule R M} :\n  restrict_scalars S V₁ = restrict_scalars S V₂ ↔ V₁ = V₂ :=\n(restrict_scalars_injective S _ _).eq_iff\n\n/-- Even though `p.restrict_scalars S` has type `submodule S M`, it is still an `R`-module. -/\ninstance restrict_scalars.orig_module (p : submodule R M) :\n  module R (p.restrict_scalars S) :=\n(by apply_instance : module R p)\n\ninstance (p : submodule R M) : is_scalar_tower S R (p.restrict_scalars S) :=\n{ smul_assoc := λ r s x, subtype.ext $ smul_assoc r s (x : M) }\n\n/-- `restrict_scalars S` is an embedding of the lattice of `R`-submodules into\nthe lattice of `S`-submodules. -/\n@[simps]\ndef restrict_scalars_embedding : submodule R M ↪o submodule S M :=\n{ to_fun := restrict_scalars S,\n  inj' := restrict_scalars_injective S R M,\n  map_rel_iff' := λ p q, by simp [set_like.le_def] }\n\n/-- Turning `p : submodule R M` into an `S`-submodule gives the same module structure\nas turning it into a type and adding a module structure. -/\n@[simps {simp_rhs := tt}]\ndef restrict_scalars_equiv (p : submodule R M) : p.restrict_scalars S ≃ₗ[R] p :=\n{ to_fun := id, inv_fun := id, map_smul' := λ c x, rfl, .. add_equiv.refl p }\n\nend restrict_scalars\n\nend add_comm_monoid\n\nsection add_comm_group\n\nvariables [ring R] [add_comm_group M]\nvariables {module_M : module R M}\nvariables (p p' : submodule R M)\nvariables {r : R} {x y : M}\n\nlemma neg_mem (hx : x ∈ p) : -x ∈ p := p.to_sub_mul_action.neg_mem hx\n\n/-- Reinterpret a submodule as an additive subgroup. -/\ndef to_add_subgroup : add_subgroup M :=\n{ neg_mem' := λ _, p.neg_mem , .. p.to_add_submonoid }\n\n@[simp] lemma coe_to_add_subgroup : (p.to_add_subgroup : set M) = p := rfl\n\n@[simp] lemma mem_to_add_subgroup : x ∈ p.to_add_subgroup ↔ x ∈ p := iff.rfl\n\ninclude module_M\n\ntheorem to_add_subgroup_injective : injective (to_add_subgroup : submodule R M → add_subgroup M)\n| p q h := set_like.ext (set_like.ext_iff.1 h : _)\n\n@[simp] theorem to_add_subgroup_eq : p.to_add_subgroup = p'.to_add_subgroup ↔ p = p' :=\nto_add_subgroup_injective.eq_iff\n\n@[mono] lemma to_add_subgroup_strict_mono :\n  strict_mono (to_add_subgroup : submodule R M → add_subgroup M) := λ _ _, id\n\n@[mono] lemma to_add_subgroup_mono : monotone (to_add_subgroup : submodule R M → add_subgroup M) :=\nto_add_subgroup_strict_mono.monotone\n\nomit module_M\n\nlemma sub_mem : x ∈ p → y ∈ p → x - y ∈ p := p.to_add_subgroup.sub_mem\n\n@[simp] lemma neg_mem_iff : -x ∈ p ↔ x ∈ p := p.to_add_subgroup.neg_mem_iff\n\nlemma add_mem_iff_left : y ∈ p → (x + y ∈ p ↔ x ∈ p) := p.to_add_subgroup.add_mem_cancel_right\n\nlemma add_mem_iff_right : x ∈ p → (x + y ∈ p ↔ y ∈ p) := p.to_add_subgroup.add_mem_cancel_left\n\ninstance : has_neg p := ⟨λx, ⟨-x.1, neg_mem _ x.2⟩⟩\n\n@[simp, norm_cast] lemma coe_neg (x : p) : ((-x : p) : M) = -x := rfl\n\ninstance : add_comm_group p :=\n{ add := (+), zero := 0, neg := has_neg.neg, ..p.to_add_subgroup.to_add_comm_group }\n\n@[simp, norm_cast] lemma coe_sub (x y : p) : (↑(x - y) : M) = ↑x - ↑y := rfl\n\nend add_comm_group\n\nsection is_domain\n\nvariables [ring R] [is_domain R]\nvariables [add_comm_group M] [module R M] {b : ι → M}\n\nlemma not_mem_of_ortho {x : M} {N : submodule R M}\n  (ortho : ∀ (c : R) (y ∈ N), c • x + y = (0 : M) → c = 0) :\n  x ∉ N :=\nby { intro hx, simpa using ortho (-1) x hx }\n\nlemma ne_zero_of_ortho {x : M} {N : submodule R M}\n  (ortho : ∀ (c : R) (y ∈ N), c • x + y = (0 : M) → c = 0) :\n  x ≠ 0 :=\nmt (λ h, show x ∈ N, from h.symm ▸ N.zero_mem) (not_mem_of_ortho ortho)\n\nend is_domain\n\nsection ordered_monoid\n\nvariables [semiring R]\n\n/-- A submodule of an `ordered_add_comm_monoid` is an `ordered_add_comm_monoid`. -/\ninstance to_ordered_add_comm_monoid\n  {M} [ordered_add_comm_monoid M] [module R M] (S : submodule R M) :\n  ordered_add_comm_monoid S :=\nsubtype.coe_injective.ordered_add_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submodule of a `linear_ordered_add_comm_monoid` is a `linear_ordered_add_comm_monoid`. -/\ninstance to_linear_ordered_add_comm_monoid\n  {M} [linear_ordered_add_comm_monoid M] [module R M] (S : submodule R M) :\n  linear_ordered_add_comm_monoid S :=\nsubtype.coe_injective.linear_ordered_add_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submodule of an `ordered_cancel_add_comm_monoid` is an `ordered_cancel_add_comm_monoid`. -/\ninstance to_ordered_cancel_add_comm_monoid\n  {M} [ordered_cancel_add_comm_monoid M] [module R M] (S : submodule R M) :\n  ordered_cancel_add_comm_monoid S :=\nsubtype.coe_injective.ordered_cancel_add_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submodule of a `linear_ordered_cancel_add_comm_monoid` is a\n`linear_ordered_cancel_add_comm_monoid`. -/\ninstance to_linear_ordered_cancel_add_comm_monoid\n  {M} [linear_ordered_cancel_add_comm_monoid M] [module R M] (S : submodule R M) :\n  linear_ordered_cancel_add_comm_monoid S :=\nsubtype.coe_injective.linear_ordered_cancel_add_comm_monoid coe rfl (λ _ _, rfl)\n\nend ordered_monoid\n\nsection ordered_group\n\nvariables [ring R]\n\n/-- A submodule of an `ordered_add_comm_group` is an `ordered_add_comm_group`. -/\ninstance to_ordered_add_comm_group\n  {M} [ordered_add_comm_group M] [module R M] (S : submodule R M) :\n  ordered_add_comm_group S :=\nsubtype.coe_injective.ordered_add_comm_group coe rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl)\n\n/-- A submodule of a `linear_ordered_add_comm_group` is a\n`linear_ordered_add_comm_group`. -/\ninstance to_linear_ordered_add_comm_group\n  {M} [linear_ordered_add_comm_group M] [module R M] (S : submodule R M) :\n  linear_ordered_add_comm_group S :=\nsubtype.coe_injective.linear_ordered_add_comm_group coe rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl)\n\nend ordered_group\n\nend submodule\n\nnamespace submodule\n\nvariables [division_ring S] [semiring R] [add_comm_monoid M] [module R M]\nvariables [has_scalar S R] [module S M] [is_scalar_tower S R M]\n\nvariables (p : submodule R M) {s : S} {x y : M}\n\ntheorem smul_mem_iff (s0 : s ≠ 0) : s • x ∈ p ↔ x ∈ p :=\np.to_sub_mul_action.smul_mem_iff s0\n\nend submodule\n\n/-- Subspace of a vector space. Defined to equal `submodule`. -/\nabbreviation subspace (R : Type u) (M : Type v)\n  [field R] [add_comm_group M] [module R M] :=\nsubmodule R M\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/module/submodule.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7662936484231889, "lm_q1q2_score": 0.4684981228957437}}
{"text": "/- ------------------------------------------------------------------------- -|\n| @project: riemann_hypothesis                                                |\n| @file:    mathlib/impl.lean                                                 |\n| @authors: Brandon H. Gomes, Alex Kontorovich                                |\n| @affil:   Rutgers University                                                |\n|- ------------------------------------------------------------------------- -/\n\nimport analysis.special_functions.exp_log\nimport topology.metric_space.cau_seq_filter\n\nimport riemann_hypothesis\n\n/-!\n-/\n\nopen riemann_hypothesis\nopen_locale big_operators\n\nnoncomputable theory\n\n/--\n-/\ninstance : Algebra ℝ := {\n    zero := has_zero.zero,\n    one := has_one.one,\n    neg := has_neg.neg,\n    add := has_add.add,\n    sub := has_sub.sub,\n    mul := has_mul.mul,\n    inv := has_inv.inv\n}\n\n/--\n-/\ninstance : Algebra ℂ := {\n    zero := has_zero.zero,\n    one := has_one.one,\n    neg := has_neg.neg,\n    add := has_add.add,\n    sub := has_sub.sub,\n    mul := has_mul.mul,\n    inv := has_inv.inv\n}\n\n/--\n-/\ndef real_explog : ExpLog ℝ ℝ :=\n{\n    exp                   := real.exp,\n    exp_homomorphism_zero := real.exp_zero,\n    exp_homomorphism      := real.exp_add,\n    exp_homomorphism_inv  := λ _ _, by rw [real.exp_sub, division_def],\n    exp_injective         := λ _ _ eq, real.exp_injective eq,\n    exp_monotonic         := λ _ _ lt, real.exp_lt_exp.mpr lt,\n    exp_monotonic_reverse := λ _ _ lt, real.exp_lt_exp.mp lt,\n    exp_positive          := real.exp_pos,\n    log                   := λ a _, real.log a,\n    log_domain_irrel      := λ _ _ _ _ eq, by rw eq,\n    log_inverted          := λ _ apos, by rw real.exp_log apos,\n}\n\n/--\n-/\ndef complex_witness.proofs.abs_exp_is_exp_real_part\n    : Π z, complex.abs (complex.exp z) = real.exp (complex.re z) :=\nbegin\n    intros,\n    rw [← complex.exp_of_real_re,\n          complex.abs_exp_eq_iff_re_eq.mpr,\n        ← complex.of_real_exp,\n          complex.abs_of_real,\n          abs_of_pos (real.exp_pos _)],\n    repeat { refine rfl },\nend\n\n/--\n-/\ndef lim_le (f : cau_seq ℝ abs) (g : cau_seq ℝ abs)\n    : (∃ j, ∀ i, j ≤ i → f i ≤ g i) → f.lim ≤ g.lim :=\nbegin\n  intros,\n  refine le_of_tendsto_of_tendsto (cau_seq.tendsto_limit _) (cau_seq.tendsto_limit _) _,\n  rwa [filter.eventually_le, filter.eventually_at_top],\nend\n\n/--\n-/\ndef unit_circle_pow_lemma\n    : Π x, complex.abs x ≤ 1 → Π (n : ℕ), complex.abs (x ^ n) ≤ 1 :=\nbegin\n    intros _ x_le_1 _,\n    induction n with n hn,\n        simp,\n        rw pow_succ,\n        refine le_trans _ hn,\n        rw is_absolute_value.abv_pow complex.abs,\n        rw complex.abs_mul,\n        rw (_ : complex.abs x ^ n = 1 * complex.abs x ^ n),\n        refine mul_le_mul\n            x_le_1 (le_of_eq (is_absolute_value.abv_pow _ _ _)) (complex.abs_nonneg _) zero_le_one,\n        simp,\nend\n\n/--\n-/\ndef complex_witness.proofs.exp_linearization\n    : Π x, complex.abs x ≤ 1\n    → Π z, complex.abs (complex.exp (x * z) - (x * z + 1))\n        ≤ (complex.abs x * complex.abs x) * real.exp (complex.abs z) :=\nbegin\n    intros _ x_le_1 _,\n    rw complex.exp,\n    rw ← cau_seq.lim_const (x*z+1),\n    rw sub_eq_add_neg,\n    rw ← cau_seq.lim_neg,\n    rw cau_seq.lim_add,\n    rw ← complex.lim_abs,\n    rw real.exp,\n    rw complex.exp,\n    rw ← complex.lim_re,\n    rw ← cau_seq.lim_const ((complex.abs x) * (complex.abs x)),\n    rw cau_seq.lim_mul_lim,\n    rw mul_comm (cau_seq.const _ _),\n\n    refine lim_le _ _ _,\n    existsi 2,\n    intros i i_ge_2,\n\n    rw (complex.cau_seq_re _).mul_apply,\n\n    rw (_ : (complex.cau_seq_re (complex.exp' ↑(complex.abs z))) i\n          = (∑ k in finset.range i, ((complex.abs z) : ℂ) ^ k / k.fact).re),\n\n    rw ← (finset.range _).sum_hom complex.re,\n    norm_cast,\n\n    show complex.abs (∑ k in finset.range i, (x * z) ^ k / k.fact - (x * z + 1))\n            ≤ (∑ k in finset.range i, (complex.abs z) ^ k / k.fact) * (complex.abs x * complex.abs x),\n\n    rw (_ : (x * z + 1) = ∑ k in finset.range 2, (x * z) ^ k / ↑(k.fact)),\n\n    rw sum_range_sub_sum_range i_ge_2,\n\n    rw (_ : complex.abs (∑ k in (finset.range i).filter (λ k, 2 ≤ k), (x * z) ^ k / ↑(k.fact))\n          = complex.abs (∑ k in (finset.range i).filter (λ k, 2 ≤ k), x ^ 2 * x ^ (k - 2) * z ^ k / ↑(k.fact))),\n\n    rw (_ : (∑ k in finset.range i, complex.abs z ^ k / ↑(k.fact))\n          = (∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact) + (1 + complex.abs z))),\n\n    rw (_ : (∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact) + (1 + complex.abs z))\n          * (complex.abs x * complex.abs x)\n          = complex.abs x ^ 2\n          * (∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact) + (1 + complex.abs z))),\n\n    have drop_extra_powers_of_x\n        : complex.abs (∑ k in (finset.range i).filter (λ k, 2 ≤ k), x ^ 2 * x ^ (k - 2) * z ^ k / ↑(k.fact))\n        ≤ ∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs x ^ 2 * (complex.abs z ^ k / ↑(k.fact)),\n    {\n        refine le_trans (abv_sum_le_sum_abv _ _) (finset.sum_le_sum (λ m _, _)),\n\n        rw mul_div_assoc,\n        rw complex.abs_mul,\n        rw complex.abs_mul,\n        rw is_absolute_value.abv_pow complex.abs,\n        rw complex.abs_div,\n        rw complex.abs_cast_nat,\n        rw ← mul_div_assoc,\n        rw division_def,\n        rw division_def,\n        rw ← is_absolute_value.abv_pow complex.abs z,\n        rw ← mul_assoc,\n\n        refine mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right _ (complex.abs_nonneg _)) (by simp),\n\n        have : complex.abs x ^ 2 * complex.abs (x ^ (m - 2)) ≤ complex.abs x ^ 2 * 1,\n            by refine mul_le_mul_of_nonneg_left (unit_circle_pow_lemma _ x_le_1 _) (pow_nonneg (complex.abs_nonneg _) _),\n\n        simp at this,\n        refine this,\n    },\n\n    simp [abs_mul, is_absolute_value.abv_pow complex.abs, complex.abs_div, finset.mul_sum.symm]\n        at drop_extra_powers_of_x,\n\n    refine le_trans drop_extra_powers_of_x (mul_le_mul (le_refl _) _ _ (pow_nonneg (complex.abs_nonneg _) _)),\n\n    rw (_ : ∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact)\n          = ∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact) + 0),\n\n    rw (_ : ∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact) + 0 + (1 + complex.abs z)\n          = ∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact) + (1 + complex.abs z)),\n\n    refine add_le_add_left _ (∑ k in (finset.range i).filter (λ k, 2 ≤ k), complex.abs z ^ k / ↑(k.fact)),\n    rw (_ : (0 : ℝ) = 0 + 0),\n    refine add_le_add (by linarith) (complex.abs_nonneg _),\n    simp,\n    simp,\n    simp,\n    rw (_ : (0 : ℝ) = ∑ k in (finset.range i).filter (λ k, 2 ≤ k), 0),\n    refine finset.sum_le_sum _,\n    intros m _,\n    rw (_ : complex.abs z ^ m / (m.fact : ℝ) = complex.abs z ^ m * (1 / (m.fact : ℝ))),\n    refine mul_nonneg _ _,\n    rw ← is_absolute_value.abv_pow complex.abs,\n    refine complex.abs_nonneg _,\n    refine le_of_lt (one_div_pos.mpr _),\n    norm_cast,\n    refine nat.fact_pos _,\n    ring,\n    refine (finset.sum_eq_zero _).symm,\n    intros,\n    refine rfl,\n    ring,\n    rw (_ : (1 + complex.abs z) = ∑ k in finset.range 2, (complex.abs z) ^ k / ↑(k.fact)),\n    rw ← sum_range_sub_sum_range i_ge_2,\n    simp,\n    simp [sub_eq_add_neg, finset.sum_range_succ, add_assoc],\n    ring,\n    refine congr_arg complex.abs _,\n    refine finset.sum_congr rfl _,\n    intros,\n    rw mul_pow,\n    rw ← pow_add,\n    rw nat.add_sub_cancel',\n    simp at H,\n    refine H.2,\n    simp [sub_eq_add_neg, finset.sum_range_succ, add_assoc],\n    refine rfl,\nend\n\n/--\n-/\ndef complex_witness.proofs.real_log_bound\n    : Π (x : ℝ) (p : 0 < 1 - x),\n        complex.abs ↑x ≤ 2⁻¹ → complex.abs ↑(real.log (1 - x)) ≤ complex.abs ↑x + complex.abs ↑x :=\nbegin\n    intros _ _ x_le_half,\n    rw complex.abs_of_real at x_le_half,\n    simp,\n\n    have ineq0 : abs (∑ i in finset.range 0, x ^ (i + 1) / (↑i + 1) + real.log (1 - x))\n               ≤ abs x ^ (0 + 1) / (1 - abs x),\n    {\n        refine real.abs_log_sub_add_sum_range_le _ _,\n        rw (_ : (2 : ℝ)⁻¹ = 1 / 2) at x_le_half,\n        linarith,\n        simp,\n    },\n    simp at ineq0,\n\n    rw (_: abs x + abs x = abs x / (1 - 2⁻¹)),\n\n    have ineq1 : -(2⁻¹) ≤ -(abs x),\n        by refine neg_le_neg x_le_half,\n\n    have ineq2 : 1 - 2⁻¹ ≤ 1 - abs x,\n        by refine sub_le_sub_left x_le_half _,\n\n    have ineq3 : (1 - abs x)⁻¹ ≤ (1 - 2⁻¹)⁻¹,\n    {\n        refine inv_le_inv_of_le _ _,\n        simp,\n        rw (_ : (2 : ℝ)⁻¹ = 1 / 2),\n        linarith,\n        simp,\n        refine ineq2,\n    },\n\n    have ineq4 : abs x / (1 - abs x) ≤ abs x / (1 - 2⁻¹) ,\n    {\n        rw (_ : abs x / (1 - abs x) = (1 - abs x)⁻¹ * abs x),\n        rw (_ : abs x / (1 - 2⁻¹) = (1 - 2⁻¹)⁻¹ * abs x),\n        refine mul_le_mul ineq3 _ _ _,\n        refine le_refl _,\n        refine abs_nonneg _,\n        rw (_: (1 - (2 : ℝ)⁻¹)⁻¹ = 2),\n        linarith,\n        ring,\n        ring,\n        ring,\n    },\n\n    linarith,\n    ring,\nend\n\n/--\n-/\ndef complex_witness : Complex ℂ ℝ :=\n{\n    real_part                := complex.re,\n    abs                      := complex.abs,\n    exp                      := complex.exp,\n    real_explog              := real_explog,\n    abs_nonneg               := complex.abs_nonneg,\n    exp_nonzero              := complex.exp_ne_zero,\n    exp_homomorphism_zero    := complex.exp_zero,\n    exp_homomorphism         := complex.exp_add,\n    exp_homomorphism_inv     := λ _ _, by rw [complex.exp_sub, division_def],\n    real_part_scaling        := λ _ _, by rw [complex.mul_re, complex.of_real_im, complex.of_real_re, zero_mul, sub_zero],\n    abs_exp_is_exp_real_part := complex_witness.proofs.abs_exp_is_exp_real_part,\n    exp_linearization        := complex_witness.proofs.exp_linearization,\n    real_log_bound           := complex_witness.proofs.real_log_bound\n}\n", "meta": {"author": "bhgomes", "repo": "lean-riemann-hypothesis", "sha": "c36b744a2dc4a7a50c7de770096bd9a051f42ab9", "save_path": "github-repos/lean/bhgomes-lean-riemann-hypothesis", "path": "github-repos/lean/bhgomes-lean-riemann-hypothesis/lean-riemann-hypothesis-c36b744a2dc4a7a50c7de770096bd9a051f42ab9/src/mathlib/impl.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936324115011, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46849811310648637}}
{"text": "import .add\n\nnoncomputable theory\n\nnamespace hidden\n\nopen myring\nopen ordered_myring\nopen myfield\nopen ordered_myfield\nopen ordered_integral_domain\n\nnamespace cau_seq\n\n-- The proof is very similar to the one we use for real series in analysis.\n-- We bound the absolute values of each of the series above, and\n-- use the ax - by = a(x - y) + y(a - b) trick, along with the\n-- triangle inequality and some appropriately chosen eventual bounds\n-- on |x - y| and |a - b|\ndef mul : cau_seq → cau_seq → cau_seq :=\nλ f g, ⟨λ n, f.val n * g.val n,\nbegin\n  have hf := f.property,\n  have hg := g.property,\n  dsimp only [is_cau_seq] at *,\n  intros ε hε,\n  -- Use the fact that f and g have bounded absolute value\n  cases cau_seq.abs_bounded_above f with uf huf,\n  cases huf with hufpos huf,\n  cases cau_seq.abs_bounded_above g with ug hug,\n  cases hug with hugpos hug,\n  -- to create some \"magical\" bound on the difference between\n  -- term m and n\n  have hεfpos : 0 < (ε / 2) / ug,\n    rw [div_def, ←zero_mul (0 : myrat)],\n    apply @lt_mul_comb_nonneg _ _ (0 : myrat) _ 0 _ (by refl) (by refl),\n      from half_pos hε,\n    from pos_impl_inv_pos hugpos,\n  have hεgpos : 0 < (ε / 2) / uf,\n    rw [div_def, ←zero_mul (0 : myrat)],\n    apply @lt_mul_comb_nonneg _ _ (0 : myrat) _ 0 _ (by refl) (by refl),\n      from half_pos hε,\n    from pos_impl_inv_pos hufpos,\n  cases hf ((ε / 2) / ug) hεfpos with M hM,\n  cases hg ((ε / 2) / uf) hεgpos with N hN,\n  clear hεfpos hεgpos hf hg, -- Tidy a bit\n  -- Obvious facts are obvious\n  existsi mynat.max M N,\n  intros m n hm hn,\n  have hMm : M ≤ m, from mynat.max_le_cancel_left hm,\n  have hMn : M ≤ n, from mynat.max_le_cancel_left hn,\n  have hNm : N ≤ m, from mynat.max_le_cancel_right hm,\n  have hNn : N ≤ n, from mynat.max_le_cancel_right hn,\n  clear hm hn,\n  -- Now we need to use the \"trick\"\n  have : f.val n * g.val n - f.val m * g.val m =\n         f.val n * (g.val n - g.val m) + g.val m * (f.val n - f.val m),\n  {\n    repeat { rw sub_def <|> rw mul_add <|> rw mul_neg },\n    have : f.val n * g.val n + -(f.val n * g.val m) + (g.val m * f.val n + -(g.val m * f.val m)) =\n           f.val n * g.val n + - (f.val m * g.val m) + (f.val n * g.val m + - (f.val n * g.val m)),\n      ac_refl,\n    rw this, clear this,\n    rw [add_neg, add_zero],\n  },\n  rw this, clear this,\n  -- And the triangle inequality\n  have : abs (f.val n * (g.val n - g.val m) + g.val m * (f.val n - f.val m)) ≤\n         abs (f.val n * (g.val n - g.val m)) + abs (g.val m * (f.val n - f.val m)),\n    apply triangle_ineq,\n  apply le_lt_chain (abs (f.val n * (g.val n - g.val m)) +\n                           abs (g.val m * (f.val n - f.val m))),\n    assumption,\n  clear this,\n  -- Abs distrib over mul\n  rw [abs_mul, abs_mul],\n  -- Apply given hypotheses, after lots of rearranging so lean gets it\n  -- Needed for rearranging\n  have huf0 : uf ≠ 0,\n    assume hufeq0,\n    from lt_impl_ne hufpos hufeq0.symm,\n  -- hug0 is frying right now\n  have hug0 : ug ≠ 0,\n    assume hugeq0,\n    from lt_impl_ne hugpos hugeq0.symm,\n  -- We juggle a bit so we can simply apply lt_comb\n  conv {\n    to_rhs,\n    rw ←half_plus_half myrat.two_nzero ε,\n    congr,\n      rw ←div_mul_cancel (ε / 2) uf huf0,\n      rw mul_comm,\n      skip,\n    rw ←div_mul_cancel (ε / 2) ug hug0,\n    rw mul_comm,\n  },\n  -- This meaty line converts one goal into 8! (fortunately not 40320)\n  apply lt_comb; apply lt_mul_comb_nonneg,\n  -- Fortunately we can kill half of them in one go\n  any_goals { apply abs_nonneg, },\n  -- And the others are things we worked out earlier\n  {\n    from huf n,\n  }, {\n    from hN m n hNm hNn,\n  }, {\n    from hug m,\n  }, {\n    from hM m n hMm hMn,\n  },\nend⟩\n\ninstance: has_mul cau_seq := ⟨mul⟩\n\ntheorem mul_val {a b : cau_seq} {n : mynat} : (a * b).val n = a.val n * b.val n := rfl\n\ntheorem mul_comm (a b : cau_seq) : a * b = b * a :=\nbegin\n  apply cau_seq.seq_eq_impl_eq,\n  intro n,\n  rw [mul_val, mul_val, myring.mul_comm],\nend\n\nopen classical\n\nlocal attribute [instance] classical.prop_decidable\n\ndef inv: cau_seq → cau_seq :=\nλ f : cau_seq, ⟨(λ n : mynat, if f ≈ (0 : cau_seq) then 0 else (f.val n)⁻¹),\nbegin\n  unfold is_cau_seq,\n  intros ε hε,\n  by_cases (f ≈ (0 : cau_seq)),\n    existsi (0 : mynat),\n    intros m n hm hn,\n    rwa [if_pos h, if_pos h, sub_def, zero_add, abs_neg, abs_zero],\n  have hf := f.property,\n  unfold is_cau_seq at hf,\n  cases cau_seq.nzero_impl_abs_eventually_bounded_below f h with A hA,\n  cases hA with N hN,\n  have h0AAε : 0 < A * (A * ε), {\n    rw ←mul_zero (0 : myrat),\n    apply @lt_mul_comb_nonneg _ _ 0 A 0 (A*ε) (by refl) (by refl) hN.left,\n    rw ←mul_zero (0 : myrat),\n    apply @lt_mul_comb_nonneg _ _ 0 A 0 ε (by refl) (by refl) hN.left,\n    assumption,\n  },\n  cases hf (A*(A*ε)) h0AAε with M hM,\n  existsi (mynat.max M N),\n  intros m n hm hn,\n  rw [if_neg h, if_neg h],\n  have hnpos : 0 < abs (f.val n), {\n    transitivity A,\n      from hN.left,\n    apply hN.right n,\n    from mynat.max_le_cancel_right hn,\n  },\n  have hnzero: f.val n ≠ 0, {\n    assume this,\n    rw this at hnpos,\n    rw abs_zero at hnpos,\n    apply lt_nrefl (0 : myrat),\n    assumption,\n  },\n  rw lt_mul_pos_left _ hnpos,\n  rw [←abs_mul, sub_def, mul_add, mul_inv hnzero],\n  have hmpos : 0 < abs (f.val m), {\n    transitivity A,\n      from hN.left,\n    apply hN.right m,\n    from mynat.max_le_cancel_right hm,\n  },\n  have hmzero: f.val m ≠ 0, {\n    assume this,\n    rw this at hmpos,\n    rw abs_zero at hmpos,\n    apply lt_nrefl (0 : myrat),\n    assumption,\n  },\n  rw [lt_mul_pos_left _ hmpos, ←abs_mul, mul_add, mul_one, ←mul_assoc,\n      myring.mul_comm, neg_mul, ←mul_assoc, inv_mul hmzero, one_mul, ←sub_def],\n  suffices: A * (A * ε) ≤ abs (f.val m) * ((abs (f.val n)) * ε),\n    apply lt_le_chain (A * (A * ε)),\n    apply hM,\n      from mynat.max_le_cancel_left hn,\n      from mynat.max_le_cancel_left hm,\n    assumption,\n  apply le_mul_comb_nonneg, {\n    from lt_impl_le hN.left,\n  }, {\n    rw ←zero_mul (0 : myrat),\n    apply le_mul_comb_nonneg,\n    refl, refl,\n    from lt_impl_le hN.left,\n    from lt_impl_le hε,\n  }, {\n    have := hN.right m (mynat.max_le_cancel_right hm),\n    apply lt_impl_le,\n    assumption,\n  },\n  apply le_mul_comb_nonneg, {\n    from lt_impl_le hN.left,\n  }, {\n    from lt_impl_le hε,\n  }, {\n    have := hN.right n (mynat.max_le_cancel_right hn),\n    apply lt_impl_le,\n    assumption,\n  },\n  refl,\nend⟩\n\ninstance: has_inv cau_seq := ⟨inv⟩\n\n-- Lemma to help rewrite definitional equalities\nlemma inv_val (f : cau_seq) (n : mynat) :\n(f⁻¹).val n = if f ≈ (0 : cau_seq) then 0 else (f.val n)⁻¹ :=\nrfl\n\ntheorem inv_equiv_zero (a : cau_seq) (h : a ≈ 0) : a⁻¹ ≈ 0 :=\nbegin\n  apply cau_seq.seq_eq_impl_cau_seq_equiv,\n  intro n,\n  rw [inv_val, if_pos],\n  refl,\n  assumption,\nend\n\nend cau_seq\n\nnamespace real\n\nprivate theorem mul_equiv (a b x : cau_seq) (hab : a ≈ b) : a * x ≈ b * x :=\nbegin\n  rw cau_seq.setoid_equiv at *,\n  intros q hq,\n  cases cau_seq.abs_bounded_above x with u hu,\n  cases hu with hu h,\n  have hqu : 0 < q * u⁻¹,\n    apply zero_lt_mul,\n      assumption,\n    apply pos_impl_inv_pos,\n    assumption,\n  cases hab (q * u⁻¹) hqu with N hN,\n  existsi N,\n  intros n hn,\n  rw [cau_seq.mul_val, cau_seq.mul_val, ←sub_mul, abs_mul,\n     lt_mul_pos_right u⁻¹ (pos_impl_inv_pos hu)],\n  apply le_lt_chain (abs (a.val n - b.val n)), {\n    conv {\n      to_rhs,\n      rw ←mul_one (abs (a.val n - b.val n)),\n    },\n    rw mul_assoc,\n    apply le_mul_comb_nonneg, {\n      exact abs_nonneg _,\n    }, {\n      apply zero_le_mul,\n        exact abs_nonneg _,\n      apply lt_impl_le,\n      apply pos_impl_inv_pos,\n      assumption,\n    }, {\n      refl,\n    }, {\n      have this : u ≠ 0,\n        assume hu0,\n        apply lt_impl_ne hu,\n        symmetry, assumption,\n      rw ←mul_inv this,\n      have huinv : 0 ≤ u⁻¹,\n        apply lt_impl_le,\n        apply pos_impl_inv_pos,\n        assumption,\n      apply le_mul_nonneg_right _ _ u⁻¹ huinv,\n      apply lt_impl_le,\n      exact h n,\n    },\n  }, {\n    exact hN n hn,\n  },\nend\n\ndef mul : real → real → real :=\nquotient.lift₂ (λ f g, ⟦f * g⟧)\nbegin\n  intros a x b y hab hxy,\n  dsimp only [],\n  rw [cau_seq.class_equiv, ←cau_seq.setoid_equiv],\n  apply @setoid.trans _ _ _ (b * x),\n    apply mul_equiv a b x,\n    assumption,\n  rw [cau_seq.mul_comm b, cau_seq.mul_comm b],\n  apply mul_equiv x y b,\n  assumption,\nend\n\ninstance: has_mul real := ⟨mul⟩\n\ntheorem mul_eq_cls {a b : cau_seq} {x y : real} :\nx = ⟦a⟧ → y = ⟦b⟧ → x * y = ⟦a * b⟧ :=\nλ hax hby, by rw [hax, hby]; refl\n\nopen classical\n\nlocal attribute [instance] classical.prop_decidable\n\ndef inv: real → real :=\nquotient.lift (λ f, ⟦f⁻¹⟧)\nbegin\n  intros a b hab,\n  have ha := a.property,\n  have hb := b.property,\n  dsimp only [],\n  by_cases ha0: a ≈ (0 : cau_seq), {\n    have: b ≈ (0 : cau_seq),\n      apply @setoid.trans cau_seq _ b a 0,\n        apply @setoid.symm cau_seq _ a b,\n        assumption,\n      assumption,\n    rw [cau_seq.class_equiv, ←cau_seq.setoid_equiv],\n    apply @setoid.trans cau_seq _ a⁻¹ 0 b⁻¹,\n      apply cau_seq.inv_equiv_zero,\n      assumption,\n    apply @setoid.symm cau_seq _ _ _,\n    apply cau_seq.inv_equiv_zero,\n    assumption,\n  }, {\n    have hb0 : ¬b ≈ (0 : cau_seq),\n      assume hb0,\n      apply ha0,\n      apply @setoid.trans cau_seq _ a b 0,\n        assumption,\n      assumption,\n    cases cau_seq.nzero_impl_abs_eventually_bounded_below a ha0 with A hA,\n    cases cau_seq.nzero_impl_abs_eventually_bounded_below b hb0 with B hB,\n    cases hA with N₁ hN₁,\n    cases hB with N₂ hN₂,\n    rw cau_seq.class_equiv,\n    rw cau_seq.setoid_equiv at hab,\n    dsimp only [cau_seq.equivalent] at hab ⊢,\n    intros ε hε,\n    have h0ABε : 0 < A * (B * ε), {\n      rw ←zero_mul (0 : myrat),\n      apply @lt_mul_comb_nonneg _ _  (0 : myrat) _ 0 _ (by refl) (by refl) hN₁.left,\n      rw ←zero_mul (0 : myrat),\n      apply @lt_mul_comb_nonneg _ _ (0 : myrat) _ 0 _ (by refl) (by refl) hN₂.left hε,\n    },\n    cases hab (A * (B * ε)) h0ABε with N₃ hN₃,\n    existsi mynat.max (mynat.max N₁ N₂) N₃,\n    intros n hn,\n    rw [cau_seq.inv_val, cau_seq.inv_val, if_neg ha0, if_neg hb0],\n    have hanpos : 0 < abs (a.val n), {\n      transitivity A,\n        from hN₁.left,\n      apply hN₁.right n,\n      apply @mynat.max_le_cancel_left _ N₂ _,\n      apply @mynat.max_le_cancel_left _ N₃ _,\n      assumption,\n    },\n    have hbnpos : 0 < abs (b.val n), {\n      transitivity B,\n        from hN₂.left,\n      apply hN₂.right n,\n      apply @mynat.max_le_cancel_right N₁ _ _,\n      apply @mynat.max_le_cancel_left _ N₃ _,\n      assumption,\n    },\n    have hanzero : a.val n ≠ 0, {\n      assume this,\n      rw this at hanpos,\n      rw abs_zero at hanpos,\n      apply lt_nrefl (0 : myrat),\n      assumption,\n    },\n    have hbnzero : b.val n ≠ 0, {\n      assume this,\n      rw this at hbnpos,\n      rw abs_zero at hbnpos,\n      apply lt_nrefl (0 : myrat),\n      assumption,\n    },\n    -- A small amount of rearranging...\n    rw [lt_mul_pos_left _ hanpos, ←abs_mul, sub_def, mul_add,\n        mul_inv hanzero, lt_mul_pos_left _ hbnpos, ←abs_mul,\n        mul_add, mul_one, mul_neg, mul_neg, add_comm,\n        mul_comm (a.val n), ←mul_assoc, mul_inv hbnzero,\n        one_mul, ←abs_neg, neg_distr, neg_neg, ←sub_def],\n    apply lt_le_chain (A * (B * ε)), {\n      apply hN₃ n,\n      apply mynat.max_le_cancel_right hn,\n    }, {\n      rw [←mul_assoc (abs (b.val n)), mul_comm (abs (b.val n)), mul_assoc (abs (a.val n))],\n      apply le_mul_comb_nonneg, {\n        from lt_impl_le hN₁.left,\n      }, {\n        rw ←zero_mul (0 : myrat),\n        apply @le_mul_comb_nonneg _ _ (0 : myrat) _ _ _ (by refl) (by refl),\n        from lt_impl_le hN₂.left,\n        from lt_impl_le hε,\n      }, {\n        apply lt_impl_le,\n        apply hN₁.right n,\n        apply @mynat.max_le_cancel_left _ N₂ _,\n        apply @mynat.max_le_cancel_left _ N₃ _,\n        assumption,\n      },\n      apply le_mul_comb_nonneg, {\n        from lt_impl_le hN₂.left,\n      }, {\n        from lt_impl_le hε,\n      }, {\n        apply lt_impl_le,\n        apply hN₂.right n,\n        apply @mynat.max_le_cancel_right N₁ _ _,\n        apply @mynat.max_le_cancel_left _ N₃ _,\n        assumption,\n      },\n      refl,\n    },\n  },\nend\n\ninstance: has_inv real := ⟨inv⟩\n\ntheorem inv_eq_cls {a : cau_seq} {x : real} :\nx = ⟦a⟧ → x⁻¹ = ⟦a⁻¹⟧ :=\nλ hax, by rw hax; refl\n\nvariables x y z : real\n\n-- Use a b c for corresponding sequences\n\nprivate theorem mul_comm (x y : real): x * y = y * x :=\nbegin\n  cases quotient.exists_rep x with a ha,\n  cases quotient.exists_rep y with b hb,\n  have hxy := mul_eq_cls ha.symm hb.symm,\n  have hyx := mul_eq_cls hb.symm ha.symm,\n  apply seq_eq_imp_real_eq hxy hyx,\n  intro n,\n  repeat { rw cau_seq.mul_val, },\n  rw mul_comm,\nend\n\nprivate theorem mul_zero: x * 0 = 0 :=\nbegin\n  cases quotient.exists_rep x with a ha,\n  apply seq_eq_imp_real_eq (mul_eq_cls ha.symm real_zero) real_zero,\n  intro n,\n  rw cau_seq.mul_val,\n  dsimp only [],\n  rw mul_zero,\nend\n\nprivate theorem mul_one: x * 1 = x :=\nbegin\n  cases quotient.exists_rep x with a ha,\n  apply seq_eq_imp_real_eq (mul_eq_cls ha.symm real_one) ha.symm,\n  intro n,\n  rw cau_seq.mul_val,\n  dsimp only [],\n  rw mul_one,\nend\n\nprivate theorem mul_assoc: x * y * z = x * (y * z) :=\nbegin\n  cases quotient.exists_rep x with a ha,\n  cases quotient.exists_rep y with b hb,\n  cases quotient.exists_rep z with c hc,\n  have h₁: x * y * z = ⟦a * b * c⟧,\n    rw mul_eq_cls, rw mul_eq_cls,\n    repeat { symmetry, assumption, },\n  have h₂: x * (y * z) = ⟦a * (b * c)⟧,\n    rw mul_eq_cls,\n    symmetry, assumption,\n    rw mul_eq_cls,\n    symmetry, assumption,\n    symmetry, assumption,\n  apply seq_eq_imp_real_eq h₁ h₂,\n  intro n,\n  repeat { rw cau_seq.mul_val, },\n  rw mul_assoc,\nend\n\nprivate theorem mul_add: x * (y + z) = x * y + x * z :=\nbegin\n  cases quotient.exists_rep x with a ha,\n  cases quotient.exists_rep y with b hb,\n  cases quotient.exists_rep z with c hc,\n  have h₁: x * (y + z) = ⟦a * (b + c)⟧,\n    rw mul_eq_cls,\n    symmetry, assumption,\n    rw add_eq_cls,\n    symmetry, assumption,\n    symmetry, assumption,\n  have h₂: x * y + x * z = ⟦a * b + a * c⟧,\n    rw add_eq_cls,\n    rw mul_eq_cls,\n    repeat { symmetry, assumption, },\n    rw mul_eq_cls,\n    repeat { symmetry, assumption, },\n  apply seq_eq_imp_real_eq h₁ h₂,\n  intro n,\n  rw [cau_seq.add_val, cau_seq.mul_val, cau_seq.add_val, cau_seq.mul_val,\n      cau_seq.mul_val, mul_add],\nend\n\n-- Reciprocal \"inv\"\n\n-- We can't actually prove this in general fields so why not\n@[simp]\ntheorem zero_inv : 0⁻¹ = (0 : real) :=\nbegin\n  have h : (0 : real)⁻¹ = ⟦0⁻¹⟧,\n    apply inv_eq_cls real_zero,\n  apply seq_eq_imp_real_eq h real_zero,\n  intro n,\n  dsimp only [],\n  rw [cau_seq.inv_val, if_pos],\n  apply @setoid.refl _ _ _,\nend\n\nprivate theorem not_equiv_zero_impl_eventually_nzero (f : cau_seq) :\n¬f ≈ 0 → ∃ N : mynat, ∀ n, N ≤ n → f.val n ≠ 0 :=\nbegin\n  intros hnf0,\n  cases cau_seq.nzero_impl_abs_eventually_bounded_below f hnf0 with δ h,\n  cases h with N h,\n  cases h with hδ h,\n  existsi N,\n  intros n hn,\n  have := h n hn,\n  intro hfval0,\n  have habsfval : abs (f.val n) = 0,\n    rw [hfval0, abs_zero],\n  suffices : 0 < abs (f.val n),\n    exact lt_impl_ne this habsfval.symm,\n  transitivity δ; assumption,\nend\n\nprivate theorem mul_inv : x ≠ 0 → x * x⁻¹ = 1 :=\nbegin\n  intro hx0,\n  cases quotient.exists_rep x with f hf,\n  rw [inv_eq_cls hf.symm, ←hf, @mul_eq_cls f f⁻¹ ⟦f⟧ _ (by refl) (by refl)],\n  rw [real_one, coe_def, cau_seq.class_equiv],\n  unfold cau_seq.equivalent,\n  intros ε hε,\n  have hnf0 : ¬f ≈ 0,\n    assume hf0,\n    apply hx0,\n    rwa [←hf, real_zero, coe_def, cau_seq.class_equiv],\n  cases not_equiv_zero_impl_eventually_nzero f hnf0 with N hN,\n  existsi N,\n  intros n hn,\n  dsimp,\n  have := hN n hn,\n  rwa [cau_seq.mul_val, cau_seq.inv_val, if_neg hnf0, myfield.mul_inv this,\n      sub_self, abs_zero],\nend\n\nlocal attribute [instance] prop_decidable\n\ninstance: myring real := ⟨\n  by apply_instance,\n  real.add_assoc,\n  real.add_zero,\n  real.add_neg,\n  mul_assoc,\n  mul_comm,\n  mul_one,\n  mul_add,\n⟩\n\ninstance : myfield real := {\n  mul_inv := mul_inv,\n  nontrivial := real.nontrivial,\n}\n\nend real\n\nend hidden\n", "meta": {"author": "Sterrs", "repo": "leaning", "sha": "3901cc953694b33adda86cb88ca30ba99594db31", "save_path": "github-repos/lean/Sterrs-leaning", "path": "github-repos/lean/Sterrs-leaning/leaning-3901cc953694b33adda86cb88ca30ba99594db31/src/principia/real/mul.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4684858201531015}}
{"text": "example : ∀ (l : list ℕ), list.append l (0 :: list.nil) ≠ list.nil :=\nby intros; induction l; simp *\n", "meta": {"author": "zeptometer", "repo": "LearnLean", "sha": "bb84d5dbe521127ba134d4dbf9559b294a80b9f7", "save_path": "github-repos/lean/zeptometer-LearnLean", "path": "github-repos/lean/zeptometer-LearnLean/LearnLean-bb84d5dbe521127ba134d4dbf9559b294a80b9f7/bluejam/topprover/09.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920116079208, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4684858201531014}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport logic.equiv.local_equiv\nimport topology.sets.opens\n\n/-!\n# Local homeomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines homeomorphisms between open subsets of topological spaces. An element `e` of\n`local_homeomorph α β` is an extension of `local_equiv α β`, i.e., it is a pair of functions\n`e.to_fun` and `e.inv_fun`, inverse of each other on the sets `e.source` and `e.target`.\nAdditionally, we require that these sets are open, and that the functions are continuous on them.\nEquivalently, they are homeomorphisms there.\n\nAs in equivs, we register a coercion to functions, and we use `e x` and `e.symm x` throughout\ninstead of `e.to_fun x` and `e.inv_fun x`.\n\n## Main definitions\n\n`homeomorph.to_local_homeomorph`: associating a local homeomorphism to a homeomorphism, with\n                                  source = target = univ\n`local_homeomorph.symm`  : the inverse of a local homeomorphism\n`local_homeomorph.trans` : the composition of two local homeomorphisms\n`local_homeomorph.refl`  : the identity local homeomorphism\n`local_homeomorph.of_set`: the identity on a set `s`\n`eq_on_source`           : equivalence relation describing the \"right\" notion of equality for local\n                           homeomorphisms\n\n## Implementation notes\n\nMost statements are copied from their local_equiv versions, although some care is required\nespecially when restricting to subsets, as these should be open subsets.\n\nFor design notes, see `local_equiv.lean`.\n\n### Local coding conventions\n\nIf a lemma deals with the intersection of a set with either source or target of a `local_equiv`,\nthen it should use `e.source ∩ s` or `e.target ∩ t`, not `s ∩ e.source` or `t ∩ e.target`.\n-/\n\nopen function set filter topological_space (second_countable_topology)\nopen_locale topology\n\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}\n[topological_space α] [topological_space β] [topological_space γ] [topological_space δ]\n\n/-- local homeomorphisms, defined on open subsets of the space -/\n@[nolint has_nonempty_instance]\nstructure local_homeomorph (α : Type*) (β : Type*) [topological_space α] [topological_space β]\n  extends local_equiv α β :=\n(open_source        : is_open source)\n(open_target        : is_open target)\n(continuous_to_fun  : continuous_on to_fun source)\n(continuous_inv_fun : continuous_on inv_fun target)\n\nnamespace local_homeomorph\n\nvariables (e : local_homeomorph α β) (e' : local_homeomorph β γ)\n\ninstance : has_coe_to_fun (local_homeomorph α β) (λ _, α → β) := ⟨λ e, e.to_fun⟩\n\n/-- The inverse of a local homeomorphism -/\nprotected def symm : local_homeomorph β α :=\n{ open_source        := e.open_target,\n  open_target        := e.open_source,\n  continuous_to_fun  := e.continuous_inv_fun,\n  continuous_inv_fun := e.continuous_to_fun,\n  ..e.to_local_equiv.symm }\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (e : local_homeomorph α β) : α → β := e\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (e : local_homeomorph α β) : β → α := e.symm\n\ninitialize_simps_projections local_homeomorph\n  (to_local_equiv_to_fun → apply, to_local_equiv_inv_fun → symm_apply,\n   to_local_equiv_source → source, to_local_equiv_target → target, -to_local_equiv)\n\nprotected lemma continuous_on : continuous_on e e.source := e.continuous_to_fun\n\nlemma continuous_on_symm : continuous_on e.symm e.target := e.continuous_inv_fun\n\n@[simp, mfld_simps] lemma mk_coe (e : local_equiv α β) (a b c d) :\n  (local_homeomorph.mk e a b c d : α → β) = e := rfl\n\n@[simp, mfld_simps] lemma mk_coe_symm (e : local_equiv α β) (a b c d) :\n  ((local_homeomorph.mk e a b c d).symm : β → α) = e.symm := rfl\n\nlemma to_local_equiv_injective : injective (to_local_equiv : local_homeomorph α β → local_equiv α β)\n| ⟨e, h₁, h₂, h₃, h₄⟩ ⟨e', h₁', h₂', h₃', h₄'⟩ rfl := rfl\n\n/- Register a few simp lemmas to make sure that `simp` puts the application of a local\nhomeomorphism in its normal form, i.e., in terms of its coercion to a function. -/\n\n@[simp, mfld_simps] lemma to_fun_eq_coe (e : local_homeomorph α β) : e.to_fun = e := rfl\n\n@[simp, mfld_simps] lemma inv_fun_eq_coe (e : local_homeomorph α β) : e.inv_fun = e.symm := rfl\n\n@[simp, mfld_simps] lemma coe_coe : (e.to_local_equiv : α → β) = e := rfl\n\n@[simp, mfld_simps] lemma coe_coe_symm : (e.to_local_equiv.symm : β → α) = e.symm := rfl\n\n@[simp, mfld_simps] lemma map_source {x : α} (h : x ∈ e.source) : e x ∈ e.target :=\ne.map_source' h\n\n@[simp, mfld_simps] lemma map_target {x : β} (h : x ∈ e.target) : e.symm x ∈ e.source :=\ne.map_target' h\n\n@[simp, mfld_simps] lemma left_inv {x : α} (h : x ∈ e.source) : e.symm (e x) = x :=\ne.left_inv' h\n\n@[simp, mfld_simps] lemma right_inv {x : β} (h : x ∈ e.target) : e (e.symm x) = x :=\ne.right_inv' h\n\nlemma eq_symm_apply {x : α} {y : β} (hx : x ∈ e.source) (hy : y ∈ e.target) :\n  x = e.symm y ↔ e x = y := e.to_local_equiv.eq_symm_apply hx hy\n\nprotected lemma maps_to : maps_to e e.source e.target := λ x, e.map_source\nprotected lemma symm_maps_to : maps_to e.symm e.target e.source := e.symm.maps_to\nprotected lemma left_inv_on : left_inv_on e.symm e e.source := λ x, e.left_inv\nprotected lemma right_inv_on : right_inv_on e.symm e e.target := λ x, e.right_inv\nprotected lemma inv_on : inv_on e.symm e e.source e.target := ⟨e.left_inv_on, e.right_inv_on⟩\nprotected lemma inj_on : inj_on e e.source := e.left_inv_on.inj_on\nprotected lemma bij_on : bij_on e e.source e.target := e.inv_on.bij_on e.maps_to e.symm_maps_to\nprotected lemma surj_on : surj_on e e.source e.target := e.bij_on.surj_on\n\n/-- A homeomorphism induces a local homeomorphism on the whole space -/\n@[simps {simp_rhs := tt, .. mfld_cfg}]\ndef _root_.homeomorph.to_local_homeomorph (e : α ≃ₜ β) :\n  local_homeomorph α β :=\n{ open_source        := is_open_univ,\n  open_target        := is_open_univ,\n  continuous_to_fun  := by { erw ← continuous_iff_continuous_on_univ, exact e.continuous_to_fun },\n  continuous_inv_fun := by { erw ← continuous_iff_continuous_on_univ, exact e.continuous_inv_fun },\n  ..e.to_equiv.to_local_equiv }\n\n/-- Replace `to_local_equiv` field to provide better definitional equalities. -/\ndef replace_equiv (e : local_homeomorph α β) (e' : local_equiv α β) (h : e.to_local_equiv = e') :\n  local_homeomorph α β :=\n{ to_local_equiv := e',\n  open_source := h ▸ e.open_source,\n  open_target := h ▸ e.open_target,\n  continuous_to_fun := h ▸ e.continuous_to_fun,\n  continuous_inv_fun := h ▸ e.continuous_inv_fun }\n\nlemma replace_equiv_eq_self (e : local_homeomorph α β) (e' : local_equiv α β)\n  (h : e.to_local_equiv = e') :\n  e.replace_equiv e' h = e :=\nby { cases e, subst e', refl }\n\nlemma source_preimage_target : e.source ⊆ e ⁻¹' e.target := e.maps_to\n\nlemma eq_of_local_equiv_eq {e e' : local_homeomorph α β}\n  (h : e.to_local_equiv = e'.to_local_equiv) : e = e' :=\nby { cases e, cases e', cases h, refl }\n\nlemma eventually_left_inverse (e : local_homeomorph α β) {x} (hx : x ∈ e.source) :\n  ∀ᶠ y in 𝓝 x, e.symm (e y) = y :=\n(e.open_source.eventually_mem hx).mono e.left_inv'\n\nlemma eventually_left_inverse' (e : local_homeomorph α β) {x} (hx : x ∈ e.target) :\n  ∀ᶠ y in 𝓝 (e.symm x), e.symm (e y) = y :=\ne.eventually_left_inverse (e.map_target hx)\n\nlemma eventually_right_inverse (e : local_homeomorph α β) {x} (hx : x ∈ e.target) :\n  ∀ᶠ y in 𝓝 x, e (e.symm y) = y :=\n(e.open_target.eventually_mem hx).mono e.right_inv'\n\nlemma eventually_right_inverse' (e : local_homeomorph α β) {x} (hx : x ∈ e.source) :\n  ∀ᶠ y in 𝓝 (e x), e (e.symm y) = y :=\ne.eventually_right_inverse (e.map_source hx)\n\nlemma eventually_ne_nhds_within (e : local_homeomorph α β) {x} (hx : x ∈ e.source) :\n  ∀ᶠ x' in 𝓝[≠] x, e x' ≠ e x :=\neventually_nhds_within_iff.2 $ (e.eventually_left_inverse hx).mono $\n  λ x' hx', mt $ λ h, by rw [mem_singleton_iff, ← e.left_inv hx, ← h, hx']\n\nlemma nhds_within_source_inter {x} (hx : x ∈ e.source) (s : set α) :\n  𝓝[e.source ∩ s] x = 𝓝[s] x :=\nnhds_within_inter_of_mem (mem_nhds_within_of_mem_nhds $ is_open.mem_nhds e.open_source hx)\n\nlemma nhds_within_target_inter {x} (hx : x ∈ e.target) (s : set β) :\n  𝓝[e.target ∩ s] x = 𝓝[s] x :=\ne.symm.nhds_within_source_inter hx s\n\nlemma image_eq_target_inter_inv_preimage {s : set α} (h : s ⊆ e.source) :\n  e '' s = e.target ∩ e.symm ⁻¹' s :=\ne.to_local_equiv.image_eq_target_inter_inv_preimage h\n\nlemma image_source_inter_eq' (s : set α) :\n  e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' s :=\ne.to_local_equiv.image_source_inter_eq' s\n\nlemma image_source_inter_eq (s : set α) :\n  e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' (e.source ∩ s) :=\ne.to_local_equiv.image_source_inter_eq s\n\nlemma symm_image_eq_source_inter_preimage {s : set β} (h : s ⊆ e.target) :\n  e.symm '' s = e.source ∩ e ⁻¹' s :=\ne.symm.image_eq_target_inter_inv_preimage h\n\nlemma symm_image_target_inter_eq (s : set β) :\n  e.symm '' (e.target ∩ s) = e.source ∩ e ⁻¹' (e.target ∩ s) :=\ne.symm.image_source_inter_eq _\n\nlemma source_inter_preimage_inv_preimage (s : set α) :\n  e.source ∩ e ⁻¹' (e.symm ⁻¹' s) = e.source ∩ s :=\ne.to_local_equiv.source_inter_preimage_inv_preimage s\n\nlemma target_inter_inv_preimage_preimage (s : set β) :\n  e.target ∩ e.symm ⁻¹' (e ⁻¹' s) = e.target ∩ s :=\ne.symm.source_inter_preimage_inv_preimage _\n\nlemma source_inter_preimage_target_inter (s : set β) :\n  e.source ∩ (e ⁻¹' (e.target ∩ s)) = e.source ∩ (e ⁻¹' s) :=\ne.to_local_equiv.source_inter_preimage_target_inter s\n\nlemma image_source_eq_target (e : local_homeomorph α β) : e '' e.source = e.target :=\ne.to_local_equiv.image_source_eq_target\n\nlemma symm_image_target_eq_source (e : local_homeomorph α β) : e.symm '' e.target = e.source :=\ne.symm.image_source_eq_target\n\n/-- Two local homeomorphisms are equal when they have equal `to_fun`, `inv_fun` and `source`.\nIt is not sufficient to have equal `to_fun` and `source`, as this only determines `inv_fun` on\nthe target. This would only be true for a weaker notion of equality, arguably the right one,\ncalled `eq_on_source`. -/\n@[ext]\nprotected lemma ext (e' : local_homeomorph α β) (h : ∀x, e x = e' x)\n  (hinv : ∀x, e.symm x = e'.symm x) (hs : e.source = e'.source) : e = e' :=\neq_of_local_equiv_eq (local_equiv.ext h hinv hs)\n\nprotected lemma ext_iff {e e' : local_homeomorph α β} : e = e' ↔ (∀ x, e x = e' x) ∧\n  (∀ x, e.symm x = e'.symm x) ∧ e.source = e'.source :=\n⟨by { rintro rfl, exact ⟨λ x, rfl, λ x, rfl, rfl⟩ }, λ h, e.ext e' h.1 h.2.1 h.2.2⟩\n\n@[simp, mfld_simps] lemma symm_to_local_equiv : e.symm.to_local_equiv = e.to_local_equiv.symm := rfl\n-- The following lemmas are already simp via local_equiv\nlemma symm_source : e.symm.source = e.target := rfl\nlemma symm_target : e.symm.target = e.source := rfl\n@[simp, mfld_simps] lemma symm_symm : e.symm.symm = e := eq_of_local_equiv_eq $ by simp\n\n/-- A local homeomorphism is continuous at any point of its source -/\nprotected \n\n/-- A local homeomorphism inverse is continuous at any point of its target -/\nlemma continuous_at_symm {x : β} (h : x ∈ e.target) : continuous_at e.symm x :=\ne.symm.continuous_at h\n\nlemma tendsto_symm {x} (hx : x ∈ e.source) :\n  tendsto e.symm (𝓝 (e x)) (𝓝 x) :=\nby simpa only [continuous_at, e.left_inv hx] using e.continuous_at_symm (e.map_source hx)\n\nlemma map_nhds_eq {x} (hx : x ∈ e.source) : map e (𝓝 x) = 𝓝 (e x) :=\nle_antisymm (e.continuous_at hx) $\n  le_map_of_right_inverse (e.eventually_right_inverse' hx) (e.tendsto_symm hx)\n\nlemma symm_map_nhds_eq {x} (hx : x ∈ e.source) :\n  map e.symm (𝓝 (e x)) = 𝓝 x :=\n(e.symm.map_nhds_eq $ e.map_source hx).trans $ by rw e.left_inv hx\n\nlemma image_mem_nhds {x} (hx : x ∈ e.source) {s : set α} (hs : s ∈ 𝓝 x) :\n  e '' s ∈ 𝓝 (e x) :=\ne.map_nhds_eq hx ▸ filter.image_mem_map hs\n\nlemma map_nhds_within_eq (e : local_homeomorph α β) {x} (hx : x ∈ e.source) (s : set α) :\n  map e (𝓝[s] x) = 𝓝[e '' (e.source ∩ s)] (e x) :=\ncalc map e (𝓝[s] x) = map e (𝓝[e.source ∩ s] x) :\n  congr_arg (map e) (e.nhds_within_source_inter hx _).symm\n... = 𝓝[e '' (e.source ∩ s)] (e x) :\n  (e.left_inv_on.mono $ inter_subset_left _ _).map_nhds_within_eq (e.left_inv hx)\n    (e.continuous_at_symm (e.map_source hx)).continuous_within_at\n    (e.continuous_at hx).continuous_within_at\n\nlemma map_nhds_within_preimage_eq (e : local_homeomorph α β) {x} (hx : x ∈ e.source) (s : set β) :\n  map e (𝓝[e ⁻¹' s] x) = 𝓝[s] (e x) :=\nby rw [e.map_nhds_within_eq hx, e.image_source_inter_eq', e.target_inter_inv_preimage_preimage,\n  e.nhds_within_target_inter (e.map_source hx)]\n\nlemma eventually_nhds (e : local_homeomorph α β) {x : α} (p : β → Prop)\n  (hx : x ∈ e.source) : (∀ᶠ y in 𝓝 (e x), p y) ↔ ∀ᶠ x in 𝓝 x, p (e x) :=\niff.trans (by rw [e.map_nhds_eq hx]) eventually_map\n\nlemma eventually_nhds' (e : local_homeomorph α β) {x : α} (p : α → Prop)\n  (hx : x ∈ e.source) : (∀ᶠ y in 𝓝 (e x), p (e.symm y)) ↔ ∀ᶠ x in 𝓝 x, p x :=\nbegin\n  rw [e.eventually_nhds _ hx],\n  refine eventually_congr ((e.eventually_left_inverse hx).mono $ λ y hy, _),\n  rw [hy]\nend\n\nlemma eventually_nhds_within (e : local_homeomorph α β) {x : α} (p : β → Prop) {s : set α}\n  (hx : x ∈ e.source) : (∀ᶠ y in 𝓝[e.symm ⁻¹' s] (e x), p y) ↔ ∀ᶠ x in 𝓝[s] x, p (e x) :=\nbegin\n  refine iff.trans _ eventually_map,\n  rw [e.map_nhds_within_eq hx, e.image_source_inter_eq', e.nhds_within_target_inter (e.maps_to hx)]\nend\n\nlemma eventually_nhds_within' (e : local_homeomorph α β) {x : α} (p : α → Prop) {s : set α}\n  (hx : x ∈ e.source) : (∀ᶠ y in 𝓝[e.symm ⁻¹' s] (e x), p (e.symm y)) ↔ ∀ᶠ x in 𝓝[s] x, p x :=\nbegin\n  rw [e.eventually_nhds_within _ hx],\n  refine eventually_congr ((eventually_nhds_within_of_eventually_nhds $\n    e.eventually_left_inverse hx).mono $ λ y hy, _),\n  rw [hy]\nend\n\n/-- This lemma is useful in the manifold library in the case that `e` is a chart. It states that\n  locally around `e x` the set `e.symm ⁻¹' s` is the same as the set intersected with the target\n  of `e` and some other neighborhood of `f x` (which will be the source of a chart on `γ`).  -/\nlemma preimage_eventually_eq_target_inter_preimage_inter\n  {e : local_homeomorph α β} {s : set α} {t : set γ} {x : α}\n  {f : α → γ} (hf : continuous_within_at f s x) (hxe : x ∈ e.source) (ht : t ∈ 𝓝 (f x)) :\n  e.symm ⁻¹' s =ᶠ[𝓝 (e x)] (e.target ∩ e.symm ⁻¹' (s ∩ f ⁻¹' t) : set β) :=\nbegin\n  rw [eventually_eq_set, e.eventually_nhds _ hxe],\n  filter_upwards [(e.open_source.mem_nhds hxe),\n    mem_nhds_within_iff_eventually.mp (hf.preimage_mem_nhds_within ht)],\n  intros y hy hyu,\n  simp_rw [mem_inter_iff, mem_preimage, mem_inter_iff, e.maps_to hy, true_and, iff_self_and,\n    e.left_inv hy, iff_true_intro hyu]\nend\n\nlemma preimage_open_of_open {s : set β} (hs : is_open s) : is_open (e.source ∩ e ⁻¹' s) :=\ne.continuous_on.preimage_open_of_open e.open_source hs\n\n/-!\n### `local_homeomorph.is_image` relation\n\nWe say that `t : set β` is an image of `s : set α` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source ∩ s) = e.target ∩ t`;\n* `e.source ∩ e ⁻¹ t = e.source ∩ s`;\n* `∀ x ∈ e.source, e x ∈ t ↔ x ∈ s` (this one is used in the definition).\n\nThis definition is a restatement of `local_equiv.is_image` for local homeomorphisms. In this section\nwe transfer API about `local_equiv.is_image` to local homeomorphisms and add a few\n`local_homeomorph`-specific lemmas like `local_homeomorph.is_image.closure`.\n-/\n\n/-- We say that `t : set β` is an image of `s : set α` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source ∩ s) = e.target ∩ t`;\n* `e.source ∩ e ⁻¹ t = e.source ∩ s`;\n* `∀ x ∈ e.source, e x ∈ t ↔ x ∈ s` (this one is used in the definition).\n-/\ndef is_image (s : set α) (t : set β) : Prop := ∀ ⦃x⦄, x ∈ e.source → (e x ∈ t ↔ x ∈ s)\n\nnamespace is_image\n\nvariables {e} {s : set α} {t : set β} {x : α} {y : β}\n\nlemma to_local_equiv (h : e.is_image s t) : e.to_local_equiv.is_image s t := h\n\nlemma apply_mem_iff (h : e.is_image s t) (hx : x ∈ e.source) : e x ∈ t ↔ x ∈ s := h hx\n\nprotected lemma symm (h : e.is_image s t) : e.symm.is_image t s := h.to_local_equiv.symm\n\nlemma symm_apply_mem_iff (h : e.is_image s t) (hy : y ∈ e.target) : (e.symm y ∈ s ↔ y ∈ t) :=\nh.symm hy\n\n@[simp] lemma symm_iff : e.symm.is_image t s ↔ e.is_image s t := ⟨λ h, h.symm, λ h, h.symm⟩\n\nprotected lemma maps_to (h : e.is_image s t) : maps_to e (e.source ∩ s) (e.target ∩ t) :=\nh.to_local_equiv.maps_to\n\nlemma symm_maps_to (h : e.is_image s t) : maps_to e.symm (e.target ∩ t) (e.source ∩ s) :=\nh.symm.maps_to\n\nlemma image_eq (h : e.is_image s t) : e '' (e.source ∩ s) = e.target ∩ t :=\nh.to_local_equiv.image_eq\n\nlemma symm_image_eq (h : e.is_image s t) : e.symm '' (e.target ∩ t) = e.source ∩ s :=\nh.symm.image_eq\n\nlemma iff_preimage_eq : e.is_image s t ↔ e.source ∩ e ⁻¹' t = e.source ∩ s :=\nlocal_equiv.is_image.iff_preimage_eq\n\nalias iff_preimage_eq ↔ preimage_eq of_preimage_eq\n\nlemma iff_symm_preimage_eq : e.is_image s t ↔ e.target ∩ e.symm ⁻¹' s = e.target ∩ t :=\nsymm_iff.symm.trans iff_preimage_eq\n\nalias iff_symm_preimage_eq ↔ symm_preimage_eq of_symm_preimage_eq\n\nlemma iff_symm_preimage_eq' :\n  e.is_image s t ↔ e.target ∩ e.symm ⁻¹' (e.source ∩ s) = e.target ∩ t :=\nby rw [iff_symm_preimage_eq, ← image_source_inter_eq, ← image_source_inter_eq']\n\nalias iff_symm_preimage_eq' ↔ symm_preimage_eq' of_symm_preimage_eq'\n\nlemma iff_preimage_eq' : e.is_image s t ↔ e.source ∩ e ⁻¹' (e.target ∩ t) = e.source ∩ s :=\nsymm_iff.symm.trans iff_symm_preimage_eq'\n\nalias iff_preimage_eq' ↔ preimage_eq' of_preimage_eq'\n\nlemma of_image_eq (h : e '' (e.source ∩ s) = e.target ∩ t) : e.is_image s t :=\nlocal_equiv.is_image.of_image_eq h\n\nlemma of_symm_image_eq (h : e.symm '' (e.target ∩ t) = e.source ∩ s) : e.is_image s t :=\nlocal_equiv.is_image.of_symm_image_eq h\n\nprotected lemma compl (h : e.is_image s t) : e.is_image sᶜ tᶜ :=\nλ x hx, not_congr (h hx)\n\nprotected lemma inter {s' t'} (h : e.is_image s t) (h' : e.is_image s' t') :\n  e.is_image (s ∩ s') (t ∩ t') :=\nλ x hx, and_congr (h hx) (h' hx)\n\nprotected lemma union {s' t'} (h : e.is_image s t) (h' : e.is_image s' t') :\n  e.is_image (s ∪ s') (t ∪ t') :=\nλ x hx, or_congr (h hx) (h' hx)\n\nprotected lemma diff {s' t'} (h : e.is_image s t) (h' : e.is_image s' t') :\n  e.is_image (s \\ s') (t \\ t') :=\nh.inter h'.compl\n\nlemma left_inv_on_piecewise {e' : local_homeomorph α β} [∀ i, decidable (i ∈ s)]\n  [∀ i, decidable (i ∈ t)] (h : e.is_image s t) (h' : e'.is_image s t) :\n  left_inv_on (t.piecewise e.symm e'.symm) (s.piecewise e e') (s.ite e.source e'.source) :=\nh.to_local_equiv.left_inv_on_piecewise h'\n\nlemma inter_eq_of_inter_eq_of_eq_on {e' : local_homeomorph α β} (h : e.is_image s t)\n  (h' : e'.is_image s t) (hs : e.source ∩ s = e'.source ∩ s) (Heq : eq_on e e' (e.source ∩ s)) :\n  e.target ∩ t = e'.target ∩ t :=\nh.to_local_equiv.inter_eq_of_inter_eq_of_eq_on h' hs Heq\n\nlemma symm_eq_on_of_inter_eq_of_eq_on {e' : local_homeomorph α β} (h : e.is_image s t)\n  (hs : e.source ∩ s = e'.source ∩ s) (Heq : eq_on e e' (e.source ∩ s)) :\n  eq_on e.symm e'.symm (e.target ∩ t) :=\nh.to_local_equiv.symm_eq_on_of_inter_eq_of_eq_on hs Heq\n\nlemma map_nhds_within_eq (h : e.is_image s t) (hx : x ∈ e.source) :\n  map e (𝓝[s] x) = 𝓝[t] (e x) :=\nby rw [e.map_nhds_within_eq hx, h.image_eq, e.nhds_within_target_inter (e.map_source hx)]\n\nprotected lemma closure (h : e.is_image s t) : e.is_image (closure s) (closure t) :=\nλ x hx, by simp only [mem_closure_iff_nhds_within_ne_bot, ← h.map_nhds_within_eq hx, map_ne_bot_iff]\n\nprotected lemma interior (h : e.is_image s t) : e.is_image (interior s) (interior t) :=\nby simpa only [closure_compl, compl_compl] using h.compl.closure.compl\n\nprotected lemma frontier (h : e.is_image s t) :\n  e.is_image (frontier s) (frontier t) :=\nh.closure.diff h.interior\n\nlemma is_open_iff (h : e.is_image s t) :\n  is_open (e.source ∩ s) ↔ is_open (e.target ∩ t) :=\n⟨λ hs, h.symm_preimage_eq' ▸ e.symm.preimage_open_of_open hs,\n  λ hs, h.preimage_eq' ▸ e.preimage_open_of_open hs⟩\n\n/-- Restrict a `local_homeomorph` to a pair of corresponding open sets. -/\n@[simps to_local_equiv] def restr (h : e.is_image s t) (hs : is_open (e.source ∩ s)) :\n  local_homeomorph α β :=\n{ to_local_equiv := h.to_local_equiv.restr,\n  open_source := hs,\n  open_target := h.is_open_iff.1 hs,\n  continuous_to_fun := e.continuous_on.mono (inter_subset_left _ _),\n  continuous_inv_fun := e.symm.continuous_on.mono (inter_subset_left _ _) }\n\nend is_image\n\nlemma is_image_source_target : e.is_image e.source e.target :=\ne.to_local_equiv.is_image_source_target\n\nlemma is_image_source_target_of_disjoint (e' : local_homeomorph α β)\n  (hs : disjoint e.source e'.source) (ht : disjoint e.target e'.target) :\n  e.is_image e'.source e'.target :=\ne.to_local_equiv.is_image_source_target_of_disjoint e'.to_local_equiv hs ht\n\n/-- Preimage of interior or interior of preimage coincide for local homeomorphisms, when restricted\nto the source. -/\nlemma preimage_interior (s : set β) :\n  e.source ∩ e ⁻¹' (interior s) = e.source ∩ interior (e ⁻¹' s) :=\n(is_image.of_preimage_eq rfl).interior.preimage_eq\n\nlemma preimage_closure (s : set β) :\n  e.source ∩ e ⁻¹' (closure s) = e.source ∩ closure (e ⁻¹' s) :=\n(is_image.of_preimage_eq rfl).closure.preimage_eq\n\nlemma preimage_frontier (s : set β) :\n  e.source ∩ e ⁻¹' (frontier s) = e.source ∩ frontier (e ⁻¹' s) :=\n(is_image.of_preimage_eq rfl).frontier.preimage_eq\n\nlemma preimage_open_of_open_symm {s : set α} (hs : is_open s) :\n  is_open (e.target ∩ e.symm ⁻¹' s) :=\ne.symm.continuous_on.preimage_open_of_open e.open_target hs\n\n/-- The image of an open set in the source is open. -/\nlemma image_open_of_open {s : set α} (hs : is_open s) (h : s ⊆ e.source) : is_open (e '' s) :=\nbegin\n  have : e '' s = e.target ∩ e.symm ⁻¹' s :=\n    e.to_local_equiv.image_eq_target_inter_inv_preimage h,\n  rw this,\n  exact e.continuous_on_symm.preimage_open_of_open e.open_target hs\nend\n\n/-- The image of the restriction of an open set to the source is open. -/\nlemma image_open_of_open' {s : set α} (hs : is_open s) : is_open (e '' (e.source ∩ s)) :=\nimage_open_of_open _ (is_open.inter e.open_source hs) (inter_subset_left _ _)\n\n/-- A `local_equiv` with continuous open forward map and an open source is a `local_homeomorph`. -/\ndef of_continuous_open_restrict (e : local_equiv α β) (hc : continuous_on e e.source)\n  (ho : is_open_map (e.source.restrict e)) (hs : is_open e.source) :\n  local_homeomorph α β :=\n{ to_local_equiv := e,\n  open_source := hs,\n  open_target := by simpa only [range_restrict, e.image_source_eq_target] using ho.is_open_range,\n  continuous_to_fun := hc,\n  continuous_inv_fun := e.image_source_eq_target ▸\n    ho.continuous_on_image_of_left_inv_on e.left_inv_on }\n\n/-- A `local_equiv` with continuous open forward map and an open source is a `local_homeomorph`. -/\ndef of_continuous_open (e : local_equiv α β) (hc : continuous_on e e.source)\n  (ho : is_open_map e) (hs : is_open e.source) :\n  local_homeomorph α β :=\nof_continuous_open_restrict e hc (ho.restrict hs) hs\n\n/-- Restricting a local homeomorphism `e` to `e.source ∩ s` when `s` is open. This is sometimes hard\nto use because of the openness assumption, but it has the advantage that when it can\nbe used then its local_equiv is defeq to local_equiv.restr -/\nprotected def restr_open (s : set α) (hs : is_open s) :\n  local_homeomorph α β :=\n(@is_image.of_symm_preimage_eq α β _ _ e s (e.symm ⁻¹' s) rfl).restr\n  (is_open.inter e.open_source hs)\n\n@[simp, mfld_simps] lemma restr_open_to_local_equiv (s : set α) (hs : is_open s) :\n  (e.restr_open s hs).to_local_equiv = e.to_local_equiv.restr s := rfl\n\n-- Already simp via local_equiv\nlemma restr_open_source (s : set α) (hs : is_open s) :\n  (e.restr_open s hs).source = e.source ∩ s := rfl\n\n/-- Restricting a local homeomorphism `e` to `e.source ∩ interior s`. We use the interior to make\nsure that the restriction is well defined whatever the set s, since local homeomorphisms are by\ndefinition defined on open sets. In applications where `s` is open, this coincides with the\nrestriction of local equivalences -/\n@[simps apply symm_apply (mfld_cfg), simps source target {attrs := []}]\nprotected def restr (s : set α) : local_homeomorph α β :=\ne.restr_open (interior s) is_open_interior\n\n@[simp, mfld_simps] lemma restr_to_local_equiv (s : set α) :\n  (e.restr s).to_local_equiv = (e.to_local_equiv).restr (interior s) := rfl\n\nlemma restr_source' (s : set α) (hs : is_open s) : (e.restr s).source = e.source ∩ s :=\nby rw [e.restr_source, hs.interior_eq]\n\nlemma restr_to_local_equiv' (s : set α) (hs : is_open s):\n  (e.restr s).to_local_equiv = e.to_local_equiv.restr s :=\nby rw [e.restr_to_local_equiv, hs.interior_eq]\n\nlemma restr_eq_of_source_subset {e : local_homeomorph α β} {s : set α} (h : e.source ⊆ s) :\n  e.restr s = e :=\nbegin\n  apply eq_of_local_equiv_eq,\n  rw restr_to_local_equiv,\n  apply local_equiv.restr_eq_of_source_subset,\n  exact interior_maximal h e.open_source\nend\n\n@[simp, mfld_simps] lemma restr_univ {e : local_homeomorph α β} : e.restr univ = e :=\nrestr_eq_of_source_subset (subset_univ _)\n\nlemma restr_source_inter (s : set α) : e.restr (e.source ∩ s) = e.restr s :=\nbegin\n  refine local_homeomorph.ext _ _ (λx, rfl) (λx, rfl) _,\n  simp [e.open_source.interior_eq, ← inter_assoc]\nend\n\n/-- The identity on the whole space as a local homeomorphism. -/\n@[simps apply (mfld_cfg), simps source target {attrs := []}]\nprotected def refl (α : Type*) [topological_space α] : local_homeomorph α α :=\n(homeomorph.refl α).to_local_homeomorph\n\n@[simp, mfld_simps] lemma refl_local_equiv :\n  (local_homeomorph.refl α).to_local_equiv = local_equiv.refl α := rfl\n@[simp, mfld_simps] lemma refl_symm : (local_homeomorph.refl α).symm = local_homeomorph.refl α :=\nrfl\n\nsection\nvariables {s : set α} (hs : is_open s)\n\n/-- The identity local equiv on a set `s` -/\n@[simps apply (mfld_cfg), simps source target {attrs := []}]\ndef of_set (s : set α) (hs : is_open s) : local_homeomorph α α :=\n{ open_source        := hs,\n  open_target        := hs,\n  continuous_to_fun  := continuous_id.continuous_on,\n  continuous_inv_fun := continuous_id.continuous_on,\n  ..local_equiv.of_set s }\n\n@[simp, mfld_simps] lemma of_set_to_local_equiv :\n  (of_set s hs).to_local_equiv = local_equiv.of_set s := rfl\n@[simp, mfld_simps] lemma of_set_symm : (of_set s hs).symm = of_set s hs := rfl\n\n@[simp, mfld_simps] lemma of_set_univ_eq_refl :\n  of_set univ is_open_univ = local_homeomorph.refl α :=\nby ext; simp\n\nend\n\n/-- Composition of two local homeomorphisms when the target of the first and the source of\nthe second coincide. -/\nprotected def trans' (h : e.target = e'.source) : local_homeomorph α γ :=\n{ open_source       := e.open_source,\n  open_target       := e'.open_target,\n  continuous_to_fun := begin\n    apply e'.continuous_to_fun.comp e.continuous_to_fun,\n    rw ← h,\n    exact e.to_local_equiv.source_subset_preimage_target\n  end,\n  continuous_inv_fun := begin\n    apply e.continuous_inv_fun.comp e'.continuous_inv_fun,\n    rw h,\n    exact e'.to_local_equiv.target_subset_preimage_source\n  end,\n  ..local_equiv.trans' e.to_local_equiv e'.to_local_equiv h }\n\n/-- Composing two local homeomorphisms, by restricting to the maximal domain where their\ncomposition is well defined. -/\nprotected def trans : local_homeomorph α γ :=\n  local_homeomorph.trans' (e.symm.restr_open e'.source e'.open_source).symm\n    (e'.restr_open e.target e.open_target) (by simp [inter_comm])\n\n@[simp, mfld_simps] lemma trans_to_local_equiv :\n  (e.trans e').to_local_equiv = e.to_local_equiv.trans e'.to_local_equiv := rfl\n@[simp, mfld_simps] lemma coe_trans : (e.trans e' : α → γ) = e' ∘ e := rfl\n@[simp, mfld_simps] lemma coe_trans_symm : ((e.trans e').symm : γ → α) = e.symm ∘ e'.symm := rfl\nlemma trans_apply {x : α} : (e.trans e') x = e' (e x) := rfl\n\nlemma trans_symm_eq_symm_trans_symm : (e.trans e').symm = e'.symm.trans e.symm :=\nby cases e; cases e'; refl\n\n/- This could be considered as a simp lemma, but there are many situations where it makes something\nsimple into something more complicated. -/\nlemma trans_source : (e.trans e').source = e.source ∩ e ⁻¹' e'.source :=\nlocal_equiv.trans_source e.to_local_equiv e'.to_local_equiv\n\nlemma trans_source' : (e.trans e').source = e.source ∩ e ⁻¹' (e.target ∩ e'.source) :=\nlocal_equiv.trans_source' e.to_local_equiv e'.to_local_equiv\n\nlemma trans_source'' : (e.trans e').source = e.symm '' (e.target ∩ e'.source) :=\nlocal_equiv.trans_source'' e.to_local_equiv e'.to_local_equiv\n\nlemma image_trans_source : e '' (e.trans e').source = e.target ∩ e'.source :=\nlocal_equiv.image_trans_source e.to_local_equiv e'.to_local_equiv\n\nlemma trans_target : (e.trans e').target = e'.target ∩ e'.symm ⁻¹' e.target := rfl\n\nlemma trans_target' : (e.trans e').target = e'.target ∩ e'.symm ⁻¹' (e'.source ∩ e.target) :=\ntrans_source' e'.symm e.symm\n\nlemma trans_target'' : (e.trans e').target = e' '' (e'.source ∩ e.target) :=\ntrans_source'' e'.symm e.symm\n\nlemma inv_image_trans_target : e'.symm '' (e.trans e').target = e'.source ∩ e.target :=\nimage_trans_source e'.symm e.symm\n\nlemma trans_assoc (e'' : local_homeomorph γ δ) :\n  (e.trans e').trans e'' = e.trans (e'.trans e'') :=\neq_of_local_equiv_eq $ local_equiv.trans_assoc e.to_local_equiv e'.to_local_equiv e''.to_local_equiv\n\n@[simp, mfld_simps] lemma trans_refl : e.trans (local_homeomorph.refl β) = e :=\neq_of_local_equiv_eq $ local_equiv.trans_refl e.to_local_equiv\n\n@[simp, mfld_simps] lemma refl_trans : (local_homeomorph.refl α).trans e = e :=\neq_of_local_equiv_eq $ local_equiv.refl_trans e.to_local_equiv\n\nlemma trans_of_set {s : set β} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e ⁻¹' s) :=\nlocal_homeomorph.ext _ _ (λx, rfl) (λx, rfl) $\n  by simp [local_equiv.trans_source, (e.preimage_interior _).symm, hs.interior_eq]\n\nlemma trans_of_set' {s : set β} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e.source ∩ e ⁻¹' s) :=\nby rw [trans_of_set, restr_source_inter]\n\nlemma of_set_trans {s : set α} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr s :=\nlocal_homeomorph.ext _ _ (λx, rfl) (λx, rfl) $\n  by simp [local_equiv.trans_source, hs.interior_eq, inter_comm]\n\nlemma of_set_trans' {s : set α} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr (e.source ∩ s) :=\nby rw [of_set_trans, restr_source_inter]\n\n@[simp, mfld_simps] lemma of_set_trans_of_set\n  {s : set α} (hs : is_open s) {s' : set α} (hs' : is_open s') :\n  (of_set s hs).trans (of_set s' hs') = of_set (s ∩ s') (is_open.inter hs hs')  :=\nbegin\n  rw (of_set s hs).trans_of_set hs',\n  ext; simp [hs'.interior_eq]\nend\n\nlemma restr_trans (s : set α) :\n  (e.restr s).trans e' = (e.trans e').restr s :=\neq_of_local_equiv_eq $ local_equiv.restr_trans e.to_local_equiv e'.to_local_equiv (interior s)\n\n/-- Postcompose a local homeomorphism with an homeomorphism.\nWe modify the source and target to have better definitional behavior. -/\n@[simps {fully_applied := ff}]\ndef trans_homeomorph (e' : β ≃ₜ γ) : local_homeomorph α γ :=\n{ to_local_equiv := e.to_local_equiv.trans_equiv e'.to_equiv,\n  open_source := e.open_source,\n  open_target := e.open_target.preimage e'.symm.continuous,\n  continuous_to_fun := e'.continuous.comp_continuous_on e.continuous_on,\n  continuous_inv_fun := e.symm.continuous_on.comp e'.symm.continuous.continuous_on (λ x h, h) }\n\nlemma trans_equiv_eq_trans (e' : β ≃ₜ γ) : e.trans_homeomorph e' = e.trans e'.to_local_homeomorph :=\nto_local_equiv_injective $ local_equiv.trans_equiv_eq_trans _ _\n\n/-- Precompose a local homeomorphism with an homeomorphism.\nWe modify the source and target to have better definitional behavior. -/\n@[simps {fully_applied := ff}]\ndef _root_.homeomorph.trans_local_homeomorph (e : α ≃ₜ β) : local_homeomorph α γ :=\n{ to_local_equiv := e.to_equiv.trans_local_equiv e'.to_local_equiv,\n  open_source := e'.open_source.preimage e.continuous,\n  open_target := e'.open_target,\n  continuous_to_fun := e'.continuous_on.comp e.continuous.continuous_on (λ x h, h),\n  continuous_inv_fun := e.symm.continuous.comp_continuous_on e'.symm.continuous_on }\n\nlemma _root_.homeomorph.trans_local_homeomorph_eq_trans (e : α ≃ₜ β) :\n  e.trans_local_homeomorph e' = e.to_local_homeomorph.trans e' :=\nto_local_equiv_injective $ equiv.trans_local_equiv_eq_trans _ _\n\n/-- `eq_on_source e e'` means that `e` and `e'` have the same source, and coincide there. They\nshould really be considered the same local equiv. -/\ndef eq_on_source (e e' : local_homeomorph α β) : Prop :=\ne.source = e'.source ∧ (eq_on e e' e.source)\n\nlemma eq_on_source_iff (e e' : local_homeomorph α β) :\neq_on_source e e' ↔ local_equiv.eq_on_source e.to_local_equiv e'.to_local_equiv :=\niff.rfl\n\n/-- `eq_on_source` is an equivalence relation -/\ninstance : setoid (local_homeomorph α β) :=\n{ r     := eq_on_source,\n  iseqv := ⟨\n    λe, (@local_equiv.eq_on_source_setoid α β).iseqv.1 e.to_local_equiv,\n    λe e' h, (@local_equiv.eq_on_source_setoid α β).iseqv.2.1 ((eq_on_source_iff e e').1 h),\n    λe e' e'' h h', (@local_equiv.eq_on_source_setoid α β).iseqv.2.2\n      ((eq_on_source_iff e e').1 h) ((eq_on_source_iff e' e'').1 h')⟩ }\n\nlemma eq_on_source_refl : e ≈ e := setoid.refl _\n\n/-- If two local homeomorphisms are equivalent, so are their inverses -/\nlemma eq_on_source.symm' {e e' : local_homeomorph α β} (h : e ≈ e') : e.symm ≈ e'.symm :=\nlocal_equiv.eq_on_source.symm' h\n\n/-- Two equivalent local homeomorphisms have the same source -/\nlemma eq_on_source.source_eq {e e' : local_homeomorph α β} (h : e ≈ e') : e.source = e'.source :=\nh.1\n\n/-- Two equivalent local homeomorphisms have the same target -/\nlemma eq_on_source.target_eq {e e' : local_homeomorph α β} (h : e ≈ e') : e.target = e'.target :=\nh.symm'.1\n\n/-- Two equivalent local homeomorphisms have coinciding `to_fun` on the source -/\nlemma eq_on_source.eq_on {e e' : local_homeomorph α β} (h : e ≈ e') :\n  eq_on e e' e.source :=\nh.2\n\n/-- Two equivalent local homeomorphisms have coinciding `inv_fun` on the target -/\nlemma eq_on_source.symm_eq_on_target {e e' : local_homeomorph α β} (h : e ≈ e') :\n  eq_on e.symm e'.symm e.target :=\nh.symm'.2\n\n/-- Composition of local homeomorphisms respects equivalence -/\nlemma eq_on_source.trans' {e e' : local_homeomorph α β} {f f' : local_homeomorph β γ}\n  (he : e ≈ e') (hf : f ≈ f') : e.trans f ≈ e'.trans f' :=\nlocal_equiv.eq_on_source.trans' he hf\n\n/-- Restriction of local homeomorphisms respects equivalence -/\nlemma eq_on_source.restr {e e' : local_homeomorph α β} (he : e ≈ e') (s : set α) :\n  e.restr s ≈ e'.restr s :=\nlocal_equiv.eq_on_source.restr he _\n\nlemma set.eq_on.restr_eq_on_source {e e' : local_homeomorph α β}\n  (h : eq_on e e' (e.source ∩ e'.source)) :\n  e.restr e'.source ≈ e'.restr e.source :=\nbegin\n  split,\n  { rw e'.restr_source' _ e.open_source,\n    rw e.restr_source' _ e'.open_source,\n    exact set.inter_comm _ _ },\n  { rw e.restr_source' _ e'.open_source,\n    refine (eq_on.trans _ h).trans _;\n    simp only with mfld_simps },\nend\n\n/-- Composition of a local homeomorphism and its inverse is equivalent to the restriction of the\nidentity to the source -/\nlemma trans_self_symm :\n  e.trans e.symm ≈ local_homeomorph.of_set e.source e.open_source :=\nlocal_equiv.trans_self_symm _\n\nlemma trans_symm_self :\n  e.symm.trans e ≈ local_homeomorph.of_set e.target e.open_target :=\ne.symm.trans_self_symm\n\nlemma eq_of_eq_on_source_univ {e e' : local_homeomorph α β} (h : e ≈ e')\n  (s : e.source = univ) (t : e.target = univ) : e = e' :=\neq_of_local_equiv_eq $ local_equiv.eq_of_eq_on_source_univ _ _ h s t\n\nsection prod\n\n/-- The product of two local homeomorphisms, as a local homeomorphism on the product space. -/\n@[simps to_local_equiv apply (mfld_cfg), simps source target symm_apply {attrs := []}]\ndef prod (e : local_homeomorph α β) (e' : local_homeomorph γ δ) :\n  local_homeomorph (α × γ) (β × δ) :=\n{ open_source := e.open_source.prod e'.open_source,\n  open_target := e.open_target.prod e'.open_target,\n  continuous_to_fun := e.continuous_on.prod_map e'.continuous_on,\n  continuous_inv_fun := e.continuous_on_symm.prod_map e'.continuous_on_symm,\n  to_local_equiv := e.to_local_equiv.prod e'.to_local_equiv }\n\n@[simp, mfld_simps] lemma prod_symm (e : local_homeomorph α β) (e' : local_homeomorph γ δ) :\n  (e.prod e').symm = (e.symm.prod e'.symm) :=\nrfl\n\n@[simp]\nlemma refl_prod_refl {α β : Type*} [topological_space α] [topological_space β] :\n  (local_homeomorph.refl α).prod (local_homeomorph.refl β) = local_homeomorph.refl (α × β) :=\nby { ext1 ⟨x, y⟩, { refl }, { rintro ⟨x, y⟩, refl }, exact univ_prod_univ }\n\n@[simp, mfld_simps] lemma prod_trans\n  {η : Type*} {ε : Type*} [topological_space η] [topological_space ε]\n  (e : local_homeomorph α β) (f : local_homeomorph β γ)\n  (e' : local_homeomorph δ η) (f' : local_homeomorph η ε) :\n  (e.prod e').trans (f.prod f') = (e.trans f).prod (e'.trans f') :=\nlocal_homeomorph.eq_of_local_equiv_eq $\n  by dsimp only [trans_to_local_equiv, prod_to_local_equiv]; apply local_equiv.prod_trans\n\nlemma prod_eq_prod_of_nonempty {e₁ e₁' : local_homeomorph α β} {e₂ e₂' : local_homeomorph γ δ}\n  (h : (e₁.prod e₂).source.nonempty) :\n  e₁.prod e₂ = e₁'.prod e₂' ↔ e₁ = e₁' ∧ e₂ = e₂' :=\nbegin\n  obtain ⟨⟨x, y⟩, -⟩ := id h,\n  haveI : nonempty α := ⟨x⟩,\n  haveI : nonempty β  := ⟨e₁ x⟩,\n  haveI : nonempty γ := ⟨y⟩,\n  haveI : nonempty δ := ⟨e₂ y⟩,\n  simp_rw [local_homeomorph.ext_iff, prod_apply, prod_symm_apply, prod_source, prod.ext_iff,\n    set.prod_eq_prod_iff_of_nonempty h,\n    forall_and_distrib, prod.forall, forall_const, forall_forall_const, and_assoc, and.left_comm]\nend\n\nlemma prod_eq_prod_of_nonempty' {e₁ e₁' : local_homeomorph α β} {e₂ e₂' : local_homeomorph γ δ}\n  (h : (e₁'.prod e₂').source.nonempty) :\n  e₁.prod e₂ = e₁'.prod e₂' ↔ e₁ = e₁' ∧ e₂ = e₂' :=\nby rw [eq_comm, prod_eq_prod_of_nonempty h, eq_comm, @eq_comm _ e₂']\n\nend prod\n\nsection piecewise\n\n/-- Combine two `local_homeomorph`s using `set.piecewise`. The source of the new `local_homeomorph`\nis `s.ite e.source e'.source = e.source ∩ s ∪ e'.source \\ s`, and similarly for target.  The\nfunction sends `e.source ∩ s` to `e.target ∩ t` using `e` and `e'.source \\ s` to `e'.target \\ t`\nusing `e'`, and similarly for the inverse function. To ensure that the maps `to_fun` and `inv_fun`\nare inverse of each other on the new `source` and `target`, the definition assumes that the sets `s`\nand `t` are related both by `e.is_image` and `e'.is_image`. To ensure that the new maps are\ncontinuous on `source`/`target`, it also assumes that `e.source` and `e'.source` meet `frontier s`\non the same set and `e x = e' x` on this intersection. -/\n@[simps to_local_equiv apply {fully_applied := ff}]\ndef piecewise (e e' : local_homeomorph α β) (s : set α) (t : set β)\n  [∀ x, decidable (x ∈ s)] [∀ y, decidable (y ∈ t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source ∩ frontier s = e'.source ∩ frontier s)\n  (Heq : eq_on e e' (e.source ∩ frontier s)) :\n  local_homeomorph α β :=\n{ to_local_equiv := e.to_local_equiv.piecewise e'.to_local_equiv s t H H',\n  open_source := e.open_source.ite e'.open_source Hs,\n  open_target := e.open_target.ite e'.open_target $\n    H.frontier.inter_eq_of_inter_eq_of_eq_on H'.frontier Hs Heq,\n  continuous_to_fun := continuous_on_piecewise_ite e.continuous_on e'.continuous_on Hs Heq,\n  continuous_inv_fun := continuous_on_piecewise_ite e.continuous_on_symm e'.continuous_on_symm\n    (H.frontier.inter_eq_of_inter_eq_of_eq_on H'.frontier Hs Heq)\n    (H.frontier.symm_eq_on_of_inter_eq_of_eq_on Hs Heq) }\n\n@[simp] lemma symm_piecewise (e e' : local_homeomorph α β) {s : set α} {t : set β}\n  [∀ x, decidable (x ∈ s)] [∀ y, decidable (y ∈ t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source ∩ frontier s = e'.source ∩ frontier s)\n  (Heq : eq_on e e' (e.source ∩ frontier s)) :\n  (e.piecewise e' s t H H' Hs Heq).symm =\n    e.symm.piecewise e'.symm t s H.symm H'.symm\n      (H.frontier.inter_eq_of_inter_eq_of_eq_on H'.frontier Hs Heq)\n      (H.frontier.symm_eq_on_of_inter_eq_of_eq_on Hs Heq) :=\nrfl\n\n/-- Combine two `local_homeomorph`s with disjoint sources and disjoint targets. We reuse\n`local_homeomorph.piecewise` then override `to_local_equiv` to `local_equiv.disjoint_union`.\nThis way we have better definitional equalities for `source` and `target`. -/\ndef disjoint_union (e e' : local_homeomorph α β)\n  [∀ x, decidable (x ∈ e.source)] [∀ y, decidable (y ∈ e.target)]\n  (Hs : disjoint e.source e'.source) (Ht : disjoint e.target e'.target) :\n  local_homeomorph α β :=\n(e.piecewise e' e.source e.target e.is_image_source_target\n  (e'.is_image_source_target_of_disjoint e Hs.symm Ht.symm)\n  (by rw [e.open_source.inter_frontier_eq, (Hs.symm.frontier_right e'.open_source).inter_eq])\n  (by { rw e.open_source.inter_frontier_eq, exact eq_on_empty _ _ })).replace_equiv\n    (e.to_local_equiv.disjoint_union e'.to_local_equiv Hs Ht)\n    (local_equiv.disjoint_union_eq_piecewise _ _ _ _).symm\n\nend piecewise\n\nsection pi\n\nvariables {ι : Type*} [fintype ι] {Xi Yi : ι → Type*} [Π i, topological_space (Xi i)]\n  [Π i, topological_space (Yi i)] (ei : Π i, local_homeomorph (Xi i) (Yi i))\n\n/-- The product of a finite family of `local_homeomorph`s. -/\n@[simps to_local_equiv] def pi : local_homeomorph (Π i, Xi i) (Π i, Yi i) :=\n{ to_local_equiv := local_equiv.pi (λ i, (ei i).to_local_equiv),\n  open_source := is_open_set_pi finite_univ $ λ i hi, (ei i).open_source,\n  open_target := is_open_set_pi finite_univ $ λ i hi, (ei i).open_target,\n  continuous_to_fun := continuous_on_pi.2 $ λ i, (ei i).continuous_on.comp\n    (continuous_apply _).continuous_on (λ f hf, hf i trivial),\n  continuous_inv_fun := continuous_on_pi.2 $ λ i, (ei i).continuous_on_symm.comp\n    (continuous_apply _).continuous_on (λ f hf, hf i trivial) }\n\nend pi\n\nsection continuity\n\n/-- Continuity within a set at a point can be read under right composition with a local\nhomeomorphism, if the point is in its target -/\nlemma continuous_within_at_iff_continuous_within_at_comp_right\n  {f : β → γ} {s : set β} {x : β} (h : x ∈ e.target) :\n  continuous_within_at f s x ↔ continuous_within_at (f ∘ e) (e ⁻¹' s) (e.symm x) :=\nby simp_rw [continuous_within_at, ← @tendsto_map'_iff _ _ _ _ e,\n  e.map_nhds_within_preimage_eq (e.map_target h), (∘), e.right_inv h]\n\n/-- Continuity at a point can be read under right composition with a local homeomorphism, if the\npoint is in its target -/\nlemma continuous_at_iff_continuous_at_comp_right\n  {f : β → γ} {x : β} (h : x ∈ e.target) :\n  continuous_at f x ↔ continuous_at (f ∘ e) (e.symm x) :=\nby rw [← continuous_within_at_univ, e.continuous_within_at_iff_continuous_within_at_comp_right h,\n       preimage_univ, continuous_within_at_univ]\n\n/-- A function is continuous on a set if and only if its composition with a local homeomorphism\non the right is continuous on the corresponding set. -/\nlemma continuous_on_iff_continuous_on_comp_right {f : β → γ} {s : set β} (h : s ⊆ e.target) :\n  continuous_on f s ↔ continuous_on (f ∘ e) (e.source ∩ e ⁻¹' s) :=\nbegin\n  simp only [← e.symm_image_eq_source_inter_preimage h, continuous_on, ball_image_iff],\n  refine forall₂_congr (λ x hx, _),\n  rw [e.continuous_within_at_iff_continuous_within_at_comp_right (h hx),\n    e.symm_image_eq_source_inter_preimage h, inter_comm, continuous_within_at_inter],\n  exact is_open.mem_nhds e.open_source (e.map_target (h hx))\nend\n\n/-- Continuity within a set at a point can be read under left composition with a local\nhomeomorphism if a neighborhood of the initial point is sent to the source of the local\nhomeomorphism-/\nlemma continuous_within_at_iff_continuous_within_at_comp_left\n  {f : γ → α} {s : set γ} {x : γ} (hx : f x ∈ e.source) (h : f ⁻¹' e.source ∈ 𝓝[s] x) :\n  continuous_within_at f s x ↔ continuous_within_at (e ∘ f) s x :=\nbegin\n  refine ⟨(e.continuous_at hx).comp_continuous_within_at, λ fe_cont, _⟩,\n  rw [← continuous_within_at_inter' h] at fe_cont ⊢,\n  have : continuous_within_at (e.symm ∘ (e ∘ f)) (s ∩ f ⁻¹' e.source) x,\n  { have : continuous_within_at e.symm univ (e (f x))\n      := (e.continuous_at_symm (e.map_source hx)).continuous_within_at,\n    exact continuous_within_at.comp this fe_cont (subset_univ _) },\n  exact this.congr (λy hy, by simp [e.left_inv hy.2]) (by simp [e.left_inv hx])\nend\n\n/-- Continuity at a point can be read under left composition with a local homeomorphism if a\nneighborhood of the initial point is sent to the source of the local homeomorphism-/\nlemma continuous_at_iff_continuous_at_comp_left {f : γ → α} {x : γ} (h : f ⁻¹' e.source ∈ 𝓝 x) :\n  continuous_at f x ↔ continuous_at (e ∘ f) x :=\nbegin\n  have hx : f x ∈ e.source := (mem_of_mem_nhds h : _),\n  have h' : f ⁻¹' e.source ∈ 𝓝[univ] x, by rwa nhds_within_univ,\n  rw [← continuous_within_at_univ, ← continuous_within_at_univ,\n      e.continuous_within_at_iff_continuous_within_at_comp_left hx h']\nend\n\n/-- A function is continuous on a set if and only if its composition with a local homeomorphism\non the left is continuous on the corresponding set. -/\nlemma continuous_on_iff_continuous_on_comp_left {f : γ → α} {s : set γ} (h : s ⊆ f ⁻¹' e.source) :\n  continuous_on f s ↔ continuous_on (e ∘ f) s :=\nforall₂_congr $ λ x hx, e.continuous_within_at_iff_continuous_within_at_comp_left\n  (h hx) (mem_of_superset self_mem_nhds_within h)\n\n/-- A function is continuous if and only if its composition with a local homeomorphism\non the left is continuous and its image is contained in the source. -/\nlemma continuous_iff_continuous_comp_left {f : γ → α} (h : f ⁻¹' e.source = univ) :\n  continuous f ↔ continuous (e ∘ f) :=\nbegin\n  simp only [continuous_iff_continuous_on_univ],\n  exact e.continuous_on_iff_continuous_on_comp_left (eq.symm h).subset,\nend\n\nend continuity\n\n/-- The homeomorphism obtained by restricting a `local_homeomorph` to a subset of the source. -/\n@[simps] def homeomorph_of_image_subset_source\n  {s : set α} {t : set β} (hs : s ⊆ e.source) (ht : e '' s = t) : s ≃ₜ t :=\n{ to_fun := λ a, ⟨e a, (congr_arg ((∈) (e a)) ht).mp ⟨a, a.2, rfl⟩⟩,\n  inv_fun := λ b, ⟨e.symm b, let ⟨a, ha1, ha2⟩ := (congr_arg ((∈) ↑b) ht).mpr b.2 in\n    ha2 ▸ (e.left_inv (hs ha1)).symm ▸ ha1⟩,\n  left_inv := λ a, subtype.ext (e.left_inv (hs a.2)),\n  right_inv := λ b, let ⟨a, ha1, ha2⟩ := (congr_arg ((∈) ↑b) ht).mpr b.2 in\n    subtype.ext (e.right_inv (ha2 ▸ e.map_source (hs ha1))),\n  continuous_to_fun := (continuous_on_iff_continuous_restrict.mp\n    (e.continuous_on.mono hs)).subtype_mk _,\n  continuous_inv_fun := (continuous_on_iff_continuous_restrict.mp\n    (e.continuous_on_symm.mono (λ b hb, let ⟨a, ha1, ha2⟩ := show b ∈ e '' s, from ht.symm ▸ hb in\n      ha2 ▸ e.map_source (hs ha1)))).subtype_mk _ }\n\n/-- A local homeomrphism defines a homeomorphism between its source and target. -/\ndef to_homeomorph_source_target : e.source ≃ₜ e.target :=\ne.homeomorph_of_image_subset_source subset_rfl e.image_source_eq_target\n\nlemma second_countable_topology_source [second_countable_topology β]\n  (e : local_homeomorph α β) :\n  second_countable_topology e.source :=\ne.to_homeomorph_source_target.second_countable_topology\n\n/-- If a local homeomorphism has source and target equal to univ, then it induces a homeomorphism\nbetween the whole spaces, expressed in this definition. -/\n@[simps apply symm_apply (mfld_cfg)]\ndef to_homeomorph_of_source_eq_univ_target_eq_univ (h : e.source = (univ : set α))\n  (h' : e.target = univ) : α ≃ₜ β :=\n{ to_fun := e,\n  inv_fun := e.symm,\n  left_inv := λx, e.left_inv $ by { rw h, exact mem_univ _ },\n  right_inv := λx, e.right_inv $ by { rw h', exact mem_univ _ },\n  continuous_to_fun := begin\n    rw [continuous_iff_continuous_on_univ],\n    convert e.continuous_to_fun,\n    rw h\n  end,\n  continuous_inv_fun := begin\n    rw [continuous_iff_continuous_on_univ],\n    convert e.continuous_inv_fun,\n    rw h'\n  end }\n\n/-- A local homeomorphism whose source is all of `α` defines an open embedding of `α` into `β`.  The\nconverse is also true; see `open_embedding.to_local_homeomorph`. -/\nlemma to_open_embedding (h : e.source = set.univ) : open_embedding e :=\nbegin\n  apply open_embedding_of_continuous_injective_open,\n  { apply continuous_iff_continuous_on_univ.mpr,\n    rw ← h,\n    exact e.continuous_to_fun },\n  { apply set.injective_iff_inj_on_univ.mpr,\n    rw ← h,\n    exact e.inj_on },\n  { intros U hU,\n    simpa only [h, subset_univ] with mfld_simps using e.image_open_of_open hU}\nend\n\nend local_homeomorph\n\nnamespace homeomorph\nvariables (e : α ≃ₜ β) (e' : β ≃ₜ γ)\n/- Register as simp lemmas that the fields of a local homeomorphism built from a homeomorphism\ncorrespond to the fields of the original homeomorphism. -/\n\n@[simp, mfld_simps] lemma refl_to_local_homeomorph :\n  (homeomorph.refl α).to_local_homeomorph = local_homeomorph.refl α := rfl\n@[simp, mfld_simps] lemma symm_to_local_homeomorph :\n  e.symm.to_local_homeomorph = e.to_local_homeomorph.symm := rfl\n@[simp, mfld_simps] lemma trans_to_local_homeomorph :\n  (e.trans e').to_local_homeomorph = e.to_local_homeomorph.trans e'.to_local_homeomorph :=\nlocal_homeomorph.eq_of_local_equiv_eq $ equiv.trans_to_local_equiv _ _\n\nend homeomorph\n\nnamespace open_embedding\nvariables (f : α → β) (h : open_embedding f)\n\n/-- An open embedding of `α` into `β`, with `α` nonempty, defines a local homeomorphism whose source\nis all of `α`.  The converse is also true; see `local_homeomorph.to_open_embedding`. -/\n@[simps apply source target (mfld_cfg)]\nnoncomputable def to_local_homeomorph [nonempty α] : local_homeomorph α β :=\nlocal_homeomorph.of_continuous_open\n  ((h.to_embedding.inj.inj_on univ).to_local_equiv _ _)\n  h.continuous.continuous_on h.is_open_map is_open_univ\n\nlemma continuous_at_iff\n  {f : α → β} {g : β → γ} (hf : open_embedding f) {x : α} :\n  continuous_at (g ∘ f) x ↔ continuous_at g (f x) :=\nbegin\n  haveI : nonempty α := ⟨x⟩,\n  convert (((hf.to_local_homeomorph f).continuous_at_iff_continuous_at_comp_right) _).symm,\n  { apply (local_homeomorph.left_inv _ _).symm,\n    simp, },\n  { simp, },\nend\n\nend open_embedding\n\nnamespace topological_space.opens\n\nopen topological_space\nvariables (s : opens α) [nonempty s]\n\n/-- The inclusion of an open subset `s` of a space `α` into `α` is a local homeomorphism from the\nsubtype `s` to `α`. -/\nnoncomputable def local_homeomorph_subtype_coe : local_homeomorph s α :=\nopen_embedding.to_local_homeomorph _ s.2.open_embedding_subtype_coe\n\n@[simp, mfld_simps] lemma local_homeomorph_subtype_coe_coe :\n  (s.local_homeomorph_subtype_coe : s → α) = coe := rfl\n\n@[simp, mfld_simps] lemma local_homeomorph_subtype_coe_source :\n  s.local_homeomorph_subtype_coe.source = set.univ := rfl\n\n@[simp, mfld_simps] lemma local_homeomorph_subtype_coe_target :\n  s.local_homeomorph_subtype_coe.target = s :=\nby { simp only [local_homeomorph_subtype_coe, subtype.range_coe_subtype] with mfld_simps, refl }\n\nend topological_space.opens\n\nnamespace local_homeomorph\n\nopen topological_space\nvariables (e : local_homeomorph α β)\nvariables (s : opens α) [nonempty s]\n\n/-- The restriction of a local homeomorphism `e` to an open subset `s` of the domain type produces a\nlocal homeomorphism whose domain is the subtype `s`.-/\nnoncomputable def subtype_restr : local_homeomorph s β := s.local_homeomorph_subtype_coe.trans e\n\nlemma subtype_restr_def : e.subtype_restr s = s.local_homeomorph_subtype_coe.trans e := rfl\n\n@[simp, mfld_simps] lemma subtype_restr_coe : ((e.subtype_restr s : local_homeomorph s β) : s → β)\n  = set.restrict ↑s (e : α → β) := rfl\n\n@[simp, mfld_simps] lemma subtype_restr_source : (e.subtype_restr s).source = coe ⁻¹' e.source :=\nby simp only [subtype_restr_def] with mfld_simps\n\n/- This lemma characterizes the transition functions of an open subset in terms of the transition\nfunctions of the original space. -/\nlemma subtype_restr_symm_trans_subtype_restr (f f' : local_homeomorph α β) :\n  (f.subtype_restr s).symm.trans (f'.subtype_restr s)\n  ≈ (f.symm.trans f').restr (f.target ∩ (f.symm) ⁻¹' s) :=\nbegin\n  simp only [subtype_restr_def, trans_symm_eq_symm_trans_symm],\n  have openness₁ : is_open (f.target ∩ f.symm ⁻¹' s) := f.preimage_open_of_open_symm s.2,\n  rw [← of_set_trans _ openness₁, ← trans_assoc, ← trans_assoc],\n  refine eq_on_source.trans' _ (eq_on_source_refl _),\n  -- f' has been eliminated !!!\n  have sets_identity : f.symm.source ∩ (f.target ∩ (f.symm) ⁻¹' s) = f.symm.source ∩ f.symm ⁻¹' s,\n  { mfld_set_tac },\n  have openness₂ : is_open (s : set α) := s.2,\n  rw [of_set_trans', sets_identity, ← trans_of_set' _ openness₂, trans_assoc],\n  refine eq_on_source.trans' (eq_on_source_refl _) _,\n  -- f has been eliminated !!!\n  refine setoid.trans (trans_symm_self s.local_homeomorph_subtype_coe) _,\n  simp only with mfld_simps,\nend\n\nend local_homeomorph\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/local_homeomorph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085859124003, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4683840706843568}}
{"text": "def p (x : Nat := 0) : Nat × Nat :=\n(x, x)\n\ntheorem ex1 : p.1 = 0 :=\nrfl\n\ntheorem ex2 : (p (x := 1) |>.2) = 1 :=\nrfl\n\ndef c {α : Type} [Inhabited α] : α × α :=\n(arbitrary, arbitrary)\n\ntheorem ex3 {α} [Inhabited α] : c.1 = arbitrary (α := α) :=\nrfl\n\ntheorem ex4 {α} [Inhabited α] : c.2 = arbitrary (α := α) :=\nrfl\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/run/optParam.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.468342337458674}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl\n\n! This file was ported from Lean 3 source module algebra.order.monoid.with_top\n! leanprover-community/mathlib commit 0111834459f5d7400215223ea95ae38a1265a907\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Hom.Group\nimport Mathbin.Algebra.Order.Monoid.OrderDual\nimport Mathbin.Algebra.Order.Monoid.WithZero.Basic\nimport Mathbin.Data.Nat.Cast.Defs\n\n/-! # Adjoining top/bottom elements to ordered monoids.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nuniverse u v\n\nvariable {α : Type u} {β : Type v}\n\nopen Function\n\nnamespace WithTop\n\nsection One\n\nvariable [One α]\n\n@[to_additive]\ninstance : One (WithTop α) :=\n  ⟨(1 : α)⟩\n\n#print WithTop.coe_one /-\n@[simp, norm_cast, to_additive]\ntheorem coe_one : ((1 : α) : WithTop α) = 1 :=\n  rfl\n#align with_top.coe_one WithTop.coe_one\n#align with_top.coe_zero WithTop.coe_zero\n-/\n\n#print WithTop.coe_eq_one /-\n@[simp, norm_cast, to_additive]\ntheorem coe_eq_one {a : α} : (a : WithTop α) = 1 ↔ a = 1 :=\n  coe_eq_coe\n#align with_top.coe_eq_one WithTop.coe_eq_one\n#align with_top.coe_eq_zero WithTop.coe_eq_zero\n-/\n\n#print WithTop.untop_one /-\n@[simp, to_additive]\ntheorem untop_one : (1 : WithTop α).untop coe_ne_top = 1 :=\n  rfl\n#align with_top.untop_one WithTop.untop_one\n#align with_top.untop_zero WithTop.untop_zero\n-/\n\n#print WithTop.untop_one' /-\n@[simp, to_additive]\ntheorem untop_one' (d : α) : (1 : WithTop α).untop' d = 1 :=\n  rfl\n#align with_top.untop_one' WithTop.untop_one'\n#align with_top.untop_zero' WithTop.untop_zero'\n-/\n\n/- warning: with_top.one_le_coe -> WithTop.one_le_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (OfNat.mk.{u1} (WithTop.{u1} α) 1 (One.one.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a)) (LE.le.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (One.toOfNat1.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1))) (WithTop.some.{u1} α a)) (LE.le.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_top.one_le_coe WithTop.one_le_coeₓ'. -/\n@[simp, norm_cast, to_additive coe_nonneg]\ntheorem one_le_coe [LE α] {a : α} : 1 ≤ (a : WithTop α) ↔ 1 ≤ a :=\n  coe_le_coe\n#align with_top.one_le_coe WithTop.one_le_coe\n#align with_top.coe_nonneg WithTop.coe_nonneg\n\n/- warning: with_top.coe_le_one -> WithTop.coe_le_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (OfNat.mk.{u1} (WithTop.{u1} α) 1 (One.one.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1))))) (LE.le.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) (WithTop.some.{u1} α a) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (One.toOfNat1.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1)))) (LE.le.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_le_one WithTop.coe_le_oneₓ'. -/\n@[simp, norm_cast, to_additive coe_le_zero]\ntheorem coe_le_one [LE α] {a : α} : (a : WithTop α) ≤ 1 ↔ a ≤ 1 :=\n  coe_le_coe\n#align with_top.coe_le_one WithTop.coe_le_one\n#align with_top.coe_le_zero WithTop.coe_le_zero\n\n/- warning: with_top.one_lt_coe -> WithTop.one_lt_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (OfNat.mk.{u1} (WithTop.{u1} α) 1 (One.one.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a)) (LT.lt.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (One.toOfNat1.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1))) (WithTop.some.{u1} α a)) (LT.lt.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_top.one_lt_coe WithTop.one_lt_coeₓ'. -/\n@[simp, norm_cast, to_additive coe_pos]\ntheorem one_lt_coe [LT α] {a : α} : 1 < (a : WithTop α) ↔ 1 < a :=\n  coe_lt_coe\n#align with_top.one_lt_coe WithTop.one_lt_coe\n#align with_top.coe_pos WithTop.coe_pos\n\n/- warning: with_top.coe_lt_one -> WithTop.coe_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (OfNat.mk.{u1} (WithTop.{u1} α) 1 (One.one.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1))))) (LT.lt.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) (WithTop.some.{u1} α a) (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (One.toOfNat1.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1)))) (LT.lt.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_one WithTop.coe_lt_oneₓ'. -/\n@[simp, norm_cast, to_additive coe_lt_zero]\ntheorem coe_lt_one [LT α] {a : α} : (a : WithTop α) < 1 ↔ a < 1 :=\n  coe_lt_coe\n#align with_top.coe_lt_one WithTop.coe_lt_one\n#align with_top.coe_lt_zero WithTop.coe_lt_zero\n\n/- warning: with_top.map_one -> WithTop.map_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] {β : Type.{u2}} (f : α -> β), Eq.{succ u2} (WithTop.{u2} β) (WithTop.map.{u1, u2} α β f (OfNat.ofNat.{u1} (WithTop.{u1} α) 1 (OfNat.mk.{u1} (WithTop.{u1} α) 1 (One.one.{u1} (WithTop.{u1} α) (WithTop.one.{u1} α _inst_1))))) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) β (WithTop.{u2} β) (HasLiftT.mk.{succ u2, succ u2} β (WithTop.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} β (WithTop.{u2} β) (WithTop.hasCoeT.{u2} β))) (f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1)))))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : One.{u2} α] {β : Type.{u1}} (f : α -> β), Eq.{succ u1} (WithTop.{u1} β) (WithTop.map.{u2, u1} α β f (OfNat.ofNat.{u2} (WithTop.{u2} α) 1 (One.toOfNat1.{u2} (WithTop.{u2} α) (WithTop.one.{u2} α _inst_1)))) (WithTop.some.{u1} β (f (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1))))\nCase conversion may be inaccurate. Consider using '#align with_top.map_one WithTop.map_oneₓ'. -/\n@[simp, to_additive]\nprotected theorem map_one {β} (f : α → β) : (1 : WithTop α).map f = (f 1 : WithTop β) :=\n  rfl\n#align with_top.map_one WithTop.map_one\n#align with_top.map_zero WithTop.map_zero\n\n#print WithTop.one_eq_coe /-\n@[simp, norm_cast, to_additive]\ntheorem one_eq_coe {a : α} : 1 = (a : WithTop α) ↔ a = 1 :=\n  trans eq_comm coe_eq_one\n#align with_top.one_eq_coe WithTop.one_eq_coe\n#align with_top.zero_eq_coe WithTop.zero_eq_coe\n-/\n\n#print WithTop.top_ne_one /-\n@[simp, to_additive]\ntheorem top_ne_one : ⊤ ≠ (1 : WithTop α) :=\n  fun.\n#align with_top.top_ne_one WithTop.top_ne_one\n#align with_top.top_ne_zero WithTop.top_ne_zero\n-/\n\n#print WithTop.one_ne_top /-\n@[simp, to_additive]\ntheorem one_ne_top : (1 : WithTop α) ≠ ⊤ :=\n  fun.\n#align with_top.one_ne_top WithTop.one_ne_top\n#align with_top.zero_ne_top WithTop.zero_ne_top\n-/\n\ninstance [Zero α] [LE α] [ZeroLEOneClass α] : ZeroLEOneClass (WithTop α) :=\n  ⟨some_le_some.2 zero_le_one⟩\n\nend One\n\nsection Add\n\nvariable [Add α] {a b c d : WithTop α} {x y : α}\n\ninstance : Add (WithTop α) :=\n  ⟨Option.map₂ (· + ·)⟩\n\n#print WithTop.coe_add /-\n@[norm_cast]\ntheorem coe_add : ((x + y : α) : WithTop α) = x + y :=\n  rfl\n#align with_top.coe_add WithTop.coe_add\n-/\n\n#print WithTop.coe_bit0 /-\n@[norm_cast]\ntheorem coe_bit0 : ((bit0 x : α) : WithTop α) = bit0 x :=\n  rfl\n#align with_top.coe_bit0 WithTop.coe_bit0\n-/\n\n#print WithTop.coe_bit1 /-\n@[norm_cast]\ntheorem coe_bit1 [One α] {a : α} : ((bit1 a : α) : WithTop α) = bit1 a :=\n  rfl\n#align with_top.coe_bit1 WithTop.coe_bit1\n-/\n\n#print WithTop.top_add /-\n@[simp]\ntheorem top_add (a : WithTop α) : ⊤ + a = ⊤ :=\n  rfl\n#align with_top.top_add WithTop.top_add\n-/\n\n#print WithTop.add_top /-\n@[simp]\ntheorem add_top (a : WithTop α) : a + ⊤ = ⊤ := by cases a <;> rfl\n#align with_top.add_top WithTop.add_top\n-/\n\n#print WithTop.add_eq_top /-\n@[simp]\ntheorem add_eq_top : a + b = ⊤ ↔ a = ⊤ ∨ b = ⊤ := by\n  cases a <;> cases b <;> simp [none_eq_top, some_eq_coe, ← WithTop.coe_add]\n#align with_top.add_eq_top WithTop.add_eq_top\n-/\n\n#print WithTop.add_ne_top /-\ntheorem add_ne_top : a + b ≠ ⊤ ↔ a ≠ ⊤ ∧ b ≠ ⊤ :=\n  add_eq_top.Not.trans not_or\n#align with_top.add_ne_top WithTop.add_ne_top\n-/\n\n/- warning: with_top.add_lt_top -> WithTop.add_lt_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (And (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α}, Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (And (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) b (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_top WithTop.add_lt_topₓ'. -/\ntheorem add_lt_top [LT α] {a b : WithTop α} : a + b < ⊤ ↔ a < ⊤ ∧ b < ⊤ := by\n  simp_rw [WithTop.lt_top_iff_ne_top, add_ne_top]\n#align with_top.add_lt_top WithTop.add_lt_top\n\n#print WithTop.add_eq_coe /-\ntheorem add_eq_coe :\n    ∀ {a b : WithTop α} {c : α}, a + b = c ↔ ∃ a' b' : α, ↑a' = a ∧ ↑b' = b ∧ a' + b' = c\n  | none, b, c => by simp [none_eq_top]\n  | some a, none, c => by simp [none_eq_top]\n  | some a, some b, c => by\n    simp only [some_eq_coe, ← coe_add, coe_eq_coe, exists_and_left, exists_eq_left]\n#align with_top.add_eq_coe WithTop.add_eq_coe\n-/\n\n#print WithTop.add_coe_eq_top_iff /-\n@[simp]\ntheorem add_coe_eq_top_iff {x : WithTop α} {y : α} : x + y = ⊤ ↔ x = ⊤ := by\n  induction x using WithTop.recTopCoe <;> simp [← coe_add]\n#align with_top.add_coe_eq_top_iff WithTop.add_coe_eq_top_iff\n-/\n\n#print WithTop.coe_add_eq_top_iff /-\n@[simp]\ntheorem coe_add_eq_top_iff {y : WithTop α} : ↑x + y = ⊤ ↔ y = ⊤ := by\n  induction y using WithTop.recTopCoe <;> simp [← coe_add]\n#align with_top.coe_add_eq_top_iff WithTop.coe_add_eq_top_iff\n-/\n\n/- warning: with_top.covariant_class_add_le -> WithTop.covariantClass_add_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LE.le.{u1} α _inst_2)], CovariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1))) (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1184 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1186 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1184 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1186) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1199 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1201 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1199 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1201)], CovariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1223 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1225 : WithTop.{u1} α) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1223 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1225) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1238 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1240 : WithTop.{u1} α) => LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1238 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1240)\nCase conversion may be inaccurate. Consider using '#align with_top.covariant_class_add_le WithTop.covariantClass_add_leₓ'. -/\ninstance covariantClass_add_le [LE α] [CovariantClass α α (· + ·) (· ≤ ·)] :\n    CovariantClass (WithTop α) (WithTop α) (· + ·) (· ≤ ·) :=\n  ⟨fun a b c h => by\n    cases a <;> cases c <;> try exact le_top\n    rcases le_coe_iff.1 h with ⟨b, rfl, h'⟩\n    exact coe_le_coe.2 (add_le_add_left (coe_le_coe.1 h) _)⟩\n#align with_top.covariant_class_add_le WithTop.covariantClass_add_le\n\n/- warning: with_top.covariant_class_swap_add_le -> WithTop.covariantClass_swap_add_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LE.le.{u1} α _inst_2)], CovariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} α) (WithTop.{u1} α) (fun (ᾰ : WithTop.{u1} α) (ᾰ : WithTop.{u1} α) => WithTop.{u1} α) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)))) (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1379 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1381 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1379 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1381)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1394 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1396 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1394 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1396)], CovariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} α) (WithTop.{u1} α) (fun (ᾰ : WithTop.{u1} α) (ᾰ : WithTop.{u1} α) => WithTop.{u1} α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1421 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1423 : WithTop.{u1} α) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1421 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1423)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1436 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1438 : WithTop.{u1} α) => LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1436 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1438)\nCase conversion may be inaccurate. Consider using '#align with_top.covariant_class_swap_add_le WithTop.covariantClass_swap_add_leₓ'. -/\ninstance covariantClass_swap_add_le [LE α] [CovariantClass α α (swap (· + ·)) (· ≤ ·)] :\n    CovariantClass (WithTop α) (WithTop α) (swap (· + ·)) (· ≤ ·) :=\n  ⟨fun a b c h => by\n    cases a <;> cases c <;> try exact le_top\n    rcases le_coe_iff.1 h with ⟨b, rfl, h'⟩\n    exact coe_le_coe.2 (add_le_add_right (coe_le_coe.1 h) _)⟩\n#align with_top.covariant_class_swap_add_le WithTop.covariantClass_swap_add_le\n\n/- warning: with_top.contravariant_class_add_lt -> WithTop.contravariantClass_add_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LT.lt.{u1} α _inst_2)], ContravariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1))) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1574 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1576 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1574 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1576) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1589 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1591 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1589 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1591)], ContravariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1613 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1615 : WithTop.{u1} α) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1613 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1615) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1628 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1630 : WithTop.{u1} α) => LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1628 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1630)\nCase conversion may be inaccurate. Consider using '#align with_top.contravariant_class_add_lt WithTop.contravariantClass_add_ltₓ'. -/\ninstance contravariantClass_add_lt [LT α] [ContravariantClass α α (· + ·) (· < ·)] :\n    ContravariantClass (WithTop α) (WithTop α) (· + ·) (· < ·) :=\n  ⟨fun a b c h => by\n    induction a using WithTop.recTopCoe; · exact (not_none_lt _ h).elim\n    induction b using WithTop.recTopCoe; · exact (not_none_lt _ h).elim\n    induction c using WithTop.recTopCoe\n    · exact coe_lt_top _\n    · exact coe_lt_coe.2 (lt_of_add_lt_add_left <| coe_lt_coe.1 h)⟩\n#align with_top.contravariant_class_add_lt WithTop.contravariantClass_add_lt\n\n/- warning: with_top.contravariant_class_swap_add_lt -> WithTop.contravariantClass_swap_add_lt is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LT.lt.{u1} α _inst_2)], ContravariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} α) (WithTop.{u1} α) (fun (ᾰ : WithTop.{u1} α) (ᾰ : WithTop.{u1} α) => WithTop.{u1} α) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)))) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1724 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1726 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1724 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1726)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1739 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1741 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1739 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1741)], ContravariantClass.{u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} α) (WithTop.{u1} α) (fun (ᾰ : WithTop.{u1} α) (ᾰ : WithTop.{u1} α) => WithTop.{u1} α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1766 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1768 : WithTop.{u1} α) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1766 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1768)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1781 : WithTop.{u1} α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1783 : WithTop.{u1} α) => LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1781 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1783)\nCase conversion may be inaccurate. Consider using '#align with_top.contravariant_class_swap_add_lt WithTop.contravariantClass_swap_add_ltₓ'. -/\ninstance contravariantClass_swap_add_lt [LT α] [ContravariantClass α α (swap (· + ·)) (· < ·)] :\n    ContravariantClass (WithTop α) (WithTop α) (swap (· + ·)) (· < ·) :=\n  ⟨fun a b c h => by\n    cases a <;> cases b <;> try exact (not_none_lt _ h).elim\n    cases c\n    · exact coe_lt_top _\n    · exact coe_lt_coe.2 (lt_of_add_lt_add_right <| coe_lt_coe.1 h)⟩\n#align with_top.contravariant_class_swap_add_lt WithTop.contravariantClass_swap_add_lt\n\n/- warning: with_top.le_of_add_le_add_left -> WithTop.le_of_add_le_add_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LE.le.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c)) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) b c)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1944 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1946 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1944 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1946) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1959 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1961 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1959 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1961)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c)) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) b c)\nCase conversion may be inaccurate. Consider using '#align with_top.le_of_add_le_add_left WithTop.le_of_add_le_add_leftₓ'. -/\nprotected theorem le_of_add_le_add_left [LE α] [ContravariantClass α α (· + ·) (· ≤ ·)] (ha : a ≠ ⊤)\n    (h : a + b ≤ a + c) : b ≤ c := by\n  lift a to α using ha\n  induction c using WithTop.recTopCoe; · exact le_top\n  induction b using WithTop.recTopCoe; · exact (not_top_le_coe _ h).elim\n  simp only [← coe_add, coe_le_coe] at h⊢\n  exact le_of_add_le_add_left h\n#align with_top.le_of_add_le_add_left WithTop.le_of_add_le_add_left\n\n/- warning: with_top.le_of_add_le_add_right -> WithTop.le_of_add_le_add_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LE.le.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a)) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) b c)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2071 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2073 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2071 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2073)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2086 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2088 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2086 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2088)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a)) -> (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) b c)\nCase conversion may be inaccurate. Consider using '#align with_top.le_of_add_le_add_right WithTop.le_of_add_le_add_rightₓ'. -/\nprotected theorem le_of_add_le_add_right [LE α] [ContravariantClass α α (swap (· + ·)) (· ≤ ·)]\n    (ha : a ≠ ⊤) (h : b + a ≤ c + a) : b ≤ c :=\n  by\n  lift a to α using ha\n  cases c\n  · exact le_top\n  cases b\n  · exact (not_top_le_coe _ h).elim\n  · exact coe_le_coe.2 (le_of_add_le_add_right <| coe_le_coe.1 h)\n#align with_top.le_of_add_le_add_right WithTop.le_of_add_le_add_right\n\n/- warning: with_top.add_lt_add_left -> WithTop.add_lt_add_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LT.lt.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2206 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2208 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2206 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2208) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2221 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2223 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2221 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2223)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_add_left WithTop.add_lt_add_leftₓ'. -/\nprotected theorem add_lt_add_left [LT α] [CovariantClass α α (· + ·) (· < ·)] (ha : a ≠ ⊤)\n    (h : b < c) : a + b < a + c := by\n  lift a to α using ha\n  rcases lt_iff_exists_coe.1 h with ⟨b, rfl, h'⟩\n  cases c\n  · exact coe_lt_top _\n  · exact coe_lt_coe.2 (add_lt_add_left (coe_lt_coe.1 h) _)\n#align with_top.add_lt_add_left WithTop.add_lt_add_left\n\n/- warning: with_top.add_lt_add_right -> WithTop.add_lt_add_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LT.lt.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2335 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2337 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2335 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2337)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2350 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2352 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2350 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2352)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_add_right WithTop.add_lt_add_rightₓ'. -/\nprotected theorem add_lt_add_right [LT α] [CovariantClass α α (swap (· + ·)) (· < ·)] (ha : a ≠ ⊤)\n    (h : b < c) : b + a < c + a := by\n  lift a to α using ha\n  rcases lt_iff_exists_coe.1 h with ⟨b, rfl, h'⟩\n  cases c\n  · exact coe_lt_top _\n  · exact coe_lt_coe.2 (add_lt_add_right (coe_lt_coe.1 h) _)\n#align with_top.add_lt_add_right WithTop.add_lt_add_right\n\n/- warning: with_top.add_le_add_iff_left -> WithTop.add_le_add_iff_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LE.le.{u1} α _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LE.le.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c)) (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2461 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2463 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2461 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2463) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2476 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2478 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2476 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2478)] [_inst_4 : ContravariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2495 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2497 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2495 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2497) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2510 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2512 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2510 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2512)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c)) (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align with_top.add_le_add_iff_left WithTop.add_le_add_iff_leftₓ'. -/\nprotected theorem add_le_add_iff_left [LE α] [CovariantClass α α (· + ·) (· ≤ ·)]\n    [ContravariantClass α α (· + ·) (· ≤ ·)] (ha : a ≠ ⊤) : a + b ≤ a + c ↔ b ≤ c :=\n  ⟨WithTop.le_of_add_le_add_left ha, fun h => add_le_add_left h a⟩\n#align with_top.add_le_add_iff_left WithTop.add_le_add_iff_left\n\n/- warning: with_top.add_le_add_iff_right -> WithTop.add_le_add_iff_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LE.le.{u1} α _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LE.le.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a)) (LE.le.{u1} (WithTop.{u1} α) (WithTop.hasLe.{u1} α _inst_2) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LE.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2586 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2588 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2586 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2588)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2601 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2603 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2601 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2603)] [_inst_4 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2623 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2625 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2623 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2625)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2638 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2640 : α) => LE.le.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2638 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2640)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (Iff (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a)) (LE.le.{u1} (WithTop.{u1} α) (WithTop.le.{u1} α _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align with_top.add_le_add_iff_right WithTop.add_le_add_iff_rightₓ'. -/\nprotected theorem add_le_add_iff_right [LE α] [CovariantClass α α (swap (· + ·)) (· ≤ ·)]\n    [ContravariantClass α α (swap (· + ·)) (· ≤ ·)] (ha : a ≠ ⊤) : b + a ≤ c + a ↔ b ≤ c :=\n  ⟨WithTop.le_of_add_le_add_right ha, fun h => add_le_add_right h a⟩\n#align with_top.add_le_add_iff_right WithTop.add_le_add_iff_right\n\n/- warning: with_top.add_lt_add_iff_left -> WithTop.add_lt_add_iff_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LT.lt.{u1} α _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} α α (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1)) (LT.lt.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2711 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2713 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2711 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2713) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2726 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2728 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2726 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2728)] [_inst_4 : ContravariantClass.{u1, u1} α α (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2745 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2747 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2745 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2747) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2760 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2762 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2760 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2762)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a c)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_add_iff_left WithTop.add_lt_add_iff_leftₓ'. -/\nprotected theorem add_lt_add_iff_left [LT α] [CovariantClass α α (· + ·) (· < ·)]\n    [ContravariantClass α α (· + ·) (· < ·)] (ha : a ≠ ⊤) : a + b < a + c ↔ b < c :=\n  ⟨lt_of_add_lt_add_left, WithTop.add_lt_add_left ha⟩\n#align with_top.add_lt_add_iff_left WithTop.add_lt_add_iff_left\n\n/- warning: with_top.add_lt_add_iff_right -> WithTop.add_lt_add_iff_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LT.lt.{u1} α _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1))) (LT.lt.{u1} α _inst_2)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))) -> (Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.hasLt.{u1} α _inst_2) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] {a : WithTop.{u1} α} {b : WithTop.{u1} α} {c : WithTop.{u1} α} [_inst_2 : LT.{u1} α] [_inst_3 : CovariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2831 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2833 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2831 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2833)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2846 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2848 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2846 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2848)] [_inst_4 : ContravariantClass.{u1, u1} α α (Function.swap.{succ u1, succ u1, succ u1} α α (fun (ᾰ : α) (ᾰ : α) => α) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2868 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2870 : α) => HAdd.hAdd.{u1, u1, u1} α α α (instHAdd.{u1} α _inst_1) x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2868 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2870)) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2883 : α) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2885 : α) => LT.lt.{u1} α _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2883 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2885)], (Ne.{succ u1} (WithTop.{u1} α) a (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))) -> (Iff (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) c a)) (LT.lt.{u1} (WithTop.{u1} α) (WithTop.lt.{u1} α _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_add_iff_right WithTop.add_lt_add_iff_rightₓ'. -/\nprotected theorem add_lt_add_iff_right [LT α] [CovariantClass α α (swap (· + ·)) (· < ·)]\n    [ContravariantClass α α (swap (· + ·)) (· < ·)] (ha : a ≠ ⊤) : b + a < c + a ↔ b < c :=\n  ⟨lt_of_add_lt_add_right, WithTop.add_lt_add_right ha⟩\n#align with_top.add_lt_add_iff_right WithTop.add_lt_add_iff_right\n\n#print WithTop.add_lt_add_of_le_of_lt /-\nprotected theorem add_lt_add_of_le_of_lt [Preorder α] [CovariantClass α α (· + ·) (· < ·)]\n    [CovariantClass α α (swap (· + ·)) (· ≤ ·)] (ha : a ≠ ⊤) (hab : a ≤ b) (hcd : c < d) :\n    a + c < b + d :=\n  (WithTop.add_lt_add_left ha hcd).trans_le <| add_le_add_right hab _\n#align with_top.add_lt_add_of_le_of_lt WithTop.add_lt_add_of_le_of_lt\n-/\n\n#print WithTop.add_lt_add_of_lt_of_le /-\nprotected theorem add_lt_add_of_lt_of_le [Preorder α] [CovariantClass α α (· + ·) (· ≤ ·)]\n    [CovariantClass α α (swap (· + ·)) (· < ·)] (hc : c ≠ ⊤) (hab : a < b) (hcd : c ≤ d) :\n    a + c < b + d :=\n  (WithTop.add_lt_add_right hc hab).trans_le <| add_le_add_left hcd _\n#align with_top.add_lt_add_of_lt_of_le WithTop.add_lt_add_of_lt_of_le\n-/\n\n/- warning: with_top.map_add -> WithTop.map_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Add.{u1} α] {F : Type.{u3}} [_inst_2 : Add.{u2} β] [_inst_3 : AddHomClass.{u3, u1, u2} F α β _inst_1 _inst_2] (f : F) (a : WithTop.{u1} α) (b : WithTop.{u1} α), Eq.{succ u2} (WithTop.{u2} β) (WithTop.map.{u1, u2} α β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β _inst_1 _inst_2 _inst_3)) f) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} α) (WithTop.{u1} α) (WithTop.{u1} α) (instHAdd.{u1} (WithTop.{u1} α) (WithTop.add.{u1} α _inst_1)) a b)) (HAdd.hAdd.{u2, u2, u2} (WithTop.{u2} β) (WithTop.{u2} β) (WithTop.{u2} β) (instHAdd.{u2} (WithTop.{u2} β) (WithTop.add.{u2} β _inst_2)) (WithTop.map.{u1, u2} α β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β _inst_1 _inst_2 _inst_3)) f) a) (WithTop.map.{u1, u2} α β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β _inst_1 _inst_2 _inst_3)) f) b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : Add.{u2} α] {F : Type.{u1}} [_inst_2 : Add.{u3} β] [_inst_3 : AddHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : WithTop.{u2} α) (b : WithTop.{u2} α), Eq.{succ u3} (WithTop.{u3} β) (WithTop.map.{u2, u3} α β (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3) f) (HAdd.hAdd.{u2, u2, u2} (WithTop.{u2} α) (WithTop.{u2} α) (WithTop.{u2} α) (instHAdd.{u2} (WithTop.{u2} α) (WithTop.add.{u2} α _inst_1)) a b)) (HAdd.hAdd.{u3, u3, u3} (WithTop.{u3} β) (WithTop.{u3} β) (WithTop.{u3} β) (instHAdd.{u3} (WithTop.{u3} β) (WithTop.add.{u3} β _inst_2)) (WithTop.map.{u2, u3} α β (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3) f) a) (WithTop.map.{u2, u3} α β (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3) f) b))\nCase conversion may be inaccurate. Consider using '#align with_top.map_add WithTop.map_addₓ'. -/\n--  There is no `with_top.map_mul_of_mul_hom`, since `with_top` does not have a multiplication.\n@[simp]\nprotected theorem map_add {F} [Add β] [AddHomClass F α β] (f : F) (a b : WithTop α) :\n    (a + b).map f = a.map f + b.map f :=\n  by\n  induction a using WithTop.recTopCoe\n  · exact (top_add _).symm\n  · induction b using WithTop.recTopCoe\n    · exact (add_top _).symm\n    · rw [map_coe, map_coe, ← coe_add, ← coe_add, ← map_add]\n      rfl\n#align with_top.map_add WithTop.map_add\n\nend Add\n\ninstance [AddSemigroup α] : AddSemigroup (WithTop α) :=\n  { WithTop.add with add_assoc := fun _ _ _ => Option.map₂_assoc add_assoc }\n\ninstance [AddCommSemigroup α] : AddCommSemigroup (WithTop α) :=\n  { WithTop.addSemigroup with add_comm := fun _ _ => Option.map₂_comm add_comm }\n\ninstance [AddZeroClass α] : AddZeroClass (WithTop α) :=\n  { WithTop.zero,\n    WithTop.add with\n    zero_add := Option.map₂_left_identity zero_add\n    add_zero := Option.map₂_right_identity add_zero }\n\ninstance [AddMonoid α] : AddMonoid (WithTop α) :=\n  { WithTop.addZeroClass, WithTop.zero, WithTop.addSemigroup with }\n\ninstance [AddCommMonoid α] : AddCommMonoid (WithTop α) :=\n  { WithTop.addMonoid, WithTop.addCommSemigroup with }\n\ninstance [AddMonoidWithOne α] : AddMonoidWithOne (WithTop α) :=\n  { WithTop.one,\n    WithTop.addMonoid with\n    natCast := fun n => ↑(n : α)\n    natCast_zero := by rw [Nat.cast_zero, WithTop.coe_zero]\n    natCast_succ := fun n => by rw [Nat.cast_add_one, WithTop.coe_add, WithTop.coe_one] }\n\ninstance [AddCommMonoidWithOne α] : AddCommMonoidWithOne (WithTop α) :=\n  { WithTop.addMonoidWithOne, WithTop.addCommMonoid with }\n\ninstance [OrderedAddCommMonoid α] : OrderedAddCommMonoid (WithTop α) :=\n  { WithTop.partialOrder, WithTop.addCommMonoid with\n    add_le_add_left := by\n      rintro a b h (_ | c); · simp [none_eq_top]\n      rcases b with (_ | b); · simp [none_eq_top]\n      rcases le_coe_iff.1 h with ⟨a, rfl, h⟩\n      simp only [some_eq_coe, ← coe_add, coe_le_coe] at h⊢\n      exact add_le_add_left h c }\n\ninstance [LinearOrderedAddCommMonoid α] : LinearOrderedAddCommMonoidWithTop (WithTop α) :=\n  { WithTop.orderTop, WithTop.linearOrder, WithTop.orderedAddCommMonoid, Option.nontrivial with\n    top_add' := WithTop.top_add }\n\ninstance [LE α] [Add α] [ExistsAddOfLE α] : ExistsAddOfLE (WithTop α) :=\n  ⟨fun a b =>\n    match a, b with\n    | ⊤, ⊤ => by simp\n    | (a : α), ⊤ => fun _ => ⟨⊤, rfl⟩\n    | (a : α), (b : α) => fun h =>\n      by\n      obtain ⟨c, rfl⟩ := exists_add_of_le (WithTop.coe_le_coe.1 h)\n      exact ⟨c, rfl⟩\n    | ⊤, (b : α) => fun h => (not_top_le_coe _ h).elim⟩\n\ninstance [CanonicallyOrderedAddMonoid α] : CanonicallyOrderedAddMonoid (WithTop α) :=\n  { WithTop.orderBot, WithTop.orderedAddCommMonoid, WithTop.existsAddOfLE with\n    le_self_add := fun a b =>\n      match a, b with\n      | ⊤, ⊤ => le_rfl\n      | (a : α), ⊤ => le_top\n      | (a : α), (b : α) => WithTop.coe_le_coe.2 le_self_add\n      | ⊤, (b : α) => le_rfl }\n\ninstance [CanonicallyLinearOrderedAddMonoid α] : CanonicallyLinearOrderedAddMonoid (WithTop α) :=\n  { WithTop.canonicallyOrderedAddMonoid, WithTop.linearOrder with }\n\n#print WithTop.coe_nat /-\n@[simp, norm_cast]\ntheorem coe_nat [AddMonoidWithOne α] (n : ℕ) : ((n : α) : WithTop α) = n :=\n  rfl\n#align with_top.coe_nat WithTop.coe_nat\n-/\n\n#print WithTop.nat_ne_top /-\n@[simp]\ntheorem nat_ne_top [AddMonoidWithOne α] (n : ℕ) : (n : WithTop α) ≠ ⊤ :=\n  coe_ne_top\n#align with_top.nat_ne_top WithTop.nat_ne_top\n-/\n\n#print WithTop.top_ne_nat /-\n@[simp]\ntheorem top_ne_nat [AddMonoidWithOne α] (n : ℕ) : (⊤ : WithTop α) ≠ n :=\n  top_ne_coe\n#align with_top.top_ne_nat WithTop.top_ne_nat\n-/\n\n#print WithTop.addHom /-\n/-- Coercion from `α` to `with_top α` as an `add_monoid_hom`. -/\ndef addHom [AddMonoid α] : α →+ WithTop α :=\n  ⟨coe, rfl, fun _ _ => rfl⟩\n#align with_top.coe_add_hom WithTop.addHom\n-/\n\n@[simp]\ntheorem coe_addHom [AddMonoid α] : ⇑(addHom : α →+ WithTop α) = coe :=\n  rfl\n#align with_top.coe_coe_add_hom WithTop.coe_addHom\n\n/- warning: with_top.zero_lt_top -> WithTop.zero_lt_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} α], LT.lt.{u1} (WithTop.{u1} α) (Preorder.toLT.{u1} (WithTop.{u1} α) (WithTop.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α _inst_1)))))))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.hasTop.{u1} α))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} α], LT.lt.{u1} (WithTop.{u1} α) (Preorder.toLT.{u1} (WithTop.{u1} α) (WithTop.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α _inst_1)))))) (Top.top.{u1} (WithTop.{u1} α) (WithTop.top.{u1} α))\nCase conversion may be inaccurate. Consider using '#align with_top.zero_lt_top WithTop.zero_lt_topₓ'. -/\n@[simp]\ntheorem zero_lt_top [OrderedAddCommMonoid α] : (0 : WithTop α) < ⊤ :=\n  coe_lt_top 0\n#align with_top.zero_lt_top WithTop.zero_lt_top\n\n/- warning: with_top.zero_lt_coe -> WithTop.zero_lt_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} α] (a : α), Iff (LT.lt.{u1} (WithTop.{u1} α) (Preorder.toLT.{u1} (WithTop.{u1} α) (WithTop.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (OfNat.mk.{u1} (WithTop.{u1} α) 0 (Zero.zero.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α _inst_1)))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithTop.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithTop.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithTop.{u1} α) (WithTop.hasCoeT.{u1} α))) a)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α _inst_1))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (AddZeroClass.toHasZero.{u1} α (AddMonoid.toAddZeroClass.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α _inst_1))))))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} α] (a : α), Iff (LT.lt.{u1} (WithTop.{u1} α) (Preorder.toLT.{u1} (WithTop.{u1} α) (WithTop.preorder.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} α) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} α) (WithTop.zero.{u1} α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α _inst_1)))))) (WithTop.some.{u1} α a)) (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommMonoid.toPartialOrder.{u1} α _inst_1))) (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (AddMonoid.toZero.{u1} α (AddCommMonoid.toAddMonoid.{u1} α (OrderedAddCommMonoid.toAddCommMonoid.{u1} α _inst_1))))) a)\nCase conversion may be inaccurate. Consider using '#align with_top.zero_lt_coe WithTop.zero_lt_coeₓ'. -/\n@[simp, norm_cast]\ntheorem zero_lt_coe [OrderedAddCommMonoid α] (a : α) : (0 : WithTop α) < a ↔ 0 < a :=\n  coe_lt_coe\n#align with_top.zero_lt_coe WithTop.zero_lt_coe\n\n#print OneHom.withTopMap /-\n/-- A version of `with_top.map` for `one_hom`s. -/\n@[to_additive \"A version of `with_top.map` for `zero_hom`s\",\n  simps (config := { fullyApplied := false })]\nprotected def OneHom.withTopMap {M N : Type _} [One M] [One N] (f : OneHom M N) :\n    OneHom (WithTop M) (WithTop N) where\n  toFun := WithTop.map f\n  map_one' := by rw [WithTop.map_one, map_one, coe_one]\n#align one_hom.with_top_map OneHom.withTopMap\n#align zero_hom.with_top_map ZeroHom.withTopMap\n-/\n\n#print AddHom.withTopMap /-\n/-- A version of `with_top.map` for `add_hom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def AddHom.withTopMap {M N : Type _} [Add M] [Add N] (f : AddHom M N) :\n    AddHom (WithTop M) (WithTop N) where\n  toFun := WithTop.map f\n  map_add' := WithTop.map_add f\n#align add_hom.with_top_map AddHom.withTopMap\n-/\n\n#print AddMonoidHom.withTopMap /-\n/-- A version of `with_top.map` for `add_monoid_hom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def AddMonoidHom.withTopMap {M N : Type _} [AddZeroClass M] [AddZeroClass N]\n    (f : M →+ N) : WithTop M →+ WithTop N :=\n  { f.toZeroHom.withTop_map, f.toAddHom.withTop_map with toFun := WithTop.map f }\n#align add_monoid_hom.with_top_map AddMonoidHom.withTopMap\n-/\n\nend WithTop\n\nnamespace WithBot\n\n@[to_additive]\ninstance [One α] : One (WithBot α) :=\n  WithTop.one\n\ninstance [Add α] : Add (WithBot α) :=\n  WithTop.add\n\ninstance [AddSemigroup α] : AddSemigroup (WithBot α) :=\n  WithTop.addSemigroup\n\ninstance [AddCommSemigroup α] : AddCommSemigroup (WithBot α) :=\n  WithTop.addCommSemigroup\n\ninstance [AddZeroClass α] : AddZeroClass (WithBot α) :=\n  WithTop.addZeroClass\n\ninstance [AddMonoid α] : AddMonoid (WithBot α) :=\n  WithTop.addMonoid\n\ninstance [AddCommMonoid α] : AddCommMonoid (WithBot α) :=\n  WithTop.addCommMonoid\n\ninstance [AddMonoidWithOne α] : AddMonoidWithOne (WithBot α) :=\n  WithTop.addMonoidWithOne\n\ninstance [AddCommMonoidWithOne α] : AddCommMonoidWithOne (WithBot α) :=\n  WithTop.addCommMonoidWithOne\n\ninstance [Zero α] [One α] [LE α] [ZeroLEOneClass α] : ZeroLEOneClass (WithBot α) :=\n  ⟨some_le_some.2 zero_le_one⟩\n\n#print WithBot.coe_one /-\n-- `by norm_cast` proves this lemma, so I did not tag it with `norm_cast`\n@[to_additive]\ntheorem coe_one [One α] : ((1 : α) : WithBot α) = 1 :=\n  rfl\n#align with_bot.coe_one WithBot.coe_one\n#align with_bot.coe_zero WithBot.coe_zero\n-/\n\n#print WithBot.coe_eq_one /-\n-- `by norm_cast` proves this lemma, so I did not tag it with `norm_cast`\n@[to_additive]\ntheorem coe_eq_one [One α] {a : α} : (a : WithBot α) = 1 ↔ a = 1 :=\n  WithTop.coe_eq_one\n#align with_bot.coe_eq_one WithBot.coe_eq_one\n#align with_bot.coe_eq_zero WithBot.coe_eq_zero\n-/\n\n#print WithBot.unbot_one /-\n@[simp, to_additive]\ntheorem unbot_one [One α] : (1 : WithBot α).unbot coe_ne_bot = 1 :=\n  rfl\n#align with_bot.unbot_one WithBot.unbot_one\n#align with_bot.unbot_zero WithBot.unbot_zero\n-/\n\n#print WithBot.unbot_one' /-\n@[simp, to_additive]\ntheorem unbot_one' [One α] (d : α) : (1 : WithBot α).unbot' d = 1 :=\n  rfl\n#align with_bot.unbot_one' WithBot.unbot_one'\n#align with_bot.unbot_zero' WithBot.unbot_zero'\n-/\n\n/- warning: with_bot.one_le_coe -> WithBot.one_le_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (OfNat.mk.{u1} (WithBot.{u1} α) 1 (One.one.{u1} (WithBot.{u1} α) (WithBot.hasOne.{u1} α _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a)) (LE.le.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (One.toOfNat1.{u1} (WithBot.{u1} α) (WithBot.one.{u1} α _inst_1))) (WithBot.some.{u1} α a)) (LE.le.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.one_le_coe WithBot.one_le_coeₓ'. -/\n@[simp, norm_cast, to_additive coe_nonneg]\ntheorem one_le_coe [One α] [LE α] {a : α} : 1 ≤ (a : WithBot α) ↔ 1 ≤ a :=\n  coe_le_coe\n#align with_bot.one_le_coe WithBot.one_le_coe\n#align with_bot.coe_nonneg WithBot.coe_nonneg\n\n/- warning: with_bot.coe_le_one -> WithBot.coe_le_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.hasLe.{u1} α _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (OfNat.mk.{u1} (WithBot.{u1} α) 1 (One.one.{u1} (WithBot.{u1} α) (WithBot.hasOne.{u1} α _inst_1))))) (LE.le.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LE.{u1} α] {a : α}, Iff (LE.le.{u1} (WithBot.{u1} α) (WithBot.le.{u1} α _inst_2) (WithBot.some.{u1} α a) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (One.toOfNat1.{u1} (WithBot.{u1} α) (WithBot.one.{u1} α _inst_1)))) (LE.le.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le_one WithBot.coe_le_oneₓ'. -/\n@[simp, norm_cast, to_additive coe_le_zero]\ntheorem coe_le_one [One α] [LE α] {a : α} : (a : WithBot α) ≤ 1 ↔ a ≤ 1 :=\n  coe_le_coe\n#align with_bot.coe_le_one WithBot.coe_le_one\n#align with_bot.coe_le_zero WithBot.coe_le_zero\n\n/- warning: with_bot.one_lt_coe -> WithBot.one_lt_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (OfNat.mk.{u1} (WithBot.{u1} α) 1 (One.one.{u1} (WithBot.{u1} α) (WithBot.hasOne.{u1} α _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a)) (LT.lt.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (One.toOfNat1.{u1} (WithBot.{u1} α) (WithBot.one.{u1} α _inst_1))) (WithBot.some.{u1} α a)) (LT.lt.{u1} α _inst_2 (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.one_lt_coe WithBot.one_lt_coeₓ'. -/\n@[simp, norm_cast, to_additive coe_pos]\ntheorem one_lt_coe [One α] [LT α] {a : α} : 1 < (a : WithBot α) ↔ 1 < a :=\n  coe_lt_coe\n#align with_bot.one_lt_coe WithBot.one_lt_coe\n#align with_bot.coe_pos WithBot.coe_pos\n\n/- warning: with_bot.coe_lt_one -> WithBot.coe_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) α (WithBot.{u1} α) (HasLiftT.mk.{succ u1, succ u1} α (WithBot.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} α (WithBot.{u1} α) (WithBot.hasCoeT.{u1} α))) a) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (OfNat.mk.{u1} (WithBot.{u1} α) 1 (One.one.{u1} (WithBot.{u1} α) (WithBot.hasOne.{u1} α _inst_1))))) (LT.lt.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : One.{u1} α] [_inst_2 : LT.{u1} α] {a : α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_2) (WithBot.some.{u1} α a) (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (One.toOfNat1.{u1} (WithBot.{u1} α) (WithBot.one.{u1} α _inst_1)))) (LT.lt.{u1} α _inst_2 a (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_lt_one WithBot.coe_lt_oneₓ'. -/\n@[simp, norm_cast, to_additive coe_lt_zero]\ntheorem coe_lt_one [One α] [LT α] {a : α} : (a : WithBot α) < 1 ↔ a < 1 :=\n  coe_lt_coe\n#align with_bot.coe_lt_one WithBot.coe_lt_one\n#align with_bot.coe_lt_zero WithBot.coe_lt_zero\n\n/- warning: with_bot.map_one -> WithBot.map_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : One.{u1} α] (f : α -> β), Eq.{succ u2} (WithBot.{u2} β) (WithBot.map.{u1, u2} α β f (OfNat.ofNat.{u1} (WithBot.{u1} α) 1 (OfNat.mk.{u1} (WithBot.{u1} α) 1 (One.one.{u1} (WithBot.{u1} α) (WithBot.hasOne.{u1} α _inst_1))))) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) β (WithBot.{u2} β) (HasLiftT.mk.{succ u2, succ u2} β (WithBot.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} β (WithBot.{u2} β) (WithBot.hasCoeT.{u2} β))) (f (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : One.{u2} α] (f : α -> β), Eq.{succ u1} (WithBot.{u1} β) (WithBot.map.{u2, u1} α β f (OfNat.ofNat.{u2} (WithBot.{u2} α) 1 (One.toOfNat1.{u2} (WithBot.{u2} α) (WithBot.one.{u2} α _inst_1)))) (WithBot.some.{u1} β (f (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1))))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_one WithBot.map_oneₓ'. -/\n@[simp, to_additive]\nprotected theorem map_one {β} [One α] (f : α → β) : (1 : WithBot α).map f = (f 1 : WithBot β) :=\n  rfl\n#align with_bot.map_one WithBot.map_one\n#align with_bot.map_zero WithBot.map_zero\n\n#print WithBot.coe_nat /-\n@[norm_cast]\ntheorem coe_nat [AddMonoidWithOne α] (n : ℕ) : ((n : α) : WithBot α) = n :=\n  rfl\n#align with_bot.coe_nat WithBot.coe_nat\n-/\n\n#print WithBot.nat_ne_bot /-\n@[simp]\ntheorem nat_ne_bot [AddMonoidWithOne α] (n : ℕ) : (n : WithBot α) ≠ ⊥ :=\n  coe_ne_bot\n#align with_bot.nat_ne_bot WithBot.nat_ne_bot\n-/\n\n#print WithBot.bot_ne_nat /-\n@[simp]\ntheorem bot_ne_nat [AddMonoidWithOne α] (n : ℕ) : (⊥ : WithBot α) ≠ n :=\n  bot_ne_coe\n#align with_bot.bot_ne_nat WithBot.bot_ne_nat\n-/\n\nsection Add\n\nvariable [Add α] {a b c d : WithBot α} {x y : α}\n\n#print WithBot.coe_add /-\n-- `norm_cast` proves those lemmas, because `with_top`/`with_bot` are reducible\ntheorem coe_add (a b : α) : ((a + b : α) : WithBot α) = a + b :=\n  rfl\n#align with_bot.coe_add WithBot.coe_add\n-/\n\n#print WithBot.coe_bit0 /-\ntheorem coe_bit0 : ((bit0 x : α) : WithBot α) = bit0 x :=\n  rfl\n#align with_bot.coe_bit0 WithBot.coe_bit0\n-/\n\n#print WithBot.coe_bit1 /-\ntheorem coe_bit1 [One α] {a : α} : ((bit1 a : α) : WithBot α) = bit1 a :=\n  rfl\n#align with_bot.coe_bit1 WithBot.coe_bit1\n-/\n\n#print WithBot.bot_add /-\n@[simp]\ntheorem bot_add (a : WithBot α) : ⊥ + a = ⊥ :=\n  rfl\n#align with_bot.bot_add WithBot.bot_add\n-/\n\n#print WithBot.add_bot /-\n@[simp]\ntheorem add_bot (a : WithBot α) : a + ⊥ = ⊥ := by cases a <;> rfl\n#align with_bot.add_bot WithBot.add_bot\n-/\n\n#print WithBot.add_eq_bot /-\n@[simp]\ntheorem add_eq_bot : a + b = ⊥ ↔ a = ⊥ ∨ b = ⊥ :=\n  WithTop.add_eq_top\n#align with_bot.add_eq_bot WithBot.add_eq_bot\n-/\n\n#print WithBot.add_ne_bot /-\ntheorem add_ne_bot : a + b ≠ ⊥ ↔ a ≠ ⊥ ∧ b ≠ ⊥ :=\n  WithTop.add_ne_top\n#align with_bot.add_ne_bot WithBot.add_ne_bot\n-/\n\n/- warning: with_bot.bot_lt_add -> WithBot.bot_lt_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_2) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) (HAdd.hAdd.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHAdd.{u1} (WithBot.{u1} α) (WithBot.hasAdd.{u1} α _inst_1)) a b)) (And (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_2) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) a) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.hasLt.{u1} α _inst_2) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.hasBot.{u1} α)) b))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Add.{u1} α] [_inst_2 : LT.{u1} α] {a : WithBot.{u1} α} {b : WithBot.{u1} α}, Iff (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_2) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) (HAdd.hAdd.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHAdd.{u1} (WithBot.{u1} α) (WithBot.add.{u1} α _inst_1)) a b)) (And (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_2) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) a) (LT.lt.{u1} (WithBot.{u1} α) (WithBot.lt.{u1} α _inst_2) (Bot.bot.{u1} (WithBot.{u1} α) (WithBot.bot.{u1} α)) b))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_add WithBot.bot_lt_addₓ'. -/\ntheorem bot_lt_add [LT α] {a b : WithBot α} : ⊥ < a + b ↔ ⊥ < a ∧ ⊥ < b :=\n  @WithTop.add_lt_top αᵒᵈ _ _ _ _\n#align with_bot.bot_lt_add WithBot.bot_lt_add\n\n#print WithBot.add_eq_coe /-\ntheorem add_eq_coe : a + b = x ↔ ∃ a' b' : α, ↑a' = a ∧ ↑b' = b ∧ a' + b' = x :=\n  WithTop.add_eq_coe\n#align with_bot.add_eq_coe WithBot.add_eq_coe\n-/\n\n#print WithBot.add_coe_eq_bot_iff /-\n@[simp]\ntheorem add_coe_eq_bot_iff : a + y = ⊥ ↔ a = ⊥ :=\n  WithTop.add_coe_eq_top_iff\n#align with_bot.add_coe_eq_bot_iff WithBot.add_coe_eq_bot_iff\n-/\n\n#print WithBot.coe_add_eq_bot_iff /-\n@[simp]\ntheorem coe_add_eq_bot_iff : ↑x + b = ⊥ ↔ b = ⊥ :=\n  WithTop.coe_add_eq_top_iff\n#align with_bot.coe_add_eq_bot_iff WithBot.coe_add_eq_bot_iff\n-/\n\n/- warning: with_bot.map_add -> WithBot.map_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Add.{u1} α] {F : Type.{u3}} [_inst_2 : Add.{u2} β] [_inst_3 : AddHomClass.{u3, u1, u2} F α β _inst_1 _inst_2] (f : F) (a : WithBot.{u1} α) (b : WithBot.{u1} α), Eq.{succ u2} (WithBot.{u2} β) (WithBot.map.{u1, u2} α β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β _inst_1 _inst_2 _inst_3)) f) (HAdd.hAdd.{u1, u1, u1} (WithBot.{u1} α) (WithBot.{u1} α) (WithBot.{u1} α) (instHAdd.{u1} (WithBot.{u1} α) (WithBot.hasAdd.{u1} α _inst_1)) a b)) (HAdd.hAdd.{u2, u2, u2} (WithBot.{u2} β) (WithBot.{u2} β) (WithBot.{u2} β) (instHAdd.{u2} (WithBot.{u2} β) (WithBot.hasAdd.{u2} β _inst_2)) (WithBot.map.{u1, u2} α β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β _inst_1 _inst_2 _inst_3)) f) a) (WithBot.map.{u1, u2} α β (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (AddHomClass.toFunLike.{u3, u1, u2} F α β _inst_1 _inst_2 _inst_3)) f) b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : Add.{u2} α] {F : Type.{u1}} [_inst_2 : Add.{u3} β] [_inst_3 : AddHomClass.{u1, u2, u3} F α β _inst_1 _inst_2] (f : F) (a : WithBot.{u2} α) (b : WithBot.{u2} α), Eq.{succ u3} (WithBot.{u3} β) (WithBot.map.{u2, u3} α β (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3) f) (HAdd.hAdd.{u2, u2, u2} (WithBot.{u2} α) (WithBot.{u2} α) (WithBot.{u2} α) (instHAdd.{u2} (WithBot.{u2} α) (WithBot.add.{u2} α _inst_1)) a b)) (HAdd.hAdd.{u3, u3, u3} (WithBot.{u3} β) (WithBot.{u3} β) (WithBot.{u3} β) (instHAdd.{u3} (WithBot.{u3} β) (WithBot.add.{u3} β _inst_2)) (WithBot.map.{u2, u3} α β (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3) f) a) (WithBot.map.{u2, u3} α β (FunLike.coe.{succ u1, succ u2, succ u3} F α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : α) => β) _x) (AddHomClass.toFunLike.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3) f) b))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_add WithBot.map_addₓ'. -/\n--  There is no `with_bot.map_mul_of_mul_hom`, since `with_bot` does not have a multiplication.\n@[simp]\nprotected theorem map_add {F} [Add β] [AddHomClass F α β] (f : F) (a b : WithBot α) :\n    (a + b).map f = a.map f + b.map f :=\n  WithTop.map_add f a b\n#align with_bot.map_add WithBot.map_add\n\n#print OneHom.withBotMap /-\n/-- A version of `with_bot.map` for `one_hom`s. -/\n@[to_additive \"A version of `with_bot.map` for `zero_hom`s\",\n  simps (config := { fullyApplied := false })]\nprotected def OneHom.withBotMap {M N : Type _} [One M] [One N] (f : OneHom M N) :\n    OneHom (WithBot M) (WithBot N) where\n  toFun := WithBot.map f\n  map_one' := by rw [WithBot.map_one, map_one, coe_one]\n#align one_hom.with_bot_map OneHom.withBotMap\n#align zero_hom.with_bot_map ZeroHom.withBotMap\n-/\n\n#print AddHom.withBotMap /-\n/-- A version of `with_bot.map` for `add_hom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def AddHom.withBotMap {M N : Type _} [Add M] [Add N] (f : AddHom M N) :\n    AddHom (WithBot M) (WithBot N) where\n  toFun := WithBot.map f\n  map_add' := WithBot.map_add f\n#align add_hom.with_bot_map AddHom.withBotMap\n-/\n\n#print AddMonoidHom.withBotMap /-\n/-- A version of `with_bot.map` for `add_monoid_hom`s. -/\n@[simps (config := { fullyApplied := false })]\nprotected def AddMonoidHom.withBotMap {M N : Type _} [AddZeroClass M] [AddZeroClass N]\n    (f : M →+ N) : WithBot M →+ WithBot N :=\n  { f.toZeroHom.withBot_map, f.toAddHom.withBot_map with toFun := WithBot.map f }\n#align add_monoid_hom.with_bot_map AddMonoidHom.withBotMap\n-/\n\nvariable [Preorder α]\n\n#print WithBot.covariantClass_add_le /-\ninstance covariantClass_add_le [CovariantClass α α (· + ·) (· ≤ ·)] :\n    CovariantClass (WithBot α) (WithBot α) (· + ·) (· ≤ ·) :=\n  @OrderDual.covariantClass_add_le (WithTop αᵒᵈ) _ _ _\n#align with_bot.covariant_class_add_le WithBot.covariantClass_add_le\n-/\n\n#print WithBot.covariantClass_swap_add_le /-\ninstance covariantClass_swap_add_le [CovariantClass α α (swap (· + ·)) (· ≤ ·)] :\n    CovariantClass (WithBot α) (WithBot α) (swap (· + ·)) (· ≤ ·) :=\n  @OrderDual.covariantClass_swap_add_le (WithTop αᵒᵈ) _ _ _\n#align with_bot.covariant_class_swap_add_le WithBot.covariantClass_swap_add_le\n-/\n\n#print WithBot.contravariantClass_add_lt /-\ninstance contravariantClass_add_lt [ContravariantClass α α (· + ·) (· < ·)] :\n    ContravariantClass (WithBot α) (WithBot α) (· + ·) (· < ·) :=\n  @OrderDual.contravariantClass_add_lt (WithTop αᵒᵈ) _ _ _\n#align with_bot.contravariant_class_add_lt WithBot.contravariantClass_add_lt\n-/\n\n#print WithBot.contravariantClass_swap_add_lt /-\ninstance contravariantClass_swap_add_lt [ContravariantClass α α (swap (· + ·)) (· < ·)] :\n    ContravariantClass (WithBot α) (WithBot α) (swap (· + ·)) (· < ·) :=\n  @OrderDual.contravariantClass_swap_add_lt (WithTop αᵒᵈ) _ _ _\n#align with_bot.contravariant_class_swap_add_lt WithBot.contravariantClass_swap_add_lt\n-/\n\n#print WithBot.le_of_add_le_add_left /-\nprotected theorem le_of_add_le_add_left [ContravariantClass α α (· + ·) (· ≤ ·)] (ha : a ≠ ⊥)\n    (h : a + b ≤ a + c) : b ≤ c :=\n  @WithTop.le_of_add_le_add_left αᵒᵈ _ _ _ _ _ _ ha h\n#align with_bot.le_of_add_le_add_left WithBot.le_of_add_le_add_left\n-/\n\n#print WithBot.le_of_add_le_add_right /-\nprotected theorem le_of_add_le_add_right [ContravariantClass α α (swap (· + ·)) (· ≤ ·)]\n    (ha : a ≠ ⊥) (h : b + a ≤ c + a) : b ≤ c :=\n  @WithTop.le_of_add_le_add_right αᵒᵈ _ _ _ _ _ _ ha h\n#align with_bot.le_of_add_le_add_right WithBot.le_of_add_le_add_right\n-/\n\n#print WithBot.add_lt_add_left /-\nprotected theorem add_lt_add_left [CovariantClass α α (· + ·) (· < ·)] (ha : a ≠ ⊥) (h : b < c) :\n    a + b < a + c :=\n  @WithTop.add_lt_add_left αᵒᵈ _ _ _ _ _ _ ha h\n#align with_bot.add_lt_add_left WithBot.add_lt_add_left\n-/\n\n#print WithBot.add_lt_add_right /-\nprotected theorem add_lt_add_right [CovariantClass α α (swap (· + ·)) (· < ·)] (ha : a ≠ ⊥)\n    (h : b < c) : b + a < c + a :=\n  @WithTop.add_lt_add_right αᵒᵈ _ _ _ _ _ _ ha h\n#align with_bot.add_lt_add_right WithBot.add_lt_add_right\n-/\n\n#print WithBot.add_le_add_iff_left /-\nprotected theorem add_le_add_iff_left [CovariantClass α α (· + ·) (· ≤ ·)]\n    [ContravariantClass α α (· + ·) (· ≤ ·)] (ha : a ≠ ⊥) : a + b ≤ a + c ↔ b ≤ c :=\n  ⟨WithBot.le_of_add_le_add_left ha, fun h => add_le_add_left h a⟩\n#align with_bot.add_le_add_iff_left WithBot.add_le_add_iff_left\n-/\n\n#print WithBot.add_le_add_iff_right /-\nprotected theorem add_le_add_iff_right [CovariantClass α α (swap (· + ·)) (· ≤ ·)]\n    [ContravariantClass α α (swap (· + ·)) (· ≤ ·)] (ha : a ≠ ⊥) : b + a ≤ c + a ↔ b ≤ c :=\n  ⟨WithBot.le_of_add_le_add_right ha, fun h => add_le_add_right h a⟩\n#align with_bot.add_le_add_iff_right WithBot.add_le_add_iff_right\n-/\n\n#print WithBot.add_lt_add_iff_left /-\nprotected theorem add_lt_add_iff_left [CovariantClass α α (· + ·) (· < ·)]\n    [ContravariantClass α α (· + ·) (· < ·)] (ha : a ≠ ⊥) : a + b < a + c ↔ b < c :=\n  ⟨lt_of_add_lt_add_left, WithBot.add_lt_add_left ha⟩\n#align with_bot.add_lt_add_iff_left WithBot.add_lt_add_iff_left\n-/\n\n#print WithBot.add_lt_add_iff_right /-\nprotected theorem add_lt_add_iff_right [CovariantClass α α (swap (· + ·)) (· < ·)]\n    [ContravariantClass α α (swap (· + ·)) (· < ·)] (ha : a ≠ ⊥) : b + a < c + a ↔ b < c :=\n  ⟨lt_of_add_lt_add_right, WithBot.add_lt_add_right ha⟩\n#align with_bot.add_lt_add_iff_right WithBot.add_lt_add_iff_right\n-/\n\n#print WithBot.add_lt_add_of_le_of_lt /-\nprotected theorem add_lt_add_of_le_of_lt [CovariantClass α α (· + ·) (· < ·)]\n    [CovariantClass α α (swap (· + ·)) (· ≤ ·)] (hb : b ≠ ⊥) (hab : a ≤ b) (hcd : c < d) :\n    a + c < b + d :=\n  @WithTop.add_lt_add_of_le_of_lt αᵒᵈ _ _ _ _ _ _ _ _ hb hab hcd\n#align with_bot.add_lt_add_of_le_of_lt WithBot.add_lt_add_of_le_of_lt\n-/\n\n#print WithBot.add_lt_add_of_lt_of_le /-\nprotected theorem add_lt_add_of_lt_of_le [CovariantClass α α (· + ·) (· ≤ ·)]\n    [CovariantClass α α (swap (· + ·)) (· < ·)] (hd : d ≠ ⊥) (hab : a < b) (hcd : c ≤ d) :\n    a + c < b + d :=\n  @WithTop.add_lt_add_of_lt_of_le αᵒᵈ _ _ _ _ _ _ _ _ hd hab hcd\n#align with_bot.add_lt_add_of_lt_of_le WithBot.add_lt_add_of_lt_of_le\n-/\n\nend Add\n\ninstance [OrderedAddCommMonoid α] : OrderedAddCommMonoid (WithBot α) :=\n  { WithBot.partialOrder, WithBot.addCommMonoid with\n    add_le_add_left := fun a b h c => add_le_add_left h c }\n\ninstance [LinearOrderedAddCommMonoid α] : LinearOrderedAddCommMonoid (WithBot α) :=\n  { WithBot.linearOrder, WithBot.orderedAddCommMonoid with }\n\nend WithBot\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Monoid/WithTop.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.468342337458674}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n\n! This file was ported from Lean 3 source module data.rat.cast\n! leanprover-community/mathlib commit acebd8d49928f6ed8920e502a6c90674e75bd441\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Rat.Order\nimport Mathlib.Data.Rat.Lemmas\nimport Mathlib.Data.Int.CharZero\nimport Mathlib.Algebra.GroupWithZero.Power\nimport Mathlib.Algebra.Field.Opposite\nimport Mathlib.Algebra.Order.Field.Basic\n\n\n/-!\n# Casts for Rational Numbers\n\n## Summary\n\nWe define the canonical injection from ℚ into an arbitrary division ring and prove various\ncasting lemmas showing the well-behavedness of this injection.\n\n## Notations\n\n- `/.` is infix notation for `rat.mk`.\n\n## Tags\n\nrat, rationals, field, ℚ, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\n\nvariable {F ι α β : Type _}\n\nnamespace Rat\n\nopen Rat\n\nsection WithDivRing\n\nvariable [DivisionRing α]\n\n@[simp, norm_cast]\ntheorem cast_coe_int (n : ℤ) : ((n : ℚ) : α) = n :=\n  (cast_def _).trans <| show (n / (1 : ℕ) : α) = n by rw [Nat.cast_one, div_one]\n#align rat.cast_coe_int Rat.cast_coe_int\n\n\n@[simp, norm_cast]\n\n\n\n@[simp, norm_cast]\ntheorem cast_zero : ((0 : ℚ) : α) = 0 :=\n  (cast_coe_int _).trans Int.cast_zero\n#align rat.cast_zero Rat.cast_zero\n\n@[simp, norm_cast]\ntheorem cast_one : ((1 : ℚ) : α) = 1 :=\n  (cast_coe_int _).trans Int.cast_one\n#align rat.cast_one Rat.cast_one\n\ntheorem cast_commute (r : ℚ) (a : α) : Commute (↑r) a := by\n  simpa only [cast_def] using (r.1.cast_commute a).div_left (r.2.cast_commute a)\n#align rat.cast_commute Rat.cast_commute\n\ntheorem cast_comm (r : ℚ) (a : α) : (r : α) * a = a * r :=\n  (cast_commute r a).eq\n#align rat.cast_comm Rat.cast_comm\n\ntheorem commute_cast (a : α) (r : ℚ) : Commute a r :=\n  (r.cast_commute a).symm\n#align rat.commute_cast Rat.commute_cast\n\n@[norm_cast]\ntheorem cast_mk_of_ne_zero (a b : ℤ) (b0 : (b : α) ≠ 0) : (a /. b : α) = a / b := by\n  have b0' : b ≠ 0 := by\n    refine' mt _ b0\n    simp (config := { contextual := true })\n  cases' e : a /. b with n d h c\n  have d0 : (d : α) ≠ 0 := by\n    intro d0\n    have dd := den_dvd a b\n    cases' show (d : ℤ) ∣ b by rwa [e] at dd with k ke\n    have : (b : α) = (d : α) * (k : α) := by rw [ke, Int.cast_mul, Int.cast_ofNat]\n    rw [d0, zero_mul] at this\n    contradiction\n  rw [num_den'] at e\n  have := congr_arg ((↑) : ℤ → α)\n    ((divInt_eq_iff b0' <| ne_of_gt <| Int.coe_nat_pos.2 h.bot_lt).1 e)\n  rw [Int.cast_mul, Int.cast_mul, Int.cast_ofNat] at this\n  -- Porting note: was `symm`\n  apply Eq.symm\n  rw [cast_def, div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq, ← mul_assoc,\n    this, mul_assoc, mul_inv_cancel b0, mul_one]\n#align rat.cast_mk_of_ne_zero Rat.cast_mk_of_ne_zero\n\n@[norm_cast]\ntheorem cast_add_of_ne_zero :\n    ∀ {m n : ℚ}, (m.den : α) ≠ 0 → (n.den : α) ≠ 0 → ((m + n : ℚ) : α) = m + n\n  | ⟨n₁, d₁, h₁, c₁⟩, ⟨n₂, d₂, h₂, c₂⟩ => fun (d₁0 : (d₁ : α) ≠ 0) (d₂0 : (d₂ : α) ≠ 0) =>\n    by\n    have d₁0' : (d₁ : ℤ) ≠ 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d₁0 ; exact d₁0 Nat.cast_zero\n    have d₂0' : (d₂ : ℤ) ≠ 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d₂0 ; exact d₂0 Nat.cast_zero\n    rw [num_den', num_den', add_def'' d₁0' d₂0']\n    suffices (n₁ * (d₂ * ((d₂ : α)⁻¹ * (d₁ : α)⁻¹)) + n₂ * (d₁ * (d₂ : α)⁻¹) * (d₁ : α)⁻¹ : α)\n        = n₁ * (d₁ : α)⁻¹ + n₂ * (d₂ : α)⁻¹\n      by\n      rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero]\n      · simpa [division_def, left_distrib, right_distrib, mul_inv_rev, d₁0, d₂0, mul_assoc]\n      all_goals simp [d₁0, d₂0]\n    rw [← mul_assoc (d₂ : α), mul_inv_cancel d₂0, one_mul, (Nat.cast_commute _ _).eq]\n    simp [d₁0, mul_assoc]\n#align rat.cast_add_of_ne_zero Rat.cast_add_of_ne_zero\n\n@[simp, norm_cast]\ntheorem cast_neg : ∀ n, ((-n : ℚ) : α) = -n\n  | ⟨n, d, h, c⟩ => by\n    simpa only [cast_def] using\n      show (↑(-n) / d : α) = -(n / d) by\n        rw [div_eq_mul_inv, div_eq_mul_inv, Int.cast_neg, neg_mul_eq_neg_mul]\n#align rat.cast_neg Rat.cast_neg\n\n@[norm_cast]\ntheorem cast_sub_of_ne_zero {m n : ℚ} (m0 : (m.den : α) ≠ 0) (n0 : (n.den : α) ≠ 0) :\n    ((m - n : ℚ) : α) = m - n := by\n  have : ((-n).den : α) ≠ 0 := by cases n ; exact n0\n  simp [sub_eq_add_neg, cast_add_of_ne_zero m0 this]\n#align rat.cast_sub_of_ne_zero Rat.cast_sub_of_ne_zero\n\n@[norm_cast]\ntheorem cast_mul_of_ne_zero :\n    ∀ {m n : ℚ}, (m.den : α) ≠ 0 → (n.den : α) ≠ 0 → ((m * n : ℚ) : α) = m * n\n  | ⟨n₁, d₁, h₁, c₁⟩, ⟨n₂, d₂, h₂, c₂⟩ => fun (d₁0 : (d₁ : α) ≠ 0) (d₂0 : (d₂ : α) ≠ 0) =>\n    by\n    have d₁0' : (d₁ : ℤ) ≠ 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d₁0 ; exact d₁0 Nat.cast_zero\n    have d₂0' : (d₂ : ℤ) ≠ 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d₂0 ; exact d₂0 Nat.cast_zero\n    rw [num_den', num_den', mul_def' d₁0' d₂0']\n    suffices (n₁ * (n₂ * (d₂ : α)⁻¹ * (d₁ : α)⁻¹) : α) = n₁ * ((d₁ : α)⁻¹ * (n₂ * (d₂ : α)⁻¹))\n      by\n      rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero]\n      · simpa [division_def, mul_inv_rev, d₁0, d₂0, mul_assoc]\n      all_goals simp [d₁0, d₂0]\n    rw [(d₁.commute_cast (_ : α)).inv_right₀.eq]\n#align rat.cast_mul_of_ne_zero Rat.cast_mul_of_ne_zero\n\n-- Porting note: rewrote proof\n@[simp]\ntheorem cast_inv_nat (n : ℕ) : ((n⁻¹ : ℚ) : α) = (n : α)⁻¹ := by\n  cases' n with n\n  · simp\n  rw [cast_def, inv_coe_nat_num, inv_coe_nat_den, if_neg n.succ_ne_zero,\n    Int.sign_eq_one_of_pos (Nat.cast_pos.mpr n.succ_pos), Int.cast_one, one_div]\n#align rat.cast_inv_nat Rat.cast_inv_nat\n\n-- Porting note: proof got a lot easier - is this still the intended statement?\n@[simp]\ntheorem cast_inv_int (n : ℤ) : ((n⁻¹ : ℚ) : α) = (n : α)⁻¹ := by\n  cases' n with n n\n  · simp [ofInt_eq_cast, cast_inv_nat]\n  · simp only [ofInt_eq_cast, Int.cast_negSucc, ← Nat.cast_succ, cast_neg, inv_neg, cast_inv_nat]\n#align rat.cast_inv_int Rat.cast_inv_int\n\n@[norm_cast]\ntheorem cast_inv_of_ne_zero :\n  ∀ {n : ℚ}, (n.num : α) ≠ 0 → (n.den : α) ≠ 0 → ((n⁻¹ : ℚ) : α) = (n : α)⁻¹\n  | ⟨n, d, h, c⟩ => fun (n0 : (n : α) ≠ 0) (d0 : (d : α) ≠ 0) =>\n    by\n    have _ : (n : ℤ) ≠ 0 := fun e => by rw [e] at n0 ; exact n0 Int.cast_zero\n    have _ : (d : ℤ) ≠ 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d0 ; exact d0 Nat.cast_zero\n    rw [num_den', inv_def']\n    rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, inv_div] <;> simp [n0, d0]\n#align rat.cast_inv_of_ne_zero Rat.cast_inv_of_ne_zero\n\n@[norm_cast]\ntheorem cast_div_of_ne_zero {m n : ℚ} (md : (m.den : α) ≠ 0) (nn : (n.num : α) ≠ 0)\n    (nd : (n.den : α) ≠ 0) : ((m / n : ℚ) : α) = m / n := by\n  have : (n⁻¹.den : ℤ) ∣ n.num := by\n    conv in n⁻¹.den => rw [← @num_den n, inv_def']\n    apply den_dvd\n  have : (n⁻¹.den : α) = 0 → (n.num : α) = 0 := fun h =>\n    by\n    let ⟨k, e⟩ := this\n    have := congr_arg ((↑) : ℤ → α) e ; rwa [Int.cast_mul, Int.cast_ofNat, h, zero_mul] at this\n  rw [division_def, cast_mul_of_ne_zero md (mt this nn), cast_inv_of_ne_zero nn nd, division_def]\n#align rat.cast_div_of_ne_zero Rat.cast_div_of_ne_zero\n\n@[simp, norm_cast]\ntheorem cast_inj [CharZero α] : ∀ {m n : ℚ}, (m : α) = n ↔ m = n\n  | ⟨n₁, d₁, d₁0, c₁⟩, ⟨n₂, d₂, d₂0, c₂⟩ =>\n    by\n    refine' ⟨fun h => _, congr_arg _⟩\n    have d₁a : (d₁ : α) ≠ 0 := Nat.cast_ne_zero.2 d₁0\n    have d₂a : (d₂ : α) ≠ 0 := Nat.cast_ne_zero.2 d₂0\n    rw [num_den', num_den'] at h⊢\n    rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h <;> simp [d₁0, d₂0] at h⊢\n    rwa [eq_div_iff_mul_eq d₂a, division_def, mul_assoc, (d₁.cast_commute (d₂ : α)).inv_left₀.eq, ←\n      mul_assoc, ← division_def, eq_comm, eq_div_iff_mul_eq d₁a, eq_comm, ← Int.cast_ofNat d₁, ←\n      Int.cast_mul, ← Int.cast_ofNat d₂, ← Int.cast_mul, Int.cast_inj, ← mkRat_eq_iff d₁0 d₂0] at h\n#align rat.cast_inj Rat.cast_inj\n\ntheorem cast_injective [CharZero α] : Function.Injective ((↑) : ℚ → α)\n  | _, _ => cast_inj.1\n#align rat.cast_injective Rat.cast_injective\n\n@[simp]\ntheorem cast_eq_zero [CharZero α] {n : ℚ} : (n : α) = 0 ↔ n = 0 := by rw [← cast_zero, cast_inj]\n#align rat.cast_eq_zero Rat.cast_eq_zero\n\ntheorem cast_ne_zero [CharZero α] {n : ℚ} : (n : α) ≠ 0 ↔ n ≠ 0 :=\n  not_congr cast_eq_zero\n#align rat.cast_ne_zero Rat.cast_ne_zero\n\n@[simp, norm_cast]\ntheorem cast_add [CharZero α] (m n) : ((m + n : ℚ) : α) = m + n :=\n  cast_add_of_ne_zero (Nat.cast_ne_zero.2 <| ne_of_gt m.pos) (Nat.cast_ne_zero.2 <| ne_of_gt n.pos)\n#align rat.cast_add Rat.cast_add\n\n@[simp, norm_cast]\ntheorem cast_sub [CharZero α] (m n) : ((m - n : ℚ) : α) = m - n :=\n  cast_sub_of_ne_zero (Nat.cast_ne_zero.2 <| ne_of_gt m.pos) (Nat.cast_ne_zero.2 <| ne_of_gt n.pos)\n#align rat.cast_sub Rat.cast_sub\n\n@[simp, norm_cast]\ntheorem cast_mul [CharZero α] (m n) : ((m * n : ℚ) : α) = m * n :=\n  cast_mul_of_ne_zero (Nat.cast_ne_zero.2 <| ne_of_gt m.pos) (Nat.cast_ne_zero.2 <| ne_of_gt n.pos)\n#align rat.cast_mul Rat.cast_mul\n\nsection\n\nset_option linter.deprecated false\n\n@[simp, norm_cast]\ntheorem cast_bit0 [CharZero α] (n : ℚ) : ((bit0 n : ℚ) : α) = (bit0 n : α) :=\n  cast_add _ _\n#align rat.cast_bit0 Rat.cast_bit0\n\n@[simp, norm_cast]\ntheorem cast_bit1 [CharZero α] (n : ℚ) : ((bit1 n : ℚ) : α) = (bit1 n : α) := by\n  rw [bit1, cast_add, cast_one, cast_bit0] ; rfl\n#align rat.cast_bit1 Rat.cast_bit1\n\nend\n\nvariable (α)\nvariable [CharZero α]\n\n/-- Coercion `ℚ → α` as a `RingHom`. -/\ndef castHom : ℚ →+* α where\n  toFun := (↑)\n  map_one' := cast_one\n  map_mul' := cast_mul\n  map_zero' := cast_zero\n  map_add' := cast_add\n#align rat.cast_hom Rat.castHom\n\nvariable {α}\n\n@[simp]\ntheorem coe_cast_hom : ⇑(castHom α) = ((↑) : ℚ → α) :=\n  rfl\n#align rat.coe_cast_hom Rat.coe_cast_hom\n\n@[simp, norm_cast]\ntheorem cast_inv (n) : ((n⁻¹ : ℚ) : α) = (n : α)⁻¹ :=\n  map_inv₀ (castHom α) _\n#align rat.cast_inv Rat.cast_inv\n\n@[simp, norm_cast]\ntheorem cast_div (m n) : ((m / n : ℚ) : α) = m / n :=\n  map_div₀ (castHom α) _ _\n#align rat.cast_div Rat.cast_div\n\n@[simp, norm_cast]\ntheorem cast_zpow (q : ℚ) (n : ℤ) : ((q ^ n : ℚ) : α) = (q : α) ^ n :=\n  map_zpow₀ (castHom α) q n\n#align rat.cast_zpow Rat.cast_zpow\n\n@[norm_cast]\ntheorem cast_mk (a b : ℤ) : (a /. b : α) = a / b := by\n  simp only [divInt_eq_div, cast_div, cast_coe_int]\n#align rat.cast_mk Rat.cast_mk\n\n@[simp, norm_cast]\ntheorem cast_pow (q) (k : ℕ) : ((q : ℚ) ^ k : α) = (q : α) ^ k :=\n  (castHom α).map_pow q k\n#align rat.cast_pow Rat.cast_pow\n\nend WithDivRing\n\nsection LinearOrderedField\n\nvariable {K : Type _} [LinearOrderedField K]\n\ntheorem cast_pos_of_pos {r : ℚ} (hr : 0 < r) : (0 : K) < r := by\n  rw [Rat.cast_def]\n  exact div_pos (Int.cast_pos.2 <| num_pos_iff_pos.2 hr) (Nat.cast_pos.2 r.pos)\n#align rat.cast_pos_of_pos Rat.cast_pos_of_pos\n\n@[mono]\ntheorem cast_strictMono : StrictMono ((↑) : ℚ → K) := fun m n => by\n  simpa only [sub_pos, cast_sub] using @cast_pos_of_pos K _ (n - m)\n#align rat.cast_strict_mono Rat.cast_strictMono\n\n@[mono]\ntheorem cast_mono : Monotone ((↑) : ℚ → K) :=\n  cast_strictMono.monotone\n#align rat.cast_mono Rat.cast_mono\n\n/-- Coercion from `ℚ` as an order embedding. -/\n@[simps!]\ndef castOrderEmbedding : ℚ ↪o K :=\n  OrderEmbedding.ofStrictMono (↑) cast_strictMono\n#align rat.cast_order_embedding Rat.castOrderEmbedding\n#align rat.cast_order_embedding_apply Rat.castOrderEmbedding_apply\n\n@[simp, norm_cast]\ntheorem cast_le {m n : ℚ} : (m : K) ≤ n ↔ m ≤ n :=\n  castOrderEmbedding.le_iff_le\n#align rat.cast_le Rat.cast_le\n\n@[simp, norm_cast]\ntheorem cast_lt {m n : ℚ} : (m : K) < n ↔ m < n :=\n  cast_strictMono.lt_iff_lt\n#align rat.cast_lt Rat.cast_lt\n\n@[simp]\ntheorem cast_nonneg {n : ℚ} : 0 ≤ (n : K) ↔ 0 ≤ n := by\n      norm_cast\n\n#align rat.cast_nonneg Rat.cast_nonneg\n\n@[simp]\ntheorem cast_nonpos {n : ℚ} : (n : K) ≤ 0 ↔ n ≤ 0 := by\n      norm_cast\n#align rat.cast_nonpos Rat.cast_nonpos\n\n@[simp]\ntheorem cast_pos {n : ℚ} : (0 : K) < n ↔ 0 < n := by\n      norm_cast\n#align rat.cast_pos Rat.cast_pos\n\n@[simp]\ntheorem cast_lt_zero {n : ℚ} : (n : K) < 0 ↔ n < 0 := by\n      norm_cast\n#align rat.cast_lt_zero Rat.cast_lt_zero\n\n@[simp, norm_cast]\ntheorem cast_min {a b : ℚ} : (↑(min a b) : K) = min (a : K) (b : K) :=\n  (@cast_mono K _).map_min\n#align rat.cast_min Rat.cast_min\n\n@[simp, norm_cast]\ntheorem cast_max {a b : ℚ} : (↑(max a b) : K) = max (a : K) (b : K) :=\n  (@cast_mono K _).map_max\n#align rat.cast_max Rat.cast_max\n\n\n@[simp, norm_cast]\ntheorem cast_abs {q : ℚ} : ((|q| : ℚ) : K) = |(q : K)| := by simp [abs_eq_max_neg]\n#align rat.cast_abs Rat.cast_abs\n\nopen Set\n\n@[simp]\ntheorem preimage_cast_Icc (a b : ℚ) : (↑) ⁻¹' Icc (a : K) b = Icc a b := by\n  ext x\n  simp\n#align rat.preimage_cast_Icc Rat.preimage_cast_Icc\n\n@[simp]\ntheorem preimage_cast_Ico (a b : ℚ) : (↑) ⁻¹' Ico (a : K) b = Ico a b := by\n  ext x\n  simp\n#align rat.preimage_cast_Ico Rat.preimage_cast_Ico\n\n@[simp]\ntheorem preimage_cast_Ioc (a b : ℚ) : (↑) ⁻¹' Ioc (a : K) b = Ioc a b := by\n  ext x\n  simp\n#align rat.preimage_cast_Ioc Rat.preimage_cast_Ioc\n\n@[simp]\ntheorem preimage_cast_Ioo (a b : ℚ) : (↑) ⁻¹' Ioo (a : K) b = Ioo a b := by\n  ext x\n  simp\n#align rat.preimage_cast_Ioo Rat.preimage_cast_Ioo\n\n@[simp]\ntheorem preimage_cast_Ici (a : ℚ) : (↑) ⁻¹' Ici (a : K) = Ici a := by\n  ext x\n  simp\n#align rat.preimage_cast_Ici Rat.preimage_cast_Ici\n\n@[simp]\ntheorem preimage_cast_Iic (a : ℚ) : (↑) ⁻¹' Iic (a : K) = Iic a := by\n  ext x\n  simp\n#align rat.preimage_cast_Iic Rat.preimage_cast_Iic\n\n@[simp]\ntheorem preimage_cast_Ioi (a : ℚ) : (↑) ⁻¹' Ioi (a : K) = Ioi a := by\n  ext x\n  simp\n#align rat.preimage_cast_Ioi Rat.preimage_cast_Ioi\n\n@[simp]\ntheorem preimage_cast_Iio (a : ℚ) : (↑) ⁻¹' Iio (a : K) = Iio a := by\n  ext x\n  simp\n#align rat.preimage_cast_Iio Rat.preimage_cast_Iio\n\nend LinearOrderedField\n\n-- Porting note: statement made more explicit\n@[norm_cast]\ntheorem cast_id (n : ℚ) : Rat.cast n = n := rfl\n#align rat.cast_id Rat.cast_id\n\n@[simp]\ntheorem cast_eq_id : ((↑) : ℚ → ℚ) = id :=\n  funext fun _ => rfl\n#align rat.cast_eq_id Rat.cast_eq_id\n\n@[simp]\ntheorem cast_hom_rat : castHom ℚ = RingHom.id ℚ :=\n  RingHom.ext cast_id\n#align rat.cast_hom_rat Rat.cast_hom_rat\n\nend Rat\n\nopen Rat\n\n@[simp]\ntheorem map_ratCast [DivisionRing α] [DivisionRing β] [RingHomClass F α β] (f : F) (q : ℚ) :\n    f q = q := by rw [cast_def, map_div₀, map_intCast, map_natCast, cast_def]\n#align map_rat_cast map_ratCast\n\n@[simp]\ntheorem eq_ratCast {k} [DivisionRing k] [RingHomClass F ℚ k] (f : F) (r : ℚ) : f r = r := by\n  rw [← map_ratCast f, Rat.cast_id]\n#align eq_rat_cast eq_ratCast\n\nnamespace MonoidWithZeroHom\n\nvariable {M₀ : Type _} [MonoidWithZero M₀] [MonoidWithZeroHomClass F ℚ M₀] {f g : F}\n\n\n/-- If `f` and `g` agree on the integers then they are equal `φ`. -/\ntheorem ext_rat' (h : ∀ m : ℤ, f m = g m) : f = g :=\n  (FunLike.ext f g) fun r => by\n    rw [← r.num_div_den, div_eq_mul_inv, map_mul, map_mul, h, ← Int.cast_ofNat,\n      eq_on_inv₀ f g]\n    apply h\n#align monoid_with_zero_hom.ext_rat' MonoidWithZeroHom.ext_rat'\n\n/-- If `f` and `g` agree on the integers then they are equal `φ`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : ℚ →*₀ M₀}\n    (h : f.comp (Int.castRingHom ℚ : ℤ →*₀ ℚ) = g.comp (Int.castRingHom ℚ)) : f = g :=\n  ext_rat' <| FunLike.congr_fun h\n#align monoid_with_zero_hom.ext_rat MonoidWithZeroHom.ext_rat\n\n/-- Positive integer values of a morphism `φ` and its value on `-1` completely determine `φ`. -/\ntheorem ext_rat_on_pnat (same_on_neg_one : f (-1) = g (-1))\n    (same_on_pnat : ∀ n : ℕ, 0 < n → f n = g n) : f = g :=\n  ext_rat' <|\n    FunLike.congr_fun <|\n      show\n        (f : ℚ →*₀ M₀).comp (Int.castRingHom ℚ : ℤ →*₀ ℚ) =\n          (g : ℚ →*₀ M₀).comp (Int.castRingHom ℚ : ℤ →*₀ ℚ)\n        from ext_int' (by simpa) (by simpa)\n#align monoid_with_zero_hom.ext_rat_on_pnat MonoidWithZeroHom.ext_rat_on_pnat\n\nend MonoidWithZeroHom\n\n/-- Any two ring homomorphisms from `ℚ` to a semiring are equal. If the codomain is a division ring,\nthen this lemma follows from `eq_ratCast`. -/\ntheorem RingHom.ext_rat {R : Type _} [Semiring R] [RingHomClass F ℚ R] (f g : F) : f = g :=\n  MonoidWithZeroHom.ext_rat' <|\n    RingHom.congr_fun <|\n      ((f : ℚ →+* R).comp (Int.castRingHom ℚ)).ext_int ((g : ℚ →+* R).comp (Int.castRingHom ℚ))\n#align ring_hom.ext_rat RingHom.ext_rat\n\ninstance Rat.subsingleton_ringHom {R : Type _} [Semiring R] : Subsingleton (ℚ →+* R) :=\n  ⟨RingHom.ext_rat⟩\n#align rat.subsingleton_ring_hom Rat.subsingleton_ringHom\n\nsection SMul\n\nnamespace Rat\n\nvariable {K : Type _} [DivisionRing K]\n\ninstance (priority := 100) distribSMul : DistribSMul ℚ K where\n  smul := (· • ·)\n  smul_zero a := by rw [smul_def, mul_zero]\n  smul_add a x y := by rw [smul_def, smul_def, smul_def, mul_add]\n#align rat.distrib_smul Rat.distribSMul\n\ninstance isScalarTower_right : IsScalarTower ℚ K K :=\n  ⟨fun a x y => by simp only [smul_def, smul_eq_mul, mul_assoc]⟩\n#align rat.is_scalar_tower_right Rat.isScalarTower_right\n\nend Rat\n\nend SMul\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Rat/Cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6406358548398979, "lm_q1q2_score": 0.46834233745867393}}
{"text": "import recover\n\n-- We are given two fields, `K` and `F`\nvariables {K F : Type*} [field K] [field F] \n\nopen module finite_dimensional \nopen_locale tensor_product\n\n/-\nNOTE: This introduces notation `[a]ₘ` for `a : Kˣ`, where `[a]ₘ` is the element of\nthe base-change `F ⊗[ℤ] (additive Kˣ)` corresponding to `a`. \n-/\nnotation `[`:max a`]ₘ`:max := 1 ⊗ₜ (additive.of_mul a)\n\nlemma one_tmul_mul (a b : Kˣ) : ([a * b]ₘ : F ⊗[ℤ] additive Kˣ) = \n  [a]ₘ + [b]ₘ := \ntensor_product.tmul_add _ _ _\n\nlemma one_tmul_inv (a : Kˣ) : ([a⁻¹]ₘ : F ⊗[ℤ] additive Kˣ) = - [a]ₘ :=\ntensor_product.tmul_neg _ _\n\n/-\nWe consider the weak topology on `dual F (F ⊗[ℤ] additive Kˣ)`. \nThis is just the pointwise convergence topology, i.e. the topology\ninduced by the product topology on the type of functions `F ⊗[ℤ] additive Kˣ → F` \nwhere `F` is given the discrete topology.\n-/\ndef module.dual.weak_topology : \n  topological_space (dual F (F ⊗[ℤ] additive Kˣ)) := \ntopological_space.induced (λ e a, e a) $ \n(@Pi.topological_space (F ⊗[ℤ] additive Kˣ) (λ _, F) $ λ a, ⊥)\n\n/-\nWe only activate this topological space instance for this file.\n-/\nlocal attribute [instance] \n  module.dual.weak_topology\n\n-- We now assume that `F` is a prime field.\n-- The is defined as saying that every element `a : F` can be expressed as \n-- `m/n` for some `m : ℤ` and some `n : ℕ` such that `(n : F) ≠ 0`.\nvariable [is_prime_field F]\n\nexample : is_prime_field ℚ := infer_instance\nexample (p : ℕ) [fact (nat.prime p)] : is_prime_field (zmod p) := infer_instance\n\n/- The main theorem of alternating pairs (prime field case). -/\ntheorem main_alternating_theorem_of_prime_field\n  -- Given a submodule `D` of `dual F (F ⊗[ℤ] additive Kˣ)`,\n  (D : submodule F (dual F (F ⊗[ℤ] additive Kˣ))) \n  -- which is: (1) closed with respect to the topology introduced above; \n  (h1 : is_closed (D : set (dual F (F ⊗[ℤ] additive Kˣ))))\n  -- (2) every element of `D` maps `[(-1 : Kˣ)]ₘ` to zero;\n  (h2 : ∀ (f : dual F (F ⊗[ℤ] additive Kˣ)) (hf : f ∈ D), f [-1]ₘ = 0) \n  -- (3) satisfies the alternating condition, i.e. whenever `u v : Kˣ` satisfy\n  -- `(u : K) + v = 1`, then `f [u]ₘ * g [v]ₘ = f [v]ₘ * g [u]ₘ`.\n  (h3 : ∀ (u v : Kˣ) (huv : (u : K) + v = 1) \n    (f g : dual F (F ⊗[ℤ] additive Kˣ))\n    (hf : f ∈ D) (hg : g ∈ D), \n    f [u]ₘ * g [v]ₘ = f [v]ₘ * g [u]ₘ) : \n  -- Then there exists a valuation subring `R` of `K`, \n  ∃ (R : valuation_subring K)\n  -- and another submodule `I` of `dual F (F ⊗[ℤ] additive Kˣ)` \n    (I : submodule F (dual F (F ⊗[ℤ] additive Kˣ)))\n    -- which is closed, and such that the following hold:\n    (Iclosed : is_closed (I : set (dual F (F ⊗[ℤ] additive Kˣ))))\n    -- (1) `I` is contained in `D`;\n    (le : I ≤ D)\n    -- (2) the elements `f` of `I` satisfy `f [u]ₘ = 0` for `R`-units;\n    (units : ∀ (u : Kˣ) (hu : u ∈ R.unit_group) \n      (f : dual F (F ⊗[ℤ] additive Kˣ))\n      (hf : f ∈ I), f [u]ₘ = 0)\n    -- (3) the elements `f` of `D` satisfy `f [u]ₘ = 0` for `R`-principal-units;\n    (punits : ∀ (u : Kˣ) (hu : u ∈ R.principal_unit_group) \n      (f : dual F (F ⊗[ℤ] additive Kˣ))\n      (hf : f ∈ D), f [u]ₘ = 0)\n    -- (4) the quotient `D / I` is finite dimensional;\n    (fd : finite_dimensional F (↥D ⧸ I.comap D.subtype)),\n    -- and `I` has codimension at most one in `D`.\n    finrank F (↥D ⧸ I.comap D.subtype) ≤ 1 := \nbegin\n  rw submodule.is_closed_iff at h1,\n  let T := D.dual_annihilator_comap,\n  have hTD : T.dual_annihilator = D,\n  { dsimp only [T],\n    exact h1.dual_comap_dual },\n  have hacl : D.acl,\n  { refine ⟨h1, h3, h2⟩ },\n  have hacl' : T.dual_annihilator.acl, \n  { convert hacl },\n  obtain ⟨R,H,le,units,principal_units,fd,codim⟩ := main_theorem_mul T hacl',\n  let I := H.dual_annihilator,\n  obtain ⟨e⟩ : nonempty ((↥D ⧸ submodule.comap D.subtype I) ≃ₗ[F] \n    (dual F (↥H ⧸ T.comap H.subtype))), \n  { dsimp [I],\n    rw ← hTD,\n    use submodule.dual_mod_comap_iso T H le,},\n  refine ⟨R, I, _, _, _, _, _, _⟩,\n  { rw submodule.is_closed_iff, apply submodule.is_closed_dual_annihilator },\n  { intros f hf, rw [← hTD, submodule.mem_dual_annihilator], \n    intros w hw,\n    dsimp [I] at hf,\n    erw submodule.mem_dual_annihilator at hf,\n    apply hf, apply le, assumption },\n  { intros u hu, \n    rw ← submodule.mem_dual_annihilator_comap_iff,\n    dsimp [I], rw submodule.dual_annihilator_dual_annihilator_comap,\n    apply units, assumption },\n  { intros u hu,\n    rw ← submodule.mem_dual_annihilator_comap_iff,\n    apply principal_units, assumption },\n  { resetI, apply e.symm.finite_dimensional },\n  { resetI, rwa [e.finrank_eq, subspace.dual_finrank_eq] },\nend\n\n", "meta": {"author": "adamtopaz", "repo": "lean-acl-pairs", "sha": "6ac31d86ca2739b6c18d3f05b7007e720f66299f", "save_path": "github-repos/lean/adamtopaz-lean-acl-pairs", "path": "github-repos/lean/adamtopaz-lean-acl-pairs/lean-acl-pairs-6ac31d86ca2739b6c18d3f05b7007e720f66299f/src/main_theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812554, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.46831648137734727}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.eq_to_hom\nimport data.ulift\n\n/-!\n# Discrete categories\n\nWe define `discrete α` as a structure containing a term `a : α` for any type `α`,\nand use this type alias to provide a `small_category` instance\nwhose only morphisms are the identities.\n\nThere is an annoying technical difficulty that it has turned out to be inconvenient\nto allow categories with morphisms living in `Prop`,\nso instead of defining `X ⟶ Y` in `discrete α` as `X = Y`,\none might define it as `plift (X = Y)`.\nIn fact, to allow `discrete α` to be a `small_category`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X ⟶ Y` as `ulift (plift (X = Y))`.\n\n`discrete.functor` promotes a function `f : I → C` (for any category `C`) to a functor\n`discrete.functor f : discrete I ⥤ C`.\n\nSimilarly, `discrete.nat_trans` and `discrete.nat_iso` promote `I`-indexed families of morphisms,\nor `I`-indexed families of isomorphisms to natural transformations or natural isomorphism.\n\nWe show equivalences of types are the same as (categorical) equivalences of the corresponding\ndiscrete categories.\n-/\n\nnamespace category_theory\n\n-- morphism levels before object levels. See note [category_theory universes].\nuniverses v₁ v₂ v₃ u₁ u₂ u₃\n\n/--\nA wrapper for promoting any type to a category,\nwith the only morphisms being equalities.\n-/\n-- This is intentionally a structure rather than a type synonym\n-- to enforce using `discrete_equiv` (or `discrete.mk` and `discrete.as`) to move between\n-- `discrete α` and `α`. Otherwise there is too much API leakage.\n@[ext] structure discrete (α : Type u₁) :=\n(as : α)\n\n@[simp] lemma discrete.mk_as {α : Type u₁} (X : discrete α) : discrete.mk X.as = X :=\nby { ext, refl, }\n\n/-- `discrete α` is equivalent to the original type `α`.-/\n@[simps] def discrete_equiv {α : Type u₁} : discrete α ≃ α :=\n{ to_fun := discrete.as,\n  inv_fun := discrete.mk,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\ninstance {α : Type u₁} [decidable_eq α] : decidable_eq (discrete α) :=\ndiscrete_equiv.decidable_eq\n\n/--\nThe \"discrete\" category on a type, whose morphisms are equalities.\n\nBecause we do not allow morphisms in `Prop` (only in `Type`),\nsomewhat annoyingly we have to define `X ⟶ Y` as `ulift (plift (X = Y))`.\n\nSee <https://stacks.math.columbia.edu/tag/001A>\n-/\ninstance discrete_category (α : Type u₁) : small_category (discrete α) :=\n{ hom  := λ X Y, ulift (plift (X.as = Y.as)),\n  id   := λ X, ulift.up (plift.up rfl),\n  comp := λ X Y Z g f, by { cases X, cases Y, cases Z, rcases f with ⟨⟨⟨⟩⟩⟩, exact g } }\n\nnamespace discrete\n\nvariables {α : Type u₁}\n\ninstance [inhabited α] : inhabited (discrete α) :=\n⟨⟨default⟩⟩\n\ninstance [subsingleton α] : subsingleton (discrete α) :=\n⟨by { intros, ext, apply subsingleton.elim, }⟩\n\n/-- A simple tactic to run `cases` on any `discrete α` hypotheses. -/\nmeta def _root_.tactic.discrete_cases : tactic unit :=\n`[cases_matching* [discrete _, (_ : discrete _) ⟶ (_ : discrete _), plift _]]\n\nrun_cmd add_interactive [``tactic.discrete_cases]\n\nlocal attribute [tidy] tactic.discrete_cases\n\ninstance [unique α] : unique (discrete α) :=\nunique.mk' (discrete α)\n\n/-- Extract the equation from a morphism in a discrete category. -/\n\n\n/-- Promote an equation between the wrapped terms in `X Y : discrete α` to a morphism `X ⟶ Y`\nin the discrete category. -/\nabbreviation eq_to_hom {X Y : discrete α} (h : X.as = Y.as) : X ⟶ Y :=\neq_to_hom (by { ext, exact h, })\n\n/-- Promote an equation between the wrapped terms in `X Y : discrete α` to an isomorphism `X ≅ Y`\nin the discrete category. -/\nabbreviation eq_to_iso {X Y : discrete α} (h : X.as = Y.as) : X ≅ Y :=\neq_to_iso (by { ext, exact h, })\n\n/-- A variant of `eq_to_hom` that lifts terms to the discrete category. -/\nabbreviation eq_to_hom' {a b : α} (h : a = b) : discrete.mk a ⟶ discrete.mk b :=\neq_to_hom h\n\n/-- A variant of `eq_to_iso` that lifts terms to the discrete category. -/\nabbreviation eq_to_iso' {a b : α} (h : a = b) : discrete.mk a ≅ discrete.mk b :=\neq_to_iso h\n\n@[simp] lemma id_def (X : discrete α) : ulift.up (plift.up (eq.refl X.as)) = 𝟙 X := rfl\n\nvariables {C : Type u₂} [category.{v₂} C]\n\ninstance {I : Type u₁} {i j : discrete I} (f : i ⟶ j) : is_iso f :=\n⟨⟨eq_to_hom (eq_of_hom f).symm, by tidy⟩⟩\n\n/--\nAny function `I → C` gives a functor `discrete I ⥤ C`.\n-/\ndef functor {I : Type u₁} (F : I → C) : discrete I ⥤ C :=\n{ obj := F ∘ discrete.as,\n  map := λ X Y f, by { discrete_cases, cases f, exact 𝟙 (F X), } }\n\n@[simp] lemma functor_obj  {I : Type u₁} (F : I → C) (i : I) :\n  (discrete.functor F).obj (discrete.mk i) = F i := rfl\n\nlemma functor_map  {I : Type u₁} (F : I → C) {i : discrete I} (f : i ⟶ i) :\n  (discrete.functor F).map f = 𝟙 (F i.as) :=\nby tidy\n\n/--\nFor functors out of a discrete category,\na natural transformation is just a collection of maps,\nas the naturality squares are trivial.\n-/\n@[simps]\ndef nat_trans {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ⟶ G.obj i) : F ⟶ G :=\n{ app := f,\n  naturality' := λ X Y g, by { discrete_cases, cases g, simp, } }\n\n/--\nFor functors out of a discrete category,\na natural isomorphism is just a collection of isomorphisms,\nas the naturality squares are trivial.\n-/\n@[simps]\ndef nat_iso {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) : F ≅ G :=\nnat_iso.of_components f (λ X Y g, by { discrete_cases, cases g, simp, })\n\n@[simp]\nlemma nat_iso_app {I : Type u₁} {F G : discrete I ⥤ C}\n  (f : Π i : discrete I, F.obj i ≅ G.obj i) (i : discrete I) :\n  (discrete.nat_iso f).app i = f i :=\nby tidy\n\n/-- Every functor `F` from a discrete category is naturally isomorphic (actually, equal) to\n  `discrete.functor (F.obj)`. -/\n@[simp]\ndef nat_iso_functor {I : Type u₁} {F : discrete I ⥤ C} :\n  F ≅ discrete.functor (F.obj ∘ discrete.mk) :=\nnat_iso $ λ i, by { discrete_cases, refl, }\n\n/-- Composing `discrete.functor F` with another functor `G` amounts to composing `F` with `G.obj` -/\n@[simp]\ndef comp_nat_iso_discrete {I : Type u₁} {D : Type u₃} [category.{v₃} D]\n (F : I → C) (G : C ⥤ D) : discrete.functor F ⋙ G ≅ discrete.functor (G.obj ∘ F) :=\nnat_iso $ λ i, iso.refl _\n\n/--\nWe can promote a type-level `equiv` to\nan equivalence between the corresponding `discrete` categories.\n-/\n@[simps]\ndef equivalence {I : Type u₁} {J : Type u₂} (e : I ≃ J) : discrete I ≌ discrete J :=\n{ functor := discrete.functor (discrete.mk ∘ (e : I → J)),\n  inverse := discrete.functor (discrete.mk ∘ (e.symm : J → I)),\n  unit_iso := discrete.nat_iso (λ i, eq_to_iso (by { discrete_cases, simp })),\n  counit_iso := discrete.nat_iso (λ j, eq_to_iso (by { discrete_cases, simp })), }\n\n/-- We can convert an equivalence of `discrete` categories to a type-level `equiv`. -/\n@[simps]\ndef equiv_of_equivalence {α : Type u₁} {β : Type u₂} (h : discrete α ≌ discrete β) : α ≃ β :=\n{ to_fun := discrete.as ∘ h.functor.obj ∘ discrete.mk,\n  inv_fun := discrete.as ∘ h.inverse.obj ∘ discrete.mk,\n  left_inv := λ a, by simpa using eq_of_hom (h.unit_iso.app (discrete.mk a)).2,\n  right_inv := λ a, by simpa using eq_of_hom (h.counit_iso.app (discrete.mk a)).1, }\n\nend discrete\n\nnamespace discrete\nvariables {J : Type v₁}\n\nopen opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\n@[simps functor_obj_as inverse_obj]\nprotected def opposite (α : Type u₁) : (discrete α)ᵒᵖ ≌ discrete α :=\nlet F : discrete α ⥤ (discrete α)ᵒᵖ := discrete.functor (λ x, op (discrete.mk x)) in\nbegin\n  refine equivalence.mk (functor.left_op F) F _\n    (discrete.nat_iso $ λ X, by { discrete_cases, simp [F] }),\n  refine nat_iso.of_components (λ X, by { tactic.op_induction', discrete_cases, simp [F], }) _,\n  tidy\nend\n\nvariables {C : Type u₂} [category.{v₂} C]\n\n@[simp] lemma functor_map_id\n  (F : discrete J ⥤ C) {j : discrete J} (f : j ⟶ j) : F.map f = 𝟙 (F.obj j) :=\nbegin\n  have h : f = 𝟙 j, { cases f, cases f, ext, },\n  rw h,\n  simp,\nend\n\nend discrete\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/discrete_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.46821108112304055}}
{"text": "/-\nCopyright (c) 2020 Heather Macbeth. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Heather Macbeth, Frédéric Dupuis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.normed_space.hahn_banach\nimport Mathlib.analysis.normed_space.inner_product\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u v \n\nnamespace Mathlib\n\n/-!\n# The topological dual of a normed space\n\nIn this file we define the topological dual of a normed space, and the bounded linear map from\na normed space into its double dual.\n\nWe also prove that, for base field `𝕜` with `[is_R_or_C 𝕜]`, this map is an isometry.\n\nWe then consider inner product spaces, with base field over `ℝ` (the corresponding results for `ℂ`\nwill require the definition of conjugate-linear maps). We define `to_dual_map`, a continuous linear\nmap from `E` to its dual, which maps an element `x` of the space to `λ y, ⟪x, y⟫`. We check\n(`to_dual_map_isometry`) that this map is an isometry onto its image, and particular is injective.\nWe also define `to_dual'` as the function taking taking a vector to its dual for a base field `𝕜`\nwith `[is_R_or_C 𝕜]`; this is a function and not a linear map.\n\nFinally, under the hypothesis of completeness (i.e., for Hilbert spaces), we prove the Fréchet-Riesz\nrepresentation (`to_dual_map_eq_top`), which states the surjectivity: every element of the dual\nof a Hilbert space `E` has the form `λ u, ⟪x, u⟫` for some `x : E`.  This permits the map\n`to_dual_map` to be upgraded to an (isometric) continuous linear equivalence, `to_dual`, between a\nHilbert space and its dual.\n\n## References\n\n* [M. Einsiedler and T. Ward, *Functional Analysis, Spectral Theory, and Applications*]\n  [EinsiedlerWard2017]\n\n## Tags\n\ndual, Fréchet-Riesz\n-/\n\nnamespace normed_space\n\n\n/-- The topological dual of a normed space `E`. -/\ndef dual (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (E : Type u_2) [normed_group E] [normed_space 𝕜 E] :=\n  continuous_linear_map 𝕜 E 𝕜\n\nprotected instance dual.inhabited (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (E : Type u_2) [normed_group E] [normed_space 𝕜 E] : Inhabited (dual 𝕜 E) :=\n  { default := 0 }\n\n/-- The inclusion of a normed space in its double (topological) dual. -/\ndef inclusion_in_double_dual' (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (E : Type u_2) [normed_group E] [normed_space 𝕜 E] (x : E) : dual 𝕜 (dual 𝕜 E) :=\n  linear_map.mk_continuous (linear_map.mk (fun (f : dual 𝕜 E) => coe_fn f x) sorry sorry) (norm x) sorry\n\n@[simp] theorem dual_def (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (E : Type u_2) [normed_group E] [normed_space 𝕜 E] (x : E) (f : dual 𝕜 E) : coe_fn (inclusion_in_double_dual' 𝕜 E x) f = coe_fn f x :=\n  rfl\n\ntheorem double_dual_bound (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (E : Type u_2) [normed_group E] [normed_space 𝕜 E] (x : E) : norm (inclusion_in_double_dual' 𝕜 E x) ≤ norm x := sorry\n\n/-- The inclusion of a normed space in its double (topological) dual, considered\n   as a bounded linear map. -/\ndef inclusion_in_double_dual (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (E : Type u_2) [normed_group E] [normed_space 𝕜 E] : continuous_linear_map 𝕜 E (dual 𝕜 (dual 𝕜 E)) :=\n  linear_map.mk_continuous (linear_map.mk (fun (x : E) => inclusion_in_double_dual' 𝕜 E x) sorry sorry) 1 sorry\n\n/-- If one controls the norm of every `f x`, then one controls the norm of `x`.\n    Compare `continuous_linear_map.op_norm_le_bound`. -/\ntheorem norm_le_dual_bound {𝕜 : Type v} [is_R_or_C 𝕜] {E : Type u} [normed_group E] [normed_space 𝕜 E] (x : E) {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ (f : dual 𝕜 E), norm (coe_fn f x) ≤ M * norm f) : norm x ≤ M := sorry\n\n/-- The inclusion of a normed space in its double dual is an isometry onto its image.-/\ntheorem inclusion_in_double_dual_isometry {𝕜 : Type v} [is_R_or_C 𝕜] {E : Type u} [normed_group E] [normed_space 𝕜 E] (x : E) : norm (coe_fn (inclusion_in_double_dual 𝕜 E) x) = norm x := sorry\n\nend normed_space\n\n\nnamespace inner_product_space\n\n\n/--\nGiven some `x` in an inner product space, we can define its dual as the continuous linear map\n`λ y, ⟪x, y⟫`. Consider using `to_dual` or `to_dual_map` instead in the real case.\n-/\ndef to_dual' (𝕜 : Type u_1) {E : Type u_2} [is_R_or_C 𝕜] [inner_product_space 𝕜 E] : E →+ normed_space.dual 𝕜 E :=\n  add_monoid_hom.mk\n    (fun (x : E) => linear_map.mk_continuous (linear_map.mk (fun (y : E) => inner x y) sorry sorry) (norm x) sorry) sorry\n    sorry\n\n@[simp] theorem to_dual'_apply (𝕜 : Type u_1) {E : Type u_2} [is_R_or_C 𝕜] [inner_product_space 𝕜 E] {x : E} {y : E} : coe_fn (coe_fn (to_dual' 𝕜) x) y = inner x y :=\n  rfl\n\n/-- In an inner product space, the norm of the dual of a vector `x` is `∥x∥` -/\n@[simp] theorem norm_to_dual'_apply (𝕜 : Type u_1) {E : Type u_2} [is_R_or_C 𝕜] [inner_product_space 𝕜 E] (x : E) : norm (coe_fn (to_dual' 𝕜) x) = norm x := sorry\n\ntheorem to_dual'_isometry (𝕜 : Type u_1) (E : Type u_2) [is_R_or_C 𝕜] [inner_product_space 𝕜 E] : isometry ⇑(to_dual' 𝕜) :=\n  add_monoid_hom.isometry_of_norm (to_dual' 𝕜) (norm_to_dual'_apply 𝕜)\n\n/--\nFréchet-Riesz representation: any `ℓ` in the dual of a Hilbert space `E` is of the form\n`λ u, ⟪y, u⟫` for some `y : E`, i.e. `to_dual'` is surjective.\n-/\ntheorem to_dual'_surjective (𝕜 : Type u_1) (E : Type u_2) [is_R_or_C 𝕜] [inner_product_space 𝕜 E] [complete_space E] : function.surjective ⇑(to_dual' 𝕜) := sorry\n\n/-- In a real inner product space `F`, the function that takes a vector `x` in `F` to its dual\n`λ y, ⟪x, y⟫` is a continuous linear map. If the space is complete (i.e. is a Hilbert space),\nconsider using `to_dual` instead. -/\n-- TODO extend to `is_R_or_C` (requires a definition of conjugate linear maps)\n\ndef to_dual_map {F : Type u_1} [inner_product_space ℝ F] : continuous_linear_map ℝ F (normed_space.dual ℝ F) :=\n  linear_map.mk_continuous (linear_map.mk ⇑(to_dual' ℝ) sorry sorry) 1 sorry\n\n@[simp] theorem to_dual_map_apply {F : Type u_1} [inner_product_space ℝ F] {x : F} {y : F} : coe_fn (coe_fn to_dual_map x) y = inner x y :=\n  rfl\n\n/-- In an inner product space, the norm of the dual of a vector `x` is `∥x∥` -/\n@[simp] theorem norm_to_dual_map_apply {F : Type u_1} [inner_product_space ℝ F] (x : F) : norm (coe_fn to_dual_map x) = norm x :=\n  norm_to_dual'_apply ℝ x\n\ntheorem to_dual_map_isometry {F : Type u_1} [inner_product_space ℝ F] : isometry ⇑to_dual_map :=\n  add_monoid_hom.isometry_of_norm (to_dual' ℝ) norm_to_dual_map_apply\n\ntheorem to_dual_map_injective {F : Type u_1} [inner_product_space ℝ F] : function.injective ⇑to_dual_map :=\n  isometry.injective to_dual_map_isometry\n\n@[simp] theorem ker_to_dual_map {F : Type u_1} [inner_product_space ℝ F] : continuous_linear_map.ker to_dual_map = ⊥ :=\n  iff.mpr linear_map.ker_eq_bot to_dual_map_injective\n\n@[simp] theorem to_dual_map_eq_iff_eq {F : Type u_1} [inner_product_space ℝ F] {x : F} {y : F} : coe_fn to_dual_map x = coe_fn to_dual_map y ↔ x = y :=\n  function.injective.eq_iff (iff.mp linear_map.ker_eq_bot ker_to_dual_map)\n\n/--\nFréchet-Riesz representation: any `ℓ` in the dual of a real Hilbert space `F` is of the form\n`λ u, ⟪y, u⟫` for some `y` in `F`.  See `inner_product_space.to_dual` for the continuous linear\nequivalence thus induced.\n-/\n-- TODO extend to `is_R_or_C` (requires a definition of conjugate linear maps)\n\ntheorem range_to_dual_map {F : Type u_1} [inner_product_space ℝ F] [complete_space F] : continuous_linear_map.range to_dual_map = ⊤ :=\n  iff.mpr linear_map.range_eq_top (to_dual'_surjective ℝ F)\n\n/--\nFréchet-Riesz representation: If `F` is a Hilbert space, the function that takes a vector in `F` to\nits dual is a continuous linear equivalence.  -/\ndef to_dual {F : Type u_1} [inner_product_space ℝ F] [complete_space F] : continuous_linear_equiv ℝ F (normed_space.dual ℝ F) :=\n  continuous_linear_equiv.of_isometry (continuous_linear_map.to_linear_map to_dual_map) to_dual_map_isometry\n    range_to_dual_map\n\n/--\nFréchet-Riesz representation: If `F` is a Hilbert space, the function that takes a vector in `F` to\nits dual is an isometry.  -/\ndef isometric.to_dual {F : Type u_1} [inner_product_space ℝ F] [complete_space F] : F ≃ᵢ normed_space.dual ℝ F :=\n  isometric.mk (linear_equiv.to_equiv (continuous_linear_equiv.to_linear_equiv to_dual)) (to_dual'_isometry ℝ F)\n\n@[simp] theorem to_dual_apply {F : Type u_1} [inner_product_space ℝ F] [complete_space F] {x : F} {y : F} : coe_fn (coe_fn to_dual x) y = inner x y :=\n  rfl\n\n@[simp] theorem to_dual_eq_iff_eq {F : Type u_1} [inner_product_space ℝ F] [complete_space F] {x : F} {y : F} : coe_fn to_dual x = coe_fn to_dual y ↔ x = y :=\n  function.injective.eq_iff (continuous_linear_equiv.injective to_dual)\n\ntheorem to_dual_eq_iff_eq' {F : Type u_1} [inner_product_space ℝ F] [complete_space F] {x : F} {x' : F} : (∀ (y : F), inner x y = inner x' y) ↔ x = x' := sorry\n\n@[simp] theorem norm_to_dual_apply {F : Type u_1} [inner_product_space ℝ F] [complete_space F] (x : F) : norm (coe_fn to_dual x) = norm x :=\n  norm_to_dual_map_apply x\n\n/-- In a Hilbert space, the norm of a vector in the dual space is the norm of its corresponding\nprimal vector. -/\ntheorem norm_to_dual_symm_apply {F : Type u_1} [inner_product_space ℝ F] [complete_space F] (ℓ : normed_space.dual ℝ F) : norm (coe_fn (continuous_linear_equiv.symm to_dual) ℓ) = norm ℓ := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/dual.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.46821107674084905}}
{"text": "import Mathlib.Data.Nat.Basic\nimport Lean4.Range\n\nopen Std Std.Range Std.Range.forIn\n\ndef ff (n : ℕ) : ℕ := Id.run do\n  let mut r := 0\n  for _ in [: n] do\n    r ← r + 1\n  return r\n\ndef incStep : ℕ → ℕ → Id (ForInStep ℕ) := λ _ r => ForInStep.yield (r + 1)\n\nvariable {m : Type u → Type v} [Monad m]\n\n-- loop f start stop 1 init (Nat.zero_lt_one) = init\ntheorem singleIncStep {k : ℕ} : Std.Range.forIn (mkRange' k k.succ) init incStep = init + 1 := by\n  simp [mkRange']\n  rw [Range.forIn]\n  simp\n  rw [loop]\n  simp [incStep, eq_false (Nat.not_succ_le_self k)]\n  exact emptyStep' Nat.le.refl\n\n-- For a function that's independent of the loop variable\n-- The result only depends on the number of iterations\n-- Notes: In `f i r`, `i` is the loop variable and `r` is the \"program state\"\n-- Notes: `Std.Range.forIn range init f`\n-- TODO: Generalise `f` to `ℕ → β → Id (ForInStep β)` (I do not know how to do this)\ntheorem succInvariantLt {k : ℕ} {init : β} {f : ℕ → β → Id (ForInStep β)} (start stop skip : ℕ)\n  (hf : ∀ i j : ℕ, f i = f j) (hs : start ≤ stop) : Range.forIn (mkRange' start stop) init f\n    = Range.forIn (mkRange' (start + skip) (stop + skip)) init f := by\n  -- Proof idea: define new function g that's independent of index, then prove they're equivalent\n  -- Then just prove it's the g applied stop - start times by induction\n  let g := f 0\n  have hf' : f = λ _ r => g r := by\n    funext\n    rw [hf _ 0]  \n  cases' Nat.exists_eq_add_of_le hs with k hk\n  rw [hk]\n  induction' k with t ht\n  simp [emptyStep]\n  sorry\n\ntheorem succInvariant {k : ℕ} {init : β} {f : ℕ → β → Id (ForInStep β)} (start stop skip : ℕ)\n  (hf : ∀ i j : ℕ, f i = f j) : Range.forIn (mkRange' start stop) init f\n    = Range.forIn (mkRange' (start + skip) (stop + skip)) init f := by\n  by_cases h : start < stop\n  exact @succInvariantLt _ k init f start stop skip hf (Nat.le_of_lt h)\n  simp [Range.forIn, mkRange', emptyStep' (Nat.ge_of_not_lt h),\n        emptyStep' (Nat.add_le_add_right (Nat.ge_of_not_lt h) skip)]\n\ntheorem incStepAlwaysYield : ∀ (i r : ℕ), ForInStep.isYield (incStep i r) := by\n  simp [incStep, ForInStep.isYield]\n\n-- This is kind of an ad-hoc theorem for the simple program\n-- Also, I have a question: `s` is a Nat here and the loop (RHS) is a `Id Nat`\n-- How do they compare?\ntheorem stateInvariant {n : ℕ} (init : ℕ) :\n  Id.run (Range.forIn (mkRange' 0 n) init incStep) + 1\n  = Range.forIn (mkRange' 0 n.succ) init incStep := by\n  induction' n with k hk\n  -- n = 0\n  simp [Id.run, Range.forIn, incStep, mkRange']\n  rw [loop, loop]\n  simp [Id.run, Range.forIn, incStep, Nat.one_eq_succ_zero]\n  rw [emptyStep' Nat.le.refl]\n  -- n = k → n = k + 1\n  simp [Id.run] at *\n  rw [rangeDecompose _ k.succ k.succ.succ _ incStepAlwaysYield, Id.run, ← hk, singleIncStep]\n  simp [Nat.le_succ]\n\ntheorem ff' : ff n = n := by\n  induction' n with k hk\n  simp\n  let h := (@stateInvariant k 0)\n  simp [ff, Id.run, Range.forIn, loop, ← succInvariant] at *\n  simp [Id.run, incStep, mkRange', Range.forIn] at h\n  conv_rhs => rw [← hk, Nat.succ_eq_add_one]\n  sorry\n\nnamespace Examples\n\nexample : ff 5 = 5 := ff'\n\nend Examples\n\n/-\n**Test Functions**\n\nHere are some test functions.\n-/\n\ndef f1 (n : ℕ) : ℕ := Id.run do\n  let mut r := 0\n  for i in [: 2 * n] do\n    if i % 2 = 0 then\n      continue\n    if i = 2 * n then\n      break\n    r ← r + i\n  return r\n\n/-\nforIn RANGE r fun i r =>\n  let r := r;\n  let __do_jp := fun r y =>\n    let __do_jp := fun r y => do\n      let r ← r + i\n      let r : ℕ := r\n      pure PUnit.unit\n      pure (ForInStep.yield r);\n    if i = 2 * n then pure (ForInStep.done r) -- `break`\n    else do\n      let y ← pure PUnit.unit\n      __do_jp r y;\n  if i % 2 = 0 then pure (ForInStep.yield r)  -- `continue`\n  else do\n    let y ← pure PUnit.unit\n    __do_jp r y\n-/\n\n#print f1\n#eval f1 50", "meta": {"author": "grhkm21", "repo": "lean4", "sha": "2e3414e5b0eabfda1169ffe1bd5754daf24ea759", "save_path": "github-repos/lean/grhkm21-lean4", "path": "github-repos/lean/grhkm21-lean4/lean4-2e3414e5b0eabfda1169ffe1bd5754daf24ea759/Lean4/Monad.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.46821107674084905}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.subobject.limits\n\n/-!\n# Image-to-kernel comparison maps\n\nWhenever `f : A ⟶ B` and `g : B ⟶ C` satisfy `w : f ≫ g = 0`,\nwe have `image_le_kernel f g w : image_subobject f ≤ kernel_subobject g`\n(assuming the appropriate images and kernels exist).\n\n`image_to_kernel f g w` is the corresponding morphism between objects in `C`.\n\nWe define `homology f g w` of such a pair as the cokernel of `image_to_kernel f g w`.\n-/\n\nuniverses v u\n\nopen category_theory category_theory.limits\n\nvariables {ι : Type*}\nvariables {V : Type u} [category.{v} V] [has_zero_morphisms V]\n\nopen_locale classical\nnoncomputable theory\n\nsection\nvariables {A B C : V} (f : A ⟶ B) [has_image f] (g : B ⟶ C) [has_kernel g]\n\nlemma image_le_kernel (w : f ≫ g = 0) :\n  image_subobject f ≤ kernel_subobject g :=\nimage_subobject_le_mk _ _ (kernel.lift _ _ w) (by simp)\n\n/--\nThe canonical morphism `image_subobject f ⟶ kernel_subobject g` when `f ≫ g = 0`.\n-/\n@[derive mono]\ndef image_to_kernel (w : f ≫ g = 0) :\n  (image_subobject f : V) ⟶ (kernel_subobject g : V) :=\n(subobject.of_le _ _ (image_le_kernel _ _ w))\n\n/-- Prefer `image_to_kernel`. -/\n@[simp] lemma subobject_of_le_as_image_to_kernel (w : f ≫ g = 0) (h) :\n  subobject.of_le (image_subobject f) (kernel_subobject g) h = image_to_kernel f g w :=\nrfl\n\n@[simp, reassoc]\nlemma image_to_kernel_arrow (w : f ≫ g = 0) :\n  image_to_kernel f g w ≫ (kernel_subobject g).arrow = (image_subobject f).arrow :=\nby simp [image_to_kernel]\n\n-- This is less useful as a `simp` lemma than it initially appears,\n-- as it \"loses\" the information the morphism factors through the image.\nlemma factor_thru_image_subobject_comp_image_to_kernel (w : f ≫ g = 0) :\n  factor_thru_image_subobject f ≫ image_to_kernel f g w = factor_thru_kernel_subobject g f w :=\nby { ext, simp, }\n\nend\n\nsection\nvariables {A B C : V} (f : A ⟶ B) (g : B ⟶ C)\n\n@[simp]\nlemma image_to_kernel_zero_left [has_kernels V] [has_zero_object V] {w} :\n  image_to_kernel (0 : A ⟶ B) g w = 0 :=\nby { ext, simp, }\n\nlemma image_to_kernel_zero_right [has_images V] {w} :\n  image_to_kernel f (0 : B ⟶ C) w =\n    (image_subobject f).arrow ≫ inv (kernel_subobject (0 : B ⟶ C)).arrow :=\nby { ext, simp }\n\nsection\nvariables [has_kernels V] [has_images V]\n\nlemma image_to_kernel_comp_right {D : V} (h : C ⟶ D) (w : f ≫ g = 0) :\n  image_to_kernel f (g ≫ h) (by simp [reassoc_of w]) =\n    image_to_kernel f g w ≫ subobject.of_le _ _ (kernel_subobject_comp_le g h) :=\nby { ext, simp }\n\nlemma image_to_kernel_comp_left {Z : V} (h : Z ⟶ A) (w : f ≫ g = 0) :\n  image_to_kernel (h ≫ f) g (by simp [w]) =\n    subobject.of_le _ _ (image_subobject_comp_le h f) ≫ image_to_kernel f g w :=\nby { ext, simp }\n\n@[simp]\nlemma image_to_kernel_comp_mono {D : V} (h : C ⟶ D) [mono h] (w) :\n  image_to_kernel f (g ≫ h) w =\n  image_to_kernel f g ((cancel_mono h).mp (by simpa using w : (f ≫ g) ≫ h = 0 ≫ h)) ≫\n    (subobject.iso_of_eq _ _ (kernel_subobject_comp_mono g h)).inv :=\nby { ext, simp, }\n\n@[simp]\nlemma image_to_kernel_epi_comp {Z : V} (h : Z ⟶ A) [epi h] (w) :\n  image_to_kernel (h ≫ f) g w =\n  subobject.of_le _ _ (image_subobject_comp_le h f) ≫\n    image_to_kernel f g ((cancel_epi h).mp (by simpa using w : h ≫ f ≫ g = h ≫ 0)) :=\nby { ext, simp, }\n\nend\n\n@[simp]\nlemma image_to_kernel_comp_hom_inv_comp [has_equalizers V] [has_images V] {Z : V} {i : B ≅ Z} (w) :\n  image_to_kernel (f ≫ i.hom) (i.inv ≫ g) w =\n  (image_subobject_comp_iso _ _).hom ≫ image_to_kernel f g (by simpa using w) ≫\n    (kernel_subobject_iso_comp i.inv g).inv :=\nby { ext, simp, }\n\nopen_locale zero_object\n\n/--\n`image_to_kernel` for `A --0--> B --g--> C`, where `g` is a mono is itself an epi\n(i.e. the sequence is exact at `B`).\n-/\ninstance image_to_kernel_epi_of_zero_of_mono [has_kernels V] [has_zero_object V] [mono g] :\n  epi (image_to_kernel (0 : A ⟶ B) g (by simp)) :=\nepi_of_target_iso_zero _ (kernel_subobject_iso g ≪≫ kernel.of_mono g)\n\n/--\n`image_to_kernel` for `A --f--> B --0--> C`, where `g` is an epi is itself an epi\n(i.e. the sequence is exact at `B`).\n-/\ninstance image_to_kernel_epi_of_epi_of_zero [has_images V] [epi f] :\n  epi (image_to_kernel f (0 : B ⟶ C) (by simp)) :=\nbegin\n  simp only [image_to_kernel_zero_right],\n  haveI := epi_image_of_epi f,\n  rw ←image_subobject_arrow,\n  refine @epi_comp _ _ _ _ _ _ (epi_comp _ _) _ _,\nend\n\nend\n\nsection\nvariables {A B C : V} (f : A ⟶ B) [has_image f] (g : B ⟶ C) [has_kernel g]\n\n/--\nThe homology of a pair of morphisms `f : A ⟶ B` and `g : B ⟶ C` satisfying `f ≫ g = 0`\nis the cokernel of the `image_to_kernel` morphism for `f` and `g`.\n-/\ndef homology {A B C : V} (f : A ⟶ B) [has_image f] (g : B ⟶ C) [has_kernel g]\n  (w : f ≫ g = 0) [has_cokernel (image_to_kernel f g w)] : V :=\ncokernel (image_to_kernel f g w)\n\nsection\nvariables (w : f ≫ g = 0) [has_cokernel (image_to_kernel f g w)]\n\n/-- The morphism from cycles to homology. -/\ndef homology.π : (kernel_subobject g : V) ⟶ homology f g w :=\ncokernel.π _\n\n@[simp] lemma homology.condition : image_to_kernel f g w ≫ homology.π f g w = 0 :=\ncokernel.condition _\n\n/--\nTo construct a map out of homology, it suffices to construct a map out of the cycles\nwhich vanishes on boundaries.\n-/\ndef homology.desc {D : V} (k : (kernel_subobject g : V) ⟶ D) (p : image_to_kernel f g w ≫ k = 0) :\n  homology f g w ⟶ D :=\ncokernel.desc _ k p\n\n@[simp, reassoc]\nlemma homology.π_desc\n  {D : V} (k : (kernel_subobject g : V) ⟶ D) (p : image_to_kernel f g w ≫ k = 0) :\n  homology.π f g w ≫ homology.desc f g w k p = k :=\nby { simp [homology.π, homology.desc], }\n\n/-- To check two morphisms out of `homology f g w` are equal, it suffices to check on cycles. -/\n@[ext]\nlemma homology.ext {D : V} {k k' : homology f g w ⟶ D}\n  (p : homology.π f g w ≫ k = homology.π f g w ≫ k') : k = k' :=\nby { ext, exact p, }\n\n/-- `homology 0 0 _` is just the middle object. -/\n@[simps]\ndef homology_zero_zero [has_zero_object V]\n  [has_image (0 : A ⟶ B)] [has_cokernel (image_to_kernel (0 : A ⟶ B) (0 : B ⟶ C) (by simp))] :\n  homology (0 : A ⟶ B) (0 : B ⟶ C) (by simp) ≅ B :=\n{ hom := homology.desc (0 : A ⟶ B) (0 : B ⟶ C) (by simp) (kernel_subobject 0).arrow (by simp),\n  inv := inv (kernel_subobject 0).arrow ≫ homology.π _ _ _, }\n\nend\n\nsection\nvariables {f g} (w : f ≫ g = 0)\n  {A' B' C' : V} {f' : A' ⟶ B'} [has_image f'] {g' : B' ⟶ C'} [has_kernel g'] (w' : f' ≫ g' = 0)\n  (α : arrow.mk f ⟶ arrow.mk f') [has_image_map α] (β : arrow.mk g ⟶ arrow.mk g')\n  {A₁ B₁ C₁ : V} {f₁ : A₁ ⟶ B₁} [has_image f₁] {g₁ : B₁ ⟶ C₁} [has_kernel g₁] (w₁ : f₁ ≫ g₁ = 0)\n  {A₂ B₂ C₂ : V} {f₂ : A₂ ⟶ B₂} [has_image f₂] {g₂ : B₂ ⟶ C₂} [has_kernel g₂] (w₂ : f₂ ≫ g₂ = 0)\n  {A₃ B₃ C₃ : V} {f₃ : A₃ ⟶ B₃} [has_image f₃] {g₃ : B₃ ⟶ C₃} [has_kernel g₃] (w₃ : f₃ ≫ g₃ = 0)\n  (α₁ : arrow.mk f₁ ⟶ arrow.mk f₂) [has_image_map α₁] (β₁ : arrow.mk g₁ ⟶ arrow.mk g₂)\n  (α₂ : arrow.mk f₂ ⟶ arrow.mk f₃) [has_image_map α₂] (β₂ : arrow.mk g₂ ⟶ arrow.mk g₃)\n\n/--\nGiven compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f ≫ g = 0` and `f' ≫ g' = 0`,\nthe `image_to_kernel` morphisms intertwine the induced map on kernels and the induced map on images.\n-/\n@[reassoc]\nlemma image_subobject_map_comp_image_to_kernel (p : α.right = β.left) :\n  image_to_kernel f g w ≫ kernel_subobject_map β =\n    image_subobject_map α ≫ image_to_kernel f' g' w' :=\nby { ext, simp [p], }\n\nvariables [has_cokernel (image_to_kernel f g w)] [has_cokernel (image_to_kernel f' g' w')]\nvariables [has_cokernel (image_to_kernel f₁ g₁ w₁)]\nvariables [has_cokernel (image_to_kernel f₂ g₂ w₂)]\nvariables [has_cokernel (image_to_kernel f₃ g₃ w₃)]\n\n/--\nGiven compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f ≫ g = 0` and `f' ≫ g' = 0`,\nwe get a morphism on homology.\n-/\ndef homology.map (p : α.right = β.left) :\n  homology f g w ⟶ homology f' g' w' :=\ncokernel.desc _ (kernel_subobject_map β ≫ cokernel.π _)\n  begin\n    rw [image_subobject_map_comp_image_to_kernel_assoc w w' α β p],\n    simp only [cokernel.condition, comp_zero],\n  end\n\n@[simp, reassoc]\nlemma homology.π_map (p : α.right = β.left) :\n  homology.π f g w ≫ homology.map w w' α β p = kernel_subobject_map β ≫ homology.π f' g' w' :=\nby simp only [homology.π, homology.map, cokernel.π_desc]\n\n@[simp, reassoc]\nlemma homology.map_desc (p : α.right = β.left)\n  {D : V} (k : (kernel_subobject g' : V) ⟶ D) (z : image_to_kernel f' g' w' ≫ k = 0) :\n  homology.map w w' α β p ≫ homology.desc f' g' w' k z =\n    homology.desc f g w (kernel_subobject_map β ≫ k)\n      (by simp only [image_subobject_map_comp_image_to_kernel_assoc w w' α β p, z, comp_zero]) :=\nby ext; simp only [homology.π_desc, homology.π_map_assoc]\n\n@[simp]\nlemma homology.map_id : homology.map w w (𝟙 _) (𝟙 _) rfl = 𝟙 _ :=\nby ext; simp only [homology.π_map, kernel_subobject_map_id, category.id_comp, category.comp_id]\n\n/-- Auxiliary lemma for homology computations. -/\nlemma homology.comp_right_eq_comp_left\n  {V : Type*} [category V] {A₁ B₁ C₁ A₂ B₂ C₂ A₃ B₃ C₃ : V}\n  {f₁ : A₁ ⟶ B₁} {g₁ : B₁ ⟶ C₁} {f₂ : A₂ ⟶ B₂} {g₂ : B₂ ⟶ C₂} {f₃ : A₃ ⟶ B₃} {g₃ : B₃ ⟶ C₃}\n  {α₁ : arrow.mk f₁ ⟶ arrow.mk f₂} {β₁ : arrow.mk g₁ ⟶ arrow.mk g₂}\n  {α₂ : arrow.mk f₂ ⟶ arrow.mk f₃} {β₂ : arrow.mk g₂ ⟶ arrow.mk g₃}\n  (p₁ : α₁.right = β₁.left) (p₂ : α₂.right = β₂.left) :\n  (α₁ ≫ α₂).right = (β₁ ≫ β₂).left :=\nby simp only [comma.comp_left, comma.comp_right, p₁, p₂]\n\n@[reassoc]\nlemma homology.map_comp (p₁ : α₁.right = β₁.left) (p₂ : α₂.right = β₂.left) :\n  homology.map w₁ w₂ α₁ β₁ p₁ ≫ homology.map w₂ w₃ α₂ β₂ p₂ =\n    homology.map w₁ w₃ (α₁ ≫ α₂) (β₁ ≫ β₂) (homology.comp_right_eq_comp_left p₁ p₂) :=\nby ext; simp only [kernel_subobject_map_comp, homology.π_map_assoc, homology.π_map, category.assoc]\n\n/-- An isomorphism between two three-term complexes induces an isomorphism on homology. -/\ndef homology.map_iso (α : arrow.mk f₁ ≅ arrow.mk f₂) (β : arrow.mk g₁ ≅ arrow.mk g₂)\n  (p : α.hom.right = β.hom.left) :\n  homology f₁ g₁ w₁ ≅ homology f₂ g₂ w₂ :=\n{ hom := homology.map w₁ w₂ α.hom β.hom p,\n  inv := homology.map w₂ w₁ α.inv β.inv\n  (by { rw [← cancel_mono (α.hom.right), ← comma.comp_right, α.inv_hom_id, comma.id_right, p,\n      ← comma.comp_left, β.inv_hom_id, comma.id_left], refl }),\n  hom_inv_id' := by { rw [homology.map_comp], convert homology.map_id _; rw [iso.hom_inv_id] },\n  inv_hom_id' := by { rw [homology.map_comp], convert homology.map_id _; rw [iso.inv_hom_id] } }\n\nend\n\nend\n\nsection\nvariables {A B C : V} {f : A ⟶ B} {g : B ⟶ C} (w : f ≫ g = 0)\n  {f' : A ⟶ B} {g' : B ⟶ C} (w' : f' ≫ g' = 0)\n  [has_kernels V] [has_cokernels V] [has_images V] [has_image_maps V]\n\n/-- Custom tactic to golf and speedup boring proofs in `homology.congr`. -/\nprivate meta def aux_tac : tactic unit :=\n`[ dsimp only [auto_param_eq], erw [category.id_comp, category.comp_id], cases pf, cases pg, refl ]\n\n/--\n`homology f g w ≅ homology f' g' w'` if `f = f'` and `g = g'`.\n(Note the objects are not changing here.)\n-/\n@[simps]\ndef homology.congr (pf : f = f') (pg : g = g') : homology f g w ≅ homology f' g' w' :=\n{ hom := homology.map w w' ⟨𝟙 _, 𝟙 _, by aux_tac⟩ ⟨𝟙 _, 𝟙 _, by aux_tac⟩ rfl,\n  inv := homology.map w' w ⟨𝟙 _, 𝟙 _, by aux_tac⟩ ⟨𝟙 _, 𝟙 _, by aux_tac⟩ rfl,\n  hom_inv_id' := begin\n    cases pf, cases pg, rw [homology.map_comp, ← homology.map_id],\n    congr' 1; exact category.comp_id _,\n  end,\n  inv_hom_id' := begin\n    cases pf, cases pg, rw [homology.map_comp, ← homology.map_id],\n    congr' 1; exact category.comp_id _,\n  end, }\n\nend\n\n/-!\nWe provide a variant `image_to_kernel' : image f ⟶ kernel g`,\nand use this to give alternative formulas for `homology f g w`.\n-/\nsection image_to_kernel'\nvariables {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (w : f ≫ g = 0)\n  [has_kernels V] [has_images V]\n\n/--\nWhile `image_to_kernel f g w` provides a morphism\n`image_subobject f ⟶ kernel_subobject g`\nin terms of the subobject API,\nthis variant provides a morphism\n`image f ⟶ kernel g`,\nwhich is sometimes more convenient.\n-/\ndef image_to_kernel' (w : f ≫ g = 0) : image f ⟶ kernel g :=\nkernel.lift g (image.ι f) (by { ext, simpa using w, })\n\n@[simp] lemma image_subobject_iso_image_to_kernel' (w : f ≫ g = 0) :\n  (image_subobject_iso f).hom ≫ image_to_kernel' f g w =\n    image_to_kernel f g w ≫ (kernel_subobject_iso g).hom :=\nby { ext, simp [image_to_kernel'], }\n\n@[simp] lemma image_to_kernel'_kernel_subobject_iso (w : f ≫ g = 0) :\n  image_to_kernel' f g w ≫ (kernel_subobject_iso g).inv =\n    (image_subobject_iso f).inv ≫ image_to_kernel f g w :=\nby { ext, simp [image_to_kernel'], }\n\nvariables [has_cokernels V]\n\n/--\n`homology f g w` can be computed as the cokernel of `image_to_kernel' f g w`.\n-/\ndef homology_iso_cokernel_image_to_kernel' (w : f ≫ g = 0) :\n  homology f g w ≅ cokernel (image_to_kernel' f g w) :=\n{ hom := cokernel.map _ _ (image_subobject_iso f).hom (kernel_subobject_iso g).hom\n    (by simp only [image_subobject_iso_image_to_kernel']),\n  inv := cokernel.map _ _ (image_subobject_iso f).inv (kernel_subobject_iso g).inv\n    (by simp only [image_to_kernel'_kernel_subobject_iso]),\n  hom_inv_id' := begin\n    apply coequalizer.hom_ext,\n    simp only [iso.hom_inv_id_assoc, cokernel.π_desc, cokernel.π_desc_assoc, category.assoc,\n      coequalizer_as_cokernel],\n    exact (category.comp_id _).symm,\n  end,\n  inv_hom_id' := by { ext1, simp only [iso.inv_hom_id_assoc, cokernel.π_desc, category.comp_id,\n    cokernel.π_desc_assoc, category.assoc], } }\n\nvariables [has_equalizers V]\n\n/--\n`homology f g w` can be computed as the cokernel of `kernel.lift g f w`.\n-/\ndef homology_iso_cokernel_lift (w : f ≫ g = 0) :\n  homology f g w ≅ cokernel (kernel.lift g f w) :=\nbegin\n  refine homology_iso_cokernel_image_to_kernel' f g w ≪≫ _,\n  have p : factor_thru_image f ≫ image_to_kernel' f g w = kernel.lift g f w,\n  { ext, simp [image_to_kernel'], },\n  exact (cokernel_epi_comp _ _).symm ≪≫ cokernel_iso_of_eq p,\nend\n\nend image_to_kernel'\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/homology/image_to_kernel.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.46821107664664074}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sebastian Ullrich\n-/\nprelude\nimport init.control.monad init.meta.interactive\nimport init.control.state init.control.except init.control.reader init.control.option\nuniverses u v\n\nopen function\nopen tactic\n\nmeta def control_laws_tac := whnf_target >> intros >> to_expr ``(rfl) >>= exact\n\nclass is_lawful_functor (f : Type u → Type v) [functor f] : Prop :=\n(map_const_eq : ∀ {α β : Type u}, ((<$) : α → f β → f α) = (<$>) ∘ const β . control_laws_tac)\n-- `functor` is indeed a categorical functor\n(id_map       : Π {α : Type u} (x : f α), id <$> x = x)\n(comp_map     : Π {α β γ : Type u} (g : α → β) (h : β → γ) (x : f α), (h ∘ g) <$> x = h <$> g <$> x)\n\nexport is_lawful_functor (map_const_eq id_map comp_map)\nattribute [simp] id_map\n-- `comp_map` does not make a good simp lemma\n\nclass is_lawful_applicative (f : Type u → Type v) [applicative f] extends is_lawful_functor f : Prop :=\n(seq_left_eq  : ∀ {α β : Type u} (a : f α) (b : f β), a <* b = const β <$> a <*> b . control_laws_tac)\n(seq_right_eq : ∀ {α β : Type u} (a : f α) (b : f β), a *> b = const α id <$> a <*> b . control_laws_tac)\n-- applicative laws\n(pure_seq_eq_map : ∀ {α β : Type u} (g : α → β) (x : f α), pure g <*> x = g <$> x)\n(map_pure        : ∀ {α β : Type u} (g : α → β) (x : α), g <$> (pure x : f α) = pure (g x))\n(seq_pure        : ∀ {α β : Type u} (g : f (α → β)) (x : α), g <*> pure x = (λ g : α → β, g x) <$> g)\n(seq_assoc       : ∀ {α β γ : Type u} (x : f α) (g : f (α → β)) (h : f (β → γ)), h <*> (g <*> x) = (@comp α β γ <$> h) <*> g <*> x)\n-- default functor law\n(comp_map := begin intros; simp [(pure_seq_eq_map _ _).symm, seq_assoc, map_pure, seq_pure] end)\n\nexport is_lawful_applicative (seq_left_eq seq_right_eq pure_seq_eq_map map_pure seq_pure seq_assoc)\nattribute [simp] map_pure seq_pure\n\n-- applicative \"law\" derivable from other laws\n@[simp] theorem pure_id_seq {α : Type u} {f : Type u → Type v} [applicative f] [is_lawful_applicative f] (x : f α) : pure id <*> x = x :=\nby simp [pure_seq_eq_map]\n\nclass is_lawful_monad (m : Type u → Type v) [monad m] extends is_lawful_applicative m : Prop :=\n(bind_pure_comp_eq_map : ∀ {α β : Type u} (f : α → β) (x : m α), x >>= pure ∘ f = f <$> x  . control_laws_tac)\n(bind_map_eq_seq : ∀ {α β : Type u} (f : m (α → β)) (x : m α), f >>= (<$> x) = f <*> x  . control_laws_tac)\n-- monad laws\n(pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x)\n(bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ),\n  x >>= f >>= g = x >>= λ x, f x >>= g)\n(pure_seq_eq_map := by intros; rw ←bind_map_eq_seq; simp [pure_bind])\n(map_pure := by intros; rw ←bind_pure_comp_eq_map; simp [pure_bind])\n(seq_pure := by intros; rw ←bind_map_eq_seq; simp [map_pure, bind_pure_comp_eq_map])\n(seq_assoc := by intros; simp [(bind_pure_comp_eq_map _ _).symm,\n                               (bind_map_eq_seq _ _).symm,\n                               bind_assoc, pure_bind])\n\nexport is_lawful_monad (bind_pure_comp_eq_map bind_map_eq_seq pure_bind bind_assoc)\nattribute [simp] pure_bind\n\n-- monad \"law\" derivable from other laws\n@[simp] theorem bind_pure {α : Type u} {m : Type u → Type v} [monad m] [is_lawful_monad m] (x : m α) : x >>= pure = x :=\nshow x >>= pure ∘ id = x, by rw bind_pure_comp_eq_map; simp [id_map]\n\nlemma bind_ext_congr {α β} {m : Type u → Type v} [has_bind m] {x : m α} {f g : α → m β} :\n  (∀ a, f a = g a) →\n  x >>= f = x >>= g :=\nλ h, by simp [show f = g, from funext h]\n\nlemma map_ext_congr {α β} {m : Type u → Type v} [functor m] {x : m α} {f g : α → β} :\n  (∀ a, f a = g a) →\n  (f <$> x : m β) = g <$> x :=\nλ h, by simp [show f = g, from funext h]\n\n-- instances of previously defined monads\n\nnamespace id\nvariables {α β : Type}\n@[simp] lemma map_eq (x : id α) (f : α → β) : f <$> x = f x := rfl\n@[simp] lemma bind_eq (x : id α) (f : α → id β) : x >>= f = f x := rfl\n@[simp] lemma pure_eq (a : α) : (pure a : id α) = a := rfl\nend id\n\ninstance : is_lawful_monad id :=\nby refine { .. }; intros; refl\n\n\nnamespace state_t\nsection\n  variable  {σ : Type u}\n  variable  {m : Type u → Type v}\n  variables {α β : Type u}\n  variables (x : state_t σ m α) (st : σ)\n\n  lemma ext {x x' : state_t σ m α} (h : ∀ st, x.run st = x'.run st) : x = x' :=\n  by cases x; cases x'; simp [show x = x', from funext h]\n\n  variable  [monad m]\n\n  @[simp] lemma run_pure (a) : (pure a : state_t σ m α).run st = pure (a, st) := rfl\n  @[simp] lemma run_bind (f : α → state_t σ m β) :\n    (x >>= f).run st = x.run st >>= λ p, (f p.1).run p.2 :=\n  by apply bind_ext_congr; intro a; cases a; simp [state_t.bind, state_t.run]\n  @[simp] lemma run_map (f : α → β) [is_lawful_monad m] :\n    (f <$> x).run st = (λ p : α × σ, (f (prod.fst p), prod.snd p)) <$> x.run st :=\n  begin\n    rw ← bind_pure_comp_eq_map _ (x.run st),\n    change (x >>= pure ∘ f).run st = _,\n    simp\n  end\n  @[simp] \n\ninstance (m : Type u → Type v) [monad m] [is_lawful_monad m] (σ : Type u) : is_lawful_monad (state_t σ m) :=\n{ id_map := by intros; apply state_t.ext; intro; simp; erw id_map,\n  pure_bind := by { intros, apply state_t.ext, simp },\n  bind_assoc := by { intros, apply state_t.ext, simp [bind_assoc] } }\n\n\nnamespace except_t\n  variables {α β ε : Type u} {m : Type u → Type v} (x : except_t ε m α)\n\n  lemma ext {x x' : except_t ε m α} (h : x.run = x'.run) : x = x' :=\n  by cases x; cases x'; simp * at *\n\n  variable [monad m]\n\n  @[simp] lemma run_pure (a) : (pure a : except_t ε m α).run = pure (@except.ok ε α a) := rfl\n  @[simp] lemma run_bind (f : α → except_t ε m β) : (x >>= f).run = x.run >>= except_t.bind_cont f :=\n  rfl\n  @[simp] lemma run_map (f : α → β) [is_lawful_monad m] : (f <$> x).run = except.map f <$> x.run :=\n  begin\n    rw ← bind_pure_comp_eq_map _ x.run,\n    change x.run >>= except_t.bind_cont (pure ∘ f) = _,\n    apply bind_ext_congr,\n    intro a; cases a; simp [except_t.bind_cont, except.map]\n  end\n  @[simp] lemma run_monad_lift {n} [has_monad_lift_t n m] (x : n α) :\n    (monad_lift x : except_t ε m α).run = except.ok <$> (monad_lift x : m α) := rfl\n  @[simp] lemma run_monad_map {m' n n'} [monad m'] [monad_functor_t n n' m m'] (f : ∀ {α}, n α → n' α) :\n    (monad_map @f x : except_t ε m' α).run = monad_map @f x.run := rfl\nend except_t\n\ninstance (m : Type u → Type v) [monad m] [is_lawful_monad m] (ε : Type u) : is_lawful_monad (except_t ε m) :=\n{ id_map := begin\n    intros, apply except_t.ext, simp only [except_t.run_map],\n    rw [map_ext_congr, id_map],\n    intro a, cases a; refl\n  end,\n  bind_pure_comp_eq_map := begin\n    intros, apply except_t.ext, simp only [except_t.run_map, except_t.run_bind],\n    rw [bind_ext_congr, bind_pure_comp_eq_map],\n    intro a, cases a; refl\n  end,\n  bind_assoc := begin\n    intros, apply except_t.ext, simp only [except_t.run_bind, bind_assoc],\n    rw [bind_ext_congr],\n    intro a, cases a; simp [except_t.bind_cont]\n  end,\n  pure_bind := by intros; apply except_t.ext; simp [except_t.bind_cont] }\n\n\nnamespace reader_t\nsection\n  variable  {ρ : Type u}\n  variable  {m : Type u → Type v}\n  variables {α β : Type u}\n  variables (x : reader_t ρ m α) (r : ρ)\n\n  lemma ext {x x' : reader_t ρ m α} (h : ∀ r, x.run r = x'.run r) : x = x' :=\n  by cases x; cases x'; simp [show x = x', from funext h]\n\n  variable  [monad m]\n\n  @[simp] lemma run_pure (a) : (pure a : reader_t ρ m α).run r = pure a := rfl\n  @[simp] lemma run_bind (f : α → reader_t ρ m β) :\n    (x >>= f).run r = x.run r >>= λ a, (f a).run r := rfl\n  @[simp] lemma run_map (f : α → β) [is_lawful_monad m] : (f <$> x).run r = f <$> x.run r :=\n  by rw ← bind_pure_comp_eq_map _ (x.run r); refl\n  @[simp] lemma run_monad_lift {n} [has_monad_lift_t n m] (x : n α) :\n    (monad_lift x : reader_t ρ m α).run r = (monad_lift x : m α) := rfl\n  @[simp] lemma run_monad_map {m' n n'} [monad m'] [monad_functor_t n n' m m'] (f : ∀ {α}, n α → n' α) :\n    (monad_map @f x : reader_t ρ m' α).run r = monad_map @f (x.run r) := rfl\n  @[simp] lemma run_read : (reader_t.read : reader_t ρ m ρ).run r = pure r := rfl\nend\nend reader_t\n\ninstance (ρ : Type u) (m : Type u → Type v) [monad m] [is_lawful_monad m] : is_lawful_monad (reader_t ρ m) :=\n{ id_map := by intros; apply reader_t.ext; intro; simp,\n  pure_bind := by intros; apply reader_t.ext; intro; simp,\n  bind_assoc := by intros; apply reader_t.ext; intro; simp [bind_assoc] }\n\n\nnamespace option_t\n  variables {α β : Type u} {m : Type u → Type v} (x : option_t m α)\n\n  lemma ext {x x' : option_t m α} (h : x.run = x'.run) : x = x' :=\n  by cases x; cases x'; simp * at *\n\n  variable [monad m]\n\n  @[simp] lemma run_pure (a) : (pure a : option_t m α).run = pure (some a) := rfl\n  @[simp] lemma run_bind (f : α → option_t m β) : (x >>= f).run = x.run >>= option_t.bind_cont f :=\n  rfl\n  @[simp] lemma run_map (f : α → β) [is_lawful_monad m] : (f <$> x).run = option.map f <$> x.run :=\n  begin\n    rw ← bind_pure_comp_eq_map _ x.run,\n    change x.run >>= option_t.bind_cont (pure ∘ f) = _,\n    apply bind_ext_congr,\n    intro a; cases a; simp [option_t.bind_cont, option.map, option.bind]\n  end\n  @[simp] lemma run_monad_lift {n} [has_monad_lift_t n m] (x : n α) :\n    (monad_lift x : option_t m α).run = some <$> (monad_lift x : m α) := rfl\n  @[simp] lemma run_monad_map {m' n n'} [monad m'] [monad_functor_t n n' m m'] (f : ∀ {α}, n α → n' α) :\n    (monad_map @f x : option_t m' α).run = monad_map @f x.run := rfl\nend option_t\n\ninstance (m : Type u → Type v) [monad m] [is_lawful_monad m] : is_lawful_monad (option_t m) :=\n{ id_map := begin\n    intros, apply option_t.ext, simp only [option_t.run_map],\n    rw [map_ext_congr, id_map],\n    intro a, cases a; refl\n  end,\n  bind_assoc := begin\n    intros, apply option_t.ext, simp only [option_t.run_bind, bind_assoc],\n    rw [bind_ext_congr],\n    intro a, cases a; simp [option_t.bind_cont]\n  end,\n  pure_bind := by intros; apply option_t.ext; simp [option_t.bind_cont] }\n", "meta": {"author": "subfish-zhou", "repo": "N2Lean", "sha": "8e858cc5b01f1ad921094dc355db3cb9473a42fd", "save_path": "github-repos/lean/subfish-zhou-N2Lean", "path": "github-repos/lean/subfish-zhou-N2Lean/N2Lean-8e858cc5b01f1ad921094dc355db3cb9473a42fd/library/init/control/lawful.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.46816169661882806}}
{"text": "import tactic.times_table\nimport number_theory.quad_ring.basic\n\nopen polynomial\n\nopen_locale big_operators\n\n-- TODO: could generalize to infinite ι\nnoncomputable def has_mul_of_table {ι R S : Type*} [fintype ι] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis ι R S) (table : ι → ι → ι → R) :\n    has_mul S :=\n{ mul := λ x y, b.equiv_fun.symm (λ k, ∑ i j, b.repr x i * b.repr y j * table i j k) }\n\nlemma mul_def' {ι R S : Type*} [fintype ι] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis ι R S) (table : ι → ι → ι → R)\n  (x y : S) (k : ι) :\n  b.repr (by { letI := has_mul_of_table b table; exact x * y }) k = ∑ i j, b.repr x i * b.repr y j * table i j k :=\nshow b.repr (b.equiv_fun.symm (λ k, ∑ i j, b.repr x i * b.repr y j * table i j k)) k =\n  ∑ i j, b.repr x i * b.repr y j * table i j k,\nby simp only [← b.equiv_fun_apply, b.equiv_fun.apply_symm_apply]\n\nlemma mul_def {ι R S : Type*} [fintype ι] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis ι R S) (table : ι → ι → ι → R)\n  (i j k : ι) :\n  b.repr (by { letI := has_mul_of_table b table; exact b i * b j }) k = table i j k :=\nbegin\n  letI := classical.dec_eq ι,\n  rw [mul_def', fintype.sum_eq_single i, fintype.sum_eq_single j],\n  { simp },\n  { intros k hk, simp [finsupp.single_eq_of_ne hk.symm] },\n  { intros k hk, simp [finsupp.single_eq_of_ne hk.symm] },\nend\n\n-- TODO: could generalize to infinite ι\n-- See note [reducible non-instances]\n@[reducible]\nnoncomputable def non_unital_non_assoc_semiring_of_table {ι R S : Type*} [fintype ι] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis ι R S) (table : ι → ι → ι → R) :\n    non_unital_non_assoc_semiring S :=\n{ zero := 0,\n  add := (+),\n  mul := λ x y, b.equiv_fun.symm (λ k, ∑ i j, b.repr x i * b.repr y j * table i j k),\n  zero_mul := λ x, b.ext_elem (λ k, by { rw mul_def', simp only [_root_.map_zero, finsupp.zero_apply, zero_mul, finset.sum_const_zero] }),\n  mul_zero := λ x, b.ext_elem (λ k, by { rw mul_def', simp only [_root_.map_zero, finsupp.zero_apply, mul_zero, zero_mul, finset.sum_const_zero] }),\n  left_distrib := λ x y z, b.ext_elem (λ k, by { rw mul_def', simp only [_root_.map_add, finsupp.add_apply, mul_add, add_mul, finset.sum_add_distrib, ← b.equiv_fun_apply, b.equiv_fun.apply_symm_apply] }),\n  right_distrib := λ x y z, b.ext_elem (λ k, by { rw mul_def', simp only [_root_.map_add, finsupp.add_apply, mul_add, add_mul, finset.sum_add_distrib, ← b.equiv_fun_apply, b.equiv_fun.apply_symm_apply] }),\n  .. hS }\n\nnamespace sqrt_d\n\nvariables (d : ℚ)\n\ndef table : fin 2 → fin 2 → fin 2 → ℚ :=\n![![![1, 0], ![0, 1]],\n  ![![0, 1], ![d, 0]]]\n\n/-- Alternative definition of `quad_ring ℚ 0 d` -/\ndef sqrt_d (d : ℚ) := fin 2 → ℚ\n\nsection\n\nlocal attribute [semireducible] sqrt_d\n\nvariables {d}\n\ndef mk (a b : ℚ) : sqrt_d d := ![a, b]\n\nvariables (d)\n\ndef sqrt : sqrt_d d := ![0, 1]\n\ninstance : add_comm_group (sqrt_d d) := pi.add_comm_group\n\nnoncomputable instance : non_unital_non_assoc_semiring (sqrt_d d) :=\nnon_unital_non_assoc_semiring_of_table (pi.basis_fun ℚ (fin 2)) (table d)\n\ninstance : module ℚ (sqrt_d d) := pi.module _ _ _\n\nnoncomputable abbreviation basis : basis (fin 2) ℚ (sqrt_d d) := pi.basis_fun ℚ (fin 2)\n\ninstance : smul_comm_class ℚ (sqrt_d d) (sqrt_d d) :=\n⟨λ m n a, (basis d).ext_elem (λ k, by {\n  rw [smul_eq_mul, smul_eq_mul, linear_equiv.map_smul, finsupp.smul_apply, mul_def', mul_def'],\n  simp,\n  ring })⟩\n\ninstance : is_scalar_tower ℚ (sqrt_d d) (sqrt_d d) :=\n⟨λ m n a, (basis d).ext_elem (λ k, by {\n  rw [smul_eq_mul, smul_eq_mul, linear_equiv.map_smul, finsupp.smul_apply, mul_def', mul_def'],\n  simp,\n  ring })⟩\n\nnoncomputable def times_table : times_table (fin 2) ℚ (sqrt_d d) :=\n{ basis := by convert pi.basis_fun ℚ (fin 2),\n  table := table d,\n  unfold_mul' := sorry }\n\nend\n\n@[times_table_simps] lemma table_apply (i j k : fin 2) :\n  (sqrt_d.times_table d).table i j k =\n  ![![![1, 0], ![0, 1]],\n    ![![0, 1], ![d, 0]]] i j k := rfl\n\n@[times_table_simps] lemma coord_mk (a b : ℚ) (i : fin 2) :\n  (sqrt_d.times_table d).coord (mk a b) i = ![a, b] i :=\nrfl\n\nvariables {d}\n\n@[elab_as_eliminator]\nlemma cases (x : sqrt_d d) {p : sqrt_d d → Prop} (h : p (mk (x 0) (x 1))) :\n  p x :=\nsorry\n\nset_option profiler true\n\n-- 600ms\nlemma mul_comm' (x y : quad_ring ℚ 0 d) : x * y = y * x :=\nby quad_ring.calc_tac\n\n-- 1s\nlemma mul_comm (x y : sqrt_d d) : x * y = y * x :=\nbegin\n  refine cases x _, refine cases y _,\n  apply (sqrt_d.times_table d).ext (λ k, _),\n  fin_cases k; times_table,\nend\n\n-- 1.3s\nlemma mul_assoc' (x y z : quad_ring ℚ 0 d) : x * y * z = x * (y * z) :=\nby quad_ring.calc_tac\n\n-- 2.5s\nlemma mul_assoc (x y z : sqrt_d d) : x * y * z = x * (y * z) :=\nbegin\n  refine cases x _, refine cases y _, refine cases z _,\n  apply (sqrt_d.times_table d).ext (λ k, _),\n  fin_cases k; times_table,\nend\n\ninstance : has_one (sqrt_d d) := ⟨![1, 0]⟩\n\n@[times_table_simps] lemma coord_one : (sqrt_d.times_table d).coord 1 = ![1, 0] := rfl\n\nnoncomputable instance : comm_semiring (sqrt_d d) :=\n{ one := 1,\n  mul_assoc := mul_assoc,\n  mul_comm := mul_comm,\n  one_mul := λ x, cases x ((sqrt_d.times_table d).ext (λ k, by fin_cases k; times_table)),\n  mul_one := λ x, cases x ((sqrt_d.times_table d).ext (λ k, by fin_cases k; times_table)),\n  .. sqrt_d.non_unital_non_assoc_semiring d }\n\nnoncomputable instance : comm_ring (sqrt_d d) :=\n{ .. sqrt_d.add_comm_group d, .. sqrt_d.comm_semiring }\n\nsection\nset_option profiler true\n\n-- calc_tac with a bit of help: 18s\nlemma quad_ring.pow_three_sub_pow_three (x y : quad_ring ℚ 0 d) :\n  x^3 - y^3 = (x - y) * (x^2 + x * y + y^2) :=\nby { refine quad_ring.ext _ _ _ _; simp [pow_succ]; ring_nf }\n\n-- times_table: 28s\nlemma times_table.pow_three_sub_pow_three (x y : sqrt_d d) :\n  x^3 - y^3 = (x - y) * (x^2 + x * y + y^2) :=\nbegin\n  refine cases x _, refine cases y _,\n  apply (sqrt_d.times_table d).ext (λ k, _),\n  fin_cases k; times_table\nend\n\n-- calc_tac with a bit of help: 62.9s\nlemma quad_ring.pow_four_sub_pow_four (x y : quad_ring ℚ 0 d) :\n  x^4 - y^4 = (x - y) * (x^3 + x^2 * y + x * y^2 + y^3) :=\nby { refine quad_ring.ext _ _ _ _; simp [pow_succ]; ring_nf }\n\n-- times_table: 108s\nlemma times_table.pow_four_sub_pow_four (x y : sqrt_d d) :\n  x^4 - y^4 = (x - y) * (x^3 + x^2 * y + x * y^2 + y^3) :=\nbegin\n  refine cases x _, refine cases y _,\n  apply (sqrt_d.times_table d).ext (λ k, _),\n  fin_cases k; times_table\nend\n\nend\n\n\nend sqrt_d\n\n#exit\n\n-- Define a new structure\n-- Might just as well have been a synonym for `adjoin_root (X^2 - 3 : (adjoin_root (X^2 - 2))[X]),\n-- but this shows off the general design.\n@[ext]\nstructure sqrt_2_sqrt_3 :=\n(a b c d : ℚ)\n\nnamespace sqrt_2_sqrt_3\n\ninstance : add_comm_group sqrt_2_sqrt_3 :=\n{ zero := ⟨0, 0, 0, 0⟩,\n  add := λ x y, ⟨x.a + y.a, x.b + y.b, x.c + y.c, x.d + y.d⟩,\n  add_comm := λ x y, by { ext : 1; apply add_comm },\n  add_zero := λ x, by { ext : 1; apply add_zero },\n  zero_add := λ x, by { ext : 1; apply zero_add },\n  add_assoc := λ x y z, by { ext : 1; apply add_assoc },\n  neg := λ x, ⟨-x.a, -x.b, -x.c, -x.d⟩,\n  add_left_neg := λ x, by { ext : 1; apply add_left_neg },\n  sub := λ x y, ⟨x.a - y.a, x.b - y.b, x.c - y.c, x.d - y.d⟩ }\n\n.\n\ninstance : module ℚ sqrt_2_sqrt_3 :=\n{ smul := λ c x, ⟨c * x.a, c * x.b, c * x.c, c * x.d⟩,\n  add_smul := λ c d x, by { ext : 1; apply add_mul },\n  smul_add := λ c x y, by { ext : 1; apply mul_add },\n  mul_smul := λ c d x, by { ext : 1; apply mul_assoc },\n  one_smul := λ x, by { ext : 1; apply one_mul },\n  smul_zero := λ c, by { ext : 1; apply mul_zero },\n  zero_smul := λ x, by { ext : 1; apply zero_mul } }\n\nnoncomputable def basis : basis (fin 4) ℚ sqrt_2_sqrt_3 :=\nbasis.of_equiv_fun $\n{ to_fun := λ x, ![x.a, x.b, x.c, x.d],\n  inv_fun := λ x, ⟨x 0, x 1, x 2, x 3⟩,\n  left_inv := λ ⟨a, b, c, d⟩, rfl,\n  right_inv := λ x, by { ext i : 1, fin_cases i; simp },\n  map_add' := λ ⟨a, b, c, d⟩ ⟨a', b', c', d'⟩, by { ext i : 1, fin_cases i; refl },\n  map_smul' := λ r ⟨a, b, c, d⟩, by { ext i : 1, fin_cases i; refl } }\n\ndef table : fin 4 → fin 4 → fin 4 → ℚ :=\n![![![1, 0, 0, 0], ![0, 1, 0, 0], ![0, 0, 1, 0], ![0, 0, 0, 1]],\n  ![![0, 1, 0, 0], ![2, 0, 0, 0], ![0, 0, 0, 1], ![0, 0, 2, 0]],\n  ![![0, 0, 1, 0], ![0, 0, 0, 1], ![3, 0, 0, 0], ![0, 3, 0, 0]],\n  ![![0, 0, 0, 1], ![0, 0, 2, 0], ![0, 3, 0, 0], ![6, 0, 0, 0]]]\n\nnoncomputable def mul : sqrt_2_sqrt_3 →ₗ[ℚ] sqrt_2_sqrt_3 →ₗ[ℚ] sqrt_2_sqrt_3 :=\nsqrt_2_sqrt_3.basis.constr ℚ $ λ i,\nsqrt_2_sqrt_3.basis.constr ℚ $ λ j,\nsqrt_2_sqrt_3.basis.equiv_fun.symm (table i j)\n\nnoncomputable instance : has_mul sqrt_2_sqrt_3 :=\n{ mul := λ x y, mul x y }\n\ninstance : has_one sqrt_2_sqrt_3 :=\n⟨⟨1, 0, 0, 0⟩⟩\n\n@[simp] lemma sqrt_2_sqrt_3.basis_repr (x : sqrt_2_sqrt_3) :\n  ⇑(sqrt_2_sqrt_3.basis.repr x) = ![x.a, x.b, x.c, x.d] :=\nrfl\n\nnoncomputable def sqrt_2_sqrt_3.times_table : times_table (fin 4) ℚ sqrt_2_sqrt_3 :=\n{ basis := sqrt_2_sqrt_3.basis,\n  table := sqrt_2_sqrt_3.table,\n  unfold_mul' := sorry }\n\n@[simp, times_table_simps] -- TODO: get rid of `@[simp]`\nlemma sqrt_2_sqrt_3.times_table_apply (i j k : fin 4) :\n  sqrt_2_sqrt_3.times_table.table i j k =\n  ![![![1, 0, 0, 0], ![0, 1, 0, 0], ![0, 0, 1, 0], ![0, 0, 0, 1]],\n    ![![0, 1, 0, 0], ![2, 0, 0, 0], ![0, 0, 0, 1], ![0, 0, 2, 0]],\n    ![![0, 0, 1, 0], ![0, 0, 0, 1], ![3, 0, 0, 0], ![0, 3, 0, 0]],\n    ![![0, 0, 0, 1], ![0, 0, 2, 0], ![0, 3, 0, 0], ![6, 0, 0, 0]]] i j k :=\nrfl\n\n@[times_table_simps] lemma coord_one (i : fin 4) :\n  sqrt_2_sqrt_3.times_table.coord 1 i = ![1, 0, 0, 0] i := rfl\n\n\n@[simp, times_table_simps] lemma coord_mk (a b c d : ℚ) (i : fin 4) :\n  sqrt_2_sqrt_3.times_table.coord ⟨a, b, c, d⟩ i = ![a, b, c, d] i := rfl\n\ndef sqrt_2 : sqrt_2_sqrt_3 := ⟨0, 1, 0, 0⟩\n@[times_table_simps] lemma coord_sqrt_2 (i : fin 4) :\n  sqrt_2_sqrt_3.times_table.coord sqrt_2 i = ![0, 1, 0, 0] i := rfl\n\ndef sqrt_3 : sqrt_2_sqrt_3 := ⟨0, 0, 1, 0⟩\n@[times_table_simps] lemma coord_sqrt_3 (i : fin 4) :\n  sqrt_2_sqrt_3.times_table.coord sqrt_3 i = ![0, 0, 1, 0] i := rfl\n\n@[simp]\nlemma finsupp.bit0_apply {α M : Type*} [add_monoid M] (f : α →₀ M) (i : α) : (bit0 f) i = bit0 (f i) := rfl\n\nend sqrt_2_sqrt_3\nnamespace sqrt_2_sqrt_3\n\n-- set_option trace.type_context.is_def_eq_detail true\n-- set_option trace.class_instances true\n\nprotected lemma mul_comm (x y : sqrt_2_sqrt_3) : x * y = y * x :=\nbegin\n  cases x, cases y,\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table\nend\n\nprotected lemma mul_assoc (x y z : sqrt_2_sqrt_3) : x * y * z = x * (y * z) :=\nbegin\n  cases x, cases y, cases z,\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table\nend\n\nprotected lemma left_distrib (x y z : sqrt_2_sqrt_3) : x * (y + z) = x * y + x * z :=\nbegin\n  cases x, cases y, cases z,\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table\nend\n\nprotected lemma right_distrib (x y z : sqrt_2_sqrt_3) : (x + y) * z = x * z + y * z :=\nbegin\n  cases x, cases y, cases z,\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table\nend\n\nnoncomputable instance : comm_ring sqrt_2_sqrt_3 :=\n{ add := (+),\n  zero := 0,\n  mul := (*),\n  one := 1,\n  neg := has_neg.neg,\n  one_mul := λ x, by { cases x, apply sqrt_2_sqrt_3.times_table.ext (λ k, _), fin_cases k; times_table },\n  mul_one := λ x, by { cases x, apply sqrt_2_sqrt_3.times_table.ext (λ k, _), fin_cases k; times_table },\n  left_distrib := sqrt_2_sqrt_3.left_distrib,\n  right_distrib := sqrt_2_sqrt_3.right_distrib,\n  mul_comm := sqrt_2_sqrt_3.mul_comm,\n  mul_assoc := sqrt_2_sqrt_3.mul_assoc,\n  .. sqrt_2_sqrt_3.add_comm_group }\n\n-- Here's a concrete example of an equation that `times_table_tac` can solve\nlemma eq₁ : (sqrt_2 + sqrt_3)^3 - 9 * (sqrt_2 + sqrt_3) = 2 * sqrt_2 :=\nbegin\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table,\nend\n\nlemma eq₂ (x y : sqrt_2_sqrt_3) : (x - y) * (x^2 + x * y + y^2) = x^3 - y^3 :=\nbegin\n  cases x, cases y,\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table\nend\n\n@[times_table_simps] lemma coord_coe_int {a : ℤ} (k : fin 4) :\n  sqrt_2_sqrt_3.times_table.coord ↑a k = ![a, 0, 0, 0] k :=\nsorry\n\nexample (a b : sqrt_2_sqrt_3) : a + -b = a - b :=\nbegin\n  cases a, cases b,\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table,\nend\n\n-- More equations to solve\nexample (a b : ℤ) : (a + b * sqrt_2 : sqrt_2_sqrt_3) * (a - b * sqrt_2) = a^2 - 2 * b^2 :=\nbegin\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table,\nend\n\n-- More equations to solve\nexample (a b c d : ℤ) :\n  (a + b * sqrt_2 + c * sqrt_3 + d * sqrt_2 * sqrt_3 : sqrt_2_sqrt_3) *\n  (a - b * sqrt_2 + c * sqrt_3 - d * sqrt_2 * sqrt_3 : sqrt_2_sqrt_3) *\n  (a + b * sqrt_2 - c * sqrt_3 - d * sqrt_2 * sqrt_3 : sqrt_2_sqrt_3) *\n  (a - b * sqrt_2 - c * sqrt_3 + d * sqrt_2 * sqrt_3 : sqrt_2_sqrt_3) =\n  a^4 - 4*a^2*b^2 + 4*b^4 - 6*a^2*c^2 - 12*b^2*c^2 + 9*c^4 + 48 * a * b * c  *d - 12*a^2*d^2 -\n    24*b^2*d^2 - 36*c^2*d^2 + 36*d^4 :=\nbegin\n  apply sqrt_2_sqrt_3.times_table.ext (λ k, _),\n  fin_cases k; times_table,\nend\n\nend sqrt_2_sqrt_3\n", "meta": {"author": "lean-forward", "repo": "class-group-and-mordell-equation", "sha": "baba2049f3bfe4d2cc184f8205997333e7c58638", "save_path": "github-repos/lean/lean-forward-class-group-and-mordell-equation", "path": "github-repos/lean/lean-forward-class-group-and-mordell-equation/class-group-and-mordell-equation-baba2049f3bfe4d2cc184f8205997333e7c58638/test/times_table.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4681426590381211}}
{"text": "import Smt\n\ntheorem prop_ext (p q : Prop) : (p ↔ q) → p = q := by\n  smt\n  simp_all\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Test/Prop/PropExt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929002541067, "lm_q2_score": 0.6001883592602049, "lm_q1q2_score": 0.46814265903812097}}
{"text": "universe u\n\nexample (α : Type u) (a b : α) (p : α → Prop) (h1 : a = b) (h2 : p a) : p b :=\n  eq.subst h1 h2\n\nexample (α : Type u) (a b : α) (p : α → Prop) (h1 : a = b) (h2 : p a) : p b :=\n  h1 ▸ h2\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch4/ex0207.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.6001883592602051, "lm_q1q2_score": 0.468142652899158}}
{"text": "/-\nCopyright (c) 2020 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.calculus.mean_value\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# L'Hôpital's rule for 0/0 indeterminate forms\n\nIn this file, we prove several forms of \"L'Hopital's rule\" for computing 0/0\nindeterminate forms. The proof of `has_deriv_at.lhopital_zero_right_on_Ioo`\nis based on the one given in the corresponding\n[Wikibooks](https://en.wikibooks.org/wiki/Calculus/L%27H%C3%B4pital%27s_Rule)\nchapter, and all other statements are derived from this one by composing by\ncarefully chosen functions.\n\nNote that the filter `f'/g'` tends to isn't required to be one of `𝓝 a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `ℝ`.\n\nEach statement is available in a `has_deriv_at` form and a `deriv` form, which\nis denoted by each statement being in either the `has_deriv_at` or the `deriv`\nnamespace.\n-/\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' ≠ 0`) have\nto be satisfied on an explicitely-provided interval.\n-/\n\nnamespace has_deriv_at\n\n\ntheorem lhopital_zero_right_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x) (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0) (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_right_on_Ico {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x) (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x) (hcf : continuous_on f (set.Ico a b)) (hcg : continuous_on g (set.Ico a b)) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0) (hfa : f a = 0) (hga : g a = 0) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x) (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0) (hfb : filter.tendsto f (nhds_within b (set.Iio b)) (nhds 0)) (hgb : filter.tendsto g (nhds_within b (set.Iio b)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within b (set.Iio b)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within b (set.Iio b)) l := sorry\n\ntheorem lhopital_zero_left_on_Ioc {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at f (f' x) x) (hgg' : ∀ (x : ℝ), x ∈ set.Ioo a b → has_deriv_at g (g' x) x) (hcf : continuous_on f (set.Ioc a b)) (hcg : continuous_on g (set.Ioc a b)) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → g' x ≠ 0) (hfb : f b = 0) (hgb : g b = 0) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within b (set.Iio b)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within b (set.Iio b)) l := sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Ioi a → has_deriv_at f (f' x) x) (hgg' : ∀ (x : ℝ), x ∈ set.Ioi a → has_deriv_at g (g' x) x) (hg' : ∀ (x : ℝ), x ∈ set.Ioi a → g' x ≠ 0) (hftop : filter.tendsto f filter.at_top (nhds 0)) (hgtop : filter.tendsto g filter.at_top (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_top l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l := sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : ∀ (x : ℝ), x ∈ set.Iio a → has_deriv_at f (f' x) x) (hgg' : ∀ (x : ℝ), x ∈ set.Iio a → has_deriv_at g (g' x) x) (hg' : ∀ (x : ℝ), x ∈ set.Iio a → g' x ≠ 0) (hfbot : filter.tendsto f filter.at_bot (nhds 0)) (hgbot : filter.tendsto g filter.at_bot (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_bot l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l := sorry\n\nend has_deriv_at\n\n\nnamespace deriv\n\n\ntheorem lhopital_zero_right_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Ioo a b)) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → deriv g x ≠ 0) (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_right_on_Ico {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Ioo a b)) (hcf : continuous_on f (set.Ico a b)) (hcg : continuous_on g (set.Ico a b)) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → deriv g x ≠ 0) (hfa : f a = 0) (hga : g a = 0) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : ℝ} {b : ℝ} (hab : a < b) {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Ioo a b)) (hg' : ∀ (x : ℝ), x ∈ set.Ioo a b → deriv g x ≠ 0) (hfb : filter.tendsto f (nhds_within b (set.Iio b)) (nhds 0)) (hgb : filter.tendsto g (nhds_within b (set.Iio b)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within b (set.Iio b)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within b (set.Iio b)) l := sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Ioi a)) (hg' : ∀ (x : ℝ), x ∈ set.Ioi a → deriv g x ≠ 0) (hftop : filter.tendsto f filter.at_top (nhds 0)) (hgtop : filter.tendsto g filter.at_top (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_top l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l := sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : differentiable_on ℝ f (set.Iio a)) (hg' : ∀ (x : ℝ), x ∈ set.Iio a → deriv g x ≠ 0) (hfbot : filter.tendsto f filter.at_bot (nhds 0)) (hgbot : filter.tendsto g filter.at_bot (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_bot l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l := sorry\n\nend deriv\n\n\n/-!\n## Generic versions\n\nThe following statements no longer any explicit interval, as they only require\nconditions holding eventually.\n-/\n\nnamespace has_deriv_at\n\n\n/-- L'Hôpital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) (nhds_within a (set.Ioi a))) (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) (nhds_within a (set.Ioi a))) (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds_within a (set.Ioi a))) (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\n/-- L'Hôpital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) (nhds_within a (set.Iio a))) (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) (nhds_within a (set.Iio a))) (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds_within a (set.Iio a))) (hfa : filter.tendsto f (nhds_within a (set.Iio a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.Iio a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.Iio a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Iio a)) l := sorry\n\n/-- L'Hôpital's rule for approaching a real, `has_deriv_at` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds' {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) (nhds_within a (set.univ \\ singleton a))) (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) (nhds_within a (set.univ \\ singleton a))) (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds_within a (set.univ \\ singleton a))) (hfa : filter.tendsto f (nhds_within a (set.univ \\ singleton a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.univ \\ singleton a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds_within a (set.univ \\ singleton a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l := sorry\n\n/-- L'Hôpital's rule for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) (nhds a)) (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) (nhds a)) (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) (nhds a)) (hfa : filter.tendsto f (nhds a) (nhds 0)) (hga : filter.tendsto g (nhds a) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) (nhds a) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  lhopital_zero_nhds' (eventually_nhds_within_of_eventually_nhds hff') (eventually_nhds_within_of_eventually_nhds hgg')\n    (eventually_nhds_within_of_eventually_nhds hg') (tendsto_nhds_within_of_tendsto_nhds hfa)\n    (tendsto_nhds_within_of_tendsto_nhds hga) (tendsto_nhds_within_of_tendsto_nhds hdiv)\n\n/-- L'Hôpital's rule for approaching +∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) filter.at_top) (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) filter.at_top) (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) filter.at_top) (hftop : filter.tendsto f filter.at_top (nhds 0)) (hgtop : filter.tendsto g filter.at_top (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_top l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l := sorry\n\n/-- L'Hôpital's rule for approaching -∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot {l : filter ℝ} {f : ℝ → ℝ} {f' : ℝ → ℝ} {g : ℝ → ℝ} {g' : ℝ → ℝ} (hff' : filter.eventually (fun (x : ℝ) => has_deriv_at f (f' x) x) filter.at_bot) (hgg' : filter.eventually (fun (x : ℝ) => has_deriv_at g (g' x) x) filter.at_bot) (hg' : filter.eventually (fun (x : ℝ) => g' x ≠ 0) filter.at_bot) (hfbot : filter.tendsto f filter.at_bot (nhds 0)) (hgbot : filter.tendsto g filter.at_bot (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => f' x / g' x) filter.at_bot l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l := sorry\n\nend has_deriv_at\n\n\nnamespace deriv\n\n\n/-- L'Hôpital's rule for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) (nhds_within a (set.Ioi a))) (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds_within a (set.Ioi a))) (hfa : filter.tendsto f (nhds_within a (set.Ioi a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.Ioi a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\n/-- L'Hôpital's rule for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) (nhds_within a (set.Iio a))) (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds_within a (set.Iio a))) (hfa : filter.tendsto f (nhds_within a (set.Iio a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.Iio a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.Iio a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.Iio a)) l := sorry\n\n/-- L'Hôpital's rule for approaching a real, `deriv` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds' {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) (nhds_within a (set.univ \\ singleton a))) (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds_within a (set.univ \\ singleton a))) (hfa : filter.tendsto f (nhds_within a (set.univ \\ singleton a)) (nhds 0)) (hga : filter.tendsto g (nhds_within a (set.univ \\ singleton a)) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds_within a (set.univ \\ singleton a)) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l := sorry\n\n/-- L'Hôpital's rule for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds {a : ℝ} {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) (nhds a)) (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) (nhds a)) (hfa : filter.tendsto f (nhds a) (nhds 0)) (hga : filter.tendsto g (nhds a) (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) (nhds a) l) : filter.tendsto (fun (x : ℝ) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  lhopital_zero_nhds' (eventually_nhds_within_of_eventually_nhds hdf) (eventually_nhds_within_of_eventually_nhds hg')\n    (tendsto_nhds_within_of_tendsto_nhds hfa) (tendsto_nhds_within_of_tendsto_nhds hga)\n    (tendsto_nhds_within_of_tendsto_nhds hdiv)\n\n/-- L'Hôpital's rule for approaching +∞, `deriv` version -/\ntheorem lhopital_zero_at_top {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) filter.at_top) (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) filter.at_top) (hftop : filter.tendsto f filter.at_top (nhds 0)) (hgtop : filter.tendsto g filter.at_top (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_top l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_top l := sorry\n\n/-- L'Hôpital's rule for approaching -∞, `deriv` version -/\ntheorem lhopital_zero_at_bot {l : filter ℝ} {f : ℝ → ℝ} {g : ℝ → ℝ} (hdf : filter.eventually (fun (x : ℝ) => differentiable_at ℝ f x) filter.at_bot) (hg' : filter.eventually (fun (x : ℝ) => deriv g x ≠ 0) filter.at_bot) (hfbot : filter.tendsto f filter.at_bot (nhds 0)) (hgbot : filter.tendsto g filter.at_bot (nhds 0)) (hdiv : filter.tendsto (fun (x : ℝ) => deriv f x / deriv g x) filter.at_bot l) : filter.tendsto (fun (x : ℝ) => f x / g x) filter.at_bot l := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/calculus/lhopital.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.46809724371790873}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.big_operators.pi\nimport Mathlib.data.finsupp.default\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_4 u_3 u_5 u_6 \n\nnamespace Mathlib\n\n/-!\n# Big operators for finsupps\n\nThis file contains theorems relevant to big operators in finitely supported functions.\n-/\n\ntheorem finset.sum_apply' {α : Type u_1} {ι : Type u_2} {A : Type u_4} [add_comm_monoid A] {s : finset α} {f : α → ι →₀ A} (i : ι) : coe_fn (finset.sum s fun (k : α) => f k) i = finset.sum s fun (k : α) => coe_fn (f k) i :=\n  Eq.symm (finset.sum_hom s ⇑(finsupp.apply_add_hom i))\n\ntheorem finsupp.sum_apply' {ι : Type u_2} {γ : Type u_3} {A : Type u_4} {B : Type u_5} [add_comm_monoid A] [add_comm_monoid B] (g : ι →₀ A) (k : ι → A → γ → B) (x : γ) : finsupp.sum g k x = finsupp.sum g fun (i : ι) (b : A) => k i b x :=\n  finset.sum_apply x (finsupp.support g) fun (a : ι) => k a (coe_fn g a)\n\ntheorem finsupp.sum_sum_index' {α : Type u_1} {ι : Type u_2} {A : Type u_4} {C : Type u_6} [add_comm_monoid A] [add_comm_monoid C] {t : ι → A → C} (h0 : ∀ (i : ι), t i 0 = 0) (h1 : ∀ (i : ι) (x y : A), t i (x + y) = t i x + t i y) {s : finset α} {f : α → ι →₀ A} : finsupp.sum (finset.sum s fun (x : α) => f x) t = finset.sum s fun (x : α) => finsupp.sum (f x) t := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/big_operators/finsupp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.46806293766953516}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monoidal.natural_transformation\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ \n\nnamespace Mathlib\n\n/-!\n# Transport a monoidal structure along an equivalence.\n\nWhen `C` and `D` are equivalent as categories,\nwe can transport a monoidal structure on `C` along the equivalence,\nobtaining a monoidal structure on `D`.\n\nWe don't yet prove anything about this transported structure!\nThe next step would be to show that the original functor can be upgraded\nto a monoidal functor with respect to this new structure.\n-/\n\nnamespace category_theory.monoidal\n\n\n/--\nTransport a monoidal structure along an equivalence of (plain) categories.\n-/\n@[simp] theorem transport_tensor_unit {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂}\n    [category D] (e : C ≌ D) : 𝟙_ = functor.obj (equivalence.functor e) 𝟙_ :=\n  Eq.refl 𝟙_\n\n/-- A type synonym for `D`, which will carry the transported monoidal structure. -/\ndef transported {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂} [category D]\n    (e : C ≌ D) :=\n  D\n\nprotected instance transported.category_theory.monoidal_category {C : Type u₁} [category C]\n    [monoidal_category C] {D : Type u₂} [category D] (e : C ≌ D) :\n    monoidal_category (transported e) :=\n  transport e\n\nprotected instance transported.inhabited {C : Type u₁} [category C] [monoidal_category C]\n    {D : Type u₂} [category D] (e : C ≌ D) : Inhabited (transported e) :=\n  { default := 𝟙_ }\n\n/--\nWe can upgrade `e.functor` to a lax monoidal functor from `C` to `D` with the transported structure.\n-/\n@[simp] theorem lax_to_transported_to_functor_map {C : Type u₁} [category C] [monoidal_category C]\n    {D : Type u₂} [category D] (e : C ≌ D) {X : C} {Y : C} :\n    ∀ (ᾰ : X ⟶ Y),\n        functor.map (lax_monoidal_functor.to_functor (lax_to_transported e)) ᾰ =\n          functor.map (equivalence.functor e) ᾰ :=\n  fun (ᾰ : X ⟶ Y) =>\n    Eq.refl (functor.map (lax_monoidal_functor.to_functor (lax_to_transported e)) ᾰ)\n\n/--\nWe can upgrade `e.functor` to a monoidal functor from `C` to `D` with the transported structure.\n-/\n@[simp] theorem to_transported_ε_is_iso {C : Type u₁} [category C] [monoidal_category C]\n    {D : Type u₂} [category D] (e : C ≌ D) :\n    monoidal_functor.ε_is_iso (to_transported e) =\n        id (is_iso.id (functor.obj (equivalence.functor e) 𝟙_)) :=\n  Eq.refl (monoidal_functor.ε_is_iso (to_transported e))\n\n/--\nWe can upgrade `e.inverse` to a lax monoidal functor from `D` with the transported structure to `C`.\n-/\ndef lax_from_transported {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂} [category D]\n    (e : C ≌ D) : lax_monoidal_functor (transported e) C :=\n  lax_monoidal_functor.mk\n    (functor.mk (functor.obj (equivalence.inverse e)) (functor.map (equivalence.inverse e)))\n    (nat_trans.app (equivalence.unit e) 𝟙_)\n    fun (X Y : transported e) =>\n      nat_trans.app (equivalence.unit e)\n        (functor.obj (equivalence.inverse e) X ⊗ functor.obj (equivalence.inverse e) Y)\n\n/--\nWe can upgrade `e.inverse` to a monoidal functor from `D` with the transported structure to `C`.\n-/\ndef from_transported {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂} [category D]\n    (e : C ≌ D) : monoidal_functor (transported e) C :=\n  monoidal_functor.mk\n    (lax_monoidal_functor.mk (lax_monoidal_functor.to_functor (lax_from_transported e))\n      (lax_monoidal_functor.ε (lax_from_transported e))\n      (lax_monoidal_functor.μ (lax_from_transported e)))\n\n/-- The unit isomorphism upgrades to a monoidal isomorphism. -/\ndef transported_monoidal_unit_iso {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂}\n    [category D] (e : C ≌ D) :\n    lax_monoidal_functor.id C ≅ lax_to_transported e ⊗⋙ lax_from_transported e :=\n  monoidal_nat_iso.of_components (fun (X : C) => iso.app (equivalence.unit_iso e) X) sorry sorry\n    sorry\n\n/-- The counit isomorphism upgrades to a monoidal isomorphism. -/\n@[simp] theorem transported_monoidal_counit_iso_hom_to_nat_trans_app {C : Type u₁} [category C]\n    [monoidal_category C] {D : Type u₂} [category D] (e : C ≌ D) (X : transported e) :\n    nat_trans.app (monoidal_nat_trans.to_nat_trans (iso.hom (transported_monoidal_counit_iso e)))\n          X =\n        nat_trans.app (iso.hom (equivalence.counit_iso e)) X :=\n  Eq.refl (nat_trans.app (iso.hom (equivalence.counit_iso e)) X)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/transport_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6926419767901476, "lm_q1q2_score": 0.4680629290946385}}
{"text": "/-\nCopyright (c) 2022 Henrik Böving. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henrik Böving, Simon Hudon\n-/\nimport LSpec.SlimCheck.Gen\n\n/-!\n# `SampleableExt` Class\nThis class permits the creation samples of a given type\ncontrolling the size of those values using the `Gen` monad`.\n# `Shrinkable` Class\nThis class helps minimize examples by creating smaller versions of\ngiven values.\nWhen testing a proposition like `∀ n : ℕ, prime n → n ≤ 100`,\n`SlimCheck` requires that `ℕ` have an instance of `SampleableExt` and for\n`prime n` to be decidable.  `SlimCheck` will then use the instance of\n`SampleableExt` to generate small examples of ℕ and progressively increase\nin size. For each example `n`, `prime n` is tested. If it is false,\nthe example will be rejected (not a test success nor a failure) and\n`SlimCheck` will move on to other examples. If `prime n` is true, `n\n≤ 100` will be tested. If it is false, `n` is a counter-example of `∀\nn : ℕ, prime n → n ≤ 100` and the test fails. If `n ≤ 100` is true,\nthe test passes and `SlimCheck` moves on to trying more examples.\nThis is a port of the Haskell QuickCheck library.\n## Main definitions\n  * `SampleableExt` class\n  * `Shrinkable` class\n### `SampleableExt`\n`SampleableExt` can be used in two ways. The first (and most common)\nis to simply generate values of a type directly using the `Gen` monad,\nif this is what you want to do then `SampleableExt.mkSelfContained` is\nthe way to go.\nFurthermore it makes it possible to express generators for types that\ndo not lend themselves to introspection, such as `ℕ → ℕ`.\nIf we test a quantification over functions the\ncounter-examples cannot be shrunken or printed meaningfully.\nFor that purpose, `SampleableExt` provides a proxy representation\n`proxy` that can be printed and shrunken as well\nas interpreted (using `interp`) as an object of the right type. If you\nare using it in the first way, this proxy type will simply be the type\nitself and the `interp` function `id`.\n### `Shrinkable\nGiven an example `x : α`, `Shrinkable α` gives us a way to shrink it\nand suggest simpler examples.\n## Shrinking\nShrinking happens when `SlimCheck` find a counter-example to a\nproperty.  It is likely that the example will be more complicated than\nnecessary so `SlimCheck` proceeds to shrink it as much as\npossible. Although equally valid, a smaller counter-example is easier\nfor a user to understand and use.\nThe `Shrinkable` class, , has a `shrink` function so that we can use\nspecialized knowledge while shrinking a value. It is not responsible\nfor the whole shrinking process however. It only has to take one step\nin the shrinking process. `SlimCheck` will repeatedly call `shrink`\nuntil no more steps can be taken. Because `shrink` guarantees that the\nsize of the candidates it produces is strictly smaller than the\nargument, we know that `SlimCheck` is guaranteed to terminate.\n## Tags\nrandom testing\n## References\n  * https://hackage.haskell.org/package/QuickCheck\n-/\n\nnamespace SlimCheck\n\nopen Random\n\n/-- Given an example `x : α`, `Shrinkable α` gives us a way to shrink it\nand suggest simpler examples. -/\nclass Shrinkable (α : Type u) extends WellFoundedRelation α where\n  shrink : (x : α) → List α := λ _ => []\n\n/-- `SampleableExt` can be used in two ways. The first (and most common)\nis to simply generate values of a type directly using the `Gen` monad,\nif this is what you want to do then `SampleableExt.mkSelfContained` is\nthe way to go.\nFurthermore it makes it possible to express generators for types that\ndo not lend themselves to introspection, such as `ℕ → ℕ`.\nIf we test a quantification over functions the\ncounter-examples cannot be shrunken or printed meaningfully.\nFor that purpose, `SampleableExt` provides a proxy representation\n`proxy` that can be printed and shrunken as well\nas interpreted (using `interp`) as an object of the right type. -/\nclass SampleableExt (α : Sort u) where\n  proxy : Type v\n  [proxyRepr : Repr proxy]\n  [shrink : Shrinkable proxy]\n  sample : Gen proxy\n  interp : proxy → α\n\nattribute [instance] SampleableExt.proxyRepr\nattribute [instance] SampleableExt.shrink\n\nnamespace SampleableExt\n\n/-- Use to generate instance whose purpose is to simply generate values\nof a type directly using the `Gen` monad -/\ndef mkSelfContained [Repr α] [Shrinkable α] (sample : Gen α) : SampleableExt α where\n  proxy := α\n  proxyRepr := inferInstance\n  shrink := inferInstance\n  sample := sample\n  interp := id\n\n/-- First samples a proxy value and interprets it. Especially useful if\nthe proxy and target type are the same. -/\ndef interpSample (α : Type u) [SampleableExt α] : Gen α := SampleableExt.interp <$> SampleableExt.sample\n\nend SampleableExt\n\nsection Shrinkers\n\n/-- `Nat.shrink' n` creates a list of smaller natural numbers by\nsuccessively dividing `n` by 2 . For example, `Nat.shrink 5 = [2, 1, 0]`. -/\npartial def Nat.shrink (n : Nat) : List Nat :=\n  if 0 < n then\n    let m := n / 2\n    let rest := shrink m\n    m :: rest\n  else\n    []\n\ninstance Nat.shrinkable : Shrinkable Nat where\n  shrink := Nat.shrink\n\n/-- `Fin.shrink` works like `Nat.shrink` but instead operates on `Fin`. -/\npartial def Fin.shrink {n : Nat} (m : Fin n.succ) : List (Fin n.succ) :=\n  if 0 < m then\n    let m := m / 2\n    let rest := shrink m\n    m :: rest\n  else\n    []\n\ninstance Fin.shrinkable {n : Nat} : Shrinkable (Fin n.succ) where\n  shrink := Fin.shrink\n\nlocal instance Int_sizeOfAbs : SizeOf Int := ⟨Int.natAbs⟩\n\n/-- `Int.shrinkable` operates like `Nat.shrinkable` but also includes the negative variants. -/\ninstance Int.shrinkable : Shrinkable Int where\n  shrink n :=\n    Nat.shrink n.natAbs |>.map fun x => - Int.ofNat x\n\ninstance Bool.shrinkable : Shrinkable Bool := {}\ninstance Char.shrinkable : Shrinkable Char := {}\n\ninstance Prod.shrinkable [shrA : Shrinkable α] [shrB : Shrinkable β] : Shrinkable (Prod α β) where\n  shrink := λ (fst,snd) =>\n    let shrink1 := shrA.shrink fst |>.map fun x => (x, snd)\n    let shrink2 := shrB.shrink snd |>.map fun x => (fst, x)\n    shrink1 ++ shrink2\n\nend Shrinkers\n\nsection Samplers\n\nopen Gen SampleableExt\n\ninstance Nat.sampleableExt : SampleableExt Nat :=\n  mkSelfContained (do choose Nat 0 (← getSize))\n\ninstance Fin.sampleableExt {n : Nat} : SampleableExt (Fin (n.succ)) :=\n  mkSelfContained (do choose (Fin n.succ) (Fin.ofNat 0) (Fin.ofNat (← getSize)))\n\ninstance Int.sampleableExt : SampleableExt Int :=\n  mkSelfContained (do choose Int (-(← getSize)) (← getSize))\n\ninstance Bool.sampleableExt : SampleableExt Bool :=\n  mkSelfContained $ chooseAny Bool\n\n/-- This can be specialized into customized `SampleableExt Char` instances.\nThe resulting instance has `1 / length` chances of making an unrestricted choice of characters\nand it otherwise chooses a character from `chars` with uniform probabilities.  -/\ndef Char.sampleable (length : Nat) (chars : List Char) : SampleableExt Char :=\n    mkSelfContained do\n      let x ←  choose Nat 0 length\n      if x == 0 then\n        let n ←  interpSample Nat\n        pure $ Char.ofNat n\n      else\n        elements chars\n\ninstance Char.sampleableDefault : SampleableExt Char :=\n  Char.sampleable 3 \" 0123abcABC:,;`\\\\/\".toList\n\ninstance Prod.sampleableExt {α β : Type u} [SampleableExt α] [SampleableExt β] :\n    SampleableExt (α × β) where\n  proxy := Prod (proxy α) (proxy β)\n  proxyRepr := inferInstance\n  shrink := inferInstance\n  sample := prodOf sample sample\n  interp := Prod.map interp interp\n\ninstance Prop.sampleableExt : SampleableExt Prop where\n  proxy := Bool\n  proxyRepr := inferInstance\n  sample := interpSample Bool\n  shrink := inferInstance\n  interp := Coe.coe\n\nend Samplers\n\n/-- An annotation for values that should never get shrinked. -/\ndef NoShrink (α : Type u) := α\n\nnamespace NoShrink\n\ndef mk (x : α) : NoShrink α := x\ndef get (x : NoShrink α) : α := x\n\ninstance inhabited [inst : Inhabited α] : Inhabited (NoShrink α) := inst\ninstance repr [inst : Repr α] : Repr (NoShrink α) := inst\n\ninstance shrinkable : Shrinkable (NoShrink α) where\n  shrink := λ _ => []\n\ninstance sampleableExt [SampleableExt α] [Repr α] : SampleableExt (NoShrink α) :=\n  SampleableExt.mkSelfContained $ (NoShrink.mk ∘ SampleableExt.interp) <$> SampleableExt.sample\n\nend NoShrink\n\nend SlimCheck", "meta": {"author": "lurk-lab", "repo": "LSpec", "sha": "88f7d23e56a061d32c7173cea5befa4b2c248b41", "save_path": "github-repos/lean/lurk-lab-LSpec", "path": "github-repos/lean/lurk-lab-LSpec/LSpec-88f7d23e56a061d32c7173cea5befa4b2c248b41/LSpec/SlimCheck/Sampleable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.46806292885920975}}
{"text": "import topology.path_connected\nimport topology.urysohns_lemma\nimport topology.uniform_space.separation\nimport linear_algebra.affine_space.independent\nimport analysis.normed_space.finite_dimension\nimport topology.algebra.order.floor\nimport topology.shrinking_lemma\nimport topology.metric_space.emetric_paracompact\nimport analysis.convex.normed\n\nnoncomputable theory\n\nopen set function filter topological_space\nopen_locale unit_interval topology uniformity filter classical\n\nsection to_specific_limits\n\nlemma tendsto_self_div_add_at_top_nhds_1_nat :\n  tendsto (λ n : ℕ, (n : ℝ) / (n + 1)) at_top (𝓝 1) :=\nbegin\n  suffices : tendsto (λ n : ℕ, (1 : ℝ) - 1 / (n + 1)) at_top (𝓝 (1 - 0)),\n  { have hn : ∀ n : ℕ, (n : ℝ) + 1 ≠ 0 := λ n, n.cast_add_one_pos.ne',\n    simp_rw [one_sub_div (hn _), add_sub_cancel, sub_zero] at this, exact this },\n  exact tendsto_const_nhds.sub tendsto_one_div_add_at_top_nhds_0_nat\nend\n\n\nend to_specific_limits\n\nsection maps\nopen function set\nvariables {α β : Type*} [topological_space α] [topological_space β] {f : α → β} {g : β → α}\n\nlemma function.left_inverse.mem_preimage_iff (hfg : left_inverse g f) {s : set α} {x : α} :\n  f x ∈ g ⁻¹' s ↔ x ∈ s :=\nby rw [set.mem_preimage, hfg x]\n\n-- to set.basic\nlemma function.left_inverse.image_eq (hfg : left_inverse g f) (s : set α) :\n  f '' s = range f ∩ g ⁻¹' s :=\n-- begin\n--   simp_rw [set.ext_iff, mem_image, mem_inter_iff, mem_range, and_comm (_ ∈ _),\n--     @eq_comm _ (f _), ← exists_and_distrib_right, ← exists_prop],\n--   simp only [hfg _, iff_true_intro iff.rfl, implies_true_iff, hfg.mem_preimage_iff] {contextual := tt},\n-- end\nbegin\n  ext x, split,\n  { rintro ⟨x, hx, rfl⟩, exact ⟨mem_range_self x, hfg.mem_preimage_iff.mpr hx⟩ },\n  { rintro ⟨⟨x, rfl⟩, b⟩, exact mem_image_of_mem f (hfg.mem_preimage_iff.mp b) }\nend\n\nlemma function.left_inverse.is_open_map {f : α → β} {g : β → α} (hfg : left_inverse g f)\n  (hf : is_open (range f)) (hg : continuous_on g (range f)) : is_open_map f :=\nby { intros U hU, rw [hfg.image_eq], exact hg.preimage_open_of_open hf hU }\n\nend maps\n\nsection -- to separation\n\nlemma filter.eventually.closed_neighborhood {α} [topological_space α] [normal_space α] {C : set α}\n  {P : α → Prop} (hP : ∀ᶠ x in 𝓝ˢ C, P x) (hC : is_closed C) :\n    ∃ C' ∈ 𝓝ˢ C, is_closed C' ∧ ∀ᶠ x in 𝓝ˢ C', P x :=\nbegin\n  obtain ⟨O, hO, hCO, hPO⟩ := mem_nhds_set_iff_exists.mp hP,\n  obtain ⟨U, hU, hCU, hUO⟩ := normal_exists_closure_subset hC hO hCO,\n  exact ⟨closure U, mem_of_superset (hU.mem_nhds_set.mpr hCU) subset_closure, is_closed_closure,\n    eventually_of_mem (hO.mem_nhds_set.mpr hUO) hPO⟩\nend\n\nend\n\nsection\n\nvariables {α β : Type*} [topological_space α] [topological_space β]\n\n\nlemma continuous_at.eventually {f : α → β} {a₀ : α} (hf : continuous_at f a₀)\n  (P : β → Prop) (hP : is_open {b | P b}) (ha₀ : P (f a₀)) :\n  ∀ᶠ a in 𝓝 a₀, P (f a) :=\nhf (is_open_iff_mem_nhds.mp hP _ ha₀)\n\nlemma continuous_at.eventually' {f : α → β} {a₀ : α} (hf : continuous_at f a₀)\n  (P : β → Prop)(hP : ∀ᶠ y in 𝓝 (f a₀), P y) :\n  ∀ᶠ a in 𝓝 a₀, P (f a) :=\nbegin\n  rw [continuous_at, tendsto_iff_comap] at hf,\n  exact eventually.filter_mono hf (hP.comap f)\nend\n\nlemma continuous.eventually {f : α → β} {a₀ : α} (hf : continuous f) (P : β → Prop)\n  (hP : is_open {b | P b}) (ha₀ : P (f a₀)) :\n  ∀ᶠ a in 𝓝 a₀, P (f a) :=\nhf.continuous_at.eventually P hP ha₀\n\n-- (unused)\nlemma nhds_set_prod_le {s : set α} {t : set β} : 𝓝ˢ (s ×ˢ t) ≤ (𝓝ˢ s).prod (𝓝ˢ t) :=\nbegin\n  intros w hw,\n  obtain ⟨u, hu, v, hv, huv⟩ := mem_prod_iff.mp hw,\n  rw [← subset_interior_iff_mem_nhds_set] at hu hv ⊢,\n  refine (prod_mono hu hv).trans _,\n  rw [← interior_prod_eq],\n  exact interior_mono huv\nend\n\ninstance [sigma_compact_space α] [sigma_compact_space β] : sigma_compact_space (α × β) :=\nbegin\n  refine ⟨⟨λ n, compact_covering α n.unpair.1 ×ˢ compact_covering β n.unpair.2, λ n,\n    (is_compact_compact_covering _ _).prod (is_compact_compact_covering _ _), _⟩⟩,\n  simp_rw [set.Union_unpair (λ n m, compact_covering α n ×ˢ compact_covering β m), ← prod_Union,\n    ← Union_prod_const, Union_compact_covering, univ_prod_univ]\nend\n\nend\n\nsection\n\nlemma support_norm {α E : Type*} [normed_add_comm_group E] (f : α → E) : support (λ a, ‖f a‖) = support f :=\nfunction.support_comp_eq norm (λ x, norm_eq_zero) f\n\n@[to_additive]\nlemma has_compact_mul_support_of_subset {α β : Type*} [topological_space α] [t2_space α]\n  [has_one β] {f : α → β} {K : set α} (hK : is_compact K) (hf : mul_support f ⊆ K) :\n  has_compact_mul_support f :=\nis_compact_of_is_closed_subset hK (is_closed_mul_tsupport f) (closure_minimal hf hK.is_closed)\n\nlemma periodic_const {α β : Type*} [has_add α] {a : α} {b : β} : periodic (λ x, b) a :=\nλ x, rfl\n\nlemma real.ball_zero_eq (r : ℝ) : metric.ball (0 : ℝ) r = Ioo (-r) r :=\nby { ext x, simp [real.norm_eq_abs, abs_lt] }\n\nend\n\nsection\n/-! ## The standard ℤ action on ℝ is properly discontinuous\n\nTODO: use that in to_mathlib.topology.periodic?\n-/\ninstance : has_vadd ℤ ℝ := ⟨λ n x, (n : ℝ) + x⟩\n\ninstance : properly_discontinuous_vadd ℤ ℝ :=\n⟨begin\n  intros K L hK hL,\n  rcases eq_empty_or_nonempty K with rfl | hK' ; rcases eq_empty_or_nonempty L with rfl | hL' ;\n  try { simp },\n  have hSK:= (hK.is_lub_Sup hK').1,\n  have hIK:= (hK.is_glb_Inf hK').1,\n  have hSL:= (hL.is_lub_Sup hL').1,\n  have hIL:= (hL.is_glb_Inf hL').1,\n  apply (finite_Icc ⌈Inf L - Sup K⌉ ⌊Sup L - Inf K⌋).subset,\n  rintros n (hn : has_vadd.vadd n '' K ∩ L ≠ ∅),\n  rcases nonempty_iff_ne_empty.mpr hn with ⟨l, ⟨k, hk, rfl⟩, hnk : (n : ℝ) + k ∈ L⟩,\n  split,\n  { rw int.ceil_le,\n    linarith [hIL hnk, hSK hk] },\n  { rw int.le_floor,\n    linarith [hSL hnk, hIK hk] }\nend⟩\n\nend\n\nsection fract\n\nopen int\n/- properties of the (dis)continuity of `int.fract` on `ℝ`.\nTo be PRed to topology.algebra.floor_ring\n-/\n\nlemma floor_eq_self_iff {x : ℝ} : (⌊x⌋ : ℝ) = x ↔ ∃ n : ℤ, x = n :=\nbegin\n  split,\n  { intro h,\n    exact ⟨⌊x⌋, h.symm⟩ },\n  { rintros ⟨n, rfl⟩,\n    rw floor_int_cast }\nend\n\nlemma fract_eq_zero_iff {x : ℝ} : fract x = 0 ↔ ∃ n : ℤ, x = n :=\nby rw [fract, sub_eq_zero, eq_comm, floor_eq_self_iff]\n\nlemma fract_ne_zero_iff {x : ℝ} : fract x ≠ 0 ↔ ∀ n : ℤ, x ≠ n :=\nby rw [← not_exists, not_iff_not, fract_eq_zero_iff]\n\nlemma Ioo_floor_mem_nhds {x : ℝ} (h : ∀ (n : ℤ), x ≠ n) : Ioo (⌊x⌋ : ℝ) (⌊x⌋ + 1 : ℝ) ∈ 𝓝 x :=\nIoo_mem_nhds ((floor_le x).eq_or_lt.elim (λ H, (h ⌊x⌋ H.symm).elim) id) (lt_floor_add_one x)\n\nlemma loc_constant_floor {x : ℝ} (h : ∀ (n : ℤ), x ≠ n) : floor =ᶠ[𝓝 x] (λ x', ⌊x⌋) :=\nbegin\n  filter_upwards [Ioo_floor_mem_nhds h],\n  intros y hy,\n  rw floor_eq_on_Ico,\n  exact mem_Ico_of_Ioo hy\nend\n\nlemma fract_eventually_eq {x : ℝ}\n  (h : fract x ≠ 0) : fract =ᶠ[𝓝 x] (λ x', x' - floor x) :=\nbegin\n  rw fract_ne_zero_iff at h,\n  exact eventually_eq.rfl.sub ((loc_constant_floor h).fun_comp _)\nend\n\n-- todo: make iff\nlemma continuous_at_fract {x : ℝ} (h : fract x ≠ 0) : continuous_at fract x :=\n(continuous_at_id.sub continuous_at_const).congr (fract_eventually_eq h).symm\n\nlemma Ioo_inter_Iio {α : Type*} [linear_order α] {a b c : α} : Ioo a b ∩ Iio c = Ioo a (min b c) :=\nby { ext, simp [and_assoc] }\n\nlemma fract_lt {x y : ℝ} {n : ℤ} (h1 : (n : ℝ) ≤ x) (h2 : x < n + y) : fract x < y :=\nbegin\n  cases le_total y 1 with hy hy,\n  { rw [← fract_sub_int x n, fract_eq_self.mpr],\n    linarith,\n    split; linarith },\n  { exact (fract_lt_one x).trans_le hy }\nend\n\nlemma one_sub_lt_fract {x y : ℝ} {n : ℤ} (hy : y ≤ 1) (h1 : (n : ℝ) - y < x) (h2 : x < n) :\n  1 - y < fract x :=\nbegin\n  have I₁ : 1 - y < x - (n-1), by linarith,\n  have I₂ : x - (n-1) < 1, by linarith,\n  norm_cast at I₁ I₂,\n  rw [← fract_sub_int x (n-1), fract_eq_self.mpr],\n  exact I₁,\n  split; linarith,\nend\n\nlemma is_open.preimage_fract' {s : set ℝ} (hs : is_open s)\n  (h2s : 0 ∈ s → s ∈ 𝓝[<] (1 : ℝ)) : is_open (fract ⁻¹' s) :=\nbegin\n  rw is_open_iff_mem_nhds,\n  rintros x (hx : fract x ∈ s),\n  rcases eq_or_ne (fract x)  0 with hx' | hx',\n  { have H : (0 : ℝ) ∈ s, by rwa hx' at hx,\n    specialize h2s H,\n    rcases fract_eq_zero_iff.mp hx' with ⟨n, rfl⟩, clear hx hx',\n    have s_mem_0 := hs.mem_nhds H,\n    rcases (nhds_basis_zero_abs_sub_lt ℝ).mem_iff.mp s_mem_0 with ⟨δ, δ_pos, hδ⟩,\n    rcases (nhds_within_has_basis (nhds_basis_Ioo_pos (1 : ℝ)) _).mem_iff.mp h2s with ⟨ε, ε_pos, hε⟩,\n    rw [Ioo_inter_Iio, min_eq_right (le_add_of_nonneg_right ε_pos.le)] at hε,\n    set ε' := min ε (1/2),\n    have ε'_pos : 0 < ε',\n      from lt_min ε_pos (by norm_num : (0 : ℝ) < 1/2),\n    have hε' : Ioo (1 - ε') 1 ⊆ s,\n    { apply subset.trans _ hε,\n      apply Ioo_subset_Ioo_left,\n      linarith [min_le_left ε (1/2)] },\n    have mem : Ioo ((n : ℝ)-ε') (n+δ) ∈ 𝓝 (n : ℝ),\n    { apply Ioo_mem_nhds ; linarith },\n    apply mem_of_superset mem,\n    rintros x ⟨hx, hx'⟩,\n    cases le_or_gt (n : ℝ) x with hx'' hx'',\n    { apply hδ,\n      rw [mem_set_of_eq, abs_eq_self.mpr (fract_nonneg x)],\n      exact fract_lt hx'' hx' },\n    { apply hε',\n      split,\n      { refine one_sub_lt_fract (by linarith [min_le_right ε (1/2)]) (by linarith) hx'' },\n      { exact fract_lt_one x }, } },\n  { rw fract_ne_zero_iff at hx',\n    have H : Ico (⌊x⌋ : ℝ) (⌊x⌋ + 1) ∈ 𝓝 x,\n      from mem_of_superset (Ioo_floor_mem_nhds hx') Ioo_subset_Ico_self,\n    exact (continuous_on_fract ⌊x⌋).continuous_at H (hs.mem_nhds hx) },\nend\n\nlemma is_open.preimage_fract {s : set ℝ} (hs : is_open s)\n  (h2s : (0 : ℝ) ∈ s → (1 : ℝ) ∈ s) : is_open (fract ⁻¹' s) :=\nhs.preimage_fract' $ λ h, nhds_within_le_nhds $ hs.mem_nhds (h2s h)\n\n-- is `sᶜ ∉ 𝓝[<] (1 : ℝ)` equivalent to something like `cluster_pt (𝓝[Iio (1 : ℝ) ∩ s] (1 : ℝ)` ?\nlemma is_closed.preimage_fract {s : set ℝ} (hs : is_closed s)\n  (h2s : sᶜ ∉ 𝓝[<] (1 : ℝ) → (0 : ℝ) ∈ s) : is_closed (fract ⁻¹' s) :=\nis_open_compl_iff.mp $ hs.is_open_compl.preimage_fract' $ λ h, by_contra $ λ h', h $ h2s h'\n\nlemma fract_preimage_mem_nhds {s : set ℝ} {x : ℝ} (h1 : s ∈ 𝓝 (fract x))\n  (h2 : fract x = 0 → s ∈ 𝓝 (1 : ℝ)) : fract ⁻¹' s ∈ 𝓝 x :=\nbegin\n  by_cases hx : fract x = 0,\n  { obtain ⟨u, hus, hu, hxu⟩ := mem_nhds_iff.mp h1,\n    obtain ⟨v, hvs, hv, h1v⟩ := mem_nhds_iff.mp (h2 hx),\n    rw [mem_nhds_iff],\n    refine ⟨fract ⁻¹' (u ∪ v), preimage_mono (union_subset hus hvs),\n      (hu.union hv).preimage_fract (λ _, subset_union_right _ _ h1v), subset_union_left _ _ hxu⟩ },\n  { exact (continuous_at_fract hx).preimage_mem_nhds h1 }\nend\n\nend fract\n\nsection\n-- to normed_space\nvariables {E F : Type*} [normed_add_comm_group E] [normed_add_comm_group F]\nvariables [normed_space ℝ E] [normed_space ℝ F]\n\nlemma dist_smul_add_one_sub_smul_le {r : ℝ} {x y : E} (h : r ∈ unit_interval) :\n  dist (r • x + (1 - r) • y) x ≤ dist y x :=\ncalc\n  dist (r • x + (1 - r) • y) x = ‖1 - r‖ * ‖x - y‖ : by simp_rw [dist_eq_norm', ← norm_smul,\n    sub_smul, one_smul, smul_sub, ← sub_sub, ← sub_add, sub_right_comm]\n  ... = (1 - r) * dist y x :\n    by rw [real.norm_eq_abs, abs_eq_self.mpr (sub_nonneg.mpr h.2), dist_eq_norm']\n  ... ≤ (1 - 0) * dist y x : mul_le_mul_of_nonneg_right (sub_le_sub_left h.1 _) dist_nonneg\n  ... = dist y x : by rw [sub_zero, one_mul]\n\nend\n\nsection -- to ???\n\n-- needs classical\nvariables {α β γ δ ι : Type*} [topological_space α] [topological_space β] {x : α}\n\nlemma is_open_slice_of_is_open_over {Ω : set (α × β)} {x₀ : α}\n  (hΩ_op : ∃ U ∈ 𝓝 x₀, is_open (Ω ∩ prod.fst ⁻¹' U)) : is_open (prod.mk x₀ ⁻¹' Ω) :=\nbegin\n  rcases hΩ_op with ⟨U, hU, hU_op⟩, convert hU_op.preimage (continuous.prod.mk x₀) using 1,\n  simp_rw [preimage_inter, preimage_preimage, preimage_const, mem_of_mem_nhds hU, if_pos,\n    inter_univ]\nend\n\nend\n\nsection proj_I\n\nvariables {α β : Type*} [linear_ordered_semiring α] {x c : α}\n\n/-- If `α` is a `linear_ordered_semiring`, then `proj_I : α → α` projection of `α` onto the unit\ninterval `[0, 1]`. -/\ndef proj_I : α → α := λ x, proj_Icc (0 : α) 1 zero_le_one x\n\nlemma proj_I_def : proj_I x = max 0 (min 1 x) := rfl\n\nlemma proj_Icc_eq_proj_I : (proj_Icc (0 : α) 1 zero_le_one x : α) = proj_I x := rfl\n\nlemma proj_I_of_le_zero (hx : x ≤ 0) : proj_I x = 0 :=\ncongr_arg coe $ proj_Icc_of_le_left _ hx\n\n@[simp] lemma proj_I_zero : proj_I (0 : α) = 0 :=\ncongr_arg coe $ proj_Icc_left _\n\nlemma proj_I_of_one_le (hx : 1 ≤ x) : proj_I x = 1 :=\ncongr_arg coe $ proj_Icc_of_right_le _ hx\n\n@[simp] lemma proj_I_one : proj_I (1 : α) = 1 :=\ncongr_arg coe $ proj_Icc_right _\n\n@[simp] lemma proj_I_eq_zero [nontrivial α] : proj_I x = 0 ↔ x ≤ 0 :=\nby { rw [← proj_Icc_eq_left (zero_lt_one' α), subtype.ext_iff], refl }\n\n@[simp] lemma proj_I_eq_one : proj_I x = 1 ↔ 1 ≤ x :=\nby { rw [← proj_Icc_eq_right (zero_lt_one' α), subtype.ext_iff], refl }\n\nlemma proj_I_mem_Icc : proj_I x ∈ Icc (0 : α) 1 :=\n(proj_Icc (0 : α) 1 zero_le_one x).prop\n\nlemma proj_I_eq_self : proj_I x = x ↔ x ∈ Icc (0 : α) 1 :=\n⟨λ h, h ▸ proj_I_mem_Icc, λ h, congr_arg coe $ proj_Icc_of_mem _ h⟩\n\n@[simp] lemma proj_I_proj_I : proj_I (proj_I x) = proj_I x :=\nproj_I_eq_self.mpr proj_I_mem_Icc\n\n@[simp] lemma proj_Icc_proj_I :\n  proj_Icc (0 : α) 1 zero_le_one (proj_I x) = proj_Icc 0 1 zero_le_one x :=\nproj_Icc_of_mem _ proj_I_mem_Icc\n\n@[simp] lemma range_proj_I : range (proj_I) = Icc 0 1 :=\nby rw [proj_I, range_comp, range_proj_Icc, image_univ, subtype.range_coe]\n\nlemma monotone_proj_I : monotone (proj_I : α → α) :=\nmonotone_proj_Icc _\n\nlemma strict_mono_on_proj_I : strict_mono_on proj_I (Icc (0 : α) 1) :=\nstrict_mono_on_proj_Icc _\n\nlemma proj_I_le_max : proj_I x ≤ max 0 x :=\nmax_le_max le_rfl $ min_le_right _ _\n\nlemma min_le_proj_I : min 1 x ≤ proj_I x :=\nle_max_right _ _\n\nlemma proj_I_le_iff : proj_I x ≤ c ↔ 0 ≤ c ∧ (1 ≤ c ∨ x ≤ c) :=\nby simp_rw [proj_I_def, max_le_iff, min_le_iff]\n\n@[simp] lemma proj_I_eq_min : proj_I x = min 1 x ↔ 0 ≤ x :=\nby simp_rw [proj_I_def, max_eq_right_iff, le_min_iff, zero_le_one, true_and]\n\nlemma min_proj_I (h2 : 0 ≤ c) : min c (proj_I x) = proj_I (min c x) :=\nby { cases le_total c x with h3 h3; simp [h2, h3, proj_I_le_iff, proj_I_eq_min.mpr],\n     simp [proj_I_eq_min.mpr, h2.trans h3, min_left_comm c, h3] }\n\nlemma continuous_proj_I [topological_space α] [order_topology α] :\n  continuous (proj_I : α → α) :=\ncontinuous_proj_Icc.subtype_coe\n\nlemma proj_I_mapsto {α : Type*} [linear_ordered_semiring α] {s : set α} (h0s : (0 : α) ∈ s)\n  (h1s : (1 : α) ∈ s) : maps_to proj_I s s :=\nλ x hx, (le_total 1 x).elim (λ h2x, by rwa [proj_I_eq_one.mpr h2x]) $\n  λ h2x, (le_total 0 x).elim (λ h3x, by rwa [proj_I_eq_self.mpr ⟨h3x, h2x⟩]) $\n  λ h3x, by rwa [proj_I_eq_zero.mpr h3x]\n-- about path.truncate\n\nlemma truncate_proj_I_right {X : Type*} [topological_space X] {a b : X}\n  (γ : path a b) (t₀ t₁ : ℝ) (s : I) :\n  γ.truncate t₀ (proj_I t₁) s = γ.truncate t₀ t₁ s :=\nbegin\n  simp_rw [path.truncate, path.coe_mk, path.extend, Icc_extend, function.comp],\n  rw [min_proj_I (s.prop.1.trans $ le_max_left _ _), proj_Icc_proj_I],\nend\n\nend proj_I\n\nsection\n\nopen encodable option\nvariables {α β γ : Type*} [topological_space α] [topological_space β]\n-- can we restate this nicely?\n\n/-- Given a locally finite sequence of sets indexed by an encodable type, we can naturally reindex\n  this sequence to get a sequence indexed by `ℕ` (by adding some `∅` values).\n  This new sequence is still locally finite. -/\nlemma decode₂_locally_finite {ι} [encodable ι] {s : ι → set α}\n  (hs : locally_finite s) : locally_finite (λ i, (s <$> decode₂ ι i).get_or_else ∅) :=\nbegin\n  intro x,\n  obtain ⟨U, hxU, hU⟩ := hs x,\n  refine ⟨U, hxU, _⟩,\n  have : encode ⁻¹' {i : ℕ | ((s <$> decode₂ ι i).get_or_else ∅ ∩ U).nonempty} =\n     {i : ι | (s i ∩ U).nonempty},\n  { simp_rw [preimage_set_of_eq, decode₂_encode, map_some, get_or_else_some] },\n  rw [← this] at hU,\n  refine finite_of_finite_preimage hU _,\n  intros n hn,\n  rw [← decode₂_ne_none_iff],\n  intro h,\n  simp_rw [mem_set_of_eq, h, map_none, get_or_else_none, empty_inter] at hn,\n  exact (not_nonempty_empty hn).elim\nend\n\nopen topological_space\n\nvariables {X : Type*} [emetric_space X] [locally_compact_space X] [second_countable_topology X]\n\nlemma exists_locally_finite_subcover_of_locally {C : set X} (hC : is_closed C) {P : set X → Prop}\n  (hP : antitone P) (h0 : P ∅) (hX : ∀ x ∈ C, ∃ V ∈ 𝓝 (x : X), P V) :\n∃ (K : ℕ → set X) (W : ℕ → set X), (∀ n, is_compact (K n)) ∧ (∀ n, is_open (W n)) ∧\n  (∀ n, P (W n)) ∧ (∀ n, K n ⊆ W n) ∧ locally_finite W ∧ C ⊆ ⋃ n, K n :=\nbegin\n  choose V' hV' hPV' using set_coe.forall'.mp hX,\n  choose V hV hVV' hcV using λ x : C, locally_compact_space.local_compact_nhds ↑x (V' x) (hV' x),\n  simp_rw [← mem_interior_iff_mem_nhds] at hV,\n  have : C ⊆ (⋃ x : C, interior (V x)) :=\n  λ x hx, by { rw [mem_Union], exact ⟨⟨x, hx⟩, hV _⟩ },\n  obtain ⟨s, hs, hsW₂⟩ := is_open_Union_countable (λ x, interior (V x)) (λ x, is_open_interior),\n  rw [← hsW₂, bUnion_eq_Union] at this, clear hsW₂,\n  obtain ⟨W, hW, hUW, hlW, hWV⟩ :=\n    precise_refinement_set hC (λ x : s, interior (V x)) (λ x, is_open_interior) this,\n  obtain ⟨K, hCK, hK, hKW⟩ :=\n    exists_subset_Union_closed_subset hC (λ x : s, hW x) (λ x _, hlW.point_finite x) hUW,\n  haveI : encodable s := hs.to_encodable,\n  let K' : ℕ → set X := λ n, (K <$> (decode₂ s n)).get_or_else ∅,\n  let W' : ℕ → set X := λ n, (W <$> (decode₂ s n)).get_or_else ∅,\n  refine ⟨K', W', _, _, _, _, _, _⟩,\n  { intro n, cases h : decode₂ s n with i,\n    { simp_rw [K', h, map_none, get_or_else_none, is_compact_empty] },\n    { simp_rw [K', h, map_some, get_or_else_some],\n      exact is_compact_of_is_closed_subset (hcV i) (hK i)\n        ((hKW i).trans $ (hWV i).trans interior_subset) }},\n  { intro n, cases h : decode₂ s n,\n    { simp_rw [W', h, map_none, get_or_else_none, is_open_empty] },\n    { simp_rw [W', h, map_some, get_or_else_some, hW] }},\n  { intro n, cases h : decode₂ s n with i,\n    { simp_rw [W', h, map_none, get_or_else_none, h0] },\n    { simp_rw [W', h, map_some, get_or_else_some], refine hP _ (hPV' i),\n      refine (hWV i).trans (interior_subset.trans $ hVV' i) }},\n  { intro n, cases h : decode₂ s n,\n    { simp_rw [K', W', h, map_none] },\n    { simp_rw [K', W', h, map_some, get_or_else_some, hKW] }},\n  { exact decode₂_locally_finite hlW },\n  { intros x hx, obtain ⟨i, hi⟩ := mem_Union.mp (hCK hx),\n    refine mem_Union.mpr ⟨encode i, _⟩,\n    simp_rw [K', decode₂_encode, map_some, get_or_else_some, hi] }\nend\n\nend\n\nsection -- to subset_properties\n\nvariables {α β γ : Type*} [topological_space α] [topological_space β] [topological_space γ]\n\nlemma is_compact.eventually_forall_mem {x₀ : α} {K : set β} (hK : is_compact K)\n  {f : α → β → γ} (hf : continuous ↿f) {U : set γ} (hU : ∀ y ∈ K, U ∈ 𝓝 (f x₀ y)) :\n  ∀ᶠ x in 𝓝 x₀, ∀ y ∈ K, f x y ∈ U :=\nhK.eventually_forall_of_forall_eventually $ λ y hy, (hf.tendsto _).eventually $\n  show U ∈ 𝓝 (↿f (x₀, y)), from hU y hy\n\nend\n\nsection -- to separation\n\nvariables {α : Type*} [topological_space α]\n\n/-\nneeds\nimport linear_algebra.affine_space.independent\nimport analysis.normed_space.finite_dimension\n-/\nlemma is_open_affine_independent (𝕜 E : Type*) {ι : Type*} [nontrivially_normed_field 𝕜]\n  [normed_add_comm_group E] [normed_space 𝕜 E] [complete_space 𝕜] [finite ι] :\n  is_open {p : ι → E | affine_independent 𝕜 p} :=\nbegin\n  classical,\n  cases is_empty_or_nonempty ι, { resetI, exact is_open_discrete _ },\n  obtain ⟨i₀⟩ := h,\n  simp_rw [affine_independent_iff_linear_independent_vsub 𝕜 _ i₀],\n  let ι' := {x // x ≠ i₀},\n  casesI nonempty_fintype ι,\n  haveI : fintype ι' := subtype.fintype _,\n  convert_to\n    is_open ((λ (p : ι → E) (i : ι'), p i -ᵥ p i₀) ⁻¹' {p : ι' → E | linear_independent 𝕜 p}),\n  refine is_open.preimage _ is_open_set_of_linear_independent,\n  refine continuous_pi (λ i', continuous.vsub (continuous_apply i') $ continuous_apply i₀),\nend\n\nend\n\nsection convex\n\nvariables {E : Type*} [add_comm_group E] [module ℝ E] [topological_space E]\n  [topological_add_group E] [has_continuous_smul ℝ E] {s : set E}\n\nlemma convex.is_preconnected' (hs : convex ℝ s) : is_preconnected s :=\nby { rcases s.eq_empty_or_nonempty with rfl|h, exact is_preconnected_empty,\n     exact (hs.is_path_connected h).is_connected.is_preconnected }\n\nend convex\n\nsection\n\nopen metric\n\nlemma continuous.inf_dist {α β : Type*} [topological_space α] [pseudo_metric_space β] {s : set β}\n  {f : α → β} (hf : continuous f) : continuous (λ x, inf_dist (f x) s) :=\n(continuous_inf_dist_pt _).comp hf\n\nend\n\nsection normed_space\nopen metric\n\nvariables {E : Type*} [normed_add_comm_group E] [normed_space ℝ E]\n\nlemma is_preconnected_ball (x : E) (r : ℝ) : is_preconnected (ball x r) :=\n(convex_ball x r).is_preconnected'\n\nlemma is_connected_ball {x : E} {r : ℝ} : is_connected (ball x r) ↔ 0 < r :=\nbegin\n  rw [← @nonempty_ball _ _ x],\n  refine ⟨λ h, h.nonempty, λ h, ((convex_ball x r).is_path_connected $ h).is_connected⟩\nend\n\n-- todo: make metric.mem_nhds_iff protected\n\nend normed_space\n\nsection connected_component_in\n\nvariables {α β : Type*} [topological_space α] [topological_space β]\n\nlemma continuous.image_connected_component_in_subset {f : α → β} {s : set α} {x : α}\n  (hf : continuous f) (hx : x ∈ s) :\n  f '' connected_component_in s x ⊆ connected_component_in (f '' s) (f x) :=\n(is_preconnected_connected_component_in.image _ hf.continuous_on).subset_connected_component_in\n  (mem_image_of_mem _ $ mem_connected_component_in hx)\n  (image_subset _ $ connected_component_in_subset _ _)\n\nlemma homeomorph.image_connected_component_in (f : α ≃ₜ β) {s : set α} {x : α} (hx : x ∈ s) :\n  f '' connected_component_in s x = connected_component_in (f '' s) (f x) :=\nbegin\n  refine (f.continuous.image_connected_component_in_subset hx).antisymm _,\n  have := f.symm.continuous.image_connected_component_in_subset (mem_image_of_mem _ hx),\n  rwa [image_subset_iff, f.preimage_symm, f.image_symm, f.preimage_image, f.symm_apply_apply]\n    at this,\nend\n\n\nend connected_component_in\n\nnamespace topological_space -- to topology.bases\nlemma cover_nat_nhds_within {α} [topological_space α] [second_countable_topology α] {f : α → set α}\n  {s : set α} (hf : ∀ x ∈ s, f x ∈ 𝓝[s] x) (hs : s.nonempty) :\n  ∃ x : ℕ → α, range x ⊆ s ∧ s ⊆ ⋃ n, f (x n) :=\nbegin\n  obtain ⟨t, hts, ht, hsf⟩ := topological_space.countable_cover_nhds_within hf,\n  have hnt : t.nonempty,\n  { by_contra,\n    rw [not_nonempty_iff_eq_empty] at h,\n    rw [h, bUnion_empty, subset_empty_iff] at hsf,\n    exact hs.ne_empty hsf },\n  obtain ⟨x, rfl⟩ := ht.exists_eq_range hnt,\n  rw [bUnion_range] at hsf,\n  exact ⟨x, hts, hsf⟩\nend\n\n/-- A version of `topological_space.cover_nat_nhds_within` where `f` is only defined on `s`. -/\nlemma cover_nat_nhds_within' {α} [topological_space α] [second_countable_topology α] {s : set α}\n  {f : ∀ x ∈ s, set α} (hf : ∀ x (hx : x ∈ s), f x hx ∈ 𝓝[s] x) (hs : s.nonempty) :\n  ∃ (x : ℕ → α) (hx : range x ⊆ s), s ⊆ ⋃ n, f (x n) (range_subset_iff.mp hx n) :=\nbegin\n  let g := λ x, if hx : x ∈ s then f x hx else ∅,\n  have hg : ∀ x ∈ s, g x ∈ 𝓝[s] x, { intros x hx, simp_rw [g, dif_pos hx], exact hf x hx },\n  obtain ⟨x, hx, h⟩ := topological_space.cover_nat_nhds_within hg hs,\n  simp_rw [g, dif_pos (range_subset_iff.mp hx _)] at h,\n  refine ⟨x, hx, h⟩,\nend\n\nend topological_space\n\nnamespace set\nnamespace subtype\nopen _root_.subtype\nvariables {α : Type*}\n\nlemma image_coe_eq_iff_eq_univ {s : set α} {t : set s} : (coe : s → α) '' t = s ↔ t = univ :=\nby { convert coe_injective.image_injective.eq_iff, rw coe_image_univ }\n\n@[simp] lemma preimage_coe_eq_univ {s t : set α} : (coe : s → α) ⁻¹' t = univ ↔ s ⊆ t :=\nby rw [← inter_eq_right_iff_subset, ← image_preimage_coe, image_coe_eq_iff_eq_univ]\n\nend subtype\nend set\nopen set\n\nsection paracompact_space\n\n-- a version of `precise_refinement_set` for open `s`.\n/-- When `s : set X` is open and paracompact, we can find a precise refinement on `s`. Note that\n in this case we only get the locally finiteness condition on `s`, which is weaker than the local\n finiteness condition on all of `X` (the collection might not be locally finite on the boundary of\n `s`). -/\ntheorem precise_refinement_set' {ι X : Type*} [topological_space X] {s : set X}\n  [paracompact_space s] (hs : is_open s)\n  (u : ι → set X) (uo : ∀ i, is_open (u i)) (us : s ⊆ ⋃ i, u i) :\n  ∃ (v : ι → set X), (∀ i, is_open (v i)) ∧ (s ⊆ ⋃ i, v i) ∧\n  locally_finite (λ i, (coe : s → X) ⁻¹' v i) ∧ (∀ i, v i ⊆ s) ∧ (∀ i, v i ⊆ u i) :=\nbegin\n  obtain ⟨v, vo, vs, vl, vu⟩ := precise_refinement (λ i, (coe : s → X) ⁻¹' u i)\n    (λ i, (uo i).preimage continuous_subtype_coe)\n    (by rwa [← preimage_Union, subtype.preimage_coe_eq_univ]),\n  refine ⟨λ i, coe '' v i, λ i, hs.is_open_map_subtype_coe _ (vo i),\n    by rw [← image_Union, vs, subtype.coe_image_univ],\n    by simp_rw [preimage_image_eq _ subtype.coe_injective, vl],\n    λ i, subtype.coe_image_subset _ _,\n    by { intro i, rw [image_subset_iff], exact vu i }⟩,\nend\n\nlemma point_finite_of_locally_finite_coe_preimage {ι X : Type*} [topological_space X] {s : set X}\n  {f : ι → set X} (hf : locally_finite (λ i, (coe : s → X) ⁻¹' f i)) (hfs : ∀ i, f i ⊆ s) {x : X} :\n  {i | x ∈ f i}.finite :=\nbegin\n  by_cases hx : x ∈ s,\n  { exact hf.point_finite ⟨x, hx⟩ },\n  { have : ∀ i, x ∉ f i := λ i hxf, hx (hfs i hxf),\n    simp only [this, set_of_false, finite_empty] }\nend\n\n\nend paracompact_space\n\nsection shrinking_lemma\n\nvariables {ι X : Type*} [topological_space X]\nvariables {u : ι → set X} {s : set X} [normal_space s]\n\n-- this lemma is currently formulated a little weirdly, since we have a collection of open sets\n-- as the input and a collection of closed/compact sets as output.\n-- Perhaps we can formulate it so that the input is a collection of compact sets whose interiors\n-- cover s.\nlemma exists_subset_Union_interior_of_is_open (hs : is_open s) (uo : ∀ i, is_open (u i))\n  (uc : ∀ i, is_compact (closure (u i)))\n  (us : ∀ i, closure (u i) ⊆ s)\n  (uf : ∀ x ∈ s, {i | x ∈ u i}.finite) (uU : s ⊆ ⋃ i, u i) :\n  ∃ v : ι → set X, s ⊆ (⋃ i, interior (v i)) ∧ (∀ i, is_compact (v i)) ∧ ∀ i, v i ⊆ u i :=\nbegin\n  obtain ⟨v, vU, vo, hv⟩ := exists_Union_eq_closure_subset\n    (λ i, (uo i).preimage (continuous_subtype_coe : continuous (coe : s → X)))\n    (λ x, uf x x.prop)\n    (by simp_rw [← preimage_Union, subtype.preimage_coe_eq_univ, uU]),\n  have : ∀ i, is_compact (closure ((coe : _ → X) '' (v i))),\n  { intro i, refine is_compact_of_is_closed_subset (uc i) is_closed_closure _,\n    apply closure_mono, rw image_subset_iff, refine subset_closure.trans (hv i) },\n  refine ⟨λ i, closure (coe '' (v i)), _, this, _⟩,\n  { refine subset.trans _ (Union_mono $\n      λ i, interior_maximal subset_closure (hs.is_open_map_subtype_coe _ (vo i))),\n    simp_rw [← image_Union, vU, subtype.coe_image_univ] },\n  { intro i,\n    have : coe '' v i ⊆ u i,\n    { rintro _ ⟨x, hx, rfl⟩, exact hv i (subset_closure hx) },\n    intros x hx,\n    have hxs : x ∈ s := us i (closure_mono this hx),\n    have : (⟨x, hxs⟩ : s) ∈ closure (v i),\n    { rw embedding_subtype_coe.closure_eq_preimage_closure_image (v i), exact hx },\n    exact hv i this }\nend\n\nend shrinking_lemma\n\nopen_locale filter\n\nlemma filter.eventually_eq.slice {α β γ : Type*} [topological_space α] [topological_space β]\n  {f g : α × β → γ} {a : α} {b : β} (h : f =ᶠ[𝓝 (a, b)] g) : (λ y, f (a, y)) =ᶠ[𝓝 b] (λ y, g(a, y)) :=\nbegin\n  rw nhds_prod_eq at h,\n  have : (pure a : filter α) ×ᶠ 𝓝 b ≤ (𝓝 a) ×ᶠ (𝓝 b),\n  exact prod_mono (by apply pure_le_nhds) le_rfl,\n  have := h.filter_mono this,\n  rw [pure_prod] at this,\n  exact eventually_map.mp this\nend\n\nlemma exists_compact_between' {α : Type*} [topological_space α] [locally_compact_space α]\n  {K U : set α} (hK : is_compact K) (hU : is_open U) (h_KU : K ⊆ U) :\n  ∃ L, is_compact L ∧ L ∈ 𝓝ˢ K ∧ L ⊆ U :=\nlet ⟨L, L_cpct, L_in, LU⟩ := exists_compact_between hK hU h_KU in\n  ⟨L, L_cpct, subset_interior_iff_mem_nhds_set.mp L_in, LU⟩\n\nsection -- to topology/basic\n\n@[simp] lemma finset.is_closed_bUnion {α} [topological_space α]\n  {ι : Type*} (s : finset ι) (f : ι → set α) (hf : ∀ i ∈ s, is_closed (f i)) :\n  is_closed (⋃ i ∈ s, f i) :=\nis_closed_bUnion s.finite_to_set hf\n\n\nend\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/to_mathlib/topology/misc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190477, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4680629248071901}}
{"text": "import data.pfun\nimport logic.relation\nimport logic.function.iterate\nimport tactic.apply_fun\nimport tactic.linear_combination\n\nnamespace option\n\n@[simp] lemma map_eq_some'_symm {α β : Type*} (f : α → β) (x : option α) (y : β) :\n  some y = x.map f ↔ ∃ a, x = some a ∧ f a = y := by { cases x; simp, exact comm, }\n\n@[simp] lemma map_eq_none'_symm {α β : Type*} (f : α → β) (x : option α) :\n  none = x.map f ↔ none = x := by cases x; simp\n\nend option\n\nnamespace part\n\n@[simp] lemma restrict_dom {α : Type*} (x : part α) {p : Prop} (hp : p → x.dom) :\n  (x.restrict p hp).dom ↔ p := by refl \n\nend part\n\nnamespace pfun\n\n@[simp] lemma res_dom {α β : Type*} (f : α →. β) {p : set α} (hp : p ⊆ f.dom) :\n  (f.restrict hp).dom = p := by simp [pfun.dom, pfun.restrict]\n\n/-- Restrict with the intersection of a set -/\ndef res_inter {α β : Type*} (f : α →. β) (p : set α) : α →. β :=\nf.restrict (set.inter_subset_right p f.dom)\n\n@[simp] lemma mem_res_inter {α β : Type*} {f : α →. β} {p : set α} {x y} :\n  y ∈ f.res_inter p x ↔ x ∈ p ∧ y ∈ f x :=\nby { simp [res_inter], tauto, }\n\n@[simp] lemma res_inter_res_inter {α β : Type*} {f : α →. β} {p₁ p₂ : set α} :\n  (f.res_inter p₁).res_inter p₂ = f.res_inter (p₁ ∩ p₂) :=\nby { ext, simp, tauto, }\n\n@[simp] lemma res_inter_dom {α β : Type*} (f : α →. β) (p : set α) :\n  (f.res_inter p).dom = p ∩ f.dom := by simp [res_inter]\n\n@[simp] lemma res_inter_dom' {α β : Type*} {f : α →. β} {p : set α} :\n  ∀ {x}, (f.res_inter p x).dom ↔ x ∈ p ∧ (f x).dom :=\nset.ext_iff.mp (res_inter_dom f p)\n\n@[simp] lemma coe_res_inter {α β : Type*} (f : α → β) (p : set α) :\n  (f : α →. β).res_inter p = pfun.res f p :=\nby { ext x, simp [mem_res], tauto, }\n\nend pfun\n\nopen relation\nopen nat (iterate)\nopen function (update iterate_succ iterate_succ_apply iterate_succ'\n  iterate_succ_apply' iterate_zero_apply)\n\nnamespace part_eval\n\n/-- Run a state transition function `σ → option σ` \"to completion\". The return value is the last\nstate returned before a `none` result. If the state transition function always returns `some` or any step of the\ntransition function diverges, then the computation diverges, returning `part.none`. -/\ndef eval {σ} (f : σ →. option σ) : σ → part σ :=\npfun.fix (λ s, (f s).map (λ x, x.elim (sum.inl s) sum.inr))\n\n/-- The reflexive transitive closure of a state transition function. `reaches f a b` means\nthere is a finite sequence of steps `f a = some a₁`, `f a₁ = some a₂`, ... such that `aₙ = b`.\nThis relation permits zero steps of the state transition function. -/\ndef reaches {σ} (f : σ →. option σ) : σ → σ → Prop :=\nrefl_trans_gen (λ a b, some b ∈ f a)\n\n@[refl] lemma reaches.refl {σ} (f : σ →. option σ) (x : σ) :\n  reaches f x x := refl_trans_gen.refl\n\n@[trans] lemma reaches.trans {σ} {f : σ →. option σ} {x y z : σ} :\n  reaches f x y → reaches f y z → reaches f x z := refl_trans_gen.trans\n\nlemma reaches_fwd {σ} {f : σ →. option σ} {x y : σ} :\n  some y ∈ f x → reaches f x y := @refl_trans_gen.single _ _ x y\n\ntheorem reaches_mono {σ} {f : σ →. option σ} (S : set σ) (hS : S ⊆ f.dom) {x y} (hf : reaches (f.restrict hS) x y) :\n  reaches f x y :=\nby { apply refl_trans_gen.mono _ hf, simp, }\n\ntheorem reaches_mono' {σ} {f g : σ →. option σ} (hfg : ∀ ⦃x y⦄, y ∈ f x → y ∈ g x) {x y} (hf : reaches f x y) :\n  reaches g x y :=\nby { apply refl_trans_gen.mono _ hf, intros _ _, apply hfg, }\n\ntheorem invariant_of_reaches {σ} {f : σ →. option σ} (S : set σ) (hS : ∀ ⦃x y⦄, x ∈ S → some y ∈ f x → y ∈ S)\n  {x y} (hx : x ∈ S) (hf : reaches f x y) : y ∈ S :=\nby { induction hf with x' y' hfx' hfy' ih, { exact hx, }, exact hS ih hfy', }\n\ntheorem reaches_of_invariant {σ} {f : σ →. option σ} (S : set σ) (hS : ∀ ⦃x y⦄, x ∈ S → some y ∈ f x → y ∈ S)\n  {x y} (hx : x ∈ S) (hf : reaches f x y) : reaches (f.res_inter S) x y :=\nbegin\n  induction hf using relation.refl_trans_gen.head_induction_on with x' y' hx' hy' ih, { refl, },\n  apply reaches.trans (reaches_fwd _) (ih _),\n  { simp only [pfun.mem_res_inter], exact ⟨hx, hx'⟩, }, { exact hS hx hx', }\nend\n\n/-- The transitive closure of a state transition function. `reaches₁ f a b` means there is a\nnonempty finite sequence of steps `f a = some a₁`, `f a₁ = some a₂`, ... such that `aₙ = b`.\nThis relation does not permit zero steps of the state transition function. -/\ndef reaches₁ {σ} (f : σ →. option σ) : σ → σ → Prop :=\ntrans_gen (λ a b, some b ∈ f a)\n\ntheorem reaches_iff_eq_or_reaches₁ {σ} {f : σ →. option σ} {a b} :\n  reaches f a b ↔ b = a ∨ reaches₁ f a b := refl_trans_gen_iff_eq_or_trans_gen\n\ntheorem reaches₁_head'_iff {σ} {f : σ →. option σ} {a b} :\n  reaches₁ f a b ↔ ∃ c : σ, some c ∈ f a ∧ reaches f c b := trans_gen.head'_iff\n\ntheorem reaches₁_eq {σ} {f : σ →. option σ} {a b c}\n  (h : f a = f b) : reaches₁ f a c ↔ reaches₁ f b c :=\ntrans_gen.head'_iff.trans (trans_gen.head'_iff.trans $ by rw h).symm\n\ntheorem reaches_total {σ} {f : σ →. option σ}\n  {a b c} (hab : reaches f a b) (hac : reaches f a c) :\n  reaches f b c ∨ reaches f c b :=\nrefl_trans_gen.total_of_right_unique (λ x y z hx hy, option.some_injective _ (part.mem_unique hx hy)) hab hac\n\ntheorem reaches₁_fwd {σ} {f : σ →. option σ}\n  {a b c} (h₁ : reaches₁ f a c) (h₂ : some b ∈ f a) : reaches f b c :=\nbegin\n  rw reaches₁_head'_iff at h₁, rcases h₁ with ⟨b', ⟨h₂', H⟩⟩,\n  cases part.mem_unique h₂ h₂', exact H,\nend\n\ntheorem reaches₁_single {σ} {f : σ →. option σ}\n  {a b} : some b ∈ f a → reaches₁ f a b :=\n@trans_gen.single σ _ a b\n\n/-- A variation on `reaches`. `reaches₀ f a b` holds if whenever `reaches₁ f b c` then\n`reaches₁ f a c`. This is a weaker property than `reaches` and is useful for replacing states with\nequivalent states without taking a step. -/\ndef reaches₀ {σ} (f : σ →. option σ) (a b : σ) : Prop :=\n∀ c, reaches₁ f b c → reaches₁ f a c\n\ntheorem reaches₀.trans {σ} {f : σ →. option σ} {a b c : σ}\n  (h₁ : reaches₀ f a b) (h₂ : reaches₀ f b c) : reaches₀ f a c\n| d h₃ := h₁ _ (h₂ _ h₃)\n\n@[refl] theorem reaches₀.refl {σ} {f : σ →. option σ} (a : σ) : reaches₀ f a a\n| b h := h\n\ntheorem reaches₀.single {σ} {f : σ →. option σ} {a b : σ}\n  (h : some b ∈ f a) : reaches₀ f a b\n| c h₂ := h₂.head h\n\ntheorem reaches₀.head {σ} {f : σ →. option σ} {a b c : σ}\n  (h : some b ∈ f a) (h₂ : reaches₀ f b c) : reaches₀ f a c :=\n(reaches₀.single h).trans h₂\n\ntheorem reaches₀.tail {σ} {f : σ →. option σ} {a b c : σ}\n  (h₁ : reaches₀ f a b) (h : some c ∈ f b) : reaches₀ f a c :=\nh₁.trans (reaches₀.single h)\n\ntheorem reaches₀_eq {σ} {f : σ →. option σ} {a b}\n  (e : f a = f b) : reaches₀ f a b\n| d h := (reaches₁_eq e).2 h\n\ntheorem reaches₁.to₀ {σ} {f : σ →. option σ} {a b : σ}\n  (h : reaches₁ f a b) : reaches₀ f a b\n| c h₂ := h.trans h₂\n\ntheorem reaches.to₀ {σ} {f : σ →. option σ} {a b : σ}\n  (h : reaches f a b) : reaches₀ f a b\n| c h₂ := h₂.trans_right h\n\ntheorem reaches₀.tail' {σ} {f : σ →. option σ} {a b c : σ}\n  (h : reaches₀ f a b) (h₂ : some c ∈ f b) : reaches₁ f a c :=\nh _ (trans_gen.single h₂)\n\n/-- (co-)Induction principle for `eval`. If a property `C` holds of any point `a` evaluating to `b`\nwhich is either terminal (meaning `a = b`) or where the next point also satisfies `C`, then it\nholds of any point where `eval f a` evaluates to `b`. This formalizes the notion that if\n`eval f a` evaluates to `b` then it reaches terminal state `b` in finitely many steps. -/\n@[elab_as_eliminator] def eval_induction {σ}\n  {f : σ →. option σ} {b : σ} {C : σ → Sort*} {a : σ} (h : b ∈ eval f a)\n  (H : ∀ a, b ∈ eval f a →\n    (∀ a', f a = part.some (some a') → C a') → C a) : C a :=\nby { dsimp only [eval] at *, exact pfun.fix_induction h (λ _ b ih, H _ b (λ _ ha, ih _ (by simp [ha]))) }\n\ntheorem mem_eval {σ} {f : σ →. option σ} {a b} :\n  b ∈ eval f a ↔ reaches f a b ∧ f b = part.some none :=\nbegin\n  split,\n  { intro h, \n    apply eval_induction h, clear h a, intros a hb ih,\n    have : (f a).dom := by simpa using pfun.dom_of_mem_fix hb, \n    rw part.dom_iff_mem at this,\n    rcases this with ⟨a'|a', ha'⟩, rw ← part.eq_some_iff at ha',\n    { rw [eval] at hb, cases (part.mem_unique hb (pfun.fix_stop a _) : b = a),\n      { exact ⟨by refl, ha'⟩, }, { simp [ha'], } },\n    specialize ih a' (by rwa part.eq_some_iff),\n    exact ⟨(reaches_fwd ha').trans ih.1, ih.2⟩, },\n  { rintro ⟨h₁, h₂⟩,\n    induction h₁ using relation.refl_trans_gen.head_induction_on with a' b' ha' hb ih,\n    { apply pfun.fix_stop, simp [h₂], },\n    rw [eval, pfun.fix_fwd _ b'], { exact ih, },\n    rw ← part.eq_some_iff at ha', simp [ha'], }\nend\n\nlemma eval_mono {σ} {f g : σ →. option σ} (hfg : ∀ ⦃x y⦄, y ∈ f x → y ∈ g x) {x y} (h : y ∈ eval f x) :\n  y ∈ eval g x :=\nby { rw [mem_eval, part.eq_some_iff] at *, exact ⟨reaches_mono' hfg h.1, hfg h.2⟩, }\n\nlemma eval_eq_of_invariant {σ} (f : σ →. option σ) (S : set σ) (hS : ∀ ⦃x y⦄, x ∈ S → some y ∈ f x → y ∈ S) {x} (hx : x ∈ S) :\n  eval f x = eval (f.res_inter S) x :=\nby { ext y, split, swap, { intro h, apply eval_mono _ h, simp, }, simp [mem_eval, part.eq_some_iff],\n     intros H₁ H₂, exact ⟨reaches_of_invariant S hS hx H₁, invariant_of_reaches _ hS hx H₁, H₂⟩, } \n\n@[simp] lemma eval_next_iter_eq_none {σ} (f : σ →. option σ) (a : σ) (h : (eval f a).dom) :\n  f ((eval f a).get h) = part.some none :=\nby { have := part.get_mem h, rw mem_eval at this, exact this.2, }\n\ntheorem eval_maximal₁ {σ} {f : σ →. option σ} {a b : σ}\n  (h : b ∈ eval f a) (c) : ¬ reaches₁ f b c | bc :=\nlet ⟨ab, b0⟩ := mem_eval.1 h, ⟨b', h', _⟩ := trans_gen.head'_iff.1 bc in\nby { rw b0 at h', simpa using h', }\n\ntheorem eval_maximal {σ} {f : σ →. option σ} {a b}\n  (h : b ∈ eval f a) {c} : reaches f b c ↔ c = b :=\nlet ⟨ab, b0⟩ := mem_eval.1 h in\nrefl_trans_gen_iff_eq $ λ b' h',\nby { rw b0 at h', simpa using h', }\n\ntheorem reaches_eval {σ} {f : σ →. option σ} {a b}\n  (ab : reaches f a b) : eval f a = eval f b :=\npart.ext $ λ c,\n ⟨λ h, let ⟨ac, c0⟩ := mem_eval.1 h in\n    mem_eval.2 ⟨(or_iff_left_of_imp $ by exact\n      λ cb, (eval_maximal h).1 cb ▸ refl_trans_gen.refl).1\n      (reaches_total ab ac), c0⟩,\n  λ h, let ⟨bc, c0⟩ := mem_eval.1 h in mem_eval.2 ⟨ab.trans bc, c0⟩,⟩\n\n/-- Given a relation `tr : σ₁ → σ₂ → Prop` between state spaces, and state transition functions\n`f₁ : σ₁ → option σ₁` and `f₂ : σ₂ → option σ₂`, `respects f₁ f₂ tr` means that if `tr a₁ a₂` holds\ninitially and `f₁` takes a step to `a₂` then `f₂` will take one or more steps before reaching a\nstate `b₂` satisfying `tr a₂ b₂`, and if `f₁ a₁` terminates then `f₂ a₂` also terminates.\nSuch a relation `tr` is also known as a refinement. -/\n-- def respects {σ₁ σ₂}\n--   (f₁ : σ₁ →. option σ₁) (f₂ : σ₂ →. option σ₂) (tr : σ₁ → σ₂ → Prop) :=\n-- ∀ ⦃a₁ a₂⦄, tr a₁ a₂ → (match f₁ a₁ with\n--   | part.none := f₂ a₂ = part.none \n--   | part.some (some b₁) := ∃ b₂, tr b₁ b₂ ∧ reaches₁ f₂ a₂ b₂\n--   | part.some none := f₂ a₂ = none\n--   end : Prop)\n\nstructure respects {σ₁ σ₂} (f₁ : σ₁ →. option σ₁) (f₂ : σ₂ →. option σ₂) (tr : σ₁ → σ₂ → Prop) : Prop :=\n(dom_of_dom : ∀ ⦃a₁ a₂⦄, tr a₁ a₂ → (f₂ a₂).dom → (f₁ a₁).dom)\n(some_of_some : ∀ ⦃a₁ a₂ b₁⦄, tr a₁ a₂ → some b₁ ∈ (f₁ a₁) → ∃ b₂, tr b₁ b₂ ∧ reaches₁ f₂ a₂ b₂)\n(none_of_none : ∀ ⦃a₁ a₂⦄, tr a₁ a₂ → none ∈ (f₁ a₁) → none ∈ (f₂ a₂))\n\nvariables {σ₁ σ₂ : Type*} {f₁ : σ₁ →. option σ₁} {f₂ : σ₂ →. option σ₂} {tr : σ₁ → σ₂ → Prop}\n\nlemma respects.exists_some {a₁ a₂ b₁} (H : respects f₁ f₂ tr) (aa : tr a₁ a₂) (hb₁ : some b₁ ∈ f₁ a₁) :\n  ∃ b₂, some b₂ ∈ f₂ a₂ :=\nby { obtain ⟨b₂, ⟨_, hb₂⟩⟩ := H.some_of_some aa hb₁, rw reaches₁_head'_iff at hb₂, tauto, }\n\nlemma respects.dom_iff_domm {a₁ a₂} (H : respects f₁ f₂ tr) (aa : tr a₁ a₂) :\n  (f₁ a₁).dom ↔ (f₂ a₂).dom :=\nbegin\n  refine ⟨λ h, _, H.dom_of_dom aa⟩,\n  rw [part.dom_iff_mem] at h ⊢, cases h with b₁ hb,\n  cases b₁,\n  { use none, exact H.none_of_none aa hb, },\n  { obtain ⟨b₂, hb₂⟩ := H.exists_some aa hb, exact ⟨_, hb₂⟩, }\nend\n\nlemma respects.none_iff_none {a₁ a₂} (H : respects f₁ f₂ tr) (aa : tr a₁ a₂) :\n  none ∈ f₁ a₁ ↔ none ∈ f₂ a₂ :=\nbegin\n  refine ⟨H.none_of_none aa, λ h, _⟩,\n  obtain ⟨x, hx⟩ : ∃ x, x ∈ f₁ a₁, { rw [← part.dom_iff_mem, H.dom_iff_domm aa, part.dom_iff_mem], exact ⟨_, h⟩, },\n  cases x, { exact hx, },\n  obtain ⟨_, hb⟩ := H.exists_some aa hx, cases part.mem_unique h hb,\nend\n\nlemma respects.some_iff_some {a₁ a₂} (H : respects f₁ f₂ tr) (aa : tr a₁ a₂) :\n  (∃ b₁, some b₁ ∈ f₁ a₁) ↔ (∃ b₂, some b₂ ∈ f₂ a₂) :=\nbegin\n  refine ⟨λ ⟨b₁, hb₁⟩, H.exists_some aa hb₁, _⟩,\n  rintro ⟨b₂, hb₂⟩,\n  obtain ⟨x, hx⟩ : ∃ x, x ∈ f₁ a₁, { rw [← part.dom_iff_mem, H.dom_iff_domm aa, part.dom_iff_mem], exact ⟨_, hb₂⟩, },\n  cases x, { rw H.none_iff_none aa at hx, cases part.mem_unique hb₂ hx, },\n  exact ⟨_, hx⟩,\nend \n\ntheorem tr_reaches₁\n  (H : respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₁} (ab : reaches₁ f₁ a₁ b₁) :\n  ∃ b₂, tr b₁ b₂ ∧ reaches₁ f₂ a₂ b₂ :=\nbegin\n  induction ab with c₁ ac c₁ d₁ ac cd IH,\n  { exact H.some_of_some aa ac, },\n  { rcases IH with ⟨c₂, cc, ac₂⟩,\n    obtain ⟨b₂, ⟨h₁, h₂⟩⟩ := H.some_of_some cc cd,\n    exact ⟨b₂, ⟨h₁, ac₂.trans h₂⟩⟩, }\nend\n\ntheorem tr_reaches {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop}\n  (H : respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₁} (ab : reaches f₁ a₁ b₁) :\n  ∃ b₂, tr b₁ b₂ ∧ reaches f₂ a₂ b₂ :=\nbegin\n  rcases refl_trans_gen_iff_eq_or_trans_gen.1 ab with rfl | ab,\n  { exact ⟨_, aa, refl_trans_gen.refl⟩ },\n  { exact let ⟨b₂, bb, h⟩ := tr_reaches₁ H aa ab in\n    ⟨b₂, bb, h.to_refl⟩ }\nend\n\ntheorem tr_reaches_rev {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop}\n  (H : respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) {b₂} (ab : reaches f₂ a₂ b₂) :\n  ∃ c₁ c₂, reaches f₂ b₂ c₂ ∧ tr c₁ c₂ ∧ reaches f₁ a₁ c₁ :=\nbegin\n  induction ab with a₂' a₂'' ha₂ ha₂' ih,\n  { refine ⟨a₁, a₂, _, aa, _⟩; refl, },\n  rcases ih with ⟨c₁, c₂, c₂h, trh, c₁h⟩,\n  by_cases H : c₂ = a₂',\n  { subst H, clear c₂h,\n    obtain ⟨c₁', hc₁'⟩ := (H.some_iff_some trh).mpr ⟨_, ha₂'⟩,\n    obtain ⟨c₂', hc₂, hc₂'⟩ := H.some_of_some trh hc₁', \n    exact ⟨c₁', c₂', reaches₁_fwd hc₂' ha₂', hc₂, c₁h.trans (reaches_fwd hc₁')⟩, },\n  refine ⟨c₁, c₂, _, trh, c₁h⟩,\n  simp_rw [reaches_iff_eq_or_reaches₁, H, false_or] at c₂h,\n  apply reaches₁_fwd c₂h ha₂',\nend\n\ntheorem tr_eval {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop}\n  (H : respects f₁ f₂ tr) {a₁ b₁ a₂} (aa : tr a₁ a₂)\n  (ab : b₁ ∈ eval f₁ a₁) : ∃ b₂, tr b₁ b₂ ∧ b₂ ∈ eval f₂ a₂ :=\nbegin\n  cases mem_eval.1 ab with ab b0,\n  rcases tr_reaches H aa ab with ⟨b₂, bb, ab⟩,\n  refine ⟨_, bb, mem_eval.2 ⟨ab, _⟩⟩,\n  rw part.eq_some_iff at ⊢ b0, rwa ← H.none_iff_none bb,\nend\n\ntheorem tr_eval_rev {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop}\n  (H : respects f₁ f₂ tr) {a₁ b₂ a₂} (aa : tr a₁ a₂)\n  (ab : b₂ ∈ eval f₂ a₂) : ∃ b₁, tr b₁ b₂ ∧ b₁ ∈ eval f₁ a₁ :=\nbegin\n  cases mem_eval.1 ab with ab b0,\n  rcases tr_reaches_rev H aa ab with ⟨c₁, c₂, bc, cc, ac⟩,\n  cases (refl_trans_gen_iff_eq _).1 bc,\n  swap, { intros _ h, rw b0 at h, simpa using h, },\n  refine ⟨_, cc, mem_eval.2 ⟨ac, _⟩⟩,\n  rw part.eq_some_iff at b0 ⊢, rwa H.none_iff_none cc,\nend\n\ntheorem tr_eval_dom {σ₁ σ₂ f₁ f₂} {tr : σ₁ → σ₂ → Prop}\n  (H : respects f₁ f₂ tr) {a₁ a₂} (aa : tr a₁ a₂) :\n  (eval f₂ a₂).dom ↔ (eval f₁ a₁).dom :=\n⟨λ h, let ⟨b₂, tr, h, _⟩ := tr_eval_rev H aa ⟨h, rfl⟩ in h,\n λ h, let ⟨b₂, tr, h, _⟩ := tr_eval H aa ⟨h, rfl⟩ in h⟩\n\n/-- A simpler version of `respects` when the state transition relation `tr` is a function. -/\nstructure frespects {σ₁ σ₂} (f₁ : σ₁ →. option σ₁) (f₂ : σ₂ →. option σ₂) (tr : σ₁ → σ₂) : Prop :=\n(dom_of_dom : ∀ ⦃a : σ₁⦄, (f₂ (tr a)).dom → (f₁ a).dom)\n(some_of_some : ∀ ⦃a b : σ₁⦄, some b ∈ f₁ a → reaches₁ f₂ (tr a) (tr b))\n(none_of_none : ∀ ⦃a⦄, none ∈ f₁ a → none ∈ f₂ (tr a))\n\n/-- An even simpler version where both take only one step each time -/\nstructure fcommutes {σ₁ σ₂} (f₁ : σ₁ →. option σ₁) (f₂ : σ₂ →. option σ₂) (tr : σ₁ → σ₂) : Prop :=\n(dom_of_dom : ∀ ⦃a : σ₁⦄, (f₂ (tr a)).dom → (f₁ a).dom)\n(some_of_some : ∀ ⦃a b : σ₁⦄, some b ∈ f₁ a → some (tr b) ∈ f₂ (tr a))\n(none_of_none : ∀ ⦃a⦄, none ∈ f₁ a → none ∈ f₂ (tr a))\n\nvariable {ftr : σ₁ → σ₂}\ntheorem fcommutes.to_frespects (H : fcommutes f₁ f₂ ftr) : frespects f₁ f₂ ftr :=\n{ dom_of_dom := H.dom_of_dom,\n  some_of_some := λ a b h, by { apply reaches₁_single, exact H.some_of_some h, },\n  none_of_none := H.none_of_none }\n\nlemma fcommutes.some_of_some' (H : fcommutes f₁ f₂ ftr) {a b : σ₁} \n  (h : some (ftr b) ∈ f₂ (ftr a)) :\n  ∃ y, ftr y = ftr b ∧ some y ∈ f₁ a :=\nbegin\n  obtain ⟨y, hy⟩ := part.dom_iff_mem.mp (H.dom_of_dom (part.dom_iff_mem.mpr ⟨_, h⟩)),\n  cases y, { cases part.mem_unique h (H.none_of_none hy), },\n  refine ⟨_, _, hy⟩, exact (option.some.inj (part.mem_unique h (H.some_of_some hy))).symm,\nend\n\ntheorem fun_respects : respects f₁ f₂ (λ a b, ftr a = b) ↔ frespects f₁ f₂ ftr :=\nbegin\n  split,\n  { intro H,\n    refine ⟨λ a, H.dom_of_dom rfl, λ a b hab, _, λ a ha, H.none_of_none rfl ha⟩, \n    simpa using H.some_of_some rfl hab, },\n  { intro H,\n    refine ⟨_, _, _⟩, { rintro a₁ a₂ rfl h, exact H.dom_of_dom h, },\n    { rintro a₁ a₂ b₁ rfl h, exact ⟨_, rfl, H.some_of_some h⟩, },\n    rintro a₁ a₂ rfl h, exact H.none_of_none h, }\nend\n\nlemma frespects.dom_iff_dom (H : frespects f₁ f₂ ftr) ⦃x : σ₁⦄ :\n  (f₁ x).dom ↔ (f₂ (ftr x)).dom :=\nrespects.dom_iff_domm (fun_respects.mpr H) rfl\n-- f(g(x)) = x\n-- S(g(a)) -->  a' \n-- g(a)  --> a\n-- theorem fcommutes.symm (H : fcommutes f₁ f₂ ftr) {ftr_inv : σ₂ → σ₁} (hinv : function.right_inverse ftr_inv ftr) :\n--   fcommutes f₂ f₁ ftr_inv :=\n-- { dom_of_dom := λ a, by simp [(fun_respects.mpr H.to_frespects).dom_iff_domm (hinv a)],\n--   some_of_some := λ a b h,\n-- begin\n--   rw [← hinv b, ← hinv a] at h, have := H.some_of_some' h,\n-- end,\n--   none_of_none := _ }\n\ntheorem frespects.eval_eq (H : frespects f₁ f₂ ftr)\n  (a₁ : σ₁) : eval f₂ (ftr a₁) = (eval f₁ a₁).map ftr :=\nbegin\n  rw ← fun_respects at H,\n  apply part.ext', { exact tr_eval_dom H rfl, },\n  intros h₂ h₁, simp at h₁,\n  have := tr_eval H rfl (part.get_mem h₁),\n  simp at this ⊢, rwa part.get_eq_iff_mem,\nend\n\ntheorem frespects.of_eval (H : frespects f₁ f₂ ftr)\n  {a b : σ₁} (h : b ∈ eval f₁ a) : (ftr b) ∈ eval f₂ (ftr a) :=\nby { rw H.eval_eq, exact part.mem_map ftr h, }\n\ntheorem frespects.none_iff_none (H : frespects f₁ f₂ ftr) (a : σ₁) :\n  none ∈ f₁ a ↔ none ∈ f₂ (ftr a) :=\nby { rw ← fun_respects at H, rw H.none_iff_none rfl, }\n\ntheorem frespects.eval_dom (H : frespects f₁ f₂ ftr) (x : σ₁) :\n  (eval f₂ (ftr x)).dom ↔ (eval f₁ x).dom := by simp [H.eval_eq]\n\ntheorem frespects.eval_get_eq (H : frespects f₁ f₂ ftr) (a : σ₁) :\n  ∀ h, ftr ((eval f₁ a).get h) = (eval f₂ (ftr a)).get (by rwa H.eval_dom) :=\nby { intros, simp [H.eval_eq], refl, }\n\nsection track_with\nvariables {σ α : Type*} (f : σ →. option σ) (t : σ →. ℕ)\n\ndef with_time : ℕ × σ →. option (ℕ × σ) :=\nλ tx, (f tx.2).bind (λ r₁, (t tx.2).bind (λ r₂ : ℕ, part.some (r₁.map $ λ r₁', (tx.1 + r₂, r₁'))))\n\ntheorem with_time_respects {f : σ →. option σ} {t : σ →. ℕ} (ht : ∀ x, (t x).dom ↔ (f x).dom) : frespects (with_time f t) f prod.snd :=\n{ dom_of_dom := λ a, by simp [with_time, ht],\n  some_of_some := λ ⟨a₁, x₁⟩ ⟨a₂, x₂⟩ h, by { apply reaches₁_single, simp [with_time] at h, rcases h with ⟨_, h, _, _, rfl, rfl⟩, exact h, },\n  none_of_none := λ ⟨a, x⟩, by { simp [with_time], exact λ h _ _, h, } }\n\ntheorem with_time_respects_self (n : ℕ) : frespects (with_time f t) (with_time f t) (prod.map (+n) id) :=\n{ dom_of_dom := λ a, by { simp [with_time], exact and.intro, },\n  some_of_some := λ ⟨a₁, x₁⟩ ⟨a₂, x₂⟩ h, \nbegin\n  apply reaches₁_single,\n  simp [with_time] at h ⊢,\n  rcases h with ⟨a, ha, t, ht₁, rfl, rfl⟩,\n  exact ⟨_, ha, t, ht₁, rfl, by ac_refl⟩,\nend,\n  none_of_none := by { simp [with_time], tauto, } }\n\ndef time_iter : σ →. ℕ :=\nλ s, (eval (with_time f t) (0, s)).bind (λ r, (t r.2).map (+r.1))\n\nvariables {f t}\nlemma with_time_restrict (S : set σ) :\n  with_time (f.res_inter S) t = (with_time f t).res_inter (prod.snd⁻¹' S) :=\nby { ext, simp [with_time], tauto, }\n\ntheorem time_iter_dom_iff (ht : ∀ x, (t x).dom ↔ (f x).dom) {x} :\n  (time_iter f t x).dom ↔ (eval f x).dom :=\nbegin\n  simp [time_iter],\n  have := with_time_respects ht,\n  simp_rw [← this.eval_dom (0, x), this.eval_get_eq (0, x), ht, eval_next_iter_eq_none f x], simp,\nend\n\nlemma with_time_mono {g : σ →. option σ} (hfg : ∀ ⦃x y⦄, y ∈ f x → y ∈ g x) :\n  ∀ ⦃x y⦄, y ∈ with_time f t x → y ∈ with_time g t x := by { simp [with_time], tauto, }\n\nlemma time_iter_mono {g : σ →. option σ} (hfg : ∀ ⦃x y⦄, y ∈ f x → y ∈ g x) {x y} (hx : y ∈ time_iter f t x) :\n  y ∈ time_iter g t x :=\nbegin\n  simp [time_iter] at hx ⊢, rcases hx with ⟨a, b, h₁, ⟨a', h₂, rfl⟩⟩,\n  refine ⟨a, b, _, ⟨a', h₂, rfl⟩⟩, apply eval_mono (with_time_mono hfg) h₁,\nend\n\ntheorem time_iter_eq_iff (ht : ∀ x, (t x).dom ↔ (f x).dom) (x : σ) (n : ℕ) :\n  n ∈ time_iter f t x ↔ ∃ t' b, reaches (with_time f t) (0, x) (t', b) ∧ none ∈ f b ∧ n ∈ (+t') <$> (t b) :=\nbegin\n  simp [time_iter, mem_eval],\n  apply exists₂_congr, intros a b,\n  conv_lhs { rw and_assoc, }, apply and_congr, { refl, },\n  apply and_congr, { rw ← (with_time_respects ht).none_iff_none (a, b), exact part.eq_some_iff, }, { refl, },\nend\n\n\nlemma time_iter_invariant {g : σ →. option σ} (S : set σ) (hS : ∀ ⦃x y⦄, x ∈ S → some y ∈ g x → y ∈ S) {x} (hx : x ∈ S) :\n  time_iter g t x = time_iter (g.res_inter S) t x :=\nbegin\n  simp only [time_iter], rw eval_eq_of_invariant (with_time g t) (prod.snd⁻¹' S), { simp [with_time_restrict], },\n  { rintros ⟨x₁, x₂⟩ ⟨y₁, y₂⟩, simp [with_time], rintros hx₂ x' hx' t' ht' rfl rfl, exact hS hx₂ hx', },\n  simpa, \nend\n\ntheorem time_iter_eq_iff_of_eval (ht : ∀ x, (t x).dom ↔ (f x).dom) {x n b} (hb : b ∈ eval f x) :\n  n ∈ time_iter f t x ↔ ∃ t', reaches (with_time f t) (0, x) (t', b) ∧ none ∈ f b ∧ n ∈ (+t') <$> (t b) :=\nbegin\n  suffices : ∀ {t' b'}, reaches (with_time f t) (0, x) (t', b') → none ∈ f b' → b = b',\n  { rw time_iter_eq_iff ht, apply exists_congr, intro n, split, { rintro ⟨b, h₁, h₂, h₃⟩, cases this h₁ h₂, tauto, }, intro, use b, tauto, },\n  intros n b' h₁ h₂, rw [← (with_time_respects ht).none_iff_none (n, b'), ← part.eq_some_iff] at h₂,\n  exact part.mem_unique hb ((with_time_respects ht).of_eval (mem_eval.mpr ⟨h₁, h₂⟩)),\nend\n\n@[simp] lemma one_def : (1 : part ℕ) = part.some 1 := rfl\n\nlemma time_eval_const_respects (ht : ∀ ⦃x⦄, (f x).dom → (t x).dom) (J : ℕ) :\n  respects (with_time (f.res_inter {s | ∀ k ∈ t s, k ≤ J}) (λ _, 1))\n           (with_time (f.res_inter {s | ∀ k ∈ t s, k ≤ J}) t) \n           (λ s₁ s₂, s₁.2 = s₂.2 ∧ s₂.1 ≤ J * s₁.1) :=\n{ dom_of_dom := by { rintro ⟨t₁, s⟩ ⟨t₂, s⟩, dsimp only, rintro ⟨rfl, _⟩, simp [with_time], tauto, },\n  some_of_some := \nbegin\n  rintro ⟨t₁, s₁⟩ ⟨t₂, s₁⟩ ⟨t₃, s₂⟩, dsimp only, rintro ⟨rfl, hb⟩,\n  simp [with_time], rintros s₂' hs hn rfl rfl, \n  rcases part.dom_iff_mem.mp (ht (part.dom_iff_mem.mpr ⟨_, hn⟩)) with ⟨tn, htn⟩,\n  use [t₂ + tn, s₂, rfl], { mono, }, apply reaches₁_single, simp, refine ⟨⟨_, _⟩, _⟩; assumption,\nend,\n  none_of_none :=\nbegin\n  rintro ⟨t₁, s₁⟩ ⟨t₂, s₁⟩, dsimp only, rintro ⟨rfl, _⟩,\n  simp [with_time, ← part.dom_iff_mem],\n  refine λ h₁ h₂, ⟨⟨h₁, h₂⟩, ht _⟩, rw part.dom_iff_mem, exact ⟨_, h₂⟩,\nend }\n\nlemma with_time_le_of_iters_le {x : σ} {n J : ℕ} (ht : ∀ x, (f x).dom → (t x).dom)\n  (h : n ∈ time_iter (f.res_inter {s | ∀ k ∈ t s, k ≤ J}) (pfun.pure 1) x) :\n  ∃ k ∈ time_iter f t x, k ≤ n * J :=\nbegin\n  simp [time_iter, pfun.pure] at h, rcases h with ⟨n, ⟨⟨s, hs⟩, rfl⟩⟩,\n  obtain ⟨⟨tf, sf⟩, h₁, h₂⟩ := tr_eval (time_eval_const_respects ht J) _ hs, swap, { use (0, x), }, swap, { split; refl, },\n  dsimp only at h₁, rcases h₁ with ⟨rfl, h₁⟩,\n  simp [time_iter],\n  obtain ⟨tl, htl, tl_le⟩ : ∃ tl ∈ t s, tl ≤ J,\n  { rw mem_eval at h₂, rcases h₂ with ⟨_, h₂⟩, simp [part.eq_some_iff, with_time] at h₂,\n    rcases h₂ with ⟨⟨H, _⟩, ⟨tl, htl⟩⟩, use [tl, htl, H _ htl], },\n  refine ⟨tf + tl, ⟨⟨tf, s, _, ⟨tl, htl, by ac_refl⟩⟩, _⟩⟩,\n  { apply eval_mono (with_time_mono _) h₂, simp, },\n  conv_rhs { rw [add_mul, add_comm], }, mono, { rw mul_comm, exact h₁, }, simpa using tl_le,\nend\n\ntheorem fcommutes.to_time_frespects (H : fcommutes f₁ f₂ ftr) :\n  fcommutes (with_time f₁ (pfun.pure 1)) (with_time f₂ (pfun.pure 1)) (prod.map id ftr) :=\n{ dom_of_dom := by { simpa [with_time, pfun.pure] using H.dom_of_dom, },\n  some_of_some :=\nbegin\n  simp [with_time, pfun.pure], rintro a₁ b₁ ⟨a₂, b₂⟩ x hx x rfl,\n  simp, rintro rfl rfl, refine ⟨some (ftr x), _, rfl, rfl⟩,\n  exact H.some_of_some hx, \nend,\n  none_of_none := by simpa [with_time, pfun.pure] using H.none_of_none }\n\ntheorem eq_time_of_fcommutes (H : fcommutes f₁ f₂ ftr) (x : σ₁) :\n  time_iter f₁ (pfun.pure 1) x = time_iter f₂ (pfun.pure 1) (ftr x) :=\nbegin\n  have := H.to_time_frespects.to_frespects.eval_eq, simp [pfun.pure] at this, \n  simp [time_iter, this, pfun.pure],\nend\n\ntheorem fcommutes.restrict (H : fcommutes f₁ f₂ ftr) (S : set σ₂) :\n  fcommutes (f₁.res_inter (ftr⁻¹' S)) (f₂.res_inter S) ftr :=\n{ dom_of_dom := λ x, by { simp, rw ← H.to_frespects.dom_iff_dom, tauto, },\n  some_of_some := λ a b, by { simp, intros h₁ h₂, exact ⟨h₁, H.some_of_some h₂⟩, },\n  none_of_none := λ a, by { simp, intros h₁ h₂, exact ⟨h₁, H.none_of_none h₂⟩, } } \n\nend track_with\n\nend part_eval", "meta": {"author": "prakol16", "repo": "lean_complexity_theory_polytime_trees", "sha": "4f478b752a2061cd829bf83a68c77180d1318b62", "save_path": "github-repos/lean/prakol16-lean_complexity_theory_polytime_trees", "path": "github-repos/lean/prakol16-lean_complexity_theory_polytime_trees/lean_complexity_theory_polytime_trees-4f478b752a2061cd829bf83a68c77180d1318b62/src/reaches.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.46806292480719003}}
{"text": "/- Copying out split_ifs from mathlib so I can understand it. -/\n\nopen expr tactic\n\nnamespace tactic\nopen interactive\n\n-- meta def fold_test (e : expr) : tactic unit :=\n--     trace $ expr.fold e [] (λ e n l, (e,n) :: l)\n-- constant α : Type\n-- constant f : α → α\n-- example : true := \n-- begin\n--   (to_expr ```(λ x : α, (λ y, x) $ f $ f x) >>= fold_test)\n-- end\n\n/-- Returns the condition of a  -/\nmeta def find_if_cond : expr → option expr | e := -- note the `| e` style.\ne.fold none $ λ e _ acc, acc <|> do\n    c ← match e with\n        | `(@ite %%c %%_ _ _ _) := some c\n        | `(@dite %%c %%_ _ _ _) := some c\n        | _ := none\n        end,\n    guard ¬c.has_var,\n    find_if_cond c <|> -- Why does this need to be recursive?\n    return c \n\n/-- Find an if condition at one of the locations. -/\nmeta def find_if_cond_at (at_ : loc) : tactic (option expr) := do\nlctx ← at_.get_locals, -- get the local context\nlctx ← lctx.mmap infer_type, --get the types\ntgt ← target,\nlet es := if at_.include_goal then tgt::lctx else lctx,\npure $ find_if_cond $ es.foldr app (default expr) -- jam all of the terms into one giant expression and run find_if_cond on it.\n\n-- make a new simp attribute called \"split_if_reduction\"\nrun_cmd mk_simp_attr `split_if_reduction\n-- Add \"split_if_reduction\" attributes to these if-reductions\nattribute [split_if_reduction] if_pos if_neg dif_pos dif_neg\n\nmeta def reduce_ifs_at (at_ : loc) : tactic unit := do\nsls ← get_user_simp_lemmas `split_if_reduction,\nlet cfg : simp_config := { fail_if_unchanged := ff },\nlet discharger := assumption <|> (applyc `not_not_intro >> assumption),\nhs ← at_.get_locals, \nhs.mmap' (λ h, simp_hyp sls [] h cfg discharger >> skip),\nwhen at_.include_goal (simp_target sls [] cfg discharger)\n\n/-- Perform an if-split with the condition `c`, give the new hypothesis the name `n`. -/\nmeta def split_if1 (c : expr) (n : name) (at_ : loc) : tactic unit := \nby_cases c n *> reduce_ifs_at at_\n\n/--Pull a name from a ref list and use that, otherwise get a boring fresh name. -/\nprivate meta def get_next_name (names : ref (list name)) : tactic name := do\nns ← read_ref names,\nmatch ns with\n| [] := get_unused_name `h\n| (n::ns) := do write_ref names ns, return n \nend\n\n/-- Check that the given condition isn't already in the local context. -/\nprivate meta def value_known (c : expr) : tactic bool :=\n(find_assumption c $> tt)\n<|> (find_assumption `(¬%%c) $> tt)\n<|> (pure ff)\n\nprivate meta def split_ifs_core (at_: loc) (names : ref (list name)) : list expr → tactic unit := λ done, do\nsome cond ← find_if_cond_at at_ | fail \"no ite or dite expressions found\",\nlet cond := match cond with `(¬%%p) := p | p := p end, -- strip off the ¬\nif cond ∈ done then skip else do -- skip conditions which have already been done.\nno_split ← value_known cond,\nif no_split then do\n    reduce_ifs_at at_,\n    try (split_ifs_core (cond :: done)) \nelse do\n    n ← get_next_name names, -- pull a new name off the shelf.\n    split_if1 cond n at_,\n    try (split_ifs_core (cond :: done))\n\nmeta def split_ifs (names : list name) (at_ : loc := loc.ns [none]) /-by default do the target.-/ :=\nusing_new_ref names $ λ names, split_ifs_core at_ names []\n\nnamespace interactive\nopen interactive.types\n/-- Splits all if-then-else-expressions into multiple goals.\n\nGiven a goal of the form `g (if p then x else y)`, `split_ifs` will produce\ntwo goals: `p ⊢ g x` and `¬p ⊢ g y`.\n\nIf there are multiple ite-expressions, then `split_ifs` will split them all,\nstarting with a top-most one whose condition does not contain another\nite-expression.\n\n`split_ifs at *` splits all ite-expressions in all hypotheses as well as the goal.\n\n`split_ifs with h₁ h₂ h₃` overrides the default names for the hypotheses.\n-/\nmeta def split_ifs (at_ : parse location) (names : parse with_ident_list) : tactic unit :=\ntactic.split_ifs names at_\n\nend interactive\nend tactic", "meta": {"author": "EdAyers", "repo": "edlib", "sha": "78b8c5d91f023f939c102837d748868e2f3ed27d", "save_path": "github-repos/lean/EdAyers-edlib", "path": "github-repos/lean/EdAyers-edlib/edlib-78b8c5d91f023f939c102837d748868e2f3ed27d/split_ifs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185944046238981, "lm_q2_score": 0.6513548714339144, "lm_q1q2_score": 0.4680599660369294}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\n! This file was ported from Lean 3 source module algebra.group_ring_action.basic\n! leanprover-community/mathlib commit 207cfac9fcd06138865b5d04f7091e46d9320432\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Ring.Equiv\nimport Mathlib.Algebra.Field.Defs\nimport Mathlib.GroupTheory.GroupAction.Group\n\n/-!\n# Group action on rings\n\nThis file defines the typeclass of monoid acting on semirings `MulSemiringAction M R`,\nand the corresponding typeclass of invariant subrings.\n\nNote that `Algebra` does not satisfy the axioms of `MulSemiringAction`.\n\n## Implementation notes\n\nThere is no separate typeclass for group acting on rings, group acting on fields, etc.\nThey are all grouped under `MulSemiringAction`.\n\n## Tags\n\ngroup action, invariant subring\n\n-/\n\n\nuniverse u v\n\n/-- Typeclass for multiplicative actions by monoids on semirings.\n\nThis combines `DistribMulAction` with `MulDistribMulAction`. -/\nclass MulSemiringAction (M : Type u) (R : Type v) [Monoid M] [Semiring R] extends\n  DistribMulAction M R where\n  /-- Multipliying `1` by a scalar gives `1` -/\n  smul_one : ∀ g : M, (g • (1 : R) : R) = 1\n  /-- Scalara multiplication distributes across multiplication -/\n  smul_mul : ∀ (g : M) (x y : R), g • (x * y) = g • x * g • y\n#align mul_semiring_action MulSemiringAction\n\nsection Semiring\n\nvariable (M N G : Type _) [Monoid M] [Monoid N] [Group G]\n\nvariable (A R S F : Type v) [AddMonoid A] [Semiring R] [CommSemiring S] [DivisionRing F]\n\n-- note we could not use `extends` since these typeclasses are made with `old_structure_cmd`\ninstance (priority := 100) MulSemiringAction.toMulDistribMulAction [h : MulSemiringAction M R] :\n    MulDistribMulAction M R :=\n  { h with }\n#align mul_semiring_action.to_mul_distrib_mul_action MulSemiringAction.toMulDistribMulAction\n\n/-- Each element of the monoid defines a semiring homomorphism. -/\n@[simps!]\ndef MulSemiringAction.toRingHom [MulSemiringAction M R] (x : M) : R →+* R :=\n  { MulDistribMulAction.toMonoidHom R x, DistribMulAction.toAddMonoidHom R x with }\n#align mul_semiring_action.to_ring_hom MulSemiringAction.toRingHom\n#align mul_semiring_action.to_ring_hom_apply MulSemiringAction.toRingHom_apply\n\ntheorem toRingHom_injective [MulSemiringAction M R] [FaithfulSMul M R] :\n    Function.Injective (MulSemiringAction.toRingHom M R) := fun _ _ h =>\n  eq_of_smul_eq_smul fun r => RingHom.ext_iff.1 h r\n#align to_ring_hom_injective toRingHom_injective\n\n/-- Each element of the group defines a semiring isomorphism. -/\n@[simps!]\ndef MulSemiringAction.toRingEquiv [MulSemiringAction G R] (x : G) : R ≃+* R :=\n  { DistribMulAction.toAddEquiv R x, MulSemiringAction.toRingHom G R x with }\n#align mul_semiring_action.to_ring_equiv MulSemiringAction.toRingEquiv\n#align mul_semiring_action.to_ring_equiv_symm_apply MulSemiringAction.toRingEquiv_symm_apply\n#align mul_semiring_action.to_ring_equiv_apply MulSemiringAction.toRingEquiv_apply\n\nsection\n\nvariable {M N}\n\n/-- Compose a `MulSemiringAction` with a `MonoidHom`, with action `f r' • m`.\nSee note [reducible non-instances]. -/\n@[reducible]\ndef MulSemiringAction.compHom (f : N →* M) [MulSemiringAction M R] : MulSemiringAction N R :=\n  { DistribMulAction.compHom R f, MulDistribMulAction.compHom R f with smul := SMul.comp.smul f }\n#align mul_semiring_action.comp_hom MulSemiringAction.compHom\n\nend\n\nsection SimpLemmas\n\nvariable {M G A R F}\n\nattribute [simp] smul_one smul_mul' smul_zero smul_add\n\n/-- Note that `smul_inv'` refers to the group case, and `smul_inv` has an additional inverse\non `x`. -/\n@[simp]\ntheorem smul_inv'' [MulSemiringAction M F] (x : M) (m : F) : x • m⁻¹ = (x • m)⁻¹ :=\n  map_inv₀ (MulSemiringAction.toRingHom M F x) _\n#align smul_inv'' smul_inv''\n\nend SimpLemmas\n\nend Semiring\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Algebra/GroupRingAction/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4680599630494681}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport control.functor\nimport data.sum.basic\n\n/-!\n# Functors with two arguments\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines bifunctors.\n\nA bifunctor is a function `F : Type* → Type* → Type*` along with a bimap which turns `F α β` into\n`F α' β'` given two functions `α → α'` and `β → β'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') ∘ (bimap f g) = bimap (f' ∘ f) (g' ∘ g)`\n\n## Main declarations\n\n* `bifunctor`: A typeclass for the bare bimap of a bifunctor.\n* `is_lawful_bifunctor`: A typeclass asserting this bimap respects the bifunctor laws.\n-/\n\nuniverses u₀ u₁ u₂ v₀ v₁ v₂\n\nopen function\n\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass bifunctor (F : Type u₀ → Type u₁ → Type u₂) :=\n(bimap : Π {α α' β β'}, (α → α') → (β → β') → F α β → F α' β')\nexport bifunctor ( bimap )\n\n/-- Bifunctor. This typeclass asserts that a lawless `bifunctor` is lawful. -/\nclass is_lawful_bifunctor (F : Type u₀ → Type u₁ → Type u₂) [bifunctor F] :=\n(id_bimap : Π {α β} (x : F α β), bimap id id x = x)\n(bimap_bimap : Π {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂)\n  (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀),\n  bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x)\n\nexport is_lawful_bifunctor (id_bimap bimap_bimap)\n\nattribute [higher_order bimap_id_id] id_bimap\nattribute [higher_order bimap_comp_bimap] bimap_bimap\n\nexport is_lawful_bifunctor (bimap_id_id bimap_comp_bimap)\nvariables {F : Type u₀ → Type u₁ → Type u₂} [bifunctor F]\n\nnamespace bifunctor\n\n/-- Left map of a bifunctor. -/\n@[reducible] def fst {α α' β} (f : α → α') : F α β → F α' β := bimap f id\n\n/-- Right map of a bifunctor. -/\n@[reducible] def snd {α β β'} (f : β → β') : F α β → F α β' := bimap id f\n\nvariable [is_lawful_bifunctor F]\n\n@[higher_order fst_id]\nlemma id_fst : Π {α β} (x : F α β), fst id x = x :=\n@id_bimap _ _ _\n\n@[higher_order snd_id]\nlemma id_snd : Π {α β} (x : F α β), snd id x = x :=\n@id_bimap _ _ _\n\n@[higher_order fst_comp_fst]\n\n\n@[higher_order fst_comp_snd]\nlemma fst_snd {α₀ α₁ β₀ β₁}\n  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n  fst f (snd f' x) = bimap f f' x :=\nby simp [fst,bimap_bimap]\n\n@[higher_order snd_comp_fst]\nlemma snd_fst {α₀ α₁ β₀ β₁}\n  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n  snd f' (fst f x) = bimap f f' x :=\nby simp [snd,bimap_bimap]\n\n@[higher_order snd_comp_snd]\nlemma comp_snd {α β₀ β₁ β₂}\n  (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α β₀) :\n  snd g' (snd g x) = snd (g' ∘ g) x :=\nby simp [snd,bimap_bimap]\n\nattribute [functor_norm] bimap_bimap comp_snd comp_fst\n  snd_comp_snd snd_comp_fst fst_comp_snd fst_comp_fst bimap_comp_bimap\n  bimap_id_id fst_id snd_id\n\nend bifunctor\nopen functor\ninstance : bifunctor prod :=\n{ bimap := @prod.map }\n\ninstance : is_lawful_bifunctor prod :=\nby refine { .. }; intros; cases x; refl\n\ninstance bifunctor.const : bifunctor const :=\n{ bimap := (λ α α' β β f _, f) }\n\ninstance is_lawful_bifunctor.const : is_lawful_bifunctor const  :=\nby refine { .. }; intros; refl\n\ninstance bifunctor.flip : bifunctor (flip F) :=\n{ bimap := (λ α α' β β' f f' x, (bimap f' f x : F β' α')) }\n\ninstance is_lawful_bifunctor.flip [is_lawful_bifunctor F] : is_lawful_bifunctor (flip F)  :=\nby refine { .. }; intros; simp [bimap] with functor_norm\n\ninstance : bifunctor sum :=\n{ bimap := @sum.map }\n\ninstance : is_lawful_bifunctor sum :=\nby refine { .. }; intros; cases x; refl\n\nopen bifunctor functor\n\n@[priority 10]\ninstance bifunctor.functor {α} : functor (F α) :=\n{ map := λ _ _, snd }\n\n@[priority 10]\ninstance bifunctor.is_lawful_functor [is_lawful_bifunctor F] {α} : is_lawful_functor (F α) :=\nby refine {..}; intros; simp [functor.map] with functor_norm\n\nsection bicompl\n\nvariables (G : Type* → Type u₀) (H : Type* → Type u₁) [functor G] [functor H]\n\ninstance : bifunctor (bicompl F G H) :=\n{ bimap := λ α α' β β' f f' x, (bimap (map f) (map f') x : F (G α') (H β')) }\n\ninstance [is_lawful_functor G]  [is_lawful_functor H] [is_lawful_bifunctor F] :\n  is_lawful_bifunctor (bicompl F G H) :=\nby constructor; intros; simp [bimap,map_id,map_comp_map] with functor_norm\n\nend bicompl\nsection bicompr\n\nvariables (G : Type u₂ → Type*) [functor G]\n\ninstance : bifunctor (bicompr G F) :=\n{ bimap := λ α α' β β' f f' x, (map (bimap f f') x : G (F α' β')) }\n\ninstance [is_lawful_functor G] [is_lawful_bifunctor F] :\n  is_lawful_bifunctor (bicompr G F) :=\nby constructor; intros; simp [bimap] with functor_norm\n\nend bicompr\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/control/bifunctor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7185943985973772, "lm_q1q2_score": 0.4680599572481793}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.group.pi\nimport Mathlib.algebra.big_operators.order\nimport Mathlib.algebra.module.basic\nimport Mathlib.group_theory.submonoid.basic\nimport Mathlib.data.fintype.card\nimport Mathlib.data.finset.preimage\nimport Mathlib.data.multiset.antidiagonal\nimport Mathlib.data.indicator_function\nimport Mathlib.PostPort\n\nuniverses u_13 u_14 l u_1 u_5 u_7 u_2 u_8 u_6 u_11 u_12 u_9 u_4 u_3 \n\nnamespace Mathlib\n\n/-!\n\n# Type of functions with finite support\n\nFor any type `α` and a type `M` with zero, we define the type `finsupp α M` (notation: `α →₀ M`)\nof finitely supported functions from `α` to `M`, i.e. the functions which are zero everywhere\non `α` except on a finite set.\n\nFunctions with finite support are used (at least) in the following parts of the library:\n\n* `monoid_algebra R M` and `add_monoid_algebra R M` are defined as `M →₀ R`;\n\n* polynomials and multivariate polynomials are defined as `add_monoid_algebra`s, hence they use\n  `finsupp` under the hood;\n\n* the linear combination of a family of vectors `v i` with coefficients `f i` (as used, e.g., to\n  define linearly independent family `linear_independent`) is defined as a map\n  `finsupp.total : (ι → M) → (ι →₀ R) →ₗ[R] M`.\n\nSome other constructions are naturally equivalent to `α →₀ M` with some `α` and `M` but are defined\nin a different way in the library:\n\n* `multiset α ≃+ α →₀ ℕ`;\n* `free_abelian_group α ≃+ α →₀ ℤ`.\n\nMost of the theory assumes that the range is a commutative additive monoid. This gives us the big\nsum operator as a powerful way to construct `finsupp` elements.\n\nMany constructions based on `α →₀ M` use `semireducible` type tags to avoid reusing unwanted type\ninstances. E.g., `monoid_algebra`, `add_monoid_algebra`, and types based on these two have\nnon-pointwise multiplication.\n\n## Notations\n\nThis file adds `α →₀ M` as a global notation for `finsupp α M`. We also use the following convention\nfor `Type*` variables in this file\n\n* `α`, `β`, `γ`: types with no additional structure that appear as the first argument to `finsupp`\n  somewhere in the statement;\n\n* `ι` : an auxiliary index type;\n\n* `M`, `M'`, `N`, `P`: types with `has_zero` or `(add_)(comm_)monoid` structure; `M` is also used\n  for a (semi)module over a (semi)ring.\n\n* `G`, `H`: groups (commutative or not, multiplicative or additive);\n\n* `R`, `S`: (semi)rings.\n\n## TODO\n\n* This file is currently ~2K lines long, so possibly it should be splitted into smaller chunks;\n\n* Add the list of definitions and important lemmas to the module docstring.\n\n## Implementation notes\n\nThis file is a `noncomputable theory` and uses classical logic throughout.\n\n## Notation\n\nThis file defines `α →₀ β` as notation for `finsupp α β`.\n\n-/\n\n/-- `finsupp α M`, denoted `α →₀ M`, is the type of functions `f : α → M` such that\n  `f x = 0` for all but finitely many `x`. -/\nstructure finsupp (α : Type u_13) (M : Type u_14) [HasZero M] where\n  support : finset α\n  to_fun : α → M\n  mem_support_to_fun : ∀ (a : α), a ∈ support ↔ to_fun a ≠ 0\n\ninfixr:25 \" →₀ \" => Mathlib.finsupp\n\nnamespace finsupp\n\n\n/-! ### Basic declarations about `finsupp` -/\n\nprotected instance has_coe_to_fun {α : Type u_1} {M : Type u_5} [HasZero M] :\n    has_coe_to_fun (α →₀ M) :=\n  has_coe_to_fun.mk (fun (_x : α →₀ M) => α → M) to_fun\n\n@[simp] theorem coe_mk {α : Type u_1} {M : Type u_5} [HasZero M] (f : α → M) (s : finset α)\n    (h : ∀ (a : α), a ∈ s ↔ f a ≠ 0) : ⇑(mk s f h) = f :=\n  rfl\n\nprotected instance has_zero {α : Type u_1} {M : Type u_5} [HasZero M] : HasZero (α →₀ M) :=\n  { zero := mk ∅ (fun (_x : α) => 0) sorry }\n\n@[simp] theorem coe_zero {α : Type u_1} {M : Type u_5} [HasZero M] : ⇑0 = fun (_x : α) => 0 := rfl\n\ntheorem zero_apply {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} : coe_fn 0 a = 0 := rfl\n\n@[simp] theorem support_zero {α : Type u_1} {M : Type u_5} [HasZero M] : support 0 = ∅ := rfl\n\nprotected instance inhabited {α : Type u_1} {M : Type u_5} [HasZero M] : Inhabited (α →₀ M) :=\n  { default := 0 }\n\n@[simp] theorem mem_support_iff {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {a : α} :\n    a ∈ support f ↔ coe_fn f a ≠ 0 :=\n  mem_support_to_fun f\n\n@[simp] theorem fun_support_eq {α : Type u_1} {M : Type u_5} [HasZero M] (f : α →₀ M) :\n    function.support ⇑f = ↑(support f) :=\n  set.ext fun (x : α) => iff.symm mem_support_iff\n\ntheorem not_mem_support_iff {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {a : α} :\n    ¬a ∈ support f ↔ coe_fn f a = 0 :=\n  iff.mp not_iff_comm (iff.symm mem_support_iff)\n\ntheorem coe_fn_injective {α : Type u_1} {M : Type u_5} [HasZero M] :\n    function.injective fun (f : α →₀ M) (x : α) => coe_fn f x :=\n  sorry\n\ntheorem ext {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {g : α →₀ M}\n    (h : ∀ (a : α), coe_fn f a = coe_fn g a) : f = g :=\n  coe_fn_injective (funext h)\n\ntheorem ext_iff {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {g : α →₀ M} :\n    f = g ↔ ∀ (a : α), coe_fn f a = coe_fn g a :=\n  { mp := fun (ᾰ : f = g) (a : α) => Eq._oldrec (Eq.refl (coe_fn f a)) ᾰ, mpr := ext }\n\ntheorem ext_iff' {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {g : α →₀ M} :\n    f = g ↔ support f = support g ∧ ∀ (x : α), x ∈ support f → coe_fn f x = coe_fn g x :=\n  sorry\n\n@[simp] theorem support_eq_empty {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} :\n    support f = ∅ ↔ f = 0 :=\n  sorry\n\ntheorem card_support_eq_zero {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} :\n    finset.card (support f) = 0 ↔ f = 0 :=\n  sorry\n\nprotected instance finsupp.decidable_eq {α : Type u_1} {M : Type u_5} [HasZero M] [DecidableEq α]\n    [DecidableEq M] : DecidableEq (α →₀ M) :=\n  fun (f g : α →₀ M) =>\n    decidable_of_iff (support f = support g ∧ ∀ (a : α), a ∈ support f → coe_fn f a = coe_fn g a)\n      sorry\n\ntheorem finite_supp {α : Type u_1} {M : Type u_5} [HasZero M] (f : α →₀ M) :\n    set.finite (set_of fun (a : α) => coe_fn f a ≠ 0) :=\n  Nonempty.intro (fintype.of_finset (support f) fun (_x : α) => mem_support_iff)\n\ntheorem support_subset_iff {α : Type u_1} {M : Type u_5} [HasZero M] {s : set α} {f : α →₀ M} :\n    ↑(support f) ⊆ s ↔ ∀ (a : α), ¬a ∈ s → coe_fn f a = 0 :=\n  sorry\n\n/-- Given `fintype α`, `equiv_fun_on_fintype` is the `equiv` between `α →₀ β` and `α → β`.\n  (All functions on a finite type are finitely supported.) -/\ndef equiv_fun_on_fintype {α : Type u_1} {M : Type u_5} [HasZero M] [fintype α] :\n    (α →₀ M) ≃ (α → M) :=\n  equiv.mk (fun (f : α →₀ M) (a : α) => coe_fn f a)\n    (fun (f : α → M) => mk (finset.filter (fun (a : α) => f a ≠ 0) finset.univ) f sorry) sorry sorry\n\n/-! ### Declarations about `single` -/\n\n/-- `single a b` is the finitely supported function which has\n  value `b` at `a` and zero otherwise. -/\ndef single {α : Type u_1} {M : Type u_5} [HasZero M] (a : α) (b : M) : α →₀ M :=\n  mk (ite (b = 0) ∅ (singleton a)) (fun (a' : α) => ite (a = a') b 0) sorry\n\ntheorem single_apply {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {a' : α} {b : M} :\n    coe_fn (single a b) a' = ite (a = a') b 0 :=\n  rfl\n\ntheorem single_eq_indicator {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} :\n    ⇑(single a b) = set.indicator (singleton a) fun (_x : α) => b :=\n  sorry\n\n@[simp] theorem single_eq_same {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} :\n    coe_fn (single a b) a = b :=\n  if_pos rfl\n\n@[simp] theorem single_eq_of_ne {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {a' : α} {b : M}\n    (h : a ≠ a') : coe_fn (single a b) a' = 0 :=\n  if_neg h\n\ntheorem single_eq_update {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} :\n    ⇑(single a b) = function.update 0 a b :=\n  sorry\n\n@[simp] theorem single_zero {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} : single a 0 = 0 :=\n  sorry\n\ntheorem single_of_single_apply {α : Type u_1} {M : Type u_5} [HasZero M] (a : α) (a' : α) (b : M) :\n    single a (coe_fn (single a' b) a) = coe_fn (single a' (single a' b)) a :=\n  sorry\n\ntheorem support_single_ne_zero {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M}\n    (hb : b ≠ 0) : support (single a b) = singleton a :=\n  if_neg hb\n\ntheorem support_single_subset {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} :\n    support (single a b) ⊆ singleton a :=\n  sorry\n\ntheorem single_apply_mem {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} (x : α) :\n    coe_fn (single a b) x ∈ insert 0 (singleton b) :=\n  sorry\n\ntheorem range_single_subset {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} :\n    set.range ⇑(single a b) ⊆ insert 0 (singleton b) :=\n  iff.mpr set.range_subset_iff single_apply_mem\n\ntheorem single_injective {α : Type u_1} {M : Type u_5} [HasZero M] (a : α) :\n    function.injective (single a) :=\n  sorry\n\ntheorem single_apply_eq_zero {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {x : α} {b : M} :\n    coe_fn (single a b) x = 0 ↔ x = a → b = 0 :=\n  sorry\n\ntheorem mem_support_single {α : Type u_1} {M : Type u_5} [HasZero M] (a : α) (a' : α) (b : M) :\n    a ∈ support (single a' b) ↔ a = a' ∧ b ≠ 0 :=\n  sorry\n\ntheorem eq_single_iff {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {a : α} {b : M} :\n    f = single a b ↔ support f ⊆ singleton a ∧ coe_fn f a = b :=\n  sorry\n\ntheorem single_eq_single_iff {α : Type u_1} {M : Type u_5} [HasZero M] (a₁ : α) (a₂ : α) (b₁ : M)\n    (b₂ : M) : single a₁ b₁ = single a₂ b₂ ↔ a₁ = a₂ ∧ b₁ = b₂ ∨ b₁ = 0 ∧ b₂ = 0 :=\n  sorry\n\ntheorem single_left_inj {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {a' : α} {b : M}\n    (h : b ≠ 0) : single a b = single a' b ↔ a = a' :=\n  sorry\n\n@[simp] theorem single_eq_zero {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} :\n    single a b = 0 ↔ b = 0 :=\n  sorry\n\ntheorem single_swap {α : Type u_1} {M : Type u_5} [HasZero M] (a₁ : α) (a₂ : α) (b : M) :\n    coe_fn (single a₁ b) a₂ = coe_fn (single a₂ b) a₁ :=\n  sorry\n\nprotected instance nontrivial {α : Type u_1} {M : Type u_5} [HasZero M] [Nonempty α]\n    [nontrivial M] : nontrivial (α →₀ M) :=\n  nonempty.elim_to_inhabited\n    fun (inst : Inhabited α) =>\n      Exists.dcases_on (exists_ne 0)\n        fun (x : M) (hx : x ≠ 0) =>\n          nontrivial_of_ne (single Inhabited.default x) 0 (mt (iff.mp single_eq_zero) hx)\n\ntheorem unique_single {α : Type u_1} {M : Type u_5} [HasZero M] [unique α] (x : α →₀ M) :\n    x = single Inhabited.default (coe_fn x Inhabited.default) :=\n  ext (iff.mpr unique.forall_iff (Eq.symm single_eq_same))\n\ntheorem unique_ext {α : Type u_1} {M : Type u_5} [HasZero M] [unique α] {f : α →₀ M} {g : α →₀ M}\n    (h : coe_fn f Inhabited.default = coe_fn g Inhabited.default) : f = g :=\n  ext\n    fun (a : α) =>\n      eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn f a = coe_fn g a)) (unique.eq_default a))) h\n\ntheorem unique_ext_iff {α : Type u_1} {M : Type u_5} [HasZero M] [unique α] {f : α →₀ M}\n    {g : α →₀ M} : f = g ↔ coe_fn f Inhabited.default = coe_fn g Inhabited.default :=\n  { mp := fun (h : f = g) => h ▸ rfl, mpr := unique_ext }\n\n@[simp] theorem unique_single_eq_iff {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {a' : α}\n    {b : M} [unique α] {b' : M} : single a b = single a' b' ↔ b = b' :=\n  sorry\n\ntheorem support_eq_singleton {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {a : α} :\n    support f = singleton a ↔ coe_fn f a ≠ 0 ∧ f = single a (coe_fn f a) :=\n  sorry\n\ntheorem support_eq_singleton' {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {a : α} :\n    support f = singleton a ↔ ∃ (b : M), ∃ (H : b ≠ 0), f = single a b :=\n  sorry\n\ntheorem card_support_eq_one {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} :\n    finset.card (support f) = 1 ↔ ∃ (a : α), coe_fn f a ≠ 0 ∧ f = single a (coe_fn f a) :=\n  sorry\n\ntheorem card_support_eq_one' {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} :\n    finset.card (support f) = 1 ↔ ∃ (a : α), ∃ (b : M), ∃ (H : b ≠ 0), f = single a b :=\n  sorry\n\n/-! ### Declarations about `on_finset` -/\n\n/-- `on_finset s f hf` is the finsupp function representing `f` restricted to the finset `s`.\n  The function needs to be `0` outside of `s`. Use this when the set needs to be filtered anyways,\n  otherwise a better set representation is often available. -/\ndef on_finset {α : Type u_1} {M : Type u_5} [HasZero M] (s : finset α) (f : α → M)\n    (hf : ∀ (a : α), f a ≠ 0 → a ∈ s) : α →₀ M :=\n  mk (finset.filter (fun (a : α) => f a ≠ 0) s) f sorry\n\n@[simp] theorem on_finset_apply {α : Type u_1} {M : Type u_5} [HasZero M] {s : finset α} {f : α → M}\n    {hf : ∀ (a : α), f a ≠ 0 → a ∈ s} {a : α} : coe_fn (on_finset s f hf) a = f a :=\n  rfl\n\n@[simp] theorem support_on_finset_subset {α : Type u_1} {M : Type u_5} [HasZero M] {s : finset α}\n    {f : α → M} {hf : ∀ (a : α), f a ≠ 0 → a ∈ s} : support (on_finset s f hf) ⊆ s :=\n  finset.filter_subset (fun (a : α) => f a ≠ 0) s\n\n@[simp] theorem mem_support_on_finset {α : Type u_1} {M : Type u_5} [HasZero M] {s : finset α}\n    {f : α → M} (hf : ∀ (a : α), f a ≠ 0 → a ∈ s) {a : α} :\n    a ∈ support (on_finset s f hf) ↔ f a ≠ 0 :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (a ∈ support (on_finset s f hf) ↔ f a ≠ 0)) (propext mem_support_iff)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (on_finset s f hf) a ≠ 0 ↔ f a ≠ 0)) on_finset_apply))\n      (iff.refl (f a ≠ 0)))\n\ntheorem support_on_finset {α : Type u_1} {M : Type u_5} [HasZero M] {s : finset α} {f : α → M}\n    (hf : ∀ (a : α), f a ≠ 0 → a ∈ s) :\n    support (on_finset s f hf) = finset.filter (fun (a : α) => f a ≠ 0) s :=\n  rfl\n\n/-! ### Declarations about `map_range` -/\n\n/-- The composition of `f : M → N` and `g : α →₀ M` is\n`map_range f hf g : α →₀ N`, well-defined when `f 0 = 0`. -/\ndef map_range {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N] (f : M → N)\n    (hf : f 0 = 0) (g : α →₀ M) : α →₀ N :=\n  on_finset (support g) (f ∘ ⇑g) sorry\n\n@[simp] theorem map_range_apply {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N]\n    {f : M → N} {hf : f 0 = 0} {g : α →₀ M} {a : α} :\n    coe_fn (map_range f hf g) a = f (coe_fn g a) :=\n  rfl\n\n@[simp] theorem map_range_zero {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N]\n    {f : M → N} {hf : f 0 = 0} : map_range f hf 0 = 0 :=\n  sorry\n\ntheorem support_map_range {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N]\n    {f : M → N} {hf : f 0 = 0} {g : α →₀ M} : support (map_range f hf g) ⊆ support g :=\n  support_on_finset_subset\n\n@[simp] theorem map_range_single {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [HasZero N] {f : M → N} {hf : f 0 = 0} {a : α} {b : M} :\n    map_range f hf (single a b) = single a (f b) :=\n  sorry\n\n/-! ### Declarations about `emb_domain` -/\n\n/-- Given `f : α ↪ β` and `v : α →₀ M`, `emb_domain f v : β →₀ M`\nis the finitely supported function whose value at `f a : β` is `v a`.\nFor a `b : β` outside the range of `f`, it is zero. -/\ndef emb_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M] (f : α ↪ β) (v : α →₀ M) :\n    β →₀ M :=\n  mk (finset.map f (support v))\n    (fun (a₂ : β) =>\n      dite (a₂ ∈ finset.map f (support v))\n        (fun (h : a₂ ∈ finset.map f (support v)) =>\n          coe_fn v (finset.choose (fun (a₁ : α) => coe_fn f a₁ = a₂) (support v) sorry))\n        fun (h : ¬a₂ ∈ finset.map f (support v)) => 0)\n    sorry\n\n@[simp] theorem support_emb_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M]\n    (f : α ↪ β) (v : α →₀ M) : support (emb_domain f v) = finset.map f (support v) :=\n  rfl\n\n@[simp] theorem emb_domain_zero {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M]\n    (f : α ↪ β) : emb_domain f 0 = 0 :=\n  rfl\n\n@[simp] theorem emb_domain_apply {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M]\n    (f : α ↪ β) (v : α →₀ M) (a : α) : coe_fn (emb_domain f v) (coe_fn f a) = coe_fn v a :=\n  sorry\n\ntheorem emb_domain_notin_range {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M] (f : α ↪ β)\n    (v : α →₀ M) (a : β) (h : ¬a ∈ set.range ⇑f) : coe_fn (emb_domain f v) a = 0 :=\n  sorry\n\ntheorem emb_domain_injective {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M] (f : α ↪ β) :\n    function.injective (emb_domain f) :=\n  sorry\n\n@[simp] theorem emb_domain_inj {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M] {f : α ↪ β}\n    {l₁ : α →₀ M} {l₂ : α →₀ M} : emb_domain f l₁ = emb_domain f l₂ ↔ l₁ = l₂ :=\n  function.injective.eq_iff (emb_domain_injective f)\n\n@[simp] theorem emb_domain_eq_zero {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M]\n    {f : α ↪ β} {l : α →₀ M} : emb_domain f l = 0 ↔ l = 0 :=\n  function.injective.eq_iff' (emb_domain_injective f) (emb_domain_zero f)\n\ntheorem emb_domain_map_range {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [HasZero N] (f : α ↪ β) (g : M → N) (p : α →₀ M) (hg : g 0 = 0) :\n    emb_domain f (map_range g hg p) = map_range g hg (emb_domain f p) :=\n  sorry\n\ntheorem single_of_emb_domain_single {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M]\n    (l : α →₀ M) (f : α ↪ β) (a : β) (b : M) (hb : b ≠ 0) (h : emb_domain f l = single a b) :\n    ∃ (x : α), l = single x b ∧ coe_fn f x = a :=\n  sorry\n\n/-! ### Declarations about `zip_with` -/\n\n/-- `zip_with f hf g₁ g₂` is the finitely supported function satisfying\n  `zip_with f hf g₁ g₂ a = f (g₁ a) (g₂ a)`, and it is well-defined when `f 0 0 = 0`. -/\ndef zip_with {α : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8} [HasZero M] [HasZero N]\n    [HasZero P] (f : M → N → P) (hf : f 0 0 = 0) (g₁ : α →₀ M) (g₂ : α →₀ N) : α →₀ P :=\n  on_finset (support g₁ ∪ support g₂) (fun (a : α) => f (coe_fn g₁ a) (coe_fn g₂ a)) sorry\n\n@[simp] theorem zip_with_apply {α : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8}\n    [HasZero M] [HasZero N] [HasZero P] {f : M → N → P} {hf : f 0 0 = 0} {g₁ : α →₀ M} {g₂ : α →₀ N}\n    {a : α} : coe_fn (zip_with f hf g₁ g₂) a = f (coe_fn g₁ a) (coe_fn g₂ a) :=\n  rfl\n\ntheorem support_zip_with {α : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8} [HasZero M]\n    [HasZero N] [HasZero P] {f : M → N → P} {hf : f 0 0 = 0} {g₁ : α →₀ M} {g₂ : α →₀ N} :\n    support (zip_with f hf g₁ g₂) ⊆ support g₁ ∪ support g₂ :=\n  support_on_finset_subset\n\n/-! ### Declarations about `erase` -/\n\n/-- `erase a f` is the finitely supported function equal to `f` except at `a` where it is equal to\n  `0`. -/\ndef erase {α : Type u_1} {M : Type u_5} [HasZero M] (a : α) (f : α →₀ M) : α →₀ M :=\n  mk (finset.erase (support f) a) (fun (a' : α) => ite (a' = a) 0 (coe_fn f a')) sorry\n\n@[simp] theorem support_erase {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {f : α →₀ M} :\n    support (erase a f) = finset.erase (support f) a :=\n  rfl\n\n@[simp] theorem erase_same {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {f : α →₀ M} :\n    coe_fn (erase a f) a = 0 :=\n  if_pos rfl\n\n@[simp] theorem erase_ne {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {a' : α} {f : α →₀ M}\n    (h : a' ≠ a) : coe_fn (erase a f) a' = coe_fn f a' :=\n  if_neg h\n\n@[simp] theorem erase_single {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {b : M} :\n    erase a (single a b) = 0 :=\n  sorry\n\ntheorem erase_single_ne {α : Type u_1} {M : Type u_5} [HasZero M] {a : α} {a' : α} {b : M}\n    (h : a ≠ a') : erase a (single a' b) = single a' b :=\n  sorry\n\n@[simp] theorem erase_zero {α : Type u_1} {M : Type u_5} [HasZero M] (a : α) : erase a 0 = 0 :=\n  sorry\n\n/-!\n### Declarations about `sum` and `prod`\n\nIn most of this section, the domain `β` is assumed to be an `add_monoid`.\n-/\n\n-- [to_additive sum] for finsupp.prod doesn't work, the equation lemmas are not generated\n\n/-- `sum f g` is the sum of `g a (f a)` over the support of `f`. -/\ndef sum {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [add_comm_monoid N] (f : α →₀ M)\n    (g : α → M → N) : N :=\n  finset.sum (support f) fun (a : α) => g a (coe_fn f a)\n\n/-- `prod f g` is the product of `g a (f a)` over the support of `f`. -/\ndef prod {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N] (f : α →₀ M)\n    (g : α → M → N) : N :=\n  finset.prod (support f) fun (a : α) => g a (coe_fn f a)\n\ntheorem sum_of_support_subset {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] (f : α →₀ M) {s : finset α} (hs : support f ⊆ s) (g : α → M → N)\n    (h : ∀ (i : α), i ∈ s → g i 0 = 0) : sum f g = finset.sum s fun (x : α) => g x (coe_fn f x) :=\n  finset.sum_subset hs\n    fun (x : α) (hxs : x ∈ s) (hx : ¬x ∈ support f) =>\n      Eq.subst (h x hxs) (congr_arg (g x)) (iff.mp not_mem_support_iff hx)\n\ntheorem prod_fintype {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N]\n    [fintype α] (f : α →₀ M) (g : α → M → N) (h : ∀ (i : α), g i 0 = 1) :\n    prod f g = finset.prod finset.univ fun (i : α) => g i (coe_fn f i) :=\n  prod_of_support_subset f (finset.subset_univ (support f)) g\n    fun (x : α) (_x : x ∈ finset.univ) => h x\n\n@[simp] theorem prod_single_index {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [comm_monoid N] {a : α} {b : M} {h : α → M → N} (h_zero : h a 0 = 1) :\n    prod (single a b) h = h a b :=\n  sorry\n\ntheorem prod_map_range_index {α : Type u_1} {M : Type u_5} {M' : Type u_6} {N : Type u_7}\n    [HasZero M] [HasZero M'] [comm_monoid N] {f : M → M'} {hf : f 0 = 0} {g : α →₀ M}\n    {h : α → M' → N} (h0 : ∀ (a : α), h a 0 = 1) :\n    prod (map_range f hf g) h = prod g fun (a : α) (b : M) => h a (f b) :=\n  sorry\n\n@[simp] theorem sum_zero_index {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {h : α → M → N} : sum 0 h = 0 :=\n  rfl\n\ntheorem sum_comm {α : Type u_1} {β : Type u_2} {M : Type u_5} {M' : Type u_6} {N : Type u_7}\n    [HasZero M] [HasZero M'] [add_comm_monoid N] (f : α →₀ M) (g : β →₀ M')\n    (h : α → M → β → M' → N) :\n    (sum f fun (x : α) (v : M) => sum g fun (x' : β) (v' : M') => h x v x' v') =\n        sum g fun (x' : β) (v' : M') => sum f fun (x : α) (v : M) => h x v x' v' :=\n  finset.sum_comm\n\n@[simp] theorem prod_ite_eq {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N]\n    [DecidableEq α] (f : α →₀ M) (a : α) (b : α → M → N) :\n    (prod f fun (x : α) (v : M) => ite (a = x) (b x v) 1) =\n        ite (a ∈ support f) (b a (coe_fn f a)) 1 :=\n  sorry\n\n@[simp] theorem sum_ite_self_eq {α : Type u_1} [DecidableEq α] {N : Type u_2} [add_comm_monoid N]\n    (f : α →₀ N) (a : α) : (sum f fun (x : α) (v : N) => ite (a = x) v 0) = coe_fn f a :=\n  sorry\n\n/-- A restatement of `prod_ite_eq` with the equality test reversed. -/\n@[simp] theorem sum_ite_eq' {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] [DecidableEq α] (f : α →₀ M) (a : α) (b : α → M → N) :\n    (sum f fun (x : α) (v : M) => ite (x = a) (b x v) 0) =\n        ite (a ∈ support f) (b a (coe_fn f a)) 0 :=\n  sorry\n\n@[simp] theorem sum_ite_self_eq' {α : Type u_1} [DecidableEq α] {N : Type u_2} [add_comm_monoid N]\n    (f : α →₀ N) (a : α) : (sum f fun (x : α) (v : N) => ite (x = a) v 0) = coe_fn f a :=\n  sorry\n\n@[simp] theorem prod_pow {α : Type u_1} {N : Type u_7} [comm_monoid N] [fintype α] (f : α →₀ ℕ)\n    (g : α → N) :\n    (prod f fun (a : α) (b : ℕ) => g a ^ b) =\n        finset.prod finset.univ fun (a : α) => g a ^ coe_fn f a :=\n  prod_fintype f (fun (a : α) (b : ℕ) => g a ^ b) fun (a : α) => pow_zero (g a)\n\n/-- If `g` maps a second argument of 0 to 1, then multiplying it over the\nresult of `on_finset` is the same as multiplying it over the original\n`finset`. -/\ntheorem on_finset_sum {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [add_comm_monoid N]\n    {s : finset α} {f : α → M} {g : α → M → N} (hf : ∀ (a : α), f a ≠ 0 → a ∈ s)\n    (hg : ∀ (a : α), g a 0 = 0) :\n    sum (on_finset s f hf) g = finset.sum s fun (a : α) => g a (f a) :=\n  sorry\n\n/-!\n### Additive monoid structure on `α →₀ M`\n-/\n\nprotected instance has_add {α : Type u_1} {M : Type u_5} [add_monoid M] : Add (α →₀ M) :=\n  { add := zip_with Add.add sorry }\n\n@[simp] theorem coe_add {α : Type u_1} {M : Type u_5} [add_monoid M] (f : α →₀ M) (g : α →₀ M) :\n    ⇑(f + g) = ⇑f + ⇑g :=\n  rfl\n\ntheorem add_apply {α : Type u_1} {M : Type u_5} [add_monoid M] {g₁ : α →₀ M} {g₂ : α →₀ M} {a : α} :\n    coe_fn (g₁ + g₂) a = coe_fn g₁ a + coe_fn g₂ a :=\n  rfl\n\ntheorem support_add {α : Type u_1} {M : Type u_5} [add_monoid M] {g₁ : α →₀ M} {g₂ : α →₀ M} :\n    support (g₁ + g₂) ⊆ support g₁ ∪ support g₂ :=\n  support_zip_with\n\ntheorem support_add_eq {α : Type u_1} {M : Type u_5} [add_monoid M] {g₁ : α →₀ M} {g₂ : α →₀ M}\n    (h : disjoint (support g₁) (support g₂)) : support (g₁ + g₂) = support g₁ ∪ support g₂ :=\n  sorry\n\n@[simp] theorem single_add {α : Type u_1} {M : Type u_5} [add_monoid M] {a : α} {b₁ : M} {b₂ : M} :\n    single a (b₁ + b₂) = single a b₁ + single a b₂ :=\n  sorry\n\nprotected instance add_monoid {α : Type u_1} {M : Type u_5} [add_monoid M] : add_monoid (α →₀ M) :=\n  add_monoid.mk Add.add sorry 0 sorry sorry\n\n/-- `finsupp.single` as an `add_monoid_hom`.\n\nSee `finsupp.lsingle` for the stronger version as a linear map.\n-/\ndef single_add_hom {α : Type u_1} {M : Type u_5} [add_monoid M] (a : α) : M →+ α →₀ M :=\n  add_monoid_hom.mk (single a) sorry sorry\n\n/-- Evaluation of a function `f : α →₀ M` at a point as an additive monoid homomorphism.\n\nSee `finsupp.lapply` for the stronger version as a linear map. -/\n@[simp] theorem apply_add_hom_apply {α : Type u_1} {M : Type u_5} [add_monoid M] (a : α)\n    (g : α →₀ M) : coe_fn (apply_add_hom a) g = coe_fn g a :=\n  Eq.refl (coe_fn (apply_add_hom a) g)\n\ntheorem single_add_erase {α : Type u_1} {M : Type u_5} [add_monoid M] (a : α) (f : α →₀ M) :\n    single a (coe_fn f a) + erase a f = f :=\n  sorry\n\ntheorem erase_add_single {α : Type u_1} {M : Type u_5} [add_monoid M] (a : α) (f : α →₀ M) :\n    erase a f + single a (coe_fn f a) = f :=\n  sorry\n\n@[simp] theorem erase_add {α : Type u_1} {M : Type u_5} [add_monoid M] (a : α) (f : α →₀ M)\n    (f' : α →₀ M) : erase a (f + f') = erase a f + erase a f' :=\n  sorry\n\nprotected theorem induction {α : Type u_1} {M : Type u_5} [add_monoid M] {p : (α →₀ M) → Prop}\n    (f : α →₀ M) (h0 : p 0)\n    (ha : ∀ (a : α) (b : M) (f : α →₀ M), ¬a ∈ support f → b ≠ 0 → p f → p (single a b + f)) :\n    p f :=\n  sorry\n\ntheorem induction₂ {α : Type u_1} {M : Type u_5} [add_monoid M] {p : (α →₀ M) → Prop} (f : α →₀ M)\n    (h0 : p 0)\n    (ha : ∀ (a : α) (b : M) (f : α →₀ M), ¬a ∈ support f → b ≠ 0 → p f → p (f + single a b)) :\n    p f :=\n  sorry\n\n@[simp] theorem add_closure_Union_range_single {α : Type u_1} {M : Type u_5} [add_monoid M] :\n    add_submonoid.closure (set.Union fun (a : α) => set.range (single a)) = ⊤ :=\n  sorry\n\n/-- If two additive homomorphisms from `α →₀ M` are equal on each `single a b`, then\nthey are equal. -/\ntheorem add_hom_ext {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [add_monoid N]\n    {f : (α →₀ M) →+ N} {g : (α →₀ M) →+ N}\n    (H : ∀ (x : α) (y : M), coe_fn f (single x y) = coe_fn g (single x y)) : f = g :=\n  sorry\n\n/-- If two additive homomorphisms from `α →₀ M` are equal on each `single a b`, then\nthey are equal.\n\nWe formulate this using equality of `add_monoid_hom`s so that `ext` tactic can apply a type-specific\nextensionality lemma after this one.  E.g., if the fiber `M` is `ℕ` or `ℤ`, then it suffices to\nverify `f (single a 1) = g (single a 1)`. -/\ntheorem add_hom_ext' {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [add_monoid N]\n    {f : (α →₀ M) →+ N} {g : (α →₀ M) →+ N}\n    (H :\n      ∀ (x : α),\n        add_monoid_hom.comp f (single_add_hom x) = add_monoid_hom.comp g (single_add_hom x)) :\n    f = g :=\n  add_hom_ext fun (x : α) => add_monoid_hom.congr_fun (H x)\n\ntheorem mul_hom_ext {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [monoid N]\n    {f : multiplicative (α →₀ M) →* N} {g : multiplicative (α →₀ M) →* N}\n    (H :\n      ∀ (x : α) (y : M),\n        coe_fn f (coe_fn multiplicative.of_add (single x y)) =\n          coe_fn g (coe_fn multiplicative.of_add (single x y))) :\n    f = g :=\n  monoid_hom.ext (add_monoid_hom.congr_fun (add_hom_ext H))\n\ntheorem mul_hom_ext' {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [monoid N]\n    {f : multiplicative (α →₀ M) →* N} {g : multiplicative (α →₀ M) →* N}\n    (H :\n      ∀ (x : α),\n        monoid_hom.comp f (coe_fn add_monoid_hom.to_multiplicative (single_add_hom x)) =\n          monoid_hom.comp g (coe_fn add_monoid_hom.to_multiplicative (single_add_hom x))) :\n    f = g :=\n  mul_hom_ext fun (x : α) => monoid_hom.congr_fun (H x)\n\ntheorem map_range_add {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [add_monoid N]\n    {f : M → N} {hf : f 0 = 0} (hf' : ∀ (x y : M), f (x + y) = f x + f y) (v₁ : α →₀ M)\n    (v₂ : α →₀ M) : map_range f hf (v₁ + v₂) = map_range f hf v₁ + map_range f hf v₂ :=\n  sorry\n\nend finsupp\n\n\ntheorem mul_equiv.map_finsupp_prod {α : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8}\n    [HasZero M] [comm_monoid N] [comm_monoid P] (h : N ≃* P) (f : α →₀ M) (g : α → M → N) :\n    coe_fn h (finsupp.prod f g) = finsupp.prod f fun (a : α) (b : M) => coe_fn h (g a b) :=\n  mul_equiv.map_prod h (fun (a : α) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem add_monoid_hom.map_finsupp_sum {α : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8}\n    [HasZero M] [add_comm_monoid N] [add_comm_monoid P] (h : N →+ P) (f : α →₀ M) (g : α → M → N) :\n    coe_fn h (finsupp.sum f g) = finsupp.sum f fun (a : α) (b : M) => coe_fn h (g a b) :=\n  add_monoid_hom.map_sum h (fun (a : α) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem ring_hom.map_finsupp_sum {α : Type u_1} {M : Type u_5} {R : Type u_11} {S : Type u_12}\n    [HasZero M] [semiring R] [semiring S] (h : R →+* S) (f : α →₀ M) (g : α → M → R) :\n    coe_fn h (finsupp.sum f g) = finsupp.sum f fun (a : α) (b : M) => coe_fn h (g a b) :=\n  ring_hom.map_sum h (fun (a : α) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem ring_hom.map_finsupp_prod {α : Type u_1} {M : Type u_5} {R : Type u_11} {S : Type u_12}\n    [HasZero M] [comm_semiring R] [comm_semiring S] (h : R →+* S) (f : α →₀ M) (g : α → M → R) :\n    coe_fn h (finsupp.prod f g) = finsupp.prod f fun (a : α) (b : M) => coe_fn h (g a b) :=\n  ring_hom.map_prod h (fun (a : α) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem monoid_hom.coe_finsupp_prod {α : Type u_1} {β : Type u_2} {N : Type u_7} {P : Type u_8}\n    [HasZero β] [monoid N] [comm_monoid P] (f : α →₀ β) (g : α → β → N →* P) :\n    ⇑(finsupp.prod f g) = finsupp.prod f fun (i : α) (fi : β) => ⇑(g i fi) :=\n  monoid_hom.coe_prod (fun (a : α) => g a (coe_fn f a)) (finsupp.support f)\n\n@[simp] theorem add_monoid_hom.finsupp_sum_apply {α : Type u_1} {β : Type u_2} {N : Type u_7}\n    {P : Type u_8} [HasZero β] [add_monoid N] [add_comm_monoid P] (f : α →₀ β) (g : α → β → N →+ P)\n    (x : N) :\n    coe_fn (finsupp.sum f g) x = finsupp.sum f fun (i : α) (fi : β) => coe_fn (g i fi) x :=\n  add_monoid_hom.finset_sum_apply (fun (a : α) => g a (coe_fn f a)) (finsupp.support f) x\n\nnamespace finsupp\n\n\nprotected instance nat_sub {α : Type u_1} : Sub (α →₀ ℕ) :=\n  { sub := zip_with (fun (m n : ℕ) => m - n) sorry }\n\n@[simp] theorem nat_sub_apply {α : Type u_1} {g₁ : α →₀ ℕ} {g₂ : α →₀ ℕ} {a : α} :\n    coe_fn (g₁ - g₂) a = coe_fn g₁ a - coe_fn g₂ a :=\n  rfl\n\n@[simp] theorem single_sub {α : Type u_1} {a : α} {n₁ : ℕ} {n₂ : ℕ} :\n    single a (n₁ - n₂) = single a n₁ - single a n₂ :=\n  sorry\n\n-- These next two lemmas are used in developing\n\n-- the partial derivative on `mv_polynomial`.\n\ntheorem sub_single_one_add {α : Type u_1} {a : α} {u : α →₀ ℕ} {u' : α →₀ ℕ} (h : coe_fn u a ≠ 0) :\n    u - single a 1 + u' = u + u' - single a 1 :=\n  sorry\n\ntheorem add_sub_single_one {α : Type u_1} {a : α} {u : α →₀ ℕ} {u' : α →₀ ℕ} (h : coe_fn u' a ≠ 0) :\n    u + (u' - single a 1) = u + u' - single a 1 :=\n  sorry\n\n@[simp] theorem nat_zero_sub {α : Type u_1} (f : α →₀ ℕ) : 0 - f = 0 :=\n  ext fun (x : α) => nat.zero_sub (coe_fn f x)\n\nprotected instance add_comm_monoid {α : Type u_1} {M : Type u_5} [add_comm_monoid M] :\n    add_comm_monoid (α →₀ M) :=\n  add_comm_monoid.mk add_monoid.add sorry add_monoid.zero sorry sorry sorry\n\nprotected instance has_sub {α : Type u_1} {G : Type u_9} [add_group G] : Sub (α →₀ G) :=\n  { sub := zip_with Sub.sub sorry }\n\nprotected instance add_group {α : Type u_1} {G : Type u_9} [add_group G] : add_group (α →₀ G) :=\n  add_group.mk add_monoid.add sorry add_monoid.zero sorry sorry (map_range Neg.neg neg_zero) Sub.sub\n    sorry\n\nprotected instance add_comm_group {α : Type u_1} {G : Type u_9} [add_comm_group G] :\n    add_comm_group (α →₀ G) :=\n  add_comm_group.mk add_group.add sorry add_group.zero sorry sorry add_group.neg add_group.sub sorry\n    sorry\n\ntheorem single_multiset_sum {α : Type u_1} {M : Type u_5} [add_comm_monoid M] (s : multiset M)\n    (a : α) : single a (multiset.sum s) = multiset.sum (multiset.map (single a) s) :=\n  sorry\n\ntheorem single_finset_sum {α : Type u_1} {ι : Type u_4} {M : Type u_5} [add_comm_monoid M]\n    (s : finset ι) (f : ι → M) (a : α) :\n    single a (finset.sum s fun (b : ι) => f b) = finset.sum s fun (b : ι) => single a (f b) :=\n  sorry\n\ntheorem single_sum {α : Type u_1} {ι : Type u_4} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] (s : ι →₀ M) (f : ι → M → N) (a : α) :\n    single a (sum s f) = sum s fun (d : ι) (c : M) => single a (f d c) :=\n  single_finset_sum (support s) (fun (a : ι) => f a (coe_fn s a)) a\n\ntheorem sum_neg_index {α : Type u_1} {M : Type u_5} {G : Type u_9} [add_group G] [add_comm_monoid M]\n    {g : α →₀ G} {h : α → G → M} (h0 : ∀ (a : α), h a 0 = 0) :\n    sum (-g) h = sum g fun (a : α) (b : G) => h a (-b) :=\n  sum_map_range_index h0\n\n@[simp] theorem neg_apply {α : Type u_1} {G : Type u_9} [add_group G] {g : α →₀ G} {a : α} :\n    coe_fn (-g) a = -coe_fn g a :=\n  rfl\n\n@[simp] theorem sub_apply {α : Type u_1} {G : Type u_9} [add_group G] {g₁ : α →₀ G} {g₂ : α →₀ G}\n    {a : α} : coe_fn (g₁ - g₂) a = coe_fn g₁ a - coe_fn g₂ a :=\n  rfl\n\n@[simp] theorem support_neg {α : Type u_1} {G : Type u_9} [add_group G] {f : α →₀ G} :\n    support (-f) = support f :=\n  finset.subset.antisymm support_map_range\n    (trans_rel_right has_subset.subset (congr_arg support (Eq.symm (neg_neg f))) support_map_range)\n\n@[simp] theorem sum_apply {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : α →₀ M} {g : α → M → β →₀ N} {a₂ : β} :\n    coe_fn (sum f g) a₂ = sum f fun (a₁ : α) (b : M) => coe_fn (g a₁ b) a₂ :=\n  add_monoid_hom.map_sum (apply_add_hom a₂) (fun (a : α) => g a (coe_fn f a)) (support f)\n\ntheorem support_sum {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : α →₀ M} {g : α → M → β →₀ N} :\n    support (sum f g) ⊆ finset.bUnion (support f) fun (a : α) => support (g a (coe_fn f a)) :=\n  sorry\n\n@[simp] theorem sum_zero {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : α →₀ M} : (sum f fun (a : α) (b : M) => 0) = 0 :=\n  finset.sum_const_zero\n\n@[simp] theorem prod_mul {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N]\n    {f : α →₀ M} {h₁ : α → M → N} {h₂ : α → M → N} :\n    (prod f fun (a : α) (b : M) => h₁ a b * h₂ a b) = prod f h₁ * prod f h₂ :=\n  finset.prod_mul_distrib\n\n@[simp] theorem sum_neg {α : Type u_1} {M : Type u_5} {G : Type u_9} [HasZero M] [add_comm_group G]\n    {f : α →₀ M} {h : α → M → G} : (sum f fun (a : α) (b : M) => -h a b) = -sum f h :=\n  Eq.symm\n    (add_monoid_hom.map_sum (-add_monoid_hom.id G) (fun (x : α) => h x (coe_fn f x)) (support f))\n\n@[simp] theorem sum_sub {α : Type u_1} {M : Type u_5} {G : Type u_9} [HasZero M] [add_comm_group G]\n    {f : α →₀ M} {h₁ : α → M → G} {h₂ : α → M → G} :\n    (sum f fun (a : α) (b : M) => h₁ a b - h₂ a b) = sum f h₁ - sum f h₂ :=\n  finset.sum_sub_distrib\n\ntheorem prod_add_index {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [comm_monoid N] {f : α →₀ M} {g : α →₀ M} {h : α → M → N} (h_zero : ∀ (a : α), h a 0 = 1)\n    (h_add : ∀ (a : α) (b₁ b₂ : M), h a (b₁ + b₂) = h a b₁ * h a b₂) :\n    prod (f + g) h = prod f h * prod g h :=\n  sorry\n\n@[simp] theorem sum_add_index' {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] {f : α →₀ M} {g : α →₀ M} (h : α → M →+ N) :\n    (sum (f + g) fun (x : α) => ⇑(h x)) =\n        (sum f fun (x : α) => ⇑(h x)) + sum g fun (x : α) => ⇑(h x) :=\n  sum_add_index (fun (a : α) => add_monoid_hom.map_zero (h a))\n    fun (a : α) => add_monoid_hom.map_add (h a)\n\n@[simp] theorem prod_add_index' {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [comm_monoid N] {f : α →₀ M} {g : α →₀ M} (h : α → multiplicative M →* N) :\n    (prod (f + g) fun (a : α) (b : M) => coe_fn (h a) (coe_fn multiplicative.of_add b)) =\n        (prod f fun (a : α) (b : M) => coe_fn (h a) (coe_fn multiplicative.of_add b)) *\n          prod g fun (a : α) (b : M) => coe_fn (h a) (coe_fn multiplicative.of_add b) :=\n  prod_add_index (fun (a : α) => monoid_hom.map_one (h a)) fun (a : α) => monoid_hom.map_mul (h a)\n\n/-- The canonical isomorphism between families of additive monoid homomorphisms `α → (M →+ N)`\nand monoid homomorphisms `(α →₀ M) →+ N`. -/\ndef lift_add_hom {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] : (α → M →+ N) ≃+ ((α →₀ M) →+ N) :=\n  add_equiv.mk\n    (fun (F : α → M →+ N) =>\n      add_monoid_hom.mk (fun (f : α →₀ M) => sum f fun (x : α) => ⇑(F x)) sorry sorry)\n    (fun (F : (α →₀ M) →+ N) (x : α) => add_monoid_hom.comp F (single_add_hom x)) sorry sorry sorry\n\n@[simp] theorem lift_add_hom_apply {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (F : α → M →+ N) (f : α →₀ M) :\n    coe_fn (coe_fn lift_add_hom F) f = sum f fun (x : α) => ⇑(F x) :=\n  rfl\n\n@[simp] theorem lift_add_hom_symm_apply {α : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (F : (α →₀ M) →+ N) (x : α) :\n    coe_fn (add_equiv.symm lift_add_hom) F x = add_monoid_hom.comp F (single_add_hom x) :=\n  rfl\n\ntheorem lift_add_hom_symm_apply_apply {α : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (F : (α →₀ M) →+ N) (x : α) (y : M) :\n    coe_fn (coe_fn (add_equiv.symm lift_add_hom) F x) y = coe_fn F (single x y) :=\n  rfl\n\n@[simp] theorem lift_add_hom_single_add_hom {α : Type u_1} {M : Type u_5} [add_comm_monoid M] :\n    coe_fn lift_add_hom single_add_hom = add_monoid_hom.id (α →₀ M) :=\n  iff.mpr (equiv.apply_eq_iff_eq_symm_apply (add_equiv.to_equiv lift_add_hom)) rfl\n\n@[simp] theorem sum_single {α : Type u_1} {M : Type u_5} [add_comm_monoid M] (f : α →₀ M) :\n    sum f single = f :=\n  add_monoid_hom.congr_fun lift_add_hom_single_add_hom f\n\n@[simp] theorem lift_add_hom_apply_single {α : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : α → M →+ N) (a : α) (b : M) :\n    coe_fn (coe_fn lift_add_hom f) (single a b) = coe_fn (f a) b :=\n  sum_single_index (add_monoid_hom.map_zero (f a))\n\n@[simp] theorem lift_add_hom_comp_single {α : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : α → M →+ N) (a : α) :\n    add_monoid_hom.comp (coe_fn lift_add_hom f) (single_add_hom a) = f a :=\n  add_monoid_hom.ext fun (b : M) => lift_add_hom_apply_single f a b\n\ntheorem comp_lift_add_hom {α : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8}\n    [add_comm_monoid M] [add_comm_monoid N] [add_comm_monoid P] (g : N →+ P) (f : α → M →+ N) :\n    add_monoid_hom.comp g (coe_fn lift_add_hom f) =\n        coe_fn lift_add_hom fun (a : α) => add_monoid_hom.comp g (f a) :=\n  sorry\n\ntheorem sum_sub_index {α : Type u_1} {β : Type u_2} {γ : Type u_3} [add_comm_group β]\n    [add_comm_group γ] {f : α →₀ β} {g : α →₀ β} {h : α → β → γ}\n    (h_sub : ∀ (a : α) (b₁ b₂ : β), h a (b₁ - b₂) = h a b₁ - h a b₂) :\n    sum (f - g) h = sum f h - sum g h :=\n  add_monoid_hom.map_sub\n    (coe_fn lift_add_hom fun (a : α) => add_monoid_hom.of_map_sub (h a) (h_sub a)) f g\n\ntheorem sum_emb_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {v : α →₀ M} {f : α ↪ β} {g : β → M → N} :\n    sum (emb_domain f v) g = sum v fun (a : α) (b : M) => g (coe_fn f a) b :=\n  sorry\n\ntheorem sum_finset_sum_index {α : Type u_1} {ι : Type u_4} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] {s : finset ι} {g : ι → α →₀ M} {h : α → M → N}\n    (h_zero : ∀ (a : α), h a 0 = 0)\n    (h_add : ∀ (a : α) (b₁ b₂ : M), h a (b₁ + b₂) = h a b₁ + h a b₂) :\n    (finset.sum s fun (i : ι) => sum (g i) h) = sum (finset.sum s fun (i : ι) => g i) h :=\n  sorry\n\ntheorem prod_sum_index {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7} {P : Type u_8}\n    [add_comm_monoid M] [add_comm_monoid N] [comm_monoid P] {f : α →₀ M} {g : α → M → β →₀ N}\n    {h : β → N → P} (h_zero : ∀ (a : β), h a 0 = 1)\n    (h_add : ∀ (a : β) (b₁ b₂ : N), h a (b₁ + b₂) = h a b₁ * h a b₂) :\n    prod (sum f g) h = prod f fun (a : α) (b : M) => prod (g a b) h :=\n  Eq.symm (prod_finset_sum_index h_zero h_add)\n\ntheorem multiset_sum_sum_index {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (f : multiset (α →₀ M)) (h : α → M → N) (h₀ : ∀ (a : α), h a 0 = 0)\n    (h₁ : ∀ (a : α) (b₁ b₂ : M), h a (b₁ + b₂) = h a b₁ + h a b₂) :\n    sum (multiset.sum f) h = multiset.sum (multiset.map (fun (g : α →₀ M) => sum g h) f) :=\n  sorry\n\ntheorem multiset_map_sum {α : Type u_1} {β : Type u_2} {γ : Type u_3} {M : Type u_5} [HasZero M]\n    {f : α →₀ M} {m : β → γ} {h : α → M → multiset β} :\n    multiset.map m (sum f h) = sum f fun (a : α) (b : M) => multiset.map m (h a b) :=\n  Eq.symm (finset.sum_hom (support f) (multiset.map m))\n\ntheorem multiset_sum_sum {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : α →₀ M} {h : α → M → multiset N} :\n    multiset.sum (sum f h) = sum f fun (a : α) (b : M) => multiset.sum (h a b) :=\n  Eq.symm (finset.sum_hom (support f) multiset.sum)\n\n/--\nComposition with a fixed additive homomorphism is itself an additive homomorphism on functions.\n-/\ndef map_range.add_monoid_hom {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (f : M →+ N) : (α →₀ M) →+ α →₀ N :=\n  add_monoid_hom.mk (map_range ⇑f sorry) sorry sorry\n\ntheorem map_range_multiset_sum {α : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (f : M →+ N) (m : multiset (α →₀ M)) :\n    map_range (⇑f) (add_monoid_hom.map_zero f) (multiset.sum m) =\n        multiset.sum\n          (multiset.map (fun (x : α →₀ M) => map_range (⇑f) (add_monoid_hom.map_zero f) x) m) :=\n  Eq.symm (multiset.sum_hom m (map_range.add_monoid_hom f))\n\ntheorem map_range_finset_sum {α : Type u_1} {ι : Type u_4} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : M →+ N) (s : finset ι) (g : ι → α →₀ M) :\n    map_range (⇑f) (add_monoid_hom.map_zero f) (finset.sum s fun (x : ι) => g x) =\n        finset.sum s fun (x : ι) => map_range (⇑f) (add_monoid_hom.map_zero f) (g x) :=\n  sorry\n\n/-! ### Declarations about `map_domain` -/\n\n/-- Given `f : α → β` and `v : α →₀ M`, `map_domain f v : β →₀ M`\n  is the finitely supported function whose value at `a : β` is the sum\n  of `v x` over all `x` such that `f x = a`. -/\ndef map_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M] (f : α → β)\n    (v : α →₀ M) : β →₀ M :=\n  sum v fun (a : α) => single (f a)\n\ntheorem map_domain_apply {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : α → β} (hf : function.injective f) (x : α →₀ M) (a : α) :\n    coe_fn (map_domain f x) (f a) = coe_fn x a :=\n  sorry\n\ntheorem map_domain_notin_range {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : α → β} (x : α →₀ M) (a : β) (h : ¬a ∈ set.range f) : coe_fn (map_domain f x) a = 0 :=\n  sorry\n\ntheorem map_domain_id {α : Type u_1} {M : Type u_5} [add_comm_monoid M] {v : α →₀ M} :\n    map_domain id v = v :=\n  sum_single v\n\ntheorem map_domain_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {M : Type u_5}\n    [add_comm_monoid M] {v : α →₀ M} {f : α → β} {g : β → γ} :\n    map_domain (g ∘ f) v = map_domain g (map_domain f v) :=\n  Eq.symm\n    (Eq.trans (sum_sum_index (fun (a : β) => single_zero) fun (a : β) (b₁ b₂ : M) => single_add)\n      (finset.sum_congr rfl fun (_x : α) (_x_1 : _x ∈ support v) => sum_single_index single_zero))\n\ntheorem map_domain_single {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : α → β} {a : α} {b : M} : map_domain f (single a b) = single (f a) b :=\n  sum_single_index single_zero\n\n@[simp] theorem map_domain_zero {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : α → β} : map_domain f 0 = 0 :=\n  sum_zero_index\n\ntheorem map_domain_congr {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {v : α →₀ M} {f : α → β} {g : α → β} (h : ∀ (x : α), x ∈ support v → f x = g x) :\n    map_domain f v = map_domain g v :=\n  sorry\n\ntheorem map_domain_add {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {v₁ : α →₀ M} {v₂ : α →₀ M} {f : α → β} :\n    map_domain f (v₁ + v₂) = map_domain f v₁ + map_domain f v₂ :=\n  sum_add_index (fun (_x : α) => single_zero) fun (_x : α) (_x_1 _x_2 : M) => single_add\n\ntheorem map_domain_finset_sum {α : Type u_1} {β : Type u_2} {ι : Type u_4} {M : Type u_5}\n    [add_comm_monoid M] {f : α → β} {s : finset ι} {v : ι → α →₀ M} :\n    map_domain f (finset.sum s fun (i : ι) => v i) =\n        finset.sum s fun (i : ι) => map_domain f (v i) :=\n  Eq.symm\n    (sum_finset_sum_index (fun (_x : α) => single_zero) fun (_x : α) (_x_1 _x_2 : M) => single_add)\n\ntheorem map_domain_sum {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [HasZero N] {f : α → β} {s : α →₀ N} {v : α → N → α →₀ M} :\n    map_domain f (sum s v) = sum s fun (a : α) (b : N) => map_domain f (v a b) :=\n  Eq.symm\n    (sum_finset_sum_index (fun (_x : α) => single_zero) fun (_x : α) (_x_1 _x_2 : M) => single_add)\n\ntheorem map_domain_support {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : α → β} {s : α →₀ M} : support (map_domain f s) ⊆ finset.image f (support s) :=\n  sorry\n\ntheorem sum_map_domain_index {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] {f : α → β} {s : α →₀ M} {h : β → M → N}\n    (h_zero : ∀ (a : β), h a 0 = 0)\n    (h_add : ∀ (a : β) (b₁ b₂ : M), h a (b₁ + b₂) = h a b₁ + h a b₂) :\n    sum (map_domain f s) h = sum s fun (a : α) (b : M) => h (f a) b :=\n  Eq.trans (sum_sum_index h_zero h_add)\n    (finset.sum_congr rfl fun (_x : α) (_x_1 : _x ∈ support s) => sum_single_index (h_zero (f _x)))\n\ntheorem emb_domain_eq_map_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : α ↪ β) (v : α →₀ M) : emb_domain f v = map_domain (⇑f) v :=\n  sorry\n\ntheorem sum_map_domain_index_inj {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] {f : α → β} {s : α →₀ M} {h : β → M → N}\n    (hf : function.injective f) : sum (map_domain f s) h = sum s fun (a : α) (b : M) => h (f a) b :=\n  sorry\n\ntheorem map_domain_injective {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : α → β} (hf : function.injective f) : function.injective (map_domain f) :=\n  sorry\n\n/-! ### Declarations about `comap_domain` -/\n\n/-- Given `f : α → β`, `l : β →₀ M` and a proof `hf` that `f` is injective on\nthe preimage of `l.support`, `comap_domain f l hf` is the finitely supported function\nfrom `α` to `M` given by composing `l` with `f`. -/\ndef comap_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M] (f : α → β) (l : β →₀ M)\n    (hf : set.inj_on f (f ⁻¹' ↑(support l))) : α →₀ M :=\n  mk (finset.preimage (support l) f hf) (fun (a : α) => coe_fn l (f a)) sorry\n\n@[simp] theorem comap_domain_apply {α : Type u_1} {β : Type u_2} {M : Type u_5} [HasZero M]\n    (f : α → β) (l : β →₀ M) (hf : set.inj_on f (f ⁻¹' ↑(support l))) (a : α) :\n    coe_fn (comap_domain f l hf) a = coe_fn l (f a) :=\n  rfl\n\ntheorem sum_comap_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] (f : α → β) (l : β →₀ M) (g : β → M → N)\n    (hf : set.bij_on f (f ⁻¹' ↑(support l)) ↑(support l)) :\n    sum (comap_domain f l (set.bij_on.inj_on hf)) (g ∘ f) = sum l g :=\n  sorry\n\ntheorem eq_zero_of_comap_domain_eq_zero {α : Type u_1} {β : Type u_2} {M : Type u_5}\n    [add_comm_monoid M] (f : α → β) (l : β →₀ M)\n    (hf : set.bij_on f (f ⁻¹' ↑(support l)) ↑(support l)) :\n    comap_domain f l (set.bij_on.inj_on hf) = 0 → l = 0 :=\n  sorry\n\ntheorem map_domain_comap_domain {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : α → β) (l : β →₀ M) (hf : function.injective f) (hl : ↑(support l) ⊆ set.range f) :\n    map_domain f (comap_domain f l (function.injective.inj_on hf (f ⁻¹' ↑(support l)))) = l :=\n  sorry\n\n/-! ### Declarations about `filter` -/\n\n/-- `filter p f` is the function which is `f a` if `p a` is true and 0 otherwise. -/\ndef filter {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop) (f : α →₀ M) : α →₀ M :=\n  mk (finset.filter (fun (a : α) => p a) (support f)) (fun (a : α) => ite (p a) (coe_fn f a) 0)\n    sorry\n\ntheorem filter_apply {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop) (f : α →₀ M) (a : α) :\n    coe_fn (filter p f) a = ite (p a) (coe_fn f a) 0 :=\n  rfl\n\ntheorem filter_eq_indicator {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop) (f : α →₀ M) :\n    ⇑(filter p f) = set.indicator (set_of fun (x : α) => p x) ⇑f :=\n  rfl\n\n@[simp] theorem filter_apply_pos {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop)\n    (f : α →₀ M) {a : α} (h : p a) : coe_fn (filter p f) a = coe_fn f a :=\n  if_pos h\n\n@[simp] theorem filter_apply_neg {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop)\n    (f : α →₀ M) {a : α} (h : ¬p a) : coe_fn (filter p f) a = 0 :=\n  if_neg h\n\n@[simp] theorem support_filter {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop)\n    (f : α →₀ M) : support (filter p f) = finset.filter p (support f) :=\n  rfl\n\ntheorem filter_zero {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop) : filter p 0 = 0 :=\n  sorry\n\n@[simp] theorem filter_single_of_pos {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop)\n    {a : α} {b : M} (h : p a) : filter p (single a b) = single a b :=\n  sorry\n\n@[simp] theorem filter_single_of_neg {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop)\n    {a : α} {b : M} (h : ¬p a) : filter p (single a b) = 0 :=\n  sorry\n\ntheorem filter_pos_add_filter_neg {α : Type u_1} {M : Type u_5} [add_monoid M] (f : α →₀ M)\n    (p : α → Prop) : filter p f + filter (fun (a : α) => ¬p a) f = f :=\n  coe_fn_injective (set.indicator_self_add_compl (set_of fun (x : α) => p x) ⇑f)\n\n/-! ### Declarations about `frange` -/\n\n/-- `frange f` is the image of `f` on the support of `f`. -/\ndef frange {α : Type u_1} {M : Type u_5} [HasZero M] (f : α →₀ M) : finset M :=\n  finset.image (⇑f) (support f)\n\ntheorem mem_frange {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} {y : M} :\n    y ∈ frange f ↔ y ≠ 0 ∧ ∃ (x : α), coe_fn f x = y :=\n  sorry\n\ntheorem zero_not_mem_frange {α : Type u_1} {M : Type u_5} [HasZero M] {f : α →₀ M} :\n    ¬0 ∈ frange f :=\n  fun (H : 0 ∈ frange f) => and.left (iff.mp mem_frange H) rfl\n\ntheorem frange_single {α : Type u_1} {M : Type u_5} [HasZero M] {x : α} {y : M} :\n    frange (single x y) ⊆ singleton y :=\n  sorry\n\n/-! ### Declarations about `subtype_domain` -/\n\n/-- `subtype_domain p f` is the restriction of the finitely supported function\n  `f` to the subtype `p`. -/\ndef subtype_domain {α : Type u_1} {M : Type u_5} [HasZero M] (p : α → Prop) (f : α →₀ M) :\n    Subtype p →₀ M :=\n  mk (finset.subtype p (support f)) (⇑f ∘ coe) sorry\n\n@[simp] theorem support_subtype_domain {α : Type u_1} {M : Type u_5} [HasZero M] {p : α → Prop}\n    {f : α →₀ M} : support (subtype_domain p f) = finset.subtype p (support f) :=\n  rfl\n\n@[simp] theorem subtype_domain_apply {α : Type u_1} {M : Type u_5} [HasZero M] {p : α → Prop}\n    {a : Subtype p} {v : α →₀ M} : coe_fn (subtype_domain p v) a = coe_fn v (subtype.val a) :=\n  rfl\n\n@[simp] theorem subtype_domain_zero {α : Type u_1} {M : Type u_5} [HasZero M] {p : α → Prop} :\n    subtype_domain p 0 = 0 :=\n  rfl\n\ntheorem subtype_domain_eq_zero_iff' {α : Type u_1} {M : Type u_5} [HasZero M] {p : α → Prop}\n    {f : α →₀ M} : subtype_domain p f = 0 ↔ ∀ (x : α), p x → coe_fn f x = 0 :=\n  sorry\n\ntheorem subtype_domain_eq_zero_iff {α : Type u_1} {M : Type u_5} [HasZero M] {p : α → Prop}\n    {f : α →₀ M} (hf : ∀ (x : α), x ∈ support f → p x) : subtype_domain p f = 0 ↔ f = 0 :=\n  sorry\n\ntheorem prod_subtype_domain_index {α : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    {p : α → Prop} [comm_monoid N] {v : α →₀ M} {h : α → M → N}\n    (hp : ∀ (x : α), x ∈ support v → p x) :\n    (prod (subtype_domain p v) fun (a : Subtype p) (b : M) => h (↑a) b) = prod v h :=\n  sorry\n\n@[simp] theorem subtype_domain_add {α : Type u_1} {M : Type u_5} [add_monoid M] {p : α → Prop}\n    {v : α →₀ M} {v' : α →₀ M} :\n    subtype_domain p (v + v') = subtype_domain p v + subtype_domain p v' :=\n  ext fun (_x : Subtype p) => rfl\n\nprotected instance subtype_domain.is_add_monoid_hom {α : Type u_1} {M : Type u_5} [add_monoid M]\n    {p : α → Prop} : is_add_monoid_hom (subtype_domain p) :=\n  is_add_monoid_hom.mk subtype_domain_zero\n\n/-- `finsupp.filter` as an `add_monoid_hom`. -/\ndef filter_add_hom {α : Type u_1} {M : Type u_5} [add_monoid M] (p : α → Prop) :\n    (α →₀ M) →+ α →₀ M :=\n  add_monoid_hom.mk (filter p) sorry sorry\n\n@[simp] theorem filter_add {α : Type u_1} {M : Type u_5} [add_monoid M] {p : α → Prop} {v : α →₀ M}\n    {v' : α →₀ M} : filter p (v + v') = filter p v + filter p v' :=\n  add_monoid_hom.map_add (filter_add_hom p) v v'\n\ntheorem subtype_domain_sum {α : Type u_1} {ι : Type u_4} {M : Type u_5} [add_comm_monoid M]\n    {p : α → Prop} {s : finset ι} {h : ι → α →₀ M} :\n    subtype_domain p (finset.sum s fun (c : ι) => h c) =\n        finset.sum s fun (c : ι) => subtype_domain p (h c) :=\n  Eq.symm (finset.sum_hom s (subtype_domain p))\n\ntheorem subtype_domain_finsupp_sum {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] {p : α → Prop} [HasZero N] {s : β →₀ N} {h : β → N → α →₀ M} :\n    subtype_domain p (sum s h) = sum s fun (c : β) (d : N) => subtype_domain p (h c d) :=\n  subtype_domain_sum\n\ntheorem filter_sum {α : Type u_1} {ι : Type u_4} {M : Type u_5} [add_comm_monoid M] {p : α → Prop}\n    (s : finset ι) (f : ι → α →₀ M) :\n    filter p (finset.sum s fun (a : ι) => f a) = finset.sum s fun (a : ι) => filter p (f a) :=\n  add_monoid_hom.map_sum (filter_add_hom p) f s\n\ntheorem filter_eq_sum {α : Type u_1} {M : Type u_5} [add_comm_monoid M] (p : α → Prop)\n    (f : α →₀ M) :\n    filter p f = finset.sum (finset.filter p (support f)) fun (i : α) => single i (coe_fn f i) :=\n  sorry\n\n@[simp] theorem subtype_domain_neg {α : Type u_1} {G : Type u_9} [add_group G] {p : α → Prop}\n    {v : α →₀ G} : subtype_domain p (-v) = -subtype_domain p v :=\n  ext fun (_x : Subtype p) => rfl\n\n@[simp] theorem subtype_domain_sub {α : Type u_1} {G : Type u_9} [add_group G] {p : α → Prop}\n    {v : α →₀ G} {v' : α →₀ G} :\n    subtype_domain p (v - v') = subtype_domain p v - subtype_domain p v' :=\n  ext fun (_x : Subtype p) => rfl\n\n/-! ### Declarations relating `finsupp` to `multiset` -/\n\n/-- Given `f : α →₀ ℕ`, `f.to_multiset` is the multiset with multiplicities given by the values of\n`f` on the elements of `α`. We define this function as an `add_equiv`. -/\ndef to_multiset {α : Type u_1} : (α →₀ ℕ) ≃+ multiset α :=\n  add_equiv.mk (fun (f : α →₀ ℕ) => sum f fun (a : α) (n : ℕ) => n •ℕ singleton a)\n    (fun (s : multiset α) => mk (multiset.to_finset s) (fun (a : α) => multiset.count a s) sorry)\n    sorry sorry sorry\n\ntheorem to_multiset_zero {α : Type u_1} : coe_fn to_multiset 0 = 0 := rfl\n\ntheorem to_multiset_add {α : Type u_1} (m : α →₀ ℕ) (n : α →₀ ℕ) :\n    coe_fn to_multiset (m + n) = coe_fn to_multiset m + coe_fn to_multiset n :=\n  add_equiv.map_add to_multiset m n\n\ntheorem to_multiset_apply {α : Type u_1} (f : α →₀ ℕ) :\n    coe_fn to_multiset f = sum f fun (a : α) (n : ℕ) => n •ℕ singleton a :=\n  rfl\n\n@[simp] theorem to_multiset_single {α : Type u_1} (a : α) (n : ℕ) :\n    coe_fn to_multiset (single a n) = n •ℕ singleton a :=\n  sorry\n\ntheorem card_to_multiset {α : Type u_1} (f : α →₀ ℕ) :\n    coe_fn multiset.card (coe_fn to_multiset f) = sum f fun (a : α) => id :=\n  sorry\n\ntheorem to_multiset_map {α : Type u_1} {β : Type u_2} (f : α →₀ ℕ) (g : α → β) :\n    multiset.map g (coe_fn to_multiset f) = coe_fn to_multiset (map_domain g f) :=\n  sorry\n\n@[simp] theorem prod_to_multiset {M : Type u_5} [comm_monoid M] (f : M →₀ ℕ) :\n    multiset.prod (coe_fn to_multiset f) = prod f fun (a : M) (n : ℕ) => a ^ n :=\n  sorry\n\n@[simp] theorem to_finset_to_multiset {α : Type u_1} (f : α →₀ ℕ) :\n    multiset.to_finset (coe_fn to_multiset f) = support f :=\n  sorry\n\n@[simp] theorem count_to_multiset {α : Type u_1} (f : α →₀ ℕ) (a : α) :\n    multiset.count a (coe_fn to_multiset f) = coe_fn f a :=\n  sorry\n\ntheorem mem_support_multiset_sum {α : Type u_1} {M : Type u_5} [add_comm_monoid M]\n    {s : multiset (α →₀ M)} (a : α) :\n    a ∈ support (multiset.sum s) → ∃ (f : α →₀ M), ∃ (H : f ∈ s), a ∈ support f :=\n  sorry\n\ntheorem mem_support_finset_sum {α : Type u_1} {ι : Type u_4} {M : Type u_5} [add_comm_monoid M]\n    {s : finset ι} {h : ι → α →₀ M} (a : α) (ha : a ∈ support (finset.sum s fun (c : ι) => h c)) :\n    ∃ (c : ι), ∃ (H : c ∈ s), a ∈ support (h c) :=\n  sorry\n\n@[simp] theorem mem_to_multiset {α : Type u_1} (f : α →₀ ℕ) (i : α) :\n    i ∈ coe_fn to_multiset f ↔ i ∈ support f :=\n  sorry\n\n/-! ### Declarations about `curry` and `uncurry` -/\n\n/-- Given a finitely supported function `f` from a product type `α × β` to `γ`,\n`curry f` is the \"curried\" finitely supported function from `α` to the type of\nfinitely supported functions from `β` to `γ`. -/\nprotected def curry {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : α × β →₀ M) : α →₀ β →₀ M :=\n  sum f fun (p : α × β) (c : M) => single (prod.fst p) (single (prod.snd p) c)\n\ntheorem sum_curry_index {α : Type u_1} {β : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : α × β →₀ M) (g : α → β → M → N)\n    (hg₀ : ∀ (a : α) (b : β), g a b 0 = 0)\n    (hg₁ : ∀ (a : α) (b : β) (c₀ c₁ : M), g a b (c₀ + c₁) = g a b c₀ + g a b c₁) :\n    (sum (finsupp.curry f) fun (a : α) (f : β →₀ M) => sum f (g a)) =\n        sum f fun (p : α × β) (c : M) => g (prod.fst p) (prod.snd p) c :=\n  sorry\n\n/-- Given a finitely supported function `f` from `α` to the type of\nfinitely supported functions from `β` to `M`,\n`uncurry f` is the \"uncurried\" finitely supported function from `α × β` to `M`. -/\nprotected def uncurry {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : α →₀ β →₀ M) : α × β →₀ M :=\n  sum f fun (a : α) (g : β →₀ M) => sum g fun (b : β) (c : M) => single (a, b) c\n\n/-- `finsupp_prod_equiv` defines the `equiv` between `((α × β) →₀ M)` and `(α →₀ (β →₀ M))` given by\ncurrying and uncurrying. -/\ndef finsupp_prod_equiv {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M] :\n    (α × β →₀ M) ≃ (α →₀ β →₀ M) :=\n  equiv.mk finsupp.curry finsupp.uncurry sorry sorry\n\ntheorem filter_curry {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : α × β →₀ M) (p : α → Prop) :\n    finsupp.curry (filter (fun (a : α × β) => p (prod.fst a)) f) = filter p (finsupp.curry f) :=\n  sorry\n\ntheorem support_curry {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : α × β →₀ M) : support (finsupp.curry f) ⊆ finset.image prod.fst (support f) :=\n  sorry\n\n/--\nScalar multiplication by a group element g,\ngiven by precomposition with the action of g⁻¹ on the domain.\n-/\ndef comap_has_scalar {α : Type u_1} {M : Type u_5} {G : Type u_9} [group G] [mul_action G α]\n    [add_comm_monoid M] : has_scalar G (α →₀ M) :=\n  has_scalar.mk fun (g : G) (f : α →₀ M) => comap_domain (fun (a : α) => g⁻¹ • a) f sorry\n\n/--\nScalar multiplication by a group element,\ngiven by precomposition with the action of g⁻¹ on the domain,\nis multiplicative in g.\n-/\ndef comap_mul_action {α : Type u_1} {M : Type u_5} {G : Type u_9} [group G] [mul_action G α]\n    [add_comm_monoid M] : mul_action G (α →₀ M) :=\n  mul_action.mk sorry sorry\n\n/--\nScalar multiplication by a group element,\ngiven by precomposition with the action of g⁻¹ on the domain,\nis additive in the second argument.\n-/\ndef comap_distrib_mul_action {α : Type u_1} {M : Type u_5} {G : Type u_9} [group G] [mul_action G α]\n    [add_comm_monoid M] : distrib_mul_action G (α →₀ M) :=\n  distrib_mul_action.mk sorry sorry\n\n/--\nScalar multiplication by a group element on finitely supported functions on a group,\ngiven by precomposition with the action of g⁻¹. -/\ndef comap_distrib_mul_action_self {M : Type u_5} {G : Type u_9} [group G] [add_comm_monoid M] :\n    distrib_mul_action G (G →₀ M) :=\n  comap_distrib_mul_action\n\n@[simp] theorem comap_smul_single {α : Type u_1} {M : Type u_5} {G : Type u_9} [group G]\n    [mul_action G α] [add_comm_monoid M] (g : G) (a : α) (b : M) :\n    g • single a b = single (g • a) b :=\n  sorry\n\n@[simp] theorem comap_smul_apply {α : Type u_1} {M : Type u_5} {G : Type u_9} [group G]\n    [mul_action G α] [add_comm_monoid M] (g : G) (f : α →₀ M) (a : α) :\n    coe_fn (g • f) a = coe_fn f (g⁻¹ • a) :=\n  rfl\n\nprotected instance has_scalar {α : Type u_1} {M : Type u_5} {R : Type u_11} [semiring R]\n    [add_comm_monoid M] [semimodule R M] : has_scalar R (α →₀ M) :=\n  has_scalar.mk fun (a : R) (v : α →₀ M) => map_range (has_scalar.smul a) sorry v\n\n/-!\nThroughout this section, some `semiring` arguments are specified with `{}` instead of `[]`.\nSee note [implicit instance arguments].\n-/\n\n@[simp] theorem smul_apply' (α : Type u_1) (M : Type u_5) {R : Type u_11} {_x : semiring R}\n    [add_comm_monoid M] [semimodule R M] {a : α} {b : R} {v : α →₀ M} :\n    coe_fn (b • v) a = b • coe_fn v a :=\n  rfl\n\nprotected instance semimodule (α : Type u_1) (M : Type u_5) {R : Type u_11} [semiring R]\n    [add_comm_monoid M] [semimodule R M] : semimodule R (α →₀ M) :=\n  semimodule.mk sorry sorry\n\ntheorem support_smul {α : Type u_1} {M : Type u_5} {R : Type u_11} {_x : semiring R}\n    [add_comm_monoid M] [semimodule R M] {b : R} {g : α →₀ M} : support (b • g) ⊆ support g :=\n  sorry\n\n@[simp] theorem filter_smul {α : Type u_1} {M : Type u_5} {R : Type u_11} {p : α → Prop}\n    {_x : semiring R} [add_comm_monoid M] [semimodule R M] {b : R} {v : α →₀ M} :\n    filter p (b • v) = b • filter p v :=\n  coe_fn_injective (set.indicator_smul (set_of fun (x : α) => p x) b ⇑v)\n\ntheorem map_domain_smul {α : Type u_1} {β : Type u_2} {M : Type u_5} {R : Type u_11}\n    {_x : semiring R} [add_comm_monoid M] [semimodule R M] {f : α → β} (b : R) (v : α →₀ M) :\n    map_domain f (b • v) = b • map_domain f v :=\n  sorry\n\n@[simp] theorem smul_single {α : Type u_1} {M : Type u_5} {R : Type u_11} {_x : semiring R}\n    [add_comm_monoid M] [semimodule R M] (c : R) (a : α) (b : M) :\n    c • single a b = single a (c • b) :=\n  map_range_single\n\n@[simp] theorem smul_single' {α : Type u_1} {R : Type u_11} {_x : semiring R} (c : R) (a : α)\n    (b : R) : c • single a b = single a (c * b) :=\n  smul_single c a b\n\ntheorem smul_single_one {α : Type u_1} {R : Type u_11} [semiring R] (a : α) (b : R) :\n    b • single a 1 = single a b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (b • single a 1 = single a b)) (smul_single b a 1)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (single a (b • 1) = single a b)) smul_eq_mul))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (single a (b * 1) = single a b)) (mul_one b)))\n        (Eq.refl (single a b))))\n\n@[simp] theorem smul_apply {α : Type u_1} {R : Type u_11} [semiring R] {a : α} {b : R}\n    {v : α →₀ R} : coe_fn (b • v) a = b • coe_fn v a :=\n  rfl\n\ntheorem sum_smul_index {α : Type u_1} {M : Type u_5} {R : Type u_11} [semiring R]\n    [add_comm_monoid M] {g : α →₀ R} {b : R} {h : α → R → M} (h0 : ∀ (i : α), h i 0 = 0) :\n    sum (b • g) h = sum g fun (i : α) (a : R) => h i (b * a) :=\n  sum_map_range_index h0\n\ntheorem sum_smul_index' {α : Type u_1} {M : Type u_5} {N : Type u_7} {R : Type u_11} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid N] {g : α →₀ M} {b : R} {h : α → M → N}\n    (h0 : ∀ (i : α), h i 0 = 0) : sum (b • g) h = sum g fun (i : α) (c : M) => h i (b • c) :=\n  sum_map_range_index h0\n\ntheorem sum_mul {α : Type u_1} {R : Type u_11} {S : Type u_12} [semiring R] [semiring S] (b : S)\n    (s : α →₀ R) {f : α → R → S} : sum s f * b = sum s fun (a : α) (c : R) => f a c * b :=\n  sorry\n\ntheorem mul_sum {α : Type u_1} {R : Type u_11} {S : Type u_12} [semiring R] [semiring S] (b : S)\n    (s : α →₀ R) {f : α → R → S} : b * sum s f = sum s fun (a : α) (c : R) => b * f a c :=\n  sorry\n\nprotected instance unique_of_right {α : Type u_1} {R : Type u_11} [semiring R] [subsingleton R] :\n    unique (α →₀ R) :=\n  unique.mk { default := Inhabited.default } sorry\n\n/-- Given an `add_comm_monoid M` and `s : set α`, `restrict_support_equiv s M` is the `equiv`\nbetween the subtype of finitely supported functions with support contained in `s` and\nthe type of finitely supported functions from `s`. -/\ndef restrict_support_equiv {α : Type u_1} (s : set α) (M : Type u_2) [add_comm_monoid M] :\n    (Subtype fun (f : α →₀ M) => ↑(support f) ⊆ s) ≃ (↥s →₀ M) :=\n  equiv.mk\n    (fun (f : Subtype fun (f : α →₀ M) => ↑(support f) ⊆ s) =>\n      subtype_domain (fun (x : α) => x ∈ s) (subtype.val f))\n    (fun (f : ↥s →₀ M) => { val := map_domain subtype.val f, property := sorry }) sorry sorry\n\n/-- Given `add_comm_monoid M` and `e : α ≃ β`, `dom_congr e` is the corresponding `equiv` between\n`α →₀ M` and `β →₀ M`. -/\nprotected def dom_congr {α : Type u_1} {β : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (e : α ≃ β) : (α →₀ M) ≃+ (β →₀ M) :=\n  add_equiv.mk (map_domain ⇑e) (map_domain ⇑(equiv.symm e)) sorry sorry sorry\n\nend finsupp\n\n\nnamespace finsupp\n\n\n/-! ### Declarations about sigma types -/\n\n/-- Given `l`, a finitely supported function from the sigma type `Σ (i : ι), αs i` to `M` and\nan index element `i : ι`, `split l i` is the `i`th component of `l`,\na finitely supported function from `as i` to `M`. -/\ndef split {ι : Type u_4} {M : Type u_5} {αs : ι → Type u_13} [HasZero M]\n    (l : (sigma fun (i : ι) => αs i) →₀ M) (i : ι) : αs i →₀ M :=\n  comap_domain (sigma.mk i) l sorry\n\ntheorem split_apply {ι : Type u_4} {M : Type u_5} {αs : ι → Type u_13} [HasZero M]\n    (l : (sigma fun (i : ι) => αs i) →₀ M) (i : ι) (x : αs i) :\n    coe_fn (split l i) x = coe_fn l (sigma.mk i x) :=\n  sorry\n\n/-- Given `l`, a finitely supported function from the sigma type `Σ (i : ι), αs i` to `β`,\n`split_support l` is the finset of indices in `ι` that appear in the support of `l`. -/\ndef split_support {ι : Type u_4} {M : Type u_5} {αs : ι → Type u_13} [HasZero M]\n    (l : (sigma fun (i : ι) => αs i) →₀ M) : finset ι :=\n  finset.image sigma.fst (support l)\n\ntheorem mem_split_support_iff_nonzero {ι : Type u_4} {M : Type u_5} {αs : ι → Type u_13} [HasZero M]\n    (l : (sigma fun (i : ι) => αs i) →₀ M) (i : ι) : i ∈ split_support l ↔ split l i ≠ 0 :=\n  sorry\n\n/-- Given `l`, a finitely supported function from the sigma type `Σ i, αs i` to `β` and\nan `ι`-indexed family `g` of functions from `(αs i →₀ β)` to `γ`, `split_comp` defines a\nfinitely supported function from the index type `ι` to `γ` given by composing `g i` with\n`split l i`. -/\ndef split_comp {ι : Type u_4} {M : Type u_5} {N : Type u_7} {αs : ι → Type u_13} [HasZero M]\n    (l : (sigma fun (i : ι) => αs i) →₀ M) [HasZero N] (g : (i : ι) → (αs i →₀ M) → N)\n    (hg : ∀ (i : ι) (x : αs i →₀ M), x = 0 ↔ g i x = 0) : ι →₀ N :=\n  mk (split_support l) (fun (i : ι) => g i (split l i)) sorry\n\ntheorem sigma_support {ι : Type u_4} {M : Type u_5} {αs : ι → Type u_13} [HasZero M]\n    (l : (sigma fun (i : ι) => αs i) →₀ M) :\n    support l = finset.sigma (split_support l) fun (i : ι) => support (split l i) :=\n  sorry\n\ntheorem sigma_sum {ι : Type u_4} {M : Type u_5} {N : Type u_7} {αs : ι → Type u_13} [HasZero M]\n    (l : (sigma fun (i : ι) => αs i) →₀ M) [add_comm_monoid N]\n    (f : (sigma fun (i : ι) => αs i) → M → N) :\n    sum l f =\n        finset.sum (split_support l)\n          fun (i : ι) => sum (split l i) fun (a : αs i) (b : M) => f (sigma.mk i a) b :=\n  sorry\n\nend finsupp\n\n\n/-! ### Declarations relating `multiset` to `finsupp` -/\n\nnamespace multiset\n\n\n/-- Given a multiset `s`, `s.to_finsupp` returns the finitely supported function on `ℕ` given by\nthe multiplicities of the elements of `s`. -/\ndef to_finsupp {α : Type u_1} : multiset α ≃+ (α →₀ ℕ) := add_equiv.symm finsupp.to_multiset\n\n@[simp] theorem to_finsupp_support {α : Type u_1} (s : multiset α) :\n    finsupp.support (coe_fn to_finsupp s) = to_finset s :=\n  rfl\n\n@[simp] theorem to_finsupp_apply {α : Type u_1} (s : multiset α) (a : α) :\n    coe_fn (coe_fn to_finsupp s) a = count a s :=\n  rfl\n\ntheorem to_finsupp_zero {α : Type u_1} : coe_fn to_finsupp 0 = 0 := add_equiv.map_zero to_finsupp\n\ntheorem to_finsupp_add {α : Type u_1} (s : multiset α) (t : multiset α) :\n    coe_fn to_finsupp (s + t) = coe_fn to_finsupp s + coe_fn to_finsupp t :=\n  add_equiv.map_add to_finsupp s t\n\n@[simp] theorem to_finsupp_singleton {α : Type u_1} (a : α) :\n    coe_fn to_finsupp (a ::ₘ 0) = finsupp.single a 1 :=\n  sorry\n\n@[simp] theorem to_finsupp_to_multiset {α : Type u_1} (s : multiset α) :\n    coe_fn finsupp.to_multiset (coe_fn to_finsupp s) = s :=\n  add_equiv.apply_symm_apply finsupp.to_multiset s\n\ntheorem to_finsupp_eq_iff {α : Type u_1} {s : multiset α} {f : α →₀ ℕ} :\n    coe_fn to_finsupp s = f ↔ s = coe_fn finsupp.to_multiset f :=\n  add_equiv.symm_apply_eq finsupp.to_multiset\n\nend multiset\n\n\n@[simp] theorem finsupp.to_multiset_to_finsupp {α : Type u_1} (f : α →₀ ℕ) :\n    coe_fn multiset.to_finsupp (coe_fn finsupp.to_multiset f) = f :=\n  add_equiv.symm_apply_apply finsupp.to_multiset f\n\n/-! ### Declarations about order(ed) instances on `finsupp` -/\n\nnamespace finsupp\n\n\nprotected instance preorder {α : Type u_1} {M : Type u_5} [preorder M] [HasZero M] :\n    preorder (α →₀ M) :=\n  preorder.mk (fun (f g : α →₀ M) => ∀ (s : α), coe_fn f s ≤ coe_fn g s)\n    (fun (a b : α →₀ M) =>\n      (∀ (s : α), coe_fn a s ≤ coe_fn b s) ∧ ¬∀ (s : α), coe_fn b s ≤ coe_fn a s)\n    sorry sorry\n\nprotected instance partial_order {α : Type u_1} {M : Type u_5} [partial_order M] [HasZero M] :\n    partial_order (α →₀ M) :=\n  partial_order.mk preorder.le preorder.lt sorry sorry sorry\n\nprotected instance add_left_cancel_semigroup {α : Type u_1} {M : Type u_5}\n    [ordered_cancel_add_comm_monoid M] : add_left_cancel_semigroup (α →₀ M) :=\n  add_left_cancel_semigroup.mk add_monoid.add sorry sorry\n\nprotected instance add_right_cancel_semigroup {α : Type u_1} {M : Type u_5}\n    [ordered_cancel_add_comm_monoid M] : add_right_cancel_semigroup (α →₀ M) :=\n  add_right_cancel_semigroup.mk add_monoid.add sorry sorry\n\nprotected instance ordered_cancel_add_comm_monoid {α : Type u_1} {M : Type u_5}\n    [ordered_cancel_add_comm_monoid M] : ordered_cancel_add_comm_monoid (α →₀ M) :=\n  ordered_cancel_add_comm_monoid.mk add_comm_monoid.add sorry sorry add_comm_monoid.zero sorry sorry\n    sorry sorry partial_order.le partial_order.lt sorry sorry sorry sorry sorry\n\ntheorem le_def {α : Type u_1} {M : Type u_5} [preorder M] [HasZero M] {f : α →₀ M} {g : α →₀ M} :\n    f ≤ g ↔ ∀ (x : α), coe_fn f x ≤ coe_fn g x :=\n  iff.rfl\n\ntheorem le_iff {α : Type u_1} {M : Type u_5} [canonically_ordered_add_monoid M] (f : α →₀ M)\n    (g : α →₀ M) : f ≤ g ↔ ∀ (s : α), s ∈ support f → coe_fn f s ≤ coe_fn g s :=\n  sorry\n\n@[simp] theorem add_eq_zero_iff {α : Type u_1} {M : Type u_5} [canonically_ordered_add_monoid M]\n    (f : α →₀ M) (g : α →₀ M) : f + g = 0 ↔ f = 0 ∧ g = 0 :=\n  sorry\n\n/-- `finsupp.to_multiset` as an order isomorphism. -/\ndef order_iso_multiset {α : Type u_1} : (α →₀ ℕ) ≃o multiset α :=\n  rel_iso.mk (add_equiv.to_equiv to_multiset) sorry\n\n@[simp] theorem coe_order_iso_multiset {α : Type u_1} : ⇑order_iso_multiset = ⇑to_multiset := rfl\n\n@[simp] theorem coe_order_iso_multiset_symm {α : Type u_1} :\n    ⇑(order_iso.symm order_iso_multiset) = ⇑multiset.to_finsupp :=\n  rfl\n\ntheorem to_multiset_strict_mono {α : Type u_1} : strict_mono ⇑to_multiset :=\n  order_iso.strict_mono order_iso_multiset\n\ntheorem sum_id_lt_of_lt {α : Type u_1} (m : α →₀ ℕ) (n : α →₀ ℕ) (h : m < n) :\n    (sum m fun (_x : α) => id) < sum n fun (_x : α) => id :=\n  sorry\n\n/-- The order on `σ →₀ ℕ` is well-founded.-/\ntheorem lt_wf (α : Type u_1) : well_founded Less :=\n  subrelation.wf sum_id_lt_of_lt\n    (inv_image.wf (fun (x : α →₀ ℕ) => sum x fun (_x : α) => id) nat.lt_wf)\n\nprotected instance decidable_le (α : Type u_1) : DecidableRel LessEq :=\n  fun (m n : α →₀ ℕ) => eq.mpr sorry finset.decidable_dforall_finset\n\n@[simp] theorem nat_add_sub_cancel {α : Type u_1} (f : α →₀ ℕ) (g : α →₀ ℕ) : f + g - g = f :=\n  ext fun (a : α) => nat.add_sub_cancel (coe_fn f a) (coe_fn g a)\n\n@[simp] theorem nat_add_sub_cancel_left {α : Type u_1} (f : α →₀ ℕ) (g : α →₀ ℕ) : f + g - f = g :=\n  ext fun (a : α) => nat.add_sub_cancel_left (coe_fn f a) (coe_fn g a)\n\ntheorem nat_add_sub_of_le {α : Type u_1} {f : α →₀ ℕ} {g : α →₀ ℕ} (h : f ≤ g) : f + (g - f) = g :=\n  ext fun (a : α) => nat.add_sub_of_le (h a)\n\ntheorem nat_sub_add_cancel {α : Type u_1} {f : α →₀ ℕ} {g : α →₀ ℕ} (h : f ≤ g) : g - f + f = g :=\n  ext fun (a : α) => nat.sub_add_cancel (h a)\n\nprotected instance canonically_ordered_add_monoid {α : Type u_1} :\n    canonically_ordered_add_monoid (α →₀ ℕ) :=\n  canonically_ordered_add_monoid.mk ordered_add_comm_monoid.add sorry ordered_add_comm_monoid.zero\n    sorry sorry sorry ordered_add_comm_monoid.le ordered_add_comm_monoid.lt sorry sorry sorry sorry\n    sorry 0 sorry sorry\n\n/-- The `finsupp` counterpart of `multiset.antidiagonal`: the antidiagonal of\n`s : α →₀ ℕ` consists of all pairs `(t₁, t₂) : (α →₀ ℕ) × (α →₀ ℕ)` such that `t₁ + t₂ = s`.\nThe finitely supported function `antidiagonal s` is equal to the multiplicities of these pairs. -/\ndef antidiagonal {α : Type u_1} (f : α →₀ ℕ) : (α →₀ ℕ) × (α →₀ ℕ) →₀ ℕ :=\n  coe_fn multiset.to_finsupp\n    (multiset.map (prod.map ⇑multiset.to_finsupp ⇑multiset.to_finsupp)\n      (multiset.antidiagonal (coe_fn to_multiset f)))\n\n@[simp] theorem mem_antidiagonal_support {α : Type u_1} {f : α →₀ ℕ} {p : (α →₀ ℕ) × (α →₀ ℕ)} :\n    p ∈ support (antidiagonal f) ↔ prod.fst p + prod.snd p = f :=\n  sorry\n\ntheorem swap_mem_antidiagonal_support {α : Type u_1} {n : α →₀ ℕ} {f : (α →₀ ℕ) × (α →₀ ℕ)} :\n    prod.swap f ∈ support (antidiagonal n) ↔ f ∈ support (antidiagonal n) :=\n  sorry\n\ntheorem antidiagonal_support_filter_fst_eq {α : Type u_1} (f : α →₀ ℕ) (g : α →₀ ℕ) :\n    finset.filter (fun (p : (α →₀ ℕ) × (α →₀ ℕ)) => prod.fst p = g) (support (antidiagonal f)) =\n        ite (g ≤ f) (singleton (g, f - g)) ∅ :=\n  sorry\n\ntheorem antidiagonal_support_filter_snd_eq {α : Type u_1} (f : α →₀ ℕ) (g : α →₀ ℕ) :\n    finset.filter (fun (p : (α →₀ ℕ) × (α →₀ ℕ)) => prod.snd p = g) (support (antidiagonal f)) =\n        ite (g ≤ f) (singleton (f - g, g)) ∅ :=\n  sorry\n\n@[simp] theorem antidiagonal_zero {α : Type u_1} : antidiagonal 0 = single (0, 0) 1 :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (antidiagonal 0 = single (0, 0) 1))\n        (Eq.symm (multiset.to_finsupp_singleton (0, 0)))))\n    (Eq.refl (antidiagonal 0))\n\ntheorem sum_antidiagonal_support_swap {α : Type u_1} {M : Type u_2} [add_comm_monoid M] (n : α →₀ ℕ)\n    (f : (α →₀ ℕ) → (α →₀ ℕ) → M) :\n    (finset.sum (support (antidiagonal n))\n          fun (p : (α →₀ ℕ) × (α →₀ ℕ)) => f (prod.fst p) (prod.snd p)) =\n        finset.sum (support (antidiagonal n))\n          fun (p : (α →₀ ℕ) × (α →₀ ℕ)) => f (prod.snd p) (prod.fst p) :=\n  sorry\n\n/-- The set `{m : α →₀ ℕ | m ≤ n}` as a `finset`. -/\ndef Iic_finset {α : Type u_1} (n : α →₀ ℕ) : finset (α →₀ ℕ) :=\n  finset.image prod.fst (support (antidiagonal n))\n\n@[simp] theorem mem_Iic_finset {α : Type u_1} {m : α →₀ ℕ} {n : α →₀ ℕ} :\n    m ∈ Iic_finset n ↔ m ≤ n :=\n  sorry\n\n@[simp] theorem coe_Iic_finset {α : Type u_1} (n : α →₀ ℕ) : ↑(Iic_finset n) = set.Iic n := sorry\n\n/-- Let `n : α →₀ ℕ` be a finitely supported function.\nThe set of `m : α →₀ ℕ` that are coordinatewise less than or equal to `n`,\nis a finite set. -/\ntheorem finite_le_nat {α : Type u_1} (n : α →₀ ℕ) : set.finite (set_of fun (m : α →₀ ℕ) => m ≤ n) :=\n  sorry\n\n/-- Let `n : α →₀ ℕ` be a finitely supported function.\nThe set of `m : α →₀ ℕ` that are coordinatewise less than or equal to `n`,\nbut not equal to `n` everywhere, is a finite set. -/\ntheorem finite_lt_nat {α : Type u_1} (n : α →₀ ℕ) : set.finite (set_of fun (m : α →₀ ℕ) => m < n) :=\n  set.finite.subset (finite_le_nat n) fun (m : α →₀ ℕ) => le_of_lt\n\nend finsupp\n\n\nnamespace multiset\n\n\ntheorem to_finsuppstrict_mono {α : Type u_1} : strict_mono ⇑to_finsupp :=\n  order_iso.strict_mono (order_iso.symm finsupp.order_iso_multiset)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/finsupp/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4680599533227754}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.limits.preserves.shapes.products\nimport topology.sheaves.sheaf_condition.equalizer_products\n\n/-!\n# Checking the sheaf condition on the underlying presheaf of types.\n\nIf `G : C ⥤ D` is a functor which reflects isomorphisms and preserves limits\n(we assume all limits exist in both `C` and `D`),\nthen checking the sheaf condition for a presheaf `F : presheaf C X`\nis equivalent to checking the sheaf condition for `F ⋙ G`.\n\nThe important special case is when\n`C` is a concrete category with a forgetful functor\nthat preserves limits and reflects isomorphisms.\nThen to check the sheaf condition it suffices\nto check it on the underlying sheaf of types.\n\n## References\n* https://stacks.math.columbia.edu/tag/0073\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\nopen topological_space\nopen opposite\n\nnamespace Top\n\nnamespace presheaf\n\nnamespace sheaf_condition\n\nopen sheaf_condition_equalizer_products\n\nuniverses v u₁ u₂\n\nvariables {C : Type u₁} [category.{v} C] [has_limits C]\nvariables {D : Type u₂} [category.{v} D] [has_limits D]\nvariables (G : C ⥤ D) [preserves_limits G]\nvariables {X : Top.{v}} (F : presheaf C X)\nvariables {ι : Type v} (U : ι → opens X)\n\nlocal attribute [reducible] diagram left_res right_res\n\n/--\nWhen `G` preserves limits, the sheaf condition diagram for `F` composed with `G` is\nnaturally isomorphic to the sheaf condition diagram for `F ⋙ G`.\n-/\ndef diagram_comp_preserves_limits :\n  diagram F U ⋙ G ≅ diagram.{v} (F ⋙ G) U :=\nbegin\n  fapply nat_iso.of_components,\n  rintro ⟨j⟩,\n  exact (preserves_product.iso _ _),\n  exact (preserves_product.iso _ _),\n  rintros ⟨⟩ ⟨⟩ ⟨⟩,\n  { ext, simp, dsimp, simp, }, -- non-terminal `simp`, but `squeeze_simp` fails\n  { ext,\n    simp only [limit.lift_π, functor.comp_map, map_lift_pi_comparison, fan.mk_π_app,\n               preserves_product.iso_hom, parallel_pair_map_left, functor.map_comp,\n               category.assoc],\n    dsimp, simp, },\n  { ext,\n    simp only [limit.lift_π, functor.comp_map, parallel_pair_map_right, fan.mk_π_app,\n               preserves_product.iso_hom, map_lift_pi_comparison, functor.map_comp,\n               category.assoc],\n    dsimp, simp, },\n  { ext, simp, dsimp, simp, },\nend\n\nlocal attribute [reducible] res\n\n/--\nWhen `G` preserves limits, the image under `G` of the sheaf condition fork for `F`\nis the sheaf condition fork for `F ⋙ G`,\npostcomposed with the inverse of the natural isomorphism `diagram_comp_preserves_limits`.\n-/\ndef map_cone_fork : G.map_cone (fork.{v} F U) ≅\n  (cones.postcompose (diagram_comp_preserves_limits G F U).inv).obj (fork (F ⋙ G) U) :=\ncones.ext (iso.refl _) (λ j,\nbegin\n  dsimp, simp [diagram_comp_preserves_limits], cases j; dsimp,\n  { rw iso.eq_comp_inv,\n    ext,\n    simp, dsimp, simp, },\n  { rw iso.eq_comp_inv,\n    ext,\n    simp, -- non-terminal `simp`, but `squeeze_simp` fails\n    dsimp,\n    simp only [limit.lift_π, fan.mk_π_app, ←G.map_comp, limit.lift_π_assoc, fan.mk_π_app] }\nend)\n\nend sheaf_condition\n\nuniverses v u₁ u₂\n\nopen sheaf_condition sheaf_condition_equalizer_products\n\nvariables {C : Type u₁} [category.{v} C] {D : Type u₂} [category.{v} D]\nvariables (G : C ⥤ D)\nvariables [reflects_isomorphisms G]\nvariables [has_limits C] [has_limits D] [preserves_limits G]\n\nvariables {X : Top.{v}} (F : presheaf C X)\n\n/--\nIf `G : C ⥤ D` is a functor which reflects isomorphisms and preserves limits\n(we assume all limits exist in both `C` and `D`),\nthen checking the sheaf condition for a presheaf `F : presheaf C X`\nis equivalent to checking the sheaf condition for `F ⋙ G`.\n\nThe important special case is when\n`C` is a concrete category with a forgetful functor\nthat preserves limits and reflects isomorphisms.\nThen to check the sheaf condition it suffices to check it on the underlying sheaf of types.\n\nAnother useful example is the forgetful functor `TopCommRing ⥤ Top`.\n\nSee <https://stacks.math.columbia.edu/tag/0073>.\nIn fact we prove a stronger version with arbitrary complete target category.\n-/\nlemma is_sheaf_iff_is_sheaf_comp :\n  presheaf.is_sheaf F ↔ presheaf.is_sheaf (F ⋙ G) :=\nbegin\n  rw [presheaf.is_sheaf_iff_is_sheaf_equalizer_products,\n    presheaf.is_sheaf_iff_is_sheaf_equalizer_products],\n  split,\n  { intros S ι U,\n    -- We have that the sheaf condition fork for `F` is a limit fork,\n    obtain ⟨t₁⟩ := S U,\n    -- and since `G` preserves limits, the image under `G` of this fork is a limit fork too.\n    letI := preserves_smallest_limits_of_preserves_limits G,\n    have t₂ := @preserves_limit.preserves _ _ _ _ _ _ _ G _ _ t₁,\n    -- As we established above, that image is just the sheaf condition fork\n    -- for `F ⋙ G` postcomposed with some natural isomorphism,\n    have t₃ := is_limit.of_iso_limit t₂ (map_cone_fork G F U),\n    -- and as postcomposing by a natural isomorphism preserves limit cones,\n    have t₄ := is_limit.postcompose_inv_equiv _ _ t₃,\n    -- we have our desired conclusion.\n    exact ⟨t₄⟩, },\n  { intros S ι U,\n    refine ⟨_⟩,\n    -- Let `f` be the universal morphism from `F.obj U` to the equalizer\n    -- of the sheaf condition fork, whatever it is.\n    -- Our goal is to show that this is an isomorphism.\n    let f := equalizer.lift _ (w F U),\n    -- If we can do that,\n    suffices : is_iso (G.map f),\n    { resetI,\n      -- we have that `f` itself is an isomorphism, since `G` reflects isomorphisms\n      haveI : is_iso f := is_iso_of_reflects_iso f G,\n      -- TODO package this up as a result elsewhere:\n      apply is_limit.of_iso_limit (limit.is_limit _),\n      apply iso.symm,\n      fapply cones.ext,\n      exact (as_iso f),\n      rintro ⟨_|_⟩; { dsimp [f], simp, }, },\n    { -- Returning to the task of shwoing that `G.map f` is an isomorphism,\n      -- we note that `G.map f` is almost but not quite (see below) a morphism\n      -- from the sheaf condition cone for `F ⋙ G` to the\n      -- image under `G` of the equalizer cone for the sheaf condition diagram.\n      let c := fork (F ⋙ G) U,\n      obtain ⟨hc⟩ := S U,\n      let d := G.map_cone (equalizer.fork (left_res.{v} F U) (right_res F U)),\n      letI := preserves_smallest_limits_of_preserves_limits G,\n      have hd : is_limit d := preserves_limit.preserves (limit.is_limit _),\n      -- Since both of these are limit cones\n      -- (`c` by our hypothesis `S`, and `d` because `G` preserves limits),\n      -- we hope to be able to conclude that `f` is an isomorphism.\n      -- We say \"not quite\" above because `c` and `d` don't quite have the same shape:\n      -- we need to postcompose by the natural isomorphism `diagram_comp_preserves_limits`\n      -- introduced above.\n      let d' := (cones.postcompose (diagram_comp_preserves_limits G F U).hom).obj d,\n      have hd' : is_limit d' :=\n        (is_limit.postcompose_hom_equiv (diagram_comp_preserves_limits G F U : _) d).symm hd,\n      -- Now everything works: we verify that `f` really is a morphism between these cones:\n      let f' : c ⟶ d' :=\n      fork.mk_hom (G.map f)\n      begin\n        dsimp only [c, d, d', f, diagram_comp_preserves_limits, res],\n        dunfold fork.ι,\n        ext1 j,\n        dsimp,\n        simp only [category.assoc, ←functor.map_comp_assoc, equalizer.lift_ι,\n          map_lift_pi_comparison_assoc],\n        dsimp [res], simp,\n      end,\n      -- conclude that it is an isomorphism,\n      -- just because it's a morphism between two limit cones.\n      haveI : is_iso f' := is_limit.hom_is_iso hc hd' f',\n      -- A cone morphism is an isomorphism exactly if the morphism between the cone points is,\n      -- so we're done!\n      exact is_iso.of_iso ((cones.forget _).map_iso (as_iso f')) }, },\nend\n\n/-!\nAs an example, we now have everything we need to check the sheaf condition\nfor a presheaf of commutative rings, merely by checking the sheaf condition\nfor the underlying sheaf of types.\n```\nimport algebra.category.Ring.limits\nexample (X : Top) (F : presheaf CommRing X) (h : presheaf.is_sheaf (F ⋙ (forget CommRing))) :\n  F.is_sheaf :=\n(is_sheaf_iff_is_sheaf_comp (forget CommRing) F).mpr h\n```\n-/\n\nend presheaf\n\nend Top\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/sheaves/forget.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4680599454719677}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\n\nimport control.functor.multivariate\nimport data.qpf.multivariate.basic\n\n/-!\n# Constant functors are QPFs\n\nConstant functors map every type vectors to the same target type. This\nis a useful device for constructing data types from more basic types\nthat are not actually functorial. For instance `const n nat` makes\n`nat` into a functor that can be used in a functor-based data type\nspecification.\n-/\n\nuniverses u\n\nnamespace mvqpf\nopen_locale mvfunctor\n\nvariables (n : ℕ)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A α} [inhabited A] : inhabited (const n A α) :=\n⟨ (default A : A) ⟩\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {α β : typevec.{u} n} (f : α ⟹ β)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) α := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) α) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) α) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A α) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) α → (const n A) β :=\nλ x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := λ α β f, const.map }\n\nlemma map_mk (x : A) :\n  f <$$> const.mk x = const.mk x := rfl\n\nlemma get_map (x : (const n A) α) :\n  const.get (f <$$> x) = const.get x := rfl\n\ninstance mvqpf : @mvqpf _ (const n A) (mvqpf.const.mvfunctor) :=\n{ P         := mvpfunctor.const n A,\n  abs       := λ α x, mvpfunctor.const.get x,\n  repr      := λ α x, mvpfunctor.const.mk n x,\n  abs_repr  := by intros; simp,\n  abs_map   := by intros; simp; refl,\n}\n\nend const\n\nend mvqpf\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/qpf/multivariate/constructions/const.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.46805994060862144}}
{"text": "/-\nCopyright (c) 2022 Yuyang Zhao. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yuyang Zhao\n\n! This file was ported from Lean 3 source module ring_theory.mv_polynomial.tower\n! leanprover-community/mathlib commit 932872382355f00112641d305ba0619305dc8642\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Tower\nimport Mathbin.Data.MvPolynomial.Basic\n\n/-!\n# Algebra towers for multivariate polynomial\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves some basic results about the algebra tower structure for the type\n`mv_polynomial σ R`.\n\nThis structure itself is provided elsewhere as `mv_polynomial.is_scalar_tower`\n\nWhen you update this file, you can also try to make a corresponding update in\n`ring_theory.polynomial.tower`.\n-/\n\n\nvariable (R A B : Type _) {σ : Type _}\n\nnamespace MvPolynomial\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring A] [CommSemiring B]\n\nvariable [Algebra R A] [Algebra A B] [Algebra R B]\n\nvariable [IsScalarTower R A B]\n\nvariable {R B}\n\n/- warning: mv_polynomial.aeval_map_algebra_map -> MvPolynomial.aeval_map_algebraMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} (A : Type.{u2}) {B : Type.{u3}} {σ : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : CommSemiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_6 : Algebra.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6)))))] (x : σ -> B) (p : MvPolynomial.{u4, u1} σ R _inst_1), Eq.{succ u3} B (coeFn.{max (succ (max u4 u2)) (succ u3), max (succ (max u4 u2)) (succ u3)} (AlgHom.{u2, max u4 u2, u3} A (MvPolynomial.{u4, u2} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u2, u2, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u2} A _inst_2)) _inst_5) (fun (_x : AlgHom.{u2, max u4 u2, u3} A (MvPolynomial.{u4, u2} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u2, u2, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u2} A _inst_2)) _inst_5) => (MvPolynomial.{u4, u2} σ A _inst_2) -> B) ([anonymous].{u2, max u4 u2, u3} A (MvPolynomial.{u4, u2} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u2, u2, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u2} A _inst_2)) _inst_5) (MvPolynomial.aeval.{u2, u3, u4} A B σ _inst_2 _inst_3 _inst_5 x) (coeFn.{max (succ (max u4 u1)) (succ (max u4 u2)), max (succ (max u4 u1)) (succ (max u4 u2))} (RingHom.{max u4 u1, max u4 u2} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.{u4, u2} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A σ _inst_2)))) (fun (_x : RingHom.{max u4 u1, max u4 u2} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.{u4, u2} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A σ _inst_2)))) => (MvPolynomial.{u4, u1} σ R _inst_1) -> (MvPolynomial.{u4, u2} σ A _inst_2)) (RingHom.hasCoeToFun.{max u4 u1, max u4 u2} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.{u4, u2} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} σ A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A σ _inst_2)))) (MvPolynomial.map.{u1, u2, u4} R A σ _inst_1 _inst_2 (algebraMap.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4)) p)) (coeFn.{max (succ (max u4 u1)) (succ u3), max (succ (max u4 u1)) (succ u3)} (AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} σ R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B σ _inst_1 _inst_3 _inst_6 x) p)\nbut is expected to have type\n  forall {R : Type.{u3}} (A : Type.{u1}) {B : Type.{u2}} {σ : Type.{u4}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u1} A] [_inst_3 : CommSemiring.{u2} B] [_inst_4 : Algebra.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2)] [_inst_5 : Algebra.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3)] [_inst_6 : Algebra.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3)] [_inst_7 : IsScalarTower.{u3, u1, u2} R A B (Algebra.toSMul.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4) (Algebra.toSMul.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_5) (Algebra.toSMul.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6)] (x : σ -> B) (p : MvPolynomial.{u4, u3} σ R _inst_1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u1} σ A _inst_2) => B) (FunLike.coe.{max (max (succ u3) (succ u1)) (succ u4), max (succ u3) (succ u4), max (succ u1) (succ u4)} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (fun (a : MvPolynomial.{u4, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u4, u3} σ R _inst_1) => MvPolynomial.{u4, u1} σ A _inst_2) a) (MulHomClass.toFunLike.{max (max u3 u1) u4, max u3 u4, max u1 u4} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (NonUnitalNonAssocSemiring.toMul.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))) (NonUnitalRingHomClass.toMulHomClass.{max (max u3 u1) u4, max u3 u4, max u1 u4} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (RingHomClass.toNonUnitalRingHomClass.{max (max u3 u1) u4, max u3 u4, max u1 u4} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))) (RingHom.instRingHomClassRingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))))) (MvPolynomial.map.{u3, u1, u4} R A σ _inst_1 _inst_2 (algebraMap.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4)) p)) (FunLike.coe.{max (max (succ u2) (succ u4)) (succ u1), max (succ u4) (succ u1), succ u2} (AlgHom.{u1, max u1 u4, u2} A (MvPolynomial.{u4, u1} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) (MvPolynomial.{u4, u1} σ A _inst_2) (fun (_x : MvPolynomial.{u4, u1} σ A _inst_2) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u1} σ A _inst_2) => B) _x) (SMulHomClass.toFunLike.{max (max u2 u4) u1, u1, max u4 u1, u2} (AlgHom.{u1, max u1 u4, u2} A (MvPolynomial.{u4, u1} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) A (MvPolynomial.{u4, u1} σ A _inst_2) B (SMulZeroClass.toSMul.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) (AddMonoid.toZero.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (AddCommMonoid.toAddMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))))) (DistribSMul.toSMulZeroClass.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) (AddMonoid.toAddZeroClass.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (AddCommMonoid.toAddMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))))) (DistribMulAction.toDistribSMul.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (AddCommMonoid.toAddMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))))) (Module.toDistribMulAction.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))) (Algebra.toModule.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2))))))) (SMulZeroClass.toSMul.{u1, u2} A B (AddMonoid.toZero.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u1, u2} A B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u1, u2} A B (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))))) (Module.toDistribMulAction.{u1, u2} A B (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u2 u4) u1, u1, max u4 u1, u2} (AlgHom.{u1, max u1 u4, u2} A (MvPolynomial.{u4, u1} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) A (MvPolynomial.{u4, u1} σ A _inst_2) B (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (AddCommMonoid.toAddMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))))) (Module.toDistribMulAction.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))) (Algebra.toModule.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} A B (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_5)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u2 u4) u1, u1, max u4 u1, u2} (AlgHom.{u1, max u1 u4, u2} A (MvPolynomial.{u4, u1} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) A (MvPolynomial.{u4, u1} σ A _inst_2) B (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) (Module.toDistribMulAction.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))) (Algebra.toModule.{u1, max u4 u1} A (MvPolynomial.{u4, u1} σ A _inst_2) _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} A B (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_5)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, max u4 u1, u2, max (max u2 u4) u1} A (MvPolynomial.{u4, u1} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5 (AlgHom.{u1, max u1 u4, u2} A (MvPolynomial.{u4, u1} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) (AlgHom.algHomClass.{u1, max u4 u1, u2} A (MvPolynomial.{u4, u1} σ A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A σ _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5))))) (MvPolynomial.aeval.{u1, u2, u4} A B σ _inst_2 _inst_3 _inst_5 x) (FunLike.coe.{max (max (succ u3) (succ u1)) (succ u4), max (succ u3) (succ u4), max (succ u1) (succ u4)} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u4, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u4, u3} σ R _inst_1) => MvPolynomial.{u4, u1} σ A _inst_2) _x) (MulHomClass.toFunLike.{max (max u3 u1) u4, max u3 u4, max u1 u4} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (NonUnitalNonAssocSemiring.toMul.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))) (NonUnitalRingHomClass.toMulHomClass.{max (max u3 u1) u4, max u3 u4, max u1 u4} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (RingHomClass.toNonUnitalRingHomClass.{max (max u3 u1) u4, max u3 u4, max u1 u4} (RingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2)))) (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))) (RingHom.instRingHomClassRingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.{u4, u1} σ A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} σ A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A σ _inst_2))))))) (MvPolynomial.map.{u3, u1, u4} R A σ _inst_1 _inst_2 (algebraMap.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4)) p)) (FunLike.coe.{max (max (succ u2) (succ u4)) (succ u3), max (succ u4) (succ u3), succ u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (MvPolynomial.{u4, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u4, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) _x) (SMulHomClass.toFunLike.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R B (AddMonoid.toZero.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u3, u2} R B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u3, u2} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u4 u3, u2, max (max u2 u4) u3} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, max u4 u3, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u3, u2, u4} R B σ _inst_1 _inst_3 _inst_6 x) p)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.aeval_map_algebra_map MvPolynomial.aeval_map_algebraMapₓ'. -/\ntheorem aeval_map_algebraMap (x : σ → B) (p : MvPolynomial σ R) :\n    aeval x (map (algebraMap R A) p) = aeval x p := by\n  rw [aeval_def, aeval_def, eval₂_map, IsScalarTower.algebraMap_eq R A B]\n#align mv_polynomial.aeval_map_algebra_map MvPolynomial.aeval_map_algebraMap\n\nend Semiring\n\nsection CommSemiring\n\nvariable [CommSemiring R] [CommSemiring A] [CommSemiring B]\n\nvariable [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B]\n\nvariable {R A}\n\n/- warning: mv_polynomial.aeval_algebra_map_apply -> MvPolynomial.aeval_algebraMap_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} (B : Type.{u3}) {σ : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : CommSemiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_6 : Algebra.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6)))))] (x : σ -> A) (p : MvPolynomial.{u4, u1} σ R _inst_1), Eq.{succ u3} B (coeFn.{max (succ (max u4 u1)) (succ u3), max (succ (max u4 u1)) (succ u3)} (AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} σ R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B σ _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u3} σ A B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (algebraMap.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5)) x)) p) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (algebraMap.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5) (coeFn.{max (succ (max u4 u1)) (succ u2), max (succ (max u4 u1)) (succ u2)} (AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) => (MvPolynomial.{u4, u1} σ R _inst_1) -> A) ([anonymous].{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.aeval.{u1, u2, u4} R A σ _inst_1 _inst_2 _inst_4 x) p))\nbut is expected to have type\n  forall {R : Type.{u3}} {A : Type.{u1}} (B : Type.{u2}) {σ : Type.{u4}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u1} A] [_inst_3 : CommSemiring.{u2} B] [_inst_4 : Algebra.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2)] [_inst_5 : Algebra.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3)] [_inst_6 : Algebra.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3)] [_inst_7 : IsScalarTower.{u3, u1, u2} R A B (Algebra.toSMul.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4) (Algebra.toSMul.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_5) (Algebra.toSMul.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6)] (x : σ -> A) (p : MvPolynomial.{u4, u3} σ R _inst_1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) p) (FunLike.coe.{max (max (succ u2) (succ u4)) (succ u3), max (succ u4) (succ u3), succ u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (MvPolynomial.{u4, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u4, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) _x) (SMulHomClass.toFunLike.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R B (AddMonoid.toZero.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u3, u2} R B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u3, u2} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (Algebra.toModule.{u3, u2} R B _inst_1 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u4 u3, u2, max (max u2 u4) u3} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, max u4 u3, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u3, u2, u4} R B σ _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u1, succ u2} σ A B (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A B (NonUnitalNonAssocSemiring.toMul.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)) (RingHom.instRingHomClassRingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (algebraMap.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_5)) x)) p) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A B (NonUnitalNonAssocSemiring.toMul.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3))) A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)) (RingHom.instRingHomClassRingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B (CommSemiring.toSemiring.{u2} B _inst_3)))))) (algebraMap.{u1, u2} A B _inst_2 (CommSemiring.toSemiring.{u2} B _inst_3) _inst_5) (FunLike.coe.{max (max (succ u1) (succ u4)) (succ u3), max (succ u4) (succ u3), succ u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (MvPolynomial.{u4, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u4, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => A) _x) (SMulHomClass.toFunLike.{max (max u1 u4) u3, u3, max u4 u3, u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} σ R _inst_1) A (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u1} R A (AddMonoid.toZero.{u1} A (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u3, u1} R A (AddMonoid.toAddZeroClass.{u1} A (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u3, u1} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Module.toDistribMulAction.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u1 u4) u3, u3, max u4 u3, u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} σ R _inst_1) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u1 u4) u3, u3, max u4 u3, u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} σ R _inst_1) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u4 u3, u1, max (max u1 u4) u3} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4 (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u3, max u4 u3, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4))))) (MvPolynomial.aeval.{u3, u1, u4} R A σ _inst_1 _inst_2 _inst_4 x) p))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.aeval_algebra_map_apply MvPolynomial.aeval_algebraMap_applyₓ'. -/\ntheorem aeval_algebraMap_apply (x : σ → A) (p : MvPolynomial σ R) :\n    aeval (algebraMap A B ∘ x) p = algebraMap A B (MvPolynomial.aeval x p) := by\n  rw [aeval_def, aeval_def, ← coe_eval₂_hom, ← coe_eval₂_hom, map_eval₂_hom, ←\n    IsScalarTower.algebraMap_eq]\n#align mv_polynomial.aeval_algebra_map_apply MvPolynomial.aeval_algebraMap_apply\n\n/- warning: mv_polynomial.aeval_algebra_map_eq_zero_iff -> MvPolynomial.aeval_algebraMap_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} (B : Type.{u3}) {σ : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : CommSemiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_6 : Algebra.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6)))))] [_inst_8 : NoZeroSMulDivisors.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (MulZeroClass.toHasZero.{u3} B (NonUnitalNonAssocSemiring.toMulZeroClass.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5)))))] [_inst_9 : Nontrivial.{u3} B] (x : σ -> A) (p : MvPolynomial.{u4, u1} σ R _inst_1), Iff (Eq.{succ u3} B (coeFn.{max (succ (max u4 u1)) (succ u3), max (succ (max u4 u1)) (succ u3)} (AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} σ R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B σ _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u3} σ A B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (algebraMap.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5)) x)) p) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (MulZeroClass.toHasZero.{u3} B (NonUnitalNonAssocSemiring.toMulZeroClass.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))))) (Eq.{succ u2} A (coeFn.{max (succ (max u4 u1)) (succ u2), max (succ (max u4 u1)) (succ u2)} (AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) => (MvPolynomial.{u4, u1} σ R _inst_1) -> A) ([anonymous].{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.aeval.{u1, u2, u4} R A σ _inst_1 _inst_2 _inst_4 x) p) (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u4}} (B : Type.{u3}) {σ : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u4} A] [_inst_3 : CommSemiring.{u3} B] [_inst_4 : Algebra.{u1, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2)] [_inst_5 : Algebra.{u4, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_6 : Algebra.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_7 : IsScalarTower.{u1, u4, u3} R A B (Algebra.toSMul.{u1, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4) (Algebra.toSMul.{u4, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5) (Algebra.toSMul.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6)] [_inst_8 : NoZeroSMulDivisors.{u4, u3} A B (CommMonoidWithZero.toZero.{u4} A (CommSemiring.toCommMonoidWithZero.{u4} A _inst_2)) (CommMonoidWithZero.toZero.{u3} B (CommSemiring.toCommMonoidWithZero.{u3} B _inst_3)) (Algebra.toSMul.{u4, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5)] [_inst_9 : Nontrivial.{u3} B] (x : σ -> A) (p : MvPolynomial.{u2, u1} σ R _inst_1), Iff (Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => B) p) (FunLike.coe.{max (max (succ u3) (succ u2)) (succ u1), max (succ u2) (succ u1), succ u3} (AlgHom.{u1, max u1 u2, u3} R (MvPolynomial.{u2, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.{u2, u1} σ R _inst_1) (fun (_x : MvPolynomial.{u2, u1} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => B) _x) (SMulHomClass.toFunLike.{max (max u3 u2) u1, u1, max u2 u1, u3} (AlgHom.{u1, max u1 u2, u3} R (MvPolynomial.{u2, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) R (MvPolynomial.{u2, u1} σ R _inst_1) B (SMulZeroClass.toSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (AddMonoid.toZero.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)))))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1))))))) (SMulZeroClass.toSMul.{u1, u3} R B (AddMonoid.toZero.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u1, u3} R B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u1, u3} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u3 u2) u1, u1, max u2 u1, u3} (AlgHom.{u1, max u1 u2, u3} R (MvPolynomial.{u2, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) R (MvPolynomial.{u2, u1} σ R _inst_1) B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u3 u2) u1, u1, max u2 u1, u3} (AlgHom.{u1, max u1 u2, u3} R (MvPolynomial.{u2, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) R (MvPolynomial.{u2, u1} σ R _inst_1) B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, max u2 u1, u3, max (max u3 u2) u1} R (MvPolynomial.{u2, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6 (AlgHom.{u1, max u1 u2, u3} R (MvPolynomial.{u2, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u1, max u2 u1, u3} R (MvPolynomial.{u2, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u1, u3, u2} R B σ _inst_1 _inst_3 _inst_6 (Function.comp.{succ u2, succ u4, succ u3} σ A B (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (RingHom.{u4, u3} A B (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u4 u3, u4, u3} (RingHom.{u4, u3} A B (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) A B (NonUnitalNonAssocSemiring.toMul.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (NonUnitalRingHomClass.toMulHomClass.{max u4 u3, u4, u3} (RingHom.{u4, u3} A B (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (RingHomClass.toNonUnitalRingHomClass.{max u4 u3, u4, u3} (RingHom.{u4, u3} A B (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) A B (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)) (RingHom.instRingHomClassRingHom.{u4, u3} A B (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))))) (algebraMap.{u4, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5)) x)) p) (OfNat.ofNat.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => B) p) 0 (Zero.toOfNat0.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => B) p) (CommMonoidWithZero.toZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => B) p) (CommSemiring.toCommMonoidWithZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => B) p) _inst_3))))) (Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => A) p) (FunLike.coe.{max (max (succ u4) (succ u2)) (succ u1), max (succ u2) (succ u1), succ u4} (AlgHom.{u1, max u1 u2, u4} R (MvPolynomial.{u2, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.{u2, u1} σ R _inst_1) (fun (_x : MvPolynomial.{u2, u1} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => A) _x) (SMulHomClass.toFunLike.{max (max u4 u2) u1, u1, max u2 u1, u4} (AlgHom.{u1, max u1 u2, u4} R (MvPolynomial.{u2, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) R (MvPolynomial.{u2, u1} σ R _inst_1) A (SMulZeroClass.toSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (AddMonoid.toZero.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)))))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1))))))) (SMulZeroClass.toSMul.{u1, u4} R A (AddMonoid.toZero.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u1, u4} R A (AddMonoid.toAddZeroClass.{u4} A (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u1, u4} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))))) (Module.toDistribMulAction.{u1, u4} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (Algebra.toModule.{u1, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u4 u2) u1, u1, max u2 u1, u4} (AlgHom.{u1, max u1 u2, u4} R (MvPolynomial.{u2, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) R (MvPolynomial.{u2, u1} σ R _inst_1) A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u4} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u4} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (Algebra.toModule.{u1, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u4 u2) u1, u1, max u2 u1, u4} (AlgHom.{u1, max u1 u2, u4} R (MvPolynomial.{u2, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) R (MvPolynomial.{u2, u1} σ R _inst_1) A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} σ R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u4} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A (CommSemiring.toSemiring.{u4} A _inst_2)))) (Algebra.toModule.{u1, u4} R A _inst_1 (CommSemiring.toSemiring.{u4} A _inst_2) _inst_4)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, max u2 u1, u4, max (max u4 u2) u1} R (MvPolynomial.{u2, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4 (AlgHom.{u1, max u1 u2, u4} R (MvPolynomial.{u2, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u1, max u2 u1, u4} R (MvPolynomial.{u2, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R σ _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4))))) (MvPolynomial.aeval.{u1, u4, u2} R A σ _inst_1 _inst_2 _inst_4 x) p) (OfNat.ofNat.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => A) p) 0 (Zero.toOfNat0.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => A) p) (CommMonoidWithZero.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => A) p) (CommSemiring.toCommMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} σ R _inst_1) => A) p) _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.aeval_algebra_map_eq_zero_iff MvPolynomial.aeval_algebraMap_eq_zero_iffₓ'. -/\ntheorem aeval_algebraMap_eq_zero_iff [NoZeroSMulDivisors A B] [Nontrivial B] (x : σ → A)\n    (p : MvPolynomial σ R) : aeval (algebraMap A B ∘ x) p = 0 ↔ aeval x p = 0 := by\n  rw [aeval_algebra_map_apply, Algebra.algebraMap_eq_smul_one, smul_eq_zero,\n    iff_false_intro (one_ne_zero' B), or_false_iff]\n#align mv_polynomial.aeval_algebra_map_eq_zero_iff MvPolynomial.aeval_algebraMap_eq_zero_iff\n\n/- warning: mv_polynomial.aeval_algebra_map_eq_zero_iff_of_injective -> MvPolynomial.aeval_algebraMap_eq_zero_iff_of_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} (B : Type.{u3}) {σ : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : CommSemiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_6 : Algebra.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3)] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3)))) (Algebra.toModule.{u1, u3} R B _inst_1 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_6)))))] {x : σ -> A} {p : MvPolynomial.{u4, u1} σ R _inst_1}, (Function.Injective.{succ u2, succ u3} A B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (algebraMap.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5))) -> (Iff (Eq.{succ u3} B (coeFn.{max (succ (max u4 u1)) (succ u3), max (succ (max u4 u1)) (succ u3)} (AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} σ R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B σ _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u3} σ A B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))) (algebraMap.{u2, u3} A B _inst_2 (CommSemiring.toSemiring.{u3} B _inst_3) _inst_5)) x)) p) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (MulZeroClass.toHasZero.{u3} B (NonUnitalNonAssocSemiring.toMulZeroClass.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B (CommSemiring.toSemiring.{u3} B _inst_3))))))))) (Eq.{succ u2} A (coeFn.{max (succ (max u4 u1)) (succ u2), max (succ (max u4 u1)) (succ u2)} (AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) => (MvPolynomial.{u4, u1} σ R _inst_1) -> A) ([anonymous].{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.aeval.{u1, u2, u4} R A σ _inst_1 _inst_2 _inst_4 x) p) (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))))))\nbut is expected to have type\n  forall {R : Type.{u3}} {A : Type.{u2}} (B : Type.{u1}) {σ : Type.{u4}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : CommSemiring.{u1} B] [_inst_4 : Algebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u1} A B _inst_2 (CommSemiring.toSemiring.{u1} B _inst_3)] [_inst_6 : Algebra.{u3, u1} R B _inst_1 (CommSemiring.toSemiring.{u1} B _inst_3)] [_inst_7 : IsScalarTower.{u3, u2, u1} R A B (Algebra.toSMul.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4) (Algebra.toSMul.{u2, u1} A B _inst_2 (CommSemiring.toSemiring.{u1} B _inst_3) _inst_5) (Algebra.toSMul.{u3, u1} R B _inst_1 (CommSemiring.toSemiring.{u1} B _inst_3) _inst_6)] {x : σ -> A} {p : MvPolynomial.{u4, u3} σ R _inst_1}, (Function.Injective.{succ u2, succ u1} A B (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)) (RingHom.instRingHomClassRingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))))) (algebraMap.{u2, u1} A B _inst_2 (CommSemiring.toSemiring.{u1} B _inst_3) _inst_5))) -> (Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) p) (FunLike.coe.{max (max (succ u1) (succ u4)) (succ u3), max (succ u4) (succ u3), succ u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (MvPolynomial.{u4, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u4, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) _x) (SMulHomClass.toFunLike.{max (max u1 u4) u3, u3, max u4 u3, u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u1} R B (AddMonoid.toZero.{u1} B (AddCommMonoid.toAddMonoid.{u1} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))))) (DistribSMul.toSMulZeroClass.{u3, u1} R B (AddMonoid.toAddZeroClass.{u1} B (AddCommMonoid.toAddMonoid.{u1} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))))) (DistribMulAction.toDistribSMul.{u3, u1} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))))) (Module.toDistribMulAction.{u3, u1} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))) (Algebra.toModule.{u3, u1} R B _inst_1 (CommSemiring.toSemiring.{u1} B _inst_3) _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u1 u4) u3, u3, max u4 u3, u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u1} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))) (Algebra.toModule.{u3, u1} R B _inst_1 (CommSemiring.toSemiring.{u1} B _inst_3) _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u1 u4) u3, u3, max u4 u3, u1} (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} σ R _inst_1) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))) (Algebra.toModule.{u3, u1} R B _inst_1 (CommSemiring.toSemiring.{u1} B _inst_3) _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u4 u3, u1, max (max u1 u4) u3} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, max u4 u3, u1} R (MvPolynomial.{u4, u3} σ R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u3, u1, u4} R B σ _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u1} σ A B (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3))) A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)) (RingHom.instRingHomClassRingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B (CommSemiring.toSemiring.{u1} B _inst_3)))))) (algebraMap.{u2, u1} A B _inst_2 (CommSemiring.toSemiring.{u1} B _inst_3) _inst_5)) x)) p) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) p) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) p) (CommMonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) p) (CommSemiring.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => B) p) _inst_3))))) (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => A) p) (FunLike.coe.{max (max (succ u2) (succ u4)) (succ u3), max (succ u4) (succ u3), succ u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (MvPolynomial.{u4, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u4, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => A) _x) (SMulHomClass.toFunLike.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} σ R _inst_1) A (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u3, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u3, u2} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} σ R _inst_1) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u2 u4) u3, u3, max u4 u3, u2} (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} σ R _inst_1) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u4 u3, u2, max (max u2 u4) u3} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4 (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u3, max u4 u3, u2} R (MvPolynomial.{u4, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4))))) (MvPolynomial.aeval.{u3, u2, u4} R A σ _inst_1 _inst_2 _inst_4 x) p) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => A) p) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => A) p) (CommMonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => A) p) (CommSemiring.toCommMonoidWithZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} σ R _inst_1) => A) p) _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.aeval_algebra_map_eq_zero_iff_of_injective MvPolynomial.aeval_algebraMap_eq_zero_iff_of_injectiveₓ'. -/\ntheorem aeval_algebraMap_eq_zero_iff_of_injective {x : σ → A} {p : MvPolynomial σ R}\n    (h : Function.Injective (algebraMap A B)) : aeval (algebraMap A B ∘ x) p = 0 ↔ aeval x p = 0 :=\n  by rw [aeval_algebra_map_apply, ← (algebraMap A B).map_zero, h.eq_iff]\n#align mv_polynomial.aeval_algebra_map_eq_zero_iff_of_injective MvPolynomial.aeval_algebraMap_eq_zero_iff_of_injective\n\nend CommSemiring\n\nend MvPolynomial\n\nnamespace Subalgebra\n\nopen MvPolynomial\n\nsection CommSemiring\n\nvariable {R A} [CommSemiring R] [CommSemiring A] [Algebra R A]\n\n/- warning: subalgebra.mv_polynomial_aeval_coe -> Subalgebra.mvPolynomial_aeval_coe is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {σ : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] (S : Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (x : σ -> (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S)) (p : MvPolynomial.{u3, u1} σ R _inst_1), Eq.{succ u2} A (coeFn.{max (succ (max u3 u1)) (succ u2), max (succ (max u3 u1)) (succ u2)} (AlgHom.{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_3) (fun (_x : AlgHom.{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_3) => (MvPolynomial.{u3, u1} σ R _inst_1) -> A) ([anonymous].{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_3) (MvPolynomial.aeval.{u1, u2, u3} R A σ _inst_1 _inst_2 _inst_3 (fun (i : σ) => (fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeSubtype.{succ u2} A (fun (x : A) => Membership.Mem.{u2, u2} A (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.hasMem.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S))))) (x i))) p) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeSubtype.{succ u2} A (fun (x : A) => Membership.Mem.{u2, u2} A (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.hasMem.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S))))) (coeFn.{max (succ (max u3 u1)) (succ u2), max (succ (max u3 u1)) (succ u2)} (AlgHom.{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} σ R _inst_1) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) (Subalgebra.toCommSemiring.{u1, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u1, u1, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) (fun (_x : AlgHom.{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} σ R _inst_1) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) (Subalgebra.toCommSemiring.{u1, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u1, u1, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) => (MvPolynomial.{u3, u1} σ R _inst_1) -> (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S)) ([anonymous].{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} σ R _inst_1) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} σ R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) (Subalgebra.toCommSemiring.{u1, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u1, u1, u3} R R σ _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) (MvPolynomial.aeval.{u1, u2, u3} R (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) σ _inst_1 (Subalgebra.toCommSemiring.{u1, u2} R A _inst_1 _inst_2 _inst_3 S) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) x) p))\nbut is expected to have type\n  forall {R : Type.{u3}} {A : Type.{u2}} {σ : Type.{u1}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Algebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] (S : Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (x : σ -> (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S))) (p : MvPolynomial.{u1, u3} σ R _inst_1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} σ R _inst_1) => A) p) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (succ u1) (succ u3), succ u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) (MvPolynomial.{u1, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u1, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} σ R _inst_1) => A) _x) (SMulHomClass.toFunLike.{max (max u2 u1) u3, u3, max u1 u3, u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) R (MvPolynomial.{u1, u3} σ R _inst_1) A (SMulZeroClass.toSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u3, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u3, u2} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u2 u1) u3, u3, max u1 u3, u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) R (MvPolynomial.{u1, u3} σ R _inst_1) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u2 u1) u3, u3, max u1 u3, u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) R (MvPolynomial.{u1, u3} σ R _inst_1) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u1 u3, u2, max (max u2 u1) u3} R (MvPolynomial.{u1, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3 (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) (AlgHom.algHomClass.{u3, max u1 u3, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3))))) (MvPolynomial.aeval.{u3, u2, u1} R A σ _inst_1 _inst_2 _inst_3 (fun (i : σ) => Subtype.val.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Set.{u2} A) (Set.instMembershipSet.{u2} A) x (SetLike.coe.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) S)) (x i))) p) (Subtype.val.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Set.{u2} A) (Set.instMembershipSet.{u2} A) x (SetLike.coe.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) S)) (FunLike.coe.{max (max (succ u2) (succ u1)) (succ u3), max (succ u1) (succ u3), succ u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) (MvPolynomial.{u1, u3} σ R _inst_1) (fun (_x : MvPolynomial.{u1, u3} σ R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} σ R _inst_1) => Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _x) (SMulHomClass.toFunLike.{max (max u2 u1) u3, u3, max u1 u3, u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (SMulZeroClass.toSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (AddMonoid.toZero.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (AddCommMonoid.toAddMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S))))))) (DistribSMul.toSMulZeroClass.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (AddMonoid.toAddZeroClass.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (AddCommMonoid.toAddMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S))))))) (DistribMulAction.toDistribSMul.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)))))) (Module.toDistribMulAction.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S))))) (Algebra.toModule.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)))))) (DistribMulActionHomClass.toSMulHomClass.{max (max u2 u1) u3, u3, max u1 u3, u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S))))) (Algebra.toModule.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max (max u2 u1) u3, u3, max u1 u3, u2} (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} σ R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} σ R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S))))) (Algebra.toModule.{u3, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, max u1 u3, u2, max (max u2 u1) u3} R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) (AlgHom.algHomClass.{u3, max u1 u3, u2} R (MvPolynomial.{u1, u3} σ R _inst_1) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} σ R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R σ _inst_1)) (CommSemiring.toSemiring.{u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S)) (MvPolynomial.algebra.{u3, u3, u1} R R σ _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)))))) (MvPolynomial.aeval.{u3, u2, u1} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.instMembership.{u2, u2} (Subalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S)) σ _inst_1 (Subalgebra.toCommSemiring.{u3, u2} R A _inst_1 _inst_2 _inst_3 S) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) x) p))\nCase conversion may be inaccurate. Consider using '#align subalgebra.mv_polynomial_aeval_coe Subalgebra.mvPolynomial_aeval_coeₓ'. -/\n@[simp]\ntheorem mvPolynomial_aeval_coe (S : Subalgebra R A) (x : σ → S) (p : MvPolynomial σ R) :\n    aeval (fun i => (x i : A)) p = aeval x p := by convert aeval_algebra_map_apply A x p\n#align subalgebra.mv_polynomial_aeval_coe Subalgebra.mvPolynomial_aeval_coe\n\nend CommSemiring\n\nend Subalgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/MvPolynomial/Tower.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789086703225, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.4680478133379661}}
{"text": "lemma maze (P Q R S T U: Prop)\n(p : P)\n(h : P → Q)\n(i : Q → R)\n(j : Q → T)\n(k : S → T)\n(l : T → U)\n: U :=\nbegin\nhave q : Q := h p,\nhave t : T := j q,\nhave u : U := l t,\nexact u,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/4-proposition-world/l4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104789086703224, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.468047813337966}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module algebra.big_operators.order\n! leanprover-community/mathlib commit 824f9ae93a4f5174d2ea948e2d75843dd83447bb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.AbsoluteValue\nimport Mathbin.Algebra.Order.Ring.WithTop\nimport Mathbin.Algebra.BigOperators.Basic\nimport Mathbin.Data.Fintype.Card\n\n/-!\n# Results about big operators with values in an ordered algebraic structure.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nMostly monotonicity results for the `∏` and `∑` operations.\n\n-/\n\n\nopen Function\n\nopen BigOperators\n\nvariable {ι α β M N G k R : Type _}\n\nnamespace Finset\n\nsection OrderedCommMonoid\n\nvariable [CommMonoid M] [OrderedCommMonoid N]\n\n/- warning: finset.le_prod_nonempty_of_submultiplicative_on_pred -> Finset.le_prod_nonempty_of_submultiplicative_on_pred is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N) (p : M -> Prop), (forall (x : M) (y : M), (p x) -> (p y) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toHasMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y)))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y))) -> (forall (g : ι -> M) (s : Finset.{u1} ι), (Finset.Nonempty.{u1} ι s) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (p (g i))) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i)))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N) (p : M -> Prop), (forall (x : M) (y : M), (p x) -> (p y) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y)))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y))) -> (forall (g : ι -> M) (s : Finset.{u1} ι), (Finset.Nonempty.{u1} ι s) -> (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (p (g i))) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i)))))\nCase conversion may be inaccurate. Consider using '#align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_predₓ'. -/\n/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M → N` be a map\nsubmultiplicative on `{x | p x}`, i.e., `p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be\na nonempty finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then\n`f (∏ x in s, g x) ≤ ∏ x in s, f (g x)`. -/\n@[to_additive le_sum_nonempty_of_subadditive_on_pred]\ntheorem le_prod_nonempty_of_submultiplicative_on_pred (f : M → N) (p : M → Prop)\n    (h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y) (hp_mul : ∀ x y, p x → p y → p (x * y))\n    (g : ι → M) (s : Finset ι) (hs_nonempty : s.Nonempty) (hs : ∀ i ∈ s, p (g i)) :\n    f (∏ i in s, g i) ≤ ∏ i in s, f (g i) :=\n  by\n  refine' le_trans (Multiset.le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul _ _ _) _\n  · simp [hs_nonempty.ne_empty]\n  · exact multiset.forall_mem_map_iff.mpr hs\n  rw [Multiset.map_map]\n  rfl\n#align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred\n#align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred\n\n/-- Let `{x | p x}` be an additive subsemigroup of an additive commutative monoid `M`. Let\n`f : M → N` be a map subadditive on `{x | p x}`, i.e., `p x → p y → f (x + y) ≤ f x + f y`. Let\n`g i`, `i ∈ s`, be a nonempty finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then\n`f (∑ i in s, g i) ≤ ∑ i in s, f (g i)`. -/\nadd_decl_doc le_sum_nonempty_of_subadditive_on_pred\n\n/- warning: finset.le_prod_nonempty_of_submultiplicative -> Finset.le_prod_nonempty_of_submultiplicative is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N), (forall (x : M) (y : M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toHasMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y))) -> (forall {s : Finset.{u1} ι}, (Finset.Nonempty.{u1} ι s) -> (forall (g : ι -> M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i)))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N), (forall (x : M) (y : M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y))) -> (forall {s : Finset.{u1} ι}, (Finset.Nonempty.{u1} ι s) -> (forall (g : ι -> M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i)))))\nCase conversion may be inaccurate. Consider using '#align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicativeₓ'. -/\n/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y` and `g i`, `i ∈ s`, is a\nnonempty finite family of elements of `M`, then `f (∏ i in s, g i) ≤ ∏ i in s, f (g i)`. -/\n@[to_additive le_sum_nonempty_of_subadditive]\ntheorem le_prod_nonempty_of_submultiplicative (f : M → N) (h_mul : ∀ x y, f (x * y) ≤ f x * f y)\n    {s : Finset ι} (hs : s.Nonempty) (g : ι → M) : f (∏ i in s, g i) ≤ ∏ i in s, f (g i) :=\n  le_prod_nonempty_of_submultiplicative_on_pred f (fun i => True) (fun x y _ _ => h_mul x y)\n    (fun _ _ _ _ => trivial) g s hs fun _ _ => trivial\n#align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative\n#align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive\n\n/-- If `f : M → N` is a subadditive function, `f (x + y) ≤ f x + f y` and `g i`, `i ∈ s`, is a\nnonempty finite family of elements of `M`, then `f (∑ i in s, g i) ≤ ∑ i in s, f (g i)`. -/\nadd_decl_doc le_sum_nonempty_of_subadditive\n\n/- warning: finset.le_prod_of_submultiplicative_on_pred -> Finset.le_prod_of_submultiplicative_on_pred is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N) (p : M -> Prop), (Eq.{succ u3} N (f (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1))))))) (OfNat.ofNat.{u3} N 1 (OfNat.mk.{u3} N 1 (One.one.{u3} N (MulOneClass.toHasOne.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2)))))))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toHasMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y)))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y))) -> (forall (g : ι -> M) {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (p (g i))) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i)))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N) (p : M -> Prop), (Eq.{succ u3} N (f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1))))) (OfNat.ofNat.{u3} N 1 (One.toOfNat1.{u3} N (Monoid.toOne.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2)))))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y)))) -> (forall (x : M) (y : M), (p x) -> (p y) -> (p (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y))) -> (forall (g : ι -> M) {s : Finset.{u1} ι}, (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (p (g i))) -> (LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i)))))\nCase conversion may be inaccurate. Consider using '#align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_predₓ'. -/\n/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M → N` be a map\nsuch that `f 1 = 1` and `f` is submultiplicative on `{x | p x}`, i.e.,\n`p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be a finite family of elements of `M` such\nthat `∀ i ∈ s, p (g i)`. Then `f (∏ i in s, g i) ≤ ∏ i in s, f (g i)`. -/\n@[to_additive le_sum_of_subadditive_on_pred]\ntheorem le_prod_of_submultiplicative_on_pred (f : M → N) (p : M → Prop) (h_one : f 1 = 1)\n    (h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y) (hp_mul : ∀ x y, p x → p y → p (x * y))\n    (g : ι → M) {s : Finset ι} (hs : ∀ i ∈ s, p (g i)) : f (∏ i in s, g i) ≤ ∏ i in s, f (g i) :=\n  by\n  rcases eq_empty_or_nonempty s with (rfl | hs_nonempty)\n  · simp [h_one]\n  · exact le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul g s hs_nonempty hs\n#align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred\n#align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred\n\n/-- Let `{x | p x}` be a subsemigroup of a commutative additive monoid `M`. Let `f : M → N` be a map\nsuch that `f 0 = 0` and `f` is subadditive on `{x | p x}`, i.e. `p x → p y → f (x + y) ≤ f x + f y`.\nLet `g i`, `i ∈ s`, be a finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then\n`f (∑ x in s, g x) ≤ ∑ x in s, f (g x)`. -/\nadd_decl_doc le_sum_of_subadditive_on_pred\n\n/- warning: finset.le_prod_of_submultiplicative -> Finset.le_prod_of_submultiplicative is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N), (Eq.{succ u3} N (f (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1))))))) (OfNat.ofNat.{u3} N 1 (OfNat.mk.{u3} N 1 (One.one.{u3} N (MulOneClass.toHasOne.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2)))))))) -> (forall (x : M) (y : M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toHasMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toHasMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y))) -> (forall (s : Finset.{u1} ι) (g : ι -> M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} {N : Type.{u3}} [_inst_1 : CommMonoid.{u2} M] [_inst_2 : OrderedCommMonoid.{u3} N] (f : M -> N), (Eq.{succ u3} N (f (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1))))) (OfNat.ofNat.{u3} N 1 (One.toOfNat1.{u3} N (Monoid.toOne.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2)))))) -> (forall (x : M) (y : M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (HMul.hMul.{u2, u2, u2} M M M (instHMul.{u2} M (MulOneClass.toMul.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M _inst_1)))) x y)) (HMul.hMul.{u3, u3, u3} N N N (instHMul.{u3} N (MulOneClass.toMul.{u3} N (Monoid.toMulOneClass.{u3} N (CommMonoid.toMonoid.{u3} N (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2))))) (f x) (f y))) -> (forall (s : Finset.{u1} ι) (g : ι -> M), LE.le.{u3} N (Preorder.toLE.{u3} N (PartialOrder.toPreorder.{u3} N (OrderedCommMonoid.toPartialOrder.{u3} N _inst_2))) (f (Finset.prod.{u2, u1} M ι _inst_1 s (fun (i : ι) => g i))) (Finset.prod.{u3, u1} N ι (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : ι) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicativeₓ'. -/\n/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y`, `f 1 = 1`, and `g i`,\n`i ∈ s`, is a finite family of elements of `M`, then `f (∏ i in s, g i) ≤ ∏ i in s, f (g i)`. -/\n@[to_additive le_sum_of_subadditive]\ntheorem le_prod_of_submultiplicative (f : M → N) (h_one : f 1 = 1)\n    (h_mul : ∀ x y, f (x * y) ≤ f x * f y) (s : Finset ι) (g : ι → M) :\n    f (∏ i in s, g i) ≤ ∏ i in s, f (g i) :=\n  by\n  refine' le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) _\n  rw [Multiset.map_map]\n  rfl\n#align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative\n#align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive\n\n/-- If `f : M → N` is a subadditive function, `f (x + y) ≤ f x + f y`, `f 0 = 0`, and `g i`,\n`i ∈ s`, is a finite family of elements of `M`, then `f (∑ i in s, g i) ≤ ∑ i in s, f (g i)`. -/\nadd_decl_doc le_sum_of_subadditive\n\nvariable {f g : ι → N} {s t : Finset ι}\n\n/- warning: finset.prod_le_prod' -> Finset.prod_le_prod' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {g : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (f i) (g i))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => g i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} {g : ι -> N} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (f i) (g i))) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : ι) => f i)) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : ι) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod' Finset.prod_le_prod'ₓ'. -/\n/-- In an ordered commutative monoid, if each factor `f i` of one finite product is less than or\nequal to the corresponding factor `g i` of another finite product, then\n`∏ i in s, f i ≤ ∏ i in s, g i`. -/\n@[to_additive sum_le_sum]\ntheorem prod_le_prod' (h : ∀ i ∈ s, f i ≤ g i) : (∏ i in s, f i) ≤ ∏ i in s, g i :=\n  Multiset.prod_map_le_prod_map f g h\n#align finset.prod_le_prod' Finset.prod_le_prod'\n#align finset.sum_le_sum Finset.sum_le_sum\n\n/-- In an ordered additive commutative monoid, if each summand `f i` of one finite sum is less than\nor equal to the corresponding summand `g i` of another finite sum, then\n`∑ i in s, f i ≤ ∑ i in s, g i`. -/\nadd_decl_doc sum_le_sum\n\n/- warning: finset.one_le_prod' -> Finset.one_le_prod' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (f i))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))) (f i))) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_le_prod' Finset.one_le_prod'ₓ'. -/\n@[to_additive sum_nonneg]\ntheorem one_le_prod' (h : ∀ i ∈ s, 1 ≤ f i) : 1 ≤ ∏ i in s, f i :=\n  le_trans (by rw [prod_const_one]) (prod_le_prod' h)\n#align finset.one_le_prod' Finset.one_le_prod'\n#align finset.sum_nonneg Finset.sum_nonneg\n\n/- warning: finset.one_le_prod'' -> Finset.one_le_prod'' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (f i)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (One.toOfNat1.{u2} N (Monoid.toOne.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))) (f i)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (One.toOfNat1.{u2} N (Monoid.toOne.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_le_prod'' Finset.one_le_prod''ₓ'. -/\n@[to_additive Finset.sum_nonneg']\ntheorem one_le_prod'' (h : ∀ i : ι, 1 ≤ f i) : 1 ≤ ∏ i : ι in s, f i :=\n  Finset.one_le_prod' fun i hi => h i\n#align finset.one_le_prod'' Finset.one_le_prod''\n#align finset.sum_nonneg' Finset.sum_nonneg'\n\n/- warning: finset.prod_le_one' -> Finset.prod_le_one' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (f i) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (f i) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))))) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : ι) => f i)) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_one' Finset.prod_le_one'ₓ'. -/\n@[to_additive sum_nonpos]\ntheorem prod_le_one' (h : ∀ i ∈ s, f i ≤ 1) : (∏ i in s, f i) ≤ 1 :=\n  (prod_le_prod' h).trans_eq (by rw [prod_const_one])\n#align finset.prod_le_one' Finset.prod_le_one'\n#align finset.sum_nonpos Finset.sum_nonpos\n\n/- warning: finset.prod_le_prod_of_subset_of_one_le' -> Finset.prod_le_prod_of_subset_of_one_le' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι} {t : Finset.{u1} ι}, (HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) s t) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i t) -> (Not (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (f i))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} {s : Finset.{u2} ι} {t : Finset.{u2} ι}, (HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) s t) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i t) -> (Not (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s)) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))) (f i))) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : ι) => f i)) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) t (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le'ₓ'. -/\n@[to_additive sum_le_sum_of_subset_of_nonneg]\ntheorem prod_le_prod_of_subset_of_one_le' (h : s ⊆ t) (hf : ∀ i ∈ t, i ∉ s → 1 ≤ f i) :\n    (∏ i in s, f i) ≤ ∏ i in t, f i := by\n  classical calc\n      (∏ i in s, f i) ≤ (∏ i in t \\ s, f i) * ∏ i in s, f i :=\n        le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp]\n      _ = ∏ i in t \\ s ∪ s, f i := (prod_union sdiff_disjoint).symm\n      _ = ∏ i in t, f i := by rw [sdiff_union_of_subset h]\n      \n#align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le'\n#align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg\n\n/- warning: finset.prod_mono_set_of_one_le' -> Finset.prod_mono_set_of_one_le' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N}, (forall (x : ι), LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (f x)) -> (Monotone.{u1, u2} (Finset.{u1} ι) N (PartialOrder.toPreorder.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι)) (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2)) (fun (s : Finset.{u1} ι) => Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N}, (forall (x : ι), LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (One.toOfNat1.{u2} N (Monoid.toOne.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))) (f x)) -> (Monotone.{u1, u2} (Finset.{u1} ι) N (PartialOrder.toPreorder.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι)) (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2)) (fun (s : Finset.{u1} ι) => Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le'ₓ'. -/\n@[to_additive sum_mono_set_of_nonneg]\ntheorem prod_mono_set_of_one_le' (hf : ∀ x, 1 ≤ f x) : Monotone fun s => ∏ x in s, f x :=\n  fun s t hst => prod_le_prod_of_subset_of_one_le' hst fun x _ _ => hf x\n#align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le'\n#align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg\n\n/- warning: finset.prod_le_univ_prod_of_one_le' -> Finset.prod_le_univ_prod_of_one_le' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} [_inst_3 : Fintype.{u1} ι] {s : Finset.{u1} ι}, (forall (x : ι), LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (f x)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x)) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.univ.{u1} ι _inst_3) (fun (x : ι) => f x)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} [_inst_3 : Fintype.{u2} ι] {s : Finset.{u2} ι}, (forall (x : ι), LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))) (f x)) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (x : ι) => f x)) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) (Finset.univ.{u2} ι _inst_3) (fun (x : ι) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le'ₓ'. -/\n@[to_additive sum_le_univ_sum_of_nonneg]\ntheorem prod_le_univ_prod_of_one_le' [Fintype ι] {s : Finset ι} (w : ∀ x, 1 ≤ f x) :\n    (∏ x in s, f x) ≤ ∏ x, f x :=\n  prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ => w a\n#align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le'\n#align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg\n\n/- warning: finset.prod_eq_one_iff_of_one_le' -> Finset.prod_eq_one_iff_of_one_le' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (f i))) -> (Iff (Eq.{succ u2} N (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2)))))))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Eq.{succ u2} N (f i) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))) (f i))) -> (Iff (Eq.{succ u1} N (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : ι) => f i)) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2)))))) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Eq.{succ u1} N (f i) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le'ₓ'. -/\n@[to_additive sum_eq_zero_iff_of_nonneg]\ntheorem prod_eq_one_iff_of_one_le' :\n    (∀ i ∈ s, 1 ≤ f i) → ((∏ i in s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) := by\n  classical\n    apply Finset.induction_on s\n    exact fun _ => ⟨fun _ _ => False.elim, fun _ => rfl⟩\n    intro a s ha ih H\n    have : ∀ i ∈ s, 1 ≤ f i := fun _ => H _ ∘ mem_insert_of_mem\n    rw [prod_insert ha, mul_eq_one_iff' (H _ <| mem_insert_self _ _) (one_le_prod' this),\n      forall_mem_insert, ih this]\n#align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le'\n#align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg\n\n/- warning: finset.prod_eq_one_iff_of_le_one' -> Finset.prod_eq_one_iff_of_le_one' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (f i) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))))) -> (Iff (Eq.{succ u2} N (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2)))))))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Eq.{succ u2} N (f i) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (f i) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))))) -> (Iff (Eq.{succ u1} N (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : ι) => f i)) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2)))))) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Eq.{succ u1} N (f i) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one'ₓ'. -/\n@[to_additive sum_eq_zero_iff_of_nonneg]\ntheorem prod_eq_one_iff_of_le_one' :\n    (∀ i ∈ s, f i ≤ 1) → ((∏ i in s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) :=\n  @prod_eq_one_iff_of_one_le' _ Nᵒᵈ _ _ _\n#align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one'\n#align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg\n\n/- warning: finset.single_le_prod' -> Finset.single_le_prod' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : ι -> N} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (f i))) -> (forall {a : ι}, (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) a s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (f a) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : ι -> N} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (OfNat.ofNat.{u1} N 1 (One.toOfNat1.{u1} N (Monoid.toOne.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2))))) (f i))) -> (forall {a : ι}, (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) a s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (f a) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (x : ι) => f x))))\nCase conversion may be inaccurate. Consider using '#align finset.single_le_prod' Finset.single_le_prod'ₓ'. -/\n@[to_additive single_le_sum]\ntheorem single_le_prod' (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a ∈ s) : f a ≤ ∏ x in s, f x :=\n  calc\n    f a = ∏ i in {a}, f i := prod_singleton.symm\n    _ ≤ ∏ i in s, f i :=\n      prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ => hf i hi\n    \n#align finset.single_le_prod' Finset.single_le_prod'\n#align finset.single_le_sum Finset.single_le_sum\n\n/- warning: finset.prod_le_pow_card -> Finset.prod_le_pow_card is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] (s : Finset.{u1} ι) (f : ι -> N) (n : N), (forall (x : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (f x) n)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s f) (HPow.hPow.{u2, 0, u2} N Nat N (instHPow.{u2, 0} N Nat (Monoid.Pow.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2)))) n (Finset.card.{u1} ι s)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] (s : Finset.{u2} ι) (f : ι -> N) (n : N), (forall (x : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) x s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (f x) n)) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s f) (HPow.hPow.{u1, 0, u1} N Nat N (instHPow.{u1, 0} N Nat (Monoid.Pow.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2)))) n (Finset.card.{u2} ι s)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_pow_card Finset.prod_le_pow_cardₓ'. -/\n@[to_additive sum_le_card_nsmul]\ntheorem prod_le_pow_card (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, f x ≤ n) :\n    s.Prod f ≤ n ^ s.card :=\n  by\n  refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _\n  · simpa using h\n  · simpa\n#align finset.prod_le_pow_card Finset.prod_le_pow_card\n#align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul\n\n/- warning: finset.pow_card_le_prod -> Finset.pow_card_le_prod is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] (s : Finset.{u1} ι) (f : ι -> N) (n : N), (forall (x : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x s) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) n (f x))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (HPow.hPow.{u2, 0, u2} N Nat N (instHPow.{u2, 0} N Nat (Monoid.Pow.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2)))) n (Finset.card.{u1} ι s)) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s f))\nbut is expected to have type\n  forall {ι : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] (s : Finset.{u2} ι) (f : ι -> N) (n : N), (forall (x : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) x s) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) n (f x))) -> (LE.le.{u1} N (Preorder.toLE.{u1} N (PartialOrder.toPreorder.{u1} N (OrderedCommMonoid.toPartialOrder.{u1} N _inst_2))) (HPow.hPow.{u1, 0, u1} N Nat N (instHPow.{u1, 0} N Nat (Monoid.Pow.{u1} N (CommMonoid.toMonoid.{u1} N (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2)))) n (Finset.card.{u2} ι s)) (Finset.prod.{u1, u2} N ι (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s f))\nCase conversion may be inaccurate. Consider using '#align finset.pow_card_le_prod Finset.pow_card_le_prodₓ'. -/\n@[to_additive card_nsmul_le_sum]\ntheorem pow_card_le_prod (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, n ≤ f x) :\n    n ^ s.card ≤ s.Prod f :=\n  @Finset.prod_le_pow_card _ Nᵒᵈ _ _ _ _ h\n#align finset.pow_card_le_prod Finset.pow_card_le_prod\n#align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum\n\n#print Finset.card_bunionᵢ_le_card_mul /-\ntheorem card_bunionᵢ_le_card_mul [DecidableEq β] (s : Finset ι) (f : ι → Finset β) (n : ℕ)\n    (h : ∀ a ∈ s, (f a).card ≤ n) : (s.bunionᵢ f).card ≤ s.card * n :=\n  card_bunionᵢ_le.trans <| sum_le_card_nsmul _ _ _ h\n#align finset.card_bUnion_le_card_mul Finset.card_bunionᵢ_le_card_mul\n-/\n\nvariable {ι' : Type _} [DecidableEq ι']\n\n/- warning: finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' -> Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} ι} {ι' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} ι'] {t : Finset.{u3} ι'} {g : ι -> ι'} {f : ι -> N}, (forall (y : ι'), (Not (Membership.Mem.{u3, u3} ι' (Finset.{u3} ι') (Finset.hasMem.{u3} ι') y t)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x)))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u3} N ι' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : ι') => Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} ι} {ι' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} ι'] {t : Finset.{u3} ι'} {g : ι -> ι'} {f : ι -> N}, (forall (y : ι'), (Not (Membership.mem.{u3, u3} ι' (Finset.{u3} ι') (Finset.instMembershipFinset.{u3} ι') y t)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (OfNat.ofNat.{u2} N 1 (One.toOfNat1.{u2} N (Monoid.toOne.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x)))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u3} N ι' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : ι') => Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber'ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y «expr ∉ » t) -/\n@[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg]\ntheorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ι'} {g : ι → ι'} {f : ι → N}\n    (h : ∀ (y) (_ : y ∉ t), (1 : N) ≤ ∏ x in s.filterₓ fun x => g x = y, f x) :\n    (∏ y in t, ∏ x in s.filterₓ fun x => g x = y, f x) ≤ ∏ x in s, f x :=\n  calc\n    (∏ y in t, ∏ x in s.filterₓ fun x => g x = y, f x) ≤\n        ∏ y in t ∪ s.image g, ∏ x in s.filterₓ fun x => g x = y, f x :=\n      prod_le_prod_of_subset_of_one_le' (subset_union_left _ _) fun y hyts => h y\n    _ = ∏ x in s, f x :=\n      prod_fiberwise_of_maps_to (fun x hx => mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _\n    \n#align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber'\n#align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg\n\n/- warning: finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' -> Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} ι} {ι' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} ι'] {t : Finset.{u3} ι'} {g : ι -> ι'} {f : ι -> N}, (forall (y : ι'), (Not (Membership.Mem.{u3, u3} ι' (Finset.{u3} ι') (Finset.hasMem.{u3} ι') y t)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x)) (OfNat.ofNat.{u2} N 1 (OfNat.mk.{u2} N 1 (One.one.{u2} N (MulOneClass.toHasOne.{u2} N (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x)) (Finset.prod.{u2, u3} N ι' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : ι') => Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} ι} {ι' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} ι'] {t : Finset.{u3} ι'} {g : ι -> ι'} {f : ι -> N}, (forall (y : ι'), (Not (Membership.mem.{u3, u3} ι' (Finset.{u3} ι') (Finset.instMembershipFinset.{u3} ι') y t)) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x)) (OfNat.ofNat.{u2} N 1 (One.toOfNat1.{u2} N (Monoid.toOne.{u2} N (CommMonoid.toMonoid.{u2} N (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2))))))) -> (LE.le.{u2} N (Preorder.toLE.{u2} N (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2))) (Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : ι) => f x)) (Finset.prod.{u2, u3} N ι' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : ι') => Finset.prod.{u2, u1} N ι (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} ι (fun (x : ι) => Eq.{succ u3} ι' (g x) y) (fun (a : ι) => _inst_3 (g a) y) s) (fun (x : ι) => f x))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one'ₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y «expr ∉ » t) -/\n@[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos]\ntheorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ι'} {g : ι → ι'} {f : ι → N}\n    (h : ∀ (y) (_ : y ∉ t), (∏ x in s.filterₓ fun x => g x = y, f x) ≤ 1) :\n    (∏ x in s, f x) ≤ ∏ y in t, ∏ x in s.filterₓ fun x => g x = y, f x :=\n  @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nᵒᵈ _ _ _ _ _ _ _ h\n#align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one'\n#align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos\n\nend OrderedCommMonoid\n\n/- warning: finset.abs_sum_le_sum_abs -> Finset.abs_sum_le_sum_abs is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] (f : ι -> G) (s : Finset.{u1} ι), LE.le.{u2} G (Preorder.toLE.{u2} G (PartialOrder.toPreorder.{u2} G (OrderedAddCommGroup.toPartialOrder.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))) (Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (SubNegMonoid.toHasNeg.{u2} G (AddGroup.toSubNegMonoid.{u2} G (AddCommGroup.toAddGroup.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))) (SemilatticeSup.toHasSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (LinearOrder.toLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1))))) (Finset.sum.{u2, u1} G ι (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} G ι (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : ι) => Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (SubNegMonoid.toHasNeg.{u2} G (AddGroup.toSubNegMonoid.{u2} G (AddCommGroup.toAddGroup.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))) (SemilatticeSup.toHasSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (LinearOrder.toLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1))))) (f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] (f : ι -> G) (s : Finset.{u1} ι), LE.le.{u2} G (Preorder.toLE.{u2} G (PartialOrder.toPreorder.{u2} G (OrderedAddCommGroup.toPartialOrder.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))) (Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (NegZeroClass.toNeg.{u2} G (SubNegZeroMonoid.toNegZeroClass.{u2} G (SubtractionMonoid.toSubNegZeroMonoid.{u2} G (SubtractionCommMonoid.toSubtractionMonoid.{u2} G (AddCommGroup.toDivisionAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))))) (SemilatticeSup.toSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (DistribLattice.toLattice.{u2} G (instDistribLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1)))))) (Finset.sum.{u2, u1} G ι (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} G ι (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : ι) => Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (NegZeroClass.toNeg.{u2} G (SubNegZeroMonoid.toNegZeroClass.{u2} G (SubtractionMonoid.toSubNegZeroMonoid.{u2} G (SubtractionCommMonoid.toSubtractionMonoid.{u2} G (AddCommGroup.toDivisionAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))))) (SemilatticeSup.toSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (DistribLattice.toLattice.{u2} G (instDistribLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1)))))) (f i)))\nCase conversion may be inaccurate. Consider using '#align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_absₓ'. -/\ntheorem abs_sum_le_sum_abs {G : Type _} [LinearOrderedAddCommGroup G] (f : ι → G) (s : Finset ι) :\n    |∑ i in s, f i| ≤ ∑ i in s, |f i| :=\n  le_sum_of_subadditive _ abs_zero abs_add s f\n#align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs\n\n/- warning: finset.abs_sum_of_nonneg -> Finset.abs_sum_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : ι -> G} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} G (Preorder.toLE.{u2} G (PartialOrder.toPreorder.{u2} G (OrderedAddCommGroup.toPartialOrder.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))) (OfNat.ofNat.{u2} G 0 (OfNat.mk.{u2} G 0 (Zero.zero.{u2} G (AddZeroClass.toHasZero.{u2} G (AddMonoid.toAddZeroClass.{u2} G (SubNegMonoid.toAddMonoid.{u2} G (AddGroup.toSubNegMonoid.{u2} G (AddCommGroup.toAddGroup.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))))))))) (f i))) -> (Eq.{succ u2} G (Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (SubNegMonoid.toHasNeg.{u2} G (AddGroup.toSubNegMonoid.{u2} G (AddCommGroup.toAddGroup.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))) (SemilatticeSup.toHasSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (LinearOrder.toLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1))))) (Finset.sum.{u2, u1} G ι (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} G ι (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : ι -> G} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (LE.le.{u2} G (Preorder.toLE.{u2} G (PartialOrder.toPreorder.{u2} G (OrderedAddCommGroup.toPartialOrder.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))) (OfNat.ofNat.{u2} G 0 (Zero.toOfNat0.{u2} G (NegZeroClass.toZero.{u2} G (SubNegZeroMonoid.toNegZeroClass.{u2} G (SubtractionMonoid.toSubNegZeroMonoid.{u2} G (SubtractionCommMonoid.toSubtractionMonoid.{u2} G (AddCommGroup.toDivisionAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))))))) (f i))) -> (Eq.{succ u2} G (Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (NegZeroClass.toNeg.{u2} G (SubNegZeroMonoid.toNegZeroClass.{u2} G (SubtractionMonoid.toSubNegZeroMonoid.{u2} G (SubtractionCommMonoid.toSubtractionMonoid.{u2} G (AddCommGroup.toDivisionAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))))) (SemilatticeSup.toSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (DistribLattice.toLattice.{u2} G (instDistribLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1)))))) (Finset.sum.{u2, u1} G ι (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} G ι (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonnegₓ'. -/\ntheorem abs_sum_of_nonneg {G : Type _} [LinearOrderedAddCommGroup G] {f : ι → G} {s : Finset ι}\n    (hf : ∀ i ∈ s, 0 ≤ f i) : |∑ i : ι in s, f i| = ∑ i : ι in s, f i := by\n  rw [abs_of_nonneg (Finset.sum_nonneg hf)]\n#align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg\n\n/- warning: finset.abs_sum_of_nonneg' -> Finset.abs_sum_of_nonneg' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : ι -> G} {s : Finset.{u1} ι}, (forall (i : ι), LE.le.{u2} G (Preorder.toLE.{u2} G (PartialOrder.toPreorder.{u2} G (OrderedAddCommGroup.toPartialOrder.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))) (OfNat.ofNat.{u2} G 0 (OfNat.mk.{u2} G 0 (Zero.zero.{u2} G (AddZeroClass.toHasZero.{u2} G (AddMonoid.toAddZeroClass.{u2} G (SubNegMonoid.toAddMonoid.{u2} G (AddGroup.toSubNegMonoid.{u2} G (AddCommGroup.toAddGroup.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))))))))) (f i)) -> (Eq.{succ u2} G (Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (SubNegMonoid.toHasNeg.{u2} G (AddGroup.toSubNegMonoid.{u2} G (AddCommGroup.toAddGroup.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))) (SemilatticeSup.toHasSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (LinearOrder.toLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1))))) (Finset.sum.{u2, u1} G ι (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} G ι (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : ι -> G} {s : Finset.{u1} ι}, (forall (i : ι), LE.le.{u2} G (Preorder.toLE.{u2} G (PartialOrder.toPreorder.{u2} G (OrderedAddCommGroup.toPartialOrder.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1)))) (OfNat.ofNat.{u2} G 0 (Zero.toOfNat0.{u2} G (NegZeroClass.toZero.{u2} G (SubNegZeroMonoid.toNegZeroClass.{u2} G (SubtractionMonoid.toSubNegZeroMonoid.{u2} G (SubtractionCommMonoid.toSubtractionMonoid.{u2} G (AddCommGroup.toDivisionAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))))))) (f i)) -> (Eq.{succ u2} G (Abs.abs.{u2} G (Neg.toHasAbs.{u2} G (NegZeroClass.toNeg.{u2} G (SubNegZeroMonoid.toNegZeroClass.{u2} G (SubtractionMonoid.toSubNegZeroMonoid.{u2} G (SubtractionCommMonoid.toSubtractionMonoid.{u2} G (AddCommGroup.toDivisionAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))))))) (SemilatticeSup.toSup.{u2} G (Lattice.toSemilatticeSup.{u2} G (DistribLattice.toLattice.{u2} G (instDistribLattice.{u2} G (LinearOrderedAddCommGroup.toLinearOrder.{u2} G _inst_1)))))) (Finset.sum.{u2, u1} G ι (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} G ι (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg'ₓ'. -/\ntheorem abs_sum_of_nonneg' {G : Type _} [LinearOrderedAddCommGroup G] {f : ι → G} {s : Finset ι}\n    (hf : ∀ i, 0 ≤ f i) : |∑ i : ι in s, f i| = ∑ i : ι in s, f i := by\n  rw [abs_of_nonneg (Finset.sum_nonneg' hf)]\n#align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg'\n\n/- warning: finset.abs_prod -> Finset.abs_prod is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : LinearOrderedCommRing.{u2} R] {f : ι -> R} {s : Finset.{u1} ι}, Eq.{succ u2} R (Abs.abs.{u2} R (Neg.toHasAbs.{u2} R (SubNegMonoid.toHasNeg.{u2} R (AddGroup.toSubNegMonoid.{u2} R (AddGroupWithOne.toAddGroup.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R (StrictOrderedRing.toRing.{u2} R (LinearOrderedRing.toStrictOrderedRing.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1)))))))) (SemilatticeSup.toHasSup.{u2} R (Lattice.toSemilatticeSup.{u2} R (LinearOrder.toLattice.{u2} R (LinearOrderedRing.toLinearOrder.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1)))))) (Finset.prod.{u2, u1} R ι (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : ι) => f x))) (Finset.prod.{u2, u1} R ι (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : ι) => Abs.abs.{u2} R (Neg.toHasAbs.{u2} R (SubNegMonoid.toHasNeg.{u2} R (AddGroup.toSubNegMonoid.{u2} R (AddGroupWithOne.toAddGroup.{u2} R (AddCommGroupWithOne.toAddGroupWithOne.{u2} R (Ring.toAddCommGroupWithOne.{u2} R (StrictOrderedRing.toRing.{u2} R (LinearOrderedRing.toStrictOrderedRing.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1)))))))) (SemilatticeSup.toHasSup.{u2} R (Lattice.toSemilatticeSup.{u2} R (LinearOrder.toLattice.{u2} R (LinearOrderedRing.toLinearOrder.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1)))))) (f x)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : LinearOrderedCommRing.{u2} R] {f : ι -> R} {s : Finset.{u1} ι}, Eq.{succ u2} R (Abs.abs.{u2} R (Neg.toHasAbs.{u2} R (Ring.toNeg.{u2} R (StrictOrderedRing.toRing.{u2} R (LinearOrderedRing.toStrictOrderedRing.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1)))) (SemilatticeSup.toSup.{u2} R (Lattice.toSemilatticeSup.{u2} R (DistribLattice.toLattice.{u2} R (instDistribLattice.{u2} R (LinearOrderedRing.toLinearOrder.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1))))))) (Finset.prod.{u2, u1} R ι (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : ι) => f x))) (Finset.prod.{u2, u1} R ι (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : ι) => Abs.abs.{u2} R (Neg.toHasAbs.{u2} R (Ring.toNeg.{u2} R (StrictOrderedRing.toRing.{u2} R (LinearOrderedRing.toStrictOrderedRing.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1)))) (SemilatticeSup.toSup.{u2} R (Lattice.toSemilatticeSup.{u2} R (DistribLattice.toLattice.{u2} R (instDistribLattice.{u2} R (LinearOrderedRing.toLinearOrder.{u2} R (LinearOrderedCommRing.toLinearOrderedRing.{u2} R _inst_1))))))) (f x)))\nCase conversion may be inaccurate. Consider using '#align finset.abs_prod Finset.abs_prodₓ'. -/\ntheorem abs_prod {R : Type _} [LinearOrderedCommRing R] {f : ι → R} {s : Finset ι} :\n    |∏ x in s, f x| = ∏ x in s, |f x| :=\n  (absHom.toMonoidHom : R →* R).map_prod _ _\n#align finset.abs_prod Finset.abs_prod\n\nsection Pigeonhole\n\nvariable [DecidableEq β]\n\n/- warning: finset.card_le_mul_card_image_of_maps_to -> Finset.card_le_mul_card_image_of_maps_to is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} β] {f : α -> β} {s : Finset.{u1} α} {t : Finset.{u2} β}, (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) (f a) t)) -> (forall (n : Nat), (forall (a : β), (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) a t) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α (Finset.filter.{u1} α (fun (x : α) => Eq.{succ u2} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) n (Finset.card.{u2} β t))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} β] {f : α -> β} {s : Finset.{u2} α} {t : Finset.{u1} β}, (forall (a : α), (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a s) -> (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) (f a) t)) -> (forall (n : Nat), (forall (a : β), (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) a t) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α (Finset.filter.{u2} α (fun (x : α) => Eq.{succ u1} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) n (Finset.card.{u1} β t))))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_toₓ'. -/\ntheorem card_le_mul_card_image_of_maps_to {f : α → β} {s : Finset α} {t : Finset β}\n    (Hf : ∀ a ∈ s, f a ∈ t) (n : ℕ) (hn : ∀ a ∈ t, (s.filterₓ fun x => f x = a).card ≤ n) :\n    s.card ≤ n * t.card :=\n  calc\n    s.card = ∑ a in t, (s.filterₓ fun x => f x = a).card := card_eq_sum_card_fiberwise Hf\n    _ ≤ ∑ _ in t, n := (sum_le_sum hn)\n    _ = _ := by simp [mul_comm]\n    \n#align finset.card_le_mul_card_image_of_maps_to Finset.card_le_mul_card_image_of_maps_to\n\n/- warning: finset.card_le_mul_card_image -> Finset.card_le_mul_card_image is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} β] {f : α -> β} (s : Finset.{u1} α) (n : Nat), (forall (a : β), (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) a (Finset.image.{u1, u2} α β (fun (a : β) (b : β) => _inst_1 a b) f s)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α (Finset.filter.{u1} α (fun (x : α) => Eq.{succ u2} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) n (Finset.card.{u2} β (Finset.image.{u1, u2} α β (fun (a : β) (b : β) => _inst_1 a b) f s))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} β] {f : α -> β} (s : Finset.{u2} α) (n : Nat), (forall (a : β), (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) a (Finset.image.{u2, u1} α β (fun (a : β) (b : β) => _inst_1 a b) f s)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α (Finset.filter.{u2} α (fun (x : α) => Eq.{succ u1} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) n (Finset.card.{u1} β (Finset.image.{u2, u1} α β (fun (a : β) (b : β) => _inst_1 a b) f s))))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_mul_card_image Finset.card_le_mul_card_imageₓ'. -/\ntheorem card_le_mul_card_image {f : α → β} (s : Finset α) (n : ℕ)\n    (hn : ∀ a ∈ s.image f, (s.filterₓ fun x => f x = a).card ≤ n) : s.card ≤ n * (s.image f).card :=\n  card_le_mul_card_image_of_maps_to (fun x => mem_image_of_mem _) n hn\n#align finset.card_le_mul_card_image Finset.card_le_mul_card_image\n\n/- warning: finset.mul_card_image_le_card_of_maps_to -> Finset.mul_card_image_le_card_of_maps_to is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} β] {f : α -> β} {s : Finset.{u1} α} {t : Finset.{u2} β}, (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) (f a) t)) -> (forall (n : Nat), (forall (a : β), (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) a t) -> (LE.le.{0} Nat Nat.hasLe n (Finset.card.{u1} α (Finset.filter.{u1} α (fun (x : α) => Eq.{succ u2} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)))) -> (LE.le.{0} Nat Nat.hasLe (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) n (Finset.card.{u2} β t)) (Finset.card.{u1} α s)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} β] {f : α -> β} {s : Finset.{u2} α} {t : Finset.{u1} β}, (forall (a : α), (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a s) -> (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) (f a) t)) -> (forall (n : Nat), (forall (a : β), (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) a t) -> (LE.le.{0} Nat instLENat n (Finset.card.{u2} α (Finset.filter.{u2} α (fun (x : α) => Eq.{succ u1} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)))) -> (LE.le.{0} Nat instLENat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) n (Finset.card.{u1} β t)) (Finset.card.{u2} α s)))\nCase conversion may be inaccurate. Consider using '#align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_toₓ'. -/\ntheorem mul_card_image_le_card_of_maps_to {f : α → β} {s : Finset α} {t : Finset β}\n    (Hf : ∀ a ∈ s, f a ∈ t) (n : ℕ) (hn : ∀ a ∈ t, n ≤ (s.filterₓ fun x => f x = a).card) :\n    n * t.card ≤ s.card :=\n  calc\n    n * t.card = ∑ _ in t, n := by simp [mul_comm]\n    _ ≤ ∑ a in t, (s.filterₓ fun x => f x = a).card := (sum_le_sum hn)\n    _ = s.card := by rw [← card_eq_sum_card_fiberwise Hf]\n    \n#align finset.mul_card_image_le_card_of_maps_to Finset.mul_card_image_le_card_of_maps_to\n\n/- warning: finset.mul_card_image_le_card -> Finset.mul_card_image_le_card is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} β] {f : α -> β} (s : Finset.{u1} α) (n : Nat), (forall (a : β), (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) a (Finset.image.{u1, u2} α β (fun (a : β) (b : β) => _inst_1 a b) f s)) -> (LE.le.{0} Nat Nat.hasLe n (Finset.card.{u1} α (Finset.filter.{u1} α (fun (x : α) => Eq.{succ u2} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)))) -> (LE.le.{0} Nat Nat.hasLe (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) n (Finset.card.{u2} β (Finset.image.{u1, u2} α β (fun (a : β) (b : β) => _inst_1 a b) f s))) (Finset.card.{u1} α s))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} β] {f : α -> β} (s : Finset.{u2} α) (n : Nat), (forall (a : β), (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) a (Finset.image.{u2, u1} α β (fun (a : β) (b : β) => _inst_1 a b) f s)) -> (LE.le.{0} Nat instLENat n (Finset.card.{u2} α (Finset.filter.{u2} α (fun (x : α) => Eq.{succ u1} β (f x) a) (fun (a_1 : α) => _inst_1 (f a_1) a) s)))) -> (LE.le.{0} Nat instLENat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) n (Finset.card.{u1} β (Finset.image.{u2, u1} α β (fun (a : β) (b : β) => _inst_1 a b) f s))) (Finset.card.{u2} α s))\nCase conversion may be inaccurate. Consider using '#align finset.mul_card_image_le_card Finset.mul_card_image_le_cardₓ'. -/\ntheorem mul_card_image_le_card {f : α → β} (s : Finset α) (n : ℕ)\n    (hn : ∀ a ∈ s.image f, n ≤ (s.filterₓ fun x => f x = a).card) : n * (s.image f).card ≤ s.card :=\n  mul_card_image_le_card_of_maps_to (fun x => mem_image_of_mem _) n hn\n#align finset.mul_card_image_le_card Finset.mul_card_image_le_card\n\nend Pigeonhole\n\nsection DoubleCounting\n\nvariable [DecidableEq α] {s : Finset α} {B : Finset (Finset α)} {n : ℕ}\n\n#print Finset.sum_card_inter_le /-\n/-- If every element belongs to at most `n` finsets, then the sum of their sizes is at most `n`\ntimes how many they are. -/\ntheorem sum_card_inter_le (h : ∀ a ∈ s, (B.filterₓ <| (· ∈ ·) a).card ≤ n) :\n    (∑ t in B, (s ∩ t).card) ≤ s.card * n :=\n  by\n  refine' le_trans _ (s.sum_le_card_nsmul _ _ h)\n  simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]\n  exact sum_comm.le\n#align finset.sum_card_inter_le Finset.sum_card_inter_le\n-/\n\n#print Finset.sum_card_le /-\n/-- If every element belongs to at most `n` finsets, then the sum of their sizes is at most `n`\ntimes how many they are. -/\ntheorem sum_card_le [Fintype α] (h : ∀ a, (B.filterₓ <| (· ∈ ·) a).card ≤ n) :\n    (∑ s in B, s.card) ≤ Fintype.card α * n :=\n  calc\n    (∑ s in B, s.card) = ∑ s in B, (univ ∩ s).card := by simp_rw [univ_inter]\n    _ ≤ Fintype.card α * n := sum_card_inter_le fun a _ => h a\n    \n#align finset.sum_card_le Finset.sum_card_le\n-/\n\n#print Finset.le_sum_card_inter /-\n/-- If every element belongs to at least `n` finsets, then the sum of their sizes is at least `n`\ntimes how many they are. -/\ntheorem le_sum_card_inter (h : ∀ a ∈ s, n ≤ (B.filterₓ <| (· ∈ ·) a).card) :\n    s.card * n ≤ ∑ t in B, (s ∩ t).card :=\n  by\n  apply (s.card_nsmul_le_sum _ _ h).trans\n  simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]\n  exact sum_comm.le\n#align finset.le_sum_card_inter Finset.le_sum_card_inter\n-/\n\n#print Finset.le_sum_card /-\n/-- If every element belongs to at least `n` finsets, then the sum of their sizes is at least `n`\ntimes how many they are. -/\ntheorem le_sum_card [Fintype α] (h : ∀ a, n ≤ (B.filterₓ <| (· ∈ ·) a).card) :\n    Fintype.card α * n ≤ ∑ s in B, s.card :=\n  calc\n    Fintype.card α * n ≤ ∑ s in B, (univ ∩ s).card := le_sum_card_inter fun a _ => h a\n    _ = ∑ s in B, s.card := by simp_rw [univ_inter]\n    \n#align finset.le_sum_card Finset.le_sum_card\n-/\n\n#print Finset.sum_card_inter /-\n/-- If every element belongs to exactly `n` finsets, then the sum of their sizes is `n` times how\nmany they are. -/\ntheorem sum_card_inter (h : ∀ a ∈ s, (B.filterₓ <| (· ∈ ·) a).card = n) :\n    (∑ t in B, (s ∩ t).card) = s.card * n :=\n  (sum_card_inter_le fun a ha => (h a ha).le).antisymm (le_sum_card_inter fun a ha => (h a ha).ge)\n#align finset.sum_card_inter Finset.sum_card_inter\n-/\n\n#print Finset.sum_card /-\n/-- If every element belongs to exactly `n` finsets, then the sum of their sizes is `n` times how\nmany they are. -/\ntheorem sum_card [Fintype α] (h : ∀ a, (B.filterₓ <| (· ∈ ·) a).card = n) :\n    (∑ s in B, s.card) = Fintype.card α * n := by\n  simp_rw [Fintype.card, ← sum_card_inter fun a _ => h a, univ_inter]\n#align finset.sum_card Finset.sum_card\n-/\n\n/- warning: finset.card_le_card_bUnion -> Finset.card_le_card_bunionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] {s : Finset.{u1} ι} {f : ι -> (Finset.{u2} α)}, (Set.PairwiseDisjoint.{u2, u1} (Finset.{u2} α) ι (Finset.partialOrder.{u2} α) (Finset.orderBot.{u2} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} ι) (Set.{u1} ι) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (Finset.Set.hasCoeT.{u1} ι))) s) f) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Finset.Nonempty.{u2} α (f i))) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} ι s) (Finset.card.{u2} α (Finset.bunionᵢ.{u1, u2} ι α (fun (a : α) (b : α) => _inst_1 a b) s f)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u2} ι} {f : ι -> (Finset.{u1} α)}, (Set.PairwiseDisjoint.{u1, u2} (Finset.{u1} α) ι (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) (Finset.toSet.{u2} ι s) f) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Finset.Nonempty.{u1} α (f i))) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} ι s) (Finset.card.{u1} α (Finset.bunionᵢ.{u2, u1} ι α (fun (a : α) (b : α) => _inst_1 a b) s f)))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_bUnion Finset.card_le_card_bunionᵢₓ'. -/\ntheorem card_le_card_bunionᵢ {s : Finset ι} {f : ι → Finset α} (hs : (s : Set ι).PairwiseDisjoint f)\n    (hf : ∀ i ∈ s, (f i).Nonempty) : s.card ≤ (s.bunionᵢ f).card :=\n  by\n  rw [card_bUnion hs, card_eq_sum_ones]\n  exact sum_le_sum fun i hi => (hf i hi).card_pos\n#align finset.card_le_card_bUnion Finset.card_le_card_bunionᵢ\n\n/- warning: finset.card_le_card_bUnion_add_card_fiber -> Finset.card_le_card_bunionᵢ_add_card_fiber is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] {s : Finset.{u1} ι} {f : ι -> (Finset.{u2} α)}, (Set.PairwiseDisjoint.{u2, u1} (Finset.{u2} α) ι (Finset.partialOrder.{u2} α) (Finset.orderBot.{u2} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} ι) (Set.{u1} ι) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (Finset.Set.hasCoeT.{u1} ι))) s) f) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} ι s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u2} α (Finset.bunionᵢ.{u1, u2} ι α (fun (a : α) (b : α) => _inst_1 a b) s f)) (Finset.card.{u1} ι (Finset.filter.{u1} ι (fun (i : ι) => Eq.{succ u2} (Finset.{u2} α) (f i) (EmptyCollection.emptyCollection.{u2} (Finset.{u2} α) (Finset.hasEmptyc.{u2} α))) (fun (a : ι) => Finset.decidableEq.{u2} α (fun (a : α) (b : α) => _inst_1 a b) (f a) (EmptyCollection.emptyCollection.{u2} (Finset.{u2} α) (Finset.hasEmptyc.{u2} α))) s))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u2} ι} {f : ι -> (Finset.{u1} α)}, (Set.PairwiseDisjoint.{u1, u2} (Finset.{u1} α) ι (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) (Finset.toSet.{u2} ι s) f) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} ι s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α (Finset.bunionᵢ.{u2, u1} ι α (fun (a : α) (b : α) => _inst_1 a b) s f)) (Finset.card.{u2} ι (Finset.filter.{u2} ι (fun (i : ι) => Eq.{succ u1} (Finset.{u1} α) (f i) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} α) (Finset.instEmptyCollectionFinset.{u1} α))) (fun (a : ι) => Finset.decidableEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (f a) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} α) (Finset.instEmptyCollectionFinset.{u1} α))) s))))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_bunionᵢ_add_card_fiberₓ'. -/\ntheorem card_le_card_bunionᵢ_add_card_fiber {s : Finset ι} {f : ι → Finset α}\n    (hs : (s : Set ι).PairwiseDisjoint f) :\n    s.card ≤ (s.bunionᵢ f).card + (s.filterₓ fun i => f i = ∅).card :=\n  by\n  rw [← Finset.filter_card_add_filter_neg_card_eq_card fun i => f i = ∅, add_comm]\n  exact\n    add_le_add_right\n      ((card_le_card_bUnion (hs.subset <| filter_subset _ _) fun i hi =>\n            nonempty_of_ne_empty <| (mem_filter.1 hi).2).trans <|\n        card_le_of_subset <| bUnion_subset_bUnion_of_subset_left _ <| filter_subset _ _)\n      _\n#align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_bunionᵢ_add_card_fiber\n\n/- warning: finset.card_le_card_bUnion_add_one -> Finset.card_le_card_bunionᵢ_add_one is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] {s : Finset.{u1} ι} {f : ι -> (Finset.{u2} α)}, (Function.Injective.{succ u1, succ u2} ι (Finset.{u2} α) f) -> (Set.PairwiseDisjoint.{u2, u1} (Finset.{u2} α) ι (Finset.partialOrder.{u2} α) (Finset.orderBot.{u2} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} ι) (Set.{u1} ι) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} ι) (Set.{u1} ι) (Finset.Set.hasCoeT.{u1} ι))) s) f) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} ι s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u2} α (Finset.bunionᵢ.{u1, u2} ι α (fun (a : α) (b : α) => _inst_1 a b) s f)) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {s : Finset.{u2} ι} {f : ι -> (Finset.{u1} α)}, (Function.Injective.{succ u2, succ u1} ι (Finset.{u1} α) f) -> (Set.PairwiseDisjoint.{u1, u2} (Finset.{u1} α) ι (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) (Finset.toSet.{u2} ι s) f) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} ι s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α (Finset.bunionᵢ.{u2, u1} ι α (fun (a : α) (b : α) => _inst_1 a b) s f)) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_bUnion_add_one Finset.card_le_card_bunionᵢ_add_oneₓ'. -/\ntheorem card_le_card_bunionᵢ_add_one {s : Finset ι} {f : ι → Finset α} (hf : Injective f)\n    (hs : (s : Set ι).PairwiseDisjoint f) : s.card ≤ (s.bunionᵢ f).card + 1 :=\n  (card_le_card_bunionᵢ_add_card_fiber hs).trans <|\n    add_le_add_left\n      (card_le_one.2 fun i hi j hj => hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm) _\n#align finset.card_le_card_bUnion_add_one Finset.card_le_card_bunionᵢ_add_one\n\nend DoubleCounting\n\nsection CanonicallyOrderedMonoid\n\nvariable [CanonicallyOrderedMonoid M] {f : ι → M} {s t : Finset ι}\n\n/- warning: finset.prod_eq_one_iff' -> Finset.prod_eq_one_iff' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι}, Iff (Eq.{succ u2} M (Finset.prod.{u2, u1} M ι (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : ι) => f x)) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1))))))))) (forall (x : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x s) -> (Eq.{succ u2} M (f x) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1))))))))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι}, Iff (Eq.{succ u2} M (Finset.prod.{u2, u1} M ι (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : ι) => f x)) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M (CommMonoid.toMonoid.{u2} M (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1))))))) (forall (x : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) x s) -> (Eq.{succ u2} M (f x) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (Monoid.toOne.{u2} M (CommMonoid.toMonoid.{u2} M (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_eq_one_iff' Finset.prod_eq_one_iff'ₓ'. -/\n@[simp, to_additive sum_eq_zero_iff]\ntheorem prod_eq_one_iff' : (∏ x in s, f x) = 1 ↔ ∀ x ∈ s, f x = 1 :=\n  prod_eq_one_iff_of_one_le' fun x hx => one_le (f x)\n#align finset.prod_eq_one_iff' Finset.prod_eq_one_iff'\n#align finset.sum_eq_zero_iff Finset.sum_eq_zero_iff\n\n/- warning: finset.prod_le_prod_of_subset' -> Finset.prod_le_prod_of_subset' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι} {t : Finset.{u1} ι}, (HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) s t) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCommMonoid.toPartialOrder.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)))) (Finset.prod.{u2, u1} M ι (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : ι) => f x)) (Finset.prod.{u2, u1} M ι (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) t (fun (x : ι) => f x)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : CanonicallyOrderedMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι} {t : Finset.{u2} ι}, (HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) s t) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)))) (Finset.prod.{u1, u2} M ι (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) s (fun (x : ι) => f x)) (Finset.prod.{u1, u2} M ι (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) t (fun (x : ι) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset'ₓ'. -/\n@[to_additive sum_le_sum_of_subset]\ntheorem prod_le_prod_of_subset' (h : s ⊆ t) : (∏ x in s, f x) ≤ ∏ x in t, f x :=\n  prod_le_prod_of_subset_of_one_le' h fun x h₁ h₂ => one_le _\n#align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset'\n#align finset.sum_le_sum_of_subset Finset.sum_le_sum_of_subset\n\n/- warning: finset.prod_mono_set' -> Finset.prod_mono_set' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] (f : ι -> M), Monotone.{u1, u2} (Finset.{u1} ι) M (PartialOrder.toPreorder.{u1} (Finset.{u1} ι) (Finset.partialOrder.{u1} ι)) (PartialOrder.toPreorder.{u2} M (OrderedCommMonoid.toPartialOrder.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1))) (fun (s : Finset.{u1} ι) => Finset.prod.{u2, u1} M ι (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : ι) => f x))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : CanonicallyOrderedMonoid.{u1} M] (f : ι -> M), Monotone.{u2, u1} (Finset.{u2} ι) M (PartialOrder.toPreorder.{u2} (Finset.{u2} ι) (Finset.partialOrder.{u2} ι)) (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1))) (fun (s : Finset.{u2} ι) => Finset.prod.{u1, u2} M ι (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) s (fun (x : ι) => f x))\nCase conversion may be inaccurate. Consider using '#align finset.prod_mono_set' Finset.prod_mono_set'ₓ'. -/\n@[to_additive sum_mono_set]\ntheorem prod_mono_set' (f : ι → M) : Monotone fun s => ∏ x in s, f x := fun s₁ s₂ hs =>\n  prod_le_prod_of_subset' hs\n#align finset.prod_mono_set' Finset.prod_mono_set'\n#align finset.sum_mono_set Finset.sum_mono_set\n\n/- warning: finset.prod_le_prod_of_ne_one' -> Finset.prod_le_prod_of_ne_one' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι} {t : Finset.{u1} ι}, (forall (x : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x s) -> (Ne.{succ u2} M (f x) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (CommMonoid.toMonoid.{u2} M (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1))))))))) -> (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) x t)) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCommMonoid.toPartialOrder.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)))) (Finset.prod.{u2, u1} M ι (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : ι) => f x)) (Finset.prod.{u2, u1} M ι (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) t (fun (x : ι) => f x)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : CanonicallyOrderedMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι} {t : Finset.{u2} ι}, (forall (x : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) x s) -> (Ne.{succ u1} M (f x) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1))))))) -> (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) x t)) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)))) (Finset.prod.{u1, u2} M ι (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) s (fun (x : ι) => f x)) (Finset.prod.{u1, u2} M ι (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) t (fun (x : ι) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one'ₓ'. -/\n@[to_additive sum_le_sum_of_ne_zero]\ntheorem prod_le_prod_of_ne_one' (h : ∀ x ∈ s, f x ≠ 1 → x ∈ t) : (∏ x in s, f x) ≤ ∏ x in t, f x :=\n  by\n  classical calc\n      (∏ x in s, f x) =\n          (∏ x in s.filter fun x => f x = 1, f x) * ∏ x in s.filter fun x => f x ≠ 1, f x :=\n        by\n        rw [← prod_union, filter_union_filter_neg_eq] <;>\n          exact disjoint_filter.2 fun _ _ h n_h => n_h h\n      _ ≤ ∏ x in t, f x :=\n        mul_le_of_le_one_of_le\n          (prod_le_one' <| by simp only [mem_filter, and_imp] <;> exact fun _ _ => le_of_eq)\n          (prod_le_prod_of_subset' <| by simpa only [subset_iff, mem_filter, and_imp] )\n      \n#align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one'\n#align finset.sum_le_sum_of_ne_zero Finset.sum_le_sum_of_ne_zero\n\nend CanonicallyOrderedMonoid\n\nsection OrderedCancelCommMonoid\n\nvariable [OrderedCancelCommMonoid M] {f g : ι → M} {s t : Finset ι}\n\n/- warning: finset.prod_lt_prod' -> Finset.prod_lt_prod' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (g i))) -> (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (g i)))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => g i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (g i))) -> (Exists.{succ u2} ι (fun (i : ι) => And (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (g i)))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => f i)) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_prod' Finset.prod_lt_prod'ₓ'. -/\n@[to_additive sum_lt_sum]\ntheorem prod_lt_prod' (Hle : ∀ i ∈ s, f i ≤ g i) (Hlt : ∃ i ∈ s, f i < g i) :\n    (∏ i in s, f i) < ∏ i in s, g i := by\n  classical\n    rcases Hlt with ⟨i, hi, hlt⟩\n    rw [← insert_erase hi, prod_insert (not_mem_erase _ _), prod_insert (not_mem_erase _ _)]\n    exact mul_lt_mul_of_lt_of_le hlt (prod_le_prod' fun j hj => Hle j <| mem_of_mem_erase hj)\n#align finset.prod_lt_prod' Finset.prod_lt_prod'\n#align finset.sum_lt_sum Finset.sum_lt_sum\n\n/- warning: finset.prod_lt_prod_of_nonempty' -> Finset.prod_lt_prod_of_nonempty' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u1} ι}, (Finset.Nonempty.{u1} ι s) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (g i))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => g i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u2} ι}, (Finset.Nonempty.{u2} ι s) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (g i))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => f i)) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty'ₓ'. -/\n@[to_additive sum_lt_sum_of_nonempty]\ntheorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : ∀ i ∈ s, f i < g i) :\n    (∏ i in s, f i) < ∏ i in s, g i := by\n  apply prod_lt_prod'\n  · intro i hi\n    apply le_of_lt (Hlt i hi)\n  cases' hs with i hi\n  exact ⟨i, hi, Hlt i hi⟩\n#align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty'\n#align finset.sum_lt_sum_of_nonempty Finset.sum_lt_sum_of_nonempty\n\n/- warning: finset.prod_lt_prod_of_subset' -> Finset.prod_lt_prod_of_subset' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι} {t : Finset.{u1} ι}, (HasSubset.Subset.{u1} (Finset.{u1} ι) (Finset.hasSubset.{u1} ι) s t) -> (forall {i : ι}, (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i t) -> (Not (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s)) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (f i)) -> (forall (j : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j t) -> (Not (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j s)) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (f j))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (j : ι) => f j)) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) t (fun (j : ι) => f j))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι} {t : Finset.{u2} ι}, (HasSubset.Subset.{u2} (Finset.{u2} ι) (Finset.instHasSubsetFinset.{u2} ι) s t) -> (forall {i : ι}, (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i t) -> (Not (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s)) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (f i)) -> (forall (j : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j t) -> (Not (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j s)) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (f j))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (j : ι) => f j)) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) t (fun (j : ι) => f j))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset'ₓ'. -/\n@[to_additive sum_lt_sum_of_subset]\ntheorem prod_lt_prod_of_subset' (h : s ⊆ t) {i : ι} (ht : i ∈ t) (hs : i ∉ s) (hlt : 1 < f i)\n    (hle : ∀ j ∈ t, j ∉ s → 1 ≤ f j) : (∏ j in s, f j) < ∏ j in t, f j := by\n  classical calc\n      (∏ j in s, f j) < ∏ j in insert i s, f j :=\n        by\n        rw [prod_insert hs]\n        exact lt_mul_of_one_lt_left' (∏ j in s, f j) hlt\n      _ ≤ ∏ j in t, f j := by\n        apply prod_le_prod_of_subset_of_one_le'\n        · simp [Finset.insert_subset, h, ht]\n        · intro x hx h'x\n          simp only [mem_insert, not_or] at h'x\n          exact hle x hx h'x.2\n      \n#align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset'\n#align finset.sum_lt_sum_of_subset Finset.sum_lt_sum_of_subset\n\n/- warning: finset.single_lt_prod' -> Finset.single_lt_prod' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι} {i : ι} {j : ι}, (Ne.{succ u1} ι j i) -> (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j s) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (f j)) -> (forall (k : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) k s) -> (Ne.{succ u1} ι k i) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (f k))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (k : ι) => f k)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι} {i : ι} {j : ι}, (Ne.{succ u2} ι j i) -> (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j s) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (f j)) -> (forall (k : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) k s) -> (Ne.{succ u2} ι k i) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (f k))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (k : ι) => f k)))\nCase conversion may be inaccurate. Consider using '#align finset.single_lt_prod' Finset.single_lt_prod'ₓ'. -/\n@[to_additive single_lt_sum]\ntheorem single_lt_prod' {i j : ι} (hij : j ≠ i) (hi : i ∈ s) (hj : j ∈ s) (hlt : 1 < f j)\n    (hle : ∀ k ∈ s, k ≠ i → 1 ≤ f k) : f i < ∏ k in s, f k :=\n  calc\n    f i = ∏ k in {i}, f k := prod_singleton.symm\n    _ < ∏ k in s, f k :=\n      prod_lt_prod_of_subset' (singleton_subset_iff.2 hi) hj (mt mem_singleton.1 hij) hlt\n        fun k hks hki => hle k hks (mt mem_singleton.2 hki)\n    \n#align finset.single_lt_prod' Finset.single_lt_prod'\n#align finset.single_lt_sum Finset.single_lt_sum\n\n/- warning: finset.one_lt_prod -> Finset.one_lt_prod is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (f i))) -> (Finset.Nonempty.{u1} ι s) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (f i))) -> (Finset.Nonempty.{u2} ι s) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_lt_prod Finset.one_lt_prodₓ'. -/\n@[to_additive sum_pos]\ntheorem one_lt_prod (h : ∀ i ∈ s, 1 < f i) (hs : s.Nonempty) : 1 < ∏ i in s, f i :=\n  lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty' hs h\n#align finset.one_lt_prod Finset.one_lt_prod\n#align finset.sum_pos Finset.sum_pos\n\n/- warning: finset.prod_lt_one -> Finset.prod_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))))) -> (Finset.Nonempty.{u1} ι s) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))))) -> (Finset.Nonempty.{u2} ι s) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => f i)) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_one Finset.prod_lt_oneₓ'. -/\n@[to_additive]\ntheorem prod_lt_one (h : ∀ i ∈ s, f i < 1) (hs : s.Nonempty) : (∏ i in s, f i) < 1 :=\n  (prod_lt_prod_of_nonempty' hs h).trans_le (by rw [prod_const_one])\n#align finset.prod_lt_one Finset.prod_lt_one\n#align finset.sum_neg Finset.sum_neg\n\n/- warning: finset.one_lt_prod' -> Finset.one_lt_prod' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (f i))) -> (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (f i)))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (f i))) -> (Exists.{succ u2} ι (fun (i : ι) => And (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (f i)))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_lt_prod' Finset.one_lt_prod'ₓ'. -/\n@[to_additive sum_pos']\ntheorem one_lt_prod' (h : ∀ i ∈ s, 1 ≤ f i) (hs : ∃ i ∈ s, 1 < f i) : 1 < ∏ i in s, f i :=\n  prod_const_one.symm.trans_lt <| prod_lt_prod' h hs\n#align finset.one_lt_prod' Finset.one_lt_prod'\n#align finset.sum_pos' Finset.sum_pos'\n\n/- warning: finset.prod_lt_one' -> Finset.prod_lt_one' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : ι -> M} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))))) -> (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1)))))))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M _inst_1))))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : ι -> M} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))))) -> (Exists.{succ u2} ι (fun (i : ι) => And (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1))))))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => f i)) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (RightCancelMonoid.toOne.{u1} M (CancelMonoid.toRightCancelMonoid.{u1} M (CancelCommMonoid.toCancelMonoid.{u1} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} M _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_one' Finset.prod_lt_one'ₓ'. -/\n@[to_additive]\ntheorem prod_lt_one' (h : ∀ i ∈ s, f i ≤ 1) (hs : ∃ i ∈ s, f i < 1) : (∏ i in s, f i) < 1 :=\n  prod_const_one.le.trans_lt' <| prod_lt_prod' h hs\n#align finset.prod_lt_one' Finset.prod_lt_one'\n#align finset.sum_neg' Finset.sum_neg'\n\n/- warning: finset.prod_eq_prod_iff_of_le -> Finset.prod_eq_prod_iff_of_le is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {s : Finset.{u1} ι} {f : ι -> M} {g : ι -> M}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (f i) (g i))) -> (Iff (Eq.{succ u2} M (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : ι) => g i))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Eq.{succ u2} M (f i) (g i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {s : Finset.{u2} ι} {f : ι -> M} {g : ι -> M}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (f i) (g i))) -> (Iff (Eq.{succ u1} M (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => f i)) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : ι) => g i))) (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Eq.{succ u1} M (f i) (g i))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_leₓ'. -/\n@[to_additive]\ntheorem prod_eq_prod_iff_of_le {f g : ι → M} (h : ∀ i ∈ s, f i ≤ g i) :\n    ((∏ i in s, f i) = ∏ i in s, g i) ↔ ∀ i ∈ s, f i = g i := by\n  classical\n    revert h\n    refine'\n      Finset.induction_on s (fun _ => ⟨fun _ _ => False.elim, fun _ => rfl⟩) fun a s ha ih H => _\n    specialize ih fun i => H i ∘ Finset.mem_insert_of_mem\n    rw [Finset.prod_insert ha, Finset.prod_insert ha, Finset.forall_mem_insert, ← ih]\n    exact\n      mul_eq_mul_iff_eq_and_eq (H a (s.mem_insert_self a))\n        (Finset.prod_le_prod' fun i => H i ∘ Finset.mem_insert_of_mem)\n#align finset.prod_eq_prod_iff_of_le Finset.prod_eq_prod_iff_of_le\n#align finset.sum_eq_sum_iff_of_le Finset.sum_eq_sum_iff_of_le\n\nend OrderedCancelCommMonoid\n\nsection LinearOrderedCancelCommMonoid\n\nvariable [LinearOrderedCancelCommMonoid M] {f g : ι → M} {s t : Finset ι}\n\n/- warning: finset.exists_lt_of_prod_lt' -> Finset.exists_lt_of_prod_lt' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u1} ι}, (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => g i))) -> (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (f i) (g i))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u1} ι}, (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => g i))) -> (Exists.{succ u1} ι (fun (i : ι) => And (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (f i) (g i))))\nCase conversion may be inaccurate. Consider using '#align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt'ₓ'. -/\n@[to_additive exists_lt_of_sum_lt]\ntheorem exists_lt_of_prod_lt' (Hlt : (∏ i in s, f i) < ∏ i in s, g i) : ∃ i ∈ s, f i < g i :=\n  by\n  contrapose! Hlt with Hle\n  exact prod_le_prod' Hle\n#align finset.exists_lt_of_prod_lt' Finset.exists_lt_of_prod_lt'\n#align finset.exists_lt_of_sum_lt Finset.exists_lt_of_sum_lt\n\n/- warning: finset.exists_le_of_prod_le' -> Finset.exists_le_of_prod_le' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u1} ι}, (Finset.Nonempty.{u1} ι s) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => g i))) -> (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (f i) (g i))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedCancelCommMonoid.{u1} M] {f : ι -> M} {g : ι -> M} {s : Finset.{u2} ι}, (Finset.Nonempty.{u2} ι s) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u1} M _inst_1)))) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u1} M _inst_1)) s (fun (i : ι) => f i)) (Finset.prod.{u1, u2} M ι (OrderedCancelCommMonoid.toCommMonoid.{u1} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u1} M _inst_1)) s (fun (i : ι) => g i))) -> (Exists.{succ u2} ι (fun (i : ι) => And (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u1} M _inst_1)))) (f i) (g i))))\nCase conversion may be inaccurate. Consider using '#align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le'ₓ'. -/\n@[to_additive exists_le_of_sum_le]\ntheorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : (∏ i in s, f i) ≤ ∏ i in s, g i) :\n    ∃ i ∈ s, f i ≤ g i := by\n  contrapose! Hle with Hlt\n  exact prod_lt_prod_of_nonempty' hs Hlt\n#align finset.exists_le_of_prod_le' Finset.exists_le_of_prod_le'\n#align finset.exists_le_of_sum_le Finset.exists_le_of_sum_le\n\n/- warning: finset.exists_one_lt_of_prod_one_of_exists_ne_one' -> Finset.exists_one_lt_of_prod_one_of_exists_ne_one' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {s : Finset.{u1} ι} (f : ι -> M), (Eq.{succ u2} M (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1))))))))))) -> (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => Ne.{succ u2} M (f i) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1))))))))))))) -> (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (OfNat.ofNat.{u2} M 1 (OfNat.mk.{u2} M 1 (One.one.{u2} M (MulOneClass.toHasOne.{u2} M (Monoid.toMulOneClass.{u2} M (RightCancelMonoid.toMonoid.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))))))))) (f i))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {s : Finset.{u1} ι} (f : ι -> M), (Eq.{succ u2} M (Finset.prod.{u2, u1} M ι (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (RightCancelMonoid.toOne.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))))))) -> (Exists.{succ u1} ι (fun (i : ι) => And (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) (Ne.{succ u2} M (f i) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (RightCancelMonoid.toOne.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))))))))) -> (Exists.{succ u1} ι (fun (i : ι) => And (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)))) (OfNat.ofNat.{u2} M 1 (One.toOfNat1.{u2} M (RightCancelMonoid.toOne.{u2} M (CancelMonoid.toRightCancelMonoid.{u2} M (CancelCommMonoid.toCancelMonoid.{u2} M (OrderedCancelCommMonoid.toCancelCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1))))))) (f i))))\nCase conversion may be inaccurate. Consider using '#align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one'ₓ'. -/\n@[to_additive exists_pos_of_sum_zero_of_exists_nonzero]\ntheorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : ι → M) (h₁ : (∏ i in s, f i) = 1)\n    (h₂ : ∃ i ∈ s, f i ≠ 1) : ∃ i ∈ s, 1 < f i :=\n  by\n  contrapose! h₁\n  obtain ⟨i, m, i_ne⟩ : ∃ i ∈ s, f i ≠ 1 := h₂\n  apply ne_of_lt\n  calc\n    (∏ j in s, f j) < ∏ j in s, 1 := prod_lt_prod' h₁ ⟨i, m, (h₁ i m).lt_of_ne i_ne⟩\n    _ = 1 := prod_const_one\n    \n#align finset.exists_one_lt_of_prod_one_of_exists_ne_one' Finset.exists_one_lt_of_prod_one_of_exists_ne_one'\n#align finset.exists_pos_of_sum_zero_of_exists_nonzero Finset.exists_pos_of_sum_zero_of_exists_nonzero\n\nend LinearOrderedCancelCommMonoid\n\nsection OrderedCommSemiring\n\nvariable [OrderedCommSemiring R] {f g : ι → R} {s t : Finset ι}\n\nopen Classical\n\n/- warning: finset.prod_nonneg -> Finset.prod_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {f : ι -> R} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))) (f i))) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {f : ι -> R} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (f i))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_nonneg Finset.prod_nonnegₓ'. -/\n-- this is also true for a ordered commutative multiplicative monoid with zero\ntheorem prod_nonneg (h0 : ∀ i ∈ s, 0 ≤ f i) : 0 ≤ ∏ i in s, f i :=\n  prod_induction f (fun i => 0 ≤ i) (fun _ _ ha hb => mul_nonneg ha hb) zero_le_one h0\n#align finset.prod_nonneg Finset.prod_nonneg\n\n/- warning: finset.prod_le_prod -> Finset.prod_le_prod is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {f : ι -> R} {g : ι -> R} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))) (f i))) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (f i) (g i))) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => f i)) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => g i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {f : ι -> R} {g : ι -> R} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (f i))) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (f i) (g i))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => f i)) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod Finset.prod_le_prodₓ'. -/\n/-- If all `f i`, `i ∈ s`, are nonnegative and each `f i` is less than or equal to `g i`, then the\nproduct of `f i` is less than or equal to the product of `g i`. See also `finset.prod_le_prod'` for\nthe case of an ordered commutative multiplicative monoid. -/\ntheorem prod_le_prod (h0 : ∀ i ∈ s, 0 ≤ f i) (h1 : ∀ i ∈ s, f i ≤ g i) :\n    (∏ i in s, f i) ≤ ∏ i in s, g i :=\n  by\n  induction' s using Finset.induction with a s has ih h\n  · simp\n  · simp only [prod_insert has]\n    apply mul_le_mul\n    · exact h1 a (mem_insert_self a s)\n    · apply ih (fun x H => h0 _ _) fun x H => h1 _ _ <;> exact mem_insert_of_mem H\n    · apply prod_nonneg fun x H => h0 x (mem_insert_of_mem H)\n    · apply le_trans (h0 a (mem_insert_self a s)) (h1 a (mem_insert_self a s))\n#align finset.prod_le_prod Finset.prod_le_prod\n\n/- warning: finset.prod_le_one -> Finset.prod_le_one is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {f : ι -> R} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))) (f i))) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (f i) (OfNat.ofNat.{u2} R 1 (OfNat.mk.{u2} R 1 (One.one.{u2} R (AddMonoidWithOne.toOne.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))))) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => f i)) (OfNat.ofNat.{u2} R 1 (OfNat.mk.{u2} R 1 (One.one.{u2} R (AddMonoidWithOne.toOne.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))))\nbut is expected to have type\n  forall {ι : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {f : ι -> R} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (f i))) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (f i) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1))))))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => f i)) (OfNat.ofNat.{u1} R 1 (One.toOfNat1.{u1} R (Semiring.toOne.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_one Finset.prod_le_oneₓ'. -/\n/-- If each `f i`, `i ∈ s` belongs to `[0, 1]`, then their product is less than or equal to one.\nSee also `finset.prod_le_one'` for the case of an ordered commutative multiplicative monoid. -/\ntheorem prod_le_one (h0 : ∀ i ∈ s, 0 ≤ f i) (h1 : ∀ i ∈ s, f i ≤ 1) : (∏ i in s, f i) ≤ 1 :=\n  by\n  convert← prod_le_prod h0 h1\n  exact Finset.prod_const_one\n#align finset.prod_le_one Finset.prod_le_one\n\n/- warning: finset.prod_add_prod_le -> Finset.prod_add_prod_le is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {s : Finset.{u1} ι} {i : ι} {f : ι -> R} {g : ι -> R} {h : ι -> R}, (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (HAdd.hAdd.{u2, u2, u2} R R R (instHAdd.{u2} R (Distrib.toHasAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))) (g i) (h i)) (f i)) -> (forall (j : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j s) -> (Ne.{succ u1} ι j i) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (g j) (f j))) -> (forall (j : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j s) -> (Ne.{succ u1} ι j i) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (h j) (f j))) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))) (g i))) -> (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))))) (h i))) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))) (HAdd.hAdd.{u2, u2, u2} R R R (instHAdd.{u2} R (Distrib.toHasAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R _inst_1))))))) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => g i)) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => h i))) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {s : Finset.{u2} ι} {i : ι} {f : ι -> R} {g : ι -> R} {h : ι -> R}, (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1))))))) (g i) (h i)) (f i)) -> (forall (j : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j s) -> (Ne.{succ u2} ι j i) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (g j) (f j))) -> (forall (j : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j s) -> (Ne.{succ u2} ι j i) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (h j) (f j))) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (g i))) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (h i))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1)))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R _inst_1))))))) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => g i)) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => h i))) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_add_prod_le Finset.prod_add_prod_leₓ'. -/\n/-- If `g, h ≤ f` and `g i + h i ≤ f i`, then the product of `f` over `s` is at least the\n  sum of the products of `g` and `h`. This is the version for `ordered_comm_semiring`. -/\ntheorem prod_add_prod_le {i : ι} {f g h : ι → R} (hi : i ∈ s) (h2i : g i + h i ≤ f i)\n    (hgf : ∀ j ∈ s, j ≠ i → g j ≤ f j) (hhf : ∀ j ∈ s, j ≠ i → h j ≤ f j) (hg : ∀ i ∈ s, 0 ≤ g i)\n    (hh : ∀ i ∈ s, 0 ≤ h i) : ((∏ i in s, g i) + ∏ i in s, h i) ≤ ∏ i in s, f i :=\n  by\n  simp_rw [prod_eq_mul_prod_diff_singleton hi]\n  refine' le_trans _ (mul_le_mul_of_nonneg_right h2i _)\n  · rw [right_distrib]\n    apply add_le_add <;> apply mul_le_mul_of_nonneg_left <;> try apply_assumption <;> assumption <;>\n        apply prod_le_prod <;>\n      simp (config := { contextual := true }) [*]\n  · apply prod_nonneg\n    simp only [and_imp, mem_sdiff, mem_singleton]\n    intro j h1j h2j\n    exact le_trans (hg j h1j) (hgf j h1j h2j)\n#align finset.prod_add_prod_le Finset.prod_add_prod_le\n\nend OrderedCommSemiring\n\nsection StrictOrderedCommSemiring\n\nvariable [StrictOrderedCommSemiring R] [Nontrivial R] {f : ι → R} {s : Finset ι}\n\n/- warning: finset.prod_pos -> Finset.prod_pos is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : StrictOrderedCommSemiring.{u2} R] [_inst_2 : Nontrivial.{u2} R] {f : ι -> R} {s : Finset.{u1} ι}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LT.lt.{u2} R (Preorder.toLT.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedCancelAddCommMonoid.toPartialOrder.{u2} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (StrictOrderedSemiring.toSemiring.{u2} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u2} R _inst_1))))))))) (f i))) -> (LT.lt.{u2} R (Preorder.toLT.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedCancelAddCommMonoid.toPartialOrder.{u2} R (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (StrictOrderedSemiring.toSemiring.{u2} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u2} R _inst_1))))))))) (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R (StrictOrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {R : Type.{u1}} [_inst_1 : StrictOrderedCommSemiring.{u1} R] [_inst_2 : Nontrivial.{u1} R] {f : ι -> R} {s : Finset.{u2} ι}, (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (StrictOrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (f i))) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (StrictOrderedSemiring.toPartialOrder.{u1} R (StrictOrderedCommSemiring.toStrictOrderedSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (StrictOrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (Finset.prod.{u1, u2} R ι (CommSemiring.toCommMonoid.{u1} R (StrictOrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_pos Finset.prod_posₓ'. -/\n-- This is also true for a ordered commutative multiplicative monoid with zero\ntheorem prod_pos (h0 : ∀ i ∈ s, 0 < f i) : 0 < ∏ i in s, f i :=\n  prod_induction f (fun x => 0 < x) (fun _ _ ha hb => mul_pos ha hb) zero_lt_one h0\n#align finset.prod_pos Finset.prod_pos\n\nend StrictOrderedCommSemiring\n\nsection CanonicallyOrderedCommSemiring\n\nvariable [CanonicallyOrderedCommSemiring R] {f g h : ι → R} {s : Finset ι} {i : ι}\n\n/- warning: canonically_ordered_comm_semiring.multiset_prod_pos -> CanonicallyOrderedCommSemiring.multiset_prod_pos is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} R] [_inst_2 : Nontrivial.{u1} R] {m : Multiset.{u1} R}, Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))))))) (Multiset.prod.{u1} R (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) m)) (forall (x : R), (Membership.Mem.{u1, u1} R (Multiset.{u1} R) (Multiset.hasMem.{u1} R) x m) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedAddCommMonoid.toPartialOrder.{u1} R (OrderedSemiring.toOrderedAddCommMonoid.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))) (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))))))) x))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} R] [_inst_2 : Nontrivial.{u1} R] {m : Multiset.{u1} R}, Iff (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CanonicallyOrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) (Multiset.prod.{u1} R (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) m)) (forall (x : R), (Membership.mem.{u1, u1} R (Multiset.{u1} R) (Multiset.instMembershipMultiset.{u1} R) x m) -> (LT.lt.{u1} R (Preorder.toLT.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (OfNat.ofNat.{u1} R 0 (Zero.toOfNat0.{u1} R (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R (CanonicallyOrderedCommSemiring.toCommSemiring.{u1} R _inst_1))))) x))\nCase conversion may be inaccurate. Consider using '#align canonically_ordered_comm_semiring.multiset_prod_pos CanonicallyOrderedCommSemiring.multiset_prod_posₓ'. -/\n@[simp]\ntheorem CanonicallyOrderedCommSemiring.multiset_prod_pos [Nontrivial R] {m : Multiset R} :\n    0 < m.Prod ↔ ∀ x ∈ m, (0 : R) < x :=\n  by\n  induction m using Quotient.inductionOn\n  rw [Multiset.quot_mk_to_coe, Multiset.coe_prod]\n  exact CanonicallyOrderedCommSemiring.list_prod_pos\n#align canonically_ordered_comm_semiring.multiset_prod_pos CanonicallyOrderedCommSemiring.multiset_prod_pos\n\n/- warning: canonically_ordered_comm_semiring.prod_pos -> CanonicallyOrderedCommSemiring.prod_pos is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : CanonicallyOrderedCommSemiring.{u2} R] {f : ι -> R} {s : Finset.{u1} ι} [_inst_2 : Nontrivial.{u2} R], Iff (LT.lt.{u2} R (Preorder.toLT.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))))))) (Finset.prod.{u2, u1} R ι (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : ι) => f i))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LT.lt.{u2} R (Preorder.toLT.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))) (OfNat.ofNat.{u2} R 0 (OfNat.mk.{u2} R 0 (Zero.zero.{u2} R (MulZeroClass.toHasZero.{u2} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))))))) (f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : CanonicallyOrderedCommSemiring.{u2} R] {f : ι -> R} {s : Finset.{u1} ι} [_inst_2 : Nontrivial.{u2} R], Iff (LT.lt.{u2} R (Preorder.toLT.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedSemiring.toPartialOrder.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (Zero.toOfNat0.{u2} R (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CanonicallyOrderedCommSemiring.toCommSemiring.{u2} R _inst_1))))) (Finset.prod.{u2, u1} R ι (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : ι) => f i))) (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (LT.lt.{u2} R (Preorder.toLT.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedSemiring.toPartialOrder.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1))))) (OfNat.ofNat.{u2} R 0 (Zero.toOfNat0.{u2} R (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CanonicallyOrderedCommSemiring.toCommSemiring.{u2} R _inst_1))))) (f i)))\nCase conversion may be inaccurate. Consider using '#align canonically_ordered_comm_semiring.prod_pos CanonicallyOrderedCommSemiring.prod_posₓ'. -/\n/-- Note that the name is to match `canonically_ordered_comm_semiring.mul_pos`. -/\n@[simp]\ntheorem CanonicallyOrderedCommSemiring.prod_pos [Nontrivial R] :\n    (0 < ∏ i in s, f i) ↔ ∀ i ∈ s, (0 : R) < f i :=\n  CanonicallyOrderedCommSemiring.multiset_prod_pos.trans <| by simp\n#align canonically_ordered_comm_semiring.prod_pos CanonicallyOrderedCommSemiring.prod_pos\n\n/- warning: finset.prod_add_prod_le' -> Finset.prod_add_prod_le' is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : CanonicallyOrderedCommSemiring.{u2} R] {f : ι -> R} {g : ι -> R} {h : ι -> R} {s : Finset.{u1} ι} {i : ι}, (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))) (HAdd.hAdd.{u2, u2, u2} R R R (instHAdd.{u2} R (Distrib.toHasAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))))) (g i) (h i)) (f i)) -> (forall (j : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j s) -> (Ne.{succ u1} ι j i) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))) (g j) (f j))) -> (forall (j : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) j s) -> (Ne.{succ u1} ι j i) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))) (h j) (f j))) -> (LE.le.{u2} R (Preorder.toLE.{u2} R (PartialOrder.toPreorder.{u2} R (OrderedAddCommMonoid.toPartialOrder.{u2} R (OrderedSemiring.toOrderedAddCommMonoid.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))) (HAdd.hAdd.{u2, u2, u2} R R R (instHAdd.{u2} R (Distrib.toHasAdd.{u2} R (NonUnitalNonAssocSemiring.toDistrib.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (OrderedSemiring.toSemiring.{u2} R (OrderedCommSemiring.toOrderedSemiring.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u2} R _inst_1)))))))) (Finset.prod.{u2, u1} R ι (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : ι) => g i)) (Finset.prod.{u2, u1} R ι (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : ι) => h i))) (Finset.prod.{u2, u1} R ι (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : ι) => f i)))\nbut is expected to have type\n  forall {ι : Type.{u2}} {R : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} R] {f : ι -> R} {g : ι -> R} {h : ι -> R} {s : Finset.{u2} ι} {i : ι}, (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))))) (g i) (h i)) (f i)) -> (forall (j : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j s) -> (Ne.{succ u2} ι j i) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (g j) (f j))) -> (forall (j : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) j s) -> (Ne.{succ u2} ι j i) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (h j) (f j))) -> (LE.le.{u1} R (Preorder.toLE.{u1} R (PartialOrder.toPreorder.{u1} R (OrderedSemiring.toPartialOrder.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1))))) (HAdd.hAdd.{u1, u1, u1} R R R (instHAdd.{u1} R (Distrib.toAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (OrderedSemiring.toSemiring.{u1} R (OrderedCommSemiring.toOrderedSemiring.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} R _inst_1)))))))) (Finset.prod.{u1, u2} R ι (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) s (fun (i : ι) => g i)) (Finset.prod.{u1, u2} R ι (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) s (fun (i : ι) => h i))) (Finset.prod.{u1, u2} R ι (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) s (fun (i : ι) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_add_prod_le' Finset.prod_add_prod_le'ₓ'. -/\n/-- If `g, h ≤ f` and `g i + h i ≤ f i`, then the product of `f` over `s` is at least the\n  sum of the products of `g` and `h`. This is the version for `canonically_ordered_comm_semiring`.\n-/\ntheorem prod_add_prod_le' (hi : i ∈ s) (h2i : g i + h i ≤ f i) (hgf : ∀ j ∈ s, j ≠ i → g j ≤ f j)\n    (hhf : ∀ j ∈ s, j ≠ i → h j ≤ f j) : ((∏ i in s, g i) + ∏ i in s, h i) ≤ ∏ i in s, f i := by\n  classical\n    simp_rw [prod_eq_mul_prod_diff_singleton hi]\n    refine' le_trans _ (mul_le_mul_right' h2i _)\n    rw [right_distrib]\n    apply add_le_add <;> apply mul_le_mul_left' <;> apply prod_le_prod' <;>\n            simp only [and_imp, mem_sdiff, mem_singleton] <;>\n          intros <;>\n        apply_assumption <;>\n      assumption\n#align finset.prod_add_prod_le' Finset.prod_add_prod_le'\n\nend CanonicallyOrderedCommSemiring\n\nend Finset\n\nnamespace Fintype\n\nvariable [Fintype ι]\n\n#print Fintype.prod_mono' /-\n@[to_additive sum_mono, mono]\ntheorem prod_mono' [OrderedCommMonoid M] : Monotone fun f : ι → M => ∏ i, f i := fun f g hfg =>\n  Finset.prod_le_prod' fun x _ => hfg x\n#align fintype.prod_mono' Fintype.prod_mono'\n#align fintype.sum_mono Fintype.sum_mono\n-/\n\nattribute [mono] sum_mono\n\n#print Fintype.prod_strict_mono' /-\n@[to_additive sum_strict_mono]\ntheorem prod_strict_mono' [OrderedCancelCommMonoid M] : StrictMono fun f : ι → M => ∏ x, f x :=\n  fun f g hfg =>\n  let ⟨hle, i, hlt⟩ := Pi.lt_def.mp hfg\n  Finset.prod_lt_prod' (fun i _ => hle i) ⟨i, Finset.mem_univ i, hlt⟩\n#align fintype.prod_strict_mono' Fintype.prod_strict_mono'\n#align fintype.sum_strict_mono Fintype.sum_strict_mono\n-/\n\nend Fintype\n\nnamespace WithTop\n\nopen Finset\n\n/- warning: with_top.prod_lt_top -> WithTop.prod_lt_top is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommMonoidWithZero.{u2} R] [_inst_2 : NoZeroDivisors.{u2} R (MulZeroClass.toHasMul.{u2} R (MulZeroOneClass.toMulZeroClass.{u2} R (MonoidWithZero.toMulZeroOneClass.{u2} R (CommMonoidWithZero.toMonoidWithZero.{u2} R _inst_1)))) (MulZeroClass.toHasZero.{u2} R (MulZeroOneClass.toMulZeroClass.{u2} R (MonoidWithZero.toMulZeroOneClass.{u2} R (CommMonoidWithZero.toMonoidWithZero.{u2} R _inst_1))))] [_inst_3 : Nontrivial.{u2} R] [_inst_4 : DecidableEq.{succ u2} R] [_inst_5 : LT.{u2} R] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} R)}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Ne.{succ u2} (WithTop.{u2} R) (f i) (Top.top.{u2} (WithTop.{u2} R) (WithTop.hasTop.{u2} R)))) -> (LT.lt.{u2} (WithTop.{u2} R) (WithTop.hasLt.{u2} R _inst_5) (Finset.prod.{u2, u1} (WithTop.{u2} R) ι (CommMonoidWithZero.toCommMonoid.{u2} (WithTop.{u2} R) (WithTop.commMonoidWithZero.{u2} R (fun (a : R) (b : R) => _inst_4 a b) _inst_1 _inst_2 _inst_3)) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} R) (WithTop.hasTop.{u2} R)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommMonoidWithZero.{u2} R] [_inst_2 : NoZeroDivisors.{u2} R (MulZeroClass.toMul.{u2} R (MulZeroOneClass.toMulZeroClass.{u2} R (MonoidWithZero.toMulZeroOneClass.{u2} R (CommMonoidWithZero.toMonoidWithZero.{u2} R _inst_1)))) (CommMonoidWithZero.toZero.{u2} R _inst_1)] [_inst_3 : Nontrivial.{u2} R] [_inst_4 : DecidableEq.{succ u2} R] [_inst_5 : LT.{u2} R] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} R)}, (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (Ne.{succ u2} (WithTop.{u2} R) (f i) (Top.top.{u2} (WithTop.{u2} R) (WithTop.top.{u2} R)))) -> (LT.lt.{u2} (WithTop.{u2} R) (WithTop.lt.{u2} R _inst_5) (Finset.prod.{u2, u1} (WithTop.{u2} R) ι (CommMonoidWithZero.toCommMonoid.{u2} (WithTop.{u2} R) (WithTop.commMonoidWithZero.{u2} R (fun (a : R) (b : R) => _inst_4 a b) _inst_1 _inst_2 _inst_3)) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} R) (WithTop.top.{u2} R)))\nCase conversion may be inaccurate. Consider using '#align with_top.prod_lt_top WithTop.prod_lt_topₓ'. -/\n/-- A product of finite numbers is still finite -/\ntheorem prod_lt_top [CommMonoidWithZero R] [NoZeroDivisors R] [Nontrivial R] [DecidableEq R] [LT R]\n    {s : Finset ι} {f : ι → WithTop R} (h : ∀ i ∈ s, f i ≠ ⊤) : (∏ i in s, f i) < ⊤ :=\n  prod_induction f (fun a => a < ⊤) (fun a b h₁ h₂ => mul_lt_top' h₁ h₂) (coe_lt_top 1) fun a ha =>\n    WithTop.lt_top_iff_ne_top.2 (h a ha)\n#align with_top.prod_lt_top WithTop.prod_lt_top\n\n/- warning: with_top.sum_eq_top_iff -> WithTop.sum_eq_top_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} M)}, Iff (Eq.{succ u2} (WithTop.{u2} M) (Finset.sum.{u2, u1} (WithTop.{u2} M) ι (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M))) (Exists.{succ u1} ι (fun (i : ι) => Exists.{0} (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) (fun (H : Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) => Eq.{succ u2} (WithTop.{u2} M) (f i) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M)))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} M)}, Iff (Eq.{succ u2} (WithTop.{u2} M) (Finset.sum.{u2, u1} (WithTop.{u2} M) ι (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M))) (Exists.{succ u1} ι (fun (i : ι) => And (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) (Eq.{succ u2} (WithTop.{u2} M) (f i) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M)))))\nCase conversion may be inaccurate. Consider using '#align with_top.sum_eq_top_iff WithTop.sum_eq_top_iffₓ'. -/\n/-- A sum of numbers is infinite iff one of them is infinite -/\ntheorem sum_eq_top_iff [AddCommMonoid M] {s : Finset ι} {f : ι → WithTop M} :\n    (∑ i in s, f i) = ⊤ ↔ ∃ i ∈ s, f i = ⊤ := by\n  induction s using Finset.cons_induction <;> simp [*, or_and_right, exists_or]\n#align with_top.sum_eq_top_iff WithTop.sum_eq_top_iff\n\n/- warning: with_top.sum_lt_top_iff -> WithTop.sum_lt_top_iff is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} M)}, Iff (LT.lt.{u2} (WithTop.{u2} M) (WithTop.hasLt.{u2} M _inst_2) (Finset.sum.{u2, u1} (WithTop.{u2} M) ι (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M))) (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (LT.lt.{u2} (WithTop.{u2} M) (WithTop.hasLt.{u2} M _inst_2) (f i) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M))))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} M)}, Iff (LT.lt.{u2} (WithTop.{u2} M) (WithTop.lt.{u2} M _inst_2) (Finset.sum.{u2, u1} (WithTop.{u2} M) ι (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M))) (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (LT.lt.{u2} (WithTop.{u2} M) (WithTop.lt.{u2} M _inst_2) (f i) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M))))\nCase conversion may be inaccurate. Consider using '#align with_top.sum_lt_top_iff WithTop.sum_lt_top_iffₓ'. -/\n/-- A sum of finite numbers is still finite -/\ntheorem sum_lt_top_iff [AddCommMonoid M] [LT M] {s : Finset ι} {f : ι → WithTop M} :\n    (∑ i in s, f i) < ⊤ ↔ ∀ i ∈ s, f i < ⊤ := by\n  simp only [WithTop.lt_top_iff_ne_top, Ne.def, sum_eq_top_iff, not_exists]\n#align with_top.sum_lt_top_iff WithTop.sum_lt_top_iff\n\n/- warning: with_top.sum_lt_top -> WithTop.sum_lt_top is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} M)}, (forall (i : ι), (Membership.Mem.{u1, u1} ι (Finset.{u1} ι) (Finset.hasMem.{u1} ι) i s) -> (Ne.{succ u2} (WithTop.{u2} M) (f i) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M)))) -> (LT.lt.{u2} (WithTop.{u2} M) (WithTop.hasLt.{u2} M _inst_2) (Finset.sum.{u2, u1} (WithTop.{u2} M) ι (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} ι} {f : ι -> (WithTop.{u2} M)}, (forall (i : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) i s) -> (Ne.{succ u2} (WithTop.{u2} M) (f i) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M)))) -> (LT.lt.{u2} (WithTop.{u2} M) (WithTop.lt.{u2} M _inst_2) (Finset.sum.{u2, u1} (WithTop.{u2} M) ι (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : ι) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M)))\nCase conversion may be inaccurate. Consider using '#align with_top.sum_lt_top WithTop.sum_lt_topₓ'. -/\n/-- A sum of finite numbers is still finite -/\ntheorem sum_lt_top [AddCommMonoid M] [LT M] {s : Finset ι} {f : ι → WithTop M}\n    (h : ∀ i ∈ s, f i ≠ ⊤) : (∑ i in s, f i) < ⊤ :=\n  sum_lt_top_iff.2 fun i hi => WithTop.lt_top_iff_ne_top.2 (h i hi)\n#align with_top.sum_lt_top WithTop.sum_lt_top\n\nend WithTop\n\nsection AbsoluteValue\n\nvariable {S : Type _}\n\n/- warning: absolute_value.sum_le -> AbsoluteValue.sum_le is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : Semiring.{u2} R] [_inst_2 : OrderedSemiring.{u3} S] (abv : AbsoluteValue.{u2, u3} R S _inst_1 _inst_2) (s : Finset.{u1} ι) (f : ι -> R), LE.le.{u3} S (Preorder.toLE.{u3} S (PartialOrder.toPreorder.{u3} S (OrderedAddCommMonoid.toPartialOrder.{u3} S (OrderedSemiring.toOrderedAddCommMonoid.{u3} S _inst_2)))) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AbsoluteValue.{u2, u3} R S _inst_1 _inst_2) (fun (f : AbsoluteValue.{u2, u3} R S _inst_1 _inst_2) => R -> S) (AbsoluteValue.hasCoeToFun.{u2, u3} R S _inst_1 _inst_2) abv (Finset.sum.{u2, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u3, u1} S ι (OrderedAddCommMonoid.toAddCommMonoid.{u3} S (OrderedSemiring.toOrderedAddCommMonoid.{u3} S _inst_2)) s (fun (i : ι) => coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AbsoluteValue.{u2, u3} R S _inst_1 _inst_2) (fun (f : AbsoluteValue.{u2, u3} R S _inst_1 _inst_2) => R -> S) (AbsoluteValue.hasCoeToFun.{u2, u3} R S _inst_1 _inst_2) abv (f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u3}} {S : Type.{u2}} [_inst_1 : Semiring.{u3} R] [_inst_2 : OrderedSemiring.{u2} S] (abv : AbsoluteValue.{u3, u2} R S _inst_1 _inst_2) (s : Finset.{u1} ι) (f : ι -> R), LE.le.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : ι) => f i))) (Preorder.toLE.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : ι) => f i))) (PartialOrder.toPreorder.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : ι) => f i))) (OrderedSemiring.toPartialOrder.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : ι) => f i))) _inst_2))) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AbsoluteValue.{u3, u2} R S _inst_1 _inst_2) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) f) (SubadditiveHomClass.toFunLike.{max u3 u2, u3, u2} (AbsoluteValue.{u3, u2} R S _inst_1 _inst_2) R S (Distrib.toAdd.{u3} R (NonUnitalNonAssocSemiring.toDistrib.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S _inst_2))))) (Preorder.toLE.{u2} S (PartialOrder.toPreorder.{u2} S (OrderedSemiring.toPartialOrder.{u2} S _inst_2))) (AbsoluteValue.subadditiveHomClass.{u3, u2} R S _inst_1 _inst_2)) abv (Finset.sum.{u3, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} S ι (OrderedAddCommMonoid.toAddCommMonoid.{u2} S (OrderedSemiring.toOrderedAddCommMonoid.{u2} S _inst_2)) s (fun (i : ι) => FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AbsoluteValue.{u3, u2} R S _inst_1 _inst_2) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) f) (SubadditiveHomClass.toFunLike.{max u3 u2, u3, u2} (AbsoluteValue.{u3, u2} R S _inst_1 _inst_2) R S (Distrib.toAdd.{u3} R (NonUnitalNonAssocSemiring.toDistrib.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S _inst_2))))) (Preorder.toLE.{u2} S (PartialOrder.toPreorder.{u2} S (OrderedSemiring.toPartialOrder.{u2} S _inst_2))) (AbsoluteValue.subadditiveHomClass.{u3, u2} R S _inst_1 _inst_2)) abv (f i)))\nCase conversion may be inaccurate. Consider using '#align absolute_value.sum_le AbsoluteValue.sum_leₓ'. -/\ntheorem AbsoluteValue.sum_le [Semiring R] [OrderedSemiring S] (abv : AbsoluteValue R S)\n    (s : Finset ι) (f : ι → R) : abv (∑ i in s, f i) ≤ ∑ i in s, abv (f i) :=\n  Finset.le_sum_of_subadditive abv (map_zero _) abv.add_le _ _\n#align absolute_value.sum_le AbsoluteValue.sum_le\n\n/- warning: is_absolute_value.abv_sum -> IsAbsoluteValue.abv_sum is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : Semiring.{u2} R] [_inst_2 : OrderedSemiring.{u3} S] (abv : R -> S) [_inst_3 : IsAbsoluteValue.{u3, u2} S _inst_2 R _inst_1 abv] (f : ι -> R) (s : Finset.{u1} ι), LE.le.{u3} S (Preorder.toLE.{u3} S (PartialOrder.toPreorder.{u3} S (OrderedAddCommMonoid.toPartialOrder.{u3} S (OrderedSemiring.toOrderedAddCommMonoid.{u3} S _inst_2)))) (abv (Finset.sum.{u2, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u3, u1} S ι (OrderedAddCommMonoid.toAddCommMonoid.{u3} S (OrderedSemiring.toOrderedAddCommMonoid.{u3} S _inst_2)) s (fun (i : ι) => abv (f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u3}} {S : Type.{u2}} [_inst_1 : Semiring.{u3} R] [_inst_2 : OrderedSemiring.{u2} S] (abv : R -> S) [_inst_3 : IsAbsoluteValue.{u2, u3} S _inst_2 R _inst_1 abv] (f : ι -> R) (s : Finset.{u1} ι), LE.le.{u2} S (Preorder.toLE.{u2} S (PartialOrder.toPreorder.{u2} S (OrderedSemiring.toPartialOrder.{u2} S _inst_2))) (abv (Finset.sum.{u3, u1} R ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : ι) => f i))) (Finset.sum.{u2, u1} S ι (OrderedAddCommMonoid.toAddCommMonoid.{u2} S (OrderedSemiring.toOrderedAddCommMonoid.{u2} S _inst_2)) s (fun (i : ι) => abv (f i)))\nCase conversion may be inaccurate. Consider using '#align is_absolute_value.abv_sum IsAbsoluteValue.abv_sumₓ'. -/\ntheorem IsAbsoluteValue.abv_sum [Semiring R] [OrderedSemiring S] (abv : R → S) [IsAbsoluteValue abv]\n    (f : ι → R) (s : Finset ι) : abv (∑ i in s, f i) ≤ ∑ i in s, abv (f i) :=\n  (IsAbsoluteValue.toAbsoluteValue abv).sum_le _ _\n#align is_absolute_value.abv_sum IsAbsoluteValue.abv_sum\n\n/- warning: absolute_value.map_prod -> AbsoluteValue.map_prod is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Nontrivial.{u2} R] [_inst_3 : LinearOrderedCommRing.{u3} S] (abv : AbsoluteValue.{u2, u3} R S (CommSemiring.toSemiring.{u2} R _inst_1) (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3))))) (f : ι -> R) (s : Finset.{u1} ι), Eq.{succ u3} S (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AbsoluteValue.{u2, u3} R S (CommSemiring.toSemiring.{u2} R _inst_1) (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3))))) (fun (f : AbsoluteValue.{u2, u3} R S (CommSemiring.toSemiring.{u2} R _inst_1) (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3))))) => R -> S) (AbsoluteValue.hasCoeToFun.{u2, u3} R S (CommSemiring.toSemiring.{u2} R _inst_1) (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3))))) abv (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R _inst_1) s (fun (i : ι) => f i))) (Finset.prod.{u3, u1} S ι (LinearOrderedCommRing.toCommMonoid.{u3} S _inst_3) s (fun (i : ι) => coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AbsoluteValue.{u2, u3} R S (CommSemiring.toSemiring.{u2} R _inst_1) (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3))))) (fun (f : AbsoluteValue.{u2, u3} R S (CommSemiring.toSemiring.{u2} R _inst_1) (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3))))) => R -> S) (AbsoluteValue.hasCoeToFun.{u2, u3} R S (CommSemiring.toSemiring.{u2} R _inst_1) (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3))))) abv (f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u3}} {S : Type.{u2}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : Nontrivial.{u3} R] [_inst_3 : LinearOrderedCommRing.{u2} S] (abv : AbsoluteValue.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))) (f : ι -> R) (s : Finset.{u1} ι), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.prod.{u3, u1} R ι (CommSemiring.toCommMonoid.{u3} R _inst_1) s (fun (i : ι) => f i))) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AbsoluteValue.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) f) (SubadditiveHomClass.toFunLike.{max u3 u2, u3, u2} (AbsoluteValue.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))) R S (Distrib.toAdd.{u3} R (NonUnitalNonAssocSemiring.toDistrib.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))))))) (Preorder.toLE.{u2} S (PartialOrder.toPreorder.{u2} S (OrderedSemiring.toPartialOrder.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))))) (AbsoluteValue.subadditiveHomClass.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3)))))) abv (Finset.prod.{u3, u1} R ι (CommSemiring.toCommMonoid.{u3} R _inst_1) s (fun (i : ι) => f i))) (Finset.prod.{u2, u1} S ι (LinearOrderedCommRing.toCommMonoid.{u2} S _inst_3) s (fun (i : ι) => FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AbsoluteValue.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))) R (fun (f : R) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) f) (SubadditiveHomClass.toFunLike.{max u3 u2, u3, u2} (AbsoluteValue.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))) R S (Distrib.toAdd.{u3} R (NonUnitalNonAssocSemiring.toDistrib.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Distrib.toAdd.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (OrderedSemiring.toSemiring.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))))))) (Preorder.toLE.{u2} S (PartialOrder.toPreorder.{u2} S (OrderedSemiring.toPartialOrder.{u2} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3))))))) (AbsoluteValue.subadditiveHomClass.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3)))))) abv (f i)))\nCase conversion may be inaccurate. Consider using '#align absolute_value.map_prod AbsoluteValue.map_prodₓ'. -/\ntheorem AbsoluteValue.map_prod [CommSemiring R] [Nontrivial R] [LinearOrderedCommRing S]\n    (abv : AbsoluteValue R S) (f : ι → R) (s : Finset ι) :\n    abv (∏ i in s, f i) = ∏ i in s, abv (f i) :=\n  abv.toMonoidHom.map_prod f s\n#align absolute_value.map_prod AbsoluteValue.map_prod\n\n/- warning: is_absolute_value.map_prod -> IsAbsoluteValue.map_prod is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} {S : Type.{u3}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : Nontrivial.{u2} R] [_inst_3 : LinearOrderedCommRing.{u3} S] (abv : R -> S) [_inst_4 : IsAbsoluteValue.{u3, u2} S (StrictOrderedSemiring.toOrderedSemiring.{u3} S (StrictOrderedRing.toStrictOrderedSemiring.{u3} S (LinearOrderedRing.toStrictOrderedRing.{u3} S (LinearOrderedCommRing.toLinearOrderedRing.{u3} S _inst_3)))) R (CommSemiring.toSemiring.{u2} R _inst_1) abv] (f : ι -> R) (s : Finset.{u1} ι), Eq.{succ u3} S (abv (Finset.prod.{u2, u1} R ι (CommSemiring.toCommMonoid.{u2} R _inst_1) s (fun (i : ι) => f i))) (Finset.prod.{u3, u1} S ι (LinearOrderedCommRing.toCommMonoid.{u3} S _inst_3) s (fun (i : ι) => abv (f i)))\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u3}} {S : Type.{u2}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : Nontrivial.{u3} R] [_inst_3 : LinearOrderedCommRing.{u2} S] (abv : R -> S) [_inst_4 : IsAbsoluteValue.{u2, u3} S (OrderedCommSemiring.toOrderedSemiring.{u2} S (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} S (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} S (LinearOrderedCommRing.toLinearOrderedCommSemiring.{u2} S _inst_3)))) R (CommSemiring.toSemiring.{u3} R _inst_1) abv] (f : ι -> R) (s : Finset.{u1} ι), Eq.{succ u2} S (abv (Finset.prod.{u3, u1} R ι (CommSemiring.toCommMonoid.{u3} R _inst_1) s (fun (i : ι) => f i))) (Finset.prod.{u2, u1} S ι (LinearOrderedCommRing.toCommMonoid.{u2} S _inst_3) s (fun (i : ι) => abv (f i)))\nCase conversion may be inaccurate. Consider using '#align is_absolute_value.map_prod IsAbsoluteValue.map_prodₓ'. -/\ntheorem IsAbsoluteValue.map_prod [CommSemiring R] [Nontrivial R] [LinearOrderedCommRing S]\n    (abv : R → S) [IsAbsoluteValue abv] (f : ι → R) (s : Finset ι) :\n    abv (∏ i in s, f i) = ∏ i in s, abv (f i) :=\n  (IsAbsoluteValue.toAbsoluteValue abv).map_prod _ _\n#align is_absolute_value.map_prod IsAbsoluteValue.map_prod\n\nend AbsoluteValue\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/BigOperators/Order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.46802834802420046}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury G. Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.affine_space.midpoint\nimport Mathlib.algebra.module.ordered\nimport Mathlib.tactic.field_simp\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Ordered modules as affine spaces\n\nIn this file we define the slope of a function `f : k → PE` taking values in an affine space over\n`k` and prove some theorems about `slope` and `line_map` in the case when `PE` is an ordered\nsemimodule over `k`. The `slope` function naturally appears in the Mean Value Theorem, and in the\nproof of the fact that a function with nonnegative second derivative on an interval is convex on\nthis interval. In the third part of this file we prove inequalities that will be used in\n`analysis.convex.basic` to link convexity of a function on an interval to monotonicity of the slope,\nsee section docstring below for details.\n\n## Implementation notes\n\nWe do not introduce the notion of ordered affine spaces (yet?). Instead, we prove various theorems\nfor an ordered semimodule interpreted as an affine space.\n\n## Tags\n\naffine space, ordered semimodule, slope\n-/\n\n/-!\n### Definition of `slope` and basic properties\n\nIn this section we define `slope f a b` and prove some properties that do not require order on the\ncodomain.  -/\n\n/-- `slope f a b = (b - a)⁻¹ • (f b -ᵥ f a)` is the slope of a function `f` on the interval\n`[a, b]`. Note that `slope f a a = 0`, not the derivative of `f` at `a`. -/\ndef slope {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) : E :=\n  b - a⁻¹ • (f b -ᵥ f a)\n\ntheorem slope_def_field {k : Type u_1} [field k] (f : k → k) (a : k) (b : k) : slope f a b = (f b - f a) / (b - a) :=\n  Eq.symm div_eq_inv_mul\n\n@[simp] theorem slope_same {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) : slope f a a = 0 := sorry\n\ntheorem eq_of_slope_eq_zero {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] {f : k → PE} {a : k} {b : k} (h : slope f a b = 0) : f a = f b := sorry\n\ntheorem slope_comm {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) : slope f a b = slope f b a := sorry\n\n/-- `slope f a c` is a linear combination of `slope f a b` and `slope f b c`. This version\nexplicitly provides coefficients. If `a ≠ c`, then the sum of the coefficients is `1`, so it is\nactually an affine combination, see `line_map_slope_slope_sub_div_sub`. -/\ntheorem sub_div_sub_smul_slope_add_sub_div_sub_smul_slope {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) (c : k) : ((b - a) / (c - a)) • slope f a b + ((c - b) / (c - a)) • slope f b c = slope f a c := sorry\n\n/-- `slope f a c` is an affine combination of `slope f a b` and `slope f b c`. This version uses\n`line_map` to express this property. -/\ntheorem line_map_slope_slope_sub_div_sub {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) (c : k) (h : a ≠ c) : coe_fn (affine_map.line_map (slope f a b) (slope f b c)) ((c - b) / (c - a)) = slope f a c := sorry\n\n/-- `slope f a b` is an affine combination of `slope f a (line_map a b r)` and\n`slope f (line_map a b r) b`. We use `line_map` to express this property. -/\ntheorem line_map_slope_line_map_slope_line_map {k : Type u_1} {E : Type u_2} {PE : Type u_3} [field k] [add_comm_group E] [semimodule k E] [add_torsor E PE] (f : k → PE) (a : k) (b : k) (r : k) : coe_fn\n    (affine_map.line_map (slope f (coe_fn (affine_map.line_map a b) r) b)\n      (slope f a (coe_fn (affine_map.line_map a b) r)))\n    r =\n  slope f a b := sorry\n\n/-!\n### Monotonicity of `line_map`\n\nIn this section we prove that `line_map a b r` is monotone (strictly or not) in its arguments if\nother arguments belong to specific domains.\n-/\n\ntheorem line_map_mono_left {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E} {r : k} (ha : a ≤ a') (hr : r ≤ 1) : coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a' b) r := sorry\n\ntheorem line_map_strict_mono_left {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E} {r : k} (ha : a < a') (hr : r < 1) : coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a' b) r := sorry\n\ntheorem line_map_mono_right {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {b' : E} {r : k} (hb : b ≤ b') (hr : 0 ≤ r) : coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a b') r := sorry\n\ntheorem line_map_strict_mono_right {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {b' : E} {r : k} (hb : b < b') (hr : 0 < r) : coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a b') r := sorry\n\ntheorem line_map_mono_endpoints {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E} {b' : E} {r : k} (ha : a ≤ a') (hb : b ≤ b') (h₀ : 0 ≤ r) (h₁ : r ≤ 1) : coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a' b') r :=\n  has_le.le.trans (line_map_mono_left ha h₁) (line_map_mono_right hb h₀)\n\ntheorem line_map_strict_mono_endpoints {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {a' : E} {b : E} {b' : E} {r : k} (ha : a < a') (hb : b < b') (h₀ : 0 ≤ r) (h₁ : r ≤ 1) : coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a' b') r := sorry\n\ntheorem line_map_lt_line_map_iff_of_lt {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} {r' : k} (h : r < r') : coe_fn (affine_map.line_map a b) r < coe_fn (affine_map.line_map a b) r' ↔ a < b := sorry\n\ntheorem left_lt_line_map_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : 0 < r) : a < coe_fn (affine_map.line_map a b) r ↔ a < b := sorry\n\ntheorem line_map_lt_left_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : 0 < r) : coe_fn (affine_map.line_map a b) r < a ↔ b < a :=\n  left_lt_line_map_iff_lt h\n\ntheorem line_map_lt_right_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : r < 1) : coe_fn (affine_map.line_map a b) r < b ↔ a < b := sorry\n\ntheorem right_lt_line_map_iff_lt {k : Type u_1} {E : Type u_2} [ordered_ring k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : r < 1) : b < coe_fn (affine_map.line_map a b) r ↔ b < a :=\n  line_map_lt_right_iff_lt h\n\ntheorem line_map_le_line_map_iff_of_lt {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} {r' : k} (h : r < r') : coe_fn (affine_map.line_map a b) r ≤ coe_fn (affine_map.line_map a b) r' ↔ a ≤ b := sorry\n\ntheorem left_le_line_map_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : 0 < r) : a ≤ coe_fn (affine_map.line_map a b) r ↔ a ≤ b := sorry\n\n@[simp] theorem left_le_midpoint {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} : a ≤ midpoint k a b ↔ a ≤ b :=\n  left_le_line_map_iff_le (iff.mpr inv_pos zero_lt_two)\n\ntheorem line_map_le_left_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : 0 < r) : coe_fn (affine_map.line_map a b) r ≤ a ↔ b ≤ a :=\n  left_le_line_map_iff_le h\n\n@[simp] theorem midpoint_le_left {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} : midpoint k a b ≤ a ↔ b ≤ a :=\n  line_map_le_left_iff_le (iff.mpr inv_pos zero_lt_two)\n\ntheorem line_map_le_right_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : r < 1) : coe_fn (affine_map.line_map a b) r ≤ b ↔ a ≤ b := sorry\n\n@[simp] theorem midpoint_le_right {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} : midpoint k a b ≤ b ↔ a ≤ b :=\n  line_map_le_right_iff_le (inv_lt_one one_lt_two)\n\ntheorem right_le_line_map_iff_le {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} {r : k} (h : r < 1) : b ≤ coe_fn (affine_map.line_map a b) r ↔ b ≤ a :=\n  line_map_le_right_iff_le h\n\n@[simp] theorem right_le_midpoint {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {a : E} {b : E} : b ≤ midpoint k a b ↔ b ≤ a :=\n  right_le_line_map_iff_le (inv_lt_one one_lt_two)\n\n/-!\n### Convexity and slope\n\nGiven an interval `[a, b]` and a point `c ∈ (a, b)`, `c = line_map a b r`, there are a few ways to\nsay that the point `(c, f c)` is above/below the segment `[(a, f a), (b, f b)]`:\n\n* compare `f c` to `line_map (f a) (f b) r`;\n* compare `slope f a c` to `slope `f a b`;\n* compare `slope f c b` to `slope f a b`;\n* compare `slope f a c` to `slope f c b`.\n\nIn this section we prove equivalence of these four approaches. In order to make the statements more\nreadable, we introduce local notation `c = line_map a b r`. Then we prove lemmas like\n\n```\nlemma map_le_line_map_iff_slope_le_slope_left (h : 0 < r * (b - a)) :\n  f c ≤ line_map (f a) (f b) r ↔ slope f a c ≤ slope f a b :=\n```\n\nFor each inequality between `f c` and `line_map (f a) (f b) r` we provide 3 lemmas:\n\n* `*_left` relates it to an inequality on `slope f a c` and `slope f a b`;\n* `*_right` relates it to an inequality on `slope f a b` and `slope f c b`;\n* no-suffix version relates it to an inequality on `slope f a c` and `slope f c b`.\n\nLater these inequalities will be used in to restate `convex_on` in terms of monotonicity of the\nslope.\n-/\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is non-strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c ≤ slope f a b`. -/\ntheorem map_le_line_map_iff_slope_le_slope_left {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) : f (coe_fn (affine_map.line_map a b) r) ≤ coe_fn (affine_map.line_map (f a) (f b)) r ↔\n  slope f a (coe_fn (affine_map.line_map a b) r) ≤ slope f a b := sorry\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is non-strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b ≤ slope f a c`. -/\ntheorem line_map_le_map_iff_slope_le_slope_left {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) : coe_fn (affine_map.line_map (f a) (f b)) r ≤ f (coe_fn (affine_map.line_map a b) r) ↔\n  slope f a b ≤ slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_le_line_map_iff_slope_le_slope_left h\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c < slope f a b`. -/\ntheorem map_lt_line_map_iff_slope_lt_slope_left {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) : f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r ↔\n  slope f a (coe_fn (affine_map.line_map a b) r) < slope f a b :=\n  lt_iff_lt_of_le_iff_le' (line_map_le_map_iff_slope_le_slope_left h) (map_le_line_map_iff_slope_le_slope_left h)\n\n/-- Given `c = line_map a b r`, `a < c`, the point `(c, f c)` is strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b < slope f a c`. -/\ntheorem line_map_lt_map_iff_slope_lt_slope_left {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) : coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) ↔\n  slope f a b < slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_lt_line_map_iff_slope_lt_slope_left h\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is non-strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b ≤ slope f c b`. -/\ntheorem map_le_line_map_iff_slope_le_slope_right {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) : f (coe_fn (affine_map.line_map a b) r) ≤ coe_fn (affine_map.line_map (f a) (f b)) r ↔\n  slope f a b ≤ slope f (coe_fn (affine_map.line_map a b) r) b := sorry\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is non-strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b ≤ slope f a b`. -/\ntheorem line_map_le_map_iff_slope_le_slope_right {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) : coe_fn (affine_map.line_map (f a) (f b)) r ≤ f (coe_fn (affine_map.line_map a b) r) ↔\n  slope f (coe_fn (affine_map.line_map a b) r) b ≤ slope f a b :=\n  map_le_line_map_iff_slope_le_slope_right h\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a b < slope f c b`. -/\ntheorem map_lt_line_map_iff_slope_lt_slope_right {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) : f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r ↔\n  slope f a b < slope f (coe_fn (affine_map.line_map a b) r) b :=\n  lt_iff_lt_of_le_iff_le' (line_map_le_map_iff_slope_le_slope_right h) (map_le_line_map_iff_slope_le_slope_right h)\n\n/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b < slope f a b`. -/\ntheorem line_map_lt_map_iff_slope_lt_slope_right {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) : coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) ↔\n  slope f (coe_fn (affine_map.line_map a b) r) b < slope f a b :=\n  map_lt_line_map_iff_slope_lt_slope_right h\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is non-strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c ≤ slope f c b`. -/\ntheorem map_le_line_map_iff_slope_le_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) : f (coe_fn (affine_map.line_map a b) r) ≤ coe_fn (affine_map.line_map (f a) (f b)) r ↔\n  slope f a (coe_fn (affine_map.line_map a b) r) ≤ slope f (coe_fn (affine_map.line_map a b) r) b := sorry\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is non-strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b ≤ slope f a c`. -/\ntheorem line_map_le_map_iff_slope_le_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) : coe_fn (affine_map.line_map (f a) (f b)) r ≤ f (coe_fn (affine_map.line_map a b) r) ↔\n  slope f (coe_fn (affine_map.line_map a b) r) b ≤ slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_le_line_map_iff_slope_le_slope hab h₀ h₁\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is strictly below the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f a c < slope f c b`. -/\ntheorem map_lt_line_map_iff_slope_lt_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) : f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r ↔\n  slope f a (coe_fn (affine_map.line_map a b) r) < slope f (coe_fn (affine_map.line_map a b) r) b :=\n  lt_iff_lt_of_le_iff_le' (line_map_le_map_iff_slope_le_slope hab h₀ h₁) (map_le_line_map_iff_slope_le_slope hab h₀ h₁)\n\n/-- Given `c = line_map a b r`, `a < c < b`, the point `(c, f c)` is strictly above the\nsegment `[(a, f a), (b, f b)]` if and only if `slope f c b < slope f a c`. -/\ntheorem line_map_lt_map_iff_slope_lt_slope {k : Type u_1} {E : Type u_2} [linear_ordered_field k] [ordered_add_comm_group E] [semimodule k E] [ordered_semimodule k E] {f : k → E} {a : k} {b : k} {r : k} (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) : coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) ↔\n  slope f (coe_fn (affine_map.line_map a b) r) b < slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_lt_line_map_iff_slope_lt_slope hab h₀ h₁\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/affine_space/ordered.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4680283336946894}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov, Eric Wieser\n-/\nimport linear_algebra.span\nimport order.partial_sups\nimport algebra.algebra.prod\n\n/-! ### Products of modules\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines constructors for linear maps whose domains or codomains are products.\n\nIt contains theorems relating these to each other, as well as to `submodule.prod`, `submodule.map`,\n`submodule.comap`, `linear_map.range`, and `linear_map.ker`.\n\n## Main definitions\n\n- products in the domain:\n  - `linear_map.fst`\n  - `linear_map.snd`\n  - `linear_map.coprod`\n  - `linear_map.prod_ext`\n- products in the codomain:\n  - `linear_map.inl`\n  - `linear_map.inr`\n  - `linear_map.prod`\n- products in both domain and codomain:\n  - `linear_map.prod_map`\n  - `linear_equiv.prod_map`\n  - `linear_equiv.skew_prod`\n-/\n\nuniverses u v w x y z u' v' w' y'\nvariables {R : Type u} {K : Type u'} {M : Type v} {V : Type v'} {M₂ : Type w} {V₂ : Type w'}\nvariables {M₃ : Type y} {V₃ : Type y'} {M₄ : Type z} {ι : Type x}\nvariables {M₅ M₆ : Type*}\n\nsection prod\n\nnamespace linear_map\n\nvariables (S : Type*) [semiring R] [semiring S]\nvariables [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\nvariables [add_comm_monoid M₅] [add_comm_monoid M₆]\nvariables [module R M] [module R M₂] [module R M₃] [module R M₄]\nvariables [module R M₅] [module R M₆]\nvariables (f : M →ₗ[R] M₂)\n\nsection\nvariables (R M M₂)\n\n/-- The first projection of a product is a linear map. -/\ndef fst : M × M₂ →ₗ[R] M := { to_fun := prod.fst, map_add' := λ x y, rfl, map_smul' := λ x y, rfl }\n\n/-- The second projection of a product is a linear map. -/\ndef snd : M × M₂ →ₗ[R] M₂ := { to_fun := prod.snd, map_add' := λ x y, rfl, map_smul' := λ x y, rfl }\nend\n\n@[simp] theorem fst_apply (x : M × M₂) : fst R M M₂ x = x.1 := rfl\n@[simp] theorem snd_apply (x : M × M₂) : snd R M M₂ x = x.2 := rfl\n\ntheorem fst_surjective : function.surjective (fst R M M₂) := λ x, ⟨(x, 0), rfl⟩\ntheorem snd_surjective : function.surjective (snd R M M₂) := λ x, ⟨(0, x), rfl⟩\n\n/-- The prod of two linear maps is a linear map. -/\n@[simps] def prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : (M →ₗ[R] M₂ × M₃) :=\n{ to_fun    := pi.prod f g,\n  map_add'  := λ x y, by simp only [pi.prod, prod.mk_add_mk, map_add],\n  map_smul' := λ c x, by simp only [pi.prod, prod.smul_mk, map_smul, ring_hom.id_apply] }\n\nlemma coe_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : ⇑(f.prod g) = pi.prod f g := rfl\n\n@[simp] theorem fst_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  (fst R M₂ M₃).comp (prod f g) = f := by ext; refl\n\n@[simp] theorem snd_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  (snd R M₂ M₃).comp (prod f g) = g := by ext; refl\n\n@[simp] theorem pair_fst_snd : prod (fst R M M₂) (snd R M M₂) = linear_map.id :=\nfun_like.coe_injective pi.prod_fst_snd\n\n/-- Taking the product of two maps with the same domain is equivalent to taking the product of\ntheir codomains.\n\nSee note [bundled maps over different rings] for why separate `R` and `S` semirings are used. -/\n@[simps] def prod_equiv\n  [module S M₂] [module S M₃] [smul_comm_class R S M₂] [smul_comm_class R S M₃] :\n  ((M →ₗ[R] M₂) × (M →ₗ[R] M₃)) ≃ₗ[S] (M →ₗ[R] M₂ × M₃) :=\n{ to_fun := λ f, f.1.prod f.2,\n  inv_fun := λ f, ((fst _ _ _).comp f, (snd _ _ _).comp f),\n  left_inv := λ f, by ext; refl,\n  right_inv := λ f, by ext; refl,\n  map_add' := λ a b, rfl,\n  map_smul' := λ r a, rfl }\n\nsection\nvariables (R M M₂)\n\n/-- The left injection into a product is a linear map. -/\ndef inl : M →ₗ[R] M × M₂ := prod linear_map.id 0\n\n/-- The right injection into a product is a linear map. -/\ndef inr : M₂ →ₗ[R] M × M₂ := prod 0 linear_map.id\n\ntheorem range_inl : range (inl R M M₂) = ker (snd R M M₂) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros ⟨y, rfl⟩, refl },\n  { intro h, exact ⟨x.fst, prod.ext rfl h.symm⟩ }\nend\n\ntheorem ker_snd : ker (snd R M M₂) = range (inl R M M₂) :=\neq.symm $ range_inl R M M₂\n\ntheorem range_inr : range (inr R M M₂) = ker (fst R M M₂) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros ⟨y, rfl⟩, refl },\n  { intro h, exact ⟨x.snd, prod.ext h.symm rfl⟩ }\nend\n\ntheorem ker_fst : ker (fst R M M₂) = range (inr R M M₂) :=\neq.symm $ range_inr R M M₂\n\nend\n\n@[simp] theorem coe_inl : (inl R M M₂ : M → M × M₂) = λ x, (x, 0) := rfl\ntheorem inl_apply (x : M) : inl R M M₂ x = (x, 0) := rfl\n\n@[simp] theorem coe_inr : (inr R M M₂ : M₂ → M × M₂) = prod.mk 0 := rfl\ntheorem inr_apply (x : M₂) : inr R M M₂ x = (0, x) := rfl\n\ntheorem inl_eq_prod : inl R M M₂ = prod linear_map.id 0 := rfl\n\ntheorem inr_eq_prod : inr R M M₂ = prod 0 linear_map.id := rfl\n\ntheorem inl_injective : function.injective (inl R M M₂) :=\nλ _, by simp\n\n\n\n/-- The coprod function `λ x : M × M₂, f x.1 + g x.2` is a linear map. -/\ndef coprod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) : M × M₂ →ₗ[R] M₃ :=\nf.comp (fst _ _ _) + g.comp (snd _ _ _)\n\n@[simp] theorem coprod_apply (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) (x : M × M₂) :\n  coprod f g x = f x.1 + g x.2 := rfl\n\n@[simp] theorem coprod_inl (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (coprod f g).comp (inl R M M₂) = f :=\nby ext; simp only [map_zero, add_zero, coprod_apply, inl_apply, comp_apply]\n\n@[simp] theorem coprod_inr (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (coprod f g).comp (inr R M M₂) = g :=\nby ext; simp only [map_zero, coprod_apply, inr_apply, zero_add, comp_apply]\n\n@[simp] theorem coprod_inl_inr : coprod (inl R M M₂) (inr R M M₂) = linear_map.id :=\nby ext; simp only [prod.mk_add_mk, add_zero, id_apply, coprod_apply,\n  inl_apply, inr_apply, zero_add]\n\ntheorem comp_coprod (f : M₃ →ₗ[R] M₄) (g₁ : M →ₗ[R] M₃) (g₂ : M₂ →ₗ[R] M₃) :\n  f.comp (g₁.coprod g₂) = (f.comp g₁).coprod (f.comp g₂) :=\next $ λ x, f.map_add (g₁ x.1) (g₂ x.2)\n\ntheorem fst_eq_coprod : fst R M M₂ = coprod linear_map.id 0 := by ext; simp\n\ntheorem snd_eq_coprod : snd R M M₂ = coprod 0 linear_map.id := by ext; simp\n\n@[simp] theorem coprod_comp_prod (f : M₂ →ₗ[R] M₄) (g : M₃ →ₗ[R] M₄)\n  (f' : M →ₗ[R] M₂) (g' : M →ₗ[R] M₃) :\n  (f.coprod g).comp (f'.prod g') = f.comp f' + g.comp g' :=\nrfl\n\n@[simp]\nlemma coprod_map_prod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) (S : submodule R M)\n  (S' : submodule R M₂) :\n  (submodule.prod S S').map (linear_map.coprod f g) = S.map f ⊔ S'.map g :=\nset_like.coe_injective $ begin\n  simp only [linear_map.coprod_apply, submodule.coe_sup, submodule.map_coe],\n  rw [←set.image2_add, set.image2_image_left, set.image2_image_right],\n  exact set.image_prod (λ m m₂, f m + g m₂),\nend\n\n/-- Taking the product of two maps with the same codomain is equivalent to taking the product of\ntheir domains.\n\nSee note [bundled maps over different rings] for why separate `R` and `S` semirings are used. -/\n@[simps] def coprod_equiv [module S M₃] [smul_comm_class R S M₃] :\n  ((M →ₗ[R] M₃) × (M₂ →ₗ[R] M₃)) ≃ₗ[S] (M × M₂ →ₗ[R] M₃) :=\n{ to_fun := λ f, f.1.coprod f.2,\n  inv_fun := λ f, (f.comp (inl _ _ _), f.comp (inr _ _ _)),\n  left_inv := λ f, by simp only [prod.mk.eta, coprod_inl, coprod_inr],\n  right_inv := λ f, by simp only [←comp_coprod, comp_id, coprod_inl_inr],\n  map_add' := λ a b,\n    by { ext, simp only [prod.snd_add, add_apply, coprod_apply, prod.fst_add, add_add_add_comm] },\n  map_smul' := λ r a,\n    by { dsimp, ext, simp only [smul_add, smul_apply, prod.smul_snd, prod.smul_fst,\n                                coprod_apply] } }\n\ntheorem prod_ext_iff {f g : M × M₂ →ₗ[R] M₃} :\n  f = g ↔ f.comp (inl _ _ _) = g.comp (inl _ _ _) ∧ f.comp (inr _ _ _) = g.comp (inr _ _ _) :=\n(coprod_equiv ℕ).symm.injective.eq_iff.symm.trans prod.ext_iff\n\n/--\nSplit equality of linear maps from a product into linear maps over each component, to allow `ext`\nto apply lemmas specific to `M →ₗ M₃` and `M₂ →ₗ M₃`.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext] theorem prod_ext {f g : M × M₂ →ₗ[R] M₃}\n  (hl : f.comp (inl _ _ _) = g.comp (inl _ _ _))\n  (hr : f.comp (inr _ _ _) = g.comp (inr _ _ _)) :\n  f = g :=\nprod_ext_iff.2 ⟨hl, hr⟩\n\n/-- `prod.map` of two linear maps. -/\ndef prod_map (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) : (M × M₂) →ₗ[R] (M₃ × M₄) :=\n(f.comp (fst R M M₂)).prod (g.comp (snd R M M₂))\n\nlemma coe_prod_map (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) :\n  ⇑(f.prod_map g) = prod.map f g := rfl\n  \n@[simp] theorem prod_map_apply (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) (x) :\n  f.prod_map g x = (f x.1, g x.2) := rfl\n\nlemma prod_map_comap_prod (f : M →ₗ[R] M₂) (g : M₃ →ₗ[R] M₄) (S : submodule R M₂)\n  (S' : submodule R M₄) :\n  (submodule.prod S S').comap (linear_map.prod_map f g) = (S.comap f).prod (S'.comap g) :=\nset_like.coe_injective $ set.preimage_prod_map_prod f g _ _\n\nlemma ker_prod_map (f : M →ₗ[R] M₂) (g : M₃ →ₗ[R] M₄) :\n  (linear_map.prod_map f g).ker = submodule.prod f.ker g.ker :=\nbegin\n  dsimp only [ker],\n  rw [←prod_map_comap_prod, submodule.prod_bot],\nend\n\n@[simp]\nlemma prod_map_id : (id : M →ₗ[R] M).prod_map (id : M₂ →ₗ[R] M₂) = id :=\nlinear_map.ext $ λ _, prod.mk.eta\n\n@[simp]\nlemma prod_map_one : (1 : M →ₗ[R] M).prod_map (1 : M₂ →ₗ[R] M₂) = 1 :=\nlinear_map.ext $ λ _, prod.mk.eta\n\nlemma prod_map_comp (f₁₂ : M →ₗ[R] M₂) (f₂₃ : M₂ →ₗ[R] M₃) (g₁₂ : M₄ →ₗ[R] M₅) (g₂₃ : M₅ →ₗ[R] M₆) :\n  f₂₃.prod_map g₂₃ ∘ₗ f₁₂.prod_map g₁₂ = (f₂₃ ∘ₗ f₁₂).prod_map (g₂₃ ∘ₗ g₁₂) := rfl\n\nlemma prod_map_mul (f₁₂ : M →ₗ[R] M) (f₂₃ : M →ₗ[R] M) (g₁₂ : M₂ →ₗ[R] M₂) (g₂₃ : M₂ →ₗ[R] M₂) :\n  f₂₃.prod_map g₂₃ * f₁₂.prod_map g₁₂ = (f₂₃ * f₁₂).prod_map (g₂₃ * g₁₂) := rfl\n\nlemma prod_map_add (f₁ : M →ₗ[R] M₃) (f₂ : M →ₗ[R] M₃) (g₁ : M₂ →ₗ[R] M₄) (g₂ : M₂ →ₗ[R] M₄) :\n  (f₁ + f₂).prod_map (g₁ + g₂) = f₁.prod_map g₁ + f₂.prod_map g₂ := rfl\n\n@[simp] lemma prod_map_zero :\n  (0 : M →ₗ[R] M₂).prod_map (0 : M₃ →ₗ[R] M₄) = 0 := rfl\n\n@[simp] lemma prod_map_smul\n [module S M₃] [module S M₄] [smul_comm_class R S M₃] [smul_comm_class R S M₄]\n (s : S) (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₄) : prod_map (s • f) (s • g) = s • prod_map f g := rfl\n\nvariables (R M M₂ M₃ M₄)\n\n/-- `linear_map.prod_map` as a `linear_map` -/\n@[simps]\ndef prod_map_linear\n [module S M₃] [module S M₄] [smul_comm_class R S M₃] [smul_comm_class R S M₄] :\n ((M →ₗ[R] M₃) × (M₂ →ₗ[R] M₄)) →ₗ[S] ((M × M₂) →ₗ[R] (M₃ × M₄)) :=\n{ to_fun := λ f, prod_map f.1 f.2,\n  map_add' := λ _ _, rfl,\n  map_smul' := λ _ _, rfl}\n\n/-- `linear_map.prod_map` as a `ring_hom` -/\n@[simps]\ndef prod_map_ring_hom : (M →ₗ[R] M) × (M₂ →ₗ[R] M₂) →+* ((M × M₂) →ₗ[R] (M × M₂)) :=\n{ to_fun := λ f, prod_map f.1 f.2,\n  map_one' := prod_map_one,\n  map_zero' := rfl,\n  map_add' := λ _ _, rfl,\n  map_mul' := λ _ _, rfl }\n\nvariables {R M M₂ M₃ M₄}\n\nsection map_mul\n\nvariables {A : Type*} [non_unital_non_assoc_semiring A] [module R A]\nvariables {B : Type*} [non_unital_non_assoc_semiring B] [module R B]\n\nlemma inl_map_mul (a₁ a₂ : A) : linear_map.inl R A B (a₁ * a₂) =\n  linear_map.inl R A B a₁ * linear_map.inl R A B a₂ :=\nprod.ext rfl (by simp)\n\nlemma inr_map_mul (b₁ b₂ : B) : linear_map.inr R A B (b₁ * b₂) =\n  linear_map.inr R A B b₁ * linear_map.inr R A B b₂ :=\nprod.ext (by simp) rfl\n\nend map_mul\n\nend linear_map\n\nend prod\n\nnamespace linear_map\n\nvariables (R M M₂)\n\nvariables [comm_semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂]\nvariables [module R M] [module R M₂]\n\n/-- `linear_map.prod_map` as an `algebra_hom` -/\n@[simps]\ndef prod_map_alg_hom : (module.End R M) × (module.End R M₂) →ₐ[R] module.End R (M × M₂) :=\n{ commutes' := λ _, rfl, ..prod_map_ring_hom R M M₂ }\n\nend linear_map\n\nnamespace linear_map\nopen submodule\n\nvariables [semiring R]\n  [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\n  [module R M] [module R M₂] [module R M₃] [module R M₄]\n\nlemma range_coprod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (f.coprod g).range = f.range ⊔ g.range :=\nsubmodule.ext $ λ x, by simp [mem_sup]\n\nlemma is_compl_range_inl_inr : is_compl (inl R M M₂).range (inr R M M₂).range :=\nbegin\n  split,\n  { rw disjoint_def,\n    rintros ⟨_, _⟩ ⟨x, hx⟩ ⟨y, hy⟩,\n    simp only [prod.ext_iff, inl_apply, inr_apply, mem_bot] at hx hy ⊢,\n    exact ⟨hy.1.symm, hx.2.symm⟩ },\n  { rw codisjoint_iff_le_sup,\n    rintros ⟨x, y⟩ -,\n    simp only [mem_sup, mem_range, exists_prop],\n    refine ⟨(x, 0), ⟨x, rfl⟩, (0, y), ⟨y, rfl⟩, _⟩,\n    simp }\nend\n\nlemma sup_range_inl_inr : (inl R M M₂).range ⊔ (inr R M M₂).range = ⊤ :=\nis_compl.sup_eq_top is_compl_range_inl_inr\n\nlemma disjoint_inl_inr : disjoint (inl R M M₂).range (inr R M M₂).range :=\nby simp [disjoint_def, @eq_comm M 0, @eq_comm M₂ 0] {contextual := tt}; intros; refl\ntheorem map_coprod_prod (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃)\n  (p : submodule R M) (q : submodule R M₂) :\n  map (coprod f g) (p.prod q) = map f p ⊔ map g q :=\nbegin\n  refine le_antisymm _ (sup_le (map_le_iff_le_comap.2 _) (map_le_iff_le_comap.2 _)),\n  { rw set_like.le_def, rintro _ ⟨x, ⟨h₁, h₂⟩, rfl⟩,\n    exact mem_sup.2 ⟨_, ⟨_, h₁, rfl⟩, _, ⟨_, h₂, rfl⟩, rfl⟩ },\n  { exact λ x hx, ⟨(x, 0), by simp [hx]⟩ },\n  { exact λ x hx, ⟨(0, x), by simp [hx]⟩ }\nend\n\ntheorem comap_prod_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃)\n  (p : submodule R M₂) (q : submodule R M₃) :\n  comap (prod f g) (p.prod q) = comap f p ⊓ comap g q :=\nsubmodule.ext $ λ x, iff.rfl\n\ntheorem prod_eq_inf_comap (p : submodule R M) (q : submodule R M₂) :\n  p.prod q = p.comap (linear_map.fst R M M₂) ⊓ q.comap (linear_map.snd R M M₂) :=\nsubmodule.ext $ λ x, iff.rfl\n\ntheorem prod_eq_sup_map (p : submodule R M) (q : submodule R M₂) :\n  p.prod q = p.map (linear_map.inl R M M₂) ⊔ q.map (linear_map.inr R M M₂) :=\nby rw [← map_coprod_prod, coprod_inl_inr, map_id]\n\nlemma span_inl_union_inr {s : set M} {t : set M₂} :\n  span R (inl R M  M₂ '' s ∪ inr R M M₂ '' t) = (span R s).prod (span R t) :=\nby rw [span_union, prod_eq_sup_map, ← span_image, ← span_image]\n\n@[simp] lemma ker_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  ker (prod f g) = ker f ⊓ ker g :=\nby rw [ker, ← prod_bot, comap_prod_prod]; refl\n\nlemma range_prod_le (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :\n  range (prod f g) ≤ (range f).prod (range g) :=\nbegin\n  simp only [set_like.le_def, prod_apply, mem_range, set_like.mem_coe, mem_prod,\n    exists_imp_distrib],\n  rintro _ x rfl,\n  exact ⟨⟨x, rfl⟩, ⟨x, rfl⟩⟩\nend\n\nlemma ker_prod_ker_le_ker_coprod {M₂ : Type*} [add_comm_group M₂] [module R M₂]\n  {M₃ : Type*} [add_comm_group M₃] [module R M₃]\n  (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) :\n  (ker f).prod (ker g) ≤ ker (f.coprod g) :=\nby { rintros ⟨y, z⟩, simp {contextual := tt} }\n\nlemma ker_coprod_of_disjoint_range {M₂ : Type*} [add_comm_group M₂] [module R M₂]\n  {M₃ : Type*} [add_comm_group M₃] [module R M₃]\n  (f : M →ₗ[R] M₃) (g : M₂ →ₗ[R] M₃) (hd : disjoint f.range g.range) :\n  ker (f.coprod g) = (ker f).prod (ker g) :=\nbegin\n  apply le_antisymm _ (ker_prod_ker_le_ker_coprod f g),\n  rintros ⟨y, z⟩ h,\n  simp only [mem_ker, mem_prod, coprod_apply] at h ⊢,\n  have : f y ∈ f.range ⊓ g.range,\n  { simp only [true_and, mem_range, mem_inf, exists_apply_eq_apply],\n    use -z,\n    rwa [eq_comm, map_neg, ← sub_eq_zero, sub_neg_eq_add] },\n  rw [hd.eq_bot, mem_bot] at this,\n  rw [this] at h,\n  simpa [this] using h,\nend\n\nend linear_map\n\nnamespace submodule\nopen linear_map\n\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂]\nvariables [module R M] [module R M₂]\n\nlemma sup_eq_range (p q : submodule R M) : p ⊔ q = (p.subtype.coprod q.subtype).range :=\nsubmodule.ext $ λ x, by simp [submodule.mem_sup, set_like.exists]\n\nvariables (p : submodule R M) (q : submodule R M₂)\n\n@[simp] theorem map_inl : p.map (inl R M M₂) = prod p ⊥ :=\nby { ext ⟨x, y⟩, simp only [and.left_comm, eq_comm, mem_map, prod.mk.inj_iff, inl_apply, mem_bot,\n  exists_eq_left', mem_prod] }\n\n@[simp] theorem map_inr : q.map (inr R M M₂) = prod ⊥ q :=\nby ext ⟨x, y⟩; simp [and.left_comm, eq_comm]\n\n@[simp] theorem comap_fst : p.comap (fst R M M₂) = prod p ⊤ :=\nby ext ⟨x, y⟩; simp\n\n@[simp] theorem comap_snd : q.comap (snd R M M₂) = prod ⊤ q :=\nby ext ⟨x, y⟩; simp\n\n@[simp] theorem prod_comap_inl : (prod p q).comap (inl R M M₂) = p := by ext; simp\n\n@[simp] theorem prod_comap_inr : (prod p q).comap (inr R M M₂) = q := by ext; simp\n\n@[simp] theorem prod_map_fst : (prod p q).map (fst R M M₂) = p :=\nby ext x; simp [(⟨0, zero_mem _⟩ : ∃ x, x ∈ q)]\n\n@[simp] theorem prod_map_snd : (prod p q).map (snd R M M₂) = q :=\nby ext x; simp [(⟨0, zero_mem _⟩ : ∃ x, x ∈ p)]\n\n@[simp] theorem ker_inl : (inl R M M₂).ker = ⊥ :=\nby rw [ker, ← prod_bot, prod_comap_inl]\n\n@[simp] theorem ker_inr : (inr R M M₂).ker = ⊥ :=\nby rw [ker, ← prod_bot, prod_comap_inr]\n\n@[simp] theorem range_fst : (fst R M M₂).range = ⊤ :=\nby rw [range_eq_map, ← prod_top, prod_map_fst]\n\n@[simp] theorem range_snd : (snd R M M₂).range = ⊤ :=\nby rw [range_eq_map, ← prod_top, prod_map_snd]\n\nvariables (R M M₂)\n\n/-- `M` as a submodule of `M × N`. -/\ndef fst : submodule R (M × M₂) := (⊥ : submodule R M₂).comap (linear_map.snd R M M₂)\n\n/-- `M` as a submodule of `M × N` is isomorphic to `M`. -/\n@[simps] def fst_equiv : submodule.fst R M M₂ ≃ₗ[R] M :=\n{ to_fun := λ x, x.1.1,\n  inv_fun := λ m, ⟨⟨m, 0⟩, by tidy⟩,\n  map_add' := by simp,\n  map_smul' := by simp,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\nlemma fst_map_fst : (submodule.fst R M M₂).map (linear_map.fst R M M₂) = ⊤ :=\nby tidy\nlemma fst_map_snd : (submodule.fst R M M₂).map (linear_map.snd R M M₂) = ⊥ :=\nby { tidy, exact 0, }\n\n/-- `N` as a submodule of `M × N`. -/\ndef snd : submodule R (M × M₂) := (⊥ : submodule R M).comap (linear_map.fst R M M₂)\n\n/-- `N` as a submodule of `M × N` is isomorphic to `N`. -/\n@[simps] def snd_equiv : submodule.snd R M M₂ ≃ₗ[R] M₂ :=\n{ to_fun := λ x, x.1.2,\n  inv_fun := λ n, ⟨⟨0, n⟩, by tidy⟩,\n  map_add' := by simp,\n  map_smul' := by simp,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\nlemma snd_map_fst : (submodule.snd R M M₂).map (linear_map.fst R M M₂) = ⊥ :=\nby { tidy, exact 0, }\nlemma snd_map_snd : (submodule.snd R M M₂).map (linear_map.snd R M M₂) = ⊤ :=\nby tidy\n\nlemma fst_sup_snd : submodule.fst R M M₂ ⊔ submodule.snd R M M₂ = ⊤ :=\nbegin\n  rw eq_top_iff,\n  rintro ⟨m, n⟩ -,\n  rw [show (m, n) = (m, 0) + (0, n), by simp],\n  apply submodule.add_mem (submodule.fst R M M₂ ⊔ submodule.snd R M M₂),\n  { exact submodule.mem_sup_left (submodule.mem_comap.mpr (by simp)), },\n  { exact submodule.mem_sup_right (submodule.mem_comap.mpr (by simp)), },\nend\n\nlemma fst_inf_snd : submodule.fst R M M₂ ⊓ submodule.snd R M M₂ = ⊥ := by tidy\n\nlemma le_prod_iff {p₁ : submodule R M} {p₂ : submodule R M₂} {q : submodule R (M × M₂)} :\n  q ≤ p₁.prod p₂ ↔ map (linear_map.fst R M M₂) q ≤ p₁ ∧ map (linear_map.snd R M M₂) q ≤ p₂ :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros x ⟨⟨y1,y2⟩, ⟨hy1,rfl⟩⟩, exact (h hy1).1 },\n    { rintros x ⟨⟨y1,y2⟩, ⟨hy1,rfl⟩⟩, exact (h hy1).2 }, },\n  { rintros ⟨hH, hK⟩ ⟨x1, x2⟩ h, exact ⟨hH ⟨_ , h, rfl⟩, hK ⟨ _, h, rfl⟩⟩, }\nend\n\nlemma prod_le_iff {p₁ : submodule R M} {p₂ : submodule R M₂} {q : submodule R (M × M₂)} :\n  p₁.prod p₂ ≤ q ↔ map (linear_map.inl R M M₂) p₁ ≤ q ∧ map (linear_map.inr R M M₂) p₂ ≤ q :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros _ ⟨x, hx, rfl⟩, apply h, exact ⟨hx, zero_mem p₂⟩, },\n    { rintros _ ⟨x, hx, rfl⟩, apply h, exact ⟨zero_mem p₁, hx⟩, }, },\n  { rintros ⟨hH, hK⟩ ⟨x1, x2⟩ ⟨h1, h2⟩,\n    have h1' : (linear_map.inl R _ _) x1 ∈ q, { apply hH, simpa using h1, },\n    have h2' : (linear_map.inr R _ _) x2 ∈ q, { apply hK, simpa using h2, },\n    simpa using add_mem h1' h2', }\nend\n\nlemma prod_eq_bot_iff {p₁ : submodule R M} {p₂ : submodule R M₂} :\n  p₁.prod p₂ = ⊥ ↔ p₁ = ⊥ ∧ p₂ = ⊥ :=\nby simp only [eq_bot_iff, prod_le_iff, (gc_map_comap _).le_iff_le, comap_bot, ker_inl, ker_inr]\n\nlemma prod_eq_top_iff {p₁ : submodule R M} {p₂ : submodule R M₂} :\n  p₁.prod p₂ = ⊤ ↔ p₁ = ⊤ ∧ p₂ = ⊤ :=\nby simp only [eq_top_iff, le_prod_iff, ← (gc_map_comap _).le_iff_le, map_top, range_fst, range_snd]\n\nend submodule\n\nnamespace linear_equiv\n\n/-- Product of modules is commutative up to linear isomorphism. -/\n@[simps apply]\ndef prod_comm (R M N : Type*) [semiring R] [add_comm_monoid M] [add_comm_monoid N]\n  [module R M] [module R N] : (M × N) ≃ₗ[R] (N × M) :=\n{ to_fun := prod.swap,\n  map_smul' := λ r ⟨m, n⟩, rfl,\n  ..add_equiv.prod_comm }\n\nsection\n\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]\nvariables {module_M : module R M} {module_M₂ : module R M₂}\nvariables {module_M₃ : module R M₃} {module_M₄ : module R M₄}\nvariables (e₁ : M ≃ₗ[R] M₂) (e₂ : M₃ ≃ₗ[R] M₄)\n\n/-- Product of linear equivalences; the maps come from `equiv.prod_congr`. -/\nprotected def prod :\n  (M × M₃) ≃ₗ[R] (M₂ × M₄) :=\n{ map_smul' := λ c x, prod.ext (e₁.map_smulₛₗ c _) (e₂.map_smulₛₗ c _),\n  .. e₁.to_add_equiv.prod_congr e₂.to_add_equiv }\n\nlemma prod_symm : (e₁.prod e₂).symm = e₁.symm.prod e₂.symm := rfl\n\n@[simp] lemma prod_apply (p) :\n  e₁.prod e₂ p = (e₁ p.1, e₂ p.2) := rfl\n\n@[simp, norm_cast] lemma coe_prod :\n  (e₁.prod e₂ : (M × M₃) →ₗ[R] (M₂ × M₄)) = (e₁ : M →ₗ[R] M₂).prod_map (e₂ : M₃ →ₗ[R] M₄) := rfl\n\nend\n\nsection\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_group M₄]\nvariables {module_M : module R M} {module_M₂ : module R M₂}\nvariables {module_M₃ : module R M₃} {module_M₄ : module R M₄}\nvariables (e₁ : M ≃ₗ[R] M₂) (e₂ : M₃ ≃ₗ[R] M₄)\n\n/-- Equivalence given by a block lower diagonal matrix. `e₁` and `e₂` are diagonal square blocks,\n  and `f` is a rectangular block below the diagonal. -/\nprotected def skew_prod (f : M →ₗ[R] M₄) :\n  (M × M₃) ≃ₗ[R] M₂ × M₄ :=\n{ inv_fun := λ p : M₂ × M₄, (e₁.symm p.1, e₂.symm (p.2 - f (e₁.symm p.1))),\n  left_inv := λ p, by simp,\n  right_inv := λ p, by simp,\n  .. ((e₁ : M →ₗ[R] M₂).comp (linear_map.fst R M M₃)).prod\n    ((e₂ : M₃ →ₗ[R] M₄).comp (linear_map.snd R M M₃) +\n      f.comp (linear_map.fst R M M₃)) }\n\n@[simp] lemma skew_prod_apply (f : M →ₗ[R] M₄) (x) :\n  e₁.skew_prod e₂ f x = (e₁ x.1, e₂ x.2 + f x.1) := rfl\n\n@[simp] lemma skew_prod_symm_apply (f : M →ₗ[R] M₄) (x) :\n  (e₁.skew_prod e₂ f).symm x = (e₁.symm x.1, e₂.symm (x.2 - f (e₁.symm x.1))) := rfl\n\nend\nend linear_equiv\n\nnamespace linear_map\nopen submodule\n\nvariables [ring R]\nvariables [add_comm_group M] [add_comm_group M₂] [add_comm_group M₃]\nvariables [module R M] [module R M₂] [module R M₃]\n\n/-- If the union of the kernels `ker f` and `ker g` spans the domain, then the range of\n`prod f g` is equal to the product of `range f` and `range g`. -/\nlemma range_prod_eq {f : M →ₗ[R] M₂} {g : M →ₗ[R] M₃} (h : ker f ⊔ ker g = ⊤) :\n  range (prod f g) = (range f).prod (range g) :=\nbegin\n  refine le_antisymm (f.range_prod_le g) _,\n  simp only [set_like.le_def, prod_apply, mem_range, set_like.mem_coe, mem_prod, exists_imp_distrib,\n    and_imp, prod.forall, pi.prod],\n  rintros _ _ x rfl y rfl,\n  simp only [prod.mk.inj_iff, ← sub_mem_ker_iff],\n  have : y - x ∈ ker f ⊔ ker g, { simp only [h, mem_top] },\n  rcases mem_sup.1 this with ⟨x', hx', y', hy', H⟩,\n  refine ⟨x' + x, _, _⟩,\n  { simp only [mem_ker.mp hx', map_add, zero_add]},\n  { simp [←eq_sub_iff_add_eq.1 H, map_add, add_left_inj, self_eq_add_right, mem_ker.mp hy'] }\nend\n\nend linear_map\n\nnamespace linear_map\n/-!\n## Tunnels and tailings\n\nSome preliminary work for establishing the strong rank condition for noetherian rings.\n\nGiven a morphism `f : M × N →ₗ[R] M` which is `i : injective f`,\nwe can find an infinite decreasing `tunnel f i n` of copies of `M` inside `M`,\nand sitting beside these, an infinite sequence of copies of `N`.\n\nWe picturesquely name these as `tailing f i n` for each individual copy of `N`,\nand `tailings f i n` for the supremum of the first `n+1` copies:\nthey are the pieces left behind, sitting inside the tunnel.\n\nBy construction, each `tailing f i (n+1)` is disjoint from `tailings f i n`;\nlater, when we assume `M` is noetherian, this implies that `N` must be trivial,\nand establishes the strong rank condition for any left-noetherian ring.\n-/\nsection tunnel\n\n-- (This doesn't work over a semiring: we need to use that `submodule R M` is a modular lattice,\n-- which requires cancellation.)\nvariables [ring R]\nvariables {N : Type*} [add_comm_group M] [module R M] [add_comm_group N] [module R N]\n\nopen function\n\n/-- An auxiliary construction for `tunnel`.\nThe composition of `f`, followed by the isomorphism back to `K`,\nfollowed by the inclusion of this submodule back into `M`. -/\ndef tunnel_aux (f : M × N →ₗ[R] M) (Kφ : Σ K : submodule R M, K ≃ₗ[R] M) :\n  M × N →ₗ[R] M :=\n(Kφ.1.subtype.comp Kφ.2.symm.to_linear_map).comp f\n\nlemma tunnel_aux_injective\n  (f : M × N →ₗ[R] M) (i : injective f) (Kφ : Σ K : submodule R M, K ≃ₗ[R] M) :\n  injective (tunnel_aux f Kφ) :=\n(subtype.val_injective.comp Kφ.2.symm.injective).comp i\n\nnoncomputable theory\n\n/-- Auxiliary definition for `tunnel`. -/\n-- Even though we have `noncomputable theory`,\n-- we get an error without another `noncomputable` here.\nnoncomputable def tunnel' (f : M × N →ₗ[R] M) (i : injective f) :\n  ℕ → Σ (K : submodule R M), K ≃ₗ[R] M\n| 0 := ⟨⊤, linear_equiv.of_top ⊤ rfl⟩\n| (n+1) :=\n⟨(submodule.fst R M N).map (tunnel_aux f (tunnel' n)),\n  ((submodule.fst R M N).equiv_map_of_injective _ (tunnel_aux_injective f i (tunnel' n))).symm.trans\n    (submodule.fst_equiv R M N)⟩\n\n/--\nGive an injective map `f : M × N →ₗ[R] M` we can find a nested sequence of submodules\nall isomorphic to `M`.\n-/\ndef tunnel (f : M × N →ₗ[R] M) (i : injective f) : ℕ →o (submodule R M)ᵒᵈ :=\n⟨λ n, order_dual.to_dual (tunnel' f i n).1, monotone_nat_of_le_succ (λ n, begin\n    dsimp [tunnel', tunnel_aux],\n    rw [submodule.map_comp, submodule.map_comp],\n    apply submodule.map_subtype_le,\n  end)⟩\n\n/--\nGive an injective map `f : M × N →ₗ[R] M` we can find a sequence of submodules\nall isomorphic to `N`.\n-/\ndef tailing (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) : submodule R M :=\n(submodule.snd R M N).map (tunnel_aux f (tunnel' f i n))\n\n/-- Each `tailing f i n` is a copy of `N`. -/\ndef tailing_linear_equiv (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) : tailing f i n ≃ₗ[R] N :=\n((submodule.snd R M N).equiv_map_of_injective _\n  (tunnel_aux_injective f i (tunnel' f i n))).symm.trans (submodule.snd_equiv R M N)\n\nlemma tailing_le_tunnel (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  tailing f i n ≤ (tunnel f i n).of_dual :=\nbegin\n  dsimp [tailing, tunnel_aux],\n  rw [submodule.map_comp, submodule.map_comp],\n  apply submodule.map_subtype_le,\nend\n\nlemma tailing_disjoint_tunnel_succ (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  disjoint (tailing f i n) (tunnel f i (n+1)).of_dual :=\nbegin\n  rw disjoint_iff,\n  dsimp [tailing, tunnel, tunnel'],\n  rw [submodule.map_inf_eq_map_inf_comap,\n    submodule.comap_map_eq_of_injective (tunnel_aux_injective _ i _), inf_comm,\n    submodule.fst_inf_snd, submodule.map_bot],\nend\n\nlemma tailing_sup_tunnel_succ_le_tunnel (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  tailing f i n ⊔ (tunnel f i (n+1)).of_dual ≤ (tunnel f i n).of_dual :=\nbegin\n  dsimp [tailing, tunnel, tunnel', tunnel_aux],\n  rw [←submodule.map_sup, sup_comm, submodule.fst_sup_snd, submodule.map_comp, submodule.map_comp],\n  apply submodule.map_subtype_le,\nend\n\n/-- The supremum of all the copies of `N` found inside the tunnel. -/\ndef tailings (f : M × N →ₗ[R] M) (i : injective f) : ℕ → submodule R M :=\npartial_sups (tailing f i)\n\n@[simp] lemma tailings_zero (f : M × N →ₗ[R] M) (i : injective f) :\n  tailings f i 0 = tailing f i 0 :=\nby simp [tailings]\n\n@[simp] lemma tailings_succ (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  tailings f i (n+1) = tailings f i n ⊔ tailing f i (n+1) :=\nby simp [tailings]\n\nlemma tailings_disjoint_tunnel (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  disjoint (tailings f i n) (tunnel f i (n+1)).of_dual :=\nbegin\n  induction n with n ih,\n  { simp only [tailings_zero],\n    apply tailing_disjoint_tunnel_succ, },\n  { simp only [tailings_succ],\n    refine disjoint.disjoint_sup_left_of_disjoint_sup_right _ _,\n    apply tailing_disjoint_tunnel_succ,\n    apply disjoint.mono_right _ ih,\n    apply tailing_sup_tunnel_succ_le_tunnel, },\nend\n\nlemma tailings_disjoint_tailing (f : M × N →ₗ[R] M) (i : injective f) (n : ℕ) :\n  disjoint (tailings f i n) (tailing f i (n+1)) :=\ndisjoint.mono_right (tailing_le_tunnel f i _) (tailings_disjoint_tunnel f i _)\n\nend tunnel\n\nsection graph\n\nvariables [semiring R] [add_comm_monoid M] [add_comm_monoid M₂]\n  [add_comm_group M₃] [add_comm_group M₄] [module R M] [module R M₂]\n  [module R M₃] [module R M₄] (f : M →ₗ[R] M₂) (g : M₃ →ₗ[R] M₄)\n\n/-- Graph of a linear map. -/\ndef graph : submodule R (M × M₂) :=\n{ carrier := {p | p.2 = f p.1},\n  add_mem' := λ a b (ha : _ = _) (hb : _ = _),\n  begin\n    change _ + _ = f (_ + _),\n    rw [map_add, ha, hb]\n  end,\n  zero_mem' := eq.symm (map_zero f),\n  smul_mem' := λ c x (hx : _ = _),\n  begin\n    change _ • _ = f (_ • _),\n    rw [map_smul, hx]\n  end }\n\n@[simp] lemma mem_graph_iff (x : M × M₂) : x ∈ f.graph ↔ x.2 = f x.1 := iff.rfl\n\nlemma graph_eq_ker_coprod : g.graph = ((-g).coprod linear_map.id).ker :=\nbegin\n  ext x,\n  change _ = _ ↔ -(g x.1) + x.2 = _,\n  rw [add_comm, add_neg_eq_zero]\nend\n\nlemma graph_eq_range_prod : f.graph = (linear_map.id.prod f).range :=\nbegin\n  ext x,\n  exact ⟨λ hx, ⟨x.1, prod.ext rfl hx.symm⟩, λ ⟨u, hu⟩, hu ▸ rfl⟩\nend\n\nend graph\n\nend linear_map\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/linear_algebra/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.467914843227711}}
{"text": "import Mathlib.Tactic.NormNum\nimport Mathlib.Tactic.Linarith\nimport Mathlib.Data.Nat.Basic\nimport Mathlib.Data.Int.Basic\n\nnamespace LC\n\n-- pure simply typed lambda calculus\nstructure Tensor1d (α : Type) where\n  size : Nat\n  val :  Nat → α\n\ndef Tensor1d.empty [Inhabited α] : Tensor1d α where\n  size := 0\n  val := fun _ => default\n\ndef Tensor1d.extract (t: Tensor1d α) (l: Nat) (len: Nat) : Tensor1d α where\n  size := len\n  val := fun ix => t.val (l + ix)\n\ndef Tensor1d.map (f : α → α) (t : Tensor1d α) : Tensor1d α where\n  size := t.size\n  val := fun ix => f (t.val ix)\n\ndef Tensor1d.fill (t: Tensor1d α) (v: α) : Tensor1d α where\n  size := t.size\n  val := fun _ix => v\n\n-- insert a slice into a tensor.\ndef Tensor1d.insertslice (t: Tensor1d α) (ix: Nat) (slice : Tensor1d α) : Tensor1d α where\n  size := t.size + slice.size\n  val := fun i =>\n    if i < ix then t.val i\n    else if i < ix + slice.size then slice.val (i - ix)\n    else t.val (i - slice.size)\n\n\n-- | TODO: implement fold\ndef Tensor1d.fold_rec (n: Nat) (arr: Nat → α) (f: β → α → β) (seed: β): β :=\n  match n with\n  | 0 => seed\n  | n + 1 => f (Tensor1d.fold_rec n arr f seed) (arr n)\n\ndef Tensor1d.fold (f : β → α → β)  (seed : β) (t : Tensor1d α) : β :=\n  Tensor1d.fold_rec t.size t.val f seed\n\nstructure Tensor2d (α : Type) where\n  size : Nat × Nat\n  val :  Nat × Nat → α\n\ndef Tensor2d.transpose (t: Tensor2d α) : Tensor2d α where\n  size := (t.size.2, t.size.1)\n  val := fun ix => t.val (ix.2, ix.1)\n\n\n-- theorem 1: extract (map) = map extract\n\ntheorem Tensor1d.extract_map (t: Tensor1d α):\n  (t.extract left len).map f = (t.map f).extract left len := by {\n    simp[Tensor1d.extract, Tensor1d.map]\n}\n\n-- theorem 2: extract (fill v) = fill (extract v)\n\ntheorem Tensor1d.extract_fill (t: Tensor1d α):\n  (t.extract left len).fill v = (t.fill v).extract left len := by {\n    simp[Tensor1d.extract, Tensor1d.fill]\n}\n\n-- theorem 3 : map fusion -- map (f ∘ g) = map f ∘ map g\ntheorem Tensor1d.map_fusion (t: Tensor1d α):\n  (t.map (g ∘ f)) = (t.map f).map g := by {\n    simp[Tensor1d.map]\n}\n\n-- for loop\ndef scf.for.loop (f : Nat → β → β) (n n_minus_i: Nat) (acc: β) : β :=\n  let i := n - n_minus_i\n  match n_minus_i with\n    | 0 => acc\n    | n_minus_i' + 1 =>\n      scf.for.loop f n n_minus_i' (f i acc)\n\ndef scf.for (n: Nat) (f: Nat → β → β) (seed: β) : β :=\n  let i := 0\n  scf.for.loop f n (n - i) seed\n\n-- theorem 1 : for peeling at beginning\ntheorem scf.for.peel_begin (n : Nat) (f : Nat → β → β) (seed : β) :\n  scf.for.loop f (n + 1) n (f 0 seed) = scf.for.loop f (n + 1) (n + 1) seed := by {\n    simp[scf.for.loop]\n  }\n\n-- theorem 2 : for peeling at ending\ntheorem scf.for.peel_end (n : Nat) (f : Nat → β → β) (seed : β) :\n  scf.for.loop f (n + 1) 0 (f n seed) = f n (scf.for.loop f n 0 seed) := by {\n    simp[scf.for.loop]\n  }\n\n\n-- theorem 3: for fusion: if computations commute, then they can be fused.\n-- TODO:\ntheorem scf.for.fusion (n : Nat) (f g : Nat → β → β)  (seed : β)\n  (COMMUTE : ∀ (ix : ℕ)  (v : β),  f ix (g ix v) = g ix (f ix v)) :\n  scf.for.loop f n n (scf.for.loop g n n seed) =\n  scf.for.loop (fun i acc => f i (g i acc)) n n seed := by {\n    induction n;\n    case zero => {\n      simp[loop];\n    }\n    case succ n' IH => {\n      simp[loop];\n      sorry\n    }\n  }\n\ntheorem scf.for.zero_n (f: Nat → β → β) (seed : β) :\n  scf.for 0 f seed = seed := by {\n    simp[scf.for, loop]\n  }\n\n  def scf.for.one_n (f: Nat → β → β) (seed : β) :\n  scf.for 1 f seed = f 0 seed := by {\n    simp[scf.for, loop]\n  }\n\n-- theorem 3 : arbitrary for peeling\ntheorem scf.for.peel_add (n m : Nat) (f : Nat → β → β) (seed : β)  :\n  scf.for.loop f (n + m) ((n + m) - n) (scf.for.loop f n (n - 0) seed) = scf.for.loop f (n + m) (n + m - 0) seed := by {\n    simp[scf.for.loop]\n    revert m;\n    induction n;\n    case zero => {\n      simp[loop]\n    }\n    case succ n' IH => {\n      intros m;\n      simp[loop];\n      sorry\n    }\n  }\n\n\n\n-- theorem 4 : tiling\n-- proof obligation for chris :)\ntheorem Tensor1d.tile [Inhabited α] (t : Tensor1d α) (SIZE :4 ∣ t.size) (f : α → α):\n  t.map f = scf.for (t.size / 4) (fun i acc =>\n    let tile := t.extract (i * 4) 4\n    let mapped_tile := tile.map f\n    let out := acc.insertslice (i * 4) mapped_tile\n    out) (Tensor1d.empty) := by {\n    cases t;\n    case mk size val =>\n    simp at SIZE ⊢;\n    have : { n : Nat //  size = n * 4 } := by {\n      norm_num at SIZE\n      -- have ⟨x, y⟩ := SIZE\n      sorry\n    }\n    have ⟨n, N⟩ := this\n    rw[N];\n    revert size\n    induction n\n    case zero => {\n      simp[scf.for, scf.for.loop]\n      sorry\n    }\n    case succ n IH => {\n      sorry\n    }\n}\n\n-- transpose is an involution\n\ntheorem Tensor2d.transpose_involutive (t: Tensor2d α):\n  (t.transpose).transpose = t := by {\n    simp[Tensor2d.transpose]\n}\n\n\n\ninductive Val where\n| int : Int → Val\n| unit : Val\n| nat : Nat → Val\n| bool : Bool → Val\n| tensor1d : Tensor1d Int → Val\n| tensor2d : Tensor2d Int → Val\n| pair : Val → Val → Val\n| triple : Val → Val → Val → Val\n| inl : Val → Val\n| inr : Val → Val\nderiving Inhabited\n\n\ndef Val.int! : Val → Int\n| .int i => i\n| _ => default\n\ndef Val.nat! : Val → Nat\n| .nat i => i\n| _ => default\n\ndef Val.bool! : Val → Bool\n| .bool i => i\n| _ => default\n\n\nabbrev Var := Int\n\nabbrev Env (α: Type) := Var → α\n\ndef Env.empty {α : Type} [Inhabited α]: Env α := fun _ => default\nnotation \"∅\" =>  Env.empty\n\ndef Env.set (e: Env α) (var: Var) (val: α) :=\n  fun needle => if needle == var then val else e needle\nnotation e \"[\" var \" := \" val \"]\" => Env.set e var val\n\n\n-- RHS of an assignment\ninductive SSAIndex : Type\n| STMT\n| EXPR\n| TERMINATOR\n| REGION\n\n-- NOTE: multiple regions can be converted into a single region by tagging the\n-- input appropriately with inl/inr.\ninductive SSA (Op: Type): SSAIndex → Type where\n| assign (lhs: Var) (rhs: SSA Op .EXPR) (rest: SSA Op .STMT) : SSA Op .STMT\n| nop : SSA Op .STMT\n| ret (above : SSA Op .STMT) (v: Var): SSA Op .TERMINATOR\n| pair (fst snd : Var) : SSA Op .EXPR\n| op (o : Op) (arg: Var) (rgn: SSA Op .REGION) : SSA Op .EXPR\n| const (k: Val) : SSA Op .EXPR\n| rgn (arg: Var) (body: SSA Op .TERMINATOR) : SSA Op .REGION\n| rgn0 : SSA Op .REGION\n| rgnvar (v: Var) : SSA Op .REGION\n| var (v: Var) : SSA Op .EXPR\n\nabbrev Expr (Op: Type) := SSA Op .EXPR\nabbrev Stmt (Op: Type) := SSA Op .STMT\n\nclass UserSemantics (Op: Type) where\n  eval: (o: Op) → (arg: Val) → (rgn: Val → Val) → Val\n\ndef SSAIndex.eval : SSAIndex → Type\n| .STMT => Env Val\n| .TERMINATOR => Val\n| .EXPR => Val\n| .REGION => Val -> Val\n\ndef SSA.eval [S : UserSemantics Op] (e: Env Val) (re: Env (Val → Val)) : SSA Op k → k.eval\n| .assign lhs rhs rest =>\n  rest.eval (e.set lhs (rhs.eval e re)) re\n| .nop => e\n| .ret above v => (above.eval e re) v\n| .pair fst snd => (e fst).pair (e snd)\n| .const v => v\n| .op o arg r => S.eval o (e arg) (r.eval Env.empty re)\n| .var v => e v\n| .rgnvar v => re v\n| .rgn0 => id\n| .rgn arg body => fun val => body.eval (e.set arg val) re\n\nnamespace ArithScfLinalg\n\ninductive op\n| add\n| sub\n| mul\n| run\n| for_\n| if_\n| fold1d -- fold\n| map1d\n| extract\n| fill\n| transpose\nderiving DecidableEq\n\n\n\ninstance : UserSemantics op where\n  eval\n  | .add, .pair (.int x) (.int y), _ => .int (x + y)\n  | .sub, .pair (.int x) (.int y), _ => .int (x - y)\n  | .run, v, r => r v\n  | .if_, (.bool cond), r => if cond then r (.inl .unit) else r (.inr .unit)\n  | .for_, (.pair (.nat n) (.int seed)), r =>\n      .int <| scf.for n (fun ix acc => (r (.pair (.int ix) (.int acc))).int!) seed\n  | .map1d, (.tensor1d t), r => .tensor1d <| t.map fun v => (r (.int v)).int!\n  | .fold1d, (.pair (.tensor1d t) (.int seed)), r =>\n      .int <| t.fold (fun acc v => (r (.pair (.int acc) (.int v))).int!) seed\n  | .extract, (.triple (.tensor1d t) (.nat l) (.nat len)), _ =>\n      .tensor1d <| t.extract l len\n  | _, _, _ => default\n\n-- TODO: port Hacker's delight examples.\n\nend ArithScfLinalg\n\nend LC", "meta": {"author": "bollu", "repo": "ssa", "sha": "19c73e48500bfe3f618c360423966677adb4673e", "save_path": "github-repos/lean/bollu-ssa", "path": "github-repos/lean/bollu-ssa/ssa-19c73e48500bfe3f618c360423966677adb4673e/SSA/Experiment/MLIRFlat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.6959583187272712, "lm_q1q2_score": 0.46791482984922983}}
{"text": "import Lean\nimport Init.Classical\n\nimport SciLean.Core.Differential\nimport SciLean.Core.Adjoint\nimport SciLean.Core.HasAdjDiff\n\nnamespace SciLean\n\nvariable {α β γ : Type}\nvariable {X Y Z : Type} [SemiHilbert X] [SemiHilbert Y] [SemiHilbert Z] \nvariable {Y₁ Y₂ : Type} [SemiHilbert Y₁] [SemiHilbert Y₂]\nvariable {ι : Type} [Enumtype ι]\n\n\n-- noncomputable \n-- def adjointDifferential (f : X → Y) (x : X) (dy' : Y) : X := (∂ f x)† dy'\n\n-- @[default_instance]\n-- instance (f : X → Y) : PartialDagger f (adjointDifferential f) := ⟨⟩\n\n-- Someting wrong here :(\n-- noncomputable \n-- def Smooth.adjointDifferential {X Y} [Hilbert X] [Hilbert Y] (f : X ⟿ Y) : X⟿Y⊸X := λ x ⟿ λ dy ⊸ adjoint (∂ f x) dy\n\n-- @[default_instance]\n-- instance (f : X → Y) : PartialDagger f (adjointDifferential f) := ⟨⟩\n\n\n-- Question: Should there be `𝒯[y] Y` or `𝒯[f x] Y`?\n-- Maybe return `(y:Y)×(𝒯[y] Y → 𝒯[x] X)×(f x = y)` but there is a problem with `Sigma` vs `PSigma`\n-- noncomputable\n-- def reverseDifferential (f : X → Y) (x : X) : Y×(Y→X) := (f x, λ dy => ∂† f x dy)\n\n-- instance (priority:=low) (f : X → Y) : ReverseDifferential f (reverseDifferential f) := ⟨⟩\n\n\n-- noncomputable\n-- abbrev gradient (f : X → ℝ) (x : X) : X := ∂† f x 1\n\n-- @[default_instance]\n-- instance (f : X → ℝ) : Nabla f (gradient f) := ⟨⟩\n\n-- noncomputable\n-- abbrev Smooth.gradient (f : X ⟿ ℝ) : X⟿X := SmoothMap.mk (λ x => adjoint (λ dx => ∂ f x dx) 1) sorry_proof\n\n-- instance (f : X ⟿ ℝ) : Nabla f (Smooth.gradient f) := ⟨⟩\n\n\n-- Notation \n-- ∇ s, f s         --> ∇ λ s => f s\n-- ∇ s : ℝ, f s     --> ∇ λ s : ℝ => f s\n-- ∇ s := t, f s    --> (∇ λ s => f s) t\nsyntax \"∇\" diffBinder \",\" term:66 : term\nsyntax \"∇\" \"(\" diffBinder \")\" \",\" term:66 : term\nmacro_rules \n| `(∇ $x:ident, $f) =>\n  `(∇ λ $x => $f)\n| `(∇ $x:ident : $type:term, $f) =>\n  `(∇ λ $x : $type => $f)\n| `(∇ $x:ident := $val:term, $f) =>\n  `((∇ λ $x => $f) $val)\n| `(∇ ($b:diffBinder), $f) =>\n  `(∇ $b, $f)\n\n\ninstance (f : X → Y) [HasAdjDiff f] (x : X) : IsLin (∂† f x) := sorry\n\n----------------------------------------------------------------------\n\n\n@[simp ↓, diff]\ntheorem id.arg_x.adjDiff_simp\n  : ∂† (λ x : X => x) = λ x dx => dx := by symdiff; simp[adjointDifferential]; done\n\n@[simp ↓, diff]\ntheorem const.arg_x.adjDiff_simp \n  : ∂† (λ (x : X) (i : ι) => x) = λ x f => ∑ i, f i := by simp[adjointDifferential]; done\n\n@[simp ↓, diff]\ntheorem const.arg_y.adjDiff_simp (x : X)\n  : ∂† (λ (y : Y) => x) = (λ y dy' => (0 : Y)) := by simp[adjointDifferential]; done\n\n@[simp ↓ low-4, diff low-4]\ntheorem swap.arg_y.adjDiff_simp\n  (f : ι → X → Z) [inst : ∀ i, HasAdjDiffT (f i)]\n  : ∂† (λ x y => f y x) = (λ x dx' => ∑ i, (∂† (f i) x) (dx' i)) := \nby \n  have := λ i => (inst i).1\n  have := λ i => (inst i).2\n\n  simp[adjointDifferential]; done\n\n@[simp ↓ low-3, diff low-3]\ntheorem subst.arg_x.adjDiff_simp\n  (f : X → Y → Z) [instf : HasAdjDiffNT 2 f]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ∂† (λ x => f x (g x)) \n    = \n    λ x dz =>\n      let (y,dg') := ℛ g x\n      -- let (dx,dy) := ∂† (uncurryN 2 f) (x,y) dz\n      -- dx + dg' dy\n      (∂† (λ x' => f x' y)) x dz\n      +\n      dg' (∂† (f x) y dz)\n    := \nby \n  have := instg.1\n  have := instg.2\n  have := instf.1\n  -- these follow from instf.proof.2\n  have : ∀ x y, HasAdjointT (λ dx => ∂ f x dx y) := sorry_proof\n  have : ∀ x y, HasAdjointT (λ dy => ∂ (f x) y dy) := sorry_proof\n\n  unfold adjointDifferential -- reverseDifferential, tangentMap, -comp.arg_x.parm1.adj_simp]\n  sorry -- symdiff\n    --sorry_proof\n  -- simp (config := {singlePass := true})\n  -- done\n\n@[simp ↓ low-2, diff low-2, simp_guard g (λ x => x)]\ntheorem subst.arg_x.parm1.adjDiff_simp\n  (a : α)\n  (f : X → Y → α → Z) [HasAdjDiffNT 2 λ x y => f x y a]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ∂† (λ x => f x (g x) a) \n    = \n    λ x dz => \n      let (y,dg') := ℛ g x\n      -- let (dx,dy) := ∂† (uncurryN 2 (λ x y => f x y a)) (x,y) dz\n      -- dx + dg' dy\n      (∂† (λ x' => f x' y a)) x dz\n      +\n      dg' (∂† (λ y' => f x y' a) y dz)\n    := \nby \n  rw[subst.arg_x.adjDiff_simp (λ x y => f x y a) g]\n  done\n\n@[simp ↓ low-2, diff low-2, simp_guard g (λ x => x)]\ntheorem subst.arg_x.parm2.adjDiff_simp\n  (a : α) (b : β)\n  (f : X → Y → α → β → Z) [HasAdjDiffNT 2 λ x y => f x y a b]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ∂† (λ x => f x (g x) a b) \n    = \n    λ x dz => \n      let (y,dg') := ℛ g x\n      (∂† (λ x' => f x' y a b)) x dz\n      +\n      dg' (∂† (λ y' => f x y' a b) y dz)\n    := \nby \n  apply subst.arg_x.adjDiff_simp (λ x y => f x y a b) g\n  done\n\n@[simp ↓ low-2, diff low-2, simp_guard g (λ x => x)]\ntheorem subst.arg_x.parm3.adjDiff_simp\n  (a : α) (b : β) (c : γ)\n  (f : X → Y → α → β → γ → Z) [HasAdjDiffNT 2 λ x y => f x y a b c]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ∂† (λ x => f x (g x) a b c) \n    = \n    λ x dz => \n      let (y,dg') := ℛ g x\n      (∂† (λ x' => f x' y a b c)) x dz\n      +\n      dg' (∂† (λ y' => f x y' a b c) y dz)\n    := \nby \n  apply subst.arg_x.adjDiff_simp (λ x y => f x y a b c) g\n  done\n\n@[simp ↓ low-1, diff low-1, simp_guard g (λ x => x)]\ntheorem comp.arg_x.adjDiff_simp\n  (f : Y → Z) [instf : HasAdjDiffT f]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ∂† (λ x => f (g x)) \n    = \n    λ x dz => \n      let (y,dg') := ℛ g x\n      dg' ((∂† f y) dz) \n  := by simp; done\n\n@[simp ↓ low-2, diff low-2, simp_guard g₁ Prod.fst, g₂ Prod.snd]\ntheorem diag.arg_x.adjDiff_simp\n  (f : Y₁ → Y₂ → Z) [HasAdjDiffNT 2 f]\n  (g₁ : X → Y₁) [hg : HasAdjDiffT g₁]\n  (g₂ : X → Y₂) [HasAdjDiffT g₂]\n  : ∂† (λ x => f (g₁ x) (g₂ x)) \n    = \n    λ x dz => \n      let (y₁,dg₁') := ℛ g₁ x\n      let (y₂,dg₂') := ℛ g₂ x\n      dg₁' ((∂† λ y₁' => f y₁' y₂) y₁ dz)\n      +\n      dg₂' ((∂† λ y₂' => f y₁ y₂') y₂ dz)\n    := \nby\n  rw[subst.arg_x.adjDiff_simp]\n  simp only [hold,reverseDifferential]\n  funext x dz\n  rw[comp.arg_x.adjDiff_simp (λ y₁ => f y₁ (g₂ x))]\n  simp only [reverseDifferential]\n  done\n\n@[simp ↓ low, diff low]\ntheorem eval.arg_f.adjDiff_simp\n  (i : ι)\n  : ∂† (λ (f : ι → X) => f i) \n    = \n    (λ f df' j => ([[i = j]] • df' : X))\n:= sorry\n\n@[simp ↓ low-1, diff low-1]\ntheorem eval.arg_x.parm1.adjDiff_simp\n  (f : X → ι → Z) [HasAdjDiff f]\n  : ∂† (λ x => f x i) \n    = \n    (λ x dx' => (∂† f x) (λ j => ([[i = j]] • dx' : Z)))\n:= \nby \n  rw [comp.arg_x.adjDiff_simp (λ (x : ι → Z) => x i) f]\n  simp[reverseDifferential]\n\n\n--------------------------------------------------------\n-- These theorems are problematic when used with simp --\n\n\n@[simp ↓ low-1, diff low-1]\ntheorem comp.arg_x.parm1.adjDiff_simp\n  (a : α) \n  (f : Y → α → Z) [HasAdjDiff λ y => f y a]\n  (g : X → Y) [HasAdjDiff g]\n  : \n    ∂† (λ x => f (g x) a) \n    = \n    λ x dz => \n      let (y,dg') := ℛ g x\n      dg' ((∂† (hold λ y => f y a)) y dz)\n:= by \n  rw[subst.arg_x.parm1.adjDiff_simp]\n  simp[-subst.arg_x.parm1.adjDiff_simp,hold]\n  done\n\n@[simp ↓ low-1, diff low-1]\ntheorem comp.arg_x.parm2.adjDiff_simp\n  (a : α) (b : β)\n  (f : Y → α → β → Z) [HasAdjDiff λ y => f y a b]\n  (g : X → Y) [HasAdjDiff g]\n  : \n    ∂† (λ x => f (g x) a b) \n    = \n    λ x dz => \n      let (y,dg') := ℛ g x\n      dg' ((∂† (hold λ y => f y a b)) y dz)\n:= by \n  rw[subst.arg_x.parm2.adjDiff_simp]\n  simp[-subst.arg_x.parm2.adjDiff_simp,hold]\n  done\n\n@[simp ↓ low-1, diff low-1]\ntheorem comp.arg_x.parm3.adjDiff_simp\n  (a : α) (b : β) (c : γ)\n  (f : Y → α → β → γ → Z) [HasAdjDiff λ y => f y a b c]\n  (g : X → Y) [HasAdjDiff g]\n  : \n    ∂† (λ x => f (g x) a b c) \n    = \n    λ x dx' => \n      let (y,dg') := ℛ g x\n      dg' ((∂† (hold λ y => f y a b c)) y dx')\n:= by \n  rw[subst.arg_x.parm3.adjDiff_simp]\n  simp[-subst.arg_x.parm3.adjDiff_simp,hold]\n  done\n\n\n-- TODO: fix this!!!\nexample (a : α) (f : Y₁ → Y₂ → α → Z) [IsSmoothT λ y₁ y₂ => f y₁ y₂ a]\n  (g₁ : X → Y₁) [hg : IsSmoothT g₁] : IsSmoothT (λ x y => f (g₁ x) y a) := by (try infer_instance); admit\n\n\n@[simp ↓ low-1, diff low-1] -- try to avoid using this theorem\ntheorem diag.arg_x.parm1.adjDiff_simp\n  (a : α)\n  (f : Y₁ → Y₂ → α → Z) [HasAdjDiffNT 2 λ y₁ y₂ => f y₁ y₂ a]\n  (g₁ : X → Y₁) [HasAdjDiffT g₁]\n  (g₂ : X → Y₂) [HasAdjDiffT g₂]\n  : ∂† (λ x => f (g₁ x) (g₂ x) a)\n    = \n    λ x dz => \n      let (y₁,dg₁') := ℛ g₁ x\n      let (y₂,dg₂') := ℛ g₂ x\n      dg₁' ((∂† (hold λ y₁' => f y₁' y₂ a)) y₁ dz)\n      +\n      dg₂' ((∂† (hold λ y₂' => f y₁ y₂' a)) y₂ dz)\n:= by \n  (apply diag.arg_x.adjDiff_simp (λ y₁ y₂ => f y₁ y₂ a) g₁ g₂)\n  \n@[simp ↓ low-1, diff low-1] -- try to avoid using this theorem\ntheorem diag.arg_x.parm2.adjDiff_simp\n  (a : α) (b : β)\n  (f : Y₁ → Y₂ → α → β → Z) [HasAdjDiffNT 2 λ y₁ y₂ => f y₁ y₂ a b]\n  (g₁ : X → Y₁) [HasAdjDiffT g₁]\n  (g₂ : X → Y₂) [HasAdjDiffT g₂]\n  : ∂† (λ x => f (g₁ x) (g₂ x) a b)\n    = \n    λ x dz => \n      let (y₁,dg₁') := ℛ g₁ x\n      let (y₂,dg₂') := ℛ g₂ x\n      dg₁' ((∂† (hold λ y₁' => f y₁' y₂ a b)) y₁ dz)\n      +\n      dg₂' ((∂† (hold λ y₂' => f y₁ y₂' a b)) y₂ dz)\n:= by \n  (apply diag.arg_x.adjDiff_simp (λ y₁ y₂ => f y₁ y₂ a b) g₁ g₂)\n  done\n\n@[simp ↓ low-1, diff low-1] -- try to avoid using this theorem\ntheorem diag.arg_x.parm3.adjDiff_simp\n  (a : α) (b : β) (c : γ)\n  (f : Y₁ → Y₂ → α → β → γ → Z) [HasAdjDiffNT 2 λ y₁ y₂ => f y₁ y₂ a b c]\n  (g₁ : X → Y₁) [HasAdjDiffT g₁]\n  (g₂ : X → Y₂) [HasAdjDiffT g₂]\n  : ∂† (λ x => f (g₁ x) (g₂ x) a b c)\n    = \n    λ x dz => \n      let (y₁,dg₁') := ℛ g₁ x\n      let (y₂,dg₂') := ℛ g₂ x\n      dg₁' ((∂† (hold λ y₁' => f y₁' y₂ a b c)) y₁ dz)\n      +\n      dg₂' ((∂† (hold λ y₂' => f y₁ y₂' a b c)) y₂ dz)\n:= by \n  (apply diag.arg_x.adjDiff_simp (λ y₁ y₂ => f y₁ y₂ a b c) g₁ g₂)\n  done\n\n----------------------------------------------------------------------\n\n\n\n@[simp ↓, diff]\ntheorem id.arg_x.revDiff_simp\n  : ℛ (λ x : X => x) = λ x => (x, λ x => x) := by simp[reverseDifferential]; done\n\n@[simp ↓, diff]\ntheorem const.arg_x.revDiff_simp \n  : ℛ (λ (x : X) (i : ι) => x) \n    = \n    λ x => ((λ i => x), (λ f => ∑ i, f i))\n  := by simp[reverseDifferential]; done\n\n@[simp ↓, diff]\ntheorem const.arg_y.revDiff_simp (x : X)\n  : ℛ (λ (y : Y) => x) \n    =\n    λ y => \n      (x, (λ dy' => 0))\n  := by simp[reverseDifferential]; done\n\n@[simp ↓ low-4, diff low-4]\ntheorem swap.arg_y.revDiff_simp\n  (f : ι → X → Z) [inst : ∀ i, HasAdjDiffT (f i)]\n  : ∂† (λ x y => f y x) = (λ x dx' => ∑ i, (∂† (f i) x) (dx' i)) := \nby \n  have := λ i => (inst i).1\n  have := λ i => (inst i).2\n\n  simp[adjointDifferential]; done\n\n@[simp ↓ low-3, diff low-3, simp_guard g (λ x => x)]\ntheorem subst.arg_x.revDiff_simp\n  (f : X → Y → Z) [instf : HasAdjDiffNT 2 f]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ℛ (λ x => f x (g x)) \n    = \n    λ x => \n      let (y,dg') := ℛ g x\n      let (z,df') := ℛ (uncurryN 2 f) (x,y)\n      (z, λ dz' => \n           let (dx₁,dy) := df' dz'\n           dx₁ + dg' dy)\n      \n    := \nby \n  have := instg.1\n  have := instg.2\n  have := instf.1\n\n  funext x;\n  unfold reverseDifferential\n  rw[subst.arg_x.adjDiff_simp]\n\n  simp only [uncurryN, Prod.Uncurry.uncurry]\n  simp only [hold, reverseDifferential]\n  conv => (rhs; rw[diag.arg_x.adjDiff_simp])\n  simp only [reverseDifferential, \n             Prod.fst.arg_xy.adjDiff_simp, \n             Prod.snd.arg_xy.adjDiff_simp,\n             prod_add_elemwise, \n             add_zero, zero_add]\n  done\n\n\n@[simp ↓ low-2, diff low-2, simp_guard g (λ x => x)]\ntheorem subst.arg_x.parm1.revDiff_simp\n  (a : α)\n  (f : X → Y → α → Z) [HasAdjDiffNT 2 λ x y => f x y a]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ℛ (λ x => f x (g x) a) \n    = \n    λ x => \n      let (y,dg') := ℛ g x\n      let (z,df') := ℛ (uncurryN 2 (λ x y => f x y a)) (x,y)\n      (z, λ dz' => \n           let (dx₁,dy) := df' dz'\n           dx₁ + dg' dy)\n    := \nby \n  apply subst.arg_x.revDiff_simp (λ x y => f x y a) g\n  done\n\n@[simp ↓ low-2, diff low-2, simp_guard g (λ x => x)]\ntheorem subst.arg_x.parm2.revDiff_simp\n  (a : α) (b : β)\n  (f : X → Y → α → β → Z) [HasAdjDiffNT 2 λ x y => f x y a b]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ℛ (λ x => f x (g x) a b) \n    = \n    λ x => \n      let (y,dg') := ℛ g x\n      let (z,df') := ℛ (uncurryN 2 (λ x y => f x y a b)) (x,y)\n      (z, λ dz' => \n           let (dx₁,dy) := df' dz'\n           dx₁ + dg' dy)\n    := \nby \n  apply subst.arg_x.revDiff_simp (λ x y => f x y a b) g\n  done\n\n@[simp ↓ low-2, diff low-2, simp_guard g (λ x => x)]\ntheorem subst.arg_x.parm3.revDiff_simp\n  (a : α) (b : β) (c : γ)\n  (f : X → Y → α → β → γ → Z) [HasAdjDiffNT 2 λ x y => f x y a b c]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ℛ (λ x => f x (g x) a b c) \n    = \n    λ x => \n      let (y,dg') := ℛ g x\n      let (z,df') := ℛ (uncurryN 2 (λ x y => f x y a b c)) (x,y)\n      (z, λ dz' => let (dx₁,dy) := df' dz'; dx₁ + dg' dy)\n    := \nby \n  apply subst.arg_x.revDiff_simp (λ x y => f x y a b c) g\n  done\n\n\n-- @[simp ↓ low-10, diff low-10]\ntheorem uncurryN2.arg_x.diff_simp\n  (f : X → Y → Z) [HasAdjDiffNT 2 f]\n  : ∂† (uncurryN 2 f) \n    =\n    λ (x,y) dz =>\n      (∂† (λ x' => f x' y) x dz, ∂† (λ y' => f x y') y dz)\n  := sorry_proof\n\n@[simp ↓ low-1, diff low-1]\ntheorem comp.arg_x.revDiff_simp\n  (f : Y → Z) [instf : HasAdjDiffT f]\n  (g : X → Y) [instg : HasAdjDiffT g]\n  : ℛ (λ x => f (g x)) \n    = \n    λ x => \n      let (y,dg') := ℛ g x\n      let (z,df') := ℛ f y\n      (z, λ dz => dg' (df' dz)) := \nby \n  unfold reverseDifferential\n  simp only [comp.arg_x.adjDiff_simp]\n  simp only [reverseDifferential]\n  done\n\n@[simp ↓ low-2, diff low-2]\ntheorem diag.arg_x.revDiff_simp\n  (f : Y₁ → Y₂ → Z) [HasAdjDiffNT 2 f]\n  (g₁ : X → Y₁) [hg : HasAdjDiffT g₁]\n  (g₂ : X → Y₂) [HasAdjDiffT g₂]\n  : ℛ (λ x => f (g₁ x) (g₂ x)) \n    = \n    λ x => \n      let (y₁,dg₁') := ℛ g₁ x\n      let (y₂,dg₂') := ℛ g₂ x\n      let (z, df') := ℛ (uncurryN 2 f) (y₁,y₂)\n      (z, λ dz => let (dy₁,dy₂) := df' dz; dg₁' dy₁ + dg₂' dy₂)\n      -- dg₁' ((∂† λ y₁ => f y₁ y₂) y₁ (h₁ ▸ h₂ ▸ dx'))\n      -- +\n      -- dg₂' ((∂† λ y₂ => f y₁ y₂) y₂ (h₂ ▸ h₁ ▸ dx'))\n    := \nby\n  unfold reverseDifferential\n  funext x\n  simp only [uncurryN, Prod.Uncurry.uncurry]\n  conv => lhs; enter [2,dz]; rw [diag.arg_x.adjDiff_simp]\n  conv => rhs; enter [2,dz]; rw [diag.arg_x.adjDiff_simp]\n  simp only [reverseDifferential,             \n             Prod.fst.arg_xy.adjDiff_simp, \n             Prod.snd.arg_xy.adjDiff_simp, \n             prod_add_elemwise, \n             add_zero, zero_add]\n  done\n\n@[simp ↓ low, diff low]\ntheorem eval.arg_f.revDiff_simp\n  (i : ι)\n  : ℛ (λ (f : ι → X) => f i) \n    = \n    λ f => (f i, (λ dx j => ([[i=j]] • dx : X)))\n  := \nby \n  simp[reverseDifferential,adjointDifferential]; done\n\n@[simp ↓ low-1, diff low-1]\ntheorem eval.arg_x.parm1.revDiff_simp\n  (f : X → ι → Z) [HasAdjDiff f] (i : ι)\n  : ℛ (λ x => f x i)\n    = \n    λ x =>\n      let (fx, df') := ℛ f x\n      (fx i, \n      λ dz => df' (λ j => ([[i=j]] • dz)))\n  := \nby \n  rw [comp.arg_x.revDiff_simp (λ (x : ι → Z) => x i) f]\n  simp[reverseDifferential,adjointDifferential]\n\n\n-- @[simp ↓]\n-- theorem subst.arg_x.revDiff_simp'''\n--   (f : X → Y → Z) [IsSmooth f]\n--   [instfx : ∀ y, HasAdjDiff λ x => f x y]\n--   [instfy : ∀ x, HasAdjDiff (f x)]\n--   (g : Y → X) [instg : HasAdjDiff g]\n--   : ∂† (λ y => f (g y) y) \n--     = \n--     λ y dy' => \n--       (∂† (λ y' => f (g y) y')) y dy'\n--       +\n--       (∂† g y) (∂† (λ x => f x y) (g y) dy')\n--     := \n-- by \n--   sorry\n\n\n\n\n\n\n\n\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Core/AdjDiff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577158, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4677955572871366}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov\n\n! This file was ported from Lean 3 source module topology.connected\n! leanprover-community/mathlib commit d101e93197bb5f6ea89bd7ba386b7f7dff1f3903\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Set.BoolIndicator\nimport Mathlib.Order.SuccPred.Relation\nimport Mathlib.Topology.SubsetProperties\n\n/-!\n# Connected subsets of topological spaces\n\nIn this file we define connected subsets of a topological spaces and various other properties and\nclasses related to connectivity.\n\n## Main definitions\n\nWe define the following properties for sets in a topological space:\n\n* `IsConnected`: a nonempty set that has no non-trivial open partition.\n  See also the section below in the module doc.\n* `connectedComponent` is the connected component of an element in the space.\n* `IsTotallyDisconnected`: all of its connected components are singletons.\n* `IsTotallySeparated`: any two points can be separated by two disjoint opens that cover the set.\n\nFor each of these definitions, we also have a class stating that the whole space\nsatisfies that property:\n`ConnectedSpace`, `TotallyDisconnectedSpace`, `TotallySeparatedSpace`.\n\n## On the definition of connected sets/spaces\n\nIn informal mathematics, connected spaces are assumed to be nonempty.\nWe formalise the predicate without that assumption as `IsPreconnected`.\nIn other words, the only difference is whether the empty space counts as connected.\nThere are good reasons to consider the empty space to be “too simple to be simple”\nSee also https://ncatlab.org/nlab/show/too+simple+to+be+simple,\nand in particular\nhttps://ncatlab.org/nlab/show/too+simple+to+be+simple#relationship_to_biased_definitions.\n-/\n\n\nopen Set Function Topology TopologicalSpace Relation\nopen scoped Classical\n\nuniverse u v\n\nvariable {α : Type u} {β : Type v} {ι : Type _} {π : ι → Type _} [TopologicalSpace α]\n  {s t u v : Set α}\n\nsection Preconnected\n\n/-- A preconnected set is one where there is no non-trivial open partition. -/\ndef IsPreconnected (s : Set α) : Prop :=\n  ∀ u v : Set α, IsOpen u → IsOpen v → s ⊆ u ∪ v → (s ∩ u).Nonempty → (s ∩ v).Nonempty →\n    (s ∩ (u ∩ v)).Nonempty\n#align is_preconnected IsPreconnected\n\n/-- A connected set is one that is nonempty and where there is no non-trivial open partition. -/\ndef IsConnected (s : Set α) : Prop :=\n  s.Nonempty ∧ IsPreconnected s\n#align is_connected IsConnected\n\ntheorem IsConnected.nonempty {s : Set α} (h : IsConnected s) : s.Nonempty :=\n  h.1\n#align is_connected.nonempty IsConnected.nonempty\n\ntheorem IsConnected.isPreconnected {s : Set α} (h : IsConnected s) : IsPreconnected s :=\n  h.2\n#align is_connected.is_preconnected IsConnected.isPreconnected\n\ntheorem IsPreirreducible.isPreconnected {s : Set α} (H : IsPreirreducible s) : IsPreconnected s :=\n  fun _ _ hu hv _ => H _ _ hu hv\n#align is_preirreducible.is_preconnected IsPreirreducible.isPreconnected\n\ntheorem IsIrreducible.isConnected {s : Set α} (H : IsIrreducible s) : IsConnected s :=\n  ⟨H.nonempty, H.isPreirreducible.isPreconnected⟩\n#align is_irreducible.is_connected IsIrreducible.isConnected\n\ntheorem isPreconnected_empty : IsPreconnected (∅ : Set α) :=\n  isPreirreducible_empty.isPreconnected\n#align is_preconnected_empty isPreconnected_empty\n\ntheorem isConnected_singleton {x} : IsConnected ({x} : Set α) :=\n  isIrreducible_singleton.isConnected\n#align is_connected_singleton isConnected_singleton\n\ntheorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set α) :=\n  isConnected_singleton.isPreconnected\n#align is_preconnected_singleton isPreconnected_singleton\n\ntheorem Set.Subsingleton.isPreconnected {s : Set α} (hs : s.Subsingleton) : IsPreconnected s :=\n  hs.induction_on isPreconnected_empty fun _ => isPreconnected_singleton\n#align set.subsingleton.is_preconnected Set.Subsingleton.isPreconnected\n\n/-- If any point of a set is joined to a fixed point by a preconnected subset,\nthen the original set is preconnected as well. -/\ntheorem isPreconnected_of_forall {s : Set α} (x : α)\n    (H : ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by\n  rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩\n  have xs : x ∈ s := by\n    rcases H y ys with ⟨t, ts, xt, -, -⟩\n    exact ts xt\n  -- porting note: todo: use `wlog xu : x ∈ u := hs xs using u v y z, v u z y`\n  cases hs xs\n  case inl xu =>\n    rcases H y ys with ⟨t, ts, xt, yt, ht⟩\n    have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩\n    exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩\n  case inr xv =>\n    rcases H z zs with ⟨t, ts, xt, zt, ht⟩\n    have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩\n    exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩\n#align is_preconnected_of_forall isPreconnected_of_forall\n\n/-- If any two points of a set are contained in a preconnected subset,\nthen the original set is preconnected as well. -/\ntheorem isPreconnected_of_forall_pair {s : Set α}\n    (H : ∀ x, x ∈ s → ∀ y, y ∈ s → ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) :\n    IsPreconnected s := by\n  rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩)\n  exacts [isPreconnected_empty, isPreconnected_of_forall x fun y => H x hx y]\n#align is_preconnected_of_forall_pair isPreconnected_of_forall_pair\n\n/-- A union of a family of preconnected sets with a common point is preconnected as well. -/\ntheorem isPreconnected_unionₛ (x : α) (c : Set (Set α)) (H1 : ∀ s ∈ c, x ∈ s)\n    (H2 : ∀ s ∈ c, IsPreconnected s) : IsPreconnected (⋃₀ c) := by\n  apply isPreconnected_of_forall x\n  rintro y ⟨s, sc, ys⟩\n  exact ⟨s, subset_unionₛ_of_mem sc, H1 s sc, ys, H2 s sc⟩\n#align is_preconnected_sUnion isPreconnected_unionₛ\n\ntheorem isPreconnected_unionᵢ {ι : Sort _} {s : ι → Set α} (h₁ : (⋂ i, s i).Nonempty)\n    (h₂ : ∀ i, IsPreconnected (s i)) : IsPreconnected (⋃ i, s i) :=\n  Exists.elim h₁ fun f hf => isPreconnected_unionₛ f _ hf (forall_range_iff.2 h₂)\n#align is_preconnected_Union isPreconnected_unionᵢ\n\ntheorem IsPreconnected.union (x : α) {s t : Set α} (H1 : x ∈ s) (H2 : x ∈ t) (H3 : IsPreconnected s)\n    (H4 : IsPreconnected t) : IsPreconnected (s ∪ t) :=\n  unionₛ_pair s t ▸ isPreconnected_unionₛ x {s, t} (by rintro r (rfl | rfl | h) <;> assumption)\n    (by rintro r (rfl | rfl | h) <;> assumption)\n#align is_preconnected.union IsPreconnected.union\n\ntheorem IsPreconnected.union' {s t : Set α} (H : (s ∩ t).Nonempty) (hs : IsPreconnected s)\n    (ht : IsPreconnected t) : IsPreconnected (s ∪ t) := by\n  rcases H with ⟨x, hxs, hxt⟩\n  exact hs.union x hxs hxt ht\n#align is_preconnected.union' IsPreconnected.union'\n\ntheorem IsConnected.union {s t : Set α} (H : (s ∩ t).Nonempty) (Hs : IsConnected s)\n    (Ht : IsConnected t) : IsConnected (s ∪ t) := by\n  rcases H with ⟨x, hx⟩\n  refine' ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, _⟩\n  exact Hs.isPreconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx)\n    Ht.isPreconnected\n#align is_connected.union IsConnected.union\n\n/-- The directed unionₛ of a set S of preconnected subsets is preconnected. -/\ntheorem IsPreconnected.unionₛ_directed {S : Set (Set α)} (K : DirectedOn (· ⊆ ·) S)\n    (H : ∀ s ∈ S, IsPreconnected s) : IsPreconnected (⋃₀ S) := by\n  rintro u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩\n  obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS\n  have Hnuv : (r ∩ (u ∩ v)).Nonempty :=\n    H _ hrS u v hu hv ((subset_unionₛ_of_mem hrS).trans Huv) ⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩\n  have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) := inter_subset_inter_left _ (subset_unionₛ_of_mem hrS)\n  exact Hnuv.mono Kruv\n#align is_preconnected.sUnion_directed IsPreconnected.unionₛ_directed\n\n/-- The bunionᵢ of a family of preconnected sets is preconnected if the graph determined by\nwhether two sets intersect is preconnected. -/\ntheorem IsPreconnected.bunionᵢ_of_reflTransGen {ι : Type _} {t : Set ι} {s : ι → Set α}\n    (H : ∀ i ∈ t, IsPreconnected (s i))\n    (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) :\n    IsPreconnected (⋃ n ∈ t, s n) := by\n  let R := fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t\n  have P : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen R i j →\n      ∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ j ∈ p, s j) := fun i hi j hj h => by\n    induction h\n    case refl =>\n      refine ⟨{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩\n      rw [bunionᵢ_singleton]\n      exact H i hi\n    case tail j k _ hjk ih =>\n      obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2\n      refine ⟨insert k p, insert_subset.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip, mem_insert k p, ?_⟩\n      rw [bunionᵢ_insert]\n      refine (H k hj).union' (hjk.1.mono ?_) hp\n      rw [inter_comm]\n      exact inter_subset_inter_right _ (subset_bunionᵢ_of_mem hjp)\n  refine' isPreconnected_of_forall_pair _\n  intro x hx y hy\n  obtain ⟨i : ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_unionᵢ₂.1 hx\n  obtain ⟨j : ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_unionᵢ₂.1 hy\n  obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj)\n  exact ⟨⋃ j ∈ p, s j, bunionᵢ_subset_bunionᵢ_left hpt, mem_bunionᵢ hip hxi,\n    mem_bunionᵢ hjp hyj, hp⟩\n#align is_preconnected.bUnion_of_refl_trans_gen IsPreconnected.bunionᵢ_of_reflTransGen\n\n/-- The bunionᵢ of a family of preconnected sets is preconnected if the graph determined by\nwhether two sets intersect is preconnected. -/\ntheorem IsConnected.bunionᵢ_of_reflTransGen {ι : Type _} {t : Set ι} {s : ι → Set α}\n    (ht : t.Nonempty) (H : ∀ i ∈ t, IsConnected (s i))\n    (K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) :\n    IsConnected (⋃ n ∈ t, s n) :=\n  ⟨nonempty_bunionᵢ.2 <| ⟨ht.some, ht.some_mem, (H _ ht.some_mem).nonempty⟩,\n    IsPreconnected.bunionᵢ_of_reflTransGen (fun i hi => (H i hi).isPreconnected) K⟩\n#align is_connected.bUnion_of_refl_trans_gen IsConnected.bunionᵢ_of_reflTransGen\n\n/-- Preconnectedness of the unionᵢ of a family of preconnected sets\nindexed by the vertices of a preconnected graph,\nwhere two vertices are joined when the corresponding sets intersect. -/\ntheorem IsPreconnected.unionᵢ_of_reflTransGen {ι : Type _} {s : ι → Set α}\n    (H : ∀ i, IsPreconnected (s i))\n    (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) :\n    IsPreconnected (⋃ n, s n) := by\n  rw [← bunionᵢ_univ]\n  exact IsPreconnected.bunionᵢ_of_reflTransGen (fun i _ => H i) fun i _ j _ => by\n    simpa [mem_univ] using K i j\n#align is_preconnected.Union_of_refl_trans_gen IsPreconnected.unionᵢ_of_reflTransGen\n\ntheorem IsConnected.unionᵢ_of_reflTransGen {ι : Type _} [Nonempty ι] {s : ι → Set α}\n    (H : ∀ i, IsConnected (s i))\n    (K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsConnected (⋃ n, s n) :=\n  ⟨nonempty_unionᵢ.2 <| Nonempty.elim ‹_› fun i : ι => ⟨i, (H _).nonempty⟩,\n    IsPreconnected.unionᵢ_of_reflTransGen (fun i => (H i).isPreconnected) K⟩\n#align is_connected.Union_of_refl_trans_gen IsConnected.unionᵢ_of_reflTransGen\n\nsection SuccOrder\n\nopen Order\n\nvariable [LinearOrder β] [SuccOrder β] [IsSuccArchimedean β]\n\n/-- The unionᵢ of connected sets indexed by a type with an archimedean successor (like `ℕ` or `ℤ`)\n  such that any two neighboring sets meet is preconnected. -/\ntheorem IsPreconnected.unionᵢ_of_chain {s : β → Set α} (H : ∀ n, IsPreconnected (s n))\n    (K : ∀ n, (s n ∩ s (succ n)).Nonempty) : IsPreconnected (⋃ n, s n) :=\n  IsPreconnected.unionᵢ_of_reflTransGen H fun i j =>\n    reflTransGen_of_succ _ (fun i _ => K i) fun i _ => by\n      rw [inter_comm]\n      exact K i\n#align is_preconnected.Union_of_chain IsPreconnected.unionᵢ_of_chain\n\n/-- The unionᵢ of connected sets indexed by a type with an archimedean successor (like `ℕ` or `ℤ`)\n  such that any two neighboring sets meet is connected. -/\ntheorem IsConnected.unionᵢ_of_chain [Nonempty β] {s : β → Set α} (H : ∀ n, IsConnected (s n))\n    (K : ∀ n, (s n ∩ s (succ n)).Nonempty) : IsConnected (⋃ n, s n) :=\n  IsConnected.unionᵢ_of_reflTransGen H fun i j =>\n    reflTransGen_of_succ _ (fun i _ => K i) fun i _ => by\n      rw [inter_comm]\n      exact K i\n#align is_connected.Union_of_chain IsConnected.unionᵢ_of_chain\n\n/-- The unionᵢ of preconnected sets indexed by a subset of a type with an archimedean successor\n  (like `ℕ` or `ℤ`) such that any two neighboring sets meet is preconnected. -/\ntheorem IsPreconnected.bunionᵢ_of_chain {s : β → Set α} {t : Set β} (ht : OrdConnected t)\n    (H : ∀ n ∈ t, IsPreconnected (s n))\n    (K : ∀ n : β, n ∈ t → succ n ∈ t → (s n ∩ s (succ n)).Nonempty) :\n    IsPreconnected (⋃ n ∈ t, s n) := by\n  have h1 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → k ∈ t := fun hi hj hk =>\n    ht.out hi hj (Ico_subset_Icc_self hk)\n  have h2 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → succ k ∈ t := fun hi hj hk =>\n    ht.out hi hj ⟨hk.1.trans <| le_succ _, succ_le_of_lt hk.2⟩\n  have h3 : ∀ {i j k : β}, i ∈ t → j ∈ t → k ∈ Ico i j → (s k ∩ s (succ k)).Nonempty :=\n    fun hi hj hk => K _ (h1 hi hj hk) (h2 hi hj hk)\n  refine' IsPreconnected.bunionᵢ_of_reflTransGen H fun i hi j hj => _\n  exact reflTransGen_of_succ _ (fun k hk => ⟨h3 hi hj hk, h1 hi hj hk⟩) fun k hk =>\n      ⟨by rw [inter_comm]; exact h3 hj hi hk, h2 hj hi hk⟩\n#align is_preconnected.bUnion_of_chain IsPreconnected.bunionᵢ_of_chain\n\n/-- The unionᵢ of connected sets indexed by a subset of a type with an archimedean successor\n  (like `ℕ` or `ℤ`) such that any two neighboring sets meet is preconnected. -/\ntheorem IsConnected.bunionᵢ_of_chain {s : β → Set α} {t : Set β} (hnt : t.Nonempty)\n    (ht : OrdConnected t) (H : ∀ n ∈ t, IsConnected (s n))\n    (K : ∀ n : β, n ∈ t → succ n ∈ t → (s n ∩ s (succ n)).Nonempty) : IsConnected (⋃ n ∈ t, s n) :=\n  ⟨nonempty_bunionᵢ.2 <| ⟨hnt.some, hnt.some_mem, (H _ hnt.some_mem).nonempty⟩,\n    IsPreconnected.bunionᵢ_of_chain ht (fun i hi => (H i hi).isPreconnected) K⟩\n#align is_connected.bUnion_of_chain IsConnected.bunionᵢ_of_chain\n\nend SuccOrder\n\n/-- Theorem of bark and tree: if a set is within a (pre)connected set\nand its closure, then it is (pre)connected as well. -/\nprotected theorem IsPreconnected.subset_closure {s : Set α} {t : Set α} (H : IsPreconnected s)\n    (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsPreconnected t :=\n  fun u v hu hv htuv ⟨_y, hyt, hyu⟩ ⟨_z, hzt, hzv⟩ =>\n  let ⟨p, hpu, hps⟩ := mem_closure_iff.1 (Ktcs hyt) u hu hyu\n  let ⟨q, hqv, hqs⟩ := mem_closure_iff.1 (Ktcs hzt) v hv hzv\n  let ⟨r, hrs, hruv⟩ := H u v hu hv (Subset.trans Kst htuv) ⟨p, hps, hpu⟩ ⟨q, hqs, hqv⟩\n  ⟨r, Kst hrs, hruv⟩\n#align is_preconnected.subset_closure IsPreconnected.subset_closure\n\nprotected theorem IsConnected.subset_closure {s : Set α} {t : Set α} (H : IsConnected s)\n    (Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsConnected t :=\n  ⟨Nonempty.mono Kst H.left, IsPreconnected.subset_closure H.right Kst Ktcs⟩\n#align is_connected.subset_closure IsConnected.subset_closure\n\n/-- The closure of a (pre)connected set is (pre)connected as well. -/\nprotected theorem IsPreconnected.closure {s : Set α} (H : IsPreconnected s) :\n    IsPreconnected (closure s) :=\n  IsPreconnected.subset_closure H subset_closure Subset.rfl\n#align is_preconnected.closure IsPreconnected.closure\n\nprotected theorem IsConnected.closure {s : Set α} (H : IsConnected s) : IsConnected (closure s) :=\n  IsConnected.subset_closure H subset_closure <| Subset.rfl\n#align is_connected.closure IsConnected.closure\n\n/-- The image of a (pre)connected set is (pre)connected as well. -/\nprotected theorem IsPreconnected.image [TopologicalSpace β] {s : Set α} (H : IsPreconnected s)\n    (f : α → β) (hf : ContinuousOn f s) : IsPreconnected (f '' s) := by\n  -- Unfold/destruct definitions in hypotheses\n  rintro u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩\n  rcases continuousOn_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩\n  rcases continuousOn_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩\n  -- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'`\n  replace huv : s ⊆ u' ∪ v'\n  · rw [image_subset_iff, preimage_union] at huv\n    replace huv := subset_inter huv Subset.rfl\n    rw [inter_distrib_right, u'_eq, v'_eq, ← inter_distrib_right] at huv\n    exact (subset_inter_iff.1 huv).1\n  -- Now `s ⊆ u' ∪ v'`, so we can apply `‹IsPreconnected s›`\n  obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).Nonempty := by\n    refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ <;> rw [inter_comm]\n    exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩]\n  rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc, inter_comm s, inter_comm s,\n    ← u'_eq, ← v'_eq] at hz\n  exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩\n#align is_preconnected.image IsPreconnected.image\n\nprotected theorem IsConnected.image [TopologicalSpace β] {s : Set α} (H : IsConnected s) (f : α → β)\n    (hf : ContinuousOn f s) : IsConnected (f '' s) :=\n  ⟨nonempty_image_iff.mpr H.nonempty, H.isPreconnected.image f hf⟩\n#align is_connected.image IsConnected.image\n\ntheorem isPreconnected_closed_iff {s : Set α} :\n    IsPreconnected s ↔ ∀ t t', IsClosed t → IsClosed t' →\n      s ⊆ t ∪ t' → (s ∩ t).Nonempty → (s ∩ t').Nonempty → (s ∩ (t ∩ t')).Nonempty :=\n  ⟨by\n    rintro h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩\n    rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter]\n    intro h'\n    have xt' : x ∉ t' := (h' xs).resolve_left (absurd xt)\n    have yt : y ∉ t := (h' ys).resolve_right (absurd yt')\n    have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩\n    rw [← compl_union] at this\n    exact this.ne_empty htt'.disjoint_compl_right.inter_eq,\n    by\n    rintro h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩\n    rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter]\n    intro h'\n    have xv : x ∉ v := (h' xs).elim (absurd xu) id\n    have yu : y ∉ u := (h' ys).elim id (absurd yv)\n    have := h _ _ hu.isClosed_compl hv.isClosed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩\n    rw [← compl_union] at this\n    exact this.ne_empty huv.disjoint_compl_right.inter_eq⟩\n#align is_preconnected_closed_iff isPreconnected_closed_iff\n\ntheorem Inducing.isPreconnected_image [TopologicalSpace β] {s : Set α} {f : α → β}\n    (hf : Inducing f) : IsPreconnected (f '' s) ↔ IsPreconnected s := by\n  refine' ⟨fun h => _, fun h => h.image _ hf.continuous.continuousOn⟩\n  rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩\n  rcases hf.isOpen_iff.1 hu' with ⟨u, hu, rfl⟩\n  rcases hf.isOpen_iff.1 hv' with ⟨v, hv, rfl⟩\n  replace huv : f '' s ⊆ u ∪ v; · rwa [image_subset_iff]\n  rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩ with\n    ⟨_, ⟨z, hzs, rfl⟩, hzuv⟩\n  exact ⟨z, hzs, hzuv⟩\n#align inducing.is_preconnected_image Inducing.isPreconnected_image\n\n/- TODO: The following lemmas about connection of preimages hold more generally for strict maps\n(the quotient and subspace topologies of the image agree) whose fibers are preconnected. -/\ntheorem IsPreconnected.preimage_of_open_map [TopologicalSpace β] {s : Set β} (hs : IsPreconnected s)\n    {f : α → β} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) :\n    IsPreconnected (f ⁻¹' s) := fun u v hu hv hsuv hsu hsv => by\n  replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf\n  obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty\n  · refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_\n    · simpa only [hsf, image_union] using image_subset f hsuv\n    · simpa only [image_preimage_inter] using hsu.image f\n    · simpa only [image_preimage_inter] using hsv.image f\n  · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩\n#align is_preconnected.preimage_of_open_map IsPreconnected.preimage_of_open_map\n\ntheorem IsPreconnected.preimage_of_closed_map [TopologicalSpace β] {s : Set β}\n    (hs : IsPreconnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f)\n    (hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) :=\n  isPreconnected_closed_iff.2 fun u v hu hv hsuv hsu hsv => by\n    replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf\n    obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty\n    · refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_\n      · simpa only [hsf, image_union] using image_subset f hsuv\n      · simpa only [image_preimage_inter] using hsu.image f\n      · simpa only [image_preimage_inter] using hsv.image f\n    · exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩\n#align is_preconnected.preimage_of_closed_map IsPreconnected.preimage_of_closed_map\n\ntheorem IsConnected.preimage_of_openMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s)\n    {f : α → β} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) :\n    IsConnected (f ⁻¹' s) :=\n  ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_open_map hinj hf hsf⟩\n#align is_connected.preimage_of_open_map IsConnected.preimage_of_openMap\n\ntheorem IsConnected.preimage_of_closedMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s)\n    {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) :\n    IsConnected (f ⁻¹' s) :=\n  ⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_closed_map hinj hf hsf⟩\n#align is_connected.preimage_of_closed_map IsConnected.preimage_of_closedMap\n\ntheorem IsPreconnected.subset_or_subset (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v)\n    (hsuv : s ⊆ u ∪ v) (hs : IsPreconnected s) : s ⊆ u ∨ s ⊆ v := by\n  specialize hs u v hu hv hsuv\n  obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty\n  · exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv)\n  · replace hs := mt (hs hsu)\n    simp_rw [Set.not_nonempty_iff_eq_empty, ← Set.disjoint_iff_inter_eq_empty,\n      disjoint_iff_inter_eq_empty.1 huv] at hs\n    exact Or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv)\n#align is_preconnected.subset_or_subset IsPreconnected.subset_or_subset\n\ntheorem IsPreconnected.subset_left_of_subset_union (hu : IsOpen u) (hv : IsOpen v)\n    (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsu : (s ∩ u).Nonempty) (hs : IsPreconnected s) :\n    s ⊆ u :=\n  Disjoint.subset_left_of_subset_union hsuv\n    (by\n      by_contra hsv\n      rw [not_disjoint_iff_nonempty_inter] at hsv\n      obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv\n      exact Set.disjoint_iff.1 huv hx)\n#align is_preconnected.subset_left_of_subset_union IsPreconnected.subset_left_of_subset_union\n\ntheorem IsPreconnected.subset_right_of_subset_union (hu : IsOpen u) (hv : IsOpen v)\n    (huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsv : (s ∩ v).Nonempty) (hs : IsPreconnected s) :\n    s ⊆ v :=\n  hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v ▸ hsuv) hsv\n#align is_preconnected.subset_right_of_subset_union IsPreconnected.subset_right_of_subset_union\n\n-- porting note: moved up\n/-- Preconnected sets are either contained in or disjoint to any given clopen set. -/\ntheorem IsPreconnected.subset_clopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t)\n    (hne : (s ∩ t).Nonempty) : s ⊆ t :=\n  hs.subset_left_of_subset_union ht.isOpen ht.compl.isOpen disjoint_compl_right (by simp) hne\n#align is_preconnected.subset_clopen IsPreconnected.subset_clopen\n\n/-- If a preconnected set `s` intersects an open set `u`, and limit points of `u` inside `s` are\ncontained in `u`, then the whole set `s` is contained in `u`. -/\ntheorem IsPreconnected.subset_of_closure_inter_subset (hs : IsPreconnected s) (hu : IsOpen u)\n    (h'u : (s ∩ u).Nonempty) (h : closure u ∩ s ⊆ u) : s ⊆ u := by\n  have A : s ⊆ u ∪ closure uᶜ := by\n    intro x hx\n    by_cases xu : x ∈ u\n    · exact Or.inl xu\n    · right\n      intro h'x\n      exact xu (h (mem_inter h'x hx))\n  apply hs.subset_left_of_subset_union hu isClosed_closure.isOpen_compl _ A h'u\n  exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure)\n#align is_preconnected.subset_of_closure_inter_subset IsPreconnected.subset_of_closure_inter_subset\n\ntheorem IsPreconnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsPreconnected s)\n    (ht : IsPreconnected t) : IsPreconnected (s ×ˢ t) := by\n  apply isPreconnected_of_forall_pair\n  rintro ⟨a₁, b₁⟩ ⟨ha₁, hb₁⟩ ⟨a₂, b₂⟩ ⟨ha₂, hb₂⟩\n  refine' ⟨Prod.mk a₁ '' t ∪ flip Prod.mk b₂ '' s, _, .inl ⟨b₁, hb₁, rfl⟩, .inr ⟨a₂, ha₂, rfl⟩, _⟩\n  · rintro _ (⟨y, hy, rfl⟩ | ⟨x, hx, rfl⟩)\n    exacts [⟨ha₁, hy⟩, ⟨hx, hb₂⟩]\n  · exact (ht.image _ (Continuous.Prod.mk _).continuousOn).union (a₁, b₂) ⟨b₂, hb₂, rfl⟩\n      ⟨a₁, ha₁, rfl⟩ (hs.image _ (continuous_id.prod_mk continuous_const).continuousOn)\n#align is_preconnected.prod IsPreconnected.prod\n\ntheorem IsConnected.prod [TopologicalSpace β] {s : Set α} {t : Set β} (hs : IsConnected s)\n    (ht : IsConnected t) : IsConnected (s ×ˢ t) :=\n  ⟨hs.1.prod ht.1, hs.2.prod ht.2⟩\n#align is_connected.prod IsConnected.prod\n\ntheorem isPreconnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)}\n    (hs : ∀ i, IsPreconnected (s i)) : IsPreconnected (pi univ s) := by\n  rintro u v uo vo hsuv ⟨f, hfs, hfu⟩ ⟨g, hgs, hgv⟩\n  rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with ⟨I, hI⟩\n  induction' I using Finset.induction_on with i I _ ihI\n  · refine' ⟨g, hgs, ⟨_, hgv⟩⟩\n    simpa using hI\n  · rw [Finset.piecewise_insert] at hI\n    have := I.piecewise_mem_set_pi hfs hgs\n    refine' (hsuv this).elim ihI fun h => _\n    set S := update (I.piecewise f g) i '' s i\n    have hsub : S ⊆ pi univ s :=\n      by\n      refine' image_subset_iff.2 fun z hz => _\n      rwa [update_preimage_univ_pi]\n      exact fun j _ => this j trivial\n    have hconn : IsPreconnected S :=\n      (hs i).image _ (continuous_const.update i continuous_id).continuousOn\n    have hSu : (S ∩ u).Nonempty := ⟨_, mem_image_of_mem _ (hfs _ trivial), hI⟩\n    have hSv : (S ∩ v).Nonempty := ⟨_, ⟨_, this _ trivial, update_eq_self _ _⟩, h⟩\n    refine' (hconn u v uo vo (hsub.trans hsuv) hSu hSv).mono _\n    exact inter_subset_inter_left _ hsub\n#align is_preconnected_univ_pi isPreconnected_univ_pi\n\n@[simp]\ntheorem isConnected_univ_pi [∀ i, TopologicalSpace (π i)] {s : ∀ i, Set (π i)} :\n    IsConnected (pi univ s) ↔ ∀ i, IsConnected (s i) := by\n  simp only [IsConnected, ← univ_pi_nonempty_iff, forall_and, and_congr_right_iff]\n  refine' fun hne => ⟨fun hc i => _, isPreconnected_univ_pi⟩\n  rw [← eval_image_univ_pi hne]\n  exact hc.image _ (continuous_apply _).continuousOn\n#align is_connected_univ_pi isConnected_univ_pi\n\ntheorem Sigma.isConnected_iff [∀ i, TopologicalSpace (π i)] {s : Set (Σi, π i)} :\n    IsConnected s ↔ ∃ i t, IsConnected t ∧ s = Sigma.mk i '' t := by\n  refine' ⟨fun hs => _, _⟩\n  · obtain ⟨⟨i, x⟩, hx⟩ := hs.nonempty\n    have : s ⊆ range (Sigma.mk i) :=\n      hs.isPreconnected.subset_clopen isClopen_range_sigmaMk ⟨⟨i, x⟩, hx, x, rfl⟩\n    exact ⟨i, Sigma.mk i ⁻¹' s, hs.preimage_of_openMap sigma_mk_injective isOpenMap_sigmaMk this,\n      (Set.image_preimage_eq_of_subset this).symm⟩\n  · rintro ⟨i, t, ht, rfl⟩\n    exact ht.image _ continuous_sigmaMk.continuousOn\n#align sigma.is_connected_iff Sigma.isConnected_iff\n\ntheorem Sigma.isPreconnected_iff [hι : Nonempty ι] [∀ i, TopologicalSpace (π i)]\n    {s : Set (Σi, π i)} : IsPreconnected s ↔ ∃ i t, IsPreconnected t ∧ s = Sigma.mk i '' t := by\n  refine' ⟨fun hs => _, _⟩\n  · obtain rfl | h := s.eq_empty_or_nonempty\n    · exact ⟨Classical.choice hι, ∅, isPreconnected_empty, (Set.image_empty _).symm⟩\n    · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩\n      refine' ⟨a, t, ht.isPreconnected, rfl⟩\n  · rintro ⟨a, t, ht, rfl⟩\n    exact ht.image _ continuous_sigmaMk.continuousOn\n#align sigma.is_preconnected_iff Sigma.isPreconnected_iff\n\ntheorem Sum.isConnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :\n    IsConnected s ↔\n      (∃ t, IsConnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsConnected t ∧ s = Sum.inr '' t := by\n  refine' ⟨fun hs => _, _⟩\n  · obtain ⟨x | x, hx⟩ := hs.nonempty\n    · have h : s ⊆ range Sum.inl :=\n        hs.isPreconnected.subset_clopen isClopen_range_inl ⟨.inl x, hx, x, rfl⟩\n      refine' Or.inl ⟨Sum.inl ⁻¹' s, _, _⟩\n      · exact hs.preimage_of_openMap Sum.inl_injective isOpenMap_inl h\n      · exact (image_preimage_eq_of_subset h).symm\n    · have h : s ⊆ range Sum.inr :=\n        hs.isPreconnected.subset_clopen isClopen_range_inr ⟨.inr x, hx, x, rfl⟩\n      refine' Or.inr ⟨Sum.inr ⁻¹' s, _, _⟩\n      · exact hs.preimage_of_openMap Sum.inr_injective isOpenMap_inr h\n      · exact (image_preimage_eq_of_subset h).symm\n  · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩)\n    · exact ht.image _ continuous_inl.continuousOn\n    · exact ht.image _ continuous_inr.continuousOn\n#align sum.is_connected_iff Sum.isConnected_iff\n\ntheorem Sum.isPreconnected_iff [TopologicalSpace β] {s : Set (Sum α β)} :\n    IsPreconnected s ↔\n      (∃ t, IsPreconnected t ∧ s = Sum.inl '' t) ∨ ∃ t, IsPreconnected t ∧ s = Sum.inr '' t := by\n  refine' ⟨fun hs => _, _⟩\n  · obtain rfl | h := s.eq_empty_or_nonempty\n    · exact Or.inl ⟨∅, isPreconnected_empty, (Set.image_empty _).symm⟩\n    obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isConnected_iff.1 ⟨h, hs⟩\n    · exact Or.inl ⟨t, ht.isPreconnected, rfl⟩\n    · exact Or.inr ⟨t, ht.isPreconnected, rfl⟩\n  · rintro (⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩)\n    · exact ht.image _ continuous_inl.continuousOn\n    · exact ht.image _ continuous_inr.continuousOn\n#align sum.is_preconnected_iff Sum.isPreconnected_iff\n\n/-- The connected component of a point is the maximal connected set\nthat contains this point. -/\ndef connectedComponent (x : α) : Set α :=\n  ⋃₀ { s : Set α | IsPreconnected s ∧ x ∈ s }\n#align connected_component connectedComponent\n\n/-- Given a set `F` in a topological space `α` and a point `x : α`, the connected\ncomponent of `x` in `F` is the connected component of `x` in the subtype `F` seen as\na set in `α`. This definition does not make sense if `x` is not in `F` so we return the\nempty set in this case. -/\ndef connectedComponentIn (F : Set α) (x : α) : Set α :=\n  if h : x ∈ F then (↑) '' connectedComponent (⟨x, h⟩ : F) else ∅\n#align connected_component_in connectedComponentIn\n\ntheorem connectedComponentIn_eq_image {F : Set α} {x : α} (h : x ∈ F) :\n    connectedComponentIn F x = (↑) '' connectedComponent (⟨x, h⟩ : F) :=\n  dif_pos h\n#align connected_component_in_eq_image connectedComponentIn_eq_image\n\ntheorem connectedComponentIn_eq_empty {F : Set α} {x : α} (h : x ∉ F) :\n    connectedComponentIn F x = ∅ :=\n  dif_neg h\n#align connected_component_in_eq_empty connectedComponentIn_eq_empty\n\ntheorem mem_connectedComponent {x : α} : x ∈ connectedComponent x :=\n  mem_unionₛ_of_mem (mem_singleton x) ⟨isPreconnected_singleton, mem_singleton x⟩\n#align mem_connected_component mem_connectedComponent\n\ntheorem mem_connectedComponentIn {x : α} {F : Set α} (hx : x ∈ F) : x ∈ connectedComponentIn F x :=\n  by simp [connectedComponentIn_eq_image hx, mem_connectedComponent, hx]\n#align mem_connected_component_in mem_connectedComponentIn\n\ntheorem connectedComponent_nonempty {x : α} : (connectedComponent x).Nonempty :=\n  ⟨x, mem_connectedComponent⟩\n#align connected_component_nonempty connectedComponent_nonempty\n\ntheorem connectedComponentIn_nonempty_iff {x : α} {F : Set α} :\n    (connectedComponentIn F x).Nonempty ↔ x ∈ F := by\n  rw [connectedComponentIn]\n  split_ifs <;> simp [connectedComponent_nonempty, *]\n#align connected_component_in_nonempty_iff connectedComponentIn_nonempty_iff\n\ntheorem connectedComponentIn_subset (F : Set α) (x : α) : connectedComponentIn F x ⊆ F := by\n  rw [connectedComponentIn]\n  split_ifs <;> simp\n#align connected_component_in_subset connectedComponentIn_subset\n\ntheorem isPreconnected_connectedComponent {x : α} : IsPreconnected (connectedComponent x) :=\n  isPreconnected_unionₛ x _ (fun _ => And.right) fun _ => And.left\n#align is_preconnected_connected_component isPreconnected_connectedComponent\n\ntheorem isPreconnected_connectedComponentIn {x : α} {F : Set α} :\n    IsPreconnected (connectedComponentIn F x) := by\n  rw [connectedComponentIn]; split_ifs\n  · exact inducing_subtype_val.isPreconnected_image.mpr isPreconnected_connectedComponent\n  · exact isPreconnected_empty\n#align is_preconnected_connected_component_in isPreconnected_connectedComponentIn\n\ntheorem isConnected_connectedComponent {x : α} : IsConnected (connectedComponent x) :=\n  ⟨⟨x, mem_connectedComponent⟩, isPreconnected_connectedComponent⟩\n#align is_connected_connected_component isConnected_connectedComponent\n\ntheorem isConnected_connectedComponentIn_iff {x : α} {F : Set α} :\n    IsConnected (connectedComponentIn F x) ↔ x ∈ F := by\n  simp_rw [← connectedComponentIn_nonempty_iff, IsConnected, isPreconnected_connectedComponentIn,\n    and_true_iff]\n#align is_connected_connected_component_in_iff isConnected_connectedComponentIn_iff\n\ntheorem IsPreconnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsPreconnected s)\n    (H2 : x ∈ s) : s ⊆ connectedComponent x := fun _z hz => mem_unionₛ_of_mem hz ⟨H1, H2⟩\n#align is_preconnected.subset_connected_component IsPreconnected.subset_connectedComponent\n\ntheorem IsPreconnected.subset_connectedComponentIn {x : α} {F : Set α} (hs : IsPreconnected s)\n    (hxs : x ∈ s) (hsF : s ⊆ F) : s ⊆ connectedComponentIn F x := by\n  have : IsPreconnected (((↑) : F → α) ⁻¹' s) := by\n    refine' inducing_subtype_val.isPreconnected_image.mp _\n    rwa [Subtype.image_preimage_coe, inter_eq_left_iff_subset.mpr hsF]\n  have h2xs : (⟨x, hsF hxs⟩ : F) ∈ (↑) ⁻¹' s := by\n    rw [mem_preimage]\n    exact hxs\n  have := this.subset_connectedComponent h2xs\n  rw [connectedComponentIn_eq_image (hsF hxs)]\n  refine' Subset.trans _ (image_subset _ this)\n  rw [Subtype.image_preimage_coe, inter_eq_left_iff_subset.mpr hsF]\n#align is_preconnected.subset_connected_component_in IsPreconnected.subset_connectedComponentIn\n\ntheorem IsConnected.subset_connectedComponent {x : α} {s : Set α} (H1 : IsConnected s)\n    (H2 : x ∈ s) : s ⊆ connectedComponent x :=\n  H1.2.subset_connectedComponent H2\n#align is_connected.subset_connected_component IsConnected.subset_connectedComponent\n\ntheorem IsPreconnected.connectedComponentIn {x : α} {F : Set α} (h : IsPreconnected F)\n    (hx : x ∈ F) : connectedComponentIn F x = F :=\n  (connectedComponentIn_subset F x).antisymm (h.subset_connectedComponentIn hx subset_rfl)\n#align is_preconnected.connected_component_in IsPreconnected.connectedComponentIn\n\ntheorem connectedComponent_eq {x y : α} (h : y ∈ connectedComponent x) :\n    connectedComponent x = connectedComponent y :=\n  eq_of_subset_of_subset (isConnected_connectedComponent.subset_connectedComponent h)\n    (isConnected_connectedComponent.subset_connectedComponent\n      (Set.mem_of_mem_of_subset mem_connectedComponent\n        (isConnected_connectedComponent.subset_connectedComponent h)))\n#align connected_component_eq connectedComponent_eq\n\ntheorem connectedComponent_eq_iff_mem {x y : α} :\n    connectedComponent x = connectedComponent y ↔ x ∈ connectedComponent y :=\n  ⟨fun h => h ▸ mem_connectedComponent, fun h => (connectedComponent_eq h).symm⟩\n#align connected_component_eq_iff_mem connectedComponent_eq_iff_mem\n\ntheorem connectedComponentIn_eq {x y : α} {F : Set α} (h : y ∈ connectedComponentIn F x) :\n    connectedComponentIn F x = connectedComponentIn F y := by\n  have hx : x ∈ F := connectedComponentIn_nonempty_iff.mp ⟨y, h⟩\n  simp_rw [connectedComponentIn_eq_image hx] at h⊢\n  obtain ⟨⟨y, hy⟩, h2y, rfl⟩ := h\n  simp_rw [Subtype.coe_mk, connectedComponentIn_eq_image hy, connectedComponent_eq h2y]\n#align connected_component_in_eq connectedComponentIn_eq\n\ntheorem connectedComponentIn_univ (x : α) : connectedComponentIn univ x = connectedComponent x :=\n  subset_antisymm\n    (isPreconnected_connectedComponentIn.subset_connectedComponent <|\n      mem_connectedComponentIn trivial)\n    (isPreconnected_connectedComponent.subset_connectedComponentIn mem_connectedComponent <|\n      subset_univ _)\n#align connected_component_in_univ connectedComponentIn_univ\n\ntheorem connectedComponent_disjoint {x y : α} (h : connectedComponent x ≠ connectedComponent y) :\n    Disjoint (connectedComponent x) (connectedComponent y) :=\n  Set.disjoint_left.2 fun _ h1 h2 =>\n    h ((connectedComponent_eq h1).trans (connectedComponent_eq h2).symm)\n#align connected_component_disjoint connectedComponent_disjoint\n\ntheorem isClosed_connectedComponent {x : α} : IsClosed (connectedComponent x) :=\n  closure_subset_iff_isClosed.1 <|\n    isConnected_connectedComponent.closure.subset_connectedComponent <|\n      subset_closure mem_connectedComponent\n#align is_closed_connected_component isClosed_connectedComponent\n\ntheorem Continuous.image_connectedComponent_subset [TopologicalSpace β] {f : α → β}\n    (h : Continuous f) (a : α) : f '' connectedComponent a ⊆ connectedComponent (f a) :=\n  (isConnected_connectedComponent.image f h.continuousOn).subset_connectedComponent\n    ((mem_image f (connectedComponent a) (f a)).2 ⟨a, mem_connectedComponent, rfl⟩)\n#align continuous.image_connected_component_subset Continuous.image_connectedComponent_subset\n\ntheorem Continuous.mapsTo_connectedComponent [TopologicalSpace β] {f : α → β} (h : Continuous f)\n    (a : α) : MapsTo f (connectedComponent a) (connectedComponent (f a)) :=\n  mapsTo'.2 <| h.image_connectedComponent_subset a\n#align continuous.maps_to_connected_component Continuous.mapsTo_connectedComponent\n\ntheorem irreducibleComponent_subset_connectedComponent {x : α} :\n    irreducibleComponent x ⊆ connectedComponent x :=\n  isIrreducible_irreducibleComponent.isConnected.subset_connectedComponent mem_irreducibleComponent\n#align irreducible_component_subset_connected_component irreducibleComponent_subset_connectedComponent\n\n@[mono]\ntheorem connectedComponentIn_mono (x : α) {F G : Set α} (h : F ⊆ G) :\n    connectedComponentIn F x ⊆ connectedComponentIn G x := by\n  by_cases hx : x ∈ F\n  · rw [connectedComponentIn_eq_image hx, connectedComponentIn_eq_image (h hx), ←\n      show ((↑) : G → α) ∘ inclusion h = (↑) from rfl, image_comp]\n    exact image_subset _ ((continuous_inclusion h).image_connectedComponent_subset ⟨x, hx⟩)\n  · rw [connectedComponentIn_eq_empty hx]\n    exact Set.empty_subset _\n#align connected_component_in_mono connectedComponentIn_mono\n\n/-- A preconnected space is one where there is no non-trivial open partition. -/\nclass PreconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where\n  /-- The universal set `Set.univ` in a preconnected space is a preconnected set. -/\n  isPreconnected_univ : IsPreconnected (univ : Set α)\n#align preconnected_space PreconnectedSpace\n\nexport PreconnectedSpace (isPreconnected_univ)\n\n/-- A connected space is a nonempty one where there is no non-trivial open partition. -/\nclass ConnectedSpace (α : Type u) [TopologicalSpace α] extends PreconnectedSpace α : Prop where\n  /-- A connected space is nonempty. -/\n  toNonempty : Nonempty α\n#align connected_space ConnectedSpace\n\nattribute [instance] ConnectedSpace.toNonempty\n\n-- see Note [lower instance priority]\ntheorem isConnected_univ [ConnectedSpace α] : IsConnected (univ : Set α) :=\n  ⟨univ_nonempty, isPreconnected_univ⟩\n#align is_connected_univ isConnected_univ\n\ntheorem isPreconnected_range [TopologicalSpace β] [PreconnectedSpace α] {f : α → β}\n    (h : Continuous f) : IsPreconnected (range f) :=\n  @image_univ _ _ f ▸ isPreconnected_univ.image _ h.continuousOn\n#align is_preconnected_range isPreconnected_range\n\ntheorem isConnected_range [TopologicalSpace β] [ConnectedSpace α] {f : α → β} (h : Continuous f) :\n    IsConnected (range f) :=\n  ⟨range_nonempty f, isPreconnected_range h⟩\n#align is_connected_range isConnected_range\n\ntheorem DenseRange.preconnectedSpace [TopologicalSpace β] [PreconnectedSpace α] {f : α → β}\n    (hf : DenseRange f) (hc : Continuous f) : PreconnectedSpace β :=\n  ⟨hf.closure_eq ▸ (isPreconnected_range hc).closure⟩\n#align dense_range.preconnected_space DenseRange.preconnectedSpace\n\ntheorem connectedSpace_iff_connectedComponent :\n    ConnectedSpace α ↔ ∃ x : α, connectedComponent x = univ := by\n  constructor\n  · rintro ⟨⟨x⟩⟩\n    exact\n      ⟨x, eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)⟩\n  · rintro ⟨x, h⟩\n    haveI : PreconnectedSpace α :=\n      ⟨by rw [← h]; exact isPreconnected_connectedComponent⟩\n    exact ⟨⟨x⟩⟩\n#align connected_space_iff_connected_component connectedSpace_iff_connectedComponent\n\ntheorem preconnectedSpace_iff_connectedComponent :\n    PreconnectedSpace α ↔ ∀ x : α, connectedComponent x = univ := by\n  constructor\n  · intro h x\n    exact eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)\n  · intro h\n    cases' isEmpty_or_nonempty α with hα hα\n    · exact ⟨by rw [univ_eq_empty_iff.mpr hα]; exact isPreconnected_empty⟩\n    · exact ⟨by rw [← h (Classical.choice hα)]; exact isPreconnected_connectedComponent⟩\n#align preconnected_space_iff_connected_component preconnectedSpace_iff_connectedComponent\n\n@[simp]\ntheorem PreconnectedSpace.connectedComponent_eq_univ {X : Type _} [TopologicalSpace X]\n    [h : PreconnectedSpace X] (x : X) : connectedComponent x = univ :=\n  preconnectedSpace_iff_connectedComponent.mp h x\n#align preconnected_space.connected_component_eq_univ PreconnectedSpace.connectedComponent_eq_univ\n\ninstance [TopologicalSpace β] [PreconnectedSpace α] [PreconnectedSpace β] :\n    PreconnectedSpace (α × β) :=\n  ⟨by\n    rw [← univ_prod_univ]\n    exact isPreconnected_univ.prod isPreconnected_univ⟩\n\ninstance [TopologicalSpace β] [ConnectedSpace α] [ConnectedSpace β] : ConnectedSpace (α × β) :=\n  ⟨inferInstance⟩\n\ninstance [∀ i, TopologicalSpace (π i)] [∀ i, PreconnectedSpace (π i)] :\n    PreconnectedSpace (∀ i, π i) :=\n  ⟨by rw [← pi_univ univ]; exact isPreconnected_univ_pi fun i => isPreconnected_univ⟩\n\ninstance [∀ i, TopologicalSpace (π i)] [∀ i, ConnectedSpace (π i)] : ConnectedSpace (∀ i, π i) :=\n  ⟨inferInstance⟩\n\n-- see Note [lower instance priority]\ninstance (priority := 100) PreirreducibleSpace.preconnectedSpace (α : Type u) [TopologicalSpace α]\n    [PreirreducibleSpace α] : PreconnectedSpace α :=\n  ⟨isPreirreducible_univ.isPreconnected⟩\n#align preirreducible_space.preconnected_space PreirreducibleSpace.preconnectedSpace\n\n-- see Note [lower instance priority]\ninstance (priority := 100) IrreducibleSpace.connectedSpace (α : Type u) [TopologicalSpace α]\n    [IrreducibleSpace α] : ConnectedSpace α where toNonempty := IrreducibleSpace.toNonempty\n#align irreducible_space.connected_space IrreducibleSpace.connectedSpace\n\ntheorem nonempty_inter [PreconnectedSpace α] {s t : Set α} :\n    IsOpen s → IsOpen t → s ∪ t = univ → s.Nonempty → t.Nonempty → (s ∩ t).Nonempty := by\n  simpa only [univ_inter, univ_subset_iff] using @PreconnectedSpace.isPreconnected_univ α _ _ s t\n#align nonempty_inter nonempty_inter\n\ntheorem isClopen_iff [PreconnectedSpace α] {s : Set α} : IsClopen s ↔ s = ∅ ∨ s = univ :=\n  ⟨fun hs =>\n    by_contradiction fun h =>\n      have h1 : s ≠ ∅ ∧ sᶜ ≠ ∅ :=\n        ⟨mt Or.inl h,\n          mt (fun h2 => Or.inr <| (by rw [← compl_compl s, h2, compl_empty] : s = univ)) h⟩\n      let ⟨_, h2, h3⟩ :=\n        nonempty_inter hs.1 hs.2.isOpen_compl (union_compl_self s) (nonempty_iff_ne_empty.2 h1.1)\n          (nonempty_iff_ne_empty.2 h1.2)\n      h3 h2,\n    by rintro (rfl | rfl) <;> [exact isClopen_empty, exact isClopen_univ]⟩\n#align is_clopen_iff isClopen_iff\n\ntheorem IsClopen.eq_univ [PreconnectedSpace α] {s : Set α} (h' : IsClopen s) (h : s.Nonempty) :\n    s = univ :=\n  (isClopen_iff.mp h').resolve_left h.ne_empty\n#align is_clopen.eq_univ IsClopen.eq_univ\n\ntheorem frontier_eq_empty_iff [PreconnectedSpace α] {s : Set α} :\n    frontier s = ∅ ↔ s = ∅ ∨ s = univ :=\n  isClopen_iff_frontier_eq_empty.symm.trans isClopen_iff\n#align frontier_eq_empty_iff frontier_eq_empty_iff\n\ntheorem nonempty_frontier_iff [PreconnectedSpace α] {s : Set α} :\n    (frontier s).Nonempty ↔ s.Nonempty ∧ s ≠ univ := by\n  simp only [nonempty_iff_ne_empty, Ne.def, frontier_eq_empty_iff, not_or]\n#align nonempty_frontier_iff nonempty_frontier_iff\n\ntheorem Subtype.preconnectedSpace {s : Set α} (h : IsPreconnected s) : PreconnectedSpace s where\n  isPreconnected_univ := by\n    rwa [← inducing_subtype_val.isPreconnected_image, image_univ, Subtype.range_val]\n#align subtype.preconnected_space Subtype.preconnectedSpace\n\ntheorem Subtype.connectedSpace {s : Set α} (h : IsConnected s) : ConnectedSpace s where\n  toPreconnectedSpace := Subtype.preconnectedSpace h.isPreconnected\n  toNonempty := h.nonempty.to_subtype\n#align subtype.connected_space Subtype.connectedSpace\n\ntheorem isPreconnected_iff_preconnectedSpace {s : Set α} : IsPreconnected s ↔ PreconnectedSpace s :=\n  ⟨Subtype.preconnectedSpace, fun h => by\n    simpa using isPreconnected_univ.image ((↑) : s → α) continuous_subtype_val.continuousOn⟩\n#align is_preconnected_iff_preconnected_space isPreconnected_iff_preconnectedSpace\n\ntheorem isConnected_iff_connectedSpace {s : Set α} : IsConnected s ↔ ConnectedSpace s :=\n  ⟨Subtype.connectedSpace, fun h =>\n    ⟨nonempty_subtype.mp h.2, isPreconnected_iff_preconnectedSpace.mpr h.1⟩⟩\n#align is_connected_iff_connected_space isConnected_iff_connectedSpace\n\n/-- A set `s` is preconnected if and only if for every cover by two open sets that are disjoint on\n`s`, it is contained in one of the two covering sets. -/\ntheorem isPreconnected_iff_subset_of_disjoint {s : Set α} :\n    IsPreconnected s ↔\n      ∀ u v, IsOpen u → IsOpen v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v := by\n  constructor <;> intro h\n  · intro u v hu hv hs huv\n    specialize h u v hu hv hs\n    contrapose! huv\n    rw [← nonempty_iff_ne_empty]\n    simp [not_subset] at huv\n    rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩\n    have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu\n    have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv\n    exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩\n  · intro u v hu hv hs hsu hsv\n    rw [nonempty_iff_ne_empty]\n    intro H\n    specialize h u v hu hv hs H\n    contrapose H\n    apply Nonempty.ne_empty\n    cases' h with h h\n    · rcases hsv with ⟨x, hxs, hxv⟩\n      exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩\n    · rcases hsu with ⟨x, hxs, hxu⟩\n      exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩\n#align is_preconnected_iff_subset_of_disjoint isPreconnected_iff_subset_of_disjoint\n\n/-- A set `s` is connected if and only if\nfor every cover by a finite collection of open sets that are pairwise disjoint on `s`,\nit is contained in one of the members of the collection. -/\ntheorem isConnected_iff_unionₛ_disjoint_open {s : Set α} :\n    IsConnected s ↔\n      ∀ U : Finset (Set α), (∀ u v : Set α, u ∈ U → v ∈ U → (s ∩ (u ∩ v)).Nonempty → u = v) →\n        (∀ u ∈ U, IsOpen u) → (s ⊆ ⋃₀ ↑U) → ∃ u ∈ U, s ⊆ u := by\n  rw [IsConnected, isPreconnected_iff_subset_of_disjoint]\n  refine ⟨fun ⟨hne, h⟩ U hU hUo hsU => ?_, fun h => ⟨?_, fun u v hu hv hs hsuv => ?_⟩⟩\n  · induction U using Finset.induction_on\n    case empty => exact absurd (by simpa using hsU) hne.not_subset_empty\n    case insert u U uU IH =>\n      simp only [← ball_cond_comm, Finset.forall_mem_insert, Finset.exists_mem_insert,\n        Finset.coe_insert, unionₛ_insert, implies_true, true_and] at *\n      refine (h _ hUo.1 (⋃₀ ↑U) (isOpen_unionₛ hUo.2) hsU ?_).imp_right ?_\n      · refine subset_empty_iff.1 fun x ⟨hxs, hxu, v, hvU, hxv⟩ => ?_\n        exact ne_of_mem_of_not_mem hvU uU (hU.1 v hvU ⟨x, hxs, hxu, hxv⟩).symm\n      · exact IH (fun u hu => (hU.2 u hu).2) hUo.2\n  · simpa [subset_empty_iff, nonempty_iff_ne_empty] using h ∅\n  · rw [← not_nonempty_iff_eq_empty] at hsuv\n    have := hsuv; rw [inter_comm u] at this\n    simpa [*, or_imp, forall_and] using h {u, v}\n#align is_connected_iff_sUnion_disjoint_open isConnected_iff_unionₛ_disjoint_open\n\n-- porting note: `IsPreconnected.subset_clopen` moved up from here\n\n/-- Preconnected sets are either contained in or disjoint to any given clopen set. -/\ntheorem disjoint_or_subset_of_clopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t) :\n    Disjoint s t ∨ s ⊆ t :=\n  (disjoint_or_nonempty_inter s t).imp_right <| hs.subset_clopen ht\n#align disjoint_or_subset_of_clopen disjoint_or_subset_of_clopen\n\n/-- A set `s` is preconnected if and only if\nfor every cover by two closed sets that are disjoint on `s`,\nit is contained in one of the two covering sets. -/\ntheorem isPreconnected_iff_subset_of_disjoint_closed :\n    IsPreconnected s ↔\n      ∀ u v, IsClosed u → IsClosed v → s ⊆ u ∪ v → s ∩ (u ∩ v) = ∅ → s ⊆ u ∨ s ⊆ v := by\n  constructor <;> intro h\n  · intro u v hu hv hs huv\n    rw [isPreconnected_closed_iff] at h\n    specialize h u v hu hv hs\n    contrapose! huv\n    rw [← nonempty_iff_ne_empty]\n    simp [not_subset] at huv\n    rcases huv with ⟨⟨x, hxs, hxu⟩, ⟨y, hys, hyv⟩⟩\n    have hxv : x ∈ v := or_iff_not_imp_left.mp (hs hxs) hxu\n    have hyu : y ∈ u := or_iff_not_imp_right.mp (hs hys) hyv\n    exact h ⟨y, hys, hyu⟩ ⟨x, hxs, hxv⟩\n  · rw [isPreconnected_closed_iff]\n    intro u v hu hv hs hsu hsv\n    rw [nonempty_iff_ne_empty]\n    intro H\n    specialize h u v hu hv hs H\n    contrapose H\n    apply Nonempty.ne_empty\n    cases' h with h h\n    · rcases hsv with ⟨x, hxs, hxv⟩\n      exact ⟨x, hxs, ⟨h hxs, hxv⟩⟩\n    · rcases hsu with ⟨x, hxs, hxu⟩\n      exact ⟨x, hxs, ⟨hxu, h hxs⟩⟩\n#align is_preconnected_iff_subset_of_disjoint_closed isPreconnected_iff_subset_of_disjoint_closed\n\n/-- A closed set `s` is preconnected if and only if for every cover by two closed sets that are\ndisjoint, it is contained in one of the two covering sets. -/\ntheorem isPreconnected_iff_subset_of_fully_disjoint_closed {s : Set α} (hs : IsClosed s) :\n    IsPreconnected s ↔\n      ∀ u v, IsClosed u → IsClosed v → s ⊆ u ∪ v → Disjoint u v → s ⊆ u ∨ s ⊆ v := by\n  refine isPreconnected_iff_subset_of_disjoint_closed.trans ⟨?_, ?_⟩ <;> intro H u v hu hv hss huv\n  · apply H u v hu hv hss\n    rw [huv.inter_eq, inter_empty]\n  have H1 := H (u ∩ s) (v ∩ s)\n  rw [subset_inter_iff, subset_inter_iff] at H1\n  simp only [Subset.refl, and_true] at H1\n  apply H1 (hu.inter hs) (hv.inter hs)\n  · rw [← inter_distrib_right]\n    exact subset_inter hss Subset.rfl\n  · rwa [disjoint_iff_inter_eq_empty, ← inter_inter_distrib_right, inter_comm]\n#align is_preconnected_iff_subset_of_fully_disjoint_closed isPreconnected_iff_subset_of_fully_disjoint_closed\n\ntheorem IsClopen.connectedComponent_subset {x} (hs : IsClopen s) (hx : x ∈ s) :\n    connectedComponent x ⊆ s :=\n  isPreconnected_connectedComponent.subset_clopen hs ⟨x, mem_connectedComponent, hx⟩\n#align is_clopen.connected_component_subset IsClopen.connectedComponent_subset\n\n/-- The connected component of a point is always a subset of the intersection of all its clopen\nneighbourhoods. -/\ntheorem connectedComponent_subset_interᵢ_clopen {x : α} :\n    connectedComponent x ⊆ ⋂ Z : { Z : Set α // IsClopen Z ∧ x ∈ Z }, Z :=\n  subset_interᵢ fun Z => Z.2.1.connectedComponent_subset Z.2.2\n#align connected_component_subset_Inter_clopen connectedComponent_subset_interᵢ_clopen\n\n/-- A clopen set is the union of its connected components. -/\ntheorem IsClopen.bunionᵢ_connectedComponent_eq {Z : Set α} (h : IsClopen Z) :\n    (⋃ x ∈ Z, connectedComponent x) = Z :=\n  Subset.antisymm (unionᵢ₂_subset fun _ => h.connectedComponent_subset) fun _ h =>\n    mem_unionᵢ₂_of_mem h mem_connectedComponent\n#align is_clopen.bUnion_connected_component_eq IsClopen.bunionᵢ_connectedComponent_eq\n\n/-- The preimage of a connected component is preconnected if the function has connected fibers\nand a subset is closed iff the preimage is. -/\ntheorem preimage_connectedComponent_connected [TopologicalSpace β] {f : α → β}\n    (connected_fibers : ∀ t : β, IsConnected (f ⁻¹' {t}))\n    (hcl : ∀ T : Set β, IsClosed T ↔ IsClosed (f ⁻¹' T)) (t : β) :\n    IsConnected (f ⁻¹' connectedComponent t) := by\n  -- The following proof is essentially https://stacks.math.columbia.edu/tag/0377\n  -- although the statement is slightly different\n  have hf : Surjective f := Surjective.of_comp fun t : β => (connected_fibers t).1\n  refine ⟨Nonempty.preimage connectedComponent_nonempty hf, ?_⟩\n  have hT : IsClosed (f ⁻¹' connectedComponent t) :=\n    (hcl (connectedComponent t)).1 isClosed_connectedComponent\n  -- To show it's preconnected we decompose (f ⁻¹' connectedComponent t) as a subset of two\n  -- closed disjoint sets in α. We want to show that it's a subset of either.\n  rw [isPreconnected_iff_subset_of_fully_disjoint_closed hT]\n  intro u v hu hv huv uv_disj\n  -- To do this we decompose connectedComponent t into T₁ and T₂\n  -- we will show that connectedComponent t is a subset of either and hence\n  -- (f ⁻¹' connectedComponent t) is a subset of u or v\n  let T₁ := { t' ∈ connectedComponent t | f ⁻¹' {t'} ⊆ u }\n  let T₂ := { t' ∈ connectedComponent t | f ⁻¹' {t'} ⊆ v }\n  have fiber_decomp : ∀ t' ∈ connectedComponent t, f ⁻¹' {t'} ⊆ u ∨ f ⁻¹' {t'} ⊆ v := by\n    intro t' ht'\n    apply isPreconnected_iff_subset_of_disjoint_closed.1 (connected_fibers t').2 u v hu hv\n    · exact Subset.trans (preimage_mono (singleton_subset_iff.2 ht')) huv\n    rw [uv_disj.inter_eq, inter_empty]\n  have T₁_u : f ⁻¹' T₁ = f ⁻¹' connectedComponent t ∩ u := by\n    apply eq_of_subset_of_subset\n    · rw [← bunionᵢ_preimage_singleton]\n      refine' unionᵢ₂_subset fun t' ht' => subset_inter _ ht'.2\n      rw [hf.preimage_subset_preimage_iff, singleton_subset_iff]\n      exact ht'.1\n    rintro a ⟨hat, hau⟩\n    constructor\n    · exact mem_preimage.1 hat\n    refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_right fun h => ?_\n    exact uv_disj.subset_compl_right hau (h rfl)\n  -- This proof is exactly the same as the above (modulo some symmetry)\n  have T₂_v : f ⁻¹' T₂ = f ⁻¹' connectedComponent t ∩ v :=\n    by\n    apply eq_of_subset_of_subset\n    · rw [← bunionᵢ_preimage_singleton]\n      refine' unionᵢ₂_subset fun t' ht' => subset_inter _ ht'.2\n      rw [hf.preimage_subset_preimage_iff, singleton_subset_iff]\n      exact ht'.1\n    rintro a ⟨hat, hav⟩\n    constructor\n    · exact mem_preimage.1 hat\n    · refine (fiber_decomp (f a) (mem_preimage.1 hat)).resolve_left fun h => ?_\n      exact uv_disj.subset_compl_left hav (h rfl)\n  -- Now we show T₁, T₂ are closed, cover connectedComponent t and are disjoint.\n  have hT₁ : IsClosed T₁ := (hcl T₁).2 (T₁_u.symm ▸ IsClosed.inter hT hu)\n  have hT₂ : IsClosed T₂ := (hcl T₂).2 (T₂_v.symm ▸ IsClosed.inter hT hv)\n  have T_decomp : connectedComponent t ⊆ T₁ ∪ T₂ := fun t' ht' => by\n    rw [mem_union t' T₁ T₂]\n    cases' fiber_decomp t' ht' with htu htv\n    · left\n      exact ⟨ht', htu⟩\n    right\n    exact ⟨ht', htv⟩\n  have T_disjoint : Disjoint T₁ T₂ := by\n    refine' Disjoint.of_preimage hf _\n    rw [T₁_u, T₂_v, disjoint_iff_inter_eq_empty, ← inter_inter_distrib_left, uv_disj.inter_eq,\n      inter_empty]\n  -- Now we do cases on whether (connectedComponent t) is a subset of T₁ or T₂ to show\n  -- that the preimage is a subset of u or v.\n  cases' (isPreconnected_iff_subset_of_fully_disjoint_closed isClosed_connectedComponent).1\n    isPreconnected_connectedComponent T₁ T₂ hT₁ hT₂ T_decomp T_disjoint with h h\n  · left\n    rw [Subset.antisymm_iff] at T₁_u\n    suffices f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₁\n      from (this.trans T₁_u.1).trans (inter_subset_right _ _)\n    exact preimage_mono h\n  · right\n    rw [Subset.antisymm_iff] at T₂_v\n    suffices f ⁻¹' connectedComponent t ⊆ f ⁻¹' T₂\n      from (this.trans T₂_v.1).trans (inter_subset_right _ _)\n    exact preimage_mono h\n#align preimage_connected_component_connected preimage_connectedComponent_connected\n\ntheorem QuotientMap.preimage_connectedComponent [TopologicalSpace β] {f : α → β}\n    (hf : QuotientMap f) (h_fibers : ∀ y : β, IsConnected (f ⁻¹' {y})) (a : α) :\n    f ⁻¹' connectedComponent (f a) = connectedComponent a :=\n  ((preimage_connectedComponent_connected h_fibers (fun _ => hf.isClosed_preimage.symm)\n      _).subset_connectedComponent mem_connectedComponent).antisymm\n    (hf.continuous.mapsTo_connectedComponent a)\n#align quotient_map.preimage_connected_component QuotientMap.preimage_connectedComponent\n\ntheorem QuotientMap.image_connectedComponent [TopologicalSpace β] {f : α → β} (hf : QuotientMap f)\n    (h_fibers : ∀ y : β, IsConnected (f ⁻¹' {y})) (a : α) :\n    f '' connectedComponent a = connectedComponent (f a) := by\n  rw [← hf.preimage_connectedComponent h_fibers, image_preimage_eq _ hf.surjective]\n#align quotient_map.image_connected_component QuotientMap.image_connectedComponent\n\nend Preconnected\n\nsection LocallyConnectedSpace\n\n/-- A topological space is **locally connected** if each neighborhood filter admits a basis\nof connected *open* sets. Note that it is equivalent to each point having a basis of connected\n(non necessarily open) sets but in a non-trivial way, so we choose this definition and prove the\nequivalence later in `locallyConnectedSpace_iff_connected_basis`. -/\nclass LocallyConnectedSpace (α : Type _) [TopologicalSpace α] : Prop where\n  /-- Open connected neighborhoods form a basis of the neighborhoods filter. -/\n  open_connected_basis : ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id\n#align locally_connected_space LocallyConnectedSpace\n\ntheorem locallyConnectedSpace_iff_open_connected_basis :\n    LocallyConnectedSpace α ↔\n      ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id :=\n  ⟨@LocallyConnectedSpace.open_connected_basis _ _, LocallyConnectedSpace.mk⟩\n#align locally_connected_space_iff_open_connected_basis locallyConnectedSpace_iff_open_connected_basis\n\ntheorem locallyConnectedSpace_iff_open_connected_subsets :\n    LocallyConnectedSpace α ↔\n      ∀ x, ∀ U ∈ 𝓝 x, ∃ V : Set α, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V := by\n  simp_rw [locallyConnectedSpace_iff_open_connected_basis]\n  refine forall_congr' fun _ => ?_\n  constructor\n  · intro h U hU\n    rcases h.mem_iff.mp hU with ⟨V, hV, hVU⟩\n    exact ⟨V, hVU, hV⟩\n  · exact fun h => ⟨fun U => ⟨fun hU =>\n      let ⟨V, hVU, hV⟩ := h U hU\n      ⟨V, hV, hVU⟩, fun ⟨V, ⟨hV, hxV, _⟩, hVU⟩ => mem_nhds_iff.mpr ⟨V, hVU, hV, hxV⟩⟩⟩\n#align locally_connected_space_iff_open_connected_subsets locallyConnectedSpace_iff_open_connected_subsets\n\n/-- A space with discrete topology is a locally connected space. -/\ninstance (priority := 100) DiscreteTopology.toLocallyConnectedSpace (α) [TopologicalSpace α]\n    [DiscreteTopology α] : LocallyConnectedSpace α :=\n  locallyConnectedSpace_iff_open_connected_subsets.2 fun x _U hU =>\n    ⟨{x}, singleton_subset_iff.2 <| mem_of_mem_nhds hU, isOpen_discrete _, rfl,\n      isConnected_singleton⟩\n#align discrete_topology.to_locally_connected_space DiscreteTopology.toLocallyConnectedSpace\n\ntheorem connectedComponentIn_mem_nhds [LocallyConnectedSpace α] {F : Set α} {x : α} (h : F ∈ 𝓝 x) :\n    connectedComponentIn F x ∈ 𝓝 x := by\n  rw [(LocallyConnectedSpace.open_connected_basis x).mem_iff] at h\n  rcases h with ⟨s, ⟨h1s, hxs, h2s⟩, hsF⟩\n  exact mem_nhds_iff.mpr ⟨s, h2s.isPreconnected.subset_connectedComponentIn hxs hsF, h1s, hxs⟩\n#align connected_component_in_mem_nhds connectedComponentIn_mem_nhds\n\nprotected theorem IsOpen.connectedComponentIn [LocallyConnectedSpace α] {F : Set α} {x : α}\n    (hF : IsOpen F) : IsOpen (connectedComponentIn F x) := by\n  rw [isOpen_iff_mem_nhds]\n  intro y hy\n  rw [connectedComponentIn_eq hy]\n  exact connectedComponentIn_mem_nhds (hF.mem_nhds <| connectedComponentIn_subset F x hy)\n#align is_open.connected_component_in IsOpen.connectedComponentIn\n\ntheorem isOpen_connectedComponent [LocallyConnectedSpace α] {x : α} :\n    IsOpen (connectedComponent x) := by\n  rw [← connectedComponentIn_univ]\n  exact isOpen_univ.connectedComponentIn\n#align is_open_connected_component isOpen_connectedComponent\n\ntheorem isClopen_connectedComponent [LocallyConnectedSpace α] {x : α} :\n    IsClopen (connectedComponent x) :=\n  ⟨isOpen_connectedComponent, isClosed_connectedComponent⟩\n#align is_clopen_connected_component isClopen_connectedComponent\n\ntheorem locallyConnectedSpace_iff_connectedComponentIn_open :\n    LocallyConnectedSpace α ↔\n      ∀ F : Set α, IsOpen F → ∀ x ∈ F, IsOpen (connectedComponentIn F x) := by\n  constructor\n  · intro h\n    exact fun F hF x _ => hF.connectedComponentIn\n  · intro h\n    rw [locallyConnectedSpace_iff_open_connected_subsets]\n    refine' fun x U hU =>\n        ⟨connectedComponentIn (interior U) x,\n          (connectedComponentIn_subset _ _).trans interior_subset, h _ isOpen_interior x _,\n          mem_connectedComponentIn _, isConnected_connectedComponentIn_iff.mpr _⟩ <;>\n      exact mem_interior_iff_mem_nhds.mpr hU\n#align locally_connected_space_iff_connected_component_in_open locallyConnectedSpace_iff_connectedComponentIn_open\n\ntheorem locallyConnectedSpace_iff_connected_subsets :\n    LocallyConnectedSpace α ↔ ∀ (x : α), ∀ U ∈ 𝓝 x, ∃ V ∈ 𝓝 x, IsPreconnected V ∧ V ⊆ U := by\n  constructor\n  · rw [locallyConnectedSpace_iff_open_connected_subsets]\n    intro h x U hxU\n    rcases h x U hxU with ⟨V, hVU, hV₁, hxV, hV₂⟩\n    exact ⟨V, hV₁.mem_nhds hxV, hV₂.isPreconnected, hVU⟩\n  · rw [locallyConnectedSpace_iff_connectedComponentIn_open]\n    refine' fun h U hU x _ => isOpen_iff_mem_nhds.mpr fun y hy => _\n    rw [connectedComponentIn_eq hy]\n    rcases h y U (hU.mem_nhds <| (connectedComponentIn_subset _ _) hy) with ⟨V, hVy, hV, hVU⟩\n    exact Filter.mem_of_superset hVy (hV.subset_connectedComponentIn (mem_of_mem_nhds hVy) hVU)\n#align locally_connected_space_iff_connected_subsets locallyConnectedSpace_iff_connected_subsets\n\ntheorem locallyConnectedSpace_iff_connected_basis :\n    LocallyConnectedSpace α ↔\n      ∀ x, (𝓝 x).HasBasis (fun s : Set α => s ∈ 𝓝 x ∧ IsPreconnected s) id := by\n  rw [locallyConnectedSpace_iff_connected_subsets]\n  exact forall_congr' <| fun x => Filter.hasBasis_self.symm\n#align locally_connected_space_iff_connected_basis locallyConnectedSpace_iff_connected_basis\n\ntheorem locallyConnectedSpace_of_connected_bases {ι : Type _} (b : α → ι → Set α) (p : α → ι → Prop)\n    (hbasis : ∀ x, (𝓝 x).HasBasis (p x) (b x))\n    (hconnected : ∀ x i, p x i → IsPreconnected (b x i)) : LocallyConnectedSpace α := by\n  rw [locallyConnectedSpace_iff_connected_basis]\n  exact fun x =>\n    (hbasis x).to_hasBasis\n      (fun i hi => ⟨b x i, ⟨(hbasis x).mem_of_mem hi, hconnected x i hi⟩, subset_rfl⟩) fun s hs =>\n      ⟨(hbasis x).index s hs.1, ⟨(hbasis x).property_index hs.1, (hbasis x).set_index_subset hs.1⟩⟩\n#align locally_connected_space_of_connected_bases locallyConnectedSpace_of_connected_bases\n\nend LocallyConnectedSpace\n\nsection TotallyDisconnected\n\n/-- A set `s` is called totally disconnected if every subset `t ⊆ s` which is preconnected is\na subsingleton, ie either empty or a singleton.-/\ndef IsTotallyDisconnected (s : Set α) : Prop :=\n  ∀ t, t ⊆ s → IsPreconnected t → t.Subsingleton\n#align is_totally_disconnected IsTotallyDisconnected\n\ntheorem isTotallyDisconnected_empty : IsTotallyDisconnected (∅ : Set α) := fun _ ht _ _ x_in _ _ =>\n  (ht x_in).elim\n#align is_totally_disconnected_empty isTotallyDisconnected_empty\n\ntheorem isTotallyDisconnected_singleton {x} : IsTotallyDisconnected ({x} : Set α) := fun _ ht _ =>\n  subsingleton_singleton.anti ht\n#align is_totally_disconnected_singleton isTotallyDisconnected_singleton\n\n/-- A space is totally disconnected if all of its connected components are singletons. -/\nclass TotallyDisconnectedSpace (α : Type u) [TopologicalSpace α] : Prop where\n  /-- The universal set `Set.univ` in a totally disconnected space is totally disconnected. -/\n  isTotallyDisconnected_univ : IsTotallyDisconnected (univ : Set α)\n#align totally_disconnected_space TotallyDisconnectedSpace\n\ntheorem IsPreconnected.subsingleton [TotallyDisconnectedSpace α] {s : Set α}\n    (h : IsPreconnected s) : s.Subsingleton :=\n  TotallyDisconnectedSpace.isTotallyDisconnected_univ s (subset_univ s) h\n#align is_preconnected.subsingleton IsPreconnected.subsingleton\n\ninstance Pi.totallyDisconnectedSpace {α : Type _} {β : α → Type _}\n    [∀ a, TopologicalSpace (β a)] [∀ a, TotallyDisconnectedSpace (β a)] :\n    TotallyDisconnectedSpace (∀ a : α, β a) :=\n  ⟨fun t _ h2 =>\n    have this : ∀ a, IsPreconnected ((fun x : ∀ a, β a => x a) '' t) := fun a =>\n      h2.image (fun x => x a) (continuous_apply a).continuousOn\n    fun x x_in y y_in => funext fun a => (this a).subsingleton ⟨x, x_in, rfl⟩ ⟨y, y_in, rfl⟩⟩\n#align pi.totally_disconnected_space Pi.totallyDisconnectedSpace\n\ninstance Prod.totallyDisconnectedSpace [TopologicalSpace β] [TotallyDisconnectedSpace α]\n    [TotallyDisconnectedSpace β] : TotallyDisconnectedSpace (α × β) :=\n  ⟨fun t _ h2 =>\n    have H1 : IsPreconnected (Prod.fst '' t) := h2.image Prod.fst continuous_fst.continuousOn\n    have H2 : IsPreconnected (Prod.snd '' t) := h2.image Prod.snd continuous_snd.continuousOn\n    fun x hx y hy =>\n    Prod.ext (H1.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)\n      (H2.subsingleton ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩)⟩\n#align prod.totally_disconnected_space Prod.totallyDisconnectedSpace\n\ninstance [TopologicalSpace β] [TotallyDisconnectedSpace α] [TotallyDisconnectedSpace β] :\n    TotallyDisconnectedSpace (Sum α β) := by\n  refine' ⟨fun s _ hs => _⟩\n  obtain ⟨t, ht, rfl⟩ | ⟨t, ht, rfl⟩ := Sum.isPreconnected_iff.1 hs\n  · exact ht.subsingleton.image _\n  · exact ht.subsingleton.image _\n\ninstance [∀ i, TopologicalSpace (π i)] [∀ i, TotallyDisconnectedSpace (π i)] :\n    TotallyDisconnectedSpace (Σi, π i) := by\n  refine' ⟨fun s _ hs => _⟩\n  obtain rfl | h := s.eq_empty_or_nonempty\n  · exact subsingleton_empty\n  · obtain ⟨a, t, ht, rfl⟩ := Sigma.isConnected_iff.1 ⟨h, hs⟩\n    exact ht.isPreconnected.subsingleton.image _\n\n-- porting note: reformulated using `Pairwise`\n/-- Let `X` be a topological space, and suppose that for all distinct `x,y ∈ X`, there\n  is some clopen set `U` such that `x ∈ U` and `y ∉ U`. Then `X` is totally disconnected. -/\ntheorem isTotallyDisconnected_of_clopen_set {X : Type _} [TopologicalSpace X]\n    (hX : Pairwise fun x y => ∃ (U : Set X), IsClopen U ∧ x ∈ U ∧ y ∉ U) :\n    IsTotallyDisconnected (Set.univ : Set X) := by\n  rintro S - hS\n  unfold Set.Subsingleton\n  by_contra' h_contra\n  rcases h_contra with ⟨x, hx, y, hy, hxy⟩\n  obtain ⟨U, h_clopen, hxU, hyU⟩ := hX hxy\n  specialize\n    hS U (Uᶜ) h_clopen.1 h_clopen.compl.1 (fun a _ => em (a ∈ U)) ⟨x, hx, hxU⟩ ⟨y, hy, hyU⟩\n  rw [inter_compl_self, Set.inter_empty] at hS\n  exact Set.not_nonempty_empty hS\n#align is_totally_disconnected_of_clopen_set isTotallyDisconnected_of_clopen_set\n\n/-- A space is totally disconnected iff its connected components are subsingletons. -/\ntheorem totallyDisconnectedSpace_iff_connectedComponent_subsingleton :\n    TotallyDisconnectedSpace α ↔ ∀ x : α, (connectedComponent x).Subsingleton := by\n  constructor\n  · intro h x\n    apply h.1\n    · exact subset_univ _\n    exact isPreconnected_connectedComponent\n  intro h; constructor\n  intro s s_sub hs\n  rcases eq_empty_or_nonempty s with (rfl | ⟨x, x_in⟩)\n  · exact subsingleton_empty\n  · exact (h x).anti (hs.subset_connectedComponent x_in)\n#align totally_disconnected_space_iff_connected_component_subsingleton totallyDisconnectedSpace_iff_connectedComponent_subsingleton\n\n/-- A space is totally disconnected iff its connected components are singletons. -/\ntheorem totallyDisconnectedSpace_iff_connectedComponent_singleton :\n    TotallyDisconnectedSpace α ↔ ∀ x : α, connectedComponent x = {x} := by\n  rw [totallyDisconnectedSpace_iff_connectedComponent_subsingleton]\n  refine forall_congr' fun x => ?_\n  rw [subsingleton_iff_singleton]\n  exact mem_connectedComponent\n#align totally_disconnected_space_iff_connected_component_singleton totallyDisconnectedSpace_iff_connectedComponent_singleton\n\n@[simp] theorem connectedComponent_eq_singleton [TotallyDisconnectedSpace α] (x : α) :\n    connectedComponent x = {x} :=\n  totallyDisconnectedSpace_iff_connectedComponent_singleton.1 ‹_› x\n#align connected_component_eq_singleton connectedComponent_eq_singleton\n\n/-- The image of a connected component in a totally disconnected space is a singleton. -/\n@[simp]\ntheorem Continuous.image_connectedComponent_eq_singleton {β : Type _} [TopologicalSpace β]\n    [TotallyDisconnectedSpace β] {f : α → β} (h : Continuous f) (a : α) :\n    f '' connectedComponent a = {f a} :=\n  (Set.subsingleton_iff_singleton <| mem_image_of_mem f mem_connectedComponent).mp\n    (isPreconnected_connectedComponent.image f h.continuousOn).subsingleton\n#align continuous.image_connected_component_eq_singleton Continuous.image_connectedComponent_eq_singleton\n\ntheorem isTotallyDisconnected_of_totallyDisconnectedSpace [TotallyDisconnectedSpace α] (s : Set α) :\n    IsTotallyDisconnected s := fun t _ ht =>\n  TotallyDisconnectedSpace.isTotallyDisconnected_univ _ t.subset_univ ht\n#align is_totally_disconnected_of_totally_disconnected_space isTotallyDisconnected_of_totallyDisconnectedSpace\n\ntheorem isTotallyDisconnected_of_image [TopologicalSpace β] {f : α → β} (hf : ContinuousOn f s)\n    (hf' : Injective f) (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s :=\n  fun _t hts ht _x x_in _y y_in =>\n  hf' <|\n    h _ (image_subset f hts) (ht.image f <| hf.mono hts) (mem_image_of_mem f x_in)\n      (mem_image_of_mem f y_in)\n#align is_totally_disconnected_of_image isTotallyDisconnected_of_image\n\ntheorem Embedding.isTotallyDisconnected [TopologicalSpace β] {f : α → β} (hf : Embedding f)\n    {s : Set α} (h : IsTotallyDisconnected (f '' s)) : IsTotallyDisconnected s :=\n  isTotallyDisconnected_of_image hf.continuous.continuousOn hf.inj h\n#align embedding.is_totally_disconnected Embedding.isTotallyDisconnected\n\ninstance Subtype.totallyDisconnectedSpace {α : Type _} {p : α → Prop} [TopologicalSpace α]\n    [TotallyDisconnectedSpace α] : TotallyDisconnectedSpace (Subtype p) :=\n  ⟨embedding_subtype_val.isTotallyDisconnected\n      (isTotallyDisconnected_of_totallyDisconnectedSpace _)⟩\n#align subtype.totally_disconnected_space Subtype.totallyDisconnectedSpace\n\nend TotallyDisconnected\n\nsection TotallySeparated\n\n-- todo: reformulate using `Set.Pairwise`\n/-- A set `s` is called totally separated if any two points of this set can be separated\nby two disjoint open sets covering `s`. -/\ndef IsTotallySeparated (s : Set α) : Prop :=\n  ∀ x ∈ s, ∀ y ∈ s, x ≠ y →\n    ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ x ∈ u ∧ y ∈ v ∧ s ⊆ u ∪ v ∧ Disjoint u v\n#align is_totally_separated IsTotallySeparated\n\ntheorem isTotallySeparated_empty : IsTotallySeparated (∅ : Set α) := fun _ => False.elim\n#align is_totally_separated_empty isTotallySeparated_empty\n\ntheorem isTotallySeparated_singleton {x} : IsTotallySeparated ({x} : Set α) := fun _ hp _ hq hpq =>\n  (hpq <| (eq_of_mem_singleton hp).symm ▸ (eq_of_mem_singleton hq).symm).elim\n#align is_totally_separated_singleton isTotallySeparated_singleton\n\ntheorem isTotallyDisconnected_of_isTotallySeparated {s : Set α} (H : IsTotallySeparated s) :\n    IsTotallyDisconnected s := by\n  intro t hts ht x x_in y y_in\n  by_contra h\n  obtain\n    ⟨u : Set α, v : Set α, hu : IsOpen u, hv : IsOpen v, hxu : x ∈ u, hyv : y ∈ v, hs : s ⊆ u ∪ v,\n      huv⟩ :=\n    H x (hts x_in) y (hts y_in) h\n  refine' (ht _ _ hu hv (hts.trans hs) ⟨x, x_in, hxu⟩ ⟨y, y_in, hyv⟩).ne_empty _\n  rw [huv.inter_eq, inter_empty]\n#align is_totally_disconnected_of_is_totally_separated isTotallyDisconnected_of_isTotallySeparated\n\nalias isTotallyDisconnected_of_isTotallySeparated ← IsTotallySeparated.isTotallyDisconnected\n#align is_totally_separated.is_totally_disconnected IsTotallySeparated.isTotallyDisconnected\n\n/-- A space is totally separated if any two points can be separated by two disjoint open sets\ncovering the whole space. -/\nclass TotallySeparatedSpace (α : Type u) [TopologicalSpace α] : Prop where\n  /-- The universal set `Set.univ` in a totally separated space is totally separated. -/\n  isTotallySeparated_univ : IsTotallySeparated (univ : Set α)\n#align totally_separated_space TotallySeparatedSpace\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.totallyDisconnectedSpace (α : Type u)\n    [TopologicalSpace α] [TotallySeparatedSpace α] : TotallyDisconnectedSpace α :=\n  ⟨TotallySeparatedSpace.isTotallySeparated_univ.isTotallyDisconnected⟩\n#align totally_separated_space.totally_disconnected_space TotallySeparatedSpace.totallyDisconnectedSpace\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.of_discrete (α : Type _) [TopologicalSpace α]\n    [DiscreteTopology α] : TotallySeparatedSpace α :=\n  ⟨fun _ _ b _ h => ⟨{b}ᶜ, {b}, isOpen_discrete _, isOpen_discrete _, h, rfl,\n    (compl_union_self _).symm.subset, disjoint_compl_left⟩⟩\n#align totally_separated_space.of_discrete TotallySeparatedSpace.of_discrete\n\ntheorem exists_clopen_of_totally_separated {α : Type _} [TopologicalSpace α]\n    [TotallySeparatedSpace α] {x y : α} (hxy : x ≠ y) :\n    ∃ U : Set α, IsClopen U ∧ x ∈ U ∧ y ∈ Uᶜ := by\n  obtain ⟨U, V, hU, hV, Ux, Vy, f, disj⟩ :=\n    TotallySeparatedSpace.isTotallySeparated_univ x (Set.mem_univ x) y (Set.mem_univ y) hxy\n  have clopen_U := isClopen_inter_of_disjoint_cover_clopen isClopen_univ f hU hV disj\n  rw [univ_inter _] at clopen_U\n  rw [← Set.subset_compl_iff_disjoint_right, subset_compl_comm] at disj\n  exact ⟨U, clopen_U, Ux, disj Vy⟩\n#align exists_clopen_of_totally_separated exists_clopen_of_totally_separated\n\nend TotallySeparated\n\nsection connectedComponentSetoid\n\n/-- The setoid of connected components of a topological space -/\ndef connectedComponentSetoid (α : Type _) [TopologicalSpace α] : Setoid α :=\n  ⟨fun x y => connectedComponent x = connectedComponent y,\n    ⟨fun x => by trivial, fun h1 => h1.symm, fun h1 h2 => h1.trans h2⟩⟩\n#align connected_component_setoid connectedComponentSetoid\n\n/-- The quotient of a space by its connected components -/\ndef ConnectedComponents (α : Type u) [TopologicalSpace α] :=\n  Quotient (connectedComponentSetoid α)\n#align connected_components ConnectedComponents\n\nnamespace ConnectedComponents\n\n/-- Coersion from a topological space to the set of connected components of this space. -/\ndef mk : α → ConnectedComponents α := Quotient.mk''\n\ninstance : CoeTC α (ConnectedComponents α) := ⟨mk⟩\n\n@[simp]\ntheorem coe_eq_coe {x y : α} :\n    (x : ConnectedComponents α) = y ↔ connectedComponent x = connectedComponent y :=\n  Quotient.eq''\n#align connected_components.coe_eq_coe ConnectedComponents.coe_eq_coe\n\ntheorem coe_ne_coe {x y : α} :\n    (x : ConnectedComponents α) ≠ y ↔ connectedComponent x ≠ connectedComponent y :=\n  coe_eq_coe.not\n#align connected_components.coe_ne_coe ConnectedComponents.coe_ne_coe\n\ntheorem coe_eq_coe' {x y : α} : (x : ConnectedComponents α) = y ↔ x ∈ connectedComponent y :=\n  coe_eq_coe.trans connectedComponent_eq_iff_mem\n#align connected_components.coe_eq_coe' ConnectedComponents.coe_eq_coe'\n\ninstance [Inhabited α] : Inhabited (ConnectedComponents α) :=\n  ⟨mk default⟩\n\ninstance : TopologicalSpace (ConnectedComponents α) :=\n  inferInstanceAs (TopologicalSpace (Quotient _))\n\ntheorem surjective_coe : Surjective (mk : α → ConnectedComponents α) :=\n  surjective_quot_mk _\n#align connected_components.surjective_coe ConnectedComponents.surjective_coe\n\ntheorem quotientMap_coe : QuotientMap (mk : α → ConnectedComponents α) :=\n  quotientMap_quot_mk\n#align connected_components.quotient_map_coe ConnectedComponents.quotientMap_coe\n\n@[continuity]\ntheorem continuous_coe : Continuous (mk : α → ConnectedComponents α) :=\n  quotientMap_coe.continuous\n#align connected_components.continuous_coe ConnectedComponents.continuous_coe\n\n@[simp]\ntheorem range_coe : range (mk : α → ConnectedComponents α) = univ :=\n  surjective_coe.range_eq\n#align connected_components.range_coe ConnectedComponents.range_coe\n\nend ConnectedComponents\n\nvariable [TopologicalSpace β] [TotallyDisconnectedSpace β] {f : α → β}\n\ntheorem Continuous.image_eq_of_connectedComponent_eq (h : Continuous f) (a b : α)\n    (hab : connectedComponent a = connectedComponent b) : f a = f b :=\n  singleton_eq_singleton_iff.1 <|\n    h.image_connectedComponent_eq_singleton a ▸\n      h.image_connectedComponent_eq_singleton b ▸ hab ▸ rfl\n#align continuous.image_eq_of_connected_component_eq Continuous.image_eq_of_connectedComponent_eq\n\n/--\nThe lift to `connectedComponents α` of a continuous map from `α` to a totally disconnected space\n-/\ndef Continuous.connectedComponentsLift (h : Continuous f) : ConnectedComponents α → β := fun x =>\n  Quotient.liftOn' x f h.image_eq_of_connectedComponent_eq\n#align continuous.connected_components_lift Continuous.connectedComponentsLift\n\n@[continuity]\ntheorem Continuous.connectedComponentsLift_continuous (h : Continuous f) :\n    Continuous h.connectedComponentsLift :=\n  h.quotient_liftOn' <| by convert h.image_eq_of_connectedComponent_eq\n#align continuous.connected_components_lift_continuous Continuous.connectedComponentsLift_continuous\n\n@[simp]\ntheorem Continuous.connectedComponentsLift_apply_coe (h : Continuous f) (x : α) :\n    h.connectedComponentsLift x = f x :=\n  rfl\n#align continuous.connected_components_lift_apply_coe Continuous.connectedComponentsLift_apply_coe\n\n@[simp]\ntheorem Continuous.connectedComponentsLift_comp_coe (h : Continuous f) :\n    h.connectedComponentsLift ∘ (↑) = f :=\n  rfl\n#align continuous.connected_components_lift_comp_coe Continuous.connectedComponentsLift_comp_coe\n\ntheorem connectedComponents_lift_unique' {β : Sort _} {g₁ g₂ : ConnectedComponents α → β}\n    (hg : g₁ ∘ ((↑) : α → ConnectedComponents α) = g₂ ∘ (↑)) : g₁ = g₂ :=\n  ConnectedComponents.surjective_coe.injective_comp_right hg\n#align connected_components_lift_unique' connectedComponents_lift_unique'\n\ntheorem Continuous.connectedComponentsLift_unique (h : Continuous f) (g : ConnectedComponents α → β)\n    (hg : g ∘ (↑) = f) : g = h.connectedComponentsLift :=\n  connectedComponents_lift_unique' <| hg.trans h.connectedComponentsLift_comp_coe.symm\n#align continuous.connected_components_lift_unique Continuous.connectedComponentsLift_unique\n\n/-- The preimage of a singleton in `connectedComponents` is the connected component\nof an element in the equivalence class. -/\ntheorem connectedComponents_preimage_singleton {x : α} :\n    (↑) ⁻¹' ({↑x} : Set (ConnectedComponents α)) = connectedComponent x := by\n  ext y\n  rw [mem_preimage, mem_singleton_iff, ConnectedComponents.coe_eq_coe']\n#align connected_components_preimage_singleton connectedComponents_preimage_singleton\n\n/-- The preimage of the image of a set under the quotient map to `connectedComponents α`\nis the union of the connected components of the elements in it. -/\ntheorem connectedComponents_preimage_image (U : Set α) :\n    (↑) ⁻¹' ((↑) '' U : Set (ConnectedComponents α)) = ⋃ x ∈ U, connectedComponent x := by\n  simp only [connectedComponents_preimage_singleton, preimage_unionᵢ₂, image_eq_unionᵢ]\n#align connected_components_preimage_image connectedComponents_preimage_image\n\ninstance ConnectedComponents.totallyDisconnectedSpace :\n    TotallyDisconnectedSpace (ConnectedComponents α) := by\n  rw [totallyDisconnectedSpace_iff_connectedComponent_singleton]\n  refine' ConnectedComponents.surjective_coe.forall.2 fun x => _\n  rw [← ConnectedComponents.quotientMap_coe.image_connectedComponent, ←\n    connectedComponents_preimage_singleton, image_preimage_eq _ ConnectedComponents.surjective_coe]\n  refine' ConnectedComponents.surjective_coe.forall.2 fun y => _\n  rw [connectedComponents_preimage_singleton]\n  exact isConnected_connectedComponent\n#align connected_components.totally_disconnected_space ConnectedComponents.totallyDisconnectedSpace\n\n/-- Functoriality of `connectedComponents` -/\ndef Continuous.connectedComponentsMap {β : Type _} [TopologicalSpace β] {f : α → β}\n    (h : Continuous f) : ConnectedComponents α → ConnectedComponents β :=\n  Continuous.connectedComponentsLift (ConnectedComponents.continuous_coe.comp h)\n#align continuous.connected_components_map Continuous.connectedComponentsMap\n\ntheorem Continuous.connectedComponentsMap_continuous {β : Type _} [TopologicalSpace β] {f : α → β}\n    (h : Continuous f) : Continuous h.connectedComponentsMap :=\n  Continuous.connectedComponentsLift_continuous (ConnectedComponents.continuous_coe.comp h)\n#align continuous.connected_components_map_continuous Continuous.connectedComponentsMap_continuous\n\nend connectedComponentSetoid\n\n/-- A preconnected set `s` has the property that every map to a\ndiscrete space that is continuous on `s` is constant on `s` -/\ntheorem IsPreconnected.constant {Y : Type _} [TopologicalSpace Y] [DiscreteTopology Y] {s : Set α}\n    (hs : IsPreconnected s) {f : α → Y} (hf : ContinuousOn f s) {x y : α} (hx : x ∈ s)\n    (hy : y ∈ s) : f x = f y :=\n  (hs.image f hf).subsingleton (mem_image_of_mem f hx) (mem_image_of_mem f hy)\n#align is_preconnected.constant IsPreconnected.constant\n\n/-- If every map to `Bool` (a discrete two-element space), that is\ncontinuous on a set `s`, is constant on s, then s is preconnected -/\ntheorem isPreconnected_of_forall_constant {s : Set α}\n    (hs : ∀ f : α → Bool, ContinuousOn f s → ∀ x ∈ s, ∀ y ∈ s, f x = f y) : IsPreconnected s := by\n  unfold IsPreconnected\n  by_contra'\n  rcases this with ⟨u, v, u_op, v_op, hsuv, ⟨x, x_in_s, x_in_u⟩, ⟨y, y_in_s, y_in_v⟩, H⟩\n  rw [not_nonempty_iff_eq_empty] at H\n  have hy : y ∉ u := fun y_in_u => eq_empty_iff_forall_not_mem.mp H y ⟨y_in_s, ⟨y_in_u, y_in_v⟩⟩\n  have : ContinuousOn u.boolIndicator s := by\n    apply (continuousOn_boolIndicator_iff_clopen _ _).mpr ⟨_, _⟩\n    · exact u_op.preimage continuous_subtype_val\n    · rw [preimage_subtype_coe_eq_compl hsuv H]\n      exact (v_op.preimage continuous_subtype_val).isClosed_compl\n  simpa [(u.mem_iff_boolIndicator _).mp x_in_u, (u.not_mem_iff_boolIndicator _).mp hy] using\n    hs _ this x x_in_s y y_in_s\n#align is_preconnected_of_forall_constant isPreconnected_of_forall_constant\n\n/-- A `PreconnectedSpace` version of `isPreconnected.constant` -/\ntheorem PreconnectedSpace.constant {Y : Type _} [TopologicalSpace Y] [DiscreteTopology Y]\n    (hp : PreconnectedSpace α) {f : α → Y} (hf : Continuous f) {x y : α} : f x = f y :=\n  IsPreconnected.constant hp.isPreconnected_univ (Continuous.continuousOn hf) trivial trivial\n#align preconnected_space.constant PreconnectedSpace.constant\n\n/-- A `PreconnectedSpace` version of `isPreconnected_of_forall_constant` -/\ntheorem preconnectedSpace_of_forall_constant\n    (hs : ∀ f : α → Bool, Continuous f → ∀ x y, f x = f y) : PreconnectedSpace α :=\n  ⟨isPreconnected_of_forall_constant fun f hf x _ y _ =>\n      hs f (continuous_iff_continuousOn_univ.mpr hf) x y⟩\n#align preconnected_space_of_forall_constant preconnectedSpace_of_forall_constant\n\n/-- Refinement of `IsPreconnected.constant` only assuming the map factors through a\ndiscrete subset of the target. -/\ntheorem IsPreconnected.constant_of_mapsTo [TopologicalSpace β] {S : Set α} (hS : IsPreconnected S)\n    {T : Set β} [DiscreteTopology T] {f : α → β} (hc : ContinuousOn f S) (hTm : MapsTo f S T)\n    {x y : α} (hx : x ∈ S) (hy : y ∈ S) : f x = f y := by\n  let F : S → T := hTm.restrict f S T\n  suffices F ⟨x, hx⟩ = F ⟨y, hy⟩ by rwa [← Subtype.coe_inj] at this\n  exact (isPreconnected_iff_preconnectedSpace.mp hS).constant (hc.restrict_mapsTo _)\n#align is_preconnected.constant_of_maps_to IsPreconnected.constant_of_mapsTo\n\n/-- A version of `IsPreconnected.constant_of_mapsTo` that assumes that the codomain is nonempty and\nproves that `f` is equal to `const α y` on `S` for some `y ∈ T`. -/\ntheorem IsPreconnected.eqOn_const_of_mapsTo [TopologicalSpace β] {S : Set α} (hS : IsPreconnected S)\n    {T : Set β} [DiscreteTopology T] {f : α → β} (hc : ContinuousOn f S) (hTm : MapsTo f S T)\n    (hne : T.Nonempty) : ∃ y ∈ T, EqOn f (const α y) S := by\n  rcases S.eq_empty_or_nonempty with (rfl | ⟨x, hx⟩)\n  · exact hne.imp fun _ hy => ⟨hy, eqOn_empty _ _⟩\n  · exact ⟨f x, hTm hx, fun x' hx' => hS.constant_of_mapsTo hc hTm hx' hx⟩\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Topology/Connected.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6688802471698041, "lm_q1q2_score": 0.467717478376586}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.bases\nimport Mathlib.topology.homeomorph\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Open sets\n\n## Summary\n\nWe define the subtype of open sets in a topological space.\n\n## Main Definitions\n\n- `opens α` is the type of open subsets of a topological space `α`.\n- `open_nhds_of x` is the type of open subsets of a topological space `α` containing `x : α`.\n-\n-/\n\nnamespace topological_space\n\n\n/-- The type of open subsets of a topological space. -/\ndef opens (α : Type u_1) [topological_space α] := Subtype fun (s : set α) => is_open s\n\nnamespace opens\n\n\nprotected instance set.has_coe {α : Type u_1} [topological_space α] : has_coe (opens α) (set α) :=\n  has_coe.mk subtype.val\n\ntheorem val_eq_coe {α : Type u_1} [topological_space α] (U : opens α) : subtype.val U = ↑U := rfl\n\n/-- the coercion `opens α → set α` applied to a pair is the same as taking the first component -/\ntheorem coe_mk {α : Type u_1} [topological_space α] {U : set α} {hU : is_open U} :\n    ↑{ val := U, property := hU } = U :=\n  rfl\n\nprotected instance has_subset {α : Type u_1} [topological_space α] : has_subset (opens α) :=\n  has_subset.mk fun (U V : opens α) => ↑U ⊆ ↑V\n\nprotected instance has_mem {α : Type u_1} [topological_space α] : has_mem α (opens α) :=\n  has_mem.mk fun (a : α) (U : opens α) => a ∈ ↑U\n\n@[simp] theorem subset_coe {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} :\n    ↑U ⊆ ↑V = (U ⊆ V) :=\n  rfl\n\n@[simp] theorem mem_coe {α : Type u_1} [topological_space α] {x : α} {U : opens α} :\n    x ∈ ↑U = (x ∈ U) :=\n  rfl\n\ntheorem ext {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} (h : ↑U = ↑V) :\n    U = V :=\n  iff.mpr subtype.ext_iff h\n\ntheorem ext_iff {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} :\n    ↑U = ↑V ↔ U = V :=\n  { mp := ext, mpr := congr_arg coe }\n\nprotected instance partial_order {α : Type u_1} [topological_space α] : partial_order (opens α) :=\n  subtype.partial_order fun (s : set α) => is_open s\n\n/-- The interior of a set, as an element of `opens`. -/\ndef interior {α : Type u_1} [topological_space α] (s : set α) : opens α :=\n  { val := interior s, property := is_open_interior }\n\ntheorem gc {α : Type u_1} [topological_space α] : galois_connection coe interior :=\n  fun (U : opens α) (s : set α) =>\n    { mp := fun (h : ↑U ≤ s) => interior_maximal h (subtype.property U),\n      mpr := fun (h : U ≤ interior s) => le_trans h interior_subset }\n\n/-- The galois insertion between sets and opens, but ordered by reverse inclusion. -/\ndef gi {α : Type u_1} [topological_space α] : galois_insertion interior subtype.val :=\n  galois_insertion.mk\n    (fun (s : order_dual (set α)) (hs : subtype.val (interior s) ≤ s) =>\n      { val := s, property := sorry })\n    sorry sorry sorry\n\n@[simp] theorem gi_choice_val {α : Type u_1} [topological_space α] {s : order_dual (set α)}\n    {hs : subtype.val (interior s) ≤ s} : subtype.val (galois_insertion.choice gi s hs) = s :=\n  rfl\n\nprotected instance complete_lattice {α : Type u_1} [topological_space α] :\n    complete_lattice (opens α) :=\n  complete_lattice.copy (order_dual.complete_lattice (order_dual (opens α)))\n    (fun (U V : opens α) => U ⊆ V) sorry { val := set.univ, property := is_open_univ } sorry\n    { val := ∅, property := is_open_empty } sorry\n    (fun (U V : opens α) => { val := ↑U ∪ ↑V, property := sorry }) sorry\n    (fun (U V : opens α) => { val := ↑U ∩ ↑V, property := sorry }) sorry\n    (fun (Us : set (opens α)) => { val := ⋃₀(coe '' Us), property := sorry }) sorry\n    complete_lattice.Inf sorry\n\n/- le  -/ (λ U V, U ⊆ V) rfl\n/- top -/ ⟨set.univ, is_open_univ⟩ (subtype.ext_iff_val.mpr interior_univ.symm)\n/- bot -/ ⟨∅, is_open_empty⟩ rfl\n/- sup -/ (λ U V, ⟨↑U ∪ ↑V, is_open_union U.2 V.2⟩) rfl\n/- inf -/ (λ U V, ⟨↑U ∩ ↑V, is_open_inter U.2 V.2⟩)\nbegin\n  funext,\n  apply subtype.ext_iff_val.mpr,\n  exact (is_open_inter U.2 V.2).interior_eq.symm,\nend\n/- Sup -/ (λ Us, ⟨⋃₀ (coe '' Us), is_open_sUnion $ λ U hU,\nby { rcases hU with ⟨⟨V, hV⟩, h, h'⟩, dsimp at h', subst h', exact hV}⟩)\nbegin\n  funext,\n  apply subtype.ext_iff_val.mpr,\n  simp [Sup_range],\n  refl,\nend\n/- Inf -/ _ rfl\n\nlemma le_def {U V : opens α} : U ≤ V ↔ (U : set α) ≤ (V : set α) :=\nby refl\ntheorem le_def {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} : U ≤ V ↔ ↑U ≤ ↑V :=\n  iff.refl (U ≤ V)\n\n\n@[simp] lemma mk_inf_mk {U V : set α} {hU : is_open U} {hV : is_open V} :\n  (⟨U, hU⟩ ⊓ ⟨V, hV⟩ : opens α) = ⟨U ⊓ V, is_open_inter hU hV⟩ := rfl\n@[simp] theorem mk_inf_mk {α : Type u_1} [topological_space α] {U : set α} {V : set α}\n    {hU : is_open U} {hV : is_open V} :\n    { val := U, property := hU } ⊓ { val := V, property := hV } =\n        { val := U ⊓ V, property := is_open_inter hU hV } :=\n  rfl\n\n@[simp,norm_cast] lemma coe_inf {U V : opens α} :\n  ((U ⊓ V : opens α) : set α) = (U : set α) ⊓ (V : set α) := rfl\n@[simp] theorem coe_inf {α : Type u_1} [topological_space α] {U : opens α} {V : opens α} :\n    ↑(U ⊓ V) = ↑U ⊓ ↑V :=\n  rfl\n\n\ninstance : has_inter (opens α) := ⟨λ U V, U ⊓ V⟩\ninstance : has_union (opens α) := ⟨λ U V, U ⊔ V⟩\nprotected instance has_inter {α : Type u_1} [topological_space α] : has_inter (opens α) :=\n  has_inter.mk fun (U V : opens α) => U ⊓ V\n\ninstance : has_emptyc (opens α) := ⟨⊥⟩\nprotected instance has_union {α : Type u_1} [topological_space α] : has_union (opens α) :=\n  has_union.mk fun (U V : opens α) => U ⊔ V\n\ninstance : inhabited (opens α) := ⟨∅⟩\nprotected instance has_emptyc {α : Type u_1} [topological_space α] : has_emptyc (opens α) :=\n  has_emptyc.mk ⊥\n\n\nprotected instance inhabited {α : Type u_1} [topological_space α] : Inhabited (opens α) :=\n  { default := ∅ }\n\n@[simp] lemma inter_eq (U V : opens α) : U ∩ V = U ⊓ V := rfl\n@[simp] lemma union_eq (U V : opens α) : U ∪ V = U ⊔ V := rfl\n@[simp] theorem inter_eq {α : Type u_1} [topological_space α] (U : opens α) (V : opens α) :\n    U ∩ V = U ⊓ V :=\n  rfl\n\n@[simp] lemma empty_eq : (∅ : opens α) = ⊥ := rfl\n@[simp] theorem union_eq {α : Type u_1} [topological_space α] (U : opens α) (V : opens α) :\n    U ∪ V = U ⊔ V :=\n  rfl\n\n\n@[simp] theorem empty_eq {α : Type u_1} [topological_space α] : ∅ = ⊥ := rfl\n\n@[simp] lemma Sup_s {Us : set (opens α)} : ↑(Sup Us) = ⋃₀ ((coe : _ → set α) '' Us) :=\nbegin\n@[simp] theorem Sup_s {α : Type u_1} [topological_space α] {Us : set (opens α)} :\n    ↑(Sup Us) = ⋃₀(coe '' Us) :=\n  sorry\n\n  rw [@galois_connection.l_Sup (opens α) (set α) _ _ (coe : opens α → set α) interior gc Us],\n  rw [set.sUnion_image]\nend\n\nlemma supr_def {ι} (s : ι → opens α) : (⨆ i, s i) = ⟨⋃ i, s i, is_open_Union $ λ i, (s i).2⟩ :=\nby { ext, simp only [supr, opens.Sup_s, sUnion_image, bUnion_range], refl }\ntheorem supr_def {α : Type u_1} [topological_space α] {ι : Sort u_2} (s : ι → opens α) :\n    (supr fun (i : ι) => s i) =\n        { val := set.Union fun (i : ι) => ↑(s i),\n          property := is_open_Union fun (i : ι) => subtype.property (s i) } :=\n  sorry\n\n\n@[simp] lemma supr_mk {ι} (s : ι → set α) (h : Π i, is_open (s i)) :\n  (⨆ i, ⟨s i, h i⟩ : opens α) = ⟨⨆ i, s i, is_open_Union h⟩ :=\n@[simp] theorem supr_mk {α : Type u_1} [topological_space α] {ι : Sort u_2} (s : ι → set α)\n    (h : ∀ (i : ι), is_open (s i)) :\n    (supr fun (i : ι) => { val := s i, property := h i }) =\n        { val := supr fun (i : ι) => s i, property := is_open_Union h } :=\n  sorry\n\nby { rw supr_def, simp }\n\n@[simp] lemma supr_s {ι} (s : ι → opens α) : ((⨆ i, s i : opens α) : set α) = ⋃ i, s i :=\nby simp [supr_def]\n@[simp] theorem supr_s {α : Type u_1} [topological_space α] {ι : Sort u_2} (s : ι → opens α) :\n    ↑(supr fun (i : ι) => s i) = set.Union fun (i : ι) => ↑(s i) :=\n  sorry\n\n\ntheorem mem_supr {ι} {x : α} {s : ι → opens α} : x ∈ supr s ↔ ∃ i, x ∈ s i :=\nby { rw [←mem_coe], simp, }\ntheorem mem_supr {α : Type u_1} [topological_space α] {ι : Sort u_2} {x : α} {s : ι → opens α} :\n    x ∈ supr s ↔ ∃ (i : ι), x ∈ s i :=\n  sorry\n\n\nlemma open_embedding_of_le {U V : opens α} (i : U ≤ V) :\n  open_embedding (set.inclusion i) :=\ntheorem open_embedding_of_le {α : Type u_1} [topological_space α] {U : opens α} {V : opens α}\n    (i : U ≤ V) : open_embedding (set.inclusion i) :=\n  open_embedding.mk\n    (embedding.mk (inducing.mk (Eq.symm induced_compose)) (set.inclusion_injective i))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (is_open (set.range (set.inclusion i)))) (set.range_inclusion i)))\n      (is_open.preimage continuous_subtype_val (subtype.property U)))\n\n{ inj := set.inclusion_injective i,\n  induced := (@induced_compose _ _ _ _ (set.inclusion i) coe).symm,\n  open_range :=\n  begin\n    rw set.range_inclusion i,\n    exact U.property.preimage continuous_subtype_val\n  end, }\n\ndef is_basis (B : set (opens α)) : Prop := is_topological_basis ((coe : _ → set α) '' B)\n\ndef is_basis {α : Type u_1} [topological_space α] (B : set (opens α)) :=\n  is_topological_basis (coe '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens α)} :\n  is_basis B ↔ ∀ {U : opens α} {x}, x ∈ U → ∃ U' ∈ B, x ∈ U' ∧ U' ⊆ U :=\ntheorem is_basis_iff_nbhd {α : Type u_1} [topological_space α] {B : set (opens α)} :\n    is_basis B ↔\n        ∀ {U : opens α} {x : α}, x ∈ U → ∃ (U' : opens α), ∃ (H : U' ∈ B), x ∈ U' ∧ U' ⊆ U :=\n  sorry\n\nbegin\n  split; intro h,\n  { rintros ⟨sU, hU⟩ x hx,\n    rcases (mem_nhds_of_is_topological_basis h).mp (mem_nhds_sets hU hx)\n      with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩,\n    refine ⟨V, H₁, _⟩,\n    cases V, dsimp at H₂, subst H₂, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU ⟨U, ⟨H₁, H₂⟩⟩, subst H₂, exact U.property },\n    { intros x sU hx hsU,\n      rcases @h (⟨sU, hsU⟩ : opens α) x hx with ⟨V, hV, H⟩,\n      exact ⟨V, ⟨V, hV, rfl⟩, H⟩ } }\nend\n\nlemma is_basis_iff_cover {B : set (opens α)} :\n  is_basis B ↔ ∀ U : opens α, ∃ Us ⊆ B, U = Sup Us :=\ntheorem is_basis_iff_cover {α : Type u_1} [topological_space α] {B : set (opens α)} :\n    is_basis B ↔ ∀ (U : opens α), ∃ (Us : set (opens α)), ∃ (H : Us ⊆ B), U = Sup Us :=\n  sorry\n\nbegin\n  split,\n  { intros hB U,\n    rcases sUnion_basis_of_is_open hB U.prop with ⟨sUs, H, hU⟩,\n    existsi {U : opens α | U ∈ B ∧ ↑U ∈ sUs},\n    split,\n    { intros U hU, exact hU.left },\n    { apply ext,\n      rw [Sup_s, hU],\n      congr' with s; split; intro hs,\n      { rcases H hs with ⟨V, hV⟩,\n        rw ← hV.right at hs,\n        refine ⟨V, ⟨⟨hV.left, hs⟩, hV.right⟩⟩ },\n      { rcases hs with ⟨V, ⟨⟨H₁, H₂⟩, H₃⟩⟩,\n        subst H₃, exact H₂ } } },\n  { intro h,\n    rw is_basis_iff_nbhd,\n    intros U x hx,\n    rcases h U with ⟨Us, hUs, H⟩,\n    replace H := congr_arg (coe : _ → set α) H,\n    rw Sup_s at H,\n    change x ∈ ↑U at hx,\n    rw H at hx,\n    rcases set.mem_sUnion.mp hx with ⟨sV, ⟨⟨V, H₁, H₂⟩, hsV⟩⟩,\n    refine ⟨V,hUs H₁,_⟩,\n    cases V with V hV,\n    dsimp at H₂, subst H₂,\n    refine ⟨hsV,_⟩,\n    change V ⊆ U, rw H,\n    exact set.subset_sUnion_of_mem ⟨⟨V, _⟩, ⟨H₁, rfl⟩⟩ }\nend\n\n/-- The preimage of an open set, as an open set. -/\n\ndef comap {f : α → β} (hf : continuous f) (V : opens β) : opens α :=\n⟨f ⁻¹' V.1, V.2.preimage hf⟩\ndef comap {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] {f : α → β}\n    (hf : continuous f) (V : opens β) : opens α :=\n  { val := f ⁻¹' subtype.val V, property := sorry }\n\n\n@[simp] lemma comap_id (U : opens α) : U.comap continuous_id = U := by { ext, refl }\n\n@[simp] theorem comap_id {α : Type u_1} [topological_space α] (U : opens α) :\n    comap continuous_id U = U :=\n  ext (set.ext fun (x : α) => iff.refl (x ∈ ↑(comap continuous_id U)))\n\nlemma comap_mono {f : α → β} (hf : continuous f) {V W : opens β} (hVW : V ⊆ W) :\n  V.comap hf ⊆ W.comap hf :=\ntheorem comap_mono {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β]\n    {f : α → β} (hf : continuous f) {V : opens β} {W : opens β} (hVW : V ⊆ W) :\n    comap hf V ⊆ comap hf W :=\n  fun (_x : α) (h : _x ∈ ↑(comap hf V)) => hVW h\n\nλ _ h, hVW h\n\n@[simp] lemma coe_comap {f : α → β} (hf : continuous f) (U : opens β) :\n  ↑(U.comap hf) = f ⁻¹' U := rfl\n@[simp] theorem coe_comap {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β]\n    {f : α → β} (hf : continuous f) (U : opens β) : ↑(comap hf U) = f ⁻¹' ↑U :=\n  rfl\n\n\n@[simp] lemma comap_val {f : α → β} (hf : continuous f) (U : opens β) :\n  (U.comap hf).1 = f ⁻¹' U := rfl\n@[simp] theorem comap_val {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β]\n    {f : α → β} (hf : continuous f) (U : opens β) : subtype.val (comap hf U) = f ⁻¹' ↑U :=\n  rfl\n\n\nprotected lemma comap_comp {g : β → γ} {f : α → β} (hg : continuous g) (hf : continuous f)\n  (U : opens γ) : U.comap (hg.comp hf) = (U.comap hg).comap hf :=\nprotected theorem comap_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α]\n    [topological_space β] [topological_space γ] {g : β → γ} {f : α → β} (hg : continuous g)\n    (hf : continuous f) (U : opens γ) : comap (continuous.comp hg hf) U = comap hf (comap hg U) :=\n  sorry\n\nby { ext1, simp only [coe_comap, preimage_preimage] }\n\n/-- A homeomorphism induces an equivalence on open sets, by taking comaps. -/\n@[simp] protected def equiv {α : Type u_1} {β : Type u_2} [topological_space α]\n    [topological_space β] (f : α ≃ₜ β) : opens α ≃ opens β :=\n  equiv.mk (comap sorry) (comap (homeomorph.continuous f)) sorry sorry\n\nend opens\n\n\n/-- The open neighborhoods of a point. See also `opens` or `nhds`. -/\ndef open_nhds_of {α : Type u_1} [topological_space α] (x : α) :=\n  Subtype fun (s : set α) => is_open s ∧ x ∈ s\n\nprotected instance open_nhds_of.inhabited {α : Type u_1} [topological_space α] (x : α) :\n    Inhabited (open_nhds_of x) :=\n  { default := { val := set.univ, property := sorry } }\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/opens_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544085240401, "lm_q2_score": 0.6688802669716107, "lm_q1q2_score": 0.4677174754546357}}
{"text": "/-\nCopyright (c) 2023 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport algebra.field.basic\nimport algebra.ring.ulift\n\n/-!\n# Field instances for `ulift`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines instances for field, semifield and related structures on `ulift` types.\n\n(Recall `ulift α` is just a \"copy\" of a type `α` in a higher universe.)\n-/\n\nuniverses u v\nvariables {α : Type u} {x y : ulift.{v} α}\n\nnamespace ulift\n\ninstance [has_rat_cast α] : has_rat_cast (ulift α) := ⟨λ a, up a⟩\n\n@[simp, norm_cast] lemma up_rat_cast [has_rat_cast α] (q : ℚ) : up (q : α) = q := rfl\n@[simp, norm_cast] lemma down_rat_cast [has_rat_cast α] (q : ℚ) : down (q : ulift α) = q := rfl\n\ninstance division_semiring [division_semiring α] : division_semiring (ulift α) :=\nby refine down_injective.division_semiring down _ _ _ _ _ _ _ _ _ _; intros; refl\n\ninstance semifield [semifield α] : semifield (ulift α) :=\n{ ..ulift.division_semiring, ..ulift.comm_group_with_zero }\n\ninstance division_ring [division_ring α] : division_ring (ulift α) :=\n{ ..ulift.division_semiring, ..ulift.add_group }\n\ninstance field [field α] : field (ulift α) :=\n{ ..ulift.semifield, ..ulift.division_ring }\n\nend ulift\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/field/ulift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.46765674546478675}}
{"text": "/-\nCopyright (c) 2018 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n-/\nimport algebra.group_with_zero.power\nimport algebra.ring.equiv\nimport tactic.linarith\n\n/-!\n# Integer power operation on fields and division rings\n\nThis file collects basic facts about the operation of raising an element of a `division_ring` to an\ninteger power. More specialised results are provided in the case of a linearly ordered field.\n-/\n\nuniverse u\n\n@[simp] lemma ring_hom.map_zpow {K L : Type*} [division_ring K] [division_ring L] (f : K →+* L) :\n  ∀ (a : K) (n : ℤ), f (a ^ n) = f a ^ n :=\nf.to_monoid_with_zero_hom.map_zpow\n\n@[simp] lemma ring_equiv.map_zpow {K L : Type*} [division_ring K] [division_ring L] (f : K ≃+* L) :\n  ∀ (a : K) (n : ℤ), f (a ^ n) = f a ^ n :=\nf.to_ring_hom.map_zpow\n\n@[simp] lemma zpow_bit1_neg {K : Type*} [division_ring K] (x : K) (n : ℤ) :\n  (-x) ^ (bit1 n) = - x ^ bit1 n :=\nby rw [zpow_bit1', zpow_bit1', neg_mul_neg, neg_mul_eq_mul_neg]\n\nsection ordered_field_power\nopen int\n\nvariables {K : Type u} [linear_ordered_field K] {a : K} {n : ℤ}\n\nlemma zpow_nonneg {a : K} (ha : 0 ≤ a) : ∀ (z : ℤ), 0 ≤ a ^ z\n| (n : ℕ) := by { rw zpow_coe_nat, exact pow_nonneg ha _ }\n| -[1+n]  := by { rw zpow_neg_succ_of_nat, exact inv_nonneg.2 (pow_nonneg ha _) }\n\nlemma zpow_pos_of_pos {a : K} (ha : 0 < a) : ∀ (z : ℤ), 0 < a ^ z\n| (n : ℕ) := by { rw zpow_coe_nat, exact pow_pos ha _ }\n| -[1+n]  := by { rw zpow_neg_succ_of_nat, exact inv_pos.2 (pow_pos ha _) }\n\nlemma zpow_le_of_le {x : K} (hx : 1 ≤ x) {a b : ℤ} (h : a ≤ b) : x ^ a ≤ x ^ b :=\nbegin\n  induction a with a a; induction b with b b,\n  { simp only [of_nat_eq_coe, zpow_coe_nat],\n    apply pow_le_pow hx,\n    apply le_of_coe_nat_le_coe_nat h },\n  { apply absurd h,\n    apply not_le_of_gt,\n    exact lt_of_lt_of_le (neg_succ_lt_zero _) (of_nat_nonneg _) },\n  { simp only [zpow_neg_succ_of_nat, one_div, of_nat_eq_coe, zpow_coe_nat],\n    apply le_trans (inv_le_one _); apply one_le_pow_of_one_le hx },\n  { simp only [zpow_neg_succ_of_nat],\n    apply (inv_le_inv _ _).2,\n    { apply pow_le_pow hx,\n      have : -(↑(a+1) : ℤ) ≤ -(↑(b+1) : ℤ), from h,\n      have h' := le_of_neg_le_neg this,\n      apply le_of_coe_nat_le_coe_nat h' },\n    repeat { apply pow_pos (lt_of_lt_of_le zero_lt_one hx) } }\nend\n\nlemma pow_le_max_of_min_le {x : K} (hx : 1 ≤ x) {a b c : ℤ} (h : min a b ≤ c) :\n      x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) :=\nbegin\n  wlog hle : a ≤ b,\n  have hnle : -b ≤ -a, from neg_le_neg hle,\n  have hfle : x ^ (-b) ≤ x ^ (-a), from zpow_le_of_le hx hnle,\n  have : x ^ (-c) ≤ x ^ (-a),\n  { apply zpow_le_of_le hx,\n    simpa only [min_eq_left hle, neg_le_neg_iff] using h },\n  simpa only [max_eq_left hfle]\nend\n\nlemma zpow_le_one_of_nonpos {p : K} (hp : 1 ≤ p) {z : ℤ} (hz : z ≤ 0) : p ^ z ≤ 1 :=\ncalc p ^ z ≤ p ^ 0 : zpow_le_of_le hp hz\n          ... = 1        : by simp\n\nlemma one_le_zpow_of_nonneg {p : K} (hp : 1 ≤ p) {z : ℤ} (hz : 0 ≤ z) : 1 ≤ p ^ z :=\ncalc p ^ z ≥ p ^ 0 : zpow_le_of_le hp hz\n          ... = 1        : by simp\n\ntheorem zpow_bit0_nonneg (a : K) (n : ℤ) : 0 ≤ a ^ bit0 n :=\nby { rw zpow_bit0, exact mul_self_nonneg _ }\n\ntheorem zpow_two_nonneg (a : K) : 0 ≤ a ^ (2 : ℤ) :=\nzpow_bit0_nonneg a 1\n\ntheorem zpow_bit0_pos {a : K} (h : a ≠ 0) (n : ℤ) : 0 < a ^ bit0 n :=\n(zpow_bit0_nonneg a n).lt_of_ne (zpow_ne_zero _ h).symm\n\ntheorem zpow_two_pos_of_ne_zero (a : K) (h : a ≠ 0) : 0 < a ^ (2 : ℤ) :=\nzpow_bit0_pos h 1\n\n@[simp] theorem zpow_bit1_neg_iff : a ^ bit1 n < 0 ↔ a < 0 :=\n⟨λ h, not_le.1 $ λ h', not_le.2 h $ zpow_nonneg h' _,\n λ h, by rw [bit1, zpow_add_one₀ h.ne]; exact mul_neg_of_pos_of_neg (zpow_bit0_pos h.ne _) h⟩\n\n@[simp] theorem zpow_bit1_nonneg_iff : 0 ≤ a ^ bit1 n ↔ 0 ≤ a :=\nle_iff_le_iff_lt_iff_lt.2 zpow_bit1_neg_iff\n\n@[simp] theorem zpow_bit1_nonpos_iff : a ^ bit1 n ≤ 0 ↔ a ≤ 0 :=\nbegin\n  rw [le_iff_lt_or_eq, zpow_bit1_neg_iff],\n  split,\n  { rintro (h | h),\n    { exact h.le },\n    { exact (zpow_eq_zero h).le } },\n  { intro h,\n    rcases eq_or_lt_of_le h with rfl|h,\n    { exact or.inr (zero_zpow _ (bit1_ne_zero n)) },\n    { exact or.inl h } }\nend\n\n@[simp] theorem zpow_bit1_pos_iff : 0 < a ^ bit1 n ↔ 0 < a :=\nlt_iff_lt_of_le_iff_le zpow_bit1_nonpos_iff\n\nend ordered_field_power\n\nlemma one_lt_zpow {K} [linear_ordered_field K] {p : K} (hp : 1 < p) :\n  ∀ z : ℤ, 0 < z → 1 < p ^ z\n| (n : ℕ) h := (zpow_coe_nat p n).symm.subst (one_lt_pow hp $ int.coe_nat_ne_zero.mp h.ne')\n| -[1+ n] h := ((int.neg_succ_not_pos _).mp h).elim\n\nsection ordered\nvariables  {K : Type*} [linear_ordered_field K]\n\nlemma nat.zpow_pos_of_pos {p : ℕ} (h : 0 < p) (n:ℤ) : 0 < (p:K)^n :=\nby { apply zpow_pos_of_pos, exact_mod_cast h }\n\nlemma nat.zpow_ne_zero_of_pos {p : ℕ} (h : 0 < p) (n:ℤ) : (p:K)^n ≠ 0 :=\nne_of_gt (nat.zpow_pos_of_pos h n)\n\nlemma zpow_strict_mono {x : K} (hx : 1 < x) :\n  strict_mono (λ n:ℤ, x ^ n) :=\nstrict_mono_int_of_lt_succ $ λ n,\nhave xpos : 0 < x, from zero_lt_one.trans hx,\ncalc x ^ n < x ^ n * x : lt_mul_of_one_lt_right (zpow_pos_of_pos xpos _) hx\n... = x ^ (n + 1) : (zpow_add_one₀ xpos.ne' _).symm\n\nlemma zpow_strict_anti {x : K} (h₀ : 0 < x) (h₁ : x < 1) : strict_anti (λ n : ℤ, x ^ n) :=\nstrict_anti_int_of_succ_lt $ λ n,\ncalc x ^ (n + 1) = x ^ n * x : zpow_add_one₀ h₀.ne' _\n... < x ^ n * 1 : (mul_lt_mul_left $ zpow_pos_of_pos h₀ _).2 h₁\n... = x ^ n : mul_one _\n\n@[simp] lemma zpow_lt_iff_lt {x : K} (hx : 1 < x) {m n : ℤ} :\n  x ^ m < x ^ n ↔ m < n :=\n(zpow_strict_mono hx).lt_iff_lt\n\n@[simp] lemma zpow_le_iff_le {x : K} (hx : 1 < x) {m n : ℤ} :\n  x ^ m ≤ x ^ n ↔ m ≤ n :=\n(zpow_strict_mono hx).le_iff_le\n\nlemma min_le_of_zpow_le_max {x : K} (hx : 1 < x) {a b c : ℤ}\n  (h_max : x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) ) : min a b ≤ c :=\nbegin\n  rw min_le_iff,\n  refine or.imp (λ h, _) (λ h, _) (le_max_iff.mp h_max);\n  rwa [zpow_le_iff_le hx, neg_le_neg_iff] at h\nend\n\n@[simp] lemma pos_div_pow_pos {a b : K} (ha : 0 < a) (hb : 0 < b) (k : ℕ) : 0 < a/b^k :=\ndiv_pos ha (pow_pos hb k)\n\n@[simp] lemma div_pow_le {a b : K} (ha : 0 < a) (hb : 1 ≤ b) (k : ℕ) : a/b^k ≤ a :=\n(div_le_iff $ pow_pos (lt_of_lt_of_le zero_lt_one hb) k).mpr\n(calc a = a * 1 : (mul_one a).symm\n   ...  ≤ a*b^k : (mul_le_mul_left ha).mpr $ one_le_pow_of_one_le hb _)\n\nlemma zpow_injective {x : K} (h₀ : 0 < x) (h₁ : x ≠ 1) :\n  function.injective ((^) x : ℤ → K) :=\nbegin\n  intros m n h,\n  rcases h₁.lt_or_lt with H|H,\n  { apply (zpow_strict_mono (one_lt_inv h₀ H)).injective,\n    show x⁻¹ ^ m = x⁻¹ ^ n,\n    rw [← zpow_neg_one, ← zpow_mul, ← zpow_mul, mul_comm _ m, mul_comm _ n, zpow_mul, zpow_mul,\n      h], },\n  { exact (zpow_strict_mono H).injective h, },\nend\n\n@[simp] lemma zpow_inj {x : K} (h₀ : 0 < x) (h₁ : x ≠ 1) {m n : ℤ} :\n  x ^ m = x ^ n ↔ m = n :=\n(zpow_injective h₀ h₁).eq_iff\n\nend ordered\n\nsection\nvariables {K : Type*} [division_ring K]\n\n@[simp, norm_cast] theorem rat.cast_zpow [char_zero K] (q : ℚ) (n : ℤ) :\n  ((q ^ n : ℚ) : K) = q ^ n :=\n(rat.cast_hom K).map_zpow q n\n\nend\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/field_power.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984445, "lm_q2_score": 0.7341195385342971, "lm_q1q2_score": 0.4676567427584851}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Floris van Doorn, Leonardo de Moura\n-/\nimport Mathlib.Init.ZeroOne\nimport Mathlib.Init.Data.Nat.Notation\n\nnamespace Nat\n\n\nsection recursor_workarounds\n\n/-- A computable version of `Nat.rec`. Workaround until Lean has native support for this. -/\ndef recC.{u} {motive : ℕ → Sort u} (zero : motive zero)\n  (succ : (n : ℕ) → motive n → motive (succ n)) :\n  (t : ℕ) → motive t\n| 0 => zero\n| (n + 1) => succ n (recC zero succ n)\n\n@[csimp]\ntheorem rec_eq_recC : @Nat.rec = @Nat.recC := by\n  funext motive zero succ n\n  induction n with\n  | zero => rfl\n  | succ n ih => rw [Nat.recC, ←ih]\n\nend recursor_workarounds\n\nset_option linter.deprecated false\n\nprotected \n\nprotected theorem zero_lt_bit0 : ∀ {n : Nat}, n ≠ 0 → 0 < bit0 n\n  | 0, h => absurd rfl h\n  | succ n, _ =>\n    calc\n      0 < succ (succ (bit0 n)) := zero_lt_succ _\n      _ = bit0 (succ n) := (Nat.bit0_succ_eq n).symm\n\n#align nat.zero_lt_bit0 Nat.zero_lt_bit0\n\nprotected theorem zero_lt_bit1 (n : Nat) : 0 < bit1 n :=\n  zero_lt_succ _\n#align nat.zero_lt_bit1 Nat.zero_lt_bit1\n\nprotected theorem bit0_ne_zero : ∀ {n : ℕ}, n ≠ 0 → bit0 n ≠ 0\n  | 0, h => absurd rfl h\n  | n + 1, _ =>\n    suffices n + 1 + (n + 1) ≠ 0 from this\n    suffices succ (n + 1 + n) ≠ 0 from this\n    fun h => Nat.noConfusion h\n#align nat.bit0_ne_zero Nat.bit0_ne_zero\n\nprotected theorem bit1_ne_zero (n : ℕ) : bit1 n ≠ 0 :=\n  show succ (n + n) ≠ 0 from fun h => Nat.noConfusion h\n#align nat.bit1_ne_zero Nat.bit1_ne_zero\n\nend Nat\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Init/Data/Nat/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.7341195152660687, "lm_q1q2_score": 0.4676567380534975}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard\n-/\nimport group_theory.submonoid.basic\nimport algebra.big_operators.basic\n\n/-!\n# Submonoids\n\nThis file defines unbundled multiplicative and additive submonoids (deprecated). For bundled form\nsee `group_theory/submonoid`.\n\nWe some results about images and preimages of submonoids under monoid homomorphisms. These theorems\nuse unbundled monoid homomorphisms (also deprecated).\n\nThere are also theorems about the submonoids generated by an element or a subset of a monoid,\ndefined inductively.\n\n## Implementation notes\n\nUnbundled submonoids will slowly be removed from mathlib.\n\n## Tags\nsubmonoid, submonoids, is_submonoid\n-/\n\nopen_locale big_operators\n\nvariables {M : Type*} [monoid M] {s : set M}\nvariables {A : Type*} [add_monoid A] {t : set A}\n\n/-- `s` is an additive submonoid: a set containing 0 and closed under addition. -/\nclass is_add_submonoid (s : set A) : Prop :=\n(zero_mem : (0:A) ∈ s)\n(add_mem {a b} : a ∈ s → b ∈ s → a + b ∈ s)\n\n/-- `s` is a submonoid: a set containing 1 and closed under multiplication. -/\n@[to_additive]\nclass is_submonoid (s : set M) : Prop :=\n(one_mem : (1:M) ∈ s)\n(mul_mem {a b} : a ∈ s → b ∈ s → a * b ∈ s)\n\nlemma additive.is_add_submonoid\n  (s : set M) : ∀ [is_submonoid s], @is_add_submonoid (additive M) _ s\n| ⟨h₁, h₂⟩ := ⟨h₁, @h₂⟩\n\ntheorem additive.is_add_submonoid_iff\n  {s : set M} : @is_add_submonoid (additive M) _ s ↔ is_submonoid s :=\n⟨λ ⟨h₁, h₂⟩, ⟨h₁, @h₂⟩, λ h, by exactI additive.is_add_submonoid _⟩\n\nlemma multiplicative.is_submonoid\n  (s : set A) : ∀ [is_add_submonoid s], @is_submonoid (multiplicative A) _ s\n| ⟨h₁, h₂⟩ := ⟨h₁, @h₂⟩\n\ntheorem multiplicative.is_submonoid_iff\n  {s : set A} : @is_submonoid (multiplicative A) _ s ↔ is_add_submonoid s :=\n⟨λ ⟨h₁, h₂⟩, ⟨h₁, @h₂⟩, λ h, by exactI multiplicative.is_submonoid _⟩\n\n/-- The intersection of two submonoids of a monoid `M` is a submonoid of `M`. -/\n@[to_additive \"The intersection of two `add_submonoid`s of an `add_monoid` `M` is\nan `add_submonoid` of M.\"]\ninstance is_submonoid.inter (s₁ s₂ : set M) [is_submonoid s₁] [is_submonoid s₂] :\n  is_submonoid (s₁ ∩ s₂) :=\n{ one_mem := ⟨is_submonoid.one_mem, is_submonoid.one_mem⟩,\n  mul_mem := λ x y hx hy,\n    ⟨is_submonoid.mul_mem hx.1 hy.1, is_submonoid.mul_mem hx.2 hy.2⟩ }\n\n/-- The intersection of an indexed set of submonoids of a monoid `M` is a submonoid of `M`. -/\n@[to_additive \"The intersection of an indexed set of `add_submonoid`s of an `add_monoid` `M` is\nan `add_submonoid` of `M`.\"]\ninstance is_submonoid.Inter {ι : Sort*} (s : ι → set M) [h : ∀ y : ι, is_submonoid (s y)] :\n  is_submonoid (set.Inter s) :=\n{ one_mem := set.mem_Inter.2 $ λ y, is_submonoid.one_mem,\n  mul_mem := λ x₁ x₂ h₁ h₂, set.mem_Inter.2 $\n    λ y, is_submonoid.mul_mem (set.mem_Inter.1 h₁ y) (set.mem_Inter.1 h₂ y) }\n\n/-- The union of an indexed, directed, nonempty set of submonoids of a monoid `M` is a submonoid\n    of `M`. -/\n@[to_additive \"The union of an indexed, directed, nonempty set\nof `add_submonoid`s of an `add_monoid` `M` is an `add_submonoid` of `M`. \"]\nlemma is_submonoid_Union_of_directed {ι : Type*} [hι : nonempty ι]\n  (s : ι → set M) [∀ i, is_submonoid (s i)]\n  (directed : ∀ i j, ∃ k, s i ⊆ s k ∧ s j ⊆ s k) :\n  is_submonoid (⋃i, s i) :=\n{ one_mem := let ⟨i⟩ := hι in set.mem_Union.2 ⟨i, is_submonoid.one_mem⟩,\n  mul_mem := λ a b ha hb,\n    let ⟨i, hi⟩ := set.mem_Union.1 ha in\n    let ⟨j, hj⟩ := set.mem_Union.1 hb in\n    let ⟨k, hk⟩ := directed i j in\n    set.mem_Union.2 ⟨k, is_submonoid.mul_mem (hk.1 hi) (hk.2 hj)⟩ }\n\nsection powers\n\n/-- The set of natural number powers `1, x, x², ...` of an element `x` of a monoid. -/\ndef powers (x : M) : set M := {y | ∃ n:ℕ, x^n = y}\n/-- The set of natural number multiples `0, x, 2x, ...` of an element `x` of an `add_monoid`. -/\ndef multiples (x : A) : set A := {y | ∃ n:ℕ, n • x = y}\nattribute [to_additive multiples] powers\n\n/-- 1 is in the set of natural number powers of an element of a monoid. -/\nlemma powers.one_mem {x : M} : (1 : M) ∈ powers x := ⟨0, pow_zero _⟩\n\n/-- 0 is in the set of natural number multiples of an element of an `add_monoid`. -/\nlemma multiples.zero_mem {x : A} : (0 : A) ∈ multiples x := ⟨0, zero_nsmul _⟩\nattribute [to_additive] powers.one_mem\n\n/-- An element of a monoid is in the set of that element's natural number powers. -/\nlemma powers.self_mem {x : M} : x ∈ powers x := ⟨1, pow_one _⟩\n\n/-- An element of an `add_monoid` is in the set of that element's natural number multiples. -/\nlemma multiples.self_mem {x : A} : x ∈ multiples x := ⟨1, one_nsmul _⟩\nattribute [to_additive] powers.self_mem\n\n/-- The set of natural number powers of an element of a monoid is closed under multiplication. -/\nlemma powers.mul_mem {x y z : M} : (y ∈ powers x) → (z ∈ powers x) → (y * z ∈ powers x) :=\nλ ⟨n₁, h₁⟩ ⟨n₂, h₂⟩, ⟨n₁ + n₂, by simp only [pow_add, *]⟩\n\n/-- The set of natural number multiples of an element of an `add_monoid` is closed under\n    addition. -/\nlemma multiples.add_mem {x y z : A} :\n  (y ∈ multiples x) → (z ∈ multiples x) → (y + z ∈ multiples x) :=\n@powers.mul_mem (multiplicative A) _ _ _ _\nattribute [to_additive] powers.mul_mem\n\n/-- The set of natural number powers of an element of a monoid `M` is a submonoid of `M`. -/\n@[to_additive \"The set of natural number multiples of an element of\nan `add_monoid` `M` is an `add_submonoid` of `M`.\"]\ninstance powers.is_submonoid (x : M) : is_submonoid (powers x) :=\n{ one_mem := powers.one_mem,\n  mul_mem := λ y z, powers.mul_mem }\n\n/-- A monoid is a submonoid of itself. -/\n@[to_additive \"An `add_monoid` is an `add_submonoid` of itself.\"]\ninstance univ.is_submonoid : is_submonoid (@set.univ M) := by split; simp\n\n/-- The preimage of a submonoid under a monoid hom is a submonoid of the domain. -/\n@[to_additive \"The preimage of an `add_submonoid` under an `add_monoid` hom is\nan `add_submonoid` of the domain.\"]\ninstance preimage.is_submonoid {N : Type*} [monoid N] (f : M → N) [is_monoid_hom f]\n  (s : set N) [is_submonoid s] : is_submonoid (f ⁻¹' s) :=\n{ one_mem := show f 1 ∈ s, by rw is_monoid_hom.map_one f; exact is_submonoid.one_mem,\n  mul_mem := λ a b (ha : f a ∈ s) (hb : f b ∈ s),\n    show f (a * b) ∈ s, by rw is_monoid_hom.map_mul f; exact is_submonoid.mul_mem ha hb }\n\n/-- The image of a submonoid under a monoid hom is a submonoid of the codomain. -/\n@[instance, to_additive \"The image of an `add_submonoid` under an `add_monoid`\nhom is an `add_submonoid` of the codomain.\"]\nlemma image.is_submonoid {γ : Type*} [monoid γ] (f : M → γ) [is_monoid_hom f]\n  (s : set M) [is_submonoid s] : is_submonoid (f '' s) :=\n{ one_mem := ⟨1, is_submonoid.one_mem, is_monoid_hom.map_one f⟩,\n  mul_mem := λ a b ⟨x, hx⟩ ⟨y, hy⟩, ⟨x * y, is_submonoid.mul_mem hx.1 hy.1,\n    by rw [is_monoid_hom.map_mul f, hx.2, hy.2]⟩ }\n\n/-- The image of a monoid hom is a submonoid of the codomain. -/\n@[to_additive \"The image of an `add_monoid` hom is an `add_submonoid`\nof the codomain.\"]\ninstance range.is_submonoid {γ : Type*} [monoid γ] (f : M → γ) [is_monoid_hom f] :\n  is_submonoid (set.range f) :=\nby rw ← set.image_univ; apply_instance\n\n/-- Submonoids are closed under natural powers. -/\nlemma is_submonoid.pow_mem {a : M} [is_submonoid s] (h : a ∈ s) : ∀ {n : ℕ}, a ^ n ∈ s\n| 0 := by { rw pow_zero, exact is_submonoid.one_mem }\n| (n + 1) := by { rw pow_succ, exact is_submonoid.mul_mem h is_submonoid.pow_mem }\n\n/-- An `add_submonoid` is closed under multiplication by naturals. -/\nlemma is_add_submonoid.smul_mem {a : A} [is_add_submonoid t] :\n  ∀ (h : a ∈ t) {n : ℕ}, n • a ∈ t :=\n@is_submonoid.pow_mem (multiplicative A) _ _ _ (multiplicative.is_submonoid _)\nattribute [to_additive smul_mem] is_submonoid.pow_mem\n\n/-- The set of natural number powers of an element of a submonoid is a subset of the submonoid. -/\nlemma is_submonoid.power_subset {a : M} [is_submonoid s] (h : a ∈ s) : powers a ⊆ s :=\nassume x ⟨n, hx⟩, hx ▸ is_submonoid.pow_mem h\n\n/-- The set of natural number multiples of an element of an `add_submonoid` is a subset of the\n    `add_submonoid`. -/\nlemma is_add_submonoid.multiple_subset {a : A} [is_add_submonoid t] :\n  a ∈ t → multiples a ⊆ t :=\n@is_submonoid.power_subset (multiplicative A) _ _ _ (multiplicative.is_submonoid _)\nattribute [to_additive multiple_subset] is_submonoid.power_subset\n\nend powers\n\nnamespace is_submonoid\n\n/-- The product of a list of elements of a submonoid is an element of the submonoid. -/\n@[to_additive \"The sum of a list of elements of an `add_submonoid` is an element of the\n`add_submonoid`.\"]\nlemma list_prod_mem [is_submonoid s] : ∀{l : list M}, (∀x∈l, x ∈ s) → l.prod ∈ s\n| []     h := one_mem\n| (a::l) h :=\n  suffices a * l.prod ∈ s, by simpa,\n  have a ∈ s ∧ (∀x∈l, x ∈ s), by simpa using h,\n  is_submonoid.mul_mem this.1 (list_prod_mem this.2)\n\n/-- The product of a multiset of elements of a submonoid of a `comm_monoid` is an element of\nthe submonoid. -/\n@[to_additive \"The sum of a multiset of elements of an `add_submonoid` of an `add_comm_monoid`\nis an element of the `add_submonoid`. \"]\nlemma multiset_prod_mem {M} [comm_monoid M] (s : set M) [is_submonoid s] (m : multiset M) :\n  (∀a∈m, a ∈ s) → m.prod ∈ s :=\nbegin\n  refine quotient.induction_on m (assume l hl, _),\n  rw [multiset.quot_mk_to_coe, multiset.coe_prod],\n  exact list_prod_mem hl\nend\n\n/-- The product of elements of a submonoid of a `comm_monoid` indexed by a `finset` is an element\nof the submonoid. -/\n@[to_additive \"The sum of elements of an `add_submonoid` of an `add_comm_monoid` indexed by\na `finset` is an element of the `add_submonoid`.\"]\nlemma finset_prod_mem {M A} [comm_monoid M] (s : set M) [is_submonoid s] (f : A → M) :\n  ∀(t : finset A), (∀b∈t, f b ∈ s) → ∏ b in t, f b ∈ s\n| ⟨m, hm⟩ hs := multiset_prod_mem s _ (by simpa)\n\nend is_submonoid\n\n-- TODO: modify `subtype_instance` to produce this definition, then use it here\n--  and for `subtype.group`\n\n/-- Submonoids are themselves monoids. -/\n@[to_additive \"An `add_submonoid` is itself an `add_monoid`.\"]\ndef subtype.monoid {s : set M} [is_submonoid s] : monoid s :=\n{ one := ⟨1, is_submonoid.one_mem⟩,\n  mul := λ x y, ⟨x * y, is_submonoid.mul_mem x.2 y.2⟩,\n  mul_one := λ x, subtype.eq $ mul_one x.1,\n  one_mul := λ x, subtype.eq $ one_mul x.1,\n  mul_assoc := λ x y z, subtype.eq $ mul_assoc x.1 y.1 z.1 }\n\n/-- Submonoids of commutative monoids are themselves commutative monoids. -/\n@[to_additive \"An `add_submonoid` of a commutative `add_monoid` is itself\na commutative `add_monoid`. \"]\ndef subtype.comm_monoid {M} [comm_monoid M] {s : set M} [is_submonoid s] : comm_monoid s :=\n{ mul_comm := λ x y, subtype.eq $ mul_comm x.1 y.1,\n  .. subtype.monoid }\n\nsection\nlocal attribute [instance] subtype.monoid subtype.add_monoid\n\n/-- Submonoids inherit the 1 of the monoid. -/\n@[simp, norm_cast, to_additive \"An `add_submonoid` inherits the 0 of the `add_monoid`. \"]\nlemma is_submonoid.coe_one [is_submonoid s] : ((1 : s) : M) = 1 := rfl\nattribute [norm_cast] is_add_submonoid.coe_zero\n\n/-- Submonoids inherit the multiplication of the monoid. -/\n@[simp, norm_cast, to_additive \"An `add_submonoid` inherits the addition of the `add_monoid`. \"]\nlemma is_submonoid.coe_mul [is_submonoid s] (a b : s) : ((a * b : s) : M) = a * b := rfl\nattribute [norm_cast] is_add_submonoid.coe_add\n\n/-- Submonoids inherit the exponentiation by naturals of the monoid. -/\n@[simp, norm_cast] lemma is_submonoid.coe_pow [is_submonoid s] (a : s) (n : ℕ) :\n  ((a ^ n : s) : M) = a ^ n :=\nby induction n; simp [*, pow_succ]\n\n/-- An `add_submonoid` inherits the multiplication by naturals of the `add_monoid`. -/\n@[simp, norm_cast] lemma is_add_submonoid.smul_coe {A : Type*} [add_monoid A] {s : set A}\n  [is_add_submonoid s] (a : s) (n : ℕ) : ((n • a : s) : A) = n • a :=\nby induction n; simp [*, succ_nsmul, zero_nsmul]\n\nattribute [to_additive smul_coe] is_submonoid.coe_pow\n\n/-- The natural injection from a submonoid into the monoid is a monoid hom. -/\n@[to_additive \"The natural injection from an `add_submonoid` into\nthe `add_monoid` is an `add_monoid` hom. \"]\ninstance subtype_val.is_monoid_hom [is_submonoid s] : is_monoid_hom (subtype.val : s → M) :=\n{ map_one := rfl, map_mul := λ _ _, rfl }\n\n/-- The natural injection from a submonoid into the monoid is a monoid hom. -/\n@[to_additive \"The natural injection from an `add_submonoid` into\nthe `add_monoid` is an `add_monoid` hom. \"]\ninstance coe.is_monoid_hom [is_submonoid s] : is_monoid_hom (coe : s → M) :=\nsubtype_val.is_monoid_hom\n\n/-- Given a monoid hom `f : γ → M` whose image is contained in a submonoid `s`, the induced map\n    from `γ` to `s` is a monoid hom. -/\n@[to_additive \"Given an `add_monoid` hom `f : γ → M` whose image is contained in\nan `add_submonoid` s, the induced map from `γ` to `s` is an `add_monoid` hom.\"]\ninstance subtype_mk.is_monoid_hom {γ : Type*} [monoid γ] [is_submonoid s] (f : γ → M)\n  [is_monoid_hom f] (h : ∀ x, f x ∈ s) : is_monoid_hom (λ x, (⟨f x, h x⟩ : s)) :=\n{ map_one := subtype.eq (is_monoid_hom.map_one f),\n  map_mul := λ x y, subtype.eq (is_monoid_hom.map_mul f x y) }\n\n/-- Given two submonoids `s` and `t` such that `s ⊆ t`, the natural injection from `s` into `t` is\n    a monoid hom. -/\n@[to_additive \"Given two `add_submonoid`s `s` and `t` such that `s ⊆ t`, the\nnatural injection from `s` into `t` is an `add_monoid` hom.\"]\ninstance set_inclusion.is_monoid_hom (t : set M) [is_submonoid s] [is_submonoid t] (h : s ⊆ t) :\n  is_monoid_hom (set.inclusion h) :=\nsubtype_mk.is_monoid_hom _ _\n\nend\n\nnamespace add_monoid\n\n/-- The inductively defined membership predicate for the submonoid generated by a subset of a\n    monoid. -/\ninductive in_closure (s : set A) : A → Prop\n| basic {a : A} : a ∈ s → in_closure a\n| zero : in_closure 0\n| add {a b : A} : in_closure a → in_closure b → in_closure (a + b)\n\nend add_monoid\n\nnamespace monoid\n\n/-- The inductively defined membership predicate for the `add_submonoid` generated by a subset of an\n    add_monoid. -/\ninductive in_closure (s : set M) : M → Prop\n| basic {a : M} : a ∈ s → in_closure a\n| one : in_closure 1\n| mul {a b : M} : in_closure a → in_closure b → in_closure (a * b)\n\nattribute [to_additive] monoid.in_closure\nattribute [to_additive] monoid.in_closure.one\nattribute [to_additive] monoid.in_closure.mul\n\n/-- The inductively defined submonoid generated by a subset of a monoid. -/\n@[to_additive \"The inductively defined `add_submonoid` genrated by a subset of an `add_monoid`.\"]\ndef closure (s : set M) : set M := {a | in_closure s a }\n\n@[to_additive]\ninstance closure.is_submonoid (s : set M) : is_submonoid (closure s) :=\n{ one_mem := in_closure.one, mul_mem := assume a b, in_closure.mul }\n\n/-- A subset of a monoid is contained in the submonoid it generates. -/\n@[to_additive \"A subset of an `add_monoid` is contained in the `add_submonoid` it generates.\"]\ntheorem subset_closure {s : set M} : s ⊆ closure s :=\nassume a, in_closure.basic\n\n/-- The submonoid generated by a set is contained in any submonoid that contains the set. -/\n@[to_additive \"The `add_submonoid` generated by a set is contained in any `add_submonoid` that\ncontains the set.\"]\ntheorem closure_subset {s t : set M} [is_submonoid t] (h : s ⊆ t) : closure s ⊆ t :=\nassume a ha, by induction ha; simp [h _, *, is_submonoid.one_mem, is_submonoid.mul_mem]\n\n/-- Given subsets `t` and `s` of a monoid `M`, if `s ⊆ t`, the submonoid of `M` generated by `s` is\n    contained in the submonoid generated by `t`. -/\n@[to_additive \"Given subsets `t` and `s` of an `add_monoid M`, if `s ⊆ t`, the `add_submonoid`\nof `M` generated by `s` is contained in the `add_submonoid` generated by `t`.\"]\ntheorem closure_mono {s t : set M} (h : s ⊆ t) : closure s ⊆ closure t :=\nclosure_subset $ set.subset.trans h subset_closure\n\n/-- The submonoid generated by an element of a monoid equals the set of natural number powers of\n    the element. -/\n@[to_additive \"The `add_submonoid` generated by an element of an `add_monoid` equals the set of\nnatural number multiples of the element.\"]\ntheorem closure_singleton {x : M} : closure ({x} : set M) = powers x :=\nset.eq_of_subset_of_subset (closure_subset $ set.singleton_subset_iff.2 $ powers.self_mem) $\n  is_submonoid.power_subset $ set.singleton_subset_iff.1 $ subset_closure\n\n/-- The image under a monoid hom of the submonoid generated by a set equals the submonoid generated\n    by the image of the set under the monoid hom. -/\n@[to_additive \"The image under an `add_monoid` hom of the `add_submonoid` generated by a set equals\nthe `add_submonoid` generated by the image of the set under the `add_monoid` hom.\"]\nlemma image_closure {A : Type*} [monoid A] (f : M → A) [is_monoid_hom f] (s : set M) :\n  f '' closure s = closure (f '' s) :=\nle_antisymm\n  begin\n    rintros _ ⟨x, hx, rfl⟩,\n    apply in_closure.rec_on hx; intros,\n    { solve_by_elim [subset_closure, set.mem_image_of_mem] },\n    { rw [is_monoid_hom.map_one f], apply is_submonoid.one_mem },\n    { rw [is_monoid_hom.map_mul f], solve_by_elim [is_submonoid.mul_mem] }\n  end\n  (closure_subset $ set.image_subset _ subset_closure)\n\n/-- Given an element `a` of the submonoid of a monoid `M` generated by a set `s`, there exists\na list of elements of `s` whose product is `a`. -/\n@[to_additive \"Given an element `a` of the `add_submonoid` of an `add_monoid M` generated by\na set `s`, there exists a list of elements of `s` whose sum is `a`.\"]\ntheorem exists_list_of_mem_closure {s : set M} {a : M} (h : a ∈ closure s) :\n  (∃l:list M, (∀x∈l, x ∈ s) ∧ l.prod = a) :=\nbegin\n  induction h,\n  case in_closure.basic : a ha { existsi ([a]), simp [ha] },\n  case in_closure.one { existsi ([]), simp },\n  case in_closure.mul : a b _ _ ha hb {\n    rcases ha with ⟨la, ha, eqa⟩,\n    rcases hb with ⟨lb, hb, eqb⟩,\n    existsi (la ++ lb),\n    simp [eqa.symm, eqb.symm, or_imp_distrib],\n    exact assume a, ⟨ha a, hb a⟩\n  }\nend\n\n/-- Given sets `s, t` of a commutative monoid `M`, `x ∈ M` is in the submonoid of `M` generated by\n    `s ∪ t` iff there exists an element of the submonoid generated by `s` and an element of the\n    submonoid generated by `t` whose product is `x`. -/\n@[to_additive \"Given sets `s, t` of a commutative `add_monoid M`, `x ∈ M` is in the `add_submonoid`\nof `M` generated by `s ∪ t` iff there exists an element of the `add_submonoid` generated by `s`\nand an element of the `add_submonoid` generated by `t` whose sum is `x`.\"]\ntheorem mem_closure_union_iff {M : Type*} [comm_monoid M] {s t : set M} {x : M} :\n  x ∈ closure (s ∪ t) ↔ ∃ y ∈ closure s, ∃ z ∈ closure t, y * z = x :=\n⟨λ hx, let ⟨L, HL1, HL2⟩ := exists_list_of_mem_closure hx in HL2 ▸\n  list.rec_on L (λ _, ⟨1, is_submonoid.one_mem, 1, is_submonoid.one_mem, mul_one _⟩)\n    (λ hd tl ih HL1, let ⟨y, hy, z, hz, hyzx⟩ := ih (list.forall_mem_of_forall_mem_cons HL1) in\n      or.cases_on (HL1 hd $ list.mem_cons_self _ _)\n        (λ hs, ⟨hd * y, is_submonoid.mul_mem (subset_closure hs) hy, z, hz,\n          by rw [mul_assoc, list.prod_cons, ← hyzx]; refl⟩)\n        (λ ht, ⟨y, hy, z * hd, is_submonoid.mul_mem hz (subset_closure ht),\n          by rw [← mul_assoc, list.prod_cons, ← hyzx, mul_comm hd]; refl⟩)) HL1,\nλ ⟨y, hy, z, hz, hyzx⟩, hyzx ▸ is_submonoid.mul_mem (closure_mono (set.subset_union_left _ _) hy)\n  (closure_mono (set.subset_union_right _ _) hz)⟩\n\nend monoid\n\n/-- Create a bundled submonoid from a set `s` and `[is_submonoid s]`. -/\n@[to_additive \"Create a bundled additive submonoid from a set `s` and `[is_add_submonoid s]`.\"]\ndef submonoid.of (s : set M) [h : is_submonoid s] : submonoid M := ⟨s, h.1, h.2⟩\n\n@[to_additive]\ninstance submonoid.is_submonoid (S : submonoid M) : is_submonoid (S : set M) := ⟨S.2, S.3⟩\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/deprecated/submonoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.4675439765509134}}
{"text": "import .basic ..data.dvector\n\n/- Some definitions for specifying normal subgroups generated by group elements and by defining a group by generators and relations -/\n\nopen quotient_group set\nopen category_theory (mk_ob)\n\nvariables {α : Type*} [group α]\n\n/-- the subgroup generated by a set is a normal subgroup if the set is closed under conjugates -/\nlemma closure.normal_subgroup {s : set α} (hs : ∀ n ∈ s, ∀ g : α, g * n * g⁻¹ ∈ s) :\n  normal_subgroup (group.closure s) :=\nbegin\n  fapply normal_subgroup.mk, intros n H g, induction H,\n  { constructor, apply hs _ H_a_1 },\n  { simp, apply group.in_closure.one },\n  { have := group.in_closure.inv (H_ih), simp only [mul_inv_rev, inv_inv] at this,\n    rwa [mul_assoc] },\n  { have := group.in_closure.mul (H_ih_a) (H_ih_a_1),\n    rwa [mul_assoc, ←mul_assoc g⁻¹, inv_mul_cancel_left, ←mul_assoc, mul_assoc g] at this },\nend\n\n/-- The smallest set containing s closed under conjugations -/\ninductive conjugates (s : set α) : set α\n| base : Π{{x}}, x ∈ s → conjugates x\n| normal : Π{{x}} y, conjugates x → conjugates (y * x * y⁻¹)\n\n/-- Given a set s of group elements, return the normal subgroup of α generated by s.\n  This is called the conjugate closure, normal closure or the normal subgroup generated by s. -/\ndef normal_closure (s : set α) : set α :=\ngroup.closure (conjugates s)\n\ninstance (s : set α) : normal_subgroup (normal_closure s) :=\nclosure.normal_subgroup $ λ x hx y, conjugates.normal y hx\n\ndef group_modulo_relations (α : Type*) [group α] (s : set α) : Group :=\nmk_ob $ quotient_group.quotient (normal_closure s)\n\nnotation α `/⟪`:95 R `⟫`:90 := group_modulo_relations α R\n\ndef group_of_generators_relations (gen : Type*) (relations : set (free_group gen)) : Group :=\n(free_group gen)/⟪relations⟫\n\nnotation `⟪`:95 G `|`:90 R`⟫`:0 := group_of_generators_relations G R\n\ndef generated_of {G : Type*} {R : set (free_group G)} : G → ⟪G | R⟫ :=\n  λ g, quotient_group.mk $ free_group.of g\n\nlocal notation `⟪`:50 a `⟫`:50 := free_group.of a\n\ndef cyclic_group_presentation (n : ℕ) : Group := ⟪unit |{ ⟪()⟫^n }⟫\n\n/- The dihedral groups -/\n\n/- The dihedral groups are an easy case of the Coxeter groups -/\nnamespace dihedral_group\ndef r := ⟪ff⟫\ndef s := ⟪tt⟫\nend dihedral_group\nopen dihedral_group\n\n/-- The dihedral group of order 2n -/\ndef dihedral_group (n : ℕ) : Group := ⟪bool | {r^n, s^2, s * r * s * r}⟫\n\n/-- The Coxeter group is the group with presentation ⟨ r_1, ... r_n | (r_ir_j)^{m_{i,j}} = 1 ⟩\nIf m_{i,j} = ∞, then no relation is imposed on r_ir_j. -/\n-- Note: we currently don't require that m i i = 1 for all i, and that m i j ≥ 2 for i ≠ j.\ndef coxeter_group {α : Type*} (m : α → α → enat) : Group :=\n⟪α | set.range (λ(x : α × α), (⟪x.1⟫ * ⟪x.2⟫)^(m x.1 x.2)) ⟫\n\n/-- coxeter_group' adds new generators with no Coxeter relations on them -/\ndef coxeter_group' {α : Type*} (m : α → α → enat) (β : Type*) : Group :=\n⟪α⊕β | set.range (λ(x : α × α), (⟪sum.inl x.1⟫ * ⟪sum.inl x.2⟫)^m x.1 x.2) ⟫\n\ndef matrix_of_graph {α : Type*} [decidable_eq α] (E : α → α → Prop) [decidable_rel E] (x y : α) :\n  enat :=\nif x = y then 1 else if E x y then 3 else 2\n\n/- Annotated graphs for generalized Coxeter-type presentations (see xviii of the atlas) -/\nstructure annotated_graph :=\n  (vertex : Type*)\n  (edge : vertex → vertex → Prop)\n  (annotation : Π{{x y}}, edge x y → enat)\n\n/-- Turn a binary relation on a type into an annotated graph.\n  By default, all edges are annotated with 3. -/\ndef annotated_graph_of_graph {α : Type*} (E : α → α → Prop) : annotated_graph :=\n{ vertex := α,\n  edge := E,\n  annotation := λ _ _ _, 3}\n\ndef matrix_of_annotated_graph (Γ : annotated_graph) [decidable_eq Γ.vertex] [decidable_rel Γ.edge]\n  (x y : Γ.vertex) : enat :=\nif x = y then 1 else if h : Γ.edge x y then Γ.annotation h else 2\n\n/-- \"annotate Γ (a,b) n\" returns an annotated graph Γ' which is identical to Γ, except that Γ'.annotation a b = n. -/\ndef annotate (Γ : annotated_graph) [decidable_rel Γ.edge] [decidable_eq Γ.vertex] (x : Γ.vertex × Γ.vertex) (n : ℕ+) : annotated_graph :=\n{ vertex := Γ.vertex,\n  edge := Γ.edge,\n  annotation := λ a b H, if (a = x.1 ∧ b = x.2) ∨ (a = x.2 ∧ b = x.1) then n else Γ.annotation H }\n\n/-- \"insert edge Γ (a,b) n\" returns Γ' which is Γ except Γ'.edge a b and Γ'.edge b a are true and annotated with n.\nIf an edge is already present, this does nothing. -/\ndef insert_edge (Γ : annotated_graph) [decidable_rel Γ.edge] [decidable_eq Γ.vertex] (x : Γ.vertex × Γ.vertex) (n : ℕ+) : annotated_graph :=\n{ vertex := Γ.vertex,\n  edge := λ a b, if (a = x.1 ∧ b = x.2) ∨ (a = x.2 ∧ b = x.1) then true else Γ.edge a b,\n  annotation := λ a b H, if h : Γ.edge a b then Γ.annotation h else n }\n\n/- Coxeter Y-diagrams -/\n@[derive decidable_eq] inductive coxeter_vertices {n} (xs : dvector ℕ+ n) : Type\n| torso {} : coxeter_vertices\n| arm : ∀ x : dfin n, dfin (xs.nth'' x) → coxeter_vertices\n\nopen coxeter_vertices\n\ninductive coxeter_edges_directed {n} (xs : dvector ℕ+ n) :\n  coxeter_vertices xs → coxeter_vertices xs → Prop\n| edge_torso : ∀ i : dfin n , coxeter_edges_directed torso (arm i dfin.fz')\n| edge_arm : ∀ i : dfin n, ∀ v : dfin (xs.nth'' i), v.to_nat + 1 ≠ xs.nth'' i →\n    coxeter_edges_directed (arm i v) (arm i (v+1))\n\ninductive symmetric_closure {α : Type*} (E : α → α → Prop) : α → α → Prop\n| incl : ∀ a b : α, E a b → symmetric_closure a b\n| symm : ∀ a b : α, E a b → symmetric_closure b a\n\ndef coxeter_edges {n} (xs : dvector ℕ+ n) : coxeter_vertices xs → coxeter_vertices xs → Prop :=\nsymmetric_closure (coxeter_edges_directed xs)\n\n-- TODO derive decidability instances\nnoncomputable instance decidable_coxeter_edges {n} (xs : dvector ℕ+ n) :\n  decidable_rel $ coxeter_edges xs :=\nλ _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_rel_annotated_coxeter_edges {n} (xs : dvector ℕ+ n) :\n  decidable_rel $ (annotated_graph_of_graph (coxeter_edges xs)).edge :=\nλ _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_eq_annotate_of_decidable (Γ : annotated_graph)\n  [decidable_eq Γ.vertex] [decidable_rel Γ.edge] (x n) : decidable_eq $ (annotate Γ x n).vertex :=\nλ _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_rel_annotate_of_decidable (Γ : annotated_graph)\n  [decidable_eq Γ.vertex] [decidable_rel Γ.edge] (x n) : decidable_rel $ (annotate Γ x n).edge :=\nλ _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_eq_insert_edge_of_decidable (Γ : annotated_graph)\n  [decidable_rel Γ.edge] [decidable_eq Γ.vertex] (x n) : decidable_eq $ (insert_edge Γ x n).vertex :=\nλ _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_rel_insert_edge_of_decidable (Γ : annotated_graph)\n  [decidable_rel Γ.edge] [decidable_eq Γ.vertex] (x n) : decidable_rel $ (insert_edge Γ x n).edge :=\nλ _ _, classical.prop_decidable _\n\n/- Derived subgroups -/\n\ndef commutator {α : Type*} [group α] : α × α → α\n| ⟨x, y⟩ :=  x * y * x⁻¹ * y⁻¹\n\nnotation `⟦`:95 x `,` y `⟧`:0 := commutator (x,y)\n\ndef commutators_of {α : Type*} [group α] (s : set α) : set α :=\ngroup.closure $ commutator '' s.prod s\n\n/-- the derived subgroup of commutator subgroup is the subgroup generated by all commutators -/\ndef derived_subgroup (α : Type*) [group α] : set α :=\ncommutators_of set.univ\n\ninstance (α : Type*) [group α] : normal_subgroup (derived_subgroup α) :=\nbegin\n  apply closure.normal_subgroup, intros x hx g, rcases hx with ⟨⟨y, z⟩, h, rfl⟩,\n  use ⟨g * y * g⁻¹, g * z * g⁻¹⟩,\n  split, split; trivial,\n  simp [commutator, mul_assoc]\nend\n\n/-- The n-th derived subgroup is defined by iterating the derived subgroup operation -/\ndef iterated_derived_subgroup (α : Type*) [group α] (n : ℕ) : set α :=\nnat.iterate commutators_of n set.univ\n\n/-- the abelianization of G is the group G quotiented by its derived subgroup -/\ndef abelianization (α : Type*) [group α] : Group :=\nmk_ob $ quotient_group.quotient $ derived_subgroup α\n\n/-- A group is called perfect if its derived subgroup is the whole group -/\ndef is_perfect (α : Type*) [group α] : Prop := derived_subgroup α = set.univ\n\n/-- A group is called solvable if its derived series eventually becomes trivial -/\ndef is_solvable (α : Type*) [group α] : Prop := ∃ n, iterated_derived_subgroup α n = {1}\n", "meta": {"author": "formalabstracts", "repo": "formalabstracts", "sha": "b0173da1af45421239d44492eeecd54bf65ee0f6", "save_path": "github-repos/lean/formalabstracts-formalabstracts", "path": "github-repos/lean/formalabstracts-formalabstracts/formalabstracts-b0173da1af45421239d44492eeecd54bf65ee0f6/src/group_theory/presentation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4675439579510833}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\n\nimport control.functor.multivariate\nimport data.qpf.multivariate.basic\n\n/-!\n# Constant functors are QPFs\n\nConstant functors map every type vectors to the same target type. This\nis a useful device for constructing data types from more basic types\nthat are not actually functorial. For instance `const n nat` makes\n`nat` into a functor that can be used in a functor-based data type\nspecification.\n-/\n\nuniverses u\n\nnamespace mvqpf\nopen_locale mvfunctor\n\nvariables (n : ℕ)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A α} [inhabited A] : inhabited (const n A α) :=\n⟨ (default : A) ⟩\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {α β : typevec.{u} n} (f : α ⟹ β)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) α := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) α) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) α) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A α) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) α → (const n A) β :=\nλ x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := λ α β f, const.map }\n\nlemma map_mk (x : A) :\n  f <$$> const.mk x = const.mk x := rfl\n\nlemma get_map (x : (const n A) α) :\n  const.get (f <$$> x) = const.get x := rfl\n\ninstance mvqpf : @mvqpf _ (const n A) (mvqpf.const.mvfunctor) :=\n{ P         := mvpfunctor.const n A,\n  abs       := λ α x, mvpfunctor.const.get x,\n  repr      := λ α x, mvpfunctor.const.mk n x,\n  abs_repr  := by intros; simp,\n  abs_map   := by intros; simp; refl, }\n\nend const\n\nend mvqpf\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/data/qpf/multivariate/constructions/const.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.46754395510422375}}
{"text": "-- Copyright (c) 2018 Michael Jendrusch. All rights reserved.\n\nimport category_theory.category\nimport category_theory.functor\nimport category_theory.products\nimport category_theory.natural_isomorphism\nimport category_theory.tactics.obviously -- Give ourselves access to `rewrite_search`\nimport .tensor_product\nimport tactic.slice\n\nopen category_theory\nopen tactic\n\nuniverses v u\n\nopen category_theory.category\nopen category_theory.functor\nopen category_theory.prod\nopen category_theory.functor.category.nat_trans\nopen category_theory.nat_iso\n\nnamespace category_theory.monoidal\nclass monoidal_category (C : Sort u) extends category.{v} C :=\n-- curried tensor product of objects:\n(tensor_obj               : C → C → C)\n-- curried tensor product of morphisms:\n(tensor_hom               : Π {X₁ Y₁ X₂ Y₂ : C}, hom X₁ Y₁ → hom X₂ Y₂ → hom (tensor_obj X₁ X₂) (tensor_obj Y₁ Y₂))\n-- tensor product laws:\n(tensor_map_id'           : ∀ (X₁ X₂ : C), tensor_hom (𝟙 X₁) (𝟙 X₂) = 𝟙 (tensor_obj X₁ X₂) . obviously)\n(tensor_map_comp'         : ∀ {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂),\n  tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) = (tensor_hom f₁ f₂) ≫ (tensor_hom g₁ g₂) . obviously)\n-- tensor unit:\n(tensor_unit              : C)\n-- associator:\n(associator               : Π X Y Z : C, (tensor_obj (tensor_obj X Y) Z) ≅ (tensor_obj X (tensor_obj Y Z)))\n(associator_naturality'   : assoc_natural tensor_obj @tensor_hom associator . obviously)\n-- left unitor:\n(left_unitor              : Π X : C, tensor_obj tensor_unit X ≅ X)\n(left_unitor_naturality'  : left_unitor_natural tensor_obj @tensor_hom tensor_unit left_unitor . obviously)\n-- right unitor:\n(right_unitor             : Π X : C, tensor_obj X tensor_unit ≅ X)\n(right_unitor_naturality' : right_unitor_natural tensor_obj @tensor_hom tensor_unit right_unitor . obviously)\n-- pentagon identity:\n(pentagon'                : pentagon @tensor_hom associator . obviously)\n-- triangle identity:\n(triangle'                : triangle @tensor_hom left_unitor right_unitor associator . obviously)\n\nrestate_axiom monoidal_category.tensor_map_id'\nattribute [simp,search] monoidal_category.tensor_map_id\nrestate_axiom monoidal_category.tensor_map_comp'\nattribute [simp,search] monoidal_category.tensor_map_comp\nrestate_axiom monoidal_category.associator_naturality'\nattribute [search] monoidal_category.associator_naturality\nrestate_axiom monoidal_category.left_unitor_naturality'\nattribute [search] monoidal_category.left_unitor_naturality\nrestate_axiom monoidal_category.right_unitor_naturality'\nattribute [search] monoidal_category.right_unitor_naturality\nrestate_axiom monoidal_category.pentagon'\nattribute [search] monoidal_category.pentagon\nrestate_axiom monoidal_category.triangle'\nattribute [search] monoidal_category.triangle\n\n@[obviously] meta def obviously'' := tactic.tidy {tactics := tidy.default_tactics ++ [rewrite_search {}]}\n\nsection\nopen monoidal_category\n\ndef one {C : Sort u} [monoidal_category.{v} C] (X : C) : X ≅ X :=\n{ hom := 𝟙 X,\n  inv := 𝟙 X }\n\ndef tensor_iso {C : Sort u} {X Y X' Y' : C} [monoidal_category.{v} C] (f : X ≅ Y) (g : X' ≅ Y') :\n    tensor_obj X X' ≅ tensor_obj Y Y' :=\n{ hom := tensor_hom f.hom g.hom,\n  inv := tensor_hom f.inv g.inv}\nend\n\n\nopen monoidal_category\n\nsection\n\nvariables (C : Sort u) [𝒞 : monoidal_category.{v} C]\ninclude 𝒞\n\ninstance : category C := 𝒞.to_category\n\ninfixr ` ⊗ `:80 := tensor_obj\ninfixr ` ⊗ `:80 := tensor_hom\ninfixr ` ⊗ `:80 := tensor_iso\n\nvariables {U V W X Y Z : C}\n\n@[search] definition interchange (f : U ⟶ V) (g : V ⟶ W) (h : X ⟶ Y) (k : Y ⟶ Z)\n  : (f ≫ g) ⊗ (h ≫ k) = (f ⊗ h) ≫ (g ⊗ k) :=\ntensor_map_comp C f h g k\n\n@[simp,search] lemma interchange_left_identity (f : W ⟶ X) (g : X ⟶ Y) :\n  (f ⊗ (𝟙 Z)) ≫ (g ⊗ (𝟙 Z)) = (f ≫ g) ⊗ (𝟙 Z) :=\nbegin\n  rw ←interchange,\n  simp\nend\n\n@[simp,search] lemma interchange_right_identity (f : W ⟶ X) (g : X ⟶ Y) :\n  (𝟙 Z ⊗ f) ≫ (𝟙 Z ⊗ g) = (𝟙 Z) ⊗ (f ≫ g) :=\nbegin\n  rw ←interchange,\n  simp\nend\n\n@[search] lemma interchange_identities (f : W ⟶ X) (g : Y ⟶ Z) :\n  ((𝟙 Y) ⊗ f) ≫ (g ⊗ (𝟙 X)) = (g ⊗ (𝟙 W)) ≫ ((𝟙 Z) ⊗ f) :=\nbegin\n  rw ←interchange,\n  rw ←interchange,\n  simp\nend\n\ninstance tensor_iso_of_iso\n    {X Y X' Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y')\n    [is_iso f] [is_iso g] : is_iso (f ⊗ g) :=\n{ inv := (is_iso.inv f) ⊗ (is_iso.inv g) }\n\n@[simp,search] lemma tensor_left_equiv\n    {X Y : C} (f g : X ⟶ Y) :\n    ((𝟙 (tensor_unit C)) ⊗ f = (𝟙 (tensor_unit C)) ⊗ g) ↔ (f = g) :=\nsorry\n\n@[simp,search] lemma tensor_right_equiv\n    {X Y : C} (f g : X ⟶ Y) :\n    (f ⊗ (𝟙 (tensor_unit C)) = g ⊗ (𝟙 (tensor_unit C))) ↔ (f = g) :=\nsorry\n\n-- proof following the nLab:\n@[search] lemma left_unitor_product_aux_perimeter (X Y : C) :\n    ((associator (tensor_unit C) (tensor_unit C) X).hom ⊗ (𝟙 Y)) ≫\n    (associator (tensor_unit C) ((tensor_unit C) ⊗ X) Y).hom ≫\n    ((𝟙 (tensor_unit C)) ⊗ (associator (tensor_unit C) X Y).hom) ≫\n    ((𝟙 (tensor_unit C)) ⊗ (left_unitor (X ⊗ Y)).hom)\n  = (((right_unitor (tensor_unit C)).hom ⊗ (𝟙 X)) ⊗ (𝟙 Y)) ≫\n    (associator (tensor_unit C) X Y).hom := by obviously\n\n@[search] lemma left_unitor_product_aux_triangle (X Y : C) :\n    ((associator (tensor_unit C) (tensor_unit C) X).hom ⊗ (𝟙 Y)) ≫\n    (((𝟙 (tensor_unit C)) ⊗ (left_unitor X).hom) ⊗ (𝟙 Y))\n  = ((right_unitor (tensor_unit C)).hom ⊗ (𝟙 X)) ⊗ (𝟙 Y) := by obviously\n\n@[search] lemma left_unitor_product_aux_square (X Y : C) :\n    (associator (tensor_unit C) ((tensor_unit C) ⊗ X) Y).hom ≫\n    ((𝟙 (tensor_unit C)) ⊗ (left_unitor X).hom ⊗ (𝟙 Y))\n  = (((𝟙 (tensor_unit C)) ⊗ (left_unitor X).hom) ⊗ (𝟙 Y)) ≫\n    (associator (tensor_unit C) X Y).hom := by obviously\n\n@[search] lemma left_unitor_product_aux (X Y : C) :\n    ((𝟙 (tensor_unit C)) ⊗ (associator (tensor_unit C) X Y).hom) ≫\n    ((𝟙 (tensor_unit C)) ⊗ (left_unitor (X ⊗ Y)).hom)\n  = (𝟙 (tensor_unit C)) ⊗ ((left_unitor X).hom ⊗ (𝟙 Y)) :=\nbegin\n  rw <-(cancel_epi (associator (tensor_unit C) ((tensor_unit C) ⊗ X) Y).hom),\n  rw left_unitor_product_aux_square,\n  rw <-(cancel_epi ((associator (tensor_unit C) (tensor_unit C) X).hom ⊗ (𝟙 Y))),\n  conv {\n    to_rhs,\n    slice 1 2,\n    rw left_unitor_product_aux_triangle,\n  },\n  obviously\nend\n\n@[search] lemma right_unitor_product_aux_perimeter (X Y : C) :\n    ((associator X Y (tensor_unit C)).hom ⊗ (𝟙 (tensor_unit C))) ≫\n    (associator X (Y ⊗ (tensor_unit C)) (tensor_unit C)).hom ≫\n    ((𝟙 X) ⊗ (associator Y (tensor_unit C) (tensor_unit C)).hom) ≫\n    ((𝟙 X) ⊗ (𝟙 Y) ⊗ (left_unitor (tensor_unit C)).hom)\n  = ((right_unitor (X ⊗ Y)).hom ⊗ (𝟙 (tensor_unit C))) ≫\n    (associator X Y (tensor_unit C)).hom := by obviously\n\n@[search] lemma right_unitor_product_aux_triangle (X Y : C) :\n    ((𝟙 X) ⊗ (associator Y (tensor_unit C) (tensor_unit C)).hom) ≫\n    ((𝟙 X) ⊗ (𝟙 Y) ⊗ (left_unitor (tensor_unit C)).hom)\n  = (𝟙 X) ⊗ (right_unitor Y).hom ⊗ (𝟙 (tensor_unit C)) := by obviously\n\n@[search] lemma right_unitor_product_aux_square (X Y : C) :\n    (associator X (Y ⊗ (tensor_unit C)) (tensor_unit C)).hom ≫\n    ((𝟙 X) ⊗ (right_unitor Y).hom ⊗ (𝟙 (tensor_unit C)))\n  = (((𝟙 X) ⊗ (right_unitor Y).hom) ⊗ (𝟙 (tensor_unit C))) ≫\n    (associator X Y (tensor_unit C)).hom := by obviously\n\n@[search] lemma right_unitor_product_aux (X Y : C) :\n    ((associator X Y (tensor_unit C)).hom ⊗ (𝟙 (tensor_unit C))) ≫\n    (((𝟙 X) ⊗ (right_unitor Y).hom) ⊗ (𝟙 (tensor_unit C)))\n  = ((right_unitor (X ⊗ Y)).hom ⊗ (𝟙 (tensor_unit C))) :=\nbegin\n  rw <-(cancel_mono (associator X Y (tensor_unit C)).hom),\n  conv {\n    to_lhs,\n    slice 2 3,\n    rw <-right_unitor_product_aux_square,\n  },\n  obviously\nend\n\n@[search] lemma left_unitor_product (X Y : C) :\n  ((associator (tensor_unit C) X Y).hom) ≫\n    ((left_unitor (X ⊗ Y)).hom)\n  = ((left_unitor X).hom ⊗ (𝟙 Y)) :=\nbegin\n  rw <-tensor_left_equiv,\n  rw <-interchange_right_identity,\n  apply left_unitor_product_aux\nend\n\n@[search] lemma right_unitor_product (X Y : C) :\n    ((associator X Y (tensor_unit C)).hom) ≫\n    ((𝟙 X) ⊗ (right_unitor Y).hom)\n  = ((right_unitor (X ⊗ Y)).hom) :=\nbegin\n  rw <-tensor_right_equiv,\n  rw <-interchange_left_identity,\n  apply right_unitor_product_aux\nend\n\nend\n\nsection\n\n-- In order to be able to describe the tensor product as a functor, we\n-- need to be up in at least `Type 1` for both objects and morphisms,\n-- so that we can construct products.\nvariables (C : Type u) [𝒞 : monoidal_category.{v+1} C]\ninclude 𝒞\n\n@[reducible] def monoidal_category.tensor : (C × C) ⥤ C :=\n{ obj := λ X, tensor_obj X.1 X.2,\n  map := λ {X Y : C × C} (f : X ⟶ Y), tensor_hom f.1 f.2 }\n\n@[reducible] def monoidal_category.left_assoc_functor : (C × C × C) ⥤ C :=\n{ obj := λ X, (X.1 ⊗ X.2.1) ⊗ X.2.2,\n  map := λ {X Y : C × C × C} (f : X ⟶ Y),\n    (f.1 ⊗ f.2.1) ⊗ f.2.2 }\n@[reducible] def monoidal_category.right_assoc_functor : (C × C × C) ⥤ C :=\n{ obj := λ X, X.1 ⊗ (X.2.1 ⊗ X.2.2),\n  map := λ {X Y : C × C × C} (f : X ⟶ Y),\n    f.1 ⊗ (f.2.1 ⊗ f.2.2) }\n@[reducible] def monoidal_category.left_unitor_functor : C ⥤ C :=\n{ obj := λ X, tensor_unit C ⊗ X,\n  map := λ {X Y : C} (f : X ⟶ Y), (𝟙 (tensor_unit C)) ⊗ f }\n@[reducible] def monoidal_category.right_unitor_functor : C ⥤ C :=\n{ obj := λ X, X ⊗ tensor_unit C,\n  map := λ {X Y : C} (f : X ⟶ Y), f ⊗ (𝟙 (tensor_unit C)) }\n\nopen monoidal_category\n\n-- natural isomorphisms for the associator and unitors.\n\n@[reducible] def monoidal_category.associator_nat_iso :\n  left_assoc_functor C ≅ right_assoc_functor C :=\nnat_iso.of_components\n  (by intros; simp; apply category_theory.monoidal.monoidal_category.associator)\n  (by intros; simp; apply associator_naturality)\n@[reducible] def monoidal_category.left_unitor_nat_iso :\n  left_unitor_functor C ≅ functor.id C :=\nnat_iso.of_components\n  (by intros; simp; apply category_theory.monoidal.monoidal_category.left_unitor)\n  (by intros; simp; apply left_unitor_naturality)\n@[reducible] def monoidal_category.right_unitor_nat_iso :\n  right_unitor_functor C ≅ functor.id C :=\nnat_iso.of_components\n  (by intros; simp; apply category_theory.monoidal.monoidal_category.right_unitor)\n  (by intros; simp; apply right_unitor_naturality)\n\nend\n\nend category_theory.monoidal\n", "meta": {"author": "mjendrusch", "repo": "monoidal-categories-reboot", "sha": "56633e549be01f389e6fe8a86dfa36970fd5fdc4", "save_path": "github-repos/lean/mjendrusch-monoidal-categories-reboot", "path": "github-repos/lean/mjendrusch-monoidal-categories-reboot/monoidal-categories-reboot-56633e549be01f389e6fe8a86dfa36970fd5fdc4/src/monoidal_categories_reboot/monoidal_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.46734174114667076}}
{"text": "/-\nCopyright (c) 2022 Rémi Bottinelli. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémi Bottinelli, Junyan Xu\n\n! This file was ported from Lean 3 source module category_theory.groupoid.subgroupoid\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Groupoid.VertexGroup\nimport Mathbin.CategoryTheory.Groupoid.Basic\nimport Mathbin.CategoryTheory.Groupoid\nimport Mathbin.Algebra.Group.Defs\nimport Mathbin.Data.Set.Lattice\nimport Mathbin.GroupTheory.Subgroup.Basic\nimport Mathbin.Order.GaloisConnection\n\n/-!\n# Subgroupoid\n\nThis file defines subgroupoids as `structure`s containing the subsets of arrows and their\nstability under composition and inversion.\nAlso defined are:\n\n* containment of subgroupoids is a complete lattice;\n* images and preimages of subgroupoids under a functor;\n* the notion of normality of subgroupoids and its stability under intersection and preimage;\n* compatibility of the above with `groupoid.vertex_group`.\n\n\n## Main definitions\n\nGiven a type `C` with associated `groupoid C` instance.\n\n* `subgroupoid C` is the type of subgroupoids of `C`\n* `subgroupoid.is_normal` is the property that the subgroupoid is stable under conjugation\n  by arbitrary arrows, _and_ that all identity arrows are contained in the subgroupoid.\n* `subgroupoid.comap` is the \"preimage\" map of subgroupoids along a functor.\n* `subgroupoid.map` is the \"image\" map of subgroupoids along a functor _injective on objects_.\n* `subgroupoid.vertex_subgroup` is the subgroup of the `vertex group` at a given vertex `v`,\n  assuming `v` is contained in the `subgroupoid` (meaning, by definition, that the arrow `𝟙 v`\n  is contained in the subgroupoid).\n\n## Implementation details\n\nThe structure of this file is copied from/inspired by `group_theory.subgroup.basic`\nand `combinatorics.simple_graph.subgraph`.\n\n## TODO\n\n* Equivalent inductive characterization of generated (normal) subgroupoids.\n* Characterization of normal subgroupoids as kernels.\n* Prove that `full` and `disconnect` preserve intersections (and `disconnect` also unions)\n\n## Tags\n\nsubgroupoid\n\n-/\n\n\nnamespace CategoryTheory\n\nopen Set Groupoid\n\nattribute [local protected] CategoryTheory.inv\n\nuniverse u v\n\nvariable {C : Type u} [Groupoid C]\n\n/-- A sugroupoid of `C` consists of a choice of arrows for each pair of vertices, closed\nunder composition and inverses.\n-/\n@[ext]\nstructure Subgroupoid (C : Type u) [Groupoid C] where\n  arrows : ∀ c d : C, Set (c ⟶ d)\n  inv : ∀ {c d} {p : c ⟶ d} (hp : p ∈ arrows c d), inv p ∈ arrows d c\n  mul : ∀ {c d e} {p} (hp : p ∈ arrows c d) {q} (hq : q ∈ arrows d e), p ≫ q ∈ arrows c e\n#align category_theory.subgroupoid CategoryTheory.Subgroupoid\n\nattribute [protected] subgroupoid.inv subgroupoid.mul\n\nnamespace Subgroupoid\n\nvariable (S : Subgroupoid C)\n\ntheorem inv_mem_iff {c d : C} (f : c ⟶ d) : inv f ∈ S.arrows d c ↔ f ∈ S.arrows c d :=\n  by\n  constructor\n  · rintro h\n    suffices inv (inv f) ∈ S.arrows c d by simpa only [inv_eq_inv, is_iso.inv_inv] using this\n    · apply S.inv h\n  · apply S.inv\n#align category_theory.subgroupoid.inv_mem_iff CategoryTheory.Subgroupoid.inv_mem_iff\n\ntheorem mul_mem_cancel_left {c d e : C} {f : c ⟶ d} {g : d ⟶ e} (hf : f ∈ S.arrows c d) :\n    f ≫ g ∈ S.arrows c e ↔ g ∈ S.arrows d e :=\n  by\n  constructor\n  · rintro h\n    suffices inv f ≫ f ≫ g ∈ S.arrows d e by\n      simpa only [inv_eq_inv, is_iso.inv_hom_id_assoc] using this\n    · apply S.mul (S.inv hf) h\n  · apply S.mul hf\n#align category_theory.subgroupoid.mul_mem_cancel_left CategoryTheory.Subgroupoid.mul_mem_cancel_left\n\ntheorem mul_mem_cancel_right {c d e : C} {f : c ⟶ d} {g : d ⟶ e} (hg : g ∈ S.arrows d e) :\n    f ≫ g ∈ S.arrows c e ↔ f ∈ S.arrows c d :=\n  by\n  constructor\n  · rintro h\n    suffices (f ≫ g) ≫ inv g ∈ S.arrows c d by\n      simpa only [inv_eq_inv, is_iso.hom_inv_id, category.comp_id, category.assoc] using this\n    · apply S.mul h (S.inv hg)\n  · exact fun hf => S.mul hf hg\n#align category_theory.subgroupoid.mul_mem_cancel_right CategoryTheory.Subgroupoid.mul_mem_cancel_right\n\n/-- The vertices of `C` on which `S` has non-trivial isotropy -/\ndef objs : Set C :=\n  { c : C | (S.arrows c c).Nonempty }\n#align category_theory.subgroupoid.objs CategoryTheory.Subgroupoid.objs\n\ntheorem mem_objs_of_src {c d : C} {f : c ⟶ d} (h : f ∈ S.arrows c d) : c ∈ S.objs :=\n  ⟨f ≫ inv f, S.mul h (S.inv h)⟩\n#align category_theory.subgroupoid.mem_objs_of_src CategoryTheory.Subgroupoid.mem_objs_of_src\n\ntheorem mem_objs_of_tgt {c d : C} {f : c ⟶ d} (h : f ∈ S.arrows c d) : d ∈ S.objs :=\n  ⟨inv f ≫ f, S.mul (S.inv h) h⟩\n#align category_theory.subgroupoid.mem_objs_of_tgt CategoryTheory.Subgroupoid.mem_objs_of_tgt\n\ntheorem id_mem_of_nonempty_isotropy (c : C) : c ∈ objs S → 𝟙 c ∈ S.arrows c c :=\n  by\n  rintro ⟨γ, hγ⟩\n  convert S.mul hγ (S.inv hγ)\n  simp only [inv_eq_inv, is_iso.hom_inv_id]\n#align category_theory.subgroupoid.id_mem_of_nonempty_isotropy CategoryTheory.Subgroupoid.id_mem_of_nonempty_isotropy\n\ntheorem id_mem_of_src {c d : C} {f : c ⟶ d} (h : f ∈ S.arrows c d) : 𝟙 c ∈ S.arrows c c :=\n  id_mem_of_nonempty_isotropy S c (mem_objs_of_src S h)\n#align category_theory.subgroupoid.id_mem_of_src CategoryTheory.Subgroupoid.id_mem_of_src\n\ntheorem id_mem_of_tgt {c d : C} {f : c ⟶ d} (h : f ∈ S.arrows c d) : 𝟙 d ∈ S.arrows d d :=\n  id_mem_of_nonempty_isotropy S d (mem_objs_of_tgt S h)\n#align category_theory.subgroupoid.id_mem_of_tgt CategoryTheory.Subgroupoid.id_mem_of_tgt\n\n/-- A subgroupoid seen as a quiver on vertex set `C` -/\ndef asWideQuiver : Quiver C :=\n  ⟨fun c d => Subtype <| S.arrows c d⟩\n#align category_theory.subgroupoid.as_wide_quiver CategoryTheory.Subgroupoid.asWideQuiver\n\n/-- The coercion of a subgroupoid as a groupoid -/\n@[simps to_category_comp_coe, simps (config := lemmasOnly) inv_coe]\ninstance coe : Groupoid S.objs where\n  Hom a b := S.arrows a.val b.val\n  id a := ⟨𝟙 a.val, id_mem_of_nonempty_isotropy S a.val a.Prop⟩\n  comp a b c p q := ⟨p.val ≫ q.val, S.mul p.Prop q.Prop⟩\n  id_comp' := fun a b ⟨p, hp⟩ => by simp only [category.id_comp]\n  comp_id' := fun a b ⟨p, hp⟩ => by simp only [category.comp_id]\n  assoc' := fun a b c d ⟨p, hp⟩ ⟨q, hq⟩ ⟨r, hr⟩ => by simp only [category.assoc]\n  inv a b p := ⟨inv p.val, S.inv p.Prop⟩\n  inv_comp' := fun a b ⟨p, hp⟩ => by simp only [inv_comp]\n  comp_inv' := fun a b ⟨p, hp⟩ => by simp only [comp_inv]\n#align category_theory.subgroupoid.coe CategoryTheory.Subgroupoid.coe\n\n@[simp]\ntheorem coe_inv_coe' {c d : S.objs} (p : c ⟶ d) :\n    (CategoryTheory.inv p).val = CategoryTheory.inv p.val := by\n  simp only [Subtype.val_eq_coe, ← inv_eq_inv, coe_inv_coe]\n#align category_theory.subgroupoid.coe_inv_coe' CategoryTheory.Subgroupoid.coe_inv_coe'\n\n/-- The embedding of the coerced subgroupoid to its parent-/\ndef hom : S.objs ⥤ C where\n  obj c := c.val\n  map c d f := f.val\n  map_id' c := rfl\n  map_comp' c d e f g := rfl\n#align category_theory.subgroupoid.hom CategoryTheory.Subgroupoid.hom\n\ntheorem hom.inj_on_objects : Function.Injective (hom S).obj :=\n  by\n  rintro ⟨c, hc⟩ ⟨d, hd⟩ hcd\n  simp only [Subtype.mk_eq_mk]\n  exact hcd\n#align category_theory.subgroupoid.hom.inj_on_objects CategoryTheory.Subgroupoid.hom.inj_on_objects\n\ntheorem hom.faithful : ∀ c d, Function.Injective fun f : c ⟶ d => (hom S).map f :=\n  by\n  rintro ⟨c, hc⟩ ⟨d, hd⟩ ⟨f, hf⟩ ⟨g, hg⟩ hfg\n  simp only [Subtype.mk_eq_mk]\n  exact hfg\n#align category_theory.subgroupoid.hom.faithful CategoryTheory.Subgroupoid.hom.faithful\n\n/-- The subgroup of the vertex group at `c` given by the subgroupoid -/\ndef vertexSubgroup {c : C} (hc : c ∈ S.objs) : Subgroup (c ⟶ c)\n    where\n  carrier := S.arrows c c\n  mul_mem' f g hf hg := S.mul hf hg\n  one_mem' := id_mem_of_nonempty_isotropy _ _ hc\n  inv_mem' f hf := S.inv hf\n#align category_theory.subgroupoid.vertex_subgroup CategoryTheory.Subgroupoid.vertexSubgroup\n\ninstance : SetLike (Subgroupoid C) (Σc d : C, c ⟶ d)\n    where\n  coe S := { F | F.2.2 ∈ S.arrows F.1 F.2.1 }\n  coe_injective' := fun ⟨S, _, _⟩ ⟨T, _, _⟩ h =>\n    by\n    ext (c d f)\n    apply Set.ext_iff.1 h ⟨c, d, f⟩\n\ntheorem mem_iff (S : Subgroupoid C) (F : Σc d, c ⟶ d) : F ∈ S ↔ F.2.2 ∈ S.arrows F.1 F.2.1 :=\n  Iff.rfl\n#align category_theory.subgroupoid.mem_iff CategoryTheory.Subgroupoid.mem_iff\n\ntheorem le_iff (S T : Subgroupoid C) : S ≤ T ↔ ∀ {c d}, S.arrows c d ⊆ T.arrows c d :=\n  by\n  rw [SetLike.le_def, Sigma.forall]\n  exact forall_congr' fun c => Sigma.forall\n#align category_theory.subgroupoid.le_iff CategoryTheory.Subgroupoid.le_iff\n\ninstance : Top (Subgroupoid C) :=\n  ⟨{  arrows := fun _ _ => Set.univ\n      mul := by\n        rintro\n        trivial\n      inv := by\n        rintro\n        trivial }⟩\n\ntheorem mem_top {c d : C} (f : c ⟶ d) : f ∈ (⊤ : Subgroupoid C).arrows c d :=\n  trivial\n#align category_theory.subgroupoid.mem_top CategoryTheory.Subgroupoid.mem_top\n\ntheorem mem_top_objs (c : C) : c ∈ (⊤ : Subgroupoid C).objs :=\n  by\n  dsimp [Top.top, objs]\n  simp only [univ_nonempty]\n#align category_theory.subgroupoid.mem_top_objs CategoryTheory.Subgroupoid.mem_top_objs\n\ninstance : Bot (Subgroupoid C) :=\n  ⟨{  arrows := fun _ _ => ∅\n      mul := fun _ _ _ _ => False.elim\n      inv := fun _ _ _ => False.elim }⟩\n\ninstance : Inhabited (Subgroupoid C) :=\n  ⟨⊤⟩\n\ninstance : Inf (Subgroupoid C) :=\n  ⟨fun S T =>\n    { arrows := fun c d => S.arrows c d ∩ T.arrows c d\n      inv := by\n        rintro\n        exact ⟨S.inv hp.1, T.inv hp.2⟩\n      mul := by\n        rintro\n        exact ⟨S.mul hp.1 hq.1, T.mul hp.2 hq.2⟩ }⟩\n\ninstance : InfSet (Subgroupoid C) :=\n  ⟨fun s =>\n    { arrows := fun c d => ⋂ S ∈ s, Subgroupoid.arrows S c d\n      inv := by\n        intros\n        rw [mem_Inter₂] at hp⊢\n        exact fun S hS => S.inv (hp S hS)\n      mul := by\n        intros\n        rw [mem_Inter₂] at hp hq⊢\n        exact fun S hS => S.mul (hp S hS) (hq S hS) }⟩\n\ninstance : CompleteLattice (Subgroupoid C) :=\n  {\n    completeLatticeOfInf (Subgroupoid C)\n      (by\n        refine' fun s => ⟨fun S Ss F => _, fun T Tl F fT => _⟩ <;>\n          simp only [Inf, mem_iff, mem_Inter]\n        exacts[fun hp => hp S Ss, fun S Ss =>\n          Tl Ss fT]) with\n    bot := ⊥\n    bot_le := fun S => empty_subset _\n    top := ⊤\n    le_top := fun S => subset_univ _\n    inf := (· ⊓ ·)\n    le_inf := fun R S T RS RT _ pR => ⟨RS pR, RT pR⟩\n    inf_le_left := fun R S _ => And.left\n    inf_le_right := fun R S _ => And.right }\n\ntheorem le_objs {S T : Subgroupoid C} (h : S ≤ T) : S.objs ⊆ T.objs := fun s ⟨γ, hγ⟩ =>\n  ⟨γ, @h ⟨s, s, γ⟩ hγ⟩\n#align category_theory.subgroupoid.le_objs CategoryTheory.Subgroupoid.le_objs\n\n/-- The functor associated to the embedding of subgroupoids -/\ndef inclusion {S T : Subgroupoid C} (h : S ≤ T) : S.objs ⥤ T.objs\n    where\n  obj s := ⟨s.val, le_objs h s.Prop⟩\n  map s t f := ⟨f.val, @h ⟨s, t, f.val⟩ f.Prop⟩\n  map_id' _ := rfl\n  map_comp' _ _ _ _ _ := rfl\n#align category_theory.subgroupoid.inclusion CategoryTheory.Subgroupoid.inclusion\n\ntheorem inclusion_inj_on_objects {S T : Subgroupoid C} (h : S ≤ T) :\n    Function.Injective (inclusion h).obj := fun ⟨s, hs⟩ ⟨t, ht⟩ => by\n  simpa only [inclusion, Subtype.mk_eq_mk] using id\n#align category_theory.subgroupoid.inclusion_inj_on_objects CategoryTheory.Subgroupoid.inclusion_inj_on_objects\n\ntheorem inclusion_faithful {S T : Subgroupoid C} (h : S ≤ T) (s t : S.objs) :\n    Function.Injective fun f : s ⟶ t => (inclusion h).map f := fun ⟨f, hf⟩ ⟨g, hg⟩ =>\n  by\n  dsimp only [inclusion]\n  simpa only [Subtype.mk_eq_mk] using id\n#align category_theory.subgroupoid.inclusion_faithful CategoryTheory.Subgroupoid.inclusion_faithful\n\ntheorem inclusion_refl {S : Subgroupoid C} : inclusion (le_refl S) = 𝟭 S.objs :=\n  Functor.hext (fun ⟨s, hs⟩ => rfl) fun ⟨s, hs⟩ ⟨t, ht⟩ ⟨f, hf⟩ => hEq_of_eq rfl\n#align category_theory.subgroupoid.inclusion_refl CategoryTheory.Subgroupoid.inclusion_refl\n\ntheorem inclusion_trans {R S T : Subgroupoid C} (k : R ≤ S) (h : S ≤ T) :\n    inclusion (k.trans h) = inclusion k ⋙ inclusion h :=\n  rfl\n#align category_theory.subgroupoid.inclusion_trans CategoryTheory.Subgroupoid.inclusion_trans\n\ntheorem inclusion_comp_embedding {S T : Subgroupoid C} (h : S ≤ T) : inclusion h ⋙ T.Hom = S.Hom :=\n  rfl\n#align category_theory.subgroupoid.inclusion_comp_embedding CategoryTheory.Subgroupoid.inclusion_comp_embedding\n\n/-- The family of arrows of the discrete groupoid -/\ninductive Discrete.Arrows : ∀ c d : C, (c ⟶ d) → Prop\n  | id (c : C) : discrete.arrows c c (𝟙 c)\n#align category_theory.subgroupoid.discrete.arrows CategoryTheory.Subgroupoid.Discrete.Arrows\n\n/-- The only arrows of the discrete groupoid are the identity arrows. -/\ndef discrete : Subgroupoid C where\n  arrows := Discrete.Arrows\n  inv := by\n    rintro _ _ _ ⟨⟩\n    simp only [inv_eq_inv, is_iso.inv_id]\n    constructor\n  mul := by\n    rintro _ _ _ _ ⟨⟩ _ ⟨⟩\n    rw [category.comp_id]\n    constructor\n#align category_theory.subgroupoid.discrete CategoryTheory.Subgroupoid.discrete\n\ntheorem mem_discrete_iff {c d : C} (f : c ⟶ d) :\n    f ∈ discrete.arrows c d ↔ ∃ h : c = d, f = eqToHom h :=\n  ⟨by\n    rintro ⟨⟩\n    exact ⟨rfl, rfl⟩, by\n    rintro ⟨rfl, rfl⟩\n    constructor⟩\n#align category_theory.subgroupoid.mem_discrete_iff CategoryTheory.Subgroupoid.mem_discrete_iff\n\n/-- A subgroupoid is wide if its carrier set is all of `C`-/\nstructure IsWide : Prop where\n  wide : ∀ c, 𝟙 c ∈ S.arrows c c\n#align category_theory.subgroupoid.is_wide CategoryTheory.Subgroupoid.IsWide\n\ntheorem isWide_iff_objs_eq_univ : S.IsWide ↔ S.objs = Set.univ :=\n  by\n  constructor\n  · rintro h\n    ext\n    constructor <;> simp only [top_eq_univ, mem_univ, imp_true_iff, forall_true_left]\n    apply mem_objs_of_src S (h.wide x)\n  · rintro h\n    refine' ⟨fun c => _⟩\n    obtain ⟨γ, γS⟩ := (le_of_eq h.symm : ⊤ ⊆ S.objs) (Set.mem_univ c)\n    exact id_mem_of_src S γS\n#align category_theory.subgroupoid.is_wide_iff_objs_eq_univ CategoryTheory.Subgroupoid.isWide_iff_objs_eq_univ\n\ntheorem IsWide.id_mem {S : Subgroupoid C} (Sw : S.IsWide) (c : C) : 𝟙 c ∈ S.arrows c c :=\n  Sw.wide c\n#align category_theory.subgroupoid.is_wide.id_mem CategoryTheory.Subgroupoid.IsWide.id_mem\n\ntheorem IsWide.eqToHom_mem {S : Subgroupoid C} (Sw : S.IsWide) {c d : C} (h : c = d) :\n    eqToHom h ∈ S.arrows c d := by\n  cases h\n  simp only [eq_to_hom_refl]\n  apply Sw.id_mem c\n#align category_theory.subgroupoid.is_wide.eq_to_hom_mem CategoryTheory.Subgroupoid.IsWide.eqToHom_mem\n\n/-- A subgroupoid is normal if it is wide and satisfies the expected stability under conjugacy. -/\nstructure IsNormal extends IsWide S : Prop where\n  conj : ∀ {c d} (p : c ⟶ d) {γ : c ⟶ c} (hs : γ ∈ S.arrows c c), inv p ≫ γ ≫ p ∈ S.arrows d d\n#align category_theory.subgroupoid.is_normal CategoryTheory.Subgroupoid.IsNormal\n\ntheorem IsNormal.conj' {S : Subgroupoid C} (Sn : IsNormal S) :\n    ∀ {c d} (p : d ⟶ c) {γ : c ⟶ c} (hs : γ ∈ S.arrows c c), p ≫ γ ≫ inv p ∈ S.arrows d d :=\n  fun c d p γ hs => by\n  convert Sn.conj (inv p) hs\n  simp\n#align category_theory.subgroupoid.is_normal.conj' CategoryTheory.Subgroupoid.IsNormal.conj'\n\ntheorem IsNormal.conjugation_bij (Sn : IsNormal S) {c d} (p : c ⟶ d) :\n    Set.BijOn (fun γ : c ⟶ c => inv p ≫ γ ≫ p) (S.arrows c c) (S.arrows d d) :=\n  by\n  refine'\n    ⟨fun γ γS => Sn.conj p γS, fun γ₁ γ₁S γ₂ γ₂S h => _, fun δ δS =>\n      ⟨p ≫ δ ≫ inv p, Sn.conj' p δS, _⟩⟩\n  ·\n    simpa only [inv_eq_inv, category.assoc, is_iso.hom_inv_id, category.comp_id,\n      is_iso.hom_inv_id_assoc] using p ≫= h =≫ inv p\n  ·\n    simp only [inv_eq_inv, category.assoc, is_iso.inv_hom_id, category.comp_id,\n      is_iso.inv_hom_id_assoc]\n#align category_theory.subgroupoid.is_normal.conjugation_bij CategoryTheory.Subgroupoid.IsNormal.conjugation_bij\n\ntheorem top_isNormal : IsNormal (⊤ : Subgroupoid C) :=\n  { wide := fun c => trivial\n    conj := fun a b c d e => trivial }\n#align category_theory.subgroupoid.top_is_normal CategoryTheory.Subgroupoid.top_isNormal\n\ntheorem infₛ_isNormal (s : Set <| Subgroupoid C) (sn : ∀ S ∈ s, IsNormal S) : IsNormal (infₛ s) :=\n  { wide := by\n      simp_rw [Inf, mem_Inter₂]\n      exact fun c S Ss => (sn S Ss).wide c\n    conj := by\n      simp_rw [Inf, mem_Inter₂]\n      exact fun c d p γ hγ S Ss => (sn S Ss).conj p (hγ S Ss) }\n#align category_theory.subgroupoid.Inf_is_normal CategoryTheory.Subgroupoid.infₛ_isNormal\n\ntheorem discrete_isNormal : (@discrete C _).IsNormal :=\n  { wide := fun c => by constructor\n    conj := fun c d f γ hγ => by\n      cases hγ\n      simp only [inv_eq_inv, category.id_comp, is_iso.inv_hom_id]\n      constructor }\n#align category_theory.subgroupoid.discrete_is_normal CategoryTheory.Subgroupoid.discrete_isNormal\n\ntheorem IsNormal.vertexSubgroup (Sn : IsNormal S) (c : C) (cS : c ∈ S.objs) :\n    (S.vertexSubgroup cS).Normal :=\n  {\n    conj_mem := fun x hx y => by\n      rw [mul_assoc]\n      exact Sn.conj' y hx }\n#align category_theory.subgroupoid.is_normal.vertex_subgroup CategoryTheory.Subgroupoid.IsNormal.vertexSubgroup\n\nsection GeneratedSubgroupoid\n\n-- TODO: proof that generated is just \"words in X\" and generated_normal is similarly\nvariable (X : ∀ c d : C, Set (c ⟶ d))\n\n/-- The subgropoid generated by the set of arrows `X` -/\ndef generated : Subgroupoid C :=\n  infₛ { S : Subgroupoid C | ∀ c d, X c d ⊆ S.arrows c d }\n#align category_theory.subgroupoid.generated CategoryTheory.Subgroupoid.generated\n\ntheorem subset_generated (c d : C) : X c d ⊆ (generated X).arrows c d :=\n  by\n  dsimp only [generated, Inf]\n  simp only [subset_Inter₂_iff]\n  exact fun S hS f fS => hS _ _ fS\n#align category_theory.subgroupoid.subset_generated CategoryTheory.Subgroupoid.subset_generated\n\n/-- The normal sugroupoid generated by the set of arrows `X` -/\ndef generatedNormal : Subgroupoid C :=\n  infₛ { S : Subgroupoid C | (∀ c d, X c d ⊆ S.arrows c d) ∧ S.IsNormal }\n#align category_theory.subgroupoid.generated_normal CategoryTheory.Subgroupoid.generatedNormal\n\ntheorem generated_le_generatedNormal : generated X ≤ generatedNormal X :=\n  by\n  apply @infₛ_le_infₛ (subgroupoid C) _\n  exact fun S ⟨h, _⟩ => h\n#align category_theory.subgroupoid.generated_le_generated_normal CategoryTheory.Subgroupoid.generated_le_generatedNormal\n\ntheorem generatedNormal_isNormal : (generatedNormal X).IsNormal :=\n  infₛ_isNormal _ fun S h => h.right\n#align category_theory.subgroupoid.generated_normal_is_normal CategoryTheory.Subgroupoid.generatedNormal_isNormal\n\ntheorem IsNormal.generatedNormal_le {S : Subgroupoid C} (Sn : S.IsNormal) :\n    generatedNormal X ≤ S ↔ ∀ c d, X c d ⊆ S.arrows c d :=\n  by\n  constructor\n  · rintro h c d\n    let h' := generated_le_generated_normal X\n    rw [le_iff] at h h'\n    exact ((subset_generated X c d).trans (@h' c d)).trans (@h c d)\n  · rintro h\n    apply @infₛ_le (subgroupoid C) _\n    exact ⟨h, Sn⟩\n#align category_theory.subgroupoid.is_normal.generated_normal_le CategoryTheory.Subgroupoid.IsNormal.generatedNormal_le\n\nend GeneratedSubgroupoid\n\nsection Hom\n\nvariable {D : Type _} [Groupoid D] (φ : C ⥤ D)\n\n/-- A functor between groupoid defines a map of subgroupoids in the reverse direction\nby taking preimages.\n -/\ndef comap (S : Subgroupoid D) : Subgroupoid C\n    where\n  arrows c d := { f : c ⟶ d | φ.map f ∈ S.arrows (φ.obj c) (φ.obj d) }\n  inv c d p hp := by\n    rw [mem_set_of, inv_eq_inv, φ.map_inv p, ← inv_eq_inv]\n    exact S.inv hp\n  mul := by\n    rintro\n    simp only [mem_set_of, functor.map_comp]\n    apply S.mul <;> assumption\n#align category_theory.subgroupoid.comap CategoryTheory.Subgroupoid.comap\n\ntheorem comap_mono (S T : Subgroupoid D) : S ≤ T → comap φ S ≤ comap φ T := fun ST ⟨c, d, p⟩ =>\n  @ST ⟨_, _, _⟩\n#align category_theory.subgroupoid.comap_mono CategoryTheory.Subgroupoid.comap_mono\n\ntheorem isNormal_comap {S : Subgroupoid D} (Sn : IsNormal S) : IsNormal (comap φ S) :=\n  { wide := fun c => by\n      rw [comap, mem_set_of, Functor.map_id]\n      apply Sn.wide\n    conj := fun c d f γ hγ =>\n      by\n      simp_rw [inv_eq_inv f, comap, mem_set_of, functor.map_comp, functor.map_inv, ← inv_eq_inv]\n      exact Sn.conj _ hγ }\n#align category_theory.subgroupoid.is_normal_comap CategoryTheory.Subgroupoid.isNormal_comap\n\n@[simp]\ntheorem comap_comp {E : Type _} [Groupoid E] (ψ : D ⥤ E) : comap (φ ⋙ ψ) = comap φ ∘ comap ψ :=\n  rfl\n#align category_theory.subgroupoid.comap_comp CategoryTheory.Subgroupoid.comap_comp\n\n/-- The kernel of a functor between subgroupoid is the preimage. -/\ndef ker : Subgroupoid C :=\n  comap φ discrete\n#align category_theory.subgroupoid.ker CategoryTheory.Subgroupoid.ker\n\ntheorem mem_ker_iff {c d : C} (f : c ⟶ d) :\n    f ∈ (ker φ).arrows c d ↔ ∃ h : φ.obj c = φ.obj d, φ.map f = eqToHom h :=\n  mem_discrete_iff (φ.map f)\n#align category_theory.subgroupoid.mem_ker_iff CategoryTheory.Subgroupoid.mem_ker_iff\n\ntheorem ker_isNormal : (ker φ).IsNormal :=\n  isNormal_comap φ discrete_isNormal\n#align category_theory.subgroupoid.ker_is_normal CategoryTheory.Subgroupoid.ker_isNormal\n\n@[simp]\ntheorem ker_comp {E : Type _} [Groupoid E] (ψ : D ⥤ E) : ker (φ ⋙ ψ) = comap φ (ker ψ) :=\n  rfl\n#align category_theory.subgroupoid.ker_comp CategoryTheory.Subgroupoid.ker_comp\n\n/-- The family of arrows of the image of a subgroupoid under a functor injective on objects -/\ninductive Map.Arrows (hφ : Function.Injective φ.obj) (S : Subgroupoid C) : ∀ c d : D, (c ⟶ d) → Prop\n  | im {c d : C} (f : c ⟶ d) (hf : f ∈ S.arrows c d) : map.arrows (φ.obj c) (φ.obj d) (φ.map f)\n#align category_theory.subgroupoid.map.arrows CategoryTheory.Subgroupoid.Map.Arrows\n\ntheorem Map.arrows_iff (hφ : Function.Injective φ.obj) (S : Subgroupoid C) {c d : D} (f : c ⟶ d) :\n    Map.Arrows φ hφ S c d f ↔\n      ∃ (a b : C)(g : a ⟶ b)(ha : φ.obj a = c)(hb : φ.obj b = d)(hg : g ∈ S.arrows a b),\n        f = eqToHom ha.symm ≫ φ.map g ≫ eqToHom hb :=\n  by\n  constructor\n  · rintro ⟨g, hg⟩\n    exact ⟨_, _, g, rfl, rfl, hg, eq_conj_eq_to_hom _⟩\n  · rintro ⟨a, b, g, rfl, rfl, hg, rfl⟩\n    rw [← eq_conj_eq_to_hom]\n    constructor\n    exact hg\n#align category_theory.subgroupoid.map.arrows_iff CategoryTheory.Subgroupoid.Map.arrows_iff\n\n/-- The \"forward\" image of a subgroupoid under a functor injective on objects -/\ndef map (hφ : Function.Injective φ.obj) (S : Subgroupoid C) : Subgroupoid D\n    where\n  arrows := Map.Arrows φ hφ S\n  inv := by\n    rintro _ _ _ ⟨⟩\n    rw [inv_eq_inv, ← functor.map_inv, ← inv_eq_inv]\n    constructor; apply S.inv; assumption\n  mul := by\n    rintro _ _ _ _ ⟨f, hf⟩ q hq\n    obtain ⟨c₃, c₄, g, he, rfl, hg, gq⟩ := (map.arrows_iff φ hφ S q).mp hq\n    cases hφ he; rw [gq, ← eq_conj_eq_to_hom, ← φ.map_comp]\n    constructor; exact S.mul hf hg\n#align category_theory.subgroupoid.map CategoryTheory.Subgroupoid.map\n\ntheorem mem_map_iff (hφ : Function.Injective φ.obj) (S : Subgroupoid C) {c d : D} (f : c ⟶ d) :\n    f ∈ (map φ hφ S).arrows c d ↔\n      ∃ (a b : C)(g : a ⟶ b)(ha : φ.obj a = c)(hb : φ.obj b = d)(hg : g ∈ S.arrows a b),\n        f = eqToHom ha.symm ≫ φ.map g ≫ eqToHom hb :=\n  Map.arrows_iff φ hφ S f\n#align category_theory.subgroupoid.mem_map_iff CategoryTheory.Subgroupoid.mem_map_iff\n\ntheorem galoisConnection_map_comap (hφ : Function.Injective φ.obj) :\n    GaloisConnection (map φ hφ) (comap φ) :=\n  by\n  rintro S T; simp_rw [le_iff]; constructor\n  · exact fun h c d f fS => h (map.arrows.im f fS)\n  · rintro h _ _ g ⟨a, gφS⟩\n    exact h gφS\n#align category_theory.subgroupoid.galois_connection_map_comap CategoryTheory.Subgroupoid.galoisConnection_map_comap\n\ntheorem map_mono (hφ : Function.Injective φ.obj) (S T : Subgroupoid C) :\n    S ≤ T → map φ hφ S ≤ map φ hφ T := fun h => (galoisConnection_map_comap φ hφ).monotone_l h\n#align category_theory.subgroupoid.map_mono CategoryTheory.Subgroupoid.map_mono\n\ntheorem le_comap_map (hφ : Function.Injective φ.obj) (S : Subgroupoid C) :\n    S ≤ comap φ (map φ hφ S) :=\n  (galoisConnection_map_comap φ hφ).le_u_l S\n#align category_theory.subgroupoid.le_comap_map CategoryTheory.Subgroupoid.le_comap_map\n\ntheorem map_comap_le (hφ : Function.Injective φ.obj) (T : Subgroupoid D) :\n    map φ hφ (comap φ T) ≤ T :=\n  (galoisConnection_map_comap φ hφ).l_u_le T\n#align category_theory.subgroupoid.map_comap_le CategoryTheory.Subgroupoid.map_comap_le\n\ntheorem map_le_iff_le_comap (hφ : Function.Injective φ.obj) (S : Subgroupoid C)\n    (T : Subgroupoid D) : map φ hφ S ≤ T ↔ S ≤ comap φ T :=\n  (galoisConnection_map_comap φ hφ).le_iff_le\n#align category_theory.subgroupoid.map_le_iff_le_comap CategoryTheory.Subgroupoid.map_le_iff_le_comap\n\ntheorem mem_map_objs_iff (hφ : Function.Injective φ.obj) (d : D) :\n    d ∈ (map φ hφ S).objs ↔ ∃ c ∈ S.objs, φ.obj c = d :=\n  by\n  dsimp [objs, map]\n  constructor\n  · rintro ⟨f, hf⟩\n    change map.arrows φ hφ S d d f at hf\n    rw [map.arrows_iff] at hf\n    obtain ⟨c, d, g, ec, ed, eg, gS, eg⟩ := hf\n    exact ⟨c, ⟨mem_objs_of_src S eg, ec⟩⟩\n  · rintro ⟨c, ⟨γ, γS⟩, rfl⟩\n    exact ⟨φ.map γ, ⟨γ, γS⟩⟩\n#align category_theory.subgroupoid.mem_map_objs_iff CategoryTheory.Subgroupoid.mem_map_objs_iff\n\n@[simp]\ntheorem map_objs_eq (hφ : Function.Injective φ.obj) : (map φ hφ S).objs = φ.obj '' S.objs :=\n  by\n  ext\n  convert mem_map_objs_iff S φ hφ x\n  simp only [mem_image, exists_prop]\n#align category_theory.subgroupoid.map_objs_eq CategoryTheory.Subgroupoid.map_objs_eq\n\n/-- The image of a functor injective on objects -/\ndef im (hφ : Function.Injective φ.obj) :=\n  map φ hφ ⊤\n#align category_theory.subgroupoid.im CategoryTheory.Subgroupoid.im\n\ntheorem mem_im_iff (hφ : Function.Injective φ.obj) {c d : D} (f : c ⟶ d) :\n    f ∈ (im φ hφ).arrows c d ↔\n      ∃ (a b : C)(g : a ⟶ b)(ha : φ.obj a = c)(hb : φ.obj b = d),\n        f = eqToHom ha.symm ≫ φ.map g ≫ eqToHom hb :=\n  by\n  convert map.arrows_iff φ hφ ⊤ f\n  simp only [Top.top, mem_univ, exists_true_left]\n#align category_theory.subgroupoid.mem_im_iff CategoryTheory.Subgroupoid.mem_im_iff\n\ntheorem mem_im_objs_iff (hφ : Function.Injective φ.obj) (d : D) :\n    d ∈ (im φ hφ).objs ↔ ∃ c : C, φ.obj c = d := by\n  simp only [im, mem_map_objs_iff, mem_top_objs, exists_true_left]\n#align category_theory.subgroupoid.mem_im_objs_iff CategoryTheory.Subgroupoid.mem_im_objs_iff\n\ntheorem obj_surjective_of_im_eq_top (hφ : Function.Injective φ.obj) (hφ' : im φ hφ = ⊤) :\n    Function.Surjective φ.obj := by\n  rintro d\n  rw [← mem_im_objs_iff, hφ']\n  apply mem_top_objs\n#align category_theory.subgroupoid.obj_surjective_of_im_eq_top CategoryTheory.Subgroupoid.obj_surjective_of_im_eq_top\n\ntheorem isNormal_map (hφ : Function.Injective φ.obj) (hφ' : im φ hφ = ⊤) (Sn : S.IsNormal) :\n    (map φ hφ S).IsNormal :=\n  { wide := fun d => by\n      obtain ⟨c, rfl⟩ := obj_surjective_of_im_eq_top φ hφ hφ' d\n      change map.arrows φ hφ S _ _ (𝟙 _)\n      rw [← Functor.map_id]\n      constructor\n      exact Sn.wide c\n    conj := fun d d' g δ hδ => by\n      rw [mem_map_iff] at hδ\n      obtain ⟨c, c', γ, cd, cd', γS, hγ⟩ := hδ\n      subst_vars\n      cases hφ cd'\n      have : d' ∈ (im φ hφ).objs := by\n        rw [hφ']\n        apply mem_top_objs\n      rw [mem_im_objs_iff] at this\n      obtain ⟨c', rfl⟩ := this\n      have : g ∈ (im φ hφ).arrows (φ.obj c) (φ.obj c') :=\n        by\n        rw [hφ']\n        trivial\n      rw [mem_im_iff] at this\n      obtain ⟨b, b', f, hb, hb', _, hf⟩ := this\n      subst_vars\n      cases hφ hb\n      cases hφ hb'\n      change map.arrows φ hφ S (φ.obj c') (φ.obj c') _\n      simp only [eq_to_hom_refl, category.comp_id, category.id_comp, inv_eq_inv]\n      suffices map.arrows φ hφ S (φ.obj c') (φ.obj c') (φ.map <| inv f ≫ γ ≫ f)\n        by\n        simp only [inv_eq_inv, functor.map_comp, functor.map_inv] at this\n        exact this\n      · constructor\n        apply Sn.conj f γS }\n#align category_theory.subgroupoid.is_normal_map CategoryTheory.Subgroupoid.isNormal_map\n\nend Hom\n\nsection Thin\n\n/-- A subgroupoid `is_thin` if it has at most one arrow between any two vertices. -/\nabbrev IsThin :=\n  Quiver.IsThin S.objs\n#align category_theory.subgroupoid.is_thin CategoryTheory.Subgroupoid.IsThin\n\ntheorem isThin_iff : S.IsThin ↔ ∀ c : S.objs, Subsingleton (S.arrows c c) := by apply is_thin_iff\n#align category_theory.subgroupoid.is_thin_iff CategoryTheory.Subgroupoid.isThin_iff\n\nend Thin\n\nsection Disconnected\n\n/-- A subgroupoid `is_totally_disconnected` if it has only isotropy arrows. -/\nabbrev IsTotallyDisconnected :=\n  IsTotallyDisconnected S.objs\n#align category_theory.subgroupoid.is_totally_disconnected CategoryTheory.Subgroupoid.IsTotallyDisconnected\n\ntheorem isTotallyDisconnected_iff :\n    S.IsTotallyDisconnected ↔ ∀ c d, (S.arrows c d).Nonempty → c = d :=\n  by\n  constructor\n  · rintro h c d ⟨f, fS⟩\n    rw [← @Subtype.mk_eq_mk _ _ c (mem_objs_of_src S fS) d (mem_objs_of_tgt S fS)]\n    exact h ⟨c, mem_objs_of_src S fS⟩ ⟨d, mem_objs_of_tgt S fS⟩ ⟨f, fS⟩\n  · rintro h ⟨c, hc⟩ ⟨d, hd⟩ ⟨f, fS⟩\n    simp only [Subtype.mk_eq_mk]\n    exact h c d ⟨f, fS⟩\n#align category_theory.subgroupoid.is_totally_disconnected_iff CategoryTheory.Subgroupoid.isTotallyDisconnected_iff\n\n/-- The isotropy subgroupoid of `S` -/\ndef disconnect : Subgroupoid C\n    where\n  arrows c d f := c = d ∧ f ∈ S.arrows c d\n  inv := by\n    rintro _ _ _ ⟨rfl, h⟩\n    exact ⟨rfl, S.inv h⟩\n  mul := by\n    rintro _ _ _ _ ⟨rfl, h⟩ _ ⟨rfl, h'⟩\n    exact ⟨rfl, S.mul h h'⟩\n#align category_theory.subgroupoid.disconnect CategoryTheory.Subgroupoid.disconnect\n\ntheorem disconnect_le : S.disconnect ≤ S := by\n  rw [le_iff]\n  rintro _ _ _ ⟨⟩\n  assumption\n#align category_theory.subgroupoid.disconnect_le CategoryTheory.Subgroupoid.disconnect_le\n\ntheorem disconnect_normal (Sn : S.IsNormal) : S.disconnect.IsNormal :=\n  { wide := fun c => ⟨rfl, Sn.wide c⟩\n    conj := fun c d p γ ⟨_, h'⟩ => ⟨rfl, Sn.conj _ h'⟩ }\n#align category_theory.subgroupoid.disconnect_normal CategoryTheory.Subgroupoid.disconnect_normal\n\n@[simp]\ntheorem mem_disconnect_objs_iff {c : C} : c ∈ S.disconnect.objs ↔ c ∈ S.objs :=\n  ⟨fun ⟨γ, h, γS⟩ => ⟨γ, γS⟩, fun ⟨γ, γS⟩ => ⟨γ, rfl, γS⟩⟩\n#align category_theory.subgroupoid.mem_disconnect_objs_iff CategoryTheory.Subgroupoid.mem_disconnect_objs_iff\n\ntheorem disconnect_objs : S.disconnect.objs = S.objs :=\n  by\n  apply Set.ext\n  apply mem_disconnect_objs_iff\n#align category_theory.subgroupoid.disconnect_objs CategoryTheory.Subgroupoid.disconnect_objs\n\ntheorem disconnect_isTotallyDisconnected : S.disconnect.IsTotallyDisconnected :=\n  by\n  rw [is_totally_disconnected_iff]\n  exact fun c d ⟨f, h, fS⟩ => h\n#align category_theory.subgroupoid.disconnect_is_totally_disconnected CategoryTheory.Subgroupoid.disconnect_isTotallyDisconnected\n\nend Disconnected\n\nsection Full\n\nvariable (D : Set C)\n\n/-- The full subgroupoid on a set `D : set C` -/\ndef full : Subgroupoid C where\n  arrows c d _ := c ∈ D ∧ d ∈ D\n  inv := by\n    rintro _ _ _ ⟨⟩\n    constructor <;> assumption\n  mul := by\n    rintro _ _ _ _ ⟨⟩ _ ⟨⟩\n    constructor <;> assumption\n#align category_theory.subgroupoid.full CategoryTheory.Subgroupoid.full\n\ntheorem full_objs : (full D).objs = D :=\n  Set.ext fun _ => ⟨fun ⟨f, h, _⟩ => h, fun h => ⟨𝟙 _, h, h⟩⟩\n#align category_theory.subgroupoid.full_objs CategoryTheory.Subgroupoid.full_objs\n\n@[simp]\ntheorem mem_full_iff {c d : C} {f : c ⟶ d} : f ∈ (full D).arrows c d ↔ c ∈ D ∧ d ∈ D :=\n  Iff.rfl\n#align category_theory.subgroupoid.mem_full_iff CategoryTheory.Subgroupoid.mem_full_iff\n\n@[simp]\ntheorem mem_full_objs_iff {c : C} : c ∈ (full D).objs ↔ c ∈ D := by rw [full_objs]\n#align category_theory.subgroupoid.mem_full_objs_iff CategoryTheory.Subgroupoid.mem_full_objs_iff\n\n@[simp]\ntheorem full_empty : full ∅ = (⊥ : Subgroupoid C) :=\n  by\n  ext\n  simp only [Bot.bot, mem_full_iff, mem_empty_iff_false, and_self_iff]\n#align category_theory.subgroupoid.full_empty CategoryTheory.Subgroupoid.full_empty\n\n@[simp]\ntheorem full_univ : full Set.univ = (⊤ : Subgroupoid C) :=\n  by\n  ext\n  simp only [mem_full_iff, mem_univ, and_self_iff, true_iff_iff]\n#align category_theory.subgroupoid.full_univ CategoryTheory.Subgroupoid.full_univ\n\ntheorem full_mono {D E : Set C} (h : D ≤ E) : full D ≤ full E :=\n  by\n  rw [le_iff]\n  rintro c d f\n  simp only [mem_full_iff]\n  exact fun ⟨hc, hd⟩ => ⟨h hc, h hd⟩\n#align category_theory.subgroupoid.full_mono CategoryTheory.Subgroupoid.full_mono\n\ntheorem full_arrow_eq_iff {c d : (full D).objs} {f g : c ⟶ d} : f = g ↔ (↑f : c.val ⟶ d.val) = ↑g :=\n  by apply Subtype.ext_iff\n#align category_theory.subgroupoid.full_arrow_eq_iff CategoryTheory.Subgroupoid.full_arrow_eq_iff\n\nend Full\n\nend Subgroupoid\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Groupoid/Subgroupoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4673417282817899}}
{"text": "import data.finset.basic\n\nimport guidelines.protocol\nimport guidelines.definitions\nimport guidelines.requirements\nimport guidelines.proof\n\nnamespace multipaxos\n\nstructure state_defs (sys_state_t pid_t slot_t ballot_t value_t : Type) :=\n  (curr : sys_state_t → pid_t → ballot_t)\n  (stored : sys_state_t → pid_t → slot_t → option (proposal ballot_t value_t))\n  (proposed : sys_state_t → slot_t → ballot_t → value_t → Prop)\n  (voted : sys_state_t → pid_t → slot_t → ballot_t → Prop)\n  (quorum : finset pid_t → Prop)\n\nnamespace state_defs\n\nvariables {sys_state_t pid_t slot_t ballot_t value_t : Type}\n\ndef chosen_ballot\n  (defs : state_defs sys_state_t pid_t slot_t ballot_t value_t) :\n    sys_state_t → slot_t → ballot_t → Prop :=\n  (λ state slot ballot,\n    ∃ q : finset pid_t, defs.quorum q ∧\n      ∀ voter ∈ q, defs.voted state voter slot ballot)\n\ndef chosen\n  (defs : state_defs sys_state_t pid_t slot_t ballot_t value_t) :\n    sys_state_t → slot_t → value_t → Prop :=\n  (λ state slot value,\n    ∃ ballot, defs.chosen_ballot state slot ballot ∧ defs.proposed state slot ballot value)\n\nend state_defs\n\nvariables {sys_state_t pid_t slot_t ballot_t value_t : Type}\n\ndef state_with_past_intervals\n  (defs : state_defs sys_state_t pid_t slot_t ballot_t value_t)\n  (proto : protocol sys_state_t) : protocol (sys_state_t × (pid_t → slot_t → set (interval ballot_t value_t))) :=\n{ init := (λ hist_state, proto.init hist_state.fst ∧\n  (∀ p s, hist_state.snd p s =\n        {{upper := defs.curr hist_state.fst p, lower := defs.stored hist_state.fst p s}})),\n  next := (λ fst_state snd_state, proto.next fst_state.fst snd_state.fst ∧\n  (∀ p s, snd_state.snd p s = fst_state.snd p s ∪\n          {{upper := defs.curr snd_state.fst p, lower := defs.stored snd_state.fst p s}})) }\n\nvariables [linear_order ballot_t] [decidable_eq pid_t]\n\nstructure proto_constraints\n  (proto : protocol sys_state_t)\n  (defs : state_defs sys_state_t pid_t slot_t ballot_t value_t) :=\n  (quorums_intersect :\n    ∀ q₁ q₂, defs.quorum q₁ → defs.quorum q₂ → (q₁ ∩ q₂).nonempty)\n  (none_proposed_at_init :\n    ∀ state slot ballot value, proto.init state → ¬defs.proposed state slot ballot value)\n  (proposed_stable :\n    ∀ slot ballot value,\n      proto.stable (λ state, defs.proposed state slot ballot value))\n  (proposals_unique :\n    ∀ slot ballot v₁ v₂,\n      proto.invariant (λ state,\n        defs.proposed state slot ballot v₁ → defs.proposed state slot ballot v₂ → v₁ = v₂))\n  (at_most_one_proposal_per_slot_per_step :\n    ∀ slot s',\n      proto.invariant (λ state,\n        proto.next state s' →\n          ∃ b v, ∀ bal val, defs.proposed s' slot bal val →\n                 (defs.proposed state slot bal val ∨ (bal = b ∧ val = v))))\n  (curr_increases :\n    ∀ process s',\n      proto.invariant (λ state,\n        proto.next state s' → defs.curr state process ≤ defs.curr s' process))\n  (stored_ballot_increases :\n    ∀ process slot prop s',\n      proto.invariant (λ state,\n        proto.next state s' →\n          defs.stored state process slot = some prop →\n            ∃ prop', defs.stored s' process slot = some prop' ∧ prop.b ≤ prop'.b))\n  (stored_is_proposed :\n    ∀ process slot prop,\n      proto.invariant (λ state,\n        defs.stored state process slot = some prop →\n          defs.proposed state slot prop.b prop.v))\n  (new_votes_ge_curr_ballot :\n    ∀ process slot ballot s',\n      proto.invariant (λ state,\n        proto.next state s' →\n          defs.voted s' process slot ballot →\n            defs.voted state process slot ballot ∨ defs.curr state process ≤ ballot))\n  (voted_stable :\n    ∀ process slot ballot,\n      proto.stable (λ state, defs.voted state process slot ballot))\n  (voted_imp_proposed :\n    ∀ process slot ballot,\n      proto.invariant (λ state,\n        defs.voted state process slot ballot →\n          ∃ value, defs.proposed state slot ballot value))\n  (voted_le_stored :\n    ∀ process slot ballot,\n      proto.invariant (λ state,\n        defs.voted state process slot ballot →\n          ∃ prop, defs.stored state process slot = some prop ∧ ballot ≤ prop.b))\n  (majority_have_upper_interval_if_proposed :\n    ∀ slot ballot value,\n      (state_with_past_intervals defs proto).invariant (λ state,\n        defs.proposed state.fst slot ballot value →\n        ∃ (q : finset pid_t)\n             (promised_prop : pid_t → option (proposal ballot_t value_t)),\n          defs.quorum q ∧\n          (∀ (a ∈ q),\n            {interval . lower := (promised_prop a), upper := ballot} ∈ state.snd a slot) ∧\n          (∀ (a ∈ q) prop_a, promised_prop a = some prop_a → prop_a.b < ballot) ∧\n          ((∀ (a ∈ q), promised_prop a = none) ∨\n           (∃ (a ∈ q) prop_a,\n             promised_prop a = some prop_a ∧\n             (∀ (a' ∈ q) prop_a', promised_prop a' = some prop_a' → prop_a'.b ≤ prop_a.b) ∧\n             prop_a.v = value))))\n\ndef safety (proto : protocol sys_state_t)\n  (defs : state_defs sys_state_t pid_t slot_t ballot_t value_t)\n  := proto.invariant (λ state, (∀ slot v v', defs.chosen state slot v → defs.chosen state slot v' → v = v'))\n\ndef safety_v2 (proto : protocol sys_state_t)\n  (defs : state_defs sys_state_t pid_t slot_t ballot_t value_t)\n  := proto.invariant (λ state, (∀ later_state slot v v', proto.reachable_from state later_state →\n                                  defs.chosen state slot v → defs.chosen later_state slot v' → v = v'))\n\nend multipaxos\n\nvariables (sys_state_t pid_t slot_t ballot_t value_t : Type)\n          [linear_order ballot_t] [decidable_eq pid_t] (proto : protocol sys_state_t)\n          (defs : multipaxos.state_defs sys_state_t pid_t slot_t ballot_t value_t)\n\n-- Given a multipaxos algorithm, we can restrict to a single slot to get a\n-- single-instance paxos algorithm.\ndef slot_instance_defs (slot : slot_t): paxos_defs sys_state_t pid_t ballot_t value_t :=\n{ curr := λ state p, defs.curr state p,\n  stored := λ state p, defs.stored state p slot,\n  proposed := λ state ballot value, defs.proposed state slot ballot value,\n  voted := λ state p ballot, defs.voted state p slot ballot,\n  quorum := defs.quorum }\n\n-- The single-instance paxos algorithm obtained in this way meets the safety\n-- constraints.\ndef slot_instance_reqs_sat (multipaxos_constraints_met : multipaxos.proto_constraints proto defs) (slot : slot_t)\n  : requirements proto (slot_instance_defs sys_state_t pid_t slot_t ballot_t value_t defs slot) :=\n{ quorums_intersect := multipaxos_constraints_met.quorums_intersect,\n  none_proposed_at_init := λ state ballot value is_init,\n    multipaxos_constraints_met.none_proposed_at_init state slot ballot value is_init,\n  proposed_stable := λ ballot value,\n    multipaxos_constraints_met.proposed_stable slot ballot value,\n  proposals_unique := λ ballot v₁ v₂,\n    multipaxos_constraints_met.proposals_unique slot ballot v₁ v₂,\n  at_most_one_proposal_per_step := λ s',\n    multipaxos_constraints_met.at_most_one_proposal_per_slot_per_step slot s',\n  curr_increases := multipaxos_constraints_met.curr_increases,\n  stored_ballot_increases := λ process prop s',\n    multipaxos_constraints_met.stored_ballot_increases process slot prop s',\n  stored_is_proposed := λ process prop,\n    multipaxos_constraints_met.stored_is_proposed process slot prop,\n  new_votes_ge_curr_ballot := λ process ballot s',\n    multipaxos_constraints_met.new_votes_ge_curr_ballot process slot ballot s',\n  voted_stable := λ process ballot,\n    multipaxos_constraints_met.voted_stable process slot ballot,\n  voted_imp_proposed := λ process ballot,\n    multipaxos_constraints_met.voted_imp_proposed process slot ballot,\n  voted_le_stored := λ process ballot,\n    multipaxos_constraints_met.voted_le_stored process slot ballot,\n  majority_have_upper_interval_if_proposed := by {\n    suffices key : (proto_with_intervals_recorded (slot_instance_defs sys_state_t pid_t slot_t ballot_t value_t defs slot) proto).invariant\n      (λ restricted_state,\n        ∃ full_state, (multipaxos.state_with_past_intervals defs proto).reachable full_state ∧\n                      full_state.fst = restricted_state.fst ∧\n                      restricted_state.snd = λ p, full_state.snd p slot),\n    by {\n      intros ballot value state reachable,\n      rcases key state reachable\n        with ⟨lift_state, lift_reachable, lift_state_is_lift, lift_snd_restriction_gives_snd⟩,\n      rw lift_snd_restriction_gives_snd, rw ← lift_state_is_lift,\n      exact multipaxos_constraints_met.majority_have_upper_interval_if_proposed\n        slot ballot value lift_state lift_reachable,\n    },\n    rw protocol.prove_invariant,\n    split,\n    { intros s is_init,\n      use ⟨s.fst, (λ p slot, {{upper := defs.curr s.fst p, lower := defs.stored s.fst p slot}})⟩,\n      split,\n      { exact ⟨0, is_init.left, by { intros p slot, refl }⟩ },\n      split,\n      { refl },\n      rw function.funext_iff,\n      exact is_init.right },\n    rintros start start_reachable next ⟨lift_start, lift_reachable, lift_start_is_lift, lift_snd_restriction_gives_snd⟩ next_reachable,\n    use ⟨next.fst, λ p s, lift_start.snd p s ∪\n                       {{upper := defs.curr next.fst p, lower := defs.stored next.fst p s}}⟩,\n    split,\n    { rcases lift_reachable with ⟨n, hn⟩,\n      exact ⟨n.succ, lift_start, hn, by { rw lift_start_is_lift, exact next_reachable.left },\n            by { intros p s, refl }⟩ },\n    split,\n    { refl },\n    rw function.funext_iff, intro p,\n    rw next_reachable.right p, unfold prod.snd,\n    rw lift_snd_restriction_gives_snd,\n    unfold slot_instance_defs\n  } }\n\ntheorem constraints_give_safety : multipaxos.proto_constraints proto defs → multipaxos.safety proto defs :=\nbegin\nintro multipaxos_constraints_met,\nsuffices key : ∀ slot, proto.invariant (λ state, (∀ v v', defs.chosen state slot v → defs.chosen state slot v' → v = v')),\nby { intros state reachable slot, exact key slot state reachable },\nintro slot,\nexact requirements_give_safety (slot_instance_reqs_sat sys_state_t pid_t slot_t ballot_t value_t proto defs multipaxos_constraints_met slot)\nend\n\ntheorem constraints_give_safety_v2 : multipaxos.proto_constraints proto defs → multipaxos.safety_v2 proto defs :=\nbegin\nintro multipaxos_constraints_met,\nsuffices key : ∀ slot, proto.invariant (λ state, (∀ later_state v v', proto.reachable_from state later_state →\n                                                    defs.chosen state slot v → defs.chosen later_state slot v' → v = v')),\nby { intros state reachable later_state slot, exact key slot state reachable later_state },\nintro slot,\nexact requirements_give_safety_v2 (slot_instance_reqs_sat sys_state_t pid_t slot_t ballot_t value_t proto defs multipaxos_constraints_met slot)\nend\n", "meta": {"author": "gnanabite", "repo": "colocated-paxos", "sha": "f60308e27d3013665809077fe80a4b2af8a42278", "save_path": "github-repos/lean/gnanabite-colocated-paxos", "path": "github-repos/lean/gnanabite-colocated-paxos/colocated-paxos-f60308e27d3013665809077fe80a4b2af8a42278/src/guidelines/multipaxos.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430645886584, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.46724909978595086}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module logic.nonempty\n! leanprover-community/mathlib commit d2d8742b0c21426362a9dacebc6005db895ca963\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Init.ZeroOne\nimport Mathlib.Logic.Basic\n\n/-!\n# Nonempty types\n\nThis file proves a few extra facts about `Nonempty`, which is defined in core Lean.\n\n## Main declarations\n\n* `Nonempty.some`: Extracts a witness of nonemptiness using choice. Takes `Nonempty α` explicitly.\n* `Classical.arbitrary`: Extracts a witness of nonemptiness using choice. Takes `Nonempty α` as an\n  instance.\n-/\n\n\nvariable {γ : α → Type _}\n\ninstance (priority := 20) Zero.nonempty [Zero α] : Nonempty α :=\n  ⟨0⟩\n\ninstance (priority := 20) One.nonempty [One α] : Nonempty α :=\n  ⟨1⟩\n\ntheorem exists_true_iff_nonempty {α : Sort _} : (∃ _ : α, True) ↔ Nonempty α :=\n  Iff.intro (fun ⟨a, _⟩ ↦ ⟨a⟩) fun ⟨a⟩ ↦ ⟨a, trivial⟩\n#align exists_true_iff_nonempty exists_true_iff_nonempty\n\n@[simp]\ntheorem nonempty_Prop {p : Prop} : Nonempty p ↔ p :=\n  Iff.intro (fun ⟨h⟩ ↦ h) fun h ↦ ⟨h⟩\n#align nonempty_Prop nonempty_Prop\n\ntheorem not_nonempty_iff_imp_false {α : Sort _} : ¬Nonempty α ↔ α → False :=\n  ⟨fun h a ↦ h ⟨a⟩, fun h ⟨a⟩ ↦ h a⟩\n#align not_nonempty_iff_imp_false not_nonempty_iff_imp_false\n\n@[simp]\ntheorem nonempty_sigma : Nonempty (Σa : α, γ a) ↔ ∃ a : α, Nonempty (γ a) :=\n  Iff.intro (fun ⟨⟨a, c⟩⟩ ↦ ⟨a, ⟨c⟩⟩) fun ⟨a, ⟨c⟩⟩ ↦ ⟨⟨a, c⟩⟩\n#align nonempty_sigma nonempty_sigma\n\n@[simp]\ntheorem nonempty_psigma {α} {β : α → Sort _} : Nonempty (PSigma β) ↔ ∃ a : α, Nonempty (β a) :=\n  Iff.intro (fun ⟨⟨a, c⟩⟩ ↦ ⟨a, ⟨c⟩⟩) fun ⟨a, ⟨c⟩⟩ ↦ ⟨⟨a, c⟩⟩\n#align nonempty_psigma nonempty_psigma\n\n@[simp]\ntheorem nonempty_subtype {α} {p : α → Prop} : Nonempty (Subtype p) ↔ ∃ a : α, p a :=\n  Iff.intro (fun ⟨⟨a, h⟩⟩ ↦ ⟨a, h⟩) fun ⟨a, h⟩ ↦ ⟨⟨a, h⟩⟩\n#align nonempty_subtype nonempty_subtype\n\n@[simp]\ntheorem nonempty_prod : Nonempty (α × β) ↔ Nonempty α ∧ Nonempty β :=\n  Iff.intro (fun ⟨⟨a, b⟩⟩ ↦ ⟨⟨a⟩, ⟨b⟩⟩) fun ⟨⟨a⟩, ⟨b⟩⟩ ↦ ⟨⟨a, b⟩⟩\n#align nonempty_prod nonempty_prod\n\n@[simp]\ntheorem nonempty_pprod {α β} : Nonempty (PProd α β) ↔ Nonempty α ∧ Nonempty β :=\n  Iff.intro (fun ⟨⟨a, b⟩⟩ ↦ ⟨⟨a⟩, ⟨b⟩⟩) fun ⟨⟨a⟩, ⟨b⟩⟩ ↦ ⟨⟨a, b⟩⟩\n#align nonempty_pprod nonempty_pprod\n\n@[simp]\ntheorem nonempty_sum : Nonempty (Sum α β) ↔ Nonempty α ∨ Nonempty β :=\n  Iff.intro\n    (fun ⟨h⟩ ↦\n      match h with\n      | Sum.inl a => Or.inl ⟨a⟩\n      | Sum.inr b => Or.inr ⟨b⟩)\n    fun h ↦\n    match h with\n    | Or.inl ⟨a⟩ => ⟨Sum.inl a⟩\n    | Or.inr ⟨b⟩ => ⟨Sum.inr b⟩\n#align nonempty_sum nonempty_sum\n\n@[simp]\ntheorem nonempty_psum {α β} : Nonempty (PSum α β) ↔ Nonempty α ∨ Nonempty β :=\n  Iff.intro\n    (fun ⟨h⟩ ↦\n      match h with\n      | PSum.inl a => Or.inl ⟨a⟩\n      | PSum.inr b => Or.inr ⟨b⟩)\n    fun h ↦\n    match h with\n    | Or.inl ⟨a⟩ => ⟨PSum.inl a⟩\n    | Or.inr ⟨b⟩ => ⟨PSum.inr b⟩\n#align nonempty_psum nonempty_psum\n\n@[simp]\ntheorem nonempty_ulift : Nonempty (ULift α) ↔ Nonempty α :=\n  Iff.intro (fun ⟨⟨a⟩⟩ ↦ ⟨a⟩) fun ⟨a⟩ ↦ ⟨⟨a⟩⟩\n#align nonempty_ulift nonempty_ulift\n\n@[simp]\ntheorem nonempty_plift {α} : Nonempty (PLift α) ↔ Nonempty α :=\n  Iff.intro (fun ⟨⟨a⟩⟩ ↦ ⟨a⟩) fun ⟨a⟩ ↦ ⟨⟨a⟩⟩\n#align nonempty_plift nonempty_plift\n\n@[simp]\ntheorem Nonempty.forall {α} {p : Nonempty α → Prop} : (∀ h : Nonempty α, p h) ↔ ∀ a, p ⟨a⟩ :=\n  Iff.intro (fun h _ ↦ h _) fun h ⟨a⟩ ↦ h a\n#align nonempty.forall Nonempty.forall\n\n@[simp]\ntheorem Nonempty.exists {α} {p : Nonempty α → Prop} : (∃ h : Nonempty α, p h) ↔ ∃ a, p ⟨a⟩ :=\n  Iff.intro (fun ⟨⟨a⟩, h⟩ ↦ ⟨a, h⟩) fun ⟨a, h⟩ ↦ ⟨⟨a⟩, h⟩\n#align nonempty.exists Nonempty.exists\n\n/-- Using `Classical.choice`, lifts a (`Prop`-valued) `Nonempty` instance to a (`Type`-valued)\n  `Inhabited` instance. `Classical.inhabited_of_nonempty` already exists, in\n  `Init/Classical.lean`, but the assumption is not a type class argument,\n  which makes it unsuitable for some applications. -/\nnoncomputable def Classical.inhabited_of_nonempty' {α} [h : Nonempty α] : Inhabited α :=\n  ⟨Classical.choice h⟩\n#align classical.inhabited_of_nonempty' Classical.inhabited_of_nonempty'\n\n/-- Using `Classical.choice`, extracts a term from a `Nonempty` type. -/\n@[reducible]\nprotected noncomputable def Nonempty.some {α} (h : Nonempty α) : α :=\n  Classical.choice h\n#align nonempty.some Nonempty.some\n\n/-- Using `Classical.choice`, extracts a term from a `Nonempty` type. -/\n@[reducible]\nprotected noncomputable def Classical.arbitrary (α) [h : Nonempty α] : α :=\n  Classical.choice h\n#align classical.arbitrary Classical.arbitrary\n\n/-- Given `f : α → β`, if `α` is nonempty then `β` is also nonempty.\n  `Nonempty` cannot be a `functor`, because `Functor` is restricted to `Type`. -/\ntheorem Nonempty.map {α β} (f : α → β) : Nonempty α → Nonempty β\n  | ⟨h⟩ => ⟨f h⟩\n#align nonempty.map Nonempty.map\n\nprotected theorem Nonempty.map2 {α β γ : Sort _} (f : α → β → γ) :\n    Nonempty α → Nonempty β → Nonempty γ\n  | ⟨x⟩, ⟨y⟩ => ⟨f x y⟩\n#align nonempty.map2 Nonempty.map2\n\nprotected theorem Nonempty.congr {α β} (f : α → β) (g : β → α) : Nonempty α ↔ Nonempty β :=\n  ⟨Nonempty.map f, Nonempty.map g⟩\n#align nonempty.congr Nonempty.congr\n\ntheorem Nonempty.elim_to_inhabited {α : Sort _} [h : Nonempty α] {p : Prop} (f : Inhabited α → p) :\n    p :=\n  h.elim <| f ∘ Inhabited.mk\n#align nonempty.elim_to_inhabited Nonempty.elim_to_inhabited\n\nprotected instance Prod.Nonempty {α β} [h : Nonempty α] [h2 : Nonempty β] : Nonempty (α × β) :=\n  h.elim fun g ↦ h2.elim fun g2 ↦ ⟨⟨g, g2⟩⟩\n\nprotected instance Pi.Nonempty {ι : Sort _} {α : ι → Sort _} [∀ i, Nonempty (α i)] :\n    Nonempty (∀ i, α i) :=\n  ⟨fun _ ↦ Classical.arbitrary _⟩\n\ntheorem Classical.nonempty_pi {ι} {α : ι → Sort _} : Nonempty (∀ i, α i) ↔ ∀ i, Nonempty (α i) :=\n  ⟨fun ⟨f⟩ a ↦ ⟨f a⟩, @Pi.Nonempty _ _⟩\n#align classical.nonempty_pi Classical.nonempty_pi\n\ntheorem subsingleton_of_not_nonempty {α : Sort _} (h : ¬Nonempty α) : Subsingleton α :=\n  ⟨fun x ↦ False.elim <| not_nonempty_iff_imp_false.mp h x⟩\n#align subsingleton_of_not_nonempty subsingleton_of_not_nonempty\n\ntheorem Function.Surjective.nonempty [h : Nonempty β] {f : α → β} (hf : Function.Surjective f) :\n      Nonempty α :=\n  let ⟨y⟩ := h\n  let ⟨x, _⟩ := hf y\n  ⟨x⟩\n#align function.surjective.nonempty Function.Surjective.nonempty\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Logic/Nonempty.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.46717567705470636}}
{"text": "/-\nCopyright (c) 2020 Frédéric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Frédéric Dupuis, Yaël Dillies\n\n! This file was ported from Lean 3 source module algebra.order.module\n! leanprover-community/mathlib commit 34ee86e6a59d911a8e4f89b68793ee7577ae79c7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.Smul\n\n/-!\n# Ordered module\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we provide lemmas about `ordered_smul` that hold once a module structure is present.\n\n## References\n\n* https://en.wikipedia.org/wiki/Ordered_module\n\n## Tags\n\nordered module, ordered scalar, ordered smul, ordered action, ordered vector space\n-/\n\n\nopen Pointwise\n\nvariable {k M N : Type _}\n\ninstance [Semiring k] [OrderedAddCommMonoid M] [Module k M] : Module k Mᵒᵈ\n    where\n  add_smul r s x := OrderDual.rec (add_smul _ _) x\n  zero_smul m := OrderDual.rec (zero_smul _) m\n\nsection Semiring\n\nvariable [OrderedSemiring k] [OrderedAddCommGroup M] [Module k M] [OrderedSMul k M] {a b : M}\n  {c : k}\n\n/- warning: smul_neg_iff_of_pos -> smul_neg_iff_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedSemiring.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M _inst_1 (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommMonoid.toPartialOrder.{u1} k (OrderedSemiring.toOrderedAddCommMonoid.{u1} k _inst_1)))) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1)))))))) c) -> (Iff (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))))) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedSemiring.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M _inst_1 (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedSemiring.toPartialOrder.{u2} k _inst_1))) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1))))) c) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1)) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2))))))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2))))))))))\nCase conversion may be inaccurate. Consider using '#align smul_neg_iff_of_pos smul_neg_iff_of_posₓ'. -/\n/- can be generalized from `module k M` to `distrib_mul_action_with_zero k M` once it exists.\nwhere `distrib_mul_action_with_zero k M`is the conjunction of `distrib_mul_action k M` and\n`smul_with_zero k M`.-/\ntheorem smul_neg_iff_of_pos (hc : 0 < c) : c • a < 0 ↔ a < 0 :=\n  by\n  rw [← neg_neg a, smul_neg, neg_neg_iff_pos, neg_neg_iff_pos]\n  exact smul_pos_iff_of_pos hc\n#align smul_neg_iff_of_pos smul_neg_iff_of_pos\n\nend Semiring\n\nsection Ring\n\nvariable [OrderedRing k] [OrderedAddCommGroup M] [Module k M] [OrderedSMul k M] {a b : M} {c : k}\n\n/- warning: smul_lt_smul_of_neg -> smul_lt_smul_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a b) -> (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a))\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a b) -> (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) c (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c b) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c a))\nCase conversion may be inaccurate. Consider using '#align smul_lt_smul_of_neg smul_lt_smul_of_negₓ'. -/\ntheorem smul_lt_smul_of_neg (h : a < b) (hc : c < 0) : c • b < c • a :=\n  by\n  rw [← neg_neg c, neg_smul, neg_smul (-c), neg_lt_neg_iff]\n  exact smul_lt_smul_of_pos h (neg_pos_of_neg hc)\n#align smul_lt_smul_of_neg smul_lt_smul_of_neg\n\n/- warning: smul_le_smul_of_nonpos -> smul_le_smul_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a b) -> (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a))\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a b) -> (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) c (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))))))) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c b) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c a))\nCase conversion may be inaccurate. Consider using '#align smul_le_smul_of_nonpos smul_le_smul_of_nonposₓ'. -/\ntheorem smul_le_smul_of_nonpos (h : a ≤ b) (hc : c ≤ 0) : c • b ≤ c • a :=\n  by\n  rw [← neg_neg c, neg_smul, neg_smul (-c), neg_le_neg_iff]\n  exact smul_le_smul_of_nonneg h (neg_nonneg_of_nonpos hc)\n#align smul_le_smul_of_nonpos smul_le_smul_of_nonpos\n\n/- warning: eq_of_smul_eq_smul_of_neg_of_le -> eq_of_smul_eq_smul_of_neg_of_le is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (Eq.{succ u2} M (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b)) -> (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a b) -> (Eq.{succ u2} M a b)\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (Eq.{succ u2} M (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c a) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c b)) -> (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) c (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))))))) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a b) -> (Eq.{succ u2} M a b)\nCase conversion may be inaccurate. Consider using '#align eq_of_smul_eq_smul_of_neg_of_le eq_of_smul_eq_smul_of_neg_of_leₓ'. -/\ntheorem eq_of_smul_eq_smul_of_neg_of_le (hab : c • a = c • b) (hc : c < 0) (h : a ≤ b) : a = b :=\n  by\n  rw [← neg_neg c, neg_smul, neg_smul (-c), neg_inj] at hab\n  exact eq_of_smul_eq_smul_of_pos_of_le hab (neg_pos_of_neg hc) h\n#align eq_of_smul_eq_smul_of_neg_of_le eq_of_smul_eq_smul_of_neg_of_le\n\n/- warning: lt_of_smul_lt_smul_of_nonpos -> lt_of_smul_lt_smul_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b)) -> (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) b a)\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c a) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) c b)) -> (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) c (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) b a)\nCase conversion may be inaccurate. Consider using '#align lt_of_smul_lt_smul_of_nonpos lt_of_smul_lt_smul_of_nonposₓ'. -/\ntheorem lt_of_smul_lt_smul_of_nonpos (h : c • a < c • b) (hc : c ≤ 0) : b < a :=\n  by\n  rw [← neg_neg c, neg_smul, neg_smul (-c), neg_lt_neg_iff] at h\n  exact lt_of_smul_lt_smul_of_nonneg h (neg_nonneg_of_nonpos hc)\n#align lt_of_smul_lt_smul_of_nonpos lt_of_smul_lt_smul_of_nonpos\n\n/- warning: smul_lt_smul_iff_of_neg -> smul_lt_smul_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (Iff (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b)) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) b a))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c b)) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) b a))\nCase conversion may be inaccurate. Consider using '#align smul_lt_smul_iff_of_neg smul_lt_smul_iff_of_negₓ'. -/\ntheorem smul_lt_smul_iff_of_neg (hc : c < 0) : c • a < c • b ↔ b < a :=\n  by\n  rw [← neg_neg c, neg_smul, neg_smul (-c), neg_lt_neg_iff]\n  exact smul_lt_smul_iff_of_pos (neg_pos_of_neg hc)\n#align smul_lt_smul_iff_of_neg smul_lt_smul_iff_of_neg\n\n/- warning: smul_neg_iff_of_neg -> smul_neg_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (Iff (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))))) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))) a))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2))))))))) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))) a))\nCase conversion may be inaccurate. Consider using '#align smul_neg_iff_of_neg smul_neg_iff_of_negₓ'. -/\ntheorem smul_neg_iff_of_neg (hc : c < 0) : c • a < 0 ↔ 0 < a :=\n  by\n  rw [← neg_neg c, neg_smul, neg_neg_iff_pos]\n  exact smul_pos_iff_of_pos (neg_pos_of_neg hc)\n#align smul_neg_iff_of_neg smul_neg_iff_of_neg\n\n/- warning: smul_pos_iff_of_neg -> smul_pos_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (Iff (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a)) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a)) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2))))))))))\nCase conversion may be inaccurate. Consider using '#align smul_pos_iff_of_neg smul_pos_iff_of_negₓ'. -/\ntheorem smul_pos_iff_of_neg (hc : c < 0) : 0 < c • a ↔ a < 0 :=\n  by\n  rw [← neg_neg c, neg_smul, neg_pos]\n  exact smul_neg_iff_of_pos (neg_pos_of_neg hc)\n#align smul_pos_iff_of_neg smul_pos_iff_of_neg\n\n/- warning: smul_nonpos_of_nonpos_of_nonneg -> smul_nonpos_of_nonpos_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))) a) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LE.le.{u2} k (Preorder.toLE.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))) a) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align smul_nonpos_of_nonpos_of_nonneg smul_nonpos_of_nonpos_of_nonnegₓ'. -/\ntheorem smul_nonpos_of_nonpos_of_nonneg (hc : c ≤ 0) (ha : 0 ≤ a) : c • a ≤ 0 :=\n  calc\n    c • a ≤ c • 0 := smul_le_smul_of_nonpos ha hc\n    _ = 0 := smul_zero c\n    \n#align smul_nonpos_of_nonpos_of_nonneg smul_nonpos_of_nonpos_of_nonneg\n\n/- warning: smul_nonneg_of_nonpos_of_nonpos -> smul_nonneg_of_nonpos_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))))) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LE.le.{u2} k (Preorder.toLE.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2))))))))) -> (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a))\nCase conversion may be inaccurate. Consider using '#align smul_nonneg_of_nonpos_of_nonpos smul_nonneg_of_nonpos_of_nonposₓ'. -/\ntheorem smul_nonneg_of_nonpos_of_nonpos (hc : c ≤ 0) (ha : a ≤ 0) : 0 ≤ c • a :=\n  @smul_nonpos_of_nonpos_of_nonneg k Mᵒᵈ _ _ _ _ _ _ hc ha\n#align smul_nonneg_of_nonpos_of_nonpos smul_nonneg_of_nonpos_of_nonpos\n\n/- warning: smul_pos_of_neg_of_neg -> smul_pos_of_neg_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2))))))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a))\nCase conversion may be inaccurate. Consider using '#align smul_pos_of_neg_of_neg smul_pos_of_neg_of_negₓ'. -/\nalias smul_pos_iff_of_neg ↔ _ smul_pos_of_neg_of_neg\n#align smul_pos_of_neg_of_neg smul_pos_of_neg_of_neg\n\n/- warning: smul_neg_of_pos_of_neg -> smul_neg_of_pos_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedSemiring.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M _inst_1 (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommMonoid.toPartialOrder.{u1} k (OrderedSemiring.toOrderedAddCommMonoid.{u1} k _inst_1)))) (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} k (Semiring.toNonAssocSemiring.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1)))))))) c) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedSemiring.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M _inst_1 (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedSemiring.toPartialOrder.{u2} k _inst_1))) (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1))))) c) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2))))))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k _inst_1)) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align smul_neg_of_pos_of_neg smul_neg_of_pos_of_negₓ'. -/\nalias smul_neg_iff_of_pos ↔ _ smul_neg_of_pos_of_neg\n#align smul_neg_of_pos_of_neg smul_neg_of_pos_of_neg\n\n/- warning: smul_neg_of_neg_of_pos -> smul_neg_of_neg_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))) a) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))))))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))) a) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align smul_neg_of_neg_of_pos smul_neg_of_neg_of_posₓ'. -/\nalias smul_neg_iff_of_neg ↔ _ smul_neg_of_neg_of_pos\n#align smul_neg_of_neg_of_pos smul_neg_of_neg_of_pos\n\n/- warning: antitone_smul_left -> antitone_smul_left is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {c : k}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (Antitone.{u2, u2} M M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {c : k}, (LE.le.{u2} k (Preorder.toLE.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (Antitone.{u1, u1} M M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (SMul.smul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))) c))\nCase conversion may be inaccurate. Consider using '#align antitone_smul_left antitone_smul_leftₓ'. -/\ntheorem antitone_smul_left (hc : c ≤ 0) : Antitone (SMul.smul c : M → M) := fun a b h =>\n  smul_le_smul_of_nonpos h hc\n#align antitone_smul_left antitone_smul_left\n\n/- warning: strict_anti_smul_left -> strict_anti_smul_left is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (StrictAnti.{u2, u2} M M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (StrictAnti.{u1, u1} M M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (SMul.smul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))) c))\nCase conversion may be inaccurate. Consider using '#align strict_anti_smul_left strict_anti_smul_leftₓ'. -/\ntheorem strict_anti_smul_left (hc : c < 0) : StrictAnti (SMul.smul c : M → M) := fun a b h =>\n  smul_lt_smul_of_neg h hc\n#align strict_anti_smul_left strict_anti_smul_left\n\n/- warning: smul_add_smul_le_smul_add_smul -> smul_add_smul_le_smul_add_smul is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] [_inst_5 : ContravariantClass.{u2, u2} M M (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))) (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))))] {a : k} {b : k} {c : M} {d : M}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) a b) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) c d) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a d) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a c) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b d)))\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] [_inst_5 : ContravariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1086 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1088 : M) => HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) x._@.Mathlib.Algebra.Order.Module._hyg.1086 x._@.Mathlib.Algebra.Order.Module._hyg.1088) (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1101 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1103 : M) => LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) x._@.Mathlib.Algebra.Order.Module._hyg.1101 x._@.Mathlib.Algebra.Order.Module._hyg.1103)] {a : k} {b : k} {c : M} {d : M}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) a b) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) c d) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a d) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a c) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b d)))\nCase conversion may be inaccurate. Consider using '#align smul_add_smul_le_smul_add_smul smul_add_smul_le_smul_add_smulₓ'. -/\n/-- Binary **rearrangement inequality**. -/\ntheorem smul_add_smul_le_smul_add_smul [ContravariantClass M M (· + ·) (· ≤ ·)] {a b : k} {c d : M}\n    (hab : a ≤ b) (hcd : c ≤ d) : a • d + b • c ≤ a • c + b • d :=\n  by\n  obtain ⟨b, rfl⟩ := exists_add_of_le hab\n  obtain ⟨d, rfl⟩ := exists_add_of_le hcd\n  rw [smul_add, add_right_comm, smul_add, ← add_assoc, add_smul _ _ d]\n  rw [le_add_iff_nonneg_right] at hab hcd\n  exact add_le_add_left (le_add_of_nonneg_right <| smul_nonneg hab hcd) _\n#align smul_add_smul_le_smul_add_smul smul_add_smul_le_smul_add_smul\n\n/- warning: smul_add_smul_le_smul_add_smul' -> smul_add_smul_le_smul_add_smul' is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] [_inst_5 : ContravariantClass.{u2, u2} M M (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))) (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))))] {a : k} {b : k} {c : M} {d : M}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) b a) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) d c) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a d) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a c) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b d)))\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] [_inst_5 : ContravariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1267 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1269 : M) => HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) x._@.Mathlib.Algebra.Order.Module._hyg.1267 x._@.Mathlib.Algebra.Order.Module._hyg.1269) (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1282 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1284 : M) => LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) x._@.Mathlib.Algebra.Order.Module._hyg.1282 x._@.Mathlib.Algebra.Order.Module._hyg.1284)] {a : k} {b : k} {c : M} {d : M}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) b a) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) d c) -> (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a d) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a c) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b d)))\nCase conversion may be inaccurate. Consider using '#align smul_add_smul_le_smul_add_smul' smul_add_smul_le_smul_add_smul'ₓ'. -/\n/-- Binary **rearrangement inequality**. -/\ntheorem smul_add_smul_le_smul_add_smul' [ContravariantClass M M (· + ·) (· ≤ ·)] {a b : k} {c d : M}\n    (hba : b ≤ a) (hdc : d ≤ c) : a • d + b • c ≤ a • c + b • d :=\n  by\n  rw [add_comm (a • d), add_comm (a • c)]\n  exact smul_add_smul_le_smul_add_smul hba hdc\n#align smul_add_smul_le_smul_add_smul' smul_add_smul_le_smul_add_smul'\n\n/- warning: smul_add_smul_lt_smul_add_smul -> smul_add_smul_lt_smul_add_smul is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] [_inst_5 : CovariantClass.{u2, u2} M M (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))))] [_inst_6 : ContravariantClass.{u2, u2} M M (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))))] {a : k} {b : k} {c : M} {d : M}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) a b) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) c d) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a d) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a c) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b d)))\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] [_inst_5 : CovariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1409 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1411 : M) => HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) x._@.Mathlib.Algebra.Order.Module._hyg.1409 x._@.Mathlib.Algebra.Order.Module._hyg.1411) (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1424 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1426 : M) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) x._@.Mathlib.Algebra.Order.Module._hyg.1424 x._@.Mathlib.Algebra.Order.Module._hyg.1426)] [_inst_6 : ContravariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1443 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1445 : M) => HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) x._@.Mathlib.Algebra.Order.Module._hyg.1443 x._@.Mathlib.Algebra.Order.Module._hyg.1445) (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1458 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1460 : M) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) x._@.Mathlib.Algebra.Order.Module._hyg.1458 x._@.Mathlib.Algebra.Order.Module._hyg.1460)] {a : k} {b : k} {c : M} {d : M}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) a b) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) c d) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a d) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a c) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b d)))\nCase conversion may be inaccurate. Consider using '#align smul_add_smul_lt_smul_add_smul smul_add_smul_lt_smul_add_smulₓ'. -/\n/-- Binary strict **rearrangement inequality**. -/\ntheorem smul_add_smul_lt_smul_add_smul [CovariantClass M M (· + ·) (· < ·)]\n    [ContravariantClass M M (· + ·) (· < ·)] {a b : k} {c d : M} (hab : a < b) (hcd : c < d) :\n    a • d + b • c < a • c + b • d :=\n  by\n  obtain ⟨b, rfl⟩ := exists_add_of_le hab.le\n  obtain ⟨d, rfl⟩ := exists_add_of_le hcd.le\n  rw [smul_add, add_right_comm, smul_add, ← add_assoc, add_smul _ _ d]\n  rw [lt_add_iff_pos_right] at hab hcd\n  exact add_lt_add_left (lt_add_of_pos_right _ <| smul_pos hab hcd) _\n#align smul_add_smul_lt_smul_add_smul smul_add_smul_lt_smul_add_smul\n\n/- warning: smul_add_smul_lt_smul_add_smul' -> smul_add_smul_lt_smul_add_smul' is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] [_inst_5 : CovariantClass.{u2, u2} M M (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))))] [_inst_6 : ContravariantClass.{u2, u2} M M (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))))) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))))] {a : k} {b : k} {c : M} {d : M}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) b a) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) d c) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a d) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) a c) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) b d)))\nbut is expected to have type\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] [_inst_5 : CovariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1625 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1627 : M) => HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) x._@.Mathlib.Algebra.Order.Module._hyg.1625 x._@.Mathlib.Algebra.Order.Module._hyg.1627) (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1640 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1642 : M) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) x._@.Mathlib.Algebra.Order.Module._hyg.1640 x._@.Mathlib.Algebra.Order.Module._hyg.1642)] [_inst_6 : ContravariantClass.{u2, u2} M M (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1659 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1661 : M) => HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) x._@.Mathlib.Algebra.Order.Module._hyg.1659 x._@.Mathlib.Algebra.Order.Module._hyg.1661) (fun (x._@.Mathlib.Algebra.Order.Module._hyg.1674 : M) (x._@.Mathlib.Algebra.Order.Module._hyg.1676 : M) => LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) x._@.Mathlib.Algebra.Order.Module._hyg.1674 x._@.Mathlib.Algebra.Order.Module._hyg.1676)] {a : k} {b : k} {c : M} {d : M}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedRing.toPartialOrder.{u1} k _inst_1))) b a) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) d c) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a d) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b c)) (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))))) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) a c) (HSMul.hSMul.{u1, u2, u2} k M M (instHSMul.{u1, u2} k M (SMulZeroClass.toSMul.{u1, u2} k M (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u1, u2} k M (MonoidWithZero.toZero.{u1} k (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1))) (NegZeroClass.toZero.{u2} M (SubNegZeroMonoid.toNegZeroClass.{u2} M (SubtractionMonoid.toSubNegZeroMonoid.{u2} M (SubtractionCommMonoid.toSubtractionMonoid.{u2} M (AddCommGroup.toDivisionAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (OrderedSemiring.toSemiring.{u1} k (OrderedRing.toOrderedSemiring.{u1} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))))) b d)))\nCase conversion may be inaccurate. Consider using '#align smul_add_smul_lt_smul_add_smul' smul_add_smul_lt_smul_add_smul'ₓ'. -/\n/-- Binary strict **rearrangement inequality**. -/\ntheorem smul_add_smul_lt_smul_add_smul' [CovariantClass M M (· + ·) (· < ·)]\n    [ContravariantClass M M (· + ·) (· < ·)] {a b : k} {c d : M} (hba : b < a) (hdc : d < c) :\n    a • d + b • c < a • c + b • d :=\n  by\n  rw [add_comm (a • d), add_comm (a • c)]\n  exact smul_add_smul_lt_smul_add_smul hba hdc\n#align smul_add_smul_lt_smul_add_smul' smul_add_smul_lt_smul_add_smul'\n\nend Ring\n\nsection Field\n\nvariable [LinearOrderedField k] [OrderedAddCommGroup M] [Module k M] [OrderedSMul k M] {a b : M}\n  {c : k}\n\n/- warning: smul_le_smul_iff_of_neg -> smul_le_smul_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Iff (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b)) (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) b a))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c b)) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) b a))\nCase conversion may be inaccurate. Consider using '#align smul_le_smul_iff_of_neg smul_le_smul_iff_of_negₓ'. -/\ntheorem smul_le_smul_iff_of_neg (hc : c < 0) : c • a ≤ c • b ↔ b ≤ a :=\n  by\n  rw [← neg_neg c, neg_smul, neg_smul (-c), neg_le_neg_iff]\n  exact smul_le_smul_iff_of_pos (neg_pos_of_neg hc)\n#align smul_le_smul_iff_of_neg smul_le_smul_iff_of_neg\n\n/- warning: inv_smul_le_iff_of_neg -> inv_smul_le_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Iff (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) (Inv.inv.{u1} k (DivInvMonoid.toHasInv.{u1} k (DivisionRing.toDivInvMonoid.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) c) a) b) (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b) a))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) (Inv.inv.{u2} k (LinearOrderedField.toInv.{u2} k _inst_1) c) a) b) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c b) a))\nCase conversion may be inaccurate. Consider using '#align inv_smul_le_iff_of_neg inv_smul_le_iff_of_negₓ'. -/\ntheorem inv_smul_le_iff_of_neg (h : c < 0) : c⁻¹ • a ≤ b ↔ c • b ≤ a :=\n  by\n  rw [← smul_le_smul_iff_of_neg h, smul_inv_smul₀ h.ne]\n  infer_instance\n#align inv_smul_le_iff_of_neg inv_smul_le_iff_of_neg\n\n/- warning: inv_smul_lt_iff_of_neg -> inv_smul_lt_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Iff (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) (Inv.inv.{u1} k (DivInvMonoid.toHasInv.{u1} k (DivisionRing.toDivInvMonoid.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) c) a) b) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c b) a))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) (Inv.inv.{u2} k (LinearOrderedField.toInv.{u2} k _inst_1) c) a) b) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c b) a))\nCase conversion may be inaccurate. Consider using '#align inv_smul_lt_iff_of_neg inv_smul_lt_iff_of_negₓ'. -/\ntheorem inv_smul_lt_iff_of_neg (h : c < 0) : c⁻¹ • a < b ↔ c • b < a :=\n  by\n  rw [← smul_lt_smul_iff_of_neg h, smul_inv_smul₀ h.ne]\n  infer_instance\n#align inv_smul_lt_iff_of_neg inv_smul_lt_iff_of_neg\n\n/- warning: smul_inv_le_iff_of_neg -> smul_inv_le_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Iff (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) (Inv.inv.{u1} k (DivInvMonoid.toHasInv.{u1} k (DivisionRing.toDivInvMonoid.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) c) b)) (LE.le.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) b (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a)))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Iff (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) a (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) (Inv.inv.{u2} k (LinearOrderedField.toInv.{u2} k _inst_1) c) b)) (LE.le.{u1} M (Preorder.toLE.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) b (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a)))\nCase conversion may be inaccurate. Consider using '#align smul_inv_le_iff_of_neg smul_inv_le_iff_of_negₓ'. -/\ntheorem smul_inv_le_iff_of_neg (h : c < 0) : a ≤ c⁻¹ • b ↔ b ≤ c • a :=\n  by\n  rw [← smul_le_smul_iff_of_neg h, smul_inv_smul₀ h.ne]\n  infer_instance\n#align smul_inv_le_iff_of_neg smul_inv_le_iff_of_neg\n\n/- warning: smul_inv_lt_iff_of_neg -> smul_inv_lt_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Iff (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) a (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) (Inv.inv.{u1} k (DivInvMonoid.toHasInv.{u1} k (DivisionRing.toDivInvMonoid.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) c) b)) (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) b (SMul.smul.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3)))) c a)))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {a : M} {b : M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Iff (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) a (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) (Inv.inv.{u2} k (LinearOrderedField.toInv.{u2} k _inst_1) c) b)) (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2))) b (HSMul.hSMul.{u2, u1, u1} k M M (instHSMul.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))))) c a)))\nCase conversion may be inaccurate. Consider using '#align smul_inv_lt_iff_of_neg smul_inv_lt_iff_of_negₓ'. -/\ntheorem smul_inv_lt_iff_of_neg (h : c < 0) : a < c⁻¹ • b ↔ b < c • a :=\n  by\n  rw [← smul_lt_smul_iff_of_neg h, smul_inv_smul₀ h.ne]\n  infer_instance\n#align smul_inv_lt_iff_of_neg smul_inv_lt_iff_of_neg\n\nvariable (M)\n\n/- warning: order_iso.smul_left_dual -> OrderIso.smulLeftDual is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} (M : Type.{u2}) [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (OrderIso.{u2, u2} M (OrderDual.{u2} M) (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OrderDual.hasLe.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)))))\nbut is expected to have type\n  forall {k : Type.{u1}} (M : Type.{u2}) [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (StrictOrderedSemiring.toSemiring.{u1} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} k (LinearOrderedField.toLinearOrderedSemifield.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedCommSemiring.toOrderedSemiring.{u1} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} k (LinearOrderedField.toLinearOrderedSemifield.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (StrictOrderedSemiring.toSemiring.{u1} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} k (LinearOrderedField.toLinearOrderedSemifield.{u1} k _inst_1)))))) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (StrictOrderedSemiring.toSemiring.{u1} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} k (LinearOrderedField.toLinearOrderedSemifield.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) _inst_3))] {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (StrictOrderedRing.toPartialOrder.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1)))))) c (OfNat.ofNat.{u1} k 0 (Zero.toOfNat0.{u1} k (CommMonoidWithZero.toZero.{u1} k (CommGroupWithZero.toCommMonoidWithZero.{u1} k (Semifield.toCommGroupWithZero.{u1} k (LinearOrderedSemifield.toSemifield.{u1} k (LinearOrderedField.toLinearOrderedSemifield.{u1} k _inst_1)))))))) -> (OrderIso.{u2, u2} M (OrderDual.{u2} M) (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2))) (OrderDual.instLEOrderDual.{u2} M (Preorder.toLE.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align order_iso.smul_left_dual OrderIso.smulLeftDualₓ'. -/\n/-- Left scalar multiplication as an order isomorphism. -/\n@[simps]\ndef OrderIso.smulLeftDual {c : k} (hc : c < 0) : M ≃o Mᵒᵈ\n    where\n  toFun b := OrderDual.toDual (c • b)\n  invFun b := c⁻¹ • OrderDual.ofDual b\n  left_inv := inv_smul_smul₀ hc.Ne\n  right_inv := smul_inv_smul₀ hc.Ne\n  map_rel_iff' b₁ b₂ := smul_le_smul_iff_of_neg hc\n#align order_iso.smul_left_dual OrderIso.smulLeftDual\n\nend Field\n\n/-! ### Upper/lower bounds -/\n\n\nsection OrderedRing\n\nvariable [OrderedRing k] [OrderedAddCommGroup M] [Module k M] [OrderedSMul k M] {s : Set M} {c : k}\n\n/- warning: smul_lower_bounds_subset_upper_bounds_smul -> smul_lowerBounds_subset_upperBounds_smul is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (HasSubset.Subset.{u2} (Set.{u2} M) (Set.hasSubset.{u2} M) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c (lowerBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s)) (upperBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s)))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LE.le.{u2} k (Preorder.toLE.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c (lowerBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s)) (upperBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s)))\nCase conversion may be inaccurate. Consider using '#align smul_lower_bounds_subset_upper_bounds_smul smul_lowerBounds_subset_upperBounds_smulₓ'. -/\ntheorem smul_lowerBounds_subset_upperBounds_smul (hc : c ≤ 0) :\n    c • lowerBounds s ⊆ upperBounds (c • s) :=\n  (antitone_smul_left hc).image_lowerBounds_subset_upperBounds_image\n#align smul_lower_bounds_subset_upper_bounds_smul smul_lowerBounds_subset_upperBounds_smul\n\n/- warning: smul_upper_bounds_subset_lower_bounds_smul -> smul_upperBounds_subset_lowerBounds_smul is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (HasSubset.Subset.{u2} (Set.{u2} M) (Set.hasSubset.{u2} M) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c (upperBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s)) (lowerBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s)))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LE.le.{u2} k (Preorder.toLE.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (HasSubset.Subset.{u1} (Set.{u1} M) (Set.instHasSubsetSet.{u1} M) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c (upperBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s)) (lowerBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s)))\nCase conversion may be inaccurate. Consider using '#align smul_upper_bounds_subset_lower_bounds_smul smul_upperBounds_subset_lowerBounds_smulₓ'. -/\ntheorem smul_upperBounds_subset_lowerBounds_smul (hc : c ≤ 0) :\n    c • upperBounds s ⊆ lowerBounds (c • s) :=\n  (antitone_smul_left hc).image_upperBounds_subset_lowerBounds_image\n#align smul_upper_bounds_subset_lower_bounds_smul smul_upperBounds_subset_lowerBounds_smul\n\n/- warning: bdd_below.smul_of_nonpos -> BddBelow.smul_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (BddBelow.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s) -> (BddAbove.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LE.le.{u2} k (Preorder.toLE.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (BddBelow.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s) -> (BddAbove.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s))\nCase conversion may be inaccurate. Consider using '#align bdd_below.smul_of_nonpos BddBelow.smul_of_nonposₓ'. -/\ntheorem BddBelow.smul_of_nonpos (hc : c ≤ 0) (hs : BddBelow s) : BddAbove (c • s) :=\n  (antitone_smul_left hc).map_bddBelow hs\n#align bdd_below.smul_of_nonpos BddBelow.smul_of_nonpos\n\n/- warning: bdd_above.smul_of_nonpos -> BddAbove.smul_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedRing.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (OrderedRing.toOrderedSemiring.{u1} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LE.le.{u1} k (Preorder.toLE.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (OrderedRing.toOrderedAddCommGroup.{u1} k _inst_1)))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))))))) -> (BddAbove.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s) -> (BddBelow.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (OrderedRing.toRing.{u1} k _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedRing.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedRing.toOrderedSemiring.{u2} k _inst_1) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LE.le.{u2} k (Preorder.toLE.{u2} k (PartialOrder.toPreorder.{u2} k (OrderedRing.toPartialOrder.{u2} k _inst_1))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))))))) -> (BddAbove.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s) -> (BddBelow.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (MonoidWithZero.toZero.{u2} k (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (OrderedSemiring.toSemiring.{u2} k (OrderedRing.toOrderedSemiring.{u2} k _inst_1)) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s))\nCase conversion may be inaccurate. Consider using '#align bdd_above.smul_of_nonpos BddAbove.smul_of_nonposₓ'. -/\ntheorem BddAbove.smul_of_nonpos (hc : c ≤ 0) (hs : BddAbove s) : BddBelow (c • s) :=\n  (antitone_smul_left hc).map_bddAbove hs\n#align bdd_above.smul_of_nonpos BddAbove.smul_of_nonpos\n\nend OrderedRing\n\nsection LinearOrderedField\n\nvariable [LinearOrderedField k] [OrderedAddCommGroup M] [Module k M] [OrderedSMul k M] {s : Set M}\n  {c : k}\n\n/- warning: lower_bounds_smul_of_neg -> lowerBounds_smul_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Eq.{succ u2} (Set.{u2} M) (lowerBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c (upperBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s)))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Eq.{succ u1} (Set.{u1} M) (lowerBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c (upperBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s)))\nCase conversion may be inaccurate. Consider using '#align lower_bounds_smul_of_neg lowerBounds_smul_of_negₓ'. -/\n@[simp]\ntheorem lowerBounds_smul_of_neg (hc : c < 0) : lowerBounds (c • s) = c • upperBounds s :=\n  (OrderIso.smulLeftDual M hc).upperBounds_image\n#align lower_bounds_smul_of_neg lowerBounds_smul_of_neg\n\n/- warning: upper_bounds_smul_of_neg -> upperBounds_smul_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Eq.{succ u2} (Set.{u2} M) (upperBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c (lowerBounds.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s)))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Eq.{succ u1} (Set.{u1} M) (upperBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c (lowerBounds.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s)))\nCase conversion may be inaccurate. Consider using '#align upper_bounds_smul_of_neg upperBounds_smul_of_negₓ'. -/\n@[simp]\ntheorem upperBounds_smul_of_neg (hc : c < 0) : upperBounds (c • s) = c • lowerBounds s :=\n  (OrderIso.smulLeftDual M hc).lowerBounds_image\n#align upper_bounds_smul_of_neg upperBounds_smul_of_neg\n\n/- warning: bdd_below_smul_iff_of_neg -> bddBelow_smul_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Iff (BddBelow.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s)) (BddAbove.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Iff (BddBelow.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s)) (BddAbove.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s))\nCase conversion may be inaccurate. Consider using '#align bdd_below_smul_iff_of_neg bddBelow_smul_iff_of_negₓ'. -/\n@[simp]\ntheorem bddBelow_smul_iff_of_neg (hc : c < 0) : BddBelow (c • s) ↔ BddAbove s :=\n  (OrderIso.smulLeftDual M hc).bddAbove_image\n#align bdd_below_smul_iff_of_neg bddBelow_smul_iff_of_neg\n\n/- warning: bdd_above_smul_iff_of_neg -> bddAbove_smul_iff_of_neg is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} k] [_inst_2 : OrderedAddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))] [_inst_4 : OrderedSMul.{u1, u2} k M (StrictOrderedSemiring.toOrderedSemiring.{u1} k (StrictOrderedRing.toStrictOrderedSemiring.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (OrderedAddCommMonoid.toAddCommMonoid.{u2} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u2} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u2} M _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))] {s : Set.{u2} M} {c : k}, (LT.lt.{u1} k (Preorder.toLT.{u1} k (PartialOrder.toPreorder.{u1} k (OrderedAddCommGroup.toPartialOrder.{u1} k (StrictOrderedRing.toOrderedAddCommGroup.{u1} k (LinearOrderedRing.toStrictOrderedRing.{u1} k (LinearOrderedCommRing.toLinearOrderedRing.{u1} k (LinearOrderedField.toLinearOrderedCommRing.{u1} k _inst_1))))))) c (OfNat.ofNat.{u1} k 0 (OfNat.mk.{u1} k 0 (Zero.zero.{u1} k (MulZeroClass.toHasZero.{u1} k (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} k (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} k (NonAssocRing.toNonUnitalNonAssocRing.{u1} k (Ring.toNonAssocRing.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))))))) -> (Iff (BddAbove.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) (SMul.smul.{u1, u2} k (Set.{u2} M) (Set.smulSet.{u1, u2} k M (SMulZeroClass.toHasSmul.{u1, u2} k M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (SMulWithZero.toSmulZeroClass.{u1, u2} k M (MulZeroClass.toHasZero.{u1} k (MulZeroOneClass.toMulZeroClass.{u1} k (MonoidWithZero.toMulZeroOneClass.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u1, u2} k M (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2))))) (Module.toMulActionWithZero.{u1, u2} k M (Ring.toSemiring.{u1} k (DivisionRing.toRing.{u1} k (Field.toDivisionRing.{u1} k (LinearOrderedField.toField.{u1} k _inst_1)))) (AddCommGroup.toAddCommMonoid.{u2} M (OrderedAddCommGroup.toAddCommGroup.{u2} M _inst_2)) _inst_3))))) c s)) (BddBelow.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedAddCommGroup.toPartialOrder.{u2} M _inst_2)) s))\nbut is expected to have type\n  forall {k : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} k] [_inst_2 : OrderedAddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))] [_inst_4 : OrderedSMul.{u2, u1} k M (OrderedCommSemiring.toOrderedSemiring.{u2} k (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} k (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (OrderedAddCommMonoid.toAddCommMonoid.{u1} M (OrderedCancelAddCommMonoid.toOrderedAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3))] {s : Set.{u1} M} {c : k}, (LT.lt.{u2} k (Preorder.toLT.{u2} k (PartialOrder.toPreorder.{u2} k (StrictOrderedRing.toPartialOrder.{u2} k (LinearOrderedRing.toStrictOrderedRing.{u2} k (LinearOrderedCommRing.toLinearOrderedRing.{u2} k (LinearOrderedField.toLinearOrderedCommRing.{u2} k _inst_1)))))) c (OfNat.ofNat.{u2} k 0 (Zero.toOfNat0.{u2} k (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))))) -> (Iff (BddAbove.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) (HSMul.hSMul.{u2, u1, u1} k (Set.{u1} M) (Set.{u1} M) (instHSMul.{u2, u1} k (Set.{u1} M) (Set.smulSet.{u2, u1} k M (SMulZeroClass.toSMul.{u2, u1} k M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (SMulWithZero.toSMulZeroClass.{u2, u1} k M (CommMonoidWithZero.toZero.{u2} k (CommGroupWithZero.toCommMonoidWithZero.{u2} k (Semifield.toCommGroupWithZero.{u2} k (LinearOrderedSemifield.toSemifield.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u2, u1} k M (Semiring.toMonoidWithZero.{u2} k (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1)))))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M (OrderedAddCommGroup.toAddCommGroup.{u1} M _inst_2)))))) (Module.toMulActionWithZero.{u2, u1} k M (StrictOrderedSemiring.toSemiring.{u2} k (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} k (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} k (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} k (LinearOrderedField.toLinearOrderedSemifield.{u2} k _inst_1))))) (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} M (OrderedAddCommGroup.toOrderedCancelAddCommMonoid.{u1} M _inst_2)) _inst_3)))))) c s)) (BddBelow.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedAddCommGroup.toPartialOrder.{u1} M _inst_2)) s))\nCase conversion may be inaccurate. Consider using '#align bdd_above_smul_iff_of_neg bddAbove_smul_iff_of_negₓ'. -/\n@[simp]\ntheorem bddAbove_smul_iff_of_neg (hc : c < 0) : BddAbove (c • s) ↔ BddBelow s :=\n  (OrderIso.smulLeftDual M hc).bddBelow_image\n#align bdd_above_smul_iff_of_neg bddAbove_smul_iff_of_neg\n\nend LinearOrderedField\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.4671756735202199}}
{"text": "/-\nCopyright (c) 2021 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn\n\n! This file was ported from Lean 3 source module group_theory.nielsen_schreier\n! leanprover-community/mathlib commit 1bda4fc53de6ade5ab9da36f2192e24e2084a2ce\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Action\nimport Mathbin.Combinatorics.Quiver.Arborescence\nimport Mathbin.Combinatorics.Quiver.ConnectedComponent\nimport Mathbin.GroupTheory.IsFreeGroup\n\n/-!\n# The Nielsen-Schreier theorem\n\nThis file proves that a subgroup of a free group is itself free.\n\n## Main result\n\n- `subgroup_is_free_of_is_free H`: an instance saying that a subgroup of a free group is free.\n\n## Proof overview\n\nThe proof is analogous to the proof using covering spaces and fundamental groups of graphs,\nbut we work directly with groupoids instead of topological spaces. Under this analogy,\n\n- `is_free_groupoid G` corresponds to saying that a space is a graph.\n- `End_mul_equiv_subgroup H` plays the role of replacing 'subgroup of fundamental group' with\n  'fundamental group of covering space'.\n- `action_groupoid_is_free G A` corresponds to the fact that a covering of a (single-vertex)\n  graph is a graph.\n- `End_is_free T` corresponds to the fact that, given a spanning tree `T` of a\n  graph, its fundamental group is free (generated by loops from the complement of the tree).\n\n## Implementation notes\n\nOur definition of `is_free_groupoid` is nonstandard. Normally one would require that functors\n`G ⥤ X` to any _groupoid_ `X` are given by graph homomorphisms from the generators, but we only\nconsider _groups_ `X`. This simplifies the argument since functor equality is complicated in\ngeneral, but simple for functors to single object categories.\n\n## References\n\nhttps://ncatlab.org/nlab/show/Nielsen-Schreier+theorem\n\n## Tags\n\nfree group, free groupoid, Nielsen-Schreier\n\n-/\n\n\nnoncomputable section\n\nopen Classical\n\nuniverse v u\n\n/- ./././Mathport/Syntax/Translate/Command.lean:224:11: unsupported: unusual advanced open style -/\nopen CategoryTheory CategoryTheory.ActionCategory CategoryTheory.SingleObj Quiver\n\n/-- `is_free_groupoid.generators G` is a type synonym for `G`. We think of this as\nthe vertices of the generating quiver of `G` when `G` is free. We can't use `G` directly,\nsince `G` already has a quiver instance from being a groupoid. -/\n@[nolint unused_arguments has_nonempty_instance]\ndef IsFreeGroupoid.Generators (G) [Groupoid G] :=\n  G\n#align is_free_groupoid.generators IsFreeGroupoid.Generators\n\n/-- A groupoid `G` is free when we have the following data:\n - a quiver on `is_free_groupoid.generators G` (a type synonym for `G`)\n - a function `of` taking a generating arrow to a morphism in `G`\n - such that a functor from `G` to any group `X` is uniquely determined\n   by assigning labels in `X` to the generating arrows.\n\n   This definition is nonstandard. Normally one would require that functors `G ⥤ X`\n   to any _groupoid_ `X` are given by graph homomorphisms from `generators`. -/\nclass IsFreeGroupoid (G) [Groupoid.{v} G] where\n  quiverGenerators : Quiver.{v + 1} (IsFreeGroupoid.Generators G)\n  of : ∀ {a b : IsFreeGroupoid.Generators G}, (a ⟶ b) → ((show G from a) ⟶ b)\n  unique_lift :\n    ∀ {X : Type v} [Group X] (f : Labelling (IsFreeGroupoid.Generators G) X),\n      ∃! F : G ⥤ CategoryTheory.SingleObj X, ∀ (a b) (g : a ⟶ b), F.map (of g) = f g\n#align is_free_groupoid IsFreeGroupoid\n\nnamespace IsFreeGroupoid\n\nattribute [instance] quiver_generators\n\n/-- Two functors from a free groupoid to a group are equal when they agree on the generating\nquiver. -/\n@[ext]\ntheorem ext_functor {G} [Groupoid.{v} G] [IsFreeGroupoid G] {X : Type v} [Group X]\n    (f g : G ⥤ CategoryTheory.SingleObj X) (h : ∀ (a b) (e : a ⟶ b), f.map (of e) = g.map (of e)) :\n    f = g :=\n  let ⟨_, _, u⟩ := @unique_lift G _ _ X _ fun (a b : Generators G) (e : a ⟶ b) => g.map (of e)\n  trans (u _ h) (u _ fun _ _ _ => rfl).symm\n#align is_free_groupoid.ext_functor IsFreeGroupoid.ext_functor\n\n/-- An action groupoid over a free group is free. More generally, one could show that the groupoid\nof elements over a free groupoid is free, but this version is easier to prove and suffices for our\npurposes.\n\nAnalogous to the fact that a covering space of a graph is a graph. (A free groupoid is like a graph,\nand a groupoid of elements is like a covering space.) -/\ninstance actionGroupoidIsFree {G A : Type u} [Group G] [IsFreeGroup G] [MulAction G A] :\n    IsFreeGroupoid (ActionCategory G A)\n    where\n  quiverGenerators :=\n    ⟨fun a b => { e : IsFreeGroup.Generators G // IsFreeGroup.of e • a.back = b.back }⟩\n  of a b e := ⟨IsFreeGroup.of e, e.property⟩\n  unique_lift := by\n    intro X _ f\n    let f' : fgp.generators G → (A → X) ⋊[mulAutArrow] G := fun e =>\n      ⟨fun b => @f ⟨(), _⟩ ⟨(), b⟩ ⟨e, smul_inv_smul _ b⟩, fgp.of e⟩\n    rcases fgp.unique_lift f' with ⟨F', hF', uF'⟩\n    refine' ⟨uncurry F' _, _, _⟩\n    · suffices semidirect_product.right_hom.comp F' = MonoidHom.id _ by\n        exact monoid_hom.ext_iff.mp this\n      ext\n      rw [MonoidHom.comp_apply, hF']\n      rfl\n    · rintro ⟨⟨⟩, a : A⟩ ⟨⟨⟩, b⟩ ⟨e, h : fgp.of e • a = b⟩\n      change (F' (fgp.of _)).left _ = _\n      rw [hF']\n      cases inv_smul_eq_iff.mpr h.symm\n      rfl\n    · intro E hE\n      have : curry E = F' := by\n        apply uF'\n        intro e\n        ext\n        · convert hE _ _ _\n          rfl\n        · rfl\n      apply functor.hext\n      · intro\n        apply Unit.ext\n      · refine' action_category.cases _\n        intros\n        simp only [← this, uncurry_map, curry_apply_left, coe_back, hom_of_pair.val]\n#align is_free_groupoid.action_groupoid_is_free IsFreeGroupoid.actionGroupoidIsFree\n\nnamespace SpanningTree\n\n/- In this section, we suppose we have a free groupoid with a spanning tree for its generating\nquiver. The goal is to prove that the vertex group at the root is free. A picture to have in mind\nis that we are 'pulling' the endpoints of all the edges of the quiver along the spanning tree to\nthe root. -/\nvariable {G : Type u} [Groupoid.{u} G] [IsFreeGroupoid G]\n  (T : WideSubquiver (Symmetrify <| Generators G)) [Arborescence T]\n\n/-- The root of `T`, except its type is `G` instead of the type synonym `T`. -/\nprivate def root' : G :=\n  show T from root T\n#align is_free_groupoid.spanning_tree.root' is_free_groupoid.spanning_tree.root'\n\n-- this has to be marked noncomputable, see issue #451.\n-- It might be nicer to define this in terms of `compose_path`\n/-- A path in the tree gives a hom, by composition. -/\nnoncomputable def homOfPath : ∀ {a : G}, Path (root T) a → (root' T ⟶ a)\n  | _, path.nil => 𝟙 _\n  | a, path.cons p f => hom_of_path p ≫ Sum.recOn f.val (fun e => of e) fun e => inv (of e)\n#align is_free_groupoid.spanning_tree.hom_of_path IsFreeGroupoid.SpanningTree.homOfPath\n\n/-- For every vertex `a`, there is a canonical hom from the root, given by the path in the tree. -/\ndef treeHom (a : G) : root' T ⟶ a :=\n  homOfPath T default\n#align is_free_groupoid.spanning_tree.tree_hom IsFreeGroupoid.SpanningTree.treeHom\n\n/-- Any path to `a` gives `tree_hom T a`, since paths in the tree are unique. -/\ntheorem treeHom_eq {a : G} (p : Path (root T) a) : treeHom T a = homOfPath T p := by\n  rw [tree_hom, Unique.default_eq]\n#align is_free_groupoid.spanning_tree.tree_hom_eq IsFreeGroupoid.SpanningTree.treeHom_eq\n\n@[simp]\ntheorem treeHom_root : treeHom T (root' T) = 𝟙 _ :=\n  -- this should just be `tree_hom_eq T path.nil`, but Lean treats `hom_of_path` with suspicion.\n    trans\n    (treeHom_eq T Path.nil) rfl\n#align is_free_groupoid.spanning_tree.tree_hom_root IsFreeGroupoid.SpanningTree.treeHom_root\n\n/-- Any hom in `G` can be made into a loop, by conjugating with `tree_hom`s. -/\ndef loopOfHom {a b : G} (p : a ⟶ b) : End (root' T) :=\n  treeHom T a ≫ p ≫ inv (treeHom T b)\n#align is_free_groupoid.spanning_tree.loop_of_hom IsFreeGroupoid.SpanningTree.loopOfHom\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (e «expr ∈ » wide_subquiver_symmetrify[quiver.wide_subquiver_symmetrify] T a b) -/\n/-- Turning an edge in the spanning tree into a loop gives the indentity loop. -/\ntheorem loopOfHom_eq_id {a b : Generators G} (e) (_ : e ∈ wideSubquiverSymmetrify T a b) :\n    loopOfHom T (of e) = 𝟙 (root' T) :=\n  by\n  rw [loop_of_hom, ← category.assoc, is_iso.comp_inv_eq, category.id_comp]\n  cases H\n  · rw [tree_hom_eq T (path.cons default ⟨Sum.inl e, H⟩), hom_of_path]\n    rfl\n  · rw [tree_hom_eq T (path.cons default ⟨Sum.inr e, H⟩), hom_of_path]\n    simp only [is_iso.inv_hom_id, category.comp_id, category.assoc, tree_hom]\n#align is_free_groupoid.spanning_tree.loop_of_hom_eq_id IsFreeGroupoid.SpanningTree.loopOfHom_eq_id\n\n/-- Since a hom gives a loop, any homomorphism from the vertex group at the root\n    extends to a functor on the whole groupoid. -/\n@[simps]\ndef functorOfMonoidHom {X} [Monoid X] (f : End (root' T) →* X) : G ⥤ CategoryTheory.SingleObj X\n    where\n  obj _ := ()\n  map a b p := f (loopOfHom T p)\n  map_id' := by\n    intro a\n    rw [loop_of_hom, category.id_comp, is_iso.hom_inv_id, ← End.one_def, f.map_one, id_as_one]\n  map_comp' := by\n    intros\n    rw [comp_as_mul, ← f.map_mul]\n    simp only [is_iso.inv_hom_id_assoc, loop_of_hom, End.mul_def, category.assoc]\n#align is_free_groupoid.spanning_tree.functor_of_monoid_hom IsFreeGroupoid.SpanningTree.functorOfMonoidHom\n\n/-- Given a free groupoid and an arborescence of its generating quiver, the vertex\n    group at the root is freely generated by loops coming from generating arrows\n    in the complement of the tree. -/\ndef endIsFree : IsFreeGroup (End (root' T)) :=\n  IsFreeGroup.ofUniqueLift ((wideSubquiverEquivSetTotal <| wideSubquiverSymmetrify T)ᶜ : Set _)\n    (fun e => loopOfHom T (of e.val.Hom))\n    (by\n      intro X _ f\n      let f' : labelling (generators G) X := fun a b e =>\n        if h : e ∈ wide_subquiver_symmetrify T a b then 1 else f ⟨⟨a, b, e⟩, h⟩\n      rcases unique_lift f' with ⟨F', hF', uF'⟩\n      refine' ⟨F'.map_End _, _, _⟩\n      · suffices ∀ {x y} (q : x ⟶ y), F'.map (loop_of_hom T q) = (F'.map q : X)\n          by\n          rintro ⟨⟨a, b, e⟩, h⟩\n          rw [functor.map_End_apply, this, hF']\n          exact dif_neg h\n        intros\n        suffices ∀ {a} (p : Path (root' T) a), F'.map (hom_of_path T p) = 1 by\n          simp only [this, tree_hom, comp_as_mul, inv_as_inv, loop_of_hom, inv_one, mul_one,\n            one_mul, functor.map_inv, functor.map_comp]\n        intro a p\n        induction' p with b c p e ih\n        · rw [hom_of_path, F'.map_id, id_as_one]\n        rw [hom_of_path, F'.map_comp, comp_as_mul, ih, mul_one]\n        rcases e with ⟨e | e, eT⟩\n        · rw [hF']\n          exact dif_pos (Or.inl eT)\n        · rw [F'.map_inv, inv_as_inv, inv_eq_one, hF']\n          exact dif_pos (Or.inr eT)\n      · intro E hE\n        ext\n        suffices (functor_of_monoid_hom T E).map x = F'.map x by\n          simpa only [loop_of_hom, functor_of_monoid_hom_map, is_iso.inv_id, tree_hom_root,\n            category.id_comp, category.comp_id] using this\n        congr\n        apply uF'\n        intro a b e\n        change E (loop_of_hom T _) = dite _ _ _\n        split_ifs\n        · rw [loop_of_hom_eq_id T e h, ← End.one_def, E.map_one]\n        · exact hE ⟨⟨a, b, e⟩, h⟩)\n#align is_free_groupoid.spanning_tree.End_is_free IsFreeGroupoid.SpanningTree.endIsFree\n\nend SpanningTree\n\n/-- Another name for the identity function `G → G`, to help type checking. -/\nprivate def symgen {G : Type u} [Groupoid.{v} G] [IsFreeGroupoid G] :\n    G → Symmetrify (Generators G) :=\n  id\n#align is_free_groupoid.symgen is_free_groupoid.symgen\n\n/-- If there exists a morphism `a → b` in a free groupoid, then there also exists a zigzag\nfrom `a` to `b` in the generating quiver. -/\ntheorem path_nonempty_of_hom {G} [Groupoid.{u, u} G] [IsFreeGroupoid G] {a b : G} :\n    Nonempty (a ⟶ b) → Nonempty (Path (symgen a) (symgen b)) :=\n  by\n  rintro ⟨p⟩\n  rw [← @weakly_connected_component.eq (generators G), eq_comm, ← free_group.of_injective.eq_iff, ←\n    mul_inv_eq_one]\n  let X := FreeGroup (weakly_connected_component <| generators G)\n  let f : G → X := fun g => FreeGroup.of (weakly_connected_component.mk g)\n  let F : G ⥤ CategoryTheory.SingleObj X := single_obj.difference_functor f\n  change F.map p = ((CategoryTheory.Functor.const G).obj ()).map p\n  congr ; ext\n  rw [functor.const_obj_map, id_as_one, difference_functor_map, mul_inv_eq_one]\n  apply congr_arg FreeGroup.of\n  apply (weakly_connected_component.eq _ _).mpr\n  exact ⟨hom.to_path (Sum.inr e)⟩\n#align is_free_groupoid.path_nonempty_of_hom IsFreeGroupoid.path_nonempty_of_hom\n\n/-- Given a connected free groupoid, its generating quiver is rooted-connected. -/\ninstance generators_connected (G) [Groupoid.{u, u} G] [IsConnected G] [IsFreeGroupoid G] (r : G) :\n    RootedConnected (symgen r) :=\n  ⟨fun b => path_nonempty_of_hom (CategoryTheory.nonempty_hom_of_connected_groupoid r b)⟩\n#align is_free_groupoid.generators_connected IsFreeGroupoid.generators_connected\n\n/-- A vertex group in a free connected groupoid is free. With some work one could drop the\nconnectedness assumption, by looking at connected components. -/\ninstance endIsFreeOfConnectedFree {G} [Groupoid G] [IsConnected G] [IsFreeGroupoid G] (r : G) :\n    IsFreeGroup (End r) :=\n  SpanningTree.endIsFree <| geodesicSubtree (symgen r)\n#align is_free_groupoid.End_is_free_of_connected_free IsFreeGroupoid.endIsFreeOfConnectedFree\n\nend IsFreeGroupoid\n\n/-- The Nielsen-Schreier theorem: a subgroup of a free group is free. -/\ninstance subgroupIsFreeOfIsFree {G : Type u} [Group G] [IsFreeGroup G] (H : Subgroup G) :\n    IsFreeGroup H :=\n  IsFreeGroup.ofMulEquiv (endMulEquivSubgroup H)\n#align subgroup_is_free_of_is_free subgroupIsFreeOfIsFree\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/GroupTheory/NielsenSchreier.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.746138993030751, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.4671756735202198}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta, Edward Ayers, Thomas Read. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Edward Ayers, Thomas Read\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.finite_products\nimport Mathlib.category_theory.limits.preserves.shapes.binary_products\nimport Mathlib.category_theory.closed.monoidal\nimport Mathlib.category_theory.monoidal.of_has_finite_products\nimport Mathlib.category_theory.adjunction.default\nimport Mathlib.category_theory.adjunction.mates\nimport Mathlib.category_theory.epi_mono\nimport Mathlib.PostPort\n\nuniverses v u u₂ \n\nnamespace Mathlib\n\n/-!\n# Cartesian closed categories\n\nGiven a category with finite products, the cartesian monoidal structure is provided by the local\ninstance `monoidal_of_has_finite_products`.\n\nWe define exponentiable objects to be closed objects with respect to this monoidal structure,\ni.e. `(X × -)` is a left adjoint.\n\nWe say a category is cartesian closed if every object is exponentiable\n(equivalently, that the category equipped with the cartesian monoidal structure is closed monoidal).\n\nShow that exponential forms a difunctor and define the exponential comparison morphisms.\n\n## TODO\nSome of the results here are true more generally for closed objects and\nfor closed monoidal categories, and these could be generalised.\n-/\n\nnamespace category_theory\n\n\n/--\nAn object `X` is *exponentiable* if `(X × -)` is a left adjoint.\nWe define this as being `closed` in the cartesian monoidal structure.\n-/\ndef exponentiable {C : Type u} [category C] [limits.has_finite_products C] (X : C) :=\n  closed X\n\n/--\nIf `X` and `Y` are exponentiable then `X ⨯ Y` is.\nThis isn't an instance because it's not usually how we want to construct exponentials, we'll usually\nprove all objects are exponential uniformly.\n-/\ndef binary_product_exponentiable {C : Type u} [category C] [limits.has_finite_products C] {X : C} {Y : C} (hX : exponentiable X) (hY : exponentiable Y) : exponentiable (X ⨯ Y) :=\n  closed.mk (adjunction.left_adjoint_of_nat_iso (iso.symm (monoidal_category.tensor_left_tensor X Y)))\n\n/--\nThe terminal object is always exponentiable.\nThis isn't an instance because most of the time we'll prove cartesian closed for all objects\nat once, rather than just for this one.\n-/\ndef terminal_exponentiable {C : Type u} [category C] [limits.has_finite_products C] : exponentiable (⊤_C) :=\n  unit_closed\n\n/--\nA category `C` is cartesian closed if it has finite products and every object is exponentiable.\nWe define this as `monoidal_closed` with respect to the cartesian monoidal structure.\n-/\ndef cartesian_closed (C : Type u) [category C] [limits.has_finite_products C] :=\n  monoidal_closed C\n\n/-- This is (-)^A. -/\ndef exp {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] : C ⥤ C :=\n  is_left_adjoint.right (monoidal_category.tensor_left A)\n\n/-- The adjunction between A ⨯ - and (-)^A. -/\ndef exp.adjunction {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] : functor.obj limits.prod.functor A ⊣ exp A :=\n  is_left_adjoint.adj\n\n/-- The evaluation natural transformation. -/\ndef ev {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] : exp A ⋙ functor.obj limits.prod.functor A ⟶ 𝟭 :=\n  adjunction.counit is_left_adjoint.adj\n\n/-- The coevaluation natural transformation. -/\ndef coev {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] : 𝟭 ⟶ functor.obj limits.prod.functor A ⋙ exp A :=\n  adjunction.unit is_left_adjoint.adj\n\n@[simp] theorem exp_adjunction_counit {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] : adjunction.counit (exp.adjunction A) = ev A :=\n  rfl\n\n@[simp] theorem exp_adjunction_unit {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] : adjunction.unit (exp.adjunction A) = coev A :=\n  rfl\n\n@[simp] theorem ev_naturality {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] {X : C} {Y : C} (f : X ⟶ Y) : limits.prod.map 𝟙 (functor.map (exp A) f) ≫ nat_trans.app (ev A) Y = nat_trans.app (ev A) X ≫ f :=\n  nat_trans.naturality (ev A) f\n\n@[simp] theorem coev_naturality_assoc {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] {X : C} {Y : C} (f : X ⟶ Y) {X' : C} (f' : functor.obj (functor.obj limits.prod.functor A ⋙ exp A) Y ⟶ X') : f ≫ nat_trans.app (coev A) Y ≫ f' = nat_trans.app (coev A) X ≫ functor.map (exp A) (limits.prod.map 𝟙 f) ≫ f' := sorry\n\n@[simp] theorem ev_coev {C : Type u} [category C] (A : C) (B : C) [limits.has_finite_products C] [exponentiable A] : limits.prod.map 𝟙 (nat_trans.app (coev A) B) ≫ nat_trans.app (ev A) (A ⨯ B) = 𝟙 :=\n  adjunction.left_triangle_components (exp.adjunction A)\n\n@[simp] theorem coev_ev {C : Type u} [category C] (A : C) (B : C) [limits.has_finite_products C] [exponentiable A] : nat_trans.app (coev A) (functor.obj (exp A) B) ≫ functor.map (exp A) (nat_trans.app (ev A) B) = 𝟙 :=\n  adjunction.right_triangle_components (exp.adjunction A)\n\nprotected instance obj.limits.preserves_colimits {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] : limits.preserves_colimits (functor.obj limits.prod.functor A) :=\n  adjunction.left_adjoint_preserves_colimits (exp.adjunction A)\n\n-- Wrap these in a namespace so we don't clash with the core versions.\n\nnamespace cartesian_closed\n\n\n/-- Currying in a cartesian closed category. -/\ndef curry {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] : (A ⨯ Y ⟶ X) → (Y ⟶ functor.obj (exp A) X) :=\n  equiv.to_fun (adjunction.hom_equiv is_left_adjoint.adj Y X)\n\n/-- Uncurrying in a cartesian closed category. -/\ndef uncurry {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] : (Y ⟶ functor.obj (exp A) X) → (A ⨯ Y ⟶ X) :=\n  equiv.inv_fun (adjunction.hom_equiv is_left_adjoint.adj Y X)\n\nend cartesian_closed\n\n\ntheorem curry_natural_left_assoc {C : Type u} [category C] {A : C} {X : C} {X' : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (f : X ⟶ X') (g : A ⨯ X' ⟶ Y) : ∀ {X'_1 : C} (f' : functor.obj (exp A) Y ⟶ X'_1),\n  cartesian_closed.curry (limits.prod.map 𝟙 f ≫ g) ≫ f' = f ≫ cartesian_closed.curry g ≫ f' := sorry\n\ntheorem curry_natural_right_assoc {C : Type u} [category C] {A : C} {X : C} {Y : C} {Y' : C} [limits.has_finite_products C] [exponentiable A] (f : A ⨯ X ⟶ Y) (g : Y ⟶ Y') {X' : C} (f' : functor.obj (exp A) Y' ⟶ X') : cartesian_closed.curry (f ≫ g) ≫ f' = cartesian_closed.curry f ≫ functor.map (exp A) g ≫ f' := sorry\n\ntheorem uncurry_natural_right {C : Type u} [category C] {A : C} {X : C} {Y : C} {Y' : C} [limits.has_finite_products C] [exponentiable A] (f : X ⟶ functor.obj (exp A) Y) (g : Y ⟶ Y') : cartesian_closed.uncurry (f ≫ functor.map (exp A) g) = cartesian_closed.uncurry f ≫ g :=\n  adjunction.hom_equiv_naturality_right_symm is_left_adjoint.adj f g\n\ntheorem uncurry_natural_left {C : Type u} [category C] {A : C} {X : C} {X' : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (f : X ⟶ X') (g : X' ⟶ functor.obj (exp A) Y) : cartesian_closed.uncurry (f ≫ g) = limits.prod.map 𝟙 f ≫ cartesian_closed.uncurry g :=\n  adjunction.hom_equiv_naturality_left_symm is_left_adjoint.adj f g\n\n@[simp] theorem uncurry_curry {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (f : A ⨯ X ⟶ Y) : cartesian_closed.uncurry (cartesian_closed.curry f) = f :=\n  equiv.left_inv (adjunction.hom_equiv is_left_adjoint.adj X Y) f\n\n@[simp] theorem curry_uncurry {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (f : X ⟶ functor.obj (exp A) Y) : cartesian_closed.curry (cartesian_closed.uncurry f) = f :=\n  equiv.right_inv (adjunction.hom_equiv is_left_adjoint.adj X Y) f\n\ntheorem curry_eq_iff {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (f : A ⨯ Y ⟶ X) (g : Y ⟶ functor.obj (exp A) X) : cartesian_closed.curry f = g ↔ f = cartesian_closed.uncurry g :=\n  adjunction.hom_equiv_apply_eq is_left_adjoint.adj f g\n\ntheorem eq_curry_iff {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (f : A ⨯ Y ⟶ X) (g : Y ⟶ functor.obj (exp A) X) : g = cartesian_closed.curry f ↔ cartesian_closed.uncurry g = f :=\n  adjunction.eq_hom_equiv_apply is_left_adjoint.adj f g\n\n-- I don't think these two should be simp.\n\ntheorem uncurry_eq {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (g : Y ⟶ functor.obj (exp A) X) : cartesian_closed.uncurry g = limits.prod.map 𝟙 g ≫ nat_trans.app (ev A) X :=\n  adjunction.hom_equiv_counit is_left_adjoint.adj\n\ntheorem curry_eq {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (g : A ⨯ Y ⟶ X) : cartesian_closed.curry g = nat_trans.app (coev A) Y ≫ functor.map (exp A) g :=\n  adjunction.hom_equiv_unit is_left_adjoint.adj\n\ntheorem uncurry_id_eq_ev {C : Type u} [category C] [limits.has_finite_products C] (A : C) (X : C) [exponentiable A] : cartesian_closed.uncurry 𝟙 = nat_trans.app (ev A) X := sorry\n\ntheorem curry_id_eq_coev {C : Type u} [category C] [limits.has_finite_products C] (A : C) (X : C) [exponentiable A] : cartesian_closed.curry 𝟙 = nat_trans.app (coev A) X := sorry\n\ntheorem curry_injective {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] : function.injective cartesian_closed.curry :=\n  equiv.injective (adjunction.hom_equiv is_left_adjoint.adj Y X)\n\ntheorem uncurry_injective {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C] [exponentiable A] : function.injective cartesian_closed.uncurry :=\n  equiv.injective (equiv.symm (adjunction.hom_equiv is_left_adjoint.adj Y X))\n\n/--\nShow that the exponential of the terminal object is isomorphic to itself, i.e. `X^1 ≅ X`.\n\nThe typeclass argument is explicit: any instance can be used.\n-/\ndef exp_terminal_iso_self {C : Type u} [category C] {X : C} [limits.has_finite_products C] [exponentiable (⊤_C)] : functor.obj (exp (⊤_C)) X ≅ X :=\n  yoneda.ext (functor.obj (exp (⊤_C)) X) X\n    (fun (Y : C) (f : Y ⟶ functor.obj (exp (⊤_C)) X) => iso.inv (limits.prod.left_unitor Y) ≫ cartesian_closed.uncurry f)\n    (fun (Y : C) (f : Y ⟶ X) => cartesian_closed.curry (iso.hom (limits.prod.left_unitor Y) ≫ f)) sorry sorry sorry\n\n/-- The internal element which points at the given morphism. -/\ndef internalize_hom {C : Type u} [category C] {A : C} {Y : C} [limits.has_finite_products C] [exponentiable A] (f : A ⟶ Y) : ⊤_C ⟶ functor.obj (exp A) Y :=\n  cartesian_closed.curry (limits.prod.fst ≫ f)\n\n/-- Pre-compose an internal hom with an external hom. -/\ndef pre {C : Type u} [category C] {A : C} {B : C} [limits.has_finite_products C] [exponentiable A] (f : B ⟶ A) [exponentiable B] : exp A ⟶ exp B :=\n  coe_fn (transfer_nat_trans_self (exp.adjunction A) (exp.adjunction B)) (functor.map limits.prod.functor f)\n\ntheorem prod_map_pre_app_comp_ev {C : Type u} [category C] {A : C} {B : C} [limits.has_finite_products C] [exponentiable A] (f : B ⟶ A) [exponentiable B] (X : C) : limits.prod.map 𝟙 (nat_trans.app (pre f) X) ≫ nat_trans.app (ev B) X = limits.prod.map f 𝟙 ≫ nat_trans.app (ev A) X :=\n  transfer_nat_trans_self_counit (exp.adjunction A) (exp.adjunction B) (functor.map limits.prod.functor f) X\n\ntheorem uncurry_pre {C : Type u} [category C] {A : C} {B : C} [limits.has_finite_products C] [exponentiable A] (f : B ⟶ A) [exponentiable B] (X : C) : cartesian_closed.uncurry (nat_trans.app (pre f) X) = limits.prod.map f 𝟙 ≫ nat_trans.app (ev A) X := sorry\n\ntheorem coev_app_comp_pre_app {C : Type u} [category C] {A : C} {B : C} {X : C} [limits.has_finite_products C] [exponentiable A] (f : B ⟶ A) [exponentiable B] : nat_trans.app (coev A) X ≫ nat_trans.app (pre f) (A ⨯ X) =\n  nat_trans.app (coev B) X ≫ functor.map (exp B) (limits.prod.map f 𝟙) :=\n  unit_transfer_nat_trans_self is_left_adjoint.adj (exp.adjunction B) (functor.map limits.prod.functor f) X\n\n@[simp] theorem pre_id {C : Type u} [category C] [limits.has_finite_products C] (A : C) [exponentiable A] : pre 𝟙 = 𝟙 := sorry\n\n@[simp] theorem pre_map {C : Type u} [category C] [limits.has_finite_products C] {A₁ : C} {A₂ : C} {A₃ : C} [exponentiable A₁] [exponentiable A₂] [exponentiable A₃] (f : A₁ ⟶ A₂) (g : A₂ ⟶ A₃) : pre (f ≫ g) = pre g ≫ pre f := sorry\n\n/-- The internal hom functor given by the cartesian closed structure. -/\ndef internal_hom {C : Type u} [category C] [limits.has_finite_products C] [cartesian_closed C] : Cᵒᵖ ⥤ C ⥤ C :=\n  functor.mk (fun (X : Cᵒᵖ) => exp (opposite.unop X)) fun (X Y : Cᵒᵖ) (f : X ⟶ Y) => pre (has_hom.hom.unop f)\n\n/-- If an initial object `I` exists in a CCC, then `A ⨯ I ≅ I`. -/\n@[simp] theorem zero_mul_hom {C : Type u} [category C] {A : C} [limits.has_finite_products C] [exponentiable A] {I : C} (t : limits.is_initial I) : iso.hom (zero_mul t) = limits.prod.snd :=\n  Eq.refl (iso.hom (zero_mul t))\n\n/-- If an initial object `0` exists in a CCC, then `0 ⨯ A ≅ 0`. -/\ndef mul_zero {C : Type u} [category C] {A : C} [limits.has_finite_products C] [exponentiable A] {I : C} (t : limits.is_initial I) : I ⨯ A ≅ I :=\n  limits.prod.braiding I A ≪≫ zero_mul t\n\n/-- If an initial object `0` exists in a CCC then `0^B ≅ 1` for any `B`. -/\ndef pow_zero {C : Type u} [category C] (B : C) [limits.has_finite_products C] {I : C} (t : limits.is_initial I) [cartesian_closed C] : functor.obj (exp I) B ≅ ⊤_C :=\n  iso.mk Inhabited.default (cartesian_closed.curry (iso.hom (mul_zero t) ≫ limits.is_initial.to t B))\n\n-- TODO: Generalise the below to its commutated variants.\n\n-- TODO: Define a distributive category, so that zero_mul and friends can be derived from this.\n\n/-- In a CCC with binary coproducts, the distribution morphism is an isomorphism. -/\ndef prod_coprod_distrib {C : Type u} [category C] [limits.has_finite_products C] [limits.has_binary_coproducts C] [cartesian_closed C] (X : C) (Y : C) (Z : C) : Z ⨯ X ⨿ (Z ⨯ Y) ≅ Z ⨯ (X ⨿ Y) :=\n  iso.mk (limits.coprod.desc (limits.prod.map 𝟙 limits.coprod.inl) (limits.prod.map 𝟙 limits.coprod.inr))\n    (cartesian_closed.uncurry\n      (limits.coprod.desc (cartesian_closed.curry limits.coprod.inl) (cartesian_closed.curry limits.coprod.inr)))\n\n/--\nIf an initial object `I` exists in a CCC then it is a strict initial object,\ni.e. any morphism to `I` is an iso.\nThis actually shows a slightly stronger version: any morphism to an initial object from an\nexponentiable object is an isomorphism.\n-/\ndef strict_initial {C : Type u} [category C] {A : C} [limits.has_finite_products C] [exponentiable A] {I : C} (t : limits.is_initial I) (f : A ⟶ I) : is_iso f :=\n  is_iso_of_mono_of_split_epi f\n\nprotected instance to_initial_is_iso {C : Type u} [category C] {A : C} [limits.has_finite_products C] [exponentiable A] [limits.has_initial C] (f : A ⟶ ⊥_C) : is_iso f :=\n  strict_initial limits.initial_is_initial f\n\n/-- If an initial object `0` exists in a CCC then every morphism from it is monic. -/\ntheorem initial_mono {C : Type u} [category C] [limits.has_finite_products C] {I : C} (B : C) (t : limits.is_initial I) [cartesian_closed C] : mono (limits.is_initial.to t B) :=\n  mono.mk\n    fun (B_1 : C) (g h : B_1 ⟶ I) (_x : g ≫ limits.is_initial.to t B = h ≫ limits.is_initial.to t B) =>\n      eq_of_inv_eq_inv (limits.is_initial.hom_ext t (inv g) (inv h))\n\nprotected instance initial.mono_to {C : Type u} [category C] [limits.has_finite_products C] [limits.has_initial C] (B : C) [cartesian_closed C] : mono (limits.initial.to B) :=\n  initial_mono B limits.initial_is_initial\n\n/--\nTransport the property of being cartesian closed across an equivalence of categories.\n\nNote we didn't require any coherence between the choice of finite products here, since we transport\nalong the `prod_comparison` isomorphism.\n-/\ndef cartesian_closed_of_equiv {C : Type u} [category C] [limits.has_finite_products C] {D : Type u₂} [category D] [limits.has_finite_products D] (e : C ≌ D) [h : cartesian_closed C] : cartesian_closed D :=\n  monoidal_closed.mk\n    fun (X : D) =>\n      closed.mk\n        (adjunction.left_adjoint_of_nat_iso\n          (iso_whisker_right (equivalence.counit_iso e)\n              (functor.obj limits.prod.functor X ⋙ equivalence.inverse e ⋙ equivalence.functor e) ≪≫\n            id (iso_whisker_left (functor.obj limits.prod.functor X) (equivalence.counit_iso e))))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/closed/cartesian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.46717566310933384}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang, Eric Wieser\n\n! This file was ported from Lean 3 source module algebra.graded_mul_action\n! leanprover-community/mathlib commit 0ebfdb71919ac6ca5d7fbc61a082fa2519556818\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GradedMonoid\n\n/-!\n# Additively-graded multiplicative action structures\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis module provides a set of heterogeneous typeclasses for defining a multiplicative structure\nover the sigma type `graded_monoid A` such that `(•) : A i → M j → M (i + j)`; that is to say, `A`\nhas an additively-graded multiplicative action on `M`. The typeclasses are:\n\n* `graded_monoid.ghas_smul A M`\n* `graded_monoid.gmul_action A M`\n\nWith the `sigma_graded` locale open, these respectively imbue:\n\n* `has_smul (graded_monoid A) (graded_monoid M)`\n* `mul_action (graded_monoid A) (graded_monoid M)`\n\nFor now, these typeclasses are primarily used in the construction of `direct_sum.gmodule.module` and\nthe rest of that file.\n\n## Internally graded multiplicative actions\n\nIn addition to the above typeclasses, in the most frequent case when `A` is an indexed collection of\n`set_like` subobjects (such as `add_submonoid`s, `add_subgroup`s, or `submodule`s), this file\nprovides the `Prop` typeclasses:\n\n* `set_like.has_graded_smul A M` (which provides the obvious `graded_monoid.ghas_smul A` instance)\n\nwhich provides the API lemma\n\n* `set_like.graded_smul_mem_graded`\n\nNote that there is no need for `set_like.graded_mul_action` or similar, as all the information it\nwould contain is already supplied by `has_graded_smul` when the objects within `A` and `M` have\na `mul_action` instance.\n\n## tags\n\ngraded action\n-/\n\n\nvariable {ι : Type _}\n\nnamespace GradedMonoid\n\n/-! ### Typeclasses -/\n\n\nsection Defs\n\nvariable (A : ι → Type _) (M : ι → Type _)\n\n#print GradedMonoid.GSmul /-\n/-- A graded version of `has_smul`. Scalar multiplication combines grades additively, i.e.\nif `a ∈ A i` and `m ∈ M j`, then `a • b` must be in `M (i + j)`-/\nclass GSmul [Add ι] where\n  smul {i j} : A i → M j → M (i + j)\n#align graded_monoid.ghas_smul GradedMonoid.GSmul\n-/\n\n#print GradedMonoid.GMul.toGSmul /-\n/-- A graded version of `has_mul.to_has_smul` -/\ninstance GMul.toGSmul [Add ι] [GMul A] : GSmul A A where smul _ _ := GMul.mul\n#align graded_monoid.ghas_mul.to_ghas_smul GradedMonoid.GMul.toGSmul\n-/\n\n#print GradedMonoid.GSmul.toSMul /-\ninstance GSmul.toSMul [Add ι] [GSmul A M] : SMul (GradedMonoid A) (GradedMonoid M) :=\n  ⟨fun (x : GradedMonoid A) (y : GradedMonoid M) => ⟨_, GSmul.smul x.snd y.snd⟩⟩\n#align graded_monoid.ghas_smul.to_has_smul GradedMonoid.GSmul.toSMul\n-/\n\n/- warning: graded_monoid.mk_smul_mk -> GradedMonoid.mk_smul_mk is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} (A : ι -> Type.{u2}) (M : ι -> Type.{u3}) [_inst_1 : Add.{u1} ι] [_inst_2 : GradedMonoid.GSmul.{u1, u2, u3} ι A M _inst_1] {i : ι} {j : ι} (a : A i) (b : M j), Eq.{succ (max u1 u3)} (GradedMonoid.{u1, u3} ι (fun {j : ι} => M j)) (SMul.smul.{max u1 u2, max u1 u3} (GradedMonoid.{u1, u2} ι (fun {i : ι} => A i)) (GradedMonoid.{u1, u3} ι (fun {j : ι} => M j)) (GradedMonoid.GSmul.toSMul.{u1, u2, u3} ι (fun {i : ι} => A i) (fun {j : ι} => M j) _inst_1 _inst_2) (GradedMonoid.mk.{u1, u2} ι (fun {i : ι} => A i) i a) (GradedMonoid.mk.{u1, u3} ι (fun {j : ι} => M j) j b)) (GradedMonoid.mk.{u1, u3} ι (fun {j : ι} => M j) (HAdd.hAdd.{u1, u1, u1} ι ι ι (instHAdd.{u1} ι _inst_1) i j) (GradedMonoid.GSmul.smul.{u1, u2, u3} ι (fun {i : ι} => A i) M _inst_1 _inst_2 i j a b))\nbut is expected to have type\n  forall {ι : Type.{u3}} (A : ι -> Type.{u2}) (M : ι -> Type.{u1}) [_inst_1 : Add.{u3} ι] [_inst_2 : GradedMonoid.GSmul.{u3, u2, u1} ι A M _inst_1] {i : ι} {j : ι} (a : A i) (b : M j), Eq.{max (succ u3) (succ u1)} (GradedMonoid.{u3, u1} ι M) (HSMul.hSMul.{max u2 u3, max u1 u3, max u3 u1} (GradedMonoid.{u3, u2} ι A) (GradedMonoid.{u3, u1} ι M) (GradedMonoid.{u3, u1} ι M) (instHSMul.{max u3 u2, max u3 u1} (GradedMonoid.{u3, u2} ι A) (GradedMonoid.{u3, u1} ι M) (GradedMonoid.GSmul.toSMul.{u3, u2, u1} ι A M _inst_1 _inst_2)) (GradedMonoid.mk.{u3, u2} ι A i a) (GradedMonoid.mk.{u3, u1} ι M j b)) (GradedMonoid.mk.{u3, u1} ι M (HAdd.hAdd.{u3, u3, u3} ι ι ι (instHAdd.{u3} ι _inst_1) i j) (GradedMonoid.GSmul.smul.{u3, u2, u1} ι A M _inst_1 _inst_2 i j a b))\nCase conversion may be inaccurate. Consider using '#align graded_monoid.mk_smul_mk GradedMonoid.mk_smul_mkₓ'. -/\ntheorem mk_smul_mk [Add ι] [GSmul A M] {i j} (a : A i) (b : M j) :\n    mk i a • mk j b = mk (i + j) (GSmul.smul a b) :=\n  rfl\n#align graded_monoid.mk_smul_mk GradedMonoid.mk_smul_mk\n\n#print GradedMonoid.GMulAction /-\n/-- A graded version of `mul_action`. -/\nclass GMulAction [AddMonoid ι] [GMonoid A] extends GSmul A M where\n  one_smul (b : GradedMonoid M) : (1 : GradedMonoid A) • b = b\n  mul_smul (a a' : GradedMonoid A) (b : GradedMonoid M) : (a * a') • b = a • a' • b\n#align graded_monoid.gmul_action GradedMonoid.GMulAction\n-/\n\n#print GradedMonoid.GMonoid.toGMulAction /-\n/-- The graded version of `monoid.to_mul_action`. -/\ninstance GMonoid.toGMulAction [AddMonoid ι] [GMonoid A] : GMulAction A A :=\n  { GMul.toGSmul _ with\n    one_smul := GMonoid.one_mul\n    mul_smul := GMonoid.mul_assoc }\n#align graded_monoid.gmonoid.to_gmul_action GradedMonoid.GMonoid.toGMulAction\n-/\n\n#print GradedMonoid.GMulAction.toMulAction /-\ninstance GMulAction.toMulAction [AddMonoid ι] [GMonoid A] [GMulAction A M] :\n    MulAction (GradedMonoid A) (GradedMonoid M)\n    where\n  one_smul := GMulAction.one_smul\n  mul_smul := GMulAction.mul_smul\n#align graded_monoid.gmul_action.to_mul_action GradedMonoid.GMulAction.toMulAction\n-/\n\nend Defs\n\nend GradedMonoid\n\n/-! ### Shorthands for creating instance of the above typeclasses for collections of subobjects -/\n\n\nsection Subobjects\n\nvariable {R : Type _}\n\n#print SetLike.GradedSmul /-\n/-- A version of `graded_monoid.ghas_smul` for internally graded objects. -/\nclass SetLike.GradedSmul {S R N M : Type _} [SetLike S R] [SetLike N M] [SMul R M] [Add ι]\n  (A : ι → S) (B : ι → N) : Prop where\n  smul_mem : ∀ ⦃i j : ι⦄ {ai bj}, ai ∈ A i → bj ∈ B j → ai • bj ∈ B (i + j)\n#align set_like.has_graded_smul SetLike.GradedSmul\n-/\n\n#print SetLike.toGSmul /-\ninstance SetLike.toGSmul {S R N M : Type _} [SetLike S R] [SetLike N M] [SMul R M] [Add ι]\n    (A : ι → S) (B : ι → N) [SetLike.GradedSmul A B] :\n    GradedMonoid.GSmul (fun i => A i) fun i => B i\n    where smul i j a b := ⟨(a : R) • b, SetLike.GradedSmul.smul_mem a.2 b.2⟩\n#align set_like.ghas_smul SetLike.toGSmul\n-/\n\n/- warning: set_like.coe_ghas_smul -> SetLike.coe_GSmul is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {S : Type.{u2}} {R : Type.{u3}} {N : Type.{u4}} {M : Type.{u5}} [_inst_1 : SetLike.{u2, u3} S R] [_inst_2 : SetLike.{u4, u5} N M] [_inst_3 : SMul.{u3, u5} R M] [_inst_4 : Add.{u1} ι] (A : ι -> S) (B : ι -> N) [_inst_5 : SetLike.GradedSmul.{u1, u2, u3, u4, u5} ι S R N M _inst_1 _inst_2 _inst_3 _inst_4 A B] {i : ι} {j : ι} (x : coeSort.{succ u2, succ (succ u3)} S Type.{u3} (SetLike.hasCoeToSort.{u2, u3} S R _inst_1) (A i)) (y : coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B j)), Eq.{succ u5} M ((fun (a : Type.{u5}) (b : Type.{u5}) [self : HasLiftT.{succ u5, succ u5} a b] => self.0) ((fun (i : ι) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} ι ι ι (instHAdd.{u1} ι _inst_4) i j)) M (HasLiftT.mk.{succ u5, succ u5} ((fun (i : ι) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} ι ι ι (instHAdd.{u1} ι _inst_4) i j)) M (CoeTCₓ.coe.{succ u5, succ u5} ((fun (i : ι) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} ι ι ι (instHAdd.{u1} ι _inst_4) i j)) M (coeBase.{succ u5, succ u5} ((fun (i : ι) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} ι ι ι (instHAdd.{u1} ι _inst_4) i j)) M (coeSubtype.{succ u5} M (fun (x : M) => Membership.Mem.{u5, u4} M N (SetLike.hasMem.{u4, u5} N M _inst_2) x (B (HAdd.hAdd.{u1, u1, u1} ι ι ι (instHAdd.{u1} ι _inst_4) i j))))))) (GradedMonoid.GSmul.smul.{u1, u3, u5} ι (fun (i : ι) => coeSort.{succ u2, succ (succ u3)} S Type.{u3} (SetLike.hasCoeToSort.{u2, u3} S R _inst_1) (A i)) (fun (i : ι) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) _inst_4 (SetLike.toGSmul.{u1, u2, u3, u4, u5} ι S R N M _inst_1 _inst_2 _inst_3 _inst_4 (fun (i : ι) => A i) (fun (i : ι) => B i) _inst_5) i j x y)) (SMul.smul.{u3, u5} R M _inst_3 ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (coeSort.{succ u2, succ (succ u3)} S Type.{u3} (SetLike.hasCoeToSort.{u2, u3} S R _inst_1) (A i)) R (HasLiftT.mk.{succ u3, succ u3} (coeSort.{succ u2, succ (succ u3)} S Type.{u3} (SetLike.hasCoeToSort.{u2, u3} S R _inst_1) (A i)) R (CoeTCₓ.coe.{succ u3, succ u3} (coeSort.{succ u2, succ (succ u3)} S Type.{u3} (SetLike.hasCoeToSort.{u2, u3} S R _inst_1) (A i)) R (coeBase.{succ u3, succ u3} (coeSort.{succ u2, succ (succ u3)} S Type.{u3} (SetLike.hasCoeToSort.{u2, u3} S R _inst_1) (A i)) R (coeSubtype.{succ u3} R (fun (x : R) => Membership.Mem.{u3, u2} R S (SetLike.hasMem.{u2, u3} S R _inst_1) x (A i)))))) x) ((fun (a : Type.{u5}) (b : Type.{u5}) [self : HasLiftT.{succ u5, succ u5} a b] => self.0) (coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B j)) M (HasLiftT.mk.{succ u5, succ u5} (coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B j)) M (CoeTCₓ.coe.{succ u5, succ u5} (coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B j)) M (coeBase.{succ u5, succ u5} (coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B j)) M (coeSubtype.{succ u5} M (fun (x : M) => Membership.Mem.{u5, u4} M N (SetLike.hasMem.{u4, u5} N M _inst_2) x (B j)))))) y))\nbut is expected to have type\n  forall {ι : Type.{u1}} {S : Type.{u5}} {R : Type.{u4}} {N : Type.{u3}} {M : Type.{u2}} [_inst_1 : SetLike.{u5, u4} S R] [_inst_2 : SetLike.{u3, u2} N M] [_inst_3 : SMul.{u4, u2} R M] [_inst_4 : Add.{u1} ι] (A : ι -> S) (B : ι -> N) [_inst_5 : SetLike.GradedSmul.{u1, u5, u4, u3, u2} ι S R N M _inst_1 _inst_2 _inst_3 _inst_4 A B] {i : ι} {j : ι} (x : Subtype.{succ u4} R (fun (x : R) => Membership.mem.{u4, u5} R S (SetLike.instMembership.{u5, u4} S R _inst_1) x (A i))) (y : Subtype.{succ u2} M (fun (x : M) => Membership.mem.{u2, u3} M N (SetLike.instMembership.{u3, u2} N M _inst_2) x (B j))), Eq.{succ u2} M (Subtype.val.{succ u2} M (fun (x : M) => Membership.mem.{u2, u2} M (Set.{u2} M) (Set.instMembershipSet.{u2} M) x (SetLike.coe.{u3, u2} N M _inst_2 (B (HAdd.hAdd.{u1, u1, u1} ι ι ι (instHAdd.{u1} ι _inst_4) i j)))) (GradedMonoid.GSmul.smul.{u1, u4, u2} ι (fun (i : ι) => Subtype.{succ u4} R (fun (x : R) => Membership.mem.{u4, u5} R S (SetLike.instMembership.{u5, u4} S R _inst_1) x (A i))) (fun (i : ι) => Subtype.{succ u2} M (fun (x : M) => Membership.mem.{u2, u3} M N (SetLike.instMembership.{u3, u2} N M _inst_2) x (B i))) _inst_4 (SetLike.toGSmul.{u1, u5, u4, u3, u2} ι S R N M _inst_1 _inst_2 _inst_3 _inst_4 (fun (i : ι) => A i) (fun (i : ι) => B i) _inst_5) i j x y)) (HSMul.hSMul.{u4, u2, u2} R M M (instHSMul.{u4, u2} R M _inst_3) (Subtype.val.{succ u4} R (fun (x : R) => Membership.mem.{u4, u5} R S (SetLike.instMembership.{u5, u4} S R _inst_1) x (A i)) x) (Subtype.val.{succ u2} M (fun (x : M) => Membership.mem.{u2, u3} M N (SetLike.instMembership.{u3, u2} N M _inst_2) x (B j)) y))\nCase conversion may be inaccurate. Consider using '#align set_like.coe_ghas_smul SetLike.coe_GSmulₓ'. -/\n@[simp]\ntheorem SetLike.coe_GSmul {S R N M : Type _} [SetLike S R] [SetLike N M] [SMul R M] [Add ι]\n    (A : ι → S) (B : ι → N) [SetLike.GradedSmul A B] {i j : ι} (x : A i) (y : B j) :\n    (@GradedMonoid.GSmul.smul ι (fun i => A i) (fun i => B i) _ _ i j x y : M) = (x : R) • y :=\n  rfl\n#align set_like.coe_ghas_smul SetLike.coe_GSmul\n\n/- warning: set_like.has_graded_mul.to_has_graded_smul -> SetLike.GradedMul.toGradedSmul is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : AddMonoid.{u1} ι] [_inst_2 : Monoid.{u2} R] {S : Type.{u3}} [_inst_3 : SetLike.{u3, u2} S R] (A : ι -> S) [_inst_4 : SetLike.GradedMonoid.{u1, u2, u3} ι R S _inst_3 _inst_2 _inst_1 A], SetLike.GradedSmul.{u1, u3, u2, u3, u2} ι S R S R _inst_3 _inst_3 (Mul.toSMul.{u2} R (MulOneClass.toHasMul.{u2} R (Monoid.toMulOneClass.{u2} R _inst_2))) (AddZeroClass.toHasAdd.{u1} ι (AddMonoid.toAddZeroClass.{u1} ι _inst_1)) A A\nbut is expected to have type\n  forall {ι : Type.{u1}} {R : Type.{u2}} [_inst_1 : AddMonoid.{u1} ι] [_inst_2 : Monoid.{u2} R] {S : Type.{u3}} [_inst_3 : SetLike.{u3, u2} S R] (A : ι -> S) [_inst_4 : SetLike.GradedMonoid.{u1, u2, u3} ι R S _inst_3 _inst_2 _inst_1 A], SetLike.GradedSmul.{u1, u3, u2, u3, u2} ι S R S R _inst_3 _inst_3 (MulAction.toSMul.{u2, u2} R R _inst_2 (Monoid.toMulAction.{u2} R _inst_2)) (AddZeroClass.toAdd.{u1} ι (AddMonoid.toAddZeroClass.{u1} ι _inst_1)) A A\nCase conversion may be inaccurate. Consider using '#align set_like.has_graded_mul.to_has_graded_smul SetLike.GradedMul.toGradedSmulₓ'. -/\n/-- Internally graded version of `has_mul.to_has_smul`. -/\ninstance SetLike.GradedMul.toGradedSmul [AddMonoid ι] [Monoid R] {S : Type _} [SetLike S R]\n    (A : ι → S) [SetLike.GradedMonoid A] : SetLike.GradedSmul A A\n    where smul_mem i j ai bj hi hj := SetLike.GradedMonoid.mul_mem hi hj\n#align set_like.has_graded_mul.to_has_graded_smul SetLike.GradedMul.toGradedSmul\n\nend Subobjects\n\nsection HomogeneousElements\n\nvariable {S R N M : Type _} [SetLike S R] [SetLike N M]\n\n/- warning: set_like.is_homogeneous.graded_smul -> SetLike.Homogeneous.graded_smul is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {S : Type.{u2}} {R : Type.{u3}} {N : Type.{u4}} {M : Type.{u5}} [_inst_1 : SetLike.{u2, u3} S R] [_inst_2 : SetLike.{u4, u5} N M] [_inst_3 : Add.{u1} ι] [_inst_4 : SMul.{u3, u5} R M] {A : ι -> S} {B : ι -> N} [_inst_5 : SetLike.GradedSmul.{u1, u2, u3, u4, u5} ι S R N M _inst_1 _inst_2 _inst_4 _inst_3 A B] {a : R} {b : M}, (SetLike.Homogeneous.{u1, u3, u2} ι R S _inst_1 A a) -> (SetLike.Homogeneous.{u1, u5, u4} ι M N _inst_2 B b) -> (SetLike.Homogeneous.{u1, u5, u4} ι M N _inst_2 B (SMul.smul.{u3, u5} R M _inst_4 a b))\nbut is expected to have type\n  forall {ι : Type.{u5}} {S : Type.{u2}} {R : Type.{u4}} {N : Type.{u1}} {M : Type.{u3}} [_inst_1 : SetLike.{u2, u4} S R] [_inst_2 : SetLike.{u1, u3} N M] [_inst_3 : Add.{u5} ι] [_inst_4 : SMul.{u4, u3} R M] {A : ι -> S} {B : ι -> N} [_inst_5 : SetLike.GradedSmul.{u5, u2, u4, u1, u3} ι S R N M _inst_1 _inst_2 _inst_4 _inst_3 A B] {a : R} {b : M}, (SetLike.Homogeneous.{u5, u4, u2} ι R S _inst_1 A a) -> (SetLike.Homogeneous.{u5, u3, u1} ι M N _inst_2 B b) -> (SetLike.Homogeneous.{u5, u3, u1} ι M N _inst_2 B (HSMul.hSMul.{u4, u3, u3} R M M (instHSMul.{u4, u3} R M _inst_4) a b))\nCase conversion may be inaccurate. Consider using '#align set_like.is_homogeneous.graded_smul SetLike.Homogeneous.graded_smulₓ'. -/\ntheorem SetLike.Homogeneous.graded_smul [Add ι] [SMul R M] {A : ι → S} {B : ι → N}\n    [SetLike.GradedSmul A B] {a : R} {b : M} :\n    SetLike.Homogeneous A a → SetLike.Homogeneous B b → SetLike.Homogeneous B (a • b)\n  | ⟨i, hi⟩, ⟨j, hj⟩ => ⟨i + j, SetLike.GradedSmul.smul_mem hi hj⟩\n#align set_like.is_homogeneous.graded_smul SetLike.Homogeneous.graded_smul\n\nend HomogeneousElements\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/GradedMulAction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.705785040214066, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.467175268257415}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.yoneda\nimport topology.sheaves.presheaf\nimport topology.category.TopCommRing\nimport topology.continuous_function.algebra\n\n/-!\n# Presheaves of functions\n\nWe construct some simple examples of presheaves of functions on a topological space.\n* `presheaf_to_Types X T`, where `T : X → Type`,\n  is the presheaf of dependently-typed (not-necessarily continuous) functions\n* `presheaf_to_Type X T`, where `T : Type`,\n  is the presheaf of (not-necessarily-continuous) functions to a fixed target type `T`\n* `presheaf_to_Top X T`, where `T : Top`,\n  is the presheaf of continuous functions into a topological space `T`\n* `presheaf_To_TopCommRing X R`, where `R : TopCommRing`\n  is the presheaf valued in `CommRing` of functions functions into a topological ring `R`\n* as an example of the previous construction,\n  `presheaf_to_TopCommRing X (TopCommRing.of ℂ)`\n  is the presheaf of rings of continuous complex-valued functions on `X`.\n-/\n\nuniverses v u\n\nopen category_theory\nopen topological_space\nopen opposite\n\nnamespace Top\n\nvariables (X : Top.{v})\n\n/--\nThe presheaf of dependently typed functions on `X`, with fibres given by a type family `T`.\nThere is no requirement that the functions are continuous, here.\n-/\ndef presheaf_to_Types (T : X → Type v) : X.presheaf (Type v) :=\n{ obj := λ U, Π x : (unop U), T x,\n  map := λ U V i g, λ (x : unop V), g (i.unop x) }\n\n@[simp] lemma presheaf_to_Types_obj\n  {T : X → Type v} {U : (opens X)ᵒᵖ} :\n  (presheaf_to_Types X T).obj U = Π x : (unop U), T x :=\nrfl\n\n@[simp] lemma presheaf_to_Types_map\n  {T : X → Type v} {U V : (opens X)ᵒᵖ} {i : U ⟶ V} {f} :\n  (presheaf_to_Types X T).map i f = λ x, f (i.unop x) :=\nrfl\n\n/--\nThe presheaf of functions on `X` with values in a type `T`.\nThere is no requirement that the functions are continuous, here.\n-/\n-- We don't just define this in terms of `presheaf_to_Types`,\n-- as it's helpful later to see (at a syntactic level) that `(presheaf_to_Type X T).obj U`\n-- is a non-dependent function.\n-- We don't use `@[simps]` to generate the projection lemmas here,\n-- as it turns out to be useful to have `presheaf_to_Type_map`\n-- written as an equality of functions (rather than being applied to some argument).\ndef presheaf_to_Type (T : Type v) : X.presheaf (Type v) :=\n{ obj := λ U, (unop U) → T,\n  map := λ U V i g, g ∘ i.unop }\n\n@[simp] lemma presheaf_to_Type_obj\n  {T : Type v} {U : (opens X)ᵒᵖ} :\n  (presheaf_to_Type X T).obj U = ((unop U) → T) :=\nrfl\n\n@[simp] lemma presheaf_to_Type_map\n  {T : Type v} {U V : (opens X)ᵒᵖ} {i : U ⟶ V} {f} :\n  (presheaf_to_Type X T).map i f = f ∘ i.unop :=\nrfl\n\n/-- The presheaf of continuous functions on `X` with values in fixed target topological space\n`T`. -/\ndef presheaf_to_Top (T : Top.{v}) : X.presheaf (Type v) :=\n(opens.to_Top X).op ⋙ (yoneda.obj T)\n\n@[simp] lemma presheaf_to_Top_obj (T : Top.{v}) (U : (opens X)ᵒᵖ) :\n  (presheaf_to_Top X T).obj U = ((opens.to_Top X).obj (unop U) ⟶ T) :=\nrfl\n\n/-- The (bundled) commutative ring of continuous functions from a topological space\nto a topological commutative ring, with pointwise multiplication. -/\n-- TODO upgrade the result to TopCommRing?\ndef continuous_functions (X : Top.{v}ᵒᵖ) (R : TopCommRing.{v}) : CommRing.{v} :=\nCommRing.of (unop X ⟶ (forget₂ TopCommRing Top).obj R)\n\nnamespace continuous_functions\n\n/-- Pulling back functions into a topological ring along a continuous map is a ring homomorphism. -/\ndef pullback {X Y : Topᵒᵖ} (f : X ⟶ Y) (R : TopCommRing) :\n  continuous_functions X R ⟶ continuous_functions Y R :=\n{ to_fun := λ g, f.unop ≫ g,\n  map_one' := rfl,\n  map_zero' := rfl,\n  map_add' := by tidy,\n  map_mul' := by tidy }\n\n/-- A homomorphism of topological rings can be postcomposed with functions from a source space `X`;\nthis is a ring homomorphism (with respect to the pointwise ring operations on functions). -/\ndef map (X : Top.{u}ᵒᵖ) {R S : TopCommRing.{u}} (φ : R ⟶ S) :\n  continuous_functions X R ⟶ continuous_functions X S :=\n{ to_fun := λ g, g ≫ ((forget₂ TopCommRing Top).map φ),\n  map_one' := by ext; exact φ.1.map_one,\n  map_zero' := by ext; exact φ.1.map_zero,\n  map_add' := by intros; ext; apply φ.1.map_add,\n  map_mul' := by intros; ext; apply φ.1.map_mul }\nend continuous_functions\n\n/-- An upgraded version of the Yoneda embedding, observing that the continuous maps\nfrom `X : Top` to `R : TopCommRing` form a commutative ring, functorial in both `X` and `R`. -/\ndef CommRing_yoneda : TopCommRing.{u} ⥤ (Top.{u}ᵒᵖ ⥤ CommRing.{u}) :=\n{ obj := λ R,\n  { obj := λ X, continuous_functions X R,\n    map := λ X Y f, continuous_functions.pullback f R },\n  map := λ R S φ,\n  { app := λ X, continuous_functions.map X φ } }\n\n/--\nThe presheaf (of commutative rings), consisting of functions on an open set `U ⊆ X` with\nvalues in some topological commutative ring `T`.\n\nFor example, we could construct the presheaf of continuous complex valued functions of `X` as\n```\npresheaf_to_TopCommRing X (TopCommRing.of ℂ)\n```\n(this requires `import topology.instances.complex`).\n-/\ndef presheaf_to_TopCommRing (T : TopCommRing.{v}) :\n  X.presheaf CommRing.{v} :=\n(opens.to_Top X).op ⋙ (CommRing_yoneda.obj T)\n\nend Top\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/topology/sheaves/presheaf_of_functions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.46717526477177573}}
{"text": "import Category.Init\n\n\n/-!\n# Category **Set**\n\n`CSet` is the **Set** category:\n- objects are all the sets, and\n- arrows are all the total functions between sets.\n-/\n\n\n\nnamespace Cat.CSet\n\n  structure All where\n    Elm : α\n    set : Set α\n\n  @[simp]\n  def All.mem (self : All) (elm : self.Elm) : Prop :=\n    elm ∈ self.set\n\n  --- `Membership` would be nice but the dependent nature of `All.mem` prevents it AFAICT.\n  infixr:60 \" ∋ \" => All.mem\n\n\n\n  structure Fn (s₁ s₂ : All) where\n    apply (a₁ : s₁.Elm) : s₁ ∋ a₁ → s₂.Elm\n    apply_post (a₁ : s₁.Elm) (legal₁ : s₁ ∋ a₁) :\n      s₂ ∋ apply a₁ legal₁\n\n  def Fn.compose\n    (g : Fn s₂ s₃)\n    (f : Fn s₁ s₂)\n    : Fn s₁ s₃\n  where\n    apply (a₁ : s₁.Elm) (legal₁ : s₁ ∋ a₁) :=\n      let a₂ := f.apply a₁ legal₁\n      let legal₂ := f.apply_post a₁ legal₁\n      g.apply a₂ legal₂\n    apply_post (a₁ : s₁.Elm) (legal₁ : s₁ ∋ a₁) :=\n      let a₂ := f.apply a₁ legal₁\n      let legal₂ := f.apply_post a₁ legal₁\n      g.apply_post a₂ legal₂\n\n  theorem Fn.compose_assoc\n    (h : Fn s₃ s₄)\n    (g : Fn s₂ s₃)\n    (f : Fn s₁ s₂)\n    : h.compose (g.compose f) = (h.compose g).compose f\n  :=\n    rfl\n\n\n\n  protected def Fn.id {s : outParam All} : Fn s s where\n    apply a _ := a\n    apply_post _ := id\n\n  theorem Fn.compose_id\n    (f : Fn s₁ s₂)\n    : f.compose Fn.id = f\n  :=\n    rfl\n\n  theorem Fn.id_compose\n    (f : Fn s₁ s₂)\n    : Fn.id.compose f = f\n  :=\n    rfl\n\nend Cat.CSet\n\ninstance Cat.CSet : Cat.Abstract CSet.All CSet.Fn where\n  compose :=\n    CSet.Fn.compose\n  compose_assoc :=\n    CSet.Fn.compose_assoc\n\n  id :=\n    @CSet.Fn.id\n  id_compose :=\n    CSet.Fn.id_compose\n  compose_id :=\n    CSet.Fn.compose_id\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/category/Category/CSet.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.705785040214066, "lm_q1q2_score": 0.46717526355039835}}
{"text": "import category_theory.colimit_lemmas\nimport homotopy_theory.formal.cylinder.hep\n\nimport .category\nimport .colimits\nimport .cylinder\nimport .homeomorphism\nimport .inter_union\nimport .smush\n\nnoncomputable theory\n\nopen set\n\nopen category_theory (hiding preimage_id)\nlocal notation f ` ∘ `:80 g:80 := g ≫ f\n\nnamespace homotopy_theory.topological_spaces\nopen homotopy_theory.topological_spaces.Top\nlocal notation `Top` := Top.{0}\n\nstructure pair :=\n(space : Top)\n(subset : set space)\n\nvariables (P Q R : pair)\n-- TODO: Is this too weird?\nlocal notation `X` := P.space\nlocal notation `A` := P.subset\nlocal notation `Y` := Q.space\nlocal notation `B` := Q.subset\nlocal notation `Z` := R.space\nlocal notation `C` := R.subset\n\n-- The subspace component of a pair, considered as a space.\ndef pair.subspace := Top.mk_ob A\n\nlocal notation `A'` := P.subspace\nlocal notation `B'` := Q.subspace\n\n-- The inclusion of the subspace, considered as a morphism of Top.\n@[reducible] def pair.incl : A' ⟶ X := incl A\n\nsection homeomorphism\n\ndef Top.homeomorphism.of_pairs (h : homeomorphism X Y) : Prop := A = h.hom ⁻¹' B\nstructure pair.homeomorphism :=\n(h : homeomorphism X Y)\n(is_of_pairs : h.of_pairs P Q)\n\nnotation P ` ≅ₚ ` Q := pair.homeomorphism P Q\n\nvariables {P Q R}\ninclude P Q\n\nlemma pair.homeomorphism.is_of_pairs' (h : P ≅ₚ Q) : A = h.h.equiv ⁻¹' B :=\nh.is_of_pairs\n\nlemma pair.homeomorphism.is_of_pairs.mk' (h : homeomorphism X Y)\n  (ha : ∀ a ∈ A, h.hom a ∈ B) (hb : ∀ b ∈ B, h.inv b ∈ A) : h.of_pairs P Q :=\nbegin\n  ext p, split, { exact ha p },\n  { intro hp, apply function.comp _ (hb (h.hom p)) hp,\n    change h.equiv.symm (h.equiv p) ∈ _ → p ∈ _,\n    simp }\nend\n\ndef pair.homeomorphism.on_subspaces (h : P ≅ₚ Q) : homeomorphism A' B' :=\nh.h.restrict h.is_of_pairs\n\nlemma is_closed_congr (h : P ≅ₚ Q) : is_closed A ↔ is_closed B :=\nby rw [h.is_of_pairs', h.h.is_closed_iff]; refl\n\n@[symm] def pair.homeomorphism.symm (h : P ≅ₚ Q) : Q ≅ₚ P :=\npair.homeomorphism.mk h.h.symm $\n  show B = h.h.equiv.symm ⁻¹' A, from\n  by rw [h.is_of_pairs', ←set.preimage_comp]; simp [preimage_id]\n\ninclude R\n\n@[trans] def pair.homeomorphism.trans (h₁ : P ≅ₚ Q) (h₂ : Q ≅ₚ R) : P ≅ₚ R :=\npair.homeomorphism.mk (h₁.h.trans h₂.h) $\n  show A = (function.comp h₂.h.equiv h₁.h.equiv) ⁻¹' C, from\n  by rw [set.preimage_comp, h₁.is_of_pairs', h₂.is_of_pairs']\n\nend homeomorphism\n\n@[reducible] def pair.empty (W : Top) : pair := pair.mk W ∅\n\nsection prod\n\ndef pair.prod : pair :=\npair.mk (Top.prod X Y) {p | p.1 ∈ A ∨ p.2 ∈ B}\n\nnotation P ` ⊗ `:35 Q:34 := pair.prod P Q\n\nvariables {P Q R}\ninclude P Q\n\nlemma pair.prod.is_closed (ha : is_closed A) (hb : is_closed B) :\n  is_closed (P ⊗ Q).subset :=\nis_closed_union\n   (continuous_iff_is_closed.mp continuous_fst _ ha)\n   (continuous_iff_is_closed.mp continuous_snd _ hb)\n\nlemma prod_comm_is_of_pairs : prod_comm.of_pairs (P ⊗ Q) (Q ⊗ P) :=\nby ext pq; cases pq; exact or.comm\n\ndef pair.prod_comm : P ⊗ Q ≅ₚ Q ⊗ P :=\npair.homeomorphism.mk prod_comm prod_comm_is_of_pairs\n\ninclude R\n\nlemma prod_assoc_is_of_pairs : prod_assoc.of_pairs ((P ⊗ Q) ⊗ R) (P ⊗ (Q ⊗ R)) :=\nby ext pqr; rcases pqr with ⟨⟨p, q⟩, r⟩; exact or.assoc\n\ndef pair.prod_assoc : (P ⊗ Q) ⊗ R ≅ₚ P ⊗ (Q ⊗ R) :=\npair.homeomorphism.mk prod_assoc prod_assoc_is_of_pairs\n\n-- Maybe we should have made `pair` a category and P ⊗ - a functor\ndef pair.prod.congr_right (h : Q ≅ₚ R) : P ⊗ Q ≅ₚ P ⊗ R :=\npair.homeomorphism.mk h.h.prod_congr_right\n  begin\n    ext pq, cases pq with p q,\n    change p ∈ A ∨ q ∈ B ↔ p ∈ A ∨ q ∈ h.h.equiv ⁻¹' C,\n    rw h.is_of_pairs'\n  end\n\nend prod\n\nsection pushout\n\n/-\n\nIf A and B are closed, then there is a pushout square\n\n  A × B → X × B\n    ↓       ↓\n  A × Y → (P ⊗ Q).subspace = A × Y ∪ X × B.\n\nNote that A × B here denotes the product of the (sub)spaces A and B,\nnot the subspace of X × Y on the product of the subsets A and B; and\nthe same for A × Y and X × B.\n\n-/\n\nvariables (ha : is_closed A) (hb : is_closed B)\n\n-- TODO: product bifunctor\nprotected def pair.i₀ : Top.prod A' B' ⟶ Top.prod A' Y :=\nTop.mk_hom (λ p, (p.1, p.2.val)) (by continuity!)\n\nprotected def pair.i₁ : Top.prod A' B' ⟶ Top.prod X B' :=\nTop.mk_hom (λ p, (p.1.val, p.2)) (by continuity!)\n\nprotected def pair.j₀ : Top.prod A' Y ⟶ (P ⊗ Q).subspace :=\nTop.mk_hom (λ p, ⟨(p.1.val, p.2), or.inl p.1.property⟩)\n  (by continuity!)\n\nprotected def pair.j₁ : Top.prod X B' ⟶ (P ⊗ Q).subspace :=\nTop.mk_hom (λ p, ⟨(p.1, p.2.val), or.inr p.2.property⟩)\n  (by continuity!)\n\nlocal notation `XY` := Top.prod X Y\n\n-- Establish an isomorphism to the intersection-union pushout square\n-- of subspaces of X × Y.\n\n-- The next few definitions are very slow to compile! Was it always this way?\n\nprotected def pair.k : homeomorphism (Top.prod A' B') (Top.mk_ob {p : XY | p.1 ∈ A ∧ p.2 ∈ B}) :=\n{ hom :=\n    Top.mk_hom\n      (λ p, ⟨(p.1.val, p.2.val), ⟨p.1.property, p.2.property⟩⟩)\n      (by continuity!),\n  inv :=\n    Top.mk_hom\n      (λ p, (⟨p.val.1, p.property.left⟩, ⟨p.val.2, p.property.right⟩))\n      (by continuity!),\n  hom_inv_id' := by ext p; rcases p with ⟨⟨a, ha⟩, ⟨b, hb⟩⟩; refl,\n  inv_hom_id' := by ext p; rcases p with ⟨⟨a, b⟩, ⟨ha, hb⟩⟩; refl }\n\nprotected def pair.l1 : homeomorphism (Top.prod A' Y) (Top.mk_ob {p : XY | p.1 ∈ A}) :=\n{ hom := Top.mk_hom (λ p, ⟨(p.1.val, p.2), p.1.property⟩) (by continuity!),\n  inv := Top.mk_hom (λ p, (⟨p.val.1, p.property⟩, p.val.2)) (by continuity!),\n  hom_inv_id' := by ext p; rcases p with ⟨⟨a, ha⟩, y⟩; refl,\n  inv_hom_id' := by ext p; rcases p with ⟨⟨a, y⟩, ha⟩; refl }\n\nprotected def pair.l2 : homeomorphism (Top.prod X B') (Top.mk_ob {p : XY | p.2 ∈ B}) :=\n{ hom := Top.mk_hom (λ p, ⟨(p.1, p.2.val), p.2.property⟩) (by continuity!),\n  inv := Top.mk_hom (λ p, (p.val.1, ⟨p.val.2, p.property⟩)) (by continuity!),\n  hom_inv_id' := by ext p; rcases p with ⟨x, ⟨b, hb⟩⟩; refl,\n  inv_hom_id' := by ext p; rcases p with ⟨⟨x, b⟩, hb⟩; refl }\n\nprotected def pair.po :\n  Is_pushout (pair.i₀ P Q) (pair.i₁ P Q) (pair.j₀ P Q) (pair.j₁ P Q) :=\nIs_pushout_of_isomorphic\n  (@Is_pushout_inter_union (Top.prod X Y) _ _\n    (continuous_iff_is_closed.mp continuous_fst _ ha)\n    (continuous_iff_is_closed.mp continuous_snd _ hb))\n  (pair.i₀ P Q) (pair.i₁ P Q)\n  (pair.k P Q) (pair.l1 P Q) (pair.l2 P Q) (by funext; refl) (by funext; refl)\n\nend pushout\n\nsection interval\n\ndef I_0 : pair := pair.mk I01 {0}\ninstance I_0.subspace.has_zero : has_zero I_0.subspace :=\n⟨⟨(0 : I01), mem_singleton _⟩⟩\n\ndef I_0.subspace.singleton : * ≃ I_0.subspace :=\n{ to_fun := λ _, 0,\n  inv_fun := λ _, punit.star,\n  left_inv := λ ⟨⟩, rfl,\n  right_inv := λ z, show 0 = z, from subtype.eq (mem_singleton_iff.mp z.property).symm }\n\nend interval\n\nsection cofibered\n\nopen homotopy_theory.cylinder\nlocal notation `i` := i.{0}\n\n-- A pair is cofibered if the inclusion of the subspace is a\n-- cofibration.\ndef pair.cofibered : Prop := hep 0 P.incl\n\nlemma pair.empty_cofibered (W : Top) : (pair.empty W).cofibered :=\nhave Is_initial_object.{0} (pair.empty W).subspace, from\n  Top.is_initial_object_of_to_empty _ (by intro p; rcases p with ⟨_,⟨⟩⟩),\nhep_initial_induced 0 this\n  (preserves_initial_object.Is_initial_object_of_Is_initial_object this)\n\ndef pair.admits_retract : Prop := ∃ r : X ⟶ A', r ∘ P.incl = 𝟙 A'\n\n-- A pair (X, A) is cofibered if and only if the inclusion map of the\n-- pair (X × I, A × I ∪ X × {0}) admits a retract.\n--\n-- This result holds even without the assumption that A is closed; see\n-- [Strøm, Note on Cofibrations II, Theorem 2]. However, a more\n-- intricate argument is then needed to show that A × I ∪ X × {0} is a\n-- pushout when (X, A) is cofibered.\nlemma pair.cofibered_iff (ha : is_closed A) :\n  P.cofibered ↔ (P ⊗ I_0).admits_retract :=\nhave po : _ := pair.po P I_0 ha (is_closed_singleton : is_closed (_ : set I01)),\nhave po' : _ :=\n  Is_pushout_of_isomorphic po\n    (i 0 @> P.subspace) P.incl\n    (prod_singleton I_0.subspace.singleton)\n    (homeomorphism.refl _)\n    (prod_singleton I_0.subspace.singleton)\n    (by ext; refl) (by ext; refl),\niff.trans (homotopy_theory.cylinder.hep_iff_pushout_retract 0 po'.transpose) $ begin\n  have : pair.incl (P ⊗ I_0) = po'.transpose.induced (i 0 @> X) (I &> pair.incl P) _, {\n    apply po'.uniqueness,\n    { rw [Is_pushout.induced_commutes₁], refl },\n    { rw [Is_pushout.induced_commutes₀], refl },\n  },\n  unfold pair.admits_retract, rw this, refl\nend\n\nvariables {P Q}\n-- TODO: Should these be ↔?\nlemma admits_retract_congr (h : P ≅ₚ Q) : P.admits_retract → Q.admits_retract :=\nassume ⟨r, hr⟩,\n⟨h.on_subspaces.hom ∘ r ∘ h.h.inv, calc\n  h.on_subspaces.hom ∘ r ∘ h.h.inv ∘ Q.incl\n    = h.on_subspaces.hom ∘ r ∘ h.h.inv ∘\n      (Q.incl ∘ h.on_subspaces.hom) ∘ h.on_subspaces.inv      : by simp\n... = h.on_subspaces.hom ∘ (r ∘ P.incl) ∘ h.on_subspaces.inv\n    : by simp [pair.homeomorphism.on_subspaces, homeomorphism.restriction_commutes]\n... = 𝟙 _  : by rw hr; simp⟩\n\nlemma cofibered_congr (h : P ≅ₚ Q) (ha : is_closed A) : P.cofibered → Q.cofibered :=\nhave P ⊗ I_0 ≅ₚ Q ⊗ I_0, from calc\n  P ⊗ I_0 ≅ₚ I_0 ⊗ P  : pair.prod_comm\n  ...     ≅ₚ I_0 ⊗ Q  : pair.prod.congr_right h -- TODO: congr_left\n  ...     ≅ₚ Q ⊗ I_0  : pair.prod_comm,\ncalc\n  P.cofibered\n    → (P ⊗ I_0).admits_retract  : (P.cofibered_iff ha).mp\n... → (Q ⊗ I_0).admits_retract  : admits_retract_congr this\n... → Q.cofibered               : (Q.cofibered_iff ((is_closed_congr h).mp ha)).mpr\n\nlemma prod_empty_admits_retract (K : Top) :\n  P.admits_retract → (P ⊗ pair.empty K).admits_retract :=\nassume ⟨r, hr⟩,\nlet r' : Top.prod X K ⟶ (P ⊗ pair.empty K).subspace :=\n  pair.j₀ P (pair.empty K) ∘ Top.prod_maps r (𝟙 K) in\nbegin\n  existsi r',\n  ext p; rcases p with ⟨⟨a, k⟩, h|⟨⟨⟩⟩⟩,\n  { change (r a).val = a,\n    exact congr_arg subtype.val (@@Top.hom_congr hr ⟨a, h⟩) },\n  { refl }\nend\n\n-- A condition for the product of closed pairs to be\n-- cofibered. Actually, P and Q only need to be cofibered (and only\n-- one of them needs to be closed); see [Strøm, Note on Cofibrations\n-- II, Theorem 6]. The argument is more intricate and the statement\n-- below will suffice for our purposes. We'll show that (Dⁿ, Sⁿ⁻¹)\n-- satisfies the hypothesis on Q.\nlemma prod_cofibered (ha : is_closed A) (hb : is_closed B)\n  (hq : Q ⊗ I_0 ≅ₚ pair.empty Y ⊗ I_0) :\n  P.cofibered → (P ⊗ Q).cofibered :=\nlet Q' := pair.empty Y in\nhave _ := calc\n  (P ⊗ I_0) ⊗ Q'\n    ≅ₚ P ⊗ (I_0 ⊗ Q')  : pair.prod_assoc\n... ≅ₚ P ⊗ (Q' ⊗ I_0)  : pair.prod.congr_right pair.prod_comm\n... ≅ₚ P ⊗ (Q ⊗ I_0)   : pair.prod.congr_right hq.symm\n... ≅ₚ (P ⊗ Q) ⊗ I_0   : pair.prod_assoc.symm,\ncalc\n  P.cofibered\n    → (P ⊗ I_0).admits_retract         : (pair.cofibered_iff P ha).mp\n... → ((P ⊗ I_0) ⊗ Q').admits_retract  : prod_empty_admits_retract _\n... → ((P ⊗ Q) ⊗ I_0).admits_retract   : admits_retract_congr this\n... → (P ⊗ Q).cofibered  : (pair.cofibered_iff _ (pair.prod.is_closed ha hb)).mpr\n\nsection smush\n\nvariables (V : Type) [topological_space V] [smush.admissible' V]\n\ndef unit_disk : Top :=\nTop.mk_ob (smush.unit_disk V)\n\ndef unit_disk_sphere : pair :=\npair.mk (unit_disk V) {v | smush.admissible.norm v.val = (1 : ℝ)}\n\nlemma unit_disk_sphere.is_closed : is_closed (unit_disk_sphere V).subset :=\nis_closed_eq (by continuity!) continuous_const\n\ndef smush : unit_disk_sphere V ⊗ I_0 ≅ₚ pair.empty (unit_disk V) ⊗ I_0 :=\npair.homeomorphism.mk\n  (homeomorphism.of_equiv (smush.H_equiv V)\n    (smush.continuous_H V) (smush.continuous_vHv V))\n  (begin\n    change {p : unit_disk V × I01 | _ ∨ p.2 ∈ ({0} : set I01)} =\n      (smush.H V) ⁻¹' {p : unit_disk V × I01 | p.1 ∈ ∅ ∨ p.2 ∈ ({0} : set I01)},\n    convert smush.Ht0 V;\n    { ext p, change _ ∨ _ ↔ _ ∨ _, apply or_congr (iff.refl _),\n      rw mem_singleton_iff, apply subtype.ext_iff },\n  end)\n\nlemma prod_disk_sphere_cofibered (ha : is_closed A) :\n  P.cofibered → (P ⊗ unit_disk_sphere V).cofibered :=\nprod_cofibered P _ ha (unit_disk_sphere.is_closed V) (smush V)\n\nend smush\n\ndef I_01 := pair.mk I01 {0, 1}\ndef I_01_is_D1_S0 : I_01 ≅ₚ unit_disk_sphere ℝ :=\npair.homeomorphism.mk\n  { hom :=\n      Top.mk_hom\n        (λ t, ⟨2 * t.val - 1, by cases t.property; erw abs_le; split; linarith⟩)\n        (by continuity!),\n    inv :=\n      Top.mk_hom\n        (λ t, by refine ⟨(1 / 2) * (t.val + 1), _, _⟩; cases abs_le.mp t.property; linarith)\n        (by continuity!),\n    hom_inv_id' := begin\n      ext t,\n      change (1 / 2) * ((2 * t.val - 1) + 1) = t.val,\n      ring\n    end,\n    inv_hom_id' := begin\n      ext t,\n      change 2 * ((1 / 2) * (t.val + 1)) - 1 = t.val,\n      ring\n    end }\n  begin\n    apply pair.homeomorphism.is_of_pairs.mk',\n    { intros a ha, change a ∈ {(0 : I01), (1 : I01)} at ha,\n      have ha' : a = (0 : I01) ∨ a = (1 : I01) := by simp at ha; exact ha,\n      cases ha' with ha' ha',\n      { subst ha', change abs (2 * (0 : ℝ) - 1) = 1, norm_num },\n      { subst ha', change abs (2 * (1 : ℝ) - 1) = 1, norm_num } },\n    { intros b hb, cases b with b hb', change abs b = 1 at hb,\n      rw abs_eq at hb, swap, exact zero_le_one,\n      cases hb with hb hb; change subtype.mk _ _ ∈ I_01.subset,\n      { subst hb, have : (1 : I01) ∈ ({0, 1} : set I01), by simp, convert this, norm_num },\n      { subst hb, have : (0 : I01) ∈ ({0, 1} : set I01), by simp, convert this, norm_num } }\n  end\n\nlemma I_01.is_closed : is_closed I_01.subset :=\n(is_closed_congr I_01_is_D1_S0).mpr (unit_disk_sphere.is_closed ℝ)\n\nlemma prod_I_01_cofibered (ha : is_closed A) :\n  P.cofibered → (P ⊗ I_01).cofibered :=\ncalc\n  P.cofibered\n    → (P ⊗ unit_disk_sphere ℝ).cofibered\n    : prod_disk_sphere_cofibered P ℝ ha\n... → (P ⊗ I_01).cofibered\n    : cofibered_congr (pair.prod.congr_right I_01_is_D1_S0.symm)\n        (pair.prod.is_closed ha (unit_disk_sphere.is_closed ℝ))\n\nend cofibered\n\nend homotopy_theory.topological_spaces\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/homotopy_theory/topological_spaces/pair.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4671752635503983}}
{"text": "import Lean.Meta \nimport Lean.Elab\nimport Mathlib.Algebra.Group.Defs\nimport Std\nimport Lean\nimport Experiments.ProdSeq\nimport Experiments.GeneralAbelianGroup\nopen Lean Meta Elab Nat Term Std ProdSeq ToExpr\n\ninstance (n: ℕ) : Inhabited (ℤ ^ n) := ⟨zeros n⟩\n\ndef ℤbasisElem (n : ℕ) (j : ℕ) : ℤ ^ n := ℤbasis n |>.get! j\n\ntheorem List.get!_of_get [Inhabited α] : (k : ℕ) → (l : List α) → (hk : k < l.length) → l.get! k = l.get ⟨k, hk⟩\n  | _, .nil, _ => by contradiction\n  | .zero, .cons _ _, _ => rfl\n  | .succ _, .cons _ _, _ => by rw [get!, get]; apply get!_of_get\n\n@[simp] theorem induced_free_map_at {A : Type _} [AddCommGroup A] {n : ℕ} (l : List A) (h : l.length = n) (k: ℕ) (hk : k < n) :\n (inducedFreeMap l h) (ℤbasisElem n k) = l.get ⟨k, h ▸ hk⟩ := by\n   rw [ℤbasisElem, List.get!_of_get, List.mapget (inducedFreeMap l h)]\n   apply List.get_index_eq; apply map_basis\n   · simp [h, hk]\n\n\nsection ToExpr\n\ninstance : ToExpr Int where\n  toExpr :=\n    fun\n      | Int.ofNat n => mkApp (mkConst ``Int.ofNat) $ toExpr n\n      | Int.negSucc n => mkApp (mkConst ``Int.negSucc) $ toExpr n\n  toTypeExpr := mkConst ``Int\n\ninstance prodToExpr {A B : Type _} [ToExpr A] [ToExpr B] : ToExpr (A × B) := inferInstance\n\ninstance : ToExpr Unit where\n  toExpr := fun | Unit.unit => mkConst ``Unit.unit\n  toTypeExpr := mkConst ``Unit\n\n@[instance] def powToExpr {A : Type _} [ToExpr A] : (n : ℕ) → ToExpr (A ^ n)\n  | .zero => inferInstanceAs (ToExpr Unit)\n  | .succ m => @prodToExpr _ _ inferInstance $ powToExpr m\n\ninstance {α : Type _} [ToExpr α] : ToExpr (List α) where\n  toExpr :=\n    let rec lstexpr : List α → Expr\n      | .nil => mkConst ``List.nil\n      | .cons h t => mkApp (mkApp (mkConst ``List.cons) $ toExpr h) $ lstexpr t\n    lstexpr\n  toTypeExpr := mkApp (mkConst ``List) $ toTypeExpr α\n\nend ToExpr\n\n\ndef zeroExpr : ℕ → TermElabM Expr\n| 0 => return mkConst ``Unit.unit\n| n + 1 => do mkAppM ``Prod.mk #[toExpr (0 : Int), ←  zeroExpr n]\n\ndef ℤbasisExpr : ℕ → ℕ → TermElabM Expr\n| 0, _ => return mkConst ``Unit.unit\n| n + 1, 0 => do mkAppM ``Prod.mk #[toExpr (1 : Int), ←  zeroExpr n]\n| n + 1, k + 1 => do mkAppM ``Prod.mk #[toExpr (1 : Int), ← ℤbasisExpr n k]\n\nelab \"ℤbasisElem#\"  n:term \"at\" j:term  : term => do\n      let nExp ← elabTerm n (some <| mkConst ``Nat)\n      let jExp ← elabTerm j (some <| mkConst ``Nat)\n      mkAppM ``ℤbasisElem #[nExp, jExp]\n\nelab \"ℤbasisExpr#\"  n:term \"at\" j:term  : term => do\n      let nExp ← elabTerm n (some <| mkConst ``Nat)\n      let jExp ← elabTerm j (some <| mkConst ``Nat)\n      let n ← exprNat nExp\n      let j ← exprNat jExp\n      ℤbasisExpr n j\n\n#eval ℤbasisElem# 3 at 1\n#eval ℤbasisExpr# 3 at 1\n\ndef ℤbasisArrM (n: ℕ): TermElabM (Array Expr) := do\n  let mut arr := #[]\n  for j in [0:n] do\n    arr := arr.push (← mkAppM ``ℤbasisElem #[toExpr n, toExpr j])\n  return arr\n\n-- def ℤbasisArrM (n: ℕ): TermElabM (Array Expr) := do\n--  return ℤbasis n |>.map toExpr |>.toArray\n\nelab \"arr#\"  n:term \"at\" j:term  : term => do\n      let nExp ← elabTerm n (some <| mkConst ``Nat)\n      let jExp ← elabTerm j (some <| mkConst ``Nat)\n      let n' ← exprNat nExp\n      let j' ← exprNat jExp\n      let arr ← ℤbasisArrM n'\n      return arr[j']\n\n#eval arr# 7 at 2\n\ndef toFreeM (e : Expr) : TermElabM Expr := do\n  let t ← addTreeM e\n  let (indTree, lst) ← AddTree.indexTreeM'' t\n  let arr ←  ℤbasisArrM (lst.length)\n  IndexAddTree.foldMapM indTree arr\n\nelab \"free#\" t:term : term => do\n  let e ← elabTerm t none\n  toFreeM e\n\ndef egFree {α : Type _}[AddCommGroup α][Repr α][DecidableEq α][Inhabited α]\n    (x y : α) := free# (x + y + x - y + x + y)\n\n#eval egFree (5 : ℤ) (2 : ℤ )\n\ndef provedLength{α : Type _}(l: List α) : PSigma (fun n : ℕ  => l.length = n) := PSigma.mk (l.length) rfl\n\n\n@[simp] def inducedFreeMap!{A: Type _}[AddCommGroup A](l: List A) :=\n    @inducedFreeMap A _ l.length l rfl\n\ninstance ind_hom! {A : Type _} [AddCommGroup A]  (l : List A)  : AddCommGroup.Homomorphism (inducedFreeMap! l) := FreeAbelianGroup.induced_hom A _\n\ndef viaFreeM (e: Expr) : TermElabM Expr := do\n  let t ← addTreeM e\n  let (indTree, lst) ← AddTree.indexTreeM'' t\n  let lstPackPair ←  listToExpr lst\n  let (lstPack, α) := lstPackPair\n  let pl ← mkAppM ``provedLength #[lstPack]\n  let n ← exprNat (← mkAppM ``PSigma.fst #[pl])\n  let pf ← mkAppM ``PSigma.snd #[pl]\n  let pf' ← mkAppOptM\n      ``Eq.trans #[none, none, none, toExpr n, pf, \n        ← mkAppM ``Eq.refl #[toExpr n]]\n  let n := List.length lst\n--  let pf ← mkAppM ``Eq.refl #[toExpr lst.length]\n  let arr ←  ℤbasisArrM n\n  let freeElem ← IndexAddTree.foldMapM indTree arr\n  let fromFree ← mkAppOptM \n      ``inducedFreeMap #[some α, none, some <| toExpr n, some lstPack, some (pf')]\n  mkAppM' fromFree #[freeElem]\n\nelab \"viafree#\" t:term : term => do\n  let e ← elabTerm t none\n  viaFreeM e\n\ndef egViaFree {α : Type}[AddCommGroup α][Repr α][DecidableEq α][Inhabited α]\n   (x y : α) := viafree# (x + y + x - y + x + y)\n\n#eval egViaFree (5 : ℤ) (2 : ℤ)\n\ntheorem egViaFreeEql{α : Type}[AddCommGroup α][Repr α][DecidableEq α][Inhabited α]\n    (x y z : α) : x + z - y + x - y + z =  viafree# (x + z - y + x - y + z)  := by\n       simp only [AddCommGroup.Homomorphism.neg_dist, AddCommGroup.add_distrib, induced_free_map_at, List.get]\n\n#print egViaFreeEql\n\ndef freeGroupEqM (e : Expr) : TermElabM Expr := do\n  let freeElemIm ← viaFreeM e\n  let eqn ← mkEq e freeElemIm\n  let mvar ← mkFreshExprMVar $ some eqn\n  let tac ← `(tactic| simp only [AddCommGroup.Homomorphism.neg_dist, AddCommGroup.add_distrib, induced_free_map_at, List.get])\n  let (goals, _) ← Elab.runTactic mvar.mvarId! tac\n  guard goals.isEmpty\n  match freeElemIm with\n    | .app ϕ freeElem _ =>\n      let freeElemR ← reduce freeElem -- the transparency here can be adjusted\n      let res ← mkFreshExprMVar $ some $ ← mkEq e (mkApp ϕ freeElemR)\n      assignExprMVar res.mvarId! mvar\n      return res\n    | _ => failure\n\nelab \"freeGroupEq#\" t:term : term => do\n  freeGroupEqM $ ← elabTerm t none\n\n#check (fun (x y z : ℤ) => freeGroupEq# x + x + y - x - y + z - x)\n\nexample {x y z : ℤ} : x + x + y - x - y + z - x = z := by\n    have p := freeGroupEq# (x + x + y - x - y + z - x)\n    rw [p, map_free_elem]\n    simp [List.sum]\n    rw [SubNegMonoid.gsmul_zero', zero_add, SubNegMonoid.gsmul_zero', zero_add, SubNegMonoid.gsmul_one]\n", "meta": {"author": "siddhartha-gadgil", "repo": "Polylean", "sha": "3b411dc1dca8c84ab221cc544d1ae3bd4f83de5a", "save_path": "github-repos/lean/siddhartha-gadgil-Polylean", "path": "github-repos/lean/siddhartha-gadgil-Polylean/Polylean-3b411dc1dca8c84ab221cc544d1ae3bd4f83de5a/Experiments/FreeAbelianMeta.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.4671752459437095}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport measure_theory.measure.null_measurable\nimport measure_theory.measurable_space\n\n/-!\n# Measure spaces\n\nThe definition of a measure and a measure space are in `measure_theory.measure_space_def`, with\nonly a few basic properties. This file provides many more properties of these objects.\nThis separation allows the measurability tactic to import only the file `measure_space_def`, and to\nbe available in `measure_space` (through `measurable_space`).\n\nGiven a measurable space `α`, a measure on `α` is a function that sends measurable sets to the\nextended nonnegative reals that satisfies the following conditions:\n1. `μ ∅ = 0`;\n2. `μ` is countably additive. This means that the measure of a countable union of pairwise disjoint\n   sets is equal to the measure of the individual sets.\n\nEvery measure can be canonically extended to an outer measure, so that it assigns values to\nall subsets, not just the measurable subsets. On the other hand, a measure that is countably\nadditive on measurable sets can be restricted to measurable sets to obtain a measure.\nIn this file a measure is defined to be an outer measure that is countably additive on\nmeasurable sets, with the additional assumption that the outer measure is the canonical\nextension of the restricted measure.\n\nMeasures on `α` form a complete lattice, and are closed under scalar multiplication with `ℝ≥0∞`.\n\nWe introduce the following typeclasses for measures:\n\n* `is_probability_measure μ`: `μ univ = 1`;\n* `is_finite_measure μ`: `μ univ < ∞`;\n* `sigma_finite μ`: there exists a countable collection of sets that cover `univ`\n  where `μ` is finite;\n* `is_locally_finite_measure μ` : `∀ x, ∃ s ∈ 𝓝 x, μ s < ∞`;\n* `has_no_atoms μ` : `∀ x, μ {x} = 0`; possibly should be redefined as\n  `∀ s, 0 < μ s → ∃ t ⊆ s, 0 < μ t ∧ μ t < μ s`.\n\nGiven a measure, the null sets are the sets where `μ s = 0`, where `μ` denotes the corresponding\nouter measure (so `s` might not be measurable). We can then define the completion of `μ` as the\nmeasure on the least `σ`-algebra that also contains all null sets, by defining the measure to be `0`\non the null sets.\n\n## Main statements\n\n* `completion` is the completion of a measure to all null measurable sets.\n* `measure.of_measurable` and `outer_measure.to_measure` are two important ways to define a measure.\n\n## Implementation notes\n\nGiven `μ : measure α`, `μ s` is the value of the *outer measure* applied to `s`.\nThis conveniently allows us to apply the measure to sets without proving that they are measurable.\nWe get countable subadditivity for all sets, but only countable additivity for measurable sets.\n\nYou often don't want to define a measure via its constructor.\nTwo ways that are sometimes more convenient:\n* `measure.of_measurable` is a way to define a measure by only giving its value on measurable sets\n  and proving the properties (1) and (2) mentioned above.\n* `outer_measure.to_measure` is a way of obtaining a measure from an outer measure by showing that\n  all measurable sets in the measurable space are Carathéodory measurable.\n\nTo prove that two measures are equal, there are multiple options:\n* `ext`: two measures are equal if they are equal on all measurable sets.\n* `ext_of_generate_from_of_Union`: two measures are equal if they are equal on a π-system generating\n  the measurable sets, if the π-system contains a spanning increasing sequence of sets where the\n  measures take finite value (in particular the measures are σ-finite). This is a special case of\n  the more general `ext_of_generate_from_of_cover`\n* `ext_of_generate_finite`: two finite measures are equal if they are equal on a π-system\n  generating the measurable sets. This is a special case of `ext_of_generate_from_of_Union` using\n  `C ∪ {univ}`, but is easier to work with.\n\nA `measure_space` is a class that is a measurable space with a canonical measure.\nThe measure is denoted `volume`.\n\n## References\n\n* <https://en.wikipedia.org/wiki/Measure_(mathematics)>\n* <https://en.wikipedia.org/wiki/Complete_measure>\n* <https://en.wikipedia.org/wiki/Almost_everywhere>\n\n## Tags\n\nmeasure, almost everywhere, measure space, completion, null set, null measurable set\n-/\n\nnoncomputable theory\n\nopen classical set filter (hiding map) function measurable_space\nopen_locale classical topological_space big_operators filter ennreal nnreal\n\nvariables {α β γ δ ι : Type*}\n\nnamespace measure_theory\n\nsection\n\nvariables {m : measurable_space α} {μ μ₁ μ₂ : measure α} {s s₁ s₂ t : set α}\n\ninstance ae_is_measurably_generated : is_measurably_generated μ.ae :=\n⟨λ s hs, let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs in\n  ⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩\n\nlemma measure_union (hd : disjoint s₁ s₂) (h₁ : measurable_set s₁) (h₂ : measurable_set s₂) :\n  μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=\nmeasure_union₀ h₁.null_measurable_set h₂.null_measurable_set hd\n\nlemma measure_add_measure_compl (h : measurable_set s) :\n  μ s + μ sᶜ = μ univ :=\nby { rw [← union_compl_self s, measure_union _ h h.compl], exact disjoint_compl_right }\n\nlemma measure_bUnion {s : set β} {f : β → set α} (hs : countable s)\n  (hd : s.pairwise (disjoint on f)) (h : ∀ b ∈ s, measurable_set (f b)) :\n  μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=\nbegin\n  haveI := hs.to_encodable,\n  rw bUnion_eq_Union,\n  exact measure_Union (hd.on_injective subtype.coe_injective $ λ x, x.2) (λ x, h x x.2)\nend\n\nlemma measure_sUnion {S : set (set α)} (hs : countable S)\n  (hd : S.pairwise disjoint) (h : ∀ s ∈ S, measurable_set s) :\n  μ (⋃₀ S) = ∑' s : S, μ s :=\nby rw [sUnion_eq_bUnion, measure_bUnion hs hd h]\n\nlemma measure_bUnion_finset {s : finset ι} {f : ι → set α} (hd : set.pairwise ↑s (disjoint on f))\n  (hm : ∀ b ∈ s, measurable_set (f b)) :\n  μ (⋃ b ∈ s, f b) = ∑ p in s, μ (f p) :=\nbegin\n  rw [← finset.sum_attach, finset.attach_eq_univ, ← tsum_fintype],\n  exact measure_bUnion s.countable_to_set hd hm\nend\n\n/-- If `s` is a countable set, then the measure of its preimage can be found as the sum of measures\nof the fibers `f ⁻¹' {y}`. -/\nlemma tsum_measure_preimage_singleton {s : set β} (hs : countable s) {f : α → β}\n  (hf : ∀ y ∈ s, measurable_set (f ⁻¹' {y})) :\n  ∑' b : s, μ (f ⁻¹' {↑b}) = μ (f ⁻¹' s) :=\nby rw [← set.bUnion_preimage_singleton, measure_bUnion hs (pairwise_disjoint_fiber _ _) hf]\n\n/-- If `s` is a `finset`, then the measure of its preimage can be found as the sum of measures\nof the fibers `f ⁻¹' {y}`. -/\nlemma sum_measure_preimage_singleton (s : finset β) {f : α → β}\n  (hf : ∀ y ∈ s, measurable_set (f ⁻¹' {y})) :\n  ∑ b in s, μ (f ⁻¹' {b}) = μ (f ⁻¹' ↑s) :=\nby simp only [← measure_bUnion_finset (pairwise_disjoint_fiber _ _) hf,\n  finset.set_bUnion_preimage_singleton]\n\nlemma measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \\ s₂) = μ s₁ :=\nmeasure_congr $ diff_ae_eq_self.2 h\n\nlemma measure_diff_null (h : μ s₂ = 0) : μ (s₁ \\ s₂) = μ s₁ :=\nmeasure_diff_null' $ measure_mono_null (inter_subset_right _ _) h\n\nlemma measure_diff (h : s₂ ⊆ s₁) (h₁ : measurable_set s₁) (h₂ : measurable_set s₂)\n  (h_fin : μ s₂ ≠ ∞) :\n  μ (s₁ \\ s₂) = μ s₁ - μ s₂ :=\nbegin\n  refine (ennreal.add_sub_self' h_fin).symm.trans _,\n  rw [← measure_union disjoint_diff h₂ (h₁.diff h₂), union_diff_cancel h]\nend\n\nlemma le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \\ s₂) :=\ntsub_le_iff_left.2 $\ncalc μ s₁ ≤ μ (s₂ ∪ s₁)        : measure_mono (subset_union_right _ _)\n      ... = μ (s₂ ∪ s₁ \\ s₂)   : congr_arg μ union_diff_self.symm\n      ... ≤ μ s₂ + μ (s₁ \\ s₂) : measure_union_le _ _\n\nlemma measure_diff_lt_of_lt_add (hs : measurable_set s) (ht : measurable_set t) (hst : s ⊆ t)\n  (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} (h : μ t < μ s + ε) : μ (t \\ s) < ε :=\nbegin\n  rw [measure_diff hst ht hs hs'], rw add_comm at h,\n  exact ennreal.sub_lt_of_lt_add (measure_mono hst) h\nend\n\nlemma measure_diff_le_iff_le_add (hs : measurable_set s) (ht : measurable_set t) (hst : s ⊆ t)\n  (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} : μ (t \\ s) ≤ ε ↔ μ t ≤ μ s + ε :=\nby rwa [measure_diff hst ht hs hs', tsub_le_iff_left]\n\nlemma measure_eq_measure_of_null_diff {s t : set α}\n  (hst : s ⊆ t) (h_nulldiff : μ (t.diff s) = 0) : μ s = μ t :=\nby { rw [←diff_diff_cancel_left hst, ←@measure_diff_null _ _ _ t _ h_nulldiff], refl, }\n\nlemma measure_eq_measure_of_between_null_diff {s₁ s₂ s₃ : set α}\n  (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \\ s₁) = 0) :\n  (μ s₁ = μ s₂) ∧ (μ s₂ = μ s₃) :=\nbegin\n  have le12 : μ s₁ ≤ μ s₂ := measure_mono h12,\n  have le23 : μ s₂ ≤ μ s₃ := measure_mono h23,\n  have key : μ s₃ ≤ μ s₁ := calc\n    μ s₃ = μ ((s₃ \\ s₁) ∪ s₁)  : by rw (diff_union_of_subset (h12.trans h23))\n     ... ≤ μ (s₃ \\ s₁) + μ s₁  : measure_union_le _ _\n     ... = μ s₁                : by simp only [h_nulldiff, zero_add],\n  exact ⟨le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)⟩,\nend\n\nlemma measure_eq_measure_smaller_of_between_null_diff {s₁ s₂ s₃ : set α}\n  (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃.diff s₁) = 0) : μ s₁ = μ s₂ :=\n(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1\n\nlemma measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : set α}\n  (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃.diff s₁) = 0) : μ s₂ = μ s₃ :=\n(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2\n\nlemma measure_compl (h₁ : measurable_set s) (h_fin : μ s ≠ ∞) : μ (sᶜ) = μ univ - μ s :=\nby { rw compl_eq_univ_diff, exact measure_diff (subset_univ s) measurable_set.univ h₁ h_fin }\n\nlemma sum_measure_le_measure_univ {s : finset ι} {t : ι → set α} (h : ∀ i ∈ s, measurable_set (t i))\n  (H : set.pairwise ↑s (disjoint on t)) :\n  ∑ i in s, μ (t i) ≤ μ (univ : set α) :=\nby { rw ← measure_bUnion_finset H h, exact measure_mono (subset_univ _) }\n\nlemma tsum_measure_le_measure_univ {s : ι → set α} (hs : ∀ i, measurable_set (s i))\n  (H : pairwise (disjoint on s)) :\n  ∑' i, μ (s i) ≤ μ (univ : set α) :=\nbegin\n  rw [ennreal.tsum_eq_supr_sum],\n  exact supr_le (λ s, sum_measure_le_measure_univ (λ i hi, hs i) (λ i hi j hj hij, H i j hij))\nend\n\n/-- If `sᵢ` is a countable family of measurable sets such that all pairwise intersections have\nmeasure `0`, then there exists a subordinate family `tᵢ ⊆ sᵢ` of measurable pairwise disjoint sets\nsuch that `tᵢ =ᵐ[μ] sᵢ`. -/\nlemma exists_subordinate_pairwise_disjoint [encodable ι] {s : ι → set α}\n  (h : ∀ i, measurable_set (s i)) (hd : pairwise (λ i j, μ (s i ∩ s j) = 0)) :\n  ∃ t : ι → set α, (∀ i, t i ⊆ s i) ∧ (∀ i, s i =ᵐ[μ] t i) ∧ (∀ i, measurable_set (t i)) ∧\n    pairwise (disjoint on t) :=\nbegin\n  set t : ι → set α := λ i, s i \\ ⋃ j ∈ ({i}ᶜ : set ι), s j,\n  refine ⟨t, λ i, diff_subset _ _, λ i, _, λ i, (h i).diff $\n    measurable_set.bUnion (countable_encodable _) $ λ j hj, h j, _⟩,\n  { refine eventually_le.antisymm _ (diff_subset _ _).eventually_le,\n    rw [ae_le_set, sdiff_sdiff_right_self, inf_eq_inter],\n    simp only [inter_Union, measure_bUnion_null_iff (countable_encodable _)],\n    exact λ j hj, hd _ _ (ne.symm hj) },\n  { rintros i j hne x ⟨⟨hsi, -⟩, -, Hj⟩,\n    exact Hj (mem_bUnion hne hsi) }\nend\n\nlemma measure_Union_of_null_inter [encodable ι] {f : ι → set α} (h : ∀ i, measurable_set (f i))\n  (hn : pairwise ((λ S T, μ (S ∩ T) = 0) on f)) : μ (⋃ i, f i) = ∑' i, μ (f i) :=\nbegin\n  rcases exists_subordinate_pairwise_disjoint h hn with ⟨t, ht_sub, ht_eq, htm, htd⟩,\n  calc μ (⋃ i, f i) = μ (⋃ i, t i)  : measure_congr (eventually_eq.countable_Union ht_eq)\n                ... = ∑' i, μ (t i) : measure_Union htd htm\n                ... = ∑' i, μ (f i) : tsum_congr (λ i, measure_congr (ht_eq i).symm)\nend\n\n/-- Pigeonhole principle for measure spaces: if `∑' i, μ (s i) > μ univ`, then\none of the intersections `s i ∩ s j` is not empty. -/\nlemma exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : measurable_space α} (μ : measure α)\n  {s : ι → set α} (hs : ∀ i, measurable_set (s i)) (H : μ (univ : set α) < ∑' i, μ (s i)) :\n  ∃ i j (h : i ≠ j), (s i ∩ s j).nonempty :=\nbegin\n  contrapose! H,\n  apply tsum_measure_le_measure_univ hs,\n  exact λ i j hij x hx, H i j hij ⟨x, hx⟩\nend\n\n/-- Pigeonhole principle for measure spaces: if `s` is a `finset` and\n`∑ i in s, μ (t i) > μ univ`, then one of the intersections `t i ∩ t j` is not empty. -/\nlemma exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : measurable_space α} (μ : measure α)\n  {s : finset ι} {t : ι → set α} (h : ∀ i ∈ s, measurable_set (t i))\n  (H : μ (univ : set α) < ∑ i in s, μ (t i)) :\n  ∃ (i ∈ s) (j ∈ s) (h : i ≠ j), (t i ∩ t j).nonempty :=\nbegin\n  contrapose! H,\n  apply sum_measure_le_measure_univ h,\n  exact λ i hi j hj hij x hx, H i hi j hj hij ⟨x, hx⟩\nend\n\n/-- Continuity from below: the measure of the union of a directed sequence of measurable sets\nis the supremum of the measures. -/\nlemma measure_Union_eq_supr [encodable ι] {s : ι → set α} (h : ∀ i, measurable_set (s i))\n  (hd : directed (⊆) s) : μ (⋃ i, s i) = ⨆ i, μ (s i) :=\nbegin\n  casesI is_empty_or_nonempty ι,\n  { simp only [supr_of_empty, Union], exact measure_empty },\n  refine le_antisymm _ (supr_le $ λ i, measure_mono $ subset_Union _ _),\n  have : ∀ n, measurable_set (disjointed (λ n, ⋃ b ∈ encodable.decode₂ ι n, s b) n) :=\n    measurable_set.disjointed (measurable_set.bUnion_decode₂ h),\n  have hn : pairwise (disjoint on\n    λ (n : ℕ), disjointed (λ (n : ℕ), ⋃ (b : ι) (H : b ∈ encodable.decode₂ ι n), s b) n) :=\n    disjoint_disjointed _,\n  rw [← encodable.Union_decode₂, ← Union_disjointed, measure_Union hn this,\n    ennreal.tsum_eq_supr_nat],\n  simp only [← measure_bUnion_finset (hn.set_pairwise _) (λ n _, this n)],\n  refine supr_le (λ n, _),\n  refine le_trans (_ : _ ≤ μ (⋃ (k ∈ finset.range n) (i ∈ encodable.decode₂ ι k), s i)) _,\n  exact measure_mono (bUnion_mono (λ k hk, disjointed_subset _ _)),\n  simp only [← finset.set_bUnion_option_to_finset, ← finset.set_bUnion_bUnion],\n  generalize : (finset.range n).bUnion (λ k, (encodable.decode₂ ι k).to_finset) = t,\n  rcases hd.finset_le t with ⟨i, hi⟩,\n  exact le_supr_of_le i (measure_mono $ bUnion_subset hi)\nend\n\nlemma measure_bUnion_eq_supr {s : ι → set α} {t : set ι} (ht : countable t)\n  (h : ∀ i ∈ t, measurable_set (s i)) (hd : directed_on ((⊆) on s) t) :\n  μ (⋃ i ∈ t, s i) = ⨆ i ∈ t, μ (s i) :=\nbegin\n  haveI := ht.to_encodable,\n  rw [bUnion_eq_Union, measure_Union_eq_supr (set_coe.forall'.1 h) hd.directed_coe,\n    supr_subtype'],\n  refl\nend\n\n/-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable\nsets is the infimum of the measures. -/\nlemma measure_Inter_eq_infi [encodable ι] {s : ι → set α}\n  (h : ∀ i, measurable_set (s i)) (hd : directed (⊇) s) (hfin : ∃ i, μ (s i) ≠ ∞) :\n  μ (⋂ i, s i) = (⨅ i, μ (s i)) :=\nbegin\n  rcases hfin with ⟨k, hk⟩,\n  have : ∀ t ⊆ s k, μ t ≠ ∞, from λ t ht, ne_top_of_le_ne_top hk (measure_mono ht),\n  rw [← ennreal.sub_sub_cancel (by exact hk) (infi_le _ k), ennreal.sub_infi,\n    ← ennreal.sub_sub_cancel (by exact hk) (measure_mono (Inter_subset _ k)),\n    ← measure_diff (Inter_subset _ k) (h k) (measurable_set.Inter h) (this _ (Inter_subset _ k)),\n    diff_Inter, measure_Union_eq_supr],\n  { congr' 1,\n    refine le_antisymm (supr_le_supr2 $ λ i, _) (supr_le_supr $ λ i, _),\n    { rcases hd i k with ⟨j, hji, hjk⟩,\n      use j,\n      rw [← measure_diff hjk (h _) (h _) (this _ hjk)],\n      exact measure_mono (diff_subset_diff_right hji) },\n    { rw [tsub_le_iff_right, ← measure_union disjoint_diff.symm ((h k).diff (h i)) (h i),\n        set.union_comm],\n      exact measure_mono (diff_subset_iff.1 $ subset.refl _) } },\n  { exact λ i, (h k).diff (h i) },\n  { exact hd.mono_comp _ (λ _ _, diff_subset_diff_right) }\nend\n\n/-- Continuity from below: the measure of the union of an increasing sequence of measurable sets\nis the limit of the measures. -/\nlemma tendsto_measure_Union [semilattice_sup ι] [encodable ι] {s : ι → set α}\n  (hs : ∀ n, measurable_set (s n)) (hm : monotone s) :\n  tendsto (μ ∘ s) at_top (𝓝 (μ (⋃ n, s n))) :=\nbegin\n  rw measure_Union_eq_supr hs (directed_of_sup hm),\n  exact tendsto_at_top_supr (assume n m hnm, measure_mono $ hm hnm)\nend\n\n/-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable\nsets is the limit of the measures. -/\nlemma tendsto_measure_Inter [encodable ι] [semilattice_sup ι] {s : ι → set α}\n  (hs : ∀ n, measurable_set (s n)) (hm : antitone s) (hf : ∃ i, μ (s i) ≠ ∞) :\n  tendsto (μ ∘ s) at_top (𝓝 (μ (⋂ n, s n))) :=\nbegin\n  rw measure_Inter_eq_infi hs (directed_of_sup hm) hf,\n  exact tendsto_at_top_infi (assume n m hnm, measure_mono $ hm hnm),\nend\n\n/-- One direction of the **Borel-Cantelli lemma**: if (sᵢ) is a sequence of sets such\nthat `∑ μ sᵢ` is finite, then the limit superior of the `sᵢ` is a null set. -/\nlemma measure_limsup_eq_zero {s : ℕ → set α} (hs : ∑' i, μ (s i) ≠ ∞) : μ (limsup at_top s) = 0 :=\nbegin\n  -- First we replace the sequence `sₙ` with a sequence of measurable sets `tₙ ⊇ sₙ` of the same\n  -- measure.\n  set t : ℕ → set α := λ n, to_measurable μ (s n),\n  have ht : ∑' i, μ (t i) ≠ ∞, by simpa only [t, measure_to_measurable] using hs,\n  suffices : μ (limsup at_top t) = 0,\n  { have A : s ≤ t := λ n, subset_to_measurable μ (s n),\n    -- TODO default args fail\n    exact measure_mono_null (limsup_le_limsup (eventually_of_forall (pi.le_def.mp A))\n      is_cobounded_le_of_bot is_bounded_le_of_top) this },\n  -- Next we unfold `limsup` for sets and replace equality with an inequality\n  simp only [limsup_eq_infi_supr_of_nat', set.infi_eq_Inter, set.supr_eq_Union,\n    ← nonpos_iff_eq_zero],\n  -- Finally, we estimate `μ (⋃ i, t (i + n))` by `∑ i', μ (t (i + n))`\n  refine le_of_tendsto_of_tendsto'\n    (tendsto_measure_Inter (λ i, measurable_set.Union (λ b, measurable_set_to_measurable _ _)) _\n      ⟨0, ne_top_of_le_ne_top ht (measure_Union_le t)⟩)\n    (ennreal.tendsto_sum_nat_add (μ ∘ t) ht) (λ n, measure_Union_le _),\n  intros n m hnm x,\n  simp only [set.mem_Union],\n  exact λ ⟨i, hi⟩, ⟨i + (m - n), by simpa only [add_assoc, tsub_add_cancel_of_le hnm] using hi⟩\nend\n\nlemma measure_if {x : β} {t : set β} {s : set α} :\n  μ (if x ∈ t then s else ∅) = indicator t (λ _, μ s) x :=\nby { split_ifs; simp [h] }\n\nend\n\nsection outer_measure\n\nvariables [ms : measurable_space α] {s t : set α}\ninclude ms\n\n/-- Obtain a measure by giving an outer measure where all sets in the σ-algebra are\n  Carathéodory measurable. -/\ndef outer_measure.to_measure (m : outer_measure α) (h : ms ≤ m.caratheodory) : measure α :=\nmeasure.of_measurable (λ s _, m s) m.empty\n  (λ f hf hd, m.Union_eq_of_caratheodory (λ i, h _ (hf i)) hd)\n\nlemma le_to_outer_measure_caratheodory (μ : measure α) : ms ≤ μ.to_outer_measure.caratheodory :=\nbegin\n  assume s hs,\n  rw to_outer_measure_eq_induced_outer_measure,\n  refine outer_measure.of_function_caratheodory (λ t, le_infi $ λ ht, _),\n  rw [← measure_eq_extend (ht.inter hs),\n    ← measure_eq_extend (ht.diff hs),\n    ← measure_union _ (ht.inter hs) (ht.diff hs),\n    inter_union_diff],\n  exact le_refl _,\n  exact λ x ⟨⟨_, h₁⟩, _, h₂⟩, h₂ h₁\nend\n\n@[simp] lemma to_measure_to_outer_measure (m : outer_measure α) (h : ms ≤ m.caratheodory) :\n  (m.to_measure h).to_outer_measure = m.trim := rfl\n\n@[simp] lemma to_measure_apply (m : outer_measure α) (h : ms ≤ m.caratheodory)\n  {s : set α} (hs : measurable_set s) : m.to_measure h s = m s :=\nm.trim_eq hs\n\nlemma le_to_measure_apply (m : outer_measure α) (h : ms ≤ m.caratheodory) (s : set α) :\n  m s ≤ m.to_measure h s :=\nm.le_trim s\n\nlemma to_measure_apply₀ (m : outer_measure α) (h : ms ≤ m.caratheodory)\n  {s : set α} (hs : null_measurable_set s (m.to_measure h)) : m.to_measure h s = m s :=\nbegin\n  refine le_antisymm _ (le_to_measure_apply _ _ _),\n  rcases hs.exists_measurable_subset_ae_eq with ⟨t, hts, htm, heq⟩,\n  calc m.to_measure h s = m.to_measure h t : measure_congr heq.symm\n                    ... = m t              : to_measure_apply m h htm\n                    ... ≤ m s              : m.mono hts\nend\n\n@[simp] lemma to_outer_measure_to_measure {μ : measure α} :\n  μ.to_outer_measure.to_measure (le_to_outer_measure_caratheodory _) = μ :=\nmeasure.ext $ λ s, μ.to_outer_measure.trim_eq\n\n@[simp] lemma bounded_by_measure (μ : measure α) :\n  outer_measure.bounded_by μ = μ.to_outer_measure :=\nμ.to_outer_measure.bounded_by_eq_self\n\nend outer_measure\n\nvariables {m0 : measurable_space α} [measurable_space β] [measurable_space γ]\nvariables {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : measure α} {s s' t : set α}\n\nlemma measure_inter_add_diff (s : set α) (ht : measurable_set t) :\n  μ (s ∩ t) + μ (s \\ t) = μ s :=\n(le_to_outer_measure_caratheodory μ _ ht _).symm\n\nlemma measure_union_add_inter (s : set α) (ht : measurable_set t) :\n  μ (s ∪ t) + μ (s ∩ t) = μ s + μ t :=\nby { rw [← measure_inter_add_diff (s ∪ t) ht, set.union_inter_cancel_right,\n  union_diff_right, ← measure_inter_add_diff s ht], ac_refl }\n\nlemma measure_union_add_inter' (hs : measurable_set s) (t : set α) :\n  μ (s ∪ t) + μ (s ∩ t) = μ s + μ t :=\nby rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm]\nnamespace measure\n\n/-- If `u` is a superset of `t` with the same measure (both sets possibly non-measurable), then\nfor any measurable set `s` one also has `μ (t ∩ s) = μ (u ∩ s)`. -/\nlemma measure_inter_eq_of_measure_eq {s t u : set α} (hs : measurable_set s)\n  (h : μ t = μ u) (htu : t ⊆ u) (ht_ne_top : μ t ≠ ∞) :\n  μ (t ∩ s) = μ (u ∩ s) :=\nbegin\n  rw h at ht_ne_top,\n  refine le_antisymm (measure_mono (inter_subset_inter_left _ htu)) _,\n  have A : μ (u ∩ s) + μ (u \\ s) ≤ μ (t ∩ s) + μ (u \\ s) := calc\n    μ (u ∩ s) + μ (u \\ s) = μ u : measure_inter_add_diff _ hs\n    ... = μ t : h.symm\n    ... = μ (t ∩ s) + μ (t \\ s) : (measure_inter_add_diff _ hs).symm\n    ... ≤ μ (t ∩ s) + μ (u \\ s) :\n      add_le_add le_rfl (measure_mono (diff_subset_diff htu subset.rfl)),\n  have B : μ (u \\ s) ≠ ∞ := (lt_of_le_of_lt (measure_mono (diff_subset _ _)) ht_ne_top.lt_top).ne,\n  exact ennreal.le_of_add_le_add_right B A\nend\n\nlemma measure_to_measurable_inter {s t : set α} (hs : measurable_set s) (ht : μ t ≠ ∞) :\n  μ (to_measurable μ t ∩ s) = μ (t ∩ s) :=\n(measure_inter_eq_of_measure_eq hs (measure_to_measurable t).symm\n  (subset_to_measurable μ t) ht).symm\n\n/-! ### The `ℝ≥0∞`-module of measures -/\n\ninstance [measurable_space α] : has_zero (measure α) :=\n⟨{ to_outer_measure := 0,\n   m_Union := λ f hf hd, tsum_zero.symm,\n   trimmed := outer_measure.trim_zero }⟩\n\n@[simp] theorem zero_to_outer_measure {m : measurable_space α} :\n  (0 : measure α).to_outer_measure = 0 := rfl\n\n@[simp, norm_cast] theorem coe_zero {m : measurable_space α} : ⇑(0 : measure α) = 0 := rfl\n\nlemma eq_zero_of_is_empty [is_empty α] {m : measurable_space α} (μ : measure α) : μ = 0 :=\next $ λ s hs, by simp only [eq_empty_of_is_empty s, measure_empty]\n\ninstance [measurable_space α] : inhabited (measure α) := ⟨0⟩\n\ninstance [measurable_space α] : has_add (measure α) :=\n⟨λ μ₁ μ₂,\n{ to_outer_measure := μ₁.to_outer_measure + μ₂.to_outer_measure,\n  m_Union := λ s hs hd,\n    show μ₁ (⋃ i, s i) + μ₂ (⋃ i, s i) = ∑' i, (μ₁ (s i) + μ₂ (s i)),\n    by rw [ennreal.tsum_add, measure_Union hd hs, measure_Union hd hs],\n  trimmed := by rw [outer_measure.trim_add, μ₁.trimmed, μ₂.trimmed] }⟩\n\n@[simp] theorem add_to_outer_measure {m : measurable_space α} (μ₁ μ₂ : measure α) :\n  (μ₁ + μ₂).to_outer_measure = μ₁.to_outer_measure + μ₂.to_outer_measure := rfl\n\n@[simp, norm_cast] theorem coe_add {m : measurable_space α} (μ₁ μ₂ : measure α) :\n  ⇑(μ₁ + μ₂) = μ₁ + μ₂ := rfl\n\ntheorem add_apply {m : measurable_space α} (μ₁ μ₂ : measure α) (s : set α) :\n  (μ₁ + μ₂) s = μ₁ s + μ₂ s := rfl\n\ninstance add_comm_monoid [measurable_space α] : add_comm_monoid (measure α) :=\nto_outer_measure_injective.add_comm_monoid to_outer_measure zero_to_outer_measure\n  add_to_outer_measure\n\ninstance [measurable_space α] : has_scalar ℝ≥0∞ (measure α) :=\n⟨λ c μ,\n  { to_outer_measure := c • μ.to_outer_measure,\n    m_Union := λ s hs hd, by simp [measure_Union, *, ennreal.tsum_mul_left],\n    trimmed := by rw [outer_measure.trim_smul, μ.trimmed] }⟩\n\n@[simp] theorem smul_to_outer_measure {m : measurable_space α} (c : ℝ≥0∞) (μ : measure α) :\n  (c • μ).to_outer_measure = c • μ.to_outer_measure :=\nrfl\n\n@[simp, norm_cast] theorem coe_smul {m : measurable_space α} (c : ℝ≥0∞) (μ : measure α) :\n  ⇑(c • μ) = c • μ :=\nrfl\n\n@[simp] theorem smul_apply {m : measurable_space α} (c : ℝ≥0∞) (μ : measure α) (s : set α) :\n  (c • μ) s = c * μ s :=\nrfl\n\ninstance [measurable_space α] : module ℝ≥0∞ (measure α) :=\ninjective.module ℝ≥0∞ ⟨to_outer_measure, zero_to_outer_measure, add_to_outer_measure⟩\n  to_outer_measure_injective smul_to_outer_measure\n\n@[simp, norm_cast] theorem coe_nnreal_smul {m : measurable_space α} (c : ℝ≥0) (μ : measure α) :\n  ⇑(c • μ) = c • μ :=\nrfl\n\n@[simp] theorem coe_nnreal_smul_apply {m : measurable_space α} (c : ℝ≥0) (μ : measure α)\n  (s : set α) :\n  (c • μ) s = c * μ s :=\nrfl\n\nlemma measure_eq_left_of_subset_of_measure_add_eq {s t : set α}\n  (h : (μ + ν) t ≠ ∞) (h' : s ⊆ t) (h'' : (μ + ν) s = (μ + ν) t) :\n  μ s = μ t :=\nbegin\n  refine le_antisymm (measure_mono h') _,\n  have : μ t + ν t ≤ μ s + ν t := calc\n    μ t + ν t = μ s + ν s : h''.symm\n    ... ≤ μ s + ν t : add_le_add le_rfl (measure_mono h'),\n  apply ennreal.le_of_add_le_add_right _ this,\n  simp only [not_or_distrib, ennreal.add_eq_top, pi.add_apply, ne.def, coe_add] at h,\n  exact h.2\nend\n\nlemma measure_eq_right_of_subset_of_measure_add_eq {s t : set α}\n  (h : (μ + ν) t ≠ ∞) (h' : s ⊆ t) (h'' : (μ + ν) s = (μ + ν) t) :\n  ν s = ν t :=\nbegin\n  rw add_comm at h'' h,\n  exact measure_eq_left_of_subset_of_measure_add_eq h h' h''\nend\n\nlemma measure_to_measurable_add_inter_left {s t : set α}\n  (hs : measurable_set s) (ht : (μ + ν) t ≠ ∞) :\n  μ (to_measurable (μ + ν) t ∩ s) = μ (t ∩ s) :=\nbegin\n  refine (measure_inter_eq_of_measure_eq hs _ (subset_to_measurable _ _) _).symm,\n  { refine measure_eq_left_of_subset_of_measure_add_eq _ (subset_to_measurable _ _)\n      (measure_to_measurable t).symm,\n    rwa measure_to_measurable t, },\n  { simp only [not_or_distrib, ennreal.add_eq_top, pi.add_apply, ne.def, coe_add] at ht,\n    exact ht.1 }\nend\n\nlemma measure_to_measurable_add_inter_right {s t : set α}\n  (hs : measurable_set s) (ht : (μ + ν) t ≠ ∞) :\n  ν (to_measurable (μ + ν) t ∩ s) = ν (t ∩ s) :=\nbegin\n  rw add_comm at ht ⊢,\n  exact measure_to_measurable_add_inter_left hs ht\nend\n\n/-! ### The complete lattice of measures -/\n\n/-- Measures are partially ordered.\n\nThe definition of less equal here is equivalent to the definition without the\nmeasurable set condition, and this is shown by `measure.le_iff'`. It is defined\nthis way since, to prove `μ ≤ ν`, we may simply `intros s hs` instead of rewriting followed\nby `intros s hs`. -/\ninstance [measurable_space α] : partial_order (measure α) :=\n{ le          := λ m₁ m₂, ∀ s, measurable_set s → m₁ s ≤ m₂ s,\n  le_refl     := assume m s hs, le_refl _,\n  le_trans    := assume m₁ m₂ m₃ h₁ h₂ s hs, le_trans (h₁ s hs) (h₂ s hs),\n  le_antisymm := assume m₁ m₂ h₁ h₂, ext $\n    assume s hs, le_antisymm (h₁ s hs) (h₂ s hs) }\n\ntheorem le_iff : μ₁ ≤ μ₂ ↔ ∀ s, measurable_set s → μ₁ s ≤ μ₂ s := iff.rfl\n\ntheorem to_outer_measure_le : μ₁.to_outer_measure ≤ μ₂.to_outer_measure ↔ μ₁ ≤ μ₂ :=\nby rw [← μ₂.trimmed, outer_measure.le_trim_iff]; refl\n\ntheorem le_iff' : μ₁ ≤ μ₂ ↔ ∀ s, μ₁ s ≤ μ₂ s :=\nto_outer_measure_le.symm\n\ntheorem lt_iff : μ < ν ↔ μ ≤ ν ∧ ∃ s, measurable_set s ∧ μ s < ν s :=\nlt_iff_le_not_le.trans $ and_congr iff.rfl $ by simp only [le_iff, not_forall, not_le, exists_prop]\n\ntheorem lt_iff' : μ < ν ↔ μ ≤ ν ∧ ∃ s, μ s < ν s :=\nlt_iff_le_not_le.trans $ and_congr iff.rfl $ by simp only [le_iff', not_forall, not_le]\n\ninstance covariant_add_le [measurable_space α] : covariant_class (measure α) (measure α) (+) (≤) :=\n⟨λ ν μ₁ μ₂ hμ s hs, add_le_add_left (hμ s hs) _⟩\n\nprotected lemma le_add_left (h : μ ≤ ν) : μ ≤ ν' + ν :=\nλ s hs, le_add_left (h s hs)\n\nprotected lemma le_add_right (h : μ ≤ ν) : μ ≤ ν + ν' :=\nλ s hs, le_add_right (h s hs)\n\nsection Inf\nvariables {m : set (measure α)}\n\nlemma Inf_caratheodory (s : set α) (hs : measurable_set s) :\n  (Inf (to_outer_measure '' m)).caratheodory.measurable_set' s :=\nbegin\n  rw [outer_measure.Inf_eq_bounded_by_Inf_gen],\n  refine outer_measure.bounded_by_caratheodory (λ t, _),\n  simp only [outer_measure.Inf_gen, le_infi_iff, ball_image_iff, coe_to_outer_measure,\n    measure_eq_infi t],\n  intros μ hμ u htu hu,\n  have hm : ∀ {s t}, s ⊆ t → outer_measure.Inf_gen (to_outer_measure '' m) s ≤ μ t,\n  { intros s t hst,\n    rw [outer_measure.Inf_gen_def],\n    refine infi_le_of_le (μ.to_outer_measure) (infi_le_of_le (mem_image_of_mem _ hμ) _),\n    rw [to_outer_measure_apply],\n    refine measure_mono hst },\n  rw [← measure_inter_add_diff u hs],\n  refine add_le_add (hm $ inter_subset_inter_left _ htu) (hm $ diff_subset_diff_left htu)\nend\n\ninstance [measurable_space α] : has_Inf (measure α) :=\n⟨λ m, (Inf (to_outer_measure '' m)).to_measure $ Inf_caratheodory⟩\n\nlemma Inf_apply (hs : measurable_set s) : Inf m s = Inf (to_outer_measure '' m) s :=\nto_measure_apply _ _ hs\n\nprivate lemma measure_Inf_le (h : μ ∈ m) : Inf m ≤ μ :=\nhave Inf (to_outer_measure '' m) ≤ μ.to_outer_measure := Inf_le (mem_image_of_mem _ h),\nassume s hs, by rw [Inf_apply hs, ← to_outer_measure_apply]; exact this s\n\nprivate lemma measure_le_Inf (h : ∀ μ' ∈ m, μ ≤ μ') : μ ≤ Inf m :=\nhave μ.to_outer_measure ≤ Inf (to_outer_measure '' m) :=\n  le_Inf $ ball_image_of_ball $ assume μ hμ, to_outer_measure_le.2 $ h _ hμ,\nassume s hs, by rw [Inf_apply hs, ← to_outer_measure_apply]; exact this s\n\ninstance [measurable_space α] : complete_semilattice_Inf (measure α) :=\n{ Inf_le := λ s a, measure_Inf_le,\n  le_Inf := λ s a, measure_le_Inf,\n  ..(by apply_instance : partial_order (measure α)),\n  ..(by apply_instance : has_Inf (measure α)), }\n\ninstance [measurable_space α] : complete_lattice (measure α) :=\n{ bot := 0,\n  bot_le := assume a s hs, by exact bot_le,\n/- Adding an explicit `top` makes `leanchecker` fail, see lean#364, disable for now\n\n  top := (⊤ : outer_measure α).to_measure (by rw [outer_measure.top_caratheodory]; exact le_top),\n  le_top := assume a s hs,\n    by cases s.eq_empty_or_nonempty with h  h;\n      simp [h, to_measure_apply ⊤ _ hs, outer_measure.top_apply],\n-/\n  .. complete_lattice_of_complete_semilattice_Inf (measure α) }\n\nend Inf\n\nprotected lemma zero_le {m0 : measurable_space α} (μ : measure α) : 0 ≤ μ := bot_le\n\nlemma nonpos_iff_eq_zero' : μ ≤ 0 ↔ μ = 0 :=\nμ.zero_le.le_iff_eq\n\n@[simp] lemma measure_univ_eq_zero : μ univ = 0 ↔ μ = 0 :=\n⟨λ h, bot_unique $ λ s hs, trans_rel_left (≤) (measure_mono (subset_univ s)) h, λ h, h.symm ▸ rfl⟩\n\n/-! ### Pushforward and pullback -/\n\n/-- Lift a linear map between `outer_measure` spaces such that for each measure `μ` every measurable\nset is caratheodory-measurable w.r.t. `f μ` to a linear map between `measure` spaces. -/\ndef lift_linear {m0 : measurable_space α} (f : outer_measure α →ₗ[ℝ≥0∞] outer_measure β)\n  (hf : ∀ μ : measure α, ‹_› ≤ (f μ.to_outer_measure).caratheodory) :\n  measure α →ₗ[ℝ≥0∞] measure β :=\n{ to_fun := λ μ, (f μ.to_outer_measure).to_measure (hf μ),\n  map_add' := λ μ₁ μ₂, ext $ λ s hs, by simp [hs],\n  map_smul' := λ c μ, ext $ λ s hs, by simp [hs] }\n\n@[simp] lemma lift_linear_apply {f : outer_measure α →ₗ[ℝ≥0∞] outer_measure β} (hf)\n  {s : set β} (hs : measurable_set s) : lift_linear f hf μ s = f μ.to_outer_measure s :=\nto_measure_apply _ _ hs\n\nlemma le_lift_linear_apply {f : outer_measure α →ₗ[ℝ≥0∞] outer_measure β} (hf) (s : set β) :\n  f μ.to_outer_measure s ≤ lift_linear f hf μ s :=\nle_to_measure_apply _ _ s\n\n/-- The pushforward of a measure. It is defined to be `0` if `f` is not a measurable function. -/\ndef map [measurable_space α] (f : α → β) : measure α →ₗ[ℝ≥0∞] measure β :=\nif hf : measurable f then\n  lift_linear (outer_measure.map f) $ λ μ s hs t,\n    le_to_outer_measure_caratheodory μ _ (hf hs) (f ⁻¹' t)\nelse 0\n\n/-- We can evaluate the pushforward on measurable sets. For non-measurable sets, see\n  `measure_theory.measure.le_map_apply` and `measurable_equiv.map_apply`. -/\n@[simp] theorem map_apply {f : α → β} (hf : measurable f) {s : set β} (hs : measurable_set s) :\n  map f μ s = μ (f ⁻¹' s) :=\nby simp [map, dif_pos hf, hs]\n\nlemma map_to_outer_measure {f : α → β} (hf : measurable f) :\n  (map f μ).to_outer_measure = (outer_measure.map f μ.to_outer_measure).trim :=\nbegin\n  rw [← trimmed, outer_measure.trim_eq_trim_iff],\n  intros s hs,\n  rw [coe_to_outer_measure, map_apply hf hs, outer_measure.map_apply, coe_to_outer_measure]\nend\n\ntheorem map_of_not_measurable {f : α → β} (hf : ¬measurable f) :\n  map f μ = 0 :=\nby rw [map, dif_neg hf, linear_map.zero_apply]\n\n@[simp] lemma map_id : map id μ = μ :=\next $ λ s, map_apply measurable_id\n\nlemma map_map {g : β → γ} {f : α → β} (hg : measurable g) (hf : measurable f) :\n  map g (map f μ) = map (g ∘ f) μ :=\next $ λ s hs,\nby simp [hf, hg, hs, hg hs, hg.comp hf, ← preimage_comp]\n\n@[mono] lemma map_mono (f : α → β) (h : μ ≤ ν) : map f μ ≤ map f ν :=\nif hf : measurable f then λ s hs, by simp only [map_apply hf hs, h _ (hf hs)]\nelse by simp only [map_of_not_measurable hf, le_rfl]\n\n/-- Even if `s` is not measurable, we can bound `map f μ s` from below.\n  See also `measurable_equiv.map_apply`. -/\ntheorem le_map_apply {f : α → β} (hf : measurable f) (s : set β) : μ (f ⁻¹' s) ≤ map f μ s :=\ncalc μ (f ⁻¹' s) ≤ μ (f ⁻¹' (to_measurable (map f μ) s)) :\n  measure_mono $ preimage_mono $ subset_to_measurable _ _\n... = map f μ (to_measurable (map f μ) s) : (map_apply hf $ measurable_set_to_measurable _ _).symm\n... = map f μ s : measure_to_measurable _\n\n/-- Even if `s` is not measurable, `map f μ s = 0` implies that `μ (f ⁻¹' s) = 0`. -/\nlemma preimage_null_of_map_null {f : α → β} (hf : measurable f) {s : set β}\n  (hs : map f μ s = 0) : μ (f ⁻¹' s) = 0 :=\nnonpos_iff_eq_zero.mp $ (le_map_apply hf s).trans_eq hs\n\nlemma tendsto_ae_map {f : α → β} (hf : measurable f) : tendsto f μ.ae (map f μ).ae :=\nλ s hs, preimage_null_of_map_null hf hs\n\n/-- Pullback of a `measure`. If `f` sends each `measurable` set to a `measurable` set, then for each\nmeasurable set `s` we have `comap f μ s = μ (f '' s)`. -/\ndef comap [measurable_space α] (f : α → β) : measure β →ₗ[ℝ≥0∞] measure α :=\nif hf : injective f ∧ ∀ s, measurable_set s → measurable_set (f '' s) then\n  lift_linear (outer_measure.comap f) $ λ μ s hs t,\n  begin\n    simp only [coe_to_outer_measure, outer_measure.comap_apply, ← image_inter hf.1,\n      image_diff hf.1],\n    apply le_to_outer_measure_caratheodory,\n    exact hf.2 s hs\n  end\nelse 0\n\nlemma comap_apply {β} [measurable_space α] {mβ : measurable_space β} (f : α → β) (hfi : injective f)\n  (hf : ∀ s, measurable_set s → measurable_set (f '' s)) (μ : measure β) (hs : measurable_set s) :\n  comap f μ s = μ (f '' s) :=\nbegin\n  rw [comap, dif_pos, lift_linear_apply _ hs, outer_measure.comap_apply, coe_to_outer_measure],\n  exact ⟨hfi, hf⟩\nend\n\n/-! ### Restricting a measure -/\n\n/-- Restrict a measure `μ` to a set `s` as an `ℝ≥0∞`-linear map. -/\ndef restrictₗ {m0 : measurable_space α} (s : set α) : measure α →ₗ[ℝ≥0∞] measure α :=\nlift_linear (outer_measure.restrict s) $ λ μ s' hs' t,\nbegin\n  suffices : μ (s ∩ t) = μ (s ∩ t ∩ s') + μ (s ∩ t \\ s'),\n  { simpa [← set.inter_assoc, set.inter_comm _ s, ← inter_diff_assoc] },\n  exact le_to_outer_measure_caratheodory _ _ hs' _,\nend\n\n/-- Restrict a measure `μ` to a set `s`. -/\ndef restrict {m0 : measurable_space α} (μ : measure α) (s : set α) : measure α := restrictₗ s μ\n\n@[simp] lemma restrictₗ_apply {m0 : measurable_space α} (s : set α) (μ : measure α) :\n  restrictₗ s μ = μ.restrict s :=\nrfl\n\n/-- This lemma shows that `restrict` and `to_outer_measure` commute. Note that the LHS has a\nrestrict on measures and the RHS has a restrict on outer measures. -/\nlemma restrict_to_outer_measure_eq_to_outer_measure_restrict (h : measurable_set s) :\n    (μ.restrict s).to_outer_measure = outer_measure.restrict s μ.to_outer_measure :=\nby simp_rw [restrict, restrictₗ, lift_linear, linear_map.coe_mk, to_measure_to_outer_measure,\n  outer_measure.restrict_trim h, μ.trimmed]\n\nlemma restrict_apply₀ (ht : null_measurable_set t (μ.restrict s)) :\n  μ.restrict s t = μ (t ∩ s) :=\n(to_measure_apply₀ _ _ ht).trans $ by simp only [coe_to_outer_measure, outer_measure.restrict_apply]\n\n/-- If `t` is a measurable set, then the measure of `t` with respect to the restriction of\n  the measure to `s` equals the outer measure of `t ∩ s`. An alternate version requiring that `s`\n  be measurable instead of `t` exists as `measure.restrict_apply'`. -/\n@[simp] lemma restrict_apply (ht : measurable_set t) : μ.restrict s t = μ (t ∩ s) :=\nrestrict_apply₀ ht.null_measurable_set\n\n/-- If `s` is a measurable set, then the outer measure of `t` with respect to the restriction of\nthe measure to `s` equals the outer measure of `t ∩ s`. This is an alternate version of\n`measure.restrict_apply`, requiring that `s` is measurable instead of `t`. -/\n@[simp] lemma restrict_apply' (hs : measurable_set s) : μ.restrict s t = μ (t ∩ s) :=\nby rw [← coe_to_outer_measure, measure.restrict_to_outer_measure_eq_to_outer_measure_restrict hs,\n      outer_measure.restrict_apply s t _, coe_to_outer_measure]\n\nlemma restrict_eq_self' (hs : measurable_set s) (t_subset : t ⊆ s) :\n  μ.restrict s t = μ t :=\nby rw [restrict_apply' hs, set.inter_eq_self_of_subset_left t_subset]\n\nlemma restrict_eq_self (h_meas_t : measurable_set t) (h : t ⊆ s) : μ.restrict s t = μ t :=\nby rw [restrict_apply h_meas_t, inter_eq_left_iff_subset.mpr h]\n\nlemma restrict_apply_self {m0 : measurable_space α} (μ : measure α) (h_meas_s : measurable_set s) :\n  (μ.restrict s) s = μ s := (restrict_eq_self h_meas_s (set.subset.refl _))\n\nlemma restrict_apply_univ (s : set α) : μ.restrict s univ = μ s :=\nby rw [restrict_apply measurable_set.univ, set.univ_inter]\n\nlemma le_restrict_apply (s t : set α) :\n  μ (t ∩ s) ≤ μ.restrict s t :=\nby { rw [restrict, restrictₗ], convert le_lift_linear_apply _ t, simp }\n\n@[simp] lemma restrict_add {m0 : measurable_space α} (μ ν : measure α) (s : set α) :\n  (μ + ν).restrict s = μ.restrict s + ν.restrict s :=\n(restrictₗ s).map_add μ ν\n\n@[simp] lemma restrict_zero {m0 : measurable_space α} (s : set α) :\n  (0 : measure α).restrict s = 0 :=\n(restrictₗ s).map_zero\n\n@[simp] lemma restrict_smul {m0 : measurable_space α} (c : ℝ≥0∞) (μ : measure α) (s : set α) :\n  (c • μ).restrict s = c • μ.restrict s :=\n(restrictₗ s).map_smul c μ\n\n@[simp] lemma restrict_restrict (hs : measurable_set s) :\n  (μ.restrict t).restrict s = μ.restrict (s ∩ t) :=\next $ λ u hu, by simp [*, set.inter_assoc]\n\nlemma restrict_comm (hs : measurable_set s) (ht : measurable_set t) :\n  (μ.restrict t).restrict s = (μ.restrict s).restrict t :=\nby rw [restrict_restrict hs, restrict_restrict ht, inter_comm]\n\nlemma restrict_apply_eq_zero (ht : measurable_set t) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 :=\nby rw [restrict_apply ht]\n\nlemma measure_inter_eq_zero_of_restrict (h : μ.restrict s t = 0) : μ (t ∩ s) = 0 :=\nnonpos_iff_eq_zero.1 (h ▸ le_restrict_apply _ _)\n\nlemma restrict_apply_eq_zero' (hs : measurable_set s) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 :=\nby rw [restrict_apply' hs]\n\n@[simp] lemma restrict_eq_zero : μ.restrict s = 0 ↔ μ s = 0 :=\nby rw [← measure_univ_eq_zero, restrict_apply_univ]\n\nlemma restrict_zero_set {s : set α} (h : μ s = 0) :\n  μ.restrict s = 0 :=\nby simp only [measure.restrict_eq_zero, h]\n\n@[simp] lemma restrict_empty : μ.restrict ∅ = 0 := restrict_zero_set measure_empty\n\n@[simp] lemma restrict_univ : μ.restrict univ = μ := ext $ λ s hs, by simp [hs]\n\nlemma restrict_union_apply (h : disjoint (t ∩ s) (t ∩ s')) (hs : measurable_set s)\n  (hs' : measurable_set s') (ht : measurable_set t) :\n  μ.restrict (s ∪ s') t = μ.restrict s t + μ.restrict s' t :=\nbegin\n  simp only [restrict_apply, ht, set.inter_union_distrib_left],\n  exact measure_union h (ht.inter hs) (ht.inter hs'),\nend\n\nlemma restrict_union (h : disjoint s t) (hs : measurable_set s) (ht : measurable_set t) :\n  μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t :=\next $ λ t' ht', restrict_union_apply (h.mono inf_le_right inf_le_right) hs ht ht'\n\nlemma restrict_union_add_inter (s : set α) (ht : measurable_set t) :\n  μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t :=\nbegin\n  ext1 u hu,\n  simp only [add_apply, restrict_apply hu, inter_union_distrib_left],\n  convert measure_union_add_inter (u ∩ s) (hu.inter ht) using 3,\n  rw [set.inter_left_comm (u ∩ s), set.inter_assoc, ← set.inter_assoc u u, set.inter_self]\nend\n\n@[simp] lemma restrict_add_restrict_compl (hs : measurable_set s) :\n  μ.restrict s + μ.restrict sᶜ = μ :=\nby rw [← restrict_union (@disjoint_compl_right (set α) _ _) hs hs.compl,\n    union_compl_self, restrict_univ]\n\n@[simp] lemma restrict_compl_add_restrict (hs : measurable_set s) :\n  μ.restrict sᶜ + μ.restrict s = μ :=\nby rw [add_comm, restrict_add_restrict_compl hs]\n\nlemma restrict_union_le (s s' : set α) : μ.restrict (s ∪ s') ≤ μ.restrict s + μ.restrict s' :=\nbegin\n  intros t ht,\n  suffices : μ (t ∩ s ∪ t ∩ s') ≤ μ (t ∩ s) + μ (t ∩ s'),\n    by simpa [ht, inter_union_distrib_left],\n  apply measure_union_le\nend\n\nlemma restrict_Union_apply_ae [encodable ι] {s : ι → set α}\n  (hd : pairwise (λ i j, μ (s i ∩ s j) = 0))\n  (hm : ∀ i, measurable_set (s i)) {t : set α} (ht : measurable_set t) :\n  μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t :=\nbegin\n  simp only [restrict_apply, ht, inter_Union],\n  exact measure_Union_of_null_inter (λ i, ht.inter (hm _)) (λ i j hne, measure_mono_null\n    (inter_subset_inter (inter_subset_right _ _) (inter_subset_right _ _)) (hd i j hne))\nend\n\nlemma restrict_Union_apply [encodable ι] {s : ι → set α} (hd : pairwise (disjoint on s))\n  (hm : ∀ i, measurable_set (s i)) {t : set α} (ht : measurable_set t) :\n  μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t :=\nrestrict_Union_apply_ae (λ i j hij, by simp [set.disjoint_iff_inter_eq_empty.1 (hd i j hij)]) hm ht\n\nlemma restrict_Union_apply_eq_supr [encodable ι] {s : ι → set α}\n  (hm : ∀ i, measurable_set (s i)) (hd : directed (⊆) s) {t : set α} (ht : measurable_set t) :\n  μ.restrict (⋃ i, s i) t = ⨆ i, μ.restrict (s i) t :=\nbegin\n  simp only [restrict_apply ht, inter_Union],\n  rw [measure_Union_eq_supr],\n  exacts [λ i, ht.inter (hm i), hd.mono_comp _ (λ s₁ s₂, inter_subset_inter_right _)]\nend\n\nlemma restrict_map {f : α → β} (hf : measurable f) {s : set β} (hs : measurable_set s) :\n  (map f μ).restrict s = map f (μ.restrict $ f ⁻¹' s) :=\next $ λ t ht, by simp [*, hf ht]\n\n/-- Restriction of a measure to a subset is monotone both in set and in measure. -/\nlemma restrict_mono' {m0 : measurable_space α} ⦃s s' : set α⦄ ⦃μ ν : measure α⦄\n  (hs : s ≤ᵐ[μ] s') (hμν : μ ≤ ν) :\n  μ.restrict s ≤ ν.restrict s' :=\nassume t ht,\ncalc μ.restrict s t = μ (t ∩ s) : restrict_apply ht\n... ≤ μ (t ∩ s') : measure_mono_ae $ hs.mono $ λ x hx ⟨hxt, hxs⟩, ⟨hxt, hx hxs⟩\n... ≤ ν (t ∩ s') : le_iff'.1 hμν (t ∩ s')\n... = ν.restrict s' t : (restrict_apply ht).symm\n\n/-- Restriction of a measure to a subset is monotone both in set and in measure. -/\n@[mono] lemma restrict_mono {m0 : measurable_space α} ⦃s s' : set α⦄ (hs : s ⊆ s') ⦃μ ν : measure α⦄\n  (hμν : μ ≤ ν) :\n  μ.restrict s ≤ ν.restrict s' :=\nrestrict_mono' (ae_of_all _ hs) hμν\n\nlemma restrict_le_self : μ.restrict s ≤ μ :=\nassume t ht,\ncalc μ.restrict s t = μ (t ∩ s) : restrict_apply ht\n... ≤ μ t : measure_mono $ inter_subset_left t s\n\nlemma restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t :=\nrestrict_mono' h (le_refl μ)\n\nlemma restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t :=\nle_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le)\n\nlemma restrict_eq_self_of_ae_mem {m0 : measurable_space α} ⦃s : set α⦄ ⦃μ : measure α⦄\n  (hs : ∀ᵐ x ∂μ, x ∈ s) :\n  μ.restrict s = μ :=\ncalc μ.restrict s = μ.restrict univ : restrict_congr_set (eventually_eq_univ.mpr hs)\n... = μ : restrict_univ\n\nlemma restrict_congr_meas (hs : measurable_set s) :\n  μ.restrict s = ν.restrict s ↔ ∀ t ⊆ s, measurable_set t → μ t = ν t :=\n⟨λ H t hts ht,\n   by rw [← inter_eq_self_of_subset_left hts, ← restrict_apply ht, H, restrict_apply ht],\n λ H, ext $ λ t ht,\n   by rw [restrict_apply ht, restrict_apply ht, H _ (inter_subset_right _ _) (ht.inter hs)]⟩\n\nlemma restrict_congr_mono (hs : s ⊆ t) (hm : measurable_set s) (h : μ.restrict t = ν.restrict t) :\n  μ.restrict s = ν.restrict s :=\nby rw [← inter_eq_self_of_subset_left hs, ← restrict_restrict hm, h, restrict_restrict hm]\n\n/-- If two measures agree on all measurable subsets of `s` and `t`, then they agree on all\nmeasurable subsets of `s ∪ t`. -/\nlemma restrict_union_congr (hsm : measurable_set s) (htm : measurable_set t) :\n  μ.restrict (s ∪ t) = ν.restrict (s ∪ t) ↔\n    μ.restrict s = ν.restrict s ∧ μ.restrict t = ν.restrict t :=\nbegin\n  refine ⟨λ h, ⟨restrict_congr_mono (subset_union_left _ _) hsm h,\n    restrict_congr_mono (subset_union_right _ _) htm h⟩, _⟩,\n  simp only [restrict_congr_meas, hsm, htm, hsm.union htm],\n  rintros ⟨hs, ht⟩ u hu hum,\n  rw [← measure_inter_add_diff u hsm, ← measure_inter_add_diff u hsm,\n    hs _ (inter_subset_right _ _) (hum.inter hsm),\n    ht _ (diff_subset_iff.2 hu) (hum.diff hsm)]\nend\n\nlemma restrict_finset_bUnion_congr {s : finset ι} {t : ι → set α}\n  (htm : ∀ i ∈ s, measurable_set (t i)) :\n  μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔\n    ∀ i ∈ s, μ.restrict (t i) = ν.restrict (t i) :=\nbegin\n  induction s using finset.induction_on with i s hi hs, { simp },\n  simp only [finset.mem_insert, or_imp_distrib, forall_and_distrib, forall_eq] at htm ⊢,\n  simp only [finset.set_bUnion_insert, ← hs htm.2],\n  exact restrict_union_congr htm.1 (s.measurable_set_bUnion htm.2)\nend\n\nlemma restrict_Union_congr [encodable ι] {s : ι → set α} (hm : ∀ i, measurable_set (s i)) :\n  μ.restrict (⋃ i, s i) = ν.restrict (⋃ i, s i) ↔\n    ∀ i, μ.restrict (s i) = ν.restrict (s i) :=\nbegin\n  refine ⟨λ h i, restrict_congr_mono (subset_Union _ _) (hm i) h, λ h, _⟩,\n  ext1 t ht,\n  have M : ∀ t : finset ι, measurable_set (⋃ i ∈ t, s i) :=\n    λ t, t.measurable_set_bUnion (λ i _, hm i),\n  have D : directed (⊆) (λ t : finset ι, ⋃ i ∈ t, s i) :=\n    directed_of_sup (λ t₁ t₂ ht, bUnion_subset_bUnion_left ht),\n  rw [Union_eq_Union_finset],\n  simp only [restrict_Union_apply_eq_supr M D ht,\n    (restrict_finset_bUnion_congr (λ i hi, hm i)).2 (λ i hi, h i)],\nend\n\nlemma restrict_bUnion_congr {s : set ι} {t : ι → set α} (hc : countable s)\n  (htm : ∀ i ∈ s, measurable_set (t i)) :\n  μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔\n    ∀ i ∈ s, μ.restrict (t i) = ν.restrict (t i) :=\nbegin\n  simp only [bUnion_eq_Union, set_coe.forall'] at htm ⊢,\n  haveI := hc.to_encodable,\n  exact restrict_Union_congr htm\nend\n\nlemma restrict_sUnion_congr {S : set (set α)} (hc : countable S) (hm : ∀ s ∈ S, measurable_set s) :\n  μ.restrict (⋃₀ S) = ν.restrict (⋃₀ S) ↔ ∀ s ∈ S, μ.restrict s = ν.restrict s :=\nby rw [sUnion_eq_bUnion, restrict_bUnion_congr hc hm]\n\n/-- This lemma shows that `Inf` and `restrict` commute for measures. -/\nlemma restrict_Inf_eq_Inf_restrict {m0 : measurable_space α} {m : set (measure α)}\n  (hm : m.nonempty) (ht : measurable_set t) :\n  (Inf m).restrict t = Inf ((λ μ : measure α, μ.restrict t) '' m) :=\nbegin\n  ext1 s hs,\n  simp_rw [Inf_apply hs, restrict_apply hs, Inf_apply (measurable_set.inter hs ht), set.image_image,\n    restrict_to_outer_measure_eq_to_outer_measure_restrict ht, ← set.image_image _ to_outer_measure,\n    ← outer_measure.restrict_Inf_eq_Inf_restrict _ (hm.image _),\n    outer_measure.restrict_apply]\nend\n\n/-! ### Extensionality results -/\n\n/-- Two measures are equal if they have equal restrictions on a spanning collection of sets\n  (formulated using `Union`). -/\nlemma ext_iff_of_Union_eq_univ [encodable ι] {s : ι → set α}\n  (hm : ∀ i, measurable_set (s i)) (hs : (⋃ i, s i) = univ) :\n  μ = ν ↔ ∀ i, μ.restrict (s i) = ν.restrict (s i) :=\nby rw [← restrict_Union_congr hm, hs, restrict_univ, restrict_univ]\n\nalias ext_iff_of_Union_eq_univ ↔ _ measure_theory.measure.ext_of_Union_eq_univ\n\n/-- Two measures are equal if they have equal restrictions on a spanning collection of sets\n  (formulated using `bUnion`). -/\nlemma ext_iff_of_bUnion_eq_univ {S : set ι} {s : ι → set α} (hc : countable S)\n  (hm : ∀ i ∈ S, measurable_set (s i)) (hs : (⋃ i ∈ S, s i) = univ) :\n  μ = ν ↔ ∀ i ∈ S, μ.restrict (s i) = ν.restrict (s i) :=\nby rw [← restrict_bUnion_congr hc hm, hs, restrict_univ, restrict_univ]\n\nalias ext_iff_of_bUnion_eq_univ ↔ _ measure_theory.measure.ext_of_bUnion_eq_univ\n\n/-- Two measures are equal if they have equal restrictions on a spanning collection of sets\n  (formulated using `sUnion`). -/\nlemma ext_iff_of_sUnion_eq_univ {S : set (set α)} (hc : countable S)\n  (hm : ∀ s ∈ S, measurable_set s) (hs : (⋃₀ S) = univ) :\n  μ = ν ↔ ∀ s ∈ S, μ.restrict s = ν.restrict s :=\next_iff_of_bUnion_eq_univ hc hm $ by rwa ← sUnion_eq_bUnion\n\nalias ext_iff_of_sUnion_eq_univ ↔ _ measure_theory.measure.ext_of_sUnion_eq_univ\n\nlemma ext_of_generate_from_of_cover {S T : set (set α)}\n  (h_gen : ‹_› = generate_from S) (hc : countable T)\n  (h_inter : is_pi_system S)\n  (hm : ∀ t ∈ T, measurable_set t) (hU : ⋃₀ T = univ) (htop : ∀ t ∈ T, μ t ≠ ∞)\n  (ST_eq : ∀ (t ∈ T) (s ∈ S), μ (s ∩ t) = ν (s ∩ t)) (T_eq : ∀ t ∈ T, μ t = ν t) :\n  μ = ν :=\nbegin\n  refine ext_of_sUnion_eq_univ hc hm hU (λ t ht, _),\n  ext1 u hu,\n  simp only [restrict_apply hu],\n  refine induction_on_inter h_gen h_inter _ (ST_eq t ht) _ _ hu,\n  { simp only [set.empty_inter, measure_empty] },\n  { intros v hv hvt,\n    have := T_eq t ht,\n    rw [set.inter_comm] at hvt ⊢,\n    rwa [← measure_inter_add_diff t hv, ← measure_inter_add_diff t hv, ← hvt,\n      ennreal.add_right_inj] at this,\n    exact ne_top_of_le_ne_top (htop t ht) (measure_mono $ set.inter_subset_left _ _) },\n  { intros f hfd hfm h_eq,\n    have : pairwise (disjoint on λ n, f n ∩ t) :=\n      λ m n hmn, (hfd m n hmn).mono (inter_subset_left _ _) (inter_subset_left _ _),\n    simp only [Union_inter, measure_Union this (λ n, (hfm n).inter (hm t ht)), h_eq] }\nend\n\n/-- Two measures are equal if they are equal on the π-system generating the σ-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the π-system.\n  This lemma is formulated using `sUnion`. -/\nlemma ext_of_generate_from_of_cover_subset {S T : set (set α)}\n  (h_gen : ‹_› = generate_from S)\n  (h_inter : is_pi_system S)\n  (h_sub : T ⊆ S) (hc : countable T) (hU : ⋃₀ T = univ) (htop : ∀ s ∈ T, μ s ≠ ∞)\n  (h_eq : ∀ s ∈ S, μ s = ν s) :\n  μ = ν :=\nbegin\n  refine ext_of_generate_from_of_cover h_gen hc h_inter _ hU htop _ (λ t ht, h_eq t (h_sub ht)),\n  { intros t ht, rw [h_gen], exact generate_measurable.basic _ (h_sub ht) },\n  { intros t ht s hs, cases (s ∩ t).eq_empty_or_nonempty with H H,\n    { simp only [H, measure_empty] },\n    { exact h_eq _ (h_inter _ _ hs (h_sub ht) H) } }\nend\n\n/-- Two measures are equal if they are equal on the π-system generating the σ-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the π-system.\n  This lemma is formulated using `Union`.\n  `finite_spanning_sets_in.ext` is a reformulation of this lemma. -/\nlemma ext_of_generate_from_of_Union (C : set (set α)) (B : ℕ → set α)\n  (hA : ‹_› = generate_from C) (hC : is_pi_system C) (h1B : (⋃ i, B i) = univ)\n  (h2B : ∀ i, B i ∈ C) (hμB : ∀ i, μ (B i) ≠ ∞) (h_eq : ∀ s ∈ C, μ s = ν s) : μ = ν :=\nbegin\n  refine ext_of_generate_from_of_cover_subset hA hC _ (countable_range B) h1B _ h_eq,\n  { rintro _ ⟨i, rfl⟩, apply h2B },\n  { rintro _ ⟨i, rfl⟩, apply hμB }\nend\n\nsection dirac\nvariable [measurable_space α]\n\n/-- The dirac measure. -/\ndef dirac (a : α) : measure α :=\n(outer_measure.dirac a).to_measure (by simp)\n\ninstance : measure_space punit := ⟨dirac punit.star⟩\n\nlemma le_dirac_apply {a} : s.indicator 1 a ≤ dirac a s :=\nouter_measure.dirac_apply a s ▸ le_to_measure_apply _ _ _\n\n@[simp] lemma dirac_apply' (a : α) (hs : measurable_set s) :\n  dirac a s = s.indicator 1 a :=\nto_measure_apply _ _ hs\n\n@[simp] lemma dirac_apply_of_mem {a : α} (h : a ∈ s) :\n  dirac a s = 1 :=\nbegin\n  have : ∀ t : set α, a ∈ t → t.indicator (1 : α → ℝ≥0∞) a = 1,\n    from λ t ht, indicator_of_mem ht 1,\n  refine le_antisymm (this univ trivial ▸ _) (this s h ▸ le_dirac_apply),\n  rw [← dirac_apply' a measurable_set.univ],\n  exact measure_mono (subset_univ s)\nend\n\n@[simp] lemma dirac_apply [measurable_singleton_class α] (a : α) (s : set α) :\n  dirac a s = s.indicator 1 a :=\nbegin\n  by_cases h : a ∈ s, by rw [dirac_apply_of_mem h, indicator_of_mem h, pi.one_apply],\n  rw [indicator_of_not_mem h, ← nonpos_iff_eq_zero],\n  calc dirac a s ≤ dirac a {a}ᶜ : measure_mono (subset_compl_comm.1 $ singleton_subset_iff.2 h)\n             ... = 0            : by simp [dirac_apply' _ (measurable_set_singleton _).compl]\nend\n\nlemma map_dirac {f : α → β} (hf : measurable f) (a : α) :\n  map f (dirac a) = dirac (f a) :=\next $ assume s hs, by simp [hs, map_apply hf hs, hf hs, indicator_apply]\n\n@[simp] lemma restrict_singleton (μ : measure α) (a : α) : μ.restrict {a} = μ {a} • dirac a :=\nbegin\n  ext1 s hs,\n  by_cases ha : a ∈ s,\n  { have : s ∩ {a} = {a}, by simpa,\n    simp * },\n  { have : s ∩ {a} = ∅, from inter_singleton_eq_empty.2 ha,\n    simp * }\nend\n\nend dirac\n\nsection sum\ninclude m0\n\n/-- Sum of an indexed family of measures. -/\ndef sum (f : ι → measure α) : measure α :=\n(outer_measure.sum (λ i, (f i).to_outer_measure)).to_measure $\nle_trans\n  (by exact le_infi (λ i, le_to_outer_measure_caratheodory _))\n  (outer_measure.le_sum_caratheodory _)\n\nlemma le_sum_apply (f : ι → measure α) (s : set α) : (∑' i, f i s) ≤ sum f s :=\nle_to_measure_apply _ _ _\n\n@[simp] lemma sum_apply (f : ι → measure α) {s : set α} (hs : measurable_set s) :\n  sum f s = ∑' i, f i s :=\nto_measure_apply _ _ hs\n\nlemma le_sum (μ : ι → measure α) (i : ι) : μ i ≤ sum μ :=\nλ s hs, by simp only [sum_apply μ hs, ennreal.le_tsum i]\n\n@[simp] lemma sum_apply_eq_zero [encodable ι] {μ : ι → measure α} {s : set α} :\n  sum μ s = 0 ↔ ∀ i, μ i s = 0 :=\nbegin\n  refine ⟨λ h i, nonpos_iff_eq_zero.1 $ h ▸ le_iff'.1 (le_sum μ i) _, λ h, nonpos_iff_eq_zero.1 _⟩,\n  rcases exists_measurable_superset_forall_eq μ s with ⟨t, hst, htm, ht⟩,\n  calc sum μ s ≤ sum μ t : measure_mono hst\n           ... = 0       : by simp *\nend\n\nlemma sum_apply_eq_zero' {μ : ι → measure α} {s : set α} (hs : measurable_set s) :\n  sum μ s = 0 ↔ ∀ i, μ i s = 0 :=\nby simp [hs]\n\nlemma ae_sum_iff [encodable ι] {μ : ι → measure α} {p : α → Prop} :\n  (∀ᵐ x ∂(sum μ), p x) ↔ ∀ i, ∀ᵐ x ∂(μ i), p x :=\nsum_apply_eq_zero\n\nlemma ae_sum_iff' {μ : ι → measure α} {p : α → Prop} (h : measurable_set {x | p x}) :\n  (∀ᵐ x ∂(sum μ), p x) ↔ ∀ i, ∀ᵐ x ∂(μ i), p x :=\nsum_apply_eq_zero' h.compl\n\n@[simp] lemma ae_sum_eq [encodable ι] (μ : ι → measure α) : (sum μ).ae = ⨆ i, (μ i).ae :=\nfilter.ext $ λ s, ae_sum_iff.trans mem_supr.symm\n\n@[simp] lemma sum_bool (f : bool → measure α) : sum f = f tt + f ff :=\next $ λ s hs, by simp [hs, tsum_fintype]\n\n@[simp] lemma sum_cond (μ ν : measure α) : sum (λ b, cond b μ ν) = μ + ν := sum_bool _\n\n@[simp] lemma restrict_sum (μ : ι → measure α) {s : set α} (hs : measurable_set s) :\n  (sum μ).restrict s = sum (λ i, (μ i).restrict s) :=\next $ λ t ht, by simp only [sum_apply, restrict_apply, ht, ht.inter hs]\n\n@[simp] lemma sum_of_empty [is_empty ι] (μ : ι → measure α) : sum μ = 0 :=\nby rw [← measure_univ_eq_zero, sum_apply _ measurable_set.univ, tsum_empty]\n\nlemma sum_congr {μ ν : ℕ → measure α} (h : ∀ n, μ n = ν n) : sum μ = sum ν :=\nby { congr, ext1 n, exact h n }\n\nlemma sum_add_sum (μ ν : ℕ → measure α) : sum μ + sum ν = sum (λ n, μ n + ν n) :=\nbegin\n  ext1 s hs,\n  simp only [add_apply, sum_apply _ hs, pi.add_apply, coe_add,\n             tsum_add ennreal.summable ennreal.summable],\nend\n\n/-- If `f` is a map with encodable codomain, then `map f μ` is the sum of Dirac measures -/\nlemma map_eq_sum [encodable β] [measurable_singleton_class β]\n  (μ : measure α) (f : α → β) (hf : measurable f) :\n  map f μ = sum (λ b : β, μ (f ⁻¹' {b}) • dirac b) :=\nbegin\n  ext1 s hs,\n  have : ∀ y ∈ s, measurable_set (f ⁻¹' {y}), from λ y _, hf (measurable_set_singleton _),\n  simp [← tsum_measure_preimage_singleton (countable_encodable s) this, *,\n    tsum_subtype s (λ b, μ (f ⁻¹' {b})), ← indicator_mul_right s (λ b, μ (f ⁻¹' {b}))]\nend\n\n/-- A measure on an encodable type is a sum of dirac measures. -/\n@[simp] lemma sum_smul_dirac [encodable α] [measurable_singleton_class α] (μ : measure α) :\n  sum (λ a, μ {a} • dirac a) = μ :=\nby simpa using (map_eq_sum μ id measurable_id).symm\n\nomit m0\nend sum\n\nlemma restrict_Union_ae [encodable ι] {s : ι → set α} (hd : pairwise (λ i j, μ (s i ∩ s j) = 0))\n  (hm : ∀ i, measurable_set (s i)) :\n  μ.restrict (⋃ i, s i) = sum (λ i, μ.restrict (s i)) :=\next $ λ t ht, by simp only [sum_apply _ ht, restrict_Union_apply_ae hd hm ht]\n\nlemma restrict_Union [encodable ι] {s : ι → set α} (hd : pairwise (disjoint on s))\n  (hm : ∀ i, measurable_set (s i)) :\n  μ.restrict (⋃ i, s i) = sum (λ i, μ.restrict (s i)) :=\next $ λ t ht, by simp only [sum_apply _ ht, restrict_Union_apply hd hm ht]\n\nlemma restrict_Union_le [encodable ι] {s : ι → set α} :\n  μ.restrict (⋃ i, s i) ≤ sum (λ i, μ.restrict (s i)) :=\nbegin\n  intros t ht,\n  suffices : μ (⋃ i, t ∩ s i) ≤ ∑' i, μ (t ∩ s i), by simpa [ht, inter_Union],\n  apply measure_Union_le\nend\n\nsection count\n\nvariable [measurable_space α]\n\n/-- Counting measure on any measurable space. -/\ndef count : measure α := sum dirac\n\nlemma le_count_apply : (∑' i : s, 1 : ℝ≥0∞) ≤ count s :=\ncalc (∑' i : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i : tsum_subtype s 1\n... ≤ ∑' i, dirac i s : ennreal.tsum_le_tsum $ λ x, le_dirac_apply\n... ≤ count s : le_sum_apply _ _\n\nlemma count_apply (hs : measurable_set s) : count s = ∑' i : s, 1 :=\nby simp only [count, sum_apply, hs, dirac_apply', ← tsum_subtype s 1, pi.one_apply]\n\n@[simp] lemma count_apply_finset [measurable_singleton_class α] (s : finset α) :\n  count (↑s : set α) = s.card :=\ncalc count (↑s : set α) = ∑' i : (↑s : set α), 1 : count_apply s.measurable_set\n                    ... = ∑ i in s, 1 : s.tsum_subtype 1\n                    ... = s.card : by simp\n\nlemma count_apply_finite [measurable_singleton_class α] (s : set α) (hs : finite s) :\n  count s = hs.to_finset.card :=\nby rw [← count_apply_finset, finite.coe_to_finset]\n\n/-- `count` measure evaluates to infinity at infinite sets. -/\nlemma count_apply_infinite (hs : s.infinite) : count s = ∞ :=\nbegin\n  refine top_unique (le_of_tendsto' ennreal.tendsto_nat_nhds_top $ λ n, _),\n  rcases hs.exists_subset_card_eq n with ⟨t, ht, rfl⟩,\n  calc (t.card : ℝ≥0∞) = ∑ i in t, 1 : by simp\n  ... = ∑' i : (t : set α), 1 : (t.tsum_subtype 1).symm\n  ... ≤ count (t : set α) : le_count_apply\n  ... ≤ count s : measure_mono ht\nend\n\n@[simp] lemma count_apply_eq_top [measurable_singleton_class α] : count s = ∞ ↔ s.infinite :=\nbegin\n  by_cases hs : s.finite,\n  { simp [set.infinite, hs, count_apply_finite] },\n  { change s.infinite at hs,\n    simp [hs, count_apply_infinite] }\nend\n\n@[simp] lemma count_apply_lt_top [measurable_singleton_class α] : count s < ∞ ↔ s.finite :=\ncalc count s < ∞ ↔ count s ≠ ∞ : lt_top_iff_ne_top\n             ... ↔ ¬s.infinite : not_congr count_apply_eq_top\n             ... ↔ s.finite    : not_not\n\nend count\n\n/-! ### Absolute continuity -/\n\n/-- We say that `μ` is absolutely continuous with respect to `ν`, or that `μ` is dominated by `ν`,\n  if `ν(A) = 0` implies that `μ(A) = 0`. -/\ndef absolutely_continuous {m0 : measurable_space α} (μ ν : measure α) : Prop :=\n∀ ⦃s : set α⦄, ν s = 0 → μ s = 0\n\nlocalized \"infix ` ≪ `:50 := measure_theory.measure.absolutely_continuous\" in measure_theory\n\nlemma absolutely_continuous_of_le (h : μ ≤ ν) : μ ≪ ν :=\nλ s hs, nonpos_iff_eq_zero.1 $ hs ▸ le_iff'.1 h s\n\nalias absolutely_continuous_of_le ← has_le.le.absolutely_continuous\n\nlemma absolutely_continuous_of_eq (h : μ = ν) : μ ≪ ν :=\nh.le.absolutely_continuous\n\nalias absolutely_continuous_of_eq ← eq.absolutely_continuous\n\nnamespace absolutely_continuous\n\nlemma mk (h : ∀ ⦃s : set α⦄, measurable_set s → ν s = 0 → μ s = 0) : μ ≪ ν :=\nbegin\n  intros s hs,\n  rcases exists_measurable_superset_of_null hs with ⟨t, h1t, h2t, h3t⟩,\n  exact measure_mono_null h1t (h h2t h3t),\nend\n\n@[refl] protected lemma refl {m0 : measurable_space α} (μ : measure α) : μ ≪ μ :=\nrfl.absolutely_continuous\n\nprotected lemma rfl : μ ≪ μ := λ s hs, hs\n\ninstance [measurable_space α] : is_refl (measure α) (≪) := ⟨λ μ, absolutely_continuous.rfl⟩\n\n@[trans] protected lemma trans (h1 : μ₁ ≪ μ₂) (h2 : μ₂ ≪ μ₃) : μ₁ ≪ μ₃ :=\nλ s hs, h1 $ h2 hs\n\n@[mono] protected lemma map (h : μ ≪ ν) (f : α → β) : map f μ ≪ map f ν :=\nif hf : measurable f then absolutely_continuous.mk $ λ s hs, by simpa [hf, hs] using @h _\nelse by simp only [map_of_not_measurable hf]\n\nprotected lemma smul (h : μ ≪ ν) (c : ℝ≥0∞) : c • μ ≪ ν :=\nmk (λ s hs hνs, by simp only [h hνs, algebra.id.smul_eq_mul, coe_smul, pi.smul_apply, mul_zero])\n\nprotected lemma coe_nnreal_smul (h : μ ≪ ν) (c : ℝ≥0) : c • μ ≪ ν :=\nh.smul c\n\nend absolutely_continuous\n\nlemma ae_le_iff_absolutely_continuous : μ.ae ≤ ν.ae ↔ μ ≪ ν :=\n⟨λ h s, by { rw [measure_zero_iff_ae_nmem, measure_zero_iff_ae_nmem], exact λ hs, h hs },\n  λ h s hs, h hs⟩\n\nalias ae_le_iff_absolutely_continuous ↔ has_le.le.absolutely_continuous_of_ae\n  measure_theory.measure.absolutely_continuous.ae_le\nalias absolutely_continuous.ae_le ← ae_mono'\n\nlemma absolutely_continuous.ae_eq (h : μ ≪ ν) {f g : α → δ} (h' : f =ᵐ[ν] g) : f =ᵐ[μ] g :=\nh.ae_le h'\n\n/-! ### Quasi measure preserving maps (a.k.a. non-singular maps) -/\n\n/-- A map `f : α → β` is said to be *quasi measure preserving* (a.k.a. non-singular) w.r.t. measures\n`μa` and `μb` if it is measurable and `μb s = 0` implies `μa (f ⁻¹' s) = 0`. -/\n@[protect_proj]\nstructure quasi_measure_preserving {m0 : measurable_space α} (f : α → β)\n  (μa : measure α . volume_tac) (μb : measure β . volume_tac) : Prop :=\n(measurable : measurable f)\n(absolutely_continuous : map f μa ≪ μb)\n\nnamespace quasi_measure_preserving\n\nprotected lemma id {m0 : measurable_space α} (μ : measure α) : quasi_measure_preserving id μ μ :=\n⟨measurable_id, map_id.absolutely_continuous⟩\n\nvariables {μa μa' : measure α} {μb μb' : measure β} {μc : measure γ} {f : α → β}\n\nlemma mono_left (h : quasi_measure_preserving f μa μb)\n  (ha : μa' ≪ μa) : quasi_measure_preserving f μa' μb :=\n⟨h.1, (ha.map f).trans h.2⟩\n\nlemma mono_right (h : quasi_measure_preserving f μa μb)\n  (ha : μb ≪ μb') : quasi_measure_preserving f μa μb' :=\n⟨h.1, h.2.trans ha⟩\n\n@[mono] lemma mono (ha : μa' ≪ μa) (hb : μb ≪ μb') (h : quasi_measure_preserving f μa μb) :\n  quasi_measure_preserving f μa' μb' :=\n(h.mono_left ha).mono_right hb\n\nprotected lemma comp {g : β → γ} {f : α → β} (hg : quasi_measure_preserving g μb μc)\n  (hf : quasi_measure_preserving f μa μb) :\n  quasi_measure_preserving (g ∘ f) μa μc :=\n⟨hg.measurable.comp hf.measurable, by { rw ← map_map hg.1 hf.1, exact (hf.2.map g).trans hg.2 }⟩\n\nprotected lemma iterate {f : α → α} (hf : quasi_measure_preserving f μa μa) :\n  ∀ n, quasi_measure_preserving (f^[n]) μa μa\n| 0 := quasi_measure_preserving.id μa\n| (n + 1) := (iterate n).comp hf\n\nlemma ae_map_le (h : quasi_measure_preserving f μa μb) : (map f μa).ae ≤ μb.ae :=\nh.2.ae_le\n\nlemma tendsto_ae (h : quasi_measure_preserving f μa μb) : tendsto f μa.ae μb.ae :=\n(tendsto_ae_map h.1).mono_right h.ae_map_le\n\nlemma ae (h : quasi_measure_preserving f μa μb) {p : β → Prop} (hg : ∀ᵐ x ∂μb, p x) :\n  ∀ᵐ x ∂μa, p (f x) :=\nh.tendsto_ae hg\n\nlemma ae_eq (h : quasi_measure_preserving f μa μb) {g₁ g₂ : β → δ} (hg : g₁ =ᵐ[μb] g₂) :\n  g₁ ∘ f =ᵐ[μa] g₂ ∘ f :=\nh.ae hg\n\nlemma preimage_null (h : quasi_measure_preserving f μa μb) {s : set β} (hs : μb s = 0) :\n  μa (f ⁻¹' s) = 0 :=\npreimage_null_of_map_null h.1 (h.2 hs)\n\nend quasi_measure_preserving\n\n/-! ### The `cofinite` filter -/\n\n/-- The filter of sets `s` such that `sᶜ` has finite measure. -/\ndef cofinite {m0 : measurable_space α} (μ : measure α) : filter α :=\n{ sets := {s | μ sᶜ < ∞},\n  univ_sets := by simp,\n  inter_sets := λ s t hs ht, by { simp only [compl_inter, mem_set_of_eq],\n    calc μ (sᶜ ∪ tᶜ) ≤ μ sᶜ + μ tᶜ : measure_union_le _ _\n                ... < ∞ : ennreal.add_lt_top.2 ⟨hs, ht⟩ },\n  sets_of_superset := λ s t hs hst, lt_of_le_of_lt (measure_mono $ compl_subset_compl.2 hst) hs }\n\nlemma mem_cofinite : s ∈ μ.cofinite ↔ μ sᶜ < ∞ := iff.rfl\n\nlemma compl_mem_cofinite : sᶜ ∈ μ.cofinite ↔ μ s < ∞ :=\nby rw [mem_cofinite, compl_compl]\n\nlemma eventually_cofinite {p : α → Prop} : (∀ᶠ x in μ.cofinite, p x) ↔ μ {x | ¬p x} < ∞ := iff.rfl\n\nend measure\n\nopen measure\nopen_locale measure_theory\n\nlemma null_measurable_set.mono_ac (h : null_measurable_set s μ) (hle : ν ≪ μ) :\n  null_measurable_set s ν :=\n⟨to_measurable μ s, measurable_set_to_measurable _ _, hle.ae_eq h.to_measurable_ae_eq.symm⟩\n\nlemma null_measurable_set.mono (h : null_measurable_set s μ) (hle : ν ≤ μ) :\n  null_measurable_set s ν :=\nh.mono_ac hle.absolutely_continuous\n\n@[simp] lemma ae_eq_bot : μ.ae = ⊥ ↔ μ = 0 :=\nby rw [← empty_mem_iff_bot, mem_ae_iff, compl_empty, measure_univ_eq_zero]\n\n@[simp] lemma ae_ne_bot : μ.ae.ne_bot ↔ μ ≠ 0 :=\nne_bot_iff.trans (not_congr ae_eq_bot)\n\n@[simp] lemma ae_zero {m0 : measurable_space α} : (0 : measure α).ae = ⊥ := ae_eq_bot.2 rfl\n\n@[mono] lemma ae_mono (h : μ ≤ ν) : μ.ae ≤ ν.ae := h.absolutely_continuous.ae_le\n\nlemma mem_ae_map_iff {f : α → β} (hf : measurable f) {s : set β} (hs : measurable_set s) :\n  s ∈ (map f μ).ae ↔ (f ⁻¹' s) ∈ μ.ae :=\nby simp only [mem_ae_iff, map_apply hf hs.compl, preimage_compl]\n\nlemma mem_ae_of_mem_ae_map {f : α → β} (hf : measurable f) {s : set β} (hs : s ∈ (map f μ).ae) :\n  f ⁻¹' s ∈ μ.ae :=\n(tendsto_ae_map hf).eventually hs\n\nlemma ae_map_iff {f : α → β} (hf : measurable f) {p : β → Prop} (hp : measurable_set {x | p x}) :\n  (∀ᵐ y ∂ (map f μ), p y) ↔ ∀ᵐ x ∂ μ, p (f x) :=\nmem_ae_map_iff hf hp\n\nlemma ae_of_ae_map {f : α → β} (hf : measurable f) {p : β → Prop} (h : ∀ᵐ y ∂ (map f μ), p y) :\n  ∀ᵐ x ∂ μ, p (f x) :=\nmem_ae_of_mem_ae_map hf h\n\nlemma ae_map_mem_range {m0 : measurable_space α} (f : α → β) (hf : measurable_set (range f))\n  (μ : measure α) :\n  ∀ᵐ x ∂(map f μ), x ∈ range f :=\nbegin\n  by_cases h : measurable f,\n  { change range f ∈ (map f μ).ae,\n    rw mem_ae_map_iff h hf,\n    apply eventually_of_forall,\n    exact mem_range_self },\n  { simp [map_of_not_measurable h] }\nend\n\nlemma ae_restrict_iff {p : α → Prop} (hp : measurable_set {x | p x}) :\n  (∀ᵐ x ∂(μ.restrict s), p x) ↔ ∀ᵐ x ∂μ, x ∈ s → p x :=\nbegin\n  simp only [ae_iff, ← compl_set_of, restrict_apply hp.compl],\n  congr' with x, simp [and_comm]\nend\n\nlemma ae_imp_of_ae_restrict {s : set α} {p : α → Prop} (h : ∀ᵐ x ∂(μ.restrict s), p x) :\n  ∀ᵐ x ∂μ, x ∈ s → p x :=\nbegin\n  simp only [ae_iff] at h ⊢,\n  simpa [set_of_and, inter_comm] using measure_inter_eq_zero_of_restrict h\nend\n\nlemma ae_restrict_iff' {s : set α} {p : α → Prop} (hs : measurable_set s) :\n  (∀ᵐ x ∂(μ.restrict s), p x) ↔ ∀ᵐ x ∂μ, x ∈ s → p x :=\nbegin\n  simp only [ae_iff, ← compl_set_of, restrict_apply_eq_zero' hs],\n  congr' with x, simp [and_comm]\nend\n\nlemma ae_restrict_mem {s : set α} (hs : measurable_set s) :\n  ∀ᵐ x ∂(μ.restrict s), x ∈ s :=\n(ae_restrict_iff' hs).2 (filter.eventually_of_forall (λ x, id))\n\nlemma ae_restrict_of_ae {s : set α} {p : α → Prop} (h : ∀ᵐ x ∂μ, p x) :\n  (∀ᵐ x ∂(μ.restrict s), p x) :=\neventually.filter_mono (ae_mono measure.restrict_le_self) h\n\nlemma ae_restrict_of_ae_restrict_of_subset {s t : set α} {p : α → Prop} (hst : s ⊆ t)\n  (h : ∀ᵐ x ∂(μ.restrict t), p x) :\n  (∀ᵐ x ∂(μ.restrict s), p x) :=\nh.filter_mono (ae_mono $ measure.restrict_mono hst (le_refl μ))\n\nlemma ae_of_ae_restrict_of_ae_restrict_compl {t : set α} {p : α → Prop}\n  (ht : ∀ᵐ x ∂(μ.restrict t), p x) (htc : ∀ᵐ x ∂(μ.restrict tᶜ), p x) :\n  ∀ᵐ x ∂μ, p x :=\nnonpos_iff_eq_zero.1 $\ncalc μ {x | ¬p x} = μ ({x | ¬p x} ∩ t ∪ {x | ¬p x} ∩ tᶜ) :\n  by rw [← inter_union_distrib_left, union_compl_self, inter_univ]\n... ≤ μ ({x | ¬p x} ∩ t) + μ ({x | ¬p x} ∩ tᶜ) : measure_union_le _ _\n... ≤ μ.restrict t {x | ¬p x} + μ.restrict tᶜ {x | ¬p x} :\n  add_le_add (le_restrict_apply _ _) (le_restrict_apply _ _)\n... = 0 : by rw [ae_iff.1 ht, ae_iff.1 htc, zero_add]\n\nlemma mem_map_restrict_ae_iff {β} {s : set α} {t : set β} {f : α → β} (hs : measurable_set s) :\n  t ∈ filter.map f (μ.restrict s).ae ↔ μ ((f ⁻¹' t)ᶜ ∩ s) = 0 :=\nby rw [mem_map, mem_ae_iff, measure.restrict_apply' hs]\n\nlemma ae_smul_measure {p : α → Prop} (h : ∀ᵐ x ∂μ, p x) (c : ℝ≥0∞) : ∀ᵐ x ∂(c • μ), p x :=\nae_iff.2 $ by rw [smul_apply, ae_iff.1 h, mul_zero]\n\nlemma ae_smul_measure_iff {p : α → Prop} {c : ℝ≥0∞} (hc : c ≠ 0) :\n  (∀ᵐ x ∂(c • μ), p x) ↔ ∀ᵐ x ∂μ, p x :=\nby simp [ae_iff, hc]\n\nlemma ae_add_measure_iff {p : α → Prop} {ν} : (∀ᵐ x ∂μ + ν, p x) ↔ (∀ᵐ x ∂μ, p x) ∧ ∀ᵐ x ∂ν, p x :=\nadd_eq_zero_iff\n\nlemma ae_eq_comp' {ν : measure β} {f : α → β} {g g' : β → δ} (hf : measurable f)\n  (h : g =ᵐ[ν] g') (h2 : map f μ ≪ ν) : g ∘ f =ᵐ[μ] g' ∘ f :=\n(quasi_measure_preserving.mk hf h2).ae_eq h\n\nlemma ae_eq_comp {f : α → β} {g g' : β → δ} (hf : measurable f)\n  (h : g =ᵐ[measure.map f μ] g') : g ∘ f =ᵐ[μ] g' ∘ f :=\nae_eq_comp' hf h absolutely_continuous.rfl\n\nlemma sub_ae_eq_zero {β} [add_group β] (f g : α → β) : f - g =ᵐ[μ] 0 ↔ f =ᵐ[μ] g :=\nbegin\n  refine ⟨λ h, h.mono (λ x hx, _), λ h, h.mono (λ x hx, _)⟩,\n  { rwa [pi.sub_apply, pi.zero_apply, sub_eq_zero] at hx, },\n  { rwa [pi.sub_apply, pi.zero_apply, sub_eq_zero], },\nend\n\nlemma le_ae_restrict : μ.ae ⊓ 𝓟 s ≤ (μ.restrict s).ae :=\nλ s hs, eventually_inf_principal.2 (ae_imp_of_ae_restrict hs)\n\n@[simp] lemma ae_restrict_eq (hs : measurable_set s) : (μ.restrict s).ae = μ.ae ⊓ 𝓟 s :=\nbegin\n  ext t,\n  simp only [mem_inf_principal, mem_ae_iff, restrict_apply_eq_zero' hs, compl_set_of,\n    not_imp, and_comm (_ ∈ s)],\n  refl\nend\n\n@[simp] lemma ae_restrict_eq_bot {s} : (μ.restrict s).ae = ⊥ ↔ μ s = 0 :=\nae_eq_bot.trans restrict_eq_zero\n\n@[simp] lemma ae_restrict_ne_bot {s} : (μ.restrict s).ae.ne_bot ↔ 0 < μ s :=\nne_bot_iff.trans $ (not_congr ae_restrict_eq_bot).trans pos_iff_ne_zero.symm\n\nlemma self_mem_ae_restrict {s} (hs : measurable_set s) : s ∈ (μ.restrict s).ae :=\nby simp only [ae_restrict_eq hs, exists_prop, mem_principal, mem_inf_iff];\n  exact ⟨_, univ_mem, s, subset.rfl, (univ_inter s).symm⟩\n\n/-- A version of the **Borel-Cantelli lemma**: if `pᵢ` is a sequence of predicates such that\n`∑ μ {x | pᵢ x}` is finite, then the measure of `x` such that `pᵢ x` holds frequently as `i → ∞` (or\nequivalently, `pᵢ x` holds for infinitely many `i`) is equal to zero. -/\nlemma measure_set_of_frequently_eq_zero {p : ℕ → α → Prop} (hp : ∑' i, μ {x | p i x} ≠ ∞) :\n  μ {x | ∃ᶠ n in at_top, p n x} = 0 :=\nby simpa only [limsup_eq_infi_supr_of_nat, frequently_at_top, set_of_forall, set_of_exists]\n  using measure_limsup_eq_zero hp\n\n/-- A version of the **Borel-Cantelli lemma**: if `sᵢ` is a sequence of sets such that\n`∑ μ sᵢ` exists, then for almost all `x`, `x` does not belong to almost all `sᵢ`. -/\nlemma ae_eventually_not_mem {s : ℕ → set α} (hs : ∑' i, μ (s i) ≠ ∞) :\n  ∀ᵐ x ∂ μ, ∀ᶠ n in at_top, x ∉ s n :=\nmeasure_set_of_frequently_eq_zero hs\n\nsection dirac\nvariable [measurable_space α]\n\nlemma mem_ae_dirac_iff {a : α} (hs : measurable_set s) : s ∈ (dirac a).ae ↔ a ∈ s :=\nby by_cases a ∈ s; simp [mem_ae_iff, dirac_apply', hs.compl, indicator_apply, *]\n\nlemma ae_dirac_iff {a : α} {p : α → Prop} (hp : measurable_set {x | p x}) :\n  (∀ᵐ x ∂(dirac a), p x) ↔ p a :=\nmem_ae_dirac_iff hp\n\n@[simp] lemma ae_dirac_eq [measurable_singleton_class α] (a : α) : (dirac a).ae = pure a :=\nby { ext s, simp [mem_ae_iff, imp_false] }\n\nlemma ae_eq_dirac' [measurable_singleton_class β] {a : α} {f : α → β} (hf : measurable f) :\n  f =ᵐ[dirac a] const α (f a) :=\n(ae_dirac_iff $ show measurable_set (f ⁻¹' {f a}), from hf $ measurable_set_singleton _).2 rfl\n\nlemma ae_eq_dirac [measurable_singleton_class α] {a : α} (f : α → δ) :\n  f =ᵐ[dirac a] const α (f a) :=\nby simp [filter.eventually_eq]\n\nend dirac\n\nsection is_finite_measure\n\ninclude m0\n\n/-- A measure `μ` is called finite if `μ univ < ∞`. -/\nclass is_finite_measure (μ : measure α) : Prop := (measure_univ_lt_top : μ univ < ∞)\n\ninstance restrict.is_finite_measure (μ : measure α) [hs : fact (μ s < ∞)] :\n  is_finite_measure (μ.restrict s) :=\n⟨by simp [hs.elim]⟩\n\nlemma measure_lt_top (μ : measure α) [is_finite_measure μ] (s : set α) : μ s < ∞ :=\n(measure_mono (subset_univ s)).trans_lt is_finite_measure.measure_univ_lt_top\n\nlemma measure_ne_top (μ : measure α) [is_finite_measure μ] (s : set α) : μ s ≠ ∞ :=\nne_of_lt (measure_lt_top μ s)\n\nlemma measure_compl_le_add_of_le_add [is_finite_measure μ] (hs : measurable_set s)\n  (ht : measurable_set t) {ε : ℝ≥0∞} (h : μ s ≤ μ t + ε) :\n  μ tᶜ ≤ μ sᶜ + ε :=\nbegin\n  rw [measure_compl ht (measure_ne_top μ _), measure_compl hs (measure_ne_top μ _),\n    tsub_le_iff_right],\n  calc μ univ = μ univ - μ s + μ s :\n    (tsub_add_cancel_of_le $ measure_mono s.subset_univ).symm\n  ... ≤ μ univ - μ s + (μ t + ε) : add_le_add_left h _\n  ... = _ : by rw [add_right_comm, add_assoc]\nend\n\nlemma measure_compl_le_add_iff [is_finite_measure μ] (hs : measurable_set s)\n  (ht : measurable_set t) {ε : ℝ≥0∞} :\n  μ sᶜ ≤ μ tᶜ + ε ↔ μ t ≤ μ s + ε :=\n⟨λ h, compl_compl s ▸ compl_compl t ▸ measure_compl_le_add_of_le_add hs.compl ht.compl h,\n  measure_compl_le_add_of_le_add ht hs⟩\n\n/-- The measure of the whole space with respect to a finite measure, considered as `ℝ≥0`. -/\ndef measure_univ_nnreal (μ : measure α) : ℝ≥0 := (μ univ).to_nnreal\n\n@[simp] lemma coe_measure_univ_nnreal (μ : measure α) [is_finite_measure μ] :\n  ↑(measure_univ_nnreal μ) = μ univ :=\nennreal.coe_to_nnreal (measure_ne_top μ univ)\n\ninstance is_finite_measure_zero : is_finite_measure (0 : measure α) := ⟨by simp⟩\n\n@[priority 100]\ninstance is_finite_measure_of_is_empty [is_empty α] : is_finite_measure μ :=\nby { rw eq_zero_of_is_empty μ, apply_instance }\n\n@[simp] lemma measure_univ_nnreal_zero : measure_univ_nnreal (0 : measure α) = 0 := rfl\n\nomit m0\n\ninstance is_finite_measure_add [is_finite_measure μ] [is_finite_measure ν] :\n  is_finite_measure (μ + ν) :=\n{ measure_univ_lt_top :=\n  begin\n    rw [measure.coe_add, pi.add_apply, ennreal.add_lt_top],\n    exact ⟨measure_lt_top _ _, measure_lt_top _ _⟩,\n  end }\n\ninstance is_finite_measure_smul_nnreal [is_finite_measure μ] {r : ℝ≥0} :\n  is_finite_measure (r • μ) :=\n{ measure_univ_lt_top := ennreal.mul_lt_top ennreal.coe_ne_top (measure_ne_top _ _) }\n\nlemma is_finite_measure_of_le (μ : measure α) [is_finite_measure μ] (h : ν ≤ μ) :\n  is_finite_measure ν :=\n{ measure_univ_lt_top := lt_of_le_of_lt (h set.univ measurable_set.univ) (measure_lt_top _ _) }\n\n@[instance] lemma measure.is_finite_measure_map {m : measurable_space α}\n  (μ : measure α) [is_finite_measure μ] (f : α → β) :\n  is_finite_measure (map f μ) :=\nbegin\n  by_cases hf : measurable f,\n  { constructor, rw map_apply hf measurable_set.univ, exact measure_lt_top μ _ },\n  { rw map_of_not_measurable hf, exact measure_theory.is_finite_measure_zero }\nend\n\n@[simp] lemma measure_univ_nnreal_eq_zero [is_finite_measure μ] :\n  measure_univ_nnreal μ = 0 ↔ μ = 0 :=\nbegin\n  rw [← measure_theory.measure.measure_univ_eq_zero, ← coe_measure_univ_nnreal],\n  norm_cast\nend\n\nlemma measure_univ_nnreal_pos [is_finite_measure μ] (hμ : μ ≠ 0) : 0 < measure_univ_nnreal μ :=\nbegin\n  contrapose! hμ,\n  simpa [measure_univ_nnreal_eq_zero, le_zero_iff] using hμ\nend\n\n/-- `le_of_add_le_add_left` is normally applicable to `ordered_cancel_add_comm_monoid`,\nbut it holds for measures with the additional assumption that μ is finite. -/\nlemma measure.le_of_add_le_add_left [is_finite_measure μ] (A2 : μ + ν₁ ≤ μ + ν₂) : ν₁ ≤ ν₂ :=\nλ S B1, ennreal.le_of_add_le_add_left (measure_theory.measure_ne_top μ S) (A2 S B1)\n\nlemma summable_measure_to_real [hμ : is_finite_measure μ]\n  {f : ℕ → set α} (hf₁ : ∀ (i : ℕ), measurable_set (f i)) (hf₂ : pairwise (disjoint on f)) :\n  summable (λ x, (μ (f x)).to_real) :=\nbegin\n  apply ennreal.summable_to_real,\n  rw ← measure_theory.measure_Union hf₂ hf₁,\n  exact ne_of_lt (measure_lt_top _ _)\nend\n\nend is_finite_measure\n\nsection is_probability_measure\n\ninclude m0\n\n/-- A measure `μ` is called a probability measure if `μ univ = 1`. -/\nclass is_probability_measure (μ : measure α) : Prop := (measure_univ : μ univ = 1)\n\nexport is_probability_measure (measure_univ)\n\n@[priority 100]\ninstance is_probability_measure.to_is_finite_measure (μ : measure α) [is_probability_measure μ] :\n  is_finite_measure μ :=\n⟨by simp only [measure_univ, ennreal.one_lt_top]⟩\n\nlemma is_probability_measure.ne_zero (μ : measure α) [is_probability_measure μ] : μ ≠ 0 :=\nmt measure_univ_eq_zero.2 $ by simp [measure_univ]\n\nomit m0\n\ninstance measure.dirac.is_probability_measure [measurable_space α] {x : α} :\n  is_probability_measure (dirac x) :=\n⟨dirac_apply_of_mem $ mem_univ x⟩\n\nlemma prob_add_prob_compl [is_probability_measure μ]\n  (h : measurable_set s) : μ s + μ sᶜ = 1 :=\n(measure_add_measure_compl h).trans measure_univ\n\nlemma prob_le_one [is_probability_measure μ] : μ s ≤ 1 :=\n(measure_mono $ set.subset_univ _).trans_eq measure_univ\n\nend is_probability_measure\n\nsection no_atoms\n\n/-- Measure `μ` *has no atoms* if the measure of each singleton is zero.\n\nNB: Wikipedia assumes that for any measurable set `s` with positive `μ`-measure,\nthere exists a measurable `t ⊆ s` such that `0 < μ t < μ s`. While this implies `μ {x} = 0`,\nthe converse is not true. -/\nclass has_no_atoms {m0 : measurable_space α} (μ : measure α) : Prop :=\n(measure_singleton : ∀ x, μ {x} = 0)\n\nexport has_no_atoms (measure_singleton)\nattribute [simp] measure_singleton\n\nvariables [has_no_atoms μ]\n\nlemma _root_.set.subsingleton.measure_zero {α : Type*} {m : measurable_space α} {s : set α}\n  (hs : s.subsingleton) (μ : measure α) [has_no_atoms μ] :\n  μ s = 0 :=\nhs.induction_on measure_empty measure_singleton\n\nlemma measure.restrict_singleton' {a : α} :\n  μ.restrict {a} = 0 :=\nby simp only [measure_singleton, measure.restrict_eq_zero]\n\ninstance (s : set α) : has_no_atoms (μ.restrict s) :=\nbegin\n  refine ⟨λ x, _⟩,\n  obtain ⟨t, hxt, ht1, ht2⟩ := exists_measurable_superset_of_null (measure_singleton x : μ {x} = 0),\n  apply measure_mono_null hxt,\n  rw measure.restrict_apply ht1,\n  apply measure_mono_null (inter_subset_left t s) ht2\nend\n\nlemma _root_.set.countable.measure_zero {α : Type*} {m : measurable_space α} {s : set α}\n  (h : countable s) (μ : measure α) [has_no_atoms μ] :\n  μ s = 0 :=\nbegin\n  rw [← bUnion_of_singleton s, ← nonpos_iff_eq_zero],\n  refine le_trans (measure_bUnion_le h _) _,\n  simp\nend\n\nlemma _root_.set.finite.measure_zero {α : Type*} {m : measurable_space α} {s : set α}\n  (h : s.finite) (μ : measure α) [has_no_atoms μ] : μ s = 0 :=\nh.countable.measure_zero μ\n\nlemma _root_.finset.measure_zero {α : Type*} {m : measurable_space α}\n  (s : finset α) (μ : measure α) [has_no_atoms μ] : μ s = 0 :=\ns.finite_to_set.measure_zero μ\n\nlemma insert_ae_eq_self (a : α) (s : set α) :\n  (insert a s : set α) =ᵐ[μ] s :=\nunion_ae_eq_right.2 $ measure_mono_null (diff_subset _ _) (measure_singleton _)\n\nvariables [partial_order α] {a b : α}\n\nlemma Iio_ae_eq_Iic : Iio a =ᵐ[μ] Iic a :=\nby simp only [← Iic_diff_right, diff_ae_eq_self,\n  measure_mono_null (set.inter_subset_right _ _) (measure_singleton a)]\n\nlemma Ioi_ae_eq_Ici : Ioi a =ᵐ[μ] Ici a :=\n@Iio_ae_eq_Iic (order_dual α) ‹_› ‹_› _ _ _\n\nlemma Ioo_ae_eq_Ioc : Ioo a b =ᵐ[μ] Ioc a b :=\n(ae_eq_refl _).inter Iio_ae_eq_Iic\n\nlemma Ioc_ae_eq_Icc : Ioc a b =ᵐ[μ] Icc a b :=\nIoi_ae_eq_Ici.inter (ae_eq_refl _)\n\nlemma Ioo_ae_eq_Ico : Ioo a b =ᵐ[μ] Ico a b :=\nIoi_ae_eq_Ici.inter (ae_eq_refl _)\n\nlemma Ioo_ae_eq_Icc : Ioo a b =ᵐ[μ] Icc a b :=\nIoi_ae_eq_Ici.inter Iio_ae_eq_Iic\n\nlemma Ico_ae_eq_Icc : Ico a b =ᵐ[μ] Icc a b :=\n(ae_eq_refl _).inter Iio_ae_eq_Iic\n\nlemma Ico_ae_eq_Ioc : Ico a b =ᵐ[μ] Ioc a b :=\nIoo_ae_eq_Ico.symm.trans Ioo_ae_eq_Ioc\n\nend no_atoms\n\nlemma ite_ae_eq_of_measure_zero {γ} (f : α → γ) (g : α → γ) (s : set α) (hs_zero : μ s = 0) :\n  (λ x, ite (x ∈ s) (f x) (g x)) =ᵐ[μ] g :=\nbegin\n  have h_ss : sᶜ ⊆ {a : α | ite (a ∈ s) (f a) (g a) = g a},\n    from λ x hx, by simp [(set.mem_compl_iff _ _).mp hx],\n  refine measure_mono_null _ hs_zero,\n  nth_rewrite 0 ←compl_compl s,\n  rwa set.compl_subset_compl,\nend\n\nlemma ite_ae_eq_of_measure_compl_zero {γ} (f : α → γ) (g : α → γ) (s : set α) (hs_zero : μ sᶜ = 0) :\n  (λ x, ite (x ∈ s) (f x) (g x)) =ᵐ[μ] f :=\nby { filter_upwards [hs_zero], intros, split_ifs, refl }\n\nnamespace measure\n\n/-- A measure is called finite at filter `f` if it is finite at some set `s ∈ f`.\nEquivalently, it is eventually finite at `s` in `f.lift' powerset`. -/\ndef finite_at_filter {m0 : measurable_space α} (μ : measure α) (f : filter α) : Prop :=\n∃ s ∈ f, μ s < ∞\n\nlemma finite_at_filter_of_finite {m0 : measurable_space α} (μ : measure α) [is_finite_measure μ]\n  (f : filter α) :\n  μ.finite_at_filter f :=\n⟨univ, univ_mem, measure_lt_top μ univ⟩\n\nlemma finite_at_filter.exists_mem_basis {f : filter α} (hμ : finite_at_filter μ f)\n  {p : ι → Prop} {s : ι → set α} (hf : f.has_basis p s) :\n  ∃ i (hi : p i), μ (s i) < ∞ :=\n(hf.exists_iff (λ s t hst ht, (measure_mono hst).trans_lt ht)).1 hμ\n\nlemma finite_at_bot {m0 : measurable_space α} (μ : measure α) : μ.finite_at_filter ⊥ :=\n⟨∅, mem_bot, by simp only [measure_empty, with_top.zero_lt_top]⟩\n\n/-- `μ` has finite spanning sets in `C` if there is a countable sequence of sets in `C` that have\n  finite measures. This structure is a type, which is useful if we want to record extra properties\n  about the sets, such as that they are monotone.\n  `sigma_finite` is defined in terms of this: `μ` is σ-finite if there exists a sequence of\n  finite spanning sets in the collection of all measurable sets. -/\n@[protect_proj, nolint has_inhabited_instance]\nstructure finite_spanning_sets_in {m0 : measurable_space α} (μ : measure α) (C : set (set α)) :=\n(set : ℕ → set α)\n(set_mem : ∀ i, set i ∈ C)\n(finite : ∀ i, μ (set i) < ∞)\n(spanning : (⋃ i, set i) = univ)\n\nend measure\nopen measure\n\n/-- A measure `μ` is called σ-finite if there is a countable collection of sets\n `{ A i | i ∈ ℕ }` such that `μ (A i) < ∞` and `⋃ i, A i = s`. -/\nclass sigma_finite {m0 : measurable_space α} (μ : measure α) : Prop :=\n(out' : nonempty (μ.finite_spanning_sets_in univ))\n\ntheorem sigma_finite_iff :\n  sigma_finite μ ↔ nonempty (μ.finite_spanning_sets_in univ) :=\n⟨λ h, h.1, λ h, ⟨h⟩⟩\n\ntheorem sigma_finite.out (h : sigma_finite μ) :\n  nonempty (μ.finite_spanning_sets_in univ) := h.1\n\ninclude m0\n\n/-- If `μ` is σ-finite it has finite spanning sets in the collection of all measurable sets. -/\ndef measure.to_finite_spanning_sets_in (μ : measure α) [h : sigma_finite μ] :\n  μ.finite_spanning_sets_in {s | measurable_set s} :=\n{ set := λ n, to_measurable μ (h.out.some.set n),\n  set_mem := λ n, measurable_set_to_measurable _ _,\n  finite := λ n, by { rw measure_to_measurable, exact h.out.some.finite n },\n  spanning := eq_univ_of_subset (Union_subset_Union $ λ n, subset_to_measurable _ _)\n    h.out.some.spanning }\n\n/-- A noncomputable way to get a monotone collection of sets that span `univ` and have finite\n  measure using `classical.some`. This definition satisfies monotonicity in addition to all other\n  properties in `sigma_finite`. -/\ndef spanning_sets (μ : measure α) [sigma_finite μ] (i : ℕ) : set α :=\naccumulate μ.to_finite_spanning_sets_in.set i\n\nlemma monotone_spanning_sets (μ : measure α) [sigma_finite μ] :\n  monotone (spanning_sets μ) :=\nmonotone_accumulate\n\nlemma measurable_spanning_sets (μ : measure α) [sigma_finite μ] (i : ℕ) :\n  measurable_set (spanning_sets μ i) :=\nmeasurable_set.Union $ λ j, measurable_set.Union_Prop $\n  λ hij, μ.to_finite_spanning_sets_in.set_mem j\n\nlemma measure_spanning_sets_lt_top (μ : measure α) [sigma_finite μ] (i : ℕ) :\n  μ (spanning_sets μ i) < ∞ :=\nmeasure_bUnion_lt_top (finite_le_nat i) $ λ j _, (μ.to_finite_spanning_sets_in.finite j).ne\n\nlemma Union_spanning_sets (μ : measure α) [sigma_finite μ] :\n  (⋃ i : ℕ, spanning_sets μ i) = univ :=\nby simp_rw [spanning_sets, Union_accumulate, μ.to_finite_spanning_sets_in.spanning]\n\nlemma is_countably_spanning_spanning_sets (μ : measure α) [sigma_finite μ] :\n  is_countably_spanning (range (spanning_sets μ)) :=\n⟨spanning_sets μ, mem_range_self, Union_spanning_sets μ⟩\n\n/-- `spanning_sets_index μ x` is the least `n : ℕ` such that `x ∈ spanning_sets μ n`. -/\ndef spanning_sets_index (μ : measure α) [sigma_finite μ] (x : α) : ℕ :=\nnat.find $ Union_eq_univ_iff.1 (Union_spanning_sets μ) x\n\nlemma measurable_spanning_sets_index (μ : measure α) [sigma_finite μ] :\n  measurable (spanning_sets_index μ) :=\nmeasurable_find _ $ measurable_spanning_sets μ\n\nlemma preimage_spanning_sets_index_singleton (μ : measure α) [sigma_finite μ] (n : ℕ) :\n  spanning_sets_index μ ⁻¹' {n} = disjointed (spanning_sets μ) n :=\npreimage_find_eq_disjointed _ _ _\n\nlemma spanning_sets_index_eq_iff (μ : measure α) [sigma_finite μ] {x : α} {n : ℕ} :\n  spanning_sets_index μ x = n ↔ x ∈ disjointed (spanning_sets μ) n :=\nby convert set.ext_iff.1 (preimage_spanning_sets_index_singleton μ n) x\n\nlemma mem_disjointed_spanning_sets_index (μ : measure α) [sigma_finite μ] (x : α) :\n  x ∈ disjointed (spanning_sets μ) (spanning_sets_index μ x) :=\n(spanning_sets_index_eq_iff μ).1 rfl\n\nlemma mem_spanning_sets_index (μ : measure α) [sigma_finite μ] (x : α) :\n  x ∈ spanning_sets μ (spanning_sets_index μ x) :=\ndisjointed_subset _ _ (mem_disjointed_spanning_sets_index μ x)\n\nlemma mem_spanning_sets_of_index_le (μ : measure α) [sigma_finite μ] (x : α)\n  {n : ℕ} (hn : spanning_sets_index μ x ≤ n) :\n  x ∈ spanning_sets μ n :=\nmonotone_spanning_sets μ hn (mem_spanning_sets_index μ x)\n\nlemma eventually_mem_spanning_sets (μ : measure α) [sigma_finite μ] (x : α) :\n  ∀ᶠ n in at_top, x ∈ spanning_sets μ n :=\neventually_at_top.2 ⟨spanning_sets_index μ x, λ b, mem_spanning_sets_of_index_le μ x⟩\n\nlemma ae_of_forall_measure_lt_top_ae_restrict {μ : measure α} [sigma_finite μ] (P : α → Prop)\n  (h : ∀ s, measurable_set s → μ s < ∞ → ∀ᵐ x ∂(μ.restrict s), P x) :\n  ∀ᵐ x ∂μ, P x :=\nbegin\n  have : ∀ n, ∀ᵐ x ∂μ, x ∈ spanning_sets μ n → P x,\n  { assume n,\n    have := h (spanning_sets μ n) (measurable_spanning_sets _ _) (measure_spanning_sets_lt_top _ _),\n    rwa ae_restrict_iff' (measurable_spanning_sets _ _) at this },\n  filter_upwards [ae_all_iff.2 this],\n  assume x hx,\n  exact hx _ (mem_spanning_sets_index _ _),\nend\n\nomit m0\n\nnamespace measure\n\nlemma supr_restrict_spanning_sets [sigma_finite μ] (hs : measurable_set s) :\n  (⨆ i, μ.restrict (spanning_sets μ i) s) = μ s :=\nbegin\n  convert (restrict_Union_apply_eq_supr (measurable_spanning_sets μ) _ hs).symm,\n  { simp [Union_spanning_sets] },\n  { exact directed_of_sup (monotone_spanning_sets μ) }\nend\n\nnamespace finite_spanning_sets_in\n\nvariables {C D : set (set α)}\n\n/-- If `μ` has finite spanning sets in `C` and `C ∩ {s | μ s < ∞} ⊆ D` then `μ` has finite spanning\nsets in `D`. -/\nprotected def mono' (h : μ.finite_spanning_sets_in C) (hC : C ∩ {s | μ s < ∞} ⊆ D) :\n  μ.finite_spanning_sets_in D :=\n⟨h.set, λ i, hC ⟨h.set_mem i, h.finite i⟩, h.finite, h.spanning⟩\n\n/-- If `μ` has finite spanning sets in `C` and `C ⊆ D` then `μ` has finite spanning sets in `D`. -/\nprotected def mono (h : μ.finite_spanning_sets_in C) (hC : C ⊆ D) : μ.finite_spanning_sets_in D :=\nh.mono' (λ s hs, hC hs.1)\n\n/-- If `μ` has finite spanning sets in the collection of measurable sets `C`, then `μ` is σ-finite.\n-/\nprotected lemma sigma_finite (h : μ.finite_spanning_sets_in C) :\n  sigma_finite μ :=\n⟨⟨h.mono $ subset_univ C⟩⟩\n\n/-- An extensionality for measures. It is `ext_of_generate_from_of_Union` formulated in terms of\n`finite_spanning_sets_in`. -/\nprotected lemma ext {ν : measure α} {C : set (set α)} (hA : ‹_› = generate_from C)\n  (hC : is_pi_system C) (h : μ.finite_spanning_sets_in C) (h_eq : ∀ s ∈ C, μ s = ν s) : μ = ν :=\next_of_generate_from_of_Union C _ hA hC h.spanning h.set_mem (λ i, (h.finite i).ne) h_eq\n\nprotected lemma is_countably_spanning (h : μ.finite_spanning_sets_in C) : is_countably_spanning C :=\n⟨h.set, h.set_mem, h.spanning⟩\n\nend finite_spanning_sets_in\n\nlemma sigma_finite_of_countable {S : set (set α)} (hc : countable S)\n  (hμ : ∀ s ∈ S, μ s < ∞) (hU : ⋃₀ S = univ) :\n  sigma_finite μ :=\nbegin\n  obtain ⟨s, hμ, hs⟩ : ∃ s : ℕ → set α, (∀ n, μ (s n) < ∞) ∧ (⋃ n, s n) = univ,\n    from (@exists_seq_cover_iff_countable _ (λ x, μ x < ⊤) ⟨∅, by simp⟩).2 ⟨S, hc, hμ, hU⟩,\n  exact ⟨⟨⟨λ n, s n, λ n, trivial, hμ, hs⟩⟩⟩,\nend\n\n/-- Given measures `μ`, `ν` where `ν ≤ μ`, `finite_spanning_sets_in.of_le` provides the induced\n`finite_spanning_set` with respect to `ν` from a `finite_spanning_set` with respect to `μ`. -/\ndef finite_spanning_sets_in.of_le (h : ν ≤ μ) {C : set (set α)}\n  (S : μ.finite_spanning_sets_in C) : ν.finite_spanning_sets_in C :=\n{ set := S.set,\n  set_mem := S.set_mem,\n  finite := λ n, lt_of_le_of_lt (le_iff'.1 h _) (S.finite n),\n  spanning := S.spanning }\n\nlemma sigma_finite_of_le (μ : measure α) [hs : sigma_finite μ]\n  (h : ν ≤ μ) : sigma_finite ν :=\n⟨hs.out.map $ finite_spanning_sets_in.of_le h⟩\n\nend measure\n\ninclude m0\n\n/-- Every finite measure is σ-finite. -/\n@[priority 100]\ninstance is_finite_measure.to_sigma_finite (μ : measure α) [is_finite_measure μ] :\n  sigma_finite μ :=\n⟨⟨⟨λ _, univ, λ _, trivial, λ _, measure_lt_top μ _, Union_const _⟩⟩⟩\n\ninstance restrict.sigma_finite (μ : measure α) [sigma_finite μ] (s : set α) :\n  sigma_finite (μ.restrict s) :=\nbegin\n  refine ⟨⟨⟨spanning_sets μ, λ _, trivial, λ i, _, Union_spanning_sets μ⟩⟩⟩,\n  rw [restrict_apply (measurable_spanning_sets μ i)],\n  exact (measure_mono $ inter_subset_left _ _).trans_lt (measure_spanning_sets_lt_top μ i)\nend\n\ninstance sum.sigma_finite {ι} [fintype ι] (μ : ι → measure α) [∀ i, sigma_finite (μ i)] :\n  sigma_finite (sum μ) :=\nbegin\n  haveI : encodable ι := fintype.encodable ι,\n  have : ∀ n, measurable_set (⋂ (i : ι), spanning_sets (μ i) n) :=\n    λ n, measurable_set.Inter (λ i, measurable_spanning_sets (μ i) n),\n  refine ⟨⟨⟨λ n, ⋂ i, spanning_sets (μ i) n, λ _, trivial, λ n, _, _⟩⟩⟩,\n  { rw [sum_apply _ (this n), tsum_fintype, ennreal.sum_lt_top_iff],\n    rintro i -,\n    exact (measure_mono $ Inter_subset _ i).trans_lt (measure_spanning_sets_lt_top (μ i) n) },\n  { rw [Union_Inter_of_monotone], simp_rw [Union_spanning_sets, Inter_univ],\n    exact λ i, monotone_spanning_sets (μ i), }\nend\n\ninstance add.sigma_finite (μ ν : measure α) [sigma_finite μ] [sigma_finite ν] :\n  sigma_finite (μ + ν) :=\nby { rw [← sum_cond], refine @sum.sigma_finite _ _ _ _ _ (bool.rec _ _); simpa }\n\nlemma sigma_finite.of_map (μ : measure α) {f : α → β} (hf : measurable f)\n  (h : sigma_finite (map f μ)) :\n  sigma_finite μ :=\n⟨⟨⟨λ n, f ⁻¹' (spanning_sets (map f μ) n),\n   λ n, trivial,\n   λ n, by simp only [← map_apply hf, measurable_spanning_sets, measure_spanning_sets_lt_top],\n   by rw [← preimage_Union, Union_spanning_sets, preimage_univ]⟩⟩⟩\n\n/-- A measure is called locally finite if it is finite in some neighborhood of each point. -/\nclass is_locally_finite_measure [topological_space α] (μ : measure α) : Prop :=\n(finite_at_nhds : ∀ x, μ.finite_at_filter (𝓝 x))\n\n@[priority 100] -- see Note [lower instance priority]\ninstance is_finite_measure.to_is_locally_finite_measure [topological_space α] (μ : measure α)\n  [is_finite_measure μ] :\n  is_locally_finite_measure μ :=\n⟨λ x, finite_at_filter_of_finite _ _⟩\n\nlemma measure.finite_at_nhds [topological_space α] (μ : measure α)\n  [is_locally_finite_measure μ] (x : α) :\n  μ.finite_at_filter (𝓝 x) :=\nis_locally_finite_measure.finite_at_nhds x\n\nlemma measure.smul_finite (μ : measure α) [is_finite_measure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) :\n  is_finite_measure (c • μ) :=\nbegin\n  lift c to ℝ≥0 using hc,\n  exact measure_theory.is_finite_measure_smul_nnreal,\nend\n\nlemma measure.exists_is_open_measure_lt_top [topological_space α] (μ : measure α)\n  [is_locally_finite_measure μ] (x : α) :\n  ∃ s : set α, x ∈ s ∧ is_open s ∧ μ s < ∞ :=\nby simpa only [exists_prop, and.assoc]\n  using (μ.finite_at_nhds x).exists_mem_basis (nhds_basis_opens x)\n\ninstance is_locally_finite_measure_smul_nnreal [topological_space α] (μ : measure α)\n  [is_locally_finite_measure μ] (c : ℝ≥0) : is_locally_finite_measure (c • μ) :=\nbegin\n  refine ⟨λ x, _⟩,\n  rcases μ.exists_is_open_measure_lt_top x with ⟨o, xo, o_open, μo⟩,\n  refine ⟨o, o_open.mem_nhds xo, _⟩,\n  apply ennreal.mul_lt_top _ μo.ne,\n  simp only [ennreal.coe_ne_top, ennreal.coe_of_nnreal_hom, ne.def, not_false_iff],\nend\n\nomit m0\n\n@[priority 100] -- see Note [lower instance priority]\ninstance sigma_finite_of_locally_finite [topological_space α]\n  [topological_space.second_countable_topology α] [is_locally_finite_measure μ] :\n  sigma_finite μ :=\nbegin\n  choose s hsx hsμ using μ.finite_at_nhds,\n  rcases topological_space.countable_cover_nhds hsx with ⟨t, htc, htU⟩,\n  refine measure.sigma_finite_of_countable (htc.image s) (ball_image_iff.2 $ λ x hx, hsμ x) _,\n  rwa sUnion_image\nend\n\n/-- If a set has zero measure in a neighborhood of each of its points, then it has zero measure\nin a second-countable space. -/\nlemma null_of_locally_null [topological_space α] [topological_space.second_countable_topology α]\n  (s : set α) (hs : ∀ x ∈ s, ∃ u ∈ 𝓝[s] x, μ (s ∩ u) = 0) :\n  μ s = 0 :=\nbegin\n  choose! u hu using hs,\n  obtain ⟨t, ts, t_count, ht⟩ : ∃ t ⊆ s, t.countable ∧ s ⊆ ⋃ x ∈ t, u x :=\n    topological_space.countable_cover_nhds_within (λ x hx, (hu x hx).1),\n  replace ht : s ⊆ ⋃ x ∈ t, s ∩ u x,\n    by { rw ← inter_bUnion, exact subset_inter (subset.refl _) ht },\n  apply measure_mono_null ht,\n  exact (measure_bUnion_null_iff t_count).2 (λ x hx, (hu x (ts hx)).2),\nend\n\n/-- If two finite measures give the same mass to the whole space and coincide on a π-system made\nof measurable sets, then they coincide on all sets in the σ-algebra generated by the π-system. -/\nlemma ext_on_measurable_space_of_generate_finite {α} (m₀ : measurable_space α)\n  {μ ν : measure α} [is_finite_measure μ]\n  (C : set (set α)) (hμν : ∀ s ∈ C, μ s = ν s) {m : measurable_space α}\n  (h : m ≤ m₀) (hA : m = measurable_space.generate_from C) (hC : is_pi_system C)\n  (h_univ : μ set.univ = ν set.univ) {s : set α} (hs : m.measurable_set' s) :\n  μ s = ν s :=\nbegin\n  haveI : is_finite_measure ν := begin\n     constructor,\n     rw ← h_univ,\n     apply is_finite_measure.measure_univ_lt_top,\n  end,\n  refine induction_on_inter hA hC (by simp) hμν _ _ hs,\n  { intros t h1t h2t,\n    have h1t_ : @measurable_set α m₀ t, from h _ h1t,\n    rw [@measure_compl α m₀ μ t h1t_ (@measure_ne_top α m₀ μ _ t),\n      @measure_compl α m₀ ν t h1t_ (@measure_ne_top α m₀ ν _ t), h_univ, h2t], },\n  { intros f h1f h2f h3f,\n    have h2f_ : ∀ (i : ℕ), @measurable_set α m₀ (f i), from (λ i, h _ (h2f i)),\n    have h_Union : @measurable_set α m₀ (⋃ (i : ℕ), f i),from @measurable_set.Union α ℕ m₀ _ f h2f_,\n    simp [measure_Union, h_Union, h1f, h3f, h2f_], },\nend\n\n/-- Two finite measures are equal if they are equal on the π-system generating the σ-algebra\n  (and `univ`). -/\nlemma ext_of_generate_finite (C : set (set α)) (hA : m0 = generate_from C) (hC : is_pi_system C)\n  [is_finite_measure μ] (hμν : ∀ s ∈ C, μ s = ν s) (h_univ : μ univ = ν univ) :\n  μ = ν :=\nmeasure.ext (λ s hs, ext_on_measurable_space_of_generate_finite m0 C hμν le_rfl hA hC h_univ hs)\n\nnamespace measure\n\nsection disjointed\n\ninclude m0\n\n/-- Given `S : μ.finite_spanning_sets_in {s | measurable_set s}`,\n`finite_spanning_sets_in.disjointed` provides a `finite_spanning_sets_in {s | measurable_set s}`\nsuch that its underlying sets are pairwise disjoint. -/\nprotected def finite_spanning_sets_in.disjointed {μ : measure α}\n  (S : μ.finite_spanning_sets_in {s | measurable_set s}) :\n   μ.finite_spanning_sets_in {s | measurable_set s} :=\n⟨disjointed S.set, measurable_set.disjointed S.set_mem,\n  λ n, lt_of_le_of_lt (measure_mono (disjointed_subset S.set n)) (S.finite _),\n  S.spanning ▸ Union_disjointed⟩\n\nlemma finite_spanning_sets_in.disjointed_set_eq {μ : measure α}\n  (S : μ.finite_spanning_sets_in {s | measurable_set s}) :\n  S.disjointed.set = disjointed S.set :=\nrfl\n\nlemma exists_eq_disjoint_finite_spanning_sets_in\n  (μ ν : measure α) [sigma_finite μ] [sigma_finite ν] :\n  ∃ (S : μ.finite_spanning_sets_in {s | measurable_set s})\n    (T : ν.finite_spanning_sets_in {s | measurable_set s}),\n    S.set = T.set ∧ pairwise (disjoint on S.set) :=\nlet S := (μ + ν).to_finite_spanning_sets_in.disjointed in\n⟨S.of_le (measure.le_add_right le_rfl), S.of_le (measure.le_add_left le_rfl),\n  rfl, disjoint_disjointed _⟩\n\nend disjointed\n\nnamespace finite_at_filter\n\nvariables {f g : filter α}\n\nlemma filter_mono (h : f ≤ g) : μ.finite_at_filter g → μ.finite_at_filter f :=\nλ ⟨s, hs, hμ⟩, ⟨s, h hs, hμ⟩\n\nlemma inf_of_left (h : μ.finite_at_filter f) : μ.finite_at_filter (f ⊓ g) :=\nh.filter_mono inf_le_left\n\nlemma inf_of_right (h : μ.finite_at_filter g) : μ.finite_at_filter (f ⊓ g) :=\nh.filter_mono inf_le_right\n\n@[simp] lemma inf_ae_iff : μ.finite_at_filter (f ⊓ μ.ae) ↔ μ.finite_at_filter f :=\nbegin\n  refine ⟨_, λ h, h.filter_mono inf_le_left⟩,\n  rintros ⟨s, ⟨t, ht, u, hu, rfl⟩, hμ⟩,\n  suffices : μ t ≤ μ (t ∩ u), from ⟨t, ht, this.trans_lt hμ⟩,\n  exact measure_mono_ae (mem_of_superset hu (λ x hu ht, ⟨ht, hu⟩))\nend\n\nalias inf_ae_iff ↔ measure_theory.measure.finite_at_filter.of_inf_ae _\n\nlemma filter_mono_ae (h : f ⊓ μ.ae ≤ g) (hg : μ.finite_at_filter g) : μ.finite_at_filter f :=\ninf_ae_iff.1 (hg.filter_mono h)\n\nprotected lemma measure_mono (h : μ ≤ ν) : ν.finite_at_filter f → μ.finite_at_filter f :=\nλ ⟨s, hs, hν⟩, ⟨s, hs, (measure.le_iff'.1 h s).trans_lt hν⟩\n\n@[mono] protected lemma mono (hf : f ≤ g) (hμ : μ ≤ ν) :\n  ν.finite_at_filter g → μ.finite_at_filter f :=\nλ h, (h.filter_mono hf).measure_mono hμ\n\nprotected lemma eventually (h : μ.finite_at_filter f) : ∀ᶠ s in f.lift' powerset, μ s < ∞ :=\n(eventually_lift'_powerset' $ λ s t hst ht, (measure_mono hst).trans_lt ht).2 h\n\nlemma filter_sup : μ.finite_at_filter f → μ.finite_at_filter g → μ.finite_at_filter (f ⊔ g) :=\nλ ⟨s, hsf, hsμ⟩ ⟨t, htg, htμ⟩,\n ⟨s ∪ t, union_mem_sup hsf htg, (measure_union_le s t).trans_lt (ennreal.add_lt_top.2 ⟨hsμ, htμ⟩)⟩\n\nend finite_at_filter\n\nlemma finite_at_nhds_within [topological_space α] {m0 : measurable_space α} (μ : measure α)\n  [is_locally_finite_measure μ] (x : α) (s : set α) :\n  μ.finite_at_filter (𝓝[s] x) :=\n(finite_at_nhds μ x).inf_of_left\n\n@[simp] lemma finite_at_principal : μ.finite_at_filter (𝓟 s) ↔ μ s < ∞ :=\n⟨λ ⟨t, ht, hμ⟩, (measure_mono ht).trans_lt hμ, λ h, ⟨s, mem_principal_self s, h⟩⟩\n\nlemma is_locally_finite_measure_of_le [topological_space α] {m : measurable_space α}\n  {μ ν : measure α} [H : is_locally_finite_measure μ] (h : ν ≤ μ) :\n  is_locally_finite_measure ν :=\nlet F := H.finite_at_nhds in ⟨λ x, (F x).measure_mono h⟩\n\n/-! ### Subtraction of measures -/\n\n/-- The measure `μ - ν` is defined to be the least measure `τ` such that `μ ≤ τ + ν`.\nIt is the equivalent of `(μ - ν) ⊔ 0` if `μ` and `ν` were signed measures.\nCompare with `ennreal.has_sub`.\nSpecifically, note that if you have `α = {1,2}`, and  `μ {1} = 2`, `μ {2} = 0`, and\n`ν {2} = 2`, `ν {1} = 0`, then `(μ - ν) {1, 2} = 2`. However, if `μ ≤ ν`, and\n`ν univ ≠ ∞`, then `(μ - ν) + ν = μ`. -/\nnoncomputable instance has_sub {α : Type*} [measurable_space α] : has_sub (measure α) :=\n⟨λ μ ν, Inf {τ | μ ≤ τ + ν} ⟩\n\nsection measure_sub\n\nlemma sub_def : μ - ν = Inf {d | μ ≤ d + ν} := rfl\n\nlemma sub_eq_zero_of_le (h : μ ≤ ν) : μ - ν = 0 :=\nbegin\n  rw [← nonpos_iff_eq_zero', measure.sub_def],\n  apply @Inf_le (measure α) _ _,\n  simp [h],\nend\n\n/-- This application lemma only works in special circumstances. Given knowledge of\nwhen `μ ≤ ν` and `ν ≤ μ`, a more general application lemma can be written. -/\nlemma sub_apply [is_finite_measure ν] (h₁ : measurable_set s) (h₂ : ν ≤ μ) :\n  (μ - ν) s = μ s - ν s :=\nbegin\n  -- We begin by defining `measure_sub`, which will be equal to `(μ - ν)`.\n  let measure_sub : measure α := @measure_theory.measure.of_measurable α _\n    (λ (t : set α) (h_t_measurable_set : measurable_set t), (μ t - ν t))\n    begin\n      simp\n    end\n    begin\n      intros g h_meas h_disj, simp only, rw ennreal.tsum_sub,\n      repeat { rw ← measure_theory.measure_Union h_disj h_meas },\n      exacts [measure_theory.measure_ne_top _ _, λ i, h₂ _ (h_meas _)]\n    end,\n  -- Now, we demonstrate `μ - ν = measure_sub`, and apply it.\n  begin\n    have h_measure_sub_add : (ν + measure_sub = μ),\n    { ext t h_t_measurable_set,\n      simp only [pi.add_apply, coe_add],\n      rw [measure_theory.measure.of_measurable_apply _ h_t_measurable_set, add_comm,\n        tsub_add_cancel_of_le (h₂ t h_t_measurable_set)] },\n    have h_measure_sub_eq : (μ - ν) = measure_sub,\n    { rw measure_theory.measure.sub_def, apply le_antisymm,\n      { apply @Inf_le (measure α) measure.complete_semilattice_Inf,\n        simp [le_refl, add_comm, h_measure_sub_add] },\n      apply @le_Inf (measure α) measure.complete_semilattice_Inf,\n      intros d h_d, rw [← h_measure_sub_add, mem_set_of_eq, add_comm d] at h_d,\n      apply measure.le_of_add_le_add_left h_d },\n    rw h_measure_sub_eq,\n    apply measure.of_measurable_apply _ h₁,\n  end\nend\n\nlemma sub_add_cancel_of_le [is_finite_measure ν] (h₁ : ν ≤ μ) : μ - ν + ν = μ :=\nbegin\n  ext s h_s_meas,\n  rw [add_apply, sub_apply h_s_meas h₁, tsub_add_cancel_of_le (h₁ s h_s_meas)],\nend\n\nlemma sub_le : μ - ν ≤ μ :=\nInf_le (measure.le_add_right (le_refl _))\n\nend measure_sub\n\nlemma restrict_sub_eq_restrict_sub_restrict (h_meas_s : measurable_set s) :\n  (μ - ν).restrict s = (μ.restrict s) - (ν.restrict s) :=\nbegin\n  repeat {rw sub_def},\n  have h_nonempty : {d | μ ≤ d + ν}.nonempty,\n  { apply @set.nonempty_of_mem _ _ μ, rw mem_set_of_eq, intros t h_meas,\n    exact le_self_add },\n  rw restrict_Inf_eq_Inf_restrict h_nonempty h_meas_s,\n  apply le_antisymm,\n  { apply @Inf_le_Inf_of_forall_exists_le (measure α) _,\n    intros ν' h_ν'_in, rw mem_set_of_eq at h_ν'_in, apply exists.intro (ν'.restrict s),\n    split,\n    { rw mem_image, apply exists.intro (ν' + (⊤ : measure_theory.measure α).restrict sᶜ),\n      rw mem_set_of_eq,\n      split,\n      { rw [add_assoc, add_comm _ ν, ← add_assoc, measure_theory.measure.le_iff],\n        intros t h_meas_t,\n        have h_inter_inter_eq_inter : ∀ t' : set α , t ∩ t' ∩ t' = t ∩ t',\n        { intro t', rw set.inter_eq_self_of_subset_left, apply set.inter_subset_right t t' },\n        have h_meas_t_inter_s : measurable_set (t ∩ s) :=\n           h_meas_t.inter h_meas_s,\n        repeat { rw ← measure_inter_add_diff t h_meas_s, rw set.diff_eq },\n        refine add_le_add _ _,\n        { rw add_apply,\n          apply le_add_right _,\n          rw add_apply,\n          rw ← @restrict_eq_self _ _ μ s _ h_meas_t_inter_s (set.inter_subset_right _ _),\n          rw ← @restrict_eq_self _ _ ν s _ h_meas_t_inter_s (set.inter_subset_right _ _),\n          apply h_ν'_in _ h_meas_t_inter_s },\n        { rw add_apply,\n          have h_meas_inter_compl :=\n            h_meas_t.inter (measurable_set.compl h_meas_s),\n          rw [restrict_apply h_meas_inter_compl, h_inter_inter_eq_inter sᶜ],\n          have h_mu_le_add_top : μ ≤ ν' + ν + ⊤,\n          { rw add_comm,\n            have h_le_top : μ ≤ ⊤ := le_top,\n            apply (λ t₂ h_meas, le_add_right (h_le_top t₂ h_meas)) },\n          apply h_mu_le_add_top _ h_meas_inter_compl } },\n      { ext1 t h_meas_t,\n        simp [restrict_apply h_meas_t,\n              restrict_apply (h_meas_t.inter h_meas_s),\n              set.inter_assoc] } },\n    { apply restrict_le_self } },\n  { apply @Inf_le_Inf_of_forall_exists_le (measure α) _,\n    intros s h_s_in, cases h_s_in with t h_t, cases h_t with h_t_in h_t_eq, subst s,\n    apply exists.intro (t.restrict s), split,\n    { rw [set.mem_set_of_eq, ← restrict_add],\n      apply restrict_mono (set.subset.refl _) h_t_in },\n    { apply le_refl _ } },\nend\n\nlemma sub_apply_eq_zero_of_restrict_le_restrict\n  (h_le : μ.restrict s ≤ ν.restrict s) (h_meas_s : measurable_set s) :\n  (μ - ν) s = 0 :=\nbegin\n  rw [← restrict_apply_self _ h_meas_s, restrict_sub_eq_restrict_sub_restrict,\n      sub_eq_zero_of_le],\n  repeat {simp [*]},\nend\n\ninstance is_finite_measure_sub [is_finite_measure μ] : is_finite_measure (μ - ν) :=\n{ measure_univ_lt_top := lt_of_le_of_lt\n    (measure.sub_le set.univ measurable_set.univ) (measure_lt_top _ _) }\n\nend measure\n\nend measure_theory\n\nopen measure_theory measure_theory.measure\n\nnamespace measurable_embedding\n\nvariables {m0 : measurable_space α} {m1 : measurable_space β} {f : α → β}\n  (hf : measurable_embedding f)\ninclude hf\n\ntheorem map_apply (μ : measure α) (s : set β) : map f μ s = μ (f ⁻¹' s) :=\nbegin\n  refine le_antisymm _ (le_map_apply hf.measurable s),\n  set t := f '' (to_measurable μ (f ⁻¹' s)) ∪ (range f)ᶜ,\n  have htm : measurable_set t,\n    from (hf.measurable_set_image.2 $ measurable_set_to_measurable _ _).union\n      hf.measurable_set_range.compl,\n  have hst : s ⊆ t,\n  { rw [subset_union_compl_iff_inter_subset, ← image_preimage_eq_inter_range],\n    exact image_subset _ (subset_to_measurable _ _) },\n  have hft : f ⁻¹' t = to_measurable μ (f ⁻¹' s),\n    by rw [preimage_union, preimage_compl, preimage_range, compl_univ, union_empty,\n      hf.injective.preimage_image],\n  calc map f μ s ≤ map f μ t : measure_mono hst\n            ... = μ (f ⁻¹' s) :\n    by rw [map_apply hf.measurable htm, hft, measure_to_measurable]\nend\n\nlemma map_comap (μ : measure β) : map f (comap f μ) = μ.restrict (range f) :=\nbegin\n  ext1 t ht,\n  rw [hf.map_apply, comap_apply f hf.injective hf.measurable_set_image' _ (hf.measurable ht),\n    image_preimage_eq_inter_range, restrict_apply ht]\nend\n\nlemma comap_apply (μ : measure β) (s : set α) : comap f μ s = μ (f '' s) :=\ncalc comap f μ s = comap f μ (f ⁻¹' (f '' s)) : by rw hf.injective.preimage_image\n... = map f (comap f μ) (f '' s) : (hf.map_apply _ _).symm\n... = μ (f '' s) : by rw [hf.map_comap, restrict_apply' hf.measurable_set_range,\n  inter_eq_self_of_subset_left (image_subset_range _ _)]\n\nlemma ae_map_iff {p : β → Prop} {μ : measure α} : (∀ᵐ x ∂(map f μ), p x) ↔ ∀ᵐ x ∂μ, p (f x) :=\nby simp only [ae_iff, hf.map_apply, preimage_set_of_eq]\n\nlemma restrict_map (μ : measure α) (s : set β) :\n  (map f μ).restrict s = map f (μ.restrict $ f ⁻¹' s) :=\nmeasure.ext $ λ t ht, by simp [hf.map_apply, ht, hf.measurable ht]\n\nend measurable_embedding\n\nsection subtype\n\nlemma comap_subtype_coe_apply {m0 : measurable_space α} {s : set α} (hs : measurable_set s)\n  (μ : measure α) (t : set s) :\n  comap coe μ t = μ (coe '' t) :=\n(measurable_embedding.subtype_coe hs).comap_apply _ _\n\nlemma map_comap_subtype_coe {m0 : measurable_space α} {s : set α} (hs : measurable_set s)\n  (μ : measure α) : map (coe : s → α) (comap coe μ) = μ.restrict s :=\nby rw [(measurable_embedding.subtype_coe hs).map_comap, subtype.range_coe]\n\nlemma ae_restrict_iff_subtype {m0 : measurable_space α} {μ : measure α} {s : set α}\n  (hs : measurable_set s) {p : α → Prop} :\n  (∀ᵐ x ∂(μ.restrict s), p x) ↔ ∀ᵐ x ∂(comap (coe : s → α) μ), p ↑x :=\nby rw [← map_comap_subtype_coe hs, (measurable_embedding.subtype_coe hs).ae_map_iff]\n\nvariables [measure_space α]\n\n/-!\n### Volume on `s : set α`\n-/\n\ninstance _root_.set_coe.measure_space (s : set α) : measure_space s :=\n⟨comap (coe : s → α) volume⟩\n\nlemma volume_set_coe_def (s : set α) : (volume : measure s) = comap (coe : s → α) volume := rfl\n\nlemma measurable_set.map_coe_volume {s : set α} (hs : measurable_set s) :\n  map (coe : s → α) volume = restrict volume s :=\nby rw [volume_set_coe_def, (measurable_embedding.subtype_coe hs).map_comap volume,\n  subtype.range_coe]\n\nlemma volume_image_subtype_coe {s : set α} (hs : measurable_set s) (t : set s) :\n  volume (coe '' t : set α) = volume t :=\n(comap_subtype_coe_apply hs volume t).symm\n\nend subtype\n\nnamespace measurable_equiv\n\n/-! Interactions of measurable equivalences and measures -/\n\nopen equiv measure_theory.measure\n\nvariables [measurable_space α] [measurable_space β] {μ : measure α} {ν : measure β}\n\n/-- If we map a measure along a measurable equivalence, we can compute the measure on all sets\n  (not just the measurable ones). -/\nprotected theorem map_apply (f : α ≃ᵐ β) (s : set β) : map f μ s = μ (f ⁻¹' s) :=\nf.measurable_embedding.map_apply _ _\n\n@[simp] lemma map_symm_map (e : α ≃ᵐ β) : map e.symm (map e μ) = μ :=\nby simp [map_map e.symm.measurable e.measurable]\n\n@[simp] lemma map_map_symm (e : α ≃ᵐ β) : map e (map e.symm ν) = ν :=\nby simp [map_map e.measurable e.symm.measurable]\n\nlemma map_measurable_equiv_injective (e : α ≃ᵐ β) : injective (map e) :=\nby { intros μ₁ μ₂ hμ, apply_fun map e.symm at hμ, simpa [map_symm_map e] using hμ }\n\nlemma map_apply_eq_iff_map_symm_apply_eq (e : α ≃ᵐ β) : map e μ = ν ↔ map e.symm ν = μ :=\nby rw [← (map_measurable_equiv_injective e).eq_iff, map_map_symm, eq_comm]\n\nlemma restrict_map (e : α ≃ᵐ β) (s : set β) : (map e μ).restrict s = map e (μ.restrict $ e ⁻¹' s) :=\ne.measurable_embedding.restrict_map _ _\n\nend measurable_equiv\n\n\nnamespace measure_theory\n\nlemma outer_measure.to_measure_zero [measurable_space α] : (0 : outer_measure α).to_measure\n  ((le_top).trans outer_measure.zero_caratheodory.symm.le) = 0 :=\nby rw [← measure.measure_univ_eq_zero, to_measure_apply _ _ measurable_set.univ,\n  outer_measure.coe_zero, pi.zero_apply]\n\nsection trim\n\n/-- Restriction of a measure to a sub-sigma algebra.\nIt is common to see a measure `μ` on a measurable space structure `m0` as being also a measure on\nany `m ≤ m0`. Since measures in mathlib have to be trimmed to the measurable space, `μ` itself\ncannot be a measure on `m`, hence the definition of `μ.trim hm`.\n\nThis notion is related to `outer_measure.trim`, see the lemma\n`to_outer_measure_trim_eq_trim_to_outer_measure`. -/\ndef measure.trim {m m0 : measurable_space α} (μ : @measure α m0) (hm : m ≤ m0) : @measure α m :=\n@outer_measure.to_measure α m μ.to_outer_measure (hm.trans (le_to_outer_measure_caratheodory μ))\n\n@[simp] lemma trim_eq_self [measurable_space α] {μ : measure α} : μ.trim le_rfl = μ :=\nby simp [measure.trim]\n\nvariables {m m0 : measurable_space α} {μ : measure α} {s : set α}\n\nlemma to_outer_measure_trim_eq_trim_to_outer_measure (μ : measure α) (hm : m ≤ m0) :\n  @measure.to_outer_measure _ m (μ.trim hm) = @outer_measure.trim _ m μ.to_outer_measure :=\nby rw [measure.trim, to_measure_to_outer_measure]\n\n@[simp] lemma zero_trim (hm : m ≤ m0) : (0 : measure α).trim hm = (0 : @measure α m) :=\nby simp [measure.trim, outer_measure.to_measure_zero]\n\nlemma trim_measurable_set_eq (hm : m ≤ m0) (hs : @measurable_set α m s) : μ.trim hm s = μ s :=\nby simp [measure.trim, hs]\n\nlemma le_trim (hm : m ≤ m0) : μ s ≤ μ.trim hm s :=\nby { simp_rw [measure.trim], exact (@le_to_measure_apply _ m _ _ _), }\n\nlemma measure_eq_zero_of_trim_eq_zero (hm : m ≤ m0) (h : μ.trim hm s = 0) : μ s = 0 :=\nle_antisymm ((le_trim hm).trans (le_of_eq h)) (zero_le _)\n\nlemma measure_trim_to_measurable_eq_zero {hm : m ≤ m0} (hs : μ.trim hm s = 0) :\n  μ (@to_measurable α m (μ.trim hm) s) = 0 :=\nmeasure_eq_zero_of_trim_eq_zero hm (by rwa measure_to_measurable)\n\nlemma ae_eq_of_ae_eq_trim {E} {hm : m ≤ m0} {f₁ f₂ : α → E}\n  (h12 : f₁ =ᶠ[@measure.ae α m (μ.trim hm)] f₂) :\n  f₁ =ᵐ[μ] f₂ :=\nmeasure_eq_zero_of_trim_eq_zero hm h12\n\nlemma restrict_trim (hm : m ≤ m0) (μ : measure α) (hs : @measurable_set α m s) :\n  @measure.restrict α m (μ.trim hm) s = (μ.restrict s).trim hm :=\nbegin\n  ext1 t ht,\n  rw [@measure.restrict_apply α m _ _ _ ht, trim_measurable_set_eq hm ht,\n    measure.restrict_apply (hm t ht),\n    trim_measurable_set_eq hm (@measurable_set.inter α m t s ht hs)],\nend\n\ninstance is_finite_measure_trim (hm : m ≤ m0) [is_finite_measure μ] :\n  is_finite_measure (μ.trim hm) :=\n{ measure_univ_lt_top :=\n    by { rw trim_measurable_set_eq hm (@measurable_set.univ _ m), exact measure_lt_top _ _, } }\n\nend trim\n\nend measure_theory\n\nopen_locale measure_theory\n\n/-!\n# Almost everywhere measurable functions\n\nA function is almost everywhere measurable if it coincides almost everywhere with a measurable\nfunction. This property, called `ae_measurable f μ`, is defined in the file `measure_space_def`.\nWe discuss several of its properties that are analogous to properties of measurable functions.\n-/\n\nsection\nopen measure_theory\n\nvariables [measurable_space α] [measurable_space β]\n{f g : α → β} {μ ν : measure α}\n\n@[nontriviality, measurability]\nlemma subsingleton.ae_measurable [subsingleton α] : ae_measurable f μ :=\nsubsingleton.measurable.ae_measurable\n\n@[nontriviality, measurability]\nlemma ae_measurable_of_subsingleton_codomain [subsingleton β] : ae_measurable f μ :=\n(measurable_of_subsingleton_codomain f).ae_measurable\n\n@[simp, measurability] lemma ae_measurable_zero_measure : ae_measurable f (0 : measure α) :=\nbegin\n  nontriviality α, inhabit α,\n  exact ⟨λ x, f (default α), measurable_const, rfl⟩\nend\n\nnamespace ae_measurable\n\nlemma mono_measure (h : ae_measurable f μ) (h' : ν ≤ μ) : ae_measurable f ν :=\n⟨h.mk f, h.measurable_mk, eventually.filter_mono (ae_mono h') h.ae_eq_mk⟩\n\nlemma mono_set {s t} (h : s ⊆ t) (ht : ae_measurable f (μ.restrict t)) :\n  ae_measurable f (μ.restrict s) :=\nht.mono_measure (restrict_mono h le_rfl)\n\nprotected lemma mono' (h : ae_measurable f μ) (h' : ν ≪ μ) : ae_measurable f ν :=\n⟨h.mk f, h.measurable_mk, h' h.ae_eq_mk⟩\n\nlemma ae_mem_imp_eq_mk {s} (h : ae_measurable f (μ.restrict s)) :\n  ∀ᵐ x ∂μ, x ∈ s → f x = h.mk f x :=\nae_imp_of_ae_restrict h.ae_eq_mk\n\nlemma ae_inf_principal_eq_mk {s} (h : ae_measurable f (μ.restrict s)) :\n  f =ᶠ[μ.ae ⊓ 𝓟 s] h.mk f :=\nle_ae_restrict h.ae_eq_mk\n\n@[measurability]\nlemma sum_measure [encodable ι] {μ : ι → measure α} (h : ∀ i, ae_measurable f (μ i)) :\n  ae_measurable f (sum μ) :=\nbegin\n  nontriviality β, inhabit β,\n  set s : ι → set α := λ i, to_measurable (μ i) {x | f x ≠ (h i).mk f x},\n  have hsμ : ∀ i, μ i (s i) = 0,\n  { intro i, rw measure_to_measurable, exact (h i).ae_eq_mk },\n  have hsm : measurable_set (⋂ i, s i),\n    from measurable_set.Inter (λ i, measurable_set_to_measurable _ _),\n  have hs : ∀ i x, x ∉ s i → f x = (h i).mk f x,\n  { intros i x hx, contrapose! hx, exact subset_to_measurable _ _ hx },\n  set g : α → β := (⋂ i, s i).piecewise (const α (default β)) f,\n  refine ⟨g, measurable_of_restrict_of_restrict_compl hsm _ _, ae_sum_iff.mpr $ λ i, _⟩,\n  { rw [restrict_piecewise], simp only [set.restrict, const], exact measurable_const },\n  { rw [restrict_piecewise_compl, compl_Inter],\n    intros t ht,\n    refine ⟨⋃ i, ((h i).mk f ⁻¹' t) ∩ (s i)ᶜ, measurable_set.Union $\n      λ i, (measurable_mk _ ht).inter (measurable_set_to_measurable _ _).compl, _⟩,\n    ext ⟨x, hx⟩,\n    simp only [mem_preimage, mem_Union, subtype.coe_mk, set.restrict, mem_inter_eq,\n      mem_compl_iff] at hx ⊢,\n    split,\n    { rintro ⟨i, hxt, hxs⟩, rwa hs _ _ hxs },\n    { rcases hx with ⟨i, hi⟩, rw hs _ _ hi, exact λ h, ⟨i, h, hi⟩ } },\n  { refine measure_mono_null (λ x (hx : f x ≠ g x), _) (hsμ i),\n    contrapose! hx, refine (piecewise_eq_of_not_mem _ _ _ _).symm,\n    exact λ h, hx (mem_Inter.1 h i) }\nend\n\n@[simp] lemma _root_.ae_measurable_sum_measure_iff [encodable ι] {μ : ι → measure α} :\n  ae_measurable f (sum μ) ↔ ∀ i, ae_measurable f (μ i) :=\n⟨λ h i, h.mono_measure (le_sum _ _), sum_measure⟩\n\n@[simp] lemma _root_.ae_measurable_add_measure_iff :\n  ae_measurable f (μ + ν) ↔ ae_measurable f μ ∧ ae_measurable f ν :=\nby { rw [← sum_cond, ae_measurable_sum_measure_iff, bool.forall_bool, and.comm], refl }\n\n@[measurability]\nlemma add_measure {f : α → β} (hμ : ae_measurable f μ) (hν : ae_measurable f ν) :\n  ae_measurable f (μ + ν) :=\nae_measurable_add_measure_iff.2 ⟨hμ, hν⟩\n\n@[measurability]\nprotected lemma Union [encodable ι] {s : ι → set α} (h : ∀ i, ae_measurable f (μ.restrict (s i))) :\n  ae_measurable f (μ.restrict (⋃ i, s i)) :=\n(sum_measure h).mono_measure $ restrict_Union_le\n\n@[simp] lemma _root_.ae_measurable_Union_iff [encodable ι] {s : ι → set α} :\n  ae_measurable f (μ.restrict (⋃ i, s i)) ↔ ∀ i, ae_measurable f (μ.restrict (s i)) :=\n⟨λ h i, h.mono_measure $ restrict_mono (subset_Union _ _) le_rfl, ae_measurable.Union⟩\n\n@[measurability]\nlemma smul_measure (h : ae_measurable f μ) (c : ℝ≥0∞) :\n  ae_measurable f (c • μ) :=\n⟨h.mk f, h.measurable_mk, ae_smul_measure h.ae_eq_mk c⟩\n\nlemma comp_measurable [measurable_space δ] {f : α → δ} {g : δ → β}\n  (hg : ae_measurable g (map f μ)) (hf : measurable f) : ae_measurable (g ∘ f) μ :=\n⟨hg.mk g ∘ f, hg.measurable_mk.comp hf, ae_eq_comp hf hg.ae_eq_mk⟩\n\nlemma comp_measurable' {δ} [measurable_space δ] {ν : measure δ} {f : α → δ} {g : δ → β}\n  (hg : ae_measurable g ν) (hf : measurable f) (h : map f μ ≪ ν) : ae_measurable (g ∘ f) μ :=\n(hg.mono' h).comp_measurable hf\n\n@[measurability]\nlemma prod_mk {γ : Type*} [measurable_space γ] {f : α → β} {g : α → γ}\n  (hf : ae_measurable f μ) (hg : ae_measurable g μ) : ae_measurable (λ x, (f x, g x)) μ :=\n⟨λ a, (hf.mk f a, hg.mk g a), hf.measurable_mk.prod_mk hg.measurable_mk,\n  eventually_eq.prod_mk hf.ae_eq_mk hg.ae_eq_mk⟩\n\nlemma subtype_mk (h : ae_measurable f μ) {s : set β} {hfs : ∀ x, f x ∈ s} (hs : measurable_set s) :\n  ae_measurable (cod_restrict f s hfs) μ :=\nbegin\n  nontriviality α, inhabit α,\n  rcases h with ⟨g, hgm, hg⟩,\n  rcases hs.exists_measurable_proj ⟨f (default α), hfs _⟩ with ⟨π, hπm, hπ⟩,\n  refine ⟨π ∘ g, hπm.comp hgm, hg.mono $ λ x hx, _⟩,\n  rw [comp_apply, ← hx, ← coe_cod_restrict_apply f s hfs, hπ]\nend\n\nprotected lemma null_measurable (h : ae_measurable f μ) : null_measurable f μ :=\nlet ⟨g, hgm, hg⟩ := h in hgm.null_measurable.congr hg.symm\n\nend ae_measurable\n\nlemma ae_measurable_iff_measurable [μ.is_complete] :\n  ae_measurable f μ ↔ measurable f :=\n⟨λ h, h.null_measurable.measurable_of_complete, λ h, h.ae_measurable⟩\n\nlemma measurable_embedding.ae_measurable_map_iff [measurable_space γ] {f : α → β}\n  (hf : measurable_embedding f) {μ : measure α} {g : β → γ} :\n  ae_measurable g (map f μ) ↔ ae_measurable (g ∘ f) μ :=\nbegin\n  refine ⟨λ H, H.comp_measurable hf.measurable, _⟩,\n  rintro ⟨g₁, hgm₁, heq⟩,\n  rcases hf.exists_measurable_extend hgm₁ (λ x, ⟨g x⟩) with ⟨g₂, hgm₂, rfl⟩,\n  exact ⟨g₂, hgm₂, hf.ae_map_iff.2 heq⟩\nend\n\nlemma measurable_embedding.ae_measurable_comp_iff [measurable_space γ] {g : β → γ}\n  (hg : measurable_embedding g) {μ : measure α} {f : α → β} :\n  ae_measurable (g ∘ f) μ ↔ ae_measurable f μ :=\nbegin\n  refine ⟨λ H, _, hg.measurable.comp_ae_measurable⟩,\n  suffices : ae_measurable ((range_splitting g ∘ range_factorization g) ∘ f) μ,\n    by rwa [(right_inverse_range_splitting hg.injective).comp_eq_id] at this,\n  exact hg.measurable_range_splitting.comp_ae_measurable (H.subtype_mk hg.measurable_set_range)\nend\n\nlemma ae_measurable_restrict_iff_comap_subtype {s : set α} (hs : measurable_set s)\n  {μ : measure α} {f : α → β} :\n  ae_measurable f (μ.restrict s) ↔ ae_measurable (f ∘ coe : s → β) (comap coe μ) :=\nby rw [← map_comap_subtype_coe hs, (measurable_embedding.subtype_coe hs).ae_measurable_map_iff]\n\n@[simp, to_additive] lemma ae_measurable_one [has_one β] : ae_measurable (λ a : α, (1 : β)) μ :=\nmeasurable_one.ae_measurable\n\n@[simp] lemma ae_measurable_smul_measure_iff {c : ℝ≥0∞} (hc : c ≠ 0) :\n  ae_measurable f (c • μ) ↔ ae_measurable f μ :=\n⟨λ h, ⟨h.mk f, h.measurable_mk, (ae_smul_measure_iff hc).1 h.ae_eq_mk⟩,\n  λ h, ⟨h.mk f, h.measurable_mk, (ae_smul_measure_iff hc).2 h.ae_eq_mk⟩⟩\n\nlemma ae_measurable_of_ae_measurable_trim {α} {m m0 : measurable_space α}\n  {μ : measure α} (hm : m ≤ m0) {f : α → β} (hf : ae_measurable f (μ.trim hm)) :\n  ae_measurable f μ :=\n⟨hf.mk f, measurable.mono hf.measurable_mk hm le_rfl, ae_eq_of_ae_eq_trim hf.ae_eq_mk⟩\n\nlemma ae_measurable_restrict_of_measurable_subtype {s : set α}\n  (hs : measurable_set s) (hf : measurable (λ x : s, f x)) : ae_measurable f (μ.restrict s) :=\n(ae_measurable_restrict_iff_comap_subtype hs).2 hf.ae_measurable\n\nlemma ae_measurable_map_equiv_iff [measurable_space γ] (e : α ≃ᵐ β) {f : β → γ} :\n  ae_measurable f (map e μ) ↔ ae_measurable (f ∘ e) μ :=\ne.measurable_embedding.ae_measurable_map_iff\n\nend\n\nnamespace is_compact\n\nvariables [topological_space α] [measurable_space α] {μ : measure α} {s : set α}\n\n/-- If `s` is a compact set and `μ` is finite at `𝓝 x` for every `x ∈ s`, then `s` admits an open\nsuperset of finite measure. -/\nlemma exists_open_superset_measure_lt_top' (h : is_compact s)\n  (hμ : ∀ x ∈ s, μ.finite_at_filter (𝓝 x)) :\n  ∃ U ⊇ s, is_open U ∧ μ U < ∞ :=\nbegin\n  refine is_compact.induction_on h _ _ _ _,\n  { use ∅, simp [superset] },\n  { rintro s t hst ⟨U, htU, hUo, hU⟩, exact ⟨U, hst.trans htU, hUo, hU⟩ },\n  { rintro s t ⟨U, hsU, hUo, hU⟩ ⟨V, htV, hVo, hV⟩,\n    refine ⟨U ∪ V, union_subset_union hsU htV, hUo.union hVo,\n      (measure_union_le _ _).trans_lt $ ennreal.add_lt_top.2 ⟨hU, hV⟩⟩ },\n  { intros x hx,\n    rcases (hμ x hx).exists_mem_basis (nhds_basis_opens _) with ⟨U, ⟨hx, hUo⟩, hU⟩,\n    exact ⟨U, nhds_within_le_nhds (hUo.mem_nhds hx), U, subset.rfl, hUo, hU⟩ }\nend\n\n/-- If `s` is a compact set and `μ` is a locally finite measure, then `s` admits an open superset of\nfinite measure. -/\nlemma exists_open_superset_measure_lt_top (h : is_compact s)\n  (μ : measure α) [is_locally_finite_measure μ] :\n  ∃ U ⊇ s, is_open U ∧ μ U < ∞ :=\nh.exists_open_superset_measure_lt_top' $ λ x hx, μ.finite_at_nhds x\n\nlemma measure_lt_top_of_nhds_within (h : is_compact s) (hμ : ∀ x ∈ s, μ.finite_at_filter (𝓝[s] x)) :\n  μ s < ∞ :=\nis_compact.induction_on h (by simp) (λ s t hst ht, (measure_mono hst).trans_lt ht)\n  (λ s t hs ht, (measure_union_le s t).trans_lt (ennreal.add_lt_top.2 ⟨hs, ht⟩)) hμ\n\nlemma measure_lt_top (h : is_compact s) {μ : measure α} [is_locally_finite_measure μ] :\n  μ s < ∞ :=\nh.measure_lt_top_of_nhds_within $ λ x hx, μ.finite_at_nhds_within _ _\n\nlemma measure_zero_of_nhds_within (hs : is_compact s) :\n  (∀ a ∈ s, ∃ t ∈ 𝓝[s] a, μ t = 0) → μ s = 0 :=\nby simpa only [← compl_mem_ae_iff] using hs.compl_mem_sets_of_nhds_within\n\nend is_compact\n\n/-- Compact covering of a `σ`-compact topological space as\n`measure_theory.measure.finite_spanning_sets_in`. -/\ndef measure_theory.measure.finite_spanning_sets_in_compact [topological_space α]\n  [sigma_compact_space α] {m : measurable_space α} (μ : measure α) [is_locally_finite_measure μ] :\n  μ.finite_spanning_sets_in {K | is_compact K} :=\n{ set := compact_covering α,\n  set_mem := is_compact_compact_covering α,\n  finite := λ n, (is_compact_compact_covering α n).measure_lt_top,\n  spanning := Union_compact_covering α }\n\n/-- A locally finite measure on a `σ`-compact topological space admits a finite spanning sequence\nof open sets. -/\ndef measure_theory.measure.finite_spanning_sets_in_open [topological_space α]\n  [sigma_compact_space α] {m : measurable_space α} (μ : measure α) [is_locally_finite_measure μ] :\n  μ.finite_spanning_sets_in {K | is_open K} :=\n{ set := λ n, ((is_compact_compact_covering α n).exists_open_superset_measure_lt_top μ).some,\n  set_mem := λ n,\n    ((is_compact_compact_covering α n).exists_open_superset_measure_lt_top μ).some_spec.snd.1,\n  finite := λ n,\n    ((is_compact_compact_covering α n).exists_open_superset_measure_lt_top μ).some_spec.snd.2,\n  spanning := eq_univ_of_subset (Union_subset_Union $ λ n,\n    ((is_compact_compact_covering α n).exists_open_superset_measure_lt_top μ).some_spec.fst)\n    (Union_compact_covering α) }\n\nsection measure_Ixx\n\nvariables [preorder α] [topological_space α] [compact_Icc_space α]\n  {m : measurable_space α} {μ : measure α} [is_locally_finite_measure μ] {a b : α}\n\nlemma measure_Icc_lt_top : μ (Icc a b) < ∞ := is_compact_Icc.measure_lt_top\n\nlemma measure_Ico_lt_top : μ (Ico a b) < ∞ :=\n(measure_mono Ico_subset_Icc_self).trans_lt measure_Icc_lt_top\n\nlemma measure_Ioc_lt_top : μ (Ioc a b) < ∞ :=\n(measure_mono Ioc_subset_Icc_self).trans_lt measure_Icc_lt_top\n\nlemma measure_Ioo_lt_top : μ (Ioo a b) < ∞ :=\n(measure_mono Ioo_subset_Icc_self).trans_lt measure_Icc_lt_top\n\nend measure_Ixx\n\nlemma metric.bounded.measure_lt_top [metric_space α] [proper_space α]\n  [measurable_space α] {μ : measure α} [is_locally_finite_measure μ] {s : set α}\n  (hs : metric.bounded s) :\n  μ s < ∞ :=\n(measure_mono subset_closure).trans_lt (metric.compact_iff_closed_bounded.2\n  ⟨is_closed_closure, metric.bounded_closure_of_bounded hs⟩).measure_lt_top\n\nsection piecewise\n\nvariables [measurable_space α] {μ : measure α} {s t : set α} {f g : α → β}\n\nlemma piecewise_ae_eq_restrict (hs : measurable_set s) : piecewise s f g =ᵐ[μ.restrict s] f :=\nbegin\n  rw [ae_restrict_eq hs],\n  exact (piecewise_eq_on s f g).eventually_eq.filter_mono inf_le_right\nend\n\nlemma piecewise_ae_eq_restrict_compl (hs : measurable_set s) :\n  piecewise s f g =ᵐ[μ.restrict sᶜ] g :=\nbegin\n  rw [ae_restrict_eq hs.compl],\n  exact (piecewise_eq_on_compl s f g).eventually_eq.filter_mono inf_le_right\nend\n\nlemma piecewise_ae_eq_of_ae_eq_set (hst : s =ᵐ[μ] t) : s.piecewise f g =ᵐ[μ] t.piecewise f g :=\nbegin\n  filter_upwards [hst],\n  intros x hx,\n  replace hx : x ∈ s ↔ x ∈ t := iff_of_eq hx,\n  by_cases h : x ∈ s; have h' := h; rw hx at h'; simp [h, h']\nend\n\nend piecewise\n\nsection indicator_function\n\nvariables [measurable_space α] {μ : measure α} {s t : set α} {f : α → β}\n\nlemma mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem [has_zero β] {t : set β}\n  (ht : (0 : β) ∈ t) (hs : measurable_set s) :\n  t ∈ filter.map (s.indicator f) μ.ae ↔ t ∈ filter.map f (μ.restrict s).ae :=\nbegin\n  simp_rw [mem_map, mem_ae_iff],\n  rw [measure.restrict_apply' hs, set.indicator_preimage, set.ite],\n  simp_rw [set.compl_union, set.compl_inter],\n  change μ (((f ⁻¹' t)ᶜ ∪ sᶜ) ∩ ((λ x, (0 : β)) ⁻¹' t \\ s)ᶜ) = 0 ↔ μ ((f ⁻¹' t)ᶜ ∩ s) = 0,\n  simp only [ht, ← set.compl_eq_univ_diff, compl_compl, set.compl_union, if_true,\n    set.preimage_const],\n  simp_rw [set.union_inter_distrib_right, set.compl_inter_self s, set.union_empty],\nend\n\nlemma mem_map_indicator_ae_iff_of_zero_nmem [has_zero β] {t : set β} (ht : (0 : β) ∉ t)  :\n  t ∈ filter.map (s.indicator f) μ.ae ↔ μ ((f ⁻¹' t)ᶜ ∪ sᶜ) = 0 :=\nbegin\n  rw [mem_map, mem_ae_iff, set.indicator_preimage, set.ite, set.compl_union, set.compl_inter],\n  change μ (((f ⁻¹' t)ᶜ ∪ sᶜ) ∩ ((λ x, (0 : β)) ⁻¹' t \\ s)ᶜ) = 0 ↔ μ ((f ⁻¹' t)ᶜ ∪ sᶜ) = 0,\n  simp only [ht, if_false, set.compl_empty, set.empty_diff, set.inter_univ, set.preimage_const],\nend\n\nlemma map_restrict_ae_le_map_indicator_ae [has_zero β] (hs : measurable_set s) :\n  filter.map f (μ.restrict s).ae ≤ filter.map (s.indicator f) μ.ae :=\nbegin\n  intro t,\n  by_cases ht : (0 : β) ∈ t,\n  { rw mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem ht hs, exact id, },\n  rw [mem_map_indicator_ae_iff_of_zero_nmem ht, mem_map_restrict_ae_iff hs],\n  exact λ h, measure_mono_null ((set.inter_subset_left _ _).trans (set.subset_union_left _ _)) h,\nend\n\nlemma ae_measurable.restrict [measurable_space β] (hfm : ae_measurable f μ) {s} :\n  ae_measurable f (μ.restrict s) :=\n⟨ae_measurable.mk f hfm, hfm.measurable_mk, ae_restrict_of_ae hfm.ae_eq_mk⟩\n\nvariables [has_zero β]\n\nlemma indicator_ae_eq_restrict (hs : measurable_set s) : indicator s f =ᵐ[μ.restrict s] f :=\npiecewise_ae_eq_restrict hs\n\nlemma indicator_ae_eq_restrict_compl (hs : measurable_set s) : indicator s f =ᵐ[μ.restrict sᶜ] 0 :=\npiecewise_ae_eq_restrict_compl hs\n\nlemma indicator_ae_eq_of_ae_eq_set (hst : s =ᵐ[μ] t) : s.indicator f =ᵐ[μ] t.indicator f :=\npiecewise_ae_eq_of_ae_eq_set hst\n\nvariables [measurable_space β]\n\nlemma ae_measurable_indicator_iff {s} (hs : measurable_set s) :\n  ae_measurable (indicator s f) μ ↔ ae_measurable f (μ.restrict s)  :=\nbegin\n  split,\n  { assume h,\n    exact (h.mono_measure measure.restrict_le_self).congr (indicator_ae_eq_restrict hs) },\n  { assume h,\n    refine ⟨indicator s (h.mk f), h.measurable_mk.indicator hs, _⟩,\n    have A : s.indicator f =ᵐ[μ.restrict s] s.indicator (ae_measurable.mk f h) :=\n      (indicator_ae_eq_restrict hs).trans (h.ae_eq_mk.trans $ (indicator_ae_eq_restrict hs).symm),\n    have B : s.indicator f =ᵐ[μ.restrict sᶜ] s.indicator (ae_measurable.mk f h) :=\n      (indicator_ae_eq_restrict_compl hs).trans (indicator_ae_eq_restrict_compl hs).symm,\n    exact ae_of_ae_restrict_of_ae_restrict_compl A B },\nend\n\n@[measurability]\nlemma ae_measurable.indicator (hfm : ae_measurable f μ) {s} (hs : measurable_set s) :\n  ae_measurable (s.indicator f) μ :=\n(ae_measurable_indicator_iff hs).mpr hfm.restrict\n\nend indicator_function\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/measure_theory/measure/measure_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.4671752377510538}}
{"text": "def is_smooth {α β} (f : α → β) : Prop := sorry\n\nclass IsSmooth {α β} (f : α → β) : Prop where\n  (proof : is_smooth f)\n\ninstance identity : IsSmooth fun a : α => a := sorry\ninstance const (b : β) : IsSmooth fun a : α => b := sorry\ninstance swap (f : α → β → γ) [∀ a, IsSmooth (f a)] : IsSmooth (λ b a => f a b) := sorry\ninstance parm (f : α → β → γ) [IsSmooth f] (b : β) : IsSmooth (λ a => f a b) := sorry\ninstance comp (f : β → γ) (g : α → β) [IsSmooth f] [IsSmooth g] : IsSmooth (fun a => f (g a)) := sorry\ninstance diag (f : β → δ → γ) (g : α → β) (h : α → δ) [IsSmooth f] [∀ b, IsSmooth (f b)] [IsSmooth g] [IsSmooth h] : IsSmooth (λ a => f (g a) (h a)) := sorry\n\nset_option trace.Meta.synthInstance true\nset_option trace.Meta.synthInstance.unusedArgs true\nexample (f : β → δ → γ) [IsSmooth f] (d : δ) : IsSmooth (λ (g : α → β) a => f (g a) d) := by infer_instance\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/815b.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.46712662832081614}}
{"text": "import Std.Lean.Parser\nimport Std.Lean.Meta.DiscrTree\nimport Mathlib.Algebra.Invertible\nimport Mathlib.Data.Rat.Cast\nimport Mathlib.Data.Nat.Basic\nimport Mathlib.Data.Int.Basic\nimport Mathlib.Tactic.Conv\nimport Qq.MetaM\nimport Qq.Delab\n\nopen Lean\nopen Lean.Meta Qq Lean.Elab Term\n\n\ninitialize registerTraceClass `Meta.Tactic.fun_trans\ninitialize registerTraceClass `Meta.Tactic.fun_trans.step\ninitialize registerTraceClass `Meta.Tactic.fun_trans.trans\n\n\ndef diff (f : α → β) : α → α → β := sorry\n\nprefix:max \"∂\" => diff\n\ntheorem diff_I  : ∂ (λ x : α => x) = λ x dx => dx := sorry\n-- theorem diff_K : ∂ (λ (x : α) (y : β) => x) = λ x dx y => dx := sorry\ntheorem diff_K [OfNat α 0] (β : Type _) (x : α) : ∂ (λ (y : β) => x) = λ y dy => 0 := sorry\ntheorem diff_B (f : β → γ) (g : α → β) \n  : ∂ (λ x => f (g x)) \n    = \n    λ x dx => ∂ f (g x) (∂ g x dx) := sorry\ntheorem diff_S [Add γ] (f : β → α → γ) (g : α → β) \n  : ∂ (λ x => f (g x) x) \n    = \n    λ x dx => \n      ∂ (f (g x)) x dx \n      + \n      ∂ (λ y' => f y' x) (g x) (∂ g x dx) := sorry\ntheorem diff_C (f : β → α → γ)\n  : ∂ (λ (x : α) (y : β) => f y x)\n    =\n    λ x dx y => ∂ (f y) x dx := sorry\ntheorem diff_eval (β) (x : α)\n  : ∂ (λ (f : α → β) => f x)\n    =\n    λ f df => df x := sorry\n\ntheorem diff_let [Add γ] (f : β → α → γ) (g : α → β)\n  : ∂ (λ x => \n      let y := g x\n      f y x)\n    =\n    λ x dx =>\n      let y  := g x\n      let dy := ∂ g x dx\n      ∂ (λ yx' : β × α => f yx'.1 yx'.2) (y,x) (dy,dx) := \nby \n  dsimp\n  sorry\n\ntheorem diff_let_B (f : β → γ) (g : α → β)\n  : ∂ (λ x => \n      let y := g x\n      f y)\n    =\n    λ x dx =>\n      let y  := g x\n      let dy := ∂ g x dx\n      ∂ f y dy := \nby \n  dsimp\n  sorry\n\nabbrev uncurry (f : α → β → γ) := λ (x,y) => f x y\nabbrev uncurry3 (f : α → β → γ → δ) := λ (x,y,z) => f x y z\n\n@[simp ↓]\ntheorem diff_uncurry_add [Add γ] (f : α → β → γ) \n  : ∂(uncurry λ x y => f x y)\n    =\n    λ (x,y) (dx,dy) => \n      ∂ (λ x' => f x' y) x dx\n      +\n      ∂ (f x) y dy := sorry\n\n@[simp ↓]\ntheorem diff_prod_map (f : α → β) (g : α → γ)\n  : ∂ (λ x => (f x, g x))\n    =\n    λ x dx => (∂ f x dx, ∂ g x dx) := sorry\n\ndef adj (f : α → β) : β → α := sorry\n\npostfix:max \"†\" => adj\n\ntheorem adj_I  : ∂ (λ x : α => x) = λ x dx => dx := sorry\ntheorem adj_B (f : β → γ) (g : α → β) \n  : (λ x => f (g x))†\n    = \n    λ z => g† (f† z) := sorry\n\ntheorem adj_S [Add α] (f : β → α → γ) (g : α → β) \n  : (λ x => f (g x) x)†\n    = \n    λ z => \n      let (b,a) := (λ (b,a) => f b a)† z\n      g† b + a := sorry\n\ndef sum (f : α → β) : β := sorry\n\n@[simp ↓] theorem sum_diff\n  : ∂ (λ (f : α → β) => sum f)\n    =\n    λ f df => sum df := sorry\n\n@[simp ↓] theorem sum_adj\n  : (λ (f : α → β) => sum f)†\n    =\n    λ x i => x := sorry\n\n\n@[simp] theorem sum_eval (f : α → β → γ) (b : β)\n  : sum f b\n    =\n    sum (λ a => f a b) := sorry\n\ntheorem adj_C (f : β → α → γ)\n  : (λ (x : α) (y : β) => f y x)†\n    =\n    λ g => sum λ y => (f y)† (g y) := sorry\n\ndef kron (i i' : α) (b : β) : β := sorry\n\ntheorem adj_eval (β) (x : α)\n  : (λ (f : α → β) => f x)†\n    =\n    λ y x' => kron x x' y := sorry\n\ntheorem adj_let {α β γ : Type} [Add α] (f : β → α → γ) (g : α → β)\n  : (λ x => \n      let y := g x\n      f y x)†\n    =\n    λ z =>\n      let yx := (λ yx' : β × α => f yx'.1 yx'.2)† z\n      g† yx.1 + yx.2 := \nby \n  sorry\n\ntheorem adj_let_B {α β γ : Type} [Add α] (f : β → γ) (g : α → β)\n  : (λ x => \n      let y := g x\n      f y)†\n    =\n    λ z =>\n      let y := f† z\n      g† y := \nby \n  sorry\n\n@[simp ↓]\ntheorem adj_prod_map (f : α → β) (g : α → γ) [Add α]\n  : (λ x => (f x, g x))†\n    =\n    λ (y,z) => f† y + g† z := sorry\n\n@[simp ↓]\ntheorem ajd_uncurry_add [Add α]\n  : (uncurry λ x y : α => x + y)†\n    =\n    λ x => (x,x) := sorry\n\n/--\nConstructs a proof that the original expression is true\ngiven a simp result which simplifies the target to `True`.\n-/\ndef _root_.Lean.Meta.Simp.Result.ofTrue (r : Simp.Result) : MetaM (Option Expr) :=\n  if r.expr.isConstOf ``True then\n    some <$> match r.proof? with\n    | some proof => mkOfEqTrue proof\n    | none => pure (mkConst ``True.intro)\n  else\n    pure none\n\ndef _root_.Array.filterIdx (p : α → Bool) (as : Array α) : Array Nat :=\n  as |>.mapIdx (λ i a => if p a then some i.1 else none) \n     |>.filterMap id\n\ndef _root_.Array.findRevIdx? {α : Type} (as : Array α) (p : α → Bool) : Option Nat :=\n  as.reverse.findIdx? p |>.map λ i => as.size - 1 - i\n\ndef getNameOfRuleI (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_I\n  else if transName == ``adj then\n    return ``adj_I\n  else\n    none\n\ndef applyRuleI (transName : Name) (X : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleI transName then\n    let proof ← Meta.mkAppOptM rule #[X]\n    let rhs := (← inferType proof).getArg! 2\n    return (rhs, proof)\n  else \n    return none\n\n\ndef getNameOfRuleK (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_K\n  else\n    none\n\ndef applyRuleK (transName : Name) (x Y : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleK transName then\n    let proof ← Meta.mkAppM rule #[Y, x]\n    let rhs := (← inferType proof).getArg! 2\n    return (rhs, proof)\n  else\n    trace[Meta.Tactic.fun_trans.trans] s!\"Failed applying rule K\"\n    return none\n\n\ndef getNameOfRuleS (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_S\n  else if transName == ``adj then\n    return ``adj_S\n  else \n    none\n\ndef applyRuleS (transName : Name) (f g : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleS transName then\n    let proof ← Meta.mkAppM rule #[f,g]\n    let rhs := (← inferType proof).getArg! 2\n     return (rhs, proof)\n   else \n     return none\n\n\ndef getNameOfRuleB (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_B\n  else if transName == ``adj then\n    return ``adj_B\n  else \n    none\n\ndef applyRuleB (transName : Name) (f g : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleB transName then\n    let proof ← Meta.mkAppM rule #[f,g]\n    trace[Meta.Tactic.fun_trans.trans] s!\"case: B '{← Meta.ppExpr (← inferType proof)}'\"\n    let rhs := (← inferType proof).getArg! 2\n     return (rhs, proof)\n   else \n     return none\n\ndef getNameOfRuleC (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_C\n  else if transName == ``adj then\n    return ``adj_C\n  else \n    none\n\ndef applyRuleC (transName : Name) (f : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleC transName then\n    let proof ← Meta.mkAppM rule #[f]\n    let rhs := (← inferType proof).getArg! 2\n    return (rhs, proof)\n  else\n    return none\n\n\ndef getNameOfRuleEval (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_eval\n  else if transName == ``adj then\n    return ``adj_eval\n  else \n    none\n\ndef applyRuleEval (transName : Name) (x Y : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleEval transName then\n    let proof ← Meta.mkAppM rule #[Y, x]\n    let rhs := (← inferType proof).getArg! 2\n    return (rhs, proof)\n  else \n    return none\n\ndef getNameOfRuleLet (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_let\n  else if transName == ``adj then\n    return ``adj_let\n  else \n    none\n\ndef applyRuleLet (transName : Name) (f g : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleLet transName then\n    let proof ← Meta.mkAppM rule #[f, g]\n    let rhs := (← inferType proof).getArg! 2\n    return (rhs, proof)\n  else \n    return none\n\ndef getNameOfRuleLetB (transName : Name) : Option Name :=\n  if transName == ``diff then\n    return ``diff_let_B\n  else if transName == ``adj then\n    return ``adj_let_B\n  else \n    none\n\ndef applyRuleLetB (transName : Name) (f g : Expr) : MetaM (Option (Expr×Expr)) := do\n  if let .some rule := getNameOfRuleLetB transName then\n    let proof ← Meta.mkAppM rule #[f, g]\n    let rhs := (← inferType proof).getArg! 2\n    return (rhs, proof)\n  else \n    return none\n\n\n/-- \n  Is expression `e` of the form `T f x₀ x₁ .. xₙ` where `T` is some function transformation?\n -/\ndef getFunctionTransform (e : Expr) : Option (Name × Expr × Array Expr) :=\n  if e.isApp && (e.isAppOf ``diff) then     \n    return (``diff, e.getAppArgs[2]!, e.getAppArgs[3:])\n  else if e.isApp && (e.isAppOf ``adj) then     \n    return (``adj, e.getAppArgs[2]!, e.getAppArgs[3:])\n  else\n    none\n\n-- #check Prod.mk 0 (Prod.mk 1 2)\n\n-- TODO: generalize to other monads\ndef _root_.Lean.Meta.letTelescope (e : Expr) (k : Array Expr → Expr → MetaM α) : MetaM α := \n  lambdaLetTelescope e λ xs b => do\n    if let .some i ← xs.findIdxM? (λ x => do pure ¬(← x.fvarId!.isLetVar)) then\n      k xs[0:i] (← mkLambdaFVars xs[i+1:] b)\n    else\n      k xs b\n\n\n/-- Modifies expression of the form:\n  ```\n  let a :=\n    let b := x\n    g b\n  f a b\n  ```\n  \n  to \n  \n  ```\n  let b := x\n  let a := g b\n  f a b\n  ```\n -/\ndef normalizeLetBindings (e : Expr) : MetaM (Option Expr) :=\n  match e with\n  | .letE .. => letTelescope e λ as fVal => do\n    let a := as[0]!\n    let aId := a.fvarId!\n    if let .some aVal ← aId.getValue? then\n      match aVal with\n      | .letE .. => letTelescope aVal λ bs gVal => do\n        withLetDecl (← aId.getUserName) (← aId.getType) gVal λ a' => do\n          let fVal ← mkLambdaFVars as[1:] fVal\n          let fVal := fVal.replaceFVar a a'\n          mkLambdaFVars (bs |>.append #[a']) fVal\n      | _ => return none\n    else\n      return none\n  | _ => return none\n\n/-- \n  -/\ndef transformFunction (transName : Name) (f : Expr) : MetaM (Option (Expr × Expr)) := do\n  match f with \n  | .lam .. => lambdaLetTelescope f λ xs b => do\n    trace[Meta.Tactic.fun_trans.trans] s!\"Transforming '{← Meta.ppExpr f}'\"\n    if h : xs.size > 0 then\n\n\n      if (xs.size ≠ 1) then\n        let x := xs[0]!\n        let y := xs[1]!\n        let xId := x.fvarId!\n        let yId := y.fvarId!\n\n        -- let binding\n        if let .some yVal ← yId.getValue? then\n\n          let g ← mkLambdaFVars #[x] yVal\n          return ← withLocalDecl\n            (← yId.getUserName) default (← yId.getType) λ y' => do\n            let b' ← mkLambdaFVars (xs[2:]) b\n\n            if b'.containsFVar xId then\n              let f ← mkLambdaFVars #[y', x] (b'.replaceFVar y y')\n\n              trace[Meta.Tactic.fun_trans.trans] s!\"case: let 'f:{← Meta.ppExpr f}' 'g:{← Meta.ppExpr g}'\"\n              applyRuleLet transName f.eta g.eta\n            else\n              let f ← mkLambdaFVars #[y'] (b'.replaceFVar y y')\n\n              trace[Meta.Tactic.fun_trans.trans] s!\"case: letB 'f:{← Meta.ppExpr f}' 'g:{← Meta.ppExpr g}'\"\n              applyRuleLetB transName f.eta g.eta\n        \n  \n        -- rule C: λ x y => f y x\n        else \n          trace[Meta.Tactic.fun_trans.trans] s!\"case: C 'f:{← Meta.ppExpr f}'\"\n          let f ← Meta.mkLambdaFVars (#[xs[1]!, xs[0]!].append xs[2:]) b\n          return ← applyRuleC transName f.eta\n      else \n\n        let x := xs[0]\n        let xId := x.fvarId!\n\n        -- rule I: λ x => x \n        if (b == x) then\n          trace[Meta.Tactic.fun_trans.trans] s!\"case: I '{← Meta.ppExpr f}'\"\n          return ← applyRuleI transName (← inferType x)\n\n        -- rule K: λ x => y\n        if ¬(b.containsFVar xId) then\n          trace[Meta.Tactic.fun_trans.trans] s!\"case: K '{← Meta.ppExpr f}'\" \n          return ← applyRuleK transName b (← inferType x)\n\n        -- case: λ x => F x\n        else if b.isApp then\n\n\n          let F    := b.getAppFn\n          let args := b.getAppArgs\n\n          trace[Meta.Tactic.fun_trans.trans] s!\"Application case 'F:{← Meta.ppExpr F}' 'args:{← args.mapM Meta.ppExpr}'\"\n\n          if let some info ← getMatcherInfo? F.constName then\n            trace[Meta.Tactic.fun_trans.trans] s!\"Encountered matcher!\"\n            return none\n\n          if b.isAppOf ``Prod.mk then\n            return none\n\n          -- if b.isAppOf ``Prod.fst then\n          --   return none\n\n          -- if b.isAppOf ``Prod.snd then\n          --   return none\n\n          \n          let doArity := true\n\n          if doArity then do\n            let depArgs := args.mapIdx (λ i arg => if arg.containsFVar xId then some (arg, i.1) else none) |>.filterMap id\n            if depArgs.size >= 2 then\n              let g : Expr ← \n                (depArgs[0:depArgs.size-1]).foldrM (init:=depArgs[depArgs.size-1]!.1) \n                  (λ y ys => mkAppOptM ``Prod.mk #[none, none, y.1,ys]) >>=\n                λ g => mkLambdaFVars #[x] g\n\n              let Ys := depArgs.map λ (arg, _) => (Name.anonymous, λ _ => inferType arg)\n              let f ← \n                withLocalDeclsD Ys λ ys => do\n                  let mut args' := args\n                  for i in [0:ys.size] do\n                    args' := args'.set! depArgs[i]!.2 ys[i]!\n                  let b' ← mkAppOptM' F (args'.map some)\n                  mkLambdaFVars ys b'\n                  -- mkAppM ``uncurry #[← mkLambdaFVars ys b']\n\n              if depArgs.size == 2 then\n                let f ← mkAppM ``uncurry #[f]\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: binary operation 'f:{← Meta.ppExpr f}' 'g:{← Meta.ppExpr g}'\"\n                return ← applyRuleB transName f g\n              if depArgs.size == 3 then\n                let f ← mkAppM ``uncurry3 #[f]\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: ternary operation 'f:{← Meta.ppExpr f}' 'g:{← Meta.ppExpr g}'\"\n                return ← applyRuleB transName f g\n              \n            \n          -- the first arguments with non-trivial occurence of `x`        \n          let id? := args.findIdx? (λ arg => (arg != x) && (arg.containsFVar xId))\n\n          -- non trivial composition?\n          if let .some id := id? then\n            let yVal  := args[id]!\n            let yType ← inferType yVal\n            let g ← mkLambdaFVars #[x] yVal\n            let f'proof : Option (Expr × Expr) ← \n              withLocalDecl `y .default yType λ y => do\n              let fbody ← mkAppOptM' F ((args.set! id y).map .some)\n              -- rule B: λ x => f (g x)\n              if ¬(fbody.containsFVar xId) then\n                let f ← mkLambdaFVars #[y] fbody\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: B 'f:{← Meta.ppExpr f}' 'g:{← Meta.ppExpr g}'\"\n                return ← applyRuleB transName f.eta g.eta\n  \n              -- rule S: λ x => f x (g x)\n              else\n                let f ← mkLambdaFVars #[y,x] fbody\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: S 'f:{← Meta.ppExpr f}' 'g:{← Meta.ppExpr g}'\"\n                return ← applyRuleS transName f.eta g.eta\n            return f'proof\n\n          \n          -- arguments containing `x`\n          let ids := args.filterIdx (λ arg => arg.containsFVar xId)\n\n          -- case: λ f => f x₀ .. xₙ\n          if (ids.size == 0) && (F == x) then  \n            trace[Meta.Tactic.fun_trans.trans] s!\"case: π '{← Meta.ppExpr f}'\"\n            let lastId  := args.size - 1\n            let lastArg := args[args.size - 1]!\n            let αtype ← inferType lastArg\n            let βtype ← inferType b\n            if args.size == 1 then\n              return ← applyRuleEval transName lastArg βtype \n            else\n              let g ← mkLambdaFVars #[x] (← mkAppM' F args[0:lastId])\n              let f ← withLocalDecl `F .default (← mkArrow αtype βtype) λ F => do\n                mkLambdaFVars #[F] (← mkAppM' F #[lastArg])\n              return ← applyRuleB transName f.eta g.eta\n\n    return none\n  | _  => return none\n\n\n/-- A simp plugin which calls `NormNum.eval`. -/\ndef tryFunTrans? (post := false) (e : Expr) : SimpM (Option Simp.Step) := do\n  if post then\n    trace[Meta.Tactic.fun_trans.step] s!\"Post-step through {← Meta.ppExpr e}\"\n  else \n    trace[Meta.Tactic.fun_trans.step] s!\"Pre-step through {← Meta.ppExpr e}\"\n\n  if post then \n    if let .some e' ← normalizeLetBindings e then\n      trace[Meta.Tactic.fun_trans.trans] s!\"Normalizing let binding from:\\n{← Meta.ppExpr e} \\n\\nto:\\n\\n{← Meta.ppExpr e'}\"\n\n      return .some (.visit (.mk e' none 0))\n\n  \n  if let .some (transName, f, args) := getFunctionTransform e then\n    if let .some (f', proof) ← transformFunction transName f then\n      if args.size == 0 then\n        return some (.visit (.mk f' proof 0))\n      else if args.size == 1 then\n        let f'' ← mkAppM' f' args\n        let proof' ← mkAppM ``congr_fun #[proof, args[0]!]\n        return some (.visit (.mk f'' proof' 0))\n      else if args.size == 2 then\n        let f'' ← mkAppM' f' args\n        let proof' ← mkAppM ``congr_fun₂ #[proof, args[0]!, args[1]!]\n        return some (.visit (.mk f'' proof' 0))\n      else if args.size == 3 then\n        let f'' ← mkAppM' f' args\n        let proof' ← mkAppM ``congr_fun₃ #[proof, args[0]!, args[1]!, args[2]!]\n        return some (.visit (.mk f'' proof' 0))\n      else\n        throwError \"Finish implementings tryFunTrans?\"\n        -- return some (.visit (.mk e none 0))\n    else return some (.visit (.mk e none 0))\n  else \n    return some (.visit (.mk e none 0))\n      \n\nvariable (ctx : Simp.Context) (useSimp := true) in\nmutual\n  /-- A discharger which calls `norm_num`. -/\n  partial def discharge (e : Expr) : SimpM (Option Expr) := do (← deriveSimp e).ofTrue\n\n  /-- A `Methods` implementation which calls `norm_num`. -/\n  partial def methods : Simp.Methods :=\n    if useSimp then {\n      pre := fun e ↦ do\n        Simp.andThen (← Simp.preDefault e discharge) tryFunTrans?\n      post := fun e ↦ do\n        Simp.andThen (← Simp.postDefault e discharge) (tryFunTrans? (post := true))\n      discharge? := discharge\n    } else {\n      pre := fun e ↦ Simp.andThen (.visit { expr := e }) tryFunTrans?\n      post := fun e ↦ Simp.andThen (.visit { expr := e }) (tryFunTrans? (post := true))\n      discharge? := discharge\n    }\n\n  /-- Traverses the given expression using simp and normalises any numbers it finds. -/\n  partial def deriveSimp (e : Expr) : MetaM Simp.Result :=\n    (·.1) <$> Simp.main e ctx (methods := methods)\nend\n\n\n-- FIXME: had to inline a bunch of stuff from `simpGoal` here\n/--\nThe core of `norm_num` as a tactic in `MetaM`.\n\n* `g`: The goal to simplify\n* `ctx`: The simp context, constructed by `mkSimpContext` and\n  containing any additional simp rules we want to use\n* `fvarIdsToSimp`: The selected set of hypotheses used in the location argument\n* `simplifyTarget`: true if the target is selected in the location argument\n* `useSimp`: true if we used `norm_num` instead of `norm_num1`\n-/\ndef funTransAt (g : MVarId) (ctx : Simp.Context) (fvarIdsToSimp : Array FVarId)\n    (simplifyTarget := true) (useSimp := true) :\n    MetaM (Option (Array FVarId × MVarId)) := g.withContext do\n  g.checkNotAssigned `norm_num\n  let mut g := g\n  let mut toAssert := #[]\n  let mut replaced := #[]\n  for fvarId in fvarIdsToSimp do\n    let localDecl ← fvarId.getDecl\n    let type ← instantiateMVars localDecl.type\n    let ctx := { ctx with simpTheorems := ctx.simpTheorems.eraseTheorem (.fvar localDecl.fvarId) }\n    let r ← deriveSimp ctx useSimp type\n    match r.proof? with\n    | some _ =>\n      let some (value, type) ← applySimpResultToProp g (mkFVar fvarId) type r\n        | return none\n      toAssert := toAssert.push { userName := localDecl.userName, type, value }\n    | none =>\n      if r.expr.isConstOf ``False then\n        g.assign (← mkFalseElim (← g.getType) (mkFVar fvarId))\n        return none\n      g ← g.replaceLocalDeclDefEq fvarId r.expr\n      replaced := replaced.push fvarId\n  if simplifyTarget then\n    let res ← g.withContext do\n      let target ← instantiateMVars (← g.getType)\n      let r ← deriveSimp ctx useSimp target\n      let some proof ← r.ofTrue\n        | some <$> applySimpResultToTarget g target r\n      g.assign proof\n      pure none\n    let some gNew := res | return none\n    g := gNew\n  let (fvarIdsNew, gNew) ← g.assertHypotheses toAssert\n  let toClear := fvarIdsToSimp.filter fun fvarId ↦ !replaced.contains fvarId\n  let gNew ← gNew.tryClearMany toClear\n  return some (fvarIdsNew, gNew)\n\nopen Qq Lean Meta Elab Tactic Term\n\n/-- Constructs a simp context from the simp argument syntax. -/\ndef getSimpContext (args : Syntax) (simpOnly := false) :\n    TacticM Simp.Context := do\n  let simpTheorems ←\n    if simpOnly then simpOnlyBuiltins.foldlM (·.addConst ·) {} else getSimpTheorems\n  let mut { ctx, starArg } ← elabSimpArgs args (eraseLocal := false) (kind := .simp)\n    { simpTheorems := #[simpTheorems], congrTheorems := ← getSimpCongrTheorems }\n  unless starArg do return ctx\n  let mut simpTheorems := ctx.simpTheorems\n  for h in ← getPropHyps do\n    unless simpTheorems.isErased (.fvar h) do\n      simpTheorems ← simpTheorems.addTheorem (.fvar h) (← h.getDecl).toExpr\n  pure { ctx with simpTheorems }\n\nopen Elab.Tactic in\n\n/--\nElaborates a call to `norm_num only? [args]` or `norm_num1`.\n* `args`: the `(simpArgs)?` syntax for simp arguments\n* `loc`: the `(location)?` syntax for the optional location argument\n* `simpOnly`: true if `only` was used in `norm_num`\n* `useSimp`: false if `norm_num1` was used, in which case only the structural parts\n  of `simp` will be used, not any of the post-processing that `simp only` does without lemmas\n-/\n-- FIXME: had to inline a bunch of stuff from `mkSimpContext` and `simpLocation` here\ndef elabFunTrans (args : Syntax) (loc : Syntax)\n    (simpOnly := false) (useSimp := true) : TacticM Unit := do\n  let ctx ← getSimpContext args (!useSimp || simpOnly)\n  let ctx := {ctx with config := {ctx.config with iota := true, zeta := false, singlePass := true}}\n  let g ← getMainGoal\n  let res ← match expandOptLocation loc with\n  | .targets hyps simplifyTarget => funTransAt g ctx (← getFVarIds hyps) simplifyTarget useSimp\n  | .wildcard => funTransAt g ctx (← g.getNondepPropHyps) (simplifyTarget := true) useSimp\n  match res with\n  | none => replaceMainGoal []\n  | some (_, g) => replaceMainGoal [g]\n\n\nopen Lean.Parser.Tactic  -- Meta.NormNum\n\nelab (name := funTrans) \"fun_trans\" only:&\" only\"? args:(simpArgs ?) loc:(location ?) : tactic =>\n  elabFunTrans args loc (simpOnly := only.isSome) (useSimp := true)\n\n-- /-- Basic version of `norm_num` that does not call `simp`. -/\n-- elab (name := normNum1) \"norm_num1\" loc:(location ?) : tactic =>\n--   elabNormNum mkNullNode loc (simpOnly := true) (useSimp := false)\n\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Tactic/FunctionTransform/Core.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676284, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.46712662301368396}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n\n! This file was ported from Lean 3 source module topology.algebra.group_with_zero\n! leanprover-community/mathlib commit c10e724be91096453ee3db13862b9fb9a992fef2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Topology.Algebra.Monoid\nimport Mathbin.Algebra.Group.Pi\nimport Mathbin.Topology.Homeomorph\n\n/-!\n# Topological group with zero\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we define `has_continuous_inv₀` to be a mixin typeclass a type with `has_inv` and\n`has_zero` (e.g., a `group_with_zero`) such that `λ x, x⁻¹` is continuous at all nonzero points. Any\nnormed (semi)field has this property. Currently the only example of `has_continuous_inv₀` in\n`mathlib` which is not a normed field is the type `nnnreal` (a.k.a. `ℝ≥0`) of nonnegative real\nnumbers.\n\nThen we prove lemmas about continuity of `x ↦ x⁻¹` and `f / g` providing dot-style `*.inv'` and\n`*.div` operations on `filter.tendsto`, `continuous_at`, `continuous_within_at`, `continuous_on`,\nand `continuous`. As a special case, we provide `*.div_const` operations that require only\n`group_with_zero` and `has_continuous_mul` instances.\n\nAll lemmas about `(⁻¹)` use `inv'` in their names because lemmas without `'` are used for\n`topological_group`s. We also use `'` in the typeclass name `has_continuous_inv₀` for the sake of\nconsistency of notation.\n\nOn a `group_with_zero` with continuous multiplication, we also define left and right multiplication\nas homeomorphisms.\n-/\n\n\nopen Topology Filter\n\nopen Filter Function\n\n/-!\n### A group with zero with continuous multiplication\n\nIf `G₀` is a group with zero with continuous `(*)`, then `(/y)` is continuous for any `y`. In this\nsection we prove lemmas that immediately follow from this fact providing `*.div_const` dot-style\noperations on `filter.tendsto`, `continuous_at`, `continuous_within_at`, `continuous_on`, and\n`continuous`.\n-/\n\n\nvariable {α β G₀ : Type _}\n\nsection DivConst\n\nvariable [GroupWithZero G₀] [TopologicalSpace G₀] [ContinuousMul G₀] {f : α → G₀} {s : Set α}\n  {l : Filter α}\n\n/- warning: filter.tendsto.div_const -> Filter.Tendsto.div_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {l : Filter.{u1} α} {x : G₀}, (Filter.Tendsto.{u1, u2} α G₀ f l (nhds.{u2} G₀ _inst_2 x)) -> (forall (y : G₀), Filter.Tendsto.{u1, u2} α G₀ (fun (a : α) => HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) (f a) y) l (nhds.{u2} G₀ _inst_2 (HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) x y)))\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : ContinuousMul.{u1} G₀ _inst_2 (MulOneClass.toMul.{u1} G₀ (Monoid.toMulOneClass.{u1} G₀ (DivInvMonoid.toMonoid.{u1} G₀ _inst_1)))] {f : α -> G₀} {l : Filter.{u2} α} {x : G₀}, (Filter.Tendsto.{u2, u1} α G₀ f l (nhds.{u1} G₀ _inst_2 x)) -> (forall (y : G₀), Filter.Tendsto.{u2, u1} α G₀ (fun (a : α) => HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toDiv.{u1} G₀ _inst_1)) (f a) y) l (nhds.{u1} G₀ _inst_2 (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toDiv.{u1} G₀ _inst_1)) x y)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.div_const Filter.Tendsto.div_constₓ'. -/\ntheorem Filter.Tendsto.div_const {x : G₀} (hf : Tendsto f l (𝓝 x)) (y : G₀) :\n    Tendsto (fun a => f a / y) l (𝓝 (x / y)) := by\n  simpa only [div_eq_mul_inv] using hf.mul tendsto_const_nhds\n#align filter.tendsto.div_const Filter.Tendsto.div_const\n\nvariable [TopologicalSpace α]\n\n/- warning: continuous_at.div_const -> ContinuousAt.div_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} [_inst_4 : TopologicalSpace.{u1} α] {a : α}, (ContinuousAt.{u1, u2} α G₀ _inst_4 _inst_2 f a) -> (forall (y : G₀), ContinuousAt.{u1, u2} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) (f x) y) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : ContinuousMul.{u1} G₀ _inst_2 (MulOneClass.toMul.{u1} G₀ (Monoid.toMulOneClass.{u1} G₀ (DivInvMonoid.toMonoid.{u1} G₀ _inst_1)))] {f : α -> G₀} [_inst_4 : TopologicalSpace.{u2} α] {a : α}, (ContinuousAt.{u2, u1} α G₀ _inst_4 _inst_2 f a) -> (forall (y : G₀), ContinuousAt.{u2, u1} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toDiv.{u1} G₀ _inst_1)) (f x) y) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.div_const ContinuousAt.div_constₓ'. -/\ntheorem ContinuousAt.div_const {a : α} (hf : ContinuousAt f a) (y : G₀) :\n    ContinuousAt (fun x => f x / y) a := by\n  simpa only [div_eq_mul_inv] using hf.mul continuousAt_const\n#align continuous_at.div_const ContinuousAt.div_const\n\n/- warning: continuous_within_at.div_const -> ContinuousWithinAt.div_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {s : Set.{u1} α} [_inst_4 : TopologicalSpace.{u1} α] {a : α}, (ContinuousWithinAt.{u1, u2} α G₀ _inst_4 _inst_2 f s a) -> (forall (y : G₀), ContinuousWithinAt.{u1, u2} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) (f x) y) s a)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : ContinuousMul.{u1} G₀ _inst_2 (MulOneClass.toMul.{u1} G₀ (Monoid.toMulOneClass.{u1} G₀ (DivInvMonoid.toMonoid.{u1} G₀ _inst_1)))] {f : α -> G₀} {s : Set.{u2} α} [_inst_4 : TopologicalSpace.{u2} α] {a : α}, (ContinuousWithinAt.{u2, u1} α G₀ _inst_4 _inst_2 f s a) -> (forall (y : G₀), ContinuousWithinAt.{u2, u1} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toDiv.{u1} G₀ _inst_1)) (f x) y) s a)\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.div_const ContinuousWithinAt.div_constₓ'. -/\ntheorem ContinuousWithinAt.div_const {a} (hf : ContinuousWithinAt f s a) (y : G₀) :\n    ContinuousWithinAt (fun x => f x / y) s a :=\n  hf.div_const _\n#align continuous_within_at.div_const ContinuousWithinAt.div_const\n\n/- warning: continuous_on.div_const -> ContinuousOn.div_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {s : Set.{u1} α} [_inst_4 : TopologicalSpace.{u1} α], (ContinuousOn.{u1, u2} α G₀ _inst_4 _inst_2 f s) -> (forall (y : G₀), ContinuousOn.{u1, u2} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) (f x) y) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : ContinuousMul.{u1} G₀ _inst_2 (MulOneClass.toMul.{u1} G₀ (Monoid.toMulOneClass.{u1} G₀ (DivInvMonoid.toMonoid.{u1} G₀ _inst_1)))] {f : α -> G₀} {s : Set.{u2} α} [_inst_4 : TopologicalSpace.{u2} α], (ContinuousOn.{u2, u1} α G₀ _inst_4 _inst_2 f s) -> (forall (y : G₀), ContinuousOn.{u2, u1} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toDiv.{u1} G₀ _inst_1)) (f x) y) s)\nCase conversion may be inaccurate. Consider using '#align continuous_on.div_const ContinuousOn.div_constₓ'. -/\ntheorem ContinuousOn.div_const (hf : ContinuousOn f s) (y : G₀) :\n    ContinuousOn (fun x => f x / y) s := by\n  simpa only [div_eq_mul_inv] using hf.mul continuousOn_const\n#align continuous_on.div_const ContinuousOn.div_const\n\n/- warning: continuous.div_const -> Continuous.div_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} [_inst_4 : TopologicalSpace.{u1} α], (Continuous.{u1, u2} α G₀ _inst_4 _inst_2 f) -> (forall (y : G₀), Continuous.{u1, u2} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) (f x) y))\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : ContinuousMul.{u1} G₀ _inst_2 (MulOneClass.toMul.{u1} G₀ (Monoid.toMulOneClass.{u1} G₀ (DivInvMonoid.toMonoid.{u1} G₀ _inst_1)))] {f : α -> G₀} [_inst_4 : TopologicalSpace.{u2} α], (Continuous.{u2, u1} α G₀ _inst_4 _inst_2 f) -> (forall (y : G₀), Continuous.{u2, u1} α G₀ _inst_4 _inst_2 (fun (x : α) => HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toDiv.{u1} G₀ _inst_1)) (f x) y))\nCase conversion may be inaccurate. Consider using '#align continuous.div_const Continuous.div_constₓ'. -/\n@[continuity]\ntheorem Continuous.div_const (hf : Continuous f) (y : G₀) : Continuous fun x => f x / y := by\n  simpa only [div_eq_mul_inv] using hf.mul continuous_const\n#align continuous.div_const Continuous.div_const\n\nend DivConst\n\n#print HasContinuousInv₀ /-\n/-- A type with `0` and `has_inv` such that `λ x, x⁻¹` is continuous at all nonzero points. Any\nnormed (semi)field has this property. -/\nclass HasContinuousInv₀ (G₀ : Type _) [Zero G₀] [Inv G₀] [TopologicalSpace G₀] : Prop where\n  continuousAt_inv₀ : ∀ ⦃x : G₀⦄, x ≠ 0 → ContinuousAt Inv.inv x\n#align has_continuous_inv₀ HasContinuousInv₀\n-/\n\nexport HasContinuousInv₀ (continuousAt_inv₀)\n\nsection Inv₀\n\nvariable [Zero G₀] [Inv G₀] [TopologicalSpace G₀] [HasContinuousInv₀ G₀] {l : Filter α} {f : α → G₀}\n  {s : Set α} {a : α}\n\n/-!\n### Continuity of `λ x, x⁻¹` at a non-zero point\n\nWe define `topological_group_with_zero` to be a `group_with_zero` such that the operation `x ↦ x⁻¹`\nis continuous at all nonzero points. In this section we prove dot-style `*.inv'` lemmas for\n`filter.tendsto`, `continuous_at`, `continuous_within_at`, `continuous_on`, and `continuous`.\n-/\n\n\n#print tendsto_inv₀ /-\ntheorem tendsto_inv₀ {x : G₀} (hx : x ≠ 0) : Tendsto Inv.inv (𝓝 x) (𝓝 x⁻¹) :=\n  continuousAt_inv₀ hx\n#align tendsto_inv₀ tendsto_inv₀\n-/\n\n/- warning: continuous_on_inv₀ -> continuousOn_inv₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : Zero.{u1} G₀] [_inst_2 : Inv.{u1} G₀] [_inst_3 : TopologicalSpace.{u1} G₀] [_inst_4 : HasContinuousInv₀.{u1} G₀ _inst_1 _inst_2 _inst_3], ContinuousOn.{u1, u1} G₀ G₀ _inst_3 _inst_3 (Inv.inv.{u1} G₀ _inst_2) (HasCompl.compl.{u1} (Set.{u1} G₀) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G₀) (Set.booleanAlgebra.{u1} G₀)) (Singleton.singleton.{u1, u1} G₀ (Set.{u1} G₀) (Set.hasSingleton.{u1} G₀) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ _inst_1)))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : Zero.{u1} G₀] [_inst_2 : Inv.{u1} G₀] [_inst_3 : TopologicalSpace.{u1} G₀] [_inst_4 : HasContinuousInv₀.{u1} G₀ _inst_1 _inst_2 _inst_3], ContinuousOn.{u1, u1} G₀ G₀ _inst_3 _inst_3 (Inv.inv.{u1} G₀ _inst_2) (HasCompl.compl.{u1} (Set.{u1} G₀) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G₀) (Set.instBooleanAlgebraSet.{u1} G₀)) (Singleton.singleton.{u1, u1} G₀ (Set.{u1} G₀) (Set.instSingletonSet.{u1} G₀) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ _inst_1))))\nCase conversion may be inaccurate. Consider using '#align continuous_on_inv₀ continuousOn_inv₀ₓ'. -/\ntheorem continuousOn_inv₀ : ContinuousOn (Inv.inv : G₀ → G₀) ({0}ᶜ) := fun x hx =>\n  (continuousAt_inv₀ hx).ContinuousWithinAt\n#align continuous_on_inv₀ continuousOn_inv₀\n\n/- warning: filter.tendsto.inv₀ -> Filter.Tendsto.inv₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : Zero.{u2} G₀] [_inst_2 : Inv.{u2} G₀] [_inst_3 : TopologicalSpace.{u2} G₀] [_inst_4 : HasContinuousInv₀.{u2} G₀ _inst_1 _inst_2 _inst_3] {l : Filter.{u1} α} {f : α -> G₀} {a : G₀}, (Filter.Tendsto.{u1, u2} α G₀ f l (nhds.{u2} G₀ _inst_3 a)) -> (Ne.{succ u2} G₀ a (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ _inst_1)))) -> (Filter.Tendsto.{u1, u2} α G₀ (fun (x : α) => Inv.inv.{u2} G₀ _inst_2 (f x)) l (nhds.{u2} G₀ _inst_3 (Inv.inv.{u2} G₀ _inst_2 a)))\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : Zero.{u1} G₀] [_inst_2 : Inv.{u1} G₀] [_inst_3 : TopologicalSpace.{u1} G₀] [_inst_4 : HasContinuousInv₀.{u1} G₀ _inst_1 _inst_2 _inst_3] {l : Filter.{u2} α} {f : α -> G₀} {a : G₀}, (Filter.Tendsto.{u2, u1} α G₀ f l (nhds.{u1} G₀ _inst_3 a)) -> (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ _inst_1))) -> (Filter.Tendsto.{u2, u1} α G₀ (fun (x : α) => Inv.inv.{u1} G₀ _inst_2 (f x)) l (nhds.{u1} G₀ _inst_3 (Inv.inv.{u1} G₀ _inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.inv₀ Filter.Tendsto.inv₀ₓ'. -/\n/-- If a function converges to a nonzero value, its inverse converges to the inverse of this value.\nWe use the name `tendsto.inv₀` as `tendsto.inv` is already used in multiplicative topological\ngroups. -/\ntheorem Filter.Tendsto.inv₀ {a : G₀} (hf : Tendsto f l (𝓝 a)) (ha : a ≠ 0) :\n    Tendsto (fun x => (f x)⁻¹) l (𝓝 a⁻¹) :=\n  (tendsto_inv₀ ha).comp hf\n#align filter.tendsto.inv₀ Filter.Tendsto.inv₀\n\nvariable [TopologicalSpace α]\n\n/- warning: continuous_within_at.inv₀ -> ContinuousWithinAt.inv₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : Zero.{u2} G₀] [_inst_2 : Inv.{u2} G₀] [_inst_3 : TopologicalSpace.{u2} G₀] [_inst_4 : HasContinuousInv₀.{u2} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} {s : Set.{u1} α} {a : α} [_inst_5 : TopologicalSpace.{u1} α], (ContinuousWithinAt.{u1, u2} α G₀ _inst_5 _inst_3 f s a) -> (Ne.{succ u2} G₀ (f a) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ _inst_1)))) -> (ContinuousWithinAt.{u1, u2} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u2} G₀ _inst_2 (f x)) s a)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : Zero.{u1} G₀] [_inst_2 : Inv.{u1} G₀] [_inst_3 : TopologicalSpace.{u1} G₀] [_inst_4 : HasContinuousInv₀.{u1} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} {s : Set.{u2} α} {a : α} [_inst_5 : TopologicalSpace.{u2} α], (ContinuousWithinAt.{u2, u1} α G₀ _inst_5 _inst_3 f s a) -> (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ _inst_1))) -> (ContinuousWithinAt.{u2, u1} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u1} G₀ _inst_2 (f x)) s a)\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.inv₀ ContinuousWithinAt.inv₀ₓ'. -/\ntheorem ContinuousWithinAt.inv₀ (hf : ContinuousWithinAt f s a) (ha : f a ≠ 0) :\n    ContinuousWithinAt (fun x => (f x)⁻¹) s a :=\n  hf.inv₀ ha\n#align continuous_within_at.inv₀ ContinuousWithinAt.inv₀\n\n/- warning: continuous_at.inv₀ -> ContinuousAt.inv₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : Zero.{u2} G₀] [_inst_2 : Inv.{u2} G₀] [_inst_3 : TopologicalSpace.{u2} G₀] [_inst_4 : HasContinuousInv₀.{u2} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} {a : α} [_inst_5 : TopologicalSpace.{u1} α], (ContinuousAt.{u1, u2} α G₀ _inst_5 _inst_3 f a) -> (Ne.{succ u2} G₀ (f a) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ _inst_1)))) -> (ContinuousAt.{u1, u2} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u2} G₀ _inst_2 (f x)) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : Zero.{u1} G₀] [_inst_2 : Inv.{u1} G₀] [_inst_3 : TopologicalSpace.{u1} G₀] [_inst_4 : HasContinuousInv₀.{u1} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} {a : α} [_inst_5 : TopologicalSpace.{u2} α], (ContinuousAt.{u2, u1} α G₀ _inst_5 _inst_3 f a) -> (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ _inst_1))) -> (ContinuousAt.{u2, u1} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u1} G₀ _inst_2 (f x)) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.inv₀ ContinuousAt.inv₀ₓ'. -/\ntheorem ContinuousAt.inv₀ (hf : ContinuousAt f a) (ha : f a ≠ 0) :\n    ContinuousAt (fun x => (f x)⁻¹) a :=\n  hf.inv₀ ha\n#align continuous_at.inv₀ ContinuousAt.inv₀\n\n/- warning: continuous.inv₀ -> Continuous.inv₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : Zero.{u2} G₀] [_inst_2 : Inv.{u2} G₀] [_inst_3 : TopologicalSpace.{u2} G₀] [_inst_4 : HasContinuousInv₀.{u2} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} [_inst_5 : TopologicalSpace.{u1} α], (Continuous.{u1, u2} α G₀ _inst_5 _inst_3 f) -> (forall (x : α), Ne.{succ u2} G₀ (f x) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ _inst_1)))) -> (Continuous.{u1, u2} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u2} G₀ _inst_2 (f x)))\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : Zero.{u1} G₀] [_inst_2 : Inv.{u1} G₀] [_inst_3 : TopologicalSpace.{u1} G₀] [_inst_4 : HasContinuousInv₀.{u1} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} [_inst_5 : TopologicalSpace.{u2} α], (Continuous.{u2, u1} α G₀ _inst_5 _inst_3 f) -> (forall (x : α), Ne.{succ u1} G₀ (f x) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ _inst_1))) -> (Continuous.{u2, u1} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u1} G₀ _inst_2 (f x)))\nCase conversion may be inaccurate. Consider using '#align continuous.inv₀ Continuous.inv₀ₓ'. -/\n@[continuity]\ntheorem Continuous.inv₀ (hf : Continuous f) (h0 : ∀ x, f x ≠ 0) : Continuous fun x => (f x)⁻¹ :=\n  continuous_iff_continuousAt.2 fun x => (hf.Tendsto x).inv₀ (h0 x)\n#align continuous.inv₀ Continuous.inv₀\n\n/- warning: continuous_on.inv₀ -> ContinuousOn.inv₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : Zero.{u2} G₀] [_inst_2 : Inv.{u2} G₀] [_inst_3 : TopologicalSpace.{u2} G₀] [_inst_4 : HasContinuousInv₀.{u2} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} {s : Set.{u1} α} [_inst_5 : TopologicalSpace.{u1} α], (ContinuousOn.{u1, u2} α G₀ _inst_5 _inst_3 f s) -> (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Ne.{succ u2} G₀ (f x) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ _inst_1))))) -> (ContinuousOn.{u1, u2} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u2} G₀ _inst_2 (f x)) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : Zero.{u1} G₀] [_inst_2 : Inv.{u1} G₀] [_inst_3 : TopologicalSpace.{u1} G₀] [_inst_4 : HasContinuousInv₀.{u1} G₀ _inst_1 _inst_2 _inst_3] {f : α -> G₀} {s : Set.{u2} α} [_inst_5 : TopologicalSpace.{u2} α], (ContinuousOn.{u2, u1} α G₀ _inst_5 _inst_3 f s) -> (forall (x : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x s) -> (Ne.{succ u1} G₀ (f x) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ _inst_1)))) -> (ContinuousOn.{u2, u1} α G₀ _inst_5 _inst_3 (fun (x : α) => Inv.inv.{u1} G₀ _inst_2 (f x)) s)\nCase conversion may be inaccurate. Consider using '#align continuous_on.inv₀ ContinuousOn.inv₀ₓ'. -/\ntheorem ContinuousOn.inv₀ (hf : ContinuousOn f s) (h0 : ∀ x ∈ s, f x ≠ 0) :\n    ContinuousOn (fun x => (f x)⁻¹) s := fun x hx => (hf x hx).inv₀ (h0 x hx)\n#align continuous_on.inv₀ ContinuousOn.inv₀\n\nend Inv₀\n\n/- warning: units.embedding_coe₀ -> Units.embedding_val₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2], Embedding.{u1, u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) G₀ (Units.topologicalSpace.{u1} G₀ _inst_2 (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) _inst_2 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2], Embedding.{u1, u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) G₀ (Units.instTopologicalSpaceUnits.{u1} G₀ _inst_2 (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))) _inst_2 (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))\nCase conversion may be inaccurate. Consider using '#align units.embedding_coe₀ Units.embedding_val₀ₓ'. -/\n/-- If `G₀` is a group with zero with topology such that `x ↦ x⁻¹` is continuous at all nonzero\npoints. Then the coercion `Mˣ → M` is a topological embedding. -/\ntheorem Units.embedding_val₀ [GroupWithZero G₀] [TopologicalSpace G₀] [HasContinuousInv₀ G₀] :\n    Embedding (coe : G₀ˣ → G₀) :=\n  Units.embedding_val_mk <| continuousOn_inv₀.mono fun x => IsUnit.ne_zero\n#align units.embedding_coe₀ Units.embedding_val₀\n\n/-!\n### Continuity of division\n\nIf `G₀` is a `group_with_zero` with `x ↦ x⁻¹` continuous at all nonzero points and `(*)`, then\ndivision `(/)` is continuous at any point where the denominator is continuous.\n-/\n\n\nsection Div\n\nvariable [GroupWithZero G₀] [TopologicalSpace G₀] [HasContinuousInv₀ G₀] [ContinuousMul G₀]\n  {f g : α → G₀}\n\n/- warning: filter.tendsto.div -> Filter.Tendsto.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} {l : Filter.{u1} α} {a : G₀} {b : G₀}, (Filter.Tendsto.{u1, u2} α G₀ f l (nhds.{u2} G₀ _inst_2 a)) -> (Filter.Tendsto.{u1, u2} α G₀ g l (nhds.{u2} G₀ _inst_2 b)) -> (Ne.{succ u2} G₀ b (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) -> (Filter.Tendsto.{u1, u2} α G₀ (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u1 u2} (α -> G₀) (Pi.instDiv.{u1, u2} α (fun (ᾰ : α) => G₀) (fun (i : α) => DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)))) f g) l (nhds.{u2} G₀ _inst_2 (HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) a b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} {l : Filter.{u2} α} {a : G₀} {b : G₀}, (Filter.Tendsto.{u2, u1} α G₀ f l (nhds.{u1} G₀ _inst_2 a)) -> (Filter.Tendsto.{u2, u1} α G₀ g l (nhds.{u1} G₀ _inst_2 b)) -> (Ne.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) -> (Filter.Tendsto.{u2, u1} α G₀ (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u2 u1} (α -> G₀) (Pi.instDiv.{u2, u1} α (fun (ᾰ : α) => G₀) (fun (i : α) => GroupWithZero.toDiv.{u1} G₀ _inst_1))) f g) l (nhds.{u1} G₀ _inst_2 (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (GroupWithZero.toDiv.{u1} G₀ _inst_1)) a b)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.div Filter.Tendsto.divₓ'. -/\ntheorem Filter.Tendsto.div {l : Filter α} {a b : G₀} (hf : Tendsto f l (𝓝 a))\n    (hg : Tendsto g l (𝓝 b)) (hy : b ≠ 0) : Tendsto (f / g) l (𝓝 (a / b)) := by\n  simpa only [div_eq_mul_inv] using hf.mul (hg.inv₀ hy)\n#align filter.tendsto.div Filter.Tendsto.div\n\n/- warning: filter.tendsto_mul_iff_of_ne_zero -> Filter.tendsto_mul_iff_of_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] [_inst_5 : T1Space.{u2} G₀ _inst_2] {f : α -> G₀} {g : α -> G₀} {l : Filter.{u1} α} {x : G₀} {y : G₀}, (Filter.Tendsto.{u1, u2} α G₀ g l (nhds.{u2} G₀ _inst_2 y)) -> (Ne.{succ u2} G₀ y (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) -> (Iff (Filter.Tendsto.{u1, u2} α G₀ (fun (n : α) => HMul.hMul.{u2, u2, u2} G₀ G₀ G₀ (instHMul.{u2} G₀ (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) (f n) (g n)) l (nhds.{u2} G₀ _inst_2 (HMul.hMul.{u2, u2, u2} G₀ G₀ G₀ (instHMul.{u2} G₀ (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) x y))) (Filter.Tendsto.{u1, u2} α G₀ f l (nhds.{u2} G₀ _inst_2 x)))\nbut is expected to have type\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)) (GroupWithZero.toInv.{u2} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] [_inst_5 : T1Space.{u2} G₀ _inst_2] {f : α -> G₀} {g : α -> G₀} {l : Filter.{u1} α} {x : G₀} {y : G₀}, (Filter.Tendsto.{u1, u2} α G₀ g l (nhds.{u2} G₀ _inst_2 y)) -> (Ne.{succ u2} G₀ y (OfNat.ofNat.{u2} G₀ 0 (Zero.toOfNat0.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) -> (Iff (Filter.Tendsto.{u1, u2} α G₀ (fun (n : α) => HMul.hMul.{u2, u2, u2} G₀ G₀ G₀ (instHMul.{u2} G₀ (MulZeroClass.toMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) (f n) (g n)) l (nhds.{u2} G₀ _inst_2 (HMul.hMul.{u2, u2, u2} G₀ G₀ G₀ (instHMul.{u2} G₀ (MulZeroClass.toMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) x y))) (Filter.Tendsto.{u1, u2} α G₀ f l (nhds.{u2} G₀ _inst_2 x)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_mul_iff_of_ne_zero Filter.tendsto_mul_iff_of_ne_zeroₓ'. -/\ntheorem Filter.tendsto_mul_iff_of_ne_zero [T1Space G₀] {f g : α → G₀} {l : Filter α} {x y : G₀}\n    (hg : Tendsto g l (𝓝 y)) (hy : y ≠ 0) :\n    Tendsto (fun n => f n * g n) l (𝓝 <| x * y) ↔ Tendsto f l (𝓝 x) :=\n  by\n  refine' ⟨fun hfg => _, fun hf => hf.mul hg⟩\n  rw [← mul_div_cancel x hy]\n  refine' tendsto.congr' _ (hfg.div hg hy)\n  refine' eventually.mp (hg.eventually_ne hy) (eventually_of_forall fun n hn => mul_div_cancel _ hn)\n#align filter.tendsto_mul_iff_of_ne_zero Filter.tendsto_mul_iff_of_ne_zero\n\nvariable [TopologicalSpace α] [TopologicalSpace β] {s : Set α} {a : α}\n\n/- warning: continuous_within_at.div -> ContinuousWithinAt.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u1} α] {s : Set.{u1} α} {a : α}, (ContinuousWithinAt.{u1, u2} α G₀ _inst_5 _inst_2 f s a) -> (ContinuousWithinAt.{u1, u2} α G₀ _inst_5 _inst_2 g s a) -> (Ne.{succ u2} G₀ (g a) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) -> (ContinuousWithinAt.{u1, u2} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u1 u2} (α -> G₀) (Pi.instDiv.{u1, u2} α (fun (ᾰ : α) => G₀) (fun (i : α) => DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)))) f g) s a)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u2} α] {s : Set.{u2} α} {a : α}, (ContinuousWithinAt.{u2, u1} α G₀ _inst_5 _inst_2 f s a) -> (ContinuousWithinAt.{u2, u1} α G₀ _inst_5 _inst_2 g s a) -> (Ne.{succ u1} G₀ (g a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) -> (ContinuousWithinAt.{u2, u1} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u2 u1} (α -> G₀) (Pi.instDiv.{u2, u1} α (fun (ᾰ : α) => G₀) (fun (i : α) => GroupWithZero.toDiv.{u1} G₀ _inst_1))) f g) s a)\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.div ContinuousWithinAt.divₓ'. -/\ntheorem ContinuousWithinAt.div (hf : ContinuousWithinAt f s a) (hg : ContinuousWithinAt g s a)\n    (h₀ : g a ≠ 0) : ContinuousWithinAt (f / g) s a :=\n  hf.div hg h₀\n#align continuous_within_at.div ContinuousWithinAt.div\n\n/- warning: continuous_on.div -> ContinuousOn.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u1} α] {s : Set.{u1} α}, (ContinuousOn.{u1, u2} α G₀ _inst_5 _inst_2 f s) -> (ContinuousOn.{u1, u2} α G₀ _inst_5 _inst_2 g s) -> (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Ne.{succ u2} G₀ (g x) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))))))) -> (ContinuousOn.{u1, u2} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u1 u2} (α -> G₀) (Pi.instDiv.{u1, u2} α (fun (ᾰ : α) => G₀) (fun (i : α) => DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)))) f g) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u2} α] {s : Set.{u2} α}, (ContinuousOn.{u2, u1} α G₀ _inst_5 _inst_2 f s) -> (ContinuousOn.{u2, u1} α G₀ _inst_5 _inst_2 g s) -> (forall (x : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x s) -> (Ne.{succ u1} G₀ (g x) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))) -> (ContinuousOn.{u2, u1} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u2 u1} (α -> G₀) (Pi.instDiv.{u2, u1} α (fun (ᾰ : α) => G₀) (fun (i : α) => GroupWithZero.toDiv.{u1} G₀ _inst_1))) f g) s)\nCase conversion may be inaccurate. Consider using '#align continuous_on.div ContinuousOn.divₓ'. -/\ntheorem ContinuousOn.div (hf : ContinuousOn f s) (hg : ContinuousOn g s) (h₀ : ∀ x ∈ s, g x ≠ 0) :\n    ContinuousOn (f / g) s := fun x hx => (hf x hx).div (hg x hx) (h₀ x hx)\n#align continuous_on.div ContinuousOn.div\n\n/- warning: continuous_at.div -> ContinuousAt.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u1} α] {a : α}, (ContinuousAt.{u1, u2} α G₀ _inst_5 _inst_2 f a) -> (ContinuousAt.{u1, u2} α G₀ _inst_5 _inst_2 g a) -> (Ne.{succ u2} G₀ (g a) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) -> (ContinuousAt.{u1, u2} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u1 u2} (α -> G₀) (Pi.instDiv.{u1, u2} α (fun (ᾰ : α) => G₀) (fun (i : α) => DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)))) f g) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u2} α] {a : α}, (ContinuousAt.{u2, u1} α G₀ _inst_5 _inst_2 f a) -> (ContinuousAt.{u2, u1} α G₀ _inst_5 _inst_2 g a) -> (Ne.{succ u1} G₀ (g a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) -> (ContinuousAt.{u2, u1} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u2 u1} (α -> G₀) (Pi.instDiv.{u2, u1} α (fun (ᾰ : α) => G₀) (fun (i : α) => GroupWithZero.toDiv.{u1} G₀ _inst_1))) f g) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.div ContinuousAt.divₓ'. -/\n/-- Continuity at a point of the result of dividing two functions continuous at that point, where\nthe denominator is nonzero. -/\ntheorem ContinuousAt.div (hf : ContinuousAt f a) (hg : ContinuousAt g a) (h₀ : g a ≠ 0) :\n    ContinuousAt (f / g) a :=\n  hf.div hg h₀\n#align continuous_at.div ContinuousAt.div\n\n/- warning: continuous.div -> Continuous.div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u1} α], (Continuous.{u1, u2} α G₀ _inst_5 _inst_2 f) -> (Continuous.{u1, u2} α G₀ _inst_5 _inst_2 g) -> (forall (x : α), Ne.{succ u2} G₀ (g x) (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) -> (Continuous.{u1, u2} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u1 u2} (α -> G₀) (Pi.instDiv.{u1, u2} α (fun (ᾰ : α) => G₀) (fun (i : α) => DivInvMonoid.toHasDiv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)))) f g))\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {f : α -> G₀} {g : α -> G₀} [_inst_5 : TopologicalSpace.{u2} α], (Continuous.{u2, u1} α G₀ _inst_5 _inst_2 f) -> (Continuous.{u2, u1} α G₀ _inst_5 _inst_2 g) -> (forall (x : α), Ne.{succ u1} G₀ (g x) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) -> (Continuous.{u2, u1} α G₀ _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (α -> G₀) (α -> G₀) (α -> G₀) (instHDiv.{max u2 u1} (α -> G₀) (Pi.instDiv.{u2, u1} α (fun (ᾰ : α) => G₀) (fun (i : α) => GroupWithZero.toDiv.{u1} G₀ _inst_1))) f g))\nCase conversion may be inaccurate. Consider using '#align continuous.div Continuous.divₓ'. -/\n@[continuity]\ntheorem Continuous.div (hf : Continuous f) (hg : Continuous g) (h₀ : ∀ x, g x ≠ 0) :\n    Continuous (f / g) := by simpa only [div_eq_mul_inv] using hf.mul (hg.inv₀ h₀)\n#align continuous.div Continuous.div\n\n/- warning: continuous_on_div -> continuousOn_div is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))], ContinuousOn.{u1, u1} (Prod.{u1, u1} G₀ G₀) G₀ (Prod.topologicalSpace.{u1, u1} G₀ G₀ _inst_2 _inst_2) _inst_2 (fun (p : Prod.{u1, u1} G₀ G₀) => HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toHasDiv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (Prod.fst.{u1, u1} G₀ G₀ p) (Prod.snd.{u1, u1} G₀ G₀ p)) (setOf.{u1} (Prod.{u1, u1} G₀ G₀) (fun (p : Prod.{u1, u1} G₀ G₀) => Ne.{succ u1} G₀ (Prod.snd.{u1, u1} G₀ G₀ p) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))], ContinuousOn.{u1, u1} (Prod.{u1, u1} G₀ G₀) G₀ (instTopologicalSpaceProd.{u1, u1} G₀ G₀ _inst_2 _inst_2) _inst_2 (fun (p : Prod.{u1, u1} G₀ G₀) => HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (GroupWithZero.toDiv.{u1} G₀ _inst_1)) (Prod.fst.{u1, u1} G₀ G₀ p) (Prod.snd.{u1, u1} G₀ G₀ p)) (setOf.{u1} (Prod.{u1, u1} G₀ G₀) (fun (p : Prod.{u1, u1} G₀ G₀) => Ne.{succ u1} G₀ (Prod.snd.{u1, u1} G₀ G₀ p) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align continuous_on_div continuousOn_divₓ'. -/\ntheorem continuousOn_div : ContinuousOn (fun p : G₀ × G₀ => p.1 / p.2) { p | p.2 ≠ 0 } :=\n  continuousOn_fst.div continuousOn_snd fun _ => id\n#align continuous_on_div continuousOn_div\n\n/- warning: continuous_at.comp_div_cases -> ContinuousAt.comp_div_cases is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {G₀ : Type.{u3}} [_inst_1 : GroupWithZero.{u3} G₀] [_inst_2 : TopologicalSpace.{u3} G₀] [_inst_3 : HasContinuousInv₀.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u3} G₀ (GroupWithZero.toDivInvMonoid.{u3} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u3} G₀ _inst_2 (MulZeroClass.toHasMul.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1))))] [_inst_5 : TopologicalSpace.{u1} α] [_inst_6 : TopologicalSpace.{u2} β] {a : α} {f : α -> G₀} {g : α -> G₀} (h : α -> G₀ -> β), (ContinuousAt.{u1, u3} α G₀ _inst_5 _inst_2 f a) -> (ContinuousAt.{u1, u3} α G₀ _inst_5 _inst_2 g a) -> ((Ne.{succ u3} G₀ (g a) (OfNat.ofNat.{u3} G₀ 0 (OfNat.mk.{u3} G₀ 0 (Zero.zero.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1)))))))) -> (ContinuousAt.{max u1 u3, u2} (Prod.{u1, u3} α G₀) β (Prod.topologicalSpace.{u1, u3} α G₀ _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (α -> G₀ -> β) (Prod.{u1, u3} α G₀) β (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u3, u2} G₀ β)) h) (Prod.mk.{u1, u3} α G₀ a (HDiv.hDiv.{u3, u3, u3} G₀ G₀ G₀ (instHDiv.{u3} G₀ (DivInvMonoid.toHasDiv.{u3} G₀ (GroupWithZero.toDivInvMonoid.{u3} G₀ _inst_1))) (f a) (g a))))) -> ((Eq.{succ u3} G₀ (g a) (OfNat.ofNat.{u3} G₀ 0 (OfNat.mk.{u3} G₀ 0 (Zero.zero.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1)))))))) -> (Filter.Tendsto.{max u1 u3, u2} (Prod.{u1, u3} α G₀) β (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (α -> G₀ -> β) (Prod.{u1, u3} α G₀) β (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u3, u2} G₀ β)) h) (Filter.prod.{u1, u3} α G₀ (nhds.{u1} α _inst_5 a) (Top.top.{u3} (Filter.{u3} G₀) (Filter.hasTop.{u3} G₀))) (nhds.{u2} β _inst_6 (h a (OfNat.ofNat.{u3} G₀ 0 (OfNat.mk.{u3} G₀ 0 (Zero.zero.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1))))))))))) -> (ContinuousAt.{u1, u2} α β _inst_5 _inst_6 (fun (x : α) => h x (HDiv.hDiv.{u3, u3, u3} G₀ G₀ G₀ (instHDiv.{u3} G₀ (DivInvMonoid.toHasDiv.{u3} G₀ (GroupWithZero.toDivInvMonoid.{u3} G₀ _inst_1))) (f x) (g x))) a)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)) (GroupWithZero.toInv.{u2} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] [_inst_5 : TopologicalSpace.{u3} α] [_inst_6 : TopologicalSpace.{u1} β] {a : α} {f : α -> G₀} {g : α -> G₀} (h : α -> G₀ -> β), (ContinuousAt.{u3, u2} α G₀ _inst_5 _inst_2 f a) -> (ContinuousAt.{u3, u2} α G₀ _inst_5 _inst_2 g a) -> ((Ne.{succ u2} G₀ (g a) (OfNat.ofNat.{u2} G₀ 0 (Zero.toOfNat0.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) -> (ContinuousAt.{max u3 u2, u1} (Prod.{u3, u2} α G₀) β (instTopologicalSpaceProd.{u3, u2} α G₀ _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (α -> G₀ -> β) (Prod.{u3, u2} α G₀) β (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u2, u1} G₀ β)) h) (Prod.mk.{u3, u2} α G₀ a (HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (GroupWithZero.toDiv.{u2} G₀ _inst_1)) (f a) (g a))))) -> ((Eq.{succ u2} G₀ (g a) (OfNat.ofNat.{u2} G₀ 0 (Zero.toOfNat0.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) -> (Filter.Tendsto.{max u3 u2, u1} (Prod.{u3, u2} α G₀) β (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (α -> G₀ -> β) (Prod.{u3, u2} α G₀) β (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u2, u1} G₀ β)) h) (Filter.prod.{u3, u2} α G₀ (nhds.{u3} α _inst_5 a) (Top.top.{u2} (Filter.{u2} G₀) (Filter.instTopFilter.{u2} G₀))) (nhds.{u1} β _inst_6 (h a (OfNat.ofNat.{u2} G₀ 0 (Zero.toOfNat0.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) -> (ContinuousAt.{u3, u1} α β _inst_5 _inst_6 (fun (x : α) => h x (HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (GroupWithZero.toDiv.{u2} G₀ _inst_1)) (f x) (g x))) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.comp_div_cases ContinuousAt.comp_div_casesₓ'. -/\n/-- The function `f x / g x` is discontinuous when `g x = 0`.\nHowever, under appropriate conditions, `h x (f x / g x)` is still continuous.\nThe condition is that if `g a = 0` then `h x y` must tend to `h a 0` when `x` tends to `a`,\nwith no information about `y`. This is represented by the `⊤` filter.\nNote: `filter.tendsto_prod_top_iff` characterizes this convergence in uniform spaces.\nSee also `filter.prod_top` and `filter.mem_prod_top`. -/\ntheorem ContinuousAt.comp_div_cases {f g : α → G₀} (h : α → G₀ → β) (hf : ContinuousAt f a)\n    (hg : ContinuousAt g a) (hh : g a ≠ 0 → ContinuousAt (↿h) (a, f a / g a))\n    (h2h : g a = 0 → Tendsto (↿h) (𝓝 a ×ᶠ ⊤) (𝓝 (h a 0))) :\n    ContinuousAt (fun x => h x (f x / g x)) a :=\n  by\n  show ContinuousAt (↿h ∘ fun x => (x, f x / g x)) a\n  by_cases hga : g a = 0\n  · rw [ContinuousAt]\n    simp_rw [comp_app, hga, div_zero]\n    exact (h2h hga).comp (continuous_at_id.prod_mk tendsto_top)\n  · exact ContinuousAt.comp (hh hga) (continuous_at_id.prod (hf.div hg hga))\n#align continuous_at.comp_div_cases ContinuousAt.comp_div_cases\n\n/- warning: continuous.comp_div_cases -> Continuous.comp_div_cases is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {G₀ : Type.{u3}} [_inst_1 : GroupWithZero.{u3} G₀] [_inst_2 : TopologicalSpace.{u3} G₀] [_inst_3 : HasContinuousInv₀.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u3} G₀ (GroupWithZero.toDivInvMonoid.{u3} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u3} G₀ _inst_2 (MulZeroClass.toHasMul.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1))))] [_inst_5 : TopologicalSpace.{u1} α] [_inst_6 : TopologicalSpace.{u2} β] {f : α -> G₀} {g : α -> G₀} (h : α -> G₀ -> β), (Continuous.{u1, u3} α G₀ _inst_5 _inst_2 f) -> (Continuous.{u1, u3} α G₀ _inst_5 _inst_2 g) -> (forall (a : α), (Ne.{succ u3} G₀ (g a) (OfNat.ofNat.{u3} G₀ 0 (OfNat.mk.{u3} G₀ 0 (Zero.zero.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1)))))))) -> (ContinuousAt.{max u1 u3, u2} (Prod.{u1, u3} α G₀) β (Prod.topologicalSpace.{u1, u3} α G₀ _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (α -> G₀ -> β) (Prod.{u1, u3} α G₀) β (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u3, u2} G₀ β)) h) (Prod.mk.{u1, u3} α G₀ a (HDiv.hDiv.{u3, u3, u3} G₀ G₀ G₀ (instHDiv.{u3} G₀ (DivInvMonoid.toHasDiv.{u3} G₀ (GroupWithZero.toDivInvMonoid.{u3} G₀ _inst_1))) (f a) (g a))))) -> (forall (a : α), (Eq.{succ u3} G₀ (g a) (OfNat.ofNat.{u3} G₀ 0 (OfNat.mk.{u3} G₀ 0 (Zero.zero.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1)))))))) -> (Filter.Tendsto.{max u1 u3, u2} (Prod.{u1, u3} α G₀) β (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (α -> G₀ -> β) (Prod.{u1, u3} α G₀) β (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u3, u2} G₀ β)) h) (Filter.prod.{u1, u3} α G₀ (nhds.{u1} α _inst_5 a) (Top.top.{u3} (Filter.{u3} G₀) (Filter.hasTop.{u3} G₀))) (nhds.{u2} β _inst_6 (h a (OfNat.ofNat.{u3} G₀ 0 (OfNat.mk.{u3} G₀ 0 (Zero.zero.{u3} G₀ (MulZeroClass.toHasZero.{u3} G₀ (MulZeroOneClass.toMulZeroClass.{u3} G₀ (MonoidWithZero.toMulZeroOneClass.{u3} G₀ (GroupWithZero.toMonoidWithZero.{u3} G₀ _inst_1))))))))))) -> (Continuous.{u1, u2} α β _inst_5 _inst_6 (fun (x : α) => h x (HDiv.hDiv.{u3, u3, u3} G₀ G₀ G₀ (instHDiv.{u3} G₀ (DivInvMonoid.toHasDiv.{u3} G₀ (GroupWithZero.toDivInvMonoid.{u3} G₀ _inst_1))) (f x) (g x))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)) (GroupWithZero.toInv.{u2} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] [_inst_5 : TopologicalSpace.{u3} α] [_inst_6 : TopologicalSpace.{u1} β] {f : α -> G₀} {g : α -> G₀} (h : α -> G₀ -> β), (Continuous.{u3, u2} α G₀ _inst_5 _inst_2 f) -> (Continuous.{u3, u2} α G₀ _inst_5 _inst_2 g) -> (forall (a : α), (Ne.{succ u2} G₀ (g a) (OfNat.ofNat.{u2} G₀ 0 (Zero.toOfNat0.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) -> (ContinuousAt.{max u3 u2, u1} (Prod.{u3, u2} α G₀) β (instTopologicalSpaceProd.{u3, u2} α G₀ _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (α -> G₀ -> β) (Prod.{u3, u2} α G₀) β (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u2, u1} G₀ β)) h) (Prod.mk.{u3, u2} α G₀ a (HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (GroupWithZero.toDiv.{u2} G₀ _inst_1)) (f a) (g a))))) -> (forall (a : α), (Eq.{succ u2} G₀ (g a) (OfNat.ofNat.{u2} G₀ 0 (Zero.toOfNat0.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))) -> (Filter.Tendsto.{max u3 u2, u1} (Prod.{u3, u2} α G₀) β (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (α -> G₀ -> β) (Prod.{u3, u2} α G₀) β (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} α (G₀ -> β) G₀ β (Function.hasUncurryBase.{u2, u1} G₀ β)) h) (Filter.prod.{u3, u2} α G₀ (nhds.{u3} α _inst_5 a) (Top.top.{u2} (Filter.{u2} G₀) (Filter.instTopFilter.{u2} G₀))) (nhds.{u1} β _inst_6 (h a (OfNat.ofNat.{u2} G₀ 0 (Zero.toOfNat0.{u2} G₀ (MonoidWithZero.toZero.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) -> (Continuous.{u3, u1} α β _inst_5 _inst_6 (fun (x : α) => h x (HDiv.hDiv.{u2, u2, u2} G₀ G₀ G₀ (instHDiv.{u2} G₀ (GroupWithZero.toDiv.{u2} G₀ _inst_1)) (f x) (g x))))\nCase conversion may be inaccurate. Consider using '#align continuous.comp_div_cases Continuous.comp_div_casesₓ'. -/\n/-- `h x (f x / g x)` is continuous under certain conditions, even if the denominator is sometimes\n  `0`. See docstring of `continuous_at.comp_div_cases`. -/\ntheorem Continuous.comp_div_cases {f g : α → G₀} (h : α → G₀ → β) (hf : Continuous f)\n    (hg : Continuous g) (hh : ∀ a, g a ≠ 0 → ContinuousAt (↿h) (a, f a / g a))\n    (h2h : ∀ a, g a = 0 → Tendsto (↿h) (𝓝 a ×ᶠ ⊤) (𝓝 (h a 0))) :\n    Continuous fun x => h x (f x / g x) :=\n  continuous_iff_continuousAt.mpr fun a =>\n    hf.ContinuousAt.comp_div_cases _ hg.ContinuousAt (hh a) (h2h a)\n#align continuous.comp_div_cases Continuous.comp_div_cases\n\nend Div\n\n/-! ### Left and right multiplication as homeomorphisms -/\n\n\nnamespace Homeomorph\n\nvariable [TopologicalSpace α] [GroupWithZero α] [ContinuousMul α]\n\n/- warning: homeomorph.mul_left₀ -> Homeomorph.mulLeft₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α), (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2)))))))) -> (Homeomorph.{u1, u1} α α _inst_1 _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α), (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) -> (Homeomorph.{u1, u1} α α _inst_1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_left₀ Homeomorph.mulLeft₀ₓ'. -/\n/-- Left multiplication by a nonzero element in a `group_with_zero` with continuous multiplication\nis a homeomorphism of the underlying type. -/\nprotected def mulLeft₀ (c : α) (hc : c ≠ 0) : α ≃ₜ α :=\n  { Equiv.mulLeft₀ c hc with\n    continuous_toFun := continuous_mul_left _\n    continuous_invFun := continuous_mul_left _ }\n#align homeomorph.mul_left₀ Homeomorph.mulLeft₀\n\n/- warning: homeomorph.mul_right₀ -> Homeomorph.mulRight₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α), (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2)))))))) -> (Homeomorph.{u1, u1} α α _inst_1 _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α), (Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) -> (Homeomorph.{u1, u1} α α _inst_1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_right₀ Homeomorph.mulRight₀ₓ'. -/\n/-- Right multiplication by a nonzero element in a `group_with_zero` with continuous multiplication\nis a homeomorphism of the underlying type. -/\nprotected def mulRight₀ (c : α) (hc : c ≠ 0) : α ≃ₜ α :=\n  { Equiv.mulRight₀ c hc with\n    continuous_toFun := continuous_mul_right _\n    continuous_invFun := continuous_mul_right _ }\n#align homeomorph.mul_right₀ Homeomorph.mulRight₀\n\n/- warning: homeomorph.coe_mul_left₀ -> Homeomorph.coe_mulLeft₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2)))))))), Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} α α _inst_1 _inst_1) => α -> α) (Homeomorph.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (Homeomorph.mulLeft₀.{u1} α _inst_1 _inst_2 _inst_3 c hc)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) c)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))), Eq.{succ u1} (α -> α) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => α) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (Homeomorph.instEquivLikeHomeomorph.{u1, u1} α α _inst_1 _inst_1))) (Homeomorph.mulLeft₀.{u1} α _inst_1 _inst_2 _inst_3 c hc)) (fun (x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2184 : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) c x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2184)\nCase conversion may be inaccurate. Consider using '#align homeomorph.coe_mul_left₀ Homeomorph.coe_mulLeft₀ₓ'. -/\n@[simp]\ntheorem coe_mulLeft₀ (c : α) (hc : c ≠ 0) : ⇑(Homeomorph.mulLeft₀ c hc) = (· * ·) c :=\n  rfl\n#align homeomorph.coe_mul_left₀ Homeomorph.coe_mulLeft₀\n\n/- warning: homeomorph.mul_left₀_symm_apply -> Homeomorph.mulLeft₀_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2)))))))), Eq.{succ u1} ((fun (_x : Homeomorph.{u1, u1} α α _inst_1 _inst_1) => α -> α) (Homeomorph.symm.{u1, u1} α α _inst_1 _inst_1 (Homeomorph.mulLeft₀.{u1} α _inst_1 _inst_2 _inst_3 c hc))) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} α α _inst_1 _inst_1) => α -> α) (Homeomorph.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (Homeomorph.symm.{u1, u1} α α _inst_1 _inst_1 (Homeomorph.mulLeft₀.{u1} α _inst_1 _inst_2 _inst_3 c hc))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_2)) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))), Eq.{succ u1} (α -> α) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => α) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (Homeomorph.instEquivLikeHomeomorph.{u1, u1} α α _inst_1 _inst_1))) (Homeomorph.symm.{u1, u1} α α _inst_1 _inst_1 (Homeomorph.mulLeft₀.{u1} α _inst_1 _inst_2 _inst_3 c hc))) (fun (x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2233 : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) (Inv.inv.{u1} α (GroupWithZero.toInv.{u1} α _inst_2) c) x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2233)\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_left₀_symm_apply Homeomorph.mulLeft₀_symm_applyₓ'. -/\n@[simp]\ntheorem mulLeft₀_symm_apply (c : α) (hc : c ≠ 0) :\n    ((Homeomorph.mulLeft₀ c hc).symm : α → α) = (· * ·) c⁻¹ :=\n  rfl\n#align homeomorph.mul_left₀_symm_apply Homeomorph.mulLeft₀_symm_apply\n\n/- warning: homeomorph.coe_mul_right₀ -> Homeomorph.coe_mulRight₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2)))))))), Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} α α _inst_1 _inst_1) => α -> α) (Homeomorph.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (Homeomorph.mulRight₀.{u1} α _inst_1 _inst_2 _inst_3 c hc)) (fun (x : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) x c)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))), Eq.{succ u1} (α -> α) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => α) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (Homeomorph.instEquivLikeHomeomorph.{u1, u1} α α _inst_1 _inst_1))) (Homeomorph.mulRight₀.{u1} α _inst_1 _inst_2 _inst_3 c hc)) (fun (x : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) x c)\nCase conversion may be inaccurate. Consider using '#align homeomorph.coe_mul_right₀ Homeomorph.coe_mulRight₀ₓ'. -/\n@[simp]\ntheorem coe_mulRight₀ (c : α) (hc : c ≠ 0) : ⇑(Homeomorph.mulRight₀ c hc) = fun x => x * c :=\n  rfl\n#align homeomorph.coe_mul_right₀ Homeomorph.coe_mulRight₀\n\n/- warning: homeomorph.mul_right₀_symm_apply -> Homeomorph.mulRight₀_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2)))))))), Eq.{succ u1} ((fun (_x : Homeomorph.{u1, u1} α α _inst_1 _inst_1) => α -> α) (Homeomorph.symm.{u1, u1} α α _inst_1 _inst_1 (Homeomorph.mulRight₀.{u1} α _inst_1 _inst_2 _inst_3 c hc))) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} α α _inst_1 _inst_1) => α -> α) (Homeomorph.hasCoeToFun.{u1, u1} α α _inst_1 _inst_1) (Homeomorph.symm.{u1, u1} α α _inst_1 _inst_1 (Homeomorph.mulRight₀.{u1} α _inst_1 _inst_2 _inst_3 c hc))) (fun (x : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toHasMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) x (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α _inst_2)) c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} α] [_inst_2 : GroupWithZero.{u1} α] [_inst_3 : ContinuousMul.{u1} α _inst_1 (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))] (c : α) (hc : Ne.{succ u1} α c (OfNat.ofNat.{u1} α 0 (Zero.toOfNat0.{u1} α (MonoidWithZero.toZero.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))), Eq.{succ u1} (α -> α) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α (fun (_x : α) => α) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} α α _inst_1 _inst_1) α α (Homeomorph.instEquivLikeHomeomorph.{u1, u1} α α _inst_1 _inst_1))) (Homeomorph.symm.{u1, u1} α α _inst_1 _inst_1 (Homeomorph.mulRight₀.{u1} α _inst_1 _inst_2 _inst_3 c hc))) (fun (x : α) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulZeroClass.toMul.{u1} α (MulZeroOneClass.toMulZeroClass.{u1} α (MonoidWithZero.toMulZeroOneClass.{u1} α (GroupWithZero.toMonoidWithZero.{u1} α _inst_2))))) x (Inv.inv.{u1} α (GroupWithZero.toInv.{u1} α _inst_2) c))\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_right₀_symm_apply Homeomorph.mulRight₀_symm_applyₓ'. -/\n@[simp]\ntheorem mulRight₀_symm_apply (c : α) (hc : c ≠ 0) :\n    ((Homeomorph.mulRight₀ c hc).symm : α → α) = fun x => x * c⁻¹ :=\n  rfl\n#align homeomorph.mul_right₀_symm_apply Homeomorph.mulRight₀_symm_apply\n\nend Homeomorph\n\nsection Zpow\n\nvariable [GroupWithZero G₀] [TopologicalSpace G₀] [HasContinuousInv₀ G₀] [ContinuousMul G₀]\n\n/- warning: continuous_at_zpow₀ -> continuousAt_zpow₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] (x : G₀) (m : Int), (Or (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))) (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) m)) -> (ContinuousAt.{u1, u1} G₀ G₀ _inst_2 _inst_2 (fun (x : G₀) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) x m) x)\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] (x : G₀) (m : Int), (Or (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (ContinuousAt.{u1, u1} G₀ G₀ _inst_2 _inst_2 (fun (x : G₀) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) x m) x)\nCase conversion may be inaccurate. Consider using '#align continuous_at_zpow₀ continuousAt_zpow₀ₓ'. -/\ntheorem continuousAt_zpow₀ (x : G₀) (m : ℤ) (h : x ≠ 0 ∨ 0 ≤ m) : ContinuousAt (fun x => x ^ m) x :=\n  by\n  cases m\n  · simpa only [zpow_ofNat] using continuousAt_pow x m\n  · simp only [zpow_negSucc]\n    have hx : x ≠ 0 := h.resolve_right (Int.negSucc_lt_zero m).not_le\n    exact (continuousAt_pow x (m + 1)).inv₀ (pow_ne_zero _ hx)\n#align continuous_at_zpow₀ continuousAt_zpow₀\n\n/- warning: continuous_on_zpow₀ -> continuousOn_zpow₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] (m : Int), ContinuousOn.{u1, u1} G₀ G₀ _inst_2 _inst_2 (fun (x : G₀) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) x m) (HasCompl.compl.{u1} (Set.{u1} G₀) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G₀) (Set.booleanAlgebra.{u1} G₀)) (Singleton.singleton.{u1, u1} G₀ (Set.{u1} G₀) (Set.hasSingleton.{u1} G₀) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] (m : Int), ContinuousOn.{u1, u1} G₀ G₀ _inst_2 _inst_2 (fun (x : G₀) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) x m) (HasCompl.compl.{u1} (Set.{u1} G₀) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G₀) (Set.instBooleanAlgebraSet.{u1} G₀)) (Singleton.singleton.{u1, u1} G₀ (Set.{u1} G₀) (Set.instSingletonSet.{u1} G₀) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align continuous_on_zpow₀ continuousOn_zpow₀ₓ'. -/\ntheorem continuousOn_zpow₀ (m : ℤ) : ContinuousOn (fun x : G₀ => x ^ m) ({0}ᶜ) := fun x hx =>\n  (continuousAt_zpow₀ _ _ (Or.inl hx)).ContinuousWithinAt\n#align continuous_on_zpow₀ continuousOn_zpow₀\n\n/- warning: filter.tendsto.zpow₀ -> Filter.Tendsto.zpow₀ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {G₀ : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G₀] [_inst_2 : TopologicalSpace.{u2} G₀] [_inst_3 : HasContinuousInv₀.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G₀ _inst_2 (MulZeroClass.toHasMul.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1))))] {f : α -> G₀} {l : Filter.{u1} α} {a : G₀}, (Filter.Tendsto.{u1, u2} α G₀ f l (nhds.{u2} G₀ _inst_2 a)) -> (forall (m : Int), (Or (Ne.{succ u2} G₀ a (OfNat.ofNat.{u2} G₀ 0 (OfNat.mk.{u2} G₀ 0 (Zero.zero.{u2} G₀ (MulZeroClass.toHasZero.{u2} G₀ (MulZeroOneClass.toMulZeroClass.{u2} G₀ (MonoidWithZero.toMulZeroOneClass.{u2} G₀ (GroupWithZero.toMonoidWithZero.{u2} G₀ _inst_1)))))))) (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) m)) -> (Filter.Tendsto.{u1, u2} α G₀ (fun (x : α) => HPow.hPow.{u2, 0, u2} G₀ Int G₀ (instHPow.{u2, 0} G₀ Int (DivInvMonoid.Pow.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) (f x) m) l (nhds.{u2} G₀ _inst_2 (HPow.hPow.{u2, 0, u2} G₀ Int G₀ (instHPow.{u2, 0} G₀ Int (DivInvMonoid.Pow.{u2} G₀ (GroupWithZero.toDivInvMonoid.{u2} G₀ _inst_1))) a m))))\nbut is expected to have type\n  forall {α : Type.{u2}} {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {f : α -> G₀} {l : Filter.{u2} α} {a : G₀}, (Filter.Tendsto.{u2, u1} α G₀ f l (nhds.{u1} G₀ _inst_2 a)) -> (forall (m : Int), (Or (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (Filter.Tendsto.{u2, u1} α G₀ (fun (x : α) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m) l (nhds.{u1} G₀ _inst_2 (HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) a m))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.zpow₀ Filter.Tendsto.zpow₀ₓ'. -/\ntheorem Filter.Tendsto.zpow₀ {f : α → G₀} {l : Filter α} {a : G₀} (hf : Tendsto f l (𝓝 a)) (m : ℤ)\n    (h : a ≠ 0 ∨ 0 ≤ m) : Tendsto (fun x => f x ^ m) l (𝓝 (a ^ m)) :=\n  (continuousAt_zpow₀ _ m h).Tendsto.comp hf\n#align filter.tendsto.zpow₀ Filter.Tendsto.zpow₀\n\nvariable {X : Type _} [TopologicalSpace X] {a : X} {s : Set X} {f : X → G₀}\n\n/- warning: continuous_at.zpow₀ -> ContinuousAt.zpow₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {f : X -> G₀}, (ContinuousAt.{u2, u1} X G₀ _inst_5 _inst_2 f a) -> (forall (m : Int), (Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))) (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) m)) -> (ContinuousAt.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m) a))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {f : X -> G₀}, (ContinuousAt.{u2, u1} X G₀ _inst_5 _inst_2 f a) -> (forall (m : Int), (Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (ContinuousAt.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m) a))\nCase conversion may be inaccurate. Consider using '#align continuous_at.zpow₀ ContinuousAt.zpow₀ₓ'. -/\ntheorem ContinuousAt.zpow₀ (hf : ContinuousAt f a) (m : ℤ) (h : f a ≠ 0 ∨ 0 ≤ m) :\n    ContinuousAt (fun x => f x ^ m) a :=\n  hf.zpow₀ m h\n#align continuous_at.zpow₀ ContinuousAt.zpow₀\n\n/- warning: continuous_within_at.zpow₀ -> ContinuousWithinAt.zpow₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {s : Set.{u2} X} {f : X -> G₀}, (ContinuousWithinAt.{u2, u1} X G₀ _inst_5 _inst_2 f s a) -> (forall (m : Int), (Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))) (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) m)) -> (ContinuousWithinAt.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m) s a))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {s : Set.{u2} X} {f : X -> G₀}, (ContinuousWithinAt.{u2, u1} X G₀ _inst_5 _inst_2 f s a) -> (forall (m : Int), (Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (ContinuousWithinAt.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m) s a))\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.zpow₀ ContinuousWithinAt.zpow₀ₓ'. -/\ntheorem ContinuousWithinAt.zpow₀ (hf : ContinuousWithinAt f s a) (m : ℤ) (h : f a ≠ 0 ∨ 0 ≤ m) :\n    ContinuousWithinAt (fun x => f x ^ m) s a :=\n  hf.zpow₀ m h\n#align continuous_within_at.zpow₀ ContinuousWithinAt.zpow₀\n\n/- warning: continuous_on.zpow₀ -> ContinuousOn.zpow₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {s : Set.{u2} X} {f : X -> G₀}, (ContinuousOn.{u2, u1} X G₀ _inst_5 _inst_2 f s) -> (forall (m : Int), (forall (a : X), (Membership.Mem.{u2, u2} X (Set.{u2} X) (Set.hasMem.{u2} X) a s) -> (Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))) (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) m))) -> (ContinuousOn.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m) s))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {s : Set.{u2} X} {f : X -> G₀}, (ContinuousOn.{u2, u1} X G₀ _inst_5 _inst_2 f s) -> (forall (m : Int), (forall (a : X), (Membership.mem.{u2, u2} X (Set.{u2} X) (Set.instMembershipSet.{u2} X) a s) -> (Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m))) -> (ContinuousOn.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m) s))\nCase conversion may be inaccurate. Consider using '#align continuous_on.zpow₀ ContinuousOn.zpow₀ₓ'. -/\ntheorem ContinuousOn.zpow₀ (hf : ContinuousOn f s) (m : ℤ) (h : ∀ a ∈ s, f a ≠ 0 ∨ 0 ≤ m) :\n    ContinuousOn (fun x => f x ^ m) s := fun a ha => (hf a ha).zpow₀ m (h a ha)\n#align continuous_on.zpow₀ ContinuousOn.zpow₀\n\n/- warning: continuous.zpow₀ -> Continuous.zpow₀ is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))) (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {f : X -> G₀}, (Continuous.{u2, u1} X G₀ _inst_5 _inst_2 f) -> (forall (m : Int), (forall (a : X), Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)))))))) (LE.le.{0} Int Int.hasLe (OfNat.ofNat.{0} Int 0 (OfNat.mk.{0} Int 0 (Zero.zero.{0} Int Int.hasZero))) m)) -> (Continuous.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m)))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G₀] [_inst_2 : TopologicalSpace.{u1} G₀] [_inst_3 : HasContinuousInv₀.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1)) (GroupWithZero.toInv.{u1} G₀ _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G₀ _inst_2 (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {f : X -> G₀}, (Continuous.{u2, u1} X G₀ _inst_5 _inst_2 f) -> (forall (m : Int), (forall (a : X), Or (Ne.{succ u1} G₀ (f a) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (Continuous.{u2, u1} X G₀ _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G₀ Int G₀ (instHPow.{u1, 0} G₀ Int (DivInvMonoid.Pow.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_1))) (f x) m)))\nCase conversion may be inaccurate. Consider using '#align continuous.zpow₀ Continuous.zpow₀ₓ'. -/\n@[continuity]\ntheorem Continuous.zpow₀ (hf : Continuous f) (m : ℤ) (h0 : ∀ a, f a ≠ 0 ∨ 0 ≤ m) :\n    Continuous fun x => f x ^ m :=\n  continuous_iff_continuousAt.2 fun x => (hf.Tendsto x).zpow₀ m (h0 x)\n#align continuous.zpow₀ Continuous.zpow₀\n\nend Zpow\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Algebra/GroupWithZero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4671266230136839}}
{"text": "/-\nCopyright 2021 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\n\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.sum\nimport formal_ml.lattice\nimport formal_ml.measurable_space\nimport formal_ml.classical\nimport data.equiv.list\nimport formal_ml.prod_measure\nimport formal_ml.finite_pi_measure\nimport formal_ml.probability_space\n\n/-\n  This file allows the construction of new probability spaces. This is useful\n  in particular when you want to consider a hypothetical scenario to relate back\n  to a real one.\n\n  For a family of random variables X indexed over β, there are a variety of operations.\n  1. pi.random_variable: We can create a new family of random variables Y, where for all (b:β),\n     X b and Y b are identical, and for any (b b':β), Y b and Y b' are independent.\n     A new probability measure is created for Y.\n  2. pi.random_variable_combine: create a new single random variable whose domain is\n     a function. Note: this does not create a new probability measure.\n\n  There are also some functions which work with a single random variable.\n  1. pi.rv: create a random variable that maps from a product probability measure to\n     a outcome space of a single measure in the product.\n  \n\n\n-/\n\n\nnoncomputable def prod.measure_space {α β:Type*} (Mα:measure_theory.measure_space α) (Mβ:measure_theory.measure_space β):measure_theory.measure_space (α × β) :=\n  @measure_theory.measure_space.mk (α × β) (@prod.measurable_space α β Mα.to_measurable_space Mβ.to_measurable_space) (prod.measure Mα.volume Mβ.volume)\n\nlemma prod.measure_space.apply (α β:Type*) (Mα:measure_theory.measure_space α) (Mβ:measure_theory.measure_space β) (S:set (α × β)):\n  @measure_theory.measure_space.volume _ (prod.measure_space Mα Mβ) S =\n  (prod.measure Mα.volume Mβ.volume) S := rfl \n\n\n\nlemma prod.measure_space.apply_prod (α β:Type*) (Mα:measure_theory.measure_space α) (Mβ:measure_theory.measure_space β) (A:set α) (B:set β):measurable_set A →\n  measurable_set B →\n  @measure_theory.measure_space.volume _ (prod.measure_space Mα Mβ) (A.prod B) = \n  (@measure_theory.measure_space.volume _ Mα (A)) * \n  (@measure_theory.measure_space.volume _ Mβ (B)) := begin\n  intros h1 h2,\n  rw prod.measure_space.apply,\n  rw prod.measure.apply_prod,\n  apply h1,\n  apply h2,\nend\n/- This is best understood through the lemma prod.probability_space.apply_prod -/\nnoncomputable def probability_space.prod {α β:Type*} (Pα:probability_space α) (Pβ:probability_space β):probability_space (α × β) := \n@probability_space.mk (α × β) \n  (prod.measure_space Pα.to_measure_space Pβ.to_measure_space)\n  begin\n  simp,\n  have A1:(@set.univ α).prod (@set.univ β) = (@set.univ (α × β)),\n  { simp },\n  rw ← A1,  \n  rw prod.measure_space.apply_prod,\n  repeat { simp },\nend\n\ndef event.prod {α β:Type*} {Pα:probability_space α} {Pβ:probability_space β} \n  (A:event Pα) (B:event Pβ):\n  event (Pα.prod Pβ) := measurable_setB.prod A B\n\nlemma event.prod_def {α β:Type*} {Pα:probability_space α} {Pβ:probability_space β} \n  (A:event Pα) (B:event Pβ):A.prod B = measurable_setB.prod A B := rfl\n\n\n/- This proves that events are independent in the resulting probability space. -/\nlemma prod.probability_space.apply_prod (α β:Type*) (Pα:probability_space α) (Pβ:probability_space β) (A:event Pα) (B:event Pβ):\n  Pr[A.prod B] = Pr[A] * Pr[B] := begin\n  rw ← ennreal.coe_eq_coe,\n  rw ennreal.coe_mul,\n  rw event_prob_def,\n  rw event_prob_def,\n  rw event_prob_def,\n  simp,\n  apply prod.measure_space.apply_prod,\n  apply A.property,\n  apply B.property,\nend\n\n\n/- Measurable functions from a product space to each multiplicand. -/\n\ndef rv_prod_fst {α β:Type*} (Pα:probability_space α) (Pβ:probability_space β):\n(Pα.prod Pβ) →ᵣ Pα.to_measurable_space := mf_fst\n\ndef rv_prod_snd {α β:Type*} (Pα:probability_space α) (Pβ:probability_space β):\n(Pα.prod Pβ) →ᵣ Pβ.to_measurable_space := mf_snd\n\n\n/- Now that we have random variables mapping one probability space to another,\n   we need to compose random variables. -/\ndef rv_compose_rv {α β γ:Type*} {Pα:probability_space α} {Pβ:probability_space β}\n{Mγ:measurable_space γ} (X:Pβ →ᵣ Mγ) (Y:Pα →ᵣ Pβ.to_measurable_space):Pα →ᵣ Mγ := \ncompose_measurable_fun X Y\n\n\n\n\nnoncomputable def random_variable.on_fst {α β γ:Type*} {Pα:probability_space α} {Mγ:measurable_space γ} \n(X:Pα →ᵣ Mγ) (Pβ:probability_space β) := rv_compose_rv X (rv_prod_fst Pα Pβ)\n\nnoncomputable def random_variable.on_snd {α β γ:Type*} {Pβ:probability_space β} {Mγ:measurable_space γ} \n(X:Pβ →ᵣ Mγ) (Pα:probability_space α) := rv_compose_rv X (rv_prod_snd Pα Pβ)\n\n\nlemma Pr_rv_prod_fst_eq {α β:Type*} {Pα:probability_space α} \n  {Pβ:probability_space β} (A:event Pα):\n\n  Pr[(rv_prod_fst Pα Pβ) ∈ᵣ A] = Pr[A] :=\nbegin\n  have h_event_rw:(rv_prod_fst Pα Pβ ∈ᵣ A) = \n           A.prod event_univ,\n  { apply event.eq, simp [rv_prod_fst, event_univ, event.prod], ext ω, simp,\n    split; intros h_1; simp [h_1], }, \n  rw h_event_rw,\n  rw prod.probability_space.apply_prod,\n  simp [rv_prod_fst, mf_fst],\nend\n\nlemma Pr_rv_prod_snd_eq {α β:Type*} {Pα:probability_space α} \n  {Pβ:probability_space β} (B:event Pβ):\n  Pr[(rv_prod_snd Pα Pβ) ∈ᵣ B] = Pr[B] :=\nbegin\n  have h_event_rw:(rv_prod_snd Pα Pβ ∈ᵣ B) = \n           event_univ.prod B,\n  { apply event.eq, simp [rv_prod_snd, event_univ, event.prod], ext ω, simp,\n    split; intros h_1; simp [h_1], }, \n  rw h_event_rw,\n  rw prod.probability_space.apply_prod,\n  simp [rv_prod_fst, mf_fst],\nend\n\n\nlemma ind_rv_prod_fst_rv_prod_snd {α β:Type*} {Pα:probability_space α} \n  {Pβ:probability_space β}:\n  random_variable_independent_pair (rv_prod_fst Pα Pβ) (rv_prod_snd Pα Pβ) :=\nbegin\n  intros A B,\n  let A':event Pα := A,\n  let B':event Pβ := B,\n  begin\n    unfold independent_event_pair,\n    have h_event_rw:(rv_prod_fst Pα Pβ ∈ᵣ A∧rv_prod_snd Pα Pβ ∈ᵣ B) = \n             A'.prod B',\n    { apply event.eq, simp [rv_prod_fst, rv_prod_snd, A', B', event.prod], ext ω, simp },\n    rw h_event_rw,\n    rw Pr_rv_prod_fst_eq,\n    rw Pr_rv_prod_snd_eq,\n    rw prod.probability_space.apply_prod,\n  end\nend\n\n\n\nlemma random_variable.on_fst_on_snd_ind {α β γ κ:Type*} {Pα:probability_space α} \n  {Pβ:probability_space β} {Mγ:measurable_space γ} {Mκ:measurable_space κ} \n{X:Pα →ᵣ Mγ} {Y:Pβ →ᵣ Mκ}:\n  random_variable_independent_pair (X.on_fst Pβ) (Y.on_snd Pα) :=\nbegin\n  simp [random_variable.on_fst, random_variable.on_snd, rv_compose_rv],\n  apply compose_independent_pair_left,\n  apply compose_independent_pair_right,\n  apply ind_rv_prod_fst_rv_prod_snd,\nend\n\n\n/- Creates a pair of random variables that are independent and defined over the\n   same probability space that are identical to the given random variables X and Y. -/\nnoncomputable def random_variable.pair_ind {α β γ κ:Type*} {Pα:probability_space α} \n  {Pβ:probability_space β} {Mγ:measurable_space γ} {Mκ:measurable_space κ} \n(X:Pα →ᵣ Mγ) (Y:Pβ →ᵣ Mκ):prod (Pα.prod Pβ →ᵣ Mγ) (Pα.prod Pβ →ᵣ Mκ) :=\n   prod.mk (X.on_fst Pβ) (Y.on_snd Pα)\n\nnoncomputable def pi.measure_space {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} (M:∀ a, measure_theory.measure_space (β a)):\n  measure_theory.measure_space (Π a, β a) :=\n  @measure_theory.measure_space.mk (Π a, β a) (@measurable_space.pi α β (λ a, (M a).to_measurable_space)) (pi.measure (λ a, (M a).volume))\n\nlemma pi.measure_space.apply {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} (M:∀ a, measure_theory.measure_space (β a)) (S:set (Π a, β a)):\n  @measure_theory.measure_space.volume _ (pi.measure_space M) S =\n  (pi.measure  (λ a, (M a).volume)) S := rfl \n\n\nlemma pi.measure_space.apply_prod {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} (M:∀ a, measure_theory.measure_space (β a)) {S:Π a, set (β a)}:\n  (∀ a, measurable_set (S a)) →\n  @measure_theory.measure_space.volume _ (pi.measure_space M) (set.pi set.univ S) =\n  finset.univ.prod (λ a, @measure_theory.measure_space.volume _ (M a) (S a)) := begin\n  intros h1,\n  rw pi.measure_space.apply,\n  rw pi.measure.apply_prod,\n  apply h1,\nend\n\nlemma pi.measure_space.Inf_sum2 {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*} (M:Π (a:α), measure_theory.measure_space (β a)) {P:set (Π (a:α), β a)}:\n  measurable_set P →\n  @measure_theory.measure_space.volume _ (pi.measure_space M) P = \n\n  (⨅ (f:ℕ → (Π (a:α), set (β a))) (h₁:∀ n m, measurable_set (f n m))\n  (h₃:P ⊆ ⋃ (n:ℕ), set.pi set.univ (f n)), \n  ∑' (n:ℕ), finset.univ.prod (λ (m:α), \n  @measure_theory.measure_space.volume _ (M m) (f n m))) := begin\n  intros h1,\n  rw pi.measure_space.apply,\n  rw pi.measure_apply,\n  rw pi.outer_measure.Inf_sum2,\n  apply h1,\nend\n\n\nnoncomputable def pi.probability_space {α:Type*} [F:fintype α] [N:nonempty α] {β:α → Type*}\n   (P:Π a, probability_space (β a)):probability_space (Π a, β a) := \n  @probability_space.mk (Π a, β a) \n  (pi.measure_space (λ a, (P a).to_measure_space))\n  begin\n  simp,\n  have A1:set.pi set.univ (λ a, @set.univ (β a)) = (@set.univ (Π a, β a)),\n  { ext1 ω, split;intros A1_1; simp at A1_1, simp, },\n  rw ← A1,\n  rw pi.measure_space.apply_prod,\n  simp,\n  simp, \nend\n\n\ndef set.pi_event {α:Type*} {β:α → Type*} [F:fintype α] [N:nonempty α] \n  {P:Π a, probability_space (β a)}\n  (T:set α) (E:Π a, event (P a)):event (pi.probability_space P) := T.pi_measurable E\n\n\nlemma set.pi_event_univ {α:Type*} [F:fintype α] [N:nonempty α] \n{β:α → Type*} {P:Π a, probability_space (β a)}\n(S:Π a, event (P a)) (T:set α) [decidable_pred T]:set.pi_event T S = set.pi_event \n(@set.univ α) (λ (a:α), if (a∈ T) then (S a) else (@event_univ (β a) (P a))) :=\nbegin\n  apply set.pi_measurable_univ,\nend\n\n\nlemma pi.probability_space.apply_prod {α:Type*} {β:α → Type*} [F:fintype α] [N:nonempty α] \n  {P:Π a, probability_space (β a)}\n  (E:Π a, event (P a)):Pr[set.pi_event set.univ E] = finset.univ.prod (λ a, Pr[E a]) := begin  \n  rw ← ennreal.coe_eq_coe,\n  rw ennreal.coe_finset_prod,\n  simp [event_prob_def],\n  apply pi.measure_space.apply_prod,\n  intros a,\n  apply (E a).property,\nend\n\nlemma pi.probability_space.apply_prod' {α:Type*} {β:α → Type*} [F:fintype α] [N:nonempty α] \n  {P:Π a, probability_space (β a)} {T:finset α}\n  (E:Π a, event (P a)):Pr[set.pi_event (↑T) E] = T.prod (λ a, Pr[E a]) := begin\n  classical,\n  --have A1:=decidable.pred T,\n  rw set.pi_event_univ,\n  rw pi.probability_space.apply_prod,\n  --rw @finset.prod_congr _ _ finset.univ finset.univ,\n  \n  have A2:finset.univ.prod (λ (a:α), if (a ∈ @coe (finset α) (set α) _ T) then Pr[E a] else 1) = \n          T.prod (λ (a:α), if (a ∈ @coe (finset α) (set α) _ T) then Pr[E a] else 1),\n  { rw ← finset.prod_subset,\n    { rw finset.subset_iff, intros x h_1, simp },\n    intros x h_unused h_x_notin_T,\n    rw if_neg,\n    intros contra,\n    apply h_x_notin_T,\n    rw ← finset.mem_coe,\n    apply contra },\n  have A3:T.prod (λ (a:α), if (a ∈ @coe (finset α) (set α) _ T) then Pr[E a] else 1) =\n          T.prod (λ (a:α), Pr[E a]),\n  { apply finset.prod_congr,\n    refl,\n    intros x A3_1,\n    rw if_pos,\n    simp,\n    apply A3_1 },\n  rw ← A3,\n  rw ← A2,\n  apply finset.prod_congr,\n  { refl },\n  { intros x A4, \n    cases classical.em (x ∈ @coe (finset α) (set α) _ T) with A5 A5,\n    rw if_pos A5,\n    rw if_pos A5,\n    rw if_neg A5,\n    rw if_neg A5,\n    simp },\nend\n\ndef mf_pi {α:Type*} {β:α → Type*} (M:Π a, measurable_space (β a)) \n   (a:α):measurable_fun (@measurable_space.pi α β M) (M a) := @subtype.mk\n  ((Π a, β a) → (β a))\n  measurable\n  (λ (d:Π a, β a), d a)\n  begin\n    apply measurable_pi_apply,\n  end\n\n\ndef pi.rv {α:Type*} {β:α → Type*} [F:fintype α] [N:nonempty α] \n  (P:Π a, probability_space (β a)) (a:α):(pi.probability_space P) →ᵣ (P a).to_measurable_space := mf_pi (λ a, (P a).to_measurable_space) a\n\nnoncomputable def pi.random_variable_proj {α:Type*} {β:α → Type*} {γ:Type*} [F:fintype α] [N:nonempty α] \n  (P:Π a, probability_space (β a)) (a:α) {M:measurable_space γ} (X:(P a) →ᵣ (M)):(pi.probability_space P) →ᵣ M := X ∘r (pi.rv P a)\n\n/- Unify a collection of random variables to be independent random variables under a single probability measure. -/\nnoncomputable def pi.random_variable {α:Type*} {β:α → Type*} {γ:α → Type*} [F:fintype α] [N:nonempty α] \n  {P:Π a, probability_space (β a)} {M:Π a, measurable_space (γ a)} (X:Π a, (P a) →ᵣ (M a)):Π a, (pi.probability_space P) →ᵣ (M a) := (λ a, pi.random_variable_proj P a (X a))\n\nlemma pi.rv_eq {α:Type*} {β:α → Type*} [F:fintype α] [N:nonempty α] \n  (P:Π a, probability_space (β a)) (a:α) (E:event (P a)):\n  Pr[(pi.rv P a)∈ᵣ E] = Pr[E] := begin\n  classical,\n  have A1:∀ (a':α), ∃ (E':event (P a')), Π (h:a=a'),E = @cast (event (P a')) \n    (event (P a)) begin rw h end E',  \n  { intros a', cases classical.em (a=a') with A1_1 A1_1,\n    { subst a', apply exists.intro E, intros h, refl },\n    { apply exists.intro (@event_univ (β a') (P a')),\n      intros h, exfalso, apply A1_1, apply h } },\n  have A2 := classical.axiom_of_choice A1,\n  cases A2 with E' A2,\n  have A4:a=a := rfl,\n  have A5 := A2 a A4,\n  have A3:(set.pi_event (@coe (finset α) (set α) _ {a}) E') = ((pi.rv P a)∈ᵣ E),\n  { apply event.eq,\n    ext ω,\n    simp [set.pi_event,pi.rv,set.pi_measurable,mf_pi],\n    subst E,\n    refl, \n     },\n  rw ← A3,\n  rw pi.probability_space.apply_prod',\n  simp,\n  subst E,\n  refl,\nend\n\nlemma pi.random_variable_proj_identical {α:Type*} {β:α → Type*} {γ:Type*} [F:fintype α] [N:nonempty α] \n  (P:Π a, probability_space (β a)) (a:α) {M:measurable_space γ} (X:(P a) →ᵣ (M)):\n  random_variable_identical (pi.random_variable_proj P a X) X :=\nbegin\n  intros S,\n  simp [pi.random_variable_proj],\n  rw rv_compose_measurable_setB,\n  apply pi.rv_eq,\nend\n\n--(pi.probability_space P) →ᵣ M := X ∘r (pi.rv P a)\n\n\n\nlemma pi.rv_independent {α:Type*} {β:α → Type*} [F:fintype α] [N:nonempty α] \n  (P:Π a, probability_space (β a)):\n  random_variable_independent (pi.rv P) :=\nbegin\n  classical,\n  intros S,\n  intros T,\n  have h1:(∀ᵣ (s : α) in T,(λ (b : α), @pi.rv α (λ (a : α), β a) F N P b ∈ᵣ S b) s) =\n          set.pi_event (↑T) S,\n  { apply event.eq,\n    ext1 ω,\n    simp [set.pi_event, set.pi_measurable, pi.rv, mf_pi] },\n  rw h1,\n  rw pi.probability_space.apply_prod',\n  apply finset.prod_congr,\n  refl,\n  intros x A1,\n  rw pi.rv_eq,\nend\n\nlemma pi.random_variable_independent {α:Type*} {β:α → Type*} {γ:α → Type*} [F:fintype α] \n  [N:nonempty α] (P:Π a, probability_space (β a)) {M:Π a, measurable_space (γ a)} \n  (X:Π a, (P a) →ᵣ (M a)):\n  random_variable_independent (pi.random_variable X) :=\nbegin\n  simp [pi.random_variable, pi.random_variable_proj, rv_compose_rv],\n  apply compose_independent',\n  apply pi.rv_independent,\nend\n\nnoncomputable def pi.random_variable_IID {β γ:Type*} {P:probability_space β} \n  {M:measurable_space γ} (X:P →ᵣ M) (m:nat):(fin m.succ) → \n  (pi.probability_space (λ (m:fin m.succ), P) →ᵣ M)\n\n := \n@pi.random_variable (fin m.succ) (λ (a:fin m.succ), β) \n  (λ (a:fin m.succ), γ) _  _ \n  (λ a, P) (λ a, M) (λ a, X) \n\n\nlemma pi.random_variable_IID_independent {β γ:Type*} {P:probability_space β} \n  {M:measurable_space γ} (X:P →ᵣ M) (m:nat):\n  random_variable_independent (pi.random_variable_IID X m) := begin\n  simp [random_variable_independent],\n  apply pi.random_variable_independent,\nend\n\n\nlemma pi.random_variable_IID_identical {β γ:Type*} {P:probability_space β} \n  {M:measurable_space γ} (X:P →ᵣ M) (m:nat) (i:fin m.succ):\n  random_variable_identical (pi.random_variable_IID X m i) \n  X := begin\n  simp [pi.random_variable_IID, pi.random_variable],\n  apply pi.random_variable_proj_identical,\nend\n\nlemma pi.random_variable_IID_identical' {β γ:Type*} {P:probability_space β} \n  {M:measurable_space γ} (X:P →ᵣ M) (m:nat) (i j:fin m.succ):\n  random_variable_identical (pi.random_variable_IID X m i) \n  (pi.random_variable_IID X m j) := begin\n  apply random_variable_identical.trans,\n  apply pi.random_variable_IID_identical,\n  apply random_variable_identical.symm,\n  apply pi.random_variable_IID_identical,\nend\n\nlemma pi.random_variable_IID_IID {β γ:Type*} {P:probability_space β} \n  {M:measurable_space γ} (X:P →ᵣ M) (m:nat):\n  random_variables_IID (pi.random_variable_IID X m) := begin\n  simp [random_variables_IID],\n  split,\n  apply pi.random_variable_IID_independent,\n  intros i j,\n  apply pi.random_variable_IID_identical',\nend\n\n/- Pair a random variable with a collection of random variables.\n   Since the collection of random variables already share a probability\n   measure, we make sure that the resulting random variables\n   share the product measure of Pα and Pβ. -/\nnoncomputable def random_variable.pair_collection {α β γ κ δ:Type*}  \n  {Pα:probability_space α} \n  {Pβ:probability_space β} {Mγ:measurable_space γ} {Mκ:measurable_space κ} \n(X:δ → Pα →ᵣ Mγ) (Y:Pβ →ᵣ Mκ):prod (δ → Pα.prod Pβ →ᵣ Mγ) (Pα.prod Pβ →ᵣ Mκ) :=\n   prod.mk (λ (d:δ), (X d).on_fst Pβ) (Y.on_snd Pα)\n\n\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/prod_probability_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4671266230136839}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.reflexive\nimport Mathlib.category_theory.limits.preserves.limits\nimport Mathlib.category_theory.monad.limits\nimport Mathlib.category_theory.monad.coequalizer\nimport Mathlib.PostPort\n\nuniverses v₁ u₁ u₂ \n\nnamespace Mathlib\n\n/-!\n# Monadicity theorems\n\nWe prove monadicity theorems which can establish a given functor is monadic. In particular, we\nshow three versions of Beck's monadicity theorem, and the reflexive (crude) monadicity theorem:\n\n`G` is a monadic right adjoint if it has a right adjoint, and:\n\n* `D` has, `G` preserves and reflects `G`-split coequalizers, see\n  `category_theory.monad.monadic_of_has_preserves_reflects_G_split_coequalizers`\n* `G` creates `G`-split coequalizers, see\n  `category_theory.monad.monadic_of_creates_G_split_coequalizers`\n  (The converse of this is also shown, see\n   `category_theory.monad.creates_G_split_coequalizers_of_monadic`)\n* `D` has and `G` preserves `G`-split coequalizers, and `G` reflects isomorphisms, see\n  `category_theory.monad.monadic_of_has_preserves_G_split_coequalizers_of_reflects_isomorphisms`\n* `D` has and `G` preserves reflexive coequalizers, and `G` reflects isomorphisms, see\n  `category_theory.monad.monadic_of_has_preserves_reflexive_coequalizers_of_reflects_isomorphisms`\n\n## Tags\n\nBeck, monadicity, descent\n\n## TODO\n\nDualise to show comonadicity theorems.\n-/\n\nnamespace category_theory\n\n\nnamespace monad\n\n\n-- Hide the implementation details in this namespace.\n\nnamespace monadicity_internal\n\n\n-- We use these parameters and notations to simplify the statements of internal constructions\n\n-- here.\n\n/--\nThe \"main pair\" for an algebra `(A, α)` is the pair of morphisms `(F α, ε_FA)`. It is always a\nreflexive pair, and will be used to construct the left adjoint to the comparison functor and show it\nis an equivalence.\n-/\nprotected instance main_pair_reflexive {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (A : algebra (left_adjoint G ⋙ G)) : is_reflexive_pair (functor.map (left_adjoint G) (algebra.a A))\n  (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A))) := sorry\n\n/--\nThe \"main pair\" for an algebra `(A, α)` is the pair of morphisms `(F α, ε_FA)`. It is always a\n`G`-split pair, and will be used to construct the left adjoint to the comparison functor and show it\nis an equivalence.\n-/\nprotected instance main_pair_G_split {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (A : algebra (left_adjoint G ⋙ G)) : functor.is_split_pair G (functor.map (left_adjoint G) (algebra.a A))\n  (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A))) :=\n  has_split_coequalizer.mk\n    (Exists.intro (algebra.A A) (Exists.intro (algebra.a A) (Nonempty.intro (beck_split_coequalizer A))))\n\n/-- The object function for the left adjoint to the comparison functor. -/\ndef comparison_left_adjoint_obj {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (A : algebra (left_adjoint G ⋙ G)) [limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n  (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] : D :=\n  limits.coequalizer (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))\n\n/--\nWe have a bijection of homsets which will be used to construct the left adjoint to the comparison\nfunctor.\n-/\ndef comparison_left_adjoint_hom_equiv {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (A : algebra (left_adjoint G ⋙ G)) (B : D) [limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n  (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] : (comparison_left_adjoint_obj A ⟶ B) ≃ (A ⟶ functor.obj (comparison G) B) :=\n  equiv.trans\n    (equiv.trans\n      (limits.cofork.is_colimit.hom_iso\n        (limits.colimit.is_colimit\n          (limits.parallel_pair (functor.map (left_adjoint G) (algebra.a A))\n            (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G))\n              (functor.obj (left_adjoint G) (algebra.A A)))))\n        B)\n      (equiv.subtype_congr (adjunction.hom_equiv (adjunction.of_right_adjoint G) (algebra.A A) B) sorry))\n    (equiv.mk\n      (fun\n        (g :\n        Subtype\n          fun (g : algebra.A A ⟶ functor.obj G B) =>\n            functor.map G (functor.map (left_adjoint G) g) ≫\n                functor.map G (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) B) =\n              algebra.a A ≫ g) =>\n        algebra.hom.mk ↑g)\n      (fun (f : A ⟶ functor.obj (comparison G) B) => { val := algebra.hom.f f, property := sorry }) sorry sorry)\n\n/--\nConstruct the adjunction to the comparison functor.\n-/\ndef left_adjoint_comparison {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] [∀ (A : algebra (left_adjoint G ⋙ G)),\n  limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] : algebra (left_adjoint G ⋙ G) ⥤ D :=\n  adjunction.left_adjoint_of_equiv\n    (fun (A : algebra (left_adjoint G ⋙ G)) (B : D) => comparison_left_adjoint_hom_equiv A B) sorry\n\n/--\nProvided we have the appropriate coequalizers, we have an adjunction to the comparison functor.\n-/\ndef comparison_adjunction {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] [∀ (A : algebra (left_adjoint G ⋙ G)),\n  limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] : left_adjoint_comparison ⊣ comparison G :=\n  adjunction.adjunction_of_equiv_left\n    (fun (A : algebra (left_adjoint G ⋙ G)) (B : D) => comparison_left_adjoint_hom_equiv A B) sorry\n\ntheorem comparison_adjunction_unit_f_aux {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] [∀ (A : algebra (left_adjoint G ⋙ G)),\n  limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] (A : algebra (left_adjoint G ⋙ G)) : algebra.hom.f (nat_trans.app (adjunction.unit comparison_adjunction) A) =\n  coe_fn\n    (adjunction.hom_equiv (adjunction.of_right_adjoint G) (algebra.A A)\n      (limits.coequalizer (functor.map (left_adjoint G) (algebra.a A))\n        (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G))\n          (functor.obj (left_adjoint G) (algebra.A A)))))\n    (limits.coequalizer.π (functor.map (left_adjoint G) (algebra.a A))\n      (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))) := sorry\n\n/--\nThis is a cofork which is helpful for establishing monadicity: the morphism from the Beck\ncoequalizer to this cofork is the unit for the adjunction on the comparison functor.\n-/\n@[simp] theorem unit_cofork_ι_app {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (A : algebra (left_adjoint G ⋙ G)) [limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n  (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] (X : limits.walking_parallel_pair) : nat_trans.app (limits.cocone.ι (unit_cofork A)) X =\n  limits.walking_parallel_pair.rec\n    (functor.map G (functor.map (left_adjoint G) (algebra.a A)) ≫\n      functor.map G\n        (limits.coequalizer.π (functor.map (left_adjoint G) (algebra.a A))\n          (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G))\n            (functor.obj (left_adjoint G) (algebra.A A)))))\n    (functor.map G\n      (limits.coequalizer.π (functor.map (left_adjoint G) (algebra.a A))\n        (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G))\n          (functor.obj (left_adjoint G) (algebra.A A)))))\n    X := sorry\n\ntheorem comparison_adjunction_unit_f {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] [∀ (A : algebra (left_adjoint G ⋙ G)),\n  limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] (A : algebra (left_adjoint G ⋙ G)) : algebra.hom.f (nat_trans.app (adjunction.unit comparison_adjunction) A) =\n  limits.is_colimit.desc (beck_coequalizer A) (unit_cofork A) := sorry\n\n/--\nThe cofork which describes the counit of the adjunction: the morphism from the coequalizer of\nthis pair to this morphism is the counit.\n-/\n@[simp] theorem counit_cofork_ι_app {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (B : D) (X : limits.walking_parallel_pair) : nat_trans.app (limits.cocone.ι (counit_cofork B)) X =\n  limits.walking_parallel_pair.rec\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G))\n        (functor.obj (left_adjoint G) (functor.obj G B)) ≫\n      nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) B)\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) B) X := sorry\n\n/-- The unit cofork is a colimit provided `G` preserves it.  -/\ndef unit_colimit_of_preserves_coequalizer {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (A : algebra (left_adjoint G ⋙ G)) [limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n  (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] [limits.preserves_colimit\n  (limits.parallel_pair (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A))))\n  G] : limits.is_colimit (unit_cofork A) :=\n  limits.is_colimit_of_has_coequalizer_of_preserves_colimit G (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))\n\n/-- The counit cofork is a colimit provided `G` reflects it. -/\ndef counit_coequalizer_of_reflects_coequalizer {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] (B : D) [limits.reflects_colimit\n  (limits.parallel_pair\n    (functor.map (left_adjoint G) (functor.map G (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) B)))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G))\n      (functor.obj (left_adjoint G) (functor.obj G B))))\n  G] : limits.is_colimit (counit_cofork B) :=\n  limits.is_colimit_of_is_colimit_cofork_map G (counit_cofork._proof_1 B)\n    (beck_coequalizer (functor.obj (comparison G) B))\n\ntheorem comparison_adjunction_counit_app {C : Type u₁} {D : Type u₂} [category C] [category D] {G : D ⥤ C} [is_right_adjoint G] [∀ (A : algebra (left_adjoint G ⋙ G)),\n  limits.has_coequalizer (functor.map (left_adjoint G) (algebra.a A))\n    (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) (functor.obj (left_adjoint G) (algebra.A A)))] (B : D) : nat_trans.app (adjunction.counit comparison_adjunction) B =\n  limits.colimit.desc\n    (limits.parallel_pair\n      (functor.map (left_adjoint G)\n        (functor.map G (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) B)))\n      (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G))\n        (functor.obj (left_adjoint G) (functor.obj G B))))\n    (counit_cofork B) := sorry\n\nend monadicity_internal\n\n\n/--\nIf `G` is monadic, it creates colimits of `G`-split pairs. This is the \"boring\" direction of Beck's\nmonadicity theorem, the converse is given in `monadic_of_creates_G_split_coequalizers`.\n-/\ndef creates_G_split_coequalizers_of_monadic {C : Type u₁} {D : Type u₂} [category C] [category D] (G : D ⥤ C) [monadic_right_adjoint G] {A : D} {B : D} (f : A ⟶ B) (g : A ⟶ B) [functor.is_split_pair G f g] : creates_colimit (limits.parallel_pair f g) G :=\n  monadic_creates_colimit_of_preserves_colimit G (limits.parallel_pair f g)\n\n/--\nTo show `G` is a monadic right adjoint, we can show it preserves and reflects `G`-split\ncoequalizers, and `C` has them.\n-/\ndef monadic_of_has_preserves_reflects_G_split_coequalizers {C : Type u₁} {D : Type u₂} [category C] [category D] (G : D ⥤ C) [is_right_adjoint G] [∀ {A B : D} (f g : A ⟶ B) [_inst_5 : functor.is_split_pair G f g], limits.has_coequalizer f g] [{A B : D} →\n  (f g : A ⟶ B) → [_inst_7 : functor.is_split_pair G f g] → limits.preserves_colimit (limits.parallel_pair f g) G] [{A B : D} →\n  (f g : A ⟶ B) → [_inst_9 : functor.is_split_pair G f g] → limits.reflects_colimit (limits.parallel_pair f g) G] : monadic_right_adjoint G := sorry\n\n/--\nBeck's monadicity theorem. If `G` has a right adjoint and creates coequalizers of `G`-split pairs,\nthen it is monadic.\nThis is the converse of `creates_G_split_of_monadic`.\n-/\ndef monadic_of_creates_G_split_coequalizers {C : Type u₁} {D : Type u₂} [category C] [category D] (G : D ⥤ C) [is_right_adjoint G] [{A B : D} → (f g : A ⟶ B) → [_inst_5 : functor.is_split_pair G f g] → creates_colimit (limits.parallel_pair f g) G] : monadic_right_adjoint G :=\n  let _inst :\n    ∀ {A B : D} (f g : A ⟶ B) [_inst_6 : functor.is_split_pair G f g],\n      limits.has_colimit (limits.parallel_pair f g ⋙ G) :=\n    sorry;\n  monadic_of_has_preserves_reflects_G_split_coequalizers G\n\n/--\nAn alternate version of Beck's monadicity theorem. If `G` reflects isomorphisms, preserves\ncoequalizers of `G`-split pairs and `C` has coequalizers of `G`-split pairs, then it is monadic.\n-/\ndef monadic_of_has_preserves_G_split_coequalizers_of_reflects_isomorphisms {C : Type u₁} {D : Type u₂} [category C] [category D] (G : D ⥤ C) [is_right_adjoint G] [reflects_isomorphisms G] [∀ {A B : D} (f g : A ⟶ B) [_inst_6 : functor.is_split_pair G f g], limits.has_coequalizer f g] [{A B : D} →\n  (f g : A ⟶ B) → [_inst_8 : functor.is_split_pair G f g] → limits.preserves_colimit (limits.parallel_pair f g) G] : monadic_right_adjoint G :=\n  monadic_of_has_preserves_reflects_G_split_coequalizers G\n\n/--\nReflexive (crude) monadicity theorem. If `G` has a right adjoint, `D` has and `G` preserves\nreflexive coequalizers and `G` reflects isomorphisms, then `G` is monadic.\n-/\ndef monadic_of_has_preserves_reflexive_coequalizers_of_reflects_isomorphisms {C : Type u₁} {D : Type u₂} [category C] [category D] (G : D ⥤ C) [is_right_adjoint G] [limits.has_reflexive_coequalizers D] [reflects_isomorphisms G] [{A B : D} → (f g : A ⟶ B) → [_inst_7 : is_reflexive_pair f g] → limits.preserves_colimit (limits.parallel_pair f g) G] : monadic_right_adjoint G := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monad/monadicity.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4671266161898023}}
{"text": "import Mathlib.Init.Function\nimport ExtParser.FinUtils\n\nnamespace Grammar\n\n  inductive PEG (n : Nat) where\n    | ε\n    | any\n    | terminal (c : Char)\n    | nonTerminal (vn : Fin n)\n    | seq (p1 p2 : PEG n)\n    | prior (p1 p2 : PEG n)\n    | star (p : PEG n)\n    | notP (p : PEG n)\n  deriving DecidableEq, Repr\n\n  open PEG\n\n  inductive PEG.le : PEG n → PEG n → Prop where\n    | refl        : le p p\n    | seq_left    : le e p1 → le e (.seq p1 p2)\n    | seq_right   : le e p2 → le e (.seq p1 p2)\n    | prior_left  : le e p1 → le e (.prior p1 p2)\n    | prior_right : le e p2 → le e (.prior p1 p2)\n    | star        : le e p → le e (.star p)\n    | notP        : le e p → le e (.notP p)\n  \n  \n  instance : LE (PEG n) where\n    le := PEG.le\n  \n  theorem PEG.le_refl (G : PEG n) : G ≤ G := by exact .refl;\n\n  theorem PEG.le_trans {G1 G2 G3 : PEG n} : G1 ≤ G2 → G2 ≤ G3 → G1 ≤ G3 := by\n    intro h g;\n    match g with\n    | .refl => exact h;\n    | .seq_left g => apply le.seq_left; exact le_trans h g;\n    | .seq_right g => apply le.seq_right; exact le_trans h g;\n    | .prior_left g => apply le.prior_left; exact le_trans h g;\n    | .prior_right g => apply le.prior_right; exact le_trans h g;\n    | .star g => apply le.star; exact le_trans h g;\n    | .notP g => apply le.notP; exact le_trans h g;\n\n  def stringPEG {n : Nat} (cs : List Char) : PEG n :=\n    match cs with\n      | [] => ε\n      | c :: cs => seq (terminal c) (stringPEG cs)\n\n  -- Grammar Production Rule\n  structure GProd (n : Nat) where\n    pos_n : 0 < n\n    f : Fin n → PEG n \n\n  -- Maybe Type for known and unknown properties\n  inductive Maybe (p : α → Prop) (a : α) where\n    | found : p a → Maybe p a\n    | unknown\n\n  open Maybe\n\n  mutual\n    -- Property of PEG grammar that can be failed\n    inductive PropF : GProd n → PEG n → Prop where\n      | any : PropF Pexp any\n      | terminal : ∀ (c : Char), PropF Pexp (terminal c)\n      | nonTerminal : ∀ (vn : Fin n), PropF Pexp (Pexp.f vn) → PropF Pexp (nonTerminal vn)\n      | seq_F : ∀ (e1 e2 : PEG n), PropF Pexp e1 → PropF Pexp (seq e1 e2)\n      | seq_0F : ∀ (e1 e2 : PEG n), Prop0 Pexp e1 → PropF Pexp e2 → PropF Pexp (seq e1 e2)\n      | seq_SF : ∀ (e1 e2 : PEG n), PropS Pexp e1 → PropF Pexp e2 → PropF Pexp (seq e1 e2)\n      | prior : ∀ (e1 e2 : PEG n), PropF Pexp e1 → PropF Pexp e2 → PropF Pexp (prior e1 e2)\n      | notP_0 : ∀ (e : PEG n), Prop0 Pexp e → PropF Pexp (notP e)\n      | notP_S : ∀ (e : PEG n), PropS Pexp e → PropF Pexp (notP e)\n\n    -- Property of PEG grammar that can succeed without consuming input\n    inductive Prop0 : GProd n → PEG n → Prop where\n      | ε : Prop0 Pexp ε\n      | nonTerminal : ∀ (vn : Fin n), Prop0 Pexp (Pexp.f vn) → Prop0 Pexp (nonTerminal vn)\n      | seq : ∀ (e1 e2 : PEG n), Prop0 Pexp e1 → Prop0 Pexp e2 → Prop0 Pexp (seq e1 e2)\n      | prior_0 : ∀ (e1 e2 : PEG n), Prop0 Pexp e1 → Prop0 Pexp (prior e1 e2)\n      | prior_F0 : ∀ (e1 e2 : PEG n), PropF Pexp e1 → Prop0 Pexp e2 → Prop0 Pexp (prior e1 e2)\n      | star : ∀ (e : PEG n), PropF Pexp e → Prop0 Pexp (star e)\n      | notP : ∀ (e : PEG n), PropF Pexp e → Prop0 Pexp (notP e)\n\n    -- Property of PEG grammar that can succeed only by consuming input\n    inductive PropS : GProd n → PEG n → Prop where\n      | any : PropS Pexp any\n      | terminal : ∀ (c : Char), PropS Pexp (terminal c)\n      | nonTerminal : ∀ (vn : Fin n), PropS Pexp (Pexp.f vn) → PropS Pexp (nonTerminal vn)\n      | seq_S0 : ∀ (e1 e2 : PEG n), PropS Pexp e1 → Prop0 Pexp e2 → PropS Pexp (seq e1 e2)\n      | seq_0S : ∀ (e1 e2 : PEG n), Prop0 Pexp e1 → PropS Pexp e2 → PropS Pexp (seq e1 e2)\n      | seq_SS : ∀ (e1 e2 : PEG n), PropS Pexp e1 → PropS Pexp e2 → PropS Pexp (seq e1 e2)\n      | prior_S : ∀ (e1 e2 : PEG n), PropS Pexp e1 → PropS Pexp (prior e1 e2)\n      | prior_FS : ∀ (e1 e2 : PEG n), PropF Pexp e1 → PropS Pexp e2 → PropS Pexp (prior e1 e2)\n      | star : ∀ (e : PEG n), PropS Pexp e → PropS Pexp (star e)\n  end\n\n  abbrev PropsTriple (Pexp : GProd n) (G : PEG n) := Maybe (PropF Pexp) G × Maybe (Prop0 Pexp) G × Maybe (PropS Pexp) G\n  abbrev PropsTriplePred (Pexp : GProd n) := ∀ (i : Fin n), PropsTriple Pexp (Pexp.f i)\n\n  -- Compute grammar properties in one iteration\n  def g_props {Pexp : GProd n} (G : PEG n) (P : PropsTriplePred Pexp) : PropsTriple Pexp G :=\n    match G with\n    | ε => (unknown, found (Prop0.ε), unknown)\n    | any => (found (PropF.any), unknown, found (PropS.any))\n    | terminal c => (found (PropF.terminal c), unknown, found (PropS.terminal c))\n    | nonTerminal vn =>\n      have (e_f, e_0, e_s) := P vn\n      (\n        match e_f with\n          | found h => found (PropF.nonTerminal vn h)\n          | unknown => unknown\n        ,\n        match e_0 with\n          | found h => found (Prop0.nonTerminal vn h)\n          | unknown => unknown\n        ,\n        match e_s with\n          | found h => found (PropS.nonTerminal vn h)\n          | unknown => unknown\n      )\n    | seq e1 e2 =>\n      have (e1_f, e1_0, e1_s) := g_props e1 P;\n      have (e2_f, e2_0, e2_s) := g_props e2 P;\n      (\n        match (e1_f, e1_0, e1_s, e2_f) with\n          | (found h, _, _, _) => found (PropF.seq_F e1 e2 h)\n          | (_,found h0,_,found hf) => found (PropF.seq_0F e1 e2 h0 hf)\n          | (_,_,found hs,found hf) => found (PropF.seq_SF e1 e2 hs hf)\n          | _ => unknown\n        ,\n        match (e1_0, e2_0) with\n          | (found h1, found h2) => found (Prop0.seq e1 e2 h1 h2)\n          | _ => unknown\n        ,\n        match (e1_0, e1_s, e2_0, e2_s) with\n          | (_,found hs,found h0,_) => found (PropS.seq_S0 e1 e2 hs h0)\n          | (found h0,_,_,found hs) => found (PropS.seq_0S e1 e2 h0 hs)\n          | (_,found h1,_,found h2) => found (PropS.seq_SS e1 e2 h1 h2)\n          | _ => unknown\n      )\n    | prior e1 e2 =>\n      have (e1_f, e1_0, _) := g_props e1 P;\n      have (e2_f, e2_0, _) := g_props e2 P;\n      (\n        match (e1_f, e2_f) with\n          | (found h1, found h2) => found (PropF.prior e1 e2 h1 h2)\n          | _ => unknown\n        ,\n        match (e1_f, e1_0, e2_0) with\n          | (_,found h,_) => found (Prop0.prior_0 e1 e2 h)\n          | (found hf,_,found h0) => found (Prop0.prior_F0 e1 e2 hf h0)\n          | _ => unknown\n        ,\n        unknown\n      )\n    | star e =>\n      have (e_f, _, e_s) := g_props e P;\n      (\n        unknown\n        ,\n        match e_f with\n          | found h => found (Prop0.star e h)\n          | unknown => unknown\n        ,\n        match e_s with\n          | found h => found (PropS.star e h)\n          | unknown => unknown\n      )\n    | notP e =>\n      have (e_f, e_0, e_s) := g_props e P;\n      (\n        match (e_0, e_s) with\n          | (found h,_) => found (PropF.notP_0 e h)\n          | (_,found h) => found (PropF.notP_S e h)\n          | _ => unknown\n        ,\n        match e_f with\n          | found h => found (Prop0.notP e h)\n          | unknown => unknown\n        ,\n        unknown\n      )\n\n  inductive Maybe.le : Maybe p a → Maybe p a → Prop where\n    | lhs_unknown : ∀ {p : α → Prop} {a : α} {mr : Maybe p a}, Maybe.le unknown mr\n    | all_found : ∀ {p : α → Prop} {a : α}, (l r : p a) → Maybe.le (found l) (found r)\n\n  instance : LE (Maybe p a) where\n    le := Maybe.le\n\n  theorem Maybe.le_refl : ∀ {x : Maybe p a}, x ≤ x := by\n    intro x\n    cases x\n    apply Maybe.le.all_found\n    apply Maybe.le.lhs_unknown\n\n  theorem Maybe.le_trans : ∀ {x y z : Maybe p a}, x ≤ y → y ≤ z → x ≤ z := by\n    intro x y z hxy hyz\n    cases hxy\n    apply Maybe.le.lhs_unknown\n    cases hyz\n    apply Maybe.le.all_found\n\n  theorem Maybe.le.not_found_to_unknown : ∀ {p : α → Prop} {a : α}, (pa : p a) → ¬ (found pa ≤ unknown) := by\n    intro p a pa h\n    cases h\n\n  theorem Maybe.le.equiv_to_imply : ∀ {p : α → Prop} {a : α} {x y : Maybe p a}, x ≤ y ↔ (x = unknown) ∨ (∃ x' y', x = found x' ∧ y = found y') := by\n    intro p a x y\n    apply Iff.intro\n    {\n      intro hxy;\n      cases hxy with\n      | lhs_unknown => apply Or.inl; rfl;\n      | all_found l r => apply Or.inr; exists l; exists r;\n    }\n    {\n      intro h;\n      match h with\n      | Or.inl g => simp [g]; exact Maybe.le.lhs_unknown;\n      | Or.inr ⟨x',⟨y', ⟨fx, fy⟩⟩⟩ => simp [fx, fy]; exact Maybe.le.all_found x' y'\n    }\n  \n  theorem Maybe.eq_of_le_le : ∀ {p : α → Prop} {a : α} {x y : Maybe p a}, x ≤ y → y ≤ x → x = y := by\n    intro p a x y hxy hyx\n    cases hxy <;> cases hyx <;> rfl\n\n  inductive PropsTriple.le (P Q : PropsTriple Pexp G) : Prop where\n    | mk : P.fst ≤ Q.fst → P.snd.fst ≤ Q.snd.fst → P.snd.snd ≤ Q.snd.snd → PropsTriple.le P Q\n\n  instance : LE (PropsTriple Pexp G) where\n    le := PropsTriple.le\n\n  theorem PropsTriple.le_refl : ∀ {x : PropsTriple Pexp G}, x ≤ x := by\n    intro x\n    apply PropsTriple.le.mk <;> apply Maybe.le_refl\n\n  theorem PropsTriple.le_trans : ∀ {x y z : PropsTriple Pexp G}, x ≤ y → y ≤ z → x ≤ z := by\n    intro x y z hxy hyz\n    cases hxy with\n      | mk hxy_f hxy_0 hxy_s => cases hyz with\n        | mk hyz_f hyz_0 hyz_s =>\n          constructor\n          apply Maybe.le_trans hxy_f hyz_f\n          apply Maybe.le_trans hxy_0 hyz_0\n          apply Maybe.le_trans hxy_s hyz_s\n  \n  theorem PropsTriple.eq_of_le_le : ∀ {x y : PropsTriple Pexp G}, x ≤ y → y ≤ x → x = y := by\n    intro x y hxy hyx;\n    match x with\n    | (x1, x2, x3) => match y with\n      | (y1, y2, y3) => \n        cases hxy <;> cases hyx <;> simp_all;\n        apply And.intro; apply Maybe.eq_of_le_le; trivial; trivial;\n        apply And.intro; apply Maybe.eq_of_le_le; trivial; trivial;\n        apply Maybe.eq_of_le_le; trivial; trivial;\n\n\n  inductive PropsTriplePred.le {Pexp : GProd n} (P Q : PropsTriplePred Pexp) : Prop where\n    | mk : (∀ (i : Fin n), (P i) ≤ (Q i)) → PropsTriplePred.le P Q\n\n  instance : LE (PropsTriplePred Pexp) where\n    le := PropsTriplePred.le\n\n  theorem PropsTriplePred.le_refl : ∀ {x : PropsTriplePred Pexp}, x ≤ x := by\n    intro x\n    constructor\n    intro i\n    apply PropsTriple.le_refl\n\n  theorem PropsTriplePred.le_trans : ∀ {x y z : PropsTriplePred Pexp}, x ≤ y → y ≤ z → x ≤ z := by\n    intro x y z (PropsTriplePred.le.mk fxy) (PropsTriplePred.le.mk fyz)\n    constructor\n    intro i\n    apply PropsTriple.le_trans (fxy i) (fyz i)\n  \n  theorem PropsTriplePred.eq_of_le_le : ∀ {x y : PropsTriplePred Pexp}, x ≤ y → y ≤ x → x = y := by\n    intro x y hxy hyx;\n    apply funext;\n    intro i;\n    cases hxy with\n    | mk fxy =>\n      cases hyx with\n      | mk fyx => apply PropsTriple.eq_of_le_le (fxy i) (fyx i);\n  \n\n  theorem g_props_growth_seq : ∀ {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e1 e2 : PEG n}, g_props e1 P ≤ g_props e1 Q → g_props e2 P ≤ g_props e2 Q → g_props (.seq e1 e2) P ≤ g_props (.seq e1 e2) Q := by\n    intros Pexp P Q e1 e2 e1_growth e2_growth\n    cases e1_growth with\n    | mk le1_f le1_0 le1_s => cases e2_growth with\n      | mk le2_f le2_0 le2_s =>\n        {\n          constructor <;> simp [g_props]\n          {\n            match (Maybe.le.equiv_to_imply.mp le1_f) with\n            | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le2_f) with\n              | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n              | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le1_0) with\n                | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le1_s) with\n                  | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e1 Q).fst <;> cases (g_props e1 Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n                | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e1 Q).fst <;> simp <;> apply Maybe.le.all_found\n            | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n          }\n          {\n            match (Maybe.le.equiv_to_imply.mp le1_0) with\n            | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n            | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le2_0) with\n              | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n              | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n          }\n          {\n            match (Maybe.le.equiv_to_imply.mp le1_0) with\n            | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le1_s) with\n              | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n              | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le2_0) with\n                | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le2_s) with\n                  | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e1 Q).snd.fst <;> cases (g_props e2 Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n                | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n            | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le1_s) with\n              | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le2_0) with\n                | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le2_s) with\n                  | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e1 Q).snd.snd <;> cases (g_props e2 Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n                | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le2_s) with\n                  | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e1 Q).snd.snd <;> simp <;> apply Maybe.le.all_found\n              | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le2_0) with\n                | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le2_s) with\n                  | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e2 Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n                | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n          }\n        }\n\n  theorem g_props_growth_nonterminal : ∀ {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {vn} , P ≤ Q → g_props (.nonTerminal vn) P ≤ g_props (.nonTerminal vn) Q := by\n    intros Pexp P Q vn hpq\n    have (PropsTriplePred.le.mk fpq) := hpq\n    cases fpq vn with\n    | mk le_f le_0 le_s =>\n      {\n        constructor <;> simp [g_props]\n        {\n          match (Maybe.le.equiv_to_imply.mp le_f) with\n          | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n          | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n        }\n        {\n          match (Maybe.le.equiv_to_imply.mp le_0) with\n          | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n          | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n        }\n        {\n          match (Maybe.le.equiv_to_imply.mp le_s) with\n          | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n          | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n        }\n      }\n\n  theorem g_props_growth_prior : ∀ {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e1 e2 : PEG n}, g_props e1 P ≤ g_props e1 Q → g_props e2 P ≤ g_props e2 Q  → g_props (.prior e1 e2) P ≤ g_props (.prior e1 e2) Q := by\n    intros Pexp P Q e1 e2 e1_growth e2_growth\n    cases e1_growth with\n    | mk le1_f le1_0 le1_s => cases e2_growth with\n      | mk le2_f le2_0 le2_s =>\n        {\n          constructor <;> simp [g_props]\n          {\n            match (Maybe.le.equiv_to_imply.mp le1_f) with\n            | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n            | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le2_f) with\n              | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n              | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n          }\n          {\n            match (Maybe.le.equiv_to_imply.mp le1_f) with\n            | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le1_0) with\n              | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n              | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n            | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; match (Maybe.le.equiv_to_imply.mp le1_0) with\n              | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le2_0) with\n                | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n                | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e1 Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n              | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n          }\n          {\n            apply Maybe.le.lhs_unknown\n          }\n        }\n\n  theorem g_props_growth_star : ∀ {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e : PEG n}, g_props e P ≤ g_props e Q → g_props (.star e) P ≤ g_props (.star e) Q := by\n    intros Pexp P Q e e_growth\n    cases e_growth with\n    | mk le_f le_0 le_s =>\n      {\n        constructor <;> simp [g_props]\n        {\n          apply Maybe.le.lhs_unknown\n        }\n        {\n          match (Maybe.le.equiv_to_imply.mp le_f) with\n          | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n          | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n        }\n        {\n          match (Maybe.le.equiv_to_imply.mp le_s) with\n          | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n          | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n        }\n      }\n\n  theorem g_props_growth_notP : ∀ {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e : PEG n}, g_props e P ≤ g_props e Q → g_props (.notP e) P ≤ g_props (.notP e) Q := by\n    intros Pexp P Q e e_growth\n    cases e_growth with\n    | mk le_f le_0 le_s =>\n      {\n        constructor <;> simp [g_props]\n        {\n          match (Maybe.le.equiv_to_imply.mp le_0) with\n          | Or.inl h => simp [h]; match (Maybe.le.equiv_to_imply.mp le_s) with\n            | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n            | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; cases (g_props e Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n          | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n        }\n        {\n          match (Maybe.le.equiv_to_imply.mp le_f) with\n          | Or.inl h => simp [h]; apply Maybe.le.lhs_unknown\n          | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy']; apply Maybe.le.all_found\n        }\n        {\n          apply Maybe.le.lhs_unknown\n        }\n      }\n\n  theorem g_props_growth : ∀ {Pexp : GProd n} {G : PEG n} {P Q : PropsTriplePred Pexp}, P ≤ Q → g_props G P ≤ g_props G Q := by\n    intro Pexp G P Q hpq\n    cases G with\n      | ε => apply PropsTriple.le_refl\n      | any => apply PropsTriple.le_refl\n      | terminal c => apply PropsTriple.le_refl\n      | nonTerminal vn => exact g_props_growth_nonterminal hpq\n      | seq e1 e2 =>\n        {\n          have e1_growth : g_props e1 P ≤ g_props e1 Q := g_props_growth hpq;\n          have e2_growth : g_props e2 P ≤ g_props e2 Q := g_props_growth hpq;\n          exact g_props_growth_seq e1_growth e2_growth\n        }\n      | prior e1 e2 =>\n        {\n          have e1_growth : g_props e1 P ≤ g_props e1 Q := g_props_growth hpq;\n          have e2_growth : g_props e2 P ≤ g_props e2 Q := g_props_growth hpq;\n          exact g_props_growth_prior e1_growth e2_growth\n        }\n      | star e =>\n        {\n          have e_growth : g_props e P ≤ g_props e Q := g_props_growth hpq;\n          exact g_props_growth_star e_growth\n        }\n      | notP e =>\n        {\n          have e_growth : g_props e P ≤ g_props e Q := g_props_growth hpq;\n          exact g_props_growth_notP e_growth\n        }\n\n  structure CoherentPred (Pexp : GProd n) where\n    pred : PropsTriplePred Pexp\n    coherent : ∀ (i : Fin n), pred i ≤ g_props (Pexp.f i) pred\n\n  instance : LE (CoherentPred Pexp) where\n    le := fun P Q => P.pred ≤ Q.pred\n  \n  theorem CoherentPred.eq_of_eq_pred : ∀ {x y : CoherentPred Pexp}, x.pred = y.pred → x = y := by\n    intro x y h;\n    cases x; cases y; simp_all;\n\n  theorem CoherentPred.eq_of_le_le : ∀ {x y : CoherentPred Pexp}, x ≤ y → y ≤ x → x = y := by\n    intro x y hxy hyx\n    cases x with\n    | mk xp xc => cases y with\n      | mk yp yc =>\n        cases hxy; cases hyx; simp_all; apply PropsTriplePred.eq_of_le_le <;> constructor <;> trivial;\n\n  def g_extend {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp) : CoherentPred Pexp :=\n    {\n      pred := fun b =>  match Fin.decEq a b with\n                        | isFalse h => P.pred b\n                        | isTrue rfl => g_props (Pexp.f a) P.pred\n      coherent := by\n        intro i; simp\n        cases Fin.decEq a i with\n        | isFalse _ =>\n          simp; apply PropsTriple.le_trans (P.coherent i);\n          apply g_props_growth;\n          constructor; intro b;\n          cases Fin.decEq a b with\n          | isFalse _ => simp; apply PropsTriple.le_refl\n          | isTrue g => cases g; simp; apply P.coherent\n        | isTrue h =>\n          cases h; simp; apply g_props_growth;\n          constructor; intro b;\n          cases Fin.decEq a b with\n          | isFalse _ => simp; apply PropsTriple.le_refl\n          | isTrue g => cases g; simp; apply P.coherent\n    }\n  \n  theorem g_extend_growth1 : ∀ {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), P ≤ g_extend a P := by\n    intro Pexp a P\n    simp [g_extend]; constructor; simp;\n    intro b; \n    cases Fin.decEq a b with\n    | isFalse _ => simp; apply PropsTriple.le_refl\n    | isTrue h => cases h; simp; apply P.coherent\n  \n  theorem g_extend_growth2 : ∀ {Pexp : GProd n} (a : Fin n) (P Q : CoherentPred Pexp), P ≤ Q → g_extend a P ≤ g_extend a Q := by\n    intro Pexp a P Q\n    intro hpq; constructor; simp [g_extend, *]\n    intro b;\n    cases Fin.decEq a b with\n    | isFalse _ => simp; cases hpq with\n      | mk fpq => exact fpq b\n    | isTrue h => cases h; simp; apply g_props_growth hpq\n\n  def recompute_props {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp) : CoherentPred Pexp :=\n    match Nat.decEq a.val.succ n with\n    | isTrue _ => g_extend a P\n    | isFalse hne =>\n      have _ : n - a.val.succ < n - a.val := Nat.sub_succ_lt_self n a.val a.isLt; -- prove termination\n      recompute_props (Fin.inbound_succ a hne) (g_extend a P)\n  termination_by recompute_props a P => n - a.val\n\n  theorem recompute_lemma1 : ∀ {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), P ≤ recompute_props a P := by\n    intro Pexp a P\n    rw [recompute_props]\n    cases Nat.decEq a.val.succ n\n    {\n      simp; \n      have _ : n - a.val.succ < n - a.val := Nat.sub_succ_lt_self n a.val a.isLt;\n      apply PropsTriplePred.le_trans (g_extend_growth1 a P);\n      apply recompute_lemma1\n    }\n    {\n      simp; apply g_extend_growth1\n    }\n  termination_by recompute_lemma1 a P => n - a.val\n\n  theorem recompute_lemma2 : ∀ {Pexp : GProd n} (a : Fin n) (P Q : CoherentPred Pexp), P ≤ Q → recompute_props a P ≤ recompute_props a Q := by\n    intro Pexp a P Q hpq\n    rw [recompute_props, recompute_props]\n    cases Nat.decEq a.val.succ n\n    {\n      simp;\n      have _ : n - a.val.succ < n - a.val := Nat.sub_succ_lt_self n a.val a.isLt;\n      apply recompute_lemma2;\n      apply g_extend_growth2 a P Q hpq;\n    }\n    {\n      simp; apply g_extend_growth2 a P Q hpq\n    }\n  termination_by recompute_lemma2 a P Q hpq => n - a.val\n\n  theorem recompute_lemma3 : ∀ {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), (hne : ¬(a.val.succ = n)) → recompute_props (Fin.inbound_succ a hne) P ≤ recompute_props a P := by\n    intro Pexp a P hne\n    have h : recompute_props a P = recompute_props (Fin.inbound_succ a hne) (g_extend a P) := by\n      rw [recompute_props]\n      cases Nat.decEq a.val.succ n\n      simp\n      contradiction\n    rw [h]\n    apply recompute_lemma2\n    apply g_extend_growth1\n  \n  theorem recompute_le_recompute_zero : ∀ {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), recompute_props a P ≤ recompute_props (Fin.mk 0 Pexp.pos_n) P := by\n    intro Pexp a P;\n    match Nat.decEq a.val 0 with\n    | isTrue h =>\n      have g : a = (Fin.mk 0 Pexp.pos_n) := Fin.eq_of_val_eq h;\n      rw [g];\n      apply PropsTriplePred.le_refl;\n    | isFalse h =>\n        have g : a = Fin.inbound_succ_pred a h := by apply Fin.inbound_succ_pred_eq;\n        rw [g, Fin.inbound_succ_pred]; simp;\n        apply PropsTriplePred.le_trans (recompute_lemma3 _ P _);\n        apply recompute_le_recompute_zero;\n  termination_by recompute_le_recompute_zero a P => a.val\n  \n  structure Fixpoint (Pexp : GProd n) where\n    coherent_pred : CoherentPred Pexp\n    isFixed : recompute_props (Fin.mk 0 Pexp.pos_n) coherent_pred = coherent_pred\n  \n  instance : LE (Fixpoint Pexp) where\n    le := fun P Q => P.coherent_pred ≤ Q.coherent_pred\n  \n  def Fixpoint.pred (P : Fixpoint Pexp) : PropsTriplePred Pexp := P.coherent_pred.pred\n  \n  theorem Fixpoint.eq_of_eq_coherent_pred : ∀ {x y : Fixpoint Pexp}, x.coherent_pred = y.coherent_pred → x = y := by\n    intro x y h;\n    cases x; cases y; simp_all;\n  \n  theorem Fixpoint.recompute_le_self : ∀ {Pexp : GProd n} (a : Fin n) (P : Fixpoint Pexp), recompute_props a P.coherent_pred ≤ P.coherent_pred := by\n    intro Pexp a P;\n    have helper : (recompute_props a P.coherent_pred ≤ P.coherent_pred) = (recompute_props a P.coherent_pred ≤ recompute_props (Fin.mk 0 Pexp.pos_n) P.coherent_pred) := by\n      rw [P.isFixed]\n    rw [helper];\n    apply recompute_le_recompute_zero;\n\n  theorem Fixpoint.no_growth : ∀ {Pexp : GProd n} (a : Fin n) (P : Fixpoint Pexp), P.coherent_pred = g_extend a P.coherent_pred := by\n    intro Pexp a P;\n    simp;\n    apply CoherentPred.eq_of_le_le;\n    {\n      apply g_extend_growth1;\n    }\n    {\n      have g_extend_le_recompute : g_extend a P.coherent_pred ≤ recompute_props a P.coherent_pred := by \n        rw [recompute_props];\n        cases Nat.decEq a.val.succ n with\n        | isTrue h => simp [h]; apply PropsTriplePred.le_refl\n        | isFalse h => \n          simp; apply recompute_lemma1;\n      apply PropsTriplePred.le_trans g_extend_le_recompute;\n      apply PropsTriplePred.le_trans;\n      apply recompute_le_recompute_zero a;\n      rw [P.isFixed];\n      apply PropsTriplePred.le_refl;\n    }\n\n  def Maybe.count_found : Maybe p a → Fin 2\n    | found _ => Fin.mk 1 (by trivial)\n    | unknown => Fin.mk 0 (by trivial)\n\n  theorem Maybe.count_growth : ∀ (P Q : Maybe p a), P ≤ Q → P.count_found ≤ Q.count_found := by\n    intro P Q h\n    simp [count_found];\n    cases h <;> simp;\n    apply Nat.zero_le; \n  \n  theorem Maybe.eq_of_same_count : ∀ (P Q : Maybe p a), P.count_found = Q.count_found → P = Q := by\n    intro P Q;\n    rw [count_found, count_found];\n    cases P <;> cases Q <;> simp;\n  \n  def PropsTriple.count_found (P : PropsTriple Pexp G) : Fin 4 :=\n    Fin.extended_add P.fst.count_found (Fin.extended_add P.snd.fst.count_found P.snd.snd.count_found)\n  \n  theorem PropsTriple.count_growth : ∀ (P Q : PropsTriple Pexp G), P ≤ Q → P.count_found ≤ Q.count_found := by\n    intro P Q h\n    rw [count_found, count_found];\n    cases h;\n    apply Fin.extended_add_le_add;\n    apply Maybe.count_growth; assumption;\n    apply Fin.extended_add_le_add <;> apply Maybe.count_growth <;> assumption;\n\n  theorem Nat.eq_eq_of_le_le_eq : ∀ {a b c d : Nat}, a ≤ c → b ≤ d → a + b = c + d → (a = c ∧ b = d) := by\n    intro a b c d le_ac le_bd h;\n    cases Nat.eq_or_lt_of_le le_ac;\n    {\n      simp_all; exact Nat.add_left_cancel h;\n    }\n    {\n      cases Nat.eq_or_lt_of_le le_bd;\n      {\n        simp_all;\n        exact Nat.add_right_cancel h;\n      }\n      {\n        have g : a + b ≠ c + d := by apply Nat.ne_of_lt; apply Nat.add_lt_add; assumption; assumption;\n        contradiction;\n      }\n    }\n\n  theorem PropsTriple.eq_of_le_with_same_count : ∀ (P Q : PropsTriple Pexp G), P ≤ Q → P.count_found = Q.count_found → P = Q := by\n    intro P Q hle hcount;\n    simp [count_found, Fin.extended_add] at hcount;\n    match hle with\n    | ⟨hf,h0,hs⟩ => \n      match P with\n      | ⟨pf,p0,ps⟩ => match Q with\n        | ⟨qf,q0,qs⟩ => \n          simp at *;\n          have g1 : (Maybe.count_found pf).val = (Maybe.count_found qf).val ∧ ((Maybe.count_found p0).val + (Maybe.count_found ps).val) = ((Maybe.count_found q0).val + (Maybe.count_found qs).val) := by\n          {\n            apply Nat.eq_eq_of_le_le_eq;\n            apply Maybe.count_growth _ _ hf;\n            apply Nat.add_le_add;\n            apply Maybe.count_growth _ _ h0;\n            apply Maybe.count_growth _ _ hs;\n            exact hcount;\n          }\n          have g2 : (Maybe.count_found p0).val = (Maybe.count_found q0).val ∧ (Maybe.count_found ps).val = (Maybe.count_found qs).val := by\n          {\n            apply Nat.eq_eq_of_le_le_eq;\n            apply Maybe.count_growth _ _ h0;\n            apply Maybe.count_growth _ _ hs;\n            exact g1.right;\n          }\n          apply And.intro\n          apply Maybe.eq_of_same_count;\n          exact Fin.eq_of_val_eq g1.left;\n          apply And.intro\n          apply Maybe.eq_of_same_count;\n          exact Fin.eq_of_val_eq g2.left;\n          apply Maybe.eq_of_same_count;\n          exact Fin.eq_of_val_eq g2.right;\n\n  def PropsTriplePred.count_found_helper {Pexp : GProd n} (P : PropsTriplePred Pexp) (i : Fin n) (res : Fin (3*(n-i.val)-2)) : Fin (3*n+1) :=\n    have new_res := (Fin.extended_add (P i).count_found res);\n    match Nat.decEq i.val 0 with\n    | isTrue h =>\n      have c : 4 + (3 * (n - i.val) - 2) - 1 = 3 * n + 1 := by\n      {\n        simp_all;\n        apply Nat.sub_eq_of_eq_add;\n        rw [←Nat.add_sub_assoc (by rw[←Nat.mul_one 2]; apply Nat.mul_le_mul; trivial; exact Pexp.pos_n) 4, Nat.add_comm, Nat.add_sub_assoc];\n        trivial;\n      }\n      Fin.cast c new_res\n    | isFalse h =>\n      have c : 4 + (3 * (n - i.val) - 2) - 1 = 3 * (n - (Fin.inbound_pred i h).val) - 2 := by\n      {\n        rw [Fin.inbound_pred]; simp;\n        calc\n          4 + (3 * (n - i.val) - 2) - 1 = 4 + (3 * (n - Nat.succ (Nat.pred i.val)) - 2) - 1 := by rw [Nat.succ_pred h]\n          _ = 4 + (3 * (n - Nat.pred i.val - 1) - 2) - 1 := by rw [←Nat.add_one, ←Nat.sub_sub];\n          _ = 4 + (3 * (n - Nat.pred i.val) - 3 - 2) - 1 := by rw [Nat.mul_sub_left_distrib];\n          _ = 3 * (n - Nat.pred i.val) - (2 + 3) + 3 := by rw [Nat.add_comm, Nat.add_sub_assoc (by trivial), Nat.sub_sub];\n          _ = 3 * (n - Nat.pred i.val) - 2 - 3 + 3 := by rw [←Nat.sub_sub]\n        apply Nat.sub_add_cancel;\n        apply Nat.le_sub_of_add_le;\n        rw [Nat.add_comm 3 2]\n        rw [←Nat.succ_sub_succ, Nat.succ_pred h, Nat.mul_sub_left_distrib, Nat.mul_succ];\n        apply Nat.le_sub_of_add_le;\n        rw [Nat.add_assoc, Nat.add_comm 3 (3 * i.val), ←Nat.add_assoc];\n        apply Nat.add_le_add_right;\n        have g : 2 + 3 * i.val ≤ 3 + 3 * i.val := by apply Nat.add_le_add_right; trivial;\n        apply Nat.le_trans g;\n        rw [Nat.add_comm, ←Nat.mul_succ];\n        apply Nat.mul_le_mul_left;\n        apply Nat.succ_le_of_lt;\n        exact i.isLt;\n      }\n      have _ : (Fin.inbound_pred i h).val + 1 < i.val + 1 := by apply Nat.succ_lt_succ; rw [Fin.inbound_pred]; simp; apply Nat.pred_lt h;\n      count_found_helper P (Fin.inbound_pred i h) (Fin.cast c new_res)\n  termination_by count_found_helper P i res => i\n\n  def PropsTriplePred.count_found {Pexp : GProd n} (P : PropsTriplePred Pexp) : Fin (3*n+1) :=\n    have max_i : Fin n := Fin.mk (n-1) (by apply Nat.sub_lt Pexp.pos_n; trivial);\n    have isLt : 0 < 3 * (n - max_i.val) - 2 := by\n    {\n      apply Nat.lt_sub_of_add_lt;\n      simp;\n      apply Nat.lt_of_succ_le;\n      rw [←Nat.mul_one (Nat.succ 2)];\n      apply Nat.mul_le_mul_left;\n      apply Nat.succ_le_of_lt;\n      apply Nat.lt_sub_of_add_lt;\n      simp;\n      exact max_i.isLt;\n    }\n    have fin_zero : Fin (3 * (n - max_i.val) - 2) := Fin.mk 0 isLt;\n    P.count_found_helper max_i fin_zero\n  \n  theorem count_growth_helper_res {Pexp : GProd n} (P : PropsTriplePred Pexp) (i : Fin n) (res1 res2 : Fin (3*(n-i.val)-2)) \n                            : res1 ≤ res2 → P.count_found_helper i res1 ≤ P.count_found_helper i res2 := by\n    intro h;\n    rw [PropsTriplePred.count_found_helper, PropsTriplePred.count_found_helper];\n    simp;\n    match Nat.decEq i.val 0 with\n    | isTrue g =>\n      {\n        simp [g, Fin.cast];\n        apply Fin.extended_add_le_add_left;\n        exact h;\n      }\n    | isFalse g =>\n      {\n        have _ : (Fin.inbound_pred i g).val + 1 < i.val + 1 := by\n        {\n          apply Nat.add_lt_add_right;\n          rw [Fin.inbound_pred];\n          apply Nat.pred_lt g;\n        }\n        simp [g, Fin.cast];\n        apply count_growth_helper_res;\n        apply Fin.extended_add_le_add_left;\n        exact h;\n      }\n  termination_by count_growth_helper_res P i res1 res2 h => i\n\n  theorem count_growth_helper_pred {Pexp : GProd n} (P Q : PropsTriplePred Pexp) (i : Fin n) (res : Fin (3*(n-i.val)-2)) \n                            : P ≤ Q → P.count_found_helper i res ≤ Q.count_found_helper i res := by\n    intro hpq;\n    match hpq with\n    | PropsTriplePred.le.mk h =>\n      {\n        rw [PropsTriplePred.count_found_helper, PropsTriplePred.count_found_helper];\n        simp;\n        match Nat.decEq i.val 0 with\n        | isTrue g =>\n          {\n            simp [g, Fin.cast];\n            apply Fin.extended_add_le_add_right;\n            rw [PropsTriple.count_found, PropsTriple.count_found];\n            apply Fin.extended_add_le_add;\n            {\n              rw [count_found, count_found];\n              simp;\n              match (h i) with\n              | ⟨h, _, _⟩ => match Maybe.le.equiv_to_imply.mp h with\n                | Or.inl h => simp [h]; cases (Q i).fst <;> simp;\n                | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy'];\n            }\n            {\n              apply Fin.extended_add_le_add;\n              {\n                rw [count_found, count_found];\n                simp;\n                match (h i) with\n                | ⟨_, h, _⟩ => match Maybe.le.equiv_to_imply.mp h with\n                  | Or.inl h => simp [h]; cases (Q i).snd.fst <;> simp;\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy'];\n              }\n              {\n                rw [count_found, count_found];\n                simp;\n                match (h i) with\n                | ⟨_, _, h⟩ => match Maybe.le.equiv_to_imply.mp h with\n                  | Or.inl h => simp [h]; cases (Q i).snd.snd <;> simp;\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy'];\n              }\n            }\n          }\n        | isFalse g =>\n          {\n            simp [g];\n            have _ : (Fin.inbound_pred i g).val + 1 < i.val + 1 := by\n            {\n              apply Nat.add_lt_add_right;\n              rw [Fin.inbound_pred];\n              apply Nat.pred_lt g;\n            }\n            have cpq : Fin.extended_add (PropsTriple.count_found (P i)) res ≤ Fin.extended_add (PropsTriple.count_found (Q i)) res := by\n            {\n              apply Fin.extended_add_le_add_right;\n              rw [PropsTriple.count_found, PropsTriple.count_found];\n              apply Fin.extended_add_le_add;\n              {\n                rw [count_found, count_found];\n                simp;\n                match (h i) with\n                | ⟨h, _, _⟩ => match Maybe.le.equiv_to_imply.mp h with\n                  | Or.inl h => simp [h]; cases (Q i).fst <;> simp;\n                  | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy'];\n              }\n              {\n                apply Fin.extended_add_le_add;\n                {\n                  rw [count_found, count_found];\n                  simp;\n                  match (h i) with\n                  | ⟨_, h, _⟩ => match Maybe.le.equiv_to_imply.mp h with\n                    | Or.inl h => simp [h]; cases (Q i).snd.fst <;> simp;\n                    | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy'];\n                }\n                {\n                  rw [count_found, count_found];\n                  simp;\n                  match (h i) with\n                  | ⟨_, _, h⟩ => match Maybe.le.equiv_to_imply.mp h with\n                    | Or.inl h => simp [h]; cases (Q i).snd.snd <;> simp;\n                    | Or.inr ⟨x',⟨y',⟨hx', hy'⟩⟩⟩ => simp [hx', hy'];\n                }\n              }\n            }\n            apply Fin.le_trans;\n            {\n              apply count_growth_helper_res;\n              apply Fin.le_cast cpq;\n            }\n            {\n              apply count_growth_helper_pred;\n              exact hpq;\n            }\n          }\n      }\n  termination_by count_growth_helper_pred P Q i res h => i\n\n  theorem PropsTriplePred.count_found_helper_eq_pred_res {Pexp : GProd n} (P Q : PropsTriplePred Pexp) (i : Fin n) (res1 res2 : Fin (3*(n-i.val)-2))\n                                                    : P ≤ Q → res1 ≤ res2 → P.count_found_helper i res1 = Q.count_found_helper i res2 → P i = Q i ∧ res1 = res2 := by\n    intro le_pred le_res;\n    rw [count_found_helper, count_found_helper];\n    match Nat.decEq i.val 0 with\n    | isTrue h =>\n      {\n        cases le_pred with\n        | mk f =>\n          {\n            simp [h, Fin.cast] at *;\n            intro hcount;\n            have g := Fin.extended_eq_eq_of_le_le_eq (PropsTriple.count_growth _ _ (f i)) le_res (Fin.eq_of_val_eq hcount);\n            exact ⟨PropsTriple.eq_of_le_with_same_count _ _ (f i) g.left,g.right⟩;\n          }\n      }\n    | isFalse h =>\n      {\n        match le_pred with\n        | PropsTriplePred.le.mk f =>\n          {\n            simp [h, Fin.cast] at *;\n            have _ : (Fin.inbound_pred i h).val + 1 < i.val + 1 := by\n            {\n              apply Nat.add_lt_add_right;\n              simp [Fin.inbound_pred];\n              apply Nat.pred_lt h;\n            }\n            intro hcount;\n            have g1 : Fin.extended_add (PropsTriple.count_found (P i)) res1 ≤ Fin.extended_add (PropsTriple.count_found (Q i)) res2 := by\n            {\n              apply Fin.extended_add_le_add;\n              {\n                apply PropsTriple.count_growth;\n                exact f i;\n              }\n              exact le_res;\n            }\n            have g2 := count_found_helper_eq_pred_res P Q (Fin.inbound_pred i h) _ _ le_pred g1 hcount;\n            have g3 : (Fin.extended_add (PropsTriple.count_found (P i)) res1).val = (Fin.extended_add (PropsTriple.count_found (Q i)) res2).val := by\n            {\n              have g := Fin.val_eq_of_eq g2.right;\n              simp at g;\n              exact g;\n            }\n            have g := Fin.extended_eq_eq_of_le_le_eq (PropsTriple.count_growth _ _ (f i)) le_res (Fin.eq_of_val_eq g3);\n            exact ⟨PropsTriple.eq_of_le_with_same_count _ _ (f i) g.left,g.right⟩;\n          }\n      }\n  termination_by PropsTriplePred.count_found_helper_eq_pred_res _ _ i _ _ _ _ _ => i\n\n  theorem PropsTriplePred.count_found_helper_eq_pred_below {Pexp : GProd n} (P Q : PropsTriplePred Pexp) (i : Fin n) (res1 res2 : Fin (3*(n-i.val)-2))\n                                                    : P ≤ Q → res1 ≤ res2 → P.count_found_helper i res1 = Q.count_found_helper i res2 → (∀ j, j ≤ i → P j = Q j) := by\n    intro le_pred le_res hcount;\n    have g1 := count_found_helper_eq_pred_res _ _ _ _ _ le_pred le_res hcount;\n    rw [count_found_helper, count_found_helper] at hcount;\n    match Nat.decEq i.val 0 with\n    | isTrue h =>\n      {\n        cases i; cases h;\n        intro j le_ji;\n        cases g1;\n        cases j; cases le_ji;\n        assumption;\n      }\n    | isFalse h =>\n      {\n        have simp_hcount : Nat.decEq i.val 0 = isFalse h := by\n        {\n          match Nat.decEq i.val 0 with\n          | isTrue _ => contradiction\n          | isFalse h => rfl\n        }\n        have _ : (Fin.inbound_pred i h).val + 1 < i.val + 1 := by\n        {\n          apply Nat.add_lt_add_right;\n          simp [Fin.inbound_pred];\n          apply Nat.pred_lt h;\n        }\n        simp [simp_hcount] at hcount;\n        match le_pred with\n        | PropsTriplePred.le.mk f =>\n          {\n            have g2 := count_found_helper_eq_pred_res _ _ _ _ _ le_pred (by apply Fin.extended_add_le_add (PropsTriple.count_growth _ _ (f i)) le_res) hcount;\n            have g := count_found_helper_eq_pred_below _ _ _ _ _ le_pred (Nat.le_of_eq (Fin.val_eq_of_eq g2.right)) hcount;\n            intro j le_ji;\n            cases Nat.eq_or_lt_of_le le_ji;\n            {\n              have eq_ji : j = i := by apply Fin.eq_of_val_eq; assumption;\n              rw [eq_ji];\n              exact g1.left;\n            }\n            {\n              have lt_ji : j < i := by assumption;\n              apply g;\n              simp [Fin.inbound_pred];\n              apply Nat.le_of_lt_succ;\n              simp;\n              rw [Nat.succ_pred h];\n              exact lt_ji;\n            }\n          }\n      }\n  termination_by _ _ i _ _ _ _ _ => i\n\n  theorem PropsTriplePred.count_growth : ∀ {Pexp : GProd n} {P Q : PropsTriplePred Pexp}, P ≤ Q → P.count_found ≤ Q.count_found := by\n    intro Pexp P Q hpq;\n    simp [count_found, Fin.cast];\n    apply count_growth_helper_pred;\n    exact hpq;\n\n  theorem PropsTriplePred.eq_of_le_with_same_count : ∀ {Pexp : GProd n} (P Q : PropsTriplePred Pexp), P ≤ Q → P.count_found = Q.count_found → P = Q := by\n    intro Pexp P Q hle hcount;\n    rw [count_found, count_found] at hcount; simp at hcount;\n    have g := count_found_helper_eq_pred_below P Q _ _ _ hle (by apply Nat.le_refl) hcount;\n    apply funext;\n    intro i;\n    apply g i;\n    apply Nat.le_sub_of_add_le;\n    apply Nat.succ_le_of_lt;\n    exact i.isLt;\n  \n  def CoherentPred.count_found {Pexp : GProd n} (P : CoherentPred Pexp) : Fin (3*n+1) := P.pred.count_found\n\n  theorem CoherentPred.count_growth : ∀ {Pexp : GProd n} {P Q : CoherentPred Pexp}, P ≤ Q → P.count_found ≤ Q.count_found := by\n    intros;\n    apply PropsTriplePred.count_growth;\n    assumption;\n\n  theorem CoherentPred.eq_of_le_with_same_count : ∀ {Pexp : GProd n} (P Q : CoherentPred Pexp), P ≤ Q → P.count_found = Q.count_found → P = Q := by\n    intro Pexp P Q hpq hcount;\n    apply CoherentPred.eq_of_eq_pred;\n    apply PropsTriplePred.eq_of_le_with_same_count;\n    exact hpq;\n    exact hcount;\n\n  def compute_props {n : Nat} {Pexp : GProd n} (P : CoherentPred Pexp) : Fixpoint Pexp :=\n    let fin_zero : Fin n := Fin.mk 0 Pexp.pos_n;\n    let new_P : CoherentPred Pexp := recompute_props fin_zero P;\n    have le_pred : P ≤ new_P := recompute_lemma1 fin_zero P;\n    match Fin.decEq P.count_found new_P.count_found with\n    | isTrue h => {coherent_pred := P, isFixed := by {\n        apply Eq.symm;\n        \n        apply CoherentPred.eq_of_le_with_same_count P new_P le_pred h;\n      }}\n    | isFalse h => \n      have _ : 3 * n + 1 - (new_P.count_found).val < 3 * n + 1 - (P.count_found).val := by\n      {\n        have g : P.count_found < new_P.count_found := by\n        {\n          match Nat.eq_or_lt_of_le (CoherentPred.count_growth le_pred) with\n          | Or.inl g => exact absurd (Fin.eq_of_val_eq g) h;\n          | Or.inr g => exact g\n        }\n        have lem : ∀ {a b c : Nat}, b < a → c < a → b < c → a - c < a - b := by\n        {\n          intro a b c hba hca hbc;\n          induction hbc with\n          | refl => rw [Nat.sub_succ]; apply Nat.pred_lt; apply Nat.sub_ne_zero_of_lt hba;\n          | step _ ih => \n            rw [Nat.sub_succ]; apply Nat.lt_trans; apply Nat.pred_lt; apply Nat.sub_ne_zero_of_lt;\n            apply Nat.lt_of_succ_lt hca; apply ih; exact Nat.lt_of_succ_lt hca;\n        }\n        apply lem;\n        exact P.count_found.isLt;\n        exact new_P.count_found.isLt;\n        exact g;\n      }\n      compute_props new_P\n  termination_by compute_props n Pexp P => 3 * n + 1 - P.count_found\n\n  def GProd.get_props (Pexp : GProd n) : Fixpoint Pexp :=\n    let unknownPred : CoherentPred Pexp := CoherentPred.mk (fun _ => (unknown, unknown, unknown)) (by intro i; constructor <;> simp <;> exact Maybe.le.lhs_unknown);\n    compute_props unknownPred\n  \n  def getPropF (Pexp : GProd n) (G : PEG n) : Maybe (PropF Pexp) G :=\n    let P := Pexp.get_props.pred;\n    (g_props G P).fst\n  \n  def getProp0 (Pexp : GProd n) (G : PEG n) : Maybe (Prop0 Pexp) G :=\n    let P := Pexp.get_props.pred;\n    (g_props G P).snd.fst\n  \n  def getPropS (Pexp : GProd n) (G : PEG n) : Maybe (PropS Pexp) G :=\n    let P := Pexp.get_props.pred;\n    (g_props G P).snd.snd\n  \n  inductive IsKnown (m : Maybe p a) : Prop where\n  | mk : ∀ (h : p a), m = found h → IsKnown m\n\n  theorem IsKnown.ne_of_unknown : ∀ m : Maybe p a, m = unknown → ¬IsKnown m := by\n    intro m h_unknown h\n    cases h;\n    cases h_unknown;\n    contradiction;\n  \n  theorem IsKnown.unknown_of_ne : ∀ m : Maybe p a, ¬IsKnown m → m = unknown := by\n    intro m hne;\n    match m with\n    | found h => apply absurd _ hne; apply IsKnown.mk h rfl;\n    | unknown => rfl\n\n  def IsKnown.from_maybe (m : Maybe p a) : Decidable (IsKnown m) :=\n    match m with\n    | found h => isTrue (IsKnown.mk h rfl)\n    | unknown => isFalse (by apply IsKnown.ne_of_unknown; rfl)\n  \n  def IsKnown.get_result {m : Maybe p a} (k : IsKnown m) : p a :=\n    match k with\n    | mk h _ => h\n\n  inductive StructuralWF (Pexp : GProd n) : PEG n → Prop where\n    | ε : StructuralWF Pexp ε\n    | any : StructuralWF Pexp any\n    | terminal : ∀ (c : Char), StructuralWF Pexp (terminal c)\n    | nonTerminal : ∀ (vn : Fin n), StructuralWF Pexp (nonTerminal vn)\n    | seq : ∀ (e1 e2 : PEG n), StructuralWF Pexp e1 → StructuralWF Pexp e2 → StructuralWF Pexp (seq e1 e2)\n    | prior : ∀ (e1 e2 : PEG n), StructuralWF Pexp e1 → StructuralWF Pexp e2 → StructuralWF Pexp (prior e1 e2)\n    | star : ∀ (e : PEG n), StructuralWF Pexp e → ¬IsKnown (getProp0 Pexp e) → StructuralWF Pexp (star e)\n    | notP : ∀ (e : PEG n), StructuralWF Pexp e → StructuralWF Pexp (notP e)\n\n  def check_StructuralWF (Pexp : GProd n) (G : PEG n) : Maybe (StructuralWF Pexp) G :=\n    match G with\n    | ε => found .ε\n    | any => found .any\n    | terminal c => found (.terminal c)\n    | nonTerminal vn => found (.nonTerminal vn)\n    | seq e1 e2 => match check_StructuralWF Pexp e1, check_StructuralWF Pexp e2 with\n      | found h1, found h2 => found (.seq e1 e2 h1 h2)\n      | _, _ => unknown\n    | prior e1 e2 => match check_StructuralWF Pexp e1, check_StructuralWF Pexp e2 with\n      | found h1, found h2 => found (.prior e1 e2 h1 h2)\n      | _, _ => unknown\n    | star e => match check_StructuralWF Pexp e, IsKnown.from_maybe (getProp0 Pexp e) with\n      | found h1, isFalse h2 => found (.star e h1 h2)\n      | _, _ => unknown\n    | notP e => match check_StructuralWF Pexp e with\n      | found h => found (.notP e h)\n      | _ => unknown\n    \n  abbrev StructuralWF_GProd (Pexp : GProd n) := ∀ (i : Fin n), StructuralWF Pexp (Pexp.f i)\n  abbrev StructuralWF_GProd_partial (u : Fin n) (Pexp : GProd n) := ∀ (i : Fin n), i ≤ u → StructuralWF Pexp (Pexp.f i)\n\n  theorem StructuralWF_GProd.from_partial {Pexp : GProd n} {hlt : n-1 < n} : StructuralWF_GProd_partial {val := n-1, isLt := hlt} Pexp → StructuralWF_GProd Pexp := by\n  {\n    intro h i;\n    apply h;\n    apply Nat.le_sub_of_add_le;\n    apply Nat.succ_le_of_lt;\n    exact i.isLt;\n  }\n  \n  def check_StructuralWF_GProd_partial (u : Fin n) (Pexp : GProd n) : Maybe (StructuralWF_GProd_partial u) Pexp :=\n    let curr_check := check_StructuralWF Pexp (Pexp.f u);\n    match curr_check, Nat.decEq u.val 0 with\n    | found h, isTrue g => found (by {\n      intro i hle;\n      have heq : i = u := by apply Fin.eq_of_val_eq; cases u; cases i; simp_all; apply Nat.eq_zero_of_le_zero; exact hle;\n      rw [heq];\n      exact h;\n    })\n    | found h, isFalse g => match check_StructuralWF_GProd_partial (Fin.inbound_pred u g) Pexp with\n      | found hpred => found (by {\n        intro i hle;\n        cases Nat.eq_or_lt_of_le hle with\n        | inl heq => rw [Fin.eq_of_val_eq heq]; exact h;\n        | inr hlt => apply hpred; rw [Fin.inbound_pred]; rw [←Nat.succ_pred g] at hlt; apply Nat.le_of_lt_succ; exact hlt;\n      })\n      | unknown => unknown\n    | unknown, _ => unknown\n  termination_by check_StructuralWF_GProd_partial u Pexp => u.val\n\n  def check_StructuralWF_GProd (Pexp : GProd n) : Maybe StructuralWF_GProd Pexp :=\n    let max_i : Fin n := Fin.mk (n-1) (by apply Nat.sub_lt Pexp.pos_n; trivial);\n    match check_StructuralWF_GProd_partial max_i Pexp with\n    | found h => found (StructuralWF_GProd.from_partial h)\n    | unknown => unknown\n\n  open Function\n\n  inductive PatternWF {p : Fin n → Fin n} (Pexp : GProd n) (σ : Bijective p) (A : Fin n) : PEG n → Prop where\n    | ε : PatternWF Pexp σ A ε\n    | any : PatternWF Pexp σ A any\n    | terminal : ∀ (c : Char), PatternWF Pexp σ A (terminal c)\n    | nonTerminal : ∀ (B : Fin n), p B < p A → PatternWF Pexp σ A (nonTerminal B)\n    | seq : ∀ (e1 e2 : PEG n), PatternWF Pexp σ A e1 → (IsKnown (getProp0 Pexp e1) → PatternWF Pexp σ A e2) → PatternWF Pexp σ A (seq e1 e2)  \n    | prior : ∀ (e1 e2 : PEG n), PatternWF Pexp σ A e1 → PatternWF Pexp σ A e2 → PatternWF Pexp σ A (prior e1 e2)\n    | star : ∀ (e : PEG n), PatternWF Pexp σ A e → PatternWF Pexp σ A (star e)\n    | notP : ∀ (e : PEG n), PatternWF Pexp σ A e → PatternWF Pexp σ A (notP e)\n  \n  def check_PatternWF {p : Fin n → Fin n} (Pexp : GProd n) (σ : Bijective p) (A : Fin n) (G : PEG n) : Maybe (PatternWF Pexp σ A) G :=\n    match G with\n    | ε => found .ε\n    | any => found .any\n    | terminal c => found (.terminal c)\n    | nonTerminal B => match Fin.decLt (p B) (p A) with\n      | isTrue h => found (.nonTerminal B h)\n      | isFalse _ => unknown\n    | seq e1 e2 => match check_PatternWF Pexp σ A e1, check_PatternWF Pexp σ A e2 with\n      | found h1, found h2 => found (.seq e1 e2 h1 (fun _ => h2))\n      | found h1, unknown => match IsKnown.from_maybe (getProp0 Pexp e1) with\n        | isTrue _ => unknown\n        | isFalse hne => found (.seq e1 e2 h1 (fun h => absurd h hne))\n      | unknown, _ => unknown\n    | prior e1 e2 => match check_PatternWF Pexp σ A e1, check_PatternWF Pexp σ A e2 with\n      | found h1, found h2 => found (.prior e1 e2 h1 h2)\n      | found _, unknown | unknown, found _ | unknown, unknown => unknown\n    | star e => match check_PatternWF Pexp σ A e with\n      | found h => found (.star e h)\n      | unknown => unknown\n    | notP e => match check_PatternWF Pexp σ A e with\n      | found h => found (.notP e h)\n      | unknown => unknown\n\n  abbrev PatternWF_GProd {p : Fin n → Fin n} (Pexp : GProd n) (σ : Bijective p) := ∀ (i : Fin n), PatternWF Pexp σ i (Pexp.f i)\n  abbrev PatternWF_GProd_partial (u : Fin n) {p : Fin n → Fin n} (Pexp : GProd n) (σ : Bijective p) := ∀ (i : Fin n), i ≤ u → PatternWF Pexp σ i (Pexp.f i)\n\n  theorem PatternWF_GProd.from_partial {p : Fin n → Fin n} {Pexp : GProd n} {σ : Bijective p} {hlt : n-1 < n} : PatternWF_GProd_partial {val := n-1, isLt := hlt} Pexp σ → PatternWF_GProd Pexp σ := by\n  {\n    intro h i;\n    apply h;\n    apply Nat.le_sub_of_add_le;\n    apply Nat.succ_le_of_lt;\n    exact i.isLt;\n  }\n\n  def check_PatternWF_GProd_partial (u : Fin n) {p : Fin n → Fin n} (Pexp : GProd n) (σ : Bijective p) : Maybe (PatternWF_GProd_partial u Pexp) σ :=\n    let curr_check := check_PatternWF Pexp σ u (Pexp.f u);\n    match curr_check, Nat.decEq u.val 0 with\n    | found h, isTrue g => found (by {\n      intro i hle;\n      have heq : i = u := by apply Fin.eq_of_val_eq; cases u; cases i; simp_all; apply Nat.eq_zero_of_le_zero; exact hle;\n      rw [heq];\n      exact h;\n    })\n    | found h, isFalse g => match check_PatternWF_GProd_partial (Fin.inbound_pred u g) Pexp σ with\n      | found hpred => found (by {\n        intro i hle;\n        cases Nat.eq_or_lt_of_le hle with\n        | inl heq => rw [Fin.eq_of_val_eq heq]; exact h;\n        | inr hlt => apply hpred; rw [Fin.inbound_pred]; rw [←Nat.succ_pred g] at hlt; apply Nat.le_of_lt_succ; exact hlt;\n      })\n      | unknown => unknown \n    | unknown, _ => unknown\n  termination_by check_PatternWF_GProd_partial u p Pexp σ => u.val\n\n  def check_PatternWF_GProd {p : Fin n → Fin n} (Pexp : GProd n) (σ : Bijective p) : Maybe (PatternWF_GProd Pexp) σ :=\n    let max_i : Fin n := Fin.mk (n-1) (by apply Nat.sub_lt Pexp.pos_n; trivial);\n    match check_PatternWF_GProd_partial max_i Pexp σ with\n    | found h => found (PatternWF_GProd.from_partial h)\n    | unknown => unknown \n\n  structure WellformedGrammar (Pexp : GProd n) where\n    structural : StructuralWF_GProd Pexp\n    pattern : ∃ σ : Bijective p, PatternWF_GProd Pexp σ\n\n  def mapping_from_list (l : List (Fin n)) (length_eq : l.length = n) : Fin n → Fin n :=\n    fun i => l.get (Fin.cast (Eq.symm length_eq) i)\n  \n  theorem bijective_from_list (l : List (Fin n)) (length_eq : l.length = n) (distinct : ∀ {i j}, l.get i = l.get j → i = j) : Bijective (mapping_from_list l length_eq) := by\n    constructor;\n    {\n      rw [Injective];\n      intro i j h;\n      rw [mapping_from_list, mapping_from_list] at h;\n      have g := Fin.val_eq_of_eq (distinct h);\n      simp [Fin.cast] at g;\n      apply Fin.eq_of_val_eq g;\n    }\n    {\n      sorry\n    }\n  \nend Grammar", "meta": {"author": "lituzou", "repo": "ExtParser", "sha": "7ddd0f3c16dd2bbf6ada6aa9fd84f618733cf4b5", "save_path": "github-repos/lean/lituzou-ExtParser", "path": "github-repos/lean/lituzou-ExtParser/ExtParser-7ddd0f3c16dd2bbf6ada6aa9fd84f618733cf4b5/ExtParser/Grammar.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.5851011542032313, "lm_q1q2_score": 0.4670200049252104}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.topological_fiber_bundle\nimport Mathlib.geometry.manifold.smooth_manifold_with_corners\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 l \n\nnamespace Mathlib\n\n/-!\n# Basic smooth bundles\n\nIn general, a smooth bundle is a bundle over a smooth manifold, whose fiber is a manifold, and\nfor which the coordinate changes are smooth. In this definition, there are charts involved at\nseveral places: in the manifold structure of the base, in the manifold structure of the fibers, and\nin the local trivializations. This makes it a complicated object in general. There is however a\nspecific situation where things are much simpler: when the fiber is a vector space (no need for\ncharts for the fibers), and when the local trivializations of the bundle and the charts of the base\ncoincide. Then everything is expressed in terms of the charts of the base, making for a much\nsimpler overall structure, which is easier to manipulate formally.\n\nMost vector bundles that naturally occur in differential geometry are of this form:\nthe tangent bundle, the cotangent bundle, differential forms (used to define de Rham cohomology)\nand the bundle of Riemannian metrics. Therefore, it is worth defining a specific constructor for\nthis kind of bundle, that we call basic smooth bundles.\n\nA basic smooth bundle is thus a smooth bundle over a smooth manifold whose fiber is a vector space,\nand which is trivial in the coordinate charts of the base. (We recall that in our notion of manifold\nthere is a distinguished atlas, which does not need to be maximal: we require the triviality above\nthis specific atlas). It can be constructed from a basic smooth bundled core, defined below,\nspecifying the changes in the fiber when one goes from one coordinate chart to another one. We do\nnot require that this changes in fiber are linear, but only diffeomorphisms.\n\n## Main definitions\n\n* `basic_smooth_bundle_core I M F`: assuming that `M` is a smooth manifold over the model with\n  corners `I` on `(𝕜, E, H)`, and `F` is a normed vector space over `𝕜`, this structure registers,\n  for each pair of charts of `M`, a smooth change of coordinates on `F`. This is the core structure\n  from which one will build a smooth bundle with fiber `F` over `M`.\n\nLet `Z` be a basic smooth bundle core over `M` with fiber `F`. We define\n`Z.to_topological_fiber_bundle_core`, the (topological) fiber bundle core associated to `Z`. From it,\nwe get a space `Z.to_topological_fiber_bundle_core.total_space` (which as a Type is just\n`Σ (x : M), F`), with the fiber bundle topology. It inherits a manifold structure (where the\ncharts are in bijection with the charts of the basis). We show that this manifold is smooth.\n\nThen we use this machinery to construct the tangent bundle of a smooth manifold.\n\n* `tangent_bundle_core I M`: the basic smooth bundle core associated to a smooth manifold `M` over a\n  model with corners `I`.\n* `tangent_bundle I M`     : the total space of `tangent_bundle_core I M`. It is itself a\n  smooth manifold over the model with corners `I.tangent`, the product of `I` and the trivial model\n  with corners on `E`.\n* `tangent_space I x`      : the tangent space to `M` at `x`\n* `tangent_bundle.proj I M`: the projection from the tangent bundle to the base manifold\n\n## Implementation notes\n\nIn the definition of a basic smooth bundle core, we do not require that the coordinate changes of\nthe fibers are linear map, only that they are diffeomorphisms. Therefore, the fibers of the\nresulting fiber bundle do not inherit a vector space structure (as an algebraic object) in general.\nAs the fiber, as a type, is just `F`, one can still always register the vector space structure, but\nit does not make sense to do so (i.e., it will not lead to any useful theorem) unless this structure\nis canonical, i.e., the coordinate changes are linear maps.\n\nFor instance, we register the vector space structure on the fibers of the tangent bundle. However,\nwe do not register the normed space structure coming from that of `F` (as it is not canonical, and\nwe also want to keep the possibility to add a Riemannian structure on the manifold later on without\nhaving two competing normed space instances on the tangent spaces).\n\nWe require `F` to be a normed space, and not just a topological vector space, as we want to talk\nabout smooth functions on `F`. The notion of derivative requires a norm to be defined.\n\n## TODO\nconstruct the cotangent bundle, and the bundles of differential forms. They should follow\nfunctorially from the description of the tangent bundle as a basic smooth bundle.\n\n## Tags\nSmooth fiber bundle, vector bundle, tangent space, tangent bundle\n-/\n\n/-- Core structure used to create a smooth bundle above `M` (a manifold over the model with\ncorner `I`) with fiber the normed vector space `F` over `𝕜`, which is trivial in the chart domains\nof `M`. This structure registers the changes in the fibers when one changes coordinate charts in the\nbase. We do not require the change of coordinates of the fibers to be linear, only smooth.\nTherefore, the fibers of the resulting bundle will not inherit a canonical vector space structure\nin general. -/\nstructure basic_smooth_bundle_core {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) (M : Type u_4) [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] (F : Type u_5) [normed_group F] [normed_space 𝕜 F] \nwhere\n  coord_change : ↥(charted_space.atlas H M) → ↥(charted_space.atlas H M) → H → F → F\n  coord_change_self : ∀ (i : ↥(charted_space.atlas H M)) (x : H),\n  x ∈ local_equiv.target (local_homeomorph.to_local_equiv (subtype.val i)) → ∀ (v : F), coord_change i i x v = v\n  coord_change_comp : ∀ (i j k : ↥(charted_space.atlas H M)) (x : H),\n  x ∈\n      local_equiv.source\n        (local_homeomorph.to_local_equiv\n          (local_homeomorph.trans (local_homeomorph.trans (local_homeomorph.symm (subtype.val i)) (subtype.val j))\n            (local_homeomorph.trans (local_homeomorph.symm (subtype.val j)) (subtype.val k)))) →\n    ∀ (v : F),\n      coord_change j k (coe_fn (local_homeomorph.trans (local_homeomorph.symm (subtype.val i)) (subtype.val j)) x)\n          (coord_change i j x v) =\n        coord_change i k x v\n  coord_change_smooth : ∀ (i j : ↥(charted_space.atlas H M)),\n  times_cont_diff_on 𝕜 ⊤\n    (fun (p : E × F) => coord_change i j (coe_fn (model_with_corners.symm I) (prod.fst p)) (prod.snd p))\n    (set.prod\n      (⇑I ''\n        local_equiv.source\n          (local_homeomorph.to_local_equiv\n            (local_homeomorph.trans (local_homeomorph.symm (subtype.val i)) (subtype.val j))))\n      set.univ)\n\n/-- The trivial basic smooth bundle core, in which all the changes of coordinates are the\nidentity. -/\ndef trivial_basic_smooth_bundle_core {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) (M : Type u_4) [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] (F : Type u_5) [normed_group F] [normed_space 𝕜 F] : basic_smooth_bundle_core I M F :=\n  basic_smooth_bundle_core.mk (fun (i j : ↥(charted_space.atlas H M)) (x : H) (v : F) => v) sorry sorry sorry\n\nnamespace basic_smooth_bundle_core\n\n\nprotected instance inhabited {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {F : Type u_5} [normed_group F] [normed_space 𝕜 F] : Inhabited (basic_smooth_bundle_core I M F) :=\n  { default := trivial_basic_smooth_bundle_core I M F }\n\n/-- Fiber bundle core associated to a basic smooth bundle core -/\ndef to_topological_fiber_bundle_core {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {F : Type u_5} [normed_group F] [normed_space 𝕜 F] (Z : basic_smooth_bundle_core I M F) : topological_fiber_bundle_core (↥(charted_space.atlas H M)) M F :=\n  topological_fiber_bundle_core.mk\n    (fun (i : ↥(charted_space.atlas H M)) => local_equiv.source (local_homeomorph.to_local_equiv (subtype.val i))) sorry\n    (fun (x : M) => { val := charted_space.chart_at H x, property := charted_space.chart_mem_atlas H x }) sorry\n    (fun (i j : ↥(charted_space.atlas H M)) (x : M) (v : F) => coord_change Z i j (coe_fn (subtype.val i) x) v) sorry\n    sorry sorry\n\n@[simp] theorem base_set {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {F : Type u_5} [normed_group F] [normed_space 𝕜 F] (Z : basic_smooth_bundle_core I M F) (i : ↥(charted_space.atlas H M)) : topological_fiber_bundle_core.base_set (to_topological_fiber_bundle_core Z) i =\n  local_equiv.source (local_homeomorph.to_local_equiv (subtype.val i)) :=\n  rfl\n\n/-- Local chart for the total space of a basic smooth bundle -/\ndef chart {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {F : Type u_5} [normed_group F] [normed_space 𝕜 F] (Z : basic_smooth_bundle_core I M F) {e : local_homeomorph M H} (he : e ∈ charted_space.atlas H M) : local_homeomorph (topological_fiber_bundle_core.total_space (to_topological_fiber_bundle_core Z)) (model_prod H F) :=\n  local_homeomorph.trans\n    (topological_fiber_bundle_core.local_triv (to_topological_fiber_bundle_core Z) { val := e, property := he })\n    (local_homeomorph.prod e (local_homeomorph.refl F))\n\n@[simp] theorem chart_source {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {F : Type u_5} [normed_group F] [normed_space 𝕜 F] (Z : basic_smooth_bundle_core I M F) (e : local_homeomorph M H) (he : e ∈ charted_space.atlas H M) : local_equiv.source (local_homeomorph.to_local_equiv (chart Z he)) =\n  topological_fiber_bundle_core.proj (to_topological_fiber_bundle_core Z) ⁻¹'\n    local_equiv.source (local_homeomorph.to_local_equiv e) := sorry\n\n@[simp] theorem chart_target {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {F : Type u_5} [normed_group F] [normed_space 𝕜 F] (Z : basic_smooth_bundle_core I M F) (e : local_homeomorph M H) (he : e ∈ charted_space.atlas H M) : local_equiv.target (local_homeomorph.to_local_equiv (chart Z he)) =\n  set.prod (local_equiv.target (local_homeomorph.to_local_equiv e)) set.univ := sorry\n\n/-- The total space of a basic smooth bundle is endowed with a charted space structure, where the\ncharts are in bijection with the charts of the basis. -/\nprotected instance to_charted_space {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {F : Type u_5} [normed_group F] [normed_space 𝕜 F] (Z : basic_smooth_bundle_core I M F) : charted_space (model_prod H F) (topologi", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/geometry/manifold/basic_smooth_bundle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312056025699, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4669805086221862}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n\n! This file was ported from Lean 3 source module category_theory.isomorphism_classes\n! leanprover-community/mathlib commit 28aa996fc6fb4317f0083c4e6daf79878d81be33\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Category.Cat\nimport Mathlib.CategoryTheory.Groupoid\nimport Mathlib.CategoryTheory.Types\n\n/-!\n# Objects of a category up to an isomorphism\n\n`IsIsomorphic X Y := Nonempty (X ≅ Y)` is an equivalence relation on the objects of a category.\nThe quotient with respect to this relation defines a functor from our category to `Type`.\n-/\n\n\nuniverse v u\n\nnamespace CategoryTheory\n\nsection Category\n\nvariable {C : Type u} [Category.{v} C]\n\n/-- An object `X` is isomorphic to an object `Y`, if `X ≅ Y` is not empty. -/\ndef IsIsomorphic : C → C → Prop := fun X Y => Nonempty (X ≅ Y)\n#align category_theory.is_isomorphic CategoryTheory.IsIsomorphic\n\nvariable (C)\n\n/-- `IsIsomorphic` defines a setoid. -/\ndef isIsomorphicSetoid : Setoid C where\n  r := IsIsomorphic\n  iseqv := ⟨fun X => ⟨Iso.refl X⟩, fun ⟨α⟩ => ⟨α.symm⟩, fun ⟨α⟩ ⟨β⟩ => ⟨α.trans β⟩⟩\n#align category_theory.is_isomorphic_setoid CategoryTheory.isIsomorphicSetoid\n\nend Category\n\n/-- The functor that sends each category to the quotient space of its objects up to an isomorphism.\n-/\ndef isomorphismClasses : Cat.{v, u} ⥤ Type u where\n  obj C := Quotient (isIsomorphicSetoid C.α)\n  map {C D} F := Quot.map F.obj fun X Y ⟨f⟩ => ⟨F.mapIso f⟩\n  map_id {C} := by  -- Porting note: this used to be `tidy`\n    dsimp; apply funext; intro x\n    apply x.recOn  -- Porting note: `induction x` not working yet\n    · intro _ _ p\n      simp only [types_id_apply]\n    · intro _\n      rfl\n  map_comp {C D E} f g := by -- Porting note(s): idem\n    dsimp; apply funext; intro x\n    apply x.recOn\n    · intro _ _ _\n      simp only [types_id_apply]\n    · intro _\n      rfl\n#align category_theory.isomorphism_classes CategoryTheory.isomorphismClasses\n\n\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/IsomorphismClasses.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4669805027194194}}
{"text": "import GMLInit.Class.DecLift\nimport GMLInit.Data.Array\nimport GMLInit.Data.Fin\n\ninstance {α} (β : α → Type _) [DecidableEq α] [(x : α) → DecidableEq (β x)] : DecidableEq ((x : α) × β x)\n| a₁, a₂ =>\n  match a₁, a₂, inferInstanceAs (Decidable (a₁.fst = a₂.fst)) with\n  | ⟨_,y₁⟩, ⟨_,y₂⟩, isTrue rfl =>\n    if h : y₁ = y₂ then\n      isTrue <| Sigma.eq rfl (heq_of_eq h)\n    else\n      isFalse fun | rfl => h rfl\n  | ⟨_,_⟩, ⟨_,_⟩, isFalse hne => isFalse fun | rfl => hne rfl\n\nclass Finite (α : Type _) extends Array α where\n  find : α → Fin toArray.size\n  find_eq_iff_get_eq (x : α) (i : Fin toArray.size) : find x = i ↔ toArray.get i = x\n  decEq : DecidableEq α := by infer_instance\n\nattribute [instance] Finite.decEq\n\nnamespace Finite\nvariable (α) [inst : Finite α]\n\nprotected abbrev size := inst.toArray.size\n\nprotected abbrev get := inst.toArray.get\n\ntheorem get_find (x : α) : Finite.get α (Finite.find x) = x := by\n  rw [←find_eq_iff_get_eq]\n\ntheorem find_get (i : Fin (Finite.size α)) : Finite.find (Finite.get α i) = i := by\n  rw [find_eq_iff_get_eq]\n\nprotected def toEquiv : Equiv α (Fin (Finite.size α)) where\n  fwd := Finite.find\n  rev := Finite.get α\n  spec {x i} := Finite.find_eq_iff_get_eq x i\n\nprotected def ofEquiv {α n} [DecidableEq α] (e : Equiv α (Fin n)) : Finite α where\n  toArray := Array.ofFun e.rev\n  find x := (Array.ofFun_size e.rev).symm ▸ e.fwd x\n  find_eq_iff_get_eq x i := by\n    constr\n    · intro h\n      rw [Array.ofFun_get]\n      rw [←e.spec]\n      rw [←h]\n      elim_casts\n    · intro h\n      rw [Array.ofFun_get] at h\n      rw [←e.spec] at h\n      clean\n      rw [h]\n      elim_casts\n\nprotected abbrev all {α} [Finite α] (p : α → Bool) : Bool :=\n  Fin.all fun i => p (Finite.get α i)\n\ntheorem forall_eq_true_of_all_eq_true {α} [Finite α] {p : α → Bool} : Finite.all p = true → ∀ x, p x = true := by\n  intro h x\n  have hall := Fin.forall_eq_true_of_all_eq_true h\n  rw [←hall (Finite.find x)]\n  rw [Finite.get_find]\n\ntheorem exists_eq_false_of_all_eq_false {α} [Finite α] {p : α → Bool} : Finite.all p = false → ∃ x, p x = false := by\n  intro h\n  match Fin.exists_eq_false_of_all_eq_false h with\n  | ⟨i, h⟩ => exists (Finite.get α i)\n\ninstance (p : α → Prop) [DecidablePred p] : Decidable (∀ x, p x) :=\n  match hall : Finite.all fun x => decide (p x) with\n  | false => isFalse $ by\n    intro h\n    match exists_eq_false_of_all_eq_false hall with\n    | ⟨x, hx⟩ => absurd h x; exact of_decide_eq_false hx\n  | true => isTrue $ by\n    intro x\n    apply of_decide_eq_true\n    exact forall_eq_true_of_all_eq_true hall ..\n\ntheorem decide_forall (p : α → Prop) [DecidablePred p] : decide (∀ x, p x) = Finite.all fun x => decide (p x) := by\n  match h : Finite.all fun x => decide (p x) with\n  | false =>\n    apply decide_eq_false\n    match exists_eq_false_of_all_eq_false h with\n    | ⟨x, hx⟩ =>\n      intro h\n      rw [decide_eq_true (h x)] at hx\n      contradiction\n  | true =>\n    apply decide_eq_true\n    intro x\n    apply of_decide_eq_true\n    apply forall_eq_true_of_all_eq_true h\n\ninstance {α} (p : α → Bool) [Finite α] [(x : α) → DecLift (p x)] : DecLift (Finite.all p) where\n  toProp := ∀ x, DecLift.toProp (p x)\n  instDecidable := inferInstance\n  decide_eq := by rw [decide_forall]; congr; funext x; rw [DecLift.decide_eq]\n\nprotected abbrev any {α} [Finite α] (p : α → Bool) : Bool :=\n  Fin.any fun i => p (Finite.get α i)\n\ntheorem exists_eq_true_of_any_eq_true {α} [Finite α] {p : α → Bool} : Finite.any p = true → ∃ x, p x = true := by\n  intro h\n  match Fin.exists_eq_true_of_any_eq_true h with\n  | ⟨i, h⟩ => exists (Finite.get α i)\n\ntheorem forall_eq_false_of_any_eq_false {α} [Finite α] {p : α → Bool} : Finite.any p = false → ∀ x, p x = false := by\n  intro h x\n  have hany := Fin.forall_eq_false_of_any_eq_false h\n  rw [←hany (Finite.find x)]\n  rw [Finite.get_find]\n\ninstance (p : α → Prop) [DecidablePred p] : Decidable (∃ x, p x) :=\n  match hany : Finite.any fun x => decide (p x) with\n  | true => isTrue $ by\n    match exists_eq_true_of_any_eq_true hany with\n    | ⟨x, hx⟩ => exists x; exact of_decide_eq_true hx\n  | false => isFalse $ by\n    intro ⟨x, hx⟩\n    absurd hx\n    apply of_decide_eq_false\n    exact forall_eq_false_of_any_eq_false hany ..\n\ntheorem decide_exists (p : α → Prop) [DecidablePred p] : decide (∃ x, p x) = Finite.any fun x => decide (p x) := by\n  match h : Finite.any fun x => decide (p x) with\n  | true =>\n    apply decide_eq_true\n    match exists_eq_true_of_any_eq_true h with\n    | ⟨x, hx⟩ =>\n      exists x\n      exact of_decide_eq_true hx\n  | false =>\n    apply decide_eq_false\n    intro ⟨x, hx⟩\n    absurd forall_eq_false_of_any_eq_false h x\n    rw [decide_eq_true hx]\n    trivial\n\ninstance {α} (p : α → Bool) [Finite α] [(x : α) → DecLift (p x)] : DecLift (Finite.any p) where\n  toProp := ∃ x, DecLift.toProp (p x)\n  instDecidable := inferInstance\n  decide_eq := by rw [decide_exists]; congr; funext x; rw [DecLift.decide_eq]\n\ninstance : Finite Empty := Finite.ofEquiv Fin.equivEmpty.inv\n\ninstance : Finite Unit := Finite.ofEquiv Fin.equivUnit.inv\n\ninstance : Finite Bool := Finite.ofEquiv Fin.equivBool.inv\n\ninstance : Finite Ordering := Finite.ofEquiv Fin.equivOrdering.inv\n\ninstance (n) : Finite (Fin n) := Finite.ofEquiv Equiv.id\n\ninstance (α) [Finite α] : Finite (Option α) :=\n  let e₁ := Fin.equivOption (Finite.size α)\n  let e₂ := Option.equiv (Finite.toEquiv α)\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂\n\ninstance (α β) [DecidableEq β] [Finite α] [Finite β] : Finite (α ⊕ β) :=\n  let e₁ := Fin.equivSum (Finite.size α) (Finite.size β)\n  let e₂ := Sum.equiv (Finite.toEquiv α) (Finite.toEquiv β)\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂\n\ninstance (α β) [DecidableEq β] [Finite α] [Finite β] : Finite (α × β) :=\n  let e₁ := Fin.equivProd (Finite.size α) (Finite.size β)\n  let e₂ := Prod.equiv (Finite.toEquiv α) (Finite.toEquiv β)\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂\n\ninstance {α : Type _} (β : α → Type _) [Finite α] [(x : α) → Finite (β x)] : Finite ((x : α) × (β x)) :=\n  let e₁ := Fin.equivSigma (fun i => Finite.size (β ((Finite.toEquiv α).rev i)))\n  let e₂ := Sigma.equiv (Finite.toEquiv α).inv (fun i => (Finite.toEquiv (β ((Finite.toEquiv α).inv.fwd i))).inv)\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂.inv\n\ninstance (α β) [Finite α] [DecidableEq β] : DecidableEq (α → β)\n| f₁, f₂ =>\n  if h : ∀ x, f₁ x = f₂ x then\n    isTrue <| funext h\n  else\n    isFalse fun | rfl => h fun _ => rfl\n\ninstance (α β) [DecidableEq β] [Finite α] [Finite β] : Finite (α → β) :=\n  let e₁ := Fin.equivFun (Finite.size β) (Finite.size α)\n  let e₂ := Fun.equivND (Finite.toEquiv α) (Finite.toEquiv β)\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂\n\ninstance {α} (β : α → Type _) [Finite α] [(x : α) → DecidableEq (β x)] : DecidableEq ((x : α) → β x)\n| f₁, f₂ =>\n  if h : ∀ x, f₁ x = f₂ x then\n    isTrue <| funext h\n  else\n    isFalse fun | rfl => h fun _ => rfl\n\ninstance {α : Type _} (β : α → Type _) [Finite α] [(x : α) → Finite (β x)] : Finite ((x : α) → β x) :=\n  let e₁ := Fin.equivPi (fun i => Finite.size (β ((Finite.toEquiv α).rev i)))\n  let e₂ := Fun.equiv (Finite.toEquiv α).inv (fun i => (Finite.toEquiv (β ((Finite.toEquiv α).inv.fwd i))).inv)\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂.inv\n\ninstance (p : α → Prop) [DecidablePred p] [Finite α] : Finite (Subtype p) :=\n  let e₁ := Fin.equivSubtype fun i => p ((Finite.toEquiv α).rev i)\n  let e₂ := Subtype.equiv (Finite.toEquiv α) (by intro; simp [Equiv.rev_fwd])\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂\n\ninstance (s : Setoid α) [DecidableRel s.r] [Finite α] : Finite (Quotient s) :=\n  let s' : Setoid (Fin (Finite.size α)) := {\n    r := fun i j => (Finite.toEquiv α).rev i ≈ (Finite.toEquiv α).rev j\n    iseqv := Equivalence.mk (fun _ => s.refl _) s.symm s.trans\n  }\n  let e₁ := Fin.equivQuotient s'\n  let e₂ := Quotient.equiv (s₁:=s) (s₂:=s') (Finite.toEquiv α) $ by\n    intro x y\n    constr\n    · intro h\n      show (Finite.toEquiv α).rev ((Finite.toEquiv α).fwd x) ≈ (Finite.toEquiv α).rev ((Finite.toEquiv α).fwd y)\n      rw [Equiv.rev_fwd, Equiv.rev_fwd]\n      exact h\n    · intro h\n      have h : (Finite.toEquiv α).rev ((Finite.toEquiv α).fwd x) ≈ (Finite.toEquiv α).rev ((Finite.toEquiv α).fwd y) := h\n      rw [Equiv.rev_fwd, Equiv.rev_fwd] at h\n      exact h\n  Finite.ofEquiv <| Equiv.comp e₁.inv e₂\n\nend Finite\n\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Class/Finite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.46697964076151266}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebraic_geometry.presheafed_space.has_colimits\nimport topology.sheaves.functors\n\n/-!\n# Sheafed spaces\n\nIntroduces the category of topological spaces equipped with a sheaf (taking values in an\narbitrary target category `C`.)\n\nWe further describe how to apply functors and natural transformations to the values of the\npresheaves.\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.limits\nopen category_theory.category category_theory.functor\n\nvariables (C : Type u) [category.{v} C] [has_products.{v} C]\n\nlocal attribute [tidy] tactic.op_induction'\n\nnamespace algebraic_geometry\n\n/-- A `SheafedSpace C` is a topological space equipped with a sheaf of `C`s. -/\nstructure SheafedSpace extends PresheafedSpace.{v} C :=\n(is_sheaf : presheaf.is_sheaf)\n\nvariables {C}\n\nnamespace SheafedSpace\n\ninstance coe_carrier : has_coe (SheafedSpace C) Top :=\n{ coe := λ X, X.carrier }\n\n/-- Extract the `sheaf C (X : Top)` from a `SheafedSpace C`. -/\ndef sheaf (X : SheafedSpace C) : sheaf C (X : Top.{v}) := ⟨X.presheaf, X.is_sheaf⟩\n\n@[simp] lemma as_coe (X : SheafedSpace.{v} C) : X.carrier = (X : Top.{v}) := rfl\n@[simp] lemma mk_coe (carrier) (presheaf) (h) :\n  (({ carrier := carrier, presheaf := presheaf, is_sheaf := h } : SheafedSpace.{v} C) :\n  Top.{v}) = carrier :=\nrfl\n\ninstance (X : SheafedSpace.{v} C) : topological_space X := X.carrier.str\n\n/-- The trivial `unit` valued sheaf on any topological space. -/\ndef unit (X : Top) : SheafedSpace (discrete unit) :=\n{ is_sheaf := presheaf.is_sheaf_unit _,\n  ..@PresheafedSpace.const (discrete unit) _ X ⟨⟨⟩⟩ }\n\ninstance : inhabited (SheafedSpace (discrete _root_.unit)) := ⟨unit (Top.of pempty)⟩\n\ninstance : category (SheafedSpace C) :=\nshow category (induced_category (PresheafedSpace.{v} C) SheafedSpace.to_PresheafedSpace),\nby apply_instance\n\n/-- Forgetting the sheaf condition is a functor from `SheafedSpace C` to `PresheafedSpace C`. -/\n@[derive [full, faithful]]\ndef forget_to_PresheafedSpace : (SheafedSpace.{v} C) ⥤ (PresheafedSpace.{v} C) :=\ninduced_functor _\n\ninstance is_PresheafedSpace_iso {X Y : SheafedSpace.{v} C} (f : X ⟶ Y) [is_iso f] :\n  @is_iso (PresheafedSpace C) _ _ _ f :=\nSheafedSpace.forget_to_PresheafedSpace.map_is_iso f\n\nvariables {C}\n\nsection\nlocal attribute [simp] id comp\n\n@[simp] lemma id_base (X : SheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).base = (𝟙 (X : Top.{v})) := rfl\n\nlemma id_c (X : SheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).c = eq_to_hom (presheaf.pushforward.id_eq X.presheaf).symm := rfl\n\n@[simp] lemma id_c_app (X : SheafedSpace C) (U) :\n  ((𝟙 X) : X ⟶ X).c.app U = eq_to_hom (by { induction U using opposite.rec, cases U, refl }) :=\nby { induction U using opposite.rec, cases U, simp only [id_c], dsimp, simp, }\n\n@[simp] lemma comp_base {X Y Z : SheafedSpace C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).base = f.base ≫ g.base := rfl\n\n@[simp] lemma comp_c_app {X Y Z : SheafedSpace C} (α : X ⟶ Y) (β : Y ⟶ Z) (U) :\n  (α ≫ β).c.app U = (β.c).app U ≫ (α.c).app (op ((opens.map (β.base)).obj (unop U)))\n:= rfl\n\nlemma comp_c_app' {X Y Z : SheafedSpace C} (α : X ⟶ Y) (β : Y ⟶ Z) (U) :\n  (α ≫ β).c.app (op U) = (β.c).app (op U) ≫ (α.c).app (op ((opens.map (β.base)).obj U))\n:= rfl\n\nlemma congr_app {X Y : SheafedSpace C} {α β : X ⟶ Y} (h : α = β) (U) :\n  α.c.app U = β.c.app U ≫ X.presheaf.map (eq_to_hom (by subst h)) :=\nPresheafedSpace.congr_app h U\n\nvariables (C)\n\n/-- The forgetful functor from `SheafedSpace` to `Top`. -/\ndef forget : SheafedSpace C ⥤ Top :=\n{ obj := λ X, (X : Top.{v}),\n  map := λ X Y f, f.base }\n\nend\n\nopen Top.presheaf\n\n/--\nThe restriction of a sheafed space along an open embedding into the space.\n-/\ndef restrict {U : Top} (X : SheafedSpace C)\n  {f : U ⟶ (X : Top.{v})} (h : open_embedding f) : SheafedSpace C :=\n{ is_sheaf := λ ι 𝒰, ⟨is_limit.of_iso_limit\n    ((is_limit.postcompose_inv_equiv _ _).inv_fun (X.is_sheaf _).some)\n    (sheaf_condition_equalizer_products.fork.iso_of_open_embedding h 𝒰).symm⟩,\n  ..X.to_PresheafedSpace.restrict h }\n\n/--\nThe restriction of a sheafed space `X` to the top subspace is isomorphic to `X` itself.\n-/\ndef restrict_top_iso (X : SheafedSpace C) :\n  X.restrict (opens.open_embedding ⊤) ≅ X :=\nforget_to_PresheafedSpace.preimage_iso X.to_PresheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : (SheafedSpace C)ᵒᵖ ⥤ C :=\nforget_to_PresheafedSpace.op ⋙ PresheafedSpace.Γ\n\nlemma Γ_def : (Γ : _ ⥤ C) = forget_to_PresheafedSpace.op ⋙ PresheafedSpace.Γ := rfl\n\n@[simp] lemma Γ_obj (X : (SheafedSpace C)ᵒᵖ) : Γ.obj X = (unop X).presheaf.obj (op ⊤) := rfl\n\nlemma Γ_obj_op (X : SheafedSpace C) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\n@[simp] lemma Γ_map {X Y : (SheafedSpace C)ᵒᵖ} (f : X ⟶ Y) :\n  Γ.map f = f.unop.c.app (op ⊤) := rfl\n\nlemma Γ_map_op {X Y : SheafedSpace C} (f : X ⟶ Y) :\n  Γ.map f.op = f.c.app (op ⊤) := rfl\n\nnoncomputable\ninstance [has_limits C] : creates_colimits (forget_to_PresheafedSpace : SheafedSpace C ⥤ _) :=\n⟨λ J hJ, by exactI ⟨λ K, creates_colimit_of_fully_faithful_of_iso\n  ⟨(PresheafedSpace.colimit_cocone (K ⋙ forget_to_PresheafedSpace)).X,\n    limit_is_sheaf _ (λ j, sheaf.pushforward_sheaf_of_sheaf _ (K.obj (unop j)).2)⟩\n  (colimit.iso_colimit_cocone ⟨_, PresheafedSpace.colimit_cocone_is_colimit _⟩).symm⟩⟩\n\ninstance [has_limits C] : has_colimits (SheafedSpace C) :=\nhas_colimits_of_has_colimits_creates_colimits forget_to_PresheafedSpace\n\nnoncomputable instance [has_limits C] : preserves_colimits (forget C) :=\nlimits.comp_preserves_colimits forget_to_PresheafedSpace (PresheafedSpace.forget C)\n\nend SheafedSpace\n\nend algebraic_geometry\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/algebraic_geometry/sheafed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.46697964076151266}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.polynomial.eval\nimport Mathlib.algebra.algebra.tower\nimport Mathlib.PostPort\n\nuniverses u z u_1 u_2 u_3 v \n\nnamespace Mathlib\n\n/-!\n# Theory of univariate polynomials\n\nWe show that `polynomial A` is an R-algebra when `A` is an R-algebra.\nWe promote `eval₂` to an algebra hom in `aeval`.\n-/\n\nnamespace polynomial\n\n\n/-- Note that this instance also provides `algebra R (polynomial R)`. -/\nprotected instance algebra_of_algebra {R : Type u} {A : Type z} [comm_semiring R] [semiring A]\n    [algebra R A] : algebra R (polynomial A) :=\n  add_monoid_algebra.algebra\n\ntheorem algebra_map_apply {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (r : R) : coe_fn (algebra_map R (polynomial A)) r = coe_fn C (coe_fn (algebra_map R A) r) :=\n  rfl\n\n/--\nWhen we have `[comm_ring R]`, the function `C` is the same as `algebra_map R (polynomial R)`.\n\n(But note that `C` is defined when `R` is not necessarily commutative, in which case\n`algebra_map` is not available.)\n-/\ntheorem C_eq_algebra_map {R : Type u_1} [comm_ring R] (r : R) :\n    coe_fn C r = coe_fn (algebra_map R (polynomial R)) r :=\n  rfl\n\n@[simp] theorem alg_hom_eval₂_algebra_map {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_ring R]\n    [ring A] [ring B] [algebra R A] [algebra R B] (p : polynomial R) (f : alg_hom R A B) (a : A) :\n    coe_fn f (eval₂ (algebra_map R A) a p) = eval₂ (algebra_map R B) (coe_fn f a) p :=\n  sorry\n\n@[simp] theorem eval₂_algebra_map_X {R : Type u_1} {A : Type u_2} [comm_ring R] [ring A]\n    [algebra R A] (p : polynomial R) (f : alg_hom R (polynomial R) A) :\n    eval₂ (algebra_map R A) (coe_fn f X) p = coe_fn f p :=\n  sorry\n\n@[simp] theorem ring_hom_eval₂_algebra_map_int {R : Type u_1} {S : Type u_2} [ring R] [ring S]\n    (p : polynomial ℤ) (f : R →+* S) (r : R) :\n    coe_fn f (eval₂ (algebra_map ℤ R) r p) = eval₂ (algebra_map ℤ S) (coe_fn f r) p :=\n  alg_hom_eval₂_algebra_map p (ring_hom.to_int_alg_hom f) r\n\n@[simp] theorem eval₂_algebra_map_int_X {R : Type u_1} [ring R] (p : polynomial ℤ)\n    (f : polynomial ℤ →+* R) : eval₂ (algebra_map ℤ R) (coe_fn f X) p = coe_fn f p :=\n  sorry\n\n-- Unfortunately `f.to_int_alg_hom` doesn't work here, as typeclasses don't match up correctly.\n\ntheorem eval₂_comp {R : Type u} {S : Type v} [comm_semiring R] {p : polynomial R} {q : polynomial R}\n    [comm_semiring S] (f : R →+* S) {x : S} : eval₂ f x (comp p q) = eval₂ f (eval₂ f x q) p :=\n  sorry\n\ntheorem eval_comp {R : Type u} {a : R} [comm_semiring R] {p : polynomial R} {q : polynomial R} :\n    eval a (comp p q) = eval (eval a q) p :=\n  eval₂_comp (ring_hom.id R)\n\nprotected instance comp.is_semiring_hom {R : Type u} [comm_semiring R] {p : polynomial R} :\n    is_semiring_hom fun (q : polynomial R) => comp q p :=\n  eq.mpr\n    (id\n      ((fun (f f_1 : polynomial R → polynomial R) (e_3 : f = f_1) => congr_arg is_semiring_hom e_3)\n        (fun (q : polynomial R) => comp q p) (fun (q : polynomial R) => eval₂ C p q)\n        (funext fun (q : polynomial R) => comp.equations._eqn_1 q p)))\n    (eval₂.is_semiring_hom C p)\n\n/-- Given a valuation `x` of the variable in an `R`-algebra `A`, `aeval R A x` is\nthe unique `R`-algebra homomorphism from `R[X]` to `A` sending `X` to `x`. -/\ndef aeval {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A] (x : A) :\n    alg_hom R (polynomial R) A :=\n  alg_hom.mk (ring_hom.to_fun (eval₂_ring_hom' (algebra_map R A) x sorry)) sorry sorry sorry sorry\n    sorry\n\ntheorem alg_hom_ext {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    {f : alg_hom R (polynomial R) A} {g : alg_hom R (polynomial R) A}\n    (h : coe_fn f X = coe_fn g X) : f = g :=\n  add_monoid_algebra.alg_hom_ext' (monoid_hom.ext_mnat h)\n\ntheorem aeval_def {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A] (x : A)\n    (p : polynomial R) : coe_fn (aeval x) p = eval₂ (algebra_map R A) x p :=\n  rfl\n\n@[simp] theorem aeval_zero {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (x : A) : coe_fn (aeval x) 0 = 0 :=\n  alg_hom.map_zero (aeval x)\n\n@[simp] theorem aeval_X {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (x : A) : coe_fn (aeval x) X = x :=\n  eval₂_X (algebra_map R A) x\n\n@[simp] theorem aeval_C {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (x : A) (r : R) : coe_fn (aeval x) (coe_fn C r) = coe_fn (algebra_map R A) r :=\n  eval₂_C (algebra_map R A) x\n\ntheorem aeval_monomial {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (x : A) {n : ℕ} {r : R} :\n    coe_fn (aeval x) (coe_fn (monomial n) r) = coe_fn (algebra_map R A) r * x ^ n :=\n  eval₂_monomial (algebra_map R A) x\n\n@[simp] theorem aeval_X_pow {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (x : A) {n : ℕ} : coe_fn (aeval x) (X ^ n) = x ^ n :=\n  eval₂_X_pow (algebra_map R A) x\n\n@[simp] theorem aeval_add {R : Type u} {A : Type z} [comm_semiring R] {p : polynomial R}\n    {q : polynomial R} [semiring A] [algebra R A] (x : A) :\n    coe_fn (aeval x) (p + q) = coe_fn (aeval x) p + coe_fn (aeval x) q :=\n  alg_hom.map_add (aeval x) p q\n\n@[simp] theorem aeval_one {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (x : A) : coe_fn (aeval x) 1 = 1 :=\n  alg_hom.map_one (aeval x)\n\n@[simp] theorem aeval_bit0 {R : Type u} {A : Type z} [comm_semiring R] {p : polynomial R}\n    [semiring A] [algebra R A] (x : A) : coe_fn (aeval x) (bit0 p) = bit0 (coe_fn (aeval x) p) :=\n  alg_hom.map_bit0 (aeval x) p\n\n@[simp] theorem aeval_bit1 {R : Type u} {A : Type z} [comm_semiring R] {p : polynomial R}\n    [semiring A] [algebra R A] (x : A) : coe_fn (aeval x) (bit1 p) = bit1 (coe_fn (aeval x) p) :=\n  alg_hom.map_bit1 (aeval x) p\n\n@[simp] theorem aeval_nat_cast {R : Type u} {A : Type z} [comm_semiring R] [semiring A]\n    [algebra R A] (x : A) (n : ℕ) : coe_fn (aeval x) ↑n = ↑n :=\n  alg_hom.map_nat_cast (aeval x) n\n\ntheorem aeval_mul {R : Type u} {A : Type z} [comm_semiring R] {p : polynomial R} {q : polynomial R}\n    [semiring A] [algebra R A] (x : A) :\n    coe_fn (aeval x) (p * q) = coe_fn (aeval x) p * coe_fn (aeval x) q :=\n  alg_hom.map_mul (aeval x) p q\n\ntheorem aeval_comp {R : Type u} [comm_semiring R] {p : polynomial R} {q : polynomial R}\n    {A : Type u_1} [comm_semiring A] [algebra R A] (x : A) :\n    coe_fn (aeval x) (comp p q) = coe_fn (aeval (coe_fn (aeval x) q)) p :=\n  eval₂_comp (algebra_map R A)\n\n@[simp] theorem aeval_map {R : Type u} [comm_semiring R] {B : Type u_1} [semiring B] [algebra R B]\n    {A : Type u_2} [comm_semiring A] [algebra R A] [algebra A B] [is_scalar_tower R A B] (b : B)\n    (p : polynomial R) : coe_fn (aeval b) (map (algebra_map R A) p) = coe_fn (aeval b) p :=\n  sorry\n\ntheorem eval_unique {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    (φ : alg_hom R (polynomial R) A) (p : polynomial R) :\n    coe_fn φ p = eval₂ (algebra_map R A) (coe_fn φ X) p :=\n  sorry\n\ntheorem aeval_alg_hom {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    {B : Type u_1} [semiring B] [algebra R B] (f : alg_hom R A B) (x : A) :\n    aeval (coe_fn f x) = alg_hom.comp f (aeval x) :=\n  sorry\n\ntheorem aeval_alg_hom_apply {R : Type u} {A : Type z} [comm_semiring R] [semiring A] [algebra R A]\n    {B : Type u_1} [semiring B] [algebra R B] (f : alg_hom R A B) (x : A) (p : polynomial R) :\n    coe_fn (aeval (coe_fn f x)) p = coe_fn f (coe_fn (aeval x) p) :=\n  iff.mp alg_hom.ext_iff (aeval_alg_hom f x) p\n\n@[simp] theorem coe_aeval_eq_eval {R : Type u} [comm_semiring R] (r : R) : ⇑(aeval r) = eval r :=\n  rfl\n\ntheorem coeff_zero_eq_aeval_zero {R : Type u} [comm_semiring R] (p : polynomial R) :\n    coeff p 0 = coe_fn (aeval 0) p :=\n  sorry\n\ntheorem pow_comp {R : Type u} [comm_semiring R] (p : polynomial R) (q : polynomial R) (k : ℕ) :\n    comp (p ^ k) q = comp p q ^ k :=\n  sorry\n\ntheorem is_root_of_eval₂_map_eq_zero {R : Type u} {S : Type v} [comm_semiring R] {p : polynomial R}\n    [comm_ring S] {f : R →+* S} (hf : function.injective ⇑f) {r : R} :\n    eval₂ f (coe_fn f r) p = 0 → is_root p r :=\n  sorry\n\ntheorem is_root_of_aeval_algebra_map_eq_zero {R : Type u} {S : Type v} [comm_semiring R]\n    [comm_ring S] [algebra R S] {p : polynomial R} (inj : function.injective ⇑(algebra_map R S))\n    {r : R} (hr : coe_fn (aeval (coe_fn (algebra_map R S) r)) p = 0) : is_root p r :=\n  is_root_of_eval₂_map_eq_zero inj hr\n\ntheorem dvd_term_of_dvd_eval_of_dvd_terms {S : Type v} [comm_ring S] {z : S} {p : S}\n    {f : polynomial S} (i : ℕ) (dvd_eval : p ∣ eval z f)\n    (dvd_terms : ∀ (j : ℕ), j ≠ i → p ∣ coeff f j * z ^ j) : p ∣ coeff f i * z ^ i :=\n  sorry\n\ntheorem dvd_term_of_is_root_of_dvd_terms {S : Type v} [comm_ring S] {r : S} {p : S}\n    {f : polynomial S} (i : ℕ) (hr : is_root f r) (h : ∀ (j : ℕ), j ≠ i → p ∣ coeff f j * r ^ j) :\n    p ∣ coeff f i * r ^ i :=\n  dvd_term_of_dvd_eval_of_dvd_terms i (Eq.symm hr ▸ dvd_zero p) h\n\ntheorem aeval_eq_sum_range {R : Type u} {S : Type v} [comm_semiring R] [comm_ring S] [algebra R S]\n    {p : polynomial R} (x : S) :\n    coe_fn (aeval x) p =\n        finset.sum (finset.range (nat_degree p + 1)) fun (i : ℕ) => coeff p i • x ^ i :=\n  sorry\n\ntheorem aeval_eq_sum_range' {R : Type u} {S : Type v} [comm_semiring R] [comm_ring S] [algebra R S]\n    {p : polynomial R} {n : ℕ} (hn : nat_degree p < n) (x : S) :\n    coe_fn (aeval x) p = finset.sum (finset.range n) fun (i : ℕ) => coeff p i • x ^ i :=\n  sorry\n\n/--\nThe evaluation map is not generally multiplicative when the coefficient ring is noncommutative,\nbut nevertheless any polynomial of the form `p * (X - monomial 0 r)` is sent to zero\nwhen evaluated at `r`.\n\nThis is the key step in our proof of the Cayley-Hamilton theorem.\n-/\ntheorem eval_mul_X_sub_C {R : Type u} [ring R] {p : polynomial R} (r : R) :\n    eval r (p * (X - coe_fn C r)) = 0 :=\n  sorry\n\ntheorem not_is_unit_X_sub_C {R : Type u} [ring R] [nontrivial R] {r : R} :\n    ¬is_unit (X - coe_fn C r) :=\n  sorry\n\ntheorem aeval_endomorphism {R : Type u} {M : Type u_1} [comm_ring R] [add_comm_group M] [module R M]\n    (f : linear_map R M M) (v : M) (p : polynomial R) :\n    coe_fn (coe_fn (aeval f) p) v = finsupp.sum p fun (n : ℕ) (b : R) => b • coe_fn (f ^ n) v :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/polynomial/algebra_map_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4669796407615126}}
{"text": "universes u v\n\ninductive imp (st : Type u)\n| Seq : imp → imp → imp\n| Modify : (st → st) → imp\n| If : (st → Prop) → imp → imp → imp\n| While : (st → Prop) → imp → imp\n\ndef Skip {α : Type u}: imp α := imp.Modify id\n\ndef repeat {α : Type u} (f : α → α) : α → ℕ → α\n| v 0 := v\n| v (nat.succ a) := repeat (f v) a\n\ndef imp_repeat {α : Type u} (f : imp α): ℕ → imp α := repeat (imp.Seq f) Skip\n\nlemma repeat_succ {α : Type u} (f : α → α) (s : α) (n : ℕ):\n   repeat f s (nat.succ n) = f (repeat f s n) :=\nbegin\nunfold repeat,\ninduction n generalizing s,\ntrivial,\nunfold repeat,\napply n_ih,\nend", "meta": {"author": "PolyB", "repo": "lean-tests", "sha": "77f01468404b1f99bc7d3197d5d507d55f4b3da1", "save_path": "github-repos/lean/PolyB-lean-tests", "path": "github-repos/lean/PolyB-lean-tests/lean-tests-77f01468404b1f99bc7d3197d5d507d55f4b3da1/src/imp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.46697963356547556}}
{"text": "/-\nCopyright (c) 2022 Alex J. Best, Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alex J. Best, Yaël Dillies\n\n! This file was ported from Lean 3 source module algebra.order.hom.ring\n! leanprover-community/mathlib commit ee05e9ce1322178f0c12004eb93c00d2c8c00ed2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.Archimedean\nimport Mathbin.Algebra.Order.Hom.Monoid\nimport Mathbin.Algebra.Order.Ring.Defs\nimport Mathbin.Algebra.Ring.Equiv\nimport Mathbin.Tactic.ByContra\nimport Mathbin.Tactic.Wlog\n\n/-!\n# Ordered ring homomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nHomomorphisms between ordered (semi)rings that respect the ordering.\n\n## Main definitions\n\n* `order_ring_hom` : Monotone semiring homomorphisms.\n* `order_ring_iso` : Monotone semiring isomorphisms.\n\n## Notation\n\n* `→+*o`: Ordered ring homomorphisms.\n* `≃+*o`: Ordered ring isomorphisms.\n\n## Tags\n\nordered ring homomorphism, order homomorphism\n-/\n\n\nopen Function\n\nvariable {F α β γ δ : Type _}\n\n#print OrderRingHom /-\n/-- `order_ring_hom α β` is the type of monotone semiring homomorphisms from `α` to `β`.\n\nWhen possible, instead of parametrizing results over `(f : order_ring_hom α β)`,\nyou should parametrize over `(F : Type*) [order_ring_hom_class F α β] (f : F)`.\n\nWhen you extend this structure, make sure to extend `order_ring_hom_class`. -/\nstructure OrderRingHom (α β : Type _) [NonAssocSemiring α] [Preorder α] [NonAssocSemiring β]\n  [Preorder β] extends α →+* β where\n  monotone' : Monotone to_fun\n#align order_ring_hom OrderRingHom\n-/\n\n/-- Reinterpret an ordered ring homomorphism as a ring homomorphism. -/\nadd_decl_doc OrderRingHom.toRingHom\n\n-- mathport name: «expr →+*o »\ninfixl:25 \" →+*o \" => OrderRingHom\n\n/- warning: order_ring_iso -> OrderRingIso is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) (β : Type.{u2}) [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], Sort.{max (succ u1) (succ u2)}\nbut is expected to have type\n  forall (α : Type.{u1}) (β : Type.{u2}) [_inst_1 : Mul.{u1} α] [_inst_2 : Mul.{u2} β] [_inst_3 : Add.{u1} α] [_inst_4 : Add.{u2} β] [_inst_5 : LE.{u1} α] [_inst_6 : LE.{u2} β], Sort.{max (succ u1) (succ u2)}\nCase conversion may be inaccurate. Consider using '#align order_ring_iso OrderRingIsoₓ'. -/\n/-- `order_ring_hom α β` is the type of order-preserving semiring isomorphisms between `α` and `β`.\n\nWhen possible, instead of parametrizing results over `(f : order_ring_iso α β)`,\nyou should parametrize over `(F : Type*) [order_ring_iso_class F α β] (f : F)`.\n\nWhen you extend this structure, make sure to extend `order_ring_iso_class`. -/\nstructure OrderRingIso (α β : Type _) [Mul α] [Add α] [LE α] [Mul β] [Add β] [LE β] extends\n  α ≃+* β where\n  map_le_map_iff' {a b : α} : to_fun a ≤ to_fun b ↔ a ≤ b\n#align order_ring_iso OrderRingIso\n\n-- mathport name: «expr ≃+*o »\ninfixl:25 \" ≃+*o \" => OrderRingIso\n\n#print OrderRingHomClass /-\n/-- `order_ring_hom_class F α β` states that `F` is a type of ordered semiring homomorphisms.\nYou should extend this typeclass when you extend `order_ring_hom`. -/\nclass OrderRingHomClass (F : Type _) (α β : outParam <| Type _) [NonAssocSemiring α] [Preorder α]\n  [NonAssocSemiring β] [Preorder β] extends RingHomClass F α β where\n  Monotone (f : F) : Monotone f\n#align order_ring_hom_class OrderRingHomClass\n-/\n\n#print OrderRingIsoClass /-\n/-- `order_ring_iso_class F α β` states that `F` is a type of ordered semiring isomorphisms.\nYou should extend this class when you extend `order_ring_iso`. -/\nclass OrderRingIsoClass (F : Type _) (α β : outParam (Type _)) [Mul α] [Add α] [LE α] [Mul β]\n  [Add β] [LE β] extends RingEquivClass F α β where\n  map_le_map_iff (f : F) {a b : α} : f a ≤ f b ↔ a ≤ b\n#align order_ring_iso_class OrderRingIsoClass\n-/\n\n#print OrderRingHomClass.toOrderAddMonoidHomClass /-\n-- See note [lower priority instance]\ninstance (priority := 100) OrderRingHomClass.toOrderAddMonoidHomClass [NonAssocSemiring α]\n    [Preorder α] [NonAssocSemiring β] [Preorder β] [OrderRingHomClass F α β] :\n    OrderAddMonoidHomClass F α β :=\n  { ‹OrderRingHomClass F α β› with }\n#align order_ring_hom_class.to_order_add_monoid_hom_class OrderRingHomClass.toOrderAddMonoidHomClass\n-/\n\n#print OrderRingHomClass.toOrderMonoidWithZeroHomClass /-\n-- See note [lower priority instance]\ninstance (priority := 100) OrderRingHomClass.toOrderMonoidWithZeroHomClass [NonAssocSemiring α]\n    [Preorder α] [NonAssocSemiring β] [Preorder β] [OrderRingHomClass F α β] :\n    OrderMonoidWithZeroHomClass F α β :=\n  { ‹OrderRingHomClass F α β› with }\n#align order_ring_hom_class.to_order_monoid_with_zero_hom_class OrderRingHomClass.toOrderMonoidWithZeroHomClass\n-/\n\n#print OrderRingIsoClass.toOrderIsoClass /-\n-- See note [lower instance priority]\ninstance (priority := 100) OrderRingIsoClass.toOrderIsoClass [Mul α] [Add α] [LE α] [Mul β] [Add β]\n    [LE β] [OrderRingIsoClass F α β] : OrderIsoClass F α β :=\n  { ‹OrderRingIsoClass F α β› with }\n#align order_ring_iso_class.to_order_iso_class OrderRingIsoClass.toOrderIsoClass\n-/\n\n/- warning: order_ring_iso_class.to_order_ring_hom_class -> OrderRingIsoClass.toOrderRingHomClass is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u3} β] [_inst_4 : Preorder.{u3} β] [_inst_5 : OrderRingIsoClass.{u1, u2, u3} F α β (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toHasAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Preorder.toLE.{u2} α _inst_2) (Distrib.toHasMul.{u3} β (NonUnitalNonAssocSemiring.toDistrib.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_3))) (Distrib.toHasAdd.{u3} β (NonUnitalNonAssocSemiring.toDistrib.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_3))) (Preorder.toLE.{u3} β _inst_4)], OrderRingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3 _inst_4\nbut is expected to have type\n  forall {F : Type.{u1}} {α : Type.{u2}} {β : Type.{u3}} {_inst_1 : NonAssocSemiring.{u2} α} {_inst_2 : Preorder.{u2} α} {_inst_3 : NonAssocSemiring.{u3} β} {_inst_4 : Preorder.{u3} β} [_inst_5 : OrderRingIsoClass.{u1, u2, u3} F α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Preorder.toLE.{u2} α _inst_2) (NonUnitalNonAssocSemiring.toMul.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_3)) (Distrib.toAdd.{u3} β (NonUnitalNonAssocSemiring.toDistrib.{u3} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} β _inst_3))) (Preorder.toLE.{u3} β _inst_4)], OrderRingHomClass.{u1, u2, u3} F α β _inst_1 _inst_2 _inst_3 _inst_4\nCase conversion may be inaccurate. Consider using '#align order_ring_iso_class.to_order_ring_hom_class OrderRingIsoClass.toOrderRingHomClassₓ'. -/\n-- See note [lower instance priority]\ninstance (priority := 100) OrderRingIsoClass.toOrderRingHomClass [NonAssocSemiring α] [Preorder α]\n    [NonAssocSemiring β] [Preorder β] [OrderRingIsoClass F α β] : OrderRingHomClass F α β :=\n  { ‹OrderRingIsoClass F α β› with Monotone := fun f => OrderHomClass.mono f }\n#align order_ring_iso_class.to_order_ring_hom_class OrderRingIsoClass.toOrderRingHomClass\n\ninstance [NonAssocSemiring α] [Preorder α] [NonAssocSemiring β] [Preorder β]\n    [OrderRingHomClass F α β] : CoeTC F (α →+*o β) :=\n  ⟨fun f => ⟨f, OrderHomClass.mono f⟩⟩\n\ninstance [Mul α] [Add α] [LE α] [Mul β] [Add β] [LE β] [OrderRingIsoClass F α β] :\n    CoeTC F (α ≃+*o β) :=\n  ⟨fun f => ⟨f, fun a b => map_le_map_iff f⟩⟩\n\n/-! ### Ordered ring homomorphisms -/\n\n\nnamespace OrderRingHom\n\nvariable [NonAssocSemiring α] [Preorder α]\n\nsection Preorder\n\nvariable [NonAssocSemiring β] [Preorder β] [NonAssocSemiring γ] [Preorder γ] [NonAssocSemiring δ]\n  [Preorder δ]\n\n#print OrderRingHom.toOrderAddMonoidHom /-\n/-- Reinterpret an ordered ring homomorphism as an ordered additive monoid homomorphism. -/\ndef toOrderAddMonoidHom (f : α →+*o β) : α →+o β :=\n  { f with }\n#align order_ring_hom.to_order_add_monoid_hom OrderRingHom.toOrderAddMonoidHom\n-/\n\n#print OrderRingHom.toOrderMonoidWithZeroHom /-\n/-- Reinterpret an ordered ring homomorphism as an order homomorphism. -/\ndef toOrderMonoidWithZeroHom (f : α →+*o β) : α →*₀o β :=\n  { f with }\n#align order_ring_hom.to_order_monoid_with_zero_hom OrderRingHom.toOrderMonoidWithZeroHom\n-/\n\ninstance : OrderRingHomClass (α →+*o β) α β\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain ⟨⟨_, _⟩, _⟩ := f <;> obtain ⟨⟨_, _⟩, _⟩ := g <;> congr\n  map_mul f := f.map_mul'\n  map_one f := f.map_one'\n  map_add f := f.map_add'\n  map_zero f := f.map_zero'\n  Monotone f := f.monotone'\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : CoeFun (α →+*o β) fun _ => α → β :=\n  ⟨fun f => f.toFun⟩\n\n/- warning: order_ring_hom.to_fun_eq_coe -> OrderRingHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (α -> β) (RingHom.toFun.{u1, u2} α β _inst_1 _inst_3 (OrderRingHom.toRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (α -> β) (OneHom.toFun.{u2, u1} α β (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1))) (MulOneClass.toOne.{u1} β (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3))) (MonoidHom.toOneHom.{u2, u1} α β (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) (RingHom.toMonoidHom.{u2, u1} α β _inst_1 _inst_3 (OrderRingHom.toRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 f)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (f : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) f) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.to_fun_eq_coe OrderRingHom.toFun_eq_coeₓ'. -/\ntheorem toFun_eq_coe (f : α →+*o β) : f.toFun = ⇑f :=\n  rfl\n#align order_ring_hom.to_fun_eq_coe OrderRingHom.toFun_eq_coe\n\n/- warning: order_ring_hom.ext -> OrderRingHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] {f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4} {g : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4}, (forall (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) g a)) -> (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] {f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4} {g : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4}, (forall (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) g a)) -> (Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) f g)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.ext OrderRingHom.extₓ'. -/\n@[ext]\ntheorem ext {f g : α →+*o β} (h : ∀ a, f a = g a) : f = g :=\n  FunLike.ext f g h\n#align order_ring_hom.ext OrderRingHom.ext\n\n/- warning: order_ring_hom.to_ring_hom_eq_coe -> OrderRingHom.toRingHom_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} α β _inst_1 _inst_3) (OrderRingHom.toRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (RingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} α β _inst_1 _inst_3) (OrderRingHom.toRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 f) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.to_ring_hom_eq_coe OrderRingHom.toRingHom_eq_coeₓ'. -/\n@[simp]\ntheorem toRingHom_eq_coe (f : α →+*o β) : f.toRingHom = f :=\n  RingHom.ext fun _ => rfl\n#align order_ring_hom.to_ring_hom_eq_coe OrderRingHom.toRingHom_eq_coe\n\n/- warning: order_ring_hom.to_order_add_monoid_hom_eq_coe -> OrderRingHom.toOrderAddMonoidHom_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (OrderRingHom.toOrderAddMonoidHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (OrderAddMonoidHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (OrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))) (OrderRingHom.toOrderAddMonoidHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 f) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.to_order_add_monoid_hom_eq_coe OrderRingHom.toOrderAddMonoidHom_eq_coeₓ'. -/\n@[simp]\ntheorem toOrderAddMonoidHom_eq_coe (f : α →+*o β) : f.toOrderAddMonoidHom = f :=\n  rfl\n#align order_ring_hom.to_order_add_monoid_hom_eq_coe OrderRingHom.toOrderAddMonoidHom_eq_coe\n\n/- warning: order_ring_hom.to_order_monoid_with_zero_hom_eq_coe clashes with order_ring_hom.to_order_monoid_with_zero_hom -> OrderRingHom.toOrderMonoidWithZeroHom\nwarning: order_ring_hom.to_order_monoid_with_zero_hom_eq_coe -> OrderRingHom.toOrderMonoidWithZeroHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (OrderRingHom.toOrderMonoidWithZeroHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (OrderMonoidWithZeroHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β], (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) -> (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.to_order_monoid_with_zero_hom_eq_coe OrderRingHom.toOrderMonoidWithZeroHomₓ'. -/\n@[simp]\ntheorem toOrderMonoidWithZeroHom (f : α →+*o β) : f.toOrderMonoidWithZeroHom = f :=\n  rfl\n#align order_ring_hom.to_order_monoid_with_zero_hom_eq_coe OrderRingHom.toOrderMonoidWithZeroHom\n\n/- warning: order_ring_hom.coe_coe_ring_hom -> OrderRingHom.coe_coe_ringHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β _inst_1 _inst_3) (fun (_x : RingHom.{u1, u2} α β _inst_1 _inst_3) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_3) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (RingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α β _inst_1 _inst_3 (RingHom.instRingHomClassRingHom.{u2, u1} α β _inst_1 _inst_3)))) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_coe_ring_hom OrderRingHom.coe_coe_ringHomₓ'. -/\n@[simp]\ntheorem coe_coe_ringHom (f : α →+*o β) : ⇑(f : α →+* β) = f :=\n  rfl\n#align order_ring_hom.coe_coe_ring_hom OrderRingHom.coe_coe_ringHom\n\n/- warning: order_ring_hom.coe_coe_order_add_monoid_hom -> OrderRingHom.coe_coe_orderAddMonoidHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (fun (_x : OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) => α -> β) (OrderAddMonoidHom.hasCoeToFun.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (OrderAddMonoidHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderAddMonoidHom.instOrderAddMonoidHomClassOrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))))) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_coe_order_add_monoid_hom OrderRingHom.coe_coe_orderAddMonoidHomₓ'. -/\n@[simp]\ntheorem coe_coe_orderAddMonoidHom (f : α →+*o β) : ⇑(f : α →+o β) = f :=\n  rfl\n#align order_ring_hom.coe_coe_order_add_monoid_hom OrderRingHom.coe_coe_orderAddMonoidHom\n\n/- warning: order_ring_hom.coe_coe_order_monoid_with_zero_hom -> OrderRingHom.coe_coe_orderMonoidWithZeroHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (fun (_x : OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) => α -> β) (OrderMonoidWithZeroHom.hasCoeToFun.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (OrderMonoidWithZeroHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α β _inst_2 _inst_4 (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) (OrderMonoidWithZeroHomClass.toOrderMonoidHomClass.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3) (OrderMonoidWithZeroHom.instOrderMonoidWithZeroHomClassOrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3))))) (OrderMonoidWithZeroHomClass.toOrderMonoidWithZeroHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_coe_order_monoid_with_zero_hom OrderRingHom.coe_coe_orderMonoidWithZeroHomₓ'. -/\n@[simp]\ntheorem coe_coe_orderMonoidWithZeroHom (f : α →+*o β) : ⇑(f : α →*₀o β) = f :=\n  rfl\n#align order_ring_hom.coe_coe_order_monoid_with_zero_hom OrderRingHom.coe_coe_orderMonoidWithZeroHom\n\n/- warning: order_ring_hom.coe_ring_hom_apply -> OrderRingHom.coe_ringHom_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} α β _inst_1 _inst_3) (fun (_x : RingHom.{u1, u2} α β _inst_1 _inst_3) => α -> β) (RingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_3) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} α β _inst_1 _inst_3) (RingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f) a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α (fun (_x : α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : α) => β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} α β _inst_1 _inst_3) α β _inst_1 _inst_3 (RingHom.instRingHomClassRingHom.{u2, u1} α β _inst_1 _inst_3)))) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f a)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_ring_hom_apply OrderRingHom.coe_ringHom_applyₓ'. -/\n@[norm_cast]\ntheorem coe_ringHom_apply (f : α →+*o β) (a : α) : (f : α →+* β) a = f a :=\n  rfl\n#align order_ring_hom.coe_ring_hom_apply OrderRingHom.coe_ringHom_apply\n\n/- warning: order_ring_hom.coe_order_add_monoid_hom_apply -> OrderRingHom.coe_orderAddMonoidHom_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (fun (_x : OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) => α -> β) (OrderAddMonoidHom.hasCoeToFun.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3))))) (OrderAddMonoidHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f) a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderAddMonoidHom.instOrderAddMonoidHomClassOrderAddMonoidHom.{u2, u1} α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3))))))) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f a)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_order_add_monoid_hom_apply OrderRingHom.coe_orderAddMonoidHom_applyₓ'. -/\n@[norm_cast]\ntheorem coe_orderAddMonoidHom_apply (f : α →+*o β) (a : α) : (f : α →+o β) a = f a :=\n  rfl\n#align order_ring_hom.coe_order_add_monoid_hom_apply OrderRingHom.coe_orderAddMonoidHom_apply\n\n/- warning: order_ring_hom.coe_order_monoid_with_zero_hom_apply -> OrderRingHom.coe_orderMonoidWithZeroHom_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (fun (_x : OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) => α -> β) (OrderMonoidWithZeroHom.hasCoeToFun.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3)) (OrderMonoidWithZeroHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} β _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4))))) f) a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α β _inst_2 _inst_4 (MulZeroOneClass.toMulOneClass.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1)) (MulZeroOneClass.toMulOneClass.{u1} β (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) (OrderMonoidWithZeroHomClass.toOrderMonoidHomClass.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3)) α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3) (OrderMonoidWithZeroHom.instOrderMonoidWithZeroHomClassOrderMonoidWithZeroHom.{u2, u1} α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3))))) (OrderMonoidWithZeroHomClass.toOrderMonoidWithZeroHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} β _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)) f) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f a)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_order_monoid_with_zero_hom_apply OrderRingHom.coe_orderMonoidWithZeroHom_applyₓ'. -/\n@[norm_cast]\ntheorem coe_orderMonoidWithZeroHom_apply (f : α →+*o β) (a : α) : (f : α →*₀o β) a = f a :=\n  rfl\n#align order_ring_hom.coe_order_monoid_with_zero_hom_apply OrderRingHom.coe_orderMonoidWithZeroHom_apply\n\n/- warning: order_ring_hom.copy -> OrderRingHom.copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f)) -> (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (f' : α -> β), (Eq.{max (succ u1) (succ u2)} (α -> β) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u2} β (Preorder.toLE.{u2} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} β (AddMonoidWithOne.toAddMonoid.{u2} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} β (NonAssocSemiring.toAddCommMonoidWithOne.{u2} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f)) -> (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.copy OrderRingHom.copyₓ'. -/\n/-- Copy of a `order_ring_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : α →+*o β) (f' : α → β) (h : f' = f) : α →+*o β :=\n  { f.toRingHom.copy f' h, f.toOrderAddMonoidHom.copy f' h with }\n#align order_ring_hom.copy OrderRingHom.copy\n\n/- warning: order_ring_hom.coe_copy -> OrderRingHom.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.copy.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 f f' h)) f'\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) (OrderRingHom.copy.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_copy OrderRingHom.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (f : α →+*o β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' :=\n  rfl\n#align order_ring_hom.coe_copy OrderRingHom.coe_copy\n\n/- warning: order_ring_hom.copy_eq -> OrderRingHom.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (f' : α -> β) (h : Eq.{max (succ u1) (succ u2)} (α -> β) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) f)), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.copy.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 f f' h) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (f' : α -> β) (h : Eq.{max (succ u2) (succ u1)} (α -> β) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) f)), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.copy.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 f f' h) f\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.copy_eq OrderRingHom.copy_eqₓ'. -/\ntheorem copy_eq (f : α →+*o β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align order_ring_hom.copy_eq OrderRingHom.copy_eq\n\nvariable (α)\n\n#print OrderRingHom.id /-\n/-- The identity as an ordered ring homomorphism. -/\nprotected def id : α →+*o α :=\n  { RingHom.id _, OrderHom.id with }\n#align order_ring_hom.id OrderRingHom.id\n-/\n\ninstance : Inhabited (α →+*o α) :=\n  ⟨OrderRingHom.id α⟩\n\n/- warning: order_ring_hom.coe_id -> OrderRingHom.coe_id is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (α -> α) (coeFn.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (fun (_x : OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) => α -> α) (OrderRingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (id.{succ u1} α)\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => α) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => α) _x) (RelHomClass.toFunLike.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2)))) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (id.{succ u1} α)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_id OrderRingHom.coe_idₓ'. -/\n@[simp]\ntheorem coe_id : ⇑(OrderRingHom.id α) = id :=\n  rfl\n#align order_ring_hom.coe_id OrderRingHom.coe_id\n\nvariable {α}\n\n/- warning: order_ring_hom.id_apply -> OrderRingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] (a : α), Eq.{succ u1} α (coeFn.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (fun (_x : OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) => α -> α) (OrderRingHom.hasCoeToFun.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHom.id.{u1} α _inst_1 _inst_2) a) a\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => α) a) (FunLike.coe.{succ u1, succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => α) _x) (RelHomClass.toFunLike.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2)))) (OrderRingHom.id.{u1} α _inst_1 _inst_2) a) a\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.id_apply OrderRingHom.id_applyₓ'. -/\n@[simp]\ntheorem id_apply (a : α) : OrderRingHom.id α a = a :=\n  rfl\n#align order_ring_hom.id_apply OrderRingHom.id_apply\n\n/- warning: order_ring_hom.coe_ring_hom_id -> OrderRingHom.coe_RingHom_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (RingHom.{u1, u1} α α _inst_1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (RingHom.{u1, u1} α α _inst_1 _inst_1) (HasLiftT.mk.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (RingHom.{u1, u1} α α _inst_1 _inst_1) (CoeTCₓ.coe.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (RingHom.{u1, u1} α α _inst_1 _inst_1) (RingHom.hasCoeT.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_1 (OrderRingHomClass.toRingHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.orderRingHomClass.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2))))) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (RingHom.id.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (RingHom.{u1, u1} α α _inst_1 _inst_1) (RingHomClass.toRingHom.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_1 (OrderRingHomClass.toRingHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2)) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (RingHom.id.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_ring_hom_id OrderRingHom.coe_RingHom_idₓ'. -/\n@[simp]\ntheorem coe_RingHom_id : (OrderRingHom.id α : α →+* α) = RingHom.id α :=\n  rfl\n#align order_ring_hom.coe_ring_hom_id OrderRingHom.coe_RingHom_id\n\n/- warning: order_ring_hom.coe_order_add_monoid_hom_id -> OrderRingHom.coe_OrderAddMonoidHom_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (OrderAddMonoidHom.{u1, u1} α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderAddMonoidHom.{u1, u1} α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1))))) (HasLiftT.mk.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderAddMonoidHom.{u1, u1} α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1))))) (CoeTCₓ.coe.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderAddMonoidHom.{u1, u1} α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1))))) (OrderAddMonoidHom.hasCoeT.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.orderRingHomClass.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2))))) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (OrderAddMonoidHom.id.{u1} α _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (OrderAddMonoidHom.{u1, u1} α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1))))) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2)) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (OrderAddMonoidHom.id.{u1} α _inst_2 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_order_add_monoid_hom_id OrderRingHom.coe_OrderAddMonoidHom_idₓ'. -/\n@[simp]\ntheorem coe_OrderAddMonoidHom_id : (OrderRingHom.id α : α →+o α) = OrderAddMonoidHom.id α :=\n  rfl\n#align order_ring_hom.coe_order_add_monoid_hom_id OrderRingHom.coe_OrderAddMonoidHom_id\n\n/- warning: order_ring_hom.coe_order_monoid_with_zero_hom_id -> OrderRingHom.coe_OrderMonoidWithZeroHom_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (OrderMonoidWithZeroHom.{u1, u1} α α _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderMonoidWithZeroHom.{u1, u1} α α _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (HasLiftT.mk.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderMonoidWithZeroHom.{u1, u1} α α _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (CoeTCₓ.coe.{succ u1, succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderMonoidWithZeroHom.{u1, u1} α α _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (OrderMonoidWithZeroHom.hasCoeT.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.orderRingHomClass.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2))))) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (OrderMonoidWithZeroHom.id.{u1} α _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (OrderMonoidWithZeroHom.{u1, u1} α α _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1)) (OrderMonoidWithZeroHomClass.toOrderMonoidWithZeroHom.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2)) (OrderRingHom.id.{u1} α _inst_1 _inst_2)) (OrderMonoidWithZeroHom.id.{u1} α _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_order_monoid_with_zero_hom_id OrderRingHom.coe_OrderMonoidWithZeroHom_idₓ'. -/\n@[simp]\ntheorem coe_OrderMonoidWithZeroHom_id :\n    (OrderRingHom.id α : α →*₀o α) = OrderMonoidWithZeroHom.id α :=\n  rfl\n#align order_ring_hom.coe_order_monoid_with_zero_hom_id OrderRingHom.coe_OrderMonoidWithZeroHom_id\n\n#print OrderRingHom.comp /-\n/-- Composition of two `order_ring_hom`s as an `order_ring_hom`. -/\nprotected def comp (f : β →+*o γ) (g : α →+*o β) : α →+*o γ :=\n  { f.toRingHom.comp g.toRingHom, f.toOrderAddMonoidHom.comp g.toOrderAddMonoidHom with }\n#align order_ring_hom.comp OrderRingHom.comp\n-/\n\n/- warning: order_ring_hom.coe_comp -> OrderRingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] [_inst_5 : NonAssocSemiring.{u3} γ] [_inst_6 : Preorder.{u3} γ] (f : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u3)} (α -> γ) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) => α -> γ) (OrderRingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g)) (Function.comp.{succ u1, succ u2, succ u3} α β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) => β -> γ) (OrderRingHom.hasCoeToFun.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) g))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u3} β] [_inst_4 : Preorder.{u3} β] [_inst_5 : NonAssocSemiring.{u2} γ] [_inst_6 : Preorder.{u2} γ] (f : OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => γ) ᾰ) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => γ) _x) (RelHomClass.toFunLike.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α γ (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : γ) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : γ) => LE.le.{u2} γ (Preorder.toLE.{u2} γ _inst_6) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α γ _inst_2 _inst_6 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} γ (AddMonoidWithOne.toAddMonoid.{u2} γ (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} γ (NonAssocSemiring.toAddCommMonoidWithOne.{u2} γ _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α γ _inst_1 _inst_2 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6)))) (OrderRingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g)) (Function.comp.{succ u1, succ u3, succ u2} α β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β (fun (_x : β) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : β) => γ) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : β) => LE.le.{u3} β (Preorder.toLE.{u3} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : γ) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : γ) => LE.le.{u2} γ (Preorder.toLE.{u2} γ _inst_6) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ _inst_4 _inst_6 (AddMonoid.toAddZeroClass.{u3} β (AddMonoidWithOne.toAddMonoid.{u3} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} β (NonAssocSemiring.toAddCommMonoidWithOne.{u3} β _inst_3)))) (AddMonoid.toAddZeroClass.{u2} γ (AddMonoidWithOne.toAddMonoid.{u2} γ (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} γ (NonAssocSemiring.toAddCommMonoidWithOne.{u2} γ _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6)))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u3} β (Preorder.toLE.{u3} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u3} β (AddMonoidWithOne.toAddMonoid.{u3} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} β (NonAssocSemiring.toAddCommMonoidWithOne.{u3} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4)))) g))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_comp OrderRingHom.coe_compₓ'. -/\n@[simp]\ntheorem coe_comp (f : β →+*o γ) (g : α →+*o β) : ⇑(f.comp g) = f ∘ g :=\n  rfl\n#align order_ring_hom.coe_comp OrderRingHom.coe_comp\n\n/- warning: order_ring_hom.comp_apply -> OrderRingHom.comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] [_inst_5 : NonAssocSemiring.{u3} γ] [_inst_6 : Preorder.{u3} γ] (f : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u3} γ (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) => α -> γ) (OrderRingHom.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) => β -> γ) (OrderRingHom.hasCoeToFun.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) g a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u3} β] [_inst_4 : Preorder.{u3} β] [_inst_5 : NonAssocSemiring.{u2} γ] [_inst_6 : Preorder.{u2} γ] (f : OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) (a : α), Eq.{succ u2} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => γ) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => γ) _x) (RelHomClass.toFunLike.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α γ (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : γ) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : γ) => LE.le.{u2} γ (Preorder.toLE.{u2} γ _inst_6) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α γ _inst_2 _inst_6 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u2} γ (AddMonoidWithOne.toAddMonoid.{u2} γ (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} γ (NonAssocSemiring.toAddCommMonoidWithOne.{u2} γ _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) α γ _inst_1 _inst_2 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6)))) (OrderRingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g) a) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β (fun (_x : β) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : β) => γ) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : β) => LE.le.{u3} β (Preorder.toLE.{u3} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : γ) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : γ) => LE.le.{u2} γ (Preorder.toLE.{u2} γ _inst_6) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ _inst_4 _inst_6 (AddMonoid.toAddZeroClass.{u3} β (AddMonoidWithOne.toAddMonoid.{u3} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} β (NonAssocSemiring.toAddCommMonoidWithOne.{u3} β _inst_3)))) (AddMonoid.toAddZeroClass.{u2} γ (AddMonoidWithOne.toAddMonoid.{u2} γ (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} γ (NonAssocSemiring.toAddCommMonoidWithOne.{u2} γ _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6)))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u3} β (Preorder.toLE.{u3} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u3} β (AddMonoidWithOne.toAddMonoid.{u3} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} β (NonAssocSemiring.toAddCommMonoidWithOne.{u3} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4)))) g a))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.comp_apply OrderRingHom.comp_applyₓ'. -/\n@[simp]\ntheorem comp_apply (f : β →+*o γ) (g : α →+*o β) (a : α) : f.comp g a = f (g a) :=\n  rfl\n#align order_ring_hom.comp_apply OrderRingHom.comp_apply\n\n/- warning: order_ring_hom.comp_assoc -> OrderRingHom.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] [_inst_5 : NonAssocSemiring.{u3} γ] [_inst_6 : Preorder.{u3} γ] [_inst_7 : NonAssocSemiring.{u4} δ] [_inst_8 : Preorder.{u4} δ] (f : OrderRingHom.{u3, u4} γ δ _inst_5 _inst_6 _inst_7 _inst_8) (g : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) (h : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u4)} (OrderRingHom.{u1, u4} α δ _inst_1 _inst_2 _inst_7 _inst_8) (OrderRingHom.comp.{u1, u2, u4} α β δ _inst_1 _inst_2 _inst_3 _inst_4 _inst_7 _inst_8 (OrderRingHom.comp.{u2, u3, u4} β γ δ _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 f g) h) (OrderRingHom.comp.{u1, u3, u4} α γ δ _inst_1 _inst_2 _inst_5 _inst_6 _inst_7 _inst_8 f (OrderRingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 g h))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u4}} {δ : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] [_inst_5 : NonAssocSemiring.{u4} γ] [_inst_6 : Preorder.{u4} γ] [_inst_7 : NonAssocSemiring.{u3} δ] [_inst_8 : Preorder.{u3} δ] (f : OrderRingHom.{u4, u3} γ δ _inst_5 _inst_6 _inst_7 _inst_8) (g : OrderRingHom.{u2, u4} β γ _inst_3 _inst_4 _inst_5 _inst_6) (h : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} α δ _inst_1 _inst_2 _inst_7 _inst_8) (OrderRingHom.comp.{u1, u2, u3} α β δ _inst_1 _inst_2 _inst_3 _inst_4 _inst_7 _inst_8 (OrderRingHom.comp.{u2, u4, u3} β γ δ _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 f g) h) (OrderRingHom.comp.{u1, u4, u3} α γ δ _inst_1 _inst_2 _inst_5 _inst_6 _inst_7 _inst_8 f (OrderRingHom.comp.{u1, u2, u4} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 g h))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.comp_assoc OrderRingHom.comp_assocₓ'. -/\ntheorem comp_assoc (f : γ →+*o δ) (g : β →+*o γ) (h : α →+*o β) :\n    (f.comp g).comp h = f.comp (g.comp h) :=\n  rfl\n#align order_ring_hom.comp_assoc OrderRingHom.comp_assoc\n\n/- warning: order_ring_hom.comp_id -> OrderRingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u1, u1, u2} α α β _inst_1 _inst_2 _inst_1 _inst_2 _inst_3 _inst_4 f (OrderRingHom.id.{u1} α _inst_1 _inst_2)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u2, u2, u1} α α β _inst_1 _inst_2 _inst_1 _inst_2 _inst_3 _inst_4 f (OrderRingHom.id.{u2} α _inst_1 _inst_2)) f\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.comp_id OrderRingHom.comp_idₓ'. -/\n@[simp]\ntheorem comp_id (f : α →+*o β) : f.comp (OrderRingHom.id α) = f :=\n  ext fun x => rfl\n#align order_ring_hom.comp_id OrderRingHom.comp_id\n\n/- warning: order_ring_hom.id_comp -> OrderRingHom.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u1, u2, u2} α β β _inst_1 _inst_2 _inst_3 _inst_4 _inst_3 _inst_4 (OrderRingHom.id.{u2} β _inst_3 _inst_4) f) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u2, u1, u1} α β β _inst_1 _inst_2 _inst_3 _inst_4 _inst_3 _inst_4 (OrderRingHom.id.{u1} β _inst_3 _inst_4) f) f\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.id_comp OrderRingHom.id_compₓ'. -/\n@[simp]\ntheorem id_comp (f : α →+*o β) : (OrderRingHom.id β).comp f = f :=\n  ext fun x => rfl\n#align order_ring_hom.id_comp OrderRingHom.id_comp\n\n/- warning: order_ring_hom.cancel_right -> OrderRingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] [_inst_5 : NonAssocSemiring.{u3} γ] [_inst_6 : Preorder.{u3} γ] {f₁ : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6} {f₂ : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6} {g : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Surjective.{succ u1, succ u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f₁ g) (OrderRingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f₂ g)) (Eq.{max (succ u2) (succ u3)} (OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) f₁ f₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u3} β] [_inst_4 : Preorder.{u3} β] [_inst_5 : NonAssocSemiring.{u2} γ] [_inst_6 : Preorder.{u2} γ] {f₁ : OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6} {f₂ : OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6} {g : OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Surjective.{succ u1, succ u3} α β (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u3} β (Preorder.toLE.{u3} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} α (AddMonoidWithOne.toAddMonoid.{u1} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} α (NonAssocSemiring.toAddCommMonoidWithOne.{u1} α _inst_1)))) (AddMonoid.toAddZeroClass.{u3} β (AddMonoidWithOne.toAddMonoid.{u3} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} β (NonAssocSemiring.toAddCommMonoidWithOne.{u3} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4)))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f₁ g) (OrderRingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f₂ g)) (Eq.{max (succ u3) (succ u2)} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.cancel_right OrderRingHom.cancel_rightₓ'. -/\ntheorem cancel_right {f₁ f₂ : β →+*o γ} {g : α →+*o β} (hg : Surjective g) :\n    f₁.comp g = f₂.comp g ↔ f₁ = f₂ :=\n  ⟨fun h => ext <| hg.forall.2 <| FunLike.ext_iff.1 h, congr_arg _⟩\n#align order_ring_hom.cancel_right OrderRingHom.cancel_right\n\n/- warning: order_ring_hom.cancel_left -> OrderRingHom.cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] [_inst_5 : NonAssocSemiring.{u3} γ] [_inst_6 : Preorder.{u3} γ] {f : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6} {g₁ : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4} {g₂ : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Injective.{succ u2, succ u3} β γ (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) => β -> γ) (OrderRingHom.hasCoeToFun.{u2, u3} β γ _inst_3 _inst_4 _inst_5 _inst_6) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} α γ _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g₁) (OrderRingHom.comp.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g₂)) (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) g₁ g₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u3} β] [_inst_4 : Preorder.{u3} β] [_inst_5 : NonAssocSemiring.{u2} γ] [_inst_6 : Preorder.{u2} γ] {f : OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6} {g₁ : OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4} {g₂ : OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Injective.{succ u3, succ u2} β γ (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β (fun (_x : β) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : β) => γ) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : β) => LE.le.{u3} β (Preorder.toLE.{u3} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : γ) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : γ) => LE.le.{u2} γ (Preorder.toLE.{u2} γ _inst_6) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ _inst_4 _inst_6 (AddMonoid.toAddZeroClass.{u3} β (AddMonoidWithOne.toAddMonoid.{u3} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} β (NonAssocSemiring.toAddCommMonoidWithOne.{u3} β _inst_3)))) (AddMonoid.toAddZeroClass.{u2} γ (AddMonoidWithOne.toAddMonoid.{u2} γ (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} γ (NonAssocSemiring.toAddCommMonoidWithOne.{u2} γ _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6) β γ _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u3, u2} β γ _inst_3 _inst_4 _inst_5 _inst_6)))) f)) -> (Iff (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α γ _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g₁) (OrderRingHom.comp.{u1, u3, u2} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g₂)) (Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} α β _inst_1 _inst_2 _inst_3 _inst_4) g₁ g₂))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.cancel_left OrderRingHom.cancel_leftₓ'. -/\ntheorem cancel_left {f : β →+*o γ} {g₁ g₂ : α →+*o β} (hf : Injective f) :\n    f.comp g₁ = f.comp g₂ ↔ g₁ = g₂ :=\n  ⟨fun h => ext fun a => hf <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩\n#align order_ring_hom.cancel_left OrderRingHom.cancel_left\n\nend Preorder\n\nvariable [NonAssocSemiring β]\n\ninstance [Preorder β] : Preorder (OrderRingHom α β) :=\n  Preorder.lift (coeFn : _ → α → β)\n\ninstance [PartialOrder β] : PartialOrder (OrderRingHom α β) :=\n  PartialOrder.lift _ FunLike.coe_injective\n\nend OrderRingHom\n\n/-! ### Ordered ring isomorphisms -/\n\n\nnamespace OrderRingIso\n\nsection LE\n\nvariable [Mul α] [Add α] [LE α] [Mul β] [Add β] [LE β] [Mul γ] [Add γ] [LE γ] [Mul δ] [Add δ] [LE δ]\n\n/- warning: order_ring_iso.to_order_iso -> OrderRingIso.toOrderIso is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> (OrderIso.{u1, u2} α β _inst_3 _inst_6)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], (OrderRingIso.{u1, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> (OrderIso.{u1, u2} α β _inst_3 _inst_6)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_order_iso OrderRingIso.toOrderIsoₓ'. -/\n/-- Reinterpret an ordered ring isomorphism as an order isomorphism. -/\ndef toOrderIso (f : α ≃+*o β) : α ≃o β :=\n  ⟨f.toRingEquiv.toEquiv, fun _ _ => f.map_le_map_iff'⟩\n#align order_ring_iso.to_order_iso OrderRingIso.toOrderIso\n\ninstance : OrderRingIsoClass (α ≃+*o β) α β\n    where\n  coe f := f.toFun\n  inv f := f.invFun\n  coe_injective' f g h₁ h₂ := by\n    obtain ⟨⟨_, _⟩, _⟩ := f\n    obtain ⟨⟨_, _⟩, _⟩ := g\n    congr\n  map_add f := f.map_add'\n  map_mul f := f.map_mul'\n  map_le_map_iff f _ _ := f.map_le_map_iff'\n  left_inv f := f.left_inv\n  right_inv f := f.right_inv\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : CoeFun (α ≃+*o β) fun _ => α → β :=\n  FunLike.hasCoeToFun\n\n/- warning: order_ring_iso.to_fun_eq_coe -> OrderRingIso.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (f : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (α -> β) (RingEquiv.toFun.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIso.toRingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (f : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (α -> β) (Equiv.toFun.{succ u2, succ u1} α β (RingEquiv.toEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 (OrderRingIso.toRingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_fun_eq_coe OrderRingIso.toFun_eq_coeₓ'. -/\ntheorem toFun_eq_coe (f : α ≃+*o β) : f.toFun = f :=\n  rfl\n#align order_ring_iso.to_fun_eq_coe OrderRingIso.toFun_eq_coe\n\n/- warning: order_ring_iso.ext -> OrderRingIso.ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] {f : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6} {g : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6}, (forall (a : α), Eq.{succ u2} β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) g a)) -> (Eq.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] {f : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6} {g : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6}, (forall (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) g a)) -> (Eq.{max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) f g)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.ext OrderRingIso.extₓ'. -/\n@[ext]\ntheorem ext {f g : α ≃+*o β} (h : ∀ a, f a = g a) : f = g :=\n  FunLike.ext f g h\n#align order_ring_iso.ext OrderRingIso.ext\n\n/- warning: order_ring_iso.coe_mk -> OrderRingIso.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (e : RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (h : forall {a : α} {b : α}, Iff (LE.le.{u2} β _inst_6 (RingEquiv.toFun.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5 e a) (RingEquiv.toFun.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5 e b)) (LE.le.{u1} α _inst_3 a b)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.mk.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e h)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (fun (_x : RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) => α -> β) (RingEquiv.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) e)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (e : RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) (h : forall {a : α} {b : α}, Iff (LE.le.{u1} β _inst_6 (Equiv.toFun.{succ u2, succ u1} α β (RingEquiv.toEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 e) a) (Equiv.toFun.{succ u2, succ u1} α β (RingEquiv.toEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 e) b)) (LE.le.{u2} α _inst_3 a b)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) (OrderRingIso.mk.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6 e h)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β (MulEquivClass.toEquivLike.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β _inst_1 _inst_4 (RingEquivClass.toMulEquivClass.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β _inst_1 _inst_2 _inst_4 _inst_5 (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5))))) e)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_mk OrderRingIso.coe_mkₓ'. -/\n@[simp]\ntheorem coe_mk (e : α ≃+* β) (h) : ⇑(⟨e, h⟩ : α ≃+*o β) = e :=\n  rfl\n#align order_ring_iso.coe_mk OrderRingIso.coe_mk\n\n/- warning: order_ring_iso.mk_coe -> OrderRingIso.mk_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (e : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (h : forall {a : α} {b : α}, Iff (LE.le.{u2} β _inst_6 (RingEquiv.toFun.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5 ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) e) a) (RingEquiv.toFun.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5 ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) e) b)) (LE.le.{u1} α _inst_3 a b)), Eq.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.mk.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) e) h) e\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (e : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (h : forall {a : α} {b : α}, Iff (LE.le.{u1} β _inst_6 (Equiv.toFun.{succ u2, succ u1} α β (RingEquiv.toEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) e)) a) (Equiv.toFun.{succ u2, succ u1} α β (RingEquiv.toEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) e)) b)) (LE.le.{u2} α _inst_3 a b)), Eq.{max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (OrderRingIso.mk.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6 (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) e) h) e\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.mk_coe OrderRingIso.mk_coeₓ'. -/\n@[simp]\ntheorem mk_coe (e : α ≃+*o β) (h) : (⟨e, h⟩ : α ≃+*o β) = e :=\n  ext fun _ => rfl\n#align order_ring_iso.mk_coe OrderRingIso.mk_coe\n\n/- warning: order_ring_iso.to_ring_equiv_eq_coe -> OrderRingIso.toRingEquiv_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (f : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (OrderRingIso.toRingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (f : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) (OrderRingIso.toRingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6 f) (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_ring_equiv_eq_coe OrderRingIso.toRingEquiv_eq_coeₓ'. -/\n@[simp]\ntheorem toRingEquiv_eq_coe (f : α ≃+*o β) : f.toRingEquiv = f :=\n  RingEquiv.ext fun _ => rfl\n#align order_ring_iso.to_ring_equiv_eq_coe OrderRingIso.toRingEquiv_eq_coe\n\n/- warning: order_ring_iso.to_order_iso_eq_coe -> OrderRingIso.toOrderIso_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (f : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_3 _inst_6) (OrderRingIso.toOrderIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} α β _inst_3 _inst_6) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} α β _inst_3 _inst_6) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} α β _inst_3 _inst_6) (OrderIso.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (f : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (OrderIso.{u2, u1} α β _inst_3 _inst_6) (OrderRingIso.toOrderIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f) (OrderIsoClass.toOrderIso.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_order_iso_eq_coe OrderRingIso.toOrderIso_eq_coeₓ'. -/\n@[simp]\ntheorem toOrderIso_eq_coe (f : α ≃+*o β) : f.toOrderIso = f :=\n  OrderIso.ext rfl\n#align order_ring_iso.to_order_iso_eq_coe OrderRingIso.toOrderIso_eq_coe\n\n/- warning: order_ring_iso.coe_to_ring_equiv -> OrderRingIso.coe_toRingEquiv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (f : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (fun (_x : RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) => α -> β) (RingEquiv.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} α β _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (f : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β (MulEquivClass.toEquivLike.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β _inst_1 _inst_4 (RingEquivClass.toMulEquivClass.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5) α β _inst_1 _inst_2 _inst_4 _inst_5 (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5))))) (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_to_ring_equiv OrderRingIso.coe_toRingEquivₓ'. -/\n@[simp, norm_cast]\ntheorem coe_toRingEquiv (f : α ≃+*o β) : ⇑(f : α ≃+* β) = f :=\n  rfl\n#align order_ring_iso.coe_to_ring_equiv OrderRingIso.coe_toRingEquiv\n\n/- warning: order_ring_iso.coe_to_order_iso -> OrderRingIso.coe_toOrderIso is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (f : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_3 _inst_6) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_3) (LE.le.{u2} β _inst_6)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_3) (LE.le.{u2} β _inst_6)) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} α β _inst_3 _inst_6) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} α β _inst_3 _inst_6) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} α β _inst_3 _inst_6) (OrderIso.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (f : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (α -> β) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderIso.{u2, u1} α β _inst_3 _inst_6) α (fun (_x : α) => β) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderIso.{u2, u1} α β _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.instRelHomClassRelIso.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298))) (OrderIsoClass.toOrderIso.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_to_order_iso OrderRingIso.coe_toOrderIsoₓ'. -/\n@[simp, norm_cast]\ntheorem coe_toOrderIso (f : α ≃+*o β) : ⇑(f : α ≃o β) = f :=\n  rfl\n#align order_ring_iso.coe_to_order_iso OrderRingIso.coe_toOrderIso\n\nvariable (α)\n\n/- warning: order_ring_iso.refl -> OrderRingIso.refl is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α], OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α], OrderRingIso.{u1, u1} α α _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.refl OrderRingIso.reflₓ'. -/\n/-- The identity map as an ordered ring isomorphism. -/\n@[refl]\nprotected def refl : α ≃+*o α :=\n  ⟨RingEquiv.refl α, fun _ _ => Iff.rfl⟩\n#align order_ring_iso.refl OrderRingIso.refl\n\ninstance : Inhabited (α ≃+*o α) :=\n  ⟨OrderRingIso.refl α⟩\n\n#print OrderRingIso.refl_apply /-\n@[simp]\ntheorem refl_apply (x : α) : OrderRingIso.refl α x = x :=\n  rfl\n#align order_ring_iso.refl_apply OrderRingIso.refl_apply\n-/\n\n/- warning: order_ring_iso.coe_ring_equiv_refl -> OrderRingIso.coe_ringEquiv_refl is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α], Eq.{succ u1} (RingEquiv.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (RingEquiv.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (HasLiftT.mk.{succ u1, succ u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (RingEquiv.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (CoeTCₓ.coe.{succ u1, succ u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (RingEquiv.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (RingEquiv.hasCoeT.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toRingEquivClass.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.orderRingIsoClass.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3))))) (OrderRingIso.refl.{u1} α _inst_1 _inst_2 _inst_3)) (RingEquiv.refl.{u1} α _inst_1 _inst_2)\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α], Eq.{succ u1} (RingEquiv.{u1, u1} α α _inst_1 _inst_1 _inst_2 _inst_2) (RingEquivClass.toRingEquiv.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toRingEquivClass.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3)) (OrderRingIso.refl.{u1} α _inst_1 _inst_2 _inst_3)) (RingEquiv.refl.{u1} α _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_ring_equiv_refl OrderRingIso.coe_ringEquiv_reflₓ'. -/\n@[simp]\ntheorem coe_ringEquiv_refl : (OrderRingIso.refl α : α ≃+* α) = RingEquiv.refl α :=\n  rfl\n#align order_ring_iso.coe_ring_equiv_refl OrderRingIso.coe_ringEquiv_refl\n\n/- warning: order_ring_iso.coe_order_iso_refl -> OrderRingIso.coe_orderIso_refl is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α], Eq.{succ u1} (OrderIso.{u1, u1} α α _inst_3 _inst_3) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderIso.{u1, u1} α α _inst_3 _inst_3) (HasLiftT.mk.{succ u1, succ u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderIso.{u1, u1} α α _inst_3 _inst_3) (CoeTCₓ.coe.{succ u1, succ u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderIso.{u1, u1} α α _inst_3 _inst_3) (OrderIso.hasCoeT.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) α α _inst_3 _inst_3 (OrderRingIsoClass.toOrderIsoClass.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.orderRingIsoClass.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3))))) (OrderRingIso.refl.{u1} α _inst_1 _inst_2 _inst_3)) (OrderIso.refl.{u1} α _inst_3)\nbut is expected to have type\n  forall (α : Type.{u1}) [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α], Eq.{succ u1} (OrderIso.{u1, u1} α α _inst_3 _inst_3) (OrderIsoClass.toOrderIso.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) α α _inst_3 _inst_3 (OrderRingIsoClass.toOrderIsoClass.{u1, u1, u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3)) (OrderRingIso.refl.{u1} α _inst_1 _inst_2 _inst_3)) (OrderIso.refl.{u1} α _inst_3)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_order_iso_refl OrderRingIso.coe_orderIso_reflₓ'. -/\n@[simp]\ntheorem coe_orderIso_refl : (OrderRingIso.refl α : α ≃o α) = OrderIso.refl α :=\n  rfl\n#align order_ring_iso.coe_order_iso_refl OrderRingIso.coe_orderIso_refl\n\nvariable {α}\n\n/- warning: order_ring_iso.symm -> OrderRingIso.symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> (OrderRingIso.{u2, u1} β α _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], (OrderRingIso.{u1, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> (OrderRingIso.{u2, u1} β α _inst_4 _inst_1 _inst_5 _inst_2 _inst_6 _inst_3)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.symm OrderRingIso.symmₓ'. -/\n/-- The inverse of an ordered ring isomorphism as an ordered ring isomorphism. -/\n@[symm]\nprotected def symm (e : α ≃+*o β) : β ≃+*o α :=\n  ⟨e.toRingEquiv.symm, fun a b => by\n    erw [← map_le_map_iff e, e.1.apply_symm_apply, e.1.apply_symm_apply]⟩\n#align order_ring_iso.symm OrderRingIso.symm\n\n/- warning: order_ring_iso.simps.symm_apply -> OrderRingIso.Simps.symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> β -> α\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], (OrderRingIso.{u1, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> β -> α\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.simps.symm_apply OrderRingIso.Simps.symm_applyₓ'. -/\n/-- See Note [custom simps projection] -/\ndef Simps.symm_apply (e : α ≃+*o β) : β → α :=\n  e.symm\n#align order_ring_iso.simps.symm_apply OrderRingIso.Simps.symm_apply\n\n/- warning: order_ring_iso.symm_symm -> OrderRingIso.symm_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (e : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.symm.{u2, u1} β α _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 (OrderRingIso.symm.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e)) e\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (e : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (OrderRingIso.symm.{u1, u2} β α _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 (OrderRingIso.symm.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e)) e\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.symm_symm OrderRingIso.symm_symmₓ'. -/\n@[simp]\ntheorem symm_symm (e : α ≃+*o β) : e.symm.symm = e :=\n  ext fun _ => rfl\n#align order_ring_iso.symm_symm OrderRingIso.symm_symm\n\n/- warning: order_ring_iso.trans -> OrderRingIso.trans is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] [_inst_7 : Mul.{u3} γ] [_inst_8 : Add.{u3} γ] [_inst_9 : LE.{u3} γ], (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> (OrderRingIso.{u2, u3} β γ _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) -> (OrderRingIso.{u1, u3} α γ _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] [_inst_7 : Mul.{u3} γ] [_inst_8 : Add.{u3} γ] [_inst_9 : LE.{u3} γ], (OrderRingIso.{u1, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> (OrderRingIso.{u2, u3} β γ _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) -> (OrderRingIso.{u1, u3} α γ _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.trans OrderRingIso.transₓ'. -/\n/-- Composition of `order_ring_iso`s as an `order_ring_iso`. -/\n@[trans, simps]\nprotected def trans (f : α ≃+*o β) (g : β ≃+*o γ) : α ≃+*o γ :=\n  ⟨f.toRingEquiv.trans g.toRingEquiv, fun a b => (map_le_map_iff g).trans (map_le_map_iff f)⟩\n#align order_ring_iso.trans OrderRingIso.trans\n\n/- warning: order_ring_iso.trans_apply -> OrderRingIso.trans_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] [_inst_7 : Mul.{u3} γ] [_inst_8 : Add.{u3} γ] [_inst_9 : LE.{u3} γ] (f : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingIso.{u2, u3} β γ _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) (a : α), Eq.{succ u3} γ (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (OrderRingIso.{u1, u3} α γ _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9) (fun (_x : OrderRingIso.{u1, u3} α γ _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9) => α -> γ) (OrderRingIso.hasCoeToFun.{u1, u3} α γ _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9) (OrderRingIso.trans.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (OrderRingIso.{u2, u3} β γ _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) (fun (_x : OrderRingIso.{u2, u3} β γ _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) => β -> γ) (OrderRingIso.hasCoeToFun.{u2, u3} β γ _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) g (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f a))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : Mul.{u3} α] [_inst_2 : Add.{u3} α] [_inst_3 : LE.{u3} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] [_inst_7 : Mul.{u1} γ] [_inst_8 : Add.{u1} γ] [_inst_9 : LE.{u1} γ] (f : OrderRingIso.{u3, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (g : OrderRingIso.{u2, u1} β γ _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => γ) a) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (OrderRingIso.{u3, u1} α γ _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => γ) _x) (RelHomClass.toFunLike.{max u3 u1, u3, u1} (OrderRingIso.{u3, u1} α γ _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) α γ (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u3} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : γ) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : γ) => LE.le.{u1} γ _inst_9 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u3 u1, u3, u1} (OrderRingIso.{u3, u1} α γ _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) α γ _inst_3 _inst_9 (OrderRingIsoClass.toOrderIsoClass.{max u3 u1, u3, u1} (OrderRingIso.{u3, u1} α γ _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) α γ _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u3, u1} α γ _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9)))) (OrderRingIso.trans.{u3, u2, u1} α β γ _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 f g) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} β γ _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) β (fun (_x : β) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : β) => γ) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} β γ _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) β γ (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : β) => LE.le.{u2} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : γ) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : γ) => LE.le.{u1} γ _inst_9 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} β γ _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) β γ _inst_6 _inst_9 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} β γ _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) β γ _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} β γ _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9)))) g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OrderRingIso.{u3, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingIso.{u3, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u3} α _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u2} β _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderIsoClass.toOrderHomClass.{max u3 u2, u3, u2} (OrderRingIso.{u3, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u3 u2, u3, u2} (OrderRingIso.{u3, u2} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u3, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) f a))\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.trans_apply OrderRingIso.trans_applyₓ'. -/\n@[simp]\ntheorem trans_apply (f : α ≃+*o β) (g : β ≃+*o γ) (a : α) : f.trans g a = g (f a) :=\n  rfl\n#align order_ring_iso.trans_apply OrderRingIso.trans_apply\n\n/- warning: order_ring_iso.self_trans_symm -> OrderRingIso.self_trans_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (e : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{succ u1} (OrderRingIso.{u1, u1} α α _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderRingIso.trans.{u1, u2, u1} α β α _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 e (OrderRingIso.symm.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e)) (OrderRingIso.refl.{u1} α _inst_1 _inst_2 _inst_3)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (e : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{succ u2} (OrderRingIso.{u2, u2} α α _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) (OrderRingIso.trans.{u2, u1, u2} α β α _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 e (OrderRingIso.symm.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e)) (OrderRingIso.refl.{u2} α _inst_1 _inst_2 _inst_3)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.self_trans_symm OrderRingIso.self_trans_symmₓ'. -/\n@[simp]\ntheorem self_trans_symm (e : α ≃+*o β) : e.trans e.symm = OrderRingIso.refl α :=\n  ext e.left_inv\n#align order_ring_iso.self_trans_symm OrderRingIso.self_trans_symm\n\n/- warning: order_ring_iso.symm_trans_self -> OrderRingIso.symm_trans_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β] (e : OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{succ u2} (OrderRingIso.{u2, u2} β β _inst_4 _inst_5 _inst_6 _inst_4 _inst_5 _inst_6) (OrderRingIso.trans.{u2, u1, u2} β α β _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.symm.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e) e) (OrderRingIso.refl.{u2} β _inst_4 _inst_5 _inst_6)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β] (e : OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{succ u1} (OrderRingIso.{u1, u1} β β _inst_4 _inst_4 _inst_5 _inst_5 _inst_6 _inst_6) (OrderRingIso.trans.{u1, u2, u1} β α β _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.symm.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e) e) (OrderRingIso.refl.{u1} β _inst_4 _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.symm_trans_self OrderRingIso.symm_trans_selfₓ'. -/\n@[simp]\ntheorem symm_trans_self (e : α ≃+*o β) : e.symm.trans e = OrderRingIso.refl β :=\n  ext e.right_inv\n#align order_ring_iso.symm_trans_self OrderRingIso.symm_trans_self\n\n/- warning: order_ring_iso.symm_bijective -> OrderRingIso.symm_bijective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Mul.{u1} α] [_inst_2 : Add.{u1} α] [_inst_3 : LE.{u1} α] [_inst_4 : Mul.{u2} β] [_inst_5 : Add.{u2} β] [_inst_6 : LE.{u2} β], Function.Bijective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (OrderRingIso.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.{u2, u1} β α _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3) (OrderRingIso.symm.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Mul.{u2} α] [_inst_2 : Add.{u2} α] [_inst_3 : LE.{u2} α] [_inst_4 : Mul.{u1} β] [_inst_5 : Add.{u1} β] [_inst_6 : LE.{u1} β], Function.Bijective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} α β _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (OrderRingIso.{u1, u2} β α _inst_4 _inst_1 _inst_5 _inst_2 _inst_6 _inst_3) (OrderRingIso.symm.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.symm_bijective OrderRingIso.symm_bijectiveₓ'. -/\ntheorem symm_bijective : Bijective (OrderRingIso.symm : α ≃+*o β → β ≃+*o α) :=\n  ⟨fun f g h => f.symm_symm.symm.trans <| (congr_arg OrderRingIso.symm h).trans g.symm_symm,\n    fun f => ⟨f.symm, f.symm_symm⟩⟩\n#align order_ring_iso.symm_bijective OrderRingIso.symm_bijective\n\nend LE\n\nsection NonAssocSemiring\n\nvariable [NonAssocSemiring α] [Preorder α] [NonAssocSemiring β] [Preorder β] [NonAssocSemiring γ]\n  [Preorder γ]\n\n/- warning: order_ring_iso.to_order_ring_hom -> OrderRingIso.toOrderRingHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β], (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) -> (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β], (OrderRingIso.{u1, u2} α β (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3)) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u1} α _inst_2) (Preorder.toLE.{u2} β _inst_4)) -> (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_order_ring_hom OrderRingIso.toOrderRingHomₓ'. -/\n/-- Reinterpret an ordered ring isomorphism as an ordered ring homomorphism. -/\ndef toOrderRingHom (f : α ≃+*o β) : α →+*o β :=\n  ⟨f.toRingEquiv.toRingHom, fun a b => (map_le_map_iff f).2⟩\n#align order_ring_iso.to_order_ring_hom OrderRingIso.toOrderRingHom\n\n/- warning: order_ring_iso.to_order_ring_hom_eq_coe -> OrderRingIso.toOrderRingHom_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4 f) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.orderRingIsoClass.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)))))) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4 f) (OrderRingHomClass.toOrderRingHom.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Preorder.toLE.{u2} α _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u1} β _inst_4))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_order_ring_hom_eq_coe OrderRingIso.toOrderRingHom_eq_coeₓ'. -/\n@[simp]\ntheorem toOrderRingHom_eq_coe (f : α ≃+*o β) : f.toOrderRingHom = f :=\n  rfl\n#align order_ring_iso.to_order_ring_hom_eq_coe OrderRingIso.toOrderRingHom_eq_coe\n\n/- warning: order_ring_iso.coe_to_order_ring_hom -> OrderRingIso.coe_toOrderRingHom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β] (f : OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)), Eq.{max (succ u1) (succ u2)} (α -> β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) => α -> β) (OrderRingHom.hasCoeToFun.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) ((fun (a : Sort.{max (succ u1) (succ u2)}) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{max (succ u1) (succ u2), max (succ u1) (succ u2)} a b] => self.0) (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (CoeTCₓ.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.orderRingIsoClass.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (fun (_x : OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) => α -> β) (OrderRingIso.hasCoeToFun.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β] (f : OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)), Eq.{max (succ u2) (succ u1)} (forall (ᾰ : α), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) ᾰ) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)))) (OrderRingHomClass.toOrderRingHom.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Preorder.toLE.{u2} α _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u1} β _inst_4))) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α (fun (_x : α) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : α) => β) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} α (AddMonoidWithOne.toAddMonoid.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_1)))) (AddMonoid.toAddZeroClass.{u1} β (AddMonoidWithOne.toAddMonoid.{u1} β (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} β (NonAssocSemiring.toAddCommMonoidWithOne.{u1} β _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) α β _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Preorder.toLE.{u2} α _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u1} β _inst_4)))))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_to_order_ring_hom OrderRingIso.coe_toOrderRingHomₓ'. -/\n@[simp, norm_cast]\ntheorem coe_toOrderRingHom (f : α ≃+*o β) : ⇑(f : α →+*o β) = f :=\n  rfl\n#align order_ring_iso.coe_to_order_ring_hom OrderRingIso.coe_toOrderRingHom\n\n/- warning: order_ring_iso.coe_to_order_ring_hom_refl -> OrderRingIso.coe_toOrderRingHom_refl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingIso.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2)) (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (HasLiftT.mk.{succ u1, succ u1} (OrderRingIso.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2)) (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (CoeTCₓ.coe.{succ u1, succ u1} (OrderRingIso.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2)) (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHom.hasCoeT.{u1, u1, u1} (OrderRingIso.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2)) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toOrderRingHomClass.{u1, u1, u1} (OrderRingIso.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2)) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIso.orderRingIsoClass.{u1, u1} α α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2)))))) (OrderRingIso.refl.{u1} α (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2))) (OrderRingHom.id.{u1} α _inst_1 _inst_2)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α], Eq.{succ u1} (OrderRingHom.{u1, u1} α α _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHomClass.toOrderRingHom.{u1, u1, u1} (OrderRingIso.{u1, u1} α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Preorder.toLE.{u1} α _inst_2)) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toOrderRingHomClass.{u1, u1, u1} (OrderRingIso.{u1, u1} α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Preorder.toLE.{u1} α _inst_2)) α α _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u1, u1} α α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2))) (OrderRingIso.refl.{u1} α (NonUnitalNonAssocSemiring.toMul.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1)) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2))) (OrderRingHom.id.{u1} α _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_to_order_ring_hom_refl OrderRingIso.coe_toOrderRingHom_reflₓ'. -/\n@[simp]\ntheorem coe_toOrderRingHom_refl : (OrderRingIso.refl α : α →+*o α) = OrderRingHom.id α :=\n  rfl\n#align order_ring_iso.coe_to_order_ring_hom_refl OrderRingIso.coe_toOrderRingHom_refl\n\n/- warning: order_ring_iso.to_order_ring_hom_injective -> OrderRingIso.toOrderRingHom_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} α] [_inst_2 : Preorder.{u1} α] [_inst_3 : NonAssocSemiring.{u2} β] [_inst_4 : Preorder.{u2} β], Function.Injective.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α _inst_1))) (Preorder.toLE.{u1} α _inst_2) (Distrib.toHasMul.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Distrib.toHasAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β _inst_3))) (Preorder.toLE.{u2} β _inst_4)) (OrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u1, u2} α β _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} α] [_inst_2 : Preorder.{u2} α] [_inst_3 : NonAssocSemiring.{u1} β] [_inst_4 : Preorder.{u1} β], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} α β (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3)) (Distrib.toAdd.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_1))) (Distrib.toAdd.{u1} β (NonUnitalNonAssocSemiring.toDistrib.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β _inst_3))) (Preorder.toLE.{u2} α _inst_2) (Preorder.toLE.{u1} β _inst_4)) (OrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u2, u1} α β _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_order_ring_hom_injective OrderRingIso.toOrderRingHom_injectiveₓ'. -/\ntheorem toOrderRingHom_injective : Injective (toOrderRingHom : α ≃+*o β → α →+*o β) := fun f g h =>\n  FunLike.coe_injective <| by convert FunLike.ext'_iff.1 h\n#align order_ring_iso.to_order_ring_hom_injective OrderRingIso.toOrderRingHom_injective\n\nend NonAssocSemiring\n\nend OrderRingIso\n\n/-!\n### Uniqueness\n\nThere is at most one ordered ring homomorphism from a linear ordered field to an archimedean linear\nordered field. Reciprocally, such an ordered ring homomorphism exists when the codomain is further\nconditionally complete.\n-/\n\n\n#print OrderRingHom.subsingleton /-\n/-- There is at most one ordered ring homomorphism from a linear ordered field to an archimedean\nlinear ordered field. -/\ninstance OrderRingHom.subsingleton [LinearOrderedField α] [LinearOrderedField β] [Archimedean β] :\n    Subsingleton (α →+*o β) :=\n  ⟨fun f g => by\n    ext x\n    by_contra' h' : f x ≠ g x\n    wlog h : f x < g x\n    · exact this g f x (Ne.symm h') (h'.lt_or_lt.resolve_left h)\n    obtain ⟨q, hf, hg⟩ := exists_rat_btwn h\n    rw [← map_ratCast f] at hf\n    rw [← map_ratCast g] at hg\n    exact\n      (lt_asymm ((OrderHomClass.mono g).reflect_lt hg) <|\n          (OrderHomClass.mono f).reflect_lt hf).elim⟩\n#align order_ring_hom.subsingleton OrderRingHom.subsingleton\n-/\n\n/- warning: order_ring_iso.subsingleton_right -> OrderRingIso.subsingleton_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : LinearOrderedField.{u2} β] [_inst_3 : Archimedean.{u2} β (OrderedSemiring.toOrderedAddCommMonoid.{u2} β (StrictOrderedSemiring.toOrderedSemiring.{u2} β (StrictOrderedRing.toStrictOrderedSemiring.{u2} β (LinearOrderedRing.toStrictOrderedRing.{u2} β (LinearOrderedCommRing.toLinearOrderedRing.{u2} β (LinearOrderedField.toLinearOrderedCommRing.{u2} β _inst_2))))))], Subsingleton.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Distrib.toHasMul.{u2} β (Ring.toDistrib.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_2))))) (Distrib.toHasAdd.{u2} β (Ring.toDistrib.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_2))))) (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommGroup.toPartialOrder.{u2} β (StrictOrderedRing.toOrderedAddCommGroup.{u2} β (LinearOrderedRing.toStrictOrderedRing.{u2} β (LinearOrderedCommRing.toLinearOrderedRing.{u2} β (LinearOrderedField.toLinearOrderedCommRing.{u2} β _inst_2))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : LinearOrderedField.{u2} β] [_inst_3 : Archimedean.{u2} β (OrderedSemiring.toOrderedAddCommMonoid.{u2} β (OrderedCommSemiring.toOrderedSemiring.{u2} β (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} β (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} β (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} β (LinearOrderedField.toLinearOrderedSemifield.{u2} β _inst_2))))))], Subsingleton.{max (succ u2) (succ u1)} (OrderRingIso.{u1, u2} α β (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))) (NonUnitalNonAssocRing.toMul.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_2)))))) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))) (Distrib.toAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_2)))))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (StrictOrderedRing.toPartialOrder.{u2} β (LinearOrderedRing.toStrictOrderedRing.{u2} β (LinearOrderedCommRing.toLinearOrderedRing.{u2} β (LinearOrderedField.toLinearOrderedCommRing.{u2} β _inst_2)))))))\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.subsingleton_right OrderRingIso.subsingleton_rightₓ'. -/\n/-- There is at most one ordered ring isomorphism between a linear ordered field and an archimedean\nlinear ordered field. -/\ninstance OrderRingIso.subsingleton_right [LinearOrderedField α] [LinearOrderedField β]\n    [Archimedean β] : Subsingleton (α ≃+*o β) :=\n  OrderRingIso.toOrderRingHom_injective.Subsingleton\n#align order_ring_iso.subsingleton_right OrderRingIso.subsingleton_right\n\n/- warning: order_ring_iso.subsingleton_left -> OrderRingIso.subsingleton_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))] [_inst_3 : LinearOrderedField.{u2} β], Subsingleton.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} α β (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Distrib.toHasAdd.{u1} α (Ring.toDistrib.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Distrib.toHasMul.{u2} β (Ring.toDistrib.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_3))))) (Distrib.toHasAdd.{u2} β (Ring.toDistrib.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_3))))) (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommGroup.toPartialOrder.{u2} β (StrictOrderedRing.toOrderedAddCommGroup.{u2} β (LinearOrderedRing.toStrictOrderedRing.{u2} β (LinearOrderedCommRing.toLinearOrderedRing.{u2} β (LinearOrderedField.toLinearOrderedCommRing.{u2} β _inst_3))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))] [_inst_3 : LinearOrderedField.{u2} β], Subsingleton.{max (succ u2) (succ u1)} (OrderRingIso.{u1, u2} α β (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))) (NonUnitalNonAssocRing.toMul.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_3)))))) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (DivisionRing.toRing.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1)))))))) (Distrib.toAdd.{u2} β (NonUnitalNonAssocSemiring.toDistrib.{u2} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β (DivisionRing.toRing.{u2} β (Field.toDivisionRing.{u2} β (LinearOrderedField.toField.{u2} β _inst_3)))))))) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (StrictOrderedRing.toPartialOrder.{u2} β (LinearOrderedRing.toStrictOrderedRing.{u2} β (LinearOrderedCommRing.toLinearOrderedRing.{u2} β (LinearOrderedField.toLinearOrderedCommRing.{u2} β _inst_3)))))))\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.subsingleton_left OrderRingIso.subsingleton_leftₓ'. -/\n/-- There is at most one ordered ring isomorphism between an archimedean linear ordered field and a\nlinear ordered field. -/\ninstance OrderRingIso.subsingleton_left [LinearOrderedField α] [Archimedean α]\n    [LinearOrderedField β] : Subsingleton (α ≃+*o β) :=\n  OrderRingIso.symm_bijective.Injective.Subsingleton\n#align order_ring_iso.subsingleton_left OrderRingIso.subsingleton_left\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Hom/Ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4669796308588191}}
{"text": "-- Copyright (c) 2017 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Stephen Morgan and Scott Morrison\n\nimport category_theory.tactics.obviously\nimport tidy.auto_cast\n\nnamespace category_theory.graphs\n\nuniverses v₁ v₂ u₁ u₂\n\nclass graph (vertices : Type u₁) :=\n(edges : vertices → vertices → Sort v₁)\n\nvariable {C : Type u₁}\nvariables {W X Y Z : C}\nvariable [𝒞 : graph.{v₁} C]\n\ndef edges : C → C → Sort v₁ := @graph.edges.{v₁} C 𝒞\n\nstructure graph_hom (G : Type u₁) [graph.{v₁} G] (H : Type u₂) [graph.{v₂} H] :=\n(onVertices : G → H)\n(onEdges    : ∀ {X Y : G}, edges X Y → edges (onVertices X) (onVertices Y))\n\nsection\nvariables {G : Type u₁} [𝒢 : graph.{v₁} G] {H : Type u₂} [ℋ : graph.{v₂} H]\ninclude 𝒢 ℋ\n\n@[extensionality] lemma graph_hom_pointwise_equal\n  {p q : graph_hom G H}\n  (vertexWitness : ∀ X : G, p.onVertices X = q.onVertices X)\n  (edgeWitness : ∀ X Y : G, ∀ f : edges X Y, ⟬ p.onEdges f ⟭ = q.onEdges f) : p = q :=\nbegin\n  induction p with p_onVertices p_onEdges,\n  induction q with q_onVertices q_onEdges,\n  have h_vertices : p_onVertices = q_onVertices, exact funext vertexWitness,\n  subst h_vertices,\n  have h_edges : @p_onEdges = @q_onEdges,\n  apply funext, intro X, apply funext, intro Y, apply funext, intro f,\n  exact edgeWitness X Y f,\n  subst h_edges\nend\nend\n\nvariables {G : Type u₁} [𝒢 : graph.{v₁} G]\ninclude 𝒢\n\ninductive path : G → G → Type (max u₁ v₁)\n| nil  : Π (h : G), path h h\n| cons : Π {h s t : G} (e : edges h s) (l : path s t), path h t\n\ndef path.length : Π {s t : G}, path s t → ℕ\n| _ _ (path.nil _) := 0\n| _ _ (@path.cons _ _ _ _ _ e l) := path.length l\n\nnotation a :: b := path.cons a b\nnotation `p[` l:(foldr `, ` (h t, path.cons h t) path.nil _ `]`) := l\n\ninductive path_of_paths : G → G → Type (max u₁ v₁)\n| nil  : Π (h : G), path_of_paths h h\n| cons : Π {h s t : G} (e : path h s) (l : path_of_paths s t), path_of_paths h t\n\nnotation a :: b := path_of_paths.cons a b\nnotation `pp[` l:(foldr `, ` (h t, path_of_paths.cons h t) path_of_paths.nil _ `]`) := l\n\n-- The pattern matching trick used here was explained by Jeremy Avigad at https://groups.google.com/d/msg/lean-user/JqaI12tdk3g/F9MZDxkFDAAJ\ndef concatenate_paths : Π {x y z : G}, path x y → path y z → path x z\n| ._ ._ _ (path.nil _)               q := q\n| ._ ._ _ (@path.cons ._ _ _ _ _ e p') q := path.cons e (concatenate_paths p' q)\n\n@[simp] lemma concatenate_paths' {x' x y z : G} (e : edges x' x) (p : path x y) (q : path y z) : concatenate_paths (e :: p) q = e :: (concatenate_paths p q) := rfl\n\ndef concatenate_path_of_paths : Π {x y : G}, path_of_paths x y → path x y\n| ._ ._ (path_of_paths.nil X) := path.nil X\n| ._ ._ (@path_of_paths.cons ._ _ _ _ _ e p') := concatenate_paths e (concatenate_path_of_paths p')\n\nend category_theory.graphs\n", "meta": {"author": "semorrison", "repo": "lean-category-theory", "sha": "a27b4ae5eac978e9188d2e867c3d11d9a5b87a9e", "save_path": "github-repos/lean/semorrison-lean-category-theory", "path": "github-repos/lean/semorrison-lean-category-theory/lean-category-theory-a27b4ae5eac978e9188d2e867c3d11d9a5b87a9e/src/category_theory/graphs/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.4669235512641516}}
{"text": "import etv.defs\nimport etv.label\n\nopen_locale classical\nnoncomputable theory\n\nvariables \n  {α : Type*} [linear_order α] {C : config α} \n  {S : finset α} (l : C.label S)\n\nprivate lemma mem_imply_nnil \n  {α : Type*} (a : α) {l : list α} (ha : a ∈ l) : l ≠ [] := \n  by intro eq; subst eq; simp at ha; tauto\n\nnamespace config.label\n\ndef is_alpha_cup (a : α) (c : list α) : Prop :=\n  (c ++ [a]).in S ∧ (c ++ [a]).sorted (<) ∧ (c ++ [a]).chain' l.slopeᶜ\n\ninstance decidable_is_alpha_cup (a : α) (c : list α) :\n  decidable (l.is_alpha_cup a c) := by rw is_alpha_cup; apply_instance\n\ntheorem alpha_cup_is_cup (c : list α)\n  (c_in_S : c.in S) (c_sorted : c.sorted (<))\n  (c_chain : c.chain' l.slopeᶜ) : C.cup c :=\nbegin\n  induction c with h0 c ih, simp,\n  cases c with h1 c, simp,\n  cases c with h2 c,\n  { simp, simp at c_sorted, assumption, },\n  simp, refine ⟨_, _, _⟩,\n  simp at c_sorted; tauto,\n  simp at c_in_S c_chain c_sorted; apply l.extend_left; tauto,\n  apply ih; simp at ⊢ c_in_S c_chain c_sorted; tauto,\nend\n\ndef alpha_cups' (a : α) : list (list α) :=\n  (S.sort (≤)).sublists.filter (l.is_alpha_cup a)\n\ndef alpha_cup' (a : α) : option (list α) :=\n  (l.alpha_cups' a).argmax list.length\n\ndef alpha_cup'_is_some {a : α} (ha : a ∈ S) : \n  option.is_some (l.alpha_cup' a) :=\nbegin\n  rw [←option.ne_none_iff_is_some, config.label.alpha_cup'], simp,\n  apply mem_imply_nnil [], simp [is_alpha_cup, alpha_cups'], exact ha,\nend\n\n-- one off from actual definition\ndef alpha (a : α) : ℕ := \n  if ha : a ∈ S then (option.get (l.alpha_cup'_is_some ha)).length else 0\n\n-- APIs for alpha: First, existence of a cup with length alpha + 1\ndef alpha_cup {a : α} (ha : a ∈ S) : \n  Σ' c : list α, c.length = l.alpha a + 1 ∧ \n    c.in S ∧ c.sorted (<) ∧ c.chain' l.slopeᶜ ∧ a ∈ c.last' :=\nbegin\n  have some := l.alpha_cup'_is_some ha,\n  set c := option.get some with def_c, \n  rw alpha, rw dif_pos ha, rw ←def_c,\n  have h_argmax := option.get_mem some, \n  rw [←def_c, alpha_cup'] at h_argmax,\n  have c_alpha_cup := list.argmax_mem h_argmax,\n  simp [alpha_cups', is_alpha_cup] at c_alpha_cup,\n  use (c ++ [a]), simp, tauto,\nend\n\n-- Next, maximality of the cup with length alpha + 1\ndef cup_length_le_alpha {a : α} {c : list α}\n  (c_in_S : c.in S) \n  (c_sorted : c.sorted (<))\n  (c_chain : c.chain' l.slopeᶜ)\n  (c_last : a ∈ c.last') : c.length ≤ l.alpha a + 1 :=\nbegin\n  have ha : a ∈ S := c_in_S _ (list.mem_of_mem_last' c_last),\n  have some := l.alpha_cup'_is_some ha,\n  set d := option.get some with def_d, \n  rw alpha, rw dif_pos ha, rw ←def_d,\n  have h_argmax := option.get_mem some, \n  rw [←def_d, alpha_cup'] at h_argmax,\n  rcases list.take_last' c_last with ⟨c', eq_c⟩,\n  subst eq_c, simp,\n  have c'_alpha_cup : c' ∈ l.alpha_cups' a := begin\n    rw alpha_cups', simp, split,\n    { apply list.sublist_of_subperm_of_sorted _ _ \n        (finset.sort_sorted_lt S),\n      apply list.nodup.subperm,\n      apply @list.nodup.sublist _ _ (c' ++ [a]), \n      simp, exact (list.sorted.nodup c_sorted),\n      intros a ha, simp, simp at c_in_S, exact (c_in_S.left) _ ha,\n      apply list.pairwise.sublist _ c_sorted, simp, },\n    { refine ⟨_, _, _⟩; assumption },\n  end,\n  exact list.le_of_mem_argmax c'_alpha_cup h_argmax,\nend\n\ntheorem add_alpha {a : α} (ha : a ∈ S)\n  {n : ℕ} {c : list α} (c_in_S : c.in S)\n  (c_cup : C.ncup n c) (c_head : a ∈ c.head') : \n  C.has_ncup (n + l.alpha a) S :=\nbegin\n  rcases (l.alpha_cup ha) with \n    ⟨d, d_length, d_in_S, d_sorted, d_chain, d_last⟩,\n  have d_cup : C.cup d := l.alpha_cup_is_cup \n   _ d_in_S d_sorted d_chain,\n  rcases list.take_last' d_last with ⟨d', eq_d⟩,\n  rcases list.take_head' c_head with ⟨c', eq_c⟩,\n  use d' ++ a :: c', \n  by_cases hd' : d' = [],\n  { subst hd', simp at eq_d, subst eq_d, simp at d_length, rw d_length,\n    rw ←eq_c, split; simp; assumption, },\n  rcases list.take_last hd' with ⟨p, d'', eq_d'⟩,\n  cases c' with q c'',\n  { subst eq_c, cases c_cup with _ c_len, simp at c_len,\n    subst c_len, rw ←eq_d, refine ⟨⟨_, _⟩, _⟩,\n    assumption, rw d_length, exact add_comm _ _, assumption, },\n  rw eq_d', split, \n  { rw [config.ncup], split, simp, refine ⟨_, _, _⟩,\n    convert d_cup, rw [eq_d, eq_d'], simp,\n    rw eq_d' at eq_d, simp at eq_d, \n    rw eq_d at d_chain d_sorted d_in_S,\n    rw eq_c at c_in_S c_cup,\n    rw list.sorted at d_sorted,\n    rw [config.ncup, config.cup] at c_cup,\n    apply l.extend_left,\n    simp at d_in_S; tauto, simp at d_in_S; tauto,\n    have t := @list.pairwise.sublist \n      _ _ [p, a] (d'' ++ [p, a]) _ d_sorted,\n    simp at t, exact t, simp,\n    simp at d_chain; tauto,\n    simp at c_in_S; tauto,\n    simp at c_cup; tauto,\n    rw ←eq_c, exact c_cup.left,\n    rw eq_d at d_length, simp at d_length,\n    rw ←eq_c, rw ←eq_d', simp, rw d_length,\n    rw c_cup.right, exact add_comm _ _, },\n  { rw ←eq_c, rw ←eq_d', simp, rw eq_d at d_in_S,\n    simp at d_in_S, tauto, },\nend\n\nend config.label\n\nnamespace config\n\nvariables (C) (S)\n\ndef is_beta_cup (a : α) (c : list α) : Prop :=\n  (c ++ [a]).in S ∧ C.cup (c ++ [a])\n\ninstance decidable_is_beta_cup (a : α) (c : list α) :\n  decidable (C.is_beta_cup S a c) := by rw is_beta_cup; apply_instance\n\ndef beta_cups' (a : α) : list (list α) :=\n  (S.sort (≤)).sublists.filter (C.is_beta_cup S a)\n\ndef beta_cup' (a : α) : option (list α) :=\n  (C.beta_cups' S a).argmax list.length\n\ndef beta_cup'_is_some {a : α} (ha : a ∈ S) : \n  option.is_some (C.beta_cup' S a) :=\nbegin\n  rw ←option.ne_none_iff_is_some, rw config.beta_cup', simp,\n  apply mem_imply_nnil [], simp [is_beta_cup, beta_cups'], exact ha,\nend\n\n-- one off from actual definition\ndef beta (a : α) : ℕ := \n  if ha : a ∈ S then (option.get (C.beta_cup'_is_some S ha)).length else 0\n\n-- APIs for beta: First, existence of a cup with length alpha + 1\ndef beta_cup {a : α} (ha : a ∈ S) : \n  Σ' c : list α, c.in S ∧ C.ncup (C.beta S a + 1) c ∧ a ∈ c.last' :=\nbegin\n  have some := C.beta_cup'_is_some S ha,\n  set c := option.get some with def_c, \n  rw beta, rw dif_pos ha, rw ←def_c,\n  have h_argmax := option.get_mem some, \n  rw [←def_c, beta_cup'] at h_argmax,\n  have c_beta_cup := list.argmax_mem h_argmax,\n  simp [beta_cups', is_beta_cup] at c_beta_cup,\n  use (c ++ [a]), simp [config.ncup], tauto,\nend\n\ntheorem has_beta_cup {a : α} (ha : a ∈ S) :\n  C.has_ncup (C.beta S a + 1) S :=\nbegin\n  rcases C.beta_cup S ha with ⟨c, c_in, c_cup, -⟩,\n  use c, tauto,\nend\n\n-- Next, maximality of the cup with length alpha + 1\ndef cup_length_le_beta {a : α} {c : list α}\n  (c_in_S : c.in S) \n  (c_cup : C.cup c)\n  (c_last : a ∈ c.last') : c.length ≤ C.beta S a + 1 :=\nbegin\n  have ha : a ∈ S := c_in_S _ (list.mem_of_mem_last' c_last),\n  have some := C.beta_cup'_is_some S ha,\n  set d := option.get some with def_d, \n  rw beta, rw dif_pos ha, rw ←def_d,\n  have h_argmax := option.get_mem some, \n  rw [←def_d, beta_cup'] at h_argmax,\n  rcases list.take_last' c_last with ⟨c', eq_c⟩,\n  subst eq_c, simp,\n  have c_sorted := list.chain'_iff_pairwise.mp c_cup.left,\n  have c'_beta_cup : c' ∈ C.beta_cups' S a := begin\n    rw beta_cups', simp, split,\n    { apply list.sublist_of_subperm_of_sorted _ _ \n        (finset.sort_sorted_lt S),\n      apply list.nodup.subperm,\n      apply @list.nodup.sublist _ _ (c' ++ [a]), simp,\n      exact (list.sorted.nodup c_sorted),\n      intros a ha, simp, simp at c_in_S, exact (c_in_S.left) _ ha,\n      apply list.pairwise.sublist _ c_sorted, simp, },\n    { split; assumption },\n  end,\n  exact list.le_of_mem_argmax c'_beta_cup h_argmax,\nend\n\nend config\n\nvariables (l) {C}\n\ntheorem config.label.alpha_le_beta {a : α} (ha : a ∈ S) : \n  l.alpha a ≤ C.beta S a :=\nbegin\n  rcases (l.alpha_cup ha) with \n    ⟨c, c_length, c_in, c_sorted, c_chain, c_last⟩,\n  have c_cup := l.alpha_cup_is_cup _ c_in c_sorted c_chain,\n  have ineq := C.cup_length_le_beta S c_in c_cup c_last,\n  rw c_length at ineq, simp at ineq, exact ineq,\nend\n\nvariables {l}\n\ntheorem slope_ff_inc_alpha \n  {a b : α} (sab : ¬l.slope a b)\n  (ha : a ∈ S) (hb : b ∈ S) (a_le_b : a < b) : \n  l.alpha a < l.alpha b :=\nbegin\n  rcases (l.alpha_cup ha) with \n    ⟨c, c_length, c_in, c_sorted, c_chain, c_last⟩,\n  rcases list.take_last' c_last with ⟨c', c_eq⟩,\n  rw [nat.lt_iff_add_one_le, ←(add_le_add_iff_right 1)],\n  set d := c ++ [b] with def_d,\n  have d_length : d.length = l.alpha a + 1 + 1 :=\n    by simp [def_d, c_length],\n  rw ←d_length,\n  apply l.cup_length_le_alpha,\n  { rw def_d, simp, tauto, },\n  { rw [def_d, c_eq, list.sorted, ←list.chain'_iff_pairwise], \n    simp, rw [list.chain'_iff_pairwise, ←list.sorted],\n    rw ←c_eq, exact ⟨c_sorted, a_le_b⟩, },\n  { rw [def_d, c_eq], simp, rw ←c_eq,\n    exact ⟨c_chain, sab⟩, },\n  { rw def_d, simp, },\nend\n\ntheorem slope_tt_inc_beta\n  {a b : α} (sab : l.slope a b)\n  (ha : a ∈ S) (hb : b ∈ S) (a_le_b : a < b) : \n  C.beta S a < C.beta S b :=\nbegin\n  rcases (C.beta_cup S ha) with \n    ⟨c, c_in, ⟨c_cup, c_length⟩, c_last⟩,\n  rcases list.take_last' c_last with ⟨c', c_eq⟩,\n  rw [nat.lt_iff_add_one_le, ←(add_le_add_iff_right 1)],\n  set d := c ++ [b] with def_d,\n  have d_length : d.length = C.beta S a + 1 + 1 :=\n    by simp [def_d, c_length],\n  rw ←d_length,\n  apply C.cup_length_le_beta S; rw def_d,\n  simp, split; assumption,\n  apply c_cup.extend_right sab; try {simp}; try {assumption},\n  simp,\nend\n\nvariables (C)\n\ntheorem config.alpha_eq_beta_inc {a b : α} \n  (ha : a ∈ S) (hb : b ∈ S) (h : l.alpha a = l.alpha b) :\n  a < b ↔ C.beta S a < C.beta S b :=\nbegin\n  split, \n  { intro hab, \n    by_cases hl : l.slope a b, \n    apply slope_tt_inc_beta hl; assumption,\n    have h' := slope_ff_inc_alpha hl ha hb hab,\n    rw h at h', simp at h', exfalso, assumption, },\n  { intro hab,\n    rcases (lt_trichotomy a b) with a_lt_b | a_eq_b | b_lt_a,\n    exact a_lt_b, \n    subst a_eq_b, simp at hab, exfalso, assumption,\n    exfalso, by_cases hl : l.slope b a, \n    have h' := slope_tt_inc_beta hl hb ha b_lt_a,\n    have h'' := lt_trans h' hab, simp at h'', exact h'',\n    have h' := slope_ff_inc_alpha hl hb ha b_lt_a,\n    rw h at h', simp at h', exact h', },\nend\n\nvariables {C} (l)\n\ntheorem config.label.beta_eq_alpha_inc {a b : α} \n  (ha : a ∈ S) (hb : b ∈ S) (h : C.beta S a = C.beta S b) :\n  a < b ↔ l.alpha a < l.alpha b :=\nbegin\n  split, \n  { intro hab, \n    by_cases hl : l.slope a b, \n    have h' := slope_tt_inc_beta hl ha hb hab,\n    rw h at h', simp at h', exfalso, assumption,\n    apply slope_ff_inc_alpha hl; assumption, },\n  { intro hab,\n    rcases (lt_trichotomy a b) with a_lt_b | a_eq_b | b_lt_a,\n    exact a_lt_b, \n    subst a_eq_b, simp at hab, exfalso, assumption,\n    exfalso, by_cases hl : l.slope b a, \n    have h' := slope_tt_inc_beta hl hb ha b_lt_a,\n    rw h at h', simp at h', exact h',\n    have h' := slope_ff_inc_alpha hl hb ha b_lt_a,\n    have h'' := lt_trans h' hab, simp at h'', exact h'', },\nend", "meta": {"author": "jcpaik", "repo": "erdos-tuza-valtr", "sha": "7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef", "save_path": "github-repos/lean/jcpaik-erdos-tuza-valtr", "path": "github-repos/lean/jcpaik-erdos-tuza-valtr/erdos-tuza-valtr-7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef/src/etv/alpha_beta.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.46692354616290643}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.instances.real_vector_space\nimport Mathlib.analysis.normed_space.add_torsor\nimport Mathlib.linear_algebra.affine_space.midpoint\nimport Mathlib.analysis.normed_space.linear_isometry\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Mazur-Ulam Theorem\n\nMazur-Ulam theorem states that an isometric bijection between two normed affine spaces over `ℝ` is\naffine. We formalize it in three definitions:\n\n* `isometric.to_real_linear_isometry_equiv_of_map_zero` : given `E ≃ᵢ F` sending `0` to `0`,\n  returns `E ≃ₗᵢ[ℝ] F` with the same `to_fun` and `inv_fun`;\n* `isometric.to_real_linear_isometry_equiv` : given `f : E ≃ᵢ F`,\n  returns `g : E ≃ₗᵢ[ℝ] F` with `g x = f x - f 0`.\n* `isometric.to_affine_equiv` : given `PE ≃ᵢ PF`, returns `g : PE ≃ᵃ[ℝ] PF` with the same\n  `to_equiv`.\n\nThe formalization is based on [Jussi Väisälä, *A Proof of the Mazur-Ulam Theorem*][Vaisala_2003].\n\n## Tags\n\nisometry, affine map, linear map\n-/\n\nnamespace isometric\n\n\n/-- If an isometric self-homeomorphism of a normed vector space over `ℝ` fixes `x` and `y`,\nthen it fixes the midpoint of `[x, y]`. This is a lemma for a more general Mazur-Ulam theorem,\nsee below. -/\ntheorem midpoint_fixed {E : Type u_1} {PE : Type u_2} [normed_group E] [normed_space ℝ E] [metric_space PE] [normed_add_torsor E PE] {x : PE} {y : PE} (e : PE ≃ᵢ PE) : coe_fn e x = x → coe_fn e y = y → coe_fn e (midpoint ℝ x y) = midpoint ℝ x y := sorry\n\n/-- A bijective isometry sends midpoints to midpoints. -/\ntheorem map_midpoint {E : Type u_1} {PE : Type u_2} [normed_group E] [normed_space ℝ E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F] [normed_space ℝ F] [metric_space PF] [normed_add_torsor F PF] (f : PE ≃ᵢ PF) (x : PE) (y : PE) : coe_fn f (midpoint ℝ x y) = midpoint ℝ (coe_fn f x) (coe_fn f y) := sorry\n\n/-!\nSince `f : PE ≃ᵢ PF` sends midpoints to midpoints, it is an affine map.\nWe define a conversion to a `continuous_linear_equiv` first, then a conversion to an `affine_map`.\n-/\n\n/-- Mazur-Ulam Theorem: if `f` is an isometric bijection between two normed vector spaces\nover `ℝ` and `f 0 = 0`, then `f` is a linear equivalence. -/\ndef to_real_linear_isometry_equiv_of_map_zero {E : Type u_1} [normed_group E] [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (h0 : coe_fn f 0 = 0) : linear_isometry_equiv ℝ E F :=\n  linear_isometry_equiv.mk\n    (linear_equiv.mk\n      (linear_map.to_fun\n        (continuous_linear_map.to_linear_map\n          (add_monoid_hom.to_real_linear_map (add_monoid_hom.of_map_midpoint ℝ ℝ (⇑f) h0 sorry) sorry)))\n      sorry sorry (equiv.inv_fun (to_equiv f)) sorry sorry)\n    sorry\n\n@[simp] theorem coe_to_real_linear_equiv_of_map_zero {E : Type u_1} [normed_group E] [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (h0 : coe_fn f 0 = 0) : ⇑(to_real_linear_isometry_equiv_of_map_zero f h0) = ⇑f :=\n  rfl\n\n@[simp] theorem coe_to_real_linear_equiv_of_map_zero_symm {E : Type u_1} [normed_group E] [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (h0 : coe_fn f 0 = 0) : ⇑(linear_isometry_equiv.symm (to_real_linear_isometry_equiv_of_map_zero f h0)) = ⇑(isometric.symm f) :=\n  rfl\n\n/-- Mazur-Ulam Theorem: if `f` is an isometric bijection between two normed vector spaces\nover `ℝ`, then `x ↦ f x - f 0` is a linear equivalence. -/\ndef to_real_linear_isometry_equiv {E : Type u_1} [normed_group E] [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) : linear_isometry_equiv ℝ E F :=\n  to_real_linear_isometry_equiv_of_map_zero (isometric.trans f (isometric.symm (isometric.add_right (coe_fn f 0)))) sorry\n\n@[simp] theorem to_real_linear_equiv_apply {E : Type u_1} [normed_group E] [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (x : E) : coe_fn (to_real_linear_isometry_equiv f) x = coe_fn f x - coe_fn f 0 :=\n  Eq.symm (sub_eq_add_neg (coe_fn f x) (coe_fn f 0))\n\n@[simp] theorem to_real_linear_isometry_equiv_symm_apply {E : Type u_1} [normed_group E] [normed_space ℝ E] {F : Type u_3} [normed_group F] [normed_space ℝ F] (f : E ≃ᵢ F) (y : F) : coe_fn (linear_isometry_equiv.symm (to_real_linear_isometry_equiv f)) y = coe_fn (isometric.symm f) (y + coe_fn f 0) :=\n  rfl\n\n/-- Convert an isometric equivalence between two affine spaces to an `affine_map`. -/\ndef to_affine_equiv {E : Type u_1} {PE : Type u_2} [normed_group E] [normed_space ℝ E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F] [normed_space ℝ F] [metric_space PF] [normed_add_torsor F PF] (f : PE ≃ᵢ PF) : affine_equiv ℝ PE PF :=\n  affine_equiv.mk' (to_equiv f)\n    (linear_isometry_equiv.to_linear_equiv\n      (to_real_linear_isometry_equiv\n        (isometric.trans (vadd_const (classical.arbitrary PE))\n          (isometric.trans f (isometric.symm (vadd_const (coe_fn f (classical.arbitrary PE))))))))\n    (classical.arbitrary PE) sorry\n\n@[simp] theorem coe_to_affine_equiv {E : Type u_1} {PE : Type u_2} [normed_group E] [normed_space ℝ E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F] [normed_space ℝ F] [metric_space PF] [normed_add_torsor F PF] (f : PE ≃ᵢ PF) : ⇑(to_affine_equiv f) = ⇑f :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/mazur_ulam.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.63341026367784, "lm_q1q2_score": 0.4669235388478045}}
{"text": "import category_theory.abelian.ext\n\nimport for_mathlib.derived_functor\n\nnoncomputable theory\n\nuniverse variables uᵣ v u\n\nopen category_theory opposite\n\nnamespace Ext\n\nvariables (R : Type uᵣ) [ring R] {C : Type u} [category.{v} C] [abelian C] [linear R C]\n  [enough_projectives C]\n\nlocal notation `Ext` i `,` A `,` B := ((Ext R C i).obj (op A)).obj B\n\ndef δ (n : ℕ) (A : short_exact_sequence C) (B : C) :\n  (Ext n , A.1 , B) ⟶ (Ext (n+1) , A.3 , B) :=\nlet E  := (((linear_yoneda R C).obj B).right_op.left_derived n),\n    E' := (((linear_yoneda R C).obj B).right_op.left_derived (n+1)) in\nquiver.hom.unop (show E'.obj A.3 ⟶ E.obj A.1, from functor.left_derived.δ _ _ _)\n\nlemma six_term_exact_seq (n : ℕ) (A : short_exact_sequence C) (B : C) :\n  exact_seq (Module.{v} R) [\n    ((«Ext» R C n).map A.g.op).app B, ((«Ext» R C n).map A.f.op).app B,\n    δ R n A B,\n    ((«Ext» R C (n+1)).map A.g.op).app B, ((«Ext» R C (n+1)).map A.f.op).app B\n    ] :=\nbegin\n  apply exact_seq.of_op,\n  exact functor.left_derived.six_term_exact_seq _ n A,\nend\n\nend «Ext»\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/ext.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677506936878, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.46689728926829493}}
{"text": "import topology.subset_properties\nimport topology.homeomorph\n\nnamespace homeomorph\n\nvariables {α β : Type*} [topological_space α] [topological_space β]\n  (e : α ≃ₜ β) [totally_disconnected_space α]\n\ninclude e\n\n--TODO: Golf and add to mathlib\nprotected lemma totally_disconnected_space : totally_disconnected_space β :=\nbegin\n  constructor,\n  rintros A - hA,\n  suffices : (e.symm '' A).subsingleton,\n  { intros x hx y hy,\n    apply e.symm.injective,\n    apply this,\n    exact ⟨x, hx, rfl⟩,\n    exact ⟨y, hy, rfl⟩ },\n  obtain ⟨h⟩ := (infer_instance : totally_disconnected_space α),\n  apply h,\n  { tauto },\n  { exact is_preconnected.image hA _ e.symm.continuous.continuous_on }\nend\n\nend homeomorph\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/topology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031738057795403, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.46688741562420233}}
{"text": "import pseudo_normed_group.category\nimport data.set.intervals\nimport for_mathlib.Profinite.extend\nimport condensed.ab\n\n.\n\nopen_locale big_operators\n\nuniverse u\nvariable (S : Fintype.{u})\n\n@[derive add_comm_group]\ndef free_pfpng := S → ℤ\n\nnoncomputable theory\nopen_locale classical\n\ninstance : has_nnnorm (free_pfpng S) :=\n⟨λ f, ∑ s, ∥f s∥₊⟩\n\nnamespace free_pfpng\n\n@[simp] lemma nnnorm_zero : ∥(0 : free_pfpng S)∥₊ = 0 :=\nby { change ∑ _, _ = _, simp }\n\n@[simp] lemma nnnorm_neg (f : free_pfpng S) : ∥(-f)∥₊ = ∥f∥₊ :=\nby { change ∑ _, _ = _, simpa }\n\nlemma nnnorm_add (f₁ f₂ : free_pfpng S) : ∥f₁ + f₂∥₊ ≤ ∥f₁∥₊ + ∥f₂∥₊ :=\nbegin\n  change ∑ _, _ ≤ ∑ _, _ + ∑ _, _,\n  rw ← finset.sum_add_distrib,\n  apply finset.sum_le_sum,\n  intros s _,\n  apply nnnorm_add_le,\nend\n\ninstance (c) : topological_space { f : free_pfpng S | ∥f∥₊ ≤ c } := ⊥\ninstance (c) : discrete_topology { f : free_pfpng S | ∥f∥₊ ≤ c } := ⟨rfl⟩\n\nlemma norm_eval_le {c : nnreal} {s : S}\n  (f : free_pfpng S) (hf : ∥f∥₊ ≤ c) : ∥f s∥₊ ≤ c :=\nle_trans (begin\n  apply @finset.single_le_sum S nnreal _ (λ t, ∥f t∥₊) finset.univ,\n  { intros _ _, apply zero_le },\n  { exact finset.mem_univ s }\nend) hf\n\ninstance (c) : fintype { f : free_pfpng S | ∥f∥₊ ≤ c } :=\nbegin\n  let A := { f : free_pfpng S | ∥f∥₊ ≤ c },\n  have h : ∃ (N : ℕ), c ≤ N := ⟨nat.ceil c, nat.le_ceil c⟩,\n  let N := h.some, let hN : c ≤ N := h.some_spec,\n  let ι : A → S → set.Icc (-(N : ℤ)) N :=\n    λ a s, ⟨a.1 s, _, _⟩,\n  rotate,\n  { -- I'm sure there is a more efficient way to do this...\n    have : - ∥a.val s∥ ≤ a.val s := neg_abs_le_self ↑(a.val s),\n    replace this : - (c : ℝ) ≤ a.val s := le_trans _ this,\n    swap,\n    { simp only [subtype.val_eq_coe, neg_le_neg_iff],\n      exact_mod_cast (norm_eval_le S a.val a.2) },\n    replace this : -(N : ℝ) ≤ _ := le_trans _ this,\n    swap,\n    { rw [neg_le_neg_iff], exact_mod_cast hN },\n    exact_mod_cast this },\n  { have : ↑(a.val s) ≤ ∥a.val s∥ := le_max_left _ _,\n    replace this : ↑(a.val s) ≤ (c : ℝ) := le_trans this _,\n    swap, { exact_mod_cast (norm_eval_le S a.val a.2) },\n    replace this := le_trans this hN,\n    push_cast at this,\n    exact_mod_cast this },\n  have : function.injective ι,\n  { rintros ⟨f,hf⟩ ⟨g,hg⟩ h,\n    ext s,\n    apply_fun (λ e, (e s).1) at h,\n    assumption },\n  apply fintype.of_injective ι this,\nend\n\ninstance : profinitely_filtered_pseudo_normed_group (free_pfpng S) :=\n{ filtration := λ c, { f | ∥ f ∥₊ ≤ c },\n  filtration_mono := λ c₁ c₂ h f hf, le_trans hf h,\n  zero_mem_filtration := λ c, by simp,\n  neg_mem_filtration := λ c f hf, by simpa,\n  add_mem_filtration := λ c₁ c₂ f₁ f₂ h₁ h₂,\n    le_trans (nnnorm_add _ _ _) (add_le_add h₁ h₂),\n  continuous_add' := λ c₁ c₂,\n    continuous_of_discrete_topology,\n  continuous_neg' := λ c, continuous_of_discrete_topology,\n  continuous_cast_le := λ _ _ _, continuous_of_discrete_topology,\n  ..(infer_instance : add_comm_group (free_pfpng S)) }\n\ndef map {S₁ S₂ : Fintype.{u}} (g : S₁ ⟶ S₂) :\n  strict_comphaus_filtered_pseudo_normed_group_hom\n  (free_pfpng S₁) (free_pfpng S₂) :=\n{ to_fun := λ f s, ∑ t in finset.univ.filter (λ w, g w = s), f t,\n  map_zero' := by simpa,\n  map_add' := λ f g, by simpa [finset.sum_add_distrib],\n  strict' := begin\n    intros c f hf,\n    refine le_trans _ hf,\n    change ∑ s₂, ∥(∑ t in finset.univ.filter (λ w, g w = s₂), f t)∥₊ ≤\n      ∑ s₁, _,\n    have : ∑ s₂, ∥(∑ t in finset.univ.filter (λ w, g w = s₂), f t)∥₊ ≤\n      ∑ s₂ : S₂, ∑ t in finset.univ.filter (λ w, g w = s₂), ∥f t∥₊,\n    { apply finset.sum_le_sum,\n      intros i _,\n      apply nnnorm_sum_le },\n    refine le_trans this _,\n    rw ← finset.sum_bUnion,\n    apply le_of_eq,\n    apply finset.sum_congr,\n    { rw finset.eq_univ_iff_forall,\n      intros x,\n      rw finset.mem_bUnion,\n      use [g x, by simp] },\n    { intros s₁ _, refl },\n    { intros x _ y _ h,\n      rintros a hh,\n      apply h,\n      simp only [finset.inf_eq_inter, finset.mem_inter, finset.mem_filter,\n        finset.mem_univ, true_and] at hh,\n      rw [← hh.1, ← hh.2] }\n  end,\n  continuous' := λ c, continuous_of_discrete_topology }\n\n@[simp]\nlemma map_id : map (𝟙 S) =\n  strict_comphaus_filtered_pseudo_normed_group_hom.id :=\nbegin\n  ext s,\n  dsimp [map],\n  simp [finset.filter_congr_decidable, finset.sum_filter],\nend\n\n@[simp]\nlemma map_comp {S₁ S₂ S₃ : Fintype.{u}}\n  (g₁ : S₁ ⟶ S₂) (g₂ : S₂ ⟶ S₃) :\n  map (g₁ ≫ g₂) =\n  (map g₂).comp (map g₁) :=\nbegin\n  ext s₃,\n  dsimp [map],\n  erw ← finset.sum_bUnion,\n  apply finset.sum_congr,\n  { ext s,\n    split,\n    { intro h, simp only [finset.mem_filter, finset.mem_univ, true_and] at h,\n      rw finset.mem_bUnion,\n      use [g₁ s, by simpa] },\n    { intro h, simp only [finset.mem_bUnion, finset.mem_filter,\n      finset.mem_univ, true_and, exists_prop, exists_eq_right'] at h,\n      simpa, } },\n  { intros s₁ h,\n    rw finset.mem_bUnion at h },\n  { intros x hx y hy,\n    simp only [finset.coe_filter, finset.coe_univ, set.sep_univ,\n      set.mem_set_of_eq] at hx hy,\n    intros h a ha,\n    simp only [finset.inf_eq_inter, finset.mem_inter, finset.mem_filter,\n      finset.mem_univ, true_and] at ha,\n    apply h, rw [← ha.1, ← ha.2] }\nend\n\nend free_pfpng\n\n@[simps]\ndef free_pfpng_functor : Fintype ⥤ ProFiltPseuNormGrp₁ :=\n{ obj := λ S,\n  { M := free_pfpng S,\n    exhaustive' := λ f, ⟨∥f∥₊, le_refl _⟩ },\n  map := λ S₁ S₂ f, free_pfpng.map f,\n  map_id' := free_pfpng.map_id,\n  map_comp' := λ _ _ _ g₁ g₂, free_pfpng.map_comp g₁ g₂ }\n\ndef Fintype.free_pfpng (T : Fintype) : ProFiltPseuNormGrp₁ :=\nfree_pfpng_functor.obj T\n\ndef Fintype.free_pfpng_unit :\n  Fintype.to_Profinite ⟶ free_pfpng_functor ⋙ ProFiltPseuNormGrp₁.level.obj 1 :=\n{ app := λ S,\n  { to_fun := λ s,\n    { val := λ t, if s = t then 1 else 0,\n      property := begin\n        show finset.sum _ _ ≤ _,\n        rw finset.sum_eq_single_of_mem,\n        swap 4, { exact s }, swap 2, { apply finset.mem_univ },\n        { dsimp, rw [if_pos rfl, nnnorm_one], },\n        rintro t - ht, dsimp, rw [if_neg ht.symm, nnnorm_zero],\n      end },\n    continuous_to_fun := continuous_bot },\n  naturality' := λ S T f, begin\n    ext s t,\n    delta ProFiltPseuNormGrp₁.level,\n    simp only [Fintype.to_Profinite_map_apply, Profinite.coe_comp, continuous_map.coe_mk,\n      function.comp_app, subtype.coe_mk, category_theory.functor.comp_map, free_pfpng_functor_map,\n      pseudo_normed_group.level_coe, subtype.coe_mk, free_pfpng.map, finset.mem_filter, true_and,\n      finset.mem_univ, strict_comphaus_filtered_pseudo_normed_group_hom.coe_mk, finset.sum_ite_eq],\n  end }\n\ndef Profinite.free_pfpng (S : Profinite) : ProFiltPseuNormGrp₁ :=\n(Profinite.extend free_pfpng_functor).obj S\n\nopen category_theory\nopen category_theory.limits\n\ndef Profinite.free_pfpng_level_iso (S : Profinite.{u}) (r) :\n  (ProFiltPseuNormGrp₁.level.obj r).obj S.free_pfpng ≅\n  limits.limit (S.fintype_diagram ⋙ free_pfpng_functor ⋙ ProFiltPseuNormGrp₁.level.obj r) :=\n(is_limit_of_preserves (ProFiltPseuNormGrp₁.level.obj r)\n  (limit.is_limit _)).cone_point_unique_up_to_iso $ limit.is_limit _\n\ndef Profinite.to_free_pfpng (S : Profinite.{u}) :\n  S ⟶ (ProFiltPseuNormGrp₁.level.obj 1).obj S.free_pfpng :=\n(limit.is_limit _).map S.as_limit_cone (whisker_left _ $ Fintype.free_pfpng_unit.{u u}) ≫\n(S.free_pfpng_level_iso 1).inv\n\n--(limits.is_limit_of_preserves (ProFiltPseuNormGrp₁.level.obj 1) (limits.limit.is_limit _)).map\n--  S.as_limit_cone $ whisker_left _ (Fintype.free_pfpng_unit) ≫ (functor.associator _ _ _).inv\n\ndef Profinite.free_pfpng_π (S : Profinite) (T : discrete_quotient S) :\n  S.free_pfpng ⟶ (Fintype.of T).free_pfpng :=\ncategory_theory.limits.limit.π _ _\n\nlemma Profinite.free_pfpng_π_w (S : Profinite) {T₁ T₂ : discrete_quotient S} (f : T₁ ⟶ T₂) :\n  Profinite.free_pfpng_π S T₁ ≫ (S.fintype_diagram ⋙ free_pfpng_functor).map f =\n  Profinite.free_pfpng_π S T₂ :=\ncategory_theory.limits.limit.w (S.fintype_diagram ⋙ free_pfpng_functor) _\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/free_pfpng/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738010682209, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4668874128854977}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Bhavik Mehta\n-/\nimport category_theory.structured_arrow\nimport category_theory.punit\nimport category_theory.reflects_isomorphisms\nimport category_theory.epi_mono\n\n/-!\n# Over and under categories\n\nOver (and under) categories are special cases of comma categories.\n* If `L` is the identity functor and `R` is a constant functor, then `comma L R` is the \"slice\" or\n  \"over\" category over the object `R` maps to.\n* Conversely, if `L` is a constant functor and `R` is the identity functor, then `comma L R` is the\n  \"coslice\" or \"under\" category under the object `L` maps to.\n\n## Tags\n\ncomma, slice, coslice, over, under\n-/\n\nnamespace category_theory\n\nuniverses v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u₁} [category.{v₁} T]\n\n/--\nThe over category has as objects arrows in `T` with codomain `X` and as morphisms commutative\ntriangles.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\n@[derive category]\ndef over (X : T) := costructured_arrow (𝟭 T) X\n\n-- Satisfying the inhabited linter\ninstance over.inhabited [inhabited T] : inhabited (over (default T)) :=\n{ default :=\n  { left := default T,\n    hom := 𝟙 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U ⟶ V}\n  (h : f.left = g.left) : f = g :=\nby tidy\n\n@[simp] lemma over_right (U : over X) : U.right = punit.star := by tidy\n\n@[simp] lemma id_left (U : over X) : comma_morphism.left (𝟙 U) = 𝟙 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).left = f.left ≫ g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A ⟶ B) : f.left ≫ B.hom = A.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/\n@[simps]\ndef mk {X Y : T} (f : Y ⟶ X) : over X :=\ncostructured_arrow.mk f\n\n/-- We can set up a coercion from arrows with codomain `X` to `over X`. This most likely should not\n    be a global instance, but it is sometimes useful. -/\ndef coe_from_hom {X Y : T} : has_coe (Y ⟶ X) (over X) :=\n{ coe := mk }\n\nsection\nlocal attribute [instance] coe_from_hom\n\n@[simp] lemma coe_hom {X Y : T} (f : Y ⟶ X) : (f : over X).hom = f := rfl\nend\n\n/-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative\n    triangle. -/\n@[simps]\ndef hom_mk {U V : over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom . obviously) :\n  U ⟶ V :=\ncostructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\n@[simps]\ndef iso_mk {f g : over X} (hl : f.left ≅ g.left) (hw : hl.hom ≫ g.hom = f.hom . obviously) :\n  f ≅ g :=\ncostructured_arrow.iso_mk hl hw\n\nsection\nvariable (X)\n/--\nThe forgetful functor mapping an arrow to its domain.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef forget : over X ⥤ T := comma.fst _ _\n\nend\n\n@[simp] lemma forget_obj {U : over X} : (forget X).obj U = U.left := rfl\n@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : (forget X).map f = f.left := rfl\n\n/--\nA morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef map {Y : T} (f : X ⟶ Y) : over X ⥤ over Y := comma.map_right _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : over X} {g : U ⟶ V}\n@[simp] lemma map_obj_left : ((map f).obj U).left = U.left := rfl\n@[simp] lemma map_obj_hom  : ((map f).obj U).hom  = U.hom ≫ f := rfl\n@[simp] lemma map_map_left : ((map f).map g).left = g.left := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map f ⋙ map g :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := λ Y Z f t, by exactI\n  ⟨⟨over.hom_mk (inv ((forget X).map f))\n      ((as_iso ((forget X).map f)).inv_comp_eq.2 (over.w f).symm),\n    by tidy⟩⟩ }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\n/--\nIf `k.left` is an epimorphism, then `k` is an epimorphism. In other words, `over.forget X` reflects\nepimorphisms.\nThe converse does not hold without additional assumptions on the underlying category.\n-/\n-- TODO: Show the converse holds if `T` has binary products or pushouts.\nlemma epi_of_epi_left {f g : over X} (k : f ⟶ g) [hk : epi k.left] : epi k :=\nfaithful_reflects_epi (forget X) hk\n\n/--\nIf `k.left` is a monomorphism, then `k` is a monomorphism. In other words, `over.forget X` reflects\nmonomorphisms.\nThe converse of `category_theory.over.mono_left_of_mono`.\n\nThis lemma is not an instance, to avoid loops in type class inference.\n-/\nlemma mono_of_mono_left {f g : over X} (k : f ⟶ g) [hk : mono k.left] : mono k :=\nfaithful_reflects_mono (forget X) hk\n\n/--\nIf `k` is a monomorphism, then `k.left` is a monomorphism. In other words, `over.forget X` preserves\nmonomorphisms.\nThe converse of `category_theory.over.mono_of_mono_left`.\n-/\ninstance mono_left_of_mono {f g : over X} (k : f ⟶ g) [mono k] : mono k.left :=\nbegin\n  refine ⟨λ (Y : T) l m a, _⟩,\n  let l' : mk (m ≫ f.hom) ⟶ f := hom_mk l (by { dsimp, rw [←over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw ← cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y ⟶ X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f ⥤ over f.left :=\n{ obj := λ α, over.mk α.hom.left,\n  map := λ α β κ, over.hom_mk κ.left.left (by { rw auto_param_eq, rw ← over.w κ, refl }) }\n\n/-- Given f : Y ⟶ X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left ⥤ over f :=\n{ obj := λ g, mk (hom_mk g.hom : mk (g.hom ≫ f.hom) ⟶ f),\n  map := λ g h α, hom_mk (hom_mk α.left (w_assoc α f.hom)) (over_morphism.ext (w α)) }\n\n/-- Given f : Y ⟶ X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f ≌ over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (iso.refl _) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f ⋙ forget f.left = forget f ⋙ forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f ⋙ forget f ⋙ forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `over X ⥤ over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T ⥤ D) : over X ⥤ over (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { left := F.map f.left,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend over\n\n/-- The under category has as objects arrows with domain `X` and as morphisms commutative\n    triangles. -/\n@[derive category]\ndef under (X : T) := structured_arrow X (𝟭 T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default T)) :=\n{ default :=\n  { right := default T,\n    hom := 𝟙 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U ⟶ V}\n  (h : f.right = g.right) : f = g :=\nby tidy\n\n@[simp] lemma under_left (U : under X) : U.left = punit.star := by tidy\n\n@[simp] lemma id_right (U : under X) : comma_morphism.right (𝟙 U) = 𝟙 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).right = f.right ≫ g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A ⟶ B) : A.hom ≫ f.right = B.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/\n@[simps]\ndef mk {X Y : T} (f : X ⟶ Y) : under X :=\nstructured_arrow.mk f\n\n/-- To give a morphism in the under category, it suffices to give a morphism fitting in a\n    commutative triangle. -/\n@[simps]\ndef hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom . obviously) :\n  U ⟶ V :=\nstructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\ndef iso_mk {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) : f ≅ g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).hom.right = hr.hom := rfl\n\n@[simp]\nlemma iso_mk_inv_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).inv.right = hr.inv := rfl\n\nsection\nvariables (X)\n/-- The forgetful functor mapping an arrow to its domain. -/\ndef forget : under X ⥤ T := comma.snd _ _\n\nend\n\n@[simp] lemma forget_obj {U : under X} : (forget X).obj U = U.right := rfl\n@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : (forget X).map f = f.right := rfl\n\n/-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/\ndef map {Y : T} (f : X ⟶ Y) : under Y ⥤ under X := comma.map_left _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : under Y} {g : U ⟶ V}\n@[simp] lemma map_obj_right : ((map f).obj U).right = U.right := rfl\n@[simp] lemma map_obj_hom   : ((map f).obj U).hom   = f ≫ U.hom := rfl\n@[simp] lemma map_map_right : ((map f).map g).right = g.right := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `under X ⥤ under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T ⥤ D) : under X ⥤ under (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { right := F.map f.right,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend under\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/over.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.709019146082187, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4668306140138124}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.enriched.basic\n! leanprover-community/mathlib commit c3019c79074b0619edb4b27553a91b2e82242395\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Monoidal.Types\nimport Mathbin.CategoryTheory.Monoidal.Center\nimport Mathbin.Tactic.ApplyFun\n\n/-!\n# Enriched categories\n\nWe set up the basic theory of `V`-enriched categories,\nfor `V` an arbitrary monoidal category.\n\nWe do not assume here that `V` is a concrete category,\nso there does not need to be a \"honest\" underlying category!\n\nUse `X ⟶[V] Y` to obtain the `V` object of morphisms from `X` to `Y`.\n\nThis file contains the definitions of `V`-enriched categories and\n`V`-functors.\n\nWe don't yet define the `V`-object of natural transformations\nbetween a pair of `V`-functors (this requires limits in `V`),\nbut we do provide a presheaf isomorphic to the Yoneda embedding of this object.\n\nWe verify that when `V = Type v`, all these notion reduce to the usual ones.\n-/\n\n\nuniverse w v u₁ u₂ u₃\n\nnoncomputable section\n\nnamespace CategoryTheory\n\nopen Opposite\n\nopen MonoidalCategory\n\nvariable (V : Type v) [Category.{w} V] [MonoidalCategory V]\n\n/- ./././Mathport/Syntax/Translate/Command.lean:401:24: unsupported: (notation) in structure -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr ⟶[] » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr ⟶[] » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr ⟶[] » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr ⟶[] » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr ⟶[] » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `«expr ⟶[] » -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- A `V`-category is a category enriched in a monoidal category `V`.\n\nNote that we do not assume that `V` is a concrete category,\nso there may not be an \"honest\" underlying category at all!\n-/\nclass EnrichedCategory (C : Type u₁) where\n  Hom : C → C → V\n  id : ∀ X, 𝟙_ V ⟶ «expr ⟶[] » X X\n  comp : ∀ X Y Z, «expr ⟶[] » X Y ⊗ «expr ⟶[] » Y Z ⟶ «expr ⟶[] » X Z\n  id_comp : ∀ X Y, (λ_ («expr ⟶[] » X Y)).inv ≫ (id X ⊗ 𝟙 _) ≫ comp X X Y = 𝟙 _ := by obviously\n  comp_id : ∀ X Y, (ρ_ («expr ⟶[] » X Y)).inv ≫ (𝟙 _ ⊗ id Y) ≫ comp X Y Y = 𝟙 _ := by obviously\n  and_assoc :\n    ∀ W X Y Z,\n      (α_ _ _ _).inv ≫ (comp W X Y ⊗ 𝟙 _) ≫ comp W Y Z = (𝟙 _ ⊗ comp X Y Z) ≫ comp W X Z := by\n    obviously\n#align category_theory.enriched_category CategoryTheory.EnrichedCategory\n\n-- mathport name: enriched_category.hom\nnotation X \" ⟶[\" V \"] \" Y:10 => (EnrichedCategory.hom X Y : V)\n\nvariable (V) {C : Type u₁} [EnrichedCategory V C]\n\n/-- The `𝟙_ V`-shaped generalized element giving the identity in a `V`-enriched category.\n-/\ndef eId (X : C) : 𝟙_ V ⟶ X ⟶[V] X :=\n  EnrichedCategory.id X\n#align category_theory.e_id CategoryTheory.eId\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- The composition `V`-morphism for a `V`-enriched category.\n-/\ndef eComp (X Y Z : C) : ((X ⟶[V] Y) ⊗ Y ⟶[V] Z) ⟶ X ⟶[V] Z :=\n  EnrichedCategory.comp X Y Z\n#align category_theory.e_comp CategoryTheory.eComp\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n-- We don't just use `restate_axiom` here; that would leave `V` as an implicit argument.\n@[simp, reassoc.1]\ntheorem eId_comp (X Y : C) : (λ_ (X ⟶[V] Y)).inv ≫ (eId V X ⊗ 𝟙 _) ≫ eComp V X X Y = 𝟙 (X ⟶[V] Y) :=\n  EnrichedCategory.id_comp X Y\n#align category_theory.e_id_comp CategoryTheory.eId_comp\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp, reassoc.1]\ntheorem eComp_id (X Y : C) : (ρ_ (X ⟶[V] Y)).inv ≫ (𝟙 _ ⊗ eId V Y) ≫ eComp V X Y Y = 𝟙 (X ⟶[V] Y) :=\n  EnrichedCategory.comp_id X Y\n#align category_theory.e_comp_id CategoryTheory.eComp_id\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp, reassoc.1]\ntheorem e_assoc (W X Y Z : C) :\n    (α_ _ _ _).inv ≫ (eComp V W X Y ⊗ 𝟙 _) ≫ eComp V W Y Z =\n      (𝟙 _ ⊗ eComp V X Y Z) ≫ eComp V W X Z :=\n  EnrichedCategory.assoc W X Y Z\n#align category_theory.e_assoc CategoryTheory.e_assoc\n\nsection\n\nvariable {V} {W : Type v} [Category.{w} W] [MonoidalCategory W]\n\n/-- A type synonym for `C`, which should come equipped with a `V`-enriched category structure.\nIn a moment we will equip this with the `W`-enriched category structure\nobtained by applying the functor `F : lax_monoidal_functor V W` to each hom object.\n-/\n@[nolint has_nonempty_instance unused_arguments]\ndef TransportEnrichment (F : LaxMonoidalFunctor V W) (C : Type u₁) :=\n  C\n#align category_theory.transport_enrichment CategoryTheory.TransportEnrichment\n\ninstance (F : LaxMonoidalFunctor V W) : EnrichedCategory W (TransportEnrichment F C)\n    where\n  Hom := fun X Y : C => F.obj (X ⟶[V] Y)\n  id := fun X : C => F.ε ≫ F.map (eId V X)\n  comp := fun X Y Z : C => F.μ _ _ ≫ F.map (eComp V X Y Z)\n  id_comp X Y := by\n    rw [comp_tensor_id, category.assoc, ← F.to_functor.map_id, F.μ_natural_assoc,\n      F.to_functor.map_id, F.left_unitality_inv_assoc, ← F.to_functor.map_comp, ←\n      F.to_functor.map_comp, e_id_comp, F.to_functor.map_id]\n  comp_id X Y := by\n    rw [id_tensor_comp, category.assoc, ← F.to_functor.map_id, F.μ_natural_assoc,\n      F.to_functor.map_id, F.right_unitality_inv_assoc, ← F.to_functor.map_comp, ←\n      F.to_functor.map_comp, e_comp_id, F.to_functor.map_id]\n  and_assoc P Q R S := by\n    rw [comp_tensor_id, category.assoc, ← F.to_functor.map_id, F.μ_natural_assoc,\n      F.to_functor.map_id, ← F.associativity_inv_assoc, ← F.to_functor.map_comp, ←\n      F.to_functor.map_comp, e_assoc, id_tensor_comp, category.assoc, ← F.to_functor.map_id,\n      F.μ_natural_assoc, F.to_functor.map_comp]\n\nend\n\n/-- Construct an honest category from a `Type v`-enriched category.\n-/\ndef categoryOfEnrichedCategoryType (C : Type u₁) [𝒞 : EnrichedCategory (Type v) C] : Category.{v} C\n    where\n  Hom := 𝒞.Hom\n  id X := eId (Type v) X PUnit.unit\n  comp X Y Z f g := eComp (Type v) X Y Z ⟨f, g⟩\n  id_comp' X Y f := congr_fun (eId_comp (Type v) X Y) f\n  comp_id' X Y f := congr_fun (eComp_id (Type v) X Y) f\n  assoc' W X Y Z f g h := (congr_fun (e_assoc (Type v) W X Y Z) ⟨f, g, h⟩ : _)\n#align category_theory.category_of_enriched_category_Type CategoryTheory.categoryOfEnrichedCategoryType\n\n/-- Construct a `Type v`-enriched category from an honest category.\n-/\ndef enrichedCategoryTypeOfCategory (C : Type u₁) [𝒞 : Category.{v} C] : EnrichedCategory (Type v) C\n    where\n  Hom := 𝒞.Hom\n  id X p := 𝟙 X\n  comp X Y Z p := p.1 ≫ p.2\n  id_comp X Y := by\n    ext\n    simp\n  comp_id X Y := by\n    ext\n    simp\n  and_assoc W X Y Z := by\n    ext ⟨f, g, h⟩\n    simp\n#align category_theory.enriched_category_Type_of_category CategoryTheory.enrichedCategoryTypeOfCategory\n\n/-- We verify that an enriched category in `Type u` is just the same thing as an honest category.\n-/\ndef enrichedCategoryTypeEquivCategory (C : Type u₁) : EnrichedCategory (Type v) C ≃ Category.{v} C\n    where\n  toFun 𝒞 := category_of_enriched_category_Type C\n  invFun 𝒞 := enriched_category_Type_of_category C\n  left_inv 𝒞 := by\n    cases 𝒞\n    dsimp [enriched_category_Type_of_category]\n    congr\n    · ext (X⟨⟩)\n      rfl\n    · ext (X Y Z⟨f, g⟩)\n      rfl\n  right_inv 𝒞 := by\n    rcases 𝒞 with @⟨@⟨⟨⟩⟩⟩\n    dsimp\n    congr\n#align category_theory.enriched_category_Type_equiv_category CategoryTheory.enrichedCategoryTypeEquivCategory\n\nsection\n\nvariable {W : Type (v + 1)} [Category.{v} W] [MonoidalCategory W] [EnrichedCategory W C]\n\n/-- A type synonym for `C`, which should come equipped with a `V`-enriched category structure.\nIn a moment we will equip this with the (honest) category structure\nso that `X ⟶ Y` is `(𝟙_ W) ⟶ (X ⟶[W] Y)`.\n\nWe obtain this category by\ntransporting the enrichment in `V` along the lax monoidal functor `coyoneda_tensor_unit`,\nthen using the equivalence of `Type`-enriched categories with honest categories.\n\nThis is sometimes called the \"underlying\" category of an enriched category,\nalthough some care is needed as the functor `coyoneda_tensor_unit`,\nwhich always exists, does not necessarily coincide with\n\"the forgetful functor\" from `V` to `Type`, if such exists.\nWhen `V` is any of `Type`, `Top`, `AddCommGroup`, or `Module R`,\n`coyoneda_tensor_unit` is just the usual forgetful functor, however.\nFor `V = Algebra R`, the usual forgetful functor is coyoneda of `R[X]`, not of `R`.\n(Perhaps we should have a typeclass for this situation: `concrete_monoidal`?)\n-/\n@[nolint has_nonempty_instance unused_arguments]\ndef ForgetEnrichment (W : Type (v + 1)) [Category.{v} W] [MonoidalCategory W] (C : Type u₁)\n    [EnrichedCategory W C] :=\n  C\n#align category_theory.forget_enrichment CategoryTheory.ForgetEnrichment\n\nvariable (W)\n\n/-- Typecheck an object of `C` as an object of `forget_enrichment W C`. -/\ndef ForgetEnrichment.of (X : C) : ForgetEnrichment W C :=\n  X\n#align category_theory.forget_enrichment.of CategoryTheory.ForgetEnrichment.of\n\n/-- Typecheck an object of `forget_enrichment W C` as an object of `C`. -/\ndef ForgetEnrichment.to (X : ForgetEnrichment W C) : C :=\n  X\n#align category_theory.forget_enrichment.to CategoryTheory.ForgetEnrichment.to\n\n@[simp]\ntheorem ForgetEnrichment.to_of (X : C) : ForgetEnrichment.to W (ForgetEnrichment.of W X) = X :=\n  rfl\n#align category_theory.forget_enrichment.to_of CategoryTheory.ForgetEnrichment.to_of\n\n@[simp]\ntheorem ForgetEnrichment.of_to (X : ForgetEnrichment W C) :\n    ForgetEnrichment.of W (ForgetEnrichment.to W X) = X :=\n  rfl\n#align category_theory.forget_enrichment.of_to CategoryTheory.ForgetEnrichment.of_to\n\ninstance categoryForgetEnrichment : Category (ForgetEnrichment W C) :=\n  by\n  let I : enriched_category (Type v) (transport_enrichment (coyoneda_tensor_unit W) C) :=\n    inferInstance\n  exact enriched_category_Type_equiv_category C I\n#align category_theory.category_forget_enrichment CategoryTheory.categoryForgetEnrichment\n\n/-- We verify that the morphism types in `forget_enrichment W C` are `(𝟙_ W) ⟶ (X ⟶[W] Y)`.\n-/\nexample (X Y : ForgetEnrichment W C) :\n    (X ⟶ Y) = (𝟙_ W ⟶ ForgetEnrichment.to W X ⟶[W] ForgetEnrichment.to W Y) :=\n  rfl\n\n/-- Typecheck a `(𝟙_ W)`-shaped `W`-morphism as a morphism in `forget_enrichment W C`. -/\ndef ForgetEnrichment.homOf {X Y : C} (f : 𝟙_ W ⟶ X ⟶[W] Y) :\n    ForgetEnrichment.of W X ⟶ ForgetEnrichment.of W Y :=\n  f\n#align category_theory.forget_enrichment.hom_of CategoryTheory.ForgetEnrichment.homOf\n\n/-- Typecheck a morphism in `forget_enrichment W C` as a `(𝟙_ W)`-shaped `W`-morphism. -/\ndef ForgetEnrichment.homTo {X Y : ForgetEnrichment W C} (f : X ⟶ Y) :\n    𝟙_ W ⟶ ForgetEnrichment.to W X ⟶[W] ForgetEnrichment.to W Y :=\n  f\n#align category_theory.forget_enrichment.hom_to CategoryTheory.ForgetEnrichment.homTo\n\n@[simp]\ntheorem ForgetEnrichment.homTo_homOf {X Y : C} (f : 𝟙_ W ⟶ X ⟶[W] Y) :\n    ForgetEnrichment.homTo W (ForgetEnrichment.homOf W f) = f :=\n  rfl\n#align category_theory.forget_enrichment.hom_to_hom_of CategoryTheory.ForgetEnrichment.homTo_homOf\n\n@[simp]\ntheorem ForgetEnrichment.homOf_homTo {X Y : ForgetEnrichment W C} (f : X ⟶ Y) :\n    ForgetEnrichment.homOf W (ForgetEnrichment.homTo W f) = f :=\n  rfl\n#align category_theory.forget_enrichment.hom_of_hom_to CategoryTheory.ForgetEnrichment.homOf_homTo\n\n/-- The identity in the \"underlying\" category of an enriched category. -/\n@[simp]\ntheorem forgetEnrichment_id (X : ForgetEnrichment W C) :\n    ForgetEnrichment.homTo W (𝟙 X) = eId W (ForgetEnrichment.to W X : C) :=\n  Category.id_comp _\n#align category_theory.forget_enrichment_id CategoryTheory.forgetEnrichment_id\n\n@[simp]\ntheorem forgetEnrichment_id' (X : C) :\n    ForgetEnrichment.homOf W (eId W X) = 𝟙 (ForgetEnrichment.of W X : C) :=\n  (forgetEnrichment_id W (ForgetEnrichment.of W X)).symm\n#align category_theory.forget_enrichment_id' CategoryTheory.forgetEnrichment_id'\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Composition in the \"underlying\" category of an enriched category. -/\n@[simp]\ntheorem forgetEnrichment_comp {X Y Z : ForgetEnrichment W C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n    ForgetEnrichment.homTo W (f ≫ g) =\n      ((λ_ (𝟙_ W)).inv ≫ (ForgetEnrichment.homTo W f ⊗ ForgetEnrichment.homTo W g)) ≫\n        eComp W _ _ _ :=\n  rfl\n#align category_theory.forget_enrichment_comp CategoryTheory.forgetEnrichment_comp\n\nend\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- A `V`-functor `F` between `V`-enriched categories\nhas a `V`-morphism from `X ⟶[V] Y` to `F.obj X ⟶[V] F.obj Y`,\nsatisfying the usual axioms.\n-/\nstructure EnrichedFunctor (C : Type u₁) [EnrichedCategory V C] (D : Type u₂)\n  [EnrichedCategory V D] where\n  obj : C → D\n  map : ∀ X Y : C, (X ⟶[V] Y) ⟶ obj X ⟶[V] obj Y\n  map_id' : ∀ X : C, eId V X ≫ map X X = eId V (obj X) := by obviously\n  map_comp' :\n    ∀ X Y Z : C,\n      eComp V X Y Z ≫ map X Z = (map X Y ⊗ map Y Z) ≫ eComp V (obj X) (obj Y) (obj Z) := by\n    obviously\n#align category_theory.enriched_functor CategoryTheory.EnrichedFunctor\n\nrestate_axiom enriched_functor.map_id'\n\nrestate_axiom enriched_functor.map_comp'\n\nattribute [simp, reassoc.1] enriched_functor.map_id\n\nattribute [simp, reassoc.1] enriched_functor.map_comp\n\n/-- The identity enriched functor. -/\n@[simps]\ndef EnrichedFunctor.id (C : Type u₁) [EnrichedCategory V C] : EnrichedFunctor V C C\n    where\n  obj X := X\n  map X Y := 𝟙 _\n#align category_theory.enriched_functor.id CategoryTheory.EnrichedFunctor.id\n\ninstance : Inhabited (EnrichedFunctor V C C) :=\n  ⟨EnrichedFunctor.id V C⟩\n\n/-- Composition of enriched functors. -/\n@[simps]\ndef EnrichedFunctor.comp {C : Type u₁} {D : Type u₂} {E : Type u₃} [EnrichedCategory V C]\n    [EnrichedCategory V D] [EnrichedCategory V E] (F : EnrichedFunctor V C D)\n    (G : EnrichedFunctor V D E) : EnrichedFunctor V C E\n    where\n  obj X := G.obj (F.obj X)\n  map X Y := F.map _ _ ≫ G.map _ _\n#align category_theory.enriched_functor.comp CategoryTheory.EnrichedFunctor.comp\n\nsection\n\nvariable {W : Type (v + 1)} [Category.{v} W] [MonoidalCategory W]\n\n/-- An enriched functor induces an honest functor of the underlying categories,\nby mapping the `(𝟙_ W)`-shaped morphisms.\n-/\ndef EnrichedFunctor.forget {C : Type u₁} {D : Type u₂} [EnrichedCategory W C] [EnrichedCategory W D]\n    (F : EnrichedFunctor W C D) : ForgetEnrichment W C ⥤ ForgetEnrichment W D\n    where\n  obj X := ForgetEnrichment.of W (F.obj (ForgetEnrichment.to W X))\n  map X Y f :=\n    ForgetEnrichment.homOf W\n      (ForgetEnrichment.homTo W f ≫ F.map (ForgetEnrichment.to W X) (ForgetEnrichment.to W Y))\n  map_comp' X Y Z f g := by\n    dsimp\n    apply_fun forget_enrichment.hom_to W\n    · simp only [iso.cancel_iso_inv_left, category.assoc, tensor_comp,\n        forget_enrichment.hom_to_hom_of, enriched_functor.map_comp, forget_enrichment_comp]\n      rfl\n    · intro f g w\n      apply_fun forget_enrichment.hom_of W  at w\n      simpa using w\n#align category_theory.enriched_functor.forget CategoryTheory.EnrichedFunctor.forget\n\nend\n\nsection\n\nvariable {V}\n\nvariable {D : Type u₂} [EnrichedCategory V D]\n\n/-!\nWe now turn to natural transformations between `V`-functors.\n\nThe mostly commonly encountered definition of an enriched natural transformation\nis a collection of morphisms\n```\n(𝟙_ W) ⟶ (F.obj X ⟶[V] G.obj X)\n```\nsatisfying an appropriate analogue of the naturality square.\n(c.f. https://ncatlab.org/nlab/show/enriched+natural+transformation)\n\nThis is the same thing as a natural transformation `F.forget ⟶ G.forget`.\n\nWe formalize this as `enriched_nat_trans F G`, which is a `Type`.\n\nHowever, there's also something much nicer: with appropriate additional hypotheses,\nthere is a `V`-object `enriched_nat_trans_obj F G` which contains more information,\nand from which one can recover `enriched_nat_trans F G ≃ (𝟙_ V) ⟶ enriched_nat_trans_obj F G`.\n\nUsing these as the hom-objects, we can build a `V`-enriched category\nwith objects the `V`-functors.\n\nFor `enriched_nat_trans_obj` to exist, it suffices to have `V` braided and complete.\n\nBefore assuming `V` is complete, we assume it is braided and\ndefine a presheaf `enriched_nat_trans_yoneda F G`\nwhich is isomorphic to the Yoneda embedding of `enriched_nat_trans_obj F G`\nwhether or not that object actually exists.\n\nThis presheaf has components `(enriched_nat_trans_yoneda F G).obj A`\nwhat we call the `A`-graded enriched natural transformations,\nwhich are collections of morphisms\n```\nA ⟶ (F.obj X ⟶[V] G.obj X)\n```\nsatisfying a similar analogue of the naturality square,\nthis time incorporating a half-braiding on `A`.\n\n(We actually define `enriched_nat_trans F G`\nas the special case `A := 𝟙_ V` with the trivial half-braiding,\nand when defining `enriched_nat_trans_yoneda F G` we use the half-braidings\ncoming from the ambient braiding on `V`.)\n-/\n\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- The type of `A`-graded natural transformations between `V`-functors `F` and `G`.\nThis is the type of morphisms in `V` from `A` to the `V`-object of natural transformations.\n-/\n@[ext, nolint has_nonempty_instance]\nstructure GradedNatTrans (A : Center V) (F G : EnrichedFunctor V C D) where\n  app : ∀ X : C, A.1 ⟶ F.obj X ⟶[V] G.obj X\n  naturality :\n    ∀ X Y : C,\n      (A.2.β (X ⟶[V] Y)).Hom ≫ (F.map X Y ⊗ app Y) ≫ eComp V _ _ _ =\n        (app X ⊗ G.map X Y) ≫ eComp V _ _ _\n#align category_theory.graded_nat_trans CategoryTheory.GradedNatTrans\n\nvariable [BraidedCategory V]\n\nopen BraidedCategory\n\n/-- A presheaf isomorphic to the Yoneda embedding of\nthe `V`-object of natural transformations from `F` to `G`.\n-/\n@[simps]\ndef enrichedNatTransYoneda (F G : EnrichedFunctor V C D) : Vᵒᵖ ⥤ Type max u₁ w\n    where\n  obj A := GradedNatTrans ((Center.ofBraided V).obj (unop A)) F G\n  map A A' f σ :=\n    { app := fun X => f.unop ≫ σ.app X\n      naturality := fun X Y => by\n        have p := σ.naturality X Y\n        dsimp at p⊢\n        rw [← id_tensor_comp_tensor_id (f.unop ≫ σ.app Y) _, id_tensor_comp, category.assoc,\n          category.assoc, ← braiding_naturality_assoc, id_tensor_comp_tensor_id_assoc, p, ←\n          tensor_comp_assoc, category.id_comp] }\n#align category_theory.enriched_nat_trans_yoneda CategoryTheory.enrichedNatTransYoneda\n\n-- TODO assuming `[has_limits C]` construct the actual object of natural transformations\n-- and show that the functor category is `V`-enriched.\nend\n\nsection\n\nattribute [local instance] category_of_enriched_category_Type\n\n/-- We verify that an enriched functor between `Type v` enriched categories\nis just the same thing as an honest functor.\n-/\n@[simps]\ndef enrichedFunctorTypeEquivFunctor {C : Type u₁} [𝒞 : EnrichedCategory (Type v) C] {D : Type u₂}\n    [𝒟 : EnrichedCategory (Type v) D] : EnrichedFunctor (Type v) C D ≃ C ⥤ D\n    where\n  toFun F :=\n    { obj := fun X => F.obj X\n      map := fun X Y f => F.map X Y f\n      map_id' := fun X => congr_fun (F.map_id X) PUnit.unit\n      map_comp' := fun X Y Z f g => congr_fun (F.map_comp X Y Z) ⟨f, g⟩ }\n  invFun F :=\n    { obj := fun X => F.obj X\n      map := fun X Y f => F.map f\n      map_id' := fun X => by\n        ext ⟨⟩\n        exact F.map_id X\n      map_comp' := fun X Y Z => by\n        ext ⟨f, g⟩\n        exact F.map_comp f g }\n  left_inv F := by\n    cases F\n    simp\n  right_inv F := by\n    cases F\n    simp\n#align category_theory.enriched_functor_Type_equiv_functor CategoryTheory.enrichedFunctorTypeEquivFunctor\n\n/-- We verify that the presheaf representing natural transformations\nbetween `Type v`-enriched functors is actually represented by\nthe usual type of natural transformations!\n-/\ndef enrichedNatTransYonedaTypeIsoYonedaNatTrans {C : Type v} [EnrichedCategory (Type v) C]\n    {D : Type v} [EnrichedCategory (Type v) D] (F G : EnrichedFunctor (Type v) C D) :\n    enrichedNatTransYoneda F G ≅\n      yoneda.obj (enrichedFunctorTypeEquivFunctor F ⟶ enrichedFunctorTypeEquivFunctor G) :=\n  NatIso.ofComponents\n    (fun α =>\n      { Hom := fun σ x =>\n          { app := fun X => σ.app X x\n            naturality' := fun X Y f => congr_fun (σ.naturality X Y) ⟨x, f⟩ }\n        inv := fun σ =>\n          { app := fun X x => (σ x).app X\n            naturality := fun X Y => by\n              ext ⟨x, f⟩\n              exact (σ x).naturality f } })\n    (by tidy)\n#align category_theory.enriched_nat_trans_yoneda_Type_iso_yoneda_nat_trans CategoryTheory.enrichedNatTransYonedaTypeIsoYonedaNatTrans\n\nend\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Enriched/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.46683061066950365}}
{"text": "import tactic \nimport measure_theory.integration\nimport measure_theory.measurable_space\n\nnoncomputable theory\nopen set \nopen classical\nopen measure_theory\nopen measurable_space\nopen_locale ennreal\n\n\n\nnamespace cond_exp\n\n\n\ndef is_subsigmaalg {S : Type*} (Γ₁ Γ₂ : measurable_space S ) : Prop :=\n  ∀ (E : set S ) , (Γ₁.is_measurable' E) → (Γ₂.is_measurable' E)\n\nlemma is_subsigmaalg_iff_le {S : Type*} {Γ₁ Γ₂ : measurable_space S } :\n  is_subsigmaalg Γ₁ Γ₂ ↔ Γ₁ ≤ Γ₂ :=\nbegin\n  split ,\n  { intros hsub E hE ,\n    exact hsub E hE , } ,\n  { intros hle E hE ,\n    exact hle E hE , } ,\nend\n\n@[simp]\nlemma self_is_subsigmaalg {S : Type*} (Γ : measurable_space S ) :\n  is_subsigmaalg Γ Γ := by { intros E hE , exact hE , }\n\n@[simp]\nlemma self_le_self_sigmaalg {S : Type*} (Γ : measurable_space S ) :\n  Γ ≤ Γ := by { intros E hE , exact hE , }\n\nlemma self_is_subsigmaalg' {S : Type*} (Γ : measurable_space S ) :\n  is_subsigmaalg Γ Γ :=\nbegin\n  have key : Γ ≤ Γ ,\n  { intros E hE ,\n    exact hE , } , \n  rwa is_subsigmaalg_iff_le ,\nend\n\ndef is_trivial_sigmaalg {S : Type*} (Γ : measurable_space S ) : Prop :=\n  ∀ (E : set S ) , (Γ.is_measurable' E) → (E = ∅ ∨ E = univ) \n\n@[simp]\nlemma trivial_is_subsigmaalg {S : Type*}\n  (Γtriv Γ : measurable_space S ) [htriv : is_trivial_sigmaalg Γtriv] :\n  is_subsigmaalg Γtriv Γ :=\nbegin\n  intros E hE , \n  have key := htriv E hE ,\n  cases key with hemp huniv ,\n  { rw hemp ,\n    exact measurable_space.is_measurable_empty Γ , } , \n  { rw huniv ,\n    have mbleuniv := (Γ.is_measurable_compl ∅ Γ.is_measurable_empty) ,\n    simp at mbleuniv ,\n    exact mbleuniv , } ,\nend\n\n@[simp]\nlemma trivial_le_sigmaalg {S : Type*}\n  (Γtriv Γ : measurable_space S ) [htriv : is_trivial_sigmaalg Γtriv] :\n  Γtriv ≤ Γ :=\nbegin\n  have key := ( @trivial_is_subsigmaalg S Γtriv Γ htriv ) ,\n  rw ← is_subsigmaalg_iff_le ,\n  exact key ,\nend\n\nlemma mble_of_submble {S T : Type*} [measurable_space T] (f : S → T)\n  (Γsub Γfull : measurable_space S ) [hsub : Γsub ≤ Γfull] :\n  (@measurable S T Γsub _ f) → (@measurable S T Γfull _ f) :=\nbegin\n  intros hf B hB ,\n  exact hsub (f⁻¹' B) (hf hB) ,\nend\n\nstructure cond_exp_enn {S : Type*} (f : S → ennreal)\n  (Γsub Γfull : measurable_space S ) [hsub : Γsub ≤ Γfull]\n  (μ : @measure_theory.measure S Γfull) :=\n  -- In the current version I am not requiring measurability\n  --     [hf : @measurable S ennreal Γfull _ f]\n  -- and integrability. I even failed to state integrability,\n  -- the following does not work:\n  --     [hintble : measure_theory.has_finite_integral f μ]\n  -- Also I'm not requiring that the measure is a\n  -- probability measure.\n  --     [hproba : probability_measure μ]\n  -- All of these would almost always\n  -- be needed, so should they be a part of the definition?\n    ( to_fun : S → ennreal )\n    ( is_submeasurable : @measurable S ennreal Γsub _ to_fun )\n    ( equal_subintegrals : ∀ (E : set S) , Γsub.is_measurable' E →\n        ∫⁻ x in E , to_fun(x) ∂ μ = ∫⁻ x in E , f(x) ∂ μ )\n\n\n\n-- Of course there should be a coercion to function,\n-- just pick the `to_fun`! Somehow, I did not manage to\n-- make this work at all...\n@[instance]\ndef cond_exp_enn.has_coe_to_fun {S : Type*} \n  {Γsub Γfull : measurable_space S} [hsub : is_subsigmaalg Γsub Γfull]\n  {f : S → ennreal} {μ : @measure_theory.measure S Γfull} :\n  has_coe_to_fun (@cond_exp_enn S f Γsub Γfull hsub μ)  :=\n{ coe := sorry ,\n  F := sorry ,\n}\n\n\nlemma cond_exp_enn_full {S : Type*} \n  {Γ : measurable_space S}\n  {f : S → ennreal} [hf : @measurable S ennreal Γ _ f]\n  {μ : @measure_theory.measure S Γ} :\n  @cond_exp_enn S f Γ Γ (self_le_self_sigmaalg Γ) μ :=\n{ to_fun := f ,\n  is_submeasurable := hf ,\n  equal_subintegrals := by { intros E hE , refl , } ,\n}\n\nlemma cond_exp_enn_trivial {S : Type*} \n  {Γtriv Γ : measurable_space S} [htriv  : is_trivial_sigmaalg Γtriv]\n  {f : S → ennreal} [hf : @measurable S ennreal Γ _ f]\n  {μ : @measure_theory.measure S Γ} [hproba : probability_measure μ] :\n  @cond_exp_enn S f Γtriv Γ (@trivial_le_sigmaalg S Γtriv Γ htriv) μ :=\n{ to_fun := ( λ (z : S) , ( ∫⁻ x , f(x) ∂ μ ) ) ,\n  is_submeasurable := by simp , \n  equal_subintegrals :=\n  begin\n    intros E hE ,\n    have key := htriv E hE ,\n    cases key with hemp huniv ,\n    { rw hemp ,\n      simp , } , \n    { rw huniv ,\n      simp ,\n      rw hproba.measure_univ ,\n      simp , } , \n  end\n}\n\n\n\nend cond_exp\n", "meta": {"author": "kkytola", "repo": "lean-questions", "sha": "9a7ded8036534575b682e28ddfed4c2f1089959d", "save_path": "github-repos/lean/kkytola-lean-questions", "path": "github-repos/lean/kkytola-lean-questions/lean-questions-9a7ded8036534575b682e28ddfed4c2f1089959d/cond_exp-question-20210401.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.46683060591719067}}
{"text": "lemma mul_comm (a b : mynat) : a * b = b * a :=\nbegin\ninduction b with k Pk,\nrw zero_mul, rw mul_zero, refl, \nrw mul_succ, rw succ_mul, rw Pk, refl,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/3-multiplication-world/l8.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191214879992, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.4668306025728816}}
{"text": "import to_product\nimport sugar_yoneda\nimport category_theory.limits.limits\nimport category_theory.limits.shapes\nuniverses v u   \nopen Product_stuff\nopen Yoneda \nopen category_theory\nopen category_theory.limits\nopen category_theory.category\n/-\nThe goal is define group obj in a category.\n          reference : Douady : Algebre et théories galoisiennes page 45\n          exemple : in the category of presheaf.\n          in Ring ? Idem ?\n     contexte : 𝒞 a un objet final et a les produit finis !\nPour coder μ X × X ⟶ X  We see that has X ⟶ T cospan f f)\n\n-/\n-- notation         f ` ⊗ `:20 g :20 := category_theory.limits.prod.map f g\n-- notation         `T`C :20 := (terminal C)\n-- notation         `T`X : 20 := (terminal.from X)\n-- notation         f ` | `:20 g :20 :=  prod.lift f g\n/-!\n#     notations : \n#         T C       :  C           (objet terminal) \n#         (f | g)   :  Z ⟶ X ⨯ Y  \n#         T X       :  X ⟶ T C\n#         (f ⊗ g)  :  Z1 ⨯ Z2 ⟶ X1 ⨯ X2 \n!-/\n\nstructure group_obj (C : Type u)[ 𝒞 : category.{v} C ] [ (has_binary_products.{v} C) ] [ (has_terminal.{v} C) ] :=\n(X : C)\n(μ : X ⨯ X ⟶ X)\n(inv : X ⟶ X)\n(ε :  T C ⟶ X)\n(hyp_one_mul  :  (T X | 𝟙 X) ≫ (ε ⊗ 𝟙 X) ≫  μ  = 𝟙 X)\n(hyp_mul_one  :  (𝟙 X | T X) ≫ ( 𝟙 X ⊗ ε) ≫ μ  = 𝟙 X)\n(hyp_inv_mul  :  (inv | 𝟙 X) ≫  μ = (T X) ≫ ε )\n(hyp_assoc    :  (μ ⊗ 𝟙 X) ≫ (μ) = (prod.associator X X X).hom ≫ (𝟙 X ⊗ μ)  ≫ μ )   -- (a *b) * c = (a * (b * c))\n\nvariables (C : Type u)\nvariables [𝒞 : category.{v} C]\nvariables  [has_binary_products.{v} C][has_terminal.{v} C]\ninclude 𝒞\ninstance coee : has_coe (group_obj C) C := ⟨λ F, F.X⟩ --- ?\nvariables (G : group_obj C)\ninclude G\n-- we start by rewriting a little \nlemma mul_one' : (𝟙 G.X | T G.X) ≫ ( 𝟙 G.X ⊗ G.ε) ≫ G.μ  = (𝟙 G.X  | (T G.X) ≫ G.ε) ≫ G.μ :=\nbegin\n     rw ← assoc,\n     rw prod.prod_comp_otimes,\n     rw comp_id,\nend\nlemma one_mul' : (T G.X | 𝟙 G.X) ≫ (G.ε ⊗ 𝟙 G.X) ≫  G.μ  = ((T G.X) ≫ G.ε | 𝟙 G.X) ≫ G.μ := \nbegin \n     rw ← assoc,\n     rw prod.prod_comp_otimes,\n     rw comp_id,\nend \nlemma one_mul_R (R A : C) (ζ : R⟦G.X⟧ ): R < ((T G.X) ≫ G.ε | 𝟙 G.X) ≫ G.μ > ζ  =  ζ :=\n begin \n     rw ← one_mul',\n     rw G.hyp_one_mul,\n     rw Yoneda.id,exact rfl,\nend\nlemma mul_one_R (R A : C) (ζ : R⟦G.X⟧ ): R < ( 𝟙 G.X | (T G.X) ≫ G.ε ) ≫ G.μ > ζ  =  ζ := \nbegin\n     rw ← mul_one', rw G.hyp_mul_one,rw Yoneda.id,\n     exact rfl, \n end\ndef one   (R : C) : R ⟦(G.X) ⟧  :=  \nbegin                                   ---- ici l'unité est R<ε> (T G.X) l'image du terminal \n     exact (terminal.from R ≫ G.ε),\nend\ndef mul (R : C) : R⟦ G.X⟧   → R⟦ G.X⟧  → R ⟦ G.X ⟧  :=  λ g1 g2, \nbegin \n     let φ := ( g1 | g2),\n     let β := (R< (G.μ) > : R⟦ G.X ⨯ G.X⟧  ⟶ R⟦G.X⟧),\n     exact β φ,\nend\nvariables (R : C)\ninclude R\ninstance yoneda_mul : has_mul (R⟦ G.X⟧) := ⟨mul C G R ⟩ \ninstance yoneda_one : has_one (R⟦ G.X⟧) := ⟨one C G R ⟩\n@[PRODUCT]lemma mul_comp (a b : R ⟦ G.X⟧ ) : a * b = (R < G.μ >) (a | b) := rfl -- priority R < g.μ > (a | b) not ()\n@[PRODUCT]lemma one_comp :  (1 : R ⟦ G.X ⟧) = terminal.from R ≫ G.ε := rfl\n\nnotation Y `⟶•`  := T Y \n@[PRODUCT]lemma Terminal_comp{Y : C} ( a : R ⟶ Y) : a ≫ (Y ⟶•) = (R ⟶•) := \nby exact subsingleton.elim (a ≫ T Y) (T R)\n\nlemma one_mulf' (ζ  : R⟦G.X ⟧) :    1 * ζ  = ζ  := begin\n     rw mul_comp,rw one_comp, --- (T X | 𝟙 X) ≫ (ε ⊗ 𝟙 X) ≫  μ  = 𝟙 X)\n     let V := one_mul_R C G R R ζ,\n     rw [Yoneda.apply_to_composition, ← assoc,prod.left_composition,comp_id\n     ,← assoc,Terminal_comp,Yoneda.composition_to_apply] at V,\n     exact V,\n     use G,\nend\nlemma mul_onef'(ζ : R⟦G.X ⟧)  : ζ * 1 = ζ := begin \n     rw mul_comp,rw one_comp,\n     have V := mul_one_R C G R R ζ,\n     rw [Yoneda.apply_to_composition, ← assoc,prod.left_composition,comp_id,← assoc\n     ,Terminal_comp,Yoneda.composition_to_apply] at V,\n     exact V,\n     use G,\nend \ndef inv' (R :C) : R⟦ G.X⟧ → R⟦ G.X⟧   := λ  ζ, begin \n     exact R<G.inv> ζ, \nend\ninstance yoneda_inv (R :C) : has_inv (R⟦G.X⟧) := ⟨inv' C G R⟩\nlemma  inv_comp (ζ : R ⟦ G.X⟧ ) : ζ⁻¹  =  (R<G.inv>) ζ  := rfl\nlemma mul_left_inv' (ζ : R ⟦ G.X ⟧) : (ζ⁻¹ * ζ ) = 1 :=  begin \n     rw inv_comp,rw mul_comp,rw one_comp,\n      rw Yoneda.apply_to_composition,\n     have V : R< (G.inv | 𝟙 G.X )   ≫  G.μ> ζ = (R<(T G.X) ≫ G.ε>) ζ ,\n          rw G.hyp_inv_mul,\n     rw [Yoneda.apply_to_composition,Yoneda.apply_to_composition,\n     ← assoc,prod.left_composition,comp_id,← assoc,Terminal_comp,Yoneda.composition_to_apply] at V,\n     assumption, use G, \nend\nlemma Grall (a b c : R ⟦G.X ⟧) : R < (prod.associator G.X G.X G.X).hom ≫ (𝟙 G.X ⊗ G.μ) ≫ G.μ> (a | b | c) \n     =(R < G.μ>) (a | (R < G.μ> (b | c))) := begin \n     tidy,\n     rw [Yoneda.apply_to_composition, ← assoc,prod.left_composition,\n     ← assoc,prod.prod_comp_otimes,Yoneda.apply_to_composition,Yoneda.apply_to_composition],\n     rw comp_id,\n     rw [← assoc,prod.left_composition,prod.lift_fst,prod.lift_fst,\n     prod.lift_snd,← assoc,prod.lift_fst,prod.lift_snd],\nend \n-- (hyp_mul_inv  :  (inv | 𝟙 X ) ≫  μ = (T X) ≫ ε )\nlemma mul_assoc' (a b c : R ⟦G.X ⟧) : a * b *c = a * ( b * c ) := begin \n     iterate 4 { rw mul_comp}, PRODUCT_CAT,\n     have ASSOC : R<((G.μ ⊗ (𝟙 G.X)) ≫ (G.μ)) >(a | b | c) = (R<(prod.associator G.X G.X G.X).hom ≫ (𝟙 G.X ⊗ G.μ)  ≫ G.μ>) (a | b | c),\n          rw G.hyp_assoc,\n     rw [Yoneda.apply_to_composition,← assoc,prod.prod_comp_otimes,comp_id,\n     ← Yoneda.apply_to_composition, ← Yoneda.apply_to_composition] at ASSOC,\n     have G_hyp : R < (prod.associator G.X G.X G.X).hom ≫ (𝟙 G.X ⊗ G.μ) ≫ G.μ> (a | b | c) \n     =(R < G.μ>) (a | (R < G.μ> (b | c))),\n          exact Grall C G R a b c ,\n       rw G_hyp at ASSOC,assumption,\n     -- R<(prod.associator G.X G.X G.X).hom ≫ (𝟙 G.X ⊗ G.μ)  ≫ G.μ> (a | b | c),\n\nend\n\ninstance : group (R⟦G.X⟧) :=  \n{    \n     mul := has_mul.mul,\n     mul_assoc := mul_assoc' C G R,\n     one    := (1 : R⟦ G.X⟧),\n     mul_one := mul_onef' C G R,\n     one_mul := one_mulf' C G R,\n     inv  := inv' C G R,\n     mul_left_inv := mul_left_inv' C G R,\n} ", "meta": {"author": "Or7ando", "repo": "lean", "sha": "d41169cf4e416a0d42092fb6bdc14131cee9dd15", "save_path": "github-repos/lean/Or7ando-lean", "path": "github-repos/lean/Or7ando-lean/lean-d41169cf4e416a0d42092fb6bdc14131cee9dd15/.github/workflows/group_objet.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.46680584478517173}}
{"text": "/- -----------------------------------------------------------------------\nPullbacks and pushouts.\n----------------------------------------------------------------------- -/\n\nimport .s1_limits\nimport .s2_products\n\nnamespace qp\n\nopen stdaux\n\nuniverse variables ℓobjx ℓhomx ℓobj ℓhom ℓobj₁ ℓhom₁ ℓobj₂ ℓhom₂\n\n\n\n/- -----------------------------------------------------------------------\nPullbacks.\n----------------------------------------------------------------------- -/\n\n/-! #brief Homs in a cospan category.\n-/\ninductive CoSpanHom (N : ℕ) : option (fin N) → option (fin N) → Type\n| id : ∀ (x : option (fin N)), CoSpanHom x x\n| hom : ∀ (n : fin N), CoSpanHom (some n) none\n\n/-! #brief A cospan category.\n-/\ndefinition CoSpanCat (N : ℕ) : Cat.{0 1}\n:= { obj := option (fin N)\n   , hom := CoSpanHom N\n   , id := CoSpanHom.id\n   , circ := λ x y z g f, begin cases f, { exact g }, { cases g, apply CoSpanHom.hom } end\n   , circ_assoc := λ x y z w h g f, begin cases f, { trivial }, { cases g, trivial } end\n   , circ_id_left := λ x y f, begin cases f, { trivial }, { trivial } end\n   , circ_id_right := λ x y f, begin cases f, { trivial }, { trivial } end\n   }\n\n/-! #brief Functor which forgets the base hom.\n-/\ndefinition CoSpanCat.forget_base (N : ℕ)\n    : Fun (CoSpanCat N) (CoSpanCat (nat.succ N))\n:= { obj := λ n, option.cases_on n option.none (λ n', option.some (stdaux.fin.add n' 1))\n   , hom := λ x y f\n            , begin\n                cases f,\n                { apply CoSpanHom.id },\n                { apply CoSpanHom.hom }\n              end\n   , hom_id := λ x, rfl\n   , hom_circ := λ x y z g f\n                 , begin\n                     cases f,\n                     { trivial },\n                     { cases g, trivial }\n                   end\n   }\n\n/-! #brief A cospan diagram.\n-/\ndefinition PullbackDrgm (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    : Fun (CoSpanCat (list.length factor)) C\n:= { obj := λ a, option.cases_on a t (list.get factor)\n   , hom := λ a₁ a₂ f, begin cases f, { apply C^.id }, { exact HomsIn.get maps n } end\n   , hom_id := λ a, rfl\n   , hom_circ := λ a₁ a₂ a₃ g f\n                 , begin\n                     cases f,\n                     { apply eq.symm C^.circ_id_right },\n                     { cases g, apply eq.symm C^.circ_id_left }\n                   end\n   }\n\n/-! #brief Every functor out of CoSpanCat is a PullbackDrgm.\n-/\ndefinition PullbackDrgm.mk_doms {C : Cat.{ℓobj ℓhom}}\n    : ∀ {N : ℕ}\n        (F : Fun (CoSpanCat N) C)\n      , list C^.obj\n| 0 F := []\n| (nat.succ N) F := (F^.obj (some (fin_of 0))) :: @PullbackDrgm.mk_doms N (F □□ CoSpanCat.forget_base N)\n\n/-! #brief Every functor out of CoSpanCat is a PullbackDrgm.\n-/\ntheorem PullbackDrgm.length_mk_doms {C : Cat.{ℓobj ℓhom}}\n    : ∀ {N : ℕ}\n        (F : Fun (CoSpanCat N) C)\n      , list.length (PullbackDrgm.mk_doms F) = N\n| 0 F := rfl\n| (nat.succ N) F := congr_arg nat.succ (@PullbackDrgm.length_mk_doms N (F □□ CoSpanCat.forget_base N))\n\n/-! #brief Every functor out of CoSpanCat is a PullbackDrgm.\n-/\ndefinition PullbackDrgm.mk_homs {C : Cat.{ℓobj ℓhom}}\n    : ∀ {N : ℕ}\n        (F : Fun (CoSpanCat N) C)\n      , @HomsIn C (PullbackDrgm.mk_doms F) (F^.obj none)\n| 0 F := HomsIn.nil\n| (nat.succ N) F\n:= HomsIn.cons (F^.hom (CoSpanHom.hom (fin_of 0)))\n               (@PullbackDrgm.mk_homs N (F □□ CoSpanCat.forget_base N))\n\n/-! #brief Every functor out of CoSpanCat is a PullbackDrgm.\n-/\ntheorem PullbackDrgm.uniq {C : Cat.{ℓobj ℓhom}}\n    {N : ℕ}\n    (F : Fun (CoSpanCat N) C)\n    : PullbackDrgm C (PullbackDrgm.mk_homs F) == F\n:= begin\n     apply Fun.heq,\n     { exact congr_arg CoSpanCat (PullbackDrgm.length_mk_doms F) },\n     { trivial },\n     { intros n₁ n₂ ωn,\n       dsimp [PullbackDrgm],\n       cases n₁ with n₁ ωn₁,\n       { cases n₂ with n₂ ωn₂,\n         { trivial },\n         { exact sorry } -- TODO\n       },\n       { cases n₂ with n₂ ωn₂,\n         { exact sorry }, -- TODO\n         { exact sorry } -- TODO\n       } \n     },\n     { intros x₁ y₁ x₂ y₂ f₁ f₂ ωf,\n       cases f₁,\n       { cases f₂,\n         { exact sorry }, -- TODO\n         { exact sorry } -- TODO\n       },\n       { cases f₂,\n         { exact sorry }, -- TODO\n         { exact sorry } -- TODO\n       }\n     }\n   end\n\n/-! #brief A cone over a pullback.\n-/\ndefinition PullbackCone (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    : Type (max ℓobj ℓhom)\n:= Cone (PullbackDrgm C maps)\n\n/-! #brief Helper for making a pullback cone.\n-/\ndefinition PullbackCone.mk {C : Cat.{ℓobj ℓhom}}\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    (c : C^.obj)\n    (to_t : C^.hom c t)\n    (proj : HomsOut c factor)\n    (ωproj : HomsList.repeat to_t (list.length factor)\n              = homs_in_comp_out maps proj)\n    : PullbackCone C maps\n:= { obj := c\n   , hom := λ x, option.cases_on x to_t (HomsOut.get proj)\n   , comm := λ x₁ x₂ f, begin\n                         cases f,\n                         { exact eq.symm C^.circ_id_left },\n                         { unfold PullbackDrgm,\n                           apply eq_of_heq,\n                           refine heq.trans (heq.symm (HomsList.get_repeat to_t n)) _,\n                           refine heq.trans _ (get_homs_in_comp_out maps proj),\n                           rw ωproj\n                         }\n                       end\n   }\n\n/-! #brief The projections out of a pullback cone.\n-/\ndefinition PullbackCone.Proj {C : Cat.{ℓobj ℓhom}}\n    {factor : list C^.obj} {t : C^.obj}\n    {maps : HomsIn factor t}\n    (cone : PullbackCone C maps)\n    : HomsOut cone^.obj factor\n:= sorry -- HomsOut.enum (Cone.hom cone)\n\n/-! #brief A pullback in a category.\n-/\n@[class] definition HasPullback (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n:= HasLimit (PullbackDrgm C maps)\n\ninstance HasPullback.HasLimit {C : Cat.{ℓobj ℓhom}}\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    : HasLimit (PullbackDrgm C maps)\n:= maps_HasPullback\n\n/-! #brief A category with all pullbacks.\n-/\nclass HasAllPullbacks (C : Cat.{ℓobj ℓhom})\n:= (has_pullback : ∀ {base : C^.obj} {factor : list C^.obj} {t : C^.obj}\n                     (maps : HomsIn (base :: factor) t)\n                   , HasPullback C maps)\n\ninstance HasAllPullbacks.HasPullback (C : Cat.{ℓobj ℓhom})\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {base : C^.obj} {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn (base :: factor) t)\n    : HasPullback C maps\n:= HasAllPullbacks.has_pullback maps\n\ninstance HasAllPullbacks.HasAllLimitsFrom (C : Cat.{ℓobj ℓhom})\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    (N : ℕ)\n    : HasAllLimitsFrom C (CoSpanCat (nat.succ N))\n:= { has_limit := λ L, let l := HasAllPullbacks.HasPullback C (PullbackDrgm.mk_homs L)\n                       in cast (HasLimit.heq begin rw PullbackDrgm.length_mk_doms end rfl (PullbackDrgm.uniq L)) l\n   }\n\n/-! #brief A category with all pullbacks along a given hom.\n-/\nclass HasPullbacksAlong (C : Cat.{ℓobj ℓhom})\n    {base t : C^.obj} (f : C^.hom base t)\n:= (has_pullback : ∀ {y : C^.obj} (map : C^.hom y t)\n                   , HasPullback C (f ↗→ map ↗→↗))\n\ninstance HasPullbacksAlong.HasPullback (C : Cat.{ℓobj ℓhom})\n    {base t : C^.obj} (f : C^.hom base t)\n    {y : C^.obj} (map : C^.hom y t)\n    [f_HasPullbacksAlong : HasPullbacksAlong C f]\n    : HasPullback C (f ↗→ map ↗→↗)\n:= HasPullbacksAlong.has_pullback f map\n\ninstance HasAllPullbacks.HasPullbacksAlong (C : Cat.{ℓobj ℓhom})\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {base t : C^.obj} (f : C^.hom base t)\n    : HasPullbacksAlong C f\n:= { has_pullback := λ y map, HasAllPullbacks.has_pullback (f ↗→ map ↗→↗)\n   }\n\n/-! #brief Helper for showing a category has a pullback.\n-/\ndefinition HasPullback.show (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    (p : C^.obj)\n    (to_t : C^.hom p t)\n    (proj : HomsOut p factor)\n    (ωproj : HomsList.repeat to_t (list.length factor)\n              = homs_in_comp_out maps proj)\n    (univ : ∀ {c : C^.obj} (to_t' : C^.hom c t) (hom : HomsOut c factor)\n              (ωhom : HomsList.repeat\n                       to_t'\n                       (list.length factor)\n                       = homs_in_comp_out maps hom)\n            , C^.hom c p)\n    (ωuniv : ∀ {c : C^.obj} (to_t' : C^.hom c t) (hom : HomsOut c factor)\n              (ωhom : HomsList.repeat\n                       to_t'\n                       (list.length factor)\n                       = homs_in_comp_out maps hom)\n             , hom = HomsOut.comp proj (univ to_t' hom ωhom))\n    (ωuniq : ∀ {c : C^.obj} (to_t' : C^.hom c t) (hom : HomsOut c factor)\n              (ωhom : HomsList.repeat\n                       to_t'\n                       (list.length factor)\n                       = homs_in_comp_out maps hom)\n               (h : C^.hom c p)\n               (ωcomm : hom = HomsOut.comp proj h)\n             , h = univ to_t' hom ωhom)\n    : HasPullback C maps\n:= HasLimit.show p (λ x, option.cases_on x to_t ((HomsOut.get proj)))\n    (λ x₁ x₂ f, begin\n                 cases f,\n                 { exact eq.symm C^.circ_id_left },\n                 { unfold PullbackDrgm,\n                   apply eq_of_heq,\n                   refine heq.trans (heq.symm (HomsList.get_repeat to_t n)) _,\n                   refine heq.trans _ (get_homs_in_comp_out maps proj),\n                   rw ωproj\n                 }\n               end)\n    (λ c hom ωcomm, univ (hom none) (HomsOut.enum (λ n, hom (some n)))\n     begin\n       exact sorry\n     end)\n    (λ c hom ωcomm a, begin exact sorry end)\n    (λ c hom ωcomm h ωh, begin exact sorry end)\n\n/-! #brief Pullbacks are cones.\n-/\ndefinition pullback.cone (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    : PullbackCone C maps\n:= limit.cone (PullbackDrgm C maps)\n\n/-! #brief The pullback of a collection of homs.\n-/\ndefinition pullback (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    : C^.obj\n:= limit (PullbackDrgm C maps)\n\n/-! #brief Projection out of a pullback.\n-/\ndefinition pullback.π (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    (n : fin (list.length factor))\n    : C^.hom (pullback C maps) (list.get factor n)\n:= limit.out (PullbackDrgm C maps) (some n)\n\n/-! #brief The commutative square property of pullbacks.\n-/\ndefinition pullback.π_comm (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    (n₁ n₂ : fin (list.length factor))\n    : HomsIn.get maps n₁ ∘∘ pullback.π C maps n₁\n       = HomsIn.get maps n₂ ∘∘ pullback.π C maps n₂\n:= sorry\n\n/-! #brief Projection out of a pullback to the base.\n-/\ndefinition pullback.πbase (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    : C^.hom (pullback C maps) t\n:= limit.out (PullbackDrgm C maps) none\n\n/-! #brief Every cone is mediated through the pullback.\n-/\ndefinition pullback.univ (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    (c : PullbackCone C maps)\n    : C^.hom c^.obj (pullback C maps)\n:= limit.univ _ c\n\n/-! #brief Every cone is mediated through the pullback.\n-/\ndefinition pullback.univ.mediates (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    {maps_HasPullback : HasPullback C maps}\n    (c : PullbackCone C maps)\n    (n : fin (list.length factor))\n    : c^.hom (some n) = C^.circ (@pullback.π C factor t maps maps_HasPullback n) (pullback.univ C maps c)\n:= limit.univ.mediates c (some n)\n\n/-! #brief Every cone is mediated through the pullback.\n-/\ndefinition pullback.univ.mediates_base (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    {maps_HasPullback : HasPullback C maps}\n    (c : PullbackCone C maps)\n    : c^.hom none = C^.circ (@pullback.πbase C factor t maps maps_HasPullback) (pullback.univ C maps c)\n:= limit.univ.mediates c none\n\n/-! #brief The mediating map from the cone to the pullback is unique.\n-/\ndefinition pullback.univ.uniq (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    {maps_HasPullback : HasPullback C maps}\n    (c : PullbackCone C maps)\n    (m : C^.hom c^.obj (pullback C maps))\n    (ω : ∀ (n : fin (list.length factor))\n         , c^.hom (some n) = (@pullback.π C factor t maps maps_HasPullback n) ∘∘ m)\n    (ωbase : c^.hom none = (@pullback.πbase C factor t maps maps_HasPullback) ∘∘ m)\n    : m = pullback.univ C maps c\n:= limit.univ.uniq c m (λ x, option.cases_on x ωbase ω)\n\n/-! #brief The unique iso between two pullbacks of the same homs.\n-/\ndefinition pullback.iso {C : Cat.{ℓobj ℓhom}}\n    {factor : list C^.obj} {t : C^.obj}\n    {maps : HomsIn factor t}\n    (maps_HasPullback₁ maps_HasPullback₂ : HasPullback C maps)\n    : C^.hom (@pullback C factor t maps maps_HasPullback₁)\n             (@pullback C factor t maps maps_HasPullback₂)\n:= limit.iso maps_HasPullback₁ maps_HasPullback₂\n\n/-! #brief Pullbacks are unique up-to unique isomorphism.\n-/\ndefinition pullback.uniq {C : Cat.{ℓobj ℓhom}}\n    {factor : list C^.obj} {t : C^.obj}\n    {maps : HomsIn factor t}\n    (maps_HasPullback₁ maps_HasPullback₂ : HasPullback C maps)\n    : Iso (pullback.iso maps_HasPullback₁ maps_HasPullback₂)\n          (pullback.iso maps_HasPullback₂ maps_HasPullback₁)\n:= limit.uniq maps_HasPullback₁ maps_HasPullback₂\n\n\n\n/- -----------------------------------------------------------------------\nPullbacks in functor categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief Pullbacks in functor categories can be computed pointwise.\n-/\ninstance FunCat.HasPullback {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    [D_HasAllPullbacks : HasAllPullbacks D]\n    {base : Fun C D} {factor : list (Fun C D)} {t : Fun C D}\n    (maps : @HomsIn (FunCat C D) (base :: factor) t)\n    : HasPullback (FunCat C D) maps\n:= @FunCat.HasLimit _ _ _ (HasAllPullbacks.HasAllLimitsFrom D _) (PullbackDrgm (FunCat C D) maps)\n\n/-! #brief Pullbacks in functor categories can be computed pointwise.\n-/\ninstance FunCat.HasAllPullbacks {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    [D_HasAllPullbacks : HasAllPullbacks D]\n    : HasAllPullbacks (FunCat C D)\n:= { has_pullback := λ base factor t maps, FunCat.HasPullback maps\n   }\n\n\n\n/- -----------------------------------------------------------------------\nPullback squares.\n----------------------------------------------------------------------- -/\n\n/-! #brief A pullback square.\n-/\nclass IsPullback {C : Cat.{ℓobj ℓhom}}\n    {p x y t : C^.obj}\n    (base : C^.hom x t) (p₁ : C^.hom p x)\n    (map : C^.hom y t)  (p₂ : C^.hom p y)\n:= (has_pullback : HasPullback C (base ↗→ map ↗→↗))\n   (ωpullback : @pullback C [x, y] t _ has_pullback = p)\n   (ωπ₁ : @pullback.π C [x, y] t _ has_pullback (@fin_of 1 0) = p₁ ∘∘ cast_hom ωpullback)\n   (ωπ₂ : @pullback.π C [x, y] t _ has_pullback (@fin_of 0 1) = p₂ ∘∘ cast_hom ωpullback)\n\n/-! #brief Pullback squares have the usual commutative diagram.\n-/\ntheorem ispullback.square {C : Cat.{ℓobj ℓhom}}\n    {p x y t : C^.obj}\n    {base : C^.hom x t} {p₁ : C^.hom p x}\n    {map : C^.hom y t}  {p₂ : C^.hom p y}\n    (isPullback : IsPullback base p₁ map p₂)\n    : C^.circ base p₁ = C^.circ map p₂\n:= sorry\n\n/-! #brief The universal map into a pullback square.\n-/\ndefinition ispullback.univ {C : Cat.{ℓobj ℓhom}}\n    {p x y t : C^.obj}\n    {base : C^.hom x t} {p₁ : C^.hom p x}\n    {map : C^.hom y t}  {p₂ : C^.hom p y}\n    (isPullback : IsPullback base p₁ map p₂)\n    {c : C^.obj} (h₁ : C^.hom c x) (h₂ : C^.hom c y)\n    (ωsquare : C^.circ base h₁ = C^.circ map h₂)\n    : C^.hom c p\n:= C^.circ\n    (cast_hom (IsPullback.ωpullback base p₁ map p₂))\n    (@pullback.univ _ _ _ _ (IsPullback.has_pullback base p₁ map p₂)\n      (PullbackCone.mk _ c (C^.circ base h₁) (h₁ ↗← h₂ ↗←↗)\n        begin\n          apply dlist.eq,\n          { trivial },\n          apply dlist.eq,\n          { exact ωsquare },\n          trivial\n        end))\n\n/-! #brief Helper for showing one has a pullback square.\n-/\ndefinition IsPullback.show {C : Cat.{ℓobj ℓhom}}\n    {p x y t : C^.obj}\n    {base : C^.hom x t} {p₁ : C^.hom p x}\n    {map : C^.hom y t}  {p₂ : C^.hom p y}\n    (univ\n      : ∀ {c : C^.obj} (h₁ : C^.hom c x) (h₂ : C^.hom c y)\n          (ωsquare : C^.circ base h₁ = C^.circ map h₂)\n        , C^.hom c p)\n    (ωsquare\n      : C^.circ base p₁ = C^.circ map p₂)\n    (ωuniv₁\n      : ∀ {c : C^.obj} (h₁ : C^.hom c x) (h₂ : C^.hom c y)\n          (ωsquare : C^.circ base h₁ = C^.circ map h₂)\n        , h₁ = C^.circ p₁ (univ h₁ h₂ ωsquare))\n    (ωuniv₂\n      : ∀ {c : C^.obj} (h₁ : C^.hom c x) (h₂ : C^.hom c y)\n          (ωsquare : C^.circ base h₁ = C^.circ map h₂)\n        , h₂ = C^.circ p₂ (univ h₁ h₂ ωsquare))\n    (ωuniv_uniq\n      : ∀ {c : C^.obj} (h₁ : C^.hom c x) (h₂ : C^.hom c y)\n          (ωsquare : C^.circ base h₁ = C^.circ map h₂)\n          (univ' : C^.hom c p)\n          (ωuniv'₁ : h₁ = C^.circ p₁ univ')\n          (ωuniv'₂ : h₂ = C^.circ p₂ univ')\n        , univ' = univ h₁ h₂ ωsquare)\n    : IsPullback base p₁ map p₂\n:= { has_pullback\n      := HasPullback.show C (base ↗→ map ↗→↗) p\n          (C^.circ base p₁)\n          (p₁ ↗← p₂ ↗←↗)\n          begin\n            apply dlist.eq,\n            { trivial },\n            apply dlist.eq,\n            { exact ωsquare },\n            trivial\n          end\n          (λ c to_t homs ωhoms\n           , begin\n               cases homs with _ h₁ _ homs,\n               cases homs with _ h₂ _ _,\n               cases bb,\n               apply univ h₁ h₂,\n               refine @eq.trans _  _ to_t _  _ _,\n               { apply eq.symm,\n                 apply HomsList.congr_get ωhoms (@fin_of 1 0)\n               },\n               { apply HomsList.congr_get ωhoms (@fin_of 0 1) }\n             end)\n          (λ c to_t homs ωhoms\n           , begin\n               cases homs with _ h₁ _ homs,\n               cases homs with _ h₂ _ _,\n               cases bb,\n               apply dlist.eq,\n               { apply ωuniv₁ },\n               apply dlist.eq,\n               { apply ωuniv₂ },\n               trivial\n             end)\n          (λ c to_t homs ωhoms h ωh\n           , begin\n               cases homs with _ h₁ _ homs,\n               cases homs with _ h₂ _ _,\n               cases bb,\n               apply ωuniv_uniq,\n               { apply dlist.congr_get ωh (@fin_of 1 0) },\n               { apply dlist.congr_get ωh (@fin_of 0 1) }\n             end)\n   , ωpullback := rfl\n   , ωπ₁ := eq.symm C^.circ_id_right\n   , ωπ₂ := eq.symm C^.circ_id_right\n   }\n\n\n\n/- -----------------------------------------------------------------------\nMaps from pullbacks to products.\n----------------------------------------------------------------------- -/\n\n/-! #brief The map from a pullback to the underlying product.\n-/\ndefinition pullback.to_finproduct (C : Cat.{ℓobj ℓhom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    [dom_HasFinProduct : HasFinProduct C factor]\n    : C^.hom (pullback C maps) (finproduct C factor)\n:= sorry\n\n\n/- -----------------------------------------------------------------------\nMaps between pullbacks.\n----------------------------------------------------------------------- -/\n\n/-! #brief Building a map between pullbacks.\n-/\ndefinition pullback.hom (C : Cat.{ℓobj ℓhom})\n    (base : C^.obj × C^.obj) (factor : list (C^.obj × C^.obj)) {t : C^.obj}\n    (maps₁ : HomsIn (list.map prod.fst (base :: factor)) t)\n    [maps₁_HasPullback : HasPullback C maps₁]\n    (maps₂ : HomsIn (list.map prod.snd (base :: factor)) t)\n    [maps₂_HasPullback : HasPullback C maps₂]\n    (fns : HomsList C (base :: factor))\n    : C^.hom (pullback C maps₁)\n             (pullback C maps₂)\n:= pullback.univ _ _\n    (PullbackCone.mk maps₂ (pullback C maps₁)\n      (HomsIn.get maps₂ fin.zero\n        ∘∘ HomsList.get fns fin.zero\n        ∘∘ pullback.π C maps₁ fin.zero)\n      (homs_comp_out fns (pullback.cone C maps₁)^.Proj)\n      sorry)\n\n\n\n/- -----------------------------------------------------------------------\nFibers.\n----------------------------------------------------------------------- -/\n\n/-! #brief Fiber of a map over a global element.\n-/\ndefinition Fiber {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x y : C^.obj} (f : C^.hom x y)\n    (y₀ : C^.hom (final C) y)\n    : C^.obj\n:= pullback C (f ↗→ y₀ ↗→↗)\n\n/-! #brief Projection out of a fiber.\n-/\ndefinition Fiber.π {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x y : C^.obj} (f : C^.hom x y)\n    (y₀ : C^.hom (final C) y)\n    : C^.hom (Fiber f y₀) x\n:= pullback.π C (f ↗→ y₀ ↗→↗) (@fin_of 1 0)\n\n/-! #brief A hom into a fiber.\n-/\ndefinition Fiber.into {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x y : C^.obj} (f : C^.hom x y)\n    (y₀ : C^.hom (final C) y)\n    {z : C^.obj}\n    (h : C^.hom z x)\n    (ωh : f ∘∘ h = y₀ ∘∘ final_hom z)\n    : C^.hom z (Fiber f y₀)\n:= pullback.univ C (f ↗→ y₀ ↗→↗)\n    (PullbackCone.mk (f ↗→ y₀ ↗→↗) z\n      (C^.circ f h)\n      (h ↗← final_hom z ↗←↗)\n      begin\n        apply HomsList.eq, { trivial },\n        apply HomsList.eq, { exact ωh },\n        trivial\n      end)\n\n/-! #brief A cone over a fiber.\n-/\ndefinition Fiber.cone {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x₁ x₂ y : C^.obj} {f₁ : C^.hom x₁ y} {f₂ : C^.hom x₂ y}\n    {y₀ : C^.hom (final C) y}\n    (h : C^.hom x₁ x₂)\n    (ωh : y₀ ∘∘ final_hom (Fiber f₁ y₀)\n           = f₂ ∘∘ h ∘∘ pullback.π C (f₁ ↗→ y₀ ↗→↗) (@fin_of 1 0))\n:= PullbackCone.mk (f₂ ↗→ y₀ ↗→↗) (Fiber f₁ y₀)\n      (y₀ ∘∘ final_hom (Fiber f₁ y₀))\n      (h ∘∘ pullback.π C (f₁ ↗→ y₀ ↗→↗) (@fin_of 1 0) ↗← final_hom (Fiber f₁ y₀) ↗←↗)\n      begin\n        apply HomsList.eq, { exact eq.trans ωh (eq.symm C^.circ_assoc) },\n        apply HomsList.eq, { trivial },\n        trivial\n      end\n\n/-! #brief A hom between fibers.\n-/\ndefinition Fiber.hom {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x₁ x₂ y : C^.obj} {f₁ : C^.hom x₁ y} {f₂ : C^.hom x₂ y}\n    {y₀ : C^.hom (final C) y}\n    (h : C^.hom x₁ x₂)\n    (ωh : y₀ ∘∘ final_hom (Fiber f₁ y₀)\n           = f₂ ∘∘ h ∘∘ pullback.π C (f₁ ↗→ y₀ ↗→↗) (@fin_of 1 0))\n    : C^.hom (Fiber f₁ y₀) (Fiber f₂ y₀)\n:= pullback.univ C (f₂ ↗→ y₀ ↗→↗) (Fiber.cone h ωh)\n\n\n\n/- -----------------------------------------------------------------------\nProducts in OverCat.\n----------------------------------------------------------------------- -/\n\n/-! #brief Existence of products in an over-category.\n-/\ndefinition OverCat.HasFinProduct₀ (C : Cat.{ℓobj ℓhom}) (c : C^.obj)\n    : HasFinProduct (OverCat C c) []\n:= @HasFinProduct.show (OverCat C c) []\n    (@final (OverCat C c) (OverCat.HasFinal C c))\n    HomsOut.nil\n    (λ X homs, @final_hom (OverCat C c) (OverCat.HasFinal C c) X)\n    (λ X homs, begin cases homs, trivial end)\n    (λ X homs h ωh, @final_hom.uniq (OverCat C c) (OverCat.HasFinal C c) X h)\n\n/-! #brief Existence of products in an over-category.\n-/\ndefinition OverCat.HasFinProduct₁ (C : Cat.{ℓobj ℓhom}) (c : C^.obj)\n    (factors : list (OverCat C c)^.obj)\n    [factors_HasPullback : HasPullback C (HomsIn.of_list_OverObj factors)]\n    : HasFinProduct (OverCat C c) factors\n:= let pb : OverObj C c\n         := { obj := pullback C (HomsIn.of_list_OverObj factors)\n            , hom := pullback.πbase C (HomsIn.of_list_OverObj factors)\n            }\nin HasProduct.show (OverCat C c) (list.get factors)\n    pb\n    (λ n, { hom := cast_hom sorry\n                    ∘∘ pullback.π C (HomsIn.of_list_OverObj factors)\n                        { val := n^.val, is_lt := cast sorry n^.is_lt }\n          , triangle := sorry\n          })\n    (λ X homs\n     , { hom := pullback.univ C (HomsIn.of_list_OverObj factors)\n                 (PullbackCone.mk (HomsIn.of_list_OverObj factors) X^.obj\n                   X^.hom\n                   (HomsOut.enum\n                     (λ n, cast_hom sorry\n                            ∘∘ (homs { val := n^.val, is_lt := cast sorry n^.is_lt})^.hom))\n                   sorry)\n       , triangle := sorry\n       })\n    (λ X hom n, sorry)\n    (λ X hom h ωh, sorry)\n\n/-! #brief Existence of products in an over-category.\n-/\ninstance OverCat.HasFinProduct (C : Cat.{ℓobj ℓhom}) (c : C^.obj)\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    : ∀ (factors : list (OverCat C c)^.obj)\n      , HasFinProduct (OverCat C c) factors\n| [] := OverCat.HasFinProduct₀ C c\n| (factor₀ :: factors)\n:= @OverCat.HasFinProduct₁ C c (factor₀ :: factors)\n     (HasAllPullbacks.HasPullback C _)\n\ninstance OverCat.HasAllFinProducts (C : Cat.{ℓobj ℓhom}) (c : C^.obj)\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    : HasAllFinProducts (OverCat C c)\n:= { has_product := OverCat.HasFinProduct C c\n   }\n\n\n/- -----------------------------------------------------------------------\nPullbacks along final homs.\n----------------------------------------------------------------------- -/\n\n/-! Categories with products have pullbacks along final homs.\n-/\ninstance HasAllFinProducts.final_hom.HasPullbacksAlong\n    {C : Cat.{ℓobj ℓhom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllFinProducts : HasAllFinProducts C]\n    (x : C^.obj)\n    : HasPullbacksAlong C (final_hom x)\n:= { has_pullback\n      := λ y map\n         , HasPullback.show C (final_hom x ↗→ map ↗→↗)\n            (finproduct C [x, y])\n            (final_hom (finproduct C [x, y]))\n            (finproduct.cone C [x, y])^.Proj\n            begin\n              apply eq.symm,\n              apply dlist.eq,\n              { apply final_hom.uniq },\n              -- induction maps with _ m _ maps rec,\n              -- { trivial },\n              -- apply dlist.eq,\n              -- { apply final_hom.uniq },\n              -- apply rec\n              exact sorry\n            end\n            begin exact sorry end\n            begin exact sorry end\n            begin exact sorry end\n   }\n\nend qp\n", "meta": {"author": "intoverflow", "repo": "qvr", "sha": "0cfcd33fe4bf8d93851a00cec5bfd21e77105d74", "save_path": "github-repos/lean/intoverflow-qvr", "path": "github-repos/lean/intoverflow-qvr/qvr-0cfcd33fe4bf8d93851a00cec5bfd21e77105d74/qp/p1_categories/c2_limits/s3_pullbacks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46678021652028656}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.sites.canonical\n! leanprover-community/mathlib commit 9e7c80f638149bfb3504ba8ff48dfdbfc949fb1a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Sites.SheafOfTypes\n\n/-!\n# The canonical topology on a category\n\nWe define the finest (largest) Grothendieck topology for which a given presheaf `P` is a sheaf.\nThis is well defined since if `P` is a sheaf for a topology `J`, then it is a sheaf for any\ncoarser (smaller) topology. Nonetheless we define the topology explicitly by specifying its sieves:\nA sieve `S` on `X` is covering for `finest_topology_single P` iff\n  for any `f : Y ⟶ X`, `P` satisfies the sheaf axiom for `S.pullback f`.\nShowing that this is a genuine Grothendieck topology (namely that it satisfies the transitivity\naxiom) forms the bulk of this file.\n\nThis generalises to a set of presheaves, giving the topology `finest_topology Ps` which is the\nfinest topology for which every presheaf in `Ps` is a sheaf.\nUsing `Ps` as the set of representable presheaves defines the `canonical_topology`: the finest\ntopology for which every representable is a sheaf.\n\nA Grothendieck topology is called `subcanonical` if it is smaller than the canonical topology,\nequivalently it is subcanonical iff every representable presheaf is a sheaf.\n\n## References\n* https://ncatlab.org/nlab/show/canonical+topology\n* https://ncatlab.org/nlab/show/subcanonical+coverage\n* https://stacks.math.columbia.edu/tag/00Z9\n* https://math.stackexchange.com/a/358709/\n-/\n\n\nuniverse v u\n\nnamespace CategoryTheory\n\nopen CategoryTheory Category Limits Sieve Classical\n\nvariable {C : Type u} [Category.{v} C]\n\nnamespace Sheaf\n\nvariable {P : Cᵒᵖ ⥤ Type v}\n\nvariable {X Y : C} {S : Sieve X} {R : Presieve X}\n\nvariable (J J₂ : GrothendieckTopology C)\n\n/--\nTo show `P` is a sheaf for the binding of `U` with `B`, it suffices to show that `P` is a sheaf for\n`U`, that `P` is a sheaf for each sieve in `B`, and that it is separated for any pullback of any\nsieve in `B`.\n\nThis is mostly an auxiliary lemma to show `is_sheaf_for_trans`.\nAdapted from [Elephant], Lemma C2.1.7(i) with suggestions as mentioned in\nhttps://math.stackexchange.com/a/358709/\n-/\ntheorem isSheafFor_bind (P : Cᵒᵖ ⥤ Type v) (U : Sieve X) (B : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄, U f → Sieve Y)\n    (hU : Presieve.IsSheafFor P U) (hB : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), Presieve.IsSheafFor P (B hf))\n    (hB' :\n      ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (h : U f) ⦃Z⦄ (g : Z ⟶ Y), Presieve.IsSeparatedFor P ((B h).pullback g)) :\n    Presieve.IsSheafFor P (Sieve.bind U B) :=\n  by\n  intro s hs\n  let y : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), presieve.family_of_elements P (B hf) := fun Y f hf Z g hg =>\n    s _ (presieve.bind_comp _ _ hg)\n  have hy : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).Compatible :=\n    by\n    intro Y f H Y₁ Y₂ Z g₁ g₂ f₁ f₂ hf₁ hf₂ comm\n    apply hs\n    apply reassoc_of comm\n  let t : presieve.family_of_elements P U := fun Y f hf => (hB hf).amalgamate (y hf) (hy hf)\n  have ht : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : U f), (y hf).IsAmalgamation (t f hf) := fun Y f hf =>\n    (hB hf).IsAmalgamation _\n  have hT : t.compatible := by\n    rw [presieve.compatible_iff_sieve_compatible]\n    intro Z W f h hf\n    apply (hB (U.downward_closed hf h)).IsSeparatedFor.ext\n    intro Y l hl\n    apply (hB' hf (l ≫ h)).ext\n    intro M m hm\n    have : bind U B (m ≫ l ≫ h ≫ f) :=\n      by\n      have : bind U B _ := presieve.bind_comp f hf hm\n      simpa using this\n    trans s (m ≫ l ≫ h ≫ f) this\n    · have := ht (U.downward_closed hf h) _ ((B _).downward_closed hl m)\n      rw [op_comp, functor_to_types.map_comp_apply] at this\n      rw [this]\n      change s _ _ = s _ _\n      simp\n    · have : s _ _ = _ := (ht hf _ hm).symm\n      simp only [assoc] at this\n      rw [this]\n      simp\n  refine' ⟨hU.amalgamate t hT, _, _⟩\n  · rintro Z _ ⟨Y, f, g, hg, hf, rfl⟩\n    rw [op_comp, functor_to_types.map_comp_apply, presieve.is_sheaf_for.valid_glue _ _ _ hg]\n    apply ht hg _ hf\n  · intro y hy\n    apply hU.is_separated_for.ext\n    intro Y f hf\n    apply (hB hf).IsSeparatedFor.ext\n    intro Z g hg\n    rw [← functor_to_types.map_comp_apply, ← op_comp, hy _ (presieve.bind_comp _ _ hg),\n      hU.valid_glue _ _ hf, ht hf _ hg]\n#align category_theory.sheaf.is_sheaf_for_bind CategoryTheory.Sheaf.isSheafFor_bind\n\n/-- Given two sieves `R` and `S`, to show that `P` is a sheaf for `S`, we can show:\n* `P` is a sheaf for `R`\n* `P` is a sheaf for the pullback of `S` along any arrow in `R`\n* `P` is separated for the pullback of `R` along any arrow in `S`.\n\nThis is mostly an auxiliary lemma to construct `finest_topology`.\nAdapted from [Elephant], Lemma C2.1.7(ii) with suggestions as mentioned in\nhttps://math.stackexchange.com/a/358709\n-/\ntheorem isSheafFor_trans (P : Cᵒᵖ ⥤ Type v) (R S : Sieve X) (hR : Presieve.IsSheafFor P R)\n    (hR' : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : S f), Presieve.IsSeparatedFor P (R.pullback f))\n    (hS : ∀ ⦃Y⦄ ⦃f : Y ⟶ X⦄ (hf : R f), Presieve.IsSheafFor P (S.pullback f)) :\n    Presieve.IsSheafFor P S :=\n  by\n  have : (bind R fun Y f hf => S.pullback f : presieve X) ≤ S :=\n    by\n    rintro Z f ⟨W, f, g, hg, hf : S _, rfl⟩\n    apply hf\n  apply presieve.is_sheaf_for_subsieve_aux P this\n  apply is_sheaf_for_bind _ _ _ hR hS\n  · intro Y f hf Z g\n    dsimp\n    rw [← pullback_comp]\n    apply (hS (R.downward_closed hf _)).IsSeparatedFor\n  · intro Y f hf\n    have : sieve.pullback f (bind R fun T (k : T ⟶ X) (hf : R k) => pullback k S) = R.pullback f :=\n      by\n      ext (Z g)\n      constructor\n      · rintro ⟨W, k, l, hl, _, comm⟩\n        rw [pullback_apply, ← comm]\n        simp [hl]\n      · intro a\n        refine' ⟨Z, 𝟙 Z, _, a, _⟩\n        simp [hf]\n    rw [this]\n    apply hR' hf\n#align category_theory.sheaf.is_sheaf_for_trans CategoryTheory.Sheaf.isSheafFor_trans\n\n/-- Construct the finest (largest) Grothendieck topology for which the given presheaf is a sheaf.\n\nThis is a special case of https://stacks.math.columbia.edu/tag/00Z9, but following a different\nproof (see the comments there).\n-/\ndef finestTopologySingle (P : Cᵒᵖ ⥤ Type v) : GrothendieckTopology C\n    where\n  sieves X S := ∀ (Y) (f : Y ⟶ X), Presieve.IsSheafFor P (S.pullback f)\n  top_mem' X Y f := by\n    rw [sieve.pullback_top]\n    exact presieve.is_sheaf_for_top_sieve P\n  pullback_stable' X Y S f hS Z g := by\n    rw [← pullback_comp]\n    apply hS\n  transitive' X S hS R hR Z g :=\n    by\n    -- This is the hard part of the construction, showing that the given set of sieves satisfies\n    -- the transitivity axiom.\n    refine' is_sheaf_for_trans P (pullback g S) _ (hS Z g) _ _\n    · intro Y f hf\n      rw [← pullback_comp]\n      apply (hS _ _).IsSeparatedFor\n    · intro Y f hf\n      have := hR hf _ (𝟙 _)\n      rw [pullback_id, pullback_comp] at this\n      apply this\n#align category_theory.sheaf.finest_topology_single CategoryTheory.Sheaf.finestTopologySingle\n\n/--\nConstruct the finest (largest) Grothendieck topology for which all the given presheaves are sheaves.\n\nThis is equal to the construction of <https://stacks.math.columbia.edu/tag/00Z9>.\n-/\ndef finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) : GrothendieckTopology C :=\n  infₛ (finestTopologySingle '' Ps)\n#align category_theory.sheaf.finest_topology CategoryTheory.Sheaf.finestTopology\n\n/-- Check that if `P ∈ Ps`, then `P` is indeed a sheaf for the finest topology on `Ps`. -/\ntheorem sheaf_for_finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) (h : P ∈ Ps) :\n    Presieve.IsSheaf (finestTopology Ps) P := fun X S hS => by\n  simpa using hS _ ⟨⟨_, _, ⟨_, h, rfl⟩, rfl⟩, rfl⟩ _ (𝟙 _)\n#align category_theory.sheaf.sheaf_for_finest_topology CategoryTheory.Sheaf.sheaf_for_finestTopology\n\n/--\nCheck that if each `P ∈ Ps` is a sheaf for `J`, then `J` is a subtopology of `finest_topology Ps`.\n-/\ntheorem le_finestTopology (Ps : Set (Cᵒᵖ ⥤ Type v)) (J : GrothendieckTopology C)\n    (hJ : ∀ P ∈ Ps, Presieve.IsSheaf J P) : J ≤ finestTopology Ps :=\n  by\n  rintro X S hS _ ⟨⟨_, _, ⟨P, hP, rfl⟩, rfl⟩, rfl⟩\n  intro Y f\n  -- this can't be combined with the previous because the `subst` is applied at the end\n  exact hJ P hP (S.pullback f) (J.pullback_stable f hS)\n#align category_theory.sheaf.le_finest_topology CategoryTheory.Sheaf.le_finestTopology\n\n/-- The `canonical_topology` on a category is the finest (largest) topology for which every\nrepresentable presheaf is a sheaf.\n\nSee <https://stacks.math.columbia.edu/tag/00ZA>\n-/\ndef canonicalTopology (C : Type u) [Category.{v} C] : GrothendieckTopology C :=\n  finestTopology (Set.range yoneda.obj)\n#align category_theory.sheaf.canonical_topology CategoryTheory.Sheaf.canonicalTopology\n\n/-- `yoneda.obj X` is a sheaf for the canonical topology. -/\ntheorem isSheaf_yoneda_obj (X : C) : Presieve.IsSheaf (canonicalTopology C) (yoneda.obj X) :=\n  fun Y S hS => sheaf_for_finestTopology _ (Set.mem_range_self _) _ hS\n#align category_theory.sheaf.is_sheaf_yoneda_obj CategoryTheory.Sheaf.isSheaf_yoneda_obj\n\n/-- A representable functor is a sheaf for the canonical topology. -/\ntheorem isSheaf_of_representable (P : Cᵒᵖ ⥤ Type v) [P.Representable] :\n    Presieve.IsSheaf (canonicalTopology C) P :=\n  Presieve.isSheaf_iso (canonicalTopology C) P.reprW (isSheaf_yoneda_obj _)\n#align category_theory.sheaf.is_sheaf_of_representable CategoryTheory.Sheaf.isSheaf_of_representable\n\n/-- A subcanonical topology is a topology which is smaller than the canonical topology.\nEquivalently, a topology is subcanonical iff every representable is a sheaf.\n-/\ndef Subcanonical (J : GrothendieckTopology C) : Prop :=\n  J ≤ canonicalTopology C\n#align category_theory.sheaf.subcanonical CategoryTheory.Sheaf.Subcanonical\n\nnamespace Subcanonical\n\n/-- If every functor `yoneda.obj X` is a `J`-sheaf, then `J` is subcanonical. -/\ntheorem of_yoneda_isSheaf (J : GrothendieckTopology C)\n    (h : ∀ X, Presieve.IsSheaf J (yoneda.obj X)) : Subcanonical J :=\n  le_finestTopology _ _\n    (by\n      rintro P ⟨X, rfl⟩\n      apply h)\n#align category_theory.sheaf.subcanonical.of_yoneda_is_sheaf CategoryTheory.Sheaf.Subcanonical.of_yoneda_isSheaf\n\n/-- If `J` is subcanonical, then any representable is a `J`-sheaf. -/\ntheorem isSheaf_of_representable {J : GrothendieckTopology C} (hJ : Subcanonical J)\n    (P : Cᵒᵖ ⥤ Type v) [P.Representable] : Presieve.IsSheaf J P :=\n  Presieve.isSheaf_of_le _ hJ (isSheaf_of_representable P)\n#align category_theory.sheaf.subcanonical.is_sheaf_of_representable CategoryTheory.Sheaf.Subcanonical.isSheaf_of_representable\n\nend Subcanonical\n\nend Sheaf\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Sites/Canonical.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46678020993986835}}
{"text": "import category_theory.Fintype\nimport data.real.nnreal\nimport laurent_measures.basic\nimport order.filter.at_top_bot\nimport pseudo_normed_group.basic\nimport pseudo_normed_group.category\nimport real_measures\nimport ring_theory.principal_ideal_domain\nimport ring_theory.power_series.basic\n\n/-- SECTIONS\nEverything takes place in the `namespace theta`\n\n* Section `aux_lemmas` contain some technicalities concerning convergent sequence\n* Section `summability` shows that the series defining `ϑ` converges\n* In Section `theta_surjective` We define the map ϑ : (laurent_measures r `S`) → ℝ and we\n  show it is surjective.\n* Section `ker_theta` studies the kernel of `ϑ`, in particular showing it is principal.\n\n   VARIABLES\n* The variable `ξ : ℝ` here corresponds to `r'` of `Analytic.pdf`, so that, for every `r`, `ϑ ξ r`\n  is`θ_r'` as a map from `r`-convergent Laurent measures to `ℝ`. It is supposed to be positive almost\neverywhere, and this is recorded as a `fact`.\n* The variable `x : ℝ` is defined globally in Sections `aux_lemmas` and `summability`.\n* The variable `r : ℝ≥0` (specifying the radius of convergency of `laurent_measures` makes its\n  first appearance in Section `theta_surjective`, but it is not globally defined. Whenever it occurs\n  it is assumed to be positive and strictly smaller than `1`, both recorded as facts.\n-/\n\nnoncomputable theory\n\nopen set filter function classical finset nat\nopen_locale topological_space classical nnreal big_operators\n\n-- def laurent_measures.to_Rfct (r : ℝ≥0) :\n--   (laurent_measures r (Fintype.of punit)) → (ℤ → ℤ) := λ ⟨F, _⟩, (F punit.star)\n\nnamespace theta\n\nvariable (ξ : ℝ)\n\n/--The basic function computing the **integer-valued** `ξ`-adic expansion of `x` -/\nnoncomputable def y (x : ℝ) : ℕ → ℝ\n| 0         := x\n| (n + 1)   := (y n) - (⌊(((y n) / ξ ^ n) : ℝ)⌋ : ℝ) * ξ ^ n\n\nsection aux_lemmas\n\nvariable (x : ℝ)\nvariable [fact (0 < ξ)]\n\nlemma bdd_floor : bdd_above (range (λ n : ℕ, (⌊ y ξ x n / ξ ^ n⌋ : ℝ))) :=\nbegin\n  use (max x ξ ⁻¹ : ℝ),\n  intros z hz,\n  obtain ⟨m, h_mz⟩ := (set.mem_range).mp hz,\n    by_cases hm : m = 0,\n  { rw [hm, pow_zero, div_one] at h_mz,\n    rw [← h_mz, y, le_max_iff],\n    apply or.intro_left,\n    exact int.floor_le x },\n  rw ← h_mz,\n  apply (int.floor_le _).trans,\n  obtain ⟨k, hk⟩ : ∃ k : ℕ, m = k + 1 := nat.exists_eq_succ_of_ne_zero hm,\n  rw [hk, y],\n  have : ξ ^ k ≠ 0 := ne_of_gt (pow_pos (fact.out _) k),\n  calc (y ξ x k - ↑⌊y ξ x k / ξ ^ k⌋ * ξ ^ k) / ξ ^ (k + 1) =\n              (y ξ x k - ↑⌊y ξ x k / ξ ^ k⌋ * ξ ^ k) / (ξ ^ k * ξ) : by {rw [pow_add, pow_one]}\n        ... = (y ξ x k - ↑⌊y ξ x k / ξ ^ k⌋ * ξ ^ k) / ξ ^ k / ξ : by {field_simp}\n        ... = (y ξ x k / ξ ^ k - ↑⌊y ξ x k / ξ ^ k⌋ * ξ ^ k / ξ ^ k) / ξ : by {rw [sub_div]}\n        ... = (y ξ x k / ξ ^ k - ↑⌊y ξ x k / ξ ^ k⌋) / ξ : by {simp only [mul_div_cancel,\n                                                                      this, ne.def, not_false_iff]}\n        ... ≤ 1 / ξ : div_le_div_of_le (le_of_lt _) (le_of_lt _)\n        ... ≤ max x ξ ⁻¹ : by {field_simp},\n  exact fact.out _,\n  {rw [sub_lt_iff_lt_add, add_comm], from (int.lt_floor_add_one _)},\nend\n\nlemma eventually_pos_y : ∀ n : ℕ, n ≥ 1 → 0 ≤ y ξ x n :=\nbegin\n  have h_pos : ∀ n : ℕ, n ≥ 1 → ξ ^ n > 0 := λ n _, pow_pos (fact.out _) n,\n  have : ∀ n : ℕ, n ≥ 1 →  (y ξ x n) / ξ ^ n ≥ ⌊(((y ξ x n) / ξ ^ n) : ℝ)⌋ := λ n _, int.floor_le _,\n  intros n hn₁,\n  by_cases hn₀ : n = 1,\n  { rw [hn₀, y,pow_zero, div_one, mul_one, sub_nonneg], apply int.floor_le },\n  { replace hn₁ : n > 1, {apply (lt_of_le_of_ne hn₁), tauto },\n    obtain ⟨m, hm⟩ : ∃ m : ℕ, m ≥ 1 ∧ n = m + 1,\n    use ⟨n - 1, and.intro (nat.le_pred_of_lt hn₁) (nat.sub_add_cancel (le_of_lt hn₁)).symm⟩,\n    rw [hm.2, y],\n    replace this := (le_div_iff (h_pos m hm.1)).mp (this m hm.1),\n    rwa ← sub_nonneg at this },\nend\n\nlemma eventually_pos_floor : ∀ n : ℕ, n ≥ 1 → (⌊((y ξ x n) / ξ ^ n )⌋ : ℝ) ≥ 0 :=\nbegin\n  have h_pos : ∀ n : ℕ, n ≥ 1 → ξ ^ n > 0 := λ n _, pow_pos (fact.out _) n,\n  intros n hn,\n  norm_cast,\n  apply int.floor_nonneg.mpr,\n  exact div_nonneg (eventually_pos_y ξ x n hn) (le_of_lt (h_pos n hn)),\nend\n\nlemma eventually_le : ∀ n, n ≥ 1 → y ξ x (n + 1) ≤ (y ξ x n) :=\nbegin\n  have h_pos : ∀ n : ℕ, n ≥ 1 → ξ ^ n > 0 := λ n _, pow_pos (fact.out _) n,\n  intros n hn,\n  rw y,\n  apply sub_le_self (y ξ x n),\n  apply mul_nonneg _ (le_of_lt (h_pos n hn)),\n  exact eventually_pos_floor ξ x n hn,\nend\n\nlemma eventually_le_one {n : ℕ} (hn : n ≥ 1) : (y ξ x n) ≤ (y ξ x 1) :=\nbegin\n  induction hn with n hn h_ind,\n  exact le_of_eq (refl _),\n  have := (eventually_le ξ x n hn).trans h_ind,\n  rwa nat.succ_eq_add_one,\nend\n\ndef aux_y : ℕ → ℝ := λ n, if n = 0 then y ξ x 1 else y ξ x n\n\nlemma eventually_antitone : antitone (aux_y ξ x) :=\nbegin\n  apply antitone_nat_of_succ_le,\n  intro n,\n  by_cases hn : n = 0,\n  {rw [hn, zero_add, aux_y],\n    simp only [nat.one_ne_zero, if_true, eq_self_iff_true, if_false] },\n  { simp only [aux_y, if_neg hn, function.comp_app, nat.succ_ne_zero, if_false],\n    replace hn : n ≥ 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr hn),\n    exact eventually_le ξ x n hn },\nend\n\nlemma limit_neg_geometric [fact (ξ < 1)] : tendsto (λ i : ℕ, - ξ ^ i) at_top (𝓝 0) :=\nbegin\n  apply summable.tendsto_at_top_zero,\n  rw summable_neg_iff,\n  apply summable_geometric_of_abs_lt_1,\n  rw abs_of_pos,\n  all_goals {exact fact.out _},\nend\n\nend aux_lemmas\n\nsection summability\n\nvariable (x : ℝ)\n\nlemma finite_sum (n : ℕ) : (y ξ x (n + 1) : ℝ) =\n  x - ∑ i in range(n + 1),  (⌊(((y ξ x i) / ξ ^ i) : ℝ)⌋ : ℝ) * (ξ ^ i) :=\nbegin\n  induction n with n h_ind,\n  { rw [zero_add, range_one, sum_singleton], refl },\n  { replace h_ind : (x - (y ξ x (n + 1)) : ℝ) =\n    ∑ i in range(n + 1),  (⌊(y ξ x i / ξ ^ i : ℝ)⌋ : ℝ) * ξ ^ i := by {rw [sub_eq_iff_eq_add,\n      ← sub_eq_iff_eq_add', h_ind] },\n    nth_rewrite_rhs 2 [nat.succ_eq_add_one, ← nat.succ_eq_add_one, range_succ],\n    rw [sum_insert, nat.succ_eq_add_one, ← sub_sub, ← h_ind, sub_sub, add_sub, add_comm _ x,\n      ← add_sub, ← sub_sub, sub_self, zero_sub, neg_sub],\n    refl,\n    simp },\nend\n\nlemma finite_sum' (n : ℕ) : x - (y ξ x n : ℝ) =\n  ∑ i in range (n),  (⌊(((y ξ x i) / ξ ^ i) : ℝ)⌋ : ℝ) * (ξ ^ i) :=\nbegin\n  by_cases hn : n =0,\n  { rw [hn, range_zero, sum_empty, sub_eq_zero], refl },\n  { replace hn : n ≥ 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr hn),\n    rw [← (nat.sub_add_cancel hn), finite_sum ξ x (n - 1)],\n    simp only [sub_sub_cancel] at * },\nend\n\nvariable [fact (0 < ξ)]\n\nlemma exists_limit_y : ∃ a, tendsto (λ n, y ξ x n) at_top (𝓝 a) :=\nbegin\n  have h_bdd : bdd_below (range (aux_y ξ x)),\n  { use 0,\n    intros z hz,\n    obtain ⟨m, h_mz⟩ := (set.mem_range).mp hz,\n    by_cases hm : m = 0,\n    { simp_rw [hm, aux_y, if_pos] at h_mz,\n      rw ← h_mz,\n      exact eventually_pos_y ξ x 1 (le_of_eq (refl _)), },\n      simp_rw [aux_y, (if_neg hm)] at h_mz,\n      rw ← h_mz,\n      replace hm : m ≥ 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr hm),\n      exact eventually_pos_y ξ x m hm },\n  have := tendsto_at_top_cinfi (eventually_antitone ξ x) h_bdd,\n  use (⨅ (i : ℕ), aux_y ξ x i),\n  apply @tendsto.congr' _ _ (aux_y ξ x) _ _ _ _ this,\n  apply (filter.eventually_eq_iff_exists_mem).mpr,\n  use {n | n ≥ 1},\n  simp only [mem_at_top_sets, ge_iff_le, mem_set_of_eq],\n  use 1,\n  simp only [imp_self, forall_const],\n  intros n hn,\n  replace hn : n ≥ 1 := by {simp only [*, ge_iff_le, mem_set_of_eq] at * },\n  have := ne_of_lt (lt_of_lt_of_le nat.zero_lt_one hn),\n  rw [aux_y, ite_eq_right_iff],\n  tauto,\nend\n\nlemma summable_norm (r : ℝ≥0) (hr₁ : r < 1) :\n      summable (λ i, ∥⌊(y ξ x i / ξ ^ i : ℝ)⌋∥ * (r ^ i)) :=\nbegin\n  by_cases hr₀ : r = 0,\n  { rw hr₀,\n    apply @summable_of_ne_finset_zero _ _ _ _ _ (range 1),\n    simp only [int.cast_eq_zero, nnreal.coe_zero, zero_pow_eq_zero, finset.mem_singleton,\n      mul_eq_zero, range_one],\n    intros _ hb,\n    exact or.intro_right _ (nat.pos_of_ne_zero hb) },\n  have h_nonneg : ∀ n : ℕ, n ≥ 1 → (r ^ n : ℝ) ≥ 0 := λ n _, pow_nonneg (r.2) n,\n  have H : ∀ j : {i // i ∉ range 1}, j.1 ≥ 1,\n  { rintro ⟨n, h_n⟩,\n    simp only [ge_iff_le, finset.mem_singleton, range_one] at h_n,\n    exact le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr h_n) },\n  apply (finset.summable_compl_iff (finset.range 1)).mp,\n  swap, apply_instance,\n  have h_nonneg : ∀ i : {i // i ∉ range 1}, (∥⌊(y ξ x i.1 / ξ ^ i.1 : ℝ)⌋∥) * r ^ i.1 ≥ 0,\n    { intro i,\n      apply mul_nonneg _ (h_nonneg i.1 (H i)),\n      simp only [norm_nonneg] },\n  obtain ⟨μ, hμ⟩  := bdd_floor ξ x,\n  have h_bdd : ∀ i : {i // i ∉ range 1}, (∥⌊(y ξ x i.1 / ξ ^ i.1 : ℝ)⌋∥) ≤ μ,\n  { rw upper_bounds at hμ,\n    simp only [*, forall_apply_eq_imp_iff', lt_one_iff, set.mem_range, forall_const,\n      forall_exists_index, nnreal.zero_le_coe, ge_iff_le, set.mem_set_of_eq, implies_true_iff,\n      nonempty_of_inhabited, subtype.forall, pow_nonneg, finset.mem_range, subtype.val_eq_coe] at *,\n    intros a ha,\n    rw [subtype.coe_mk, int.norm_eq_abs],\n    replace ha : a ≥ 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr ha),\n    rwa [abs_eq_self.mpr (eventually_pos_floor ξ x a ha)],\n    exact hμ a },\n  replace h_bdd : ∀ i : {i // i ∉ range 1}, (∥⌊(y ξ x i.1 / ξ ^ i.1 : ℝ)⌋∥) * r ^ i.1\n      ≤ μ * r ^ i.1,\n    { intro i,\n    rw mul_le_mul_right,\n    exacts [h_bdd i, pow_pos ((ne.symm hr₀).le_iff_lt.mp r.2) i.1] },\n  apply summable_of_nonneg_of_le h_nonneg h_bdd,\n  apply (@finset.summable_compl_iff _ _ _ _ _ (λ i, μ * r ^ i) (finset.range 1)).mpr,\n  apply summable.mul_left,\n  apply summable_geometric_of_abs_lt_1,\n  rwa [← nnreal.val_eq_coe, abs_eq_self.mpr r.2],\nend\n\nlemma summable_nnnorm (r : ℝ≥0) (hr₁ : r < 1) :\n      summable (λ i, ∥⌊(y ξ x i / ξ ^ i : ℝ)⌋∥₊ * (r ^ i)) :=\nby simpa only [← nnreal.summable_coe, nonneg.coe_mul, coe_nnnorm, nnreal.coe_pow]\n  using summable_norm ξ x r hr₁\n\nlemma summable_floor (r : ℝ≥0) (hr₁ : r < 1) :\n   summable (λ i, (⌊(y ξ x i / ξ ^ i : ℝ)⌋ : ℝ) * r ^ i) :=\nbegin\n  have h_norm_eq : (λ i : ℕ, (∥⌊y ξ x i / ξ ^ i⌋∥ * (r ^ i : ℝ))) =\n    (λ i : ℕ, (∥(⌊y ξ x i / ξ ^ i⌋ : ℝ) * (r ^ i)∥)),\n    { funext,\n      simp only [norm_mul, norm_pow, nnreal.norm_eq, mul_eq_mul_right_iff],\n      rw [real.norm_eq_abs, int.norm_eq_abs],\n      tauto },\n  have := summable_norm ξ x r hr₁,\n  rw h_norm_eq at this,\n  apply summable_of_summable_norm (this),\nend\n\nlemma limit_y [fact (ξ < 1)]: tendsto (λ n, y ξ x n) at_top (𝓝 0) :=\nbegin\n  have h_pos : 0 < ξ := fact.out _,\n  let ξ₀ : ℝ≥0 := ⟨ξ, le_of_lt (fact.out _)⟩,\n  have h_right : ∀ n, n ≥ 1 → (⌊(y ξ x n / ξ ^ n)⌋ : ℝ) ≤ (y ξ x n / ξ ^ n) :=\n    (λ _ _, int.floor_le _),\n  replace h_right : ∀ n, n ≥ 1 → (⌊(y ξ x n / ξ ^ n)⌋ : ℝ) * ξ ^ n  ≤ y ξ x n :=\n    (λ n hn, (le_div_iff (pow_pos h_pos n)).mp (h_right n hn)),\n  replace h_right : ∀ᶠ n in at_top, (⌊(y ξ x n / ξ ^ n)⌋ : ℝ) * ξ ^ n  ≤ y ξ x n,\n  { simp only [ge_iff_le, eventually_at_top], use [1, h_right] },\n  have h_left : ∀ n, n ≥ 1 → (y ξ x n / ξ ^ n) - 1 ≤ ⌊(y ξ x n / ξ ^ n)⌋ :=\n    (λ n hn, le_of_lt (int.sub_one_lt_floor _)),\n  replace h_left : ∀ n, n ≥ 1 → (y ξ x n - ξ ^ n) ≤ ⌊(y ξ x n / ξ ^ n)⌋ * ξ ^ n,\n  { have h_one : ∀ n : ℕ, 0 < ξ ^ n := (λ n, pow_pos h_pos n),\n    intros n hn,\n    calc y ξ x n - ξ ^ n\n        = ((y ξ x n / ξ ^ n) - 1) * ξ ^ n : by { rw [sub_mul, one_mul, div_mul_cancel _ (h_one _).ne'], }\n    ... ≤ ⌊(y ξ x n / ξ ^ n)⌋ * ξ ^ n : (mul_le_mul_right (h_one n)).mpr (h_left n hn) },\n  replace h_left : ∀ᶠ n in at_top, y ξ x n - ξ ^ n ≤ (⌊(y ξ x n / ξ ^ n)⌋ : ℝ) * ξ ^ n,\n  { simp only [eventually_at_top], use [1, h_left] },\n  have : tendsto (λ n, y ξ x n - ξ ^ n) at_top (𝓝 (exists_limit_y ξ x).some),\n  { convert tendsto.add (exists_limit_y ξ x).some_spec (limit_neg_geometric ξ),\n    rw add_zero } ,\n  have h₁ := (le_of_tendsto_of_tendsto this\n    (summable_floor ξ x ξ₀ _).tendsto_at_top_zero h_left).antisymm (le_of_tendsto_of_tendsto\n    (summable_floor ξ x ξ₀ _).tendsto_at_top_zero (exists_limit_y ξ x).some_spec h_right),\n  have := (exists_limit_y ξ x).some_spec,\n  rwa h₁ at this,\n  all_goals {rw [← nnreal.coe_lt_coe, nnreal.coe_one, subtype.coe_mk], exact fact.out _},\nend\n\nlemma has_sum_x [fact (ξ < 1)] : has_sum (λ i, (⌊(((y ξ x i) / ξ ^ i) : ℝ)⌋ : ℝ) * (ξ ^ i)) x :=\nbegin\n  let ξ₀ : ℝ≥0 := ⟨ξ, le_of_lt (fact.out _)⟩,\n  apply (summable_floor ξ x ξ₀ _).has_sum_iff_tendsto_nat.mpr,\n  simp_rw [subtype.coe_mk, ← (finite_sum' ξ x), sub_eq_add_neg],\n  nth_rewrite_rhs 0 [← add_zero x],\n  apply @tendsto.const_add ℕ ℝ _ _ _ x 0 _ at_top,\n  rw ← neg_zero,\n  refine tendsto.neg (limit_y ξ x),\n  { rw [← nnreal.coe_lt_coe, nnreal.coe_one, subtype.coe_mk],\n    exact fact.out _},\nend\n\nend summability\n\nsection theta_surj\n\n\n/--The map `ϑ` defined in Theorem 6.9 of Analytic.pdf. Given the definition of `tsum` we do not need\n to require that `r ≤ ξ` to simply define `ϑ`.-/\n\ndef seval_ℒ {r : ℝ≥0} (S : Fintype) (s : S): (laurent_measures r S) →\n  (laurent_measures r (Fintype.of punit)) := λ F, ⟨(λ _, F s), (λ _, F.2 s)⟩\n\ndef ϑ₀ (r : ℝ≥0) : (laurent_measures r (Fintype.of punit)) → ℝ :=\n  λ F, tsum (λ n, (F punit.star n) * ξ ^ n)--TODO: remove this\n\ndef ϑ (r p : ℝ≥0) (S : Fintype) : (laurent_measures r S) → real_measures p S :=\n  λ F s, tsum (λ n, (F s n) * ξ ^ n)\n\n@[nolint unused_arguments]\ndef ϑ' (r p: ℝ≥0) (S : Fintype) : (laurent_measures r S) → (S → ℝ) :=\n  λ F s, (ϑ₀ ξ r) (seval_ℒ S s F)\n\n\nlemma ϑ_eq_ϑ' : ϑ = ϑ' := rfl\n\ndef ϑ_section (r p : ℝ≥0) (S : Fintype) (g : real_measures p S) [fact (r < 1)] [fact (0 < ξ)]\n   [fact (ξ < 1)] : (S → ℤ → ℤ) := λ s m, int.rec_on m (λ i, ⌊((y ξ (g s) i) / ξ ^ i)⌋) (0)\n\nlemma summable_ϑ_section (r p : ℝ≥0) (S : Fintype) (g : real_measures p S) [fact (r < 1)]\n  [fact (0 < ξ)] [fact (ξ < 1)] : ∀ s, summable (λ n, ∥(ϑ_section ξ r p S g ) s n∥₊ * r ^ n) :=\nbegin\n  let F₀ := ϑ_section ξ r p S g,\n  have hinj : function.injective (coe : ℕ → ℤ) := by {apply int.coe_nat_inj},\n  have h_aux : ∀ s : S, ∀ n : ℤ, n ∉ set.range (coe : ℕ → ℤ) → F₀ s n = 0,\n  { rintros s ( _ | _ ),\n    simp only [is_empty.forall_iff, set.mem_range_self, not_true, int.of_nat_eq_coe],\n    intro,\n    refl },\n  have h_range_norm : ∀ s : S, ∀ n : ℤ, n ∉ set.range (coe : ℕ → ℤ) → ∥F₀ s n ∥₊ * r ^ n = 0,\n  { intros s n,\n    specialize h_aux s n,\n    simp only [h_aux, int.cast_eq_zero, mul_eq_zero, nnnorm_eq_zero],\n    tauto},\n  intro s,\n  apply (@function.injective.summable_iff _ _ _ _ _ _ _ hinj (h_range_norm s)).mp,\n  exact summable_nnnorm ξ (g s) r (fact.out _),\nend\n\ntheorem ϑ_surjective (r p : ℝ≥0) (S : Fintype) (g : real_measures p S) [fact (r < 1)] [fact (0 < ξ)]\n   [fact (ξ < 1)] : ∃ (F : laurent_measures r S), (ϑ ξ r p S F) = g :=\nbegin\n  have hinj : function.injective (coe : ℕ → ℤ) := by {apply int.coe_nat_inj},\n    let F : laurent_measures r S := ⟨ϑ_section ξ r p S g, summable_ϑ_section ξ r p S g⟩,\n    have h_aux : ∀ s : S, ∀ n : ℤ, n ∉ set.range (coe : ℕ → ℤ) → F s n = 0,\n    { rintros s ( _ | _ ),\n      simp only [is_empty.forall_iff, set.mem_range_self, not_true, int.of_nat_eq_coe],\n      intro,\n      refl },\n    have h_range : ∀ s : S, ∀ n : ℤ, n ∉ set.range (coe : ℕ → ℤ) → (F s n : ℝ) * ξ ^ n = 0,\n    { intros n hn,\n    specialize h_aux n hn,\n    simp only [h_aux, int.cast_eq_zero, mul_eq_zero, nnnorm_eq_zero],\n    tauto },\n    use F,\n    have : ∀ s : S, has_sum (λ n, ((F s n) : ℝ) * ξ ^ n) (g s),\n    { intro s,\n      apply (@function.injective.has_sum_iff _ _ _ _ _ _ (g s) _ hinj (h_range s)).mp,\n      exact has_sum_x ξ (g s) },\n    funext,\n    apply has_sum.tsum_eq,\n    exact this s,\nend\n\nend theta_surj\n\n\n\n\n-- theorem ϑ₀_surjective (x : ℝ) (r : ℝ≥0) [fact (r < 1)] [fact (0 < ξ)] [fact (ξ < 1)] :\n--   ∃ (F : laurent_measures r (Fintype.of punit)), (ϑ₀ ξ r F) = x :=\n-- begin\n--   let f₀ : ℤ → ℤ := λ m, int.rec_on m (λ i, ⌊((y ξ x i) / ξ ^ i)⌋) (0),\n--   let F₀ : Fintype.of punit → ℤ → ℤ := λ a, f₀,\n--   have hinj : function.injective (coe : ℕ → ℤ) := by {apply int.coe_nat_inj},\n--   have h_aux : ∀ n : ℤ, n ∉ set.range (coe : ℕ → ℤ) → f₀ n = 0,\n--   { rintro ( _ | _ ),\n--     simp only [is_empty.forall_iff, set.mem_range_self, not_true, int.of_nat_eq_coe],\n--     intro,\n--     refl },\n--   have h_range : ∀ n : ℤ,\n--     n ∉ set.range (coe : ℕ → ℤ) → (F₀ punit.star n : ℝ) * ξ ^ n = 0,\n--   swap,\n--   have h_range_norm : ∀ n : ℤ,\n--     n ∉ set.range (coe : ℕ → ℤ) → ∥F₀ punit.star n ∥ * r ^ n = 0,\n--   swap,\n--   { have HF₀ : ∀ (s : Fintype.of punit), summable (λ (n : ℤ), ∥F₀ s n∥ * r ^ n),\n--     { intro s,\n--       apply (@function.injective.summable_iff _ _ _ _ _ _ _ hinj h_range_norm).mp,\n--       apply summable_norm ξ x r (fact.out _) },\n--     let F : laurent_measures r (Fintype.of punit) := ⟨F₀, HF₀⟩,\n--     use F,\n--     have : has_sum (λ n, ((F₀ punit.star n) : ℝ) * ξ ^ n) x,\n--     { apply (@function.injective.has_sum_iff _ _ _ _ _ _ x _ hinj h_range).mp,\n--       exact has_sum_x ξ x },\n--     apply has_sum.tsum_eq,\n--     exact this },\n--   all_goals { intros n hn,\n--     specialize h_aux n hn,\n--     simp only [h_aux, int.cast_eq_zero, mul_eq_zero, norm_eq_zero],\n--     tauto },\n-- end\n\nend theta\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/laurent_measures/theta.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4667802099398683}}
{"text": "import\n  data.real.sqrt\n  extra.real_hom.semifield_char0_hom\n  extra.real_hom.nnreal_odd_ext\n  extra.real_prop.real_quadratic_sol\n\n/-! # IMO 2012 A5 -/\n\nnamespace IMOSL\nnamespace IMO2012A5\n\nopen function nnreal\nopen_locale nnreal\n\ndef good {R S : Type*} [ring R] [ring S] (f : R → S) :=\n  ∀ x y : R, f (1 + x * y) - f(x + y) = f x * f y\n\n\n\nsection extra_lemmas\n\nprivate lemma one_add_mul_sub_add {R : Type*} [ring R] (x y : R) :\n  (1 + x * y) - (x + y) = (x - 1) * (y - 1) :=\n  by rw [add_comm, ← sub_add_sub_comm, ← mul_sub_one,\n    ← neg_sub y, ← sub_eq_add_neg, ← sub_one_mul]\n\nprivate lemma one_add_mul_add_add {R : Type*} [ring R] (x y : R) :\n  (1 + x * y) + (x + y) = (x + 1) * (y + 1) :=\n  by rw [add_add_add_comm, ← add_one_mul, add_comm 1 x, ← mul_one_add, add_comm 1 y]\n\nend extra_lemmas\n\n\n\n\n\nsection basic_results\n\nsection answer\n\nvariables {R S : Type*} [ring R]\n\nprivate lemma good_zero [ring S] : good (λ (_ : R), (0 : S)) :=\n  λ x y, by rw [sub_zero, mul_zero]\n\nprivate lemma good_hom_sub_one [ring S] (φ : R →+* S) :\n  good (λ (x : R), φ x - 1) :=\n  λ x y, by rw [sub_sub_sub_cancel_right, φ.map_add, φ.map_one, φ.map_add, φ.map_mul];\n    exact one_add_mul_sub_add (φ x) (φ y)\n\nprivate lemma good_hom_sq_sub_one [comm_ring S] (φ : R →+* S) :\n  good (λ (x : R), φ x ^ 2 - 1) :=\n  λ x y, by rw [sub_sub_sub_cancel_right, φ.map_add, φ.map_one, φ.map_add, φ.map_mul, sq_sub_sq,\n    one_add_mul_sub_add, one_add_mul_add_add, mul_mul_mul_comm, ← sq_sub_sq, ← sq_sub_sq, one_pow]\n\nend answer\n\n\nprivate lemma good_subst_neg_one {R S : Type*} [ring R] [ring S] {f : R → S} (h : good f) (x : R) :\n  f x - f (-x) = f (-1) * f (1 - x) :=\n  by rw [← h, neg_one_mul, neg_sub, add_sub_cancel'_right, ← add_sub_assoc, neg_add_self, zero_sub]\n\n\nsection domain\n\nvariables {R S : Type*} [ring R] [comm_ring S] [is_domain S] {f : R → S} (h : good f)\ninclude h\n\nprivate lemma good_map_one : f 1 = 0 :=\n  by replace h := h 1 1; rwa [mul_one, sub_self, zero_eq_mul_self] at h\n\nprivate lemma good_eq_zero_of_map_zero_ne_neg_one (h0 : f 0 ≠ -1) : f = 0 :=\n  funext (λ x, by have h1 := h x 0; rwa [mul_zero, add_zero, good_map_one h, zero_sub,\n    add_zero, ← mul_neg_one, mul_eq_mul_left_iff, or_iff_right h0.symm] at h1)\n\nend domain\n\nend basic_results\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nsection results\n\nvariables {R : Type*} [comm_ring R] [is_domain R] {f : ℝ → R} (feq : good f)\ninclude feq\n\n\nsection case_fneg1_ne_0\n\nvariable (fneg1_ne_0 : f (-1) ≠ 0)\ninclude fneg1_ne_0\n\nprivate lemma lem2_1 : f 0 = -1 :=\nbegin\n  contrapose! fneg1_ne_0 with f0_ne_neg1,\n  rw [good_eq_zero_of_map_zero_ne_neg_one feq f0_ne_neg1, pi.zero_apply]\nend\n\nprivate lemma lem2_2 (x : ℝ) : f (2 - x) = -f x :=\nbegin\n  have h := good_subst_neg_one feq (-(1 - x)),\n  rwa [neg_neg, ← neg_sub, good_subst_neg_one feq (1 - x), ← mul_neg, mul_eq_mul_left_iff,\n       or_iff_left fneg1_ne_0, sub_sub_cancel, sub_neg_eq_add, ← add_sub_assoc, eq_comm] at h\nend\n\nprivate lemma lem2_3 (x : ℝ) : f (x + 2) = f x + 2 :=\nbegin\n  revert x; suffices : ∀ x : ℝ, x ≤ 0 → f (x + 2) - f x = f 3 - f 1,\n  { have h := lem2_2 feq fneg1_ne_0 0,\n    rw [sub_zero, lem2_1 feq fneg1_ne_0, neg_neg] at h,\n    have h0 := this 0 (le_refl 0),\n    rw [← h0, zero_add, h, lem2_1 feq fneg1_ne_0, sub_neg_eq_add, ← bit0] at this,\n    clear h0; intros x,\n    cases le_total x 0 with h0 h0,\n    rw [← sub_eq_iff_eq_add', this x h0],\n    rw [← this (-x) (by rwa neg_nonpos), add_comm (-x), ← sub_eq_add_neg,\n        lem2_2 feq fneg1_ne_0, ← add_sub_assoc, add_neg_self, zero_sub,\n        ← lem2_2 feq fneg1_ne_0, sub_neg_eq_add, add_comm] },\n  intros x h,\n  obtain ⟨u, v, h0, h1⟩ : ∃ u v : ℝ, u + v = 1 ∧ u * v = x - 1 :=\n  begin\n    refine extra.exists_add_eq_mul_eq (le_trans _ (sq_nonneg 1)),\n    exact mul_nonpos_of_nonneg_of_nonpos zero_le_four (sub_nonpos_of_le (le_trans h zero_le_one))\n  end,\n  have h2 := feq (2 - u) (2 - v),\n  rw [lem2_2 feq fneg1_ne_0, lem2_2 feq fneg1_ne_0, neg_mul_neg, ← feq, h1,\n      sub_add_sub_comm, h0, sub_eq_sub_iff_sub_eq_sub, add_sub_cancel'_right] at h2,\n  convert h2 using 3,\n  work_on_goal 2 { rw [eq_sub_iff_add_eq, bit1, add_assoc, ← bit0] },\n  rw [add_comm (1 : ℝ), ← sub_eq_sub_iff_add_eq_add, ← h1, sub_mul, mul_sub,\n      mul_sub, ← sub_add, sub_sub, mul_comm u 2, ← mul_add, add_comm v u, h0,\n      mul_one, two_mul, add_sub_cancel, add_sub_cancel']\nend\n\nprivate lemma lem2_4 (x : ℝ) : f (-x) = -(2 + f x) :=\nbegin\n  have h := lem2_3 feq fneg1_ne_0 (-x),\n  rw [add_comm, ← sub_eq_add_neg, lem2_2 feq fneg1_ne_0, ← sub_eq_iff_eq_add] at h,\n  rw [← h, sub_eq_add_neg, add_comm, neg_add]\nend\n\nprivate lemma lem2_5 (x y : ℝ) : f (x + y) = f x + f y + 1 :=\nbegin\n  have h := feq (-x) (-y),\n  rw [neg_mul_neg, ← neg_add, lem2_4 feq fneg1_ne_0, sub_neg_eq_add, lem2_4 feq fneg1_ne_0,\n      lem2_4 feq fneg1_ne_0, neg_mul_neg, add_mul, mul_add, mul_add, ← feq, ← sub_eq_zero] at h,\n  replace h : 2 * (f (x + y) - (f x + f y + 1)) = 0 := by rw ← h; ring,\n  rwa [mul_eq_zero, sub_eq_zero, or_comm] at h,\n  cases h with h h,\n  exact h,\n  have h0 := lem2_3 feq fneg1_ne_0 (-1),\n  rw [bit0, neg_add_cancel_comm_assoc, h, add_zero, good_map_one feq, eq_comm] at h0,\n  exfalso; exact fneg1_ne_0 h0\nend\n\nprivate lemma lem2_6 : ∃ φ : ℝ →+* R, f = φ - 1 :=\nbegin\n  use f + 1; simp,\n  exact good_map_one feq,\n  intros x y,\n  have h := feq x y,\n  rw [sub_eq_iff_eq_add, lem2_5 feq fneg1_ne_0, good_map_one feq, zero_add] at h,\n  rw [h, lem2_5 feq fneg1_ne_0, add_one_mul, mul_add_one, add_assoc, add_assoc],\n  rw [lem2_1 feq fneg1_ne_0, neg_add_self],\n  intros x y; rw [lem2_5 feq fneg1_ne_0, add_assoc, add_add_add_comm]\nend\n\nend case_fneg1_ne_0\n\n\n\nsection case_fneg1_eq_0\n\nvariable (fneg1_eq_0 : f (-1) = 0)\ninclude fneg1_eq_0\n\nprivate lemma lem3_1 (x : ℝ) : f (-x) = f x :=\n  by rw [eq_comm, ← sub_eq_zero, good_subst_neg_one feq x, fneg1_eq_0, zero_mul]\n\nprivate lemma lem3_2 (u v : ℝ≥0) : f (1 + v / 4) - f (1 - v / 4) = f (sqrt (u + v)) - f (sqrt u) :=\nbegin\n  obtain ⟨x, y, h, h0⟩ : ∃ x y : ℝ, x + y = sqrt (u + v) ∧ x * y = v / 4 :=\n  begin\n    apply extra.exists_add_eq_mul_eq,\n    rw [real.coe_sqrt, nonneg.coe_add, real.sq_sqrt, mul_div_cancel'],\n    exacts [le_add_of_nonneg_left (coe_nonneg u), four_ne_zero,\n            add_nonneg (coe_nonneg u) (coe_nonneg v)]\n  end,\n  rw [← h, ← h0, sub_eq_sub_iff_sub_eq_sub, feq, ← lem3_1 feq fneg1_eq_0 y,\n      ← feq, mul_neg, ← sub_eq_add_neg, sub_right_inj, ← sub_eq_add_neg],\n  suffices : (u : ℝ) = (x - y) ^ 2,\n  { rw [real.coe_sqrt, this, real.sqrt_sq_eq_abs],\n    cases le_total 0 (x - y) with h1 h1,\n    rw abs_eq_self.mpr h1,\n    rw [abs_eq_neg_self.mpr h1, lem3_1 feq fneg1_eq_0] },\n  replace h := congr_arg (λ x, x ^ 2) h; simp only [] at h,\n  rw [← nonneg.coe_pow, sq_sqrt, nonneg.coe_add, ← sub_eq_iff_eq_add] at h,\n  rw [← h, sub_eq_iff_eq_add', ← sub_eq_iff_eq_add, add_sq, sub_sq, add_sub_add_right_eq_sub,\n      add_sub_sub_cancel, mul_assoc, ← add_mul, h0, ← bit0, mul_div_cancel'],\n  exact four_ne_zero\nend\n\nvariable (f0_eq_neg1 : f 0 = -1)\ninclude f0_eq_neg1\n\nprivate lemma lem3_3 (u v : ℝ≥0) : f (sqrt (u + v)) = f (sqrt u) + f (sqrt v) + 1 :=\n  by rw [add_assoc, ← sub_eq_iff_eq_add', ← lem3_2 feq fneg1_eq_0, lem3_2 feq fneg1_eq_0 0,\n         zero_add, sqrt_zero, nonneg.coe_zero, sub_eq_add_neg, f0_eq_neg1, neg_neg]\n\nprivate lemma lem3_4 (u v : ℝ≥0) : f (u * v) + 1 = (f u + 1) * (f v + 1) :=\nbegin\n  revert u v; suffices : ∀ u v : ℝ≥0, f (u + v) = f u + f v + f (sqrt (2 * u * v)) + 2,\n  { intros u v,\n    have h := feq u v,\n    rw [← nonneg.coe_one, ← nonneg.coe_mul, this, nonneg.coe_one, ← lem3_1 feq fneg1_eq_0,\n        fneg1_eq_0, zero_add, mul_one, this, add_sub_add_right_eq_sub, mul_assoc,\n        add_sub_add_right_eq_sub, nonneg.coe_mul, sub_eq_iff_eq_add, ← add_assoc] at h,\n    rw [h, add_one_mul, mul_add_one, ← add_assoc] },\n  intros u v,\n  have h := lem3_3 feq fneg1_eq_0 f0_eq_neg1,\n  rw [← nonneg.coe_add, ← sqrt_sq (u + v), add_sq, h, sqrt_sq, h, sqrt_sq,\n      add_right_comm _ 1 (f v), add_right_comm (f u), add_assoc, ← bit0]\nend\n\nprivate lemma lem3_5 : ∃ φ : ℝ≥0 →+* R, f = λ x : ℝ, φ (x.nnabs ^ 2) - 1 :=\nbegin\n  use λ x, f (sqrt x) + 1,\n  rw [sqrt_one, nonneg.coe_one, good_map_one feq, zero_add],\n  intros x y; rw [sqrt_mul, nonneg.coe_mul, lem3_4 feq fneg1_eq_0 f0_eq_neg1],\n  rw [sqrt_zero, nonneg.coe_zero, f0_eq_neg1, neg_add_self],\n  intros x y; rw [lem3_3 feq fneg1_eq_0 f0_eq_neg1, add_add_add_comm, add_assoc],\n  funext x,\n  rw [ring_hom.coe_mk, add_sub_cancel, sqrt_sq, real.coe_nnabs],\n  cases le_total 0 x with h h,\n  rw abs_eq_self.mpr h,\n  rw [abs_eq_neg_self.mpr h, lem3_1 feq fneg1_eq_0]\nend\n\nend case_fneg1_eq_0\n\nend results\n\n\n\n\n/-- Final solution -/\ntheorem final_solution_general {R : Type*} [comm_ring R] [is_domain R] (f : ℝ → R) : good f ↔\n  f = 0 ∨ (∃ φ : ℝ →+* R, f = φ - 1) ∨ (∃ φ : ℝ≥0 →+* R, f = λ x : ℝ, φ (x.nnabs ^ 2) - 1) :=\nbegin\n  split,\n  { intros feq,\n    cases ne_or_eq (f 0) (-1) with h h,\n    left; exact good_eq_zero_of_map_zero_ne_neg_one feq h,\n    right; cases eq_or_ne (f (-1)) 0 with h0 h0,\n    right; exact lem3_5 feq h0 h,\n    left; exact lem2_6 feq h0 },\n  { rintros (rfl | ⟨φ, rfl⟩ | ⟨φ, h⟩),\n    exact good_zero,\n    exact good_hom_sub_one φ,\n    intros x y,\n    conv at h { congr, skip, funext,\n      rw [← extra.nnreal_ring_hom.coe_fn_apply, nnreal.coe_pow, real.coe_nnabs, pow_bit0_abs] },\n    subst h; simp only [],\n    rw [add_sq, add_sq, one_pow, mul_one, sub_sub_sub_cancel_right, add_right_comm, mul_assoc,\n        add_right_comm (x ^ 2), map_add, map_add, map_add, add_sub_add_right_eq_sub,\n        map_one, map_add, mul_pow, map_mul, sub_one_mul, mul_sub_one, sub_sub, ← add_sub_assoc,\n        ← sub_add, add_comm, add_sub_right_comm] }\nend\n\n/-- Final solution, case char(R) ≠ 0 -/\ntheorem final_solution_char_ne_0 {R : Type*} [comm_ring R] [is_domain R]\n    (p : ℕ) [fact (p ≠ 0)] [char_p R p] (f : ℝ → R) : good f ↔ f = 0 :=\n  by rw [final_solution_general, is_empty.exists_iff, is_empty.exists_iff, or_false, or_false]\n\n/-- Final solution, case R = ℝ -/\ntheorem final_solution_real (f : ℝ → ℝ) : good f ↔ f = 0 ∨ (f = id - 1) ∨ (f = λ x, x ^ 2 - 1) :=\nbegin\n  rw [final_solution_general, unique.exists_iff, unique.exists_iff],\n  unfold default; refine or_congr_right' (or_congr_right' _),\n  conv_lhs { congr, skip, funext,\n    rw [nnreal.coe_to_real_hom, nnreal.coe_pow, real.coe_nnabs, pow_bit0_abs] }\nend\n\nend IMO2012A5\nend IMOSL\n", "meta": {"author": "mortarsanjaya", "repo": "imo-A-and-N", "sha": "645a924da7442f41d56ee6a0d96dc4d777b593a9", "save_path": "github-repos/lean/mortarsanjaya-imo-A-and-N", "path": "github-repos/lean/mortarsanjaya-imo-A-and-N/imo-A-and-N-645a924da7442f41d56ee6a0d96dc4d777b593a9/src/IMO2012/A5/A5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.466526328331623}}
{"text": "import .util\n\nnamespace inverse\n    open function\n    open classical (renaming some → unexists) (renaming some_spec → unexists_prop)\n    open classical (choice prop_decidable)\n    local attribute [instance] prop_decidable\n\n    open util\n\n    -- one-sided inverses:\n    class invertible.one_sided {T T': Sort _} (f: T → T') :=\n        (g: T' → T)\n        (left_inv:\n            ∀ x: T,\n            g (f x) = x)\n\n    @[reducible, inline] def inv {T T': Sort _} (f: T → T') [hf: invertible.one_sided f]:\n        T' → T := hf.g\n\n    @[simp] theorem inv.elim {T T': Sort _} (f: T → T') [hf: invertible.one_sided f]:\n        ∀ x: T,\n        inv f (f x) = x := by apply hf.left_inv\n\n    instance inv.surjective {T T': Sort _} (f: T → T') [hf: invertible.one_sided f]:\n        surjective (inv f) := begin\n            intro x,\n            apply exists.intro (f x),\n            simp,\n        end\n\n    instance invertible.one_sided.injective {T T': Sort _} (f: T → T') [hf: invertible.one_sided f]:\n        injective f := begin\n            intros x y hxy,\n            have hinvxy: inv f (f x) = inv f (f y) := congr rfl hxy,\n            simp at hinvxy,\n            assumption,\n        end\n\n\n    -- noncomputable inverse:\n    noncomputable def inj_inv {T T': Sort _} [hT: nonempty T] (f: T → T') (y: T'): T :=\n        if h: ∃ x: T, f x = y then\n            unexists h\n        else\n            choice hT\n\n    noncomputable def inj_inv.is_inverse {T T': Sort _} [hT: nonempty T] (f: T → T') [hf: injective f]:\n        invertible.one_sided f := {\n            g := inj_inv f,\n            left_inv := begin\n                intros,\n                rw [inj_inv],\n                cases em (∃ (x' : T), f x' = f x),\n                case or.inl {\n                    rw [dif_pos h],\n                    apply hf,\n                    exact unexists_prop h,\n                },\n                case or.inr {\n                    rw [dif_neg h],\n                    apply false.elim,\n                    apply h,\n                    apply exists.intro x,\n                    refl,\n                },\n            end,\n        }\n\n\n    -- two-sided inverses:\n    class invertible {T T': Sort _} (f: T → T') extends invertible.one_sided f :=\n        (right_inv:\n            ∀ y: T',\n            f (g y) = y)\n\n    instance invertible.surjective {T T': Sort _} (f: T → T') [hf: invertible f]:\n        surjective f := begin\n            intro y,\n            apply exists.intro ((inv f) y),\n            rw [hf.right_inv],\n        end\n\n    instance invertible.bijective {T T': Sort _} (f: T → T') [hf: invertible f]:\n        bijective f := {\n            -- injective:\n            left := by apply invertible.one_sided.injective,\n            -- surjective:\n            right := by apply invertible.surjective,\n        }\n\n    instance invertible.of_surjective {T T': Sort _} (f: T → T') [hfinv: invertible.one_sided f] [hfsur: surjective f]:\n        invertible f := begin\n            split,\n            intros,\n            have hex := hfsur y,\n            apply exists.elim hex,\n            intros x hx,\n            rw [←hx],\n            exact congr rfl (invertible.one_sided.left_inv f x),\n        end\n\n    instance inv.invertible {T T': Sort _} (f: T → T') [hf: invertible f]:\n        invertible (inv f) := {\n            g := f,\n            left_inv := hf.right_inv,\n            right_inv := hf.left_inv,\n        }\n\n    @[simp] theorem inv.elim_of_inv {T T': Sort _} (f: T → T') [hf: invertible f]:\n        inv (inv f) = f := by rw [inv.invertible]\n\n    theorem inv.uniq {T T': Sort _} (f: T → T') [hf: invertible f]:\n        ∀ {g: T' → T},\n        (∀ x: T, g (f x) = x) →\n        g = inv f := begin\n            intros g hg,\n            funext,\n            have hfsurx := invertible.surjective f x,\n            apply exists.elim hfsurx,\n            intros y hy,\n            rw [←hy, hg y],\n            rw [inv, hf.left_inv],\n        end\n\n    instance inv.injective {T T': Sort _} (f: T → T') [hf: invertible f]:\n        injective (inv f) := begin\n            intros x y hxy,\n            have hfx := invertible.surjective f x,\n            have hfy := invertible.surjective f y,\n            apply exists.elim hfx,\n            intros a ha,\n            apply exists.elim hfy,\n            intros b hb,\n            rw [←ha, ←hb] at *,\n            simp at hxy,\n            rw [hxy],\n        end\n\n\n    -- id:\n    instance id.invertible {T: Sort _}:\n        invertible (@id T) := {\n            g := id,\n            left_inv := begin\n                intros,\n                refl,\n            end,\n            right_inv := begin\n                intros,\n                refl,\n            end,\n        }\nend inverse\n", "meta": {"author": "evhub", "repo": "lean-math-examples", "sha": "dec44bf581a1e9d5bf0b5261803a43fe8fd350e1", "save_path": "github-repos/lean/evhub-lean-math-examples", "path": "github-repos/lean/evhub-lean-math-examples/lean-math-examples-dec44bf581a1e9d5bf0b5261803a43fe8fd350e1/inverse.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.6001883592602049, "lm_q1q2_score": 0.46652632833162294}}
{"text": "import tactic.qify\n\nexample (a b : ℕ) : (a : ℚ) ≤ b ↔ a ≤ b := by qify ; refl\nexample (a b : ℕ) : (a : ℚ) < b ↔ a < b := by qify ; refl\nexample (a b : ℕ) : (a : ℚ) = b ↔ a = b := by qify ; refl\nexample (a b : ℕ) : (a : ℚ) ≠ b ↔ a ≠ b := by qify ; refl\n\nexample (a b : ℤ) : (a : ℚ) ≤ b ↔ a ≤ b := by qify ; refl\nexample (a b : ℤ) : (a : ℚ) < b ↔ a < b := by qify ; refl\nexample (a b : ℤ) : (a : ℚ) = b ↔ a = b := by qify ; refl\nexample (a b : ℤ) : (a : ℚ) ≠ b ↔ a ≠ b := by qify ; refl\n\nexample (a b c : ℕ) (h : a - b = c) (hab : b ≤ a) : a = c + b :=\nbegin\n  qify [hab] at h ⊢, -- `zify` does the same thing here.\n  exact sub_eq_iff_eq_add.1 h,\nend\n\nexample (a b c : ℤ) (h : a / b = c) (hab : b ∣ a) (hb : b ≠ 0) : a = c * b :=\nbegin\n  qify [hab] at h hb ⊢,\n  exact (div_eq_iff hb).1 h,\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/qify.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4665263221389698}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport measure_theory.measure.ae_measurable\n\n/-!\n# Typeclasses for measurability of operations\n\nIn this file we define classes `has_measurable_mul` etc and prove dot-style lemmas\n(`measurable.mul`, `ae_measurable.mul` etc). For binary operations we define two typeclasses:\n\n- `has_measurable_mul` says that both left and right multiplication are measurable;\n- `has_measurable_mul₂` says that `λ p : α × α, p.1 * p.2` is measurable,\n\nand similarly for other binary operations. The reason for introducing these classes is that in case\nof topological space `α` equipped with the Borel `σ`-algebra, instances for `has_measurable_mul₂`\netc require `α` to have a second countable topology.\n\nWe define separate classes for `has_measurable_div`/`has_measurable_sub`\nbecause on some types (e.g., `ℕ`, `ℝ≥0∞`) division and/or subtraction are not defined as `a * b⁻¹` /\n`a + (-b)`.\n\nFor instances relating, e.g., `has_continuous_mul` to `has_measurable_mul` see file\n`measure_theory.borel_space`.\n\n## Implementation notes\n\nFor the heuristics of `@[to_additive]` it is important that the type with a multiplication\n(or another multiplicative operations) is the first (implicit) argument of all declarations.\n\n## Tags\n\nmeasurable function, arithmetic operator\n\n## Todo\n\n* Uniformize the treatment of `pow` and `smul`.\n* Use `@[to_additive]` to send `has_measurable_pow` to `has_measurable_smul₂`.\n* This might require changing the definition (swapping the arguments in the function that is\n  in the conclusion of `measurable_smul`.)\n-/\n\nuniverses u v\n\nopen_locale big_operators pointwise measure_theory\nopen measure_theory\n\n/-!\n### Binary operations: `(+)`, `(*)`, `(-)`, `(/)`\n-/\n\n/-- We say that a type `has_measurable_add` if `((+) c)` and `(+ c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (+)` see `has_measurable_add₂`. -/\nclass has_measurable_add (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_const_add : ∀ c : M, measurable ((+) c))\n(measurable_add_const : ∀ c : M, measurable (+ c))\n\nexport has_measurable_add (measurable_const_add measurable_add_const)\n\n/-- We say that a type `has_measurable_add` if `uncurry (+)` is a measurable functions.\nFor a typeclass assuming measurability of `((+) c)` and `(+ c)` see `has_measurable_add`. -/\nclass has_measurable_add₂ (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_add : measurable (λ p : M × M, p.1 + p.2))\n\nexport has_measurable_add₂ (measurable_add)\n  has_measurable_add (measurable_const_add measurable_add_const)\n\n/-- We say that a type `has_measurable_mul` if `((*) c)` and `(* c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (*)` see `has_measurable_mul₂`. -/\n@[to_additive]\nclass has_measurable_mul (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_const_mul : ∀ c : M, measurable ((*) c))\n(measurable_mul_const : ∀ c : M, measurable (* c))\n\nexport has_measurable_mul (measurable_const_mul measurable_mul_const)\n\n/-- We say that a type `has_measurable_mul` if `uncurry (*)` is a measurable functions.\nFor a typeclass assuming measurability of `((*) c)` and `(* c)` see `has_measurable_mul`. -/\n@[to_additive has_measurable_add₂]\nclass has_measurable_mul₂ (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_mul : measurable (λ p : M × M, p.1 * p.2))\n\nexport has_measurable_mul₂ (measurable_mul)\n\nsection mul\n\nvariables {M α : Type*} [measurable_space M] [has_mul M] {m : measurable_space α}\n  {f g : α → M} {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_mul [has_measurable_mul M] (hf : measurable f) (c : M) :\n  measurable (λ x, c * f x) :=\n(measurable_const_mul c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.const_mul [has_measurable_mul M] (hf : ae_measurable f μ) (c : M) :\n  ae_measurable (λ x, c * f x) μ :=\n(has_measurable_mul.measurable_const_mul c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.mul_const [has_measurable_mul M] (hf : measurable f) (c : M) :\n  measurable (λ x, f x * c) :=\n(measurable_mul_const c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.mul_const [has_measurable_mul M] (hf : ae_measurable f μ) (c : M) :\n  ae_measurable (λ x, f x * c) μ :=\n(measurable_mul_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.mul' [has_measurable_mul₂ M] (hf : measurable f) (hg : measurable g) :\n  measurable (f * g) :=\nmeasurable_mul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma measurable.mul [has_measurable_mul₂ M] (hf : measurable f) (hg : measurable g) :\n  measurable (λ a, f a * g a) :=\nmeasurable_mul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul' [has_measurable_mul₂ M] (hf : ae_measurable f μ)\n  (hg : ae_measurable g μ) :\n  ae_measurable (f * g) μ :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul [has_measurable_mul₂ M] (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ a, f a * g a) μ :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_mul₂.to_has_measurable_mul [has_measurable_mul₂ M] :\n  has_measurable_mul M :=\n⟨λ c, measurable_const.mul measurable_id, λ c, measurable_id.mul measurable_const⟩\n\n@[to_additive]\ninstance pi.has_measurable_mul {ι : Type*} {α : ι → Type*} [∀ i, has_mul (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_mul (α i)] :\n  has_measurable_mul (Π i, α i) :=\n⟨λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).const_mul _,\n λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).mul_const _⟩\n\n@[to_additive pi.has_measurable_add₂]\ninstance pi.has_measurable_mul₂ {ι : Type*} {α : ι → Type*} [∀ i, has_mul (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_mul₂ (α i)] :\n  has_measurable_mul₂ (Π i, α i) :=\n⟨measurable_pi_iff.mpr $ λ i, measurable_fst.eval.mul measurable_snd.eval⟩\n\nattribute [measurability] measurable.add' measurable.add ae_measurable.add ae_measurable.add'\n  measurable.const_add ae_measurable.const_add measurable.add_const ae_measurable.add_const\n\nend mul\n\n/-- A version of `measurable_div_const` that assumes `has_measurable_mul` instead of\n  `has_measurable_div`. This can be nice to avoid unnecessary type-class assumptions. -/\n@[to_additive /-\" A version of `measurable_sub_const` that assumes `has_measurable_add` instead of\n  `has_measurable_sub`. This can be nice to avoid unnecessary type-class assumptions. \"-/]\nlemma measurable_div_const' {G : Type*} [div_inv_monoid G] [measurable_space G]\n  [has_measurable_mul G] (g : G) : measurable (λ h, h / g) :=\nby simp_rw [div_eq_mul_inv, measurable_mul_const]\n\n/-- This class assumes that the map `β × γ → β` given by `(x, y) ↦ x ^ y` is measurable. -/\nclass has_measurable_pow (β γ : Type*) [measurable_space β] [measurable_space γ] [has_pow β γ] :=\n(measurable_pow : measurable (λ p : β × γ, p.1 ^ p.2))\n\nexport has_measurable_pow (measurable_pow)\n\n/-- `monoid.has_pow` is measurable. -/\ninstance monoid.has_measurable_pow (M : Type*) [monoid M] [measurable_space M]\n  [has_measurable_mul₂ M] : has_measurable_pow M ℕ :=\n⟨measurable_from_prod_countable $ λ n, begin\n  induction n with n ih,\n  { simp only [pow_zero, ←pi.one_def, measurable_one] },\n  { simp only [pow_succ], exact measurable_id.mul ih }\nend⟩\n\nsection pow\n\nvariables {β γ α : Type*} [measurable_space β] [measurable_space γ] [has_pow β γ]\n  [has_measurable_pow β γ] {m : measurable_space α} {μ : measure α} {f : α → β} {g : α → γ}\n\ninclude m\n\n@[measurability]\nlemma measurable.pow (hf : measurable f) (hg : measurable g) :\n  measurable (λ x, f x ^ g x) :=\nmeasurable_pow.comp (hf.prod_mk hg)\n\n@[measurability]\nlemma ae_measurable.pow (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ x, f x ^ g x) μ :=\nmeasurable_pow.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability]\nlemma measurable.pow_const (hf : measurable f) (c : γ) :\n  measurable (λ x, f x ^ c) :=\nhf.pow measurable_const\n\n@[measurability]\nlemma ae_measurable.pow_const (hf : ae_measurable f μ) (c : γ) :\n  ae_measurable (λ x, f x ^ c) μ :=\nhf.pow ae_measurable_const\n\n@[measurability]\nlemma measurable.const_pow (hg : measurable g) (c : β) :\n  measurable (λ x, c ^ g x) :=\nmeasurable_const.pow hg\n\n@[measurability]\nlemma ae_measurable.const_pow (hg : ae_measurable g μ) (c : β) :\n  ae_measurable (λ x, c ^ g x) μ :=\nae_measurable_const.pow hg\n\nomit m\n\nend pow\n\n/-- We say that a type `has_measurable_sub` if `(λ x, c - x)` and `(λ x, x - c)` are measurable\nfunctions. For a typeclass assuming measurability of `uncurry (-)` see `has_measurable_sub₂`. -/\nclass has_measurable_sub (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_const_sub : ∀ c : G, measurable (λ x, c - x))\n(measurable_sub_const : ∀ c : G, measurable (λ x, x - c))\n\nexport has_measurable_sub (measurable_const_sub measurable_sub_const)\n\n/-- We say that a type `has_measurable_sub` if `uncurry (-)` is a measurable functions.\nFor a typeclass assuming measurability of `((-) c)` and `(- c)` see `has_measurable_sub`. -/\nclass has_measurable_sub₂ (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_sub : measurable (λ p : G × G, p.1 - p.2))\n\nexport has_measurable_sub₂ (measurable_sub)\n\n/-- We say that a type `has_measurable_div` if `((/) c)` and `(/ c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (/)` see `has_measurable_div₂`. -/\n@[to_additive] class has_measurable_div (G₀: Type*) [measurable_space G₀] [has_div G₀] : Prop :=\n(measurable_const_div : ∀ c : G₀, measurable ((/) c))\n(measurable_div_const : ∀ c : G₀, measurable (/ c))\n\nexport has_measurable_div (measurable_const_div measurable_div_const)\n\n/-- We say that a type `has_measurable_div` if `uncurry (/)` is a measurable functions.\nFor a typeclass assuming measurability of `((/) c)` and `(/ c)` see `has_measurable_div`. -/\n@[to_additive has_measurable_sub₂]\nclass has_measurable_div₂ (G₀: Type*) [measurable_space G₀] [has_div G₀] : Prop :=\n(measurable_div : measurable (λ p : G₀× G₀, p.1 / p.2))\n\nexport has_measurable_div₂ (measurable_div)\n\nsection div\n\nvariables {G α : Type*} [measurable_space G] [has_div G] {m : measurable_space α} {f g : α → G}\n  {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_div [has_measurable_div G] (hf : measurable f) (c : G) :\n  measurable (λ x, c / f x) :=\n(has_measurable_div.measurable_const_div c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.const_div [has_measurable_div G] (hf : ae_measurable f μ) (c : G) :\n  ae_measurable (λ x, c / f x) μ :=\n(has_measurable_div.measurable_const_div c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.div_const [has_measurable_div G] (hf : measurable f) (c : G) :\n  measurable (λ x, f x / c) :=\n(has_measurable_div.measurable_div_const c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.div_const [has_measurable_div G] (hf : ae_measurable f μ) (c : G) :\n  ae_measurable (λ x, f x / c) μ :=\n(has_measurable_div.measurable_div_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.div' [has_measurable_div₂ G] (hf : measurable f) (hg : measurable g) :\n  measurable (f / g) :=\nmeasurable_div.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma measurable.div [has_measurable_div₂ G] (hf : measurable f) (hg : measurable g) :\n  measurable (λ a, f a / g a) :=\nmeasurable_div.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div' [has_measurable_div₂ G] (hf : ae_measurable f μ)\n  (hg : ae_measurable g μ) :\n  ae_measurable (f / g) μ :=\nmeasurable_div.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div [has_measurable_div₂ G] (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ a, f a / g a) μ :=\nmeasurable_div.comp_ae_measurable (hf.prod_mk hg)\n\nattribute [measurability] measurable.sub measurable.sub' ae_measurable.sub ae_measurable.sub'\n  measurable.const_sub ae_measurable.const_sub measurable.sub_const ae_measurable.sub_const\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_div₂.to_has_measurable_div [has_measurable_div₂ G] :\n  has_measurable_div G :=\n⟨λ c, measurable_const.div measurable_id, λ c, measurable_id.div measurable_const⟩\n\n@[to_additive]\ninstance pi.has_measurable_div {ι : Type*} {α : ι → Type*} [∀ i, has_div (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_div (α i)] :\n  has_measurable_div (Π i, α i) :=\n⟨λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).const_div _,\n λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).div_const _⟩\n\n@[to_additive pi.has_measurable_sub₂]\ninstance pi.has_measurable_div₂ {ι : Type*} {α : ι → Type*} [∀ i, has_div (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_div₂ (α i)] :\n  has_measurable_div₂ (Π i, α i) :=\n⟨measurable_pi_iff.mpr $ λ i, measurable_fst.eval.div measurable_snd.eval⟩\n\n@[measurability]\nlemma measurable_set_eq_fun {m : measurable_space α} {E} [measurable_space E] [add_group E]\n  [measurable_singleton_class E] [has_measurable_sub₂ E] {f g : α → E}\n  (hf : measurable f) (hg : measurable g) :\n  measurable_set {x | f x = g x} :=\nbegin\n  suffices h_set_eq : {x : α | f x = g x} = {x | (f-g) x = (0 : E)},\n  { rw h_set_eq,\n    exact (hf.sub hg) measurable_set_eq, },\n  ext,\n  simp_rw [set.mem_set_of_eq, pi.sub_apply, sub_eq_zero],\nend\n\nlemma null_measurable_set_eq_fun {E} [measurable_space E] [add_group E]\n  [measurable_singleton_class E] [has_measurable_sub₂ E] {f g : α → E}\n  (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  null_measurable_set {x | f x = g x} μ :=\nbegin\n  apply (measurable_set_eq_fun hf.measurable_mk hg.measurable_mk).null_measurable_set.congr,\n  filter_upwards [hf.ae_eq_mk, hg.ae_eq_mk] with x hfx hgx,\n  change (hf.mk f x = hg.mk g x) = (f x = g x),\n  simp only [hfx, hgx],\nend\n\nlemma measurable_set_eq_fun_of_countable {m : measurable_space α} {E} [measurable_space E]\n  [measurable_singleton_class E] [countable E] {f g : α → E}\n  (hf : measurable f) (hg : measurable g) :\n  measurable_set {x | f x = g x} :=\nbegin\n  have : {x | f x = g x} = ⋃ j, {x | f x = j} ∩ {x | g x = j},\n  { ext1 x, simp only [set.mem_set_of_eq, set.mem_Union, set.mem_inter_iff, exists_eq_right'], },\n  rw this,\n  refine measurable_set.Union (λ j, measurable_set.inter _ _),\n  { exact hf (measurable_set_singleton j), },\n  { exact hg (measurable_set_singleton j), },\nend\n\nlemma ae_eq_trim_of_measurable {α E} {m m0 : measurable_space α} {μ : measure α}\n  [measurable_space E] [add_group E] [measurable_singleton_class E] [has_measurable_sub₂ E]\n  (hm : m ≤ m0) {f g : α → E} (hf : measurable[m] f) (hg : measurable[m] g)\n  (hfg : f =ᵐ[μ] g) :\n  f =ᶠ[@measure.ae α m (μ.trim hm)] g :=\nbegin\n  rwa [filter.eventually_eq, ae_iff, trim_measurable_set_eq hm _],\n  exact (@measurable_set.compl α _ m (@measurable_set_eq_fun α m E _ _ _ _ _ _ hf hg)),\nend\n\nend div\n\n/-- We say that a type `has_measurable_neg` if `x ↦ -x` is a measurable function. -/\nclass has_measurable_neg (G : Type*) [has_neg G] [measurable_space G] : Prop :=\n(measurable_neg : measurable (has_neg.neg : G → G))\n\n/-- We say that a type `has_measurable_inv` if `x ↦ x⁻¹` is a measurable function. -/\n@[to_additive]\nclass has_measurable_inv (G : Type*) [has_inv G] [measurable_space G] : Prop :=\n(measurable_inv : measurable (has_inv.inv : G → G))\n\nexport has_measurable_inv (measurable_inv) has_measurable_neg (measurable_neg)\n\n@[priority 100, to_additive]\ninstance has_measurable_div_of_mul_inv (G : Type*) [measurable_space G]\n  [div_inv_monoid G] [has_measurable_mul G] [has_measurable_inv G] :\n  has_measurable_div G :=\n{ measurable_const_div := λ c,\n    by { convert (measurable_inv.const_mul c), ext1, apply div_eq_mul_inv },\n  measurable_div_const := λ c,\n    by { convert (measurable_id.mul_const c⁻¹), ext1, apply div_eq_mul_inv } }\n\nsection inv\n\nvariables {G α : Type*} [has_inv G] [measurable_space G] [has_measurable_inv G]\n  {m : measurable_space α} {f : α → G} {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.inv (hf : measurable f) : measurable (λ x, (f x)⁻¹) := measurable_inv.comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.inv (hf : ae_measurable f μ) : ae_measurable (λ x, (f x)⁻¹) μ :=\nmeasurable_inv.comp_ae_measurable hf\n\nattribute [measurability] measurable.neg ae_measurable.neg\n\n@[simp, to_additive] lemma measurable_inv_iff {G : Type*} [group G] [measurable_space G]\n  [has_measurable_inv G] {f : α → G} : measurable (λ x, (f x)⁻¹) ↔ measurable f :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\n@[simp, to_additive] lemma ae_measurable_inv_iff {G : Type*} [group G] [measurable_space G]\n  [has_measurable_inv G] {f : α → G} :\n  ae_measurable (λ x, (f x)⁻¹) μ ↔ ae_measurable f μ :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\n@[simp] lemma measurable_inv_iff₀ {G₀ : Type*} [group_with_zero G₀]\n  [measurable_space G₀] [has_measurable_inv G₀] {f : α → G₀} :\n  measurable (λ x, (f x)⁻¹) ↔ measurable f :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\n@[simp] lemma ae_measurable_inv_iff₀ {G₀ : Type*} [group_with_zero G₀]\n  [measurable_space G₀] [has_measurable_inv G₀] {f : α → G₀} :\n  ae_measurable (λ x, (f x)⁻¹) μ ↔ ae_measurable f μ :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_inv {ι : Type*} {α : ι → Type*} [∀ i, has_inv (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_inv (α i)] :\n  has_measurable_inv (Π i, α i) :=\n⟨measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).inv⟩\n\n@[to_additive] lemma measurable_set.inv {s : set G} (hs : measurable_set s) : measurable_set s⁻¹ :=\nmeasurable_inv hs\n\nend inv\n\n/-- `div_inv_monoid.has_pow` is measurable. -/\ninstance div_inv_monoid.has_measurable_zpow (G : Type u) [div_inv_monoid G] [measurable_space G]\n  [has_measurable_mul₂ G] [has_measurable_inv G] :\n  has_measurable_pow G ℤ :=\n⟨measurable_from_prod_countable $ λ n, begin\n  cases n with n n,\n  { simp_rw zpow_of_nat, exact measurable_id.pow_const _ },\n  { simp_rw zpow_neg_succ_of_nat, exact (measurable_id.pow_const (n + 1)).inv }\nend⟩\n\n@[priority 100, to_additive]\ninstance has_measurable_div₂_of_mul_inv (G : Type*) [measurable_space G]\n  [div_inv_monoid G] [has_measurable_mul₂ G] [has_measurable_inv G] :\n  has_measurable_div₂ G :=\n⟨by { simp only [div_eq_mul_inv], exact measurable_fst.mul measurable_snd.inv }⟩\n\n/-- We say that the action of `M` on `α` `has_measurable_vadd` if for each `c` the map `x ↦ c +ᵥ x`\nis a measurable function and for each `x` the map `c ↦ c +ᵥ x` is a measurable function. -/\nclass has_measurable_vadd (M α : Type*) [has_vadd M α] [measurable_space M] [measurable_space α] :\n  Prop :=\n(measurable_const_vadd : ∀ c : M, measurable ((+ᵥ) c : α → α))\n(measurable_vadd_const : ∀ x : α, measurable (λ c : M, c +ᵥ x))\n\n/-- We say that the action of `M` on `α` `has_measurable_smul` if for each `c` the map `x ↦ c • x`\nis a measurable function and for each `x` the map `c ↦ c • x` is a measurable function. -/\n@[to_additive]\nclass has_measurable_smul (M α : Type*) [has_smul M α] [measurable_space M] [measurable_space α] :\n  Prop :=\n(measurable_const_smul : ∀ c : M, measurable ((•) c : α → α))\n(measurable_smul_const : ∀ x : α, measurable (λ c : M, c • x))\n\n/-- We say that the action of `M` on `α` `has_measurable_vadd₂` if the map\n`(c, x) ↦ c +ᵥ x` is a measurable function. -/\nclass has_measurable_vadd₂ (M α : Type*) [has_vadd M α] [measurable_space M]\n  [measurable_space α] : Prop :=\n(measurable_vadd : measurable (function.uncurry (+ᵥ) : M × α → α))\n\n/-- We say that the action of `M` on `α` `has_measurable_smul₂` if the map\n`(c, x) ↦ c • x` is a measurable function. -/\n@[to_additive has_measurable_vadd₂]\nclass has_measurable_smul₂ (M α : Type*) [has_smul M α] [measurable_space M]\n  [measurable_space α] : Prop :=\n(measurable_smul : measurable (function.uncurry (•) : M × α → α))\n\nexport has_measurable_smul (measurable_const_smul measurable_smul_const)\nexport has_measurable_smul₂ (measurable_smul)\nexport has_measurable_vadd (measurable_const_vadd measurable_vadd_const)\nexport has_measurable_vadd₂ (measurable_vadd)\n\n@[to_additive]\ninstance has_measurable_smul_of_mul (M : Type*) [has_mul M] [measurable_space M]\n  [has_measurable_mul M] :\n  has_measurable_smul M M :=\n⟨measurable_id.const_mul, measurable_id.mul_const⟩\n\n@[to_additive]\ninstance has_measurable_smul₂_of_mul (M : Type*) [has_mul M] [measurable_space M]\n  [has_measurable_mul₂ M] :\n  has_measurable_smul₂ M M :=\n⟨measurable_mul⟩\n\n@[to_additive] instance submonoid.has_measurable_smul {M α} [measurable_space M]\n  [measurable_space α] [monoid M] [mul_action M α] [has_measurable_smul M α] (s : submonoid M) :\n  has_measurable_smul s α :=\n⟨λ c, by simpa only using measurable_const_smul (c : M),\n  λ x, (measurable_smul_const x : measurable (λ c : M, c • x)).comp measurable_subtype_coe⟩\n\n@[to_additive] instance subgroup.has_measurable_smul {G α} [measurable_space G]\n  [measurable_space α] [group G] [mul_action G α] [has_measurable_smul G α] (s : subgroup G) :\n  has_measurable_smul s α :=\ns.to_submonoid.has_measurable_smul\n\nsection smul\n\nvariables {M β α : Type*} [measurable_space M] [measurable_space β] [has_smul M β]\n  {m : measurable_space α} {f : α → M} {g : α → β}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.smul [has_measurable_smul₂ M β] (hf : measurable f) (hg : measurable g) :\n  measurable (λ x, f x • g x) :=\nmeasurable_smul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.smul [has_measurable_smul₂ M β]\n  {μ : measure α} (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ x, f x • g x) μ :=\nhas_measurable_smul₂.measurable_smul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_smul₂.to_has_measurable_smul [has_measurable_smul₂ M β] :\n  has_measurable_smul M β :=\n⟨λ c, measurable_const.smul measurable_id, λ y, measurable_id.smul measurable_const⟩\n\ninclude m\n\nvariables [has_measurable_smul M β] {μ : measure α}\n\n@[measurability, to_additive]\nlemma measurable.smul_const (hf : measurable f) (y : β) :\n  measurable (λ x, f x • y) :=\n(has_measurable_smul.measurable_smul_const y).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.smul_const (hf : ae_measurable f μ) (y : β) :\n  ae_measurable (λ x, f x • y) μ :=\n(has_measurable_smul.measurable_smul_const y).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.const_smul' (hg : measurable g) (c : M) :\n  measurable (λ x, c • g x) :=\n(has_measurable_smul.measurable_const_smul c).comp hg\n\n@[measurability, to_additive]\nlemma measurable.const_smul (hg : measurable g) (c : M) :\n  measurable (c • g) :=\nhg.const_smul' c\n\n@[measurability, to_additive]\nlemma ae_measurable.const_smul' (hg : ae_measurable g μ) (c : M) :\n  ae_measurable (λ x, c • g x) μ :=\n(has_measurable_smul.measurable_const_smul c).comp_ae_measurable hg\n\n@[measurability, to_additive]\nlemma ae_measurable.const_smul (hf : ae_measurable g μ) (c : M) :\n  ae_measurable (c • g) μ :=\nhf.const_smul' c\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_smul {ι : Type*} {α : ι → Type*} [∀ i, has_smul M (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_smul M (α i)] :\n  has_measurable_smul M (Π i, α i) :=\n⟨λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).const_smul _,\n λ g, measurable_pi_iff.mpr $ λ i, measurable_smul_const _⟩\n\n/-- `add_monoid.has_smul_nat` is measurable. -/\ninstance add_monoid.has_measurable_smul_nat₂ (M : Type*) [add_monoid M] [measurable_space M]\n  [has_measurable_add₂ M] : has_measurable_smul₂ ℕ M :=\n⟨begin\n  suffices : measurable (λ p : M × ℕ, p.2 • p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_countable (λ n, _),\n  induction n with n ih,\n  { simp only [zero_smul, ←pi.zero_def, measurable_zero] },\n  { simp only [succ_nsmul], exact measurable_id.add ih }\nend⟩\n\n/-- `sub_neg_monoid.has_smul_int` is measurable. -/\ninstance sub_neg_monoid.has_measurable_smul_int₂ (M : Type*) [sub_neg_monoid M] [measurable_space M]\n  [has_measurable_add₂ M] [has_measurable_neg M] : has_measurable_smul₂ ℤ M :=\n⟨begin\n  suffices : measurable (λ p : M × ℤ, p.2 • p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_countable (λ n, _),\n  induction n with n n ih,\n  { simp only [of_nat_zsmul], exact measurable_const_smul _, },\n  { simp only [zsmul_neg_succ_of_nat], exact (measurable_const_smul _).neg }\nend⟩\n\nend smul\n\nsection mul_action\n\nvariables {M β α : Type*} [measurable_space M] [measurable_space β] [monoid M] [mul_action M β]\n  [has_measurable_smul M β] [measurable_space α] {f : α → β} {μ : measure α}\n\nvariables {G : Type*} [group G] [measurable_space G] [mul_action G β]\n  [has_measurable_smul G β]\n\n@[to_additive]\nlemma measurable_const_smul_iff (c : G) :\n  measurable (λ x, c • f x) ↔ measurable f :=\n⟨λ h, by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, λ h, h.const_smul c⟩\n\n@[to_additive]\nlemma ae_measurable_const_smul_iff (c : G) :\n  ae_measurable (λ x, c • f x) μ ↔ ae_measurable f μ :=\n⟨λ h, by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, λ h, h.const_smul c⟩\n\n@[to_additive]\ninstance : measurable_space Mˣ := measurable_space.comap (coe : Mˣ → M) ‹_›\n\n@[to_additive]\ninstance units.has_measurable_smul : has_measurable_smul Mˣ β :=\n{ measurable_const_smul := λ c, (measurable_const_smul (c : M) : _),\n  measurable_smul_const := λ x,\n    (measurable_smul_const x : measurable (λ c : M, c • x)).comp measurable_space.le_map_comap, }\n\n@[to_additive]\nlemma is_unit.measurable_const_smul_iff {c : M} (hc : is_unit c) :\n  measurable (λ x, c • f x) ↔ measurable f :=\nlet ⟨u, hu⟩ := hc in hu ▸ measurable_const_smul_iff u\n\n@[to_additive]\nlemma is_unit.ae_measurable_const_smul_iff {c : M} (hc : is_unit c) :\n  ae_measurable (λ x, c • f x) μ ↔ ae_measurable f μ :=\nlet ⟨u, hu⟩ := hc in hu ▸ ae_measurable_const_smul_iff u\n\nvariables {G₀ : Type*} [group_with_zero G₀] [measurable_space G₀] [mul_action G₀ β]\n  [has_measurable_smul G₀ β]\n\nlemma measurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) :\n  measurable (λ x, c • f x) ↔ measurable f :=\n(is_unit.mk0 c hc).measurable_const_smul_iff\n\nlemma ae_measurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) :\n  ae_measurable (λ x, c • f x) μ ↔ ae_measurable f μ :=\n(is_unit.mk0 c hc).ae_measurable_const_smul_iff\n\nend mul_action\n\n/-!\n### Opposite monoid\n-/\n\nsection opposite\nopen mul_opposite\n\n@[to_additive]\ninstance {α : Type*} [h : measurable_space α] : measurable_space αᵐᵒᵖ := measurable_space.map op h\n\n@[to_additive]\nlemma measurable_mul_op {α : Type*} [measurable_space α] : measurable (op : α → αᵐᵒᵖ) := λ s, id\n\n@[to_additive]\nlemma measurable_mul_unop {α : Type*} [measurable_space α] : measurable (unop : αᵐᵒᵖ → α) := λ s, id\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul M] :\n  has_measurable_mul Mᵐᵒᵖ :=\n⟨λ c, measurable_mul_op.comp (measurable_mul_unop.mul_const _),\n  λ c, measurable_mul_op.comp (measurable_mul_unop.const_mul _)⟩\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul₂ M] :\n  has_measurable_mul₂ Mᵐᵒᵖ :=\n⟨measurable_mul_op.comp ((measurable_mul_unop.comp measurable_snd).mul\n  (measurable_mul_unop.comp measurable_fst))⟩\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul.op {M α} [measurable_space M]\n  [measurable_space α] [has_smul M α] [has_smul Mᵐᵒᵖ α] [is_central_scalar M α]\n  [has_measurable_smul M α] : has_measurable_smul Mᵐᵒᵖ α :=\n⟨ mul_opposite.rec $ λ c, show measurable (λ x, op c • x),\n                          by simpa only [op_smul_eq_smul] using measurable_const_smul c,\n  λ x, show measurable (λ c, op (unop c) • x),\n       by simpa only [op_smul_eq_smul] using (measurable_smul_const x).comp measurable_mul_unop⟩\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul₂.op {M α} [measurable_space M]\n  [measurable_space α] [has_smul M α] [has_smul Mᵐᵒᵖ α] [is_central_scalar M α]\n  [has_measurable_smul₂ M α] : has_measurable_smul₂ Mᵐᵒᵖ α :=\n⟨show measurable (λ x : Mᵐᵒᵖ × α, op (unop x.1) • x.2), begin\n  simp_rw op_smul_eq_smul,\n  refine (measurable_mul_unop.comp measurable_fst).smul measurable_snd,\nend⟩\n\n@[to_additive]\ninstance has_measurable_smul_opposite_of_mul {M : Type*} [has_mul M] [measurable_space M]\n  [has_measurable_mul M] : has_measurable_smul Mᵐᵒᵖ M :=\n⟨λ c, measurable_mul_const (unop c), λ x, measurable_mul_unop.const_mul x⟩\n\n@[to_additive]\ninstance has_measurable_smul₂_opposite_of_mul {M : Type*} [has_mul M] [measurable_space M]\n  [has_measurable_mul₂ M] : has_measurable_smul₂ Mᵐᵒᵖ M :=\n⟨measurable_snd.mul (measurable_mul_unop.comp measurable_fst)⟩\n\nend opposite\n\n/-!\n### Big operators: `∏` and `∑`\n-/\n\nsection monoid\nvariables {M α : Type*} [monoid M] [measurable_space M] [has_measurable_mul₂ M]\n  {m : measurable_space α} {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma list.measurable_prod' (l : list (α → M)) (hl : ∀ f ∈ l, measurable f) :\n  measurable l.prod :=\nbegin\n  induction l with f l ihl, { exact measurable_one },\n  rw [list.forall_mem_cons] at hl,\n  rw [list.prod_cons],\n  exact hl.1.mul (ihl hl.2)\nend\n\n@[measurability, to_additive]\nlemma list.ae_measurable_prod' (l : list (α → M))\n  (hl : ∀ f ∈ l, ae_measurable f μ) : ae_measurable l.prod μ :=\nbegin\n  induction l with f l ihl, { exact ae_measurable_one },\n  rw [list.forall_mem_cons] at hl,\n  rw [list.prod_cons],\n  exact hl.1.mul (ihl hl.2)\nend\n\n@[measurability, to_additive]\nlemma list.measurable_prod (l : list (α → M)) (hl : ∀ f ∈ l, measurable f) :\n  measurable (λ x, (l.map (λ f : α → M, f x)).prod) :=\nby simpa only [← pi.list_prod_apply] using l.measurable_prod' hl\n\n@[measurability, to_additive]\nlemma list.ae_measurable_prod (l : list (α → M)) (hl : ∀ f ∈ l, ae_measurable f μ) :\n  ae_measurable (λ x, (l.map (λ f : α → M, f x)).prod) μ :=\nby simpa only [← pi.list_prod_apply] using l.ae_measurable_prod' hl\n\nomit m\n\nend monoid\n\nsection comm_monoid\nvariables {M ι α : Type*} [comm_monoid M] [measurable_space M] [has_measurable_mul₂ M]\n  {m : measurable_space α} {μ : measure α} {f : ι → α → M}\n\ninclude m\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod' (l : multiset (α → M)) (hl : ∀ f ∈ l, measurable f) :\n  measurable l.prod :=\nby { rcases l with ⟨l⟩, simpa using l.measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod' (l : multiset (α → M))\n  (hl : ∀ f ∈ l, ae_measurable f μ) : ae_measurable l.prod μ :=\nby { rcases l with ⟨l⟩, simpa using l.ae_measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod (s : multiset (α → M)) (hs : ∀ f ∈ s, measurable f) :\n  measurable (λ x, (s.map (λ f : α → M, f x)).prod) :=\nby simpa only [← pi.multiset_prod_apply] using s.measurable_prod' hs\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod (s : multiset (α → M))\n  (hs : ∀ f ∈ s, ae_measurable f μ) : ae_measurable (λ x, (s.map (λ f : α → M, f x)).prod) μ :=\nby simpa only [← pi.multiset_prod_apply] using s.ae_measurable_prod' hs\n\n@[measurability, to_additive]\nlemma finset.measurable_prod' (s : finset ι) (hf : ∀i ∈ s, measurable (f i)) :\n  measurable (∏ i in s, f i) :=\nfinset.prod_induction _ _ (λ _ _, measurable.mul) (@measurable_one M _ _ _ _) hf\n\n@[measurability, to_additive]\nlemma finset.measurable_prod (s : finset ι) (hf : ∀i ∈ s, measurable (f i)) :\n  measurable (λ a, ∏ i in s, f i a) :=\nby simpa only [← finset.prod_apply] using s.measurable_prod' hf\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod' (s : finset ι) (hf : ∀i ∈ s, ae_measurable (f i) μ) :\n  ae_measurable (∏ i in s, f i) μ :=\nmultiset.ae_measurable_prod' _ $\n  λ g hg, let ⟨i, hi, hg⟩ := multiset.mem_map.1 hg in (hg ▸ hf _ hi)\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod (s : finset ι) (hf : ∀i ∈ s, ae_measurable (f i) μ) :\n  ae_measurable (λ a, ∏ i in s, f i a) μ :=\nby simpa only [← finset.prod_apply] using s.ae_measurable_prod' hf\n\nomit m\n\nend comm_monoid\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/measure_theory/group/arithmetic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6548947357776796, "lm_q1q2_score": 0.46643711610999317}}
{"text": "import lang\nimport normalization\nimport data.set\n\n-- V⟦−⟧ : type → PowerSet(ClosedVal)\n-- V⟦−⟧ : type → (ClosedVal → 2)\n-- interp_val : type → val → Prop\n--\n\nopen exp typ\n\nnotation e ` ↦* `:90 e' := is_many_step e e'\n\ndef irred (e:exp) := ¬(∃ e', e ↦str e')\n\n-- Approach to defining inductive relation inspired from ModuRes.\n\ndef T := set exp\ninstance T_has_mem : has_mem (exp) T := set.has_mem\ninstance T_has_inter : has_inter T := set.has_inter\n\ndef step_closure (s:T) : T :=\n  { e:exp | ∀ e', (e ↦* e') ∧ irred(e') → e' ∈ s }\n\ninductive rel_arrow: T → T → T\n| Rlam (Rτ1 Rτ2:T) (x:string) (τ:typ) (e:exp)\n  (Hfunc: ∀ (v:exp), (v ∈ Rτ1) → (substitute x v e) ∈ step_closure Rτ2) :\n  (rel_arrow Rτ1 Rτ2 (lam x τ e))\n\ndef closed_vals := { e : exp | is_val e }\n\ndef interp_val : typ → (set exp)\n| unitT := (singleton exp.unit)\n| (arrowT τ1 τ2) := (rel_arrow (interp_val τ1) (interp_val τ2)) ∩ closed_vals\n\ndef interp_exp (τ:typ) := step_closure (interp_val τ)\n\nnotation `V⟦` τ `⟧` := interp_val τ\nnotation `E⟦` τ `⟧` := interp_exp τ\n\n-- XXX: now, we're gonna call context_list Γ, and have to explicitly to\n-- (mk_context Γ) in has_type.\ndef interp_ctx : context_list → set env\n| [] [] := true\n| ((y,τ)::Γ) ((x,v)::γ) := x=y ∧ interp_ctx Γ γ ∧ (v ∈ V⟦τ⟧)\n| _ _ := false\n\nnotation `G⟦` Γ `⟧` := interp_ctx Γ\n\ndef semantic_has_type (Γ:context_list) (e:exp) (τ:typ) : Prop :=\n  ∀ γ, γ ∈ G⟦Γ⟧ → env_sub γ e ∈ E⟦τ⟧\n\nnotation Γ ` ⊨ `:90 e:90 ` : `:90 τ := semantic_has_type Γ e τ\n\ndef safe (e:exp) : Prop :=\n∀ e', (e ↦* e') → (is_val e') ∨ (∃ e'', e' ↦str e'')\n\nlemma interp_val_implies_closedval :\n∀ v τ, v ∈ V⟦τ⟧ → v ∈ closed_vals :=\nbegin\n  introv Hval,\n  cases τ,\n  {\n      unfold interp_val at Hval,\n      unfold singleton at Hval,\n      simp at Hval, subst Hval,\n      constructor\n  },\n  {\n      unfold interp_val at Hval,\n      cases Hval,\n      unfold closed_vals at Hval_right,\n      simp at Hval_right, assumption\n  }\nend\n\nlemma semantic_implies_type_safety :\n∀ e τ,\n  ([] ⊨ e : τ) →\n  safe(e) :=\nbegin\n  introv HTy,\n  intros e' Hstep,\n  by_cases irred(e'), tactic.swap,\n  { -- easy case, just take a step\n    unfold irred at h,\n    simp at h,\n    cases h with e'',\n    right,\n    existsi e'',\n    assumption\n  },\n  { -- otherwise, show\n    unfold semantic_has_type at HTy,\n    specialize HTy [] _,\n    { constructor },\n    unfold env_sub at HTy,\n    specialize HTy e' ⟨Hstep, h⟩,\n    left,\n    apply interp_val_implies_closedval,\n    assumption\n  }\nend\n\ndef not_in_env (γ:env) (x:string) : Prop := (∀ v, (x, v) ∉ γ)\n\nlemma env_sub_lam_notin :\n∀ γ x τ e,\n  not_in_env γ x →\n  env_sub γ (lam x τ e) = lam x τ (env_sub γ e) :=\nbegin\n  introv Hnot,\n  induction γ,\n  { unfold env_sub },\n  cases γ_hd,\n  unfold env_sub,\n  sorry,\nend\n\nlemma env_sub_lam_in :\n∀ γ x τ e v,\n  ((x, v) ∈ γ) →\n  env_sub γ (lam x τ e) = lam x τ e :=\nbegin\nsorry\nend\n\n-- This is the \"substitution lemma\" on page 13 of notes.\nlemma substitution_lemma :\n  ∀ γ x vx e,\n  not_in_env γ x →\n  env_sub ((x,vx)::γ) e = substitute x vx (env_sub γ e) :=\nbegin\n  introv Hnot,\n  unfold env_sub,\n  induction γ generalizing e,\n  { unfold env_sub },\n  cases γ_hd,\n  unfold env_sub,\n  rw <- γ_ih, tactic.swap,\n  {\n    intros v,\n    specialize Hnot v,\n    intros H,\n    apply Hnot,\n    right, assumption\n  },\n  rw substitute_commute,\n  repeat { sorry }\nend\n\ntheorem fundamental_property :\n∀ Γ e τ,\n  (mk_context Γ ⊢ e : τ) →\n  (Γ ⊨ e : τ) :=\nbegin\n  introv Hty,\n  generalize h : (mk_context Γ) = (ctx),\n  rw h at *,\n  induction Hty generalizing Γ; subst h; unfold semantic_has_type,\n  { -- case: unit\n    introv Hγ, rw env_sub_unit,\n    unfold interp_exp step_closure, simp *,\n    introv Hstep Hirred,\n    cases Hstep,\n    { constructor },\n    exfalso, cases Hstep_Hstep,\n  },\n  { -- case: var\n    introv Hγ,\n    rename [Hty_x → x, Hty_τ → τ],\n    -- Argument:\n    -- Knowing (mk_context Γ) x = some τ and γ ∈ G⟦Γ⟧ should tells us:\n    -- ∃ (x,vx) ∈ γ, vx ∈ V⟦τ⟧,\n    --    env_sub γ (var x) = vx\n    -- At that point, we're done because V⟦τ⟧ ⊆ E⟦τ⟧.\n    sorry,\n  },\n  { -- case: abs; this is where induction will be a bit tricky.\n    introv Hγ,\n    rename [Hty_x → x, Hty_τ1 → τ1, Hty_τ2 → τ2, Hty_e → e],\n    -- FIXME: using this false lemma (could be made true modulo α-substitutions)\n    -- to mimic the argument in the lecture notes for now.\n    by_cases (not_in_env γ x), tactic.swap,\n    { sorry },\n    {\n      rw env_sub_lam_notin, tactic.swap, { tauto },\n      intros e' Hstep,\n      cases Hstep with Hstep Hirred,\n      cases Hstep, tactic.swap, { cases Hstep_Hstep },\n      unfold interp_val,\n      split, tactic.swap,\n      { unfold closed_vals, constructor },\n      constructor,\n      intros v Hv,\n      -- NOTE: step_closure V⟦τ2⟧ is the same as E⟦τ2⟧.\n      rw (_:step_closure V⟦τ2⟧ = E⟦τ2⟧), tactic.swap,\n      { unfold interp_exp },\n\n      -- Apply inductive hypothesis\n      specialize Hty_ih ((x,τ1)::Γ) _,\n      { unfold mk_context },\n      specialize Hty_ih ((x,v)::γ) _,\n      { constructor, { refl },\n        split; assumption,\n      },\n      unfold env_sub at Hty_ih,\n      rw <- substitution_lemma, tactic.swap, assumption,\n      apply Hty_ih,\n    }\n  },\n  repeat { sorry }\nend\n", "meta": {"author": "upamanyus", "repo": "pl-experiments", "sha": "ff4434ae9df0c00f50520eac64b87d5ae42991c1", "save_path": "github-repos/lean/upamanyus-pl-experiments", "path": "github-repos/lean/upamanyus-pl-experiments/pl-experiments-ff4434ae9df0c00f50520eac64b87d5ae42991c1/stlc/src/typesafety.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.46643709851497084}}
{"text": "/-\nCopyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Pierre-Alexandre Bazin\n\n! This file was ported from Lean 3 source module algebra.module.pid\n! leanprover-community/mathlib commit f62c15c01a5409b31b97a82d79a12980be4eff35\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Module.DedekindDomain\nimport Mathbin.LinearAlgebra.FreeModule.Pid\nimport Mathbin.Algebra.Module.Projective\nimport Mathbin.Algebra.Category.Module.Biproducts\n\n/-!\n# Structure of finitely generated modules over a PID\n\n## Main statements\n\n* `module.equiv_direct_sum_of_is_torsion` : A finitely generated torsion module over a PID is\n  isomorphic to a direct sum of some `R ⧸ R ∙ (p i ^ e i)` where the `p i ^ e i` are prime powers.\n* `module.equiv_free_prod_direct_sum` : A finitely generated module over a PID is isomorphic to the\n  product of a free module (its torsion free part) and a direct sum of the form above (its torsion\n  submodule).\n\n## Notation\n\n* `R` is a PID and `M` is a (finitely generated for main statements) `R`-module, with additional\n  torsion hypotheses in the intermediate lemmas.\n* `N` is a `R`-module lying over a higher type universe than `R`. This assumption is needed on the\n  final statement for technical reasons.\n* `p` is an irreducible element of `R` or a tuple of these.\n\n## Implementation details\n\nWe first prove (`submodule.is_internal_prime_power_torsion_of_pid`) that a finitely generated\ntorsion module is the internal direct sum of its `p i ^ e i`-torsion submodules for some\n(finitely many) prime powers `p i ^ e i`. This is proved in more generality for a Dedekind domain\nat `submodule.is_internal_prime_power_torsion`.\n\nThen we treat the case of a `p ^ ∞`-torsion module (that is, a module where all elements are\ncancelled by scalar multiplication by some power of `p`) and apply it to the `p i ^ e i`-torsion\nsubmodules (that are `p i ^ ∞`-torsion) to get the result for torsion modules.\n\nThen we get the general result using that a torsion free module is free (which has been proved at\n`module.free_of_finite_type_torsion_free'` at `linear_algebra/free_module/pid.lean`.)\n\n## Tags\n\nFinitely generated module, principal ideal domain, classification, structure theorem\n-/\n\n\nuniverse u v\n\nopen BigOperators\n\nvariable {R : Type u} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R]\n\nvariable {M : Type v} [AddCommGroup M] [Module R M]\n\nvariable {N : Type max u v} [AddCommGroup N] [Module R N]\n\nopen DirectSum\n\nopen Submodule\n\n/-- A finitely generated torsion module over a PID is an internal direct sum of its\n`p i ^ e i`-torsion submodules for some primes `p i` and numbers `e i`.-/\ntheorem Submodule.isInternal_prime_power_torsion_of_pid [Module.Finite R M]\n    (hM : Module.IsTorsion R M) :\n    ∃ (ι : Type u)(_ : Fintype ι)(_ : DecidableEq ι)(p : ι → R)(h : ∀ i, Irreducible <| p i)(e :\n      ι → ℕ), DirectSum.IsInternal fun i => torsion_by R M <| p i ^ e i :=\n  by\n  obtain ⟨P, dec, hP, e, this⟩ := is_internal_prime_power_torsion hM\n  refine' ⟨P, inferInstance, dec, fun p => is_principal.generator (p : Ideal R), _, e, _⟩\n  · rintro ⟨p, hp⟩\n    haveI := Ideal.isPrime_of_prime (hP p hp)\n    exact (is_principal.prime_generator_of_is_prime p (hP p hp).NeZero).Irreducible\n  · convert this\n    ext p : 1\n    rw [← torsion_by_span_singleton_eq, Ideal.submodule_span_eq, ← Ideal.span_singleton_pow,\n      Ideal.span_singleton_generator]\n#align submodule.is_internal_prime_power_torsion_of_pid Submodule.isInternal_prime_power_torsion_of_pid\n\nnamespace Module\n\nsection PTorsion\n\nvariable {p : R} (hp : Irreducible p) (hM : Module.IsTorsion' M (Submonoid.powers p))\n\nvariable [dec : ∀ x : M, Decidable (x = 0)]\n\nopen Ideal Submodule.IsPrincipal\n\ninclude dec\n\ninclude hp hM\n\ntheorem Ideal.torsionOf_eq_span_pow_pOrder (x : M) : torsionOf R M x = span {p ^ pOrder hM x} :=\n  by\n  dsimp only [p_order]\n  rw [← (torsion_of R M x).span_singleton_generator, Ideal.span_singleton_eq_span_singleton, ←\n    Associates.mk_eq_mk_iff_associated, Associates.mk_pow]\n  have prop :\n    (fun n : ℕ => p ^ n • x = 0) = fun n : ℕ =>\n      (Associates.mk <| generator <| torsion_of R M x) ∣ Associates.mk p ^ n :=\n    by\n    ext n\n    rw [← Associates.mk_pow, Associates.mk_dvd_mk, ← mem_iff_generator_dvd]\n    rfl\n  have := (is_torsion'_powers_iff p).mp hM x\n  rw [prop] at this\n  classical convert Associates.eq_pow_find_of_dvd_irreducible_pow\n        ((Associates.irreducible_mk p).mpr hp) this.some_spec\n#align ideal.torsion_of_eq_span_pow_p_order Ideal.torsionOf_eq_span_pow_pOrder\n\ntheorem p_pow_smul_lift {x y : M} {k : ℕ} (hM' : Module.IsTorsionBy R M (p ^ pOrder hM y))\n    (h : p ^ k • x ∈ R ∙ y) : ∃ a : R, p ^ k • x = p ^ k • a • y :=\n  by\n  by_cases hk : k ≤ p_order hM y\n  · let f :=\n      ((R ∙ p ^ (p_order hM y - k) * p ^ k).quotEquivOfEq _ _).trans\n        (quot_torsion_of_equiv_span_singleton R M y)\n    have :\n      f.symm ⟨p ^ k • x, h⟩ ∈ R ∙ Ideal.Quotient.mk (R ∙ p ^ (p_order hM y - k) * p ^ k) (p ^ k) :=\n      by\n      rw [← quotient.torsion_by_eq_span_singleton, mem_torsion_by_iff, ← f.symm.map_smul]\n      convert f.symm.map_zero\n      ext\n      rw [coe_smul_of_tower, coe_mk, coe_zero, smul_smul, ← pow_add, Nat.sub_add_cancel hk, @hM' x]\n      · exact mem_nonZeroDivisors_of_ne_zero (pow_ne_zero _ hp.ne_zero)\n    rw [Submodule.mem_span_singleton] at this\n    obtain ⟨a, ha⟩ := this\n    use a\n    rw [f.eq_symm_apply, ← Ideal.Quotient.mk_eq_mk, ← quotient.mk_smul] at ha\n    dsimp only [smul_eq_mul, f, LinearEquiv.trans_apply, Submodule.quotEquivOfEq_mk,\n      quot_torsion_of_equiv_span_singleton_apply_mk] at ha\n    rw [smul_smul, mul_comm]\n    exact congr_arg coe ha.symm\n    · symm\n      convert Ideal.torsionOf_eq_span_pow_pOrder hp hM y\n      rw [← pow_add, Nat.sub_add_cancel hk]\n  · use 0\n    rw [zero_smul, smul_zero, ← Nat.sub_add_cancel (le_of_not_le hk), pow_add, mul_smul, hM',\n      smul_zero]\n#align module.p_pow_smul_lift Module.p_pow_smul_lift\n\nopen Submodule.Quotient\n\ntheorem exists_smul_eq_zero_and_mk_eq {z : M} (hz : Module.IsTorsionBy R M (p ^ pOrder hM z))\n    {k : ℕ} (f : (R ⧸ R ∙ p ^ k) →ₗ[R] M ⧸ R ∙ z) :\n    ∃ x : M, p ^ k • x = 0 ∧ Submodule.Quotient.mk x = f 1 :=\n  by\n  have f1 := mk_surjective (R ∙ z) (f 1)\n  have : p ^ k • f1.some ∈ R ∙ z :=\n    by\n    rw [← quotient.mk_eq_zero, mk_smul, f1.some_spec, ← f.map_smul]\n    convert f.map_zero\n    change _ • Submodule.Quotient.mk _ = _\n    rw [← mk_smul, quotient.mk_eq_zero, Algebra.id.smul_eq_mul, mul_one]\n    exact Submodule.mem_span_singleton_self _\n  obtain ⟨a, ha⟩ := p_pow_smul_lift hp hM hz this\n  refine' ⟨f1.some - a • z, by rw [smul_sub, sub_eq_zero, ha], _⟩\n  rw [mk_sub, mk_smul, (quotient.mk_eq_zero _).mpr <| Submodule.mem_span_singleton_self _,\n    smul_zero, sub_zero, f1.some_spec]\n#align module.exists_smul_eq_zero_and_mk_eq Module.exists_smul_eq_zero_and_mk_eq\n\nopen Finset Multiset\n\nomit dec hM\n\n/-- A finitely generated `p ^ ∞`-torsion module over a PID is isomorphic to a direct sum of some\n  `R ⧸ R ∙ (p ^ e i)` for some `e i`.-/\ntheorem torsion_by_prime_power_decomposition (hN : Module.IsTorsion' N (Submonoid.powers p))\n    [h' : Module.Finite R N] :\n    ∃ (d : ℕ)(k : Fin d → ℕ), Nonempty <| N ≃ₗ[R] ⨁ i : Fin d, R ⧸ R ∙ p ^ (k i : ℕ) :=\n  by\n  obtain ⟨d, s, hs⟩ := @Module.Finite.exists_fin _ _ _ _ _ h'; use d; clear h'\n  induction' d with d IH generalizing N\n  · use fun i => finZeroElim i\n    rw [Set.range_eq_empty, Submodule.span_empty] at hs\n    haveI : Unique N :=\n      ⟨⟨0⟩, fun x => by\n        rw [← mem_bot _, hs]\n        trivial⟩\n    exact ⟨0⟩\n  · have : ∀ x : N, Decidable (x = 0)\n    classical\n      infer_instance\n      obtain ⟨j, hj⟩ := exists_is_torsion_by hN d.succ d.succ_ne_zero s hs\n      let s' : Fin d → N ⧸ R ∙ s j := Submodule.Quotient.mk ∘ s ∘ j.succ_above\n      obtain ⟨k, ⟨f⟩⟩ := IH _ s' _ <;> clear IH\n      · have :\n          ∀ i : Fin d,\n            ∃ x : N, p ^ k i • x = 0 ∧ f (Submodule.Quotient.mk x) = DirectSum.lof R _ _ i 1 :=\n          by\n          intro i\n          let fi := f.symm.to_linear_map.comp (DirectSum.lof _ _ _ i)\n          obtain ⟨x, h0, h1⟩ := exists_smul_eq_zero_and_mk_eq hp hN hj fi\n          refine' ⟨x, h0, _⟩\n          rw [h1]\n          simp only [LinearMap.coe_comp, f.symm.coe_to_linear_map, f.apply_symm_apply]\n        refine'\n          ⟨_,\n            ⟨(((@lequivProdOfRightSplitExact _ _ _ _ _ _ _ _ _ _ _ _\n                              ((f.trans ULift.moduleEquiv.{u, u, v}.symm).toLinearMap.comp <| mkq _)\n                              ((DirectSum.toModule _ _ _ fun i =>\n                                    (liftQSpanSingleton.{u, u} (p ^ k i)\n                                        (LinearMap.toSpanSingleton _ _ _)\n                                        (this i).choose_spec.left :\n                                      R ⧸ _ →ₗ[R] _)).comp\n                                ulift.module_equiv.to_linear_map)\n                              (R ∙ s j).injective_subtype _ _).symm.trans <|\n                        ((quot_torsion_of_equiv_span_singleton _ _ _).symm.trans <|\n                              quot_equiv_of_eq _ _ <|\n                                Ideal.torsionOf_eq_span_pow_pOrder hp hN _).Prod <|\n                          ULift.moduleEquiv).trans <|\n                    (@DirectSum.lequivProdDirectSum R _ _ _\n                        (fun i => R ⧸ R ∙ p ^ @Option.rec _ (fun _ => ℕ) (p_order hN <| s j) k i) _\n                        _).symm).trans <|\n                DirectSum.lequivCongrLeft R (finSuccEquiv d).symm⟩⟩\n        · rw [range_subtype, LinearEquiv.toLinearMap_eq_coe, LinearEquiv.ker_comp, ker_mkq]\n        · rw [LinearEquiv.toLinearMap_eq_coe, ← f.comp_coe, LinearMap.comp_assoc,\n            LinearMap.comp_assoc, ← LinearEquiv.toLinearMap_eq_coe,\n            LinearEquiv.toLinearMap_symm_comp_eq, LinearMap.comp_id, ← LinearMap.comp_assoc, ←\n            LinearMap.comp_assoc]\n          suffices (f.to_linear_map.comp (R ∙ s j).mkQ).comp _ = LinearMap.id by\n            rw [← f.to_linear_map_eq_coe, this, LinearMap.id_comp]\n          ext i : 3\n          simp only [LinearMap.coe_comp, Function.comp_apply, mkq_apply]\n          rw [LinearEquiv.coe_toLinearMap, LinearMap.id_apply, DirectSum.toModule_lof,\n            liftq_span_singleton_apply, LinearMap.toSpanSingleton_one, Ideal.Quotient.mk_eq_mk,\n            map_one, (this i).choose_spec.right]\n      ·\n        exact\n          (mk_surjective _).forall.mpr fun x =>\n            ⟨(@hN x).some, by rw [← quotient.mk_smul, (@hN x).choose_spec, quotient.mk_zero]⟩\n      · have hs' := congr_arg (Submodule.map <| mkq <| R ∙ s j) hs\n        rw [Submodule.map_span, Submodule.map_top, range_mkq] at hs'\n        simp only [mkq_apply] at hs'\n        simp only [s']\n        rw [Set.range_comp (_ ∘ s), Fin.range_succAbove]\n        rw [← Set.range_comp, ← Set.insert_image_compl_eq_range _ j, Function.comp_apply,\n          (quotient.mk_eq_zero _).mpr (Submodule.mem_span_singleton_self _), span_insert_zero] at\n          hs'\n        exact hs'\n#align module.torsion_by_prime_power_decomposition Module.torsion_by_prime_power_decomposition\n\nend PTorsion\n\n/-- A finitely generated torsion module over a PID is isomorphic to a direct sum of some\n  `R ⧸ R ∙ (p i ^ e i)` where the `p i ^ e i` are prime powers.-/\ntheorem equiv_directSum_of_isTorsion [h' : Module.Finite R N] (hN : Module.IsTorsion R N) :\n    ∃ (ι : Type u)(_ : Fintype ι)(p : ι → R)(h : ∀ i, Irreducible <| p i)(e : ι → ℕ),\n      Nonempty <| N ≃ₗ[R] ⨁ i : ι, R ⧸ R ∙ p i ^ e i :=\n  by\n  obtain ⟨I, fI, _, p, hp, e, h⟩ := Submodule.isInternal_prime_power_torsion_of_pid hN\n  haveI := fI\n  have :\n    ∀ i,\n      ∃ (d : ℕ)(k : Fin d → ℕ),\n        Nonempty <| torsion_by R N (p i ^ e i) ≃ₗ[R] ⨁ j, R ⧸ R ∙ p i ^ k j :=\n    by\n    haveI := isNoetherian_of_fg_of_noetherian' (module.finite_def.mp h')\n    haveI := fun i => isNoetherian_submodule' (torsion_by R N <| p i ^ e i)\n    exact fun i =>\n      torsion_by_prime_power_decomposition (hp i)\n        ((is_torsion'_powers_iff <| p i).mpr fun x => ⟨e i, smul_torsion_by _ _⟩)\n  classical\n    refine'\n      ⟨Σi, Fin (this i).some, inferInstance, fun ⟨i, j⟩ => p i, fun ⟨i, j⟩ => hp i, fun ⟨i, j⟩ =>\n        (this i).choose_spec.some j,\n        ⟨(LinearEquiv.ofBijective (DirectSum.coeLinearMap _) h).symm.trans <|\n            (Dfinsupp.mapRange.linearEquiv fun i => (this i).choose_spec.choose_spec.some).trans <|\n              (DirectSum.sigmaLcurryEquiv R).symm.trans\n                (Dfinsupp.mapRange.linearEquiv fun i => quot_equiv_of_eq _ _ _)⟩⟩\n    cases' i with i j\n    simp only\n#align module.equiv_direct_sum_of_is_torsion Module.equiv_directSum_of_isTorsion\n\n/-- **Structure theorem of finitely generated modules over a PID** : A finitely generated\n  module over a PID is isomorphic to the product of a free module and a direct sum of some\n  `R ⧸ R ∙ (p i ^ e i)` where the `p i ^ e i` are prime powers.-/\ntheorem equiv_free_prod_directSum [h' : Module.Finite R N] :\n    ∃ (n : ℕ)(ι : Type u)(_ : Fintype ι)(p : ι → R)(h : ∀ i, Irreducible <| p i)(e : ι → ℕ),\n      Nonempty <| N ≃ₗ[R] (Fin n →₀ R) × ⨁ i : ι, R ⧸ R ∙ p i ^ e i :=\n  by\n  haveI := isNoetherian_of_fg_of_noetherian' (module.finite_def.mp h')\n  haveI := isNoetherian_submodule' (torsion R N)\n  haveI := Module.Finite.of_surjective _ (torsion R N).mkQ_surjective\n  obtain ⟨I, fI, p, hp, e, ⟨h⟩⟩ := equiv_direct_sum_of_is_torsion (@torsion_is_torsion R N _ _ _)\n  obtain ⟨n, ⟨g⟩⟩ := @Module.basisOfFiniteTypeTorsionFree' R _ _ _ (N ⧸ torsion R N) _ _ _ _\n  haveI : Module.Projective R (N ⧸ torsion R N) := Module.projectiveOfBasis ⟨g⟩\n  obtain ⟨f, hf⟩ := Module.projective_lifting_property _ LinearMap.id (torsion R N).mkQ_surjective\n  refine'\n    ⟨n, I, fI, p, hp, e,\n      ⟨(lequivProdOfRightSplitExact (torsion R N).injective_subtype _ hf).symm.trans <|\n          (h.prod g).trans <| LinearEquiv.prodComm R _ _⟩⟩\n  rw [range_subtype, ker_mkq]\n#align module.equiv_free_prod_direct_sum Module.equiv_free_prod_directSum\n\nend Module\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Module/Pid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.4664370857172255}}
{"text": "-- Copyright © 2019 François G. Dorais. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n\nimport .basic\nimport .action\n\nnamespace algebra\n\nsignature magma (α : Type*) :=\n(op : α → α → α)\n\nnamespace magma_sig\nvariables {α : Type*} (s : magma_sig α)\n\n@[signature_instance]\ndefinition to_left_action : left_action_sig α α :=\n{ act := s.op\n}\n\n@[signature_instance]\ndefinition to_right_action : right_action_sig α α :=\n{ act := s.op\n}\n\nend magma_sig\n\nclass magma {α} (s : magma_sig α) : Prop := intro [] ::\n\nabbreviation magma.infer {α} (s : magma_sig α) : magma s := magma.intro _\n\n@[theory]\nclass cancel_magma {α} (s : magma_sig α) : Prop := intro ::\n(left_cancellative : identity.op_left_cancellative s.op)\n(right_cancellative : identity.op_right_cancellative s.op)\n\ninstance cancel_magma.to_magma {α} (s : magma_sig α) [i : cancel_magma s] : magma s := magma.infer _ \n\n@[theory]\nclass comm_magma {α} (s : magma_sig α) : Prop := intro ::\n(commutative : identity.op_commutative s.op)\n\ninstance comm_magma.to_magma {α} (s : magma_sig α) [i : comm_magma s] : magma s := magma.infer _ \n\n@[theory]\nclass cancel_comm_magma {α} (s : magma_sig α) : Prop := intro ::\n(commutative : identity.op_commutative s.op)\n(right_cancellative : identity.op_right_cancellative s.op)\n\ninstance cancel_comm_magma.to_comm_magma {α} (s : magma_sig α) [i : cancel_comm_magma s] : comm_magma s := comm_magma.infer _\n\n@[identity_instance]\ntheorem cancel_comm_magma.left_cancellative {α} (s : magma_sig α) [i : cancel_comm_magma s] :\nidentity.op_left_cancellative s.op :=\nλ x y z h, have s.op y x = s.op z x, \nfrom calc s.op y x\n= s.op x y : by rw op_commutative s.op ...\n= s.op x z : by rw h ...\n= s.op z x : by rw op_commutative s.op,\nop_right_cancellative s.op this\n\ninstance cancel_comm_magma.to_cancel_magma {α} (s : magma_sig α) [i : cancel_comm_magma s] : cancel_magma s := cancel_magma.infer _\n\nend algebra\n", "meta": {"author": "fgdorais", "repo": "lean-universal", "sha": "9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1", "save_path": "github-repos/lean/fgdorais-lean-universal", "path": "github-repos/lean/fgdorais-lean-universal/lean-universal-9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1/src/algebra/theories/magma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.46636718157398244}}
{"text": "import tactic.linarith\nimport algebra.order.with_zero\nimport topology.locally_finite\nimport data.fin.interval\nimport data.fin.succ_pred\n\nimport to_mathlib.set_theory.cardinal.basic\n\n/-!\n# Indexing types\n\nThis is a stupid file introducing a type class for types that will index\nlocally finite covers of (paracompact) manifolds without having\nto discuss according to compactness. The only intended instances\nare `ℕ` and `fin (n+1)`.\n\nIt also includes a lemma about locally finite cover that doesn't require an indexing\nindex type but will be used with one.\n-/\n\nopen set\n\nclass indexing (α : Type*) [linear_order α] :=\n(from_nat : ℕ → α)\n(to_nat : α → ℕ)\n(mono_from : monotone from_nat)\n(from_to : ∀ a, from_nat (to_nat a) = a)\n\n@[priority 100]\ninstance indexing.has_coe (α : Type*) [linear_order α] [indexing α] : has_coe ℕ α :=\n⟨indexing.from_nat⟩\n\n@[simp]\nlemma indexing.coe_to {α : Type*} [linear_order α] [indexing α] (i : α) :\n  ((indexing.to_nat i) : α) = i :=\nindexing.from_to i\n\nlemma indexing.coe_mono {α : Type*} [linear_order α] [indexing α] {i j : ℕ} (h : i ≤ j) :\n  (i : α) ≤ j :=\nindexing.mono_from h\n\ninstance indexing.nonempty (α : Type*) [linear_order α] [indexing α] : nonempty α :=\n⟨indexing.from_nat 0⟩\n\ninstance : indexing ℕ :=\n{ from_nat := id,\n  to_nat := id,\n  mono_from := monotone_id,\n  from_to := λ n, rfl }\n\ndef fin.indexing (n : ℕ) : indexing (fin $ n + 1) :=\n{ from_nat := λ k, if h : k < n + 1 then ⟨k, h⟩ else fin.last n,\n  to_nat := coe,\n  mono_from := λ k l hkl, begin\n    dsimp [fin.of_nat],\n    split_ifs ; try { simp [fin.le_last] };\n    linarith,\n  end,\n  from_to := begin\n    rintros ⟨k, hk⟩,\n    erw dif_pos hk,\n    refl\n  end }\n\nlocal attribute [instance] fin.indexing\nopen_locale topology\n\n/-- Our model indexing type depending on `n : ℕ` is `ℕ` if `n = 0` and `fin n` otherwise-/\ndef index_type (n : ℕ) : Type :=\nnat.cases_on n ℕ (λ k, fin $ k + 1)\n\n@[simp] lemma index_type_zero : index_type 0 = ℕ := rfl\n\n@[simp] lemma index_type_succ (n : ℕ) : index_type (n + 1) = fin (n + 1) := rfl\n\n@[simp] lemma index_type_of_zero_lt {n : ℕ} (h : 0 < n) : index_type n = fin n :=\nby rw [← nat.succ_pred_eq_of_pos h, index_type_succ]\n\ninstance (n : ℕ) : linear_order (index_type n) :=\nnat.cases_on n nat.linear_order (λ _, fin.linear_order)\n\ninstance (n : ℕ) : indexing (index_type n) :=\nnat.cases_on n nat.indexing (λ _, fin.indexing _)\n\ninstance (n : ℕ) : locally_finite_order (index_type n) :=\nnat.cases_on n nat.locally_finite_order (λ _, fin.locally_finite_order _)\n\ninstance (n : ℕ) : order_bot (index_type n) :=\nnat.cases_on n nat.order_bot (λ k, show order_bot $ fin (k + 1), by apply_instance)\n\ninstance (N : ℕ) : has_zero (index_type N) := ⟨indexing.from_nat 0⟩\n\nlemma set.countable_iff_exists_nonempty_index_type_equiv\n  {α : Type*} {s : set α} (hne : s.nonempty) :\n  s.countable ↔ ∃ n, nonempty (index_type n ≃ s) :=\nbegin\n  -- Huge golfing opportunity.\n  cases @set.finite_or_infinite _ s,\n  { refine ⟨λ hh, ⟨h.to_finset.card, _⟩, λ _, h.countable⟩,\n    have : 0 < h.to_finset.card,\n    { rw finset.card_pos, exact (set.finite.to_finset_nonempty h).mpr hne},\n    simp only [this, index_type_of_zero_lt],\n    have e₁ := fintype.equiv_fin h.to_finset,\n    rw [fintype.card_coe, h.coe_sort_to_finset] at e₁,\n    exact ⟨e₁.symm⟩, },\n  { refine ⟨λ hh, ⟨0, _⟩, _⟩,\n    { simp only [index_type_zero],\n      obtain ⟨_i⟩ := set.countable_infinite_iff_nonempty_denumerable.mp ⟨hh, h⟩,\n      haveI := _i,\n      exact ⟨(denumerable.eqv s).symm⟩, },\n    { rintros ⟨n, ⟨fn⟩⟩,\n      have hn : n = 0,\n      { by_contra hn,\n        replace hn : 0 < n := zero_lt_iff.mpr hn,\n        simp only [hn, index_type_of_zero_lt] at fn,\n        exact set.not_infinite.mpr ⟨fintype.of_equiv (fin n) fn⟩ h, },\n      simp only [hn, index_type_zero] at fn,\n      exact set.countable_iff_exists_injective.mpr ⟨fn.symm, fn.symm.injective⟩, }, },\nend\n\nopen filter\n\nlemma index_type.lt_or_eq_succ (N n : ℕ) :\n  (n : index_type N) < (n+1 : ℕ) ∨ (n : index_type N) = (n+1 : ℕ) :=\nbegin\n  rw or_comm,\n  exact eq_or_lt_of_le (indexing.mono_from n.le_succ)\nend\n\nlemma index_type.le_or_lt_succ {N n : ℕ} (hn : (n : index_type N) < (n+1 : ℕ)) (j : index_type N) :\n  j ≤ n ↔ j < (n + 1 : ℕ) :=\nbegin\n  cases N, { exact nat.lt_succ_iff.symm, },\n  refine ⟨λ h, lt_of_le_of_lt h hn, λ h, _⟩,\n  clear hn,\n  obtain ⟨j, hj⟩ := j,\n  change _ ≤ indexing.from_nat n,\n  change _ < indexing.from_nat (n + 1) at h,\n  unfold indexing.from_nat at ⊢ h,\n  rcases lt_trichotomy N n with hNn | rfl | hNn,\n  { replace hNn : ¬ (n < N + 1) := by simpa using nat.succ_le_iff.mpr hNn,\n    simp only [hNn, not_false_iff, dif_neg],\n    exact fin.le_last _ },\n  { simpa using nat.lt_succ_iff.mp hj },\n  { simp only [hNn, add_lt_add_iff_right, dif_pos, fin.mk_lt_mk] at h,\n    simpa only [nat.lt.step hNn, dif_pos, fin.mk_le_mk] using nat.lt_succ_iff.mp h }\nend\n\nlemma index_type.not_lt_zero {N : ℕ} (j : index_type N) : ¬ (j < 0) :=\nnat.cases_on N nat.not_lt_zero (λ n, fin.not_lt_zero) j\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/indexing.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.46636717779316095}}
{"text": "import Rings.Fields\nimport completeness\nimport Rings.ToMathlib.finset\n\nnamespace Lefschetz\n\nopen fol\nopen Rings\nopen Fields\nopen Rings.instances\n\n/-- Lefschetz part 1. Any sentence or its negation can be deduced in ACF₀-/\ntheorem is_complete'_ACF₀ : is_complete' ACF₀ :=\nbegin\n  sorry\nend\n\n/-- Lefschetz part 1. Being true in a model of ACF₀ implies being true for any model of ACF₀-/\ntheorem is_complete''_ACF₀ : is_complete'' ACF₀ :=\nis_complete''_to_is_complete' (is_complete'_ACF₀)\n\n/-- Lefschetz part 3. Any sentence or its negation can be deduced in ACFₚ-/\ntheorem is_complete'_ACFₚ {p : ℕ} (hp : nat.prime p) : is_complete' (ACFₚ hp) :=\nbegin\n  sorry\nend\n\n/-- Lefcschetz part 3. Being true in a model of ACFₚ implies being true for any model of ACFₚ-/\ntheorem is_complete''_ACFₚ {p : ℕ} (hp : nat.prime p) :\n  is_complete'' (ACFₚ hp) :=\nis_complete''_to_is_complete' (is_complete'_ACFₚ hp)\n\n/-- Lefchetz part 2. A sentence holds for ACF₀ if and only if it holds for ACFₚ for large enough p -/\ntheorem characteristic_change_left (ϕ : sentence ring_signature) :\nACF₀ ⊨ ϕ → ∃ (n : ℕ), ∀ {p : ℕ} (hp : nat.prime p), n < p → ACFₚ hp ⊨ ϕ :=\nbegin\n  rw compactness,\n  intro hsatis,\n  obtain ⟨ fs , hsatis , hsub ⟩ := hsatis,\n  classical,\n  obtain ⟨ fsACF , fsrange , hunion, hACF , hrange ⟩ :=\n    finset.subset_union_elim hsub,\n  set fsnat : finset ℕ := finset.preimage fsrange plus_one_ne_zero\n      (set.inj_on_of_injective injective_plus_one_ne_zero _) with hfsnat,\n  use fsnat.sup id + 1,\n  intros p hp hlt M hMx hmodel,\n  have _inst_1 : fact (M ⊨ ACF) := ⟨ (models_ACFₚ_iff.mp hmodel).2 ⟩,\n  have hchar := @models_ACFₚ_char _ _ _inst_1 _ hmodel,\n  apply hsatis hMx,\n  rw [← hunion, finset.coe_union, all_realize_sentence_union],\n  split,\n  {\n    apply all_realize_sentence_of_subset _ hACF,\n    exact all_realize_sentence_of_subset hmodel ACF_subset_ACFₚ,\n  },\n  {\n    have hSTS :(∀ n : ℕ, n ∈ fsnat → M ⊨ plus_one_ne_zero n) → M ⊨ fsrange,\n    {\n      classical,\n      have hrw0 := finset.image_preimage plus_one_ne_zero fsrange\n        (set.inj_on_of_injective injective_plus_one_ne_zero _),\n      rw [← hfsnat, finset.filter_mem_set_of_subset_set (λ x hx, (hrange hx).1)]\n        at hrw0,\n      rw ← hrw0,\n      simp only [all_realize_sentence],\n      intros hrealize ϕ hϕ,\n      simp only [set.mem_preimage, set.mem_image,\n        finset.coe_preimage, finset.mem_coe, finset.coe_image] at hϕ,\n      obtain ⟨ n , hn , hϕ ⟩ := hϕ,\n      rw [← hϕ],\n      apply hrealize,\n      rw [hfsnat, finset.mem_preimage],\n      exact hn,\n    },\n    apply hSTS,\n    intros n hnp,\n    rw realize_plus_one_ne_zero,\n    have hne_zero_of_le_char :\n      ∀ x : ℕ, x.succ < p → (x.succ : M) ≠ 0,\n    {\n      intros x hx hbot,\n      apply nat.succ_ne_zero x,\n      have hfield : field M.carrier := @models_ACF_to.Field _ _inst_1,\n      apply @ring_char.lt_char_field _ (models_ACF_to.Field),\n      { exact hbot },\n      rw ← hchar at hx,\n      exact hx,\n    },\n    apply hne_zero_of_le_char _,\n    apply lt_of_le_of_lt (nat.succ_le_succ _) hlt,\n    exact finset.le_sup hnp,\n  },\nend\n\n/-- Any ring fact holds in ACF₀ if and only if for all large p it holds for all ACFₚ-/\ntheorem characteristic_change (ϕ : sentence ring_signature) :\nACF₀ ⊨ ϕ ↔ (∃ (n : ℕ), ∀ {p : ℕ} (hp : nat.prime p), n < p → ACFₚ hp ⊨ ϕ) :=\nbegin\n  split,\n  { apply characteristic_change_left },\n  {\n    intro hn,\n    cases is_complete'_ACF₀ ϕ with hsatis hsatis,\n    { exact hsatis },\n    {\n      have hm := characteristic_change_left (∼ ϕ) hsatis,\n      cases hn with n hn,\n      cases hm with m hm,\n      obtain ⟨ p , hle , hp ⟩ := nat.exists_infinite_primes (max n m).succ,\n      have hnp : n < p :=\n        lt_of_lt_of_le (nat.lt_succ_of_le (le_max_left _ _)) hle,\n      have hmp : m < p :=\n        lt_of_lt_of_le (nat.lt_succ_of_le (le_max_right _ _)) hle,\n      have hS := instances.algebraic_closure_of_zmod_models_ACFₚ hp,\n      specialize @hn p hp hnp _ ⟨ 0 ⟩ hS,\n      specialize @hm p hp hmp _ ⟨ 0 ⟩ hS,\n      simp only [realize_sentence_not] at hm,\n      exfalso,\n      apply hm hn,\n    },\n  },\nend\n\n\n\n\n\n\n\n\n\n\nend Lefschetz\n", "meta": {"author": "Jlh18", "repo": "ModelTheoryInLean8", "sha": "fbda7d869d4169b6e739bb74165e99ee03ca63d6", "save_path": "github-repos/lean/Jlh18-ModelTheoryInLean8", "path": "github-repos/lean/Jlh18-ModelTheoryInLean8/ModelTheoryInLean8-fbda7d869d4169b6e739bb74165e99ee03ca63d6/Trash/Rings/Lefschetz.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673223709252, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.46632443096793813}}
{"text": "import geometry.manifold.diffeomorph\nimport geometry.manifold.algebra.monoid\nimport geometry.manifold.metrizable\nimport to_mathlib.analysis.calculus\n\nopen bundle set function filter\nopen_locale manifold topology\nnoncomputable theory\n\nsection charted_space\n\nvariables {M H : Type*} [topological_space M] [topological_space H] [charted_space H M]\n  (G : structure_groupoid H)\n\nend charted_space\n\nnamespace model_with_corners\n\nvariables {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n  {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]\n  {H : Type*} [topological_space H]\n  {M : Type*} [topological_space M] (f : local_homeomorph M H) (I : model_with_corners 𝕜 E H)\n\nend model_with_corners\n\n\n-- todo: make `vector_bundle_core.total_space` protected!\nnamespace vector_bundle_core\n\nvariables {𝕜 B F : Type*} [nontrivially_normed_field 𝕜]\n  [normed_add_comm_group F] [normed_space 𝕜 F] [topological_space B]\n  {ι : Type*} (Z : vector_bundle_core 𝕜 B F ι) {i j : ι}\n\n@[simp, mfld_simps] lemma local_triv_continuous_linear_map_at {b : B} (hb : b ∈ Z.base_set i) :\n  (Z.local_triv i).continuous_linear_map_at 𝕜 b = Z.coord_change (Z.index_at b) i b :=\nbegin\n  ext1 v,\n  rw [(Z.local_triv i).continuous_linear_map_at_apply 𝕜, (Z.local_triv i).coe_linear_map_at_of_mem],\n  exacts [rfl, hb]\nend\n\n@[simp, mfld_simps] lemma trivialization_at_continuous_linear_map_at {b₀ b : B}\n  (hb : b ∈ (trivialization_at F Z.fiber b₀).base_set) :\n  (trivialization_at F Z.fiber b₀).continuous_linear_map_at 𝕜 b =\n  Z.coord_change (Z.index_at b) (Z.index_at b₀) b :=\nZ.local_triv_continuous_linear_map_at hb\n\n@[simp, mfld_simps] lemma local_triv_symmL {b : B} (hb : b ∈ Z.base_set i) :\n  (Z.local_triv i).symmL 𝕜 b = Z.coord_change i (Z.index_at b) b :=\nby { ext1 v, rw [(Z.local_triv i).symmL_apply 𝕜, (Z.local_triv i).symm_apply], exacts [rfl, hb] }\n\n@[simp, mfld_simps] lemma trivialization_at_symmL {b₀ b : B}\n  (hb : b ∈ (trivialization_at F Z.fiber b₀).base_set) :\n  (trivialization_at F Z.fiber b₀).symmL 𝕜 b = Z.coord_change (Z.index_at b₀) (Z.index_at b) b :=\nZ.local_triv_symmL hb\n\n@[simp, mfld_simps] lemma trivialization_at_coord_change_eq {b₀ b₁ b : B}\n  (hb : b ∈ (trivialization_at F Z.fiber b₀).base_set ∩ (trivialization_at F Z.fiber b₁).base_set)\n  (v : F) :\n  (trivialization_at F Z.fiber b₀).coord_changeL 𝕜 (trivialization_at F Z.fiber b₁) b v =\n  Z.coord_change (Z.index_at b₀) (Z.index_at b₁) b v :=\nZ.local_triv_coord_change_eq _ _ hb v\n\nend vector_bundle_core\n\nnamespace tangent_bundle\n\nvariables {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n{E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]\n{H : Type*} [topological_space H] {I : model_with_corners 𝕜 E H}\n{M : Type*} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M]\n{F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F]\n\nlemma ext_chart_at_def (x : M) : ext_chart_at I x = (chart_at H x).extend I := rfl\n\nlemma coord_change_at_self {b b' x : F} :\n  (tangent_bundle_core 𝓘(𝕜, F) F).coord_change (achart F b) (achart F b') x = 1 :=\nby simpa only [tangent_bundle_core_coord_change] with mfld_simps using\n    fderiv_within_id unique_diff_within_at_univ\n\nend tangent_bundle\n\nsection smooth_manifold_with_corners\nopen smooth_manifold_with_corners\n\nvariables {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n  {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]\n  {E' : Type*} [normed_add_comm_group E'] [normed_space 𝕜 E']\n  {F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F]\n  {F' : Type*} [normed_add_comm_group F'] [normed_space 𝕜 F']\n  {H : Type*} [topological_space H] {I : model_with_corners 𝕜 E H}\n  {H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}\n  {G : Type*} [topological_space G] {J : model_with_corners 𝕜 F G}\n  {G' : Type*} [topological_space G'] {J' : model_with_corners 𝕜 F' G'}\n  {M : Type*} [topological_space M] [charted_space H M]\n  {M' : Type*} [topological_space M'] [charted_space H' M']\n  {N : Type*} [topological_space N] [charted_space G N]\n  {N' : Type*} [topological_space N'] [charted_space G' N']\n  {F'' : Type*} [normed_add_comm_group F''] [normed_space 𝕜 F'']\nvariables {f : M → M'} {m n : ℕ∞} {s : set M} {x x' : M}\n-- declare some additional normed spaces, used for fibers of vector bundles\n{F₁ : Type*} [normed_add_comm_group F₁] [normed_space 𝕜 F₁]\n{F₂ : Type*} [normed_add_comm_group F₂] [normed_space 𝕜 F₂]\n\nvariables [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M']\n  [smooth_manifold_with_corners J N]\n\n-- this can be useful to see where we (ab)use definitional equalities\n-- local attribute [irreducible] tangent_space\n\n/-! The two instances below deserve some further thought. For example one might not want the tangent\nspace at every point to carry a canonical norm.\n\nNote that `dual_pair.update` requires `F` to be a `normed_add_comm_group` (though perhaps we could\nget away with `has_continuous_smul` with sufficient extra work).\n\nIn `rel_mfld.slice` we use `dual_pair.update` applied to `tangent_space`. If we don't add these\ninstances, then in fact Lean still accepts the definition. What is going on is that Lean\nis unfolding the definition of `tangent_space`, realizing that `tangent_space I x = E` and\n`tangent_space I' y = E'` and using the `normed_add_comm_group` instances of these types.\nNote that this still uses these instances but at the cost that up to reducible transparency, the\nterm is not type-correct (in other words: you have to unfold `tangent_space` to realize that the\nterm is type-correct).\n\nThis means that many tactics, like `simp`, `rw`, and `dsimp` fail to rewrite within this term,\nbecause the result is not type correct up to reducible transparancy.\n\nDeclaring these instances avoids such problems. -/\n\ninstance {x : M} : normed_add_comm_group (tangent_space I x) := by delta_instance tangent_space\ninstance {x : M} : normed_space 𝕜 (tangent_space I x) := by delta_instance tangent_space\n\n-- lemma tangent_bundle_core_coord_change_achart (x x' : M) (z : H) :\n--   (tangent_bundle_core I M).coord_change (achart H x) (achart H x') z =\n--   fderiv_within 𝕜 (ext_chart_at I x' ∘ (ext_chart_at I x).symm) (range I) (I z) :=\n-- rfl\n\nvariables (I)\n-- used in tangent_bundle_model_space_chart_at\n\nlemma cont_mdiff_prod {f : M → M' × N'} :\n  cont_mdiff I (I'.prod J') n f ↔\n  cont_mdiff I I' n (λ x, (f x).1) ∧ cont_mdiff I J' n (λ x, (f x).2) :=\n⟨λ h, ⟨h.fst, h.snd⟩, λ h, by { convert h.1.prod_mk h.2, ext x; refl }⟩\n\nlemma cont_mdiff_at_prod {f : M → M' × N'} {x : M} :\n  cont_mdiff_at I (I'.prod J') n f x ↔\n  cont_mdiff_at I I' n (λ x, (f x).1) x ∧ cont_mdiff_at I J' n (λ x, (f x).2) x :=\n⟨λ h, ⟨h.fst, h.snd⟩, λ h, by { convert h.1.prod_mk h.2, ext x; refl }⟩\n\nlemma model_with_corners.fderiv_within_comp_symm (x : H) :\n  fderiv_within 𝕜 (I ∘ I.symm) (range I) (I x) = continuous_linear_map.id 𝕜 E :=\nbegin\n  have : fderiv_within 𝕜 (I ∘ I.symm) (range I) (I x) = fderiv_within 𝕜 id (range I) (I x),\n  { refine fderiv_within_congr I.unique_diff_at_image (λ y hy, _) (by simp only with mfld_simps),\n    exact model_with_corners.right_inv _ hy },\n  rwa fderiv_within_id I.unique_diff_at_image at this\nend\n\n\nlemma tangent_bundle_core_coord_change_model_space (x x' : H) (z : H) :\n  (tangent_bundle_core I H).coord_change (achart H x) (achart H x') z =\n  continuous_linear_map.id 𝕜 E :=\nbegin\n  simp only [tangent_bundle_core_coord_change_achart, ext_chart_at, I.fderiv_within_comp_symm] with mfld_simps,\nend\n\n\nlemma cont_diff_on_coord_change' {e e' : local_homeomorph M H}\n  (h : e ∈ atlas H M) (h' : e' ∈ atlas H M) :\n  cont_diff_on 𝕜 ⊤ (I ∘ (e.symm ≫ₕ e') ∘ I.symm) (I.symm ⁻¹' (e.symm ≫ₕ e').source ∩ range I) :=\n(has_groupoid.compatible (cont_diff_groupoid ⊤ I) h h').1\n\nvariables {I}\n/-- A congruence lemma for `mfderiv`, (ab)using the fact that `tangent_space I' (f x)` is\ndefinitionally equal to `E'`. -/\nlemma mfderiv_congr_point {x' : M} (h : x = x') :\n  @eq (E →L[𝕜] E') (mfderiv I I' f x) (mfderiv I I' f x') :=\nby subst h\n\n/-- A congruence lemma for `mfderiv`, (ab)using the fact that `tangent_space I' (f x)` is\ndefinitionally equal to `E'`. -/\nlemma mfderiv_congr {f' : M → M'} (h : f = f') :\n  @eq (E →L[𝕜] E') (mfderiv I I' f x) (mfderiv I I' f' x) :=\nby subst h\n\n/-- The derivative of the projection `M × M' → M` is the projection `TM × TM' → TM` -/\nlemma mfderiv_fst (x : M × M') :\n  mfderiv (I.prod I') I prod.fst x = continuous_linear_map.fst 𝕜 E E' :=\nbegin\n  simp_rw [mfderiv, if_pos smooth_at_fst.mdifferentiable_at, written_in_ext_chart_at,\n    ext_chart_at_prod, function.comp, local_equiv.prod_coe, local_equiv.prod_coe_symm],\n  have : unique_diff_within_at 𝕜 (range (I.prod I')) (ext_chart_at (I.prod I') x x) :=\n  (I.prod I').unique_diff _ (mem_range_self _),\n  refine (filter.eventually_eq.fderiv_within_eq this _ _).trans _,\n  swap 3,\n  { exact (ext_chart_at I x.1).right_inv ((ext_chart_at I x.1).maps_to $\n      mem_ext_chart_source I x.1) },\n  { refine eventually_of_mem (ext_chart_at_target_mem_nhds_within (I.prod I') x)\n      (λ y hy, local_equiv.right_inv _ _),\n    rw [ext_chart_at_prod] at hy,\n    exact hy.1 },\n  exact fderiv_within_fst this,\nend\n\n/-- The derivative of the projection `M × M' → M'` is the projection `TM × TM' → TM'` -/\nlemma mfderiv_snd (x : M × M') :\n  mfderiv (I.prod I') I' prod.snd x = continuous_linear_map.snd 𝕜 E E' :=\nbegin\n  simp_rw [mfderiv, if_pos smooth_at_snd.mdifferentiable_at, written_in_ext_chart_at,\n    ext_chart_at_prod, function.comp, local_equiv.prod_coe, local_equiv.prod_coe_symm],\n  have : unique_diff_within_at 𝕜 (range (I.prod I')) (ext_chart_at (I.prod I') x x) :=\n  (I.prod I').unique_diff _ (mem_range_self _),\n  refine (filter.eventually_eq.fderiv_within_eq this _ _).trans _,\n  swap 3,\n  { exact (ext_chart_at I' x.2).right_inv ((ext_chart_at I' x.2).maps_to $\n      mem_ext_chart_source I' x.2) },\n  { refine eventually_of_mem (ext_chart_at_target_mem_nhds_within (I.prod I') x)\n      (λ y hy, local_equiv.right_inv _ _),\n    rw [ext_chart_at_prod] at hy,\n    exact hy.2 },\n  exact fderiv_within_snd this,\nend\n\nlemma mdifferentiable_at.prod_mk {f : N → M} {g : N → M'} {x : N}\n  (hf : mdifferentiable_at J I f x)\n  (hg : mdifferentiable_at J I' g x) :\n  mdifferentiable_at J (I.prod I') (λ x, (f x, g x)) x :=\n⟨hf.1.prod hg.1, hf.2.prod hg.2⟩\n\n\n-- todo: rename differentiable_at.fderiv_within_prod -> differentiable_within_at.fderiv_within_prod\nlemma mdifferentiable_at.mfderiv_prod {f : N → M} {g : N → M'} {x : N}\n  (hf : mdifferentiable_at J I f x)\n  (hg : mdifferentiable_at J I' g x) :\n  mfderiv J (I.prod I') (λ x, (f x, g x)) x = (mfderiv J I f x).prod (mfderiv J I' g x) :=\nbegin\n  classical,\n  simp_rw [mfderiv, if_pos (hf.prod_mk hg), if_pos hf, if_pos hg],\n  exact differentiable_at.fderiv_within_prod hf.2 hg.2 (J.unique_diff _ (mem_range_self _))\nend\n\nlemma mfderiv_prod_left {x₀ : M} {y₀ : M'} :\n  mfderiv I (I.prod I') (λ x, (x, y₀)) x₀ = continuous_linear_map.inl 𝕜 E E' :=\nbegin\n  refine ((mdifferentiable_at_id I).mfderiv_prod (mdifferentiable_at_const I I')).trans _,\n  rw [mfderiv_id, mfderiv_const],\n  refl\nend\n\nlemma mfderiv_prod_right {x₀ : M} {y₀ : M'} :\n  mfderiv I' (I.prod I') (λ y, (x₀, y)) y₀ = continuous_linear_map.inr 𝕜 E E' :=\nbegin\n  refine ((mdifferentiable_at_const I' I).mfderiv_prod (mdifferentiable_at_id I')).trans _,\n  rw [mfderiv_id, mfderiv_const],\n  refl\nend\n\nlemma mfderiv_prod_eq_add {f : N × M → M'} {p : N × M}\n  (hf : mdifferentiable_at (J.prod I) I' f p) :\n  mfderiv (J.prod I) I' f p =\n  (show F × E →L[𝕜] E', from mfderiv (J.prod I) I' (λ (z : N × M), f (z.1, p.2)) p +\n  mfderiv (J.prod I) I' (λ (z : N × M), f (p.1, z.2)) p) :=\nbegin\n  dsimp only,\n  rw [← @prod.mk.eta _ _ p] at hf,\n  rw [mfderiv_comp p (by apply hf) (smooth_fst.prod_mk smooth_const).mdifferentiable_at,\n    mfderiv_comp p (by apply hf) (smooth_const.prod_mk smooth_snd).mdifferentiable_at,\n    ← continuous_linear_map.comp_add,\n    smooth_fst.mdifferentiable_at.mfderiv_prod smooth_const.mdifferentiable_at,\n    smooth_const.mdifferentiable_at.mfderiv_prod smooth_snd.mdifferentiable_at,\n    mfderiv_fst, mfderiv_snd, mfderiv_const, mfderiv_const],\n  symmetry,\n  convert continuous_linear_map.comp_id _,\n  { exact continuous_linear_map.fst_prod_zero_add_zero_prod_snd },\n  simp_rw [prod.mk.eta],\nend\n\n-- lemma cont_mdiff_within_at_insert :\n--   cont_mdiff_within_at I I' n f (insert x' s) x ↔ cont_mdiff_within_at I I' n f s x :=\n-- begin\n--   sorry\n-- end\n\n-- alias cont_mdiff_within_at_insert ↔ cont_mdiff_within_at.of_insert cont_mdiff_within_at.insert'\n\n-- lemma cont_mdiff_within_at.insert (h : cont_mdiff_within_at I I' n f s x) :\n--   cont_mdiff_within_at I I' n f (insert x s) x :=\n-- h.insert'\n\nopen bundle\nvariables\n  {Z : M → Type*} [topological_space (total_space Z)] [∀ b, topological_space (Z b)]\n  [∀ b, add_comm_monoid (Z b)] [∀ b, module 𝕜 (Z b)]\n  [fiber_bundle F₁ Z] [vector_bundle 𝕜 F₁ Z] [smooth_vector_bundle F₁ Z I]\n  {Z₂ : M' → Type*} [topological_space (total_space Z₂)] [∀ b, topological_space (Z₂ b)]\n  [∀ b, add_comm_monoid (Z₂ b)] [∀ b, module 𝕜 (Z₂ b)]\n  [fiber_bundle F₂ Z₂] [vector_bundle 𝕜 F₂ Z₂] [smooth_vector_bundle F₂ Z₂ I']\n\nvariables (I I' Z Z₂ F₁ F₂)\n\n/-- When `ϕ` is a continuous linear map that changes vectors in charts around `x` to vectors\n  in charts around `y`, `in_coordinates' Z Z₂ x₀ x y₀ y ϕ` is a coordinate change of this continuous\n  linear map that makes sense from charts around `x₀` to charts around `y₀`\n  by composing it with appropriate coordinate changes given by smooth vector bundles `Z` and `Z₂`.\n-/\ndef in_coordinates' (x₀ x : M) (y₀ y : M') (ϕ : Z x →L[𝕜] Z₂ y) : F₁ →L[𝕜] F₂ :=\n(trivialization_at F₂ Z₂ y₀).continuous_linear_map_at 𝕜 y ∘L ϕ ∘L\n(trivialization_at F₁ Z x₀).symmL 𝕜 x\n\n/-- When `ϕ x` is a continuous linear map that changes vectors in charts around `f x` to vectors\n  in charts around `g x`, `in_coordinates I I' f g ϕ x₀ x` is a coordinate change of this continuous\n  linear map that makes sense from charts around `f x₀` to charts around `g x₀`\n  by composing it with appropriate coordinate changes. -/\ndef in_coordinates (f : N → M) (g : N → M')\n  (ϕ : Π x : N, tangent_space I (f x) →L[𝕜] tangent_space I' (g x)) : N → N → E →L[𝕜] E' :=\nλ x₀ x, in_coordinates' E E' (tangent_space I) (tangent_space I') (f x₀) (f x) (g x₀) (g x) (ϕ x)\n\nvariables {F₁ F₂}\n\n/-! Todo: use `in_coordinates` instead of `in_coordinates_core`.\nThese are the same mathematical object, but not equal, since they are defined differently if the\n`x` and the `y` are not in the right charts. -/\n\ndef in_coordinates_core' {ι₁ ι₂} (Z₁ : vector_bundle_core 𝕜 M F₁ ι₁)\n  (Z₂ : vector_bundle_core 𝕜 M' F₂ ι₂) (x₀ x : M) (y₀ y : M') (ϕ : F₁ →L[𝕜] F₂) : F₁ →L[𝕜] F₂ :=\nZ₂.coord_change (Z₂.index_at y) (Z₂.index_at y₀) y ∘L ϕ ∘L\n  Z₁.coord_change (Z₁.index_at x₀) (Z₁.index_at x) x\n\ndef in_coordinates_core (f : N → M) (g : N → M') (ϕ : N → E →L[𝕜] E') :\n  N → N → E →L[𝕜] E' :=\nλ x₀ x, in_coordinates_core' (tangent_bundle_core I M) (tangent_bundle_core I' M')\n  (f x₀) (f x) (g x₀) (g x) (ϕ x)\n\n/-- rewrite `in_coordinates'` using continuous linear equivalences. -/\nlemma in_coordinates'_eq (x₀ x : M) (y₀ y : M') (ϕ : Z x →L[𝕜] Z₂ y)\n  (hx : x ∈ (trivialization_at F₁ Z x₀).base_set)\n  (hy : y ∈ (trivialization_at F₂ Z₂ y₀).base_set) :\n  in_coordinates' F₁ F₂ Z Z₂ x₀ x y₀ y ϕ =\n  ((trivialization_at F₂ Z₂ y₀).continuous_linear_equiv_at 𝕜 y hy : Z₂ y →L[𝕜] F₂) ∘L ϕ ∘L\n  (((trivialization_at F₁ Z x₀).continuous_linear_equiv_at 𝕜 x hx).symm : F₁ →L[𝕜] Z x) :=\nbegin\n  ext,\n  simp_rw [in_coordinates', continuous_linear_map.coe_comp', continuous_linear_equiv.coe_coe,\n    trivialization.coe_continuous_linear_equiv_at_eq,\n    trivialization.symm_continuous_linear_equiv_at_eq]\nend\n\n/-- The map `in_coordinates_core'` is trivial on the model spaces -/\nlemma in_coordinates_core'_tangent_bundle_core_model_space\n  (x₀ x : H) (y₀ y : H') (ϕ : E →L[𝕜] E') :\n    in_coordinates_core' (tangent_bundle_core I H) (tangent_bundle_core I' H') x₀ x y₀ y ϕ = ϕ :=\nby simp_rw [in_coordinates_core', tangent_bundle_core_index_at,\n  tangent_bundle_core_coord_change_model_space,\n  continuous_linear_map.id_comp, continuous_linear_map.comp_id]\n\nlemma in_coordinates_core_model_space (f : N → H) (g : N → H') (ϕ : N → E →L[𝕜] E') (x₀ : N) :\n    in_coordinates_core I I' f g ϕ x₀ = ϕ :=\nby simp_rw [in_coordinates_core, in_coordinates_core'_tangent_bundle_core_model_space]\n\nlemma in_coordinates_core'_eq {ι₁ ι₂} (Z₁ : vector_bundle_core 𝕜 M F₁ ι₁)\n  (Z₂ : vector_bundle_core 𝕜 M' F₂ ι₂)\n  {x₀ x : M} {y₀ y : M'} (ϕ : F₁ →L[𝕜] F₂)\n  (hx : x ∈ Z₁.base_set (Z₁.index_at x₀))\n  (hy : y ∈ Z₂.base_set (Z₂.index_at y₀)) :\n    in_coordinates' F₁ F₂ Z₁.fiber Z₂.fiber x₀ x y₀ y ϕ =\n    in_coordinates_core' Z₁ Z₂ x₀ x y₀ y ϕ :=\nby simp_rw [in_coordinates', in_coordinates_core',\n    Z₂.trivialization_at_continuous_linear_map_at hy, Z₁.trivialization_at_symmL hx]\n\nvariables {I I'}\n\n-- lemma cont_mdiff_within_at.mfderiv {s : set N} {x : N} (f : N → M → M') (g : N → M)\n--   (hf : cont_mdiff_within_at (J.prod I) I' n (function.uncurry f) (prod.fst ⁻¹' s) (x, g x))\n--   (hg : cont_mdiff_within_at J I m g s x) (hmn : m + 1 ≤ n) (hxs : x ∈ s) :\n--   -- todo: remove x ∈ s hypothesis by working with `insert x s` everywhere.\n--   cont_mdiff_within_at J 𝓘(𝕜, E →L[𝕜] E') m\n--     (in_coordinates_core I I' g (λ x, f x (g x)) (λ x', mfderiv I I' (f x') (g x')) x) s x :=\n-- begin\n--   have h4f : continuous_within_at (λ x, f x (g x)) s x,\n--   { apply continuous_within_at.comp (by apply hf.continuous_within_at)\n--       (continuous_within_at_id.prod hg.continuous_within_at),\n--     simp_rw [maps_to', image_subset_iff, preimage_preimage, preimage_id] },\n--   have h3f := cont_mdiff_within_at_iff_cont_mdiff_on_nhds.mp\n--     (hf.of_le $ (self_le_add_left 1 m).trans hmn),\n--   have h2f : ∀ᶠ x₂ in 𝓝[s] x, cont_mdiff_at I I' 1 (f x₂) (g x₂),\n--   sorry,\n--   -- { refine ((continuous_within_at_id.prod hg.continuous_within_at).tendsto.eventually h3f).mono (λ x hx, _),\n--   --   exact hx.comp (g x) (cont_mdiff_within_at_const.prod_mk cont_mdiff_within_at_id) },\n--   have h2g := hg.continuous_within_at.preimage_mem_nhds_within\n--     (ext_chart_at_source_mem_nhds I (g x)),\n--   have : cont_diff_within_at 𝕜 m (λ x', fderiv_within 𝕜\n--     (ext_chart_at I' (f x (g x)) ∘ f ((ext_chart_at J x).symm x') ∘ (ext_chart_at I (g x)).symm)\n--     (range I) (ext_chart_at I (g x) (g ((ext_chart_at J x).symm x'))))\n--     ((ext_chart_at J x).symm ⁻¹' s ∩ range J) (ext_chart_at J x x),\n--   { rw [cont_mdiff_within_at_iff] at hf hg,\n--     simp_rw [function.comp, uncurry, ext_chart_at_prod, local_equiv.prod_coe_symm] at hf ⊢,\n--     refine (cont_diff_within_at_fderiv_within _\n--       (hg.2.mono_of_mem _) I.unique_diff hmn _ _ _ _).mono_of_mem _,\n--     swap 3,\n--     { simp_rw [function.comp, ext_chart_at_to_inv], exact hf.2 },\n--     { refine (ext_chart_at J x).symm ⁻¹' s ∩ (ext_chart_at J x).target ∩\n--         (ext_chart_at J x).symm ⁻¹' (g ⁻¹' (ext_chart_at I (g x)).source) },\n--     { refine mem_of_superset self_mem_nhds_within ((inter_subset_left _ _).trans $ _),\n--       exact inter_subset_inter_right _ (ext_chart_at_target_subset_range J x) },\n--     { simp_rw [mem_inter_iff, mem_preimage, ext_chart_at_to_inv],\n--       exact ⟨⟨hxs, local_equiv.maps_to _ (mem_ext_chart_source J x)⟩,\n--         mem_ext_chart_source I (g x)⟩ },\n--     { simp_rw [model_with_corners.range_prod],\n--       rw [inter_assoc, inter_prod],\n--       refine inter_subset_inter _ _,\n--       { sorry },\n--       exact set.prod_mono ((inter_subset_left _ _).trans $ ext_chart_at_target_subset_range J x)\n--         subset_rfl },\n--     { refine eventually_of_forall (λ x', mem_range_self _) },\n--     swap 2,\n--     { sorry,\n--       -- refine inter_mem (ext_chart_at_target_mem_nhds_within J x) _,\n--       -- ext_chart_at_preimage_mem_nhds_within\n--       -- refine nhds_within_le_nhds (ext_chart_at_preimage_mem_nhds' _ _ (mem_ext_chart_source J x) _),\n--       -- exact hg.1.preimage_mem_nhds (ext_chart_at_source_mem_nhds I (g x))\n--       },\n--     simp_rw [function.comp, ext_chart_at_to_inv],\n--     refine mem_of_superset self_mem_nhds_within _,\n--     refine (image_subset_range _ _).trans _,\n--     exact range_comp_subset_range (λ a, chart_at H (g x) $ g $ (chart_at G x).symm $ J.symm a) I },\n--   have : cont_mdiff_within_at J 𝓘(𝕜, E →L[𝕜] E') m\n--     (λ x', fderiv_within 𝕜 (ext_chart_at I' (f x (g x)) ∘ f x' ∘ (ext_chart_at I (g x)).symm)\n--     (range I) (ext_chart_at I (g x) (g x'))) s x,\n--   { simp_rw [cont_mdiff_within_at_iff_source_of_mem_source (mem_chart_source G x),\n--       cont_mdiff_within_at_iff_cont_diff_within_at, function.comp],\n--     exact this },\n--   have : cont_mdiff_within_at J 𝓘(𝕜, E →L[𝕜] E') m\n--     (λ x', fderiv_within 𝕜 (ext_chart_at I' (f x (g x)) ∘ (ext_chart_at I' (f x' (g x'))).symm ∘\n--       written_in_ext_chart_at I I' (g x') (f x') ∘ ext_chart_at I (g x') ∘\n--       (ext_chart_at I (g x)).symm) (range I) (ext_chart_at I (g x) (g x'))) s x,\n--   { refine this.congr_of_eventually_eq _ sorry,\n--     filter_upwards [h2g, h2f],\n--     intros x₂ hx₂ h2x₂,\n--     have : ∀ x' ∈ (ext_chart_at I (g x)).symm ⁻¹' (ext_chart_at I (g x₂)).source ∩\n--         (ext_chart_at I (g x)).symm ⁻¹' (f x₂ ⁻¹' (ext_chart_at I' (f x₂ (g x₂))).source),\n--       (ext_chart_at I' (f x (g x)) ∘ (ext_chart_at I' (f x₂ (g x₂))).symm ∘\n--       written_in_ext_chart_at I I' (g x₂) (f x₂) ∘ ext_chart_at I (g x₂) ∘\n--       (ext_chart_at I (g x)).symm) x' =\n--       ext_chart_at I' (f x (g x)) (f x₂ ((ext_chart_at I (g x)).symm x')),\n--     { rintro x' ⟨hx', h2x'⟩,\n--       simp_rw [written_in_ext_chart_at, function.comp_apply],\n--       rw [(ext_chart_at I (g x₂)).left_inv hx', (ext_chart_at I' (f x₂ (g x₂))).left_inv h2x'] },\n--     refine filter.eventually_eq.fderiv_within_eq_nhds (I.unique_diff _ $ mem_range_self _) _,\n--     refine eventually_of_mem (inter_mem _ _) this,\n--     { exact ext_chart_at_preimage_mem_nhds' _ _ hx₂ (ext_chart_at_source_mem_nhds I (g x₂)) },\n--     refine ext_chart_at_preimage_mem_nhds' _ _ hx₂ _,\n--     exact h2x₂.continuous_at.preimage_mem_nhds (ext_chart_at_source_mem_nhds _ _) },\n--   /- The conclusion is the same as the following, when unfolding coord_change of\n--     `tangent_bundle_core` -/\n--   change cont_mdiff_within_at J 𝓘(𝕜, E →L[𝕜] E') m\n--     (λ x', (fderiv_within 𝕜 (ext_chart_at I' (f x (g x)) ∘ (ext_chart_at I' (f x' (g x'))).symm)\n--         (range I') (ext_chart_at I' (f x' (g x')) (f x' (g x')))).comp\n--         ((mfderiv I I' (f x') (g x')).comp (fderiv_within 𝕜 (ext_chart_at I (g x') ∘\n--         (ext_chart_at I (g x)).symm) (range I) (ext_chart_at I (g x) (g x'))))) s x,\n--   refine this.congr_of_eventually_eq _ sorry,\n--   filter_upwards [h2g, h2f,\n--     h4f.preimage_mem_nhds_within (ext_chart_at_source_mem_nhds I' (f x (g x)))],\n--   intros x₂ hx₂ h2x₂ h3x₂,\n--   symmetry,\n--   rw [(h2x₂.mdifferentiable_at le_rfl).mfderiv],\n--   have hI := (cont_diff_within_at_ext_coord_change I (g x₂) (g x) $\n--     local_equiv.mem_symm_trans_source _ hx₂ $ mem_ext_chart_source I (g x₂))\n--     .differentiable_within_at le_top,\n--   have hI' := (cont_diff_within_at_ext_coord_change I' (f x (g x)) (f x₂ (g x₂)) $\n--     local_equiv.mem_symm_trans_source _\n--     (mem_ext_chart_source I' (f x₂ (g x₂))) h3x₂).differentiable_within_at le_top,\n--   have h3f := (h2x₂.mdifferentiable_at le_rfl).2,\n--   refine fderiv_within.comp₃ _ hI' h3f hI _ _ _ _ (I.unique_diff _ $ mem_range_self _),\n--   { exact λ x _, mem_range_self _ },\n--   { exact λ x _, mem_range_self _ },\n--   { simp_rw [written_in_ext_chart_at, function.comp_apply,\n--       (ext_chart_at I (g x₂)).left_inv (mem_ext_chart_source I (g x₂))] },\n--   { simp_rw [function.comp_apply, (ext_chart_at I (g x)).left_inv hx₂] }\n-- end\n\n -- todo: prove from cont_mdiff_within_at.mfderiv\n/-- The appropriate (more general) formulation of `cont_mdiff_at.mfderiv''`. -/\nlemma cont_mdiff_at.mfderiv''' {x : N} (f : N → M → M') (g : N → M)\n  (hf : cont_mdiff_at (J.prod I) I' n (function.uncurry f) (x, g x))\n  (hg : cont_mdiff_at J I m g x) (hmn : m + 1 ≤ n) :\n  cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m\n    (in_coordinates_core I I' g (λ x, f x (g x)) (λ x', mfderiv I I' (f x') (g x')) x) x :=\nbegin\n  have h4f : continuous_at (λ x, f x (g x)) x,\n  { apply continuous_at.comp (by apply hf.continuous_at) (continuous_at_id.prod hg.continuous_at) },\n  have h3f := cont_mdiff_at_iff_cont_mdiff_at_nhds.mp (hf.of_le $ (self_le_add_left 1 m).trans hmn),\n  have h2f : ∀ᶠ x₂ in 𝓝 x, cont_mdiff_at I I' 1 (f x₂) (g x₂),\n  { refine ((continuous_at_id.prod hg.continuous_at).tendsto.eventually h3f).mono (λ x hx, _),\n    exact hx.comp (g x) (cont_mdiff_at_const.prod_mk cont_mdiff_at_id) },\n  have h2g := hg.continuous_at.preimage_mem_nhds (ext_chart_at_source_mem_nhds I (g x)),\n  have : cont_diff_within_at 𝕜 m (λ x', fderiv_within 𝕜\n    (ext_chart_at I' (f x (g x)) ∘ f ((ext_chart_at J x).symm x') ∘ (ext_chart_at I (g x)).symm)\n    (range I) (ext_chart_at I (g x) (g ((ext_chart_at J x).symm x'))))\n    (range J) (ext_chart_at J x x),\n  { rw [cont_mdiff_at_iff] at hf hg,\n    simp_rw [function.comp, uncurry, ext_chart_at_prod, local_equiv.prod_coe_symm] at hf ⊢,\n    refine (cont_diff_within_at_fderiv_within _\n      (hg.2.mono_of_mem _) I.unique_diff hmn _ _ _ _).mono_of_mem _,\n    swap 3,\n    { simp_rw [function.comp, ext_chart_at_to_inv], exact hf.2 },\n    { refine (ext_chart_at J x).target ∩\n      (λ x', (ext_chart_at J x).symm x') ⁻¹' (g ⁻¹' (ext_chart_at I (g x)).source) },\n    { exact mem_of_superset self_mem_nhds_within\n        ((inter_subset_left _ _).trans $ ext_chart_at_target_subset_range J x) },\n    { simp_rw [mem_inter_iff, mem_preimage, ext_chart_at_to_inv],\n      exact ⟨local_equiv.maps_to _ (mem_ext_chart_source J x), mem_ext_chart_source I (g x)⟩ },\n    { simp_rw [model_with_corners.range_prod],\n      exact set.prod_mono ((inter_subset_left _ _).trans $ ext_chart_at_target_subset_range J x)\n        subset_rfl },\n    { refine eventually_of_forall (λ x', mem_range_self _) },\n    swap 2,\n    { refine inter_mem (ext_chart_at_target_mem_nhds_within J x) _,\n      refine nhds_within_le_nhds (ext_chart_at_preimage_mem_nhds' _ _ (mem_ext_chart_source J x) _),\n      exact hg.1.preimage_mem_nhds (ext_chart_at_source_mem_nhds I (g x)) },\n    simp_rw [function.comp, ext_chart_at_to_inv],\n    refine mem_of_superset self_mem_nhds_within _,\n    refine (image_subset_range _ _).trans _,\n    exact range_comp_subset_range (λ a, chart_at H (g x) $ g $ (chart_at G x).symm $ J.symm a) I },\n  have : cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m\n    (λ x', fderiv_within 𝕜 (ext_chart_at I' (f x (g x)) ∘ f x' ∘ (ext_chart_at I (g x)).symm)\n    (range I) (ext_chart_at I (g x) (g x'))) x,\n  { simp_rw [cont_mdiff_at_iff_source_of_mem_source (mem_chart_source G x),\n      cont_mdiff_within_at_iff_cont_diff_within_at, function.comp],\n    exact this },\n  have : cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m\n    (λ x', fderiv_within 𝕜 (ext_chart_at I' (f x (g x)) ∘ (ext_chart_at I' (f x' (g x'))).symm ∘\n      written_in_ext_chart_at I I' (g x') (f x') ∘ ext_chart_at I (g x') ∘\n      (ext_chart_at I (g x)).symm) (range I) (ext_chart_at I (g x) (g x'))) x,\n  { refine this.congr_of_eventually_eq _,\n    filter_upwards [h2g, h2f],\n    intros x₂ hx₂ h2x₂,\n    have : ∀ x' ∈ (ext_chart_at I (g x)).symm ⁻¹' (ext_chart_at I (g x₂)).source ∩\n        (ext_chart_at I (g x)).symm ⁻¹' (f x₂ ⁻¹' (ext_chart_at I' (f x₂ (g x₂))).source),\n      (ext_chart_at I' (f x (g x)) ∘ (ext_chart_at I' (f x₂ (g x₂))).symm ∘\n      written_in_ext_chart_at I I' (g x₂) (f x₂) ∘ ext_chart_at I (g x₂) ∘\n      (ext_chart_at I (g x)).symm) x' =\n      ext_chart_at I' (f x (g x)) (f x₂ ((ext_chart_at I (g x)).symm x')),\n    { rintro x' ⟨hx', h2x'⟩,\n      simp_rw [written_in_ext_chart_at, function.comp_apply],\n      rw [(ext_chart_at I (g x₂)).left_inv hx', (ext_chart_at I' (f x₂ (g x₂))).left_inv h2x'] },\n    refine filter.eventually_eq.fderiv_within_eq_nhds (I.unique_diff _ $ mem_range_self _) _,\n    refine eventually_of_mem (inter_mem _ _) this,\n    { exact ext_chart_at_preimage_mem_nhds' _ _ hx₂ (ext_chart_at_source_mem_nhds I (g x₂)) },\n    refine ext_chart_at_preimage_mem_nhds' _ _ hx₂ _,\n    exact (h2x₂.continuous_at).preimage_mem_nhds (ext_chart_at_source_mem_nhds _ _) },\n  /- The conclusion is the same as the following, when unfolding coord_change of\n    `tangent_bundle_core` -/\n  change cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m\n    (λ x', (fderiv_within 𝕜 (ext_chart_at I' (f x (g x)) ∘ (ext_chart_at I' (f x' (g x'))).symm)\n        (range I') (ext_chart_at I' (f x' (g x')) (f x' (g x')))).comp\n        ((mfderiv I I' (f x') (g x')).comp (fderiv_within 𝕜 (ext_chart_at I (g x') ∘\n        (ext_chart_at I (g x)).symm) (range I) (ext_chart_at I (g x) (g x'))))) x,\n  refine this.congr_of_eventually_eq _,\n  filter_upwards [h2g, h2f,\n    h4f.preimage_mem_nhds (ext_chart_at_source_mem_nhds I' (f x (g x)))],\n  intros x₂ hx₂ h2x₂ h3x₂,\n  symmetry,\n  rw [(h2x₂.mdifferentiable_at le_rfl).mfderiv],\n  have hI := (cont_diff_within_at_ext_coord_change I (g x₂) (g x) $\n    local_equiv.mem_symm_trans_source _ hx₂ $ mem_ext_chart_source I (g x₂))\n    .differentiable_within_at le_top,\n  have hI' := (cont_diff_within_at_ext_coord_change I' (f x (g x)) (f x₂ (g x₂)) $\n    local_equiv.mem_symm_trans_source _\n    (mem_ext_chart_source I' (f x₂ (g x₂))) h3x₂).differentiable_within_at le_top,\n  have h3f := (h2x₂.mdifferentiable_at le_rfl).2,\n  refine fderiv_within.comp₃ _ hI' h3f hI _ _ _ _ (I.unique_diff _ $ mem_range_self _),\n  { exact λ x _, mem_range_self _ },\n  { exact λ x _, mem_range_self _ },\n  { simp_rw [written_in_ext_chart_at, function.comp_apply,\n      (ext_chart_at I (g x₂)).left_inv (mem_ext_chart_source I (g x₂))] },\n  { simp_rw [function.comp_apply, (ext_chart_at I (g x)).left_inv hx₂] }\nend\n\n/-- The map `D_xf(x,y)` is `C^n` as a continuous linear map, assuming that `f` is a `C^(n+1)` map\nbetween manifolds.\nWe have to insert appropriate coordinate changes to make sense of this statement.\nThis statement is general enough to work for partial derivatives / functions with parameters. -/\nlemma cont_mdiff_at.mfderiv'' (f : M → M → M')\n  (hf : cont_mdiff_at (I.prod I) I' n (function.uncurry f) (x, x)) (hmn : m + 1 ≤ n) :\n  cont_mdiff_at I 𝓘(𝕜, E →L[𝕜] E') m\n    (in_coordinates_core I I' id (λ x, f x x) (λ x', mfderiv I I' (f x') x') x) x :=\nhf.mfderiv''' f id cont_mdiff_at_id hmn\n\n/-- The map `mfderiv f` is `C^n` as a continuous linear map, assuming that `f` is `C^(n+1)`.\nWe have to insert appropriate coordinate changes to make sense of this statement. -/\nlemma cont_mdiff_at.mfderiv' {f : M → M'}\n  (hf : cont_mdiff_at I I' n f x) (hmn : m + 1 ≤ n) :\n  cont_mdiff_at I 𝓘(𝕜, E →L[𝕜] E') m (in_coordinates_core I I' id f (mfderiv I I' f) x) x :=\nbegin\n  have : cont_mdiff_at (I.prod I) I' n (λ x : M × M, f x.2) (x, x) :=\n  cont_mdiff_at.comp (x, x) hf cont_mdiff_at_snd,\n  apply cont_mdiff_at.mfderiv'' (λ x, f) this hmn\n  -- apply cont_mdiff_at.mfderiv''' (λ x, f) id this cont_mdiff_at_id hmn\nend\n\ninstance has_smooth_add_self : has_smooth_add 𝓘(𝕜, F) F :=\n⟨by { convert cont_diff_add.cont_mdiff, exact model_with_corners_self_prod.symm,\n  exact charted_space_self_prod }⟩\n\nend smooth_manifold_with_corners\n\nsection maps\n\nvariables {𝕜 : Type*} [nontrivially_normed_field 𝕜]\n{E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]\n{E' : Type*} [normed_add_comm_group E'] [normed_space 𝕜 E']\n{F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F]\n{H : Type*} [topological_space H]\n{H' : Type*} [topological_space H']\n{G : Type*} [topological_space G]\n{G' : Type*} [topological_space G']\n{I : model_with_corners 𝕜 E H} {I' : model_with_corners 𝕜 E' H'}\n{J : model_with_corners 𝕜 F G} {J' : model_with_corners 𝕜 F G'}\n\nvariables {M : Type*} [topological_space M] [charted_space H M]\n{M' : Type*} [topological_space M'] [charted_space H' M']\n{N : Type*} [topological_space N] [charted_space G N]\n{N' : Type*} [topological_space N'] [charted_space G' N']\n{n : ℕ∞}\n(f : C^∞⟮I, M; J, N⟯)\n\nnamespace cont_mdiff_map\n\n/-- The first projection of a product, as a smooth map. -/\ndef fst : C^n⟮I.prod I', M × M'; I, M⟯ := ⟨prod.fst, cont_mdiff_fst⟩\n\n/-- The second projection of a product, as a smooth map. -/\ndef snd : C^n⟮I.prod I', M × M'; I', M'⟯ := ⟨prod.snd, cont_mdiff_snd⟩\n\n/-- Given two smooth maps `f` and `g`, this is the smooth map `(x, y) ↦ (f x, g y)`. -/\ndef prod_mk (f : C^n⟮J, N; I, M⟯) (g : C^n⟮J, N; I', M'⟯) : C^n⟮J, N; I.prod I', M × M'⟯ :=\n⟨λ x, (f x, g x), f.2.prod_mk g.2⟩\n\nend cont_mdiff_map\n\nnamespace diffeomorph\n\ninstance : continuous_map_class (M ≃ₘ⟮I, J⟯ N) M N :=\n{ coe := coe_fn,\n  coe_injective' := coe_fn_injective,\n  map_continuous := λ f, f.continuous }\n\nend diffeomorph\n\nend maps\n\nsection\nvariables {E : Type*} [normed_add_comm_group E] [normed_space ℝ E]\n  {H : Type*} [topological_space H] (I : model_with_corners ℝ E H) {M : Type*}\n  [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M]\n  {G : Type*} [normed_add_comm_group G] [normed_space ℝ G] [finite_dimensional ℝ G]\n  {HG : Type*} [topological_space HG] (IG : model_with_corners ℝ G HG) {N : Type*}\n  [topological_space N] [charted_space HG N] [smooth_manifold_with_corners IG N]\n\ndef filter.germ.cont_mdiff_at' {x : M} (φ : germ (𝓝 x) N) (n : ℕ∞) : Prop :=\nquotient.lift_on' φ (λ f, cont_mdiff_at I IG n f x) (λ f g h, propext begin\n  split,\n  all_goals { refine λ H, H.congr_of_eventually_eq _ },\n  exacts [h.symm, h]\nend)\nend\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/to_mathlib/geometry/manifold/misc_manifold.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4663244231658801}}
{"text": "/-\nCopyright (c) 2018 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\nimport Init.Data.Fin.Basic\nimport Init.System.Platform\n\nopen Nat\n\n@[extern \"lean_uint8_of_nat\"]\ndef UInt8.ofNat (n : @& Nat) : UInt8 := ⟨Fin.ofNat n⟩\nabbrev Nat.toUInt8 := UInt8.ofNat\n@[extern \"lean_uint8_to_nat\"]\ndef UInt8.toNat (n : UInt8) : Nat := n.val.val\n@[extern c inline \"#1 + #2\"]\ndef UInt8.add (a b : UInt8) : UInt8 := ⟨a.val + b.val⟩\n@[extern c inline \"#1 - #2\"]\ndef UInt8.sub (a b : UInt8) : UInt8 := ⟨a.val - b.val⟩\n@[extern c inline \"#1 * #2\"]\ndef UInt8.mul (a b : UInt8) : UInt8 := ⟨a.val * b.val⟩\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt8.div (a b : UInt8) : UInt8 := ⟨a.val / b.val⟩\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt8.mod (a b : UInt8) : UInt8 := ⟨a.val % b.val⟩\n@[extern \"lean_uint8_modn\"]\ndef UInt8.modn (a : UInt8) (n : @& Nat) : UInt8 := ⟨a.val % n⟩\n@[extern c inline \"#1 & #2\"]\ndef UInt8.land (a b : UInt8) : UInt8 := ⟨Fin.land a.val b.val⟩\n@[extern c inline \"#1 | #2\"]\ndef UInt8.lor (a b : UInt8) : UInt8 := ⟨Fin.lor a.val b.val⟩\n@[extern c inline \"#1 ^ #2\"]\ndef UInt8.xor (a b : UInt8) : UInt8 := ⟨Fin.xor a.val b.val⟩\n@[extern c inline \"#1 << #2 % 8\"]\ndef UInt8.shiftLeft (a b : UInt8) : UInt8 := ⟨a.val <<< (modn b 8).val⟩\n@[extern c inline \"#1 >> #2 % 8\"]\ndef UInt8.shiftRight (a b : UInt8) : UInt8 := ⟨a.val >>> (modn b 8).val⟩\ndef UInt8.lt (a b : UInt8) : Prop := a.val < b.val\ndef UInt8.le (a b : UInt8) : Prop := a.val ≤ b.val\n\ninstance : OfNat UInt8 n   := ⟨UInt8.ofNat n⟩\ninstance : Add UInt8       := ⟨UInt8.add⟩\ninstance : Sub UInt8       := ⟨UInt8.sub⟩\ninstance : Mul UInt8       := ⟨UInt8.mul⟩\ninstance : Mod UInt8       := ⟨UInt8.mod⟩\ninstance : HMod UInt8 Nat UInt8 := ⟨UInt8.modn⟩\ninstance : Div UInt8       := ⟨UInt8.div⟩\ninstance : LT UInt8        := ⟨UInt8.lt⟩\ninstance : LE UInt8        := ⟨UInt8.le⟩\n\n@[extern c inline \"~ #1\"]\ndef UInt8.complement (a:UInt8) : UInt8 := 0-(a+1)\n\ninstance : Complement UInt8 := ⟨UInt8.complement⟩\ninstance : AndOp UInt8     := ⟨UInt8.land⟩\ninstance : OrOp UInt8      := ⟨UInt8.lor⟩\ninstance : Xor UInt8       := ⟨UInt8.xor⟩\ninstance : ShiftLeft UInt8  := ⟨UInt8.shiftLeft⟩\ninstance : ShiftRight UInt8 := ⟨UInt8.shiftRight⟩\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 < #2\"]\ndef UInt8.decLt (a b : UInt8) : Decidable (a < b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n < m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 <= #2\"]\ndef UInt8.decLe (a b : UInt8) : Decidable (a ≤ b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : UInt8) : Decidable (a < b) := UInt8.decLt a b\ninstance (a b : UInt8) : Decidable (a ≤ b) := UInt8.decLe a b\n\n@[extern \"lean_uint16_of_nat\"]\ndef UInt16.ofNat (n : @& Nat) : UInt16 := ⟨Fin.ofNat n⟩\nabbrev Nat.toUInt16 := UInt16.ofNat\n@[extern \"lean_uint16_to_nat\"]\ndef UInt16.toNat (n : UInt16) : Nat := n.val.val\n@[extern c inline \"#1 + #2\"]\ndef UInt16.add (a b : UInt16) : UInt16 := ⟨a.val + b.val⟩\n@[extern c inline \"#1 - #2\"]\ndef UInt16.sub (a b : UInt16) : UInt16 := ⟨a.val - b.val⟩\n@[extern c inline \"#1 * #2\"]\ndef UInt16.mul (a b : UInt16) : UInt16 := ⟨a.val * b.val⟩\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt16.div (a b : UInt16) : UInt16 := ⟨a.val / b.val⟩\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt16.mod (a b : UInt16) : UInt16 := ⟨a.val % b.val⟩\n@[extern \"lean_uint16_modn\"]\ndef UInt16.modn (a : UInt16) (n : @& Nat) : UInt16 := ⟨a.val % n⟩\n@[extern c inline \"#1 & #2\"]\ndef UInt16.land (a b : UInt16) : UInt16 := ⟨Fin.land a.val b.val⟩\n@[extern c inline \"#1 | #2\"]\ndef UInt16.lor (a b : UInt16) : UInt16 := ⟨Fin.lor a.val b.val⟩\n@[extern c inline \"#1 ^ #2\"]\ndef UInt16.xor (a b : UInt16) : UInt16 := ⟨Fin.xor a.val b.val⟩\n@[extern c inline \"#1 << #2 % 16\"]\ndef UInt16.shiftLeft (a b : UInt16) : UInt16 := ⟨a.val <<< (modn b 16).val⟩\n@[extern c inline \"#1 >> #2 % 16\"]\ndef UInt16.shiftRight (a b : UInt16) : UInt16 := ⟨a.val >>> (modn b 16).val⟩\ndef UInt16.lt (a b : UInt16) : Prop := a.val < b.val\ndef UInt16.le (a b : UInt16) : Prop := a.val ≤ b.val\n\n\ninstance : OfNat UInt16 n   := ⟨UInt16.ofNat n⟩\ninstance : Add UInt16       := ⟨UInt16.add⟩\ninstance : Sub UInt16       := ⟨UInt16.sub⟩\ninstance : Mul UInt16       := ⟨UInt16.mul⟩\ninstance : Mod UInt16       := ⟨UInt16.mod⟩\ninstance : HMod UInt16 Nat UInt16 := ⟨UInt16.modn⟩\ninstance : Div UInt16       := ⟨UInt16.div⟩\ninstance : LT UInt16        := ⟨UInt16.lt⟩\ninstance : LE UInt16        := ⟨UInt16.le⟩\n\n@[extern c inline \"~ #1\"]\ndef UInt16.complement (a:UInt16) : UInt16 := 0-(a+1)\n\ninstance : Complement UInt16 := ⟨UInt16.complement⟩\ninstance : AndOp UInt16     := ⟨UInt16.land⟩\ninstance : OrOp UInt16      := ⟨UInt16.lor⟩\ninstance : Xor UInt16       := ⟨UInt16.xor⟩\ninstance : ShiftLeft UInt16  := ⟨UInt16.shiftLeft⟩\ninstance : ShiftRight UInt16 := ⟨UInt16.shiftRight⟩\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 < #2\"]\ndef UInt16.decLt (a b : UInt16) : Decidable (a < b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n < m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 <= #2\"]\ndef UInt16.decLe (a b : UInt16) : Decidable (a ≤ b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : UInt16) : Decidable (a < b) := UInt16.decLt a b\ninstance (a b : UInt16) : Decidable (a ≤ b) := UInt16.decLe a b\n\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNat (n : @& Nat) : UInt32 := ⟨Fin.ofNat n⟩\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNat' (n : Nat) (h : n < UInt32.size) : UInt32 := ⟨⟨n, h⟩⟩\nabbrev Nat.toUInt32 := UInt32.ofNat\n@[extern c inline \"#1 + #2\"]\ndef UInt32.add (a b : UInt32) : UInt32 := ⟨a.val + b.val⟩\n@[extern c inline \"#1 - #2\"]\ndef UInt32.sub (a b : UInt32) : UInt32 := ⟨a.val - b.val⟩\n@[extern c inline \"#1 * #2\"]\ndef UInt32.mul (a b : UInt32) : UInt32 := ⟨a.val * b.val⟩\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt32.div (a b : UInt32) : UInt32 := ⟨a.val / b.val⟩\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt32.mod (a b : UInt32) : UInt32 := ⟨a.val % b.val⟩\n@[extern \"lean_uint32_modn\"]\ndef UInt32.modn (a : UInt32) (n : @& Nat) : UInt32 := ⟨a.val % n⟩\n@[extern c inline \"#1 & #2\"]\ndef UInt32.land (a b : UInt32) : UInt32 := ⟨Fin.land a.val b.val⟩\n@[extern c inline \"#1 | #2\"]\ndef UInt32.lor (a b : UInt32) : UInt32 := ⟨Fin.lor a.val b.val⟩\n@[extern c inline \"#1 ^ #2\"]\ndef UInt32.xor (a b : UInt32) : UInt32 := ⟨Fin.xor a.val b.val⟩\n@[extern c inline \"#1 << #2 % 32\"]\ndef UInt32.shiftLeft (a b : UInt32) : UInt32 := ⟨a.val <<< (modn b 32).val⟩\n@[extern c inline \"#1 >> #2 % 32\"]\ndef UInt32.shiftRight (a b : UInt32) : UInt32 := ⟨a.val >>> (modn b 32).val⟩\n@[extern c inline \"((uint8_t)#1)\"]\ndef UInt32.toUInt8 (a : UInt32) : UInt8 := a.toNat.toUInt8\n@[extern c inline \"((uint16_t)#1)\"]\ndef UInt32.toUInt16 (a : UInt32) : UInt16 := a.toNat.toUInt16\n@[extern c inline \"((uint32_t)#1)\"]\ndef UInt8.toUInt32 (a : UInt8) : UInt32 := a.toNat.toUInt32\n\ninstance : OfNat UInt32 n   := ⟨UInt32.ofNat n⟩\ninstance : Add UInt32       := ⟨UInt32.add⟩\ninstance : Sub UInt32       := ⟨UInt32.sub⟩\ninstance : Mul UInt32       := ⟨UInt32.mul⟩\ninstance : Mod UInt32       := ⟨UInt32.mod⟩\ninstance : HMod UInt32 Nat UInt32 := ⟨UInt32.modn⟩\ninstance : Div UInt32       := ⟨UInt32.div⟩\n\n@[extern c inline \"~ #1\"]\ndef UInt32.complement (a:UInt32) : UInt32 := 0-(a+1)\n\ninstance : Complement UInt32 := ⟨UInt32.complement⟩\ninstance : AndOp UInt32     := ⟨UInt32.land⟩\ninstance : OrOp UInt32      := ⟨UInt32.lor⟩\ninstance : Xor UInt32       := ⟨UInt32.xor⟩\ninstance : ShiftLeft UInt32  := ⟨UInt32.shiftLeft⟩\ninstance : ShiftRight UInt32 := ⟨UInt32.shiftRight⟩\n\n@[extern \"lean_uint64_of_nat\"]\ndef UInt64.ofNat (n : @& Nat) : UInt64 := ⟨Fin.ofNat n⟩\nabbrev Nat.toUInt64 := UInt64.ofNat\n@[extern \"lean_uint64_to_nat\"]\ndef UInt64.toNat (n : UInt64) : Nat := n.val.val\n@[extern c inline \"#1 + #2\"]\ndef UInt64.add (a b : UInt64) : UInt64 := ⟨a.val + b.val⟩\n@[extern c inline \"#1 - #2\"]\ndef UInt64.sub (a b : UInt64) : UInt64 := ⟨a.val - b.val⟩\n@[extern c inline \"#1 * #2\"]\ndef UInt64.mul (a b : UInt64) : UInt64 := ⟨a.val * b.val⟩\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt64.div (a b : UInt64) : UInt64 := ⟨a.val / b.val⟩\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt64.mod (a b : UInt64) : UInt64 := ⟨a.val % b.val⟩\n@[extern \"lean_uint64_modn\"]\ndef UInt64.modn (a : UInt64) (n : @& Nat) : UInt64 := ⟨a.val % n⟩\n@[extern c inline \"#1 & #2\"]\ndef UInt64.land (a b : UInt64) : UInt64 := ⟨Fin.land a.val b.val⟩\n@[extern c inline \"#1 | #2\"]\ndef UInt64.lor (a b : UInt64) : UInt64 := ⟨Fin.lor a.val b.val⟩\n@[extern c inline \"#1 ^ #2\"]\ndef UInt64.xor (a b : UInt64) : UInt64 := ⟨Fin.xor a.val b.val⟩\n@[extern c inline \"#1 << #2 % 64\"]\ndef UInt64.shiftLeft (a b : UInt64) : UInt64 := ⟨a.val <<< (modn b 64).val⟩\n@[extern c inline \"#1 >> #2 % 64\"]\ndef UInt64.shiftRight (a b : UInt64) : UInt64 := ⟨a.val >>> (modn b 64).val⟩\ndef UInt64.lt (a b : UInt64) : Prop := a.val < b.val\ndef UInt64.le (a b : UInt64) : Prop := a.val ≤ b.val\n@[extern c inline \"((uint8_t)#1)\"]\ndef UInt64.toUInt8 (a : UInt64) : UInt8 := a.toNat.toUInt8\n@[extern c inline \"((uint16_t)#1)\"]\ndef UInt64.toUInt16 (a : UInt64) : UInt16 := a.toNat.toUInt16\n@[extern c inline \"((uint32_t)#1)\"]\ndef UInt64.toUInt32 (a : UInt64) : UInt32 := a.toNat.toUInt32\n@[extern c inline \"((uint64_t)#1)\"]\ndef UInt32.toUInt64 (a : UInt32) : UInt64 := a.toNat.toUInt64\n\ninstance : OfNat UInt64 n   := ⟨UInt64.ofNat n⟩\ninstance : Add UInt64       := ⟨UInt64.add⟩\ninstance : Sub UInt64       := ⟨UInt64.sub⟩\ninstance : Mul UInt64       := ⟨UInt64.mul⟩\ninstance : Mod UInt64       := ⟨UInt64.mod⟩\ninstance : HMod UInt64 Nat UInt64 := ⟨UInt64.modn⟩\ninstance : Div UInt64       := ⟨UInt64.div⟩\ninstance : LT UInt64        := ⟨UInt64.lt⟩\ninstance : LE UInt64        := ⟨UInt64.le⟩\n\n@[extern c inline \"~ #1\"]\ndef UInt64.complement (a:UInt64) : UInt64 := 0-(a+1)\n\ninstance : Complement UInt64 := ⟨UInt64.complement⟩\ninstance : AndOp UInt64     := ⟨UInt64.land⟩\ninstance : OrOp UInt64      := ⟨UInt64.lor⟩\ninstance : Xor UInt64       := ⟨UInt64.xor⟩\ninstance : ShiftLeft UInt64  := ⟨UInt64.shiftLeft⟩\ninstance : ShiftRight UInt64 := ⟨UInt64.shiftRight⟩\n\n@[extern c inline \"(uint64_t)#1\"]\ndef Bool.toUInt64 (b : Bool) : UInt64 := if b then 1 else 0\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 < #2\"]\ndef UInt64.decLt (a b : UInt64) : Decidable (a < b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n < m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 <= #2\"]\ndef UInt64.decLe (a b : UInt64) : Decidable (a ≤ b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : UInt64) : Decidable (a < b) := UInt64.decLt a b\ninstance (a b : UInt64) : Decidable (a ≤ b) := UInt64.decLe a b\n\ntheorem usizeSzGt0 : USize.size > 0 :=\n  Nat.posPowOfPos System.Platform.numBits (Nat.zeroLtSucc _)\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNat (n : @& Nat) : USize := ⟨Fin.ofNat' n usizeSzGt0⟩\nabbrev Nat.toUSize := USize.ofNat\n@[extern \"lean_usize_to_nat\"]\ndef USize.toNat (n : USize) : Nat := n.val.val\n@[extern c inline \"#1 + #2\"]\ndef USize.add (a b : USize) : USize := ⟨a.val + b.val⟩\n@[extern c inline \"#1 - #2\"]\ndef USize.sub (a b : USize) : USize := ⟨a.val - b.val⟩\n@[extern c inline \"#1 * #2\"]\ndef USize.mul (a b : USize) : USize := ⟨a.val * b.val⟩\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef USize.div (a b : USize) : USize := ⟨a.val / b.val⟩\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef USize.mod (a b : USize) : USize := ⟨a.val % b.val⟩\n@[extern \"lean_usize_modn\"]\ndef USize.modn (a : USize) (n : @& Nat) : USize := ⟨a.val % n⟩\n@[extern c inline \"#1 & #2\"]\ndef USize.land (a b : USize) : USize := ⟨Fin.land a.val b.val⟩\n@[extern c inline \"#1 | #2\"]\ndef USize.lor (a b : USize) : USize := ⟨Fin.lor a.val b.val⟩\n@[extern c inline \"#1 ^ #2\"]\ndef USize.xor (a b : USize) : USize := ⟨Fin.xor a.val b.val⟩\n@[extern c inline \"#1 << #2 % (sizeof(size_t) * 8)\"]\ndef USize.shiftLeft (a b : USize) : USize := ⟨a.val <<< (modn b System.Platform.numBits).val⟩\n@[extern c inline \"#1 >> #2 % (sizeof(size_t) * 8)\"]\ndef USize.shiftRight (a b : USize) : USize := ⟨a.val >>> (modn b System.Platform.numBits).val⟩\n@[extern c inline \"#1\"]\ndef UInt32.toUSize (a : UInt32) : USize := a.toNat.toUSize\n@[extern c inline \"((size_t)#1)\"]\ndef UInt64.toUSize (a : UInt64) : USize := a.toNat.toUSize\n@[extern c inline \"(uint32_t)#1\"]\ndef USize.toUInt32 (a : USize) : UInt32 := a.toNat.toUInt32\n\ndef USize.lt (a b : USize) : Prop := a.val < b.val\ndef USize.le (a b : USize) : Prop := a.val ≤ b.val\n\ninstance : OfNat USize n   := ⟨USize.ofNat n⟩\ninstance : Add USize       := ⟨USize.add⟩\ninstance : Sub USize       := ⟨USize.sub⟩\ninstance : Mul USize       := ⟨USize.mul⟩\ninstance : Mod USize       := ⟨USize.mod⟩\ninstance : HMod USize Nat USize := ⟨USize.modn⟩\ninstance : Div USize       := ⟨USize.div⟩\ninstance : LT USize        := ⟨USize.lt⟩\ninstance : LE USize        := ⟨USize.le⟩\n\n@[extern c inline \"~ #1\"]\ndef USize.complement (a:USize) : USize := 0-(a+1)\n\ninstance : Complement USize := ⟨USize.complement⟩\ninstance : AndOp USize      := ⟨USize.land⟩\ninstance : OrOp USize       := ⟨USize.lor⟩\ninstance : Xor USize        := ⟨USize.xor⟩\ninstance : ShiftLeft USize  := ⟨USize.shiftLeft⟩\ninstance : ShiftRight USize := ⟨USize.shiftRight⟩\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 < #2\"]\ndef USize.decLt (a b : USize) : Decidable (a < b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n < m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 <= #2\"]\ndef USize.decLe (a b : USize) : Decidable (a ≤ b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : USize) : Decidable (a < b) := USize.decLt a b\ninstance (a b : USize) : Decidable (a ≤ b) := USize.decLe a b\n\ntheorem USize.modn_lt {m : Nat} : ∀ (u : USize), m > 0 → USize.toNat (u % m) < m\n  | ⟨u⟩, h => Fin.modn_lt u h\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/stage0/src/Init/Data/UInt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.46627632568725447}}
{"text": "import number_theory.padics.padic_norm\nimport data.real.cau_seq\nimport analysis.special_functions.exp_log\nimport analysis.special_functions.pow\nimport data.nat.prime\nimport data.nat.basic\nimport tactic.apply\nimport tactic.linarith\nimport topology.metric_space.basic\n\nopen is_absolute_value\n\nvariables (α: ℝ)\n\ndef abvs_equiv {β} [ring β] (abv: β → ℝ) (abv': β → ℝ) [is_absolute_value abv] [is_absolute_value abv'] :=\n  ∃ α: ℝ, 0 < α ∧ (λ x: β, (abv x) ^ α) = abv'\n\ntheorem abvs_equiv_reflexive {β} [ring β]:\n  ∀ (abv: β → ℝ) [is_abv: is_absolute_value abv], @abvs_equiv _ _ abv abv is_abv is_abv :=\nbegin\n  intros abv is_abv,\n  use [1, by linarith],\n  simp,\nend\n\ntheorem abvs_equiv_symmetric {β} [ring β]:\n  ∀ (abv abv': β → ℝ) [abv_abv: is_absolute_value abv] [abv'_abv: is_absolute_value abv'],\n    @abvs_equiv _ _ abv abv' abv_abv abv'_abv → @abvs_equiv _ _ abv' abv abv'_abv abv_abv :=\nbegin\n  intros abv abv' abv_abv abv'_abv p,\n  rcases p with ⟨ α, zero_lt_α, hα ⟩,\n  use [α⁻¹, by simp [zero_lt_α]],\n  ext x,\n  have abvx_nonneg: 0 ≤ abv x,\n  from @abv_nonneg _ _ _ _ abv abv_abv x,\n  symmetry,\n  calc abv x = abv x ^ (1: ℝ)          : by rw real.rpow_one\n    ... = abv x ^ (α * α⁻¹)            : by { simp [(ne.symm ∘ ne_of_lt) zero_lt_α], }\n    ... = (abv x ^ α) ^ (α⁻¹)          : by { rw real.rpow_mul abvx_nonneg, }\n    ... = ((λ x, abv x ^ α) x) ^ (α⁻¹) : by simp\n    ... = (abv' x) ^ (α⁻¹)             : by rw hα,\nend\n\n\ntheorem abvs_equiv_transitive {β} [ring β]:\n  ∀ (abv abv' abv'': β → ℝ) [abv_abv: is_absolute_value abv] [abv'_abv: is_absolute_value abv']\n      [abv''_abv: is_absolute_value abv''],\n    @abvs_equiv _ _ abv abv' abv_abv abv'_abv → @abvs_equiv _ _ abv' abv'' abv'_abv abv''_abv →\n      @abvs_equiv _ _ abv abv'' abv_abv abv''_abv :=\nbegin\n  intros abv abv' abv'' abv_abv abv'_abv abv''_abv abv_equiv_abv' abv'_equiv_abv'',\n  rcases abv_equiv_abv' with ⟨ α, zero_lt_α, hα ⟩,\n  rcases abv'_equiv_abv'' with ⟨ γ, zero_lt_γ, hγ ⟩,\n  use [α * γ, by simp [zero_lt_α, zero_lt_γ]],\n  ext x,\n  have abvx_nonneg: 0 ≤ abv x,\n  from @abv_nonneg _ _ _ _ abv abv_abv x,\n  rw real.rpow_mul abvx_nonneg,\n  rw [← hγ, ← hα],\nend\n", "meta": {"author": "RaitoBezarius", "repo": "berkovich-spaces", "sha": "0a49f75a599bcb20333ec86b301f84411f04f7cf", "save_path": "github-repos/lean/RaitoBezarius-berkovich-spaces", "path": "github-repos/lean/RaitoBezarius-berkovich-spaces/berkovich-spaces-0a49f75a599bcb20333ec86b301f84411f04f7cf/src/abvs_equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.46627631871382724}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport linear_algebra.affine_space.affine_map\nimport algebra.invertible\n\n/-!\n# Affine equivalences\n\nIn this file we define `affine_equiv k P₁ P₂` (notation: `P₁ ≃ᵃ[k] P₂`) to be the type of affine\nequivalences between `P₁` and `P₂, i.e., equivalences such that both forward and inverse maps are\naffine maps.\n\nWe define the following equivalences:\n\n* `affine_equiv.refl k P`: the identity map as an `affine_equiv`;\n\n* `e.symm`: the inverse map of an `affine_equiv` as an `affine_equiv`;\n\n* `e.trans e'`: composition of two `affine_equiv`s; note that the order follows `mathlib`'s\n  `category_theory` convention (apply `e`, then `e'`), not the convention used in function\n  composition and compositions of bundled morphisms.\n\nWe equip `affine_equiv k P P` with a `group` structure with multiplication corresponding to\ncomposition in `affine_equiv.group`.\n\n## Tags\n\naffine space, affine equivalence\n-/\n\nopen function set\nopen_locale affine\n\n/-- An affine equivalence is an equivalence between affine spaces such that both forward\nand inverse maps are affine.\n\nWe define it using an `equiv` for the map and a `linear_equiv` for the linear part in order\nto allow affine equivalences with good definitional equalities. -/\n@[nolint has_inhabited_instance]\nstructure affine_equiv (k P₁ P₂ : Type*) {V₁ V₂ : Type*} [ring k]\n  [add_comm_group V₁] [module k V₁] [add_torsor V₁ P₁]\n  [add_comm_group V₂] [module k V₂] [add_torsor V₂ P₂] extends P₁ ≃ P₂ :=\n(linear : V₁ ≃ₗ[k] V₂)\n(map_vadd' : ∀ (p : P₁) (v : V₁), to_equiv (v +ᵥ p) = linear v +ᵥ to_equiv p)\n\nnotation P₁ ` ≃ᵃ[`:25 k:25 `] `:0 P₂:0 := affine_equiv k P₁ P₂\n\nvariables {k P₁ P₂ P₃ P₄ V₁ V₂ V₃ V₄ : Type*} [ring k]\n  [add_comm_group V₁] [module k V₁] [add_torsor V₁ P₁]\n  [add_comm_group V₂] [module k V₂] [add_torsor V₂ P₂]\n  [add_comm_group V₃] [module k V₃] [add_torsor V₃ P₃]\n  [add_comm_group V₄] [module k V₄] [add_torsor V₄ P₄]\n\nnamespace affine_equiv\n\ninclude V₁ V₂\n\ninstance : has_coe_to_fun (P₁ ≃ᵃ[k] P₂) (λ _, P₁ → P₂) := ⟨λ e, e.to_fun⟩\n\ninstance : has_coe (P₁ ≃ᵃ[k] P₂) (P₁ ≃ P₂) := ⟨affine_equiv.to_equiv⟩\n\nvariables (k P₁)\n\nomit V₂\n\n/-- Identity map as an `affine_equiv`. -/\n@[refl] def refl : P₁ ≃ᵃ[k] P₁ :=\n{ to_equiv := equiv.refl P₁,\n  linear := linear_equiv.refl k V₁,\n  map_vadd' := λ _ _, rfl }\n\n@[simp] lemma coe_refl : ⇑(refl k P₁) = id := rfl\n\nlemma refl_apply (x : P₁) : refl k P₁ x = x := rfl\n\n@[simp] lemma to_equiv_refl : (refl k P₁).to_equiv = equiv.refl P₁ := rfl\n\n@[simp] lemma linear_refl : (refl k P₁).linear = linear_equiv.refl k V₁ := rfl\n\nvariables {k P₁}\n\ninclude V₂\n\n@[simp] lemma map_vadd (e : P₁ ≃ᵃ[k] P₂) (p : P₁) (v : V₁) : e (v +ᵥ p) = e.linear v +ᵥ e p :=\ne.map_vadd' p v\n\n@[simp] lemma coe_to_equiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.to_equiv = e := rfl\n\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef to_affine_map (e : P₁ ≃ᵃ[k] P₂) : P₁ →ᵃ[k] P₂ := { to_fun := e, .. e }\n\ninstance : has_coe (P₁ ≃ᵃ[k] P₂) (P₁ →ᵃ[k] P₂) := ⟨to_affine_map⟩\n\n@[simp] lemma coe_to_affine_map (e : P₁ ≃ᵃ[k] P₂) :\n  (e.to_affine_map : P₁ → P₂) = (e : P₁ → P₂) :=\nrfl\n\n@[simp] lemma to_affine_map_mk (f : P₁ ≃ P₂) (f' : V₁ ≃ₗ[k] V₂) (h) :\n  to_affine_map (mk f f' h) = ⟨f, f', h⟩ :=\nrfl\n\n@[norm_cast, simp] lemma coe_coe (e : P₁ ≃ᵃ[k] P₂) : ((e : P₁ →ᵃ[k] P₂) : P₁ → P₂) = e := rfl\n\n@[simp] lemma linear_to_affine_map (e : P₁ ≃ᵃ[k] P₂) : e.to_affine_map.linear = e.linear := rfl\n\nlemma to_affine_map_injective : injective (to_affine_map : (P₁ ≃ᵃ[k] P₂) → (P₁ →ᵃ[k] P₂)) :=\nbegin\n  rintros ⟨e, el, h⟩ ⟨e', el', h'⟩ H,\n  simp only [to_affine_map_mk, equiv.coe_inj, linear_equiv.to_linear_map_inj] at H,\n  congr,\n  exacts [H.1, H.2]\nend\n\n@[simp] lemma to_affine_map_inj {e e' : P₁ ≃ᵃ[k] P₂} :\n  e.to_affine_map = e'.to_affine_map ↔ e = e' :=\nto_affine_map_injective.eq_iff\n\n@[ext] lemma ext {e e' : P₁ ≃ᵃ[k] P₂} (h : ∀ x, e x = e' x) : e = e' :=\nto_affine_map_injective $ affine_map.ext h\n\nlemma coe_fn_injective : @injective (P₁ ≃ᵃ[k] P₂) (P₁ → P₂) coe_fn :=\nλ e e' H, ext $ congr_fun H\n\n@[simp, norm_cast] lemma coe_fn_inj {e e' : P₁ ≃ᵃ[k] P₂} : (e : P₁ → P₂) = e' ↔ e = e' :=\ncoe_fn_injective.eq_iff\n\nlemma to_equiv_injective : injective (to_equiv : (P₁ ≃ᵃ[k] P₂) → (P₁ ≃ P₂)) :=\nλ e e' H, ext $ equiv.ext_iff.1 H\n\n@[simp] lemma to_equiv_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.to_equiv = e'.to_equiv ↔ e = e' :=\nto_equiv_injective.eq_iff\n\n@[simp] lemma coe_mk (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (h) :\n  ((⟨e, e', h⟩ : P₁ ≃ᵃ[k] P₂) : P₁ → P₂) = e :=\nrfl\n\n/-- Construct an affine equivalence by verifying the relation between the map and its linear part at\none base point. Namely, this function takes a map `e : P₁ → P₂`, a linear equivalence\n`e' : V₁ ≃ₗ[k] V₂`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/\ndef mk' (e : P₁ → P₂) (e' : V₁ ≃ₗ[k] V₂) (p : P₁) (h : ∀ p' : P₁, e p' = e' (p' -ᵥ p) +ᵥ e p) :\n  P₁ ≃ᵃ[k] P₂ :=\n{ to_fun := e,\n  inv_fun := λ q' : P₂, e'.symm (q' -ᵥ e p) +ᵥ p,\n  left_inv := λ p', by simp [h p'],\n  right_inv := λ q', by simp [h (e'.symm (q' -ᵥ e p) +ᵥ p)],\n  linear := e',\n  map_vadd' := λ p' v, by { simp [h p', h (v +ᵥ p'), vadd_vsub_assoc, vadd_vadd] } }\n\n@[simp] lemma coe_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : ⇑(mk' e e' p h) = e := rfl\n@[simp] lemma linear_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) :\n  (mk' e e' p h).linear = e' := rfl\n\n/-- Inverse of an affine equivalence as an affine equivalence. -/\n@[symm] def symm (e : P₁ ≃ᵃ[k] P₂) : P₂ ≃ᵃ[k] P₁ :=\n{ to_equiv := e.to_equiv.symm,\n  linear := e.linear.symm,\n  map_vadd' := λ v p, e.to_equiv.symm.apply_eq_iff_eq_symm_apply.2 $\n    by simpa using (e.to_equiv.apply_symm_apply v).symm }\n\n@[simp] lemma symm_to_equiv (e : P₁ ≃ᵃ[k] P₂) : e.to_equiv.symm = e.symm.to_equiv := rfl\n\n@[simp] lemma symm_linear (e : P₁ ≃ᵃ[k] P₂) : e.linear.symm = e.symm.linear := rfl\n\n/-- See Note [custom simps projection] -/\ndef simps.apply (e : P₁ ≃ᵃ[k] P₂) : P₁ → P₂ := e\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (e : P₁ ≃ᵃ[k] P₂) : P₂ → P₁ := e.symm\n\ninitialize_simps_projections affine_equiv\n  (to_equiv_to_fun → apply, to_equiv_inv_fun → symm_apply, linear → linear as_prefix, -to_equiv)\n\nprotected lemma bijective (e : P₁ ≃ᵃ[k] P₂) : bijective e := e.to_equiv.bijective\nprotected lemma surjective (e : P₁ ≃ᵃ[k] P₂) : surjective e := e.to_equiv.surjective\nprotected lemma injective (e : P₁ ≃ᵃ[k] P₂) : injective e := e.to_equiv.injective\n\n@[simp] lemma range_eq (e : P₁ ≃ᵃ[k] P₂) : range e = univ := e.surjective.range_eq\n\n@[simp] lemma apply_symm_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₂) : e (e.symm p) = p :=\ne.to_equiv.apply_symm_apply p\n\n@[simp] lemma symm_apply_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₁) : e.symm (e p) = p :=\ne.to_equiv.symm_apply_apply p\n\nlemma apply_eq_iff_eq_symm_apply (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂} : e p₁ = p₂ ↔ p₁ = e.symm p₂ :=\ne.to_equiv.apply_eq_iff_eq_symm_apply\n\n@[simp] lemma apply_eq_iff_eq (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂ : P₁} : e p₁ = e p₂ ↔ p₁ = p₂ :=\ne.to_equiv.apply_eq_iff_eq\n\nomit V₂\n\n@[simp] lemma symm_refl : (refl k P₁).symm = refl k P₁ := rfl\n\ninclude V₂ V₃\n\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\n@[trans] def trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : P₁ ≃ᵃ[k] P₃ :=\n{ to_equiv := e.to_equiv.trans e'.to_equiv,\n  linear := e.linear.trans e'.linear,\n  map_vadd' := λ p v, by simp only [linear_equiv.trans_apply, coe_to_equiv, (∘),\n    equiv.coe_trans, map_vadd] }\n\n@[simp] lemma coe_trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : ⇑(e.trans e') = e' ∘ e := rfl\n\nlemma trans_apply (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) (p : P₁) : e.trans e' p = e' (e p) := rfl\n\ninclude V₄\n\nlemma trans_assoc (e₁ : P₁ ≃ᵃ[k] P₂) (e₂ : P₂ ≃ᵃ[k] P₃) (e₃ : P₃ ≃ᵃ[k] P₄) :\n  (e₁.trans e₂).trans e₃ = e₁.trans (e₂.trans e₃) :=\next $ λ _, rfl\n\nomit V₃ V₄\n\n@[simp] lemma trans_refl (e : P₁ ≃ᵃ[k] P₂) : e.trans (refl k P₂) = e :=\next $ λ _, rfl\n\n@[simp] lemma refl_trans (e : P₁ ≃ᵃ[k] P₂) : (refl k P₁).trans e = e :=\next $ λ _, rfl\n\n@[simp] lemma self_trans_symm (e : P₁ ≃ᵃ[k] P₂) : e.trans e.symm = refl k P₁ :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : P₁ ≃ᵃ[k] P₂) : e.symm.trans e = refl k P₂ :=\next e.apply_symm_apply\n\n@[simp] lemma apply_line_map (e : P₁ ≃ᵃ[k] P₂) (a b : P₁) (c : k) :\n  e (affine_map.line_map a b c) = affine_map.line_map (e a) (e b) c :=\ne.to_affine_map.apply_line_map a b c\n\nomit V₂\n\ninstance : group (P₁ ≃ᵃ[k] P₁) :=\n{ one := refl k P₁,\n  mul := λ e e', e'.trans e,\n  inv := symm,\n  mul_assoc := λ e₁ e₂ e₃, trans_assoc _ _ _,\n  one_mul := trans_refl,\n  mul_one := refl_trans,\n  mul_left_inv := self_trans_symm }\n\nlemma one_def : (1 : P₁ ≃ᵃ[k] P₁) = refl k P₁ := rfl\n\n@[simp] lemma coe_one : ⇑(1 : P₁ ≃ᵃ[k] P₁) = id := rfl\n\nlemma mul_def (e e' : P₁ ≃ᵃ[k] P₁) : e * e' = e'.trans e := rfl\n\n@[simp] lemma coe_mul (e e' : P₁ ≃ᵃ[k] P₁) : ⇑(e * e') = e ∘ e' := rfl\n\nlemma inv_def (e : P₁ ≃ᵃ[k] P₁) : e⁻¹ = e.symm := rfl\n\n/-- `affine_equiv.linear` on automorphisms is a `monoid_hom`. -/\n@[simps] def linear_hom : (P₁ ≃ᵃ[k] P₁) →* (V₁ ≃ₗ[k] V₁) :=\n{ to_fun := linear,\n  map_one' := rfl,\n  map_mul' := λ _ _, rfl }\n\n/-- The group of `affine_equiv`s are equivalent to the group of units of `affine_map`.\n\nThis is the affine version of `linear_map.general_linear_group.general_linear_equiv`. -/\n@[simps]\ndef equiv_units_affine_map : (P₁ ≃ᵃ[k] P₁) ≃* (P₁ →ᵃ[k] P₁)ˣ :=\n{ to_fun := λ e, ⟨e, e.symm, congr_arg coe e.symm_trans_self, congr_arg coe e.self_trans_symm⟩,\n  inv_fun := λ u,\n  { to_fun := (u : P₁ →ᵃ[k] P₁), inv_fun := (↑(u⁻¹) : P₁ →ᵃ[k] P₁),\n    left_inv := affine_map.congr_fun u.inv_mul,\n    right_inv := affine_map.congr_fun u.mul_inv,\n    linear := linear_map.general_linear_group.general_linear_equiv _ _ $\n      units.map (by exact affine_map.linear_hom) u,\n    map_vadd' := λ _ _, (u : P₁ →ᵃ[k] P₁).map_vadd _ _ },\n  left_inv := λ e, affine_equiv.ext $ λ x, rfl,\n  right_inv := λ u, units.ext $ affine_map.ext $ λ x, rfl,\n  map_mul' := λ e₁ e₂, rfl }\n\nvariable (k)\n\n/-- The map `v ↦ v +ᵥ b` as an affine equivalence between a module `V` and an affine space `P` with\ntangent space `V`. -/\n@[simps]\ndef vadd_const (b : P₁) : V₁ ≃ᵃ[k] P₁ :=\n{ to_equiv := equiv.vadd_const b,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := λ p v, add_vadd _ _ _ }\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef const_vsub (p : P₁) : P₁ ≃ᵃ[k] V₁ :=\n{ to_equiv := equiv.const_vsub p,\n  linear := linear_equiv.neg k,\n  map_vadd' := λ p' v, by simp [vsub_vadd_eq_vsub_sub, neg_add_eq_sub] }\n\n@[simp] lemma coe_const_vsub (p : P₁) : ⇑(const_vsub k p) = (-ᵥ) p := rfl\n\n@[simp] lemma coe_const_vsub_symm (p : P₁) : ⇑(const_vsub k p).symm = λ v, -v +ᵥ p := rfl\n\nvariable (P₁)\n\n/-- The map `p ↦ v +ᵥ p` as an affine automorphism of an affine space. -/\n@[simps]\ndef const_vadd (v : V₁) : P₁ ≃ᵃ[k] P₁ :=\n{ to_equiv := equiv.const_vadd P₁ v,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := λ p w, vadd_comm _ _ _ }\n\nsection homothety\n\nomit V₁\n\nvariables {R V P : Type*} [comm_ring R] [add_comm_group V] [module R V] [affine_space V P]\ninclude V\n\n/-- Fixing a point in affine space, homothety about this point gives a group homomorphism from (the\ncentre of) the units of the scalars into the group of affine equivalences. -/\ndef homothety_units_mul_hom (p : P) : Rˣ →* P ≃ᵃ[R] P :=\nequiv_units_affine_map.symm.to_monoid_hom.comp $ units.map (affine_map.homothety_hom p)\n\n@[simp] lemma coe_homothety_units_mul_hom_apply (p : P) (t : Rˣ) :\n  (homothety_units_mul_hom p t : P → P) = affine_map.homothety p (t : R) :=\nrfl\n\n@[simp] lemma coe_homothety_units_mul_hom_apply_symm (p : P) (t : Rˣ) :\n  ((homothety_units_mul_hom p t).symm : P → P) = affine_map.homothety p (↑t⁻¹ : R) :=\nrfl\n\n@[simp] lemma coe_homothety_units_mul_hom_eq_homothety_hom_coe (p : P) :\n  (coe : (P ≃ᵃ[R] P) → P →ᵃ[R] P) ∘ homothety_units_mul_hom p =\n  (affine_map.homothety_hom p) ∘ (coe : Rˣ → R) :=\nfunext $ λ _, rfl\n\nend homothety\n\nvariable {P₁}\nopen function\n\n/-- Point reflection in `x` as a permutation. -/\ndef point_reflection (x : P₁) : P₁ ≃ᵃ[k] P₁ := (const_vsub k x).trans (vadd_const k x)\n\nlemma point_reflection_apply (x y : P₁) : point_reflection k x y = x -ᵥ y +ᵥ x := rfl\n\n@[simp] lemma point_reflection_symm (x : P₁) : (point_reflection k x).symm = point_reflection k x :=\nto_equiv_injective $ equiv.point_reflection_symm x\n\n@[simp] lemma to_equiv_point_reflection (x : P₁) :\n  (point_reflection k x).to_equiv = equiv.point_reflection x :=\nrfl\n\n@[simp] lemma point_reflection_self (x : P₁) : point_reflection k x x = x := vsub_vadd _ _\n\nlemma point_reflection_involutive (x : P₁) : involutive (point_reflection k x : P₁ → P₁) :=\nequiv.point_reflection_involutive x\n\n/-- `x` is the only fixed point of `point_reflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\nlemma point_reflection_fixed_iff_of_injective_bit0 {x y : P₁} (h : injective (bit0 : V₁ → V₁)) :\n  point_reflection k x y = y ↔ y = x :=\nequiv.point_reflection_fixed_iff_of_injective_bit0 h\n\nlemma injective_point_reflection_left_of_injective_bit0 (h : injective (bit0 : V₁ → V₁)) (y : P₁) :\n  injective (λ x : P₁, point_reflection k x y) :=\nequiv.injective_point_reflection_left_of_injective_bit0 h y\n\nlemma injective_point_reflection_left_of_module [invertible (2:k)]:\n  ∀ y, injective (λ x : P₁, point_reflection k x y) :=\ninjective_point_reflection_left_of_injective_bit0 k $ λ x y h,\n  by rwa [bit0, bit0, ← two_smul k x, ← two_smul k y,\n    (is_unit_of_invertible (2:k)).smul_left_cancel] at h\n\nlemma point_reflection_fixed_iff_of_module [invertible (2:k)] {x y : P₁} :\n  point_reflection k x y = y ↔ y = x :=\n((injective_point_reflection_left_of_module k y).eq_iff' (point_reflection_self k y)).trans eq_comm\n\nend affine_equiv\n\nnamespace linear_equiv\n\n/-- Interpret a linear equivalence between modules as an affine equivalence. -/\ndef to_affine_equiv (e : V₁ ≃ₗ[k] V₂) : V₁ ≃ᵃ[k] V₂ :=\n{ to_equiv := e.to_equiv,\n  linear := e,\n  map_vadd' := λ p v, e.map_add v p }\n\n@[simp] lemma coe_to_affine_equiv (e : V₁ ≃ₗ[k] V₂) : ⇑e.to_affine_equiv = e := rfl\n\nend linear_equiv\n\nnamespace affine_map\n\nopen affine_equiv\n\ninclude V₁\n\nlemma line_map_vadd (v v' : V₁) (p : P₁) (c : k) :\n  line_map v v' c +ᵥ p = line_map (v +ᵥ p) (v' +ᵥ p) c :=\n(vadd_const k p).apply_line_map v v' c\n\nlemma line_map_vsub (p₁ p₂ p₃ : P₁) (c : k) :\n  line_map p₁ p₂ c -ᵥ p₃ = line_map (p₁ -ᵥ p₃) (p₂ -ᵥ p₃) c :=\n(vadd_const k p₃).symm.apply_line_map p₁ p₂ c\n\nlemma vsub_line_map (p₁ p₂ p₃ : P₁) (c : k) :\n  p₁ -ᵥ line_map p₂ p₃ c = line_map (p₁ -ᵥ p₂) (p₁ -ᵥ p₃) c :=\n(const_vsub k p₁).apply_line_map p₂ p₃ c\n\nlemma vadd_line_map (v : V₁) (p₁ p₂ : P₁) (c : k) :\n  v +ᵥ line_map p₁ p₂ c = line_map (v +ᵥ p₁) (v +ᵥ p₂) c :=\n(const_vadd k P₁ v).apply_line_map p₁ p₂ c\n\nvariables {R' : Type*} [comm_ring R'] [module R' V₁]\n\nlemma homothety_neg_one_apply (c p : P₁) :\n  homothety c (-1:R') p = point_reflection R' c p :=\nby simp [homothety_apply, point_reflection_apply]\n\nend affine_map\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/linear_algebra/affine_space/affine_equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.46614303576945354}}
{"text": "example (s : ℝ) (s_pos : 0 < s) (s_max : s ≤ 1): (s + 1) ^ (s + 1) / s ^ s ≤ 4 :=\nbegin\n  rw div_le_iff,\n  have pow_to_exp1 : 4*s^s = exp(log 4 + s*log s),\n    { rw [exp_add, exp_log (show 0 < (4 : ℝ), by norm_num), ← log_rpow s_pos, exp_log],\n      apply rpow_pos_of_pos,\n      linarith},\n  have pow_to_exp2 : (s+1)^(s+1) = exp((s+1) * log(s+1)),\n    { rw [← log_rpow (show 0 < s + 1, by linarith), exp_log],\n      apply rpow_pos_of_pos,\n      linarith},\n  { rw [pow_to_exp1, pow_to_exp2],\n    rw exp_le_exp,\n    have H1 : ∀ {x : ℝ}, 0 < x → 0 < deriv (λ (x : ℝ), (x + 1) * log (x + 1) - x * log x) x,\n    { intros x x_pos, \n      rw diff_helper,\n      rw ← log_div,\n      apply log_pos,\n      rw one_lt_div,\n      linarith,\n      all_goals{linarith [x_pos]\n      }, -- need to add 0 < x\n    },\n    have H := convex.strict_mono_of_deriv_pos (convex_Icc 0 1) x_log_x_cont _ _,\n    { sorry},\n    { apply differentiable_on.sub,\n      { apply differentiable_on.mul,\n        { apply differentiable_on.add_const differentiable_on_id,},\n        { apply differentiable_on.log,\n          { apply differentiable_on.add_const differentiable_on_id,},\n          { intros x hx, \n            rw mem_interior at *,\n            -- screams\n            sorry},\n        },\n      },\n      { sorry},\n    },\n    { -- ∀ (x : ℝ), x ∈ interior (Icc 0 1) → 0 < deriv (λ (x : ℝ), (x + 1) * log (x + 1) - x * log x) x\n      sorry},\n    \n    all_goals{sorry} -- (s + 1) * log (s + 1) ≤ log 4 + s * log s\n  },\n  { apply rpow_pos_of_pos,\n    linarith}\nend", "meta": {"author": "jamesa9283", "repo": "special-functions", "sha": "392758fb7207762c9ba6938462614994ff45bdc4", "save_path": "github-repos/lean/jamesa9283-special-functions", "path": "github-repos/lean/jamesa9283-special-functions/special-functions-392758fb7207762c9ba6938462614994ff45bdc4/src/ScholzeLog/scratch.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4661408589994101}}
{"text": "/-\nCopyright (c) 2019 Seul Baek. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Seul Baek\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.omega.term\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-\nDefinition of linear constrain clauses.\n-/\n\nnamespace omega\n\n\n/-- (([t₁,...tₘ],[s₁,...,sₙ]) : clause) encodes the constraints\n0 = ⟦t₁⟧ ∧ ... ∧ 0 = ⟦tₘ⟧ ∧ 0 ≤ ⟦s₁⟧ ∧ ... ∧ 0 ≤ ⟦sₙ⟧, where\n⟦t⟧ is the value of (t : term). -/\ndef clause :=\n  List term × List term\n\nnamespace clause\n\n\n/-- holds v c := clause c holds under valuation v -/\ndef holds (v : ℕ → ℤ) : clause → Prop :=\n  sorry\n\n/-- sat c := there exists a valuation v under which c holds -/\ndef sat (c : clause) :=\n  ∃ (v : ℕ → ℤ), holds v c\n\n/-- unsat c := there is no valuation v under which c holds -/\ndef unsat (c : clause) :=\n  ¬sat c\n\n/-- append two clauses by elementwise appending -/\ndef append (c1 : clause) (c2 : clause) : clause :=\n  (prod.fst c1 ++ prod.fst c2, prod.snd c1 ++ prod.snd c2)\n\ntheorem holds_append {v : ℕ → ℤ} {c1 : clause} {c2 : clause} : holds v c1 → holds v c2 → holds v (append c1 c2) := sorry\n\nend clause\n\n\n/-- There exists a satisfiable clause c in argument -/\ndef clauses.sat (cs : List clause) :=\n  ∃ (c : clause), ∃ (H : c ∈ cs), clause.sat c\n\n/-- There is no satisfiable clause c in argument -/\ndef clauses.unsat (cs : List clause) :=\n  ¬clauses.sat cs\n\ntheorem clauses.unsat_nil : clauses.unsat [] := sorry\n\ntheorem clauses.unsat_cons (c : clause) (cs : List clause) : clause.unsat c → clauses.unsat cs → clauses.unsat (c :: cs) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/omega/clause.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4661408589994101}}
{"text": "import Smt\n\ntheorem disjunctive_syllogism (p q : Bool) : p || q → !p → q := by\n  smt\n  intro hpq hnp\n  cases p <;> simp_all\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Test/Bool/DisjunctiveSyllogism.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.46611011474946457}}
{"text": "variable (u w x x' y y' z : Nat) (p : Nat → Prop)\n\nexample (h₁ : x + 0 = x') (h₂ : y + 0 = y')\n        : x + y + 0 = x' + y' := by\n  simp at *\n  simp [*]\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/simpBug.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.615087848460224, "lm_q1q2_score": 0.46611010940258685}}
{"text": "import NBG.SetTheory.Axioms.Extensionality\n\n-- Classoid\nprivate theorem ClassEqIsEquivalence : @Equivalence Class Class.Eq :=\n  { refl := ClassEq.refl, symm := ClassEq.symm, trans := ClassEq.trans }\n\ninstance Classoid : Setoid Class where\n  r     := Class.Eq\n  iseqv := ClassEqIsEquivalence\n\ndef Class' : Type u := Quotient Classoid\n\ntheorem Classoid.sound {X Y : Class}:\n  X ＝ Y → (Quot.mk Class.Eq X) = (Quot.mk Class.Eq Y) :=\nfun h => Quot.sound h\n\ntheorem Classoid.refl : ∀(X : Class'), X=X := by {\n  intro _;\n  apply Quot.inductionOn (motive := fun X => X=X);\n  intro X;\n  apply Classoid.sound;\n  exact ClassEq.refl X;\n}\n", "meta": {"author": "furea2", "repo": "NBG", "sha": "51b45e0b08c1d0090430b0d898de4fc1b7bc09d7", "save_path": "github-repos/lean/furea2-NBG", "path": "github-repos/lean/furea2-NBG/NBG-51b45e0b08c1d0090430b0d898de4fc1b7bc09d7/NBG/SetTheory/Extra/Classoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943603346811, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.46611010802042835}}
{"text": "lemma one_mul (m : mynat) : 1 * m = m :=\nbegin\ninduction m with h hd,\nrw mul_zero,\nrefl,\nrw mul_succ,\nrw hd,\nrw succ_eq_add_one,\nrefl,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world03/level03.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.46611010802042824}}
{"text": "import data.qpf.univariate.basic\nimport control.bifunctor\n\nuniverses u\nvariables {F : Type u → Type u} [functor F]\n\nnamespace qpf\n\nsection box\nvariables (F)\n\n/-- apply a functor to a set of values. taken from\n [Basil Fürer, Andreas Lochbihler, Joshua Schneider, Dmitriy Traytel *Quotients of Bounded Natural Functors*][fuerer-lochbihler-schneider-traytel2020]\nhenceforth referred to as the QBNF paper\n -/\ndef box {α} (A : set α) : set (F α) :=\n{ x | ∀ β (f g : α → β), (∀ a ∈ A, f a = g a) → f <$> x = g <$> x }\n\nvariables {F}\n\n/--\nAlternate notion of support set based on `box`.\nTaken from the QBNF paper\n-/\ndef supp' {α} (x : F α) : set α :=\n⋂ A ∈ { A : set α | x ∈ box F A}, A\n\n/--\nAlternate notion of predicate lifting based on `box`.\nTaken from the QBNF paper\n-/\ndef liftp' {α} (x : F α) (p : α → Prop) : Prop :=\n∀ a ∈ supp' x, p a\n\nend box\n\nend qpf\n\n\nnamespace ex\n\n/-- polynomial functor isomorph to `α × _` for some `α` -/\ndef prod.pfunctor (α : Type) : pfunctor :=\n⟨ α, λ _, unit ⟩\n\ninstance {α} : qpf (prod α) :=\n{ P := prod.pfunctor α,\n  abs := λ β ⟨a,f⟩, (a, f ()),\n  repr := λ β ⟨x,y⟩, ⟨x, λ _, y⟩,\n  abs_repr := λ β ⟨x,y⟩, rfl,\n  abs_map := λ β γ f ⟨a,g⟩, rfl }\n\n/-- example relation for products -/\ndef foo.R (α : Type) (x y : bool × α) : Prop :=\nx.1 = y.1 ∧ (x.1 → x.2 = y.2)\n\nlemma equivalence_foo.R (α) : equivalence (foo.R α) :=\nbegin\n  refine ⟨_,_,_⟩,\n  { intro, exact ⟨rfl,λ _, rfl⟩ },\n  { intros x y h, refine ⟨h.1.symm, λ _, (h.2 _).symm⟩,\n    rwa h.1 },\n  { rintros x y z ⟨ha,ha'⟩ ⟨hb,hb'⟩,\n    refine ⟨ha.trans hb, λ hh, _⟩,\n    refine (ha' hh).trans (hb' _),\n    rwa ← ha }\nend\n\n/-- example of a qpf -/\ndef foo (α : Type) :=\nquot $ foo.R α\n\ninstance {α} [inhabited α] : inhabited (foo α) := ⟨ quot.mk _ default ⟩\n\n/-- functor operation of `foo` -/\ndef foo.map {α β} (f : α → β) (x : foo α) : foo β :=\nquot.lift_on x (λ x : bool × α, quot.mk (foo.R β) $ f <$> x)\n  (λ ⟨a₀,a₁⟩ ⟨b₀,b₁⟩ h, quot.sound ⟨h.1,λ h', show f a₁ = f b₁, from congr_arg f (h.2 h')⟩)\n\ninstance : functor foo :=\n{ map := @foo.map }\n\n@[simp]\nlemma foo.map_mk {α β : Type} (f : α → β) (x : bool × α) :\n  (f <$> quot.mk _ x : foo β) = quot.mk _ (f <$> x) :=\nby simp [(<$>),foo.map]\n\nnoncomputable instance qpf.foo : qpf foo :=\n@qpf.quotient_qpf (prod bool) _ ex.prod.qpf foo _ (λ α, quot.mk _) (λ α, quot.out)\n  (by simp)\n  (by intros; simp)\n\n/-- constructor for `foo` -/\ndef foo.mk {α} (b : bool) (x : α) : foo α := quot.mk _ (b, x)\n\n@[simp]\nlemma foo.map_mk' {α β : Type} (f : α → β) (b : bool) (x : α) :\n  f <$> foo.mk b x = foo.mk b (f x) :=\nby simp only [foo.mk, foo.map_mk]; refl\n\n@[simp]\nlemma foo.map_tt {α : Type} (x y : α) :\n  foo.mk tt x = foo.mk tt y ↔ x = y :=\nby simp [foo.mk]; split; intro h; [replace h := quot.exact _ h, rw h];\n   rw (equivalence_foo.R _).eqv_gen_iff at h;\n   exact h.2 rfl\n\n/-- consequence of original definition of `supp`. If there exists more than\none value of type `α`, then the support of `foo.mk ff x` is empty -/\nlemma supp_mk_ff₀ {α} (x y : α) (h : ¬ x = y) : functor.supp (foo.mk ff x) = {} :=\nbegin\n  dsimp [functor.supp], ext z, simp, -- split; intro h,\n  classical, by_cases x = z,\n  { use (λ a, ¬ z = a), subst z,\n    dsimp [functor.liftp],\n    simp, refine ⟨foo.mk ff ⟨y,h⟩,_⟩,\n    simp, apply quot.sound, simp [foo.R] },\n  { use (λ a, x = a),\n    dsimp [functor.liftp],\n    simp [h], use foo.mk ff ⟨x,rfl⟩,\n    simp }\nend\n\n/-- consequence of original definition of `supp`. If there exists only\none value of type `α`, then the support of `foo.mk ff x` contains that value -/\nlemma supp_mk_ff₁ {α} (x : α) (h : ∀ z, x = z) : functor.supp (foo.mk ff x) = {x} :=\nbegin\n  dsimp [functor.supp], ext y, simp, split; intro h',\n  { apply @h' (= x), dsimp [functor.liftp],\n    use foo.mk ff ⟨x,rfl⟩, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with ⟨⟨z,z',hz⟩,hp⟩,\n    simp at hp, convert hz,\n    rw [h'], apply h },\nend\n\n/--\nSuch a QPF is not uniform\n-/\nlemma foo_not_uniform : ¬ @qpf.is_uniform foo _ qpf.foo :=\nbegin\n  simp only [qpf.is_uniform, foo, qpf.foo, set.image_univ, not_forall, not_imp],\n  existsi [bool,ff,ff,λ a : unit, tt,λ a : unit, ff], split,\n  { apply quot.sound, simp [foo.R, qpf.abs, prod.qpf._match_1] },\n  { simp! only [set.range, set.ext_iff],\n    simp only [not_exists, false_iff, bool.forall_bool, eq_self_iff_true, exists_false, not_true,\n      and_self, set.mem_set_of_eq, iff_false],\n    exact λ h, h () }\nend\n\n/-- intuitive consequence of original definition of `supp`. -/\nlemma supp_mk_tt {α} (x : α) : functor.supp (foo.mk tt x) = {x} :=\nbegin\n  dsimp [functor.supp], ext y, simp, split; intro h',\n  { apply @h' (= x), dsimp [functor.liftp],\n    use foo.mk tt ⟨x,rfl⟩, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with ⟨⟨z,z',hz⟩,hp⟩,\n    simp at hp, replace hp := quot.exact _ hp,\n    rw (equivalence_foo.R _).eqv_gen_iff at hp,\n    rcases hp with ⟨⟨⟩,hp⟩, subst y,\n    replace hp := hp rfl, cases hp,\n    exact hz }\nend\n\n/-- simple consequence of the definition of `supp` from the QBNF paper -/\nlemma supp_mk_ff' {α} (x : α) : qpf.supp' (foo.mk ff x) = {} :=\nbegin\n  dsimp [qpf.supp'], ext, simp, dsimp [qpf.box],\n  use ∅, simp [foo.mk], intros, apply quot.sound,\n  dsimp [foo.R], split, refl, rintro ⟨ ⟩\nend\n\n/-- simple consequence of the definition of `supp` from the QBNF paper -/\nlemma supp_mk_tt' {α} (x : α) : qpf.supp' (foo.mk tt x) = {x} :=\nbegin\n  dsimp [qpf.supp'], ext, simp, dsimp [qpf.box], split; intro h,\n  { specialize h {x} _,\n    { clear h, introv hfg, simp, rw hfg, simp },\n    { simp at h, assumption }, },\n  { introv hfg, subst x_1, classical,\n    let f : α → α ⊕ bool := λ x, if x ∈ i then sum.inl x else sum.inr tt,\n    let g : α → α ⊕ bool := λ x, if x ∈ i then sum.inl x else sum.inr ff,\n    specialize hfg _ f g _,\n    { intros, simp [*,f,g,if_pos] },\n    { simp [f,g] at hfg, split_ifs at hfg,\n      assumption, cases hfg } }\nend\nend ex\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/qpf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388167733099, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.46600992346203307}}
{"text": "/-\nCopyright (c) 2018 Andreas Swerdlow. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andreas Swerdlow\n-/\nimport algebra.module.linear_map\nimport linear_algebra.bilinear_map\nimport linear_algebra.matrix.basis\nimport linear_algebra.linear_pmap\n\n/-!\n# Sesquilinear form\n\nThis files provides properties about sesquilinear forms. The maps considered are of the form\n`M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R`, where `I₁ : R₁ →+* R` and `I₂ : R₂ →+* R` are ring homomorphisms and\n`M₁` is a module over `R₁` and `M₂` is a module over `R₂`.\nSesquilinear forms are the special case that `M₁ = M₂`, `R₁ = R₂ = R`, and `I₁ = ring_hom.id R`.\nTaking additionally `I₂ = ring_hom.id R`, then one obtains bilinear forms.\n\nThese forms are a special case of the bilinear maps defined in `bilinear_map.lean` and all basic\nlemmas about construction and elementary calculations are found there.\n\n## Main declarations\n\n* `is_ortho`: states that two vectors are orthogonal with respect to a sesquilinear form\n* `is_symm`, `is_alt`: states that a sesquilinear form is symmetric and alternating, respectively\n* `orthogonal_bilin`: provides the orthogonal complement with respect to sesquilinear form\n\n## References\n\n* <https://en.wikipedia.org/wiki/Sesquilinear_form#Over_arbitrary_rings>\n\n## Tags\n\nSesquilinear form,\n-/\n\nopen_locale big_operators\n\nvariables {R R₁ R₂ R₃ M M₁ M₂ K K₁ K₂ V V₁ V₂ n: Type*}\n\nnamespace linear_map\n\n/-! ### Orthogonal vectors -/\n\nsection comm_ring\n\n-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables [comm_semiring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  [comm_semiring R₂] [add_comm_monoid M₂] [module R₂ M₂]\n  {I₁ : R₁ →+* R} {I₂ : R₂ →+* R} {I₁' : R₁ →+* R}\n\n/-- The proposition that two elements of a sesquilinear form space are orthogonal -/\ndef is_ortho (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x y) : Prop := B x y = 0\n\nlemma is_ortho_def {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} {x y} : B.is_ortho x y ↔ B x y = 0 := iff.rfl\n\nlemma is_ortho_zero_left (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x) : is_ortho B (0 : M₁) x :=\nby { dunfold is_ortho, rw [ map_zero B, zero_apply] }\n\nlemma is_ortho_zero_right (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x) : is_ortho B x (0 : M₂) :=\nmap_zero (B x)\n\n\n\n/-- A set of vectors `v` is orthogonal with respect to some bilinear form `B` if and only\nif for all `i ≠ j`, `B (v i) (v j) = 0`. For orthogonality between two elements, use\n`bilin_form.is_ortho` -/\ndef is_Ortho (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R) (v : n → M₁) : Prop :=\npairwise (B.is_ortho on v)\n\nlemma is_Ortho_def {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R} {v : n → M₁} :\n  B.is_Ortho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 := iff.rfl\n\nlemma is_Ortho_flip (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R) {v : n → M₁} :\n  B.is_Ortho v ↔ B.flip.is_Ortho v :=\nbegin\n  simp_rw is_Ortho_def,\n  split; intros h i j hij,\n  { rw flip_apply,\n    exact h j i (ne.symm hij) },\n  simp_rw flip_apply at h,\n  exact h j i (ne.symm hij),\nend\n\nend comm_ring\nsection field\n\nvariables [field K] [field K₁] [add_comm_group V₁] [module K₁ V₁]\n  [field K₂] [add_comm_group V₂] [module K₂ V₂]\n  {I₁ : K₁ →+* K} {I₂ : K₂ →+* K} {I₁' : K₁ →+* K}\n  {J₁ : K →+* K} {J₂ : K →+* K}\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J₁ is invertible\nlemma ortho_smul_left {B : V₁ →ₛₗ[I₁] V₂ →ₛₗ[I₂] K} {x y} {a : K₁} (ha : a ≠ 0) :\n  (is_ortho B x y) ↔ (is_ortho B (a • x) y) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smulₛₗ₂, H, smul_zero]},\n  { rw [map_smulₛₗ₂, smul_eq_zero] at H,\n    cases H,\n    { rw I₁.map_eq_zero at H, trivial },\n    { exact H }}\nend\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J₂ is invertible\nlemma ortho_smul_right {B : V₁ →ₛₗ[I₁] V₂ →ₛₗ[I₂] K} {x y} {a : K₂} {ha : a ≠ 0} :\n(is_ortho B x y) ↔ (is_ortho B x (a • y)) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smulₛₗ, H, smul_zero] },\n  { rw [map_smulₛₗ, smul_eq_zero] at H,\n    cases H,\n    { simp at H,\n      exfalso,\n      exact ha H },\n    { exact H }}\nend\n\n/-- A set of orthogonal vectors `v` with respect to some sesquilinear form `B` is linearly\n  independent if for all `i`, `B (v i) (v i) ≠ 0`. -/\nlemma linear_independent_of_is_Ortho {B : V₁ →ₛₗ[I₁] V₁ →ₛₗ[I₁'] K} {v : n → V₁}\n  (hv₁ : B.is_Ortho v) (hv₂ : ∀ i, ¬ B.is_ortho (v i) (v i)) : linear_independent K₁ v :=\nbegin\n  classical,\n  rw linear_independent_iff',\n  intros s w hs i hi,\n  have : B (s.sum $ λ (i : n), w i • v i) (v i) = 0,\n  { rw [hs, map_zero, zero_apply] },\n  have hsum : s.sum (λ (j : n), I₁(w j) * B (v j) (v i)) = I₁(w i) * B (v i) (v i),\n  { apply finset.sum_eq_single_of_mem i hi,\n    intros j hj hij,\n    rw [is_Ortho_def.1 hv₁ _ _ hij, mul_zero], },\n  simp_rw [B.map_sum₂, map_smulₛₗ₂, smul_eq_mul, hsum] at this,\n  apply I₁.map_eq_zero.mp,\n  exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv₂ i) this,\nend\n\nend field\n\n\n/-! ### Reflexive bilinear forms -/\n\nsection reflexive\n\nvariables [comm_semiring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  {I₁ : R₁ →+* R} {I₂ : R₁ →+* R}\n  {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n\n/-- The proposition that a sesquilinear form is reflexive -/\ndef is_refl (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : Prop :=\n  ∀ (x y), B x y = 0 → B y x = 0\n\nnamespace is_refl\n\nvariable (H : B.is_refl)\n\nlemma eq_zero : ∀ {x y}, B x y = 0 → B y x = 0 := λ x y, H x y\n\nlemma ortho_comm {x y} : is_ortho B x y ↔ is_ortho B y x := ⟨eq_zero H, eq_zero H⟩\n\nend is_refl\nend reflexive\n\n/-! ### Symmetric bilinear forms -/\n\nsection symmetric\n\nvariables [comm_semiring R] [add_comm_monoid M] [module R M]\n  {I : R →+* R} {B : M →ₛₗ[I] M →ₗ[R] R}\n\n/-- The proposition that a sesquilinear form is symmetric -/\ndef is_symm (B : M →ₛₗ[I] M →ₗ[R] R) : Prop :=\n  ∀ (x y), I (B x y) = B y x\n\nnamespace is_symm\n\nprotected lemma eq (H : B.is_symm) (x y) : I (B x y) = B y x := H x y\n\nlemma is_refl (H : B.is_symm) : B.is_refl := λ x y H1, by { rw ←H.eq, simp [H1] }\n\nlemma ortho_comm (H : B.is_symm) {x y} : is_ortho B x y ↔ is_ortho B y x := H.is_refl.ortho_comm\n\nlemma dom_restrict_symm (H : B.is_symm) (p : submodule R M) : (B.dom_restrict₁₂ p p).is_symm :=\nbegin\n  intros x y,\n  simp_rw dom_restrict₁₂_apply,\n  exact H x y,\nend\n\nend is_symm\n\nlemma is_symm_iff_eq_flip {B : M →ₗ[R] M →ₗ[R] R} : B.is_symm ↔ B = B.flip :=\nbegin\n  split; intro h,\n  { ext,\n    rw [←h, flip_apply, ring_hom.id_apply] },\n  intros x y,\n  conv_lhs { rw h },\n  rw [flip_apply, ring_hom.id_apply],\nend\n\nend symmetric\n\n\n/-! ### Alternating bilinear forms -/\n\nsection alternating\n\nvariables [comm_ring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  {I₁ : R₁ →+* R} {I₂ : R₁ →+* R} {I : R₁ →+* R} {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n\n/-- The proposition that a sesquilinear form is alternating -/\ndef is_alt (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : Prop := ∀ x, B x x = 0\n\nnamespace is_alt\n\nvariable (H : B.is_alt)\ninclude H\n\nlemma self_eq_zero (x) : B x x = 0 := H x\n\nlemma neg (x y) : - B x y = B y x :=\nbegin\n  have H1 : B (y + x) (y + x) = 0,\n  { exact self_eq_zero H (y + x) },\n  simp [map_add, self_eq_zero H] at H1,\n  rw [add_eq_zero_iff_neg_eq] at H1,\n  exact H1,\nend\n\nlemma is_refl : B.is_refl :=\nbegin\n  intros x y h,\n  rw [←neg H, h, neg_zero],\nend\n\nlemma ortho_comm {x y} : is_ortho B x y ↔ is_ortho B y x := H.is_refl.ortho_comm\n\nend is_alt\n\nlemma is_alt_iff_eq_neg_flip  [no_zero_divisors R] [char_zero R] {B : M₁ →ₛₗ[I] M₁ →ₛₗ[I] R} :\n  B.is_alt ↔ B = -B.flip :=\nbegin\n  split; intro h,\n  { ext,\n    simp_rw [neg_apply, flip_apply],\n    exact (h.neg _ _).symm },\n  intros x,\n  let h' := congr_fun₂ h x x,\n  simp only [neg_apply, flip_apply, ←add_eq_zero_iff_eq_neg] at h',\n  exact add_self_eq_zero.mp h',\nend\n\nend alternating\n\nend linear_map\n\nnamespace submodule\n\n/-! ### The orthogonal complement -/\n\nvariables [comm_ring R] [comm_ring R₁] [add_comm_group M₁] [module R₁ M₁]\n  {I₁ : R₁ →+* R} {I₂ : R₁ →+* R}\n  {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n\n/-- The orthogonal complement of a submodule `N` with respect to some bilinear form is the set of\nelements `x` which are orthogonal to all elements of `N`; i.e., for all `y` in `N`, `B x y = 0`.\n\nNote that for general (neither symmetric nor antisymmetric) bilinear forms this definition has a\nchirality; in addition to this \"left\" orthogonal complement one could define a \"right\" orthogonal\ncomplement for which, for all `y` in `N`, `B y x = 0`.  This variant definition is not currently\nprovided in mathlib. -/\ndef orthogonal_bilin (N : submodule R₁ M₁) (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : submodule R₁ M₁ :=\n{ carrier := { m | ∀ n ∈ N, B.is_ortho n m },\n  zero_mem' := λ x _, B.is_ortho_zero_right x,\n  add_mem' := λ x y hx hy n hn,\n    by rw [linear_map.is_ortho, map_add, show B n x = 0, by exact hx n hn,\n        show B n y = 0, by exact hy n hn, zero_add],\n  smul_mem' := λ c x hx n hn,\n    by rw [linear_map.is_ortho, linear_map.map_smulₛₗ, show B n x = 0, by exact hx n hn,\n        smul_zero] }\n\nvariables {N L : submodule R₁ M₁}\n\n@[simp] lemma mem_orthogonal_bilin_iff {m : M₁} :\n  m ∈ N.orthogonal_bilin B ↔ ∀ n ∈ N, B.is_ortho n m := iff.rfl\n\nlemma orthogonal_bilin_le (h : N ≤ L) : L.orthogonal_bilin B ≤ N.orthogonal_bilin B :=\nλ _ hn l hl, hn l (h hl)\n\nlemma le_orthogonal_bilin_orthogonal_bilin (b : B.is_refl) :\n  N ≤ (N.orthogonal_bilin B).orthogonal_bilin B :=\nλ n hn m hm, b _ _ (hm n hn)\n\nend submodule\n\nnamespace linear_map\n\nsection orthogonal\n\nvariables [field K] [add_comm_group V] [module K V]\n  [field K₁] [add_comm_group V₁] [module K₁ V₁]\n  {J : K →+* K} {J₁ : K₁ →+* K} {J₁' : K₁ →+* K}\n\n-- ↓ This lemma only applies in fields as we require `a * b = 0 → a = 0 ∨ b = 0`\nlemma span_singleton_inf_orthogonal_eq_bot\n  (B : V₁ →ₛₗ[J₁] V₁ →ₛₗ[J₁'] K) (x : V₁) (hx : ¬ B.is_ortho x x) :\n  (K₁ ∙ x) ⊓ submodule.orthogonal_bilin (K₁ ∙ x) B = ⊥ :=\nbegin\n  rw ← finset.coe_singleton,\n  refine eq_bot_iff.2 (λ y h, _),\n  rcases mem_span_finset.1 h.1 with ⟨μ, rfl⟩,\n  have := h.2 x _,\n  { rw finset.sum_singleton at this ⊢,\n    suffices hμzero : μ x = 0,\n    { rw [hμzero, zero_smul, submodule.mem_bot] },\n    change B x (μ x • x) = 0 at this, rw [map_smulₛₗ, smul_eq_mul] at this,\n    exact or.elim (zero_eq_mul.mp this.symm)\n    (λ y, by { simp at y, exact y })\n    (λ hfalse, false.elim $ hx hfalse) },\n  { rw submodule.mem_span; exact λ _ hp, hp $ finset.mem_singleton_self _ }\nend\n\n-- ↓ This lemma only applies in fields since we use the `mul_eq_zero`\nlemma orthogonal_span_singleton_eq_to_lin_ker {B : V →ₗ[K] V →ₛₗ[J] K} (x : V) :\n  submodule.orthogonal_bilin (K ∙ x) B = (B x).ker :=\nbegin\n  ext y,\n  simp_rw [submodule.mem_orthogonal_bilin_iff, linear_map.mem_ker,\n           submodule.mem_span_singleton ],\n  split,\n  { exact λ h, h x ⟨1, one_smul _ _⟩ },\n  { rintro h _ ⟨z, rfl⟩,\n    rw [is_ortho, map_smulₛₗ₂, smul_eq_zero],\n    exact or.intro_right _ h }\nend\n\n\n-- todo: Generalize this to sesquilinear maps\nlemma span_singleton_sup_orthogonal_eq_top {B : V →ₗ[K] V →ₗ[K] K}\n  {x : V} (hx : ¬ B.is_ortho x x) :\n  (K ∙ x) ⊔ submodule.orthogonal_bilin (K ∙ x) B = ⊤ :=\nbegin\n  rw orthogonal_span_singleton_eq_to_lin_ker,\n  exact (B x).span_singleton_sup_ker_eq_top hx,\nend\n\n\n-- todo: Generalize this to sesquilinear maps\n/-- Given a bilinear form `B` and some `x` such that `B x x ≠ 0`, the span of the singleton of `x`\n  is complement to its orthogonal complement. -/\nlemma is_compl_span_singleton_orthogonal {B : V →ₗ[K] V →ₗ[K] K}\n  {x : V} (hx : ¬ B.is_ortho x x) : is_compl (K ∙ x) (submodule.orthogonal_bilin (K ∙ x) B) :=\n{ inf_le_bot := eq_bot_iff.1 $\n    (span_singleton_inf_orthogonal_eq_bot B x hx),\n  top_le_sup := eq_top_iff.1 $ span_singleton_sup_orthogonal_eq_top hx }\n\nend orthogonal\n\n/-! ### Nondegenerate bilinear forms -/\n\nsection nondegenerate\n\nsection comm_semiring\nvariables [comm_semiring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  [comm_semiring R₂] [add_comm_monoid M₂] [module R₂ M₂]\n  {I₁ : R₁ →+* R} {I₂ : R₂ →+* R} {I₁' : R₁ →+* R}\n\n/-- A bilinear form is called left-separating if\nthe only element that is left-orthogonal to every other element is `0`; i.e.,\nfor every nonzero `x` in `M₁`, there exists `y` in `M₂` with `B x y ≠ 0`.-/\ndef separating_left (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) : Prop :=\n∀ x : M₁, (∀ y : M₂, B x y = 0) → x = 0\n\n/-- A bilinear form is called right-separating if\nthe only element that is right-orthogonal to every other element is `0`; i.e.,\nfor every nonzero `y` in `M₂`, there exists `x` in `M₁` with `B x y ≠ 0`.-/\ndef separating_right (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) : Prop :=\n∀ y : M₂, (∀ x : M₁, B x y = 0) → y = 0\n\n/-- A bilinear form is called non-degenerate if it is left-separating and right-separating. -/\ndef nondegenerate (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) : Prop := separating_left B ∧ separating_right B\n\n@[simp] lemma flip_separating_right {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.flip.separating_right ↔ B.separating_left := ⟨λ hB x hy, hB x hy, λ hB x hy, hB x hy⟩\n\n@[simp] lemma flip_separating_left {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.flip.separating_left ↔ separating_right B := by rw [←flip_separating_right, flip_flip]\n\n@[simp] lemma flip_nondegenerate {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.flip.nondegenerate ↔ B.nondegenerate :=\niff.trans and.comm (and_congr flip_separating_right flip_separating_left)\n\nlemma separating_left_iff_linear_nontrivial {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_left ↔ ∀ x : M₁, B x = 0 → x = 0 :=\nbegin\n  split; intros h x hB,\n  { let h' := h x,\n    simp only [hB, zero_apply, eq_self_iff_true, forall_const] at h',\n    exact h' },\n  have h' : B x = 0 := by { ext, rw [zero_apply], exact hB _ },\n  exact h x h',\nend\n\nlemma separating_right_iff_linear_flip_nontrivial {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_right ↔ ∀ y : M₂, B.flip y = 0 → y = 0 :=\nby rw [←flip_separating_left, separating_left_iff_linear_nontrivial]\n\n/-- A bilinear form is left-separating if and only if it has a trivial kernel. -/\ntheorem separating_left_iff_ker_eq_bot {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_left ↔ B.ker = ⊥ :=\niff.trans separating_left_iff_linear_nontrivial linear_map.ker_eq_bot'.symm\n\n/-- A bilinear form is right-separating if and only if its flip has a trivial kernel. -/\ntheorem separating_right_iff_flip_ker_eq_bot {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_right ↔ B.flip.ker = ⊥ :=\nby rw [←flip_separating_left, separating_left_iff_ker_eq_bot]\n\nend comm_semiring\n\nsection comm_ring\n\nvariables [comm_ring R] [add_comm_group M] [module R M]\n  {I I' : R →+* R}\n\nlemma is_symm.nondegenerate_of_separating_left {B : M →ₗ[R] M →ₗ[R] R}\n  (hB : B.is_symm) (hB' : B.separating_left) : B.nondegenerate :=\nbegin\n  refine ⟨hB', _⟩,\n  rw [is_symm_iff_eq_flip.mp hB, flip_separating_right],\n  exact hB',\nend\n\nlemma is_symm.nondegenerate_of_separating_right {B : M →ₗ[R] M →ₗ[R] R}\n  (hB : B.is_symm) (hB' : B.separating_right) : B.nondegenerate :=\nbegin\n  refine ⟨_, hB'⟩,\n  rw [is_symm_iff_eq_flip.mp hB, flip_separating_left],\n  exact hB',\nend\n\n/-- The restriction of a symmetric bilinear form `B` onto a submodule `W` is\nnondegenerate if `W` has trivial intersection with its orthogonal complement,\nthat is `disjoint W (W.orthogonal_bilin B)`. -/\nlemma nondegenerate_restrict_of_disjoint_orthogonal\n  {B : M →ₗ[R] M →ₗ[R] R} (hB : B.is_symm)\n  {W : submodule R M} (hW : disjoint W (W.orthogonal_bilin B)) :\n  (B.dom_restrict₁₂ W W).nondegenerate :=\nbegin\n  refine (hB.dom_restrict_symm W).nondegenerate_of_separating_left  _,\n  rintro ⟨x, hx⟩ b₁,\n  rw [submodule.mk_eq_zero, ← submodule.mem_bot R],\n  refine hW ⟨hx, λ y hy, _⟩,\n  specialize b₁ ⟨y, hy⟩,\n  simp_rw [dom_restrict₁₂_apply, submodule.coe_mk] at b₁,\n  rw hB.ortho_comm,\n  exact b₁,\nend\n\n/-- An orthogonal basis with respect to a left-separating bilinear form has no self-orthogonal\nelements. -/\nlemma is_Ortho.not_is_ortho_basis_self_of_separating_left [nontrivial R]\n  {B : M →ₛₗ[I] M →ₛₗ[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_left)\n  (i : n) : ¬B.is_ortho (v i) (v i) :=\nbegin\n  intro ho,\n  refine v.ne_zero i (hB (v i) $ λ m, _),\n  obtain ⟨vi, rfl⟩ := v.repr.symm.surjective m,\n  rw [basis.repr_symm_apply, finsupp.total_apply, finsupp.sum, map_sum],\n  apply finset.sum_eq_zero,\n  rintros j -,\n  rw map_smulₛₗ,\n  convert mul_zero _ using 2,\n  obtain rfl | hij := eq_or_ne i j,\n  { exact ho },\n  { exact h i j hij },\nend\n\n/-- An orthogonal basis with respect to a right-separating bilinear form has no self-orthogonal\nelements. -/\nlemma is_Ortho.not_is_ortho_basis_self_of_separating_right [nontrivial R]\n  {B : M →ₛₗ[I] M →ₛₗ[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_right)\n  (i : n) : ¬B.is_ortho (v i) (v i) :=\nbegin\n  rw is_Ortho_flip at h,\n  rw is_ortho_flip,\n  exact h.not_is_ortho_basis_self_of_separating_left (flip_separating_left.mpr hB) i,\nend\n\n/-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is left-separating\nif the basis has no elements which are self-orthogonal. -/\nlemma is_Ortho.separating_left_of_not_is_ortho_basis_self [no_zero_divisors R]\n  {B : M →ₗ[R] M →ₗ[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : ∀ i, ¬B.is_ortho (v i) (v i)) :\n  B.separating_left :=\nbegin\n  intros m hB,\n  obtain ⟨vi, rfl⟩ := v.repr.symm.surjective m,\n  rw linear_equiv.map_eq_zero_iff,\n  ext i,\n  rw [finsupp.zero_apply],\n  specialize hB (v i),\n  simp_rw [basis.repr_symm_apply, finsupp.total_apply, finsupp.sum, map_sum₂, map_smulₛₗ₂,\n    smul_eq_mul] at hB,\n  rw finset.sum_eq_single i at hB,\n  { exact eq_zero_of_ne_zero_of_mul_right_eq_zero (h i) hB, },\n  { intros j hj hij, convert mul_zero _ using 2, exact hO j i hij, },\n  { intros hi, convert zero_mul _ using 2, exact finsupp.not_mem_support_iff.mp hi }\nend\n\n/-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is right-separating\nif the basis has no elements which are self-orthogonal. -/\nlemma is_Ortho.separating_right_iff_not_is_ortho_basis_self [no_zero_divisors R]\n  {B : M →ₗ[R] M →ₗ[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : ∀ i, ¬B.is_ortho (v i) (v i)) :\n  B.separating_right :=\nbegin\n  rw is_Ortho_flip at hO,\n  rw [←flip_separating_left],\n  refine is_Ortho.separating_left_of_not_is_ortho_basis_self v hO (λ i, _),\n  rw is_ortho_flip,\n  exact h i,\nend\n\n/-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is nondegenerate\nif the basis has no elements which are self-orthogonal. -/\nlemma is_Ortho.nondegenerate_of_not_is_ortho_basis_self [no_zero_divisors R]\n  {B : M →ₗ[R] M →ₗ[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : ∀ i, ¬B.is_ortho (v i) (v i)) :\n  B.nondegenerate :=\n⟨is_Ortho.separating_left_of_not_is_ortho_basis_self v hO h,\n  is_Ortho.separating_right_iff_not_is_ortho_basis_self v hO h⟩\n\nend comm_ring\n\nend nondegenerate\n\nend linear_map\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/linear_algebra/sesquilinear_form.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154240079185319, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4659949175404007}}
{"text": "/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers\n-/\nimport data.set.pointwise.interval\nimport linear_algebra.affine_space.basic\nimport linear_algebra.bilinear_map\nimport linear_algebra.pi\nimport linear_algebra.prod\n\n/-!\n# Affine maps\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines affine maps.\n\n## Main definitions\n\n* `affine_map` is the type of affine maps between two affine spaces with the same ring `k`.  Various\n  basic examples of affine maps are defined, including `const`, `id`, `line_map` and `homothety`.\n\n## Notations\n\n* `P1 →ᵃ[k] P2` is a notation for `affine_map k P1 P2`;\n* `affine_space V P`: a localized notation for `add_torsor V P` defined in\n  `linear_algebra.affine_space.basic`.\n\n## Implementation notes\n\n`out_param` is used in the definition of `[add_torsor V P]` to make `V` an implicit argument\n(deduced from `P`) in most cases; `include V` is needed in many cases for `V`, and type classes\nusing it, to be added as implicit arguments to individual lemmas.  As for modules, `k` is an\nexplicit argument rather than implied by `P` or `V`.\n\nThis file only provides purely algebraic definitions and results. Those depending on analysis or\ntopology are defined elsewhere; see `analysis.normed_space.add_torsor` and\n`topology.algebra.affine`.\n\n## References\n\n* https://en.wikipedia.org/wiki/Affine_space\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n-/\n\nopen_locale affine\n\n/-- An `affine_map k P1 P2` (notation: `P1 →ᵃ[k] P2`) is a map from `P1` to `P2` that\ninduces a corresponding linear map from `V1` to `V2`. -/\nstructure affine_map (k : Type*) {V1 : Type*} (P1 : Type*) {V2 : Type*} (P2 : Type*)\n    [ring k]\n    [add_comm_group V1] [module k V1] [affine_space V1 P1]\n    [add_comm_group V2] [module k V2] [affine_space V2 P2] :=\n(to_fun : P1 → P2)\n(linear : V1 →ₗ[k] V2)\n(map_vadd' : ∀ (p : P1) (v : V1), to_fun (v +ᵥ p) =  linear v +ᵥ to_fun p)\n\nnotation P1 ` →ᵃ[`:25 k:25 `] `:0 P2:0 := affine_map k P1 P2\n\ninstance affine_map.fun_like (k : Type*) {V1 : Type*} (P1 : Type*) {V2 : Type*} (P2 : Type*)\n  [ring k]\n  [add_comm_group V1] [module k V1] [affine_space V1 P1]\n  [add_comm_group V2] [module k V2] [affine_space V2 P2]:\n  fun_like (P1 →ᵃ[k] P2) P1 (λ _, P2) :=\n{ coe := affine_map.to_fun,\n  coe_injective' := λ ⟨f, f_linear, f_add⟩ ⟨g, g_linear, g_add⟩ (h : f = g), begin\n    cases (add_torsor.nonempty : nonempty P1) with p,\n    congr' with v,\n    apply vadd_right_cancel (f p),\n    erw [← f_add, h, ← g_add]\n  end }\n\ninstance affine_map.has_coe_to_fun (k : Type*) {V1 : Type*} (P1 : Type*) {V2 : Type*} (P2 : Type*)\n  [ring k]\n  [add_comm_group V1] [module k V1] [affine_space V1 P1]\n  [add_comm_group V2] [module k V2] [affine_space V2 P2] :\n  has_coe_to_fun (P1 →ᵃ[k] P2) (λ _, P1 → P2) := fun_like.has_coe_to_fun\n\nnamespace linear_map\n\nvariables {k : Type*} {V₁ : Type*} {V₂ : Type*} [ring k] [add_comm_group V₁] [module k V₁]\n  [add_comm_group V₂] [module k V₂] (f : V₁ →ₗ[k] V₂)\n\n/-- Reinterpret a linear map as an affine map. -/\ndef to_affine_map : V₁ →ᵃ[k] V₂ :=\n{ to_fun := f,\n  linear := f,\n  map_vadd' := λ p v, f.map_add v p }\n\n@[simp] lemma coe_to_affine_map : ⇑f.to_affine_map = f := rfl\n\n@[simp] lemma to_affine_map_linear : f.to_affine_map.linear = f := rfl\n\nend linear_map\n\nnamespace affine_map\n\nvariables {k : Type*} {V1 : Type*} {P1 : Type*} {V2 : Type*} {P2 : Type*}\n    {V3 : Type*} {P3 : Type*} {V4 : Type*} {P4 : Type*} [ring k]\n    [add_comm_group V1] [module k V1] [affine_space V1 P1]\n    [add_comm_group V2] [module k V2] [affine_space V2 P2]\n    [add_comm_group V3] [module k V3] [affine_space V3 P3]\n    [add_comm_group V4] [module k V4] [affine_space V4 P4]\ninclude V1 V2\n\n/-- Constructing an affine map and coercing back to a function\nproduces the same map. -/\n@[simp] lemma coe_mk (f : P1 → P2) (linear add) :\n  ((mk f linear add : P1 →ᵃ[k] P2) : P1 → P2) = f := rfl\n\n/-- `to_fun` is the same as the result of coercing to a function. -/\n@[simp] lemma to_fun_eq_coe (f : P1 →ᵃ[k] P2) : f.to_fun = ⇑f := rfl\n\n/-- An affine map on the result of adding a vector to a point produces\nthe same result as the linear map applied to that vector, added to the\naffine map applied to that point. -/\n@[simp] lemma map_vadd (f : P1 →ᵃ[k] P2) (p : P1) (v : V1) :\n  f (v +ᵥ p) = f.linear v +ᵥ f p := f.map_vadd' p v\n\n/-- The linear map on the result of subtracting two points is the\nresult of subtracting the result of the affine map on those two\npoints. -/\n@[simp] lemma linear_map_vsub (f : P1 →ᵃ[k] P2) (p1 p2 : P1) :\n  f.linear (p1 -ᵥ p2) = f p1 -ᵥ f p2 :=\nby conv_rhs { rw [←vsub_vadd p1 p2, map_vadd, vadd_vsub] }\n\n/-- Two affine maps are equal if they coerce to the same function. -/\n@[ext] lemma ext {f g : P1 →ᵃ[k] P2} (h : ∀ p, f p = g p) : f = g :=\nfun_like.ext _ _ h\n\nlemma ext_iff {f g : P1 →ᵃ[k] P2} : f = g ↔ ∀ p, f p = g p := ⟨λ h p, h ▸ rfl, ext⟩\n\nlemma coe_fn_injective : @function.injective (P1 →ᵃ[k] P2) (P1 → P2) coe_fn :=\nfun_like.coe_injective\n\nprotected lemma congr_arg (f : P1 →ᵃ[k] P2) {x y : P1} (h : x = y) : f x = f y :=\ncongr_arg _ h\n\nprotected lemma congr_fun {f g : P1 →ᵃ[k] P2} (h : f = g) (x : P1) : f x = g x :=\nh ▸ rfl\n\nvariables (k P1)\n\n/-- Constant function as an `affine_map`. -/\ndef const (p : P2) : P1 →ᵃ[k] P2 :=\n{ to_fun := function.const P1 p,\n  linear := 0,\n  map_vadd' := λ p v, by simp }\n\n@[simp] lemma coe_const (p : P2) : ⇑(const k P1 p) = function.const P1 p := rfl\n\n@[simp] lemma const_linear (p : P2) : (const k P1 p).linear = 0 := rfl\n\nvariables {k P1}\n\nlemma linear_eq_zero_iff_exists_const (f : P1 →ᵃ[k] P2) :\n  f.linear = 0 ↔ ∃ q, f = const k P1 q :=\nbegin\n  refine ⟨λ h, _, λ h, _⟩,\n  { use f (classical.arbitrary P1),\n    ext,\n    rw [coe_const, function.const_apply, ← @vsub_eq_zero_iff_eq V2, ← f.linear_map_vsub, h,\n      linear_map.zero_apply], },\n  { rcases h with ⟨q, rfl⟩,\n    exact const_linear k P1 q, },\nend\n\ninstance nonempty : nonempty (P1 →ᵃ[k] P2) :=\n(add_torsor.nonempty : nonempty P2).elim $ λ p, ⟨const k P1 p⟩\n\n/-- Construct an affine map by verifying the relation between the map and its linear part at one\nbase point. Namely, this function takes a map `f : P₁ → P₂`, a linear map `f' : V₁ →ₗ[k] V₂`, and\na point `p` such that for any other point `p'` we have `f p' = f' (p' -ᵥ p) +ᵥ f p`. -/\ndef mk' (f : P1 → P2) (f' : V1 →ₗ[k] V2) (p : P1) (h : ∀ p' : P1, f p' = f' (p' -ᵥ p) +ᵥ f p) :\n  P1 →ᵃ[k] P2 :=\n{ to_fun := f,\n  linear := f',\n  map_vadd' := λ p' v, by rw [h, h p', vadd_vsub_assoc, f'.map_add, vadd_vadd] }\n\n@[simp] lemma coe_mk' (f : P1 → P2) (f' : V1 →ₗ[k] V2) (p h) : ⇑(mk' f f' p h) = f := rfl\n\n@[simp] lemma mk'_linear (f : P1 → P2) (f' : V1 →ₗ[k] V2) (p h) : (mk' f f' p h).linear = f' := rfl\n\nsection has_smul\nvariables {R : Type*} [monoid R] [distrib_mul_action R V2] [smul_comm_class k R V2]\n\n/-- The space of affine maps to a module inherits an `R`-action from the action on its codomain. -/\ninstance : mul_action R (P1 →ᵃ[k] V2) :=\n{ smul := λ c f, ⟨c • f, c • f.linear, λ p v, by simp [smul_add]⟩,\n  one_smul := λ f, ext $ λ p, one_smul _ _,\n  mul_smul := λ c₁ c₂ f, ext $ λ p, mul_smul _ _ _ }\n\n@[simp, norm_cast] lemma coe_smul (c : R) (f : P1 →ᵃ[k] V2) : ⇑(c • f) = c • f := rfl\n\n@[simp] lemma smul_linear (t : R) (f : P1 →ᵃ[k] V2) : (t • f).linear = t • f.linear := rfl\n\ninstance [distrib_mul_action Rᵐᵒᵖ V2] [is_central_scalar R V2] :\n  is_central_scalar R (P1 →ᵃ[k] V2) :=\n{ op_smul_eq_smul := λ r x, ext $ λ _, op_smul_eq_smul _ _ }\n\nend has_smul\n\ninstance : has_zero (P1 →ᵃ[k] V2) := { zero := ⟨0, 0, λ p v, (zero_vadd _ _).symm⟩ }\ninstance : has_add (P1 →ᵃ[k] V2) :=\n{ add := λ f g, ⟨f + g, f.linear + g.linear, λ p v, by simp [add_add_add_comm]⟩ }\ninstance : has_sub (P1 →ᵃ[k] V2) :=\n{ sub := λ f g, ⟨f - g, f.linear - g.linear, λ p v, by simp [sub_add_sub_comm]⟩ }\ninstance : has_neg (P1 →ᵃ[k] V2) := { neg := λ f, ⟨-f, -f.linear, λ p v, by simp [add_comm]⟩ }\n\n@[simp, norm_cast] lemma coe_zero : ⇑(0 : P1 →ᵃ[k] V2) = 0 := rfl\n@[simp, norm_cast] lemma coe_add (f g : P1 →ᵃ[k] V2) : ⇑(f + g) = f + g := rfl\n@[simp, norm_cast] lemma coe_neg (f : P1 →ᵃ[k] V2) : ⇑(-f) = -f := rfl\n@[simp, norm_cast] lemma coe_sub (f g : P1 →ᵃ[k] V2) : ⇑(f - g) = f - g := rfl\n@[simp] lemma zero_linear : (0 : P1 →ᵃ[k] V2).linear = 0 := rfl\n@[simp] lemma add_linear (f g : P1 →ᵃ[k] V2) : (f + g).linear = f.linear + g.linear := rfl\n@[simp] lemma sub_linear (f g : P1 →ᵃ[k] V2) : (f - g).linear = f.linear - g.linear := rfl\n@[simp] lemma neg_linear (f : P1 →ᵃ[k] V2) : (-f).linear = -f.linear := rfl\n\n/-- The set of affine maps to a vector space is an additive commutative group. -/\ninstance : add_comm_group (P1 →ᵃ[k] V2) :=\ncoe_fn_injective.add_comm_group _\n  coe_zero coe_add coe_neg coe_sub (λ _ _, coe_smul _ _) (λ _ _, coe_smul _ _)\n\n/-- The space of affine maps from `P1` to `P2` is an affine space over the space of affine maps\nfrom `P1` to the vector space `V2` corresponding to `P2`. -/\ninstance : affine_space (P1 →ᵃ[k] V2) (P1 →ᵃ[k] P2) :=\n{ vadd := λ f g, ⟨λ p, f p +ᵥ g p, f.linear + g.linear, λ p v,\n    by simp [vadd_vadd, add_right_comm]⟩,\n  zero_vadd := λ f, ext $ λ p, zero_vadd _ (f p),\n  add_vadd := λ f₁ f₂ f₃, ext $ λ p, add_vadd (f₁ p) (f₂ p) (f₃ p),\n  vsub := λ f g, ⟨λ p, f p -ᵥ g p, f.linear - g.linear, λ p v,\n    by simp [vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, add_sub, sub_add_eq_add_sub]⟩,\n  vsub_vadd' := λ f g, ext $ λ p, vsub_vadd (f p) (g p),\n  vadd_vsub' := λ f g, ext $ λ p, vadd_vsub (f p) (g p) }\n\n@[simp] lemma vadd_apply (f : P1 →ᵃ[k] V2) (g : P1 →ᵃ[k] P2) (p : P1) :\n  (f +ᵥ g) p = f p +ᵥ g p :=\nrfl\n\n@[simp] lemma vsub_apply (f g : P1 →ᵃ[k] P2) (p : P1) :\n  (f -ᵥ g : P1 →ᵃ[k] V2) p = f p -ᵥ g p :=\nrfl\n\n/-- `prod.fst` as an `affine_map`. -/\ndef fst : (P1 × P2) →ᵃ[k] P1 :=\n{ to_fun := prod.fst,\n  linear := linear_map.fst k V1 V2,\n  map_vadd' := λ _ _, rfl }\n\n@[simp] lemma coe_fst : ⇑(fst : (P1 × P2) →ᵃ[k] P1) = prod.fst := rfl\n@[simp] lemma fst_linear : (fst : (P1 × P2) →ᵃ[k] P1).linear = linear_map.fst k V1 V2 := rfl\n\n/-- `prod.snd` as an `affine_map`. -/\ndef snd : (P1 × P2) →ᵃ[k] P2 :=\n{ to_fun := prod.snd,\n  linear := linear_map.snd k V1 V2,\n  map_vadd' := λ _ _, rfl }\n\n@[simp] lemma coe_snd : ⇑(snd : (P1 × P2) →ᵃ[k] P2) = prod.snd := rfl\n@[simp] lemma snd_linear : (snd : (P1 × P2) →ᵃ[k] P2).linear = linear_map.snd k V1 V2 := rfl\n\nvariables (k P1)\nomit V2\n\n/-- Identity map as an affine map. -/\ndef id : P1 →ᵃ[k] P1 :=\n{ to_fun := id,\n  linear := linear_map.id,\n  map_vadd' := λ p v, rfl }\n\n/-- The identity affine map acts as the identity. -/\n@[simp] lemma coe_id : ⇑(id k P1) = _root_.id := rfl\n\n@[simp] lemma id_linear : (id k P1).linear = linear_map.id := rfl\n\nvariable {P1}\n\n/-- The identity affine map acts as the identity. -/\nlemma id_apply (p : P1) : id k P1 p = p := rfl\n\nvariables {k P1}\n\ninstance : inhabited (P1 →ᵃ[k] P1) := ⟨id k P1⟩\n\ninclude V2 V3\n\n/-- Composition of affine maps. -/\ndef comp (f : P2 →ᵃ[k] P3) (g : P1 →ᵃ[k] P2) : P1 →ᵃ[k] P3 :=\n{ to_fun := f ∘ g,\n  linear := f.linear.comp g.linear,\n  map_vadd' := begin\n    intros p v,\n    rw [function.comp_app, g.map_vadd, f.map_vadd],\n    refl\n  end }\n\n/-- Composition of affine maps acts as applying the two functions. -/\n@[simp] lemma coe_comp (f : P2 →ᵃ[k] P3) (g : P1 →ᵃ[k] P2) :\n  ⇑(f.comp g) = f ∘ g := rfl\n\n/-- Composition of affine maps acts as applying the two functions. -/\nlemma comp_apply (f : P2 →ᵃ[k] P3) (g : P1 →ᵃ[k] P2) (p : P1) :\n  f.comp g p = f (g p) := rfl\n\nomit V3\n\n@[simp] lemma comp_id (f : P1 →ᵃ[k] P2) : f.comp (id k P1) = f := ext $ λ p, rfl\n\n@[simp] lemma id_comp (f : P1 →ᵃ[k] P2) : (id k P2).comp f = f := ext $ λ p, rfl\n\ninclude V3 V4\n\nlemma comp_assoc (f₃₄ : P3 →ᵃ[k] P4) (f₂₃ : P2 →ᵃ[k] P3) (f₁₂ : P1 →ᵃ[k] P2) :\n  (f₃₄.comp f₂₃).comp f₁₂ = f₃₄.comp (f₂₃.comp f₁₂) :=\nrfl\n\nomit V2 V3 V4\n\ninstance : monoid (P1 →ᵃ[k] P1) :=\n{ one := id k P1,\n  mul := comp,\n  one_mul := id_comp,\n  mul_one := comp_id,\n  mul_assoc := comp_assoc }\n\n@[simp] lemma coe_mul (f g : P1 →ᵃ[k] P1) : ⇑(f * g) = f ∘ g := rfl\n@[simp] lemma coe_one : ⇑(1 : P1 →ᵃ[k] P1) = _root_.id := rfl\n\n/-- `affine_map.linear` on endomorphisms is a `monoid_hom`. -/\n@[simps] def linear_hom : (P1 →ᵃ[k] P1) →* (V1 →ₗ[k] V1) :=\n{ to_fun := linear,\n  map_one' := rfl,\n  map_mul' := λ _ _, rfl }\n\ninclude V2\n\n@[simp] lemma linear_injective_iff (f : P1 →ᵃ[k] P2) :\n  function.injective f.linear ↔ function.injective f :=\nbegin\n  obtain ⟨p⟩ := (infer_instance : nonempty P1),\n  have h : ⇑f.linear = (equiv.vadd_const (f p)).symm ∘ f ∘ (equiv.vadd_const p),\n  { ext v, simp [f.map_vadd, vadd_vsub_assoc], },\n  rw [h, equiv.comp_injective, equiv.injective_comp],\nend\n\n@[simp] lemma linear_surjective_iff (f : P1 →ᵃ[k] P2) :\n  function.surjective f.linear ↔ function.surjective f :=\nbegin\n  obtain ⟨p⟩ := (infer_instance : nonempty P1),\n  have h : ⇑f.linear = (equiv.vadd_const (f p)).symm ∘ f ∘ (equiv.vadd_const p),\n  { ext v, simp [f.map_vadd, vadd_vsub_assoc], },\n  rw [h, equiv.comp_surjective, equiv.surjective_comp],\nend\n\n@[simp] lemma linear_bijective_iff (f : P1 →ᵃ[k] P2) :\n  function.bijective f.linear ↔ function.bijective f :=\nand_congr f.linear_injective_iff f.linear_surjective_iff\n\nlemma image_vsub_image {s t : set P1} (f : P1 →ᵃ[k] P2) :\n  (f '' s) -ᵥ (f '' t) = f.linear '' (s -ᵥ t) :=\nbegin\n  ext v,\n  simp only [set.mem_vsub, set.mem_image, exists_exists_and_eq_and, exists_and_distrib_left,\n    ← f.linear_map_vsub],\n  split,\n  { rintros ⟨x, hx, y, hy, hv⟩,\n    exact ⟨x -ᵥ y, ⟨x, hx, y, hy, rfl⟩, hv⟩, },\n  { rintros ⟨-, ⟨x, hx, y, hy, rfl⟩, rfl⟩,\n    exact ⟨x, hx, y, hy, rfl⟩, },\nend\n\nomit V2\n\n/-! ### Definition of `affine_map.line_map` and lemmas about it -/\n\n/-- The affine map from `k` to `P1` sending `0` to `p₀` and `1` to `p₁`. -/\ndef line_map (p₀ p₁ : P1) : k →ᵃ[k] P1 :=\n((linear_map.id : k →ₗ[k] k).smul_right (p₁ -ᵥ p₀)).to_affine_map +ᵥ const k k p₀\n\nlemma coe_line_map (p₀ p₁ : P1) : (line_map p₀ p₁ : k → P1) = λ c, c • (p₁ -ᵥ p₀) +ᵥ p₀ := rfl\n\nlemma line_map_apply (p₀ p₁ : P1) (c : k) : line_map p₀ p₁ c = c • (p₁ -ᵥ p₀) +ᵥ p₀ := rfl\n\nlemma line_map_apply_module' (p₀ p₁ : V1) (c : k) : line_map p₀ p₁ c = c • (p₁ - p₀) + p₀ := rfl\n\n\n\nomit V1\n\nlemma line_map_apply_ring' (a b c : k) : line_map a b c = c * (b - a) + a :=\nrfl\n\nlemma line_map_apply_ring (a b c : k) : line_map a b c = (1 - c) * a + c * b :=\nline_map_apply_module a b c\n\ninclude V1\n\nlemma line_map_vadd_apply (p : P1) (v : V1) (c : k) :\n  line_map p (v +ᵥ p) c = c • v +ᵥ p :=\nby rw [line_map_apply, vadd_vsub]\n\n@[simp] lemma line_map_linear (p₀ p₁ : P1) :\n  (line_map p₀ p₁ : k →ᵃ[k] P1).linear = linear_map.id.smul_right (p₁ -ᵥ p₀) :=\nadd_zero _\n\nlemma line_map_same_apply (p : P1) (c : k) : line_map p p c = p := by simp [line_map_apply]\n\n@[simp] lemma line_map_same (p : P1) : line_map p p = const k k p :=\next $ line_map_same_apply p\n\n@[simp] lemma line_map_apply_zero (p₀ p₁ : P1) : line_map p₀ p₁ (0:k) = p₀ :=\nby simp [line_map_apply]\n\n@[simp] lemma line_map_apply_one (p₀ p₁ : P1) : line_map p₀ p₁ (1:k) = p₁ :=\nby simp [line_map_apply]\n\n@[simp] lemma line_map_eq_line_map_iff [no_zero_smul_divisors k V1] {p₀ p₁ : P1} {c₁ c₂ : k} :\n  line_map p₀ p₁ c₁ = line_map p₀ p₁ c₂ ↔ p₀ = p₁ ∨ c₁ = c₂ :=\nby rw [line_map_apply, line_map_apply, ←@vsub_eq_zero_iff_eq V1, vadd_vsub_vadd_cancel_right,\n       ←sub_smul, smul_eq_zero, sub_eq_zero, vsub_eq_zero_iff_eq, or_comm, eq_comm]\n\n@[simp] lemma line_map_eq_left_iff [no_zero_smul_divisors k V1] {p₀ p₁ : P1} {c : k} :\n  line_map p₀ p₁ c = p₀ ↔ p₀ = p₁ ∨ c = 0 :=\nby rw [←@line_map_eq_line_map_iff k V1, line_map_apply_zero]\n\n@[simp] lemma line_map_eq_right_iff [no_zero_smul_divisors k V1] {p₀ p₁ : P1} {c : k} :\n  line_map p₀ p₁ c = p₁ ↔ p₀ = p₁ ∨ c = 1 :=\nby rw [←@line_map_eq_line_map_iff k V1, line_map_apply_one]\n\nvariables (k)\n\nlemma line_map_injective [no_zero_smul_divisors k V1] {p₀ p₁ : P1} (h : p₀ ≠ p₁) :\n  function.injective (line_map p₀ p₁ : k → P1) :=\nλ c₁ c₂ hc, (line_map_eq_line_map_iff.mp hc).resolve_left h\n\nvariables {k}\n\ninclude V2\n\n@[simp] lemma apply_line_map (f : P1 →ᵃ[k] P2) (p₀ p₁ : P1) (c : k) :\n  f (line_map p₀ p₁ c) = line_map (f p₀) (f p₁) c :=\nby simp [line_map_apply]\n\n@[simp] lemma comp_line_map (f : P1 →ᵃ[k] P2) (p₀ p₁ : P1) :\n  f.comp (line_map p₀ p₁) = line_map (f p₀) (f p₁) :=\next $ f.apply_line_map p₀ p₁\n\n@[simp] lemma fst_line_map (p₀ p₁ : P1 × P2) (c : k) :\n  (line_map p₀ p₁ c).1 = line_map p₀.1 p₁.1 c :=\nfst.apply_line_map p₀ p₁ c\n\n@[simp] lemma snd_line_map (p₀ p₁ : P1 × P2) (c : k) :\n  (line_map p₀ p₁ c).2 = line_map p₀.2 p₁.2 c :=\nsnd.apply_line_map p₀ p₁ c\n\nomit V2\n\nlemma line_map_symm (p₀ p₁ : P1) :\n  line_map p₀ p₁ = (line_map p₁ p₀).comp (line_map (1:k) (0:k)) :=\nby { rw [comp_line_map], simp }\n\nlemma line_map_apply_one_sub (p₀ p₁ : P1) (c : k) :\n  line_map p₀ p₁ (1 - c) = line_map p₁ p₀ c :=\nby { rw [line_map_symm p₀, comp_apply], congr, simp [line_map_apply] }\n\n@[simp] lemma line_map_vsub_left (p₀ p₁ : P1) (c : k) :\n  line_map p₀ p₁ c -ᵥ p₀ = c • (p₁ -ᵥ p₀) :=\nvadd_vsub _ _\n\n@[simp] lemma left_vsub_line_map (p₀ p₁ : P1) (c : k) :\n  p₀ -ᵥ line_map p₀ p₁ c = c • (p₀ -ᵥ p₁) :=\nby rw [← neg_vsub_eq_vsub_rev, line_map_vsub_left, ← smul_neg, neg_vsub_eq_vsub_rev]\n\n@[simp] lemma line_map_vsub_right (p₀ p₁ : P1) (c : k) :\n  line_map p₀ p₁ c -ᵥ p₁ = (1 - c) • (p₀ -ᵥ p₁) :=\nby rw [← line_map_apply_one_sub, line_map_vsub_left]\n\n@[simp] lemma right_vsub_line_map (p₀ p₁ : P1) (c : k) :\n  p₁ -ᵥ line_map p₀ p₁ c = (1 - c) • (p₁ -ᵥ p₀) :=\nby rw [← line_map_apply_one_sub, left_vsub_line_map]\n\nlemma line_map_vadd_line_map (v₁ v₂ : V1) (p₁ p₂ : P1) (c : k) :\n  line_map v₁ v₂ c +ᵥ line_map p₁ p₂ c = line_map (v₁ +ᵥ p₁) (v₂ +ᵥ p₂) c :=\n((fst : V1 × P1 →ᵃ[k] V1) +ᵥ snd).apply_line_map  (v₁, p₁) (v₂, p₂) c\n\nlemma line_map_vsub_line_map (p₁ p₂ p₃ p₄ : P1) (c : k) :\n  line_map p₁ p₂ c -ᵥ line_map p₃ p₄ c = line_map (p₁ -ᵥ p₃) (p₂ -ᵥ p₄) c :=\n-- Why Lean fails to find this instance without a hint?\nby letI : affine_space (V1 × V1) (P1 × P1) := prod.add_torsor; exact\n((fst : P1 × P1 →ᵃ[k] P1) -ᵥ (snd : P1 × P1 →ᵃ[k] P1)).apply_line_map (_, _) (_, _) c\n\n/-- Decomposition of an affine map in the special case when the point space and vector space\nare the same. -/\nlemma decomp (f : V1 →ᵃ[k] V2) : (f : V1 → V2) = f.linear + (λ z, f 0) :=\nbegin\n  ext x,\n  calc\n    f x = f.linear x +ᵥ f 0                      : by simp [← f.map_vadd]\n    ... = (f.linear.to_fun + λ (z : V1), f 0) x  : by simp\nend\n\n/-- Decomposition of an affine map in the special case when the point space and vector space\nare the same. -/\nlemma decomp' (f : V1 →ᵃ[k] V2) : (f.linear : V1 → V2) = f - (λ z, f 0) :=\nby rw decomp ; simp only [linear_map.map_zero, pi.add_apply, add_sub_cancel, zero_add]\n\nomit V1\n\nlemma image_uIcc {k : Type*} [linear_ordered_field k] (f : k →ᵃ[k] k)\n  (a b : k) :\n  f '' set.uIcc a b = set.uIcc (f a) (f b) :=\nbegin\n  have : ⇑f = (λ x, x + f 0) ∘ λ x, x * (f 1 - f 0),\n  { ext x,\n    change f x = x • (f 1 -ᵥ f 0) +ᵥ f 0,\n    rw [← f.linear_map_vsub, ← f.linear.map_smul, ← f.map_vadd],\n    simp only [vsub_eq_sub, add_zero, mul_one, vadd_eq_add, sub_zero, smul_eq_mul] },\n  rw [this, set.image_comp],\n  simp only [set.image_add_const_uIcc, set.image_mul_const_uIcc]\nend\n\nsection\n\nvariables {ι : Type*} {V : Π i : ι, Type*} {P : Π i : ι, Type*} [Π i, add_comm_group (V i)]\n  [Π i, module k (V i)] [Π i, add_torsor (V i) (P i)]\n\ninclude V\n\n/-- Evaluation at a point as an affine map. -/\ndef proj (i : ι) : (Π i : ι, P i) →ᵃ[k] P i :=\n{ to_fun := λ f, f i,\n  linear := @linear_map.proj k ι _ V _ _ i,\n  map_vadd' := λ p v, rfl }\n\n@[simp] lemma proj_apply (i : ι) (f : Π i, P i) : @proj k _ ι V P _ _ _ i f = f i := rfl\n\n@[simp] lemma proj_linear (i : ι) :\n   (@proj k _ ι V P _ _ _ i).linear = @linear_map.proj k ι _ V _ _ i := rfl\n\nlemma pi_line_map_apply (f g : Π i, P i) (c : k) (i : ι) :\n  line_map f g c i = line_map (f i) (g i) c :=\n(proj i : (Π i, P i) →ᵃ[k] P i).apply_line_map f g c\n\nend\n\nend affine_map\n\nnamespace affine_map\n\nvariables {R k V1 P1 V2 : Type*}\n\nsection ring\nvariables [ring k] [add_comm_group V1] [affine_space V1 P1] [add_comm_group V2]\nvariables [module k V1] [module k V2]\ninclude V1\n\nsection distrib_mul_action\nvariables [monoid R] [distrib_mul_action R V2] [smul_comm_class k R V2]\n\n/-- The space of affine maps to a module inherits an `R`-action from the action on its codomain. -/\ninstance : distrib_mul_action R (P1 →ᵃ[k] V2) :=\n{ smul_add := λ c f g, ext $ λ p, smul_add _ _ _,\n  smul_zero := λ c, ext $ λ p, smul_zero _ }\n\nend distrib_mul_action\n\nsection module\nvariables [semiring R] [module R V2] [smul_comm_class k R V2]\n\n/-- The space of affine maps taking values in an `R`-module is an `R`-module. -/\ninstance : module R (P1 →ᵃ[k] V2) :=\n{ smul := (•),\n  add_smul := λ c₁ c₂ f, ext $ λ p, add_smul _ _ _,\n  zero_smul := λ f, ext $ λ p, zero_smul _ _,\n  .. affine_map.distrib_mul_action }\n\nvariables (R)\n\n/-- The space of affine maps between two modules is linearly equivalent to the product of the\ndomain with the space of linear maps, by taking the value of the affine map at `(0 : V1)` and the\nlinear part.\n\nSee note [bundled maps over different rings]-/\n@[simps] def to_const_prod_linear_map : (V1 →ᵃ[k] V2) ≃ₗ[R] V2 × (V1 →ₗ[k] V2) :=\n{ to_fun    := λ f, ⟨f 0, f.linear⟩,\n  inv_fun   := λ p, p.2.to_affine_map + const k V1 p.1,\n  left_inv  := λ f, by { ext, rw f.decomp, simp, },\n  right_inv := by { rintros ⟨v, f⟩, ext; simp, },\n  map_add'  := by simp,\n  map_smul' := by simp, }\n\nend module\n\nend ring\n\nsection comm_ring\n\nvariables [comm_ring k] [add_comm_group V1] [affine_space V1 P1] [add_comm_group V2]\nvariables [module k V1] [module k V2]\ninclude V1\n\n/-- `homothety c r` is the homothety (also known as dilation) about `c` with scale factor `r`. -/\ndef homothety (c : P1) (r : k) : P1 →ᵃ[k] P1 :=\nr • (id k P1 -ᵥ const k P1 c) +ᵥ const k P1 c\n\nlemma homothety_def (c : P1) (r : k) :\n  homothety c r = r • (id k P1 -ᵥ const k P1 c) +ᵥ const k P1 c :=\nrfl\n\nlemma homothety_apply (c : P1) (r : k) (p : P1) : homothety c r p = r • (p -ᵥ c : V1) +ᵥ c := rfl\n\nlemma homothety_eq_line_map (c : P1) (r : k) (p : P1) : homothety c r p = line_map c p r := rfl\n\n@[simp] lemma homothety_one (c : P1) : homothety c (1:k) = id k P1 :=\nby { ext p, simp [homothety_apply] }\n\n@[simp] lemma homothety_apply_same (c : P1) (r : k) : homothety c r c = c := line_map_same_apply c r\n\nlemma homothety_mul_apply (c : P1) (r₁ r₂ : k) (p : P1) :\n  homothety c (r₁ * r₂) p = homothety c r₁ (homothety c r₂ p) :=\nby simp [homothety_apply, mul_smul]\n\nlemma homothety_mul (c : P1) (r₁ r₂ : k) :\n  homothety c (r₁ * r₂) = (homothety c r₁).comp (homothety c r₂) :=\next $ homothety_mul_apply c r₁ r₂\n\n@[simp] lemma homothety_zero (c : P1) : homothety c (0:k) = const k P1 c :=\nby { ext p, simp [homothety_apply] }\n\n@[simp] lemma homothety_add (c : P1) (r₁ r₂ : k) :\n  homothety c (r₁ + r₂) = r₁ • (id k P1 -ᵥ const k P1 c) +ᵥ homothety c r₂ :=\nby simp only [homothety_def, add_smul, vadd_vadd]\n\n/-- `homothety` as a multiplicative monoid homomorphism. -/\ndef homothety_hom (c : P1) : k →* P1 →ᵃ[k] P1 :=\n⟨homothety c, homothety_one c, homothety_mul c⟩\n\n@[simp] lemma coe_homothety_hom (c : P1) : ⇑(homothety_hom c : k →* _) = homothety c := rfl\n\n/-- `homothety` as an affine map. -/\ndef homothety_affine (c : P1) : k →ᵃ[k] (P1 →ᵃ[k] P1) :=\n⟨homothety c, (linear_map.lsmul k _).flip (id k P1 -ᵥ const k P1 c),\n  function.swap (homothety_add c)⟩\n\n@[simp] lemma coe_homothety_affine (c : P1) :\n  ⇑(homothety_affine c : k →ᵃ[k] _) = homothety c :=\nrfl\n\nend comm_ring\n\nend affine_map\n\nsection\nvariables {𝕜 E F : Type*} [ring 𝕜] [add_comm_group E] [add_comm_group F] [module 𝕜 E] [module 𝕜 F]\n\n/-- Applying an affine map to an affine combination of two points yields an affine combination of\nthe images. -/\nlemma convex.combo_affine_apply {x y : E} {a b : 𝕜} {f : E →ᵃ[𝕜] F} (h : a + b = 1) :\n  f (a • x + b • y) = a • f x + b • f y :=\nby { simp only [convex.combo_eq_smul_sub_add h, ←vsub_eq_sub], exact f.apply_line_map _ _ _ }\n\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/linear_algebra/affine_space/affine_map.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.46590690290958603}}
{"text": "/-\nCopyright (c) 2020 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.pi\nimport Mathlib.data.prod\nimport Mathlib.logic.unique\nimport Mathlib.logic.function.basic\nimport Mathlib.PostPort\n\nuniverses u_3 l u_1 u_2 u_4 \n\nnamespace Mathlib\n\n/-!\n# Nontrivial types\n\nA type is *nontrivial* if it contains at least two elements. This is useful in particular for rings\n(where it is equivalent to the fact that zero is different from one) and for vector spaces\n(where it is equivalent to the fact that the dimension is positive).\n\nWe introduce a typeclass `nontrivial` formalizing this property.\n-/\n\n/-- Predicate typeclass for expressing that a type is not reduced to a single element. In rings,\nthis is equivalent to `0 ≠ 1`. In vector spaces, this is equivalent to positive dimension. -/\nclass nontrivial (α : Type u_3) where\n  exists_pair_ne : ∃ (x : α), ∃ (y : α), x ≠ y\n\ntheorem nontrivial_iff {α : Type u_1} : nontrivial α ↔ ∃ (x : α), ∃ (y : α), x ≠ y :=\n  { mp := fun (h : nontrivial α) => nontrivial.exists_pair_ne,\n    mpr := fun (h : ∃ (x : α), ∃ (y : α), x ≠ y) => nontrivial.mk h }\n\ntheorem exists_pair_ne (α : Type u_1) [nontrivial α] : ∃ (x : α), ∃ (y : α), x ≠ y :=\n  nontrivial.exists_pair_ne\n\ntheorem exists_ne {α : Type u_1} [nontrivial α] (x : α) : ∃ (y : α), y ≠ x := sorry\n\n-- `x` and `y` are explicit here, as they are often needed to guide typechecking of `h`.\n\ntheorem nontrivial_of_ne {α : Type u_1} (x : α) (y : α) (h : x ≠ y) : nontrivial α :=\n  nontrivial.mk (Exists.intro x (Exists.intro y h))\n\n-- `x` and `y` are explicit here, as they are often needed to guide typechecking of `h`.\n\ntheorem nontrivial_of_lt {α : Type u_1} [preorder α] (x : α) (y : α) (h : x < y) : nontrivial α :=\n  nontrivial.mk (Exists.intro x (Exists.intro y (ne_of_lt h)))\n\nprotected instance nontrivial.to_nonempty {α : Type u_1} [nontrivial α] : Nonempty α := sorry\n\n/-- An inhabited type is either nontrivial, or has a unique element. -/\ndef nontrivial_psum_unique (α : Type u_1) [Inhabited α] : psum (nontrivial α) (unique α) :=\n  dite (nontrivial α) (fun (h : nontrivial α) => psum.inl h)\n    fun (h : ¬nontrivial α) => psum.inr (unique.mk { default := Inhabited.default } sorry)\n\ntheorem subsingleton_iff {α : Type u_1} : subsingleton α ↔ ∀ (x y : α), x = y :=\n  { mp := fun (h : subsingleton α) => subsingleton.elim,\n    mpr := fun (h : ∀ (x y : α), x = y) => subsingleton.intro h }\n\ntheorem not_nontrivial_iff_subsingleton {α : Type u_1} : ¬nontrivial α ↔ subsingleton α := sorry\n\ntheorem not_subsingleton (α : Type u_1) [h : nontrivial α] : ¬subsingleton α := sorry\n\n/-- A type is either a subsingleton or nontrivial. -/\ntheorem subsingleton_or_nontrivial (α : Type u_1) : subsingleton α ∨ nontrivial α :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (subsingleton α ∨ nontrivial α))\n        (Eq.symm (propext not_nontrivial_iff_subsingleton))))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (¬nontrivial α ∨ nontrivial α))\n          (propext (or_comm (¬nontrivial α) (nontrivial α)))))\n      (classical.em (nontrivial α)))\n\ntheorem false_of_nontrivial_of_subsingleton (α : Type u_1) [nontrivial α] [subsingleton α] :\n    False :=\n  sorry\n\nprotected instance option.nontrivial {α : Type u_1} [Nonempty α] : nontrivial (Option α) :=\n  nonempty.elim_to_inhabited\n    fun (inst : Inhabited α) =>\n      nontrivial.mk\n        (Exists.intro none\n          (Exists.intro (some Inhabited.default)\n            (id (id fun (ᾰ : none = some Inhabited.default) => option.no_confusion ᾰ))))\n\n/-- Pushforward a `nontrivial` instance along an injective function. -/\nprotected theorem function.injective.nontrivial {α : Type u_1} {β : Type u_2} [nontrivial α]\n    {f : α → β} (hf : function.injective f) : nontrivial β :=\n  sorry\n\n/-- Pullback a `nontrivial` instance along a surjective function. -/\nprotected theorem function.surjective.nontrivial {α : Type u_1} {β : Type u_2} [nontrivial β]\n    {f : α → β} (hf : function.surjective f) : nontrivial α :=\n  sorry\n\n/-- An injective function from a nontrivial type has an argument at\nwhich it does not take a given value. -/\nprotected theorem function.injective.exists_ne {α : Type u_1} {β : Type u_2} [nontrivial α]\n    {f : α → β} (hf : function.injective f) (y : β) : ∃ (x : α), f x ≠ y :=\n  sorry\n\nprotected instance nontrivial_prod_right {α : Type u_1} {β : Type u_2} [Nonempty α] [nontrivial β] :\n    nontrivial (α × β) :=\n  function.surjective.nontrivial prod.snd_surjective\n\nprotected instance nontrivial_prod_left {α : Type u_1} {β : Type u_2} [nontrivial α] [Nonempty β] :\n    nontrivial (α × β) :=\n  function.surjective.nontrivial prod.fst_surjective\n\nnamespace pi\n\n\n/-- A pi type is nontrivial if it's nonempty everywhere and nontrivial somewhere. -/\ntheorem nontrivial_at {I : Type u_3} {f : I → Type u_4} (i' : I) [inst : ∀ (i : I), Nonempty (f i)]\n    [nontrivial (f i')] : nontrivial ((i : I) → f i) :=\n  function.injective.nontrivial\n    (function.update_injective (fun (i : I) => Classical.choice (inst i)) i')\n\n/--\nAs a convenience, provide an instance automatically if `(f (default I))` is nontrivial.\n\nIf a different index has the non-trivial type, then use `haveI := nontrivial_at that_index`.\n-/\nprotected instance nontrivial {I : Type u_3} {f : I → Type u_4} [Inhabited I]\n    [inst : ∀ (i : I), Nonempty (f i)] [nontrivial (f Inhabited.default)] :\n    nontrivial ((i : I) → f i) :=\n  nontrivial_at Inhabited.default\n\nend pi\n\n\nprotected instance function.nontrivial {α : Type u_1} {β : Type u_2} [h : Nonempty α]\n    [nontrivial β] : nontrivial (α → β) :=\n  nonempty.elim h fun (a : α) => pi.nontrivial_at a\n\nprotected theorem subsingleton.le {α : Type u_1} [preorder α] [subsingleton α] (x : α) (y : α) :\n    x ≤ y :=\n  le_of_eq (subsingleton.elim x y)\n\nnamespace tactic\n\n\n/--\nTries to generate a `nontrivial α` instance by performing case analysis on\n`subsingleton_or_nontrivial α`,\nattempting to discharge the subsingleton branch using lemmas with `@[nontriviality]` attribute,\nincluding `subsingleton.le` and `eq_iff_true_of_subsingleton`.\n-/\n/--\nTries to generate a `nontrivial α` instance using `nontrivial_of_ne` or `nontrivial_of_lt`\nand local hypotheses.\n-/\nend tactic\n\n\nnamespace tactic.interactive\n\n\n/--\nAttempts to generate a `nontrivial α` hypothesis.\n\nThe tactic first looks for an instance using `apply_instance`.\n\nIf the goal is an (in)equality, the type `α` is inferred from the goal.\nOtherwise, the type needs to be specified in the tactic invocation, as `nontriviality α`.\n\nThe `nontriviality` tactic will first look for strict inequalities amongst the hypotheses,\nand use these to derive the `nontrivial` instance directly.\n\nOtherwise, it will perform a case split on `subsingleton α ∨ nontrivial α`, and attempt to discharge\nthe `subsingleton` goal using `simp [lemmas] with nontriviality`, where `[lemmas]` is a list of\nadditional `simp` lemmas that can be passed to `nontriviality` using the syntax\n`nontriviality α using [lemmas]`.\n\n```\nexample {R : Type} [ordered_ring R] {a : R} (h : 0 < a) : 0 < a :=\nbegin\n  nontriviality, -- There is now a `nontrivial R` hypothesis available.\n  assumption,\nend\n```\n\n```\nexample {R : Type} [comm_ring R] {r s : R} : r * s = s * r :=\nbegin\n  nontriviality, -- There is now a `nontrivial R` hypothesis available.\n  apply mul_comm,\nend\n```\n\n```\nexample {R : Type} [ordered_ring R] {a : R} (h : 0 < a) : (2 : ℕ) ∣ 4 :=\nbegin\n  nontriviality R, -- there is now a `nontrivial R` hypothesis available.\n  dec_trivial\nend\n```\n\n```\ndef myeq {α : Type} (a b : α) : Prop := a = b\n\nexample {α : Type} (a b : α) (h : a = b) : myeq a b :=\nbegin\n  success_if_fail { nontriviality α }, -- Fails\n  nontriviality α using [myeq], -- There is now a `nontrivial α` hypothesis available\n  assumption\nend\n```\n-/\nend tactic.interactive\n\n\nnamespace bool\n\n\nprotected instance nontrivial : nontrivial Bool :=\n  nontrivial.mk (Exists.intro tt (Exists.intro false tt_eq_ff_eq_false))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/logic/nontrivial_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4659068985020881}}
{"text": "/-\nCopyright (c) 2020 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\nimport analysis.calculus.mean_value\n\n/-!\n# L'Hôpital's rule for 0/0 indeterminate forms\n\nIn this file, we prove several forms of \"L'Hopital's rule\" for computing 0/0\nindeterminate forms. The proof of `has_deriv_at.lhopital_zero_right_on_Ioo`\nis based on the one given in the corresponding\n[Wikibooks](https://en.wikibooks.org/wiki/Calculus/L%27H%C3%B4pital%27s_Rule)\nchapter, and all other statements are derived from this one by composing by\ncarefully chosen functions.\n\nNote that the filter `f'/g'` tends to isn't required to be one of `𝓝 a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `ℝ`.\n\nEach statement is available in a `has_deriv_at` form and a `deriv` form, which\nis denoted by each statement being in either the `has_deriv_at` or the `deriv`\nnamespace.\n\n## Tags\n\nL'Hôpital's rule, L'Hopital's rule\n-/\n\nopen filter set\nopen_locale filter topological_space pointwise\n\nvariables {a b : ℝ} (hab : a < b) {l : filter ℝ} {f f' g g' : ℝ → ℝ}\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' ≠ 0`) have\nto be satisfied on an explicitly-provided interval.\n-/\n\nnamespace has_deriv_at\n\ninclude hab\n\ntheorem lhopital_zero_right_on_Ioo\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  have sub : ∀ x ∈ Ioo a b, Ioo a x ⊆ Ioo a b := λ x hx, Ioo_subset_Ioo (le_refl a) (le_of_lt hx.2),\n  have hg : ∀ x ∈ (Ioo a b), g x ≠ 0,\n  { intros x hx h,\n    have : tendsto g (𝓝[<] x) (𝓝 0),\n    { rw [← h, ← nhds_within_Ioo_eq_nhds_within_Iio hx.1],\n      exact ((hgg' x hx).continuous_at.continuous_within_at.mono $ sub x hx).tendsto },\n    obtain ⟨y, hyx, hy⟩ : ∃ c ∈ Ioo a x, g' c = 0,\n      from exists_has_deriv_at_eq_zero' hx.1 hga this (λ y hy, hgg' y $ sub x hx hy),\n    exact hg' y (sub x hx hyx) hy },\n  have : ∀ x ∈ Ioo a b, ∃ c ∈ Ioo a x, (f x) * (g' c) = (g x) * (f' c),\n  { intros x hx,\n    rw [← sub_zero (f x), ← sub_zero (g x)],\n    exact exists_ratio_has_deriv_at_eq_ratio_slope' g g' hx.1 f f'\n      (λ y hy, hgg' y $ sub x hx hy) (λ y hy, hff' y $ sub x hx hy) hga hfa\n      (tendsto_nhds_within_of_tendsto_nhds (hgg' x hx).continuous_at.tendsto)\n      (tendsto_nhds_within_of_tendsto_nhds (hff' x hx).continuous_at.tendsto) },\n  choose! c hc using this,\n  have : ∀ x ∈ Ioo a b, ((λ x', (f' x') / (g' x')) ∘ c) x = f x / g x,\n  { intros x hx,\n    rcases hc x hx with ⟨h₁, h₂⟩,\n    field_simp [hg x hx, hg' (c x) ((sub x hx) h₁)],\n    simp only [h₂],\n    rwa mul_comm },\n  have cmp : ∀ x ∈ Ioo a b, a < c x ∧ c x < x,\n    from λ x hx, (hc x hx).1,\n  rw ← nhds_within_Ioo_eq_nhds_within_Ioi hab,\n  apply tendsto_nhds_within_congr this,\n  simp only,\n  apply hdiv.comp,\n  refine tendsto_nhds_within_of_tendsto_nhds_of_eventually_within _\n    (tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds\n      (tendsto_nhds_within_of_tendsto_nhds tendsto_id) _ _) _,\n  all_goals\n  { apply eventually_nhds_within_of_forall,\n    intros x hx,\n    have := cmp x hx,\n    try {simp},\n    linarith [this] }\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (nhds_within a (Ioi a)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within a (Ioi a)) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [← hfa, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcf a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\n  { rw [← hga, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcg a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\nend\n\ntheorem lhopital_zero_left_on_Ioo\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (𝓝 0)) (hgb : tendsto g (nhds_within b (Iio b)) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  -- Here, we essentially compose by `has_neg.neg`. The following is mostly technical details.\n  have hdnf : ∀ x ∈ -Ioo a b, has_deriv_at (f ∘ has_neg.neg) (f' (-x) * (-1)) x,\n    from λ x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : ∀ x ∈ -Ioo a b, has_deriv_at (g ∘ has_neg.neg) (g' (-x) * (-1)) x,\n    from λ x hx, comp x (hgg' (-x) hx) (has_deriv_at_neg x),\n  rw preimage_neg_Ioo at hdnf,\n  rw preimage_neg_Ioo at hdng,\n  have := lhopital_zero_right_on_Ioo (neg_lt_neg hab) hdnf hdng\n    (by { intros x hx h,\n          apply hg' _ (by {rw ← preimage_neg_Ioo at hx, exact hx}),\n          rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h })\n    (hfb.comp tendsto_neg_nhds_within_Ioi_neg)\n    (hgb.comp tendsto_neg_nhds_within_Ioi_neg)\n    (by { simp only [neg_div_neg_eq, mul_one, mul_neg_eq_neg_mul_symm],\n          exact (tendsto_congr $ λ x, rfl).mp (hdiv.comp tendsto_neg_nhds_within_Ioi_neg) }),\n  have := this.comp tendsto_neg_nhds_within_Iio,\n  unfold function.comp at this,\n  simpa only [neg_neg]\nend\n\ntheorem lhopital_zero_left_on_Ioc\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hcf : continuous_on f (Ioc a b)) (hcg : continuous_on g (Ioc a b))\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfb : f b = 0) (hgb : g b = 0)\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  refine lhopital_zero_left_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [← hfb, ← nhds_within_Ioo_eq_nhds_within_Iio hab],\n    exact ((hcf b $ right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto },\n  { rw [← hgb, ← nhds_within_Ioo_eq_nhds_within_Iio hab],\n    exact ((hcg b $ right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto },\nend\n\nomit hab\n\ntheorem lhopital_zero_at_top_on_Ioi\n  (hff' : ∀ x ∈ Ioi a, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioi a, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioi a, g' x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  obtain ⟨ a', haa', ha'⟩ : ∃ a', a < a' ∧ 0 < a' :=\n    ⟨1 + max a 0, ⟨lt_of_le_of_lt (le_max_left a 0) (lt_one_add _),\n                   lt_of_le_of_lt (le_max_right a 0) (lt_one_add _)⟩⟩,\n  have fact1 : ∀ (x:ℝ), x ∈ Ioo 0 a'⁻¹ → x ≠ 0 := λ _ hx, (ne_of_lt hx.1).symm,\n  have fact2 : ∀ x ∈ Ioo 0 a'⁻¹, a < x⁻¹,\n    from λ _ hx, lt_trans haa' ((lt_inv ha' hx.1).mpr hx.2),\n  have hdnf : ∀ x ∈ Ioo 0 a'⁻¹, has_deriv_at (f ∘ has_inv.inv) (f' (x⁻¹) * (-(x^2)⁻¹)) x,\n    from λ x hx, comp x (hff' (x⁻¹) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have hdng : ∀ x ∈ Ioo 0 a'⁻¹, has_deriv_at (g ∘ has_inv.inv) (g' (x⁻¹) * (-(x^2)⁻¹)) x,\n    from λ x hx, comp x (hgg' (x⁻¹) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have := lhopital_zero_right_on_Ioo (inv_pos.mpr ha') hdnf hdng\n    (by { intros x hx,\n          refine mul_ne_zero _ (neg_ne_zero.mpr $ inv_ne_zero $ pow_ne_zero _ $ fact1 x hx),\n          exact hg' _ (fact2 x hx) })\n    (hftop.comp tendsto_inv_zero_at_top)\n    (hgtop.comp tendsto_inv_zero_at_top)\n    (by { refine (tendsto_congr' _).mp (hdiv.comp tendsto_inv_zero_at_top),\n          rw eventually_eq_iff_exists_mem,\n          use [Ioi 0, self_mem_nhds_within],\n          intros x hx,\n          unfold function.comp,\n          erw mul_div_mul_right,\n          refine neg_ne_zero.mpr (inv_ne_zero $ pow_ne_zero _ $ ne_of_gt hx) }),\n  have := this.comp tendsto_inv_at_top_zero',\n  unfold function.comp at this,\n  simpa only [inv_inv₀],\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hff' : ∀ x ∈ Iio a, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Iio a, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Iio a, g' x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  -- Here, we essentially compose by `has_neg.neg`. The following is mostly technical details.\n  have hdnf : ∀ x ∈ -Iio a, has_deriv_at (f ∘ has_neg.neg) (f' (-x) * (-1)) x,\n    from λ x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : ∀ x ∈ -Iio a, has_deriv_at (g ∘ has_neg.neg) (g' (-x) * (-1)) x,\n    from λ x hx, comp x (hgg' (-x) hx) (has_deriv_at_neg x),\n  rw preimage_neg_Iio at hdnf,\n  rw preimage_neg_Iio at hdng,\n  have := lhopital_zero_at_top_on_Ioi hdnf hdng\n    (by { intros x hx h,\n          apply hg' _ (by {rw ← preimage_neg_Iio at hx, exact hx}),\n          rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h })\n    (hfbot.comp tendsto_neg_at_top_at_bot)\n    (hgbot.comp tendsto_neg_at_top_at_bot)\n    (by { simp only [mul_one, mul_neg_eq_neg_mul_symm, neg_div_neg_eq],\n          exact (tendsto_congr $ λ x, rfl).mp (hdiv.comp tendsto_neg_at_top_at_bot) }),\n  have := this.comp tendsto_neg_at_bot_at_top,\n  unfold function.comp at this,\n  simpa only [neg_neg],\nend\n\nend has_deriv_at\n\nnamespace deriv\n\ninclude hab\n\ntheorem lhopital_zero_right_on_Ioo\n  (hdf : differentiable_on ℝ f (Ioo a b)) (hg' : ∀ x ∈ Ioo a b, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  have hdf : ∀ x ∈ Ioo a b, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : ∀ x ∈ Ioo a b, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_right_on_Ioo hab (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfa hga hdiv\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hdf : differentiable_on ℝ f (Ioo a b))\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : ∀ x ∈ (Ioo a b), (deriv g) x ≠ 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (nhds_within a (Ioi a)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within a (Ioi a)) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hdf hg' _ _ hdiv,\n  { rw [← hfa, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcf a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\n  { rw [← hga, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcg a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\nend\n\ntheorem lhopital_zero_left_on_Ioo\n  (hdf : differentiable_on ℝ f (Ioo a b))\n  (hg' : ∀ x ∈ (Ioo a b), (deriv g) x ≠ 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (𝓝 0)) (hgb : tendsto g (nhds_within b (Iio b)) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (nhds_within b (Iio b)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  have hdf : ∀ x ∈ Ioo a b, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : ∀ x ∈ Ioo a b, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_left_on_Ioo hab (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfb hgb hdiv\nend\n\nomit hab\n\ntheorem lhopital_zero_at_top_on_Ioi\n  (hdf : differentiable_on ℝ f (Ioi a))\n  (hg' : ∀ x ∈ (Ioi a), (deriv g) x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  have hdf : ∀ x ∈ Ioi a, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioi_mem_nhds hx),\n  have hdg : ∀ x ∈ Ioi a, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_top_on_Ioi (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hftop hgtop hdiv,\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hdf : differentiable_on ℝ f (Iio a))\n  (hg' : ∀ x ∈ (Iio a), (deriv g) x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdf : ∀ x ∈ Iio a, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Iio_mem_nhds hx),\n  have hdg : ∀ x ∈ Iio a, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_bot_on_Iio (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfbot hgbot hdiv,\nend\n\nend deriv\n\n/-!\n## Generic versions\n\nThe following statements no longer any explicit interval, as they only require\nconditions holding eventually.\n-/\n\nnamespace has_deriv_at\n\n/-- L'Hôpital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right\n  (hff' : ∀ᶠ x in 𝓝[>] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[>] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[>] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ 𝓝[>] a := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_nhds_within_Ioi_iff_exists_Ioo_subset at hs,\n  rcases hs with ⟨u, hau, hu⟩,\n  refine lhopital_zero_right_on_Ioo hau _ _ _ hfa hga hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hu hx).1.1 <|> exact (hu hx).1.2 <|> exact (hu hx).2\nend\n\n/-- L'Hôpital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left\n  (hff' : ∀ᶠ x in 𝓝[<] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[<] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[<] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[<] a) (𝓝 0)) (hga : tendsto g (𝓝[<] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[<] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[<] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ 𝓝[<] a := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_nhds_within_Iio_iff_exists_Ioo_subset at hs,\n  rcases hs with ⟨l, hal, hl⟩,\n  refine lhopital_zero_left_on_Ioo hal _ _ _ hfa hga hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl hx).1.1 <|> exact (hl hx).1.2 <|> exact (hl hx).2\nend\n\n/-- L'Hôpital's rule for approaching a real, `has_deriv_at` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds'\n  (hff' : ∀ᶠ x in 𝓝[univ \\ {a}] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[univ \\ {a}] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[univ \\ {a}] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[univ \\ {a}] a) (𝓝 0)) (hga : tendsto g (𝓝[univ \\ {a}] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[univ \\ {a}] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a ∪ Ioi a,\n  { ext, rw [mem_diff_singleton, eq_true_intro $ mem_univ x, true_and, ne_iff_lt_or_gt], refl },\n  simp only [this, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact ⟨lhopital_zero_nhds_left hff'.1 hgg'.1 hg'.1 hfa.1 hga.1 hdiv.1,\n          lhopital_zero_nhds_right hff'.2 hgg'.2 hg'.2 hfa.2 hga.2 hdiv.2⟩\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds\n  (hff' : ∀ᶠ x in 𝓝 a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝 a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝 a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝 a) (𝓝 0)) (hga : tendsto g (𝓝 a) (𝓝 0))\n  (hdiv : tendsto (λ x, f' x / g' x) (𝓝 a) l) :\n  tendsto (λ x, f x / g x) (𝓝[univ \\ {a}] a) l :=\nbegin\n  apply @lhopital_zero_nhds' _ _ _ f' _ g';\n  apply eventually_nhds_within_of_eventually_nhds <|> apply tendsto_nhds_within_of_tendsto_nhds;\n  assumption\nend\n\n/-- L'Hôpital's rule for approaching +∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top\n  (hff' : ∀ᶠ x in at_top, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in at_top, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in at_top, g' x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ at_top := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_at_top_sets at hs,\n  rcases hs with ⟨l, hl⟩,\n  have hl' : Ioi l ⊆ s := λ x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_top_on_Ioi _ _ (λ x hx, hg' x $ (hl' hx).2) hftop hgtop hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl' hx).1.1 <|> exact (hl' hx).1.2\nend\n\n/-- L'Hôpital's rule for approaching -∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot\n  (hff' : ∀ᶠ x in at_bot, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in at_bot, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in at_bot, g' x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ at_bot := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_at_bot_sets at hs,\n  rcases hs with ⟨l, hl⟩,\n  have hl' : Iio l ⊆ s := λ x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_bot_on_Iio _ _ (λ x hx, hg' x $ (hl' hx).2) hfbot hgbot hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl' hx).1.1 <|> exact (hl' hx).1.2\nend\n\nend has_deriv_at\n\nnamespace deriv\n\n/-- **L'Hôpital's rule** for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right\n  (hdf : ∀ᶠ x in 𝓝[>] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[>] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[>] a) (𝓝 0)) (hga : tendsto g (𝓝[>] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[>] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[>] a) l :=\nbegin\n  have hdg : ∀ᶠ x in 𝓝[>] a, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in 𝓝[>] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in 𝓝[>] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_nhds_right hdf' hdg' hg' hfa hga hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left\n  (hdf : ∀ᶠ x in 𝓝[<] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[<] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[<] a) (𝓝 0)) (hga : tendsto g (𝓝[<] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[<] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[<] a) l :=\nbegin\n  have hdg : ∀ᶠ x in 𝓝[<] a, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in 𝓝[<] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in 𝓝[<] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_nhds_left hdf' hdg' hg' hfa hga hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `deriv` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds'\n  (hdf : ∀ᶠ x in 𝓝[univ \\ {a}] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[univ \\ {a}] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[univ \\ {a}] a) (𝓝 0)) (hga : tendsto g (𝓝[univ \\ {a}] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[univ \\ {a}] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a ∪ Ioi a,\n  { ext, rw [mem_diff_singleton, eq_true_intro $ mem_univ x, true_and, ne_iff_lt_or_gt], refl },\n  simp only [this, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact ⟨lhopital_zero_nhds_left hdf.1 hg'.1 hfa.1 hga.1 hdiv.1,\n          lhopital_zero_nhds_right hdf.2 hg'.2 hfa.2 hga.2 hdiv.2⟩,\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds\n  (hdf : ∀ᶠ x in 𝓝 a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝 a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝 a) (𝓝 0)) (hga : tendsto g (𝓝 a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝 a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[univ \\ {a}] a) l :=\nbegin\n  apply lhopital_zero_nhds';\n  apply eventually_nhds_within_of_eventually_nhds <|> apply tendsto_nhds_within_of_tendsto_nhds;\n  assumption\nend\n\n/-- **L'Hôpital's rule** for approaching +∞, `deriv` version -/\ntheorem lhopital_zero_at_top\n  (hdf : ∀ᶠ (x : ℝ) in at_top, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ (x : ℝ) in at_top, deriv g x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  have hdg : ∀ᶠ x in at_top, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in at_top, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in at_top, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_at_top hdf' hdg' hg' hftop hgtop hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching -∞, `deriv` version -/\ntheorem lhopital_zero_at_bot\n  (hdf : ∀ᶠ (x : ℝ) in at_bot, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ (x : ℝ) in at_bot, deriv g x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdg : ∀ᶠ x in at_bot, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in at_bot, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in at_bot, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_at_bot hdf' hdg' hg' hfbot hgbot hdiv\nend\n\nend deriv\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/analysis/calculus/lhopital.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.4658822631009442}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Reid Barton\n-/\nimport category_theory.functor.fully_faithful\n\n/-!\n# Induced categories and full subcategories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nGiven a category `D` and a function `F : C → D `from a type `C` to the\nobjects of `D`, there is an essentially unique way to give `C` a\ncategory structure such that `F` becomes a fully faithful functor,\nnamely by taking $$ Hom_C(X, Y) = Hom_D(FX, FY) $$. We call this the\ncategory induced from `D` along `F`.\n\nAs a special case, if `C` is a subtype of `D`,\nthis produces the full subcategory of `D` on the objects belonging to `C`.\nIn general the induced category is equivalent to the full subcategory of `D` on the\nimage of `F`.\n\n## Implementation notes\n\nIt looks odd to make `D` an explicit argument of `induced_category`,\nwhen it is determined by the argument `F` anyways. The reason to make `D`\nexplicit is in order to control its syntactic form, so that instances\nlike `induced_category.has_forget₂` (elsewhere) refer to the correct\nform of D. This is used to set up several algebraic categories like\n\n  def CommMon : Type (u+1) := induced_category Mon (bundled.map @comm_monoid.to_monoid)\n  -- not `induced_category (bundled monoid) (bundled.map @comm_monoid.to_monoid)`,\n  -- even though `Mon = bundled monoid`!\n-/\n\nnamespace category_theory\n\nuniverses v v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\n\nsection induced\n\nvariables {C : Type u₁} (D : Type u₂) [category.{v} D]\nvariables (F : C → D)\ninclude F\n\n/--\n`induced_category D F`, where `F : C → D`, is a typeclass synonym for `C`,\nwhich provides a category structure so that the morphisms `X ⟶ Y` are the morphisms\nin `D` from `F X` to `F Y`.\n-/\n@[nolint has_nonempty_instance unused_arguments]\ndef induced_category : Type u₁ := C\n\nvariables {D}\n\ninstance induced_category.has_coe_to_sort {α : Sort*} [has_coe_to_sort D α] :\n  has_coe_to_sort (induced_category D F) α :=\n⟨λ c, ↥(F c)⟩\n\ninstance induced_category.category : category.{v} (induced_category D F) :=\n{ hom  := λ X Y, F X ⟶ F Y,\n  id   := λ X, 𝟙 (F X),\n  comp := λ _ _ _ f g, f ≫ g }\n\n/--\nThe forgetful functor from an induced category to the original category,\nforgetting the extra data.\n-/\n@[simps] def induced_functor : induced_category D F ⥤ D :=\n{ obj := F, map := λ x y f, f }\n\ninstance induced_category.full : full (induced_functor F) :=\n{ preimage := λ x y f, f }\ninstance induced_category.faithful : faithful (induced_functor F) := {}\n\nend induced\n\nsection full_subcategory\n/- A full subcategory is the special case of an induced category with F = subtype.val. -/\n\nvariables {C : Type u₁} [category.{v} C]\nvariables (Z : C → Prop)\n\n/--\nA subtype-like structure for full subcategories. Morphisms just ignore the property. We don't use\nactual subtypes since the simp-normal form `↑X` of `X.val` does not work well for full\nsubcategories.\n\nSee <https://stacks.math.columbia.edu/tag/001D>. We do not define 'strictly full' subcategories.\n-/\n@[ext, nolint has_nonempty_instance] structure full_subcategory :=\n(obj : C)\n(property : Z obj)\n\ninstance full_subcategory.category : category.{v} (full_subcategory Z) :=\ninduced_category.category full_subcategory.obj\n\n/--\nThe forgetful functor from a full subcategory into the original category\n(\"forgetting\" the condition).\n-/\ndef full_subcategory_inclusion : full_subcategory Z ⥤ C :=\ninduced_functor full_subcategory.obj\n\n@[simp] lemma full_subcategory_inclusion.obj {X} :\n  (full_subcategory_inclusion Z).obj X = X.obj := rfl\n@[simp] lemma full_subcategory_inclusion.map {X Y} {f : X ⟶ Y} :\n  (full_subcategory_inclusion Z).map f = f := rfl\n\ninstance full_subcategory.full : full (full_subcategory_inclusion Z) :=\ninduced_category.full _\ninstance full_subcategory.faithful : faithful (full_subcategory_inclusion Z) :=\ninduced_category.faithful _\n\nvariables {Z} {Z' : C → Prop}\n\n/-- An implication of predicates `Z → Z'` induces a functor between full subcategories. -/\n@[simps]\ndef full_subcategory.map (h : ∀ ⦃X⦄, Z X → Z' X) : full_subcategory Z ⥤ full_subcategory Z' :=\n{ obj := λ X, ⟨X.1, h X.2⟩,\n  map := λ X Y f, f }\n\ninstance (h : ∀ ⦃X⦄, Z X → Z' X) : full (full_subcategory.map h) :=\n{ preimage := λ X Y f, f }\n\ninstance (h : ∀ ⦃X⦄, Z X → Z' X) : faithful (full_subcategory.map h) := {}\n\n@[simp] lemma full_subcategory.map_inclusion (h : ∀ ⦃X⦄, Z X → Z' X) :\n  full_subcategory.map h ⋙ full_subcategory_inclusion Z' = full_subcategory_inclusion Z :=\nrfl\n\nsection lift\nvariables {D : Type u₂} [category.{v₂} D] (P Q : D → Prop)\n\n/-- A functor which maps objects to objects satisfying a certain property induces a lift through\n    the full subcategory of objects satisfying that property. -/\n@[simps]\ndef full_subcategory.lift (F : C ⥤ D) (hF : ∀ X, P (F.obj X)) : C ⥤ full_subcategory P :=\n{ obj := λ X, ⟨F.obj X, hF X⟩,\n  map := λ X Y f, F.map f }\n\n/-- Composing the lift of a functor through a full subcategory with the inclusion yields the\n    original functor. Unfortunately, this is not true by definition, so we only get a natural\n    isomorphism, but it is pointwise definitionally true, see\n    `full_subcategory.inclusion_obj_lift_obj` and `full_subcategory.inclusion_map_lift_map`. -/\ndef full_subcategory.lift_comp_inclusion (F : C ⥤ D) (hF : ∀ X, P (F.obj X)) :\n  full_subcategory.lift P F hF ⋙ full_subcategory_inclusion P ≅ F :=\nnat_iso.of_components (λ X, iso.refl _) (by simp)\n\n@[simp]\nlemma full_subcategory.inclusion_obj_lift_obj (F : C ⥤ D) (hF : ∀ X, P (F.obj X)) {X : C} :\n  (full_subcategory_inclusion P).obj ((full_subcategory.lift P F hF).obj X) = F.obj X :=\nrfl\n\nlemma full_subcategory.inclusion_map_lift_map (F : C ⥤ D) (hF : ∀ X, P (F.obj X)) {X Y : C}\n  (f : X ⟶ Y) :\n  (full_subcategory_inclusion P).map ((full_subcategory.lift P F hF).map f) = F.map f :=\nrfl\n\ninstance (F : C ⥤ D) (hF : ∀ X, P (F.obj X)) [faithful F] :\n  faithful (full_subcategory.lift P F hF) :=\nfaithful.of_comp_iso (full_subcategory.lift_comp_inclusion P F hF)\n\ninstance (F : C ⥤ D) (hF : ∀ X, P (F.obj X)) [full F] : full (full_subcategory.lift P F hF) :=\nfull.of_comp_faithful_iso (full_subcategory.lift_comp_inclusion P F hF)\n\n@[simp]\nlemma full_subcategory.lift_comp_map (F : C ⥤ D) (hF : ∀ X, P (F.obj X)) (h : ∀ ⦃X⦄, P X → Q X) :\n  full_subcategory.lift P F hF ⋙ full_subcategory.map h =\n    full_subcategory.lift Q F (λ X, h (hF X)) :=\nrfl\n\nend lift\n\nend full_subcategory\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/full_subcategory.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6791787056691697, "lm_q1q2_score": 0.4658822630069365}}
{"text": "inductive day : Type\n| monday\n| tuesday\n| wednesday\n| thursday\n| friday\n| saturday\n| sunday\n\ndef next_weekday : day -> day\n| day.monday := day.tuesday\n| day.tuesday := day.wednesday\n| day.wednesday := day.thursday\n| day.thursday := day.friday\n| day.friday := day.saturday\n| day.saturday := day.sunday\n| day.sunday := day.monday\n\nexample : next_weekday (next_weekday day.saturday) = day.monday := rfl\n", "meta": {"author": "happy-bracket", "repo": "lean_playground", "sha": "137b76966001091c445f6f472d27bbe5a8cf5d49", "save_path": "github-repos/lean/happy-bracket-lean_playground", "path": "github-repos/lean/happy-bracket-lean_playground/lean_playground-137b76966001091c445f6f472d27bbe5a8cf5d49/sf_weekdays.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.46588226291292895}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.category.default\nimport Mathlib.data.equiv.functor\nimport Mathlib.PostPort\n\nuniverses u₀ u₁ l \n\nnamespace Mathlib\n\n/-!\n# Functions functorial with respect to equivalences\n\nAn `equiv_functor` is a function from `Type → Type` equipped with the additional data of\ncoherently mapping equivalences to equivalences.\n\nIn categorical language, it is an endofunctor of the \"core\" of the category `Type`.\n-/\n\n/--\nAn `equiv_functor` is only functorial with respect to equivalences.\n\nTo construct an `equiv_functor`, it suffices to supply just the function `f α → f β` from\nan equivalence `α ≃ β`, and then prove the functor laws. It's then a consequence that\nthis function is part of an equivalence, provided by `equiv_functor.map_equiv`.\n-/\nclass equiv_functor (f : Type u₀ → Type u₁) where\n  map : {α β : Type u₀} → α ≃ β → f α → f β\n  map_refl' :\n    autoParam (∀ (α : Type u₀), map (equiv.refl α) = id)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  map_trans' :\n    autoParam (∀ {α β γ : Type u₀} (k : α ≃ β) (h : β ≃ γ), map (equiv.trans k h) = map h ∘ map k)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n@[simp] theorem equiv_functor.map_refl {f : Type u₀ → Type u₁} [c : equiv_functor f] (α : Type u₀) :\n    equiv_functor.map (equiv.refl α) = id :=\n  sorry\n\ntheorem equiv_functor.map_trans {f : Type u₀ → Type u₁} [c : equiv_functor f] {α : Type u₀}\n    {β : Type u₀} {γ : Type u₀} (k : α ≃ β) (h : β ≃ γ) :\n    equiv_functor.map (equiv.trans k h) = equiv_functor.map h ∘ equiv_functor.map k :=\n  sorry\n\nnamespace equiv_functor\n\n\n/-- An `equiv_functor` in fact takes every equiv to an equiv. -/\ndef map_equiv (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀} (e : α ≃ β) :\n    f α ≃ f β :=\n  equiv.mk (map e) (map (equiv.symm e)) sorry sorry\n\n@[simp] theorem map_equiv_apply (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀}\n    {β : Type u₀} (e : α ≃ β) (x : f α) : coe_fn (map_equiv f e) x = map e x :=\n  rfl\n\ntheorem map_equiv_symm_apply (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀}\n    (e : α ≃ β) (y : f β) : coe_fn (equiv.symm (map_equiv f e)) y = map (equiv.symm e) y :=\n  rfl\n\n@[simp] theorem map_equiv_refl (f : Type u₀ → Type u₁) [equiv_functor f] (α : Type u₀) :\n    map_equiv f (equiv.refl α) = equiv.refl (f α) :=\n  sorry\n\n@[simp] theorem map_equiv_symm (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀} {β : Type u₀}\n    (e : α ≃ β) : equiv.symm (map_equiv f e) = map_equiv f (equiv.symm e) :=\n  equiv.ext (map_equiv_symm_apply f e)\n\n/--\nThe composition of `map_equiv`s is carried over the `equiv_functor`.\nFor plain `functor`s, this lemma is named `map_map` when applied\nor `map_comp_map` when not applied.\n-/\n@[simp] theorem map_equiv_trans (f : Type u₀ → Type u₁) [equiv_functor f] {α : Type u₀}\n    {β : Type u₀} {γ : Type u₀} (ab : α ≃ β) (bc : β ≃ γ) :\n    equiv.trans (map_equiv f ab) (map_equiv f bc) = map_equiv f (equiv.trans ab bc) :=\n  sorry\n\nprotected instance of_is_lawful_functor (f : Type u₀ → Type u₁) [Functor f] [is_lawful_functor f] :\n    equiv_functor f :=\n  mk fun (α β : Type u₀) (e : α ≃ β) => Functor.map ⇑e\n\ntheorem map_equiv.injective (f : Type u₀ → Type u₁) [Applicative f] [is_lawful_applicative f]\n    {α : Type u₀} {β : Type u₀} (h : Type u₀ → function.injective pure) :\n    function.injective (map_equiv f) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/control/equiv_functor_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592642, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.46580833041813563}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen, Eric Wieser\n-/\nimport data.matrix.basic\nimport data.fin.vec_notation\nimport tactic.fin_cases\nimport algebra.big_operators.fin\n\n/-!\n# Matrix and vector notation\n\nThis file includes `simp` lemmas for applying operations in `data.matrix.basic` to values built out\nof the matrix notation `![a, b] = vec_cons a (vec_cons b vec_empty)` defined in\n`data.fin.vec_notation`.\n\nThis also provides the new notation `!![a, b; c, d] = matrix.of ![![a, b], ![c, d]]`.\nThis notation also works for empty matrices; `!![,,,] : matrix (fin 0) (fin 3)` and\n`!![;;;] : matrix (fin 3) (fin 0)`.\n\n## Implementation notes\n\nThe `simp` lemmas require that one of the arguments is of the form `vec_cons _ _`.\nThis ensures `simp` works with entries only when (some) entries are already given.\nIn other words, this notation will only appear in the output of `simp` if it\nalready appears in the input.\n\n## Notations\n\nThis file provide notation `!![a, b; c, d]` for matrices, which corresponds to\n`matrix.of ![![a, b], ![c, d]]`.\nA parser for `a, b; c, d`-style strings is provided as `matrix.entry_parser`, while\n`matrix.notation` provides the hook for the `!!` notation.\nNote that in lean 3 the pretty-printer will not show `!!` notation, instead showing the version\nwith `of ![![...]]`.\n\n## Examples\n\nExamples of usage can be found in the `test/matrix.lean` file.\n-/\n\nnamespace matrix\n\nuniverse u\nvariables {α : Type u} {o n m : ℕ} {m' n' o' : Type*}\n\nopen_locale matrix\n\n/-- Matrices can be reflected whenever their entries can. We insert an `@id (matrix m' n' α)` to\nprevent immediate decay to a function. -/\nmeta instance matrix.reflect [reflected_univ.{u}] [reflected_univ.{u_1}] [reflected_univ.{u_2}]\n  [reflected _ α] [reflected _ m'] [reflected _ n']\n  [h : has_reflect (m' → n' → α)] : has_reflect (matrix m' n' α) :=\nλ m, (by reflect_name : reflected _ @id.{(max u_1 u_2 u) + 1}).subst₂\n  ((by reflect_name : reflected _ @matrix.{u_1 u_2 u}).subst₃ `(_) `(_) `(_)) $\n  by { dunfold matrix, exact h m }\n\nsection parser\nopen lean\nopen lean.parser\nopen interactive\nopen interactive.types\n\n/-- Parse the entries of a matrix -/\nmeta def entry_parser {α : Type} (p : parser α) :\n  parser (Σ m n, fin m → fin n → α) :=\ndo\n  -- a list of lists if the matrix has at least one row, or the number of columns if the matrix has\n  -- zero rows.\n  let p : parser (list (list α) ⊕ ℕ) :=\n    (sum.inl <$> (\n      (pure [] <* tk \";\").repeat_at_least 1 <|> -- empty rows\n      (sep_by_trailing (tk \";\") $ sep_by_trailing (tk \",\") p)) <|>\n    (sum.inr <$> list.length <$> many (tk \",\"))), -- empty columns\n  which ← p,\n  match which with\n  | (sum.inl l) := do\n    h :: tl ← pure l,\n    let n := h.length,\n    l : list (vector α n) ← l.mmap (λ row,\n      if h : row.length = n then\n        pure (⟨row, h⟩ : vector α n)\n      else\n        interaction_monad.fail \"Rows must be of equal length\"),\n    pure ⟨l.length, n, λ i j, (l.nth_le _ i.prop).nth j⟩\n  | (sum.inr n) :=\n    pure ⟨0, n, fin_zero_elim⟩\n  end\n\n-- Lean can't find this instance without some help. We only need it available in `Type 0`, and it is\n-- a massive amount of effort to make it universe-polymorphic.\n@[instance] meta def sigma_sigma_fin_matrix_has_reflect {α : Type}\n  [has_reflect α] [reflected _ α] :\n  has_reflect (Σ (m n : ℕ), fin m → fin n → α) :=\n@sigma.reflect.{0 0} _ _ ℕ (λ m, Σ n, fin m → fin n → α) _ _ _ $ λ i,\n  @sigma.reflect.{0 0} _ _ ℕ _ _ _ _ (λ j, infer_instance)\n\n/-- `!![a, b; c, d]` notation for matrices indexed by `fin m` and `fin n`. See the module docstring\nfor details. -/\n@[user_notation]\nmeta def «notation» (_ : parse $ tk \"!![\")\n  (val : parse (entry_parser (parser.pexpr 1) <* tk \"]\")) : parser pexpr :=\ndo\n  let ⟨m, n, entries⟩ := val,\n  let entry_vals := pi_fin.to_pexpr (pi_fin.to_pexpr ∘ entries),\n  pure (``(@matrix.of (fin %%`(m)) (fin %%`(n)) _).app entry_vals)\n\nend parser\n\nvariables (a b : ℕ)\n\n/-- Use `![...]` notation for displaying a `fin`-indexed matrix, for example:\n\n```\n#eval !![1, 2; 3, 4] + !![3, 4; 5, 6]  -- !![4, 6; 8, 10]\n```\n-/\ninstance [has_repr α] : has_repr (matrix (fin m) (fin n) α) :=\n{ repr := λ f,\n  \"!![\" ++ (string.intercalate \"; \" $ (list.fin_range m).map $ λ i,\n    string.intercalate \", \" $ (list.fin_range n).map (λ j, repr (f i j)))  ++ \"]\" }\n\n@[simp] lemma cons_val' (v : n' → α) (B : fin m → n' → α) (i j) :\n  vec_cons v B i j = vec_cons (v j) (λ i, B i j) i :=\nby { refine fin.cases _ _ i; simp }\n\n@[simp] lemma head_val' (B : fin m.succ → n' → α) (j : n') :\n  vec_head (λ i, B i j) = vec_head B j := rfl\n\n@[simp] lemma tail_val' (B : fin m.succ → n' → α) (j : n') :\n  vec_tail (λ i, B i j) = λ i, vec_tail B i j :=\nby { ext, simp [vec_tail] }\n\nsection dot_product\n\nvariables [add_comm_monoid α] [has_mul α]\n\n@[simp] lemma dot_product_empty (v w : fin 0 → α) :\n  dot_product v w = 0 := finset.sum_empty\n\n@[simp] lemma cons_dot_product (x : α) (v : fin n → α) (w : fin n.succ → α) :\n  dot_product (vec_cons x v) w = x * vec_head w + dot_product v (vec_tail w) :=\nby simp [dot_product, fin.sum_univ_succ, vec_head, vec_tail]\n\n@[simp] lemma dot_product_cons (v : fin n.succ → α) (x : α) (w : fin n → α) :\n  dot_product v (vec_cons x w) = vec_head v * x + dot_product (vec_tail v) w :=\nby simp [dot_product, fin.sum_univ_succ, vec_head, vec_tail]\n\n@[simp] lemma cons_dot_product_cons (x : α) (v : fin n → α) (y : α) (w : fin n → α) :\n  dot_product (vec_cons x v) (vec_cons y w) = x * y + dot_product v w :=\nby simp\n\nend dot_product\n\nsection col_row\n\n@[simp] lemma col_empty (v : fin 0 → α) : col v = vec_empty :=\nempty_eq _\n\n@[simp] lemma col_cons (x : α) (u : fin m → α) :\n  col (vec_cons x u) = vec_cons (λ _, x) (col u) :=\nby { ext i j, refine fin.cases _ _ i; simp [vec_head, vec_tail] }\n\n@[simp] lemma row_empty : row (vec_empty : fin 0 → α) = λ _, vec_empty :=\nby { ext, refl }\n\n@[simp] lemma row_cons (x : α) (u : fin m → α) :\n  row (vec_cons x u) = λ _, vec_cons x u :=\nby { ext, refl }\n\nend col_row\n\nsection transpose\n\n@[simp] lemma transpose_empty_rows (A : matrix m' (fin 0) α) : Aᵀ = of ![] := empty_eq _\n\n@[simp] lemma transpose_empty_cols (A : matrix (fin 0) m' α) : Aᵀ = of (λ i, ![]) :=\nfunext (λ i, empty_eq _)\n\n@[simp] lemma cons_transpose (v : n' → α) (A : matrix (fin m) n' α) :\n  (of (vec_cons v A))ᵀ = of (λ i, vec_cons (v i) (Aᵀ i)) :=\nby { ext i j, refine fin.cases _ _ j; simp }\n\n@[simp] lemma head_transpose (A : matrix m' (fin n.succ) α) :\n  vec_head (of.symm Aᵀ) = vec_head ∘ (of.symm A) :=\nrfl\n\n@[simp] lemma tail_transpose (A : matrix m' (fin n.succ) α) :\n  vec_tail (of.symm Aᵀ) = (vec_tail ∘ A)ᵀ :=\nby { ext i j, refl }\n\nend transpose\n\nsection mul\n\nvariables [semiring α]\n\n@[simp] lemma empty_mul [fintype n'] (A : matrix (fin 0) n' α) (B : matrix n' o' α) :\n  A ⬝ B = of ![] :=\nempty_eq _\n\n@[simp] lemma empty_mul_empty (A : matrix m' (fin 0) α) (B : matrix (fin 0) o' α) :\n  A ⬝ B = 0 :=\nrfl\n\n@[simp] lemma mul_empty [fintype n'] (A : matrix m' n' α) (B : matrix n' (fin 0) α) :\n  A ⬝ B = of (λ _, ![]) :=\nfunext (λ _, empty_eq _)\n\nlemma mul_val_succ [fintype n']\n  (A : matrix (fin m.succ) n' α) (B : matrix n' o' α) (i : fin m) (j : o') :\n  (A ⬝ B) i.succ j = (of (vec_tail (of.symm A)) ⬝ B) i j := rfl\n\n@[simp] lemma cons_mul [fintype n'] (v : n' → α) (A : fin m → n' → α) (B : matrix n' o' α) :\n  of (vec_cons v A) ⬝ B = of (vec_cons (vec_mul v B) (of.symm (of A ⬝ B))) :=\nby { ext i j, refine fin.cases _ _ i, { refl },  simp [mul_val_succ], }\n\nend mul\n\nsection vec_mul\n\nvariables [semiring α]\n\n@[simp] lemma empty_vec_mul (v : fin 0 → α) (B : matrix (fin 0) o' α) :\n  vec_mul v B = 0 :=\nrfl\n\n@[simp] lemma vec_mul_empty [fintype n'] (v : n' → α) (B : matrix n' (fin 0) α) :\n  vec_mul v B = ![] :=\nempty_eq _\n\n@[simp] lemma cons_vec_mul (x : α) (v : fin n → α) (B : fin n.succ → o' → α) :\n  vec_mul (vec_cons x v) (of B) = x • (vec_head B) + vec_mul v (of $ vec_tail B) :=\nby { ext i, simp [vec_mul] }\n\n@[simp] lemma vec_mul_cons (v : fin n.succ → α) (w : o' → α) (B : fin n → o' → α) :\n  vec_mul v (of $ vec_cons w B) = vec_head v • w + vec_mul (vec_tail v) (of B) :=\nby { ext i, simp [vec_mul] }\n\n@[simp] lemma cons_vec_mul_cons (x : α) (v : fin n → α) (w : o' → α) (B : fin n → o' → α) :\n  vec_mul (vec_cons x v) (of $ vec_cons w B) = x • w + vec_mul v (of B) :=\nby simp\n\nend vec_mul\n\nsection mul_vec\n\nvariables [semiring α]\n\n@[simp] lemma empty_mul_vec [fintype n'] (A : matrix (fin 0) n' α) (v : n' → α) :\n  mul_vec A v = ![] :=\nempty_eq _\n\n@[simp] lemma mul_vec_empty (A : matrix m' (fin 0) α) (v : fin 0 → α) :\n  mul_vec A v = 0 :=\nrfl\n\n@[simp] lemma cons_mul_vec [fintype n'] (v : n' → α) (A : fin m → n' → α) (w : n' → α) :\n  mul_vec (of $ vec_cons v A) w = vec_cons (dot_product v w) (mul_vec (of A) w) :=\nby { ext i, refine fin.cases _ _ i; simp [mul_vec] }\n\n@[simp] lemma mul_vec_cons {α} [comm_semiring α] (A : m' → (fin n.succ) → α) (x : α)\n  (v : fin n → α) :\n  mul_vec (of A) (vec_cons x v) = (x • vec_head ∘ A) + mul_vec (of (vec_tail ∘ A)) v :=\nby { ext i, simp [mul_vec, mul_comm] }\n\nend mul_vec\n\nsection vec_mul_vec\n\nvariables [semiring α]\n\n@[simp] lemma empty_vec_mul_vec (v : fin 0 → α) (w : n' → α) :\n  vec_mul_vec v w = ![] :=\nempty_eq _\n\n@[simp] lemma vec_mul_vec_empty (v : m' → α) (w : fin 0 → α) :\n  vec_mul_vec v w = λ _, ![] :=\nfunext (λ i, empty_eq _)\n\n@[simp] lemma cons_vec_mul_vec (x : α) (v : fin m → α) (w : n' → α) :\n  vec_mul_vec (vec_cons x v) w = vec_cons (x • w) (vec_mul_vec v w) :=\nby { ext i, refine fin.cases _ _ i; simp [vec_mul_vec] }\n\n@[simp] lemma vec_mul_vec_cons (v : m' → α) (x : α) (w : fin n → α) :\n  vec_mul_vec v (vec_cons x w) = λ i, v i • vec_cons x w :=\nby { ext i j, rw [vec_mul_vec_apply, pi.smul_apply, smul_eq_mul] }\n\nend vec_mul_vec\n\nsection smul\n\nvariables [semiring α]\n\n@[simp] lemma smul_mat_empty {m' : Type*} (x : α) (A : fin 0 → m' → α) : x • A = ![] := empty_eq _\n\n@[simp] lemma smul_mat_cons (x : α) (v : n' → α) (A : fin m → n' → α) :\n  x • vec_cons v A = vec_cons (x • v) (x • A) :=\nby { ext i, refine fin.cases _ _ i; simp }\n\nend smul\n\nsection submatrix\n\n@[simp] lemma submatrix_empty (A : matrix m' n' α) (row : fin 0 → m') (col : o' → n') :\n  submatrix A row col = ![] :=\nempty_eq _\n\n@[simp] \n\nend submatrix\n\nsection vec2_and_vec3\n\nsection one\n\nvariables [has_zero α] [has_one α]\n\nlemma one_fin_two : (1 : matrix (fin 2) (fin 2) α) = !![1, 0; 0, 1] :=\nby { ext i j, fin_cases i; fin_cases j; refl }\n\nlemma one_fin_three : (1 : matrix (fin 3) (fin 3) α) = !![1, 0, 0; 0, 1, 0; 0, 0, 1] :=\nby { ext i j, fin_cases i; fin_cases j; refl }\n\nend one\n\nlemma eta_fin_two (A : matrix (fin 2) (fin 2) α) : A = !![A 0 0, A 0 1; A 1 0, A 1 1] :=\nby { ext i j, fin_cases i; fin_cases j; refl }\n\nlemma eta_fin_three (A : matrix (fin 3) (fin 3) α) :\n  A = !![A 0 0, A 0 1, A 0 2;\n         A 1 0, A 1 1, A 1 2;\n         A 2 0, A 2 1, A 2 2] :=\nby { ext i j, fin_cases i; fin_cases j; refl }\n\nlemma mul_fin_two [add_comm_monoid α] [has_mul α] (a₁₁ a₁₂ a₂₁ a₂₂ b₁₁ b₁₂ b₂₁ b₂₂ : α) :\n  !![a₁₁, a₁₂;\n     a₂₁, a₂₂] ⬝ !![b₁₁, b₁₂;\n                    b₂₁, b₂₂] = !![a₁₁ * b₁₁ + a₁₂ * b₂₁, a₁₁ * b₁₂ + a₁₂ * b₂₂;\n                                   a₂₁ * b₁₁ + a₂₂ * b₂₁, a₂₁ * b₁₂ + a₂₂ * b₂₂] :=\nbegin\n  ext i j,\n  fin_cases i; fin_cases j; simp [matrix.mul, dot_product, fin.sum_univ_succ]\nend\n\nlemma mul_fin_three [add_comm_monoid α] [has_mul α]\n  (a₁₁ a₁₂ a₁₃ a₂₁ a₂₂ a₂₃ a₃₁ a₃₂ a₃₃ b₁₁ b₁₂ b₁₃ b₂₁ b₂₂ b₂₃ b₃₁ b₃₂ b₃₃ : α) :\n  !![a₁₁, a₁₂, a₁₃;\n     a₂₁, a₂₂, a₂₃;\n     a₃₁, a₃₂, a₃₃] ⬝ !![b₁₁, b₁₂, b₁₃;\n                         b₂₁, b₂₂, b₂₃;\n                         b₃₁, b₃₂, b₃₃] =\n  !![a₁₁*b₁₁ + a₁₂*b₂₁ + a₁₃*b₃₁, a₁₁*b₁₂ + a₁₂*b₂₂ + a₁₃*b₃₂, a₁₁*b₁₃ + a₁₂*b₂₃ + a₁₃*b₃₃;\n     a₂₁*b₁₁ + a₂₂*b₂₁ + a₂₃*b₃₁, a₂₁*b₁₂ + a₂₂*b₂₂ + a₂₃*b₃₂, a₂₁*b₁₃ + a₂₂*b₂₃ + a₂₃*b₃₃;\n     a₃₁*b₁₁ + a₃₂*b₂₁ + a₃₃*b₃₁, a₃₁*b₁₂ + a₃₂*b₂₂ + a₃₃*b₃₂, a₃₁*b₁₃ + a₃₂*b₂₃ + a₃₃*b₃₃] :=\nbegin\n  ext i j,\n  fin_cases i; fin_cases j; simp [matrix.mul, dot_product, fin.sum_univ_succ, ←add_assoc],\nend\n\nlemma vec2_eq {a₀ a₁ b₀ b₁ : α} (h₀ : a₀ = b₀) (h₁ : a₁ = b₁) :\n  ![a₀, a₁] = ![b₀, b₁] :=\nby subst_vars\n\nlemma vec3_eq {a₀ a₁ a₂ b₀ b₁ b₂ : α} (h₀ : a₀ = b₀) (h₁ : a₁ = b₁) (h₂ : a₂ = b₂) :\n  ![a₀, a₁, a₂] = ![b₀, b₁, b₂] :=\nby subst_vars\n\nlemma vec2_add [has_add α] (a₀ a₁ b₀ b₁ : α) :\n  ![a₀, a₁] + ![b₀, b₁] = ![a₀ + b₀, a₁ + b₁] :=\nby rw [cons_add_cons, cons_add_cons, empty_add_empty]\n\nlemma vec3_add [has_add α] (a₀ a₁ a₂ b₀ b₁ b₂ : α) :\n  ![a₀, a₁, a₂] + ![b₀, b₁, b₂] = ![a₀ + b₀, a₁ + b₁, a₂ + b₂] :=\nby rw [cons_add_cons, cons_add_cons, cons_add_cons, empty_add_empty]\n\nlemma smul_vec2 {R : Type*} [has_smul R α] (x : R) (a₀ a₁ : α) :\n  x • ![a₀, a₁] = ![x • a₀, x • a₁] :=\nby rw [smul_cons, smul_cons, smul_empty]\n\nlemma smul_vec3 {R : Type*} [has_smul R α] (x : R) (a₀ a₁ a₂ : α) :\n  x • ![a₀, a₁, a₂] = ![x • a₀, x • a₁, x • a₂] :=\nby rw [smul_cons, smul_cons, smul_cons, smul_empty]\n\nvariables [add_comm_monoid α] [has_mul α]\n\nlemma vec2_dot_product' {a₀ a₁ b₀ b₁ : α} :\n  ![a₀, a₁] ⬝ᵥ ![b₀, b₁] = a₀ * b₀ + a₁ * b₁ :=\nby rw [cons_dot_product_cons, cons_dot_product_cons, dot_product_empty, add_zero]\n\n@[simp] lemma vec2_dot_product (v w : fin 2 → α) :\n  v ⬝ᵥ w = v 0 * w 0 + v 1 * w 1 :=\nvec2_dot_product'\n\nlemma vec3_dot_product' {a₀ a₁ a₂ b₀ b₁ b₂ : α} :\n  ![a₀, a₁, a₂] ⬝ᵥ ![b₀, b₁, b₂] = a₀ * b₀ + a₁ * b₁ + a₂ * b₂ :=\nby rw [cons_dot_product_cons, cons_dot_product_cons, cons_dot_product_cons,\n       dot_product_empty, add_zero, add_assoc]\n\n@[simp] lemma vec3_dot_product (v w : fin 3 → α) :\n  v ⬝ᵥ w = v 0 * w 0 + v 1 * w 1 + v 2 * w 2 :=\nvec3_dot_product'\n\nend vec2_and_vec3\n\nend matrix\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/matrix/notation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592642, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4658083217919112}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.limits\nimport Mathlib.category_theory.thin\nimport Mathlib.PostPort\n\nuniverses v l u \n\nnamespace Mathlib\n\n/-!\n# Wide pullbacks\n\nWe define the category `wide_pullback_shape`, (resp. `wide_pushout_shape`) which is the category\nobtained from a discrete category of type `J` by adjoining a terminal (resp. initial) element.\nLimits of this shape are wide pullbacks (pushouts).\nThe convenience method `wide_cospan` (`wide_span`) constructs a functor from this category, hitting\nthe given morphisms.\n\nWe use `wide_pullback_shape` to define ordinary pullbacks (pushouts) by using `J := walking_pair`,\nwhich allows easy proofs of some related lemmas.\nFurthermore, wide pullbacks are used to show the existence of limits in the slice category.\nNamely, if `C` has wide pullbacks then `C/B` has limits for any object `B` in `C`.\n\nTypeclasses `has_wide_pullbacks` and `has_finite_wide_pullbacks` assert the existence of wide\npullbacks and finite wide pullbacks.\n-/\n\nnamespace category_theory.limits\n\n\n/-- A wide pullback shape for any type `J` can be written simply as `option J`. -/\ndef wide_pullback_shape (J : Type v) := Option J\n\n/-- A wide pushout shape for any type `J` can be written simply as `option J`. -/\ndef wide_pushout_shape (J : Type v) := Option J\n\nnamespace wide_pullback_shape\n\n\n/-- The type of arrows for the shape indexing a wide pullback. -/\ninductive hom {J : Type v} : wide_pullback_shape J → wide_pullback_shape J → Type v where\n| id : (X : wide_pullback_shape J) → hom X X\n| term : (j : J) → hom (some j) none\n\nprotected instance struct {J : Type v} : category_struct (wide_pullback_shape J) := sorry\n\nprotected instance hom.inhabited {J : Type v} : Inhabited (hom none none) :=\n  { default := hom.id none }\n\nprotected instance subsingleton_hom {J : Type v} (j : wide_pullback_shape J)\n    (j' : wide_pullback_shape J) : subsingleton (j ⟶ j') :=\n  sorry\n\nprotected instance category {J : Type v} : small_category (wide_pullback_shape J) := thin_category\n\n@[simp] theorem hom_id {J : Type v} (X : wide_pullback_shape J) : hom.id X = 𝟙 := rfl\n\n/--\nConstruct a functor out of the wide pullback shape given a J-indexed collection of arrows to a\nfixed object.\n-/\n@[simp] theorem wide_cospan_map {J : Type v} {C : Type u} [category C] (B : C) (objs : J → C)\n    (arrows : (j : J) → objs j ⟶ B) (X : wide_pullback_shape J) (Y : wide_pullback_shape J)\n    (f : X ⟶ Y) :\n    functor.map (wide_cospan B objs arrows) f =\n        hom.cases_on f\n          (fun (f_1 : wide_pullback_shape J) (H_1 : X = f_1) =>\n            Eq._oldrec\n              (fun (H_2 : Y = X) =>\n                Eq._oldrec\n                  (fun (f : X ⟶ X) (H_3 : f == hom.id X) =>\n                    Eq._oldrec 𝟙 (wide_cospan._proof_1 X f H_3))\n                  (wide_cospan._proof_2 X Y H_2) f)\n              H_1)\n          (fun (j : J) (H_1 : X = some j) =>\n            Eq._oldrec\n              (fun (f : some j ⟶ Y) (H_2 : Y = none) =>\n                Eq._oldrec\n                  (fun (f : some j ⟶ none) (H_3 : f == hom.term j) =>\n                    Eq._oldrec (arrows j) (wide_cospan._proof_3 j f H_3))\n                  (wide_cospan._proof_4 Y H_2) f)\n              (wide_cospan._proof_5 X j H_1) f)\n          (wide_cospan._proof_6 X) (wide_cospan._proof_7 Y) (wide_cospan._proof_8 X Y f) :=\n  Eq.refl (functor.map (wide_cospan B objs arrows) f)\n\n/-- Every diagram is naturally isomorphic (actually, equal) to a `wide_cospan` -/\ndef diagram_iso_wide_cospan {J : Type v} {C : Type u} [category C] (F : wide_pullback_shape J ⥤ C) :\n    F ≅\n        wide_cospan (functor.obj F none) (fun (j : J) => functor.obj F (some j))\n          fun (j : J) => functor.map F (hom.term j) :=\n  nat_iso.of_components (fun (j : wide_pullback_shape J) => eq_to_iso sorry) sorry\n\nend wide_pullback_shape\n\n\nnamespace wide_pushout_shape\n\n\n/-- The type of arrows for the shape indexing a wide psuhout. -/\ninductive hom {J : Type v} : wide_pushout_shape J → wide_pushout_shape J → Type v where\n| id : (X : wide_pushout_shape J) → hom X X\n| init : (j : J) → hom none (some j)\n\nprotected instance struct {J : Type v} : category_struct (wide_pushout_shape J) := sorry\n\nprotected instance hom.inhabited {J : Type v} : Inhabited (hom none none) :=\n  { default := hom.id none }\n\nprotected instance subsingleton_hom {J : Type v} (j : wide_pushout_shape J)\n    (j' : wide_pushout_shape J) : subsingleton (j ⟶ j') :=\n  sorry\n\nprotected instance category {J : Type v} : small_category (wide_pushout_shape J) := thin_category\n\n@[simp] theorem hom_id {J : Type v} (X : wide_pushout_shape J) : hom.id X = 𝟙 := rfl\n\n/--\nConstruct a functor out of the wide pushout shape given a J-indexed collection of arrows from a\nfixed object.\n-/\n@[simp] theorem wide_span_map {J : Type v} {C : Type u} [category C] (B : C) (objs : J → C)\n    (arrows : (j : J) → B ⟶ objs j) (X : wide_pushout_shape J) (Y : wide_pushout_shape J)\n    (f : X ⟶ Y) :\n    functor.map (wide_span B objs arrows) f =\n        hom.cases_on f\n          (fun (f_1 : wide_pushout_shape J) (H_1 : X = f_1) =>\n            Eq._oldrec\n              (fun (H_2 : Y = X) =>\n                Eq._oldrec\n                  (fun (f : X ⟶ X) (H_3 : f == hom.id X) =>\n                    Eq._oldrec 𝟙 (wide_span._proof_1 X f H_3))\n                  (wide_span._proof_2 X Y H_2) f)\n              H_1)\n          (fun (j : J) (H_1 : X = none) =>\n            Eq._oldrec\n              (fun (f : none ⟶ Y) (H_2 : Y = some j) =>\n                Eq._oldrec\n                  (fun (f : none ⟶ some j) (H_3 : f == hom.init j) =>\n                    Eq._oldrec (arrows j) (wide_span._proof_3 j f H_3))\n                  (wide_span._proof_4 Y j H_2) f)\n              (wide_span._proof_5 X H_1) f)\n          (wide_span._proof_6 X) (wide_span._proof_7 Y) (wide_span._proof_8 X Y f) :=\n  Eq.refl (functor.map (wide_span B objs arrows) f)\n\n/-- Every diagram is naturally isomorphic (actually, equal) to a `wide_span` -/\ndef diagram_iso_wide_span {J : Type v} {C : Type u} [category C] (F : wide_pushout_shape J ⥤ C) :\n    F ≅\n        wide_span (functor.obj F none) (fun (j : J) => functor.obj F (some j))\n          fun (j : J) => functor.map F (hom.init j) :=\n  nat_iso.of_components (fun (j : wide_pushout_shape J) => eq_to_iso sorry) sorry\n\nend wide_pushout_shape\n\n\n/-- `has_wide_pullbacks` represents a choice of wide pullback for every collection of morphisms -/\ndef has_wide_pullbacks (C : Type u) [category C] :=\n  ∀ (J : Type v), has_limits_of_shape (wide_pullback_shape J) C\n\n/-- `has_wide_pushouts` represents a choice of wide pushout for every collection of morphisms -/\ndef has_wide_pushouts (C : Type u) [category C] :=\n  ∀ (J : Type v), has_colimits_of_shape (wide_pushout_shape J) C\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/shapes/wide_pullbacks_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757645879592642, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4658083217919112}}
{"text": "import data.real.basic tactic.linarith\n\ntheorem Q3 (S : set ℝ) (HS : ∃ a : ℝ, a ∈ S) (u : ℝ) (Hu : u ∈ upper_bounds S) :\nis_lub S u ↔ ∀ ε > 0, ∃ s ∈ S, s > u - ε :=\nbegin\n  split,\n  { intro Hu,\n    intros ε Hε,\n    let v := u - ε,\n    have Hv : ¬ (u ≤ v),\n      change ¬ (u ≤ u - ε),\n      linarith,\n    have Hv' : v ∉ upper_bounds S,\n      intro Hv'',\n      apply Hv,\n      apply Hu.2,\n      assumption,\n    change ¬ (v ∈ {x : ℝ | ∀ s, s ∈ S → s ≤ v}) at Hv', -- bug in Lean?\n    change ¬ (v ∈ {x : ℝ | ∀ s, s ∈ S → s ≤ x}) at Hv', -- bug in Lean?\n  --  change ¬ (∀ s : ℝ, s ∈ S → s ≤ v) at Hv',\n  --  rw not_forall at Hv',\n    sorry },\n  { \n    sorry },\nend\n\n", "meta": {"author": "ImperialCollegeLondon", "repo": "M1P1-lean", "sha": "3723468cc50f8bebd00a9811caf25224a578de17", "save_path": "github-repos/lean/ImperialCollegeLondon-M1P1-lean", "path": "github-repos/lean/ImperialCollegeLondon-M1P1-lean/M1P1-lean-3723468cc50f8bebd00a9811caf25224a578de17/src/problem_sheets/sheet_1/sht01Q03.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.903294209307224, "lm_q2_score": 0.5156199157230156, "lm_q1q2_score": 0.46575648407607884}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Scott Morrison\n\n! This file was ported from Lean 3 source module algebraic_geometry.structure_sheaf\n! leanprover-community/mathlib commit d39590fc8728fbf6743249802486f8c91ffe07bc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.AlgebraicGeometry.PrimeSpectrum.Basic\nimport Mathbin.Algebra.Category.Ring.Colimits\nimport Mathbin.Algebra.Category.Ring.Limits\nimport Mathbin.Topology.Sheaves.LocalPredicate\nimport Mathbin.RingTheory.Localization.AtPrime\nimport Mathbin.RingTheory.Subring.Basic\n\n/-!\n# The structure sheaf on `prime_spectrum R`.\n\nWe define the structure sheaf on `Top.of (prime_spectrum R)`, for a commutative ring `R` and prove\nbasic properties about it. We define this as a subsheaf of the sheaf of dependent functions into the\nlocalizations, cut out by the condition that the function must be locally equal to a ratio of\nelements of `R`.\n\nBecause the condition \"is equal to a fraction\" passes to smaller open subsets,\nthe subset of functions satisfying this condition is automatically a subpresheaf.\nBecause the condition \"is locally equal to a fraction\" is local,\nit is also a subsheaf.\n\n(It may be helpful to refer back to `topology.sheaves.sheaf_of_functions`,\nwhere we show that dependent functions into any type family form a sheaf,\nand also `topology.sheaves.local_predicate`, where we characterise the predicates\nwhich pick out sub-presheaves and sub-sheaves of these sheaves.)\n\nWe also set up the ring structure, obtaining\n`structure_sheaf R : sheaf CommRing (Top.of (prime_spectrum R))`.\n\nWe then construct two basic isomorphisms, relating the structure sheaf to the underlying ring `R`.\nFirst, `structure_sheaf.stalk_iso` gives an isomorphism between the stalk of the structure sheaf\nat a point `p` and the localization of `R` at the prime ideal `p`. Second,\n`structure_sheaf.basic_open_iso` gives an isomorphism between the structure sheaf on `basic_open f`\nand the localization of `R` at the submonoid of powers of `f`.\n\n## References\n\n* [Robin Hartshorne, *Algebraic Geometry*][Har77]\n\n\n-/\n\n\nuniverse u\n\nnoncomputable section\n\nvariable (R : Type u) [CommRing R]\n\nopen TopCat\n\nopen TopologicalSpace\n\nopen CategoryTheory\n\nopen Opposite\n\nnamespace AlgebraicGeometry\n\n/-- The prime spectrum, just as a topological space.\n-/\ndef PrimeSpectrum.top : TopCat :=\n  TopCat.of (PrimeSpectrum R)\n#align algebraic_geometry.prime_spectrum.Top AlgebraicGeometry.PrimeSpectrum.top\n\nnamespace StructureSheaf\n\n/-- The type family over `prime_spectrum R` consisting of the localization over each point.\n-/\ndef Localizations (P : PrimeSpectrum.top R) : Type u :=\n  Localization.AtPrime P.asIdeal deriving CommRing, LocalRing\n#align algebraic_geometry.structure_sheaf.localizations AlgebraicGeometry.StructureSheaf.Localizations\n\ninstance (P : PrimeSpectrum.top R) : Inhabited (Localizations R P) :=\n  ⟨1⟩\n\ninstance (U : Opens (PrimeSpectrum.top R)) (x : U) : Algebra R (Localizations R x) :=\n  Localization.algebra\n\ninstance (U : Opens (PrimeSpectrum.top R)) (x : U) :\n    IsLocalization.AtPrime (Localizations R x) (x : PrimeSpectrum.top R).asIdeal :=\n  Localization.isLocalization\n\nvariable {R}\n\n/-- The predicate saying that a dependent function on an open `U` is realised as a fixed fraction\n`r / s` in each of the stalks (which are localizations at various prime ideals).\n-/\ndef IsFraction {U : Opens (PrimeSpectrum.top R)} (f : ∀ x : U, Localizations R x) : Prop :=\n  ∃ r s : R, ∀ x : U, ¬s ∈ x.1.asIdeal ∧ f x * algebraMap _ _ s = algebraMap _ _ r\n#align algebraic_geometry.structure_sheaf.is_fraction AlgebraicGeometry.StructureSheaf.IsFraction\n\ntheorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.top R)} {f : ∀ x : U, Localizations R x}\n    (hf : IsFraction f) :\n    ∃ r s : R,\n      ∀ x : U,\n        ∃ hs : s ∉ x.1.asIdeal,\n          f x =\n            IsLocalization.mk' (Localization.AtPrime _) r\n              (⟨s, hs⟩ : (x : PrimeSpectrum.top R).asIdeal.primeCompl) :=\n  by\n  rcases hf with ⟨r, s, h⟩\n  refine' ⟨r, s, fun x => ⟨(h x).1, (is_localization.mk'_eq_iff_eq_mul.mpr _).symm⟩⟩\n  exact (h x).2.symm\n#align algebraic_geometry.structure_sheaf.is_fraction.eq_mk' AlgebraicGeometry.StructureSheaf.IsFraction.eq_mk'\n\nvariable (R)\n\n/-- The predicate `is_fraction` is \"prelocal\",\nin the sense that if it holds on `U` it holds on any open subset `V` of `U`.\n-/\ndef isFractionPrelocal : PrelocalPredicate (Localizations R)\n    where\n  pred U f := IsFraction f\n  res := by\n    rintro V U i f ⟨r, s, w⟩\n    exact ⟨r, s, fun x => w (i x)⟩\n#align algebraic_geometry.structure_sheaf.is_fraction_prelocal AlgebraicGeometry.StructureSheaf.isFractionPrelocal\n\n/-- We will define the structure sheaf as\nthe subsheaf of all dependent functions in `Π x : U, localizations R x`\nconsisting of those functions which can locally be expressed as a ratio of\n(the images in the localization of) elements of `R`.\n\nQuoting Hartshorne:\n\nFor an open set $U ⊆ Spec A$, we define $𝒪(U)$ to be the set of functions\n$s : U → ⨆_{𝔭 ∈ U} A_𝔭$, such that $s(𝔭) ∈ A_𝔭$ for each $𝔭$,\nand such that $s$ is locally a quotient of elements of $A$:\nto be precise, we require that for each $𝔭 ∈ U$, there is a neighborhood $V$ of $𝔭$,\ncontained in $U$, and elements $a, f ∈ A$, such that for each $𝔮 ∈ V, f ∉ 𝔮$,\nand $s(𝔮) = a/f$ in $A_𝔮$.\n\nNow Hartshorne had the disadvantage of not knowing about dependent functions,\nso we replace his circumlocution about functions into a disjoint union with\n`Π x : U, localizations x`.\n-/\ndef isLocallyFraction : LocalPredicate (Localizations R) :=\n  (isFractionPrelocal R).sheafify\n#align algebraic_geometry.structure_sheaf.is_locally_fraction AlgebraicGeometry.StructureSheaf.isLocallyFraction\n\n@[simp]\ntheorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.top R)} (f : ∀ x : U, Localizations R x) :\n    (isLocallyFraction R).pred f =\n      ∀ x : U,\n        ∃ (V : _)(m : x.1 ∈ V)(i : V ⟶ U),\n          ∃ r s : R,\n            ∀ y : V, ¬s ∈ y.1.asIdeal ∧ f (i y : U) * algebraMap _ _ s = algebraMap _ _ r :=\n  rfl\n#align algebraic_geometry.structure_sheaf.is_locally_fraction_pred AlgebraicGeometry.StructureSheaf.isLocallyFraction_pred\n\n/-- The functions satisfying `is_locally_fraction` form a subring.\n-/\ndef sectionsSubring (U : (Opens (PrimeSpectrum.top R))ᵒᵖ) :\n    Subring (∀ x : unop U, Localizations R x)\n    where\n  carrier := { f | (isLocallyFraction R).pred f }\n  zero_mem' := by\n    refine' fun x => ⟨unop U, x.2, 𝟙 _, 0, 1, fun y => ⟨_, _⟩⟩\n    · rw [← Ideal.ne_top_iff_one]\n      exact y.1.IsPrime.1\n    · simp\n  one_mem' := by\n    refine' fun x => ⟨unop U, x.2, 𝟙 _, 1, 1, fun y => ⟨_, _⟩⟩\n    · rw [← Ideal.ne_top_iff_one]\n      exact y.1.IsPrime.1\n    · simp\n  add_mem' := by\n    intro a b ha hb x\n    rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩\n    rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩\n    refine' ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ra * sb + rb * sa, sa * sb, _⟩\n    intro y\n    rcases wa (opens.inf_le_left _ _ y) with ⟨nma, wa⟩\n    rcases wb (opens.inf_le_right _ _ y) with ⟨nmb, wb⟩\n    fconstructor\n    · intro H\n      cases y.1.IsPrime.mem_or_mem H <;> contradiction\n    · simp only [add_mul, RingHom.map_add, Pi.add_apply, RingHom.map_mul]\n      erw [← wa, ← wb]\n      simp only [mul_assoc]\n      congr 2\n      rw [mul_comm]\n      rfl\n  neg_mem' := by\n    intro a ha x\n    rcases ha x with ⟨V, m, i, r, s, w⟩\n    refine' ⟨V, m, i, -r, s, _⟩\n    intro y\n    rcases w y with ⟨nm, w⟩\n    fconstructor\n    · exact nm\n    · simp only [RingHom.map_neg, Pi.neg_apply]\n      erw [← w]\n      simp only [neg_mul]\n  mul_mem' := by\n    intro a b ha hb x\n    rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩\n    rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩\n    refine' ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ra * rb, sa * sb, _⟩\n    intro y\n    rcases wa (opens.inf_le_left _ _ y) with ⟨nma, wa⟩\n    rcases wb (opens.inf_le_right _ _ y) with ⟨nmb, wb⟩\n    fconstructor\n    · intro H\n      cases y.1.IsPrime.mem_or_mem H <;> contradiction\n    · simp only [Pi.mul_apply, RingHom.map_mul]\n      erw [← wa, ← wb]\n      simp only [mul_left_comm, mul_assoc, mul_comm]\n      rfl\n#align algebraic_geometry.structure_sheaf.sections_subring AlgebraicGeometry.StructureSheaf.sectionsSubring\n\nend StructureSheaf\n\nopen StructureSheaf\n\n/-- The structure sheaf (valued in `Type`, not yet `CommRing`) is the subsheaf consisting of\nfunctions satisfying `is_locally_fraction`.\n-/\ndef structureSheafInType : Sheaf (Type u) (PrimeSpectrum.top R) :=\n  subsheafToTypes (isLocallyFraction R)\n#align algebraic_geometry.structure_sheaf_in_Type AlgebraicGeometry.structureSheafInType\n\ninstance commRingStructureSheafInTypeObj (U : (Opens (PrimeSpectrum.top R))ᵒᵖ) :\n    CommRing ((structureSheafInType R).1.obj U) :=\n  (sectionsSubring R U).toCommRing\n#align algebraic_geometry.comm_ring_structure_sheaf_in_Type_obj AlgebraicGeometry.commRingStructureSheafInTypeObj\n\nopen _Root_.PrimeSpectrum\n\n/-- The structure presheaf, valued in `CommRing`, constructed by dressing up the `Type` valued\nstructure presheaf.\n-/\n@[simps]\ndef structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.top R)\n    where\n  obj U := CommRingCat.of ((structureSheafInType R).1.obj U)\n  map U V i :=\n    { toFun := (structureSheafInType R).1.map i\n      map_zero' := rfl\n      map_add' := fun x y => rfl\n      map_one' := rfl\n      map_mul' := fun x y => rfl }\n#align algebraic_geometry.structure_presheaf_in_CommRing AlgebraicGeometry.structurePresheafInCommRing\n\n/-- Some glue, verifying that that structure presheaf valued in `CommRing` agrees\nwith the `Type` valued structure presheaf.\n-/\ndef structurePresheafCompForget :\n    structurePresheafInCommRing R ⋙ forget CommRingCat ≅ (structureSheafInType R).1 :=\n  NatIso.ofComponents (fun U => Iso.refl _) (by tidy)\n#align algebraic_geometry.structure_presheaf_comp_forget AlgebraicGeometry.structurePresheafCompForget\n\nopen TopCat.Presheaf\n\n/-- The structure sheaf on $Spec R$, valued in `CommRing`.\n\nThis is provided as a bundled `SheafedSpace` as `Spec.SheafedSpace R` later.\n-/\ndef Spec.structureSheaf : Sheaf CommRingCat (PrimeSpectrum.top R) :=\n  ⟨structurePresheafInCommRing R,\n    (-- We check the sheaf condition under `forget CommRing`.\n          isSheaf_iff_isSheaf_comp\n          _ _).mpr\n      (isSheaf_of_iso (structurePresheafCompForget R).symm (structureSheafInType R).cond)⟩\n#align algebraic_geometry.Spec.structure_sheaf AlgebraicGeometry.Spec.structureSheaf\n\nopen Spec (structureSheaf)\n\nnamespace StructureSheaf\n\n@[simp]\ntheorem res_apply (U V : Opens (PrimeSpectrum.top R)) (i : V ⟶ U)\n    (s : (structureSheaf R).1.obj (op U)) (x : V) :\n    ((structureSheaf R).1.map i.op s).1 x = (s.1 (i x) : _) :=\n  rfl\n#align algebraic_geometry.structure_sheaf.res_apply AlgebraicGeometry.StructureSheaf.res_apply\n\n/-\n\nNotation in this comment\n\nX = Spec R\nOX = structure sheaf\n\nIn the following we construct an isomorphism between OX_p and R_p given any point p corresponding\nto a prime ideal in R.\n\nWe do this via 8 steps:\n\n1. def const (f g : R) (V) (hv : V ≤ D_g) : OX(V) [for api]\n2. def to_open (U) : R ⟶ OX(U)\n3. [2] def to_stalk (p : Spec R) : R ⟶ OX_p\n4. [2] def to_basic_open (f : R) : R_f ⟶ OX(D_f)\n5. [3] def localization_to_stalk (p : Spec R) : R_p ⟶ OX_p\n6. def open_to_localization (U) (p) (hp : p ∈ U) : OX(U) ⟶ R_p\n7. [6] def stalk_to_fiber_ring_hom (p : Spec R) : OX_p ⟶ R_p\n8. [5,7] def stalk_iso (p : Spec R) : OX_p ≅ R_p\n\nIn the square brackets we list the dependencies of a construction on the previous steps.\n\n-/\n/-- The section of `structure_sheaf R` on an open `U` sending each `x ∈ U` to the element\n`f/g` in the localization of `R` at `x`. -/\ndef const (f g : R) (U : Opens (PrimeSpectrum.top R))\n    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.top R).asIdeal.primeCompl) :\n    (structureSheaf R).1.obj (op U) :=\n  ⟨fun x => IsLocalization.mk' _ f ⟨g, hu x x.2⟩, fun x =>\n    ⟨U, x.2, 𝟙 _, f, g, fun y => ⟨hu y y.2, IsLocalization.mk'_spec _ _ _⟩⟩⟩\n#align algebraic_geometry.structure_sheaf.const AlgebraicGeometry.StructureSheaf.const\n\n@[simp]\ntheorem const_apply (f g : R) (U : Opens (PrimeSpectrum.top R))\n    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.top R).asIdeal.primeCompl) (x : U) :\n    (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hu x x.2⟩ :=\n  rfl\n#align algebraic_geometry.structure_sheaf.const_apply AlgebraicGeometry.StructureSheaf.const_apply\n\ntheorem const_apply' (f g : R) (U : Opens (PrimeSpectrum.top R))\n    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.top R).asIdeal.primeCompl) (x : U)\n    (hx : g ∈ (asIdeal (x : PrimeSpectrum.top R)).primeCompl) :\n    (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hx⟩ :=\n  rfl\n#align algebraic_geometry.structure_sheaf.const_apply' AlgebraicGeometry.StructureSheaf.const_apply'\n\ntheorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectrum.top R)\n    (hx : x ∈ U) :\n    ∃ (V : Opens (PrimeSpectrum.top R))(hxV : x ∈ V)(i : V ⟶ U)(f g : R)(hg : _),\n      const R f g V hg = (structureSheaf R).1.map i.op s :=\n  let ⟨V, hxV, iVU, f, g, hfg⟩ := s.2 ⟨x, hx⟩\n  ⟨V, hxV, iVU, f, g, fun y hyV => (hfg ⟨y, hyV⟩).1,\n    Subtype.eq <| funext fun y => IsLocalization.mk'_eq_iff_eq_mul.2 <| Eq.symm <| (hfg y).2⟩\n#align algebraic_geometry.structure_sheaf.exists_const AlgebraicGeometry.StructureSheaf.exists_const\n\n@[simp]\ntheorem res_const (f g : R) (U hu V hv i) :\n    (structureSheaf R).1.map i (const R f g U hu) = const R f g V hv :=\n  rfl\n#align algebraic_geometry.structure_sheaf.res_const AlgebraicGeometry.StructureSheaf.res_const\n\ntheorem res_const' (f g : R) (V hv) :\n    (structureSheaf R).1.map (homOfLE hv).op (const R f g (basicOpen g) fun _ => id) =\n      const R f g V hv :=\n  rfl\n#align algebraic_geometry.structure_sheaf.res_const' AlgebraicGeometry.StructureSheaf.res_const'\n\ntheorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=\n  Subtype.eq <|\n    funext fun x =>\n      IsLocalization.mk'_eq_iff_eq_mul.2 <| by\n        erw [RingHom.map_zero, Subtype.val_eq_coe, Subring.coe_zero, Pi.zero_apply,\n          MulZeroClass.zero_mul]\n#align algebraic_geometry.structure_sheaf.const_zero AlgebraicGeometry.StructureSheaf.const_zero\n\ntheorem const_self (f : R) (U hu) : const R f f U hu = 1 :=\n  Subtype.eq <| funext fun x => IsLocalization.mk'_self _ _\n#align algebraic_geometry.structure_sheaf.const_self AlgebraicGeometry.StructureSheaf.const_self\n\ntheorem const_one (U) : (const R 1 1 U fun p _ => Submonoid.one_mem _) = 1 :=\n  const_self R 1 U _\n#align algebraic_geometry.structure_sheaf.const_one AlgebraicGeometry.StructureSheaf.const_one\n\ntheorem const_add (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :\n    const R f₁ g₁ U hu₁ + const R f₂ g₂ U hu₂ =\n      const R (f₁ * g₂ + f₂ * g₁) (g₁ * g₂) U fun x hx =>\n        Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) :=\n  Subtype.eq <|\n    funext fun x =>\n      Eq.symm <| by convert IsLocalization.mk'_add f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩\n#align algebraic_geometry.structure_sheaf.const_add AlgebraicGeometry.StructureSheaf.const_add\n\ntheorem const_mul (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :\n    const R f₁ g₁ U hu₁ * const R f₂ g₂ U hu₂ =\n      const R (f₁ * f₂) (g₁ * g₂) U fun x hx => Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) :=\n  Subtype.eq <|\n    funext fun x =>\n      Eq.symm <| by convert IsLocalization.mk'_mul _ f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩\n#align algebraic_geometry.structure_sheaf.const_mul AlgebraicGeometry.StructureSheaf.const_mul\n\ntheorem const_ext {f₁ f₂ g₁ g₂ : R} {U hu₁ hu₂} (h : f₁ * g₂ = f₂ * g₁) :\n    const R f₁ g₁ U hu₁ = const R f₂ g₂ U hu₂ :=\n  Subtype.eq <|\n    funext fun x =>\n      IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm, Subtype.coe_mk])\n#align algebraic_geometry.structure_sheaf.const_ext AlgebraicGeometry.StructureSheaf.const_ext\n\ntheorem const_congr {f₁ f₂ g₁ g₂ : R} {U hu} (hf : f₁ = f₂) (hg : g₁ = g₂) :\n    const R f₁ g₁ U hu = const R f₂ g₂ U (hg ▸ hu) := by substs hf hg\n#align algebraic_geometry.structure_sheaf.const_congr AlgebraicGeometry.StructureSheaf.const_congr\n\ntheorem const_mul_rev (f g : R) (U hu₁ hu₂) : const R f g U hu₁ * const R g f U hu₂ = 1 := by\n  rw [const_mul, const_congr R rfl (mul_comm g f), const_self]\n#align algebraic_geometry.structure_sheaf.const_mul_rev AlgebraicGeometry.StructureSheaf.const_mul_rev\n\ntheorem const_mul_cancel (f g₁ g₂ : R) (U hu₁ hu₂) :\n    const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ :=\n  by\n  rw [const_mul, const_ext]\n  rw [mul_assoc]\n#align algebraic_geometry.structure_sheaf.const_mul_cancel AlgebraicGeometry.StructureSheaf.const_mul_cancel\n\ntheorem const_mul_cancel' (f g₁ g₂ : R) (U hu₁ hu₂) :\n    const R g₁ g₂ U hu₂ * const R f g₁ U hu₁ = const R f g₂ U hu₂ := by\n  rw [mul_comm, const_mul_cancel]\n#align algebraic_geometry.structure_sheaf.const_mul_cancel' AlgebraicGeometry.StructureSheaf.const_mul_cancel'\n\n/-- The canonical ring homomorphism interpreting an element of `R` as\na section of the structure sheaf. -/\ndef toOpen (U : Opens (PrimeSpectrum.top R)) : CommRingCat.of R ⟶ (structureSheaf R).1.obj (op U)\n    where\n  toFun f :=\n    ⟨fun x => algebraMap R _ f, fun x =>\n      ⟨U, x.2, 𝟙 _, f, 1, fun y =>\n        ⟨(Ideal.ne_top_iff_one _).1 y.1.2.1,\n          by\n          rw [RingHom.map_one, mul_one]\n          rfl⟩⟩⟩\n  map_one' := Subtype.eq <| funext fun x => RingHom.map_one _\n  map_mul' f g := Subtype.eq <| funext fun x => RingHom.map_mul _ _ _\n  map_zero' := Subtype.eq <| funext fun x => RingHom.map_zero _\n  map_add' f g := Subtype.eq <| funext fun x => RingHom.map_add _ _ _\n#align algebraic_geometry.structure_sheaf.to_open AlgebraicGeometry.StructureSheaf.toOpen\n\n@[simp]\ntheorem toOpen_res (U V : Opens (PrimeSpectrum.top R)) (i : V ⟶ U) :\n    toOpen R U ≫ (structureSheaf R).1.map i.op = toOpen R V :=\n  rfl\n#align algebraic_geometry.structure_sheaf.to_open_res AlgebraicGeometry.StructureSheaf.toOpen_res\n\n@[simp]\ntheorem toOpen_apply (U : Opens (PrimeSpectrum.top R)) (f : R) (x : U) :\n    (toOpen R U f).1 x = algebraMap _ _ f :=\n  rfl\n#align algebraic_geometry.structure_sheaf.to_open_apply AlgebraicGeometry.StructureSheaf.toOpen_apply\n\ntheorem toOpen_eq_const (U : Opens (PrimeSpectrum.top R)) (f : R) :\n    toOpen R U f = const R f 1 U fun x _ => (Ideal.ne_top_iff_one _).1 x.2.1 :=\n  Subtype.eq <| funext fun x => Eq.symm <| IsLocalization.mk'_one _ f\n#align algebraic_geometry.structure_sheaf.to_open_eq_const AlgebraicGeometry.StructureSheaf.toOpen_eq_const\n\n/-- The canonical ring homomorphism interpreting an element of `R` as an element of\nthe stalk of `structure_sheaf R` at `x`. -/\ndef toStalk (x : PrimeSpectrum.top R) : CommRingCat.of R ⟶ (structureSheaf R).Presheaf.stalk x :=\n  (toOpen R ⊤ ≫ (structureSheaf R).Presheaf.germ ⟨x, ⟨⟩⟩ : _)\n#align algebraic_geometry.structure_sheaf.to_stalk AlgebraicGeometry.StructureSheaf.toStalk\n\n@[simp]\ntheorem toOpen_germ (U : Opens (PrimeSpectrum.top R)) (x : U) :\n    toOpen R U ≫ (structureSheaf R).Presheaf.germ x = toStalk R x :=\n  by\n  rw [← to_open_res R ⊤ U (hom_of_le le_top : U ⟶ ⊤), category.assoc, presheaf.germ_res]\n  rfl\n#align algebraic_geometry.structure_sheaf.to_open_germ AlgebraicGeometry.StructureSheaf.toOpen_germ\n\n@[simp]\ntheorem germ_toOpen (U : Opens (PrimeSpectrum.top R)) (x : U) (f : R) :\n    (structureSheaf R).Presheaf.germ x (toOpen R U f) = toStalk R x f :=\n  by\n  rw [← to_open_germ]\n  rfl\n#align algebraic_geometry.structure_sheaf.germ_to_open AlgebraicGeometry.StructureSheaf.germ_toOpen\n\ntheorem germ_to_top (x : PrimeSpectrum.top R) (f : R) :\n    (structureSheaf R).Presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens (PrimeSpectrum.top R)))\n        (toOpen R ⊤ f) =\n      toStalk R x f :=\n  rfl\n#align algebraic_geometry.structure_sheaf.germ_to_top AlgebraicGeometry.StructureSheaf.germ_to_top\n\ntheorem isUnit_to_basicOpen_self (f : R) : IsUnit (toOpen R (basicOpen f) f) :=\n  isUnit_of_mul_eq_one _ (const R 1 f (basicOpen f) fun _ => id) <| by\n    rw [to_open_eq_const, const_mul_rev]\n#align algebraic_geometry.structure_sheaf.is_unit_to_basic_open_self AlgebraicGeometry.StructureSheaf.isUnit_to_basicOpen_self\n\ntheorem isUnit_toStalk (x : PrimeSpectrum.top R) (f : x.asIdeal.primeCompl) :\n    IsUnit (toStalk R x (f : R)) :=\n  by\n  erw [← germ_to_open R (basic_open (f : R)) ⟨x, f.2⟩ (f : R)]\n  exact RingHom.isUnit_map _ (is_unit_to_basic_open_self R f)\n#align algebraic_geometry.structure_sheaf.is_unit_to_stalk AlgebraicGeometry.StructureSheaf.isUnit_toStalk\n\n/-- The canonical ring homomorphism from the localization of `R` at `p` to the stalk\nof the structure sheaf at the point `p`. -/\ndef localizationToStalk (x : PrimeSpectrum.top R) :\n    CommRingCat.of (Localization.AtPrime x.asIdeal) ⟶ (structureSheaf R).Presheaf.stalk x :=\n  show Localization.AtPrime x.asIdeal →+* _ from IsLocalization.lift (isUnit_toStalk R x)\n#align algebraic_geometry.structure_sheaf.localization_to_stalk AlgebraicGeometry.StructureSheaf.localizationToStalk\n\n@[simp]\ntheorem localizationToStalk_of (x : PrimeSpectrum.top R) (f : R) :\n    localizationToStalk R x (algebraMap _ (Localization _) f) = toStalk R x f :=\n  IsLocalization.lift_eq _ f\n#align algebraic_geometry.structure_sheaf.localization_to_stalk_of AlgebraicGeometry.StructureSheaf.localizationToStalk_of\n\n@[simp]\ntheorem localizationToStalk_mk' (x : PrimeSpectrum.top R) (f : R) (s : (asIdeal x).primeCompl) :\n    localizationToStalk R x (IsLocalization.mk' _ f s : Localization _) =\n      (structureSheaf R).Presheaf.germ (⟨x, s.2⟩ : basicOpen (s : R))\n        (const R f s (basicOpen s) fun _ => id) :=\n  (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by\n    erw [← germ_to_open R (basic_open s) ⟨x, s.2⟩, ← germ_to_open R (basic_open s) ⟨x, s.2⟩, ←\n      RingHom.map_mul, to_open_eq_const, to_open_eq_const, const_mul_cancel']\n#align algebraic_geometry.structure_sheaf.localization_to_stalk_mk' AlgebraicGeometry.StructureSheaf.localizationToStalk_mk'\n\n/-- The ring homomorphism that takes a section of the structure sheaf of `R` on the open set `U`,\nimplemented as a subtype of dependent functions to localizations at prime ideals, and evaluates\nthe section on the point corresponding to a given prime ideal. -/\ndef openToLocalization (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R) (hx : x ∈ U) :\n    (structureSheaf R).1.obj (op U) ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal)\n    where\n  toFun s := (s.1 ⟨x, hx⟩ : _)\n  map_one' := rfl\n  map_mul' _ _ := rfl\n  map_zero' := rfl\n  map_add' _ _ := rfl\n#align algebraic_geometry.structure_sheaf.open_to_localization AlgebraicGeometry.StructureSheaf.openToLocalization\n\n@[simp]\ntheorem coe_openToLocalization (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R)\n    (hx : x ∈ U) :\n    (openToLocalization R U x hx :\n        (structureSheaf R).1.obj (op U) → Localization.AtPrime x.asIdeal) =\n      fun s => (s.1 ⟨x, hx⟩ : _) :=\n  rfl\n#align algebraic_geometry.structure_sheaf.coe_open_to_localization AlgebraicGeometry.StructureSheaf.coe_openToLocalization\n\ntheorem openToLocalization_apply (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R)\n    (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :\n    openToLocalization R U x hx s = (s.1 ⟨x, hx⟩ : _) :=\n  rfl\n#align algebraic_geometry.structure_sheaf.open_to_localization_apply AlgebraicGeometry.StructureSheaf.openToLocalization_apply\n\n/-- The ring homomorphism from the stalk of the structure sheaf of `R` at a point corresponding to\na prime ideal `p` to the localization of `R` at `p`,\nformed by gluing the `open_to_localization` maps. -/\ndef stalkToFiberRingHom (x : PrimeSpectrum.top R) :\n    (structureSheaf R).Presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=\n  Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1)\n    { X := _\n      ι :=\n        {\n          app := fun U =>\n            openToLocalization R ((OpenNhds.inclusion _).obj (unop U)) x (unop U).2 } }\n#align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom\n\n@[simp]\ntheorem germ_comp_stalkToFiberRingHom (U : Opens (PrimeSpectrum.top R)) (x : U) :\n    (structureSheaf R).Presheaf.germ x ≫ stalkToFiberRingHom R x = openToLocalization R U x x.2 :=\n  Limits.colimit.ι_desc _ _\n#align algebraic_geometry.structure_sheaf.germ_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.germ_comp_stalkToFiberRingHom\n\n@[simp]\ntheorem stalkToFiberRingHom_germ' (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R)\n    (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :\n    stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=\n  RingHom.ext_iff.1 (germ_comp_stalkToFiberRingHom R U ⟨x, hx⟩ : _) s\n#align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ' AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ'\n\n@[simp]\ntheorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.top R)) (x : U)\n    (s : (structureSheaf R).1.obj (op U)) :\n    stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ x s) = s.1 x :=\n  by\n  cases x\n  exact stalk_to_fiber_ring_hom_germ' R U _ _ _\n#align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ\n\n@[simp]\ntheorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.top R) :\n    toStalk R x ≫ stalkToFiberRingHom R x = (algebraMap _ _ : R →+* Localization _) :=\n  by\n  erw [to_stalk, category.assoc, germ_comp_stalk_to_fiber_ring_hom]\n  rfl\n#align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom\n\n@[simp]\ntheorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.top R) (f : R) :\n    stalkToFiberRingHom R x (toStalk R x f) = algebraMap _ (Localization _) f :=\n  RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _\n#align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk\n\n/-- The ring isomorphism between the stalk of the structure sheaf of `R` at a point `p`\ncorresponding to a prime ideal in `R` and the localization of `R` at `p`. -/\n@[simps]\ndef stalkIso (x : PrimeSpectrum.top R) :\n    (structureSheaf R).Presheaf.stalk x ≅ CommRingCat.of (Localization.AtPrime x.asIdeal)\n    where\n  hom := stalkToFiberRingHom R x\n  inv := localizationToStalk R x\n  hom_inv_id' :=\n    (structureSheaf R).Presheaf.stalk_hom_ext fun U hxU =>\n      by\n      ext s; simp only [comp_apply]; rw [id_apply, stalk_to_fiber_ring_hom_germ']\n      obtain ⟨V, hxV, iVU, f, g, hg, hs⟩ := exists_const _ _ s x hxU\n      erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localization_to_stalk_mk']\n      refine' (structure_sheaf R).Presheaf.germ_ext V hxV (hom_of_le hg) iVU _\n      erw [← hs, res_const']\n  inv_hom_id' :=\n    @IsLocalization.ringHom_ext R _ x.asIdeal.primeCompl (Localization.AtPrime x.asIdeal) _ _\n        (Localization.AtPrime x.asIdeal) _ _\n        (RingHom.comp (stalkToFiberRingHom R x) (localizationToStalk R x))\n        (RingHom.id (Localization.AtPrime _)) <|\n      by\n      ext f\n      simp only [RingHom.comp_apply, RingHom.id_apply, localization_to_stalk_of,\n        stalk_to_fiber_ring_hom_to_stalk]\n#align algebraic_geometry.structure_sheaf.stalk_iso AlgebraicGeometry.StructureSheaf.stalkIso\n\ninstance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=\n  IsIso.of_iso (stalkIso R x)\n\ninstance (x : PrimeSpectrum R) : IsIso (localizationToStalk R x) :=\n  IsIso.of_iso (stalkIso R x).symm\n\n@[simp, reassoc.1]\ntheorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.top R) :\n    stalkToFiberRingHom R x ≫ localizationToStalk R x = 𝟙 _ :=\n  (stalkIso R x).hom_inv_id\n#align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_localization_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_localizationToStalk\n\n@[simp, reassoc.1]\ntheorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.top R) :\n    localizationToStalk R x ≫ stalkToFiberRingHom R x = 𝟙 _ :=\n  (stalkIso R x).inv_hom_id\n#align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkToFiberRingHom\n\n/-- The canonical ring homomorphism interpreting `s ∈ R_f` as a section of the structure sheaf\non the basic open defined by `f ∈ R`. -/\ndef toBasicOpen (f : R) : Localization.Away f →+* (structureSheaf R).1.obj (op <| basicOpen f) :=\n  IsLocalization.Away.lift f (isUnit_to_basicOpen_self R f)\n#align algebraic_geometry.structure_sheaf.to_basic_open AlgebraicGeometry.StructureSheaf.toBasicOpen\n\n@[simp]\ntheorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :\n    toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =\n      const R f g (basicOpen s) fun x hx => Submonoid.powers_subset hx g.2 :=\n  (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by\n    rw [to_open_eq_const, to_open_eq_const, const_mul_cancel']\n#align algebraic_geometry.structure_sheaf.to_basic_open_mk' AlgebraicGeometry.StructureSheaf.toBasicOpen_mk'\n\n@[simp]\ntheorem localization_toBasicOpen (f : R) :\n    RingHom.comp (toBasicOpen R f) (algebraMap R (Localization.Away f)) = toOpen R (basicOpen f) :=\n  RingHom.ext fun g => by\n    rw [to_basic_open, IsLocalization.Away.lift, RingHom.comp_apply, IsLocalization.lift_eq]\n#align algebraic_geometry.structure_sheaf.localization_to_basic_open AlgebraicGeometry.StructureSheaf.localization_toBasicOpen\n\n@[simp]\ntheorem toBasicOpen_to_map (s f : R) :\n    toBasicOpen R s (algebraMap R (Localization.Away s) f) =\n      const R f 1 (basicOpen s) fun _ _ => Submonoid.one_mem _ :=\n  (IsLocalization.lift_eq _ _).trans <| toOpen_eq_const _ _ _\n#align algebraic_geometry.structure_sheaf.to_basic_open_to_map AlgebraicGeometry.StructureSheaf.toBasicOpen_to_map\n\n-- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.\ntheorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=\n  by\n  intro s t h_eq\n  obtain ⟨a, ⟨b, hb⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) s\n  obtain ⟨c, ⟨d, hd⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) t\n  simp only [to_basic_open_mk'] at h_eq\n  rw [IsLocalization.eq]\n  -- We know that the fractions `a/b` and `c/d` are equal as sections of the structure sheaf on\n  -- `basic_open f`. We need to show that they agree as elements in the localization of `R` at `f`.\n  -- This amounts showing that `r * (d * a) = r * (b * c)`, for some power `r = f ^ n` of `f`.\n  -- We define `I` as the ideal of *all* elements `r` satisfying the above equation.\n  let I : Ideal R :=\n    { carrier := { r : R | r * (d * a) = r * (b * c) }\n      zero_mem' := by simp only [Set.mem_setOf_eq, MulZeroClass.zero_mul]\n      add_mem' := fun r₁ r₂ hr₁ hr₂ => by\n        dsimp at hr₁ hr₂⊢\n        simp only [add_mul, hr₁, hr₂]\n      smul_mem' := fun r₁ r₂ hr₂ => by\n        dsimp at hr₂⊢\n        simp only [mul_assoc, hr₂] }\n  -- Our claim now reduces to showing that `f` is contained in the radical of `I`\n  suffices f ∈ I.radical by\n    cases' this with n hn\n    exact ⟨⟨f ^ n, n, rfl⟩, hn⟩\n  rw [← vanishing_ideal_zero_locus_eq_radical, mem_vanishing_ideal]\n  intro p hfp\n  contrapose hfp\n  rw [mem_zero_locus, Set.not_subset]\n  have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩\n  rw [const_apply, const_apply, IsLocalization.eq] at this\n  cases' this with r hr\n  exact ⟨r.1, hr, r.2⟩\n#align algebraic_geometry.structure_sheaf.to_basic_open_injective AlgebraicGeometry.StructureSheaf.toBasicOpen_injective\n\n/-\nAuxiliary lemma for surjectivity of `to_basic_open`.\nEvery section can locally be represented on basic opens `basic_opens g` as a fraction `f/g`\n-/\ntheorem locally_const_basicOpen (U : Opens (PrimeSpectrum.top R))\n    (s : (structureSheaf R).1.obj (op U)) (x : U) :\n    ∃ (f g : R)(i : basicOpen g ⟶ U),\n      x.1 ∈ basicOpen g ∧\n        (const R f g (basicOpen g) fun y hy => hy) = (structureSheaf R).1.map i.op s :=\n  by\n  -- First, any section `s` can be represented as a fraction `f/g` on some open neighborhood of `x`\n  -- and we may pass to a `basic_open h`, since these form a basis\n  obtain ⟨V, hxV : x.1 ∈ V.1, iVU, f, g, hVDg : V ≤ basic_open g, s_eq⟩ :=\n    exists_const R U s x.1 x.2\n  obtain ⟨_, ⟨h, rfl⟩, hxDh, hDhV : basic_open h ≤ V⟩ :=\n    is_topological_basis_basic_opens.exists_subset_of_mem_open hxV V.2\n  -- The problem is of course, that `g` and `h` don't need to coincide.\n  -- But, since `basic_open h ≤ basic_open g`, some power of `h` must be a multiple of `g`\n  cases' (basic_open_le_basic_open_iff h g).mp (Set.Subset.trans hDhV hVDg) with n hn\n  -- Actually, we will need a *nonzero* power of `h`.\n  -- This is because we will need the equality `basic_open (h ^ n) = basic_open h`, which only\n  -- holds for a nonzero power `n`. We therefore artificially increase `n` by one.\n  replace hn := Ideal.mul_mem_left (Ideal.span {g}) h hn\n  rw [← pow_succ, Ideal.mem_span_singleton'] at hn\n  cases' hn with c hc\n  have basic_opens_eq := basic_open_pow h (n + 1) (by linarith)\n  have i_basic_open := eq_to_hom basic_opens_eq ≫ hom_of_le hDhV\n  -- We claim that `(f * c) / h ^ (n+1)` is our desired representation\n  use f * c, h ^ (n + 1), i_basic_open ≫ iVU, (basic_opens_eq.symm.le : _) hxDh\n  rw [op_comp, functor.map_comp, comp_apply, ← s_eq, res_const]\n  -- Note that the last rewrite here generated an additional goal, which was a parameter\n  -- of `res_const`. We prove this goal first\n  swap\n  · intro y hy\n    rw [basic_opens_eq] at hy\n    exact (Set.Subset.trans hDhV hVDg : _) hy\n  -- All that is left is a simple calculation\n  apply const_ext\n  rw [mul_assoc f c g, hc]\n#align algebraic_geometry.structure_sheaf.locally_const_basic_open AlgebraicGeometry.StructureSheaf.locally_const_basicOpen\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (i j «expr ∈ » t) -/\n/-\nAuxiliary lemma for surjectivity of `to_basic_open`.\nA local representation of a section `s` as fractions `a i / h i` on finitely many basic opens\n`basic_open (h i)` can be \"normalized\" in such a way that `a i * h j = h i * a j` for all `i, j`\n-/\ntheorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R))\n    (s : (structureSheaf R).1.obj (op U)) {ι : Type _} (t : Finset ι) (a h : ι → R)\n    (iDh : ∀ i : ι, basicOpen (h i) ⟶ U) (h_cover : U ≤ ⨆ i ∈ t, basicOpen (h i))\n    (hs :\n      ∀ i : ι,\n        (const R (a i) (h i) (basicOpen (h i)) fun y hy => hy) =\n          (structureSheaf R).1.map (iDh i).op s) :\n    ∃ (a' h' : ι → R)(iDh' : ∀ i : ι, basicOpen (h' i) ⟶ U),\n      (U ≤ ⨆ i ∈ t, basicOpen (h' i)) ∧\n        (∀ (i) (_ : i ∈ t) (j) (_ : j ∈ t), a' i * h' j = h' i * a' j) ∧\n          ∀ i ∈ t,\n            (structureSheaf R).1.map (iDh' i).op s =\n              const R (a' i) (h' i) (basicOpen (h' i)) fun y hy => hy :=\n  by\n  -- First we show that the fractions `(a i * h j) / (h i * h j)` and `(h i * a j) / (h i * h j)`\n  -- coincide in the localization of `R` at `h i * h j`\n  have fractions_eq :\n    ∀ i j : ι,\n      IsLocalization.mk' (Localization.Away _) (a i * h j) ⟨h i * h j, Submonoid.mem_powers _⟩ =\n        IsLocalization.mk' _ (h i * a j) ⟨h i * h j, Submonoid.mem_powers _⟩ :=\n    by\n    intro i j\n    let D := basic_open (h i * h j)\n    let iDi : D ⟶ basic_open (h i) := hom_of_le (basic_open_mul_le_left _ _)\n    let iDj : D ⟶ basic_open (h j) := hom_of_le (basic_open_mul_le_right _ _)\n    -- Crucially, we need injectivity of `to_basic_open`\n    apply to_basic_open_injective R (h i * h j)\n    rw [to_basic_open_mk', to_basic_open_mk']\n    simp only [[anonymous]]\n    -- Here, both sides of the equation are equal to a restriction of `s`\n    trans\n    convert congr_arg ((structure_sheaf R).1.map iDj.op) (hs j).symm using 1\n    convert congr_arg ((structure_sheaf R).1.map iDi.op) (hs i) using 1\n    swap\n    all_goals rw [res_const]; apply const_ext; ring\n    -- The remaining two goals were generated during the rewrite of `res_const`\n    -- These can be solved immediately\n    exacts[basic_open_mul_le_right _ _, basic_open_mul_le_left _ _]\n  -- From the equality in the localization, we obtain for each `(i,j)` some power `(h i * h j) ^ n`\n  -- which equalizes `a i * h j` and `h i * a j`\n  have exists_power :\n    ∀ i j : ι, ∃ n : ℕ, a i * h j * (h i * h j) ^ n = h i * a j * (h i * h j) ^ n :=\n    by\n    intro i j\n    obtain ⟨⟨c, n, rfl⟩, hc⟩ := is_localization.eq.mp (fractions_eq i j)\n    use n + 1\n    rw [pow_succ]\n    dsimp at hc\n    convert hc using 1 <;> ring\n  let n := fun p : ι × ι => (exists_power p.1 p.2).some\n  have n_spec := fun p : ι × ι => (exists_power p.fst p.snd).choose_spec\n  -- We need one power `(h i * h j) ^ N` that works for *all* pairs `(i,j)`\n  -- Since there are only finitely many indices involved, we can pick the supremum.\n  let N := (t ×ˢ t).sup n\n  have basic_opens_eq : ∀ i : ι, basic_open (h i ^ (N + 1)) = basic_open (h i) := fun i =>\n    basic_open_pow _ _ (by linarith)\n  -- Expanding the fraction `a i / h i` by the power `(h i) ^ N` gives the desired normalization\n  refine'\n    ⟨fun i => a i * h i ^ N, fun i => h i ^ (N + 1), fun i => eq_to_hom (basic_opens_eq i) ≫ iDh i,\n      _, _, _⟩\n  · simpa only [basic_opens_eq] using h_cover\n  · intro i hi j hj\n    -- Here we need to show that our new fractions `a i / h i` satisfy the normalization condition\n    -- Of course, the power `N` we used to expand the fractions might be bigger than the power\n    -- `n (i, j)` which was originally chosen. We denote their difference by `k`\n    have n_le_N : n (i, j) ≤ N := Finset.le_sup (finset.mem_product.mpr ⟨hi, hj⟩)\n    cases' Nat.le.dest n_le_N with k hk\n    simp only [← hk, pow_add, pow_one]\n    -- To accommodate for the difference `k`, we multiply both sides of the equation `n_spec (i, j)`\n      -- by `(h i * h j) ^ k`\n      convert congr_arg (fun z => z * (h i * h j) ^ k) (n_spec (i, j)) using 1 <;>\n      · simp only [n, mul_pow]\n        ring\n  -- Lastly, we need to show that the new fractions still represent our original `s`\n  intro i hi\n  rw [op_comp, functor.map_comp, comp_apply, ← hs, res_const]\n  -- additional goal spit out by `res_const`\n  swap\n  exact (basic_opens_eq i).le\n  apply const_ext\n  rw [pow_succ]\n  ring\n#align algebraic_geometry.structure_sheaf.normalize_finite_fraction_representation AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation\n\nopen Classical\n\nopen BigOperators\n\n-- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.\ntheorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :=\n  by\n  intro s\n  -- In this proof, `basic_open f` will play two distinct roles: Firstly, it is an open set in the\n  -- prime spectrum. Secondly, it is used as an indexing type for various families of objects\n  -- (open sets, ring elements, ...). In order to make the distinction clear, we introduce a type\n  -- alias `ι` that is used whenever we want think of it as an indexing type.\n  let ι : Type u := basic_open f\n  -- First, we pick some cover of basic opens, on which we can represent `s` as a fraction\n  choose a' h' iDh' hxDh' s_eq' using locally_const_basic_open R (basic_open f) s\n  -- Since basic opens are compact, we can pass to a finite subcover\n  obtain ⟨t, ht_cover'⟩ :=\n    (is_compact_basic_open f).elim_finite_subcover (fun i : ι => basic_open (h' i))\n      (fun i => is_open_basic_open) fun x hx => _\n  swap\n  · -- Here, we need to show that our basic opens actually form a cover of `basic_open f`\n    rw [Set.mem_unionᵢ]\n    exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩\n  simp only [← opens.coe_supr, SetLike.coe_subset_coe] at ht_cover'\n  -- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j`\n  obtain ⟨a, h, iDh, ht_cover, ah_ha, s_eq⟩ :=\n    normalize_finite_fraction_representation R (basic_open f) s t a' h' iDh' ht_cover' s_eq'\n  clear s_eq' iDh' hxDh' ht_cover' a' h'\n  simp only [← SetLike.coe_subset_coe, opens.coe_supr] at ht_cover\n  -- Next we show that some power of `f` is a linear combination of the `h i`\n  obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical :=\n    by\n    rw [← vanishing_ideal_zero_locus_eq_radical, zero_locus_span]\n    simp only [basic_open_eq_zero_locus_compl] at ht_cover\n    rw [Set.compl_subset_comm] at ht_cover\n    -- Why doesn't `simp_rw` do this?\n    simp_rw [Set.compl_unionᵢ, compl_compl, ← zero_locus_Union, ← Finset.set_bunionᵢ_coe, ←\n      Set.image_eq_unionᵢ] at ht_cover\n    apply vanishing_ideal_anti_mono ht_cover\n    exact subset_vanishing_ideal_zero_locus {f} (Set.mem_singleton f)\n  replace hn := Ideal.mul_mem_left _ f hn\n  erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn\n  rcases hn with ⟨b, b_supp, hb⟩\n  rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb\n  dsimp at hb\n  -- Finally, we have all the ingredients.\n  -- We claim that our preimage is given by `(∑ (i : ι) in t, b i * a i) / f ^ (n+1)`\n  use\n    IsLocalization.mk' (Localization.Away f) (∑ i : ι in t, b i * a i)\n      (⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _)\n  rw [to_basic_open_mk']\n  -- Since the structure sheaf is a sheaf, we can show the desired equality locally.\n  -- Annoyingly, `sheaf.eq_of_locally_eq` requires an open cover indexed by a *type*, so we need to\n  -- coerce our finset `t` to a type first.\n  let tt := ((t : Set (basic_open f)) : Type u)\n  apply\n    (structure_sheaf R).eq_of_locally_eq' (fun i : tt => basic_open (h i)) (basic_open f)\n      fun i : tt => iDh i\n  · -- This feels a little redundant, since already have `ht_cover` as a hypothesis\n    -- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the\n    -- Union indexed by the type `tt`, so we need some boilerplate to translate one to the other\n    intro x hx\n    erw [TopologicalSpace.Opens.mem_supᵢ]\n    have := ht_cover hx\n    rw [← Finset.set_bunionᵢ_coe, Set.mem_unionᵢ₂] at this\n    rcases this with ⟨i, i_mem, x_mem⟩\n    use i, i_mem\n  rintro ⟨i, hi⟩\n  dsimp\n  change (structure_sheaf R).1.map _ _ = (structure_sheaf R).1.map _ _\n  rw [s_eq i hi, res_const]\n  -- Again, `res_const` spits out an additional goal\n  swap\n  · intro y hy\n    change y ∈ basic_open (f ^ (n + 1))\n    rw [basic_open_pow f (n + 1) (by linarith)]\n    exact (le_of_hom (iDh i) : _) hy\n  -- The rest of the proof is just computation\n  apply const_ext\n  rw [← hb, Finset.sum_mul, Finset.mul_sum]\n  apply Finset.sum_congr rfl\n  intro j hj\n  rw [mul_assoc, ah_ha j hj i hi]\n  ring\n#align algebraic_geometry.structure_sheaf.to_basic_open_surjective AlgebraicGeometry.StructureSheaf.toBasicOpen_surjective\n\ninstance isIso_toBasicOpen (f : R) : IsIso (show CommRingCat.of _ ⟶ _ from toBasicOpen R f) :=\n  haveI : is_iso ((forget CommRingCat).map (show CommRingCat.of _ ⟶ _ from to_basic_open R f)) :=\n    (is_iso_iff_bijective _).mpr ⟨to_basic_open_injective R f, to_basic_open_surjective R f⟩\n  is_iso_of_reflects_iso _ (forget CommRingCat)\n#align algebraic_geometry.structure_sheaf.is_iso_to_basic_open AlgebraicGeometry.StructureSheaf.isIso_toBasicOpen\n\n/-- The ring isomorphism between the structure sheaf on `basic_open f` and the localization of `R`\nat the submonoid of powers of `f`. -/\ndef basicOpenIso (f : R) :\n    (structureSheaf R).1.obj (op (basicOpen f)) ≅ CommRingCat.of (Localization.Away f) :=\n  (asIso (show CommRingCat.of _ ⟶ _ from toBasicOpen R f)).symm\n#align algebraic_geometry.structure_sheaf.basic_open_iso AlgebraicGeometry.StructureSheaf.basicOpenIso\n\ninstance stalkAlgebra (p : PrimeSpectrum R) : Algebra R ((structureSheaf R).Presheaf.stalk p) :=\n  (toStalk R p).toAlgebra\n#align algebraic_geometry.structure_sheaf.stalk_algebra AlgebraicGeometry.StructureSheaf.stalkAlgebra\n\n@[simp]\ntheorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :\n    algebraMap R ((structureSheaf R).Presheaf.stalk p) r = toStalk R p r :=\n  rfl\n#align algebraic_geometry.structure_sheaf.stalk_algebra_map AlgebraicGeometry.StructureSheaf.stalkAlgebra_map\n\n/-- Stalk of the structure sheaf at a prime p as localization of R -/\ninstance IsLocalization.to_stalk (p : PrimeSpectrum R) :\n    IsLocalization.AtPrime ((structureSheaf R).Presheaf.stalk p) p.asIdeal :=\n  by\n  convert(IsLocalization.isLocalization_iff_of_ringEquiv _\n          (stalk_iso R p).symm.commRingIsoToRingEquiv).mp\n      Localization.isLocalization\n  apply Algebra.algebra_ext\n  intro\n  rw [stalk_algebra_map]\n  congr 1\n  erw [iso.eq_comp_inv]\n  exact to_stalk_comp_stalk_to_fiber_ring_hom R p\n#align algebraic_geometry.structure_sheaf.is_localization.to_stalk AlgebraicGeometry.StructureSheaf.IsLocalization.to_stalk\n\ninstance openAlgebra (U : (Opens (PrimeSpectrum R))ᵒᵖ) : Algebra R ((structureSheaf R).val.obj U) :=\n  (toOpen R (unop U)).toAlgebra\n#align algebraic_geometry.structure_sheaf.open_algebra AlgebraicGeometry.StructureSheaf.openAlgebra\n\n@[simp]\ntheorem openAlgebra_map (U : (Opens (PrimeSpectrum R))ᵒᵖ) (r : R) :\n    algebraMap R ((structureSheaf R).val.obj U) r = toOpen R (unop U) r :=\n  rfl\n#align algebraic_geometry.structure_sheaf.open_algebra_map AlgebraicGeometry.StructureSheaf.openAlgebra_map\n\n/-- Sections of the structure sheaf of Spec R on a basic open as localization of R -/\ninstance IsLocalization.to_basicOpen (r : R) :\n    IsLocalization.Away r ((structureSheaf R).val.obj (op <| basicOpen r)) :=\n  by\n  convert(IsLocalization.isLocalization_iff_of_ringEquiv _\n          (basic_open_iso R r).symm.commRingIsoToRingEquiv).mp\n      Localization.isLocalization\n  apply Algebra.algebra_ext\n  intro x\n  congr 1\n  exact (localization_to_basic_open R r).symm\n#align algebraic_geometry.structure_sheaf.is_localization.to_basic_open AlgebraicGeometry.StructureSheaf.IsLocalization.to_basicOpen\n\ninstance to_basicOpen_epi (r : R) : Epi (toOpen R (basicOpen r)) :=\n  ⟨fun S f g h => by\n    refine' IsLocalization.ringHom_ext _ _\n    pick_goal 5\n    exact is_localization.to_basic_open R r\n    exact h⟩\n#align algebraic_geometry.structure_sheaf.to_basic_open_epi AlgebraicGeometry.StructureSheaf.to_basicOpen_epi\n\n@[elementwise]\ntheorem to_global_factors :\n    toOpen R ⊤ =\n      CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R))) ≫\n        toBasicOpen R (1 : R) ≫ (structureSheaf R).1.map (eqToHom basicOpen_one.symm).op :=\n  by\n  rw [← category.assoc]\n  change to_open R ⊤ = (to_basic_open R 1).comp _ ≫ _\n  unfold CommRingCat.ofHom\n  rw [localization_to_basic_open R, to_open_res]\n#align algebraic_geometry.structure_sheaf.to_global_factors AlgebraicGeometry.StructureSheaf.to_global_factors\n\ninstance isIso_to_global : IsIso (toOpen R ⊤) :=\n  by\n  let hom := CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R)))\n  haveI : is_iso hom :=\n    is_iso.of_iso (IsLocalization.atOne R (Localization.Away (1 : R))).toRingEquiv.toCommRingIso\n  rw [to_global_factors R]\n  infer_instance\n#align algebraic_geometry.structure_sheaf.is_iso_to_global AlgebraicGeometry.StructureSheaf.isIso_to_global\n\n/-- The ring isomorphism between the ring `R` and the global sections `Γ(X, 𝒪ₓ)`. -/\n@[simps (config := { rhsMd := Tactic.Transparency.semireducible })]\ndef globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :=\n  asIso (toOpen R ⊤)\n#align algebraic_geometry.structure_sheaf.global_sections_iso AlgebraicGeometry.StructureSheaf.globalSectionsIso\n\n@[simp]\ntheorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ :=\n  rfl\n#align algebraic_geometry.structure_sheaf.global_sections_iso_hom AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom\n\n@[simp, reassoc.1, elementwise]\ntheorem toStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :\n    toStalk R y ≫ (structureSheaf R).Presheaf.stalkSpecializes h = toStalk R x :=\n  by\n  dsimp [to_stalk]\n  simpa [-to_open_germ]\n#align algebraic_geometry.structure_sheaf.to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes\n\n@[simp, reassoc.1, elementwise]\ntheorem localizationToStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R}\n    (h : x ⤳ y) :\n    StructureSheaf.localizationToStalk R y ≫ (structureSheaf R).Presheaf.stalkSpecializes h =\n      CommRingCat.ofHom (PrimeSpectrum.localizationMapOfSpecializes h) ≫\n        StructureSheaf.localizationToStalk R x :=\n  by\n  apply IsLocalization.ringHom_ext y.as_ideal.prime_compl\n  any_goals dsimp; infer_instance\n  erw [RingHom.comp_assoc]\n  conv_rhs => erw [RingHom.comp_assoc]\n  dsimp [CommRingCat.ofHom, localization_to_stalk, PrimeSpectrum.localizationMapOfSpecializes]\n  rw [IsLocalization.lift_comp, IsLocalization.lift_comp, IsLocalization.lift_comp]\n  exact to_stalk_stalk_specializes h\n#align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes\n\n@[simp, reassoc.1, elementwise]\ntheorem stalkSpecializes_stalk_to_fiber {R : Type _} [CommRing R] {x y : PrimeSpectrum R}\n    (h : x ⤳ y) :\n    (structureSheaf R).Presheaf.stalkSpecializes h ≫ StructureSheaf.stalkToFiberRingHom R x =\n      StructureSheaf.stalkToFiberRingHom R y ≫ PrimeSpectrum.localizationMapOfSpecializes h :=\n  by\n  change _ ≫ (structure_sheaf.stalk_iso R x).hom = (structure_sheaf.stalk_iso R y).hom ≫ _\n  rw [← iso.eq_comp_inv, category.assoc, ← iso.inv_comp_eq]\n  exact localization_to_stalk_stalk_specializes h\n#align algebraic_geometry.structure_sheaf.stalk_specializes_stalk_to_fiber AlgebraicGeometry.StructureSheaf.stalkSpecializes_stalk_to_fiber\n\nsection Comap\n\nvariable {R} {S : Type u} [CommRing S] {P : Type u} [CommRing P]\n\n/--\nGiven a ring homomorphism `f : R →+* S`, an open set `U` of the prime spectrum of `R` and an open\nset `V` of the prime spectrum of `S`, such that `V ⊆ (comap f) ⁻¹' U`, we can push a section `s`\non `U` to a section on `V`, by composing with `localization.local_ring_hom _ _ f` from the left and\n`comap f` from the right. Explicitly, if `s` evaluates on `comap f p` to `a / b`, its image on `V`\nevaluates on `p` to `f(a) / f(b)`.\n\nAt the moment, we work with arbitrary dependent functions `s : Π x : U, localizations R x`. Below,\nwe prove the predicate `is_locally_fraction` is preserved by this map, hence it can be extended to\na morphism between the structure sheaves of `R` and `S`.\n-/\ndef comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpectrum.top S))\n    (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (s : ∀ x : U, Localizations R x) (y : V) :\n    Localizations S y :=\n  Localization.localRingHom (PrimeSpectrum.comap f y.1).asIdeal _ f rfl\n    (s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ : _)\n#align algebraic_geometry.structure_sheaf.comap_fun AlgebraicGeometry.StructureSheaf.comapFun\n\ntheorem comapFun_isLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)\n    (s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) :\n    (isLocallyFraction S).toPrelocalPredicate.pred (comapFun f U V hUV s) :=\n  by\n  rintro ⟨p, hpV⟩\n  -- Since `s` is locally fraction, we can find a neighborhood `W` of `prime_spectrum.comap f p`\n  -- in `U`, such that `s = a / b` on `W`, for some ring elements `a, b : R`.\n  rcases hs ⟨PrimeSpectrum.comap f p, hUV hpV⟩ with ⟨W, m, iWU, a, b, h_frac⟩\n  -- We claim that we can write our new section as the fraction `f a / f b` on the neighborhood\n  -- `(comap f) ⁻¹ W ⊓ V` of `p`.\n  refine' ⟨opens.comap (comap f) W ⊓ V, ⟨m, hpV⟩, opens.inf_le_right _ _, f a, f b, _⟩\n  rintro ⟨q, ⟨hqW, hqV⟩⟩\n  specialize h_frac ⟨PrimeSpectrum.comap f q, hqW⟩\n  refine' ⟨h_frac.1, _⟩\n  dsimp only [comap_fun]\n  erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, ← RingHom.map_mul,\n    h_frac.2, Localization.localRingHom_to_map]\n  rfl\n#align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFun_isLocallyFraction\n\n/-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and\n`S` such that `V ⊆ (comap f) ⁻¹ U`, the induced ring homomorphism from the structure sheaf of `R`\nat `U` to the structure sheaf of `S` at `V`.\n\nExplicitly, this map is given as follows: For a point `p : V`, if the section `s` evaluates on `p`\nto the fraction `a / b`, its image on `V` evaluates on `p` to the fraction `f(a) / f(b)`.\n-/\ndef comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpectrum.top S))\n    (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) :\n    (structureSheaf R).1.obj (op U) →+* (structureSheaf S).1.obj (op V)\n    where\n  toFun s := ⟨comapFun f U V hUV s.1, comapFun_isLocallyFraction f U V hUV s.1 s.2⟩\n  map_one' :=\n    Subtype.ext <|\n      funext fun p =>\n        by\n        rw [Subtype.coe_mk, Subtype.val_eq_coe, comap_fun, (sections_subring R (op U)).coe_one,\n          Pi.one_apply, RingHom.map_one]\n        rfl\n  map_zero' :=\n    Subtype.ext <|\n      funext fun p =>\n        by\n        rw [Subtype.coe_mk, Subtype.val_eq_coe, comap_fun, (sections_subring R (op U)).val_zero,\n          Pi.zero_apply, RingHom.map_zero]\n        rfl\n  map_add' s t :=\n    Subtype.ext <|\n      funext fun p =>\n        by\n        rw [Subtype.coe_mk, Subtype.val_eq_coe, comap_fun, (sections_subring R (op U)).val_add,\n          Pi.add_apply, RingHom.map_add]\n        rfl\n  map_mul' s t :=\n    Subtype.ext <|\n      funext fun p =>\n        by\n        rw [Subtype.coe_mk, Subtype.val_eq_coe, comap_fun, (sections_subring R (op U)).coe_mul,\n          Pi.mul_apply, RingHom.map_mul]\n        rfl\n#align algebraic_geometry.structure_sheaf.comap AlgebraicGeometry.StructureSheaf.comap\n\n@[simp]\ntheorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)\n    (s : (structureSheaf R).1.obj (op U)) (p : V) :\n    (comap f U V hUV s).1 p =\n      Localization.localRingHom (PrimeSpectrum.comap f p.1).asIdeal _ f rfl\n        (s.1 ⟨PrimeSpectrum.comap f p.1, hUV p.2⟩ : _) :=\n  rfl\n#align algebraic_geometry.structure_sheaf.comap_apply AlgebraicGeometry.StructureSheaf.comap_apply\n\ntheorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (a b : R)\n    (hb : ∀ x : PrimeSpectrum R, x ∈ U → b ∈ x.asIdeal.primeCompl) :\n    comap f U V hUV (const R a b U hb) =\n      const S (f a) (f b) V fun p hpV => hb (PrimeSpectrum.comap f p) (hUV hpV) :=\n  Subtype.eq <|\n    funext fun p => by\n      rw [comap_apply, const_apply, const_apply]\n      erw [Localization.localRingHom_mk']\n      rfl\n#align algebraic_geometry.structure_sheaf.comap_const AlgebraicGeometry.StructureSheaf.comap_const\n\n/-- For an inclusion `i : V ⟶ U` between open sets of the prime spectrum of `R`, the comap of the\nidentity from OO_X(U) to OO_X(V) equals as the restriction map of the structure sheaf.\n\nThis is a generalization of the fact that, for fixed `U`, the comap of the identity from OO_X(U)\nto OO_X(U) is the identity.\n-/\ntheorem comap_id_eq_map (U V : Opens (PrimeSpectrum.top R)) (iVU : V ⟶ U) :\n    (comap (RingHom.id R) U V fun p hpV => leOfHom iVU <| by rwa [PrimeSpectrum.comap_id]) =\n      (structureSheaf R).1.map iVU.op :=\n  RingHom.ext fun s =>\n    Subtype.eq <|\n      funext fun p => by\n        rw [comap_apply]\n        -- Unfortunately, we cannot use `localization.local_ring_hom_id` here, because\n        -- `prime_spectrum.comap (ring_hom.id R) p` is not *definitionally* equal to `p`. Instead, we use\n        -- that we can write `s` as a fraction `a/b` in a small neighborhood around `p`. Since\n        -- `prime_spectrum.comap (ring_hom.id R) p` equals `p`, it is also contained in the same\n        -- neighborhood, hence `s` equals `a/b` there too.\n        obtain ⟨W, hpW, iWU, h⟩ := s.2 (iVU p)\n        obtain ⟨a, b, h'⟩ := h.eq_mk'\n        obtain ⟨hb₁, s_eq₁⟩ := h' ⟨p, hpW⟩\n        obtain ⟨hb₂, s_eq₂⟩ :=\n          h' ⟨PrimeSpectrum.comap (RingHom.id _) p.1, by rwa [PrimeSpectrum.comap_id]⟩\n        dsimp only at s_eq₁ s_eq₂\n        erw [s_eq₂, Localization.localRingHom_mk', ← s_eq₁, ← res_apply]\n#align algebraic_geometry.structure_sheaf.comap_id_eq_map AlgebraicGeometry.StructureSheaf.comap_id_eq_map\n\n/--\nThe comap of the identity is the identity. In this variant of the lemma, two open subsets `U` and\n`V` are given as arguments, together with a proof that `U = V`. This is be useful when `U` and `V`\nare not definitionally equal.\n-/\ntheorem comap_id (U V : Opens (PrimeSpectrum.top R)) (hUV : U = V) :\n    (comap (RingHom.id R) U V fun p hpV => by rwa [hUV, PrimeSpectrum.comap_id]) =\n      eqToHom (show (structureSheaf R).1.obj (op U) = _ by rw [hUV]) :=\n  by erw [comap_id_eq_map U V (eq_to_hom hUV.symm), eq_to_hom_op, eq_to_hom_map]\n#align algebraic_geometry.structure_sheaf.comap_id AlgebraicGeometry.StructureSheaf.comap_id\n\n@[simp]\ntheorem comap_id' (U : Opens (PrimeSpectrum.top R)) :\n    (comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ :=\n  by\n  rw [comap_id U U rfl]\n  rfl\n#align algebraic_geometry.structure_sheaf.comap_id' AlgebraicGeometry.StructureSheaf.comap_id'\n\ntheorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (W : Opens (PrimeSpectrum.top P))\n    (hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :\n    (comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =\n      (comap g V W hVW).comp (comap f U V hUV) :=\n  RingHom.ext fun s =>\n    Subtype.eq <|\n      funext fun p => by\n        rw [comap_apply]\n        erw [Localization.localRingHom_comp _ (PrimeSpectrum.comap g p.1).asIdeal]\n        -- refl works here, because `prime_spectrum.comap (g.comp f) p` is defeq to\n        -- `prime_spectrum.comap f (prime_spectrum.comap g p)`\n        rfl\n#align algebraic_geometry.structure_sheaf.comap_comp AlgebraicGeometry.StructureSheaf.comap_comp\n\n@[elementwise, reassoc.1]\ntheorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) :\n    (toOpen R U ≫ comap f U (Opens.comap (PrimeSpectrum.comap f) U) fun _ => id) =\n      CommRingCat.ofHom f ≫ toOpen S _ :=\n  RingHom.ext fun s =>\n    Subtype.eq <|\n      funext fun p => by\n        simp_rw [comp_apply, comap_apply, Subtype.val_eq_coe]\n        erw [Localization.localRingHom_to_map]\n        rfl\n#align algebraic_geometry.structure_sheaf.to_open_comp_comap AlgebraicGeometry.StructureSheaf.toOpen_comp_comap\n\nend Comap\n\nend StructureSheaf\n\nend AlgebraicGeometry\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/AlgebraicGeometry/StructureSheaf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.46570683965942783}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Kyle Miller\n-/\n\nimport Mathlib.CategoryTheory.ConcreteCategory.Basic\nimport Mathlib.Util.AddRelatedDecl\nimport Std.Tactic.Lint\n\n/-!\n# Tools to reformulate category-theoretic lemmas in concrete categories\n\n## The `elementwise` attribute\n\nThe `elementwise` attribute generates lemmas for concrete categories from lemmas\nthat equate morphisms in a category.\n\nA sort of inverse to this for the `Type _` category is the `@[higher_order]` attribute.\n\nFor more details, see the documentation attached to the `syntax` declaration.\n\n## Main definitions\n\n- The `@[elementwise]` attribute.\n\n- The ``elementwise_of% h` term elaborator.\n\n## Implementation\n\nThis closely follows the implementation of the `@[reassoc]` attribute, due to Simon Hudon and\nreimplemented by Scott Morrison in Lean 4.\n-/\n\nopen Lean Meta Elab Tactic\nopen Mathlib.Tactic\n\nnamespace Tactic.Elementwise\nopen CategoryTheory\n\nsection theorems\n\ntheorem forget_hom_Type (α β : Type u) (f : α ⟶ β) : (forget (Type u)).map f = f := rfl\n\ntheorem forall_congr_forget_Type (α : Type u) (p : α → Prop) :\n  (∀ (x : ConcreteCategory.Forget.obj α), p x) ↔ ∀ (x : α), p x := Iff.rfl\n\nattribute [local instance] ConcreteCategory.hasCoeToFun ConcreteCategory.hasCoeToSort\n\ntheorem hom_elementwise [Category C] [ConcreteCategory C]\n    {X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x := by rw [h]\n\nend theorems\n\n/-- List of simp lemmas to apply to the elementwise theorem. -/\ndef elementwiseThms : List Name :=\n  [``CategoryTheory.coe_id, ``CategoryTheory.coe_comp, ``CategoryTheory.comp_apply,\n    ``CategoryTheory.id_apply,\n    -- further simplifications if the category is `Type`\n    ``forget_hom_Type, ``forall_congr_forget_Type,\n    -- simp can itself simplify trivial equalities into `true`. Adding this lemma makes it\n    -- easier to detect when this has occurred.\n    ``implies_true]\n\n/--\nGiven an equation `f = g` between morphisms `X ⟶ Y` in a category `C`\n(possibly after a `∀` binder), produce the equation `∀ (x : X), f x = g x` or\n`∀ [ConcreteCategory C] (x : X), f x = g x` as needed (after the `∀` binder), but\nwith compositions fully right associated and identities removed.\n\nReturns the proof of the new theorem along with (optionally) a new level metavariable\nfor the first universe parameter to `ConcreteCategory`.\n\nThe `simpSides` option controles whether to simplify both sides of the equality, for simpNF\npurposes.\n-/\ndef elementwiseExpr (src : Name) (type pf : Expr) (simpSides := true) :\n    MetaM (Expr × Option Level) := do\n  let type := (← instantiateMVars type).cleanupAnnotations\n  forallTelescope type fun fvars type' => do\n    mkHomElementwise type' (mkAppN pf fvars) fun eqPf instConcr? => do\n      -- First simplify using elementwise-specific lemmas\n      let mut eqPf' ← simpType (simpOnlyNames elementwiseThms (config := { decide := false })) eqPf\n      if (← inferType eqPf') == .const ``True [] then\n        throwError \"elementwise lemma for {src} is trivial after applying ConcreteCategory {\"\"\n          }lemmas, which can be caused by how applications are unfolded. {\"\"\n          }Using elementwise is unnecessary.\"\n      if simpSides then\n        let ctx := { ← Simp.Context.mkDefault with config.decide := false }\n        let (ty', eqPf'') ← simpEq (fun e => return (← simp e ctx).1) (← inferType eqPf') eqPf'\n        -- check that it's not a simp-trivial equality:\n        forallTelescope ty' fun _ ty' => do\n          if let some (_, lhs, rhs) := ty'.eq? then\n            if ← Std.Tactic.Lint.isSimpEq lhs rhs then\n              throwError \"applying simp to both sides reduces elementwise lemma for {src} {\"\"\n                }to the trivial equality {ty'}. {\"\"\n                }Either add `nosimp` or remove the `elementwise` attribute.\"\n        eqPf' ← mkExpectedTypeHint eqPf'' ty'\n      if let some (w, instConcr) := instConcr? then\n        return (← Meta.mkLambdaFVars (fvars.push instConcr) eqPf', w)\n      else\n        return (← Meta.mkLambdaFVars fvars eqPf', none)\nwhere\n  /-- Given an equality, extract a `Category` instance from it or raise an error.\n  Returns the name of the category and its instance. -/\n  extractCatInstance (eqTy : Expr) : MetaM (Expr × Expr) := do\n    let some (α, _, _) := eqTy.cleanupAnnotations.eq? | failure\n    let (``Quiver.Hom, #[_, instQuiv, _, _]) := α.getAppFnArgs | failure\n    let (``CategoryTheory.CategoryStruct.toQuiver, #[_, instCS]) := instQuiv.getAppFnArgs | failure\n    let (``CategoryTheory.Category.toCategoryStruct, #[C, instC]) := instCS.getAppFnArgs | failure\n    return (C, instC)\n  mkHomElementwise {α} (eqTy eqPf : Expr) (k : Expr → Option (Level × Expr) → MetaM α) :\n      MetaM α := do\n    let (C, instC) ← try extractCatInstance eqTy catch _ =>\n      throwError \"elementwise expects equality of morphisms in a category\"\n    -- First try being optimistic that there is already a ConcreteCategory instance.\n    if let some eqPf' ← observing? (mkAppM ``hom_elementwise #[eqPf]) then\n      k eqPf' none\n    else\n      -- That failed, so we need to introduce the instance, which takes creating\n      -- a fresh universe level for `ConcreteCategory`'s forgetful functor.\n      let .app (.const ``Category [v, u]) _ ← inferType instC\n        | throwError \"internal error in elementwise\"\n      let w ← mkFreshLevelMVar\n      let cty : Expr := mkApp2 (.const ``ConcreteCategory [w, v, u]) C instC\n      withLocalDecl `inst .instImplicit cty fun cfvar => do\n        let eqPf' ← mkAppM ``hom_elementwise #[eqPf]\n        k eqPf' (some (w, cfvar))\n\n/-- Gives a name based on `baseName` that's not already in the list. -/\nprivate partial def mkUnusedName (names : List Name) (baseName : Name) : Name :=\n  if not (names.contains baseName) then\n    baseName\n  else\n    let rec loop (i : Nat := 0) : Name :=\n      let w := Name.appendIndexAfter baseName i\n      if names.contains w then\n        loop (i + 1)\n      else\n        w\n    loop 1\n\n/-- The `elementwise` attribute can be added to a lemma proving an equation of morphisms, and it\ncreates a new lemma for a `ConcreteCategory` giving an equation with those morphisms applied\nto some value.\n\nSyntax examples:\n- `@[elementwise]`\n- `@[elementwise nosimp]` to not use `simp` on both sides of the generated lemma\n- `@[elementwise (attr := simp)]` to apply the `simp` attribute to both the generated lemma and\n  the original lemma.\n\nExample application of `elementwise`:\n\n```lean\n@[elementwise]\nlemma some_lemma {C : Type _} [Category C]\n    {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (h : X ⟶ Z) (w : ...) : f ≫ g = h := ...\n```\n\nproduces\n\n```lean\nlemma some_lemma_apply {C : Type _} [Category C]\n    {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (h : X ⟶ Z) (w : ...)\n    [ConcreteCategory C] (x : X) : g (f x) = h x := ...\n```\n\nHere `X` is being coerced to a type via `CategoryTheory.ConcreteCategory.hasCoeToSort` and\n`f`, `g`, and `h` are being coerced to functions via `CategoryTheory.ConcreteCategory.hasCoeToFun`.\nFurther, we simplify the type using `CategoryTheory.coe_id : ((𝟙 X) : X → X) x = x` and\n`CategoryTheory.coe_comp : (f ≫ g) x = g (f x)`,\nreplacing morphism composition with function composition.\n\nThe `[ConcreteCategory C]` argument will be omitted if it is possible to synthesize an instance.\n\nThe name of the produced lemma can be specified with `@[elementwise other_lemma_name]`.\nIf `simp` is added first, the generated lemma will also have the `simp` attribute.\n -/\nsyntax (name := elementwise) \"elementwise\"\n  \"nosimp\"? (\"(\" &\"attr\" \":=\" Parser.Term.attrInstance,* \")\")? : attr\n\ninitialize registerBuiltinAttribute {\n  name := `elementwise\n  descr := \"\"\n  applicationTime := .afterCompilation\n  add := fun src ref kind => match ref with\n  | `(attr| elementwise $[nosimp%$nosimp?]? $[(attr := $stx?,*)]?) => MetaM.run' do\n    if (kind != AttributeKind.global) then\n      throwError \"`elementwise` can only be used as a global attribute\"\n    addRelatedDecl src \"_apply\" ref stx? fun type value levels => do\n      let (newValue, level?) ← elementwiseExpr src type value (simpSides := nosimp?.isNone)\n      let newLevels ← if let some level := level? then do\n        let w := mkUnusedName levels `w\n        unless ← isLevelDefEq level (mkLevelParam w) do\n          throwError \"Could not create level parameter for ConcreteCategory instance\"\n        pure <| w :: levels\n      else\n        pure levels\n      pure (newValue, newLevels)\n  | _ => throwUnsupportedSyntax }\n\n/--\n`elementwise_of% h`, where `h` is a proof of an equation `f = g` between\nmorphisms `X ⟶ Y` in a concrete category (possibly after a `∀` binder),\nproduces a proof of equation `∀ (x : X), f x = g x`, but with compositions fully\nright associated and identities removed.\n\nA typical example is using `elementwise_of%` to dynamically generate rewrite lemmas:\n```lean\nexample (M N K : Mon) (f : M ⟶ N) (g : N ⟶ K) (h : M ⟶ K) (w : f ≫ g = h) (m : M) :\n    g (f m) = h m := by rw [elementwise_of% w]\n```\nIn this case, `elementwise_of% w` generates the lemma `∀ (x : M), f (g x) = h x`.\n\nLike the `@[elementwise]` attribute, `elementwise_of%` inserts a `ConcreteCategory`\ninstance argument if it can't synthesize a relevant `ConcreteCategory` instance.\n(Technical note: The forgetful functor's universe variable is instantiated with a\nfresh level metavariable in this case.)\n\nOne difference between `elementwise_of%` and `@[elementwise]` is that `@[elementwise]` by\ndefault applies `simp` to both sides of the generated lemma to get something that is in simp\nnormal form. `elementwise_of%` does not do this.\n-/\nelab \"elementwise_of% \" t:term : term => do\n  let e ← Term.elabTerm t none\n  let (pf, _) ← elementwiseExpr .anonymous (← inferType e) e (simpSides := false)\n  return pf\n\nend Tactic.Elementwise\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Tactic/Elementwise.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4657068372317761}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport control.random\nimport control.uliftable\nimport data.list.big_operators.lemmas\nimport data.list.perm\n\n/-!\n# `gen` Monad\n\nThis monad is used to formulate randomized computations with a parameter\nto specify the desired size of the result.\n\nThis is a port of the Haskell QuickCheck library.\n\n## Main definitions\n  * `gen` monad\n\n## Local notation\n\n * `i .. j` : `Icc i j`, the set of values between `i` and `j` inclusively;\n\n## Tags\n\nrandom testing\n\n## References\n\n  * https://hackage.haskell.org/package/QuickCheck\n\n-/\n\nuniverses u v\n\nnamespace slim_check\n\n/-- Monad to generate random examples to test properties with.\nIt has a `nat` parameter so that the caller can decide on the\nsize of the examples. -/\n@[reducible, derive [monad, is_lawful_monad]]\ndef gen (α : Type u) := reader_t (ulift ℕ) rand α\n\nvariable (α : Type u)\n\nlocal infix ` .. `:41 := set.Icc\n\n/-- Execute a `gen` inside the `io` monad using `i` as the example\nsize and with a fresh random number generator. -/\ndef io.run_gen {α} (x : gen α) (i : ℕ) : io α :=\nio.run_rand (x.run ⟨i⟩)\n\nnamespace gen\n\nsection rand\n\n/-- Lift `random.random` to the `gen` monad. -/\ndef choose_any [random α] : gen α :=\n⟨ λ _, rand.random α ⟩\n\nvariables {α} [preorder α]\n\n/-- Lift `random.random_r` to the `gen` monad. -/\ndef choose [bounded_random α] (x y : α) (p : x ≤ y) : gen (x .. y) :=\n⟨ λ _, rand.random_r x y p ⟩\n\nend rand\n\nopen nat\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat (x y : ℕ) (p : x ≤ y) : gen (x .. y) :=\nchoose x y p\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat' (x y : ℕ) (p : x < y) : gen (set.Ico x y) :=\nhave ∀ i, x < i → i ≤ y → i.pred < y,\n  from λ i h₀ h₁,\n     show i.pred.succ ≤ y,\n     by rwa succ_pred_eq_of_pos; apply lt_of_le_of_lt (nat.zero_le _) h₀,\nsubtype.map pred (λ i (h : x+1 ≤ i ∧ i ≤ y), ⟨le_pred_of_lt h.1, this _ h.1 h.2⟩) <$>\n  choose (x+1) y p\n\nopen nat\n\ninstance : uliftable gen.{u} gen.{v} :=\nreader_t.uliftable' (equiv.ulift.trans equiv.ulift.symm)\n\ninstance : has_orelse gen.{u} :=\n⟨ λ α x y, do\n  b ← uliftable.up $ choose_any bool,\n  if b.down then x else y ⟩\n\nvariable {α}\n\n/-- Get access to the size parameter of the `gen` monad. For\nreasons of universe polymorphism, it is specified in\ncontinuation passing style. -/\ndef sized (cmd : ℕ → gen α) : gen α :=\n⟨ λ ⟨sz⟩, reader_t.run (cmd sz) ⟨sz⟩ ⟩\n\n/-- Apply a function to the size parameter. -/\ndef resize (f : ℕ → ℕ) (cmd : gen α) : gen α :=\n⟨ λ ⟨sz⟩, reader_t.run cmd ⟨f sz⟩ ⟩\n\n/-- Create `n` examples using `cmd`. -/\ndef vector_of : ∀ (n : ℕ) (cmd : gen α), gen (vector α n)\n| 0 _ := return vector.nil\n| (succ n) cmd := vector.cons <$> cmd <*> vector_of n cmd\n\n/-- Create a list of examples using `cmd`. The size is controlled\nby the size parameter of `gen`. -/\ndef list_of (cmd : gen α) : gen (list α) :=\nsized $ λ sz, do\ndo ⟨ n ⟩ ← uliftable.up $ choose_nat 0 (sz + 1) dec_trivial,\n   v ← vector_of n.val cmd,\n   return v.to_list\n\nopen ulift\n\n/-- Given a list of example generators, choose one to create an example. -/\ndef one_of (xs : list (gen α)) (pos : 0 < xs.length) : gen α := do\n⟨⟨n, h, h'⟩⟩ ← uliftable.up $ choose_nat' 0 xs.length pos,\nlist.nth_le xs n h'\n\n/-- Given a list of example generators, choose one to create an example. -/\ndef elements (xs : list α) (pos : 0 < xs.length) : gen α := do\n⟨⟨n,h₀,h₁⟩⟩ ← uliftable.up $ choose_nat' 0 xs.length pos,\npure $ list.nth_le xs n h₁\n\n/--\n`freq_aux xs i _` takes a weighted list of generator and a number meant to select one of the\ngenerators.\n\nIf we consider `freq_aux [(1, gena), (3, genb), (5, genc)] 4 _`, we choose a generator by splitting\nthe interval 1-9 into 1-1, 2-4, 5-9 so that the width of each interval corresponds to one of the\nnumber in the list of generators. Then, we check which interval 4 falls into: it selects `genb`.\n-/\ndef freq_aux : Π (xs : list (ℕ+ × gen α)) i, i < (xs.map (subtype.val ∘ prod.fst)).sum → gen α\n| [] i h := false.elim (nat.not_lt_zero _ h)\n| ((i, x) :: xs) j h :=\n  if h' : j < i then x\n  else freq_aux xs (j - i)\n    (by { rw tsub_lt_iff_right (le_of_not_gt h'),\n      simpa [list.sum_cons, add_comm] using h })\n\n/--\n`freq [(1, gena), (3, genb), (5, genc)] _` will choose one of `gena`, `genb`, `genc` with\nprobabilities proportional to the number accompanying them. In this example, the sum of\nthose numbers is 9, `gena` will be chosen with probability ~1/9, `genb` with ~3/9 (i.e. 1/3)\nand `genc` with probability 5/9.\n-/\ndef freq (xs : list (ℕ+ × gen α)) (pos : 0 < xs.length) : gen α :=\nlet s := (xs.map (subtype.val ∘ prod.fst)).sum in\nhave ha : 1 ≤ s, from\n  (le_trans pos $\n    list.length_map (subtype.val ∘ prod.fst) xs ▸\n      (list.length_le_sum_of_one_le _ (λ i, by { simp, intros, assumption }))),\nhave 0 ≤ s - 1, from le_tsub_of_add_le_right ha,\nuliftable.adapt_up gen.{0} gen.{u} (choose_nat 0 (s-1) this) $ λ i,\nfreq_aux xs i.1 (by rcases i with ⟨i,h₀,h₁⟩; rwa le_tsub_iff_right at h₁; exact ha)\n\n/-- Generate a random permutation of a given list. -/\ndef permutation_of {α : Type u} : Π xs : list α, gen (subtype $ list.perm xs)\n| [] := pure ⟨[], list.perm.nil ⟩\n| (x :: xs) := do\n⟨xs',h⟩ ← permutation_of xs,\n⟨⟨n,_,h'⟩⟩ ← uliftable.up $ choose_nat 0 xs'.length dec_trivial,\npure ⟨list.insert_nth n x xs',\n  list.perm.trans (list.perm.cons _ h)\n    (list.perm_insert_nth _ _ h').symm ⟩\n\nend gen\n\nend slim_check\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/testing/slim_check/gen.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4657068346217256}}
{"text": "import data.nat.basic \n\nopen tactic \nopen tactic.interactive («have»)\n\nexample (a b : ℕ) (h : a = b) : b = a := eq.symm h\n\nmeta def my_symm : tactic unit := \ndo \n  eq1 ← get_local `h,\n  «have» none none ``(eq.symm %%eq1) \n\nexample (a b : ℕ) (h : a = b) : b = a := \nbegin \n  my_symm,\n  exact this\nend \n\nopen interactive (parse)\nopen lean.parser (ident)\n\nmeta def tactic.interactive.my_symm' (eq1 : parse ident) : tactic unit := \ndo \n  eq1 ← get_local eq1,\n  «have» none none ``(eq.symm %%eq1)\n\nexample (a b : ℕ) (h : a = b) : b = a := \nbegin \n  my_symm' h, \n  sorry,\nend", "meta": {"author": "apurvanakade", "repo": "lean-playground", "sha": "2fe58797031ff8a6c29e1a442cbcc7a0ebc9c768", "save_path": "github-repos/lean/apurvanakade-lean-playground", "path": "github-repos/lean/apurvanakade-lean-playground/lean-playground-2fe58797031ff8a6c29e1a442cbcc7a0ebc9c768/src/metaprogramming/get_local.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6370307875894138, "lm_q1q2_score": 0.46570682958402315}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n\n! This file was ported from Lean 3 source module data.set.pointwise.list_of_fn\n! leanprover-community/mathlib commit 327c3c0d9232d80e250dc8f65e7835b82b266ea5\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Pointwise.Basic\nimport Mathbin.Data.List.OfFn\n\n/-!\n# Pointwise operations with lists of sets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves some lemmas about pointwise algebraic operations with lists of sets.\n-/\n\n\nnamespace Set\n\nvariable {F α β γ : Type _}\n\nvariable [Monoid α] {s t : Set α} {a : α} {m n : ℕ}\n\nopen Pointwise\n\n/- warning: set.mem_prod_list_of_fn -> Set.mem_prod_list_ofFn is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Monoid.{u1} α] {n : Nat} {a : α} {s : (Fin n) -> (Set.{u1} α)}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (List.prod.{u1} (Set.{u1} α) (Set.mul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Set.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (List.ofFn.{u1} (Set.{u1} α) n s))) (Exists.{succ u1} (forall (i : Fin n), coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (s i)) (fun (f : forall (i : Fin n), coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (s i)) => Eq.{succ u1} α (List.prod.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (List.ofFn.{u1} α n (fun (i : Fin n) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (s i)) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (s i)) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (s i)) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (s i)) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (s i)))))) (f i)))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Monoid.{u1} α] {n : Nat} {a : α} {s : (Fin n) -> (Set.{u1} α)}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (List.prod.{u1} (Set.{u1} α) (Set.mul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Set.one.{u1} α (Monoid.toOne.{u1} α _inst_1)) (List.ofFn.{u1} (Set.{u1} α) n s))) (Exists.{succ u1} (forall (i : Fin n), Set.Elem.{u1} α (s i)) (fun (f : forall (i : Fin n), Set.Elem.{u1} α (s i)) => Eq.{succ u1} α (List.prod.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (Monoid.toOne.{u1} α _inst_1) (List.ofFn.{u1} α n (fun (i : Fin n) => Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (s i)) (f i)))) a))\nCase conversion may be inaccurate. Consider using '#align set.mem_prod_list_of_fn Set.mem_prod_list_ofFnₓ'. -/\n@[to_additive]\ntheorem mem_prod_list_ofFn {a : α} {s : Fin n → Set α} :\n    a ∈ (List.ofFn s).Prod ↔ ∃ f : ∀ i : Fin n, s i, (List.ofFn fun i => (f i : α)).Prod = a :=\n  by\n  induction' n with n ih generalizing a\n  · simp_rw [List.ofFn_zero, List.prod_nil, Fin.exists_fin_zero_pi, eq_comm, Set.mem_one]\n  ·\n    simp_rw [List.ofFn_succ, List.prod_cons, Fin.exists_fin_succ_pi, Fin.cons_zero, Fin.cons_succ,\n      mem_mul, @ih, exists_and_left, exists_exists_eq_and, SetCoe.exists, Subtype.coe_mk,\n      exists_prop]\n#align set.mem_prod_list_of_fn Set.mem_prod_list_ofFn\n#align set.mem_sum_list_of_fn Set.mem_sum_list_ofFn\n\n/- warning: set.mem_list_prod -> Set.mem_list_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Monoid.{u1} α] {l : List.{u1} (Set.{u1} α)} {a : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (List.prod.{u1} (Set.{u1} α) (Set.mul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Set.one.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) l)) (Exists.{succ u1} (List.{u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s))) (fun (l' : List.{u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s))) => And (Eq.{succ u1} α (List.prod.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) α (fun (x : Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) x)) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) x)) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) x)) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) x)) α (coeSubtype.{succ u1} α (fun (x_1 : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x_1 (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) x)))))) (Sigma.snd.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) x)) l')) a) (Eq.{succ u1} (List.{u1} (Set.{u1} α)) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (Set.{u1} α) (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) l') l)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Monoid.{u1} α] {l : List.{u1} (Set.{u1} α)} {a : α}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (List.prod.{u1} (Set.{u1} α) (Set.mul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1))) (Set.one.{u1} α (Monoid.toOne.{u1} α _inst_1)) l)) (Exists.{succ u1} (List.{u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s))) (fun (l' : List.{u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s))) => And (Eq.{succ u1} α (List.prod.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (Monoid.toOne.{u1} α _inst_1) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s)) α (fun (x : Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s)) => Subtype.val.{succ u1} α (fun (x_1 : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x_1 (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s) x)) (Sigma.snd.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s) x)) l')) a) (Eq.{succ u1} (List.{u1} (Set.{u1} α)) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s)) (Set.{u1} α) (Sigma.fst.{u1, u1} (Set.{u1} α) (fun (s : Set.{u1} α) => Set.Elem.{u1} α s)) l') l)))\nCase conversion may be inaccurate. Consider using '#align set.mem_list_prod Set.mem_list_prodₓ'. -/\n@[to_additive]\ntheorem mem_list_prod {l : List (Set α)} {a : α} :\n    a ∈ l.Prod ↔\n      ∃ l' : List (Σs : Set α, ↥s),\n        List.prod (l'.map fun x => (Sigma.snd x : α)) = a ∧ l'.map Sigma.fst = l :=\n  by\n  induction' l using List.ofFnRec with n f\n  simp_rw [List.exists_iff_exists_tuple, List.map_ofFn, List.ofFn_inj', and_left_comm,\n    exists_and_left, exists_eq_left, heq_iff_eq, Function.comp, mem_prod_list_of_fn]\n  constructor\n  · rintro ⟨fi, rfl⟩\n    exact ⟨fun i => ⟨_, fi i⟩, rfl, rfl⟩\n  · rintro ⟨fi, rfl, rfl⟩\n    exact ⟨fun i => _, rfl⟩\n#align set.mem_list_prod Set.mem_list_prod\n#align set.mem_list_sum Set.mem_list_sum\n\n/- warning: set.mem_pow -> Set.mem_pow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : Monoid.{u1} α] {s : Set.{u1} α} {a : α} {n : Nat}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a (HPow.hPow.{u1, 0, u1} (Set.{u1} α) Nat (Set.{u1} α) (instHPow.{u1, 0} (Set.{u1} α) Nat (Set.NPow.{u1} α (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)))) s n)) (Exists.{succ u1} ((Fin n) -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (fun (f : (Fin n) -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) => Eq.{succ u1} α (List.prod.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (MulOneClass.toHasOne.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (List.ofFn.{u1} α n (fun (i : Fin n) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) α (coeSubtype.{succ u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s))))) (f i)))) a))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : Monoid.{u1} α] {s : Set.{u1} α} {a : α} {n : Nat}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a (HPow.hPow.{u1, 0, u1} (Set.{u1} α) Nat (Set.{u1} α) (instHPow.{u1, 0} (Set.{u1} α) Nat (Set.NPow.{u1} α (Monoid.toOne.{u1} α _inst_1) (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)))) s n)) (Exists.{succ u1} ((Fin n) -> (Set.Elem.{u1} α s)) (fun (f : (Fin n) -> (Set.Elem.{u1} α s)) => Eq.{succ u1} α (List.prod.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α _inst_1)) (Monoid.toOne.{u1} α _inst_1) (List.ofFn.{u1} α n (fun (i : Fin n) => Subtype.val.{succ u1} α (fun (x : α) => Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) (f i)))) a))\nCase conversion may be inaccurate. Consider using '#align set.mem_pow Set.mem_powₓ'. -/\n@[to_additive]\ntheorem mem_pow {a : α} {n : ℕ} :\n    a ∈ s ^ n ↔ ∃ f : Fin n → s, (List.ofFn fun i => (f i : α)).Prod = a := by\n  rw [← mem_prod_list_of_fn, List.ofFn_const, List.prod_replicate]\n#align set.mem_pow Set.mem_pow\n#align set.mem_nsmul Set.mem_nsmul\n\nend Set\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Set/Pointwise/ListOfFn.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110202, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.46570681969101757}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Kenny Lau, Yury Kudryashov\n-/\nimport data.list.pairwise\nimport logic.relation\n\n/-!\n# Relation chain\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides basic results about `list.chain` (definition in `data.list.defs`).\nA list `[a₂, ..., aₙ]` is a `chain` starting at `a₁` with respect to the relation `r` if `r a₁ a₂`\nand `r a₂ a₃` and ... and `r aₙ₋₁ aₙ`. We write it `chain r a₁ [a₂, ..., aₙ]`.\nA graph-specialized version is in development and will hopefully be added under `combinatorics.`\nsometime soon.\n-/\n\nuniverses u v\n\nopen nat\n\nnamespace list\n\nvariables {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : list α} {a b : α}\n\nmk_iff_of_inductive_prop list.chain list.chain_iff\n\ntheorem rel_of_chain_cons {a b : α} {l : list α}\n  (p : chain R a (b :: l)) : R a b :=\n(chain_cons.1 p).1\n\ntheorem chain_of_chain_cons {a b : α} {l : list α}\n  (p : chain R a (b :: l)) : chain R b l :=\n(chain_cons.1 p).2\n\ntheorem chain.imp' {S : α → α → Prop}\n  (HRS : ∀ ⦃a b⦄, R a b → S a b) {a b : α} (Hab : ∀ ⦃c⦄, R a c → S b c)\n  {l : list α} (p : chain R a l) : chain S b l :=\nby induction p with _ a c l r p IH generalizing b; constructor;\n   [exact Hab r, exact IH (@HRS _)]\n\ntheorem chain.imp {S : α → α → Prop}\n  (H : ∀ a b, R a b → S a b) {a : α} {l : list α} (p : chain R a l) : chain S a l :=\np.imp' H (H a)\n\ntheorem chain.iff {S : α → α → Prop}\n  (H : ∀ a b, R a b ↔ S a b) {a : α} {l : list α} : chain R a l ↔ chain S a l :=\n⟨chain.imp (λ a b, (H a b).1), chain.imp (λ a b, (H a b).2)⟩\n\ntheorem chain.iff_mem {a : α} {l : list α} :\n  chain R a l ↔ chain (λ x y, x ∈ a :: l ∧ y ∈ l ∧ R x y) a l :=\n⟨λ p, by induction p with _ a b l r p IH; constructor;\n  [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩,\n   exact IH.imp (λ a b ⟨am, bm, h⟩,\n    ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩)],\n chain.imp (λ a b h, h.2.2)⟩\n\ntheorem chain_singleton {a b : α} : chain R a [b] ↔ R a b :=\nby simp only [chain_cons, chain.nil, and_true]\n\ntheorem chain_split {a b : α} {l₁ l₂ : list α} : chain R a (l₁ ++ b :: l₂) ↔\n  chain R a (l₁ ++ [b]) ∧ chain R b l₂ :=\nby induction l₁ with x l₁ IH generalizing a;\nsimp only [*, nil_append, cons_append, chain.nil, chain_cons, and_true, and_assoc]\n\n@[simp] theorem chain_append_cons_cons {a b c : α} {l₁ l₂ : list α} :\n  chain R a (l₁ ++ b :: c :: l₂) ↔ chain R a (l₁ ++ [b]) ∧ R b c ∧ chain R c l₂ :=\nby rw [chain_split, chain_cons]\n\ntheorem chain_iff_forall₂ :\n  ∀ {a : α} {l : list α}, chain R a l ↔ l = [] ∨ forall₂ R (a :: init l) l\n| a [] := by simp\n| a [b] := by simp [init]\n| a (b :: c :: l) := by simp [@chain_iff_forall₂ b]\n\ntheorem chain_append_singleton_iff_forall₂ :\n  chain R a (l ++ [b]) ↔ forall₂ R (a :: l) (l ++ [b]) :=\nby simp [chain_iff_forall₂, init]\n\ntheorem chain_map (f : β → α) {b : β} {l : list β} :\n  chain R (f b) (map f l) ↔ chain (λ a b : β, R (f a) (f b)) b l :=\nby induction l generalizing b; simp only [map, chain.nil, chain_cons, *]\n\ntheorem chain_of_chain_map {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, S (f a) (f b) → R a b) {a : α} {l : list α}\n  (p : chain S (f a) (map f l)) : chain R a l :=\n((chain_map f).1 p).imp H\n\ntheorem chain_map_of_chain {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, R a b → S (f a) (f b)) {a : α} {l : list α}\n  (p : chain R a l) : chain S (f a) (map f l) :=\n(chain_map f).2 $ p.imp H\n\ntheorem chain_pmap_of_chain {S : β → β → Prop} {p : α → Prop}\n  {f : Π a, p a → β}\n  (H : ∀ a b ha hb, R a b → S (f a ha) (f b hb))\n  {a : α} {l : list α}\n  (hl₁ : chain R a l) (ha : p a) (hl₂ : ∀ a ∈ l, p a) :\n  chain S (f a ha) (list.pmap f l hl₂) :=\nbegin\n  induction l with lh lt l_ih generalizing a,\n  { simp },\n  { simp [H _ _ _ _ (rel_of_chain_cons hl₁), l_ih _ (chain_of_chain_cons hl₁)] }\nend\n\ntheorem chain_of_chain_pmap {S : β → β → Prop} {p : α → Prop}\n  (f : Π a, p a → β) {l : list α} (hl₁ : ∀ a ∈ l, p a)\n  {a : α} (ha : p a) (hl₂ : chain S (f a ha) (list.pmap f l hl₁))\n  (H : ∀ a b ha hb, S (f a ha) (f b hb) → R a b) :\n  chain R a l :=\nbegin\n  induction l with lh lt l_ih generalizing a,\n  { simp },\n  { simp [H _ _ _ _ (rel_of_chain_cons hl₂), l_ih _ _ (chain_of_chain_cons hl₂)] }\nend\n\nprotected lemma pairwise.chain (p : pairwise R (a :: l)) : chain R a l :=\nbegin\n  cases pairwise_cons.1 p with r p', clear p,\n  induction p' with b l r' p IH generalizing a, {exact chain.nil},\n  simp only [chain_cons, forall_mem_cons] at r,\n  exact chain_cons.2 ⟨r.1, IH r'⟩\nend\n\nprotected lemma chain.pairwise [is_trans α R] :\n  ∀ {a : α} {l : list α}, chain R a l → pairwise R (a :: l)\n| a [] chain.nil := pairwise_singleton _ _\n| a _ (@chain.cons _ _ _ b l h hb) := hb.pairwise.cons begin\n    simp only [mem_cons_iff, forall_eq_or_imp, h, true_and],\n    exact λ c hc, trans h (rel_of_pairwise_cons hb.pairwise hc),\n  end\n\ntheorem chain_iff_pairwise [is_trans α R] {a : α} {l : list α} :\n  chain R a l ↔ pairwise R (a :: l) :=\n⟨chain.pairwise, pairwise.chain⟩\n\nprotected lemma chain.sublist [is_trans α R] (hl : l₂.chain R a) (h : l₁ <+ l₂) : l₁.chain R a :=\nby { rw chain_iff_pairwise at ⊢ hl, exact hl.sublist (h.cons_cons a) }\n\nprotected lemma chain.rel [is_trans α R] (hl : l.chain R a) (hb : b ∈ l) : R a b :=\nby { rw chain_iff_pairwise at hl, exact rel_of_pairwise_cons hl hb }\n\ntheorem chain_iff_nth_le {R} : ∀ {a : α} {l : list α},\n  chain R a l ↔ (∀ h : 0 < length l, R a (nth_le l 0 h)) ∧ (∀ i (h : i < length l - 1),\n    R (nth_le l i (lt_of_lt_pred h)) (nth_le l (i+1) (lt_pred_iff.mp h)))\n| a []       := by simp\n| a (b :: t) :=\nbegin\n  rw [chain_cons, chain_iff_nth_le],\n  split,\n  { rintro ⟨R, ⟨h0, h⟩⟩,\n    split,\n    { intro w, exact R },\n    intros i w,\n    cases i,\n    { apply h0 },\n    convert h i _ using 1,\n    simp only [succ_eq_add_one, add_succ_sub_one, add_zero, length, add_lt_add_iff_right] at w,\n    exact lt_pred_iff.mpr w, },\n  rintro ⟨h0, h⟩, split,\n  { apply h0, simp, },\n  split,\n  { apply h 0, },\n  intros i w, convert h (i+1) _ using 1,\n  exact lt_pred_iff.mp w,\nend\n\ntheorem chain'.imp {S : α → α → Prop}\n  (H : ∀ a b, R a b → S a b) {l : list α} (p : chain' R l) : chain' S l :=\nby cases l; [trivial, exact p.imp H]\n\ntheorem chain'.iff {S : α → α → Prop}\n  (H : ∀ a b, R a b ↔ S a b) {l : list α} : chain' R l ↔ chain' S l :=\n⟨chain'.imp (λ a b, (H a b).1), chain'.imp (λ a b, (H a b).2)⟩\n\ntheorem chain'.iff_mem : ∀ {l : list α}, chain' R l ↔ chain' (λ x y, x ∈ l ∧ y ∈ l ∧ R x y) l\n| []       := iff.rfl\n| (x :: l) :=\n  ⟨λ h, (chain.iff_mem.1 h).imp $ λ a b ⟨h₁, h₂, h₃⟩, ⟨h₁, or.inr h₂, h₃⟩,\n   chain'.imp $ λ a b h, h.2.2⟩\n\n@[simp] theorem chain'_nil : chain' R [] := trivial\n\n@[simp] theorem chain'_singleton (a : α) : chain' R [a] := chain.nil\n\n@[simp] theorem chain'_cons {x y l} : chain' R (x :: y :: l) ↔ R x y ∧ chain' R (y :: l) :=\nchain_cons\n\ntheorem chain'_is_infix : ∀ l : list α, chain' (λ x y, [x, y] <:+: l) l\n| [] := chain'_nil\n| [a] := chain'_singleton _\n| (a::b::l) := chain'_cons.2 ⟨⟨[], l, by simp⟩,\n  (chain'_is_infix (b::l)).imp $ λ x y h, h.trans ⟨[a], [], by simp⟩⟩\n\ntheorem chain'_split {a : α} : ∀ {l₁ l₂ : list α}, chain' R (l₁ ++ a :: l₂) ↔\n  chain' R (l₁ ++ [a]) ∧ chain' R (a :: l₂)\n| []        l₂ := (and_iff_right (chain'_singleton a)).symm\n| (b :: l₁) l₂ := chain_split\n\n@[simp] theorem chain'_append_cons_cons {b c : α} {l₁ l₂ : list α} :\n  chain' R (l₁ ++ b :: c :: l₂) ↔ chain' R (l₁ ++ [b]) ∧ R b c ∧ chain' R (c :: l₂) :=\nby rw [chain'_split, chain'_cons]\n\ntheorem chain'_map (f : β → α) {l : list β} :\n  chain' R (map f l) ↔ chain' (λ a b : β, R (f a) (f b)) l :=\nby cases l; [refl, exact chain_map _]\n\ntheorem chain'_of_chain'_map {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, S (f a) (f b) → R a b) {l : list α}\n  (p : chain' S (map f l)) : chain' R l :=\n((chain'_map f).1 p).imp H\n\ntheorem chain'_map_of_chain' {S : β → β → Prop} (f : α → β)\n  (H : ∀ a b : α, R a b → S (f a) (f b)) {l : list α}\n  (p : chain' R l) : chain' S (map f l) :=\n(chain'_map f).2 $ p.imp H\n\ntheorem pairwise.chain' : ∀ {l : list α}, pairwise R l → chain' R l\n| []       _ := trivial\n| (a :: l) h := pairwise.chain h\n\ntheorem chain'_iff_pairwise [is_trans α R] : ∀ {l : list α},\n  chain' R l ↔ pairwise R l\n| []       := (iff_true_intro pairwise.nil).symm\n| (a :: l) := chain_iff_pairwise\n\nprotected lemma chain'.sublist [is_trans α R] (hl : l₂.chain' R) (h : l₁ <+ l₂) : l₁.chain' R :=\nby { rw chain'_iff_pairwise at ⊢ hl, exact hl.sublist h }\n\ntheorem chain'.cons {x y l} (h₁ : R x y) (h₂ : chain' R (y :: l)) :\n  chain' R (x :: y :: l) :=\nchain'_cons.2 ⟨h₁, h₂⟩\n\ntheorem chain'.tail : ∀ {l} (h : chain' R l), chain' R l.tail\n| []            _ := trivial\n| [x]           _ := trivial\n| (x :: y :: l) h := (chain'_cons.mp h).right\n\ntheorem chain'.rel_head {x y l} (h : chain' R (x :: y :: l)) : R x y :=\nrel_of_chain_cons h\n\ntheorem chain'.rel_head' {x l} (h : chain' R (x :: l)) ⦃y⦄ (hy : y ∈ head' l) : R x y :=\nby { rw ← cons_head'_tail hy at h, exact h.rel_head }\n\ntheorem chain'.cons' {x} :\n  ∀ {l : list α},  chain' R l → (∀ y ∈ l.head', R x y) → chain' R (x :: l)\n| []       _  _ := chain'_singleton x\n| (a :: l) hl H := hl.cons $ H _ rfl\n\ntheorem chain'_cons' {x l} : chain' R (x :: l) ↔ (∀ y ∈ head' l, R x y) ∧ chain' R l :=\n⟨λ h, ⟨h.rel_head', h.tail⟩, λ ⟨h₁, h₂⟩, h₂.cons' h₁⟩\n\n\n\ntheorem chain'.append (h₁ : chain' R l₁) (h₂ : chain' R l₂)\n  (h : ∀ (x ∈ l₁.last') (y ∈ l₂.head'), R x y) :\n  chain' R (l₁ ++ l₂) :=\nchain'_append.2 ⟨h₁, h₂, h⟩\n\ntheorem chain'.left_of_append (h : chain' R (l₁ ++ l₂)) : chain' R l₁ := (chain'_append.1 h).1\ntheorem chain'.right_of_append (h : chain' R (l₁ ++ l₂)) : chain' R l₂ := (chain'_append.1 h).2.1\n\ntheorem chain'.infix (h : chain' R l) (h' : l₁ <:+: l) : chain' R l₁ :=\nby { rcases h' with ⟨l₂, l₃, rfl⟩, exact h.left_of_append.right_of_append }\n\ntheorem chain'.suffix (h : chain' R l) (h' : l₁ <:+ l) : chain' R l₁ := h.infix h'.is_infix\ntheorem chain'.prefix (h : chain' R l) (h' : l₁ <+: l) : chain' R l₁ := h.infix h'.is_infix\ntheorem chain'.drop (h : chain' R l) (n : ℕ) : chain' R (drop n l) := h.suffix (drop_suffix _ _)\ntheorem chain'.init (h : chain' R l) : chain' R l.init := h.prefix l.init_prefix\ntheorem chain'.take (h : chain' R l) (n : ℕ) : chain' R (take n l) := h.prefix (take_prefix _ _)\n\ntheorem chain'_pair {x y} : chain' R [x, y] ↔ R x y :=\nby simp only [chain'_singleton, chain'_cons, and_true]\n\ntheorem chain'.imp_head {x y} (h : ∀ {z}, R x z → R y z) {l} (hl : chain' R (x :: l)) :\n  chain' R (y :: l) :=\nhl.tail.cons' $ λ z hz, h $ hl.rel_head' hz\n\ntheorem chain'_reverse : ∀ {l}, chain' R (reverse l) ↔ chain' (flip R) l\n| []            := iff.rfl\n| [a]           := by simp only [chain'_singleton, reverse_singleton]\n| (a :: b :: l) := by rw [chain'_cons, reverse_cons, reverse_cons, append_assoc, cons_append,\n    nil_append, chain'_split, ← reverse_cons, @chain'_reverse (b :: l), and_comm, chain'_pair, flip]\n\ntheorem chain'_iff_nth_le {R} : ∀ {l : list α},\n  chain' R l ↔ ∀ i (h : i < length l - 1),\n    R (nth_le l i (lt_of_lt_pred h)) (nth_le l (i+1) (lt_pred_iff.mp h))\n| []            := by simp\n| [a]           := by simp\n| (a :: b :: t) :=\nbegin\n  rw [← and_forall_succ, chain'_cons, chain'_iff_nth_le],\n  simp only [length, nth_le, add_tsub_cancel_right, add_lt_add_iff_right, tsub_pos_iff_lt,\n    one_lt_succ_succ, true_implies_iff],\n  refl,\nend\n\n/-- If `l₁ l₂` and `l₃` are lists and `l₁ ++ l₂` and `l₂ ++ l₃` both satisfy\n  `chain' R`, then so does `l₁ ++ l₂ ++ l₃` provided `l₂ ≠ []` -/\nlemma chain'.append_overlap {l₁ l₂ l₃ : list α}\n  (h₁ : chain' R (l₁ ++ l₂)) (h₂ : chain' R (l₂ ++ l₃)) (hn : l₂ ≠ []) :\n  chain' R (l₁ ++ l₂ ++ l₃) :=\nh₁.append h₂.right_of_append $\n  by simpa only [last'_append_of_ne_nil _ hn] using (chain'_append.1 h₂).2.2\n\n/--\nIf `a` and `b` are related by the reflexive transitive closure of `r`, then there is a `r`-chain\nstarting from `a` and ending on `b`.\nThe converse of `relation_refl_trans_gen_of_exists_chain`.\n-/\nlemma exists_chain_of_relation_refl_trans_gen (h : relation.refl_trans_gen r a b) :\n  ∃ l, chain r a l ∧ last (a :: l) (cons_ne_nil _ _) = b :=\nbegin\n  apply relation.refl_trans_gen.head_induction_on h,\n  { exact ⟨[], chain.nil, rfl⟩ },\n  { intros c d e t ih,\n    obtain ⟨l, hl₁, hl₂⟩ := ih,\n    refine ⟨d :: l, chain.cons e hl₁, _⟩,\n    rwa last_cons_cons }\nend\n\n/--\nGiven a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then\nthe predicate is true everywhere in the chain and at `a`.\nThat is, we can propagate the predicate up the chain.\n-/\nlemma chain.induction (p : α → Prop)\n  (l : list α) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : ∀ i ∈ a :: l, p i :=\nbegin\n  induction l generalizing a,\n  { cases hb,\n    simp [final] },\n  { rw chain_cons at h,\n    rintro _ (rfl | _),\n    apply carries h.1 (l_ih h.2 hb _ (or.inl rfl)),\n    apply l_ih h.2 hb _ H }\nend\n\n/--\nGiven a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then\nthe predicate is true at `a`.\nThat is, we can propagate the predicate all the way up the chain.\n-/\n@[elab_as_eliminator]\nlemma chain.induction_head (p : α → Prop)\n  (l : list α) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : p a :=\n(chain.induction p l h hb carries final) _ (mem_cons_self _ _)\n\n/--\nIf there is an `r`-chain starting from `a` and ending at `b`, then `a` and `b` are related by the\nreflexive transitive closure of `r`. The converse of `exists_chain_of_relation_refl_trans_gen`.\n-/\nlemma relation_refl_trans_gen_of_exists_chain (l) (hl₁ : chain r a l)\n  (hl₂ : last (a :: l) (cons_ne_nil _ _) = b) :\n  relation.refl_trans_gen r a b :=\nchain.induction_head _ l hl₁ hl₂ (λ x y, relation.refl_trans_gen.head) relation.refl_trans_gen.refl\n\nend list\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/list/chain.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.4656851657095556}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau\n-/\nimport algebra.module.linear_map\nimport algebra.big_operators.basic\nimport data.set.finite\nimport group_theory.submonoid.membership\nimport group_theory.group_action.big_operators\nimport data.finset.preimage\n\n/-!\n# Dependent functions with finite support\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nFor a non-dependent version see `data/finsupp.lean`.\n\n## Notation\n\nThis file introduces the notation `Π₀ a, β a` as notation for `dfinsupp β`, mirroring the `α →₀ β`\nnotation used for `finsupp`. This works for nested binders too, with `Π₀ a b, γ a b` as notation\nfor `dfinsupp (λ a, dfinsupp (γ a))`.\n\n## Implementation notes\n\nThe support is internally represented (in the primed `dfinsupp.support'`) as a `multiset` that\nrepresents a superset of the true support of the function, quotiented by the always-true relation so\nthat this does not impact equality. This approach has computational benefits over storing a\n`finset`; it allows us to add together two finitely-supported functions (`dfinsupp.has_add`) without\nhaving to evaluate the resulting function to recompute its support (which would required\ndecidability of `b = 0` for `b : β i`).\n\nThe true support of the function can still be recovered with `dfinsupp.support`; but these\ndecidability obligations are now postponed to when the support is actually needed. As a consequence,\nthere are two ways to sum a `dfinsupp`: with `dfinsupp.sum` which works over an arbitrary function\nbut requires recomputation of the support and therefore a `decidable` argument; and with\n`dfinsupp.sum_add_hom` which requires an additive morphism, using its properties to show that\nsumming over a superset of the support is sufficient.\n\n`finsupp` takes an altogether different approach here; it uses `classical.decidable` and declares\n`finsupp.has_add` as noncomputable. This design difference is independent of the fact that\n`dfinsupp` is dependently-typed and `finsupp` is not; in future, we may want to align these two\ndefinitions, or introduce two more definitions for the other combinations of decisions.\n-/\n\nuniverses u u₁ u₂ v v₁ v₂ v₃ w x y l\n\nopen_locale big_operators\n\nvariables {ι : Type u} {γ : Type w} {β : ι → Type v} {β₁ : ι → Type v₁} {β₂ : ι → Type v₂}\n\n\nvariable (β)\n/-- A dependent function `Π i, β i` with finite support, with notation `Π₀ i, β i`.\n\nNote that `dfinsupp.support` is the preferred API for accessing the support of the function,\n`dfinsupp.support'` is a implementation detail that aids computability; see the implementation\nnotes in this file for more information. -/\nstructure dfinsupp [Π i, has_zero (β i)] : Type (max u v) :=\nmk' ::\n(to_fun : Π i, β i)\n(support' : trunc {s : multiset ι // ∀ i, i ∈ s ∨ to_fun i = 0})\nvariable {β}\n\nnotation `Π₀` binders `, ` r:(scoped f, dfinsupp f) := r\ninfix ` →ₚ `:25 := dfinsupp\n\nnamespace dfinsupp\n\nsection basic\nvariables [Π i, has_zero (β i)] [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n\ninstance fun_like : fun_like (Π₀ i, β i) ι β :=\n⟨λ f, f.to_fun, λ ⟨f₁, s₁⟩ ⟨f₂, s₁⟩ (h : f₁= f₂), by { subst h, congr'} ⟩\n\n/-- Helper instance for when there are too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (Π₀ i, β i) (λ _, Π i, β i) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe (f : Π₀ i, β i) : f.to_fun = f := rfl\n\n@[ext] lemma ext {f g : Π₀ i, β i} (h : ∀ i, f i = g i) : f = g := fun_like.ext _ _ h\n/-- Deprecated. Use `fun_like.ext_iff` instead. -/\nlemma ext_iff {f g : Π₀ i, β i} : f = g ↔ ∀ i, f i = g i := fun_like.ext_iff\n/-- Deprecated. Use `fun_like.coe_injective` instead. -/\nlemma coe_fn_injective : @function.injective (Π₀ i, β i) (Π i, β i) coe_fn := fun_like.coe_injective\n\ninstance : has_zero (Π₀ i, β i) := ⟨⟨0, trunc.mk $ ⟨∅, λ i, or.inr rfl⟩⟩⟩\ninstance : inhabited (Π₀ i, β i) := ⟨0⟩\n\n@[simp]\nlemma coe_mk' (f : Π i, β i) (s) : ⇑(⟨f, s⟩ : Π₀ i, β i) = f := rfl\n\n@[simp] lemma coe_zero : ⇑(0 : Π₀ i, β i) = 0 := rfl\nlemma zero_apply (i : ι) : (0 : Π₀ i, β i) i = 0 := rfl\n\n/-- The composition of `f : β₁ → β₂` and `g : Π₀ i, β₁ i` is\n  `map_range f hf g : Π₀ i, β₂ i`, well defined when `f 0 = 0`.\n\nThis preserves the structure on `f`, and exists in various bundled forms for when `f` is itself\nbundled:\n\n* `dfinsupp.map_range.add_monoid_hom`\n* `dfinsupp.map_range.add_equiv`\n* `dfinsupp.map_range.linear_map`\n* `dfinsupp.map_range.linear_equiv`\n-/\ndef map_range (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (x : Π₀ i, β₁ i) : Π₀ i, β₂ i :=\n⟨λ i, f i (x i), x.support'.map $ λ s, ⟨s, λ i, (s.2 i).imp_right $ λ h : x i = 0, h.symm ▸ hf i⟩⟩\n\n@[simp] lemma map_range_apply\n  (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (g : Π₀ i, β₁ i) (i : ι) :\n  map_range f hf g i = f i (g i) :=\nrfl\n\n@[simp] lemma map_range_id (h : ∀ i, id (0 : β₁ i) = 0 := λ i, rfl) (g : Π₀ (i : ι), β₁ i) :\n  map_range (λ i, (id : β₁ i → β₁ i)) h g = g :=\nby { ext, refl }\n\nlemma map_range_comp (f : Π i, β₁ i → β₂ i) (f₂ : Π i, β i → β₁ i)\n  (hf : ∀ i, f i 0 = 0) (hf₂ : ∀ i, f₂ i 0 = 0) (h : ∀ i, (f i ∘ f₂ i) 0 = 0)\n  (g : Π₀ (i : ι), β i) :\n  map_range (λ i, f i ∘ f₂ i) h g = map_range f hf (map_range f₂ hf₂ g) :=\nby { ext, simp only [map_range_apply] }\n\n@[simp] lemma map_range_zero (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) :\n  map_range f hf (0 : Π₀ i, β₁ i) = 0 :=\nby { ext, simp only [map_range_apply, coe_zero, pi.zero_apply, hf] }\n\n/-- Let `f i` be a binary operation `β₁ i → β₂ i → β i` such that `f i 0 0 = 0`.\nThen `zip_with f hf` is a binary operation `Π₀ i, β₁ i → Π₀ i, β₂ i → Π₀ i, β i`. -/\ndef zip_with (f : Π i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0)\n  (x : Π₀ i, β₁ i) (y : Π₀ i, β₂ i) : (Π₀ i, β i) :=\n⟨λ i, f i (x i) (y i), begin\n  refine x.support'.bind (λ xs, _),\n  refine y.support'.map (λ ys, _),\n  refine ⟨xs + ys, λ i, _⟩,\n  obtain h1 | (h1 : x i = 0) := xs.prop i,\n  { left, rw multiset.mem_add, left, exact h1 },\n  obtain h2 | (h2 : y i = 0) := ys.prop i,\n  { left, rw multiset.mem_add, right, exact h2 },\n  right, rw [h1, h2, hf]\nend⟩\n\n@[simp] lemma zip_with_apply\n  (f : Π i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0) (g₁ : Π₀ i, β₁ i) (g₂ : Π₀ i, β₂ i) (i : ι) :\n  zip_with f hf g₁ g₂ i = f i (g₁ i) (g₂ i) :=\nrfl\n\nsection piecewise\nvariables (x y : Π₀ i, β i) (s : set ι) [Π i, decidable (i ∈ s)]\n\n/-- `x.piecewise y s` is the finitely supported function equal to `x` on the set `s`,\n  and to `y` on its complement. -/\ndef piecewise : Π₀ i, β i := zip_with (λ i x y, if i ∈ s then x else y) (λ _, if_t_t _ 0) x y\n\nlemma piecewise_apply (i : ι) : x.piecewise y s i = if i ∈ s then x i else y i :=\nzip_with_apply _ _ x y i\n\n@[simp, norm_cast] lemma coe_piecewise : ⇑(x.piecewise y s) = s.piecewise x y :=\nby { ext, apply piecewise_apply }\n\nend piecewise\n\nend basic\n\nsection algebra\n\ninstance [Π i, add_zero_class (β i)] : has_add (Π₀ i, β i) :=\n⟨zip_with (λ _, (+)) (λ _, add_zero 0)⟩\n\nlemma add_apply [Π i, add_zero_class (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) :\n  (g₁ + g₂) i = g₁ i + g₂ i :=\nrfl\n\n@[simp] lemma coe_add [Π i, add_zero_class (β i)] (g₁ g₂ : Π₀ i, β i) :\n  ⇑(g₁ + g₂) = g₁ + g₂ :=\nrfl\n\ninstance [Π i, add_zero_class (β i)] : add_zero_class (Π₀ i, β i) :=\nfun_like.coe_injective.add_zero_class _ coe_zero coe_add\n\n/-- Note the general `dfinsupp.has_smul` instance doesn't apply as `ℕ` is not distributive\nunless `β i`'s addition is commutative. -/\ninstance has_nat_scalar [Π i, add_monoid (β i)] : has_smul ℕ (Π₀ i, β i) :=\n⟨λc v, v.map_range (λ _, (•) c) (λ _, nsmul_zero _)⟩\n\nlemma nsmul_apply [Π i, add_monoid (β i)] (b : ℕ) (v : Π₀ i, β i) (i : ι) :\n  (b • v) i = b • (v i) :=\nrfl\n\n@[simp] lemma coe_nsmul [Π i, add_monoid (β i)] (b : ℕ) (v : Π₀ i, β i) : ⇑(b • v) = b • v :=\nrfl\n\ninstance [Π i, add_monoid (β i)] : add_monoid (Π₀ i, β i) :=\nfun_like.coe_injective.add_monoid _ coe_zero coe_add (λ _ _, coe_nsmul _ _)\n\n/-- Coercion from a `dfinsupp` to a pi type is an `add_monoid_hom`. -/\ndef coe_fn_add_monoid_hom [Π i, add_zero_class (β i)] : (Π₀ i, β i) →+ (Π i, β i) :=\n{ to_fun := coe_fn, map_zero' := coe_zero, map_add' := coe_add }\n\n/-- Evaluation at a point is an `add_monoid_hom`. This is the finitely-supported version of\n`pi.eval_add_monoid_hom`. -/\ndef eval_add_monoid_hom [Π i, add_zero_class (β i)] (i : ι) : (Π₀ i, β i) →+ β i :=\n(pi.eval_add_monoid_hom β i).comp coe_fn_add_monoid_hom\n\ninstance [Π i, add_comm_monoid (β i)] : add_comm_monoid (Π₀ i, β i) :=\nfun_like.coe_injective.add_comm_monoid _ coe_zero coe_add (λ _ _, coe_nsmul _ _)\n\n@[simp] lemma coe_finset_sum {α} [Π i, add_comm_monoid (β i)] (s : finset α) (g : α → Π₀ i, β i) :\n  ⇑(∑ a in s, g a) = ∑ a in s, g a :=\n(coe_fn_add_monoid_hom : _ →+ (Π i, β i)).map_sum g s\n\n@[simp] lemma finset_sum_apply {α} [Π i, add_comm_monoid (β i)] (s : finset α) (g : α → Π₀ i, β i)\n  (i : ι) :\n  (∑ a in s, g a) i = ∑ a in s, g a i :=\n(eval_add_monoid_hom i : _ →+ β i).map_sum g s\n\ninstance [Π i, add_group (β i)] : has_neg (Π₀ i, β i) :=\n⟨λ f, f.map_range (λ _, has_neg.neg) (λ _, neg_zero)⟩\n\nlemma neg_apply [Π i, add_group (β i)] (g : Π₀ i, β i) (i : ι) : (- g) i = - g i :=\nrfl\n\n@[simp] lemma coe_neg [Π i, add_group (β i)] (g : Π₀ i, β i) : ⇑(- g) = - g :=\nrfl\n\ninstance [Π i, add_group (β i)] : has_sub (Π₀ i, β i) :=\n⟨zip_with (λ _, has_sub.sub) (λ _, sub_zero 0)⟩\n\nlemma sub_apply [Π i, add_group (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) :\n  (g₁ - g₂) i = g₁ i - g₂ i :=\nrfl\n\n@[simp] lemma coe_sub [Π i, add_group (β i)] (g₁ g₂ : Π₀ i, β i) :\n  ⇑(g₁ - g₂) = g₁ - g₂ :=\nrfl\n\n/-- Note the general `dfinsupp.has_smul` instance doesn't apply as `ℤ` is not distributive\nunless `β i`'s addition is commutative. -/\ninstance has_int_scalar [Π i, add_group (β i)] : has_smul ℤ (Π₀ i, β i) :=\n⟨λc v, v.map_range (λ _, (•) c) (λ _, zsmul_zero _)⟩\n\nlemma zsmul_apply [Π i, add_group (β i)] (b : ℤ) (v : Π₀ i, β i) (i : ι) : (b • v) i = b • (v i) :=\nrfl\n\n@[simp] lemma coe_zsmul [Π i, add_group (β i)] (b : ℤ) (v : Π₀ i, β i) : ⇑(b • v) = b • v :=\nrfl\n\ninstance [Π i, add_group (β i)] : add_group (Π₀ i, β i) :=\nfun_like.coe_injective.add_group _\n  coe_zero coe_add coe_neg coe_sub (λ _ _, coe_nsmul _ _) (λ _ _, coe_zsmul _ _)\n\ninstance [Π i, add_comm_group (β i)] : add_comm_group (Π₀ i, β i) :=\nfun_like.coe_injective.add_comm_group _\n  coe_zero coe_add coe_neg coe_sub (λ _ _, coe_nsmul _ _) (λ _ _, coe_zsmul _ _)\n\n/-- Dependent functions with finite support inherit a semiring action from an action on each\ncoordinate. -/\ninstance [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] :\n  has_smul γ (Π₀ i, β i) :=\n⟨λc v, v.map_range (λ _, (•) c) (λ _, smul_zero _)⟩\n\nlemma smul_apply [monoid γ] [Π i, add_monoid (β i)]\n  [Π i, distrib_mul_action γ (β i)] (b : γ) (v : Π₀ i, β i) (i : ι) :\n  (b • v) i = b • (v i) :=\nrfl\n\n@[simp] lemma coe_smul [monoid γ] [Π i, add_monoid (β i)]\n  [Π i, distrib_mul_action γ (β i)] (b : γ) (v : Π₀ i, β i) :\n  ⇑(b • v) = b • v :=\nrfl\n\ninstance {δ : Type*} [monoid γ] [monoid δ]\n  [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] [Π i, distrib_mul_action δ (β i)]\n  [Π i, smul_comm_class γ δ (β i)] :\n  smul_comm_class γ δ (Π₀ i, β i) :=\n{ smul_comm := λ r s m, ext $ λ i, by simp only [smul_apply, smul_comm r s (m i)] }\n\ninstance {δ : Type*} [monoid γ] [monoid δ]\n  [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] [Π i, distrib_mul_action δ (β i)]\n  [has_smul γ δ] [Π i, is_scalar_tower γ δ (β i)] :\n  is_scalar_tower γ δ (Π₀ i, β i) :=\n{ smul_assoc := λ r s m, ext $ λ i, by simp only [smul_apply, smul_assoc r s (m i)] }\n\ninstance [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)]\n  [Π i, distrib_mul_action γᵐᵒᵖ (β i)] [∀ i, is_central_scalar γ (β i)] :\n  is_central_scalar γ (Π₀ i, β i) :=\n{ op_smul_eq_smul := λ r m, ext $ λ i, by simp only [smul_apply, op_smul_eq_smul r (m i)] }\n\n/-- Dependent functions with finite support inherit a `distrib_mul_action` structure from such a\nstructure on each coordinate. -/\ninstance [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)] :\n  distrib_mul_action γ (Π₀ i, β i) :=\nfunction.injective.distrib_mul_action coe_fn_add_monoid_hom fun_like.coe_injective coe_smul\n\n/-- Dependent functions with finite support inherit a module structure from such a structure on\neach coordinate. -/\ninstance [semiring γ] [Π i, add_comm_monoid (β i)] [Π i, module γ (β i)] :\n  module γ (Π₀ i, β i) :=\n{ zero_smul := λ c, ext $ λ i, by simp only [smul_apply, zero_smul, zero_apply],\n  add_smul := λ c x y, ext $ λ i, by simp only [add_apply, smul_apply, add_smul],\n  ..dfinsupp.distrib_mul_action }\n\nend algebra\n\nsection filter_and_subtype_domain\n\n/-- `filter p f` is the function which is `f i` if `p i` is true and 0 otherwise. -/\ndef filter [Π i, has_zero (β i)] (p : ι → Prop) [decidable_pred p] (x : Π₀ i, β i) : Π₀ i, β i :=\n⟨λ i, if p i then x i else 0, x.support'.map\n  (λ xs, ⟨xs, λ i, (xs.prop i).imp_right $ λ H : x i = 0, by rw [H, if_t_t]⟩)⟩\n\n@[simp] lemma filter_apply [Π i, has_zero (β i)]\n  (p : ι → Prop) [decidable_pred p] (i : ι) (f : Π₀ i, β i) :\n  f.filter p i = if p i then f i else 0 :=\nrfl\n\nlemma filter_apply_pos [Π i, has_zero (β i)]\n  {p : ι → Prop} [decidable_pred p] (f : Π₀ i, β i) {i : ι} (h : p i) :\n  f.filter p i = f i :=\nby simp only [filter_apply, if_pos h]\n\nlemma filter_apply_neg [Π i, has_zero (β i)]\n  {p : ι → Prop} [decidable_pred p] (f : Π₀ i, β i) {i : ι} (h : ¬ p i) :\n  f.filter p i = 0 :=\nby simp only [filter_apply, if_neg h]\n\nlemma filter_pos_add_filter_neg [Π i, add_zero_class (β i)] (f : Π₀ i, β i)\n  (p : ι → Prop) [decidable_pred p] :\n  f.filter p + f.filter (λi, ¬ p i) = f :=\next $ λ i, by simp only [add_apply, filter_apply]; split_ifs; simp only [add_zero, zero_add]\n\n@[simp] lemma filter_zero [Π i, has_zero (β i)] (p : ι → Prop) [decidable_pred p] :\n  (0 : Π₀ i, β i).filter p = 0 :=\nby { ext, simp }\n\n@[simp] lemma filter_add [Π i, add_zero_class (β i)] (p : ι → Prop) [decidable_pred p]\n  (f g : Π₀ i, β i) :\n  (f + g).filter p = f.filter p + g.filter p :=\nby { ext, simp [ite_add_zero] }\n\n@[simp] lemma filter_smul [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)]\n  (p : ι → Prop) [decidable_pred p] (r : γ) (f : Π₀ i, β i) :\n  (r • f).filter p = r • f.filter p :=\nby { ext, simp [smul_ite] }\n\nvariables (γ β)\n\n/-- `dfinsupp.filter` as an `add_monoid_hom`. -/\n@[simps]\ndef filter_add_monoid_hom [Π i, add_zero_class (β i)] (p : ι → Prop) [decidable_pred p] :\n  (Π₀ i, β i) →+ (Π₀ i, β i) :=\n{ to_fun := filter p,\n  map_zero' := filter_zero p,\n  map_add' := filter_add p }\n\n/-- `dfinsupp.filter` as a `linear_map`. -/\n@[simps]\ndef filter_linear_map [semiring γ] [Π i, add_comm_monoid (β i)] [Π i, module γ (β i)]\n  (p : ι → Prop) [decidable_pred p] :\n  (Π₀ i, β i) →ₗ[γ] (Π₀ i, β i) :=\n{ to_fun := filter p,\n  map_add' := filter_add p,\n  map_smul' := filter_smul p }\n\nvariables {γ β}\n\n@[simp] lemma filter_neg [Π i, add_group (β i)] (p : ι → Prop) [decidable_pred p]\n  (f : Π₀ i, β i) :\n  (-f).filter p = -f.filter p :=\n(filter_add_monoid_hom β p).map_neg f\n\n@[simp] lemma filter_sub [Π i, add_group (β i)] (p : ι → Prop) [decidable_pred p]\n  (f g : Π₀ i, β i) :\n  (f - g).filter p = f.filter p - g.filter p :=\n(filter_add_monoid_hom β p).map_sub f g\n\n/-- `subtype_domain p f` is the restriction of the finitely supported function\n  `f` to the subtype `p`. -/\ndef subtype_domain [Π i, has_zero (β i)] (p : ι → Prop) [decidable_pred p] (x : Π₀ i, β i) :\n  Π₀ i : subtype p, β i :=\n⟨λ i, x (i : ι), x.support'.map\n  (λ xs, ⟨(multiset.filter p xs).attach.map $ λ j, ⟨j, (multiset.mem_filter.1 j.2).2⟩,\n      λ i, (xs.prop i).imp_left $ λ H, multiset.mem_map.2\n        ⟨⟨i, multiset.mem_filter.2 ⟨H, i.2⟩⟩, multiset.mem_attach _ _, subtype.eta _ _⟩⟩)⟩\n\n@[simp] lemma subtype_domain_zero [Π i, has_zero (β i)] {p : ι → Prop} [decidable_pred p] :\n  subtype_domain p (0 : Π₀ i, β i) = 0 :=\nrfl\n\n@[simp] lemma subtype_domain_apply [Π i, has_zero (β i)] {p : ι → Prop} [decidable_pred p]\n  {i : subtype p} {v : Π₀ i, β i} :\n  (subtype_domain p v) i = v i :=\nrfl\n\n@[simp] lemma subtype_domain_add [Π i, add_zero_class (β i)] {p : ι → Prop} [decidable_pred p]\n  (v v' : Π₀ i, β i) :\n  (v + v').subtype_domain p = v.subtype_domain p + v'.subtype_domain p :=\ncoe_fn_injective rfl\n\n@[simp] lemma subtype_domain_smul [monoid γ] [Π i, add_monoid (β i)]\n  [Π i, distrib_mul_action γ (β i)] {p : ι → Prop} [decidable_pred p] (r : γ) (f : Π₀ i, β i) :\n  (r • f).subtype_domain p = r • f.subtype_domain p :=\ncoe_fn_injective rfl\n\nvariables (γ β)\n\n/-- `subtype_domain` but as an `add_monoid_hom`. -/\n@[simps] def subtype_domain_add_monoid_hom [Π i, add_zero_class (β i)]\n  (p : ι → Prop) [decidable_pred p] : (Π₀ i : ι, β i) →+ Π₀ i : subtype p, β i :=\n{ to_fun := subtype_domain p,\n  map_zero' := subtype_domain_zero,\n  map_add' := subtype_domain_add }\n\n/-- `dfinsupp.subtype_domain` as a `linear_map`. -/\n@[simps]\ndef subtype_domain_linear_map [semiring γ] [Π i, add_comm_monoid (β i)] [Π i, module γ (β i)]\n  (p : ι → Prop) [decidable_pred p] :\n  (Π₀ i, β i) →ₗ[γ] (Π₀ i : subtype p, β i) :=\n{ to_fun := subtype_domain p,\n  map_add' := subtype_domain_add,\n  map_smul' := subtype_domain_smul }\n\nvariables {γ β}\n\n@[simp]\nlemma subtype_domain_neg [Π i, add_group (β i)] {p : ι → Prop} [decidable_pred p] {v : Π₀ i, β i} :\n  (- v).subtype_domain p = - v.subtype_domain p :=\ncoe_fn_injective rfl\n\n@[simp] lemma subtype_domain_sub [Π i, add_group (β i)] {p : ι → Prop} [decidable_pred p]\n  {v v' : Π₀ i, β i} :\n  (v - v').subtype_domain p = v.subtype_domain p - v'.subtype_domain p :=\ncoe_fn_injective rfl\n\nend filter_and_subtype_domain\n\n\nvariable [dec : decidable_eq ι]\ninclude dec\n\nsection basic\nvariable [Π i, has_zero (β i)]\n\nomit dec\nlemma finite_support (f : Π₀ i, β i) : set.finite {i | f i ≠ 0} :=\nbegin\n  classical,\n  exact trunc.induction_on f.support' (λ xs, (multiset.to_finset ↑xs).finite_to_set.subset (λ i H,\n    multiset.mem_to_finset.2 ((xs.prop i).resolve_right H)))\nend\ninclude dec\n\n/-- Create an element of `Π₀ i, β i` from a finset `s` and a function `x`\ndefined on this `finset`. -/\ndef mk (s : finset ι) (x : Π i : (↑s : set ι), β (i : ι)) : Π₀ i, β i :=\n⟨λ i, if H : i ∈ s then x ⟨i, H⟩ else 0, trunc.mk ⟨s.1,\n  λ i, if H : i ∈ s then or.inl H else or.inr $ dif_neg H⟩⟩\n\nvariables {s : finset ι} {x : Π i : (↑s : set ι), β i} {i : ι}\n\n@[simp] lemma mk_apply : (mk s x : Π i, β i) i = if H : i ∈ s then x ⟨i, H⟩ else 0 := rfl\nlemma mk_of_mem (hi : i ∈ s) : (mk s x : Π i, β i) i = x ⟨i, hi⟩ := dif_pos hi\nlemma mk_of_not_mem (hi : i ∉ s) : (mk s x : Π i, β i) i = 0 := dif_neg hi\n\ntheorem mk_injective (s : finset ι) : function.injective (@mk ι β _ _ s) :=\nbegin\n  intros x y H,\n  ext i,\n  have h1 : (mk s x : Π i, β i) i = (mk s y : Π i, β i) i, {rw H},\n  cases i with i hi,\n  change i ∈ s at hi,\n  dsimp only [mk_apply, subtype.coe_mk] at h1,\n  simpa only [dif_pos hi] using h1\nend\n\nomit dec\n\ninstance unique [∀ i, subsingleton (β i)] : unique (Π₀ i, β i) := fun_like.coe_injective.unique\n\ninstance unique_of_is_empty [is_empty ι] : unique (Π₀ i, β i) := fun_like.coe_injective.unique\n\n/-- Given `fintype ι`, `equiv_fun_on_fintype` is the `equiv` between `Π₀ i, β i` and `Π i, β i`.\n  (All dependent functions on a finite type are finitely supported.) -/\n@[simps apply] def equiv_fun_on_fintype [fintype ι] : (Π₀ i, β i) ≃ (Π i, β i) :=\n{ to_fun := coe_fn,\n  inv_fun := λ f, ⟨f, trunc.mk ⟨finset.univ.1, λ i, or.inl $ finset.mem_univ_val _⟩⟩,\n  left_inv := λ x, coe_fn_injective rfl,\n  right_inv := λ x, rfl }\n\n@[simp] lemma equiv_fun_on_fintype_symm_coe [fintype ι] (f : Π₀ i, β i) :\n  equiv_fun_on_fintype.symm f = f :=\nequiv.symm_apply_apply _ _\ninclude dec\n\n/-- The function `single i b : Π₀ i, β i` sends `i` to `b`\nand all other points to `0`. -/\ndef single (i : ι) (b : β i) : Π₀ i, β i :=\n⟨pi.single i b,\n  trunc.mk ⟨{i}, λ j, (decidable.eq_or_ne j i).imp (by simp) (λ h, pi.single_eq_of_ne h _)⟩⟩\n\nlemma single_eq_pi_single {i b} : ⇑(single i b : Π₀ i, β i) = pi.single i b :=\nrfl\n\n@[simp] lemma single_apply {i i' b} :\n  (single i b : Π₀ i, β i) i' = (if h : i = i' then eq.rec_on h b else 0) :=\nbegin\n  rw [single_eq_pi_single, pi.single, function.update],\n  simp [@eq_comm _ i i'],\nend\n\n@[simp] lemma single_zero (i) : (single i 0 : Π₀ i, β i) = 0 :=\nfun_like.coe_injective $ pi.single_zero _\n\n@[simp] lemma single_eq_same {i b} : (single i b : Π₀ i, β i) i = b :=\nby simp only [single_apply, dif_pos rfl]\n\nlemma single_eq_of_ne {i i' b} (h : i ≠ i') : (single i b : Π₀ i, β i) i' = 0 :=\nby simp only [single_apply, dif_neg h]\n\nlemma single_injective {i} : function.injective (single i : β i → Π₀ i, β i) :=\nλ x y H, pi.single_injective β i $ coe_fn_injective.eq_iff.mpr H\n\n/-- Like `finsupp.single_eq_single_iff`, but with a `heq` due to dependent types -/\nlemma single_eq_single_iff (i j : ι) (xi : β i) (xj : β j) :\n  dfinsupp.single i xi = dfinsupp.single j xj ↔ i = j ∧ xi == xj ∨ xi = 0 ∧ xj = 0 :=\nbegin\n  split,\n  { intro h,\n    by_cases hij : i = j,\n    { subst hij,\n      exact or.inl ⟨rfl, heq_of_eq (dfinsupp.single_injective h)⟩, },\n    { have h_coe : ⇑(dfinsupp.single i xi) = dfinsupp.single j xj := congr_arg coe_fn h,\n      have hci := congr_fun h_coe i,\n      have hcj := congr_fun h_coe j,\n      rw dfinsupp.single_eq_same at hci hcj,\n      rw dfinsupp.single_eq_of_ne (ne.symm hij) at hci,\n      rw dfinsupp.single_eq_of_ne (hij) at hcj,\n      exact or.inr ⟨hci, hcj.symm⟩, }, },\n  { rintros (⟨rfl, hxi⟩ | ⟨hi, hj⟩),\n    { rw eq_of_heq hxi, },\n    { rw [hi, hj, dfinsupp.single_zero, dfinsupp.single_zero], }, },\nend\n\n/-- `dfinsupp.single a b` is injective in `a`. For the statement that it is injective in `b`, see\n`dfinsupp.single_injective` -/\nlemma single_left_injective {b : Π (i : ι), β i} (h : ∀ i, b i ≠ 0) :\n  function.injective (λ i, single i (b i) : ι → Π₀ i, β i) :=\nλ a a' H, (((single_eq_single_iff _ _ _ _).mp H).resolve_right $ λ hb, h _ hb.1).left\n\n@[simp] lemma single_eq_zero {i : ι} {xi : β i} : single i xi = 0 ↔ xi = 0 :=\nbegin\n  rw [←single_zero i, single_eq_single_iff],\n  simp,\nend\n\nlemma filter_single (p : ι → Prop) [decidable_pred p] (i : ι) (x : β i) :\n  (single i x).filter p = if p i then single i x else 0 :=\nbegin\n  ext j,\n  have := apply_ite (λ x : Π₀ i, β i, x j) (p i) (single i x) 0,\n  dsimp at this,\n  rw [filter_apply, this],\n  obtain rfl | hij := decidable.eq_or_ne i j,\n  { refl, },\n  { rw [single_eq_of_ne hij, if_t_t, if_t_t], },\nend\n\n@[simp] lemma filter_single_pos {p : ι → Prop} [decidable_pred p] (i : ι) (x : β i) (h : p i) :\n  (single i x).filter p = single i x :=\nby rw [filter_single, if_pos h]\n\n@[simp] lemma filter_single_neg {p : ι → Prop} [decidable_pred p] (i : ι) (x : β i) (h : ¬p i) :\n  (single i x).filter p = 0 :=\nby rw [filter_single, if_neg h]\n\n/-- Equality of sigma types is sufficient (but not necessary) to show equality of `dfinsupp`s. -/\nlemma single_eq_of_sigma_eq\n  {i j} {xi : β i} {xj : β j} (h : (⟨i, xi⟩ : sigma β) = ⟨j, xj⟩) :\n  dfinsupp.single i xi = dfinsupp.single j xj :=\nby { cases h, refl }\n\n@[simp] lemma equiv_fun_on_fintype_single [fintype ι] (i : ι) (m : β i) :\n  (@dfinsupp.equiv_fun_on_fintype ι β _ _) (dfinsupp.single i m) = pi.single i m :=\nby { ext, simp [dfinsupp.single_eq_pi_single], }\n\n@[simp] lemma equiv_fun_on_fintype_symm_single [fintype ι] (i : ι) (m : β i) :\n  (@dfinsupp.equiv_fun_on_fintype ι β _ _).symm (pi.single i m) = dfinsupp.single i m :=\nby { ext i', simp only [← single_eq_pi_single, equiv_fun_on_fintype_symm_coe] }\n\n/-- Redefine `f i` to be `0`. -/\ndef erase (i : ι) (x : Π₀ i, β i) : Π₀ i, β i :=\n⟨λ j, if j = i then 0 else x.1 j, x.support'.map $ λ xs,\n  ⟨xs, λ j, (xs.prop j).imp_right $ λ H, by simp only [H, if_t_t]⟩⟩\n\n@[simp] lemma erase_apply {i j : ι} {f : Π₀ i, β i} :\n  (f.erase i) j = if j = i then 0 else f j :=\nrfl\n\n@[simp] lemma erase_same {i : ι} {f : Π₀ i, β i} : (f.erase i) i = 0 :=\nby simp\n\nlemma erase_ne {i i' : ι} {f : Π₀ i, β i} (h : i' ≠ i) : (f.erase i) i' = f i' :=\nby simp [h]\n\nlemma piecewise_single_erase (x : Π₀ i, β i) (i : ι) :\n  (single i (x i)).piecewise (x.erase i) {i} = x :=\nbegin\n  ext j, rw piecewise_apply, split_ifs,\n  { rw [(id h : j = i), single_eq_same] },\n  { exact erase_ne h },\nend\n\nlemma erase_eq_sub_single {β : ι → Type*} [Π i, add_group (β i)] (f : Π₀ i, β i) (i : ι) :\n  f.erase i = f - single i (f i) :=\nbegin\n  ext j,\n  rcases eq_or_ne i j with rfl|h,\n  { simp },\n  { simp [erase_ne h.symm, single_eq_of_ne h] }\nend\n\n@[simp] lemma erase_zero (i : ι) : erase i (0 : Π₀ i, β i) = 0 :=\next $ λ _, if_t_t _ _\n\n@[simp] lemma filter_ne_eq_erase (f : Π₀ i, β i) (i : ι) : f.filter (≠ i) = f.erase i :=\nbegin\n  ext1 j,\n  simp only [dfinsupp.filter_apply, dfinsupp.erase_apply, ite_not],\nend\n\n@[simp] lemma filter_ne_eq_erase' (f : Π₀ i, β i) (i : ι) : f.filter ((≠) i) = f.erase i :=\nbegin\n  rw ←filter_ne_eq_erase f i,\n  congr' with j,\n  exact ne_comm,\nend\n\nlemma erase_single (j : ι) (i : ι) (x : β i) :\n  (single i x).erase j = if i = j then 0 else single i x :=\nby rw [←filter_ne_eq_erase, filter_single, ite_not]\n\n@[simp] lemma erase_single_same (i : ι) (x : β i) : (single i x).erase i = 0 :=\nby rw [erase_single, if_pos rfl]\n\n@[simp] lemma erase_single_ne {i j : ι} (x : β i) (h : i ≠ j) : (single i x).erase j = single i x :=\nby rw [erase_single, if_neg h]\n\nsection update\n\nvariables (f : Π₀ i, β i) (i) (b : β i)\n\n/-- Replace the value of a `Π₀ i, β i` at a given point `i : ι` by a given value `b : β i`.\nIf `b = 0`, this amounts to removing `i` from the support.\nOtherwise, `i` is added to it.\n\nThis is the (dependent) finitely-supported version of `function.update`. -/\ndef update : Π₀ i, β i :=\n⟨function.update f i b, f.support'.map $ λ s,\n  ⟨i ::ₘ s, λ j, begin\n    rcases eq_or_ne i j with rfl|hi,\n    { simp, },\n    { obtain hj | (hj : f j = 0) := s.prop j,\n      { exact or.inl (multiset.mem_cons_of_mem hj), },\n      { exact or.inr ((function.update_noteq hi.symm b _).trans hj) } }\n  end⟩⟩\n\nvariables (j : ι)\n\n@[simp] lemma coe_update : (f.update i b : Π (i : ι), β i) = function.update f i b := rfl\n\n@[simp] lemma update_self : f.update i (f i) = f :=\nby { ext, simp }\n\n@[simp] lemma update_eq_erase : f.update i 0 = f.erase i :=\nbegin\n  ext j,\n  rcases eq_or_ne i j with rfl|hi,\n  { simp },\n  { simp [hi.symm] }\nend\n\nlemma update_eq_single_add_erase {β : ι → Type*} [Π i, add_zero_class (β i)] (f : Π₀ i, β i) (i : ι)\n  (b : β i) :\n  f.update i b = single i b + f.erase i :=\nbegin\n  ext j,\n  rcases eq_or_ne i j with rfl|h,\n  { simp },\n  { simp [function.update_noteq h.symm, h, erase_ne, h.symm] }\nend\n\nlemma update_eq_erase_add_single {β : ι → Type*} [Π i, add_zero_class (β i)] (f : Π₀ i, β i) (i : ι)\n  (b : β i) :\n  f.update i b = f.erase i + single i b :=\nbegin\n  ext j,\n  rcases eq_or_ne i j with rfl|h,\n  { simp },\n  { simp [function.update_noteq h.symm, h, erase_ne, h.symm] }\nend\n\nlemma update_eq_sub_add_single {β : ι → Type*} [Π i, add_group (β i)] (f : Π₀ i, β i) (i : ι)\n  (b : β i) :\n  f.update i b = f - single i (f i) + single i b :=\nby rw [update_eq_erase_add_single f i b, erase_eq_sub_single f i]\n\nend update\n\nend basic\n\nsection add_monoid\n\nvariable [Π i, add_zero_class (β i)]\n\n@[simp] lemma single_add (i : ι) (b₁ b₂ : β i) : single i (b₁ + b₂) = single i b₁ + single i b₂ :=\next $ assume i',\nbegin\n  by_cases h : i = i',\n  { subst h, simp only [add_apply, single_eq_same] },\n  { simp only [add_apply, single_eq_of_ne h, zero_add] }\nend\n\n@[simp] lemma erase_add (i : ι) (f₁ f₂ : Π₀ i, β i) : erase i (f₁ + f₂) = erase i f₁ + erase i f₂ :=\next $ λ _, by simp [ite_zero_add]\n\nvariables (β)\n\n/-- `dfinsupp.single` as an `add_monoid_hom`. -/\n@[simps] def single_add_hom (i : ι) : β i →+ Π₀ i, β i :=\n{ to_fun := single i, map_zero' := single_zero i, map_add' := single_add i }\n\n/-- `dfinsupp.erase` as an `add_monoid_hom`. -/\n@[simps] def erase_add_hom (i : ι) : (Π₀ i, β i) →+ Π₀ i, β i :=\n{ to_fun := erase i, map_zero' := erase_zero i, map_add' := erase_add i }\n\nvariables {β}\n\n@[simp] lemma single_neg {β : ι → Type v} [Π i, add_group (β i)] (i : ι) (x : β i) :\n  single i (-x) = -single i x :=\n(single_add_hom β i).map_neg x\n\n@[simp] lemma single_sub {β : ι → Type v} [Π i, add_group (β i)] (i : ι) (x y : β i) :\n  single i (x - y) = single i x - single i y :=\n(single_add_hom β i).map_sub x y\n\n@[simp] lemma erase_neg {β : ι → Type v} [Π i, add_group (β i)] (i : ι) (f : Π₀ i, β i) :\n  (-f).erase i = -f.erase i :=\n(erase_add_hom β i).map_neg f\n\n@[simp] lemma erase_sub {β : ι → Type v} [Π i, add_group (β i)] (i : ι) (f g : Π₀ i, β i) :\n  (f - g).erase i = f.erase i - g.erase i :=\n(erase_add_hom β i).map_sub f g\n\nlemma single_add_erase (i : ι) (f : Π₀ i, β i) : single i (f i) + f.erase i = f :=\next $ λ i',\nif h : i = i'\nthen by subst h; simp only [add_apply, single_apply, erase_apply, dif_pos rfl, if_pos, add_zero]\nelse by simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (ne.symm h), zero_add]\n\nlemma erase_add_single (i : ι) (f : Π₀ i, β i) : f.erase i + single i (f i) = f :=\next $ λ i',\nif h : i = i'\nthen by subst h; simp only [add_apply, single_apply, erase_apply, dif_pos rfl, if_pos, zero_add]\nelse by simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (ne.symm h), add_zero]\n\nprotected theorem induction {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i)\n  (h0 : p 0) (ha : ∀i b (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (single i b + f)) :\n  p f :=\nbegin\n  cases f with f s,\n  induction s using trunc.induction_on,\n  cases s with s H,\n  induction s using multiset.induction_on with i s ih generalizing f,\n  { have : f = 0 := funext (λ i, (H i).resolve_left id),\n    subst this,\n    exact h0 },\n  have H2 : p (erase i ⟨f, trunc.mk ⟨i ::ₘ s, H⟩⟩),\n  { dsimp only [erase, trunc.map, trunc.bind, trunc.lift_on, trunc.lift_mk, function.comp,\n      subtype.coe_mk],\n    have H2 : ∀ j, j ∈ s ∨ ite (j = i) 0 (f j) = 0,\n    { intro j, cases H j with H2 H2,\n      { cases multiset.mem_cons.1 H2 with H3 H3,\n        { right, exact if_pos H3 },\n        { left, exact H3 } },\n      right, split_ifs; [refl, exact H2] },\n    have H3 : (⟨λ (j : ι), ite (j = i) 0 (f j), trunc.mk ⟨i ::ₘ s, _⟩⟩ : Π₀ i, β i)\n      = ⟨λ (j : ι), ite (j = i) 0 (f j), trunc.mk ⟨s, H2⟩⟩ := ext (λ _, rfl),\n    rw H3, apply ih },\n  have H3 : single i _ + _ = (⟨f, trunc.mk ⟨i ::ₘ s, H⟩⟩ : Π₀ i, β i) :=\n    single_add_erase _ _,\n  rw ← H3,\n  change p (single i (f i) + _),\n  cases classical.em (f i = 0) with h h,\n  { rw [h, single_zero, zero_add], exact H2 },\n  refine ha _ _ _ _ h H2,\n  rw erase_same\nend\n\nlemma induction₂ {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i)\n  (h0 : p 0) (ha : ∀i b (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (f + single i b)) :\n  p f :=\ndfinsupp.induction f h0 $ λ i b f h1 h2 h3,\nhave h4 : f + single i b = single i b + f,\n{ ext j, by_cases H : i = j,\n  { subst H, simp [h1] },\n  { simp [H] } },\neq.rec_on h4 $ ha i b f h1 h2 h3\n\n@[simp] lemma add_closure_Union_range_single :\n  add_submonoid.closure (⋃ i : ι, set.range (single i : β i → (Π₀ i, β i))) = ⊤ :=\ntop_unique $ λ x hx, (begin\n  apply dfinsupp.induction x,\n  exact add_submonoid.zero_mem _,\n  exact λ a b f ha hb hf, add_submonoid.add_mem _\n    (add_submonoid.subset_closure $ set.mem_Union.2 ⟨a, set.mem_range_self _⟩) hf\nend)\n\n/-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then\nthey are equal. -/\n\n\n/-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then\nthey are equal.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext] lemma add_hom_ext' {γ : Type w} [add_zero_class γ] ⦃f g : (Π₀ i, β i) →+ γ⦄\n  (H : ∀ x, f.comp (single_add_hom β x) = g.comp (single_add_hom β x)) :\n  f = g :=\nadd_hom_ext $ λ x, add_monoid_hom.congr_fun (H x)\n\nend add_monoid\n\n@[simp] lemma mk_add [Π i, add_zero_class (β i)] {s : finset ι} {x y : Π i : (↑s : set ι), β i} :\n  mk s (x + y) = mk s x + mk s y :=\next $ λ i, by simp only [add_apply, mk_apply]; split_ifs; [refl, rw zero_add]\n\n@[simp] lemma mk_zero [Π i, has_zero (β i)] {s : finset ι} :\n  mk s (0 : Π i : (↑s : set ι), β i.1) = 0 :=\next $ λ i, by simp only [mk_apply]; split_ifs; refl\n\n@[simp] lemma mk_neg [Π i, add_group (β i)] {s : finset ι} {x : Π i : (↑s : set ι), β i.1} :\n  mk s (-x) = -mk s x :=\next $ λ i, by simp only [neg_apply, mk_apply]; split_ifs; [refl, rw neg_zero]\n\n@[simp] lemma mk_sub [Π i, add_group (β i)] {s : finset ι} {x y : Π i : (↑s : set ι), β i.1} :\n  mk s (x - y) = mk s x - mk s y :=\next $ λ i, by simp only [sub_apply, mk_apply]; split_ifs; [refl, rw sub_zero]\n\n/-- If `s` is a subset of `ι` then `mk_add_group_hom s` is the canonical additive\ngroup homomorphism from $\\prod_{i\\in s}\\beta_i$ to $\\prod_{\\mathtt{i : \\iota}}\\beta_i.$-/\ndef mk_add_group_hom [Π i, add_group (β i)] (s : finset ι) :\n  (Π (i : (s : set ι)), β ↑i) →+ (Π₀ (i : ι), β i) :=\n{ to_fun := mk s,\n  map_zero' := mk_zero,\n  map_add' := λ _ _, mk_add }\n\nsection\nvariables [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)]\n\n@[simp] lemma mk_smul {s : finset ι} (c : γ) (x : Π i : (↑s : set ι), β (i : ι)) :\n  mk s (c • x) = c • mk s x :=\next $ λ i, by simp only [smul_apply, mk_apply]; split_ifs; [refl, rw smul_zero]\n\n@[simp] lemma single_smul {i : ι} (c : γ) (x : β i) :\n  single i (c • x) = c • single i x :=\next $ λ i, by simp only [smul_apply, single_apply]; split_ifs; [cases h, rw smul_zero]; refl\n\nend\n\nsection support_basic\n\nvariables [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n\n/-- Set `{i | f x ≠ 0}` as a `finset`. -/\ndef support (f : Π₀ i, β i) : finset ι :=\nf.support'.lift (λ xs, (multiset.to_finset ↑xs).filter $ λ i, f i ≠ 0) $\nbegin\n  rintros ⟨sx, hx⟩ ⟨sy, hy⟩,\n  dsimp only [subtype.coe_mk, to_fun_eq_coe] at *,\n  ext i, split,\n  { intro H,\n    rcases finset.mem_filter.1 H with ⟨h1, h2⟩,\n    exact finset.mem_filter.2 ⟨multiset.mem_to_finset.2 $ (hy i).resolve_right h2, h2⟩ },\n  { intro H,\n    rcases finset.mem_filter.1 H with ⟨h1, h2⟩,\n    exact finset.mem_filter.2 ⟨multiset.mem_to_finset.2 $ (hx i).resolve_right h2, h2⟩ },\nend\n\n@[simp] theorem support_mk_subset {s : finset ι} {x : Π i : (↑s : set ι), β i.1} :\n  (mk s x).support ⊆ s :=\nλ i H, multiset.mem_to_finset.1 (finset.mem_filter.1 H).1\n\n@[simp] theorem support_mk'_subset {f : Π i, β i} {s : multiset ι} {h} :\n  (mk' f $ trunc.mk ⟨s, h⟩).support ⊆ s.to_finset :=\nλ i H, multiset.mem_to_finset.1 $ by simpa using (finset.mem_filter.1 H).1\n\n@[simp] theorem mem_support_to_fun (f : Π₀ i, β i) (i) : i ∈ f.support ↔ f i ≠ 0 :=\nbegin\n  cases f with f s,\n  induction s using trunc.induction_on,\n  dsimp only [support, trunc.lift_mk],\n  rw [finset.mem_filter, multiset.mem_to_finset, coe_mk'],\n  exact and_iff_right_of_imp (s.prop i).resolve_right\nend\n\ntheorem eq_mk_support (f : Π₀ i, β i) : f = mk f.support (λ i, f i) :=\nbegin\n  change f = mk f.support (λ i, f i.1),\n  ext i,\n  by_cases h : f i ≠ 0; [skip, rw [not_not] at h];\n    simp [h]\nend\n\n@[simp] lemma support_zero : (0 : Π₀ i, β i).support = ∅ := rfl\n\nlemma mem_support_iff {f : Π₀ i, β i} {i : ι} : i ∈ f.support ↔ f i ≠ 0 := f.mem_support_to_fun _\n\nlemma not_mem_support_iff {f : Π₀ i, β i} {i : ι} : i ∉ f.support ↔ f i = 0 :=\nnot_iff_comm.1 mem_support_iff.symm\n\n@[simp] lemma support_eq_empty {f : Π₀ i, β i} : f.support = ∅ ↔ f = 0 :=\n⟨λ H, ext $ by simpa [finset.ext_iff] using H, by simp {contextual:=tt}⟩\n\ninstance decidable_zero : decidable_pred (eq (0 : Π₀ i, β i)) :=\nλ f, decidable_of_iff _ $ support_eq_empty.trans eq_comm\n\nlemma support_subset_iff {s : set ι} {f : Π₀ i, β i} :\n  ↑f.support ⊆ s ↔ (∀i∉s, f i = 0) :=\nby simp [set.subset_def];\n   exact forall_congr (assume i, not_imp_comm)\n\nlemma support_single_ne_zero {i : ι} {b : β i} (hb : b ≠ 0) : (single i b).support = {i} :=\nbegin\n  ext j, by_cases h : i = j,\n  { subst h, simp [hb] },\n  simp [ne.symm h, h]\nend\n\nlemma support_single_subset {i : ι} {b : β i} : (single i b).support ⊆ {i} :=\nsupport_mk'_subset\n\nsection map_range_and_zip_with\n\nvariables [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n\nlemma map_range_def [Π i (x : β₁ i), decidable (x ≠ 0)]\n  {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} :\n  map_range f hf g = mk g.support (λ i, f i.1 (g i.1)) :=\nbegin\n  ext i,\n  by_cases h : g i ≠ 0; simp at h; simp [h, hf]\nend\n\n@[simp] lemma map_range_single {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {i : ι} {b : β₁ i} :\n  map_range f hf (single i b) = single i (f i b) :=\ndfinsupp.ext $ λ i', by by_cases i = i'; [{subst i', simp}, simp [h, hf]]\n\nvariables [Π i (x : β₁ i), decidable (x ≠ 0)] [Π i (x : β₂ i), decidable (x ≠ 0)]\n\nlemma support_map_range {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} :\n  (map_range f hf g).support ⊆ g.support :=\nby simp [map_range_def]\n\nlemma zip_with_def {ι : Type u} {β : ι → Type v} {β₁ : ι → Type v₁} {β₂ : ι → Type v₂}\n  [dec : decidable_eq ι] [Π (i : ι), has_zero (β i)] [Π (i : ι), has_zero (β₁ i)]\n  [Π (i : ι), has_zero (β₂ i)] [Π (i : ι) (x : β₁ i), decidable (x ≠ 0)]\n  [Π (i : ι) (x : β₂ i), decidable (x ≠ 0)]\n  {f : Π i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0}\n  {g₁ : Π₀ i, β₁ i} {g₂ : Π₀ i, β₂ i} :\n  zip_with f hf g₁ g₂ = mk (g₁.support ∪ g₂.support) (λ i, f i.1 (g₁ i.1) (g₂ i.1)) :=\nbegin\n  ext i,\n  by_cases h1 : g₁ i ≠ 0; by_cases h2 : g₂ i ≠ 0;\n    simp only [not_not, ne.def] at h1 h2; simp [h1, h2, hf]\nend\n\nlemma support_zip_with {f : Π i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0}\n  {g₁ : Π₀ i, β₁ i} {g₂ : Π₀ i, β₂ i} :\n  (zip_with f hf g₁ g₂).support ⊆ g₁.support ∪ g₂.support :=\nby simp [zip_with_def]\n\nend map_range_and_zip_with\n\nlemma erase_def (i : ι) (f : Π₀ i, β i) :\n  f.erase i = mk (f.support.erase i) (λ j, f j.1) :=\nby { ext j, by_cases h1 : j = i; by_cases h2 : f j ≠ 0; simp at h2; simp [h1, h2] }\n\n@[simp] lemma support_erase (i : ι) (f : Π₀ i, β i) :\n  (f.erase i).support = f.support.erase i :=\nby { ext j, by_cases h1 : j = i, simp [h1], by_cases h2 : f j ≠ 0; simp at h2; simp [h1, h2] }\n\nlemma support_update_ne_zero (f : Π₀ i, β i) (i : ι) {b : β i} (h : b ≠ 0) :\n  support (f.update i b) = insert i f.support :=\nbegin\n  ext j,\n  rcases eq_or_ne i j with rfl|hi,\n  { simp [h] },\n  { simp [hi.symm] }\nend\n\nlemma support_update (f : Π₀ i, β i) (i : ι) (b : β i) [decidable (b = 0)] :\n  support (f.update i b) = if b = 0 then support (f.erase i) else insert i f.support :=\nbegin\n  ext j,\n  split_ifs with hb,\n  { substI hb, simp [update_eq_erase, support_erase] },\n  { rw [support_update_ne_zero f _ hb] }\nend\n\nsection filter_and_subtype_domain\n\nvariables {p : ι → Prop} [decidable_pred p]\n\nlemma filter_def (f : Π₀ i, β i) :\n  f.filter p = mk (f.support.filter p) (λ i, f i.1) :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i ≠ 0;\n simp at h2; simp [h1, h2]\n\n@[simp] lemma support_filter (f : Π₀ i, β i) :\n  (f.filter p).support = f.support.filter p :=\nby ext i; by_cases h : p i; simp [h]\n\nlemma subtype_domain_def (f : Π₀ i, β i) :\n  f.subtype_domain p = mk (f.support.subtype p) (λ i, f i) :=\nby ext i; by_cases h2 : f i ≠ 0; try {simp at h2}; dsimp; simp [h2]\n\n@[simp] lemma support_subtype_domain {f : Π₀ i, β i} :\n  (subtype_domain p f).support = f.support.subtype p :=\nby { ext i, simp, }\n\nend filter_and_subtype_domain\n\nend support_basic\n\nlemma support_add [Π i, add_zero_class (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  {g₁ g₂ : Π₀ i, β i} :\n  (g₁ + g₂).support ⊆ g₁.support ∪ g₂.support :=\nsupport_zip_with\n\n@[simp] lemma support_neg [Π i, add_group (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  {f : Π₀ i, β i} :\n  support (-f) = support f :=\nby ext i; simp\n\nlemma support_smul {γ : Type w} [semiring γ] [Π i, add_comm_monoid (β i)] [Π i, module γ (β i)]\n  [Π ( i : ι) (x : β i), decidable (x ≠ 0)]\n  (b : γ) (v : Π₀ i, β i) : (b • v).support ⊆ v.support :=\nsupport_map_range\n\ninstance [Π i, has_zero (β i)] [Π i, decidable_eq (β i)] : decidable_eq (Π₀ i, β i) :=\nassume f g, decidable_of_iff (f.support = g.support ∧ (∀i∈f.support, f i = g i))\n  ⟨assume ⟨h₁, h₂⟩, ext $ assume i,\n      if h : i ∈ f.support then h₂ i h else\n        have hf : f i = 0, by rwa [mem_support_iff, not_not] at h,\n        have hg : g i = 0, by rwa [h₁, mem_support_iff, not_not] at h,\n        by rw [hf, hg],\n    by { rintro rfl, simp }⟩\n\nsection equiv\nopen finset\n\nvariables {κ : Type*}\n/--Reindexing (and possibly removing) terms of a dfinsupp.-/\nnoncomputable def comap_domain [Π i, has_zero (β i)] (h : κ → ι) (hh : function.injective h)\n  (f : Π₀ i, β i) : Π₀ k, β (h k) :=\n{ to_fun := λ x, f (h x),\n  support' := f.support'.map $ λ s,\n    ⟨((multiset.to_finset ↑s).preimage h (hh.inj_on _)).val,\n    λ x, (s.prop (h x)).imp_left $ λ hx, mem_preimage.mpr $ multiset.mem_to_finset.mpr hx ⟩ }\n\n@[simp] lemma comap_domain_apply [Π i, has_zero (β i)] (h : κ → ι) (hh : function.injective h)\n  (f : Π₀ i, β i) (k : κ) :\n  comap_domain h hh f k = f (h k) :=\nrfl\n\n@[simp] lemma comap_domain_zero [Π i, has_zero (β i)] (h : κ → ι) (hh : function.injective h) :\n  comap_domain h hh (0 : Π₀ i, β i) = 0 :=\nby { ext, rw [zero_apply, comap_domain_apply, zero_apply] }\n\n@[simp] lemma comap_domain_add [Π i, add_zero_class (β i)] (h : κ → ι) (hh : function.injective h)\n  (f g : Π₀ i, β i) :\n  comap_domain h hh (f + g) = comap_domain h hh f + comap_domain h hh g :=\nby { ext, rw [add_apply, comap_domain_apply, comap_domain_apply, comap_domain_apply, add_apply] }\n\n@[simp] lemma comap_domain_smul [monoid γ] [Π i, add_monoid (β i)] [Π i, distrib_mul_action γ (β i)]\n  (h : κ → ι) (hh : function.injective h) (r : γ) (f : Π₀ i, β i) :\n  comap_domain h hh (r • f) = r • comap_domain h hh f :=\nby { ext, rw [smul_apply, comap_domain_apply, smul_apply, comap_domain_apply] }\n\n@[simp] lemma comap_domain_single [decidable_eq κ] [Π i, has_zero (β i)]\n  (h : κ → ι) (hh : function.injective h) (k : κ) (x : β (h k)) :\n  comap_domain h hh (single (h k) x) = single k x :=\nbegin\n  ext,\n  rw comap_domain_apply,\n  obtain rfl | hik := decidable.eq_or_ne i k,\n  { rw [single_eq_same, single_eq_same] },\n  { rw [single_eq_of_ne hik.symm, single_eq_of_ne (hh.ne hik.symm)] },\nend\n\nomit dec\n/--A computable version of comap_domain when an explicit left inverse is provided.-/\ndef comap_domain' [Π i, has_zero (β i)] (h : κ → ι) {h' : ι → κ}\n  (hh' : function.left_inverse h' h) (f : Π₀ i, β i) : (Π₀ k, β (h k)) :=\n{ to_fun := λ x, f (h x),\n  support' := f.support'.map $ λ s, ⟨multiset.map h' s, λ x,\n    (s.prop (h x)).imp_left $ λ hx, multiset.mem_map.mpr ⟨_, hx, hh' _⟩⟩ }\n\n@[simp] lemma comap_domain'_apply [Π i, has_zero (β i)] (h : κ → ι) {h' : ι → κ}\n  (hh' : function.left_inverse h' h) (f : Π₀ i, β i) (k : κ) : comap_domain' h hh' f k = f (h k) :=\nrfl\n\n@[simp] lemma comap_domain'_zero [Π i, has_zero (β i)] (h : κ → ι) {h' : ι → κ}\n  (hh' : function.left_inverse h' h) :\n  comap_domain' h hh' (0 : Π₀ i, β i) = 0 :=\nby { ext, rw [zero_apply, comap_domain'_apply, zero_apply] }\n\n@[simp] lemma comap_domain'_add [Π i, add_zero_class (β i)] (h : κ → ι) {h' : ι → κ}\n  (hh' : function.left_inverse h' h) (f g : Π₀ i, β i) :\n  comap_domain' h hh' (f + g) = comap_domain' h hh' f + comap_domain' h hh' g :=\nby { ext, rw [add_apply, comap_domain'_apply, comap_domain'_apply, comap_domain'_apply, add_apply] }\n\n@[simp] lemma comap_domain'_smul [monoid γ] [Π i, add_monoid (β i)]\n  [Π i, distrib_mul_action γ (β i)] (h : κ → ι) {h' : ι → κ}\n  (hh' : function.left_inverse h' h) (r : γ) (f : Π₀ i, β i) :\n  comap_domain' h hh' (r • f) = r • comap_domain' h hh' f :=\nby { ext, rw [smul_apply, comap_domain'_apply, smul_apply, comap_domain'_apply] }\n\n@[simp] lemma comap_domain'_single [decidable_eq ι] [decidable_eq κ] [Π i, has_zero (β i)]\n  (h : κ → ι) {h' : ι → κ} (hh' : function.left_inverse h' h) (k : κ) (x : β (h k)) :\n  comap_domain' h hh' (single (h k) x) = single k x :=\nbegin\n  ext,\n  rw comap_domain'_apply,\n  obtain rfl | hik := decidable.eq_or_ne i k,\n  { rw [single_eq_same, single_eq_same] },\n  { rw [single_eq_of_ne hik.symm, single_eq_of_ne (hh'.injective.ne hik.symm)] },\nend\n\n/-- Reindexing terms of a dfinsupp.\n\nThis is the dfinsupp version of `equiv.Pi_congr_left'`. -/\n@[simps apply]\ndef equiv_congr_left [Π i, has_zero (β i)] (h : ι ≃ κ) : (Π₀ i, β i) ≃ (Π₀ k, β (h.symm k)) :=\n{ to_fun := comap_domain' h.symm h.right_inv,\n  inv_fun := λ f, map_range (λ i, equiv.cast $ congr_arg β $ h.symm_apply_apply i)\n    (λ i, (equiv.cast_eq_iff_heq _).mpr $\n      by { convert heq.rfl, repeat { exact (h.symm_apply_apply i).symm } })\n        (@comap_domain' _ _ _ _ h _ h.left_inv f),\n  left_inv := λ f, by { ext i, rw [map_range_apply, comap_domain'_apply, comap_domain'_apply,\n    equiv.cast_eq_iff_heq, h.symm_apply_apply] },\n  right_inv := λ f, by { ext k, rw [comap_domain'_apply, map_range_apply, comap_domain'_apply,\n    equiv.cast_eq_iff_heq, h.apply_symm_apply] } }\n\nsection curry\nvariables {α : ι → Type*} {δ : Π i, α i → Type v}\n\n-- lean can't find these instances\ninstance has_add₂ [Π i j, add_zero_class (δ i j)] : has_add (Π₀ (i : ι) (j : α i), δ i j) :=\n@dfinsupp.has_add ι (λ i, Π₀ j, δ i j) _\n\ninstance add_zero_class₂ [Π i j, add_zero_class (δ i j)] :\n  add_zero_class (Π₀ (i : ι) (j : α i), δ i j) :=\n@dfinsupp.add_zero_class ι (λ i, Π₀ j, δ i j) _\n\ninstance add_monoid₂ [Π i j, add_monoid (δ i j)] :\n  add_monoid (Π₀ (i : ι) (j : α i), δ i j) :=\n@dfinsupp.add_monoid ι (λ i, Π₀ j, δ i j) _\n\ninstance distrib_mul_action₂ [monoid γ] [Π i j, add_monoid (δ i j)]\n  [Π i j, distrib_mul_action γ (δ i j)] :\n  distrib_mul_action γ (Π₀ (i : ι) (j : α i), δ i j) :=\n@dfinsupp.distrib_mul_action ι _ (λ i, Π₀ j, δ i j) _ _ _\n\n/--The natural map between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`.  -/\nnoncomputable def sigma_curry [Π i j, has_zero (δ i j)] (f : Π₀ (i : Σ i, _), δ i.1 i.2) :\n  Π₀ i j, δ i j :=\nby { classical,\n  exact mk (f.support.image $ λ i, i.1)\n    (λ i, mk (f.support.preimage (sigma.mk i) $ sigma_mk_injective.inj_on _) $ λ j, f ⟨i, j⟩) }\n\n@[simp] lemma sigma_curry_apply [Π i j, has_zero (δ i j)] (f : Π₀ (i : Σ i, _), δ i.1 i.2)\n  (i : ι) (j : α i) :\n  sigma_curry f i j = f ⟨i, j⟩ :=\nbegin\n  dunfold sigma_curry, by_cases h : f ⟨i, j⟩ = 0,\n  { rw [h, mk_apply], split_ifs, { rw mk_apply, split_ifs, { exact h }, { refl } }, { refl } },\n  { rw [mk_of_mem, mk_of_mem], { refl },\n    { rw [mem_preimage, mem_support_to_fun], exact h },\n    { rw mem_image, refine ⟨⟨i, j⟩, _, rfl⟩, rw mem_support_to_fun, exact h } }\nend\n\n@[simp] lemma sigma_curry_zero [Π i j, has_zero (δ i j)] :\n  sigma_curry (0 : Π₀ (i : Σ i, _), δ i.1 i.2) = 0 :=\nby { ext i j, rw sigma_curry_apply, refl }\n\n@[simp] lemma sigma_curry_add [Π i j, add_zero_class (δ i j)] (f g : Π₀ (i : Σ i, α i), δ i.1 i.2) :\n  @sigma_curry _ _ δ _ (f + g) = (@sigma_curry _ _ δ _ f + @sigma_curry ι α δ _ g) :=\nbegin\n  ext i j,\n  rw [@add_apply _ (λ i, Π₀ j, δ i j) _ (sigma_curry _), add_apply, sigma_curry_apply,\n      sigma_curry_apply, sigma_curry_apply, add_apply]\nend\n\n@[simp] lemma sigma_curry_smul [monoid γ] [Π i j, add_monoid (δ i j)]\n  [Π i j, distrib_mul_action γ (δ i j)] (r : γ) (f : Π₀ (i : Σ i, α i), δ i.1 i.2) :\n  @sigma_curry _ _ δ _ (r • f) = r • @sigma_curry _ _ δ _ f :=\nbegin\n  ext i j,\n  rw [@smul_apply _ _ (λ i, Π₀ j, δ i j) _ _ _ _ (sigma_curry _), smul_apply, sigma_curry_apply,\n      sigma_curry_apply, smul_apply]\nend\n\n@[simp] lemma sigma_curry_single [decidable_eq ι] [Π i, decidable_eq (α i)]\n  [Π i j, has_zero (δ i j)] (ij : Σ i, α i) (x : δ ij.1 ij.2) :\n  @sigma_curry _ _ _ _ (single ij x) = single ij.1 (single ij.2 x : Π₀ j, δ ij.1 j) :=\nbegin\n  obtain ⟨i, j⟩ := ij,\n  ext i' j',\n  dsimp only,\n  rw sigma_curry_apply,\n  obtain rfl | hi := eq_or_ne i i',\n  { rw single_eq_same,\n    obtain rfl | hj := eq_or_ne j j',\n    { rw [single_eq_same, single_eq_same] },\n    { rw [single_eq_of_ne, single_eq_of_ne hj],\n      simpa using hj }, },\n  { rw [single_eq_of_ne, single_eq_of_ne hi, zero_apply],\n    simpa using hi },\nend\n\n/--The natural map between `Π₀ i (j : α i), δ i j` and `Π₀ (i : Σ i, α i), δ i.1 i.2`, inverse of\n`curry`.-/\ndef sigma_uncurry [Π i j, has_zero (δ i j)]\n  [Π i, decidable_eq (α i)] [Π i j (x : δ i j), decidable (x ≠ 0)] (f : Π₀ i j, δ i j) :\n  Π₀ (i : Σ i, _), δ i.1 i.2 :=\n{ to_fun := λ i, f i.1 i.2,\n  support' := f.support'.map $ λ s,\n    ⟨(multiset.bind ↑s $ λ i, ((f i).support.map ⟨sigma.mk i, sigma_mk_injective⟩).val), λ i, begin\n      simp_rw [multiset.mem_bind, map_val, multiset.mem_map, function.embedding.coe_fn_mk,\n        ←finset.mem_def, mem_support_to_fun],\n      obtain hi | (hi : f i.1 = 0) := s.prop i.1,\n      { by_cases hi' : f i.1 i.2 = 0,\n        { exact or.inr hi' },\n        { exact or.inl ⟨_, hi, i.2, hi', sigma.eta _⟩ } },\n      { right,\n        rw [hi, zero_apply] }\n    end⟩ }\n\n@[simp] lemma sigma_uncurry_apply [Π i j, has_zero (δ i j)]\n  [Π i, decidable_eq (α i)] [Π i j (x : δ i j), decidable (x ≠ 0)]\n  (f : Π₀ i j, δ i j) (i : ι) (j : α i) :\n  sigma_uncurry f ⟨i, j⟩ = f i j :=\nrfl\n\n@[simp] lemma sigma_uncurry_zero [Π i j, has_zero (δ i j)]\n  [Π i, decidable_eq (α i)] [Π i j (x : δ i j), decidable (x ≠ 0)]:\n  sigma_uncurry (0 : Π₀ i j, δ i j) = 0 :=\nrfl\n\n@[simp] lemma sigma_uncurry_add [Π i j, add_zero_class (δ i j)]\n  [Π i, decidable_eq (α i)] [Π i j (x : δ i j), decidable (x ≠ 0)]\n  (f g : Π₀ i j, δ i j) :\n  sigma_uncurry (f + g) = sigma_uncurry f + sigma_uncurry g :=\ncoe_fn_injective rfl\n\n@[simp] lemma sigma_uncurry_smul [monoid γ] [Π i j, add_monoid (δ i j)]\n  [Π i, decidable_eq (α i)] [Π i j (x : δ i j), decidable (x ≠ 0)]\n  [Π i j, distrib_mul_action γ (δ i j)] (r : γ) (f : Π₀ i j, δ i j) :\n  sigma_uncurry (r • f) = r • sigma_uncurry f :=\ncoe_fn_injective rfl\n\n@[simp] lemma sigma_uncurry_single [Π i j, has_zero (δ i j)]\n  [decidable_eq ι] [Π i, decidable_eq (α i)] [Π i j (x : δ i j), decidable (x ≠ 0)]\n  (i) (j : α i) (x : δ i j) :\n  sigma_uncurry (single i (single j x : Π₀ (j : α i), δ i j)) = single ⟨i, j⟩ x:=\nbegin\n  ext ⟨i', j'⟩,\n  dsimp only,\n  rw sigma_uncurry_apply,\n  obtain rfl | hi := eq_or_ne i i',\n  { rw single_eq_same,\n    obtain rfl | hj := eq_or_ne j j',\n    { rw [single_eq_same, single_eq_same] },\n    { rw [single_eq_of_ne hj, single_eq_of_ne],\n      simpa using hj }, },\n  { rw [single_eq_of_ne hi, single_eq_of_ne, zero_apply],\n    simpa using hi },\nend\n\n/--The natural bijection between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`.\n\nThis is the dfinsupp version of `equiv.Pi_curry`. -/\nnoncomputable def sigma_curry_equiv [Π i j, has_zero (δ i j)]\n  [Π i, decidable_eq (α i)] [Π i j (x : δ i j), decidable (x ≠ 0)] :\n  (Π₀ (i : Σ i, _), δ i.1 i.2) ≃ Π₀ i j, δ i j :=\n{ to_fun := sigma_curry,\n  inv_fun := sigma_uncurry,\n  left_inv := λ f, by { ext ⟨i, j⟩, rw [sigma_uncurry_apply, sigma_curry_apply] },\n  right_inv := λ f, by { ext i j, rw [sigma_curry_apply, sigma_uncurry_apply] } }\n\nend curry\n\nvariables {α : option ι → Type v}\n\n/-- Adds a term to a dfinsupp, making a dfinsupp indexed by an `option`.\n\nThis is the dfinsupp version of `option.rec`. -/\ndef extend_with [Π i, has_zero (α i)] (a : α none) (f : Π₀ i, α (some i)) : Π₀ i, α i :=\n{ to_fun := option.rec a f,\n  support' := f.support'.map $ λ s, ⟨none ::ₘ multiset.map some s, λ i,\n    option.rec (or.inl $ multiset.mem_cons_self _ _)\n      (λ i, (s.prop i).imp_left $ λ h, multiset.mem_cons_of_mem $ multiset.mem_map_of_mem _ h) i⟩ }\n\n@[simp] lemma extend_with_none [Π i, has_zero (α i)] (f : Π₀ i, α (some i)) (a : α none) :\n  f.extend_with a none = a :=\nrfl\n@[simp] lemma extend_with_some [Π i, has_zero (α i)] (f : Π₀ i, α (some i)) (a : α none) (i : ι) :\n  f.extend_with a (some i) = f i :=\nrfl\n\n@[simp] lemma extend_with_single_zero [decidable_eq ι] [Π i, has_zero (α i)]\n  (i : ι) (x : α (some i)) :\n  (single i x).extend_with 0 = single (some i) x :=\nbegin\n  ext (_ | j),\n  { rw [extend_with_none, single_eq_of_ne (option.some_ne_none _)] },\n  { rw extend_with_some,\n    obtain rfl | hij := decidable.eq_or_ne i j,\n    { rw [single_eq_same, single_eq_same] },\n    { rw [single_eq_of_ne hij, single_eq_of_ne ((option.some_injective _).ne hij)] }, },\nend\n\n@[simp] lemma extend_with_zero [decidable_eq ι] [Π i, has_zero (α i)] (x : α none) :\n  (0 : Π₀ i, α (some i)).extend_with x = single none x :=\nbegin\n  ext (_ | j),\n  { rw [extend_with_none, single_eq_same] },\n  { rw [extend_with_some, single_eq_of_ne (option.some_ne_none _).symm, zero_apply] },\nend\n\ninclude dec\n/-- Bijection obtained by separating the term of index `none` of a dfinsupp over `option ι`.\n\nThis is the dfinsupp version of `equiv.pi_option_equiv_prod`. -/\n@[simps] noncomputable def equiv_prod_dfinsupp [Π i, has_zero (α i)] :\n  (Π₀ i, α i) ≃ α none × Π₀ i, α (some i) :=\n{ to_fun := λ f, (f none, comap_domain some (option.some_injective _) f),\n  inv_fun := λ f, f.2.extend_with f.1,\n  left_inv := λ f, begin\n    ext i, cases i with i,\n    { rw extend_with_none },\n    { rw [extend_with_some, comap_domain_apply] }\n  end,\n  right_inv := λ x, begin\n    dsimp only,\n    ext,\n    { exact extend_with_none x.snd _ },\n    { rw [comap_domain_apply, extend_with_some] }\n  end }\n\nlemma equiv_prod_dfinsupp_add [Π i, add_zero_class (α i)] (f g : Π₀ i, α i) :\n  equiv_prod_dfinsupp (f + g) = equiv_prod_dfinsupp f + equiv_prod_dfinsupp g :=\nprod.ext (add_apply _ _ _) (comap_domain_add _ _ _ _)\n\nlemma equiv_prod_dfinsupp_smul [monoid γ] [Π i, add_monoid (α i)] [Π i, distrib_mul_action γ (α i)]\n  (r : γ) (f : Π₀ i, α i) :\n  equiv_prod_dfinsupp (r • f) = r • equiv_prod_dfinsupp f :=\nprod.ext (smul_apply _ _ _) (comap_domain_smul _ _ _ _)\n\nend equiv\n\nsection prod_and_sum\n\n/-- `prod f g` is the product of `g i (f i)` over the support of `f`. -/\n@[to_additive \"`sum f g` is the sum of `g i (f i)` over the support of `f`.\"]\ndef prod [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)] [comm_monoid γ]\n  (f : Π₀ i, β i) (g : Π i, β i → γ) : γ :=\n∏ i in f.support, g i (f i)\n\n@[to_additive]\nlemma prod_map_range_index {β₁ : ι → Type v₁} {β₂ : ι → Type v₂}\n  [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n  [Π i (x : β₁ i), decidable (x ≠ 0)] [Π i (x : β₂ i), decidable (x ≠ 0)] [comm_monoid γ]\n  {f : Π i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} {h : Π i, β₂ i → γ}\n  (h0 : ∀i, h i 0 = 1) :\n  (map_range f hf g).prod h = g.prod (λi b, h i (f i b)) :=\nbegin\n  rw [map_range_def],\n  refine (finset.prod_subset support_mk_subset _).trans _,\n  { intros i h1 h2,\n    dsimp, simp [h1] at h2, dsimp at h2,\n    simp [h1, h2, h0] },\n  { refine finset.prod_congr rfl _,\n    intros i h1,\n    simp [h1] }\nend\n\n@[to_additive]\nlemma prod_zero_index [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {h : Π i, β i → γ} : (0 : Π₀ i, β i).prod h = 1 :=\nrfl\n\n@[to_additive]\nlemma prod_single_index [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)] [comm_monoid γ]\n  {i : ι} {b : β i} {h : Π i, β i → γ} (h_zero : h i 0 = 1) :\n  (single i b).prod h = h i b :=\nbegin\n  by_cases h : b ≠ 0,\n  { simp [dfinsupp.prod, support_single_ne_zero h] },\n  { rw [not_not] at h, simp [h, prod_zero_index, h_zero], refl }\nend\n\n@[to_additive]\nlemma prod_neg_index [Π i, add_group (β i)] [Π i (x : β i), decidable (x ≠ 0)] [comm_monoid γ]\n  {g : Π₀ i, β i} {h : Π i, β i → γ} (h0 : ∀i, h i 0 = 1) :\n  (-g).prod h = g.prod (λi b, h i (- b)) :=\nprod_map_range_index h0\n\nomit dec\n@[to_additive]\nlemma prod_comm {ι₁ ι₂ : Sort*} {β₁ : ι₁ → Type*} {β₂ : ι₂ → Type*}\n  [decidable_eq ι₁] [decidable_eq ι₂] [Π i, has_zero (β₁ i)] [Π i, has_zero (β₂ i)]\n  [Π i (x : β₁ i), decidable (x ≠ 0)] [Π i (x : β₂ i), decidable (x ≠ 0)] [comm_monoid γ]\n  (f₁ : Π₀ i, β₁ i) (f₂ : Π₀ i, β₂ i) (h : Π i, β₁ i → Π i, β₂ i → γ) :\n  f₁.prod (λ i₁ x₁, f₂.prod $ λ i₂ x₂, h i₁ x₁ i₂ x₂) =\n  f₂.prod (λ i₂ x₂, f₁.prod $ λ i₁ x₁, h i₁ x₁ i₂ x₂) := finset.prod_comm\n\n@[simp] lemma sum_apply {ι₁ : Type u₁} [decidable_eq ι₁] {β₁ : ι₁ → Type v₁}\n  [Π i₁, has_zero (β₁ i₁)] [Π i (x : β₁ i), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)]\n  {f : Π₀ i₁, β₁ i₁} {g : Π i₁, β₁ i₁ → Π₀ i, β i} {i₂ : ι} :\n  (f.sum g) i₂ = f.sum (λi₁ b, g i₁ b i₂) :=\n(eval_add_monoid_hom i₂ : (Π₀ i, β i) →+ β i₂).map_sum  _ f.support\n\ninclude dec\n\nlemma support_sum {ι₁ : Type u₁} [decidable_eq ι₁] {β₁ : ι₁ → Type v₁}\n  [Π i₁, has_zero (β₁ i₁)] [Π i (x : β₁ i), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  {f : Π₀ i₁, β₁ i₁} {g : Π i₁, β₁ i₁ → Π₀ i, β i} :\n  (f.sum g).support ⊆ f.support.bUnion (λi, (g i (f i)).support) :=\nhave ∀i₁ : ι, f.sum (λ (i : ι₁) (b : β₁ i), (g i b) i₁) ≠ 0 →\n    (∃ (i : ι₁), f i ≠ 0 ∧ ¬ (g i (f i)) i₁ = 0),\n  from assume i₁ h,\n  let ⟨i, hi, ne⟩ := finset.exists_ne_zero_of_sum_ne_zero h in\n  ⟨i, mem_support_iff.1 hi, ne⟩,\nby simpa [finset.subset_iff, mem_support_iff, finset.mem_bUnion, sum_apply] using this\n\n@[simp, to_additive] lemma prod_one [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {f : Π₀ i, β i} :\n  f.prod (λi b, (1 : γ)) = 1 :=\nfinset.prod_const_one\n\n@[simp, to_additive] lemma prod_mul [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {f : Π₀ i, β i} {h₁ h₂ : Π i, β i → γ} :\n  f.prod (λi b, h₁ i b * h₂ i b) = f.prod h₁ * f.prod h₂ :=\nfinset.prod_mul_distrib\n\n@[simp, to_additive] lemma prod_inv [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_group γ] {f : Π₀ i, β i} {h : Π i, β i → γ} :\n  f.prod (λi b, (h i b)⁻¹) = (f.prod h)⁻¹ :=\n((inv_monoid_hom : γ →* γ).map_prod _ f.support).symm\n\n@[to_additive] lemma prod_eq_one [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {f : Π₀ i, β i} {h : Π i, β i → γ} (hyp : ∀ i, h i (f i) = 1) :\n  f.prod h = 1 := finset.prod_eq_one $ λ i hi, hyp i\n\nlemma smul_sum {α : Type*} [monoid α] [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [add_comm_monoid γ] [distrib_mul_action α γ] {f : Π₀ i, β i} {h : Π i, β i → γ} {c : α} :\n  c • f.sum h = f.sum (λ a b, c • h a b) := finset.smul_sum\n\n@[to_additive]\nlemma prod_add_index [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {f g : Π₀ i, β i}\n  {h : Π i, β i → γ} (h_zero : ∀i, h i 0 = 1) (h_add : ∀i b₁ b₂, h i (b₁ + b₂) = h i b₁ * h i b₂) :\n  (f + g).prod h = f.prod h * g.prod h :=\nhave f_eq : ∏ i in f.support ∪ g.support, h i (f i) = f.prod h,\n  from (finset.prod_subset (finset.subset_union_left _ _) $\n    by simp [mem_support_iff, h_zero] {contextual := tt}).symm,\nhave g_eq : ∏ i in f.support ∪ g.support, h i (g i) = g.prod h,\n  from (finset.prod_subset (finset.subset_union_right _ _) $\n    by simp [mem_support_iff, h_zero] {contextual := tt}).symm,\ncalc ∏ i in (f + g).support, h i ((f + g) i) =\n      ∏ i in f.support ∪ g.support, h i ((f + g) i) :\n    finset.prod_subset support_add $\n      by simp [mem_support_iff, h_zero] {contextual := tt}\n  ... = (∏ i in f.support ∪ g.support, h i (f i)) *\n      (∏ i in f.support ∪ g.support, h i (g i)) :\n    by simp [h_add, finset.prod_mul_distrib]\n  ... = _ : by rw [f_eq, g_eq]\n\n@[to_additive]\nlemma _root_.dfinsupp_prod_mem [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {S : Type*} [set_like S γ] [submonoid_class S γ] (s : S)\n  (f : Π₀ i, β i) (g : Π i, β i → γ) (h : ∀ c, f c ≠ 0 → g c (f c) ∈ s) : f.prod g ∈ s :=\nprod_mem $ λ i hi, h _ $ mem_support_iff.1 hi\n\n@[simp, to_additive] lemma prod_eq_prod_fintype [fintype ι] [Π i, has_zero (β i)]\n  [Π (i : ι) (x : β i), decidable (x ≠ 0)] [comm_monoid γ] (v : Π₀ i, β i) [f : Π i, β i → γ]\n  (hf : ∀ i, f i 0 = 1) :\n  v.prod f = ∏ i, f i (dfinsupp.equiv_fun_on_fintype v i) :=\nbegin\n  suffices : ∏ i in v.support, f i (v i) = ∏ i, f i (v i),\n  { simp [dfinsupp.prod, this] },\n  apply finset.prod_subset v.support.subset_univ,\n  intros i hi' hi,\n  rw [mem_support_iff, not_not] at hi,\n  rw [hi, hf],\nend\n\n/--\nWhen summing over an `add_monoid_hom`, the decidability assumption is not needed, and the result is\nalso an `add_monoid_hom`.\n-/\ndef sum_add_hom [Π i, add_zero_class (β i)] [add_comm_monoid γ] (φ : Π i, β i →+ γ) :\n  (Π₀ i, β i) →+ γ :=\n{ to_fun := (λ f,\n    f.support'.lift (λ s, ∑ i in multiset.to_finset ↑s, φ i (f i)) $\n    begin\n      rintros ⟨sx, hx⟩ ⟨sy, hy⟩,\n      dsimp only [subtype.coe_mk, to_fun_eq_coe] at *,\n      have H1 : sx.to_finset ∩ sy.to_finset ⊆ sx.to_finset, from finset.inter_subset_left _ _,\n      have H2 : sx.to_finset ∩ sy.to_finset ⊆ sy.to_finset, from finset.inter_subset_right _ _,\n      refine (finset.sum_subset H1 _).symm.trans\n          ((finset.sum_congr rfl _).trans (finset.sum_subset H2 _)),\n      { intros i H1 H2, rw finset.mem_inter at H2,\n        simp only [multiset.mem_to_finset] at H1 H2,\n        rw [(hy i).resolve_left (mt (and.intro H1) H2), add_monoid_hom.map_zero] },\n      { intros i H1, refl },\n      { intros i H1 H2, rw finset.mem_inter at H2,\n        simp only [multiset.mem_to_finset] at H1 H2,\n        rw [(hx i).resolve_left (mt (λ H3, and.intro H3 H1) H2), add_monoid_hom.map_zero] }\n    end),\n  map_add' := begin\n    rintros ⟨f, sf, hf⟩ ⟨g, sg, hg⟩,\n    change ∑ i in _, _ = (∑ i in _, _) + (∑ i in _, _),\n    simp only [coe_add, coe_mk', subtype.coe_mk, pi.add_apply, map_add, finset.sum_add_distrib],\n    congr' 1,\n    { refine (finset.sum_subset _ _).symm,\n      { intro i, simp only [multiset.mem_to_finset, multiset.mem_add], exact or.inl },\n      { intros i H1 H2, simp only [multiset.mem_to_finset, multiset.mem_add] at H2,\n        rw [(hf i).resolve_left H2, add_monoid_hom.map_zero] } },\n    { refine (finset.sum_subset _ _).symm,\n      { intro i, simp only [multiset.mem_to_finset, multiset.mem_add], exact or.inr },\n      { intros i H1 H2, simp only [multiset.mem_to_finset, multiset.mem_add] at H2,\n        rw [(hg i).resolve_left H2, add_monoid_hom.map_zero] } }\n  end,\n  map_zero' := rfl }\n\n@[simp] lemma sum_add_hom_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (φ : Π i, β i →+ γ) (i) (x : β i) : sum_add_hom φ (single i x) = φ i x :=\nbegin\n  dsimp [sum_add_hom, single, trunc.lift_mk],\n  rw [multiset.to_finset_singleton, finset.sum_singleton, pi.single_eq_same],\nend\n\n@[simp] lemma sum_add_hom_comp_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (f : Π i, β i →+ γ) (i : ι) :\n  (sum_add_hom f).comp (single_add_hom β i) = f i :=\nadd_monoid_hom.ext $ λ x, sum_add_hom_single f i x\n\n/-- While we didn't need decidable instances to define it, we do to reduce it to a sum -/\nlemma sum_add_hom_apply [Π i, add_zero_class (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [add_comm_monoid γ] (φ : Π i, β i →+ γ) (f : Π₀ i, β i) :\n  sum_add_hom φ f = f.sum (λ x, φ x) :=\nbegin\n  rcases f with ⟨f, s, hf⟩,\n  change ∑ i in _, _ = (∑ i in finset.filter _ _, _),\n  rw [finset.sum_filter, finset.sum_congr rfl],\n  intros i _,\n  dsimp only [coe_mk', subtype.coe_mk] at *,\n  split_ifs,\n  refl,\n  rw [(not_not.mp h), add_monoid_hom.map_zero],\nend\n\nlemma _root_.dfinsupp_sum_add_hom_mem [Π i, add_zero_class (β i)] [add_comm_monoid γ] {S : Type*}\n  [set_like S γ] [add_submonoid_class S γ] (s : S) (f : Π₀ i, β i) (g : Π i, β i →+ γ)\n  (h : ∀ c, f c ≠ 0 → g c (f c) ∈ s) : dfinsupp.sum_add_hom g f ∈ s :=\nbegin\n  classical,\n  rw dfinsupp.sum_add_hom_apply,\n  convert dfinsupp_sum_mem _ _ _ _,\n  { apply_instance },\n  exact h\nend\n\n/-- The supremum of a family of commutative additive submonoids is equal to the range of\n`dfinsupp.sum_add_hom`; that is, every element in the `supr` can be produced from taking a finite\nnumber of non-zero elements of `S i`, coercing them to `γ`, and summing them. -/\nlemma _root_.add_submonoid.supr_eq_mrange_dfinsupp_sum_add_hom [add_comm_monoid γ]\n  (S : ι → add_submonoid γ) : supr S = (dfinsupp.sum_add_hom (λ i, (S i).subtype)).mrange :=\nbegin\n  apply le_antisymm,\n  { apply supr_le _,\n    intros i y hy,\n    exact ⟨dfinsupp.single i ⟨y, hy⟩, dfinsupp.sum_add_hom_single _ _ _⟩, },\n  { rintros x ⟨v, rfl⟩,\n    exact dfinsupp_sum_add_hom_mem _ v _ (λ i _, (le_supr S i : S i ≤ _) (v i).prop) }\nend\n\n/-- The bounded supremum of a family of commutative additive submonoids is equal to the range of\n`dfinsupp.sum_add_hom` composed with `dfinsupp.filter_add_monoid_hom`; that is, every element in the\nbounded `supr` can be produced from taking a finite number of non-zero elements from the `S i` that\nsatisfy `p i`, coercing them to `γ`, and summing them. -/\nlemma _root_.add_submonoid.bsupr_eq_mrange_dfinsupp_sum_add_hom (p : ι → Prop)\n  [decidable_pred p] [add_comm_monoid γ] (S : ι → add_submonoid γ) :\n  (⨆ i (h : p i), S i) =\n    ((sum_add_hom (λ i, (S i).subtype)).comp (filter_add_monoid_hom _ p)).mrange :=\nbegin\n  apply le_antisymm,\n  { refine supr₂_le (λ i hi y hy, ⟨dfinsupp.single i ⟨y, hy⟩, _⟩),\n    rw [add_monoid_hom.comp_apply, filter_add_monoid_hom_apply, filter_single_pos _ _ hi],\n    exact sum_add_hom_single _ _ _, },\n  { rintros x ⟨v, rfl⟩,\n    refine dfinsupp_sum_add_hom_mem _ _ _ (λ i hi, _),\n    refine add_submonoid.mem_supr_of_mem i _,\n    by_cases hp : p i,\n    { simp [hp], },\n    { simp [hp] }, }\nend\n\nlemma _root_.add_submonoid.mem_supr_iff_exists_dfinsupp [add_comm_monoid γ]\n  (S : ι → add_submonoid γ) (x : γ) :\n  x ∈ supr S ↔ ∃ f : Π₀ i, S i, dfinsupp.sum_add_hom (λ i, (S i).subtype) f = x :=\nset_like.ext_iff.mp (add_submonoid.supr_eq_mrange_dfinsupp_sum_add_hom S) x\n\n/-- A variant of `add_submonoid.mem_supr_iff_exists_dfinsupp` with the RHS fully unfolded. -/\nlemma _root_.add_submonoid.mem_supr_iff_exists_dfinsupp' [add_comm_monoid γ]\n  (S : ι → add_submonoid γ) [Π i (x : S i), decidable (x ≠ 0)] (x : γ) :\n  x ∈ supr S ↔ ∃ f : Π₀ i, S i, f.sum (λ i xi, ↑xi) = x :=\nbegin\n  rw add_submonoid.mem_supr_iff_exists_dfinsupp,\n  simp_rw sum_add_hom_apply,\n  congr',\nend\n\nlemma _root_.add_submonoid.mem_bsupr_iff_exists_dfinsupp (p : ι → Prop)\n  [decidable_pred p] [add_comm_monoid γ] (S : ι → add_submonoid γ) (x : γ) :\n  x ∈ (⨆ i (h : p i), S i) ↔\n    ∃ f : Π₀ i, S i, dfinsupp.sum_add_hom (λ i, (S i).subtype) (f.filter p) = x :=\nset_like.ext_iff.mp (add_submonoid.bsupr_eq_mrange_dfinsupp_sum_add_hom p S) x\n\nomit dec\nlemma sum_add_hom_comm {ι₁ ι₂ : Sort*} {β₁ : ι₁ → Type*} {β₂ : ι₂ → Type*} {γ : Type*}\n  [decidable_eq ι₁] [decidable_eq ι₂] [Π i, add_zero_class (β₁ i)] [Π i, add_zero_class (β₂ i)]\n  [add_comm_monoid γ]\n  (f₁ : Π₀ i, β₁ i) (f₂ : Π₀ i, β₂ i) (h : Π i j, β₁ i →+ β₂ j →+ γ) :\n  sum_add_hom (λ i₂, sum_add_hom (λ i₁, h i₁ i₂) f₁) f₂ =\n  sum_add_hom (λ i₁, sum_add_hom (λ i₂, (h i₁ i₂).flip) f₂) f₁ :=\nbegin\n  obtain ⟨⟨f₁, s₁, h₁⟩, ⟨f₂, s₂, h₂⟩⟩ := ⟨f₁, f₂⟩,\n  simp only [sum_add_hom, add_monoid_hom.finset_sum_apply, quotient.lift_on_mk,\n    add_monoid_hom.coe_mk, add_monoid_hom.flip_apply, trunc.lift],\n  exact finset.sum_comm,\nend\n\ninclude dec\n/-- The `dfinsupp` version of `finsupp.lift_add_hom`,-/\n@[simps apply symm_apply]\ndef lift_add_hom [Π i, add_zero_class (β i)] [add_comm_monoid γ] :\n  (Π i, β i →+ γ) ≃+ ((Π₀ i, β i) →+ γ) :=\n{ to_fun := sum_add_hom,\n  inv_fun := λ F i, F.comp (single_add_hom β i),\n  left_inv := λ x, by { ext, simp },\n  right_inv := λ ψ, by { ext, simp },\n  map_add' := λ F G, by { ext, simp } }\n\n/-- The `dfinsupp` version of `finsupp.lift_add_hom_single_add_hom`,-/\n@[simp] lemma lift_add_hom_single_add_hom [Π i, add_comm_monoid (β i)] :\n  lift_add_hom (single_add_hom β) = add_monoid_hom.id (Π₀ i, β i) :=\nlift_add_hom.to_equiv.apply_eq_iff_eq_symm_apply.2 rfl\n\n/-- The `dfinsupp` version of `finsupp.lift_add_hom_apply_single`,-/\nlemma lift_add_hom_apply_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (f : Π i, β i →+ γ) (i : ι) (x : β i) :\n  lift_add_hom f (single i x) = f i x :=\nby simp\n\n/-- The `dfinsupp` version of `finsupp.lift_add_hom_comp_single`,-/\nlemma lift_add_hom_comp_single [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (f : Π i, β i →+ γ) (i : ι) :\n  (lift_add_hom f).comp (single_add_hom β i) = f i :=\nby simp\n\n/-- The `dfinsupp` version of `finsupp.comp_lift_add_hom`,-/\nlemma comp_lift_add_hom {δ : Type*} [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  [add_comm_monoid δ] (g : γ →+ δ) (f : Π i, β i →+ γ) :\n  g.comp (lift_add_hom f) = lift_add_hom (λ a, g.comp (f a)) :=\nlift_add_hom.symm_apply_eq.1 $ funext $ λ a,\n  by rw [lift_add_hom_symm_apply, add_monoid_hom.comp_assoc, lift_add_hom_comp_single]\n\n@[simp]\nlemma sum_add_hom_zero [Π i, add_zero_class (β i)] [add_comm_monoid γ] :\n  sum_add_hom (λ i, (0 : β i →+ γ)) = 0 :=\n(lift_add_hom : (Π i, β i →+ γ) ≃+ _).map_zero\n\n@[simp]\nlemma sum_add_hom_add [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  (g : Π i, β i →+ γ) (h : Π i, β i →+ γ) :\n  sum_add_hom (λ i, g i + h i) = sum_add_hom g + sum_add_hom h :=\nlift_add_hom.map_add _ _\n\n@[simp]\nlemma sum_add_hom_single_add_hom [Π i, add_comm_monoid (β i)] :\n  sum_add_hom (single_add_hom β) = add_monoid_hom.id _ :=\nlift_add_hom_single_add_hom\n\nlemma comp_sum_add_hom {δ : Type*} [Π i, add_zero_class (β i)] [add_comm_monoid γ]\n  [add_comm_monoid δ] (g : γ →+ δ) (f : Π i, β i →+ γ) :\n  g.comp (sum_add_hom f) = sum_add_hom (λ a, g.comp (f a)) :=\ncomp_lift_add_hom _ _\n\nlemma sum_sub_index [Π i, add_group (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [add_comm_group γ] {f g : Π₀ i, β i}\n  {h : Π i, β i → γ} (h_sub : ∀i b₁ b₂, h i (b₁ - b₂) = h i b₁ - h i b₂) :\n  (f - g).sum h = f.sum h - g.sum h :=\nbegin\n  have := (lift_add_hom (λ a, add_monoid_hom.of_map_sub (h a) (h_sub a))).map_sub f g,\n  rw [lift_add_hom_apply, sum_add_hom_apply, sum_add_hom_apply, sum_add_hom_apply] at this,\n  exact this,\nend\n\n@[to_additive]\nlemma prod_finset_sum_index {γ : Type w} {α : Type x}\n  [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ]\n  {s : finset α} {g : α → Π₀ i, β i}\n  {h : Π i, β i → γ} (h_zero : ∀i, h i 0 = 1) (h_add : ∀i b₁ b₂, h i (b₁ + b₂) = h i b₁ * h i b₂) :\n  ∏ i in s, (g i).prod h = (∑ i in s, g i).prod h :=\nbegin\n  classical,\n  exact finset.induction_on s\n  (by simp [prod_zero_index])\n  (by simp [prod_add_index, h_zero, h_add] {contextual := tt})\nend\n\n@[to_additive]\nlemma prod_sum_index {ι₁ : Type u₁} [decidable_eq ι₁] {β₁ : ι₁ → Type v₁}\n  [Π i₁, has_zero (β₁ i₁)] [Π i (x : β₁ i), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ]\n  {f : Π₀ i₁, β₁ i₁} {g : Π i₁, β₁ i₁ → Π₀ i, β i}\n  {h : Π i, β i → γ} (h_zero : ∀i, h i 0 = 1) (h_add : ∀i b₁ b₂, h i (b₁ + b₂) = h i b₁ * h i b₂) :\n  (f.sum g).prod h = f.prod (λi b, (g i b).prod h) :=\n(prod_finset_sum_index h_zero h_add).symm\n\n@[simp] lemma sum_single [Π i, add_comm_monoid (β i)]\n  [Π i (x : β i), decidable (x ≠ 0)] {f : Π₀ i, β i} :\n  f.sum single = f :=\nbegin\n  have := add_monoid_hom.congr_fun lift_add_hom_single_add_hom f,\n  rw [lift_add_hom_apply, sum_add_hom_apply] at this,\n  exact this,\nend\n\n@[to_additive]\nlemma prod_subtype_domain_index [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n  [comm_monoid γ] {v : Π₀ i, β i} {p : ι → Prop} [decidable_pred p]\n  {h : Π i, β i → γ} (hp : ∀ x ∈ v.support, p x) :\n  (v.subtype_domain p).prod (λi b, h i b) = v.prod h :=\nfinset.prod_bij (λp _, p)\n  (by simp) (by simp)\n  (assume ⟨a₀, ha₀⟩ ⟨a₁, ha₁⟩, by simp)\n  (λ i hi, ⟨⟨i, hp i hi⟩, by simpa using hi, rfl⟩)\n\nomit dec\nlemma subtype_domain_sum [Π i, add_comm_monoid (β i)]\n  {s : finset γ} {h : γ → Π₀ i, β i} {p : ι → Prop} [decidable_pred p] :\n  (∑ c in s, h c).subtype_domain p = ∑ c in s, (h c).subtype_domain p :=\n(subtype_domain_add_monoid_hom β p).map_sum  _ s\n\nlemma subtype_domain_finsupp_sum {δ : γ → Type x} [decidable_eq γ]\n  [Π c, has_zero (δ c)] [Π c (x : δ c), decidable (x ≠ 0)]\n  [Π i, add_comm_monoid (β i)]\n  {p : ι → Prop} [decidable_pred p]\n  {s : Π₀ c, δ c} {h : Π c, δ c → Π₀ i, β i} :\n  (s.sum h).subtype_domain p = s.sum (λc d, (h c d).subtype_domain p) :=\nsubtype_domain_sum\n\nend prod_and_sum\n\n/-! ### Bundled versions of `dfinsupp.map_range`\n\nThe names should match the equivalent bundled `finsupp.map_range` definitions.\n-/\n\nsection map_range\nomit dec\n\nvariables [Π i, add_zero_class (β i)] [Π i, add_zero_class (β₁ i)] [Π i, add_zero_class (β₂ i)]\n\nlemma map_range_add (f : Π i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0)\n  (hf' : ∀ i x y, f i (x + y) = f i x + f i y) (g₁ g₂ : Π₀ i, β₁ i):\n  map_range f hf (g₁ + g₂) = map_range f hf g₁ + map_range f hf g₂ :=\nbegin\n  ext,\n  simp only [map_range_apply f, coe_add, pi.add_apply, hf']\nend\n\n/-- `dfinsupp.map_range` as an `add_monoid_hom`. -/\n@[simps apply]\ndef map_range.add_monoid_hom (f : Π i, β₁ i →+ β₂ i) : (Π₀ i, β₁ i) →+ (Π₀ i, β₂ i) :=\n{ to_fun := map_range (λ i x, f i x) (λ i, (f i).map_zero),\n  map_zero' := map_range_zero _ _,\n  map_add' := map_range_add _ _ (λ i, (f i).map_add) }\n\n@[simp]\nlemma map_range.add_monoid_hom_id :\n  map_range.add_monoid_hom (λ i, add_monoid_hom.id (β₂ i)) = add_monoid_hom.id _ :=\nadd_monoid_hom.ext map_range_id\n\nlemma map_range.add_monoid_hom_comp (f : Π i, β₁ i →+ β₂ i) (f₂ : Π i, β i →+ β₁ i):\n  map_range.add_monoid_hom (λ i, (f i).comp (f₂ i)) =\n    (map_range.add_monoid_hom f).comp (map_range.add_monoid_hom f₂) :=\nadd_monoid_hom.ext $ map_range_comp (λ i x, f i x) (λ i x, f₂ i x) _ _ _\n\n/-- `dfinsupp.map_range.add_monoid_hom` as an `add_equiv`. -/\n@[simps apply]\ndef map_range.add_equiv (e : Π i, β₁ i ≃+ β₂ i) : (Π₀ i, β₁ i) ≃+ (Π₀ i, β₂ i) :=\n{ to_fun := map_range (λ i x, e i x) (λ i, (e i).map_zero),\n  inv_fun := map_range (λ i x, (e i).symm x) (λ i, (e i).symm.map_zero),\n  left_inv := λ x, by rw ←map_range_comp; { simp_rw add_equiv.symm_comp_self, simp },\n  right_inv := λ x, by rw ←map_range_comp; { simp_rw add_equiv.self_comp_symm, simp },\n  .. map_range.add_monoid_hom (λ i, (e i).to_add_monoid_hom) }\n\n@[simp]\nlemma map_range.add_equiv_refl :\n  (map_range.add_equiv $ λ i, add_equiv.refl (β₁ i)) = add_equiv.refl _ :=\nadd_equiv.ext map_range_id\n\nlemma map_range.add_equiv_trans (f : Π i, β i ≃+ β₁ i) (f₂ : Π i, β₁ i ≃+ β₂ i):\n  map_range.add_equiv (λ i, (f i).trans (f₂ i)) =\n    (map_range.add_equiv f).trans (map_range.add_equiv f₂) :=\nadd_equiv.ext $ map_range_comp (λ i x, f₂ i x) (λ i x, f i x) _ _ _\n\n@[simp]\nlemma map_range.add_equiv_symm (e : Π i, β₁ i ≃+ β₂ i) :\n  (map_range.add_equiv e).symm = map_range.add_equiv (λ i, (e i).symm) := rfl\n\nend map_range\n\nend dfinsupp\n\n/-! ### Product and sum lemmas for bundled morphisms.\n\nIn this section, we provide analogues of `add_monoid_hom.map_sum`, `add_monoid_hom.coe_finset_sum`,\nand `add_monoid_hom.finset_sum_apply` for `dfinsupp.sum` and `dfinsupp.sum_add_hom` instead of\n`finset.sum`.\n\nWe provide these for `add_monoid_hom`, `monoid_hom`, `ring_hom`, `add_equiv`, and `mul_equiv`.\n\nLemmas for `linear_map` and `linear_equiv` are in another file.\n-/\nsection\n\nvariables [decidable_eq ι]\n\nnamespace monoid_hom\nvariables {R S : Type*}\nvariables [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n\n@[simp, to_additive]\nlemma map_dfinsupp_prod [comm_monoid R] [comm_monoid S]\n  (h : R →* S) (f : Π₀ i, β i) (g : Π i, β i → R) :\n  h (f.prod g) = f.prod (λ a b, h (g a b)) := h.map_prod _ _\n\n@[to_additive]\nlemma coe_dfinsupp_prod [monoid R] [comm_monoid S]\n  (f : Π₀ i, β i) (g : Π i, β i → R →* S) :\n  ⇑(f.prod g) = f.prod (λ a b, (g a b)) := coe_finset_prod _ _\n\n@[simp, to_additive]\nlemma dfinsupp_prod_apply [monoid R] [comm_monoid S]\n  (f : Π₀ i, β i) (g : Π i, β i → R →* S) (r : R) :\n  (f.prod g) r = f.prod (λ a b, (g a b) r) := finset_prod_apply _ _ _\n\nend monoid_hom\n\nnamespace ring_hom\nvariables {R S : Type*}\nvariables [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n\n@[simp]\nlemma map_dfinsupp_prod [comm_semiring R] [comm_semiring S]\n  (h : R →+* S) (f : Π₀ i, β i) (g : Π i, β i → R) :\n  h (f.prod g) = f.prod (λ a b, h (g a b)) := h.map_prod _ _\n\n@[simp]\nlemma map_dfinsupp_sum [non_assoc_semiring R] [non_assoc_semiring S]\n  (h : R →+* S) (f : Π₀ i, β i) (g : Π i, β i → R) :\n  h (f.sum g) = f.sum (λ a b, h (g a b)) := h.map_sum _ _\n\nend ring_hom\n\nnamespace mul_equiv\nvariables {R S : Type*}\nvariables [Π i, has_zero (β i)] [Π i (x : β i), decidable (x ≠ 0)]\n\n@[simp, to_additive]\nlemma map_dfinsupp_prod [comm_monoid R] [comm_monoid S]\n  (h : R ≃* S) (f : Π₀ i, β i) (g : Π i, β i → R) :\n  h (f.prod g) = f.prod (λ a b, h (g a b)) := h.map_prod _ _\n\nend mul_equiv\n\n/-! The above lemmas, repeated for `dfinsupp.sum_add_hom`. -/\n\nnamespace add_monoid_hom\nvariables {R S : Type*}\n\nopen dfinsupp\n\n@[simp]\nlemma map_dfinsupp_sum_add_hom [add_comm_monoid R] [add_comm_monoid S] [Π i, add_zero_class (β i)]\n  (h : R →+ S) (f : Π₀ i, β i) (g : Π i, β i →+ R) :\n  h (sum_add_hom g f) = sum_add_hom (λ i, h.comp (g i)) f :=\ncongr_fun (comp_lift_add_hom h g) f\n\n@[simp]\nlemma dfinsupp_sum_add_hom_apply [add_zero_class R] [add_comm_monoid S] [Π i, add_zero_class (β i)]\n  (f : Π₀ i, β i) (g : Π i, β i →+ R →+ S) (r : R) :\n  (sum_add_hom g f) r = sum_add_hom (λ i, (eval r).comp (g i)) f :=\nmap_dfinsupp_sum_add_hom (eval r) f g\n\nlemma coe_dfinsupp_sum_add_hom [add_zero_class R] [add_comm_monoid S] [Π i, add_zero_class (β i)]\n  (f : Π₀ i, β i) (g : Π i, β i →+ R →+ S) :\n  ⇑(sum_add_hom g f) = sum_add_hom (λ i, (coe_fn R S).comp (g i)) f :=\nmap_dfinsupp_sum_add_hom (coe_fn R S) f g\n\nend add_monoid_hom\n\nnamespace ring_hom\nvariables {R S : Type*}\n\nopen dfinsupp\n\n@[simp]\nlemma map_dfinsupp_sum_add_hom [non_assoc_semiring R] [non_assoc_semiring S]\n  [Π i, add_zero_class (β i)] (h : R →+* S) (f : Π₀ i, β i) (g : Π i, β i →+ R) :\n  h (sum_add_hom g f) = sum_add_hom (λ i, h.to_add_monoid_hom.comp (g i)) f :=\nadd_monoid_hom.congr_fun (comp_lift_add_hom h.to_add_monoid_hom g) f\n\nend ring_hom\n\nnamespace add_equiv\nvariables {R S : Type*}\n\nopen dfinsupp\n\n@[simp]\nlemma map_dfinsupp_sum_add_hom [add_comm_monoid R] [add_comm_monoid S] [Π i, add_zero_class (β i)]\n  (h : R ≃+ S) (f : Π₀ i, β i) (g : Π i, β i →+ R) :\n  h (sum_add_hom g f) = sum_add_hom (λ i, h.to_add_monoid_hom.comp (g i)) f :=\nadd_monoid_hom.congr_fun (comp_lift_add_hom h.to_add_monoid_hom g) f\n\nend add_equiv\n\nend\n\nsection finite_infinite\n\ninstance dfinsupp.fintype {ι : Sort*} {π : ι → Sort*} [decidable_eq ι] [Π i, has_zero (π i)]\n  [fintype ι] [∀ i, fintype (π i)] :\n  fintype (Π₀ i, π i) :=\nfintype.of_equiv (Π i, π i) dfinsupp.equiv_fun_on_fintype.symm\n\ninstance dfinsupp.infinite_of_left {ι : Sort*} {π : ι → Sort*}\n  [∀ i, nontrivial (π i)] [Π i, has_zero (π i)] [infinite ι] :\n  infinite (Π₀ i, π i) :=\nby letI := classical.dec_eq ι; choose m hm using (λ i, exists_ne (0 : π i)); exact\ninfinite.of_injective _ (dfinsupp.single_left_injective hm)\n\n/-- See `dfinsupp.infinite_of_right` for this in instance form, with the drawback that\nit needs all `π i` to be infinite. -/\nlemma dfinsupp.infinite_of_exists_right {ι : Sort*} {π : ι → Sort*}\n  (i : ι) [infinite (π i)] [Π i, has_zero (π i)] :\n  infinite (Π₀ i, π i) :=\nby letI := classical.dec_eq ι; exact\ninfinite.of_injective (λ j, dfinsupp.single i j) dfinsupp.single_injective\n\n/-- See `dfinsupp.infinite_of_exists_right` for the case that only one `π ι` is infinite. -/\ninstance dfinsupp.infinite_of_right {ι : Sort*} {π : ι → Sort*}\n  [∀ i, infinite (π i)] [Π i, has_zero (π i)] [nonempty ι] :\n  infinite (Π₀ i, π i) :=\ndfinsupp.infinite_of_exists_right (classical.arbitrary ι)\n\nend finite_infinite\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/dfinsupp/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.46568515717821957}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.list.forall2\n\n/-!\n# List sections\n\nThis file proves some stuff about `list.sections` (definition in `data.list.defs`). A section of a\nlist of lists `[l₁, ..., lₙ]` is a list whose `i`-th element comes from the `i`-th list.\n-/\n\n\nopen nat function\n\nnamespace list\nvariables {α β : Type*}\n\ntheorem mem_sections {L : list (list α)} {f} : f ∈ sections L ↔ forall₂ (∈) f L :=\nbegin\n  refine ⟨λ h, _, λ h, _⟩,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall₂.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with ⟨_, _, _, _, rfl⟩,\n    simp only [*, forall₂_cons, true_and] },\n  { induction h with a l f L al fL fs, {exact or.inl rfl},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map],\n    exact ⟨_, fs, _, al, rfl, rfl⟩ }\nend\n\n\n\nlemma rel_sections {r : α → β → Prop} :\n  (forall₂ (forall₂ r) ⇒ forall₂ (forall₂ r)) sections sections\n| _ _ forall₂.nil := forall₂.cons forall₂.nil forall₂.nil\n| _ _ (forall₂.cons h₀ h₁) :=\n  rel_bind (rel_sections h₁) (assume _ _ hl, rel_map (assume _ _ ha, forall₂.cons ha hl) h₀)\n\nend list\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/list/sections.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.672331699179286, "lm_q1q2_score": 0.4656851529125514}}
{"text": "import graph_theory.path\nvariables {V V' V'': Type*}\nopen function\n\nnamespace simple_graph\nopen walk\n\nstructure path_embedding (G : simple_graph V) (G' : simple_graph V') :=\n  (f        : V ↪ V')\n  (df       : Π e : G.dart, G'.walk (f e.fst) (f e.snd))\n  --\n  (nodup    : ∀ e : G.dart, (df e).support.nodup)\n  (sym      : ∀ e : G.dart, df e.symm = (df e).reverse)\n  --\n  (endpoint : ∀ {e x}, f x ∈ (df e).support → x ∈ e.edge)\n  --\n  (disjoint : ∀ {e e' z}, z ∈ (df e).support → z ∈ (df e').support →\n    e.edge = e'.edge ∨ ∃ x, z = f x)\n\ndef embeds_into (G : simple_graph V) (G' : simple_graph V') := nonempty (path_embedding G G')\n\ninfix ` ≼t `:50 := embeds_into -- TODO rename as topological minor\n\nnamespace path_embedding\n\nvariables {G : simple_graph V} {G' : simple_graph V'} {G'' : simple_graph V''}\nvariables (F : path_embedding G G')\nvariables {x y z : V} {x' y' z' : V'} {p : walk G x y} {p' : walk G y z}\n\nlemma nop {e : G.dart} : 0 < (F.df e).length :=\npos_iff_ne_zero.mpr $ λ h, G.ne_of_adj e.is_adj $ F.f.injective $ point_of_size_0 h\n\n@[simp] def follow : Π {x y : V}, walk G x y → walk G' (F.f x) (F.f y)\n| _ _ nil        := nil\n| _ _ (cons h p) := F.df ⟨⟨_,_⟩,h⟩ ++ follow p\n\n@[simp] lemma follow_append : follow F (p ++ p') = follow F p ++ follow F p' :=\nby { induction p, refl, simp only [cons_append,append_assoc,p_ih,follow] }\n\nlemma mem_follow (h₁ : 0 < p.length) (h₂ : z' ∈ (follow F p).support) :\n  ∃ e ∈ darts p, z' ∈ (F.df e).support :=\nbegin\n  induction p with u u v w h p ih, {simp at h₁, contradiction}, clear h₁,\n  simp only [follow, mem_support_append_iff] at h₂, cases h₂,\n  { exact ⟨⟨⟨_,_⟩, h⟩, or.inl rfl, h₂⟩ },\n  { cases p,\n    { refine ⟨⟨⟨_,_⟩,h⟩, or.inl rfl, _⟩, simp only [follow, support_nil, list.mem_singleton] at h₂,\n      rw h₂, exact end_mem_support _ },\n    { specialize ih _ h₂, simp only [length_cons, nat.succ_pos'],\n      choose e h₃ h₄ using ih, exact ⟨e, or.inr h₃, h₄⟩ } }\nend\n\nlemma follow_nodup {p : walk G x y} (h : p.support.nodup) : (follow F p).support.nodup :=\nbegin\n  induction p with u u v w h p ih,\n  { simp only [follow, support_nil, list.nodup_cons, list.not_mem_nil, not_false_iff,\n    list.nodup_nil, and_self] },\n  { simp only [follow], simp only [support_cons, list.nodup_cons] at h, apply nodup_concat.mpr,\n    refine ⟨F.nodup _, ih h.2, _⟩, rintros z h3 h4,\n    cases nat.eq_zero_or_pos p.length with h5 h5,\n    { cases p,\n      { simp only [follow, support_nil, list.mem_singleton] at h4, exact h4 },\n      { simp only [length_cons, nat.succ_ne_zero] at h5, contradiction } },\n    { obtain ⟨e,h7,h8⟩ := mem_follow F h5 h4,\n      cases F.disjoint h3 h8 with h9 h9,\n      { exfalso, apply h.1, apply (mem_of_edges h5).mpr ⟨e,h7,_⟩, rw <-h9,\n        exact sym2.mem_mk_left _ _ },\n      { obtain ⟨v,_⟩ := h9, subst z, have h10 := F.endpoint h3,\n        cases sym2.mem_iff.mp h10 with h10 h10,\n        { subst h10, exfalso, apply h.1,\n          have := F.endpoint h8, rw [dart.edge] at this, rcases e with ⟨⟨ex,ey⟩,he⟩, simp at this,\n          cases this with h12 h12,\n          { rw h12, exact p.dart_fst_mem_support_of_mem_darts h7 },\n          { rw h12, exact p.dart_snd_mem_support_of_mem_darts h7 } },\n        { rw h10 } } } }\nend\n\nlemma follow_rev {p : walk G x y} : follow F p.reverse = (follow F p).reverse :=\nbegin\n  induction p with u u v w h p ih, refl,\n  simp only [ih.symm, follow, reverse_cons, follow_append, append_nil, reverse_append],\n  congr, exact F.sym ⟨⟨_,_⟩,h⟩\nend\n\ndef comp (F : path_embedding G G') (F' : path_embedding G' G'') : path_embedding G G'' :=\n{ f := ⟨F'.f ∘ F.f, injective.comp F'.f.inj' F.f.inj'⟩,\n  df := λ e, follow F' (F.df e),\n  --\n  nodup := λ e, (follow_nodup F') (F.nodup _),\n  sym := by { intro e, rewrite F.sym e, apply follow_rev },\n  --\n  endpoint := by {\n    intros e x h1, obtain ⟨e',h4,h5⟩ := mem_follow F' (nop F) h1,\n    exact F.endpoint ((walk.mem_of_edges (nop _)).mpr ⟨e',h4,F'.endpoint h5⟩)\n  },\n  --\n  disjoint := by {\n    intros e e' z h1 h2,\n    replace h1 := mem_follow _ (nop _) h1, obtain ⟨e1,h3,h4⟩ := h1,\n    replace h2 := mem_follow _ (nop _) h2, obtain ⟨e2,h5,h6⟩ := h2,\n    have h7 := F'.disjoint h4 h6, cases h7,\n    { left, clear h4 h6, replace h3 := walk.mem_edges h3, replace h5 := walk.mem_edges h5,\n      replace h5 : e1.fst ∈ (F.df e').support ∧ e1.snd ∈ (F.df e').support :=\n      by { cases (dart_edge_eq_iff e1 e2).mp h7; subst e1,\n        exact h5, simp only [dart.symm], exact h5.symm },\n      cases F.disjoint h3.1 h5.1 with h10 h10, exact h10, obtain ⟨x,h10⟩ := h10, rw h10 at h3 h5,\n      cases F.disjoint h3.2 h5.2 with h11 h11, exact h11, obtain ⟨y,h11⟩ := h11, rw h11 at h3 h5,\n      have h12 := F.endpoint h3.1, have h13 := F.endpoint h3.2,\n      have h14 := F.endpoint h5.1, have h15 := F.endpoint h5.2,\n      have h16 : x ≠ y := by { intro h, apply G'.ne_of_adj e1.is_adj, convert congr_arg F.f h },\n      exact sym2.eq_of_ne_mem h16 h12 h13 h14 h15 },\n    { obtain ⟨y,h8⟩ := h7, subst z, replace h4 := F'.endpoint h4, replace h6 := F'.endpoint h6,\n      replace h3 := walk.mem_edges h3, replace h5 := walk.mem_edges h5,\n      replace h3 : y ∈ (F.df e).support, by { simp only [dart.edge, sym2.mem_iff] at h4,\n        rcases e1 with ⟨⟨e1x,e1y⟩,e1h⟩, simp at h4,\n        cases h4; subst h4, exact h3.1, exact h3.2 },\n      replace h5 : y ∈ (F.df e').support, by { simp only [dart.edge, sym2.mem_iff] at h6,\n        rcases e2 with ⟨⟨e2x,e2y⟩,e2h⟩, simp at h6,\n        cases h6; subst h6, exact h5.1, exact h5.2 },\n      cases F.disjoint h3 h5 with h9 h9,\n      { left, exact h9 },\n      { obtain ⟨x,h9⟩ := h9, subst h9, right, use x, refl } } } }\n\ntheorem trans : embeds_into G G' → embeds_into G' G'' → embeds_into G G'' :=\nλ ⟨F⟩ ⟨F'⟩, ⟨comp F F'⟩\n\ndef from_hom (f : G →g G') (inj : injective f) : path_embedding G G' :=\n{ f := ⟨f, inj⟩,\n  df := λ e, cons (f.map_rel' e.is_adj) nil,\n  nodup := λ e, by {\n    simp only [support_cons, embedding.coe_fn_mk, support_nil, rel_hom.coe_fn_to_fun,\n              list.nodup_cons, list.mem_singleton, list.not_mem_nil, not_false_iff,\n              list.nodup_nil, and_true],\n    exact G'.ne_of_adj (f.map_rel' e.is_adj) },\n  sym := λ e, by {\n    simp only [dart.symm, reverse_cons, reverse_nil, nil_append, rel_hom.coe_fn_to_fun,\n              embedding.coe_fn_mk, eq_self_iff_true, heq_iff_eq, and_self], simp },\n  --\n  endpoint := λ e x h, by {\n    simp only [embedding.coe_fn_mk, support_cons, support_nil, rel_hom.coe_fn_to_fun,\n              list.mem_cons_iff, list.mem_singleton] at h,\n    simp only [dart.edge, sym2.mem_iff], rcases e with ⟨⟨ex,ey⟩,eh⟩, simp,\n    cases h, { left, exact inj h }, { right, exact inj h } },\n  --\n  disjoint := by { intros e e' z h₁ h₂, right, cases h₁, subst h₁, exact ⟨e.fst,rfl⟩,\n    cases h₁, subst h₁, exact ⟨e.snd,rfl⟩, cases h₁ } }\n\nend path_embedding\nend simple_graph\n", "meta": {"author": "vbeffara", "repo": "lean", "sha": "0004b1d502ac3f4ccd213dbd23589d4c4f9fece8", "save_path": "github-repos/lean/vbeffara-lean", "path": "github-repos/lean/vbeffara-lean/lean-0004b1d502ac3f4ccd213dbd23589d4c4f9fece8/src/graph_theory/path_embedding.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.46568514836500713}}
{"text": "/-\nCopyright (c) 2021 Mario Carneiro All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport algebra.big_operators.norm_num\nimport data.nat.squarefree\nimport data.int.gcd\nimport data.nat.fib\nimport data.nat.prime\nimport data.nat.sqrt_norm_num\nimport analysis.special_functions.pow\nimport number_theory.legendre_symbol.norm_num\n\n/-!\n# Tests for `norm_num` extensions\n-/\n\n-- coverage tests\nexample : nat.sqrt 0 = 0 := by norm_num\nexample : nat.sqrt 1 = 1 := by norm_num\nexample : nat.sqrt 2 = 1 := by norm_num\nexample : nat.sqrt 3 = 1 := by norm_num\nexample : nat.sqrt 4 = 2 := by norm_num\nexample : nat.sqrt 9 = 3 := by norm_num\nexample : nat.sqrt 10 = 3 := by norm_num\nexample : nat.sqrt 100 = 10 := by norm_num\nexample : nat.sqrt 120 = 10 := by norm_num\nexample : nat.sqrt 121 = 11 := by norm_num\n\nexample : nat.coprime 1 2 := by norm_num\nexample : nat.coprime 2 1 := by norm_num\nexample : ¬ nat.coprime 0 0 := by norm_num\nexample : ¬ nat.coprime 0 3 := by norm_num\nexample : ¬ nat.coprime 2 0 := by norm_num\nexample : nat.coprime 2 3 := by norm_num\nexample : ¬ nat.coprime 2 4 := by norm_num\n\nexample : nat.gcd 1 2 = 1 := by norm_num\nexample : nat.gcd 2 1 = 1 := by norm_num\nexample : nat.gcd 0 0 = 0 := by norm_num\nexample : nat.gcd 0 3 = 3 := by norm_num\nexample : nat.gcd 2 0 = 2 := by norm_num\nexample : nat.gcd 2 3 = 1 := by norm_num\nexample : nat.gcd 2 4 = 2 := by norm_num\n\nexample : nat.lcm 1 2 = 2 := by norm_num\nexample : nat.lcm 2 1 = 2 := by norm_num\nexample : nat.lcm 0 0 = 0 := by norm_num\nexample : nat.lcm 0 3 = 0 := by norm_num\nexample : nat.lcm 2 0 = 0 := by norm_num\nexample : nat.lcm 2 3 = 6 := by norm_num\nexample : nat.lcm 2 4 = 4 := by norm_num\n\nexample : int.gcd 2 3 = 1 := by norm_num\nexample : int.gcd (-2) 3 = 1 := by norm_num\nexample : int.gcd 2 (-3) = 1 := by norm_num\nexample : int.gcd (-2) (-3) = 1 := by norm_num\n\nexample : int.lcm 2 3 = 6 := by norm_num\nexample : int.lcm (-2) 3 = 6 := by norm_num\nexample : int.lcm 2 (-3) = 6 := by norm_num\nexample : int.lcm (-2) (-3) = 6 := by norm_num\n\nexample : ¬ nat.prime 0 := by norm_num\nexample : ¬ nat.prime 1 := by norm_num\nexample : nat.prime 2 := by norm_num\nexample : nat.prime 3 := by norm_num\nexample : ¬ nat.prime 4 := by norm_num\nexample : nat.prime 5 := by norm_num\nexample : nat.prime 109 := by norm_num\nexample : nat.prime 1277 := by norm_num\nexample : ¬ nat.prime 1000000000000000000000000000000000000000000000000 := by norm_num\n\nexample : nat.min_fac 0 = 2 := by norm_num\nexample : nat.min_fac 1 = 1 := by norm_num\nexample : nat.min_fac 2 = 2 := by norm_num\nexample : nat.min_fac 3 = 3 := by norm_num\nexample : nat.min_fac 4 = 2 := by norm_num\nexample : nat.min_fac 121 = 11 := by norm_num\nexample : nat.min_fac 221 = 13 := by norm_num\n\nexample : nat.factors 0 = [] := by norm_num\nexample : nat.factors 1 = [] := by norm_num\nexample : nat.factors 2 = [2] := by norm_num\nexample : nat.factors 3 = [3] := by norm_num\nexample : nat.factors 4 = [2, 2] := by norm_num\nexample : nat.factors 12 = [2, 2, 3] := by norm_num\nexample : nat.factors 221 = [13, 17] := by norm_num\n\n-- randomized tests\nexample : nat.gcd 35 29 = 1 := by norm_num\nexample : int.gcd 35 29 = 1 := by norm_num\nexample : nat.lcm 35 29 = 1015 := by norm_num\nexample : int.gcd 35 29 = 1 := by norm_num\nexample : nat.coprime 35 29 := by norm_num\n\nexample : nat.gcd 80 2 = 2 := by norm_num\nexample : int.gcd 80 2 = 2 := by norm_num\nexample : nat.lcm 80 2 = 80 := by norm_num\nexample : int.gcd 80 2 = 2 := by norm_num\nexample : ¬ nat.coprime 80 2 := by norm_num\n\nexample : nat.gcd 19 17 = 1 := by norm_num\nexample : int.gcd 19 17 = 1 := by norm_num\nexample : nat.lcm 19 17 = 323 := by norm_num\nexample : int.gcd 19 17 = 1 := by norm_num\nexample : nat.coprime 19 17 := by norm_num\n\nexample : nat.gcd 11 18 = 1 := by norm_num\nexample : int.gcd 11 18 = 1 := by norm_num\nexample : nat.lcm 11 18 = 198 := by norm_num\nexample : int.gcd 11 18 = 1 := by norm_num\nexample : nat.coprime 11 18 := by norm_num\n\nexample : nat.gcd 23 73 = 1 := by norm_num\nexample : int.gcd 23 73 = 1 := by norm_num\nexample : nat.lcm 23 73 = 1679 := by norm_num\nexample : int.gcd 23 73 = 1 := by norm_num\nexample : nat.coprime 23 73 := by norm_num\n\nexample : nat.gcd 73 68 = 1 := by norm_num\nexample : int.gcd 73 68 = 1 := by norm_num\nexample : nat.lcm 73 68 = 4964 := by norm_num\nexample : int.gcd 73 68 = 1 := by norm_num\nexample : nat.coprime 73 68 := by norm_num\n\nexample : nat.gcd 28 16 = 4 := by norm_num\nexample : int.gcd 28 16 = 4 := by norm_num\nexample : nat.lcm 28 16 = 112 := by norm_num\nexample : int.gcd 28 16 = 4 := by norm_num\nexample : ¬ nat.coprime 28 16 := by norm_num\n\nexample : nat.gcd 44 98 = 2 := by norm_num\nexample : int.gcd 44 98 = 2 := by norm_num\nexample : nat.lcm 44 98 = 2156 := by norm_num\nexample : int.gcd 44 98 = 2 := by norm_num\nexample : ¬ nat.coprime 44 98 := by norm_num\n\nexample : nat.gcd 21 79 = 1 := by norm_num\nexample : int.gcd 21 79 = 1 := by norm_num\nexample : nat.lcm 21 79 = 1659 := by norm_num\nexample : int.gcd 21 79 = 1 := by norm_num\nexample : nat.coprime 21 79 := by norm_num\n\nexample : nat.gcd 93 34 = 1 := by norm_num\nexample : int.gcd 93 34 = 1 := by norm_num\nexample : nat.lcm 93 34 = 3162 := by norm_num\nexample : int.gcd 93 34 = 1 := by norm_num\nexample : nat.coprime 93 34 := by norm_num\n\nexample : ¬ nat.prime 912 := by norm_num\nexample : nat.min_fac 912 = 2 := by norm_num\nexample : nat.factors 912 = [2, 2, 2, 2, 3, 19] := by norm_num\n\nexample : ¬ nat.prime 681 := by norm_num\nexample : nat.min_fac 681 = 3 := by norm_num\nexample : nat.factors 681 = [3, 227] := by norm_num\n\nexample : ¬ nat.prime 728 := by norm_num\nexample : nat.min_fac 728 = 2 := by norm_num\nexample : nat.factors 728 = [2, 2, 2, 7, 13] := by norm_num\n\nexample : ¬ nat.prime 248 := by norm_num\nexample : nat.min_fac 248 = 2 := by norm_num\nexample : nat.factors 248 = [2, 2, 2, 31] := by norm_num\n\nexample : ¬ nat.prime 682 := by norm_num\nexample : nat.min_fac 682 = 2 := by norm_num\nexample : nat.factors 682 = [2, 11, 31] := by norm_num\n\nexample : ¬ nat.prime 115 := by norm_num\nexample : nat.min_fac 115 = 5 := by norm_num\nexample : nat.factors 115 = [5, 23] := by norm_num\n\nexample : ¬ nat.prime 824 := by norm_num\nexample : nat.min_fac 824 = 2 := by norm_num\nexample : nat.factors 824 = [2, 2, 2, 103] := by norm_num\n\nexample : ¬ nat.prime 942 := by norm_num\nexample : nat.min_fac 942 = 2 := by norm_num\nexample : nat.factors 942 = [2, 3, 157] := by norm_num\n\nexample : ¬ nat.prime 34 := by norm_num\nexample : nat.min_fac 34 = 2 := by norm_num\nexample : nat.factors 34 = [2, 17] := by norm_num\n\nexample : ¬ nat.prime 754 := by norm_num\nexample : nat.min_fac 754 = 2 := by norm_num\nexample : nat.factors 754 = [2, 13, 29] := by norm_num\n\nexample : ¬ nat.prime 663 := by norm_num\nexample : nat.min_fac 663 = 3 := by norm_num\nexample : nat.factors 663 = [3, 13, 17] := by norm_num\n\nexample : ¬ nat.prime 923 := by norm_num\nexample : nat.min_fac 923 = 13 := by norm_num\nexample : nat.factors 923 = [13, 71] := by norm_num\n\nexample : ¬ nat.prime 77 := by norm_num\nexample : nat.min_fac 77 = 7 := by norm_num\nexample : nat.factors 77 = [7, 11] := by norm_num\n\nexample : ¬ nat.prime 162 := by norm_num\nexample : nat.min_fac 162 = 2 := by norm_num\nexample : nat.factors 162 = [2, 3, 3, 3, 3] := by norm_num\n\nexample : ¬ nat.prime 669 := by norm_num\nexample : nat.min_fac 669 = 3 := by norm_num\nexample : nat.factors 669 = [3, 223] := by norm_num\n\nexample : ¬ nat.prime 476 := by norm_num\nexample : nat.min_fac 476 = 2 := by norm_num\nexample : nat.factors 476 = [2, 2, 7, 17] := by norm_num\n\nexample : nat.prime 251 := by norm_num\nexample : nat.min_fac 251 = 251 := by norm_num\nexample : nat.factors 251 = [251] := by norm_num\n\nexample : ¬ nat.prime 129 := by norm_num\nexample : nat.min_fac 129 = 3 := by norm_num\nexample : nat.factors 129 = [3, 43] := by norm_num\n\nexample : ¬ nat.prime 471 := by norm_num\nexample : nat.min_fac 471 = 3 := by norm_num\nexample : nat.factors 471 = [3, 157] := by norm_num\n\nexample : ¬ nat.prime 851 := by norm_num\nexample : nat.min_fac 851 = 23 := by norm_num\nexample : nat.factors 851 = [23, 37] := by norm_num\n\nexample : ¬ squarefree 0 := by norm_num\nexample : squarefree 1 := by norm_num\nexample : squarefree 2 := by norm_num\nexample : squarefree 3 := by norm_num\nexample : ¬ squarefree 4 := by norm_num\nexample : squarefree 5 := by norm_num\nexample : squarefree 6 := by norm_num\nexample : squarefree 7 := by norm_num\nexample : ¬ squarefree 8 := by norm_num\nexample : ¬ squarefree 9 := by norm_num\nexample : squarefree 10 := by norm_num\nexample : squarefree (2*3*5*17) := by norm_num\nexample : ¬ squarefree (2*3*5*5*17) := by norm_num\nexample : squarefree 251 := by norm_num\n\nexample : nat.fib 0 = 0 := by norm_num\nexample : nat.fib 1 = 1 := by norm_num\nexample : nat.fib 2 = 1 := by norm_num\nexample : nat.fib 3 = 2 := by norm_num\nexample : nat.fib 4 = 3 := by norm_num\nexample : nat.fib 5 = 5 := by norm_num\nexample : nat.fib 6 = 8 := by norm_num\nexample : nat.fib 7 = 13 := by norm_num\nexample : nat.fib 8 = 21 := by norm_num\nexample : nat.fib 9 = 34 := by norm_num\nexample : nat.fib 10 = 55 := by norm_num\nexample : nat.fib 37 = 24157817 := by norm_num\nexample : nat.fib 64 = 10610209857723 := by norm_num\nexample : nat.fib 100 + nat.fib 101 = nat.fib 102 := by norm_num\n\nexample : (2 : ℝ) ^ (3 : ℝ) = 8 := by norm_num\nexample : (1 : ℝ) ^ (20 : ℝ) = 1 := by norm_num\nexample : (2 : ℝ) ^ (-3 : ℝ) = 1/8 := by norm_num\n\nsection big_operators\n\nvariables {α : Type*} [comm_ring α]\n\nopen_locale big_operators\n\n-- Lists:\nexample : ([1, 2, 1, 3]).sum = 7 := by norm_num [-list.sum_cons]\nexample : (([1, 2, 1, 3] : list ℚ).map (λ i, i^2)).sum = 15 := by norm_num [-list.map]\nexample : (list.range 10).sum = 45 := by norm_num [-list.range_succ]\nexample : (list.fin_range 10).sum = 45 := by norm_num [-list.fin_range_succ]\n\n-- Multisets:\nexample : (1 ::ₘ 2 ::ₘ 1 ::ₘ 3 ::ₘ {}).sum = 7 := by norm_num [-multiset.sum_cons]\nexample : ((1 ::ₘ 2 ::ₘ 1 ::ₘ 3 ::ₘ {}).map (λ i, i^2)).sum = 15 := by norm_num [-multiset.map_cons]\nexample : (({1, 2, 1, 3} : multiset ℚ).map (λ i, i^2)).sum = 15 := by norm_num [-multiset.map_cons]\nexample : (multiset.range 10).sum = 45 := by norm_num [-multiset.map_cons, -multiset.range_succ]\nexample : (↑[1, 2, 1, 3] : multiset ℕ).sum = 7 := by norm_num\n\n-- Finsets:\nexample (f : fin 0 → α) : ∑ i : fin 0, f i = 0 := by norm_num\nexample (f : ℕ → α) : ∑ i in (∅ : finset ℕ), f i = 0 := by norm_num\nexample (f : fin 3 → α) : ∑ i : fin 3, f i = f 0 + f 1 + f 2 := by norm_num; ring\nexample (f : fin 4 → α) : ∑ i : fin 4, f i = f 0 + f 1 + f 2 + f 3 := by norm_num; ring\nexample (f : ℕ → α) : ∑ i in {0, 1, 2}, f i = f 0 + f 1 + f 2 := by norm_num; ring\nexample (f : ℕ → α) : ∑ i in {0, 2, 2, 3, 1, 0}, f i = f 0 + f 1 + f 2 + f 3 := by norm_num; ring\nexample (f : ℕ → α) : ∑ i in {0, 2, 2 - 3, 3 - 1, 1, 0}, f i = f 0 + f 1 + f 2 := by norm_num; ring\nexample : (∑ i in finset.range 10, (i^2 : ℕ)) = 285 := by norm_num\nexample : (∑ i in finset.Icc 5 10, (i^2 : ℕ)) = 355 := by norm_num\nexample : (∑ i in finset.Ico 5 10, (i^2 : ℕ)) = 255 := by norm_num\nexample : (∑ i in finset.Ioc 5 10, (i^2 : ℕ)) = 330 := by norm_num\nexample : (∑ i in finset.Ioo 5 10, (i^2 : ℕ)) = 230 := by norm_num\nexample : (∑ i : ℤ in finset.Ioo (-5) 5, i^2) = 60 := by norm_num\nexample (f : ℕ → α) : ∑ i in finset.mk {0, 1, 2} dec_trivial, f i = f 0 + f 1 + f 2 :=\n  by norm_num; ring\n\n-- Combined with other `norm_num` extensions:\nexample : ∏ i in finset.range 9, nat.sqrt (i + 1) = 96 := by norm_num\nexample : ∏ i in {1, 4, 9, 16}, nat.sqrt i = 24 := by norm_num\nexample : ∏ i in finset.Icc 0 8, nat.sqrt (i + 1) = 96 := by norm_num\n\n-- Nested operations:\nexample : ∑ i : fin 2, ∑ j : fin 2, ![![0, 1], ![2, 3]] i j = 6 := by norm_num\n\nend big_operators\n\nsection jacobi\n\n-- Jacobi and Legendre symbols\n\nopen_locale number_theory_symbols\n\nexample : J(123 | 335) = -1 := by norm_num\nexample : J(-2345 | 6789) = -1 := by norm_num\nexample : J(-1 | 1655801) = 1 := by norm_num\nexample : J(-102334155 | 165580141) = -1 := by norm_num\n\nexample : J(58378362899022564339483801989973056405585914719065 |\n            53974350278769849773003214636618718468638750007307) = -1 := by norm_num\n\nexample : J(3 + 4 | 3 * 5) = -1 := by norm_num\nexample : J(J(-1 | 7) | 11) = -1 := by norm_num\n\ninstance prime_1000003 : fact (nat.prime 1000003) := ⟨by norm_num⟩\nexample : legendre_sym 1000003 7 = -1 := by norm_num\n\nend jacobi\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/norm_num_ext.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.46564843066688394}}
{"text": "import M4R.Algebra.Ring.Defs\n\nnamespace M4R\n\n  namespace NCSemiring\n\n    protected instance Product (α₁ : Type _) (α₂ : Type _) [NCSemiring α₁] [NCSemiring α₂] : NCSemiring (α₁ × α₂) where\n      one               := (1, 1)\n      mul               := fun (a₁, a₂) (b₁, b₂) => (a₁ * b₁, a₂ * b₂)\n      mul_one           := fun (a₁, a₂) => by simp [HMul.hMul, Mul.mul]; exact ⟨mul_one a₁, mul_one a₂⟩\n      one_mul           := fun (a₁, a₂) => by simp [HMul.hMul, Mul.mul]; exact ⟨one_mul a₁, one_mul a₂⟩\n      mul_assoc         := fun (a₁, a₂) (b₁, b₂) (c₁, c₂) => by\n        simp [HMul.hMul, Mul.mul];exact ⟨mul_assoc a₁ b₁ c₁, mul_assoc a₂ b₂ c₂⟩\n      mul_distrib_left  := fun (a₁, a₂) (b₁, b₂) (c₁, c₂) => by\n        simp [HMul.hMul, Mul.mul, HAdd.hAdd, Add.add]; exact ⟨mul_distrib_left a₁ b₁ c₁, mul_distrib_left a₂ b₂ c₂⟩\n      mul_distrib_right := fun (a₁, a₂) (b₁, b₂) (c₁, c₂) => by\n        simp [HMul.hMul, Mul.mul, HAdd.hAdd, Add.add]; exact ⟨mul_distrib_right a₁ b₁ c₁, mul_distrib_right a₂ b₂ c₂⟩\n      mul_zero          := fun (a₁, a₂) => by\n        simp [HMul.hMul, Mul.mul, Monoid.product_zero]; exact ⟨mul_zero a₁, mul_zero a₂⟩\n      zero_mul          := fun (a₁, a₂) => by\n        simp [HMul.hMul, Mul.mul, Monoid.product_zero]; exact ⟨zero_mul a₁, zero_mul a₂⟩\n\n    theorem product_mul {α₁ : Type _} {α₂ : Type _} [NCSemiring α₁] [NCSemiring α₂] : ∀ x y : α₁ × α₂, x * y = (x.fst * y.fst, x.snd * y.snd) :=\n      fun (x₁, x₂) (y₁, y₂) => rfl\n\n    protected instance multi_product.One {ι : Type _} (fι : ι → Type _) [∀ i, One (fι i)] : One (MultiProd fι) where\n      one := fun _ => 1\n    protected theorem multi_product.One_def {ι : Type _} {fι : ι → Type _} [∀ i, One (fι i)] : ∀ i, (1 : MultiProd fι) i = 1 :=\n      fun _ => rfl\n\n    protected instance multi_product.Mul {ι : Type _} (fι : ι → Type _) [∀ i, Mul (fι i)] : Mul (MultiProd fι) where\n      mul := fun a b i => a i * b i\n    protected theorem multi_product.Mul_def {ι : Type _} {fι : ι → Type _} [∀ i, Mul (fι i)] (a b : MultiProd fι) :\n      ∀ i, (a * b) i = a i * b i := fun _ => rfl\n\n    protected instance multi_product {ι : Type _} (fι : ι → Type _) [∀ i, NCSemiring (fι i)] : NCSemiring (MultiProd fι) where\n      mul_one           := fun a => funext fun i => NCSemiring.mul_one (a i)\n      one_mul           := fun a => funext fun i => NCSemiring.one_mul (a i)\n      mul_assoc         := fun a b c => funext fun i => NCSemiring.mul_assoc (a i) (b i) (c i)\n      mul_distrib_left  := fun a b c => funext fun i => NCSemiring.mul_distrib_left (a i) (b i) (c i)\n      mul_distrib_right := fun a b c => funext fun i => NCSemiring.mul_distrib_right (a i) (b i) (c i)\n      mul_zero          := fun a => funext fun i => NCSemiring.mul_zero (a i)\n      zero_mul          := fun a => funext fun i => NCSemiring.zero_mul (a i)\n\n    theorem ofNat.preserve_succ [NCSemiring α] (n : Nat) : n.succ = (n : α) + 1 := by\n      induction n with\n      | zero => simp only [NCSemiring.ofNat, Monoid.zero_add]\n      | succ k ih => rfl\n\n    theorem ofNat.preserve_add [NCSemiring α] (m n : Nat) : m + n = (m : α) + n := by\n      induction n with\n      | zero => simp only [NCSemiring.ofNat, Monoid.add_zero]; rfl\n      | succ k ih => rw [Nat.add_succ, preserve_succ, preserve_succ, ih, Monoid.add_assoc]\n\n    theorem mul_nat_succ [NCSemiring α] (a : α) (n : Nat) : n.succ * a = n * a + a := by\n      rw [ofNat.preserve_succ, mul_distrib_right, one_mul]\n\n    theorem pow_nat_succ [NCSemiring α] (a : α) (x : Nat) : a ^ (Nat.succ x) = a^x * a :=\n      match x with\n      | Nat.zero => by simp only [HPow.hPow, Pow.pow, NCSemiring.pow_nat, one_mul]\n      | Nat.succ k  => rfl\n\n    theorem pow_nat_one [NCSemiring α] (n : Nat) : (1 : α)^n = 1 := by\n      induction n with\n      | zero      => rfl\n      | succ k ih => rw [pow_nat_succ, ih, one_mul]\n    theorem pow_nat_0 [NCSemiring α] (a : α) : a ^ (0 : Nat) = 1 := rfl\n    theorem pow_nat_1 [NCSemiring α] (a : α) : a ^ (1 : Nat) = a := rfl\n\n    theorem pow_nat_add_distrib [NCSemiring α] (a : α) (m n : Nat) : a^(m + n) = a^m * a^n := by\n      induction n with\n      | zero      => rw [Nat.add_zero, pow_nat_0, mul_one]\n      | succ k ih => rw [Nat.add_succ, pow_nat_succ, pow_nat_succ, ←mul_assoc, ih]\n\n    protected class constructor_ncsr (α : Type _) extends CommMonoid.constructor_cm α, One α, Mul α where\n      mul_one           : ∀ a : α, a * 1 = a\n      one_mul           : ∀ a : α, 1 * a = a\n      mul_assoc         : ∀ a b c : α, (a * b) * c = a * (b * c)\n      mul_distrib_left  : ∀ a b c : α, a * (b + c) = a * b + a * c\n      mul_distrib_right : ∀ a b c : α, (a + b) * c = a * c + b * c\n      mul_zero          : ∀ a : α, a * 0 = 0\n      zero_mul          : ∀ a : α, 0 * a = 0\n\n    protected def construct {α : Type _} (c : NCSemiring.constructor_ncsr α) : NCSemiring α where\n      toCommMonoid := CommMonoid.construct c.toconstructor_cm\n      mul_one           := c.mul_one\n      one_mul           := c.one_mul\n      mul_assoc         := c.mul_assoc\n      mul_distrib_left  := c.mul_distrib_left\n      mul_distrib_right := c.mul_distrib_right\n      mul_zero          := c.mul_zero\n      zero_mul          := c.zero_mul\n\n    protected def to_constructor (α : Type _) [NCSemiring α] : NCSemiring.constructor_ncsr α where\n      toconstructor_cm := CommMonoid.to_constructor α\n      mul_one           := NCSemiring.mul_one\n      one_mul           := NCSemiring.one_mul\n      mul_assoc         := NCSemiring.mul_assoc\n      mul_distrib_left  := NCSemiring.mul_distrib_left\n      mul_distrib_right := NCSemiring.mul_distrib_right\n      mul_zero          := NCSemiring.mul_zero\n      zero_mul          := NCSemiring.zero_mul\n\n  end NCSemiring\n\n  namespace Semiring\n    open NCSemiring\n\n    protected instance Product (α₁ : Type _) (α₂ : Type _) [Semiring α₁] [Semiring α₂] : Semiring (α₁ × α₂) where\n      mul_comm := fun (a₁, a₂) (b₁, b₂) => by simp [HMul.hMul, Mul.mul]; exact ⟨mul_comm a₁ b₁, mul_comm a₂ b₂⟩\n\n    protected instance multi_product {ι : Type _} (fι : ι → Type _) [∀ i, Semiring (fι i)] : Semiring (MultiProd fι) where\n      mul_comm := fun a b => funext fun i => Semiring.mul_comm (a i) (b i)\n\n    theorem mul_right_comm [Semiring α] (a b c : α) : a * b * c = a * c * b := by\n      rw [mul_assoc, mul_comm b, ←mul_assoc]\n    theorem mul_left_comm [Semiring α] (a b c : α) : a * (b * c) = b * (a * c) := by\n      rw [←mul_assoc, mul_comm a, mul_assoc]\n\n    theorem divides_self [Semiring α] (a : α) : a ÷ a := ⟨1, mul_one a⟩\n    theorem divides_zero [Semiring α] (a : α) : a ÷ 0 := ⟨0, mul_zero a⟩\n    theorem divides_add [Semiring α] {a b c : α} : a ÷ b → a ÷ c → a ÷ (b + c)\n    | ⟨x, axb⟩, ⟨y, ayc⟩ => ⟨x + y, by rw [mul_distrib_left, axb, ayc]⟩\n    theorem divides_mul [Semiring α] {a b : α} (c : α) : a ÷ b → a ÷ (b * c)\n    | ⟨x, axb⟩ => ⟨x * c, by rw [←mul_assoc, axb]⟩\n    theorem divides_mul' [Semiring α] {a c : α} (b : α) : a ÷ c → a ÷ (b * c) := by\n      rw [mul_comm]; exact divides_mul b\n\n    theorem isUnit_1 [Semiring α] : isUnit (1 : α) := ⟨1, by simp [one_mul]⟩\n    theorem notUnit_0 [Semiring α] : (0 : α) ≠ (1 : α) → ¬isUnit (0 : α) := by\n      intro h₁ ⟨_, h₂⟩; rw [zero_mul] at h₂; exact h₁ h₂\n    theorem unit_mul [Semiring α] {a b : α} : isUnit a → isUnit b → isUnit (a * b)\n    | ⟨x, xs⟩, ⟨y, ys⟩ => by\n      apply Exists.intro (y * x); rw [mul_assoc, ←mul_assoc b, ys, one_mul, xs]\n    theorem divides_unit [Semiring α] {a b : α} : isUnit b → a ÷ b → isUnit a := by\n      intro ub ab\n      let ⟨binv, bbinv⟩ := Classical.indefiniteDescription _ ub\n      let ⟨c, ac⟩ := Classical.indefiniteDescription _ ab\n      exact ⟨c * binv, by rw [←mul_assoc, ac, bbinv]⟩\n    theorem unit_divides [Semiring α] : ∀ a b : α, isUnit a → a ÷ b := by\n      intro a b ⟨c, ac⟩; exact ⟨c * b, by rw [←mul_assoc, ac, one_mul]⟩\n\n    def unit_set (α : Type _) [Semiring α] : Set α := {x | isUnit x}\n\n    noncomputable def unit_inv [Semiring α] {a : α} (h : isUnit a) : α :=\n      Classical.choose h\n    theorem mul_unit_inv [Semiring α] {a : α} (h : isUnit a) : a * unit_inv h = 1 :=\n      Classical.choose_spec h\n    theorem unit_inv_mul [Semiring α] {a : α} (h : isUnit a) : unit_inv h * a = 1 := by\n      rw [mul_comm]; exact mul_unit_inv h\n\n    noncomputable instance UnitGroup [Semiring α] : Group ↑(unit_set α) := Group.construct\n    {\n      zero := ⟨1, ⟨1, by rw [mul_one]⟩⟩\n      add := fun a b => ⟨a.val * b.val, unit_mul a.property b.property⟩\n      neg := fun ⟨x, xs⟩ => ⟨unit_inv xs, x, unit_inv_mul xs⟩\n      add_zero := fun ⟨a, _⟩ => Set.elementExt (mul_one a)\n      add_assoc := fun ⟨a, _⟩ ⟨b, _⟩ ⟨c, _⟩ => Set.elementExt (mul_assoc a b c)\n      add_neg := fun ⟨a, as⟩ => Set.elementExt (mul_unit_inv as)\n    }\n\n    theorem pow_nat_mul_distrib [Semiring α] (a b : α) (m : Nat) : (a * b)^m = a^m * b^m := by\n      induction m with\n      | zero      => simp only [Nat.zero_eq, pow_nat_0, mul_one]\n      | succ k ih => simp only [pow_nat_succ, ←mul_assoc, ih, mul_comm]\n\n    theorem pow_nat_comp [Semiring α] (a : α) (m n : Nat) : (a^m)^n = a^(m*n) := by\n      induction m with\n      | zero => rw [Nat.zero_mul, pow_nat_0, pow_nat_one]\n      | succ k ih => rw [pow_nat_succ, Nat.succ_mul, pow_nat_mul_distrib, ih, pow_nat_add_distrib]\n\n    protected class constructor_sr (α : Type _) extends CommMonoid.constructor_cm α, One α, Mul α where\n      mul_one           : ∀ a : α, a * 1 = a\n      mul_assoc         : ∀ a b c : α, (a * b) * c = a * (b * c)\n      mul_distrib_left  : ∀ a b c : α, a * (b + c) = a * b + a * c\n      mul_zero          : ∀ a : α, a * 0 = 0\n      mul_comm          : ∀ a b : α, a * b = b * a\n\n    protected def construct {α : Type _} (c : Semiring.constructor_sr α) : Semiring α where\n      toCommMonoid      := CommMonoid.construct c.toconstructor_cm\n      mul_one           := c.mul_one\n      one_mul           := fun a => by rw [c.mul_comm]; exact c.mul_one a\n      mul_assoc         := c.mul_assoc\n      mul_distrib_left  := c.mul_distrib_left\n      mul_distrib_right := fun a b _ => by rw [c.mul_comm, c.mul_comm a, c.mul_comm b]; exact c.mul_distrib_left _ _ _\n      mul_zero          := c.mul_zero\n      zero_mul          := fun a => by rw [c.mul_comm]; exact c.mul_zero a\n      mul_comm          := c.mul_comm\n\n    protected def to_constructor (α : Type _) [Semiring α] : Semiring.constructor_sr α where\n      toconstructor_cm  := CommMonoid.to_constructor α\n      mul_one           := mul_one\n      mul_assoc         := mul_assoc\n      mul_distrib_left  := mul_distrib_left\n      mul_zero          := mul_zero\n      mul_comm          := mul_comm\n\n  end Semiring\n\n  instance NatSemiring : Semiring Nat := Semiring.construct\n    {\n      toconstructor_cm  := NatMonoid.to_constructor\n      mul_one           := Nat.mul_one\n      mul_assoc         := Nat.mul_assoc\n      mul_distrib_left  := Nat.left_distrib\n      mul_zero          := Nat.mul_zero\n      mul_comm          := Nat.mul_comm\n    }\n\nend M4R\n", "meta": {"author": "Hop311", "repo": "M4R", "sha": "ebd1b04af344f9737d290bf8b48b3cde35e9787b", "save_path": "github-repos/lean/Hop311-M4R", "path": "github-repos/lean/Hop311-M4R/M4R-ebd1b04af344f9737d290bf8b48b3cde35e9787b/M4R/Algebra/Ring/Semiring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581097540519, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.46554047836825696}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport group_theory.finiteness\nimport ring_theory.adjoin.tower\nimport ring_theory.finiteness\nimport ring_theory.noetherian\n\n/-!\n# Finiteness conditions in commutative algebra\n\nIn this file we define a notion of finiteness that is common in commutative algebra.\n\n## Main declarations\n\n- `algebra.finite_type`, `ring_hom.finite_type`, `alg_hom.finite_type`\n  all of these express that some object is finitely generated *as algebra* over some base ring.\n\n-/\n\nopen function (surjective)\nopen_locale big_operators polynomial\n\nsection module_and_algebra\n\nvariables (R A B M N : Type*)\n\n/-- An algebra over a commutative semiring is of `finite_type` if it is finitely generated\nover the base ring as algebra. -/\nclass algebra.finite_type [comm_semiring R] [semiring A] [algebra R A] : Prop :=\n(out : (⊤ : subalgebra R A).fg)\n\nnamespace module\n\nvariables [semiring R] [add_comm_monoid M] [module R M] [add_comm_monoid N] [module R N]\n\nnamespace finite\nopen _root_.submodule set\n\nvariables {R M N}\n\nsection algebra\n\n@[priority 100] -- see Note [lower instance priority]\ninstance finite_type {R : Type*} (A : Type*) [comm_semiring R] [semiring A]\n  [algebra R A] [hRA : finite R A] : algebra.finite_type R A :=\n⟨subalgebra.fg_of_submodule_fg hRA.1⟩\n\nend algebra\n\nend finite\n\nend module\n\nnamespace algebra\n\nvariables [comm_ring R] [comm_ring A] [algebra R A] [comm_ring B] [algebra R B]\nvariables [add_comm_group M] [module R M]\nvariables [add_comm_group N] [module R N]\n\nnamespace finite_type\n\nlemma self : finite_type R R := ⟨⟨{1}, subsingleton.elim _ _⟩⟩\n\nprotected lemma polynomial : finite_type R R[X] :=\n⟨⟨{polynomial.X}, by { rw finset.coe_singleton, exact polynomial.adjoin_X }⟩⟩\n\nopen_locale classical\n\nprotected lemma mv_polynomial (ι : Type*) [finite ι] : finite_type R (mv_polynomial ι R) :=\nby casesI nonempty_fintype ι; exact ⟨⟨finset.univ.image mv_polynomial.X,\n  by {rw [finset.coe_image, finset.coe_univ, set.image_univ], exact mv_polynomial.adjoin_range_X}⟩⟩\n\n\n\nvariables {R A B}\n\nlemma of_surjective (hRA : finite_type R A) (f : A →ₐ[R] B) (hf : surjective f) :\n  finite_type R B :=\n⟨begin\n  convert hRA.1.map f,\n  simpa only [map_top f, @eq_comm _ ⊤, eq_top_iff, alg_hom.mem_range] using hf\nend⟩\n\nlemma equiv (hRA : finite_type R A) (e : A ≃ₐ[R] B) : finite_type R B :=\nhRA.of_surjective e e.surjective\n\nlemma trans [algebra A B] [is_scalar_tower R A B] (hRA : finite_type R A) (hAB : finite_type A B) :\n  finite_type R B :=\n⟨fg_trans' hRA.1 hAB.1⟩\n\n/-- An algebra is finitely generated if and only if it is a quotient\nof a polynomial ring whose variables are indexed by a finset. -/\nlemma iff_quotient_mv_polynomial : (finite_type R A) ↔ ∃ (s : finset A)\n  (f : (mv_polynomial {x // x ∈ s} R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rintro ⟨s, hs⟩,\n    use [s, mv_polynomial.aeval coe],\n    intro x,\n    have hrw : (↑s : set A) = (λ (x : A), x ∈ s.val) := rfl,\n    rw [← set.mem_range, ← alg_hom.coe_range, ← adjoin_eq_range, ← hrw, hs],\n    exact set.mem_univ x },\n  { rintro ⟨s, ⟨f, hsur⟩⟩,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R {x // x ∈ s}) f hsur }\nend\n\n/-- An algebra is finitely generated if and only if it is a quotient\nof a polynomial ring whose variables are indexed by a fintype. -/\nlemma iff_quotient_mv_polynomial' : (finite_type R A) ↔ ∃ (ι : Type u_2) (_ : fintype ι)\n  (f : (mv_polynomial ι R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial,\n    rintro ⟨s, ⟨f, hsur⟩⟩,\n    use [{x // x ∈ s}, by apply_instance, f, hsur] },\n  { rintro ⟨ι, ⟨hfintype, ⟨f, hsur⟩⟩⟩,\n    letI : fintype ι := hfintype,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R ι) f hsur }\nend\n\n/-- An algebra is finitely generated if and only if it is a quotient of a polynomial ring in `n`\nvariables. -/\nlemma iff_quotient_mv_polynomial'' : (finite_type R A) ↔ ∃ (n : ℕ)\n  (f : (mv_polynomial (fin n) R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial',\n    rintro ⟨ι, hfintype, ⟨f, hsur⟩⟩,\n    resetI,\n    have equiv := mv_polynomial.rename_equiv R (fintype.equiv_fin ι),\n    exact ⟨fintype.card ι, alg_hom.comp f equiv.symm, function.surjective.comp hsur\n      (alg_equiv.symm equiv).surjective⟩ },\n  { rintro ⟨n, ⟨f, hsur⟩⟩,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R (fin n)) f hsur }\nend\n\ninstance prod [hA : finite_type R A] [hB : finite_type R B] : finite_type R (A × B) :=\n⟨begin\n  rw ← subalgebra.prod_top,\n  exact hA.1.prod hB.1\nend⟩\n\nlemma is_noetherian_ring (R S : Type*) [comm_ring R] [comm_ring S] [algebra R S]\n  [h : algebra.finite_type R S] [is_noetherian_ring R] : is_noetherian_ring S :=\nbegin\n  obtain ⟨s, hs⟩ := h.1,\n  apply is_noetherian_ring_of_surjective\n    (mv_polynomial s R) S (mv_polynomial.aeval coe : mv_polynomial s R →ₐ[R] S),\n  rw [← set.range_iff_surjective, alg_hom.coe_to_ring_hom, ← alg_hom.coe_range,\n    ← algebra.adjoin_range_eq_range_aeval, subtype.range_coe_subtype, finset.set_of_mem, hs],\n  refl\nend\n\nlemma _root_.subalgebra.fg_iff_finite_type {R A : Type*} [comm_semiring R] [semiring A]\n  [algebra R A] (S : subalgebra R A) : S.fg ↔ algebra.finite_type R S :=\nS.fg_top.symm.trans ⟨λ h, ⟨h⟩, λ h, h.out⟩\n\nend finite_type\n\nend algebra\n\nend module_and_algebra\n\nnamespace ring_hom\nvariables {A B C : Type*} [comm_ring A] [comm_ring B] [comm_ring C]\n\n/-- A ring morphism `A →+* B` is of `finite_type` if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A →+* B) : Prop := @algebra.finite_type A B _ _ f.to_algebra\n\nnamespace finite\n\nvariables {A}\n\nlemma finite_type {f : A →+* B} (hf : f.finite) : finite_type f :=\n@module.finite.finite_type _ _ _ _ f.to_algebra hf\n\nend finite\n\nnamespace finite_type\n\nvariables (A)\n\nlemma id : finite_type (ring_hom.id A) := algebra.finite_type.self A\n\nvariables {A}\n\nlemma comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.finite_type) (hg : surjective g) :\n  (g.comp f).finite_type :=\n@algebra.finite_type.of_surjective A B C _ _ f.to_algebra _ (g.comp f).to_algebra hf\n{ to_fun := g, commutes' := λ a, rfl, .. g } hg\n\nlemma of_surjective (f : A →+* B) (hf : surjective f) : f.finite_type :=\nby { rw ← f.comp_id, exact (id A).comp_surjective hf }\n\nlemma comp {g : B →+* C} {f : A →+* B} (hg : g.finite_type) (hf : f.finite_type) :\n  (g.comp f).finite_type :=\n@algebra.finite_type.trans A B C _ _ f.to_algebra _ (g.comp f).to_algebra g.to_algebra\nbegin\n  fconstructor,\n  intros a b c,\n  simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc],\n  refl\nend\nhf hg\n\nlemma of_finite {f : A →+* B} (hf : f.finite) : f.finite_type :=\n@module.finite.finite_type _ _ _ _ f.to_algebra hf\n\nalias of_finite ← _root_.ring_hom.finite.to_finite_type\n\nlemma of_comp_finite_type {f : A →+* B} {g : B →+* C} (h : (g.comp f).finite_type) :\n  g.finite_type :=\nbegin\n  letI := f.to_algebra,\n  letI := g.to_algebra,\n  letI := (g.comp f).to_algebra,\n  letI : is_scalar_tower A B C := restrict_scalars.is_scalar_tower A B C,\n  letI : algebra.finite_type A C := h,\n  exact algebra.finite_type.of_restrict_scalars_finite_type A B C\nend\n\nend finite_type\n\nend ring_hom\n\nnamespace alg_hom\n\nvariables {R A B C : Type*} [comm_ring R]\nvariables [comm_ring A] [comm_ring B] [comm_ring C]\nvariables [algebra R A] [algebra R B] [algebra R C]\n\n/-- An algebra morphism `A →ₐ[R] B` is of `finite_type` if it is of finite type as ring morphism.\nIn other words, if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A →ₐ[R] B) : Prop := f.to_ring_hom.finite_type\n\nnamespace finite\n\nvariables {R A}\n\nlemma finite_type {f : A →ₐ[R] B} (hf : f.finite) : finite_type f :=\nring_hom.finite.finite_type hf\n\nend finite\n\nnamespace finite_type\n\nvariables (R A)\n\nlemma id : finite_type (alg_hom.id R A) := ring_hom.finite_type.id A\n\nvariables {R A}\n\nlemma comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.finite_type) (hf : f.finite_type) :\n  (g.comp f).finite_type :=\nring_hom.finite_type.comp hg hf\n\nlemma comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.finite_type) (hg : surjective g) :\n  (g.comp f).finite_type :=\nring_hom.finite_type.comp_surjective hf hg\n\nlemma of_surjective (f : A →ₐ[R] B) (hf : surjective f) : f.finite_type :=\nring_hom.finite_type.of_surjective f hf\n\nlemma of_comp_finite_type {f : A →ₐ[R] B} {g : B →ₐ[R] C} (h : (g.comp f).finite_type) :\ng.finite_type :=\nring_hom.finite_type.of_comp_finite_type h\n\nend finite_type\n\nend alg_hom\n\nsection monoid_algebra\n\nvariables {R : Type*} {M : Type*}\n\nnamespace add_monoid_algebra\n\nopen algebra add_submonoid submodule\n\nsection span\n\nsection semiring\n\nvariables [comm_semiring R] [add_monoid M]\n\n/-- An element of `add_monoid_algebra R M` is in the subalgebra generated by its support. -/\nlemma mem_adjoin_support (f : add_monoid_algebra R M) : f ∈ adjoin R (of' R M '' f.support) :=\nbegin\n  suffices : span R (of' R M '' f.support) ≤ (adjoin R (of' R M '' f.support)).to_submodule,\n  { exact this (mem_span_support f) },\n  rw submodule.span_le,\n  exact subset_adjoin\nend\n\n/-- If a set `S` generates, as algebra, `add_monoid_algebra R M`, then the set of supports of\nelements of `S` generates `add_monoid_algebra R M`. -/\nlemma support_gen_of_gen {S : set (add_monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (⋃ f ∈ S, (of' R M '' (f.support : set M))) = ⊤ :=\nbegin\n  refine le_antisymm le_top _,\n  rw [← hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : of' R M '' f.support ⊆\n    ⋃ (g : add_monoid_algebra R M) (H : g ∈ S), of' R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union₂.2 ⟨f, ⟨hf, hs⟩⟩ },\n  exact adjoin_mono hincl (mem_adjoin_support f)\nend\n\n/-- If a set `S` generates, as algebra, `add_monoid_algebra R M`, then the image of the union of\nthe supports of elements of `S` generates `add_monoid_algebra R M`. -/\nlemma support_gen_of_gen' {S : set (add_monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (of' R M '' (⋃ f ∈ S, (f.support : set M))) = ⊤ :=\nbegin\n  suffices : of' R M '' (⋃ f ∈ S, (f.support : set M)) = ⋃ f ∈ S, (of' R M '' (f.support : set M)),\n  { rw this,\n    exact support_gen_of_gen hS },\n  simp only [set.image_Union]\nend\n\nend semiring\n\nsection ring\n\nvariables [comm_ring R] [add_comm_monoid M]\n\n/-- If `add_monoid_algebra R M` is of finite type, there there is a `G : finset M` such that its\nimage generates, as algera, `add_monoid_algebra R M`. -/\nlemma exists_finset_adjoin_eq_top [h : finite_type R (add_monoid_algebra R M)] :\n  ∃ G : finset M, algebra.adjoin R (of' R M '' G) = ⊤ :=\nbegin\n  unfreezingI { obtain ⟨S, hS⟩ := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (λ f, f.support),\n  have : (finset.bUnion S (λ f, f.support) : set M) = ⋃ f ∈ S, (f.support : set M),\n  { simp only [finset.set_bUnion_coe, finset.coe_bUnion] },\n  rw [this],\n  exact support_gen_of_gen' hS\nend\n\n/-- The image of an element `m : M` in `add_monoid_algebra R M` belongs the submodule generated by\n`S : set M` if and only if `m ∈ S`. -/\nlemma of'_mem_span [nontrivial R] {m : M} {S : set M} :\n  of' R M m ∈ span R (of' R M '' S) ↔ m ∈ S :=\nbegin\n  refine ⟨λ h, _, λ h, submodule.subset_span $ set.mem_image_of_mem (of R M) h⟩,\n  rw [of', ← finsupp.supported_eq_span_single, finsupp.mem_supported,\n    finsupp.support_single_ne_zero _ (one_ne_zero' R)] at h,\n  simpa using h\nend\n\n/--If the image of an element `m : M` in `add_monoid_algebra R M` belongs the submodule generated by\nthe closure of some `S : set M` then `m ∈ closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of' R M m ∈ span R (submonoid.closure (of' R M '' S) : set (add_monoid_algebra R M))) :\n  m ∈ closure S :=\nbegin\n  suffices : multiplicative.of_add m ∈ submonoid.closure (multiplicative.to_add ⁻¹' S),\n  { simpa [← to_submonoid_closure] },\n  let S' := @submonoid.closure M multiplicative.mul_one_class S,\n  have h' : submonoid.map (of R M) S' = submonoid.closure ((λ (x : M), (of R M) x) '' S) :=\n    monoid_hom.map_mclosure _ _,\n  rw [set.image_congr' (show ∀ x, of' R M x = of R M x, from λ x, of'_eq_of x), ← h'] at h,\n  simpa using of'_mem_span.1 h\nend\n\nend ring\n\nend span\n\nvariables [add_comm_monoid M]\n\n/-- If a set `S` generates an additive monoid `M`, then the image of `M` generates, as algebra,\n`add_monoid_algebra R M`. -/\nlemma mv_polynomial_aeval_of_surjective_of_closure [comm_semiring R] {S : set M}\n  (hS : closure S = ⊤) : function.surjective (mv_polynomial.aeval\n  (λ (s : S), of' R M ↑s) : mv_polynomial S R → add_monoid_algebra R M) :=\nbegin\n  refine λ f, induction_on f (λ m, _) _ _,\n  { have : m ∈ closure S := hS.symm ▸ mem_top _,\n    refine closure_induction this (λ m hm, _) _ _,\n    { exact ⟨mv_polynomial.X ⟨m, hm⟩, mv_polynomial.aeval_X _ _⟩ },\n    { exact ⟨1, alg_hom.map_one _⟩ },\n    { rintro m₁ m₂ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩,\n      exact ⟨P₁ * P₂, by rw [alg_hom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]; refl⟩ } },\n  { rintro f g ⟨P, rfl⟩ ⟨Q, rfl⟩,\n    exact ⟨P + Q, alg_hom.map_add _ _ _⟩ },\n  { rintro r f ⟨P, rfl⟩,\n    exact ⟨r • P, alg_hom.map_smul _ _ _⟩ }\nend\n\nvariables (R M)\n\n/-- If an additive monoid `M` is finitely generated then `add_monoid_algebra R M` is of finite\ntype. -/\ninstance finite_type_of_fg [comm_ring R] [h : add_monoid.fg M] :\n  finite_type R (add_monoid_algebra R M) :=\nbegin\n  obtain ⟨S, hS⟩ := h.out,\n  exact (finite_type.mv_polynomial R (S : set M)).of_surjective (mv_polynomial.aeval\n    (λ (s : (S : set M)), of' R M ↑s)) (mv_polynomial_aeval_of_surjective_of_closure hS)\nend\n\nvariables {R M}\n\n/-- An additive monoid `M` is finitely generated if and only if `add_monoid_algebra R M` is of\nfinite type. -/\nlemma finite_type_iff_fg [comm_ring R] [nontrivial R] :\n  finite_type R (add_monoid_algebra R M) ↔ add_monoid.fg M :=\nbegin\n  refine ⟨λ h, _, λ h, @add_monoid_algebra.finite_type_of_fg _ _ _ _ h⟩,\n  obtain ⟨S, hS⟩ := @exists_finset_adjoin_eq_top R M _ _ h,\n  refine add_monoid.fg_def.2 ⟨S, (eq_top_iff' _).2 (λ m, _)⟩,\n  have hm : of' R M m ∈ (adjoin R (of' R M '' ↑S)).to_submodule,\n  { simp only [hS, top_to_submodule, submodule.mem_top], },\n  rw [adjoin_eq_span] at hm,\n  exact mem_closure_of_mem_span_closure hm\nend\n\n/-- If `add_monoid_algebra R M` is of finite type then `M` is finitely generated. -/\nlemma fg_of_finite_type [comm_ring R] [nontrivial R] [h : finite_type R (add_monoid_algebra R M)] :\n  add_monoid.fg M :=\nfinite_type_iff_fg.1 h\n\n/-- An additive group `G` is finitely generated if and only if `add_monoid_algebra R G` is of\nfinite type. -/\nlemma finite_type_iff_group_fg {G : Type*} [add_comm_group G] [comm_ring R] [nontrivial R] :\n  finite_type R (add_monoid_algebra R G) ↔ add_group.fg G :=\nby simpa [add_group.fg_iff_add_monoid.fg] using finite_type_iff_fg\n\nend add_monoid_algebra\n\nnamespace monoid_algebra\n\nopen algebra submonoid submodule\n\nsection span\n\nsection semiring\n\nvariables [comm_semiring R] [monoid M]\n\n/-- An element of `monoid_algebra R M` is in the subalgebra generated by its support. -/\nlemma mem_adjoin_support (f : monoid_algebra R M) : f ∈ adjoin R (of R M '' f.support) :=\nbegin\n  suffices : span R (of R M '' f.support) ≤ (adjoin R (of R M '' f.support)).to_submodule,\n  { exact this (mem_span_support f) },\n  rw submodule.span_le,\n  exact subset_adjoin\nend\n\n/-- If a set `S` generates, as algebra, `monoid_algebra R M`, then the set of supports of elements\nof `S` generates `monoid_algebra R M`. -/\nlemma support_gen_of_gen {S : set (monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (⋃ f ∈ S, (of R M '' (f.support : set M))) = ⊤ :=\nbegin\n  refine le_antisymm le_top _,\n  rw [← hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : (of R M) '' f.support ⊆\n    ⋃ (g : monoid_algebra R M) (H : g ∈ S), of R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union₂.2 ⟨f, ⟨hf, hs⟩⟩ },\n  exact adjoin_mono hincl (mem_adjoin_support f)\nend\n\n/-- If a set `S` generates, as algebra, `monoid_algebra R M`, then the image of the union of the\nsupports of elements of `S` generates `monoid_algebra R M`. -/\nlemma support_gen_of_gen' {S : set (monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (of R M '' (⋃ f ∈ S, (f.support : set M))) = ⊤ :=\nbegin\n  suffices : of R M '' (⋃ f ∈ S, (f.support : set M)) = ⋃ f ∈ S, (of R M '' (f.support : set M)),\n  { rw this,\n    exact support_gen_of_gen hS },\n  simp only [set.image_Union]\nend\n\nend semiring\n\nsection ring\n\nvariables [comm_ring R] [comm_monoid M]\n\n/-- If `monoid_algebra R M` is of finite type, there there is a `G : finset M` such that its image\ngenerates, as algera, `monoid_algebra R M`. -/\nlemma exists_finset_adjoin_eq_top [h :finite_type R (monoid_algebra R M)] :\n  ∃ G : finset M, algebra.adjoin R (of R M '' G) = ⊤ :=\nbegin\n  unfreezingI { obtain ⟨S, hS⟩ := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (λ f, f.support),\n  have : (finset.bUnion S (λ f, f.support) : set M) = ⋃ f ∈ S, (f.support : set M),\n  { simp only [finset.set_bUnion_coe, finset.coe_bUnion] },\n  rw [this],\n  exact support_gen_of_gen' hS\nend\n\n/-- The image of an element `m : M` in `monoid_algebra R M` belongs the submodule generated by\n`S : set M` if and only if `m ∈ S`. -/\nlemma of_mem_span_of_iff [nontrivial R] {m : M} {S : set M} :\n  of R M m ∈ span R (of R M '' S) ↔ m ∈ S :=\nbegin\n  refine ⟨λ h, _, λ h, submodule.subset_span $ set.mem_image_of_mem (of R M) h⟩,\n  rw [of, monoid_hom.coe_mk, ← finsupp.supported_eq_span_single, finsupp.mem_supported,\n    finsupp.support_single_ne_zero _ (one_ne_zero' R)] at h,\n  simpa using h\nend\n\n/--If the image of an element `m : M` in `monoid_algebra R M` belongs the submodule generated by the\nclosure of some `S : set M` then `m ∈ closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of R M m ∈ span R (submonoid.closure (of R M '' S) : set (monoid_algebra R M))) :\n  m ∈ closure S :=\nbegin\n  rw ← monoid_hom.map_mclosure at h,\n  simpa using of_mem_span_of_iff.1 h\nend\n\nend ring\n\nend span\n\nvariables [comm_monoid M]\n\n/-- If a set `S` generates a monoid `M`, then the image of `M` generates, as algebra,\n`monoid_algebra R M`. -/\nlemma mv_polynomial_aeval_of_surjective_of_closure [comm_semiring R] {S : set M}\n  (hS : closure S = ⊤) : function.surjective (mv_polynomial.aeval\n  (λ (s : S), of R M ↑s) : mv_polynomial S R → monoid_algebra R M) :=\nbegin\n  refine λ f, induction_on f (λ m, _) _ _,\n  { have : m ∈ closure S := hS.symm ▸ mem_top _,\n    refine closure_induction this (λ m hm, _) _ _,\n    { exact ⟨mv_polynomial.X ⟨m, hm⟩, mv_polynomial.aeval_X _ _⟩ },\n    { exact ⟨1, alg_hom.map_one _⟩ },\n    { rintro m₁ m₂ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩,\n      exact ⟨P₁ * P₂, by rw [alg_hom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]⟩ } },\n  { rintro f g ⟨P, rfl⟩ ⟨Q, rfl⟩,\n    exact ⟨P + Q, alg_hom.map_add _ _ _⟩ },\n  { rintro r f ⟨P, rfl⟩,\n    exact ⟨r • P, alg_hom.map_smul _ _ _⟩ }\nend\n\n/-- If a monoid `M` is finitely generated then `monoid_algebra R M` is of finite type. -/\ninstance finite_type_of_fg [comm_ring R] [monoid.fg M] : finite_type R (monoid_algebra R M) :=\n(add_monoid_algebra.finite_type_of_fg R (additive M)).equiv (to_additive_alg_equiv R M).symm\n\n/-- A monoid `M` is finitely generated if and only if `monoid_algebra R M` is of finite type. -/\nlemma finite_type_iff_fg [comm_ring R] [nontrivial R] :\n  finite_type R (monoid_algebra R M) ↔ monoid.fg M :=\n⟨λ h, monoid.fg_iff_add_fg.2 $ add_monoid_algebra.finite_type_iff_fg.1 $ h.equiv $\n  to_additive_alg_equiv R M, λ h, @monoid_algebra.finite_type_of_fg _ _ _ _ h⟩\n\n/-- If `monoid_algebra R M` is of finite type then `M` is finitely generated. -/\nlemma fg_of_finite_type [comm_ring R] [nontrivial R] [h : finite_type R (monoid_algebra R M)] :\n  monoid.fg M :=\nfinite_type_iff_fg.1 h\n\n/-- A group `G` is finitely generated if and only if `add_monoid_algebra R G` is of finite type. -/\nlemma finite_type_iff_group_fg {G : Type*} [comm_group G] [comm_ring R] [nontrivial R] :\n  finite_type R (monoid_algebra R G) ↔ group.fg G :=\nby simpa [group.fg_iff_monoid.fg] using finite_type_iff_fg\n\nend monoid_algebra\n\nend monoid_algebra\n\nsection vasconcelos\nvariables {R : Type*} [comm_ring R] {M : Type*} [add_comm_group M] [module R M] (f : M →ₗ[R] M)\n\nnoncomputable theory\n\n/-- The structure of a module `M` over a ring `R` as a module over `R[X]` when given a\nchoice of how `X` acts by choosing a linear map `f : M →ₗ[R] M` -/\ndef module_polynomial_of_endo : module R[X] M :=\nmodule.comp_hom M (polynomial.aeval f).to_ring_hom\n\nlemma module_polynomial_of_endo_smul_def (n : R[X]) (a : M) :\n  @@has_smul.smul (module_polynomial_of_endo f).to_has_smul n a = polynomial.aeval f n a := rfl\n\nlocal attribute [simp] module_polynomial_of_endo_smul_def\n\ninclude f\nlemma module_polynomial_of_endo.is_scalar_tower : @is_scalar_tower R R[X] M _\n  (by { letI := module_polynomial_of_endo f, apply_instance }) _ :=\nbegin\n  letI := module_polynomial_of_endo f,\n  constructor,\n  intros x y z,\n  simp,\nend\n\nopen polynomial module\n\n/-- A theorem/proof by Vasconcelos, given a finite module `M` over a commutative ring, any\nsurjective endomorphism of `M` is also injective. Based on,\nhttps://math.stackexchange.com/a/239419/31917,\nhttps://www.ams.org/journals/tran/1969-138-00/S0002-9947-1969-0238839-5/.\nThis is similar to `is_noetherian.injective_of_surjective_endomorphism` but only applies in the\ncommutative case, but does not use a Noetherian hypothesis. -/\ntheorem module.finite.injective_of_surjective_endomorphism [hfg : finite R M]\n  (f_surj : function.surjective f) : function.injective f :=\nbegin\n  letI := module_polynomial_of_endo f,\n  haveI : is_scalar_tower R R[X] M := module_polynomial_of_endo.is_scalar_tower f,\n  have hfgpoly : finite R[X] M, from finite.of_restrict_scalars_finite R _ _,\n  have X_mul : ∀ o, (X : R[X]) • o = f o,\n  { intro,\n    simp, },\n  have : (⊤ : submodule R[X] M) ≤ ideal.span {X} • ⊤,\n  { intros a ha,\n    obtain ⟨y, rfl⟩ := f_surj a,\n    rw [← X_mul y],\n    exact submodule.smul_mem_smul (ideal.mem_span_singleton.mpr (dvd_refl _)) trivial, },\n  obtain ⟨F, hFa, hFb⟩ := submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul _\n    (⊤ : submodule R[X] M) (finite_def.mp hfgpoly) this,\n  rw [← linear_map.ker_eq_bot, linear_map.ker_eq_bot'],\n  intros m hm,\n  rw ideal.mem_span_singleton' at hFa,\n  obtain ⟨G, hG⟩ := hFa,\n  suffices : (F - 1) • m = 0,\n  { have Fmzero := hFb m (by simp),\n    rwa [← sub_add_cancel F 1, add_smul, one_smul, this, zero_add] at Fmzero, },\n  rw [← hG, mul_smul, X_mul m, hm, smul_zero],\nend\n\nend vasconcelos\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/finite_type.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631541, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.46554047269810145}}
{"text": "variables p q : Prop\n\ntheorem t1 : p → q → p := λ (hp : p) (hq : q), hp\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0210.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7956581000631541, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.46554047269810145}}
{"text": "import .free\n-- import .orthogonal -- not being used yet, so commenting out because it takes a while to compile.\n\nuniverses u v w\n\n#check my_unit.{u}\n#check my_unit.star\n\nopen category_theory\n\n-- todo : maybe the definition of initial and final objects should be in another file?\n\nsection\n\nvariables (C : Type u) [CC : category.{v u} C]\ninclude CC\n\ndef initial_object (I : C) : Prop :=\n\tforall (X : C), ∃! ( i : I ⟶  X), true\n\n\nend\n\n\n#check initial_object\n\n#check my_empty.cases_on\n\n#check empty.cases_on\n\ndef emptyf {X : Type w} (impossibility : my_empty.{u} ) :  X :=\nbegin\ninduction impossibility\nend\n\n#check emptyf\n\nsection\n\nvariables (c : Type u -> Type v) (hom : (Pi {alpha beta : Type u}, c alpha -> c beta -> (alpha -> beta) -> Prop))\n\n#check concrete_category\n\nvariable C : concrete_category @hom\n\n#check @is_free_over\n\nvariable [C2 : category (bundled c)]\n\n#check @initial_object\n#check @initial_object (bundled c)\n#check @initial_object (bundled c) C2\n\n\ntheorem free_over_empty_implies_initial (A : (bundled c)) [C3 : category (bundled c)]: (@is_free_over c @hom C A my_empty.{u} emptyf) -> (@initial_object (bundled c) C3 A) :=\n\tsorry\n\n\nend\n\n", "meta": {"author": "drocta", "repo": "orthogonal-free-surjective", "sha": "6523bdbc7479a62155aae3405c6b00b5673b4b75", "save_path": "github-repos/lean/drocta-orthogonal-free-surjective", "path": "github-repos/lean/drocta-orthogonal-free-surjective/orthogonal-free-surjective-6523bdbc7479a62155aae3405c6b00b5673b4b75/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.795658090372256, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.46554046702794577}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Johan Commelin\n-/\nimport category_theory.limits.shapes.terminal\n\n/-!\n# Zero objects\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA category \"has a zero object\" if it has an object which is both initial and terminal. Having a\nzero object provides zero morphisms, as the unique morphisms factoring through the zero object;\nsee `category_theory.limits.shapes.zero_morphisms`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n-/\n\nnoncomputable theory\n\nuniverses v u v' u'\n\nopen category_theory\nopen category_theory.category\n\nvariables {C : Type u} [category.{v} C]\nvariables {D : Type u'} [category.{v'} D]\n\nnamespace category_theory\n\nnamespace limits\n\n/-- An object `X` in a category is a *zero object* if for every object `Y`\nthere is a unique morphism `to : X → Y` and a unique morphism `from : Y → X`.\n\nThis is a characteristic predicate for `has_zero_object`. -/\nstructure is_zero (X : C) : Prop :=\n(unique_to   : ∀ Y, nonempty (unique (X ⟶ Y)))\n(unique_from : ∀ Y, nonempty (unique (Y ⟶ X)))\n\nnamespace is_zero\n\nvariables {X Y : C}\n\n/-- If `h : is_zero X`, then `h.to Y` is a choice of unique morphism `X → Y`. -/\nprotected def «to» (h : is_zero X) (Y : C) : X ⟶ Y :=\n@default (X ⟶ Y) $ @unique.inhabited _ $ (h.unique_to Y).some\n\nlemma eq_to (h : is_zero X) (f : X ⟶ Y) : f = h.to Y :=\n@unique.eq_default _ (id _) _\n\nlemma to_eq (h : is_zero X) (f : X ⟶ Y) : h.to Y = f :=\n(h.eq_to f).symm\n\n/-- If `h : is_zero X`, then `h.from Y` is a choice of unique morphism `Y → X`. -/\nprotected def «from» (h : is_zero X) (Y : C) : Y ⟶ X :=\n@default (Y ⟶ X) $ @unique.inhabited _ $ (h.unique_from Y).some\n\nlemma eq_from (h : is_zero X) (f : Y ⟶ X) : f = h.from Y :=\n@unique.eq_default _ (id _) _\n\nlemma from_eq (h : is_zero X) (f : Y ⟶ X) : h.from Y = f :=\n(h.eq_from f).symm\n\nlemma eq_of_src (hX : is_zero X) (f g : X ⟶ Y) : f = g :=\n(hX.eq_to f).trans (hX.eq_to g).symm\n\nlemma eq_of_tgt (hX : is_zero X) (f g : Y ⟶ X) : f = g :=\n(hX.eq_from f).trans (hX.eq_from g).symm\n\n/-- Any two zero objects are isomorphic. -/\ndef iso (hX : is_zero X) (hY : is_zero Y) : X ≅ Y :=\n{ hom := hX.to Y,\n  inv := hX.from Y,\n  hom_inv_id' := hX.eq_of_src _ _,\n  inv_hom_id' := hY.eq_of_src _ _, }\n\n/-- A zero object is in particular initial. -/\nprotected def is_initial (hX : is_zero X) : is_initial X :=\n@is_initial.of_unique _ _ X $ λ Y, (hX.unique_to Y).some\n\n/-- A zero object is in particular terminal. -/\nprotected def is_terminal (hX : is_zero X) : is_terminal X :=\n@is_terminal.of_unique _ _ X $ λ Y, (hX.unique_from Y).some\n\n/-- The (unique) isomorphism between any initial object and the zero object. -/\ndef iso_is_initial (hX : is_zero X) (hY : is_initial Y) : X ≅ Y :=\nhX.is_initial.unique_up_to_iso hY\n\n/-- The (unique) isomorphism between any terminal object and the zero object. -/\ndef iso_is_terminal (hX : is_zero X) (hY : is_terminal Y) : X ≅ Y :=\nhX.is_terminal.unique_up_to_iso hY\n\nlemma of_iso (hY : is_zero Y) (e : X ≅ Y) : is_zero X :=\nbegin\n  refine ⟨λ Z, ⟨⟨⟨e.hom ≫ hY.to Z⟩, λ f, _⟩⟩, λ Z, ⟨⟨⟨hY.from Z ≫ e.inv⟩, λ f, _⟩⟩⟩,\n  { rw ← cancel_epi e.inv, apply hY.eq_of_src, },\n  { rw ← cancel_mono e.hom, apply hY.eq_of_tgt, },\nend\n\nlemma op (h : is_zero X) : is_zero (opposite.op X) :=\n⟨λ Y, ⟨⟨⟨(h.from (opposite.unop Y)).op⟩, λ f, quiver.hom.unop_inj (h.eq_of_tgt _ _)⟩⟩,\n  λ Y, ⟨⟨⟨(h.to (opposite.unop Y)).op⟩, λ f, quiver.hom.unop_inj (h.eq_of_src _ _)⟩⟩⟩\n\nlemma unop {X : Cᵒᵖ} (h : is_zero X) : is_zero (opposite.unop X) :=\n⟨λ Y, ⟨⟨⟨(h.from (opposite.op Y)).unop⟩, λ f, quiver.hom.op_inj (h.eq_of_tgt _ _)⟩⟩,\n  λ Y, ⟨⟨⟨(h.to (opposite.op Y)).unop⟩, λ f, quiver.hom.op_inj (h.eq_of_src _ _)⟩⟩⟩\n\nend is_zero\n\nend limits\n\nopen category_theory.limits\n\nlemma iso.is_zero_iff {X Y : C} (e : X ≅ Y) :\n  is_zero X ↔ is_zero Y :=\n⟨λ h, h.of_iso e.symm, λ h, h.of_iso e⟩\n\nlemma functor.is_zero (F : C ⥤ D) (hF : ∀ X, is_zero (F.obj X)) :\n  is_zero F :=\nbegin\n  split; intros G; refine ⟨⟨⟨_⟩, _⟩⟩,\n  { refine { app := λ X, (hF _).to _, naturality' := _ },\n    intros, exact (hF _).eq_of_src _ _ },\n  { intro f, ext, apply (hF _).eq_of_src _ _ },\n  { refine { app := λ X, (hF _).from _, naturality' := _ },\n    intros, exact (hF _).eq_of_tgt _ _ },\n  { intro f, ext, apply (hF _).eq_of_tgt _ _ },\nend\n\nnamespace limits\n\nvariables (C)\n\n/-- A category \"has a zero object\" if it has an object which is both initial and terminal. -/\nclass has_zero_object : Prop :=\n(zero : ∃ X : C, is_zero X)\n\ninstance has_zero_object_punit : has_zero_object (discrete punit) :=\n{ zero := ⟨⟨⟨⟩⟩, by tidy, by tidy⟩, }\n\nsection\n\nvariables [has_zero_object C]\n\n/--\nConstruct a `has_zero C` for a category with a zero object.\nThis can not be a global instance as it will trigger for every `has_zero C` typeclass search.\n-/\nprotected def has_zero_object.has_zero : has_zero C :=\n{ zero := has_zero_object.zero.some }\n\nlocalized \"attribute [instance] category_theory.limits.has_zero_object.has_zero\" in zero_object\n\nlemma is_zero_zero : is_zero (0 : C) :=\nhas_zero_object.zero.some_spec\n\ninstance has_zero_object_op : has_zero_object Cᵒᵖ := ⟨⟨opposite.op 0, is_zero.op (is_zero_zero C)⟩⟩\n\nend\n\nopen_locale zero_object\n\nlemma has_zero_object_unop [has_zero_object Cᵒᵖ] : has_zero_object C :=\n⟨⟨opposite.unop 0, is_zero.unop (is_zero_zero Cᵒᵖ)⟩⟩\n\nvariables {C}\n\nlemma is_zero.has_zero_object {X : C} (hX : is_zero X) : has_zero_object C := ⟨⟨X, hX⟩⟩\n\n/-- Every zero object is isomorphic to *the* zero object. -/\ndef is_zero.iso_zero [has_zero_object C] {X : C} (hX : is_zero X) : X ≅ 0 :=\nhX.iso (is_zero_zero C)\n\nlemma is_zero.obj [has_zero_object D] {F : C ⥤ D} (hF : is_zero F) (X : C) :\n  is_zero (F.obj X) :=\nbegin\n  let G : C ⥤ D := (category_theory.functor.const C).obj 0,\n  have hG : is_zero G := functor.is_zero _ (λ X, is_zero_zero _),\n  let e : F ≅ G := hF.iso hG,\n  exact (is_zero_zero _).of_iso (e.app X),\nend\n\nnamespace has_zero_object\nvariables [has_zero_object C]\n\n/-- There is a unique morphism from the zero object to any object `X`. -/\nprotected def unique_to (X : C) : unique (0 ⟶ X) :=\n((is_zero_zero C).unique_to X).some\n\n/-- There is a unique morphism from any object `X` to the zero object. -/\nprotected def unique_from (X : C) : unique (X ⟶ 0) :=\n((is_zero_zero C).unique_from X).some\n\nlocalized \"attribute [instance] category_theory.limits.has_zero_object.unique_to\" in zero_object\nlocalized \"attribute [instance] category_theory.limits.has_zero_object.unique_from\" in zero_object\n\n@[ext]\nlemma to_zero_ext {X : C} (f g : X ⟶ 0) : f = g :=\n(is_zero_zero C).eq_of_tgt _ _\n\n@[ext]\nlemma from_zero_ext {X : C} (f g : 0 ⟶ X) : f = g :=\n(is_zero_zero C).eq_of_src _ _\n\ninstance (X : C) : subsingleton (X ≅ 0) := by tidy\n\ninstance {X : C} (f : 0 ⟶ X) : mono f :=\n{ right_cancellation := λ Z g h w, by ext, }\n\ninstance {X : C} (f : X ⟶ 0) : epi f :=\n{ left_cancellation := λ Z g h w, by ext, }\n\ninstance zero_to_zero_is_iso (f : (0 : C) ⟶ 0) :\n  is_iso f :=\nby convert (show is_iso (𝟙 (0 : C)), by apply_instance)\n\n/-- A zero object is in particular initial. -/\ndef zero_is_initial : is_initial (0 : C) :=\n(is_zero_zero C).is_initial\n\n/-- A zero object is in particular terminal. -/\ndef zero_is_terminal : is_terminal (0 : C) :=\n(is_zero_zero C).is_terminal\n\n/-- A zero object is in particular initial. -/\n@[priority 10]\ninstance has_initial : has_initial C :=\nhas_initial_of_unique 0\n\n/-- A zero object is in particular terminal. -/\n@[priority 10]\ninstance has_terminal : has_terminal C :=\nhas_terminal_of_unique 0\n\n/-- The (unique) isomorphism between any initial object and the zero object. -/\ndef zero_iso_is_initial {X : C} (t : is_initial X) : 0 ≅ X :=\nzero_is_initial.unique_up_to_iso t\n\n/-- The (unique) isomorphism between any terminal object and the zero object. -/\ndef zero_iso_is_terminal {X : C} (t : is_terminal X) : 0 ≅ X :=\nzero_is_terminal.unique_up_to_iso t\n\n/-- The (unique) isomorphism between the chosen initial object and the chosen zero object. -/\ndef zero_iso_initial [has_initial C] : 0 ≅ ⊥_ C :=\nzero_is_initial.unique_up_to_iso initial_is_initial\n\n/-- The (unique) isomorphism between the chosen terminal object and the chosen zero object. -/\ndef zero_iso_terminal [has_terminal C] : 0 ≅ ⊤_ C :=\nzero_is_terminal.unique_up_to_iso terminal_is_terminal\n\n@[priority 100]\ninstance has_strict_initial : initial_mono_class C :=\ninitial_mono_class.of_is_initial zero_is_initial (λ X, category_theory.mono _)\n\nend has_zero_object\n\nend limits\n\nopen category_theory.limits\nopen_locale zero_object\n\nlemma functor.is_zero_iff [has_zero_object D] (F : C ⥤ D) :\n  is_zero F ↔ ∀ X, is_zero (F.obj X) :=\n⟨λ hF X, hF.obj X, functor.is_zero _⟩\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/shapes/zero_objects.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.4655127856557468}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Johan Commelin, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.ordered_group\nimport Mathlib.algebra.group_with_zero.default\nimport Mathlib.algebra.group_with_zero.power\nimport Mathlib.tactic.abel\nimport Mathlib.PostPort\n\nuniverses u_1 l u_2 \n\nnamespace Mathlib\n\n/-!\n# Linearly ordered commutative groups and monoids with a zero element adjoined\n\nThis file sets up a special class of linearly ordered commutative monoids\nthat show up as the target of so-called “valuations” in algebraic number theory.\n\nUsually, in the informal literature, these objects are constructed\nby taking a linearly ordered commutative group Γ and formally adjoining a zero element: Γ ∪ {0}.\n\nThe disadvantage is that a type such as `nnreal` is not of that form,\nwhereas it is a very common target for valuations.\nThe solutions is to use a typeclass, and that is exactly what we do in this file.\n\nNote that to avoid issues with import cycles, `linear_ordered_comm_monoid_with_zero` is defined\nin another file. However, the lemmas about it are stated here.\n-/\n\n/-- A linearly ordered commutative group with a zero element. -/\nclass linear_ordered_comm_group_with_zero (α : Type u_1)\n    extends comm_group_with_zero α, linear_ordered_comm_monoid_with_zero α where\n\n/-\nThe following facts are true more generally in a (linearly) ordered commutative monoid.\n-/\n\ntheorem one_le_pow_of_one_le' {α : Type u_1} {x : α} [linear_ordered_comm_monoid_with_zero α]\n    {n : ℕ} (H : 1 ≤ x) : 1 ≤ x ^ n :=\n  Nat.rec (le_refl 1) (fun (n : ℕ) (ih : 1 ≤ x ^ n) => one_le_mul H ih) n\n\ntheorem pow_le_one_of_le_one {α : Type u_1} {x : α} [linear_ordered_comm_monoid_with_zero α] {n : ℕ}\n    (H : x ≤ 1) : x ^ n ≤ 1 :=\n  Nat.rec (le_refl 1) (fun (n : ℕ) (ih : x ^ n ≤ 1) => mul_le_one' H ih) n\n\ntheorem eq_one_of_pow_eq_one {α : Type u_1} {x : α} [linear_ordered_comm_monoid_with_zero α] {n : ℕ}\n    (hn : n ≠ 0) (H : x ^ n = 1) : x = 1 :=\n  sorry\n\ntheorem pow_eq_one_iff {α : Type u_1} {x : α} [linear_ordered_comm_monoid_with_zero α] {n : ℕ}\n    (hn : n ≠ 0) : x ^ n = 1 ↔ x = 1 :=\n  { mp := eq_one_of_pow_eq_one hn, mpr := fun (ᾰ : x = 1) => Eq._oldrec (one_pow n) (Eq.symm ᾰ) }\n\ntheorem one_le_pow_iff {α : Type u_1} {x : α} [linear_ordered_comm_monoid_with_zero α] {n : ℕ}\n    (hn : n ≠ 0) : 1 ≤ x ^ n ↔ 1 ≤ x :=\n  sorry\n\ntheorem pow_le_one_iff {α : Type u_1} {x : α} [linear_ordered_comm_monoid_with_zero α] {n : ℕ}\n    (hn : n ≠ 0) : x ^ n ≤ 1 ↔ x ≤ 1 :=\n  sorry\n\ntheorem zero_le_one' {α : Type u_1} [linear_ordered_comm_monoid_with_zero α] : 0 ≤ 1 :=\n  linear_ordered_comm_monoid_with_zero.zero_le_one\n\n@[simp] theorem zero_le' {α : Type u_1} {a : α} [linear_ordered_comm_monoid_with_zero α] : 0 ≤ a :=\n  sorry\n\n@[simp] theorem not_lt_zero' {α : Type u_1} {a : α} [linear_ordered_comm_monoid_with_zero α] :\n    ¬a < 0 :=\n  not_lt_of_le zero_le'\n\n@[simp] theorem le_zero_iff {α : Type u_1} {a : α} [linear_ordered_comm_monoid_with_zero α] :\n    a ≤ 0 ↔ a = 0 :=\n  { mp := fun (h : a ≤ 0) => le_antisymm h zero_le', mpr := fun (h : a = 0) => h ▸ le_refl a }\n\ntheorem zero_lt_iff {α : Type u_1} {a : α} [linear_ordered_comm_monoid_with_zero α] :\n    0 < a ↔ a ≠ 0 :=\n  { mp := ne_of_gt, mpr := fun (h : a ≠ 0) => lt_of_le_of_ne zero_le' (ne.symm h) }\n\ntheorem ne_zero_of_lt {α : Type u_1} {a : α} {b : α} [linear_ordered_comm_monoid_with_zero α]\n    (h : b < a) : a ≠ 0 :=\n  fun (h1 : a = 0) => not_lt_zero' ((fun (this : b < 0) => this) (h1 ▸ h))\n\ntheorem zero_lt_one'' {α : Type u_1} [linear_ordered_comm_group_with_zero α] : 0 < 1 :=\n  lt_of_le_of_ne zero_le_one' zero_ne_one\n\ntheorem le_of_le_mul_right {α : Type u_1} {a : α} {b : α} {c : α}\n    [linear_ordered_comm_group_with_zero α] (h : c ≠ 0) (hab : a * c ≤ b * c) : a ≤ b :=\n  sorry\n\ntheorem le_mul_inv_of_mul_le {α : Type u_1} {a : α} {b : α} {c : α}\n    [linear_ordered_comm_group_with_zero α] (h : c ≠ 0) (hab : a * c ≤ b) : a ≤ b * (c⁻¹) :=\n  sorry\n\ntheorem mul_inv_le_of_le_mul {α : Type u_1} {a : α} {b : α} {c : α}\n    [linear_ordered_comm_group_with_zero α] (h : c ≠ 0) (hab : a ≤ b * c) : a * (c⁻¹) ≤ b :=\n  sorry\n\ntheorem div_le_div' {α : Type u_1} [linear_ordered_comm_group_with_zero α] (a : α) (b : α) (c : α)\n    (d : α) (hb : b ≠ 0) (hd : d ≠ 0) : a * (b⁻¹) ≤ c * (d⁻¹) ↔ a * d ≤ c * b :=\n  sorry\n\n@[simp] theorem units.zero_lt {α : Type u_1} [linear_ordered_comm_group_with_zero α] (u : units α) :\n    0 < ↑u :=\n  iff.mpr zero_lt_iff (units.ne_zero u)\n\ntheorem mul_lt_mul'''' {α : Type u_1} {a : α} {b : α} {c : α} {d : α}\n    [linear_ordered_comm_group_with_zero α] (hab : a < b) (hcd : c < d) : a * c < b * d :=\n  sorry\n\ntheorem mul_inv_lt_of_lt_mul' {α : Type u_1} {x : α} {y : α} {z : α}\n    [linear_ordered_comm_group_with_zero α] (h : x < y * z) : x * (z⁻¹) < y :=\n  sorry\n\ntheorem mul_lt_right' {α : Type u_1} {a : α} {b : α} [linear_ordered_comm_group_with_zero α] (c : α)\n    (h : a < b) (hc : c ≠ 0) : a * c < b * c :=\n  sorry\n\ntheorem pow_lt_pow_succ {α : Type u_1} [linear_ordered_comm_group_with_zero α] {x : α} {n : ℕ}\n    (hx : 1 < x) : x ^ n < x ^ Nat.succ n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (x ^ n < x ^ Nat.succ n)) (Eq.symm (one_mul (x ^ n)))))\n    (mul_lt_right' (x ^ n) hx (pow_ne_zero n (ne_of_gt (lt_trans zero_lt_one'' hx))))\n\ntheorem pow_lt_pow' {α : Type u_1} [linear_ordered_comm_group_with_zero α] {x : α} {m : ℕ} {n : ℕ}\n    (hx : 1 < x) (hmn : m < n) : x ^ m < x ^ n :=\n  nat.less_than_or_equal.drec (pow_lt_pow_succ hx)\n    (fun {n : ℕ} (hmn : nat.less_than_or_equal (Nat.succ m) n) (ih : x ^ m < x ^ n) =>\n      lt_trans ih (pow_lt_pow_succ hx))\n    hmn\n\ntheorem inv_lt_inv'' {α : Type u_1} {a : α} {b : α} [linear_ordered_comm_group_with_zero α]\n    (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ < (b⁻¹) ↔ b < a :=\n  inv_lt_inv_iff\n\ntheorem inv_le_inv'' {α : Type u_1} {a : α} {b : α} [linear_ordered_comm_group_with_zero α]\n    (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ ≤ (b⁻¹) ↔ b ≤ a :=\n  inv_le_inv_iff\n\nnamespace monoid_hom\n\n\ntheorem map_neg_one {α : Type u_1} [linear_ordered_comm_group_with_zero α] {R : Type u_2} [ring R]\n    (f : R →* α) : coe_fn f (-1) = 1 :=\n  sorry\n\n@[simp] theorem map_neg {α : Type u_1} [linear_ordered_comm_group_with_zero α] {R : Type u_2}\n    [ring R] (f : R →* α) (x : R) : coe_fn f (-x) = coe_fn f x :=\n  sorry\n\ntheorem map_sub_swap {α : Type u_1} [linear_ordered_comm_group_with_zero α] {R : Type u_2} [ring R]\n    (f : R →* α) (x : R) (y : R) : coe_fn f (x - y) = coe_fn f (y - x) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/linear_ordered_comm_group_with_zero_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210897, "lm_q2_score": 0.668880247169804, "lm_q1q2_score": 0.4655127680320982}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Mario Carneiro\n-/\nimport control.traversable.equiv\nimport data.vector.basic\n\nuniverses u v w\n\nnamespace d_array\nvariables {n : ℕ} {α : fin n → Type u}\n\ninstance [∀ i, inhabited (α i)] : inhabited (d_array n α) :=\n⟨⟨default⟩⟩\n\nend d_array\n\nnamespace array\n\ninstance {n α} [inhabited α] : inhabited (array n α) :=\nd_array.inhabited\n\ntheorem to_list_of_heq {n₁ n₂ α} {a₁ : array n₁ α} {a₂ : array n₂ α}\n  (hn : n₁ = n₂) (ha : a₁ == a₂) : a₁.to_list = a₂.to_list :=\nby congr; assumption\n\n/- rev_list -/\n\nsection rev_list\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem rev_list_reverse_aux : ∀ i (h : i ≤ n) (t : list α),\n  (a.iterate_aux (λ _, (::)) i h []).reverse_core t = a.rev_iterate_aux (λ _, (::)) i h t\n| 0     h t := rfl\n| (i+1) h t := rev_list_reverse_aux i _ _\n\n@[simp] theorem rev_list_reverse : a.rev_list.reverse = a.to_list :=\nrev_list_reverse_aux _ _ _\n\n@[simp] theorem to_list_reverse : a.to_list.reverse = a.rev_list :=\nby rw [←rev_list_reverse, list.reverse_reverse]\n\nend rev_list\n\n/- mem -/\n\nsection mem\nvariables {n : ℕ} {α : Type u} {v : α} {a : array n α}\n\ntheorem mem.def : v ∈ a ↔ ∃ i, a.read i = v :=\niff.rfl\n\ntheorem mem_rev_list_aux : ∀ {i} (h : i ≤ n),\n  (∃ (j : fin n), (j : ℕ) < i ∧ read a j = v) ↔ v ∈ a.iterate_aux (λ _, (::)) i h []\n| 0     _ := ⟨λ ⟨i, n, _⟩, absurd n i.val.not_lt_zero, false.elim⟩\n| (i+1) h := let IH := mem_rev_list_aux (le_of_lt h) in\n  ⟨λ ⟨j, ji1, e⟩, or.elim (lt_or_eq_of_le $ nat.le_of_succ_le_succ ji1)\n    (λ ji, list.mem_cons_of_mem _ $ IH.1 ⟨j, ji, e⟩)\n    (λ je, by simp [d_array.iterate_aux]; apply or.inl; unfold read at e;\n          have H : j = ⟨i, h⟩ := fin.eq_of_veq je; rwa [←H, e]),\n  λ m, begin\n    simp [d_array.iterate_aux, list.mem] at m,\n    cases m with e m',\n    exact ⟨⟨i, h⟩, nat.lt_succ_self _, eq.symm e⟩,\n    exact let ⟨j, ji, e⟩ := IH.2 m' in\n    ⟨j, nat.le_succ_of_le ji, e⟩\n  end⟩\n\n@[simp] theorem mem_rev_list : v ∈ a.rev_list ↔ v ∈ a :=\niff.symm $ iff.trans\n  (exists_congr $ λ j, iff.symm $\n    show j.1 < n ∧ read a j = v ↔ read a j = v,\n    from and_iff_right j.2)\n  (mem_rev_list_aux _)\n\n@[simp] theorem mem_to_list : v ∈ a.to_list ↔ v ∈ a :=\nby rw ←rev_list_reverse; exact list.mem_reverse.trans mem_rev_list\n\nend mem\n\n/- foldr -/\n\nsection foldr\nvariables {n : ℕ} {α : Type u} {β : Type w} {b : β} {f : α → β → β} {a : array n α}\n\ntheorem rev_list_foldr_aux : ∀ {i} (h : i ≤ n),\n  (d_array.iterate_aux a (λ _, (::)) i h []).foldr f b = d_array.iterate_aux a (λ _, f) i h b\n| 0     h := rfl\n| (j+1) h := congr_arg (f (read a ⟨j, h⟩)) (rev_list_foldr_aux _)\n\ntheorem rev_list_foldr : a.rev_list.foldr f b = a.foldl b f :=\nrev_list_foldr_aux _\n\nend foldr\n\n/- foldl -/\n\nsection foldl\nvariables {n : ℕ} {α : Type u} {β : Type w} {b : β} {f : β → α → β} {a : array n α}\n\ntheorem to_list_foldl : a.to_list.foldl f b = a.foldl b (function.swap f) :=\nby rw [←rev_list_reverse, list.foldl_reverse, rev_list_foldr]\n\nend foldl\n\n/- length -/\n\nsection length\nvariables {n : ℕ} {α : Type u}\n\ntheorem rev_list_length_aux (a : array n α) (i h) :\n  (a.iterate_aux (λ _, (::)) i h []).length = i :=\nby induction i; simp [*, d_array.iterate_aux]\n\n@[simp] theorem rev_list_length (a : array n α) : a.rev_list.length = n :=\nrev_list_length_aux a _ _\n\n@[simp] theorem to_list_length (a : array n α) : a.to_list.length = n :=\nby rw[←rev_list_reverse, list.length_reverse, rev_list_length]\n\nend length\n\n/- nth -/\n\nsection nth\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem to_list_nth_le_aux (i : ℕ) (ih : i < n) : ∀ j {jh t h'},\n  (∀ k tl, j + k = i → list.nth_le t k tl = a.read ⟨i, ih⟩) →\n  (a.rev_iterate_aux (λ _, (::)) j jh t).nth_le i h' = a.read ⟨i, ih⟩\n| 0     _  _ _  al := al i _ $ zero_add _\n| (j+1) jh t h' al := to_list_nth_le_aux j $ λ k tl hjk,\n  show list.nth_le (a.read ⟨j, jh⟩ :: t) k tl = a.read ⟨i, ih⟩, from\n  match k, hjk, tl with\n  | 0,    e, tl := match i, e, ih with ._, rfl, _ := rfl end\n  | k'+1, _, tl := by simp[list.nth_le]; exact al _ _ (by simp [add_comm, add_assoc, *]; cc)\n  end\n\ntheorem to_list_nth_le (i : ℕ) (h h') : list.nth_le a.to_list i h' = a.read ⟨i, h⟩ :=\nto_list_nth_le_aux _ _ _ (λ k tl, absurd tl k.not_lt_zero)\n\n@[simp] theorem to_list_nth_le' (a : array n α) (i : fin n) (h') :\n  list.nth_le a.to_list i h' = a.read i :=\nby cases i; apply to_list_nth_le\n\ntheorem to_list_nth {i v} : list.nth a.to_list i = some v ↔ ∃ h, a.read ⟨i, h⟩ = v :=\nbegin\n  rw list.nth_eq_some,\n  have ll := to_list_length a,\n  split; intro h; cases h with h e; subst v,\n  { exact ⟨ll ▸ h, (to_list_nth_le _ _ _).symm⟩ },\n  { exact ⟨ll.symm ▸ h, to_list_nth_le _ _ _⟩ }\nend\n\ntheorem write_to_list {i v} : (a.write i v).to_list = a.to_list.update_nth i v :=\nlist.ext_le (by simp) $ λ j h₁ h₂, begin\n  have h₃ : j < n, {simpa using h₁},\n  rw [to_list_nth_le _ h₃],\n  refine let ⟨_, e⟩ := list.nth_eq_some.1 _ in e.symm,\n  by_cases ij : (i : ℕ) = j,\n  { subst j, rw [show (⟨(i : ℕ), h₃⟩ : fin _) = i, from fin.eq_of_veq rfl,\n      array.read_write, list.nth_update_nth_of_lt],\n    simp [h₃] },\n  { rw [list.nth_update_nth_ne _ _ ij, a.read_write_of_ne,\n        to_list_nth.2 ⟨h₃, rfl⟩],\n    exact fin.ne_of_vne ij }\nend\n\nend nth\n\n/- enum -/\n\nsection enum\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem mem_to_list_enum {i v} : (i, v) ∈ a.to_list.enum ↔ ∃ h, a.read ⟨i, h⟩ = v :=\nby simp [list.mem_iff_nth, to_list_nth, and.comm, and.assoc, and.left_comm]\n\nend enum\n\n/- to_array -/\n\nsection to_array\nvariables {n : ℕ} {α : Type u}\n\n@[simp] theorem to_list_to_array (a : array n α) : a.to_list.to_array == a :=\nheq_of_heq_of_eq\n  (@@eq.drec_on (λ m (e : a.to_list.length = m), (d_array.mk (λ v, a.to_list.nth_le v.1 v.2)) ==\n    (@d_array.mk m (λ _, α) $ λ v, a.to_list.nth_le v.1 $ e.symm ▸ v.2)) a.to_list_length heq.rfl) $\n  d_array.ext $ λ ⟨i, h⟩, to_list_nth_le i h _\n\n@[simp] theorem to_array_to_list (l : list α) : l.to_array.to_list = l :=\nlist.ext_le (to_list_length _) $ λ n h1 h2, to_list_nth_le _ h2 _\n\nend to_array\n\n/- push_back -/\n\nsection push_back\nvariables {n : ℕ} {α : Type u} {v : α} {a : array n α}\n\nlemma push_back_rev_list_aux : ∀ i h h',\n  d_array.iterate_aux (a.push_back v) (λ _, (::)) i h [] = d_array.iterate_aux a (λ _, (::)) i h' []\n| 0 h h' := rfl\n| (i+1) h h' := begin\n  simp [d_array.iterate_aux],\n  refine ⟨_, push_back_rev_list_aux _ _ _⟩,\n  dsimp [read, d_array.read, push_back],\n  rw [dif_neg], refl,\n  exact ne_of_lt h',\nend\n\n@[simp] theorem push_back_rev_list : (a.push_back v).rev_list = v :: a.rev_list :=\nbegin\n  unfold push_back rev_list foldl iterate d_array.iterate,\n  dsimp [d_array.iterate_aux, read, d_array.read, push_back],\n  rw [dif_pos (eq.refl n)],\n  apply congr_arg,\n  apply push_back_rev_list_aux\nend\n\n@[simp] theorem push_back_to_list : (a.push_back v).to_list = a.to_list ++ [v] :=\nby rw [←rev_list_reverse, ←rev_list_reverse, push_back_rev_list, list.reverse_cons]\n\n@[simp] lemma read_push_back_left (i : fin n) : (a.push_back v).read i.cast_succ = a.read i :=\nbegin\n  cases i with i hi,\n  have : ¬ i = n := ne_of_lt hi,\n  simp [push_back, this, fin.cast_succ, fin.cast_add, fin.cast_le, fin.cast_lt, read, d_array.read]\nend\n\n@[simp] lemma read_push_back_right : (a.push_back v).read (fin.last _) = v :=\nbegin\n  cases hn : fin.last n with k hk,\n  have : k = n := by simpa [fin.eq_iff_veq ] using hn.symm,\n  simp [push_back, this, fin.cast_succ, fin.cast_add, fin.cast_le, fin.cast_lt, read, d_array.read]\nend\n\nend push_back\n\n/- foreach -/\n\nsection foreach\nvariables {n : ℕ} {α : Type u} {β : Type v} {i : fin n} {f : fin n → α → β} {a : array n α}\n\n@[simp] theorem read_foreach : (foreach a f).read i = f i (a.read i) :=\nrfl\n\nend foreach\n\n/- map -/\n\nsection map\nvariables {n : ℕ} {α : Type u} {β : Type v} {i : fin n} {f : α → β} {a : array n α}\n\ntheorem read_map : (a.map f).read i = f (a.read i) :=\nread_foreach\n\nend map\n\n/- map₂ -/\n\nsection map₂\nvariables {n : ℕ} {α : Type u} {i : fin n} {f : α → α → α} {a₁ a₂ : array n α}\n\n@[simp] theorem read_map₂ : (map₂ f a₁ a₂).read i = f (a₁.read i) (a₂.read i) :=\nread_foreach\n\nend map₂\n\nend array\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/array/lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802471698041, "lm_q2_score": 0.6959583124210896, "lm_q1q2_score": 0.4655127680320982}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.list.sigma\nimport Mathlib.testing.slim_check.sampleable\nimport Mathlib.testing.slim_check.testable\nimport Mathlib.tactic.pretty_cases\nimport Mathlib.PostPort\n\nuniverses u v l u_1 u_2 w \n\nnamespace Mathlib\n\n/-!\n## `slim_check`: generators for functions\n\nThis file defines `sampleable` instances for `α → β` functions and\n`ℤ → ℤ` injective functions.\n\nFunctions are generated by creating a list of pairs and one more value\nusing the list as a lookup table and resorting to the additional value\nwhen a value is not found in the table.\n\nInjective functions are generated by creating a list of numbers and\na permutation of that list. The permutation insures that every input\nis mapped to a unique output. When an input is not found in the list\nthe input itself is used as an output.\n\nInjective functions `f : α → α` could be generated easily instead of\n`ℤ → ℤ` by generating a `list α`, removing duplicates and creating a\npermutations. One has to be careful when generating the domain to make\nif vast enough that, when generating arguments to apply `f` to,\nthey argument should be likely to lie in the domain of `f`. This is\nthe reason that injective functions `f : ℤ → ℤ` are generated by\nfixing the domain to the range `[-2*size .. -2*size]`, with `size`\nthe size parameter of the `gen` monad.\n\nMuch of the machinery provided in this file is applicable to generate\ninjective functions of type `α → α` and new instances should be easy\nto define.\n\nOther classes of functions such as monotone functions can generated using\nsimilar techniques. For monotone functions, generating two lists, sorting them\nand matching them should suffice, with appropriate default values.\nSome care must be taken for shrinking such functions to make sure\ntheir defining property is invariant through shrinking. Injective\nfunctions are an example of how complicated it can get.\n-/\n\nnamespace slim_check\n\n\n/-- Data structure specifying a total function using a list of pairs\nand a default value returned when the input is not in the domain of\nthe partial function.\n\n`with_default f y` encodes `x ↦ f x` when `x ∈ f` and `x ↦ y`\notherwise.\n\nWe use `Σ` to encode mappings instead of `×` because we\nrely on the association list API defined in `data.list.sigma`.\n -/\ninductive total_function (α : Type u) (β : Type v) \nwhere\n| with_default : List (sigma fun (_x : α) => β) → β → total_function α β\n\nprotected instance total_function.inhabited {α : Type u_1} {β : Type u_2} [Inhabited β] : Inhabited (total_function α β) :=\n  { default := total_function.with_default ∅ Inhabited.default }\n\nnamespace total_function\n\n\n/-- Apply a total function to an argument. -/\ndef apply {α : Type u_1} {β : Type u_2} [DecidableEq α] : total_function α β → α → β :=\n  sorry\n\n/--\nImplementation of `has_repr (total_function α β)`.\n\nCreates a string for a given `finmap` and output, `x₀ ↦ y₀, .. xₙ ↦ yₙ`\nfor each of the entries. The brackets are provided by the calling function.\n-/\ndef repr_aux {α : Type u} [has_repr α] {β : Type v} [has_repr β] (m : List (sigma fun (_x : α) => β)) : string :=\n  string.join\n    (list.qsort (fun (x y : string) => to_bool (x < y))\n      (list.map\n        (fun (x : sigma fun (_x : α) => β) =>\n          string.empty ++ to_string (repr (sigma.fst x)) ++\n            (string.str\n                  (string.str (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit0 (bit0 1)))))))\n                    (char.of_nat\n                      (bit0 (bit1 (bit1 (bit0 (bit0 (bit1 (bit0 (bit1 (bit1 (bit0 (bit0 (bit0 (bit0 1)))))))))))))))\n                  (char.of_nat (bit0 (bit0 (bit0 (bit0 (bit0 1)))))) ++\n                to_string (repr (sigma.snd x)) ++\n              string.str (string.str string.empty (char.of_nat (bit0 (bit0 (bit1 (bit1 (bit0 1)))))))\n                (char.of_nat (bit0 (bit0 (bit0 (bit0 (bit0 1))))))))\n        m))\n\n/--\nProduce a string for a given `total_function`.\nThe output is of the form `[x₀ ↦ f x₀, .. xₙ ↦ f xₙ, _ ↦ y]`.\n-/\nprotected def repr {α : Type u} [has_repr α] {β : Type v} [has_repr β] : total_function α β → string :=\n  sorry\n\nprotected instance has_repr (α : Type u) (β : Type v) [has_repr α] [has_repr β] : has_repr (total_function α β) :=\n  has_repr.mk total_function.repr\n\n/-- Create a `finmap` from a list of pairs. -/\ndef list.to_finmap' {α : Type u_1} {β : Type u_2} (xs : List (α × β)) : List (sigma fun (_x : α) => β) :=\n  list.map prod.to_sigma xs\n\n/-- Redefine `sizeof` to follow the structure of `sampleable` instances. -/\ndef total.sizeof {α : Type u} {β : Type v} [sampleable α] [sampleable β] : total_function α β → ℕ :=\n  sorry\n\nprotected instance has_sizeof {α : Type u} {β : Type v} [sampleable α] [sampleable β] : SizeOf (total_function α β) :=\n  { sizeOf := total.sizeof }\n\n/-- Shrink a total function by shrinking the lists that represent it. -/\nprotected def shrink {α : Type u} {β : Type v} [sampleable α] [sampleable β] [DecidableEq α] : shrink_fn (total_function α β) :=\n  sorry\n\nprotected instance pi.sampleable_ext {α : Type u} {β : Type v} [sampleable α] [sampleable β] [DecidableEq α] [has_repr α] [has_repr β] : sampleable_ext (α → β) :=\n  sampleable_ext.mk (total_function α β)\n    (do \n      sample (List (α × β))\n      uliftable.up (sample β)\n      sorry)\n    total_function.shrink\n\nprotected instance pi_pred.sampleable_ext {α : Type u} [sampleable_ext (α → Bool)] : sampleable_ext (α → Prop) :=\n  sampleable_ext.mk (sampleable_ext.proxy_repr (α → Bool)) (sampleable_ext.sample (α → Bool)) sampleable_ext.shrink\n\nprotected instance pi_uncurry.sampleable_ext {α : Type u} {β : Type v} {γ : Sort w} [sampleable_ext (α × β → γ)] : sampleable_ext (α → β → γ) :=\n  sampleable_ext.mk (sampleable_ext.proxy_repr (α × β → γ)) (sampleable_ext.sample (α × β → γ)) sampleable_ext.shrink\n\nend total_function\n\n\n/--\nData structure specifying a total function using a list of pairs\nand a default value returned when the input is not in the domain of\nthe partial function.\n\n`map_to_self f` encodes `x ↦ f x` when `x ∈ f` and `x ↦ x`,\ni.e. `x` to itself, otherwise.\n\nWe use `Σ` to encode mappings instead of `×` because we\nrely on the association list API defined in `data.list.sigma`.\n-/\ninductive injective_function (α : Type u) \nwhere\n| map_to_self : (xs : List (sigma fun (_x : α) => α)) →\n  list.map sigma.fst xs ~ list.map sigma.snd xs → list.nodup (list.map sigma.snd xs) → injective_function α\n\nprotected instance injective_function.inhabited {α : Type u_1} : Inhabited (injective_function α) :=\n  { default := injective_function.map_to_self [] list.perm.nil list.nodup_nil }\n\nnamespace injective_function\n\n\n/-- Apply a total function to an argument. -/\ndef apply {α : Type u} [DecidableEq α] : injective_function α → α → α :=\n  sorry\n\n/--\nProduce a string for a given `total_function`.\nThe output is of the form `[x₀ ↦ f x₀, .. xₙ ↦ f xₙ, x ↦ x]`.\nUnlike for `total_function`, the default value is not a constant\nbut the identity function.\n-/\nprotected def repr {α : Type u} [has_repr α] : injective_function α → string :=\n  sorry\n\nprotected instance has_repr (α : Type u) [has_repr α] : has_repr (injective_function α) :=\n  has_repr.mk injective_function.repr\n\n/-- Interpret a list of pairs as a total function, defaulting to\nthe identity function when no entries are found for a given function -/\ndef list.apply_id {α : Type u} [DecidableEq α] (xs : List (α × α)) (x : α) : α :=\n  option.get_or_else (list.lookup x (list.map prod.to_sigma xs)) x\n\n@[simp] theorem list.apply_id_cons {α : Type u} [DecidableEq α] (xs : List (α × α)) (x : α) (y : α) (z : α) : list.apply_id ((y, z) :: xs) x = ite (y = x) z (list.apply_id xs x) := sorry\n\ntheorem list.apply_id_zip_eq {α : Type u} [DecidableEq α] {xs : List α} {ys : List α} (h₀ : list.nodup xs) (h₁ : list.length xs = list.length ys) (x : α) (y : α) (i : ℕ) (h₂ : list.nth xs i = some x) : list.apply_id (list.zip xs ys) x = y ↔ list.nth ys i = some y := sorry\n\ntheorem apply_id_mem_iff {α : Type u} [DecidableEq α] {xs : List α} {ys : List α} (h₀ : list.nodup xs) (h₁ : xs ~ ys) (x : α) : list.apply_id (list.zip xs ys) x ∈ ys ↔ x ∈ xs := sorry\n\ntheorem list.apply_id_eq_self {α : Type u} [DecidableEq α] {xs : List α} {ys : List α} (x : α) : ¬x ∈ xs → list.apply_id (list.zip xs ys) x = x := sorry\n\ntheorem apply_id_injective {α : Type u} [DecidableEq α] {xs : List α} {ys : List α} (h₀ : list.nodup xs) (h₁ : xs ~ ys) : function.injective (list.apply_id (list.zip xs ys)) := sorry\n\n/--\nRemove a slice of length `m` at index `n` in a list and a permutation, maintaining the property\nthat it is a permutation.\n-/\ndef perm.slice {α : Type u_1} [DecidableEq α] (n : ℕ) (m : ℕ) : (psigma fun (xs : List α) => psigma fun (ys : List α) => xs ~ ys ∧ list.nodup ys) →\n  psigma fun (xs : List α) => psigma fun (ys : List α) => xs ~ ys ∧ list.nodup ys :=\n  sorry\n\n/--\nA lazy list, in decreasing order, of sizes that should be\nsliced off a list of length `n`\n-/\ndef slice_sizes : ℕ → lazy_list ℕ+ :=\n  sorry\n\n/--\nShrink a permutation of a list, slicing a segment in the middle.\n\nThe sizes of the slice being removed start at `n` (with `n` the length\nof the list) and then `n / 2`, then `n / 4`, etc down to 1. The slices\nwill be taken at index `0`, `n / k`, `2n / k`, `3n / k`, etc.\n-/\nprotected def shrink_perm {α : Type} [DecidableEq α] [SizeOf α] : shrink_fn (psigma fun (xs : List α) => psigma fun (ys : List α) => xs ~ ys ∧ list.nodup ys) :=\n  sorry\n\nprotected instance has_sizeof {α : Type u_1} [SizeOf α] : SizeOf (injective_function α) :=\n  { sizeOf := fun (_x : injective_function α) => sorry }\n\n/--\nShrink an injective function slicing a segment in the middle of the domain and removing\nthe corresponding elements in the codomain, hence maintaining the property that\none is a permutation of the other.\n-/\nprotected def shrink {α : Type} [SizeOf α] [DecidableEq α] : shrink_fn (injective_function α) :=\n  sorry\n\n/-- Create an injective function from one list and a permutation of that list. -/\nprotected def mk {α : Type (max u_1 u_2)} (xs : List α) (ys : List α) (h : xs ~ ys) (h' : list.nodup ys) : injective_function α :=\n  (fun (h₀ : list.length xs ≤ list.length ys) =>\n      (fun (h₁ : list.length ys ≤ list.length xs) =>\n          map_to_self (total_function.list.to_finmap' (list.zip xs ys)) sorry sorry)\n        sorry)\n    sorry\n\nprotected theorem injective {α : Type u} [DecidableEq α] (f : injective_function α) : function.injective (apply f) := sorry\n\nprotected instance pi_injective.sampleable_ext : sampleable_ext (Subtype fun (f : ℤ → ℤ) => function.injective f) :=\n  sampleable_ext.mk (injective_function ℤ)\n    (gen.sized\n      fun (sz : ℕ) =>\n        let xs' : List ℤ := int.range (-(bit0 1 * ↑sz + bit0 1)) (bit0 1 * ↑sz + bit0 1);\n        do \n          let ys ← gen.permutation_of xs'\n          (fun (Hinj : function.injective fun (r : ℕ) => -(bit0 1 * ↑sz + bit0 1) + ↑r) =>\n                let r : injective_function ℤ := injective_function.mk xs' (subtype.val ys) sorry sorry;\n                pure r)\n              sorry)\n    injective_function.shrink\n\nend injective_function\n\n\nprotected instance injective.testable {α : Sort u_1} {β : Sort u_2} (f : α → β) [I : testable\n  (named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n    (∀ (x : α),\n      named_binder (string.str string.empty (char.of_nat (bit1 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n        (∀ (y : α),\n          named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit0 (bit0 1))))))))\n            (f x = f y → x = y))))] : testable (function.injective f) :=\n  I\n\nprotected instance monotone.testable {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α → β) [I : testable\n  (named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n    (∀ (x : α),\n      named_binder (string.str string.empty (char.of_nat (bit1 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n        (∀ (y : α),\n          named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit0 (bit0 1))))))))\n            (x ≤ y → f x ≤ f y))))] : testable (monotone f) :=\n  I\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/testing/slim_check/functions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.46550417671004457}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport algebra.category.Mon.basic\nimport category_theory.endomorphism\n\n/-!\n# Category instances for group, add_group, comm_group, and add_comm_group.\n\nWe introduce the bundled categories:\n* `Group`\n* `AddGroup`\n* `CommGroup`\n* `AddCommGroup`\nalong with the relevant forgetful functors between them, and to the bundled monoid categories.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of groups and group morphisms. -/\n@[to_additive AddGroup]\ndef Group : Type (u+1) := bundled group\n\n/-- The category of additive groups and group morphisms -/\nadd_decl_doc AddGroup\n\nnamespace Group\n\n@[to_additive]\ninstance : bundled_hom.parent_projection group.to_monoid := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] Group\nattribute [to_additive] Group.large_category Group.concrete_category\n\n@[to_additive] instance : has_coe_to_sort Group Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `Group` from the underlying type and typeclass. -/\n@[to_additive] def of (X : Type u) [group X] : Group := bundled.of X\n\n/-- Construct a bundled `AddGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddGroup.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `Group`. -/\n@[to_additive] def of_hom {X Y : Type u} [group X] [group Y] (f : X →* Y) : of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddGroup`. -/\nadd_decl_doc AddGroup.of_hom\n\n@[simp, to_additive] lemma of_hom_apply {X Y : Type*} [group X] [group Y] (f : X →* Y) (x : X) :\n  of_hom f x = f x := rfl\n\n@[to_additive]\ninstance (G : Group) : group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [group R] : (Group.of R : Type u) = R := rfl\n\n@[to_additive]\ninstance : has_one Group := ⟨Group.of punit⟩\n\n@[to_additive]\ninstance : inhabited Group := ⟨1⟩\n\n@[to_additive]\ninstance one.unique : unique (1 : Group) :=\n{ default := 1,\n  uniq := λ a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : Group) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[ext, to_additive]\n\n\n@[to_additive has_forget_to_AddMon]\ninstance has_forget_to_Mon : has_forget₂ Group Mon := bundled_hom.forget₂ _ _\n\nend Group\n\n/-- The category of commutative groups and group morphisms. -/\n@[to_additive AddCommGroup]\ndef CommGroup : Type (u+1) := bundled comm_group\n\n/-- The category of additive commutative groups and group morphisms. -/\nadd_decl_doc AddCommGroup\n\n/-- `Ab` is an abbreviation for `AddCommGroup`, for the sake of mathematicians' sanity. -/\nabbreviation Ab := AddCommGroup\n\nnamespace CommGroup\n\n@[to_additive]\ninstance : bundled_hom.parent_projection comm_group.to_group := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommGroup\nattribute [to_additive] CommGroup.large_category CommGroup.concrete_category\n\n@[to_additive] instance : has_coe_to_sort CommGroup Type* := bundled.has_coe_to_sort\n\n\n/-- Construct a bundled `CommGroup` from the underlying type and typeclass. -/\n@[to_additive] def of (G : Type u) [comm_group G] : CommGroup := bundled.of G\n\n/-- Construct a bundled `AddCommGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddCommGroup.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `CommGroup`. -/\n@[to_additive] def of_hom {X Y : Type u} [comm_group X] [comm_group Y] (f : X →* Y) :\n  of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddCommGroup`. -/\nadd_decl_doc AddCommGroup.of_hom\n\n@[simp, to_additive] lemma of_hom_apply {X Y : Type*} [comm_group X] [comm_group Y] (f : X →* Y)\n  (x : X) : of_hom f x = f x := rfl\n\n@[to_additive]\ninstance comm_group_instance (G : CommGroup) : comm_group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [comm_group R] : (CommGroup.of R : Type u) = R := rfl\n\n@[to_additive] instance : has_one CommGroup := ⟨CommGroup.of punit⟩\n\n@[to_additive] instance : inhabited CommGroup := ⟨1⟩\n\n@[to_additive]\ninstance one.unique : unique (1 : CommGroup) :=\n{ default := 1,\n  uniq := λ a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : CommGroup) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[ext, to_additive]\nlemma ext (G H : CommGroup) (f₁ f₂ : G ⟶ H) (w : ∀ x, f₁ x = f₂ x) : f₁ = f₂ :=\nby { ext1, apply w }\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget₂ CommGroup Group := bundled_hom.forget₂ _ _\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget₂ CommGroup CommMon :=\ninduced_category.has_forget₂ (λ G : CommGroup, CommMon.of G)\n\nend CommGroup\n\n-- This example verifies an improvement possible in Lean 3.8.\n-- Before that, to have `monoid_hom.map_map` usable by `simp` here,\n-- we had to mark all the concrete category `has_coe_to_sort` instances reducible.\n-- Now, it just works.\n@[to_additive]\nexample {R S : CommGroup} (i : R ⟶ S) (r : R) (h : r = 1) : i r = 1 :=\nby simp [h]\n\nnamespace AddCommGroup\n\n/-- Any element of an abelian group gives a unique morphism from `ℤ` sending\n`1` to that element. -/\n-- Note that because `ℤ : Type 0`, this forces `G : AddCommGroup.{0}`,\n-- so we write this explicitly to be clear.\n-- TODO generalize this, requiring a `ulift_instances.lean` file\ndef as_hom {G : AddCommGroup.{0}} (g : G) : (AddCommGroup.of ℤ) ⟶ G :=\nzmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : ℤ) : (as_hom g) i = i • g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\nλ h k w, by convert congr_arg (λ k : (AddCommGroup.of ℤ) ⟶ G, (k : ℤ → G) (1 : ℤ)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of ℤ) ⟶ G) (w : f (1 : ℤ) = g (1 : ℤ)) : f = g :=\nadd_monoid_hom.ext_int w\n\n-- TODO: this argument should be generalised to the situation where\n-- the forgetful functor is representable.\nlemma injective_of_mono {G H : AddCommGroup.{0}} (f : G ⟶ H) [mono f] : function.injective f :=\nλ g₁ g₂ h,\nbegin\n  have t0 : as_hom g₁ ≫ f = as_hom g₂ ≫ f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g₁ = as_hom g₂ := (cancel_mono _).1 t0,\n  apply as_hom_injective t1,\nend\n\nend AddCommGroup\n\n/-- Build an isomorphism in the category `Group` from a `mul_equiv` between `group`s. -/\n@[to_additive add_equiv.to_AddGroup_iso, simps]\ndef mul_equiv.to_Group_iso {X Y : Group} (e : X ≃* Y) : X ≅ Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddGroup` from an `add_equiv` between `add_group`s. -/\nadd_decl_doc add_equiv.to_AddGroup_iso\n\n/-- Build an isomorphism in the category `CommGroup` from a `mul_equiv` between `comm_group`s. -/\n@[to_additive add_equiv.to_AddCommGroup_iso, simps]\ndef mul_equiv.to_CommGroup_iso {X Y : CommGroup} (e : X ≃* Y) : X ≅ Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddCommGroup` from a `add_equiv` between\n`add_comm_group`s. -/\nadd_decl_doc add_equiv.to_AddCommGroup_iso\n\nnamespace category_theory.iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Group`. -/\n@[to_additive AddGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism in the category\n`AddGroup`.\", simps]\ndef Group_iso_to_mul_equiv {X Y : Group} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\n/-- Build a `mul_equiv` from an isomorphism in the category `CommGroup`. -/\n@[to_additive AddCommGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism\nin the category `AddCommGroup`.\", simps]\ndef CommGroup_iso_to_mul_equiv {X Y : CommGroup} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\nend category_theory.iso\n\n/-- multiplicative equivalences between `group`s are the same as (isomorphic to) isomorphisms\nin `Group` -/\n@[to_additive add_equiv_iso_AddGroup_iso \"additive equivalences between `add_group`s are the same\nas (isomorphic to) isomorphisms in `AddGroup`\"]\ndef mul_equiv_iso_Group_iso {X Y : Group.{u}} : (X ≃* Y) ≅ (X ≅ Y) :=\n{ hom := λ e, e.to_Group_iso,\n  inv := λ i, i.Group_iso_to_mul_equiv, }\n\n/-- multiplicative equivalences between `comm_group`s are the same as (isomorphic to) isomorphisms\nin `CommGroup` -/\n@[to_additive add_equiv_iso_AddCommGroup_iso \"additive equivalences between `add_comm_group`s are\nthe same as (isomorphic to) isomorphisms in `AddCommGroup`\"]\ndef mul_equiv_iso_CommGroup_iso {X Y : CommGroup.{u}} : X ≃* Y ≅ (X ≅ Y) :=\n{ hom := λ e, e.to_CommGroup_iso,\n  inv := λ i, i.CommGroup_iso_to_mul_equiv, }\n\nnamespace category_theory.Aut\n\n/-- The (bundled) group of automorphisms of a type is isomorphic to the (bundled) group\nof permutations. -/\ndef iso_perm {α : Type u} : Group.of (Aut α) ≅ Group.of (equiv.perm α) :=\n{ hom := ⟨λ g, g.to_equiv, (by tidy), (by tidy)⟩,\n  inv := ⟨λ g, g.to_iso, (by tidy), (by tidy)⟩ }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {α : Type u} : Aut α ≃* equiv.perm α :=\niso_perm.Group_iso_to_mul_equiv\n\nend category_theory.Aut\n\n@[to_additive]\ninstance Group.forget_reflects_isos : reflects_isomorphisms (forget Group.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Group_iso).1⟩,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommGroup_iso).1⟩,\n  end }\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/category/Group/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529715, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.46550416497345387}}
{"text": "/-\nCopyright (c) 2018-2019 Minchao Wu. All rights reserved.\nReleased under MIT license as described in the file LICENSE.\nAuthor: Minchao Wu\n-/\n\nimport defs\nopen nnf tactic\n\nmeta def frame_restriction : tactic unit :=\ndo intro `a >> `[simp]\n\nstructure KT (states : Type) extends kripke states :=\n(refl : reflexive rel . frame_restriction)\n\ninstance inhabited_KT : inhabited (KT ℕ) := \n⟨{ val := λ a b, tt, rel := λ a b, tt }⟩\n\n@[simp] def force {states : Type} (k : KT states) : states → nnf → Prop\n| s (var n)    := k.val n s\n| s (neg n)    := ¬ k.val n s\n| s (and φ ψ)  := force s φ ∧ force s ψ\n| s (or φ ψ)   := force s φ ∨ force s ψ\n| s (box φ)    := ∀ s', k.rel s s' → force s' φ\n| s (dia φ)    := ∃ s', k.rel s s' ∧ force s' φ\n\ndef sat {st} (k : KT st) (s) (Γ : list nnf) : Prop := \n∀ φ ∈ Γ, force k s φ\n\ndef unsatisfiable (Γ : list nnf) : Prop := \n∀ (st) (k : KT st) s, ¬ sat k s Γ\n\ntheorem unsat_singleton {φ} : unsatisfiable [φ] → ∀ (st) (k : KT st) s, ¬ force k s φ\n := \nbegin\n  intro h, intros, intro hf, \n  apply h, intros ψ hψ, rw list.mem_singleton at hψ, rw hψ, exact hf\nend\n\ntheorem sat_of_empty {st} (k : KT st) (s) : sat k s [] :=\nλ φ h, absurd h $ list.not_mem_nil _\n\ntheorem ne_empty_of_unsat {Γ} (h : unsatisfiable Γ): Γ ≠ [] := \nbegin \n  intro heq, rw heq at h, \n  apply h, apply sat_of_empty, exact nat, \n  apply inhabited_KT.1, exact 0 \nend\n\ninductive model\n| cons : list ℕ → list model → model\n\ninstance : decidable_eq model := by tactic.mk_dec_eq_instance\n\nopen model\n\n@[simp] def mval : ℕ → model → bool\n| p (cons v r) := p ∈ v\n\n@[simp] def mrel : model → model → bool\n| m₁@(cons v r) m₂ := m₂ ∈ r ∨ m₁ = m₂\n\ntheorem refl_mrel (s : model) : mrel s s := by cases s with v r; simp\n\ntheorem mem_of_mrel_tt : Π {v r m}, mrel (cons v r) m = tt → m ∈ r ∨ cons v r = m :=\nbegin\n  intros v r m h, by_cases hc : cons v r = m,\n  {right, exact hc},{left, by_contradiction hn, \n  have : mrel (cons v r) m = ff, { simp [hc, hn] },\n  rw h at this, contradiction}\nend\n\n-- TODO : make this neater. Currently it's just a copy-paste\ntheorem mem_of_mrel_empty : Π {v m}, mrel (cons v []) m = tt → cons v [] = m :=\nbegin\n  intros v m h, by_cases hc : cons v [] = m,\n  {exact hc},\n  {by_contradiction hn, \n  have : mrel (cons v []) m = ff, { simp [hc, hn] },\n  rw h at this, contradiction}\nend\n\n@[simp] def builder : KT model := \n{val := λ n s, mval n s, rel := λ s₁ s₂, mrel s₁ s₂, refl := refl_mrel}\n\ntheorem force_box_of_leaf {v φ} (h : force builder (cons v []) φ): \nforce builder (cons v []) (box φ) :=\nbegin\n  dsimp, intros s' hs',\n  have : cons v [] = s', {apply mem_of_mrel_empty, exact hs'},\n  rw ←this, assumption\nend\n\ndef srefl (m h : list nnf) := \n∀ {v l φ}, sat builder (cons v l) m → \nbox φ ∈ h → \n(∀ ψ, box ψ ∈ h → ∀ m ∈ l, force builder m ψ) → \nforce builder (cons v l) φ\n\nstructure seqt : Type :=\n(main : list nnf)\n(hdld : list nnf)\n-- srefl main hdld says that sequent hdld | main satisfies theorem 3.7(2)\n(pmain : srefl main hdld)\n-- box_only says there are only boxed formulas in hdld\n(phdld : box_only hdld)\n\nclass val_constructible (Γ : seqt) :=\n(satu : saturated Γ.main)\n(no_box_main : ∀ {φ}, box φ ∉ Γ.main)\n(no_contra_main : ∀ {n}, var n ∈ Γ.main → neg n ∉ Γ.main)\n(v : list ℕ)\n(hv : ∀ n, var n ∈ Γ.main ↔ n ∈ v)\n\nclass modal_applicable (Γ : seqt) extends val_constructible Γ :=\n(φ : nnf)\n(ex : dia φ ∈ Γ.main)\n\nclass model_constructible (Γ : seqt) extends val_constructible Γ :=\n(no_dia : ∀ {φ}, nnf.dia φ ∉ Γ.main)\n\ntheorem build_model : Π Γ (h : model_constructible Γ), \nsat builder (cons h.v []) Γ.main := \nbegin\n  intros, intro, intro hmem,\n  cases heq : φ,\n  case nnf.var : n {dsimp, have := h.hv, rw heq at hmem, rw this at hmem, simp [hmem]},\n  case nnf.neg : n {dsimp, have h₁ := h.hv, rw heq at hmem, have := h.no_contra_main, simp, rw ←h₁, intro hvar, apply this, swap, exact hmem, exact hvar},\n  case nnf.box : ψ {dsimp, intros, have := h.no_box_main, exfalso, rw heq at hmem, exact this hmem},\n  case nnf.and : φ ψ { rw heq at hmem, have := h.satu.no_and, have := @this φ ψ, contradiction},\n  case nnf.or : φ ψ { rw heq at hmem, have := h.satu.no_or, have := @this φ ψ, contradiction},\n  case nnf.dia : φ { rw heq at hmem, have := h.no_dia, have := @this φ, contradiction},\nend\n\n\n/- Regular lemmas for the propositional part. -/\n\nsection\nvariables (φ ψ : nnf) (Γ₁ Γ₂ Δ Λ: list nnf) {st : Type}\nvariables (k : KT st) (s : st)\nopen list\n\ntheorem sat_subset (h₁ : Γ₁ ⊆ Γ₂) (h₂ : sat k s Γ₂) : sat k s Γ₁ :=\nλ x hx, h₂ _ (h₁ hx)\n\ntheorem sat_sublist (h₁ : Γ₁ <+ Γ₂) (h₂ :sat k s Γ₂) : sat k s Γ₁ := \nsat_subset _ _ _ _ (sublist.subset h₁) h₂\n\ntheorem sat_append (h₁ : sat k s Γ₁) (h₂ : sat k s Γ₂) : sat k s (Γ₁ ++ Γ₂) :=\nbegin\n  intros φ h, rw mem_append at h, cases h,\n  apply h₁ _ h, apply h₂ _ h\nend\n\ntheorem unsat_contra  {Δ n} : var n ∈ Δ →  neg n ∈ Δ →  unsatisfiable Δ:= \nbegin\n  intros h₁ h₂, intros v hsat, intros s hsat,\n  have := hsat _ h₁, have := hsat _ h₂, simpa\nend\n\ntheorem unsat_contra_seqt {Δ : seqt} {n} : var n ∈ Δ.main →  neg n ∈ Δ.main →  unsatisfiable (Δ.main ++ Δ.hdld):= \nbegin\n  intros h₁ h₂, intros st m, intros s hsat,\n  have := unsat_contra h₁ h₂,\n  have := this _ m s,\n  apply this,\n  apply sat_subset _ _ _ _ _ hsat, \n  simp\nend\n\ntheorem sat_of_and : force k s (and φ ψ) ↔ (force k s φ) ∧ (force k s ψ) := \nby split; {intro, simpa}\n\ntheorem sat_of_sat_erase (h₁ : sat k s $ Δ.erase φ) (h₂ : force k s φ) : sat k s Δ := \nbegin\n  intro ψ, intro h,\n  by_cases (ψ = φ),\n  {rw h, assumption},\n  {have : ψ ∈ Δ.erase φ,\n   rw mem_erase_of_ne, assumption, exact h,\n   apply h₁, assumption}\nend\n\ntheorem unsat_and_of_unsat_split \n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : unsatisfiable $ φ :: ψ :: Δ.erase (and φ ψ)) : \n        unsatisfiable Δ :=\nbegin\n  intro st, intros, intro h,\n  apply h₂, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ h₁, rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ h₁, rw sat_of_and at this, exact this.2}, \n    {have := h _ h₁, apply h, apply mem_of_mem_erase he} }\nend\n\ntheorem unsat_and_of_unsat_split_seqt {Γ}\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : unsatisfiable $ (φ :: ψ :: Δ.erase (and φ ψ)++Γ)) : \n        unsatisfiable (Δ++Γ) :=\nbegin\n  intro st, intros, intro h,\n  apply h₂, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ (mem_append_left _ h₁), rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ (mem_append_left _ h₁), rw sat_of_and at this, exact this.2},\n    {have := h _ (mem_append_left _ h₁), apply h, apply mem_of_mem_erase, rw erase_append_left, exact he, exact h₁} }\nend\n\ntheorem sat_and_of_sat_split\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : sat k s $ φ :: ψ :: Δ.erase (and φ ψ)) : \n        sat k s Δ := \nbegin\n  intro e, intro he,\n  by_cases (e = and φ ψ),\n  { rw h, dsimp, split, repeat {apply h₂, simp} },\n  { have : e ∈ Δ.erase (and φ ψ),\n      { rw mem_erase_of_ne, repeat { assumption } },\n    apply h₂, simp [this] }\nend\n\ntheorem sat_and_of_sat_split_seqt {Γ}\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : sat k s $ (φ :: ψ :: Δ.erase (and φ ψ)++Γ)) : \n        sat k s (Δ++Γ) := \nbegin\n  intro e, intro he,\n  by_cases (e = and φ ψ),\n  { rw h, dsimp, split, repeat {apply h₂, simp} },\n  { have : e ∈ Δ.erase (and φ ψ) ++ Γ,\n      { rw ←erase_append_left, rw mem_erase_of_ne, repeat {assumption} },\n    apply h₂, simp [this] }\nend\n\ntheorem sat_split_of_sat_and_seqt {Γ}\n        (h₁ : and φ ψ ∈ Δ) \n        (h₂ : sat k s (Δ++Γ)) : \n        sat k s $ (φ :: ψ :: Δ.erase (and φ ψ)++Γ) := \nbegin\n  intros e he, rw mem_append at he, cases he,\n  have : force k s (and φ ψ), {apply h₂, simp [h₁]}, rw sat_of_and at this, \n  {cases he, \n  {rw he, exact this.left}, \n  {cases he, rw he, exact this.right, apply h₂, rw mem_append, left, apply mem_of_mem_erase he}\n  },\n  {apply h₂, rw mem_append, right, exact he}\nend\n\ntheorem unsat_or_of_unsat_split_seqt {Γ}\n        (h : or φ ψ ∈ Δ) \n        (h₁ : unsatisfiable $ (φ :: Δ.erase (nnf.or φ ψ)++Γ)) \n        (h₂ : unsatisfiable $ (ψ :: Δ.erase (nnf.or φ ψ)++Γ)) : \n        unsatisfiable $ (Δ++Γ) := \nbegin\n  intro, intros, intro hsat,\n  have := hsat _ (mem_append_left _ h),\n  dsimp at this,\n  cases this,\n  {apply h₁, swap 3, exact k, swap, exact s, intro e, intro he, \n   cases he, rw he, exact this, apply hsat, \napply mem_of_mem_erase, rw erase_append_left, exact he, exact h},\n  {apply h₂, swap 3, exact k, swap, exact s, intro e, intro he, \n   cases he, rw he, exact this, apply hsat, apply mem_of_mem_erase, rw erase_append_left, exact he, exact h}\nend\n\ntheorem sat_or_of_sat_split_left \n        (h : or φ ψ ∈ Δ) \n        (hl : sat k s $ φ :: Δ.erase (nnf.or φ ψ)) :\n        sat k s Δ := \nbegin\n  intros e he,\n  by_cases (e = or φ ψ),\n  { rw h, dsimp, left, apply hl, simp},\n  {have : e ∈ Δ.erase (or φ ψ),\n     { rw mem_erase_of_ne, repeat { assumption } },\n   apply hl, simp [this]}\nend\n\ntheorem sat_or_of_sat_split_right\n        (h : or φ ψ ∈ Δ) \n        (hl : sat k s $ ψ :: Δ.erase (nnf.or φ ψ)) :\n        sat k s Δ := \nbegin\n  intros e he,\n  by_cases (e = or φ ψ),\n  { rw h, dsimp, right, apply hl, simp},\n  { have : e ∈ Δ.erase (or φ ψ),\n      { rw mem_erase_of_ne, repeat { assumption } },\n    apply hl, simp [this] }\nend\n\n/- KT-specific lemmas -/\n\ntheorem force_of_force_box (h : force k s $ box φ) : force k s φ \n:= begin dsimp at h, apply h, apply k.refl end\n\ntheorem unsat_copy_of_unsat_box \n        (h₁ : box φ ∈ Δ) \n        (h₂ : unsatisfiable $ (φ :: Δ.erase (box φ)) ++ box φ :: Λ) : \n        unsatisfiable (Δ ++ Λ) :=\nbegin\n  intros st k s h,\n  apply h₂, swap 3, exact k, swap, exact s,\n  intros e he,\n  rw [mem_append] at he,\n  cases he,\n  {cases he, \n    {rw he, apply force_of_force_box, apply h (box φ), simp [h₁]},\n    {apply h, rw mem_append, left, apply mem_of_mem_erase he }},\n  {cases he, \n    {rw ←he at h₁, apply h, rw mem_append, left, exact h₁},\n    {apply h, rw mem_append, right, assumption}}\nend\n\ntheorem sat_copy_of_sat_box \n        (h₁ : box φ ∈ Δ) \n        (h₂ : sat k s $ (φ :: Δ.erase (box φ)) ++ box φ :: Λ) : \n        sat k s (Δ ++ Λ) :=\nbegin\n  intros ψ hφ,\n  rw mem_append at hφ,\n  cases hφ,\n  {by_cases heq : ψ = box φ, \n    {rw heq, apply h₂ (box φ), simp}, \n    {have := mem_erase_of_ne heq, rw ←this at hφ, apply h₂, simp, right, left, exact hφ}},\n  {apply h₂, simp, repeat {right}, exact hφ}\nend\n\ntheorem sat_box_of_sat_copy\n        (h₁ : box φ ∈ Δ) \n        (h₂ : sat k s (Δ ++ Λ)) : \n        sat k s $ (φ :: Δ.erase (box φ)) ++ box φ :: Λ :=\nbegin\n  apply sat_append,\n  {intros ψ h, cases h, have : sat k s Δ, {apply sat_subset Δ (Δ++Λ), simp, assumption}, have := this _ h₁, apply force_of_force_box, rw h, exact this, apply h₂, have := mem_of_mem_erase h, simp [this]},\n  {intros ψ h, cases h, rw h, have := h₂ (box φ), apply this, simp [h₁], apply h₂, rw mem_append, right, exact h}\nend\n\nend\n\ndef and_child {φ ψ} (Γ : seqt) (h : nnf.and φ ψ ∈ Γ.main) : seqt :=\n⟨φ :: ψ :: Γ.main.erase (and φ ψ), Γ.hdld, \nbegin \n  intros k s γ hsat hin hall, \n  by_cases heq : γ = and φ ψ,\n  {rw heq, split, apply hsat, simp, apply hsat, simp},\n  {apply Γ.pmain _ hin hall, apply sat_and_of_sat_split _ _ _ _ _ h hsat}\nend, \nΓ.phdld⟩\n\ninductive and_instance_seqt (Γ : seqt) : seqt → Type\n| cons : Π {φ ψ} (h : nnf.and φ ψ ∈ Γ.main), \n         and_instance_seqt $ and_child Γ h\n\ndef or_child_left {φ ψ} (Γ : seqt) (h : nnf.or φ ψ ∈ Γ.main) : seqt :=\n⟨φ :: Γ.main.erase (or φ ψ), Γ.hdld, \nbegin \n  intros k s γ hsat hin hall, \n  by_cases heq : γ = or φ ψ,\n  {rw heq, dsimp, left, apply hsat, simp},\n  {apply Γ.pmain, apply sat_or_of_sat_split_left, exact h, exact hsat, exact hin, exact hall}\nend, \nΓ.phdld⟩\n\ndef or_child_right {φ ψ} (Γ : seqt) (h : nnf.or φ ψ ∈ Γ.main) : seqt :=\n⟨ψ :: Γ.main.erase (or φ ψ), Γ.hdld, \nbegin \n  intros k s γ hsat hin hall, \n  by_cases heq : γ = or φ ψ,\n  {rw heq, dsimp, right, apply hsat, simp},\n  {apply Γ.pmain, apply sat_or_of_sat_split_right, exact h, exact hsat, exact hin, exact hall}\nend, \nΓ.phdld⟩\n\ninductive or_instance_seqt (Γ : seqt) : seqt → seqt → Type\n| cons : Π {φ ψ} (h : nnf.or φ ψ ∈ Γ.main),\n         or_instance_seqt (or_child_left Γ h) (or_child_right Γ h)\n\ndef box_child {φ} (Γ : seqt) (h : nnf.box φ ∈ Γ.main) : seqt :=\n⟨φ :: Γ.main.erase (box φ), box φ :: Γ.hdld, \nbegin \n  intros k s γ hsat hin hall, \n  cases hin,\n  {simp at hin, rw hin, apply hsat, simp},\n  {apply Γ.pmain, intros ψ hψ,\n   by_cases heq : ψ = box φ,\n   {rw heq, dsimp, intros s' hs', \n    have := mem_of_mrel_tt hs', cases this,\n    {apply hall, simp, assumption},\n    {rw ←this, apply hsat, simp} },\n   {apply hsat, right, \n    have := list.mem_erase_of_ne heq, swap, exact Γ.main, \n    rw ←this at hψ, assumption},\n  {assumption},{intros, apply hall, simp [a], exact H} }\nend, \ncons_box_only Γ.phdld⟩\n\ninductive copy_instance_seqt (Γ : seqt) : seqt → Type\n| cons : Π {φ} (h : nnf.box φ ∈ Γ.main), \n         copy_instance_seqt $ box_child Γ h\n\ntheorem build_model_seqt : Π Γ (h : model_constructible Γ), \nsat builder (cons h.v []) (Γ.main ++ Γ.hdld) := \nbegin \n  intros Γ h, apply sat_append, apply build_model,\n  intros ψ hψ, \n  have := box_only_ex Γ.phdld hψ, cases this with w hw,\n  rw hw, apply force_box_of_leaf, apply Γ.pmain _ _,\n  {intros ψ hin m hm, exfalso, apply list.not_mem_nil, exact hm},\n  {apply build_model},\n  {rw hw at hψ, assumption}\nend \n", "meta": {"author": "minchaowu", "repo": "ModalTab", "sha": "9bb0bf17faf0554d907ef7bdd639648742889178", "save_path": "github-repos/lean/minchaowu-ModalTab", "path": "github-repos/lean/minchaowu-ModalTab/ModalTab-9bb0bf17faf0554d907ef7bdd639648742889178/src/KT/KT_defs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.4655041640159728}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.polynomial.ring_division\nimport Mathlib.data.mv_polynomial.rename\nimport Mathlib.ring_theory.polynomial.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n## Function extensionality for multivariate polynomials\n\nIn this file we show that two multivariate polynomials over an infinite integral domain are equal\nif they are equal upon evaluating them on an arbitrary assignment of the variables.\n\n# Main declaration\n\n* `mv_polynomial.funext`: two polynomials `φ ψ : mv_polynomial σ R`\n  over an infinite integral domain `R` are equal if `eval x φ = eval x ψ` for all `x : σ → R`.\n\n-/\n\nnamespace mv_polynomial\n\n\n/-- Two multivariate polynomials over an infinite integral domain are equal\nif they are equal upon evaluating them on an arbitrary assignment of the variables. -/\ntheorem funext {R : Type u_1} [integral_domain R] [infinite R] {σ : Type u_2}\n    {p : mv_polynomial σ R} {q : mv_polynomial σ R}\n    (h : ∀ (x : σ → R), coe_fn (eval x) p = coe_fn (eval x) q) : p = q :=\n  sorry\n\ntheorem funext_iff {R : Type u_1} [integral_domain R] [infinite R] {σ : Type u_2}\n    {p : mv_polynomial σ R} {q : mv_polynomial σ R} :\n    p = q ↔ ∀ (x : σ → R), coe_fn (eval x) p = coe_fn (eval x) q :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/mv_polynomial/funext_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4655041591298405}}
{"text": "/-\nCopyright (c) 2018 Luca Gerolla. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Luca Gerolla, Kevin Buzzard\nDefinition of homotopy, properties and equivalence relation. \n-/\nimport analysis.topology.continuity\nimport analysis.topology.topological_space\nimport analysis.topology.infinite_sum\nimport analysis.topology.topological_structures\nimport analysis.topology.uniform_space\nimport analysis.real\nimport data.real.basic tactic.norm_num\nimport data.set.basic\nimport Topology.Material.pasting_lemma\nimport Topology.Material.path \nimport Topology.Material.real_results\n\n\nopen set filter lattice classical\nnamespace homotopy  \nopen path\n\nvariables {α  : Type*} [topological_space α ] \nvariables {β  : Type*} [topological_space β ] { x y z w : β  }\nvariables ( x0 : β  )\nvariable s : I01 \n\nnoncomputable theory\n\nlocal attribute [instance] classical.prop_decidable \n\n-- HOMOTOPY \n\n\n-- General Homotopy \nstructure homotopy  {f : α → β} {g : α → β} ( hcf : continuous f) ( hcg : continuous g) :=\n(to_fun : I01 × α →  β )  \n(at_zero : ( λ x, to_fun ( 0 , x) ) = f )\n(at_one : ( λ x, to_fun ( 1 , x) ) = g)\n(cont :  continuous  to_fun ) \n\n\nstructure path_homotopy ( f : path x y) ( g : path x y) := \n(to_fun : I01 × I01 →  β )\n(path_s : ∀ s : I01, is_path x y ( λ t, to_fun (s, t) ) ) \n(at_zero : ∀ y, to_fun (0,y) = f.to_fun y ) \n(at_one :  ∀ y, to_fun (1,y) = g.to_fun y)\n(cont : continuous to_fun)\n\n-- Simp lemmas\n@[simp] \nlemma at_zero_path_hom { f : path x y } { g : path x y} (F : path_homotopy f g) (y : I01) : \nF.to_fun (0, y) = path.to_fun f y := F.3 y\n\n@[simp] \nlemma at_one_path_hom { f : path x y} { g : path x y} (F : path_homotopy f g) (y : I01): \nF.to_fun (1, y) = path.to_fun g y := F.4 y \n\n@[simp]\nlemma at_pt_zero_hom  { f : path x y} { g : path x y} (F : path_homotopy f g) (s : I01) :\nF.to_fun (s, 0) = x :=  begin exact (F.2 s).1 end \n\n@[simp]\nlemma at_pt_one_hom  { f : path x y} { g : path x y} (F : path_homotopy f g) (s : I01) :\nF.to_fun (s, 1) = y :=  begin exact (F.2 s).2.1  end \n\n\n\nvariables { l  k : path x y } \nvariable F : path_homotopy l k\n\n-- Alternative path_homotopy.mk\ndef path_homotopy.mk'  { f : path x y} { g : path x y}  \n  (F : I01 × I01 →  β) (start_pt : ∀ s : I01, F (s, 0) = x) (end_pt : ∀ s : I01, F (s, 1) = y) \n  (at_zero : ∀ y, F (0,y) = f.to_fun y ) (at_one : ∀ y, F (1,y) = g.to_fun y ) \n  (F_cont : continuous F) : path_homotopy f g := \n{   to_fun := F, \n    path_s := \n    begin \n      unfold is_path, intro s, split, exact start_pt s, split, exact end_pt s, \n      refine continuous.comp _ F_cont, \n      exact continuous.prod_mk continuous_const continuous_id, \n    end, \n    at_zero := at_zero, \n    at_one := at_one, \n    cont := F_cont\n}\n\n\n \n-- Ending points of path_homotopy are fixed  (Can Remove - not Used)\nlemma hom_eq_of_pts { x y : β } { f g : path x y } ( F : path_homotopy f g ) : \n∀ s : I01, check_pts x y ( λ t,  F.to_fun (s, t)) := \nbegin \n  intro s, unfold check_pts, split, \n    have h₁ : F.to_fun (s, 0) =  ( λ t,  F.to_fun (s, t)) 0, by simp, \n    rw h₁ , exact (F.path_s s).left,\n    have h₂  : F.to_fun (s, 1) =  ( λ t,  F.to_fun (s, t)) 1, by simp, \n    rw h₂ , exact (F.path_s s).right.left \nend \n\n--- (Can Remove - not Used)\nlemma hom_path_is_cont { x y : β } { f g : path x y } ( F : path_homotopy f g ) : \n∀ s : I01, continuous ( λ t,  F.to_fun (s, t)) := \nbegin intro s, exact (F.path_s s).right.right end \n\ndef hom_to_path { f g : path x y } ( F : path_homotopy f g ) (s : I01) : path x y := \nto_path ( λ t,  F.to_fun (s, t)) (F.path_s s) \n\n--------------------------------------------\n\n--------------------------------------------\n-- IDENTITY / INVERSE / COMPOSITION of HOMOTOPY \n\n\n--- Identity homotopy \ndef path_homotopy_id { x y : β} (f : path x y) : path_homotopy f f := \n{   to_fun :=  λ st  , f.to_fun (prod.snd st) ,  \n\n    path_s := begin  intro s, unfold is_path, exact ⟨ f.at_zero,  f.at_one, f.cont ⟩ end, \n\n    at_zero := by simp , \n    at_one := by simp ,  \n\n    cont := \n    begin \n      let h := λ st, f.to_fun ( @prod.snd I01 I01 st ) , \n      have hc : continuous h, \n        exact continuous.comp  continuous_snd f.cont, \n      exact hc,\n    end  \n} \n\n--- Inverse homotopy\nlemma help_hom_inv : (λ (st : ↥I01 × ↥I01), F.to_fun (par_inv (st.fst), st.snd)) = \n  ((λ (st : ↥I01 × ↥I01), F.to_fun (st.fst , st.snd)) ∘ \n     (λ (x : I01 × I01) , (( par_inv x.1 , x.2 ) : I01 × I01))) := by trivial\n\ndef path_homotopy_inverse { x y : β} {f : path x y} {g : path x y} ( F : path_homotopy f g) : path_homotopy g f := \n{   to_fun :=   λ st  , F.to_fun ( par_inv st.1 , st.2 ),\n    path_s := \n    begin \n      intro s, unfold is_path, split, \n        exact (F.path_s (par_inv s)).1, split, \n          exact (F.path_s (par_inv s)).2.1, \n          exact (F.path_s (par_inv s)).2.2\n    end,  \n    at_zero := begin intro t,  simp [eqn_1_par_inv],  end, \n    at_one := begin intro t, simp, end,   \n    cont := \n    begin \n      show continuous ((λ (st : ↥I01 × ↥I01), F.to_fun (st.fst , st.snd)) ∘ (λ (x : I01 × I01) , (( par_inv x.1 , x.2 ) : I01 × I01))), \n      have H : continuous (λ (x : I01 × I01) , (( par_inv x.1 , x.2 ) : I01 × I01)),\n        { exact continuous.prod_mk ( continuous.comp  continuous_fst continuous_par_inv) \n          ( @continuous.comp (I01×I01) I01 I01 _ _ _ (λ x : I01×I01, x.2) _ continuous_snd continuous_id) }, \n      simp [continuous.comp H F.cont], \n    end \n} \n\n------------------------------------------\n\n---- Composition of homotopy\n\nlocal notation `I` := @set.univ I01\n\n-- Prove T1 × I01, T2 × I01 cover I01 × I01 \nlemma cover_prod_I01 : ( (set.prod T1 (@set.univ I01)) ∪ (set.prod T2 (@set.univ I01)) ) = \n  @set.univ (I01 × I01) := \nbegin \n  apply set.ext, intro x, split, simp [mem_set_of_eq], \n  intro H, simp, have H : 0 ≤ x.1.val ∧ x.1.val ≤ 1, by exact x.1.property,\n  unfold T1 T2 T, simp [mem_set_of_eq, or_iff_not_imp_left, -one_div_eq_inv], \n  intro nL, have H2 : (1 / 2 :ℝ )< x.1.val, by exact nL H.1, \n  exact ⟨ le_of_lt H2, H.2 ⟩ ,\nend\n\n-- Closedness and intersection of T1 × I01, T2 × I01\nlemma prod_T1_is_closed : is_closed (set.prod T1 I) := \nbegin simp [T1_is_closed, is_closed_prod]  end\n\nlemma prod_T2_is_closed : is_closed (set.prod T2 I) := \nbegin simp [T2_is_closed, is_closed_prod] end\n\nlemma prod_inter_T : set.inter (set.prod T1 I) (set.prod T2 I) = \n  set.prod  { x : I01 | x.val = 1/2 } I := \nbegin \n  unfold T1 T2 T set.inter set.prod, simp [mem_set_of_eq, -one_div_eq_inv], \n  apply set.ext, intro x, split,\n  {rw mem_set_of_eq , rw mem_set_of_eq, simp [-one_div_eq_inv], intros A B C D, \n   have H : x.1.val < 1 / 2 ∨ x.1.val = 1/2, by exact lt_or_eq_of_le B, \n   exact le_antisymm  B C   }, \n  rw mem_set_of_eq , rw mem_set_of_eq, intro H, rw H, norm_num \nend\n\n\n-- Define general / T1 / T2 reparametrised homotopy and prove continuity\ndef fgen_hom { x y : α } {r s : ℝ} {f g: path x y } (Hrs : r < s)\n ( F : path_homotopy f g) : (set.prod (T r s Hrs ) I) → α := \nλ st, F.to_fun (( par Hrs ⟨st.1.1, (mem_prod.1 st.2).1 ⟩) , st.1.2 )\n\n\ntheorem p_hom_cont { x y : α } {r s : ℝ} {f g : path x y } (Hrs : r < s) ( F : path_homotopy f g)  : continuous (fgen_hom Hrs F) := \nbegin \n  unfold fgen_hom, refine continuous.comp _ F.cont , \n  refine continuous.prod_mk _ (continuous.comp continuous_subtype_val continuous_snd), \n  refine continuous.comp _ (continuous_par Hrs), \n  refine continuous_subtype_mk _ _,\n  exact continuous.comp continuous_subtype_val continuous_fst,\nend\n\ndef fa_hom { x y : α }{f g: path x y } ( F : path_homotopy f g) : (set.prod T1 I) → α  := \n@fgen_hom _ _ _ _ 0 (1/2 : ℝ ) _ _  zero_lt_half F \n\nlemma CA_hom { x y : α }{f g: path x y } ( F : path_homotopy f g) : continuous (fa_hom F) := \np_hom_cont zero_lt_half F \n \ndef fb_hom { x y : α }{f g: path x y } ( F : path_homotopy f g) : (set.prod T2 I) → α  := \n@fgen_hom _ _ _ _ (1/2 : ℝ ) 1 _ _  half_lt_one F \n\nlemma CB_hom { x y : α }{f g: path x y } ( F : path_homotopy f g) : continuous (fb_hom F) := \np_hom_cont half_lt_one F \n\n---\n\n-- Other helpful lemmas \n\n@[simp]\nlemma cond_start {f : path x y} {g : path x y} {h : path x y} \n  ( F : path_homotopy f g) ( G : path_homotopy g h) : \n  paste cover_prod_I01 (fa_hom F) (fb_hom G) (s, 0) = x := \nbegin unfold paste, split_ifs, unfold fa_hom fgen_hom, simp, unfold fb_hom fgen_hom, simp, end\n\n@[simp]\nlemma cond_end {f : path x y} {g : path x y} {h : path x y} \n  ( F : path_homotopy f g) ( G : path_homotopy g h) : \n  paste cover_prod_I01 (fa_hom F) (fb_hom G) (s, 1) = y := \nbegin unfold paste, split_ifs, unfold fa_hom fgen_hom, simp, unfold fb_hom fgen_hom, simp, end\n\n-- Homotopy composition\ndef path_homotopy_comp  {f : path x y} {g : path x y} {h : path x y} \n  ( F : path_homotopy f g) ( G : path_homotopy g h) : path_homotopy f h :=\n{   to_fun := λ st, ( @paste (I01 × I01) β (set.prod T1 I) (set.prod T2 I)  cover_prod_I01 ( λ st , (fa_hom F ) st ) ) ( λ st, (fb_hom G ) st  )  st  , \n\n    path_s := \n    begin \n      intro s, unfold is_path, split, simp, \n        split, simp, simp, \n        \n      unfold paste, unfold fa_hom fb_hom fgen_hom, simp, \n      by_cases H : ∀ t : I01, (s, t) ∈ set.prod T1 I, simp [H],  \n        refine (F.path_s (par zero_lt_half ⟨ s, _ ⟩  )).2.2, unfold set.prod at H, \n        have H2 : (s, s) ∈ {p : ↥I01 × ↥I01 | p.fst ∈ T1 ∧ p.snd ∈ univ}, exact H s, simp [mem_set_of_eq] at H2, exact H2, \n        simp at H,\n        have H3:  s ∉ T1, simp [not_forall] at H, exact H.2,\n        simp [H3], refine (G.path_s (par half_lt_one ⟨ s, _ ⟩  )).2.2,        \n        exact T2_of_not_T1 H3, \n    end,  \n\n    at_zero := begin  intro y, simp, unfold paste, rw dif_pos, unfold fa_hom fgen_hom, simp , \n        simp [mem_set_of_eq], exact help_T1,  end, \n\n    at_one := begin intro y, simp, unfold paste, rw dif_neg, unfold fb_hom fgen_hom, simp , \n        simp [mem_set_of_eq], exact help_02, end,  \n\n    cont := \n    begin simp, refine cont_of_paste _ _ _ (CA_hom F) (CB_hom G) , \n      exact prod_T1_is_closed, \n      exact prod_T2_is_closed, \n      unfold match_of_fun, intros x B1 B2, \n        have Int : x ∈ set.inter (set.prod T1 I) (set.prod T2 I), exact ⟨ B1 , B2 ⟩ , \n        rwa [prod_inter_T] at Int, \n        have V : x.1.1 = 1/2, rwa [set.prod, mem_set_of_eq] at Int, rwa [mem_set_of_eq] at Int, exact Int.1, cases x, \n        have xeq : x_fst = ⟨ 1/2 , help_01 ⟩ , apply subtype.eq, rw V,\n        simp [xeq, -one_div_eq_inv], \n        show fa_hom F ⟨(⟨1 / 2, help_01⟩, x_snd), _⟩ = fb_hom G ⟨(⟨1 / 2, help_01⟩, x_snd), _⟩ , unfold fa_hom fb_hom fgen_hom, \n        simp [eqn_1, eqn_2, -one_div_eq_inv], \n    end \n}  \n\n---------------------------------\n\n------------------------------------------------------\n\n---- EQUIVALENCE OF HOMOTOPY\n\n\n\ndefinition is_homotopic_to  (f : path x y) ( g : path x y) : Prop := nonempty ( path_homotopy f g) \n\n\ntheorem is_reflexive : @reflexive (path x y) ( is_homotopic_to ) := \nbegin \n  unfold reflexive, intro f, unfold is_homotopic_to,   \n    have H : path_homotopy f f, \n        exact path_homotopy_id f , \n    exact ⟨ H ⟩ \nend\n\n\ntheorem is_symmetric  : @symmetric (path x y)  (is_homotopic_to) :=\nbegin\n    unfold symmetric, intros f g H, unfold is_homotopic_to,\n    cases H with F, exact ⟨path_homotopy_inverse  F⟩,\nend\n\ntheorem is_transitive  : @transitive (path x y)  (is_homotopic_to) := \nbegin \n    unfold transitive, intros f g h Hfg Hgh, unfold is_homotopic_to at *, \n      cases Hfg  with F,  cases Hgh with G,  \n    exact ⟨ path_homotopy_comp F G⟩ , \nend \n\n\ntheorem is_equivalence : @equivalence (path x y)  (is_homotopic_to) := \n⟨ is_reflexive, is_symmetric, is_transitive⟩ \n\n\n-----------------------------------------------------\n\n\n\nend homotopy", "meta": {"author": "ImperialCollegeLondon", "repo": "xena-UROP-2018", "sha": "b111fb87f343cf79eca3b886f99ee15c1dd9884b", "save_path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018", "path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018/xena-UROP-2018-b111fb87f343cf79eca3b886f99ee15c1dd9884b/src/Topology/Material/homotopy.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6477982043529716, "lm_q1q2_score": 0.46550414935757584}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.wf\nimport Mathlib.Lean3Lib.init.data.nat.basic\n\nnamespace Mathlib\n\nnamespace nat\n\n\nprotected def div (x : ℕ) : ℕ → ℕ := well_founded.fix lt_wf div.F\n\nprotected instance has_div : Div ℕ := { div := nat.div }\n\ntheorem div_def_aux (x : ℕ) (y : ℕ) :\n    x / y =\n        dite (0 < y ∧ y ≤ x) (fun (h : 0 < y ∧ y ≤ x) => (x - y) / y + 1)\n          fun (h : ¬(0 < y ∧ y ≤ x)) => 0 :=\n  congr_fun (well_founded.fix_eq lt_wf div.F x) y\n\nprotected def mod (x : ℕ) : ℕ → ℕ := well_founded.fix lt_wf mod.F\n\nprotected instance has_mod : Mod ℕ := { mod := nat.mod }\n\ntheorem mod_def_aux (x : ℕ) (y : ℕ) :\n    x % y =\n        dite (0 < y ∧ y ≤ x) (fun (h : 0 < y ∧ y ≤ x) => (x - y) % y)\n          fun (h : ¬(0 < y ∧ y ≤ x)) => x :=\n  congr_fun (well_founded.fix_eq lt_wf mod.F x) y\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/data/nat/div_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.46542616654950314}}
{"text": "/-\nCopyright (c) 2017 Daniel Selsam. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Daniel Selsam\n\nMain functional correctness theorem for stochastic backpropagation.\n-/\nimport .util .graph .compute_grad .predicates .estimators .env .dvec .compute_grad_slow_correct .memoize_correct .lemmas .lemmas_extra\n\nnamespace certigrad\nopen tactic list theorems\n\ntheorem backprop_correct {costs : list ID} :\n  ∀ {nodes : list node} (inputs : env) (tgts : list reference),\n  ∀ {tgt : reference} {idx : ℕ}, at_idx tgts idx tgt →\n  nodup (tgts ++ map node.ref nodes) →\n  well_formed_at costs nodes inputs tgt →\n  grads_exist_at nodes inputs tgt →\n  pdfs_exist_at nodes inputs →\n  is_gintegrable (λ m, ⟦compute_grad_slow costs nodes m tgt⟧) inputs nodes dvec.head →\n  can_differentiate_under_integrals costs nodes inputs tgt →\n\n  ∇ (λ θ₀, E (graph.to_dist (λ m, ⟦sum_costs m costs⟧) (env.insert tgt θ₀ inputs) nodes) dvec.head) (env.get tgt inputs)\n  =\n  E (graph.to_dist (λ m, backprop costs nodes m tgts) inputs nodes) (λ dict, dvec.get tgt.2 dict idx) :=\n\nassume (nodes : list node) (inputs : env) (tgts : list reference)\n       (tgt : reference) (idx : ℕ) (H_at_idx : at_idx tgts idx tgt)\n       (H_nd : nodup (tgts ++ map node.ref nodes))\n       (H_wf : well_formed_at costs nodes inputs tgt)\n       (H_gs_exist : grads_exist_at nodes inputs tgt)\n       (H_pdfs_exist : pdfs_exist_at nodes inputs)\n       (H_grad_gint : is_gintegrable (λ m, ⟦compute_grad_slow costs nodes m tgt⟧) inputs nodes dvec.head)\n       (H_diff_under_int : can_differentiate_under_integrals costs nodes inputs tgt),\n\nhave H_gdiff : is_gdifferentiable (λ m, ⟦sum_costs m costs⟧) tgt inputs nodes dvec.head, from\n  is_gdifferentiable_of_pre _ _ _ H_wf H_gs_exist H_pdfs_exist H_diff_under_int,\nhave H_nabla_gint : is_nabla_gintegrable (λ m, ⟦sum_costs m costs⟧) tgt inputs nodes dvec.head, from\n  is_nabla_gintegrable_of_gintegrable _ _ _ H_wf H_gs_exist H_pdfs_exist H_gdiff H_diff_under_int H_grad_gint,\n\nbegin\nrw (compute_grad_slow_correct H_wf H_gs_exist H_pdfs_exist H_gdiff H_nabla_gint H_grad_gint H_diff_under_int),\nrw (E.E_move_fn_to_continuation _ _ _ (λ dict, dvec.get tgt.2 dict idx)),\ndunfold backprop, dsimp,\nsimp only [(λ m, tvec.get_from_env H_at_idx m), (λ m, memoize_correct costs nodes m H_at_idx H_nd)]\nend\n\n\nend certigrad\n", "meta": {"author": "dselsam", "repo": "certigrad", "sha": "c9a06e93f1ec58196d6d3b8563b29868d916727f", "save_path": "github-repos/lean/dselsam-certigrad", "path": "github-repos/lean/dselsam-certigrad/certigrad-c9a06e93f1ec58196d6d3b8563b29868d916727f/src/certigrad/backprop_correct.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.46537428731219066}}
{"text": "import new.unordered.d\nimport new.unordered.C\n\nopen topological_space Top Top.sheaf\nopen category_theory\nopen opposite\n\nuniverse u\nvariables {X : Top.{u}} (𝓕 : sheaf Ab X) (U : X.oc)\n\nsection C_alt\n\nvariables {𝓕 U}\ndef C.pre.is_skewsymmetric {n : ℕ} (f : C.pre 𝓕 U n) : Prop :=\n∀ (i j : fin n) (α : fin n → U.ι),\n  f α =\n  𝓕.1.map (eq_to_hom (face.swap_eq α i j)).op (- f (swap i j α))\n\ndef C.pre.is_skewsymmetric' {n : ℕ} (f : C.pre 𝓕 U n) : Prop :=\n∀ (i j : fin n) (α : fin n → U.ι),\n  f (swap i j α) =\n  - 𝓕.1.map (eq_to_hom (face.swap_eq α i j).symm).op (f α)\n\nlemma is_skewsymmetric_iff_is_skewsymmetric' {n} (f : C.pre 𝓕 U n) :\n  C.pre.is_skewsymmetric f ↔ C.pre.is_skewsymmetric' f :=\n{ mp := λ h i j α, begin\n    specialize h i j α,\n    rw [h, map_neg, map_neg, neg_neg, ← comp_apply, ← 𝓕.1.map_comp, ← op_comp, eq_to_hom_trans, eq_to_hom_refl],\n    simp,\n  end,\n  mpr := λ h i j α, begin\n    specialize h i j α,\n    rw [h, neg_neg, ← comp_apply, ← 𝓕.1.map_comp, ← op_comp, eq_to_hom_trans, eq_to_hom_refl],\n    simp\n  end }\n\nend C_alt\n\ndef C_alt.pre (n : ℕ) : add_subgroup (C 𝓕 U n) :=\n{ carrier := { f : C.pre 𝓕 U n | f.is_skewsymmetric ∧ ∀ (α : fin n → U.ι), ¬ function.injective α → f α = 0},\n  add_mem' := λ f g hf hg, begin\n    rcases hf with ⟨hf1, hf2⟩,\n    rcases hg with ⟨hg1, hg2⟩,\n    split,\n    intros i j α,\n    change f α + g α = 𝓕.1.map _ (- (f _ + g _)),\n    rw [map_neg, map_add, hf1 i j, hg1 i j, map_neg, map_neg, neg_add],\n    \n\n    intros α ha,\n    change f α + g α = 0,\n    rw [hf2, hg2, add_zero];\n    assumption,\n  end,\n  zero_mem' := begin\n    split,\n    intros i j α,\n    simp only [C_pre.zero_apply, neg_zero, map_zero],\n\n    intros α ha,\n    simp,\n  end,\n  neg_mem' := λ f ⟨hf1, hf2⟩, begin\n    split,\n    intros i j α,\n    simp only [C_pre.neg_apply],\n    rw neg_neg,\n    rw hf1 i j,\n    simp only [map_neg, neg_neg],\n\n    intros α ha,\n    change - (f α) = 0,\n    rw hf2 _ ha,\n    rw neg_zero,\n  end }\n\ndef C_alt (n : ℕ) : Ab := AddCommGroup.of $ C_alt.pre 𝓕 U n\n\ndef d_alt (n : ℕ) : C_alt 𝓕 U n ⟶ C_alt 𝓕 U (n + 1) :=\n{ to_fun := λ f, ⟨d 𝓕 U n f.1, sorry⟩,\n  map_zero' := begin\n    rw subtype.ext_iff_val,\n    simp,\n  end,\n  map_add' := begin\n    rintros ⟨f, hf⟩ ⟨g, hg⟩,\n    rw subtype.ext_iff_val,\n    simp,\n  end }\n\nlemma d_alt_d_alt_eq_zero (n : ℕ) :\n  d_alt 𝓕 U n ≫ d_alt 𝓕 U (n + 1) = 0 :=\nbegin\n  ext f α,\n  rw [comp_apply],\n  simp only [AddCommGroup.zero_apply, add_subgroup.coe_zero, C_pre.zero_apply],\n  convert dd_eq_zero 𝓕 U n f.1 α,\nend", "meta": {"author": "jjaassoonn", "repo": "cc", "sha": "6d3dc6885fa012e8c18fd38ab2949d73777fb442", "save_path": "github-repos/lean/jjaassoonn-cc", "path": "github-repos/lean/jjaassoonn-cc/cc-6d3dc6885fa012e8c18fd38ab2949d73777fb442/src/new/alt/skewsymmetric.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.46537428237998923}}
{"text": "import SciLean\nimport Qq\n\nopen SciLean\n\nvariable {X Y Z W : Type} [SemiHilbert X] [SemiHilbert Y] [SemiHilbert Z] [SemiHilbert W]\n         {Y₁ Y₂ : Type} [SemiHilbert Y₁] [SemiHilbert Y₂]\n         {ι κ : Type} [Enumtype ι] [Enumtype κ]\n\n\nexample {n : Nat} : (∇ (x : ℝ^{n}), ‖x‖²) = λ x : ℝ^{n} => (2:ℝ)*x := by symdiff; done\nexample {n : Nat} (m : ℝ) : (∇ (x : ℝ^{n}), 1/2 * m * ‖x‖²) = λ x : ℝ^{n} => m*x := by symdiff; done\n\n\n@[diff]\ntheorem adjoint_sum_eval_rank1 (f : ι → X → Y) [∀ i, HasAdjointT (f i)]\n  : (λ (x : ι → X) => ∑ i, f i (x i))†\n    =\n    λ y i => (f i)† y := by symdiff; sorry\n\n\n\n\n@[diff]\ntheorem adjDiff_sum_eval_rank1 (f : ι → X → Y) [hf : ∀ i, HasAdjDiffT (f i)]\n  : ∂† (λ (x : ι → X) => ∑ i, f i (x i))\n    =\n    λ x dy' i => ∂† (f i) (x i) dy' := \nby \n  unfold adjointDifferential\n  have := λ i => (hf i).1\n  have := λ i => (hf i).2\n  symdiff; symdiff; done\n\n@[diff]\ntheorem revDiff_sum_eval_rank1 (f : ι → X → Y) [hf : ∀ i, HasAdjDiffT (f i)]\n  : ℛ (λ (x : ι → X) => ∑ i, f i (x i))\n    =\n    λ x => (∑ i, f i (x i), λ dy' i => ∂† (f i) (x i) dy') := \nby \n  unfold reverseDifferential\n  symdiff; done\n\n\nunif_hint adjoint_sum_eval_rank1.unif_hint_0\n  (f? : ι → X → Y) \n  (f : ι → W → Y) (h : X → W)\nwhere\n  f? =?= λ i x => f i (h x)\n  |-\n  (λ (x : ι → X) => ∑ i, (f? i) (x i))† \n  =?= \n  (λ (x : ι → X) => ∑ i, f i (h (x i)))†\n\n\n\nunif_hint adjoint_sum_eval_rank1.unif_hint_1 \n  (f? : ι → X → Y) \n  (f : ι → X → α → Y) (g : ι → α)\nwhere\n  f? =?= λ i x => f i x (g i)\n  |-\n  (λ (x : ι → X) => ∑ i, (f? i) (x i))† \n  =?= \n  (λ (x : ι → X) => ∑ i, f i (x i) (g i))†\n\n\nunif_hint adjDiff_sum_eval_rank1.unif_hint_1\n  (f? : ι → X → Y) \n  (f : ι → X → W) (h : ι → W → Y)\nwhere\n  f? =?= λ i x => h i (f i x)\n  |-\n  ∂† (λ (x : ι → X) => ∑ i, (f? i) (x i))\n  =?= \n  ∂† (λ (x : ι → X) => ∑ i, h i (f i (x i)))\n\nunif_hint adjDiff_sum_eval_rank1.unif_hint_2\n  (f? : ι → X → Y) \n  (op : Y₁ → Y₂ → Y)\n  (f₁ : ι → X → Y₁) (f₂ : ι → X → Y₂)-- (h : ι → W → Y)\nwhere\n  f? =?= λ i x => op (f₁ i x) (f₂ i x)\n  |-\n  ∂† (λ (x : ι → X) => ∑ i, (f? i) (x i))\n  =?= \n  ∂† (λ (x : ι → X) => ∑ i, (op (f₁ i (x i)) (f₂ i (x i))))\n\n\nunif_hint adjDiff_sum_eval_rank1.unif_hint_3\n  (f? : ι → ℝ → ℝ) \n  -- (op : Y₁ → Y₂ → Y)\n  -- (f₁ : ι → X → Y₁) (f₂ : ι → X → Y₂)-- (h : ι → W → Y)\nwhere\n  f? =?= λ i x => x * x\n  |-\n  ∂† (λ (x : ι → ℝ) => ∑ i, (f? i) (x i))\n  =?= \n  ∂† (λ (x : ι → ℝ) => ∑ i, x i * x i)\n\n\n@[simp]\ntheorem sum_setElem_zero {Xι} [ArrayType Xι ι X]\n  : ∑ i, setElem (0 : Xι) i (f i) = introElem f := sorry\n\n@[diff]\ntheorem adjDiff_ArrayType_rule_forall₂ {Xι} [ArrayType Xι ι X] (f : ι → X → Y) [∀ i, HasAdjDiffT (f i)]\n  : ∂† (λ (x : Xι) i => f i x[i])\n    =\n    λ x dx' => introElem λ i => ∂† (f i) x[i] (dx' i) := \nby\n  symdiff; simp; done\n\n\nunif_hint adjDiff_ArrayType_rule_forall₂.unif_hint_2 {Xι} [ArrayType Xι ι X]\n  (f? : ι → X → Y)\n  (f : ι → X → W) (h : ι → W → Y)\nwhere\n  f? =?= λ i x => h i (f i x)\n  |-\n  ∂† (λ (x : Xι) i => f? i x[i])\n  =?= \n  ∂† (λ (x : Xι) i => h i (f i x[i]))\n\n@[diff]\ntheorem adjDiff_ArrayType_rule_forall₂.unif_hint_1 {Xι} [ArrayType Xι ι X]\n  (f : ι → X → Y) [∀ i, HasAdjDiffT (f i)]\n  (h : ι → Y → Z) [∀ i, HasAdjDiffT (h i)]\n  : ∂† (λ (x : Xι) i => h i (f i x[i]))\n    =\n    λ x dx' => introElem λ i => ∂† (λ x => h i (f i x)) x[i] (dx' i) := \nby\n  symdiff; done\n\n\nexample {X} [Hilbert X] (c : ℝ) : HasAdjDiffT (fun x : X => c * ‖ x ‖²) := by infer_instance\n\nexample (c : ℝ) : HasAdjDiffT (fun x : ℝ => c * ‖ x ‖² ) := by infer_instance\nexample {X} [Hilbert X] (c : ℝ) : HasAdjDiffT (fun x : X => c * ⟪x,x⟫) := by infer_instance\n\nset_option trace.Meta.Tactic.simp.rewrite true in\nexample {n : Nat} : ∇ (x : Fin n → ℝ), ∑ i, x i  = λ x i =>    1 := by symdiff; done\nset_option trace.Meta.Tactic.simp.rewrite true in\nexample {n : Nat} : ∇ (x : ℝ^{n}),      ∑ i, x[i] = λ x => ⊞ i, 1 := by symdiff; rfl; done\n\nexample {n : Nat} : ∇ (x : Fin n → ℝ), ∑ i, ‖x i‖²  = λ x i =>    (2:ℝ) * x i := by symdiff; done\nexample {n : Nat} : ∇ (x : ℝ^{n}),      ∑ i, ‖x[i]‖² = λ x => ⊞ i, (2:ℝ) * x[i] := by symdiff; rfl; done\n\nexample {n : Nat} (c : ℝ) : ∇ (x : Fin n → ℝ), ∑ i, c * ‖x i‖²  = λ x i =>    2 * c * x i := by symdiff; done \n\nset_option synthInstance.maxSize 1000 \nset_option trace.Meta.Tactic.simp.unify true in\nexample {n : Nat} (c : ℝ) : ∇ (x : ℝ^{n}),      ∑ i, c * ‖x[i]‖² = λ x => ⊞ i, 2 * c * x[i] := by symdiff; rfl; done \n\nset_option trace.Meta.Tactic.simp.discharge true in\nexample {n : Nat} (c : ℝ) : ∂† (λ (x : ℝ^{n}) i => c * ‖x[i]‖²) = λ x dx' => ⊞ i, 2 * c * dx' i * x[i] := by \n  symdiff\n  rw[adjDiff_ArrayType_rule_forall₂.unif_hint]; symdiff; rfl -- (λ _ (x : ℝ) => ‖x‖²) (λ _ (x : ℝ) => c * x)\n  done\n\n\nexample {n : Nat} (c : ℝ) : ∇ (x : Fin n → ℝ), ∑ i, (c + i) * ‖x i‖² = λ x (i : Fin n) => 2 * (c + i) * x i := by symdiff; done \nset_option trace.Meta.Tactic.simp.unify true in\nexample {n : Nat} : ∇ (x : Fin n → ℝ), ∑ i, x i * x i = λ x i => 2 * x i := \nby \n  unfold gradient; funext x; \n  rw[adjDiff_sum_eval_rank1 (λ i xi => xi * xi)]\n  symdiff; done\nexample {n : Nat} : ∇ (x : ℝ^{n}), ∑ i, x[i]*x[i] = λ x => ⊞ i, (2:ℝ) * x[i] := by symdiff; done\n\n\nopen Lean Qq Meta Elab Term\n\n\n\n\ndef unifyTest (lhs rhs : Expr) : MetaM Unit := do\n  let ppLhs ← Meta.ppExpr lhs\n  let ppRhs ← Meta.ppExpr rhs\n  let test ← isDefEq lhs rhs\n  if test then\n    IO.println s!\"Success: {ppLhs} =?= {ppRhs}\"\n  else\n    throwError \"Failure: {ppLhs} =?= {ppRhs}\"\n\nunif_hint \n  (α β γ : Type) (F : (α→β) → (α→γ)) (g : β → γ)\nwhere\n  F =?= λ f x => g (f x)\n  |-\n  (λ f x => g (f x))\n  =?=\n  λ f => F f\n\nunif_hint \n  (α β γ : Type) (F : (α→β) → (α→γ)) (g : β → γ)\nwhere\n  F =?= λ f x => g (f x)\n  |-\n  λ f => F f\n  =?=\n  (λ f x => g (f x))\n\n\nnotation x \" =?= \" y => unifyTest x y\n\n#eval show MetaM Unit from do\n  let f? : Q(Nat→Nat) ← mkFreshExprMVar q(Nat→Nat)\n\n  unifyTest q(λ (x : Nat) => $f? x)\n            q(λ (x : Nat) => Nat.succ (Nat.succ x))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) ← mkFreshExprMVarQ q(Nat)\n  let f? : Q(Nat→Nat) ← mkFreshExprMVarQ q(Nat→Nat)\n\n  unifyTest q(λ (x : Fin $n? → Nat) i => $f? (x i))\n            q(λ (x : Fin $n? → Nat) i => Nat.succ (x i))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) ← mkFreshExprMVarQ q(Nat)\n  let f? : Q(Nat→Nat) ← mkFreshExprMVarQ q(Nat→Nat)\n  let g? : Q(Nat→Nat) ← mkFreshExprMVarQ q(Nat→Nat)\n\n  unifyTest q(λ (x : Fin $n? → Nat) i => $f? (x i))\n            q(λ (x : Fin $n? → Nat) i => $g? (x i))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) ← mkFreshExprMVarQ q(Nat)\n  let F? : Q((Fin $n?→Nat)→(Fin $n?→Nat)) ← mkFreshExprMVarQ q((Fin $n?→Nat)→(Fin $n?→Nat))\n  let g? : Q(Nat→Nat) ← mkFreshExprMVarQ q(Nat→Nat)\n\n  unifyTest q(λ (x : Fin $n? → Nat) => $F? x)\n            q(λ (x : Fin $n? → Nat) i => $g? (x i))\n\n\n#eval show MetaM Unit from do\n  let X? : Q(Type) ← mkFreshExprMVarQ q(Type)\n  let Y? : Q(Type) ← mkFreshExprMVarQ q(Type)\n  let Z? : Q(Type) ← mkFreshExprMVarQ q(Type)\n  let g? : Q($Y?→$Z?) ← mkFreshExprMVarQ q($Y?→$Z?)\n  let h? : Q($Y?→$Z?) ← mkFreshExprMVarQ q($Y?→$Z?)\n\n  q(λ (f : $X? → $Y?) x => $g? (f x))\n  =?= \n  q(λ (f : $X? → $Y?) x => $h? (f x))\n\n\n#eval show MetaM Unit from do\n  let X? : Q(Type) ← mkFreshExprMVarQ q(Type)\n  let Y? : Q(Type) ← mkFreshExprMVarQ q(Type)\n  let F? : Q(($X?→$Y?)→($X?→$Y?)) ← mkFreshExprMVarQ q(($X?→$Y?)→($X?→$Y?))\n  let G? : Q(($X?→$Y?)→($X?→$Y?)) ← mkFreshExprMVarQ q(($X?→$Y?)→($X?→$Y?))\n  let g? : Q($Y?→$Y?) ← mkFreshExprMVarQ q($Y?→$Y?)\n\n  q(λ (f : $X? → $Y?) => $F? f)\n  =?=\n  q(λ (f : $X? → $Y?) x => $g? (f x))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) ← mkFreshExprMVarQ q(Nat)\n  let f? : Q(Nat→Nat) ← mkFreshExprMVarQ q(Nat→Nat)\n\n  unifyTest q(id $ λ (x : Fin $n? → Nat) i => $f? (x i))\n            q(id $ λ (x : Fin $n? → Nat) i => Nat.succ (x i))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) ← mkFreshExprMVarQ q(Nat)\n  let op? : Q(ℝ → ℝ → ℝ) ← mkFreshExprMVarQ q(ℝ → ℝ → ℝ)\n\n  unifyTest q(λ (x : Fin $n? → ℝ) i => $op? (x i) (x i))\n            q(λ (x : Fin $n? → ℝ) i => x i * x i)\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) ← mkFreshExprMVarQ q(Nat)\n  let f? : Q(Fin $n? → ℝ → ℝ) ← mkFreshExprMVarQ q(Fin $n? → ℝ → ℝ)\n\n  unifyTest q(λ (x : Fin $n? → ℝ) i => $f? i (x i))\n            q(λ (x : Fin $n? → ℝ) i => x i * x i)\n\n\n\ndef n := q(10)\n\n\n-- works fine\ndef FinExpr := \n  let n := q(10)\n  q(Fin $n)\n\ndef FinExpr' : Q(Type) := \n  let n := q(10)\n  q(Fin $n) -- unknown identifier '«$n»'\n\n\n-- Construct an expression\ndef a : Expr := q([42 + 1])\n\n-- Construct a typed expression\ndef b : Q(List Nat) := q([42 + 1])\n\ndef b' : Q(Nat) := q(42 + 1)\n\n-- Antiquotations\ndef c := \n  let n : Q(Nat) := q(10)\n  q([42 + $n + $b'])\n\n-- Dependently-typed antiquotations\ndef d (u : Level) (n : Q(Nat)) (x : Q(Type u × Fin ($n + 1))) : Q(Fin ($n + 3)) :=\n  q(⟨$x.2, Nat.lt_of_lt_of_le $x.2.2 (Nat.le_add_right _ 2)⟩)\n\n\n#eval show MetaM Unit from do\n  let a? ← mkFreshExprMVar q(Nat)\n  let b? ← mkFreshExprMVar q(Nat)\n  pure ()\n\n#eval show MetaM Unit from do\n  let a? ← mkFreshExprMVarQ q(Nat)\n  let b? ← mkFreshExprMVarQ q(Nat) -- incompatible metavariable _uniq.146616\n  pure ()\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/tests/core_adjDiff_test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.46533065969376947}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.group.hom\nimport Mathlib.category_theory.limits.shapes.kernels\nimport Mathlib.algebra.big_operators.basic\nimport Mathlib.PostPort\n\nuniverses v u l u_1 \n\nnamespace Mathlib\n\n/-!\n# Preadditive categories\n\nA preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that\ncomposition of morphisms is linear in both variables.\n\nThis file contains a definition of preadditive category that directly encodes the definition given\nabove. The definition could also be phrased as follows: A preadditive category is a category\nenriched over the category of Abelian groups. Once the general framework to state this in Lean is\navailable, the contents of this file should become obsolete.\n\n## Main results\n\n* Definition of preadditive categories and basic properties\n* In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all\n  composable `g`.\n* A preadditive category with kernels has equalizers.\n\n## Implementation notes\n\nThe simp normal form for negation and composition is to push negations as far as possible to\nthe outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)`\nis simplified to `f ≫ g`.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n\n## Tags\n\nadditive, preadditive, Hom group, Ab-category, Ab-enriched\n-/\n\nnamespace category_theory\n\n\n/-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is\n    linear in both variables. -/\nclass preadditive (C : Type u) [category C] where\n  hom_group :\n    autoParam ((P Q : C) → add_comm_group (P ⟶ Q))\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.tactic.apply_instance\")\n        (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"tactic\")\n          \"apply_instance\")\n        [])\n  add_comp' :\n    autoParam (∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R), (f + f') ≫ g = f ≫ g + f' ≫ g)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  comp_add' :\n    autoParam (∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R), f ≫ (g + g') = f ≫ g + f ≫ g')\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n@[simp] theorem preadditive.add_comp {C : Type u} [category C] [c : preadditive C] (P : C) (Q : C)\n    (R : C) (f : P ⟶ Q) (f' : P ⟶ Q) (g : Q ⟶ R) : (f + f') ≫ g = f ≫ g + f' ≫ g :=\n  sorry\n\n@[simp] theorem preadditive.comp_add {C : Type u} [category C] [c : preadditive C] (P : C) (Q : C)\n    (R : C) (f : P ⟶ Q) (g : Q ⟶ R) (g' : Q ⟶ R) : f ≫ (g + g') = f ≫ g + f ≫ g' :=\n  sorry\n\n@[simp] theorem preadditive.add_comp_assoc {C : Type u} [category C] [c : preadditive C] (P : C)\n    (Q : C) (R : C) (f : P ⟶ Q) (f' : P ⟶ Q) (g : Q ⟶ R) {X' : C} :\n    ∀ (f'_1 : R ⟶ X'), (f + f') ≫ g ≫ f'_1 = (f ≫ g + f' ≫ g) ≫ f'_1 :=\n  sorry\n\ntheorem preadditive.comp_add_assoc {C : Type u} [category C] [c : preadditive C] (P : C) (Q : C)\n    (R : C) (f : P ⟶ Q) (g : Q ⟶ R) (g' : Q ⟶ R) {X' : C} (f' : R ⟶ X') :\n    f ≫ (g + g') ≫ f' = (f ≫ g + f ≫ g') ≫ f' :=\n  sorry\n\nend category_theory\n\n\nnamespace category_theory.preadditive\n\n\n/-- Composition by a fixed left argument as a group homomorphism -/\ndef left_comp {C : Type u} [category C] [preadditive C] {P : C} {Q : C} (R : C) (f : P ⟶ Q) :\n    (Q ⟶ R) →+ (P ⟶ R) :=\n  add_monoid_hom.mk' (fun (g : Q ⟶ R) => f ≫ g) sorry\n\n/-- Composition by a fixed right argument as a group homomorphism -/\ndef right_comp {C : Type u} [category C] [preadditive C] (P : C) {Q : C} {R : C} (g : Q ⟶ R) :\n    (P ⟶ Q) →+ (P ⟶ R) :=\n  add_monoid_hom.mk' (fun (f : P ⟶ Q) => f ≫ g) sorry\n\n@[simp] theorem sub_comp_assoc {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C}\n    (f : P ⟶ Q) (f' : P ⟶ Q) (g : Q ⟶ R) {X' : C} :\n    ∀ (f'_1 : R ⟶ X'), (f - f') ≫ g ≫ f'_1 = (f ≫ g - f' ≫ g) ≫ f'_1 :=\n  sorry\n\n-- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma.\n\n@[simp] theorem comp_sub {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C}\n    (f : P ⟶ Q) (g : Q ⟶ R) (g' : Q ⟶ R) : f ≫ (g - g') = f ≫ g - f ≫ g' :=\n  add_monoid_hom.map_sub (left_comp R f) g g'\n\n@[simp] theorem neg_comp {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C}\n    (f : P ⟶ Q) (g : Q ⟶ R) : (-f) ≫ g = -f ≫ g :=\n  add_monoid_hom.map_neg (right_comp P g) f\n\n/- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma. -/\n\ntheorem comp_neg_assoc {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C} (f : P ⟶ Q)\n    (g : Q ⟶ R) {X' : C} (f' : R ⟶ X') : f ≫ (-g) ≫ f' = (-f ≫ g) ≫ f' :=\n  sorry\n\ntheorem neg_comp_neg {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C} (f : P ⟶ Q)\n    (g : Q ⟶ R) : (-f) ≫ (-g) = f ≫ g :=\n  sorry\n\ntheorem comp_sum {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C} {J : Type u_1}\n    {s : finset J} (f : P ⟶ Q) (g : J → (Q ⟶ R)) :\n    (f ≫ finset.sum s fun (j : J) => g j) = finset.sum s fun (j : J) => f ≫ g j :=\n  sorry\n\ntheorem sum_comp_assoc {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C}\n    {J : Type u_1} {s : finset J} (f : J → (P ⟶ Q)) (g : Q ⟶ R) {X' : C} (f' : R ⟶ X') :\n    finset.sum s f ≫ g ≫ f' = (finset.sum s fun (j : J) => f j ≫ g) ≫ f' :=\n  sorry\n\nprotected instance has_neg.neg.category_theory.epi {C : Type u} [category C] [preadditive C] {P : C}\n    {Q : C} {f : P ⟶ Q} [epi f] : epi (-f) :=\n  epi.mk\n    fun (R : C) (g g' : Q ⟶ R) (H : (-f) ≫ g = (-f) ≫ g') =>\n      eq.mp (Eq._oldrec (Eq.refl (-g = -g')) (propext neg_inj))\n        (eq.mp (Eq._oldrec (Eq.refl (f ≫ (-g) = f ≫ (-g'))) (propext (cancel_epi f)))\n          (eq.mp (Eq._oldrec (Eq.refl (f ≫ (-g) = -f ≫ g')) (Eq.symm (comp_neg f g')))\n            (eq.mp (Eq._oldrec (Eq.refl (-f ≫ g = -f ≫ g')) (Eq.symm (comp_neg f g)))\n              (eq.mp (Eq._oldrec (Eq.refl (-f ≫ g = (-f) ≫ g')) (neg_comp f g'))\n                (eq.mp (Eq._oldrec (Eq.refl ((-f) ≫ g = (-f) ≫ g')) (neg_comp f g)) H)))))\n\nprotected instance has_neg.neg.category_theory.mono {C : Type u} [category C] [preadditive C]\n    {P : C} {Q : C} {f : P ⟶ Q} [mono f] : mono (-f) :=\n  mono.mk\n    fun (R : C) (g g' : R ⟶ P) (H : g ≫ (-f) = g' ≫ (-f)) =>\n      eq.mp (Eq._oldrec (Eq.refl (-g = -g')) (propext neg_inj))\n        (eq.mp (Eq._oldrec (Eq.refl ((-g) ≫ f = (-g') ≫ f)) (propext (cancel_mono f)))\n          (eq.mp (Eq._oldrec (Eq.refl ((-g) ≫ f = -g' ≫ f)) (Eq.symm (neg_comp g' f)))\n            (eq.mp (Eq._oldrec (Eq.refl (-g ≫ f = -g' ≫ f)) (Eq.symm (neg_comp g f)))\n              (eq.mp (Eq._oldrec (Eq.refl (-g ≫ f = g' ≫ (-f))) (comp_neg g' f))\n                (eq.mp (Eq._oldrec (Eq.refl (g ≫ (-f) = g' ≫ (-f))) (comp_neg g f)) H)))))\n\nprotected instance preadditive_has_zero_morphisms {C : Type u} [category C] [preadditive C] :\n    limits.has_zero_morphisms C :=\n  limits.has_zero_morphisms.mk\n\ntheorem mono_of_cancel_zero {C : Type u} [category C] [preadditive C] {Q : C} {R : C} (f : Q ⟶ R)\n    (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) : mono f :=\n  mono.mk\n    fun (P : C) (g g' : P ⟶ Q) (hg : g ≫ f = g' ≫ f) =>\n      iff.mp sub_eq_zero\n        (h (g - g')\n          (Eq.trans (add_monoid_hom.map_sub (right_comp P f) g g') (iff.mpr sub_eq_zero hg)))\n\ntheorem mono_iff_cancel_zero {C : Type u} [category C] [preadditive C] {Q : C} {R : C} (f : Q ⟶ R) :\n    mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 :=\n  { mp := fun (m : mono f) (P : C) (g : P ⟶ Q) => limits.zero_of_comp_mono f,\n    mpr := mono_of_cancel_zero f }\n\ntheorem mono_of_kernel_zero {C : Type u} [category C] [preadditive C] {X : C} {Y : C} {f : X ⟶ Y}\n    [limits.has_limit (limits.parallel_pair f 0)] (w : limits.kernel.ι f = 0) : mono f :=\n  sorry\n\ntheorem epi_of_cancel_zero {C : Type u} [category C] [preadditive C] {P : C} {Q : C} (f : P ⟶ Q)\n    (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) : epi f :=\n  epi.mk\n    fun (R : C) (g g' : Q ⟶ R) (hg : f ≫ g = f ≫ g') =>\n      iff.mp sub_eq_zero\n        (h (g - g')\n          (Eq.trans (add_monoid_hom.map_sub (left_comp R f) g g') (iff.mpr sub_eq_zero hg)))\n\ntheorem epi_iff_cancel_zero {C : Type u} [category C] [preadditive C] {P : C} {Q : C} (f : P ⟶ Q) :\n    epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 :=\n  { mp := fun (e : epi f) (R : C) (g : Q ⟶ R) => limits.zero_of_epi_comp f,\n    mpr := epi_of_cancel_zero f }\n\ntheorem epi_of_cokernel_zero {C : Type u} [category C] [preadditive C] {X : C} {Y : C} (f : X ⟶ Y)\n    [limits.has_colimit (limits.parallel_pair f 0)] (w : limits.cokernel.π f = 0) : epi f :=\n  sorry\n\nend preadditive\n\n\n/-- A kernel of `f - g` is an equalizer of `f` and `g`. -/\ntheorem preadditive.has_limit_parallel_pair {C : Type u} [category C] [preadditive C] {X : C}\n    {Y : C} (f : X ⟶ Y) (g : X ⟶ Y) [limits.has_kernel (f - g)] :\n    limits.has_limit (limits.parallel_pair f g) :=\n  sorry\n\n/-- If a preadditive category has all kernels, then it also has all equalizers. -/\ntheorem preadditive.has_equalizers_of_has_kernels {C : Type u} [category C] [preadditive C]\n    [limits.has_kernels C] : limits.has_equalizers C :=\n  limits.has_equalizers_of_has_limit_parallel_pair C\n\n/-- A cokernel of `f - g` is a coequalizer of `f` and `g`. -/\ntheorem preadditive.has_colimit_parallel_pair {C : Type u} [category C] [preadditive C] {X : C}\n    {Y : C} (f : X ⟶ Y) (g : X ⟶ Y) [limits.has_cokernel (f - g)] :\n    limits.has_colimit (limits.parallel_pair f g) :=\n  sorry\n\n/-- If a preadditive category has all cokernels, then it also has all coequalizers. -/\ntheorem preadditive.has_coequalizers_of_has_cokernels {C : Type u} [category C] [preadditive C]\n    [limits.has_cokernels C] : limits.has_coequalizers C :=\n  limits.has_coequalizers_of_has_colimit_parallel_pair C\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/preadditive/default_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.46531545468867985}}
{"text": "/-\nCopyright (c) 2014 Robert Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn\n\n! This file was ported from Lean 3 source module algebra.order.field.canonical.basic\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.Field.Canonical.Defs\n\n/-!\n# Lemmas about canonically ordered semifields.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n-/\n\n\nvariable {α : Type _}\n\nsection CanonicallyLinearOrderedSemifield\n\nvariable [CanonicallyLinearOrderedSemifield α] [Sub α] [OrderedSub α]\n\n/- warning: tsub_div -> tsub_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedSemifield.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedCancelAddCommMonoid.toPartialOrder.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} α _inst_1)))))))) (Distrib.toHasAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} α _inst_1))))))))) _inst_2] (a : α) (b : α) (c : α), Eq.{succ u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} α _inst_1))))))) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) a b) c) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} α _inst_1))))))) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (GroupWithZero.toDivInvMonoid.{u1} α (DivisionSemiring.toGroupWithZero.{u1} α (Semifield.toDivisionSemiring.{u1} α (LinearOrderedSemifield.toSemifield.{u1} α (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} α _inst_1))))))) b c))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedSemifield.{u1} α] [_inst_2 : Sub.{u1} α] [_inst_3 : OrderedSub.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedSemiring.toPartialOrder.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} α _inst_1))))))) (Distrib.toAdd.{u1} α (NonUnitalNonAssocSemiring.toDistrib.{u1} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} α (Semiring.toNonAssocSemiring.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} α _inst_1))))))))) _inst_2] (a : α) (b : α) (c : α), Eq.{succ u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (CanonicallyLinearOrderedSemifield.toDiv.{u1} α _inst_1)) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) a b) c) (HSub.hSub.{u1, u1, u1} α α α (instHSub.{u1} α _inst_2) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (CanonicallyLinearOrderedSemifield.toDiv.{u1} α _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (CanonicallyLinearOrderedSemifield.toDiv.{u1} α _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align tsub_div tsub_divₓ'. -/\ntheorem tsub_div (a b c : α) : (a - b) / c = a / c - b / c := by simp_rw [div_eq_mul_inv, tsub_mul]\n#align tsub_div tsub_div\n\nend CanonicallyLinearOrderedSemifield\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Field/Canonical/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.46521361956262713}}
{"text": "/-\nCopyright (c) 2022 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport algebra.hom.group_instances\nimport topology.algebra.uniform_group\nimport topology.uniform_space.completion\n\n/-!\n# Multiplicative action on the completion of a uniform space\n\nIn this file we define typeclasses `has_uniform_continuous_const_vadd` and\n`has_uniform_continuous_const_smul` and prove that a multiplicative action on `X` with uniformly\ncontinuous `(•) c` can be extended to a multiplicative action on `uniform_space.completion X`.\n\nIn later files once the additive group structure is set up, we provide\n* `uniform_space.completion.distrib_mul_action`\n* `uniform_space.completion.mul_action_with_zero`\n* `uniform_space.completion.module`\n-/\n\nuniverses u v w x y z\n\nnoncomputable theory\n\nvariables (R : Type u) (M : Type v) (N : Type w) (X : Type x) (Y : Type y)\n  [uniform_space X] [uniform_space Y]\n\n/-- An additive action such that for all `c`, the map `λ x, c +ᵥ x` is uniformly continuous. -/\nclass has_uniform_continuous_const_vadd [uniform_space X] [has_vadd M X] : Prop :=\n(uniform_continuous_const_vadd : ∀ (c : M), uniform_continuous ((+ᵥ) c : X → X))\n\n/-- A multiplicative action such that for all `c`, the map `λ x, c • x` is uniformly continuous. -/\n@[to_additive]\nclass has_uniform_continuous_const_smul [uniform_space X] [has_scalar M X] : Prop :=\n(uniform_continuous_const_smul : ∀ (c : M), uniform_continuous ((•) c : X → X))\n\nexport has_uniform_continuous_const_vadd (uniform_continuous_const_vadd)\n  has_uniform_continuous_const_smul (uniform_continuous_const_smul)\n\ninstance add_monoid.has_uniform_continuous_const_smul_nat [add_group X] [uniform_add_group X] :\n  has_uniform_continuous_const_smul ℕ X :=\n⟨uniform_continuous_const_nsmul⟩\n\ninstance add_group.has_uniform_continuous_const_smul_int [add_group X] [uniform_add_group X] :\n  has_uniform_continuous_const_smul ℤ X :=\n⟨uniform_continuous_const_zsmul⟩\n\nsection has_scalar\n\nvariable [has_scalar M X]\n\n@[priority 100, to_additive]\ninstance has_uniform_continuous_const_smul.to_has_continuous_const_smul\n  [has_uniform_continuous_const_smul M X] : has_continuous_const_smul M X :=\n⟨λ c, (uniform_continuous_const_smul c).continuous⟩\n\nvariables {M X Y}\n\n@[to_additive] lemma uniform_continuous.const_smul [has_uniform_continuous_const_smul M X]\n  {f : Y → X} (hf : uniform_continuous f) (c : M) :\n  uniform_continuous (c • f) :=\n(uniform_continuous_const_smul c).comp hf\n\n/-- If a scalar is central, then its right action is uniform continuous when its left action is. -/\n@[priority 100]\ninstance has_uniform_continuous_const_smul.op [has_scalar Mᵐᵒᵖ X] [is_central_scalar M X]\n  [has_uniform_continuous_const_smul M X] : has_uniform_continuous_const_smul Mᵐᵒᵖ X :=\n⟨mul_opposite.rec $ λ c, begin\n  change uniform_continuous (λ m, mul_opposite.op c • m),\n  simp_rw op_smul_eq_smul,\n  exact uniform_continuous_const_smul c,\nend⟩\n\n@[to_additive] instance mul_opposite.has_uniform_continuous_const_smul\n  [has_uniform_continuous_const_smul M X] : has_uniform_continuous_const_smul M Xᵐᵒᵖ :=\n⟨λ c, mul_opposite.uniform_continuous_op.comp $ mul_opposite.uniform_continuous_unop.const_smul c⟩\n\nend has_scalar\n\n@[to_additive] instance uniform_group.to_has_uniform_continuous_const_smul\n  {G : Type u} [group G] [uniform_space G] [uniform_group G] :\n  has_uniform_continuous_const_smul G G :=\n⟨λ c, uniform_continuous_const.mul uniform_continuous_id⟩\n\nnamespace uniform_space\n\nnamespace completion\n\nsection has_scalar\n\nvariable [has_scalar M X]\n\n@[to_additive has_vadd] instance : has_scalar M (completion X) :=\n⟨λ c, completion.map ((•) c)⟩\n\n@[to_additive] instance : has_uniform_continuous_const_smul M (completion X) :=\n⟨λ c, uniform_continuous_map⟩\n\ninstance [has_scalar Mᵐᵒᵖ X] [is_central_scalar M X] : is_central_scalar M (completion X) :=\n⟨λ c a, congr_arg (λ f, completion.map f a) $ by exact funext (op_smul_eq_smul c)⟩\n\nvariables {M X} [has_uniform_continuous_const_smul M X]\n\n@[simp, norm_cast, to_additive]\n\n\nend has_scalar\n\n@[to_additive] instance [monoid M] [mul_action M X] [has_uniform_continuous_const_smul M X] :\n  mul_action M (completion X) :=\n{ smul := (•),\n  one_smul := ext' (continuous_const_smul _) continuous_id $ λ a, by rw [← coe_smul, one_smul],\n  mul_smul := λ x y, ext' (continuous_const_smul _) ((continuous_const_smul _).const_smul _) $\n    λ a, by simp only [← coe_smul, mul_smul] }\n\nend completion\n\nend uniform_space\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/topology/algebra/uniform_mul_action.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.46521361956262713}}
{"text": "import Advent\n\ninductive DDigit (base: Nat)\n  | Z\n  | DP (d: Fin base)\n  | DN (d: Fin base)\nderiving Repr, BEq, Inhabited\n\ninstance {base}: ToString (DDigit base) where\n  toString \n  | .Z => \"0\"\n  | .DP x => toString <| (x : Nat) + 1\n  | .DN x => \"-\" ++ (toString <| (x : Nat) + 1)\n\ndef DoubleSys base := Array (DDigit base)\nnamespace DoubleSys\n  instance {base}: BEq (DoubleSys base) where beq (x: Array _) y := x == y\n  instance {base}: Inhabited (DoubleSys base) where default := Array.empty\n  instance {base}: ToString (DoubleSys base) where \n    toString := Array.foldl (·.append <| char · |> (·.push '|')) \"\"\n  where \n    char\n    | .Z => \"0\"\n    | .DP d => s!\"{d.succ}\"\n    | .DN d => s!\"-{d.succ}\"\n\n  instance {base}: Coe (DoubleSys base) Nat where\n    coe := Array.foldl addDig 0\n  where\n    base' := base * 2 + 1 \n    addDig n\n    | .Z => n * base'\n    | .DP d => n * base' + d + 1\n    | .DN d => n * base' - d - 1\n\n  private theorem doubleLe: b > 0 -> a < b * 2 -> ¬ (a < b) -> b * 2 - 1 - a < b := by \n    intros u p q\n    rw [<-Nat.sub_add_eq] \n    have p₂: b = b * 2 - b := by \n      rw [Nat.mul_add b 1 1]\n      simp\n    conv => rhs; rw [p₂]\n    apply Nat.sub_lt_sub_left\n    . apply Nat.lt_add_of_pos_left\n      simp\n      assumption\n    . apply Nat.lt_of_not_le\n      intro p\n      apply q\n      apply Nat.lt_of_succ_le\n      rw [Nat.add_comm] at p\n      assumption\n      \n  instance {base}: Coe Nat (DoubleSys base) where\n    coe x := go Array.empty x x\n  where\n    go acc x\n    | 0 => acc.reverse\n    | fuel + 1 => \n      let base' := base * 2 + 1\n      if x == 0 then acc.reverse else\n      let r := x % base'\n      let x' := x / base'\n      let d := match q: r with\n        | 0 => DDigit.Z\n        | r' + 1 => \n          if p: r' < base then DDigit.DP ⟨ r', p ⟩\n          else \n            let r'' := base * 2 - 1 - r'\n            DDigit.DN <| Fin.mk r'' <| by \n              apply doubleLe\n              . apply Nat.lt_of_not_le\n                intro p₂\n                rw [Nat.le_zero] at p₂\n                have bq: base' = base * 2 + 1 := Eq.refl _\n                conv at bq =>\n                  rw [p₂]\n                  rhs\n                  simp\n                have rp: r = x % base' := Eq.refl _\n                have rp₂ : x % base' < 1 := by \n                  rw [<-bq]\n                  apply Nat.mod_lt\n                  apply Nat.zero_lt_of_ne_zero\n                  simp\n                rw [←rp, q] at rp₂\n                contradiction\n              . apply Nat.lt_of_succ_le\n                rw [<-q]\n                apply Nat.le_of_lt_succ\n                have qq: base' = (base * 2).succ := by simp\n                rw [<-qq]\n                have qqq: r = x % base' := by simp\n                rw [qqq]\n                apply Nat.mod_lt\n                rw [qq]\n                apply Nat.zero_lt_succ\n              . assumption\n      let x := if let .DN _ := d then x' + 1 else x'\n      go (acc.push d) x fuel\n\n\nend DoubleSys\n\n\nabbrev SNAFU := DoubleSys 2\n\ndef readSnafu (s: String): Option SNAFU := \n  s.toList.toArray.mapM go\nwhere \n  go: Char -> Option (DDigit 2)\n  | '-' => some <| DDigit.DN 0\n  | '=' => some <| DDigit.DN 1\n  | '0' => some <| DDigit.Z\n  | '1' => some <| DDigit.DP 0\n  | '2' => some <| DDigit.DP 1\n  | _   => none\n\ndef writeSnafu : SNAFU -> String := \n  String.mk ∘ Array.toList ∘ Array.map toChar\nwhere \n  toChar\n  | DDigit.DN 0 => '-'\n  | DDigit.DN 1 => '='\n  | DDigit.Z => '0'\n  | DDigit.DP 0 => '1'\n  | DDigit.DP 1 => '2'\n\ndef main: IO Unit := do \n  let lines <- readLines 25\n  let snafus := (lines.mapM readSnafu).get!\n  snafus.forM IO.println\n  let nats: List Nat := snafus.map <| λ (x: SNAFU) => ↑x\n  nats.forM IO.println\n  let back := nats.map (fun (x: Nat) => (x: SNAFU))\n  if back == snafus then IO.println \"OK!\"\n  let s := nats.sum\n  IO.println s\n  IO.println <| writeSnafu s\n", "meta": {"author": "Odomontois", "repo": "advent2022-lean", "sha": "75634a2257287ec1536690f8dbd92573f670e0e2", "save_path": "github-repos/lean/Odomontois-advent2022-lean", "path": "github-repos/lean/Odomontois-advent2022-lean/advent2022-lean-75634a2257287ec1536690f8dbd92573f670e0e2/days/day25.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257127, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.46521361346207385}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.geom_sum\nimport Mathlib.order.filter.archimedean\nimport Mathlib.order.iterate\nimport Mathlib.topology.instances.ennreal\nimport Mathlib.tactic.ring_exp\nimport Mathlib.analysis.asymptotics\nimport Mathlib.PostPort\n\nuniverses u_1 u_4 \n\nnamespace Mathlib\n\n/-!\n# A collection of specific limit computations\n-/\n\ntheorem tendsto_norm_at_top_at_top : filter.tendsto norm filter.at_top filter.at_top :=\n  filter.tendsto_abs_at_top_at_top\n\ntheorem summable_of_absolute_convergence_real {f : ℕ → ℝ} : (∃ (r : ℝ),\n    filter.tendsto (fun (n : ℕ) => finset.sum (finset.range n) fun (i : ℕ) => abs (f i)) filter.at_top (nhds r)) →\n  summable f := sorry\n\ntheorem tendsto_inverse_at_top_nhds_0_nat : filter.tendsto (fun (n : ℕ) => ↑n⁻¹) filter.at_top (nhds 0) :=\n  filter.tendsto.comp tendsto_inv_at_top_zero tendsto_coe_nat_at_top_at_top\n\ntheorem tendsto_const_div_at_top_nhds_0_nat (C : ℝ) : filter.tendsto (fun (n : ℕ) => C / ↑n) filter.at_top (nhds 0) := sorry\n\ntheorem nnreal.tendsto_inverse_at_top_nhds_0_nat : filter.tendsto (fun (n : ℕ) => ↑n⁻¹) filter.at_top (nhds 0) := sorry\n\ntheorem nnreal.tendsto_const_div_at_top_nhds_0_nat (C : nnreal) : filter.tendsto (fun (n : ℕ) => C / ↑n) filter.at_top (nhds 0) := sorry\n\ntheorem tendsto_one_div_add_at_top_nhds_0_nat : filter.tendsto (fun (n : ℕ) => 1 / (↑n + 1)) filter.at_top (nhds 0) := sorry\n\n/-! ### Powers -/\n\ntheorem tendsto_add_one_pow_at_top_at_top_of_pos {α : Type u_1} [linear_ordered_semiring α] [archimedean α] {r : α} (h : 0 < r) : filter.tendsto (fun (n : ℕ) => (r + 1) ^ n) filter.at_top filter.at_top :=\n  filter.tendsto_at_top_at_top_of_monotone' (fun (n m : ℕ) => pow_le_pow (le_add_of_nonneg_left (le_of_lt h)))\n    (iff.mpr not_bdd_above_iff fun (x : α) => iff.mpr set.exists_range_iff (add_one_pow_unbounded_of_pos x h))\n\ntheorem tendsto_pow_at_top_at_top_of_one_lt {α : Type u_1} [linear_ordered_ring α] [archimedean α] {r : α} (h : 1 < r) : filter.tendsto (fun (n : ℕ) => r ^ n) filter.at_top filter.at_top :=\n  sub_add_cancel r 1 ▸ tendsto_add_one_pow_at_top_at_top_of_pos (iff.mpr sub_pos h)\n\ntheorem nat.tendsto_pow_at_top_at_top_of_one_lt {m : ℕ} (h : 1 < m) : filter.tendsto (fun (n : ℕ) => m ^ n) filter.at_top filter.at_top :=\n  nat.sub_add_cancel (le_of_lt h) ▸ tendsto_add_one_pow_at_top_at_top_of_pos (nat.sub_pos_of_lt h)\n\ntheorem tendsto_norm_zero' {𝕜 : Type u_1} [normed_group 𝕜] : filter.tendsto norm (nhds_within 0 (set_of fun (x : 𝕜) => x ≠ 0)) (nhds_within 0 (set.Ioi 0)) :=\n  filter.tendsto.inf tendsto_norm_zero\n    (iff.mpr filter.tendsto_principal_principal\n      fun (x : 𝕜) (hx : x ∈ set_of fun (x : 𝕜) => x ≠ 0) => iff.mpr norm_pos_iff hx)\n\ntheorem normed_field.tendsto_norm_inverse_nhds_within_0_at_top {𝕜 : Type u_1} [normed_field 𝕜] : filter.tendsto (fun (x : 𝕜) => norm (x⁻¹)) (nhds_within 0 (set_of fun (x : 𝕜) => x ≠ 0)) filter.at_top :=\n  filter.tendsto.congr (fun (x : 𝕜) => Eq.symm (normed_field.norm_inv x))\n    (filter.tendsto.comp tendsto_inv_zero_at_top tendsto_norm_zero')\n\ntheorem tendsto_pow_at_top_nhds_0_of_lt_1 {𝕜 : Type u_1} [linear_ordered_field 𝕜] [archimedean 𝕜] [topological_space 𝕜] [order_topology 𝕜] {r : 𝕜} (h₁ : 0 ≤ r) (h₂ : r < 1) : filter.tendsto (fun (n : ℕ) => r ^ n) filter.at_top (nhds 0) := sorry\n\ntheorem tendsto_pow_at_top_nhds_within_0_of_lt_1 {𝕜 : Type u_1} [linear_ordered_field 𝕜] [archimedean 𝕜] [topological_space 𝕜] [order_topology 𝕜] {r : 𝕜} (h₁ : 0 < r) (h₂ : r < 1) : filter.tendsto (fun (n : ℕ) => r ^ n) filter.at_top (nhds_within 0 (set.Ioi 0)) :=\n  iff.mpr filter.tendsto_inf\n    { left := tendsto_pow_at_top_nhds_0_of_lt_1 (has_lt.lt.le h₁) h₂,\n      right := iff.mpr filter.tendsto_principal (filter.eventually_of_forall fun (n : ℕ) => pow_pos h₁ n) }\n\ntheorem is_o_pow_pow_of_lt_left {r₁ : ℝ} {r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ < r₂) : asymptotics.is_o (fun (n : ℕ) => r₁ ^ n) (fun (n : ℕ) => r₂ ^ n) filter.at_top := sorry\n\ntheorem is_O_pow_pow_of_le_left {r₁ : ℝ} {r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ ≤ r₂) : asymptotics.is_O (fun (n : ℕ) => r₁ ^ n) (fun (n : ℕ) => r₂ ^ n) filter.at_top :=\n  or.elim (has_le.le.eq_or_lt h₂) (fun (h : r₁ = r₂) => h ▸ asymptotics.is_O_refl (fun (n : ℕ) => r₁ ^ n) filter.at_top)\n    fun (h : r₁ < r₂) => asymptotics.is_o.is_O (is_o_pow_pow_of_lt_left h₁ h)\n\ntheorem is_o_pow_pow_of_abs_lt_left {r₁ : ℝ} {r₂ : ℝ} (h : abs r₁ < abs r₂) : asymptotics.is_o (fun (n : ℕ) => r₁ ^ n) (fun (n : ℕ) => r₂ ^ n) filter.at_top :=\n  asymptotics.is_o.of_norm_right\n    (asymptotics.is_o.of_norm_left\n      (asymptotics.is_o.congr (pow_abs r₁) (pow_abs r₂) (is_o_pow_pow_of_lt_left (abs_nonneg r₁) h)))\n\n/-- Various statements equivalent to the fact that `f n` grows exponentially slower than `R ^ n`.\n\n* 0: $f n = o(a ^ n)$ for some $-R < a < R$;\n* 1: $f n = o(a ^ n)$ for some $0 < a < R$;\n* 2: $f n = O(a ^ n)$ for some $-R < a < R$;\n* 3: $f n = O(a ^ n)$ for some $0 < a < R$;\n* 4: there exist `a < R` and `C` such that one of `C` and `R` is positive and $|f n| ≤ Ca^n$\n     for all `n`;\n* 5: there exists `0 < a < R` and a positive `C` such that $|f n| ≤ Ca^n$ for all `n`;\n* 6: there exists `a < R` such that $|f n| ≤ a ^ n$ for sufficiently large `n`;\n* 7: there exists `0 < a < R` such that $|f n| ≤ a ^ n$ for sufficiently large `n`.\n\nNB: For backwards compatibility, if you add more items to the list, please append them at the end of\nthe list. -/\ntheorem tfae_exists_lt_is_o_pow (f : ℕ → ℝ) (R : ℝ) : tfae\n  [∃ (a : ℝ), ∃ (H : a ∈ set.Ioo (-R) R), asymptotics.is_o f (pow a) filter.at_top,\n    ∃ (a : ℝ), ∃ (H : a ∈ set.Ioo 0 R), asymptotics.is_o f (pow a) filter.at_top,\n    ∃ (a : ℝ), ∃ (H : a ∈ set.Ioo (-R) R), asymptotics.is_O f (pow a) filter.at_top,\n    ∃ (a : ℝ), ∃ (H : a ∈ set.Ioo 0 R), asymptotics.is_O f (pow a) filter.at_top,\n    ∃ (a : ℝ), ∃ (H : a < R), ∃ (C : ℝ), ∃ (h₀ : 0 < C ∨ 0 < R), ∀ (n : ℕ), abs (f n) ≤ C * a ^ n,\n    ∃ (a : ℝ), ∃ (H : a ∈ set.Ioo 0 R), ∃ (C : ℝ), ∃ (H : C > 0), ∀ (n : ℕ), abs (f n) ≤ C * a ^ n,\n    ∃ (a : ℝ), ∃ (H : a < R), filter.eventually (fun (n : ℕ) => abs (f n) ≤ a ^ n) filter.at_top,\n    ∃ (a : ℝ), ∃ (H : a ∈ set.Ioo 0 R), filter.eventually (fun (n : ℕ) => abs (f n) ≤ a ^ n) filter.at_top] := sorry\n\ntheorem uniformity_basis_dist_pow_of_lt_1 {α : Type u_1} [metric_space α] {r : ℝ} (h₀ : 0 < r) (h₁ : r < 1) : filter.has_basis (uniformity α) (fun (k : ℕ) => True)\n  fun (k : ℕ) => set_of fun (p : α × α) => dist (prod.fst p) (prod.snd p) < r ^ k :=\n  metric.mk_uniformity_basis (fun (i : ℕ) (_x : True) => pow_pos h₀ i)\n    fun (ε : ℝ) (ε0 : 0 < ε) =>\n      Exists.imp (fun (k : ℕ) (hk : r ^ k < ε) => Exists.intro trivial (has_lt.lt.le hk)) (exists_pow_lt_of_lt_one ε0 h₁)\n\ntheorem geom_lt {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) {n : ℕ} (hn : 0 < n) (h : ∀ (k : ℕ), k < n → c * u k < u (k + 1)) : c ^ n * u 0 < u n := sorry\n\ntheorem geom_le {u : ℕ → ℝ} {c : ℝ} (hc : 0 ≤ c) (n : ℕ) (h : ∀ (k : ℕ), k < n → c * u k ≤ u (k + 1)) : c ^ n * u 0 ≤ u n := sorry\n\n/-- For any natural `k` and a real `r > 1` we have `n ^ k = o(r ^ n)` as `n → ∞`. -/\ntheorem is_o_pow_const_const_pow_of_one_lt {R : Type u_1} [normed_ring R] (k : ℕ) {r : ℝ} (hr : 1 < r) : asymptotics.is_o (fun (n : ℕ) => ↑n ^ k) (fun (n : ℕ) => r ^ n) filter.at_top := sorry\n\n/-- For a real `r > 1` we have `n = o(r ^ n)` as `n → ∞`. -/\ntheorem is_o_coe_const_pow_of_one_lt {R : Type u_1} [normed_ring R] {r : ℝ} (hr : 1 < r) : asymptotics.is_o coe (fun (n : ℕ) => r ^ n) filter.at_top := sorry\n\n/-- If `∥r₁∥ < r₂`, then for any naturak `k` we have `n ^ k r₁ ^ n = o (r₂ ^ n)` as `n → ∞`. -/\ntheorem is_o_pow_const_mul_const_pow_const_pow_of_norm_lt {R : Type u_1} [normed_ring R] (k : ℕ) {r₁ : R} {r₂ : ℝ} (h : norm r₁ < r₂) : asymptotics.is_o (fun (n : ℕ) => ↑n ^ k * r₁ ^ n) (fun (n : ℕ) => r₂ ^ n) filter.at_top := sorry\n\ntheorem tendsto_pow_const_div_const_pow_of_one_lt (k : ℕ) {r : ℝ} (hr : 1 < r) : filter.tendsto (fun (n : ℕ) => ↑n ^ k / r ^ n) filter.at_top (nhds 0) :=\n  asymptotics.is_o.tendsto_0 (is_o_pow_const_const_pow_of_one_lt k hr)\n\n/-- If `|r| < 1`, then `n ^ k r ^ n` tends to zero for any natural `k`. -/\ntheorem tendsto_pow_const_mul_const_pow_of_abs_lt_one (k : ℕ) {r : ℝ} (hr : abs r < 1) : filter.tendsto (fun (n : ℕ) => ↑n ^ k * r ^ n) filter.at_top (nhds 0) := sorry\n\n/-- If a sequence `v` of real numbers satisfies `k * v n ≤ v (n+1)` with `1 < k`,\nthen it goes to +∞. -/\ntheorem tendsto_at_top_of_geom_le {v : ℕ → ℝ} {c : ℝ} (h₀ : 0 < v 0) (hc : 1 < c) (hu : ∀ (n : ℕ), c * v n ≤ v (n + 1)) : filter.tendsto v filter.at_top filter.at_top :=\n  filter.tendsto_at_top_mono\n    (fun (n : ℕ) => geom_le (has_le.le.trans zero_le_one (has_lt.lt.le hc)) n fun (k : ℕ) (hk : k < n) => hu k)\n    (filter.tendsto.at_top_mul_const h₀ (tendsto_pow_at_top_at_top_of_one_lt hc))\n\ntheorem nnreal.tendsto_pow_at_top_nhds_0_of_lt_1 {r : nnreal} (hr : r < 1) : filter.tendsto (fun (n : ℕ) => r ^ n) filter.at_top (nhds 0) := sorry\n\ntheorem ennreal.tendsto_pow_at_top_nhds_0_of_lt_1 {r : ennreal} (hr : r < 1) : filter.tendsto (fun (n : ℕ) => r ^ n) filter.at_top (nhds 0) := sorry\n\n/-- In a normed ring, the powers of an element x with `∥x∥ < 1` tend to zero. -/\ntheorem tendsto_pow_at_top_nhds_0_of_norm_lt_1 {R : Type u_1} [normed_ring R] {x : R} (h : norm x < 1) : filter.tendsto (fun (n : ℕ) => x ^ n) filter.at_top (nhds 0) :=\n  squeeze_zero_norm' (eventually_norm_pow_le x) (tendsto_pow_at_top_nhds_0_of_lt_1 (norm_nonneg x) h)\n\ntheorem tendsto_pow_at_top_nhds_0_of_abs_lt_1 {r : ℝ} (h : abs r < 1) : filter.tendsto (fun (n : ℕ) => r ^ n) filter.at_top (nhds 0) :=\n  tendsto_pow_at_top_nhds_0_of_norm_lt_1 h\n\n/-! ### Geometric series-/\n\ntheorem has_sum_geometric_of_lt_1 {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) : has_sum (fun (n : ℕ) => r ^ n) (1 - r⁻¹) := sorry\n\ntheorem summable_geometric_of_lt_1 {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) : summable fun (n : ℕ) => r ^ n :=\n  Exists.intro (1 - r⁻¹) (has_sum_geometric_of_lt_1 h₁ h₂)\n\ntheorem tsum_geometric_of_lt_1 {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) : (tsum fun (n : ℕ) => r ^ n) = (1 - r⁻¹) :=\n  has_sum.tsum_eq (has_sum_geometric_of_lt_1 h₁ h₂)\n\ntheorem has_sum_geometric_two : has_sum (fun (n : ℕ) => (1 / bit0 1) ^ n) (bit0 1) := sorry\n\ntheorem summable_geometric_two : summable fun (n : ℕ) => (1 / bit0 1) ^ n :=\n  Exists.intro (bit0 1) has_sum_geometric_two\n\ntheorem tsum_geometric_two : (tsum fun (n : ℕ) => (1 / bit0 1) ^ n) = bit0 1 :=\n  has_sum.tsum_eq has_sum_geometric_two\n\ntheorem sum_geometric_two_le (n : ℕ) : (finset.sum (finset.range n) fun (i : ℕ) => (1 / bit0 1) ^ i) ≤ bit0 1 := sorry\n\ntheorem has_sum_geometric_two' (a : ℝ) : has_sum (fun (n : ℕ) => a / bit0 1 / bit0 1 ^ n) a := sorry\n\ntheorem summable_geometric_two' (a : ℝ) : summable fun (n : ℕ) => a / bit0 1 / bit0 1 ^ n :=\n  Exists.intro a (has_sum_geometric_two' a)\n\ntheorem tsum_geometric_two' (a : ℝ) : (tsum fun (n : ℕ) => a / bit0 1 / bit0 1 ^ n) = a :=\n  has_sum.tsum_eq (has_sum_geometric_two' a)\n\ntheorem nnreal.has_sum_geometric {r : nnreal} (hr : r < 1) : has_sum (fun (n : ℕ) => r ^ n) (1 - r⁻¹) := sorry\n\ntheorem nnreal.summable_geometric {r : nnreal} (hr : r < 1) : summable fun (n : ℕ) => r ^ n :=\n  Exists.intro (1 - r⁻¹) (nnreal.has_sum_geometric hr)\n\ntheorem tsum_geometric_nnreal {r : nnreal} (hr : r < 1) : (tsum fun (n : ℕ) => r ^ n) = (1 - r⁻¹) :=\n  has_sum.tsum_eq (nnreal.has_sum_geometric hr)\n\n/-- The series `pow r` converges to `(1-r)⁻¹`. For `r < 1` the RHS is a finite number,\nand for `1 ≤ r` the RHS equals `∞`. -/\ntheorem ennreal.tsum_geometric (r : ennreal) : (tsum fun (n : ℕ) => r ^ n) = (1 - r⁻¹) := sorry\n\ntheorem has_sum_geometric_of_norm_lt_1 {K : Type u_4} [normed_field K] {ξ : K} (h : norm ξ < 1) : has_sum (fun (n : ℕ) => ξ ^ n) (1 - ξ⁻¹) := sorry\n\ntheorem summable_geometric_of_norm_lt_1 {K : Type u_4} [normed_field K] {ξ : K} (h : norm ξ < 1) : summable fun (n : ℕ) => ξ ^ n :=\n  Exists.intro (1 - ξ⁻¹) (has_sum_geometric_of_norm_lt_1 h)\n\ntheorem tsum_geometric_of_norm_lt_1 {K : Type u_4} [normed_field K] {ξ : K} (h : norm ξ < 1) : (tsum fun (n : ℕ) => ξ ^ n) = (1 - ξ⁻¹) :=\n  has_sum.tsum_eq (has_sum_geometric_of_norm_lt_1 h)\n\ntheorem has_sum_geometric_of_abs_lt_1 {r : ℝ} (h : abs r < 1) : has_sum (fun (n : ℕ) => r ^ n) (1 - r⁻¹) :=\n  has_sum_geometric_of_norm_lt_1 h\n\ntheorem summable_geometric_of_abs_lt_1 {r : ℝ} (h : abs r < 1) : summable fun (n : ℕ) => r ^ n :=\n  summable_geometric_of_norm_lt_1 h\n\ntheorem tsum_geometric_of_abs_lt_1 {r : ℝ} (h : abs r < 1) : (tsum fun (n : ℕ) => r ^ n) = (1 - r⁻¹) :=\n  tsum_geometric_of_norm_lt_1 h\n\n/-- A geometric series in a normed field is summable iff the norm of the common ratio is less than\none. -/\n@[simp] theorem summable_geometric_iff_norm_lt_1 {K : Type u_4} [normed_field K] {ξ : K} : (summable fun (n : ℕ) => ξ ^ n) ↔ norm ξ < 1 := sorry\n\ntheorem summable_norm_pow_mul_geometric_of_norm_lt_1 {R : Type u_1} [normed_ring R] (k : ℕ) {r : R} (hr : norm r < 1) : summable fun (n : ℕ) => norm (↑n ^ k * r ^ n) := sorry\n\ntheorem summable_pow_mul_geometric_of_norm_lt_1 {R : Type u_1} [normed_ring R] [complete_space R] (k : ℕ) {r : R} (hr : norm r < 1) : summable fun (n : ℕ) => ↑n ^ k * r ^ n :=\n  summable_of_summable_norm (summable_norm_pow_mul_geometric_of_norm_lt_1 k hr)\n\n/-- If `∥r∥ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `has_sum` version. -/\ntheorem has_sum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type u_1} [normed_field 𝕜] [complete_space 𝕜] {r : 𝕜} (hr : norm r < 1) : has_sum (fun (n : ℕ) => ↑n * r ^ n) (r / (1 - r) ^ bit0 1) := sorry\n\n/-- If `∥r∥ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`. -/\ntheorem tsum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type u_1} [normed_field 𝕜] [complete_space 𝕜] {r : 𝕜} (hr : norm r < 1) : (tsum fun (n : ℕ) => ↑n * r ^ n) = r / (1 - r) ^ bit0 1 :=\n  has_sum.tsum_eq (has_sum_coe_mul_geometric_of_norm_lt_1 hr)\n\n/-!\n### Sequences with geometrically decaying distance in metric spaces\n\nIn this paragraph, we discuss sequences in metric spaces or emetric spaces for which the distance\nbetween two consecutive terms decays geometrically. We show that such sequences are Cauchy\nsequences, and bound their distances to the limit. We also discuss series with geometrically\ndecaying terms.\n-/\n\n/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, `C ≠ ∞`, `r < 1`,\nthen `f` is a Cauchy sequence.-/\ntheorem cauchy_seq_of_edist_le_geometric {α : Type u_1} [emetric_space α] (r : ennreal) (C : ennreal) (hr : r < 1) (hC : C ≠ ⊤) {f : ℕ → α} (hu : ∀ (n : ℕ), edist (f n) (f (n + 1)) ≤ C * r ^ n) : cauchy_seq f := sorry\n\n/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, then the distance from\n`f n` to the limit of `f` is bounded above by `C * r^n / (1 - r)`. -/\ntheorem edist_le_of_edist_le_geometric_of_tendsto {α : Type u_1} [emetric_space α] (r : ennreal) (C : ennreal) {f : ℕ → α} (hu : ∀ (n : ℕ), edist (f n) (f (n + 1)) ≤ C * r ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) (n : ℕ) : edist (f n) a ≤ C * r ^ n / (1 - r) := sorry\n\n/-- If `edist (f n) (f (n+1))` is bounded by `C * r^n`, then the distance from\n`f 0` to the limit of `f` is bounded above by `C / (1 - r)`. -/\ntheorem edist_le_of_edist_le_geometric_of_tendsto₀ {α : Type u_1} [emetric_space α] (r : ennreal) (C : ennreal) {f : ℕ → α} (hu : ∀ (n : ℕ), edist (f n) (f (n + 1)) ≤ C * r ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) : edist (f 0) a ≤ C / (1 - r) := sorry\n\n/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then `f` is a Cauchy sequence.-/\ntheorem cauchy_seq_of_edist_le_geometric_two {α : Type u_1} [emetric_space α] (C : ennreal) (hC : C ≠ ⊤) {f : ℕ → α} (hu : ∀ (n : ℕ), edist (f n) (f (n + 1)) ≤ C / bit0 1 ^ n) : cauchy_seq f := sorry\n\n/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then the distance from\n`f n` to the limit of `f` is bounded above by `2 * C * 2^-n`. -/\ntheorem edist_le_of_edist_le_geometric_two_of_tendsto {α : Type u_1} [emetric_space α] (C : ennreal) {f : ℕ → α} (hu : ∀ (n : ℕ), edist (f n) (f (n + 1)) ≤ C / bit0 1 ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) (n : ℕ) : edist (f n) a ≤ bit0 1 * C / bit0 1 ^ n := sorry\n\n/-- If `edist (f n) (f (n+1))` is bounded by `C * 2^-n`, then the distance from\n`f 0` to the limit of `f` is bounded above by `2 * C`. -/\ntheorem edist_le_of_edist_le_geometric_two_of_tendsto₀ {α : Type u_1} [emetric_space α] (C : ennreal) {f : ℕ → α} (hu : ∀ (n : ℕ), edist (f n) (f (n + 1)) ≤ C / bit0 1 ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) : edist (f 0) a ≤ bit0 1 * C := sorry\n\ntheorem aux_has_sum_of_le_geometric {α : Type u_1} [metric_space α] {r : ℝ} {C : ℝ} (hr : r < 1) {f : ℕ → α} (hu : ∀ (n : ℕ), dist (f n) (f (n + 1)) ≤ C * r ^ n) : has_sum (fun (n : ℕ) => C * r ^ n) (C / (1 - r)) := sorry\n\n/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then `f` is a Cauchy sequence.\nNote that this lemma does not assume `0 ≤ C` or `0 ≤ r`. -/\ntheorem cauchy_seq_of_le_geometric {α : Type u_1} [metric_space α] (r : ℝ) (C : ℝ) (hr : r < 1) {f : ℕ → α} (hu : ∀ (n : ℕ), dist (f n) (f (n + 1)) ≤ C * r ^ n) : cauchy_seq f :=\n  cauchy_seq_of_dist_le_of_summable (fun (n : ℕ) => C * r ^ n) hu\n    (Exists.intro (C / (1 - r)) (aux_has_sum_of_le_geometric hr hu))\n\n/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then the distance from\n`f n` to the limit of `f` is bounded above by `C * r^n / (1 - r)`. -/\ntheorem dist_le_of_le_geometric_of_tendsto₀ {α : Type u_1} [metric_space α] (r : ℝ) (C : ℝ) (hr : r < 1) {f : ℕ → α} (hu : ∀ (n : ℕ), dist (f n) (f (n + 1)) ≤ C * r ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a ≤ C / (1 - r) :=\n  has_sum.tsum_eq (aux_has_sum_of_le_geometric hr hu) ▸\n    dist_le_tsum_of_dist_le_of_tendsto₀ (fun (b : ℕ) => C * r ^ b) hu\n      (Exists.intro (C / (1 - r)) (aux_has_sum_of_le_geometric hr hu)) ha\n\n/-- If `dist (f n) (f (n+1))` is bounded by `C * r^n`, `r < 1`, then the distance from\n`f 0` to the limit of `f` is bounded above by `C / (1 - r)`. -/\ntheorem dist_le_of_le_geometric_of_tendsto {α : Type u_1} [metric_space α] (r : ℝ) (C : ℝ) (hr : r < 1) {f : ℕ → α} (hu : ∀ (n : ℕ), dist (f n) (f (n + 1)) ≤ C * r ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) (n : ℕ) : dist (f n) a ≤ C * r ^ n / (1 - r) := sorry\n\n/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then `f` is a Cauchy sequence. -/\ntheorem cauchy_seq_of_le_geometric_two {α : Type u_1} [metric_space α] (C : ℝ) {f : ℕ → α} (hu₂ : ∀ (n : ℕ), dist (f n) (f (n + 1)) ≤ C / bit0 1 / bit0 1 ^ n) : cauchy_seq f :=\n  cauchy_seq_of_dist_le_of_summable (fun (n : ℕ) => C / bit0 1 / bit0 1 ^ n) hu₂\n    (Exists.intro C (has_sum_geometric_two' C))\n\n/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then the distance from\n`f 0` to the limit of `f` is bounded above by `C`. -/\ntheorem dist_le_of_le_geometric_two_of_tendsto₀ {α : Type u_1} [metric_space α] (C : ℝ) {f : ℕ → α} (hu₂ : ∀ (n : ℕ), dist (f n) (f (n + 1)) ≤ C / bit0 1 / bit0 1 ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a ≤ C :=\n  tsum_geometric_two' C ▸\n    dist_le_tsum_of_dist_le_of_tendsto₀ (fun (n : ℕ) => C / bit0 1 / bit0 1 ^ n) hu₂ (summable_geometric_two' C) ha\n\n/-- If `dist (f n) (f (n+1))` is bounded by `(C / 2) / 2^n`, then the distance from\n`f n` to the limit of `f` is bounded above by `C / 2^n`. -/\ntheorem dist_le_of_le_geometric_two_of_tendsto {α : Type u_1} [metric_space α] (C : ℝ) {f : ℕ → α} (hu₂ : ∀ (n : ℕ), dist (f n) (f (n + 1)) ≤ C / bit0 1 / bit0 1 ^ n) {a : α} (ha : filter.tendsto f filter.at_top (nhds a)) (n : ℕ) : dist (f n) a ≤ C / bit0 1 ^ n := sorry\n\ntheorem dist_partial_sum_le_of_le_geometric {α : Type u_1} [normed_group α] {r : ℝ} {C : ℝ} {f : ℕ → α} (hf : ∀ (n : ℕ), norm (f n) ≤ C * r ^ n) (n : ℕ) : dist (finset.sum (finset.range n) fun (i : ℕ) => f i) (finset.sum (finset.range (n + 1)) fun (i : ℕ) => f i) ≤ C * r ^ n := sorry\n\n/-- If `∥f n∥ ≤ C * r ^ n` for all `n : ℕ` and some `r < 1`, then the partial sums of `f` form a\nCauchy sequence. This lemma does not assume `0 ≤ r` or `0 ≤ C`. -/\ntheorem cauchy_seq_finset_of_geometric_bound {α : Type u_1} [normed_group α] {r : ℝ} {C : ℝ} {f : ℕ → α} (hr : r < 1) (hf : ∀ (n : ℕ), norm (f n) ≤ C * r ^ n) : cauchy_seq fun (s : finset ℕ) => finset.sum s fun (x : ℕ) => f x :=\n  cauchy_seq_finset_of_norm_bounded (fun (n : ℕ) => C * r ^ n)\n    (has_sum.summable (aux_has_sum_of_le_geometric hr (dist_partial_sum_le_of_le_geometric hf))) hf\n\n/-- If `∥f n∥ ≤ C * r ^ n` for all `n : ℕ` and some `r < 1`, then the partial sums of `f` are within\ndistance `C * r ^ n / (1 - r)` of the sum of the series. This lemma does not assume `0 ≤ r` or\n`0 ≤ C`. -/\ntheorem norm_sub_le_of_geometric_bound_of_has_sum {α : Type u_1} [normed_group α] {r : ℝ} {C : ℝ} {f : ℕ → α} (hr : r < 1) (hf : ∀ (n : ℕ), norm (f n) ≤ C * r ^ n) {a : α} (ha : has_sum f a) (n : ℕ) : norm ((finset.sum (finset.range n) fun (x : ℕ) => f x) - a) ≤ C * r ^ n / (1 - r) := sorry\n\n/-- A geometric series in a complete normed ring is summable.\nProved above (same name, different namespace) for not-necessarily-complete normed fields. -/\ntheorem normed_ring.summable_geometric_of_norm_lt_1 {R : Type u_4} [normed_ring R] [complete_space R] (x : R) (h : norm x < 1) : summable fun (n : ℕ) => x ^ n := sorry\n\n/-- Bound for the sum of a geometric series in a normed ring.  This formula does not assume that the\nnormed ring satisfies the axiom `∥1∥ = 1`. -/\ntheorem normed_ring.tsum_geometric_of_norm_lt_1 {R : Type u_4} [normed_ring R] [complete_space R] (x : R) (h : norm x < 1) : norm (tsum fun (n : ℕ) => x ^ n) ≤ norm 1 - 1 + (1 - norm x⁻¹) := sorry\n\ntheorem geom_series_mul_neg {R : Type u_4} [normed_ring R] [complete_space R] (x : R) (h : norm x < 1) : (tsum fun (i : ℕ) => x ^ i) * (1 - x) = 1 := sorry\n\ntheorem mul_neg_geom_series {R : Type u_4} [normed_ring R] [complete_space R] (x : R) (h : norm x < 1) : ((1 - x) * tsum fun (i : ℕ) => x ^ i) = 1 := sorry\n\n/-! ### Positive sequences with small sums on encodable types -/\n\n/-- For any positive `ε`, define on an encodable type a positive sequence with sum less than `ε` -/\ndef pos_sum_of_encodable {ε : ℝ} (hε : 0 < ε) (ι : Type u_1) [encodable ι] : Subtype fun (ε' : ι → ℝ) => (∀ (i : ι), 0 < ε' i) ∧ ∃ (c : ℝ), has_sum ε' c ∧ c ≤ ε :=\n  let f : ℕ → ℝ := fun (n : ℕ) => ε / bit0 1 / bit0 1 ^ n;\n  { val := f ∘ encodable.encode, property := sorry }\n\nnamespace nnreal\n\n\ntheorem exists_pos_sum_of_encodable {ε : nnreal} (hε : 0 < ε) (ι : Type u_1) [encodable ι] : ∃ (ε' : ι → nnreal), (∀ (i : ι), 0 < ε' i) ∧ ∃ (c : nnreal), has_sum ε' c ∧ c < ε := sorry\n\nend nnreal\n\n\nnamespace ennreal\n\n\ntheorem exists_pos_sum_of_encodable {ε : ennreal} (hε : 0 < ε) (ι : Type u_1) [encodable ι] : ∃ (ε' : ι → nnreal), (∀ (i : ι), 0 < ε' i) ∧ (tsum fun (i : ι) => ↑(ε' i)) < ε := sorry\n\nend ennreal\n\n\n/-!\n### Factorial\n-/\n\ntheorem factorial_tendsto_at_top : filter.tendsto nat.factorial filter.at_top filter.at_top :=\n  filter.tendsto_at_top_at_top_of_monotone nat.monotone_factorial fun (n : ℕ) => Exists.intro n (nat.self_le_factorial n)\n\ntheorem tendsto_factorial_div_pow_self_at_top : filter.tendsto (fun (n : ℕ) => ↑(nat.factorial n) / ↑n ^ n) filter.at_top (nhds 0) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/specific_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.4650481036558553}}
{"text": "import data.matrix data.rat.basic .misc tactic.fin_cases\nimport .matrix_pequiv order.order_iso .simplex_new_pivot\n\nopen matrix fintype finset function pequiv simplex simplex.prebasis\n\nvariables {m n k: ℕ}\n\nlocal notation `rvec`:2000 n := matrix (fin 1) (fin n) ℚ\nlocal notation `cvec`:2000 m := matrix (fin m) (fin 1) ℚ\nlocal infix ` ⬝ `:70 := matrix.mul\nlocal postfix `ᵀ` : 1500 := transpose\nlocal attribute [instance] matrix.partial_order\n\nnamespace simplex'\n\ndef choose_pivot_column (AN_bar : matrix (fin m) (fin (n - m)) ℚ)\n  (c : rvec (n - m)) : option (fin (n - m)) :=\nfin.find (λ s : fin (n - m), 0 < c 0 s)\n\ndef choose_pivot_row (AN_bar : matrix (fin m) (fin (n - m)) ℚ) (b_bar : cvec m)\n  (s : fin (n - m)) : option (fin m) :=\nfin.find (λ r : fin m, 0 < AN_bar r s ∧ ∀ i : fin m, 0 < AN_bar i s →\n  (AN_bar r s)⁻¹ * b_bar r 0 ≤ (AN_bar i s)⁻¹ * b_bar i 0)\n\nlemma choose_pivot_column_eq_none (B : prebasis m n) (A_bar : matrix (fin m) (fin n) ℚ)\n  (b_bar : cvec m) (c : rvec n) (hA_bar : A_bar ⬝ B.basis.to_matrixᵀ = 1)\n  (h0b : 0 ≤ b_bar)\n  (h : choose_pivot_column (A_bar ⬝ B.nonbasis.to_matrixᵀ) (reduced_cost B A_bar c) = none) :\n  is_optimal_basis B A_bar b_bar c :=\nis_optimal_basis_of_reduced_cost_nonpos _ _ hA_bar h0b $\n  begin\n    intros i j,\n    fin_cases i,\n    exact le_of_not_gt (fin.find_eq_none_iff.1 h j : _)\n  end\n\nlemma choose_pivot_row_eq_none (B : prebasis m n) (A_bar : matrix (fin m) (fin n) ℚ)\n  (b_bar : cvec m) (r : fin m) (s : fin (n - m))\n  (hn : choose_pivot_row (A_bar ⬝ B.nonbasis.to_matrixᵀ) b_bar s = none) :\n  (A_bar ⬝ B.nonbasis.to_matrixᵀ) r s ≤ 0 :=\nle_of_not_gt $ λ (hpivot : _ < _), begin\n  rw [choose_pivot_row, fin.find_eq_none_iff] at hn,\n  cases @finset.min_of_mem _ _\n    ((univ.filter (λ j : fin m, 0 < (A_bar ⬝ B.nonbasis.to_matrixᵀ) j s)).image\n      (λ i, ((A_bar ⬝ B.nonbasis.to_matrixᵀ) i s)⁻¹ * b_bar i 0))\n      (((A_bar ⬝ B.nonbasis.to_matrixᵀ) r s)⁻¹ * b_bar r 0)\n     (mem_image_of_mem _ (by simp *)) with q hq,\n  rcases mem_image.1 (mem_of_min hq) with ⟨i, hip, hiq⟩,\n  subst hiq,\n  refine hn i ⟨(finset.mem_filter.1 hip).2, λ j hj, _⟩,\n  refine min_le_of_mem _ hq,\n  refine mem_image_of_mem _ _,\n  simpa using hj\nend\n\nlemma choose_pivot_column_spec (AN_bar : matrix (fin m) (fin (n - m)) ℚ) (c : rvec (n - m))\n  (s : fin (n - m)) (hs : s ∈ choose_pivot_column AN_bar c) : 0 < c 0 s :=\nfin.find_spec _ hs\n\ndef swap_inverse (AN_bar : matrix (fin m) (fin (n - m)) ℚ) (r : fin m) (s : fin (n - m)) :\n  matrix (fin m) (fin m) ℚ :=\nlet pivot_inv := (AN_bar r s)⁻¹ in\n(1 : matrix (fin m) (fin m) ℚ).write_column r\n  (λ i, if i = r then pivot_inv else -AN_bar i s * pivot_inv)\n\nlemma pivot_element_eq (B : prebasis m n) (A_bar : matrix (fin m) (fin n) ℚ)\n  (r : fin m) (s : fin (n - m)) :\n  (pivot_element B A_bar r s) = (λ _ _, (A_bar ⬝ B.nonbasis.to_matrixᵀ) r s) :=\nbegin\n  ext i j,\n  have hi : i = 0, from subsingleton.elim _ _,\n  have hj : j = 0, from subsingleton.elim _ _,\n  substs hi hj,\n  simp only [pivot_element, matrix_mul_apply, mul_matrix_apply, (to_matrix_symm _).symm],\n  refl\nend\n\nlemma single_apply {α β : Type*} [decidable_eq α] [decidable_eq β] (a a' : α) (b : β) :\n  single a b a' = if a' = a then some b else none := rfl\n\n@[simp] lemma add_add_neg_cancel'_right {α : Type*} [add_comm_group α] (a b : α) : a + (b + -a) = b :=\nadd_sub_cancel'_right a b\n\nlemma swap_inverse_eq_swap_inverse (B : prebasis m n) (AN_bar : matrix (fin m) (fin (n - m)) ℚ)\n  (r : fin m) (s : fin (n - m)) (hpivot : AN_bar r s ≠ 0) :\n  swap_inverse AN_bar r s =\n  simplex.swap_inverse B (AN_bar ⬝ B.nonbasis.to_matrix) r s :=\nhave ∀ i j r s, (AN_bar ⬝ ((single s (0 : fin 1)).to_matrix ⬝ (λ (_ _ : fin 1), (AN_bar r s)⁻¹))) i j\n  = (AN_bar r s)⁻¹ * AN_bar i s,\n  begin\n    intros, fin_cases j,\n    rw [← matrix.mul_assoc, mul_eq_smul, matrix.smul_val, matrix_mul_apply, symm_single,\n      simplex'.single_apply, if_pos],\n    congr,\n  end,\nbegin\n  ext i j,\n  simp [simplex'.swap_inverse, simplex.swap_inverse,\n    matrix.mul_add, matrix.add_mul, matrix.add_val, write_column_apply,\n    matrix.neg_val,\n    mul_matrix_apply, matrix_mul_apply, one_val, pivot_element_eq, inv_def],\n  dsimp [symm_single, simplex'.single_apply],\n  split_ifs,\n  { rw [if_pos h.symm, if_pos h_1],\n    simp [add_val, neg_val, one_val, matrix.mul_assoc, this, h_1, inv_mul_cancel hpivot], },\n  { cc },\n  { cc },\n  { rw [if_neg h_1, if_pos h.symm],\n    simp [matrix.mul_assoc, this, mul_comm] },\n  { cc },\n  { rw [if_neg (ne.symm h), if_neg h_2], simp },\n  { rw [if_pos h_2, if_neg (ne.symm h)], simp },\n  { rw [if_neg h_2, if_neg (ne.symm h)], simp }\nend\n\nlemma swap_nonbasis_eq (B : prebasis m n) (r : fin m) (s : fin (n - m)) :\n  (B.swap r s).nonbasis.to_matrix = (B.nonbasis.to_matrix : matrix _ _ ℚ)\n  + (single s (B.basisg r)).to_matrix - (single s (B.nonbasisg s)).to_matrix :=\nbegin\n  dsimp [prebasis.swap],\n  simp only [to_matrix_swap, to_matrix_trans],\n  simp [matrix.mul_add, (to_matrix_trans _ _).symm,\n    trans_single_of_mem _ (nonbasisg_mem B s),\n    trans_single_of_eq_none _ (nonbasis_basisg_eq_none B r)]\nend\n\nlemma nonbasis_transpose_mul_single (B : prebasis m n) (i : fin (n - m)) (j : fin k) :\n  (B.nonbasis.to_matrixᵀ : matrix _ _ ℚ) ⬝ (single i j).to_matrix =\n  (single (B.nonbasisg i) j).to_matrix :=\nby rw [← to_matrix_symm, ← to_matrix_trans, trans_single_of_mem _ (nonbasis_nonbasisg _ _)]\n\nlemma basis_transpose_mul_single (B : prebasis m n) (i : fin m) (j : fin k) :\n  (B.basis.to_matrixᵀ : matrix _ _ ℚ) ⬝ (single i j).to_matrix =\n  (single (B.basisg i) j).to_matrix :=\nby rw [← to_matrix_symm, ← to_matrix_trans, trans_single_of_mem _ (basis_basisg _ _)]\n\n@[simp] lemma swap_nonbasis_mul_single_of_eq (B : prebasis m n) (r : fin m) (s : fin (n - m)) :\n  ((B.swap r s).nonbasis.to_matrixᵀ : matrix _ _ ℚ) ⬝ (single s (0 : fin 1)).to_matrix =\n  B.basis.to_matrixᵀ ⬝ (single r 0).to_matrix  :=\nbegin\n  simp [swap_nonbasis_eq, transpose_add, (to_matrix_symm _).symm, matrix.add_mul],\n  simp [to_matrix_symm, nonbasis_transpose_mul_single, basis_transpose_mul_single],\nend\n\n@[simp] lemma swap_nonbasis_mul_single_of_ne (B : prebasis m n) (r : fin m) {s : fin (n - m)}\n  {j : fin (n - m)} (hsj : s ≠ j) :\n  ((B.swap r s).nonbasis.to_matrixᵀ : matrix _ _ ℚ) ⬝ (single j (0 : fin 1)).to_matrix =\n  B.nonbasis.to_matrixᵀ ⬝ (single j 0).to_matrix  :=\nbegin\n  simp [swap_nonbasis_eq, transpose_add, (to_matrix_symm _).symm, matrix.add_mul],\n  simp [to_matrix_symm, nonbasis_transpose_mul_single, basis_transpose_mul_single,\n    single_mul_single_of_ne hsj],\nend\n\nlemma reduced_cost_swap (B : prebasis m n) (A_bar : matrix (fin m) (fin n) ℚ) (c : rvec n)\n  (r : fin m) (s : fin (n - m)) (hA_bar : A_bar ⬝ B.basis.to_matrixᵀ = 1)\n  (hpivot : pivot_element B A_bar r s ≠ 0) :\n  reduced_cost (B.swap r s) (simplex.swap_inverse B A_bar r s ⬝ A_bar) c =\n  reduced_cost B A_bar c ⬝ (1 - (single s (0 : fin 1)).to_matrix ⬝\n    (pivot_element B A_bar r s)⁻¹ ⬝ (single 0 r).to_matrix ⬝ A_bar ⬝ B.nonbasis.to_matrixᵀ -\n    (single s 0).to_matrix ⬝ (pivot_element B A_bar r s)⁻¹ ⬝ (single 0 s).to_matrix) :=\nhave h₁ : simplex.swap_inverse B A_bar r s ⬝ A_bar ⬝ (to_matrix ((swap B r s).basis))ᵀ = 1,\n  by rw [matrix.mul_assoc, swap_mul_swap_inverse hA_bar hpivot],\nhave h₂ : ∀ {k : ℕ}, ∀ {M : matrix (fin 1) (fin k) ℚ},\n    to_matrix (single s r) ⬝ (A_bar ⬝ ((to_matrix (B.nonbasis))ᵀ ⬝\n    (to_matrix (single s 0) ⬝ ((pivot_element B A_bar r s)⁻¹ ⬝ M)))) =\n    (single s 0).to_matrix ⬝ M,\n  begin\n    intros,\n    rw [← single_mul_single s (0 : fin 1) r, matrix.mul_assoc],\n    refine congr_arg (matrix.mul _) _,\n    simp only [(matrix.mul_assoc _ _ _).symm, pivot_element, inv_eq_inverse] at ⊢ hpivot,\n    rw [one_by_one_mul_inv_cancel hpivot, matrix.one_mul]\n  end,\nbegin\n  refine mul_single_ext (λ j, _),\n  let x : matrix _ _ ℚ := (B.swap r s).nonbasis.to_matrixᵀ ⬝\n    (single j (0 : fin 1)).to_matrix,\n  have hxdef : x = (B.swap r s).nonbasis.to_matrixᵀ ⬝\n    (single j (0 : fin 1)).to_matrix, from rfl,\n  have hx : (single j (0 : fin 1)).to_matrix = (B.swap r s).nonbasis.to_matrix ⬝ x,\n  { simp [x, (matrix.mul_assoc _ _ _).symm] },\n  let b_bar := (simplex.swap_inverse B A_bar r s ⬝ A_bar) ⬝ x,\n  rw [hx, ← matrix.mul_assoc, ← add_left_inj (c ⬝ (B.swap r s).basis.to_matrixᵀ ⬝ b_bar),\n    ← objective_function_eq rfl h₁, matrix.mul_assoc c _ b_bar],\n  have h₃ : A_bar ⬝ ((to_matrix ((swap B r s).basis))ᵀ ⬝ b_bar) = A_bar ⬝ x,\n  { simp only [b_bar, x, (matrix.mul_assoc _ _ _).symm],\n    rw [mul_eq_one_comm.1 (swap_mul_swap_inverse hA_bar hpivot),\n      matrix.one_mul], },\n  conv_rhs {rw [objective_function_eq h₃ hA_bar], },\n  conv_lhs {rw [objective_function_eq rfl hA_bar] },\n  simp [x, b_bar, simplex.swap_inverse, matrix.mul_add, matrix.mul_assoc,\n    mul_right_eq_of_mul_eq (nonbasis_mul_nonbasis_transpose _),\n    matrix.add_mul, mul_right_eq_of_mul_eq (nonbasis_mul_swap_basis_tranpose _ _ _), h₂],\n  by_cases hjs : j = s,\n  { simp only [pivot_element, matrix.mul_assoc] at hpivot,\n    simp [hjs, mul_right_eq_of_mul_eq hA_bar, matrix.mul_assoc,\n      mul_right_eq_of_mul_eq (nonbasis_mul_basis_transpose _),\n      pivot_element, inv_eq_inverse, one_by_one_inv_mul_cancel hpivot] },\n  { simp [mul_right_eq_of_mul_eq hA_bar, single_mul_single_of_ne (ne.symm hjs),\n      swap_nonbasis_mul_single_of_ne _ _ (ne.symm hjs),\n      mul_right_eq_of_mul_eq (nonbasis_mul_nonbasis_transpose _)] }\nend\n\nset_option eqn_compiler.zeta true\n\ndef simplex : Π (B : prebasis m n) (AN_bar : matrix (fin m) (fin (n - m)) ℚ) (b_bar : cvec m)\n  (c : rvec (n - m)),\n  option (prebasis m n × matrix (fin m) (fin (n - m)) ℚ × (cvec m) × (rvec (n - m)))\n| B AN_bar b_bar c :=\n  match choose_pivot_column AN_bar c with\n  | none   := some (B, AN_bar, b_bar, c)\n  | some s :=\n    match choose_pivot_row AN_bar b_bar s with\n    | none   := none\n    | some r :=\n      have wf : false, from sorry,\n      let S := simplex'.swap_inverse AN_bar r s in\n      let AN_bar' : matrix (fin m) (fin (n - m)) ℚ :=\n        AN_bar.write_column s (λ j, if j = r then (1 : ℚ) else 0) in\n      simplex (B.swap r s) (S ⬝ AN_bar') (S ⬝ b_bar)\n        ((c - (c 0 s / AN_bar r s) • (λ _, AN_bar r) -\n          (0 : matrix _ _ ℚ).write_column s (λ _, c 0 s / AN_bar r s)))\n    end\n  end\nusing_well_founded { rel_tac := λ _ _, `[exact ⟨_, empty_wf⟩], dec_tac := tactic.assumption }\n\nlemma simplex_spec : Π (B : prebasis m n) (A_bar : matrix (fin m) (fin n) ℚ)\n  (b_bar : cvec m) (c : rvec n) (hA_bar : A_bar ⬝ B.basis.to_matrixᵀ = 1) (h0b : 0 ≤ b_bar),\n  (option.cases_on (simplex B (A_bar ⬝ B.nonbasis.to_matrixᵀ) b_bar (reduced_cost B A_bar c))\n    (is_unbounded A_bar b_bar c)\n    (λ P, is_optimal_basis P.1 A_bar b_bar c) : Prop)\n| B A_bar b_bar c := assume hA_bar h0b,\n  begin\n    rw [simplex'.simplex],\n    cases hs : choose_pivot_column (A_bar ⬝ B.nonbasis.to_matrixᵀ)\n      (reduced_cost B A_bar c) with s,\n    { dsimp [simplex'.simplex._match_3],\n      exact choose_pivot_column_eq_none _ _ _ _ hA_bar h0b hs },\n    { dsimp [simplex'.simplex._match_3],\n      cases hr : choose_pivot_row (A_bar ⬝ B.nonbasis.to_matrixᵀ) b_bar s with r,\n      { dsimp [simplex'.simplex._match_4],\n        have : 0 < reduced_cost B A_bar c ⬝ (single s (0 : fin 1)).to_matrix,\n        { rw [cvec_one_lt_iff, matrix_mul_apply],\n          exact choose_pivot_column_spec _ _ _ hs },\n        exact is_unbounded_of_pivot_element_nonpos b_bar _ hA_bar h0b this\n          (λ r i j, by rw [pivot_element_eq];\n            exact choose_pivot_row_eq_none _ _ _ _ _ hr) },\n      { dsimp [simplex'.simplex._match_4],\n        let AN_bar := A_bar ⬝ B.nonbasis.to_matrixᵀ,\n        let S := simplex'.swap_inverse AN_bar r s,\n        let AN_bar' : matrix (fin m) (fin (n - m)) ℚ :=\n          AN_bar.write_column s (λ j, if j = r then (1 : ℚ) else 0),\n        have := simplex_spec (B.swap r s) _ _ _ _ _,\n         } },\n  end\n\nend simplex'\n\ndef ex.A := list.to_matrix 3 4 [[1/64443321,   18932,    -1, 9],\n                                [1/2, -7/145931, -1/145903, 3],\n                                [  -11,     -1111,     22, 100]]\n\ndef ex.b : cvec 3 := (λ i _, list.nth_le [0,0,1] i sorry)\n--#eval ex.b\ndef ex.c : rvec 4 := λ _ i, (list.nth_le [3/4, -20, 1/2, -6] i sorry)\n\n#eval @_root_.simplex 3 7 ex.A ex.b ex.c\n", "meta": {"author": "ChrisHughes24", "repo": "LP", "sha": "e3ed64c2d1f642696104584e74ae7226d8e916de", "save_path": "github-repos/lean/ChrisHughes24-LP", "path": "github-repos/lean/ChrisHughes24-LP/LP-e3ed64c2d1f642696104584e74ae7226d8e916de/scratch/simplex_no_prebasis.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46504809702132455}}
{"text": "import tactic\n\ndef hom  {X Y : Type} (f : X → X) (g : Y → Y) : Type :=\n{ h : X → Y // ∀ z, h (f z) = g (h z) }\n\ninstance {X Y : Type} (f : X → X) (g : Y → Y) :\n  has_coe_to_fun (hom f g) (λ _, X → Y) :=\n{ coe := subtype.val }\n\n-- Σ (X : Type) (x : X), (X → X)\n\n-- def T := Σ (X : Type), X → X\n\n-- def C := Σ t : T, t.fst\n\n@[simp] lemma map_f {X Y : Type} (f : X → X) (g : Y → Y)\n  (h : hom f g) : ∀ z, h (f z) = g (h z) := h.2\n\n@[simp] def iterate_aux {X : Type} (x : X) (f : X → X) : ℕ → X\n| 0     := x\n| (n+1) := f (iterate_aux n)\n\ndef iterate {X : Sort*} (x : X) (f : X → X) : ℕ → X :=\niterate_aux x f\n-- #print nat.rec_on\ndef nat.rec_on2 {motive : ℕ → Sort*} (n : ℕ) (h0 : motive 0) \n  (h1 : Π (n : ℕ), motive n → motive n.succ) : motive n :=\nlet x : Σ n, motive n := iterate ⟨0, h0⟩ (λ x, ⟨x.1 + 1, h1 x.1 x.2⟩) n in\n\n\ndef factorial (n : ℕ) : ℕ :=\n(iterate (1, 1) (λ x, (x.1 + 1, x.1 * x.2)) n).2\n\nlemma factorial_zero : factorial 0 = 1 := rfl\n\n#eval factorial 0\n\n\n@[simp] lemma iterate_zero {X : Type} (x : X) (f : X → X) :\n  iterate x f 0 = x := rfl\n\n@[simp] lemma iterate_succ {X : Type} (x : X) (f : X → X) (n : ℕ) :\n  iterate x f n.succ = f (iterate x f n) := rfl\n\nlemma factorial_succ_aux (n : ℕ) :\n  (iterate (1, 1) (λ x, (x.1 + 1, x.1 * x.2)) (n + 1)) =\n    let x := iterate (1, 1) (λ x, (x.1 + 1, x.1 * x.2)) n in\n      (n + 2, (n + 1) * x.2) :=\nby induction n; simp *\n\nlemma factorial_succ (n : ℕ) : factorial (n + 1) = (n + 1) * factorial n :=\nbegin\n  rw [factorial, factorial_succ_aux],\n  refl\nend\n\nlemma app_iterate {X Y : Type} (h : X → Y) (x : X) (n : ℕ) (f : X → X)\n  (g : Y → Y)\n  (H : ∀ x, h (f x) = g (h x)) :\n  h (iterate x f n) = iterate (h x) g n :=\nbegin\n  induction n with n ih,\n  { refl },\n  { rw [iterate_succ, iterate_succ, H, ih], }\nend\n\nlemma iterate_iterate {X : Type} (f : X → X) (x : X) (g : ℕ → ℕ) (y : ℕ) (n : ℕ)\n  (H : ∀ z, iterate x f (g z) = f (iterate x f z)) :\n  iterate x f (iterate y g n) = iterate (iterate x f y) f n :=\nbegin\n  induction n with n ih,\n  { refl },\n  { simp [H, ih] }\nend\n\n\n-- @[simp] lemma iterate_zero_succ : ⇑(iterate 0 nat.succ) = id :=\n-- by funext n; induction n; simp *\n\n-- @[simp] lemma iterate_one_succ : ⇑(iterate 1 nat.succ) = nat.succ :=\n-- by funext n; induction n; simp *\n\nlemma succ_iterate (g : ℕ → ℕ) (y : ℕ) (n : ℕ)\n  (H : ∀ z, nat.succ (g z) = nat.succ z.succ) :\n  nat.succ (iterate y g n) = iterate y.succ nat.succ n :=\nbegin\n  have := iterate_iterate nat.succ 1,\n  rw [iterate_one_succ] at this,\n  apply this,\n  assumption,\nend\n\n@[simp] lemma iterate_zero_id {X : Type} {x : X}: ⇑(iterate x id) = (λ _, x) :=\nby funext n; induction n; simp *\n\nlemma iterate_eq (x : ℕ) (f : ℕ → ℕ) (g : ℕ → ℕ) (n : ℕ)\n  (h0 : x = g 0)\n  (h1 : ∀ n, f (g n) = g n.succ) :\n  iterate x f n = g n :=\nbegin\n  subst h0,\n  induction n,\n  { simp },\n  { simp * }\nend\n\n@[simp] def add (a : ℕ) : ℕ → ℕ := iterate a nat.succ\n@[simp] def mul (a : ℕ) : ℕ → ℕ := iterate 0 (add a)\n\ninfix ` + ` := add\ninfix ` * ` := mul\n\nlemma add_assoc' (a b c : ℕ) : add (add a b) c = add a (add b c) :=\nbegin\n  dunfold add,\n  rw [iterate_iterate],\n  intros,\n  simp,\nend\n\nlemma succ_add (a b : ℕ) : (add a b).succ = add a.succ b :=\nbegin\n  simp [add],\n  rw succ_iterate,\n  intros, refl\nend\n\nmeta def tactic.interactive.fold :=\n`[repeat { rw [← add] }, repeat { rw ← mul}]\n\nlemma mul_add' (a b c : ℕ) : mul a (add b c) = add (mul a b) (mul a c) :=\nbegin\n  delta add mul,\n  rw [app_iterate (iterate 0 (iterate a nat.succ)) b],\n  rw iterate_iterate,\n  { apply iterate_eq,\n    { refl },\n    { intro c,\n      rw iterate_iterate,\n      { simp,\n        symmetry,\n        rw iterate_iterate,\n        { apply iterate_eq,\n          { simp,\n            induction a with a ih,\n            { simp, },\n            { simp,\n              rw [ih],\n              fold, }\n             } }\n\n          } } }\nend\n\ndef succ_eq_iterate (n : ℕ) : n.succ = iterate n nat.succ 1 := rfl\n\nlemma mul_assoc' (a b c : ℕ) : mul (mul a b) c = mul a (mul b c) :=\nbegin\n  delta add mul,\n  dsimp,\n  rw [app_iterate],\n\n\nend\n", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/natural_numbers.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.46502071952187873}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport group_theory.finiteness\nimport ring_theory.algebra_tower\nimport ring_theory.ideal.quotient\nimport ring_theory.noetherian\n\n/-!\n# Finiteness conditions in commutative algebra\n\nIn this file we define several notions of finiteness that are common in commutative algebra.\n\n## Main declarations\n\n- `module.finite`, `algebra.finite`, `ring_hom.finite`, `alg_hom.finite`\n  all of these express that some object is finitely generated *as module* over some base ring.\n- `algebra.finite_type`, `ring_hom.finite_type`, `alg_hom.finite_type`\n  all of these express that some object is finitely generated *as algebra* over some base ring.\n- `algebra.finite_presentation`, `ring_hom.finite_presentation`, `alg_hom.finite_presentation`\n  all of these express that some object is finitely presented *as algebra* over some base ring.\n\n-/\n\nopen function (surjective)\nopen_locale big_operators polynomial\n\nsection module_and_algebra\n\nvariables (R A B M N : Type*)\n\n/-- A module over a semiring is `finite` if it is finitely generated as a module. -/\nclass module.finite [semiring R] [add_comm_monoid M] [module R M] :\n  Prop := (out : (⊤ : submodule R M).fg)\n\n/-- An algebra over a commutative semiring is of `finite_type` if it is finitely generated\nover the base ring as algebra. -/\nclass algebra.finite_type [comm_semiring R] [semiring A] [algebra R A] : Prop :=\n(out : (⊤ : subalgebra R A).fg)\n\n/-- An algebra over a commutative semiring is `finite_presentation` if it is the quotient of a\npolynomial ring in `n` variables by a finitely generated ideal. -/\ndef algebra.finite_presentation [comm_semiring R] [semiring A] [algebra R A] : Prop :=\n∃ (n : ℕ) (f : mv_polynomial (fin n) R →ₐ[R] A),\n  surjective f ∧ f.to_ring_hom.ker.fg\n\nnamespace module\n\nvariables [semiring R] [add_comm_monoid M] [module R M] [add_comm_monoid N] [module R N]\n\nlemma finite_def {R M} [semiring R] [add_comm_monoid M] [module R M] :\n  finite R M ↔ (⊤ : submodule R M).fg := ⟨λ h, h.1, λ h, ⟨h⟩⟩\n\n@[priority 100] -- see Note [lower instance priority]\ninstance is_noetherian.finite [is_noetherian R M] : finite R M :=\n⟨is_noetherian.noetherian ⊤⟩\n\nnamespace finite\nopen _root_.submodule set\n\nlemma iff_add_monoid_fg {M : Type*} [add_comm_monoid M] : module.finite ℕ M ↔ add_monoid.fg M :=\n⟨λ h, add_monoid.fg_def.2 $ (fg_iff_add_submonoid_fg ⊤).1 (finite_def.1 h),\n  λ h, finite_def.2 $ (fg_iff_add_submonoid_fg ⊤).2 (add_monoid.fg_def.1 h)⟩\n\nlemma iff_add_group_fg {G : Type*} [add_comm_group G] : module.finite ℤ G ↔ add_group.fg G :=\n⟨λ h, add_group.fg_def.2 $ (fg_iff_add_subgroup_fg ⊤).1 (finite_def.1 h),\n  λ h, finite_def.2 $ (fg_iff_add_subgroup_fg ⊤).2 (add_group.fg_def.1 h)⟩\n\nvariables {R M N}\n\nlemma exists_fin [finite R M] : ∃ (n : ℕ) (s : fin n → M), span R (range s) = ⊤ :=\nsubmodule.fg_iff_exists_fin_generating_family.mp out\n\nlemma of_surjective [hM : finite R M] (f : M →ₗ[R] N) (hf : surjective f) :\n  finite R N :=\n⟨begin\n  rw [← linear_map.range_eq_top.2 hf, ← submodule.map_top],\n  exact hM.1.map f\nend⟩\n\nlemma of_injective [is_noetherian R N] (f : M →ₗ[R] N)\n  (hf : function.injective f) : finite R M :=\n⟨fg_of_injective f hf⟩\n\nvariables (R)\n\ninstance self : finite R R :=\n⟨⟨{1}, by simpa only [finset.coe_singleton] using ideal.span_singleton_one⟩⟩\n\nvariable (M)\n\nlemma of_restrict_scalars_finite (R A M : Type*) [comm_semiring R] [semiring A] [add_comm_monoid M]\n  [module R M] [module A M] [algebra R A] [is_scalar_tower R A M] [hM : finite R M] :\n  finite A M :=\nbegin\n  rw [finite_def, fg_def] at hM ⊢,\n  obtain ⟨S, hSfin, hSgen⟩ := hM,\n  refine ⟨S, hSfin, eq_top_iff.2 _⟩,\n  have := submodule.span_le_restrict_scalars R A S,\n  rw hSgen at this,\n  exact this\nend\n\nvariables {R M}\n\ninstance prod [hM : finite R M] [hN : finite R N] : finite R (M × N) :=\n⟨begin\n  rw ← submodule.prod_top,\n  exact submodule.fg_prod hM.1 hN.1\nend⟩\n\ninstance pi {ι : Type*} {M : ι → Type*} [fintype ι] [Π i, add_comm_monoid (M i)]\n  [Π i, module R (M i)] [h : ∀ i, finite R (M i)] : finite R (Π i, M i) :=\n⟨begin\n  rw ← submodule.pi_top,\n  exact submodule.fg_pi (λ i, (h i).1),\nend⟩\n\nlemma equiv [hM : finite R M] (e : M ≃ₗ[R] N) : finite R N :=\nof_surjective (e : M →ₗ[R] N) e.surjective\n\nsection algebra\n\nlemma trans {R : Type*} (A B : Type*) [comm_semiring R] [comm_semiring A] [algebra R A]\n  [semiring B] [algebra R B] [algebra A B] [is_scalar_tower R A B] :\n  ∀ [finite R A] [finite A B], finite R B\n| ⟨⟨s, hs⟩⟩ ⟨⟨t, ht⟩⟩ := ⟨submodule.fg_def.2\n  ⟨set.image2 (•) (↑s : set A) (↑t : set B),\n    set.finite.image2 _ s.finite_to_set t.finite_to_set,\n    by rw [set.image2_smul, submodule.span_smul hs (↑t : set B),\n      ht, submodule.restrict_scalars_top]⟩⟩\n\n@[priority 100] -- see Note [lower instance priority]\ninstance finite_type {R : Type*} (A : Type*) [comm_semiring R] [comm_semiring A]\n  [algebra R A] [hRA : finite R A] : algebra.finite_type R A :=\n⟨subalgebra.fg_of_submodule_fg hRA.1⟩\n\nend algebra\n\nend finite\n\nend module\n\nnamespace algebra\n\nvariables [comm_ring R] [comm_ring A] [algebra R A] [comm_ring B] [algebra R B]\nvariables [add_comm_group M] [module R M]\nvariables [add_comm_group N] [module R N]\n\nnamespace finite_type\n\nlemma self : finite_type R R := ⟨⟨{1}, subsingleton.elim _ _⟩⟩\n\nsection\nopen_locale classical\n\nprotected lemma mv_polynomial (ι : Type*) [fintype ι] : finite_type R (mv_polynomial ι R) :=\n⟨⟨finset.univ.image mv_polynomial.X, begin\n  rw eq_top_iff, refine λ p, mv_polynomial.induction_on' p\n    (λ u x, finsupp.induction u (subalgebra.algebra_map_mem _ x)\n      (λ i n f hif hn ih, _))\n    (λ p q ihp ihq, subalgebra.add_mem _ ihp ihq),\n  rw [add_comm, mv_polynomial.monomial_add_single],\n  exact subalgebra.mul_mem _ ih\n    (subalgebra.pow_mem _ (subset_adjoin $ finset.mem_image_of_mem _ $ finset.mem_univ _) _)\nend⟩⟩\nend\n\nlemma of_restrict_scalars_finite_type [algebra A B] [is_scalar_tower R A B] [hB : finite_type R B] :\n  finite_type A B :=\nbegin\n  obtain ⟨S, hS⟩ := hB.out,\n  refine ⟨⟨S, eq_top_iff.2 (λ b, _)⟩⟩,\n  have le : adjoin R (S : set B) ≤ subalgebra.restrict_scalars R (adjoin A S),\n  { apply (algebra.adjoin_le _ : _ ≤ (subalgebra.restrict_scalars R (adjoin A ↑S))),\n    simp only [subalgebra.coe_restrict_scalars],\n    exact algebra.subset_adjoin, },\n  exact le (eq_top_iff.1 hS b),\nend\n\nvariables {R A B}\n\nlemma of_surjective (hRA : finite_type R A) (f : A →ₐ[R] B) (hf : surjective f) :\n  finite_type R B :=\n⟨begin\n  convert subalgebra.fg_map _ f hRA.1,\n  simpa only [map_top f, @eq_comm _ ⊤, eq_top_iff, alg_hom.mem_range] using hf\nend⟩\n\nlemma equiv (hRA : finite_type R A) (e : A ≃ₐ[R] B) : finite_type R B :=\nhRA.of_surjective e e.surjective\n\nlemma trans [algebra A B] [is_scalar_tower R A B] (hRA : finite_type R A) (hAB : finite_type A B) :\n  finite_type R B :=\n⟨fg_trans' hRA.1 hAB.1⟩\n\n/-- An algebra is finitely generated if and only if it is a quotient\nof a polynomial ring whose variables are indexed by a finset. -/\nlemma iff_quotient_mv_polynomial : (finite_type R A) ↔ ∃ (s : finset A)\n  (f : (mv_polynomial {x // x ∈ s} R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rintro ⟨s, hs⟩,\n    use [s, mv_polynomial.aeval coe],\n    intro x,\n    have hrw : (↑s : set A) = (λ (x : A), x ∈ s.val) := rfl,\n    rw [← set.mem_range, ← alg_hom.coe_range, ← adjoin_eq_range, ← hrw, hs],\n    exact set.mem_univ x },\n  { rintro ⟨s, ⟨f, hsur⟩⟩,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R {x // x ∈ s}) f hsur }\nend\n\n/-- An algebra is finitely generated if and only if it is a quotient\nof a polynomial ring whose variables are indexed by a fintype. -/\nlemma iff_quotient_mv_polynomial' : (finite_type R A) ↔ ∃ (ι : Type u_2) (_ : fintype ι)\n  (f : (mv_polynomial ι R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial,\n    rintro ⟨s, ⟨f, hsur⟩⟩,\n    use [{x // x ∈ s}, by apply_instance, f, hsur] },\n  { rintro ⟨ι, ⟨hfintype, ⟨f, hsur⟩⟩⟩,\n    letI : fintype ι := hfintype,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R ι) f hsur }\nend\n\n/-- An algebra is finitely generated if and only if it is a quotient of a polynomial ring in `n`\nvariables. -/\nlemma iff_quotient_mv_polynomial'' : (finite_type R A) ↔ ∃ (n : ℕ)\n  (f : (mv_polynomial (fin n) R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial',\n    rintro ⟨ι, hfintype, ⟨f, hsur⟩⟩,\n    letI := hfintype,\n    obtain ⟨equiv⟩ := @fintype.trunc_equiv_fin ι (classical.dec_eq ι) hfintype,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    exact ⟨fintype.card ι, alg_hom.comp f equiv.symm, function.surjective.comp hsur\n      (alg_equiv.symm equiv).surjective⟩ },\n  { rintro ⟨n, ⟨f, hsur⟩⟩,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R (fin n)) f hsur }\nend\n\n/-- A finitely presented algebra is of finite type. -/\nlemma of_finite_presentation : finite_presentation R A → finite_type R A :=\nbegin\n  rintro ⟨n, f, hf⟩,\n  apply (finite_type.iff_quotient_mv_polynomial'').2,\n  exact ⟨n, f, hf.1⟩\nend\n\ninstance prod [hA : finite_type R A] [hB : finite_type R B] : finite_type R (A × B) :=\n⟨begin\n  rw ← subalgebra.prod_top,\n  exact subalgebra.fg_prod hA.1 hB.1\nend⟩\n\nend finite_type\n\nnamespace finite_presentation\n\nvariables {R A B}\n\n/-- An algebra over a Noetherian ring is finitely generated if and only if it is finitely\npresented. -/\nlemma of_finite_type [is_noetherian_ring R] : finite_type R A ↔ finite_presentation R A :=\nbegin\n  refine ⟨λ h, _, algebra.finite_type.of_finite_presentation⟩,\n  obtain ⟨n, f, hf⟩ := algebra.finite_type.iff_quotient_mv_polynomial''.1 h,\n  refine ⟨n, f, hf, _⟩,\n  have hnoet : is_noetherian_ring (mv_polynomial (fin n) R) := by apply_instance,\n  replace hnoet := (is_noetherian_ring_iff.1 hnoet).noetherian,\n  exact hnoet f.to_ring_hom.ker,\nend\n\n/-- If `e : A ≃ₐ[R] B` and `A` is finitely presented, then so is `B`. -/\nlemma equiv (hfp : finite_presentation R A) (e : A ≃ₐ[R] B) : finite_presentation R B :=\nbegin\n  obtain ⟨n, f, hf⟩ := hfp,\n  use [n, alg_hom.comp ↑e f],\n  split,\n  { exact function.surjective.comp e.surjective hf.1 },\n  suffices hker : (alg_hom.comp ↑e f).to_ring_hom.ker = f.to_ring_hom.ker,\n  { rw hker, exact hf.2 },\n  { have hco : (alg_hom.comp ↑e f).to_ring_hom = ring_hom.comp ↑e.to_ring_equiv f.to_ring_hom,\n    { have h : (alg_hom.comp ↑e f).to_ring_hom = e.to_alg_hom.to_ring_hom.comp f.to_ring_hom := rfl,\n      have h1 : ↑(e.to_ring_equiv) = (e.to_alg_hom).to_ring_hom := rfl,\n      rw [h, h1] },\n    rw [ring_hom.ker_eq_comap_bot, hco, ← ideal.comap_comap, ← ring_hom.ker_eq_comap_bot,\n      ring_hom.ker_coe_equiv (alg_equiv.to_ring_equiv e), ring_hom.ker_eq_comap_bot] }\nend\n\nvariable (R)\n\n/-- The ring of polynomials in finitely many variables is finitely presented. -/\nprotected lemma mv_polynomial (ι : Type u_2) [fintype ι] :\n  finite_presentation R (mv_polynomial ι R) :=\nbegin\n  obtain ⟨equiv⟩ := @fintype.trunc_equiv_fin ι (classical.dec_eq ι) _,\n  replace equiv := mv_polynomial.rename_equiv R equiv,\n  refine ⟨_, alg_equiv.to_alg_hom equiv.symm, _⟩,\n  split,\n  { exact (alg_equiv.symm equiv).surjective },\n  suffices hinj : function.injective equiv.symm.to_alg_hom.to_ring_hom,\n  { rw [(ring_hom.injective_iff_ker_eq_bot _).1 hinj],\n    exact submodule.fg_bot },\n  exact (alg_equiv.symm equiv).injective\nend\n\n/-- `R` is finitely presented as `R`-algebra. -/\nlemma self : finite_presentation R R :=\nequiv (finite_presentation.mv_polynomial R pempty) (mv_polynomial.is_empty_alg_equiv R pempty)\n\nvariable {R}\n\n/-- The quotient of a finitely presented algebra by a finitely generated ideal is finitely\npresented. -/\nprotected lemma quotient {I : ideal A} (h : I.fg) (hfp : finite_presentation R A) :\n  finite_presentation R (A ⧸ I) :=\nbegin\n  obtain ⟨n, f, hf⟩ := hfp,\n  refine ⟨n, (ideal.quotient.mkₐ R I).comp f, _, _⟩,\n  { exact (ideal.quotient.mkₐ_surjective R I).comp hf.1 },\n  { refine ideal.fg_ker_comp _ _ hf.2 _ hf.1,\n    simp [h] }\nend\n\n/-- If `f : A →ₐ[R] B` is surjective with finitely generated kernel and `A` is finitely presented,\nthen so is `B`. -/\nlemma of_surjective {f : A →ₐ[R] B} (hf : function.surjective f) (hker : f.to_ring_hom.ker.fg)\n  (hfp : finite_presentation R A) : finite_presentation R B :=\nequiv (hfp.quotient hker) (ideal.quotient_ker_alg_equiv_of_surjective hf)\n\nlemma iff : finite_presentation R A ↔\n  ∃ n (I : ideal (mv_polynomial (fin n) R)) (e : (_ ⧸ I) ≃ₐ[R] A), I.fg :=\nbegin\n  split,\n  { rintros ⟨n, f, hf⟩,\n    exact ⟨n, f.to_ring_hom.ker, ideal.quotient_ker_alg_equiv_of_surjective hf.1, hf.2⟩ },\n  { rintros ⟨n, I, e, hfg⟩,\n    exact equiv ((finite_presentation.mv_polynomial R _).quotient hfg) e }\nend\n\n/-- An algebra is finitely presented if and only if it is a quotient of a polynomial ring whose\nvariables are indexed by a fintype by a finitely generated ideal. -/\nlemma iff_quotient_mv_polynomial' : finite_presentation R A ↔ ∃ (ι : Type u_2) (_ : fintype ι)\n  (f : mv_polynomial ι R →ₐ[R] A), surjective f ∧ f.to_ring_hom.ker.fg :=\nbegin\n  split,\n  { rintro ⟨n, f, hfs, hfk⟩,\n    set ulift_var := mv_polynomial.rename_equiv R equiv.ulift,\n    refine ⟨ulift (fin n), infer_instance, f.comp ulift_var.to_alg_hom,\n      hfs.comp ulift_var.surjective,\n      ideal.fg_ker_comp _ _ _ hfk ulift_var.surjective⟩,\n    convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv ulift_var.to_ring_equiv, },\n  { rintro ⟨ι, hfintype, f, hf⟩,\n    haveI : fintype ι := hfintype,\n    obtain ⟨equiv⟩ := @fintype.trunc_equiv_fin ι (classical.dec_eq ι) _,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    refine ⟨fintype.card ι, f.comp equiv.symm,\n      hf.1.comp (alg_equiv.symm equiv).surjective,\n      ideal.fg_ker_comp _ f _ hf.2 equiv.symm.surjective⟩,\n    convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv (equiv.symm.to_ring_equiv), }\nend\n\n/-- If `A` is a finitely presented `R`-algebra, then `mv_polynomial (fin n) A` is finitely presented\nas `R`-algebra. -/\nlemma mv_polynomial_of_finite_presentation (hfp : finite_presentation R A) (ι : Type*)\n  [fintype ι] : finite_presentation R (mv_polynomial ι A) :=\nbegin\n  rw iff_quotient_mv_polynomial' at hfp ⊢,\n  classical,\n  obtain ⟨ι', _, f, hf_surj, hf_ker⟩ := hfp,\n  resetI,\n  let g := (mv_polynomial.map_alg_hom f).comp (mv_polynomial.sum_alg_equiv R ι ι').to_alg_hom,\n  refine ⟨ι ⊕ ι', by apply_instance, g,\n    (mv_polynomial.map_surjective f.to_ring_hom hf_surj).comp (alg_equiv.surjective _),\n    ideal.fg_ker_comp _ _ _ _ (alg_equiv.surjective _)⟩,\n  { convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv (mv_polynomial.sum_alg_equiv R ι ι').to_ring_equiv },\n  { rw [alg_hom.to_ring_hom_eq_coe, mv_polynomial.map_alg_hom_coe_ring_hom, mv_polynomial.ker_map],\n    exact hf_ker.map mv_polynomial.C, }\nend\n\n/-- If `A` is an `R`-algebra and `S` is an `A`-algebra, both finitely presented, then `S` is\n  finitely presented as `R`-algebra. -/\nlemma trans [algebra A B] [is_scalar_tower R A B] (hfpA : finite_presentation R A)\n  (hfpB : finite_presentation A B) : finite_presentation R B :=\nbegin\n  obtain ⟨n, I, e, hfg⟩ := iff.1 hfpB,\n  exact equiv ((mv_polynomial_of_finite_presentation hfpA _).quotient hfg) (e.restrict_scalars R)\nend\n\nend finite_presentation\n\nend algebra\n\nend module_and_algebra\n\nnamespace ring_hom\nvariables {A B C : Type*} [comm_ring A] [comm_ring B] [comm_ring C]\n\n/-- A ring morphism `A →+* B` is `finite` if `B` is finitely generated as `A`-module. -/\ndef finite (f : A →+* B) : Prop :=\nby letI : algebra A B := f.to_algebra; exact module.finite A B\n\n/-- A ring morphism `A →+* B` is of `finite_type` if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A →+* B) : Prop := @algebra.finite_type A B _ _ f.to_algebra\n\n/-- A ring morphism `A →+* B` is of `finite_presentation` if `B` is finitely presented as\n`A`-algebra. -/\ndef finite_presentation (f : A →+* B) : Prop := @algebra.finite_presentation A B _ _ f.to_algebra\n\nnamespace finite\n\nvariables (A)\n\nlemma id : finite (ring_hom.id A) := module.finite.self A\n\nvariables {A}\n\nlemma of_surjective (f : A →+* B) (hf : surjective f) : f.finite :=\nbegin\n  letI := f.to_algebra,\n  exact module.finite.of_surjective (algebra.of_id A B).to_linear_map hf\nend\n\nlemma comp {g : B →+* C} {f : A →+* B} (hg : g.finite) (hf : f.finite) : (g.comp f).finite :=\n@module.finite.trans A B C _ _ f.to_algebra _ (g.comp f).to_algebra g.to_algebra\nbegin\n  fconstructor,\n  intros a b c,\n  simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc],\n  refl\nend\nhf hg\n\nlemma finite_type {f : A →+* B} (hf : f.finite) : finite_type f :=\n@module.finite.finite_type _ _ _ _ f.to_algebra hf\n\nlemma of_comp_finite {f : A →+* B} {g : B →+* C} (h : (g.comp f).finite) : g.finite :=\nbegin\n  letI := f.to_algebra,\n  letI := g.to_algebra,\n  letI := (g.comp f).to_algebra,\n  letI : is_scalar_tower A B C := restrict_scalars.is_scalar_tower A B C,\n  letI : module.finite A C := h,\n  exact module.finite.of_restrict_scalars_finite A B C\nend\n\nend finite\n\nnamespace finite_type\n\nvariables (A)\n\nlemma id : finite_type (ring_hom.id A) := algebra.finite_type.self A\n\nvariables {A}\n\nlemma comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.finite_type) (hg : surjective g) :\n  (g.comp f).finite_type :=\n@algebra.finite_type.of_surjective A B C _ _ f.to_algebra _ (g.comp f).to_algebra hf\n{ to_fun := g, commutes' := λ a, rfl, .. g } hg\n\nlemma of_surjective (f : A →+* B) (hf : surjective f) : f.finite_type :=\nby { rw ← f.comp_id, exact (id A).comp_surjective hf }\n\nlemma comp {g : B →+* C} {f : A →+* B} (hg : g.finite_type) (hf : f.finite_type) :\n  (g.comp f).finite_type :=\n@algebra.finite_type.trans A B C _ _ f.to_algebra _ (g.comp f).to_algebra g.to_algebra\nbegin\n  fconstructor,\n  intros a b c,\n  simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc],\n  refl\nend\nhf hg\n\nlemma of_finite_presentation {f : A →+* B} (hf : f.finite_presentation) : f.finite_type :=\n@algebra.finite_type.of_finite_presentation A B _ _ f.to_algebra hf\n\nlemma of_comp_finite_type {f : A →+* B} {g : B →+* C} (h : (g.comp f).finite_type) :\n  g.finite_type :=\nbegin\n  letI := f.to_algebra,\n  letI := g.to_algebra,\n  letI := (g.comp f).to_algebra,\n  letI : is_scalar_tower A B C := restrict_scalars.is_scalar_tower A B C,\n  letI : algebra.finite_type A C := h,\n  exact algebra.finite_type.of_restrict_scalars_finite_type A B C\nend\n\nend finite_type\n\nnamespace finite_presentation\n\nvariables (A)\n\nlemma id : finite_presentation (ring_hom.id A) := algebra.finite_presentation.self A\n\nvariables {A}\n\nlemma comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.finite_presentation) (hg : surjective g)\n  (hker : g.ker.fg) :  (g.comp f).finite_presentation :=\n@algebra.finite_presentation.of_surjective A B C _ _ f.to_algebra _ (g.comp f).to_algebra\n{ to_fun := g, commutes' := λ a, rfl, .. g } hg hker hf\n\nlemma of_surjective (f : A →+* B) (hf : surjective f) (hker : f.ker.fg) : f.finite_presentation :=\nby { rw ← f.comp_id, exact (id A).comp_surjective hf hker}\n\nlemma of_finite_type [is_noetherian_ring A] {f : A →+* B} : f.finite_type ↔ f.finite_presentation :=\n@algebra.finite_presentation.of_finite_type A B _ _ f.to_algebra _\n\nlemma comp {g : B →+* C} {f : A →+* B} (hg : g.finite_presentation) (hf : f.finite_presentation) :\n  (g.comp f).finite_presentation :=\n@algebra.finite_presentation.trans A B C _ _ f.to_algebra _ (g.comp f).to_algebra g.to_algebra\n{ smul_assoc := λ a b c, begin\n    simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc],\n    refl\n  end }\nhf hg\n\nend finite_presentation\n\nend ring_hom\n\nnamespace alg_hom\n\nvariables {R A B C : Type*} [comm_ring R]\nvariables [comm_ring A] [comm_ring B] [comm_ring C]\nvariables [algebra R A] [algebra R B] [algebra R C]\n\n/-- An algebra morphism `A →ₐ[R] B` is finite if it is finite as ring morphism.\nIn other words, if `B` is finitely generated as `A`-module. -/\ndef finite (f : A →ₐ[R] B) : Prop := f.to_ring_hom.finite\n\n/-- An algebra morphism `A →ₐ[R] B` is of `finite_type` if it is of finite type as ring morphism.\nIn other words, if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A →ₐ[R] B) : Prop := f.to_ring_hom.finite_type\n\n/-- An algebra morphism `A →ₐ[R] B` is of `finite_presentation` if it is of finite presentation as\nring morphism. In other words, if `B` is finitely presented as `A`-algebra. -/\ndef finite_presentation (f : A →ₐ[R] B) : Prop := f.to_ring_hom.finite_presentation\n\nnamespace finite\n\nvariables (R A)\n\nlemma id : finite (alg_hom.id R A) := ring_hom.finite.id A\n\nvariables {R A}\n\nlemma comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.finite) (hf : f.finite) : (g.comp f).finite :=\nring_hom.finite.comp hg hf\n\nlemma of_surjective (f : A →ₐ[R] B) (hf : surjective f) : f.finite :=\nring_hom.finite.of_surjective f hf\n\nlemma finite_type {f : A →ₐ[R] B} (hf : f.finite) : finite_type f :=\nring_hom.finite.finite_type hf\n\nlemma of_comp_finite {f : A →ₐ[R] B} {g : B →ₐ[R] C} (h : (g.comp f).finite) : g.finite :=\nring_hom.finite.of_comp_finite h\n\nend finite\n\nnamespace finite_type\n\nvariables (R A)\n\nlemma id : finite_type (alg_hom.id R A) := ring_hom.finite_type.id A\n\nvariables {R A}\n\nlemma comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.finite_type) (hf : f.finite_type) :\n  (g.comp f).finite_type :=\nring_hom.finite_type.comp hg hf\n\nlemma comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.finite_type) (hg : surjective g) :\n  (g.comp f).finite_type :=\nring_hom.finite_type.comp_surjective hf hg\n\nlemma of_surjective (f : A →ₐ[R] B) (hf : surjective f) : f.finite_type :=\nring_hom.finite_type.of_surjective f hf\n\nlemma of_finite_presentation {f : A →ₐ[R] B} (hf : f.finite_presentation) : f.finite_type :=\nring_hom.finite_type.of_finite_presentation hf\n\nlemma of_comp_finite_type {f : A →ₐ[R] B} {g : B →ₐ[R] C} (h : (g.comp f).finite_type) :\ng.finite_type :=\nring_hom.finite_type.of_comp_finite_type h\n\nend finite_type\n\nnamespace finite_presentation\n\nvariables (R A)\n\nlemma id : finite_presentation (alg_hom.id R A) := ring_hom.finite_presentation.id A\n\nvariables {R A}\n\nlemma comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.finite_presentation)\n  (hf : f.finite_presentation) : (g.comp f).finite_presentation :=\nring_hom.finite_presentation.comp hg hf\n\nlemma comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.finite_presentation)\n  (hg : surjective g) (hker : g.to_ring_hom.ker.fg) : (g.comp f).finite_presentation :=\nring_hom.finite_presentation.comp_surjective hf hg hker\n\nlemma of_surjective (f : A →ₐ[R] B) (hf : surjective f) (hker : f.to_ring_hom.ker.fg) :\n  f.finite_presentation :=\nring_hom.finite_presentation.of_surjective f hf hker\n\nlemma of_finite_type [is_noetherian_ring A] {f : A →ₐ[R] B} :\n  f.finite_type ↔ f.finite_presentation :=\nring_hom.finite_presentation.of_finite_type\n\nend finite_presentation\n\nend alg_hom\n\nsection monoid_algebra\n\nvariables {R : Type*} {M : Type*}\n\nnamespace add_monoid_algebra\n\nopen algebra add_submonoid submodule\n\nsection span\n\nsection semiring\n\nvariables [comm_semiring R] [add_monoid M]\n\n/-- An element of `add_monoid_algebra R M` is in the subalgebra generated by its support. -/\nlemma mem_adjoin_support (f : add_monoid_algebra R M) : f ∈ adjoin R (of' R M '' f.support) :=\nbegin\n  suffices : span R (of' R M '' f.support) ≤ (adjoin R (of' R M '' f.support)).to_submodule,\n  { exact this (mem_span_support f) },\n  rw submodule.span_le,\n  exact subset_adjoin\nend\n\n/-- If a set `S` generates, as algebra, `add_monoid_algebra R M`, then the set of supports of\nelements of `S` generates `add_monoid_algebra R M`. -/\nlemma support_gen_of_gen {S : set (add_monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (⋃ f ∈ S, (of' R M '' (f.support : set M))) = ⊤ :=\nbegin\n  refine le_antisymm le_top _,\n  rw [← hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : of' R M '' f.support ⊆\n    ⋃ (g : add_monoid_algebra R M) (H : g ∈ S), of' R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union₂.2 ⟨f, ⟨hf, hs⟩⟩ },\n  exact adjoin_mono hincl (mem_adjoin_support f)\nend\n\n/-- If a set `S` generates, as algebra, `add_monoid_algebra R M`, then the image of the union of\nthe supports of elements of `S` generates `add_monoid_algebra R M`. -/\nlemma support_gen_of_gen' {S : set (add_monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (of' R M '' (⋃ f ∈ S, (f.support : set M))) = ⊤ :=\nbegin\n  suffices : of' R M '' (⋃ f ∈ S, (f.support : set M)) = ⋃ f ∈ S, (of' R M '' (f.support : set M)),\n  { rw this,\n    exact support_gen_of_gen hS },\n  simp only [set.image_Union]\nend\n\nend semiring\n\nsection ring\n\nvariables [comm_ring R] [add_comm_monoid M]\n\n/-- If `add_monoid_algebra R M` is of finite type, there there is a `G : finset M` such that its\nimage generates, as algera, `add_monoid_algebra R M`. -/\nlemma exists_finset_adjoin_eq_top [h : finite_type R (add_monoid_algebra R M)] :\n  ∃ G : finset M, algebra.adjoin R (of' R M '' G) = ⊤ :=\nbegin\n  unfreezingI { obtain ⟨S, hS⟩ := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (λ f, f.support),\n  have : (finset.bUnion S (λ f, f.support) : set M) = ⋃ f ∈ S, (f.support : set M),\n  { simp only [finset.set_bUnion_coe, finset.coe_bUnion] },\n  rw [this],\n  exact support_gen_of_gen' hS\nend\n\n/-- The image of an element `m : M` in `add_monoid_algebra R M` belongs the submodule generated by\n`S : set M` if and only if `m ∈ S`. -/\nlemma of'_mem_span [nontrivial R] {m : M} {S : set M} :\n  of' R M m ∈ span R (of' R M '' S) ↔ m ∈ S :=\nbegin\n  refine ⟨λ h, _, λ h, submodule.subset_span $ set.mem_image_of_mem (of R M) h⟩,\n  rw [of', ← finsupp.supported_eq_span_single, finsupp.mem_supported,\n    finsupp.support_single_ne_zero (@one_ne_zero R _ (by apply_instance))] at h,\n  simpa using h\nend\n\n/--If the image of an element `m : M` in `add_monoid_algebra R M` belongs the submodule generated by\nthe closure of some `S : set M` then `m ∈ closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of' R M m ∈ span R (submonoid.closure (of' R M '' S) : set (add_monoid_algebra R M))) :\n  m ∈ closure S :=\nbegin\n  suffices : multiplicative.of_add m ∈ submonoid.closure (multiplicative.to_add ⁻¹' S),\n  { simpa [← to_submonoid_closure] },\n  rw [set.image_congr' (show ∀ x, of' R M x = of R M x, from λ x, of'_eq_of x),\n    ← monoid_hom.map_mclosure] at h,\n  simpa using of'_mem_span.1 h\nend\n\nend ring\n\nend span\n\nvariables [add_comm_monoid M]\n\n/-- If a set `S` generates an additive monoid `M`, then the image of `M` generates, as algebra,\n`add_monoid_algebra R M`. -/\nlemma mv_polynomial_aeval_of_surjective_of_closure [comm_semiring R] {S : set M}\n  (hS : closure S = ⊤) : function.surjective (mv_polynomial.aeval\n  (λ (s : S), of' R M ↑s) : mv_polynomial S R → add_monoid_algebra R M) :=\nbegin\n  refine λ f, induction_on f (λ m, _) _ _,\n  { have : m ∈ closure S := hS.symm ▸ mem_top _,\n    refine closure_induction this (λ m hm, _) _ _,\n    { exact ⟨mv_polynomial.X ⟨m, hm⟩, mv_polynomial.aeval_X _ _⟩ },\n    { exact ⟨1, alg_hom.map_one _⟩ },\n    { rintro m₁ m₂ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩,\n      exact ⟨P₁ * P₂, by rw [alg_hom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]; refl⟩ } },\n  { rintro f g ⟨P, rfl⟩ ⟨Q, rfl⟩,\n    exact ⟨P + Q, alg_hom.map_add _ _ _⟩ },\n  { rintro r f ⟨P, rfl⟩,\n    exact ⟨r • P, alg_hom.map_smul _ _ _⟩ }\nend\n\nvariables (R M)\n\n/-- If an additive monoid `M` is finitely generated then `add_monoid_algebra R M` is of finite\ntype. -/\ninstance finite_type_of_fg [comm_ring R] [h : add_monoid.fg M] :\n  finite_type R (add_monoid_algebra R M) :=\nbegin\n  obtain ⟨S, hS⟩ := h.out,\n  exact (finite_type.mv_polynomial R (S : set M)).of_surjective (mv_polynomial.aeval\n    (λ (s : (S : set M)), of' R M ↑s)) (mv_polynomial_aeval_of_surjective_of_closure hS)\nend\n\nvariables {R M}\n\n/-- An additive monoid `M` is finitely generated if and only if `add_monoid_algebra R M` is of\nfinite type. -/\nlemma finite_type_iff_fg [comm_ring R] [nontrivial R] :\n  finite_type R (add_monoid_algebra R M) ↔ add_monoid.fg M :=\nbegin\n  refine ⟨λ h, _, λ h, @add_monoid_algebra.finite_type_of_fg _ _ _ _ h⟩,\n  obtain ⟨S, hS⟩ := @exists_finset_adjoin_eq_top R M _ _ h,\n  refine add_monoid.fg_def.2 ⟨S, (eq_top_iff' _).2 (λ m, _)⟩,\n  have hm : of' R M m ∈ (adjoin R (of' R M '' ↑S)).to_submodule,\n  { simp only [hS, top_to_submodule, submodule.mem_top], },\n  rw [adjoin_eq_span] at hm,\n  exact mem_closure_of_mem_span_closure hm\nend\n\n/-- If `add_monoid_algebra R M` is of finite type then `M` is finitely generated. -/\nlemma fg_of_finite_type [comm_ring R] [nontrivial R] [h : finite_type R (add_monoid_algebra R M)] :\n  add_monoid.fg M :=\nfinite_type_iff_fg.1 h\n\n/-- An additive group `G` is finitely generated if and only if `add_monoid_algebra R G` is of\nfinite type. -/\nlemma finite_type_iff_group_fg {G : Type*} [add_comm_group G] [comm_ring R] [nontrivial R] :\n  finite_type R (add_monoid_algebra R G) ↔ add_group.fg G :=\nby simpa [add_group.fg_iff_add_monoid.fg] using finite_type_iff_fg\n\nend add_monoid_algebra\n\nnamespace monoid_algebra\n\nopen algebra submonoid submodule\n\nsection span\n\nsection semiring\n\nvariables [comm_semiring R] [monoid M]\n\n/-- An element of `monoid_algebra R M` is in the subalgebra generated by its support. -/\nlemma mem_adjoint_support (f : monoid_algebra R M) : f ∈ adjoin R (of R M '' f.support) :=\nbegin\n  suffices : span R (of R M '' f.support) ≤ (adjoin R (of R M '' f.support)).to_submodule,\n  { exact this (mem_span_support f) },\n  rw submodule.span_le,\n  exact subset_adjoin\nend\n\n/-- If a set `S` generates, as algebra, `monoid_algebra R M`, then the set of supports of elements\nof `S` generates `monoid_algebra R M`. -/\nlemma support_gen_of_gen {S : set (monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (⋃ f ∈ S, (of R M '' (f.support : set M))) = ⊤ :=\nbegin\n  refine le_antisymm le_top _,\n  rw [← hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : (of R M) '' f.support ⊆\n    ⋃ (g : monoid_algebra R M) (H : g ∈ S), of R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union₂.2 ⟨f, ⟨hf, hs⟩⟩ },\n  exact adjoin_mono hincl (mem_adjoint_support f)\nend\n\n/-- If a set `S` generates, as algebra, `monoid_algebra R M`, then the image of the union of the\nsupports of elements of `S` generates `monoid_algebra R M`. -/\nlemma support_gen_of_gen' {S : set (monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (of R M '' (⋃ f ∈ S, (f.support : set M))) = ⊤ :=\nbegin\n  suffices : of R M '' (⋃ f ∈ S, (f.support : set M)) = ⋃ f ∈ S, (of R M '' (f.support : set M)),\n  { rw this,\n    exact support_gen_of_gen hS },\n  simp only [set.image_Union]\nend\n\nend semiring\n\nsection ring\n\nvariables [comm_ring R] [comm_monoid M]\n\n/-- If `monoid_algebra R M` is of finite type, there there is a `G : finset M` such that its image\ngenerates, as algera, `monoid_algebra R M`. -/\nlemma exists_finset_adjoin_eq_top [h :finite_type R (monoid_algebra R M)] :\n  ∃ G : finset M, algebra.adjoin R (of R M '' G) = ⊤ :=\nbegin\n  unfreezingI { obtain ⟨S, hS⟩ := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (λ f, f.support),\n  have : (finset.bUnion S (λ f, f.support) : set M) = ⋃ f ∈ S, (f.support : set M),\n  { simp only [finset.set_bUnion_coe, finset.coe_bUnion] },\n  rw [this],\n  exact support_gen_of_gen' hS\nend\n\n/-- The image of an element `m : M` in `monoid_algebra R M` belongs the submodule generated by\n`S : set M` if and only if `m ∈ S`. -/\nlemma of_mem_span_of_iff [nontrivial R] {m : M} {S : set M} :\n  of R M m ∈ span R (of R M '' S) ↔ m ∈ S :=\nbegin\n  refine ⟨λ h, _, λ h, submodule.subset_span $ set.mem_image_of_mem (of R M) h⟩,\n  rw [of, monoid_hom.coe_mk, ← finsupp.supported_eq_span_single, finsupp.mem_supported,\n    finsupp.support_single_ne_zero (@one_ne_zero R _ (by apply_instance))] at h,\n  simpa using h\nend\n\n/--If the image of an element `m : M` in `monoid_algebra R M` belongs the submodule generated by the\nclosure of some `S : set M` then `m ∈ closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of R M m ∈ span R (submonoid.closure (of R M '' S) : set (monoid_algebra R M))) :\n  m ∈ closure S :=\nbegin\n  rw ← monoid_hom.map_mclosure at h,\n  simpa using of_mem_span_of_iff.1 h\nend\n\nend ring\n\nend span\n\nvariables [comm_monoid M]\n\n/-- If a set `S` generates a monoid `M`, then the image of `M` generates, as algebra,\n`monoid_algebra R M`. -/\nlemma mv_polynomial_aeval_of_surjective_of_closure [comm_semiring R] {S : set M}\n  (hS : closure S = ⊤) : function.surjective (mv_polynomial.aeval\n  (λ (s : S), of R M ↑s) : mv_polynomial S R → monoid_algebra R M) :=\nbegin\n  refine λ f, induction_on f (λ m, _) _ _,\n  { have : m ∈ closure S := hS.symm ▸ mem_top _,\n    refine closure_induction this (λ m hm, _) _ _,\n    { exact ⟨mv_polynomial.X ⟨m, hm⟩, mv_polynomial.aeval_X _ _⟩ },\n    { exact ⟨1, alg_hom.map_one _⟩ },\n    { rintro m₁ m₂ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩,\n      exact ⟨P₁ * P₂, by rw [alg_hom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]⟩ } },\n  { rintro f g ⟨P, rfl⟩ ⟨Q, rfl⟩,\n    exact ⟨P + Q, alg_hom.map_add _ _ _⟩ },\n  { rintro r f ⟨P, rfl⟩,\n    exact ⟨r • P, alg_hom.map_smul _ _ _⟩ }\nend\n\n/-- If a monoid `M` is finitely generated then `monoid_algebra R M` is of finite type. -/\ninstance finite_type_of_fg [comm_ring R] [monoid.fg M] : finite_type R (monoid_algebra R M) :=\n(add_monoid_algebra.finite_type_of_fg R (additive M)).equiv (to_additive_alg_equiv R M).symm\n\n/-- A monoid `M` is finitely generated if and only if `monoid_algebra R M` is of finite type. -/\nlemma finite_type_iff_fg [comm_ring R] [nontrivial R] :\n  finite_type R (monoid_algebra R M) ↔ monoid.fg M :=\n⟨λ h, monoid.fg_iff_add_fg.2 $ add_monoid_algebra.finite_type_iff_fg.1 $ h.equiv $\n  to_additive_alg_equiv R M, λ h, @monoid_algebra.finite_type_of_fg _ _ _ _ h⟩\n\n/-- If `monoid_algebra R M` is of finite type then `M` is finitely generated. -/\nlemma fg_of_finite_type [comm_ring R] [nontrivial R] [h : finite_type R (monoid_algebra R M)] :\n  monoid.fg M :=\nfinite_type_iff_fg.1 h\n\n/-- A group `G` is finitely generated if and only if `add_monoid_algebra R G` is of finite type. -/\nlemma finite_type_iff_group_fg {G : Type*} [comm_group G] [comm_ring R] [nontrivial R] :\n  finite_type R (monoid_algebra R G) ↔ group.fg G :=\nby simpa [group.fg_iff_monoid.fg] using finite_type_iff_fg\n\nend monoid_algebra\n\nend monoid_algebra\n\nsection vasconcelos\nvariables {R : Type*} [comm_ring R] {M : Type*} [add_comm_group M] [module R M] (f : M →ₗ[R] M)\n\nnoncomputable theory\n\n/-- The structure of a module `M` over a ring `R` as a module over `polynomial R` when given a\nchoice of how `X` acts by choosing a linear map `f : M →ₗ[R] M` -/\n@[simps]\ndef module_polynomial_of_endo : module R[X] M :=\nmodule.comp_hom M (polynomial.aeval f).to_ring_hom\n\ninclude f\nlemma module_polynomial_of_endo.is_scalar_tower : @is_scalar_tower R R[X] M _\n  (by { letI := module_polynomial_of_endo f, apply_instance }) _ :=\nbegin\n  letI := module_polynomial_of_endo f,\n  constructor,\n  intros x y z,\n  simp,\nend\n\nopen polynomial module\n\n/-- A theorem/proof by Vasconcelos, given a finite module `M` over a commutative ring, any\nsurjective endomorphism of `M` is also injective. Based on,\nhttps://math.stackexchange.com/a/239419/31917,\nhttps://www.ams.org/journals/tran/1969-138-00/S0002-9947-1969-0238839-5/.\nThis is similar to `is_noetherian.injective_of_surjective_endomorphism` but only applies in the\ncommutative case, but does not use a Noetherian hypothesis. -/\ntheorem module.finite.injective_of_surjective_endomorphism [hfg : finite R M]\n  (f_surj : function.surjective f) : function.injective f :=\nbegin\n  letI := module_polynomial_of_endo f,\n  haveI : is_scalar_tower R R[X] M := module_polynomial_of_endo.is_scalar_tower f,\n  have hfgpoly : finite R[X] M, from finite.of_restrict_scalars_finite R _ _,\n  have X_mul : ∀ o, (X : R[X]) • o = f o,\n  { intro,\n    simp, },\n  have : (⊤ : submodule R[X] M) ≤ ideal.span {X} • ⊤,\n  { intros a ha,\n    obtain ⟨y, rfl⟩ := f_surj a,\n    rw [← X_mul y],\n    exact submodule.smul_mem_smul (ideal.mem_span_singleton.mpr (dvd_refl _)) trivial, },\n  obtain ⟨F, hFa, hFb⟩ := submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul _\n    (⊤ : submodule R[X] M) (finite_def.mp hfgpoly) this,\n  rw [← linear_map.ker_eq_bot, linear_map.ker_eq_bot'],\n  intros m hm,\n  rw ideal.mem_span_singleton' at hFa,\n  obtain ⟨G, hG⟩ := hFa,\n  suffices : (F - 1) • m = 0,\n  { have Fmzero := hFb m (by simp),\n    rwa [← sub_add_cancel F 1, add_smul, one_smul, this, zero_add] at Fmzero, },\n  rw [← hG, mul_smul, X_mul m, hm, smul_zero],\nend\n\nend vasconcelos\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/ring_theory/finiteness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.4650207148365702}}
{"text": "/-\nCopyright (c) 2021 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n\n! This file was ported from Lean 3 source module category_theory.sites.compatible_plus\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Sites.Whiskering\nimport Mathbin.CategoryTheory.Sites.Plus\n\n/-!\n\nIn this file, we prove that the plus functor is compatible with functors which\npreserve the correct limits and colimits.\n\nSee `category_theory/sites/compatible_sheafification` for the compatibility\nof sheafification, which follows easily from the content in this file.\n\n-/\n\n\nnamespace CategoryTheory.GrothendieckTopology\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nopen Opposite\n\nuniverse w₁ w₂ v u\n\nvariable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C)\n\nvariable {D : Type w₁} [Category.{max v u} D]\n\nvariable {E : Type w₂} [Category.{max v u} E]\n\nvariable (F : D ⥤ E)\n\nnoncomputable section\n\nvariable [∀ (α β : Type max v u) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) D]\n\nvariable [∀ (α β : Type max v u) (fst snd : β → α), HasLimitsOfShape (WalkingMulticospan fst snd) E]\n\nvariable [∀ (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F]\n\nvariable (P : Cᵒᵖ ⥤ D)\n\n/-- The diagram used to define `P⁺`, composed with `F`, is isomorphic\nto the diagram used to define `P ⋙ F`. -/\ndef diagramCompIso (X : C) : J.diagram P X ⋙ F ≅ J.diagram (P ⋙ F) X :=\n  NatIso.ofComponents\n    (fun W => by\n      refine' _ ≪≫ has_limit.iso_of_nat_iso (W.unop.multicospan_comp _ _).symm\n      refine'\n        (is_limit_of_preserves F (limit.is_limit _)).conePointUniqueUpToIso (limit.is_limit _))\n    (by\n      intro A B f\n      ext\n      dsimp\n      simp only [functor.map_cone_π_app, multiequalizer.multifork_π_app_left, iso.symm_hom,\n        multiequalizer.lift_ι, eq_to_hom_refl, category.comp_id,\n        limit.cone_point_unique_up_to_iso_hom_comp,\n        grothendieck_topology.cover.multicospan_comp_hom_inv_left, has_limit.iso_of_nat_iso_hom_π,\n        category.assoc]\n      simp only [← F.map_comp, multiequalizer.lift_ι])\n#align category_theory.grothendieck_topology.diagram_comp_iso CategoryTheory.GrothendieckTopology.diagramCompIso\n\n@[simp, reassoc.1]\ntheorem diagramCompIso_hom_ι (X : C) (W : (J.cover X)ᵒᵖ) (i : W.unop.arrow) :\n    (J.diagramCompIso F P X).Hom.app W ≫ Multiequalizer.ι _ i = F.map (Multiequalizer.ι _ _) :=\n  by\n  delta diagram_comp_iso\n  dsimp\n  simp\n#align category_theory.grothendieck_topology.diagram_comp_iso_hom_ι CategoryTheory.GrothendieckTopology.diagramCompIso_hom_ι\n\nvariable [∀ X : C, HasColimitsOfShape (J.cover X)ᵒᵖ D]\n\nvariable [∀ X : C, HasColimitsOfShape (J.cover X)ᵒᵖ E]\n\nvariable [∀ X : C, PreservesColimitsOfShape (J.cover X)ᵒᵖ F]\n\n/-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`. -/\ndef plusCompIso : J.plusObj P ⋙ F ≅ J.plusObj (P ⋙ F) :=\n  NatIso.ofComponents\n    (fun X => by\n      refine' _ ≪≫ has_colimit.iso_of_nat_iso (J.diagram_comp_iso F P X.unop)\n      refine'\n        (is_colimit_of_preserves F\n              (colimit.is_colimit (J.diagram P (unop X)))).coconePointUniqueUpToIso\n          (colimit.is_colimit _))\n    (by\n      intro X Y f\n      apply (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).hom_ext\n      intro W\n      dsimp [plus_obj, plus_map]\n      simp only [functor.map_comp, category.assoc]\n      slice_rhs 1 2 =>\n        erw [(is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).fac]\n      slice_lhs 1 3 =>\n        simp only [← F.map_comp]\n        dsimp [colim_map, is_colimit.map, colimit.pre]\n        simp only [colimit.ι_desc_assoc, colimit.ι_desc]\n        dsimp [cocones.precompose]\n        rw [category.assoc, colimit.ι_desc]\n        dsimp [cocone.whisker]\n        rw [F.map_comp]\n      simp only [category.assoc]\n      slice_lhs 2 3 =>\n        erw [(is_colimit_of_preserves F (colimit.is_colimit (J.diagram P Y.unop))).fac]\n      dsimp\n      simp only [has_colimit.iso_of_nat_iso_ι_hom_assoc, grothendieck_topology.diagram_pullback_app,\n        colimit.ι_pre, has_colimit.iso_of_nat_iso_ι_hom, ι_colim_map_assoc]\n      simp only [← category.assoc]\n      congr 1\n      ext\n      dsimp\n      simp only [category.assoc]\n      erw [multiequalizer.lift_ι, diagram_comp_iso_hom_ι, diagram_comp_iso_hom_ι, ← F.map_comp,\n        multiequalizer.lift_ι])\n#align category_theory.grothendieck_topology.plus_comp_iso CategoryTheory.GrothendieckTopology.plusCompIso\n\n@[simp, reassoc.1]\ntheorem ι_plusCompIso_hom (X) (W) :\n    F.map (colimit.ι _ W) ≫ (J.plusCompIso F P).Hom.app X =\n      (J.diagramCompIso F P X.unop).Hom.app W ≫ colimit.ι _ W :=\n  by\n  delta diagram_comp_iso plus_comp_iso\n  simp only [is_colimit.desc_cocone_morphism_hom, is_colimit.unique_up_to_iso_hom,\n    cocones.forget_map, iso.trans_hom, nat_iso.of_components_hom_app, functor.map_iso_hom, ←\n    category.assoc]\n  erw [(is_colimit_of_preserves F (colimit.is_colimit (J.diagram P (unop X)))).fac]\n  simp only [category.assoc, has_limit.iso_of_nat_iso_hom_π, iso.symm_hom,\n    cover.multicospan_comp_hom_inv_left, eq_to_hom_refl, category.comp_id,\n    limit.cone_point_unique_up_to_iso_hom_comp, functor.map_cone_π_app,\n    multiequalizer.multifork_π_app_left, multiequalizer.lift_ι, functor.map_comp, eq_self_iff_true,\n    category.assoc, iso.trans_hom, iso.cancel_iso_hom_left, nat_iso.of_components_hom_app,\n    colimit.cocone_ι, category.assoc, has_colimit.iso_of_nat_iso_ι_hom]\n#align category_theory.grothendieck_topology.ι_plus_comp_iso_hom CategoryTheory.GrothendieckTopology.ι_plusCompIso_hom\n\n@[simp, reassoc.1]\ntheorem plusCompIso_whiskerLeft {F G : D ⥤ E} (η : F ⟶ G) (P : Cᵒᵖ ⥤ D)\n    [∀ X : C, PreservesColimitsOfShape (J.cover X)ᵒᵖ F]\n    [∀ (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan F]\n    [∀ X : C, PreservesColimitsOfShape (J.cover X)ᵒᵖ G]\n    [∀ (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D), PreservesLimit (W.index P).multicospan G] :\n    whiskerLeft _ η ≫ (J.plusCompIso G P).Hom =\n      (J.plusCompIso F P).Hom ≫ J.plusMap (whiskerLeft _ η) :=\n  by\n  ext X\n  apply (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).hom_ext\n  intro W\n  dsimp [plus_obj, plus_map]\n  simp only [ι_plus_comp_iso_hom, ι_colim_map, whisker_left_app, ι_plus_comp_iso_hom_assoc,\n    nat_trans.naturality_assoc, grothendieck_topology.diagram_nat_trans_app]\n  simp only [← category.assoc]\n  congr 1\n  ext\n  dsimp\n  simpa\n#align category_theory.grothendieck_topology.plus_comp_iso_whisker_left CategoryTheory.GrothendieckTopology.plusCompIso_whiskerLeft\n\n/-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`, functorially in `F`. -/\n@[simps hom_app inv_app]\ndef plusFunctorWhiskerLeftIso (P : Cᵒᵖ ⥤ D)\n    [∀ (F : D ⥤ E) (X : C), PreservesColimitsOfShape (J.cover X)ᵒᵖ F]\n    [∀ (F : D ⥤ E) (X : C) (W : J.cover X) (P : Cᵒᵖ ⥤ D),\n        PreservesLimit (W.index P).multicospan F] :\n    (whiskeringLeft _ _ E).obj (J.plusObj P) ≅ (whiskeringLeft _ _ _).obj P ⋙ J.plusFunctor E :=\n  NatIso.ofComponents (fun X => plusCompIso _ _ _) fun F G η => plusCompIso_whiskerLeft _ _ _\n#align category_theory.grothendieck_topology.plus_functor_whisker_left_iso CategoryTheory.GrothendieckTopology.plusFunctorWhiskerLeftIso\n\n@[simp, reassoc.1]\ntheorem plusCompIso_whiskerRight {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) :\n    whiskerRight (J.plusMap η) F ≫ (J.plusCompIso F Q).Hom =\n      (J.plusCompIso F P).Hom ≫ J.plusMap (whiskerRight η F) :=\n  by\n  ext X\n  apply (is_colimit_of_preserves F (colimit.is_colimit (J.diagram P X.unop))).hom_ext\n  intro W\n  dsimp [plus_obj, plus_map]\n  simp only [ι_colim_map, whisker_right_app, ι_plus_comp_iso_hom_assoc,\n    grothendieck_topology.diagram_nat_trans_app]\n  simp only [← category.assoc, ← F.map_comp]\n  dsimp [colim_map, is_colimit.map]\n  simp only [colimit.ι_desc]\n  dsimp [cocones.precompose]\n  simp only [functor.map_comp, category.assoc, ι_plus_comp_iso_hom]\n  simp only [← category.assoc]\n  congr 1\n  ext\n  dsimp\n  simp only [diagram_comp_iso_hom_ι_assoc, multiequalizer.lift_ι, diagram_comp_iso_hom_ι,\n    category.assoc]\n  simp only [← F.map_comp, multiequalizer.lift_ι]\n#align category_theory.grothendieck_topology.plus_comp_iso_whisker_right CategoryTheory.GrothendieckTopology.plusCompIso_whiskerRight\n\n/-- The isomorphism between `P⁺ ⋙ F` and `(P ⋙ F)⁺`, functorially in `P`. -/\n@[simps hom_app inv_app]\ndef plusFunctorWhiskerRightIso :\n    J.plusFunctor D ⋙ (whiskeringRight _ _ _).obj F ≅\n      (whiskeringRight _ _ _).obj F ⋙ J.plusFunctor E :=\n  NatIso.ofComponents (fun P => J.plusCompIso _ _) fun P Q η => plusCompIso_whiskerRight _ _ _\n#align category_theory.grothendieck_topology.plus_functor_whisker_right_iso CategoryTheory.GrothendieckTopology.plusFunctorWhiskerRightIso\n\n@[simp, reassoc.1]\ntheorem whiskerRight_toPlus_comp_plusCompIso_hom :\n    whiskerRight (J.toPlus _) _ ≫ (J.plusCompIso F P).Hom = J.toPlus _ :=\n  by\n  ext\n  dsimp [to_plus]\n  simp only [ι_plus_comp_iso_hom, functor.map_comp, category.assoc]\n  simp only [← category.assoc]\n  congr 1\n  ext\n  delta cover.to_multiequalizer\n  simp only [diagram_comp_iso_hom_ι, category.assoc, ← F.map_comp]\n  erw [multiequalizer.lift_ι, multiequalizer.lift_ι]\n  rfl\n#align category_theory.grothendieck_topology.whisker_right_to_plus_comp_plus_comp_iso_hom CategoryTheory.GrothendieckTopology.whiskerRight_toPlus_comp_plusCompIso_hom\n\n@[simp]\ntheorem toPlus_comp_plusCompIso_inv :\n    J.toPlus _ ≫ (J.plusCompIso F P).inv = whiskerRight (J.toPlus _) _ := by simp [iso.comp_inv_eq]\n#align category_theory.grothendieck_topology.to_plus_comp_plus_comp_iso_inv CategoryTheory.GrothendieckTopology.toPlus_comp_plusCompIso_inv\n\ntheorem plusCompIso_inv_eq_plusLift (hP : Presheaf.IsSheaf J (J.plusObj P ⋙ F)) :\n    (J.plusCompIso F P).inv = J.plusLift (whiskerRight (J.toPlus _) _) hP :=\n  by\n  apply J.plus_lift_unique\n  simp [iso.comp_inv_eq]\n#align category_theory.grothendieck_topology.plus_comp_iso_inv_eq_plus_lift CategoryTheory.GrothendieckTopology.plusCompIso_inv_eq_plusLift\n\nend CategoryTheory.GrothendieckTopology\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Sites/CompatiblePlus.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.63341027059799, "lm_q1q2_score": 0.46499884818511333}}
{"text": "import QL.FOL.semantics order.filter.ultrafilter data.finset.basic\nopen encodable\n\nuniverses u v\n\nnamespace fol\n\nopen_locale logic_symbol\nopen logic.semantics\n\nvariables {L : language.{u}} {μ : Type v} {n : ℕ} {I : Type u} [inhabited I] (F : ultrafilter I)\n  {𝔄 : I → nonempty_Structure L}\n\ndef uequiv : (Π i, 𝔄 i) → (Π i, 𝔄 i) → Prop :=\nλ u₁ u₂, {i | u₁ i = u₂ i} ∈ F\n\nnotation u` ~[`:80 F`] `v:80 := uequiv F u v\n\n@[simp] lemma uequiv_refl (u : Π i, 𝔄 i) : u ~[F] u :=\nby { simp[uequiv], exact F.univ_sets }\n\nlemma uequiv_symm {u₁ u₂ : Π i, 𝔄 i} : u₁ ~[F] u₂ → u₂ ~[F] u₁ :=\nby { simp[uequiv], have : {i | u₁ i = u₂ i} = {i | u₂ i = u₁ i}, { ext, simp, exact eq_comm }, simp[this] }\n\nlemma uequiv_trans {u₁ u₂ u₃ : Π i, 𝔄 i} : u₁ ~[F] u₂ → u₂ ~[F] u₃ → u₁ ~[F] u₃ :=\nby { simp[uequiv], intros h₁ h₂,\n     have : {i | u₁ i = u₂ i} ∩ {i | u₂ i = u₃ i} ⊆ {i | u₁ i = u₃ i},\n     { intros i hi, simp* at* },\n     exact F.sets_of_superset (F.inter_sets h₁ h₂) this }\n\ntheorem uequiv_equivalence : equivalence (@uequiv L I _ F 𝔄) :=\n⟨uequiv_refl F, λ _ _ , uequiv_symm F, λ _ _ _, uequiv_trans F⟩\n\n\n@[reducible, simp, instance]\ndef ult (𝔄 : I → nonempty_Structure L) (F : ultrafilter I) : setoid (Π i, 𝔄 i) := ⟨@uequiv L I _ F 𝔄, uequiv_equivalence F⟩\n\ndef Ult (𝔄 : I → nonempty_Structure L) (F : ultrafilter I) : Type* :=\nquotient (ult 𝔄 F: setoid (Π i, 𝔄 i))\n\ndef to_quotient {𝔄 : I → nonempty_Structure L} {F : ultrafilter I} (u : Π i, 𝔄 i) : Ult 𝔄 F := quotient.mk' u\n\nnotation `⟦`u`⟧*` :max := to_quotient u\n\ninstance : inhabited (Ult 𝔄 F) := ⟨⟦λ i, default⟧*⟩\n\nnamespace Ult\nopen logic.semantics\n\n@[elab_as_eliminator]\nprotected lemma ind_on {C : Ult 𝔄 F → Prop} (u : Ult 𝔄 F)\n  (h : ∀ u : Π i, 𝔄 i, C ⟦u⟧*) : C u :=\nquotient.induction_on' u h\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on {φ} (d : Ult 𝔄 F) (f : (Π i, 𝔄 i) → φ)\n  (h : ∀ (v u : Π i, 𝔄 i), v ~[F] u → f v = f u) : φ :=\nquotient.lift_on' d f h\n\n@[simp]\nprotected lemma lift_on_eq {φ} (u₀ : Π i, 𝔄 i) (f : (Π i, 𝔄 i) → φ)\n  (h : ∀ v u, v ~[F] u → f v = f u) : fol.Ult.lift_on F ⟦u₀⟧* f h = f u₀ := rfl\n\n@[elab_as_eliminator, reducible, simp]\nprotected def lift_on₂ {φ} (u₁ u₂ : Ult 𝔄 F) (f : (Π i, 𝔄 i) → (Π i, 𝔄 i) → φ)\n  (h : ∀ u₁ u₂ v₁ v₂, u₁ ~[F] v₁ → u₂ ~[F] v₂ → f u₁ u₂ = f v₁ v₂) : φ :=\nquotient.lift_on₂' u₁ u₂ f h\n\n@[simp]\nprotected lemma lift_on₂_eq {φ} (u₁ u₂ : Π i, 𝔄 i) (f : (Π i, 𝔄 i) → (Π i, 𝔄 i) → φ)\n  (h : ∀ t₁ t₂ u₁ u₂, (t₁ ~[F] u₁) → (t₂ ~[F] u₂) → f t₁ t₂ = f u₁ u₂) :\n  fol.Ult.lift_on₂ F ⟦u₁⟧* ⟦u₂⟧* f h = f u₁ u₂ := rfl\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on_finitary {φ} {n : ℕ} (v : finitary (Ult 𝔄 F) n) (f : finitary (Π i, 𝔄 i) n → φ)\n  (h : ∀ v₁ v₂ : finitary (Π i, 𝔄 i) n, (∀ n, (v₁ n) ~[F] (v₂ n)) → f v₁ = f v₂) : φ :=\nquotient.lift_on_finitary v f h \n\n@[simp]\nprotected lemma lift_on_finitary_eq {φ} {n} (v : finitary (Π i, 𝔄 i) n) (f : finitary (Π i, 𝔄 i) n → φ)\n  (h : ∀ v₁ v₂ : finitary (Π i, 𝔄 i) n, (∀ n, (v₁ n) ~[F] (v₂ n)) → f v₁ = f v₂) :\n  fol.Ult.lift_on_finitary F (λ x, ⟦v x⟧*) f h = f v :=\nquotient.lift_on_finitary_eq v f h\n\n@[simp] lemma of_eq_of {u₁ u₂ : Π i, 𝔄 i} : (⟦u₁⟧* : Ult 𝔄 F) = ⟦u₂⟧* ↔ u₁ ~[F] u₂ :=\nby simp[to_quotient, quotient.eq']\n\nlemma equivs_mem {n} {v₁ v₂ : finitary (Π i, 𝔄 i) n} (h : ∀ (x : fin n), {i : I | v₁ x i = v₂ x i} ∈ F) :\n  {i | (λ x, v₁ x i) = (λ x, v₂ x i)} ∈ F := \nbegin\n  induction n with n IH,\n  { have : {i : I | (λ x, v₁ x i) = (λ x, v₂ x i)} = set.univ,\n    { ext i, simp }, rw this, exact F.univ_sets },\n  { have ss : {i | v₁ 0 i = v₂ 0 i} ∩ {i | (λ x, v₁.tail x i) = (λ x, v₂.tail x i)} ⊆ {i : I | (λ x, v₁ x i) = (λ x, v₂ x i)},\n    { intros i hi, simp[finitary.tail] at*,\n      funext x, refine fin.cases _ _ x,\n      { exact hi.1 },\n      { intros j, have := congr_fun hi.2 j, simp at this, exact this } },\n    have : {i | v₁ 0 i = v₂ 0 i} ∩ {i | (λ x, v₁.tail x i) = (λ x, v₂.tail x i)} ∈ F,\n      from (F.inter_sets (h _) (@IH v₁.tail v₂.tail (λ x, h _))),\n    refine F.sets_of_superset this ss }\nend\n\nlemma fn_equiv {n} {v₁ v₂ : finitary (Π i, 𝔄 i) n} (h : ∀ x, v₁ x ~[F] v₂ x) (f : L.fn n) :\n  (λ i, (𝔄 i).fn f (λ x, v₁ x i)) ~[F] (λ i, (𝔄 i).fn f (λ x, v₂ x i)) :=\nbegin\n  simp[uequiv] at*,\n  have : {i | (λ x, v₁ x i) = (λ x, v₂ x i)} ⊆ {i | (𝔄 i).fn f (λ x, v₁ x i) = (𝔄 i).fn f (λ x, v₂ x i)},\n  { intros i hi, simp* at* },\n  exact F.sets_of_superset (equivs_mem F h) this\nend\n\nlemma pr_equiv : ∀ {n} {v₁ v₂ : finitary (Π i, 𝔄 i) n} (h : ∀ x, v₁ x ~[F] v₂ x) (p : L.pr n),\n  {i | (𝔄 i).pr p (λ x, v₁ x i)} ∈ F ↔ {i | (𝔄 i).pr p (λ x, v₂ x i)} ∈ F :=\nbegin\n  suffices : ∀ {n} {v₁ v₂ : finitary (Π i, 𝔄 i) n} (h : ∀ x, v₁ x ~[F] v₂ x) (p : L.pr n),\n  {i | (𝔄 i).pr p (λ x, v₁ x i)} ∈ F → {i | (𝔄 i).pr p (λ x, v₂ x i)} ∈ F,\n  { intros n v₁ v₂ eqn p, refine ⟨this eqn p, this (λ x, uequiv_symm _ (eqn x)) p⟩ },\n  intros n v₁ v₂ eqn p h,\n  have : {i | (𝔄 i).pr p (λ x, v₁ x i)} ∩ {i | (λ x, v₁ x i) = (λ x, v₂ x i)} ⊆ {i | (𝔄 i).pr p (λ x, v₂ x i)},\n  { intros i hi, simp* at*, simp[←hi.2], exact hi.1 },\n  refine F.sets_of_superset (F.inter_sets h (equivs_mem _ eqn)) this\nend\n\ndef product_fn (k) (f : L.fn k) : finitary (Ult 𝔄 F) k → Ult 𝔄 F :=\nλ v, fol.Ult.lift_on_finitary F v (λ v, (⟦λ i, (𝔄 i).fn f (λ x, v x i)⟧* : Ult 𝔄 F)) $ λ u₁ u₂ eqn,\nby { simp, exact fn_equiv F eqn f }\n\ndef product_pr (n) (p : L.pr n) : finitary (Ult 𝔄 F) n → Prop :=\nλ v, fol.Ult.lift_on_finitary F v (λ v, {i | (𝔄 i).pr p (λ x, v x i)} ∈ F) $ λ u₁ u₂ eqn,\nby { simp, exact pr_equiv F eqn p }\n\n@[reducible] def product (𝔄 : I → nonempty_Structure L) (F : ultrafilter I) : nonempty_Structure L :=\n{ dom := Ult 𝔄 F,\n  fn := product_fn F,\n  pr := product_pr F,\n  dom_inhabited := Ult.inhabited F }\n\nvariables {F}\nopen subformula\n\nlemma Structure_fn_eq {n} (f : L.fn n) : (product 𝔄 F).fn f = product_fn F _ f := rfl\n\nlemma Structure_pr_eq {n} (r : L.pr n) : (product 𝔄 F).pr r = product_pr F _ r := rfl\n\nvariables (Φ : Π i, μ → 𝔄 i) (e : Π i, fin n → 𝔄 i)\n\nlemma val_subterm (t : subterm L μ n) :\n  subterm.val (product 𝔄 F : Structure L) (λ x, ⟦λ i, Φ i x⟧*) (λ x, ⟦λ i, e i x⟧*) t = ⟦λ i, subterm.val (𝔄 i) (Φ i) (e i) t⟧* :=\nby induction t; simp[Structure_fn_eq, product_fn, *]\n\nprivate lemma concat_to_quo (u : Π i, 𝔄 i) :\n  ((⟦u⟧* : Ult 𝔄 F) *> λ x, ⟦λ i, e i x⟧*) = λ x, ⟦λ i, (u i *> e i) x⟧* :=\nby ext x; refine fin.cases _ _ x; simp\n\ntheorem subval_subformula : ∀ {n} (e : Π i, fin n → 𝔄 i) (p : subformula L μ n),\n  subval (product 𝔄 F : Structure L) (λ x, ⟦λ i, Φ i x⟧*) (λ x, ⟦λ i, e i x⟧*) p ↔ {i | subval (𝔄 i : Structure L) (Φ i) (e i) p} ∈ F\n| n e verum          := by simp[top_eq]; exact F.univ_sets\n| n e (relation r v) := by simp[Structure_pr_eq, product_pr, val_subterm, (∘)]\n| n e (imply p q)    :=\n    by simp[imply_eq, subval_subformula _ p, subval_subformula _ q, decidable.imp_iff_not_or,\n      ←ultrafilter.compl_mem_iff_not_mem]; exact ultrafilter.union_mem_iff.symm\n| n e (neg p)        := by simp[neg_eq, subval_subformula _ p]; exact ultrafilter.compl_mem_iff_not_mem.symm\n| n e (fal p)        :=\n    begin\n      simp[fal_eq],\n      let e' := λ (u : Π i, 𝔄 i), (λ i, u i *> e i),\n      calc (∀ u : product 𝔄 F, subval (product 𝔄 F : Structure L) (λ x, ⟦λ i, Φ i x⟧*) (u *> λ x, ⟦λ i, e i x⟧*) p)\n          ↔ (∀ u : Π i, 𝔄 i, subval (product 𝔄 F : Structure L) (λ x, ⟦λ i, Φ i x⟧*) (λ x, ⟦λ i, e' u i x⟧*) p)\n      : by { split,\n             { intros h u, simpa[e', concat_to_quo] using h ⟦u⟧* },\n             { intros h u, induction u using fol.Ult.ind_on, simpa[concat_to_quo] using h u } }\n      ... ↔ ∀ u : Π i, 𝔄 i, {i | subval (𝔄 i : Structure L) (Φ i) (e' u i) p} ∈ F\n      : by { exact forall_congr (λ u, subval_subformula (e' u) p) }\n      ... ↔ {i : I | ∀ (x : 𝔄 i), subval (𝔄 i : Structure L) (Φ i) (x *> e i) p} ∈ F\n      : by { simp[e'], split,\n            { intros h,\n              let u : Π i, 𝔄 i := λ i, classical.epsilon (λ u, ¬subval ↑(𝔄 i) (Φ i) (u *> e i) p),\n              refine F.sets_of_superset (h u) _,\n              { intros i, simp, intros hi, by_contradiction A, simp at A,\n                have : ¬subval ↑(𝔄 i) (Φ i) (u i *> e i) p,\n                from classical.epsilon_spec_aux _ _ A,\n                contradiction } },\n            { intros h u, refine filter.mem_of_superset h (by intros i hi; exact hi (u i)) } }\n    end\n\n-- Łoś's theorem\ntheorem fundamental_param (p : formula L μ) (Φ : ∀ i, μ → 𝔄 i) :\n  val (product 𝔄 F : Structure L) (λ x, ⟦λ i, Φ i x⟧*) p ↔ {i | val (𝔄 i : Structure L) (Φ i) p} ∈ F :=\nby have := @subval_subformula L _ _ _ F _ Φ _ (λ i, fin.nil) p; exact cast (by congr) this\n\ntheorem fundamental {σ : sentence L} :\n  product 𝔄 F ⊧ σ ↔ {i | 𝔄 i ⊧ σ} ∈ F :=\nby have := @fundamental_param L _ _ _ F 𝔄 σ (λ i, fin.nil); simp[nonempty_Structure.sentence_models_def];\n   exact cast (by congr) this\n\nend Ult\nend fol\n\nnamespace fol\nvariables {L : language.{u}} \n\ndef finTheory (T : Theory L) := {s : finset (sentence L) // ↑s ⊆ T}\n\nvariables {T : Theory L}\n\ndef finTheory.empty {T : Theory L} : finTheory T := ⟨∅, by simp⟩\ninstance : inhabited (finTheory T) := ⟨⟨∅, by simp⟩⟩\n\nnoncomputable def finTheory.insert (P : finTheory T) {σ : sentence L} (h : σ ∈ T) : finTheory T :=\n⟨insert σ P.val, λ x hx,  by { simp at hx, cases hx, simp[hx, h], refine P.property hx }⟩\n\n@[simp] lemma finTheory.insert_val (P : finTheory T) {σ : sentence L} (h : σ ∈ T) :\n  (P.insert h).val = insert σ P.val := rfl\n\ninstance : has_coe (finTheory T) (Theory L) := ⟨λ s, {p | p ∈ s.val}⟩\n\nnamespace compactness\nopen nonempty_Structure\n\nvariables (𝔄 : finTheory T → nonempty_Structure L) \n\ndef formdomain (p : sentence L) : set (finTheory T) := {i | 𝔄 i ⊧ p}\n\ndef F : set (set (finTheory T)) := {x | ∃ p, T p ∧ x = formdomain 𝔄 p}\n\nprivate lemma finite_intersection_lmm (nonempty : ∃ p, T p) (H : ∀ (i : finTheory T) p, p ∈ i.val → 𝔄 i ⊧ p) :\n  ∀ S : finset (set (finTheory T)), (↑S : set (set (finTheory T))) ⊆ F 𝔄 →\n  ∃ P : finTheory T,\n  (∀ p, p ∈ P.val → formdomain 𝔄 p ∈ S) ∧ (∀ S', S' ∈ S → ∃ p, p ∈ P.val ∧ S' = formdomain 𝔄 p) :=\nbegin\n  intros S, induction S using finset.induction with i S i_fresh IH,\n  { intros _, simp[set.nonempty], rcases nonempty with ⟨p₀, hyp_p₀⟩,\n    refine ⟨⟨∅, by simp⟩, _⟩, unfold_coes, simp },\n  { intros h, simp at*,\n    have lmm₁ : ↑S ⊆ F 𝔄, from set.subset.trans (set.subset_insert _ _) h,\n    have : ∃ (P : finTheory T),\n      (∀ p, p ∈ ↑P → formdomain 𝔄 p ∈ S) ∧ (∀ S', S' ∈ S → ∃ p, p ∈ ↑P ∧ S' = formdomain 𝔄 p),\n    from IH lmm₁, rcases this with ⟨P, IH₁, IH₂⟩,\n    have : ∃ p, T p ∧ i = formdomain 𝔄 p, from h (set.mem_insert i ↑S),\n    rcases this with ⟨p, hyp_p, rfl⟩,\n    refine ⟨P.insert hyp_p, _, _, _⟩; unfold_coes; simp,\n    { refine λ q hyp_q, or.inr (IH₁ _ hyp_q) },\n    { refine ⟨p, or.inl rfl, rfl⟩ },\n    { intros S' hyp_S',\n      have : ∃ p, p ∈ ↑P ∧ S' = formdomain 𝔄 p, from IH₂ _ hyp_S', rcases this with ⟨p, hyp, rfl⟩,\n      refine ⟨p, or.inr hyp, rfl⟩ } }\nend\n\ntheorem finite_intersection (h : ∃ p, T p) (H : ∀ (i : finTheory T) p, p ∈ i.val → 𝔄 i ⊧ p) :\n  ∀ S : finset (set (finTheory T)), \n  (↑S : set (set (finTheory T))) ⊆ F 𝔄 → (⋂₀ (↑S : set (set (finTheory T)))).nonempty :=\nbegin\n  intros S hS, have := finite_intersection_lmm _ h H S hS, rcases this with ⟨P, hyp⟩,\n  refine ⟨P, λ S' hS', _⟩, \n  have := hyp.2 S' hS', rcases this with ⟨p, hyp_p, rfl⟩, simp[formdomain] at*,\n  refine H _ _ hyp_p\nend\n\ntheorem ultrafilter_exists (h : ∃ p, p ∈ T) (H : ∀ (i : finTheory T) p, p ∈ i.val → 𝔄 i ⊧ p) :\n  ∃ U : ultrafilter (finTheory T), F 𝔄 ⊆ U.to_filter.sets :=\nultrafilter.exists_ultrafilter_of_finite_inter_nonempty _ (finite_intersection _ h H)\n\ntheorem compact (T : Theory L) :\n  Satisfiable T ↔ ∀ S : finset (sentence L), ↑S ⊆ T → Satisfiable (S : Theory L) :=\n  ⟨by { intros H S hyp_S, rcases H with ⟨𝔄, hyp⟩,\n        refine ⟨𝔄, λ p h, hyp (hyp_S h)⟩ },\n   by { suffices : (∀ S : finTheory T, Satisfiable (↑S : Theory L)) → Satisfiable T,\n        { intros h, refine this (λ S, _),\n          rcases h S.val S.property with ⟨𝔄, hyp_𝔄⟩, refine ⟨𝔄, hyp_𝔄⟩ },\n    intros H, by_cases C : T = ∅,\n        { rcases C with rfl, refine ⟨default, by intros p; simp⟩ },\n        { have ex : ∃ p, p ∈ T, { by_contra, simp at*, refine C _, { ext x, simp, refine h _ } }, \n          have : ∃ (𝔄 : finTheory T → nonempty_Structure L), ∀ (i : finTheory T) p, p ∈ i.val → 𝔄 i ⊧ p,\n          from classical.skolem.mp H, rcases this with ⟨𝔄, hyp_𝔄⟩,\n          have := @ultrafilter_exists _ _ 𝔄 ex hyp_𝔄, rcases this with ⟨U, hyp_U⟩,\n          refine ⟨Ult.product 𝔄 U, _⟩, intros p hyp_p, rw Ult.fundamental,\n          have : {i | 𝔄 i ⊧ p} ∈ F 𝔄, { refine ⟨p, hyp_p, rfl⟩ },\n          exact hyp_U this } }⟩\n\nend compactness\n\nend fol\n", "meta": {"author": "iehality", "repo": "lean-logic", "sha": "201cef2500203f7de83deb7fa8287934e2e142b2", "save_path": "github-repos/lean/iehality-lean-logic", "path": "github-repos/lean/iehality-lean-logic/lean-logic-201cef2500203f7de83deb7fa8287934e2e142b2/src/QL/FOL/ultraproduct.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.464998838024679}}
{"text": "import algebraic_topology.simplicial_set\nimport category_theory.limits.kan_extension\nimport for_mathlib.split_simplicial_object\nimport for_mathlib.category_theory.limits.concrete\nimport data.fintype.basic\n\nnoncomputable theory\n\nuniverses u\n\nopen category_theory\nopen category_theory.limits\nopen opposite\nopen_locale simplicial\n\nnamespace simplex_category\n\nsection\nvariables {X Y : simplex_category} (θ : X ⟶ Y)\ninstance : strong_epi (factor_thru_image θ) :=\nstrong_epi_factor_thru_image_of_strong_epi_mono_factorisation\n  (has_strong_epi_mono_factorisations.has_fac θ).some\n\nlemma is_iso_of_epi_and_card [hθ : epi θ] (h : X.len = Y.len) : is_iso θ :=\nbegin\n  apply is_iso_of_bijective,\n  split,\n  { by_contra h',\n    rw epi_iff_surjective at hθ,\n    simpa only [fintype.card_fin, add_lt_add_iff_right, h, lt_self_iff_false]\n      using fintype.card_lt_of_surjective_not_injective _ hθ h', },\n  { change function.surjective θ.to_order_hom,\n    rw ← epi_iff_surjective,\n    apply_instance, },\nend\n\nend\n\n--protected def rec {F : Π (X : simplex_category), Sort u} (h : ∀ (n : ℕ), F [n]) :\n--  Π X, F X := λ n, h n.len\n\nend simplex_category\n\nnamespace sSet\n\nlemma map_comp' (X : sSet) {Δ₀ Δ₁ Δ₂ : simplex_categoryᵒᵖ} (θ : Δ₀ ⟶ Δ₁) (θ' : Δ₁ ⟶ Δ₂)\n  (x : X.obj Δ₀) : X.map (θ ≫ θ') x = X.map θ' (X.map θ x) :=\ncongr_fun (X.map_comp θ θ') x\n\nnamespace truncated\n\ndef i (n : ℕ) : truncated n ⥤ sSet.{u} :=\nLan simplex_category.truncated.inclusion.op\n\ndef adjunction (n : ℕ) : i n ⊣ sk n :=\ncategory_theory.Lan.adjunction _ simplex_category.truncated.inclusion.op\n\ninstance adjunction.unit_is_iso (n : ℕ) : is_iso (adjunction n).unit :=\nLan.coreflective _ _\n\nend truncated\n\ndef sk' (n : ℕ) : sSet ⥤ sSet := sk n ⋙ truncated.i n\n\ndef ι_sk' (n : ℕ) : sk' n ⟶ 𝟭 sSet := (truncated.adjunction n).counit\n\ninstance sk_ι_sk'_is_iso (n : ℕ) : is_iso (whisker_right (ι_sk' n) (sk.{u} n)) :=\nbegin\n  let f := (whisker_left (sk.{u} n) (truncated.adjunction n).unit),\n  let g := whisker_right (truncated.adjunction n).counit (sk.{u} n),\n  haveI : is_iso (f ≫ g),\n  { rw (truncated.adjunction n).right_triangle,\n    apply_instance, },\n  change is_iso g,\n  exact is_iso.of_is_iso_comp_left f g,\nend\n\nlemma ι_sk'_bij (X : sSet) (n : ℕ) (Δ : simplex_categoryᵒᵖ) (h : Δ.unop.len ≤ n) :\n  is_iso (((ι_sk' n).app X).app Δ) :=\nbegin\n  induction Δ using opposite.rec,\n  have h' : ∃ (Δ' : simplex_category.truncated n), Δ = Δ'.1 := ⟨⟨Δ, h⟩, rfl⟩,\n  cases h' with Δ' hΔ',\n  subst hΔ',\n  let e := as_iso (whisker_right (ι_sk' n) (sk n)),\n  exact is_iso.of_iso ((e.app X).app (opposite.op Δ')),\nend\n\ndef simplex_is_degenerate {X : sSet} {Δ : simplex_categoryᵒᵖ} (x : X.obj Δ) : Prop :=\n∃ (Δ' : simplex_categoryᵒᵖ) (θ : Δ' ⟶ Δ) (hθ₁ : epi θ.unop) (hθ₂ : ¬mono θ.unop)\n  (y : X.obj Δ'), x = X.map θ y\n\n@[simp]\ndef nondegenerate_simplices (X : sSet) (Δ : simplex_categoryᵒᵖ) : set (X.obj Δ) :=\ncompl simplex_is_degenerate\n\nlemma is_iso_of_nondegenerate_simplices {X : sSet} {Δ Δ' : simplex_categoryᵒᵖ}\n  (x : X.nondegenerate_simplices Δ) (θ : Δ' ⟶ Δ) (hθ : epi θ.unop) (y : X.obj Δ')\n  (hy : x.1 = X.map θ y) : is_iso θ :=\nbegin\n  suffices : is_iso θ.unop,\n  { haveI := this,\n    change is_iso θ.unop.op,\n    apply_instance, },\n  apply simplex_category.is_iso_of_bijective,\n  split,\n  { change function.injective θ.unop.to_order_hom,\n    rw ← simplex_category.mono_iff_injective,\n    by_contra,\n    exact x.2 ⟨Δ', θ, hθ, h, y, hy⟩, },\n  { change function.surjective θ.unop.to_order_hom,\n    rw ← simplex_category.epi_iff_surjective,\n    exact hθ, },\nend\n\n@[simp]\ndef ι_nondegenerate_simplices (X : sSet.{u}) (Δ : simplex_categoryᵒᵖ) :\n  (X.nondegenerate_simplices Δ : Type u) ⟶ X.obj Δ := subtype.val\n\nlemma zero_simplices_are_nondegenerate (X : sSet) : X.nondegenerate_simplices (op [0]) = ⊤ :=\nbegin\n  ext,\n  split,\n  { intro h,\n    simp only [set.top_eq_univ], },\n  { intros h₀ h,\n    rcases h with ⟨Δ', θ, hθ₁, hθ₂, y, hy⟩,\n    apply hθ₂,\n    rw simplex_category.mono_iff_injective,\n    intros a₁ a₂ h,\n    rw [fin.eq_zero a₁, fin.eq_zero a₂], },\nend\n\nlemma is_epi_image_of_nondegenerate_simplex (X : sSet) {Δ : simplex_categoryᵒᵖ} (x : X.obj Δ) :\n  ∃ (Δ' : simplex_categoryᵒᵖ) (θ : Δ' ⟶ Δ) (hθ : epi θ.unop) (y : X.obj Δ')\n    (hy : y ∈ X.nondegenerate_simplices Δ'), x = X.map θ y :=\nbegin\n  induction Δ using opposite.rec,\n  induction Δ with n,\n  induction n using nat.strong_rec' with n hn,\n  cases n,\n  { refine ⟨op [0], 𝟙 _, infer_instance, x, _, by simp only [functor_to_types.map_id_apply]⟩,\n    rw zero_simplices_are_nondegenerate,\n    simp only [set.top_eq_univ], },\n { by_cases x ∈ X.nondegenerate_simplices (op [n.succ]),\n    { exact ⟨_, 𝟙 _, infer_instance, x, h, by simp only [functor_to_types.map_id_apply]⟩, },\n    { dsimp [nondegenerate_simplices] at h,\n      simp only [set.not_not_mem] at h,\n      rcases h with ⟨Δ', π, hπ₁, hπ₂, y, hy⟩,\n      induction Δ' using opposite.rec,\n      induction Δ' with m,\n      have hm : m < n.succ,\n      { have hπ₁' := (simplex_category.len_le_of_epi hπ₁),\n        dsimp at hπ₁',\n        cases hπ₁'.lt_or_eq,\n        { assumption, },\n        { subst h,\n          exfalso,\n          apply hπ₂,\n          rw simplex_category.mono_iff_injective,\n          rw simplex_category.epi_iff_surjective at hπ₁,\n          rw finite.injective_iff_bijective at ⊢,\n          rw finite.surjective_iff_bijective at hπ₁,\n          assumption, }, },\n      rcases hn m hm y with ⟨Δ'', θ, hθ, z, hz, eq⟩,\n      haveI := hπ₁,\n      haveI := hθ,\n      refine ⟨Δ'', θ ≫ π, by { rw unop_comp, apply epi_comp, }, z, hz, _⟩,\n      simp only [functor_to_types.map_comp_apply, hy, eq], }, },\nend\n\n--lemma splitting.sum.concrete_bijective (N : ℕ → Type u) (Δ : simplex_categoryᵒᵖ) :\n--  function.bijective (limits.concrete.coproduct_map (simplicial_object.splitting.summand N Δ) :\n--    sigma (simplicial_object.splitting.summand N Δ) → simplicial_object.splitting.sum N Δ) :=\n--limits.concrete.coproduct_map_bijective _\n\nlemma image_of_nondegenerate_simplex_uniqueness₀ (X : sSet)\n  {Δ Δ₁ Δ₂ : simplex_categoryᵒᵖ} (y₁ : X.obj Δ₁) (y₂ : X.obj Δ₂)\n  (hy₁ : y₁ ∈ X.nondegenerate_simplices Δ₁)\n  (θ₁ : Δ₁ ⟶ Δ) (θ₂ : Δ₂ ⟶ Δ) (hθ₁ : epi θ₁.unop) (hθ₂ : epi θ₂.unop)\n  (eq : X.map θ₁ y₁ = X.map θ₂ y₂) : Δ₁.unop.len ≤ Δ₂.unop.len :=\nbegin\n  haveI := is_split_epi_of_epi θ₁.unop,\n  let f := section_ θ₁.unop ≫ θ₂.unop,\n  have eq₁ : y₁ = X.map f.op y₂,\n  { dsimp only [f],\n    rw [op_comp, X.map_comp', quiver.hom.op_unop, ← eq, ← X.map_comp'],\n    change _ = X.map (θ₁.unop.op ≫ _) _,\n    rw [← op_comp, is_split_epi.id θ₁.unop, op_id, X.map_id, types_id_apply], },\n  let F := limits.image.mono_factorisation f,\n  rw [← F.fac, op_comp, X.map_comp'] at eq₁,\n  haveI : epi F.e := by { simp only [limits.as_factor_thru_image], apply_instance, },\n  haveI he := is_iso_of_nondegenerate_simplices ⟨y₁, hy₁⟩ F.e.op infer_instance _ eq₁,\n  haveI : is_iso F.e,\n  { change is_iso F.e.op.unop,\n    apply_instance, },\n  have hf : mono f,\n  { rw ← F.fac,\n    apply mono_comp, },\n  exact simplex_category.len_le_of_mono hf,\nend\n\nlemma image_of_nondegenerate_simplex_uniqueness₁ (X : sSet)\n  {Δ Δ₁ Δ₂ : simplex_categoryᵒᵖ} (y₁ : X.obj Δ₁) (y₂ : X.obj Δ₂)\n  (hy₁ : y₁ ∈ X.nondegenerate_simplices Δ₁) (hy₂ : y₂ ∈ X.nondegenerate_simplices Δ₂)\n  (θ₁ : Δ₁ ⟶ Δ) (θ₂ : Δ₂ ⟶ Δ) (hθ₁ : epi θ₁.unop) (hθ₂ : epi θ₂.unop)\n  (eq : X.map θ₁ y₁ = X.map θ₂ y₂) : Δ₁ = Δ₂ :=\nbegin\n  unfreezingI { induction Δ₁ using opposite.rec, induction Δ₂ using opposite.rec, },\n  congr,\n  ext,\n  apply le_antisymm,\n  { exact image_of_nondegenerate_simplex_uniqueness₀ X y₁ y₂ hy₁ θ₁ θ₂ hθ₁ hθ₂ eq, },\n  { exact image_of_nondegenerate_simplex_uniqueness₀ X y₂ y₁ hy₂ θ₂ θ₁ hθ₂ hθ₁ eq.symm, },\nend\n\nlemma image_of_nondegenerate_simplex_uniqueness₂ (X : sSet)\n  {Δ Δ' : simplex_categoryᵒᵖ} (y₁ : X.obj Δ') (y₂ : X.obj Δ')\n  (hy₁ : y₁ ∈ X.nondegenerate_simplices Δ') (hy₂ : y₂ ∈ X.nondegenerate_simplices Δ')\n  (θ₁ : Δ' ⟶ Δ) (θ₂ : Δ' ⟶ Δ) (hθ₁ : epi θ₁.unop) (hθ₂ : epi θ₂.unop)\n  (eq : X.map θ₁ y₁ = X.map θ₂ y₂) : y₁ = y₂ :=\nbegin\n  haveI := is_split_epi_of_epi θ₁.unop,\n  let f := section_ θ₁.unop ≫ θ₂.unop,\n  have eq₁ : y₁ = X.map f.op y₂,\n  { dsimp only [f],\n    rw [op_comp, X.map_comp', quiver.hom.op_unop, ← eq, ← X.map_comp'],\n    change _ = X.map (θ₁.unop.op ≫ _) _,\n    rw [← op_comp, is_split_epi.id θ₁.unop, op_id, X.map_id, types_id_apply], },\n  have eq₂ := eq₁,\n  let F := limits.image.mono_factorisation f,\n  rw [← F.fac, op_comp, X.map_comp'] at eq₂,\n  haveI : epi F.e := by { simp only [limits.as_factor_thru_image], apply_instance, },\n  haveI he := is_iso_of_nondegenerate_simplices ⟨y₁, hy₁⟩ F.e.op infer_instance _ eq₂,\n  haveI : is_iso F.e,\n  { change is_iso F.e.op.unop,\n    apply_instance, },\n  haveI : mono f,\n  { rw ← F.fac,\n    apply mono_comp, },\n  simpa only [simplex_category.eq_id_of_mono f, op_id, X.map_id, types_id_apply] using eq₁,\nend\n\nlemma ext_epi_of_sections {Δ₁ Δ₂ : simplex_category} (θ₁ θ₂ : Δ₁ ⟶ Δ₂) [epi θ₁]\n  (h : ∀ (s : split_epi θ₁), s.section_ ≫ θ₂ = 𝟙 _) : θ₁ = θ₂ :=\nbegin\n  ext1, ext1, ext1 x,\n  have h₂ : ∃ (s : split_epi θ₁), s.section_.to_order_hom (θ₁.to_order_hom x) = x,\n  { haveI := is_split_epi_of_epi θ₁,\n    let α : fin (Δ₂.len+1) → fin (Δ₁.len+1) := λ y,\n      if (y = θ₁.to_order_hom x) then x else (section_ θ₁).to_order_hom y,\n    have hα : ∀ y, θ₁.to_order_hom (α y) = y,\n    { intro y,\n      dsimp [α],\n      split_ifs with h₁,\n      { rw ← h₁, },\n      { have h₃ := congr_arg order_hom.to_fun (congr_arg simplex_category.hom.to_order_hom (is_split_epi.id θ₁)),\n        exact congr_fun h₃ y, }, },\n    let β : Δ₂ ⟶ Δ₁ := simplex_category.hom.mk ⟨α, begin\n      intros x₁ x₂,\n      contrapose,\n      intro h,\n      simp only [not_le] at h ⊢,\n      suffices : x₂ ≤ x₁,\n      { cases this.lt_or_eq with h₁ h₂,\n        { assumption, },\n        { exfalso,\n          simpa only [h₂, lt_self_iff_false] using h, }, },\n      simpa only [hα, order_hom.to_fun_eq_coe] using θ₁.to_order_hom.monotone' h.le,\n    end⟩,\n    refine ⟨⟨β, _⟩, _⟩,\n    { ext1, ext1, ext1 y,\n      apply hα, },\n    { simp only [simplex_category.hom.to_order_hom_mk, order_hom.coe_fun_mk,\n        ite_eq_left_iff, eq_self_iff_true, not_true, is_empty.forall_iff], }, },\n  rcases h₂ with ⟨s, hs⟩,\n  rw ← hs,\n  have eq := h s,\n  have h₃ := s.id',\n  simp only [auto_param_eq] at h₃,\n  rw ← h₃ at eq,\n  have h₄ : (θ₁ ≫ s.section_ ≫ θ₁).to_order_hom x =\n    (θ₁ ≫ s.section_ ≫ θ₂).to_order_hom x := by rw eq,\n  exact h₄,\nend\n\nlemma image_of_nondegenerate_simplex_uniqueness₃ (X : sSet)\n  {Δ Δ' : simplex_categoryᵒᵖ} (y : X.obj Δ')\n  (hy : y ∈ X.nondegenerate_simplices Δ')\n  (θ₁ : Δ' ⟶ Δ) (θ₂ : Δ' ⟶ Δ) (hθ₁ : epi θ₁.unop) (hθ₂ : epi θ₂.unop)\n  (eq : X.map θ₁ y = X.map θ₂ y) : θ₁ = θ₂ :=\nbegin\n  apply quiver.hom.unop_inj,\n  apply ext_epi_of_sections,\n  introI s,\n  let f := s.section_ ≫ θ₂.unop,\n  change f = 𝟙 _,\n  have eq₁ : y = X.map f.op y,\n  { dsimp only [f],\n    rw [op_comp, X.map_comp', quiver.hom.op_unop, ← eq, ← X.map_comp'],\n    change _ = X.map (θ₁.unop.op ≫ _) _,\n    rw [← op_comp, s.id, op_id, X.map_id, types_id_apply], },\n  let F := limits.image.mono_factorisation f,\n  rw [← F.fac, op_comp, X.map_comp'] at eq₁,\n  haveI : epi F.e := by { simp only [limits.as_factor_thru_image], apply_instance, },\n  haveI he := is_iso_of_nondegenerate_simplices ⟨y, hy⟩ F.e.op infer_instance _ eq₁,\n  haveI : is_iso F.e,\n  { change is_iso F.e.op.unop,\n    apply_instance, },\n  haveI : mono f,\n  { rw ← F.fac,\n    apply mono_comp, },\n  exact simplex_category.eq_id_of_mono f,\nend\n\n@[simp]\ndef splitting_map (X : sSet.{u}) (Δ : simplex_categoryᵒᵖ) :\n  sigma (simplicial_object.splitting.summand\n    (λ n, (X.nondegenerate_simplices (op [n]) : Type u)) Δ) → X.obj Δ :=\nλ s, X.map s.1.e.op s.2.1\n\nlemma splitting_map_bijective (X : sSet.{u}) (Δ : simplex_categoryᵒᵖ) :\n  function.bijective (X.splitting_map Δ) :=\nbegin\n  split,\n  { rintros ⟨⟨Δ₁, θ₁, hθ₁⟩, y₁, hy₁⟩ ⟨⟨Δ₂, θ₂, hθ₂⟩, y₂, hy₂⟩ eq,\n    induction Δ₁ using opposite.rec,\n    induction Δ₂ using opposite.rec,\n    have h₁ := X.image_of_nondegenerate_simplex_uniqueness₁ y₁ y₂ hy₁ hy₂ θ₁.op θ₂.op\n      hθ₁ hθ₂ eq,\n    simp only [simplex_category.mk_len, op_inj_iff, unop_op] at h₁,\n    subst h₁,\n    have h₂ := X.image_of_nondegenerate_simplex_uniqueness₂ y₁ y₂ hy₁ hy₂ θ₁.op θ₂.op\n      hθ₁ hθ₂ eq,\n    subst h₂,\n    have h₃ := X.image_of_nondegenerate_simplex_uniqueness₃ y₁ hy₁ θ₁.op θ₂.op hθ₁ hθ₂ eq,\n    have h₃' : θ₁ = θ₂ := by { apply quiver.hom.op_inj, exact h₃, },\n    subst h₃', },\n  { intro y,\n    rcases X.is_epi_image_of_nondegenerate_simplex y with ⟨Δ', θ, hθ, y, hy, eq⟩,\n    exact ⟨⟨⟨Δ', ⟨θ.unop, hθ⟩⟩, ⟨y, hy⟩⟩, eq.symm⟩, },\nend\n\n@[simps]\ndef splitting (X : sSet.{u}) : simplicial_object.splitting X :=\nbegin\n  let N : ℕ → Type u := λ n, X.nondegenerate_simplices (op [n]),\n  let ι : Π (n : ℕ), N n → X.obj (op [n]) := λ n, subtype.val,\n  exact\n  { N := N,\n    ι := ι,\n    map_is_iso' := λ Δ, begin\n      rw is_iso_iff_bijective,\n      let α := X.splitting_map Δ,\n      let β := simplicial_object.splitting.map X ι Δ,\n      let γ := concrete.coproduct_map (simplicial_object.splitting.summand N Δ),\n      have hγ : function.bijective γ := concrete.coproduct_map_bijective _,\n      change function.bijective β,\n      have eq : β ∘ γ = α,\n      { ext s,\n        rcases s with ⟨A, x⟩,\n        dsimp [α, β, γ],\n        have h := comp_apply (simplicial_object.splitting.ι_coprod N A)\n          (simplicial_object.splitting.map X ι Δ) x,\n        simp only [concrete_category.has_coe_to_fun_Type,\n          simplicial_object.splitting.ι_coprod, simplicial_object.splitting.map] at h,\n        erw [colimit.ι_desc, cofan.mk_ι_app] at h,\n        exact h.symm, },\n      rw [← function.bijective.of_comp_iff β hγ, eq],\n      apply splitting_map_bijective,\n    end, },\nend\n\nend sSet\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebraic_topology/simplicial_sets/skeleta.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.4649988329444617}}
{"text": "import data.set.basic -- hide\nopen set -- hide\n/- Tactic : apply\n\n## Summary\n\nIf `h : P → Q` is a hypothesis, and the goal is `⊢ Q` then\n`apply h` changes the goal to `⊢ P`. \n\n## Details\n\nIf you have a function `h : P → Q` and your goal is `⊢ Q`\nthen `apply h` changes the goal to `⊢ P`. The logic is\nsimple: if you are trying to create a term of type `Q`,\nbut `h` is a function which turns terms of type `P` into\nterms of type `Q`, then it will suffice to construct a\nterm of type `P`. A mathematician might say: \"we need\nto construct an element of $Q$, but we have a function $h:P\\to Q$\nso it suffices to construct an element of $P$\". Or alternatively\n\"we need to prove $Q$, but we have a proof $h$ that $P\\implies Q$\nso it suffices to prove $P$\".\n\n-/\n\n/-\nIn this level we introduce the new tactic `apply`. Look at what it does and try to solve it!\n-/\n\n/- Hint : Click here for a hint, in case you get stuck.\nStart with an `intro`, then try to `apply` the right hypothesis.\n-/\n\nvariables {X Y : Type} -- hide\n\n/- Lemma : no-side-bar\nIf A, B and C are sets and x ∈ A, and we know that x ∈ A → x ∈ B and that x ∈ B → x ∈ C, then\nwe can deduce that x ∈ C.\n-/\nlemma subset_transitive_basic (A B C : set X) (x : X) (hAB : x ∈ A → x ∈ B) (hBC : x ∈ B → x ∈ C) :\n  x ∈ A → x ∈ C :=\nbegin\n  intro h,\n  apply hBC,\n  apply hAB,\n  exact h,\n\n  \nend\n\n", "meta": {"author": "mmasdeu", "repo": "topologygame", "sha": "0a1b868031919a5555e7b99efca66ece2f546ec7", "save_path": "github-repos/lean/mmasdeu-topologygame", "path": "github-repos/lean/mmasdeu-topologygame/topologygame-0a1b868031919a5555e7b99efca66ece2f546ec7/src/set_theory_world/level06.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7217432062975978, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4649651037928573}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad, Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.control.functor.multivariate\nimport Mathlib.data.pfunctor.univariate.default\nimport Mathlib.data.sigma.default\nimport Mathlib.PostPort\n\nuniverses u l u_1 \n\nnamespace Mathlib\n\n/-!\n# Multivariate polynomial functors.\n\nMultivariate polynomial functors are used for defining M-types and W-types.\nThey map a type vector `α` to the type `Σ a : A, B a ⟹ α`, with `A : Type` and\n`B : A → typevec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `α` are positive.\n-/\n\n/--\nmultivariate polynomial functors\n-/\nstructure mvpfunctor (n : ℕ) \nwhere\n  A : Type u\n  B : A → typevec n\n\nnamespace mvpfunctor\n\n\n/-- Applying `P` to an object of `Type` -/\ndef obj {n : ℕ} (P : mvpfunctor n) (α : typevec n) :=\n  sigma fun (a : A P) => typevec.arrow (B P a) α\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map {n : ℕ} (P : mvpfunctor n) {α : typevec n} {β : typevec n} (f : typevec.arrow α β) : obj P α → obj P β :=\n  fun (_x : obj P α) => sorry\n\nprotected instance inhabited {n : ℕ} : Inhabited (mvpfunctor n) :=\n  { default := mk Inhabited.default fun (_x : Inhabited.default) => Inhabited.default }\n\nprotected instance obj.inhabited {n : ℕ} (P : mvpfunctor n) {α : typevec n} [Inhabited (A P)] [(i : fin2 n) → Inhabited (α i)] : Inhabited (obj P α) :=\n  { default := sigma.mk Inhabited.default fun (_x : fin2 n) (_x_1 : B P Inhabited.default _x) => Inhabited.default }\n\nprotected instance obj.mvfunctor {n : ℕ} (P : mvpfunctor n) : mvfunctor (obj P) :=\n  mvfunctor.mk (map P)\n\ntheorem map_eq {n : ℕ} (P : mvpfunctor n) {α : typevec n} {β : typevec n} (g : typevec.arrow α β) (a : A P) (f : typevec.arrow (B P a) α) : mvfunctor.map g (sigma.mk a f) = sigma.mk a (typevec.comp g f) :=\n  rfl\n\ntheorem id_map {n : ℕ} (P : mvpfunctor n) {α : typevec n} (x : obj P α) : mvfunctor.map typevec.id x = x :=\n  sigma.cases_on x\n    fun (x_fst : A P) (x_snd : typevec.arrow (B P x_fst) α) =>\n      idRhs (mvfunctor.map typevec.id (sigma.mk x_fst x_snd) = mvfunctor.map typevec.id (sigma.mk x_fst x_snd)) rfl\n\ntheorem comp_map {n : ℕ} (P : mvpfunctor n) {α : typevec n} {β : typevec n} {γ : typevec n} (f : typevec.arrow α β) (g : typevec.arrow β γ) (x : obj P α) : mvfunctor.map (typevec.comp g f) x = mvfunctor.map g (mvfunctor.map f x) := sorry\n\nprotected instance obj.is_lawful_mvfunctor {n : ℕ} (P : mvpfunctor n) : is_lawful_mvfunctor (obj P) :=\n  is_lawful_mvfunctor.mk (id_map P) (comp_map P)\n\n/-- Constant functor where the input object does not affect the output -/\ndef const (n : ℕ) (A : Type u) : mvpfunctor n :=\n  mk A fun (a : A) (i : fin2 n) => pempty\n\n/-- Constructor for the constant functor -/\ndef const.mk (n : ℕ) {A : Type u} (x : A) {α : typevec n} : obj (const n A) α :=\n  sigma.mk x fun (i : fin2 n) (a : B (const n A) x i) => pempty.elim a\n\n/-- Destructor for the constant functor -/\ndef const.get {n : ℕ} {A : Type u} {α : typevec n} (x : obj (const n A) α) : A :=\n  sigma.fst x\n\n@[simp] theorem const.get_map {n : ℕ} {A : Type u} {α : typevec n} {β : typevec n} (f : typevec.arrow α β) (x : obj (const n A) α) : const.get (mvfunctor.map f x) = const.get x :=\n  sigma.cases_on x\n    fun (x_fst : A (const n A)) (x_snd : typevec.arrow (B (const n A) x_fst) α) =>\n      Eq.refl (const.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem const.get_mk {n : ℕ} {A : Type u} {α : typevec n} (x : A) : const.get (const.mk n x) = x :=\n  Eq.refl (const.get (const.mk n x))\n\n@[simp] theorem const.mk_get {n : ℕ} {A : Type u} {α : typevec n} (x : obj (const n A) α) : const.mk n (const.get x) = x := sorry\n\n/-- Functor composition on polynomial functors -/\ndef comp {n : ℕ} {m : ℕ} (P : mvpfunctor n) (Q : fin2 n → mvpfunctor m) : mvpfunctor m :=\n  mk (sigma fun (a₂ : A P) => (i : fin2 n) → B P a₂ i → A (Q i))\n    fun (a : sigma fun (a₂ : A P) => (i : fin2 n) → B P a₂ i → A (Q i)) (i : fin2 m) =>\n      sigma fun (j : fin2 n) => sigma fun (b : B P (sigma.fst a) j) => B (Q j) (sigma.snd a j b) i\n\n/-- Constructor for functor composition -/\ndef comp.mk {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m} (x : obj P fun (i : fin2 n) => obj (Q i) α) : obj (comp P Q) α :=\n  sigma.mk (sigma.mk (sigma.fst x) fun (i : fin2 n) (a : B P (sigma.fst x) i) => sigma.fst (sigma.snd x i a))\n    fun (i : fin2 m)\n      (a :\n      B (comp P Q) (sigma.mk (sigma.fst x) fun (i : fin2 n) (a : B P (sigma.fst x) i) => sigma.fst (sigma.snd x i a))\n        i) =>\n      sigma.snd (sigma.snd x (sigma.fst a) (sigma.fst (sigma.snd a))) i (sigma.snd (sigma.snd a))\n\n/-- Destructor for functor composition -/\ndef comp.get {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m} (x : obj (comp P Q) α) : obj P fun (i : fin2 n) => obj (Q i) α :=\n  sigma.mk (sigma.fst (sigma.fst x))\n    fun (i : fin2 n) (a : B P (sigma.fst (sigma.fst x)) i) =>\n      sigma.mk (sigma.snd (sigma.fst x) i a)\n        fun (j : fin2 m) (b : B (Q i) (sigma.snd (sigma.fst x) i a) j) => sigma.snd x j (sigma.mk i (sigma.mk a b))\n\ntheorem comp.get_map {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m} {β : typevec m} (f : typevec.arrow α β) (x : obj (comp P Q) α) : comp.get (mvfunctor.map f x) = mvfunctor.map (fun (i : fin2 n) (x : obj (Q i) α) => mvfunctor.map f x) (comp.get x) :=\n  sigma.cases_on x\n    fun (x_fst : A (comp P Q)) (x_snd : typevec.arrow (B (comp P Q) x_fst) α) =>\n      Eq.refl (comp.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem comp.get_mk {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m} (x : obj P fun (i : fin2 n) => obj (Q i) α) : comp.get (comp.mk x) = x := sorry\n\n@[simp] theorem comp.mk_get {n : ℕ} {m : ℕ} {P : mvpfunctor n} {Q : fin2 n → mvpfunctor m} {α : typevec m} (x : obj (comp P Q) α) : comp.mk (comp.get x) = x := sorry\n\n/-\nlifting predicates and relations\n-/\n\ntheorem liftp_iff {n : ℕ} {P : mvpfunctor n} {α : typevec n} (p : {i : fin2 n} → α i → Prop) (x : obj P α) : mvfunctor.liftp p x ↔\n  ∃ (a : A P), ∃ (f : typevec.arrow (B P a) α), x = sigma.mk a f ∧ ∀ (i : fin2 n) (j : B P a i), p (f i j) := sorry\n\ntheorem liftp_iff' {n : ℕ} {P : mvpfunctor n} {α : typevec n} (p : {i : fin2 n} → α i → Prop) (a : A P) (f : typevec.arrow (B P a) α) : mvfunctor.liftp p (sigma.mk a f) ↔ ∀ (i : fin2 n) (x : B P a i), p (f i x) := sorry\n\ntheorem liftr_iff {n : ℕ} {P : mvpfunctor n} {α : typevec n} (r : {i : fin2 n} → α i → α i → Prop) (x : obj P α) (y : obj P α) : mvfunctor.liftr r x y ↔\n  ∃ (a : A P),\n    ∃ (f₀ : typevec.arrow (B P a) α),\n      ∃ (f₁ : typevec.arrow (B P a) α),\n        x = sigma.mk a f₀ ∧ y = sigma.mk a f₁ ∧ ∀ (i : fin2 n) (j : B P a i), r (f₀ i j) (f₁ i j) := sorry\n\ntheorem supp_eq {n : ℕ} {P : mvpfunctor n} {α : typevec n} (a : A P) (f : typevec.arrow (B P a) α) (i : fin2 n) : mvfunctor.supp (sigma.mk a f) i = f i '' set.univ := sorry\n\nend mvpfunctor\n\n\n/-\nDecomposing an n+1-ary pfunctor.\n-/\n\nnamespace mvpfunctor\n\n\n/-- Split polynomial functor, get a n-ary functor\nfrom a `n+1`-ary functor -/\ndef drop {n : ℕ} (P : mvpfunctor (n + 1)) : mvpfunctor n :=\n  mk (A P) fun (a : A P) => typevec.drop (B P a)\n\n/-- Split polynomial functor, get a univariate functor\nfrom a `n+1`-ary functor -/\ndef last {n : ℕ} (P : mvpfunctor (n + 1)) : pfunctor :=\n  pfunctor.mk (A P) fun (a : A P) => typevec.last (B P a)\n\n/-- append arrows of a polynomial functor application -/\ndef append_contents {n : ℕ} (P : mvpfunctor (n + 1)) {α : typevec n} {β : Type u_1} {a : A P} (f' : typevec.arrow (B (drop P) a) α) (f : pfunctor.B (last P) a → β) : typevec.arrow (B P a) (α ::: β) :=\n  typevec.split_fun f' f\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/pfunctor/multivariate/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4649651016445146}}
{"text": "--\n\n-- New notation that overlaps with existing notation\nsyntax (name := myPair) (priority := high) \"(\" term \",\" term \")\" : term\n\nmacro_rules (kind := myPair)\n| `(($a, $b)) => `([$a, $b])\n\n#eval (1, 2) -- not ambiguous since myPair parser has higher priority\n\ntheorem ex1 : (1, 2) = [1, 2] :=\nrfl\n\n-- Define macro for expanding the builtin triple notation\n-- Macros bypass builtin elaboration functions\nmacro_rules\n| `(($a, $b, $c)) => `($a + $b + $c)\n\n#eval (1, 2, 3)\n\nsyntax (name := mySingleton) \"[\" term \"]\" : term\n\nmacro_rules (kind := mySingleton)\n| `([$a]) => `(2 * $a)\n\n#check [1] -- ambiguous it can be `mySingleton` or the singleton list\n\n\nsyntax (priority := 100) \"(\" term \",\" term \", \" term \")\" : term -- priority without a kind\n\nmacro_rules\n| `(($a, $b, $c)) => `([$a, $b, $c])\n\n#eval (1,2,3)\n\ntheorem ex2 : (1, 2, 3) = [1, 2, 3] :=\nrfl\n\ntheorem ex3 : (1, 2, 3, 4) = Prod.mk 1 (Prod.mk 2 (Prod.mk 3 4)) :=\nrfl\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/tests/lean/parserPrio.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.4649650840729102}}
{"text": "import IIT.PropInversion\nimport IIT.ClarifyIndices\n\n/-\niit A : Type\n| ι   : (n : Nat) → A\n| mid : (x y : A) → (p : lt' x y) → A\n\niit lt' : (x : A) → (y : A) → Type\n| ι'    : (m n : Nat) → (p : m < n) → lt' (A.ι m) (A.ι n)\n| mid_l : (x y : A) → (p : lt' x y) → lt' x (A.mid x y p)\n| mid_r : (x y : A) → (p : lt' x y) → lt' (A.mid x y p) y\n-/\n\nmutual\ninductive Aₑ : Type 1\n| ιₑ   : Nat → Aₑ\n| midₑ : (x y : Aₑ) → (p : lt'ₑ) → Aₑ\n\n\ninductive lt'ₑ : Type 1\n| ι'ₑ : (m n : Nat) → (p : m < n) → lt'ₑ\n| mid_lₑ : (x y : Aₑ) → (p : lt'ₑ) → lt'ₑ\n| mid_rₑ : (x y : Aₑ) → (p : lt'ₑ) → lt'ₑ\nend\n\nopen Aₑ lt'ₑ\n\nmutual\ninductive A_w : Aₑ → Prop\n| ι_w : ∀ n, A_w (ιₑ n)\n| mid_w : ∀ {x}, A_w x → ∀ {y}, A_w y → ∀ {p}, lt'_w x y p → A_w (midₑ x y p)\n\ninductive lt'_w : Aₑ → Aₑ → lt'ₑ → Prop\n| ι'_w : ∀ m n p, lt'_w (ιₑ m) (ιₑ n) (ι'ₑ m n p)\n| mid_l_w : ∀ {x}, A_w x → ∀ {y}, A_w y → ∀ {p}, lt'_w x y p \n    → lt'_w x (midₑ x y p) (mid_lₑ x y p)\n| mid_r_w : ∀ {x}, A_w x → ∀ {y}, A_w y → ∀ {p}, lt'_w x y p \n    → lt'_w (midₑ x y p) y (mid_rₑ x y p)\nend\n\nopen A_w lt'_w\n\ndef A := PSigma A_w\ndef lt' := fun (x y : A) => PSigma (lt'_w x.1 y.1)\n\ndef ι : Nat → A := fun n => ⟨ιₑ n, ι_w n⟩\ndef mid (x y : A) (p : lt' x y) : A := ⟨midₑ x.1 y.1 p.1, mid_w x.2 y.2 p.2⟩ \ndef ι' (m n : Nat) (p : m < n) : lt' (ι m) (ι n) := ⟨ι'ₑ m n p, ι'_w m n p⟩\ndef mid_l (x y : A) (p : lt' x y) : lt' x (mid x y p) :=\n  ⟨mid_lₑ x.1 y.1 p.1, mid_l_w x.2 y.2 p.2⟩\ndef mid_r (x y : A) (p : lt' x y) : lt' (mid x y p) y :=\n  ⟨mid_rₑ x.1 y.1 p.1, mid_r_w x.2 y.2 p.2⟩\n\nsection\nvariable\n  (Aₘ     : A → Type 1)\n  (lt'ₘ   : ∀ {x}, Aₘ x → ∀ {y}, Aₘ y → lt' x y → Type 1)\n  (ιₘ     : ∀ n, Aₘ (ι n))\n  (midₘ   : ∀ {x}, (xₘ : Aₘ x) → ∀ {y}, (yₘ : Aₘ y) → ∀ {p}, (pₘ : lt'ₘ xₘ yₘ p) → Aₘ (mid x y p))\n  (ι'ₘ    : ∀ m n p, lt'ₘ (ιₘ m) (ιₘ n) (ι' m n p))\n  (mid_lₘ : ∀ {x}, (xₘ : Aₘ x) → ∀ {y}, (yₘ : Aₘ y) → ∀ {p}, (pₘ : lt'ₘ xₘ yₘ p)\n    → lt'ₘ xₘ (midₘ xₘ yₘ pₘ) (mid_l x y p))\n  (mid_rₘ : ∀ {x}, (xₘ : Aₘ x) → ∀ {y}, (yₘ : Aₘ y) → ∀ {p}, (pₘ : lt'ₘ xₘ yₘ p)\n    → lt'ₘ (midₘ xₘ yₘ pₘ) yₘ (mid_r x y p))\n\nmutual\ninductive Aᵣ : (x : A) → Aₘ x → Type 1\n| ιᵣ : ∀ n, Aᵣ (ι n) (ιₘ n)\n| midᵣ : ∀ {x} {xₘ : Aₘ x}, Aᵣ x xₘ →\n           ∀ {y} {yₘ : Aₘ y}, Aᵣ y yₘ →\n             ∀ {p} {pₘ : lt'ₘ xₘ yₘ p}, lt'ᵣ xₘ yₘ p pₘ → Aᵣ (mid x y p) (midₘ xₘ yₘ pₘ)\n\ninductive lt'ᵣ : {x : A} → (xₘ : Aₘ x) → {y : A} → (yₘ : Aₘ y) → (p : lt' x y) → lt'ₘ xₘ yₘ p → Type 1\n| ι'ᵣ : ∀ m n p, lt'ᵣ (ιₘ m) (ιₘ n) (ι' m n p) (ι'ₘ m n p)\n| mid_lᵣ : ∀ {x} {xₘ : Aₘ x}, Aᵣ x xₘ →\n             ∀ {y} {yₘ : Aₘ y}, Aᵣ y yₘ →\n               ∀ {p} {pₘ : lt'ₘ xₘ yₘ p}, lt'ᵣ xₘ yₘ p pₘ →\n                 lt'ᵣ xₘ (midₘ xₘ yₘ pₘ) (mid_l x y p) (mid_lₘ xₘ yₘ pₘ)\n| mid_rᵣ : ∀ {x} {xₘ : Aₘ x}, Aᵣ x xₘ →\n             ∀ {y} {yₘ : Aₘ y}, Aᵣ y yₘ →\n               ∀ {p} {pₘ : lt'ₘ xₘ yₘ p}, lt'ᵣ xₘ yₘ p pₘ →\n                 lt'ᵣ (midₘ xₘ yₘ pₘ) yₘ (mid_r x y p) (mid_rₘ xₘ yₘ pₘ)\nend\n\nopen Aᵣ lt'ᵣ\n\nstructure PSigmaUnique {α : Type _} (β : α → Type _) :=\n  fst : α\n  snd : β fst\n  unique : ∀ {a}, β a → a = fst\n\nnoncomputable def A_tot (x : A) : PSigmaUnique (Aᵣ Aₘ lt'ₘ ιₘ midₘ ι'ₘ mid_lₘ mid_rₘ x) := by\n  cases x with | mk xₑ x_w => ?_\n  apply Aₑ.recOn xₑ\n    (motive_1 := fun xₑ => ∀ x_w, PSigmaUnique (Aᵣ Aₘ lt'ₘ ιₘ midₘ ι'ₘ mid_lₘ mid_rₘ ⟨xₑ, x_w⟩))\n    (motive_2 := fun pₑ => ∀ {x xₘ} (xᵣ : Aᵣ Aₘ lt'ₘ ιₘ midₘ ι'ₘ mid_lₘ mid_rₘ x xₘ)\n                  {y yₘ} (yᵣ : Aᵣ Aₘ lt'ₘ ιₘ midₘ ι'ₘ mid_lₘ mid_rₘ y yₘ)\n                   p_w, PSigmaUnique (lt'ᵣ Aₘ lt'ₘ ιₘ midₘ ι'ₘ mid_lₘ mid_rₘ xₘ yₘ ⟨pₑ, p_w⟩))\n  skip\n  · intro n _\n    exact ⟨ιₘ n, ιᵣ n, fun {xₘ} xᵣ => by cases xᵣ; rfl⟩\n  · intro x y p x_ih y_ih p_ih ctor_w\n    inversion ctor_w with x_w y_w p_w\n    cases x_ih x_w with | mk xₘ xᵣ x_unique => ?_\n    cases y_ih y_w with | mk yₘ yᵣ y_unique => ?_\n    cases p_ih xᵣ yᵣ p_w with | mk pₘ pᵣ p_unique => ?_\n    exact ⟨midₘ xₘ yₘ pₘ, midᵣ xᵣ yᵣ pᵣ, fun {zₘ} zᵣ => by \n      cases zᵣ with | @midᵣ x' x'ₘ x'ᵣ y' y'ₘ y'ᵣ p' p'ₘ p'ᵣ => ?_\n      cases x_unique x'ᵣ\n      cases y_unique y'ᵣ\n      cases p_unique p'ᵣ\n      rfl ⟩\n  · intro m n p x xₘ xᵣ y yₘ yᵣ ctor_w\n    cases x with | mk xₑ x_w => ?_\n    cases y with | mk yₑ y_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    cases xᵣ\n    cases yᵣ\n    exact ⟨ι'ₘ m n p, ι'ᵣ m n p, fun {qₘ} qᵣ => by\n      cases qᵣ\n      rfl ⟩\n  · intro yₑ zₑ pₑ y_ih z_ih p_ih x' x'ₘ x'ᵣ y' y'ₘ y'ᵣ ctor_w\n    cases x' with | mk x'ₑ x'_w => ?_\n    cases y' with | mk y'ₑ y'_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    cases y'ᵣ with | @midᵣ x'' x''ₘ x''ᵣ y'' y''ₘ y''ᵣ p'' p''ₘ p''ᵣ => ?_\n    simp only at ctor_w\n    cases x'' with | mk x''ₑ x''_w => ?_\n    cases y'' with | mk y''ₑ y''_w => ?_\n    cases p'' with | mk p''ₑ p''_w => ?_\n    clarifyIndices ctor_w\n    simp only at ctor_w\n    cases y_ih x''_w with | mk x'''ₘ x'''ᵣ x'''_unique => ?_\n    cases z_ih y''_w with | mk y'''ₘ y'''ᵣ y'''_unique => ?_\n    cases p_ih x'''ᵣ y'''ᵣ p''_w with | mk p'''ₘ p'''ᵣ p'''_unique => ?_\n    simp only at *\n    cases x'''_unique x'ᵣ\n    cases x'''_unique x''ᵣ\n    cases y'''_unique y''ᵣ\n    cases p'''_unique p''ᵣ\n    exact ⟨mid_lₘ _ _ _, mid_lᵣ x''ᵣ y''ᵣ p''ᵣ, fun {qₘ} qᵣ => by\n      match qᵣ with\n      | mid_lᵣ x'''ᵣ y'''ᵣ p'''ᵣ => skip ⟩\n  \n    \nnoncomputable def Ty_tot (Γ : Con) (A : Ty Γ) :\n  PSigma (Tyᵣ Conₘ Tyₘ nilₘ extₘ baseₘ piₘ (Con_tot Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ).1 A) := by\n  cases Γ with | mk Γₑ Γ_w => ?_\n  cases A with | mk Aₑ A_w => ?_\n  apply Tyₑ.recOn Aₑ\n    (motive_1 := fun Γₑ => ∀ Γ_w, PSigma (Conᵣ Conₘ Tyₘ nilₘ extₘ baseₘ piₘ ⟨Γₑ, Γ_w⟩))\n    (motive_2 := fun Aₑ => ∀ {Γ Γₘ} (Γᵣ : Conᵣ Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ Γₘ)\n                   A_w, PSigma (Tyᵣ Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γₘ ⟨Aₑ, A_w⟩))\n  · intro Γ_w\n    exact PSigma.mk nilₘ nilᵣ\n  · intro Δₑ Aₑ Δ_ih A_ih ctor_w\n    inversion ctor_w with Δ_w A_w\n    cases Δ_ih Δ_w with | mk Δₘ Δᵣ => ?_\n    cases A_ih Δᵣ A_w with | mk Aₘ Aᵣ => ?_\n    exact PSigma.mk (extₘ Δₘ Aₘ) (extᵣ Δᵣ Aᵣ)\n  · intro Γₑ Γ_ih Δ Δₘ Δᵣ ctor_w\n    cases Δ with | mk Δₑ Δ_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    exact PSigma.mk (baseₘ Δₘ) (baseᵣ Δᵣ)\n  · intro Δₑ Aₑ Bₑ Δ_ih A_ih B_ih Δ' Δ'ₘ Δ'ᵣ ctor_w\n    cases Δ' with | mk Δ'ₑ Δ_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    inversion ctor_w with Δ_w A_w B_w\n    cases A_ih Δ'ᵣ A_w with | mk Aₘ Aᵣ => ?_\n    cases B_ih (extᵣ Δ'ᵣ Aᵣ) B_w with | mk Bₘ Bᵣ => ?_ \n    exact PSigma.mk (piₘ Δ'ₘ Aₘ Bₘ) (piᵣ Δ'ᵣ Aᵣ Bᵣ)\n  · exact (Con_tot Conₘ Tyₘ nilₘ extₘ baseₘ piₘ ⟨Γₑ, Γ_w⟩).2\n\nnoncomputable def Con.rec (Γ : Con) : Conₘ Γ :=\n(Con_tot Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ).1\n\nnoncomputable def Ty.rec (Γ : Con) (A : Ty Γ) : Tyₘ (Con.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ) A :=\n(Ty_tot Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ A).1\n\ntheorem nil_beta : Con.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ nil = nilₘ :=\nrfl\n\ntheorem ext_beta (Γ : Con) (A : Ty Γ) :\n  Con.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ (ext Γ A) \n  = extₘ (Con.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ)\n    (Ty.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ A) :=\nrfl\n\ntheorem base_beta (Γ : Con) :\n  Ty.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ (base Γ)\n  = baseₘ (Con.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ) :=\nrfl\n\ntheorem pi_beta (Γ : Con) (A : Ty Γ) (B : Ty (ext Γ A)) :\n  Ty.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ (pi Γ A B)\n  = piₘ (Con.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ)\n      (Ty.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ Γ A)\n      (Ty.rec Conₘ Tyₘ nilₘ extₘ baseₘ piₘ (ext Γ A) B) :=\nrfl\n\nend", "meta": {"author": "javra", "repo": "iit", "sha": "44e3d082858cd143626f30960174ad3e42560016", "save_path": "github-repos/lean/javra-iit", "path": "github-repos/lean/javra-iit/iit-44e3d082858cd143626f30960174ad3e42560016/Manual/DenseCompletionNatLt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.4649542548521186}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.balanced\nimport category_theory.lifting_properties.basic\n\n/-!\n# Strong epimorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file, we define strong epimorphisms. A strong epimorphism is an epimorphism `f`\nwhich has the (unique) left lifting property with respect to monomorphisms. Similarly,\na strong monomorphisms in a monomorphism which has the (unique) right lifting property\nwith respect to epimorphisms.\n\n## Main results\n\nBesides the definition, we show that\n* the composition of two strong epimorphisms is a strong epimorphism,\n* if `f ≫ g` is a strong epimorphism, then so is `g`,\n* if `f` is both a strong epimorphism and a monomorphism, then it is an isomorphism\n\nWe also define classes `strong_mono_category` and `strong_epi_category` for categories in which\nevery monomorphism or epimorphism is strong, and deduce that these categories are balanced.\n\n## TODO\n\nShow that the dual of a strong epimorphism is a strong monomorphism, and vice versa.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 1*][borceux-vol1]\n-/\n\nuniverses v u\n\nnamespace category_theory\nvariables {C : Type u} [category.{v} C]\n\nvariables {P Q : C}\n\n/-- A strong epimorphism `f` is an epimorphism which has the left lifting property\nwith respect to monomorphisms. -/\nclass strong_epi (f : P ⟶ Q) : Prop :=\n(epi : epi f)\n(llp : ∀ ⦃X Y : C⦄ (z : X ⟶ Y) [mono z], has_lifting_property f z)\n\nlemma strong_epi.mk' {f : P ⟶ Q} [epi f]\n  (hf : ∀ (X Y : C) (z : X ⟶ Y) (hz : mono z) (u : P ⟶ X) (v : Q ⟶ Y)\n    (sq : comm_sq u f z v), sq.has_lift) : strong_epi f :=\n{ epi := infer_instance,\n  llp := λ X Y z hz, ⟨λ u v sq, hf X Y z hz u v sq⟩, }\n\n/-- A strong monomorphism `f` is a monomorphism which has the right lifting property\nwith respect to epimorphisms. -/\nclass strong_mono (f : P ⟶ Q) : Prop :=\n(mono : mono f)\n(rlp : ∀ ⦃X Y : C⦄ (z : X ⟶ Y) [epi z], has_lifting_property z f)\n\nlemma strong_mono.mk' {f : P ⟶ Q} [mono f]\n  (hf : ∀ (X Y : C) (z : X ⟶ Y) (hz : epi z) (u : X ⟶ P) (v : Y ⟶ Q)\n    (sq : comm_sq u z f v), sq.has_lift) : strong_mono f :=\n{ mono := infer_instance,\n  rlp := λ X Y z hz, ⟨λ u v sq, hf X Y z hz u v sq⟩, }\n\nattribute [instance, priority 100] strong_epi.llp\nattribute [instance, priority 100] strong_mono.rlp\n\n@[priority 100]\ninstance epi_of_strong_epi (f : P ⟶ Q) [strong_epi f] : epi f := strong_epi.epi\n\n@[priority 100]\ninstance mono_of_strong_mono (f : P ⟶ Q) [strong_mono f] : mono f := strong_mono.mono\n\nsection\nvariables {R : C} (f : P ⟶ Q) (g : Q ⟶ R)\n\n/-- The composition of two strong epimorphisms is a strong epimorphism. -/\nlemma strong_epi_comp [strong_epi f] [strong_epi g] : strong_epi (f ≫ g) :=\n{ epi := epi_comp _ _,\n  llp := by { introsI, apply_instance, }, }\n\n/-- The composition of two strong monomorphisms is a strong monomorphism. -/\nlemma strong_mono_comp [strong_mono f] [strong_mono g] : strong_mono (f ≫ g) :=\n{ mono := mono_comp _ _,\n  rlp := by { introsI, apply_instance, }, }\n\n/-- If `f ≫ g` is a strong epimorphism, then so is `g`. -/\nlemma strong_epi_of_strong_epi [strong_epi (f ≫ g)] : strong_epi g :=\n{ epi := epi_of_epi f g,\n  llp := begin\n    introsI,\n    constructor,\n    intros u v sq,\n    have h₀ : (f ≫ u) ≫ z = (f ≫ g) ≫ v, by simp only [category.assoc, sq.w],\n    exact comm_sq.has_lift.mk' ⟨(comm_sq.mk h₀).lift,\n      by simp only [← cancel_mono z, category.assoc, comm_sq.fac_right, sq.w], by simp⟩,\n  end, }\n\n/-- If `f ≫ g` is a strong monomorphism, then so is `f`. -/\n\n\n/-- An isomorphism is in particular a strong epimorphism. -/\n@[priority 100] instance strong_epi_of_is_iso [is_iso f] : strong_epi f :=\n{ epi := by apply_instance,\n  llp := λ X Y z hz, has_lifting_property.of_left_iso _ _, }\n\n/-- An isomorphism is in particular a strong monomorphism. -/\n@[priority 100] instance strong_mono_of_is_iso [is_iso f] : strong_mono f :=\n{ mono := by apply_instance,\n  rlp := λ X Y z hz, has_lifting_property.of_right_iso _ _, }\n\nlemma strong_epi.of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'}\n  (e : arrow.mk f ≅ arrow.mk g) [h : strong_epi f] : strong_epi g :=\n{ epi := begin\n    rw arrow.iso_w' e,\n    haveI := epi_comp f e.hom.right,\n    apply epi_comp,\n  end,\n  llp := λ X Y z, by { introI, apply has_lifting_property.of_arrow_iso_left e z, }, }\n\nlemma strong_mono.of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'}\n  (e : arrow.mk f ≅ arrow.mk g) [h : strong_mono f] : strong_mono g :=\n{ mono := begin\n    rw arrow.iso_w' e,\n    haveI := mono_comp f e.hom.right,\n    apply mono_comp,\n  end,\n  rlp := λ X Y z, by { introI, apply has_lifting_property.of_arrow_iso_right z e, }, }\n\nlemma strong_epi.iff_of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'}\n  (e : arrow.mk f ≅ arrow.mk g) : strong_epi f ↔ strong_epi g :=\nby { split; introI, exacts [strong_epi.of_arrow_iso e, strong_epi.of_arrow_iso e.symm], }\n\nlemma strong_mono.iff_of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'}\n  (e : arrow.mk f ≅ arrow.mk g) : strong_mono f ↔ strong_mono g :=\nby { split; introI, exacts [strong_mono.of_arrow_iso e, strong_mono.of_arrow_iso e.symm], }\n\nend\n\n/-- A strong epimorphism that is a monomorphism is an isomorphism. -/\nlemma is_iso_of_mono_of_strong_epi (f : P ⟶ Q) [mono f] [strong_epi f] : is_iso f :=\n⟨⟨(comm_sq.mk (show 𝟙 P ≫ f = f ≫ 𝟙 Q, by simp)).lift, by tidy⟩⟩\n\n/-- A strong monomorphism that is an epimorphism is an isomorphism. -/\nlemma is_iso_of_epi_of_strong_mono (f : P ⟶ Q) [epi f] [strong_mono f] : is_iso f :=\n⟨⟨(comm_sq.mk (show 𝟙 P ≫ f = f ≫ 𝟙 Q, by simp)).lift, by tidy⟩⟩\n\nsection\nvariables (C)\n\n/-- A strong epi category is a category in which every epimorphism is strong. -/\nclass strong_epi_category : Prop :=\n(strong_epi_of_epi : ∀ {X Y : C} (f : X ⟶ Y) [epi f], strong_epi f)\n\n/-- A strong mono category is a category in which every monomorphism is strong. -/\nclass strong_mono_category : Prop :=\n(strong_mono_of_mono : ∀ {X Y : C} (f : X ⟶ Y) [mono f], strong_mono f)\n\nend\n\nlemma strong_epi_of_epi [strong_epi_category C] (f : P ⟶ Q) [epi f] : strong_epi f :=\nstrong_epi_category.strong_epi_of_epi _\n\nlemma strong_mono_of_mono [strong_mono_category C] (f : P ⟶ Q) [mono f] : strong_mono f :=\nstrong_mono_category.strong_mono_of_mono _\n\nsection\nlocal attribute [instance] strong_epi_of_epi\n\n@[priority 100]\ninstance balanced_of_strong_epi_category [strong_epi_category C] : balanced C :=\n{ is_iso_of_mono_of_epi := λ _ _ _ _ _, by exactI is_iso_of_mono_of_strong_epi _ }\n\nend\n\nsection\nlocal attribute [instance] strong_mono_of_mono\n\n@[priority 100]\ninstance balanced_of_strong_mono_category [strong_mono_category C] : balanced C :=\n{ is_iso_of_mono_of_epi := λ _ _ _ _ _, by exactI is_iso_of_epi_of_strong_mono _ }\n\nend\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/shapes/strong_epi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833945721304, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4648959366984469}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel, Johan Commelin, Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.abelian.basic\n! leanprover-community/mathlib commit 8c75ef3517d4106e89fe524e6281d0b0545f47fc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Constructions.Pullbacks\nimport Mathbin.CategoryTheory.Preadditive.Biproducts\nimport Mathbin.CategoryTheory.Limits.Shapes.Images\nimport Mathbin.CategoryTheory.Limits.Constructions.LimitsOfProductsAndEqualizers\nimport Mathbin.CategoryTheory.Abelian.NonPreadditive\n\n/-!\n# Abelian categories\n\nThis file contains the definition and basic properties of abelian categories.\n\nThere are many definitions of abelian category. Our definition is as follows:\nA category is called abelian if it is preadditive,\nhas a finite products, kernels and cokernels,\nand if every monomorphism and epimorphism is normal.\n\nIt should be noted that if we also assume coproducts, then preadditivity is\nactually a consequence of the other properties, as we show in\n`non_preadditive_abelian.lean`. However, this fact is of little practical\nrelevance, since essentially all interesting abelian categories come with a\npreadditive structure. In this way, by requiring preadditivity, we allow the\nuser to pass in the \"native\" preadditive structure for the specific category they are\nworking with.\n\n## Main definitions\n\n* `abelian` is the type class indicating that a category is abelian. It extends `preadditive`.\n* `abelian.image f` is `kernel (cokernel.π f)`, and\n* `abelian.coimage f` is `cokernel (kernel.ι f)`.\n\n## Main results\n\n* In an abelian category, mono + epi = iso.\n* If `f : X ⟶ Y`, then the map `factor_thru_image f : X ⟶ image f` is an epimorphism, and the map\n  `factor_thru_coimage f : coimage f ⟶ Y` is a monomorphism.\n* Factoring through the image and coimage is a strong epi-mono factorisation. This means that\n  * every abelian category has images. We provide the isomorphism\n    `image_iso_image : abelian.image f ≅ limits.image f`.\n  * the canonical morphism `coimage_image_comparison : coimage f ⟶ image f`\n    is an isomorphism.\n* We provide the alternate characterisation of an abelian category as a category with\n  (co)kernels and finite products, and in which the canonical coimage-image comparison morphism\n  is always an isomorphism.\n* Every epimorphism is a cokernel of its kernel. Every monomorphism is a kernel of its cokernel.\n* The pullback of an epimorphism is an epimorphism. The pushout of a monomorphism is a monomorphism.\n  (This is not to be confused with the fact that the pullback of a monomorphism is a monomorphism,\n  which is true in any category).\n\n## Implementation notes\n\nThe typeclass `abelian` does not extend `non_preadditive_abelian`,\nto avoid having to deal with comparing the two `has_zero_morphisms` instances\n(one from `preadditive` in `abelian`, and the other a field of `non_preadditive_abelian`).\nAs a consequence, at the beginning of this file we trivially build\na `non_preadditive_abelian` instance from an `abelian` instance,\nand use this to restate a number of theorems,\nin each case just reusing the proof from `non_preadditive_abelian.lean`.\n\nWe don't show this yet, but abelian categories are finitely complete and finitely cocomplete.\nHowever, the limits we can construct at this level of generality will most likely be less nice than\nthe ones that can be created in specific applications. For this reason, we adopt the following\nconvention:\n\n* If the statement of a theorem involves limits, the existence of these limits should be made an\n  explicit typeclass parameter.\n* If a limit only appears in a proof, but not in the statement of a theorem, the limit should not\n  be a typeclass parameter, but instead be created using `abelian.has_pullbacks` or a similar\n  definition.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]\n* [P. Aluffi, *Algebra: Chapter 0*][aluffi2016]\n\n-/\n\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Preadditive\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nnamespace CategoryTheory\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable (C)\n\n/-- A (preadditive) category `C` is called abelian if it has all finite products,\nall kernels and cokernels, and if every monomorphism is the kernel of some morphism\nand every epimorphism is the cokernel of some morphism.\n\n(This definition implies the existence of zero objects:\nfinite products give a terminal object, and in a preadditive category\nany terminal object is a zero object.)\n-/\nclass Abelian extends Preadditive C, NormalMonoCategory C, NormalEpiCategory C where\n  [HasFiniteProducts : HasFiniteProducts C]\n  [HasKernels : HasKernels C]\n  [HasCokernels : HasCokernels C]\n#align category_theory.abelian CategoryTheory.Abelian\n\nattribute [instance] abelian.has_finite_products\n\nattribute [instance] abelian.has_kernels abelian.has_cokernels\n\nend CategoryTheory\n\nopen CategoryTheory\n\n/-!\nWe begin by providing an alternative constructor:\na preadditive category with kernels, cokernels, and finite products,\nin which the coimage-image comparison morphism is always an isomorphism,\nis an abelian category.\n-/\n\n\nnamespace CategoryTheory.Abelian\n\nvariable {C : Type u} [Category.{v} C] [Preadditive C]\n\nvariable [Limits.HasKernels C] [Limits.HasCokernels C]\n\nnamespace OfCoimageImageComparisonIsIso\n\n/-- The factorisation of a morphism through its abelian image. -/\n@[simps]\ndef imageMonoFactorisation {X Y : C} (f : X ⟶ Y) : MonoFactorisation f\n    where\n  i := Abelian.image f\n  m := kernel.ι _\n  m_mono := inferInstance\n  e := kernel.lift _ f (cokernel.condition _)\n  fac := kernel.lift_ι _ _ _\n#align category_theory.abelian.of_coimage_image_comparison_is_iso.image_mono_factorisation CategoryTheory.Abelian.OfCoimageImageComparisonIsIso.imageMonoFactorisation\n\ntheorem imageMonoFactorisation_e' {X Y : C} (f : X ⟶ Y) :\n    (imageMonoFactorisation f).e = cokernel.π _ ≫ Abelian.coimageImageComparison f :=\n  by\n  ext\n  simp only [abelian.coimage_image_comparison, image_mono_factorisation_e, category.assoc,\n    cokernel.π_desc_assoc]\n#align category_theory.abelian.of_coimage_image_comparison_is_iso.image_mono_factorisation_e' CategoryTheory.Abelian.OfCoimageImageComparisonIsIso.imageMonoFactorisation_e'\n\n/-- If the coimage-image comparison morphism for a morphism `f` is an isomorphism,\nwe obtain an image factorisation of `f`. -/\ndef imageFactorisation {X Y : C} (f : X ⟶ Y) [IsIso (Abelian.coimageImageComparison f)] :\n    ImageFactorisation f where\n  f := imageMonoFactorisation f\n  IsImage :=\n    { lift := fun F => inv (Abelian.coimageImageComparison f) ≫ cokernel.desc _ F.e F.kernel_ι_comp\n      lift_fac := fun F =>\n        by\n        simp only [image_mono_factorisation_m, is_iso.inv_comp_eq, category.assoc,\n          abelian.coimage_image_comparison]\n        ext\n        simp only [cokernel.π_desc_assoc, mono_factorisation.fac, image.fac] }\n#align category_theory.abelian.of_coimage_image_comparison_is_iso.image_factorisation CategoryTheory.Abelian.OfCoimageImageComparisonIsIso.imageFactorisation\n\ninstance [HasZeroObject C] {X Y : C} (f : X ⟶ Y) [Mono f]\n    [IsIso (Abelian.coimageImageComparison f)] : IsIso (imageMonoFactorisation f).e :=\n  by\n  rw [image_mono_factorisation_e']\n  exact is_iso.comp_is_iso\n\ninstance [HasZeroObject C] {X Y : C} (f : X ⟶ Y) [Epi f] : IsIso (imageMonoFactorisation f).m :=\n  by\n  dsimp\n  infer_instance\n\nvariable [∀ {X Y : C} (f : X ⟶ Y), IsIso (Abelian.coimageImageComparison f)]\n\n/-- A category in which coimage-image comparisons are all isomorphisms has images. -/\ntheorem hasImages : HasImages C :=\n  { HasImage := fun X Y f => { exists_image := ⟨imageFactorisation f⟩ } }\n#align category_theory.abelian.of_coimage_image_comparison_is_iso.has_images CategoryTheory.Abelian.OfCoimageImageComparisonIsIso.hasImages\n\nvariable [Limits.HasFiniteProducts C]\n\nattribute [local instance] limits.has_finite_biproducts.of_has_finite_products\n\n/-- A category with finite products in which coimage-image comparisons are all isomorphisms\nis a normal mono category.\n-/\ndef normalMonoCategory : NormalMonoCategory C\n    where normalMonoOfMono X Y f m :=\n    { z := _\n      g := cokernel.π f\n      w := by simp\n      IsLimit := by\n        haveI : limits.has_images C := has_images\n        haveI : has_equalizers C := preadditive.has_equalizers_of_has_kernels\n        haveI : has_zero_object C := limits.has_zero_object_of_has_finite_biproducts _\n        have aux : _ := _\n        refine' is_limit_aux _ (fun A => limit.lift _ _ ≫ inv (image_mono_factorisation f).e) aux _\n        · intro A g hg\n          rw [kernel_fork.ι_of_ι] at hg\n          rw [← cancel_mono f, hg, ← aux, kernel_fork.ι_of_ι]\n        · intro A\n          simp only [kernel_fork.ι_of_ι, category.assoc]\n          convert limit.lift_π _ _ using 2\n          rw [is_iso.inv_comp_eq, eq_comm]\n          exact (image_mono_factorisation f).fac }\n#align category_theory.abelian.of_coimage_image_comparison_is_iso.normal_mono_category CategoryTheory.Abelian.OfCoimageImageComparisonIsIso.normalMonoCategory\n\n/-- A category with finite products in which coimage-image comparisons are all isomorphisms\nis a normal epi category.\n-/\ndef normalEpiCategory : NormalEpiCategory C\n    where normalEpiOfEpi X Y f m :=\n    { w := kernel f\n      g := kernel.ι _\n      w := kernel.condition _\n      IsColimit := by\n        haveI : limits.has_images C := has_images\n        haveI : has_equalizers C := preadditive.has_equalizers_of_has_kernels\n        haveI : has_zero_object C := limits.has_zero_object_of_has_finite_biproducts _\n        have aux : _ := _\n        refine'\n          is_colimit_aux _\n            (fun A =>\n              inv (image_mono_factorisation f).m ≫\n                inv (abelian.coimage_image_comparison f) ≫ colimit.desc _ _)\n            aux _\n        · intro A g hg\n          rw [cokernel_cofork.π_of_π] at hg\n          rw [← cancel_epi f, hg, ← aux, cokernel_cofork.π_of_π]\n        · intro A\n          simp only [cokernel_cofork.π_of_π, ← category.assoc]\n          convert colimit.ι_desc _ _ using 2\n          rw [is_iso.comp_inv_eq, is_iso.comp_inv_eq, eq_comm, ← image_mono_factorisation_e']\n          exact (image_mono_factorisation f).fac }\n#align category_theory.abelian.of_coimage_image_comparison_is_iso.normal_epi_category CategoryTheory.Abelian.OfCoimageImageComparisonIsIso.normalEpiCategory\n\nend OfCoimageImageComparisonIsIso\n\nvariable [∀ {X Y : C} (f : X ⟶ Y), IsIso (Abelian.coimageImageComparison f)]\n  [Limits.HasFiniteProducts C]\n\nattribute [local instance] of_coimage_image_comparison_is_iso.normal_mono_category\n\nattribute [local instance] of_coimage_image_comparison_is_iso.normal_epi_category\n\n/-- A preadditive category with kernels, cokernels, and finite products,\nin which the coimage-image comparison morphism is always an isomorphism,\nis an abelian category.\n\nThe Stacks project uses this characterisation at the definition of an abelian category.\nSee <https://stacks.math.columbia.edu/tag/0109>.\n-/\ndef ofCoimageImageComparisonIsIso : Abelian C where\n#align category_theory.abelian.of_coimage_image_comparison_is_iso CategoryTheory.Abelian.ofCoimageImageComparisonIsIso\n\nend CategoryTheory.Abelian\n\nnamespace CategoryTheory.Abelian\n\nvariable {C : Type u} [Category.{v} C] [Abelian C]\n\n/-- An abelian category has finite biproducts. -/\ninstance (priority := 100) hasFiniteBiproducts : HasFiniteBiproducts C :=\n  Limits.HasFiniteBiproducts.of_hasFiniteProducts\n#align category_theory.abelian.has_finite_biproducts CategoryTheory.Abelian.hasFiniteBiproducts\n\ninstance (priority := 100) hasBinaryBiproducts : HasBinaryBiproducts C :=\n  Limits.hasBinaryBiproducts_of_finite_biproducts _\n#align category_theory.abelian.has_binary_biproducts CategoryTheory.Abelian.hasBinaryBiproducts\n\ninstance (priority := 100) hasZeroObject : HasZeroObject C :=\n  hasZeroObject_of_hasInitial_object\n#align category_theory.abelian.has_zero_object CategoryTheory.Abelian.hasZeroObject\n\nsection ToNonPreadditiveAbelian\n\n/-- Every abelian category is, in particular, `non_preadditive_abelian`. -/\ndef nonPreadditiveAbelian : NonPreadditiveAbelian C :=\n  { ‹Abelian C› with }\n#align category_theory.abelian.non_preadditive_abelian CategoryTheory.Abelian.nonPreadditiveAbelian\n\nend ToNonPreadditiveAbelian\n\nsection\n\n/-! We now promote some instances that were constructed using `non_preadditive_abelian`. -/\n\n\nattribute [local instance] non_preadditive_abelian\n\nvariable {P Q : C} (f : P ⟶ Q)\n\n/-- The map `p : P ⟶ image f` is an epimorphism -/\ninstance : Epi (Abelian.factorThruImage f) := by infer_instance\n\ninstance isIso_factorThruImage [Mono f] : IsIso (Abelian.factorThruImage f) := by infer_instance\n#align category_theory.abelian.is_iso_factor_thru_image CategoryTheory.Abelian.isIso_factorThruImage\n\n/-- The canonical morphism `i : coimage f ⟶ Q` is a monomorphism -/\ninstance : Mono (Abelian.factorThruCoimage f) := by infer_instance\n\ninstance isIso_factorThruCoimage [Epi f] : IsIso (Abelian.factorThruCoimage f) := by infer_instance\n#align category_theory.abelian.is_iso_factor_thru_coimage CategoryTheory.Abelian.isIso_factorThruCoimage\n\nend\n\nsection Factor\n\nattribute [local instance] non_preadditive_abelian\n\nvariable {P Q : C} (f : P ⟶ Q)\n\nsection\n\ntheorem mono_of_kernel_ι_eq_zero (h : kernel.ι f = 0) : Mono f :=\n  mono_of_kernel_zero h\n#align category_theory.abelian.mono_of_kernel_ι_eq_zero CategoryTheory.Abelian.mono_of_kernel_ι_eq_zero\n\ntheorem epi_of_cokernel_π_eq_zero (h : cokernel.π f = 0) : Epi f :=\n  by\n  apply normal_mono_category.epi_of_zero_cokernel _ (cokernel f)\n  simp_rw [← h]\n  exact is_colimit.of_iso_colimit (colimit.is_colimit (parallel_pair f 0)) (iso_of_π _)\n#align category_theory.abelian.epi_of_cokernel_π_eq_zero CategoryTheory.Abelian.epi_of_cokernel_π_eq_zero\n\nend\n\nsection\n\nvariable {f}\n\ntheorem image_ι_comp_eq_zero {R : C} {g : Q ⟶ R} (h : f ≫ g = 0) : Abelian.image.ι f ≫ g = 0 :=\n  zero_of_epi_comp (Abelian.factorThruImage f) <| by simp [h]\n#align category_theory.abelian.image_ι_comp_eq_zero CategoryTheory.Abelian.image_ι_comp_eq_zero\n\ntheorem comp_coimage_π_eq_zero {R : C} {g : Q ⟶ R} (h : f ≫ g = 0) : f ≫ Abelian.coimage.π g = 0 :=\n  zero_of_comp_mono (Abelian.factorThruCoimage g) <| by simp [h]\n#align category_theory.abelian.comp_coimage_π_eq_zero CategoryTheory.Abelian.comp_coimage_π_eq_zero\n\nend\n\n/-- Factoring through the image is a strong epi-mono factorisation. -/\n@[simps]\ndef imageStrongEpiMonoFactorisation : StrongEpiMonoFactorisation f\n    where\n  i := Abelian.image f\n  m := image.ι f\n  m_mono := by infer_instance\n  e := Abelian.factorThruImage f\n  e_strongEpi := strongEpi_of_epi _\n#align category_theory.abelian.image_strong_epi_mono_factorisation CategoryTheory.Abelian.imageStrongEpiMonoFactorisation\n\n/-- Factoring through the coimage is a strong epi-mono factorisation. -/\n@[simps]\ndef coimageStrongEpiMonoFactorisation : StrongEpiMonoFactorisation f\n    where\n  i := Abelian.coimage f\n  m := Abelian.factorThruCoimage f\n  m_mono := by infer_instance\n  e := coimage.π f\n  e_strongEpi := strongEpi_of_epi _\n#align category_theory.abelian.coimage_strong_epi_mono_factorisation CategoryTheory.Abelian.coimageStrongEpiMonoFactorisation\n\nend Factor\n\nsection HasStrongEpiMonoFactorisations\n\n/-- An abelian category has strong epi-mono factorisations. -/\ninstance (priority := 100) : HasStrongEpiMonoFactorisations C :=\n  HasStrongEpiMonoFactorisations.mk fun X Y f => imageStrongEpiMonoFactorisation f\n\n-- In particular, this means that it has well-behaved images.\nexample : HasImages C := by infer_instance\n\nexample : HasImageMaps C := by infer_instance\n\nend HasStrongEpiMonoFactorisations\n\nsection Images\n\nvariable {X Y : C} (f : X ⟶ Y)\n\n/-- The coimage-image comparison morphism is always an isomorphism in an abelian category.\nSee `category_theory.abelian.of_coimage_image_comparison_is_iso` for the converse.\n-/\ninstance : IsIso (coimageImageComparison f) :=\n  by\n  convert is_iso.of_iso\n      (is_image.iso_ext (coimage_strong_epi_mono_factorisation f).toMonoIsImage\n        (image_strong_epi_mono_factorisation f).toMonoIsImage)\n  ext\n  change _ = _ ≫ (image_strong_epi_mono_factorisation f).m\n  simp [-image_strong_epi_mono_factorisation_to_mono_factorisation_m]\n\n/-- There is a canonical isomorphism between the abelian coimage and the abelian image of a\n    morphism. -/\nabbrev coimageIsoImage : Abelian.coimage f ≅ Abelian.image f :=\n  asIso (coimageImageComparison f)\n#align category_theory.abelian.coimage_iso_image CategoryTheory.Abelian.coimageIsoImage\n\n/-- There is a canonical isomorphism between the abelian coimage and the categorical image of a\n    morphism. -/\nabbrev coimageIsoImage' : Abelian.coimage f ≅ image f :=\n  IsImage.isoExt (coimageStrongEpiMonoFactorisation f).toMonoIsImage (Image.isImage f)\n#align category_theory.abelian.coimage_iso_image' CategoryTheory.Abelian.coimageIsoImage'\n\ntheorem coimageIsoImage'_hom :\n    (coimageIsoImage' f).Hom =\n      cokernel.desc _ (factorThruImage f) (by simp [← cancel_mono (limits.image.ι f)]) :=\n  by\n  ext\n  simp only [← cancel_mono (limits.image.ι f), is_image.iso_ext_hom, cokernel.π_desc,\n    category.assoc, is_image.lift_ι, coimage_strong_epi_mono_factorisation_to_mono_factorisation_m,\n    limits.image.fac]\n#align category_theory.abelian.coimage_iso_image'_hom CategoryTheory.Abelian.coimageIsoImage'_hom\n\ntheorem factorThruImage_comp_coimageIsoImage'_inv :\n    factorThruImage f ≫ (coimageIsoImage' f).inv = cokernel.π _ := by\n  simp only [is_image.iso_ext_inv, image.is_image_lift, image.fac_lift,\n    coimage_strong_epi_mono_factorisation_to_mono_factorisation_e]\n#align category_theory.abelian.factor_thru_image_comp_coimage_iso_image'_inv CategoryTheory.Abelian.factorThruImage_comp_coimageIsoImage'_inv\n\n/-- There is a canonical isomorphism between the abelian image and the categorical image of a\n    morphism. -/\nabbrev imageIsoImage : Abelian.image f ≅ image f :=\n  IsImage.isoExt (imageStrongEpiMonoFactorisation f).toMonoIsImage (Image.isImage f)\n#align category_theory.abelian.image_iso_image CategoryTheory.Abelian.imageIsoImage\n\ntheorem imageIsoImage_hom_comp_image_ι : (imageIsoImage f).Hom ≫ Limits.image.ι _ = kernel.ι _ := by\n  simp only [is_image.iso_ext_hom, is_image.lift_ι,\n    image_strong_epi_mono_factorisation_to_mono_factorisation_m]\n#align category_theory.abelian.image_iso_image_hom_comp_image_ι CategoryTheory.Abelian.imageIsoImage_hom_comp_image_ι\n\ntheorem imageIsoImage_inv :\n    (imageIsoImage f).inv =\n      kernel.lift _ (Limits.image.ι f) (by simp [← cancel_epi (factor_thru_image f)]) :=\n  by\n  ext\n  simp only [is_image.iso_ext_inv, image.is_image_lift, limits.image.fac_lift,\n    image_strong_epi_mono_factorisation_to_mono_factorisation_e, category.assoc, kernel.lift_ι,\n    limits.image.fac]\n#align category_theory.abelian.image_iso_image_inv CategoryTheory.Abelian.imageIsoImage_inv\n\nend Images\n\nsection CokernelOfKernel\n\nvariable {X Y : C} {f : X ⟶ Y}\n\nattribute [local instance] non_preadditive_abelian\n\n/-- In an abelian category, an epi is the cokernel of its kernel. More precisely:\n    If `f` is an epimorphism and `s` is some limit kernel cone on `f`, then `f` is a cokernel\n    of `fork.ι s`. -/\ndef epiIsCokernelOfKernel [Epi f] (s : Fork f 0) (h : IsLimit s) :\n    IsColimit (CokernelCofork.ofπ f (KernelFork.condition s)) :=\n  NonPreadditiveAbelian.epiIsCokernelOfKernel s h\n#align category_theory.abelian.epi_is_cokernel_of_kernel CategoryTheory.Abelian.epiIsCokernelOfKernel\n\n/-- In an abelian category, a mono is the kernel of its cokernel. More precisely:\n    If `f` is a monomorphism and `s` is some colimit cokernel cocone on `f`, then `f` is a kernel\n    of `cofork.π s`. -/\ndef monoIsKernelOfCokernel [Mono f] (s : Cofork f 0) (h : IsColimit s) :\n    IsLimit (KernelFork.ofι f (CokernelCofork.condition s)) :=\n  NonPreadditiveAbelian.monoIsKernelOfCokernel s h\n#align category_theory.abelian.mono_is_kernel_of_cokernel CategoryTheory.Abelian.monoIsKernelOfCokernel\n\nvariable (f)\n\n/-- In an abelian category, any morphism that turns to zero when precomposed with the kernel of an\n    epimorphism factors through that epimorphism. -/\ndef epiDesc [Epi f] {T : C} (g : X ⟶ T) (hg : kernel.ι f ≫ g = 0) : Y ⟶ T :=\n  (epiIsCokernelOfKernel _ (limit.isLimit _)).desc (CokernelCofork.ofπ _ hg)\n#align category_theory.abelian.epi_desc CategoryTheory.Abelian.epiDesc\n\n@[simp, reassoc.1]\ntheorem comp_epiDesc [Epi f] {T : C} (g : X ⟶ T) (hg : kernel.ι f ≫ g = 0) :\n    f ≫ epiDesc f g hg = g :=\n  (epiIsCokernelOfKernel _ (limit.isLimit _)).fac (CokernelCofork.ofπ _ hg) WalkingParallelPair.one\n#align category_theory.abelian.comp_epi_desc CategoryTheory.Abelian.comp_epiDesc\n\n/-- In an abelian category, any morphism that turns to zero when postcomposed with the cokernel of a\n    monomorphism factors through that monomorphism. -/\ndef monoLift [Mono f] {T : C} (g : T ⟶ Y) (hg : g ≫ cokernel.π f = 0) : T ⟶ X :=\n  (monoIsKernelOfCokernel _ (colimit.isColimit _)).lift (KernelFork.ofι _ hg)\n#align category_theory.abelian.mono_lift CategoryTheory.Abelian.monoLift\n\n@[simp, reassoc.1]\ntheorem monoLift_comp [Mono f] {T : C} (g : T ⟶ Y) (hg : g ≫ cokernel.π f = 0) :\n    monoLift f g hg ≫ f = g :=\n  (monoIsKernelOfCokernel _ (colimit.isColimit _)).fac (KernelFork.ofι _ hg)\n    WalkingParallelPair.zero\n#align category_theory.abelian.mono_lift_comp CategoryTheory.Abelian.monoLift_comp\n\nend CokernelOfKernel\n\nsection\n\ninstance (priority := 100) hasEqualizers : HasEqualizers C :=\n  Preadditive.hasEqualizers_of_hasKernels\n#align category_theory.abelian.has_equalizers CategoryTheory.Abelian.hasEqualizers\n\n/-- Any abelian category has pullbacks -/\ninstance (priority := 100) hasPullbacks : HasPullbacks C :=\n  hasPullbacks_of_hasBinaryProducts_of_hasEqualizers C\n#align category_theory.abelian.has_pullbacks CategoryTheory.Abelian.hasPullbacks\n\nend\n\nsection\n\ninstance (priority := 100) hasCoequalizers : HasCoequalizers C :=\n  Preadditive.hasCoequalizers_of_hasCokernels\n#align category_theory.abelian.has_coequalizers CategoryTheory.Abelian.hasCoequalizers\n\n/-- Any abelian category has pushouts -/\ninstance (priority := 100) hasPushouts : HasPushouts C :=\n  hasPushouts_of_hasBinaryCoproducts_of_hasCoequalizers C\n#align category_theory.abelian.has_pushouts CategoryTheory.Abelian.hasPushouts\n\ninstance (priority := 100) hasFiniteLimits : HasFiniteLimits C :=\n  Limits.hasFiniteLimits_of_hasEqualizers_and_finite_products\n#align category_theory.abelian.has_finite_limits CategoryTheory.Abelian.hasFiniteLimits\n\ninstance (priority := 100) hasFiniteColimits : HasFiniteColimits C :=\n  Limits.hasFiniteColimits_of_hasCoequalizers_and_finite_coproducts\n#align category_theory.abelian.has_finite_colimits CategoryTheory.Abelian.hasFiniteColimits\n\nend\n\nnamespace PullbackToBiproductIsKernel\n\nvariable [Limits.HasPullbacks C] {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n\n/-! This section contains a slightly technical result about pullbacks and biproducts.\n    We will need it in the proof that the pullback of an epimorphism is an epimorpism. -/\n\n\n/-- The canonical map `pullback f g ⟶ X ⊞ Y` -/\nabbrev pullbackToBiproduct : pullback f g ⟶ X ⊞ Y :=\n  biprod.lift pullback.fst pullback.snd\n#align category_theory.abelian.pullback_to_biproduct_is_kernel.pullback_to_biproduct CategoryTheory.Abelian.PullbackToBiproductIsKernel.pullbackToBiproduct\n\n/-- The canonical map `pullback f g ⟶ X ⊞ Y` induces a kernel cone on the map\n    `biproduct X Y ⟶ Z` induced by `f` and `g`. A slightly more intuitive way to think of\n    this may be that it induces an equalizer fork on the maps induced by `(f, 0)` and\n    `(0, g)`. -/\nabbrev pullbackToBiproductFork : KernelFork (biprod.desc f (-g)) :=\n  KernelFork.ofι (pullbackToBiproduct f g) <| by\n    rw [biprod.lift_desc, comp_neg, pullback.condition, add_right_neg]\n#align category_theory.abelian.pullback_to_biproduct_is_kernel.pullback_to_biproduct_fork CategoryTheory.Abelian.PullbackToBiproductIsKernel.pullbackToBiproductFork\n\n/-- The canonical map `pullback f g ⟶ X ⊞ Y` is a kernel of the map induced by\n    `(f, -g)`. -/\ndef isLimitPullbackToBiproduct : IsLimit (pullbackToBiproductFork f g) :=\n  Fork.IsLimit.mk _\n    (fun s =>\n      pullback.lift (Fork.ι s ≫ biprod.fst) (Fork.ι s ≫ biprod.snd) <|\n        sub_eq_zero.1 <| by\n          rw [category.assoc, category.assoc, ← comp_sub, sub_eq_add_neg, ← comp_neg, ←\n            biprod.desc_eq, kernel_fork.condition s])\n    (fun s => by\n      ext <;> rw [fork.ι_of_ι, category.assoc]\n      · rw [biprod.lift_fst, pullback.lift_fst]\n      · rw [biprod.lift_snd, pullback.lift_snd])\n    fun s m h => by ext <;> simp [← h]\n#align category_theory.abelian.pullback_to_biproduct_is_kernel.is_limit_pullback_to_biproduct CategoryTheory.Abelian.PullbackToBiproductIsKernel.isLimitPullbackToBiproduct\n\nend PullbackToBiproductIsKernel\n\nnamespace BiproductToPushoutIsCokernel\n\nvariable [Limits.HasPushouts C] {W X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)\n\n/-- The canonical map `Y ⊞ Z ⟶ pushout f g` -/\nabbrev biproductToPushout : Y ⊞ Z ⟶ pushout f g :=\n  biprod.desc pushout.inl pushout.inr\n#align category_theory.abelian.biproduct_to_pushout_is_cokernel.biproduct_to_pushout CategoryTheory.Abelian.BiproductToPushoutIsCokernel.biproductToPushout\n\n/-- The canonical map `Y ⊞ Z ⟶ pushout f g` induces a cokernel cofork on the map\n    `X ⟶ Y ⊞ Z` induced by `f` and `-g`. -/\nabbrev biproductToPushoutCofork : CokernelCofork (biprod.lift f (-g)) :=\n  CokernelCofork.ofπ (biproductToPushout f g) <| by\n    rw [biprod.lift_desc, neg_comp, pushout.condition, add_right_neg]\n#align category_theory.abelian.biproduct_to_pushout_is_cokernel.biproduct_to_pushout_cofork CategoryTheory.Abelian.BiproductToPushoutIsCokernel.biproductToPushoutCofork\n\n/-- The cofork induced by the canonical map `Y ⊞ Z ⟶ pushout f g` is in fact a colimit cokernel\n    cofork. -/\ndef isColimitBiproductToPushout : IsColimit (biproductToPushoutCofork f g) :=\n  Cofork.IsColimit.mk _\n    (fun s =>\n      pushout.desc (biprod.inl ≫ Cofork.π s) (biprod.inr ≫ Cofork.π s) <|\n        sub_eq_zero.1 <| by\n          rw [← category.assoc, ← category.assoc, ← sub_comp, sub_eq_add_neg, ← neg_comp, ←\n            biprod.lift_eq, cofork.condition s, zero_comp])\n    (fun s => by ext <;> simp) fun s m h => by ext <;> simp [← h]\n#align category_theory.abelian.biproduct_to_pushout_is_cokernel.is_colimit_biproduct_to_pushout CategoryTheory.Abelian.BiproductToPushoutIsCokernel.isColimitBiproductToPushout\n\nend BiproductToPushoutIsCokernel\n\nsection EpiPullback\n\nvariable [Limits.HasPullbacks C] {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n\n/-- In an abelian category, the pullback of an epimorphism is an epimorphism.\n    Proof from [aluffi2016, IX.2.3], cf. [borceux-vol2, 1.7.6] -/\ninstance epi_pullback_of_epi_f [Epi f] : Epi (pullback.snd : pullback f g ⟶ Y) :=\n  -- It will suffice to consider some morphism e : Y ⟶ R such that\n    -- pullback.snd ≫ e = 0 and show that e = 0.\n    epi_of_cancel_zero\n    _ fun R e h =>\n    by\n    -- Consider the morphism u := (0, e) : X ⊞ Y⟶ R.\n    let u := biprod.desc (0 : X ⟶ R) e\n    -- The composite pullback f g ⟶ X ⊞ Y ⟶ R is zero by assumption.\n    have hu : pullback_to_biproduct_is_kernel.pullback_to_biproduct f g ≫ u = 0 := by simpa\n    -- pullback_to_biproduct f g is a kernel of (f, -g), so (f, -g) is a\n    -- cokernel of pullback_to_biproduct f g\n    have :=\n      epi_is_cokernel_of_kernel _\n        (pullback_to_biproduct_is_kernel.is_limit_pullback_to_biproduct f g)\n    -- We use this fact to obtain a factorization of u through (f, -g) via some d : Z ⟶ R.\n    obtain ⟨d, hd⟩ := cokernel_cofork.is_colimit.desc' this u hu\n    change Z ⟶ R at d\n    change biprod.desc f (-g) ≫ d = u at hd\n    -- But then f ≫ d = 0:\n    have : f ≫ d = 0;\n    calc\n      f ≫ d = (biprod.inl ≫ biprod.desc f (-g)) ≫ d := by rw [biprod.inl_desc]\n      _ = biprod.inl ≫ u := by rw [category.assoc, hd]\n      _ = 0 := biprod.inl_desc _ _\n      \n    -- But f is an epimorphism, so d = 0...\n    have : d = 0 := (cancel_epi f).1 (by simpa)\n    -- ...or, in other words, e = 0.\n    calc\n      e = biprod.inr ≫ u := by rw [biprod.inr_desc]\n      _ = biprod.inr ≫ biprod.desc f (-g) ≫ d := by rw [← hd]\n      _ = biprod.inr ≫ biprod.desc f (-g) ≫ 0 := by rw [this]\n      _ = (biprod.inr ≫ biprod.desc f (-g)) ≫ 0 := by rw [← category.assoc]\n      _ = 0 := has_zero_morphisms.comp_zero _ _\n      \n#align category_theory.abelian.epi_pullback_of_epi_f CategoryTheory.Abelian.epi_pullback_of_epi_f\n\n/-- In an abelian category, the pullback of an epimorphism is an epimorphism. -/\ninstance epi_pullback_of_epi_g [Epi g] : Epi (pullback.fst : pullback f g ⟶ X) :=\n  -- It will suffice to consider some morphism e : X ⟶ R such that\n    -- pullback.fst ≫ e = 0 and show that e = 0.\n    epi_of_cancel_zero\n    _ fun R e h =>\n    by\n    -- Consider the morphism u := (e, 0) : X ⊞ Y ⟶ R.\n    let u := biprod.desc e (0 : Y ⟶ R)\n    -- The composite pullback f g ⟶ X ⊞ Y ⟶ R is zero by assumption.\n    have hu : pullback_to_biproduct_is_kernel.pullback_to_biproduct f g ≫ u = 0 := by simpa\n    -- pullback_to_biproduct f g is a kernel of (f, -g), so (f, -g) is a\n    -- cokernel of pullback_to_biproduct f g\n    have :=\n      epi_is_cokernel_of_kernel _\n        (pullback_to_biproduct_is_kernel.is_limit_pullback_to_biproduct f g)\n    -- We use this fact to obtain a factorization of u through (f, -g) via some d : Z ⟶ R.\n    obtain ⟨d, hd⟩ := cokernel_cofork.is_colimit.desc' this u hu\n    change Z ⟶ R at d\n    change biprod.desc f (-g) ≫ d = u at hd\n    -- But then (-g) ≫ d = 0:\n    have : (-g) ≫ d = 0;\n    calc\n      (-g) ≫ d = (biprod.inr ≫ biprod.desc f (-g)) ≫ d := by rw [biprod.inr_desc]\n      _ = biprod.inr ≫ u := by rw [category.assoc, hd]\n      _ = 0 := biprod.inr_desc _ _\n      \n    -- But g is an epimorphism, thus so is -g, so d = 0...\n    have : d = 0 := (cancel_epi (-g)).1 (by simpa)\n    -- ...or, in other words, e = 0.\n    calc\n      e = biprod.inl ≫ u := by rw [biprod.inl_desc]\n      _ = biprod.inl ≫ biprod.desc f (-g) ≫ d := by rw [← hd]\n      _ = biprod.inl ≫ biprod.desc f (-g) ≫ 0 := by rw [this]\n      _ = (biprod.inl ≫ biprod.desc f (-g)) ≫ 0 := by rw [← category.assoc]\n      _ = 0 := has_zero_morphisms.comp_zero _ _\n      \n#align category_theory.abelian.epi_pullback_of_epi_g CategoryTheory.Abelian.epi_pullback_of_epi_g\n\ntheorem epi_snd_of_isLimit [Epi f] {s : PullbackCone f g} (hs : IsLimit s) : Epi s.snd :=\n  by\n  convert epi_of_epi_fac (is_limit.cone_point_unique_up_to_iso_hom_comp (limit.is_limit _) hs _)\n  · rfl\n  · exact abelian.epi_pullback_of_epi_f _ _\n#align category_theory.abelian.epi_snd_of_is_limit CategoryTheory.Abelian.epi_snd_of_isLimit\n\ntheorem epi_fst_of_isLimit [Epi g] {s : PullbackCone f g} (hs : IsLimit s) : Epi s.fst :=\n  by\n  convert epi_of_epi_fac (is_limit.cone_point_unique_up_to_iso_hom_comp (limit.is_limit _) hs _)\n  · rfl\n  · exact abelian.epi_pullback_of_epi_g _ _\n#align category_theory.abelian.epi_fst_of_is_limit CategoryTheory.Abelian.epi_fst_of_isLimit\n\n/-- Suppose `f` and `g` are two morphisms with a common codomain and suppose we have written `g` as\n    an epimorphism followed by a monomorphism. If `f` factors through the mono part of this\n    factorization, then any pullback of `g` along `f` is an epimorphism. -/\ntheorem epi_fst_of_factor_thru_epi_mono_factorization (g₁ : Y ⟶ W) [Epi g₁] (g₂ : W ⟶ Z) [Mono g₂]\n    (hg : g₁ ≫ g₂ = g) (f' : X ⟶ W) (hf : f' ≫ g₂ = f) (t : PullbackCone f g) (ht : IsLimit t) :\n    Epi t.fst := by\n  apply epi_fst_of_is_limit _ _ (pullback_cone.is_limit_of_factors f g g₂ f' g₁ hf hg t ht)\n#align category_theory.abelian.epi_fst_of_factor_thru_epi_mono_factorization CategoryTheory.Abelian.epi_fst_of_factor_thru_epi_mono_factorization\n\nend EpiPullback\n\nsection MonoPushout\n\nvariable [Limits.HasPushouts C] {W X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)\n\ninstance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr : Z ⟶ pushout f g) :=\n  mono_of_cancel_zero _ fun R e h =>\n    by\n    let u := biprod.lift (0 : R ⟶ Y) e\n    have hu : u ≫ biproduct_to_pushout_is_cokernel.biproduct_to_pushout f g = 0 := by simpa\n    have :=\n      mono_is_kernel_of_cokernel _\n        (biproduct_to_pushout_is_cokernel.is_colimit_biproduct_to_pushout f g)\n    obtain ⟨d, hd⟩ := kernel_fork.is_limit.lift' this u hu\n    change R ⟶ X at d\n    change d ≫ biprod.lift f (-g) = u at hd\n    have : d ≫ f = 0;\n    calc\n      d ≫ f = d ≫ biprod.lift f (-g) ≫ biprod.fst := by rw [biprod.lift_fst]\n      _ = u ≫ biprod.fst := by rw [← category.assoc, hd]\n      _ = 0 := biprod.lift_fst _ _\n      \n    have : d = 0 := (cancel_mono f).1 (by simpa)\n    calc\n      e = u ≫ biprod.snd := by rw [biprod.lift_snd]\n      _ = (d ≫ biprod.lift f (-g)) ≫ biprod.snd := by rw [← hd]\n      _ = (0 ≫ biprod.lift f (-g)) ≫ biprod.snd := by rw [this]\n      _ = 0 ≫ biprod.lift f (-g) ≫ biprod.snd := by rw [category.assoc]\n      _ = 0 := zero_comp\n      \n#align category_theory.abelian.mono_pushout_of_mono_f CategoryTheory.Abelian.mono_pushout_of_mono_f\n\ninstance mono_pushout_of_mono_g [Mono g] : Mono (pushout.inl : Y ⟶ pushout f g) :=\n  mono_of_cancel_zero _ fun R e h =>\n    by\n    let u := biprod.lift e (0 : R ⟶ Z)\n    have hu : u ≫ biproduct_to_pushout_is_cokernel.biproduct_to_pushout f g = 0 := by simpa\n    have :=\n      mono_is_kernel_of_cokernel _\n        (biproduct_to_pushout_is_cokernel.is_colimit_biproduct_to_pushout f g)\n    obtain ⟨d, hd⟩ := kernel_fork.is_limit.lift' this u hu\n    change R ⟶ X at d\n    change d ≫ biprod.lift f (-g) = u at hd\n    have : d ≫ (-g) = 0;\n    calc\n      d ≫ (-g) = d ≫ biprod.lift f (-g) ≫ biprod.snd := by rw [biprod.lift_snd]\n      _ = u ≫ biprod.snd := by rw [← category.assoc, hd]\n      _ = 0 := biprod.lift_snd _ _\n      \n    have : d = 0 := (cancel_mono (-g)).1 (by simpa)\n    calc\n      e = u ≫ biprod.fst := by rw [biprod.lift_fst]\n      _ = (d ≫ biprod.lift f (-g)) ≫ biprod.fst := by rw [← hd]\n      _ = (0 ≫ biprod.lift f (-g)) ≫ biprod.fst := by rw [this]\n      _ = 0 ≫ biprod.lift f (-g) ≫ biprod.fst := by rw [category.assoc]\n      _ = 0 := zero_comp\n      \n#align category_theory.abelian.mono_pushout_of_mono_g CategoryTheory.Abelian.mono_pushout_of_mono_g\n\ntheorem mono_inr_of_isColimit [Mono f] {s : PushoutCocone f g} (hs : IsColimit s) : Mono s.inr :=\n  by\n  convert mono_of_mono_fac\n      (is_colimit.comp_cocone_point_unique_up_to_iso_hom hs (colimit.is_colimit _) _)\n  · rfl\n  · exact abelian.mono_pushout_of_mono_f _ _\n#align category_theory.abelian.mono_inr_of_is_colimit CategoryTheory.Abelian.mono_inr_of_isColimit\n\ntheorem mono_inl_of_isColimit [Mono g] {s : PushoutCocone f g} (hs : IsColimit s) : Mono s.inl :=\n  by\n  convert mono_of_mono_fac\n      (is_colimit.comp_cocone_point_unique_up_to_iso_hom hs (colimit.is_colimit _) _)\n  · rfl\n  · exact abelian.mono_pushout_of_mono_g _ _\n#align category_theory.abelian.mono_inl_of_is_colimit CategoryTheory.Abelian.mono_inl_of_isColimit\n\n/-- Suppose `f` and `g` are two morphisms with a common domain and suppose we have written `g` as\n    an epimorphism followed by a monomorphism. If `f` factors through the epi part of this\n    factorization, then any pushout of `g` along `f` is a monomorphism. -/\ntheorem mono_inl_of_factor_thru_epi_mono_factorization (f : X ⟶ Y) (g : X ⟶ Z) (g₁ : X ⟶ W) [Epi g₁]\n    (g₂ : W ⟶ Z) [Mono g₂] (hg : g₁ ≫ g₂ = g) (f' : W ⟶ Y) (hf : g₁ ≫ f' = f)\n    (t : PushoutCocone f g) (ht : IsColimit t) : Mono t.inl := by\n  apply mono_inl_of_is_colimit _ _ (pushout_cocone.is_colimit_of_factors _ _ _ _ _ hf hg t ht)\n#align category_theory.abelian.mono_inl_of_factor_thru_epi_mono_factorization CategoryTheory.Abelian.mono_inl_of_factor_thru_epi_mono_factorization\n\nend MonoPushout\n\nend CategoryTheory.Abelian\n\nnamespace CategoryTheory.NonPreadditiveAbelian\n\nvariable (C : Type u) [Category.{v} C] [NonPreadditiveAbelian C]\n\n/-- Every non_preadditive_abelian category can be promoted to an abelian category. -/\ndef abelian : Abelian C :=\n  {/- We need the `convert`s here because the instances we have are slightly different from the\n       instances we need: `has_kernels` depends on an instance of `has_zero_morphisms`. In the\n       case of `non_preadditive_abelian`, this instance is an explicit argument. However, in the case\n       of `abelian`, the `has_zero_morphisms` instance is derived from `preadditive`. So we need to\n       transform an instance of \"has kernels with non_preadditive_abelian.has_zero_morphisms\" to an\n       instance of \"has kernels with non_preadditive_abelian.preadditive.has_zero_morphisms\". Luckily,\n       we have a `subsingleton` instance for `has_zero_morphisms`, so `convert` can immediately close\n       the goal it creates for the two instances of `has_zero_morphisms`, and the proof is complete. -/\n    NonPreadditiveAbelian.preadditive with\n    HasFiniteProducts := by infer_instance\n    HasKernels := by convert(by infer_instance : limits.has_kernels C)\n    HasCokernels := by convert(by infer_instance : limits.has_cokernels C)\n    normalMonoOfMono := by\n      intros\n      convert normal_mono_of_mono f\n    normalEpiOfEpi := by\n      intros\n      convert normal_epi_of_epi f }\n#align category_theory.non_preadditive_abelian.abelian CategoryTheory.NonPreadditiveAbelian.abelian\n\nend CategoryTheory.NonPreadditiveAbelian\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Abelian/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833893685269, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4648959335753047}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport data.multiset.nodup\n\n/-!\n# The cartesian product of multisets\n-/\n\nnamespace multiset\n\nsection pi\nvariables {α : Type*}\nopen function\n\n/-- Given `δ : α → Type*`, `pi.empty δ` is the trivial dependent function out of the empty\nmultiset. -/\ndef pi.empty (δ : α → Type*) : (Πa∈(0:multiset α), δ a) .\n\nvariables [decidable_eq α] {δ : α → Type*}\n\n/-- Given `δ : α → Type*`, a multiset `m` and a term `a`, as well as a term `b : δ a` and a\nfunction `f` such that `f a' : δ a'` for all `a'` in `m`, `pi.cons m a b f` is a function `g` such\nthat `g a'' : δ a''` for all `a''` in `a ::ₘ m`. -/\ndef pi.cons (m : multiset α) (a : α) (b : δ a) (f : Πa∈m, δ a) : Πa'∈a ::ₘ m, δ a' :=\nλa' ha', if h : a' = a then eq.rec b h.symm else f a' $ (mem_cons.1 ha').resolve_left h\n\nlemma pi.cons_same {m : multiset α} {a : α} {b : δ a} {f : Πa∈m, δ a} (h : a ∈ a ::ₘ m) :\n  pi.cons m a b f a h = b :=\ndif_pos rfl\n\nlemma pi.cons_ne {m : multiset α} {a a' : α} {b : δ a} {f : Πa∈m, δ a}\n  (h' : a' ∈ a ::ₘ m) (h : a' ≠ a) :\n  pi.cons m a b f a' h' = f a' ((mem_cons.1 h').resolve_left h) :=\ndif_neg h\n\nlemma pi.cons_swap {a a' : α} {b : δ a} {b' : δ a'} {m : multiset α} {f : Πa∈m, δ a} (h : a ≠ a') :\n  pi.cons (a' ::ₘ m) a b (pi.cons m a' b' f) == pi.cons (a ::ₘ m) a' b' (pi.cons m a b f) :=\nbegin\n  apply hfunext, { refl }, intros a'' _ h, subst h,\n  apply hfunext, { rw [cons_swap] }, intros ha₁ ha₂ h,\n  by_cases h₁ : a'' = a; by_cases h₂ : a'' = a';\n    simp [*, pi.cons_same, pi.cons_ne] at *,\n  { subst h₁, rw [pi.cons_same, pi.cons_same] },\n  { subst h₂, rw [pi.cons_same, pi.cons_same] }\nend\n\n/-- `pi m t` constructs the Cartesian product over `t` indexed by `m`. -/\ndef pi (m : multiset α) (t : Πa, multiset (δ a)) : multiset (Πa∈m, δ a) :=\nm.rec_on {pi.empty δ} (λa m (p : multiset (Πa∈m, δ a)), (t a).bind $ λb, p.map $ pi.cons m a b)\nbegin\n  intros a a' m n,\n  by_cases eq : a = a',\n  { subst eq },\n  { simp [map_bind, bind_bind (t a') (t a)],\n    apply bind_hcongr, { rw [cons_swap a a'] },\n    intros b hb,\n    apply bind_hcongr, { rw [cons_swap a a'] },\n    intros b' hb',\n    apply map_hcongr, { rw [cons_swap a a'] },\n    intros f hf,\n    exact pi.cons_swap eq }\nend\n\n@[simp] lemma pi_zero (t : Πa, multiset (δ a)) : pi 0 t = pi.empty δ ::ₘ 0 := rfl\n\n@[simp] lemma pi_cons (m : multiset α) (t : Πa, multiset (δ a)) (a : α) :\n  pi (a ::ₘ m) t = ((t a).bind $ λb, (pi m t).map $ pi.cons m a b) :=\nrec_on_cons a m\n\nlemma pi_cons_injective {a : α} {b : δ a} {s : multiset α} (hs : a ∉ s) :\n  function.injective (pi.cons s a b) :=\nassume f₁ f₂ eq, funext $ assume a', funext $ assume h',\nhave ne : a ≠ a', from assume h, hs $ h.symm ▸ h',\nhave a' ∈ a ::ₘ s, from mem_cons_of_mem h',\ncalc f₁ a' h' = pi.cons s a b f₁ a' this : by rw [pi.cons_ne this ne.symm]\n  ... = pi.cons s a b f₂ a' this : by rw [eq]\n  ... = f₂ a' h' : by rw [pi.cons_ne this ne.symm]\n\nlemma card_pi (m : multiset α) (t : Πa, multiset (δ a)) :\n  card (pi m t) = prod (m.map $ λa, card (t a)) :=\nmultiset.induction_on m (by simp) (by simp [mul_comm] {contextual := tt})\n\nlemma nodup_pi {s : multiset α} {t : Πa, multiset (δ a)} :\n  nodup s → (∀a∈s, nodup (t a)) → nodup (pi s t) :=\nmultiset.induction_on s (assume _ _, nodup_singleton _)\nbegin\n  assume a s ih hs ht,\n  have has : a ∉ s, by simp at hs; exact hs.1,\n  have hs : nodup s, by simp at hs; exact hs.2,\n  simp,\n  split,\n  { assume b hb,\n    from nodup_map (pi_cons_injective has) (ih hs $ assume a' h', ht a' $ mem_cons_of_mem h') },\n  { apply pairwise_of_nodup _ (ht a $ mem_cons_self _ _),\n    from assume b₁ hb₁ b₂ hb₂ neb, disjoint_map_map.2 (assume f hf g hg eq,\n      have pi.cons s a b₁ f a (mem_cons_self _ _) = pi.cons s a b₂ g a (mem_cons_self _ _),\n        by rw [eq],\n      neb $ show b₁ = b₂, by rwa [pi.cons_same, pi.cons_same] at this) }\nend\n\nlemma mem_pi (m : multiset α) (t : Πa, multiset (δ a)) :\n  ∀f:Πa∈m, δ a, (f ∈ pi m t) ↔ (∀a (h : a ∈ m), f a h ∈ t a) :=\nbegin\n  refine multiset.induction_on m (λ f, _) (λ a m ih f, _),\n  { simpa using show f = pi.empty δ, by funext a ha; exact ha.elim },\n  simp only [mem_bind, exists_prop, mem_cons, pi_cons, mem_map], split,\n  { rintro ⟨b, hb, f', hf', rfl⟩ a' ha',\n    rw [ih] at hf',\n    by_cases a' = a,\n    { subst h, rwa [pi.cons_same] },\n    { rw [pi.cons_ne _ h], apply hf' } },\n  { intro hf,\n    refine ⟨_, hf a (mem_cons_self a _), λa ha, f a (mem_cons_of_mem ha),\n      (ih _).2 (λ a' h', hf _ _), _⟩,\n    funext a' h',\n    by_cases a' = a,\n    { subst h, rw [pi.cons_same] },\n    { rw [pi.cons_ne _ h] } }\nend\n\nend pi\n\nend multiset\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/multiset/pi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.4647012234235746}}
{"text": "/-\nCopyright (c) 2019 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Simon Hudon\n\nMonad encapsulating continuation passing programming style, similar to\nHaskell's `Cont`, `ContT` and `MonadCont`:\nhttp://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Cont.html\n-/\n\nimport tactic.interactive\n\nuniverses u v w\n\nstructure monad_cont.label (α : Type w) (m : Type u → Type v) (β : Type u) :=\n(apply : α → m β)\n\ndef monad_cont.goto {α β} {m : Type u → Type v} (f : monad_cont.label α m β) (x : α) := f.apply x\n\nclass monad_cont (m : Type u → Type v)\nextends monad m :=\n(call_cc : Π {α β}, ((monad_cont.label α m β) → m α) → m α)\n\nopen monad_cont\n\nclass is_lawful_monad_cont (m : Type u → Type v) [monad_cont m]\nextends is_lawful_monad m :=\n(call_cc_bind_right {α ω γ} (cmd : m α) (next : (label ω m γ) → α → m ω) :\n  call_cc (λ f, cmd >>= next f) = cmd >>= λ x, call_cc (λ f, next f x))\n(call_cc_bind_left {α} (β) (x : α) (dead : label α m β → β → m α) :\n  call_cc (λ f : label α m β, goto f x >>= dead f) = pure x)\n(call_cc_dummy {α β} (dummy : m α) :\n  call_cc (λ f : label α m β, dummy) = dummy)\n\nexport is_lawful_monad_cont\n\ndef cont_t (r : Type u) (m : Type u → Type v) (α : Type w) := (α → m r) → m r\n\nnamespace cont_t\n\nexport monad_cont (label goto)\n\nvariables {r : Type u} {m : Type u → Type v} {α β γ ω : Type w}\n\ndef run : cont_t r m α → (α → m r) → m r := id\n\ndef map (f : m r → m r) (x : cont_t r m α) : cont_t r m α := f ∘ x\n\nlemma run_cont_t_map_cont_t (f : m r → m r) (x : cont_t r m α) :\n  run (map f x) = f ∘ run x := rfl\n\ndef with_cont_t (f : (β → m r) → α → m r) (x : cont_t r m α) : cont_t r m β :=\nλ g, x $ f g\n\nlemma run_with_cont_t (f : (β → m r) → α → m r) (x : cont_t r m α) :\n  run (with_cont_t f x) = run x ∘ f := rfl\n\ninstance : monad (cont_t r m) :=\n{ pure := λ α x f, f x,\n  bind := λ α β x f g, x $ λ i, f i g }\n\ninstance : is_lawful_monad (cont_t r m) :=\n{ id_map := by { intros, refl },\n  pure_bind := by { intros, ext, refl },\n  bind_assoc := by { intros, ext, refl } }\n\ninstance [monad m] : has_monad_lift m (cont_t r m) :=\n{ monad_lift := λ a x f, x >>= f }\n\nlemma monad_lift_bind [monad m] [is_lawful_monad m] {α β} (x : m α) (f : α → m β) :\n  (monad_lift (x >>= f) : cont_t r m β) = monad_lift x >>= monad_lift ∘ f :=\nby { ext, simp only [monad_lift,has_monad_lift.monad_lift,(∘),(>>=),bind_assoc,id.def] }\n\ninstance : monad_cont (cont_t r m) :=\n{ call_cc := λ α β f g, f ⟨λ x h, g x⟩ g }\n\ninstance : is_lawful_monad_cont (cont_t r m) :=\n{ call_cc_bind_right := by intros; ext; refl,\n  call_cc_bind_left := by intros; ext; refl,\n  call_cc_dummy := by intros; ext; refl }\n\nend cont_t\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/category/monad/cont.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.46470121869293873}}
{"text": "/-\nCopyright (c) 2022 Rémi Bottinelli. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémi Bottinelli\n-/\nimport category_theory.category.basic\nimport category_theory.functor.basic\nimport category_theory.groupoid\nimport tactic.nth_rewrite\nimport category_theory.path_category\nimport category_theory.quotient\nimport combinatorics.quiver.symmetric\n\n/-!\n# Free groupoid on a quiver\n\nThis file defines the free groupoid on a quiver, the lifting of a prefunctor to its unique\nextension as a functor from the free groupoid, and proves uniqueness of this extension.\n\n## Main results\n\nGiven the type `V` and a quiver instance on `V`:\n\n- `free_groupoid V`: a type synonym for `V`.\n- `free_groupoid_groupoid`: the `groupoid` instance on `free_groupoid V`.\n- `lift`: the lifting of a prefunctor from `V` to `V'` where `V'` is a groupoid, to a functor.\n  `free_groupoid V ⥤ V'`.\n- `lift_spec` and `lift_unique`: the proofs that, respectively, `lift` indeed is a lifting\n  and is the unique one.\n\n## Implementation notes\n\nThe free groupoid is first defined by symmetrifying the quiver, taking the induced path category\nand finally quotienting by the reducibility relation.\n\n-/\n\nopen set classical function\nlocal attribute [instance] prop_decidable\n\nnamespace category_theory\nnamespace groupoid\nnamespace free\n\nuniverses u v u' v' u'' v''\n\nvariables {V : Type u} [quiver.{v+1} V]\n\n/-- Shorthand for the \"forward\" arrow corresponding to `f` in `paths $ symmetrify V` -/\nabbreviation quiver.hom.to_pos_path {X Y : V} (f : X ⟶ Y) :\n  ((category_theory.paths.category_paths $ quiver.symmetrify V).hom X Y) := f.to_pos.to_path\n\n/-- Shorthand for the \"forward\" arrow corresponding to `f` in `paths $ symmetrify V` -/\nabbreviation quiver.hom.to_neg_path {X Y : V} (f : X ⟶ Y) :\n  ((category_theory.paths.category_paths $ quiver.symmetrify V).hom Y X) := f.to_neg.to_path\n\n/-- The \"reduction\" relation -/\ninductive red_step : hom_rel (paths (quiver.symmetrify V))\n| step (X Z : quiver.symmetrify V) (f : X ⟶ Z) :\n    red_step (𝟙 X) (f.to_path ≫ (quiver.reverse f).to_path)\n\n/-- The underlying vertices of the free groupoid -/\ndef _root_.category_theory.free_groupoid (V) [Q : quiver V] := quotient (@red_step V Q)\n\ninstance {V} [Q : quiver V] [h : nonempty V] : nonempty (free_groupoid V) := ⟨⟨h.some⟩⟩\n\nlemma congr_reverse {X Y : paths $ quiver.symmetrify V} (p q : X ⟶ Y) :\n  quotient.comp_closure red_step p q →\n  quotient.comp_closure red_step (p.reverse) (q.reverse) :=\nbegin\n  rintro ⟨XW, pp, qq, WY, _, Z, f⟩,\n  have : quotient.comp_closure red_step (WY.reverse ≫ 𝟙 _ ≫ XW.reverse)\n    (WY.reverse ≫ (f.to_path ≫ (quiver.reverse f).to_path) ≫ XW.reverse),\n  { apply quotient.comp_closure.intro,\n    apply red_step.step, },\n  simpa only [category_struct.comp, category_struct.id, quiver.path.reverse, quiver.path.nil_comp,\n    quiver.path.reverse_comp, quiver.reverse_reverse, quiver.path.reverse_to_path,\n    quiver.path.comp_assoc] using this,\nend\n\nlemma congr_comp_reverse {X Y : paths $ quiver.symmetrify V} (p : X ⟶ Y) :\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (p ≫ p.reverse) =\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (𝟙 X) :=\nbegin\n  apply quot.eqv_gen_sound,\n  induction p with _ _ q f ih,\n  { apply eqv_gen.refl, },\n  { simp only [quiver.path.reverse],\n    fapply eqv_gen.trans,\n    { exact q ≫ q.reverse, },\n    { apply eqv_gen.symm, apply eqv_gen.rel,\n      have : quotient.comp_closure\n               red_step (q ≫ (𝟙 _) ≫ q.reverse)\n               (q ≫ (f.to_path ≫ (quiver.reverse f).to_path) ≫ q.reverse), by\n      { apply quotient.comp_closure.intro, apply red_step.step, },\n      have that : q.cons f = q.comp f.to_path, by refl, rw that,\n      simp only [category.assoc, category.id_comp] at this ⊢,\n      simp only [category_struct.comp, quiver.path.comp_assoc] at this ⊢,\n      exact this, },\n    { exact ih }, },\nend\n\nlemma congr_reverse_comp {X Y : paths $ quiver.symmetrify V} (p : X ⟶ Y) :\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (p.reverse ≫ p) =\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (𝟙 Y) :=\nbegin\n  nth_rewrite 1 ←quiver.path.reverse_reverse p,\n  apply congr_comp_reverse,\nend\n\ninstance : category (free_groupoid V) := quotient.category red_step\n\n/-- The inverse of an arrow in the free groupoid -/\ndef quot_inv {X Y : free_groupoid V} (f : X ⟶ Y) : Y ⟶ X :=\nquot.lift_on f\n            (λ pp, quot.mk _ $ pp.reverse)\n            (λ pp qq con, quot.sound $ congr_reverse pp qq con)\n\ninstance : groupoid (free_groupoid V) :=\n{ inv := λ X Y f, quot_inv f,\n  inv_comp' := λ X Y p, quot.induction_on p $ λ pp, congr_reverse_comp pp,\n  comp_inv' := λ X Y p, quot.induction_on p $ λ pp, congr_comp_reverse pp }\n\n/-- The inclusion of the quiver on `V` to the underlying quiver on `free_groupoid V`-/\ndef of (V) [quiver V] : V ⥤q (free_groupoid V) :=\n{ obj := λ X, ⟨X⟩,\n  map := λ X Y f, quot.mk _ f.to_pos_path }\n\nlemma of_eq : of V =\n  (quiver.symmetrify.of ⋙q paths.of).comp (quotient.functor $ @red_step V _).to_prefunctor :=\nbegin\n  apply prefunctor.ext, rotate,\n  { rintro X, refl, },\n  { rintro X Y f, refl, }\nend\n\nsection universal_property\n\nvariables {V' : Type u'} [groupoid V'] (φ : V ⥤q V')\n\n/-- The lift of a prefunctor to a groupoid, to a functor from `free_groupoid V` -/\ndef lift (φ : V ⥤q V') : free_groupoid V ⥤ V' :=\nquotient.lift _\n  (paths.lift $ quiver.symmetrify.lift φ)\n  (by\n    { rintros _ _ _ _ ⟨X,Y,f⟩,\n      simp only [quiver.symmetrify.lift_reverse, paths.lift_nil, quiver.path.comp_nil,\n                 paths.lift_cons, paths.lift_to_path],\n      symmetry,\n      apply groupoid.comp_inv, })\n\nlemma lift_spec (φ : V ⥤q V') : of V ⋙q (lift φ).to_prefunctor = φ :=\nbegin\n  rw [of_eq, prefunctor.comp_assoc, prefunctor.comp_assoc, functor.to_prefunctor_comp],\n  dsimp [lift],\n  rw [quotient.lift_spec, paths.lift_spec, quiver.symmetrify.lift_spec],\nend\n\nlemma lift_unique (φ : V ⥤q V') (Φ : free_groupoid V ⥤ V')\n  (hΦ : of V ⋙q Φ.to_prefunctor = φ) : Φ = lift φ :=\nbegin\n  apply quotient.lift_unique,\n  apply paths.lift_unique,\n  fapply @quiver.symmetrify.lift_unique _ _ _ _ _ _ _ _ _,\n  { rw ←functor.to_prefunctor_comp, exact hΦ, },\n  { constructor, rintros X Y f,\n    simp only [←functor.to_prefunctor_comp,prefunctor.comp_map, paths.of_map, inv_eq_inv],\n    change Φ.map (inv ((quotient.functor red_step).to_prefunctor.map f.to_path)) =\n           inv (Φ.map ((quotient.functor red_step).to_prefunctor.map f.to_path)),\n    have := functor.map_inv Φ ((quotient.functor red_step).to_prefunctor.map f.to_path),\n    convert this; simp only [inv_eq_inv], },\nend\n\nend universal_property\n\nsection functoriality\n\nvariables {V' : Type u'} [quiver.{v'+1} V'] {V'' : Type u''} [quiver.{v''+1} V'']\n\n/-- The functor of free groupoid induced by a prefunctor of quivers -/\ndef _root_.category_theory.free_groupoid_functor (φ : V ⥤q V') :\n  free_groupoid V ⥤ free_groupoid V' := lift (φ ⋙q of V')\n\n\n\nlemma free_groupoid_functor_comp\n  (φ : V ⥤q V') (φ' : V' ⥤q V'') :\n  free_groupoid_functor (φ ⋙q φ') = free_groupoid_functor φ ⋙ free_groupoid_functor φ' :=\nbegin\n  dsimp only [free_groupoid_functor], symmetry,\n  apply lift_unique, refl,\nend\n\nend functoriality\n\nend free\nend groupoid\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/groupoid/free_groupoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.46470121054366903}}
{"text": "-- Iteration of equivalences over the integers\n\n-- Idea -- if f is a bijection then we can talk about f^n for n an integer,\n-- because f⁻¹ is just the inverse bijection\n\nimport tactic\n\nnamespace int\n\n-- First we define f^n as a function\n-- This is the n'th iterate of f as a function from X to X\n\n-- honest approach via iterations needs big API before\n-- you can make ℤ → ≃ → ≃\n\n-- there is already the notation `f^[n]` when f is a function and\n-- n is a natural. I will steal their binding power.\n\n-- _ `^[`:1 _:1 `]`:0 := nat.iterate #1 #0\n\n-- here is some cool notation (hopefully with the correct binding power)\n\ndef iterate {X : Type} (n : ℤ) (f : X ≃ X) : X ≃ X := f^n\n\n-- make a definition for iterate\n-- Not sure what we need\n\n-- currently: no interface at all for `iterate`. \n\n-- I mean that there are functions in the iterate namespace.\n-- For example \n\n-- notation might have to be changed but all I care about is\n-- that n must be to left of f. No arguments until it\n-- turns out rubbish\n--notation `⦃`:1 n `⦄^`:1 f := int.iterate n f\n\nnamespace iterate\n\nvariables {X : Type} (m n : ℤ) (f : X ≃ X) (x : X)\n\nlemma comp : int.iterate m f (int.iterate n f x) = int.iterate (m + n) f x :=\nbegin\n  suffices : (f ^ m * f ^ n) x = (f ^ (m + n)) x,\n    convert this,\n  rw gpow_add,\nend\n\n@[simp] lemma zero : iterate 0 f = equiv.refl X := rfl\n@[simp] lemma one : iterate 1 f = f := by { ext x, refl }\n@[simp] lemma neg_one : iterate (-1) f = f.symm := by { ext x, refl }\n\nlemma neg (a : ℤ) : iterate (-a) f = iterate a f.symm :=\nby show f^(-a) = f⁻¹^a; group\n\nlemma succ : iterate n f (f x) = iterate (n + 1) f x := comp n 1 f x\n\nlemma succ' : f (iterate n f x) = iterate (n + 1) f x := \nby rw add_comm; exact comp 1 n f x\n\ntheorem mul (f : X ≃ X) (a b : ℤ) (x : X) : iterate a (iterate b f) = \nint.iterate (a * b) f := by show (f ^ b) ^ a = f ^ (a * b); group\n\nend iterate\n\nend int\n", "meta": {"author": "ImperialCollegeLondon", "repo": "group-theory-game", "sha": "152ec4a92ad67b6174a3d240c63fa56a6df6017e", "save_path": "github-repos/lean/ImperialCollegeLondon-group-theory-game", "path": "github-repos/lean/ImperialCollegeLondon-group-theory-game/group-theory-game-152ec4a92ad67b6174a3d240c63fa56a6df6017e/src/int/iterate.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4644720442494618}}
{"text": "import applications.functor_category\nimport grothendieck\nimport sheaf\nimport category.element\nimport tactic.equiv_rw\nimport data.quot\nimport pullback_colimit\nimport category.colimits\n\nnamespace category_theory\n\nuniverses v u\n\nvariables {C : Type u} [small_category C] (J : sieve_set C) [grothendieck J]\n\nopen classifier limits category\n\nnoncomputable theory\n\n@[ext]\nstructure closure_operator (α : Type*) [has_le α] :=\n(to_fun : α → α)\n(ord' : ∀ {x y : α}, x ≤ y → to_fun x ≤ to_fun y)\n(inflate' : ∀ x, x ≤ to_fun x)\n(idem' : ∀ x, to_fun (to_fun x) = to_fun x)\n\ninstance (α : Type*) [has_le α] : has_coe_to_fun (closure_operator α) :=\n⟨_, closure_operator.to_fun⟩\n\ninstance (α : Type*) [has_le α] : has_le (closure_operator α) :=\n⟨λ c₁ c₂, ∀ x, c₁ x ≤ c₂ x⟩\n\nlemma closure_operator.ord {α : Type*} [has_le α] (c : closure_operator α) {x y : α} (h : x ≤ y) :\n  c x ≤ c y :=\nc.ord' h\n\nlemma closure_operator.inflate {α : Type*} [has_le α] (c : closure_operator α) (x : α) :\n  x ≤ c x := c.inflate' x\n\nlemma closure_operator.idem {α : Type*} [has_le α] (c : closure_operator α) (x : α) :\n  c (c x) = c x := c.idem' x\n\n/-- The sieve-set induced by a closure operator on sieves. -/\ndef grothendieck_from_natural_operator (c : Π (X : C), closure_operator (sieve X)) :\n  sieve_set C :=\nλ X S, c X S = ⊤\n\n/-- If a closure operator on sieves is natural, it induces a Grothendieck topology. -/\ninstance natural_operator_is_grothendieck (c : Π (X : C), closure_operator (sieve X))\n  (hc : ∀ (X Y : C) (f : X ⟶ Y) (S : sieve Y), (c Y S).pullback f = c _ (S.pullback f)) :\ngrothendieck (grothendieck_from_natural_operator c) :=\n{ max := λ X,\n  begin\n    apply top_unique,\n    apply (c _).inflate,\n  end,\n  stab := λ X Y S hS f,\n  begin\n    change _ = _ at hS,\n    change _ = _,\n    rw [← hc, hS, sieve.pullback_top],\n  end,\n  trans := λ X S hS T hT,\n  begin\n    change _ = _,\n    rw ← (c X).idem,\n    apply top_unique,\n    change _ = _ at hS,\n    rw ← hS,\n    apply (c _).ord,\n    intros Y g hg,\n    rw sieve.pullback_eq_top_iff_mem,\n    rw hc,\n    apply hT g hg,\n  end }\n\n@[simps]\ndef close {c : C} (S : sieve c) : sieve c :=\n{ arrows := λ g, grothendieck.covers J S g.hom,\n  subs := λ d e f h k,\n  begin\n    change S.pullback (h ≫ f) ∈ J e,\n    change S.pullback f ∈ J d at k,\n    rw sieve.pullback_comp,\n    apply grothendieck.stab (S.pullback f) k h,\n  end }\n\n\nlemma close_preserves_order {c : C} {S T : sieve c} (h : S ≤ T) :\n  close J S ≤ close J T :=\nbegin\n  intros d g hg,\n  change S.pullback g ∈ J d at hg,\n  apply grothendieck.superset_covering (sieve.pullback_le_map h g) hg,\nend\n\nlemma close_inflationary {c : C} (S : sieve c) :\n  S ≤ close J S :=\nbegin\n  intros d g hg,\n  change S.pullback g ∈ J d,\n  rw sieve.pullback_eq_top_iff_mem at hg,\n  rw hg,\n  apply grothendieck.max,\nend\n\nlemma close_idem (c : C) (S : sieve c) :\n  close J (close J S) = close J S :=\nbegin\n  apply le_antisymm,\n    intros d g hg,\n    change (close J S).pullback g ∈ J d at hg,\n    apply grothendieck.trans _ hg,\n    intros e g' hg',\n    change (S.pullback g).pullback g' ∈ J e,\n    rw ← S.pullback_comp,\n    exact hg',\n  apply close_preserves_order J (close_inflationary _ _),\nend\n\nlemma close_inter (c : C) (S T : sieve c) :\n  close J (S ⊓ T) = close J S ⊓ close J T :=\nbegin\n  apply le_antisymm,\n  { refine le_inf (close_preserves_order _ inf_le_left) (close_preserves_order _ inf_le_right) },\n  rintros d g ⟨hg₁, hg₂⟩,\n  change S.pullback g ∈ J d at hg₁,\n  change (S ⊓ T).pullback g ∈ J d,\n  rw sieve.pullback_inter,\n  apply grothendieck.intersection_covering hg₁ hg₂,\nend\n\nlemma close_pullback (c d : C) (S : sieve c) (f : d ⟶ c) :\n  close J (S.pullback f) = (close J S).pullback f :=\nbegin\n  ext e g,\n  change (S.pullback f).pullback g ∈ J e ↔ S.pullback (g ≫ f) ∈ J e,\n  rw S.pullback_comp,\nend\n\nlemma incl_iff_closure_eq_top (c : C) (S : sieve c) : S ∈ J c ↔ close J S = ⊤ :=\nbegin\n  split,\n    intro h,\n    ext d f,\n    change S.pullback f ∈ J d ↔ true,\n    simpa using grothendieck.stab S h f,\n  rw [close],\n  intro q,\n  refine grothendieck.trans ⊤ (grothendieck.max _) _ _,\n  intros d g hg,\n  rw ← q at hg,\n  exact hg,\nend\n\n/-- Natural closure operators on the set of sieves are the same thing as Grothendieck topologies. -/\ndef operators_equiv_topology :\n  {c : Π (X : C), closure_operator (sieve X) // ∀ X Y f S, (c Y S).pullback f = c X (S.pullback f)}\n≃ {J : sieve_set C // grothendieck J} :=\n{ to_fun := λ c, ⟨grothendieck_from_natural_operator c.1, category_theory.natural_operator_is_grothendieck _ c.2⟩,\n  inv_fun := λ J, by { haveI := J.2, refine ⟨λ X, ⟨close J.1, λ x y, close_preserves_order _, close_inflationary _, close_idem _ _⟩, λ X Y f S, _⟩, symmetry, apply close_pullback, },\n  left_inv :=\n  begin\n    rintro ⟨c₁, c₂⟩,\n    ext x S y f,\n    dsimp [close, grothendieck.covers, grothendieck_from_natural_operator],\n    change c₁ y (S.pullback f) = ⊤ ↔ over.mk f ∈ (c₁ x S).arrows,\n    rw ← c₂,\n    rw sieve.pullback_eq_top_iff_mem,\n  end,\n  right_inv :=\n  begin\n    rintro ⟨J, _⟩,\n    resetI,\n    ext c S,\n    apply (incl_iff_closure_eq_top J c S).symm,\n  end }\n\n@[simps]\ndef j : Ω (Cᵒᵖ ⥤ Type u) ⟶ Ω (Cᵒᵖ ⥤ Type u) :=\n{ app := λ c S, close J S,\n  naturality' := λ c c' f,\n  begin\n    ext1 S,\n    change sieve c.unop at S,\n    apply close_pullback,\n  end }\n\nlemma yoneda_generates (X Y : Cᵒᵖ ⥤ Type u) (f g : X ⟶ Y)\n  (h : ∀ (c : Cᵒᵖ) (k : yoneda.obj c.unop ⟶ X), k ≫ f = k ≫ g) :\n  f = g :=\nbegin\n  ext c t,\n  specialize h c ((yoneda_sections_small c.unop X).inv t),\n  have := congr_arg (λ i, nat_trans.app i c) h,\n  dsimp [yoneda_lemma, ulift_trivial] at this,\n  have z := congr_fun this (has_hom.hom.unop (𝟙 _)),\n  dsimp at z,\n  rw [X.map_id] at z,\n  exact z,\nend\n\ndef sieve_equiv_arrow (c : C) : sieve c ≃ (yoneda.obj c ⟶ Ω _) :=\n(yoneda_sections_small c (Ω _)).to_equiv.symm\n\nlemma equiv_close (c : C) (S : sieve c) :\n  sieve_equiv_arrow _ (close J S) = sieve_equiv_arrow _ S ≫ j J :=\nbegin\n  ext d f : 3,\n  symmetry,\n  apply close_pullback,\nend\n\ndef sub_repr (c : C) : sieve c ≃ subq (yoneda.obj c) :=\n(sieve_equiv_arrow c).trans classification\n\nlemma sub_repr_eq (c : C) (S : sieve c) : sub_repr c S = subq.mk S.functor_inclusion :=\nbegin\n  change classification _ = _,\n  rw ← classification.eq_symm_apply,\n  ext c' f c'' g,\n  change over.mk (g ≫ f) ∈ S.arrows ↔ ∃ (x : {h // over.mk h ∈ S.arrows}), x.1 = g ≫ f,\n  rw [subtype.exists],\n  simp,\nend\n\ndef sieve_subq (c : C) :\nsieve c ≃o subq (yoneda.obj c) :=\n{ to_equiv := sub_repr c,\n  map_rel_iff' :=\n  begin\n    intros S T,\n    rw [sub_repr_eq, sub_repr_eq],\n    change S ≤ T ↔ nonempty (_ ⟶ _),\n    split,\n    intro h,\n      exact ⟨sub.hom_mk (sieve.le_as_functor h) (sieve.le_as_functor_comm h)⟩,\n    rintro ⟨a⟩ d f hf,\n    let f' := a.left.app (opposite.op d) ⟨f, hf⟩,\n    have := sub.w a,\n    dsimp at *,\n    have q := congr_arg (λ t, nat_trans.app t (opposite.op d)) this,\n    dsimp at q,\n    replace q := congr_fun q ⟨f, hf⟩,\n    dsimp at q,\n    rw ← q,\n    apply (a.left.app (opposite.op d) ⟨f, hf⟩).2,\n  end }\n\nlemma inclusion_inter (c : C) (S T : sieve c) :\n  sieve_subq _ (S ⊓ T) = sieve_subq _ S ⊓ sieve_subq _ T :=\norder_iso.map_inf _ _ _\n\n@[reassoc]\nlemma and_arrow_sieve (c : C) (S T : sieve c) :\n  (prod.lift (sieve_equiv_arrow _ S) (sieve_equiv_arrow _ T) ≫ and_arrow _) = sieve_equiv_arrow _ (S ⊓ T) :=\nbegin\n  have : ∀ (S : sieve _), sieve_equiv_arrow c S = classify (sieve_subq _ S),\n    intro S,\n    change _ = classify (classification (sieve_equiv_arrow c S)),\n    symmetry,\n    apply classification.left_inv,\n  rw [this, this, this],\n  rw and_property,\n  rw inclusion_inter,\nend\n\ninstance : topology (j J) :=\n{ ax1 :=\n  begin\n    ext c ⟨⟩ d f,\n    change J d ((⊤ : sieve _).pullback f) ↔ true,\n    rw sieve.pullback_top,\n    simp only [iff_true],\n    exact grothendieck.max d,\n  end,\n  ax2 :=\n  begin\n    ext c S : 3,\n    apply close_idem,\n  end,\n  ax3 :=\n  begin\n    apply yoneda_generates,\n    intros c k,\n    equiv_rw prod.equiv (yoneda.obj c.unop) (Ω _) (Ω _) at k,\n    cases k with k₁ k₂,\n    change prod.lift k₁ k₂ ≫ _ = prod.lift k₁ k₂ ≫ _ ≫ _,\n    rw prod.lift_map_assoc,\n    equiv_rw (sieve_equiv_arrow c.unop).symm at k₁,\n    equiv_rw (sieve_equiv_arrow c.unop).symm at k₂,\n\n    rw [← equiv_close, ← equiv_close, and_arrow_sieve, and_arrow_sieve_assoc, ← equiv_close],\n    rw (sieve_equiv_arrow _).apply_eq_iff_eq,\n    rw close_inter,\n  end }.\n\n\ndef dense_inclusion (c : C) (S : sieve c) (h : S ∈ J c) : closure.dense (j J) S.functor_inclusion :=\nbegin\n  constructor,\n  change classification (classify (subq.mk _) ≫ _) = _,\n  rw ← sub_repr_eq,\n  dsimp only [sub_repr, equiv.trans],\n  change classification (classification.symm (classification _) ≫ _) = _,\n  rw classification.symm_apply_apply,\n  erw ← equiv_close,\n  change sieve_subq _ _ = _,\n  rw ← order_iso.map_top (sieve_subq c),\n  congr' 1,\n  ext d f,\n  change S.pullback f ∈ J d ↔ true,\n  simpa using grothendieck.stab S h f,\nend\n\nlemma dense_inclusion_iff (c : C) (S : sieve c) (h : closure.dense (j J) S.functor_inclusion) :\n  S ∈ J c :=\nbegin\n  have := h.closure_eq_top,\n  change classification (classify (subq.mk _) ≫ _) = _ at this,\n  rw ← sub_repr_eq at this,\n  dsimp only [sub_repr, equiv.trans] at this,\n  change classification (classification.symm (classification _) ≫ _) = _ at this,\n  rw classification.symm_apply_apply at this,\n  erw ← equiv_close at this,\n  change sieve_subq _ _ = _ at this,\n  rw ← order_iso.map_top (sieve_subq c) at this,\n  erw (sieve_subq c).to_equiv.apply_eq_iff_eq at this,\n  rw close at this,\n  refine grothendieck.trans ⊤ (grothendieck.max _) _ _,\n  intros d g hg,\n  rw ← this at hg,\n  exact hg,\nend\n\ndef jsheaf_is_Jsheaf (P : Cᵒᵖ ⥤ Type u) (h : sheaf_condition (j J) P) : grothendieck.sheaf_condition J P :=\nbegin\n  intros c S γ hS,\n  change S.as_functor ⟶ _ at γ,\n  haveI : closure.dense (j J) S.functor_inclusion := dense_inclusion _ _ _ hS,\n  apply h S.functor_inclusion γ,\nend\n\n-- This can be generalised to show it suffices to check the sheaf condition on a\n-- generating set (in the sense of colimits).\ndef sheaf.yoneda_mk (P : Cᵒᵖ ⥤ Type u)\n  (h : Π c S f' (m : S ⟶ yoneda.obj c) [closure.dense (j J) m], {f : yoneda.obj c ⟶ P // m ≫ f = f' ∧ ∀ a, m ≫ a = f' → a = f}) :\n  sheaf_condition (j J) P :=\nsheaf_condition.mk' _ _\nbegin\n  introsI E A m σ _,\n  let A' : (E.elements)ᵒᵖ → (Cᵒᵖ ⥤ Type u) := λ i, pullback ((the_cocone E).ι.app i) m,\n  let m' : Π (i : E.elementsᵒᵖ), A' i ⟶ yoneda.obj i.unop.1.unop := λ i, pullback.fst,\n  let top_map : Π (i : E.elementsᵒᵖ), A' i ⟶ A := λ i, pullback.snd,\n  have pb : ∀ (i : E.elementsᵒᵖ), m' i ≫ _ = top_map i ≫ m := λ i, pullback.condition,\n  let A'diagram : E.elementsᵒᵖ ⥤ (Cᵒᵖ ⥤ Type u),\n  { refine { functor . obj := A',\n             map := λ i j f,\n              pullback.lift (m' i ≫ yoneda.map f.unop.1.unop) (top_map i)\n                (by erw [← pb i, assoc, (the_cocone E).w f]), map_id' := _, map_comp' := _},\n    { intro j,\n      apply pullback.hom_ext;\n      simp },\n    { intros i₁ i₂ i₃ f g,\n      apply pullback.hom_ext; simp } },\n  let τ : A'diagram ⟶ ((category_of_elements.π E).left_op ⋙ yoneda) :=\n    { nat_trans . app := m', naturality' := λ i j f, pullback.lift_fst _ _ _ },\n  let A'cocone : cocone A'diagram,\n    refine ⟨A, λ i, top_map i, _⟩,\n    intros i j f,\n    rw pullback.lift_snd,\n    apply (comp_id _).symm,\n  let A'colimit := pullback_colimit A'cocone (is_a_limit E) τ m pb (λ i, cone_is_pullback _ _),\n  let h' : Π (i : E.elementsᵒᵖ), {f // m' i ≫ f = top_map i ≫ σ ∧ ∀ a, m' i ≫ a = top_map i ≫ σ → a = f} :=\n    λ i, (h _ _ (top_map i ≫ σ) (m' i)),\n  let h'₁ : Π (i : E.elementsᵒᵖ), yoneda.obj i.unop.1.unop ⟶ P := λ i, (h' i).1,\n  have h'₂ : ∀ (i : E.elementsᵒᵖ), m' i ≫ h'₁ i = top_map i ≫ σ := λ i, (h' i).2.1,\n  have h'₃ : ∀ (i : E.elementsᵒᵖ) a, m' i ≫ a = top_map i ≫ σ → a = h'₁ i := λ i, (h' i).2.2,\n  have legs : ∀ (i j : E.elementsᵒᵖ) (f : i ⟶ j), yoneda.map (has_hom.hom.unop f).1.unop ≫ h'₁ j = h'₁ i ≫ 𝟙 P,\n  { intros,\n    rw comp_id,\n    apply h'₃ i,\n    let hf : A' i ⟶ A' j := pullback.lift (m' i ≫ yoneda.map f.unop.1.unop) (top_map i)\n                              (by erw [← pb i, assoc, (the_cocone E).w f]),\n    have : hf ≫ m' j = m' i ≫ yoneda.map _ := pullback.lift_fst _ _ _,\n    rw ← reassoc_of this,\n    rw h'₂ j,\n    apply pullback.lift_snd_assoc },\n  refine ⟨(is_a_limit E).desc ⟨P, h'₁, legs⟩, _, _⟩,\n  { apply A'colimit.hom_ext,\n    intro i,\n    rw ← pullback.condition_assoc,\n    rw (is_a_limit E).fac,\n    apply h'₂ },\n  { intros q hq,\n    apply (is_a_limit E).hom_ext,\n    intro i,\n    rw (is_a_limit E).fac,\n    apply h'₃ i,\n    rw pullback.condition_assoc,\n    rw hq }\nend.\n\ndef Jsheaf_is_jsheaf (P : Cᵒᵖ ⥤ Type u) (h : grothendieck.sheaf_condition J P) : sheaf_condition (j J) P :=\nsheaf.yoneda_mk J P\nbegin\n  introsI c S' f' m hm,\n  let S := (sub_repr _).symm ⟦sub.mk' m⟧,\n  have same_class := sub_repr_eq _ S,\n  rw (sub_repr _).apply_symm_apply at same_class,\n  have : closure.dense (j J) S.functor_inclusion,\n  refine ⟨_⟩,\n  change closure.operator _ (subq.mk _) = _,\n  rw ← same_class,\n  apply hm.closure_eq_top,\n  have := dense_inclusion_iff J _ S this,\n  have : classifier_of m = classifier_of S.functor_inclusion,\n    change classify ⟦sub.mk' m⟧ = classify ⟦sub.mk' S.functor_inclusion⟧,\n    rw same_class,\n  let i := how_inj_is_classifier m S.functor_inclusion this,\n  have hi : i.hom ≫ _ = _ := c_very_inj this,\n  refine ⟨(h _ S (i.inv ≫ f') ‹S ∈ J c›).1.1.1, _, _⟩,\n  rw [← hi, assoc, (h _ S (i.inv ≫ f') ‹S ∈ J c›).1.1.2], simp,\n  intros a ha,\n  apply subtype.ext_iff.1 ((h _ S (i.inv ≫ f') ‹S ∈ J c›).2 ⟨a, _⟩),\n  rw iso.eq_inv_comp,\n  rw reassoc_of hi,\n  rw ha,\nend\n\ndef equivalent_sheaf_conditions (P : Cᵒᵖ ⥤ Type u) :\n  grothendieck.sheaf_condition J P ≃ sheaf_condition (j J) P :=\n{ to_fun := Jsheaf_is_jsheaf _ _,\n  inv_fun := jsheaf_is_Jsheaf _ _,\n  left_inv := λ _, subsingleton.elim _ _,\n  right_inv := λ _, subsingleton.elim _ _ }\n\nend category_theory", "meta": {"author": "b-mehta", "repo": "topos", "sha": "c9032b11789e36038bc841a1e2b486972421b983", "save_path": "github-repos/lean/b-mehta-topos", "path": "github-repos/lean/b-mehta-topos/topos-c9032b11789e36038bc841a1e2b486972421b983/src/applications/topologies.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4644720378565197}}
{"text": "import TBA.Eulerian.Nat\n\nopen Nat List\n\nnamespace Eq\n\nprotected theorem symm_iff {a b : α} : b = a ↔ a = b := ⟨Eq.symm, Eq.symm⟩ \n\nend Eq\n\nnamespace List\n\n@[simp] theorem length_append {as bs : List α} :\n  length (as ++ bs) = length as + length bs :=\n  match as with\n  | []      => by simp\n  | a :: as => by simp [Nat.succ_add, length_append]\n\ntheorem length_zero_iff_nil {as : List α} : length as = 0 ↔ as = [] :=\n⟨fun e => by cases as; rfl; simp [length_cons] at e, fun e => by rw [e]; rfl⟩\n\ntheorem length_cons_ne_zero {as : List α} {a : α} : length (a :: as) ≠ 0 := by\n  rw [List.length_cons]; exact Nat.succNeZero _\n\n-- Some lemmas about filters\n\n@[simp] theorem filter_nil {p : α → Bool} : filter p [] = [] := by\n  simp [filter, filterAux, reverse, reverseAux]\n\ntheorem cons_eq_append (a : α) (as : List α) : a :: as = [a] ++ as := rfl\n\ntheorem reverseAux_append {rs as : List α} : reverseAux rs as = reverseAux rs [] ++ as :=\n  match rs with\n  | []      => rfl\n  | r :: rs => by\n    simp only [reverseAux]\n    rw [reverseAux_append, reverseAux_append (as := [r]), cons_eq_append r as, append_assoc]\n\ntheorem filterAux_aux {p : α → Bool} (as : List α) :\n  (rs : List α) → filterAux p as rs = rs.reverse ++ (filterAux p as []) :=\n  match as with\n  | [] => by intros; simp [filterAux, reverse, reverseAux];\n  | a :: as => by\n    intro rs\n    simp only [filterAux]\n    cases p a\n    case false => simp [filterAux_aux as rs]\n    case true =>\n      rw [filterAux_aux as (a :: rs), filterAux_aux as [a]]\n      simp only [reverse, reverseAux, List.append, List.cons_append, List.nil_append]\n      rw [reverseAux_append, cons_eq_append _ (filterAux p as []), append_assoc]\n\ntheorem filter_cons (a : α) (as : List α) :\n  filter p (a :: as) = if p a then a :: filter p as else filter p as := by\n  simp only [filter, filterAux]\n  cases p a\n  simp\n  rw [filterAux_aux]; simp [reverse, reverseAux]\n\n@[simp] theorem filter_append {as bs : List α} {p : α → Bool} :\n  filter p (as ++ bs) = filter p as ++ filter p bs := by\n  induction as with\n  | nil      => simp\n  | cons a as ih =>\n    rw [filter_cons, cons_append, filter_cons]\n    cases p a <;> simp [ih]\n\n-- A membership predicate\n\ninductive Mem : α → List α → Prop where\n  | head (a : α) (as : List α)   : Mem a (a::as)\n  | tail (a b : α) (bs : List α) : Mem a bs → Mem a (b::bs)\n\ninfix:50 \" ∈ \" => Mem\n\nclass IsBEqEq (α : Type) [BEq α] : Prop where\n  beq_is_eq {a b : α} : (a == b) = (a = b)\n\ninstance [DecidableEq α] : IsBEqEq α where\n  beq_is_eq := @fun a b => by byCases h : a = b <;> simp_all [BEq.beq, decideEqTrue, decideEqFalse]\n\ninstance [DecidableEq α] : IsBEqEq (α × α) where\n  beq_is_eq := @fun (a₁, a₂) (b₁, b₂) => by byCases h₁ : a₁ = b₁ <;> byCases h₂ : a₂ = b₂ <;> simp_all [BEq.beq, decideEqTrue, decideEqFalse]\n\nexport IsBEqEq (beq_is_eq)\n\nattribute [local simp] beq_is_eq\n\n@[simp] theorem beq_refl [BEq α] [IsBEqEq α] : ((a : α) == a) = true := by\n  simp\n\n@[simp] theorem beq_neq [BEq α] [IsBEqEq α] {a b : α} (h : ¬ a = b) : (a == b) = false := by\n   cases hbeq : a == b <;> simp_all\n\ntheorem length_erase_mem [BEq α] [IsBEqEq α] {a : α} {as : List α} (h : a ∈ as) :\n  length (List.erase as a) + 1 = length as :=\n  match a, as, h with\n  | _, _, Mem.head a bs => by simp [List.erase]\n  | _, _, Mem.tail a b bs h => by\n    simp only [List.erase]\n    match b == a with\n    | true => simp\n    | false => { simp only [length_cons]; rw [←length_erase_mem h] }\n\ntheorem mem_singleton [BEq α] [IsBEqEq α] {a b : α} (h : a ∈ [b]) : a = b := by\n  cases h with\n  | head h       => rfl\n  | tail _ _ _ h => cases h\n\ndef mem_of_nonzero_length [BEq α] [IsBEqEq α] {as : List α} :\n  (h : length as > 0) → { a // a ∈ as } :=\n  match as with\n  | []      => by { simp only [length_nil]; intro fa; cases fa }\n  | a :: as => by { intros; apply Subtype.mk; apply Mem.head }\n\ntheorem mem_append {as bs : List α} : ∀ a, a ∈ (as ++ bs) → a ∈ as ∨ a ∈ bs :=\n  match as with\n  | [] => by intros; apply Or.inr; assumption\n  | a :: as => by \n    simp only [List.cons_append]\n    intros a h\n    cases h with\n    | head h => apply Or.inl; apply Mem.head\n    | tail _ _ _ h =>\n      cases mem_append (as := as) (bs := bs) a h\n      case inl => apply Or.inl; apply Mem.tail; assumption\n      case inr => apply Or.inr; assumption\n\ntheorem mem_of_mem_filter {as : List α} {a : α} {p : α → Bool} : a ∈ filter p as → a ∈ as :=\n  match as with\n  | [] => by intros; assumption\n  | a' :: as => by \n      rw [filter_cons]; cases p a'\n      case false => intro h; apply Mem.tail; apply mem_of_mem_filter h\n      case true => \n        intro h\n        cases h with\n        | head => apply Mem.head\n        | tail _ _ _ h => apply Mem.tail; apply mem_of_mem_filter h\n\ntheorem mem_filter_of_prop {as : List α} {a : α} {p : α → Bool} (ha : a ∈ as) (hpa : p a = true) :\n  a ∈ filter p as := by\n  induction ha with\n  | head a as => rw [filter_cons, hpa]; simp; apply Mem.head\n  | tail a b as ha' ih => \n    rw [filter_cons]\n    cases hpb : p b\n    case false => simp; exact ih hpa\n    case true  => simp; apply Mem.tail; exact ih hpa\n\ntheorem filterProp_of_mem {as : List α} {p : α → Bool} {a : α} : a ∈ filter p as → p a = true :=\n  match as with\n  | [] => by intro h; cases h\n  | a' :: as => by\n      rw [filter_cons]; byCases hpa : p a'\n      case inr => simp [hpa]; exact filterProp_of_mem\n      case inl => simp [hpa]; intro h; cases h; assumption; apply filterProp_of_mem; assumption\n\ntheorem mem_split {a : α} {as : List α} (h : a ∈ as) : ∃ s t, as = s ++ a :: t :=\n  match a, as, h with\n  | _, _, Mem.head a bs     => ⟨[], ⟨bs, rfl⟩⟩\n  | _, _, Mem.tail a b bs h =>\n    match bs, mem_split h with\n    | _, ⟨s, ⟨t, rfl⟩⟩ => ⟨b::s, ⟨t, List.cons_append .. ▸ rfl⟩⟩\n\n-- Couting elements\n\nsection Count\nvariable [BEq α] [IsBEqEq α] (as bs as' bs' : List α) (a b : α)\n\ndef count : Nat := (as.filter $ fun b => b == a).length\n\n@[simp] theorem count_empty : count [] a = 0 := by simp [count]\n\n@[simp] theorem count_self_cons : (a :: as).count a = Nat.succ (as.count a) := by\n  simp [count, filter_cons]\n\ntheorem count_neq_cons {as} {a b : α} (h : ¬ b = a) : (b :: as).count a = as.count a := by\n  simp [count, filter_cons, h]\n\n@[simp] theorem count_append : (as ++ bs).count a = as.count a + bs.count a :=\n  by simp [count]\n\n--set_option trace.Meta.Tactic.simp true\ntheorem count_erase {as : List α} {a b : α} :\n  (as.erase a).count b = if (a == b) then (as.count b) - 1 else as.count b :=\n  match as with\n  | [] => by simp only [List.erase]; cases (a == b) <;> simp\n  | a' :: as => by\n    simp only [List.erase]\n    byCases h : a' = a\n    case inl => \n      cases h\n      simp only [beq_refl]\n      byCases h' : a = b\n      case inl => cases h'; simp only [beq_refl, Lean.Simp.ite_True, Nat.succ_sub_succ, count_self_cons]; apply Nat.sub_zero\n      case inr => rw [beq_neq h']; simp [count_neq_cons h']\n    case inr =>\n      rw [beq_neq h]\n      byCases h' : a' = b\n      case inl => cases h'; simp [count_erase (as := as), beq_neq (Ne.symm h)]\n      case inr => simp [count_neq_cons h', count_neq_cons h', count_erase]\n\ntheorem count_le_cons : as.count a ≤ (b :: as).count a := by\n  byCases h : (b = a)\n  case inl => cases h; simp [count_self_cons, Nat.leSucc]\n  case inr => rw [count_neq_cons h]; simp [Nat.leRefl]\n\ntheorem mem_nonzeroCount {as : List α} {a : α}: a ∈ as ↔ as.count a > 0 := by\n  apply Iff.intro\n  case mp =>\n    intro h\n    induction h with\n    | head a => simp [Nat.zeroLtSucc]\n    | tail _ _ _ h ih => apply Nat.ltOfLtOfLe ih; apply count_le_cons\n  case mpr =>\n    intro h\n    let ⟨a', ha'⟩ := mem_of_nonzero_length h\n    let foo := filterProp_of_mem ha'\n    rw [←beq_is_eq.mp foo]\n    apply mem_of_mem_filter ha'\n    \n-- Erasing elements from lists\n  \ntheorem erase_comm {as : List α} : (as.erase a).erase b  = (as.erase b).erase a :=\n  match as with\n  | [] => rfl\n  | a' :: as => by\n    byCases h : a' = a\n    case inl => \n      cases h; simp only [List.erase]\n      byCases h' : b = a\n      case inl => cases h'; simp\n      case inr => rw [beq_neq (Ne.symm h')]; simp [List.erase]\n    case inr =>\n      simp only [List.erase]\n      rw [beq_neq h]\n      byCases h' : a' = b\n      case inl => cases h'; simp [List.erase]\n      case inr => simp [List.erase, beq_neq h', beq_neq h, erase_comm (as := as)]\n\ntheorem filter_erase_false {as : List α} {a : α} {p : α → Bool} (h : p a = false) :\n  filter p (as.erase a) = filter p as :=\n  match as with\n  | [] => by simp [List.erase]\n  | b :: as => by\n    simp only [List.erase, filter_cons]\n    byCases h' : b = a\n    case inl => cases h'; simp [h]\n    case inr => simp [h', filter_cons]; rw [filter_erase_false h]\n\ntheorem filter_erase_true {as : List α} {a : α} {p : α → Bool} (hpa : p a = true) :\n  filter p (as.erase a) = (filter p as).erase a :=\n  match as with\n  | [] => rfl\n  | b :: as => by\n    simp\n    byCases h : b = a\n    case inl => cases h; simp [List.erase, filter_cons, hpa]\n    case inr =>\n      simp only [List.erase, beq_neq h, filter_cons]\n      cases hpb : p b\n      case false => exact filter_erase_true hpa\n      case true => rw [filter_erase_true hpa]; simp [List.erase, h]\n\ndef eraseAll (as bs : List α) : List α :=\n  match bs with\n  | []      => as\n  | b :: bs => eraseAll (as.erase b) bs\n\ninfixl:55 \" -l \" => eraseAll\n\ntheorem erase_eraseAll {as bs : List α} {a : α} : (as.erase a) -l bs = (as -l bs).erase a :=\n  match bs with\n  | [] => rfl\n  | b :: bs => by simp only [eraseAll]; rw [←erase_eraseAll, erase_comm]\n\n@[simp] theorem count_eraseAll (as bs : List α) (a : α) :\n  (as -l bs).count a = as.count a - bs.count a :=\n  match bs with\n  | [] => rfl\n  | b :: bs => by\n    simp only [eraseAll]; rw [erase_eraseAll]; simp\n    byCases hba : b = a;\n    case inl => cases hba; rw [count_self_cons, count_erase, count_eraseAll as bs a, beq_refl]; rfl\n    case inr => rw [count_erase, beq_neq hba, count_eraseAll as bs a, count_neq_cons]; repeat simp_all\n\n-- Lists which are permutations of each other, and sublists modulo permutation\n\ndef isPermEqvTo : Prop := ∀ a, as.count a = bs.count a\ninfixl:50 \" ≃ \" => isPermEqvTo -- Type as \\simeq\n\ndef isPermSubOf : Prop := ∀ a, as.count a ≤ bs.count a\ninfixl:50 \" ⊆ \" => isPermSubOf -- Type as \\sub\n\ntheorem permSubOfEraseSub : (as -l bs) ⊆ as := fun a => by simp [Nat.subLe]\n\ntheorem mem_of_mem_eraseAll {as bs : List α} {a : α} : a ∈ (as -l bs) → a ∈ as := by\n  rw [mem_nonzeroCount, mem_nonzeroCount, count_eraseAll]\n  intro h; exact Nat.ltOfLtOfLe h (Nat.subLe _ _)\n\ntheorem permSubEraseAllLength {as bs : List α} : bs ⊆ as → length (as -l bs) = length as - length bs :=\n  match bs with\n  | [] => fun _ => rfl\n  | b :: bs => fun hsub => by\n    simp only [eraseAll, length_cons]\n    have hbas : b ∈ as := by\n      have hb := hsub b\n      rw [count_self_cons] at hb\n      rw [mem_nonzeroCount]\n      exact Nat.ltOfLeOfLt (zeroLe _) (ltOfSuccLe hb)\n    have hsub' : bs.isPermSubOf (as.erase b) := fun c => by\n      have hc := hsub c\n      byCases h : b = c\n      case inl =>\n        cases h\n        rw [count_self_cons] at hc\n        rw [count_erase]\n        simp [leOfSuccLeSucc (Nat.leTrans hc leSuccSubOne)]\n      case inr =>\n        rw [count_neq_cons h] at hc\n        apply Nat.leTrans hc\n        rw [count_erase, beq_neq h]\n        simp [Nat.leRefl]\n    rw [permSubEraseAllLength hsub', ←length_erase_mem hbas, Nat.succ_sub_succ]\n\ntheorem permSubExtend {as bs : List α} {b} (hsub : bs ⊆ as) (ha : b ∈ (as -l bs)) : (b :: bs) ⊆ as := by\n  intro a\n  rw [mem_nonzeroCount, count_eraseAll, ←zeroLtIffSub] at ha\n  byCases h : b = a\n  case inl => cases h; simp; assumption\n  case inr => rw [count_neq_cons h]; apply hsub\n\ndef permSubObtainComplement {as bs : List α} (hsub : bs ⊆ as) \n    (hlength : bs.length < as.length) : { e // e ∈ as -l bs} := by\n  have hl : (as -l bs).length > 0 := by rw [permSubEraseAllLength hsub, ←zeroLtIffSub]; assumption\n  revert hl; cases as -l bs\n  case nil => simp only [length_nil]; intro hl'; cases hl'\n  case cons => intros; exact ⟨_, Mem.head _ _⟩\n\ntheorem permSubEqvClosed {as bs bs' : List α} (heqv : bs ≃ bs') (hsub : bs ⊆ as) : bs' ⊆ as :=\n  fun a => by rw [←heqv a]; exact hsub a\n\ntheorem permSubSingleton {as : List α} {a : α} : a ∈ as → [a] ⊆ as := by\n  intros ha b\n  rw [mem_nonzeroCount] at ha\n  byCases h : a = b\n  case inl => cases h; simp [count_self_cons]; assumption\n  case inr => rw [count_neq_cons h]; simp [Nat.zeroLe]\n\ntheorem permEqvRotate : (as ++ bs) ≃ (bs ++ as) :=\n  fun a => by simp [Nat.add_comm];\n\ntheorem permEqvRefl {as : List α} : as ≃ as :=\n  fun a => rfl\n\ntheorem permEqvTrans {as bs cs : List α} (h : as ≃ bs) (h' : bs ≃ cs) : as ≃ cs :=\n  fun a => Eq.trans (h a) (h' a)\n\ntheorem permEqvSymm {as bs : List α} (h : as ≃ bs) : bs ≃ as :=\n  fun a => by simp [Nat.add_comm, h a]\n\ntheorem permEqvToEraseAppend {as bs : List α} (ps : bs ⊆ as) : as ≃ ((as -l bs) ++ bs) :=\n  fun a => by simp only [count_append, count_eraseAll]; rw [←Nat.le_subAdd (ps a)]\n\ntheorem permEqvToEraseCons {as : List α} {a : α} (h : a ∈ as) : as ≃ (a :: (as.erase a)) := by\n  exact permEqvTrans (permEqvToEraseAppend (permSubSingleton h)) (permEqvRotate _ _)\n\ntheorem permEqvCons {as bs : List α} {a : α} (h : as ≃ bs) : (a :: as) ≃ (a :: bs) := by\n  intro b\n  byCases hba : (a = b)\n  case inl => cases hba; simp [count_self_cons, h a];\n  case inr => rw [count_neq_cons hba, count_neq_cons hba, h b]\n\ntheorem permSubEraseOfpermEqvCons {as bs : List α} {a : α} (h : (a :: as) ⊆ bs) :\n  as ⊆ (bs.erase a) := fun b => by\n  let ha := h a\n  byCases h' : a = b\n  case inl =>\n    cases h'\n    rw [count_erase]\n    rw [count_self_cons] at ha\n    simp [Nat.leOfSuccLeSucc (Nat.leTrans ha leSuccSubOne)]\n  case inr =>\n    let hb := h b\n    rw [count_neq_cons h'] at hb\n    rw [count_erase, beq_neq h']\n    exact hb\n\ntheorem permEqvOfPermSub {as bs : List α} : as ⊆ bs → as.length = bs.length → as ≃ bs :=\n  match as with\n  | [] => fun hsub hl => by\n    rw [length_nil, Eq.symm_iff, length_zero_iff_nil] at hl\n    rw [hl]; intro b; rfl\n  | a :: as => fun hsub hl => by\n    have habs : a ∈ bs := by\n      rw [mem_nonzeroCount]\n      let hsuba := hsub a\n      simp only [count_self_cons] at hsuba\n      exact Nat.ltOfLtOfLe (Nat.zeroLtSucc _) hsuba\n    have hsub' : as.isPermSubOf (bs.erase a) := permSubEraseOfpermEqvCons hsub\n    have hl' : as.length = (bs.erase a).length := by\n      apply Nat.add_right_cancel (m := 1)\n      rw [length_erase_mem habs, ←hl, length_cons]\n    have hp : bs.isPermEqvTo (a :: (bs.erase a)) := permEqvToEraseCons habs\n    exact permEqvTrans (permEqvCons (permEqvOfPermSub hsub' hl')) (permEqvSymm hp)\n\ntheorem permEqvMemClosed {as bs : List α} {a : α} (hp : as ≃ bs) : a ∈ as → a ∈ bs := by\n  rw [mem_nonzeroCount, mem_nonzeroCount, hp a]; intros; assumption\n\ntheorem permEqvEraseOfpermEqvCons {as bs : List α} {a : α} (h : (a :: as) ≃ bs) : as ≃ (bs.erase a) := fun a' => by\n  let ha := h a\n  byCases h' : a = a'\n  case inl => \n    cases h'\n    rw [count_erase]\n    simp only [beq_refl, Lean.Simp.ite_True]\n    rw [←ha, count_self_cons, succ_sub_succ,  Nat.sub_zero]\n  case inr =>\n    let ha' := h a'\n    rw [count_neq_cons h'] at ha'\n    rw [count_erase, beq_neq h']\n    exact ha'\n\ntheorem permEqvLength {as bs : List α} : as ≃ bs → as.length = bs.length :=\n  match as with\n  | [] =>\n    match bs with\n    | [] => fun _ => rfl\n    | b :: bs => fun h => by\n      let hb := h b\n      simp only [count] at hb; rw [filter_cons, beq_refl] at hb\n      simp at hb\n  | a :: as => fun h => by\n    let ha := h a\n    rw [count_self_cons] at ha\n    rw [length_cons, permEqvLength (permEqvEraseOfpermEqvCons h)]\n    exact length_erase_mem (mem_nonzeroCount.mpr (Nat.ltOfLtOfEq (Nat.zeroLtSucc (count as a)) ha))\n\ntheorem permEqv_filter_erase_true {as : List α} {a : α} {p : α → Bool} (hpa : p a = true) (ha : a ∈ as) :\n  (a :: filter p (List.erase as a)) ≃ (filter p as) := by\n  intro b\n  byCases h : a = b\n  case inl =>\n    cases h\n    rw [count_self_cons, filter_erase_true hpa, count_erase]\n    simp only [beq_refl, Lean.Simp.ite_True]\n    have h' : 1 ≤ count (filter p as) a := by\n      apply Nat.succLeOfLt\n      apply mem_nonzeroCount.mp\n      apply mem_filter_of_prop ha hpa\n    exact Eq.symm (le_subAdd h')\n  case inr =>\n    rw [count_neq_cons h, filter_erase_true hpa, count_erase, beq_neq h]\n    simp\n\ntheorem permEqvFilter {as bs : List α} (p : α → Bool) : as ≃ bs → (filter p as) ≃ (filter p bs) :=\n  match as with\n  | [] => by\n    intro h\n    rw [length_zero_iff_nil.mp $ Eq.symm (permEqvLength h)]\n    exact permEqvRefl\n  | a :: as => by\n    intro h\n    rw [filter_cons]\n    have h' := permEqvFilter p (permEqvEraseOfpermEqvCons h)\n    cases hpa : p a with\n    | true =>\n      simp only [beq_refl, Lean.Simp.ite_True]\n      apply permEqvTrans (permEqvCons h')\n      have ha : a ∈ bs := by rw [mem_nonzeroCount, ←h a]; simp [zeroLtSucc]\n      exact permEqv_filter_erase_true (as := bs) hpa ha\n    | false =>\n      refine permEqvTrans h' ?_\n      rw [filter_erase_false hpa]\n      exact permEqvRefl\n\nend Count\n\nend List\n", "meta": {"author": "IPDSnelting", "repo": "tba-2021", "sha": "b6390e55b768423d3266969e81d19290129c5914", "save_path": "github-repos/lean/IPDSnelting-tba-2021", "path": "github-repos/lean/IPDSnelting-tba-2021/tba-2021-b6390e55b768423d3266969e81d19290129c5914/TBA/Eulerian/ListNoDecEq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593171945417, "lm_q2_score": 0.7461390043208003, "lm_q1q2_score": 0.46444117516174055}}
{"text": "/-\nAuthor: <Redacted for anonymized submission>\n-/\n-- import snarks.groth16.declarations\nimport ...attributes\nimport ...integral_domain_tactic\nimport ...general_lemmas.polynomial_degree\nimport data.mv_polynomial.basic\nimport data.mv_polynomial.funext\nimport data.polynomial.field_division\nimport algebra.polynomial.big_operators\n-- import ...attributes\nimport .vars\n\n/-!\n# Knowledge Soundness\n\nThis file proves the knowledge-soundness property of the Groth16 system for type III pairings, as \npresented in \"Another Look at Extraction and Randomization of Groth’s zk-SNARK\" by \n[Baghery et al.](https://eprint.iacr.org/2020/811.pdf).\n\n-/\n\nopen_locale big_operators classical\n\nsection groth16\n\nopen mv_polynomial groth16\n\nnoncomputable theory\n\nuniverses u\n\n\n/-- The finite field parameter of our SNARK -/\nparameter {F : Type u}\nparameter [field F]\n\n/-- The naturals representing:\n  n_stmt - the statement size, \n  n_wit - the witness size -/ \nparameters {n_stmt n_wit n_var : ℕ}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt → (polynomial F) }\nparameter {u_wit : fin n_wit → (polynomial F) }\nparameter {v_stmt : fin n_stmt → (polynomial F) }\nparameter {v_wit : fin n_wit → (polynomial F) }\nparameter {w_stmt : fin n_stmt → (polynomial F) }\nparameter {w_wit : fin n_wit → (polynomial F) }\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit → F} \n/-- t is the polynomial divisibility by which is used to verify satisfaction of the SSP -/\ndef t : polynomial F := ∏ i in (finset.fin_range n_wit), (polynomial.X - polynomial.C (r i))\n-- TODO this could potentially be spun off into a mathlib definition\n\n\n/-- Checks whether a statement witness pair satisfies the SSP -/\ndef satisfying (a_stmt : fin n_stmt → F ) (a_wit : fin n_wit → F) := \n((∑ i in (finset.fin_range n_stmt), a_stmt i • u_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • u_wit i))\n  * \n(∑ i in (finset.fin_range n_stmt), a_stmt i • v_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • v_wit i))\n  -\n(∑ i in (finset.fin_range n_stmt), a_stmt i • w_stmt i\n  + (∑ i in (finset.fin_range n_wit), a_wit i • w_wit i)))\n   %ₘ t = 0\n\n\nrun_cmd mk_simp_attr `crs\nrun_cmd tactic.add_doc_string `simp_attr.crs \"Attribute for defintions of CRS elements\"\n\n/-- The crs elements \nThese funtions are actually multivariate Laurent polynomials of the toxic waste samples, \nbut we represent them here as functions on assignments of the variables to values.\n-/\n@[crs]\ndef crs_α  (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.α)\n@[crs]\ndef crs_β (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.β)\n@[crs]\ndef crs_γ (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.γ)\n@[crs]\ndef crs_δ (f : groth16.vars → F) : polynomial F := polynomial.C (f vars.δ)\n@[crs]\ndef crs_powers_of_x (i : fin n_var) (f : groth16.vars → F) : polynomial F := ((polynomial.X)^(i : ℕ))\n@[crs]\ndef crs_l (i : fin n_stmt) (f : groth16.vars → F) : polynomial F := \npolynomial.C (1 / f vars.γ) * (polynomial.C (f vars.β / f vars.γ) * u_stmt i\n+\npolynomial.C  (f vars.α / f vars.γ) * v_stmt i\n+\n(w_stmt i)) \n@[crs]\ndef crs_m (i : fin n_wit) (f : groth16.vars → F) : polynomial F := \npolynomial.C (1 / f vars.δ) * (polynomial.C  (f vars.β / f vars.δ) * (u_wit i)\n+\npolynomial.C  (f vars.α / f vars.δ) * (v_wit i)\n+\n(w_wit i)) \n@[crs]\ndef crs_n (i : fin (n_var - 1)) (f : groth16.vars → F) : polynomial F := \n(polynomial.X)^(i : ℕ) * t * polynomial.C (1 / f vars.δ)\n\n/-- The coefficients of the CRS elements in the algebraic adversary's representation -/\nparameters {A_α A_β A_γ A_δ B_α B_β B_γ B_δ C_α C_β C_γ C_δ  : F}\nparameters {A_x B_x C_x : fin n_var → F}\nparameters {A_l B_l C_l : fin n_stmt → F}\nparameters {A_m B_m C_m : fin n_wit → F}\nparameters {A_h B_h C_h : fin (n_var-1) → F}\n\n\n/-- Polynomial forms of the adversary's proof representation -/\ndef A : (groth16.vars → F) -> polynomial F := λ f,\n  polynomial.C A_α * (crs_α f)\n\n\ndef B : (groth16.vars → F) -> polynomial F  :=  λ f,\n  polynomial.C B_β * crs_β f\n\n\ndef C : (groth16.vars → F) -> polynomial F  :=  λ f,\n  polynomial.C C_α * crs_α f\n\n\n\nlocal notation `groth16polynomial` := mv_polynomial vars (polynomial F)\n\n\n/-- The modified crs elements \nthese are multivariate (non-Laurent!) polynomials of the toxic waste samples, \nobtained by multiplying the Laurent polynomial forms of the CRS through by γδ. \nWe will later prove that the laurent polynomial equation is equivalent to a similar equation of the modified crs elements, allowing us to construct a proof in terms of polynomials -/\n@[crs]\ndef crs'_α  : groth16polynomial := X vars.α * X vars.γ * X vars.δ\n@[crs]\ndef crs'_β : groth16polynomial := X vars.β * X vars.γ * X vars.δ\n@[crs]\ndef crs'_γ : groth16polynomial := X vars.γ * X vars.γ * X vars.δ\n@[crs]\ndef crs'_δ : groth16polynomial := X vars.δ * X vars.γ * X vars.δ\n@[crs]\ndef crs'_powers_of_x (i : fin n_var) : (groth16polynomial) := mv_polynomial.C (polynomial.X ^ (i : ℕ)) * X vars.γ * X vars.δ\n-- I define prodcuts of these crs elements without the division, then later claim identities. Is this right?\n@[crs]\ndef crs'_l (i : fin n_stmt) : (groth16polynomial) := \n(X vars.β * X vars.δ) * mv_polynomial.C (u_stmt i)\n+\n(X vars.α * X vars.δ) * mv_polynomial.C (v_stmt i)\n+\nX vars.δ * mv_polynomial.C (w_stmt i)\n@[crs]\ndef crs'_m (i : fin n_wit) : (groth16polynomial) := \n(X vars.β * X vars.γ) * mv_polynomial.C (u_wit i)\n+\n(X vars.α * X vars.γ) * mv_polynomial.C (v_wit i)\n+\nX vars.γ * mv_polynomial.C (w_wit i)\n@[crs]\ndef crs'_t (i : fin (n_var - 1)) : (groth16polynomial) := \nX vars.γ * mv_polynomial.C ((polynomial.X)^(i : ℕ) * t)\n\n\n/-- Polynomial form of A in the adversary's proof representation -/\ndef A'  : groth16polynomial := \n  crs'_α * mv_polynomial.C (polynomial.C (A_α))\n  +\n  crs'_β * mv_polynomial.C (polynomial.C (A_β))\n\n\n/-- Polynomial form of B in the adversary's proof representation -/\ndef B'  : groth16polynomial := \n  crs'_β * mv_polynomial.C (polynomial.C (B_β))\n\n\n/-- Polynomial form of C in the adversary's proof representation -/\ndef C'  : groth16polynomial := \n  crs'_α * mv_polynomial.C (polynomial.C (C_α))\n  +\n  crs'_β * mv_polynomial.C (polynomial.C (C_β))\n  + \n  crs'_δ * mv_polynomial.C (polynomial.C (C_δ))\n\n\n\n\n\n\nlemma modification_equivalence (a_stmt : fin n_stmt → F ) : \n  A * B = C -> A' * B' = C'\n:=\nbegin\n  -- TODO different now that we switch to mv_poly vars (poly F)\n  -- rw verified,\n  -- rw verified',\n  intro h,\n  -- Apply functional extensionality\n  simp [A', B', C'],\n  rw function.funext_iff at h,\n  simp [A, B, C] at h,\n\n\nend\n\nend groth16", "meta": {"author": "BoltonBailey", "repo": "formal-snarks-project", "sha": "154414784f90a1e257162fcbdd7e805ecb2a49c2", "save_path": "github-repos/lean/BoltonBailey-formal-snarks-project", "path": "github-repos/lean/BoltonBailey-formal-snarks-project/formal-snarks-project-154414784f90a1e257162fcbdd7e805ecb2a49c2/src/snarks/groth16typeIII/mwe.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199714402813, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.46443553502463264}}
{"text": "lemma contrapositive2 (P Q : Prop) : (¬ Q → ¬ P) → (P → Q) :=\nbegin\nby_cases p : P; by_cases q : Q,\nintros h p2,\nexact q,\nrepeat { tauto! },\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/5-advanced-proposition-world/l10.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702880639792, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4643779065887792}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n\n! This file was ported from Lean 3 source module topology.fiber_bundle.trivialization\n! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.Bundle\nimport Mathlib.Topology.Algebra.Order.Field\nimport Mathlib.Topology.LocalHomeomorph\n\n/-!\n# Trivializations\n\n## Main definitions\n\n### Basic definitions\n\n* `Trivialization F p` : structure extending local homeomorphisms, defining a local\n  trivialization of a topological space `Z` with projection `p` and fiber `F`.\n\n* `Pretrivialization F proj` : trivialization as a local equivalence, mainly used when the\n  topology on the total space has not yet been defined.\n\n### Operations on bundles\n\nWe provide the following operations on `Trivialization`s.\n\n* `Trivialization.compHomeomorph`: given a local trivialization `e` of a fiber bundle\n  `p : Z → B` and a homeomorphism `h : Z' ≃ₜ Z`, returns a local trivialization of the fiber bundle\n  `p ∘ h`.\n\n## Implementation notes\n\nPreviously, in mathlib, there was a structure `topological_vector_bundle.trivialization` which\nextended another structure `topological_fibre_bundle.trivialization` by a linearity hypothesis. As\nof PR leanprover-community/mathlib#17359, we have changed this to a single structure\n`Trivialization` (no namespace), together with a mixin class `trivialization.is_linear`.\n\nThis permits all the *data* of a vector bundle to be held at the level of fibre bundles, so that the\nsame trivializations can underlie an object's structure as (say) a vector bundle over `ℂ` and as a\nvector bundle over `ℝ`, as well as its structure simply as a fibre bundle.\n\nThis might be a little surprising, given the general trend of the library to ever-increased\nbundling.  But in this case the typical motivation for more bundling does not apply: there is no\nalgebraic or order structure on the whole type of linear (say) trivializations of a bundle.\nIndeed, since trivializations only have meaning on their base sets (taking junk values outside), the\ntype of linear trivializations is not even particularly well-behaved.\n-/\n\n\nopen TopologicalSpace Filter Set Function Bundle Topology\nopen scoped Classical\n\nvariable {ι : Type _} {B : Type _} {F : Type _} {E : B → Type _}\n\nvariable (F) {Z : Type _} [TopologicalSpace B] [TopologicalSpace F] {proj : Z → B}\n\n/-- This structure contains the information left for a local trivialization (which is implemented\nbelow as `Trivialization F proj`) if the total space has not been given a topology, but we\nhave a topology on both the fiber and the base space. Through the construction\n`topological_fiber_prebundle F proj` it will be possible to promote a\n`Pretrivialization F proj` to a `Trivialization F proj`. -/\nstructure Pretrivialization (proj : Z → B) extends LocalEquiv Z (B × F) where\n  open_target : IsOpen target\n  baseSet : Set B\n  open_baseSet : IsOpen baseSet\n  source_eq : source = proj ⁻¹' baseSet\n  target_eq : target = baseSet ×ˢ univ\n  proj_toFun : ∀ p ∈ source, (toFun p).1 = proj p\n#align pretrivialization Pretrivialization\n\nnamespace Pretrivialization\n\nvariable {F}\nvariable (e : Pretrivialization F proj) {x : Z}\n\n/-- Coercion of a pretrivialization to a function. We don't use `e.toFun` in the `CoeFun` instance\nbecause it is actually `e.toLocalEquiv.toFun`, so `simp` will apply lemmas about\n`toLocalEquiv`. While we may want to switch to this behavior later, doing it mid-port will break a\nlot of proofs.  -/\n@[coe] def toFun' : Z → (B × F) := e.toFun\n\ninstance : CoeFun (Pretrivialization F proj) fun _ => Z → B × F := ⟨toFun'⟩\n\n@[ext]\nlemma ext' (e e' : Pretrivialization F proj) (h₁ : e.toLocalEquiv = e'.toLocalEquiv)\n    (h₂ : e.baseSet = e'.baseSet) : e = e' := by\n  cases e; cases e'; congr\n#align pretrivialization.ext Pretrivialization.ext'\n\n-- porting note: todo: move `ext` here?\nlemma ext {e e' : Pretrivialization F proj} (h₁ : ∀ x, e x = e' x)\n    (h₂ : ∀ x, e.toLocalEquiv.symm x = e'.toLocalEquiv.symm x) (h₃ : e.baseSet = e'.baseSet) :\n    e = e' := by\n  ext1 <;> [ext1, exact h₃]\n  · apply h₁\n  · apply h₂\n  · rw [e.source_eq, e'.source_eq, h₃]\n\n/-- If the fiber is nonempty, then the projection to -/\nlemma toLocalEquiv_injective [Nonempty F] :\n    Injective (toLocalEquiv : Pretrivialization F proj → LocalEquiv Z (B × F)) := fun e e' h => by\n  refine ext' _ _ h ?_\n  simpa only [fst_image_prod, univ_nonempty, target_eq]\n    using congr_arg (Prod.fst '' LocalEquiv.target ·) h\n\n@[simp, mfld_simps]\ntheorem coe_coe : ⇑e.toLocalEquiv = e :=\n  rfl\n#align pretrivialization.coe_coe Pretrivialization.coe_coe\n\n@[simp, mfld_simps]\ntheorem coe_fst (ex : x ∈ e.source) : (e x).1 = proj x :=\n  e.proj_toFun x ex\n#align pretrivialization.coe_fst Pretrivialization.coe_fst\n\ntheorem mem_source : x ∈ e.source ↔ proj x ∈ e.baseSet := by rw [e.source_eq, mem_preimage]\n#align pretrivialization.mem_source Pretrivialization.mem_source\n\ntheorem coe_fst' (ex : proj x ∈ e.baseSet) : (e x).1 = proj x :=\n  e.coe_fst (e.mem_source.2 ex)\n#align pretrivialization.coe_fst' Pretrivialization.coe_fst'\n\nprotected theorem eqOn : EqOn (Prod.fst ∘ e) proj e.source := fun _ hx => e.coe_fst hx\n#align pretrivialization.eq_on Pretrivialization.eqOn\n\ntheorem mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x :=\n  Prod.ext (e.coe_fst ex).symm rfl\n#align pretrivialization.mk_proj_snd Pretrivialization.mk_proj_snd\n\ntheorem mk_proj_snd' (ex : proj x ∈ e.baseSet) : (proj x, (e x).2) = e x :=\n  Prod.ext (e.coe_fst' ex).symm rfl\n#align pretrivialization.mk_proj_snd' Pretrivialization.mk_proj_snd'\n\n/-- Composition of inverse and coercion from the subtype of the target. -/\ndef setSymm : e.target → Z :=\n  e.target.restrict e.toLocalEquiv.symm\n#align pretrivialization.set_symm Pretrivialization.setSymm\n\ntheorem mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.baseSet := by\n  rw [e.target_eq, prod_univ, mem_preimage]\n#align pretrivialization.mem_target Pretrivialization.mem_target\n\ntheorem proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.toLocalEquiv.symm x) = x.1 := by\n  have := (e.coe_fst (e.map_target hx)).symm\n  rwa [← e.coe_coe, e.right_inv hx] at this\n#align pretrivialization.proj_symm_apply Pretrivialization.proj_symm_apply\n\ntheorem proj_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) :\n    proj (e.toLocalEquiv.symm (b, x)) = b :=\n  e.proj_symm_apply (e.mem_target.2 hx)\n#align pretrivialization.proj_symm_apply' Pretrivialization.proj_symm_apply'\n\ntheorem proj_surjOn_baseSet [Nonempty F] : Set.SurjOn proj e.source e.baseSet := fun b hb =>\n  let ⟨y⟩ := ‹Nonempty F›\n  ⟨e.toLocalEquiv.symm (b, y), e.toLocalEquiv.map_target <| e.mem_target.2 hb,\n    e.proj_symm_apply' hb⟩\n#align pretrivialization.proj_surj_on_base_set Pretrivialization.proj_surjOn_baseSet\n\ntheorem apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.toLocalEquiv.symm x) = x :=\n  e.toLocalEquiv.right_inv hx\n#align pretrivialization.apply_symm_apply Pretrivialization.apply_symm_apply\n\ntheorem apply_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) :\n    e (e.toLocalEquiv.symm (b, x)) = (b, x) :=\n  e.apply_symm_apply (e.mem_target.2 hx)\n#align pretrivialization.apply_symm_apply' Pretrivialization.apply_symm_apply'\n\ntheorem symm_apply_apply {x : Z} (hx : x ∈ e.source) : e.toLocalEquiv.symm (e x) = x :=\n  e.toLocalEquiv.left_inv hx\n#align pretrivialization.symm_apply_apply Pretrivialization.symm_apply_apply\n\n@[simp, mfld_simps]\ntheorem symm_apply_mk_proj {x : Z} (ex : x ∈ e.source) :\n    e.toLocalEquiv.symm (proj x, (e x).2) = x := by\n  rw [← e.coe_fst ex, Prod.mk.eta, ← e.coe_coe, e.left_inv ex]\n#align pretrivialization.symm_apply_mk_proj Pretrivialization.symm_apply_mk_proj\n\n@[simp, mfld_simps]\ntheorem preimage_symm_proj_baseSet :\n    e.toLocalEquiv.symm ⁻¹' (proj ⁻¹' e.baseSet) ∩ e.target = e.target := by\n  refine' inter_eq_right_iff_subset.mpr fun x hx => _\n  simp only [mem_preimage, LocalEquiv.invFun_as_coe, e.proj_symm_apply hx]\n  exact e.mem_target.mp hx\n#align pretrivialization.preimage_symm_proj_base_set Pretrivialization.preimage_symm_proj_baseSet\n\n@[simp, mfld_simps]\ntheorem preimage_symm_proj_inter (s : Set B) :\n    e.toLocalEquiv.symm ⁻¹' (proj ⁻¹' s) ∩ e.baseSet ×ˢ univ = (s ∩ e.baseSet) ×ˢ univ := by\n  ext ⟨x, y⟩\n  suffices x ∈ e.baseSet → (proj (e.toLocalEquiv.symm (x, y)) ∈ s ↔ x ∈ s) by\n    simpa only [prod_mk_mem_set_prod_eq, mem_inter_iff, and_true_iff, mem_univ, and_congr_left_iff]\n  intro h\n  rw [e.proj_symm_apply' h]\n#align pretrivialization.preimage_symm_proj_inter Pretrivialization.preimage_symm_proj_inter\n\ntheorem target_inter_preimage_symm_source_eq (e f : Pretrivialization F proj) :\n    f.target ∩ f.toLocalEquiv.symm ⁻¹' e.source = (e.baseSet ∩ f.baseSet) ×ˢ univ := by\n  rw [inter_comm, f.target_eq, e.source_eq, f.preimage_symm_proj_inter]\n#align pretrivialization.target_inter_preimage_symm_source_eq Pretrivialization.target_inter_preimage_symm_source_eq\n\ntheorem trans_source (e f : Pretrivialization F proj) :\n    (f.toLocalEquiv.symm.trans e.toLocalEquiv).source = (e.baseSet ∩ f.baseSet) ×ˢ univ := by\n  rw [LocalEquiv.trans_source, LocalEquiv.symm_source, e.target_inter_preimage_symm_source_eq]\n#align pretrivialization.trans_source Pretrivialization.trans_source\n\ntheorem symm_trans_symm (e e' : Pretrivialization F proj) :\n    (e.toLocalEquiv.symm.trans e'.toLocalEquiv).symm = e'.toLocalEquiv.symm.trans e.toLocalEquiv :=\n  by rw [LocalEquiv.trans_symm_eq_symm_trans_symm, LocalEquiv.symm_symm]\n#align pretrivialization.symm_trans_symm Pretrivialization.symm_trans_symm\n\ntheorem symm_trans_source_eq (e e' : Pretrivialization F proj) :\n    (e.toLocalEquiv.symm.trans e'.toLocalEquiv).source = (e.baseSet ∩ e'.baseSet) ×ˢ univ := by\n  rw [LocalEquiv.trans_source, e'.source_eq, LocalEquiv.symm_source, e.target_eq, inter_comm,\n    e.preimage_symm_proj_inter, inter_comm]\n#align pretrivialization.symm_trans_source_eq Pretrivialization.symm_trans_source_eq\n\n\n\nvariable (e' : Pretrivialization F (π E)) {x' : TotalSpace E} {b : B} {y : E b}\n\ntheorem coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.baseSet :=\n  e'.mem_source\n#align pretrivialization.coe_mem_source Pretrivialization.coe_mem_source\n\n@[simp, mfld_simps]\ntheorem coe_coe_fst (hb : b ∈ e'.baseSet) : (e' y).1 = b :=\n  e'.coe_fst (e'.mem_source.2 hb)\n#align pretrivialization.coe_coe_fst Pretrivialization.coe_coe_fst\n\ntheorem mk_mem_target {x : B} {y : F} : (x, y) ∈ e'.target ↔ x ∈ e'.baseSet :=\n  e'.mem_target\n#align pretrivialization.mk_mem_target Pretrivialization.mk_mem_target\n\ntheorem symm_coe_proj {x : B} {y : F} (e' : Pretrivialization F (π E)) (h : x ∈ e'.baseSet) :\n    (e'.toLocalEquiv.symm (x, y)).1 = x :=\n  e'.proj_symm_apply' h\n#align pretrivialization.symm_coe_proj Pretrivialization.symm_coe_proj\n\nsection Zero\n\nvariable [∀ x, Zero (E x)]\n\n/-- A fiberwise inverse to `e`. This is the function `F → E b` that induces a local inverse\n`B × F → total_space E` of `e` on `e.baseSet`. It is defined to be `0` outside `e.baseSet`. -/\nprotected noncomputable def symm (e : Pretrivialization F (π E)) (b : B) (y : F) : E b :=\n  if hb : b ∈ e.baseSet then\n    cast (congr_arg E (e.proj_symm_apply' hb)) (e.toLocalEquiv.symm (b, y)).2\n  else 0\n#align pretrivialization.symm Pretrivialization.symm\n\ntheorem symm_apply (e : Pretrivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : F) :\n    e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.toLocalEquiv.symm (b, y)).2 :=\n  dif_pos hb\n#align pretrivialization.symm_apply Pretrivialization.symm_apply\n\ntheorem symm_apply_of_not_mem (e : Pretrivialization F (π E)) {b : B} (hb : b ∉ e.baseSet) (y : F) :\n    e.symm b y = 0 :=\n  dif_neg hb\n#align pretrivialization.symm_apply_of_not_mem Pretrivialization.symm_apply_of_not_mem\n\ntheorem coe_symm_of_not_mem (e : Pretrivialization F (π E)) {b : B} (hb : b ∉ e.baseSet) :\n    (e.symm b : F → E b) = 0 :=\n  funext fun _ => dif_neg hb\n#align pretrivialization.coe_symm_of_not_mem Pretrivialization.coe_symm_of_not_mem\n\ntheorem mk_symm (e : Pretrivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : F) :\n    totalSpaceMk b (e.symm b y) = e.toLocalEquiv.symm (b, y) := by\n  rw [e.symm_apply hb, TotalSpace.mk_cast (e.proj_symm_apply' hb), TotalSpace.eta]\n#align pretrivialization.mk_symm Pretrivialization.mk_symm\n\ntheorem symm_proj_apply (e : Pretrivialization F (π E)) (z : TotalSpace E)\n    (hz : z.proj ∈ e.baseSet) : e.symm z.proj (e z).2 = z.2 := by\n  rw [e.symm_apply hz, cast_eq_iff_heq, e.mk_proj_snd' hz, e.symm_apply_apply (e.mem_source.mpr hz)]\n#align pretrivialization.symm_proj_apply Pretrivialization.symm_proj_apply\n\ntheorem symm_apply_apply_mk (e : Pretrivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : E b) :\n    e.symm b (e (totalSpaceMk b y)).2 = y :=\n  e.symm_proj_apply (totalSpaceMk b y) hb\n#align pretrivialization.symm_apply_apply_mk Pretrivialization.symm_apply_apply_mk\n\ntheorem apply_mk_symm (e : Pretrivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : F) :\n    e (totalSpaceMk b (e.symm b y)) = (b, y) := by\n  rw [e.mk_symm hb, e.apply_symm_apply (e.mk_mem_target.mpr hb)]\n#align pretrivialization.apply_mk_symm Pretrivialization.apply_mk_symm\n\nend Zero\n\nend Pretrivialization\n\nvariable [TopologicalSpace Z] [TopologicalSpace (TotalSpace E)]\n\n/-- A structure extending local homeomorphisms, defining a local trivialization of a projection\n`proj : Z → B` with fiber `F`, as a local homeomorphism between `Z` and `B × F` defined between two\nsets of the form `proj ⁻¹' baseSet` and `baseSet × F`, acting trivially on the first coordinate.\n-/\n-- porting note: todo: was @[nolint has_nonempty_instance]\nstructure Trivialization (proj : Z → B) extends LocalHomeomorph Z (B × F) where\n  baseSet : Set B\n  open_baseSet : IsOpen baseSet\n  source_eq : source = proj ⁻¹' baseSet\n  target_eq : target = baseSet ×ˢ univ\n  proj_toFun : ∀ p ∈ source, (toLocalHomeomorph p).1 = proj p\n#align trivialization Trivialization\n\nnamespace Trivialization\n\nvariable {F}\nvariable (e : Trivialization F proj) {x : Z}\n\n@[ext]\nlemma ext' (e e' : Trivialization F proj) (h₁ : e.toLocalHomeomorph = e'.toLocalHomeomorph)\n    (h₂ : e.baseSet = e'.baseSet) : e = e' := by\n  cases e; cases e'; congr\n#align trivialization.ext Trivialization.ext'\n\n/-- Coercion of a trivialization to a function. We don't use `e.toFun` in the `CoeFun` instance\nbecause it is actually `e.toLocalEquiv.toFun`, so `simp` will apply lemmas about\n`toLocalEquiv`. While we may want to switch to this behavior later, doing it mid-port will break a\nlot of proofs.  -/\n@[coe] def toFun' : Z → (B × F) := e.toFun\n\n/-- Natural identification as a `Pretrivialization`. -/\ndef toPretrivialization : Pretrivialization F proj :=\n  { e with }\n#align trivialization.to_pretrivialization Trivialization.toPretrivialization\n\ninstance : CoeFun (Trivialization F proj) fun _ => Z → B × F := ⟨toFun'⟩\n\ninstance : Coe (Trivialization F proj) (Pretrivialization F proj) :=\n  ⟨toPretrivialization⟩\n\ntheorem toPretrivialization_injective :\n    Function.Injective fun e : Trivialization F proj => e.toPretrivialization := fun e e' h => by\n  ext1\n  exacts [LocalHomeomorph.toLocalEquiv_injective (congr_arg Pretrivialization.toLocalEquiv h),\n    congr_arg Pretrivialization.baseSet h]\n#align trivialization.to_pretrivialization_injective Trivialization.toPretrivialization_injective\n\n@[simp, mfld_simps]\ntheorem coe_coe : ⇑e.toLocalHomeomorph = e :=\n  rfl\n#align trivialization.coe_coe Trivialization.coe_coe\n\n@[simp, mfld_simps]\ntheorem coe_fst (ex : x ∈ e.source) : (e x).1 = proj x :=\n  e.proj_toFun x ex\n#align trivialization.coe_fst Trivialization.coe_fst\n\nprotected theorem eqOn : EqOn (Prod.fst ∘ e) proj e.source := fun _x hx => e.coe_fst hx\n#align trivialization.eq_on Trivialization.eqOn\n\ntheorem mem_source : x ∈ e.source ↔ proj x ∈ e.baseSet := by rw [e.source_eq, mem_preimage]\n#align trivialization.mem_source Trivialization.mem_source\n\ntheorem coe_fst' (ex : proj x ∈ e.baseSet) : (e x).1 = proj x :=\n  e.coe_fst (e.mem_source.2 ex)\n#align trivialization.coe_fst' Trivialization.coe_fst'\n\ntheorem mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x :=\n  Prod.ext (e.coe_fst ex).symm rfl\n#align trivialization.mk_proj_snd Trivialization.mk_proj_snd\n\ntheorem mk_proj_snd' (ex : proj x ∈ e.baseSet) : (proj x, (e x).2) = e x :=\n  Prod.ext (e.coe_fst' ex).symm rfl\n#align trivialization.mk_proj_snd' Trivialization.mk_proj_snd'\n\ntheorem source_inter_preimage_target_inter (s : Set (B × F)) :\n    e.source ∩ e ⁻¹' (e.target ∩ s) = e.source ∩ e ⁻¹' s :=\n  e.toLocalHomeomorph.source_inter_preimage_target_inter s\n#align trivialization.source_inter_preimage_target_inter Trivialization.source_inter_preimage_target_inter\n\n@[simp, mfld_simps]\ntheorem coe_mk (e : LocalHomeomorph Z (B × F)) (i j k l m) (x : Z) :\n    (Trivialization.mk e i j k l m : Trivialization F proj) x = e x :=\n  rfl\n#align trivialization.coe_mk Trivialization.coe_mk\n\ntheorem mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.baseSet :=\n  e.toPretrivialization.mem_target\n#align trivialization.mem_target Trivialization.mem_target\n\ntheorem map_target {x : B × F} (hx : x ∈ e.target) : e.toLocalHomeomorph.symm x ∈ e.source :=\n  e.toLocalHomeomorph.map_target hx\n#align trivialization.map_target Trivialization.map_target\n\ntheorem proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.toLocalHomeomorph.symm x) = x.1 :=\n  e.toPretrivialization.proj_symm_apply hx\n#align trivialization.proj_symm_apply Trivialization.proj_symm_apply\n\ntheorem proj_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) :\n    proj (e.toLocalHomeomorph.symm (b, x)) = b :=\n  e.toPretrivialization.proj_symm_apply' hx\n#align trivialization.proj_symm_apply' Trivialization.proj_symm_apply'\n\ntheorem proj_surjOn_baseSet [Nonempty F] : Set.SurjOn proj e.source e.baseSet :=\n  e.toPretrivialization.proj_surjOn_baseSet\n#align trivialization.proj_surj_on_base_set Trivialization.proj_surjOn_baseSet\n\ntheorem apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.toLocalHomeomorph.symm x) = x :=\n  e.toLocalHomeomorph.right_inv hx\n#align trivialization.apply_symm_apply Trivialization.apply_symm_apply\n\ntheorem apply_symm_apply' {b : B} {x : F} (hx : b ∈ e.baseSet) :\n    e (e.toLocalHomeomorph.symm (b, x)) = (b, x) :=\n  e.toPretrivialization.apply_symm_apply' hx\n#align trivialization.apply_symm_apply' Trivialization.apply_symm_apply'\n\n@[simp, mfld_simps]\ntheorem symm_apply_mk_proj (ex : x ∈ e.source) : e.toLocalHomeomorph.symm (proj x, (e x).2) = x :=\n  e.toPretrivialization.symm_apply_mk_proj ex\n#align trivialization.symm_apply_mk_proj Trivialization.symm_apply_mk_proj\n\ntheorem symm_trans_source_eq (e e' : Trivialization F proj) :\n    (e.toLocalEquiv.symm.trans e'.toLocalEquiv).source = (e.baseSet ∩ e'.baseSet) ×ˢ univ :=\n  Pretrivialization.symm_trans_source_eq e.toPretrivialization e'\n#align trivialization.symm_trans_source_eq Trivialization.symm_trans_source_eq\n\ntheorem symm_trans_target_eq (e e' : Trivialization F proj) :\n    (e.toLocalEquiv.symm.trans e'.toLocalEquiv).target = (e.baseSet ∩ e'.baseSet) ×ˢ univ :=\n  Pretrivialization.symm_trans_target_eq e.toPretrivialization e'\n#align trivialization.symm_trans_target_eq Trivialization.symm_trans_target_eq\n\ntheorem coe_fst_eventuallyEq_proj (ex : x ∈ e.source) : Prod.fst ∘ e =ᶠ[𝓝 x] proj :=\n  mem_nhds_iff.2 ⟨e.source, fun _y hy => e.coe_fst hy, e.open_source, ex⟩\n#align trivialization.coe_fst_eventually_eq_proj Trivialization.coe_fst_eventuallyEq_proj\n\ntheorem coe_fst_eventuallyEq_proj' (ex : proj x ∈ e.baseSet) : Prod.fst ∘ e =ᶠ[𝓝 x] proj :=\n  e.coe_fst_eventuallyEq_proj (e.mem_source.2 ex)\n#align trivialization.coe_fst_eventually_eq_proj' Trivialization.coe_fst_eventuallyEq_proj'\n\ntheorem map_proj_nhds (ex : x ∈ e.source) : map proj (𝓝 x) = 𝓝 (proj x) := by\n  rw [← e.coe_fst ex, ← map_congr (e.coe_fst_eventuallyEq_proj ex), ← map_map, ← e.coe_coe,\n    e.map_nhds_eq ex, map_fst_nhds]\n#align trivialization.map_proj_nhds Trivialization.map_proj_nhds\n\ntheorem preimage_subset_source {s : Set B} (hb : s ⊆ e.baseSet) : proj ⁻¹' s ⊆ e.source :=\n  fun _p hp => e.mem_source.mpr (hb hp)\n#align trivialization.preimage_subset_source Trivialization.preimage_subset_source\n\ntheorem image_preimage_eq_prod_univ {s : Set B} (hb : s ⊆ e.baseSet) :\n    e '' (proj ⁻¹' s) = s ×ˢ univ :=\n  Subset.antisymm\n    (image_subset_iff.mpr fun p hp =>\n      ⟨(e.proj_toFun p (e.preimage_subset_source hb hp)).symm ▸ hp, trivial⟩)\n    fun p hp =>\n    let hp' : p ∈ e.target := e.mem_target.mpr (hb hp.1)\n    ⟨e.invFun p, mem_preimage.mpr ((e.proj_symm_apply hp').symm ▸ hp.1), e.apply_symm_apply hp'⟩\n#align trivialization.image_preimage_eq_prod_univ Trivialization.image_preimage_eq_prod_univ\n\n/-- The preimage of a subset of the base set is homeomorphic to the product with the fiber. -/\ndef preimageHomeomorph {s : Set B} (hb : s ⊆ e.baseSet) : proj ⁻¹' s ≃ₜ s × F :=\n  (e.toLocalHomeomorph.homeomorphOfImageSubsetSource (e.preimage_subset_source hb)\n        (e.image_preimage_eq_prod_univ hb)).trans\n    ((Homeomorph.Set.prod s univ).trans ((Homeomorph.refl s).prodCongr (Homeomorph.Set.univ F)))\n#align trivialization.preimage_homeomorph Trivialization.preimageHomeomorph\n\n@[simp]\ntheorem preimageHomeomorph_apply {s : Set B} (hb : s ⊆ e.baseSet) (p : proj ⁻¹' s) :\n    e.preimageHomeomorph hb p = (⟨proj p, p.2⟩, (e p).2) :=\n  Prod.ext (Subtype.ext (e.proj_toFun p (e.mem_source.mpr (hb p.2)))) rfl\n#align trivialization.preimage_homeomorph_apply Trivialization.preimageHomeomorph_apply\n\n@[simp]\ntheorem preimageHomeomorph_symm_apply {s : Set B} (hb : s ⊆ e.baseSet) (p : s × F) :\n    (e.preimageHomeomorph hb).symm p = ⟨e.symm (p.1, p.2), ((e.preimageHomeomorph hb).symm p).2⟩ :=\n  rfl\n#align trivialization.preimage_homeomorph_symm_apply Trivialization.preimageHomeomorph_symm_apply\n\n/-- The source is homeomorphic to the product of the base set with the fiber. -/\ndef sourceHomeomorphBaseSetProd : e.source ≃ₜ e.baseSet × F :=\n  (Homeomorph.setCongr e.source_eq).trans (e.preimageHomeomorph subset_rfl)\n#align trivialization.source_homeomorph_base_set_prod Trivialization.sourceHomeomorphBaseSetProd\n\n@[simp]\ntheorem sourceHomeomorphBaseSetProd_apply (p : e.source) :\n    e.sourceHomeomorphBaseSetProd p = (⟨proj p, e.mem_source.mp p.2⟩, (e p).2) :=\n  e.preimageHomeomorph_apply subset_rfl ⟨p, e.mem_source.mp p.2⟩\n#align trivialization.source_homeomorph_base_set_prod_apply Trivialization.sourceHomeomorphBaseSetProd_apply\n\n@[simp]\ntheorem sourceHomeomorphBaseSetProd_symm_apply (p : e.baseSet × F) :\n    e.sourceHomeomorphBaseSetProd.symm p =\n      ⟨e.symm (p.1, p.2), (e.sourceHomeomorphBaseSetProd.symm p).2⟩ :=\n  rfl\n#align trivialization.source_homeomorph_base_set_prod_symm_apply Trivialization.sourceHomeomorphBaseSetProd_symm_apply\n\n/-- Each fiber of a trivialization is homeomorphic to the specified fiber. -/\ndef preimageSingletonHomeomorph {b : B} (hb : b ∈ e.baseSet) : proj ⁻¹' {b} ≃ₜ F :=\n  .trans (e.preimageHomeomorph (Set.singleton_subset_iff.mpr hb)) <|\n    .trans (.prodCongr (Homeomorph.homeomorphOfUnique ({b} : Set B) PUnit.{1}) (Homeomorph.refl F))\n      (Homeomorph.punitProd F)\n#align trivialization.preimage_singleton_homeomorph Trivialization.preimageSingletonHomeomorph\n\n@[simp]\ntheorem preimageSingletonHomeomorph_apply {b : B} (hb : b ∈ e.baseSet) (p : proj ⁻¹' {b}) :\n    e.preimageSingletonHomeomorph hb p = (e p).2 :=\n  rfl\n#align trivialization.preimage_singleton_homeomorph_apply Trivialization.preimageSingletonHomeomorph_apply\n\n@[simp]\ntheorem preimageSingletonHomeomorph_symm_apply {b : B} (hb : b ∈ e.baseSet) (p : F) :\n    (e.preimageSingletonHomeomorph hb).symm p =\n      ⟨e.symm (b, p), by rw [mem_preimage, e.proj_symm_apply' hb, mem_singleton_iff]⟩ :=\n  rfl\n#align trivialization.preimage_singleton_homeomorph_symm_apply Trivialization.preimageSingletonHomeomorph_symm_apply\n\n/-- In the domain of a bundle trivialization, the projection is continuous-/\ntheorem continuousAt_proj (ex : x ∈ e.source) : ContinuousAt proj x :=\n  (e.map_proj_nhds ex).le\n#align trivialization.continuous_at_proj Trivialization.continuousAt_proj\n\n/-- Composition of a `Trivialization` and a `Homeomorph`. -/\nprotected def compHomeomorph {Z' : Type _} [TopologicalSpace Z'] (h : Z' ≃ₜ Z) :\n    Trivialization F (proj ∘ h) where\n  toLocalHomeomorph := h.toLocalHomeomorph.trans e.toLocalHomeomorph\n  baseSet := e.baseSet\n  open_baseSet := e.open_baseSet\n  source_eq := by simp [source_eq, preimage_preimage, (· ∘ ·)]\n  target_eq := by simp [target_eq]\n  proj_toFun p hp := by\n    have hp : h p ∈ e.source := by simpa using hp\n    simp [hp]\n#align trivialization.comp_homeomorph Trivialization.compHomeomorph\n\n/-- Read off the continuity of a function `f : Z → X` at `z : Z` by transferring via a\ntrivialization of `Z` containing `z`. -/\ntheorem continuousAt_of_comp_right {X : Type _} [TopologicalSpace X] {f : Z → X} {z : Z}\n    (e : Trivialization F proj) (he : proj z ∈ e.baseSet)\n    (hf : ContinuousAt (f ∘ e.toLocalEquiv.symm) (e z)) : ContinuousAt f z := by\n  have hez : z ∈ e.toLocalEquiv.symm.target := by\n    rw [LocalEquiv.symm_target, e.mem_source]\n    exact he\n  rwa [e.toLocalHomeomorph.symm.continuousAt_iff_continuousAt_comp_right hez,\n    LocalHomeomorph.symm_symm]\n#align trivialization.continuous_at_of_comp_right Trivialization.continuousAt_of_comp_right\n\n/-- Read off the continuity of a function `f : X → Z` at `x : X` by transferring via a\ntrivialization of `Z` containing `f x`. -/\ntheorem continuousAt_of_comp_left {X : Type _} [TopologicalSpace X] {f : X → Z} {x : X}\n    (e : Trivialization F proj) (hf_proj : ContinuousAt (proj ∘ f) x) (he : proj (f x) ∈ e.baseSet)\n    (hf : ContinuousAt (e ∘ f) x) : ContinuousAt f x := by\n  rw [e.continuousAt_iff_continuousAt_comp_left]\n  · exact hf\n  rw [e.source_eq, ← preimage_comp]\n  exact hf_proj.preimage_mem_nhds (e.open_baseSet.mem_nhds he)\n#align trivialization.continuous_at_of_comp_left Trivialization.continuousAt_of_comp_left\n\nvariable (e' : Trivialization F (π E)) {x' : TotalSpace E} {b : B} {y : E b}\n\nprotected theorem continuousOn : ContinuousOn e' e'.source :=\n  e'.continuous_toFun\n#align trivialization.continuous_on Trivialization.continuousOn\n\ntheorem coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.baseSet :=\n  e'.mem_source\n#align trivialization.coe_mem_source Trivialization.coe_mem_source\n\n@[deprecated LocalHomeomorph.open_target]\ntheorem open_target' : IsOpen e'.target := e'.open_target\n#align trivialization.open_target Trivialization.open_target'\n\n@[simp, mfld_simps]\ntheorem coe_coe_fst (hb : b ∈ e'.baseSet) : (e' y).1 = b :=\n  e'.coe_fst (e'.mem_source.2 hb)\n#align trivialization.coe_coe_fst Trivialization.coe_coe_fst\n\ntheorem mk_mem_target {y : F} : (b, y) ∈ e'.target ↔ b ∈ e'.baseSet :=\n  e'.toPretrivialization.mem_target\n#align trivialization.mk_mem_target Trivialization.mk_mem_target\n\ntheorem symm_apply_apply {x : TotalSpace E} (hx : x ∈ e'.source) :\n    e'.toLocalHomeomorph.symm (e' x) = x :=\n  e'.toLocalEquiv.left_inv hx\n#align trivialization.symm_apply_apply Trivialization.symm_apply_apply\n\n@[simp, mfld_simps]\ntheorem symm_coe_proj {x : B} {y : F} (e : Trivialization F (π E)) (h : x ∈ e.baseSet) :\n    (e.toLocalHomeomorph.symm (x, y)).1 = x :=\n  e.proj_symm_apply' h\n#align trivialization.symm_coe_proj Trivialization.symm_coe_proj\n\nsection Zero\n\nvariable [∀ x, Zero (E x)]\n\n/-- A fiberwise inverse to `e'`. The function `F → E x` that induces a local inverse\n`B × F → total_space E` of `e'` on `e'.baseSet`. It is defined to be `0` outside `e'.baseSet`. -/\nprotected noncomputable def symm (e : Trivialization F (π E)) (b : B) (y : F) : E b :=\n  e.toPretrivialization.symm b y\n#align trivialization.symm Trivialization.symm\n\ntheorem symm_apply (e : Trivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : F) :\n    e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.toLocalHomeomorph.symm (b, y)).2 :=\n  dif_pos hb\n#align trivialization.symm_apply Trivialization.symm_apply\n\ntheorem symm_apply_of_not_mem (e : Trivialization F (π E)) {b : B} (hb : b ∉ e.baseSet) (y : F) :\n    e.symm b y = 0 :=\n  dif_neg hb\n#align trivialization.symm_apply_of_not_mem Trivialization.symm_apply_of_not_mem\n\ntheorem mk_symm (e : Trivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : F) :\n    totalSpaceMk b (e.symm b y) = e.toLocalHomeomorph.symm (b, y) :=\n  e.toPretrivialization.mk_symm hb y\n#align trivialization.mk_symm Trivialization.mk_symm\n\ntheorem symm_proj_apply (e : Trivialization F (π E)) (z : TotalSpace E) (hz : z.proj ∈ e.baseSet) :\n    e.symm z.proj (e z).2 = z.2 :=\n  e.toPretrivialization.symm_proj_apply z hz\n#align trivialization.symm_proj_apply Trivialization.symm_proj_apply\n\ntheorem symm_apply_apply_mk (e : Trivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : E b) :\n    e.symm b (e (totalSpaceMk b y)).2 = y :=\n  e.symm_proj_apply (totalSpaceMk b y) hb\n#align trivialization.symm_apply_apply_mk Trivialization.symm_apply_apply_mk\n\ntheorem apply_mk_symm (e : Trivialization F (π E)) {b : B} (hb : b ∈ e.baseSet) (y : F) :\n    e (totalSpaceMk b (e.symm b y)) = (b, y) :=\n  e.toPretrivialization.apply_mk_symm hb y\n#align trivialization.apply_mk_symm Trivialization.apply_mk_symm\n\ntheorem continuousOn_symm (e : Trivialization F (π E)) :\n    ContinuousOn (fun z : B × F => totalSpaceMk z.1 (e.symm z.1 z.2)) (e.baseSet ×ˢ univ) := by\n  have : ∀ z ∈ e.baseSet ×ˢ (univ : Set F),\n      totalSpaceMk z.1 (e.symm z.1 z.2) = e.toLocalHomeomorph.symm z := by\n    rintro x ⟨hx : x.1 ∈ e.baseSet, _⟩\n    rw [e.mk_symm hx]\n  refine' ContinuousOn.congr _ this\n  rw [← e.target_eq]\n  exact e.toLocalHomeomorph.continuousOn_symm\n#align trivialization.continuous_on_symm Trivialization.continuousOn_symm\n\nend Zero\n\n/-- If `e` is a `Trivialization` of `proj : Z → B` with fiber `F` and `h` is a homeomorphism\n`F ≃ₜ F'`, then `e.trans_fiber_homeomorph h` is the trivialization of `proj` with the fiber `F'`\nthat sends `p : Z` to `((e p).1, h (e p).2)`. -/\ndef transFiberHomeomorph {F' : Type _} [TopologicalSpace F'] (e : Trivialization F proj)\n    (h : F ≃ₜ F') : Trivialization F' proj where\n  toLocalHomeomorph := e.toLocalHomeomorph.transHomeomorph <| (Homeomorph.refl _).prodCongr h\n  baseSet := e.baseSet\n  open_baseSet := e.open_baseSet\n  source_eq := e.source_eq\n  target_eq := by simp [target_eq, prod_univ, preimage_preimage]\n  proj_toFun := e.proj_toFun\n#align trivialization.trans_fiber_homeomorph Trivialization.transFiberHomeomorph\n\n@[simp]\ntheorem transFiberHomeomorph_apply {F' : Type _} [TopologicalSpace F'] (e : Trivialization F proj)\n    (h : F ≃ₜ F') (x : Z) : e.transFiberHomeomorph h x = ((e x).1, h (e x).2) :=\n  rfl\n#align trivialization.trans_fiber_homeomorph_apply Trivialization.transFiberHomeomorph_apply\n\n/-- Coordinate transformation in the fiber induced by a pair of bundle trivializations. See also\n`Trivialization.coordChangeHomeomorph` for a version bundled as `F ≃ₜ F`. -/\ndef coordChange (e₁ e₂ : Trivialization F proj) (b : B) (x : F) : F :=\n  (e₂ <| e₁.toLocalHomeomorph.symm (b, x)).2\n#align trivialization.coord_change Trivialization.coordChange\n\ntheorem mk_coordChange (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet)\n    (h₂ : b ∈ e₂.baseSet) (x : F) :\n    (b, e₁.coordChange e₂ b x) = e₂ (e₁.toLocalHomeomorph.symm (b, x)) := by\n  refine' Prod.ext _ rfl\n  rw [e₂.coe_fst', ← e₁.coe_fst', e₁.apply_symm_apply' h₁]\n  · rwa [e₁.proj_symm_apply' h₁]\n  · rwa [e₁.proj_symm_apply' h₁]\n#align trivialization.mk_coord_change Trivialization.mk_coordChange\n\ntheorem coordChange_apply_snd (e₁ e₂ : Trivialization F proj) {p : Z} (h : proj p ∈ e₁.baseSet) :\n    e₁.coordChange e₂ (proj p) (e₁ p).snd = (e₂ p).snd := by\n  rw [coordChange, e₁.symm_apply_mk_proj (e₁.mem_source.2 h)]\n#align trivialization.coord_change_apply_snd Trivialization.coordChange_apply_snd\n\ntheorem coordChange_same_apply (e : Trivialization F proj) {b : B} (h : b ∈ e.baseSet) (x : F) :\n    e.coordChange e b x = x := by rw [coordChange, e.apply_symm_apply' h]\n#align trivialization.coord_change_same_apply Trivialization.coordChange_same_apply\n\ntheorem coordChange_same (e : Trivialization F proj) {b : B} (h : b ∈ e.baseSet) :\n    e.coordChange e b = id :=\n  funext <| e.coordChange_same_apply h\n#align trivialization.coord_change_same Trivialization.coordChange_same\n\ntheorem coordChange_coordChange (e₁ e₂ e₃ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet)\n    (h₂ : b ∈ e₂.baseSet) (x : F) :\n    e₂.coordChange e₃ b (e₁.coordChange e₂ b x) = e₁.coordChange e₃ b x := by\n  rw [coordChange, e₁.mk_coordChange _ h₁ h₂, ← e₂.coe_coe, e₂.left_inv, coordChange]\n  rwa [e₂.mem_source, e₁.proj_symm_apply' h₁]\n#align trivialization.coord_change_coord_change Trivialization.coordChange_coordChange\n\ntheorem continuous_coordChange (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet)\n    (h₂ : b ∈ e₂.baseSet) : Continuous (e₁.coordChange e₂ b) := by\n  refine' continuous_snd.comp (e₂.toLocalHomeomorph.continuousOn.comp_continuous\n    (e₁.toLocalHomeomorph.continuousOn_symm.comp_continuous _ _) _)\n  · exact continuous_const.prod_mk continuous_id\n  · exact fun x => e₁.mem_target.2 h₁\n  · intro x\n    rwa [e₂.mem_source, e₁.proj_symm_apply' h₁]\n#align trivialization.continuous_coord_change Trivialization.continuous_coordChange\n\n/-- Coordinate transformation in the fiber induced by a pair of bundle trivializations,\nas a homeomorphism. -/\nprotected def coordChangeHomeomorph (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet)\n    (h₂ : b ∈ e₂.baseSet) : F ≃ₜ F where\n  toFun := e₁.coordChange e₂ b\n  invFun := e₂.coordChange e₁ b\n  left_inv x := by simp only [*, coordChange_coordChange, coordChange_same_apply]\n  right_inv x := by simp only [*, coordChange_coordChange, coordChange_same_apply]\n  continuous_toFun := e₁.continuous_coordChange e₂ h₁ h₂\n  continuous_invFun := e₂.continuous_coordChange e₁ h₂ h₁\n#align trivialization.coord_change_homeomorph Trivialization.coordChangeHomeomorph\n\n@[simp]\ntheorem coordChangeHomeomorph_coe (e₁ e₂ : Trivialization F proj) {b : B} (h₁ : b ∈ e₁.baseSet)\n    (h₂ : b ∈ e₂.baseSet) : ⇑(e₁.coordChangeHomeomorph e₂ h₁ h₂) = e₁.coordChange e₂ b :=\n  rfl\n#align trivialization.coord_change_homeomorph_coe Trivialization.coordChangeHomeomorph_coe\n\nvariable {B' : Type _} [TopologicalSpace B']\n\ntheorem isImage_preimage_prod (e : Trivialization F proj) (s : Set B) :\n    e.toLocalHomeomorph.IsImage (proj ⁻¹' s) (s ×ˢ univ) := fun x hx => by simp [e.coe_fst', hx]\n#align trivialization.is_image_preimage_prod Trivialization.isImage_preimage_prod\n\n/-- Restrict a `Trivialization` to an open set in the base. `-/\nprotected def restrOpen (e : Trivialization F proj) (s : Set B) (hs : IsOpen s) :\n    Trivialization F proj where\n  toLocalHomeomorph :=\n    ((e.isImage_preimage_prod s).symm.restr (IsOpen.inter e.open_target (hs.prod isOpen_univ))).symm\n  baseSet := e.baseSet ∩ s\n  open_baseSet := IsOpen.inter e.open_baseSet hs\n  source_eq := by simp [source_eq]\n  target_eq := by simp [target_eq, prod_univ]\n  proj_toFun p hp := e.proj_toFun p hp.1\n#align trivialization.restr_open Trivialization.restrOpen\n\nsection Piecewise\n\ntheorem frontier_preimage (e : Trivialization F proj) (s : Set B) :\n    e.source ∩ frontier (proj ⁻¹' s) = proj ⁻¹' (e.baseSet ∩ frontier s) := by\n  rw [← (e.isImage_preimage_prod s).frontier.preimage_eq, frontier_prod_univ_eq,\n    (e.isImage_preimage_prod _).preimage_eq, e.source_eq, preimage_inter]\n#align trivialization.frontier_preimage Trivialization.frontier_preimage\n\n/-- Given two bundle trivializations `e`, `e'` of `proj : Z → B` and a set `s : Set B` such that\nthe base sets of `e` and `e'` intersect `frontier s` on the same set and `e p = e' p` whenever\n`proj p ∈ e.baseSet ∩ frontier s`, `e.piecewise e' s Hs Heq` is the bundle trivialization over\n`Set.ite s e.baseSet e'.baseSet` that is equal to `e` on `proj ⁻¹ s` and is equal to `e'`\notherwise. -/\nnoncomputable def piecewise (e e' : Trivialization F proj) (s : Set B)\n    (Hs : e.baseSet ∩ frontier s = e'.baseSet ∩ frontier s)\n    (Heq : EqOn e e' <| proj ⁻¹' (e.baseSet ∩ frontier s)) : Trivialization F proj where\n  toLocalHomeomorph :=\n    e.toLocalHomeomorph.piecewise e'.toLocalHomeomorph (proj ⁻¹' s) (s ×ˢ univ)\n      (e.isImage_preimage_prod s) (e'.isImage_preimage_prod s)\n      (by rw [e.frontier_preimage, e'.frontier_preimage, Hs]) (by rwa [e.frontier_preimage])\n  baseSet := s.ite e.baseSet e'.baseSet\n  open_baseSet := e.open_baseSet.ite e'.open_baseSet Hs\n  source_eq := by simp [source_eq]\n  target_eq := by simp [target_eq, prod_univ]\n  proj_toFun p := by\n    rintro (⟨he, hs⟩ | ⟨he, hs⟩)\n    -- porting note: was `<;> simp [*]`\n    · simp [piecewise_eq_of_mem _ _ _ hs, *]\n    · simp [piecewise_eq_of_not_mem _ _ _ hs, *]\n#align trivialization.piecewise Trivialization.piecewise\n\n/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B`\nover a linearly ordered base `B` and a point `a ∈ e.baseSet ∩ e'.baseSet` such that\n`e` equals `e'` on `proj ⁻¹' {a}`, `e.piecewise_le_of_eq e' a He He' Heq` is the bundle\ntrivialization over `Set.ite (Iic a) e.baseSet e'.baseSet` that is equal to `e` on points `p`\nsuch that `proj p ≤ a` and is equal to `e'` otherwise. -/\nnoncomputable def piecewiseLeOfEq [LinearOrder B] [OrderTopology B] (e e' : Trivialization F proj)\n    (a : B) (He : a ∈ e.baseSet) (He' : a ∈ e'.baseSet) (Heq : ∀ p, proj p = a → e p = e' p) :\n    Trivialization F proj :=\n  e.piecewise e' (Iic a)\n    (Set.ext fun x => and_congr_left_iff.2 fun hx => by\n      obtain rfl : x = a := mem_singleton_iff.1 (frontier_Iic_subset _ hx)\n      simp [He, He'])\n    fun p hp => Heq p <| frontier_Iic_subset _ hp.2\n#align trivialization.piecewise_le_of_eq Trivialization.piecewiseLeOfEq\n\n/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B` over a\nlinearly ordered base `B` and a point `a ∈ e.baseSet ∩ e'.baseSet`, `e.piecewise_le e' a He He'`\nis the bundle trivialization over `Set.ite (Iic a) e.baseSet e'.baseSet` that is equal to `e` on\npoints `p` such that `proj p ≤ a` and is equal to `((e' p).1, h (e' p).2)` otherwise, where\n`h = `e'.coord_change_homeomorph e _ _` is the homeomorphism of the fiber such that\n`h (e' p).2 = (e p).2` whenever `e p = a`. -/\nnoncomputable def piecewiseLe [LinearOrder B] [OrderTopology B] (e e' : Trivialization F proj)\n    (a : B) (He : a ∈ e.baseSet) (He' : a ∈ e'.baseSet) : Trivialization F proj :=\n  e.piecewiseLeOfEq (e'.transFiberHomeomorph (e'.coordChangeHomeomorph e He' He)) a He He' <| by\n    rintro p rfl\n    ext1\n    · simp [e.coe_fst', e'.coe_fst', *]\n    · simp [coordChange_apply_snd, *]\n#align trivialization.piecewise_le Trivialization.piecewiseLe\n\n/-- Given two bundle trivializations `e`, `e'` over disjoint sets, `e.disjoint_union e' H` is the\nbundle trivialization over the union of the base sets that agrees with `e` and `e'` over their\nbase sets. -/\nnoncomputable def disjointUnion (e e' : Trivialization F proj) (H : Disjoint e.baseSet e'.baseSet) :\n    Trivialization F proj where\n  toLocalHomeomorph :=\n    e.toLocalHomeomorph.disjointUnion e'.toLocalHomeomorph\n      (by\n        rw [e.source_eq, e'.source_eq]\n        exact H.preimage _)\n      (by\n        rw [e.target_eq, e'.target_eq, disjoint_iff_inf_le]\n        intro x hx\n        exact H.le_bot ⟨hx.1.1, hx.2.1⟩)\n  baseSet := e.baseSet ∪ e'.baseSet\n  open_baseSet := IsOpen.union e.open_baseSet e'.open_baseSet\n  source_eq := congr_arg₂ (· ∪ ·) e.source_eq e'.source_eq\n  target_eq := (congr_arg₂ (· ∪ ·) e.target_eq e'.target_eq).trans union_prod.symm\n  proj_toFun := by\n    rintro p (hp | hp')\n    · show (e.source.piecewise e e' p).1 = proj p\n      rw [piecewise_eq_of_mem, e.coe_fst] <;> exact hp\n    · show (e.source.piecewise e e' p).1 = proj p\n      rw [piecewise_eq_of_not_mem, e'.coe_fst hp']\n      simp only [source_eq] at hp' ⊢\n      exact fun h => H.le_bot ⟨h, hp'⟩\n#align trivialization.disjoint_union Trivialization.disjointUnion\n\nend Piecewise\n\nend Trivialization\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Topology/FiberBundle/Trivialization.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4643778890265731}}
{"text": "/- Inaccessible names -/\n\nexample : ∀ x y : Nat, x = y → y = x := by\n  intros\n  apply Eq.symm\n  assumption\n\nexample : ∀ x y : Nat, x = y → y = x := by\n  intros\n  apply Eq.symm\n  rename_i a b hab\n  exact hab\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/doc/examples/NFM2022/nfm16.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6406358479787609, "lm_q1q2_score": 0.4643778840531388}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport logic.relator\n\n/-!\n# Quotient types\n\nThis module extends the core library's treatment of quotient types (`init.data.quot`).\n\n## Tags\n\nquotient\n-/\n\nvariables {α : Sort*} {β : Sort*}\n\nnamespace setoid\n\nlemma ext {α : Sort*} :\n  ∀{s t : setoid α}, (∀a b, @setoid.r α s a b ↔ @setoid.r α t a b) → s = t\n| ⟨r, _⟩ ⟨p, _⟩ eq :=\n  have r = p, from funext $ assume a, funext $ assume b, propext $ eq a b,\n  by subst this\n\nend setoid\n\nnamespace quot\nvariables {ra : α → α → Prop} {rb : β → β → Prop} {φ : quot ra → quot rb → Sort*}\nlocal notation `⟦`:max a `⟧` := quot.mk _ a\n\ninstance (r : α → α → Prop) [inhabited α] : inhabited (quot r) := ⟨⟦default⟧⟩\n\ninstance [subsingleton α] : subsingleton (quot ra) :=\n⟨λ x, quot.induction_on x (λ y, quot.ind (λ b, congr_arg _ (subsingleton.elim _ _)))⟩\n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂ (qa : quot ra) (qb : quot rb) (f : Π a b, φ ⟦a⟧ ⟦b⟧)\n  (ca : ∀ {b a₁ a₂}, ra a₁ a₂ → f a₁ b == f a₂ b)\n  (cb : ∀ {a b₁ b₂}, rb b₁ b₂ → f a b₁ == f a b₂) : φ qa qb :=\nquot.hrec_on qa (λ a, quot.hrec_on qb (f a) (λ b₁ b₂ pb, cb pb)) $ λ a₁ a₂ pa,\n  quot.induction_on qb $ λ b,\n    calc @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₁) (@cb _)\n          == f a₁ b                                     : by simp [heq_self_iff_true]\n      ... == f a₂ b                                     : ca pa\n      ... == @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₂) (@cb _) : by simp [heq_self_iff_true]\n\n/-- Map a function `f : α → β` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra → quot rb`. -/\nprotected def map (f : α → β) (h : (ra ⇒ rb) f f) : quot ra → quot rb :=\nquot.lift (λ x, ⟦f x⟧) $ assume x y (h₁ : ra x y), quot.sound $ h h₁\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `quot ra → quot ra'`. -/\nprotected def map_right {ra' : α → α → Prop} (h : ∀a₁ a₂, ra a₁ a₂ → ra' a₁ a₂) :\n  quot ra → quot ra' :=\nquot.map id h\n\n/-- weaken the relation of a quotient -/\ndef factor {α : Type*} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n  quot r → quot s :=\nquot.lift (quot.mk s) (λ x y rxy, quot.sound (h x y rxy))\n\nlemma factor_mk_eq {α : Type*} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n  factor r s h ∘ quot.mk _ = quot.mk _ := rfl\n\nvariables {γ : Sort*} {r : α → α → Prop} {s : β → β → Prop}\n\n/-- **Alias** of `quot.lift_beta`. -/\nlemma lift_mk (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) (a : α) :\n  quot.lift f h (quot.mk r a) = f a := quot.lift_beta f h a\n\n@[simp]\nlemma lift_on_mk (a : α) (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :\n  quot.lift_on (quot.mk r a) f h = f a := rfl\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β`. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift₂\n  (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n  (q₁ : quot r) (q₂ : quot s) : γ :=\nquot.lift (λ a, quot.lift (f a) (hr a))\n(λ a₁ a₂ ha, funext (λ q, quot.induction_on q (λ b, hs a₁ a₂ b ha)))\nq₁ q₂\n\n@[simp]\nlemma lift₂_mk (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) (a : α) (b : β) :\n  quot.lift₂ f hr hs (quot.mk r a) (quot.mk s b) = f a b := rfl\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` and applies it. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift_on₂ (p : quot r) (q : quot s) (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) : γ := quot.lift₂ f hr hs p q\n\n@[simp]\nlemma lift_on₂_mk (a : α) (b : β) (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) :\n  quot.lift_on₂ (quot.mk r a) (quot.mk s b) f hr hs = f a b := rfl\n\nvariables {t : γ → γ → Prop}\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` wih values in a quotient of\n`γ`. -/\nprotected def map₂ (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b))\n  (q₁ : quot r) (q₂ : quot s) : quot t :=\nquot.lift₂ (λ a b, quot.mk t $ f a b) (λ a b₁ b₂ hb, quot.sound (hr a b₁ b₂ hb))\n(λ a₁ a₂ b ha, quot.sound (hs a₁ a₂ b ha)) q₁ q₂\n\n@[simp]\nlemma map₂_mk (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b))\n  (a : α) (b : β) : quot.map₂ f hr hs (quot.mk r a) (quot.mk s b) = quot.mk t (f a b) := rfl\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on₂\n  {δ : quot r → quot s → Prop} (q₁ : quot r) (q₂ : quot s)\n  (h : ∀ a b, δ (quot.mk r a) (quot.mk s b)) : δ q₁ q₂ :=\nquot.ind (λ a₁, quot.ind (λ a₂, h a₁ a₂) q₂) q₁\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on₃\n  {δ : quot r → quot s → quot t → Prop} (q₁ : quot r) (q₂ : quot s) (q₃ : quot t)\n  (h : ∀ a b c, δ (quot.mk r a) (quot.mk s b) (quot.mk t c)) : δ q₁ q₂ q₃ :=\nquot.ind (λ a₁, quot.ind (λ a₂, quot.ind (λ a₃, h a₁ a₂ a₃) q₃) q₂) q₁\n\nend quot\n\nnamespace quotient\nvariables [sa : setoid α] [sb : setoid β]\nvariables {φ : quotient sa → quotient sb → Sort*}\n\ninstance (s : setoid α) [inhabited α] : inhabited (quotient s) := ⟨⟦default⟧⟩\n\ninstance (s : setoid α) [subsingleton α] : subsingleton (quotient s) :=\nquot.subsingleton\n\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂ (qa : quotient sa) (qb : quotient sb) (f : Π a b, φ ⟦a⟧ ⟦b⟧)\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) : φ qa qb :=\nquot.hrec_on₂ qa qb f\n  (λ _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (λ _ _ _ p, c _ _ _ _ (setoid.refl _) p)\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : α → β) (h : ((≈) ⇒ (≈)) f f) : quotient sa → quotient sb :=\nquot.map f h\n\n@[simp] lemma map_mk (f : α → β) (h : ((≈) ⇒ (≈)) f f) (x : α) :\n  quotient.map f h (⟦x⟧ : quotient sa) = (⟦f x⟧ : quotient sb) :=\nrfl\n\nvariables {γ : Sort*} [sc : setoid γ]\n\n/-- Map a function `f : α → β → γ` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa → quotient sb → quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map₂ (f : α → β → γ) (h : ((≈) ⇒ (≈) ⇒ (≈)) f f) :\n  quotient sa → quotient sb → quotient sc :=\nquotient.lift₂ (λ x y, ⟦f x y⟧) (λ x₁ y₁ x₂ y₂ h₁ h₂, quot.sound $ h h₁ h₂)\n\n@[simp] lemma map₂_mk (f : α → β → γ) (h : ((≈) ⇒ (≈) ⇒ (≈)) f f) (x : α) (y : β) :\n  quotient.map₂ f h (⟦x⟧ : quotient sa) (⟦y⟧ : quotient sb) = (⟦f x y⟧ : quotient sc) := rfl\n\nend quotient\n\nlemma quot.eq {α : Type*} {r : α → α → Prop} {x y : α} :\n  quot.mk r x = quot.mk r y ↔ eqv_gen r x y :=\n⟨quot.exact r, quot.eqv_gen_sound⟩\n\n@[simp] theorem quotient.eq [r : setoid α] {x y : α} : ⟦x⟧ = ⟦y⟧ ↔ x ≈ y :=\n⟨quotient.exact, quotient.sound⟩\n\ntheorem forall_quotient_iff {α : Type*} [r : setoid α] {p : quotient r → Prop} :\n  (∀a:quotient r, p a) ↔ (∀a:α, p ⟦a⟧) :=\n⟨assume h x, h _, assume h a, a.induction_on h⟩\n\n@[simp] lemma quotient.lift_mk [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b)\n  (x : α) :\n  quotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift_comp_mk [setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b) :\n  quotient.lift f h ∘ quotient.mk = f :=\nrfl\n\n@[simp] lemma quotient.lift₂_mk {α : Sort*} {β : Sort*} {γ : Sort*} [setoid α] [setoid β]\n  (f : α → β → γ)\n  (h : ∀ (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂)\n  (a : α) (b : β) :\n  quotient.lift₂ f h (quotient.mk a) (quotient.mk b) = f a b := rfl\n\n@[simp] lemma quotient.lift_on_mk [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b)\n  (x : α) :\n  quotient.lift_on (quotient.mk x) f h = f x := rfl\n\n@[simp] theorem quotient.lift_on₂_mk {α : Sort*} {β : Sort*} [setoid α] (f : α → α → β)\n  (h : ∀ (a₁ a₂ b₁ b₂ : α), a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂) (x y : α) :\n  quotient.lift_on₂ (quotient.mk x) (quotient.mk y) f h = f x y := rfl\n\n/-- `quot.mk r` is a surjective function. -/\nlemma surjective_quot_mk (r : α → α → Prop) : function.surjective (quot.mk r) :=\nquot.exists_rep\n\n/-- `quotient.mk` is a surjective function. -/\nlemma surjective_quotient_mk (α : Sort*) [s : setoid α] :\n  function.surjective (quotient.mk : α → quotient s) :=\nquot.exists_rep\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quot.out {r : α → α → Prop} (q : quot r) : α :=\nclassical.some (quot.exists_rep q)\n\n/-- Unwrap the VM representation of a quotient to obtain an element of the equivalence class.\n  Computable but unsound. -/\nmeta def quot.unquot {r : α → α → Prop} : quot r → α := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : α → α → Prop} (q : quot r) : quot.mk r q.out = q :=\nclassical.some_spec (quot.exists_rep q)\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quotient.out [s : setoid α] : quotient s → α := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid α] (q : quotient s) : ⟦q.out⟧ = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid α] (a : α) : ⟦a⟧.out ≈ a :=\nquotient.exact (quotient.out_eq _)\n\nlemma quotient.mk_eq_iff_out [s : setoid α] {x : α} {y : quotient s} :\n  ⟦x⟧ = y ↔ x ≈ quotient.out y :=\nbegin\n  refine iff.trans _ quotient.eq,\n  rw quotient.out_eq y,\nend\n\nlemma quotient.eq_mk_iff_out [s : setoid α] {x : quotient s} {y : α} :\n  x = ⟦y⟧ ↔ quotient.out x ≈ y  :=\nbegin\n  refine iff.trans _ quotient.eq,\n  rw quotient.out_eq x,\nend\n\n@[simp] lemma quotient.out_equiv_out {s : setoid α} {x y : quotient s} :\n  x.out ≈ y.out ↔ x = y :=\nby rw [← quotient.eq_mk_iff_out, quotient.out_eq]\n\n@[simp] lemma quotient.out_inj {s : setoid α} {x y : quotient s} :\n  x.out = y.out ↔ x = y :=\n⟨λ h, quotient.out_equiv_out.1 $ h ▸ setoid.refl _, λ h, h ▸ rfl⟩\n\nsection pi\n\ninstance pi_setoid {ι : Sort*} {α : ι → Sort*} [∀ i, setoid (α i)] : setoid (Π i, α i) :=\n{ r := λ a b, ∀ i, a i ≈ b i,\n  iseqv := ⟨\n    λ a i, setoid.refl _,\n    λ a b h i, setoid.symm (h _),\n    λ a b c h₁ h₂ i, setoid.trans (h₁ _) (h₂ _)⟩ }\n\n/-- Given a function `f : Π i, quotient (S i)`, returns the class of functions `Π i, α i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def quotient.choice {ι : Type*} {α : ι → Type*} [S : Π i, setoid (α i)]\n  (f : Π i, quotient (S i)) : @quotient (Π i, α i) (by apply_instance) :=\n⟦λ i, (f i).out⟧\n\n@[simp] theorem quotient.choice_eq {ι : Type*} {α : ι → Type*} [Π i, setoid (α i)]\n  (f : Π i, α i) : quotient.choice (λ i, ⟦f i⟧) = ⟦f⟧ :=\nquotient.sound $ λ i, quotient.mk_out _\n\n@[elab_as_eliminator] lemma quotient.induction_on_pi\n   {ι : Type*} {α : ι → Sort*} [s : ∀ i, setoid (α i)]\n   {p : (Π i, quotient (s i)) → Prop} (f : Π i, quotient (s i))\n   (h : ∀ a : Π i, α i, p (λ i, ⟦a i⟧)) : p f :=\nbegin\n  rw ← (funext (λ i, quotient.out_eq (f i)) : (λ i,  ⟦(f i).out⟧) = f),\n  apply h,\nend\n\nend pi\n\nlemma nonempty_quotient_iff (s : setoid α) : nonempty (quotient s) ↔ nonempty α :=\n⟨assume ⟨a⟩, quotient.induction_on a nonempty.intro, assume ⟨a⟩, ⟨⟦a⟧⟩⟩\n\n/-- `trunc α` is the quotient of `α` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty α`, but unlike `nonempty α`, `trunc α` is data,\n  so the VM representation is the same as `α`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (α : Sort u) : Sort u := @quot α (λ _ _, true)\n\ntheorem true_equivalence : @equivalence α (λ _ _, true) :=\n⟨λ _, trivial, λ _ _ _, trivial, λ _ _ _ _ _, trivial⟩\n\nnamespace trunc\n\n/-- Constructor for `trunc α` -/\ndef mk (a : α) : trunc α := quot.mk _ a\n\ninstance [inhabited α] : inhabited (trunc α) := ⟨mk default⟩\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : α → β) (c : ∀ a b : α, f a = f b) : trunc α → β :=\nquot.lift f (λ a b _, c a b)\n\ntheorem ind {β : trunc α → Prop} : (∀ a : α, β (mk a)) → ∀ q : trunc α, β q := quot.ind\n\nprotected theorem lift_mk (f : α → β) (c) (a : α) : lift f c (mk a) = f a := rfl\n\n/-- Lift a constant function on `q : trunc α`. -/\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc α) (f : α → β)\n  (c : ∀ a b : α, f a = f b) : β := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {β : trunc α → Prop} (q : trunc α)\n  (h : ∀ a, β (mk a)) : β q := ind h q\n\ntheorem exists_rep (q : trunc α) : ∃ a : α, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on₂ {C : trunc α → trunc β → Prop} (q₁ : trunc α) (q₂ : trunc β)\n  (h : ∀ a b, C (mk a) (mk b)) : C q₁ q₂ :=\ntrunc.induction_on q₁ $ λ a₁, trunc.induction_on q₂ (h a₁)\n\nprotected theorem eq (a b : trunc α) : a = b :=\ntrunc.induction_on₂ a b (λ x y, quot.sound trivial)\n\ninstance : subsingleton (trunc α) := ⟨trunc.eq⟩\n\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : trunc α) (f : α → trunc β) : trunc β :=\ntrunc.lift_on q f (λ a b, trunc.eq _ _)\n\n/-- A function `f : α → β` defines a function `map f : trunc α → trunc β`. -/\ndef map (f : α → β) (q : trunc α) : trunc β := bind q (trunc.mk ∘ f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := λ α q, trunc.eq _ _,\n  pure_bind := λ α β q f, rfl,\n  bind_assoc := λ α β γ x f g, trunc.eq _ _ }\n\nvariable {C : trunc α → Sort*}\n\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : Π a, C (mk a)) (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc α) : C q :=\nquot.rec f (λ a b _, h a b) q\n\n/-- A version of `trunc.rec` taking `q : trunc α` as the first argument. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc α) (f : Π a, C (mk a))\n  (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b) : C q :=\ntrunc.rec f h q\n\n/-- A version of `trunc.rec_on` assuming the codomain is a `subsingleton`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton\n   [∀ a, subsingleton (C (mk a))] (q : trunc α) (f : Π a, C (mk a)) : C q :=\ntrunc.rec f (λ a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc α` (using the axiom of choice). -/\nnoncomputable def out : trunc α → α := quot.out\n\n@[simp] theorem out_eq (q : trunc α) : mk q.out = q := trunc.eq _ _\n\nprotected theorem nonempty (q : trunc α) : nonempty α :=\nnonempty_of_exists q.exists_rep\n\nend trunc\n\nnamespace quotient\nvariables {γ : Sort*} {φ : Sort*}\n  {s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}\n\n/-! Versions of quotient definitions and lemmas ending in `'` use unification instead\nof typeclass inference for inferring the `setoid` argument. This is useful when there are\nseveral different quotient relations on a type, for example quotient groups, rings and modules. -/\n\n/-- A version of `quotient.mk` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk' (a : α) : quotient s₁ := quot.mk s₁.1 a\n\n/-- `quotient.mk'` is a surjective function. -/\nlemma surjective_quotient_mk' : function.surjective (quotient.mk' : α → quotient s₁) :=\nquot.exists_rep\n\n/-- A version of `quotient.lift_on` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s₁) (f : α → φ)\n  (h : ∀ a b, @setoid.r α s₁ a b → f a = f b) : φ := quotient.lift_on q f h\n\n@[simp]\nprotected lemma lift_on'_mk' (f : α → φ) (h) (x : α) :\n  quotient.lift_on' (@quotient.mk' _ s₁ x) f h = f x := rfl\n\n/-- A version of `quotient.lift_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on₂' (q₁ : quotient s₁) (q₂ : quotient s₂) (f : α → β → γ)\n  (h : ∀ a₁ a₂ b₁ b₂, @setoid.r α s₁ a₁ b₁ → @setoid.r β s₂ a₂ b₂ → f a₁ a₂ = f b₁ b₂) : γ :=\nquotient.lift_on₂ q₁ q₂ f h\n\n@[simp]\nprotected lemma lift_on₂'_mk' (f : α → β → γ) (h) (a : α) (b : β) :\n  quotient.lift_on₂' (@quotient.mk' _ s₁ a) (@quotient.mk' _ s₂ b) f h = f a b := rfl\n\n/-- A version of `quotient.ind` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s₁ → Prop}\n  (h : ∀ a, p (quotient.mk' a)) (q : quotient s₁) : p q :=\nquotient.ind h q\n\n/-- A version of `quotient.ind₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma ind₂' {p : quotient s₁ → quotient s₂ → Prop}\n  (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂))\n  (q₁ : quotient s₁) (q₂ : quotient s₂) : p q₁ q₂ :=\nquotient.ind₂ h q₁ q₂\n\n/-- A version of `quotient.induction_on` taking `{s : setoid α}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s₁ → Prop} (q : quotient s₁)\n  (h : ∀ a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n/-- A version of `quotient.induction_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on₂' {p : quotient s₁ → quotient s₂ → Prop} (q₁ : quotient s₁)\n  (q₂ : quotient s₂) (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂)) : p q₁ q₂ :=\nquotient.induction_on₂ q₁ q₂ h\n\n/-- A version of `quotient.induction_on₃` taking `{s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on₃' {p : quotient s₁ → quotient s₂ → quotient s₃ → Prop}\n  (q₁ : quotient s₁) (q₂ : quotient s₂) (q₃ : quotient s₃)\n  (h : ∀ a₁ a₂ a₃, p (quotient.mk' a₁) (quotient.mk' a₂) (quotient.mk' a₃)) : p q₁ q₂ q₃ :=\nquotient.induction_on₃ q₁ q₂ q₃ h\n\n/-- A version of `quotient.rec_on_subsingleton` taking `{s₁ : setoid α}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_eliminator]\nprotected def rec_on_subsingleton' {φ : quotient s₁ → Sort*}\n  [h : ∀ a, subsingleton (φ ⟦a⟧)] (q : quotient s₁) (f : Π a, φ (quotient.mk' a)) : φ q :=\nquotient.rec_on_subsingleton q f\n\n/-- A version of `quotient.rec_on_subsingleton₂` taking `{s₁ : setoid α} {s₂ : setoid α}`\nas implicit arguments instead of instance arguments. -/\nattribute [reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton₂'\n   {φ : quotient s₁ → quotient s₂ → Sort*} [h : ∀ a b, subsingleton (φ ⟦a⟧ ⟦b⟧)]\n   (q₁ : quotient s₁) (q₂ : quotient s₂) (f : Π a₁ a₂, φ (quotient.mk' a₁) (quotient.mk' a₂)) :\n   φ q₁ q₂ :=\nquotient.rec_on_subsingleton₂ q₁ q₂ f\n\n/-- Recursion on a `quotient` argument `a`, result type depends on `⟦a⟧`. -/\nprotected def hrec_on' {φ : quotient s₁ → Sort*} (qa : quotient s₁) (f : Π a, φ (quotient.mk' a))\n  (c : ∀ a₁ a₂, a₁ ≈ a₂ → f a₁ == f a₂) : φ qa :=\nquot.hrec_on qa f c\n\n@[simp] \n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂' {φ : quotient s₁ → quotient s₂ → Sort*} (qa : quotient s₁)\n  (qb : quotient s₂) (f : ∀ a b, φ (quotient.mk' a) (quotient.mk' b))\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) : φ qa qb :=\nquotient.hrec_on₂ qa qb f c\n\n@[simp] lemma hrec_on₂'_mk' {φ : quotient s₁ → quotient s₂ → Sort*}\n  (f : ∀ a b, φ (quotient.mk' a) (quotient.mk' b))\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) (x : α) (qb : quotient s₂) :\n  (quotient.mk' x).hrec_on₂' qb f c = qb.hrec_on' (f x) (λ b₁ b₂, c _ _ _ _ (setoid.refl _)) :=\nrfl\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : α → β) (h : (s₁.r ⇒ s₂.r) f f) :\n  quotient s₁ → quotient s₂ :=\nquot.map f h\n\n@[simp] lemma map'_mk' (f : α → β) (h) (x : α) :\n  (quotient.mk' x : quotient s₁).map' f h = (quotient.mk' (f x) : quotient s₂) :=\nrfl\n\n/-- A version of `quotient.map₂` using curly braces and unification. -/\nprotected def map₂' (f : α → β → γ) (h : (s₁.r ⇒ s₂.r ⇒ s₃.r) f f) :\n  quotient s₁ → quotient s₂ → quotient s₃ :=\nquotient.map₂ f h\n\n@[simp] lemma map₂'_mk' (f : α → β → γ) (h) (x : α) :\n  (quotient.mk' x : quotient s₁).map₂' f h =\n    (quotient.map' (f x) (h (setoid.refl x)) : quotient s₂ → quotient s₃) :=\nrfl\n\nlemma exact' {a b : α} :\n  (quotient.mk' a : quotient s₁) = quotient.mk' b → @setoid.r _ s₁ a b :=\nquotient.exact\n\nlemma sound' {a b : α} : @setoid.r _ s₁ a b → @quotient.mk' α s₁ a = quotient.mk' b :=\nquotient.sound\n\n@[simp]\nprotected lemma eq' {a b : α} : @quotient.mk' α s₁ a = quotient.mk' b ↔ @setoid.r _ s₁ a b :=\nquotient.eq\n\n/-- A version of `quotient.out` taking `{s₁ : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : quotient s₁) : α := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s₁) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : α) : @setoid.r α s₁ (quotient.mk' a : quotient s₁).out' a :=\nquotient.exact (quotient.out_eq _)\n\nsection\n\nvariables [setoid α]\n\nprotected lemma mk'_eq_mk (x : α) : quotient.mk' x = ⟦x⟧ := rfl\n\n@[simp] protected lemma lift_on'_mk (x : α) (f : α → β) (h) : ⟦x⟧.lift_on' f h = f x := rfl\n\n@[simp] protected lemma lift_on₂'_mk [setoid β] (f : α → β → γ) (h) (a : α) (b : β) :\n  quotient.lift_on₂' ⟦a⟧ ⟦b⟧ f h = f a b := quotient.lift_on₂'_mk' _ _ _ _\n\n@[simp] lemma map'_mk [setoid β] (f : α → β) (h) (x : α) : ⟦x⟧.map' f h = ⟦f x⟧ := rfl\n\nend\n\nend quotient\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/data/quot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.7549149923816048, "lm_q1q2_score": 0.4643390544140514}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\n\nimport control.functor.multivariate\nimport data.qpf.multivariate.basic\n\n/-!\n# Constant functors are QPFs\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nConstant functors map every type vectors to the same target type. This\nis a useful device for constructing data types from more basic types\nthat are not actually functorial. For instance `const n nat` makes\n`nat` into a functor that can be used in a functor-based data type\nspecification.\n-/\n\nuniverses u\n\nnamespace mvqpf\nopen_locale mvfunctor\n\nvariables (n : ℕ)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A α} [inhabited A] : inhabited (const n A α) :=\n⟨ (default : A) ⟩\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {α β : typevec.{u} n} (f : α ⟹ β)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) α := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) α) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) α) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A α) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) α → (const n A) β :=\nλ x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := λ α β f, const.map }\n\nlemma map_mk (x : A) :\n  f <$$> const.mk x = const.mk x := rfl\n\nlemma get_map (x : (const n A) α) :\n  const.get (f <$$> x) = const.get x := rfl\n\ninstance mvqpf : @mvqpf _ (const n A) (mvqpf.const.mvfunctor) :=\n{ P         := mvpfunctor.const n A,\n  abs       := λ α x, mvpfunctor.const.get x,\n  repr      := λ α x, mvpfunctor.const.mk n x,\n  abs_repr  := by intros; simp,\n  abs_map   := by intros; simp; refl, }\n\nend const\n\nend mvqpf\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/qpf/multivariate/constructions/const.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.709019146082187, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.46433290155917456}}
{"text": "def Hd : List α → Type\n  | []     => PUnit\n  | a :: _ => α\n\ndef hd : (as : List α) → Hd as\n  | []     => ()\n  | a :: l => a\n\ntheorem inj_hd (α : Type) : (a a': α) → (l l' : List α) → a :: l = a' :: l' → a = a' := by\n  intro a a' l l' h\n  show hd (a :: l) = hd (a' :: l')\n  cases h\n  rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/depHd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.46433289903049196}}
{"text": "/-\nCopyright (c) 2014 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad\n\nWeak orders \"≤\", strict orders \"<\", and structures that include both.\n-/\nimport .binary\nuniverses u v w\nhott_theory\nset_option old_structure_cmd true\n\nnamespace hott\n\nopen algebra\n\nvariable {A : Type _}\n\n/- weak orders -/\n\nclass has_le (α : Type u) := (le : α → α → Type u)\nclass has_lt (α : Type u) := (lt : α → α → Type u)\n\n@[reducible] def ge {α : Type u} [has_le α] (a b : α) : Type u := has_le.le b a\n@[reducible] def gt {α : Type u} [has_lt α] (a b : α) : Type u := has_lt.lt b a\n\nhott_theory_cmd \"local infix [parsing_only] ` <= ` := hott.has_le.le\"\nhott_theory_cmd \"local infix ` ≤ `  := hott.has_le.le\"\nhott_theory_cmd \"local infix ` < ` := hott.has_lt.lt\"\nhott_theory_cmd \"local infix [parsing_only] ` >= ` := hott.ge\"\nhott_theory_cmd \"local infix ` ≥ `  := hott.ge\"\nhott_theory_cmd \"local infix ` > ` := hott.gt\"\n\nnamespace algebra\n@[hott, class] structure weak_order (A : Type _) extends has_le A :=\n(le_refl : Πa, le a a)\n(le_trans : Πa b c, le a b → le b c → le a c)\n(le_antisymm : Πa b, le a b → le b a → a = b)\n\nsection\n  variable [s : weak_order A]\n  include s\n\n  @[hott, refl] def le.rfl {a : A} : a ≤ a := weak_order.le_refl _\n  @[hott] def le.refl (a : A) : a ≤ a := weak_order.le_refl _\n\n  @[hott] def le_of_eq {a b : A} (H : a = b) : a ≤ b := transport (λx, a ≤ x) H (le.refl a)\n  @[hott] def ge_of_eq {a b : A} (H : a = b) : a ≥ b := le_of_eq H⁻¹\n\n  @[hott, trans] def le.trans {a b c : A} : a ≤ b → b ≤ c → a ≤ c := weak_order.le_trans _ _ _\n\n  @[hott, trans] def le.trans_eq {a b c : A} (H1 : a ≤ b) (H2 : b = c) : a ≤ c :=\n  le.trans H1 (le_of_eq H2)\n\n  @[hott, trans] def le.eq_trans {a b c : A} (H1 : a = b) (H2 : b ≤ c) : a ≤ c :=\n  le.trans (le_of_eq H1) H2\n\n  @[hott, trans] def ge.trans {a b c : A} (H1 : a ≥ b) (H2: b ≥ c) : a ≥ c := le.trans H2 H1\n\n  @[hott, trans] def ge.trans_eq {a b c : A} (H1 : a ≥ b) (H2 : b = c) : a ≥ c :=\n  le.eq_trans H2⁻¹ H1\n\n  @[hott, trans] def ge.eq_trans {a b c : A} (H1 : a = b) (H2 : b ≥ c) : a ≥ c :=\n  le.trans_eq H2 H1⁻¹\n\n  @[hott] def le.antisymm {a b : A} : a ≤ b → b ≤ a → a = b := weak_order.le_antisymm _ _\n\n  -- Alternate syntax. (Abbreviations do not migrate well.)\n  @[hott] def eq_of_le_of_ge {a b : A} : a ≤ b → b ≤ a → a = b := le.antisymm\nend\n\n@[hott, class] structure linear_weak_order (A : Type _) extends weak_order A :=\n(le_total : Πa b, le a b ⊎ le b a)\n\nsection\n  variables [linear_weak_order A]\n\n  @[hott] def le.total (a b : A) : a ≤ b ⊎ b ≤ a := linear_weak_order.le_total _ _\n\n  @[hott] theorem le_of_not_ge {a b : A} (H : ¬ a ≥ b) : a ≤ b := sum.resolve_left (le.total _ _) H\n\n  @[hott] def le_by_cases (a b : A) {P : Type _} (H1 : a ≤ b → P) (H2 : b ≤ a → P) : P :=\n  begin\n    cases (le.total a b) with H H,\n    { exact H1 H},\n    { exact H2 H}\n  end\nend\n\n/- strict orders -/\n\n@[hott, class] structure strict_order (A : Type _) extends has_lt A :=\n(lt_irrefl : Πa, ¬ lt a a)\n(lt_trans : Πa b c, lt a b → lt b c → lt a c)\n\nsection\n  variable [s : strict_order A]\n  include s\n\n  @[hott] def lt.irrefl (a : A) : ¬ a < a := strict_order.lt_irrefl _\n  @[hott] def not_lt_self (a : A) : ¬ a < a := lt.irrefl _   -- alternate syntax\n\n  @[hott] theorem lt_self_iff_empty (a : A) : a < a ↔ empty :=\n  iff_empty_intro (lt.irrefl a)\n\n  @[hott, trans] def lt.trans {a b c : A} : a < b → b < c → a < c := strict_order.lt_trans _ _ _\n\n  @[hott, trans] def lt.trans_eq {a b c : A} (H1 : a < b) (H2 : b = c) : a < c :=\n  by hinduction H2; exact H1\n\n  @[hott, trans] def lt.eq_trans {a b c : A} (H1 : a = b) (H2 : b < c) : a < c :=\n  by hinduction H1; exact H2\n\n  @[hott, trans] def gt.trans {a b c : A} (H1 : a > b) (H2: b > c) : a > c := lt.trans H2 H1\n\n  @[hott, trans] def gt.trans_eq {a b c : A} (H1 : a > b) (H2 : b = c) : a > c :=\n  by hinduction H2; exact H1\n\n  @[hott, trans] def gt.eq_trans {a b c : A} (H1 : a = b) (H2 : b > c) : a > c :=\n  by hinduction H1; exact H2\n\n  @[hott] def ne_of_lt {a b : A} (lt_ab : a < b) : a ≠ b :=\n  assume eq_ab : a = b,\n  show empty, from lt.irrefl b (eq_ab ▸ lt_ab)\n\n  @[hott] theorem ne_of_gt {a b : A} (gt_ab : a > b) : a ≠ b :=\n  ne.symm (ne_of_lt gt_ab)\n\n  @[hott] theorem lt.asymm {a b : A} (H : a < b) : ¬ b < a :=\n  assume H1 : b < a, lt.irrefl _ (lt.trans H H1)\n\n  @[hott] theorem not_lt_of_gt {a b : A} (H : a > b) : ¬ a < b := lt.asymm H    -- alternate syntax\nend\n\n/- well-founded orders -/\n\n@[hott, class] structure wf_strict_order (A : Type _) extends strict_order A :=\n(wf_rec : ΠP : A → Type _, (Πx, (Πy, lt y x → P y) → P x) → Πx, P x)\n\n@[hott] def wf.rec_on {A : Type _} [s : wf_strict_order A] {P : A → Type _}\n    (x : A) (H : Πx, (Πy, wf_strict_order.lt y x → P y) → P x) : P x :=\nwf_strict_order.wf_rec P H x\n\n/- structures with a weak and a strict order -/\n\n@[hott, class] structure order_pair (A : Type _) extends weak_order A, has_lt A :=\n(le_of_lt : Π a b, lt a b → le a b)\n(lt_of_lt_of_le : Π a b c, lt a b → le b c → lt a c)\n(lt_of_le_of_lt : Π a b c, le a b → lt b c → lt a c)\n(lt_irrefl : Π a, ¬ lt a a)\n\nsection\n  variable [s : order_pair A]\n  variables {a b c : A}\n  include s\n\n  @[hott] def le_of_lt : a < b → a ≤ b := order_pair.le_of_lt _ _\n\n  @[hott, trans] def lt_of_lt_of_le : a < b → b ≤ c → a < c := order_pair.lt_of_lt_of_le _ _ _\n\n  @[hott, trans] def lt_of_le_of_lt : a ≤ b → b < c → a < c := order_pair.lt_of_le_of_lt _ _ _\n\n  @[hott] private def lt_irrefl (s' : order_pair A) (a : A) : ¬ a < a := order_pair.lt_irrefl _\n\n  @[hott] private def lt_trans (s' : order_pair A) (a b c: A) (lt_ab : a < b) (lt_bc : b < c) :\n    a < c :=\n  lt_of_lt_of_le lt_ab (le_of_lt lt_bc)\n\n  @[hott, instance] def order_pair.to_strict_order : strict_order A :=\n  { lt_irrefl := lt_irrefl s, lt_trans := lt_trans s, ..s }\n\n  @[hott, trans] def gt_of_gt_of_ge (H1 : a > b) (H2 : b ≥ c) : a > c := lt_of_le_of_lt H2 H1\n\n  @[hott, trans] def gt_of_ge_of_gt (H1 : a ≥ b) (H2 : b > c) : a > c := lt_of_lt_of_le H2 H1\n\n  @[hott] def not_le_of_gt (H : a > b) : ¬ a ≤ b :=\n  assume H1 : a ≤ b,\n  lt.irrefl _ (lt_of_lt_of_le H H1)\n\n  @[hott] theorem not_lt_of_ge (H : a ≥ b) : ¬ a < b :=\n  assume H1 : a < b,\n  lt.irrefl _ (lt_of_le_of_lt H H1)\nend\n\n@[hott, class] structure strong_order_pair (A : Type _) extends weak_order A, has_lt A :=\n(le_iff_lt_sum_eq : Πa b, le a b ↔ lt a b ⊎ a = b)\n(lt_irrefl : Π a, ¬ lt a a)\n\n@[hott] def le_iff_lt_sum_eq [s : strong_order_pair A] {a b : A} : a ≤ b ↔ a < b ⊎ a = b :=\nstrong_order_pair.le_iff_lt_sum_eq _ _\n\n@[hott] def lt_sum_eq_of_le [s : strong_order_pair A] {a b : A} (le_ab : a ≤ b) : a < b ⊎ a = b :=\niff.mp le_iff_lt_sum_eq le_ab\n\n@[hott] def le_of_lt_sum_eq [s : strong_order_pair A] {a b : A} (lt_sum_eq : a < b ⊎ a = b) :\n  a ≤ b :=\niff.mpr le_iff_lt_sum_eq lt_sum_eq\n\n@[hott] private def lt_irrefl' [s : strong_order_pair A] (a : A) : ¬ a < a :=\nstrong_order_pair.lt_irrefl _\n\n@[hott] private def le_of_lt' [s : strong_order_pair A] (a b : A) : a < b → a ≤ b :=\nλHlt, le_of_lt_sum_eq (sum.inl Hlt)\n\n@[hott] private def lt_iff_le_prod_ne [s : strong_order_pair A] {a b : A} :\n  a < b ↔ (a ≤ b × a ≠ b) :=\niff.intro\n  (λHlt, pair (le_of_lt_sum_eq (sum.inl Hlt)) (λHab, absurd (Hab ▸ Hlt) (lt_irrefl' _)))\n  (λHand,\n   have Hor : a < b ⊎ a = b, from lt_sum_eq_of_le Hand.fst,\n   sum.resolve_right Hor Hand.snd)\n\n@[hott] theorem lt_of_le_of_ne [s : strong_order_pair A] {a b : A} : a ≤ b → a ≠ b → a < b :=\nλH1 H2, iff.mpr lt_iff_le_prod_ne (pair H1 H2)\n\n@[hott] private def ne_of_lt' [s : strong_order_pair A] {a b : A} (H : a < b) : a ≠ b :=\n((iff.mp (@lt_iff_le_prod_ne _ _ _ _)) H).snd\n\n@[hott] private def lt_of_lt_of_le' [s : strong_order_pair A] (a b c : A) : a < b → b ≤ c → a < c :=\nassume lt_ab : a < b,\nassume le_bc : b ≤ c,\nhave le_ac : a ≤ c, from le.trans (le_of_lt' _ _ lt_ab) le_bc,\nhave ne_ac : a ≠ c, from\n  assume eq_ac : a = c,\n  have le_ba : b ≤ a, from eq_ac⁻¹ ▸ le_bc,\n  have eq_ab : a = b, from le.antisymm  (le_of_lt' _ _ lt_ab) le_ba,\n  show empty, from ne_of_lt' lt_ab eq_ab,\nshow a < c, from iff.mpr (lt_iff_le_prod_ne) (pair le_ac ne_ac)\n\n@[hott] def lt_of_le_of_lt' [s : strong_order_pair A] (a b c : A) : a ≤ b → b < c → a < c :=\nassume le_ab : a ≤ b,\nassume lt_bc : b < c,\nhave le_ac : a ≤ c, from le.trans le_ab (le_of_lt' _ _ lt_bc),\nhave ne_ac : a ≠ c, from\n  assume eq_ac : a = c,\n  have le_cb : c ≤ b, from eq_ac ▸ le_ab,\n  have eq_bc : b = c, from le.antisymm  (le_of_lt' _ _ lt_bc) le_cb,\n  show empty, from ne_of_lt' lt_bc eq_bc,\nshow a < c, from iff.mpr (lt_iff_le_prod_ne) (pair le_ac ne_ac)\n\n@[hott, instance] def strong_order_pair.to_order_pair [s : strong_order_pair A] : order_pair A :=\n{ lt_irrefl := lt_irrefl',\n  le_of_lt := le_of_lt',\n  lt_of_le_of_lt := lt_of_le_of_lt',\n  lt_of_lt_of_le := lt_of_lt_of_le', ..s }\n\n/- linear orders -/\n\n@[hott, class] structure linear_order_pair (A : Type _) extends order_pair A, linear_weak_order A\n\n@[hott, class] structure linear_strong_order_pair (A : Type _) extends strong_order_pair A,\n    linear_weak_order A\n\n@[hott, instance] def linear_strong_order_pair.to_linear_order_pair\n    [s : linear_strong_order_pair A] : linear_order_pair A :=\n{ ..s, ..strong_order_pair.to_order_pair }\n\nsection\n  variable [s : linear_strong_order_pair A]\n  variables (a b c : A)\n  include s\n\n  @[hott] def lt.trichotomy : a < b ⊎ a = b ⊎ b < a :=\n  sum.elim (le.total a b)\n    (assume H : a ≤ b,\n      sum.elim (iff.mp le_iff_lt_sum_eq H) sum.inl (assume H1, sum.inr (sum.inl H1)))\n    (assume H : b ≤ a,\n      sum.elim (iff.mp le_iff_lt_sum_eq H)\n        (assume H1, sum.inr (sum.inr H1))\n        (assume H1, sum.inr (sum.inl (H1⁻¹))))\n\n  @[hott] def lt.by_cases {a b : A} {P : Type _}\n    (H1 : a < b → P) (H2 : a = b → P) (H3 : b < a → P) : P :=\n  sum.elim (lt.trichotomy _ _)\n    (assume H, H1 H)\n    (assume H, sum.elim H (assume H', H2 H') (assume H', H3 H'))\n\n  @[hott] def lt_ge_by_cases {a b : A} {P : Type _} (H1 : a < b → P) (H2 : a ≥ b → P) : P :=\n  lt.by_cases H1 (λH, H2 (le_of_eq H⁻¹)) (λH, H2 (le_of_lt H))\n\n  @[hott] def le_of_not_gt {a b : A} (H : ¬ a > b) : a ≤ b :=\n  lt.by_cases (assume H', absurd H' H) (assume H', le_of_eq H'⁻¹) (assume H', le_of_lt H')\n\n  @[hott] theorem lt_of_not_ge {a b : A} (H : ¬ a ≥ b) : a < b :=\n  lt.by_cases\n    (assume H', absurd begin exact le_of_lt H' end H)\n    (assume H', absurd (le_of_eq H') H)\n    (assume H', H')\n\n  @[hott] theorem lt_sum_ge : a < b ⊎ a ≥ b :=\n  lt.by_cases\n    (assume H1 : a < b, sum.inl H1)\n    (assume H1 : a = b, sum.inr (le_of_eq H1⁻¹))\n    (assume H1 : a > b, sum.inr (le_of_lt H1))\n\n  @[hott] theorem le_sum_gt : a ≤ b ⊎ a > b :=\n  sum.swap (lt_sum_ge b a)\n\n  @[hott] theorem lt_sum_gt_of_ne {a b : A} (H : a ≠ b) : a < b ⊎ a > b :=\n  lt.by_cases (assume H1, sum.inl H1) (assume H1, absurd H1 H) (assume H1, sum.inr H1)\nend\n\nopen decidable\n\n@[hott, class] structure decidable_linear_order (A : Type _) extends linear_strong_order_pair A :=\n(decidable_lt : decidable_rel lt)\n\nsection\n  variable [s : decidable_linear_order A]\n  variables {a b c d : A}\n  include s\n  open hott.decidable\n\n  @[hott, instance] def decidable_lt : decidable (a < b) :=\n  @decidable_linear_order.decidable_lt _ _ _ _\n\n  @[hott, instance] def decidable_le : decidable (a ≤ b) :=\n  by_cases\n    (assume H : a < b, inl (le_of_lt H))\n    (assume H : ¬ a < b,\n      have H1 : b ≤ a, from le_of_not_gt H,\n      by_cases\n        (assume H2 : b < a, inr (not_le_of_gt H2))\n        (assume H2 : ¬ b < a, inl (le_of_not_gt H2)))\n\n  @[hott, instance] def has_decidable_eq : decidable (a = b) :=\n  by_cases\n    (assume H : a ≤ b,\n      by_cases\n        (assume H1 : b ≤ a, inl (le.antisymm H H1))\n        (assume H1 : ¬ b ≤ a, inr (assume H2 : a = b, H1 (le_of_eq H2⁻¹))))\n    (assume H : ¬ a ≤ b,\n      (inr (assume H1 : a = b, H (le_of_eq H1))))\n\n  @[hott] theorem eq_sum_lt_of_not_lt {a b : A} (H : ¬ a < b) : a = b ⊎ b < a :=\n  if Heq :: a = b then sum.inl Heq else sum.inr (lt_of_not_ge (λ Hge, H (lt_of_le_of_ne Hge Heq)))\n\n  @[hott] theorem eq_sum_lt_of_le {a b : A} (H : a ≤ b) : a = b ⊎ a < b :=\n    begin\n      hinduction eq_sum_lt_of_not_lt (not_lt_of_ge H) with x1 H' H',\n      exact sum.inl H'⁻¹,\n      exact sum.inr H'\n    end\n\n  @[hott] def lt.cases {B : Type _} (a b : A) (t_lt t_eq t_gt : B) : B :=\n  if' a = b then t_eq else (if' a < b then t_lt else t_gt)\n\n  @[hott] theorem lt.cases_of_eq {B : Type _} {a b : A} {t_lt t_eq t_gt : B} (H : a = b) :\n  lt.cases a b t_lt t_eq t_gt = t_eq := if_pos H\n\n  @[hott] theorem lt.cases_of_lt {B : Type _} {a b : A} {t_lt t_eq t_gt : B} (H : a < b) :\n    lt.cases a b t_lt t_eq t_gt = t_lt :=\n  if_neg (ne_of_lt H) ⬝ if_pos H\n\n  @[hott] theorem lt.cases_of_gt {B : Type _} {a b : A} {t_lt t_eq t_gt : B} (H : a > b) :\n    lt.cases a b t_lt t_eq t_gt = t_gt :=\n  if_neg (ne.symm (ne_of_lt H)) ⬝ if_neg (lt.asymm H)\n\n  @[hott] def min (a b : A) : A := if' a ≤ b then a else b\n  @[hott] def max (a b : A) : A := if' a ≤ b then b else a\n\n  /- these show min and max form a lattice -/\n\n  @[hott] theorem min_le_left (a b : A) : min a b ≤ a :=\n  hott.decidable.by_cases\n    (assume H : a ≤ b, by dsimp [min]; rwr [if_pos H])\n    (assume H : ¬ a ≤ b, by dsimp [min]; rwr [if_neg H]; apply le_of_lt (lt_of_not_ge H))\n\n  @[hott] theorem min_le_right (a b : A) : min a b ≤ b :=\n  hott.decidable.by_cases\n    (assume H : a ≤ b, by dsimp [min]; rwr [if_pos H]; apply H)\n    (assume H : ¬ a ≤ b, by dsimp [min]; rwr [if_neg H])\n\n  @[hott] theorem le_min {a b c : A} (H₁ : c ≤ a) (H₂ : c ≤ b) : c ≤ min a b :=\n  hott.decidable.by_cases\n    (assume H : a ≤ b, by dsimp [min]; rwr [if_pos H]; apply H₁)\n    (assume H : ¬ a ≤ b, by dsimp [min]; rwr [if_neg H]; apply H₂)\n\n  @[hott] theorem le_max_left (a b : A) : a ≤ max a b :=\n  hott.decidable.by_cases\n    (assume H : a ≤ b, by dsimp [max]; rwr [if_pos H]; apply H)\n    (assume H : ¬ a ≤ b, by dsimp [max]; rwr [if_neg H])\n\n  @[hott] theorem le_max_right (a b : A) : b ≤ max a b :=\n  hott.decidable.by_cases\n    (assume H : a ≤ b, by dsimp [max]; rwr [if_pos H])\n    (assume H : ¬ a ≤ b, by dsimp [max]; rwr [if_neg H]; apply le_of_lt (lt_of_not_ge H))\n\n  @[hott] theorem max_le {a b c : A} (H₁ : a ≤ c) (H₂ : b ≤ c) : max a b ≤ c :=\n  hott.decidable.by_cases\n    (assume H : a ≤ b, by dsimp [max]; rwr [if_pos H]; apply H₂)\n    (assume H : ¬ a ≤ b, by dsimp [max]; rwr [if_neg H]; apply H₁)\n\n  @[hott] theorem le_max_left_iff_unit (a b : A) : a ≤ max a b ↔ unit :=\n  iff_unit_intro (le_max_left a b)\n\n  @[hott] theorem le_max_right_iff_unit (a b : A) : b ≤ max a b ↔ unit :=\n  iff_unit_intro (le_max_right a b)\n\n  /- these are also proved for lattices, but with inf and sup in place of min and max -/\n\n  @[hott] theorem eq_min {a b c : A} (H₁ : c ≤ a) (H₂ : c ≤ b) (H₃ : Π{d}, d ≤ a → d ≤ b → d ≤ c) :\n    c = min a b :=\n  le.antisymm (le_min H₁ H₂) (H₃ (min_le_left _ _) (min_le_right _ _))\n\n  @[hott] theorem min.comm (a b : A) : min a b = min b a :=\n  eq_min (min_le_right _ _) (min_le_left _ _) (λ c H₁ H₂, le_min H₂ H₁)\n\n  @[hott] theorem min.assoc (a b c : A) : min (min a b) c = min a (min b c) :=\n  begin\n    apply eq_min,\n    { apply le.trans, apply min_le_left, apply min_le_left },\n    { apply le_min, apply le.trans, apply min_le_left, apply min_le_right, apply min_le_right },\n    { intros d H₁ H₂, apply le_min, apply le_min H₁, apply le.trans H₂, apply min_le_left,\n      apply le.trans H₂, apply min_le_right }\n  end\n\n  @[hott] theorem min.left_comm (a b c : A) : min a (min b c) = min b (min a c) :=\n  binary.left_comm (@min.comm A s) (@min.assoc A s) a b c\n\n  @[hott] theorem min.right_comm (a b c : A) : min (min a b) c = min (min a c) b :=\n  binary.right_comm (@min.comm A s) (@min.assoc A s) a b c\n\n  @[hott] theorem min_self (a : A) : min a a = a :=\n  by apply inverse; apply eq_min (le.refl a) le.rfl; intros; assumption\n\n  @[hott] theorem min_eq_left {a b : A} (H : a ≤ b) : min a b = a :=\n  by apply inverse; apply eq_min le.rfl H; intros; assumption\n\n  @[hott] theorem min_eq_right {a b : A} (H : b ≤ a) : min a b = b :=\n  by rwr min.comm; exact min_eq_left H\n\n  @[hott] theorem eq_max {a b c : A} (H₁ : a ≤ c) (H₂ : b ≤ c) (H₃ : Π{d}, a ≤ d → b ≤ d → c ≤ d) :\n    c = max a b :=\n  le.antisymm (H₃ (le_max_left _ _) (le_max_right _ _)) (max_le H₁ H₂)\n\n  @[hott] theorem max.comm (a b : A) : max a b = max b a :=\n  eq_max (le_max_right _ _) (le_max_left _ _) (λ c H₁ H₂, max_le H₂ H₁)\n\n  @[hott] theorem max.assoc (a b c : A) : max (max a b) c = max a (max b c) :=\n  begin\n    apply eq_max,\n    { apply le.trans, apply le_max_left a b, apply le_max_left },\n    { apply max_le, apply le.trans, apply le_max_right a b, apply le_max_left, apply le_max_right },\n    { intros d H₁ H₂, apply max_le, apply max_le H₁, apply le.trans (le_max_left _ _) H₂,\n      apply le.trans (le_max_right _ _) H₂}\n  end\n\n  @[hott] theorem max.left_comm (a b c : A) : max a (max b c) = max b (max a c) :=\n  binary.left_comm (@max.comm A s) (@max.assoc A s) a b c\n\n  @[hott] theorem max.right_comm (a b c : A) : max (max a b) c = max (max a c) b :=\n  binary.right_comm (@max.comm A s) (@max.assoc A s) a b c\n\n  @[hott] theorem max_self (a : A) : max a a = a :=\n  by apply inverse; apply eq_max (le.refl a) le.rfl; intros; assumption\n\n  @[hott] theorem max_eq_left {a b : A} (H : b ≤ a) : max a b = a :=\n  by apply inverse; apply eq_max le.rfl H; intros; assumption\n\n  @[hott] theorem max_eq_right {a b : A} (H : a ≤ b) : max a b = b :=\n  by rwr max.comm; exact max_eq_left H\n\n  /- these rely on lt_of_lt -/\n\n  @[hott] theorem min_eq_left_of_lt {a b : A} (H : a < b) : min a b = a :=\n  min_eq_left (le_of_lt H)\n\n  @[hott] theorem min_eq_right_of_lt {a b : A} (H : b < a) : min a b = b :=\n  min_eq_right (le_of_lt H)\n\n  @[hott] theorem max_eq_left_of_lt {a b : A} (H : b < a) : max a b = a :=\n  max_eq_left (le_of_lt H)\n\n  @[hott] theorem max_eq_right_of_lt {a b : A} (H : a < b) : max a b = b :=\n  max_eq_right (le_of_lt H)\n\n  /- these use the fact that it is a linear ordering -/\n\n  @[hott] theorem lt_min {a b c : A} (H₁ : a < b) (H₂ : a < c) : a < min b c :=\n  sum.elim (le_sum_gt _ _)\n    (assume H : b ≤ c, by rwr (min_eq_left H); apply H₁)\n    (assume H : b > c, by rwr (min_eq_right_of_lt H); apply H₂)\n\n  @[hott] theorem max_lt {a b c : A} (H₁ : a < c) (H₂ : b < c) : max a b < c :=\n  sum.elim (le_sum_gt _ _)\n    (assume H : a ≤ b, by rwr (max_eq_right H); apply H₂)\n    (assume H : a > b, by rwr (max_eq_left_of_lt H); apply H₁)\nend\nend algebra\nend hott\n", "meta": {"author": "gebner", "repo": "hott3", "sha": "7ead7a8a2503049eacd45cbff6587802bae2add2", "save_path": "github-repos/lean/gebner-hott3", "path": "github-repos/lean/gebner-hott3/hott3-7ead7a8a2503049eacd45cbff6587802bae2add2/src/hott/algebra/order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421275, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.46433289350587265}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Simon Hudon\n\n! This file was ported from Lean 3 source module data.pfunctor.multivariate.basic\n! leanprover-community/mathlib commit 23aa88e32dcc9d2a24cca7bc23268567ed4cd7d6\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Control.Functor.Multivariate\nimport Mathbin.Data.Pfunctor.Univariate.Basic\n\n/-!\n# Multivariate polynomial functors.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nMultivariate polynomial functors are used for defining M-types and W-types.\nThey map a type vector `α` to the type `Σ a : A, B a ⟹ α`, with `A : Type` and\n`B : A → typevec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `α` are positive.\n-/\n\n\nuniverse u v\n\nopen MvFunctor\n\n#print MvPFunctor /-\n/-- multivariate polynomial functors\n-/\nstructure MvPFunctor (n : ℕ) where\n  A : Type u\n  B : A → TypeVec.{u} n\n#align mvpfunctor MvPFunctor\n-/\n\nnamespace MvPFunctor\n\nopen MvFunctor (Liftp Liftr)\n\nvariable {n m : ℕ} (P : MvPFunctor.{u} n)\n\n#print MvPFunctor.Obj /-\n/-- Applying `P` to an object of `Type` -/\ndef Obj (α : TypeVec.{u} n) : Type u :=\n  Σa : P.A, P.B a ⟹ α\n#align mvpfunctor.obj MvPFunctor.Obj\n-/\n\n#print MvPFunctor.map /-\n/-- Applying `P` to a morphism of `Type` -/\ndef map {α β : TypeVec n} (f : α ⟹ β) : P.Obj α → P.Obj β := fun ⟨a, g⟩ => ⟨a, TypeVec.comp f g⟩\n#align mvpfunctor.map MvPFunctor.map\n-/\n\ninstance : Inhabited (MvPFunctor n) :=\n  ⟨⟨default, default⟩⟩\n\n#print MvPFunctor.Obj.inhabited /-\ninstance Obj.inhabited {α : TypeVec n} [Inhabited P.A] [∀ i, Inhabited (α i)] :\n    Inhabited (P.Obj α) :=\n  ⟨⟨default, fun _ _ => default⟩⟩\n#align mvpfunctor.obj.inhabited MvPFunctor.Obj.inhabited\n-/\n\ninstance : MvFunctor P.Obj :=\n  ⟨@MvPFunctor.map n P⟩\n\n#print MvPFunctor.map_eq /-\ntheorem map_eq {α β : TypeVec n} (g : α ⟹ β) (a : P.A) (f : P.B a ⟹ α) :\n    @MvFunctor.map _ P.Obj _ _ _ g ⟨a, f⟩ = ⟨a, g ⊚ f⟩ :=\n  rfl\n#align mvpfunctor.map_eq MvPFunctor.map_eq\n-/\n\n#print MvPFunctor.id_map /-\ntheorem id_map {α : TypeVec n} : ∀ x : P.Obj α, TypeVec.id <$$> x = x\n  | ⟨a, g⟩ => rfl\n#align mvpfunctor.id_map MvPFunctor.id_map\n-/\n\n#print MvPFunctor.comp_map /-\ntheorem comp_map {α β γ : TypeVec n} (f : α ⟹ β) (g : β ⟹ γ) :\n    ∀ x : P.Obj α, (g ⊚ f) <$$> x = g <$$> f <$$> x\n  | ⟨a, h⟩ => rfl\n#align mvpfunctor.comp_map MvPFunctor.comp_map\n-/\n\ninstance : LawfulMvFunctor P.Obj where\n  id_map := @id_map _ P\n  comp_map := @comp_map _ P\n\n#print MvPFunctor.const /-\n/-- Constant functor where the input object does not affect the output -/\ndef const (n : ℕ) (A : Type u) : MvPFunctor n :=\n  { A\n    B := fun a i => PEmpty }\n#align mvpfunctor.const MvPFunctor.const\n-/\n\nsection Const\n\nvariable (n) {A : Type u} {α β : TypeVec.{u} n}\n\n#print MvPFunctor.const.mk /-\n/-- Constructor for the constant functor -/\ndef const.mk (x : A) {α} : (const n A).Obj α :=\n  ⟨x, fun i a => PEmpty.elim a⟩\n#align mvpfunctor.const.mk MvPFunctor.const.mk\n-/\n\nvariable {n A}\n\n#print MvPFunctor.const.get /-\n/-- Destructor for the constant functor -/\ndef const.get (x : (const n A).Obj α) : A :=\n  x.1\n#align mvpfunctor.const.get MvPFunctor.const.get\n-/\n\n#print MvPFunctor.const.get_map /-\n@[simp]\ntheorem const.get_map (f : α ⟹ β) (x : (const n A).Obj α) : const.get (f <$$> x) = const.get x :=\n  by\n  cases x\n  rfl\n#align mvpfunctor.const.get_map MvPFunctor.const.get_map\n-/\n\n#print MvPFunctor.const.get_mk /-\n@[simp]\ntheorem const.get_mk (x : A) : const.get (const.mk n x : (const n A).Obj α) = x := by rfl\n#align mvpfunctor.const.get_mk MvPFunctor.const.get_mk\n-/\n\n#print MvPFunctor.const.mk_get /-\n@[simp]\ntheorem const.mk_get (x : (const n A).Obj α) : const.mk n (const.get x) = x :=\n  by\n  cases x\n  dsimp [const.get, const.mk]\n  congr with (_⟨⟩)\n#align mvpfunctor.const.mk_get MvPFunctor.const.mk_get\n-/\n\nend Const\n\n#print MvPFunctor.comp /-\n/-- Functor composition on polynomial functors -/\ndef comp (P : MvPFunctor.{u} n) (Q : Fin2 n → MvPFunctor.{u} m) : MvPFunctor m\n    where\n  A := Σa₂ : P.1, ∀ i, P.2 a₂ i → (Q i).1\n  B a i := Σ(j : _)(b : P.2 a.1 j), (Q j).2 (a.snd j b) i\n#align mvpfunctor.comp MvPFunctor.comp\n-/\n\nvariable {P} {Q : Fin2 n → MvPFunctor.{u} m} {α β : TypeVec.{u} m}\n\n#print MvPFunctor.comp.mk /-\n/-- Constructor for functor composition -/\ndef comp.mk (x : P.Obj fun i => (Q i).Obj α) : (comp P Q).Obj α :=\n  ⟨⟨x.1, fun i a => (x.2 _ a).1⟩, fun i a => (x.snd a.fst a.snd.fst).snd i a.snd.snd⟩\n#align mvpfunctor.comp.mk MvPFunctor.comp.mk\n-/\n\n#print MvPFunctor.comp.get /-\n/-- Destructor for functor composition -/\ndef comp.get (x : (comp P Q).Obj α) : P.Obj fun i => (Q i).Obj α :=\n  ⟨x.1.1, fun i a => ⟨x.fst.snd i a, fun (j : Fin2 m) (b : (Q i).B _ j) => x.snd j ⟨i, ⟨a, b⟩⟩⟩⟩\n#align mvpfunctor.comp.get MvPFunctor.comp.get\n-/\n\n#print MvPFunctor.comp.get_map /-\ntheorem comp.get_map (f : α ⟹ β) (x : (comp P Q).Obj α) :\n    comp.get (f <$$> x) = (fun i (x : (Q i).Obj α) => f <$$> x) <$$> comp.get x :=\n  by\n  cases x\n  rfl\n#align mvpfunctor.comp.get_map MvPFunctor.comp.get_map\n-/\n\n#print MvPFunctor.comp.get_mk /-\n@[simp]\ntheorem comp.get_mk (x : P.Obj fun i => (Q i).Obj α) : comp.get (comp.mk x) = x :=\n  by\n  cases x\n  simp! [comp.get, comp.mk]\n#align mvpfunctor.comp.get_mk MvPFunctor.comp.get_mk\n-/\n\n#print MvPFunctor.comp.mk_get /-\n@[simp]\ntheorem comp.mk_get (x : (comp P Q).Obj α) : comp.mk (comp.get x) = x :=\n  by\n  cases x\n  dsimp [comp.get, comp.mk]\n  ext : 2 <;> intros ; rfl; rfl\n  congr ; ext1 <;> intros <;> rfl\n  ext : 2; congr ; rcases x_1 with ⟨a, b, c⟩ <;> rfl\n#align mvpfunctor.comp.mk_get MvPFunctor.comp.mk_get\n-/\n\n#print MvPFunctor.liftP_iff /-\n/-\nlifting predicates and relations\n-/\ntheorem liftP_iff {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (x : P.Obj α) :\n    LiftP p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i j, p (f i j) :=\n  by\n  constructor\n  · rintro ⟨y, hy⟩\n    cases' h : y with a f\n    refine' ⟨a, fun i j => (f i j).val, _, fun i j => (f i j).property⟩\n    rw [← hy, h, map_eq]\n    rfl\n  rintro ⟨a, f, xeq, pf⟩\n  use ⟨a, fun i j => ⟨f i j, pf i j⟩⟩\n  rw [xeq]; rfl\n#align mvpfunctor.liftp_iff MvPFunctor.liftP_iff\n-/\n\n#print MvPFunctor.liftP_iff' /-\ntheorem liftP_iff' {α : TypeVec n} (p : ∀ ⦃i⦄, α i → Prop) (a : P.A) (f : P.B a ⟹ α) :\n    @LiftP.{u} _ P.Obj _ α p ⟨a, f⟩ ↔ ∀ i x, p (f i x) :=\n  by\n  simp only [liftp_iff, Sigma.mk.inj_iff] <;> constructor <;> intro\n  · casesm*Exists _, _ ∧ _\n    subst_vars\n    assumption\n  repeat' first |constructor|assumption\n#align mvpfunctor.liftp_iff' MvPFunctor.liftP_iff'\n-/\n\n#print MvPFunctor.liftR_iff /-\ntheorem liftR_iff {α : TypeVec n} (r : ∀ ⦃i⦄, α i → α i → Prop) (x y : P.Obj α) :\n    LiftR r x y ↔ ∃ a f₀ f₁, x = ⟨a, f₀⟩ ∧ y = ⟨a, f₁⟩ ∧ ∀ i j, r (f₀ i j) (f₁ i j) :=\n  by\n  constructor\n  · rintro ⟨u, xeq, yeq⟩\n    cases' h : u with a f\n    use a, fun i j => (f i j).val.fst, fun i j => (f i j).val.snd\n    constructor\n    · rw [← xeq, h]\n      rfl\n    constructor\n    · rw [← yeq, h]\n      rfl\n    intro i j\n    exact (f i j).property\n  rintro ⟨a, f₀, f₁, xeq, yeq, h⟩\n  use ⟨a, fun i j => ⟨(f₀ i j, f₁ i j), h i j⟩⟩\n  dsimp; constructor\n  · rw [xeq]\n    rfl\n  rw [yeq]; rfl\n#align mvpfunctor.liftr_iff MvPFunctor.liftR_iff\n-/\n\nopen Set MvFunctor\n\n#print MvPFunctor.supp_eq /-\ntheorem supp_eq {α : TypeVec n} (a : P.A) (f : P.B a ⟹ α) (i) :\n    @supp.{u} _ P.Obj _ α (⟨a, f⟩ : P.Obj α) i = f i '' univ :=\n  by\n  ext; simp only [supp, image_univ, mem_range, mem_set_of_eq]\n  constructor <;> intro h\n  · apply @h fun i x => ∃ y : P.B a i, f i y = x\n    rw [liftp_iff']\n    intros\n    refine' ⟨_, rfl⟩\n  · simp only [liftp_iff']\n    cases h\n    subst x\n    tauto\n#align mvpfunctor.supp_eq MvPFunctor.supp_eq\n-/\n\nend MvPFunctor\n\n/-\nDecomposing an n+1-ary pfunctor.\n-/\nnamespace MvPFunctor\n\nopen TypeVec\n\nvariable {n : ℕ} (P : MvPFunctor.{u} (n + 1))\n\n#print MvPFunctor.drop /-\n/-- Split polynomial functor, get a n-ary functor\nfrom a `n+1`-ary functor -/\ndef drop : MvPFunctor n where\n  A := P.A\n  B a := (P.B a).drop\n#align mvpfunctor.drop MvPFunctor.drop\n-/\n\n#print MvPFunctor.last /-\n/-- Split polynomial functor, get a univariate functor\nfrom a `n+1`-ary functor -/\ndef last : PFunctor where\n  A := P.A\n  B a := (P.B a).getLast\n#align mvpfunctor.last MvPFunctor.last\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print MvPFunctor.appendContents /-\n/-- append arrows of a polynomial functor application -/\n@[reducible]\ndef appendContents {α : TypeVec n} {β : Type _} {a : P.A} (f' : P.drop.B a ⟹ α)\n    (f : P.getLast.B a → β) : P.B a ⟹ (α ::: β) :=\n  splitFun f' f\n#align mvpfunctor.append_contents MvPFunctor.appendContents\n-/\n\nend MvPFunctor\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Pfunctor/Multivariate/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710233, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4643328879812529}}
{"text": "import Radon.LC_limit\nimport analysis.normed_space.weak_dual\n\nopen_locale nnreal big_operators classical\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\nopen topological_space\n\nlocal attribute [instance]\n  locally_constant.seminormed_add_comm_group\n  locally_constant.pseudo_metric_space\n\nnamespace Profinite\n\n/-- The weak dual of `C(X,ℝ)` is linearly equivalent to\nthe weak dual of `locally_constant X ℝ`. -/\ndef weak_dual_C_equiv_LC (X : Profinite.{0}) :\n  weak_dual ℝ C(X,ℝ) ≃ₗ[ℝ] weak_dual ℝ (locally_constant X ℝ) :=\n{ inv_fun := X.weak_dual_LC_to_C,\n  left_inv := begin\n    intros f, ext t,\n    show (locally_constant.pkg X ℝ).extend _ _ = _,\n    --  `dsimp [weak_dual_C_to_LC, weak_dual_LC_to_C]` works instead of `show` but is slower\n    apply (locally_constant.pkg X ℝ).induction_on t,\n    { apply is_closed_eq,\n      refine (locally_constant.pkg X ℝ).continuous_extend,\n      exact f.2 },\n    { intros e,\n      rw (locally_constant.pkg X ℝ).extend_coe, refl,\n      apply continuous_linear_map.uniform_continuous,\n      apply_instance }\n  end,\n  right_inv := begin\n    intros f, ext t,\n    show (locally_constant.pkg X ℝ).extend _ _ = _,\n--  `dsimp [weak_dual_C_to_LC, weak_dual_LC_to_C, weak_dual.comap]` works instead of `show`,\n--  but is slower,\n    erw (locally_constant.pkg X ℝ).extend_coe,\n    apply continuous_linear_map.uniform_continuous,\n    apply_instance,\n  end,\n  ..(X.weak_dual_C_to_LC) }\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_to_Radon_LC (X : Profinite.{0}) (p c : ℝ≥0) :\n  X.Radon p c ⟶ X.Radon_LC p c :=\n{ to_fun := λ μ, ⟨weak_dual_C_to_LC _ μ.1, μ.2⟩,\n  continuous_to_fun := begin\n    apply continuous.subtype_mk,\n    refine continuous.comp _ continuous_subtype_coe,\n    exact continuous_linear_map.continuous _,\n  end }\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_to_Radon (X : Profinite.{0}) (p c : ℝ≥0) :\n  X.Radon_LC p c → X.Radon p c :=\nλ μ, ⟨weak_dual_LC_to_C _ μ.1, begin\n    change (weak_dual_C_to_LC _ (weak_dual_LC_to_C _ μ.1)).bdd_LC p c,\n    erw X.weak_dual_C_equiv_LC.apply_symm_apply,\n    exact μ.2,\n  end⟩\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_to_weak_dual (X : Profinite.{0}) (p c : ℝ≥0) :\n  X.Radon_LC p c → weak_dual ℝ (locally_constant X ℝ) := subtype.val\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef weak_dual_LC_to_fun (X : Profinite.{0}) :\n  weak_dual ℝ (locally_constant X ℝ) → locally_constant X ℝ → ℝ := λ μ x, μ x\n\nlemma continuous_weak_dual_LC_to_fun (X : Profinite.{0}) :\n  continuous X.weak_dual_LC_to_fun :=\nbegin\n  apply continuous_pi, intros e,\n  exact weak_dual.eval_continuous _,\nend\n\ninstance t2_space_weak_dual (X : Profinite.{0}) :\n  t2_space (weak_dual ℝ (locally_constant X ℝ)) :=\n⟨λ x y h, separated_by_continuous (X.continuous_weak_dual_LC_to_fun) $\n  λ c, h $ by { ext t, apply_fun (λ e, e t) at c, exact c } ⟩\n\nlemma Radon_LC_closed_embedding (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  closed_embedding (X.Radon_LC_to_weak_dual p c) :=\nclosed_embedding_subtype_coe\nbegin\n  apply is_compact.is_closed,\n  let S := _, change is_compact S,\n  have : S = set.range (X.Radon_LC_to_weak_dual p c),\n  { erw subtype.range_val, refl },\n  rw this, clear this,\n  apply is_compact_range,\n  exact continuous_subtype_coe,\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_to_weak_dual (X : Profinite.{0}) (p c : ℝ≥0) :\n  X.Radon p c → weak_dual ℝ C(X,ℝ) := subtype.val\n\nlemma Radon_closed_embedding (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  closed_embedding (X.Radon_to_weak_dual p c) :=\nclosed_embedding_subtype_coe\nbegin\n  let T : set (weak_dual ℝ (locally_constant X ℝ)) :=\n    { f | f.bdd_LC p c },\n  change is_closed (X.weak_dual_C_to_LC ⁻¹' T),\n  apply is_closed.preimage,\n  exact (weak_dual_C_to_LC X).continuous,\n  convert (X.Radon_LC_closed_embedding p c).closed_range,\n  erw subtype.range_val, refl,\nend\n\nlemma Radon_closed_embedding_range_bdd (X : Profinite) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] : metric.bounded\n  (normed_space.dual.to_weak_dual ⁻¹' set.range (X.Radon_to_weak_dual p c)) :=\nbegin\n  -- Use c^(1/p)\n  letI : uniform_space (locally_constant.pkg X ℝ).space :=\n    (locally_constant.pkg X ℝ).uniform_struct,\n  refine (metric.bounded_iff_subset_ball 0).mpr _,\n  refine ⟨c^(1/(p : ℝ)), λ μ hμ, mem_closed_ball_zero_iff.mpr _⟩,\n  apply continuous_linear_map.op_norm_le_bound,\n  refine (nnreal.coe_nonneg _).trans_eq (nnreal.coe_rpow _ _),\n  intros f,\n  apply (locally_constant.pkg X ℝ).induction_on f,\n  { apply is_closed_le,\n    refine continuous.comp (continuous_norm) _,\n    exact μ.continuous,\n    refine continuous.comp (continuous_mul_left _) continuous_norm },\n  { intros e,\n    let γ : weak_dual ℝ (locally_constant X ℝ) :=\n      X.weak_dual_C_to_LC μ,\n    dsimp [locally_constant.pkg],\n    have : μ e = γ e, refl, rw this, clear this,\n    have : ∥ e.to_continuous_map ∥ = ∥ e ∥,\n    { simp only [continuous_map.norm_eq_supr_norm,\n        locally_constant.norm_def, locally_constant.to_continuous_map_eq_coe,\n        locally_constant.coe_continuous_map] },\n    erw this, clear this,\n    suffices : ∥ γ e ∥₊ ≤ c^(1 / (p : ℝ)) * ∥ e ∥₊, by exact_mod_cast this,\n    have hp : 0 < (p : ℝ) := nnreal.coe_pos.mpr (fact.out (0 < p)),\n    have hp' : (p : ℝ) ≠ 0,\n    { exact ne_of_gt hp },\n    rw [← nnreal.rpow_le_rpow_iff hp, nnreal.mul_rpow, ← nnreal.rpow_mul],\n    rw [(show 1 / (p : ℝ) * p = 1, from (eq_div_iff hp').mp rfl), nnreal.rpow_one],\n    obtain ⟨δ,hδ⟩ := hμ,\n    have H := δ.2 e.discrete_quotient,\n    replace H := mul_le_mul H (le_refl (∥ e ∥₊^(p : ℝ))) (zero_le _) (zero_le _),\n    refine le_trans _ H, clear H,\n    rw [mul_comm, finset.mul_sum],\n    nth_rewrite 0 e.eq_sum,\n\n    simp_rw [γ.map_sum, γ.map_smul],\n    refine le_trans (real.pow_nnnorm_sum_le _ _ _) _,\n\n    apply finset.sum_le_sum, rintros x -,\n    rw [smul_eq_mul, nnnorm_mul, nnreal.mul_rpow],\n    refine mul_le_mul _ (le_of_eq _) (zero_le _) (zero_le _),\n    apply nnreal.rpow_le_rpow _ (le_of_lt hp),\n    obtain ⟨x,rfl⟩ := discrete_quotient.proj_surjective _ x,\n    change ∥ e x ∥₊ ≤ _,\n    apply locally_constant.nnnorm_apply_le_nnnorm,\n    congr' 2,\n    change _ = X.Radon_to_weak_dual p c δ _, rw hδ, refl },\nend\n\ninstance compact_space_Radon (X : Profinite) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  compact_space (X.Radon p c) :=\nbegin\n  let e : X.Radon p c ≃ₜ set.range (X.Radon_to_weak_dual p c) :=\n    homeomorph.of_embedding _ (X.Radon_closed_embedding p c).to_embedding,\n  suffices : compact_space (set.range (X.Radon_to_weak_dual p c)),\n  { resetI, apply e.symm.compact_space },\n  rw ← is_compact_iff_compact_space,\n  apply weak_dual.is_compact_of_bounded_of_closed,\n  apply Radon_closed_embedding_range_bdd,\n  exact (X.Radon_closed_embedding p c).closed_range,\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_equiv_Radon_LC (X : Profinite.{0}) (p c : ℝ≥0) :\n  X.Radon p c ≃ X.Radon_LC p c :=\n{ to_fun := X.Radon_to_Radon_LC p c,\n  inv_fun := X.Radon_LC_to_Radon p c,\n  left_inv := begin\n    intros t, ext1,\n    apply X.weak_dual_C_equiv_LC.symm_apply_apply,\n  end,\n  right_inv := begin\n    intros t, ext1,\n    apply X.weak_dual_C_equiv_LC.apply_symm_apply,\n  end }\n\nlemma continuous_Radon_equiv_Radon_LC (X : Profinite.{0}) (p c : ℝ≥0) :\n  continuous (X.Radon_equiv_Radon_LC p c) :=\ncontinuous_map.continuous _\n\nlemma continuous_Radon_equiv_Radon_LC_symm (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  continuous (X.Radon_equiv_Radon_LC p c).symm :=\nbegin\n  rw continuous_iff_is_closed,\n  intros T hT,\n  rw ← equiv.image_eq_preimage,\n  apply is_compact.is_closed,\n  apply is_compact.image,\n  exact is_closed.is_compact hT,\n  exact continuous_map.continuous _,\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_homeomorph_Radon_LC (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  X.Radon p c ≃ₜ X.Radon_LC p c :=\n{ continuous_to_fun := continuous_Radon_equiv_Radon_LC _ _ _,\n  continuous_inv_fun := continuous_Radon_equiv_Radon_LC_symm _ _ _,\n  ..(X.Radon_equiv_Radon_LC p c) }\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_iso_Radon_LC (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  X.Radon p c ≅ X.Radon_LC p c :=\nTop.iso_of_homeo (X.Radon_homeomorph_Radon_LC p c)\n\n/-- The functor `X ↦ X.Radon p c` is isomorphic to its locally constant variant. -/\ndef Radon_functor_iso_Radon_LC_functor (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  Radon_functor p c ≅ Radon_LC_functor p c :=\nnat_iso.of_components\n(λ X, X.Radon_iso_Radon_LC p c)\nbegin\n  intros X Y f, ext, refl,\nend\n\n/-- A `CompHaus` variant of `Radon_functor`. -/\ndef Radon_CompHaus_functor (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  Profinite.{0} ⥤ CompHaus.{0} :=\n{ obj := λ X, CompHaus.of $ X.Radon p c,\n  map := λ X Y f, (Radon_functor p c).map f,\n  map_id' := (Radon_functor p c).map_id,\n  map_comp' := λ _ _ _ f g, (Radon_functor p c).map_comp f g }\n\n/-- The functor `X ↦ X.Radon p c` is isomorphic to its locally constant variant.\nThis is a variant taking values in `CompHaus` as opposed to `Top`. -/\ndef Radon_CompHaus_functor_iso_Radon_LC_CompHaus_functor (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  Radon_CompHaus_functor p c ≅ Radon_LC_CompHaus_functor p c :=\nnat_iso.of_components\n(λ X,\n{ hom := (Radon_functor_iso_Radon_LC_functor p c).hom.app X,\n  inv := (Radon_functor_iso_Radon_LC_functor p c).inv.app X,\n  hom_inv_id' := begin\n    erw [← nat_trans.comp_app, iso.hom_inv_id], refl,\n  end,\n  inv_hom_id' := begin\n    erw [← nat_trans.comp_app, iso.inv_hom_id], refl,\n  end })\nbegin\n  intros, ext, refl,\nend\n\n/-- The cone exhibiting `X.Radon p c` as the limit of `T.Radon p c` where\n`T` varies over the discrete quotients of `X`. -/\ndef Radon_CompHaus_cone (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  cone (X.diagram ⋙ Radon_CompHaus_functor p c) :=\n(Radon_CompHaus_functor p c).map_cone X.as_limit_cone\n\n/-- X.Radon_CompHaus_cone p c` is a limit cone, as promised. -/\ndef is_limit_Radon_CompHaus_cone (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  is_limit (X.Radon_CompHaus_cone p c) :=\n{ lift := λ S,\n    (X.is_limit_Radon_LC_CompHaus_cone p c).lift\n    ⟨S.X, S.π ≫ whisker_left _ (Radon_CompHaus_functor_iso_Radon_LC_CompHaus_functor p c).hom⟩ ≫\n    (Radon_CompHaus_functor_iso_Radon_LC_CompHaus_functor p c).inv.app _,\n  fac' := begin\n    intros S j,\n    erw [category.assoc, ← nat_trans.naturality,\n      (X.is_limit_Radon_LC_CompHaus_cone p c).fac_assoc,\n      ← nat_iso.app_inv, iso.comp_inv_eq], refl,\n  end,\n  uniq' := begin\n    intros S m hm,\n    rw [← nat_iso.app_inv, iso.eq_comp_inv],\n    apply (X.is_limit_Radon_LC_CompHaus_cone p c).hom_ext, intros j,\n    erw (X.is_limit_Radon_LC_CompHaus_cone p c).fac,\n    dsimp, rw ← hm,\n    simp only [category.assoc],\n    erw ← nat_trans.naturality,\n  end }\n\n/-- The comparison between `Radon_LC` and `real_measures p` taking\nvalues in `CompHaus` instead of `Top`, and restricted to the discrete quotients of `X`. -/\ndef Radon_LC_CompHaus_comparison (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  X.diagram ⋙ Radon_LC_CompHaus_functor p c ≅\n  X.fintype_diagram ⋙ real_measures.functor p ⋙ CompHausFiltPseuNormGrp₁.level.obj c :=\nnat_iso.of_components\n(λ T,\n{ hom := (X.Radon_LC_comparison p c).hom.app _,\n  inv := (X.Radon_LC_comparison p c).inv.app _,\n  hom_inv_id' := begin\n    erw [← nat_trans.comp_app, iso.hom_inv_id], refl,\n  end,\n  inv_hom_id' := begin\n    erw [← nat_trans.comp_app, iso.inv_hom_id], refl,\n  end })\nbegin\n  intros S T i, dsimp,\n  erw ((X.Radon_LC_comparison p c).hom).naturality, refl,\nend\n\n/-- The comparison between `Radon` and `real_measures p`\nrestricted to the discrete quotients of `X`. -/\ndef Radon_CompHaus_comparison (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  X.diagram ⋙ Radon_CompHaus_functor p c ≅\n  X.fintype_diagram ⋙ real_measures.functor p ⋙ CompHausFiltPseuNormGrp₁.level.obj c :=\niso_whisker_left _ (Radon_CompHaus_functor_iso_Radon_LC_CompHaus_functor _ _) ≪≫\nRadon_LC_CompHaus_comparison _ _ _\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_iso_limit (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  CompHaus.of (X.Radon p c) ≅\n  limit (X.fintype_diagram ⋙ real_measures.functor p ⋙ CompHausFiltPseuNormGrp₁.level.obj c) :=\n(X.is_limit_Radon_CompHaus_cone p c).cone_point_unique_up_to_iso (limit.is_limit _) ≪≫\nhas_limit.iso_of_nat_iso (Radon_CompHaus_comparison _ _ _)\n\n/-- The compact Hausdorff space `X.Radon p c` is isomorphic to the limit of\n`real_measures p T` as `T` varies over the discrete quotients of `X`.\n-/\ndef Radon_iso_real_measures (X : Profinite.{0}) (p c : ℝ≥0)\n  [fact (0 < p)] [fact (p ≤ 1)] :\n  CompHaus.of (X.Radon p c) ≅\n  (CompHausFiltPseuNormGrp₁.level.obj c).obj\n  ((Profinite.extend (real_measures.functor p)).obj X) :=\nRadon_iso_limit _ _ _ ≪≫\nhas_limit.iso_of_nat_iso (functor.associator _ _ _).symm ≪≫\n(limit.is_limit _).cone_point_unique_up_to_iso\n(is_limit_of_preserves ((CompHausFiltPseuNormGrp₁.level.obj c))\n  (limit.is_limit (X.fintype_diagram ⋙ real_measures.functor p)))\n\nend Profinite\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/Radon/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.46424349973755213}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.fin_category\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.shapes.equalizers\nimport category_theory.limits.shapes.wide_pullbacks\nimport category_theory.limits.shapes.pullbacks\nimport data.fintype.basic\n\n/-!\n# Categories with finite limits.\n\nA typeclass for categories with all finite (co)limits.\n-/\n\nuniverses w' w v' u' v u\n\nnoncomputable theory\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables (C : Type u) [category.{v} C]\n\n/--\nA category has all finite limits if every functor `J ⥤ C` with a `fin_category J`\ninstance and `J : Type` has a limit.\n\nThis is often called 'finitely complete'.\n-/\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\nclass has_finite_limits : Prop :=\n(out (J : Type) [𝒥 : small_category J] [@fin_category J 𝒥] : @has_limits_of_shape J 𝒥 C _)\n\n@[priority 100]\ninstance has_limits_of_shape_of_has_finite_limits\n  (J : Type w) [small_category J] [fin_category J] [has_finite_limits C] :\n  has_limits_of_shape J C :=\nbegin\n  apply has_limits_of_shape_of_equivalence (fin_category.equiv_as_type J),\n  apply has_finite_limits.out\nend\n\n@[priority 100]\ninstance has_finite_limits_of_has_limits_of_size [has_limits_of_size.{v' u'} C] :\n  has_finite_limits C :=\n⟨λ J hJ hJ', by { haveI := has_limits_of_size_shrink.{0 0} C,\n  exact has_limits_of_shape_of_equivalence (fin_category.equiv_as_type J) }⟩\n\n/-- If `C` has all limits, it has finite limits. -/\n@[priority 100]\ninstance has_finite_limits_of_has_limits [has_limits C] : has_finite_limits C :=\ninfer_instance\n\n/-- We can always derive `has_finite_limits C` by providing limits at an\narbitrary universe. -/\nlemma has_finite_limits_of_has_finite_limits_of_size\n  (h : ∀ (J : Type w) {𝒥 : small_category J} (hJ : @fin_category J 𝒥),\n    by { resetI, exact has_limits_of_shape J C }) :\n  has_finite_limits C :=\n⟨λ J hJ hhJ,\n  begin\n    resetI,\n    letI : category.{w w} (ulift_hom.{w} (ulift.{w 0} J)),\n    { apply ulift_hom.category.{0}, exact category_theory.ulift_category J },\n    haveI := h (ulift_hom.{w} (ulift.{w} J)) category_theory.fin_category_ulift,\n    exact has_limits_of_shape_of_equivalence (ulift_hom_ulift_category.equiv.{w w} J).symm\n  end ⟩\n\n/--\nA category has all finite colimits if every functor `J ⥤ C` with a `fin_category J`\ninstance and `J : Type` has a colimit.\n\nThis is often called 'finitely cocomplete'.\n-/\nclass has_finite_colimits : Prop :=\n(out (J : Type) [𝒥 : small_category J] [@fin_category J 𝒥] : @has_colimits_of_shape J 𝒥 C _)\n\n@[priority 100]\ninstance has_colimits_of_shape_of_has_finite_colimits\n  (J : Type w) [small_category J] [fin_category J] [has_finite_colimits C] :\n  has_colimits_of_shape J C :=\nbegin\n  apply has_colimits_of_shape_of_equivalence (fin_category.equiv_as_type J),\n  apply has_finite_colimits.out\nend\n\n@[priority 100]\ninstance has_finite_colimits_of_has_colimits_of_size [has_colimits_of_size.{v' u'} C] :\n  has_finite_colimits C :=\n⟨λ J hJ hJ', by { haveI := has_colimits_of_size_shrink.{0 0} C,\n  exact has_colimits_of_shape_of_equivalence (fin_category.equiv_as_type J) }⟩\n\n/-- We can always derive `has_finite_colimits C` by providing colimits at an\narbitrary universe. -/\nlemma has_finite_colimits_of_has_finite_colimits_of_size\n  (h : ∀ (J : Type w) {𝒥 : small_category J} (hJ : @fin_category J 𝒥),\n    by { resetI, exact has_colimits_of_shape J C }) :\n  has_finite_colimits C :=\n⟨λ J hJ hhJ,\n  begin\n    resetI,\n    letI : category.{w w} (ulift_hom.{w} (ulift.{w 0} J)),\n    { apply ulift_hom.category.{0}, exact category_theory.ulift_category J },\n    haveI := h (ulift_hom.{w} (ulift.{w} J)) category_theory.fin_category_ulift,\n    exact has_colimits_of_shape_of_equivalence (ulift_hom_ulift_category.equiv.{w w} J).symm\n  end ⟩\nsection\n\nopen walking_parallel_pair walking_parallel_pair_hom\n\ninstance fintype_walking_parallel_pair : fintype walking_parallel_pair :=\n{ elems := [walking_parallel_pair.zero, walking_parallel_pair.one].to_finset,\n  complete := λ x, by { cases x; simp } }\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance (j j' : walking_parallel_pair) : fintype (walking_parallel_pair_hom j j') :=\n{ elems := walking_parallel_pair.rec_on j\n    (walking_parallel_pair.rec_on j' [walking_parallel_pair_hom.id zero].to_finset\n      [left, right].to_finset)\n    (walking_parallel_pair.rec_on j' ∅ [walking_parallel_pair_hom.id one].to_finset),\n  complete := by tidy }\n\nend\n\ninstance : fin_category walking_parallel_pair := { }\n\n/-- Equalizers are finite limits, so if `C` has all finite limits, it also has all equalizers -/\nexample [has_finite_limits C] : has_equalizers C := by apply_instance\n\n/-- Coequalizers are finite colimits, of if `C` has all finite colimits, it also has all\n    coequalizers -/\nexample [has_finite_colimits C] : has_coequalizers C := by apply_instance\n\nvariables {J : Type v}\n\nlocal attribute [tidy] tactic.case_bash\n\nnamespace wide_pullback_shape\n\ninstance fintype_obj [fintype J] : fintype (wide_pullback_shape J) :=\nby { rw wide_pullback_shape, apply_instance }\n\ninstance fintype_hom (j j' : wide_pullback_shape J) : fintype (j ⟶ j') :=\n{ elems :=\n  begin\n    cases j',\n    { cases j,\n      { exact {hom.id none} },\n      { exact {hom.term j} } },\n    { by_cases some j' = j,\n      { rw h,\n        exact {hom.id j} },\n      { exact ∅ } }\n  end,\n  complete := by tidy }\n\nend wide_pullback_shape\n\nnamespace wide_pushout_shape\n\ninstance fintype_obj [fintype J] : fintype (wide_pushout_shape J) :=\nby { rw wide_pushout_shape, apply_instance }\n\ninstance fintype_hom (j j' : wide_pushout_shape J) : fintype (j ⟶ j') :=\n{ elems :=\n  begin\n    cases j,\n    { cases j',\n      { exact {hom.id none} },\n      { exact {hom.init j'} } },\n    { by_cases some j = j',\n      { rw h,\n        exact {hom.id j'} },\n      { exact ∅ } }\n  end,\n  complete := by tidy }\n\nend wide_pushout_shape\n\ninstance fin_category_wide_pullback [fintype J] : fin_category (wide_pullback_shape J) :=\n{ fintype_hom := wide_pullback_shape.fintype_hom }\n\ninstance fin_category_wide_pushout [fintype J] :\n  fin_category (wide_pushout_shape J) :=\n{ fintype_hom := wide_pushout_shape.fintype_hom }\n\n/--\n`has_finite_wide_pullbacks` represents a choice of wide pullback\nfor every finite collection of morphisms\n-/\n-- We can't just made this an `abbreviation`\n-- because of https://github.com/leanprover-community/lean/issues/429\nclass has_finite_wide_pullbacks : Prop :=\n(out (J : Type) [fintype J] : has_limits_of_shape (wide_pullback_shape J) C)\n\ninstance has_limits_of_shape_wide_pullback_shape\n  (J : Type) [fintype J] [has_finite_wide_pullbacks C] :\n  has_limits_of_shape (wide_pullback_shape J) C :=\nby { haveI := @has_finite_wide_pullbacks.out C _ _ J, apply_instance }\n\n/--\n`has_finite_wide_pushouts` represents a choice of wide pushout\nfor every finite collection of morphisms\n-/\nclass has_finite_wide_pushouts : Prop :=\n(out (J : Type) [fintype J] : has_colimits_of_shape (wide_pushout_shape J) C)\n\ninstance has_colimits_of_shape_wide_pushout_shape\n  (J : Type) [fintype J] [has_finite_wide_pushouts C] :\n  has_colimits_of_shape (wide_pushout_shape J) C :=\nby { haveI := @has_finite_wide_pushouts.out C _ _ J, apply_instance }\n\n/--\nFinite wide pullbacks are finite limits, so if `C` has all finite limits,\nit also has finite wide pullbacks\n-/\nlemma has_finite_wide_pullbacks_of_has_finite_limits [has_finite_limits C] :\n  has_finite_wide_pullbacks C :=\n⟨λ J _, by exactI has_finite_limits.out _⟩\n\n/--\nFinite wide pushouts are finite colimits, so if `C` has all finite colimits,\nit also has finite wide pushouts\n-/\nlemma has_finite_wide_pushouts_of_has_finite_limits [has_finite_colimits C] :\n  has_finite_wide_pushouts C :=\n⟨λ J _, by exactI has_finite_colimits.out _⟩\n\ninstance fintype_walking_pair : fintype walking_pair :=\n{ elems := {walking_pair.left, walking_pair.right},\n  complete := λ x, by { cases x; simp } }\n\n/-- Pullbacks are finite limits, so if `C` has all finite limits, it also has all pullbacks -/\nexample [has_finite_wide_pullbacks C] : has_pullbacks C := by apply_instance\n\n/-- Pushouts are finite colimits, so if `C` has all finite colimits, it also has all pushouts -/\nexample [has_finite_wide_pushouts C] : has_pushouts C := by apply_instance\n\nend category_theory.limits\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/category_theory/limits/shapes/finite_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.46424349758670386}}
{"text": "structure A where\n  private x : Nat := 10\n\ndef g (a : Nat) : A :=\n  {}\n\ntheorem ex1 (a : Nat) : (g a |>.x) = 10 :=\n  rfl\n\nstructure B extends A where\n  y : Nat\n  x := 20\n\ndef f (a : Nat) : B :=\n  { y := a }\n\ntheorem ex2 (a : Nat) : (f a |>.x) = 20 :=\n  rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/structPrivateFieldBug2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.737158174177441, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4642434946152859}}
{"text": "import data.nat.basic\n\n-- The next lemma won't be used, it's a warming up exercise for the one below.\n-- It could go to mathlib.\nlemma exists_by_induction {α : Type*} {P : ℕ → α → Prop}\n  (h₀ : ∃ a, P 0 a)\n  (ih : ∀ n a, P n a → ∃ a', P (n+1) a') :\n  ∃ f : ℕ → α, ∀ n, P n (f n) :=\nbegin\n  choose f₀ hf₀ using h₀,\n  choose! F hF using ih,\n  exact ⟨λ n, nat.rec_on n f₀ F, λ n, nat.rec hf₀ (λ n ih, hF n _ ih) n⟩\nend\n\n-- We make `P` and `Q` explicit to help the elaborator when applying the lemma\n-- (elab_as_eliminator isn't enough).\nlemma exists_by_induction' {α : Type*} (P : ℕ → α → Prop) (Q : ℕ → α → α → Prop)\n  (h₀ : ∃ a, P 0 a)\n  (ih : ∀ n a, P n a → ∃ a', P (n+1) a' ∧ Q n a a') :\n  ∃ f : ℕ → α, ∀ n, P n (f n) ∧ Q n (f n) (f $ n+1) :=\nbegin\n  choose f₀ hf₀ using h₀,\n  choose! F hF hF' using ih,\n  have key : ∀ n, P n (nat.rec_on n f₀ F), from λ n, nat.rec hf₀ (λ n ih, hF n _ ih) n,\n  exact ⟨λ n, nat.rec_on n f₀ F, λ n, ⟨key n, hF' n _ (key n)⟩⟩\nend\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/to_mathlib/data/nat/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4642434924644378}}
{"text": "--  An abstract formalization of \"isomorphism is equality up to relabeling\"\n-- -------------------------------------------------------------------------\n--\n-- See `README.md` for more info.\n--\n-- Definitions related to `functorStructure`.\n\n\n\nimport Structure.Basic\nimport Structure.UniverseFunctor\nimport Structure.ProductStructure\n\nopen Morphisms\nopen HasStructure\n\n\n\nset_option autoBoundImplicitLocal false\n\n\n\nnamespace StructureFunctor.functorStructure\n\n-- `universeStructure` enables us to define functors for the two maps from a structure `T` to the\n-- functor structure with `T` on one side.\n--\n-- In other words, `functorStructure` is functorial in both arguments.\n\nsection OneSided\n\nvariable (S : Structure)\n\ndef outgoingToFun {T₁ T₂ : Structure} (e : T₁ ≃ T₂) :\n  StructureFunctor (functorStructure S T₁) (functorStructure S T₂) :=\ncompFun.congrArg_right.functor S e.toFun\n\nnamespace outgoingToFun\n\ndef respectsEquiv {T₁ T₂ : Structure} :\n  GeneralizedFunctor.Functor (S := StructureEquiv.equivStructure T₁ T₂)\n                             (T := functorStructure (functorStructure S T₁) (functorStructure S T₂))\n                             (outgoingToFun S) :=\n(compFun.congrArg_right.functor.functorFunctor S ⊙ StructureEquiv.toFunProj T₁ T₂).functor\n\ndef respectsComp {T₁ T₂ T₃ : Structure} (e : T₁ ≃ T₂) (f : T₂ ≃ T₃) :\n  outgoingToFun S (f • e) ≃ outgoingToFun S f ⊙ outgoingToFun S e :=\ncompFun.congrArg_right.functor.respectsCompFun S e.toFun f.toFun\n\ntheorem respectsComp.nat {T₁ T₂ T₃ : Structure} {e₁ e₂ : T₁ ≃ T₂} {f₁ f₂ : T₂ ≃ T₃} (η : e₁ ≃ e₂) (θ : f₁ ≃ f₂) :\n  compFun.congrArg (respectsEquiv S η) (respectsEquiv S θ) • respectsComp S e₁ f₁ ≈ respectsComp S e₂ f₂ • respectsEquiv S (StructureEquiv.comp_congrArg η θ) :=\ncompFun.congrArg_right.functor.respectsCompFun.nat S η.toFunEquiv θ.toFunEquiv\n\ndef respectsId (T : Structure) :\n  outgoingToFun S (id_ T) ≃ @idFun (functorStructure S T) :=\ncompFun.congrArg_right.functor.respectsIdFun S T\n\nend outgoingToFun\n\ndef outgoingFunctorDesc : UniverseStructureFunctorDesc :=\n{ map             := λ T => functorStructure S T,\n  toFun           := outgoingToFun                  S,\n  respectsEquiv   := outgoingToFun.respectsEquiv    S,\n  respectsComp    := outgoingToFun.respectsComp     S,\n  respectsCompNat := outgoingToFun.respectsComp.nat S,\n  respectsId      := outgoingToFun.respectsId       S }\n\ndef outgoingFunctorFunctor' : UniverseStructureFunctor :=\nUniverseStructureFunctorDesc.universeStructureFunctor (outgoingFunctorDesc S)\n\ndef outgoingFunctorFunctor : UniverseFunctor universeStructure :=\nUniverseStructureFunctorDesc.universeFunctor (outgoingFunctorDesc S)\n\ndef incomingToFun {T₁ T₂ : Structure} (e : T₁ ≃ T₂) :\n  StructureFunctor (functorStructure T₁ S) (functorStructure T₂ S) :=\ncompFun.congrArg_left.functor S e.invFun\n\nnamespace incomingToFun\n\ndef respectsEquiv {T₁ T₂ : Structure} :\n  GeneralizedFunctor.Functor (S := StructureEquiv.equivStructure T₁ T₂)\n                             (T := functorStructure (functorStructure T₁ S) (functorStructure T₂ S))\n                             (incomingToFun S) :=\n(compFun.congrArg_left.functor.functorFunctor S ⊙ StructureEquiv.invFunProj T₁ T₂).functor\n\ndef respectsComp {T₁ T₂ T₃ : Structure} (e : T₁ ≃ T₂) (f : T₂ ≃ T₃) :\n  incomingToFun S (f • e) ≃ incomingToFun S f ⊙ incomingToFun S e :=\ncompFun.congrArg_left.functor.respectsCompFun S f.invFun e.invFun\n\ntheorem respectsComp.nat {T₁ T₂ T₃ : Structure} {e₁ e₂ : T₁ ≃ T₂} {f₁ f₂ : T₂ ≃ T₃} (η : e₁ ≃ e₂) (θ : f₁ ≃ f₂) :\n  compFun.congrArg (respectsEquiv S η) (respectsEquiv S θ) • respectsComp S e₁ f₁ ≈ respectsComp S e₂ f₂ • respectsEquiv S (StructureEquiv.comp_congrArg η θ) :=\ncompFun.congrArg_left.functor.respectsCompFun.nat S θ.invFunEquiv η.invFunEquiv\n\ndef respectsId (T : Structure) :\n  incomingToFun S (id_ T) ≃ @idFun (functorStructure T S) :=\ncompFun.congrArg_left.functor.respectsIdFun S T\n\nend incomingToFun\n\ndef incomingFunctorDesc : UniverseStructureFunctorDesc :=\n{ map             := λ T => functorStructure T S,\n  toFun           := incomingToFun                  S,\n  respectsEquiv   := incomingToFun.respectsEquiv    S,\n  respectsComp    := incomingToFun.respectsComp     S,\n  respectsCompNat := incomingToFun.respectsComp.nat S,\n  respectsId      := incomingToFun.respectsId       S }\n\ndef incomingFunctorFunctor' : UniverseStructureFunctor :=\nUniverseStructureFunctorDesc.universeStructureFunctor (incomingFunctorDesc S)\n\ndef incomingFunctorFunctor : UniverseFunctor universeStructure :=\nUniverseStructureFunctorDesc.universeFunctor (incomingFunctorDesc S)\n\nend OneSided\n\n\n\n-- `outgoingFunctorFunctor` and `incomingFunctorFunctor` are themselves functors.\n\ndef outgoingFunctorFunctorFunctor :\n  StructureFunctor universeStructure (functorStructure universeStructure universeStructure) :=\n{ map     := outgoingFunctorFunctor,\n  functor := { mapEquiv  := λ e => { ext := λ T => congrArg (incomingFunctorFunctor T) e,\n                                     nat := sorry },\n               isFunctor := sorry } }\n\ndef incomingFunctorFunctorFunctor :\n  StructureFunctor universeStructure (functorStructure universeStructure universeStructure) :=\n{ map     := incomingFunctorFunctor,\n  functor := { mapEquiv  := λ e => { ext := λ T => congrArg (outgoingFunctorFunctor T) e,\n                                     nat := sorry },\n               isFunctor := sorry } }\n\n\n\n-- By uncurrying, we can obtain a `UniverseFunctor` that outputs arbitrary functor structures, i.e.\n-- `(S, T) ↦ (S → T)`.\n\nsection TwoSided\n\ndef functorStructureFunctor : UniverseFunctor (StructureProduct.productStructure universeStructure universeStructure) :=\nFunctorProductEquivalences.uncurry outgoingFunctorFunctorFunctor\n\nend TwoSided\n\nend StructureFunctor.functorStructure\n", "meta": {"author": "SReichelt", "repo": "lean4-experiments", "sha": "ff55357a01a34a91bf670d712637480089085ee4", "save_path": "github-repos/lean/SReichelt-lean4-experiments", "path": "github-repos/lean/SReichelt-lean4-experiments/lean4-experiments-ff55357a01a34a91bf670d712637480089085ee4/Structure/FunctorStructure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.46424349246443775}}
{"text": "import analysis.special_functions.pow\n\nimport polyhedral_lattice.cosimplicial\nimport combinatorial_lemma\nimport breen_deligne.eg\n\nimport thm95.constants.spectral_constants\n\nimport for_mathlib.nnreal\n\n/-!\n# Explicit formulas for the constants used in Theorem 9.5 of Analytic.pdf\n\nFix the following notation.\n\n* `r` and `r'` are real numbers satisfying `0 < r < r' ≤ 1`\n* `BD` denotes a Breen-Deligne package\n* `κ'` is a sequence of nonnegative real numbers\n* `Λ` denotes a polyhedral lattice\n\nThe main goal of this file is to define sequences of constants `k₁`, `K₁`, `k'`, `N₂`, `b`, `H`,\nsatisfying the inequalities below.\nBut first we make some abbreviations:\n\n* `k₀ m := normed_spectral.k₀ m (k₁ m)`\n* `K₀ m := normed_spectral.K₀ m (K₁ m)`\n* `ε m := normed_spectral.ε m (K₁ m)`\n* `k m := (k' m)^2`\n* `K m := 2 * K₀ m * H m`\n\nIt is known that:\n\n* `normed_spectral.k₀` always returns a number larger or equal to `1`.\n* `normed_spectral.K₀` always returns a number larger or equal to `1`.\n* `normed_spectral.ε` always returns a positive number.\n\nThe following inequalities are imposed on these constants\nby the normed homological algebra of the rest of the proof:\n\n* `1 < k₁ m`\n* `1 ≤ K₁ m`\n* `1 ≤ k' m`\n* `k (m - 1) ≤ k₁ m`, for `m > 0`\n* `K (m - 1) ≤ K₁ m`, for `m > 0`\n* `m + 2 + (r + 1) / (r * (1 - r)) * (m + 2) ^ 2 ≤ K₁ m`\n* `k₀ m ≤ k' m`\n* `κ' i ≤ k' m` for all `i ≤ m+1`\n* `(2 * k' m) * (r / r') ^ (b m) ≤ ε m`\n* `k' m ≤ 2 ^ N₂ m`\n* `k' m / (2 ^ N₂ m) ≤ r' ^ (b m)`\n* `r ^ (b m) * (2 ^ N₂ m) ≤ 2 * k' m * (r / r') ^ (b m)`\n* For `q ≤ m`, the technical condition\n  `((BD.data.homotopy_mul BD.homotopy (N₂ m)).hom q (q + 1)).bound_by (H m)`\n  saying that `H m` should be larger than a list of `m + 1` numbers depending on `BD` and `N₂ m`.\n\n-/\n\nnoncomputable theory\n\nopen_locale nnreal\n\nopen real finset\n\nnamespace helper\n\n/-- Given real numbers `r`, `r'`, `k'`, and `ε`, we define `b` to be the smallest natural number\nlarger than `log(ε / (2 * k')) / log(r/r')`. -/\ndef b (r r' k' ε : ℝ) : ℕ := nat.ceil ((log $ ε/(2 * k')) / log (r/r'))\n\n/-- Under the constraints that `r`, `r'`, `k'`, and `ε` are positive real numbers\nsatisfying `r < r'`, the natural number `b = b r r' k' ε` satisfies\n`(2 * k') * (r/r') ^ b ≤ ε`. -/\nlemma b_spec {r r' k' ε : ℝ} (hr : 0 < r) (hr' : 0 < r') (hrr' : r < r')\n  (hk' : 0 < k') (hε : 0 < ε) : (2 * k') * (r / r') ^ (b r r' k' ε) ≤ ε :=\nbegin\n  have f₁ : 0 < 2*k' := mul_pos zero_lt_two hk',\n  have f₂ : r/r' < 1 := (div_lt_one hr').mpr hrr',\n  have f₃ : 0 < r/r' := div_pos hr hr',\n  have f₄ :0 < (r / r') ^ b r r' k' ε := pow_pos f₃ _,\n  rw [← le_div_iff' f₁, ← log_le_log f₄ (div_pos hε f₁), log_pow, ← div_le_iff_of_neg (log_neg f₃ f₂)],\n  exact nat.le_ceil (log (ε / (2 * k')) / log (r / r')),\nend\n\n/-- Given real numbers `r'`, `k'`, and `b`, we define `N₂` to be the smallest natural number\nlarger than `log(k' / r'^b) / log(2)`. -/\ndef N₂ (r' k' b : ℝ) := nat.ceil (log (k'/r'^b) / log 2)\n\n/-- Under the constraints that `r'` and `k'` are positive real numbers,\nthe natural number `N₂ = N₂ r' k' b` satisfies `k' / (2 ^ N₂) ≤ r' ^ b`. -/\nlemma N₂_spec {r' k' b : ℝ} (hr' : 0 < r') (hk' : 0 < k') : k'/ (2 ^ (N₂ r' k' b)) ≤ r' ^ b :=\nbegin\n  have f₁ : (0 : ℝ) < 2 ^ N₂ r' k' b := pow_pos zero_lt_two _,\n  have f₂ : (0 : ℝ) < r' ^ b := rpow_pos_of_pos hr' _,\n  have f₃ : 0 < k' / r' ^ b := div_pos hk' f₂,\n  have f₄ : 0 < log 2 := log_pos one_lt_two,\n  rw [div_le_iff' f₁, ← div_le_iff f₂,  ← log_le_log f₃ f₁, log_pow, ← div_le_iff f₄],\n  apply nat.le_ceil,\nend\n\n/-- Under the constraints that `r'` is a positive real number and `k'` is nonnegative,\nthe natural number `N₂ = N₂ r' k' b` satisfies `r' ^b < 2 * k' / (2 ^ N₂)`. -/\nlemma N₂_spec_of_pos' {r' k' b} (h : 0 < N₂ r' k' b) (hr' : 0 < r') (hk' : 0 ≤ k') :\n  r' ^ b < 2 * k'  / 2 ^ N₂ r' k' b :=\nbegin\n  have h' := nat.lt_ceil.mp h,\n  have : 0 < log (k'/r'^b)/ log 2,\n  { exact_mod_cast nat.lt_ceil.mp h },\n  have f₁ : 0 < 2 ^ N₂ r' k' b := pow_pos zero_lt_two _,\n  have Hk' : k' ≠ 0,\n  { intro H,\n    simpa [H, N₂] using h },\n  have f₂ : 0 < r' ^ b := rpow_pos_of_pos hr' b,\n\n  have f₃ : 0 < k' / r' ^ b := div_pos ((ne.symm Hk').le_iff_lt.mp hk') f₂,\n  have f₃' : k' / r' ^ b ≠ 0 := f₃.ne.symm,\n  have f₄ : (N₂ r' k' b : ℝ) < _ := nat.ceil_lt_add_one this.le,\n\n  rwa [lt_div_iff, ← lt_div_iff', mul_div_assoc, ← log_lt_log_iff, log_mul, log_pow,\n       ← lt_div_iff (log_pos one_lt_two), add_div, div_self (log_pos one_lt_two).ne.symm, add_comm],\n  all_goals { assumption <|> norm_num  },\n  assumption\nend\n\nend helper\n\nsection\n\n/-!\nIn the rest of this file, we fix once and for all the following parameters:\n\n* `r` and `r'` are nonnegative real numbers\n* `BD` denotes a Breen-Deligne package\n* `κ` and `κ'` are sequences of nonnegative real numbers,\n  that are assumed to be \"adept\" with respect to `BD`\n  and \"very suitable\" with respect to `BD`, `r`, and `r'`.\n* `Λ` denotes a polyhedral lattice\n-/\n\nparameters (r r' : ℝ≥0)\nparameters (BD : breen_deligne.package) (κ κ' : ℕ → ℝ≥0)\nparameters (Λ : PolyhedralLattice)\n\n/-!\nWe also let `m` denote a variable natural number.\n-/\n\nvariables  (m : ℕ)\n\nnamespace thm95\n\nopen system_of_double_complexes\n\nnamespace universal_constants\n\nopen breen_deligne\n\n/-- `k₁ m` is a sequence of nonnegative real numbers, defined recursively via\n* `k₁ 0 = 2` (the important property being `k₁ 0 > 1`) and\n* `k₁ (m+1)` is the maximum of `2` and `c`,\n  where `c` is the square of the maximum of `k₀ m (k₁ m)`, and `κ' 0`, `κ' 1`, ..., `κ' (m+1)`.\n  Here `k₀ m k` is the sequence of constants used in the proof of `normed_spectral`. -/\nnoncomputable def k₁ : ℕ → ℝ≥0\n| 0     := 2 -- should be anything > 1\n| (m+1) := max 2 ((max (normed_spectral.k₀ m (k₁ m)) $ (range $ m+2).sup κ')^2)\n\n/-- All the numbers `k₁ m` are larger than `1`. -/\ninstance one_lt_k₁ : Π (m : ℕ), fact (1 < k₁ m)\n| 0     := ⟨one_lt_two⟩\n| (m+1) := ⟨lt_of_lt_of_le one_lt_two (le_max_left _ _)⟩\n\n/-- `k₀ m` is the constant `k₀ m (k m)` used in the proof of `normed_spectral`. -/\nabbreviation k₀ : ℝ≥0 := normed_spectral.k₀ m (k₁ m)\n\n/-- `k' m` is the maximum of `k₀ m` and the constants `κ' 0`, `κ' 1`, ..., `κ' m`, `κ' (m+1)` -/\ndef k' : ℝ≥0 := max (k₀ m) $ (range $ m+2).sup κ'\n\n/-- For indices `i` ranging over `0` up to `m+1`, we have `κ' i ≤ k' m`. -/\nlemma κ'_le_k' {i : ℕ} (hi : i ≤ m+1) : κ' i ≤ k' m :=\nle_max_iff.mpr $ or.inr $ le_sup $ mem_range.mpr $ nat.lt_succ_iff.mpr hi\n\n-- A different way of telling Lean the same fact as the previous lemma.\ninstance fact_κ'_le_k' {i : ℕ} (hi : fact (i ≤ m+1)) : fact (κ' i ≤ k' m) := ⟨κ'_le_k' _ hi.1⟩\n\n/-- We always have `1 ≤ k' m` for all `m`, since `1 ≤ k₀ m`. -/\ninstance one_le_k' : fact (1 ≤ k' m) := ⟨le_trans (fact.out _) $ le_max_left _ _⟩\n\n/-- We always `k₀ m ≤ k' m`. -/\ninstance k₀_le_k' : fact (k₀ m ≤ k' m) := ⟨le_max_left _ _⟩\n\n/-- `k m` is the square of `k' m`. -/\ndef k : ℝ≥0 := k' m * k' m\n\ninstance one_le_k : fact (1 ≤ k m) := by { delta k, apply_instance }\n\n/-- For positive `m`, we have `k (m-1) ≤ k₁ m`. -/\ninstance k_le_k₁ [fact (0 < m)] : fact (k (m - 1) ≤ k₁ m) :=\nbegin\n  unfreezingI {cases m},\n  { exact false.elim (lt_irrefl 0 (fact.elim infer_instance)) },\n  { apply fact.mk,\n    simp only [k₁],\n    convert le_max_right _ _,\n    rw pow_two,\n    refl }\nend\n\n/-- `k₁_sqrt m` denotes the square root of `k₁ m`. -/\ndef k₁_sqrt : ℝ≥0 := ⟨real.sqrt (k₁ m), real.sqrt_nonneg _⟩\n\ninstance one_lt_k₁_sqrt : fact (1 < k₁_sqrt m) := ⟨begin\n  change (1 : ℝ) < real.sqrt (k₁ κ' m),\n  rw [real.lt_sqrt zero_le_one, pow_two, mul_one],\n  exact (universal_constants.one_lt_k₁ κ' m).elim,\nend⟩\n\n/-- `y m r` denotes `m + 2 + (r + 1) / (r - r^2) * (m + 2)^2`. -/\ndef y (m : ℕ) (r : ℝ≥0) := (m + 2 : ℝ≥0) + (r + 1) / (r * (1 - r)) * (m + 2)^2\n\n/-- `H' m n` is the maximum of `1` and `c`, where `c` bounds the first `m+1` maps in the\n`n`-th iteration of the homotopy of the Breen-Deligne package `BD`. -/\ndef H' (n : ℕ) :=\nmax 1 ((range $ m+1).sup $ λ q, ((BD.data.homotopy_mul BD.homotopy n).hom q (q + 1)).bound)\n\n/-- `K₁` is a sequence of nonnegative real numbers, defined recursively via\n* `K₁ 0 = 2 + (r + 1) / (r * (1 - r)) * 4`\n* `K₁ (m+1) = max (y (m+1) r) c`, where\n  - `y (m+1) r` is defined to be `m + 3 + (r + 1) / (r - r^2) * (m + 3)^2`\n  - `c` is `2 * K₀ m (K₁ m) * (H' m N₂)`\n  - `K₀ m K₁` denotes one of the constants used in the proof of `normed_spectral`\n  - `N₂` denotes the natural number `N₂ r' (k' m) (b r r' (k' m) ε)` defined before\n  - `ε` denotes the constant `ε m (K₁ m)` used in the proof of `normed_spectral`. -/\nnoncomputable def K₁ : ℕ → ℝ≥0\n| 0     := 2 + (r + 1) / (r * (1 - r)) * 4\n| (m+1) :=\nmax (y (m+1) r)\n    (2 * normed_spectral.K₀ m (K₁ m) *\n         (H' m $ helper.N₂ r' (k' m) (helper.b r r' (k' m) (normed_spectral.ε m (K₁ m)))))\n\n/-- For all `m`, the number `K₁ m` is larger than `1`. -/\ninstance one_le_K₁ : ∀ m, fact (1 ≤ K₁ m)\n| 0     := ⟨begin\n             dsimp [K₁],\n             apply le_add_right,\n             exact one_le_two\n            end⟩\n| (m+1) := ⟨begin\n              dsimp [K₁],\n              refine le_max_iff.mpr (or.inl _),\n              dsimp [y],\n              apply le_add_right,\n              norm_cast,\n              exact le_add_self\n            end⟩\n\n/-- `K₀ m` is the constant `K₀ m (K m)` used in the proof of `normed_spectral` -/\nabbreviation K₀ : ℝ≥0 := normed_spectral.K₀ m (K₁ m)\n\n/-- `ε m` is the constant `ε m (K m)` used in the proof of `normed_spectral` -/\nabbreviation ε : ℝ≥0 := normed_spectral.ε m (K₁ m)\n\ninstance ε_pos : fact (0 < ε m) := ⟨normed_spectral.ε_pos _ _⟩\n\nvariables [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' ≤ 1)]\n\n/-- `b κ' r r' m` is the smallest `b` such that `2 * (k' m) * (r / r') ^ b ≤ (ε m)`. -/\ndef b : ℕ := helper.b r r' (k' m) (ε m)\n\n/-- `b κ' r r' m` is the smallest `b` such that `2 * (k' m) * (r / r') ^ b ≤ (ε m)`.\nThis lemma proves that `b` indeed satisfies the property claimed at its definition. -/\nlemma b_spec : (2 * k' m) * (r / r') ^ (b m) ≤ ε m :=\nbegin\n  suffices : 2 * (k' κ' m : ℝ) * (r / r') ^ b r r' BD κ' m ≤ ε r r' BD κ' m,\n  exact_mod_cast this,\n  apply helper.b_spec ‹fact (0 < r)›.out ‹fact (0 < r')›.out ‹fact (r < r')›.out ; norm_cast ;\n  apply fact.out\nend\n\n/-- `N₂ κ' r r' m` is the smallest `N₂` such that `N = 2 ^ N₂` satisfies\n`(k' m) / N ≤ r' ^ (b κ' r r' m)`. -/\ndef N₂ : ℕ := helper.N₂ r' (k' m) (b m)\n\n/-- `N₂ κ' r r' m` is the smallest `N₂` such that `N = 2 ^ N₂` satisfies\n`(k' m) / N ≤ r' ^ (b κ' r r' m)`.\nThis lemma proves that `N₂` indeed satisfies the property claimed at its definition. -/\nlemma N₂_spec : (k' m) / (2 ^ (N₂ m)) ≤ r' ^ b m :=\nbegin\n  suffices : (k' κ' m : ℝ) / 2 ^ N₂ r r' BD κ' m ≤ r' ^ (b r r' BD κ' m : ℝ),\n  exact_mod_cast this,\n  apply helper.N₂_spec ‹fact (0 < r')›.out ; norm_cast ;\n  apply fact.out\nend\n\n/-- `N₂ = N₂ κ' r r' m` is defined in such a way that `r' ^ b < 2 * k' m / 2 ^ N₂`,\nwhere `b = b κ' r r' m`. -/\nlemma N₂_spec_of_pos' (h : 0 < N₂ m) :\n  r' ^ b m < 2 * k' m / 2 ^ N₂ m :=\nbegin\n  suffices : (r' : ℝ) ^ (b r r' BD κ' m : ℝ) < 2 * k' κ' m / 2 ^ N₂ r r' BD κ' m,\n  exact_mod_cast this,\n  apply helper.N₂_spec_of_pos' h,\n  { norm_cast,\n    exact ‹fact (0 < r')›.out },\n  apply nnreal.coe_nonneg\nend\n\nlemma k'_eq_one_of_N₂_spec_eq_zero (h : N₂ m = 0) : k' m = 1 :=\nbegin\n  refine le_antisymm _ (universal_constants.one_le_k' _ _).1,\n  obtain F := N₂_spec r r' BD κ' m,\n  rw [h, pow_zero, div_one] at F,\n  refine F.trans (pow_le_one (b r r' BD κ' m) (le_of_lt _) _);\n  { apply fact.out _,\n    assumption }\nend\n\n/-- `N m = 2 ^ N₂ m` is the smallest `N` that satisfies `(k' m) / N ≤ r' ^ (b m)` -/\ndef N : ℕ := 2 ^ N₂ m\n\ninstance N_pos : fact (0 < N m) := ⟨pow_pos zero_lt_two _⟩\n\n/-- For all `m` we have `k' m ≤ N m = 2 ^ N₂ m`. -/\ninstance k'_le_two_pow_N : fact (k' m ≤ 2 ^ N₂ m) :=\n{ out := begin\n  rw [← mul_one ((2 : ℝ≥0) ^ _)],\n  obtain F := N₂_spec r r' BD κ' m,\n  rw [nnreal.div_le_iff (pow_pos zero_lt_two _).ne', mul_comm] at F,\n  refine F.trans (mul_le_mul rfl.le _ _ _),\n  { refine pow_le_one _ (zero_le r') _,\n    apply fact.out _,\n    assumption },\n  repeat { exact pow_nonneg (zero_le _) _ }\nend }\n\n/-- For all `m` we have `r ^ (b m) * (N m) ≤ 2 * k' m * (r / r') ^ (b m)`. -/\nlemma r_pow_b_mul_N_le : r ^ (b m) * (N m) ≤ 2 * k' m * (r / r') ^ (b m) :=\nbegin\n  rw [mul_comm _ (_ ^ _), N, div_pow, nat.cast_pow, nat.cast_bit0, nat.cast_one, div_eq_mul_one_div,\n    mul_assoc, div_mul_comm, mul_one],\n  refine mul_le_mul_left' _ _,\n  rw [nnreal.le_div_iff_mul_le, mul_comm, ← nnreal.le_div_iff_mul_le],\n  { by_cases N0 : N₂ r r' BD κ' m = 0,\n    { rw [k'_eq_one_of_N₂_spec_eq_zero _ _ BD _ _ N0, mul_one, N0, pow_zero, div_one],\n      refine le_trans (pow_le_one _ (nnreal.coe_nonneg _) _) one_le_two,\n      apply fact.out _,\n      assumption },\n    { exact le_of_lt (N₂_spec_of_pos' _ _ BD _ _ (zero_lt_iff.mpr N0)) } },\n  { exact pow_ne_zero _ two_ne_zero },\n  { exact pow_ne_zero _ (ne_of_gt (fact.out _)) }\nend\n\n/-- For all `m` we have `r ^ b m * N m ≤ ε m`. -/\nlemma r_pow_b_le_ε : r ^ b m * N m ≤ ε m := (r_pow_b_mul_N_le _).trans (b_spec _)\n\n/-- For all `m` we have `k' m * (2 ^ N₂ m)⁻¹ ≤ r' ^ b m`. -/\nlemma N₂_spec' : k' m * (2 ^ N₂ m)⁻¹ ≤ r' ^ b m :=\nby { rw [inv_eq_one_div, mul_one_div], exact N₂_spec r r' BD κ' m }\n\n/-- `H BD κ' r r' m` is the universal bound on the norm of the `N₂`th Breen--Deligne homotopy\nin the first `m` degrees. Here `N₂ = N₂ κ' r r' m`. -/\ndef H : ℕ := H' m (N₂ m)\n\nlemma one_le_H : 1 ≤ H m := le_max_left _ _\n\ninstance H_pos : fact (0 < H m) := ⟨zero_lt_one.trans_le $ one_le_H _⟩\ninstance H_pos' : fact ((0:ℝ≥0) < H m) := by { norm_cast, apply_instance }\n\nlemma bound_by_H {q : ℕ} (h : q ≤ m) :\n  ((BD.data.homotopy_mul BD.homotopy (N₂ m)).hom q (q + 1)).bound_by (H m) :=\nbegin\n  rw [H, H', universal_map.bound_by, le_max_iff],\n  right,\n  refine @le_sup _ _ _ _ (range $ m+1)\n    (λ q, ((BD.data.homotopy_mul BD.homotopy (N₂ r r' BD κ' m)).hom q (q + 1)).bound) _ _,\n  rwa [mem_range, nat.lt_succ_iff],\nend\n\n/-- `K m` is defined to be `2 * K₀ m (K₁ m) * H m`,\nwhere `K₀ m (K₁ m)` is one of the constants used in the proof of `normed_spectral`. -/\ndef K : ℝ≥0 := 2 * normed_spectral.K₀ m (K₁ m) * H m\n\ninstance one_le_K : fact (1 ≤ K m) := fact.mk $\ncalc 1 = 1 * 1 * 1 : by simp\n... ≤ 2 * normed_spectral.K₀ m (K₁ m) * H m :\nbegin\n  refine mul_le_mul' (mul_le_mul' one_le_two $ (normed_spectral.one_le_K₀ _ _).1) _,\n  norm_cast,\n  apply one_le_H\nend\n\n/-- For all positive `m`, we have `K (m - 1) ≤ K₁ m`. -/\ninstance K_le_K₁ [fact (0 < m)] : fact (K (m - 1) ≤ K₁ m) :=\n⟨begin\n  tactic.unfreeze_local_instances,\n  have hm : 0 < m, from fact.out _,\n  cases m,\n  { exfalso, exact nat.lt_asymm hm hm, },\n  simp only [K₁, nat.succ_sub_succ_eq_sub, nat.sub_zero, le_max_iff],\n  right,\n  apply le_refl\nend⟩\n\nlemma K₁_spec : (m + 2 + (r + 1) / (r * (1 - r)) * (m + 2)^2 : ℝ≥0) ≤ K₁ m :=\nbegin\n  cases m,\n  { norm_num [K₁] },\n  { simp only [K₁, le_max_iff],\n    left,\n    apply le_refl }\nend\n\nsection open simplex_category\n\ndef c₀_aux (m : ℕ) (Λ : PolyhedralLattice) : ℝ≥0 :=\nN m * lem98.d Λ (N m) / (k₁_sqrt m - 1) / r' / (range $ m+1).inf' ⟨0, by simp⟩ κ\n\n-- define this such that the lemmas below hold\nnoncomputable def c₀ : ℕ → PolyhedralLattice → ℝ≥0\n| 0 Λ := c₀_aux 0 Λ\n| (m+1) Λ := max (c₀_aux (m+1) Λ)\n    (max (c₀ m Λ)\n    (max (c₀ m ((Λ.cosimplicial (N (m+1))).obj (mk 0)))\n      ((range (m+1)).sup (λ i, c₀ m ((Λ.cosimplicial (N (m+1))).obj (mk (i + 1)))))))\n\nlemma c₀_mono : fact (c₀ (m - 1) Λ ≤ c₀ m Λ) :=\nbegin\n  fsplit,\n  cases m,\n  { apply le_refl, },\n  { dsimp [c₀],\n    apply le_trans _ (le_max_right _ _),\n    apply le_trans _ (le_max_left _ _),\n    simp, }\nend\n\nlemma c₀_pred_le (hm : 0 < m) : fact (c₀ (m - 1) ((Λ.cosimplicial (N m)).obj (mk 0)) ≤  c₀ m Λ) :=\nbegin\n  fsplit,\n  cases m,\n  { cases hm, },\n  { dsimp [c₀],\n    apply le_trans _ (le_max_right _ _),\n    apply le_trans _ (le_max_right _ _),\n    apply le_trans _ (le_max_left _ _),\n    simp, }\nend\n\nlemma c₀_pred_le_of_le (i : ℕ) (hi : i + 2 ≤ m + 1) :\n  fact (c₀ (m - 1) ((Λ.cosimplicial (N m)).obj (mk (i + 1))) ≤ c₀ m Λ) :=\nbegin\n  fsplit,\n  cases m,\n  { simpa using nat.succ_le_succ_iff.mp hi, },\n  { dsimp [c₀],\n    replace hi : i ∈ range (m + 1) :=\n      mem_range.mpr (nat.succ_le_iff.mp (nat.succ_le_succ_iff.mp hi)),\n    apply le_trans _ (le_max_right _ _),\n    apply le_trans _ (le_max_right _ _),\n    apply le_trans _ (le_max_right _ _),\n    simp only [nat.succ_sub_succ_eq_sub, nat.sub_zero, nat.succ_eq_add_one],\n    exact le_sup hi, }\nend\n\nlemma fix_this_in_mathlib :\n  nnreal.semilattice_inf = lattice.to_semilattice_inf ℝ≥0 :=\nbegin\n  apply semilattice_inf.ext, intros, refl,\nend\n\nlemma c₀_spec [BD.data.very_suitable r r' κ] (j : ℕ) (hj : j ≤ m) :\n  lem98.d Λ (N m) ≤ (k₁_sqrt m - 1) * (r' * (κ j * c₀ m Λ)) / (N m) :=\nbegin\n  have w := BD.data.pos κ,\n  rw [nnreal.le_div_iff', ←nnreal.div_le_iff', ←nnreal.div_le_iff', ←nnreal.div_le_iff'],\n  rotate,\n  { exact (w _).ne' },\n  { apply ne_of_gt, exact fact.out _ },\n  { rw [← pos_iff_ne_zero, ←add_lt_add_iff_right (1 : ℝ≥0), tsub_add_cancel_of_le, zero_add]; apply fact.out, },\n  { apply ne_of_gt, exact fact.out _ },\n  cases m, { cases hj, apply le_refl, },\n  refine le_trans _ (le_max_left _ _),\n  dsimp [c₀_aux],\n  apply nnreal.div_le_div_left_of,\n  { rw [fix_this_in_mathlib, lt_inf'_iff], intros b mem, exact w b },\n  { refine inf'_le _ _, exact mem_range_succ_iff.mpr hj },\nend\n\nend\n\nend universal_constants\n\nend thm95\n\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/thm95/constants/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4642434822199055}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n\n! This file was ported from Lean 3 source module algebra.algebra.tower\n! leanprover-community/mathlib commit 832f7b9162039c28b9361289c8681f155cae758f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Equiv\nimport Mathbin.LinearAlgebra.Span\n\n/-!\n# Towers of algebras\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `algebra A S`,\n`algebra R S`, `algebra R A` and `is_scalar_tower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `to_alg_hom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [AddCommMonoid M] [Module R M] [Module A M] [IsScalarTower R A M]\n\nvariable {A}\n\n/- warning: algebra.lsmul -> Algebra.lsmul is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {A : Type.{u2}} (M : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toHasSmul.{u2, u3} A M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))], AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 _inst_4 _inst_5)\nbut is expected to have type\n  forall (R : Type.{u1}) {A : Type.{u2}} (M : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3) (SMulZeroClass.toSMul.{u2, u3} A M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toSMul.{u1, u3} R M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u3} R M (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))], AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)\nCase conversion may be inaccurate. Consider using '#align algebra.lsmul Algebra.lsmulₓ'. -/\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `R`-module `M`.\n\nThis is a stronger version of `distrib_mul_action.to_linear_map`, and could also have been\ncalled `algebra.to_module_End`. -/\ndef lsmul : A →ₐ[R] Module.End R M\n    where\n  toFun := DistribMulAction.toLinearMap R M\n  map_one' := LinearMap.ext fun _ => one_smul A _\n  map_mul' a b := LinearMap.ext <| smul_assoc a b\n  map_zero' := LinearMap.ext fun _ => zero_smul A _\n  map_add' a b := LinearMap.ext fun _ => add_smul _ _ _\n  commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmul\n\n/- warning: algebra.lsmul_coe -> Algebra.lsmul_coe is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {A : Type.{u2}} (M : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toHasSmul.{u2, u3} A M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))] (a : A), Eq.{succ u3} ((fun (_x : LinearMap.{u1, u1, u3, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_4 _inst_4 _inst_5 _inst_5) => M -> M) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 _inst_4 _inst_5)) (fun (_x : AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 _inst_4 _inst_5)) => A -> (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)) ([anonymous].{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 _inst_4 _inst_5)) (Algebra.lsmul.{u1, u2, u3} R A M _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) a)) (coeFn.{succ u3, succ u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (fun (_x : LinearMap.{u1, u1, u3, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_4 _inst_4 _inst_5 _inst_5) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u3, u3} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_4 _inst_5 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 _inst_4 _inst_5)) (fun (_x : AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 _inst_4 _inst_5)) => A -> (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)) ([anonymous].{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 _inst_4 _inst_5)) (Algebra.lsmul.{u1, u2, u3} R A M _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) a)) (SMul.smul.{u2, u3} A M (SMulZeroClass.toHasSmul.{u2, u3} A M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) a)\nbut is expected to have type\n  forall (R : Type.{u1}) {A : Type.{u2}} (M : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3) (SMulZeroClass.toSMul.{u2, u3} A M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toSMul.{u1, u3} R M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u3} R M (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))] (a : A), Eq.{succ u3} (forall (a : M), (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) a) (FunLike.coe.{succ u3, succ u3, succ u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) a) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u3, u3} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_4 _inst_5 _inst_5 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (FunLike.coe.{max (succ u3) (succ u2), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _x) (SMulHomClass.toFunLike.{max u3 u2, u1, u2, u3} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)) R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toSMul.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (AddMonoid.toZero.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)))))) (DistribSMul.toSMulZeroClass.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (AddMonoid.toAddZeroClass.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)))))) (DistribMulAction.toDistribSMul.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))) (Module.toDistribMulAction.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)))) (Algebra.toModule.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u2, u1, u2, u3} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)) R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3)) (Module.toDistribMulAction.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)))) (Algebra.toModule.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5))) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u3 u2} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3) (Algebra.toModule.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)) (AlgHomClass.linearMapClass.{u1, u2, u3, max u3 u2} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5) (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)) (AlgHom.algHomClass.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 _inst_4 _inst_5)))))) (Algebra.lsmul.{u1, u2, u3} R A M _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) a)) ((fun (x._@.Mathlib.Algebra.Algebra.Tower._hyg.253 : A) (x._@.Mathlib.Algebra.Algebra.Tower._hyg.255 : M) => HSMul.hSMul.{u2, u3, u3} A M M (instHSMul.{u2, u3} A M (SMulZeroClass.toSMul.{u2, u3} A M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6))))) x._@.Mathlib.Algebra.Algebra.Tower._hyg.253 x._@.Mathlib.Algebra.Algebra.Tower._hyg.255) a)\nCase conversion may be inaccurate. Consider using '#align algebra.lsmul_coe Algebra.lsmul_coeₓ'. -/\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R M a : M → M) = (· • ·) a :=\n  rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} (A) {M}\n\n/- warning: is_scalar_tower.algebra_map_smul -> IsScalarTower.algebraMap_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} (A : Type.{u2}) {M : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : SMul.{u1, u3} R M] [_inst_5 : MulAction.{u2, u3} A M (MonoidWithZero.toMonoid.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2))] [_inst_6 : IsScalarTower.{u1, u2, u3} R A M (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (MulAction.toHasSmul.{u2, u3} A M (MonoidWithZero.toMonoid.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) _inst_5) _inst_4] (r : R) (x : M), Eq.{succ u3} M (SMul.smul.{u2, u3} A M (MulAction.toHasSmul.{u2, u3} A M (MonoidWithZero.toMonoid.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) _inst_5) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_3) r) x) (SMul.smul.{u1, u3} R M _inst_4 r x)\nbut is expected to have type\n  forall {R : Type.{u1}} (A : Type.{u2}) {M : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : SMul.{u1, u3} R M] [_inst_5 : MulAction.{u2, u3} A M (MonoidWithZero.toMonoid.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2))] [_inst_6 : IsScalarTower.{u1, u2, u3} R A M (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3) (MulAction.toSMul.{u2, u3} A M (MonoidWithZero.toMonoid.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) _inst_5) _inst_4] (r : R) (x : M), Eq.{succ u3} M (HSMul.hSMul.{u2, u3, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) M M (instHSMul.{u2, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) M (MulAction.toSMul.{u2, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) M (MonoidWithZero.toMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) _inst_2)) _inst_5)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (RingHom.instRingHomClassRingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_3) r) x) (HSMul.hSMul.{u1, u3, u3} R M M (instHSMul.{u1, u3} R M _inst_4) r x)\nCase conversion may be inaccurate. Consider using '#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smulₓ'. -/\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n  rw [Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\n/- warning: is_scalar_tower.of_algebra_map_eq -> IsScalarTower.of_algebraMap_eq is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3], (forall (x : R), Eq.{succ u3} A (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (fun (_x : RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) => R -> A) (RingHom.hasCoeToFun.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (algebraMap.{u1, u3} R A _inst_1 _inst_3 _inst_8) x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (fun (_x : RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) => S -> A) (RingHom.hasCoeToFun.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (algebraMap.{u2, u3} S A _inst_2 _inst_3 _inst_6) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (fun (_x : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (algebraMap.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) x))) -> (IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3], (forall (x : R), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) x) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (RingHom.instRingHomClassRingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (algebraMap.{u1, u3} R A _inst_1 _inst_3 _inst_8) x) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => A) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S A (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (algebraMap.{u2, u3} S A _inst_2 _inst_3 _inst_6) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (RingHom.instRingHomClassRingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))))) (algebraMap.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) x))) -> (IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8))\nCase conversion may be inaccurate. Consider using '#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eqₓ'. -/\ntheorem of_algebraMap_eq [Algebra R A]\n    (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n  ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n#print IsScalarTower.of_algebraMap_eq' /-\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n    (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n  of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n-/\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\n#print IsScalarTower.algebraMap_eq /-\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n  RingHom.ext fun x => by\n    simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n-/\n\n/- warning: is_scalar_tower.algebra_map_apply -> IsScalarTower.algebraMap_apply is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) (A : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)))))] (x : R), Eq.{succ u3} A (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (fun (_x : RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) => R -> A) (RingHom.hasCoeToFun.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (algebraMap.{u1, u3} R A _inst_1 _inst_3 _inst_8) x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (fun (_x : RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) => S -> A) (RingHom.hasCoeToFun.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (algebraMap.{u2, u3} S A _inst_2 _inst_3 _inst_6) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (fun (_x : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (algebraMap.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) x))\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) (A : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8)] (x : R), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) x) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (RingHom.instRingHomClassRingHom.{u1, u3} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (algebraMap.{u1, u3} R A _inst_1 _inst_3 _inst_8) x) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => A) _x) (MulHomClass.toFunLike.{max u2 u3, u2, u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S A (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u3, u2, u3} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (RingHom.instRingHomClassRingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (algebraMap.{u2, u3} S A _inst_2 _inst_3 _inst_6) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (RingHom.instRingHomClassRingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))))) (algebraMap.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) x))\nCase conversion may be inaccurate. Consider using '#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_applyₓ'. -/\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n  rw [algebra_map_eq R S A, RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n#print IsScalarTower.Algebra.ext /-\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n    (h :\n      ∀ (r : S) (x : A),\n        (haveI := h1\n          r • x) =\n          r • x) :\n    h1 = h2 :=\n  Algebra.algebra_ext _ _ fun r => by\n    simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n-/\n\n#print IsScalarTower.toAlgHom /-\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n  { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n-/\n\n#print IsScalarTower.toAlgHom_apply /-\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y :=\n  rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n-/\n\n/- warning: is_scalar_tower.coe_to_alg_hom -> IsScalarTower.coe_toAlgHom is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (S : Type.{u2}) (A : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)))))], Eq.{max (succ u2) (succ u3)} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) ((fun (a : Sort.{max (succ u2) (succ u3)}) (b : Sort.{max (succ u2) (succ u3)}) [self : HasLiftT.{max (succ u2) (succ u3), max (succ u2) (succ u3)} a b] => self.0) (AlgHom.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8) (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8) (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (CoeTCₓ.coe.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8) (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (RingHom.hasCoeT.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8) S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8) R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8 (AlgHom.algHomClass.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8))))) (IsScalarTower.toAlgHom.{u1, u2, u3} R S A _inst_1 _inst_2 _inst_3 _inst_5 _inst_6 _inst_8 _inst_10)) (algebraMap.{u2, u3} S A _inst_2 _inst_3 _inst_6)\nbut is expected to have type\n  forall (R : Type.{u1}) (S : Type.{u2}) (A : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8)], Eq.{max (succ u2) (succ u3)} (RingHom.{u2, u3} S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3)) (RingHomClass.toRingHom.{max u2 u3, u2, u3} (AlgHom.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8) S A (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (AlgHomClass.toRingHomClass.{max u2 u3, u1, u2, u3} (AlgHom.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8) R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8 (AlgHom.algHomClass.{u1, u2, u3} R S A _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_3 _inst_5 _inst_8)) (IsScalarTower.toAlgHom.{u1, u2, u3} R S A _inst_1 _inst_2 _inst_3 _inst_5 _inst_6 _inst_8 _inst_10)) (algebraMap.{u2, u3} S A _inst_2 _inst_3 _inst_6)\nCase conversion may be inaccurate. Consider using '#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHomₓ'. -/\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n  RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n#print IsScalarTower.coe_to_alg_hom' /-\n@[simp]\ntheorem coe_to_alg_hom' : (toAlgHom R S A : S → A) = algebraMap S A :=\n  rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_to_alg_hom'\n-/\n\nvariable {R S A B}\n\n#print IsScalarTower.AlgHom.map_algebraMap /-\n@[simp]\ntheorem IsScalarTower.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n    f (algebraMap R A r) = algebraMap R B r := by\n  rw [algebra_map_apply R S A r, f.commutes, ← algebra_map_apply R S B]\n#align alg_hom.map_algebra_map IsScalarTower.AlgHom.map_algebraMap\n-/\n\nvariable (R)\n\n/- warning: alg_hom.comp_algebra_map_of_tower -> IsScalarTower.AlgHom.comp_algebraMap_of_tower is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)))))] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u4} S B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u2, u4} S B (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u2, u4} S B (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7))))) (SMulZeroClass.toHasSmul.{u1, u4} R B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u1, u4} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u1, u4} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9)))))] (f : AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u1) (succ u4)} (RingHom.{u1, u4} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (RingHom.comp.{u1, u3, u4} R A B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) ((fun (a : Sort.{max (succ u3) (succ u4)}) (b : Sort.{max (succ u3) (succ u4)}) [self : HasLiftT.{max (succ u3) (succ u4), max (succ u3) (succ u4)} a b] => self.0) (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (HasLiftT.mk.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (CoeTCₓ.coe.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (RingHom.hasCoeT.{max u3 u4, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) (AlgHomClass.toRingHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgHom.algHomClass.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7))))) f) (algebraMap.{u1, u3} R A _inst_1 _inst_3 _inst_8)) (algebraMap.{u1, u4} R B _inst_1 _inst_4 _inst_9)\nbut is expected to have type\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8)] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u4} S B _inst_2 _inst_4 _inst_7) (Algebra.toSMul.{u1, u4} R B _inst_1 _inst_4 _inst_9)] (f : AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u1) (succ u4)} (RingHom.{u1, u4} R B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (RingHom.comp.{u1, u3, u4} R A B (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) (RingHomClass.toRingHom.{max u4 u3, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) (AlgHomClass.toRingHomClass.{max u4 u3, u2, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgHom.algHomClass.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7)) f) (algebraMap.{u1, u3} R A _inst_1 _inst_3 _inst_8)) (algebraMap.{u1, u4} R B _inst_1 _inst_4 _inst_9)\nCase conversion may be inaccurate. Consider using '#align alg_hom.comp_algebra_map_of_tower IsScalarTower.AlgHom.comp_algebraMap_of_towerₓ'. -/\n@[simp]\ntheorem IsScalarTower.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n    (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n  RingHom.ext f.map_algebraMap\n#align alg_hom.comp_algebra_map_of_tower IsScalarTower.AlgHom.comp_algebraMap_of_tower\n\nvariable (R) {S A B}\n\n/- warning: is_scalar_tower.subsemiring -> IsScalarTower.subsemiring is a dubious translation:\nlean 3 declaration is\n  forall {S : Type.{u1}} {A : Type.{u2}} [_inst_2 : CommSemiring.{u1} S] [_inst_3 : Semiring.{u2} A] [_inst_6 : Algebra.{u1, u2} S A _inst_2 _inst_3] (U : Subsemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))), IsScalarTower.{u1, u1, u2} (coeSort.{succ u1, succ (succ u1)} (Subsemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subsemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))) S (Subsemiring.setLike.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)))) U) S A (Subsemiring.hasSmul.{u1, u1} S S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)) (Mul.toSMul.{u1} S (Distrib.toHasMul.{u1} S (NonUnitalNonAssocSemiring.toDistrib.{u1} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)))))) U) (SMulZeroClass.toHasSmul.{u1, u2} S A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} S A (MulZeroClass.toHasZero.{u1} S (MulZeroOneClass.toMulZeroClass.{u1} S (MonoidWithZero.toMulZeroOneClass.{u1} S (Semiring.toMonoidWithZero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} S A (Semiring.toMonoidWithZero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u2} S A (CommSemiring.toSemiring.{u1} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3))) (Algebra.toModule.{u1, u2} S A _inst_2 _inst_3 _inst_6))))) (Subsemiring.hasSmul.{u1, u2} S A (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)) (SMulZeroClass.toHasSmul.{u1, u2} S A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} S A (MulZeroClass.toHasZero.{u1} S (MulZeroOneClass.toMulZeroClass.{u1} S (MonoidWithZero.toMulZeroOneClass.{u1} S (Semiring.toMonoidWithZero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} S A (Semiring.toMonoidWithZero.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u2} S A (CommSemiring.toSemiring.{u1} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_3))) (Algebra.toModule.{u1, u2} S A _inst_2 _inst_3 _inst_6))))) U)\nbut is expected to have type\n  forall {S : Type.{u1}} {A : Type.{u2}} [_inst_2 : CommSemiring.{u1} S] [_inst_3 : Semiring.{u2} A] [_inst_6 : Algebra.{u1, u2} S A _inst_2 _inst_3] (U : Subsemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))), IsScalarTower.{u1, u1, u2} (Subtype.{succ u1} S (fun (x : S) => Membership.mem.{u1, u1} S (Subsemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))) (SetLike.instMembership.{u1, u1} (Subsemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2))) S (Subsemiring.instSetLikeSubsemiring.{u1} S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)))) x U)) S A (Subsemiring.smul.{u1, u1} S S (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)) (Algebra.toSMul.{u1, u1} S S _inst_2 (CommSemiring.toSemiring.{u1} S _inst_2) (Algebra.id.{u1} S _inst_2)) U) (Algebra.toSMul.{u1, u2} S A _inst_2 _inst_3 _inst_6) (Subsemiring.smul.{u1, u2} S A (Semiring.toNonAssocSemiring.{u1} S (CommSemiring.toSemiring.{u1} S _inst_2)) (Algebra.toSMul.{u1, u2} S A _inst_2 _inst_3 _inst_6) U)\nCase conversion may be inaccurate. Consider using '#align is_scalar_tower.subsemiring IsScalarTower.subsemiringₓ'. -/\n-- conflicts with is_scalar_tower.subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n  of_algebraMap_eq fun x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n#print IsScalarTower.of_ring_hom /-\n@[nolint instance_priority]\ninstance of_ring_hom {R A B : Type _} [CommSemiring R] [CommSemiring A] [CommSemiring B]\n    [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n    @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n  letI := (f : A →+* B).toAlgebra\n  of_algebra_map_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n-/\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable (R) {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n#print AlgHom.restrictScalars /-\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n  { (f : A →+* B) with\n    commutes' := fun r =>\n      by\n      rw [algebra_map_apply R S A, algebra_map_apply R S B]\n      exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n-/\n\n#print AlgHom.restrictScalars_apply /-\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x :=\n  rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n-/\n\n/- warning: alg_hom.coe_restrict_scalars -> AlgHom.coe_restrictScalars is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)))))] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u4} S B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u2, u4} S B (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u2, u4} S B (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7))))) (SMulZeroClass.toHasSmul.{u1, u4} R B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u1, u4} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u1, u4} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9)))))] (f : AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u3) (succ u4)} (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) ((fun (a : Sort.{max (succ u3) (succ u4)}) (b : Sort.{max (succ u3) (succ u4)}) [self : HasLiftT.{max (succ u3) (succ u4), max (succ u3) (succ u4)} a b] => self.0) (AlgHom.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (HasLiftT.mk.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (CoeTCₓ.coe.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (RingHom.hasCoeT.{max u3 u4, u3, u4} (AlgHom.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) (AlgHomClass.toRingHomClass.{max u3 u4, u1, u3, u4} (AlgHom.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgHom.algHomClass.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9))))) (AlgHom.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f)) ((fun (a : Sort.{max (succ u3) (succ u4)}) (b : Sort.{max (succ u3) (succ u4)}) [self : HasLiftT.{max (succ u3) (succ u4), max (succ u3) (succ u4)} a b] => self.0) (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (HasLiftT.mk.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (CoeTCₓ.coe.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (RingHom.hasCoeT.{max u3 u4, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) (AlgHomClass.toRingHomClass.{max u3 u4, u2, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgHom.algHomClass.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7))))) f)\nbut is expected to have type\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8)] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u4} S B _inst_2 _inst_4 _inst_7) (Algebra.toSMul.{u1, u4} R B _inst_1 _inst_4 _inst_9)] (f : AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (RingHom.{u3, u4} A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4)) (RingHomClass.toRingHom.{max u4 u3, u3, u4} (AlgHom.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) (AlgHomClass.toRingHomClass.{max u4 u3, u1, u3, u4} (AlgHom.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgHom.algHomClass.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9)) (AlgHom.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f)) (RingHomClass.toRingHom.{max u4 u3, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A B (Semiring.toNonAssocSemiring.{u3} A _inst_3) (Semiring.toNonAssocSemiring.{u4} B _inst_4) (AlgHomClass.toRingHomClass.{max u4 u3, u2, u3, u4} (AlgHom.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgHom.algHomClass.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7)) f)\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalarsₓ'. -/\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f :=\n  rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n#print AlgHom.coe_restrict_scalars' /-\n@[simp]\ntheorem coe_restrict_scalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f :=\n  rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrict_scalars'\n-/\n\n#print AlgHom.restrictScalars_injective /-\ntheorem restrictScalars_injective :\n    Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun f g h =>\n  AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n-/\n\nend AlgHom\n\nnamespace AlgEquiv\n\n#print AlgEquiv.restrictScalars /-\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n  { (f : A ≃+* B) with\n    commutes' := fun r =>\n      by\n      rw [algebra_map_apply R S A, algebra_map_apply R S B]\n      exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n-/\n\n/- warning: alg_equiv.restrict_scalars_apply -> AlgEquiv.restrictScalars_apply is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)))))] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u4} S B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u2, u4} S B (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u2, u4} S B (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7))))) (SMulZeroClass.toHasSmul.{u1, u4} R B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u1, u4} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u1, u4} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9)))))] (f : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (x : A), Eq.{succ u4} B (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (fun (_x : AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) => A -> B) (AlgEquiv.hasCoeToFun.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (AlgEquiv.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f) x) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (fun (_x : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) => A -> B) (AlgEquiv.hasCoeToFun.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) f x)\nbut is expected to have type\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8)] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u4} S B _inst_2 _inst_4 _inst_7) (Algebra.toSMul.{u1, u4} R B _inst_1 _inst_4 _inst_9)] (f : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (x : A), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) x) (FunLike.coe.{max (succ u4) (succ u3), succ u3, succ u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u3, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Module.toDistribMulAction.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8))))) (SMulZeroClass.toSMul.{u1, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribSMul.toSMulZeroClass.{u1, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribMulAction.toDistribSMul.{u1, u4} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u3, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)) (Module.toDistribMulAction.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9)) (SemilinearMapClass.distribMulActionHomClass.{u1, u3, u4, max u4 u3} R A B (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9) (AlgHomClass.linearMapClass.{u1, u3, u4, max u4 u3} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (AlgEquivClass.toAlgHomClass.{max u4 u3, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgEquiv.instAlgEquivClassAlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9)))))) (AlgEquiv.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f) x) (FunLike.coe.{max (succ u4) (succ u3), succ u3, succ u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u3, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u3} S A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u3} S A (MonoidWithZero.toMonoid.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Module.toDistribMulAction.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} S B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribSMul.toSMulZeroClass.{u2, u4} S B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribMulAction.toDistribSMul.{u2, u4} S B (MonoidWithZero.toMonoid.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u3, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B (MonoidWithZero.toMonoid.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6)) (Module.toDistribMulAction.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u4 u3} S A B (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, max u4 u3} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (AlgEquivClass.toAlgHomClass.{max u4 u3, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgEquiv.instAlgEquivClassAlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7)))))) f x)\nCase conversion may be inaccurate. Consider using '#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_applyₓ'. -/\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x :=\n  rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n/- warning: alg_equiv.coe_restrict_scalars -> AlgEquiv.coe_restrictScalars is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)))))] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u4} S B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u2, u4} S B (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u2, u4} S B (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7))))) (SMulZeroClass.toHasSmul.{u1, u4} R B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u1, u4} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u1, u4} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9)))))] (f : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u3) (succ u4)} (RingEquiv.{u3, u4} A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) ((fun (a : Sort.{max (succ u3) (succ u4)}) (b : Sort.{max (succ u3) (succ u4)}) [self : HasLiftT.{max (succ u3) (succ u4), max (succ u3) (succ u4)} a b] => self.0) (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (RingEquiv.{u3, u4} A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (HasLiftT.mk.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (RingEquiv.{u3, u4} A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (CoeTCₓ.coe.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (RingEquiv.{u3, u4} A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (RingEquiv.hasCoeT.{max u3 u4, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (AlgEquivClass.toRingEquivClass.{max u3 u4, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgEquiv.algEquivClass.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9))))) (AlgEquiv.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f)) ((fun (a : Sort.{max (succ u3) (succ u4)}) (b : Sort.{max (succ u3) (succ u4)}) [self : HasLiftT.{max (succ u3) (succ u4), max (succ u3) (succ u4)} a b] => self.0) (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingEquiv.{u3, u4} A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (HasLiftT.mk.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingEquiv.{u3, u4} A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (CoeTCₓ.coe.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (RingEquiv.{u3, u4} A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (RingEquiv.hasCoeT.{max u3 u4, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A B (Distrib.toHasMul.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toHasMul.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Distrib.toHasAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (AlgEquivClass.toRingEquivClass.{max u3 u4, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgEquiv.algEquivClass.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7))))) f)\nbut is expected to have type\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8)] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u4} S B _inst_2 _inst_4 _inst_7) (Algebra.toSMul.{u1, u4} R B _inst_1 _inst_4 _inst_9)] (f : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (RingEquiv.{u3, u4} A B (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalNonAssocSemiring.toMul.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Distrib.toAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Distrib.toAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (RingEquivClass.toRingEquiv.{max u4 u3, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) A B (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Distrib.toAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (NonUnitalNonAssocSemiring.toMul.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Distrib.toAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (AlgEquivClass.toRingEquivClass.{max u4 u3, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgEquiv.instAlgEquivClassAlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9)) (AlgEquiv.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f)) (RingEquivClass.toRingEquiv.{max u4 u3, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A B (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Distrib.toAdd.{u3} A (NonUnitalNonAssocSemiring.toDistrib.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (NonUnitalNonAssocSemiring.toMul.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Distrib.toAdd.{u4} B (NonUnitalNonAssocSemiring.toDistrib.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (AlgEquivClass.toRingEquivClass.{max u4 u3, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgEquiv.instAlgEquivClassAlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7)) f)\nCase conversion may be inaccurate. Consider using '#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalarsₓ'. -/\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f :=\n  rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n/- warning: alg_equiv.coe_restrict_scalars' -> AlgEquiv.coe_restrict_scalars' is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)))))] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5))))) (SMulZeroClass.toHasSmul.{u2, u4} S B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u2, u4} S B (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u2, u4} S B (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7))))) (SMulZeroClass.toHasSmul.{u1, u4} R B (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (SMulWithZero.toSmulZeroClass.{u1, u4} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (MulActionWithZero.toSMulWithZero.{u1, u4} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))))) (Module.toMulActionWithZero.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9)))))] (f : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u3) (succ u4)} ((fun (_x : AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) => A -> B) (AlgEquiv.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f)) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (fun (_x : AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) => A -> B) (AlgEquiv.hasCoeToFun.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (AlgEquiv.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f)) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (fun (_x : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) => A -> B) (AlgEquiv.hasCoeToFun.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) f)\nbut is expected to have type\n  forall (R : Type.{u1}) {S : Type.{u2}} {A : Type.{u3}} {B : Type.{u4}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} S] [_inst_3 : Semiring.{u3} A] [_inst_4 : Semiring.{u4} B] [_inst_5 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2)] [_inst_6 : Algebra.{u2, u3} S A _inst_2 _inst_3] [_inst_7 : Algebra.{u2, u4} S B _inst_2 _inst_4] [_inst_8 : Algebra.{u1, u3} R A _inst_1 _inst_3] [_inst_9 : Algebra.{u1, u4} R B _inst_1 _inst_4] [_inst_10 : IsScalarTower.{u1, u2, u3} R S A (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toSMul.{u1, u3} R A _inst_1 _inst_3 _inst_8)] [_inst_11 : IsScalarTower.{u1, u2, u4} R S B (Algebra.toSMul.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_2) _inst_5) (Algebra.toSMul.{u2, u4} S B _inst_2 _inst_4 _inst_7) (Algebra.toSMul.{u1, u4} R B _inst_1 _inst_4 _inst_9)] (f : AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (forall (a : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) a) (FunLike.coe.{max (succ u4) (succ u3), succ u3, succ u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u3, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u3} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Module.toDistribMulAction.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8))))) (SMulZeroClass.toSMul.{u1, u4} R B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribSMul.toSMulZeroClass.{u1, u4} R B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribMulAction.toDistribSMul.{u1, u4} R B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u3, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8)) (Module.toDistribMulAction.{u1, u4} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9)) (SemilinearMapClass.distribMulActionHomClass.{u1, u3, u4, max u4 u3} R A B (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u1, u3} R A _inst_1 _inst_3 _inst_8) (Algebra.toModule.{u1, u4} R B _inst_1 _inst_4 _inst_9) (AlgHomClass.linearMapClass.{u1, u3, u4, max u4 u3} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) (AlgEquivClass.toAlgHomClass.{max u4 u3, u1, u3, u4} (AlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9) R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9 (AlgEquiv.instAlgEquivClassAlgEquiv.{u1, u3, u4} R A B _inst_1 _inst_3 _inst_4 _inst_8 _inst_9)))))) (AlgEquiv.restrictScalars.{u1, u2, u3, u4} R S A B _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 f)) (FunLike.coe.{max (succ u4) (succ u3), succ u3, succ u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) _x) (SMulHomClass.toFunLike.{max u4 u3, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribSMul.toSMulZeroClass.{u2, u3} S A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))))) (DistribMulAction.toDistribSMul.{u2, u3} S A (MonoidWithZero.toMonoid.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (Module.toDistribMulAction.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6))))) (SMulZeroClass.toSMul.{u2, u4} S B (AddMonoid.toZero.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribSMul.toSMulZeroClass.{u2, u4} S B (AddMonoid.toAddZeroClass.{u4} B (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))))) (DistribMulAction.toDistribSMul.{u2, u4} S B (MonoidWithZero.toMonoid.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7))))) (DistribMulActionHomClass.toSMulHomClass.{max u4 u3, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B (MonoidWithZero.toMonoid.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_2))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3)))) (AddCommMonoid.toAddMonoid.{u4} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4)))) (Module.toDistribMulAction.{u2, u3} S A (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6)) (Module.toDistribMulAction.{u2, u4} S B (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7)) (SemilinearMapClass.distribMulActionHomClass.{u2, u3, u4, max u4 u3} S A B (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (CommSemiring.toSemiring.{u2} S _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_4))) (Algebra.toModule.{u2, u3} S A _inst_2 _inst_3 _inst_6) (Algebra.toModule.{u2, u4} S B _inst_2 _inst_4 _inst_7) (AlgHomClass.linearMapClass.{u2, u3, u4, max u4 u3} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) (AlgEquivClass.toAlgHomClass.{max u4 u3, u2, u3, u4} (AlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7) S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7 (AlgEquiv.instAlgEquivClassAlgEquiv.{u2, u3, u4} S A B _inst_2 _inst_3 _inst_4 _inst_6 _inst_7)))))) f)\nCase conversion may be inaccurate. Consider using '#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrict_scalars'ₓ'. -/\n@[simp]\ntheorem coe_restrict_scalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f :=\n  rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrict_scalars'\n\n#print AlgEquiv.restrictScalars_injective /-\ntheorem restrictScalars_injective :\n    Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun f g h =>\n  AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n-/\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable (R A) {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/- warning: submodule.restrict_scalars_span -> Submodule.restrictScalars_span is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) {M : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toHasSmul.{u2, u3} A M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))], (Function.Surjective.{succ u1, succ u2} R A (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_3))) -> (forall (X : Set.{u3} M), Eq.{succ u3} (Submodule.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Submodule.restrictScalars.{u1, u2, u3} R A M _inst_2 _inst_4 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_6 (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) _inst_7 (Submodule.span.{u2, u3} A M _inst_2 _inst_4 _inst_6 X)) (Submodule.span.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5 X))\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) {M : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3) (SMulZeroClass.toSMul.{u2, u3} A M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toSMul.{u1, u3} R M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u3} R M (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))], (Function.Surjective.{succ u1, succ u2} R A (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (RingHom.instRingHomClassRingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_3))) -> (forall (X : Set.{u3} M), Eq.{succ u3} (Submodule.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Submodule.restrictScalars.{u1, u2, u3} R A M _inst_2 _inst_4 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_6 (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3) _inst_7 (Submodule.span.{u2, u3} A M _inst_2 _inst_4 _inst_6 X)) (Submodule.span.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5 X))\nCase conversion may be inaccurate. Consider using '#align submodule.restrict_scalars_span Submodule.restrictScalars_spanₓ'. -/\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n    restrictScalars R (span A X) = span R X :=\n  by\n  refine' ((span_le_restrict_scalars R A X).antisymm fun m hm => _).symm\n  refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n  obtain ⟨r, rfl⟩ := hsur a\n  simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\n/- warning: submodule.coe_span_eq_span_of_surjective -> Submodule.coe_span_eq_span_of_surjective is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) {M : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toHasSmul.{u2, u3} A M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4))) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))], (Function.Surjective.{succ u1, succ u2} R A (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_3))) -> (forall (s : Set.{u3} M), Eq.{succ u3} (Set.{u3} M) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Submodule.{u2, u3} A M _inst_2 _inst_4 _inst_6) (Set.{u3} M) (HasLiftT.mk.{succ u3, succ u3} (Submodule.{u2, u3} A M _inst_2 _inst_4 _inst_6) (Set.{u3} M) (CoeTCₓ.coe.{succ u3, succ u3} (Submodule.{u2, u3} A M _inst_2 _inst_4 _inst_6) (Set.{u3} M) (SetLike.Set.hasCoeT.{u3, u3} (Submodule.{u2, u3} A M _inst_2 _inst_4 _inst_6) M (Submodule.setLike.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (Submodule.span.{u2, u3} A M _inst_2 _inst_4 _inst_6 s)) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Submodule.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Set.{u3} M) (HasLiftT.mk.{succ u3, succ u3} (Submodule.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Set.{u3} M) (CoeTCₓ.coe.{succ u3, succ u3} (Submodule.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Set.{u3} M) (SetLike.Set.hasCoeT.{u3, u3} (Submodule.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) M (Submodule.setLike.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5)))) (Submodule.span.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5 s)))\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) {M : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommMonoid.{u3} M] [_inst_5 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4] [_inst_6 : Module.{u2, u3} A M _inst_2 _inst_4] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3) (SMulZeroClass.toSMul.{u2, u3} A M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 _inst_4 _inst_6)))) (SMulZeroClass.toSMul.{u1, u3} R M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (SMulWithZero.toSMulZeroClass.{u1, u3} R M (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_4)) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5))))], (Function.Surjective.{succ u1, succ u2} R A (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2)) R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2) (RingHom.instRingHomClassRingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (algebraMap.{u1, u2} R A _inst_1 _inst_2 _inst_3))) -> (forall (s : Set.{u3} M), Eq.{succ u3} (Set.{u3} M) (SetLike.coe.{u3, u3} (Submodule.{u2, u3} A M _inst_2 _inst_4 _inst_6) M (Submodule.setLike.{u2, u3} A M _inst_2 _inst_4 _inst_6) (Submodule.span.{u2, u3} A M _inst_2 _inst_4 _inst_6 s)) (SetLike.coe.{u3, u3} (Submodule.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) M (Submodule.setLike.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5) (Submodule.span.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_4 _inst_5 s)))\nCase conversion may be inaccurate. Consider using '#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjectiveₓ'. -/\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n    (Submodule.span A s : Set M) = Submodule.span R s :=\n  congr_arg coe (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\n#print Submodule.smul_mem_span_smul_of_mem /-\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n    (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n  span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n    (by\n      rw [zero_smul]\n      exact zero_mem _)\n    (fun c₁ c₂ ih₁ ih₂ => by\n      rw [add_smul]\n      exact add_mem ih₁ ih₂)\n    fun b c hc => by\n    rw [IsScalarTower.smul_assoc]\n    exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n-/\n\nvariable [SMulCommClass R S A]\n\n/- warning: submodule.smul_mem_span_smul -> Submodule.smul_mem_span_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u3} A] [_inst_4 : Module.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))] [_inst_5 : Module.{u2, u3} S A _inst_2 _inst_3] [_inst_6 : Module.{u1, u3} R A _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6))))] [_inst_8 : SMulCommClass.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6)))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))] {s : Set.{u2} S}, (Eq.{succ u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.span.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4 s) (Top.top.{u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.hasTop.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4))) -> (forall {t : Set.{u3} A} {k : S} {x : A}, (Membership.Mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.hasMem.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) x (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 t)) -> (Membership.Mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.hasMem.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) (SMul.smul.{u2, u3} S A (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) k x) (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (SMul.smul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))) s t))))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u3} A] [_inst_4 : Module.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))] [_inst_5 : Module.{u2, u3} S A _inst_2 _inst_3] [_inst_6 : Module.{u1, u3} R A _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toSMul.{u1, u2} R S (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (SMulWithZero.toSMulZeroClass.{u1, u2} R S (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u1, u3} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6))))] [_inst_8 : SMulCommClass.{u1, u2, u3} R S A (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u1, u3} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6)))) (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))] {s : Set.{u2} S}, (Eq.{succ u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.span.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4 s) (Top.top.{u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.instTopSubmodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4))) -> (forall {t : Set.{u3} A} {k : S} {x : A}, (Membership.mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.instMembership.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) x (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 t)) -> (Membership.mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.instMembership.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) (HSMul.hSMul.{u2, u3, u3} S A A (instHSMul.{u2, u3} S A (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))) k x) (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (HSMul.hSMul.{u2, u3, u3} (Set.{u2} S) (Set.{u3} A) (Set.{u3} A) (instHSMul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))))) s t))))\nCase conversion may be inaccurate. Consider using '#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smulₓ'. -/\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n    (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n  span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n    (by\n      rw [smul_zero]\n      exact zero_mem _)\n    (fun x y ihx ihy => by\n      rw [smul_add]\n      exact add_mem ihx ihy)\n    fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\n/- warning: submodule.smul_mem_span_smul' -> Submodule.smul_mem_span_smul' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u3} A] [_inst_4 : Module.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))] [_inst_5 : Module.{u2, u3} S A _inst_2 _inst_3] [_inst_6 : Module.{u1, u3} R A _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6))))] [_inst_8 : SMulCommClass.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6)))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))] {s : Set.{u2} S}, (Eq.{succ u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.span.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4 s) (Top.top.{u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.hasTop.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4))) -> (forall {t : Set.{u3} A} {k : S} {x : A}, (Membership.Mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.hasMem.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) x (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (SMul.smul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))) s t))) -> (Membership.Mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.hasMem.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) (SMul.smul.{u2, u3} S A (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) k x) (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (SMul.smul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))) s t))))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u3} A] [_inst_4 : Module.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))] [_inst_5 : Module.{u2, u3} S A _inst_2 _inst_3] [_inst_6 : Module.{u1, u3} R A _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toSMul.{u1, u2} R S (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (SMulWithZero.toSMulZeroClass.{u1, u2} R S (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u1, u3} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6))))] [_inst_8 : SMulCommClass.{u1, u2, u3} R S A (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u1, u3} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6)))) (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))] {s : Set.{u2} S}, (Eq.{succ u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.span.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4 s) (Top.top.{u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.instTopSubmodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4))) -> (forall {t : Set.{u3} A} {k : S} {x : A}, (Membership.mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.instMembership.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) x (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (HSMul.hSMul.{u2, u3, u3} (Set.{u2} S) (Set.{u3} A) (Set.{u3} A) (instHSMul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))))) s t))) -> (Membership.mem.{u3, u3} A (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (SetLike.instMembership.{u3, u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) A (Submodule.setLike.{u1, u3} R A _inst_1 _inst_3 _inst_6)) (HSMul.hSMul.{u2, u3, u3} S A A (instHSMul.{u2, u3} S A (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))) k x) (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (HSMul.hSMul.{u2, u3, u3} (Set.{u2} S) (Set.{u3} A) (Set.{u3} A) (instHSMul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))))) s t))))\nCase conversion may be inaccurate. Consider using '#align submodule.smul_mem_span_smul' Submodule.smul_mem_span_smul'ₓ'. -/\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n    (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n  span_induction hx\n    (fun x hx => by\n      let ⟨p, q, hp, hq, hpq⟩ := Set.mem_smul.1 hx\n      rw [← hpq, smul_smul]\n      exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n    (by\n      rw [smul_zero]\n      exact zero_mem _)\n    (fun x y ihx ihy => by\n      rw [smul_add]\n      exact add_mem ihx ihy)\n    fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul' Submodule.smul_mem_span_smul'\n\n/- warning: submodule.span_smul_of_span_eq_top -> Submodule.span_smul_of_span_eq_top is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u3} A] [_inst_4 : Module.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))] [_inst_5 : Module.{u2, u3} S A _inst_2 _inst_3] [_inst_6 : Module.{u1, u3} R A _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6))))] [_inst_8 : SMulCommClass.{u1, u2, u3} R S A (SMulZeroClass.toHasSmul.{u1, u3} R A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u1, u3} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6)))) (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))] {s : Set.{u2} S}, (Eq.{succ u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.span.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4 s) (Top.top.{u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.hasTop.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4))) -> (forall (t : Set.{u3} A), Eq.{succ u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (SMul.smul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toHasSmul.{u2, u3} S A (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (SMulWithZero.toSmulZeroClass.{u2, u3} S A (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u3} A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3))) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))) s t)) (Submodule.restrictScalars.{u1, u2, u3} R S A _inst_2 _inst_3 _inst_1 _inst_6 _inst_5 (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) _inst_7 (Submodule.span.{u2, u3} S A _inst_2 _inst_3 _inst_5 t)))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} {A : Type.{u3}} [_inst_1 : Semiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_3 : AddCommMonoid.{u3} A] [_inst_4 : Module.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)))] [_inst_5 : Module.{u2, u3} S A _inst_2 _inst_3] [_inst_6 : Module.{u1, u3} R A _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R S A (SMulZeroClass.toSMul.{u1, u2} R S (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (SMulWithZero.toSMulZeroClass.{u1, u2} R S (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))) (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u1, u3} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6))))] [_inst_8 : SMulCommClass.{u1, u2, u3} R S A (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u1, u3} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u1, u3} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u1, u3} R A _inst_1 _inst_3 _inst_6)))) (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5))))] {s : Set.{u2} S}, (Eq.{succ u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.span.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4 s) (Top.top.{u2} (Submodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4) (Submodule.instTopSubmodule.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4))) -> (forall (t : Set.{u3} A), Eq.{succ u3} (Submodule.{u1, u3} R A _inst_1 _inst_3 _inst_6) (Submodule.span.{u1, u3} R A _inst_1 _inst_3 _inst_6 (HSMul.hSMul.{u2, u3, u3} (Set.{u2} S) (Set.{u3} A) (Set.{u3} A) (instHSMul.{u2, u3} (Set.{u2} S) (Set.{u3} A) (Set.smul.{u2, u3} S A (SMulZeroClass.toSMul.{u2, u3} S A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (SMulWithZero.toSMulZeroClass.{u2, u3} S A (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (MulActionWithZero.toSMulWithZero.{u2, u3} S A (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A _inst_3)) (Module.toMulActionWithZero.{u2, u3} S A _inst_2 _inst_3 _inst_5)))))) s t)) (Submodule.restrictScalars.{u1, u2, u3} R S A _inst_2 _inst_3 _inst_1 _inst_6 _inst_5 (SMulZeroClass.toSMul.{u1, u2} R S (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (SMulWithZero.toSMulZeroClass.{u1, u2} R S (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R _inst_1) (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (Module.toMulActionWithZero.{u1, u2} R S _inst_1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_4)))) _inst_7 (Submodule.span.{u2, u3} S A _inst_2 _inst_3 _inst_5 t)))\nCase conversion may be inaccurate. Consider using '#align submodule.span_smul_of_span_eq_top Submodule.span_smul_of_span_eq_topₓ'. -/\ntheorem span_smul_of_span_eq_top {s : Set S} (hs : span R s = ⊤) (t : Set A) :\n    span R (s • t) = (span S t).restrictScalars R :=\n  le_antisymm\n    (span_le.2 fun x hx =>\n      let ⟨p, q, hps, hqt, hpqx⟩ := Set.mem_smul.1 hx\n      hpqx ▸ (span S t).smul_mem p (subset_span hqt))\n    fun p hp =>\n    span_induction hp (fun x hx => one_smul S x ▸ smul_mem_span_smul hs (subset_span hx))\n      (zero_mem _) (fun _ _ => add_mem) fun k x hx => smul_mem_span_smul' hs hx\n#align submodule.span_smul_of_span_eq_top Submodule.span_smul_of_span_eq_top\n\nend Module\n\nsection Algebra\n\nvariable [CommSemiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Algebra R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\n/- warning: submodule.span_algebra_map_image -> Submodule.span_algebraMap_image is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_4 : Algebra.{u1, u2} R S _inst_1 _inst_2] (a : Set.{u1} R), Eq.{succ u2} (Submodule.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4)) (Submodule.span.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4) (Set.image.{u1, u2} R S (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (fun (_x : RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) => R -> S) (RingHom.hasCoeToFun.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (algebraMap.{u1, u2} R S _inst_1 _inst_2 _inst_4)) a)) (Submodule.map.{u1, u1, u1, u2, max u1 u2} R R R S (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHomSurjective.ids.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) R S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4)) (LinearMap.semilinearMapClass.{u1, u1, u1, u2} R R R S (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Algebra.linearMap.{u1, u2} R S _inst_1 _inst_2 _inst_4) (Submodule.span.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) a))\nbut is expected to have type\n  forall {R : Type.{u1}} {S : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} S] [_inst_4 : Algebra.{u1, u2} R S _inst_1 _inst_2] (a : Set.{u1} R), Eq.{succ u2} (Submodule.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4)) (Submodule.span.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4) (Set.image.{u1, u2} R S (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) R S (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) R S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2)) R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2) (RingHom.instRingHomClassRingHom.{u1, u2} R S (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} S _inst_2))))) (algebraMap.{u1, u2} R S _inst_1 _inst_2 _inst_4)) a)) (Submodule.map.{u1, u1, u1, u2, max u1 u2} R R R S (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHomSurjective.ids.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) R S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4)) (LinearMap.instSemilinearMapClassLinearMap.{u1, u1, u1, u2} R R R S (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Algebra.toModule.{u1, u2} R S _inst_1 _inst_2 _inst_4) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Algebra.linearMap.{u1, u2} R S _inst_1 _inst_2 _inst_4) (Submodule.span.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) a))\nCase conversion may be inaccurate. Consider using '#align submodule.span_algebra_map_image Submodule.span_algebraMap_imageₓ'. -/\n/-- A variant of `submodule.span_image` for `algebra_map`. -/\ntheorem span_algebraMap_image (a : Set R) :\n    Submodule.span R (algebraMap R S '' a) = (Submodule.span R a).map (Algebra.linearMap R S) :=\n  (Submodule.span_image <| Algebra.linearMap R S).trans rfl\n#align submodule.span_algebra_map_image Submodule.span_algebraMap_image\n\n/- warning: submodule.span_algebra_map_image_of_tower -> Submodule.span_algebraMap_image_of_tower is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {S : Type.{u2}} {T : Type.{u3}} [_inst_8 : CommSemiring.{u2} S] [_inst_9 : Semiring.{u3} T] [_inst_10 : Module.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))] [_inst_11 : IsScalarTower.{u1, u2, u2} R S S (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (Mul.toSMul.{u2} S (Distrib.toHasMul.{u2} S (NonUnitalNonAssocSemiring.toDistrib.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))))) (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10))))] [_inst_12 : Algebra.{u1, u3} R T _inst_1 _inst_9] [_inst_13 : Algebra.{u2, u3} S T _inst_8 _inst_9] [_inst_14 : IsScalarTower.{u1, u2, u3} R S T (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (SMulZeroClass.toHasSmul.{u2, u3} S T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S T (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S T (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (Module.toMulActionWithZero.{u2, u3} S T (CommSemiring.toSemiring.{u2} S _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u2, u3} S T _inst_8 _inst_9 _inst_13))))) (SMulZeroClass.toHasSmul.{u1, u3} R T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R T (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R T (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (Module.toMulActionWithZero.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12)))))] (a : Set.{u2} S), Eq.{succ u3} (Submodule.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12)) (Submodule.span.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12) (Set.image.{u2, u3} S T (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) (fun (_x : RingHom.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) => S -> T) (RingHom.hasCoeToFun.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) (algebraMap.{u2, u3} S T _inst_8 _inst_9 _inst_13)) a)) (Submodule.map.{u1, u1, u2, u3, max u2 u3} R R S T (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) _inst_10 (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHomSurjective.ids.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) S T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) _inst_10 (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12)) (LinearMap.semilinearMapClass.{u1, u1, u2, u3} R R S T (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) _inst_10 (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.restrictScalars.{u1, u2, u2, u3} R S S T (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} S _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) _inst_10 (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12) (Semiring.toModule.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Algebra.toModule.{u2, u3} S T _inst_8 _inst_9 _inst_13) (LinearMap.IsScalarTower.compatibleSMul.{u2, u3, u1, u2} S T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) R S (CommSemiring.toSemiring.{u2} S _inst_8) (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (Semiring.toModule.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) _inst_11 (SMulZeroClass.toHasSmul.{u1, u3} R T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R T (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R T (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (Module.toMulActionWithZero.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_12))))) (Algebra.toModule.{u2, u3} S T _inst_8 _inst_9 _inst_13) _inst_14) (Algebra.linearMap.{u2, u3} S T _inst_8 _inst_9 _inst_13)) (Submodule.span.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10 a))\nbut is expected to have type\n  forall {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] {S : Type.{u2}} {T : Type.{u1}} [_inst_8 : CommSemiring.{u2} S] [_inst_9 : Semiring.{u1} T] [_inst_10 : Module.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))] [_inst_11 : IsScalarTower.{u3, u2, u2} R S S (SMulZeroClass.toSMul.{u3, u2} R S (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (SMulWithZero.toSMulZeroClass.{u3, u2} R S (CommMonoidWithZero.toZero.{u3} R (CommSemiring.toCommMonoidWithZero.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (MulActionWithZero.toSMulWithZero.{u3, u2} R S (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (Module.toMulActionWithZero.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (Algebra.toSMul.{u2, u2} S S _inst_8 (CommSemiring.toSemiring.{u2} S _inst_8) (Algebra.id.{u2} S _inst_8)) (SMulZeroClass.toSMul.{u3, u2} R S (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (SMulWithZero.toSMulZeroClass.{u3, u2} R S (CommMonoidWithZero.toZero.{u3} R (CommSemiring.toCommMonoidWithZero.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (MulActionWithZero.toSMulWithZero.{u3, u2} R S (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (Module.toMulActionWithZero.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10))))] [_inst_12 : Algebra.{u3, u1} R T _inst_1 _inst_9] [_inst_13 : Algebra.{u2, u1} S T _inst_8 _inst_9] [_inst_14 : IsScalarTower.{u3, u2, u1} R S T (SMulZeroClass.toSMul.{u3, u2} R S (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (SMulWithZero.toSMulZeroClass.{u3, u2} R S (CommMonoidWithZero.toZero.{u3} R (CommSemiring.toCommMonoidWithZero.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (MulActionWithZero.toSMulWithZero.{u3, u2} R S (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (Module.toMulActionWithZero.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (Algebra.toSMul.{u2, u1} S T _inst_8 _inst_9 _inst_13) (Algebra.toSMul.{u3, u1} R T _inst_1 _inst_9 _inst_12)] (a : Set.{u2} S), Eq.{succ u1} (Submodule.{u3, u1} R T (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_12)) (Submodule.span.{u3, u1} R T (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_12) (Set.image.{u2, u1} S T (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => T) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toMul.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9) (RingHom.instRingHomClassRingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9))))) (algebraMap.{u2, u1} S T _inst_8 _inst_9 _inst_13)) a)) (Submodule.map.{u3, u3, u2, u1, max u2 u1} R R S T (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) _inst_10 (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_12) (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (RingHomSurjective.ids.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (LinearMap.{u3, u3, u2, u1} R R (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) S T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) _inst_10 (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_12)) (LinearMap.instSemilinearMapClassLinearMap.{u3, u3, u2, u1} R R S T (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) _inst_10 (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_12) (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (LinearMap.restrictScalars.{u3, u2, u2, u1} R S S T (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u2} S _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) _inst_10 (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_12) (Semiring.toModule.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Algebra.toModule.{u2, u1} S T _inst_8 _inst_9 _inst_13) (LinearMap.IsScalarTower.compatibleSMul.{u2, u1, u3, u2} S T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) R S (CommSemiring.toSemiring.{u2} S _inst_8) (SMulZeroClass.toSMul.{u3, u2} R S (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (SMulWithZero.toSMulZeroClass.{u3, u2} R S (CommMonoidWithZero.toZero.{u3} R (CommSemiring.toCommMonoidWithZero.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (MulActionWithZero.toSMulWithZero.{u3, u2} R S (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommMonoidWithZero.toZero.{u2} S (CommSemiring.toCommMonoidWithZero.{u2} S _inst_8)) (Module.toMulActionWithZero.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (SMulZeroClass.toSMul.{u3, u2} R S (AddMonoid.toZero.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))))) (SMulWithZero.toSMulZeroClass.{u3, u2} R S (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddMonoid.toZero.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))))) (MulActionWithZero.toSMulWithZero.{u3, u2} R S (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toZero.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))))) (Module.toMulActionWithZero.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10)))) (Semiring.toModule.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) _inst_11 (SMulZeroClass.toSMul.{u3, u1} R T (AddMonoid.toZero.{u1} T (AddCommMonoid.toAddMonoid.{u1} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))))) (SMulWithZero.toSMulZeroClass.{u3, u1} R T (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddMonoid.toZero.{u1} T (AddCommMonoid.toAddMonoid.{u1} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))))) (MulActionWithZero.toSMulWithZero.{u3, u1} R T (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toZero.{u1} T (AddCommMonoid.toAddMonoid.{u1} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))))) (Module.toMulActionWithZero.{u3, u1} R T (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_12))))) (Algebra.toModule.{u2, u1} S T _inst_8 _inst_9 _inst_13) _inst_14) (Algebra.linearMap.{u2, u1} S T _inst_8 _inst_9 _inst_13)) (Submodule.span.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) _inst_10 a))\nCase conversion may be inaccurate. Consider using '#align submodule.span_algebra_map_image_of_tower Submodule.span_algebraMap_image_of_towerₓ'. -/\ntheorem span_algebraMap_image_of_tower {S T : Type _} [CommSemiring S] [Semiring T] [Module R S]\n    [IsScalarTower R S S] [Algebra R T] [Algebra S T] [IsScalarTower R S T] (a : Set S) :\n    Submodule.span R (algebraMap S T '' a) =\n      (Submodule.span R a).map ((Algebra.linearMap S T).restrictScalars R) :=\n  (Submodule.span_image <| (Algebra.linearMap S T).restrictScalars R).trans rfl\n#align submodule.span_algebra_map_image_of_tower Submodule.span_algebraMap_image_of_tower\n\n/- warning: submodule.map_mem_span_algebra_map_image -> Submodule.map_mem_span_algebraMap_image is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {S : Type.{u2}} {T : Type.{u3}} [_inst_8 : CommSemiring.{u2} S] [_inst_9 : Semiring.{u3} T] [_inst_10 : Algebra.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8)] [_inst_11 : Algebra.{u1, u3} R T _inst_1 _inst_9] [_inst_12 : Algebra.{u2, u3} S T _inst_8 _inst_9] [_inst_13 : IsScalarTower.{u1, u2, u3} R S T (SMulZeroClass.toHasSmul.{u1, u2} R S (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R S (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R S (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} S (AddMonoid.toAddZeroClass.{u2} S (AddCommMonoid.toAddMonoid.{u2} S (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))))) (Module.toMulActionWithZero.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10))))) (SMulZeroClass.toHasSmul.{u2, u3} S T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} S T (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))))) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} S T (Semiring.toMonoidWithZero.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (Module.toMulActionWithZero.{u2, u3} S T (CommSemiring.toSemiring.{u2} S _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u2, u3} S T _inst_8 _inst_9 _inst_12))))) (SMulZeroClass.toHasSmul.{u1, u3} R T (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R T (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R T (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} T (AddMonoid.toAddZeroClass.{u3} T (AddCommMonoid.toAddMonoid.{u3} T (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9)))))) (Module.toMulActionWithZero.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_11)))))] (x : S) (a : Set.{u2} S), (Membership.Mem.{u2, u2} S (Submodule.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10)) (SetLike.hasMem.{u2, u2} (Submodule.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10)) S (Submodule.setLike.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10))) x (Submodule.span.{u1, u2} R S (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u1, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10) a)) -> (Membership.Mem.{u3, u3} T (Submodule.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_11)) (SetLike.hasMem.{u3, u3} (Submodule.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_11)) T (Submodule.setLike.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_11))) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) (fun (_x : RingHom.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) => S -> T) (RingHom.hasCoeToFun.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) (algebraMap.{u2, u3} S T _inst_8 _inst_9 _inst_12) x) (Submodule.span.{u1, u3} R T (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} T (Semiring.toNonAssocSemiring.{u3} T _inst_9))) (Algebra.toModule.{u1, u3} R T _inst_1 _inst_9 _inst_11) (Set.image.{u2, u3} S T (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) (fun (_x : RingHom.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) => S -> T) (RingHom.hasCoeToFun.{u2, u3} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u3} T _inst_9)) (algebraMap.{u2, u3} S T _inst_8 _inst_9 _inst_12)) a)))\nbut is expected to have type\n  forall {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] {S : Type.{u2}} {T : Type.{u1}} [_inst_8 : CommSemiring.{u2} S] [_inst_9 : Semiring.{u1} T] [_inst_10 : Algebra.{u3, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8)] [_inst_11 : Algebra.{u3, u1} R T _inst_1 _inst_9] [_inst_12 : Algebra.{u2, u1} S T _inst_8 _inst_9] [_inst_13 : IsScalarTower.{u3, u2, u1} R S T (Algebra.toSMul.{u3, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10) (Algebra.toSMul.{u2, u1} S T _inst_8 _inst_9 _inst_12) (Algebra.toSMul.{u3, u1} R T _inst_1 _inst_9 _inst_11)] (x : S) (a : Set.{u2} S), (Membership.mem.{u2, u2} S (Submodule.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u3, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10)) (SetLike.instMembership.{u2, u2} (Submodule.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u3, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10)) S (Submodule.setLike.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u3, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10))) x (Submodule.span.{u3, u2} R S (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (Algebra.toModule.{u3, u2} R S _inst_1 (CommSemiring.toSemiring.{u2} S _inst_8) _inst_10) a)) -> (Membership.mem.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => T) x) (Submodule.{u3, u1} R T (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_11)) (SetLike.instMembership.{u1, u1} (Submodule.{u3, u1} R T (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_11)) T (Submodule.setLike.{u3, u1} R T (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_11))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => T) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toMul.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9) (RingHom.instRingHomClassRingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9))))) (algebraMap.{u2, u1} S T _inst_8 _inst_9 _inst_12) x) (Submodule.span.{u3, u1} R T (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (Algebra.toModule.{u3, u1} R T _inst_1 _inst_9 _inst_11) (Set.image.{u2, u1} S T (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => T) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)))) (NonUnitalNonAssocSemiring.toMul.{u1} T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} T (Semiring.toNonAssocSemiring.{u1} T _inst_9)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9)) S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9) (RingHom.instRingHomClassRingHom.{u2, u1} S T (Semiring.toNonAssocSemiring.{u2} S (CommSemiring.toSemiring.{u2} S _inst_8)) (Semiring.toNonAssocSemiring.{u1} T _inst_9))))) (algebraMap.{u2, u1} S T _inst_8 _inst_9 _inst_12)) a)))\nCase conversion may be inaccurate. Consider using '#align submodule.map_mem_span_algebra_map_image Submodule.map_mem_span_algebraMap_imageₓ'. -/\ntheorem map_mem_span_algebraMap_image {S T : Type _} [CommSemiring S] [Semiring T] [Algebra R S]\n    [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n    (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) :=\n  by\n  rw [span_algebra_map_image_of_tower, mem_map]\n  exact ⟨x, hx, rfl⟩\n#align submodule.map_mem_span_algebra_map_image Submodule.map_mem_span_algebraMap_image\n\nend Algebra\n\nend Submodule\n\nend Semiring\n\nsection Ring\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [AddCommGroup M] [Module A M] [Module R M] [IsScalarTower R A M]\n\n/- warning: algebra.lsmul_injective -> Algebra.lsmul_injective is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) (M : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommGroup.{u3} M] [_inst_5 : Module.{u2, u3} A M _inst_2 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)] [_inst_6 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toHasSmul.{u2, u3} A M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (SMulWithZero.toSmulZeroClass.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_5)))) (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6))))] [_inst_8 : NoZeroSMulDivisors.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (SubNegMonoid.toAddMonoid.{u3} M (AddGroup.toSubNegMonoid.{u3} M (AddCommGroup.toAddGroup.{u3} M _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (SMulWithZero.toSmulZeroClass.{u2, u3} A M (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_5))))] {x : A}, (Ne.{succ u2} A x (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))))))) -> (Function.Injective.{succ u3, succ u3} M M (coeFn.{succ u3, succ u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (fun (_x : LinearMap.{u1, u1, u3, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6 _inst_6) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u3, u3} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6 _inst_6 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) (fun (_x : AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) => A -> (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) ([anonymous].{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.End.algebra.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) (Algebra.lsmul.{u1, u2, u3} R A M _inst_1 _inst_2 _inst_3 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6 _inst_5 _inst_7) x)))\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) (M : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : Semiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 _inst_2] [_inst_4 : AddCommGroup.{u3} M] [_inst_5 : Module.{u2, u3} A M _inst_2 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)] [_inst_6 : Module.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4)] [_inst_7 : IsScalarTower.{u1, u2, u3} R A M (Algebra.toSMul.{u1, u2} R A _inst_1 _inst_2 _inst_3) (SMulZeroClass.toSMul.{u2, u3} A M (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (SMulWithZero.toSMulZeroClass.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_5)))) (SMulZeroClass.toSMul.{u1, u3} R M (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (SMulWithZero.toSMulZeroClass.{u1, u3} R M (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (Module.toMulActionWithZero.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6))))] [_inst_8 : NoZeroSMulDivisors.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (SMulZeroClass.toSMul.{u2, u3} A M (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (SMulWithZero.toSMulZeroClass.{u2, u3} A M (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2)) (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A M (Semiring.toMonoidWithZero.{u2} A _inst_2) (NegZeroClass.toZero.{u3} M (SubNegZeroMonoid.toNegZeroClass.{u3} M (SubtractionMonoid.toSubNegZeroMonoid.{u3} M (SubtractionCommMonoid.toSubtractionMonoid.{u3} M (AddCommGroup.toDivisionAddCommMonoid.{u3} M _inst_4))))) (Module.toMulActionWithZero.{u2, u3} A M _inst_2 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_5))))] {x : A}, (Ne.{succ u2} A x (OfNat.ofNat.{u2} A 0 (Zero.toOfNat0.{u2} A (MonoidWithZero.toZero.{u2} A (Semiring.toMonoidWithZero.{u2} A _inst_2))))) -> (Function.Injective.{succ u3, succ u3} M M (FunLike.coe.{succ u3, succ u3, succ u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) x) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u3, u3} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6 _inst_6 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (FunLike.coe.{max (succ u3) (succ u2), succ u2, succ u3} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _x) (SMulHomClass.toFunLike.{max u3 u2, u1, u2, u3} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (SMulZeroClass.toSMul.{u1, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribSMul.toSMulZeroClass.{u1, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))))) (DistribMulAction.toDistribSMul.{u1, u2} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3))))) (SMulZeroClass.toSMul.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (AddMonoid.toZero.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)))))) (DistribSMul.toSMulZeroClass.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (AddMonoid.toAddZeroClass.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)))))) (DistribMulAction.toDistribSMul.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6))))) (Module.toDistribMulAction.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)))) (Algebra.toModule.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u2, u1, u2, u3} (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2)))) (AddCommMonoid.toAddMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6))))) (Module.toDistribMulAction.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3)) (Module.toDistribMulAction.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)))) (Algebra.toModule.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6))) (SemilinearMapClass.distribMulActionHomClass.{u1, u2, u3, max u3 u2} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Semiring.toNonAssocSemiring.{u3} (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)))) (Algebra.toModule.{u1, u2} R A _inst_1 _inst_2 _inst_3) (Algebra.toModule.{u1, u3} R (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) (AlgHomClass.linearMapClass.{u1, u2, u3, max u3 u2} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) (AlgHom.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)) (AlgHom.algHomClass.{u1, u2, u3} R A (Module.End.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_1 _inst_2 (Module.End.semiring.{u1, u3} R M (CommSemiring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6) _inst_3 (Module.instAlgebraEndToSemiringSemiring.{u1, u3} R M _inst_1 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6)))))) (Algebra.lsmul.{u1, u2, u3} R A M _inst_1 _inst_2 _inst_3 (AddCommGroup.toAddCommMonoid.{u3} M _inst_4) _inst_6 _inst_5 _inst_7) x)))\nCase conversion may be inaccurate. Consider using '#align algebra.lsmul_injective Algebra.lsmul_injectiveₓ'. -/\ntheorem lsmul_injective [NoZeroSMulDivisors A M] {x : A} (hx : x ≠ 0) :\n    Function.Injective (lsmul R M x) :=\n  smul_right_injective _ hx\n#align algebra.lsmul_injective Algebra.lsmul_injective\n\nend Algebra\n\nend Ring\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Algebra/Tower.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933315126792, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.46407482251985827}}
{"text": "inductive Cat :=\n| var (n : Nat) : Cat\n\nmutual\n\ninductive Obj : Cat → Type where\n| var (C : Cat) (n : Nat) : Obj C\n| varApp {C D : Cat} (v : Nat) (X : Obj C) : Obj D\n| rAdjApp {C D : Cat} (F : Func C D) (X : Obj D) : Obj C\n\ninductive Func : Cat → Cat → Type where\n| id (C : Cat) : Func C C\n| compVar {C D E : Cat} (F : Func C D) (v : Nat) : Func C E\n| compRAdj {C D E : Cat} (F : Func C D) (G : Func E D) : Func C E\n\nend\n\nmutual\n\ndef ObjContainsRAdj {C' D' : Cat} (L : Func C' D') : {C : Cat} → (X : Obj C) → Prop\n| _, Obj.var _ _     => False\n| _, Obj.varApp _ X  => ObjContainsRAdj L X\n| _, Obj.rAdjApp F X => FuncContainsRAdj L F ∨ ObjContainsRAdj L X\n\ndef FuncContainsRAdj {C' D' : Cat} (L : Func C' D') : {C D : Cat} → (F : Func C D) → Prop\n| _, _, Func.id _         => False\n| _, _, Func.compVar G v  => FuncContainsRAdj L G\n| _, _, Func.compRAdj G H => FuncContainsRAdj L G ∨ HEq L H\n\nend\n\nnoncomputable def Func.compAux {D E : Cat} (G : Func D E) : (C : Cat) → (F : Func C D) → Func C E :=\n@Func.recOn (λ _ _ => Unit) (λ D E G => (C : Cat) → (F : Func C D) → Func C E)\n  D E G\n  (λ _ _ => ())\n  (λ _ _ _ => ())\n  (λ _ _ _ _ => ())\n  (λ _ _ F => F)\n  (λ D v ih C F => compVar (ih _ F) v)\n  (λ F G ih _ C H => compRAdj (ih _ H) G)\n\nnoncomputable def Func.comp {C D E : Cat} (F : Func C D) (G : Func D E) : Func C E :=\nFunc.compAux G _ F\n\nnoncomputable def Func.app {C D : Cat} (F : Func C D) : (X : Obj C) → Obj D :=\n@Func.recOn (λ _ _ => Unit) (λ C D _ => Obj C → Obj D)\n  C D F\n  (λ _ _ => ())\n  (λ _ _ _ => ())\n  (λ _ _ _ _ => ())\n  (λ _ X => X)\n  (λ F v ih X => Obj.varApp v (ih X))\n  (λ F G ih _ X => Obj.rAdjApp G (ih X))\n\ntheorem Func.idApp {C : Cat} (X : Obj C) : (Func.id C).app X = X := rfl\n\ntheorem Func.compVarApp {C D E : Cat} (F : Func C D) (v : Nat) (X : Obj C) :\n  (@Func.compVar C D E F v).app X = Obj.varApp v (F.app X) := rfl\n\ntheorem Func.compRAdjApp {C D E : Cat} (F : Func C D) (G : Func E D) (X : Obj C) :\n  (Func.compRAdj F G).app X = Obj.rAdjApp G (F.app X) := rfl\n\ndef Func.var (C D : Cat) (v : Nat) : Func C D :=\nFunc.compVar (Func.id _) v\n\ndef Func.rAdj {C D : Cat} (F : Func D C) : Func C D :=\nFunc.compRAdj (Func.id _) F\n\nnoncomputable def Obj.cases : {C : Cat} → (X Y : Obj C) → Σ D : Cat, Obj D × Obj D\n| C, X, rAdjApp F Y => cases (F.app X) Y\n| C, X,           Y => ⟨C, X, Y⟩\n\n\ntheorem FuncAppContainsRAdj {C' D' : Cat} (G : Func C' D') :\n  {C D : Cat} → (F : Func C D) → (X : Obj C) →\n  ObjContainsRAdj G (F.app X) ↔ FuncContainsRAdj G F ∨ ObjContainsRAdj G X\n| _, _, (Func.id _), X => by\nrw [Func.idApp, FuncContainsRAdj, false_or, iff_self]\ntrivial\n| _, _, (Func.compVar F v), X => by\nrw [Func.compVarApp, ObjContainsRAdj, FuncContainsRAdj, FuncAppContainsRAdj G F, iff_self]\ntrivial\n| _, _, (Func.compRAdj I H), X => by\nrw [Func.compRAdjApp, ObjContainsRAdj, FuncContainsRAdj, FuncAppContainsRAdj G I]\nsorry\n\ntheorem ObjContainsRAdjCases1 : {C D E : Cat} → {X Y : Obj E} → {F : Func C D} →\n  ObjContainsRAdj F (X.cases Y).2.1 → ObjContainsRAdj F X ∨ ObjContainsRAdj F Y\n| C, D, E, X, Obj.rAdjApp G Y, F, h => by\n  rw [Obj.cases] at h\n  have h' := ObjContainsRAdjCases1 h\n  rw [FuncAppContainsRAdj] at h'\n  rw [ObjContainsRAdj]\n  sorry\n| C, D, E, X, Obj.var _ _, F, h => by\n  rw [Obj.cases] at h\n  simp [Obj.cases] at h\n  exact Or.inl h\n  intros _ _ _ h\n  injection h\n| C, D, E, X, Obj.varApp v Y, F, h => by\n  rw [Obj.cases] at h\n  simp at h\n  exact Or.inl h\n  intros _ _ _ h\n  injection h\n\ntheorem ObjContainsRAdjCases2 : {C D E : Cat} → {X Y : Obj E} → {F : Func C D} →\n  ObjContainsRAdj F (X.cases Y).2.2 → ObjContainsRAdj F X ∨ ObjContainsRAdj F Y\n| C, D, E, X, Obj.rAdjApp G Y, F, h => by\n  rw [Obj.cases] at h\n  have h' := ObjContainsRAdjCases2 h\n  rw [FuncAppContainsRAdj] at h'\n  rw [ObjContainsRAdj]\n  sorry\n| C, D, E, X, Obj.var _ _, F, h => by\n  rw [Obj.cases] at h\n  simp [Obj.cases] at h\n  exact Or.inr h\n  intros _ _ _ h\n  injection h\n| C, D, E, X, Obj.varApp v Y, F, h => by\n  rw [Obj.cases] at h\n  simp at h\n  exact Or.inr h\n  intros _ _ _ h\n  injection h\n\nstructure Context : Type 1 :=\n( HomVar {C : Cat} (X Y : Obj C) : Type )\n( hasRAdj {C D : Cat} (F : Func C D) : Bool )\n\nvariable (Γ : Context)\n\nmutual\n\ninductive HomAux : {C : Cat} → (X Y : Obj C) → Type where\n| var {C : Cat} (X Y : Obj C) (v : Γ.HomVar X Y) : HomAux (X.cases Y).2.1 (X.cases Y).2.2\n| mapVar {C : Cat} (D : Cat) {X Y : Obj C} (v : Nat) (f : HomAux X Y) :\n  HomAux ((Func.var C D v).app X) ((Func.var C D v).app Y)\n| mapRAdj {C D : Cat} {X Y : Obj C} (F : Func D C) (f : HomAux X Y) :\n  HomAux (F.rAdj.app X) (F.rAdj.app Y)\n| restrict {C D : Cat} (F : Func C D)\n  {X : Obj C} {Y : Obj D} :\n  Hom (F.app X) Y → HomAux X (Obj.rAdjApp F Y)\n| counit {C D : Cat} (F : Func C D) (X : Obj D) :\n  HomAux (F.app (F.rAdj.app X)) X\n\ninductive Hom : {C : Cat} → (X Y : Obj C) → Type where\n| id {C : Cat} (X : Obj C) : Hom X X\n| comp' {C : Cat} {X Y Z : Obj C} (f : HomAux X Y) (g : Hom Y Z) : Hom X Z\n\nend\n\n-- mutual\n\n-- def HomAuxContainsVar {C' : Cat} {A B : Obj C'} (v : Γ.HomVar A B) :\n--   {C : Cat} → {X Y : Obj C} → HomAux Γ X Y → Prop\n-- | _, _, _, HomAux.mapVar _ f         => HomAuxContainsVar v f\n-- | _, _, _, HomAux.mapRAdj F f        => HomAuxContainsVar v f\n-- | _, _, _, @HomAux.var _ D X' Y' w => HEq w v\n-- | _, _, _, HomAux.restrict F f    => HomContainsVar v f\n-- | _, _, _, HomAux.counit F X      => False\n\n-- def HomContainsVar {C' : Cat} {A B : Obj C'} (v : Γ.HomVar A B) :\n--   {C : Cat} → {X Y : Obj C} → Hom Γ X Y → Prop\n-- | _, _, _, Hom.id _ => False\n-- | _, _, _, Hom.comp' f g => HomAuxContainsVar v f ∨ HomContainsVar v g\n\n-- end\n\nmutual\n\ninductive HomAuxContainsVar {C' : Cat} {A B : Obj C'} (v : Γ.HomVar A B) :\n  {C : Cat} → {X Y : Obj C} → HomAux Γ X Y → Prop where\n| self : HomAuxContainsVar v (HomAux.var A B v)\n| mapRAdj : HomAuxContainsVar v f → HomAuxContainsVar v (HomAux.mapRAdj F f)\n| mapVar : HomAuxContainsVar v f → HomAuxContainsVar v (HomAux.mapVar D F f)\n| restrict : HomContainsVar v f → HomAuxContainsVar v (HomAux.restrict _ f)\n\ninductive HomContainsVar {C' : Cat} {A B : Obj C'} (v : Γ.HomVar A B) :\n  {C : Cat} → {X Y : Obj C} → Hom Γ X Y → Prop where\n| compLeft : HomAuxContainsVar v f → HomContainsVar v (Hom.comp' f g)\n| compRight : HomContainsVar v g → HomContainsVar v (Hom.comp' f g)\n\nend\n\nvariable {Γ}\n\nnamespace Hom\n\nvariable {C D : Cat}\n\nsection defs\n\ndef ofHomAux {X Y : Obj C} (f : HomAux Γ X Y) : Hom Γ X Y :=\nHom.comp' f (Hom.id _)\n\nnoncomputable def var {X Y : Obj C} (v : Γ.HomVar X Y) : Hom Γ (X.cases Y).2.1 (X.cases Y).2.2 :=\nofHomAux (HomAux.var _ _ v)\n\nnoncomputable def comp : {C : Cat} → {X Y Z : Obj C} →\n  Hom Γ X Y → Hom Γ Y Z → Hom Γ X Z\n| _, _, _, _, Hom.id _, g => g\n| _, _, _, _, Hom.comp' f g, h => Hom.comp' f (comp g h)\n\nnoncomputable def mapAux : {C D : Cat} → (F : Func C D) → {X Y : Obj C} →\n  (f : HomAux Γ X Y) → HomAux Γ (F.app X) (F.app Y)\n| _, _, Func.id _,           _, _, f => f\n| _, _, (Func.compVar F v),  _, _, f => HomAux.mapVar _ v (mapAux F f)\n| _, _, (Func.compRAdj F G), _, _, f => HomAux.mapRAdj G (mapAux F f)\n\nnoncomputable def map {C D : Cat} (F : Func C D) : {X Y : Obj C} →\n  (f : Hom Γ X Y) → Hom Γ (F.app X) (F.app Y)\n| _, _, Hom.id _ => Hom.id _\n| _, _, Hom.comp' f g => Hom.comp' (mapAux F f) (map F g)\n\nnoncomputable def restrict {C D : Cat} (F : Func C D) (hF : Γ.hasRAdj F)\n  {X : Obj C} {Y : Obj D}\n  (f : Hom Γ (F.app X) Y) : Hom Γ X (Obj.rAdjApp F Y) :=\nofHomAux (HomAux.restrict F f)\n\nnoncomputable def counit {C D : Cat} (F : Func C D) (hF : Γ.hasRAdj F) (X : Obj D) :\n  Hom Γ (F.app (F.rAdj.app X)) X :=\nofHomAux (HomAux.counit F X)\n\nend defs\n\nsection lemmas\n\ntheorem compId : {X Y : Obj C} → (f : Hom Γ X Y) → f.comp (Hom.id _) = f\n| _, _, (Hom.id _) => by rw [comp]\n| _, _, (Hom.comp' f g) => by rw [Hom.comp, compId g]\n\ntheorem idComp {X Y : Obj C} (f : Hom Γ X Y) : (Hom.id _).comp f = f :=\nby rw [Hom.comp]\n\ntheorem compAssoc : {W X Y Z : Obj C} →\n  (f : Hom Γ W X) → (g : Hom Γ X Y) → (h : Hom Γ Y Z) →\n  (f.comp g).comp h = f.comp (g.comp h)\n| _, _, _, _, Hom.id _,      h, i => by rw [idComp, idComp]\n| _, _, _, _, Hom.comp' f g, h, i =>\nby rw [Hom.comp, Hom.comp, Hom.comp, compAssoc g]\n\ntheorem mapId {X : Obj C} (F : Func C D) : map F (@Hom.id Γ C X) = Hom.id (F.app X) :=\nby rw [Hom.map]\n\ntheorem mapComp (F : Func C D) : {X Y Z : Obj C} → (f : Hom Γ X Y) → (g : Hom Γ Y Z) →\n  map F (f.comp g) = (map F f).comp (map F g)\n| _, _, _, Hom.id _,      g => by rw [idComp, mapId, idComp]\n| _, _, _, Hom.comp' f g, h => by rw [comp, map, map, mapComp F g, comp]\n\nend lemmas\n\n/- Now the other normalisation stuff.\n  -- Suppose we have f : X → Y where X and Y are Objects of C.\n  -- If Y is rAdj, then f must be restrict to be almostNormal\n  -- If Y is not rAdj then f is almostNormal if every rAdj functor contained in\n    f is contained in a variable in F or X or Y.\n  -- A term is normal if every subterm (define properly) is almostNormal\n -/\n\nend Hom\n\nmutual\n\nnoncomputable def changeVarsAux (Γ₁ Γ₂ : Context)\n  (h : ∀ {C D : Cat} (F : Func C D), Γ₁.hasRAdj F → Γ₂.hasRAdj F)\n  (i : {C : Cat} → {X Y : Obj C} → Γ₁.HomVar X Y → Γ₂.HomVar X Y) :\n  {C : Cat} → {X Y : Obj C} → HomAux Γ₁ X Y → HomAux Γ₂ X Y\n| _, _, _, HomAux.mapVar _ v f => HomAux.mapVar _ v (changeVarsAux Γ₁ Γ₂ h i f)\n| _, _, _, HomAux.mapRAdj F f => HomAux.mapRAdj F (changeVarsAux Γ₁ Γ₂ h i f)\n| _, _, _, HomAux.var _ _ f => HomAux.var _ _ (i f)\n| _, _, _, HomAux.restrict F f => HomAux.restrict F (changeVars Γ₁ Γ₂ h i f)\n| _, _, _, HomAux.counit F X => HomAux.counit F X\n\nnoncomputable def changeVars (Γ₁ Γ₂ : Context)\n  (h : ∀ {C D : Cat} (F : Func C D), Γ₁.hasRAdj F → Γ₂.hasRAdj F)\n  (i : {C : Cat} → {X Y : Obj C} → Γ₁.HomVar X Y → Γ₂.HomVar X Y) :\n  {C : Cat} → {X Y : Obj C} → Hom Γ₁ X Y → Hom Γ₂ X Y\n| _, _, _, Hom.id _ => Hom.id _\n| _, _, _, Hom.comp' f g => Hom.comp' (changeVarsAux Γ₁ Γ₂ h i f) (changeVars Γ₁ Γ₂ h i g)\n\nend\n\nmutual\n\nnoncomputable def changeVarsAux2 (Γ₁ Γ₂ : Context) :\n  {C : Cat} → {X Y : Obj C} → (f : HomAux Γ₁ X Y) →\n  (h : ∀ {C D : Cat} (F : Func C D), Γ₁.hasRAdj F → Γ₂.hasRAdj F) →\n  (i : {C : Cat} → {X Y : Obj C} → (v : Γ₁.HomVar X Y) →\n    HomAuxContainsVar Γ₁ v f → Γ₂.HomVar X Y)  → HomAux Γ₂ X Y\n| _, _, _, HomAux.mapVar _ v f, h, i =>\n    HomAux.mapVar _ v (changeVarsAux2 Γ₁ Γ₂ f h\n      (by\n        intros C X Y v hv\n        apply i\n        constructor\n        assumption ))\n| _, _, _, HomAux.mapRAdj F f, h, i => HomAux.mapRAdj F (changeVarsAux2 Γ₁ Γ₂ f h\n   (by\n        intros C X Y v hv\n        have := i v\n        apply this\n        constructor\n        assumption ))\n| _, _, _, HomAux.var _ _ v, h, i => HomAux.var _ _ (i v (by constructor))\n| _, _, _, HomAux.restrict F f, h, i => HomAux.restrict F (changeVars2 Γ₁ Γ₂ f h\n  (by\n    intros\n    apply i\n    constructor\n    assumption ))\n| _, _, _, HomAux.counit F X, h, i => HomAux.counit F X\n\nnoncomputable def changeVars2 (Γ₁ Γ₂ : Context) :\n  {C : Cat} → {X Y : Obj C} → (f : Hom Γ₁ X Y) →\n  (h : ∀ {C D : Cat} (F : Func C D), Γ₁.hasRAdj F → Γ₂.hasRAdj F) →\n  (i : {C : Cat} → {X Y : Obj C} → (v : Γ₁.HomVar X Y) →\n    HomContainsVar Γ₁ v f → Γ₂.HomVar X Y) → Hom Γ₂ X Y\n| _, _, _, Hom.id _, _, _ => Hom.id _\n| _, _, _, Hom.comp' f g, h, i =>\n  Hom.comp' (changeVarsAux2 Γ₁ Γ₂ f h\n    (by\n      intros\n      apply i\n      constructor\n      assumption))\n    (changeVars2 Γ₁ Γ₂ g h\n      (by\n        intros C X Y v hv\n        apply i v\n        apply HomContainsVar.compRight\n        assumption ))\n\nend\n\nnoncomputable def toPresheaf (Γ₁ Γ₂ : Context)\n  (h : ∀ {C D : Cat} (F : Func C D), Γ₁.hasRAdj F → Γ₂.hasRAdj F)\n  (i : {C : Cat} → {X Y : Obj C} → Γ₁.HomVar X Y → Γ₂.HomVar X Y)\n  {C : Cat} {X Y : Obj C} (f : Hom X Y) :\n", "meta": {"author": "ChrisHughes24", "repo": "lean4stuff", "sha": "2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346", "save_path": "github-repos/lean/ChrisHughes24-lean4stuff", "path": "github-repos/lean/ChrisHughes24-lean4stuff/lean4stuff-2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346/Stuff/rep_functor_adjoint.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4640472017207165}}
{"text": "-- En el artículo \"Single axioms for groups and abelian groups with\n-- various operations\" https://bit.ly/3kMBlA0 de McCune se demuestra que\n-- el siguiente axioma caracteriza a los grupos\n--    (x * (y * (((z * z⁻¹) * (u * y)⁻¹) * x))⁻¹) = u\n\nimport tactic\n\nclass mccune_group (α : Type*) extends has_mul α, has_inv α, inhabited α :=\n(mccune (x y z u : α) : x * (y * (((z * z⁻¹) * (u * y)⁻¹) * x))⁻¹ = u)\n\nnamespace mccune_group\nvariables {α : Type*} [mccune_group α] (x y z u w v : α)\n\nlemma l5 : x * (y * (z * z⁻¹ * (u * y)⁻¹ * x))⁻¹ = u := mccune _ _ _ _\n\nlemma l7 : x * (y * y⁻¹ * (z * u)⁻¹ * (v * v⁻¹) * (z * x))⁻¹ = u :=\nby simpa [l5 (v * v⁻¹)] using l5 x (y * y⁻¹ * (z * u)⁻¹ * (v * v⁻¹)) v u\n\nlemma l9 : x * (y * (z * z⁻¹) * (u * x))⁻¹ = v * v⁻¹ * (y * u)⁻¹ * (w * w⁻¹) :=\nby simpa [l5 (w * w⁻¹)] using l7 x w u (v * v⁻¹ * (y * u)⁻¹ * (w * w⁻¹)) z\n\nlemma l10 : y * y⁻¹ * (z * z⁻¹ * (u * x)⁻¹ * u)⁻¹ * (v * v⁻¹) = x :=\nby simpa [l9 _ _ _ u v y] using l7 x z u x z\n\nlemma l12 : x * x⁻¹ * y⁻¹⁻¹ * (z * z⁻¹) = y :=\nby simpa [l10] using l10 y x x (y * y⁻¹ * (y * y⁻¹)⁻¹) z\n\nlemma l14 : (x * x⁻¹) * (y * z)⁻¹ = u * u⁻¹ * (y * z)⁻¹ := -- [10 -> 5]\nbegin\n  convert l5 _ _ _ _,\n  rw l10,\n  exact x,\nend\n\nlemma l15 : (x * x⁻¹) * y⁻¹ = (z * z⁻¹) * y⁻¹ :=\nby simpa [l12] using l14 x ((x * x⁻¹) * y⁻¹⁻¹) (z * z⁻¹) z\n\nlemma l17 : u * u⁻¹ = v * v⁻¹ := -- [15 → 5 : 5]\nbegin\n  rw ←l5 u u⁻¹ u (v * v⁻¹),\n  rw l15 v _,\n  rw l5,\nend\n\ninstance : has_one α := ⟨arbitrary α * (arbitrary α)⁻¹⟩\n\n@[simp] lemma l17' : u * u⁻¹ = 1 := l17 _ _\n\nlemma l10' : (1 * ((1 * (u * x)⁻¹) * u)⁻¹) * 1 = x := l10 _ _ _ _ _\n\nlemma l20' : (1 * (1*z)⁻¹)*1 = z⁻¹ :=\nbegin\n  convert l10' _ _,\n  rw l17',\n  rw l17',\nend\n\nlemma l5' : x * (y * ((1 * (u * y)⁻¹) * x))⁻¹ = u := l5 _ _ _ _\n\nlemma l22' : x * (y⁻¹ * (1 * x))⁻¹ = y := -- [17 → 5]\nby { convert l5' _ _ y, simp }\n\nlemma l7' : x * (((1 * (z * u)⁻¹) * 1) * (z * x))⁻¹ = u := l7 _ _ _ _ _\n\nlemma l25' : x * (1⁻¹⁻¹ * (w * x))⁻¹ = w⁻¹ := -- [19 → 7:20]\nbegin\n  convert l7' _ _ _,\n  rw l17',\n  convert (l20' _).symm,\n  simp,\nend\n\nlemma l32' : 1⁻¹ * (y⁻¹ * 1)⁻¹ = y := -- [17 → 22]\nbegin\n  convert l22' (1 : α)⁻¹ y,\n  simp\nend\n\nlemma l34' : x⁻¹ * (1⁻¹⁻¹ * 1)⁻¹ = x⁻¹ := by simpa using l25' x⁻¹ x\n\nlemma l36' : (1 * (x * 1⁻¹⁻¹)⁻¹)⁻¹ = x :=\nbegin\n  convert l5' _ _ _,\n  rw l25',\n  exact x\nend\n\nlemma l44' : x * (1⁻¹⁻¹ * 1)⁻¹ = x := by simpa [l36'] using l34' (1 * (x * 1⁻¹⁻¹)⁻¹)\nlemma l48' : (1 : α)⁻¹⁻¹ * 1 = 1 := by simpa using (l44' ((1 : α)⁻¹⁻¹ * 1)).symm\nlemma l52' : x * 1⁻¹ = x := by simpa [l48'] using l44' x\nlemma l57' : (1⁻¹ * u)⁻¹⁻¹ = u := by simpa [l52', l20'] using l10' u 1⁻¹\n\nlemma l62' : (x⁻¹ * 1)⁻¹ = x⁻¹⁻¹ :=\nby simpa [l32'] using (l57' (x⁻¹ * 1)⁻¹).symm\n\nlemma l76' : (x * 1)⁻¹ = x⁻¹ := by simpa [l57'] using l62' (1⁻¹ * x)⁻¹\n\nlemma l88' : 1⁻¹ * x⁻¹⁻¹ = x :=\nby simpa [l76'] using l32' x\n\n@[simp] lemma l116' : y * 1 = y :=\nbegin\n  have := l88' (y * 1),\n  rw l76' at this,\n  rw l88' at this,\n  exact this.symm\nend\n\n@[simp] lemma one_inv_inv : (1 : α)⁻¹⁻¹ = 1 :=\nby simpa using l48'\n\n@[simp] lemma one_inv : (1 : α)⁻¹ = 1 :=\nby simpa using l88' (1 : α)\n\nlemma l92' : (1 * y⁻¹)⁻¹ = y :=\nby simpa using l36' y\n\nlemma l126' : (y * z) * z⁻¹ = y :=\nbegin\n  have := l5' ((1 : α) * (y * z)⁻¹)⁻¹ z y,\n  rw l17' at this,\n  simpa [l92'] using this,\nend\n\nlemma l201 : x * y⁻¹⁻¹ = x * y :=\nby simpa [l126' x y] using l126' (x * y) y⁻¹\n\n@[simp] lemma l207' : 1 * z = z :=\nby simpa [l201] using l126' z z⁻¹\n\n@[simp] lemma l227 : y⁻¹⁻¹ = y :=\nby simpa using l201 1 y\n\n@[simp] lemma inv_mul : x⁻¹ * x = 1 :=\nby simpa using l17' x⁻¹\n\nlemma l229 : (z * x)⁻¹ = x⁻¹ * z⁻¹ := -- 126->25:227,207\nby simpa [l126'] using (l25' x⁻¹ (z * x)).symm\n\nlemma thingy : x * (x⁻¹ * z) = z := -- [126->5:207,229,229,227,227]\nbegin\n  have := l5' x z⁻¹ z,\n  simp only [one_inv, l17', l207'] at this,\n  rw [l229, l227] at this,\n  exact this,\nend\n\nlemma l239 : x * ((x⁻¹ * u) * y) = u * y := -- [126->5:207,229,229,227,227]\nby simpa [l229, l126'] using l5' x y⁻¹ (u * y)\n\nlemma l260 : (x * y) * z = x * (y * z) := -- [215->215:229,229,229,227,227,239]\nbegin\n  rw ←l239 x⁻¹ z y,\n  rw thingy,\n  simp\nend\n\ninstance : group α :=\n{ mul_assoc := l260,\n  one_mul := by simp,\n  mul_one := by simp,\n  mul_left_inv := λ x, inv_mul _,\n  ..(by apply_instance : has_one α),\n  ..(by apply_instance : has_mul α),\n  ..(by apply_instance : has_inv α) }\n\nend mccune_group\n", "meta": {"author": "jaalonso", "repo": "Demostraciones-con-Lean", "sha": "034ee559250cf55e28d10d8e65f1a4642e284251", "save_path": "github-repos/lean/jaalonso-Demostraciones-con-Lean", "path": "github-repos/lean/jaalonso-Demostraciones-con-Lean/Demostraciones-con-Lean-034ee559250cf55e28d10d8e65f1a4642e284251/src/Axiomas_de_grupos_a_partir_del_de_McCune.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312006227325, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4640041198395752}}
{"text": "import spaces.test_function\nimport measure_theory.measure.lebesgue\n\nopen measure_theory\nopen_locale test_function\n\nabbreviation distribution {E : Type*} [normed_group E] [normed_space ℝ E] (Ω : set E) \n  (F : Type*) [normed_group F] [normed_space ℝ F] (n : with_top ℕ) : Type* :=\nCc^n⟮Ω, E, ℝ; ℝ⟯ →L[ℝ] F\n\nlocalized \"notation `𝓓'` := distribution\" in distribution\n\nnamespace distribution\n\nvariables {E : Type*} [normed_group E] [normed_space ℝ E] (Ω : set E) \n  (F : Type*) [normed_group F] [normed_space ℝ F] (n : with_top ℕ)\n\nnoncomputable def dirac (x : E) : 𝓓' Ω ℝ n := \n  (bounded_continuous_function.eval_clm ℝ x) ∘L \n  (bounded_cont_diff_map.to_bounded_continuous_functionL ℝ E ℝ n) ∘L\n  (test_function.to_bounded_cont_diff_mapL)\n\n@[simp] lemma dirac_apply (x : E) (f : Cc^n⟮Ω, E, ℝ; ℝ⟯) : dirac Ω n x f = f x := rfl\n\nnoncomputable def of_measure [measurable_space E] [opens_measurable_space E] \n  (μ : measure E) [is_finite_measure_on_compacts μ] : \n  𝓓' Ω ℝ n := \n(L1.integral_clm) ∘L (test_function.to_Lp n 1 μ)\n\n@[simp] lemma of_measure_apply [measurable_space E] [opens_measurable_space E] \n  (μ : measure E) [is_finite_measure_on_compacts μ] (f : Cc^n⟮Ω, E, ℝ; ℝ⟯) : \n  of_measure Ω n μ f = ∫ x : E, f x ∂μ := \nby rw [of_measure, integral_eq f (f.integrable μ), L1.integral_eq]; refl\n\nnoncomputable def dirac' [measurable_space E] [opens_measurable_space E] (x : E) : 𝓓' Ω ℝ n := \n  of_measure Ω n (measure.dirac x)\n\nlemma dirac_eq_dirac' [measurable_space E] [opens_measurable_space E] (x : E) : \n  dirac Ω n x = dirac' Ω n x :=\nbegin\n  ext f,\n  rw [dirac', dirac_apply, of_measure_apply, integral_dirac]\nend\n\nend distribution\n\nsection dderiv -- This will be generalized to fderiv, but I want to do some tests\n\nvariables (Ω : set ℝ) (F : Type*) [normed_group F] [normed_space ℝ F]\n\n--def dderivₗ : 𝓓' Ω F ⊤ →ₗ[ℝ] 𝓓' Ω F ⊤ :=\n\nend dderiv", "meta": {"author": "ADedecker", "repo": "distributions", "sha": "b4d124142788db55cf781184aff03bcc46aa2b10", "save_path": "github-repos/lean/ADedecker-distributions", "path": "github-repos/lean/ADedecker-distributions/distributions-b4d124142788db55cf781184aff03bcc46aa2b10/src/spaces/distribution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867873410141, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.46398844639278686}}
{"text": "import analysis.special_functions.trigonometric.deriv\nimport analysis.special_functions.log.deriv\nimport analysis.special_functions.sqrt\nimport analysis.calculus.cont_diff\nimport data.nat.log\nimport analysis.calculus.mean_value\nimport analysis.special_functions.trigonometric.arctan_deriv\nimport tactic\nimport analysis.special_functions.pow_deriv\nimport analysis.special_functions.trigonometric.inverse_deriv\nimport analysis.special_functions.log.base\nopen_locale topological_space\nopen_locale topological_space filter classical real\n\nnoncomputable theory\n\nopen set\nopen set filter\nopen real\nnamespace real\n\n/- # This proof was our last, and there for quite messy and unfinished. -/\n/- # Our main goal was to go from deriv c*log(a * y + b) to our system of 2 equations. This system is called system_a_2. -/\n/- # Now, for our previous functions a, y, b, then we found deriv c*log(a * y + b) = x / y. -/\n/- # This system can be rewritten as deriv c*log(a * y + b) = c* (a'*y+a*y'+b')/(a*y +b) in general. -/\n/- # Then for a general a, y, and b, for deriv c*log(a * y + b) = x / y to hold, then c* (a'*y+a*y'+b')/(a*y +b) = x / y must hold. -/\n/- # The easiest way to show this holds it to rewrite this to (a*y +b)*x = c*y*(a'*y + a*y' + b') =>  a*y*x + b*x - c*y*(a'*y + a*y') + c*y*b'= 0  -/\n/- # We have the assumption that b is a polynomial of order 8, and than a = c*b'/x, thus the previous equation is reduced to b*x - c*y*(a'*y + a*y')= 0   -/\n/- # To get rid for 1/x^2 b*x in a', we multiply by x^2, such that we get  x^2*(b*x - c*y*(a'*y + a*y'))= 0   -/\n/- # Thus we have to show x^2*(b*x - c*y*(a'*y + a*y'))= 0, but this only holds under certain for the coeffiecient in y and b.   -/\n/- # The relation between the coeffiecient in y and b is system_eleven. Thus if system_eleven holds iff x^2*(b*x - c*y*(a'*y + a*y'))= 0.   -/\n/- # We only managed to show that system_eleven implies x^2*(b*x - c*y*(a'*y + a*y'))= 0, but if we had more we would have shown the other way as well.  -/\n\ndef fun_z_gen (x:ℝ) (e2:ℝ) (e3:ℝ) (e4:ℝ): ℝ := x^4+e2*x^2+e3*x+e4\ndef fun_b_gen (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ): ℝ \n:= -x^8+d7*x^7+d6*x^6+d5*x^5+d4*x^4+d3*x^3+d2*x^2+d1*x+d0 -- d_8 = - 1 as an assumption, could be better implemented.\ndef fun_a_gen (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) : ℝ \n:= (-1/8)*(-8*x^6+7*d7*x^5+6*d6*x^4+5*d5*x^3+4*d4*x^2+3*d3*x+2*d2+d1*x⁻¹)  -- this comes from the assumption c*b'/x, but again could be better implemented.\ndef deriv_fun_a_gen (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d1:ℝ) : ℝ \n:= -8*6*(-1/8)*x^5+7*5*(-1/8)*d7*x^4+6*4*(-1/8)*d6*x^3+5*3*(-1/8)*d5*x^2+4*2*(-1/8)*d4*x+3*(-1/8)*d3-(-1/8)*d1/(x)^2 -- done by hand due to time pressure.\ndef deriv_fun_z_gen (x:ℝ) (e2:ℝ) (e3:ℝ): ℝ := 4*x^3+2*e2*x+e3  -- done by hand due to time pressure.\n\ndef system_a_2 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ):= (100*e_4 + 71*e_2^2=0) ∧ (70*e_3^2 + 972*e_2*e_4+45*e_2^3=0) ∧ d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210 * e_3 * (71 * e_2 ^ 2 + 100 * e_4)) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = -(4 / 3 * e_3) ∧ d_6 = -(2 * e_2) ∧ d_7 = 0\ndef system_eleven (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) := -((d_1*e_4)/64) = 0 ∧ -((d_1*e_3)/128) = 0 ∧ 1/64*(d_2*e_3 + 3*d_3*e_4) = 0 ∧ 1/128*(-128*d_0 + 4*d_2*e_2 + 9*d_3*e_3 + 16*d_4*e_4) = 0 ∧\n1/64*(-63*d_1 + 6*d_3*e_2 + 10*d_4*e_3 + 15*d_5*e_4) = 0 ∧ 1/128*(-120*d_2 + 24*d_4*e_2 + 35*d_5*e_3 + 48*d_6*e_4) = 0 ∧ 1/64*(-55*d_3 + 20*d_5*e_2 + 27*d_6*e_3 + 35*d_7*e_4) = 0 ∧\n1/128*(-96*d_4 + 60*d_6*e_2 + 77*d_7*e_3 - 96*e_4) = 0 ∧ 1/64*(-39*d_5 + 42*d_7*e_2 - 52*e_3) = 0 ∧ -(7/16)*(d_6 + 2*e_2) = 0 ∧ -((15*d_7)/64) = 0\ndef system_eleven_neg (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) := ((15/64)* d_7)=0 ∧ (7 / 16 * d_6 + 7 / 8 * e_2)=0 ∧ ((-1)/64* (-39 * d_5 + 42 * d_7 * e_2 - 52 * e_3))=0  ∧ ((-1)/128 * (-96* d_4 + 60 * d_6 * e_2 + 77 * d_7 * e_3 - 96 * e_4))=0 ∧ ((-1)/64 * (-55 * d_3 + 20 * d_5 * e_2 + 27 * d_6 * e_3 + 35 * d_7 * e_4))=0 ∧ ((-1)/128 * (-120 * d_2 + 24 * d_4 * e_2 + 35 * d_5 * e_3 + 48 * d_6 * e_4))=0 ∧ ((-1)/64*(-63 * d_1 + 6 * d_3 * e_2 + 10 * d_4 * e_3 + 15 * d_5 * e_4))=0 ∧ ((-1)/128 * (-128 * d_0 + 4 * d_2 * e_2 + 9 * d_3 * e_3 + 16 * d_4 * e_4))=0 ∧ ((-1)/64 * (d_2 * e_3 + 3 * d_3 * e_4))=0 ∧ ((d_1 * e_3)/128)=0 ∧ ((d_1 * e_4)/64)=0\n\n\n/- # Needed system eleven with minus signs in front of it to match my other functions.  -/\nlemma system_eleven_implies_system_eleven_neg (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \nsystem_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 → system_eleven_neg e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7:=\nbegin\n  unfold system_eleven,\n  unfold system_eleven_neg,\n  intro h,\n  cases h with h1 h2,\n  cases h2 with h2 h3,\n  cases h3 with h3 h4,\n  cases h4 with h4 h5,\n  cases h5 with h5 h6,\n  cases h6 with h6 h7,\n  cases h7 with h7 h8,\n  cases h8 with h8 h9,\n  cases h9 with h9 h10,\n  cases h10 with h10 h11,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  linarith,\nend\n\nlemma system_eleven_neg_implies_system_eleven (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \nsystem_eleven_neg e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 → system_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7:=\nbegin\n  unfold system_eleven,\n  unfold system_eleven_neg,\n  intro h,\n  cases h with h1 h2,\n  cases h2 with h2 h3,\n  cases h3 with h3 h4,\n  cases h4 with h4 h5,\n  cases h5 with h5 h6,\n  cases h6 with h6 h7,\n  cases h7 with h7 h8,\n  cases h8 with h8 h9,\n  cases h9 with h9 h10,\n  cases h10 with h10 h11,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  split,\n  linarith,\n  linarith,\nend\n\nlemma system_eleven_iff_system_eleven_neg (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \nsystem_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 ↔ system_eleven_neg e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7:=\nbegin\n  split,\n  apply system_eleven_implies_system_eleven_neg x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  apply system_eleven_neg_implies_system_eleven x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\nend\n\nlemma unfolding_polynomial_first_term (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ): \nx.fun_b_gen d7 d6 d5 d4 d3 d2 d1 d0 * x ^ 3= (-1) * x ^ 11 + d7 * x ^ 10 + d6 * x ^ 9 + d5 * x ^ 8 + d4 * x ^ 7 + d3 * x ^ 6 + d2 * x ^ 5 + d1 * x ^ 4 + d0 * x ^ 3:=\nbegin\n  unfold fun_b_gen,\n  repeat {conv_lhs {rw add_mul,}},\n  ring_nf,\nend\n\n/- # Again, a better and more efficient way could have been used here, but due to time pressure this was not   -/\n/- # Would have needed to add x≠0 to be with out sorrys, but due to time pressure, this has not been implemented.    -/\nlemma unfolding_polynomial_second_term (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n1 / 8 * (x.deriv_fun_a_gen d7 d6 d5 d4 d3 d1 * x.fun_z_gen e2 e3 e4) * x ^ 2 = 3 / 4 * x ^ 11 + -(35 / 64 * d7 * x ^ 10) + 1 / 8 * (6 * e2 + -(3 * d6)) * x ^ 9 + 1 / 8 * (-(35 / 8 * d7 * e2) + 6 * e3 + -(15 / 8 * d5)) * x ^ 8 + 1 / 8 * (-(35 / 8 * d7 * e3) + -(3 * d6 * e2) + 6 * e4 + -d4) * x ^ 7 + 1 / 8 * (-(3 * d6 * e3) + -(35 / 8 * d7 * e4) + -(15 / 8 * d5 * e2) + -(3 / 8 * d3)) * x ^ 6 + 1 / 8 * (-(15 / 8 * d5 * e3) + -(3 * d6 * e4) + -(d4 * e2)) * x ^ 5 + 1 / 8 * (-(15 / 8 * d5 * e4) + -(d4 * e3) + -(3 / 8 * d3 * e2) + 1 / 8 * d1) * x ^ 4 + 1 / 8 * (-(d4 * e4) + -(3 / 8 * d3 * e3)) * x ^ 3 + 1 / 8 * (-(3 / 8 * d3 * e4) + 1 / 8 * d1 * e2) * x ^ 2 + 1 / 64 * d1 * e3 * x + 1 / 64 * d1 * e4:=\nbegin\n  rw mul_assoc,\n  rw mul_assoc,\n  --unfold deriv_fun_a_gen,\n  unfold fun_z_gen,\n  repeat {conv_lhs {rw add_mul,}},\n  have h1: x ^ 4 * x ^ 2 + e2 * x ^ 2 * x ^ 2 + e3 * x * x ^ 2 + e4 * x ^ 2 = x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2,\n    ring_nf,\n  rw h1,\n  unfold deriv_fun_a_gen,\n  rw sub_mul,\n  repeat {conv_lhs {rw add_mul,}},\n  have h2: (-8) * 6 * ((-1) / 8) * x ^ 5 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2) = (6) * x ^ 11  + (6) * e2 * x ^ 9 + (6) * e3 * x ^ 8 + (6) * e4 * x ^ 7,\n    ring_nf,\n  rw h2,\n  have h3: 7 * 5 * ((-1) / 8) * d7 * x ^ 4 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2)= (-35/8) * d7 * x ^ 10 + (-35/8) * d7 * e2 * x ^ 8 + (-35/8) * d7 *e3 * x ^ 7 + (-35/8) * d7 *e4 * x ^ 6,\n    ring_nf,\n  rw h3,\n  have h4: 6 * 4 * ((-1) / 8) * d6 * x ^ 3 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2) = (-3) * d6 * x ^ 9  + (-3) * d6 *e2 * x ^ 7 + (-3) * d6 * e3 * x ^ 6 + (-3) * d6 * e4 * x ^ 5,\n    ring_nf,\n  rw h4, \n  have h5: 5 * 3 * ((-1) / 8) * d5 * x ^ 2 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2) = (-15/8) * d5 * x ^ 8 + (-15/8) * d5 * e2 * x ^ 6 +(-15/8) * d5 * e3 * x ^ 5 + (-15/8) * d5 * e4 * x ^ 4,\n    ring_nf,\n  rw h5,\n  --4 * 2 * ((-1) / 8) * d4 * x * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2) \n  have h6: 4 * 2 * ((-1) / 8) * d4 * x * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2)  = (-1) * d4 * x ^ 7 + (-1) * d4 *e2 * x ^ 5 + (-1) * d4 * e3 * x ^ 4 + (-1) * d4 *e4 * x ^ 3,\n    ring_nf,\n  rw h6,\n  --3 * ((-1) / 8) * d3 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2)\n  have h7: 3 * ((-1) / 8) * d3 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2) = (-3/8) * d3 * x ^ 6 + (-3/8) * d3 *e2 * x ^ 4 + (-3/8) * d3 *e3 * x ^ 3 + (-3/8) * d3 *e4 * x ^ 2,\n    ring_nf,\n  rw h7,\n  -- (-1) / 8 * d1 / x ^ 2 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2))\n  have h8: (-1) / 8 * d1 / x ^ 2 * (x ^ 6 + e2 * x ^ 4 + e3 * x ^ 3 + e4 * x ^ 2) = (-1) / 8 * d1 * x ^ 4 + (-1) / 8 * d1 * e2 * x ^ 2 +  (-1) / 8 * d1 * e3 * x + (-1) / 8 * d1 * e4,\n    ring_nf,\n    sorry,\n  rw h8,\n  repeat {conv_lhs {rw sub_eq_add_neg,}},\n  repeat {conv_lhs {rw ← add_assoc,}}, -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------d1 * x ^ 4 +  d1 * e2 * x ^ 2 +  d1 * e3 * x +  d1 * e4,\n  have h9: (6) * x ^ 11 + (6) * e2 * x ^ 9 + (6) * e3 * x ^ 8 + (6) * e4 * x ^ 7 + (-35/8) * d7 * x ^ 10 + (-35/8) * d7 * e2 * x ^ 8 +(-35/8) * d7 * e3 * x ^ 7 +(-35/8) * d7 * e4 * x ^ 6 +(-3) * d6 * x ^ 9 +(-3) * d6 * e2 * x ^ 7 + (-3) * d6 * e3 * x ^ 6 + (-3) * d6 * e4 * x ^ 5 + (-15/8) * d5 * x ^ 8 + (-15/8) * d5 * e2 * x ^ 6 + (-15/8) * d5 * e3 * x ^ 5 + (-15/8)* d5 * e4 * x ^ 4 + (-1) * d4 * x ^ 7 + (-1) * d4 * e2 * x ^ 5 + (-1) * d4 * e3 * x ^ 4 + (-1) * d4 * e4 * x ^ 3 +(-3/8) * d3 * x ^ 6 + (-3/8) * d3 * e2 * x ^ 4 + (-3/8) * d3 * e3 * x ^ 3 + (-3/8) * d3 * e4 * x ^ 2    =    (6) * x ^ 11   + (-35/8) * d7 * x ^ 10  + ((6) * e2   + (-3) * d6) * x ^ 9+ ((-35/8) * d7 * e2 + (6) * e3   + (-15/8) * d5 ) * x ^ 8 + ((-35/8) * d7 * e3  + (-3) * d6 * e2 + (6) * e4 + (-1) * d4) * x ^ 7+ ((-3) * d6 * e3 + (-35/8) * d7 * e4 + (-15/8) * d5 * e2 +(-3/8) * d3) * x ^ 6   + ((-15/8) * d5 * e3 + (-3) * d6 * e4  + (-1) * d4 * e2) * x ^ 5   +((-15/8) * d5 * e4 + (-1) * d4 * e3 + (-3/8) * d3 * e2) * x ^ 4 +((-1) * d4 * e4 +  (-3/8) * d3 * e3) * x ^ 3 + (-3/8) * d3 * e4 * x ^ 2,\n    ring_nf,\n  rw h9,\n  have h10: (-((-1) / 8 * d1 * x ^ 4 + (-1) / 8 * d1 * e2 * x ^ 2 + (-1) / 8 * d1 * e3 * x + (-1) / 8 * d1 * e4))= (-1)*((-1) / 8* d1 * x ^ 4 + (-1) / 8*d1 * e2 * x ^ 2 + (-1) / 8* d1 * e3 * x + (-1) / 8*d1 * e4),\n    ring_nf,\n  rw h10,\n  rw mul_add (-1) ((-1) / 8 * d1 * x ^ 4 + (-1) / 8 * d1 * e2 * x ^ 2 + (-1) / 8 * d1 * e3 * x ) ((-1) / 8 * d1 * e4),\n  rw mul_add (-1) ((-1) / 8 * d1 * x ^ 4 + (-1) / 8 * d1 * e2 * x ^ 2 ) ((-1) / 8 * d1 * e3 * x ),\n  rw mul_add (-1) ((-1) / 8 * d1 * x ^ 4) ((-1) / 8 * d1 * e2 * x ^ 2 ),\n  have h11: (6) * x ^ 11 + (-35/8) * d7 * x ^ 10 + ((6) * e2 + (-3) * d6) * x ^ 9 +((-35/8) * d7 * e2 + (6) * e3 + (-15/8) * d5) * x ^ 8 +((-35/8) * d7 * e3 + (-3) * d6 * e2 + (6) * e4 + (-1) * d4) * x ^ 7 +((-3) * d6 * e3 + (-35/8) * d7 * e4 + (-15/8) * d5 * e2 + (-3/8) * d3) * x ^ 6 +((-15/8) * d5 * e3 + (-3) * d6 * e4 + (-1) * d4 * e2) * x ^ 5 +((-15/8) * d5 * e4 + (-1) * d4 * e3 + (-3/8) * d3 * e2) * x ^ 4 +((-1) * d4 * e4 + (-3/8) * d3 * e3) * x ^ 3 + (-3/8) * d3 * e4 * x ^ 2 +((-1) * ( (-1) / 8 * d1 * x ^ 4) + (-1) * ((-1) / 8 *d1 * e2 * x ^ 2) + (-1) * ( (-1) / 8 *d1 * e3 * x) + (-1) * ((-1) / 8 * d1 * e4)) = (6) * x ^ 11 + (-35/8) * d7 * x ^ 10 + ((6) * e2 + (-3) * d6) * x ^ 9 +((-35/8) * d7 * e2 + (6) * e3 + (-15/8) * d5) * x ^ 8 +((-35/8) * d7 * e3 + (-3) * d6 * e2 + (6) * e4 + (-1) * d4) * x ^ 7 +((-3) * d6 * e3 + (-35/8) * d7 * e4 + (-15/8) * d5 * e2 + (-3/8) * d3) * x ^ 6 +((-15/8) * d5 * e3 + (-3) * d6 * e4 + (-1) * d4 * e2) * x ^ 5 +((-15/8) * d5 * e4 + (-1) * d4 * e3 + (-3/8) * d3 * e2 +(-1) * (-1) / 8 *d1) * x ^ 4 +((-1) * d4 * e4 + (-3/8) * d3 * e3) * x ^ 3 + ((-3/8) * d3 * e4+ (-1) * (-1) / 8 * d1 * e2)* x ^ 2  + ((-1) * (-1) / 8 * d1 * e3) * x + (-1) * (-1) / 8 *d1 * e4,\n    ring_nf,\n  rw h11,\n  repeat {conv_lhs {rw mul_add,}},\n  repeat {conv_lhs {rw ← mul_assoc,}},\n  conv_lhs {norm_num,}\nend \n\nlemma unfolding_polynomial_third_term (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n1 / 8 * (1 / 2 * x.fun_a_gen d7 d6 d5 d4 d3 d2 d1 * x.deriv_fun_z_gen e2 e3) * x ^ 2 = 1 / 4 * x ^ 11 + -(7 / 32) * d7 * x ^ 10 + -(1 / 128) * ((-16) * e2 + 24 * d6) * x ^ 9 + -(1 / 128) * ((-8) * e3 + 20 * d5 + 7 * d7 * 2 * e2) * x ^ 8 + -(1 / 128) * (16 * d4 + 6 * d6 * 2 * e2 + 7 * d7 * e3) * x ^ 7 + -(1 / 128) * (12 * d3 + 5 * d5 * 2 * e2 + 6 * d6 * e3) * x ^ 6 + -(1 / 128) * (8 * d2 + 4 * d4 * 2 * e2 + 5 * d5 * e3) * x ^ 5 + -(1 / 128) * (4 * d1 + 3 * d3 * 2 * e2 + 4 * d4 * e3) * x ^ 4 + -(1 / 128) * (2 * d2 * 2 * e2 + 3 * d3 * e3) * x ^ 3 + -(1 / 128) * (d1 * 2 * e2 + 2 * d2 * e3) * x ^ 2 + -(1 / 128) * d1 * e3 * x:=\nbegin\n  rw mul_assoc,\n  rw mul_assoc,\n  --unfold fun_a_gen,\n  unfold deriv_fun_z_gen,\n  repeat {conv_lhs {rw add_mul,}},\n  have h1: 4 * x ^ 3 * x ^ 2 + 2 * e2 * x * x ^ 2 + e3 * x ^ 2= 4 * x ^ 5  + 2 * e2 * x ^ 3 + e3 * x ^ 2,\n    ring_nf,\n  rw h1,\n  unfold fun_a_gen,\n  rw mul_assoc,\n  repeat {conv_lhs {rw mul_add,}},\n  have h2: 1 / 8 * (1 / 2 * (((-1) / 8 * ((-8) * x ^ 6) + (-1) / 8 * (7 * d7 * x ^ 5) + (-1) / 8 * (6 * d6 * x ^ 4) + (-1) / 8 * (5 * d5 * x ^ 3) + (-1) / 8 * (4 * d4 * x ^ 2) + (-1) / 8 * (3 * d3 * x) + (-1) / 8 * (2 * d2) + (-1) / 8 * (d1 * x⁻¹)) * (4 * x ^ 5))) = (-1) / 64 *(1 / 2 *(((-8) * 4* x ^ 11  + 7 * 4 * d7 * x ^ 10 + 6 *4 * d6 * x ^ 9 + 5 *4 * d5 * x ^ 8 + 4 * 4* d4 * x ^ 7 + 3 * 4 * d3 * x ^ 6 + 2 * 4* d2 * x ^5 + 4*d1*x⁻¹*x^5 ) )),\n    ring_nf,\n  have h2extra:  4*d1*x⁻¹*x^5= 4* d1 * x ^4,\n      sorry,\n  have h3: 1 / 8 * (1 / 2 * (((-1) / 8 * ((-8) * x ^ 6) + (-1) / 8 * (7 * d7 * x ^ 5) + (-1) / 8 * (6 * d6 * x ^ 4) + (-1) / 8 * (5 * d5 * x ^ 3) + (-1) / 8 * (4 * d4 * x ^ 2) + (-1) / 8 * (3 * d3 * x) + (-1) / 8 * (2 * d2) + (-1) / 8 * (d1 * x⁻¹)) * (4 * x ^ 5))) = (-1) / 64 *(1 / 2 *(((-8) * 4* x ^ 11  + 7 * 4 * d7 * x ^ 10 + 6 *4 * d6 * x ^ 9 + 5 *4 * d5 * x ^ 8 + 4 * 4* d4 * x ^ 7 + 3 * 4 * d3 * x ^ 6 + 2 * 4* d2 * x ^5 + 4*d1*x^4 ) )),\n    rw h2,\n    rw h2extra,\n  rw h3,\n  have h4: 1 / 8 * (1 / 2 * (((-1) / 8 * ((-8) * x ^ 6) + (-1) / 8 * (7 * d7 * x ^ 5) + (-1) / 8 * (6 * d6 * x ^ 4) + (-1) / 8 * (5 * d5 * x ^ 3) + (-1) / 8 * (4 * d4 * x ^ 2) + (-1) / 8 * (3 * d3 * x) + (-1) / 8 * (2 * d2) + (-1) / 8 * (d1 * x⁻¹)) * (2 * e2 * x ^ 3)))=(-1) / 64 *(1 / 2 *(((-8)  * 2 * e2 * x ^ 9 + 7 * d7 * 2 * e2 * x ^ 8 + 6 * d6 *  2 * e2 * x ^ 7 + 5 * d5 * 2 * e2 * x ^ 6 + 4 * d4 * 2 * e2 * x ^ 5 + 3 * d3 * 2 * e2 * x ^ 4 + 2 * d2 * 2 * e2 * x ^ 3 +d1 *  2 * e2 * x⁻¹ *x ^ 3) )),\n    ring_nf,\n  rw h4,\n  have h5: 1 / 8 * (1 / 2 * (((-1) / 8 * ((-8) * x ^ 6) + (-1) / 8 * (7 * d7 * x ^ 5) + (-1) / 8 * (6 * d6 * x ^ 4) + (-1) / 8 * (5 * d5 * x ^ 3) + (-1) / 8 * (4 * d4 * x ^ 2) + (-1) / 8 * (3 * d3 * x) + (-1) / 8 * (2 * d2) + (-1) / 8 * (d1 * x⁻¹)) * (e3 * x ^ 2)))= (-1) / 64 *(1 / 2 *(((-8) * e3 * x ^ 8 + 7 * d7  * e3 * x ^ 7 + 6 * d6 * e3 * x ^ 6 + 5 * d5 * e3 * x ^ 5 + 4 * d4 * e3 * x ^ 4 + 3 * d3 * e3 * x ^ 3 + 2 * d2 *e3 * x ^ 2 + d1 * e3 * x ^ 2 * x⁻¹) )),\n    ring_nf,\n  rw h5,\n  have h3extra: d1 * e3 * x ^ 2 * x⁻¹ = d1 * e3 * x,\n    sorry,\n  rw h3extra,\n  have h4extra: d1 * 2 * e2 * x⁻¹ * x ^ 3 = d1 * 2 * e2 *  x ^ 2,\n    sorry,\n  rw h4extra,\n  rw ← mul_add,\n  rw ← mul_add,\n  rw ← mul_add,\n  rw ← mul_add,\n  repeat {conv_lhs {rw ← add_assoc,}},\n  have h5: (-8) * 4 * x ^ 11 + 7 * 4 * d7 * x ^ 10 + 6 * 4 * d6 * x ^ 9 + 5 * 4 * d5 * x ^ 8 + 4 * 4 * d4 * x ^ 7 + 3 * 4 * d3 * x ^ 6 + 2 * 4 * d2 * x ^ 5 + 4 * d1 * x ^ 4 + (-8) * 2 * e2 * x ^ 9 + 7 * d7 * 2 * e2 * x ^ 8 + 6 * d6 * 2 * e2 * x ^ 7 + 5 * d5 * 2 * e2 * x ^ 6 + 4 * d4 * 2 * e2 * x ^ 5 + 3 * d3 * 2 * e2 * x ^ 4 + 2 * d2 * 2 * e2 * x ^ 3 + d1 * 2 * e2 * x ^ 2 +(-8) * e3 * x ^ 8 + 7 * d7 * e3 * x ^ 7 + 6 * d6 * e3 * x ^ 6 +  5 * d5 * e3 * x ^ 5 + 4 * d4 * e3 * x ^ 4 +3 * d3 * e3 * x ^ 3 + 2 * d2 * e3 * x ^ 2 +d1 * e3 * x     =       (-8) * 4 * x ^ 11 + 7 * 4 * d7 * x ^ 10 + ((-8) * 2 * e2 + 6 * 4 * d6) * x ^ 9 + ( (-8) * e3  +5 * 4 * d5 + 7 * d7 * 2 * e2) * x ^ 8 + (4 * 4 * d4 + 6 * d6 * 2 * e2 + 7 * d7 * e3) * x ^ 7 + (3 * 4 * d3 + 5 * d5 * 2 * e2 + 6 * d6 * e3) * x ^ 6 + (2 * 4 * d2 + 4 * d4 * 2 * e2 +  5 * d5 * e3)* x ^ 5  + (4 * d1 + 3 * d3 * 2 * e2  + 4 * d4 * e3) * x ^ 4+ (2 * d2 * 2 * e2 +3 * d3 * e3) * x ^ 3 + (d1 * 2 * e2 + 2 * d2 * e3) * x ^ 2 + d1 * e3 * x, \n    ring_nf,\n  rw h5,\n  repeat {conv_lhs {rw mul_add,}},\n  repeat {conv_lhs {rw ← mul_assoc,}},\n  conv_lhs {norm_num,},\n  repeat {conv_lhs {rw ← mul_assoc,}},\n  repeat {conv_lhs {rw ← neg_mul,}},\nend\n\nlemma eq_11 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \nd7 + -(35 / 64 * d7) + -(7 / 32 * d7)=(15/64)* d7:=\nbegin\n  field_simp,\n  ring_nf,\nend\n\nlemma eq_10 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(d6 + 1 / 8 * (6 * e2 + -(3 * d6)) + -(1 / 128 * (-(16 * e2) + 24 * d6)))=7 / 16 * d6 + 7 / 8 * e2:=\nbegin\n  conv_lhs {simp,},\n  conv_lhs {ring_nf,},\nend\n\nlemma eq_9 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(d5 + 1 / 8 * (-(35 / 8 * d7 * e2) + 6 * e3 + -(15 / 8 * d5)) + -(1 / 128 * (-(8 * e3) + 20 * d5 + 7 * d7 * 2 * e2)))=(-1)/64* (-39 * d5 + 42 * d7 * e2 - 52 * e3):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_8 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(d4 + -(1 / 128 * (16 * d4 + 6 * d6 * 2 * e2 + 7 * d7 * e3)) + 1 / 8 * (-(35 / 8 * d7 * e3) + -(3 * d6 * e2) + 6 * e4 + -d4))=(-1)/128 * (-96* d4 + 60 * d6 * e2 + 77 * d7 * e3 - 96 * e4):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_7 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(d3 + 1 / 8 * (-(3 * d6 * e3) + -(35 / 8 * d7 * e4) + -(15 / 8 * d5 * e2) + -(3 / 8 * d3)) + -(1 / 128 * (12 * d3 + 5 * d5 * 2 * e2 + 6 * d6 * e3)))=(-1)/64 * (-55 * d3 + 20 * d5 * e2 + 27 * d6 * e3 + 35 * d7 * e4):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_6 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(d2 + 1 / 8 * (-(15 / 8 * d5 * e3) + -(3 * d6 * e4) + -(d4 * e2)) + -(1 / 128 * (8 * d2 + 4 * d4 * 2 * e2 + 5 * d5 * e3))) =(-1)/128 * (-120 * d2 + 24 * d4 * e2 + 35 * d5 * e3 + 48 * d6 * e4):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_5 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(d1 + -(1 / 128 * (4 * d1 + 3 * d3 * 2 * e2 + 4 * d4 * e3)) + 1 / 8 * (-(15 / 8 * d5 * e4) + -(d4 * e3) + -(3 / 8 * d3 * e2) + 1 / 8 * d1))=(-1)/64*(-63 * d1 + 6 * d3 * e2 + 10 * d4 * e3 + 15 * d5 * e4):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_4 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(d0 + 1 / 8 * (-(d4 * e4) + -(3 / 8 * d3 * e3)) + -(1 / 128 * (2 * d2 * 2 * e2 + 3 * d3 * e3)))=(-1)/128 * (-128 * d0 + 4 * d2 * e2 + 9 * d3 * e3 + 16 * d4 * e4):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_3 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(1 / 8 * (-(3 / 8 * d3 * e4) + 1 / 8 * d1 * e2) + -(1 / 128 * (d1 * 2 * e2 + 2 * d2 * e3)))= (-1)/64 * (d2 * e3 + 3 * d3 * e4):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_2 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n(1 / 64 * d1 * e3 + -(1 / 128 * d1 * e3))=((d1 * e3)/128):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_1 (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n1 / 64 * d1 * e4=((d1 * e4)/64):=\nbegin\n  simp,\n  ring_nf,\nend\n\n/- # Again, a better and more efficient way could have been used here, but due to time pressure this was not   -/\nlemma unfolding_polynomial (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ): \n((fun_b_gen x d7 d6 d5 d4 d3 d2 d1 d0)*x-(-1/8)*((deriv_fun_a_gen x d7 d6 d5 d4 d3 d1)*(fun_z_gen x e2 e3 e4)+(1/2)*(fun_a_gen x d7 d6 d5 d4 d3 d2 d1)*(deriv_fun_z_gen x e2 e3))) * x^2= (d7 + -(35 / 64 * d7) + -(7 / 32 * d7)) * x ^ 10 + (d6 + 1 / 8 * (6 * e2 + -(3 * d6)) + -(1 / 128 * (-(16 * e2) + 24 * d6))) * x ^ 9 + (d5 + 1 / 8 * (-(35 / 8 * d7 * e2) + 6 * e3 + -(15 / 8 * d5)) + -(1 / 128 * (-(8 * e3) + 20 * d5 + 7 * d7 * 2 * e2))) * x ^ 8 + (d4 + -(1 / 128 * (16 * d4 + 6 * d6 * 2 * e2 + 7 * d7 * e3)) + 1 / 8 * (-(35 / 8 * d7 * e3) + -(3 * d6 * e2) + 6 * e4 + -d4)) * x ^ 7 + (d3 + 1 / 8 * (-(3 * d6 * e3) + -(35 / 8 * d7 * e4) + -(15 / 8 * d5 * e2) + -(3 / 8 * d3)) + -(1 / 128 * (12 * d3 + 5 * d5 * 2 * e2 + 6 * d6 * e3))) * x ^ 6 + (d2 + 1 / 8 * (-(15 / 8 * d5 * e3) + -(3 * d6 * e4) + -(d4 * e2)) + -(1 / 128 * (8 * d2 + 4 * d4 * 2 * e2 + 5 * d5 * e3))) * x ^ 5 + (d1 + -(1 / 128 * (4 * d1 + 3 * d3 * 2 * e2 + 4 * d4 * e3)) + 1 / 8 * (-(15 / 8 * d5 * e4) + -(d4 * e3) + -(3 / 8 * d3 * e2) + 1 / 8 * d1)) * x ^ 4 + (d0 + 1 / 8 * (-(d4 * e4) + -(3 / 8 * d3 * e3)) + -(1 / 128 * (2 * d2 * 2 * e2 + 3 * d3 * e3))) * x ^ 3 + (1 / 8 * (-(3 / 8 * d3 * e4) + 1 / 8 * d1 * e2) + -(1 / 128 * (d1 * 2 * e2 + 2 * d2 * e3))) * x ^ 2 + (1 / 64 * d1 * e3 + -(1 / 128 * d1 * e3)) * x + 1 / 64 * d1 * e4:=\nbegin\n  repeat {conv_lhs {rw sub_mul,}},\n  conv_lhs {rw mul_assoc,},\n  nth_rewrite 1 ← pow_one x,\n  conv_lhs {rw ← pow_add,},\n  conv_lhs {norm_num,},\n  conv_lhs {rw mul_add,},\n  conv_lhs {rw add_mul,},\n  conv_lhs {rw unfolding_polynomial_first_term x d7 d6 d5 d4 d3 d2 d1 d0,},\n  conv_lhs {rw unfolding_polynomial_second_term x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,},\n  conv_lhs {rw unfolding_polynomial_third_term x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,},\n  repeat {conv_lhs {rw ← add_assoc,}},\n  have h: (-1) * x ^ 11 + d7 * x ^ 10 + d6 * x ^ 9 + d5 * x ^ 8 + d4 * x ^ 7 + d3 * x ^ 6 + d2 * x ^ 5 + d1 * x ^ 4 + d0 * x ^ 3 + 3 / 4 * x ^ 11 + -(35 / 64 * d7 * x ^ 10) + 1 / 8 * (6 * e2 + -(3 * d6)) * x ^ 9 + 1 / 8 * (-(35 / 8 * d7 * e2) + 6 * e3 + -(15 / 8 * d5)) * x ^ 8 + 1 / 8 * (-(35 / 8 * d7 * e3) + -(3 * d6 * e2) + 6 * e4 + -d4) * x ^ 7 + 1 / 8 * (-(3 * d6 * e3) + -(35 / 8 * d7 * e4) + -(15 / 8 * d5 * e2) + -(3 / 8 * d3)) * x ^ 6 + 1 / 8 * (-(15 / 8 * d5 * e3) + -(3 * d6 * e4) + -(d4 * e2)) * x ^ 5 + 1 / 8 * (-(15 / 8 * d5 * e4) + -(d4 * e3) + -(3 / 8 * d3 * e2) + 1 / 8 * d1) * x ^ 4 + 1 / 8 * (-(d4 * e4) + -(3 / 8 * d3 * e3)) * x ^ 3 + 1 / 8 * (-(3 / 8 * d3 * e4) + 1 / 8 * d1 * e2) * x ^ 2 + 1 / 64 * d1 * e3 * x + 1 / 64 * d1 * e4 + 1 / 4 * x ^ 11 + -(7 / 32) * d7 * x ^ 10 + -(1 / 128) * ((-16) * e2 + 24 * d6) * x ^ 9 + -(1 / 128) * ((-8) * e3 + 20 * d5 + 7 * d7 * 2 * e2) * x ^ 8 + -(1 / 128) * (16 * d4 + 6 * d6 * 2 * e2 + 7 * d7 * e3) * x ^ 7 + -(1 / 128) * (12 * d3 + 5 * d5 * 2 * e2 + 6 * d6 * e3) * x ^ 6 + -(1 / 128) * (8 * d2 + 4 * d4 * 2 * e2 + 5 * d5 * e3) * x ^ 5 + -(1 / 128) * (4 * d1 + 3 * d3 * 2 * e2 + 4 * d4 * e3) * x ^ 4 + -(1 / 128) * (2 * d2 * 2 * e2 + 3 * d3 * e3) * x ^ 3 + -(1 / 128) * (d1 * 2 * e2 + 2 * d2 * e3) * x ^ 2 + -(1 / 128) * d1 * e3 * x                             =                       (d7 + -(35 / 64 * d7) + -(7 / 32) * d7) * x ^ 10 + (d6+ 1 / 8 * (6 * e2 + -(3 * d6))  + -(1 / 128) * ((-16) * e2 + 24 * d6)) * x ^ 9 + (d5  + 1 / 8 * (-(35 / 8 * d7 * e2) + 6 * e3 + -(15 / 8 * d5))  + -(1 / 128) * ((-8) * e3 + 20 * d5 + 7 * d7 * 2 * e2)) * x ^ 8+ (d4 + -(1 / 128) * (16 * d4 + 6 * d6 * 2 * e2 + 7 * d7 * e3)   + 1 / 8 * (-(35 / 8 * d7 * e3) + -(3 * d6 * e2) + 6 * e4 + -d4)) * x ^ 7 + (d3  + 1 / 8 * (-(3 * d6 * e3) + -(35 / 8 * d7 * e4) + -(15 / 8 * d5 * e2) + -(3 / 8 * d3)) + -(1 / 128) * (12 * d3 + 5 * d5 * 2 * e2 + 6 * d6 * e3)) * x ^ 6 + (d2  + 1 / 8 * (-(15 / 8 * d5 * e3) + -(3 * d6 * e4) + -(d4 * e2))  + -(1 / 128) * (8 * d2 + 4 * d4 * 2 * e2 + 5 * d5 * e3)) * x ^ 5 + (d1  + -(1 / 128) * (4 * d1 + 3 * d3 * 2 * e2 + 4 * d4 * e3)  + 1 / 8 * (-(15 / 8 * d5 * e4) + -(d4 * e3) + -(3 / 8 * d3 * e2) + 1 / 8 * d1)) * x ^ 4+ (d0 + 1 / 8 * (-(d4 * e4) + -(3 / 8 * d3 * e3)) + -(1 / 128) * (2 * d2 * 2 * e2 + 3 * d3 * e3)) * x ^ 3 + (1 / 8 * (-(3 / 8 * d3 * e4) + 1 / 8 * d1 * e2) + -(1 / 128) * (d1 * 2 * e2 + 2 * d2 * e3)) * x ^ 2 + (1 / 64 * d1 * e3 + -(1 / 128) * d1 * e3) * x + 1 / 64 * d1 * e4 ,   \n    ring_nf,\n  rw h,\n  norm_num,\nend\n\n\n\nlemma system_eleven_implies_polynomial_eq_zero (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ) (h: system_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7): \nsystem_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 → ((fun_b_gen x d7 d6 d5 d4 d3 d2 d1 d0)*x-(-1/8)*((deriv_fun_a_gen x d7 d6 d5 d4 d3 d1)*(fun_z_gen x e2 e3 e4)+(1/2)*(fun_a_gen x d7 d6 d5 d4 d3 d2 d1)*(deriv_fun_z_gen x e2 e3))) * x^2= 0:=\nbegin\n  intro h,\n  rw system_eleven_iff_system_eleven_neg at h,\n  cases h with h1 h2,\n  cases h2 with h2 h3,\n  cases h3 with h3 h4,\n  cases h4 with h4 h5,\n  cases h5 with h5 h6,\n  cases h6 with h6 h7,\n  cases h7 with h7 h8,\n  cases h8 with h8 h9,\n  cases h9 with h9 h10,\n  cases h10 with h10 h11,\n  rw unfolding_polynomial x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_1 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_2 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_3 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_4 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_5 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_6 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_7 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_8 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_9 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_10 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw eq_11 x d7 d6 d5 d4 d3 d2 d1 d0 e2 e3 e4,\n  rw [h11,h10,h9,h8,h7,h6,h5,h4,h3,h2,h1],\n  simp only [zero_mul, add_zero],\n  exact x,\nend\n\nlemma polynomial_eq_zero_implies_system_eleven (x:ℝ) (d7:ℝ) (d6:ℝ) (d5:ℝ) (d4:ℝ) (d3:ℝ) (d2:ℝ) (d1:ℝ) (d0:ℝ)\n(e2:ℝ) (e3:ℝ) (e4:ℝ) (h: system_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7): \n ((fun_b_gen x d7 d6 d5 d4 d3 d2 d1 d0)*x-(-1/8)*((deriv_fun_a_gen x d7 d6 d5 d4 d3 d1)*(fun_z_gen x e2 e3 e4)+(1/2)*(fun_a_gen x d7 d6 d5 d4 d3 d2 d1)*(deriv_fun_z_gen x e2 e3))) * x^2= 0 →system_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 :=\nbegin\n  sorry, --discussed this with Alain friday, unfortunately we could not make it work \nend\n\n/- # Unfortunately, we did not have the time to fully connect the part above and the part below except for the lemma system_eleven_implies_polynomial_eq_zero   -/\n\nlemma hd6 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : d_6 + 2 * e_2 = 0 ↔ d_6 = -(2 * e_2) :=\nbegin\n  rw add_eq_zero_iff_eq_neg,\nend\n\nlemma hd5 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : -(39 * d_5) + 42 * d_7 * e_2 - 52 * e_3 = 0 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔ d_5 = -52 / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin\n  simp,\n  intros hd6 hd7,\n  simp[hd7],\n  rw [sub_eq_zero, ← neg_mul, mul_comm, ← eq_div_iff],\n  ring_nf,\n  norm_num,\nend\n\nlemma hd4 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : -(96 * d_4) + 60 * d_6 * e_2 + 77 * d_7 * e_3 - 96 * e_4 = 0 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\nd_4 = -((5 * e_2^2) / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin\n  simp,\n  intros hd5 hd6 hd7,\n  simp[hd6, hd7],\n  ring_nf,\n  rw [add_eq_zero_iff_eq_neg, ← neg_mul, mul_comm, ← eq_div_iff],\n  ring_nf,\n  norm_num,\nend\n\nlemma hd3 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : -(55 * d_3) + 20 * d_5 * e_2 + 27 * d_6 * e_3 + 35 * d_7 * e_4 = 0 ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\nd_3 = -((22 * e_2 * e_3) / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin\n  simp,\n  intros hd4 hd5 hd6 hd7,\n  simp[hd5, hd6, hd7],\n  rw [add_assoc, add_eq_zero_iff_eq_neg, ← neg_mul, mul_comm, ← eq_div_iff],\n  ring_nf,\n  norm_num,\nend\n\nlemma hd2 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : -(120 * d_2) + 24 * d_4 * e_2 + 35 * d_5 * e_3 + 48 * d_6 * e_4 = 0 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\nd_2 = -e_2 ^ 3 / 4 - (7 * e_3 ^ 2) / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin\n  simp,\n  intros hd3 hd4 hd5 hd6 hd7,\n  simp[hd4, hd5, hd6],\n  rw [add_assoc, add_assoc, add_eq_zero_iff_eq_neg, ← neg_mul, mul_comm, ← eq_div_iff],\n  ring_nf,\n  norm_num,\nend\n\nlemma hd1 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : -(63 * d_1) + 6 * d_3 * e_2 + 10 * d_4 * e_3 + 15 * d_5 * e_4 = 0 ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\nd_1 = (-(1 / 210)) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin \n  simp,\n  intros hd2 hd3 hd4 hd5 hd6 hd7,\n  simp[hd3, hd4, hd5],\n  rw [add_assoc, add_assoc, add_eq_zero_iff_eq_neg, ← neg_mul, mul_comm, ← eq_div_iff],\n  ring_nf,\n  norm_num,\nend\n\nlemma hd0 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : -(128 * d_0) + 4 * d_2 * e_2 + 9 * d_3 * e_3 + 16 * d_4 * e_4 = 0 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\nd_0 = -(e_2 ^ 4 / 128) - (83 * e_2 * e_3 ^ 2) / 720 - (3 * e_2 ^ 2 * e_4) / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0:=\nbegin\n  simp,\n  intros hd1 hd2 hd3 hd4 hd5 hd6 hd7,\n  simp[hd2, hd3, hd4],\n  rw [add_assoc, add_assoc, add_eq_zero_iff_eq_neg, ← neg_mul, mul_comm, ← eq_div_iff],\n  ring_nf,\n  norm_num,\nend\n\nlemma hsys3 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : d_2 * e_3 + 3 * d_3 * e_4 = 0 ∧ d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\n(-(1 / 180)) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 ∧ d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin\n  simp only [one_div, neg_mul, neg_eq_zero, inv_eq_zero, bit0_eq_zero, and.congr_left_iff, and_imp],\n  intros hd0 hd1 hd2 hd3 hd4 hd5 hd6 hd7,\n  rw [hd2, hd3],\n  ring_nf,\n  rw sub_eq_zero,\n  rw add_eq_zero_iff_eq_neg,\n  rw ← neg_neg ((1 / 4 * e_3 * e_2 ^ 2 + 27 / 5 * e_4 * e_3) * e_2),\n  rw neg_inj,\n  ring_nf,\nend\n\nlemma hsys2 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero : e_3 ≠ 0) : d_1 = 0 ∧ -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 ∧ d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\n-(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 ∧ -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 ∧ d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin\n  simp only [one_div, neg_mul, neg_eq_zero, inv_eq_zero, bit0_eq_zero, and.congr_left_iff, and_imp],\n  intros hsys3 hd0 hd1 hd2 hd3 hd4 hd5 hd6 hd7,\n  rw[hd1],\n  simp,\nend\n\nlemma hsys1 (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero3 : e_3 ≠ 0) (hnotzero4 : e_4 ≠ 0) : (d_1 = 0 ∨ e_4 = 0) ∧ -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 ∧ -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 ∧ d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 ↔\n-(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 ∧ -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 ∧ -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 ∧ d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 ∧ d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) ∧ d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 ∧ d_3 = -(22 * e_2 * e_3 / 15) ∧ d_4 = -(5 * e_2 ^ 2 / 4) - e_4 ∧ d_5 = (-52) / 39 * e_3 ∧ d_6 = -(2 * e_2) ∧ d_7 = 0 :=\nbegin\n  simp only [one_div, neg_mul, neg_eq_zero, inv_eq_zero, bit0_eq_zero, and.congr_left_iff, and_imp],\n  intros hsys2 hsys3 hd0 hd1 hd2 hd3 hd4 hd5 hd6 hd7,\n  rw[hd1],\n  simp*,\nend\n\nlemma system_a_notzero (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero3 : e_3 ≠ 0) (h : system_a_2 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7) : e_4 ≠ 0 :=\nbegin\n  unfold system_a_2 at h,\n  cases h with h1 h,\n  cases h with h2 h,\n  by_contra,\n  simp[h] at h1 h2,\n  rw or_iff_right at h1,\n  simp[h1] at h2,\n  rw or_iff_right at h2,\n  exact hnotzero3 h2,\n  repeat {norm_num},\nend\n\nlemma system_a_iff_system_eleven (e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 : ℝ) (hnotzero3 : e_3 ≠ 0) (hnotzero4 : e_4 ≠ 0) : system_eleven e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 ↔ system_a_2 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 :=\nbegin\n  unfold system_a_2,\n  unfold system_eleven,\n  simp[hnotzero3],\n  norm_num,\n  rw hd6 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hd5 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hd4 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hd3 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hd2 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hd1 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hd0 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hsys3 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hsys2 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3,\n  rw hsys1 e_2 e_3 e_4 d_0 d_1 d_2 d_3 d_4 d_5 d_6 d_7 hnotzero3 hnotzero4,\n  simp*,\n  norm_num,\n  ring_nf,\nend\n\nend real", "meta": {"author": "rtertr", "repo": "Lean-CAP", "sha": "d1ac0ed855947f93c9cd14d9858ffe9979b26d18", "save_path": "github-repos/lean/rtertr-Lean-CAP", "path": "github-repos/lean/rtertr-Lean-CAP/Lean-CAP-d1ac0ed855947f93c9cd14d9858ffe9979b26d18/General_form.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.46398844081146745}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport algebra.category.Module.kernels\nimport algebra.category.Module.limits\nimport category_theory.abelian.exact\n\n/-!\n# The category of left R-modules is abelian.\n\nAdditionally, two linear maps are exact in the categorical sense iff `range f = ker g`.\n-/\n\nopen category_theory\nopen category_theory.limits\n\nnoncomputable theory\n\nuniverses v u\n\nnamespace Module\nvariables {R : Type u} [ring R] {M N : Module.{v} R} (f : M ⟶ N)\n\n/-- In the category of modules, every monomorphism is normal. -/\ndef normal_mono (hf : mono f) : normal_mono f :=\n{ Z := of R f.range.quotient,\n  g := f.range.mkq,\n  w := linear_map.range_mkq_comp _,\n  is_limit :=\n    is_kernel.iso_kernel _ _ (kernel_is_limit _)\n      /- The following [invalid Lean code](https://github.com/leanprover-community/lean/issues/341)\n        might help you understand what's going on here:\n        ```\n        calc\n        M   ≃ₗ[R] f.ker.quotient  : (submodule.quot_equiv_of_eq_bot _ (ker_eq_bot_of_mono _)).symm\n        ... ≃ₗ[R] f.range         : linear_map.quot_ker_equiv_range f\n        ... ≃ₗ[R] r.range.mkq.ker : linear_equiv.of_eq _ _ (submodule.ker_mkq _).symm\n        ```\n      -/\n      (linear_equiv.to_Module_iso'\n        (linear_equiv.trans (submodule.quot_equiv_of_eq_bot _ (ker_eq_bot_of_mono _)).symm\n          (linear_equiv.trans (linear_map.quot_ker_equiv_range f)\n            (linear_equiv.of_eq _ _ (submodule.ker_mkq _).symm)))) $\n      by { ext, refl } }\n\n/-- In the category of modules, every epimorphism is normal. -/\ndef normal_epi (hf : epi f) : normal_epi f :=\n{ W := of R f.ker,\n  g := f.ker.subtype,\n  w := linear_map.comp_ker_subtype _,\n  is_colimit :=\n    is_cokernel.cokernel_iso _ _ (cokernel_is_colimit _)\n      (linear_equiv.to_Module_iso'\n      /- The following invalid Lean code might help you understand what's going on here:\n        ```\n        calc f.ker.subtype.range.quotient\n            ≃ₗ[R] f.ker.quotient : submodule.quot_equiv_of_eq _ _ (submodule.range_subtype _)\n        ... ≃ₗ[R] f.range        : linear_map.quot_ker_equiv_range f\n        ... ≃ₗ[R] N              : linear_equiv.of_top _ (range_eq_top_of_epi _)\n        ```\n      -/\n        (linear_equiv.trans\n          (linear_equiv.trans (submodule.quot_equiv_of_eq _ _ (submodule.range_subtype _))\n            (linear_map.quot_ker_equiv_range f)) (linear_equiv.of_top _ (range_eq_top_of_epi _)))) $\n      by { ext, refl } }\n\n/-- The category of R-modules is abelian. -/\ninstance : abelian (Module R) :=\n{ has_finite_products := ⟨by apply_instance⟩,\n  has_kernels := by apply_instance,\n  has_cokernels := has_cokernels_Module,\n  normal_mono := λ X Y, normal_mono,\n  normal_epi := λ X Y, normal_epi }\n\nvariables {O : Module.{v} R} (g : N ⟶ O)\n\nopen linear_map\nlocal attribute [instance] preadditive.has_equalizers_of_has_kernels\n\ntheorem exact_iff : exact f g ↔ f.range = g.ker :=\nbegin\n  rw abelian.exact_iff' f g (kernel_is_limit _) (cokernel_is_colimit _),\n  exact ⟨λ h, le_antisymm (range_le_ker_iff.2 h.1) (ker_le_range_iff.2 h.2),\n    λ h, ⟨range_le_ker_iff.1 $ le_of_eq h, ker_le_range_iff.1 $ le_of_eq h.symm⟩⟩\nend\n\nend Module\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/category/Module/abelian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4639409638773473}}
{"text": "def g (xs ys : List Nat) : Nat :=\n  match xs, ys with\n  | [a, b], _ => Nat.succ (a+b)\n  | _, [b, c] => Nat.succ b\n  | _, _   => 1\n\nexample (a b : Bool) (x y z : Nat) (xs : List Nat) (h1 : (if a then x else y) = 0) (h2 : xs.head! = 0) : g [x] xs = 1 := by\n  simp [g]\n  repeat any_goals (split at *)\n  any_goals (first | decide | contradiction | injections)\n  next b c _ _ _ =>\n    show Nat.succ b = 1\n    subst xs; simp [List.head!] at h2; simp [h2]\n  next b c _ _ _ =>\n    show Nat.succ b = 1\n    subst xs; simp [List.head!] at h2; simp [h2]\n\nexample (a : Bool) (h1 : (if a then x else y) = 1) : x + y > 0 := by\n  split at h1\n  . subst h1; rw [Nat.succ_add]; apply Nat.zero_lt_succ\n  . subst h1; apply Nat.zero_lt_succ\n\ndef f (x : Nat) : Nat :=\n  match x with\n  | 100 => 0\n  | 200 => 0\n  | _   => 1\n\nexample (h1 : f x = 0) (h2 : x > 300) : False := by\n  simp [f] at h1\n  split at h1\n  . contradiction\n  . contradiction\n  . contradiction\n\nexample (h1 : f x = 0) (h2 : x > 300) : False := by\n  simp [f] at h1\n  split at h1 <;> contradiction\n", "meta": {"author": "subfish-zhou", "repo": "leanprover-zh_CN.github.io", "sha": "8b2985d4a3d458ceda9361ac454c28168d920d3f", "save_path": "github-repos/lean/subfish-zhou-leanprover-zh_CN.github.io", "path": "github-repos/lean/subfish-zhou-leanprover-zh_CN.github.io/leanprover-zh_CN.github.io-8b2985d4a3d458ceda9361ac454c28168d920d3f/tests/lean/run/split3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4639159076163431}}
{"text": "example (P Q : Prop) : P → (Q → P) :=\nbegin\n    intro p,\n    intro q,\n    exact p,\nend\n", "meta": {"author": "nomoid", "repo": "lean-proofs", "sha": "b9f03a24623d1a1d111d6c2bbf53c617e2596d6a", "save_path": "github-repos/lean/nomoid-lean-proofs", "path": "github-repos/lean/nomoid-lean-proofs/lean-proofs-b9f03a24623d1a1d111d6c2bbf53c617e2596d6a/src/world6/level5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321720225279, "lm_q2_score": 0.6513548714339144, "lm_q1q2_score": 0.4639158948388312}}
{"text": "import for_mathlib.coproduct group_theory.semidirect_product\n\nnoncomputable theory\n\nuniverse u\n\nvariables {ι : Type} [decidable_eq ι] (r : free_group ι) (T : set ι) [decidable_pred T]\n\nopen free_group\n\ndef phi : closure_var T →* mul_aut (free_group (free_group ι)) :=\n{ to_fun := λ g : closure_var T, free_group.equiv (mul_left (g : free_group ι)),\n  map_one' := by simp [equiv.perm.one_def]; refl,\n  map_mul' := λ x y, by simp [equiv.perm.mul_def]; refl }\n\ndef phi' : free_group ι →* mul_aut (free_group (free_group ι)) :=\n{ to_fun := λ w, free_group.equiv (mul_left w),\n  map_one' := by simp [equiv.perm.one_def, mul_aut.one_def],\n  map_mul' := by simp [equiv.perm.mul_def, mul_aut.mul_def] }\n\nlemma phi'_of' (n : C∞) (w w' : free_group ι) :\n  phi' w (of' w' n) = of' (w * w') n := by simp [phi']\n\ninclude r\n\ndef unnormalize : free_group (free_group ι) ⋊[phi T] closure_var T →* free_group ι :=\nsemidirect_product.lift\n  (free_group.lift' (λ g : free_group ι,\n    (mul_aut.conj g : free_group ι ≃* free_group ι).to_monoid_hom.comp\n      (gpowers_hom (free_group ι) r)))\n  (subgroup.subtype (closure_var T))\n  (λ g, hom_ext (λ i, by simp [_root_.phi, of_eq_of']))\n\nopen semidirect_product\n\ndef unnormalize' : free_group (free_group ι) ⋊[phi'] free_group ι →* free_group ι :=\nsemidirect_product.lift\n  (free_group.lift' (λ g : free_group ι,\n    (mul_aut.conj g : free_group ι ≃* free_group ι).to_monoid_hom.comp\n      (gpowers_hom (free_group ι) r)))\n  (monoid_hom.id _)\n  (λ g, hom_ext (λ i, by simp [_root_.phi', of_eq_of']))\n\n@[simp] lemma unnormalize'_inr (w : free_group ι) : unnormalize' r (inr w) = w :=\nsemidirect_product.lift_inr _ _ _ _\n\nlemma unnormalize'_inl (w : free_group (free_group ι)) :\n  unnormalize' r (inl w) = free_group.lift' (λ g : free_group ι,\n    (mul_aut.conj g : free_group ι ≃* free_group ι).to_monoid_hom.comp\n      (gpowers_hom (free_group ι) r)) w :=\nsemidirect_product.lift_inl _ _ _ _\n\nomit r\n\ndef remove_subscript (t : ι) : free_group (ι × C∞) →* free_group ι :=\nfree_group.lift' (λ g, (mul_aut.conj (of' t g.2)).to_monoid_hom.comp (of' g.1))\n\ndef mul_subscript (n : C∞) : free_group (ι × C∞) ≃* free_group (ι × C∞) :=\nfree_group.equiv (equiv.prod_congr (equiv.refl _) (mul_left n))\n\n@[simp] lemma remove_subscript_comp_mul_subscript (t : ι) (n : C∞) :\n  (remove_subscript t).comp (mul_subscript n).to_monoid_hom =\n  (mul_aut.conj (of' t n)).to_monoid_hom.comp (remove_subscript t) :=\nfree_group.hom_ext (by simp [remove_subscript, mul_subscript, of_eq_of'])\n\n@[simp] lemma remove_subscript_mul_subscript (t : ι) (n : C∞) (x) : remove_subscript t\n  (mul_subscript n x) =  of' t n * remove_subscript t x * of' t n⁻¹ :=\nby simpa [-remove_subscript_comp_mul_subscript] using monoid_hom.ext_iff.1\n  (remove_subscript_comp_mul_subscript t n) x\n\n@[simp] lemma remove_subscript_of' (t : ι) (l : ι × C∞) (n : C∞) : remove_subscript t (of' l n) =\n  (mul_aut.conj (of' t l.2)).to_monoid_hom.comp (of' l.1) n :=\nfree_group.lift'_of' _ _ _\n\nlemma remove_subscript_SD (t : ι) :\n  free_group (free_group (ι × C∞)) ⋊[phi'] free_group (ι × C∞) →*\n  free_group (free_group ι) ⋊[phi'] free_group ι :=\nsemidirect_product.lift (inl.comp\n  (free_group.lift' (λ g, of' (remove_subscript t g))))\n  (inr.comp (remove_subscript t))\n  begin\n    intro g,\n    apply free_group.hom_ext,\n    assume i,\n    simp only [of_eq_of', lift'_of', monoid_hom.comp_apply, mul_equiv.to_monoid_hom_apply, phi'_of'],\n    apply semidirect_product.ext;\n    simp [phi']\n  end\n\ninclude r\n\n/-- Not the correct definition -/\nstructure solver (T : set ι): Type :=\n(to_fun : free_group ι → option (free_group (free_group ι) ⋊[phi'] free_group ι))\n(inv : ∀ (x : free_group ι), x ∈ (set.univ : set (free_group ι)) →\n  ∃ (y : free_group (free_group ι) ⋊[phi'] free_group ι), y ∈ to_fun x → unnormalize' r y = x)\n\ninstance : has_coe_to_fun (solver r T) :=\n{ F := λ _, free_group ι → option (free_group (free_group ι) ⋊[phi'] free_group ι),\n  coe := solver.to_fun }\n\nlemma unnormalize_eq_of_mem {n : solver r T}\n  {x : free_group ι} {y : free_group (free_group ι) ⋊[phi'] free_group ι}\n  (h : y ∈ n x) : unnormalize' r y = x := sorry\n\nlemma unnormalize_inl_eq_of_mem {n : solver r T}\n  {x : free_group ι} {y : free_group (free_group ι) ⋊[phi'] free_group ι}\n  (h : y ∈ n x) : unnormalize' r (inl y.left) = x * y.right⁻¹ :=\nby rw [eq_mul_inv_iff_mul_eq, ← unnormalize'_inr r y.right, ← monoid_hom.map_mul,\n    inl_left_mul_inr_right, unnormalize_eq_of_mem r T h]\n\nvariable {ι}\n\nomit r\n\nnoncomputable def normalize_cons\n  (t : ι) (r' : free_group (ι × C∞))\n  {A B : set (ι × C∞)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) :\n  Π (old1 : free_group (ι × C∞))\n  (old2 : free_group (free_group (ι × C∞)) ⋊[phi'] free_group (ι × C∞)),\n  free_group (free_group (ι × C∞)) ⋊[phi'] free_group (ι × C∞)\n| old1 ⟨w, ⟨[], _⟩⟩     := ⟨phi' old1 w, old1⟩\n| old1 ⟨w, ⟨i :: l, _⟩⟩ :=\n  if i.1.1 = t\n  then if i.2 ≤ 1\n    then option.elim (hA old1)\n      (normalize_cons ⟨old1.1 ++ [i], sorry⟩ ⟨(phi' (of' i.1 i.2))⁻¹ w, ⟨l, sorry⟩⟩)\n      (λ a, inr (of (t, 1))⁻¹ *\n        normalize_cons (mul_subscript ii (right_hom a))\n          ⟨phi' (of (t, 1)) (phi' a.right⁻¹ a.left * w), of' i.1 (ii * i.2) * ⟨l, sorry⟩⟩)\n    else option.elim (hB old1)\n      (normalize_cons ⟨old1.1 ++ [i], sorry⟩ ⟨(phi' (of' i.1 i.2))⁻¹ w, ⟨l, sorry⟩⟩)\n      (λ a, inr (of (t, 1)) *\n        normalize_cons (mul_subscript (ii⁻¹) (right_hom a))\n          ⟨phi' (of (t, 1))⁻¹  (phi' a.right⁻¹ a.left * w), of' i.1 (ii⁻¹ * i.2) *⟨l, sorry⟩⟩)\n  else normalize_cons ⟨old1.1 ++ [i], sorry⟩ ⟨(phi' (of' i.1 i.2))⁻¹ w, ⟨l, sorry⟩⟩\nusing_well_founded { rel_tac := λ _ _, `[exact ⟨λ _ _, true, sorry⟩], dec_tac := `[trivial] }\n\n@[simp] lemma remove_subscript_unnormalize_normalize_cons\n  (t : ι) (r' : free_group (ι × C∞))\n  {A B : set (ι × C∞)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A)\n  (hB : solver r' B) :\n  Π (old1 : free_group (ι × C∞))\n  (old2 : free_group (free_group (ι × C∞)) ⋊[phi'] free_group (ι × C∞)),\n  remove_subscript t (unnormalize' r' (normalize_cons t r' hA hB old1 old2)) =\n    remove_subscript t (old1 * unnormalize' r' old2)\n| old1 ⟨w, ⟨[], _⟩⟩     := by rw normalize_cons; simp [inl_aut]\n| old1 ⟨w, ⟨i :: l, _⟩⟩ := begin\n  rw normalize_cons,\n  split_ifs,\n  { cases h1 : hA old1,\n    { simp [remove_subscript_unnormalize_normalize_cons, inl_aut_inv, mul_assoc] },\n    { have : i.1.2 = ii, from sorry,\n      simp [remove_subscript_unnormalize_normalize_cons, mul_assoc, inl_aut_inv,\n        unnormalize_inl_eq_of_mem _ _ h1, of_eq_of', inl_aut, this, h,\n        unnormalize_eq_of_mem _ _ h1] } },\n  { cases h2 : hB old1,\n    { simp [remove_subscript_unnormalize_normalize_cons, inl_aut_inv, mul_assoc] },\n    { have : i.1.2 = ii, from sorry,\n      simp [remove_subscript_unnormalize_normalize_cons, mul_assoc, inl_aut_inv,\n        unnormalize_inl_eq_of_mem _ _ h2, of_eq_of', inl_aut, this, h,\n        unnormalize_eq_of_mem _ _ h2] } },\n  { simp [remove_subscript_unnormalize_normalize_cons, inl_aut_inv, mul_assoc] }\nend\nusing_well_founded { rel_tac := λ _ _, `[exact ⟨λ _ _, true, sorry⟩], dec_tac := `[trivial] }\n\nnoncomputable def normalize_with_subscript_aux\n  (t : ι) (r' : free_group (ι × C∞))\n  {A B : set (ι × C∞)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) :\n  Π (w : list (Σ i : ι, C∞)) (hw : reduced w),\n  free_group (free_group (ι × C∞)) ⋊[phi'] free_group (ι × C∞)\n| []       _ := 1\n| (i :: l) _ := normalize_cons t r' hA hB (of' (i.1, 1) i.2)\n  (normalize_with_subscript_aux l sorry)\n\nnoncomputable def normalize_with_subscript\n  (t : ι) (r' : free_group (ι × C∞))\n  {A B : set (ι × C∞)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B)\n  (w : free_group ι) :\n  free_group (free_group (ι × C∞)) ⋊[phi'] free_group (ι × C∞) :=\nnormalize_with_subscript_aux t r' hA hB w.1 w.2\n\nlemma remove_subscript_unnormalize_normalize_with_subscript_aux\n  (t : ι) (r' : free_group (ι × C∞))\n  {A B : set (ι × C∞)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) :\n  Π (w : list (Σ i : ι, C∞)) (hw : reduced w),\n  remove_subscript t (unnormalize' r' (normalize_with_subscript_aux t r' hA hB w hw)) = ⟨w, hw⟩\n| []       _ := by simp [normalize_with_subscript_aux]\n| (i :: l) _ := begin\n  rw [normalize_with_subscript_aux, remove_subscript_unnormalize_normalize_cons,\n    monoid_hom.map_mul, remove_subscript_unnormalize_normalize_with_subscript_aux],\n  simp\nend\n\n@[simp] lemma remove_subscript_unnormalize_normalize_with_subscript\n  (t : ι) (r' : free_group (ι × C∞)) {A B : set (ι × C∞)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) (w : free_group ι) :\n  remove_subscript t (unnormalize' r' (normalize_with_subscript t r' hA hB w)) = w :=\nby cases w; apply remove_subscript_unnormalize_normalize_with_subscript_aux\n\ndef Icc_prod (x : ι) (a b : C∞) : set (ι × C∞) :=\n{ p | p.1 = x → a ≤ p.2 ∧ p.2 ≤ b }\n\ninstance (x : ι) (a b : C∞) : decidable_pred (Icc_prod x a b) :=\nby dunfold Icc_prod; apply_instance\n\n/- need to cyclically reduce r' -/\ndef normalize (t x : ι) (r' : free_group (ι × C∞))\n  (hx : x ∉ T) (ht : exp_sum t r = 1) (a b : C∞)\n  (ha : a ∈ finset.min ((vars r').image prod.snd))\n  (hb : b ∈ finset.max ((vars r').image prod.snd))\n  (hr' : r' = ((free_group.to_SD t) r).left)\n  (hr'₁ : solver r' (Icc_prod x a (b * ii⁻¹)))\n  (hr'₂ : solver r' (Icc_prod x (a * ii) b)) (w : free_group ι) :\n  option (free_group (free_group ι) ⋊[phi'] free_group ι) :=\nlet w' := remove_subscript_SD t (normalize_with_subscript t r' hr'₁ hr'₂ w) in\nif w'.right ∈ closure_var T then some w' else none\n\n", "meta": {"author": "ChrisHughes24", "repo": "single_relation", "sha": "556990dab75054a1c14717a72c8901dc9f2f01e4", "save_path": "github-repos/lean/ChrisHughes24-single_relation", "path": "github-repos/lean/ChrisHughes24-single_relation/single_relation-556990dab75054a1c14717a72c8901dc9f2f01e4/scratch/inductive_step.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4638579103126612}}
{"text": "import for_mathlib.derived.les2\nimport for_mathlib.unop\n\nnoncomputable theory\n\nuniverses v u\n\nopen category_theory category_theory.limits\n\nvariables {A : Type u} [category.{v} A] [abelian A]\n\nlocal notation `𝒦` := homotopy_category A (complex_shape.up ℤ)\n\nnamespace bounded_homotopy_category\nvariables {X Y Z : cochain_complex A ℤ} (f : X ⟶ Y) (g : Y ⟶ Z)\n\n\nsection\nopen homotopy_category\n\n-- move me\n@[reassoc]\nlemma Ext_map_Ext_iso [enough_projectives A]\n  (i : ℤ) (P₁ P₂ X₁ X₂ Y : bounded_homotopy_category A)\n  [is_K_projective P₁.val] [is_K_projective P₂.val]\n  (f₁ : P₁ ⟶ X₁) [is_quasi_iso f₁] (f₂ : P₂ ⟶ X₂) [is_quasi_iso f₂]\n  (φ : X₁ ⟶ X₂) (φ' : P₁ ⟶ P₂) (h : φ' ≫ f₂ = f₁ ≫ φ) :\n  ((Ext i).flip.obj Y).map φ.op ≫ (Ext_iso i P₁ X₁ Y f₁).hom =\n    (Ext_iso i P₂ X₂ Y f₂).hom ≫ (preadditive_yoneda.obj (Y⟦i⟧)).map φ'.op :=\nbegin\n  dsimp only [Ext_iso, functor.map_iso_hom, iso.op_hom, Ext, Ext0,\n    functor.flip_obj_map, functor.comp_map, whiskering_left_obj_map, whisker_left_app,\n    functor.flip_map_app],\n  rw [← category_theory.functor.map_comp, ← op_comp,\n      ← category_theory.functor.map_comp, ← op_comp],\n  congr' 2,\n  dsimp only [replacement_iso_hom, opposite.unop_op],\n  refine lift_ext X₂.π _ _ _,\n  simp only [category.assoc, lift_lifts, lift_lifts_assoc, quiver.hom.unop_op, h],\nend\n\n-- move me\n@[reassoc]\nlemma Ext_map_Ext_iso' [enough_projectives A]\n  (i : ℤ) (X₁ X₂ Y : bounded_homotopy_category A) (φ : X₁ ⟶ X₂) :\n  ((Ext i).flip.obj Y).map φ.op ≫ (Ext_iso i _ X₁ Y X₁.π).hom =\n    (Ext_iso i _ X₂ Y X₂.π).hom ≫ (preadditive_yoneda.obj (Y⟦i⟧)).map (lift (X₁.π ≫ φ) X₂.π).op :=\nExt_map_Ext_iso _ _ _ _ _ _ _ _ _ _ $ by rw [lift_lifts]\n\nlemma Ext_iso_naturality_snd_component\n  [enough_projectives A]\n  (i : ℤ) (P X Y₁ Y₂ : bounded_homotopy_category A)\n  [is_K_projective P.val]\n  (f : P ⟶ X) [is_quasi_iso f] (g : Y₁ ⟶ Y₂) :\n  ((Ext i).obj _).map g ≫ (Ext_iso i P X _ f).hom =\n  (Ext_iso i P X _ f).hom ≫ (preadditive_yoneda.flip.obj (opposite.op P)).map (g⟦i⟧') :=\nbegin\n  dsimp only [Ext_iso, Ext, Ext0], ext t,\n  dsimp, simp only [comp_apply], dsimp, simp,\nend\n\nend\n\ndef shift_iso [enough_projectives A]\n  (n : ℤ) (X : cochain_complex A ℤ) (Y : bounded_homotopy_category A)\n  [((homotopy_category.quotient A (complex_shape.up ℤ)).obj X).is_bounded_above] :\n  (((Ext (n+1)).flip.obj Y)).obj (opposite.op $ (of' X)⟦(1:ℤ)⟧) ≅\n  (((Ext n).flip.obj Y)).obj (opposite.op $ (of' X)) :=\nbegin\n  let e := Ext_iso n (of' X).replace (of' X) Y (of' X).π,\n  let e' := Ext_iso (n+1) ((of' X).replace⟦1⟧) ((of' X)⟦1⟧) Y ((of' X).π⟦(1:ℤ)⟧'),\n  refine (e' ≪≫ _ ≪≫ e.symm),\n  clear e e',\n  refine add_equiv.to_AddCommGroup_iso _,\n  refine shift_iso_aux 1 n _ _,\nend\n\nopen category_theory.preadditive\n\nlemma shift_iso_conj\n  (n : ℤ)\n  [enough_projectives A]\n  (W : bounded_homotopy_category A)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y)] :\n  (shift_iso _ _ _).inv ≫ (((Ext (n+1)).flip.obj W).right_op.map ((of_hom f)⟦(1 : ℤ)⟧')).unop\n    ≫ (shift_iso _ _ _).hom =\n  ((Ext n).flip.obj W).map (of_hom f).op :=\nbegin\n  dsimp only [shift_iso, iso.trans_hom, iso.trans_inv, iso.symm_inv, iso.symm_hom,\n    functor.right_op_map, quiver.hom.unop_op],\n  simp only [category.assoc],\n  rw [Ext_map_Ext_iso_assoc (n+1)\n    ((shift_functor (bounded_homotopy_category A) (1:ℤ)).obj (of' X).replace)\n    ((shift_functor (bounded_homotopy_category A) (1:ℤ)).obj (of' Y).replace)\n    _ _ _\n    ((shift_functor (bounded_homotopy_category A) 1).map (of' X).π)\n    ((shift_functor (bounded_homotopy_category A) 1).map (of' Y).π)\n    _ ((lift ((of' X).π ≫ of_hom f) (of' Y).π)⟦1⟧'),\n    iso.inv_hom_id_assoc],\n  swap,\n  { simp only [comp_neg, neg_comp, neg_inj, ← category_theory.functor.map_comp, lift_lifts], },\n  simp only [← category.assoc, iso.comp_inv_eq],\n  rw [Ext_map_Ext_iso', category.assoc, category.assoc], congr' 1,\n  rw [← category.assoc, ← iso.eq_comp_inv],\n  apply AddCommGroup.ext, intros φ,\n  dsimp only [shift_iso_aux, add_equiv.to_AddCommGroup_iso],\n  rw [comp_apply, comp_apply],\n  dsimp only [add_equiv.coe_to_add_monoid_hom, add_equiv.symm, equiv.symm, add_equiv.to_equiv_mk,\n    add_equiv.coe_mk],\n  erw [preadditive_yoneda_obj_map_apply, preadditive_yoneda_obj_map_apply],\n  simp only [← category.assoc, quiver.hom.unop_op, ← category_theory.functor.map_comp],\nend\n\n--attribute [simps] shift_iso_aux\nlemma shift_iso_conj'\n  (n : ℤ)\n  [enough_projectives A]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  (W₁ W₂ : bounded_homotopy_category A) (f : W₁ ⟶ W₂) :\n  (shift_iso n X W₁).inv ≫ ((Ext (n+1)).obj _).map f ≫ (shift_iso n X _).hom =\n  ((Ext n).obj _).map f :=\nbegin\n  dsimp only [shift_iso, iso.trans_hom, iso.trans_inv, iso.symm_hom, iso.symm_inv],\n  simp only [category.assoc],\n  slice_lhs 4 5 { rw Ext_iso_naturality_snd_component },\n  simp only [category.assoc, iso.inv_hom_id_assoc, category.id_comp],\n  rw ← iso.eq_inv_comp,\n  simp_rw ← category.assoc,\n  rw iso.comp_inv_eq,\n  simp_rw category.assoc,\n  rw Ext_iso_naturality_snd_component,\n  rw iso.inv_hom_id_assoc,\n  ext t,\n  dsimp,\n  simp only [comp_apply],\n  dsimp,\n  simp only [add_zero, unit_of_tensor_iso_unit_inv_app, opaque_eq_to_iso_inv,\n    discrete.functor_map_id, nat_trans.id_app, category.id_comp, category.assoc,\n    nat_trans.naturality, functor.comp_map, μ_hom_inv_app_assoc, functor.map_comp,\n    ε_inv_app_obj, discrete.right_unitor_def, eq_to_iso.hom, eq_to_hom_map,\n    eq_to_hom_app, μ_naturality_assoc, μ_inv_hom_app_assoc],\n  erw ← nat_trans.naturality_assoc,\n  erw ← nat_trans.naturality_assoc,\n  dsimp, let s := _, change _ ≫ _ ≫ s = _, rw ← category.assoc, convert category.comp_id _,\n  dsimp [s], simp,\nend\n\n@[reassoc] lemma shift_iso_Ext_map\n  (n : ℤ)\n  [enough_projectives A]\n  (W : bounded_homotopy_category A)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y)] :\n  (((Ext (n+1)).flip.obj W).right_op.map ((of_hom f)⟦(1 : ℤ)⟧')).unop ≫ (shift_iso _ _ _).hom =\n  (shift_iso _ _ _).hom ≫ ((Ext n).flip.obj W).map (of_hom f).op :=\nby rw [← iso.inv_comp_eq, shift_iso_conj]\n\n@[reassoc] lemma Ext_map_shift_iso_inv\n  (n : ℤ)\n  [enough_projectives A]\n  (W : bounded_homotopy_category A)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y)] :\n  (shift_iso _ _ _).inv ≫ (((Ext (n+1)).flip.obj W).right_op.map ((of_hom f)⟦(1 : ℤ)⟧')).unop =\n  ((Ext n).flip.obj W).map (of_hom f).op ≫ (shift_iso _ _ _).inv :=\nby rw [iso.eq_comp_inv, category.assoc, shift_iso_conj]\n\ndef Ext_δ\n  (n : ℤ)\n  [enough_projectives A]\n  (W : bounded_homotopy_category A)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Z)]\n  (w : ∀ i, short_exact (f.f i) (g.f i)) :\n  ((Ext n).flip.obj W).obj (opposite.op $ of' X) ⟶\n  ((Ext (n+1)).flip.obj W).obj (opposite.op $ of' Z) :=\n(shift_iso n X W).inv ≫ (connecting_hom' f g (n+1) W w).unop\n\n.\n\ndef map_cone {A₁ A₂ B₁ B₂ : cochain_complex A ℤ}\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj A₁)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj B₁)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj A₂)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj B₂)]\n  (f₁ : A₁ ⟶ B₁) (f₂ : A₂ ⟶ B₂) (a : A₁ ⟶ A₂) (b : B₁ ⟶ B₂) (sq : f₁ ≫ b = a ≫ f₂) :\n  cone f₁ ⟶ cone f₂ :=\n(homotopy_category.quotient _ _).map $\n{ f := λ i, biprod.lift (biprod.fst ≫ a.f _) (biprod.snd ≫ b.f _),\n  comm' := begin\n    rintros i j ⟨⟨rfl⟩⟩,\n    ext,\n    { dsimp [homological_complex.cone.d], simp },\n    { dsimp [homological_complex.cone.d], simp,\n      simp only [← homological_complex.comp_f, sq] },\n    { dsimp [homological_complex.cone.d], simp },\n    { dsimp [homological_complex.cone.d], simp },\n  end }\n\n.\n\nlemma Ext_δ_natural\n  (i : ℤ)\n  [enough_projectives A]\n  (W : bounded_homotopy_category A)\n  {X₁ Y₁ Z₁ : cochain_complex A ℤ} (f₁ : X₁ ⟶ Y₁) (f₂ : Y₁ ⟶ Z₁)\n  {X₂ Y₂ Z₂ : cochain_complex A ℤ} (g₁ : X₂ ⟶ Y₂) (g₂ : Y₂ ⟶ Z₂)\n  (α₁ : X₁ ⟶ X₂) (α₂ : Y₁ ⟶ Y₂) (α₃ : Z₁ ⟶ Z₂)\n  (sq₁ : f₁ ≫ α₂ = α₁ ≫ g₁) (sq₂ : f₂ ≫ α₃ = α₂ ≫ g₂)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X₁)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y₁)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Z₁)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X₂)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y₂)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Z₂)]\n  (w₁ : ∀ i, short_exact (f₁.f i) (f₂.f i))\n  (w₂ : ∀ i, short_exact (g₁.f i) (g₂.f i)) :\n  ((Ext i).flip.obj W).map (of_hom α₁).op ≫ Ext_δ f₁ f₂ i W w₁ =\n    Ext_δ g₁ g₂ i W w₂ ≫ ((Ext (i + 1)).flip.obj W).map (of_hom α₃).op :=\nbegin\n  -- TODO: This proof is SLOW.\n  delta Ext_δ,\n  let F := homotopy_category.quotient A (complex_shape.up ℤ),\n  simp only [category.assoc],\n  dsimp only [connecting_hom', unop_comp],\n  simp only [unop_inv, category.assoc],\n  simp only [← category.assoc, is_iso.comp_inv_eq],\n  simp only [category.assoc],\n  dsimp only [functor.right_op, quiver.hom.unop_op, functor.flip, opposite.unop_op],\n  let t := _, change _ = _ ≫ _ ≫ t,\n  have ht : t = ((Ext (i+1)).map (quiver.hom.op _)).app W,\n  rotate 2,\n  { apply map_cone,\n    exact sq₁ },\n  { -- Move the inv, and this should be doable.\n    dsimp [t], rw is_iso.inv_comp_eq,\n    ext f,\n    dsimp [Ext, shift_iso, Ext_iso, preadditive_yoneda_obj, linear_map.to_add_monoid_hom],\n    simp only [comp_apply], dsimp,\n    simp only [← category.assoc],\n    congr' 1,\n    apply lift_ext (of' Z₂).π, swap, apply_instance,\n    simp only [category.assoc, lift_lifts, lift_lifts_assoc],\n    congr' 1, dsimp [map_cone, cone.π, homotopy_category.cone.π],\n    erw [← F.map_comp, ← F.map_comp], congr' 1,\n    dsimp [homological_complex.cone.π],\n    ext,\n    { simp },\n    { simp,\n      simp only [← homological_complex.comp_f, sq₂] } },\n  rw ht, clear ht, clear t,\n  ext f,\n  dsimp [Ext, shift_iso, Ext_iso, preadditive_yoneda_obj, linear_map.to_add_monoid_hom],\n  dsimp only [shift_iso_aux, add_equiv.symm],\n  simp only [comp_apply],\n  dsimp,\n  simp only [← category.assoc], congr' 1,\n  simp only [functor.map_comp, ← category.assoc], congr' 1,\n  simp only [category.assoc],\n  apply lift_ext (((of' X₂).π)⟦(1 : ℤ)⟧'),\n  swap, apply_instance,\n  simp only [category.assoc, ← functor.map_comp, lift_lifts],\n  simp only [functor.map_comp, lift_lifts_assoc, lift_lifts, category.assoc],\n  congr' 1,\n  dsimp [cone_triangle, map_cone],\n  simp only [comp_neg, neg_comp], congr' 1,\n  erw [← F.map_comp, ← F.map_comp], congr' 1,\n  dsimp [homological_complex.cone.out],\n  ext,\n  { simp, },\n  { simp, }\nend\n\n.\n\nlemma Ext_δ_natural'\n  (i : ℤ)\n  [enough_projectives A]\n  (W₁ W₂ : bounded_homotopy_category A)\n  (e : W₁ ⟶ W₂)\n  {X Y Z : cochain_complex A ℤ} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Z)]\n  (w : ∀ i, short_exact (f.f i) (g.f i)) :\n  ((Ext i).obj _).map e ≫ Ext_δ f g i W₂ w =\n  Ext_δ f g i W₁ w ≫ ((Ext (i+1)).obj _).map e :=\nbegin\n  delta Ext_δ,\n  dsimp [connecting_hom'],\n  simp only [quiver.hom.unop_op, unop_inv],\n  simp_rw ← category.assoc,\n  rw is_iso.comp_inv_eq,\n  simp_rw category.assoc,\n  let t := _, change _ = _ ≫ _ ≫ t,\n  have ht : t = ((Ext (i + 1)).obj _).map e,\n  { dsimp only [t],\n    rw [is_iso.inv_comp_eq, nat_trans.naturality] },\n  rw ht, clear ht t,\n  rw iso.eq_inv_comp,\n  rw ← nat_trans.naturality,\n  simp only [← category.assoc],\n  congr' 1,\n  rw [iso.comp_inv_eq, ← shift_iso_conj', iso.hom_inv_id_assoc],\nend\n\nlemma Ext_five_term_exact_seq'\n  (n : ℤ)\n  [enough_projectives A]\n  (W : bounded_homotopy_category A)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Z)]\n  (w : ∀ i, short_exact (f.f i) (g.f i)) :\n  let E := λ n, ((Ext n).flip.obj W) in\n  exact_seq Ab.{v} $\n    [ (E n).map (of_hom g).op\n    , (E n).map (of_hom f).op\n    , Ext_δ f g n W w\n    , (E (n+1)).map (of_hom g).op ] :=\nbegin\n  refine (Ext_five_term_exact_seq f g n W w).pair.unop.cons _,\n  refine exact.cons _ (exact.exact_seq _),\n  { rw [Ext_δ, functor.right_op_map, quiver.hom.unop_op, ← shift_iso_conj f n W,\n      exact_iso_comp, exact_comp_hom_inv_comp_iff],\n    have := (Ext_five_term_exact_seq f g (n+1) W w).unop.pair,\n    erw [functor.map_neg, category_theory.unop_neg, abelian.exact_neg_left_iff] at this,\n    exact this },\n  { rw [Ext_δ, exact_iso_comp],\n    exact ((Ext_five_term_exact_seq f g (n+1) W w).drop 1).pair.unop, }\nend\n\nend bounded_homotopy_category\n\nnamespace bounded_derived_category\n\nvariables [enough_projectives A]\nvariables {X Y Z : bounded_derived_category A} (f : X ⟶ Y) (g : Y ⟶ Z)\nopen homological_complex\n\ndef cone (f : X ⟶ Y) : bounded_derived_category A :=\n(localization_functor _).obj $\n{ val := homotopy_category.cone f.val.out,\n  bdd := begin\n    obtain ⟨a,ha⟩ := homotopy_category.is_bounded_above.cond X.val.val,\n    obtain ⟨b,hb⟩ := homotopy_category.is_bounded_above.cond Y.val.val,\n    constructor, use (max a b + 1),\n    intros t ht,\n    apply is_zero_biprod,\n    { apply ha, refine le_trans (le_trans _ ht) _,\n      refine le_trans (le_max_left a b) _,\n      all_goals { linarith } },\n    { apply hb,\n      refine le_trans _ ht, refine le_trans (le_max_right a b) _,\n      linarith }\n  end }\n\n-- UGH\nend bounded_derived_category\n\n-- move me\ninstance single_is_bounded_above (X : A) :\n  homotopy_category.is_bounded_above {as := (homological_complex.single A (complex_shape.up ℤ) 0).obj X} :=\nbegin\n  refine ⟨⟨1, _⟩⟩,\n  intros i hi,\n  dsimp,\n  rw if_neg,\n  { exact is_zero_zero _ },\n  { rintro rfl, exact zero_lt_one.not_le hi }\nend\n\n-- move me\ninstance quotient_single_is_bounded_above (X : A) :\n  ((homotopy_category.quotient A (complex_shape.up ℤ)).obj\n    ((homological_complex.single A (complex_shape.up ℤ) 0).obj X)).is_bounded_above :=\nsingle_is_bounded_above X\n\ndef Ext'_δ [enough_projectives A]\n  {X Y Z : A} (W : A) {f : X ⟶ Y} {g : Y ⟶ Z}\n  (h : short_exact f g) (n : ℤ) :\n  ((Ext' n).flip.obj W).obj (opposite.op $ X) ⟶\n  ((Ext' (n+1)).flip.obj W).obj (opposite.op $ Z) :=\nbegin\n  refine @bounded_homotopy_category.Ext_δ _ _ _ _ _ _\n    ((homological_complex.single _ _ _).map f)\n    ((homological_complex.single _ _ _).map g)\n    n _ _\n    (quotient_single_is_bounded_above _)\n    (quotient_single_is_bounded_above _)\n    (quotient_single_is_bounded_above _) _,\n  intro i, dsimp, by_cases hi : i = 0,\n  { subst i, dsimp, simp only [eq_self_iff_true, category.comp_id, category.id_comp, if_true, h] },\n  { rw [dif_neg hi, dif_neg hi, if_neg hi, if_neg hi, if_neg hi],\n    refine ⟨exact_of_zero _ _⟩, }\nend\n\nlemma Ext'_δ_natural [enough_projectives A]\n  {X₁ X₂ X₃ Y₁ Y₂ Y₃ : A}\n  (f₁ : X₁ ⟶ X₂) (f₂ : X₂ ⟶ X₃)\n  (g₁ : Y₁ ⟶ Y₂) (g₂ : Y₂ ⟶ Y₃)\n  (α₁ : X₁ ⟶ Y₁) (α₂ : X₂ ⟶ Y₂) (α₃ : X₃ ⟶ Y₃)\n  (sq₁ : f₁ ≫ α₂ = α₁ ≫ g₁) (sq₂ : f₂ ≫ α₃ = α₂ ≫ g₂)\n  (Z : A) (hf : short_exact f₁ f₂) (hg : short_exact g₁ g₂) (i : ℤ) :\n  ((Ext' i).flip.obj Z).map α₁.op ≫ Ext'_δ Z hf i =\n    Ext'_δ Z hg i ≫ ((Ext' (i+1)).flip.obj Z).map α₃.op :=\nbegin\n  delta Ext' Ext'_δ,\n  apply bounded_homotopy_category.Ext_δ_natural _ _ _ _ _ _ _\n    ((homological_complex.single A (complex_shape.up ℤ) 0).map α₂),\n  all_goals { simp only [← category_theory.functor.map_comp, sq₁, sq₂, quiver.hom.unop_op] },\nend\n\nnamespace category_theory\nnamespace short_exact\n\nlemma Ext'_five_term_exact_seq [enough_projectives A]\n  {X Y Z : A} (W : A) {f : X ⟶ Y} {g : Y ⟶ Z}\n  (h : short_exact f g) (n : ℤ) :\n  let E := λ n, ((Ext' n).flip.obj W) in\n  exact_seq Ab.{v} $\n    [ (E n).map g.op\n    , (E n).map f.op\n    , Ext'_δ W h n\n    , (E (n+1)).map g.op ] :=\nbegin\n  let f' := (homological_complex.single _ (complex_shape.up ℤ) (0:ℤ)).map f,\n  let g' := (homological_complex.single _ (complex_shape.up ℤ) (0:ℤ)).map g,\n  let W' := (bounded_homotopy_category.single _ 0).obj W,\n  have Hfg : ∀ (i : ℤ), short_exact (f'.f i) (g'.f i),\n  { intro i, dsimp, by_cases hi : i = 0,\n    { subst i, dsimp, simp only [eq_self_iff_true, category.comp_id, category.id_comp, if_true, h] },\n    { rw [dif_neg hi, dif_neg hi, if_neg hi, if_neg hi, if_neg hi],\n      refine ⟨exact_of_zero _ _⟩, } },\n  convert bounded_homotopy_category.Ext_five_term_exact_seq' f' g' n W' Hfg,\nend\n\nend short_exact\nend category_theory\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/for_mathlib/derived/les3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.46385791031266116}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.list.basic\nimport Mathlib.data.fin\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\nnamespace list\n\n\n/- of_fn -/\n\ntheorem length_of_fn_aux {α : Type u} {n : ℕ} (f : fin n → α) (m : ℕ) (h : m ≤ n) (l : List α) :\n    length (of_fn_aux f m h l) = length l + m :=\n  sorry\n\n@[simp] theorem length_of_fn {α : Type u} {n : ℕ} (f : fin n → α) : length (of_fn f) = n :=\n  Eq.trans (length_of_fn_aux f n of_fn._proof_1 []) (zero_add n)\n\ntheorem nth_of_fn_aux {α : Type u} {n : ℕ} (f : fin n → α) (i : ℕ) (m : ℕ) (h : m ≤ n)\n    (l : List α) :\n    (∀ (i : ℕ), nth l i = of_fn_nth_val f (i + m)) →\n        nth (of_fn_aux f m h l) i = of_fn_nth_val f i :=\n  sorry\n\n@[simp] theorem nth_of_fn {α : Type u} {n : ℕ} (f : fin n → α) (i : ℕ) :\n    nth (of_fn f) i = of_fn_nth_val f i :=\n  sorry\n\ntheorem nth_le_of_fn {α : Type u} {n : ℕ} (f : fin n → α) (i : fin n) :\n    nth_le (of_fn f) (↑i) (Eq.symm (length_of_fn f) ▸ subtype.property i) = f i :=\n  sorry\n\n@[simp] theorem nth_le_of_fn' {α : Type u} {n : ℕ} (f : fin n → α) {i : ℕ}\n    (h : i < length (of_fn f)) :\n    nth_le (of_fn f) i h = f { val := i, property := length_of_fn f ▸ h } :=\n  nth_le_of_fn f { val := i, property := length_of_fn f ▸ h }\n\n@[simp] theorem map_of_fn {α : Type u} {β : Type u_1} {n : ℕ} (f : fin n → α) (g : α → β) :\n    map g (of_fn f) = of_fn (g ∘ f) :=\n  sorry\n\ntheorem array_eq_of_fn {α : Type u} {n : ℕ} (a : array n α) :\n    array.to_list a = of_fn (array.read a) :=\n  sorry\n\n@[simp] theorem of_fn_zero {α : Type u} (f : fin 0 → α) : of_fn f = [] := rfl\n\n@[simp] theorem of_fn_succ {α : Type u} {n : ℕ} (f : fin (Nat.succ n) → α) :\n    of_fn f = f 0 :: of_fn fun (i : fin n) => f (fin.succ i) :=\n  sorry\n\ntheorem of_fn_nth_le {α : Type u} (l : List α) :\n    (of_fn fun (i : fin (length l)) => nth_le l (↑i) (subtype.property i)) = l :=\n  sorry\n\n-- not registered as a simp lemma, as otherwise it fires before `forall_mem_of_fn_iff` which\n\n-- is much more useful\n\ntheorem mem_of_fn {α : Type u} {n : ℕ} (f : fin n → α) (a : α) : a ∈ of_fn f ↔ a ∈ set.range f :=\n  sorry\n\n@[simp] theorem forall_mem_of_fn_iff {α : Type u} {n : ℕ} {f : fin n → α} {P : α → Prop} :\n    (∀ (i : α), i ∈ of_fn f → P i) ↔ ∀ (j : fin n), P (f j) :=\n  sorry\n\n@[simp] theorem of_fn_const {α : Type u} (n : ℕ) (c : α) :\n    (of_fn fun (i : fin n) => c) = repeat c n :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/list/of_fn_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.46374278359524496}}
{"text": "infix:50 \" ≅ \"  => HEq\ntheorem ex1 {α : Sort u} {a b : α} (h : a ≅ b) : a = b :=\n  match h with\n  | HEq.refl _ => rfl\n\ntheorem ex2 {α : Sort u2} {a : α} {motive : {β : Sort u2} → β → Sort u1} (m : motive a) {β : Sort u2} {b : β} (h : a ≅ b) : motive b :=\n  match h, m with\n  | HEq.refl _, m => m\n\ntheorem ex3 {α : Sort u} {a : α} {p : α → Sort v} {b : α} (h₁ : a ≅ b) (h₂ : p a) : p b :=\n  match h₁, h₂ with\n  | HEq.refl _, h₂ => h₂\n\ntheorem ex4 {α β : Sort u} {a : α} {b : β} (h : a ≅ b) : b ≅ a :=\n  match h with\n  | HEq.refl _ => HEq.refl _\n\ntheorem ex5 {α : Sort u} {a a' : α} (h : a = a') : a ≅ a' :=\n  match h with\n  | rfl => HEq.refl _\n\ntheorem ex6 {α β : Sort u} (h : α = β) (a : α) : cast h a ≅ a :=\n  match h with\n  | rfl => HEq.refl _\n\ntheorem ex7 {α β σ : Sort u} {a : α} {b : β} {c : σ} (h₁ : a ≅ b) (h₂ : b ≅ c) : a ≅ c :=\n  match h₁, h₂ with\n  | HEq.refl _, HEq.refl _ => HEq.refl _\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/discrRefinement2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4637427810926096}}
{"text": "import GroundZero.Structures\nopen GroundZero.Types.Equiv\nopen GroundZero.Structures\nopen GroundZero.Types\n\n/-\n  Univalence axiom formulated using equivalence J-rule.\n\n  ua, idtoeqv, compRule, propUniq\n  * HoTT 2.10\n\n  Full univalence: (A ≃ B) ≃ (A = B).\n\n  Proof that Type is not a set.\n  * HoTT 3.1, example 3.1.9\n-/\n\nnamespace GroundZero\n\nuniverse u v u' v'\n\naxiom J {C : Π (A B : Type u), A ≃ B → Type v}\n  (h : Π (A : Type u), C A A (ideqv A))\n  {A B : Type u} (e : A ≃ B) : C A B e\n\nattribute [eliminator] J\n\naxiom Jβrule {C : Π (A B : Type u), A ≃ B → Type v}\n  {h : Π (A : Type u), C A A (ideqv A)} {A : Type u} :\n  J h (ideqv A) = h A\n\nnoncomputable hott def Jrule (C : Π (A B : Type u), A ≃ B → Type v)\n  (h : Π (A : Type u), C A A (ideqv A)) {A B : Type u} (e : A ≃ B) : C A B e :=\nJ h e\n\nnoncomputable hott def ua {A B : Type u} : A ≃ B → A = B :=\nJrule (λ A B _, A = B) idp\n\nnamespace ua\n\nnoncomputable hott def reflOnUa (A : Type u) : ua (ideqv A) = idp A :=\nby apply Jβrule\n\nnoncomputable hott def transportRule {A B : Type u} (e : A ≃ B) (x : A) :\n  transportconst (ua e) x = e x :=\nbegin\n  induction e; transitivity;\n  apply Id.map (transport id · x);\n  apply reflOnUa; reflexivity\nend\n\nnoncomputable hott def transportInvRule {A B : Type u} (e : A ≃ B) (x : B) :\n  transportconst (ua e)⁻¹ x = e.left x :=\nbegin\n  induction e; transitivity;\n  apply Id.map (transport id ·⁻¹ x);\n  apply reflOnUa; reflexivity\nend\n\nnoncomputable hott def compRule {A B : Type u} (e : A ≃ B) (x : A) : x =[id, ua e] e x :=\ntransportRule e x\n\nhott def idtoeqvAndId {A : Type u} : idtoeqv (idp A) = ideqv A :=\nby reflexivity\n\nnoncomputable hott def uaβrule {A B : Type u} (e : A ≃ B) : idtoeqv (ua e) = e :=\nbegin induction e; change _ = idtoeqv (idp _); apply Id.map; apply reflOnUa end\n\nnoncomputable hott def propUniq {A B : Type u} (p : A = B) : ua (idtoeqv p) = p :=\nbegin induction p; exact Jβrule end\n\nnoncomputable hott def univalence (A B : Type u) : (A ≃ B) ≃ (A = B) :=\n⟨ua, (⟨idtoeqv, uaβrule⟩, ⟨idtoeqv, propUniq⟩)⟩\n\nnoncomputable hott def propext {A B : Type u}\n  (F : prop A) (G : prop B) : (A ↔ B) → A = B :=\nλ h, ua (propEquivLemma F G h.left h.right)\n\nnoncomputable hott def uaTrans {A B γ : Type u} (p : A ≃ B) (q : B ≃ γ) :\n  ua (Equiv.trans p q) = ua p ⬝ ua q :=\nbegin\n  induction p; induction q; change ua (ideqv _) = _; symmetry;\n  change _ = idp _ ⬝ _; apply Id.map (· ⬝ ua _); apply reflOnUa\nend\n\nhott def isZero : ℕ → 𝟐\n| Nat.zero   => true\n| Nat.succ _ => false\n\nexample (h : 0 = 1) : 𝟎 :=\nffNeqTt (Id.map isZero h)⁻¹\n\nhott def succNeqZero {n : ℕ} : ¬(Nat.succ n = 0) :=\nλ h, ffNeqTt (Id.map isZero h)\n\nhott def negNeg : Π x, not (not x) = x\n| true  => idp true\n| false => idp false\n\nhott def negBoolEquiv : 𝟐 ≃ 𝟐 :=\n⟨not, (⟨not, negNeg⟩, ⟨not, negNeg⟩)⟩\n\nnoncomputable hott def universeNotASet : ¬(hset Type) :=\nbegin\n  let p : 𝟐 = 𝟐 := ua negBoolEquiv; let h := transportconst p true;\n  let g : h = false := transportRule negBoolEquiv true;\n  intro ε; let f : h = true := Id.map (transportconst · true) (ε _ _ p (idp 𝟐));\n  apply ffNeqTt; exact g⁻¹ ⬝ f\nend\n\nnoncomputable hott def coproductSet {A B : Type}\n  (f : hset A) (g : hset B) : hset (A + B)\n| Coproduct.inl x, Coproduct.inl y =>\n  transport prop (ua (@Coproduct.inl.inj' A B x y))⁻¹ (f _ _)\n| Coproduct.inl x, Coproduct.inr y =>\n  transport prop (ua (@Coproduct.inl.inlInr A B x y))⁻¹ emptyIsProp\n| Coproduct.inr x, Coproduct.inl y =>\n  transport prop (ua (@Coproduct.inr.inrInl A B x y))⁻¹ emptyIsProp\n| Coproduct.inr x, Coproduct.inr y =>\n  transport prop (ua (@Coproduct.inr.inj' A B x y))⁻¹ (g _ _)\n\n-- exercise 2.17 (i) in HoTT book\nnoncomputable hott def productEquiv₁ {A A' B B' : Type u}\n  (e₁ : A ≃ A') (e₂ : B ≃ B') : (A × B) ≃ (A' × B') :=\nbegin\n  have p := ua e₁; have q := ua e₂;\n  induction p; induction q; apply ideqv\nend\n\nnoncomputable hott def productEquiv₂ {A A' B B' : Type u}\n  (e₁ : A ≃ A') (e₂ : B ≃ B') : (A × B) ≃ (A' × B') :=\nbegin induction e₁; induction e₂; reflexivity end\n\nsection\n  open GroundZero.Types.Product\n  variable {A : Type u} {A' : Type v} {B : Type u'} {B' : Type v'}\n\n  hott def productEquiv₃ (e₁ : A ≃ A') (e₂ : B ≃ B') : (A × B) ≃ (A' × B') :=\n  prodEquiv e₁ e₂\nend\n\nsection\n  variable {C : 𝟐 → Type u}\n\n  hott def familyOnBool.sec (w : C false × C true) : Π b, C b\n  | false => w.1\n  | true  => w.2\n\n  hott def familyOnBool.ret (φ : Π b, C b) : C false × C true :=\n  (φ false, φ true)\n\n  hott def familyOnBool : (C false × C true) ≃ Π b, C b :=\n  begin\n    existsi familyOnBool.sec; apply Qinv.toBiinv;\n    existsi familyOnBool.ret; apply Prod.mk;\n    { intro φ; apply HITs.Interval.funext; intro b;\n      induction b using Bool.casesOn <;> reflexivity };\n    { intro w; reflexivity }\n  end\nend\n\nend ua\nend GroundZero", "meta": {"author": "forked-from-1kasper", "repo": "ground_zero", "sha": "58ad68bb54e355f6c39beaee2b383879eccc9952", "save_path": "github-repos/lean/forked-from-1kasper-ground_zero", "path": "github-repos/lean/forked-from-1kasper-ground_zero/ground_zero-58ad68bb54e355f6c39beaee2b383879eccc9952/GroundZero/Theorems/UA.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754607093178, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4637427810814232}}
{"text": "/-\nCopyright (c) 2021 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport category_theory.preadditive.default\n\n/-!\n# Preadditive structure on functor categories\n\nIf `C` and `D` are categories and `D` is preadditive,\nthen `C ⥤ D` is also preadditive.\n\n-/\n\nopen_locale big_operators\n\nnamespace category_theory\nopen category_theory.limits preadditive\n\nvariables {C D : Type*} [category C] [category D] [preadditive D]\n\ninstance functor_category_preadditive : preadditive (C ⥤ D) :=\n{ hom_group := λ F G,\n  { add := λ α β,\n    { app := λ X, α.app X + β.app X,\n      naturality' := by { intros, rw [comp_add, add_comp, α.naturality, β.naturality] } },\n    zero := { app := λ X, 0, naturality' := by { intros, rw [zero_comp, comp_zero] } },\n    neg := λ α,\n    { app := λ X, -α.app X,\n      naturality' := by { intros, rw [comp_neg, neg_comp, α.naturality] } },\n    sub := λ α β,\n    { app := λ X, α.app X - β.app X,\n      naturality' := by { intros, rw [comp_sub, sub_comp, α.naturality, β.naturality] } },\n    add_assoc := by { intros, ext, apply add_assoc },\n    zero_add := by { intros, ext, apply zero_add },\n    add_zero := by { intros, ext, apply add_zero },\n    sub_eq_add_neg := by { intros, ext, apply sub_eq_add_neg },\n    add_left_neg := by { intros, ext, apply add_left_neg },\n    add_comm := by { intros, ext, apply add_comm } },\n  add_comp' := by { intros, ext, apply add_comp },\n  comp_add' := by { intros, ext, apply comp_add } }\n\nnamespace nat_trans\n\nvariables {F G : C ⥤ D}\n\n/-- Application of a natural transformation at a fixed object,\nas group homomorphism -/\n@[simps] def app_hom (X : C) : (F ⟶ G) →+ (F.obj X ⟶ G.obj X) :=\n{ to_fun := λ α, α.app X,\n  map_zero' := rfl,\n  map_add' := λ _ _, rfl }\n\n@[simp] lemma app_zero (X : C) : (0 : F ⟶ G).app X = 0 := rfl\n\n@[simp] lemma app_add (X : C) (α β : F ⟶ G) : (α + β).app X = α.app X + β.app X := rfl\n\n@[simp] lemma app_sub (X : C) (α β : F ⟶ G) : (α - β).app X = α.app X - β.app X := rfl\n\n@[simp] lemma app_neg (X : C) (α : F ⟶ G) : (-α).app X = -α.app X := rfl\n\n@[simp] lemma app_nsmul (X : C) (α : F ⟶ G) (n : ℕ) : (n • α).app X = n • α.app X :=\n(app_hom X).map_nsmul α n\n\n@[simp] lemma app_zsmul (X : C) (α : F ⟶ G) (n : ℤ) : (n • α).app X = n • α.app X :=\n(app_hom X : (F ⟶ G) →+ (F.obj X ⟶ G.obj X)).map_zsmul α n\n\n@[simp] lemma app_sum {ι : Type*} (s : finset ι) (X : C) (α : ι → (F ⟶ G)) :\n  (∑ i in s, α i).app X = ∑ i in s, ((α i).app X) :=\nby { rw [← app_hom_apply, add_monoid_hom.map_sum], refl }\n\nend nat_trans\n\nend category_theory\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/category_theory/preadditive/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.727975460709318, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.46374277606496656}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Devon Tuma\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.group_theory.submonoid.operations\nimport Mathlib.group_theory.submonoid.membership\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Non-zero divisors\n\nIn this file we define the submonoid `non_zero_divisors` of a `monoid_with_zero`.\n-/\n\n/-- The submonoid of non-zero-divisors of a `monoid_with_zero` `R`. -/\ndef non_zero_divisors (R : Type u_1) [monoid_with_zero R] : submonoid R :=\n  submonoid.mk (set_of fun (x : R) => ∀ (z : R), z * x = 0 → z = 0) sorry sorry\n\ntheorem mul_mem_non_zero_divisors {R : Type u_1} [comm_ring R] {a : R} {b : R} : a * b ∈ non_zero_divisors R ↔ a ∈ non_zero_divisors R ∧ b ∈ non_zero_divisors R := sorry\n\ntheorem eq_zero_of_ne_zero_of_mul_right_eq_zero {A : Type u_2} [integral_domain A] {x : A} {y : A} (hnx : x ≠ 0) (hxy : y * x = 0) : y = 0 :=\n  or.resolve_right (eq_zero_or_eq_zero_of_mul_eq_zero hxy) hnx\n\ntheorem eq_zero_of_ne_zero_of_mul_left_eq_zero {A : Type u_2} [integral_domain A] {x : A} {y : A} (hnx : x ≠ 0) (hxy : x * y = 0) : y = 0 :=\n  or.resolve_left (eq_zero_or_eq_zero_of_mul_eq_zero hxy) hnx\n\ntheorem mem_non_zero_divisors_iff_ne_zero {A : Type u_2} [integral_domain A] {x : A} : x ∈ non_zero_divisors A ↔ x ≠ 0 := sorry\n\ntheorem map_ne_zero_of_mem_non_zero_divisors {R : Type u_1} [comm_ring R] [nontrivial R] {B : Type u_2} [ring B] {g : R →+* B} (hg : function.injective ⇑g) {x : ↥(non_zero_divisors R)} : coe_fn g ↑x ≠ 0 :=\n  fun (h0 : coe_fn g ↑x = 0) =>\n    one_ne_zero (subtype.property x 1 (Eq.symm (one_mul (subtype.val x)) ▸ hg (trans h0 (Eq.symm (ring_hom.map_zero g)))))\n\ntheorem map_mem_non_zero_divisors {A : Type u_2} [integral_domain A] {B : Type u_1} [integral_domain B] {g : A →+* B} (hg : function.injective ⇑g) {x : ↥(non_zero_divisors A)} : coe_fn g ↑x ∈ non_zero_divisors B :=\n  fun (z : B) (hz : z * coe_fn g ↑x = 0) =>\n    eq_zero_of_ne_zero_of_mul_right_eq_zero (map_ne_zero_of_mem_non_zero_divisors hg) hz\n\ntheorem le_non_zero_divisors_of_domain {A : Type u_2} [integral_domain A] {M : submonoid A} (hM : ¬↑0 ∈ M) : M ≤ non_zero_divisors A :=\n  fun (x : A) (hx : x ∈ M) (y : A) (hy : y * x = 0) =>\n    or.rec_on (eq_zero_or_eq_zero_of_mul_eq_zero hy) (fun (h : y = 0) => h) fun (h : x = 0) => absurd (h ▸ hx) hM\n\ntheorem powers_le_non_zero_divisors_of_domain {A : Type u_2} [integral_domain A] {a : A} (ha : a ≠ 0) : submonoid.powers a ≤ non_zero_divisors A :=\n  le_non_zero_divisors_of_domain\n    fun (h : ↑0 ∈ submonoid.powers a) => absurd (Exists.rec_on h fun (_x : ℕ) (hn : a ^ _x = ↑0) => pow_eq_zero hn) ha\n\ntheorem map_le_non_zero_divisors_of_injective {A : Type u_2} [integral_domain A] {B : Type u_1} [integral_domain B] {f : A →+* B} (hf : function.injective ⇑f) {M : submonoid A} (hM : M ≤ non_zero_divisors A) : submonoid.map (↑f) M ≤ non_zero_divisors B := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/non_zero_divisors.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.46360740179147764}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Mario Carneiro\n\n! This file was ported from Lean 3 source module linear_algebra.bilinear_map\n! leanprover-community/mathlib commit ee05e9ce1322178f0c12004eb93c00d2c8c00ed2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.LinearAlgebra.Basic\n\n/-!\n# Basics on bilinear maps\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file provides basics on bilinear maps. The most general form considered are maps that are\nsemilinear in both arguments. They are of type `M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P`, where `M` and `N`\nare modules over `R` and `S` respectively, `P` is a module over both `R₂` and `S₂` with\ncommuting actions, and `ρ₁₂ : R →+* R₂` and `σ₁₂ : S →+* S₂`.\n\n## Main declarations\n\n* `linear_map.mk₂`: a constructor for bilinear maps,\n  taking an unbundled function together with proof witnesses of bilinearity\n* `linear_map.flip`: turns a bilinear map `M × N → P` into `N × M → P`\n* `linear_map.lcomp` and `linear_map.llcomp`: composition of linear maps as a bilinear map\n* `linear_map.compl₂`: composition of a bilinear map `M × N → P` with a linear map `Q → M`\n* `linear_map.compr₂`: composition of a bilinear map `M × N → P` with a linear map `Q → N`\n* `linear_map.lsmul`: scalar multiplication as a bilinear map `R × M → M`\n\n## Tags\n\nbilinear\n-/\n\n\nnamespace LinearMap\n\nsection Semiring\n\n-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariable {R : Type _} [Semiring R] {S : Type _} [Semiring S]\n\nvariable {R₂ : Type _} [Semiring R₂] {S₂ : Type _} [Semiring S₂]\n\nvariable {M : Type _} {N : Type _} {P : Type _}\n\nvariable {M₂ : Type _} {N₂ : Type _} {P₂ : Type _}\n\nvariable {Nₗ : Type _} {Pₗ : Type _}\n\nvariable {M' : Type _} {N' : Type _} {P' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]\n\nvariable [AddCommMonoid M₂] [AddCommMonoid N₂] [AddCommMonoid P₂]\n\nvariable [AddCommMonoid Nₗ] [AddCommMonoid Pₗ]\n\nvariable [AddCommGroup M'] [AddCommGroup N'] [AddCommGroup P']\n\nvariable [Module R M] [Module S N] [Module R₂ P] [Module S₂ P]\n\nvariable [Module R M₂] [Module S N₂] [Module R P₂] [Module S₂ P₂]\n\nvariable [Module R Pₗ] [Module S Pₗ]\n\nvariable [Module R M'] [Module S N'] [Module R₂ P'] [Module S₂ P']\n\nvariable [SMulCommClass S₂ R₂ P] [SMulCommClass S R Pₗ] [SMulCommClass S₂ R₂ P']\n\nvariable [SMulCommClass S₂ R P₂]\n\nvariable {ρ₁₂ : R →+* R₂} {σ₁₂ : S →+* S₂}\n\nvariable (ρ₁₂ σ₁₂)\n\n/- warning: linear_map.mk₂'ₛₗ -> LinearMap.mk₂'ₛₗ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] (ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) (σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) (f : M -> N -> P), (forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u7} P (f (HAdd.hAdd.{u5, u5, u5} M M M (instHAdd.{u5} M (AddZeroClass.toHasAdd.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toHasAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m₁ n) (f m₂ n))) -> (forall (c : R) (m : M) (n : N), Eq.{succ u7} P (f (SMul.smul.{u1, u5} R M (SMulZeroClass.toHasSmul.{u1, u5} R M (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u5} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u5} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (Module.toMulActionWithZero.{u1, u5} R M _inst_1 _inst_5 _inst_16)))) c m) n) (SMul.smul.{u3, u7} R₂ P (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18)))) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) (fun (_x : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) => R -> R₂) (RingHom.hasCoeToFun.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) ρ₁₂ c) (f m n))) -> (forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u7} P (f m (HAdd.hAdd.{u6, u6, u6} N N N (instHAdd.{u6} N (AddZeroClass.toHasAdd.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toHasAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m n₁) (f m n₂))) -> (forall (c : S) (m : M) (n : N), Eq.{succ u7} P (f m (SMul.smul.{u2, u6} S N (SMulZeroClass.toHasSmul.{u2, u6} S N (AddZeroClass.toHasZero.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6))) (SMulWithZero.toSmulZeroClass.{u2, u6} S N (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6))) (MulActionWithZero.toSMulWithZero.{u2, u6} S N (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6))) (Module.toMulActionWithZero.{u2, u6} S N _inst_2 _inst_6 _inst_17)))) c n)) (SMul.smul.{u4, u7} S₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (coeFn.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) (fun (_x : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) => S -> S₂) (RingHom.hasCoeToFun.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) σ₁₂ c) (f m n))) -> (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toSMul.{u4, u7} S₂ P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u4, u7} S₂ P (MonoidWithZero.toZero.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u3, u7} R₂ P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u3, u7} R₂ P (MonoidWithZero.toZero.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] (ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) (σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) (f : M -> N -> P), (forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u7} P (f (HAdd.hAdd.{u5, u5, u5} M M M (instHAdd.{u5} M (AddZeroClass.toAdd.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m₁ n) (f m₂ n))) -> (forall (c : R) (m : M) (n : N), Eq.{succ u7} P (f (HSMul.hSMul.{u1, u5, u5} R M M (instHSMul.{u1, u5} R M (SMulZeroClass.toSMul.{u1, u5} R M (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u1, u5} R M (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u1, u5} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (Module.toMulActionWithZero.{u1, u5} R M _inst_1 _inst_5 _inst_16))))) c m) n) (HSMul.hSMul.{u3, u7, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P P (instHSMul.{u3, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (SMulZeroClass.toSMul.{u3, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u3, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (MonoidWithZero.toZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) (Semiring.toMonoidWithZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) _inst_3)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u3, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (Semiring.toMonoidWithZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) _inst_3) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u3, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P _inst_3 _inst_7 _inst_18))))) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) R R₂ (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u3} R₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R₂ (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) R R₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R₂ (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3) (RingHom.instRingHomClassRingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3))))) ρ₁₂ c) (f m n))) -> (forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u7} P (f m (HAdd.hAdd.{u6, u6, u6} N N N (instHAdd.{u6} N (AddZeroClass.toAdd.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m n₁) (f m n₂))) -> (forall (c : S) (m : M) (n : N), Eq.{succ u7} P (f m (HSMul.hSMul.{u2, u6, u6} S N N (instHSMul.{u2, u6} S N (SMulZeroClass.toSMul.{u2, u6} S N (AddMonoid.toZero.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6)) (SMulWithZero.toSMulZeroClass.{u2, u6} S N (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6)) (MulActionWithZero.toSMulWithZero.{u2, u6} S N (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6)) (Module.toMulActionWithZero.{u2, u6} S N _inst_2 _inst_6 _inst_17))))) c n)) (HSMul.hSMul.{u4, u7, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P P (instHSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (SMulZeroClass.toSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (MonoidWithZero.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) _inst_4)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) _inst_4) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P _inst_4 _inst_7 _inst_19))))) (FunLike.coe.{max (succ u2) (succ u4), succ u2, succ u4} (RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) _x) (MulHomClass.toFunLike.{max u2 u4, u2, u4} (RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) S S₂ (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u4} S₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S₂ (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u4, u2, u4} (RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) S S₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S₂ (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u4, u2, u4} (RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4) (RingHom.instRingHomClassRingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4))))) σ₁₂ c) (f m n))) -> (LinearMap.{u1, u3, u5, max u7 u6} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30))\nCase conversion may be inaccurate. Consider using '#align linear_map.mk₂'ₛₗ LinearMap.mk₂'ₛₗₓ'. -/\n/-- Create a bilinear map from a function that is semilinear in each component.\nSee `mk₂'` and `mk₂` for the linear case. -/\ndef mk₂'ₛₗ (f : M → N → P) (H1 : ∀ m₁ m₂ n, f (m₁ + m₂) n = f m₁ n + f m₂ n)\n    (H2 : ∀ (c : R) (m n), f (c • m) n = ρ₁₂ c • f m n)\n    (H3 : ∀ m n₁ n₂, f m (n₁ + n₂) = f m n₁ + f m n₂)\n    (H4 : ∀ (c : S) (m n), f m (c • n) = σ₁₂ c • f m n) : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P\n    where\n  toFun m :=\n    { toFun := f m\n      map_add' := H3 m\n      map_smul' := fun c => H4 c m }\n  map_add' m₁ m₂ := LinearMap.ext <| H1 m₁ m₂\n  map_smul' c m := LinearMap.ext <| H2 c m\n#align linear_map.mk₂'ₛₗ LinearMap.mk₂'ₛₗ\n\nvariable {ρ₁₂ σ₁₂}\n\n/- warning: linear_map.mk₂'ₛₗ_apply -> LinearMap.mk₂'ₛₗ_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : M -> N -> P) {H1 : forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u7} P (f (HAdd.hAdd.{u5, u5, u5} M M M (instHAdd.{u5} M (AddZeroClass.toHasAdd.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toHasAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m₁ n) (f m₂ n))} {H2 : forall (c : R) (m : M) (n : N), Eq.{succ u7} P (f (SMul.smul.{u1, u5} R M (SMulZeroClass.toHasSmul.{u1, u5} R M (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u5} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u5} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (Module.toMulActionWithZero.{u1, u5} R M _inst_1 _inst_5 _inst_16)))) c m) n) (SMul.smul.{u3, u7} R₂ P (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18)))) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) (fun (_x : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) => R -> R₂) (RingHom.hasCoeToFun.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) ρ₁₂ c) (f m n))} {H3 : forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u7} P (f m (HAdd.hAdd.{u6, u6, u6} N N N (instHAdd.{u6} N (AddZeroClass.toHasAdd.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toHasAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m n₁) (f m n₂))} {H4 : forall (c : S) (m : M) (n : N), Eq.{succ u7} P (f m (SMul.smul.{u2, u6} S N (SMulZeroClass.toHasSmul.{u2, u6} S N (AddZeroClass.toHasZero.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6))) (SMulWithZero.toSmulZeroClass.{u2, u6} S N (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6))) (MulActionWithZero.toSMulWithZero.{u2, u6} S N (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u6} N (AddMonoid.toAddZeroClass.{u6} N (AddCommMonoid.toAddMonoid.{u6} N _inst_6))) (Module.toMulActionWithZero.{u2, u6} S N _inst_2 _inst_6 _inst_17)))) c n)) (SMul.smul.{u4, u7} S₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (coeFn.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) (fun (_x : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) => S -> S₂) (RingHom.hasCoeToFun.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)) σ₁₂ c) (f m n))} (m : M) (n : N), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) (LinearMap.mk₂'ₛₗ.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f H1 H2 H3 H4) m) n) (f m n)\nbut is expected to have type\n  forall {R : Type.{u5}} [_inst_1 : Semiring.{u5} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u4}} [_inst_3 : Semiring.{u4} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u6}} {N : Type.{u3}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u6} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u5, u6} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u4, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u4, u7} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u7} S₂ P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u7} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u7} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u1, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u4, u7} R₂ P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u4, u7} R₂ P (MonoidWithZero.toZero.{u4} R₂ (Semiring.toMonoidWithZero.{u4} R₂ _inst_3)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u4, u7} R₂ P (Semiring.toMonoidWithZero.{u4} R₂ _inst_3) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u4, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u5, u4} R R₂ (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : M -> N -> P) {H1 : forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u7} P (f (HAdd.hAdd.{u6, u6, u6} M M M (instHAdd.{u6} M (AddZeroClass.toAdd.{u6} M (AddMonoid.toAddZeroClass.{u6} M (AddCommMonoid.toAddMonoid.{u6} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m₁ n) (f m₂ n))} {H2 : forall (c : R) (m : M) (n : N), Eq.{succ u7} P (f (HSMul.hSMul.{u5, u6, u6} R M M (instHSMul.{u5, u6} R M (SMulZeroClass.toSMul.{u5, u6} R M (AddMonoid.toZero.{u6} M (AddCommMonoid.toAddMonoid.{u6} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u5, u6} R M (MonoidWithZero.toZero.{u5} R (Semiring.toMonoidWithZero.{u5} R _inst_1)) (AddMonoid.toZero.{u6} M (AddCommMonoid.toAddMonoid.{u6} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u5, u6} R M (Semiring.toMonoidWithZero.{u5} R _inst_1) (AddMonoid.toZero.{u6} M (AddCommMonoid.toAddMonoid.{u6} M _inst_5)) (Module.toMulActionWithZero.{u5, u6} R M _inst_1 _inst_5 _inst_16))))) c m) n) (HSMul.hSMul.{u4, u7, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P P (instHSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (SMulZeroClass.toSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (MonoidWithZero.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) _inst_3)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) _inst_3) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) c) P _inst_3 _inst_7 _inst_18))))) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (RingHom.{u5, u4} R R₂ (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) _x) (MulHomClass.toFunLike.{max u5 u4, u5, u4} (RingHom.{u5, u4} R R₂ (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3)) R R₂ (NonUnitalNonAssocSemiring.toMul.{u5} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} R (Semiring.toNonAssocSemiring.{u5} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u4} R₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} R₂ (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u5 u4, u5, u4} (RingHom.{u5, u4} R R₂ (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3)) R R₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} R (Semiring.toNonAssocSemiring.{u5} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} R₂ (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u5 u4, u5, u4} (RingHom.{u5, u4} R R₂ (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3)) R R₂ (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3) (RingHom.instRingHomClassRingHom.{u5, u4} R R₂ (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R₂ _inst_3))))) ρ₁₂ c) (f m n))} {H3 : forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u7} P (f m (HAdd.hAdd.{u3, u3, u3} N N N (instHAdd.{u3} N (AddZeroClass.toAdd.{u3} N (AddMonoid.toAddZeroClass.{u3} N (AddCommMonoid.toAddMonoid.{u3} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (f m n₁) (f m n₂))} {H4 : forall (c : S) (m : M) (n : N), Eq.{succ u7} P (f m (HSMul.hSMul.{u2, u3, u3} S N N (instHSMul.{u2, u3} S N (SMulZeroClass.toSMul.{u2, u3} S N (AddMonoid.toZero.{u3} N (AddCommMonoid.toAddMonoid.{u3} N _inst_6)) (SMulWithZero.toSMulZeroClass.{u2, u3} S N (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u3} N (AddCommMonoid.toAddMonoid.{u3} N _inst_6)) (MulActionWithZero.toSMulWithZero.{u2, u3} S N (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u3} N (AddCommMonoid.toAddMonoid.{u3} N _inst_6)) (Module.toMulActionWithZero.{u2, u3} S N _inst_2 _inst_6 _inst_17))))) c n)) (HSMul.hSMul.{u1, u7, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P P (instHSMul.{u1, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (SMulZeroClass.toSMul.{u1, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (MonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) _inst_4)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) _inst_4) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u1, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) c) P _inst_4 _inst_7 _inst_19))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S₂) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)) S S₂ (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u1} S₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S₂ (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)) S S₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S₂ (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)) S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4) (RingHom.instRingHomClassRingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4))))) σ₁₂ c) (f m n))} (m : M) (n : N), Eq.{succ u7} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) n) (FunLike.coe.{max (succ u3) (succ u7), succ u3, succ u7} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u6) (succ u3)) (succ u7), succ u6, max (succ u3) (succ u7)} (LinearMap.{u5, u4, u6, max u7 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u4, u3, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u5, u4, u6, max u3 u7} R R₂ M (LinearMap.{u2, u1, u3, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u4, u3, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) (LinearMap.mk₂'ₛₗ.{u5, u2, u4, u1, u6, u3, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f H1 H2 H3 H4) m) n) (f m n)\nCase conversion may be inaccurate. Consider using '#align linear_map.mk₂'ₛₗ_apply LinearMap.mk₂'ₛₗ_applyₓ'. -/\n@[simp]\ntheorem mk₂'ₛₗ_apply (f : M → N → P) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk₂'ₛₗ ρ₁₂ σ₁₂ f H1 H2 H3 H4 : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) m n = f m n :=\n  rfl\n#align linear_map.mk₂'ₛₗ_apply LinearMap.mk₂'ₛₗ_apply\n\nvariable (R S)\n\n/- warning: linear_map.mk₂' -> LinearMap.mk₂' is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : Semiring.{u1} R] (S : Type.{u2}) [_inst_2 : Semiring.{u2} S] {M : Type.{u3}} {N : Type.{u4}} {Pₗ : Type.{u5}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_6 : AddCommMonoid.{u4} N] [_inst_12 : AddCommMonoid.{u5} Pₗ] [_inst_16 : Module.{u1, u3} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u4} S N _inst_2 _inst_6] [_inst_24 : Module.{u1, u5} R Pₗ _inst_1 _inst_12] [_inst_25 : Module.{u2, u5} S Pₗ _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u2, u1, u5} S R Pₗ (SMulZeroClass.toHasSmul.{u2, u5} S Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S Pₗ (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S Pₗ (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u2, u5} S Pₗ _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toHasSmul.{u1, u5} R Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R Pₗ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u1, u5} R Pₗ _inst_1 _inst_12 _inst_24))))] (f : M -> N -> Pₗ), (forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u5} Pₗ (f (HAdd.hAdd.{u3, u3, u3} M M M (instHAdd.{u3} M (AddZeroClass.toHasAdd.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toHasAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m₁ n) (f m₂ n))) -> (forall (c : R) (m : M) (n : N), Eq.{succ u5} Pₗ (f (SMul.smul.{u1, u3} R M (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5))) (Module.toMulActionWithZero.{u1, u3} R M _inst_1 _inst_5 _inst_16)))) c m) n) (SMul.smul.{u1, u5} R Pₗ (SMulZeroClass.toHasSmul.{u1, u5} R Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R Pₗ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u1, u5} R Pₗ _inst_1 _inst_12 _inst_24)))) c (f m n))) -> (forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u5} Pₗ (f m (HAdd.hAdd.{u4, u4, u4} N N N (instHAdd.{u4} N (AddZeroClass.toHasAdd.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toHasAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m n₁) (f m n₂))) -> (forall (c : S) (m : M) (n : N), Eq.{succ u5} Pₗ (f m (SMul.smul.{u2, u4} S N (SMulZeroClass.toHasSmul.{u2, u4} S N (AddZeroClass.toHasZero.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6))) (SMulWithZero.toSmulZeroClass.{u2, u4} S N (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6))) (MulActionWithZero.toSMulWithZero.{u2, u4} S N (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6))) (Module.toMulActionWithZero.{u2, u4} S N _inst_2 _inst_6 _inst_17)))) c n)) (SMul.smul.{u2, u5} S Pₗ (SMulZeroClass.toHasSmul.{u2, u5} S Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S Pₗ (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S Pₗ (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u2, u5} S Pₗ _inst_2 _inst_12 _inst_25)))) c (f m n))) -> (LinearMap.{u1, u1, u3, max u4 u5} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M (LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_16 (LinearMap.module.{u2, u2, u1, u4, u5} S S R N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) _inst_1 _inst_24 _inst_31))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : Semiring.{u1} R] (S : Type.{u2}) [_inst_2 : Semiring.{u2} S] {M : Type.{u3}} {N : Type.{u4}} {Pₗ : Type.{u5}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_6 : AddCommMonoid.{u4} N] [_inst_12 : AddCommMonoid.{u5} Pₗ] [_inst_16 : Module.{u1, u3} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u4} S N _inst_2 _inst_6] [_inst_24 : Module.{u1, u5} R Pₗ _inst_1 _inst_12] [_inst_25 : Module.{u2, u5} S Pₗ _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u2, u1, u5} S R Pₗ (SMulZeroClass.toSMul.{u2, u5} S Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u2, u5} S Pₗ (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u2, u5} S Pₗ (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u2, u5} S Pₗ _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toSMul.{u1, u5} R Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} R Pₗ (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} R Pₗ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u1, u5} R Pₗ _inst_1 _inst_12 _inst_24))))] (f : M -> N -> Pₗ), (forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u5} Pₗ (f (HAdd.hAdd.{u3, u3, u3} M M M (instHAdd.{u3} M (AddZeroClass.toAdd.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m₁ n) (f m₂ n))) -> (forall (c : R) (m : M) (n : N), Eq.{succ u5} Pₗ (f (HSMul.hSMul.{u1, u3, u3} R M M (instHSMul.{u1, u3} R M (SMulZeroClass.toSMul.{u1, u3} R M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u1, u3} R M (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)) (Module.toMulActionWithZero.{u1, u3} R M _inst_1 _inst_5 _inst_16))))) c m) n) (HSMul.hSMul.{u1, u5, u5} R Pₗ Pₗ (instHSMul.{u1, u5} R Pₗ (SMulZeroClass.toSMul.{u1, u5} R Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} R Pₗ (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} R Pₗ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u1, u5} R Pₗ _inst_1 _inst_12 _inst_24))))) c (f m n))) -> (forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u5} Pₗ (f m (HAdd.hAdd.{u4, u4, u4} N N N (instHAdd.{u4} N (AddZeroClass.toAdd.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m n₁) (f m n₂))) -> (forall (c : S) (m : M) (n : N), Eq.{succ u5} Pₗ (f m (HSMul.hSMul.{u2, u4, u4} S N N (instHSMul.{u2, u4} S N (SMulZeroClass.toSMul.{u2, u4} S N (AddMonoid.toZero.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6)) (SMulWithZero.toSMulZeroClass.{u2, u4} S N (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6)) (MulActionWithZero.toSMulWithZero.{u2, u4} S N (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6)) (Module.toMulActionWithZero.{u2, u4} S N _inst_2 _inst_6 _inst_17))))) c n)) (HSMul.hSMul.{u2, u5, u5} S Pₗ Pₗ (instHSMul.{u2, u5} S Pₗ (SMulZeroClass.toSMul.{u2, u5} S Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u2, u5} S Pₗ (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u2, u5} S Pₗ (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u2, u5} S Pₗ _inst_2 _inst_12 _inst_25))))) c (f m n))) -> (LinearMap.{u1, u1, u3, max u5 u4} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M (LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u2, u1, u4, u5} S S R N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) _inst_1 _inst_24 _inst_31))\nCase conversion may be inaccurate. Consider using '#align linear_map.mk₂' LinearMap.mk₂'ₓ'. -/\n/-- Create a bilinear map from a function that is linear in each component.\nSee `mk₂` for the special case where both arguments come from modules over the same ring. -/\ndef mk₂' (f : M → N → Pₗ) (H1 : ∀ m₁ m₂ n, f (m₁ + m₂) n = f m₁ n + f m₂ n)\n    (H2 : ∀ (c : R) (m n), f (c • m) n = c • f m n)\n    (H3 : ∀ m n₁ n₂, f m (n₁ + n₂) = f m n₁ + f m n₂)\n    (H4 : ∀ (c : S) (m n), f m (c • n) = c • f m n) : M →ₗ[R] N →ₗ[S] Pₗ :=\n  mk₂'ₛₗ (RingHom.id R) (RingHom.id S) f H1 H2 H3 H4\n#align linear_map.mk₂' LinearMap.mk₂'\n\nvariable {R S}\n\n/- warning: linear_map.mk₂'_apply -> LinearMap.mk₂'_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {M : Type.{u3}} {N : Type.{u4}} {Pₗ : Type.{u5}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_6 : AddCommMonoid.{u4} N] [_inst_12 : AddCommMonoid.{u5} Pₗ] [_inst_16 : Module.{u1, u3} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u4} S N _inst_2 _inst_6] [_inst_24 : Module.{u1, u5} R Pₗ _inst_1 _inst_12] [_inst_25 : Module.{u2, u5} S Pₗ _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u2, u1, u5} S R Pₗ (SMulZeroClass.toHasSmul.{u2, u5} S Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S Pₗ (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S Pₗ (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u2, u5} S Pₗ _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toHasSmul.{u1, u5} R Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R Pₗ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u1, u5} R Pₗ _inst_1 _inst_12 _inst_24))))] (f : M -> N -> Pₗ) {H1 : forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u5} Pₗ (f (HAdd.hAdd.{u3, u3, u3} M M M (instHAdd.{u3} M (AddZeroClass.toHasAdd.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toHasAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m₁ n) (f m₂ n))} {H2 : forall (c : R) (m : M) (n : N), Eq.{succ u5} Pₗ (f (SMul.smul.{u1, u3} R M (SMulZeroClass.toHasSmul.{u1, u3} R M (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u3} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u3} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5))) (Module.toMulActionWithZero.{u1, u3} R M _inst_1 _inst_5 _inst_16)))) c m) n) (SMul.smul.{u1, u5} R Pₗ (SMulZeroClass.toHasSmul.{u1, u5} R Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R Pₗ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u1, u5} R Pₗ _inst_1 _inst_12 _inst_24)))) c (f m n))} {H3 : forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u5} Pₗ (f m (HAdd.hAdd.{u4, u4, u4} N N N (instHAdd.{u4} N (AddZeroClass.toHasAdd.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toHasAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m n₁) (f m n₂))} {H4 : forall (c : S) (m : M) (n : N), Eq.{succ u5} Pₗ (f m (SMul.smul.{u2, u4} S N (SMulZeroClass.toHasSmul.{u2, u4} S N (AddZeroClass.toHasZero.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6))) (SMulWithZero.toSmulZeroClass.{u2, u4} S N (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6))) (MulActionWithZero.toSMulWithZero.{u2, u4} S N (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u4} N (AddMonoid.toAddZeroClass.{u4} N (AddCommMonoid.toAddMonoid.{u4} N _inst_6))) (Module.toMulActionWithZero.{u2, u4} S N _inst_2 _inst_6 _inst_17)))) c n)) (SMul.smul.{u2, u5} S Pₗ (SMulZeroClass.toHasSmul.{u2, u5} S Pₗ (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S Pₗ (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S Pₗ (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12))) (Module.toMulActionWithZero.{u2, u5} S Pₗ _inst_2 _inst_12 _inst_25)))) c (f m n))} (m : M) (n : N), Eq.{succ u5} Pₗ (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) (fun (_x : LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) => N -> Pₗ) (LinearMap.hasCoeToFun.{u2, u2, u4, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (coeFn.{max (succ u3) (succ (max u4 u5)), max (succ u3) (succ (max u4 u5))} (LinearMap.{u1, u1, u3, max u4 u5} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M (LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_16 (LinearMap.module.{u2, u2, u1, u4, u5} S S R N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) _inst_1 _inst_24 _inst_31)) (fun (_x : LinearMap.{u1, u1, u3, max u4 u5} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M (LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_16 (LinearMap.module.{u2, u2, u1, u4, u5} S S R N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) _inst_1 _inst_24 _inst_31)) => M -> (LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25)) (LinearMap.hasCoeToFun.{u1, u1, u3, max u4 u5} R R M (LinearMap.{u2, u2, u4, u5} S S _inst_2 _inst_2 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _inst_1 _inst_1 _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) _inst_16 (LinearMap.module.{u2, u2, u1, u4, u5} S S R N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) _inst_1 _inst_24 _inst_31) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (LinearMap.mk₂'.{u1, u2, u3, u4, u5} R _inst_1 S _inst_2 M N Pₗ _inst_5 _inst_6 _inst_12 _inst_16 _inst_17 _inst_24 _inst_25 _inst_31 f H1 H2 H3 H4) m) n) (f m n)\nbut is expected to have type\n  forall {R : Type.{u3}} [_inst_1 : Semiring.{u3} R] {S : Type.{u1}} [_inst_2 : Semiring.{u1} S] {M : Type.{u4}} {N : Type.{u2}} {Pₗ : Type.{u5}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_6 : AddCommMonoid.{u2} N] [_inst_12 : AddCommMonoid.{u5} Pₗ] [_inst_16 : Module.{u3, u4} R M _inst_1 _inst_5] [_inst_17 : Module.{u1, u2} S N _inst_2 _inst_6] [_inst_24 : Module.{u3, u5} R Pₗ _inst_1 _inst_12] [_inst_25 : Module.{u1, u5} S Pₗ _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u1, u3, u5} S R Pₗ (SMulZeroClass.toSMul.{u1, u5} S Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} S Pₗ (MonoidWithZero.toZero.{u1} S (Semiring.toMonoidWithZero.{u1} S _inst_2)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} S Pₗ (Semiring.toMonoidWithZero.{u1} S _inst_2) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u1, u5} S Pₗ _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toSMul.{u3, u5} R Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u3, u5} R Pₗ (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R _inst_1)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u3, u5} R Pₗ (Semiring.toMonoidWithZero.{u3} R _inst_1) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u3, u5} R Pₗ _inst_1 _inst_12 _inst_24))))] (f : M -> N -> Pₗ) {H1 : forall (m₁ : M) (m₂ : M) (n : N), Eq.{succ u5} Pₗ (f (HAdd.hAdd.{u4, u4, u4} M M M (instHAdd.{u4} M (AddZeroClass.toAdd.{u4} M (AddMonoid.toAddZeroClass.{u4} M (AddCommMonoid.toAddMonoid.{u4} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m₁ n) (f m₂ n))} {H2 : forall (c : R) (m : M) (n : N), Eq.{succ u5} Pₗ (f (HSMul.hSMul.{u3, u4, u4} R M M (instHSMul.{u3, u4} R M (SMulZeroClass.toSMul.{u3, u4} R M (AddMonoid.toZero.{u4} M (AddCommMonoid.toAddMonoid.{u4} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u3, u4} R M (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R _inst_1)) (AddMonoid.toZero.{u4} M (AddCommMonoid.toAddMonoid.{u4} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u3, u4} R M (Semiring.toMonoidWithZero.{u3} R _inst_1) (AddMonoid.toZero.{u4} M (AddCommMonoid.toAddMonoid.{u4} M _inst_5)) (Module.toMulActionWithZero.{u3, u4} R M _inst_1 _inst_5 _inst_16))))) c m) n) (HSMul.hSMul.{u3, u5, u5} R Pₗ Pₗ (instHSMul.{u3, u5} R Pₗ (SMulZeroClass.toSMul.{u3, u5} R Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u3, u5} R Pₗ (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R _inst_1)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u3, u5} R Pₗ (Semiring.toMonoidWithZero.{u3} R _inst_1) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u3, u5} R Pₗ _inst_1 _inst_12 _inst_24))))) c (f m n))} {H3 : forall (m : M) (n₁ : N) (n₂ : N), Eq.{succ u5} Pₗ (f m (HAdd.hAdd.{u2, u2, u2} N N N (instHAdd.{u2} N (AddZeroClass.toAdd.{u2} N (AddMonoid.toAddZeroClass.{u2} N (AddCommMonoid.toAddMonoid.{u2} N _inst_6)))) n₁ n₂)) (HAdd.hAdd.{u5, u5, u5} Pₗ Pₗ Pₗ (instHAdd.{u5} Pₗ (AddZeroClass.toAdd.{u5} Pₗ (AddMonoid.toAddZeroClass.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)))) (f m n₁) (f m n₂))} {H4 : forall (c : S) (m : M) (n : N), Eq.{succ u5} Pₗ (f m (HSMul.hSMul.{u1, u2, u2} S N N (instHSMul.{u1, u2} S N (SMulZeroClass.toSMul.{u1, u2} S N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N _inst_6)) (SMulWithZero.toSMulZeroClass.{u1, u2} S N (MonoidWithZero.toZero.{u1} S (Semiring.toMonoidWithZero.{u1} S _inst_2)) (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N _inst_6)) (MulActionWithZero.toSMulWithZero.{u1, u2} S N (Semiring.toMonoidWithZero.{u1} S _inst_2) (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N _inst_6)) (Module.toMulActionWithZero.{u1, u2} S N _inst_2 _inst_6 _inst_17))))) c n)) (HSMul.hSMul.{u1, u5, u5} S Pₗ Pₗ (instHSMul.{u1, u5} S Pₗ (SMulZeroClass.toSMul.{u1, u5} S Pₗ (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} S Pₗ (MonoidWithZero.toZero.{u1} S (Semiring.toMonoidWithZero.{u1} S _inst_2)) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} S Pₗ (Semiring.toMonoidWithZero.{u1} S _inst_2) (AddMonoid.toZero.{u5} Pₗ (AddCommMonoid.toAddMonoid.{u5} Pₗ _inst_12)) (Module.toMulActionWithZero.{u1, u5} S Pₗ _inst_2 _inst_12 _inst_25))))) c (f m n))} (m : M) (n : N), Eq.{succ u5} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => Pₗ) n) (FunLike.coe.{max (succ u2) (succ u5), succ u2, succ u5} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u1, u1, u2, u5} S S _inst_2 _inst_2 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2))) (FunLike.coe.{max (max (succ u4) (succ u2)) (succ u5), succ u4, max (succ u2) (succ u5)} (LinearMap.{u3, u3, u4, max u5 u2} R R _inst_1 _inst_1 (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1)) M (LinearMap.{u1, u1, u2, u5} S S _inst_2 _inst_2 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u2, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2))) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u1, u3, u2, u5} S S R N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) _inst_1 _inst_24 _inst_31)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u1, u1, u2, u5} S S _inst_2 _inst_2 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, u4, max u2 u5} R R M (LinearMap.{u1, u1, u2, u5} S S _inst_2 _inst_2 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) N Pₗ _inst_6 _inst_12 _inst_17 _inst_25) _inst_1 _inst_1 _inst_5 (LinearMap.addCommMonoid.{u1, u1, u2, u5} S S N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2))) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u1, u3, u2, u5} S S R N Pₗ _inst_2 _inst_2 _inst_6 _inst_12 _inst_17 _inst_25 (RingHom.id.{u1} S (Semiring.toNonAssocSemiring.{u1} S _inst_2)) _inst_1 _inst_24 _inst_31) (RingHom.id.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) (LinearMap.mk₂'.{u3, u1, u4, u2, u5} R _inst_1 S _inst_2 M N Pₗ _inst_5 _inst_6 _inst_12 _inst_16 _inst_17 _inst_24 _inst_25 _inst_31 f H1 H2 H3 H4) m) n) (f m n)\nCase conversion may be inaccurate. Consider using '#align linear_map.mk₂'_apply LinearMap.mk₂'_applyₓ'. -/\n@[simp]\ntheorem mk₂'_apply (f : M → N → Pₗ) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk₂' R S f H1 H2 H3 H4 : M →ₗ[R] N →ₗ[S] Pₗ) m n = f m n :=\n  rfl\n#align linear_map.mk₂'_apply LinearMap.mk₂'_apply\n\n/- warning: linear_map.ext₂ -> LinearMap.ext₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} {f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)}, (forall (m : M) (n : N), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f m) n) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) g m) n)) -> (Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) f g)\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} {f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)}, (forall (m : M) (n : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) n) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f m) n) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) g m) n)) -> (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) f g)\nCase conversion may be inaccurate. Consider using '#align linear_map.ext₂ LinearMap.ext₂ₓ'. -/\ntheorem ext₂ {f g : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (H : ∀ m n, f m n = g m n) : f = g :=\n  LinearMap.ext fun m => LinearMap.ext fun n => H m n\n#align linear_map.ext₂ LinearMap.ext₂\n\n/- warning: linear_map.congr_fun₂ -> LinearMap.congr_fun₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} {f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)}, (Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) f g) -> (forall (x : M) (y : N), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) g x) y))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} {f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)}, (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) f g) -> (forall (x : M) (y : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) x) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) x) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) g x) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.congr_fun₂ LinearMap.congr_fun₂ₓ'. -/\ntheorem congr_fun₂ {f g : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (h : f = g) (x y) : f x y = g x y :=\n  LinearMap.congr_fun (LinearMap.congr_fun h x) y\n#align linear_map.congr_fun₂ LinearMap.congr_fun₂\n\nsection\n\nattribute [local instance] SMulCommClass.symm\n\n#print LinearMap.flip /-\n/-- Given a linear map from `M` to linear maps from `N` to `P`, i.e., a bilinear map from `M × N` to\n`P`, change the order of variables and get a linear map from `N` to linear maps from `M` to `P`. -/\ndef flip (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) : N →ₛₗ[σ₁₂] M →ₛₗ[ρ₁₂] P :=\n  mk₂'ₛₗ σ₁₂ ρ₁₂ (fun n m => f m n) (fun n₁ n₂ m => (f m).map_add _ _)\n    (fun c n m => (f m).map_smulₛₗ _ _) (fun n m₁ m₂ => by rw [f.map_add] <;> rfl) fun c n m => by\n    rw [f.map_smulₛₗ] <;> rfl\n#align linear_map.flip LinearMap.flip\n-/\n\nend\n\n/- warning: linear_map.flip_apply -> LinearMap.flip_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (m : M) (n : N), Eq.{succ u7} P (coeFn.{max (succ u5) (succ u7), max (succ u5) (succ u7)} (LinearMap.{u1, u3, u5, u7} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) (fun (_x : LinearMap.{u1, u3, u5, u7} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) => M -> P) (LinearMap.hasCoeToFun.{u1, u3, u5, u7} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u2, u4, u6, max u5 u7} S S₂ _inst_2 _inst_4 σ₁₂ N (LinearMap.{u1, u3, u5, u7} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R₂ S₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂ _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R₂ _inst_3 S₂ _inst_4 P _inst_7 _inst_18 _inst_19 _inst_30))) (fun (_x : LinearMap.{u2, u4, u6, max u5 u7} S S₂ _inst_2 _inst_4 σ₁₂ N (LinearMap.{u1, u3, u5, u7} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R₂ S₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂ _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R₂ _inst_3 S₂ _inst_4 P _inst_7 _inst_18 _inst_19 _inst_30))) => N -> (LinearMap.{u1, u3, u5, u7} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18)) (LinearMap.hasCoeToFun.{u2, u4, u6, max u5 u7} S S₂ N (LinearMap.{u1, u3, u5, u7} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_2 _inst_4 _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R₂ S₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂ _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R₂ _inst_3 S₂ _inst_4 P _inst_7 _inst_18 _inst_19 _inst_30)) σ₁₂) (LinearMap.flip.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f) n) m) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f m) n)\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (m : M) (n : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) m) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => LinearMap.{u7, u6, u5, u4} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) n) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, u4} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u3, max (succ u5) (succ u4)} (LinearMap.{u2, u1, u3, max u4 u5} S S₂ _inst_2 _inst_4 σ₁₂ N (LinearMap.{u7, u6, u5, u4} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u7, u6, u5, u4} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) _inst_17 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u6, u1, u5, u4} R R₂ S₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂ _inst_4 _inst_19 (SMulCommClass.symm.{u4, u6, u1} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18)))) _inst_30))) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => LinearMap.{u7, u6, u5, u4} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, max u5 u4} S S₂ N (LinearMap.{u7, u6, u5, u4} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_2 _inst_4 _inst_6 (LinearMap.addCommMonoid.{u7, u6, u5, u4} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) _inst_17 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u6, u1, u5, u4} R R₂ S₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂ _inst_4 _inst_19 (SMulCommClass.symm.{u4, u6, u1} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18)))) _inst_30)) σ₁₂) (LinearMap.flip.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f) n) m) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f m) n)\nCase conversion may be inaccurate. Consider using '#align linear_map.flip_apply LinearMap.flip_applyₓ'. -/\n@[simp]\ntheorem flip_apply (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (m : M) (n : N) : flip f n m = f m n :=\n  rfl\n#align linear_map.flip_apply LinearMap.flip_apply\n\n/- warning: linear_map.flip_flip -> LinearMap.flip_flip is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} [_inst_34 : SMulCommClass.{u3, u4, u7} R₂ S₂ P (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18)))) (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19))))] (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)), Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 (LinearMap.flip._proof_1.{u4, u3, u7} S₂ _inst_4 R₂ _inst_3 P _inst_7 _inst_19 _inst_18 _inst_34))) (LinearMap.flip.{u2, u1, u4, u3, u6, u5, u7} S _inst_2 R _inst_1 S₂ _inst_4 R₂ _inst_3 N M P _inst_6 _inst_5 _inst_7 _inst_17 _inst_16 _inst_19 _inst_18 _inst_34 σ₁₂ ρ₁₂ (LinearMap.flip.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f)) f\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (_inst_34 : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)), Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 (SMulCommClass.symm.{u4, u1, u6} R₂ S₂ P (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18)))) (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulCommClass.symm.{u4, u6, u1} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18)))) _inst_30)))) (LinearMap.flip.{u2, u7, u1, u6, u3, u5, u4} S _inst_2 R _inst_1 S₂ _inst_4 R₂ _inst_3 N M P _inst_6 _inst_5 _inst_7 _inst_17 _inst_16 _inst_19 _inst_18 (SMulCommClass.symm.{u4, u6, u1} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18)))) _inst_30) σ₁₂ ρ₁₂ (LinearMap.flip.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ _inst_34)) _inst_34\nCase conversion may be inaccurate. Consider using '#align linear_map.flip_flip LinearMap.flip_flipₓ'. -/\n@[simp]\ntheorem flip_flip [SMulCommClass R₂ S₂ P] (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) : f.flip.flip = f :=\n  LinearMap.ext₂ fun x y => (f.flip.flip_apply _ _).trans (f.flip_apply _ _)\n#align linear_map.flip_flip LinearMap.flip_flip\n\nopen BigOperators\n\nvariable {R}\n\n/- warning: linear_map.flip_inj -> LinearMap.flip_inj is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} {f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)}, (Eq.{max (succ u6) (succ (max u5 u7))} (LinearMap.{u2, u4, u6, max u5 u7} S S₂ _inst_2 _inst_4 σ₁₂ N (LinearMap.{u1, u3, u5, u7} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R₂ S₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂ _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R₂ _inst_3 S₂ _inst_4 P _inst_7 _inst_18 _inst_19 _inst_30))) (LinearMap.flip.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f) (LinearMap.flip.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ g)) -> (Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) f g)\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} {f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)}, (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u2, u1, u3, max u4 u5} S S₂ _inst_2 _inst_4 σ₁₂ N (LinearMap.{u7, u6, u5, u4} R R₂ _inst_1 _inst_3 ρ₁₂ M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u7, u6, u5, u4} R R₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂) _inst_17 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u6, u1, u5, u4} R R₂ S₂ M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 ρ₁₂ _inst_4 _inst_19 (SMulCommClass.symm.{u4, u6, u1} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18)))) _inst_30))) (LinearMap.flip.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f) (LinearMap.flip.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ g)) -> (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) f g)\nCase conversion may be inaccurate. Consider using '#align linear_map.flip_inj LinearMap.flip_injₓ'. -/\ntheorem flip_inj {f g : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P} (H : flip f = flip g) : f = g :=\n  ext₂ fun m n => show flip f n m = flip g n m by rw [H]\n#align linear_map.flip_inj LinearMap.flip_inj\n\n/- warning: linear_map.map_zero₂ -> LinearMap.map_zero₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (y : N), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (OfNat.ofNat.{u5} M 0 (OfNat.mk.{u5} M 0 (Zero.zero.{u5} M (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))))))) y) (OfNat.ofNat.{u7} P 0 (OfNat.mk.{u7} P 0 (Zero.zero.{u7} P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))))))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (y : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (OfNat.ofNat.{u5} M 0 (Zero.toOfNat0.{u5} M (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))))) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (OfNat.ofNat.{u5} M 0 (Zero.toOfNat0.{u5} M (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))))) y) (OfNat.ofNat.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) 0 (Zero.toOfNat0.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) _inst_7))))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_zero₂ LinearMap.map_zero₂ₓ'. -/\ntheorem map_zero₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (y) : f 0 y = 0 :=\n  (flip f y).map_zero\n#align linear_map.map_zero₂ LinearMap.map_zero₂\n\n/- warning: linear_map.map_neg₂ -> LinearMap.map_neg₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {N : Type.{u5}} {M' : Type.{u6}} {P' : Type.{u7}} [_inst_6 : AddCommMonoid.{u5} N] [_inst_13 : AddCommGroup.{u6} M'] [_inst_15 : AddCommGroup.{u7} P'] [_inst_17 : Module.{u2, u5} S N _inst_2 _inst_6] [_inst_26 : Module.{u1, u6} R M' _inst_1 (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13)] [_inst_28 : Module.{u3, u7} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_29 : Module.{u4, u7} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_32 : SMulCommClass.{u4, u3, u7} S₂ R₂ P' (SMulZeroClass.toHasSmul.{u4, u7} S₂ P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P' (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P' (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (Module.toMulActionWithZero.{u4, u7} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_29)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P' (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P' (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (Module.toMulActionWithZero.{u3, u7} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_28))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (x : M') (y : N), Eq.{succ u7} P' (coeFn.{max (succ u5) (succ u7), max (succ u5) (succ u7)} (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f (Neg.neg.{u6} M' (SubNegMonoid.toHasNeg.{u6} M' (AddGroup.toSubNegMonoid.{u6} M' (AddCommGroup.toAddGroup.{u6} M' _inst_13))) x)) y) (Neg.neg.{u7} P' (SubNegMonoid.toHasNeg.{u7} P' (AddGroup.toSubNegMonoid.{u7} P' (AddCommGroup.toAddGroup.{u7} P' _inst_15))) (coeFn.{max (succ u5) (succ u7), max (succ u5) (succ u7)} (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f x) y))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {N : Type.{u3}} {M' : Type.{u5}} {P' : Type.{u4}} [_inst_6 : AddCommMonoid.{u3} N] [_inst_13 : AddCommGroup.{u5} M'] [_inst_15 : AddCommGroup.{u4} P'] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_26 : Module.{u7, u5} R M' _inst_1 (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13)] [_inst_28 : Module.{u6, u4} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_29 : Module.{u1, u4} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_32 : SMulCommClass.{u1, u6, u4} S₂ R₂ P' (SMulZeroClass.toSMul.{u1, u4} S₂ P' (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P' (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P' (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (Module.toMulActionWithZero.{u1, u4} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_29)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P' (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P' (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P' (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (Module.toMulActionWithZero.{u6, u4} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_28))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (x : M') (y : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (Neg.neg.{u5} M' (NegZeroClass.toNeg.{u5} M' (SubNegZeroMonoid.toNegZeroClass.{u5} M' (SubtractionMonoid.toSubNegZeroMonoid.{u5} M' (SubtractionCommMonoid.toSubtractionMonoid.{u5} M' (AddCommGroup.toDivisionAddCommMonoid.{u5} M' _inst_13))))) x)) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) (FunLike.coe.{max (max (succ u3) (succ u5)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) M' (fun (_x : M') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f (Neg.neg.{u5} M' (NegZeroClass.toNeg.{u5} M' (SubNegZeroMonoid.toNegZeroClass.{u5} M' (SubtractionMonoid.toSubNegZeroMonoid.{u5} M' (SubtractionCommMonoid.toSubtractionMonoid.{u5} M' (AddCommGroup.toDivisionAddCommMonoid.{u5} M' _inst_13))))) x)) y) (Neg.neg.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') y) (NegZeroClass.toNeg.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') y) (SubNegZeroMonoid.toNegZeroClass.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') y) (SubtractionMonoid.toSubNegZeroMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') y) (SubtractionCommMonoid.toSubtractionMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') y) (AddCommGroup.toDivisionAddCommMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') y) _inst_15))))) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) x) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) (FunLike.coe.{max (max (succ u3) (succ u5)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) M' (fun (_x : M') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f x) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_neg₂ LinearMap.map_neg₂ₓ'. -/\ntheorem map_neg₂ (f : M' →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P') (x y) : f (-x) y = -f x y :=\n  (flip f y).map_neg _\n#align linear_map.map_neg₂ LinearMap.map_neg₂\n\n/- warning: linear_map.map_sub₂ -> LinearMap.map_sub₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {N : Type.{u5}} {M' : Type.{u6}} {P' : Type.{u7}} [_inst_6 : AddCommMonoid.{u5} N] [_inst_13 : AddCommGroup.{u6} M'] [_inst_15 : AddCommGroup.{u7} P'] [_inst_17 : Module.{u2, u5} S N _inst_2 _inst_6] [_inst_26 : Module.{u1, u6} R M' _inst_1 (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13)] [_inst_28 : Module.{u3, u7} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_29 : Module.{u4, u7} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_32 : SMulCommClass.{u4, u3, u7} S₂ R₂ P' (SMulZeroClass.toHasSmul.{u4, u7} S₂ P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P' (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P' (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (Module.toMulActionWithZero.{u4, u7} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_29)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P' (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P' (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (Module.toMulActionWithZero.{u3, u7} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_28))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (x : M') (y : M') (z : N), Eq.{succ u7} P' (coeFn.{max (succ u5) (succ u7), max (succ u5) (succ u7)} (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f (HSub.hSub.{u6, u6, u6} M' M' M' (instHSub.{u6} M' (SubNegMonoid.toHasSub.{u6} M' (AddGroup.toSubNegMonoid.{u6} M' (AddCommGroup.toAddGroup.{u6} M' _inst_13)))) x y)) z) (HSub.hSub.{u7, u7, u7} P' P' P' (instHSub.{u7} P' (SubNegMonoid.toHasSub.{u7} P' (AddGroup.toSubNegMonoid.{u7} P' (AddCommGroup.toAddGroup.{u7} P' _inst_15)))) (coeFn.{max (succ u5) (succ u7), max (succ u5) (succ u7)} (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f x) z) (coeFn.{max (succ u5) (succ u7), max (succ u5) (succ u7)} (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R₂ M' (LinearMap.{u2, u4, u5, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u6} M' _inst_13) (LinearMap.addCommMonoid.{u2, u4, u5, u7} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f y) z))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {N : Type.{u3}} {M' : Type.{u5}} {P' : Type.{u4}} [_inst_6 : AddCommMonoid.{u3} N] [_inst_13 : AddCommGroup.{u5} M'] [_inst_15 : AddCommGroup.{u4} P'] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_26 : Module.{u7, u5} R M' _inst_1 (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13)] [_inst_28 : Module.{u6, u4} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_29 : Module.{u1, u4} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_32 : SMulCommClass.{u1, u6, u4} S₂ R₂ P' (SMulZeroClass.toSMul.{u1, u4} S₂ P' (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P' (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P' (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (Module.toMulActionWithZero.{u1, u4} S₂ P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_29)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P' (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P' (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P' (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (NegZeroClass.toZero.{u4} P' (SubNegZeroMonoid.toNegZeroClass.{u4} P' (SubtractionMonoid.toSubNegZeroMonoid.{u4} P' (SubtractionCommMonoid.toSubtractionMonoid.{u4} P' (AddCommGroup.toDivisionAddCommMonoid.{u4} P' _inst_15))))) (Module.toMulActionWithZero.{u6, u4} R₂ P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_28))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) (x : M') (y : M') (z : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (HSub.hSub.{u5, u5, u5} M' M' M' (instHSub.{u5} M' (SubNegMonoid.toSub.{u5} M' (AddGroup.toSubNegMonoid.{u5} M' (AddCommGroup.toAddGroup.{u5} M' _inst_13)))) x y)) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) (FunLike.coe.{max (max (succ u3) (succ u5)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) M' (fun (_x : M') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f (HSub.hSub.{u5, u5, u5} M' M' M' (instHSub.{u5} M' (SubNegMonoid.toSub.{u5} M' (AddGroup.toSubNegMonoid.{u5} M' (AddCommGroup.toAddGroup.{u5} M' _inst_13)))) x y)) z) (HSub.hSub.{u4, u4, u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) (instHSub.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) (SubNegMonoid.toSub.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) (AddGroup.toSubNegMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) (AddCommGroup.toAddGroup.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') z) _inst_15)))) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) x) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) (FunLike.coe.{max (max (succ u3) (succ u5)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) M' (fun (_x : M') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f x) z) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) y) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P') _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) (FunLike.coe.{max (max (succ u3) (succ u5)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32)) M' (fun (_x : M') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M') => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M' (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29) _inst_1 _inst_3 (AddCommGroup.toAddCommMonoid.{u5} M' _inst_13) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 σ₁₂ _inst_3 _inst_28 _inst_32) ρ₁₂) f y) z))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_sub₂ LinearMap.map_sub₂ₓ'. -/\ntheorem map_sub₂ (f : M' →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P') (x y z) : f (x - y) z = f x z - f y z :=\n  (flip f z).map_sub _ _\n#align linear_map.map_sub₂ LinearMap.map_sub₂\n\n/- warning: linear_map.map_add₂ -> LinearMap.map_add₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (x₁ : M) (x₂ : M) (y : N), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (HAdd.hAdd.{u5, u5, u5} M M M (instHAdd.{u5} M (AddZeroClass.toHasAdd.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)))) x₁ x₂)) y) (HAdd.hAdd.{u7, u7, u7} P P P (instHAdd.{u7} P (AddZeroClass.toHasAdd.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)))) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x₁) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x₂) y))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (x₁ : M) (x₂ : M) (y : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (HAdd.hAdd.{u5, u5, u5} M M M (instHAdd.{u5} M (AddZeroClass.toAdd.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)))) x₁ x₂)) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (HAdd.hAdd.{u5, u5, u5} M M M (instHAdd.{u5} M (AddZeroClass.toAdd.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)))) x₁ x₂)) y) (HAdd.hAdd.{u4, u4, u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (instHAdd.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddZeroClass.toAdd.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddMonoid.toAddZeroClass.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) _inst_7)))) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) x₁) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x₁) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) x₂) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x₂) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_add₂ LinearMap.map_add₂ₓ'. -/\ntheorem map_add₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (x₁ x₂ y) : f (x₁ + x₂) y = f x₁ y + f x₂ y :=\n  (flip f y).map_add _ _\n#align linear_map.map_add₂ LinearMap.map_add₂\n\n/- warning: linear_map.map_smul₂ -> LinearMap.map_smul₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {S₂ : Type.{u3}} [_inst_4 : Semiring.{u3} S₂] {M₂ : Type.{u4}} {N₂ : Type.{u5}} {P₂ : Type.{u6}} [_inst_8 : AddCommMonoid.{u4} M₂] [_inst_9 : AddCommMonoid.{u5} N₂] [_inst_10 : AddCommMonoid.{u6} P₂] [_inst_20 : Module.{u1, u4} R M₂ _inst_1 _inst_8] [_inst_21 : Module.{u2, u5} S N₂ _inst_2 _inst_9] [_inst_22 : Module.{u1, u6} R P₂ _inst_1 _inst_10] [_inst_23 : Module.{u3, u6} S₂ P₂ _inst_4 _inst_10] [_inst_33 : SMulCommClass.{u3, u1, u6} S₂ R P₂ (SMulZeroClass.toHasSmul.{u3, u6} S₂ P₂ (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (SMulWithZero.toSmulZeroClass.{u3, u6} S₂ P₂ (MulZeroClass.toHasZero.{u3} S₂ (MulZeroOneClass.toMulZeroClass.{u3} S₂ (MonoidWithZero.toMulZeroOneClass.{u3} S₂ (Semiring.toMonoidWithZero.{u3} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (MulActionWithZero.toSMulWithZero.{u3, u6} S₂ P₂ (Semiring.toMonoidWithZero.{u3} S₂ _inst_4) (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (Module.toMulActionWithZero.{u3, u6} S₂ P₂ _inst_4 _inst_10 _inst_23)))) (SMulZeroClass.toHasSmul.{u1, u6} R P₂ (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u6} R P₂ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u6} R P₂ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (Module.toMulActionWithZero.{u1, u6} R P₂ _inst_1 _inst_10 _inst_22))))] {σ₁₂ : RingHom.{u2, u3} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u3} S₂ _inst_4)} (f : LinearMap.{u1, u1, u4, max u5 u6} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M₂ (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) (r : R) (x : M₂) (y : N₂), Eq.{succ u6} P₂ (coeFn.{max (succ u5) (succ u6), max (succ u5) (succ u6)} (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) (fun (_x : LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) => N₂ -> P₂) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) (coeFn.{max (succ u4) (succ (max u5 u6)), max (succ u4) (succ (max u5 u6))} (LinearMap.{u1, u1, u4, max u5 u6} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M₂ (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) (fun (_x : LinearMap.{u1, u1, u4, max u5 u6} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M₂ (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) => M₂ -> (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23)) (LinearMap.hasCoeToFun.{u1, u1, u4, max u5 u6} R R M₂ (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) f (SMul.smul.{u1, u4} R M₂ (SMulZeroClass.toHasSmul.{u1, u4} R M₂ (AddZeroClass.toHasZero.{u4} M₂ (AddMonoid.toAddZeroClass.{u4} M₂ (AddCommMonoid.toAddMonoid.{u4} M₂ _inst_8))) (SMulWithZero.toSmulZeroClass.{u1, u4} R M₂ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u4} M₂ (AddMonoid.toAddZeroClass.{u4} M₂ (AddCommMonoid.toAddMonoid.{u4} M₂ _inst_8))) (MulActionWithZero.toSMulWithZero.{u1, u4} R M₂ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u4} M₂ (AddMonoid.toAddZeroClass.{u4} M₂ (AddCommMonoid.toAddMonoid.{u4} M₂ _inst_8))) (Module.toMulActionWithZero.{u1, u4} R M₂ _inst_1 _inst_8 _inst_20)))) r x)) y) (SMul.smul.{u1, u6} R P₂ (SMulZeroClass.toHasSmul.{u1, u6} R P₂ (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u6} R P₂ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u6} R P₂ (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u6} P₂ (AddMonoid.toAddZeroClass.{u6} P₂ (AddCommMonoid.toAddMonoid.{u6} P₂ _inst_10))) (Module.toMulActionWithZero.{u1, u6} R P₂ _inst_1 _inst_10 _inst_22)))) r (coeFn.{max (succ u5) (succ u6), max (succ u5) (succ u6)} (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) (fun (_x : LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) => N₂ -> P₂) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) (coeFn.{max (succ u4) (succ (max u5 u6)), max (succ u4) (succ (max u5 u6))} (LinearMap.{u1, u1, u4, max u5 u6} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M₂ (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) (fun (_x : LinearMap.{u1, u1, u4, max u5 u6} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) M₂ (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) => M₂ -> (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23)) (LinearMap.hasCoeToFun.{u1, u1, u4, max u5 u6} R R M₂ (LinearMap.{u2, u3, u5, u6} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) f x) y))\nbut is expected to have type\n  forall {R : Type.{u6}} [_inst_1 : Semiring.{u6} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M₂ : Type.{u5}} {N₂ : Type.{u3}} {P₂ : Type.{u4}} [_inst_8 : AddCommMonoid.{u5} M₂] [_inst_9 : AddCommMonoid.{u3} N₂] [_inst_10 : AddCommMonoid.{u4} P₂] [_inst_20 : Module.{u6, u5} R M₂ _inst_1 _inst_8] [_inst_21 : Module.{u2, u3} S N₂ _inst_2 _inst_9] [_inst_22 : Module.{u6, u4} R P₂ _inst_1 _inst_10] [_inst_23 : Module.{u1, u4} S₂ P₂ _inst_4 _inst_10] [_inst_33 : SMulCommClass.{u1, u6, u4} S₂ R P₂ (SMulZeroClass.toSMul.{u1, u4} S₂ P₂ (AddMonoid.toZero.{u4} P₂ (AddCommMonoid.toAddMonoid.{u4} P₂ _inst_10)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P₂ (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P₂ (AddCommMonoid.toAddMonoid.{u4} P₂ _inst_10)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P₂ (AddCommMonoid.toAddMonoid.{u4} P₂ _inst_10)) (Module.toMulActionWithZero.{u1, u4} S₂ P₂ _inst_4 _inst_10 _inst_23)))) (SMulZeroClass.toSMul.{u6, u4} R P₂ (AddMonoid.toZero.{u4} P₂ (AddCommMonoid.toAddMonoid.{u4} P₂ _inst_10)) (SMulWithZero.toSMulZeroClass.{u6, u4} R P₂ (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P₂ (AddCommMonoid.toAddMonoid.{u4} P₂ _inst_10)) (MulActionWithZero.toSMulWithZero.{u6, u4} R P₂ (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u4} P₂ (AddCommMonoid.toAddMonoid.{u4} P₂ _inst_10)) (Module.toMulActionWithZero.{u6, u4} R P₂ _inst_1 _inst_10 _inst_22))))] {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u6, u6, u5, max u4 u3} R R _inst_1 _inst_1 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R _inst_1)) M₂ (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) (r : R) (x : M₂) (y : N₂), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M₂) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) (HSMul.hSMul.{u6, u5, u5} R M₂ M₂ (instHSMul.{u6, u5} R M₂ (SMulZeroClass.toSMul.{u6, u5} R M₂ (AddMonoid.toZero.{u5} M₂ (AddCommMonoid.toAddMonoid.{u5} M₂ _inst_8)) (SMulWithZero.toSMulZeroClass.{u6, u5} R M₂ (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u5} M₂ (AddCommMonoid.toAddMonoid.{u5} M₂ _inst_8)) (MulActionWithZero.toSMulWithZero.{u6, u5} R M₂ (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u5} M₂ (AddCommMonoid.toAddMonoid.{u5} M₂ _inst_8)) (Module.toMulActionWithZero.{u6, u5} R M₂ _inst_1 _inst_8 _inst_20))))) r x)) N₂ (fun (_x : N₂) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u6, u6, u5, max u4 u3} R R _inst_1 _inst_1 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R _inst_1)) M₂ (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) M₂ (fun (_x : M₂) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M₂) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u5, max u3 u4} R R M₂ (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R _inst_1))) f (HSMul.hSMul.{u6, u5, u5} R M₂ M₂ (instHSMul.{u6, u5} R M₂ (SMulZeroClass.toSMul.{u6, u5} R M₂ (AddMonoid.toZero.{u5} M₂ (AddCommMonoid.toAddMonoid.{u5} M₂ _inst_8)) (SMulWithZero.toSMulZeroClass.{u6, u5} R M₂ (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u5} M₂ (AddCommMonoid.toAddMonoid.{u5} M₂ _inst_8)) (MulActionWithZero.toSMulWithZero.{u6, u5} R M₂ (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u5} M₂ (AddCommMonoid.toAddMonoid.{u5} M₂ _inst_8)) (Module.toMulActionWithZero.{u6, u5} R M₂ _inst_1 _inst_8 _inst_20))))) r x)) y) (HSMul.hSMul.{u6, u4, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (instHSMul.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (SMulZeroClass.toSMul.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) _inst_10)) (SMulWithZero.toSMulZeroClass.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) _inst_10)) (MulActionWithZero.toSMulWithZero.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) _inst_10)) (Module.toMulActionWithZero.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) y) _inst_1 _inst_10 _inst_22))))) r (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M₂) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) x) N₂ (fun (_x : N₂) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N₂) => P₂) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u6, u6, u5, max u4 u3} R R _inst_1 _inst_1 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R _inst_1)) M₂ (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33)) M₂ (fun (_x : M₂) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M₂) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u5, max u3 u4} R R M₂ (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N₂ P₂ _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R N₂ P₂ _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 σ₁₂ _inst_1 _inst_22 _inst_33) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R _inst_1))) f x) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_smul₂ LinearMap.map_smul₂ₓ'. -/\ntheorem map_smul₂ (f : M₂ →ₗ[R] N₂ →ₛₗ[σ₁₂] P₂) (r : R) (x y) : f (r • x) y = r • f x y :=\n  (flip f y).map_smul _ _\n#align linear_map.map_smul₂ LinearMap.map_smul₂\n\n/- warning: linear_map.map_smulₛₗ₂ -> LinearMap.map_smulₛₗ₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (r : R) (x : M) (y : N), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (SMul.smul.{u1, u5} R M (SMulZeroClass.toHasSmul.{u1, u5} R M (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u5} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u5} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} M (AddMonoid.toAddZeroClass.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5))) (Module.toMulActionWithZero.{u1, u5} R M _inst_1 _inst_5 _inst_16)))) r x)) y) (SMul.smul.{u3, u7} R₂ P (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18)))) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) (fun (_x : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) => R -> R₂) (RingHom.hasCoeToFun.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)) ρ₁₂ r) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x) y))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (r : R) (x : M) (y : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (HSMul.hSMul.{u7, u5, u5} R M M (instHSMul.{u7, u5} R M (SMulZeroClass.toSMul.{u7, u5} R M (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u7, u5} R M (MonoidWithZero.toZero.{u7} R (Semiring.toMonoidWithZero.{u7} R _inst_1)) (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u7, u5} R M (Semiring.toMonoidWithZero.{u7} R _inst_1) (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (Module.toMulActionWithZero.{u7, u5} R M _inst_1 _inst_5 _inst_16))))) r x)) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (HSMul.hSMul.{u7, u5, u5} R M M (instHSMul.{u7, u5} R M (SMulZeroClass.toSMul.{u7, u5} R M (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u7, u5} R M (MonoidWithZero.toZero.{u7} R (Semiring.toMonoidWithZero.{u7} R _inst_1)) (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u7, u5} R M (Semiring.toMonoidWithZero.{u7} R _inst_1) (AddMonoid.toZero.{u5} M (AddCommMonoid.toAddMonoid.{u5} M _inst_5)) (Module.toMulActionWithZero.{u7, u5} R M _inst_1 _inst_5 _inst_16))))) r x)) y) (HSMul.hSMul.{u6, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (instHSMul.{u6, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (SMulZeroClass.toSMul.{u6, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (MonoidWithZero.toZero.{u6} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) (Semiring.toMonoidWithZero.{u6} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) _inst_3)) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (Semiring.toMonoidWithZero.{u6} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) _inst_3) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) _inst_7)) (Module.toMulActionWithZero.{u6, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) r) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) _inst_3 _inst_7 _inst_18))))) (FunLike.coe.{max (succ u7) (succ u6), succ u7, succ u6} (RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R₂) _x) (MulHomClass.toFunLike.{max u7 u6, u7, u6} (RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)) R R₂ (NonUnitalNonAssocSemiring.toMul.{u7} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u7} R (Semiring.toNonAssocSemiring.{u7} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u6} R₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u6} R₂ (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u7 u6, u7, u6} (RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)) R R₂ (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u7} R (Semiring.toNonAssocSemiring.{u7} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u6} R₂ (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u7 u6, u7, u6} (RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)) R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3) (RingHom.instRingHomClassRingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3))))) ρ₁₂ r) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) x) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_smulₛₗ₂ LinearMap.map_smulₛₗ₂ₓ'. -/\ntheorem map_smulₛₗ₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (r : R) (x y) : f (r • x) y = ρ₁₂ r • f x y :=\n  (flip f y).map_smulₛₗ _ _\n#align linear_map.map_smulₛₗ₂ LinearMap.map_smulₛₗ₂\n\n/- warning: linear_map.map_sum₂ -> LinearMap.map_sum₂ is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} {ι : Type.{u8}} (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (t : Finset.{u8} ι) (x : ι -> M) (y : N), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (Finset.sum.{u5, u8} M ι _inst_5 t (fun (i : ι) => x i))) y) (Finset.sum.{u7, u8} P ι _inst_7 t (fun (i : ι) => coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (x i)) y))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} {ι : Type.{u8}} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (t : Finset.{u8} ι) (x : ι -> M) (y : N), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (Finset.sum.{u5, u8} M ι _inst_5 t (fun (i : ι) => x i))) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (Finset.sum.{u5, u8} M ι _inst_5 t (fun (i : ι) => x i))) y) (Finset.sum.{u4, u8} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) ι _inst_7 t (fun (i : ι) => FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (x i)) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (x i)) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_sum₂ LinearMap.map_sum₂ₓ'. -/\ntheorem map_sum₂ {ι : Type _} (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (t : Finset ι) (x : ι → M) (y) :\n    f (∑ i in t, x i) y = ∑ i in t, f (x i) y :=\n  (flip f y).map_sum\n#align linear_map.map_sum₂ LinearMap.map_sum₂\n\n#print LinearMap.domRestrict₂ /-\n/-- Restricting a bilinear map in the second entry -/\ndef domRestrict₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (q : Submodule S N) : M →ₛₗ[ρ₁₂] q →ₛₗ[σ₁₂] P\n    where\n  toFun m := (f m).domRestrict q\n  map_add' m₁ m₂ := LinearMap.ext fun _ => by simp only [map_add, dom_restrict_apply, add_apply]\n  map_smul' c m :=\n    LinearMap.ext fun _ => by simp only [f.map_smulₛₗ, dom_restrict_apply, smul_apply]\n#align linear_map.dom_restrict₂ LinearMap.domRestrict₂\n-/\n\n/- warning: linear_map.dom_restrict₂_apply -> LinearMap.domRestrict₂_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (q : Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) (x : M) (y : coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) => (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) (LinearMap.domRestrict₂.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f q) x) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x) ((fun (a : Type.{u6}) (b : Type.{u6}) [self : HasLiftT.{succ u6, succ u6} a b] => self.0) (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (HasLiftT.mk.{succ u6, succ u6} (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (CoeTCₓ.coe.{succ u6, succ u6} (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (coeBase.{succ u6, succ u6} (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (coeSubtype.{succ u6} N (fun (x : N) => Membership.Mem.{u6, u6} N (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) (SetLike.hasMem.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) x q))))) y))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (q : Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (x : M) (y : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) => P) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) x) (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) (fun (_x : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) (LinearMap.domRestrict₂.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f q) x) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) x) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f x) (Subtype.val.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Set.{u3} N) (Set.instMembershipSet.{u3} N) x (SetLike.coe.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17) q)) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.dom_restrict₂_apply LinearMap.domRestrict₂_applyₓ'. -/\ntheorem domRestrict₂_apply (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (q : Submodule S N) (x : M) (y : q) :\n    f.domRestrict₂ q x y = f x y :=\n  rfl\n#align linear_map.dom_restrict₂_apply LinearMap.domRestrict₂_apply\n\n#print LinearMap.domRestrict₁₂ /-\n/-- Restricting a bilinear map in both components -/\ndef domRestrict₁₂ (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (p : Submodule R M) (q : Submodule S N) :\n    p →ₛₗ[ρ₁₂] q →ₛₗ[σ₁₂] P :=\n  (f.domRestrict p).domRestrict₂ q\n#align linear_map.dom_restrict₁₂ LinearMap.domRestrict₁₂\n-/\n\n/- warning: linear_map.dom_restrict₁₂_apply -> LinearMap.domRestrict₁₂_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : Semiring.{u1} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u3}} [_inst_3 : Semiring.{u3} R₂] {S₂ : Type.{u4}} [_inst_4 : Semiring.{u4} S₂] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_16 : Module.{u1, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u6} S N _inst_2 _inst_6] [_inst_18 : Module.{u3, u7} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S₂ R₂ P (SMulZeroClass.toHasSmul.{u4, u7} S₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S₂ P (MulZeroClass.toHasZero.{u4} S₂ (MulZeroOneClass.toMulZeroClass.{u4} S₂ (MonoidWithZero.toMulZeroOneClass.{u4} S₂ (Semiring.toMonoidWithZero.{u4} S₂ _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S₂ P (Semiring.toMonoidWithZero.{u4} S₂ _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R₂ P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R₂ P (MulZeroClass.toHasZero.{u3} R₂ (MulZeroOneClass.toMulZeroClass.{u3} R₂ (MonoidWithZero.toMulZeroOneClass.{u3} R₂ (Semiring.toMonoidWithZero.{u3} R₂ _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R₂ P (Semiring.toMonoidWithZero.{u3} R₂ _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u1, u3} R R₂ (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u4} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S₂ _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (p : Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) (q : Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) (x : coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) (y : coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q), Eq.{succ u7} P (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) => (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) (Submodule.addCommMonoid.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (Submodule.module.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) (Submodule.addCommMonoid.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (Submodule.module.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _inst_1 _inst_3 (Submodule.addCommMonoid.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (Submodule.module.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u6} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) (LinearMap.domRestrict₁₂.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f p q) x) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₂ M (LinearMap.{u2, u4, u6, u7} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f ((fun (a : Type.{u5}) (b : Type.{u5}) [self : HasLiftT.{succ u5, succ u5} a b] => self.0) (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) M (HasLiftT.mk.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) M (CoeTCₓ.coe.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) M (coeBase.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) p) M (coeSubtype.{succ u5} M (fun (x : M) => Membership.Mem.{u5, u5} M (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.hasMem.{u5, u5} (Submodule.{u1, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u1, u5} R M _inst_1 _inst_5 _inst_16)) x p))))) x)) ((fun (a : Type.{u6}) (b : Type.{u6}) [self : HasLiftT.{succ u6, succ u6} a b] => self.0) (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (HasLiftT.mk.{succ u6, succ u6} (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (CoeTCₓ.coe.{succ u6, succ u6} (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (coeBase.{succ u6, succ u6} (coeSort.{succ u6, succ (succ u6)} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) Type.{u6} (SetLike.hasCoeToSort.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) q) N (coeSubtype.{succ u6} N (fun (x : N) => Membership.Mem.{u6, u6} N (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) (SetLike.hasMem.{u6, u6} (Submodule.{u2, u6} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u6} S N _inst_2 _inst_6 _inst_17)) x q))))) y))\nbut is expected to have type\n  forall {R : Type.{u7}} [_inst_1 : Semiring.{u7} R] {S : Type.{u2}} [_inst_2 : Semiring.{u2} S] {R₂ : Type.{u6}} [_inst_3 : Semiring.{u6} R₂] {S₂ : Type.{u1}} [_inst_4 : Semiring.{u1} S₂] {M : Type.{u5}} {N : Type.{u3}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_16 : Module.{u7, u5} R M _inst_1 _inst_5] [_inst_17 : Module.{u2, u3} S N _inst_2 _inst_6] [_inst_18 : Module.{u6, u4} R₂ P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S₂ P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S₂ R₂ P (SMulZeroClass.toSMul.{u1, u4} S₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S₂ P (MonoidWithZero.toZero.{u1} S₂ (Semiring.toMonoidWithZero.{u1} S₂ _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S₂ P (Semiring.toMonoidWithZero.{u1} S₂ _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S₂ P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R₂ P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R₂ P (MonoidWithZero.toZero.{u6} R₂ (Semiring.toMonoidWithZero.{u6} R₂ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R₂ P (Semiring.toMonoidWithZero.{u6} R₂ _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R₂ P _inst_3 _inst_7 _inst_18))))] {ρ₁₂ : RingHom.{u7, u6} R R₂ (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R₂ _inst_3)} {σ₁₂ : RingHom.{u2, u1} S S₂ (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S₂ _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (p : Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (q : Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (x : Subtype.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.instMembership.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16)) x p)) (y : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) => P) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Subtype.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.instMembership.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16)) x p)) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) x) (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) (fun (_x : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ (Subtype.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.instMembership.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16)) x p)) (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) (Submodule.addCommMonoid.{u7, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (Submodule.module.{u7, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) (Subtype.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.instMembership.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16)) x p)) (fun (_x : Subtype.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.instMembership.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16)) x p)) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Subtype.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.instMembership.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16)) x p)) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ (Subtype.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) (SetLike.instMembership.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16)) x p)) (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19) _inst_1 _inst_3 (Submodule.addCommMonoid.{u7, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂) (Submodule.module.{u7, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ (Subtype.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) (SetLike.instMembership.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17)) x q)) P _inst_2 _inst_4 (Submodule.addCommMonoid.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_7 (Submodule.module.{u2, u3} S N _inst_2 _inst_6 _inst_17 q) _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) (LinearMap.domRestrict₁₂.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R₂ _inst_3 S₂ _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 ρ₁₂ σ₁₂ f p q) x) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) (Subtype.val.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Set.{u5} M) (Set.instMembershipSet.{u5} M) x (SetLike.coe.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16) p)) x)) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R₂ _inst_1 _inst_3 ρ₁₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30)) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R₂ M (LinearMap.{u2, u1, u3, u4} S S₂ _inst_2 _inst_4 σ₁₂ N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S₂ R₂ N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 σ₁₂ _inst_3 _inst_18 _inst_30) ρ₁₂) f (Subtype.val.{succ u5} M (fun (x : M) => Membership.mem.{u5, u5} M (Set.{u5} M) (Set.instMembershipSet.{u5} M) x (SetLike.coe.{u5, u5} (Submodule.{u7, u5} R M _inst_1 _inst_5 _inst_16) M (Submodule.setLike.{u7, u5} R M _inst_1 _inst_5 _inst_16) p)) x)) (Subtype.val.{succ u3} N (fun (x : N) => Membership.mem.{u3, u3} N (Set.{u3} N) (Set.instMembershipSet.{u3} N) x (SetLike.coe.{u3, u3} (Submodule.{u2, u3} S N _inst_2 _inst_6 _inst_17) N (Submodule.setLike.{u2, u3} S N _inst_2 _inst_6 _inst_17) q)) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.dom_restrict₁₂_apply LinearMap.domRestrict₁₂_applyₓ'. -/\ntheorem domRestrict₁₂_apply (f : M →ₛₗ[ρ₁₂] N →ₛₗ[σ₁₂] P) (p : Submodule R M) (q : Submodule S N)\n    (x : p) (y : q) : f.domRestrict₁₂ p q x y = f x y :=\n  rfl\n#align linear_map.dom_restrict₁₂_apply LinearMap.domRestrict₁₂_apply\n\nend Semiring\n\nsection CommSemiring\n\nvariable {R : Type _} [CommSemiring R] {R₂ : Type _} [CommSemiring R₂]\n\nvariable {R₃ : Type _} [CommSemiring R₃] {R₄ : Type _} [CommSemiring R₄]\n\nvariable {M : Type _} {N : Type _} {P : Type _} {Q : Type _}\n\nvariable {Mₗ : Type _} {Nₗ : Type _} {Pₗ : Type _} {Qₗ Qₗ' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]\n\nvariable [AddCommMonoid Mₗ] [AddCommMonoid Nₗ] [AddCommMonoid Pₗ]\n\nvariable [AddCommMonoid Qₗ] [AddCommMonoid Qₗ']\n\nvariable [Module R M] [Module R₂ N] [Module R₃ P] [Module R₄ Q]\n\nvariable [Module R Mₗ] [Module R Nₗ] [Module R Pₗ] [Module R Qₗ] [Module R Qₗ']\n\nvariable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃}\n\nvariable {σ₄₂ : R₄ →+* R₂} {σ₄₃ : R₄ →+* R₃}\n\nvariable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] [RingHomCompTriple σ₄₂ σ₂₃ σ₄₃]\n\nvariable (R)\n\n/- warning: linear_map.mk₂ -> LinearMap.mk₂ is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : M -> Nₗ -> Pₗ), (forall (m₁ : M) (m₂ : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toHasAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m₁ n) (f m₂ n))) -> (forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (Module.toMulActionWithZero.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_14)))) c m) n) (SMul.smul.{u1, u4} R Pₗ (SMulZeroClass.toHasSmul.{u1, u4} R Pₗ (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) c (f m n))) -> (forall (m : M) (n₁ : Nₗ) (n₂ : Nₗ), Eq.{succ u4} Pₗ (f m (HAdd.hAdd.{u3, u3, u3} Nₗ Nₗ Nₗ (instHAdd.{u3} Nₗ (AddZeroClass.toHasAdd.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)))) n₁ n₂)) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toHasAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m n₁) (f m n₂))) -> (forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f m (SMul.smul.{u1, u3} R Nₗ (SMulZeroClass.toHasSmul.{u1, u3} R Nₗ (AddZeroClass.toHasZero.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u3} R Nₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u3} R Nₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10))) (Module.toMulActionWithZero.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_19)))) c n)) (SMul.smul.{u1, u4} R Pₗ (SMulZeroClass.toHasSmul.{u1, u4} R Pₗ (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) c (f m n))) -> (LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.mk₂._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : M -> Nₗ -> Pₗ), (forall (m₁ : M) (m₂ : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m₁ n) (f m₂ n))) -> (forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (HSMul.hSMul.{u1, u2, u2} R M M (instHSMul.{u1, u2} R M (SMulZeroClass.toSMul.{u1, u2} R M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u1, u2} R M (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (Module.toMulActionWithZero.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_14))))) c m) n) (HSMul.hSMul.{u1, u4, u4} R Pₗ Pₗ (instHSMul.{u1, u4} R Pₗ (SMulZeroClass.toSMul.{u1, u4} R Pₗ (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (SMulWithZero.toSMulZeroClass.{u1, u4} R Pₗ (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (MulActionWithZero.toSMulWithZero.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) c (f m n))) -> (forall (m : M) (n₁ : Nₗ) (n₂ : Nₗ), Eq.{succ u4} Pₗ (f m (HAdd.hAdd.{u3, u3, u3} Nₗ Nₗ Nₗ (instHAdd.{u3} Nₗ (AddZeroClass.toAdd.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)))) n₁ n₂)) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m n₁) (f m n₂))) -> (forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f m (HSMul.hSMul.{u1, u3, u3} R Nₗ Nₗ (instHSMul.{u1, u3} R Nₗ (SMulZeroClass.toSMul.{u1, u3} R Nₗ (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (SMulWithZero.toSMulZeroClass.{u1, u3} R Nₗ (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (MulActionWithZero.toSMulWithZero.{u1, u3} R Nₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_19))))) c n)) (HSMul.hSMul.{u1, u4, u4} R Pₗ Pₗ (instHSMul.{u1, u4} R Pₗ (SMulZeroClass.toSMul.{u1, u4} R Pₗ (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (SMulWithZero.toSMulZeroClass.{u1, u4} R Pₗ (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (MulActionWithZero.toSMulWithZero.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) c (f m n))) -> (LinearMap.{u1, u1, u2, max u4 u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))))\nCase conversion may be inaccurate. Consider using '#align linear_map.mk₂ LinearMap.mk₂ₓ'. -/\n/-- Create a bilinear map from a function that is linear in each component.\n\nThis is a shorthand for `mk₂'` for the common case when `R = S`. -/\ndef mk₂ (f : M → Nₗ → Pₗ) (H1 : ∀ m₁ m₂ n, f (m₁ + m₂) n = f m₁ n + f m₂ n)\n    (H2 : ∀ (c : R) (m n), f (c • m) n = c • f m n)\n    (H3 : ∀ m n₁ n₂, f m (n₁ + n₂) = f m n₁ + f m n₂)\n    (H4 : ∀ (c : R) (m n), f m (c • n) = c • f m n) : M →ₗ[R] Nₗ →ₗ[R] Pₗ :=\n  mk₂' R R f H1 H2 H3 H4\n#align linear_map.mk₂ LinearMap.mk₂\n\n/- warning: linear_map.mk₂_apply -> LinearMap.mk₂_apply is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : M -> Nₗ -> Pₗ) {H1 : forall (m₁ : M) (m₂ : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (HAdd.hAdd.{u2, u2, u2} M M M (instHAdd.{u2} M (AddZeroClass.toHasAdd.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toHasAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m₁ n) (f m₂ n))} {H2 : forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (Module.toMulActionWithZero.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_14)))) c m) n) (SMul.smul.{u1, u4} R Pₗ (SMulZeroClass.toHasSmul.{u1, u4} R Pₗ (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) c (f m n))} {H3 : forall (m : M) (n₁ : Nₗ) (n₂ : Nₗ), Eq.{succ u4} Pₗ (f m (HAdd.hAdd.{u3, u3, u3} Nₗ Nₗ Nₗ (instHAdd.{u3} Nₗ (AddZeroClass.toHasAdd.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)))) n₁ n₂)) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toHasAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m n₁) (f m n₂))} {H4 : forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f m (SMul.smul.{u1, u3} R Nₗ (SMulZeroClass.toHasSmul.{u1, u3} R Nₗ (AddZeroClass.toHasZero.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u3} R Nₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u3} R Nₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} Nₗ (AddMonoid.toAddZeroClass.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10))) (Module.toMulActionWithZero.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_19)))) c n)) (SMul.smul.{u1, u4} R Pₗ (SMulZeroClass.toHasSmul.{u1, u4} R Pₗ (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R Pₗ (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) c (f m n))} (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => Nₗ -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u2) (succ (max u3 u4)), max (succ u2) (succ (max u3 u4))} (LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.mk₂._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (fun (_x : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.mk₂._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) => M -> (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, u2, max u3 u4} R R M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.mk₂._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.mk₂.{u1, u2, u3, u4} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 f H1 H2 H3 H4) m) n) (f m n)\nbut is expected to have type\n  forall (R : Type.{u2}) [_inst_1 : CommSemiring.{u2} R] {M : Type.{u3}} {Nₗ : Type.{u1}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_10 : AddCommMonoid.{u1} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u2, u3} R M (CommSemiring.toSemiring.{u2} R _inst_1) _inst_5] [_inst_19 : Module.{u2, u1} R Nₗ (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10] [_inst_20 : Module.{u2, u4} R Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11] (f : M -> Nₗ -> Pₗ) {H1 : forall (m₁ : M) (m₂ : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (HAdd.hAdd.{u3, u3, u3} M M M (instHAdd.{u3} M (AddZeroClass.toAdd.{u3} M (AddMonoid.toAddZeroClass.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)))) m₁ m₂) n) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m₁ n) (f m₂ n))} {H2 : forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f (HSMul.hSMul.{u2, u3, u3} R M M (instHSMul.{u2, u3} R M (SMulZeroClass.toSMul.{u2, u3} R M (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u2, u3} R M (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u2, u3} R M (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u3} M (AddCommMonoid.toAddMonoid.{u3} M _inst_5)) (Module.toMulActionWithZero.{u2, u3} R M (CommSemiring.toSemiring.{u2} R _inst_1) _inst_5 _inst_14))))) c m) n) (HSMul.hSMul.{u2, u4, u4} R Pₗ Pₗ (instHSMul.{u2, u4} R Pₗ (SMulZeroClass.toSMul.{u2, u4} R Pₗ (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (SMulWithZero.toSMulZeroClass.{u2, u4} R Pₗ (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (MulActionWithZero.toSMulWithZero.{u2, u4} R Pₗ (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u2, u4} R Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11 _inst_20))))) c (f m n))} {H3 : forall (m : M) (n₁ : Nₗ) (n₂ : Nₗ), Eq.{succ u4} Pₗ (f m (HAdd.hAdd.{u1, u1, u1} Nₗ Nₗ Nₗ (instHAdd.{u1} Nₗ (AddZeroClass.toAdd.{u1} Nₗ (AddMonoid.toAddZeroClass.{u1} Nₗ (AddCommMonoid.toAddMonoid.{u1} Nₗ _inst_10)))) n₁ n₂)) (HAdd.hAdd.{u4, u4, u4} Pₗ Pₗ Pₗ (instHAdd.{u4} Pₗ (AddZeroClass.toAdd.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)))) (f m n₁) (f m n₂))} {H4 : forall (c : R) (m : M) (n : Nₗ), Eq.{succ u4} Pₗ (f m (HSMul.hSMul.{u2, u1, u1} R Nₗ Nₗ (instHSMul.{u2, u1} R Nₗ (SMulZeroClass.toSMul.{u2, u1} R Nₗ (AddMonoid.toZero.{u1} Nₗ (AddCommMonoid.toAddMonoid.{u1} Nₗ _inst_10)) (SMulWithZero.toSMulZeroClass.{u2, u1} R Nₗ (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u1} Nₗ (AddCommMonoid.toAddMonoid.{u1} Nₗ _inst_10)) (MulActionWithZero.toSMulWithZero.{u2, u1} R Nₗ (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u1} Nₗ (AddCommMonoid.toAddMonoid.{u1} Nₗ _inst_10)) (Module.toMulActionWithZero.{u2, u1} R Nₗ (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 _inst_19))))) c n)) (HSMul.hSMul.{u2, u4, u4} R Pₗ Pₗ (instHSMul.{u2, u4} R Pₗ (SMulZeroClass.toSMul.{u2, u4} R Pₗ (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (SMulWithZero.toSMulZeroClass.{u2, u4} R Pₗ (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (MulActionWithZero.toSMulWithZero.{u2, u4} R Pₗ (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u2, u4} R Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11 _inst_20))))) c (f m n))} (m : M) (n : Nₗ), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Pₗ) n) (FunLike.coe.{max (succ u1) (succ u4), succ u1, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u2, u1, u4} R R (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) m) Nₗ (fun (_x : Nₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u1, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (FunLike.coe.{max (max (succ u3) (succ u1)) (succ u4), succ u3, max (succ u1) (succ u4)} (LinearMap.{u2, u2, u3, max u4 u1} R R (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) M (LinearMap.{u2, u2, u1, u4} R R (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u1, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u2, u2, u1, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_20 (smulCommClass_self.{u2, u4} R Pₗ (CommSemiring.toCommMonoid.{u2} R _inst_1) (MulActionWithZero.toMulAction.{u2, u4} R Pₗ (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u2, u4} R Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11 _inst_20))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u2, u2, u1, u4} R R (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u3, max u1 u4} R R M (LinearMap.{u2, u2, u1, u4} R R (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u1, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u2, u2, u1, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (CommSemiring.toSemiring.{u2} R _inst_1) _inst_20 (smulCommClass_self.{u2, u4} R Pₗ (CommSemiring.toCommMonoid.{u2} R _inst_1) (MulActionWithZero.toMulAction.{u2, u4} R Pₗ (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u2, u4} R Pₗ (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (LinearMap.mk₂.{u2, u3, u1, u4} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 f H1 H2 H3 H4) m) n) (f m n)\nCase conversion may be inaccurate. Consider using '#align linear_map.mk₂_apply LinearMap.mk₂_applyₓ'. -/\n@[simp]\ntheorem mk₂_apply (f : M → Nₗ → Pₗ) {H1 H2 H3 H4} (m : M) (n : Nₗ) :\n    (mk₂ R f H1 H2 H3 H4 : M →ₗ[R] Nₗ →ₗ[R] Pₗ) m n = f m n :=\n  rfl\n#align linear_map.mk₂_apply LinearMap.mk₂_apply\n\nvariable (R M N P)\n\n#print LinearMap.lflip /-\n/-- Given a linear map from `M` to linear maps from `N` to `P`, i.e., a bilinear map `M → N → P`,\nchange the order of variables and get a linear map from `N` to linear maps from `M` to `P`. -/\ndef lflip : (M →ₛₗ[σ₁₃] N →ₛₗ[σ₂₃] P) →ₗ[R₃] N →ₛₗ[σ₂₃] M →ₛₗ[σ₁₃] P\n    where\n  toFun := flip\n  map_add' _ _ := rfl\n  map_smul' _ _ := rfl\n#align linear_map.lflip LinearMap.lflip\n-/\n\nvariable {R M N P}\n\nvariable (f : M →ₛₗ[σ₁₃] N →ₛₗ[σ₂₃] P)\n\n/- warning: linear_map.lflip_apply -> LinearMap.lflip_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R₂ : Type.{u2}} [_inst_2 : CommSemiring.{u2} R₂] {R₃ : Type.{u3}} [_inst_3 : CommSemiring.{u3} R₃] {M : Type.{u4}} {N : Type.{u5}} {P : Type.{u6}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_6 : AddCommMonoid.{u5} N] [_inst_7 : AddCommMonoid.{u6} P] [_inst_14 : Module.{u1, u4} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_15 : Module.{u2, u5} R₂ N (CommSemiring.toSemiring.{u2} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7] {σ₂₃ : RingHom.{u2, u3} R₂ R₃ (Semiring.toNonAssocSemiring.{u2} R₂ (CommSemiring.toSemiring.{u2} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₁₃ : RingHom.{u1, u3} R R₃ (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} (f : LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (m : M) (n : N), Eq.{succ u6} P (coeFn.{max (succ u4) (succ u6), max (succ u4) (succ u6)} (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (fun (_x : LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) => M -> P) (LinearMap.hasCoeToFun.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (coeFn.{max (succ u5) (succ (max u4 u6)), max (succ u5) (succ (max u4 u6))} (LinearMap.{u2, u3, u5, max u4 u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (fun (_x : LinearMap.{u2, u3, u5, max u4 u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) => N -> (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16)) (LinearMap.hasCoeToFun.{u2, u3, u5, max u4 u6} R₂ R₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₂₃) (coeFn.{max (succ (max u4 u5 u6)) (succ (max u5 u4 u6)), max (succ (max u4 u5 u6)) (succ (max u5 u4 u6))} (LinearMap.{u3, u3, max u4 u5 u6, max u5 u4 u6} R₃ R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (LinearMap.{u2, u3, u5, max u4 u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (LinearMap.addCommMonoid.{u1, u3, u4, max u5 u6} R R₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₁₃) (LinearMap.addCommMonoid.{u2, u3, u5, max u4 u6} R₂ R₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₂₃) (LinearMap.module.{u1, u3, u3, u4, max u5 u6} R R₃ R₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_3.{u2, u3, u5, u6} R₂ _inst_2 R₃ _inst_3 N P _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃)) (LinearMap.module.{u2, u3, u3, u5, max u4 u6} R₂ R₃ R₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_4.{u1, u3, u4, u6} R _inst_1 R₃ _inst_3 M P _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃))) (fun (_x : LinearMap.{u3, u3, max u4 u5 u6, max u5 u4 u6} R₃ R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (LinearMap.{u2, u3, u5, max u4 u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (LinearMap.addCommMonoid.{u1, u3, u4, max u5 u6} R R₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₁₃) (LinearMap.addCommMonoid.{u2, u3, u5, max u4 u6} R₂ R₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₂₃) (LinearMap.module.{u1, u3, u3, u4, max u5 u6} R R₃ R₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_3.{u2, u3, u5, u6} R₂ _inst_2 R₃ _inst_3 N P _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃)) (LinearMap.module.{u2, u3, u3, u5, max u4 u6} R₂ R₃ R₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_4.{u1, u3, u4, u6} R _inst_1 R₃ _inst_3 M P _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃))) => (LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) -> (LinearMap.{u2, u3, u5, max u4 u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)))) (LinearMap.hasCoeToFun.{u3, u3, max u4 u5 u6, max u5 u4 u6} R₃ R₃ (LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (LinearMap.{u2, u3, u5, max u4 u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.addCommMonoid.{u1, u3, u4, max u5 u6} R R₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₁₃) (LinearMap.addCommMonoid.{u2, u3, u5, max u4 u6} R₂ R₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₂₃) (LinearMap.module.{u1, u3, u3, u4, max u5 u6} R R₃ R₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_3.{u2, u3, u5, u6} R₂ _inst_2 R₃ _inst_3 N P _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃)) (LinearMap.module.{u2, u3, u3, u5, max u4 u6} R₂ R₃ R₃ N (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_4.{u1, u3, u4, u6} R _inst_1 R₃ _inst_3 M P _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃)) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)))) (LinearMap.lflip.{u1, u2, u3, u4, u5, u6} R _inst_1 R₂ _inst_2 R₃ _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 σ₂₃ σ₁₃) f) n) m) (coeFn.{max (succ u5) (succ u6), max (succ u5) (succ u6)} (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) => N -> P) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (coeFn.{max (succ u4) (succ (max u5 u6)), max (succ u4) (succ (max u5 u6))} (LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (fun (_x : LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) => M -> (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16)) (LinearMap.hasCoeToFun.{u1, u3, u4, max u5 u6} R R₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃) f m) n)\nbut is expected to have type\n  forall {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] {R₂ : Type.{u1}} [_inst_2 : CommSemiring.{u1} R₂] {R₃ : Type.{u3}} [_inst_3 : CommSemiring.{u3} R₃] {M : Type.{u5}} {N : Type.{u2}} {P : Type.{u6}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u2} N] [_inst_7 : AddCommMonoid.{u6} P] [_inst_14 : Module.{u4, u5} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_15 : Module.{u1, u2} R₂ N (CommSemiring.toSemiring.{u1} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7] {σ₂₃ : RingHom.{u1, u3} R₂ R₃ (Semiring.toNonAssocSemiring.{u1} R₂ (CommSemiring.toSemiring.{u1} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₁₃ : RingHom.{u4, u3} R R₃ (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} (f : LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (m : M) (n : N), Eq.{succ u6} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) m) (FunLike.coe.{max (succ u5) (succ u6), succ u5, succ u6} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) n) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) _x) (LinearMap.instFunLikeLinearMap.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (FunLike.coe.{max (max (succ u5) (succ u2)) (succ u6), succ u2, max (succ u5) (succ u6)} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) => LinearMap.{u1, u3, u2, max u6 u5} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) f) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u1, u3, u2, max u5 u6} R₂ R₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₂₃) (FunLike.coe.{max (max (succ u6) (succ u2)) (succ u5), max (max (succ u6) (succ u2)) (succ u5), max (max (succ u6) (succ u2)) (succ u5)} (LinearMap.{u3, u3, max (max u6 u2) u5, max (max u6 u5) u2} R₃ R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (LinearMap.{u1, u3, u2, max u6 u5} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (LinearMap.addCommMonoid.{u4, u3, u5, max u2 u6} R R₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃) (LinearMap.addCommMonoid.{u1, u3, u2, max u5 u6} R₂ R₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₂₃) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, max u2 u6} R R₃ R₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u1, u3, u3, u3, u2, u6} R₂ R₃ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, max u5 u6} R₂ R₃ R₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u3, u3, u3, u5, u6} R R₃ R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))))) (LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (fun (_x : LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) => LinearMap.{u1, u3, u2, max u6 u5} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, max (max u6 u2) u5, max (max u6 u2) u5} R₃ R₃ (LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (LinearMap.{u1, u3, u2, max u6 u5} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.addCommMonoid.{u4, u3, u5, max u2 u6} R R₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃) (LinearMap.addCommMonoid.{u1, u3, u2, max u5 u6} R₂ R₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₂₃) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, max u2 u6} R R₃ R₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u1, u3, u3, u3, u2, u6} R₂ R₃ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, max u5 u6} R₂ R₃ R₃ N (LinearMap.{u4, u3, u5, u6} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u3, u3, u3, u5, u6} R R₃ R₃ R₃ M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R₃ (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (Module.toDistribMulAction.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)))) (LinearMap.lflip.{u4, u1, u3, u5, u2, u6} R _inst_1 R₂ _inst_2 R₃ _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 σ₂₃ σ₁₃) f) n) m) (FunLike.coe.{max (succ u2) (succ u6), succ u2, succ u6} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (FunLike.coe.{max (max (succ u5) (succ u2)) (succ u6), succ u5, max (succ u2) (succ u6)} (LinearMap.{u4, u3, u5, max u6 u2} R R₃ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u4, u3, u5, max u2 u6} R R₃ M (LinearMap.{u1, u3, u2, u6} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃) f m) n)\nCase conversion may be inaccurate. Consider using '#align linear_map.lflip_apply LinearMap.lflip_applyₓ'. -/\n@[simp]\ntheorem lflip_apply (m : M) (n : N) : lflip R M N P f n m = f m n :=\n  rfl\n#align linear_map.lflip_apply LinearMap.lflip_apply\n\nvariable (R Pₗ)\n\n#print LinearMap.lcomp /-\n/-- Composing a linear map `M → N` and a linear map `N → P` to form a linear map `M → P`. -/\ndef lcomp (f : M →ₗ[R] Nₗ) : (Nₗ →ₗ[R] Pₗ) →ₗ[R] M →ₗ[R] Pₗ :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcomp LinearMap.lcomp\n-/\n\nvariable {R Pₗ}\n\n/- warning: linear_map.lcomp_apply -> LinearMap.lcomp_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (g : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (x : M), Eq.{succ u4} Pₗ (coeFn.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (fun (_x : LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) => M -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ (max u3 u4)) (succ (max u2 u4)), max (succ (max u3 u4)) (succ (max u2 u4))} (LinearMap.{u1, u1, max u3 u4, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (fun (_x : LinearMap.{u1, u1, max u3 u4, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) => (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) -> (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, max u3 u4, max u2 u4} R R (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.lcomp.{u1, u2, u3, u4} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 f) g) x) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => Nₗ -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => M -> Nₗ) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f x))\nbut is expected to have type\n  forall {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] {M : Type.{u3}} {Nₗ : Type.{u2}} {Pₗ : Type.{u1}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_10 : AddCommMonoid.{u2} Nₗ] [_inst_11 : AddCommMonoid.{u1} Pₗ] [_inst_14 : Module.{u4, u3} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u2} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11] (f : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (g : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => Pₗ) x) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) g) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u3, u1} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (FunLike.coe.{max (max (succ u3) (succ u2)) (succ u1), max (succ u2) (succ u1), max (succ u3) (succ u1)} (LinearMap.{u4, u4, max u1 u2, max u1 u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u2, u1} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u3, u1} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u2, u1} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, max u2 u1, max u3 u1} R R (LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u2, u1} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u3, u1} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u2, u1} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.lcomp.{u4, u3, u2, u1} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 f) g) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) Nₗ (fun (_x : Nₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u2, u1} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => Nₗ) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u3, u2} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) f x))\nCase conversion may be inaccurate. Consider using '#align linear_map.lcomp_apply LinearMap.lcomp_applyₓ'. -/\n@[simp]\ntheorem lcomp_apply (f : M →ₗ[R] Nₗ) (g : Nₗ →ₗ[R] Pₗ) (x : M) : lcomp R Pₗ f g x = g (f x) :=\n  rfl\n#align linear_map.lcomp_apply LinearMap.lcomp_apply\n\n/- warning: linear_map.lcomp_apply' -> LinearMap.lcomp_apply' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (g : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20), Eq.{max (succ u2) (succ u4)} (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (coeFn.{max (succ (max u3 u4)) (succ (max u2 u4)), max (succ (max u3 u4)) (succ (max u2 u4))} (LinearMap.{u1, u1, max u3 u4, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (fun (_x : LinearMap.{u1, u1, max u3 u4, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) => (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) -> (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, max u3 u4, max u2 u4} R R (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_1.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.lcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.lcomp.{u1, u2, u3, u4} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 f) g) (LinearMap.comp.{u1, u1, u1, u2, u3, u4} R R R M Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHomCompTriple.ids.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g f)\nbut is expected to have type\n  forall {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] {M : Type.{u3}} {Nₗ : Type.{u2}} {Pₗ : Type.{u1}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_10 : AddCommMonoid.{u2} Nₗ] [_inst_11 : AddCommMonoid.{u1} Pₗ] [_inst_14 : Module.{u4, u3} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u2} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11] (f : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (g : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20), Eq.{max (succ u3) (succ u1)} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) g) (FunLike.coe.{max (max (succ u3) (succ u2)) (succ u1), max (succ u2) (succ u1), max (succ u3) (succ u1)} (LinearMap.{u4, u4, max u1 u2, max u1 u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u2, u1} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u3, u1} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u2, u1} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, max u2 u1, max u3 u1} R R (LinearMap.{u4, u4, u2, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, u3, u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u2, u1} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u3, u1} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u2, u1} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u1} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} Pₗ (AddCommMonoid.toAddMonoid.{u1} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u1} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.lcomp.{u4, u3, u2, u1} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 f) g) (LinearMap.comp.{u4, u4, u4, u3, u2, u1} R R R M Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (RingHomCompTriple.ids.{u4, u4} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) g f)\nCase conversion may be inaccurate. Consider using '#align linear_map.lcomp_apply' LinearMap.lcomp_apply'ₓ'. -/\ntheorem lcomp_apply' (f : M →ₗ[R] Nₗ) (g : Nₗ →ₗ[R] Pₗ) : lcomp R Pₗ f g = g ∘ₗ f :=\n  rfl\n#align linear_map.lcomp_apply' LinearMap.lcomp_apply'\n\nvariable (P σ₂₃)\n\n#print LinearMap.lcompₛₗ /-\n/-- Composing a semilinear map `M → N` and a semilinear map `N → P` to form a semilinear map\n`M → P` is itself a linear map. -/\ndef lcompₛₗ (f : M →ₛₗ[σ₁₂] N) : (N →ₛₗ[σ₂₃] P) →ₗ[R₃] M →ₛₗ[σ₁₃] P :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcompₛₗ LinearMap.lcompₛₗ\n-/\n\nvariable {P σ₂₃}\n\ninclude σ₁₃\n\n/- warning: linear_map.lcompₛₗ_apply -> LinearMap.lcompₛₗ_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R₂ : Type.{u2}} [_inst_2 : CommSemiring.{u2} R₂] {R₃ : Type.{u3}} [_inst_3 : CommSemiring.{u3} R₃] {M : Type.{u4}} {N : Type.{u5}} {P : Type.{u6}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_6 : AddCommMonoid.{u5} N] [_inst_7 : AddCommMonoid.{u6} P] [_inst_14 : Module.{u1, u4} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_15 : Module.{u2, u5} R₂ N (CommSemiring.toSemiring.{u2} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7] {σ₁₂ : RingHom.{u1, u2} R R₂ (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R₂ (CommSemiring.toSemiring.{u2} R₂ _inst_2))} {σ₂₃ : RingHom.{u2, u3} R₂ R₃ (Semiring.toNonAssocSemiring.{u2} R₂ (CommSemiring.toSemiring.{u2} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₁₃ : RingHom.{u1, u3} R R₃ (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} [_inst_23 : RingHomCompTriple.{u1, u2, u3} R R₂ R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₂ σ₂₃ σ₁₃] (f : LinearMap.{u1, u2, u4, u5} R R₂ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R₂ _inst_2) σ₁₂ M N _inst_5 _inst_6 _inst_14 _inst_15) (g : LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (x : M), Eq.{succ u6} P (coeFn.{max (succ u4) (succ u6), max (succ u4) (succ u6)} (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (fun (_x : LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) => M -> P) (LinearMap.hasCoeToFun.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (coeFn.{max (succ (max u5 u6)) (succ (max u4 u6)), max (succ (max u5 u6)) (succ (max u4 u6))} (LinearMap.{u3, u3, max u5 u6, max u4 u6} R₃ R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lcompₛₗ._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lcompₛₗ._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (fun (_x : LinearMap.{u3, u3, max u5 u6, max u4 u6} R₃ R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))) (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lcompₛₗ._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lcompₛₗ._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) => (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) -> (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16)) (LinearMap.hasCoeToFun.{u3, u3, max u5 u6, max u4 u6} R₃ R₃ (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u1, u3, u4, u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (CommSemiring.toSemiring.{u3} R₃ _inst_3) (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lcompₛₗ._proof_1.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (LinearMap.module.{u1, u3, u3, u4, u6} R R₃ R₃ M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.lcompₛₗ._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16)) (RingHom.id.{u3} R₃ (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)))) (LinearMap.lcompₛₗ.{u1, u2, u3, u4, u5, u6} R _inst_1 R₂ _inst_2 R₃ _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 σ₁₂ σ₂₃ σ₁₃ _inst_23 f) g) x) (coeFn.{max (succ u5) (succ u6), max (succ u5) (succ u6)} (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) => N -> P) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) g (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearMap.{u1, u2, u4, u5} R R₂ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R₂ _inst_2) σ₁₂ M N _inst_5 _inst_6 _inst_14 _inst_15) (fun (_x : LinearMap.{u1, u2, u4, u5} R R₂ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R₂ _inst_2) σ₁₂ M N _inst_5 _inst_6 _inst_14 _inst_15) => M -> N) (LinearMap.hasCoeToFun.{u1, u2, u4, u5} R R₂ M N (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R₂ _inst_2) _inst_5 _inst_6 _inst_14 _inst_15 σ₁₂) f x))\nbut is expected to have type\n  forall {R : Type.{u6}} [_inst_1 : CommSemiring.{u6} R] {R₂ : Type.{u5}} [_inst_2 : CommSemiring.{u5} R₂] {R₃ : Type.{u2}} [_inst_3 : CommSemiring.{u2} R₃] {M : Type.{u4}} {N : Type.{u3}} {P : Type.{u1}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_6 : AddCommMonoid.{u3} N] [_inst_7 : AddCommMonoid.{u1} P] [_inst_14 : Module.{u6, u4} R M (CommSemiring.toSemiring.{u6} R _inst_1) _inst_5] [_inst_15 : Module.{u5, u3} R₂ N (CommSemiring.toSemiring.{u5} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u2, u1} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7] {σ₁₂ : RingHom.{u6, u5} R R₂ (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (Semiring.toNonAssocSemiring.{u5} R₂ (CommSemiring.toSemiring.{u5} R₂ _inst_2))} {σ₂₃ : RingHom.{u5, u2} R₂ R₃ (Semiring.toNonAssocSemiring.{u5} R₂ (CommSemiring.toSemiring.{u5} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3))} {σ₁₃ : RingHom.{u6, u2} R R₃ (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3))} [_inst_23 : RingHomCompTriple.{u6, u5, u2} R R₂ R₃ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₁₂ σ₂₃ σ₁₃] (f : LinearMap.{u6, u5, u4, u3} R R₂ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R₂ _inst_2) σ₁₂ M N _inst_5 _inst_6 _inst_14 _inst_15) (g : LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) x) (FunLike.coe.{max (succ u4) (succ u1), succ u4, succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) => LinearMap.{u6, u2, u4, u1} R R₃ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) g) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P) _x) (LinearMap.instFunLikeLinearMap.{u6, u2, u4, u1} R R₃ M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (FunLike.coe.{max (max (succ u4) (succ u3)) (succ u1), max (succ u3) (succ u1), max (succ u4) (succ u1)} (LinearMap.{u2, u2, max u1 u3, max u1 u4} R₃ R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3) (CommSemiring.toSemiring.{u2} R₃ _inst_3) (RingHom.id.{u2} R₃ (Semiring.toNonAssocSemiring.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3))) (LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u6, u2, u4, u1} R R₃ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (LinearMap.addCommMonoid.{u5, u2, u3, u1} R₂ R₃ N P (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (LinearMap.addCommMonoid.{u6, u2, u4, u1} R R₃ M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u2, u2, u3, u1} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R₃ P (CommSemiring.toCommMonoid.{u2} R₃ _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R₃ P (Semiring.toMonoidWithZero.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7 _inst_16)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u2, u2, u4, u1} R R₃ R₃ M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R₃ P (CommSemiring.toCommMonoid.{u2} R₃ _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R₃ P (Semiring.toMonoidWithZero.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7 _inst_16))))) (LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) => LinearMap.{u6, u2, u4, u1} R R₃ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, max u3 u1, max u4 u1} R₃ R₃ (LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u6, u2, u4, u1} R R₃ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₁₃ M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R₃ _inst_3) (CommSemiring.toSemiring.{u2} R₃ _inst_3) (LinearMap.addCommMonoid.{u5, u2, u3, u1} R₂ R₃ N P (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (LinearMap.addCommMonoid.{u6, u2, u4, u1} R R₃ M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃) (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u2, u2, u3, u1} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R₃ P (CommSemiring.toCommMonoid.{u2} R₃ _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R₃ P (Semiring.toMonoidWithZero.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7 _inst_16)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u2, u2, u4, u1} R R₃ R₃ M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 σ₁₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R₃ P (CommSemiring.toCommMonoid.{u2} R₃ _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R₃ P (Semiring.toMonoidWithZero.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7 _inst_16)))) (RingHom.id.{u2} R₃ (Semiring.toNonAssocSemiring.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3)))) (LinearMap.lcompₛₗ.{u6, u5, u2, u4, u3, u1} R _inst_1 R₂ _inst_2 R₃ _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 σ₁₂ σ₂₃ σ₁₃ _inst_23 f) g) x) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (LinearMap.{u5, u2, u3, u1} R₂ R₃ (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u5, u2, u3, u1} R₂ R₃ N P (CommSemiring.toSemiring.{u5} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) g (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (LinearMap.{u6, u5, u4, u3} R R₂ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R₂ _inst_2) σ₁₂ M N _inst_5 _inst_6 _inst_14 _inst_15) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => N) _x) (LinearMap.instFunLikeLinearMap.{u6, u5, u4, u3} R R₂ M N (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R₂ _inst_2) _inst_5 _inst_6 _inst_14 _inst_15 σ₁₂) f x))\nCase conversion may be inaccurate. Consider using '#align linear_map.lcompₛₗ_apply LinearMap.lcompₛₗ_applyₓ'. -/\n@[simp]\ntheorem lcompₛₗ_apply (f : M →ₛₗ[σ₁₂] N) (g : N →ₛₗ[σ₂₃] P) (x : M) :\n    lcompₛₗ P σ₂₃ f g x = g (f x) :=\n  rfl\n#align linear_map.lcompₛₗ_apply LinearMap.lcompₛₗ_apply\n\nomit σ₁₃\n\nvariable (R M Nₗ Pₗ)\n\n#print LinearMap.llcomp /-\n/-- Composing a linear map `M → N` and a linear map `N → P` to form a linear map `M → P`. -/\ndef llcomp : (Nₗ →ₗ[R] Pₗ) →ₗ[R] (M →ₗ[R] Nₗ) →ₗ[R] M →ₗ[R] Pₗ :=\n  flip\n    { toFun := lcomp R Pₗ\n      map_add' := fun f f' => ext₂ fun g x => g.map_add _ _\n      map_smul' := fun (c : R) f => ext₂ fun g x => g.map_smul _ _ }\n#align linear_map.llcomp LinearMap.llcomp\n-/\n\nvariable {R M Nₗ Pₗ}\n\nsection\n\n/- warning: linear_map.llcomp_apply -> LinearMap.llcomp_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (g : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (x : M), Eq.{succ u4} Pₗ (coeFn.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (fun (_x : LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) => M -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ (max u2 u3)) (succ (max u2 u4)), max (succ (max u2 u3)) (succ (max u2 u4))} (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (fun (_x : LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) => (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) -> (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ (max u3 u4)) (succ (max (max u2 u3) u2 u4)), max (succ (max u3 u4)) (succ (max (max u2 u3) u2 u4))} (LinearMap.{u1, u1, max u3 u4, max (max u2 u3) u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_3.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, max u2 u3, max u2 u4} R R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M Pₗ _inst_5 _inst_11 _inst_14 _inst_20))) (fun (_x : LinearMap.{u1, u1, max u3 u4, max (max u2 u3) u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_3.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, max u2 u3, max u2 u4} R R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M Pₗ _inst_5 _inst_11 _inst_14 _inst_20))) => (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) -> (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)))) (LinearMap.hasCoeToFun.{u1, u1, max u3 u4, max (max u2 u3) u2 u4} R R (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_3.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, max u2 u3, max u2 u4} R R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M Pₗ _inst_5 _inst_11 _inst_14 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.llcomp.{u1, u2, u3, u4} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20) f) g) x) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => Nₗ -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (fun (_x : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => M -> Nₗ) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g x))\nbut is expected to have type\n  forall {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] {M : Type.{u1}} {Nₗ : Type.{u3}} {Pₗ : Type.{u2}} [_inst_5 : AddCommMonoid.{u1} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u2} Pₗ] [_inst_14 : Module.{u4, u1} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11] (f : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (g : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (x : M), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => Pₗ) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) g) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (FunLike.coe.{max (max (succ u1) (succ u3)) (succ u2), max (succ u1) (succ u3), max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) f) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (fun (_x : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, max u1 u3, max u1 u2} R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (FunLike.coe.{max (max (succ u1) (succ u3)) (succ u2), max (succ u3) (succ u2), max (max (succ u1) (succ u3)) (succ u2)} (LinearMap.{u4, u4, max u2 u3, max (max u2 u1) u3 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.addCommMonoid.{u4, u4, u3, u2} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, max u1 u3, max u1 u2} R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u2} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, max u1 u3, max u1 u2} R R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))))) (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, max u3 u2, max (max u1 u3) u2} R R (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u3, u2} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, max u1 u3, max u1 u2} R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u2} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, max u1 u3, max u1 u2} R R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.llcomp.{u4, u1, u3, u2} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20) f) g) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) Nₗ (fun (_x : Nₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u3, u2} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => Nₗ) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) g x))\nCase conversion may be inaccurate. Consider using '#align linear_map.llcomp_apply LinearMap.llcomp_applyₓ'. -/\n@[simp]\ntheorem llcomp_apply (f : Nₗ →ₗ[R] Pₗ) (g : M →ₗ[R] Nₗ) (x : M) :\n    llcomp R M Nₗ Pₗ f g x = f (g x) :=\n  rfl\n#align linear_map.llcomp_apply LinearMap.llcomp_apply\n\n/- warning: linear_map.llcomp_apply' -> LinearMap.llcomp_apply' is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (g : LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19), Eq.{max (succ u2) (succ u4)} (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (coeFn.{max (succ (max u2 u3)) (succ (max u2 u4)), max (succ (max u2 u3)) (succ (max u2 u4))} (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (fun (_x : LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) => (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) -> (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ (max u3 u4)) (succ (max (max u2 u3) u2 u4)), max (succ (max u3 u4)) (succ (max (max u2 u3) u2 u4))} (LinearMap.{u1, u1, max u3 u4, max (max u2 u3) u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_3.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, max u2 u3, max u2 u4} R R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M Pₗ _inst_5 _inst_11 _inst_14 _inst_20))) (fun (_x : LinearMap.{u1, u1, max u3 u4, max (max u2 u3) u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_3.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, max u2 u3, max u2 u4} R R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M Pₗ _inst_5 _inst_11 _inst_14 _inst_20))) => (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) -> (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)))) (LinearMap.hasCoeToFun.{u1, u1, max u3 u4, max (max u2 u3) u2 u4} R R (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u1, u1, max u2 u3, max u2 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, max u2 u3, max u2 u4} R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_3.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, max u2 u3, max u2 u4} R R R (LinearMap.{u1, u1, u2, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u1, u1, u2, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u4} R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.module.{u1, u1, u1, u2, u3} R R R M Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_19 (LinearMap.llcomp._proof_1.{u1, u3} R _inst_1 Nₗ _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.llcomp._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M Pₗ _inst_5 _inst_11 _inst_14 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.llcomp.{u1, u2, u3, u4} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20) f) g) (LinearMap.comp.{u1, u1, u1, u2, u3, u4} R R R M Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (RingHomCompTriple.ids.{u1, u1} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f g)\nbut is expected to have type\n  forall {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] {M : Type.{u1}} {Nₗ : Type.{u3}} {Pₗ : Type.{u2}} [_inst_5 : AddCommMonoid.{u1} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u2} Pₗ] [_inst_14 : Module.{u4, u1} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11] (f : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (g : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) g) (FunLike.coe.{max (max (succ u1) (succ u3)) (succ u2), max (succ u1) (succ u3), max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) f) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (fun (_x : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) => LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, max u1 u3, max u1 u2} R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (FunLike.coe.{max (max (succ u1) (succ u3)) (succ u2), max (succ u3) (succ u2), max (max (succ u1) (succ u3)) (succ u2)} (LinearMap.{u4, u4, max u2 u3, max (max u2 u1) u3 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.addCommMonoid.{u4, u4, u3, u2} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, max u1 u3, max u1 u2} R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u2} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, max u1 u3, max u1 u2} R R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))))) (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, max u3 u2, max (max u1 u3) u2} R R (LinearMap.{u4, u4, u3, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (LinearMap.{u4, u4, max u3 u1, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u3, u2} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, max u1 u3, max u1 u2} R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u2} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, max u1 u3, max u1 u2} R R R (LinearMap.{u4, u4, u1, u3} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Nₗ _inst_5 _inst_10 _inst_14 _inst_19) (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) M Pₗ _inst_5 _inst_11 _inst_14 _inst_20) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u3} R R R M Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_14 _inst_19 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_19 (smulCommClass_self.{u4, u3} R Nₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R Nₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} Nₗ (AddCommMonoid.toAddMonoid.{u3} Nₗ _inst_10)) (Module.toMulActionWithZero.{u4, u3} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_11 _inst_14 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (MonoidWithZero.toMonoid.{u4} R (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (Module.toDistribMulAction.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) (LinearMap.llcomp.{u4, u1, u3, u2} R _inst_1 M Nₗ Pₗ _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20) f) g) (LinearMap.comp.{u4, u4, u4, u1, u3, u2} R R R M Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5 _inst_10 _inst_11 _inst_14 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (RingHomCompTriple.ids.{u4, u4} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) f g)\nCase conversion may be inaccurate. Consider using '#align linear_map.llcomp_apply' LinearMap.llcomp_apply'ₓ'. -/\ntheorem llcomp_apply' (f : Nₗ →ₗ[R] Pₗ) (g : M →ₗ[R] Nₗ) : llcomp R M Nₗ Pₗ f g = f ∘ₗ g :=\n  rfl\n#align linear_map.llcomp_apply' LinearMap.llcomp_apply'\n\nend\n\n#print LinearMap.compl₂ /-\n/-- Composing a linear map `Q → N` and a bilinear map `M → N → P` to\nform a bilinear map `M → Q → P`. -/\ndef compl₂ (g : Q →ₛₗ[σ₄₂] N) : M →ₛₗ[σ₁₃] Q →ₛₗ[σ₄₃] P :=\n  (lcompₛₗ _ _ g).comp f\n#align linear_map.compl₂ LinearMap.compl₂\n-/\n\ninclude σ₄₃\n\n/- warning: linear_map.compl₂_apply -> LinearMap.compl₂_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R₂ : Type.{u2}} [_inst_2 : CommSemiring.{u2} R₂] {R₃ : Type.{u3}} [_inst_3 : CommSemiring.{u3} R₃] {R₄ : Type.{u4}} [_inst_4 : CommSemiring.{u4} R₄] {M : Type.{u5}} {N : Type.{u6}} {P : Type.{u7}} {Q : Type.{u8}} [_inst_5 : AddCommMonoid.{u5} M] [_inst_6 : AddCommMonoid.{u6} N] [_inst_7 : AddCommMonoid.{u7} P] [_inst_8 : AddCommMonoid.{u8} Q] [_inst_14 : Module.{u1, u5} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_15 : Module.{u2, u6} R₂ N (CommSemiring.toSemiring.{u2} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u3, u7} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7] [_inst_17 : Module.{u4, u8} R₄ Q (CommSemiring.toSemiring.{u4} R₄ _inst_4) _inst_8] {σ₂₃ : RingHom.{u2, u3} R₂ R₃ (Semiring.toNonAssocSemiring.{u2} R₂ (CommSemiring.toSemiring.{u2} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₁₃ : RingHom.{u1, u3} R R₃ (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₄₂ : RingHom.{u4, u2} R₄ R₂ (Semiring.toNonAssocSemiring.{u4} R₄ (CommSemiring.toSemiring.{u4} R₄ _inst_4)) (Semiring.toNonAssocSemiring.{u2} R₂ (CommSemiring.toSemiring.{u2} R₂ _inst_2))} {σ₄₃ : RingHom.{u4, u3} R₄ R₃ (Semiring.toNonAssocSemiring.{u4} R₄ (CommSemiring.toSemiring.{u4} R₄ _inst_4)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} [_inst_24 : RingHomCompTriple.{u4, u2, u3} R₄ R₂ R₃ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₂ σ₂₃ σ₄₃] (f : LinearMap.{u1, u3, u5, max u6 u7} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u6, u7} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (g : LinearMap.{u4, u2, u8, u6} R₄ R₂ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u2} R₂ _inst_2) σ₄₂ Q N _inst_8 _inst_6 _inst_17 _inst_15) (m : M) (q : Q), Eq.{succ u7} P (coeFn.{max (succ u8) (succ u7), max (succ u8) (succ u7)} (LinearMap.{u4, u3, u8, u7} R₄ R₃ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) (fun (_x : LinearMap.{u4, u3, u8, u7} R₄ R₃ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) => Q -> P) (LinearMap.hasCoeToFun.{u4, u3, u8, u7} R₄ R₃ Q P (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃) (coeFn.{max (succ u5) (succ (max u8 u7)), max (succ u5) (succ (max u8 u7))} (LinearMap.{u1, u3, u5, max u8 u7} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u4, u3, u8, u7} R₄ R₃ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u4, u3, u8, u7} R₄ R₃ Q P (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃) _inst_14 (LinearMap.module.{u4, u3, u3, u8, u7} R₄ R₃ R₃ Q P (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.compl₂._proof_2.{u3, u7} R₃ _inst_3 P _inst_7 _inst_16))) (fun (_x : LinearMap.{u1, u3, u5, max u8 u7} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u4, u3, u8, u7} R₄ R₃ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u4, u3, u8, u7} R₄ R₃ Q P (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃) _inst_14 (LinearMap.module.{u4, u3, u3, u8, u7} R₄ R₃ R₃ Q P (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.compl₂._proof_2.{u3, u7} R₃ _inst_3 P _inst_7 _inst_16))) => M -> (LinearMap.{u4, u3, u8, u7} R₄ R₃ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u8 u7} R R₃ M (LinearMap.{u4, u3, u8, u7} R₄ R₃ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u4, u3, u8, u7} R₄ R₃ Q P (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃) _inst_14 (LinearMap.module.{u4, u3, u3, u8, u7} R₄ R₃ R₃ Q P (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.compl₂._proof_2.{u3, u7} R₃ _inst_3 P _inst_7 _inst_16)) σ₁₃) (LinearMap.compl₂.{u1, u2, u3, u4, u5, u6, u7, u8} R _inst_1 R₂ _inst_2 R₃ _inst_3 R₄ _inst_4 M N P Q _inst_5 _inst_6 _inst_7 _inst_8 _inst_14 _inst_15 _inst_16 _inst_17 σ₂₃ σ₁₃ σ₄₂ σ₄₃ _inst_24 f g) m) q) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u3, u6, u7} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u2, u3, u6, u7} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) => N -> P) (LinearMap.hasCoeToFun.{u2, u3, u6, u7} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u6, u7} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u6, u7} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) => M -> (LinearMap.{u2, u3, u6, u7} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R₃ M (LinearMap.{u2, u3, u6, u7} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃) f m) (coeFn.{max (succ u8) (succ u6), max (succ u8) (succ u6)} (LinearMap.{u4, u2, u8, u6} R₄ R₂ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u2} R₂ _inst_2) σ₄₂ Q N _inst_8 _inst_6 _inst_17 _inst_15) (fun (_x : LinearMap.{u4, u2, u8, u6} R₄ R₂ (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u2} R₂ _inst_2) σ₄₂ Q N _inst_8 _inst_6 _inst_17 _inst_15) => Q -> N) (LinearMap.hasCoeToFun.{u4, u2, u8, u6} R₄ R₂ Q N (CommSemiring.toSemiring.{u4} R₄ _inst_4) (CommSemiring.toSemiring.{u2} R₂ _inst_2) _inst_8 _inst_6 _inst_17 _inst_15 σ₄₂) g q))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R₂ : Type.{u7}} [_inst_2 : CommSemiring.{u7} R₂] {R₃ : Type.{u3}} [_inst_3 : CommSemiring.{u3} R₃] {R₄ : Type.{u8}} [_inst_4 : CommSemiring.{u8} R₄] {M : Type.{u2}} {N : Type.{u5}} {P : Type.{u4}} {Q : Type.{u6}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_6 : AddCommMonoid.{u5} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_8 : AddCommMonoid.{u6} Q] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_15 : Module.{u7, u5} R₂ N (CommSemiring.toSemiring.{u7} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u3, u4} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7] [_inst_17 : Module.{u8, u6} R₄ Q (CommSemiring.toSemiring.{u8} R₄ _inst_4) _inst_8] {σ₂₃ : RingHom.{u7, u3} R₂ R₃ (Semiring.toNonAssocSemiring.{u7} R₂ (CommSemiring.toSemiring.{u7} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₁₃ : RingHom.{u1, u3} R R₃ (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₄₂ : RingHom.{u8, u7} R₄ R₂ (Semiring.toNonAssocSemiring.{u8} R₄ (CommSemiring.toSemiring.{u8} R₄ _inst_4)) (Semiring.toNonAssocSemiring.{u7} R₂ (CommSemiring.toSemiring.{u7} R₂ _inst_2))} {σ₄₃ : RingHom.{u8, u3} R₄ R₃ (Semiring.toNonAssocSemiring.{u8} R₄ (CommSemiring.toSemiring.{u8} R₄ _inst_4)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} [_inst_24 : RingHomCompTriple.{u8, u7, u3} R₄ R₂ R₃ (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₂ σ₂₃ σ₄₃] (f : LinearMap.{u1, u3, u2, max u4 u5} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u7, u3, u5, u4} R₂ R₃ (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u7, u3, u5, u4} R₂ R₃ N P (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u3, u3, u5, u4} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) (g : LinearMap.{u8, u7, u6, u5} R₄ R₂ (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u7} R₂ _inst_2) σ₄₂ Q N _inst_8 _inst_6 _inst_17 _inst_15) (m : M) (q : Q), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q) => P) q) (FunLike.coe.{max (succ u4) (succ u6), succ u6, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u8, u3, u6, u4} R₄ R₃ (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) m) Q (fun (_x : Q) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q) => P) _x) (LinearMap.instFunLikeLinearMap.{u8, u3, u6, u4} R₄ R₃ Q P (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃) (FunLike.coe.{max (max (succ u2) (succ u4)) (succ u6), succ u2, max (succ u4) (succ u6)} (LinearMap.{u1, u3, u2, max u4 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u8, u3, u6, u4} R₄ R₃ (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u8, u3, u6, u4} R₄ R₃ Q P (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u8, u3, u3, u6, u4} R₄ R₃ R₃ Q P (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u8, u3, u6, u4} R₄ R₃ (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u1, u3, u2, max u4 u6} R R₃ M (LinearMap.{u8, u3, u6, u4} R₄ R₃ (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₄₃ Q P _inst_8 _inst_7 _inst_17 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u8, u3, u6, u4} R₄ R₃ Q P (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u8, u3, u3, u6, u4} R₄ R₃ R₃ Q P (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 σ₄₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃) (LinearMap.compl₂.{u1, u7, u3, u8, u2, u5, u4, u6} R _inst_1 R₂ _inst_2 R₃ _inst_3 R₄ _inst_4 M N P Q _inst_5 _inst_6 _inst_7 _inst_8 _inst_14 _inst_15 _inst_16 _inst_17 σ₂₃ σ₁₃ σ₄₂ σ₄₃ _inst_24 f g) m) q) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u7, u3, u5, u4} R₂ R₃ (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u7, u3, u5, u4} R₂ R₃ N P (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) (FunLike.coe.{max (max (succ u2) (succ u5)) (succ u4), succ u2, max (succ u5) (succ u4)} (LinearMap.{u1, u3, u2, max u4 u5} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u7, u3, u5, u4} R₂ R₃ (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u7, u3, u5, u4} R₂ R₃ N P (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u3, u3, u5, u4} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u7, u3, u5, u4} R₂ R₃ (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u1, u3, u2, max u5 u4} R R₃ M (LinearMap.{u7, u3, u5, u4} R₂ R₃ (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_5 (LinearMap.addCommMonoid.{u7, u3, u5, u4} R₂ R₃ N P (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u3, u3, u5, u4} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u7} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16)))) σ₁₃) f m) (FunLike.coe.{max (succ u5) (succ u6), succ u6, succ u5} (LinearMap.{u8, u7, u6, u5} R₄ R₂ (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u7} R₂ _inst_2) σ₄₂ Q N _inst_8 _inst_6 _inst_17 _inst_15) Q (fun (_x : Q) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q) => N) _x) (LinearMap.instFunLikeLinearMap.{u8, u7, u6, u5} R₄ R₂ Q N (CommSemiring.toSemiring.{u8} R₄ _inst_4) (CommSemiring.toSemiring.{u7} R₂ _inst_2) _inst_8 _inst_6 _inst_17 _inst_15 σ₄₂) g q))\nCase conversion may be inaccurate. Consider using '#align linear_map.compl₂_apply LinearMap.compl₂_applyₓ'. -/\n@[simp]\ntheorem compl₂_apply (g : Q →ₛₗ[σ₄₂] N) (m : M) (q : Q) : f.compl₂ g m q = f m (g q) :=\n  rfl\n#align linear_map.compl₂_apply LinearMap.compl₂_apply\n\nomit σ₄₃\n\n/- warning: linear_map.compl₂_id -> LinearMap.compl₂_id is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R₂ : Type.{u2}} [_inst_2 : CommSemiring.{u2} R₂] {R₃ : Type.{u3}} [_inst_3 : CommSemiring.{u3} R₃] {M : Type.{u4}} {N : Type.{u5}} {P : Type.{u6}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_6 : AddCommMonoid.{u5} N] [_inst_7 : AddCommMonoid.{u6} P] [_inst_14 : Module.{u1, u4} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_15 : Module.{u2, u5} R₂ N (CommSemiring.toSemiring.{u2} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7] {σ₂₃ : RingHom.{u2, u3} R₂ R₃ (Semiring.toNonAssocSemiring.{u2} R₂ (CommSemiring.toSemiring.{u2} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} {σ₁₃ : RingHom.{u1, u3} R R₃ (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3))} (f : LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R₃ P (CommSemiring.toCommMonoid.{u3} R₃ _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R₃ P (Semiring.toMonoidWithZero.{u3} R₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R₃ P (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_7 _inst_16))))), Eq.{max (succ u4) (succ (max u5 u6))} (LinearMap.{u1, u3, u4, max u5 u6} R R₃ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₁₃ M (LinearMap.{u2, u3, u5, u6} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R₂ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u3} R₃ _inst_3) _inst_16 (LinearMap.compl₂._proof_2.{u3, u6} R₃ _inst_3 P _inst_7 _inst_16))) (LinearMap.compl₂.{u1, u2, u3, u2, u4, u5, u6, u5} R _inst_1 R₂ _inst_2 R₃ _inst_3 R₂ _inst_2 M N P N _inst_5 _inst_6 _inst_7 _inst_6 _inst_14 _inst_15 _inst_16 _inst_15 σ₂₃ σ₁₃ (RingHom.id.{u2} R₂ (Semiring.toNonAssocSemiring.{u2} R₂ (CommSemiring.toSemiring.{u2} R₂ _inst_2))) σ₂₃ (RingHomCompTriple.ids.{u2, u3} R₂ R₃ (CommSemiring.toSemiring.{u2} R₂ _inst_2) (CommSemiring.toSemiring.{u3} R₃ _inst_3) σ₂₃) f (LinearMap.id.{u2, u5} R₂ N (CommSemiring.toSemiring.{u2} R₂ _inst_2) _inst_6 _inst_15)) f\nbut is expected to have type\n  forall {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] {R₂ : Type.{u1}} [_inst_2 : CommSemiring.{u1} R₂] {R₃ : Type.{u2}} [_inst_3 : CommSemiring.{u2} R₃] {M : Type.{u6}} {N : Type.{u5}} {P : Type.{u4}} [_inst_5 : AddCommMonoid.{u6} M] [_inst_6 : AddCommMonoid.{u5} N] [_inst_7 : AddCommMonoid.{u4} P] [_inst_14 : Module.{u3, u6} R M (CommSemiring.toSemiring.{u3} R _inst_1) _inst_5] [_inst_15 : Module.{u1, u5} R₂ N (CommSemiring.toSemiring.{u1} R₂ _inst_2) _inst_6] [_inst_16 : Module.{u2, u4} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7] {σ₂₃ : RingHom.{u1, u2} R₂ R₃ (Semiring.toNonAssocSemiring.{u1} R₂ (CommSemiring.toSemiring.{u1} R₂ _inst_2)) (Semiring.toNonAssocSemiring.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3))} {σ₁₃ : RingHom.{u3, u2} R R₃ (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3))} (f : LinearMap.{u3, u2, u6, max u4 u5} R R₃ (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u2, u5, u4} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u2, u5, u4} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u2, u2, u5, u4} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_16 (smulCommClass_self.{u2, u4} R₃ P (CommSemiring.toCommMonoid.{u2} R₃ _inst_3) (MulActionWithZero.toMulAction.{u2, u4} R₃ P (Semiring.toMonoidWithZero.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u2, u4} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7 _inst_16))))), Eq.{max (max (succ u6) (succ u5)) (succ u4)} (LinearMap.{u3, u2, u6, max u4 u5} R R₃ (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₁₃ M (LinearMap.{u1, u2, u5, u4} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃ N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u2, u5, u4} R₂ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u2, u2, u5, u4} R₂ R₃ R₃ N P (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 σ₂₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_16 (smulCommClass_self.{u2, u4} R₃ P (CommSemiring.toCommMonoid.{u2} R₃ _inst_3) (MulActionWithZero.toMulAction.{u2, u4} R₃ P (Semiring.toMonoidWithZero.{u2} R₃ (CommSemiring.toSemiring.{u2} R₃ _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u2, u4} R₃ P (CommSemiring.toSemiring.{u2} R₃ _inst_3) _inst_7 _inst_16))))) (LinearMap.compl₂.{u3, u1, u2, u1, u6, u5, u4, u5} R _inst_1 R₂ _inst_2 R₃ _inst_3 R₂ _inst_2 M N P N _inst_5 _inst_6 _inst_7 _inst_6 _inst_14 _inst_15 _inst_16 _inst_15 σ₂₃ σ₁₃ (RingHom.id.{u1} R₂ (Semiring.toNonAssocSemiring.{u1} R₂ (CommSemiring.toSemiring.{u1} R₂ _inst_2))) σ₂₃ (RingHomCompTriple.ids.{u1, u2} R₂ R₃ (CommSemiring.toSemiring.{u1} R₂ _inst_2) (CommSemiring.toSemiring.{u2} R₃ _inst_3) σ₂₃) f (LinearMap.id.{u1, u5} R₂ N (CommSemiring.toSemiring.{u1} R₂ _inst_2) _inst_6 _inst_15)) f\nCase conversion may be inaccurate. Consider using '#align linear_map.compl₂_id LinearMap.compl₂_idₓ'. -/\n@[simp]\ntheorem compl₂_id : f.compl₂ LinearMap.id = f :=\n  by\n  ext\n  rw [compl₂_apply, id_coe, id.def]\n#align linear_map.compl₂_id LinearMap.compl₂_id\n\n#print LinearMap.compl₁₂ /-\n/-- Composing linear maps `Q → M` and `Q' → N` with a bilinear map `M → N → P` to\nform a bilinear map `Q → Q' → P`. -/\ndef compl₁₂ (f : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Qₗ →ₗ[R] Mₗ) (g' : Qₗ' →ₗ[R] Nₗ) :\n    Qₗ →ₗ[R] Qₗ' →ₗ[R] Pₗ :=\n  (f.comp g).compl₂ g'\n#align linear_map.compl₁₂ LinearMap.compl₁₂\n-/\n\n/- warning: linear_map.compl₁₂_apply -> LinearMap.compl₁₂_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {Mₗ : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} {Qₗ : Type.{u5}} {Qₗ' : Type.{u6}} [_inst_9 : AddCommMonoid.{u2} Mₗ] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_12 : AddCommMonoid.{u5} Qₗ] [_inst_13 : AddCommMonoid.{u6} Qₗ'] [_inst_18 : Module.{u1, u2} R Mₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] [_inst_21 : Module.{u1, u5} R Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12] [_inst_22 : Module.{u1, u6} R Qₗ' (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13] (f : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) (g : LinearMap.{u1, u1, u5, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) (g' : LinearMap.{u1, u1, u6, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) (x : Qₗ) (y : Qₗ'), Eq.{succ u4} Pₗ (coeFn.{max (succ u6) (succ u4), max (succ u6) (succ u4)} (LinearMap.{u1, u1, u6, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) (fun (_x : LinearMap.{u1, u1, u6, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) => Qₗ' -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u6, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u5) (succ (max u6 u4)), max (succ u5) (succ (max u6 u4))} (LinearMap.{u1, u1, u5, max u6 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ (LinearMap.{u1, u1, u6, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u1, u1, u6, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_21 (LinearMap.module.{u1, u1, u1, u6, u4} R R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.compl₁₂._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (fun (_x : LinearMap.{u1, u1, u5, max u6 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ (LinearMap.{u1, u1, u6, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u1, u1, u6, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_21 (LinearMap.module.{u1, u1, u1, u6, u4} R R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.compl₁₂._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) => Qₗ -> (LinearMap.{u1, u1, u6, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, u5, max u6 u4} R R Qₗ (LinearMap.{u1, u1, u6, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12 (LinearMap.addCommMonoid.{u1, u1, u6, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_21 (LinearMap.module.{u1, u1, u1, u6, u4} R R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.compl₁₂._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.compl₁₂.{u1, u2, u3, u4, u5, u6} R _inst_1 Mₗ Nₗ Pₗ Qₗ Qₗ' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f g g') x) y) (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => Nₗ -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u2) (succ (max u3 u4)), max (succ u2) (succ (max u3 u4))} (LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) (fun (_x : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) => Mₗ -> (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, u2, max u3 u4} R R Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f (coeFn.{max (succ u5) (succ u2), max (succ u5) (succ u2)} (LinearMap.{u1, u1, u5, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) (fun (_x : LinearMap.{u1, u1, u5, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) => Qₗ -> Mₗ) (LinearMap.hasCoeToFun.{u1, u1, u5, u2} R R Qₗ Mₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12 _inst_9 _inst_21 _inst_18 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g x)) (coeFn.{max (succ u6) (succ u3), max (succ u6) (succ u3)} (LinearMap.{u1, u1, u6, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) (fun (_x : LinearMap.{u1, u1, u6, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) => Qₗ' -> Nₗ) (LinearMap.hasCoeToFun.{u1, u1, u6, u3} R R Qₗ' Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_10 _inst_22 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g' y))\nbut is expected to have type\n  forall {R : Type.{u6}} [_inst_1 : CommSemiring.{u6} R] {Mₗ : Type.{u5}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} {Qₗ : Type.{u2}} {Qₗ' : Type.{u1}} [_inst_9 : AddCommMonoid.{u5} Mₗ] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_12 : AddCommMonoid.{u2} Qₗ] [_inst_13 : AddCommMonoid.{u1} Qₗ'] [_inst_18 : Module.{u6, u5} R Mₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_9] [_inst_19 : Module.{u6, u3} R Nₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10] [_inst_20 : Module.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11] [_inst_21 : Module.{u6, u2} R Qₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12] [_inst_22 : Module.{u6, u1} R Qₗ' (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13] (f : LinearMap.{u6, u6, u5, max u4 u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Mₗ (LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) (g : LinearMap.{u6, u6, u2, u5} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) (g' : LinearMap.{u6, u6, u1, u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) (x : Qₗ) (y : Qₗ'), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ') => Pₗ) y) (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ) => LinearMap.{u6, u6, u1, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) x) Qₗ' (fun (_x : Qₗ') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ') => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u1, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) (FunLike.coe.{max (max (succ u4) (succ u2)) (succ u1), succ u2, max (succ u4) (succ u1)} (LinearMap.{u6, u6, u2, max u4 u1} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ (LinearMap.{u6, u6, u1, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u6, u6, u1, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_21 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u1, u4} R R R Qₗ' Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) Qₗ (fun (_x : Qₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ) => LinearMap.{u6, u6, u1, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, max u4 u1} R R Qₗ (LinearMap.{u6, u6, u1, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12 (LinearMap.addCommMonoid.{u6, u6, u1, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_21 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u1, u4} R R R Qₗ' Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) (LinearMap.compl₁₂.{u6, u5, u3, u4, u2, u1} R _inst_1 Mₗ Nₗ Pₗ Qₗ Qₗ' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f g g') x) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Mₗ) => LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (LinearMap.{u6, u6, u2, u5} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) Qₗ (fun (a : Qₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ) => Mₗ) a) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, u5} R R Qₗ Mₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12 _inst_9 _inst_21 _inst_18 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) g x)) Nₗ (fun (_x : Nₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) (FunLike.coe.{max (max (succ u5) (succ u3)) (succ u4), succ u5, max (succ u3) (succ u4)} (LinearMap.{u6, u6, u5, max u4 u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Mₗ (LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) Mₗ (fun (_x : Mₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Mₗ) => LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u5, max u3 u4} R R Mₗ (LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) f (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (LinearMap.{u6, u6, u2, u5} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) Qₗ (fun (_x : Qₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ) => Mₗ) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, u5} R R Qₗ Mₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12 _inst_9 _inst_21 _inst_18 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) g x)) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (LinearMap.{u6, u6, u1, u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) Qₗ' (fun (_x : Qₗ') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ') => Nₗ) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u1, u3} R R Qₗ' Nₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_10 _inst_22 _inst_19 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) g' y))\nCase conversion may be inaccurate. Consider using '#align linear_map.compl₁₂_apply LinearMap.compl₁₂_applyₓ'. -/\n@[simp]\ntheorem compl₁₂_apply (f : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Qₗ →ₗ[R] Mₗ) (g' : Qₗ' →ₗ[R] Nₗ) (x : Qₗ)\n    (y : Qₗ') : f.compl₁₂ g g' x y = f (g x) (g' y) :=\n  rfl\n#align linear_map.compl₁₂_apply LinearMap.compl₁₂_apply\n\n/- warning: linear_map.compl₁₂_id_id -> LinearMap.compl₁₂_id_id is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {Mₗ : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} [_inst_9 : AddCommMonoid.{u2} Mₗ] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_18 : Module.{u1, u2} R Mₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))), Eq.{max (succ u2) (succ (max u3 u4))} (LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.compl₁₂._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (LinearMap.compl₁₂.{u1, u2, u3, u4, u2, u3} R _inst_1 Mₗ Nₗ Pₗ Mₗ Nₗ _inst_9 _inst_10 _inst_11 _inst_9 _inst_10 _inst_18 _inst_19 _inst_20 _inst_18 _inst_19 f (LinearMap.id.{u1, u2} R Mₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9 _inst_18) (LinearMap.id.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_19)) f\nbut is expected to have type\n  forall {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] {Mₗ : Type.{u3}} {Nₗ : Type.{u1}} {Pₗ : Type.{u2}} [_inst_9 : AddCommMonoid.{u3} Mₗ] [_inst_10 : AddCommMonoid.{u1} Nₗ] [_inst_11 : AddCommMonoid.{u2} Pₗ] [_inst_18 : Module.{u4, u3} R Mₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_9] [_inst_19 : Module.{u4, u1} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11] (f : LinearMap.{u4, u4, u3, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Mₗ (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))), Eq.{max (max (succ u3) (succ u1)) (succ u2)} (LinearMap.{u4, u4, u3, max u2 u1} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Mₗ (LinearMap.{u4, u4, u1, u2} R R (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u4} R (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1))) (CommSemiring.toSemiring.{u4} R _inst_1) _inst_20 (smulCommClass_self.{u4, u2} R Pₗ (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R Pₗ (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} Pₗ (AddCommMonoid.toAddMonoid.{u2} Pₗ _inst_11)) (Module.toMulActionWithZero.{u4, u2} R Pₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.compl₁₂.{u4, u3, u1, u2, u3, u1} R _inst_1 Mₗ Nₗ Pₗ Mₗ Nₗ _inst_9 _inst_10 _inst_11 _inst_9 _inst_10 _inst_18 _inst_19 _inst_20 _inst_18 _inst_19 f (LinearMap.id.{u4, u3} R Mₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_9 _inst_18) (LinearMap.id.{u4, u1} R Nₗ (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)) f\nCase conversion may be inaccurate. Consider using '#align linear_map.compl₁₂_id_id LinearMap.compl₁₂_id_idₓ'. -/\n@[simp]\ntheorem compl₁₂_id_id (f : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ) : f.compl₁₂ LinearMap.id LinearMap.id = f :=\n  by\n  ext\n  simp_rw [compl₁₂_apply, id_coe, id.def]\n#align linear_map.compl₁₂_id_id LinearMap.compl₁₂_id_id\n\n/- warning: linear_map.compl₁₂_inj -> LinearMap.compl₁₂_inj is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {Mₗ : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} {Qₗ : Type.{u5}} {Qₗ' : Type.{u6}} [_inst_9 : AddCommMonoid.{u2} Mₗ] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_12 : AddCommMonoid.{u5} Qₗ] [_inst_13 : AddCommMonoid.{u6} Qₗ'] [_inst_18 : Module.{u1, u2} R Mₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] [_inst_21 : Module.{u1, u5} R Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12] [_inst_22 : Module.{u1, u6} R Qₗ' (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13] {f₁ : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))} {f₂ : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))} {g : LinearMap.{u1, u1, u5, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18} {g' : LinearMap.{u1, u1, u6, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19}, (Function.Surjective.{succ u5, succ u2} Qₗ Mₗ (coeFn.{max (succ u5) (succ u2), max (succ u5) (succ u2)} (LinearMap.{u1, u1, u5, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) (fun (_x : LinearMap.{u1, u1, u5, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) => Qₗ -> Mₗ) (LinearMap.hasCoeToFun.{u1, u1, u5, u2} R R Qₗ Mₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12 _inst_9 _inst_21 _inst_18 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g)) -> (Function.Surjective.{succ u6, succ u3} Qₗ' Nₗ (coeFn.{max (succ u6) (succ u3), max (succ u6) (succ u3)} (LinearMap.{u1, u1, u6, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) (fun (_x : LinearMap.{u1, u1, u6, u3} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) => Qₗ' -> Nₗ) (LinearMap.hasCoeToFun.{u1, u1, u6, u3} R R Qₗ' Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_10 _inst_22 _inst_19 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g')) -> (Iff (Eq.{max (succ u5) (succ (max u6 u4))} (LinearMap.{u1, u1, u5, max u6 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ (LinearMap.{u1, u1, u6, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u1, u1, u6, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_21 (LinearMap.module.{u1, u1, u1, u6, u4} R R R Qₗ' Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (LinearMap.compl₁₂._proof_2.{u1, u4} R _inst_1 Pₗ _inst_11 _inst_20))) (LinearMap.compl₁₂.{u1, u2, u3, u4, u5, u6} R _inst_1 Mₗ Nₗ Pₗ Qₗ Qₗ' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f₁ g g') (LinearMap.compl₁₂.{u1, u2, u3, u4, u5, u6} R _inst_1 Mₗ Nₗ Pₗ Qₗ Qₗ' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f₂ g g')) (Eq.{max (succ u2) (succ (max u3 u4))} (LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Mₗ (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_18 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) f₁ f₂))\nbut is expected to have type\n  forall {R : Type.{u6}} [_inst_1 : CommSemiring.{u6} R] {Mₗ : Type.{u5}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} {Qₗ : Type.{u2}} {Qₗ' : Type.{u1}} [_inst_9 : AddCommMonoid.{u5} Mₗ] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_12 : AddCommMonoid.{u2} Qₗ] [_inst_13 : AddCommMonoid.{u1} Qₗ'] [_inst_18 : Module.{u6, u5} R Mₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_9] [_inst_19 : Module.{u6, u3} R Nₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10] [_inst_20 : Module.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11] [_inst_21 : Module.{u6, u2} R Qₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12] [_inst_22 : Module.{u6, u1} R Qₗ' (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13] {f₁ : LinearMap.{u6, u6, u5, max u4 u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Mₗ (LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))} {f₂ : LinearMap.{u6, u6, u5, max u4 u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Mₗ (LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))} {g : LinearMap.{u6, u6, u2, u5} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18} {g' : LinearMap.{u6, u6, u1, u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19}, (Function.Surjective.{succ u2, succ u5} Qₗ Mₗ (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (LinearMap.{u6, u6, u2, u5} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ Mₗ _inst_12 _inst_9 _inst_21 _inst_18) Qₗ (fun (_x : Qₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ) => Mₗ) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, u5} R R Qₗ Mₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12 _inst_9 _inst_21 _inst_18 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) g)) -> (Function.Surjective.{succ u1, succ u3} Qₗ' Nₗ (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (LinearMap.{u6, u6, u1, u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Nₗ _inst_13 _inst_10 _inst_22 _inst_19) Qₗ' (fun (_x : Qₗ') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Qₗ') => Nₗ) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u1, u3} R R Qₗ' Nₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_10 _inst_22 _inst_19 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) g')) -> (Iff (Eq.{max (max (succ u4) (succ u2)) (succ u1)} (LinearMap.{u6, u6, u2, max u4 u1} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ (LinearMap.{u6, u6, u1, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Qₗ' Pₗ _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u6, u6, u1, u4} R R Qₗ' Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_21 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u1, u4} R R R Qₗ' Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13 _inst_11 _inst_22 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) (LinearMap.compl₁₂.{u6, u5, u3, u4, u2, u1} R _inst_1 Mₗ Nₗ Pₗ Qₗ Qₗ' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f₁ g g') (LinearMap.compl₁₂.{u6, u5, u3, u4, u2, u1} R _inst_1 Mₗ Nₗ Pₗ Qₗ Qₗ' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f₂ g g')) (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u6, u6, u5, max u4 u3} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Mₗ (LinearMap.{u6, u6, u3, u4} R R (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)))) _inst_18 (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u6, u6, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1))) (CommSemiring.toSemiring.{u6} R _inst_1) _inst_20 (smulCommClass_self.{u6, u4} R Pₗ (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R Pₗ (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11)) (Module.toMulActionWithZero.{u6, u4} R Pₗ (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) f₁ f₂))\nCase conversion may be inaccurate. Consider using '#align linear_map.compl₁₂_inj LinearMap.compl₁₂_injₓ'. -/\ntheorem compl₁₂_inj {f₁ f₂ : Mₗ →ₗ[R] Nₗ →ₗ[R] Pₗ} {g : Qₗ →ₗ[R] Mₗ} {g' : Qₗ' →ₗ[R] Nₗ}\n    (hₗ : Function.Surjective g) (hᵣ : Function.Surjective g') :\n    f₁.compl₁₂ g g' = f₂.compl₁₂ g g' ↔ f₁ = f₂ :=\n  by\n  constructor <;> intro h\n  · -- B₁.comp l r = B₂.comp l r → B₁ = B₂\n    ext (x y)\n    cases' hₗ x with x' hx\n    subst hx\n    cases' hᵣ y with y' hy\n    subst hy\n    convert LinearMap.congr_fun₂ h x' y'\n  ·-- B₁ = B₂ → B₁.comp l r = B₂.comp l r\n    subst h\n#align linear_map.compl₁₂_inj LinearMap.compl₁₂_inj\n\n#print LinearMap.compr₂ /-\n/-- Composing a linear map `P → Q` and a bilinear map `M → N → P` to\nform a bilinear map `M → N → Q`. -/\ndef compr₂ (f : M →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Pₗ →ₗ[R] Qₗ) : M →ₗ[R] Nₗ →ₗ[R] Qₗ :=\n  llcomp R Nₗ Pₗ Qₗ g ∘ₗ f\n#align linear_map.compr₂ LinearMap.compr₂\n-/\n\n/- warning: linear_map.compr₂_apply -> LinearMap.compr₂_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {Nₗ : Type.{u3}} {Pₗ : Type.{u4}} {Qₗ : Type.{u5}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} Nₗ] [_inst_11 : AddCommMonoid.{u4} Pₗ] [_inst_12 : AddCommMonoid.{u5} Qₗ] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R Nₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] [_inst_21 : Module.{u1, u5} R Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12] (f : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) (g : LinearMap.{u1, u1, u4, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Pₗ Qₗ _inst_11 _inst_12 _inst_20 _inst_21) (m : M) (n : Nₗ), Eq.{succ u5} Qₗ (coeFn.{max (succ u3) (succ u5), max (succ u3) (succ u5)} (LinearMap.{u1, u1, u3, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) (fun (_x : LinearMap.{u1, u1, u3, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) => Nₗ -> Qₗ) (LinearMap.hasCoeToFun.{u1, u1, u3, u5} R R Nₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u2) (succ (max u3 u5)), max (succ u2) (succ (max u3 u5))} (LinearMap.{u1, u1, u2, max u3 u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u5} R R Nₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u5} R R R Nₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_21 (LinearMap.compr₂._proof_2.{u1, u5} R _inst_1 Qₗ _inst_12 _inst_21))) (fun (_x : LinearMap.{u1, u1, u2, max u3 u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u5} R R Nₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u5} R R R Nₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_21 (LinearMap.compr₂._proof_2.{u1, u5} R _inst_1 Qₗ _inst_12 _inst_21))) => M -> (LinearMap.{u1, u1, u3, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21)) (LinearMap.hasCoeToFun.{u1, u1, u2, max u3 u5} R R M (LinearMap.{u1, u1, u3, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u5} R R Nₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u5} R R R Nₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_21 (LinearMap.compr₂._proof_2.{u1, u5} R _inst_1 Qₗ _inst_12 _inst_21)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.compr₂.{u1, u2, u3, u4, u5} R _inst_1 M Nₗ Pₗ Qₗ _inst_5 _inst_10 _inst_11 _inst_12 _inst_14 _inst_19 _inst_20 _inst_21 f g) m) n) (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearMap.{u1, u1, u4, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Pₗ Qₗ _inst_11 _inst_12 _inst_20 _inst_21) (fun (_x : LinearMap.{u1, u1, u4, u5} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Pₗ Qₗ _inst_11 _inst_12 _inst_20 _inst_21) => Pₗ -> Qₗ) (LinearMap.hasCoeToFun.{u1, u1, u4, u5} R R Pₗ Qₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_12 _inst_20 _inst_21 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) g (coeFn.{max (succ u3) (succ u4), max (succ u3) (succ u4)} (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (fun (_x : LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) => Nₗ -> Pₗ) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u2) (succ (max u3 u4)), max (succ u2) (succ (max u3 u4))} (LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) (fun (_x : LinearMap.{u1, u1, u2, max u3 u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) => M -> (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, u2, max u3 u4} R R M (LinearMap.{u1, u1, u3, u4} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) _inst_14 (LinearMap.module.{u1, u1, u1, u3, u4} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_20 (smulCommClass_self.{u1, u4} R Pₗ (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R Pₗ (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} Pₗ (AddMonoid.toAddZeroClass.{u4} Pₗ (AddCommMonoid.toAddMonoid.{u4} Pₗ _inst_11))) (Module.toMulActionWithZero.{u1, u4} R Pₗ (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) f m) n))\nbut is expected to have type\n  forall {R : Type.{u5}} [_inst_1 : CommSemiring.{u5} R] {M : Type.{u4}} {Nₗ : Type.{u2}} {Pₗ : Type.{u3}} {Qₗ : Type.{u1}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_10 : AddCommMonoid.{u2} Nₗ] [_inst_11 : AddCommMonoid.{u3} Pₗ] [_inst_12 : AddCommMonoid.{u1} Qₗ] [_inst_14 : Module.{u5, u4} R M (CommSemiring.toSemiring.{u5} R _inst_1) _inst_5] [_inst_19 : Module.{u5, u2} R Nₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10] [_inst_20 : Module.{u5, u3} R Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_11] [_inst_21 : Module.{u5, u1} R Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_12] (f : LinearMap.{u5, u5, u4, max u3 u2} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) M (LinearMap.{u5, u5, u2, u3} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u3} R R Nₗ Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u5, u5, u2, u3} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_20 (smulCommClass_self.{u5, u3} R Pₗ (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u3} R Pₗ (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u3} Pₗ (AddCommMonoid.toAddMonoid.{u3} Pₗ _inst_11)) (Module.toMulActionWithZero.{u5, u3} R Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_11 _inst_20))))) (g : LinearMap.{u5, u5, u3, u1} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Pₗ Qₗ _inst_11 _inst_12 _inst_20 _inst_21) (m : M) (n : Nₗ), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Qₗ) n) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u5, u5, u2, u1} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) m) Nₗ (fun (_x : Nₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Qₗ) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u2, u1} R R Nₗ Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) (FunLike.coe.{max (max (succ u4) (succ u2)) (succ u1), succ u4, max (succ u2) (succ u1)} (LinearMap.{u5, u5, u4, max u1 u2} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) M (LinearMap.{u5, u5, u2, u1} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u1} R R Nₗ Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u5, u5, u2, u1} R R R Nₗ Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_21 (smulCommClass_self.{u5, u1} R Qₗ (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u1} R Qₗ (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u1} Qₗ (AddCommMonoid.toAddMonoid.{u1} Qₗ _inst_12)) (Module.toMulActionWithZero.{u5, u1} R Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_12 _inst_21))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u5, u5, u2, u1} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u4, max u2 u1} R R M (LinearMap.{u5, u5, u2, u1} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Qₗ _inst_10 _inst_12 _inst_19 _inst_21) (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u1} R R Nₗ Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u5, u5, u2, u1} R R R Nₗ Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_12 _inst_19 _inst_21 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_21 (smulCommClass_self.{u5, u1} R Qₗ (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u1} R Qₗ (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u1} Qₗ (AddCommMonoid.toAddMonoid.{u1} Qₗ _inst_12)) (Module.toMulActionWithZero.{u5, u1} R Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_12 _inst_21)))) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) (LinearMap.compr₂.{u5, u4, u2, u3, u1} R _inst_1 M Nₗ Pₗ Qₗ _inst_5 _inst_10 _inst_11 _inst_12 _inst_14 _inst_19 _inst_20 _inst_21 f g) m) n) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (LinearMap.{u5, u5, u3, u1} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Pₗ Qₗ _inst_11 _inst_12 _inst_20 _inst_21) Pₗ (fun (_x : Pₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Pₗ) => Qₗ) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u3, u1} R R Pₗ Qₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_11 _inst_12 _inst_20 _inst_21 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) g (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u5, u5, u2, u3} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) m) Nₗ (fun (_x : Nₗ) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Nₗ) => Pₗ) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u2, u3} R R Nₗ Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) (FunLike.coe.{max (max (succ u4) (succ u2)) (succ u3), succ u4, max (succ u2) (succ u3)} (LinearMap.{u5, u5, u4, max u3 u2} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) M (LinearMap.{u5, u5, u2, u3} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u3} R R Nₗ Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u5, u5, u2, u3} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_20 (smulCommClass_self.{u5, u3} R Pₗ (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u3} R Pₗ (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u3} Pₗ (AddCommMonoid.toAddMonoid.{u3} Pₗ _inst_11)) (Module.toMulActionWithZero.{u5, u3} R Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_11 _inst_20))))) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => LinearMap.{u5, u5, u2, u3} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u4, max u2 u3} R R M (LinearMap.{u5, u5, u2, u3} R R (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) Nₗ Pₗ _inst_10 _inst_11 _inst_19 _inst_20) (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u3} R R Nₗ Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u5, u5, u2, u3} R R R Nₗ Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10 _inst_11 _inst_19 _inst_20 (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1))) (CommSemiring.toSemiring.{u5} R _inst_1) _inst_20 (smulCommClass_self.{u5, u3} R Pₗ (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u3} R Pₗ (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u3} Pₗ (AddCommMonoid.toAddMonoid.{u3} Pₗ _inst_11)) (Module.toMulActionWithZero.{u5, u3} R Pₗ (CommSemiring.toSemiring.{u5} R _inst_1) _inst_11 _inst_20)))) (RingHom.id.{u5} R (Semiring.toNonAssocSemiring.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)))) f m) n))\nCase conversion may be inaccurate. Consider using '#align linear_map.compr₂_apply LinearMap.compr₂_applyₓ'. -/\n@[simp]\ntheorem compr₂_apply (f : M →ₗ[R] Nₗ →ₗ[R] Pₗ) (g : Pₗ →ₗ[R] Qₗ) (m : M) (n : Nₗ) :\n    f.compr₂ g m n = g (f m n) :=\n  rfl\n#align linear_map.compr₂_apply LinearMap.compr₂_apply\n\nvariable (R M)\n\n#print LinearMap.lsmul /-\n/-- Scalar multiplication as a bilinear map `R → M → M`. -/\ndef lsmul : R →ₗ[R] M →ₗ[R] M :=\n  mk₂ R (· • ·) add_smul (fun _ _ _ => mul_smul _ _ _) smul_add fun r s m => by\n    simp only [smul_smul, smul_eq_mul, mul_comm]\n#align linear_map.lsmul LinearMap.lsmul\n-/\n\nvariable {R M}\n\n/- warning: linear_map.lsmul_apply -> LinearMap.lsmul_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] (r : R) (m : M), Eq.{succ u2} M (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_14 (LinearMap.lsmul._proof_1.{u1, u2} R _inst_1 M _inst_5 _inst_14))) (fun (_x : LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_14 (LinearMap.lsmul._proof_1.{u1, u2} R _inst_1 M _inst_5 _inst_14))) => R -> (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14)) (LinearMap.hasCoeToFun.{u1, u1, u1, u2} R R R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_14 (LinearMap.lsmul._proof_1.{u1, u2} R _inst_1 M _inst_5 _inst_14)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.lsmul.{u1, u2} R _inst_1 M _inst_5 _inst_14) r) m) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5))) (Module.toMulActionWithZero.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_14)))) r m)\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] (r : R) (m : M), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) m) (FunLike.coe.{succ u2, succ u2, succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : R) => LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) r) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_14 (smulCommClass_self.{u1, u2} R M (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (Module.toMulActionWithZero.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_14))))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : R) => LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u1, u2} R R R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) M M _inst_5 _inst_5 _inst_14 _inst_14) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_5 _inst_14 _inst_14 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{u1} R _inst_1) _inst_14 (smulCommClass_self.{u1, u2} R M (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (Module.toMulActionWithZero.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_14)))) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.lsmul.{u1, u2} R _inst_1 M _inst_5 _inst_14) r) m) (HSMul.hSMul.{u1, u2, u2} R M M (instHSMul.{u1, u2} R M (SMulZeroClass.toSMul.{u1, u2} R M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (SMulWithZero.toSMulZeroClass.{u1, u2} R M (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_5)) (Module.toMulActionWithZero.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5 _inst_14))))) r m)\nCase conversion may be inaccurate. Consider using '#align linear_map.lsmul_apply LinearMap.lsmul_applyₓ'. -/\n@[simp]\ntheorem lsmul_apply (r : R) (m : M) : lsmul R M r m = r • m :=\n  rfl\n#align linear_map.lsmul_apply LinearMap.lsmul_apply\n\nend CommSemiring\n\nsection CommRing\n\nvariable {R R₂ S S₂ M N P : Type _}\n\nvariable {Mₗ Nₗ Pₗ : Type _}\n\nvariable [CommRing R] [CommRing S] [CommRing R₂] [CommRing S₂]\n\nsection AddCommGroup\n\nvariable [AddCommGroup M] [AddCommGroup N] [AddCommGroup P]\n\nvariable [Module R M] [Module S N] [Module R₂ P] [Module S₂ P]\n\n/- warning: linear_map.lsmul_injective -> LinearMap.lsmul_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_5 : AddCommGroup.{u2} M] [_inst_8 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)] [_inst_12 : NoZeroSMulDivisors.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8))))] {x : R}, (Ne.{succ u1} R x (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))))))))) -> (Function.Injective.{succ u2, succ u2} M M (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (fun (_x : LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) => M -> M) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) _inst_8 (LinearMap.lsmul._proof_1.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8))) (fun (_x : LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) _inst_8 (LinearMap.lsmul._proof_1.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8))) => R -> (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8)) (LinearMap.hasCoeToFun.{u1, u1, u1, u2} R R R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) _inst_8 (LinearMap.lsmul._proof_1.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.lsmul.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8) x)))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : CommRing.{u2} R] [_inst_5 : AddCommGroup.{u1} M] [_inst_8 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5)] [_inst_12 : NoZeroSMulDivisors.{u2, u1} R M (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (Module.toMulActionWithZero.{u2, u1} R M (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8))))] {x : R}, (Ne.{succ u2} R x (OfNat.ofNat.{u2} R 0 (Zero.toOfNat0.{u2} R (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))))) -> (Function.Injective.{succ u1, succ u1} M M (FunLike.coe.{succ u1, succ u1, succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : R) => LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) x) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => M) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u1, u1} R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearMap.{u2, u2, u2, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) R (LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (LinearMap.addCommMonoid.{u2, u2, u1, u1} R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u2, u2, u1, u1} R R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) _inst_8 (smulCommClass_self.{u2, u1} R M (CommSemiring.toCommMonoid.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (MulActionWithZero.toMulAction.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5))) (Module.toMulActionWithZero.{u2, u1} R M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8))))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : R) => LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u2, u1} R R R (LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (LinearMap.addCommMonoid.{u2, u2, u1, u1} R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u2, u2, u1, u1} R R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) _inst_8 (smulCommClass_self.{u2, u1} R M (CommSemiring.toCommMonoid.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (MulActionWithZero.toMulAction.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5))) (Module.toMulActionWithZero.{u2, u1} R M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8)))) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (LinearMap.lsmul.{u2, u1} R (CommRing.toCommSemiring.{u2} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8) x)))\nCase conversion may be inaccurate. Consider using '#align linear_map.lsmul_injective LinearMap.lsmul_injectiveₓ'. -/\ntheorem lsmul_injective [NoZeroSMulDivisors R M] {x : R} (hx : x ≠ 0) :\n    Function.Injective (lsmul R M x) :=\n  smul_right_injective _ hx\n#align linear_map.lsmul_injective LinearMap.lsmul_injective\n\n/- warning: linear_map.ker_lsmul -> LinearMap.ker_lsmul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : CommRing.{u1} R] [_inst_5 : AddCommGroup.{u2} M] [_inst_8 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)] [_inst_12 : NoZeroSMulDivisors.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8))))] {a : R}, (Ne.{succ u1} R a (OfNat.ofNat.{u1} R 0 (OfNat.mk.{u1} R 0 (Zero.zero.{u1} R (MulZeroClass.toHasZero.{u1} R (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} R (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} R (NonAssocRing.toNonUnitalNonAssocRing.{u1} R (Ring.toNonAssocRing.{u1} R (CommRing.toRing.{u1} R _inst_1)))))))))) -> (Eq.{succ u2} (Submodule.{u1, u2} R M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8) (LinearMap.ker.{u1, u1, u2, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (LinearMap.semilinearMapClass.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) _inst_8 (LinearMap.lsmul._proof_1.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8))) (fun (_x : LinearMap.{u1, u1, u1, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) _inst_8 (LinearMap.lsmul._proof_1.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8))) => R -> (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8)) (LinearMap.hasCoeToFun.{u1, u1, u1, u2} R R R (LinearMap.{u1, u1, u2, u2} R R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.addCommMonoid.{u1, u1, u2, u2} R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (Semiring.toModule.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))) (LinearMap.module.{u1, u1, u1, u2, u2} R R R M M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) _inst_8 (LinearMap.lsmul._proof_1.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1))))) (LinearMap.lsmul.{u1, u2} R (CommRing.toCommSemiring.{u1} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8) a)) (Bot.bot.{u2} (Submodule.{u1, u2} R M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8) (Submodule.hasBot.{u1, u2} R M (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_5) _inst_8)))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : CommRing.{u2} R] [_inst_5 : AddCommGroup.{u1} M] [_inst_8 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5)] [_inst_12 : NoZeroSMulDivisors.{u2, u1} R M (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_5))))) (Module.toMulActionWithZero.{u2, u1} R M (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8))))] {a : R}, (Ne.{succ u2} R a (OfNat.ofNat.{u2} R 0 (Zero.toOfNat0.{u2} R (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))))) -> (Eq.{succ u1} (Submodule.{u2, u1} R M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8) (LinearMap.ker.{u2, u2, u1, u1, u1} R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : R) => LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) a) (LinearMap.instSemilinearMapClassLinearMap.{u2, u2, u1, u1} R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (LinearMap.{u2, u2, u2, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) R (LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (LinearMap.addCommMonoid.{u2, u2, u1, u1} R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u2, u2, u1, u1} R R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) _inst_8 (smulCommClass_self.{u2, u1} R M (CommSemiring.toCommMonoid.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (MulActionWithZero.toMulAction.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5))) (Module.toMulActionWithZero.{u2, u1} R M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8))))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : R) => LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u2, u1} R R R (LinearMap.{u2, u2, u1, u1} R R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) M M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (LinearMap.addCommMonoid.{u2, u2, u1, u1} R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (Semiring.toModule.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u2, u2, u1, u1} R R R M M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8 _inst_8 (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)))) (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) _inst_8 (smulCommClass_self.{u2, u1} R M (CommSemiring.toCommMonoid.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (MulActionWithZero.toMulAction.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5))) (Module.toMulActionWithZero.{u2, u1} R M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8)))) (RingHom.id.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1))))) (LinearMap.lsmul.{u2, u1} R (CommRing.toCommSemiring.{u2} R _inst_1) M (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8) a)) (Bot.bot.{u1} (Submodule.{u2, u1} R M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8) (Submodule.instBotSubmodule.{u2, u1} R M (CommSemiring.toSemiring.{u2} R (CommRing.toCommSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_5) _inst_8)))\nCase conversion may be inaccurate. Consider using '#align linear_map.ker_lsmul LinearMap.ker_lsmulₓ'. -/\ntheorem ker_lsmul [NoZeroSMulDivisors R M] {a : R} (ha : a ≠ 0) : (LinearMap.lsmul R M a).ker = ⊥ :=\n  LinearMap.ker_eq_bot_of_injective (LinearMap.lsmul_injective ha)\n#align linear_map.ker_lsmul LinearMap.ker_lsmul\n\nend AddCommGroup\n\nend CommRing\n\nend LinearMap\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/BilinearMap.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.46360740179147764}}
{"text": "/-\nCopyright (c) 2019 Amelia Livingston. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Amelia Livingston\n-/\nimport algebra.group.prod\nimport algebra.hom.equiv\nimport data.setoid.basic\nimport group_theory.submonoid.operations\n\n/-!\n# Congruence relations\n\nThis file defines congruence relations: equivalence relations that preserve a binary operation,\nwhich in this case is multiplication or addition. The principal definition is a `structure`\nextending a `setoid` (an equivalence relation), and the inductive definition of the smallest\ncongruence relation containing a binary relation is also given (see `con_gen`).\n\nThe file also proves basic properties of the quotient of a type by a congruence relation, and the\ncomplete lattice of congruence relations on a type. We then establish an order-preserving bijection\nbetween the set of congruence relations containing a congruence relation `c` and the set of\ncongruence relations on the quotient by `c`.\n\nThe second half of the file concerns congruence relations on monoids, in which case the\nquotient by the congruence relation is also a monoid. There are results about the universal\nproperty of quotients of monoids, and the isomorphism theorems for monoids.\n\n## Implementation notes\n\nThe inductive definition of a congruence relation could be a nested inductive type, defined using\nthe equivalence closure of a binary relation `eqv_gen`, but the recursor generated does not work.\nA nested inductive definition could conceivably shorten proofs, because they would allow invocation\nof the corresponding lemmas about `eqv_gen`.\n\nThe lemmas `refl`, `symm` and `trans` are not tagged with `@[refl]`, `@[symm]`, and `@[trans]`\nrespectively as these tags do not work on a structure coerced to a binary relation.\n\nThere is a coercion from elements of a type to the element's equivalence class under a\ncongruence relation.\n\nA congruence relation on a monoid `M` can be thought of as a submonoid of `M × M` for which\nmembership is an equivalence relation, but whilst this fact is established in the file, it is not\nused, since this perspective adds more layers of definitional unfolding.\n\n## Tags\n\ncongruence, congruence relation, quotient, quotient by congruence relation, monoid,\nquotient monoid, isomorphism theorems\n-/\n\nvariables (M : Type*) {N : Type*} {P : Type*}\n\nopen function setoid\n\n/-- A congruence relation on a type with an addition is an equivalence relation which\n    preserves addition. -/\nstructure add_con [has_add M] extends setoid M :=\n(add' : ∀ {w x y z}, r w x → r y z → r (w + y) (x + z))\n\n/-- A congruence relation on a type with a multiplication is an equivalence relation which\n    preserves multiplication. -/\n@[to_additive add_con] structure con [has_mul M] extends setoid M :=\n(mul' : ∀ {w x y z}, r w x → r y z → r (w * y) (x * z))\n\n/-- The equivalence relation underlying an additive congruence relation. -/\nadd_decl_doc add_con.to_setoid\n\n/-- The equivalence relation underlying a multiplicative congruence relation. -/\nadd_decl_doc con.to_setoid\n\nvariables {M}\n\n/-- The inductively defined smallest additive congruence relation containing a given binary\n    relation. -/\ninductive add_con_gen.rel [has_add M] (r : M → M → Prop) : M → M → Prop\n| of : Π x y, r x y → add_con_gen.rel x y\n| refl : Π x, add_con_gen.rel x x\n| symm : Π x y, add_con_gen.rel x y → add_con_gen.rel y x\n| trans : Π x y z, add_con_gen.rel x y → add_con_gen.rel y z → add_con_gen.rel x z\n| add : Π w x y z, add_con_gen.rel w x → add_con_gen.rel y z → add_con_gen.rel (w + y) (x + z)\n\n/-- The inductively defined smallest multiplicative congruence relation containing a given binary\n    relation. -/\n@[to_additive add_con_gen.rel]\ninductive con_gen.rel [has_mul M] (r : M → M → Prop) : M → M → Prop\n| of : Π x y, r x y → con_gen.rel x y\n| refl : Π x, con_gen.rel x x\n| symm : Π x y, con_gen.rel x y → con_gen.rel y x\n| trans : Π x y z, con_gen.rel x y → con_gen.rel y z → con_gen.rel x z\n| mul : Π w x y z, con_gen.rel w x → con_gen.rel y z → con_gen.rel (w * y) (x * z)\n\n/-- The inductively defined smallest multiplicative congruence relation containing a given binary\n    relation. -/\n@[to_additive add_con_gen \"The inductively defined smallest additive congruence relation containing\na given binary relation.\"]\ndef con_gen [has_mul M] (r : M → M → Prop) : con M :=\n⟨⟨con_gen.rel r, ⟨con_gen.rel.refl, con_gen.rel.symm, con_gen.rel.trans⟩⟩, con_gen.rel.mul⟩\n\nnamespace con\n\nsection\nvariables [has_mul M] [has_mul N] [has_mul P] (c : con M)\n\n@[to_additive]\ninstance : inhabited (con M) :=\n⟨con_gen empty_relation⟩\n\n/-- A coercion from a congruence relation to its underlying binary relation. -/\n@[to_additive \"A coercion from an additive congruence relation to its underlying binary relation.\"]\ninstance : has_coe_to_fun (con M) (λ _, M → M → Prop) := ⟨λ c, λ x y, @setoid.r _ c.to_setoid x y⟩\n\n@[simp, to_additive] lemma rel_eq_coe (c : con M) : c.r = c := rfl\n\n/-- Congruence relations are reflexive. -/\n@[to_additive \"Additive congruence relations are reflexive.\"]\nprotected lemma refl (x) : c x x := c.to_setoid.refl' x\n\n/-- Congruence relations are symmetric. -/\n@[to_additive \"Additive congruence relations are symmetric.\"]\nprotected lemma symm : ∀ {x y}, c x y → c y x := λ _ _ h, c.to_setoid.symm' h\n\n/-- Congruence relations are transitive. -/\n@[to_additive \"Additive congruence relations are transitive.\"]\nprotected lemma trans : ∀ {x y z}, c x y → c y z → c x z :=\nλ _ _ _ h, c.to_setoid.trans' h\n\n/-- Multiplicative congruence relations preserve multiplication. -/\n@[to_additive \"Additive congruence relations preserve addition.\"]\nprotected lemma mul : ∀ {w x y z}, c w x → c y z → c (w * y) (x * z) :=\nλ _ _ _ _ h1 h2, c.mul' h1 h2\n\n@[simp, to_additive] lemma rel_mk {s : setoid M} {h a b} :\n  con.mk s h a b ↔ r a b :=\niff.rfl\n\n/-- Given a type `M` with a multiplication, a congruence relation `c` on `M`, and elements of `M`\n    `x, y`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`. -/\n@[to_additive \"Given a type `M` with an addition, `x, y ∈ M`, and an additive congruence relation\n`c` on `M`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`.\"]\ninstance : has_mem (M × M) (con M) := ⟨λ x c, c x.1 x.2⟩\n\nvariables {c}\n\n/-- The map sending a congruence relation to its underlying binary relation is injective. -/\n@[to_additive \"The map sending an additive congruence relation to its underlying binary relation\nis injective.\"]\nlemma ext' {c d : con M} (H : c.r = d.r) : c = d :=\nby { rcases c with ⟨⟨⟩⟩, rcases d with ⟨⟨⟩⟩, cases H, congr, }\n\n/-- Extensionality rule for congruence relations. -/\n@[ext, to_additive \"Extensionality rule for additive congruence relations.\"]\nlemma ext {c d : con M} (H : ∀ x y, c x y ↔ d x y) : c = d :=\next' $ by ext; apply H\n\n/-- The map sending a congruence relation to its underlying equivalence relation is injective. -/\n@[to_additive \"The map sending an additive congruence relation to its underlying equivalence\nrelation is injective.\"]\nlemma to_setoid_inj {c d : con M} (H : c.to_setoid = d.to_setoid) : c = d :=\next $ ext_iff.1 H\n\n/-- Iff version of extensionality rule for congruence relations. -/\n@[to_additive \"Iff version of extensionality rule for additive congruence relations.\"]\nlemma ext_iff {c d : con M} : (∀ x y, c x y ↔ d x y) ↔ c = d :=\n⟨ext, λ h _ _, h ▸ iff.rfl⟩\n\n/-- Two congruence relations are equal iff their underlying binary relations are equal. -/\n@[to_additive \"Two additive congruence relations are equal iff their underlying binary relations\nare equal.\"]\nlemma ext'_iff {c d : con M} : c.r = d.r ↔ c = d :=\n⟨ext', λ h, h ▸ rfl⟩\n\n/-- The kernel of a multiplication-preserving function as a congruence relation. -/\n@[to_additive \"The kernel of an addition-preserving function as an additive congruence relation.\"]\ndef mul_ker (f : M → P) (h : ∀ x y, f (x * y) = f x * f y) : con M :=\n{ to_setoid := setoid.ker f,\n  mul' := λ _ _ _ _ h1 h2, by { dsimp [setoid.ker, on_fun] at *, rw [h, h1, h2, h], } }\n\n/-- Given types with multiplications `M, N`, the product of two congruence relations `c` on `M` and\n    `d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁` is related to `y₁`\n    by `c` and `x₂` is related to `y₂` by `d`. -/\n@[to_additive prod \"Given types with additions `M, N`, the product of two congruence relations\n`c` on `M` and `d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁`\nis related to `y₁` by `c` and `x₂` is related to `y₂` by `d`.\"]\nprotected def prod (c : con M) (d : con N) : con (M × N) :=\n{ mul' := λ _ _ _ _ h1 h2, ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩, ..c.to_setoid.prod d.to_setoid }\n\n/-- The product of an indexed collection of congruence relations. -/\n@[to_additive \"The product of an indexed collection of additive congruence relations.\"]\ndef pi {ι : Type*} {f : ι → Type*} [Π i, has_mul (f i)]\n  (C : Π i, con (f i)) : con (Π i, f i) :=\n{ mul' := λ _ _ _ _ h1 h2 i, (C i).mul (h1 i) (h2 i), ..@pi_setoid _ _ $ λ i, (C i).to_setoid }\n\nvariables (c)\n\n-- Quotients\n\n/-- Defining the quotient by a congruence relation of a type with a multiplication. -/\n@[to_additive \"Defining the quotient by an additive congruence relation of a type with\nan addition.\"]\nprotected def quotient := quotient $ c.to_setoid\n\n/-- Coercion from a type with a multiplication to its quotient by a congruence relation.\n\nSee Note [use has_coe_t]. -/\n@[to_additive \"Coercion from a type with an addition to its quotient by an additive congruence\nrelation\", priority 0]\ninstance : has_coe_t M c.quotient := ⟨@quotient.mk _ c.to_setoid⟩\n\n/-- The quotient by a decidable congruence relation has decidable equality. -/\n@[to_additive \"The quotient by a decidable additive congruence relation has decidable equality.\",\n  priority 500] -- Lower the priority since it unifies with any quotient type.\ninstance [d : ∀ a b, decidable (c a b)] : decidable_eq c.quotient :=\n@quotient.decidable_eq M c.to_setoid d\n\n@[simp, to_additive] lemma quot_mk_eq_coe {M : Type*} [has_mul M] (c : con M) (x : M) :\n  quot.mk c x = (x : c.quotient) :=\nrfl\n\n/-- The function on the quotient by a congruence relation `c` induced by a function that is\n    constant on `c`'s equivalence classes. -/\n@[elab_as_eliminator, to_additive \"The function on the quotient by a congruence relation `c`\ninduced by a function that is constant on `c`'s equivalence classes.\"]\nprotected def lift_on {β} {c : con M} (q : c.quotient) (f : M → β)\n  (h : ∀ a b, c a b → f a = f b) : β := quotient.lift_on' q f h\n\n/-- The binary function on the quotient by a congruence relation `c` induced by a binary function\n    that is constant on `c`'s equivalence classes. -/\n@[elab_as_eliminator, to_additive \"The binary function on the quotient by a congruence relation `c`\ninduced by a binary function that is constant on `c`'s equivalence classes.\"]\nprotected def lift_on₂ {β} {c : con M} (q r : c.quotient) (f : M → M → β)\n  (h : ∀ a₁ a₂ b₁ b₂, c a₁ b₁ → c a₂ b₂ → f a₁ a₂ = f b₁ b₂) : β := quotient.lift_on₂' q r f h\n\n/-- A version of `quotient.hrec_on₂'` for quotients by `con`. -/\n@[to_additive \"A version of `quotient.hrec_on₂'` for quotients by `add_con`.\"]\nprotected def hrec_on₂ {cM : con M} {cN : con N} {φ : cM.quotient → cN.quotient → Sort*}\n  (a : cM.quotient) (b : cN.quotient)\n  (f : Π (x : M) (y : N), φ x y) (h : ∀ x y x' y', cM x x' → cN y y' → f x y == f x' y') :\n  φ a b :=\nquotient.hrec_on₂' a b f h\n\n@[simp, to_additive] lemma hrec_on₂_coe {cM : con M} {cN : con N}\n  {φ : cM.quotient → cN.quotient → Sort*} (a : M) (b : N)\n  (f : Π (x : M) (y : N), φ x y) (h : ∀ x y x' y', cM x x' → cN y y' → f x y == f x' y') :\n  con.hrec_on₂ ↑a ↑b f h = f a b :=\nrfl\n\nvariables {c}\n\n/-- The inductive principle used to prove propositions about the elements of a quotient by a\n    congruence relation. -/\n@[elab_as_eliminator, to_additive \"The inductive principle used to prove propositions about\nthe elements of a quotient by an additive congruence relation.\"]\nprotected lemma induction_on {C : c.quotient → Prop} (q : c.quotient) (H : ∀ x : M, C x) : C q :=\nquotient.induction_on' q H\n\n/-- A version of `con.induction_on` for predicates which take two arguments. -/\n@[elab_as_eliminator, to_additive \"A version of `add_con.induction_on` for predicates which take\ntwo arguments.\"]\nprotected lemma induction_on₂ {d : con N} {C : c.quotient → d.quotient → Prop}\n  (p : c.quotient) (q : d.quotient) (H : ∀ (x : M) (y : N), C x y) : C p q :=\nquotient.induction_on₂' p q H\n\nvariables (c)\n\n/-- Two elements are related by a congruence relation `c` iff they are represented by the same\n    element of the quotient by `c`. -/\n@[simp, to_additive \"Two elements are related by an additive congruence relation `c` iff they\nare represented by the same element of the quotient by `c`.\"]\nprotected lemma eq {a b : M} : (a : c.quotient) = b ↔ c a b :=\nquotient.eq'\n\n/-- The multiplication induced on the quotient by a congruence relation on a type with a\n    multiplication. -/\n@[to_additive \"The addition induced on the quotient by an additive congruence relation on a type\nwith an addition.\"]\ninstance has_mul : has_mul c.quotient :=\n⟨λ x y, quotient.lift_on₂' x y (λ w z, ((w * z : M) : c.quotient))\n     $ λ _ _ _ _ h1 h2, c.eq.2 $ c.mul h1 h2⟩\n\n/-- The kernel of the quotient map induced by a congruence relation `c` equals `c`. -/\n@[simp, to_additive \"The kernel of the quotient map induced by an additive congruence relation\n`c` equals `c`.\"]\nlemma mul_ker_mk_eq : mul_ker (coe : M → c.quotient) (λ x y, rfl) = c :=\next $ λ x y, quotient.eq'\n\nvariables {c}\n\n/-- The coercion to the quotient of a congruence relation commutes with multiplication (by\n    definition). -/\n@[simp, to_additive \"The coercion to the quotient of an additive congruence relation commutes with\naddition (by definition).\"]\nlemma coe_mul (x y : M) : (↑(x * y) : c.quotient) = ↑x * ↑y := rfl\n\n/-- Definition of the function on the quotient by a congruence relation `c` induced by a function\n    that is constant on `c`'s equivalence classes. -/\n@[simp, to_additive \"Definition of the function on the quotient by an additive congruence\nrelation `c` induced by a function that is constant on `c`'s equivalence classes.\"]\nprotected lemma lift_on_coe {β} (c : con M) (f : M → β)\n  (h : ∀ a b, c a b → f a = f b) (x : M) :\n  con.lift_on (x : c.quotient) f h = f x := rfl\n\n/-- Makes an isomorphism of quotients by two congruence relations, given that the relations are\n    equal. -/\n@[to_additive \"Makes an additive isomorphism of quotients by two additive congruence relations,\ngiven that the relations are equal.\"]\nprotected def congr {c d : con M} (h : c = d) :  c.quotient ≃* d.quotient :=\n{ map_mul' := λ x y, by rcases x; rcases y; refl,\n  ..quotient.congr (equiv.refl M) $ by apply ext_iff.2 h }\n\n-- The complete lattice of congruence relations on a type\n\n/-- For congruence relations `c, d` on a type `M` with a multiplication, `c ≤ d` iff `∀ x y ∈ M`,\n    `x` is related to `y` by `d` if `x` is related to `y` by `c`. -/\n@[to_additive \"For additive congruence relations `c, d` on a type `M` with an addition, `c ≤ d` iff\n`∀ x y ∈ M`, `x` is related to `y` by `d` if `x` is related to `y` by `c`.\"]\ninstance : has_le (con M) := ⟨λ c d, ∀ ⦃x y⦄, c x y → d x y⟩\n\n/-- Definition of `≤` for congruence relations. -/\n@[to_additive \"Definition of `≤` for additive congruence relations.\"]\ntheorem le_def {c d : con M} : c ≤ d ↔ ∀ {x y}, c x y → d x y := iff.rfl\n\n/-- The infimum of a set of congruence relations on a given type with a multiplication. -/\n@[to_additive \"The infimum of a set of additive congruence relations on a given type with\nan addition.\"]\ninstance : has_Inf (con M) :=\n⟨λ S, ⟨⟨λ x y, ∀ c : con M, c ∈ S → c x y,\n⟨λ x c hc, c.refl x, λ _ _ h c hc, c.symm $ h c hc,\n λ _ _ _ h1 h2 c hc, c.trans (h1 c hc) $ h2 c hc⟩⟩,\n λ _ _ _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc⟩⟩\n\n/-- The infimum of a set of congruence relations is the same as the infimum of the set's image\n    under the map to the underlying equivalence relation. -/\n@[to_additive \"The infimum of a set of additive congruence relations is the same as the infimum of\nthe set's image under the map to the underlying equivalence relation.\"]\nlemma Inf_to_setoid (S : set (con M)) : (Inf S).to_setoid = Inf (to_setoid '' S) :=\nsetoid.ext' $ λ x y, ⟨λ h r ⟨c, hS, hr⟩, by rw ←hr; exact h c hS,\n  λ h c hS, h c.to_setoid ⟨c, hS, rfl⟩⟩\n\n/-- The infimum of a set of congruence relations is the same as the infimum of the set's image\n    under the map to the underlying binary relation. -/\n@[to_additive \"The infimum of a set of additive congruence relations is the same as the infimum\nof the set's image under the map to the underlying binary relation.\"]\nlemma Inf_def (S : set (con M)) : ⇑(Inf S) = Inf (@set.image (con M) (M → M → Prop) coe_fn S) :=\nby { ext, simp only [Inf_image, infi_apply, infi_Prop_eq], refl }\n\n@[to_additive]\ninstance : partial_order (con M) :=\n{ le := (≤),\n  lt := λ c d, c ≤ d ∧ ¬d ≤ c,\n  le_refl := λ c _ _, id,\n  le_trans := λ c1 c2 c3 h1 h2 x y h, h2 $ h1 h,\n  lt_iff_le_not_le := λ _ _, iff.rfl,\n  le_antisymm := λ c d hc hd, ext $ λ x y, ⟨λ h, hc h, λ h, hd h⟩ }\n\n/-- The complete lattice of congruence relations on a given type with a multiplication. -/\n@[to_additive \"The complete lattice of additive congruence relations on a given type with\nan addition.\"]\ninstance : complete_lattice (con M) :=\n{ inf := λ c d, ⟨(c.to_setoid ⊓ d.to_setoid), λ _ _ _ _ h1 h2, ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩⟩,\n  inf_le_left := λ _ _ _ _ h, h.1,\n  inf_le_right := λ _ _ _ _ h, h.2,\n  le_inf := λ _ _ _ hb hc _ _ h, ⟨hb h, hc h⟩,\n  top := { mul' := by tauto, ..setoid.complete_lattice.top},\n  le_top := λ _ _ _ h, trivial,\n  bot := { mul' := λ _ _ _ _ h1 h2, h1 ▸ h2 ▸ rfl, ..setoid.complete_lattice.bot},\n  bot_le := λ c x y h, h ▸ c.refl x,\n  .. complete_lattice_of_Inf (con M) $ assume s,\n    ⟨λ r hr x y h, (h : ∀ r ∈ s, (r : con M) x y) r hr, λ r hr x y h r' hr', hr hr' h⟩ }\n\n/-- The infimum of two congruence relations equals the infimum of the underlying binary\n    operations. -/\n@[to_additive \"The infimum of two additive congruence relations equals the infimum of the\nunderlying binary operations.\"]\nlemma inf_def {c d : con M} : (c ⊓ d).r = c.r ⊓ d.r := rfl\n\n/-- Definition of the infimum of two congruence relations. -/\n@[to_additive \"Definition of the infimum of two additive congruence relations.\"]\ntheorem inf_iff_and {c d : con M} {x y} : (c ⊓ d) x y ↔ c x y ∧ d x y := iff.rfl\n\n/-- The inductively defined smallest congruence relation containing a binary relation `r` equals\n    the infimum of the set of congruence relations containing `r`. -/\n@[to_additive add_con_gen_eq \"The inductively defined smallest additive congruence relation\ncontaining a binary relation `r` equals the infimum of the set of additive congruence relations\ncontaining `r`.\"]\ntheorem con_gen_eq (r : M → M → Prop) :\n  con_gen r = Inf {s : con M | ∀ x y, r x y → s x y} :=\nle_antisymm\n  (λ x y H, con_gen.rel.rec_on H (λ _ _ h _ hs, hs _ _ h) (con.refl _) (λ _ _ _, con.symm _)\n    (λ _ _ _ _ _, con.trans _)\n    $ λ w x y z _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc)\n  (Inf_le (λ _ _, con_gen.rel.of _ _))\n\n/-- The smallest congruence relation containing a binary relation `r` is contained in any\n    congruence relation containing `r`. -/\n@[to_additive add_con_gen_le \"The smallest additive congruence relation containing a binary\nrelation `r` is contained in any additive congruence relation containing `r`.\"]\ntheorem con_gen_le {r : M → M → Prop} {c : con M} (h : ∀ x y, r x y → @setoid.r _ c.to_setoid x y) :\n  con_gen r ≤ c :=\nby rw con_gen_eq; exact Inf_le h\n\n/-- Given binary relations `r, s` with `r` contained in `s`, the smallest congruence relation\n    containing `s` contains the smallest congruence relation containing `r`. -/\n@[to_additive add_con_gen_mono \"Given binary relations `r, s` with `r` contained in `s`, the\nsmallest additive congruence relation containing `s` contains the smallest additive congruence\nrelation containing `r`.\"]\ntheorem con_gen_mono {r s : M → M → Prop} (h : ∀ x y, r x y → s x y) :\n  con_gen r ≤ con_gen s :=\ncon_gen_le $ λ x y hr, con_gen.rel.of _ _ $ h x y hr\n\n/-- Congruence relations equal the smallest congruence relation in which they are contained. -/\n@[simp, to_additive add_con_gen_of_add_con \"Additive congruence relations equal the smallest\nadditive congruence relation in which they are contained.\"]\nlemma con_gen_of_con (c : con M) : con_gen c = c :=\nle_antisymm (by rw con_gen_eq; exact Inf_le (λ _ _, id)) con_gen.rel.of\n\n/-- The map sending a binary relation to the smallest congruence relation in which it is\n    contained is idempotent. -/\n@[simp, to_additive add_con_gen_idem \"The map sending a binary relation to the smallest additive\ncongruence relation in which it is contained is idempotent.\"]\nlemma con_gen_idem (r : M → M → Prop) :\n  con_gen (con_gen r) = con_gen r :=\ncon_gen_of_con _\n\n/-- The supremum of congruence relations `c, d` equals the smallest congruence relation containing\n    the binary relation '`x` is related to `y` by `c` or `d`'. -/\n@[to_additive sup_eq_add_con_gen \"The supremum of additive congruence relations `c, d` equals the\nsmallest additive congruence relation containing the binary relation '`x` is related to `y`\nby `c` or `d`'.\"]\nlemma sup_eq_con_gen (c d : con M) :\n  c ⊔ d = con_gen (λ x y, c x y ∨ d x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  simp only [le_def, or_imp_distrib, ← forall_and_distrib]\nend\n\n/-- The supremum of two congruence relations equals the smallest congruence relation containing\n    the supremum of the underlying binary operations. -/\n@[to_additive \"The supremum of two additive congruence relations equals the smallest additive\ncongruence relation containing the supremum of the underlying binary operations.\"]\nlemma sup_def {c d : con M} : c ⊔ d = con_gen (c.r ⊔ d.r) :=\nby rw sup_eq_con_gen; refl\n\n/-- The supremum of a set of congruence relations `S` equals the smallest congruence relation\n    containing the binary relation 'there exists `c ∈ S` such that `x` is related to `y` by\n    `c`'. -/\n@[to_additive Sup_eq_add_con_gen \"The supremum of a set of additive congruence relations `S` equals\nthe smallest additive congruence relation containing the binary relation 'there exists `c ∈ S`\nsuch that `x` is related to `y` by `c`'.\"]\nlemma Sup_eq_con_gen (S : set (con M)) :\n  Sup S = con_gen (λ x y, ∃ c : con M, c ∈ S ∧ c x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  ext,\n  exact ⟨λ h _ _ ⟨r, hr⟩, h hr.1 hr.2,\n         λ h r hS _ _ hr, h _ _ ⟨r, hS, hr⟩⟩,\nend\n\n/-- The supremum of a set of congruence relations is the same as the smallest congruence relation\n    containing the supremum of the set's image under the map to the underlying binary relation. -/\n@[to_additive \"The supremum of a set of additive congruence relations is the same as the smallest\nadditive congruence relation containing the supremum of the set's image under the map to the\nunderlying binary relation.\"]\nlemma Sup_def {S : set (con M)} :\n  Sup S = con_gen (Sup (@set.image (con M) (M → M → Prop) coe_fn S)) :=\nbegin\n  rw [Sup_eq_con_gen, Sup_image],\n  congr' with x y,\n  simp only [Sup_image, supr_apply, supr_Prop_eq, exists_prop, rel_eq_coe]\nend\n\nvariables (M)\n\n/-- There is a Galois insertion of congruence relations on a type with a multiplication `M` into\n    binary relations on `M`. -/\n@[to_additive \"There is a Galois insertion of additive congruence relations on a type with\nan addition `M` into binary relations on `M`.\"]\nprotected def gi :\n  @galois_insertion (M → M → Prop) (con M) _ _ con_gen coe_fn :=\n{ choice := λ r h, con_gen r,\n  gc := λ r c, ⟨λ H _ _ h, H $ con_gen.rel.of _ _ h, λ H, con_gen_of_con c ▸ con_gen_mono H⟩,\n  le_l_u := λ x, (con_gen_of_con x).symm ▸ le_refl x,\n  choice_eq := λ _ _, rfl }\n\nvariables {M} (c)\n\n\n/-- Given a function `f`, the smallest congruence relation containing the binary relation on `f`'s\n    image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)`\n    by a congruence relation `c`.' -/\n@[to_additive \"Given a function `f`, the smallest additive congruence relation containing the\nbinary relation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the\nelements of `f⁻¹(y)` by an additive congruence relation `c`.'\"]\ndef map_gen (f : M → N) : con N :=\ncon_gen $ λ x y, ∃ a b, f a = x ∧ f b = y ∧ c a b\n\n/-- Given a surjective multiplicative-preserving function `f` whose kernel is contained in a\n    congruence relation `c`, the congruence relation on `f`'s codomain defined by '`x ≈ y` iff the\n    elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.' -/\n@[to_additive \"Given a surjective addition-preserving function `f` whose kernel is contained in\nan additive congruence relation `c`, the additive congruence relation on `f`'s codomain defined\nby '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.'\"]\ndef map_of_surjective (f : M → N) (H : ∀ x y, f (x * y) = f x * f y) (h : mul_ker f H ≤ c)\n  (hf : surjective f) : con N :=\n{ mul' := λ w x y z ⟨a, b, hw, hx, h1⟩ ⟨p, q, hy, hz, h2⟩,\n    ⟨a * p, b * q, by rw [H, hw, hy], by rw [H, hx, hz], c.mul h1 h2⟩,\n  ..c.to_setoid.map_of_surjective f h hf }\n\n/-- A specialization of 'the smallest congruence relation containing a congruence relation `c`\n    equals `c`'. -/\n@[to_additive \"A specialization of 'the smallest additive congruence relation containing\nan additive congruence relation `c` equals `c`'.\"]\nlemma map_of_surjective_eq_map_gen {c : con M} {f : M → N} (H : ∀ x y, f (x * y) = f x * f y)\n  (h : mul_ker f H ≤ c) (hf : surjective f) :\n  c.map_gen f = c.map_of_surjective f H h hf :=\nby rw ←con_gen_of_con (c.map_of_surjective f H h hf); refl\n\n/-- Given types with multiplications `M, N` and a congruence relation `c` on `N`, a\n    multiplication-preserving map `f : M → N` induces a congruence relation on `f`'s domain\n    defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' -/\n@[to_additive \"Given types with additions `M, N` and an additive congruence relation `c` on `N`,\nan addition-preserving map `f : M → N` induces an additive congruence relation on `f`'s domain\ndefined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' \"]\ndef comap (f : M → N) (H : ∀ x y, f (x * y) = f x * f y) (c : con N) : con M :=\n{ mul' := λ w x y z h1 h2, show c (f (w * y)) (f (x * z)), by rw [H, H]; exact c.mul h1 h2,\n  ..c.to_setoid.comap f }\n\n@[simp, to_additive] lemma comap_rel {f : M → N} (H : ∀ x y, f (x * y) = f x * f y)\n  {c : con N} {x y : M} :\n  comap f H c x y ↔ c (f x) (f y) :=\niff.rfl\n\nsection\nopen _root_.quotient\n\n/-- Given a congruence relation `c` on a type `M` with a multiplication, the order-preserving\n    bijection between the set of congruence relations containing `c` and the congruence relations\n    on the quotient of `M` by `c`. -/\n@[to_additive \"Given an additive congruence relation `c` on a type `M` with an addition,\nthe order-preserving bijection between the set of additive congruence relations containing `c` and\nthe additive congruence relations on the quotient of `M` by `c`.\"]\ndef correspondence : {d // c ≤ d} ≃o (con c.quotient) :=\n{ to_fun := λ d, d.1.map_of_surjective coe _\n    (by rw mul_ker_mk_eq; exact d.2) $ @exists_rep _ c.to_setoid,\n  inv_fun := λ d, ⟨comap (coe : M → c.quotient) (λ x y, rfl) d, λ _ _ h,\n    show d _ _, by rw c.eq.2 h; exact d.refl _ ⟩,\n  left_inv := λ d, subtype.ext_iff_val.2 $ ext $ λ _ _,\n    ⟨λ h, let ⟨a, b, hx, hy, H⟩ := h in\n      d.1.trans (d.1.symm $ d.2 $ c.eq.1 hx) $ d.1.trans H $ d.2 $ c.eq.1 hy,\n     λ h, ⟨_, _, rfl, rfl, h⟩⟩,\n  right_inv := λ d, let Hm : mul_ker (coe : M → c.quotient) (λ x y, rfl) ≤\n        comap (coe : M → c.quotient) (λ x y, rfl) d :=\n      λ x y h, show d _ _, by rw mul_ker_mk_eq at h; exact c.eq.2 h ▸ d.refl _ in\n    ext $ λ x y, ⟨λ h, let ⟨a, b, hx, hy, H⟩ := h in hx ▸ hy ▸ H,\n      con.induction_on₂ x y $ λ w z h, ⟨w, z, rfl, rfl, h⟩⟩,\n  map_rel_iff' := λ s t, ⟨λ h _ _ hs, let ⟨a, b, hx, hy, ht⟩ := h ⟨_, _, rfl, rfl, hs⟩ in\n      t.1.trans (t.1.symm $ t.2 $ eq_rel.1 hx) $ t.1.trans ht $ t.2 $ eq_rel.1 hy,\n      λ h _ _ hs, let ⟨a, b, hx, hy, Hs⟩ := hs in ⟨a, b, hx, hy, h Hs⟩⟩ }\n\nend\n\nend\n\nsection mul_one_class\n\nvariables {M} [mul_one_class M] [mul_one_class N] [mul_one_class P] (c : con M)\n\n/-- The quotient of a monoid by a congruence relation is a monoid. -/\n@[to_additive \"The quotient of an `add_monoid` by an additive congruence relation is\nan `add_monoid`.\"]\ninstance mul_one_class : mul_one_class c.quotient :=\n{ one := ((1 : M) : c.quotient),\n  mul := (*),\n  mul_one := λ x, quotient.induction_on' x $ λ _, congr_arg coe $ mul_one _,\n  one_mul := λ x, quotient.induction_on' x $ λ _, congr_arg coe $ one_mul _ }\n\nvariables {c}\n\n/-- The 1 of the quotient of a monoid by a congruence relation is the equivalence class of the\n    monoid's 1. -/\n@[simp, to_additive \"The 0 of the quotient of an `add_monoid` by an additive congruence relation\nis the equivalence class of the `add_monoid`'s 0.\"]\nlemma coe_one : ((1 : M) : c.quotient) = 1 := rfl\n\nvariables (M c)\n\n/-- The submonoid of `M × M` defined by a congruence relation on a monoid `M`. -/\n@[to_additive \"The `add_submonoid` of `M × M` defined by an additive congruence\nrelation on an `add_monoid` `M`.\"]\nprotected def submonoid : submonoid (M × M) :=\n{ carrier := { x | c x.1 x.2 },\n  one_mem' := c.iseqv.1 1,\n  mul_mem' := λ _ _, c.mul }\n\nvariables {M c}\n\n/-- The congruence relation on a monoid `M` from a submonoid of `M × M` for which membership\n    is an equivalence relation. -/\n@[to_additive \"The additive congruence relation on an `add_monoid` `M` from\nan `add_submonoid` of `M × M` for which membership is an equivalence relation.\"]\ndef of_submonoid (N : submonoid (M × M)) (H : equivalence (λ x y, (x, y) ∈ N)) : con M :=\n{ r := λ x y, (x, y) ∈ N,\n  iseqv := H,\n  mul' := λ _ _ _ _, N.mul_mem }\n\n/-- Coercion from a congruence relation `c` on a monoid `M` to the submonoid of `M × M` whose\n    elements are `(x, y)` such that `x` is related to `y` by `c`. -/\n@[to_additive \"Coercion from a congruence relation `c` on an `add_monoid` `M`\nto the `add_submonoid` of `M × M` whose elements are `(x, y)` such that `x`\nis related to `y` by `c`.\"]\ninstance to_submonoid : has_coe (con M) (submonoid (M × M)) := ⟨λ c, c.submonoid M⟩\n\n@[to_additive] lemma mem_coe {c : con M} {x y} :\n  (x, y) ∈ (↑c : submonoid (M × M)) ↔ (x, y) ∈ c := iff.rfl\n\n@[to_additive]\ntheorem to_submonoid_inj (c d : con M) (H : (c : submonoid (M × M)) = d) : c = d :=\next $ λ x y, show (x, y) ∈ (c : submonoid (M × M)) ↔ (x, y) ∈ ↑d, by rw H\n\n@[to_additive]\nlemma le_iff {c d : con M} : c ≤ d ↔ (c : submonoid (M × M)) ≤ d :=\n⟨λ h x H, h H, λ h x y hc, h $ show (x, y) ∈ c, from hc⟩\n\n/-- The kernel of a monoid homomorphism as a congruence relation. -/\n@[to_additive \"The kernel of an `add_monoid` homomorphism as an additive congruence relation.\"]\ndef ker (f : M →* P) : con M := mul_ker f f.3\n\n/-- The definition of the congruence relation defined by a monoid homomorphism's kernel. -/\n@[simp, to_additive \"The definition of the additive congruence relation defined by an `add_monoid`\nhomomorphism's kernel.\"]\nlemma ker_rel (f : M →* P) {x y} : ker f x y ↔ f x = f y := iff.rfl\n\n/-- There exists an element of the quotient of a monoid by a congruence relation (namely 1). -/\n@[to_additive \"There exists an element of the quotient of an `add_monoid` by a congruence relation\n(namely 0).\"]\ninstance quotient.inhabited : inhabited c.quotient := ⟨((1 : M) : c.quotient)⟩\n\nvariables (c)\n\n/-- The natural homomorphism from a monoid to its quotient by a congruence relation. -/\n@[to_additive \"The natural homomorphism from an `add_monoid` to its quotient by an additive\ncongruence relation.\"]\ndef mk' : M →* c.quotient := ⟨coe, rfl, λ _ _, rfl⟩\n\nvariables (x y : M)\n\n/-- The kernel of the natural homomorphism from a monoid to its quotient by a congruence\n    relation `c` equals `c`. -/\n@[simp, to_additive \"The kernel of the natural homomorphism from an `add_monoid` to its quotient by\nan additive congruence relation `c` equals `c`.\"]\nlemma mk'_ker : ker c.mk' = c := ext $ λ _ _, c.eq\n\nvariables {c}\n\n/-- The natural homomorphism from a monoid to its quotient by a congruence relation is\n    surjective. -/\n@[to_additive \"The natural homomorphism from an `add_monoid` to its quotient by a congruence\nrelation is surjective.\"]\nlemma mk'_surjective : surjective c.mk' :=\nquotient.surjective_quotient_mk'\n\n@[simp, to_additive] lemma coe_mk' : (c.mk' : M → c.quotient) = coe := rfl\n\n/-- The elements related to `x ∈ M`, `M` a monoid, by the kernel of a monoid homomorphism are\n    those in the preimage of `f(x)` under `f`. -/\n@[to_additive \"The elements related to `x ∈ M`, `M` an `add_monoid`, by the kernel of\nan `add_monoid` homomorphism are those in the preimage of `f(x)` under `f`. \"]\nlemma ker_apply_eq_preimage {f : M →* P} (x) : (ker f) x = f ⁻¹' {f x} :=\nset.ext $ λ x,\n  ⟨λ h, set.mem_preimage.2 $ set.mem_singleton_iff.2 h.symm,\n   λ h, (set.mem_singleton_iff.1 $ set.mem_preimage.1 h).symm⟩\n\n/-- Given a monoid homomorphism `f : N → M` and a congruence relation `c` on `M`, the congruence\n    relation induced on `N` by `f` equals the kernel of `c`'s quotient homomorphism composed with\n    `f`. -/\n@[to_additive \"Given an `add_monoid` homomorphism `f : N → M` and an additive congruence relation\n`c` on `M`, the additive congruence relation induced on `N` by `f` equals the kernel of `c`'s\nquotient homomorphism composed with `f`.\"]\nlemma comap_eq {f : N →* M} : comap f f.map_mul c = ker (c.mk'.comp f) :=\next $ λ x y, show c _ _ ↔ c.mk' _ = c.mk' _, by rw ←c.eq; refl\n\nvariables (c) (f : M →* P)\n\n/-- The homomorphism on the quotient of a monoid by a congruence relation `c` induced by a\n    homomorphism constant on `c`'s equivalence classes. -/\n@[to_additive \"The homomorphism on the quotient of an `add_monoid` by an additive congruence\nrelation `c` induced by a homomorphism constant on `c`'s equivalence classes.\"]\ndef lift (H : c ≤ ker f) : c.quotient →* P :=\n{ to_fun := λ x, con.lift_on x f $ λ _ _ h, H h,\n  map_one' := by rw ←f.map_one; refl,\n  map_mul' := λ x y, con.induction_on₂ x y $ λ m n, f.map_mul m n ▸ rfl }\n\nvariables {c f}\n\n/-- The diagram describing the universal property for quotients of monoids commutes. -/\n@[to_additive \"The diagram describing the universal property for quotients of `add_monoid`s\ncommutes.\"]\nlemma lift_mk' (H : c ≤ ker f) (x) :\n  c.lift f H (c.mk' x) = f x := rfl\n\n/-- The diagram describing the universal property for quotients of monoids commutes. -/\n@[simp, to_additive \"The diagram describing the universal property for quotients of `add_monoid`s\ncommutes.\"]\nlemma lift_coe (H : c ≤ ker f) (x : M) :\n  c.lift f H x = f x := rfl\n\n/-- The diagram describing the universal property for quotients of monoids commutes. -/\n@[simp, to_additive \"The diagram describing the universal property for quotients of `add_monoid`s\ncommutes.\"]\ntheorem lift_comp_mk' (H : c ≤ ker f) :\n  (c.lift f H).comp c.mk' = f := by ext; refl\n\n/-- Given a homomorphism `f` from the quotient of a monoid by a congruence relation, `f` equals the\n    homomorphism on the quotient induced by `f` composed with the natural map from the monoid to\n    the quotient. -/\n@[simp, to_additive \"Given a homomorphism `f` from the quotient of an `add_monoid` by an additive\ncongruence relation, `f` equals the homomorphism on the quotient induced by `f` composed with the\nnatural map from the `add_monoid` to the quotient.\"]\nlemma lift_apply_mk' (f : c.quotient →* P) :\n  c.lift (f.comp c.mk') (λ x y h, show f ↑x = f ↑y, by rw c.eq.2 h) = f :=\nby ext; rcases x; refl\n\n/-- Homomorphisms on the quotient of a monoid by a congruence relation are equal if they\n    are equal on elements that are coercions from the monoid. -/\n@[to_additive \"Homomorphisms on the quotient of an `add_monoid` by an additive congruence relation\nare equal if they are equal on elements that are coercions from the `add_monoid`.\"]\nlemma lift_funext (f g : c.quotient →* P) (h : ∀ a : M, f a = g a) : f = g :=\nbegin\n  rw [←lift_apply_mk' f, ←lift_apply_mk' g],\n  congr' 1,\n  exact monoid_hom.ext_iff.2 h,\nend\n\n/-- The uniqueness part of the universal property for quotients of monoids. -/\n@[to_additive \"The uniqueness part of the universal property for quotients of `add_monoid`s.\"]\ntheorem lift_unique (H : c ≤ ker f) (g : c.quotient →* P)\n  (Hg : g.comp c.mk' = f) : g = c.lift f H :=\nlift_funext g (c.lift f H) $ λ x, by { subst f, refl }\n\n/-- Given a congruence relation `c` on a monoid and a homomorphism `f` constant on `c`'s\n    equivalence classes, `f` has the same image as the homomorphism that `f` induces on the\n    quotient. -/\n@[to_additive \"Given an additive congruence relation `c` on an `add_monoid` and a homomorphism `f`\nconstant on `c`'s equivalence classes, `f` has the same image as the homomorphism that `f` induces\non the quotient.\"]\ntheorem lift_range (H : c ≤ ker f) : (c.lift f H).mrange = f.mrange :=\nsubmonoid.ext $ λ x, ⟨by rintros ⟨⟨y⟩, hy⟩; exact ⟨y, hy⟩, λ ⟨y, hy⟩, ⟨↑y, hy⟩⟩\n\n/-- Surjective monoid homomorphisms constant on a congruence relation `c`'s equivalence classes\n    induce a surjective homomorphism on `c`'s quotient. -/\n@[to_additive \"Surjective `add_monoid` homomorphisms constant on an additive congruence\nrelation `c`'s equivalence classes induce a surjective homomorphism on `c`'s quotient.\"]\nlemma lift_surjective_of_surjective (h : c ≤ ker f) (hf : surjective f) :\n  surjective (c.lift f h) :=\nλ y, exists.elim (hf y) $ λ w hw, ⟨w, (lift_mk' h w).symm ▸ hw⟩\n\nvariables (c f)\n\n/-- Given a monoid homomorphism `f` from `M` to `P`, the kernel of `f` is the unique congruence\n    relation on `M` whose induced map from the quotient of `M` to `P` is injective. -/\n@[to_additive \"Given an `add_monoid` homomorphism `f` from `M` to `P`, the kernel of `f`\nis the unique additive congruence relation on `M` whose induced map from the quotient of `M`\nto `P` is injective.\"]\nlemma ker_eq_lift_of_injective (H : c ≤ ker f) (h : injective (c.lift f H)) :\n  ker f = c :=\nto_setoid_inj $ ker_eq_lift_of_injective f H h\n\nvariables {c}\n\n/-- The homomorphism induced on the quotient of a monoid by the kernel of a monoid homomorphism. -/\n@[to_additive \"The homomorphism induced on the quotient of an `add_monoid` by the kernel\nof an `add_monoid` homomorphism.\"]\ndef ker_lift : (ker f).quotient →* P :=\n(ker f).lift f $ λ _ _, id\n\nvariables {f}\n\n/-- The diagram described by the universal property for quotients of monoids, when the congruence\n    relation is the kernel of the homomorphism, commutes. -/\n@[simp, to_additive \"The diagram described by the universal property for quotients\nof `add_monoid`s, when the additive congruence relation is the kernel of the homomorphism,\ncommutes.\"]\nlemma ker_lift_mk (x : M) :  ker_lift f x = f x := rfl\n\n/-- Given a monoid homomorphism `f`, the induced homomorphism on the quotient by `f`'s kernel has\n    the same image as `f`. -/\n@[simp, to_additive \"Given an `add_monoid` homomorphism `f`, the induced homomorphism\non the quotient by `f`'s kernel has the same image as `f`.\"]\nlemma ker_lift_range_eq : (ker_lift f).mrange = f.mrange :=\nlift_range $ λ _ _, id\n\n/-- A monoid homomorphism `f` induces an injective homomorphism on the quotient by `f`'s kernel. -/\n@[to_additive \"An `add_monoid` homomorphism `f` induces an injective homomorphism on the quotient\nby `f`'s kernel.\"]\nlemma ker_lift_injective (f : M →* P) : injective (ker_lift f) :=\nλ x y, quotient.induction_on₂' x y $ λ _ _, (ker f).eq.2\n\n/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, `d`'s quotient\n    map induces a homomorphism from the quotient by `c` to the quotient by `d`. -/\n@[to_additive \"Given additive congruence relations `c, d` on an `add_monoid` such that `d`\ncontains `c`, `d`'s quotient map induces a homomorphism from the quotient by `c` to the quotient\nby `d`.\"]\ndef map (c d : con M) (h : c ≤ d) : c.quotient →* d.quotient :=\nc.lift d.mk' $ λ x y hc, show (ker d.mk') x y, from\n  (mk'_ker d).symm ▸ h hc\n\n/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, the definition of\n    the homomorphism from the quotient by `c` to the quotient by `d` induced by `d`'s quotient\n    map. -/\n@[to_additive \"Given additive congruence relations `c, d` on an `add_monoid` such that `d`\ncontains `c`, the definition of the homomorphism from the quotient by `c` to the quotient by `d`\ninduced by `d`'s quotient map.\"]\nlemma map_apply {c d : con M} (h : c ≤ d) (x) :\n  c.map d h x = c.lift d.mk' (λ x y hc, d.eq.2 $ h hc) x := rfl\n\nvariables (c)\n\n/-- The first isomorphism theorem for monoids. -/\n@[to_additive \"The first isomorphism theorem for `add_monoid`s.\"]\nnoncomputable def quotient_ker_equiv_range (f : M →* P) : (ker f).quotient ≃* f.mrange :=\n{ map_mul' := monoid_hom.map_mul _,\n  ..equiv.of_bijective\n      ((@mul_equiv.to_monoid_hom (ker_lift f).mrange _ _ _\n        $ mul_equiv.submonoid_congr ker_lift_range_eq).comp (ker_lift f).mrange_restrict) $\n      (equiv.bijective _).comp\n        ⟨λ x y h, ker_lift_injective f $ by rcases x; rcases y; injections,\n         λ ⟨w, z, hz⟩, ⟨z, by rcases hz; rcases _x; refl⟩⟩ }\n\n/-- The first isomorphism theorem for monoids in the case of a homomorphism with right inverse. -/\n@[to_additive \"The first isomorphism theorem for `add_monoid`s in the case of a homomorphism\nwith right inverse.\", simps]\ndef quotient_ker_equiv_of_right_inverse (f : M →* P) (g : P → M)\n  (hf : function.right_inverse g f) :\n  (ker f).quotient ≃* P :=\n{ to_fun := ker_lift f,\n  inv_fun := coe ∘ g,\n  left_inv := λ x, ker_lift_injective _ (by rw [function.comp_app, ker_lift_mk, hf]),\n  right_inv := hf,\n  .. ker_lift f }\n\n/-- The first isomorphism theorem for monoids in the case of a surjective homomorphism.\n\nFor a `computable` version, see `con.quotient_ker_equiv_of_right_inverse`.\n-/\n@[to_additive \"The first isomorphism theorem for `add_monoid`s in the case of a surjective\nhomomorphism.\n\nFor a `computable` version, see `add_con.quotient_ker_equiv_of_right_inverse`.\n\"]\nnoncomputable def quotient_ker_equiv_of_surjective (f : M →* P) (hf : surjective f) :\n  (ker f).quotient ≃* P :=\nquotient_ker_equiv_of_right_inverse _ _ hf.has_right_inverse.some_spec\n\n/-- The second isomorphism theorem for monoids. -/\n@[to_additive \"The second isomorphism theorem for `add_monoid`s.\"]\nnoncomputable def comap_quotient_equiv (f : N →* M) :\n  (comap f f.map_mul c).quotient ≃* (c.mk'.comp f).mrange :=\n(con.congr comap_eq).trans $ quotient_ker_equiv_range $ c.mk'.comp f\n\n/-- The third isomorphism theorem for monoids. -/\n@[to_additive \"The third isomorphism theorem for `add_monoid`s.\"]\ndef quotient_quotient_equiv_quotient (c d : con M) (h : c ≤ d) :\n  (ker (c.map d h)).quotient ≃* d.quotient :=\n{ map_mul' := λ x y, con.induction_on₂ x y $ λ w z, con.induction_on₂ w z $ λ a b,\n    show _ = d.mk' a * d.mk' b, by rw ←d.mk'.map_mul; refl,\n  ..quotient_quotient_equiv_quotient c.to_setoid d.to_setoid h }\n\nend mul_one_class\n\nsection monoids\n\n/-- Multiplicative congruence relations preserve natural powers. -/\n@[to_additive add_con.nsmul \"Additive congruence relations preserve natural scaling.\"]\nprotected lemma pow {M : Type*} [monoid M] (c : con M) :\n  ∀ (n : ℕ) {w x}, c w x → c (w ^ n) (x ^ n)\n| 0 w x h := by simpa using c.refl _\n| (nat.succ n) w x h := by simpa [pow_succ] using c.mul h (pow n h)\n\n@[to_additive]\ninstance {M : Type*} [mul_one_class M] (c : con M) : has_one c.quotient :=\n{ one := ((1 : M) : c.quotient) }\n\ninstance _root_.add_con.quotient.has_nsmul\n  {M : Type*} [add_monoid M] (c : add_con M) : has_scalar ℕ c.quotient :=\n{ smul := λ n x, quotient.lift_on' x (λ w, ((n • w : M) : c.quotient))\n     $ λ x y h, c.eq.2 $ c.nsmul n h}\n\n@[to_additive add_con.quotient.has_nsmul]\ninstance {M : Type*} [monoid M] (c : con M) : has_pow c.quotient ℕ :=\n{ pow := λ x n, quotient.lift_on' x (λ w, ((w ^ n : M) : c.quotient))\n     $ λ x y h, c.eq.2 $ c.pow n h}\n\n/-- The quotient of a semigroup by a congruence relation is a semigroup. -/\n@[to_additive \"The quotient of an `add_semigroup` by an additive congruence relation is\nan `add_semigroup`.\"]\ninstance semigroup {M : Type*} [semigroup M] (c : con M) : semigroup c.quotient :=\nfunction.surjective.semigroup _ quotient.surjective_quotient_mk' (λ _ _, rfl)\n\n/-- The quotient of a commutative semigroup by a congruence relation is a semigroup. -/\n@[to_additive \"The quotient of an `add_comm_semigroup` by an additive congruence relation is\nan `add_semigroup`.\"]\ninstance comm_semigroup {M : Type*} [comm_semigroup M] (c : con M) : comm_semigroup c.quotient :=\nfunction.surjective.comm_semigroup _ quotient.surjective_quotient_mk' (λ _ _, rfl)\n\n/-- The quotient of a monoid by a congruence relation is a monoid. -/\n@[to_additive \"The quotient of an `add_monoid` by an additive congruence relation is\nan `add_monoid`.\"]\ninstance monoid {M : Type*} [monoid M] (c : con M) : monoid c.quotient :=\nfunction.surjective.monoid _ quotient.surjective_quotient_mk' rfl (λ _ _, rfl) (λ _ _, rfl)\n\n/-- The quotient of a `comm_monoid` by a congruence relation is a `comm_monoid`. -/\n@[to_additive \"The quotient of an `add_comm_monoid` by an additive congruence\nrelation is an `add_comm_monoid`.\"]\ninstance comm_monoid {M : Type*} [comm_monoid M] (c : con M) :\n  comm_monoid c.quotient :=\nfunction.surjective.comm_monoid _ quotient.surjective_quotient_mk' rfl (λ _ _, rfl) (λ _ _, rfl)\n\nend monoids\n\nsection groups\n\nvariables {M} [group M] [group N] [group P] (c : con M)\n\n/-- Multiplicative congruence relations preserve inversion. -/\n@[to_additive \"Additive congruence relations preserve negation.\"]\nprotected lemma inv : ∀ {w x}, c w x → c w⁻¹ x⁻¹ :=\nλ x y h, by simpa using c.symm (c.mul (c.mul (c.refl x⁻¹) h) (c.refl y⁻¹))\n\n/-- Multiplicative congruence relations preserve division. -/\n@[to_additive \"Additive congruence relations preserve subtraction.\"]\nprotected lemma div : ∀ {w x y z}, c w x → c y z → c (w / y) (x / z) :=\nλ w x y z h1 h2, by simpa only [div_eq_mul_inv] using c.mul h1 (c.inv h2)\n\n/-- Multiplicative congruence relations preserve integer powers. -/\n@[to_additive add_con.zsmul \"Additive congruence relations preserve integer scaling.\"]\nprotected lemma zpow : ∀ (n : ℤ) {w x}, c w x → c (w ^ n) (x ^ n)\n| (int.of_nat n) w x h := by simpa only [zpow_of_nat] using c.pow _ h\n| -[1+ n] w x h := by simpa only [zpow_neg_succ_of_nat] using c.inv (c.pow _ h)\n\n/-- The inversion induced on the quotient by a congruence relation on a type with a\n    inversion. -/\n@[to_additive \"The negation induced on the quotient by an additive congruence relation on a type\nwith an negation.\"]\ninstance has_inv : has_inv c.quotient :=\n⟨λ x, quotient.lift_on' x (λ w, ((w⁻¹ : M) : c.quotient))\n     $ λ x y h, c.eq.2 $ c.inv h⟩\n\n/-- The division induced on the quotient by a congruence relation on a type with a\n    division. -/\n@[to_additive \"The subtraction induced on the quotient by an additive congruence relation on a type\nwith a subtraction.\"]\ninstance has_div : has_div c.quotient :=\n⟨λ x y, quotient.lift_on₂' x y (λ w z, ((w / z : M) : c.quotient))\n     $ λ _ _ _ _ h1 h2, c.eq.2 $ c.div h1 h2⟩\n\n/-- The integer scaling induced on the quotient by a congruence relation on a type with a\n    subtraction. -/\ninstance _root_.add_con.quotient.has_zsmul\n  {M : Type*} [add_group M] (c : add_con M) : has_scalar ℤ c.quotient :=\n⟨λ z x, quotient.lift_on' x (λ w, ((z • w : M) : c.quotient))\n     $ λ x y h, c.eq.2 $ c.zsmul z h⟩\n\n/-- The integer power induced on the quotient by a congruence relation on a type with a\n    division. -/\n@[to_additive add_con.quotient.has_zsmul]\ninstance has_zpow : has_pow c.quotient ℤ :=\n⟨λ x z, quotient.lift_on' x (λ w, ((w ^ z : M) : c.quotient))\n     $ λ x y h, c.eq.2 $ c.zpow z h⟩\n\n/-- The quotient of a group by a congruence relation is a group. -/\n@[to_additive \"The quotient of an `add_group` by an additive congruence relation is\nan `add_group`.\"]\ninstance group : group c.quotient :=\nfunction.surjective.group _ quotient.surjective_quotient_mk' rfl\n  (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\nend groups\n\nsection units\n\nvariables {α : Type*} [monoid M] {c : con M}\n\n/-- In order to define a function `(con.quotient c)ˣ → α` on the units of `con.quotient c`,\nwhere `c : con M` is a multiplicative congruence on a monoid, it suffices to define a function `f`\nthat takes elements `x y : M` with proofs of `c (x * y) 1` and `c (y * x) 1`, and returns an element\nof `α` provided that `f x y _ _ = f x' y' _ _` whenever `c x x'` and `c y y'`. -/\n@[to_additive] def lift_on_units (u : units c.quotient)\n  (f : Π (x y : M), c (x * y) 1 → c (y * x) 1 → α)\n  (Hf : ∀ x y hxy hyx x' y' hxy' hyx', c x x' → c y y' → f x y hxy hyx = f x' y' hxy' hyx') :\n  α :=\nbegin\n  refine @con.hrec_on₂ M M _ _ c c (λ x y, x * y = 1 → y * x = 1 → α)\n    (u : c.quotient) (↑u⁻¹ : c.quotient)\n    (λ (x y : M) (hxy : (x * y : c.quotient) = 1) (hyx : (y * x : c.quotient) = 1),\n    f x y (c.eq.1 hxy) (c.eq.1 hyx)) (λ x y x' y' hx hy, _) u.3 u.4,\n  ext1, { rw [c.eq.2 hx, c.eq.2 hy] },\n  rintro Hxy Hxy' -,\n  ext1, { rw [c.eq.2 hx, c.eq.2 hy] },\n  rintro Hyx Hyx' -,\n  exact heq_of_eq (Hf _ _ _ _ _ _ _ _ hx hy)\nend\n\n/-- In order to define a function `(con.quotient c)ˣ → α` on the units of `con.quotient c`,\nwhere `c : con M` is a multiplicative congruence on a monoid, it suffices to define a function `f`\nthat takes elements `x y : M` with proofs of `c (x * y) 1` and `c (y * x) 1`, and returns an element\nof `α` provided that `f x y _ _ = f x' y' _ _` whenever `c x x'` and `c y y'`. -/\nadd_decl_doc add_con.lift_on_add_units\n\n@[simp, to_additive]\nlemma lift_on_units_mk (f : Π (x y : M), c (x * y) 1 → c (y * x) 1 → α)\n  (Hf : ∀ x y hxy hyx x' y' hxy' hyx', c x x' → c y y' → f x y hxy hyx = f x' y' hxy' hyx')\n  (x y : M) (hxy hyx) :\n  lift_on_units ⟨(x : c.quotient), y, hxy, hyx⟩ f Hf = f x y (c.eq.1 hxy) (c.eq.1 hyx) :=\nrfl\n\n@[elab_as_eliminator, to_additive]\nlemma induction_on_units {p : units c.quotient → Prop} (u : units c.quotient)\n  (H : ∀ (x y : M) (hxy : c (x * y) 1) (hyx : c (y * x) 1), p ⟨x, y, c.eq.2 hxy, c.eq.2 hyx⟩) :\n  p u :=\nbegin\n  rcases u with ⟨⟨x⟩, ⟨y⟩, h₁, h₂⟩,\n  exact H x y (c.eq.1 h₁) (c.eq.1 h₂)\nend\n\nend units\n\nend con\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/group_theory/congruence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6825737473266735, "lm_q1q2_score": 0.4635895498006035}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard,\nAmelia Livingston, Yury Kudryashov\n-/\n\nimport group_theory.submonoid.basic\nimport data.equiv.mul_add\nimport algebra.group.prod\nimport algebra.group.inj_surj\n\n/-!\n# Operations on `submonoid`s\n\nIn this file we define various operations on `submonoid`s and `monoid_hom`s.\n\n## Main definitions\n\n### Conversion between multiplicative and additive definitions\n\n* `submonoid.to_add_submonoid`, `submonoid.to_add_submonoid'`, `add_submonoid.to_submonoid`,\n  `add_submonoid.to_submonoid'`: convert between multiplicative and additive submonoids of `M`,\n  `multiplicative M`, and `additive M`. These are stated as `order_iso`s.\n\n### (Commutative) monoid structure on a submonoid\n\n* `submonoid.to_monoid`, `submonoid.to_comm_monoid`: a submonoid inherits a (commutative) monoid\n  structure.\n\n### Operations on submonoids\n\n* `submonoid.comap`: preimage of a submonoid under a monoid homomorphism as a submonoid of the\n  domain;\n* `submonoid.map`: image of a submonoid under a monoid homomorphism as a submonoid of the codomain;\n* `submonoid.prod`: product of two submonoids `s : submonoid M` and `t : submonoid N` as a submonoid\n  of `M × N`;\n\n### Monoid homomorphisms between submonoid\n\n* `submonoid.subtype`: embedding of a submonoid into the ambient monoid.\n* `submonoid.inclusion`: given two submonoids `S`, `T` such that `S ≤ T`, `S.inclusion T` is the\n  inclusion of `S` into `T` as a monoid homomorphism;\n* `mul_equiv.submonoid_congr`: converts a proof of `S = T` into a monoid isomorphism between `S`\n  and `T`.\n* `submonoid.prod_equiv`: monoid isomorphism between `s.prod t` and `s × t`;\n\n### Operations on `monoid_hom`s\n\n* `monoid_hom.mrange`: range of a monoid homomorphism as a submonoid of the codomain;\n* `monoid_hom.mrestrict`: restrict a monoid homomorphism to a submonoid;\n* `monoid_hom.cod_mrestrict`: restrict the codomain of a monoid homomorphism to a submonoid;\n* `monoid_hom.mrange_restrict`: restrict a monoid homomorphism to its range;\n\n## Tags\n\nsubmonoid, range, product, map, comap\n-/\n\nvariables {M N P : Type*} [mul_one_class M] [mul_one_class N] [mul_one_class P] (S : submonoid M)\n\n/-!\n### Conversion to/from `additive`/`multiplicative`\n-/\n\nsection\n\n/-- Submonoids of monoid `M` are isomorphic to additive submonoids of `additive M`. -/\n@[simps]\ndef submonoid.to_add_submonoid : submonoid M ≃o add_submonoid (additive M) :=\n{ to_fun := λ S,\n  { carrier := additive.to_mul ⁻¹' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  inv_fun := λ S,\n  { carrier := additive.of_mul ⁻¹' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  left_inv := λ x, by cases x; refl,\n  right_inv := λ x, by cases x; refl,\n  map_rel_iff' := λ a b, iff.rfl, }\n\n/-- Additive submonoids of an additive monoid `additive M` are isomorphic to submonoids of `M`. -/\nabbreviation add_submonoid.to_submonoid' : add_submonoid (additive M) ≃o submonoid M :=\nsubmonoid.to_add_submonoid.symm\n\nlemma submonoid.to_add_submonoid_closure (S : set M) :\n  (submonoid.closure S).to_add_submonoid = add_submonoid.closure (additive.to_mul ⁻¹' S) :=\nle_antisymm\n  (submonoid.to_add_submonoid.to_galois_connection.l_le $\n    submonoid.closure_le.2 add_submonoid.subset_closure)\n  (add_submonoid.closure_le.2 submonoid.subset_closure)\n\nlemma add_submonoid.to_submonoid'_closure (S : set (additive M)) :\n  (add_submonoid.closure S).to_submonoid' = submonoid.closure (multiplicative.of_add ⁻¹' S) :=\nle_antisymm\n  (add_submonoid.to_submonoid'.to_galois_connection.l_le $\n    add_submonoid.closure_le.2 submonoid.subset_closure)\n  (submonoid.closure_le.2 add_submonoid.subset_closure)\n\nend\n\nsection\n\nvariables {A : Type*} [add_zero_class A]\n\n/-- Additive submonoids of an additive monoid `A` are isomorphic to\nmultiplicative submonoids of `multiplicative A`. -/\n@[simps]\ndef add_submonoid.to_submonoid : add_submonoid A ≃o submonoid (multiplicative A) :=\n{ to_fun := λ S,\n  { carrier := multiplicative.to_add ⁻¹' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  inv_fun := λ S,\n  { carrier := multiplicative.of_add ⁻¹' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  left_inv := λ x, by cases x; refl,\n  right_inv := λ x, by cases x; refl,\n  map_rel_iff' := λ a b, iff.rfl, }\n\n/-- Submonoids of a monoid `multiplicative A` are isomorphic to additive submonoids of `A`. -/\nabbreviation submonoid.to_add_submonoid' : submonoid (multiplicative A) ≃o add_submonoid A :=\nadd_submonoid.to_submonoid.symm\n\nlemma add_submonoid.to_submonoid_closure (S : set A) :\n  (add_submonoid.closure S).to_submonoid = submonoid.closure (multiplicative.to_add ⁻¹' S) :=\nle_antisymm\n  (add_submonoid.to_submonoid.to_galois_connection.l_le $\n    add_submonoid.closure_le.2 submonoid.subset_closure)\n  (submonoid.closure_le.2 add_submonoid.subset_closure)\n\nlemma submonoid.to_add_submonoid'_closure (S : set (multiplicative A)) :\n  (submonoid.closure S).to_add_submonoid' = add_submonoid.closure (additive.of_mul ⁻¹' S) :=\nle_antisymm\n  (submonoid.to_add_submonoid'.to_galois_connection.l_le $\n    submonoid.closure_le.2 add_submonoid.subset_closure)\n  (add_submonoid.closure_le.2 submonoid.subset_closure)\n\nend\n\nnamespace submonoid\n\nopen set\n\n/-!\n### `comap` and `map`\n-/\n\n/-- The preimage of a submonoid along a monoid homomorphism is a submonoid. -/\n@[to_additive \"The preimage of an `add_submonoid` along an `add_monoid` homomorphism is an\n`add_submonoid`.\"]\ndef comap (f : M →* N) (S : submonoid N) : submonoid M :=\n{ carrier := (f ⁻¹' S),\n  one_mem' := show f 1 ∈ S, by rw f.map_one; exact S.one_mem,\n  mul_mem' := λ a b ha hb,\n    show f (a * b) ∈ S, by rw f.map_mul; exact S.mul_mem ha hb }\n\n@[simp, to_additive]\nlemma coe_comap (S : submonoid N) (f : M →* N) : (S.comap f : set M) = f ⁻¹' S := rfl\n\n@[simp, to_additive]\nlemma mem_comap {S : submonoid N} {f : M →* N} {x : M} : x ∈ S.comap f ↔ f x ∈ S := iff.rfl\n\n@[to_additive]\nlemma comap_comap (S : submonoid P) (g : N →* P) (f : M →* N) :\n  (S.comap g).comap f = S.comap (g.comp f) :=\nrfl\n\n@[simp, to_additive]\nlemma comap_id (S : submonoid P) : S.comap (monoid_hom.id _) = S :=\next (by simp)\n\n/-- The image of a submonoid along a monoid homomorphism is a submonoid. -/\n@[to_additive \"The image of an `add_submonoid` along an `add_monoid` homomorphism is\nan `add_submonoid`.\"]\ndef map (f : M →* N) (S : submonoid M) : submonoid N :=\n{ carrier := (f '' S),\n  one_mem' := ⟨1, S.one_mem, f.map_one⟩,\n  mul_mem' := begin rintros _ _ ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩, exact ⟨x * y, S.mul_mem hx hy,\n    by rw f.map_mul; refl⟩ end }\n\n@[simp, to_additive]\nlemma coe_map (f : M →* N) (S : submonoid M) :\n  (S.map f : set N) = f '' S := rfl\n\n@[simp, to_additive]\nlemma mem_map {f : M →* N} {S : submonoid M} {y : N} :\n  y ∈ S.map f ↔ ∃ x ∈ S, f x = y :=\nmem_image_iff_bex\n\n@[to_additive]\nlemma mem_map_of_mem (f : M →* N) (x : S) : f x ∈ S.map f :=\nmem_image_of_mem f x.2\n\n@[to_additive]\nlemma map_map (g : N →* P) (f : M →* N) : (S.map f).map g = S.map (g.comp f) :=\nset_like.coe_injective $ image_image _ _ _\n\n@[to_additive]\nlemma map_le_iff_le_comap {f : M →* N} {S : submonoid M} {T : submonoid N} :\n  S.map f ≤ T ↔ S ≤ T.comap f :=\nimage_subset_iff\n\n@[to_additive]\nlemma gc_map_comap (f : M →* N) : galois_connection (map f) (comap f) :=\nλ S T, map_le_iff_le_comap\n\n@[to_additive]\nlemma map_le_of_le_comap {T : submonoid N} {f : M →* N} : S ≤ T.comap f → S.map f ≤ T :=\n(gc_map_comap f).l_le\n\n@[to_additive]\nlemma le_comap_of_map_le {T : submonoid N} {f : M →* N} : S.map f ≤ T → S ≤ T.comap f :=\n(gc_map_comap f).le_u\n\n@[to_additive]\nlemma le_comap_map {f : M →* N} : S ≤ (S.map f).comap f :=\n(gc_map_comap f).le_u_l _\n\n@[to_additive]\nlemma map_comap_le {S : submonoid N} {f : M →* N} : (S.comap f).map f ≤ S :=\n(gc_map_comap f).l_u_le _\n\n@[to_additive]\nlemma monotone_map {f : M →* N} : monotone (map f) :=\n(gc_map_comap f).monotone_l\n\n@[to_additive]\nlemma monotone_comap {f : M →* N} : monotone (comap f) :=\n(gc_map_comap f).monotone_u\n\n@[simp, to_additive]\nlemma map_comap_map {f : M →* N} : ((S.map f).comap f).map f = S.map f :=\ncongr_fun ((gc_map_comap f).l_u_l_eq_l) _\n\n@[simp, to_additive]\nlemma comap_map_comap {S : submonoid N} {f : M →* N} : ((S.comap f).map f).comap f = S.comap f :=\ncongr_fun ((gc_map_comap f).u_l_u_eq_u) _\n\n@[to_additive]\nlemma map_sup (S T : submonoid M) (f : M →* N) : (S ⊔ T).map f = S.map f ⊔ T.map f :=\n(gc_map_comap f).l_sup\n\n@[to_additive]\nlemma map_supr {ι : Sort*} (f : M →* N) (s : ι → submonoid M) :\n  (supr s).map f = ⨆ i, (s i).map f :=\n(gc_map_comap f).l_supr\n\n@[to_additive]\nlemma comap_inf (S T : submonoid N) (f : M →* N) : (S ⊓ T).comap f = S.comap f ⊓ T.comap f :=\n(gc_map_comap f).u_inf\n\n@[to_additive]\nlemma comap_infi {ι : Sort*} (f : M →* N) (s : ι → submonoid N) :\n  (infi s).comap f = ⨅ i, (s i).comap f :=\n(gc_map_comap f).u_infi\n\n@[simp, to_additive] lemma map_bot (f : M →* N) : (⊥ : submonoid M).map f = ⊥ :=\n(gc_map_comap f).l_bot\n\n@[simp, to_additive] \n\n@[simp, to_additive] lemma map_id (S : submonoid M) : S.map (monoid_hom.id M) = S :=\next (λ x, ⟨λ ⟨_, h, rfl⟩, h, λ h, ⟨_, h, rfl⟩⟩)\n\nsection galois_coinsertion\n\nvariables {ι : Type*} {f : M →* N} (hf : function.injective f)\n\ninclude hf\n\n/-- `map f` and `comap f` form a `galois_coinsertion` when `f` is injective. -/\ndef gci_map_comap : galois_coinsertion (map f) (comap f) :=\n(gc_map_comap f).to_galois_coinsertion\n  (λ S x, by simp [mem_comap, mem_map, hf.eq_iff])\n\nlemma comap_map_eq_of_injective (S : submonoid M) : (S.map f).comap f = S :=\n(gci_map_comap hf).u_l_eq _\n\nlemma comap_surjective_of_injective : function.surjective (comap f) :=\n(gci_map_comap hf).u_surjective\n\nlemma map_injective_of_injective : function.injective (map f) :=\n(gci_map_comap hf).l_injective\n\nlemma comap_inf_map_of_injective (S T : submonoid M) : (S.map f ⊓ T.map f).comap f = S ⊓ T :=\n(gci_map_comap hf).u_inf_l _ _\n\nlemma comap_infi_map_of_injective (S : ι → submonoid M) : (⨅ i, (S i).map f).comap f = infi S :=\n(gci_map_comap hf).u_infi_l _\n\nlemma comap_sup_map_of_injective (S T : submonoid M) : (S.map f ⊔ T.map f).comap f = S ⊔ T :=\n(gci_map_comap hf).u_sup_l _ _\n\nlemma comap_supr_map_of_injective (S : ι → submonoid M) : (⨆ i, (S i).map f).comap f = supr S :=\n(gci_map_comap hf).u_supr_l _\n\nlemma map_le_map_iff_of_injective {S T : submonoid M} : S.map f ≤ T.map f ↔ S ≤ T :=\n(gci_map_comap hf).l_le_l_iff\n\nlemma map_strict_mono_of_injective : strict_mono (map f) :=\n(gci_map_comap hf).strict_mono_l\n\nend galois_coinsertion\n\nsection galois_insertion\n\nvariables {ι : Type*} {f : M →* N} (hf : function.surjective f)\n\ninclude hf\n\n/-- `map f` and `comap f` form a `galois_insertion` when `f` is surjective. -/\ndef gi_map_comap : galois_insertion (map f) (comap f) :=\n(gc_map_comap f).to_galois_insertion\n  (λ S x h, let ⟨y, hy⟩ := hf x in mem_map.2 ⟨y, by simp [hy, h]⟩)\n\nlemma map_comap_eq_of_surjective (S : submonoid N) : (S.comap f).map f = S :=\n(gi_map_comap hf).l_u_eq _\n\nlemma map_surjective_of_surjective : function.surjective (map f) :=\n(gi_map_comap hf).l_surjective\n\nlemma comap_injective_of_surjective : function.injective (comap f) :=\n(gi_map_comap hf).u_injective\n\nlemma map_inf_comap_of_surjective (S T : submonoid N) : (S.comap f ⊓ T.comap f).map f = S ⊓ T :=\n(gi_map_comap hf).l_inf_u _ _\n\nlemma map_infi_comap_of_surjective (S : ι → submonoid N) : (⨅ i, (S i).comap f).map f = infi S :=\n(gi_map_comap hf).l_infi_u _\n\nlemma map_sup_comap_of_surjective (S T : submonoid N) : (S.comap f ⊔ T.comap f).map f = S ⊔ T :=\n(gi_map_comap hf).l_sup_u _ _\n\nlemma map_supr_comap_of_surjective (S : ι → submonoid N) : (⨆ i, (S i).comap f).map f = supr S :=\n(gi_map_comap hf).l_supr_u _\n\nlemma comap_le_comap_iff_of_surjective {S T : submonoid N} : S.comap f ≤ T.comap f ↔ S ≤ T :=\n(gi_map_comap hf).u_le_u_iff\n\nlemma comap_strict_mono_of_surjective : strict_mono (comap f) :=\n(gi_map_comap hf).strict_mono_u\n\nend galois_insertion\n\n/-- A submonoid of a monoid inherits a multiplication. -/\n@[to_additive \"An `add_submonoid` of an `add_monoid` inherits an addition.\"]\ninstance has_mul : has_mul S := ⟨λ a b, ⟨a.1 * b.1, S.mul_mem a.2 b.2⟩⟩\n\n/-- A submonoid of a monoid inherits a 1. -/\n@[to_additive \"An `add_submonoid` of an `add_monoid` inherits a zero.\"]\ninstance has_one : has_one S := ⟨⟨_, S.one_mem⟩⟩\n\n@[simp, to_additive] lemma coe_mul (x y : S) : (↑(x * y) : M) = ↑x * ↑y := rfl\n@[simp, to_additive] lemma coe_one : ((1 : S) : M) = 1 := rfl\nattribute [norm_cast] coe_mul coe_one\nattribute [norm_cast] add_submonoid.coe_add add_submonoid.coe_zero\n\n/-- A submonoid of a unital magma inherits a unital magma structure. -/\n@[to_additive \"An `add_submonoid` of an unital additive magma inherits an unital additive magma\nstructure.\"]\ninstance to_mul_one_class {M : Type*} [mul_one_class M] (S : submonoid M) : mul_one_class S :=\nsubtype.coe_injective.mul_one_class coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a monoid inherits a monoid structure. -/\n@[to_additive \"An `add_submonoid` of an `add_monoid` inherits an `add_monoid`\nstructure.\"]\ninstance to_monoid {M : Type*} [monoid M] (S : submonoid M) : monoid S :=\nsubtype.coe_injective.monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a `comm_monoid` is a `comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of an `add_comm_monoid` is\nan `add_comm_monoid`.\"]\ninstance to_comm_monoid {M} [comm_monoid M] (S : submonoid M) : comm_monoid S :=\nsubtype.coe_injective.comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of an `ordered_comm_monoid` is an `ordered_comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of an `ordered_add_comm_monoid` is\nan `ordered_add_comm_monoid`.\"]\ninstance to_ordered_comm_monoid {M} [ordered_comm_monoid M] (S : submonoid M) :\n  ordered_comm_monoid S :=\nsubtype.coe_injective.ordered_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a `linear_ordered_comm_monoid` is a `linear_ordered_comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of a `linear_ordered_add_comm_monoid` is\na `linear_ordered_add_comm_monoid`.\"]\ninstance to_linear_ordered_comm_monoid {M} [linear_ordered_comm_monoid M] (S : submonoid M) :\n  linear_ordered_comm_monoid S :=\nsubtype.coe_injective.linear_ordered_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of an `ordered_cancel_comm_monoid` is an `ordered_cancel_comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of an `ordered_cancel_add_comm_monoid` is\nan `ordered_cancel_add_comm_monoid`.\"]\ninstance to_ordered_cancel_comm_monoid {M} [ordered_cancel_comm_monoid M] (S : submonoid M) :\n  ordered_cancel_comm_monoid S :=\nsubtype.coe_injective.ordered_cancel_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a `linear_ordered_cancel_comm_monoid` is a `linear_ordered_cancel_comm_monoid`.\n-/\n@[to_additive \"An `add_submonoid` of a `linear_ordered_cancel_add_comm_monoid` is\na `linear_ordered_cancel_add_comm_monoid`.\"]\ninstance to_linear_ordered_cancel_comm_monoid {M} [linear_ordered_cancel_comm_monoid M]\n  (S : submonoid M) : linear_ordered_cancel_comm_monoid S :=\nsubtype.coe_injective.linear_ordered_cancel_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- The natural monoid hom from a submonoid of monoid `M` to `M`. -/\n@[to_additive \"The natural monoid hom from an `add_submonoid` of `add_monoid` `M` to `M`.\"]\ndef subtype : S →* M := ⟨coe, rfl, λ _ _, rfl⟩\n\n@[simp, to_additive] theorem coe_subtype : ⇑S.subtype = coe := rfl\n\n/-- An induction principle on elements of the type `submonoid.closure s`.\nIf `p` holds for `1` and all elements of `s`, and is preserved under multiplication, then `p`\nholds for all elements of the closure of `s`.\n\nThe difference with `submonoid.closure_induction` is that this acts on the subtype.\n-/\n@[to_additive \"An induction principle on elements of the type `add_submonoid.closure s`.\nIf `p` holds for `0` and all elements of `s`, and is preserved under addition, then `p`\nholds for all elements of the closure of `s`.\n\nThe difference with `add_submonoid.closure_induction` is that this acts on the subtype.\"]\nlemma closure_induction' (s : set M) {p : closure s → Prop}\n  (Hs : ∀ x (h : x ∈ s), p ⟨x, subset_closure h⟩)\n  (H1 : p 1)\n  (Hmul : ∀ x y, p x → p y → p (x * y))\n  (x : closure s) :\n  p x :=\nsubtype.rec_on x $ λ x hx, begin\n  refine exists.elim _ (λ (hx : x ∈ closure s) (hc : p ⟨x, hx⟩), hc),\n  exact closure_induction hx\n    (λ x hx, ⟨subset_closure hx, Hs x hx⟩)\n    ⟨one_mem _, H1⟩\n    (λ x y hx hy, exists.elim hx $ λ hx' hx, exists.elim hy $ λ hy' hy,\n      ⟨mul_mem _ hx' hy', Hmul _ _ hx hy⟩),\nend\n\nattribute [elab_as_eliminator] submonoid.closure_induction' add_submonoid.closure_induction'\n\n/-- Given `submonoid`s `s`, `t` of monoids `M`, `N` respectively, `s × t` as a submonoid\nof `M × N`. -/\n@[to_additive prod \"Given `add_submonoid`s `s`, `t` of `add_monoid`s `A`, `B` respectively, `s × t`\nas an `add_submonoid` of `A × B`.\"]\ndef prod (s : submonoid M) (t : submonoid N) : submonoid (M × N) :=\n{ carrier := (s : set M).prod t,\n  one_mem' := ⟨s.one_mem, t.one_mem⟩,\n  mul_mem' := λ p q hp hq, ⟨s.mul_mem hp.1 hq.1, t.mul_mem hp.2 hq.2⟩ }\n\n@[to_additive coe_prod]\nlemma coe_prod (s : submonoid M) (t : submonoid N) :\n (s.prod t : set (M × N)) = (s : set M).prod (t : set N) :=\nrfl\n\n@[to_additive mem_prod]\nlemma mem_prod {s : submonoid M} {t : submonoid N} {p : M × N} :\n  p ∈ s.prod t ↔ p.1 ∈ s ∧ p.2 ∈ t := iff.rfl\n\n@[to_additive prod_mono]\nlemma prod_mono {s₁ s₂ : submonoid M} {t₁ t₂ : submonoid N} (hs : s₁ ≤ s₂) (ht : t₁ ≤ t₂) :\n  s₁.prod t₁ ≤ s₂.prod t₂ :=\nset.prod_mono hs ht\n\n@[to_additive prod_top]\nlemma prod_top (s : submonoid M) :\n  s.prod (⊤ : submonoid N) = s.comap (monoid_hom.fst M N) :=\next $ λ x, by simp [mem_prod, monoid_hom.coe_fst]\n\n@[to_additive top_prod]\nlemma top_prod (s : submonoid N) :\n  (⊤ : submonoid M).prod s = s.comap (monoid_hom.snd M N) :=\next $ λ x, by simp [mem_prod, monoid_hom.coe_snd]\n\n@[simp, to_additive top_prod_top]\nlemma top_prod_top : (⊤ : submonoid M).prod (⊤ : submonoid N) = ⊤ :=\n(top_prod _).trans $ comap_top _\n\n@[to_additive] lemma bot_prod_bot : (⊥ : submonoid M).prod (⊥ : submonoid N) = ⊥ :=\nset_like.coe_injective $ by simp [coe_prod, prod.one_eq_mk]\n\n/-- The product of submonoids is isomorphic to their product as monoids. -/\n@[to_additive prod_equiv \"The product of additive submonoids is isomorphic to their product\nas additive monoids\"]\ndef prod_equiv (s : submonoid M) (t : submonoid N) : s.prod t ≃* s × t :=\n{ map_mul' := λ x y, rfl, .. equiv.set.prod ↑s ↑t }\n\nopen monoid_hom\n\n@[to_additive]\nlemma map_inl (s : submonoid M) : s.map (inl M N) = s.prod ⊥ :=\next $ λ p, ⟨λ ⟨x, hx, hp⟩, hp ▸ ⟨hx, set.mem_singleton 1⟩,\n  λ ⟨hps, hp1⟩, ⟨p.1, hps, prod.ext rfl $ (set.eq_of_mem_singleton hp1).symm⟩⟩\n\n@[to_additive]\nlemma map_inr (s : submonoid N) : s.map (inr M N) = prod ⊥ s :=\next $ λ p, ⟨λ ⟨x, hx, hp⟩, hp ▸ ⟨set.mem_singleton 1, hx⟩,\n  λ ⟨hp1, hps⟩, ⟨p.2, hps, prod.ext (set.eq_of_mem_singleton hp1).symm rfl⟩⟩\n\n@[simp, to_additive prod_bot_sup_bot_prod]\nlemma prod_bot_sup_bot_prod (s : submonoid M) (t : submonoid N) :\n  (s.prod ⊥) ⊔ (prod ⊥ t) = s.prod t :=\nle_antisymm (sup_le (prod_mono (le_refl s) bot_le) (prod_mono bot_le (le_refl t))) $\nassume p hp, prod.fst_mul_snd p ▸ mul_mem _\n  ((le_sup_left : s.prod ⊥ ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨hp.1, set.mem_singleton 1⟩)\n  ((le_sup_right : prod ⊥ t ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨set.mem_singleton 1, hp.2⟩)\n\nend submonoid\n\nnamespace monoid_hom\n\nopen submonoid\n\n/-- For many categories (monoids, modules, rings, ...) the set-theoretic image of a morphism `f` is\na subobject of the codomain. When this is the case, it is useful to define the range of a morphism\nin such a way that the underlying carrier set of the range subobject is definitionally\n`set.range f`. In particular this means that the types `↥(set.range f)` and `↥f.range` are\ninterchangeable without proof obligations.\n\nA convenient candidate definition for range which is mathematically correct is `map ⊤ f`, just as\n`set.range` could have been defined as `f '' set.univ`. However, this lacks the desired definitional\nconvenience, in that it both does not match `set.range`, and that it introduces a redudant `x ∈ ⊤`\nterm which clutters proofs. In such a case one may resort to the `copy`\npattern. A `copy` function converts the definitional problem for the carrier set of a subobject\ninto a one-off propositional proof obligation which one discharges while writing the definition of\nthe definitionally convenient range (the parameter `hs` in the example below).\n\nA good example is the case of a morphism of monoids. A convenient definition for\n`monoid_hom.mrange` would be `(⊤ : submonoid M).map f`. However since this lacks the required\ndefinitional convenience, we first define `submonoid.copy` as follows:\n```lean\nprotected def copy (S : submonoid M) (s : set M) (hs : s = S) : submonoid M :=\n{ carrier  := s,\n  one_mem' := hs.symm ▸ S.one_mem',\n  mul_mem' := hs.symm ▸ S.mul_mem' }\n```\nand then finally define:\n```lean\ndef mrange (f : M →* N) : submonoid N :=\n((⊤ : submonoid M).map f).copy (set.range f) set.image_univ.symm\n```\n-/\nlibrary_note \"range copy pattern\"\n\n/-- The range of a monoid homomorphism is a submonoid. See Note [range copy pattern]. -/\n@[to_additive \"The range of an `add_monoid_hom` is an `add_submonoid`.\"]\ndef mrange (f : M →* N) : submonoid N :=\n((⊤ : submonoid M).map f).copy (set.range f) set.image_univ.symm\n\n@[simp, to_additive]\nlemma coe_mrange (f : M →* N) :\n  (f.mrange : set N) = set.range f :=\nrfl\n\n@[simp, to_additive] lemma mem_mrange {f : M →* N} {y : N} :\n  y ∈ f.mrange ↔ ∃ x, f x = y :=\niff.rfl\n\n@[to_additive] lemma mrange_eq_map (f : M →* N) : f.mrange = (⊤ : submonoid M).map f :=\nby ext; simp\n\n@[to_additive]\nlemma map_mrange (g : N →* P) (f : M →* N) : f.mrange.map g = (g.comp f).mrange :=\nby simpa only [mrange_eq_map] using (⊤ : submonoid M).map_map g f\n\n@[to_additive]\nlemma mrange_top_iff_surjective {N} [mul_one_class N] {f : M →* N} :\n  f.mrange = (⊤ : submonoid N) ↔ function.surjective f :=\nset_like.ext'_iff.trans $ iff.trans (by rw [coe_mrange, coe_top]) set.range_iff_surjective\n\n/-- The range of a surjective monoid hom is the whole of the codomain. -/\n@[to_additive \"The range of a surjective `add_monoid` hom is the whole of the codomain.\"]\nlemma mrange_top_of_surjective {N} [mul_one_class N] (f : M →* N) (hf : function.surjective f) :\n  f.mrange = (⊤ : submonoid N) :=\nmrange_top_iff_surjective.2 hf\n\n@[to_additive]\nlemma mclosure_preimage_le (f : M →* N) (s : set N) :\n  closure (f ⁻¹' s) ≤ (closure s).comap f :=\nclosure_le.2 $ λ x hx, set_like.mem_coe.2 $ mem_comap.2 $ subset_closure hx\n\n/-- The image under a monoid hom of the submonoid generated by a set equals the submonoid generated\n    by the image of the set. -/\n@[to_additive \"The image under an `add_monoid` hom of the `add_submonoid` generated by a set equals\nthe `add_submonoid` generated by the image of the set.\"]\nlemma map_mclosure (f : M →* N) (s : set M) :\n  (closure s).map f = closure (f '' s) :=\nle_antisymm\n  (map_le_iff_le_comap.2 $ le_trans (closure_mono $ set.subset_preimage_image _ _)\n    (mclosure_preimage_le _ _))\n  (closure_le.2 $ set.image_subset _ subset_closure)\n\n/-- Restriction of a monoid hom to a submonoid of the domain. -/\n@[to_additive \"Restriction of an add_monoid hom to an `add_submonoid` of the domain.\"]\ndef mrestrict {N : Type*} [mul_one_class N] (f : M →* N) (S : submonoid M) : S →* N :=\nf.comp S.subtype\n\n@[simp, to_additive]\nlemma mrestrict_apply {N : Type*} [mul_one_class N] (f : M →* N) (x : S) : f.mrestrict S x = f x :=\nrfl\n\n/-- Restriction of a monoid hom to a submonoid of the codomain. -/\n@[to_additive \"Restriction of an `add_monoid` hom to an `add_submonoid` of the codomain.\"]\ndef cod_mrestrict (f : M →* N) (S : submonoid N) (h : ∀ x, f x ∈ S) : M →* S :=\n{ to_fun := λ n, ⟨f n, h n⟩,\n  map_one' := subtype.eq f.map_one,\n  map_mul' := λ x y, subtype.eq (f.map_mul x y) }\n\n/-- Restriction of a monoid hom to its range interpreted as a submonoid. -/\n@[to_additive \"Restriction of an `add_monoid` hom to its range interpreted as a submonoid.\"]\ndef mrange_restrict {N} [mul_one_class N] (f : M →* N) : M →* f.mrange :=\nf.cod_mrestrict f.mrange $ λ x, ⟨x, rfl⟩\n\n@[simp, to_additive]\nlemma coe_mrange_restrict {N} [mul_one_class N] (f : M →* N) (x : M) :\n  (f.mrange_restrict x : N) = f x :=\nrfl\n\nend monoid_hom\n\nnamespace submonoid\nopen monoid_hom\n\n@[to_additive]\nlemma mrange_inl : (inl M N).mrange = prod ⊤ ⊥ :=\nby simpa only [mrange_eq_map] using map_inl ⊤\n\n@[to_additive]\nlemma mrange_inr : (inr M N).mrange = prod ⊥ ⊤ :=\nby simpa only [mrange_eq_map] using map_inr ⊤\n\n@[to_additive]\nlemma mrange_inl' : (inl M N).mrange = comap (snd M N) ⊥ := mrange_inl.trans (top_prod _)\n\n@[to_additive]\nlemma mrange_inr' : (inr M N).mrange = comap (fst M N) ⊥ := mrange_inr.trans (prod_top _)\n\n@[simp, to_additive]\nlemma mrange_fst : (fst M N).mrange = ⊤ :=\n(fst M N).mrange_top_of_surjective $ @prod.fst_surjective _ _ ⟨1⟩\n\n@[simp, to_additive]\nlemma mrange_snd : (snd M N).mrange = ⊤ :=\n(snd M N).mrange_top_of_surjective $ @prod.snd_surjective _ _ ⟨1⟩\n@[simp, to_additive]\n\nlemma mrange_inl_sup_mrange_inr : (inl M N).mrange ⊔ (inr M N).mrange = ⊤ :=\nby simp only [mrange_inl, mrange_inr, prod_bot_sup_bot_prod, top_prod_top]\n\n/-- The monoid hom associated to an inclusion of submonoids. -/\n@[to_additive \"The `add_monoid` hom associated to an inclusion of submonoids.\"]\ndef inclusion {S T : submonoid M} (h : S ≤ T) : S →* T :=\nS.subtype.cod_mrestrict _ (λ x, h x.2)\n\n@[simp, to_additive]\nlemma range_subtype (s : submonoid M) : s.subtype.mrange = s :=\nset_like.coe_injective $ (coe_mrange _).trans $ subtype.range_coe\n\n@[to_additive] lemma eq_top_iff' : S = ⊤ ↔ ∀ x : M, x ∈ S :=\neq_top_iff.trans ⟨λ h m, h $ mem_top m, λ h m _, h m⟩\n\n@[to_additive] lemma eq_bot_iff_forall : S = ⊥ ↔ ∀ x ∈ S, x = (1 : M) :=\nbegin\n  split,\n  { intros h x x_in,\n    rwa [h, mem_bot] at x_in },\n  { intros h,\n    ext x,\n    rw mem_bot,\n    exact ⟨h x, by { rintros rfl, exact S.one_mem }⟩ },\nend\n\n@[to_additive] lemma nontrivial_iff_exists_ne_one (S : submonoid M) :\n  nontrivial S ↔ ∃ x ∈ S, x ≠ (1:M) :=\nbegin\n  split,\n  { introI h,\n    rcases exists_ne (1 : S) with ⟨⟨h, h_in⟩, h_ne⟩,\n    use [h, h_in],\n    intro hyp,\n    apply  h_ne,\n    simpa [hyp] },\n  { rintros ⟨x, x_in, hx⟩,\n    apply nontrivial_of_ne (⟨x, x_in⟩ : S) 1,\n    intro hyp,\n    apply hx,\n    simpa [has_one.one] using hyp },\nend\n\n/-- A submonoid is either the trivial submonoid or nontrivial. -/\n@[to_additive] lemma bot_or_nontrivial (S : submonoid M) : S = ⊥ ∨ nontrivial S :=\nbegin\n  classical,\n  by_cases h : ∀ x ∈ S, x = (1 : M),\n  { left,\n    exact S.eq_bot_iff_forall.mpr h },\n  { right,\n    push_neg at h,\n    simpa [nontrivial_iff_exists_ne_one] using h },\nend\n\n/-- A submonoid is either the trivial submonoid or contains a nonzero element. -/\n@[to_additive] lemma bot_or_exists_ne_one (S : submonoid M) : S = ⊥ ∨ ∃ x ∈ S, x ≠ (1:M) :=\nbegin\n  convert S.bot_or_nontrivial,\n  rw nontrivial_iff_exists_ne_one\nend\n\nend submonoid\n\nnamespace mul_equiv\n\nvariables {S} {T : submonoid M}\n\n/-- Makes the identity isomorphism from a proof that two submonoids of a multiplicative\n    monoid are equal. -/\n@[to_additive \"Makes the identity additive isomorphism from a proof two\nsubmonoids of an additive monoid are equal.\"]\ndef submonoid_congr (h : S = T) : S ≃* T :=\n{ map_mul' :=  λ _ _, rfl, ..equiv.set_congr $ congr_arg _ h }\n\nend mul_equiv\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/group_theory/submonoid/operations.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.463589545461934}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport order.category.BoundedDistribLattice\n\n/-!\n# The category of boolean algebras\n\nThis defines `BoolAlg`, the category of boolean algebras.\n-/\n\nopen order_dual opposite set\n\nuniverses u\n\nopen category_theory\n\n/-- The category of boolean algebras. -/\ndef BoolAlg := bundled boolean_algebra\n\nnamespace BoolAlg\n\ninstance : has_coe_to_sort BoolAlg Type* := bundled.has_coe_to_sort\ninstance (X : BoolAlg) : boolean_algebra X := X.str\n\n/-- Construct a bundled `BoolAlg` from a `boolean_algebra`. -/\ndef of (α : Type*) [boolean_algebra α] : BoolAlg := bundled.of α\n\n@[simp] lemma coe_of (α : Type*) [boolean_algebra α] : ↥(of α) = α := rfl\n\ninstance : inhabited BoolAlg := ⟨of punit⟩\n\n/-- Turn a `BoolAlg` into a `BoundedDistribLattice` by forgetting its complement operation. -/\ndef to_BoundedDistribLattice (X : BoolAlg) : BoundedDistribLattice := BoundedDistribLattice.of X\n\n@[simp] lemma coe_to_BoundedDistribLattice (X : BoolAlg) : ↥X.to_BoundedDistribLattice = ↥X := rfl\n\ninstance : large_category.{u} BoolAlg := induced_category.category to_BoundedDistribLattice\ninstance : concrete_category BoolAlg := induced_category.concrete_category to_BoundedDistribLattice\n\ninstance has_forget_to_BoundedDistribLattice : has_forget₂ BoolAlg BoundedDistribLattice :=\ninduced_category.has_forget₂ to_BoundedDistribLattice\n\n/-- Constructs an equivalence between boolean algebras from an order isomorphism\nbetween them. -/\n@[simps] def iso.mk {α β : BoolAlg.{u}} (e : α ≃o β) : α ≅ β :=\n{ hom := (e : bounded_lattice_hom α β),\n  inv := (e.symm : bounded_lattice_hom β α),\n  hom_inv_id' := by { ext, exact e.symm_apply_apply _ },\n  inv_hom_id' := by { ext, exact e.apply_symm_apply _ } }\n\n/-- `order_dual` as a functor. -/\n@[simps] def dual : BoolAlg ⥤ BoolAlg :=\n{ obj := λ X, of (order_dual X), map := λ X Y, bounded_lattice_hom.dual }\n\n/-- The equivalence between `BoolAlg` and itself induced by `order_dual` both ways. -/\n@[simps functor inverse] def dual_equiv : BoolAlg ≌ BoolAlg :=\nequivalence.mk dual dual\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n\nend BoolAlg\n\nlemma BoolAlg_dual_comp_forget_to_BoundedDistribLattice :\n  BoolAlg.dual ⋙ forget₂ BoolAlg BoundedDistribLattice =\n    forget₂ BoolAlg BoundedDistribLattice ⋙ BoundedDistribLattice.dual := rfl\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/order/category/BoolAlg.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178686187839, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.46358953216448934}}
{"text": "import lib.tactics\nimport knopp.common\n\nuniverses u\n\nnamespace knopp\n\ndef sequence := ℕ → ℚ\n\ndef bound (xₙ : sequence) (K : ℚ) : Prop := ∀ i, (-K ≤ xₙ i ∧ xₙ i ≤ K)\n\ndef bounded (xₙ : sequence) : Prop := ∃ K, bound xₙ K\n\ndef sequence_6_1 : sequence := λ n, 1 / (n + 1)\ndef sequence_6_2 : sequence := λ n, 2 ^ (n + 1)\ndef sequence_6_3 (a : ℚ) : sequence := λ n, a ^ (n + 1)\ndef sequence_6_4 : sequence := λ n, ↑((n + 1) % 2)\ndef sequence_6_6 : sequence := λ n, ((-1) ^ n) / (n + 1)\ndef sequence_6_7 : sequence := nat.fix $ λ n x, dmatch n with\n  | 0 := 1\n  | 1 := 1\n  | (m + 2) := x ⟨m + 1, _⟩ + x ⟨m, _⟩\nend\n\n\n/-\nWe proceed to give this somewhat inaccurate statement a precise\nformulation.\n\nWe consider a system S of well-distinguished objects, which we\ndenote by a, /?,.... S will be called a number system and its elements\na, j3, . . . will be called numbers if, besides being capable of definition\nexclusively by means of rational numbers (i. c. ultimately by means of\nnatural numbers alone) 9 , these symbols a, jS, . . . satisfy the following four\nconditions :\n\n1. Between any two elements a and /3 of S one and only one of the\nthree relations 10\n\na < 0, a = a >\n\nnecessarily holds (this is expressed briefly by saying that S is an ordered\nsystem) and these relations of order between the elements of S are subject\nto the same fundamental laws 1 as their analogues in the system of rational\nnumbers u .\n\n2. Four distinct methods of combining any two elements of S are\ndefined, called Addition, Subtraction, Multiplication and Division. With\na single exception, to be mentioned immediately (3.), these processes\ncan always be carried out to one definite result, and obey the same Fun-\ndamental Laws 2, I IV, as their analogues in the system of the rational\n\n\n\n9 We shall come across actual examples m 3 and 5; for the moment, we\nn.ay think of decimal fractions, or similar symbols constructed from rational numbers.\nSee also footnote 10, p. 12.\n\n10 Cf. also footnotes 2 and 4.\n\n11 As to what we may call the practical meaning of these relations, nothing\nIs implied; \"<\" may as usual stand for \"less than'*, but it may equally well mean\n\"before\", \"to the left of\", \"higher than\", \"lower than\", \"subsequent to\", in fact\nmay express any relation of order (including \"greater than\"). This meaning merely\nhas to be defined without ambiguity and kept consistent. Similarly, \"equality\"\nneed not imply identity. Thus, for example, within the system of symbols of the\nform p/q, where/), q are integers and q =4= 0, the symbols 3/4, 0/8, I)/ 12 are\ngenerally said to be \"equal\"; that is, for certain purposes (calculating, measuring,\nand so on) we define equality within our system of symbols in such a way that 3/4 -=\n6/8-= -9-12, although 3/4, 0/8, -9-12 are in the first instance different\nelements of that system (see also 14, note 1).\n\n\n\n10 Chapter I. Principles of the theory of real numbers.\n\nnumbers 12 . (The \"zero\" of the system, which must be known in order\nthat the elements can be divided into positive and negative, is to be defined\nas explained in footnote 14 below.)\n\n3. With every rational number we can associate an element of S\n(and all others \"equal' ' to it) in such a manner that, if a and b denote\nrational numbers, a, ft their associates from S:\n\na) the relation 1. holding between a and ft is of the same form as\nthat holding between a and b.\n\nb) the element resulting from a combination of a and ft (i. e. a + ft,\na ft, a ft, or a -f- ft) has for its associated rational number the result\nof the similar combination of a and b (i. e. a + b, a b, a b, or a -^ b\nrespectively).\n\n[This is also expressed, more shortly, by saying that the system S\ncontains a sub-system S' sivnilar and isomorphous to the system\nof rational numbers. Such a sub-system is in fact constituted by those\nelements of S which we have associated with rational numbers 13 .]\n\nIn such a correspondence, an element of S associated with the rational\nnumber zero, and all elements equal to it, may be shortly referred to as\nthe \"zero\" of the system of elements. The exception mentioned in 2.\nthen relates to division by zero 14 .\n\n\n\n12 With reference to these four processes it should be noted, as in the case\nof the symbols < and -, that no practical interpretation is implied. We also\ndraw attention to the fact that subtraction is already completely denned in terms\nof addition, and division in terms of multiplication, so that, properly speaking,\nonly two modes of combining elements need be assumed known.\n\n13 Two ordered systems are similar if it is possible to associate each element\nof the one \\\\ith an element of the other in such a way that the same one of the\nrelations 4, 1 as holds between two elements of the one system also holds between\nthe two associated elements of the other, they are tsomorfihous relatively to the\npossible modes of combining their elements, if the element resulting from a com-\nbination of two elements of the one system is associated with that resulting from\nthe similar combination of the two associated elements of the other system.\n\n14 The third of the stipulations by means of which we here characterise the\nconcept of number is fulfilled, moreover, as a consequence of the first arid second.\nFor our purposes, this fact is not essential; but as it is significant from a systematic\npoint of view, we briefly indicate its proof as follows' By 4, 2, there is an element\nfor which a -f- a. From the fundamental laws 2, 1, it then quite eastl> follow^\ntha one and the same element of S satisfies a -I- - a, for every a. This element\n, with all elements equal to it, is called the neutral element relatively to the process\nof addition, or for brevity the \"zero\" in S. If a is different from this \"zero\", there\nis, further, an element for which a e a; and it again appears thit this element\nis the same as that satisfying n - a for any other a in S. This e, with all elements\nequal to it, is called the neutral element relatively to the process of multiplication,\nor, briefly, the \"unit\" in S. The elements of S produced bv repeated addition or\nsubtraction of this \"unit\", and any others equal to them, are then called \"integers\"\nof S. All further elements of S (and all equal to them) which result fiom these\nby the process of division then form the sub-system S' of S in question; that it\nis similar and i amorphous to the system of all rational numbers is in fact easily\ndeduced from 4, i and 4, 2. Thus, as asserted, our concept of number is already\ndetermined by the requirements of 4, 1, 2 and 4.\n\n\n\n1. The system ot rational numbers and its gaps. 11\n\n4. For any two elements a and /3 of S both standing in the relation\n\">\" to the \"zero\" of the system, there exists a natural number n for\nwhich n j8 > a. Here n )3 denotes the sum ]8 -f- jf? + . . . -|- ]8 containing\nthe element ]8 w times. (Postulate of Eudoxus; cf. 2, VI.)\n\nTo this abstract characterisation of the concept of number we\nwill append the following remark l5 : If the system S contains no other\nelements than those corresponding to rational numbers as specified\nin 3, then our system does not differ in any essential feature from the\nsystem of rational numbers, but only in the (purely external) designation\nof the elements by symbols, or in the (purely practical) interpretation\nwhich we give to these symbols; differences almost as irrelevant,\nat bottom, as those which occur when we write figures at one time in\nArabic characters, at another, in Roman or Chinese, or take them to\ndenote now temperature, now velocity or electric charge. Disregarding\nexternal characteristics of notation and practical interpretation, we\nshould thus be perfectly justified in considering the system S as identical\nwith the system of rational numbers and in this sense we may put a = a,\n\nb --.&....\n\nIf, however, the system S contains other elements besides the above\nmentioned, then we shall say that S includes the system of rational\nnumbers, and is an extension of it. Whether a system of this more com-\nprehensive kind exists at all, remains for the moment an open question;\n\n\n\n15 We have defined the concept of number by a set of properties characterising\nit. A critical construction of the foundations of arithmetic, which is quite out\nof the question within the limits of this volume, would have to comprise a strict\ninvestigation as to the extent to which these properties are independent of one\nanother, i. e. whether any one of them can or cannot be deduced from the rest as\na provable fact. Further, t would have to be shuwn that none of these fundamental\nstipulations is in contradiction with any other and other matters too would\nrequire consideration. These investigations are tedious and have not yet reached a\nfinal conclusion.\n\nIn the treatment by E. Landau mentioned on p. 2, footnote 7, it is proved with\nabsolute rigour that the fundamental laws of arithmetic which we have set up\ncan all be deduced from the following 5 axioms relating to the natural numbers:\n\nAxiom 1 : 1 is a natural number.\n\nAxiom 2: For every natural number n there is just one other number\nthat is called the successor of n. (Let it be denoted by n'.)\n\nAxiom 3: We have always n' 1.\n\nAxiom 4: From m' ~~ n' t it follows that m n.\n\nAxiom 5: The induction law V is valid (in its first form).\n\nThese 5 axioms, first formulated as here by G. Peano, but in substance set up\nby R. Dedektnd, assume that the natural numbers as a whole are regarded as given,\nthat a relation of equality (and hence also inequality) is defined between them,\nand that this equality satisfies the relations 1, 1, 2, 3 (which belong to pure\nlogic).\n\n\n\n12 Chapter I. Principles of the theory of real numbers.\n\nbut an example will come before our notice presently in the system of\nreal numbers 16 .\n\nHaving thus agreed as to the amount of preliminary assumption\nwe require, we may now drop all argument on the subject, and again\nraise the question: What do we mean by saying that we know the number\nV2 or TT?\n\nIt must in the first instance be termed altogether paradoxical that\na number having its square equal to 2 does not exist in the system so\nfar constructed 17 , or, in geometrical language, that the point A of\nthe number-axis, whose distance from O equals the diagonal of the\nsquare of side O U, coincides with none of the \"rational points\". For\nthe rational numbers are dense, i. e. between any two of them (which\n\nare distinct) we can point out as many more as we please (since, if a ^ b y\n\nfo a\n\nthe n rational numbers given by a + v , for v = 1, 2, . . . , n, evi-\n\nn -|- 1\n\ndently all lie between a and b and are distinct from these and from one\nanother); but they are not, as we might say, dense enough to symbolise\nall conceivable points. Rather, as the aggregate of all integers proved\ntoo scanty to meet the requirements of the four processes of arithmetic,\n\n\n\n16 The mode of defining the number-concept given in 4 is of course not\nthe only possible one. Frequently the designation of number is still ascribed to\nobjects which fail to satisfy some one or other of the requirements there laid down.\nThus for instance we may relinquish the condition that the objects under con-\nsideration should be constructively developed from rational numbers, regarding\nany entities (for instance points, or distances, or such like) as numbers, provided\nonly they satisfy the conditions 4, 1 4, or, in short, are similar and isomorphous\nto the system we have just set up. This conception of the notion of number,\nin accordance with which all isomoiphous systems must be regarded as in the ab-\nstract sense identical, is perfectly justified from a mathematical point of view, but\nobjections necessarily arise in connection with the theory of knowledge. We\nshall encounter another modification of the number -concept when we come to\ndeal with complex numbers.\n\n17 Proof'. There is certainly no natural number of square equal to 2, as\nI 2 - 1 and all other integers have their squares ^ 4. Thus V2 could only be a\n\n(positive) fraction , where q may be taken ^ 2 and prime to p (i. e. the fraction\n\nis in its lowest terms). But if - is in its lowest terms, so is ( - J , which there-\n\nQ W/ Q ' q\n\nfore cannot reduce to the whole number 2. In a slightly different form: For any\ntwo natural numbers p and q without common factor, we have necessarily /> 2 4- 2 q~.\nFor since two integers without common factors cannot both be even, either p is\nodd, or else p is even and q odd. In the first case /> 2 is again odd, hence cannot\nequal an even integer 2 q 2 . In the second case p 2 = (2 p'Y is divisible by 4, but 2 q z\nis not, since it is double an odd number. So p' 2 =1= 2 r/ 2 again. This Pythagoras is\nsaid to have already known (cf. M. Cantor, Gesch. d. Mathem., Vol. 1, 2 lj ed., pp.\n142 and 169. 1894).\n\n\n\n1. The system of rational numbers and its gaps. 13\n\nso also the aggregate of all rational numbers contains too many gaps 18\nto satisfy the more exacting demands of root extraction. One feels,\nnevertheless, that a perfectly definite numerical value belongs to the point\nA and therefore to the symbol V2. What are the tangible facts which\nunderlie this feeling?\n\nObviously, in the first instance, this: We do, it is true, know\nperfectly well that the values 1-4 or 1*41 or 1*414 etc. for V2 are in-\naccurate, in fact that these (rational) numbers have squares < 2, i. e.\nare too small. But we also know that the values 1-5 or 1-42 or\n1*415 etc. are in the same sense too large; that the value which we\nare attempting to reach would have therefore to lie between the corres-\nponding too large and too small values. We thus reach the definite\nconviction that the value of N/2 is within our grasp, although the given\nvalues are all incorrect. The root of this conviction can only lie in\nthe fact that we have at our command a process, by which the above\nvalues may be continued as far as we please; we can, that is, form\npairs of decimal fractions, with 1, 2, 3, ... places of decimals, one frac-\ntion of each pair being too large, and the other too small, and\nthe two differing only by one unit in the last decimal place, i. e. by (y 1 ^) 71 ,\nif n is the number of decimal places. As this difference may be made\nas small as ive <please, by sufficiently increasing the number n of given\ndecimal places, we are taught through the above process to enclose\nthe value which we are in search of between two numbers as near\nas we please to one another. By a metaphor, somewhat bold at the\npresent stage, we say that through this process V2 itself is \"given\",\nin virtue of it, V2 is \"known\", by it, V2 may be \"calculated\", and\nso on.\n\nWe have precisely the same situation with regard to any other value\nwhich cannot actually be denoted by a rational number, as for instance\nTT, log 2, sin 10 etc. If we say, these numbers are known, nothing more\nis implied than that we know some process (in most cases an extremely\nlaborious one) by which, as detailed in the case of V2, the desired value\nmay be imprisoned, hemmed in, within a narrower and narrower space\nbetween rational numbers, and this space ultimately narrowed down\nas much as we please.\n\nFor the purpose of a somewhat more general and more accurate\n\n\n\n18 This is the paradox, scarcely capable of any direct illustration, that a set\nof points, dense in the sense just explained, mav already be marked on the number\naxis, and yet not comprise all the points of the straight line. The situation may\nbe described thus: Integers form a first rough partition into compartments; rational\nnumbers fill these compartments as with a fine sand, which on minute inspection\ninevitably still discloses gaps. To fill these will be our next problem.\n\n\n\n14 Chapter I. Principles of the theory of real numbers.\n\nstatement of these matters, we insert a discussion of sequences of rational\nnumbers, provisional in character, but nevertheless of fundamental im-\nportance for all that comes after.\n\n2. Sequences of rational numbers 1 .\n\nIn the process indicated above for calculating V2, successive well-\ndefined rational numbers were constructed; their expression in decimal\nform was material in the description; from this form we now propose\nto free it, and start with the following\n\n5. Definition. If, by means of any suitable process of construction, we\n\ncan form successively a first, a second, a third, . . . (rational) number and\nif to every positive integer n one and only one well-defined (rational) number\nx n thus corresponds, then the numbers\n\nX l> X 2> X '3> > X m\n\n(in this order, corresponding to the natural order of the integers 1 , 2, 3, ...\nn, . . .) are said to form a sequence. We denote it for brevity by (x n )\nor (*!, * 2 , . . .).\n\nO Examples.\n\n\n\ni u i\n\n* n ~~ ] '* C * sec l uence > or ] > 2' 3'\n\n\n\n2. x n - 2\"; i. e. the sequence 2, 4, 8, 16, ...\n\n3. x n a n ; i. e. the sequence a, a 2 , a 3 , . . . , where a is a given number.\n- 4. x n ~ H 1 - (- 1 ) 71 }; 1- e. the sequence 1, 0, 1, 0, 1, 0, ...\n\n6. x n = the decimal fraction for V2, terminated at the w th digit.\n/ iyi i 111\n\n6. x n - L_^.__ ; i. e . the sequence 1, - i, + * - ' . . .\n\nn & j *\n\n7. Let x 1 = 1, x 2 = 1, # 3 = x l + # 2 ~ ^ and, generally, for n > 3, let\nx n ~ x n-i + x n-z- We thus obtain the sequence 1, 1, 2, 3, 5, 8, 13, 21, . . . , ubually\ncalled Fibonacci's sequence.\n\n8. l,2,},-8,-J,S,J,-3,-J,...\n\no 3 4 5 + I\n\nA 2,3,3,..., - n ....\n\n10 1 2 3 4 - 1\n\n10 - U '2'3'4' n\"\"\"\n\n11. x n the w th prime number 2 ; i. e. the sequence 2, 3, 5, 7, 11, 13, ... \\\n\n12. The sequence 1, |, ^, g, ^ m wh.ch * = (l + J + . . . + i)\n\n\n\n1 In this section all literal symbols will continue to stand for rational numbers\nonly.\n\n2 Euclid proved that there is an infinity of primes. If p lt p 2 , . . . , p k are any\nprime numbers, then the integer m -= (/>,/> 2 . . . p k ) + 1 is either a prime different\nfrom pi, pi, . . . , p k , or else a product of such primes. Hence no finite set of prime\nnumbers can include all primes.\n\n\n\n2. Sequences of rational numbers. 15\n\nRemarks.\n\n1. The law of formation may be quite arbitrary; it need not, in particular,\nbe embodied in any explicit formula enabling us to obtain x n , for a given n t by\ndirect calculation. In examples 6, 5, 7 and 11, clearly no such formula can be im-\nmediately written down. If the terms of the sequence are individually given, neither\nthe law of formation (cf. 6, 5 and 12) nor any other kind of regularity (cf. 6, ll)\namong the successive numbers is necessarily apparent.\n\n2. It is sometimes advantageous to start the sequence with a \"0 th \" term x ,\nor even with a ( l) th or ( 2) th term, x__ lt #_ 2 . Occasionally, it pays better to start\nindexing with 2 or 3. The only essential is that there should be an integer m ^\nsuch that x n is defined for every n ^ m. The term x m is then called the initial term\nof the sequence. We will however, even then, continue to designate as the n ih term\nlhat which bears the index n. In 6, 2, 3 and 4, for instance, we can without further\ndifficulties take a th term or even ( l) t}l or ( 2) <h to head the sequence. The \"first\nterm\" of a sequence is then not necessarily the term with which the sequence begins.\nThe notation will be preferably (x 0> *i> ) or (#-i #o> ) etc., as the case may be,\nunless it is either quite clear or irrelevant where our enumeration begins, and the\nabbreviated notation (x n ) can be adopted.\n\n3. A sequence is frequently characterised as infinite. The epithet is then\nmerely intended to emphasize the fact that every term is succeeded by other terms.\nIt is also said that there is an infinite number of terms. More generally, there is\nsaid to be a finite number or an infinite number of things under consideration accord-\ning as the number of these things can be indicated by a definite integral number\nor not. And we may remark here that the word infinite, when otherwise used in\nthe sequel, will have a symbolic significance only, intended as a concise expression\nof some perfectly definite (and usually quite simple) circumstance.\n\n4. If all the terms of a sequence have one and the same value c, the sequence\nis said to be identically equal to c, and in symbols (x n ) ~ c. More generally, we shall\nwrite (x n ) == (x n ') if the two sequences (x n ) and (x n ') agree term for term, i. e. for\nevery index in question x n ~ x n '.\n\n5. It is often helpful and convenient to represent a sequence graphically\nby marking off its terms on the number-axis, or to think of them as so marked.\nWe thus obtain a sequence of point*. But in doing this it should be borne in mind\nthat, in a sequence, one and the same number may occur repeatedly, even \"in-\nfinitely often\" (cf. 6, 4); the corresponding point has then to be counted (i. e. con-\nsidered as a term of the sequence of points) repeatedly, or infinitely often, as the\ncase may be.\n\n0. A graphical representation of a different kind is obtained by marking,\nwith respect to a pair of rectangular coordinate axes, the points whose coordinates\nare (w, x n ) for w = 1, 2, 3, ... and joining consecutive points by straight segments.\nThe broken line so constructed gives a picture (diagram, or graph) of the sequence.\n\nTo consider from the most diverse points of view the sequences hereby\nintroduced, and the real sequences that will shortly be defined, will be the\nmain object of the following chapters. We shall be interested more par-\nticularly in properties which hold, or are stipulated to hold, for all the\nterms of the sequence, or at least for all terms beyond (or following) some\ndefinite term 3 . With reference to this last restriction, it may sometimes\n\n\n\n8 E. g. all the terms of the sequence 6, 9 are > 1. Or, all the terms of the\nsequence 6, 2 after the 6 th are > 100 (or more shortly: for n > 6, x n > 100).\n\n\n\n16 Chapter I. Principles of the theory of real numbers.\n\nbe said that particular considerations in hand are valid \"a finite number\nof terms being disregarded\", or only concern the ultimate behaviour of\nthe sequence. Our first examples of considerations of the kind referred\nto are afforded by the following definitions:\n\nDefinitions. I. A sequence is said to be bounded*, if there is a\npositive number K such that each term x n of the sequence satisfies the\ninequality\n\nx n ^ K or\n\n\n\nThe number K is then called a bound of the sequence.\n\n\n\nRemarks and Examples.\n\n1. In definition 8, it is a matter of practical indifference whether we write\n\"\" or \"<K\". For if | x n \\ ^ K holds always (i. e. for every n in question),\n\nthen we can also find a constant K' such that \\ x n \\ < K' holds always; indeed,\nclearly any K.' > K will serve the purpose. Conversely, if | x n \\ < K. always, then\na fortiori \\ x n \\ ^ K. When the exact magnitude of the bound comes in of course\nthe distinction may be essential.\n\n2. If K is a bound of (x n ) t then so is any larger number K'.\n\n3. The sequences 6, 1, 4, 5, 6, 9, 10 are evidently bounded; so is 6, 3, pro-\nvided | a | Si 1. The sequences 6, 2, 7, 8, 11 are certainly not so. Whether 6, 3\nfor every \\a\\ >1, or 6, 12, is bounded or not, i> not immediately obvious.\n\n4. If all we know is the existence of a constant K lt such that x n < K lt for\nevery n t then the sequence is said to be bounded on the right (or above) and K l is\ncalled a bound above (or a right hand bound) of the sequence.\n\nIf there is a constant K 2 such that x n > K 2 always, then (x n ) is said to be\nbounded on the left (or below) and K 2 is called a bound below (or a left hand bound)\nof the sequence.\n\nHere K and K 2 need not be positive.\n\n5. Supposing a given sequence is bounded on the right, it may still happen\nthat among its numbers none is the greatest. For instance, 6, 10 is bounded on\nthe right, yet every term of this sequence is exceeded by all that follow it, and none\ncan be the greatest 6 . Similarly, a sequence bounded on the left need contain no\nleast term; cf. 6, 1 and 0. (With this fact, which will appear at first sight para-\ndoxical, the beginner should make himself thoroughly familiar.)\n\nAmong a finite number of values there is of course always both a greatest and\na least, i. e. a value not exceeded by any of the others, and one which none of the\nothers falls below. (There may, however, be several equal to this greatest or least\nvalue.)\n\n(5. The property of boundedness of a sequence x n (though not the actual value\nof one of the bounds) is a property of the tail-end of the sequence ; it is unaffected\nby any alteration to an isolated term of the sequence. (Proof?)\n\n\n\n4 This nomenclature appears to have been introduced by C. Jordan, Cours\nd'analyse, Vol. 1, p. 22. Paris 1893.\n\n6 The beginner should guard against modes of expression such as these,\nwhich may often be heard: \"for n infinitely large, x n 1\"; \"1 is the greatest\nnumber of the sequence\". Anything of this sort is sheer nonsense (cf. on this point\n7, 3). For the terms of the sequence are 0, ,],},... and none of these is -- 1, on\nthe contrary all of them are < 1. And there is no such thing as an \"infinitely large n\".\n\n\n\n2. Sequences of rational numbers. 17\n\nII. A sequence is said to be monotone ascending or increasing 9.\n\nif, for every value of n,\n\nX n ^ X n+ il\n\nit is said to be monotone descending or decreasing if, for every n,\n\nx n S X n +l*\n\nBoth kinds will also be referred to as monotone sequences.\n\nRemarks and Examples.\n\n1. A sequence need not of course be either monotone increasing, or mono-\ntone decreasing; cf. 6, 4, 6, 8. Monotone sequences are, however, extremely com-\nmon, and usually easier to deal with than those which are not monotone. That\nis why it is convenient to give them a distinguishing name.\n\n2. Instead of \"ascending\" we should more strictly say \"non-descending\",\nand instead of \"descending\", \"non-ascending\". This, however, is not customary.\nIf in any special instance the sign of equality is excluded, so that x n < x ni l or\nv n > x n} ,, as the case may be, for every n t then the sequence is said to be strictly\nmonotone (increasing or decreasing).\n\n3. The sequences 6, 2, 5, 7, 10, 11, 12 and 6, 1, 9 are monotone; the first-\nnamed ascending, the others descending. 6, 3 is monotone descending, if ^ a ^ 1,\nbut monotone ascending if a \" . 1 ; for a < 0, it is not monotone.\n\n4. The designation of \"monotone\" is due to C. Neumann (Ober die nach\nKteis-, Kugel- und Zylmderfunktionen fortschreitenden Entwickelungen, pp. 2(5,\n27. Leipzig 1881).\n\nWe now come to a definition to which the reader should pay\nthe greatest attention, sparing no effort to make himself master of its\nmeaning and all that it implies.\n\nIII. A sequence will be called a null sequence if it possesses the fol- 10\nlowing property: given any arbitrary positive (rational) number e, the in-\nequality\n\n| x n | < c\n\nis satisfied by all the terms, with at most a finite number 6 of exceptions. In\nother words : an arbitrary positive number e being chosen, it is always possible\nto designate a term x m of the sequence, beyond which the terms are less than\ne in absolute value. Or a number n Q can always be found, such that\n\n|*|< for\n\n\n\nRemarks and Examples.\n\n1. If, in a given sequence, these conditions are fulfilled for a particular e,\nthey will certainly be fulfilled for every greater e (cf. 8, 1), but not necessarily for\nany smaller e. (In 6, 10, for instance, the conditions are fulfilled for e = 1 and there-\nfore for every larger e, if we put n =0; for e - } it is not possible to satisfy them.)\nIn the case of a null sequence, the conditions have to be fulfilled for every positive\n\n8 Cf. 7, 3.\n\n\n\n18 Chapter I. Principles of the theory of real numbers.\n\n, and in particular, therefore, for every very small e > 0. On this account, it is\nusual to formulate the definition somewhat more emphatically as follows: (x n )\nis a null sequence if, to every > 0, however small, there corresponds a number\nn such that\n\n| x n | < c for every n > n .\n\n\n\nI x n | < c, provided n >\nwhatever be the value of e. It is thus sufficient to put n a\n\n\n\nHere w () need not be an integer.\n\n2. The sequence 6, 1 is clearly a null sequence; for\n\n-,\n\n.\n\n3. The place in a given sequence beyond which the terms remain numeri-\ncally < e, will naturally depend in general on the magnitude of e; speaking broadly,\nit will lie further and further to the right (i. e. n n will be larger and larger), the\nsmaller the given c is (cf. 2). This dependence of the number n on e is often\nemphasised by saying explicitly: \"To each given corresponds a number n Q w (t)\nsuch that ...\"\n\n4. The positive number below which | x n \\ is to he from some stage onwards\nneed not always be denoted by c. Any positive number, however designated, may\nserve. In the sequel, where e, a, K t . . . , denoting any given positive numbers, we\n\nmay often use instead ^, ^, ^, e 2 , a e, t a , etc.\n\n5. The sign of x n plays no part here, since | x n \\ = | x n \\. Accordingly\n6, is also a null sequence.\n\n6. In a null sequence, no term need be equal to zero. But all terms, whose\nindex is very large, must be very small. For if I choose e = 10~~, say, then for cver\\\nn > a certain n 0t ( x n \\ must be < 10~' 5 . Similarly for e - - 10~ 10 and for any other e.\n\n7. The sequence (a n ) specified in 6, 3 is also a null sequence provided \\ a \\ < 1.\nProof. If a 0, the assertion is trivial, since then, for every > 0, | x n \\ <\n\nfor every n. If < | a \\ < 1, then (by 3, 1,4). ---. > 1. If therefore we put\n\nI * I\n\n* = 1 4- p t then p > 0.\nI a \\\n\nBut in that case, for every n ^ 2, we have\n\n(a) <l + #) n >! + #\n\nFor when n = 2, we have (1 4- />) 2 ^ 1 + 2/> -f p z > 1 -f 2p; the stated relation\ntherefore holds in that case. If, for n k ^ 2,\n\n(!+/>)*> 1-1- kp,\nthen by 2, III, 6\n\n\n\ntherefore our relation, assumed true for n = k t is true for w = & + 1. By 2, V\nit therefore holds 7 for every n ^ 2.\n\n\n\n7 The proof shows moreover that (a) is valid for n ^ 2 provided only 1 4- P\n> 0, i. e. p > 1, but =t=0. For p -- and for n = 1, (a) becomes an equality.\nFor /> > 0, the validity of (a) follows immediately from the expansion of the left-\nhand side by the binomial theorem. The relation (a) is called Bernoulli's Inequality\n(James Bernoulli, Propositiones arithmeticae de seriebus, 1689, Prop. 4).\n\n\n\n2. Sequences of rational numbers. 19\n\nAccordingly, we now have\n\n\n\nso that, however small c > may be, we have\n\nI x n I ^ I aU I < for every n >\n\nP\n\n\n\n8. In particular, besides the sequence f ) mentioned in 2., ( -), (-- J,\n//4\\\"\\ . W \\ 2n / \\ 3fi /\n\n( (?) )'\n\n\n\ni ui\n\n9. A similar remark to that of 8, 1 may be appended to Definition 10: no\nessential modification is produced by reading \"5* e\" for \"< e\" there. In fact,\nif, for every n > w () , | x n \\ < e, then a fortiori \\ x n \\ 5^ c; conversely, if, given any\ne, ?2 can be so determined that | x n \\ '^ e for every n > w 3 , then choosing any posi-\ntive number e t < c there is certainly an n 1 such that | x n \\ fg c l9 for every n > n^\nand consequently\n\n| x n | < for every n > n t ;\n\nthe conditions in their original form are thus also fulfilled. Precisely analogous\nconsiderations show that in Definition 10 \"> H O \" and \"^ w \" are practically inter-\nchangeable alternatives.\n\nIn any individual case, however, the distinction must of course be taken into\naccount.\n\n10. Although in a sequence every term stands entirely by itself, with a definite\nfixed value, and is not necessarily in any particular relation with the preceding\nor following terms, yet it is quite customary to ascribe \"to the terms x n \", or \"to\nthe general term' 1 any peculiarities in the sequence which may be observed on\nrunning through it. We might say, for instance, in 6, 1 the terms diminish; in\n6, 2 the terms increase; in 6, 4 or 6, 6 the terms oscillate; in 6, 11 the general\nterm cannot be expressed by a formula, and so on. In this sense, the character-\nistic behaviour of a null sequence may be described by saying that the terms become\narbitrarily small, or infinitely small 8 ; by which neither more nor less is meant than\nis contained in Definition 9 10, viz. that for every > however small the terms\nare ultimately (i. e. for all indices n > a suitable n ; or from and after, or beyond,\na certain n (t ) numericallv less than e.\n\n11. A null sequence is ipso facto bounded. For if we choose e I, then there\nmust be an integer n, such that, for every n > n i9 \\ x n \\ < 1. Among the finite\nnumber of values | .v t |, | x 2 1, . . . , ! .v nl |, however, one (cf. 8, 5) is greatest, M\nsay. Then for K M -f 1, obviously | .v w | is akvays < K.\n\n12. To prove that a given sequence is a null sequence, it is indispensable\nto show that for a prescribed e > 0, the corresponding w y can actually be proved\nto exist (for instance, as in the examples that follow, by actually designating such\na number). Conversely, if a sequence (x n ) is assumed to be a null sequence, it is\nthereby assumed that, for every t, the corresponding n may really be regarded as\nexistent. On the other hand, the student should make sure that he understands\nclearly what is meant by a sequence not being a null sequence. The meaning is\nthis : it is not true that, for every positive number *, beyond a certain point | x n \\\n\n\n\n6 This mode of expression is due to A. L. Caitchy (Analyse algebrique, pp. 4\nand 2G).\n\n9 There need of course be no question here of the sequence being monotone.\nAlso, in any case, some | x n | 's of index 5* w may already be < c.\n\n\n\n20 Chapter I. Principles of the theory of real numbers.\n\nis always < e; there exists a special positive number e,,, such that | x n \\ is not, beyond\ntiny // , always < c () ; after every // there is a larger index n (and therefore an in-\nfinite number of such indices) for which | v n | ]> c .\n\n1 3. Finally we may indicate a means of interpreting geometrically the special\ncharacter of a null sequence.\n\nUsing the graphical representation 7, 5, the sequence is a nuii sequence if\nits terms ultimately (for n > n n ) all belong to the interval 10 e . . . -f- . Let\nus call such an interval for brevity an e-neighbourhood of the origin; then we may\nstate (x n ) is a null sequence if every c-neighbourhood of the origin (however small)\ncontains all but a finite number, at most, of the terms of the sequence.\n\nSimilarly, using the graphical representation 7, 6, we can state: (x n ) is a\nnull sequence if every *-stnp (however narrow) about the a\\ts of absci^ae contains\nthe entire graph, with the exception, at most, of a finite initial portion, the e-strip\nbeing limited by parallels to the axis of abscissae through the two points (0, e).\n\n14. The concept of a null sequence, the \"arbitrarily small given positive\nnumber c\", to which we shall from now on have continually and indispensably to\nappeal, and which may thus be said to form a main support for the whole super-\nstructure of analysis, appears to have been first used in 1055 by J. Walks (v. Opera\nI., p. 3S2/3). Substantially, however, it is already to be found in Euclid, Elements V.\n\nWe are already in a better position to comprehend what is involved\nin the idea, discussed above, of a meaning for V2 or TT or log 5. In\nforming on the one hand (we keep to the instance of V2) the numbers\n\n* 1 =l-4; *o=l-41; * a = 1-414; * 4 == 1-4142; ...\non the other, the numbers\n\nyi = I'O; y* - 1-42; ^ - 1415; y, =-- 1-4143; . . .\n\nwe are obviously constructing two sequences of (rational) numbers (x n )\nand (y n ) according to a perfectly definite (though possibly very laborious)\nmethod of procedure. These two sequences are both monotone, (x n )\nincreasing, (y n ) decreasing. Furthermore x n is <y n for every //, but the\ndifferences, i. e. the numbers\n\ny n x n =- d n\n\nform, by 10, 8, a null sequence, since d n = n . These are clearly the\n\nfacts which convince us that we \"know\" V2, and can \"calculate\" it ?\nand so on, although as we said before no one has yet had the\nvalue V2 completely within his view, so to speak. If we refer\nagain to the more suggestive representation on the number-axis, then,\nobviously (cf. fig. 1, p. 25): the points x l and y determine an interval\n\n\n\n10 The word interval denotes a portion of the number-axis between a definite\npair of its points. According as we reckon these points themselves as belonging\nto the interval or not, this is termed closed or open. Unless otherwise stated, the\ninterval will always in the sequel be regarded as closed. (For 10, 13 this is immaterial,\nby 10, 9.) Supposing a to be the left end point, b the right end point, of an interval,\nwe call this for brevity the interval a ... b.\n\n\n\n2. Sequences of rational numbers. 21\n\n! of length d l ; the points x 2 and jy 2 similarly, an interval / 2 of length\n. Since\n\n\n\nthe second interval lies wholly within the first. Similarly, the points X 3\nand V 3 determine an interval of length d 3 , completely within / 2 , and\ngenerally, the points x n and y n determine an interval f n completely\ninside J n - V The lengths of these intervals form a null sequence; the\nintervals themselves shrink up, one surmises, about a definite\nnumber, contract to a quite definite point.\n\nIt only remains to examine how near this surmise is to truth. With\nthis purpose in view, we state, more generally, the following:\n\nDefinition. To express the fact that a monotone ascending sequence 11.\n(x n ) and a monotone descending sequence (y n ) are given, whose terms for\nevery n satisfy the condition\n\nx n ^y n\n\nand for which the differences\n\ndn=y n - Xn\n\nform a null sequence, we say for brevity that we are given a nest of\nintervals (Intervallschachtelung)*. TJie n th interval stretches\nfrom x n to y n and has length d n . The nest itself will be denoted by ( /) or\n\nby (# | y n )-\n\nThe conjecture which we made above now finds its first confirma-\ntion in the following:\n\nTheorem f . There is at most one (rational) point s belonging to all 12.\nthe intervals of a given nest, that is to say satisfying, for every n t the in-\nequality\n\n*n^s^ y n >\n\nProof: If there were, besides $, another number s f differing from\nit, and also satisfying the inequality\n\n\n\nfor every , then, for every , besides\n\nx n <Ls< y n ,\n\n\n\n* A set or series of similar objects is said to form a nest or to be nested (inein-\nander geschachtelt) when each smaller one is enclosed or fits into that which is next\nin size to it. The word nest is here used with the additional (ideal) characteristic\nimplied, that the sizes diminish to zero. When this is not implied, we shall use the\nmore explicit phrase that each is contained in the preceding (or we might say that\nthey are nested).\n\nf We note here for future reference that this theorem continues to hold un-\naltered when the numbers which occur are arbitrary real numbers.\n\n2 (051)\n\n\n\n22 Chapter I. Principles of the theory of real numbers.\n\nwe should also have (v. 3, I, 4)\n\nby 3, I, 2 and 3, II, 5, the inequalities\n\nwould therefore hold for every n. Choosing = | s s r |, d n would never\n(a fortiori not for every n beyond a certain // ) be < . This contradicts\nthe hypothesis that (d n ) is a null sequence. The assumption that two\ndistinct points belong to all the intervals is therefore inadmissible 11 .\nQ. E. D.\n\nRemarks and Examples.\n\n1. Let* n = \"-\"--, y = ^J; that is to say,/,, - 5J=J . . . \"-J- 1 , d n = ?\n\nWe can at once verify that we actually have a nest of intervals here, since\n\n2\nx n ^ x n+i \"^ yn+i ^ Vn ^ or ever y n t an< ^ since, for every n > , we have d n < t\n\n\n\nhowever > be chosen.\n\nThe number 5=1 here belongs to all the / 's, since n ~~- - < 1 < - ~\n\n* n n n\n\nfor every n. No number other than 1 can belong therefore to all the intervals.\n\n2. Let f n be defined as follows 12 : / is the interval ... 1; / l the left half\nof A; Jz the right half ofy^ y 3 the left half ofy 2 ; and so on. These intervals are\n\nobviously each contained in the preceding; and since J n has length d n k>n , tmd\n\nthese numbers form a null sequence, we have a nest of intervals. A little considera-\ntion shows that the sequence of the x n 's consists of the numbers\n\n0> 4' 4 10 ~~ 16' 4 + T6 ~*~ G4 \"\" 6T * * '\n\neach taken twice running; and that the sequence of y n 's begins with 1 and con-\ntinues with\n\n1 ~\" 2 = 2 J l ~ 2 ~ 8 ^ 8' ~ 2 \"\" 8 ~~ 32 ^ 32* * ' *\neach taken twice running. Now\n\n1,1,1, , 1 1 A 1\\ ^ 1\n\n\n\n4 16 Ci ' ' ' P = 3 ~ 4*- 3\n\n\n\n~ 4*-)\n\n\n\n11 From a graphical point of view, what the proof indicates is that if $ and\n$' belong to all the intervals, then each interval has a length at least equal to the\ndistance | s s' | between s and s' (v. 3, II, 6); these lengths cannot, therefore,\nform a null sequence.\n\n12 Here we let the index start from (cf. 7, 2).\n\n13 For any two numbers a and b, and every positive integer k t the formula\n\na fc - b k = (a - b)(a k ~ l + a k ~* b+ ... + a b k ~ 2 + * fc ~ 1 )\nis known to hold. Whence, more particularly, for a =t= 1, the formulae\n\n1 + a + . . . + a k ~* = ! ~ ** and a + a* + . . . + a k = \\ \" a * . a.\nl o 1 a\n\n\n\n3. Irrational numbers. 23\n\nHence, for every n t x n < J < y n \\ thus s J is the single number which belongs\nto all the intervals. Here, therefore, (/ n ) \"defines\" or \" determines* ' the number i,\nor (y n ) shrinks up to the number J.\n\n3. vf we are given a nest of intervals (/ n ), and a number s has been recog-\nnised as belonging to all the / n 's, then by our theorem, 5 is quite uniquely deter-\nmined by ( / n ). We therefore say, more pointedly, that the nest (/ n ) \"defines\" or\n\"encloses\" the number s. We also say that 5 is the innermost point of all the intervals.\n\n4. If s is any given rational number and we put, for n 1 , 2, . . . , x n ~ s\n\n1 n\n\nand y n s + -, then (x n \\ y n ) is evidently a nest of intervals determining the number\n\ns itself. But this is also the case if we put, for every n, x n -^ s and y n s. Mani-\nfestly, we can, in the most various ways, form nests of intervals defining a given\nnumber.\n\nThis theorem, however, only confirms what we may regard as one\nhalf of our previously described impression; namely, that if a number\ns belongs to all the intervals of a nest, then there is none other besides\nwith this property, s is uniquely determined by the nest.\n\nThe other half of our impression, namely, that there must also\nalways be a (rational) number belonging to all the intervals of a nest,\nis erroneous^ and it is precisely this fact which will become our induce-\nment for extending the system of rational numbers.\n\nThis the following example shows. As on p. 20, let x l 14; x.> 1-41 ; . . .;\ny l 1 >; y z = 1-42; . . . Then there is no rational number s> for which x n !L A \"? y n\nfor every n. In fact, if we put\n\nv ' v a v 7 v 2\nx n x n Vn ~ 3>n\n\nthen the intervals / n ' x n ' . . . y n ' also form a nest 11 . But x n f x^ < 2 for all n,\nand y n ' -- y n 2 > 2 for all n (because this was how x n and y n were chosen), i. e.\nx n f < 2 < y n '. On the other hand, if x n ;< s ^-_ y n we should have, by squaring\n(as we may, by 3, 1, 3), x n ' ? s 2 ^ y n ' for all n. By our theorem 12 this would in-\nvolve s 2 = 2, which is however impossible, by the proof given in footnote 17 on\np. 12. Here, therefore, there is certainly no (rational) number belonging to all the\nintervals.\n\nIn the following paragraphs, we will investigate what, in a case such\nas this, should be done.\n\n3. Irrational numbers.\n\nWe must come to terms with the fact that there is no rational\nnumber whose square is 2, that the system of rational numbers is too\ndefective, too incomplete, too full of gaps, to furnish a solution for the\n\n\n\n14 For it follows from x n ^ x n l < y n+ i ^ y n since all the numbers are\npositive, so that squaring (cf. 3, I, 3) is allowed that x n ' ^ *v' n+1 < y' nf i ^ y n ';\nfurther y n ' x n ' -- (y n + x n )(y n .v n ); therefore, since .v r} and y n are certainly\n\n< 2 for every n, y n ' x n ' < --^ n , i. e. < s, provided J )n < ; and this, by 10, 8,\nis certainly the case for every n > a certain w .\n\n\n\n24: Chapter I. Principles of the theory of real numbers.\n\nequation x 2 2. Indeed, this is only one of many equations for whose\nsolution the material of the system of rational numbers proves insufficient.\nAlmost all the numerical values which we are in the habit of denoting\nby \\/n t log n, sin a, tan a and so on, are non-existent in the system of\nrational numbers and can no more be immediately \"obtained\", or \"deter-\nmined\", or be \"stated in figures\", than can V2. The material is too coarse\nfor such finer purposes.\n\nThe considerations brought forward in the preceding paragraphs\npoint to means for providing ourselves with more suitable material.\nWe saw, on the one hand, that, behind the conviction that we do\nknow V2, there lay no more, substantially, than the fact that we possess\na method by which a perfectly definite nest of intervals may be\nobtained ; for its construction, the solution of the equation x 2 2 of\ncourse gave the occasion lr> . We saw, on the other hand, that if a\nnest (/ n ) encloses any number s capable of specification at all (this still\nimplying that it is a rational number) then this number s is quite uniquely\ndefined by the nest ( / n ), - so unambiguously, indeed, that it ia entirely\nindifferent, whether I give (write down, indicate) the number directly,\nor give, instead, the nest (/) with the tacit addition that, by the latter,\nI mean precisely the number s which it uniquely encloses or defines. In\nthis sense, the two data (the two symbols) are equivalent, and may\nto a certain extent be considered equal 16 , so that we may write in-\ndeed:\n\n(/n) = * or (x n | y n ) = s.\n\n15 The kernel of this procedure is in fact as follows: We ascertain that\n\nI 2 < 2, 2 2 > 2, and accordingly put # 1, y ~ 2. We then divide the interval\n\nk\nJ Q =- x . . . y into 10 equal parts, and taking the points of division, 1 + , for\n\nk -= 0, 1, 2, . . . , 9, 10, determine by trial whether their squares are > 2 or < 2.\nWe find that the squares corresponding to k 0, 1, 2, 3, 4 are too small, those\ncorresponding to k = 5 y G, . . . , 10 too large, and accordingly we put Xi =1-4 and\ny t == 1-5. Next, we divide the interval /j. x l . . . y l into 10 equal parts, and go\nthrough a similar test with regard to the new points of division and so on. The\nknown process for extracting the square root of 2 is intended mainly to make the\nsuccessive trials as mechanical as possible. The corresponding treatment of,\nfor instance, the equation 10* = 2 (i. e. determination of the common logarithm\nof 2) involves the following nest of intervals: Since 10 < 2, 10 l > 2, we here pu:\nX Q = 0, y = 1 and divide / = # . . . y into 10 equal parts. For the points of\n\ndivision, lftt we next test whether 10*/ 10 < 2 or > 2, that is to say, whether 10 fc\n\n< 2 10 or > 2 10 . As a result of this trial, we shall have to put x^ ~ 0-3, y^ ^ 0-4.\nThe interval / l x l . . . y l is again divided into 10 equal parts, the same pro-\n\n3 k\n\ncedure instituted for the points of division ^ -}- . and, in consequence, x z put\n\nequal to 30 and y a to 31 and so on. This obvious procedure is of course\nmuch too laborious for practical calculations.\n\n16 The justification for this is provided by Theorems 14 to 19.\n\n\n\n3. Irrational numbers. 25\n\nConsequently, we will not say merely: \"the nest (/ n ) defines the number\ns\" but rather \"(/) is only another symbol for the number $\", or in fine,\n\"(/ n ) is the number s\" exactly as we are used to look upon the decimal\nfraction 0-333 ... as merely another symbol for the number , or as being\nprecisely the number itself.\n\nIt now becomes extremely natural to introduce tentatively an\nanalogous mode of expression with regard to those nests of intervals\nwhich contain no rational number. Thus if x n , y n denote the numbers\nconstructed previously in connection with the equation x 2 = 2, one\nmight seeing that in the system of rational numbers there is not\na single one whose square =2 decide to say that this nest (x n \\ y n )\ndetermines the \"true\" \"value of V2 \" though one incapable of being\nsymbolised by means of rational numbers, that it encloses this\n\n\n\nX\n\n\n\nU -J J\n\nFig. 1.\n\nvalue unambiguously in fine, \"it is a newly created symbol for this\nnumber\", or, for brevity, \"it is the number itself\". And similarly in every\nother case. If (/ n ) (x n \\ y n ) is any nest of intervals and no rational\nnumber s belongs to all its intervals, we might finally resolve to say that\nthis nest encloses a perfectly definite value, though one incapable of\nbeing directly symbolised by means of rational numbers, it deter-\nmines a perfectly definite number, though one unfortunately non-\nexistent in the system of rational numbers, it is a newly created symbol\nfor this number, or briefly: is the number itself; and this number, in\ncontradistinction to the rational numbers, would then have to be called\nan irrational number.\n\nHere certainly the question arises: Can this be done without\nfurther justification ? Is it allowable ? May we, without more ado,\ndesignate these new symbols, the nests (x n \\ y n ), as numbers? The fol-\nlowing considerations are intended to show that to this course there is\nno obstacle whatever.\n\nIn the first instance, a simple graphical illustration of these facts\non the number-axis (see fig. 1) gives every appearance of justification to\nour resolution. If, by any construction, we have marked a point P on\nthe number-axis (e. g. by marking off to the right of O the length\n\n\n\n26 Chapter I. Principles of the theory of real numbers.\n\nof the diagonal of a square of side O U) then we can in any number\nof ways define a nest of intervals enclosing the point P. We may\ndo so in this way, for instance. First of all we imagine all integers\n\n^ marked on the axis. Of these, there will be exactly one, say p,\n\nsuch that our point P lies in the stretch from p inclusive to (/>+!)\nexclusive. Accordingly we put x -= p, y p + 1, and divide the\ninterval J Q = x . . . y Q into 10 equal parts 17 . The points of division\n\nk\nare p + - (with k = 0, 1, 2, . . . , 10), and among them, there will again\n\nk k\n\nbe exactly one, say p + - J , such that P lies between x t p -[- *\n\ninclusive and y^ = p + * -y~ exclusive. The interval J^ x l . . . y^\n\nis again divided into 10 equal parts, and so on. If we imagine this process\ncontinued indefinitely, we obtain a perfectly definite nest (J n ) all of whose\nintervals J n contain the point P. No other point P' besides P can lie in all\nthe intervals J n . For, if that were so, all the intervals would have to con-\ntain the whole stretch PP', which is impossible, as the lengths of the\n\nintervals (j n has length J form a null sequence.\n\nFor every arbitrarily given point P on the number-axis (rational or\nnot) there are thus nests of intervals obviously, indeed, any number\nof such nests which contain that point and no other. And in the\npresent instance, i. e. in the graphical representation on the number-\naxis the converse appears most plausible; if we consider any nest\nof intervals, there seems to be always one point (and by the reasoning\nabove, only this one) belonging to all its intervals, which is thus deter-\nmined by it. We believe, at any rate, that we may infer this directly from\nour conception of the continuity, or gaplessness y of the straight line 18 .\n\nThus in this geometrical representation we should have complete\nreciprocity: every point can be enclosed in a suitable nest of intervals\nand every such nest invariably encloses one and only one point.\n\nThis gives us a high degree of confidence in the adequacy of our\nresolve to consider nests of intervals as numbers, which we now for-\nmulate more precisely as follows:\n\n13. Definition. We will say of every nest of intervals (J n ) or (x n \\ y n ),\nthat it defines or, for brevity, it is, a determinate number. To represent\n\n\n\n17 Instead of 10 we may of course take any other integer ^ 2. For furthei\ndetail, see 5.\n\n18 The proposition, by which the \"continuity of the straight line\" is expressly\npostulated for a proof cannot be here expected, since it is essentially a description\nof the form of our concept of the straight line which is involved is called the\nCantor-Dedekind axiom.\n\n\n\n3. Irrational numbers. 27\n\nit y we use the symbol denoting the nest of intervals itself, and only as an ab-\nbreviation replace this by a small Greek letter, writing in this sense 19 , e. g.\n\n(J n ) or (x n \\y n ) - a.\n\nNow, in spite of all we have said, this cannot but seem a very arbi-\ntrary step, the question has to be repeated most insistently: will it\npass without further justification? These purely ideal objects which we\nhave just defined these nests of intervals (or else that still extremely\nquestionable 'something' which such a nest encloses or determines) can\nwe speak of these as numbers? Are they after all numbers in the same\nsense as the rational numbers, more precisely, in the sense in which\nthe number concept was defined by our conditions 4?\n\nThe answer can only consist in deciding, whether the totality or\naggregate of all conceivable nests of intervals, or of the symbols (/ n ) or\n( x n \\ yn) r <* introduced to denote them, forms a system of objects satis-\nfying these conditions 4 20 ; a system therefore to recapitulate these\nconditions briefly whose elements are derived from the rational numbers,\nand 1. are capable of being ordered; 2. are capable of being combined\nby the four processes (rules), obeying at the same time the fundamental\nlaws 1 and 2, I IV; 3. contain a sub-system similar and isomorphous\nto the system of rational numbers; and 4. satisfy the Postulate of Eud-\noxus.\n\nIf and only if the decision turns out to be favourable, all will be\nwell; our new symbols will then have vindicated their numerical char-\nacter, and we shall have established that they are numbers, whose\ntotality we shall then designate as the system or set of real numbers.\n\nNow the decision in question does not present the slightest diffi-\nculty, and we may accordingly be brief in expounding the details:\n\nNests of intervals or our new symbols (x n \\ y n ) are certainly\nconstructed by means of rational number-symbols alone; we have there-\nfore only to settle the points 4, 1 4. For this, we shall go to work in\nthe following way: Certain of the nests of intervals define a rational\nnumber 21 , something, therefore, for which both meaning and mode of\ncombination have been previously established. We consider two such\nrational- valued nests, say (x n \\ y n ) s and (x n f \\ y n ') = s'. With the two\nrational number-symbols s and s', we can immediately distinguish whether\nthe first s is <, = or > the second s'; and we can combine the two by\nthe four processes of arithmetic. Essentially, what we have to do is to\nendeavour directly to recognise the former fact, and to carry out the latter\nprocesses, on the two nests of intervals themselves by which s and s' were\n\n\n\n19 <7 is an abbreviated notation for the nest of intervals ( / n ) or (x n \\ y n ).\n\n20 The reader should here read these conditions through again.\n81 We will describe such nests for brevity as rational-valued.\n\n\n\n28 Chapter 1. Principles of the theory of real numbers.\n\ngiven, and finally to extend the result to the aggregate of all nests of intervals.\nEach provable proposition (A) relating to rational-valued nests will ac-\ncordingly give rise to a corresponding definition (B). We begin by setting\ndown concisely side by side these pairs of propositions (A) and\ndefinitions (B) 22 .\n\n14. Equality: A. Theorem. If(x n \\y n ) = 5 and (x n f \\y n ') = s' are two\nrational-valued nests of intervals, then s = s' holds if, and only if,\nbesides\n\n*n ^ y n and x n ' <^ y n ' 9\nwe have 23\n\n\n\nfor every n.\n\nOn this theorem we now base the following:\n\nB. Definition. Two arbitrary nests of intervals cr (# n |j> n ) and\na .= (x n f | y n ') are said to be equal if and only if\n\n\n\nor every n.\n\nRemarks and Examples.\n\n1. The numbers x n and \\ n ' on the one hand, y n and y n ' on the other, need\nof course have nothing whatever to do with one another. This is no more sur-\nprising than that rational numbers so entirely different in appearance as , g'A,\nand 375 should be referred to as \"equal\". Equality is indeed something which\n\n\n\n22 The import of proposition and definition should in each case be interpreted\nin relation to the number-axis.\n\n23 Into the very simple proofs of the propositions 14 to 19 we do not propose\nto enter, for the general reasons explained on p. 2. They will not present the\nslightest difficulty to the reader, once he has mastered the contents of Chapter II,\nwhereas at this stage they would appear to him strange; moreover they will serve\nas exercises in that chapter. Merely as a specimen and example for the solution\nof those problems, we will here prove Theorem 14:\n\na) If s = s' t then we have both x n ^ $ ^ y n and x n ' ^ s ^ y n ' y whence at\nonce, x n < y n ' and x n ' ^ y^ for every n.\n\nb) If conversely x n 5$ y n ' for every n, then s ^ s' must hold. For if we had\ns > s', i. e. s s' > 0, then, since (y n x n ) is a null sequence, we could so choose\nthe index p, that\n\ny p - x p < s s/ r X P - s ' > y* - *\n\nAs however s is certainly ^ y p , this would imply x p s' > 0. We could therefore\nchoose a further index r for which\n\ny/ - */ < * - s'.\n\nSince x r ' ^ $', this would imply y r ' < x^ Choosing an integer m exceed-\ning both p and r, we could deduce, in view of the respective ascending and descend-\ning monotony of our sequences of numbers, that a fortiori y m ' < x m , which con-\ntradicts the hypothesis that x n ^ y^ for every n. Thus s ^ $' is ensured.\n\nBy interchanging throughout the above proof the accented and non-accented\nletters, we deduce in the same manner that if x n ' < y n for every n, then s' ^ s\nIf then we have both x n ' ^ y n and x n y n ' holding for every , then s ~ s\nnecessarily follows. Q. E. D.\n\n\n\n3. Irrational numbers. 29\n\nis not fixed a priori, but needs to be established by some form of definition, and\nit i> perfectly compatible \\vith marked dissimilarity in a purely external aspect.\n\n2. The two nests I ^ 3 ) anc * *^ ~ are ct l ua l m accordance with\nour present definition\n\n3. By 14, we may write e. g. (s s -\\- J = s --= (s \\ s), the latter symbol\ndenoting a nest all of whose intervals ha\\e both their left and their right endpomts\n\n\n\ns. In particular, f\n\n\n\n- (0 | 0) = 0.\n\n\n\nw/\n\n4. It still remains to establish but the proof is so simple that vve will not\ngo into it further that (cf. Footnote 23), in consequence of our definition, we\nhave a) a a (Footnote 24), b) a -= a' always implies a' = a, and c) a a 7 , a' a\"\ninvolve a = a\".\n\nInequality: A. Theorem. If (x n \\ y n ) = s and (x n f \\ y n ') s' are 15\ntwo rational-valued nests, then we have s < s', if and only if\n\nx n ^ y n ' for every //, but not x n f 5^ y n for every ;/,\n\n* e - y>n < x m f or <** feast one M.\n\nB. Definition. Given any two nests of intervals a = (x n \\ y n ) and\na (x n r | y n '), then we shall say a < o-', if\n\nx n f y n ' for every ;/, but not x n ' ^ y n f or every n,\ni. e. for at least one m, y m -- x m '.\n\nRemarks and Examples.\n\n1. It is clear that by 14 and 15 the totality of all conceivable nests is ordered.\nFor if a and a' are any two of them, either there is equality, a a 7 , or, for at least\none p, we have y v <* .Vj/, implying a < a 7 , or finally, for at least one r, y r ' < .v |f\nimplying a' < a. The last two cases cannot occur simultaneously, since, for m\ngreater than r and />, we should then have, a fortiori, v ?/ / <. v 7/1 ', which is impossible.\nThus between a ard a' one and only one of the three relations\n\nalways holds, and the totality of these new symbols is thus ordered by 14 and 15.\n\n2. Here again it would have to be established in all detail that the laws of\norder 1 continue to hold good with the adopted definitions of equality and in-\nequality. Taking as model the proof in the footnote to Theorem 14, this presents\nso few essential difficulties that we will not enter into it further: The laic* of order\ndo, effectually^ all remain valid.\n\n3. In consequence of 14 and 15 we now have, therefore, for every n\n\nA n < c y n .\n\nWhat does this mean r It means that each of the rational numbers x n is, in ac-\ncordance with 14 and 15, not greater than the nest a ~ (x n \\ y n ). Or: if we con-\n\n24 Here it may be clearly recognised that this \"law\" is by no means trivial:\nit has indeed to be proved that with the given definition of equality every nest of\nintervals is effectually \"equal\" to itself, that is to say that the conditions of that\ndefinition are fulfilled, when the same nest is taken for both of the nests of intervals\nwhich we are comparing.\n\n\n\n30 Chapter I. Principles of the theory of real numbers.\n\nsider any particular one of the numbers x n> say x p , and denote it for brevity by x,\nthen we may write (see 14, Rem. 3)\n\n(v ;) -) x - x - -\n\n\n\nx + f j or - (x | x)\nand our statement takes the form\n\n(*!*) <.!*,).\n\nWe may prove it as follows. If it were not true, then for at least one r,\n\ny r < x, i. e. y r < x^\nand so a fortiori, if m is greater than r and p y\n\ny m < *m.\n\nwhich certainly cannot be the case. In the same way we see that a < y n . Accord-\ningly, a is to be regarded as lyin^ between x n and y n for each n, in other word*, v con-\ntained within the interval J n .\n\nThe fact that no other number a', besides a, can possess the same property\nis now easily proved. If in fact there were a second nest of intervals a' - (\\ n ' \\ y n ')\nsuch that for every definite index /> we also had x p ^ a' < y p , then the left hand\ninequality means, more precisely (cf 3), that (v^ | v p ) r^ (v n ' | y n ') and so, by 14\nand 15, x p ^ y n ' for every n. Since this must hold in particular for // p, we\ndeduce x 9 ^1 y v ' for every p, which signifies, by 14 and 15, that a ^ a'. In the\nsame manner the right hand inequality is seen to imply that a' jj <* Thus neces-\nsarily a a', which was what we set out to prove.\n\n4. By 15, a is > 0, i. e. \"positive\", if and only if (x n \\ y n ) > (0 | 0), that is\nto say, if for some suitable index p, x v > 0. But in this case, as the .v w f s increase\nwith n, we have a fortiori x n ^ for every n > p. We may therefore* say : a\n(v n | y n ) is positive if, and only if, all the endpomts ,v w , y n are positive from and\nafter a definite index. The exact analogue holds of course for a < 0.\n\n5. If or > 0, and, for every n ^ p, x n > 0, let us form a new nest (x n ' \\ y n ')\n= a' by putting x x\\ . . . *V-i all equal to x p , but every other x n ' and\ny n ' equal to the corresponding x n and y n . By 14, obviously a a'; and we may\nsay: If a is positive, then there are always nests of intervals equal to it, for which\nall the endpoints of intervals are positive. The exact analogue holds for a < 0.\n\nSo far then, in respect of the possibility of ordering them, our nests\nof intervals may be said to vindicate their character as numbers com-\npletely. It is no more difficult to establish a similar conclusion with regard\nto the possibilities of combining them.\n\n16. Addition: A. Theorem 2r> . If (x n \\y n ) and (x n '\\y n f ) are any two nests\nof intervals, then (x n + # n '> yn + y n ') w also one, and if the former are both\nrational-valued and respectively = s and = s\\ then the latter is also rational-\nvalued, and determines the number s + s' '.\n\nB. Definition. If (x n \\ y n ) a and (x n f \\ y n ') ~ &' are any two nests\nof intervals and a\" denotes the nest (x n + x n ', y n + y n ') deduced from them,\nthen we write\n\na\" = a + a'\n\nand a\" ts called the sum of a and a'.\n\n\n\n18 With regard to the proof, cf. footnote 23.\n\n\n\n3. Irrational numbers. 31\n\nSubtraction: A. Theorem. If (x n \\ y n ) is a nest of intervals, then so 17.\nis ( y n | x n ); and if the former is rational-valued s, then the latter\nis also rational-valued, and determines the number s.\n\nB. Definition. If a = (x n \\ y n ) is any nest of intervals and a' de-\nnote the nest of intervals ( y n \\ x n ) t we write\n\na' = -a\n\nand say v is the opposite of cr. By the difference of two nests of inter-\nvals we then mean the sum of the first and of the opposite of the second.\n\nMultiplication: A. Theorem. If(x n \\ y n ) and (x^ \\ y n ') are any two 18.\npositive nests of intervals, replaced, if necessary, (in accordance with\n15, 5) by two nests of intervals equal to them, for which all the endpoints\nof intervals are positive (or at least non-negative), then (x n x n r \\y n y n ')\nis also a nest of intervals; and if the former are rational-valued and respec-\ntively s and = s', then the latter is also rational-valued, and determines the\nnumber s s'.\n\nB. Definition. If (x n \\ y n ) a and (x n r \\ y n f ) a are any two\npositive nests of intervals for which all the endpoints of intervals are positive\nwhich is no restriction, by 15, 5 and a\" denote the nest (x n x n ' \\y n y n ')\nderived from them, then we write\n\na\" = <T- a'\n\nand call o-\" the ^product of a and cr'.\n\nThe slight modifications which have to be made in this definition if\none or both of a and or' are negative or zero, we leave to the reader, and\nhenceforth consider the product of any two nests of intervals as defined.\n\nDivision: A. Theorem. // (x n \\ y n ) is any positive nest of intervals 19.\nfor which all endpoints of intervals are positive, (cf. 15, 5) then so is ( J;\n\nVn x n'\n\nand if the former is rational-valued, and = s, the latter is also rational-\nvalued, and determines the number -.\n\nB. Definition. If (x n \\ y n ) = a is any positive nest of intervals for\n\nwhich all endpoints are positive, and a' denote the nest (-- ), then we\n\n\\y n xj\n\nwrite\n\n\n\nand say a' is the reciprocal of a. By the quotient of a first by a second\npositive nest of intervals we then mean the product of the first by the reciprocal\nof the second.\n\nThe slight modifications necessary in this definition, if a (in the one\ncase) or the second of the two nests of intervals (in the other) is negative,\n\n\n\n32 Chapter I. Principles of the theory of real numbers.\n\nwe may again leave to the reader, and henceforth consider the quotient\nof any two nests of intervals of which the second is different from 0, as\ndefined. If (x n \\ y n ) a = 0, then the above method fails to produce\na \"reciprocal\" nest: division by is here also impossible.\n\nThe result of the preceding considerations is thus as follows: By\ndefinitions 14 to 19, the system of all nests of intervals is ordered in the\nsense of 4, 1, and admits of having its elements combined by the four\nprocesses in the sense of 4, 2. In consequence of the theorems 14 to 19,\nas stated in each case, this system possesses further, in the aggregate of\nall rational-valued nests, a sub-system, similar and isomorphous to the\nsystem of rational numbers, in the sense of 4, 3. It remains to show that\nthe system also fulfils the Postulate of Eudoxus. But if (x n \\ y n ) = a and\n( x n I yn) ~ v are an y two positive nests for which all endpoints of in-\ntervals are positive (cf. 15, 5), let x m and y m f be a definite pair of these\nendpoints; the theorem of Eudoxus ensures the existence of an integer\np, for which p x m > y m ', and the nest p a, or (p x n \\ p y n ), in accordance\nwith 15, is then effectually > a'.\n\nThe next step should be to establish in all detail (cf. 14, 4 and 15,\n2) that the four processes defined in 16 to 19 for nests of intervals obey\nthe fundamental laws 2. This again offers not the slightest difficulty and\nwe will accordingly spare ourselves the trouble of setting it forth 26 . The\nFundamental Laws of Arithmetic, and thereby the entire body of rules valid\nin calculations with rational numbers, effectually retain their validity in the\nnew system.\n\nBy this, our nests of intervals have finally proved themselves in\nevery respect to be numbers in the sense of 4: The system of all\nnests of intervals is a number-system, the nests themselves are numbers 27 .\n\n\n\n26 As regards addition, for instance, it should be shown that:\n\na) Addition can always be carried out. (This follows at once from the defini-\ntion.)\n\nb) The result is unique; i. e. a a', T = T' (in the sense of 14) imply\na -f- r a 1 \\- r' , if the sums are formed in accordance with 16 and the test\nfor equality carried out in accordance with 14. In the corresponding sense, it should\nbe shown further that\n\nc) a + T = T -f- a always.\n\nd) fe + a) + T = g -|- (o- + T) always.\n\ne) a < a' implies a -\\- T < a' 4* T always.\n\nAnd similarly for the other three processes of combination.\n\n27 Whether, as above, we regard nests of intervals as themselves numbers,\nor imagine some hypothetical entity introduced, which belongs to all the intervals\nJ n (cf. 15, 3) and thus appears to be in a special sense the number enclosed by\n\nthe nest of intervals and, consequently, the common element in all equal nests\nthis at bottom is a pure matter of taste and makes no essential difference. The\nequality a -- (x n \\ y n ) we may, at any rate, from now on, (cf. 13, footnote 19) read\nindifferently either as \"a is an abbreviated notation for the nest of intervals (x n \\ y n )\" 9\nor as \"a is the number defined by the nest of intervals (x n \\ y n )\".\n\n\n\n4. Completeness and uniqueness of the system of real numbers. 33\n\nThis system we shall henceforth designate as the system of real numbers.\nIt is an extension of the system of rational numbers, in the sense in\nwhich the expression was used on p. 11, since there are not only rational-\nvalued nests but also others besides.\n\nThis system of real numbers is in one-one correspondence with\nthe whole aggregate of points of the number-axis. For, on the strength\nof the considerations set forth on pp. 24, 25, we can immediately assert\nthat to every nest of intervals a corresponds one and only one point,\nnamely that common to all the intervals / n , which on account of the Cantor-\nDedekind axiom is considered in each case as existing. Also two nests of\nintervals a and cr' have, corresponding to them, one and the same point,\nif and only if they are equal, in the sense of 14. To each number cr (that\nis to say, to all nests of intervals equal to each other) corresponds exactly\none point, and to each point exactly one number. The point corresponding\nin this manner to a particular number is called its image (or representative)\npoint, and we may now assert that the system of real numbers can be uniquely\nand reversibly represented by the points of a straight line.\n\n\n\n4. Completeness and uniqueness of the system of real\n\nnumbers.\n\nTwo last doubts remain to be dispelled 28 : Our starting point in\n3 was the fact that the system of rational numbers, by reason of its\n\"gaps\", could not satisfy all demands which would appear in the course\nof the elementary processes of calculation. Our newly created number-\nsystem the system Z as we will call it for brevity is in this respect\ncertainly more efficient. E. g. it contains 29 a number a for which cr 2 2.\nYet the possibility is not excluded that the new system may still show\ngaps like the old, or that in some other way it may be susceptible of still\nfurther extension.\n\nAccordingly, we raise the following question: Is it conceivable that\na system Z, recognizable as a number-system in the sense of 4, and con-\ntaining all the elements of the system Z, should also contain additional\nelements distinct from these? *\n\n\n\n28 Cf. the closing words of the Introduction (p. 2).\n\n29 For if CT = (x n | y n ) denote the nest of intervals constructed on p. 20\nin connection with the equation A? 3 = 2, then by 18 we have a a (x n 2 \\ y n *). Since,\nhowever, # n 2 < 2 and y n 2 > 2, it follows that a 2 = 2. Q. E. D.\n\n80 I. e. Z would have to represent an extension of Z in the same sense as Z\nitself represents an extension of the system of rational numbers.\n\n\n\n34 Chapter I. Principles of the theory of real numbers.\n\nIt is not difficult to sec that this cannot be so, so that we have in\nfact the following theorem:\n\n20. Theorem of completeness. The system /, of all real numbers is in-\n\ncapable of further extension compatible with the conditions 4.\n\nProof: Let Z be a system which satisfies the conditions 4 and\ncontains all the elements of /. If a denote an arbitrary element of Z,\nthen 4, 4 in which we choose for ft the number 1, contained in Z,\nand also, therefore, in Z shows that there exists an integer p > a,\nand similarly another p' > a. For these 3l we have p' < a < p.\nConsidering successively the (finite number of) integers between p'\nand />, starting with - />', we know that we must come to a last one which\nis still ^ a. If this be called g, then\n\n\n\nBy applying to this interval g . . . g + 1 the method, already re-\npeatedly used, of subdivision into ten parts, a perfectly definite nest of\nintervals (x n \\ y n ) is obtained. And a repetition word for word of the\nproof in 15, 3 shows that the number thus defined can neither be > nor\n< a. Every element of / is therefore equal to a real number, so that Z\ncan contain no elements other than real numbers.\n\nA final objection might be this: We have succeeded in forming the\nsystem Z in a comparatively natural, but after all an arbitrary, manner.\nOther measures, obviously, might be adopted for filling up the gaps in\nthe system of rational numbers. (In the very next section we shall come\nacross other, equally ready means to this end.) It is conceivable that\na different method would lead to other numbers, i. e. to number-systems\ndiffering, in more or less essential particulars, from the one constructed\nby us. The question thus indicated may be given a precise formulation\nas follows:\n\nLet us suppose that we have somehow, starting with the system\nof rational numbers, succeeded in constructing a system < of elements\nwhich, besides still satisfying the conditions 4, as is the case with our\nsystem Z, and therefore deserving the name of a number-system, also\nfulfils a further requirement, usually referred to as the Postulate of\ncompleteness, on account of the theorem proved above. On the\nstrength of 4, 3, ^ contains elements, corresponding to the rational numbers.\nLet (x n | y n ) be any nest and let \\ n and n be the elements of associated\nwith x n , y n in accordance with 4, 3; the stipulation then runs thus:\nshall always contain at least one element # satisfying, for every n y the con-\nditions r n ^ cs ^ *) n .\n\nIn exact form, our problem is now: Can such a system <5 differ in\n\n\n\n[ At this point, the Postulate of Eudoxus gains its axiomatic significance.\n\n\n\n4. Completeness and uniqueness of the system of real numbers. 35\n\nany essential particulars from the system Z of real numbers, or must the\ntwo systems be regarded as substantially identical, in the perfectly definite\nsense that they can be brought into relation as similar and isomorphous\nto one another?\n\nThe theorem stated below, by solving this problem in the sense\nwhich we should anticipate, closes the construction of the system of real\nnumbers.\n\nTheorem of Uniqueness. Every such system & is necessarily similar 21.\nand isomorphous to the system Z of real numbers as constructed by us. Essen-\ntially, only one such system therefore exists.\n\nProof. By 4, 3, contains a sub-system <', which is similar and\nisomorphous to the system of rational numbers contained in Z, and whose\nelements may therefore be called, for short, the rational elements of ^\nIf a (x n \\ y n ) is any real number, 5 rnust, according to our new stipula-\ntion, contain an element a, which for every n satisfies the conditions\nin ?? * ^ Wn if \\ n and \\j n are the elements of S corresponding to the\nrational numbers x n and y n .\n\nAlso, these conditions define g uniquely. For if a second element\n/, simultaneously with *, satisfied the conditions \\ n ^ $ <* \\^ n for every\n, then it would follow, word for word as in the proof of 12, that for\nevery n\n\n\n\ni. e. ^ the non-negative one of the two elements & $' and $' .\nLet r stand for an arbitrary positive rational number, and i for the cor-\nresponding element in > (therefore in 5'); then, on account of the similarity\nand isomorphism of >' with the system of rational numbers, we must\nhave, simultaneously with y p x p < r, the relation \\j p r^ < v holding\nfor a suitable index p. For every such r therefore\n\n\n\nIf therefore tj denotes one particular such i and if r n , n = 1, 2, . . . ,\ndenotes the element (certainly present in >', by 4, 2) which, when repeated\nn times, yields the sum r lf we see, after writing down the above inequality\nfor r = v n and adding it to itself n times, that for every n = 1, 2, . . . ,\n\nn | d $' | ^ t!\n\nmust also hold. Since, however, satisfies the postulate 4, 4, it follows\nthat = *'.\n\nIf we proceed to associate this uniquely defined clement g and\nthe real number cr, it becomes clear that contains a sub-system 5* $\nsimilar and isomorphous to the system /, of all real numbers. That\nsuch a system 5* is n t susceptible of further extension compatible\n\n\n\n36 Chapter I. Principles of the theory of real numbers.\n\nwith the conditions 4, but must be identical with c ij), was the import\nof the previously established theorem of completeness. Thereby, it is\nproved that 5 an d %, arc similar and isomorphous to one another,\nand therefore may be regarded, in all essentials, as identical: Our system\nZ of all real numbers is in all essentials the only one possible satisfying both\nthe conditions 4 and the postulate of completeness.\n\nAfter these somewhat abstract considerations, the main result of our\nwhole investigation may be summarised as follows:\n\nBesides the rational numbers with which we are familiar, there exist\nothers, the so-called irrational numbers. Each of them may be enclosed\n(determined, given, . . .) by a suitable nest of intervals and this indeed\nin many ways. These irrational numbers fit in consistently with the\nrational numbers, in such a manner that the conditions stated in 4 are\nfulfilled by the joint system of all rational and irrational numbers, with\nwhich, to be brief, all calculations may be effected, formally^ exactly as\nwith the rational numbers alone, but with greater success.\n\nThis wider system is moreover incapable of any further extension\ncompatible with conditions 4, and is in all essentials the only system of\nsymbols which satisfies these conditions 4 and also the postulate of com-\npleteness.\n\nWe call it the system of real numbers.\n\nIt is with the elements of this system, with the real numbers \\ that\nwe work (at first exclusively) in the sequel. We consider a particular\nreal number as given (known, determined, defined, calculable, . . .) if\neither it is a rational number and so can be literally written down with\nthe help of integers inserting if need be a fractional bar or a minus\nsign or (and this holds in any case) we are given 32 a nest of intervals\ndefining the number.\n\nWe shall very soon see, however, that many other ways and means,\nbesides the nests of intervals, exist, for defining a real number. In pro-\nportion as such ways become known to us, we shall widen the above-\nmentioned conditions, under which we consider a number as given.\n\n\n\n32 I. e. by the complete explicit specification of the (rational) endpomts in\nthe manner just described*\n\n\n\n5. Radix fractions and the Dedekind section. 37\n\n\n\n5. Radix fractions and the Dedekind section.\n\nA few of the methods for defining real numbers may be mentioned\nat once, as particularly important from the points of view of both theory\nand practice.\n\nIn the first place, a nest of intervals need not always be given in\nthe form (x n \\ y n ) considered by us ; it may often be written in a more\nconvenient form. Thus, as we have already seen, a decimal fraction,\ne.g. 1-41421 . . . , may be immediately interpreted as a nest of intervals,\nwith the assumptions\n\n1 =l-4; #a=l-41; ar 3 = 1-414; ...,\n\nand, generally, x n equal to the decimal fraction broken off after the\nif\" 1 digit; y n being derived from x n by raising the last digit by one,\n\ni.e. y n -- x n -f- 1( y w - Practically, we may thus say that decimal fractions\n\nrepresent a peculiarly clear and convenient specification of nests of\nintervals 33 .\n\nIt is obviously quite an unessential part that the base or radix 10\nof the ordinary scale of notation plays in this connection. If g is any\ninteger ^ 2, we have the exact analogue for fractions in a scale of\nradix g or radix fractions with base g. To begin with, given a real\nnumber o-, an integer p (>, =, or < 0) is uniquely defined by the\ncondition\n\np^cr <p |-1.\n\nThe interval y o between p and p -f- 1 is next divided into g equal\nparts, and each of these parts considered both hero and similarly\nin the following steps as including its left endpoint, but not its\nright one. Then cr belongs to one, and to one only, of these parts,\ni. e. among the numbers 0, 1, 2, . . . , g I there is one and\nonly one which we shall call for brevity a \"digit\" and denote by\n#! for which\n\n\n\n33 The drawback to it is that we can seldom perceive the law of succession\nof the digits, i. e the law of formal ion of the .v w 's and >' n 's.\n\n\n\n38 Chapter I. Principles of the theory of real numbers.\n\nThe interval / x thus defined we proceed to divide again into g equal parts,\nand a will, as before, belong to one, and to one only, of these parts, i. e.\na definite \"digit\" x 2 will be found for which\n\n\n\nThe interval / 2 thus defined we proceed to divide again into g equal parts,\nand so on. The nest of intervals (/ n ) = (x n \\y n ) determined by this pro-\ncess, for which\n\n\n\n* 4- f 4- 4- --\"=* 4-\ng + g * + --- + gn - l +\n\n\n\nz n\n\n(n = 1, 2, 3, . . .)\n\n\n\nclearly defines the number cr, so that M a (# | jy w ). But on the analogy\nof decimal fractions we may now write\n\no ---- p I O-*! .\n\nwhere of course the base g of the radix fraction must be known from\nthe context.\n\nWe have therefore the\n\n22. Theorem 1. Every real number can be represented in one and essen-\ntially only one 35 way by a radix fraction in the scale of base g.\n\nWe mention the following theorem relating further to this represen-\ntation, but shall make no use of it in the sequel:\n\nTheorem 2. The radix fraction for a real number a whatever be\n\n\n\n31 That we have a nest of intervals is immediately obvious, since x n _ 1 <\nX n <*\" y n ^ y n _ 1 throughout, and y n v n - n forms a null sequence, by 10, 7.\n\nr> The slight alteration in our method, required if all the intervals are con-\nsidered as including their right and not their left endpomts, the reader will doubtless\nbe able to carry out for himself. The two results differ if, and only if, the given\nnumber a is rational, and can be written as a fraction having, as denominator, a\npower of g t so that the point a is an endpoint of one of our intervals. Actually\nthe two nests of intervals\n\np -f 0-afi ar, . . . * r _i (~r ~ J ) (g - 1) (# - 1) and / -I- O^ ar t . . . *,._, z r 00 . . . ,\n\nwhere the digit z r is supposed ^ 1, are equal by 14. In every other case, two radix\nfractions which are not identical are unequal, by 14. The reader will easily prove\nfor himself that, except m this case, the representation of any real number a as\na radix fraction with base g is absolutely unique.\n\n\n\n5. Radix fractions and the Dedekind section. 39\n\nthe chosen radix g 2g 2 will prove periodic (or recurring) if and only if\na is rational**.\n\nA particularly advantageous choice to make is often g = 2 ; the pro-\ncess for expressing the number a is then called briefly the method of\nbisection and the resulting radix fraction, whose digits can in that case\nonly be or 1, is called a binary fraction. The method, in a somewhat\nmore general light, is this: we start from a definite interval / and, in\naccordance with some particular rule or point of view, definitely select\none of its two halves, calling it J\\ we then again make a definite choice\nof one of the two halves of y lf calling it / 2 ; and so on. By so doing, we\nspecify, in every case, a well-defined real number, determined with ab-\nsolute uniqueness by the method which regulates at each stage the choice\nbetween the two half- intervals 37 .\n\nIn radix fractions, just as in decimal fractions, we accordingly see\na peculiarly clear and convenient mode of specifying nests of intervals.\nThey shall accordingly in future be admitted for the definition of real\nnumbers on the same footing as decimal fractions.\n\nThe distinction lies somewhat deeper between nests of intervals and\nthe following method of definition of real numbers.\n\nWe suppose given, in any particular way as , two classes of numbers\nA and B, subject to the following three conditions:\n\n1) Each of the two classes contains at least one number.\n\n2) Every number of the class A is 5^ every number of the class B.\n\n3) If an arbitrary positive (small) number e is prescribed, then two\nnumbers can be so chosen from the two classes, a ', say, from A and\nb', say, from B, that 39\n\nb' a < e.\n\nThen the following theorem, holds :\n\n\n\n30 Here for simplicity we regard terminating radix fractions as periodic with\nperiod 0. That every rational number can be represented by a recurring decimal\nfraction was proved by J. Walhs, De Algebra tractatus, p. 3<>4, 1G ( J3. That conversely\nevery irrational number can always, and in one way only, be represented as a non-\nrecurring decimal fraction was first proved generally by O. Stolz (Allgememe Anth-\nmetik I, p. 119, 1885).\n\n37 An example was given in 12, 2.\n\n88 E. g. A contains all rational numbers whose cube is < 5, B all rational\nnumbers whose cube is > 5.\n\n30 \\y e sav f or s hort: the numbers of the two classes approach arbitrarily\nnear to one another. In the example of the preceding footnote, we see at once that\nconditions 1) and 2) are satisfied; that 3) is also satisfied we recognise from the\npossibility of calculating (by the method of partition into tenth parts, for instance)\ntwo decimal fractions ,v n and y n with n places of decimals, differing only by a unit\n\nin the last place, and such that x n 3 < 5, y n * > 5; n being so chosen that , ( . n < e.\n\n\n\n40 Chapter I. Principles of the theory of real numbers.\n\nTheorem 3. There exists one and only one real number a such that\nfor every number a in A and every number b in B the relation\n\na-^v^b\nis always true.\n\nProof. It is again obvious that no two different numbers cr, <r'\nwith this property can exist. For putting | a a' \\ r, we should have\n> 0, yet b a ^ c for every pair of elements a and b from A and B\nrespectively, contrary to condition 3.\n\nThere exists then at most one such number a. We find it in the\nfollowing way: By hypothesis, there is at least one number a l in A and\none number b in B. If a = 6 X , then the common value is manifestly\nthe number a which we are in search of. If a l 4= b ly and therefore by\n2), a l < b ly then we choose two rational numbers x l f^ a ly and y ^ b l\nand apply the method of bisection to the interval / l which they deter-\nmine; we denote the left or right half by / 2 , according as the left half\n(endpoints included) does or does not still contain a point of the class B. By\nthe same rule we next select one of the halves of / 2 , calling it / 3 , and\nso on.\n\nThe intervals / 1? / 2 , . . . , ./, . . . , being obtained by the method of\nbisection, necessarily form a nest\n\n( A) = (x n I y n ) = *\n\nFrom their mode of formation, they possess moreover the property that\nno number of B can lie to the left of any of their left endpoints, and no\nnumber of A to the right of their right endpoints.\n\nBut from this it follows at once that the number a enclosed by them\nis the number required by theorem 3. In fact, if, contrary to the assertion\nin that theorem, a particular number a of A were > cr, so that a a > 0,\nthen we could choose from the succession of intervals J n a particular one,\nsa Y /i> -~ X P ypy Wlt h length < a a. Since x v 5g a ^ y p , this would\nimply\n\ny p or <; y 9 x v <. a a, i. e. y 9 < a,\n\nwhereas, actually, no point of A lies to the right of the right endpoint\ny p of y p . If on the other hand, in any instance, b < cr, it would similarly\nfollow that for a suitable index q, b < x qy whereas actually no point of\nB lies to the left of the left endpoint of an interval J q . Hence we must in-\nvariably have a ^ u fg b. Q. E. D.\n\nAs a special corollary, we have the following theorem, which sup-\nplements Theorem 12, forming an extension of it to the case when the\nnumbers there occurring are arbitrary real numbers. In the formulation,\nwe anticipate the obvious definitions 23 25 of next paragraph.\n\n\n\n5. Radix fractions and the Dedekind section. 41\n\nTheorem 4- If (x n ) is a monotone ascending, and (y n ) a monotone des-\ncending, sequence of (any) real numbers ; //, further, x n <^ y n for every n,\nand the differences y n x n d n form a null sequence-, then there is invariably\none and only one real number a, such that for every n\n\n\n\nWe then say, as before (cf. Definition 11), that the two given sequences define\na nest of intervals (x n \\ y n ) and that a is the number which it (uniquely) deter-\nmines.\n\nProof. If with all the left endpoints x n we constitute a class A,\nand with all the right endpoints y n a class #, of real numbers, these clearly\nsatisfy conditions 1) to 3) of Theorem 3, from which the correctness of\nthe above statement at once follows.\n\n\n\nRemarks and Examples?.\n\n1. Instead of 3), it is often more convenient to stipulate that e.g. every\nrational number should belong either to A or to B (as \\\\as the case in the\nexample of last footnote). In fact, in that case, since rational numbers arc\ndense on the number axis, the requirement 3) is fulfilled of itself. To see this,\nwe have only to imagine the \\\\hole number-axis subduidcd into equal portions of\nlength < e/2. Now consider any one of the portions containing an element from\nA, and, to the right of it, take another portion containing an element from B , together\nwith these two portions, take the finite number of portions, if any, between them.\nOne of these considered portions must be the first of them to contain an element\nb from B. Either this particular portion, or the preceding one, will contain an element\na from A, and we have b a ^ .\n\n2. It is often still more convenient to divide till real numbers into tsvo classes\nA and B. In that case of course 3) is, a fortion, also satisfied of itself.\n\n3. If the two classes A and B are given in one of the last-mentioned ways,\nthen we say that a Dedekind section, is made in the domain of either rational or\nreal numbers, as the case may be 10 . The someuhat more general specification of\ntwo classes ll involved in our theorem 3 \\\\i\\\\ also for brevity be termed a section\nand denoted by (A \\ B). Our theorem 3 can then be stated briefly in the form:\nA section (A \\ B) invariably defines a determinate real number. And its proof consists\nsimply in pointing out that the specification of a section carries with it the speci-\nfication of a nest of intervals, which furnishes a number a with the properties required.\n\n4. Seeing then that every section immediately provides a definite nest of\nintervals, we shall henceforth regard sections as permissible means of defining\n(determining, specifying, . . .) real numbers; also, we now write, if the section\n(A | B) defines the number a,\n\n(A\\B) a.\n\n\n\n40 Cf. p. 1 , footnote 0.\n\n41 This was given in the above form by A. C\\it>elli % Giornale di Matematici,\nVol. 35, p. 209, 1897.\n\n\n\n42 Chapter I. Principles of the theory of real numbers.\n\n5. The converse is of course equally true and even more easily proved. Given\na nest (x n \\ y n ) = cr, we can consider all left endpoints x n as forming a class A,\nand right endpoints a class B, and these two classes evidently furnish a section, which\ndefines the same numher a as the nest itself. A nest can accordingly be regarded\nas a particular kind of section.\n\n(>. By our last remark, the method of sections (for the definition of real\nnumbers) is superior in generality to that of nests. It is also quite as convenient\nfrom the intuitional point of v lew. For if we take, say, the section (A \\ B) in the\nsomewhat more special form, mentioned in 2, of a section in the domain of real\nnumbers, then what our theorem implies is this. If we imagine all points of the\nnumber-axis separated into two classes A and B, thinking e. g. of points of the\none class as marked black and those of the other as white; and if, when this is\ndone, (I) there is at least one point of each kind, (2) every black point lies to the\nleft of every white point, and (3) every point on the number-axis is effectually\ncoloured either black or \\\\hite, then the t\\\\o classes must come into contact at a\nperfectly definite place, and to the left of this place all is black, to the right of it all\nis \\\\hite.\n\n7. We must take care, however, not to accept the illustration just given as\na proof. Had we not already with the help of nests of intervals invented the class\nof real numbers, our theorem could not be proved at all any more than it could\nbe proved that every nest defines a number. We simply agreed and were amply\njustified by the result to regard every nest as a number. In exactly the same\nway we can agree and this is actually the course followed by JR. Dedekmd 42\nin his construction of the system of real numbers to regard every section in the\ndomain of rational numbers as a \"real number\" , and we should then, exactly as\nin our investigations in 3, only have to examine whether this is permissible; i. e.\nwe should have to make sure whether the totality of all such sections (A \\ Z?) forms\na number system in the sense of conditions 4 which is not more difficult than\nthe analogous investigations carried out in 3.\n\nHenceforward and for the present exclusively real numbers\nform our working material. We may even, if we please, drop the word\n\"real\": For the present, \"number\" shall invariably mean a real number.\n\n\n\nExercises on Chapter I.\n\n1. From the fundamental laws 1 and 2 deduce the most important of the\nfurther arithmetical rules, e. g. (a) the product of two negative numbers is positive;\n(b) a .+ c < b + c invariably implies a < b ; (c) for every a we have a -= ;\netc.\n\n2. When in 3, II, 4 are the signs of equality correct?\n\n3. Express the following numbers as binary and as ternary fractions (i. e.\nin scales of notation of which the bases are respectively 2 and 3) :\n\n1 3 1 1 10\n2' 8' TV 7' 17 ;\n\nfind the first few figures of the binary and ternary fractions for V2, V3, ir and e.\n42 Stetigkeit und irrationale Zahlen, Brunswick 1872,\n\n\n\n6. Arbitrary sequences and arbitrary null sequences. 43\n\na n __ an\n\n4. In the sequence 6, 7 prove x n o t where a and ft are the roots\n\nof the quadratic equation x 2 x -f- 1. (Hint: the sequences (a n ) and ()3 W ) have\nthe same law of formation as the sequence 6, 7.)\n\n5. Form the sequence (v n ) of numbers given, for \\: 1, by the formula\n\n.v nfl ---= ax n -| A \\ n _,,\n\nwhere a and A are given positive numbers and the initial terms #, x l 0, 1 ; 1, 0;\n-- 1, a; 1, j3; or are arbitrary. (Here a and j3 denote respectively the positive\nand the negative root of the equation x 2 a x -}- b ) In each of the four cases\ngive an explicit formula for x n .\n\n6. If / , /!, / 2 , ... is a sequence of nested intervals (i. e. each contained\nin the preceding) about whose lengths nothing further is known, then there is at\nleast one point which belongs to all the / n 's.\n\n7. A real number or is irrational, if we can find an ascending sequence of\nintegers (<y n ), such that q n a is not an integer for any H, but if, \\\\hcn p n stands for\nthe integer nearest to q n a, ( f fn a Pn) 1S a null sequence.\n\n8. Prove that (v n | y n ) is a nest in each of the following examples:\n\n\n\nn , .....\n\nb) < A:, < 3-, and for every n ^ 1, v nfl *'r n y n , v n H -- } (V M -f- .v n );\n\nc) < x, <- v, , v nM - i (v w f Vn). y n +i ~ VY M .v w :\n\nd) ^ Xt <>'! ,>' wf i - 1 (x n i V n ), V/M r v/ ^ v n 3' w 1 1 J\n\ne) < .Y! < >'! ,. , A W -H - ^v n .v n , 3'n+i = 2 (v nf i + y n );\n\n\n\ng) < v, < Vi ,3'nM i (V w h 3' w ), V, H _, -- Vw '' Vw .\n\n3'w+i\n\nEvaluate the numbers defined in examples (a) and (g). (Cf. problems 91\nand 92.)\n-/\n\nend knopp\n", "meta": {"author": "AtnNn", "repo": "lean-sandbox", "sha": "8c68afbdc09213173aef1be195da7a9a86060a97", "save_path": "github-repos/lean/AtnNn-lean-sandbox", "path": "github-repos/lean/AtnNn-lean-sandbox/lean-sandbox-8c68afbdc09213173aef1be195da7a9a86060a97/src/knopp/chapter01.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6757646140788307, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.4635403730796717}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport group_theory.finiteness\nimport ring_theory.algebra_tower\nimport ring_theory.ideal.quotient\nimport ring_theory.noetherian\n\n/-!\n# Finiteness conditions in commutative algebra\n\nIn this file we define several notions of finiteness that are common in commutative algebra.\n\n## Main declarations\n\n- `module.finite`, `algebra.finite`, `ring_hom.finite`, `alg_hom.finite`\n  all of these express that some object is finitely generated *as module* over some base ring.\n- `algebra.finite_type`, `ring_hom.finite_type`, `alg_hom.finite_type`\n  all of these express that some object is finitely generated *as algebra* over some base ring.\n- `algebra.finite_presentation`, `ring_hom.finite_presentation`, `alg_hom.finite_presentation`\n  all of these express that some object is finitely presented *as algebra* over some base ring.\n\n-/\n\nopen function (surjective)\nopen_locale big_operators\n\nsection module_and_algebra\n\nvariables (R A B M N : Type*)\n\n/-- A module over a semiring is `finite` if it is finitely generated as a module. -/\nclass module.finite [semiring R] [add_comm_monoid M] [module R M] :\n  Prop := (out : (⊤ : submodule R M).fg)\n\n/-- An algebra over a commutative semiring is of `finite_type` if it is finitely generated\nover the base ring as algebra. -/\nclass algebra.finite_type [comm_semiring R] [semiring A] [algebra R A] : Prop :=\n(out : (⊤ : subalgebra R A).fg)\n\n/-- An algebra over a commutative semiring is `finite_presentation` if it is the quotient of a\npolynomial ring in `n` variables by a finitely generated ideal. -/\ndef algebra.finite_presentation [comm_semiring R] [semiring A] [algebra R A] : Prop :=\n∃ (n : ℕ) (f : mv_polynomial (fin n) R →ₐ[R] A),\n  surjective f ∧ f.to_ring_hom.ker.fg\n\nnamespace module\n\nvariables [semiring R] [add_comm_monoid M] [module R M] [add_comm_monoid N] [module R N]\n\nlemma finite_def {R M} [semiring R] [add_comm_monoid M] [module R M] :\n  finite R M ↔ (⊤ : submodule R M).fg := ⟨λ h, h.1, λ h, ⟨h⟩⟩\n\n@[priority 100] -- see Note [lower instance priority]\ninstance is_noetherian.finite [is_noetherian R M] : finite R M :=\n⟨is_noetherian.noetherian ⊤⟩\n\nnamespace finite\nopen _root_.submodule set\n\nlemma iff_add_monoid_fg {M : Type*} [add_comm_monoid M] : module.finite ℕ M ↔ add_monoid.fg M :=\n⟨λ h, add_monoid.fg_def.2 $ (fg_iff_add_submonoid_fg ⊤).1 (finite_def.1 h),\n  λ h, finite_def.2 $ (fg_iff_add_submonoid_fg ⊤).2 (add_monoid.fg_def.1 h)⟩\n\nlemma iff_add_group_fg {G : Type*} [add_comm_group G] : module.finite ℤ G ↔ add_group.fg G :=\n⟨λ h, add_group.fg_def.2 $ (fg_iff_add_subgroup_fg ⊤).1 (finite_def.1 h),\n  λ h, finite_def.2 $ (fg_iff_add_subgroup_fg ⊤).2 (add_group.fg_def.1 h)⟩\n\nvariables {R M N}\n\nlemma exists_fin [finite R M] : ∃ (n : ℕ) (s : fin n → M), span R (range s) = ⊤ :=\nsubmodule.fg_iff_exists_fin_generating_family.mp out\n\nlemma of_surjective [hM : finite R M] (f : M →ₗ[R] N) (hf : surjective f) :\n  finite R N :=\n⟨begin\n  rw [← linear_map.range_eq_top.2 hf, ← submodule.map_top],\n  exact submodule.fg_map hM.1\nend⟩\n\nlemma of_injective [is_noetherian R N] (f : M →ₗ[R] N)\n  (hf : function.injective f) : finite R M :=\n⟨fg_of_injective f hf⟩\n\nvariables (R)\n\ninstance self : finite R R :=\n⟨⟨{1}, by simpa only [finset.coe_singleton] using ideal.span_singleton_one⟩⟩\n\nvariable (M)\n\nlemma of_restrict_scalars_finite (R A M : Type*) [comm_semiring R] [semiring A] [add_comm_monoid M]\n  [module R M] [module A M] [algebra R A] [is_scalar_tower R A M] [hM : finite R M] :\n  finite A M :=\nbegin\n  rw [finite_def, fg_def] at hM ⊢,\n  obtain ⟨S, hSfin, hSgen⟩ := hM,\n  refine ⟨S, hSfin, eq_top_iff.2 _⟩,\n  have := submodule.span_le_restrict_scalars R A S,\n  rw hSgen at this,\n  exact this\nend\n\nvariables {R M}\n\ninstance prod [hM : finite R M] [hN : finite R N] : finite R (M × N) :=\n⟨begin\n  rw ← submodule.prod_top,\n  exact submodule.fg_prod hM.1 hN.1\nend⟩\n\nlemma equiv [hM : finite R M] (e : M ≃ₗ[R] N) : finite R N :=\nof_surjective (e : M →ₗ[R] N) e.surjective\n\nsection algebra\n\nlemma trans {R : Type*} (A B : Type*) [comm_semiring R] [comm_semiring A] [algebra R A]\n  [semiring B] [algebra R B] [algebra A B] [is_scalar_tower R A B] :\n  ∀ [finite R A] [finite A B], finite R B\n| ⟨⟨s, hs⟩⟩ ⟨⟨t, ht⟩⟩ := ⟨submodule.fg_def.2\n  ⟨set.image2 (•) (↑s : set A) (↑t : set B),\n    set.finite.image2 _ s.finite_to_set t.finite_to_set,\n    by rw [set.image2_smul, submodule.span_smul hs (↑t : set B),\n      ht, submodule.restrict_scalars_top]⟩⟩\n\n@[priority 100] -- see Note [lower instance priority]\ninstance finite_type {R : Type*} (A : Type*) [comm_semiring R] [comm_semiring A]\n  [algebra R A] [hRA : finite R A] : algebra.finite_type R A :=\n⟨subalgebra.fg_of_submodule_fg hRA.1⟩\n\nend algebra\n\nend finite\n\nend module\n\nnamespace algebra\n\nvariables [comm_ring R] [comm_ring A] [algebra R A] [comm_ring B] [algebra R B]\nvariables [add_comm_group M] [module R M]\nvariables [add_comm_group N] [module R N]\n\nnamespace finite_type\n\nlemma self : finite_type R R := ⟨⟨{1}, subsingleton.elim _ _⟩⟩\n\nsection\nopen_locale classical\n\nprotected lemma mv_polynomial (ι : Type*) [fintype ι] : finite_type R (mv_polynomial ι R) :=\n⟨⟨finset.univ.image mv_polynomial.X, begin\n  rw eq_top_iff, refine λ p, mv_polynomial.induction_on' p\n    (λ u x, finsupp.induction u (subalgebra.algebra_map_mem _ x)\n      (λ i n f hif hn ih, _))\n    (λ p q ihp ihq, subalgebra.add_mem _ ihp ihq),\n  rw [add_comm, mv_polynomial.monomial_add_single],\n  exact subalgebra.mul_mem _ ih\n    (subalgebra.pow_mem _ (subset_adjoin $ finset.mem_image_of_mem _ $ finset.mem_univ _) _)\nend⟩⟩\nend\n\nlemma of_restrict_scalars_finite_type [algebra A B] [is_scalar_tower R A B] [hB : finite_type R B] :\n  finite_type A B :=\nbegin\n  obtain ⟨S, hS⟩ := hB.out,\n  refine ⟨⟨S, eq_top_iff.2 (λ b, _)⟩⟩,\n  have le : adjoin R (S : set B) ≤ subalgebra.restrict_scalars R (adjoin A S),\n  { apply (algebra.adjoin_le _ : _ ≤ (subalgebra.restrict_scalars R (adjoin A ↑S))),\n    simp only [subalgebra.coe_restrict_scalars],\n    exact algebra.subset_adjoin, },\n  exact le (eq_top_iff.1 hS b),\nend\n\nvariables {R A B}\n\nlemma of_surjective (hRA : finite_type R A) (f : A →ₐ[R] B) (hf : surjective f) :\n  finite_type R B :=\n⟨begin\n  convert subalgebra.fg_map _ f hRA.1,\n  simpa only [map_top f, @eq_comm _ ⊤, eq_top_iff, alg_hom.mem_range] using hf\nend⟩\n\nlemma equiv (hRA : finite_type R A) (e : A ≃ₐ[R] B) : finite_type R B :=\nhRA.of_surjective e e.surjective\n\nlemma trans [algebra A B] [is_scalar_tower R A B] (hRA : finite_type R A) (hAB : finite_type A B) :\n  finite_type R B :=\n⟨fg_trans' hRA.1 hAB.1⟩\n\n/-- An algebra is finitely generated if and only if it is a quotient\nof a polynomial ring whose variables are indexed by a finset. -/\nlemma iff_quotient_mv_polynomial : (finite_type R A) ↔ ∃ (s : finset A)\n  (f : (mv_polynomial {x // x ∈ s} R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rintro ⟨s, hs⟩,\n    use [s, mv_polynomial.aeval coe],\n    intro x,\n    have hrw : (↑s : set A) = (λ (x : A), x ∈ s.val) := rfl,\n    rw [← set.mem_range, ← alg_hom.coe_range, ← adjoin_eq_range, ← hrw, hs],\n    exact set.mem_univ x },\n  { rintro ⟨s, ⟨f, hsur⟩⟩,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R {x // x ∈ s}) f hsur }\nend\n\n/-- An algebra is finitely generated if and only if it is a quotient\nof a polynomial ring whose variables are indexed by a fintype. -/\nlemma iff_quotient_mv_polynomial' : (finite_type R A) ↔ ∃ (ι : Type u_2) (_ : fintype ι)\n  (f : (mv_polynomial ι R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial,\n    rintro ⟨s, ⟨f, hsur⟩⟩,\n    use [{x // x ∈ s}, by apply_instance, f, hsur] },\n  { rintro ⟨ι, ⟨hfintype, ⟨f, hsur⟩⟩⟩,\n    letI : fintype ι := hfintype,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R ι) f hsur }\nend\n\n/-- An algebra is finitely generated if and only if it is a quotient of a polynomial ring in `n`\nvariables. -/\nlemma iff_quotient_mv_polynomial'' : (finite_type R A) ↔ ∃ (n : ℕ)\n  (f : (mv_polynomial (fin n) R) →ₐ[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial',\n    rintro ⟨ι, hfintype, ⟨f, hsur⟩⟩,\n    letI := hfintype,\n    obtain ⟨equiv⟩ := @fintype.trunc_equiv_fin ι (classical.dec_eq ι) hfintype,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    exact ⟨fintype.card ι, alg_hom.comp f equiv.symm, function.surjective.comp hsur\n      (alg_equiv.symm equiv).surjective⟩ },\n  { rintro ⟨n, ⟨f, hsur⟩⟩,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R (fin n)) f hsur }\nend\n\n/-- A finitely presented algebra is of finite type. -/\nlemma of_finite_presentation : finite_presentation R A → finite_type R A :=\nbegin\n  rintro ⟨n, f, hf⟩,\n  apply (finite_type.iff_quotient_mv_polynomial'').2,\n  exact ⟨n, f, hf.1⟩\nend\n\ninstance prod [hA : finite_type R A] [hB : finite_type R B] : finite_type R (A × B) :=\n⟨begin\n  rw ← subalgebra.prod_top,\n  exact subalgebra.fg_prod hA.1 hB.1\nend⟩\n\nend finite_type\n\nnamespace finite_presentation\n\nvariables {R A B}\n\n/-- An algebra over a Noetherian ring is finitely generated if and only if it is finitely\npresented. -/\nlemma of_finite_type [is_noetherian_ring R] : finite_type R A ↔ finite_presentation R A :=\nbegin\n  refine ⟨λ h, _, algebra.finite_type.of_finite_presentation⟩,\n  obtain ⟨n, f, hf⟩ := algebra.finite_type.iff_quotient_mv_polynomial''.1 h,\n  refine ⟨n, f, hf, _⟩,\n  have hnoet : is_noetherian_ring (mv_polynomial (fin n) R) := by apply_instance,\n  replace hnoet := (is_noetherian_ring_iff.1 hnoet).noetherian,\n  exact hnoet f.to_ring_hom.ker,\nend\n\n/-- If `e : A ≃ₐ[R] B` and `A` is finitely presented, then so is `B`. -/\nlemma equiv (hfp : finite_presentation R A) (e : A ≃ₐ[R] B) : finite_presentation R B :=\nbegin\n  obtain ⟨n, f, hf⟩ := hfp,\n  use [n, alg_hom.comp ↑e f],\n  split,\n  { exact function.surjective.comp e.surjective hf.1 },\n  suffices hker : (alg_hom.comp ↑e f).to_ring_hom.ker = f.to_ring_hom.ker,\n  { rw hker, exact hf.2 },\n  { have hco : (alg_hom.comp ↑e f).to_ring_hom = ring_hom.comp ↑e.to_ring_equiv f.to_ring_hom,\n    { have h : (alg_hom.comp ↑e f).to_ring_hom = e.to_alg_hom.to_ring_hom.comp f.to_ring_hom := rfl,\n      have h1 : ↑(e.to_ring_equiv) = (e.to_alg_hom).to_ring_hom := rfl,\n      rw [h, h1] },\n    rw [ring_hom.ker_eq_comap_bot, hco, ← ideal.comap_comap, ← ring_hom.ker_eq_comap_bot,\n      ring_hom.ker_coe_equiv (alg_equiv.to_ring_equiv e), ring_hom.ker_eq_comap_bot] }\nend\n\nvariable (R)\n\n/-- The ring of polynomials in finitely many variables is finitely presented. -/\nprotected lemma mv_polynomial (ι : Type u_2) [fintype ι] :\n  finite_presentation R (mv_polynomial ι R) :=\nbegin\n  obtain ⟨equiv⟩ := @fintype.trunc_equiv_fin ι (classical.dec_eq ι) _,\n  replace equiv := mv_polynomial.rename_equiv R equiv,\n  refine ⟨_, alg_equiv.to_alg_hom equiv.symm, _⟩,\n  split,\n  { exact (alg_equiv.symm equiv).surjective },\n  suffices hinj : function.injective equiv.symm.to_alg_hom.to_ring_hom,\n  { rw [(ring_hom.injective_iff_ker_eq_bot _).1 hinj],\n    exact submodule.fg_bot },\n  exact (alg_equiv.symm equiv).injective\nend\n\n/-- `R` is finitely presented as `R`-algebra. -/\nlemma self : finite_presentation R R :=\nequiv (finite_presentation.mv_polynomial R pempty) (mv_polynomial.is_empty_alg_equiv R pempty)\n\nvariable {R}\n\n/-- The quotient of a finitely presented algebra by a finitely generated ideal is finitely\npresented. -/\nprotected lemma quotient {I : ideal A} (h : submodule.fg I) (hfp : finite_presentation R A) :\n  finite_presentation R (A ⧸ I) :=\nbegin\n  obtain ⟨n, f, hf⟩ := hfp,\n  refine ⟨n, (ideal.quotient.mkₐ R I).comp f, _, _⟩,\n  { exact (ideal.quotient.mkₐ_surjective R I).comp hf.1 },\n  { refine submodule.fg_ker_ring_hom_comp _ _ hf.2 _ hf.1,\n    simp [h] }\nend\n\n/-- If `f : A →ₐ[R] B` is surjective with finitely generated kernel and `A` is finitely presented,\nthen so is `B`. -/\nlemma of_surjective {f : A →ₐ[R] B} (hf : function.surjective f) (hker : f.to_ring_hom.ker.fg)\n  (hfp : finite_presentation R A) : finite_presentation R B :=\nequiv (hfp.quotient hker) (ideal.quotient_ker_alg_equiv_of_surjective hf)\n\nlemma iff : finite_presentation R A ↔\n  ∃ n (I : ideal (mv_polynomial (fin n) R)) (e : (_ ⧸ I) ≃ₐ[R] A), I.fg :=\nbegin\n  split,\n  { rintros ⟨n, f, hf⟩,\n    exact ⟨n, f.to_ring_hom.ker, ideal.quotient_ker_alg_equiv_of_surjective hf.1, hf.2⟩ },\n  { rintros ⟨n, I, e, hfg⟩,\n    exact equiv ((finite_presentation.mv_polynomial R _).quotient hfg) e }\nend\n\n/-- An algebra is finitely presented if and only if it is a quotient of a polynomial ring whose\nvariables are indexed by a fintype by a finitely generated ideal. -/\nlemma iff_quotient_mv_polynomial' : finite_presentation R A ↔ ∃ (ι : Type u_2) (_ : fintype ι)\n  (f : mv_polynomial ι R →ₐ[R] A), surjective f ∧ f.to_ring_hom.ker.fg :=\nbegin\n  split,\n  { rintro ⟨n, f, hfs, hfk⟩,\n    set ulift_var := mv_polynomial.rename_equiv R equiv.ulift,\n    refine ⟨ulift (fin n), infer_instance, f.comp ulift_var.to_alg_hom,\n      hfs.comp ulift_var.surjective,\n      submodule.fg_ker_ring_hom_comp _ _ _ hfk ulift_var.surjective⟩,\n    convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv ulift_var.to_ring_equiv, },\n  { rintro ⟨ι, hfintype, f, hf⟩,\n    haveI : fintype ι := hfintype,\n    obtain ⟨equiv⟩ := @fintype.trunc_equiv_fin ι (classical.dec_eq ι) _,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    refine ⟨fintype.card ι, f.comp equiv.symm,\n      hf.1.comp (alg_equiv.symm equiv).surjective,\n      submodule.fg_ker_ring_hom_comp _ f _ hf.2 equiv.symm.surjective⟩,\n    convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv (equiv.symm.to_ring_equiv), }\nend\n\n/-- If `A` is a finitely presented `R`-algebra, then `mv_polynomial (fin n) A` is finitely presented\nas `R`-algebra. -/\nlemma mv_polynomial_of_finite_presentation (hfp : finite_presentation R A) (ι : Type*)\n  [fintype ι] : finite_presentation R (mv_polynomial ι A) :=\nbegin\n  rw iff_quotient_mv_polynomial' at hfp ⊢,\n  classical,\n  obtain ⟨ι', _, f, hf_surj, hf_ker⟩ := hfp,\n  resetI,\n  let g := (mv_polynomial.map_alg_hom f).comp (mv_polynomial.sum_alg_equiv R ι ι').to_alg_hom,\n  refine ⟨ι ⊕ ι', by apply_instance, g,\n    (mv_polynomial.map_surjective f.to_ring_hom hf_surj).comp (alg_equiv.surjective _),\n    submodule.fg_ker_ring_hom_comp _ _ _ _ (alg_equiv.surjective _)⟩,\n  { convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv _, },\n  { rw [alg_hom.to_ring_hom_eq_coe, mv_polynomial.map_alg_hom_coe_ring_hom, mv_polynomial.ker_map],\n    exact submodule.map_fg_of_fg _ hf_ker mv_polynomial.C, }\nend\n\n/-- If `A` is an `R`-algebra and `S` is an `A`-algebra, both finitely presented, then `S` is\n  finitely presented as `R`-algebra. -/\nlemma trans [algebra A B] [is_scalar_tower R A B] (hfpA : finite_presentation R A)\n  (hfpB : finite_presentation A B) : finite_presentation R B :=\nbegin\n  obtain ⟨n, I, e, hfg⟩ := iff.1 hfpB,\n  exact equiv ((mv_polynomial_of_finite_presentation hfpA _).quotient hfg) (e.restrict_scalars R)\nend\n\nend finite_presentation\n\nend algebra\n\nend module_and_algebra\n\nnamespace ring_hom\nvariables {A B C : Type*} [comm_ring A] [comm_ring B] [comm_ring C]\n\n/-- A ring morphism `A →+* B` is `finite` if `B` is finitely generated as `A`-module. -/\ndef finite (f : A →+* B) : Prop :=\nby letI : algebra A B := f.to_algebra; exact module.finite A B\n\n/-- A ring morphism `A →+* B` is of `finite_type` if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A →+* B) : Prop := @algebra.finite_type A B _ _ f.to_algebra\n\n/-- A ring morphism `A →+* B` is of `finite_presentation` if `B` is finitely presented as\n`A`-algebra. -/\ndef finite_presentation (f : A →+* B) : Prop := @algebra.finite_presentation A B _ _ f.to_algebra\n\nnamespace finite\n\nvariables (A)\n\nlemma id : finite (ring_hom.id A) := module.finite.self A\n\nvariables {A}\n\nlemma of_surjective (f : A →+* B) (hf : surjective f) : f.finite :=\nbegin\n  letI := f.to_algebra,\n  exact module.finite.of_surjective (algebra.of_id A B).to_linear_map hf\nend\n\nlemma comp {g : B →+* C} {f : A →+* B} (hg : g.finite) (hf : f.finite) : (g.comp f).finite :=\n@module.finite.trans A B C _ _ f.to_algebra _ (g.comp f).to_algebra g.to_algebra\nbegin\n  fconstructor,\n  intros a b c,\n  simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc],\n  refl\nend\nhf hg\n\nlemma finite_type {f : A →+* B} (hf : f.finite) : finite_type f :=\n@module.finite.finite_type _ _ _ _ f.to_algebra hf\n\nlemma of_comp_finite {f : A →+* B} {g : B →+* C} (h : (g.comp f).finite) : g.finite :=\nbegin\n  letI := f.to_algebra,\n  letI := g.to_algebra,\n  letI := (g.comp f).to_algebra,\n  letI : is_scalar_tower A B C := restrict_scalars.is_scalar_tower A B C,\n  letI : module.finite A C := h,\n  exact module.finite.of_restrict_scalars_finite A B C\nend\n\nend finite\n\nnamespace finite_type\n\nvariables (A)\n\nlemma id : finite_type (ring_hom.id A) := algebra.finite_type.self A\n\nvariables {A}\n\nlemma comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.finite_type) (hg : surjective g) :\n  (g.comp f).finite_type :=\n@algebra.finite_type.of_surjective A B C _ _ f.to_algebra _ (g.comp f).to_algebra hf\n{ to_fun := g, commutes' := λ a, rfl, .. g } hg\n\nlemma of_surjective (f : A →+* B) (hf : surjective f) : f.finite_type :=\nby { rw ← f.comp_id, exact (id A).comp_surjective hf }\n\nlemma comp {g : B →+* C} {f : A →+* B} (hg : g.finite_type) (hf : f.finite_type) :\n  (g.comp f).finite_type :=\n@algebra.finite_type.trans A B C _ _ f.to_algebra _ (g.comp f).to_algebra g.to_algebra\nbegin\n  fconstructor,\n  intros a b c,\n  simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc],\n  refl\nend\nhf hg\n\nlemma of_finite_presentation {f : A →+* B} (hf : f.finite_presentation) : f.finite_type :=\n@algebra.finite_type.of_finite_presentation A B _ _ f.to_algebra hf\n\nlemma of_comp_finite_type {f : A →+* B} {g : B →+* C} (h : (g.comp f).finite_type) :\n  g.finite_type :=\nbegin\n  letI := f.to_algebra,\n  letI := g.to_algebra,\n  letI := (g.comp f).to_algebra,\n  letI : is_scalar_tower A B C := restrict_scalars.is_scalar_tower A B C,\n  letI : algebra.finite_type A C := h,\n  exact algebra.finite_type.of_restrict_scalars_finite_type A B C\nend\n\nend finite_type\n\nnamespace finite_presentation\n\nvariables (A)\n\nlemma id : finite_presentation (ring_hom.id A) := algebra.finite_presentation.self A\n\nvariables {A}\n\nlemma comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.finite_presentation) (hg : surjective g)\n  (hker : g.ker.fg) :  (g.comp f).finite_presentation :=\n@algebra.finite_presentation.of_surjective A B C _ _ f.to_algebra _ (g.comp f).to_algebra\n{ to_fun := g, commutes' := λ a, rfl, .. g } hg hker hf\n\nlemma of_surjective (f : A →+* B) (hf : surjective f) (hker : f.ker.fg) : f.finite_presentation :=\nby { rw ← f.comp_id, exact (id A).comp_surjective hf hker}\n\nlemma of_finite_type [is_noetherian_ring A] {f : A →+* B} : f.finite_type ↔ f.finite_presentation :=\n@algebra.finite_presentation.of_finite_type A B _ _ f.to_algebra _\n\nlemma comp {g : B →+* C} {f : A →+* B} (hg : g.finite_presentation) (hf : f.finite_presentation) :\n  (g.comp f).finite_presentation :=\n@algebra.finite_presentation.trans A B C _ _ f.to_algebra _ (g.comp f).to_algebra g.to_algebra\n{ smul_assoc := λ a b c, begin\n    simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc],\n    refl\n  end }\nhf hg\n\nend finite_presentation\n\nend ring_hom\n\nnamespace alg_hom\n\nvariables {R A B C : Type*} [comm_ring R]\nvariables [comm_ring A] [comm_ring B] [comm_ring C]\nvariables [algebra R A] [algebra R B] [algebra R C]\n\n/-- An algebra morphism `A →ₐ[R] B` is finite if it is finite as ring morphism.\nIn other words, if `B` is finitely generated as `A`-module. -/\ndef finite (f : A →ₐ[R] B) : Prop := f.to_ring_hom.finite\n\n/-- An algebra morphism `A →ₐ[R] B` is of `finite_type` if it is of finite type as ring morphism.\nIn other words, if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A →ₐ[R] B) : Prop := f.to_ring_hom.finite_type\n\n/-- An algebra morphism `A →ₐ[R] B` is of `finite_presentation` if it is of finite presentation as\nring morphism. In other words, if `B` is finitely presented as `A`-algebra. -/\ndef finite_presentation (f : A →ₐ[R] B) : Prop := f.to_ring_hom.finite_presentation\n\nnamespace finite\n\nvariables (R A)\n\nlemma id : finite (alg_hom.id R A) := ring_hom.finite.id A\n\nvariables {R A}\n\nlemma comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.finite) (hf : f.finite) : (g.comp f).finite :=\nring_hom.finite.comp hg hf\n\nlemma of_surjective (f : A →ₐ[R] B) (hf : surjective f) : f.finite :=\nring_hom.finite.of_surjective f hf\n\nlemma finite_type {f : A →ₐ[R] B} (hf : f.finite) : finite_type f :=\nring_hom.finite.finite_type hf\n\nlemma of_comp_finite {f : A →ₐ[R] B} {g : B →ₐ[R] C} (h : (g.comp f).finite) : g.finite :=\nring_hom.finite.of_comp_finite h\n\nend finite\n\nnamespace finite_type\n\nvariables (R A)\n\nlemma id : finite_type (alg_hom.id R A) := ring_hom.finite_type.id A\n\nvariables {R A}\n\nlemma comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.finite_type) (hf : f.finite_type) :\n  (g.comp f).finite_type :=\nring_hom.finite_type.comp hg hf\n\nlemma comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.finite_type) (hg : surjective g) :\n  (g.comp f).finite_type :=\nring_hom.finite_type.comp_surjective hf hg\n\nlemma of_surjective (f : A →ₐ[R] B) (hf : surjective f) : f.finite_type :=\nring_hom.finite_type.of_surjective f hf\n\nlemma of_finite_presentation {f : A →ₐ[R] B} (hf : f.finite_presentation) : f.finite_type :=\nring_hom.finite_type.of_finite_presentation hf\n\nlemma of_comp_finite_type {f : A →ₐ[R] B} {g : B →ₐ[R] C} (h : (g.comp f).finite_type) :\ng.finite_type :=\nring_hom.finite_type.of_comp_finite_type h\n\nend finite_type\n\nnamespace finite_presentation\n\nvariables (R A)\n\nlemma id : finite_presentation (alg_hom.id R A) := ring_hom.finite_presentation.id A\n\nvariables {R A}\n\nlemma comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.finite_presentation)\n  (hf : f.finite_presentation) : (g.comp f).finite_presentation :=\nring_hom.finite_presentation.comp hg hf\n\nlemma comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.finite_presentation)\n  (hg : surjective g) (hker : g.to_ring_hom.ker.fg) : (g.comp f).finite_presentation :=\nring_hom.finite_presentation.comp_surjective hf hg hker\n\nlemma of_surjective (f : A →ₐ[R] B) (hf : surjective f) (hker : f.to_ring_hom.ker.fg) :\n  f.finite_presentation :=\nring_hom.finite_presentation.of_surjective f hf hker\n\nlemma of_finite_type [is_noetherian_ring A] {f : A →ₐ[R] B} :\n  f.finite_type ↔ f.finite_presentation :=\nring_hom.finite_presentation.of_finite_type\n\nend finite_presentation\n\nend alg_hom\n\nsection monoid_algebra\n\nvariables {R : Type*} {M : Type*}\n\nnamespace add_monoid_algebra\n\nopen algebra add_submonoid submodule\n\nsection span\n\nsection semiring\n\nvariables [comm_semiring R] [add_monoid M]\n\n/-- An element of `add_monoid_algebra R M` is in the subalgebra generated by its support. -/\nlemma mem_adjoin_support (f : add_monoid_algebra R M) : f ∈ adjoin R (of' R M '' f.support) :=\nbegin\n  suffices : span R (of' R M '' f.support) ≤ (adjoin R (of' R M '' f.support)).to_submodule,\n  { exact this (mem_span_support f) },\n  rw submodule.span_le,\n  exact subset_adjoin\nend\n\n/-- If a set `S` generates, as algebra, `add_monoid_algebra R M`, then the set of supports of\nelements of `S` generates `add_monoid_algebra R M`. -/\nlemma support_gen_of_gen {S : set (add_monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (⋃ f ∈ S, (of' R M '' (f.support : set M))) = ⊤ :=\nbegin\n  refine le_antisymm le_top _,\n  rw [← hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : of' R M '' f.support ⊆\n    ⋃ (g : add_monoid_algebra R M) (H : g ∈ S), of' R M '' g.support,\n  { intros s hs,\n    exact set.mem_bUnion_iff.2 ⟨f, ⟨hf, hs⟩⟩ },\n  exact adjoin_mono hincl (mem_adjoin_support f)\nend\n\n/-- If a set `S` generates, as algebra, `add_monoid_algebra R M`, then the image of the union of\nthe supports of elements of `S` generates `add_monoid_algebra R M`. -/\nlemma support_gen_of_gen' {S : set (add_monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (of' R M '' (⋃ f ∈ S, (f.support : set M))) = ⊤ :=\nbegin\n  suffices : of' R M '' (⋃ f ∈ S, (f.support : set M)) = ⋃ f ∈ S, (of' R M '' (f.support : set M)),\n  { rw this,\n    exact support_gen_of_gen hS },\n  simp only [set.image_Union]\nend\n\nend semiring\n\nsection ring\n\nvariables [comm_ring R] [add_comm_monoid M]\n\n/-- If `add_monoid_algebra R M` is of finite type, there there is a `G : finset M` such that its\nimage generates, as algera, `add_monoid_algebra R M`. -/\nlemma exists_finset_adjoin_eq_top [h : finite_type R (add_monoid_algebra R M)] :\n  ∃ G : finset M, algebra.adjoin R (of' R M '' G) = ⊤ :=\nbegin\n  unfreezingI { obtain ⟨S, hS⟩ := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (λ f, f.support),\n  have : (finset.bUnion S (λ f, f.support) : set M) = ⋃ f ∈ S, (f.support : set M),\n  { simp only [finset.set_bUnion_coe, finset.coe_bUnion] },\n  rw [this],\n  exact support_gen_of_gen' hS\nend\n\n/-- The image of an element `m : M` in `add_monoid_algebra R M` belongs the submodule generated by\n`S : set M` if and only if `m ∈ S`. -/\nlemma of'_mem_span [nontrivial R] {m : M} {S : set M} :\n  of' R M m ∈ span R (of' R M '' S) ↔ m ∈ S :=\nbegin\n  refine ⟨λ h, _, λ h, submodule.subset_span $ set.mem_image_of_mem (of R M) h⟩,\n  rw [of', ← finsupp.supported_eq_span_single, finsupp.mem_supported,\n    finsupp.support_single_ne_zero (@one_ne_zero R _ (by apply_instance))] at h,\n  simpa using h\nend\n\n/--If the image of an element `m : M` in `add_monoid_algebra R M` belongs the submodule generated by\nthe closure of some `S : set M` then `m ∈ closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of' R M m ∈ span R (submonoid.closure (of' R M '' S) : set (add_monoid_algebra R M))) :\n  m ∈ closure S :=\nbegin\n  suffices : multiplicative.of_add m ∈ submonoid.closure (multiplicative.to_add ⁻¹' S),\n  { simpa [← to_submonoid_closure] },\n  rw [set.image_congr' (show ∀ x, of' R M x = of R M x, from λ x, of'_eq_of x),\n    ← monoid_hom.map_mclosure] at h,\n  simpa using of'_mem_span.1 h\nend\n\nend ring\n\nend span\n\nvariables [add_comm_monoid M]\n\n/-- If a set `S` generates an additive monoid `M`, then the image of `M` generates, as algebra,\n`add_monoid_algebra R M`. -/\nlemma mv_polynomial_aeval_of_surjective_of_closure [comm_semiring R] {S : set M}\n  (hS : closure S = ⊤) : function.surjective (mv_polynomial.aeval\n  (λ (s : S), of' R M ↑s) : mv_polynomial S R → add_monoid_algebra R M) :=\nbegin\n  refine λ f, induction_on f (λ m, _) _ _,\n  { have : m ∈ closure S := hS.symm ▸ mem_top _,\n    refine closure_induction this (λ m hm, _) _ _,\n    { exact ⟨mv_polynomial.X ⟨m, hm⟩, mv_polynomial.aeval_X _ _⟩ },\n    { exact ⟨1, alg_hom.map_one _⟩ },\n    { rintro m₁ m₂ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩,\n      exact ⟨P₁ * P₂, by rw [alg_hom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]; refl⟩ } },\n  { rintro f g ⟨P, rfl⟩ ⟨Q, rfl⟩,\n    exact ⟨P + Q, alg_hom.map_add _ _ _⟩ },\n  { rintro r f ⟨P, rfl⟩,\n    exact ⟨r • P, alg_hom.map_smul _ _ _⟩ }\nend\n\nvariables (R M)\n\n/-- If an additive monoid `M` is finitely generated then `add_monoid_algebra R M` is of finite\ntype. -/\ninstance finite_type_of_fg [comm_ring R] [h : add_monoid.fg M] :\n  finite_type R (add_monoid_algebra R M) :=\nbegin\n  obtain ⟨S, hS⟩ := h.out,\n  exact (finite_type.mv_polynomial R (S : set M)).of_surjective (mv_polynomial.aeval\n    (λ (s : (S : set M)), of' R M ↑s)) (mv_polynomial_aeval_of_surjective_of_closure hS)\nend\n\nvariables {R M}\n\n/-- An additive monoid `M` is finitely generated if and only if `add_monoid_algebra R M` is of\nfinite type. -/\nlemma finite_type_iff_fg [comm_ring R] [nontrivial R] :\n  finite_type R (add_monoid_algebra R M) ↔ add_monoid.fg M :=\nbegin\n  refine ⟨λ h, _, λ h, @add_monoid_algebra.finite_type_of_fg _ _ _ _ h⟩,\n  obtain ⟨S, hS⟩ := @exists_finset_adjoin_eq_top R M _ _ h,\n  refine add_monoid.fg_def.2 ⟨S, (eq_top_iff' _).2 (λ m, _)⟩,\n  have hm : of' R M m ∈ (adjoin R (of' R M '' ↑S)).to_submodule,\n  { simp only [hS, top_to_submodule, submodule.mem_top], },\n  rw [adjoin_eq_span] at hm,\n  exact mem_closure_of_mem_span_closure hm\nend\n\n/-- If `add_monoid_algebra R M` is of finite type then `M` is finitely generated. -/\nlemma fg_of_finite_type [comm_ring R] [nontrivial R] [h : finite_type R (add_monoid_algebra R M)] :\n  add_monoid.fg M :=\nfinite_type_iff_fg.1 h\n\n/-- An additive group `G` is finitely generated if and only if `add_monoid_algebra R G` is of\nfinite type. -/\nlemma finite_type_iff_group_fg {G : Type*} [add_comm_group G] [comm_ring R] [nontrivial R] :\n  finite_type R (add_monoid_algebra R G) ↔ add_group.fg G :=\nby simpa [add_group.fg_iff_add_monoid.fg] using finite_type_iff_fg\n\nend add_monoid_algebra\n\nnamespace monoid_algebra\n\nopen algebra submonoid submodule\n\nsection span\n\nsection semiring\n\nvariables [comm_semiring R] [monoid M]\n\n/-- An element of `monoid_algebra R M` is in the subalgebra generated by its support. -/\nlemma mem_adjoint_support (f : monoid_algebra R M) : f ∈ adjoin R (of R M '' f.support) :=\nbegin\n  suffices : span R (of R M '' f.support) ≤ (adjoin R (of R M '' f.support)).to_submodule,\n  { exact this (mem_span_support f) },\n  rw submodule.span_le,\n  exact subset_adjoin\nend\n\n/-- If a set `S` generates, as algebra, `monoid_algebra R M`, then the set of supports of elements\nof `S` generates `monoid_algebra R M`. -/\nlemma support_gen_of_gen {S : set (monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (⋃ f ∈ S, (of R M '' (f.support : set M))) = ⊤ :=\nbegin\n  refine le_antisymm le_top _,\n  rw [← hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : (of R M) '' f.support ⊆\n    ⋃ (g : monoid_algebra R M) (H : g ∈ S), of R M '' g.support,\n  { intros s hs,\n    exact set.mem_bUnion_iff.2 ⟨f, ⟨hf, hs⟩⟩ },\n  exact adjoin_mono hincl (mem_adjoint_support f)\nend\n\n/-- If a set `S` generates, as algebra, `monoid_algebra R M`, then the image of the union of the\nsupports of elements of `S` generates `monoid_algebra R M`. -/\nlemma support_gen_of_gen' {S : set (monoid_algebra R M)} (hS : algebra.adjoin R S = ⊤) :\n  algebra.adjoin R (of R M '' (⋃ f ∈ S, (f.support : set M))) = ⊤ :=\nbegin\n  suffices : of R M '' (⋃ f ∈ S, (f.support : set M)) = ⋃ f ∈ S, (of R M '' (f.support : set M)),\n  { rw this,\n    exact support_gen_of_gen hS },\n  simp only [set.image_Union]\nend\n\nend semiring\n\nsection ring\n\nvariables [comm_ring R] [comm_monoid M]\n\n/-- If `monoid_algebra R M` is of finite type, there there is a `G : finset M` such that its image\ngenerates, as algera, `monoid_algebra R M`. -/\nlemma exists_finset_adjoin_eq_top [h :finite_type R (monoid_algebra R M)] :\n  ∃ G : finset M, algebra.adjoin R (of R M '' G) = ⊤ :=\nbegin\n  unfreezingI { obtain ⟨S, hS⟩ := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (λ f, f.support),\n  have : (finset.bUnion S (λ f, f.support) : set M) = ⋃ f ∈ S, (f.support : set M),\n  { simp only [finset.set_bUnion_coe, finset.coe_bUnion] },\n  rw [this],\n  exact support_gen_of_gen' hS\nend\n\n/-- The image of an element `m : M` in `monoid_algebra R M` belongs the submodule generated by\n`S : set M` if and only if `m ∈ S`. -/\nlemma of_mem_span_of_iff [nontrivial R] {m : M} {S : set M} :\n  of R M m ∈ span R (of R M '' S) ↔ m ∈ S :=\nbegin\n  refine ⟨λ h, _, λ h, submodule.subset_span $ set.mem_image_of_mem (of R M) h⟩,\n  rw [of, monoid_hom.coe_mk, ← finsupp.supported_eq_span_single, finsupp.mem_supported,\n    finsupp.support_single_ne_zero (@one_ne_zero R _ (by apply_instance))] at h,\n  simpa using h\nend\n\n/--If the image of an element `m : M` in `monoid_algebra R M` belongs the submodule generated by the\nclosure of some `S : set M` then `m ∈ closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of R M m ∈ span R (submonoid.closure (of R M '' S) : set (monoid_algebra R M))) :\n  m ∈ closure S :=\nbegin\n  rw ← monoid_hom.map_mclosure at h,\n  simpa using of_mem_span_of_iff.1 h\nend\n\nend ring\n\nend span\n\nvariables [comm_monoid M]\n\n/-- If a set `S` generates a monoid `M`, then the image of `M` generates, as algebra,\n`monoid_algebra R M`. -/\nlemma mv_polynomial_aeval_of_surjective_of_closure [comm_semiring R] {S : set M}\n  (hS : closure S = ⊤) : function.surjective (mv_polynomial.aeval\n  (λ (s : S), of R M ↑s) : mv_polynomial S R → monoid_algebra R M) :=\nbegin\n  refine λ f, induction_on f (λ m, _) _ _,\n  { have : m ∈ closure S := hS.symm ▸ mem_top _,\n    refine closure_induction this (λ m hm, _) _ _,\n    { exact ⟨mv_polynomial.X ⟨m, hm⟩, mv_polynomial.aeval_X _ _⟩ },\n    { exact ⟨1, alg_hom.map_one _⟩ },\n    { rintro m₁ m₂ ⟨P₁, hP₁⟩ ⟨P₂, hP₂⟩,\n      exact ⟨P₁ * P₂, by rw [alg_hom.map_mul, hP₁, hP₂, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]⟩ } },\n  { rintro f g ⟨P, rfl⟩ ⟨Q, rfl⟩,\n    exact ⟨P + Q, alg_hom.map_add _ _ _⟩ },\n  { rintro r f ⟨P, rfl⟩,\n    exact ⟨r • P, alg_hom.map_smul _ _ _⟩ }\nend\n\n/-- If a monoid `M` is finitely generated then `monoid_algebra R M` is of finite type. -/\ninstance finite_type_of_fg [comm_ring R] [monoid.fg M] : finite_type R (monoid_algebra R M) :=\n(add_monoid_algebra.finite_type_of_fg R (additive M)).equiv (to_additive_alg_equiv R M).symm\n\n/-- A monoid `M` is finitely generated if and only if `monoid_algebra R M` is of finite type. -/\nlemma finite_type_iff_fg [comm_ring R] [nontrivial R] :\n  finite_type R (monoid_algebra R M) ↔ monoid.fg M :=\n⟨λ h, monoid.fg_iff_add_fg.2 $ add_monoid_algebra.finite_type_iff_fg.1 $ h.equiv $\n  to_additive_alg_equiv R M, λ h, @monoid_algebra.finite_type_of_fg _ _ _ _ h⟩\n\n/-- If `monoid_algebra R M` is of finite type then `M` is finitely generated. -/\nlemma fg_of_finite_type [comm_ring R] [nontrivial R] [h : finite_type R (monoid_algebra R M)] :\n  monoid.fg M :=\nfinite_type_iff_fg.1 h\n\n/-- A group `G` is finitely generated if and only if `add_monoid_algebra R G` is of finite type. -/\nlemma finite_type_iff_group_fg {G : Type*} [comm_group G] [comm_ring R] [nontrivial R] :\n  finite_type R (monoid_algebra R G) ↔ group.fg G :=\nby simpa [group.fg_iff_monoid.fg] using finite_type_iff_fg\n\nend monoid_algebra\n\nend monoid_algebra\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/ring_theory/finiteness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.46354036426202}}
{"text": "/-\nCopyright (c) 2022 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n\n! This file was ported from Lean 3 source module topology.metric_space.isometric_smul\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Topology.MetricSpace.Isometry\n\n/-!\n# Group actions by isometries\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we define two typeclasses:\n\n- `has_isometric_smul M X` says that `M` multiplicatively acts on a (pseudo extended) metric space\n  `X` by isometries;\n- `has_isometric_vadd` is an additive version of `has_isometric_smul`.\n\nWe also prove basic facts about isometric actions and define bundled isometries\n`isometry_equiv.const_mul`, `isometry_equiv.mul_left`, `isometry_equiv.mul_right`,\n`isometry_equiv.div_left`, `isometry_equiv.div_right`, and `isometry_equiv.inv`, as well as their\nadditive versions.\n\nIf `G` is a group, then `has_isometric_smul G G` means that `G` has a left-invariant metric while\n`has_isometric_smul Gᵐᵒᵖ G` means that `G` has a right-invariant metric. For a commutative group,\nthese two notions are equivalent. A group with a right-invariant metric can be also represented as a\n`normed_group`.\n-/\n\n\nopen Set\n\nopen ENNReal Pointwise\n\nuniverse u v w\n\nvariable (M : Type u) (G : Type v) (X : Type w)\n\n#print IsometricVAdd /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`isometry_vadd] [] -/\n/-- An additive action is isometric if each map `x ↦ c +ᵥ x` is an isometry. -/\nclass IsometricVAdd [PseudoEMetricSpace X] [VAdd M X] : Prop where\n  isometry_vadd : ∀ c : M, Isometry ((· +ᵥ ·) c : X → X)\n#align has_isometric_vadd IsometricVAdd\n-/\n\n#print IsometricSMul /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`isometry_smul] [] -/\n/-- A multiplicative action is isometric if each map `x ↦ c • x` is an isometry. -/\n@[to_additive]\nclass IsometricSMul [PseudoEMetricSpace X] [SMul M X] : Prop where\n  isometry_smul : ∀ c : M, Isometry ((· • ·) c : X → X)\n#align has_isometric_smul IsometricSMul\n#align has_isometric_vadd IsometricVAdd\n-/\n\nexport IsometricVAdd (isometry_vadd)\n\nexport IsometricSMul (isometry_smul)\n\n#print IsometricSMul.to_continuousConstSMul /-\n@[to_additive]\ninstance (priority := 100) IsometricSMul.to_continuousConstSMul [PseudoEMetricSpace X] [SMul M X]\n    [IsometricSMul M X] : ContinuousConstSMul M X :=\n  ⟨fun c => (isometry_smul X c).Continuous⟩\n#align has_isometric_smul.to_has_continuous_const_smul IsometricSMul.to_continuousConstSMul\n#align has_isometric_vadd.to_has_continuous_const_vadd IsometricVAdd.to_continuousConstVAdd\n-/\n\n#print IsometricSMul.opposite_of_comm /-\n@[to_additive]\ninstance (priority := 100) IsometricSMul.opposite_of_comm [PseudoEMetricSpace X] [SMul M X]\n    [SMul Mᵐᵒᵖ X] [IsCentralScalar M X] [IsometricSMul M X] : IsometricSMul Mᵐᵒᵖ X :=\n  ⟨fun c x y => by simpa only [← op_smul_eq_smul] using isometry_smul X c.unop x y⟩\n#align has_isometric_smul.opposite_of_comm IsometricSMul.opposite_of_comm\n#align has_isometric_vadd.opposite_of_comm IsometricVAdd.opposite_of_comm\n-/\n\nvariable {M G X}\n\nsection Emetric\n\nvariable [PseudoEMetricSpace X] [Group G] [MulAction G X] [IsometricSMul G X]\n\n#print edist_smul_left /-\n@[simp, to_additive]\ntheorem edist_smul_left [SMul M X] [IsometricSMul M X] (c : M) (x y : X) :\n    edist (c • x) (c • y) = edist x y :=\n  isometry_smul X c x y\n#align edist_smul_left edist_smul_left\n#align edist_vadd_left edist_vadd_left\n-/\n\n#print isometry_mul_left /-\n@[to_additive]\ntheorem isometry_mul_left [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] (a : M) :\n    Isometry ((· * ·) a) :=\n  isometry_smul M a\n#align isometry_mul_left isometry_mul_left\n#align isometry_add_left isometry_add_left\n-/\n\n#print edist_mul_left /-\n@[simp, to_additive]\ntheorem edist_mul_left [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] (a b c : M) :\n    edist (a * b) (a * c) = edist b c :=\n  isometry_mul_left a b c\n#align edist_mul_left edist_mul_left\n#align edist_add_left edist_add_left\n-/\n\n#print isometry_mul_right /-\n@[to_additive]\ntheorem isometry_mul_right [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a : M) :\n    Isometry fun x => x * a :=\n  isometry_smul M (MulOpposite.op a)\n#align isometry_mul_right isometry_mul_right\n#align isometry_add_right isometry_add_right\n-/\n\n#print edist_mul_right /-\n@[simp, to_additive]\ntheorem edist_mul_right [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :\n    edist (a * c) (b * c) = edist a b :=\n  isometry_mul_right c a b\n#align edist_mul_right edist_mul_right\n#align edist_add_right edist_add_right\n-/\n\n/- warning: edist_div_right -> edist_div_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_5 : DivInvMonoid.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M _inst_6 (Mul.toHasOppositeSMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_5))))] (a : M) (b : M) (c : M), Eq.{1} ENNReal (EDist.edist.{u1} M (PseudoEMetricSpace.toHasEdist.{u1} M _inst_6) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toHasDiv.{u1} M _inst_5)) a c) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toHasDiv.{u1} M _inst_5)) b c)) (EDist.edist.{u1} M (PseudoEMetricSpace.toHasEdist.{u1} M _inst_6) a b)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_5 : DivInvMonoid.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M _inst_6 (Mul.toHasOppositeSMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_5))))] (a : M) (b : M) (c : M), Eq.{1} ENNReal (EDist.edist.{u1} M (PseudoEMetricSpace.toEDist.{u1} M _inst_6) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toDiv.{u1} M _inst_5)) a c) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toDiv.{u1} M _inst_5)) b c)) (EDist.edist.{u1} M (PseudoEMetricSpace.toEDist.{u1} M _inst_6) a b)\nCase conversion may be inaccurate. Consider using '#align edist_div_right edist_div_rightₓ'. -/\n@[simp, to_additive]\ntheorem edist_div_right [DivInvMonoid M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :\n    edist (a / c) (b / c) = edist a b := by simp only [div_eq_mul_inv, edist_mul_right]\n#align edist_div_right edist_div_right\n#align edist_sub_right edist_sub_right\n\n/- warning: edist_inv_inv -> edist_inv_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G), Eq.{1} ENNReal (EDist.edist.{u1} G (PseudoEMetricSpace.toHasEdist.{u1} G _inst_5) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) a) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) b)) (EDist.edist.{u1} G (PseudoEMetricSpace.toHasEdist.{u1} G _inst_5) a b)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G), Eq.{1} ENNReal (EDist.edist.{u1} G (PseudoEMetricSpace.toEDist.{u1} G _inst_5) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) a) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) b)) (EDist.edist.{u1} G (PseudoEMetricSpace.toEDist.{u1} G _inst_5) a b)\nCase conversion may be inaccurate. Consider using '#align edist_inv_inv edist_inv_invₓ'. -/\n@[simp, to_additive]\ntheorem edist_inv_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G] (a b : G) :\n    edist a⁻¹ b⁻¹ = edist a b := by\n  rw [← edist_mul_left a, ← edist_mul_right _ _ b, mul_right_inv, one_mul, inv_mul_cancel_right,\n    edist_comm]\n#align edist_inv_inv edist_inv_inv\n#align edist_neg_neg edist_neg_neg\n\n/- warning: isometry_inv -> isometry_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], Isometry.{u1, u1} G G _inst_5 _inst_5 (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], Isometry.{u1, u1} G G _inst_5 _inst_5 (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align isometry_inv isometry_invₓ'. -/\n@[to_additive]\ntheorem isometry_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G] :\n    Isometry (Inv.inv : G → G) :=\n  edist_inv_inv\n#align isometry_inv isometry_inv\n#align isometry_neg isometry_neg\n\n/- warning: edist_inv -> edist_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (x : G) (y : G), Eq.{1} ENNReal (EDist.edist.{u1} G (PseudoEMetricSpace.toHasEdist.{u1} G _inst_5) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) x) y) (EDist.edist.{u1} G (PseudoEMetricSpace.toHasEdist.{u1} G _inst_5) x (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) y))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (x : G) (y : G), Eq.{1} ENNReal (EDist.edist.{u1} G (PseudoEMetricSpace.toEDist.{u1} G _inst_5) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) x) y) (EDist.edist.{u1} G (PseudoEMetricSpace.toEDist.{u1} G _inst_5) x (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) y))\nCase conversion may be inaccurate. Consider using '#align edist_inv edist_invₓ'. -/\n@[to_additive]\ntheorem edist_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G] (x y : G) :\n    edist x⁻¹ y = edist x y⁻¹ := by rw [← edist_inv_inv, inv_inv]\n#align edist_inv edist_inv\n#align edist_neg edist_neg\n\n/- warning: edist_div_left -> edist_div_left is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (c : G), Eq.{1} ENNReal (EDist.edist.{u1} G (PseudoEMetricSpace.toHasEdist.{u1} G _inst_5) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) a b) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) a c)) (EDist.edist.{u1} G (PseudoEMetricSpace.toHasEdist.{u1} G _inst_5) b c)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (c : G), Eq.{1} ENNReal (EDist.edist.{u1} G (PseudoEMetricSpace.toEDist.{u1} G _inst_5) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) a b) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) a c)) (EDist.edist.{u1} G (PseudoEMetricSpace.toEDist.{u1} G _inst_5) b c)\nCase conversion may be inaccurate. Consider using '#align edist_div_left edist_div_leftₓ'. -/\n@[simp, to_additive]\ntheorem edist_div_left [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]\n    (a b c : G) : edist (a / b) (a / c) = edist b c := by\n  rw [div_eq_mul_inv, div_eq_mul_inv, edist_mul_left, edist_inv_inv]\n#align edist_div_left edist_div_left\n#align edist_sub_left edist_sub_left\n\nnamespace IsometryEquiv\n\n#print IsometryEquiv.constSMul /-\n/-- If a group `G` acts on `X` by isometries, then `isometry_equiv.const_smul` is the isometry of\n`X` given by multiplication of a constant element of the group. -/\n@[to_additive\n      \"If an additive group `G` acts on `X` by isometries, then `isometry_equiv.const_vadd`\\nis the isometry of `X` given by addition of a constant element of the group.\",\n  simps toEquiv apply]\ndef constSMul (c : G) : X ≃ᵢ X where\n  toEquiv := MulAction.toPerm c\n  isometry_toFun := isometry_smul X c\n#align isometry_equiv.const_smul IsometryEquiv.constSMul\n#align isometry_equiv.const_vadd IsometryEquiv.constVAdd\n-/\n\n/- warning: isometry_equiv.const_smul_symm -> IsometryEquiv.constSMul_symm is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoEMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X _inst_1 (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G), Eq.{succ u2} (IsometryEquiv.{u2, u2} X X _inst_1 _inst_1) (IsometryEquiv.symm.{u2, u2} X X _inst_1 _inst_1 (IsometryEquiv.constSMul.{u1, u2} G X _inst_1 _inst_2 _inst_3 _inst_4 c)) (IsometryEquiv.constSMul.{u1, u2} G X _inst_1 _inst_2 _inst_3 _inst_4 (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) c))\nbut is expected to have type\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoEMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X _inst_1 (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G), Eq.{succ u2} (IsometryEquiv.{u2, u2} X X _inst_1 _inst_1) (IsometryEquiv.symm.{u2, u2} X X _inst_1 _inst_1 (IsometryEquiv.constSMul.{u1, u2} G X _inst_1 _inst_2 _inst_3 _inst_4 c)) (IsometryEquiv.constSMul.{u1, u2} G X _inst_1 _inst_2 _inst_3 _inst_4 (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) c))\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.const_smul_symm IsometryEquiv.constSMul_symmₓ'. -/\n@[simp, to_additive]\ntheorem constSMul_symm (c : G) : (constSMul c : X ≃ᵢ X).symm = constSMul c⁻¹ :=\n  ext fun _ => rfl\n#align isometry_equiv.const_smul_symm IsometryEquiv.constSMul_symm\n#align isometry_equiv.const_vadd_symm IsometryEquiv.constVAdd_symm\n\nvariable [PseudoEMetricSpace G]\n\n/- warning: isometry_equiv.mul_left -> IsometryEquiv.mulLeft is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.mul_left IsometryEquiv.mulLeftₓ'. -/\n/-- Multiplication `y ↦ x * y` as an `isometry_equiv`. -/\n@[to_additive \"Addition `y ↦ x + y` as an `isometry_equiv`.\", simps apply toEquiv]\ndef mulLeft [IsometricSMul G G] (c : G) : G ≃ᵢ G\n    where\n  toEquiv := Equiv.mulLeft c\n  isometry_toFun := edist_mul_left c\n#align isometry_equiv.mul_left IsometryEquiv.mulLeft\n#align isometry_equiv.add_left IsometryEquiv.addLeft\n\n/- warning: isometry_equiv.mul_left_symm -> IsometryEquiv.mulLeft_symm is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (x : G), Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.mulLeft.{u1} G _inst_2 _inst_5 _inst_6 x)) (IsometryEquiv.mulLeft.{u1} G _inst_2 _inst_5 _inst_6 (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) x))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] (x : G), Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.mulLeft.{u1} G _inst_2 _inst_5 _inst_6 x)) (IsometryEquiv.mulLeft.{u1} G _inst_2 _inst_5 _inst_6 (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) x))\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.mul_left_symm IsometryEquiv.mulLeft_symmₓ'. -/\n@[simp, to_additive]\ntheorem mulLeft_symm [IsometricSMul G G] (x : G) : (mulLeft x).symm = IsometryEquiv.mulLeft x⁻¹ :=\n  constSMul_symm x\n#align isometry_equiv.mul_left_symm IsometryEquiv.mulLeft_symm\n#align isometry_equiv.add_left_symm IsometryEquiv.addLeft_symm\n\n/- warning: isometry_equiv.mul_right -> IsometryEquiv.mulRight is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.mul_right IsometryEquiv.mulRightₓ'. -/\n--ext $ λ y, rfl\n/-- Multiplication `y ↦ y * x` as an `isometry_equiv`. -/\n@[to_additive \"Addition `y ↦ y + x` as an `isometry_equiv`.\", simps apply toEquiv]\ndef mulRight [IsometricSMul Gᵐᵒᵖ G] (c : G) : G ≃ᵢ G\n    where\n  toEquiv := Equiv.mulRight c\n  isometry_toFun a b := edist_mul_right a b c\n#align isometry_equiv.mul_right IsometryEquiv.mulRight\n#align isometry_equiv.add_right IsometryEquiv.addRight\n\n/- warning: isometry_equiv.mul_right_symm -> IsometryEquiv.mulRight_symm is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (x : G), Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.mulRight.{u1} G _inst_2 _inst_5 _inst_6 x)) (IsometryEquiv.mulRight.{u1} G _inst_2 _inst_5 _inst_6 (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) x))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (x : G), Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.mulRight.{u1} G _inst_2 _inst_5 _inst_6 x)) (IsometryEquiv.mulRight.{u1} G _inst_2 _inst_5 _inst_6 (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) x))\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.mul_right_symm IsometryEquiv.mulRight_symmₓ'. -/\n@[simp, to_additive]\ntheorem mulRight_symm [IsometricSMul Gᵐᵒᵖ G] (x : G) : (mulRight x).symm = mulRight x⁻¹ :=\n  ext fun y => rfl\n#align isometry_equiv.mul_right_symm IsometryEquiv.mulRight_symm\n#align isometry_equiv.add_right_symm IsometryEquiv.addRight_symm\n\n/- warning: isometry_equiv.div_right -> IsometryEquiv.divRight is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.div_right IsometryEquiv.divRightₓ'. -/\n/-- Division `y ↦ y / x` as an `isometry_equiv`. -/\n@[to_additive \"Subtraction `y ↦ y - x` as an `isometry_equiv`.\", simps apply toEquiv]\ndef divRight [IsometricSMul Gᵐᵒᵖ G] (c : G) : G ≃ᵢ G\n    where\n  toEquiv := Equiv.divRight c\n  isometry_toFun a b := edist_div_right a b c\n#align isometry_equiv.div_right IsometryEquiv.divRight\n#align isometry_equiv.sub_right IsometryEquiv.subRight\n\n/- warning: isometry_equiv.div_right_symm -> IsometryEquiv.divRight_symm is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (c : G), Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.divRight.{u1} G _inst_2 _inst_5 _inst_6 c)) (IsometryEquiv.mulRight.{u1} G _inst_2 _inst_5 _inst_6 c)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (c : G), Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.divRight.{u1} G _inst_2 _inst_5 _inst_6 c)) (IsometryEquiv.mulRight.{u1} G _inst_2 _inst_5 _inst_6 c)\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.div_right_symm IsometryEquiv.divRight_symmₓ'. -/\n@[simp, to_additive]\ntheorem divRight_symm [IsometricSMul Gᵐᵒᵖ G] (c : G) : (divRight c).symm = mulRight c :=\n  ext fun y => rfl\n#align isometry_equiv.div_right_symm IsometryEquiv.divRight_symm\n#align isometry_equiv.sub_right_symm IsometryEquiv.subRight_symm\n\nvariable [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]\n\n/- warning: isometry_equiv.div_left -> IsometryEquiv.divLeft is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], G -> (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5)\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.div_left IsometryEquiv.divLeftₓ'. -/\n/-- Division `y ↦ x / y` as an `isometry_equiv`. -/\n@[to_additive \"Subtraction `y ↦ x - y` as an `isometry_equiv`.\", simps apply symm_apply toEquiv]\ndef divLeft (c : G) : G ≃ᵢ G where\n  toEquiv := Equiv.divLeft c\n  isometry_toFun := edist_div_left c\n#align isometry_equiv.div_left IsometryEquiv.divLeft\n#align isometry_equiv.sub_left IsometryEquiv.subLeft\n\nvariable (G)\n\n/- warning: isometry_equiv.inv -> IsometryEquiv.inv is a dubious translation:\nlean 3 declaration is\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], IsometryEquiv.{u1, u1} G G _inst_5 _inst_5\nbut is expected to have type\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], IsometryEquiv.{u1, u1} G G _inst_5 _inst_5\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.inv IsometryEquiv.invₓ'. -/\n/-- Inversion `x ↦ x⁻¹` as an `isometry_equiv`. -/\n@[to_additive \"Negation `x ↦ -x` as an `isometry_equiv`.\", simps apply toEquiv]\ndef inv : G ≃ᵢ G where\n  toEquiv := Equiv.inv G\n  isometry_toFun := edist_inv_inv\n#align isometry_equiv.inv IsometryEquiv.inv\n#align isometry_equiv.neg IsometryEquiv.neg\n\n/- warning: isometry_equiv.inv_symm -> IsometryEquiv.inv_symm is a dubious translation:\nlean 3 declaration is\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.inv.{u1} G _inst_2 _inst_5 _inst_6 _inst_7)) (IsometryEquiv.inv.{u1} G _inst_2 _inst_5 _inst_6 _inst_7)\nbut is expected to have type\n  forall (G : Type.{u1}) [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))], Eq.{succ u1} (IsometryEquiv.{u1, u1} G G _inst_5 _inst_5) (IsometryEquiv.symm.{u1, u1} G G _inst_5 _inst_5 (IsometryEquiv.inv.{u1} G _inst_2 _inst_5 _inst_6 _inst_7)) (IsometryEquiv.inv.{u1} G _inst_2 _inst_5 _inst_6 _inst_7)\nCase conversion may be inaccurate. Consider using '#align isometry_equiv.inv_symm IsometryEquiv.inv_symmₓ'. -/\n@[simp, to_additive]\ntheorem inv_symm : (inv G).symm = inv G :=\n  rfl\n#align isometry_equiv.inv_symm IsometryEquiv.inv_symm\n#align isometry_equiv.neg_symm IsometryEquiv.neg_symm\n\nend IsometryEquiv\n\nnamespace Emetric\n\n#print EMetric.smul_ball /-\n@[simp, to_additive]\ntheorem smul_ball (c : G) (x : X) (r : ℝ≥0∞) : c • ball x r = ball (c • x) r :=\n  (IsometryEquiv.constSMul c).image_emetric_ball _ _\n#align emetric.smul_ball EMetric.smul_ball\n#align emetric.vadd_ball EMetric.vadd_ball\n-/\n\n/- warning: emetric.preimage_smul_ball -> EMetric.preimage_smul_ball is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoEMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X _inst_1 (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : ENNReal), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) c) (EMetric.ball.{u2} X _inst_1 x r)) (EMetric.ball.{u2} X _inst_1 (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) c) x) r)\nbut is expected to have type\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoEMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X _inst_1 (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : ENNReal), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1599 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1601 : X) => HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1599 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1601) c) (EMetric.ball.{u2} X _inst_1 x r)) (EMetric.ball.{u2} X _inst_1 (HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) c) x) r)\nCase conversion may be inaccurate. Consider using '#align emetric.preimage_smul_ball EMetric.preimage_smul_ballₓ'. -/\n@[simp, to_additive]\ntheorem preimage_smul_ball (c : G) (x : X) (r : ℝ≥0∞) : (· • ·) c ⁻¹' ball x r = ball (c⁻¹ • x) r :=\n  by rw [preimage_smul, smul_ball]\n#align emetric.preimage_smul_ball EMetric.preimage_smul_ball\n#align emetric.preimage_vadd_ball EMetric.preimage_vadd_ball\n\n#print EMetric.smul_closedBall /-\n@[simp, to_additive]\ntheorem smul_closedBall (c : G) (x : X) (r : ℝ≥0∞) : c • closedBall x r = closedBall (c • x) r :=\n  (IsometryEquiv.constSMul c).image_emetric_closedBall _ _\n#align emetric.smul_closed_ball EMetric.smul_closedBall\n#align emetric.vadd_closed_ball EMetric.vadd_closedBall\n-/\n\n/- warning: emetric.preimage_smul_closed_ball -> EMetric.preimage_smul_closedBall is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoEMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X _inst_1 (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : ENNReal), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) c) (EMetric.closedBall.{u2} X _inst_1 x r)) (EMetric.closedBall.{u2} X _inst_1 (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) c) x) r)\nbut is expected to have type\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoEMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X _inst_1 (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : ENNReal), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1741 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1743 : X) => HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1741 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1743) c) (EMetric.closedBall.{u2} X _inst_1 x r)) (EMetric.closedBall.{u2} X _inst_1 (HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) c) x) r)\nCase conversion may be inaccurate. Consider using '#align emetric.preimage_smul_closed_ball EMetric.preimage_smul_closedBallₓ'. -/\n@[simp, to_additive]\ntheorem preimage_smul_closedBall (c : G) (x : X) (r : ℝ≥0∞) :\n    (· • ·) c ⁻¹' closedBall x r = closedBall (c⁻¹ • x) r := by rw [preimage_smul, smul_closed_ball]\n#align emetric.preimage_smul_closed_ball EMetric.preimage_smul_closedBall\n#align emetric.preimage_vadd_closed_ball EMetric.preimage_vadd_closedBall\n\nvariable [PseudoEMetricSpace G]\n\n/- warning: emetric.preimage_mul_left_ball -> EMetric.preimage_mul_left_ball is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) a) (EMetric.ball.{u1} G _inst_5 b r)) (EMetric.ball.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) a) b) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1862 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1864 : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1862 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.1864) a) (EMetric.ball.{u1} G _inst_5 b r)) (EMetric.ball.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) a) b) r)\nCase conversion may be inaccurate. Consider using '#align emetric.preimage_mul_left_ball EMetric.preimage_mul_left_ballₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_ball [IsometricSMul G G] (a b : G) (r : ℝ≥0∞) :\n    (· * ·) a ⁻¹' ball b r = ball (a⁻¹ * b) r :=\n  preimage_smul_ball a b r\n#align emetric.preimage_mul_left_ball EMetric.preimage_mul_left_ball\n#align emetric.preimage_add_left_ball EMetric.preimage_add_left_ball\n\n/- warning: emetric.preimage_mul_right_ball -> EMetric.preimage_mul_right_ball is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (EMetric.ball.{u1} G _inst_5 b r)) (EMetric.ball.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (EMetric.ball.{u1} G _inst_5 b r)) (EMetric.ball.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nCase conversion may be inaccurate. Consider using '#align emetric.preimage_mul_right_ball EMetric.preimage_mul_right_ballₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_ball [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ≥0∞) :\n    (fun x => x * a) ⁻¹' ball b r = ball (b / a) r :=\n  by\n  rw [div_eq_mul_inv]\n  exact preimage_smul_ball (MulOpposite.op a) b r\n#align emetric.preimage_mul_right_ball EMetric.preimage_mul_right_ball\n#align emetric.preimage_add_right_ball EMetric.preimage_add_right_ball\n\n/- warning: emetric.preimage_mul_left_closed_ball -> EMetric.preimage_mul_left_closedBall is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) a) (EMetric.closedBall.{u1} G _inst_5 b r)) (EMetric.closedBall.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) a) b) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G _inst_5 (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2036 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2038 : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2036 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2038) a) (EMetric.closedBall.{u1} G _inst_5 b r)) (EMetric.closedBall.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) a) b) r)\nCase conversion may be inaccurate. Consider using '#align emetric.preimage_mul_left_closed_ball EMetric.preimage_mul_left_closedBallₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_closedBall [IsometricSMul G G] (a b : G) (r : ℝ≥0∞) :\n    (· * ·) a ⁻¹' closedBall b r = closedBall (a⁻¹ * b) r :=\n  preimage_smul_closedBall a b r\n#align emetric.preimage_mul_left_closed_ball EMetric.preimage_mul_left_closedBall\n#align emetric.preimage_add_left_closed_ball EMetric.preimage_add_left_closedBall\n\n/- warning: emetric.preimage_mul_right_closed_ball -> EMetric.preimage_mul_right_closedBall is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (EMetric.closedBall.{u1} G _inst_5 b r)) (EMetric.closedBall.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoEMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G _inst_5 (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : ENNReal), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (EMetric.closedBall.{u1} G _inst_5 b r)) (EMetric.closedBall.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nCase conversion may be inaccurate. Consider using '#align emetric.preimage_mul_right_closed_ball EMetric.preimage_mul_right_closedBallₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_closedBall [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ≥0∞) :\n    (fun x => x * a) ⁻¹' closedBall b r = closedBall (b / a) r :=\n  by\n  rw [div_eq_mul_inv]\n  exact preimage_smul_closed_ball (MulOpposite.op a) b r\n#align emetric.preimage_mul_right_closed_ball EMetric.preimage_mul_right_closedBall\n#align emetric.preimage_add_right_closed_ball EMetric.preimage_add_right_closedBall\n\nend Emetric\n\nend Emetric\n\n#print dist_smul /-\n@[simp, to_additive]\ntheorem dist_smul [PseudoMetricSpace X] [SMul M X] [IsometricSMul M X] (c : M) (x y : X) :\n    dist (c • x) (c • y) = dist x y :=\n  (isometry_smul X c).dist_eq x y\n#align dist_smul dist_smul\n#align dist_vadd dist_vadd\n-/\n\n#print nndist_smul /-\n@[simp, to_additive]\ntheorem nndist_smul [PseudoMetricSpace X] [SMul M X] [IsometricSMul M X] (c : M) (x y : X) :\n    nndist (c • x) (c • y) = nndist x y :=\n  (isometry_smul X c).nndist_eq x y\n#align nndist_smul nndist_smul\n#align nndist_vadd nndist_vadd\n-/\n\n#print dist_mul_left /-\n@[simp, to_additive]\ntheorem dist_mul_left [PseudoMetricSpace M] [Mul M] [IsometricSMul M M] (a b c : M) :\n    dist (a * b) (a * c) = dist b c :=\n  dist_smul a b c\n#align dist_mul_left dist_mul_left\n#align dist_add_left dist_add_left\n-/\n\n#print nndist_mul_left /-\n@[simp, to_additive]\ntheorem nndist_mul_left [PseudoMetricSpace M] [Mul M] [IsometricSMul M M] (a b c : M) :\n    nndist (a * b) (a * c) = nndist b c :=\n  nndist_smul a b c\n#align nndist_mul_left nndist_mul_left\n#align nndist_add_left nndist_add_left\n-/\n\n#print dist_mul_right /-\n@[simp, to_additive]\ntheorem dist_mul_right [Mul M] [PseudoMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :\n    dist (a * c) (b * c) = dist a b :=\n  dist_smul (MulOpposite.op c) a b\n#align dist_mul_right dist_mul_right\n#align dist_add_right dist_add_right\n-/\n\n#print nndist_mul_right /-\n@[simp, to_additive]\ntheorem nndist_mul_right [PseudoMetricSpace M] [Mul M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :\n    nndist (a * c) (b * c) = nndist a b :=\n  nndist_smul (MulOpposite.op c) a b\n#align nndist_mul_right nndist_mul_right\n#align nndist_add_right nndist_add_right\n-/\n\n/- warning: dist_div_right -> dist_div_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} M] [_inst_2 : PseudoMetricSpace.{u1} M] [_inst_3 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M (PseudoMetricSpace.toPseudoEMetricSpace.{u1} M _inst_2) (Mul.toHasOppositeSMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1))))] (a : M) (b : M) (c : M), Eq.{1} Real (Dist.dist.{u1} M (PseudoMetricSpace.toHasDist.{u1} M _inst_2) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toHasDiv.{u1} M _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toHasDiv.{u1} M _inst_1)) b c)) (Dist.dist.{u1} M (PseudoMetricSpace.toHasDist.{u1} M _inst_2) a b)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} M] [_inst_2 : PseudoMetricSpace.{u1} M] [_inst_3 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M (PseudoMetricSpace.toPseudoEMetricSpace.{u1} M _inst_2) (Mul.toHasOppositeSMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1))))] (a : M) (b : M) (c : M), Eq.{1} Real (Dist.dist.{u1} M (PseudoMetricSpace.toDist.{u1} M _inst_2) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toDiv.{u1} M _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toDiv.{u1} M _inst_1)) b c)) (Dist.dist.{u1} M (PseudoMetricSpace.toDist.{u1} M _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align dist_div_right dist_div_rightₓ'. -/\n@[simp, to_additive]\ntheorem dist_div_right [DivInvMonoid M] [PseudoMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :\n    dist (a / c) (b / c) = dist a b := by simp only [div_eq_mul_inv, dist_mul_right]\n#align dist_div_right dist_div_right\n#align dist_sub_right dist_sub_right\n\n/- warning: nndist_div_right -> nndist_div_right is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} M] [_inst_2 : PseudoMetricSpace.{u1} M] [_inst_3 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M (PseudoMetricSpace.toPseudoEMetricSpace.{u1} M _inst_2) (Mul.toHasOppositeSMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1))))] (a : M) (b : M) (c : M), Eq.{1} NNReal (NNDist.nndist.{u1} M (PseudoMetricSpace.toNNDist.{u1} M _inst_2) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toHasDiv.{u1} M _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toHasDiv.{u1} M _inst_1)) b c)) (NNDist.nndist.{u1} M (PseudoMetricSpace.toNNDist.{u1} M _inst_2) a b)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} M] [_inst_2 : PseudoMetricSpace.{u1} M] [_inst_3 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M (PseudoMetricSpace.toPseudoEMetricSpace.{u1} M _inst_2) (Mul.toHasOppositeSMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M _inst_1))))] (a : M) (b : M) (c : M), Eq.{1} NNReal (NNDist.nndist.{u1} M (PseudoMetricSpace.toNNDist.{u1} M _inst_2) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toDiv.{u1} M _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} M M M (instHDiv.{u1} M (DivInvMonoid.toDiv.{u1} M _inst_1)) b c)) (NNDist.nndist.{u1} M (PseudoMetricSpace.toNNDist.{u1} M _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align nndist_div_right nndist_div_rightₓ'. -/\n@[simp, to_additive]\ntheorem nndist_div_right [DivInvMonoid M] [PseudoMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] (a b c : M) :\n    nndist (a / c) (b / c) = nndist a b := by simp only [div_eq_mul_inv, nndist_mul_right]\n#align nndist_div_right nndist_div_right\n#align nndist_sub_right nndist_sub_right\n\n/- warning: dist_inv_inv -> dist_inv_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G), Eq.{1} Real (Dist.dist.{u1} G (PseudoMetricSpace.toHasDist.{u1} G _inst_2) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) a) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) b)) (Dist.dist.{u1} G (PseudoMetricSpace.toHasDist.{u1} G _inst_2) a b)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G), Eq.{1} Real (Dist.dist.{u1} G (PseudoMetricSpace.toDist.{u1} G _inst_2) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))) a) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))) b)) (Dist.dist.{u1} G (PseudoMetricSpace.toDist.{u1} G _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align dist_inv_inv dist_inv_invₓ'. -/\n@[simp, to_additive]\ntheorem dist_inv_inv [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]\n    (a b : G) : dist a⁻¹ b⁻¹ = dist a b :=\n  (IsometryEquiv.inv G).dist_eq a b\n#align dist_inv_inv dist_inv_inv\n#align dist_neg_neg dist_neg_neg\n\n/- warning: nndist_inv_inv -> nndist_inv_inv is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G), Eq.{1} NNReal (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) a) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) b)) (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) a b)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G), Eq.{1} NNReal (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))) a) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1)))) b)) (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align nndist_inv_inv nndist_inv_invₓ'. -/\n@[simp, to_additive]\ntheorem nndist_inv_inv [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]\n    (a b : G) : nndist a⁻¹ b⁻¹ = nndist a b :=\n  (IsometryEquiv.inv G).nndist_eq a b\n#align nndist_inv_inv nndist_inv_inv\n#align nndist_neg_neg nndist_neg_neg\n\n/- warning: dist_div_left -> dist_div_left is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G) (c : G), Eq.{1} Real (Dist.dist.{u1} G (PseudoMetricSpace.toHasDist.{u1} G _inst_2) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a b) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a c)) (Dist.dist.{u1} G (PseudoMetricSpace.toHasDist.{u1} G _inst_2) b c)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G) (c : G), Eq.{1} Real (Dist.dist.{u1} G (PseudoMetricSpace.toDist.{u1} G _inst_2) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a b) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a c)) (Dist.dist.{u1} G (PseudoMetricSpace.toDist.{u1} G _inst_2) b c)\nCase conversion may be inaccurate. Consider using '#align dist_div_left dist_div_leftₓ'. -/\n@[simp, to_additive]\ntheorem dist_div_left [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]\n    (a b c : G) : dist (a / b) (a / c) = dist b c := by simp [div_eq_mul_inv]\n#align dist_div_left dist_div_left\n#align dist_sub_left dist_sub_left\n\n/- warning: nndist_div_left -> nndist_div_left is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G) (c : G), Eq.{1} NNReal (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a b) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a c)) (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) b c)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] [_inst_2 : PseudoMetricSpace.{u1} G] [_inst_3 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))] [_inst_4 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_2) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))] (a : G) (b : G) (c : G), Eq.{1} NNReal (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a b) (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) a c)) (NNDist.nndist.{u1} G (PseudoMetricSpace.toNNDist.{u1} G _inst_2) b c)\nCase conversion may be inaccurate. Consider using '#align nndist_div_left nndist_div_leftₓ'. -/\n@[simp, to_additive]\ntheorem nndist_div_left [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul Gᵐᵒᵖ G]\n    (a b c : G) : nndist (a / b) (a / c) = nndist b c := by simp [div_eq_mul_inv]\n#align nndist_div_left nndist_div_left\n#align nndist_sub_left nndist_sub_left\n\nnamespace Metric\n\nvariable [PseudoMetricSpace X] [Group G] [MulAction G X] [IsometricSMul G X]\n\n#print Metric.smul_ball /-\n@[simp, to_additive]\ntheorem smul_ball (c : G) (x : X) (r : ℝ) : c • ball x r = ball (c • x) r :=\n  (IsometryEquiv.constSMul c).image_ball _ _\n#align metric.smul_ball Metric.smul_ball\n#align metric.vadd_ball Metric.vadd_ball\n-/\n\n/- warning: metric.preimage_smul_ball -> Metric.preimage_smul_ball is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X (PseudoMetricSpace.toPseudoEMetricSpace.{u2} X _inst_1) (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : Real), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) c) (Metric.ball.{u2} X _inst_1 x r)) (Metric.ball.{u2} X _inst_1 (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) c) x) r)\nbut is expected to have type\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X (PseudoMetricSpace.toPseudoEMetricSpace.{u2} X _inst_1) (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : Real), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2854 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2856 : X) => HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2854 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2856) c) (Metric.ball.{u2} X _inst_1 x r)) (Metric.ball.{u2} X _inst_1 (HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) c) x) r)\nCase conversion may be inaccurate. Consider using '#align metric.preimage_smul_ball Metric.preimage_smul_ballₓ'. -/\n@[simp, to_additive]\ntheorem preimage_smul_ball (c : G) (x : X) (r : ℝ) : (· • ·) c ⁻¹' ball x r = ball (c⁻¹ • x) r := by\n  rw [preimage_smul, smul_ball]\n#align metric.preimage_smul_ball Metric.preimage_smul_ball\n#align metric.preimage_vadd_ball Metric.preimage_vadd_ball\n\n#print Metric.smul_closedBall /-\n@[simp, to_additive]\ntheorem smul_closedBall (c : G) (x : X) (r : ℝ) : c • closedBall x r = closedBall (c • x) r :=\n  (IsometryEquiv.constSMul c).image_closedBall _ _\n#align metric.smul_closed_ball Metric.smul_closedBall\n#align metric.vadd_closed_ball Metric.vadd_closedBall\n-/\n\n/- warning: metric.preimage_smul_closed_ball -> Metric.preimage_smul_closedBall is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X (PseudoMetricSpace.toPseudoEMetricSpace.{u2} X _inst_1) (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : Real), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) c) (Metric.closedBall.{u2} X _inst_1 x r)) (Metric.closedBall.{u2} X _inst_1 (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) c) x) r)\nbut is expected to have type\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X (PseudoMetricSpace.toPseudoEMetricSpace.{u2} X _inst_1) (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : Real), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2996 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2998 : X) => HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2996 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.2998) c) (Metric.closedBall.{u2} X _inst_1 x r)) (Metric.closedBall.{u2} X _inst_1 (HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) c) x) r)\nCase conversion may be inaccurate. Consider using '#align metric.preimage_smul_closed_ball Metric.preimage_smul_closedBallₓ'. -/\n@[simp, to_additive]\ntheorem preimage_smul_closedBall (c : G) (x : X) (r : ℝ) :\n    (· • ·) c ⁻¹' closedBall x r = closedBall (c⁻¹ • x) r := by rw [preimage_smul, smul_closed_ball]\n#align metric.preimage_smul_closed_ball Metric.preimage_smul_closedBall\n#align metric.preimage_vadd_closed_ball Metric.preimage_vadd_closedBall\n\n#print Metric.smul_sphere /-\n@[simp, to_additive]\ntheorem smul_sphere (c : G) (x : X) (r : ℝ) : c • sphere x r = sphere (c • x) r :=\n  (IsometryEquiv.constSMul c).image_sphere _ _\n#align metric.smul_sphere Metric.smul_sphere\n#align metric.vadd_sphere Metric.vadd_sphere\n-/\n\n/- warning: metric.preimage_smul_sphere -> Metric.preimage_smul_sphere is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X (PseudoMetricSpace.toPseudoEMetricSpace.{u2} X _inst_1) (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : Real), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) c) (Metric.sphere.{u2} X _inst_1 x r)) (Metric.sphere.{u2} X _inst_1 (SMul.smul.{u1, u2} G X (MulAction.toHasSmul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) c) x) r)\nbut is expected to have type\n  forall {G : Type.{u1}} {X : Type.{u2}} [_inst_1 : PseudoMetricSpace.{u2} X] [_inst_2 : Group.{u1} G] [_inst_3 : MulAction.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))] [_inst_4 : IsometricSMul.{u1, u2} G X (PseudoMetricSpace.toPseudoEMetricSpace.{u2} X _inst_1) (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)] (c : G) (x : X) (r : Real), Eq.{succ u2} (Set.{u2} X) (Set.preimage.{u2, u2} X X ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3138 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3140 : X) => HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3138 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3140) c) (Metric.sphere.{u2} X _inst_1 x r)) (Metric.sphere.{u2} X _inst_1 (HSMul.hSMul.{u1, u2, u2} G X X (instHSMul.{u1, u2} G X (MulAction.toSMul.{u1, u2} G X (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) _inst_3)) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) c) x) r)\nCase conversion may be inaccurate. Consider using '#align metric.preimage_smul_sphere Metric.preimage_smul_sphereₓ'. -/\n@[simp, to_additive]\ntheorem preimage_smul_sphere (c : G) (x : X) (r : ℝ) :\n    (· • ·) c ⁻¹' sphere x r = sphere (c⁻¹ • x) r := by rw [preimage_smul, smul_sphere]\n#align metric.preimage_smul_sphere Metric.preimage_smul_sphere\n#align metric.preimage_vadd_sphere Metric.preimage_vadd_sphere\n\nvariable [PseudoMetricSpace G]\n\n/- warning: metric.preimage_mul_left_ball -> Metric.preimage_mul_left_ball is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) a) (Metric.ball.{u1} G _inst_5 b r)) (Metric.ball.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) a) b) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3259 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3261 : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3259 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3261) a) (Metric.ball.{u1} G _inst_5 b r)) (Metric.ball.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) a) b) r)\nCase conversion may be inaccurate. Consider using '#align metric.preimage_mul_left_ball Metric.preimage_mul_left_ballₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_ball [IsometricSMul G G] (a b : G) (r : ℝ) :\n    (· * ·) a ⁻¹' ball b r = ball (a⁻¹ * b) r :=\n  preimage_smul_ball a b r\n#align metric.preimage_mul_left_ball Metric.preimage_mul_left_ball\n#align metric.preimage_add_left_ball Metric.preimage_add_left_ball\n\n/- warning: metric.preimage_mul_right_ball -> Metric.preimage_mul_right_ball is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (Metric.ball.{u1} G _inst_5 b r)) (Metric.ball.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (Metric.ball.{u1} G _inst_5 b r)) (Metric.ball.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nCase conversion may be inaccurate. Consider using '#align metric.preimage_mul_right_ball Metric.preimage_mul_right_ballₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_ball [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ) :\n    (fun x => x * a) ⁻¹' ball b r = ball (b / a) r :=\n  by\n  rw [div_eq_mul_inv]\n  exact preimage_smul_ball (MulOpposite.op a) b r\n#align metric.preimage_mul_right_ball Metric.preimage_mul_right_ball\n#align metric.preimage_add_right_ball Metric.preimage_add_right_ball\n\n/- warning: metric.preimage_mul_left_closed_ball -> Metric.preimage_mul_left_closedBall is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (Mul.toSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) a) (Metric.closedBall.{u1} G _inst_5 b r)) (Metric.closedBall.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (DivInvMonoid.toHasInv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) a) b) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} G G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (MulAction.toSMul.{u1, u1} G G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)) (Monoid.toMulAction.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G ((fun (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3433 : G) (x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3435 : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3433 x._@.Mathlib.Topology.MetricSpace.IsometricSMul._hyg.3435) a) (Metric.closedBall.{u1} G _inst_5 b r)) (Metric.closedBall.{u1} G _inst_5 (HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) (Inv.inv.{u1} G (InvOneClass.toInv.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_2)))) a) b) r)\nCase conversion may be inaccurate. Consider using '#align metric.preimage_mul_left_closed_ball Metric.preimage_mul_left_closedBallₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_closedBall [IsometricSMul G G] (a b : G) (r : ℝ) :\n    (· * ·) a ⁻¹' closedBall b r = closedBall (a⁻¹ * b) r :=\n  preimage_smul_closedBall a b r\n#align metric.preimage_mul_left_closed_ball Metric.preimage_mul_left_closedBall\n#align metric.preimage_add_left_closed_ball Metric.preimage_add_left_closedBall\n\n/- warning: metric.preimage_mul_right_closed_ball -> Metric.preimage_mul_right_closedBall is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (Metric.closedBall.{u1} G _inst_5 b r)) (Metric.closedBall.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toHasDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_2 : Group.{u1} G] [_inst_5 : PseudoMetricSpace.{u1} G] [_inst_6 : IsometricSMul.{u1, u1} (MulOpposite.{u1} G) G (PseudoMetricSpace.toPseudoEMetricSpace.{u1} G _inst_5) (Mul.toHasOppositeSMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2)))))] (a : G) (b : G) (r : Real), Eq.{succ u1} (Set.{u1} G) (Set.preimage.{u1, u1} G G (fun (x : G) => HMul.hMul.{u1, u1, u1} G G G (instHMul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))))) x a) (Metric.closedBall.{u1} G _inst_5 b r)) (Metric.closedBall.{u1} G _inst_5 (HDiv.hDiv.{u1, u1, u1} G G G (instHDiv.{u1} G (DivInvMonoid.toDiv.{u1} G (Group.toDivInvMonoid.{u1} G _inst_2))) b a) r)\nCase conversion may be inaccurate. Consider using '#align metric.preimage_mul_right_closed_ball Metric.preimage_mul_right_closedBallₓ'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_closedBall [IsometricSMul Gᵐᵒᵖ G] (a b : G) (r : ℝ) :\n    (fun x => x * a) ⁻¹' closedBall b r = closedBall (b / a) r :=\n  by\n  rw [div_eq_mul_inv]\n  exact preimage_smul_closed_ball (MulOpposite.op a) b r\n#align metric.preimage_mul_right_closed_ball Metric.preimage_mul_right_closedBall\n#align metric.preimage_add_right_closed_ball Metric.preimage_add_right_closedBall\n\nend Metric\n\nsection Instances\n\nvariable {Y : Type _} [PseudoEMetricSpace X] [PseudoEMetricSpace Y] [SMul M X] [IsometricSMul M X]\n\n@[to_additive]\ninstance [SMul M Y] [IsometricSMul M Y] : IsometricSMul M (X × Y) :=\n  ⟨fun c => (isometry_smul X c).Prod_map (isometry_smul Y c)⟩\n\n#print Prod.isometricSMul' /-\n@[to_additive]\ninstance Prod.isometricSMul' {N} [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] [Mul N]\n    [PseudoEMetricSpace N] [IsometricSMul N N] : IsometricSMul (M × N) (M × N) :=\n  ⟨fun c => (isometry_smul M c.1).Prod_map (isometry_smul N c.2)⟩\n#align prod.has_isometric_smul' Prod.isometricSMul'\n#align prod.has_isometric_vadd' Prod.isometricVAdd'\n-/\n\n#print Prod.isometricSMul'' /-\n@[to_additive]\ninstance Prod.isometricSMul'' {N} [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] [Mul N]\n    [PseudoEMetricSpace N] [IsometricSMul Nᵐᵒᵖ N] : IsometricSMul (M × N)ᵐᵒᵖ (M × N) :=\n  ⟨fun c => (isometry_mul_right c.unop.1).Prod_map (isometry_mul_right c.unop.2)⟩\n#align prod.has_isometric_smul'' Prod.isometricSMul''\n#align prod.has_isometric_vadd'' Prod.isometricVAdd''\n-/\n\n#print Units.isometricSMul /-\n@[to_additive]\ninstance Units.isometricSMul [Monoid M] : IsometricSMul Mˣ X :=\n  ⟨fun c => by convert isometry_smul X (c : M)⟩\n#align units.has_isometric_smul Units.isometricSMul\n#align add_units.has_isometric_vadd AddUnits.isometricVAdd\n-/\n\n@[to_additive]\ninstance : IsometricSMul M Xᵐᵒᵖ :=\n  ⟨fun c x y => by simpa only using edist_smul_left c x.unop y.unop⟩\n\n#print ULift.isometricSMul /-\n@[to_additive]\ninstance ULift.isometricSMul : IsometricSMul (ULift M) X :=\n  ⟨fun c => by simpa only using isometry_smul X c.down⟩\n#align ulift.has_isometric_smul ULift.isometricSMul\n#align ulift.has_isometric_vadd ULift.isometricVAdd\n-/\n\n#print ULift.isometricSMul' /-\n@[to_additive]\ninstance ULift.isometricSMul' : IsometricSMul M (ULift X) :=\n  ⟨fun c x y => by simpa only using edist_smul_left c x.1 y.1⟩\n#align ulift.has_isometric_smul' ULift.isometricSMul'\n#align ulift.has_isometric_vadd' ULift.isometricVAdd'\n-/\n\n@[to_additive]\ninstance {ι} {X : ι → Type _} [Fintype ι] [∀ i, SMul M (X i)] [∀ i, PseudoEMetricSpace (X i)]\n    [∀ i, IsometricSMul M (X i)] : IsometricSMul M (∀ i, X i) :=\n  ⟨fun c => isometry_dcomp (fun i => (· • ·) c) fun i => isometry_smul (X i) c⟩\n\n#print Pi.isometricSMul' /-\n@[to_additive]\ninstance Pi.isometricSMul' {ι} {M X : ι → Type _} [Fintype ι] [∀ i, SMul (M i) (X i)]\n    [∀ i, PseudoEMetricSpace (X i)] [∀ i, IsometricSMul (M i) (X i)] :\n    IsometricSMul (∀ i, M i) (∀ i, X i) :=\n  ⟨fun c => isometry_dcomp (fun i => (· • ·) (c i)) fun i => isometry_smul _ _⟩\n#align pi.has_isometric_smul' Pi.isometricSMul'\n#align pi.has_isometric_vadd' Pi.isometricVAdd'\n-/\n\n#print Pi.isometricSMul'' /-\n@[to_additive]\ninstance Pi.isometricSMul'' {ι} {M : ι → Type _} [Fintype ι] [∀ i, Mul (M i)]\n    [∀ i, PseudoEMetricSpace (M i)] [∀ i, IsometricSMul (M i)ᵐᵒᵖ (M i)] :\n    IsometricSMul (∀ i, M i)ᵐᵒᵖ (∀ i, M i) :=\n  ⟨fun c => isometry_dcomp (fun i (x : M i) => x * c.unop i) fun i => isometry_mul_right _⟩\n#align pi.has_isometric_smul'' Pi.isometricSMul''\n#align pi.has_isometric_vadd'' Pi.isometricVAdd''\n-/\n\n#print Additive.isometricVAdd /-\ninstance Additive.isometricVAdd : IsometricVAdd (Additive M) X :=\n  ⟨fun c => isometry_smul X c.toMul⟩\n#align additive.has_isometric_vadd Additive.isometricVAdd\n-/\n\n/- warning: additive.has_isometric_vadd' -> Additive.isometricVAdd' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_5 : Mul.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricSMul.{u1, u1} M M _inst_6 (Mul.toSMul.{u1} M _inst_5)], IsometricVAdd.{u1, u1} (Additive.{u1} M) (Additive.{u1} M) (Additive.pseudoEmetricSpace.{u1} M _inst_6) (Add.toVAdd.{u1} (Additive.{u1} M) (Additive.hasAdd.{u1} M _inst_5))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_5 : Mul.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricSMul.{u1, u1} M M _inst_6 (Mul.toSMul.{u1} M _inst_5)], IsometricVAdd.{u1, u1} (Additive.{u1} M) (Additive.{u1} M) (instPseudoEMetricSpaceAdditive.{u1} M _inst_6) (Add.toVAdd.{u1} (Additive.{u1} M) (Additive.add.{u1} M _inst_5))\nCase conversion may be inaccurate. Consider using '#align additive.has_isometric_vadd' Additive.isometricVAdd'ₓ'. -/\ninstance Additive.isometricVAdd' [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] :\n    IsometricVAdd (Additive M) (Additive M) :=\n  ⟨fun c x y => edist_smul_left c.toMul x.toMul y.toMul⟩\n#align additive.has_isometric_vadd' Additive.isometricVAdd'\n\n/- warning: additive.has_isometric_vadd'' -> Additive.isometricVAdd'' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_5 : Mul.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M _inst_6 (Mul.toHasOppositeSMul.{u1} M _inst_5)], IsometricVAdd.{u1, u1} (AddOpposite.{u1} (Additive.{u1} M)) (Additive.{u1} M) (Additive.pseudoEmetricSpace.{u1} M _inst_6) (Add.toHasOppositeVAdd.{u1} (Additive.{u1} M) (Additive.hasAdd.{u1} M _inst_5))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_5 : Mul.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricSMul.{u1, u1} (MulOpposite.{u1} M) M _inst_6 (Mul.toHasOppositeSMul.{u1} M _inst_5)], IsometricVAdd.{u1, u1} (AddOpposite.{u1} (Additive.{u1} M)) (Additive.{u1} M) (instPseudoEMetricSpaceAdditive.{u1} M _inst_6) (Add.toHasOppositeVAdd.{u1} (Additive.{u1} M) (Additive.add.{u1} M _inst_5))\nCase conversion may be inaccurate. Consider using '#align additive.has_isometric_vadd'' Additive.isometricVAdd''ₓ'. -/\ninstance Additive.isometricVAdd'' [Mul M] [PseudoEMetricSpace M] [IsometricSMul Mᵐᵒᵖ M] :\n    IsometricVAdd (Additive M)ᵃᵒᵖ (Additive M) :=\n  ⟨fun c x y => edist_smul_left (MulOpposite.op c.unop.toMul) x.toMul y.toMul⟩\n#align additive.has_isometric_vadd'' Additive.isometricVAdd''\n\n#print Multiplicative.isometricSMul /-\ninstance Multiplicative.isometricSMul {M X} [VAdd M X] [PseudoEMetricSpace X] [IsometricVAdd M X] :\n    IsometricSMul (Multiplicative M) X :=\n  ⟨fun c => isometry_vadd X c.toAdd⟩\n#align multiplicative.has_isometric_smul Multiplicative.isometricSMul\n-/\n\n/- warning: multiplicative.has_isometric_smul' -> Multiplicative.isometricSMul' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_5 : Add.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricVAdd.{u1, u1} M M _inst_6 (Add.toVAdd.{u1} M _inst_5)], IsometricSMul.{u1, u1} (Multiplicative.{u1} M) (Multiplicative.{u1} M) (Multiplicative.pseudoEmetricSpace.{u1} M _inst_6) (Mul.toSMul.{u1} (Multiplicative.{u1} M) (Multiplicative.hasMul.{u1} M _inst_5))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_5 : Add.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricVAdd.{u1, u1} M M _inst_6 (Add.toVAdd.{u1} M _inst_5)], IsometricSMul.{u1, u1} (Multiplicative.{u1} M) (Multiplicative.{u1} M) (instPseudoEMetricSpaceMultiplicative.{u1} M _inst_6) (Mul.toSMul.{u1} (Multiplicative.{u1} M) (Multiplicative.mul.{u1} M _inst_5))\nCase conversion may be inaccurate. Consider using '#align multiplicative.has_isometric_smul' Multiplicative.isometricSMul'ₓ'. -/\ninstance Multiplicative.isometricSMul' [Add M] [PseudoEMetricSpace M] [IsometricVAdd M M] :\n    IsometricSMul (Multiplicative M) (Multiplicative M) :=\n  ⟨fun c x y => edist_vadd_left c.toAdd x.toAdd y.toAdd⟩\n#align multiplicative.has_isometric_smul' Multiplicative.isometricSMul'\n\n/- warning: multiplicative.has_isometric_vadd'' -> Multiplicative.isometricVAdd'' is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_5 : Add.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricVAdd.{u1, u1} (AddOpposite.{u1} M) M _inst_6 (Add.toHasOppositeVAdd.{u1} M _inst_5)], IsometricSMul.{u1, u1} (MulOpposite.{u1} (Multiplicative.{u1} M)) (Multiplicative.{u1} M) (Multiplicative.pseudoEmetricSpace.{u1} M _inst_6) (Mul.toHasOppositeSMul.{u1} (Multiplicative.{u1} M) (Multiplicative.hasMul.{u1} M _inst_5))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_5 : Add.{u1} M] [_inst_6 : PseudoEMetricSpace.{u1} M] [_inst_7 : IsometricVAdd.{u1, u1} (AddOpposite.{u1} M) M _inst_6 (Add.toHasOppositeVAdd.{u1} M _inst_5)], IsometricSMul.{u1, u1} (MulOpposite.{u1} (Multiplicative.{u1} M)) (Multiplicative.{u1} M) (instPseudoEMetricSpaceMultiplicative.{u1} M _inst_6) (Mul.toHasOppositeSMul.{u1} (Multiplicative.{u1} M) (Multiplicative.mul.{u1} M _inst_5))\nCase conversion may be inaccurate. Consider using '#align multiplicative.has_isometric_vadd'' Multiplicative.isometricVAdd''ₓ'. -/\ninstance Multiplicative.isometricVAdd'' [Add M] [PseudoEMetricSpace M] [IsometricVAdd Mᵃᵒᵖ M] :\n    IsometricSMul (Multiplicative M)ᵐᵒᵖ (Multiplicative M) :=\n  ⟨fun c x y => edist_vadd_left (AddOpposite.op c.unop.toAdd) x.toAdd y.toAdd⟩\n#align multiplicative.has_isometric_vadd'' Multiplicative.isometricVAdd''\n\nend Instances\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/MetricSpace/IsometricSmul.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6757646075489391, "lm_q1q2_score": 0.4635403642620199}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.finset.basic\nimport Mathlib.data.multiset.fold\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# The fold operation for a commutative associative operation over a finset.\n-/\n\nnamespace finset\n\n\n/-! ### fold -/\n\n/-- `fold op b f s` folds the commutative associative operation `op` over the\n  `f`-image of `s`, i.e. `fold (+) b f {1,2,3} = `f 1 + f 2 + f 3 + b`. -/\ndef fold {α : Type u_1} {β : Type u_2} (op : β → β → β) [hc : is_commutative β op] [ha : is_associative β op] (b : β) (f : α → β) (s : finset α) : β :=\n  multiset.fold op b (multiset.map f (val s))\n\n@[simp] theorem fold_empty {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} : fold op b f ∅ = b :=\n  rfl\n\n@[simp] theorem fold_insert {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {s : finset α} {a : α} [DecidableEq α] (h : ¬a ∈ s) : fold op b f (insert a s) = op (f a) (fold op b f s) := sorry\n\n@[simp] theorem fold_singleton {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {a : α} : fold op b f (singleton a) = op (f a) b :=\n  rfl\n\n@[simp] theorem fold_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {g : γ ↪ α} {s : finset γ} : fold op b f (map g s) = fold op b (f ∘ ⇑g) s := sorry\n\n@[simp] theorem fold_image {α : Type u_1} {β : Type u_2} {γ : Type u_3} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} [DecidableEq α] {g : γ → α} {s : finset γ} (H : ∀ (x : γ), x ∈ s → ∀ (y : γ), y ∈ s → g x = g y → x = y) : fold op b f (image g s) = fold op b (f ∘ g) s := sorry\n\ntheorem fold_congr {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {s : finset α} {g : α → β} (H : ∀ (x : α), x ∈ s → f x = g x) : fold op b f s = fold op b g s := sorry\n\ntheorem fold_op_distrib {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {s : finset α} {f : α → β} {g : α → β} {b₁ : β} {b₂ : β} : fold op (op b₁ b₂) (fun (x : α) => op (f x) (g x)) s = op (fold op b₁ f s) (fold op b₂ g s) := sorry\n\ntheorem fold_hom {α : Type u_1} {β : Type u_2} {γ : Type u_3} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {s : finset α} {op' : γ → γ → γ} [is_commutative γ op'] [is_associative γ op'] {m : β → γ} (hm : ∀ (x y : β), m (op x y) = op' (m x) (m y)) : fold op' (m b) (fun (x : α) => m (f x)) s = m (fold op b f s) := sorry\n\ntheorem fold_union_inter {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {b₁ : β} {b₂ : β} : op (fold op b₁ f (s₁ ∪ s₂)) (fold op b₂ f (s₁ ∩ s₂)) = op (fold op b₂ f s₁) (fold op b₁ f s₂) := sorry\n\n@[simp] theorem fold_insert_idem {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {s : finset α} {a : α} [DecidableEq α] [hi : is_idempotent β op] : fold op b f (insert a s) = op (f a) (fold op b f s) := sorry\n\ntheorem fold_op_rel_iff_and {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {s : finset α} {r : β → β → Prop} (hr : ∀ {x y z : β}, r x (op y z) ↔ r x y ∧ r x z) {c : β} : r c (fold op b f s) ↔ r c b ∧ ∀ (x : α), x ∈ s → r c (f x) := sorry\n\ntheorem fold_op_rel_iff_or {α : Type u_1} {β : Type u_2} {op : β → β → β} [hc : is_commutative β op] [ha : is_associative β op] {f : α → β} {b : β} {s : finset α} {r : β → β → Prop} (hr : ∀ {x y z : β}, r x (op y z) ↔ r x y ∨ r x z) {c : β} : r c (fold op b f s) ↔ r c b ∨ ∃ (x : α), ∃ (H : x ∈ s), r c (f x) := sorry\n\n@[simp] theorem fold_union_empty_singleton {α : Type u_1} [DecidableEq α] (s : finset α) : fold has_union.union ∅ singleton s = s := sorry\n\n@[simp] theorem fold_sup_bot_singleton {α : Type u_1} [DecidableEq α] (s : finset α) : fold has_sup.sup ⊥ singleton s = s :=\n  fold_union_empty_singleton s\n\ntheorem le_fold_min {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : c ≤ fold min b f s ↔ c ≤ b ∧ ∀ (x : α), x ∈ s → c ≤ f x :=\n  fold_op_rel_iff_and fun (x y z : β) => le_min_iff\n\ntheorem fold_min_le {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : fold min b f s ≤ c ↔ b ≤ c ∨ ∃ (x : α), ∃ (H : x ∈ s), f x ≤ c :=\n  id (fold_op_rel_iff_or fun (x y z : β) => id min_le_iff)\n\ntheorem lt_fold_min {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : c < fold min b f s ↔ c < b ∧ ∀ (x : α), x ∈ s → c < f x :=\n  fold_op_rel_iff_and fun (x y z : β) => lt_min_iff\n\ntheorem fold_min_lt {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : fold min b f s < c ↔ b < c ∨ ∃ (x : α), ∃ (H : x ∈ s), f x < c :=\n  id (fold_op_rel_iff_or fun (x y z : β) => id min_lt_iff)\n\ntheorem fold_max_le {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : fold max b f s ≤ c ↔ b ≤ c ∧ ∀ (x : α), x ∈ s → f x ≤ c :=\n  id (fold_op_rel_iff_and fun (x y z : β) => id max_le_iff)\n\ntheorem le_fold_max {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : c ≤ fold max b f s ↔ c ≤ b ∨ ∃ (x : α), ∃ (H : x ∈ s), c ≤ f x :=\n  fold_op_rel_iff_or fun (x y z : β) => le_max_iff\n\ntheorem fold_max_lt {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : fold max b f s < c ↔ b < c ∧ ∀ (x : α), x ∈ s → f x < c :=\n  id (fold_op_rel_iff_and fun (x y z : β) => id max_lt_iff)\n\ntheorem lt_fold_max {α : Type u_1} {β : Type u_2} {f : α → β} {b : β} {s : finset α} [linear_order β] (c : β) : c < fold max b f s ↔ c < b ∨ ∃ (x : α), ∃ (H : x ∈ s), c < f x :=\n  fold_op_rel_iff_or fun (x y z : β) => lt_max_iff\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/finset/fold.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6757645879592642, "lm_q1q2_score": 0.46354035082449313}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Riccardo Brasca, Johan Commelin, Scott Morrison\n-/\nimport analysis.normed.group.SemiNormedGroup\nimport analysis.normed.group.quotient\nimport category_theory.limits.shapes.kernels\n\n/-!\n# Kernels and cokernels in SemiNormedGroup₁ and SemiNormedGroup\n\nWe show that `SemiNormedGroup₁` has cokernels\n(for which of course the `cokernel.π f` maps are norm non-increasing),\nas well as the easier result that `SemiNormedGroup` has cokernels. We also show that\n`SemiNormedGroup` has kernels.\n\nSo far, I don't see a way to state nicely what we really want:\n`SemiNormedGroup` has cokernels, and `cokernel.π f` is norm non-increasing.\nThe problem is that the limits API doesn't promise you any particular model of the cokernel,\nand in `SemiNormedGroup` one can always take a cokernel and rescale its norm\n(and hence making `cokernel.π f` arbitrarily large in norm), obtaining another categorical cokernel.\n\n-/\n\nopen category_theory category_theory.limits\n\nuniverse u\n\nnamespace SemiNormedGroup₁\n\nnoncomputable theory\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup₁`. -/\ndef cokernel_cocone {X Y : SemiNormedGroup₁.{u}} (f : X ⟶ Y) : cofork f 0 :=\ncofork.of_π\n  (@SemiNormedGroup₁.mk_hom\n    _ (SemiNormedGroup.of (Y ⧸ (normed_add_group_hom.range f.1)))\n    f.1.range.normed_mk\n    (normed_add_group_hom.is_quotient_quotient _).norm_le)\n  begin\n    ext,\n    simp only [comp_apply, limits.zero_comp, normed_add_group_hom.zero_apply,\n      SemiNormedGroup₁.mk_hom_apply, SemiNormedGroup₁.zero_apply, ←normed_add_group_hom.mem_ker,\n      f.1.range.ker_normed_mk, f.1.mem_range],\n    use x,\n    refl,\n  end\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup₁`. -/\ndef cokernel_lift {X Y : SemiNormedGroup₁.{u}} (f : X ⟶ Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X ⟶ s.X :=\nbegin\n  fsplit,\n  -- The lift itself:\n  { apply normed_add_group_hom.lift _ s.π.1,\n    rintro _ ⟨b, rfl⟩,\n    change (f ≫ s.π) b = 0,\n    simp, },\n  -- The lift has norm at most one:\n  exact normed_add_group_hom.lift_norm_noninc _ _ _ s.π.2,\nend\n\ninstance : has_cokernels SemiNormedGroup₁.{u} :=\n{ has_colimit := λ X Y f, has_colimit.mk\n  { cocone := cokernel_cocone f,\n    is_colimit := is_colimit_aux _\n      (cokernel_lift f)\n      (λ s, begin\n        ext,\n        apply normed_add_group_hom.lift_mk f.1.range,\n        rintro _ ⟨b, rfl⟩,\n        change (f ≫ s.π) b = 0,\n        simp,\n      end)\n      (λ s m w, subtype.eq\n        (normed_add_group_hom.lift_unique f.1.range _ _ _ (congr_arg subtype.val w : _))), } }\n\n-- Sanity check\nexample : has_cokernels SemiNormedGroup₁ := by apply_instance\n\nend SemiNormedGroup₁\n\nnamespace SemiNormedGroup\n\nsection equalizers_and_kernels\n\n/-- The equalizer cone for a parallel pair of morphisms of seminormed groups. -/\ndef fork {V W : SemiNormedGroup.{u}} (f g : V ⟶ W) : fork f g :=\n@fork.of_ι _ _ _ _ _ _ (of (f - g).ker) (normed_add_group_hom.incl (f - g).ker) $\nbegin\n  ext v,\n  have : v.1 ∈ (f - g).ker := v.2,\n  simpa only [normed_add_group_hom.incl_apply, pi.zero_apply, coe_comp,\n    normed_add_group_hom.coe_zero, subtype.val_eq_coe, normed_add_group_hom.mem_ker,\n    normed_add_group_hom.coe_sub, pi.sub_apply, sub_eq_zero] using this\nend\n\ninstance has_limit_parallel_pair {V W : SemiNormedGroup.{u}} (f g : V ⟶ W) :\n  has_limit (parallel_pair f g) :=\n{ exists_limit := nonempty.intro\n  { cone := fork f g,\n    is_limit := fork.is_limit.mk _\n      (λ c, normed_add_group_hom.ker.lift (fork.ι c) _ $\n      show normed_add_group_hom.comp_hom (f - g) c.ι = 0,\n      by { rw [add_monoid_hom.map_sub, add_monoid_hom.sub_apply, sub_eq_zero], exact c.condition })\n      (λ c, normed_add_group_hom.ker.incl_comp_lift _ _ _)\n      (λ c g h, by { ext x, dsimp, rw ← h, refl }) } }\n\ninstance : limits.has_equalizers.{u (u+1)} SemiNormedGroup :=\n@has_equalizers_of_has_limit_parallel_pair SemiNormedGroup _ $ λ V W f g,\n  SemiNormedGroup.has_limit_parallel_pair f g\n\nend equalizers_and_kernels\n\nsection cokernel\n\n-- PROJECT: can we reuse the work to construct cokernels in `SemiNormedGroup₁` here?\n-- I don't see a way to do this that is less work than just repeating the relevant parts.\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : cofork f 0 :=\n@cofork.of_π _ _ _ _ _ _\n  (SemiNormedGroup.of (Y ⧸ (normed_add_group_hom.range f)))\n  f.range.normed_mk\n  begin\n    ext,\n    simp only [comp_apply, limits.zero_comp, normed_add_group_hom.zero_apply,\n      ←normed_add_group_hom.mem_ker, f.range.ker_normed_mk, f.mem_range, exists_apply_eq_apply],\n  end\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef cokernel_lift {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X ⟶ s.X := normed_add_group_hom.lift _ s.π\nbegin\n  rintro _ ⟨b, rfl⟩,\n  change (f ≫ s.π) b = 0,\n  simp,\nend\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef is_colimit_cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  is_colimit (cokernel_cocone f) :=\nis_colimit_aux _ (cokernel_lift f)\n(λ s, begin\n  ext,\n  apply normed_add_group_hom.lift_mk f.range,\n  rintro _ ⟨b, rfl⟩,\n  change (f ≫ s.π) b = 0,\n  simp,\nend)\n(λ s m w, normed_add_group_hom.lift_unique f.range _ _ _ w)\n\ninstance : has_cokernels SemiNormedGroup.{u} :=\n{ has_colimit := λ X Y f, has_colimit.mk\n  { cocone := cokernel_cocone f,\n    is_colimit := is_colimit_cokernel_cocone f } }\n\n-- Sanity check\nexample : has_cokernels SemiNormedGroup := by apply_instance\n\nsection explicit_cokernel\n\n/-- An explicit choice of cokernel, which has good properties with respect to the norm. -/\ndef explicit_cokernel {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : SemiNormedGroup.{u} :=\n(cokernel_cocone f).X\n\n/-- Descend to the explicit cokernel. -/\ndef explicit_cokernel_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) : explicit_cokernel f ⟶ Z :=\n(is_colimit_cokernel_cocone f).desc (cofork.of_π g (by simp [w]))\n\n/-- The projection from `Y` to the explicit cokernel of `X ⟶ Y`. -/\ndef explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) : Y ⟶ explicit_cokernel f :=\n(cokernel_cocone f).ι.app walking_parallel_pair.one\n\nlemma explicit_cokernel_π_surjective {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} :\n  function.surjective (explicit_cokernel_π f) :=\nsurjective_quot_mk _\n\n@[simp, reassoc]\nlemma comp_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  f ≫ explicit_cokernel_π f = 0 :=\nbegin\n  convert (cokernel_cocone f).w walking_parallel_pair_hom.left,\n  simp,\nend\n\n@[simp]\nlemma explicit_cokernel_π_apply_dom_eq_zero {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} (x : X) :\n  (explicit_cokernel_π f) (f x) = 0 :=\nshow (f ≫ (explicit_cokernel_π f)) x = 0, by { rw [comp_explicit_cokernel_π], refl }\n\n@[simp, reassoc]\nlemma explicit_cokernel_π_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) : explicit_cokernel_π f ≫ explicit_cokernel_desc w = g :=\n(is_colimit_cokernel_cocone f).fac _ _\n\n@[simp]\nlemma explicit_cokernel_π_desc_apply {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  {cond : f ≫ g = 0} (x : Y) : explicit_cokernel_desc cond (explicit_cokernel_π f x) = g x :=\nshow (explicit_cokernel_π f ≫ explicit_cokernel_desc cond) x = g x, by rw explicit_cokernel_π_desc\n\nlemma explicit_cokernel_desc_unique {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) (e : explicit_cokernel f ⟶ Z) (he : explicit_cokernel_π f ≫ e = g) :\n  e = explicit_cokernel_desc w :=\nbegin\n  apply (is_colimit_cokernel_cocone f).uniq (cofork.of_π g (by simp [w])),\n  rintro (_|_),\n  { convert w.symm,\n    simp },\n  { exact he }\nend\n\nlemma explicit_cokernel_desc_comp_eq_desc {X Y Z W : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  {h : Z ⟶ W} {cond : f ≫ g = 0} :\n  explicit_cokernel_desc cond ≫ h = explicit_cokernel_desc (show f ≫ (g ≫ h) = 0,\n  by rw [← category_theory.category.assoc, cond, limits.zero_comp]) :=\nbegin\n  refine explicit_cokernel_desc_unique _ _ _,\n  rw [← category_theory.category.assoc, explicit_cokernel_π_desc]\nend\n\n@[simp]\nlemma explicit_cokernel_desc_zero {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} :\n  explicit_cokernel_desc (show f ≫ (0 : Y ⟶ Z) = 0, from category_theory.limits.comp_zero) = 0 :=\neq.symm $ explicit_cokernel_desc_unique _ _ category_theory.limits.comp_zero\n\n@[ext]\nlemma explicit_cokernel_hom_ext {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y}\n  (e₁ e₂ : explicit_cokernel f ⟶ Z)\n  (h : explicit_cokernel_π f ≫ e₁ = explicit_cokernel_π f ≫ e₂) : e₁ = e₂ :=\nbegin\n  let g : Y ⟶ Z := explicit_cokernel_π f ≫ e₂,\n  have w : f ≫ g = 0, by simp,\n  have : e₂ = explicit_cokernel_desc w,\n  { apply explicit_cokernel_desc_unique, refl },\n  rw this,\n  apply explicit_cokernel_desc_unique,\n  exact h,\nend\n\ninstance explicit_cokernel_π.epi {X Y : SemiNormedGroup.{u}} {f : X ⟶ Y} :\n  epi (explicit_cokernel_π f) :=\nbegin\n  constructor,\n  intros Z g h H,\n  ext x,\n  obtain ⟨x, hx⟩ := explicit_cokernel_π_surjective (explicit_cokernel_π f x),\n  change (explicit_cokernel_π f ≫ g) _ = _,\n  rw [H]\nend\n\nlemma is_quotient_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\nnormed_add_group_hom.is_quotient (explicit_cokernel_π f) :=\nnormed_add_group_hom.is_quotient_quotient _\n\nlemma norm_noninc_explicit_cokernel_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  (explicit_cokernel_π f).norm_noninc :=\n(is_quotient_explicit_cokernel_π f).norm_le\n\nopen_locale nnreal\n\nlemma explicit_cokernel_desc_norm_le_of_norm_le {X Y Z : SemiNormedGroup.{u}}\n  {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) (c : ℝ≥0) (h : ‖ g ‖ ≤ c) :\n  ‖ explicit_cokernel_desc w ‖ ≤ c :=\nnormed_add_group_hom.lift_norm_le _ _ _ h\n\n\n\nlemma explicit_cokernel_desc_comp_eq_zero {X Y Z W : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  {h : Z ⟶ W} (cond : f ≫ g = 0) (cond2 : g ≫ h = 0) :\n  explicit_cokernel_desc cond ≫ h = 0 :=\nbegin\n  rw [← cancel_epi (explicit_cokernel_π f), ← category.assoc, explicit_cokernel_π_desc],\n  simp [cond2]\nend\n\nlemma explicit_cokernel_desc_norm_le {X Y Z : SemiNormedGroup.{u}}\n  {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) : ‖ explicit_cokernel_desc w ‖ ≤ ‖ g ‖ :=\nexplicit_cokernel_desc_norm_le_of_norm_le w ‖ g ‖₊ le_rfl\n\n/-- The explicit cokernel is isomorphic to the usual cokernel. -/\ndef explicit_cokernel_iso {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  explicit_cokernel f ≅ cokernel f :=\n(is_colimit_cokernel_cocone f).cocone_point_unique_up_to_iso (colimit.is_colimit _)\n\n@[simp]\nlemma explicit_cokernel_iso_hom_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  explicit_cokernel_π f ≫ (explicit_cokernel_iso f).hom = cokernel.π _ :=\nby simp [explicit_cokernel_π, explicit_cokernel_iso, is_colimit.cocone_point_unique_up_to_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_inv_π {X Y : SemiNormedGroup.{u}} (f : X ⟶ Y) :\n  cokernel.π f ≫ (explicit_cokernel_iso f).inv = explicit_cokernel_π f :=\nby simp [explicit_cokernel_π, explicit_cokernel_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_hom_desc {X Y Z : SemiNormedGroup.{u}} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (w : f ≫ g = 0) :\n  (explicit_cokernel_iso f).hom ≫ cokernel.desc f g w = explicit_cokernel_desc w :=\nbegin\n  ext1,\n  simp [explicit_cokernel_desc, explicit_cokernel_π, explicit_cokernel_iso,\n    is_colimit.cocone_point_unique_up_to_iso],\nend\n\n/-- A special case of `category_theory.limits.cokernel.map` adapted to `explicit_cokernel`. -/\nnoncomputable def explicit_cokernel.map {A B C D : SemiNormedGroup.{u}} {fab : A ⟶ B}\n  {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D} (h : fab ≫ fbd = fac ≫ fcd) :\n  explicit_cokernel fab ⟶ explicit_cokernel fcd :=\n@explicit_cokernel_desc _ _ _ fab (fbd ≫ explicit_cokernel_π _) $ by simp [reassoc_of h]\n\n/-- A special case of `category_theory.limits.cokernel.map_desc` adapted to `explicit_cokernel`. -/\nlemma explicit_coker.map_desc {A B C D B' D' : SemiNormedGroup.{u}}\n  {fab : A ⟶ B} {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D}\n  {h : fab ≫ fbd = fac ≫ fcd} {fbb' : B ⟶ B'} {fdd' : D ⟶ D'}\n  {condb : fab ≫ fbb' = 0} {condd : fcd ≫ fdd' = 0} {g : B' ⟶ D'}\n  (h' : fbb' ≫ g = fbd ≫ fdd'):\n  explicit_cokernel_desc condb ≫ g = explicit_cokernel.map h ≫ explicit_cokernel_desc condd :=\nbegin\n  delta explicit_cokernel.map,\n  simp [← cancel_epi (explicit_cokernel_π fab), category.assoc, explicit_cokernel_π_desc, h']\nend\n\nend explicit_cokernel\n\nend cokernel\n\nend SemiNormedGroup\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/analysis/normed/group/SemiNormedGroup/kernels.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6757645879592642, "lm_q1q2_score": 0.46354035082449313}}
{"text": "/-\nCopyright (c) 2021 . All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport group_theory.group_action.basic\nimport group_theory.subgroup.zpowers\nimport algebra.group_ring_action.basic\n/-!\n# Conjugation action of a group on itself\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the conjugation action of a group on itself. See also `mul_aut.conj` for\nthe definition of conjugation as a homomorphism into the automorphism group.\n\n## Main definitions\n\nA type alias `conj_act G` is introduced for a group `G`. The group `conj_act G` acts on `G`\nby conjugation. The group `conj_act G` also acts on any normal subgroup of `G` by conjugation.\n\nAs a generalization, this also allows:\n* `conj_act Mˣ` to act on `M`, when `M` is a `monoid`\n* `conj_act G₀` to act on `G₀`, when `G₀` is a `group_with_zero`\n\n## Implementation Notes\n\nThe scalar action in defined in this file can also be written using `mul_aut.conj g • h`. This\nhas the advantage of not using the type alias `conj_act`, but the downside of this approach\nis that some theorems about the group actions will not apply when since this\n`mul_aut.conj g • h` describes an action of `mul_aut G` on `G`, and not an action of `G`.\n\n-/\n\nvariables (α M G G₀ R K : Type*)\n\n/-- A type alias for a group `G`. `conj_act G` acts on `G` by conjugation -/\ndef conj_act : Type* := G\n\nnamespace conj_act\nopen mul_action subgroup\n\nvariables {M G G₀ R K}\n\ninstance : Π [group G], group (conj_act G) := id\ninstance : Π [div_inv_monoid G], div_inv_monoid (conj_act G) := id\ninstance : Π [group_with_zero G], group_with_zero (conj_act G) := id\ninstance : Π [fintype G], fintype (conj_act G) := id\n\n@[simp] lemma card [fintype G] : fintype.card (conj_act G) = fintype.card G := rfl\n\nsection div_inv_monoid\n\nvariable [div_inv_monoid G]\n\ninstance : inhabited (conj_act G) := ⟨1⟩\n\n/-- Reinterpret `g : conj_act G` as an element of `G`. -/\ndef of_conj_act : conj_act G ≃* G := ⟨id, id, λ _, rfl, λ _, rfl, λ _ _, rfl⟩\n\n/-- Reinterpret `g : G` as an element of `conj_act G`. -/\ndef to_conj_act : G ≃* conj_act G := of_conj_act.symm\n\n/-- A recursor for `conj_act`, for use as `induction x using conj_act.rec` when `x : conj_act G`. -/\nprotected def rec {C : conj_act G → Sort*} (h : Π g, C (to_conj_act g)) : Π g, C g := h\n\n@[simp] lemma «forall» (p : conj_act G → Prop) :\n  (∀ (x : conj_act G), p x) ↔ ∀ x : G, p (to_conj_act x) := iff.rfl\n\n@[simp] lemma of_mul_symm_eq : (@of_conj_act G _).symm = to_conj_act := rfl\n@[simp] lemma to_mul_symm_eq : (@to_conj_act G _).symm = of_conj_act := rfl\n@[simp] lemma to_conj_act_of_conj_act (x : conj_act G) : to_conj_act (of_conj_act x) = x := rfl\n@[simp] lemma of_conj_act_to_conj_act (x : G) : of_conj_act (to_conj_act x) = x := rfl\n@[simp] lemma of_conj_act_one : of_conj_act (1 : conj_act G) = 1 := rfl\n@[simp] lemma to_conj_act_one : to_conj_act (1 : G) = 1 := rfl\n@[simp] lemma of_conj_act_inv (x : conj_act G) : of_conj_act (x⁻¹) = (of_conj_act x)⁻¹ := rfl\n@[simp] lemma to_conj_act_inv (x : G) : to_conj_act (x⁻¹) = (to_conj_act x)⁻¹ := rfl\n@[simp] lemma of_conj_act_mul (x y : conj_act G) :\n  of_conj_act (x * y) = of_conj_act x * of_conj_act y := rfl\n@[simp] lemma to_conj_act_mul (x y : G) : to_conj_act (x * y) =\n  to_conj_act x * to_conj_act y := rfl\n\ninstance : has_smul (conj_act G) G :=\n{ smul := λ g h, of_conj_act g * h * (of_conj_act g)⁻¹ }\n\nlemma smul_def (g : conj_act G) (h : G) : g • h = of_conj_act g * h * (of_conj_act g)⁻¹ := rfl\n\nend div_inv_monoid\n\nsection units\n\nsection monoid\nvariables [monoid M]\n\ninstance has_units_scalar : has_smul (conj_act Mˣ) M :=\n{ smul := λ g h, of_conj_act g * h * ↑(of_conj_act g)⁻¹ }\n\nlemma units_smul_def (g : conj_act Mˣ) (h : M) : g • h = of_conj_act g * h * ↑(of_conj_act g)⁻¹ :=\nrfl\n\ninstance units_mul_distrib_mul_action : mul_distrib_mul_action (conj_act Mˣ) M :=\n{ smul := (•),\n  one_smul := by simp [units_smul_def],\n  mul_smul := by simp [units_smul_def, mul_assoc, mul_inv_rev],\n  smul_mul := by simp [units_smul_def, mul_assoc],\n  smul_one := by simp [units_smul_def], }\n\ninstance units_smul_comm_class [has_smul α M] [smul_comm_class α M M] [is_scalar_tower α M M] :\n  smul_comm_class α (conj_act Mˣ) M :=\n{ smul_comm := λ a um m, by rw [units_smul_def, units_smul_def, mul_smul_comm, smul_mul_assoc] }\n\ninstance units_smul_comm_class' [has_smul α M] [smul_comm_class M α M] [is_scalar_tower α M M] :\n  smul_comm_class (conj_act Mˣ) α M :=\nby { haveI : smul_comm_class α M M := smul_comm_class.symm _ _ _, exact smul_comm_class.symm _ _ _ }\n\nend monoid\n\nsection semiring\nvariables [semiring R]\n\ninstance units_mul_semiring_action : mul_semiring_action (conj_act Rˣ) R :=\n{ smul := (•),\n  smul_zero := by simp [units_smul_def],\n  smul_add := by simp [units_smul_def, mul_add, add_mul],\n  ..conj_act.units_mul_distrib_mul_action}\n\nend semiring\n\nend units\n\nsection group_with_zero\nvariable [group_with_zero G₀]\n\n@[simp] lemma of_conj_act_zero : of_conj_act (0 : conj_act G₀) = 0 := rfl\n@[simp] \n\ninstance mul_action₀ : mul_action (conj_act G₀) G₀ :=\n{ smul := (•),\n  one_smul := by simp [smul_def],\n  mul_smul := by simp [smul_def, mul_assoc, mul_inv_rev] }\n\ninstance smul_comm_class₀ [has_smul α G₀] [smul_comm_class α G₀ G₀] [is_scalar_tower α G₀ G₀] :\n  smul_comm_class α (conj_act G₀) G₀ :=\n{ smul_comm := λ a ug g, by rw [smul_def, smul_def, mul_smul_comm, smul_mul_assoc] }\n\ninstance smul_comm_class₀' [has_smul α G₀] [smul_comm_class G₀ α G₀] [is_scalar_tower α G₀ G₀] :\n  smul_comm_class (conj_act G₀) α G₀ :=\nby { haveI := smul_comm_class.symm G₀ α G₀, exact smul_comm_class.symm _ _ _ }\n\nend group_with_zero\n\nsection division_ring\nvariables [division_ring K]\n\ninstance distrib_mul_action₀ : distrib_mul_action (conj_act K) K :=\n{ smul := (•),\n  smul_zero := by simp [smul_def],\n  smul_add := by simp [smul_def, mul_add, add_mul],\n  ..conj_act.mul_action₀ }\n\nend division_ring\n\nvariables [group G]\n\ninstance : mul_distrib_mul_action (conj_act G) G :=\n{ smul := (•),\n  smul_mul := by simp [smul_def, mul_assoc],\n  smul_one := by simp [smul_def],\n  one_smul := by simp [smul_def],\n  mul_smul := by simp [smul_def, mul_assoc] }\n\ninstance smul_comm_class [has_smul α G] [smul_comm_class α G G] [is_scalar_tower α G G] :\n  smul_comm_class α (conj_act G) G :=\n{ smul_comm := λ a ug g, by rw [smul_def, smul_def, mul_smul_comm, smul_mul_assoc] }\n\ninstance smul_comm_class' [has_smul α G] [smul_comm_class G α G] [is_scalar_tower α G G] :\n  smul_comm_class (conj_act G) α G :=\nby { haveI := smul_comm_class.symm G α G, exact smul_comm_class.symm _ _ _ }\n\nlemma smul_eq_mul_aut_conj (g : conj_act G) (h : G) : g • h = mul_aut.conj (of_conj_act g) h := rfl\n\n/-- The set of fixed points of the conjugation action of `G` on itself is the center of `G`. -/\nlemma fixed_points_eq_center : fixed_points (conj_act G) G = center G :=\nbegin\n  ext x,\n  simp [mem_center_iff, smul_def, mul_inv_eq_iff_eq_mul]\nend\n\nlemma stabilizer_eq_centralizer (g : G) : stabilizer (conj_act G) g = (zpowers g).centralizer :=\nle_antisymm (le_centralizer_iff.mp (zpowers_le.mpr (λ x, mul_inv_eq_iff_eq_mul.mp)))\n  (λ x h, mul_inv_eq_of_eq_mul (h g (mem_zpowers g)).symm)\n\n/-- As normal subgroups are closed under conjugation, they inherit the conjugation action\n  of the underlying group. -/\ninstance subgroup.conj_action {H : subgroup G} [hH : H.normal] :\n  has_smul (conj_act G) H :=\n⟨λ g h, ⟨g • h, hH.conj_mem h.1 h.2 (of_conj_act g)⟩⟩\n\nlemma subgroup.coe_conj_smul {H : subgroup G} [hH : H.normal] (g : conj_act G) (h : H) :\n  ↑(g • h) = g • (h : G) := rfl\n\ninstance subgroup.conj_mul_distrib_mul_action {H : subgroup G} [hH : H.normal] :\n  mul_distrib_mul_action (conj_act G) H :=\n(subtype.coe_injective).mul_distrib_mul_action H.subtype subgroup.coe_conj_smul\n\n/-- Group conjugation on a normal subgroup. Analogous to `mul_aut.conj`. -/\ndef _root_.mul_aut.conj_normal {H : subgroup G} [hH : H.normal] : G →* mul_aut H :=\n(mul_distrib_mul_action.to_mul_aut (conj_act G) H).comp to_conj_act.to_monoid_hom\n\n@[simp] lemma _root_.mul_aut.conj_normal_apply {H : subgroup G} [H.normal] (g : G) (h : H) :\n  ↑(mul_aut.conj_normal g h) = g * h * g⁻¹ := rfl\n\n@[simp] lemma _root_.mul_aut.conj_normal_symm_apply {H : subgroup G} [H.normal] (g : G) (h : H) :\n  ↑((mul_aut.conj_normal g).symm h) = g⁻¹ * h * g :=\nby { change _ * (_)⁻¹⁻¹ = _, rw inv_inv, refl }\n\n@[simp] lemma _root_.mul_aut.conj_normal_inv_apply {H : subgroup G} [H.normal] (g : G) (h : H) :\n  ↑((mul_aut.conj_normal g)⁻¹ h) = g⁻¹ * h * g :=\nmul_aut.conj_normal_symm_apply g h\n\nlemma _root_.mul_aut.conj_normal_coe {H : subgroup G} [H.normal] {h : H} :\n  mul_aut.conj_normal ↑h = mul_aut.conj h :=\nmul_equiv.ext (λ x, rfl)\n\ninstance normal_of_characteristic_of_normal {H : subgroup G} [hH : H.normal]\n  {K : subgroup H} [h : K.characteristic] : (K.map H.subtype).normal :=\n⟨λ a ha b, by\n{ obtain ⟨a, ha, rfl⟩ := ha,\n  exact K.apply_coe_mem_map H.subtype\n    ⟨_, ((set_like.ext_iff.mp (h.fixed (mul_aut.conj_normal b)) a).mpr ha)⟩ }⟩\n\nend conj_act\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/group_theory/group_action/conj_act.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.4634503934792468}}
{"text": "-- Copyright © 2019 François G. Dorais. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n\nimport .basic\n\nnamespace universal\nvariables {τ : Type} {σ : Type*} (sig : signature τ σ)\n\nabbreviation substitution (dom₁ dom₂ : list τ) := Π (i : index dom₁), term sig dom₂ i.val\n\nnamespace substitution\nvariables {sig} {dom₁ dom₂ dom₃ : list τ} (sub : substitution sig dom₁ dom₂)\n\nabbreviation to_valuation : algebra.valuation (term_algebra sig dom₂) dom₁ := sub\n\nabbreviation apply {cod} (t : term sig dom₁ cod) : term sig dom₂ cod :=\nalgebra.eval (term_algebra sig dom₂) t sub\n\ntheorem apply_def {cod} (t : term sig dom₁ cod) : sub.apply t = (term_algebra sig dom₂).eval t sub := rfl\n\ntheorem apply_proj {i : index dom₁} : sub.apply (term.proj i) = sub i := rfl\n\ntheorem apply_func {f} (ts : Π (i : sig.index f), term sig dom₁ i.val) :\nsub.apply (term.func f ts) = term.func f (λ i, sub.apply (ts i)) := rfl\n\ntheorem eval (alg : algebra sig) : ∀ {cod} (t : term sig dom₁ cod) (val : Π (i : index dom₂), alg.sort i.val),\nalg.eval (sub.apply t) val = alg.eval t (λ i, alg.eval (sub i) val)\n| _ (term.proj i) val := rfl\n| _ (term.func f ts) val :=\n  have IH : (λ i, alg.eval (sub.apply (ts i)) val) = (λ i, alg.eval (ts i) (λ i, alg.eval (sub i) val)),\n  from funext $ λ i, eval (ts i) val,\n  calc alg.eval (sub.apply (term.func f ts)) val\n  = alg.func f (λ i, alg.eval (sub.apply (ts i)) val) : rfl ...\n  = alg.func f (λ i, alg.eval (ts i) (λ i, alg.eval (sub i) val)) : by rw IH ...\n  = alg.eval (term.func f ts) (λ (i : index dom₁), alg.eval (sub i) val) : by reflexivity\n\nabbreviation id {dom : list τ} : substitution sig dom dom := term.proj\n\n@[simp] theorem id_apply {dom : list τ} : ∀ {cod} (t : term sig dom cod), substitution.id.apply t = t\n| _ (term.proj _) := rfl\n| _ (term.func f ts) := \n  have (λ i, apply id (ts i)) = ts,\n  from funext $ λ i, id_apply (ts i),\n  calc apply id (term.func f ts)\n  = term.func f (λ i, apply id (ts i)) : rfl ...\n  = term.func f ts : by rw this\n\nabbreviation comp : substitution sig dom₂ dom₃ → substitution sig dom₁ dom₂ → substitution sig dom₁ dom₃ :=\nλ sub₂₃ sub₁₂ i, sub₂₃.apply (sub₁₂ i)\n\n@[simp] theorem comp_apply (sub₂₃ : substitution sig dom₂ dom₃) (sub₁₂ : substitution sig dom₁ dom₂) :\n∀ {cod} (t : term sig dom₁ cod), (comp sub₂₃ sub₁₂).apply t = sub₂₃.apply (sub₁₂.apply t)\n| _ (term.proj _) := rfl\n| _ (term.func f ts) :=\n  have (λ i, (comp sub₂₃ sub₁₂).apply (ts i)) = (λ i, sub₂₃.apply (sub₁₂.apply (ts i))),\n  from funext $ λ i, comp_apply (ts i),\n  calc (comp sub₂₃ sub₁₂).apply (term.func f ts)\n  = term.func f (λ i, (comp sub₂₃ sub₁₂).apply (ts i)) : rfl ...\n  = term.func f (λ i, sub₂₃.apply (sub₁₂.apply (ts i))) : by rw this ...\n  = sub₂₃.apply (term.func f (λ i, sub₁₂.apply (ts i))) : by rw apply_func sub₂₃ ...\n  = sub₂₃.apply (apply sub₁₂ (term.func f ts)) : by rw apply_func sub₁₂\n\nend substitution\n\nsection subst \nvariables {sig} {dom₁ dom₂ : list τ} (sub : substitution sig dom₁ dom₂)\n\nabbreviation term.subst {{cod}} : term sig dom₁ cod → term sig dom₂ cod := sub.apply\n\nabbreviation equation.subst {{cod}} : equation sig dom₁ cod → equation sig dom₂ cod :=\nλ e, ⟨sub.apply e.lhs, sub.apply e.rhs⟩\n\ntheorem equation.subst_lhs {cod} (e : equation sig dom₁ cod) : (e.subst sub).lhs = e.lhs.subst sub := rfl\n\ntheorem equation.subst_rhs {cod} (e : equation sig dom₁ cod) : (e.subst sub).rhs = e.rhs.subst sub := rfl\n\ntheorem subst_subst {dom₁ dom₂ dom₃ : list τ} (sub₂₃ : substitution sig dom₂ dom₃) (sub₁₂ : substitution sig dom₁ dom₂) {cod} (t : term sig dom₁ cod) :\nt.subst (λ i, (sub₁₂ i).subst sub₂₃) = (t.subst sub₁₂).subst sub₂₃ := substitution.comp_apply sub₂₃ sub₁₂ t\n\n@[simp] theorem subst_proj {dom} {cod} (t : term sig dom cod) : t.subst term.proj = t := substitution.id_apply t\n\nend subst\n\n\n\nend universal\n", "meta": {"author": "fgdorais", "repo": "lean-universal", "sha": "9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1", "save_path": "github-repos/lean/fgdorais-lean-universal", "path": "github-repos/lean/fgdorais-lean-universal/lean-universal-9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1/src/universal/substitution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.46345039141679234}}
{"text": "/-\nCopyright (c) 2017 Simon Hudon All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Mario Carneiro\n\nEvaluating arithmetic expressions including *, +, -, ^, ≤\n-/\n\nimport algebra.group_power data.rat tactic.interactive data.nat.prime\n\nuniverses u v w\n\nnamespace expr\n\nprotected meta def to_pos_rat : expr → option ℚ\n| `(%%e₁ / %%e₂) := do m ← e₁.to_nat, n ← e₂.to_nat, some (rat.mk m n)\n| e              := do n ← e.to_nat, return (rat.of_int n)\n\nprotected meta def to_rat : expr → option ℚ\n| `(has_neg.neg %%e) := do q ← e.to_pos_rat, some (-q)\n| e                  := e.to_pos_rat\n\nprotected meta def of_rat (α : expr) : ℚ → tactic expr\n| ⟨(n:ℕ), d, h, c⟩   := do\n  e₁ ← expr.of_nat α n,\n  if d = 1 then return e₁ else\n  do e₂ ← expr.of_nat α d,\n  tactic.mk_app ``has_div.div [e₁, e₂]\n| ⟨-[1+n], d, h, c⟩ := do\n  e₁ ← expr.of_nat α (n+1),\n  e ← (if d = 1 then return e₁ else do\n    e₂ ← expr.of_nat α d,\n    tactic.mk_app ``has_div.div [e₁, e₂]),\n  tactic.mk_app ``has_neg.neg [e]\n\nend expr\n\nnamespace tactic\n\nmeta def refl_conv (e : expr) : tactic (expr × expr) :=\ndo p ← mk_eq_refl e, return (e, p)\n\nmeta def trans_conv (t₁ t₂ : expr → tactic (expr × expr)) (e : expr) :\n  tactic (expr × expr) :=\n(do (e₁, p₁) ← t₁ e,\n  (do (e₂, p₂) ← t₂ e₁,\n    p ← mk_eq_trans p₁ p₂, return (e₂, p)) <|>\n  return (e₁, p₁)) <|> t₂ e\n\nend tactic\n\nopen tactic\n\nnamespace norm_num\nvariable {α : Type u}\n\nlemma subst_into_neg {α} [has_neg α] (a ta t : α) (pra : a = ta) (prt : -ta = t) : -a = t :=\nby simp [pra, prt]\n\ntheorem bit0_zero [add_group α] : bit0 (0 : α) = 0 := add_zero _\n\ntheorem bit1_zero [add_group α] [has_one α] : bit1 (0 : α) = 1 :=\nby rw [bit1, bit0_zero, zero_add]\n\nlemma pow_bit0_helper [monoid α] (a t : α) (b : ℕ) (h : a ^ b = t) :\n  a ^ bit0 b = t * t :=\nby simp [pow_bit0, h]\n\nlemma pow_bit1_helper [monoid α] (a t : α) (b : ℕ) (h : a ^ b = t) :\n  a ^ bit1 b = t * t * a :=\nby simp [pow_bit1, h]\n\nlemma lt_add_of_pos_helper [ordered_cancel_comm_monoid α]\n  (a b c : α) (h : a + b = c) (h₂ : 0 < b) : a < c :=\nh ▸ (lt_add_iff_pos_right _).2 h₂\n\nlemma nat_div_helper (a b q r : ℕ) (h : r + q * b = a) (h₂ : r < b) : a / b = q :=\nby rw [← h, nat.add_mul_div_right _ _ (lt_of_le_of_lt (nat.zero_le _) h₂),\n       nat.div_eq_of_lt h₂, zero_add]\n\nlemma int_div_helper (a b q r : ℤ) (h : r + q * b = a) (h₁ : 0 ≤ r) (h₂ : r < b) : a / b = q :=\nby rw [← h, int.add_mul_div_right _ _ (ne_of_gt (lt_of_le_of_lt h₁ h₂)),\n       int.div_eq_zero_of_lt h₁ h₂, zero_add]\n\nlemma nat_mod_helper (a b q r : ℕ) (h : r + q * b = a) (h₂ : r < b) : a % b = r :=\nby rw [← h, nat.add_mul_mod_self_right, nat.mod_eq_of_lt h₂]\n\nlemma int_mod_helper (a b q r : ℤ) (h : r + q * b = a) (h₁ : 0 ≤ r) (h₂ : r < b) : a % b = r :=\nby rw [← h, int.add_mul_mod_self, int.mod_eq_of_lt h₁ h₂]\n\nmeta def eval_pow (simp : expr → tactic (expr × expr)) : expr → tactic (expr × expr)\n| `(@has_pow.pow %%α _ %%m %%e₁ %%e₂) :=\n  match m with\n  | `(nat.has_pow) :=\n    mk_app ``nat.pow [e₁, e₂] >>= eval_pow\n  | `(@monoid.has_pow %%α %%m) :=\n    mk_app ``monoid.pow [e₁, e₂] >>= eval_pow\n  | _ := failed\n  end\n| `(monoid.pow %%e₁ 0) := do\n  p ← mk_app ``pow_zero [e₁],\n  a ← infer_type e₁,\n  o ← mk_app ``has_one.one [a],\n  return (o, p)\n| `(monoid.pow %%e₁ 1) := do\n  p ← mk_app ``pow_one [e₁],\n  return (e₁, p)\n| `(monoid.pow %%e₁ (bit0 %%e₂)) := do\n  e ← mk_app ``monoid.pow [e₁, e₂],\n  (e', p) ← simp e,\n  p' ← mk_app ``norm_num.pow_bit0_helper [e₁, e', e₂, p],\n  e'' ← to_expr ``(%%e' * %%e'),\n  return (e'', p')\n| `(monoid.pow %%e₁ (bit1 %%e₂)) := do\n  e ← mk_app ``monoid.pow [e₁, e₂],\n  (e', p) ← simp e,\n  p' ← mk_app ``norm_num.pow_bit1_helper [e₁, e', e₂, p],\n  e'' ← to_expr ``(%%e' * %%e' * %%e₁),\n  return (e'', p')\n| `(nat.pow %%e₁ %%e₂) := do\n  p₁ ← mk_app ``nat.pow_eq_pow [e₁, e₂],\n  e ← mk_app ``monoid.pow [e₁, e₂],\n  (e', p₂) ← simp e,\n  p ← mk_eq_trans p₁ p₂,\n  return (e', p)\n| _ := failed\n\nmeta def prove_pos : instance_cache → expr → tactic (instance_cache × expr)\n| c `(has_one.one _) := do (c, p) ← c.mk_app ``zero_lt_one [], return (c, p)\n| c `(bit0 %%e)      := do (c, p) ← prove_pos c e, (c, p) ← c.mk_app ``bit0_pos [e, p], return (c, p)\n| c `(bit1 %%e)      := do (c, p) ← prove_pos c e, (c, p) ← c.mk_app ``bit1_pos' [e, p], return (c, p)\n| c `(%%e₁ / %%e₂)   := do\n  (c, p₁) ← prove_pos c e₁, (c, p₂) ← prove_pos c e₂,\n  (c, p) ← c.mk_app ``div_pos_of_pos_of_pos [e₁, e₂, p₁, p₂],\n  return (c, p)\n| c e                       := failed\n\nmeta def prove_lt (simp : expr → tactic (expr × expr)) : instance_cache → expr → expr → tactic (instance_cache × expr)\n| c `(- %%e₁) `(- %%e₂) := do\n  (c, p) ← prove_lt c e₁ e₂,\n  (c, p) ← c.mk_app ``neg_lt_neg [e₁, e₂, p],\n  return (c, p)\n| c `(- %%e₁) `(has_zero.zero _) := do\n  (c, p) ← prove_pos c e₁,\n  (c, p) ← c.mk_app ``neg_neg_of_pos [e₁, p],\n  return (c, p)\n| c `(- %%e₁) e₂ := do\n  (c, p₁) ← prove_pos c e₁,\n  (c, me₁) ← c.mk_app ``has_neg.neg [e₁],\n  (c, p₁) ← c.mk_app ``neg_neg_of_pos [e₁, p₁],\n  (c, p₂) ← prove_pos c e₂,\n  (c, z) ← c.mk_app ``has_zero.zero [],\n  (c, p) ← c.mk_app ``lt_trans [me₁, z, e₂, p₁, p₂],\n  return (c, p)\n| c `(has_zero.zero _) e₂ := prove_pos c e₂\n| c e₁ e₂ := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  d ← expr.of_rat c.α (n₂ - n₁),\n  (c, e₃) ← c.mk_app ``has_add.add [e₁, d],\n  (e₂', p) ← norm_num e₃,\n  guard (e₂' =ₐ e₂),\n  (c, p') ← prove_pos c d,\n  (c, p) ← c.mk_app ``norm_num.lt_add_of_pos_helper [e₁, d, e₂, p, p'],\n  return (c, p)\n\nprivate meta def true_intro (p : expr) : tactic (expr × expr) :=\nprod.mk <$> mk_const `true <*> mk_app ``eq_true_intro [p]\n\nprivate meta def false_intro (p : expr) : tactic (expr × expr) :=\nprod.mk <$> mk_const `false <*> mk_app ``eq_false_intro [p]\n\nmeta def eval_ineq (simp : expr → tactic (expr × expr)) : expr → tactic (expr × expr)\n| `(%%e₁ < %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ < n₂ then\n    do (_, p) ← prove_lt simp c e₁ e₂, true_intro p\n  else do\n    (c, p) ← if n₁ = n₂ then c.mk_app ``lt_irrefl [e₁] else\n      (do (c, p') ← prove_lt simp c e₂ e₁,\n          c.mk_app ``not_lt_of_gt [e₁, e₂, p']),\n    false_intro p\n| `(%%e₁ ≤ %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ ≤ n₂ then do\n    (c, p) ← if n₁ = n₂ then c.mk_app ``le_refl [e₁] else\n      (do (c, p') ← prove_lt simp c e₁ e₂,\n          c.mk_app ``le_of_lt [e₁, e₂, p']),\n    true_intro p\n  else do\n    (c, p) ← prove_lt simp c e₂ e₁,\n    (c, p) ← c.mk_app ``not_le_of_gt [e₁, e₂, p],\n    false_intro p\n| `(%%e₁ = %%e₂) := do\n  n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,\n  c ← infer_type e₁ >>= mk_instance_cache,\n  if n₁ < n₂ then do\n    (c, p) ← prove_lt simp c e₁ e₂,\n    (c, p) ← c.mk_app ``ne_of_lt [e₁, e₂, p],\n    false_intro p\n  else if n₂ < n₁ then do\n    (c, p) ← prove_lt simp c e₂ e₁,\n    (c, p) ← c.mk_app ``ne_of_gt [e₁, e₂, p],\n    false_intro p\n  else mk_eq_refl e₁ >>= true_intro\n| `(%%e₁ > %%e₂) := mk_app ``has_lt.lt [e₂, e₁] >>= simp\n| `(%%e₁ ≥ %%e₂) := mk_app ``has_le.le [e₂, e₁] >>= simp\n| `(%%e₁ ≠ %%e₂) := do e ← mk_app ``eq [e₁, e₂], mk_app ``not [e] >>= simp\n| _ := failed\n\nmeta def eval_div_ext (simp : expr → tactic (expr × expr)) : expr → tactic (expr × expr)\n| `(has_inv.inv %%e) := do\n  c ← infer_type e >>= mk_instance_cache,\n  (c, p₁) ← c.mk_app ``inv_eq_one_div [e],\n  (c, o) ← c.mk_app ``has_one.one [],\n  (c, e') ← c.mk_app ``has_div.div [o, e],\n  (do (e'', p₂) ← simp e',\n    p ← mk_eq_trans p₁ p₂,\n    return (e'', p)) <|> return (e', p₁)\n| `(%%e₁ / %%e₂) := do\n  α ← infer_type e₁,\n  c ← mk_instance_cache α,\n  match α with\n  | `(nat) := do\n    n₁ ← e₁.to_nat, n₂ ← e₂.to_nat,\n    q ← expr.of_nat α (n₁ / n₂),\n    r ← expr.of_nat α (n₁ % n₂),\n    (c, e₃) ← c.mk_app ``has_mul.mul [q, e₂],\n    (c, e₃) ← c.mk_app ``has_add.add [r, e₃],\n    (e₁', p) ← norm_num e₃,\n    guard (e₁' =ₐ e₁),\n    (c, p') ← prove_lt simp c r e₂,\n    p ← mk_app ``norm_num.nat_div_helper [e₁, e₂, q, r, p, p'],\n    return (q, p)\n  | `(int) := match e₂ with\n    | `(- %%e₂') := do\n      (c, p₁) ← c.mk_app ``int.div_neg [e₁, e₂'],\n      (c, e) ← c.mk_app ``has_div.div [e₁, e₂'],\n      (c, e) ← c.mk_app ``has_neg.neg [e],\n      (e', p₂) ← simp e,\n      p ← mk_eq_trans p₁ p₂,\n      return (e', p)\n    | _ := do\n      n₁ ← e₁.to_int,\n      n₂ ← e₂.to_int,\n      q ← expr.of_rat α $ rat.of_int (n₁ / n₂),\n      r ← expr.of_rat α $ rat.of_int (n₁ % n₂),\n      (c, e₃) ← c.mk_app ``has_mul.mul [q, e₂],\n      (c, e₃) ← c.mk_app ``has_add.add [r, e₃],\n      (e₁', p) ← norm_num e₃,\n      guard (e₁' =ₐ e₁),\n      (c, r0) ← c.mk_app ``has_zero.zero [],\n      (c, r0) ← c.mk_app ``has_le.le [r0, r],\n      (_, p₁) ← simp r0,\n      p₁ ← mk_app ``of_eq_true [p₁],\n      (c, p₂) ← prove_lt simp c r e₂,\n      p ← mk_app ``norm_num.int_div_helper [e₁, e₂, q, r, p, p₁, p₂],\n      return (q, p)\n    end\n  | _ := failed\n  end\n| `(%%e₁ % %%e₂) := do\n  α ← infer_type e₁,\n  c ← mk_instance_cache α,\n  match α with\n  | `(nat) := do\n    n₁ ← e₁.to_nat, n₂ ← e₂.to_nat,\n    q ← expr.of_nat α (n₁ / n₂),\n    r ← expr.of_nat α (n₁ % n₂),\n    (c, e₃) ← c.mk_app ``has_mul.mul [q, e₂],\n    (c, e₃) ← c.mk_app ``has_add.add [r, e₃],\n    (e₁', p) ← norm_num e₃,\n    guard (e₁' =ₐ e₁),\n    (c, p') ← prove_lt simp c r e₂,\n    p ← mk_app ``norm_num.nat_mod_helper [e₁, e₂, q, r, p, p'],\n    return (r, p)\n  | `(int) := match e₂ with\n    | `(- %%e₂') := do\n      let p₁ := (expr.const ``int.mod_neg []).mk_app [e₁, e₂'],\n      (c, e) ← c.mk_app ``has_mod.mod [e₁, e₂'],\n      (e', p₂) ← simp e,\n      p ← mk_eq_trans p₁ p₂,\n      return (e', p)\n    | _ := do\n      n₁ ← e₁.to_int,\n      n₂ ← e₂.to_int,\n      q ← expr.of_rat α $ rat.of_int (n₁ / n₂),\n      r ← expr.of_rat α $ rat.of_int (n₁ % n₂),\n      (c, e₃) ← c.mk_app ``has_mul.mul [q, e₂],\n      (c, e₃) ← c.mk_app ``has_add.add [r, e₃],\n      (e₁', p) ← norm_num e₃,\n      guard (e₁' =ₐ e₁),\n      (c, r0) ← c.mk_app ``has_zero.zero [],\n      (c, r0) ← c.mk_app ``has_le.le [r0, r],\n      (_, p₁) ← simp r0,\n      p₁ ← mk_app ``of_eq_true [p₁],\n      (c, p₂) ← prove_lt simp c r e₂,\n      p ← mk_app ``norm_num.int_mod_helper [e₁, e₂, q, r, p, p₁, p₂],\n      return (r, p)\n    end\n  | _ := failed\n  end\n| `(%%e₁ ∣ %%e₂) := do\n  α ← infer_type e₁,\n  c ← mk_instance_cache α,\n  n ← match α with\n  | `(nat) := return ``nat.dvd_iff_mod_eq_zero\n  | `(int) := return ``int.dvd_iff_mod_eq_zero\n  | _ := failed\n  end,\n  p₁ ← mk_app ``propext [@expr.const tt n [] e₁ e₂],\n  (e', p₂) ← simp `(%%e₂ % %%e₁ = 0),\n  p' ← mk_eq_trans p₁ p₂,\n  return (e', p')\n| _ := failed\n\nlemma not_prime_helper (a b n : ℕ)\n  (h : a * b = n) (h₁ : 1 < a) (h₂ : 1 < b) : ¬ nat.prime n :=\nby rw ← h; exact nat.not_prime_mul h₁ h₂\n\nlemma is_prime_helper (n : ℕ)\n  (h₁ : 1 < n) (h₂ : nat.min_fac n = n) : nat.prime n :=\nnat.prime_def_min_fac.2 ⟨h₁, h₂⟩\n\nlemma min_fac_bit0 (n : ℕ) : nat.min_fac (bit0 n) = 2 :=\nby simp [nat.min_fac_eq, show 2 ∣ bit0 n, by simp [bit0_eq_two_mul n]]\n\ndef min_fac_helper (n k : ℕ) : Prop :=\n0 < k ∧ bit1 k ≤ nat.min_fac (bit1 n)\n\ntheorem min_fac_helper.n_pos {n k : ℕ} (h : min_fac_helper n k) : 0 < n :=\nnat.pos_iff_ne_zero.2 $ λ e,\nby rw e at h; exact not_le_of_lt (nat.bit1_lt h.1) h.2\n\nlemma min_fac_ne_bit0 {n k : ℕ} : nat.min_fac (bit1 n) ≠ bit0 k :=\nby rw bit0_eq_two_mul; exact λ e, absurd\n  ((nat.dvd_add_iff_right (by simp [bit0_eq_two_mul n])).2\n    (dvd_trans ⟨_, e⟩ (nat.min_fac_dvd _)))\n  dec_trivial\n\nlemma min_fac_helper_0 (n : ℕ) (h : 0 < n) : min_fac_helper n 1 :=\nbegin\n  refine ⟨zero_lt_one, lt_of_le_of_ne _ min_fac_ne_bit0.symm⟩,\n  refine @lt_of_le_of_ne ℕ _ _ _ (nat.min_fac_pos _) _,\n  intro e,\n  have := nat.min_fac_prime _,\n  { rw ← e at this, exact nat.not_prime_one this },\n  { exact ne_of_gt (nat.bit1_lt h) }\nend\n\nlemma min_fac_helper_1 {n k k' : ℕ} (e : k + 1 = k')\n  (np : nat.min_fac (bit1 n) ≠ bit1 k)\n  (h : min_fac_helper n k) : min_fac_helper n k' :=\nbegin\n  rw ← e,\n  refine ⟨nat.succ_pos _,\n    (lt_of_le_of_ne (lt_of_le_of_ne _ _ : k+1+k < _)\n      min_fac_ne_bit0.symm : bit0 (k+1) < _)⟩,\n  { rw add_right_comm, exact h.2 },\n  { rw add_right_comm, exact np.symm }\nend\n\nlemma min_fac_helper_2 (n k k' : ℕ) (e : k + 1 = k')\n  (np : ¬ nat.prime (bit1 k)) (h : min_fac_helper n k) : min_fac_helper n k' :=\nbegin\n  refine min_fac_helper_1 e _ h,\n  intro e₁, rw ← e₁ at np,\n  exact np (nat.min_fac_prime $ ne_of_gt $ nat.bit1_lt h.n_pos)\nend\n\nlemma min_fac_helper_3 (n k k' : ℕ) (e : k + 1 = k')\n  (nd : bit1 k ∣ bit1 n = false)\n  (h : min_fac_helper n k) : min_fac_helper n k' :=\nbegin\n  refine min_fac_helper_1 e _ h,\n  intro e₁, rw [eq_false, ← e₁] at nd,\n  exact nd (nat.min_fac_dvd _)\nend\n\nlemma min_fac_helper_4 (n k : ℕ) (hd : bit1 k ∣ bit1 n = true)\n  (h : min_fac_helper n k) : nat.min_fac (bit1 n) = bit1 k :=\nby rw eq_true at hd; exact\nle_antisymm (nat.min_fac_le_of_dvd (nat.bit1_lt h.1) hd) h.2\n\nlemma min_fac_helper_5 (n k k' : ℕ) (e : bit1 k * bit1 k = k')\n  (hd : bit1 n < k') (h : min_fac_helper n k) : nat.min_fac (bit1 n) = bit1 n :=\nbegin\n  refine (nat.prime_def_min_fac.1 (nat.prime_def_le_sqrt.2\n    ⟨nat.bit1_lt h.n_pos, _⟩)).2,\n  rw ← e at hd,\n  intros m m2 hm md,\n  have := le_trans h.2 (le_trans (nat.min_fac_le_of_dvd m2 md) hm),\n  rw nat.le_sqrt at this,\n  exact not_le_of_lt hd this\nend\n\nmeta def prove_non_prime (simp : expr → tactic (expr × expr)) (e : expr) (n d₁ : ℕ) : tactic expr :=\ndo let e₁ := reflect d₁,\n  c ← mk_instance_cache `(nat),\n  (c, p₁) ← prove_lt simp c `(1) e₁,\n  let d₂ := n / d₁, let e₂ := reflect d₂,\n  (e', p) ← mk_app ``has_mul.mul [e₁, e₂] >>= norm_num,\n  guard (e' =ₐ e),\n  (c, p₂) ← prove_lt simp c `(1) e₂,\n  return $ (expr.const ``not_prime_helper []).mk_app [e₁, e₂, e, p, p₁, p₂]\n\nmeta def prove_min_fac (simp : expr → tactic (expr × expr))\n  (e₁ : expr) (n1 : ℕ) : expr → expr → tactic (expr × expr)\n| e₂ p := do\n  k ← e₂.to_nat,\n  let k1 := bit1 k,\n  e₁1 ← mk_app ``bit1 [e₁],\n  e₂1 ← mk_app ``bit1 [e₂],\n  if n1 < k1*k1 then do\n    c ← mk_instance_cache `(nat),\n    (c, e') ← c.mk_app ``has_mul.mul [e₂1, e₂1],\n    (e', p₁) ← norm_num e',\n    (c, p₂) ← prove_lt simp c e₁1 e',\n    p' ← mk_app ``min_fac_helper_5 [e₁, e₂, e', p₁, p₂, p],\n    return (e₁1, p')\n  else let d := k1.min_fac in\n  if to_bool (d < k1) then do\n    (e', p₁) ← norm_num `(%%e₂ + 1),\n    p₂ ← prove_non_prime simp e₂1 k1 d,\n    mk_app ``min_fac_helper_2 [e₁, e₂, e', p₁, p₂, p] >>= prove_min_fac e'\n  else do\n    (_, p₂) ← simp `((%%e₂1 : ℕ) ∣ %%e₁1),\n    if k1 ∣ n1 then do\n      p' ← mk_app ``min_fac_helper_4 [e₁, e₂, p₂, p],\n      return (e₂1, p')\n    else do\n      (e', p₁) ← norm_num `(%%e₂ + 1),\n      mk_app ``min_fac_helper_3 [e₁, e₂, e', p₁, p₂, p] >>= prove_min_fac e'\n\nmeta def eval_prime (simp : expr → tactic (expr × expr)) : expr → tactic (expr × expr)\n| `(nat.prime %%e) := do\n  n ← e.to_nat,\n  match n with\n  | 0 := false_intro `(nat.not_prime_zero)\n  | 1 := false_intro `(nat.not_prime_one)\n  | _ := let d₁ := n.min_fac in\n    if d₁ < n then prove_non_prime simp e n d₁ >>= false_intro\n    else do\n      let e₁ := reflect d₁,\n      c ← mk_instance_cache `(nat),\n      (c, p₁) ← prove_lt simp c `(1) e₁,\n      (e₁, p) ← simp `(nat.min_fac %%e),\n      true_intro $ (expr.const ``is_prime_helper []).mk_app [e, p₁, p]\n  end\n| `(nat.min_fac 0) := refl_conv (reflect (0:ℕ))\n| `(nat.min_fac 1) := refl_conv (reflect (1:ℕ))\n| `(nat.min_fac (bit0 %%e)) := prod.mk `(2) <$> mk_app ``min_fac_bit0 [e]\n| `(nat.min_fac (bit1 %%e)) := do\n  n ← e.to_nat,\n  c ← mk_instance_cache `(nat),\n  (c, p) ← prove_pos c e,\n  mk_app ``min_fac_helper_0 [e, p] >>= prove_min_fac simp e (bit1 n) `(1)\n| _ := failed\n\nmeta def derive1 (simp : expr → tactic (expr × expr)) (e : expr) :\n  tactic (expr × expr) :=\nnorm_num e <|> eval_div_ext simp e <|>\neval_pow simp e <|> eval_ineq simp e <|> eval_prime simp e\n\nmeta def derive : expr → tactic (expr × expr) | e :=\ndo (_, e', pr) ←\n    ext_simplify_core () {} simp_lemmas.mk (λ _, failed) (λ _ _ _ _ _, failed)\n      (λ _ _ _ _ e,\n        do (new_e, pr) ← derive1 derive e,\n           guard (¬ new_e =ₐ e),\n           return ((), new_e, some pr, tt))\n      `eq e,\n    return (e', pr)\n\nend norm_num\n\nnamespace tactic.interactive\nopen norm_num interactive interactive.types\n\n/-- Basic version of `norm_num` that does not call `simp`. -/\nmeta def norm_num1 (loc : parse location) : tactic unit :=\ndo ns ← loc.get_locals,\n   tt ← tactic.replace_at derive ns loc.include_goal\n      | fail \"norm_num failed to simplify\",\n   when loc.include_goal $ try tactic.triv,\n   when (¬ ns.empty) $ try tactic.contradiction\n\n/-- Normalize numerical expressions. Supports the operations\n  `+` `-` `*` `/` `^` `<` `≤` over ordered fields (or other\n  appropriate classes), as well as `-` `/` `%` over `ℤ` and `ℕ`. -/\nmeta def norm_num (hs : parse simp_arg_list) (l : parse location) : tactic unit :=\nrepeat1 $ orelse' (norm_num1 l) $\nsimp_core {} (norm_num1 (loc.ns [none])) ff hs [] l\n\nmeta def apply_normed (x : parse texpr) : tactic unit :=\ndo x₁ ← to_expr x,\n  (x₂,_) ← derive x₁,\n  tactic.exact x₂\n\nend tactic.interactive\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/tactic/norm_num.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4634503895487121}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.structured_arrow\nimport category_theory.groupoid\nimport category_theory.punit\n\n/-!\n# The category of elements\n\nThis file defines the category of elements, also known as (a special case of) the Grothendieck\nconstruction.\n\nGiven a functor `F : C ⥤ Type`, an object of `F.elements` is a pair `(X : C, x : F.obj X)`.\nA morphism `(X, x) ⟶ (Y, y)` is a morphism `f : X ⟶ Y` in `C`, so `F.map f` takes `x` to `y`.\n\n## Implementation notes\n\nThis construction is equivalent to a special case of a comma construction, so this is mostly just a\nmore convenient API. We prove the equivalence in\n`category_theory.category_of_elements.structured_arrow_equivalence`.\n\n## References\n* [Emily Riehl, *Category Theory in Context*, Section 2.4][riehl2017]\n* <https://en.wikipedia.org/wiki/Category_of_elements>\n* <https://ncatlab.org/nlab/show/category+of+elements>\n\n## Tags\ncategory of elements, Grothendieck construction, comma category\n-/\n\nnamespace category_theory\n\nuniverses w v u\nvariables {C : Type u} [category.{v} C]\n\n/--\nThe type of objects for the category of elements of a functor `F : C ⥤ Type`\nis a pair `(X : C, x : F.obj X)`.\n-/\n@[nolint has_nonempty_instance]\ndef functor.elements (F : C ⥤ Type w) := (Σ c : C, F.obj c)\n\n/-- The category structure on `F.elements`, for `F : C ⥤ Type`.\n    A morphism `(X, x) ⟶ (Y, y)` is a morphism `f : X ⟶ Y` in `C`, so `F.map f` takes `x` to `y`.\n -/\ninstance category_of_elements (F : C ⥤ Type w) : category.{v} F.elements :=\n{ hom := λ p q, { f : p.1 ⟶ q.1 // (F.map f) p.2 = q.2 },\n  id := λ p, ⟨𝟙 p.1, by obviously⟩,\n  comp := λ p q r f g, ⟨f.val ≫ g.val, by obviously⟩ }\n\nnamespace category_of_elements\n\n@[ext]\nlemma ext (F : C ⥤ Type w) {x y : F.elements} (f g : x ⟶ y) (w : f.val = g.val) : f = g :=\nsubtype.ext_val w\n\n@[simp] lemma comp_val {F : C ⥤ Type w} {p q r : F.elements} {f : p ⟶ q} {g : q ⟶ r} :\n  (f ≫ g).val = f.val ≫ g.val := rfl\n\n@[simp] lemma id_val {F : C ⥤ Type w} {p : F.elements} : (𝟙 p : p ⟶ p).val = 𝟙 p.1 := rfl\n\nend category_of_elements\n\nnoncomputable\ninstance groupoid_of_elements {G : Type u} [groupoid.{v} G] (F : G ⥤ Type w) :\n  groupoid F.elements :=\n{ inv := λ p q f, ⟨inv f.val,\n    calc F.map (inv f.val) q.2 = F.map (inv f.val) (F.map f.val p.2) : by rw f.2\n                           ... = (F.map f.val ≫ F.map (inv f.val)) p.2 : rfl\n                           ... = p.2 : by {rw ← F.map_comp, simp} ⟩,\n  inv_comp' := λ _ _ _, by { ext, simp },\n  comp_inv' := λ _ _ _, by { ext, simp } }\n\nnamespace category_of_elements\nvariable (F : C ⥤ Type w)\n\n/-- The functor out of the category of elements which forgets the element. -/\n@[simps]\ndef π : F.elements ⥤ C :=\n{ obj := λ X, X.1,\n  map := λ X Y f, f.val }\n\n/--\nA natural transformation between functors induces a functor between the categories of elements.\n-/\n@[simps]\ndef map {F₁ F₂ : C ⥤ Type w} (α : F₁ ⟶ F₂) : F₁.elements ⥤ F₂.elements :=\n{ obj := λ t, ⟨t.1, α.app t.1 t.2⟩,\n  map := λ t₁ t₂ k, ⟨k.1, by simpa [←k.2] using (functor_to_types.naturality _ _ α k.1 t₁.2).symm⟩ }\n\n@[simp] lemma map_π {F₁ F₂ : C ⥤ Type w} (α : F₁ ⟶ F₂) : map α ⋙ π F₂ = π F₁ := rfl\n\n/-- The forward direction of the equivalence `F.elements ≅ (*, F)`. -/\ndef to_structured_arrow : F.elements ⥤ structured_arrow punit F :=\n{ obj := λ X, structured_arrow.mk (λ _, X.2),\n  map := λ X Y f, structured_arrow.hom_mk f.val (by tidy) }\n\n@[simp] lemma to_structured_arrow_obj (X) :\n  (to_structured_arrow F).obj X = { left := ⟨⟨⟩⟩, right := X.1, hom := λ _, X.2 } := rfl\n@[simp] lemma to_comma_map_right {X Y} (f : X ⟶ Y) :\n  ((to_structured_arrow F).map f).right = f.val := rfl\n\n/-- The reverse direction of the equivalence `F.elements ≅ (*, F)`. -/\ndef from_structured_arrow : structured_arrow punit F ⥤ F.elements :=\n{ obj := λ X, ⟨X.right, X.hom (punit.star)⟩,\n  map := λ X Y f, ⟨f.right, congr_fun f.w'.symm punit.star⟩ }\n\n@[simp] lemma from_structured_arrow_obj (X) :\n  (from_structured_arrow F).obj X = ⟨X.right, X.hom (punit.star)⟩ := rfl\n@[simp] lemma from_structured_arrow_map {X Y} (f : X ⟶ Y) :\n  (from_structured_arrow F).map f = ⟨f.right, congr_fun f.w'.symm punit.star⟩ := rfl\n\n/-- The equivalence between the category of elements `F.elements`\n    and the comma category `(*, F)`. -/\n@[simps]\ndef structured_arrow_equivalence : F.elements ≌ structured_arrow punit F :=\nequivalence.mk (to_structured_arrow F) (from_structured_arrow F)\n  (nat_iso.of_components (λ X, eq_to_iso (by tidy)) (by tidy))\n  (nat_iso.of_components\n    (λ X, structured_arrow.iso_mk (iso.refl _) (by tidy))\n    (by tidy))\n\nopen opposite\n\n/--\nThe forward direction of the equivalence `F.elementsᵒᵖ ≅ (yoneda, F)`,\ngiven by `category_theory.yoneda_sections`.\n-/\n@[simps]\ndef to_costructured_arrow (F : Cᵒᵖ ⥤ Type v) : (F.elements)ᵒᵖ ⥤ costructured_arrow yoneda F :=\n{ obj := λ X, costructured_arrow.mk\n    ((yoneda_sections (unop (unop X).fst) F).inv (ulift.up (unop X).2)),\n  map := λ X Y f,\n  begin\n    fapply costructured_arrow.hom_mk,\n    exact f.unop.val.unop,\n    ext y,\n    simp only [costructured_arrow.mk_hom_eq_self, yoneda_map_app, functor_to_types.comp, op_comp,\n      yoneda_sections_inv_app, functor_to_types.map_comp_apply, quiver.hom.op_unop,\n      subtype.val_eq_coe],\n    congr,\n    exact f.unop.2,\n  end }\n\n/--\nThe reverse direction of the equivalence `F.elementsᵒᵖ ≅ (yoneda, F)`,\ngiven by `category_theory.yoneda_equiv`.\n-/\n@[simps]\ndef from_costructured_arrow (F : Cᵒᵖ ⥤ Type v) : (costructured_arrow yoneda F)ᵒᵖ ⥤ F.elements :=\n{ obj := λ X, ⟨op (unop X).1, yoneda_equiv.1 (unop X).3⟩,\n  map := λ X Y f, ⟨f.unop.1.op,\n  begin\n    convert (congr_fun ((unop X).hom.naturality f.unop.left.op) (𝟙 _)).symm,\n    simp only [equiv.to_fun_as_coe, quiver.hom.unop_op, yoneda_equiv_apply,\n      types_comp_apply, category.comp_id, yoneda_obj_map],\n    have : yoneda.map f.unop.left ≫ (unop X).hom = (unop Y).hom,\n    { convert f.unop.3, erw category.comp_id },\n    erw ← this,\n    simp only [yoneda_map_app, functor_to_types.comp],\n    erw category.id_comp\n  end ⟩}\n\n@[simp]\nlemma from_costructured_arrow_obj_mk (F : Cᵒᵖ ⥤ Type v) {X : C} (f : yoneda.obj X ⟶ F) :\n  (from_costructured_arrow F).obj (op (costructured_arrow.mk f)) = ⟨op X, yoneda_equiv.1 f⟩ := rfl\n\n/-- The unit of the equivalence `F.elementsᵒᵖ ≅ (yoneda, F)` is indeed iso. -/\nlemma from_to_costructured_arrow_eq (F : Cᵒᵖ ⥤ Type v) :\n (to_costructured_arrow F).right_op ⋙ from_costructured_arrow F = 𝟭 _ :=\nbegin\n  apply functor.ext,\n  intros X Y f,\n  have : ∀ {a b : F.elements} (H : a = b),\n    ↑(eq_to_hom H) = eq_to_hom (show a.fst = b.fst, by { cases H, refl }) :=\n    λ _ _ H, by { cases H, refl },\n  ext, simp[this],\n  tidy\nend\n\n/-- The counit of the equivalence `F.elementsᵒᵖ ≅ (yoneda, F)` is indeed iso. -/\nlemma to_from_costructured_arrow_eq (F : Cᵒᵖ ⥤ Type v) :\n  (from_costructured_arrow F).right_op ⋙ to_costructured_arrow F = 𝟭 _ :=\nbegin\n  apply functor.hext,\n  { intro X, cases X, cases X_right,\n    simp only [functor.id_obj, functor.right_op_obj,\n      to_costructured_arrow_obj, functor.comp_obj, costructured_arrow.mk],\n    congr,\n    ext x f,\n    convert congr_fun (X_hom.naturality f.op).symm (𝟙 X_left),\n    simp only [quiver.hom.unop_op, yoneda_obj_map],\n    erw category.comp_id },\n  intros X Y f,\n  rcases X with ⟨X_left, ⟨⟨⟩⟩⟩, rcases Y with ⟨Y_left, ⟨⟨⟩⟩⟩, cases f,\n  simp [costructured_arrow.hom_mk],\n  delta costructured_arrow.mk,\n  congr,\n  { ext x f,\n    convert congr_fun (X_hom.naturality f.op).symm (𝟙 X_left),\n    simp only [quiver.hom.unop_op, category_theory.yoneda_obj_map],\n    erw category.comp_id },\n  { ext x f,\n    convert congr_fun (Y_hom.naturality f.op).symm (𝟙 Y_left),\n    simp only [quiver.hom.unop_op, category_theory.yoneda_obj_map],\n    erw category.comp_id },\n  simp,\n  exact proof_irrel_heq _ _,\nend\n\n\n/-- The equivalence `F.elementsᵒᵖ ≅ (yoneda, F)` given by yoneda lemma. -/\n@[simps] def costructured_arrow_yoneda_equivalence (F : Cᵒᵖ ⥤ Type v) :\n  (F.elements)ᵒᵖ ≌ costructured_arrow yoneda F :=\nequivalence.mk (to_costructured_arrow F) (from_costructured_arrow F).right_op\n  (nat_iso.op (eq_to_iso (from_to_costructured_arrow_eq F)))\n  (eq_to_iso $ to_from_costructured_arrow_eq F)\n\n/--\nThe equivalence `(-.elements)ᵒᵖ ≅ (yoneda, -)` of is actually a natural isomorphism of functors.\n-/\nlemma costructured_arrow_yoneda_equivalence_naturality {F₁ F₂ : Cᵒᵖ ⥤ Type v}\n  (α : F₁ ⟶ F₂) : (map α).op ⋙ to_costructured_arrow F₂ =\n    to_costructured_arrow F₁ ⋙ costructured_arrow.map α :=\nbegin\n  fapply functor.ext,\n  { intro X,\n    simp only [costructured_arrow.map_mk, to_costructured_arrow_obj,\n      functor.op_obj, functor.comp_obj],\n    congr,\n    ext x f,\n    simpa using congr_fun (α.naturality f.op).symm (unop X).snd },\n  { intros X Y f, ext,\n    have : ∀ {F : Cᵒᵖ ⥤ Type v} {a b : costructured_arrow yoneda F} (H : a = b),\n      comma_morphism.left (eq_to_hom H) = eq_to_hom (show a.left = b.left, by { cases H, refl }) :=\n      λ _ _ _ H, by { cases H, refl },\n    simp [this] }\nend\n\nend category_of_elements\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/elements.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.4634420213472617}}
{"text": "import .vm_check ..syntax\n\n/-\nfoo is an rbmap with (\"A\", 0) to (\"Z\", 25) \n-/\ndef foo := \nlet l := (list.range 26).map (λ i, (char.to_string $ char.of_nat (i + 65), i))\nin rbmap.from_list l\n\n#eval foo.find \"Z\"\n\n/- check time -/\n-- set_option profiler true\n\n-- too slow\n-- theorem bar : foo.find \"Z\" = some 25 := rfl\n\n#eval foo.find \"Z\"\n\n\n-- curiously, fails; VM doesn't have code associated with bool.tt\n-- example : tt = tt := by vm_check_tt\n\nexample : id tt = tt := by vm_check_tt\n\nexample : tt && tt = tt := by vm_check_tt\n\nexample : 2 < 5 := vm_check\n\n-- fails\n-- example : 5 < 2 := vm_check\n\n-- fails\n-- example : ∀ x, 2 < x := vm_check\n\nexample : 1000 * 1000 = 1000000 := vm_check\n\n-- set_option profiler true\n\ntheorem bar : foo.find \"Z\" = some 25 := vm_check\n\n-- fails\n-- example : ∀ x : nat, x = x :=\n-- assume x, vm_check\n\nnamespace testeq\n\ndef foo (s t : string) : nat :=\nif s = t then 0 else 1\n\ndef foo' (s t : nat) : nat :=\nif s = t then 0 else 1\n\ndef bar (s t : string) : nat → nat\n| 0 := 0\n| (n+1):= foo s t + bar n\n\ndef bar' (s t : nat) : nat → nat\n| 0 := 0\n| (n+1):= foo' s t + bar' n\n\ndef baz := \"hello\"\n\ndef bla (s : string) : nat → nat\n| 0 := 0\n| (n+1):= foo s s + bla n\n\ndef bla' := \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n\ndef bla'' := \"oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n\nset_option profiler true\n\n/-\n#eval bar bla' bla' 1000000\n\n#eval bar bla' bla'' 1000000\n\n#eval bar (\"o\"++ bla') bla'' 1000000\n\n#eval bar \"hello\" \"goodbye\" 1000000\n\n#eval bar \"hello\" \"hello\" 1000000\n\n#eval bar \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n1000000\n\n--#eval bar baz baz 1000000\n\n--#eval bla \"hello\" 1000000\n\n--#eval bar' 25 67 1000000\n\n--#eval bar' 43 43 1000000\n\n-/\n\nend testeq\n\n/-do\ntgt ← target,\napply `(@of_to_bool_eq_tt %%tgt),\nskip\n-/\n\n\nsection\nopen hol\nopen hol.type\n\n-- these seem slow\nset_option profiler true\n\ntheorem arities_ok_mk_prop : arities_ok mk_prop :=\nby { dsimp [mk_prop, arities_ok, arities_ok_aux, list.empty, coe_sort], reflexivity }\n\ntheorem arities_ok_mk_list_type (t : type) (h : arities_ok t) : arities_ok (mk_list_type t) = tt :=\nby { dsimp [mk_list_type, arities_ok, coe_sort] at *, dsimp [arities_ok_aux], rw h, reflexivity }\n\ntheorem arities_ok_mk_list_type' (t : type) (h : arities_ok t) : arities_ok (mk_list_type t) = tt :=\nby { simp [mk_list_type, arities_ok, coe_sort] at *, simp [arities_ok_aux], split, assumption, reflexivity }\n\n@[simp] theorem arity_list : constructor.list.arity = 1 := rfl\n\ntheorem arities_ok_mk_list_type'' (t : type) (h : arities_ok t = tt) : arities_ok (mk_list_type t) = tt :=\nby { simp [arities_ok] at *, simp [mk_list_type, arities_ok_aux, h] }\n\ntheorem arities_ok_mk_list_type''' (t : type) (h : arities_ok t = tt) : arities_ok (mk_list_type t) = tt :=  by { dsimp [arities_ok] at *, dsimp [mk_list_type, arities_ok_aux, constructor.list], rw h, reflexivity }\n\n-- much faster\n#eval arities_ok mk_prop\n#eval arities_ok (mk_list_type mk_prop)\n\nend\n", "meta": {"author": "avigad", "repo": "formal_logic", "sha": "59d7fe7cb7a7927fb72d89d4fd40965bcd769349", "save_path": "github-repos/lean/avigad-formal_logic", "path": "github-repos/lean/avigad-formal_logic/formal_logic-59d7fe7cb7a7927fb72d89d4fd40965bcd769349/src/misc/experiments.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6723317123102955, "lm_q2_score": 0.6893056104028797, "lm_q1q2_score": 0.4634420213472616}}
{"text": "import tactic --hide\n\n\n/-\nYou can also use `cases` when working with the `∨` (\"or\") connective. For example, if you have\nthe assumption\n\n```\nh : P ∨ Q\n``` \n\nthen `cases h with hp hq` will convert your state into the following two states:\n\n```\nP : Prop\nhp : P\n⊢ P\n```\nand\n\n```\nP : Prop\nhq : Q\n⊢ Q\n```\none where `P` is true and one where `Q` is true.\n\nTry this in the lemma below.\n-/\n\n/- Lemma\nIf $P$ is a logical statement and $P$ or $P$ is true, then $P$ is true.\n-/\n\nlemma cases_or_example (P : Prop) (hp : P ∨ P) : P :=\nbegin\n  cases hp with hp hp,\n  exact hp,\n  exact hp,\nend", "meta": {"author": "CBirkbeck", "repo": "logic_projic", "sha": "0b029af0fbfc0ac6eafae47401d5bbf8e641d7d2", "save_path": "github-repos/lean/CBirkbeck-logic_projic", "path": "github-repos/lean/CBirkbeck-logic_projic/logic_projic-0b029af0fbfc0ac6eafae47401d5bbf8e641d7d2/src/logic2/casestac2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.4634420208783864}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport control.equiv_functor\nimport data.option.basic\nimport data.subtype\nimport logic.equiv.defs\n\n/-!\n# Equivalences for `option α`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\n\nWe define\n* `equiv.option_congr`: the `option α ≃ option β` constructed from `e : α ≃ β` by sending `none` to\n  `none`, and applying a `e` elsewhere.\n* `equiv.remove_none`: the `α ≃ β` constructed from `option α ≃ option β` by removing `none` from\n  both sides.\n-/\n\nnamespace equiv\n\nopen option\n\nvariables {α β γ : Type*}\n\nsection option_congr\n\n/-- A universe-polymorphic version of `equiv_functor.map_equiv option e`. -/\n@[simps apply]\ndef option_congr (e : α ≃ β) : option α ≃ option β :=\n{ to_fun := option.map e,\n  inv_fun := option.map e.symm,\n  left_inv := λ x, (option.map_map _ _ _).trans $\n    e.symm_comp_self.symm ▸ congr_fun option.map_id x,\n  right_inv := λ x, (option.map_map _ _ _).trans $\n    e.self_comp_symm.symm ▸ congr_fun option.map_id x }\n\n@[simp] lemma option_congr_refl : option_congr (equiv.refl α) = equiv.refl _ :=\next $ congr_fun option.map_id\n\n@[simp] lemma option_congr_symm (e : α ≃ β) : (option_congr e).symm = option_congr e.symm := rfl\n\n@[simp] lemma option_congr_trans (e₁ : α ≃ β) (e₂ : β ≃ γ) :\n  (option_congr e₁).trans (option_congr e₂) = option_congr (e₁.trans e₂) :=\next $ option.map_map _ _\n\n/-- When `α` and `β` are in the same universe, this is the same as the result of\n`equiv_functor.map_equiv`. -/\nlemma option_congr_eq_equiv_function_map_equiv {α β : Type*} (e : α ≃ β) :\n  option_congr e = equiv_functor.map_equiv option e := rfl\n\nend option_congr\n\nsection remove_none\nvariables (e : option α ≃ option β)\n\nprivate def remove_none_aux (x : α) : β :=\nif h : (e (some x)).is_some\n  then option.get h\n  else option.get $ show (e none).is_some, from\n  begin\n    rw ←option.ne_none_iff_is_some,\n    intro hn,\n    rw [option.not_is_some_iff_eq_none, ←hn] at h,\n    simpa only using e.injective h,\n  end\n\nprivate lemma remove_none_aux_some {x : α} (h : ∃ x', e (some x) = some x') :\n  some (remove_none_aux e x) = e (some x) :=\nby simp [remove_none_aux, option.is_some_iff_exists.mpr h]\n\nprivate lemma remove_none_aux_none {x : α} (h : e (some x) = none) :\n  some (remove_none_aux e x) = e none :=\nby simp [remove_none_aux, option.not_is_some_iff_eq_none.mpr h]\n\nprivate lemma remove_none_aux_inv (x : α) : remove_none_aux e.symm (remove_none_aux e x) = x :=\noption.some_injective _ begin\n  cases h1 : e.symm (some (remove_none_aux e x)); cases h2 : (e (some x)),\n  { rw remove_none_aux_none _ h1,\n    exact (e.eq_symm_apply.mpr h2).symm },\n  { rw remove_none_aux_some _ ⟨_, h2⟩ at h1,\n    simpa using h1, },\n  { rw remove_none_aux_none _ h2 at h1,\n    simpa using h1, },\n  { rw remove_none_aux_some _ ⟨_, h1⟩,\n    rw remove_none_aux_some _ ⟨_, h2⟩,\n    simp },\nend\n\n/-- Given an equivalence between two `option` types, eliminate `none` from that equivalence by\nmapping `e.symm none` to `e none`. -/\ndef remove_none : α ≃ β :=\n{ to_fun := remove_none_aux e,\n  inv_fun := remove_none_aux e.symm,\n  left_inv := remove_none_aux_inv e,\n  right_inv := remove_none_aux_inv e.symm, }\n\n@[simp]\nlemma remove_none_symm : (remove_none e).symm = remove_none e.symm := rfl\n\nlemma remove_none_some {x : α} (h : ∃ x', e (some x) = some x') :\n  some (remove_none e x) = e (some x) := remove_none_aux_some e h\n\n\n\n@[simp] lemma option_symm_apply_none_iff : e.symm none = none ↔ e none = none :=\n⟨λ h, by simpa using (congr_arg e h).symm, λ h, by simpa using (congr_arg e.symm h).symm⟩\n\nlemma some_remove_none_iff {x : α} :\n  some (remove_none e x) = e none ↔ e.symm none = some x :=\nbegin\n  cases h : e (some x) with a,\n  { rw remove_none_none _ h,\n    simpa using (congr_arg e.symm h).symm },\n  { rw remove_none_some _ ⟨a, h⟩,\n    have := (congr_arg e.symm h),\n    rw [symm_apply_apply] at this,\n    simp only [false_iff, apply_eq_iff_eq],\n    simp [this] }\nend\n\n@[simp]\nlemma remove_none_option_congr (e : α ≃ β) : remove_none e.option_congr = e :=\nequiv.ext $ λ x, option.some_injective _ $ remove_none_some _ ⟨e x, by simp [equiv_functor.map]⟩\n\nend remove_none\n\nlemma option_congr_injective : function.injective (option_congr : α ≃ β → option α ≃ option β) :=\nfunction.left_inverse.injective remove_none_option_congr\n\n/-- Equivalences between `option α` and `β` that send `none` to `x` are equivalent to\nequivalences between `α` and `{y : β // y ≠ x}`. -/\ndef option_subtype [decidable_eq β] (x : β) :\n  {e : option α ≃ β // e none = x} ≃ (α ≃ {y : β // y ≠ x}) :=\n{ to_fun := λ e,\n    { to_fun := λ a, ⟨e a, ((equiv_like.injective _).ne_iff' e.property).2 (some_ne_none _)⟩,\n      inv_fun := λ b, get (ne_none_iff_is_some.1 (((equiv_like.injective _).ne_iff'\n        (((apply_eq_iff_eq_symm_apply _).1 e.property).symm)).2 b.property)),\n      left_inv := λ a, begin\n          rw [←some_inj, some_get, ←coe_def],\n          exact symm_apply_apply (e : option α ≃ β) a\n        end,\n      right_inv := λ b, begin\n          ext,\n          simp,\n          exact apply_symm_apply _ _\n        end },\n  inv_fun := λ e,\n    ⟨{ to_fun := λ a, cases_on' a x (coe ∘ e),\n       inv_fun := λ b, if h : b = x then none else e.symm ⟨b, h⟩,\n       left_inv := λ a, begin\n           cases a, { simp },\n           simp only [cases_on'_some, function.comp_app, subtype.coe_eta, symm_apply_apply,\n                      dite_eq_ite],\n           exact if_neg (e a).property\n         end,\n       right_inv := λ b, begin\n           by_cases h : b = x;\n             simp [h]\n         end},\n     rfl⟩,\n  left_inv := λ e, begin\n      ext a,\n      cases a,\n      { simpa using e.property.symm },\n      { simpa }\n    end,\n  right_inv := λ e, begin\n      ext a,\n      refl\n    end }\n\n@[simp] lemma option_subtype_apply_apply [decidable_eq β] (x : β)\n  (e : {e : option α ≃ β // e none = x}) (a : α) (h) :\n  option_subtype x e a = ⟨(e : option α ≃ β) a, h⟩ :=\nrfl\n\n@[simp] lemma coe_option_subtype_apply_apply [decidable_eq β] (x : β)\n  (e : {e : option α ≃ β // e none = x}) (a : α) :\n  ↑(option_subtype x e a) = (e : option α ≃ β) a :=\nrfl\n\n@[simp] lemma option_subtype_apply_symm_apply [decidable_eq β] (x : β)\n  (e : {e : option α ≃ β // e none = x}) (b : {y : β // y ≠ x}) :\n  ↑((option_subtype x e).symm b) = (e : option α ≃ β).symm b :=\nbegin\n  dsimp only [option_subtype],\n  simp\nend\n\n@[simp] lemma option_subtype_symm_apply_apply_coe [decidable_eq β] (x : β)\n  (e : α ≃ {y : β // y ≠ x}) (a : α) : (option_subtype x).symm e a = e a :=\nrfl\n\n@[simp] lemma option_subtype_symm_apply_apply_some [decidable_eq β] (x : β)\n  (e : α ≃ {y : β // y ≠ x}) (a : α) : (option_subtype x).symm e (some a) = e a :=\nrfl\n\n@[simp] lemma option_subtype_symm_apply_apply_none [decidable_eq β] (x : β)\n  (e : α ≃ {y : β // y ≠ x}) : (option_subtype x).symm e none = x :=\nrfl\n\n@[simp] lemma option_subtype_symm_apply_symm_apply [decidable_eq β] (x : β)\n  (e : α ≃ {y : β // y ≠ x}) (b : {y : β // y ≠ x}) :\n  ((option_subtype x).symm e : option α ≃ β).symm b = e.symm b :=\nbegin\n  simp only [option_subtype, coe_fn_symm_mk, subtype.coe_mk, subtype.coe_eta, dite_eq_ite,\n             ite_eq_right_iff],\n  exact λ h, false.elim (b.property h),\nend\n\nend equiv\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/logic/equiv/option.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6893056231680122, "lm_q1q2_score": 0.4634420208783863}}
{"text": "import tactic.rewrite_search\n\naxiom foo : [0] = [1]\naxiom bar1 : [1] = [2]\naxiom bar2 : [2] = [3]\naxiom bar3 : [3] = [4]\naxiom bar4 : [4] = [5]\naxiom bar5 : [5] = [6]\naxiom bar6 : [6] = [7]\naxiom baz : [4] = [0]\n\n-- Obviously sub-optimal\nexample : [0] = [7] :=\nbegin\n  -- erw [foo, bar1, bar2, bar3, bar4, bar5, bar6],\n  rewrite_search_with [foo, bar1, bar2, bar3, bar4, bar5, bar6, baz]\n    { optimal := ff, no visualiser, explain := tt },\nend\n\nexample : [0] = [7] :=\nbegin\n  /- `rewrite_search` says -/\n  erw [foo, bar1, bar2, bar3, bar4, bar5, bar6]\nend\n\n-- Obviously optimal\nexample : [0] = [7] :=\nbegin\n  rewrite_search_with [foo, bar1, bar2, bar3, bar4, bar5, bar6, baz]\n    { optimal := tt, no visualiser, explain := tt },\nend\n\nexample : [0] = [7] :=\nbegin\n  /- `rewrite_search` says -/\n  erw [←baz, bar4, bar5, bar6]\nend\n", "meta": {"author": "semorrison", "repo": "lean-rewrite-search", "sha": "e804b8f2753366b8957be839908230ee73f9e89f", "save_path": "github-repos/lean/semorrison-lean-rewrite-search", "path": "github-repos/lean/semorrison-lean-rewrite-search/lean-rewrite-search-e804b8f2753366b8957be839908230ee73f9e89f/test/rewrite_search_optimal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.4634420165871847}}
{"text": "import Lbar.functor\nimport laurent_measures.functor\nimport laurent_measures.aux_lemmas\nimport invpoly.functor\nimport condensed.condensify\n\n.\n\n/-!\nThe short exact sequence\n```\n0 → ℤ[T⁻¹] → ℳ(S, ℤ((T))_r') → ℳ-bar(S)_r' → 0\n```\n-/\n\n-- move me\nlemma int.coe_nat_injective : function.injective (coe : ℕ → ℤ) :=\nλ m n h, int.coe_nat_inj h\n\nlemma int.nat_abs_of_nonpos {a : ℤ} : a ≤ 0 → ↑(a.nat_abs) = -a :=\nbegin\n  intro h,\n  rw ← int.nat_abs_neg,\n  apply int.nat_abs_of_nonneg,\n  exact neg_nonneg.mpr h,\nend\n\n\nnoncomputable theory\n\nopen aux_thm69\nopen_locale nnreal\n\nvariables (r' : ℝ≥0) [fact (0 < r')] (S : Fintype)\n\nnamespace invpoly\n\ndef to_laurent_measures_fun (F : invpoly r' S) : S → ℤ → ℤ\n| s 0       := (F s).coeff 0\n| s (n+1:ℕ) := 0\n| s -[1+n]  := (F s).coeff (n+1)\n\nlemma to_laurent_measures_fun_zero (F : invpoly r' S) (s : S) :\nto_laurent_measures_fun r' S F s 0 = (F s).coeff 0 :=\nrfl\n\nlemma to_laurent_measures_fun_pos (F : invpoly r' S) (s : S) (n : ℕ) :\nto_laurent_measures_fun r' S F s (n+1 : ℕ) = 0 :=\nrfl\n\nlemma to_laurent_measures_fun_pos' (F : invpoly r' S) (s : S) (n : ℕ) :\nto_laurent_measures_fun r' S F s (n + 1) = 0 :=\nrfl\n\nlemma to_laurent_measures_fun_pos'' (F : invpoly r' S) (s : S) {m : ℤ} (hn : 0 < m) :\nto_laurent_measures_fun r' S F s m = 0 :=\nbegin\n  convert to_laurent_measures_fun_pos' r' S F s (m - 1).nat_abs,\n  rw int.nat_abs_of_nonneg,\n  { ring },\n  { linarith }\nend\n\nlemma to_laurent_measures_fun_neg (F : invpoly r' S) (s : S) (n : ℕ) :\nto_laurent_measures_fun r' S F s -[1+n] = (F s).coeff (n+1) :=\nrfl\n\nlemma to_laurent_measures_fun_neg' (F : invpoly r' S) (s : S) (n : ℕ) :\nto_laurent_measures_fun r' S F s (-(n.succ)) = (F s).coeff (n+1) :=\nrfl\n\nlemma to_laurent_measures_fun_nonpos (F : invpoly r' S) (s : S) (n : ℕ) :\nto_laurent_measures_fun r' S F s (-n) = (F s).coeff n :=\nbegin\n  cases n,\n  { exact to_laurent_measures_fun_zero r' S F s, },\n  { exact to_laurent_measures_fun_neg r' S F s n, }\nend\n\n/-- The natural inclusion from an S-indexed set of polynomials `Fₛ : ℤ[T⁻¹]` to\nthe corresponding power series `Fₛ : ℤ[[T]][T⁻¹]`. -/\n@[simps] def to_laurent_measures (F : invpoly r' S) : laurent_measures r' S :=\n{ to_fun := to_laurent_measures_fun r' S F,\n  summable' := λ s, begin\n    rw ← nnreal.summable_coe,\n    rw ← @summable_subtype_and_compl ℝ ℤ _ _ _ _ _ {n : ℤ | n ≤ 0},\n    split,\n    { have := F.nnreal_summable s,\n      rw ← nnreal.summable_coe at this,\n      convert (equiv.summable_iff (equiv.nonpos_ge_zero ℤ)).mpr _,\n      rotate,\n      { exact λ a, ((∥(F s).coeff (int.to_nat a)∥₊ * r' ^ (-(a.1))) : ℝ) },\n      rotate,\n      { apply funext,\n        rintros ⟨x, hx⟩,\n        rcases x with ⟨_ | x⟩ | x,\n        { refl },\n        { rw [int.of_nat_eq_coe, int.coe_nat_succ, set.mem_set_of_eq] at hx,\n          refine (not_lt.mpr hx _).elim,\n          exact int.add_pos_of_nonneg_of_pos (int.coe_zero_le x) zero_lt_one },\n        { simp only [subtype.coe_mk, zpow_neg_succ_of_nat, nonneg.coe_mul, coe_nnnorm,\n            nnreal.coe_pow, subtype.val_eq_coe, zpow_neg, function.comp_app, nnreal.coe_eq_zero,\n            equiv.nonpos_ge_zero_eval, inv_inv, inv_eq_zero, pow_eq_zero_iff, nat.succ_pos'],\n        congr } },\n      { refine (equiv.summable_iff (int_subtype_nonneg_equiv.symm : ℕ ≃ {z : ℤ // 0 ≤ z})).mp _,\n        simpa },\n      /- setup equiv with `ℕ` using `k → -k` and use `F.nnreal_summable s` -/ },\n    { convert summable_zero, ext ⟨((_|n)|n), hn⟩,\n      { simp only [int.of_nat_eq_coe, int.coe_nat_zero, le_refl, not_true, set.mem_compl_iff,\n          set.mem_set_of_eq] at hn,\n        exact hn.elim },\n      { erw [nnnorm_zero, zero_mul, nnreal.coe_zero], },\n      { simp only [not_le, int.neg_succ_not_pos, set.mem_compl_iff, set.mem_set_of_eq] at hn,\n        exact hn.elim }, },\n  end }\n\nopen_locale big_operators\n\n/-- The projection from a Laurent measure `Fₛ : ℤ[[T]][T⁻¹]` to `Fₛ : ℤ[T⁻¹]` obtained\nby throwing away all the positive terms. -/\ndef of_laurent_measures [fact (r' < 1)] (F : laurent_measures r' S) : invpoly r' S :=\nλ s, ∑ n in finset.range ((1 : ℤ) -(laurent_measures.exists_bdd_filtration\n  (show (0 : ℝ) < r', by norm_cast; exact fact.elim infer_instance)\n  (by norm_cast; exact fact.elim infer_instance) F).some).to_nat,\n  F s (-n) * polynomial.X^n\n\n-- move me\nopen polynomial finset\nlemma polynomial.sum_range_const_mul_X_pow_coeff {R : Type*} [semiring R]\n  (f : ℕ → R) (d n : ℕ) :\n(∑ i in range d, C (f i) * X^i).coeff n = if n < d then f n else 0 :=\nbegin\n  rw finset_sum_coeff,\n  split_ifs,\n  { suffices : ∀ b, (C (f b) * X ^ b).coeff n = if n = b then f b else 0,\n    { simp_rw this,\n      simp [h], },\n    intro i,\n    simp [coeff_X_pow] },\n  { refine sum_eq_zero (λ i hi, coeff_eq_zero_of_degree_lt _),\n    apply lt_of_le_of_lt (degree_mul_le _ _),\n    apply lt_of_le_of_lt (add_le_add (degree_C_le) (degree_X_pow_le i)),\n    norm_cast,\n    rw finset.mem_range at hi,\n    rw [zero_add],\n    exact lt_of_lt_of_le hi (le_of_not_lt h), },\nend\n\n-- ℤ[X] version without C\nlemma polynomial.sum_range_int_mul_X_pow_coeff (f : ℕ → ℤ) (d n : ℕ) :\n(∑ i in range d, (f i : polynomial ℤ) * X^i).coeff n = if n < d then f n else 0 :=\npolynomial.sum_range_const_mul_X_pow_coeff f d n\n\nlemma of_laurent_measures_strict [fact (r' < 1)] (F : laurent_measures r' S) :\n  ∥of_laurent_measures r' S F∥₊ ≤ ∥F∥₊ :=\nbegin\n  unfold has_nnnorm.nnnorm,\n  apply finset.sum_le_sum, rintro s -,\n  change tsum _ ≤ tsum _,\n  delta of_laurent_measures,\n  simp_rw polynomial.sum_range_int_mul_X_pow_coeff,\n  apply tsum_le_tsum_of_inj (λ (n : ℕ), -(n : ℤ)),\n  { intros a b h, simpa using h, },\n  { intros, apply zero_le, },\n  { intro i,\n    split_ifs,\n    { refl, },\n    convert zero_le _,\n    simp only [norm_zero, mul_eq_zero, nonneg.mk_eq_zero, eq_self_iff_true, true_or], },\n  { apply summable_of_ne_finset_zero,\n    intros i hi,\n    split_ifs,\n    { exfalso,\n      apply hi,\n      rw ← finset.mem_range at h,\n      exact h, },\n    { simp } },\n  { exact F.nnreal_summable s },\n  { apply_instance, }\nend\n\nlemma to_laurent_measures_of_laurent_measures [fact (r' < 1)] (F : invpoly r' S) :\n  of_laurent_measures r' S (to_laurent_measures r' S F) = F :=\nbegin\n  let d := (laurent_measures.exists_bdd_filtration\n    (show (0 : ℝ) < r', by norm_cast; exact fact.elim infer_instance)\n    (by norm_cast; exact fact.elim infer_instance) (to_laurent_measures r' S F)).some,\n  have hd : ∀ (s : S) (n : ℤ), n < d → (to_laurent_measures r' S F) s n = 0 :=\n    (laurent_measures.exists_bdd_filtration\n    (show (0 : ℝ) < r', by norm_cast; exact fact.elim infer_instance)\n    (by norm_cast; exact fact.elim infer_instance) (to_laurent_measures r' S F)).some_spec,\n  ext s n,\n  delta of_laurent_measures,\n  suffices : (∑ (n : ℕ) in range (1 - d).to_nat,\n    C (to_laurent_measures r' S F s (-↑n)) * X ^ n).coeff n =\n  (F s).coeff n,\n    simpa,\n  rw polynomial.sum_range_const_mul_X_pow_coeff,\n  rw ← to_laurent_measures_fun_nonpos,\n  split_ifs, refl,\n  symmetry,\n  apply hd,\n  push_neg at h,\n  rw int.to_nat_le at h,\n  linarith,\nend\n\n-- note: can't deduce immediately from `to_laurent_measures_of_laurent_measures`\n-- because `r' < 1` not assumed.\nlemma to_laurent_measures_injective : function.injective (to_laurent_measures r' S) :=\nbegin\n  intros F G h,\n  ext s (_|n),\n  { apply_fun (λ F, F s 0) at h, exact h },\n  { apply_fun (λ F, F s (-n.succ)) at h, exact h }\nend\n\ndef to_laurent_measures_addhom : invpoly r' S →+ laurent_measures r' S :=\nadd_monoid_hom.mk' (to_laurent_measures r' S) $\nbegin\n  intros F G, ext s ((_|n)|n),\n  { simp only [to_laurent_measures_fun, add_apply, int.of_nat_zero,\n      to_laurent_measures_to_fun, laurent_measures.add_apply, polynomial.coeff_add], },\n  { refl, },\n  { simp only [to_laurent_measures_fun, add_apply, to_laurent_measures_to_fun,\n      laurent_measures.add_apply, polynomial.coeff_add], }\nend\n\nlemma to_laurent_measures_addhom_isometry (p : invpoly r' S) :\n  ∥(to_laurent_measures_addhom r' S) p∥₊ = ∥p∥₊ :=\nbegin\n  unfold nnnorm,\n  congr',\n  ext s,\n  norm_cast,\n  refine tsum_eq_tsum_of_ne_zero_bij (λ n, -((n.1 : ℕ) : ℤ)) _ _ _,\n  { rintros ⟨x, _⟩ ⟨y, _⟩ h, simpa using h },\n  { intros n hn,\n    rw function.mem_support at hn,\n    rw set.mem_range,\n    rcases n with ((_|n)|n),\n    { exact ⟨⟨0, hn⟩, rfl⟩ },\n    { exfalso,\n      simpa [to_laurent_measures_addhom, to_laurent_measures_fun_pos'] using hn },\n    { exact ⟨⟨n+1, hn⟩, rfl⟩ } },\n  { rintro ⟨n, hn⟩,\n    simp only [to_laurent_measures_addhom, add_monoid_hom.mk'_apply, to_laurent_measures_to_fun, subtype.coe_mk, zpow_neg,\n      zpow_coe_nat, mul_eq_mul_right_iff, subtype.mk_eq_mk, inv_eq_zero],\n    left,\n    cases n with n,\n    { simp [to_laurent_measures_fun_zero], },\n    { simp only [to_laurent_measures_fun_neg'], } },\nend\n\ndef to_laurent_measures_hom [fact (r' < 1)]: comphaus_filtered_pseudo_normed_group_with_Tinv_hom r'\n  (invpoly r' S) (laurent_measures r' S) :=\n{ strict' := begin\n    rintros c p hp,\n    simp only [add_monoid_hom.to_fun_eq_coe, laurent_measures.mem_filtration_iff],\n    simp only [mem_filtration_iff] at hp,\n    rwa to_laurent_measures_addhom_isometry,\n  end,\n  continuous' := λ c, continuous_bot,\n  map_Tinv' := begin\n    intro F,\n    ext s z,\n    change to_laurent_measures_fun r' S (λ (s : ↥S), polynomial.X * F s) s z =\n      to_laurent_measures_fun r' S F s (z + 1),\n    rcases lt_trichotomy 0 z with (hz | rfl | hz),\n    { let n := (z - 1).nat_abs,\n      have hn : z - 1 = n := int.eq_nat_abs_of_zero_le (int.le_sub_one_of_lt hz),\n      rw sub_eq_iff_eq_add at hn,\n      rw [hn, to_laurent_measures_fun_pos', (by norm_cast : (n : ℤ) + 1 = (n + 1 : ℕ)),\n        to_laurent_measures_fun_pos'] },\n    { rw [to_laurent_measures_fun_zero, (by norm_cast : (0 : ℤ) + 1 = (0 + 1 : ℕ)),\n        to_laurent_measures_fun_pos],\n      simp only [polynomial.mul_coeff_zero, polynomial.coeff_X_zero, zero_mul] },\n    { let n := (z + 1).nat_abs,\n      have hn : (n : ℤ) = -(z + 1) := int.nat_abs_of_nonpos (int.add_one_le_of_lt hz),\n      rw eq_neg_iff_eq_neg at hn,\n      rw hn,\n      rw ← eq_sub_iff_add_eq at hn,\n      rw [hn, to_laurent_measures_fun_nonpos, (by {simp, ring} : -(n : ℤ) - 1 = -(n + 1 : ℕ)),\n        to_laurent_measures_fun_nonpos, polynomial.coeff_X_mul] },\n  end,\n  .. to_laurent_measures_addhom r' S }.\n\n@[simps]\ndef to_laurent_measures_nat_trans [fact (r' < 1)]:\n  Fintype_invpoly r' ⟶ Fintype_LaurentMeasures r' :=\n{ app := λ S, to_laurent_measures_hom r' S,\n  naturality' := λ S T f, begin\n    ext p t n,\n    classical,\n    suffices : to_laurent_measures_fun r' T (map f p) t n =\n      (finset.filter (λ (t_1 : S.α), f t_1 = t) finset.univ).sum (λ (x : S.α),\n        to_laurent_measures_fun r' S p x n),\n    simpa [to_laurent_measures_hom, to_laurent_measures_addhom],\n    rcases n with ((_ | n) | n),\n    { convert map_apply f p t 0, },\n    { simp only [int.of_nat_eq_coe, to_laurent_measures_fun_pos, finset.sum_const_zero] },\n    { convert map_apply f p t (n+1), }\n  end }\n\nend invpoly\n\nnamespace laurent_measures\n\n/-- `to_Lbar r S` is the function sending a Laurent measure `Fₛ : ℤ → ℤ` to its\ntruncation `Fₛ : {n ≥ 1} → ℤ` (often thought of as a power series `Fₛ ∈ Tℤ[[T]]`.) -/\n@[simps] def to_Lbar (F : laurent_measures r' S) : Lbar r' S :=\n{ to_fun := λ s n, if n = 0 then 0 else F s n,\n  coeff_zero' := λ s, if_pos rfl,\n  summable' := λ s, begin\n    have := nnreal.summable_comp_injective (F.nnreal_summable s) int.coe_nat_injective,\n    refine nnreal.summable_of_le _ this,\n    intros n,\n    split_ifs,\n    { simp only [int.nat_abs_zero, nat.cast_zero, zero_mul, zero_le'] },\n    { simp only [function.comp_app, nnreal.coe_nat_abs, zpow_coe_nat] }\n  end }\n\n/-- `to_Lbar_section r S` is the natural inclusion from `Lbar r S` to `laurent_measures r S`\nsending a power series `Fₛ : {n≥1} → ℤ` to the associated function `Fₛ : ℤ → ℤ` which\nvanishes on non-positive integers. -/\ndef to_Lbar_section (G : Lbar r' S) : laurent_measures r' S :=\n⟨λ s n, G s n.to_nat,\nbegin\n  intro s,\n  refine (nnreal.summable_iff_on_nat_less 0 (λ n n0, _)).mpr _,\n  { simp [int.to_nat_of_nonpos n0.le] },\n  { simp only [int.to_nat_coe_nat, zpow_coe_nat],\n    simpa only [← nnreal.coe_nat_abs] using G.summable' s }\nend⟩\n\nlemma to_Lbar_section_to_Lbar (G : Lbar r' S) :\n  to_Lbar r' S (to_Lbar_section r' S G) = G :=\nbegin\n  ext s (_|n),\n  { exact (G.coeff_zero s).symm },\n  { show ite (n.succ = 0) 0 (G s (n + 1)) = G s n.succ, from if_neg n.succ_ne_zero }\nend\n\nlemma tsum_nat_eq_tsum_int {α : Type*} [add_comm_monoid α] [topological_space α]\n  [t2_space α]\n  (f : ℤ → α) : ∑' (n : ℕ), f n = ∑' (z : ℤ), if z < 0 then 0 else f z :=\nlet e : ↥(function.support (λ (x : ℕ), f ↑x)) ≃\n  ↥(function.support (λ (y : ℤ), ite (y < 0) 0 (f y))) :=\n{ to_fun := λ x, ⟨x, x.2⟩,\n  inv_fun := λ y, ⟨y.1.nat_abs, λ h, begin\n    cases y with y hy,\n    apply hy,\n    dsimp only,\n    split_ifs, refl,\n    convert h,\n    exact int.eq_nat_abs_of_zero_le (le_of_not_lt h_1),\n  end⟩,\n  left_inv := begin\n    rintro ⟨x, hx⟩,\n    refl,\n  end,\n  right_inv := begin\n    rintro ⟨y, hy⟩,\n    simp only [coe_coe, subtype.coe_mk, subtype.mk_eq_mk],\n    refine (int.eq_nat_abs_of_zero_le _).symm,\n    by_contra h,\n    push_neg at h,\n    apply hy,\n    dsimp only,\n    rw if_pos h,\n  end } in\nbegin\n  apply equiv.tsum_eq_tsum_of_support e,\n  rintros ⟨x, hx⟩,\n  have hx2 : ¬ ((x : ℤ) < 0) := λ h, nat.not_lt_zero x (int.coe_nat_lt.1 h),\n  simp [hx2],\nend\n\nlemma to_Lbar_section_mem_filtration (G : Lbar r' S) (c : ℝ≥0)\n  (hG : G ∈ pseudo_normed_group.filtration (Lbar r' S) c) :\n  to_Lbar_section r' S G ∈ pseudo_normed_group.filtration (laurent_measures r' S) c :=\nbegin\n  change _ ≤ _,\n  convert (hG : _ ≤ _) using 1,\n  change finset.univ.sum _ = finset.univ.sum _,\n  congr' 1, ext s, norm_cast,\n  symmetry,\n  convert tsum_nat_eq_tsum_int (λ n, ∥G s n.to_nat∥₊ * r' ^ n),\n  { ext n,\n    simp only [int.nat_abs, nonneg.coe_mul, nnreal.coe_nat_cast, nnreal.coe_pow,\n      int.to_nat_coe_nat, zpow_coe_nat, coe_nnnorm, mul_eq_mul_right_iff,\n      int.nat_abs, _root_.coe_nnnorm, int.norm_eq_abs, int.cast_nat_abs],\n    left, refl,\n  },\n  { ext z,\n    simp only [to_Lbar_section, coe_mk, nonneg.coe_mul, coe_nnnorm, nnreal.coe_zpow],\n    split_ifs,\n    { simp [int.to_nat_of_nonpos h.le, G.coeff_zero] },\n    { simp } },\nend\n\nlemma to_Lbar_surjective : function.surjective (to_Lbar r' S) :=\nλ G, ⟨to_Lbar_section r' S G, to_Lbar_section_to_Lbar r' S G⟩\n\nlemma nnnorm_to_Lbar (F : laurent_measures r' S) : ∥to_Lbar r' S F∥₊ ≤ ∥F∥₊ :=\nbegin\n  rw [nnnorm_def, Lbar.nnnorm_def],\n  refine finset.sum_le_sum (λ s hs, _),\n  have := nnreal.summable_comp_injective (F.nnreal_summable s) int.coe_nat_injective,\n  refine (tsum_le_tsum _ ((to_Lbar r' S F).summable s) this).trans\n    (nnreal.tsum_comp_le_tsum_of_inj (F.nnreal_summable s) int.coe_nat_injective),\n  intro n,\n  simp only [nnreal.coe_nat_abs, to_Lbar_to_fun, function.comp_app, zpow_coe_nat],\n  split_ifs, { rw [nnnorm_zero, zero_mul], exact zero_le' }, { refl }\nend\n\n/-- `to_Lbar_hom` is the `comphaus_filtered_pseudo_normed_group_with_Tinv_hom` version\nof `to_Lbar r S`, the function which truncates a Laurent power series in `ℤ[[T]][1/T]`\nto its positive terms in `Tℤ[[T]]`. -/\n@[simps] def to_Lbar_hom : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r'\n  (laurent_measures r' S) (Lbar r' S) :=\n{ to_fun := to_Lbar r' S,\n  map_zero' := by { ext,\n    simp only [to_Lbar_to_fun, zero_apply, if_t_t, Lbar.coe_zero, pi.zero_apply], },\n  map_add' := λ F G, by { ext, simp only [to_Lbar_to_fun, add_apply, Lbar.coe_add, pi.add_apply],\n    split_ifs, { rw add_zero }, { refl } },\n  strict' := λ c F (hF : ∥F∥₊ ≤ c), (nnnorm_to_Lbar r' S F).trans hF,\n  continuous' := λ c, begin\n    let f : _ := _, show continuous f,\n    rw Lbar_le.continuous_iff,\n    intros N,\n    let e : ℕ ↪ ℤ := ⟨coe, int.coe_nat_injective⟩,\n    let T : finset ℤ := (finset.range (N + 1)).map e,\n    let g : laurent_measures_bdd r' S T c → Lbar_bdd r' ⟨S⟩ c N := λ F,\n    { to_fun := λ s n, if n = 0 then 0 else F s ⟨n, _⟩,\n      coeff_zero' := λ s, if_pos rfl,\n      sum_le' := _ },\n    have : Lbar_le.truncate N ∘ f = g ∘ truncate T,\n    { dsimp [f], ext F s ⟨(_|n), hn⟩, { simp only [fin.mk_zero, Lbar_bdd.coeff_zero], },\n      simp only [Lbar_le.truncate_to_fun, Lbar_bdd.coe_mk, coe_coe, int.coe_nat_succ,\n        truncate_to_fun, subtype.coe_mk, subtype.ext_iff, fin.coe_zero, nat.succ_ne_zero, if_false],\n      exact to_Lbar_to_fun r' S F s (n+1), },\n    { rw this, exact continuous_of_discrete_topology.comp (truncate_continuous _ _ _ _) },\n    { simpa only [coe_coe, finset.mem_map, finset.mem_range, function.embedding.coe_fn_mk,\n        int.coe_nat_inj', exists_prop, exists_eq_right] using n.2, },\n    { cases S, refine le_trans (finset.sum_le_sum _) F.bound, dsimp,\n      rintro s -,\n      erw [finset.sum_attach', finset.sum_map, ← fin.sum_univ_eq_sum_range],\n      refine finset.sum_le_sum (λ i hi, _),\n      simp only [finset.mem_map, finset.mem_range, exists_prop, exists_eq_right, nnreal.coe_nat_abs,\n        embedding_like.apply_eq_iff_eq, function.embedding.coe_fn_mk, subtype.coe_mk, zpow_coe_nat],\n      rw dif_pos, swap, { exact i.2 },\n      split_ifs, { rw [nnnorm_zero, zero_mul], exact zero_le' }, { refl } }\n  end,\n  map_Tinv' := λ F, begin\n    erw [Tinv_apply, Lbar.Tinv_apply],\n    ext s (_|n),\n    { simp only [to_Lbar_to_fun, eq_self_iff_true, if_true, Lbar.Tinv_zero], },\n    { simp only [to_Lbar_to_fun, nat.succ_ne_zero, int.coe_nat_succ, shift_to_fun_to_fun,\n        Lbar.Tinv_succ], }\n  end }\n\n@[simps]\ndef to_Lbar_nat_trans : Fintype_LaurentMeasures r' ⟶ Fintype_Lbar r' :=\n{ app := λ S, to_Lbar_hom r' S,\n  naturality' := λ S₁ S₂ f, begin\n    ext,\n    simp only [Fintype_LaurentMeasures_map, category_theory.comp_apply, to_Lbar_hom_to_fun, to_Lbar_to_fun,\n      Fintype_Lbar_map_to_fun, Lbar.map_to_fun, map_hom, map_apply,\n      comphaus_filtered_pseudo_normed_group_with_Tinv_hom.coe_mk],\n    split_ifs, { simp only [finset.sum_const_zero], }, { refl }\n  end }\n.\n\nend laurent_measures\n\nnamespace Lbar\n\nopen category_theory ProFiltPseuNormGrpWithTinv₁\n\ntheorem short_exact (S : Profinite) [fact (r' < 1)] :\n  short_exact\n    ((condensify_map\n      (whisker_right (invpoly.to_laurent_measures_nat_trans r') (PFPNGT₁_to_CHFPNG₁ₑₗ r'))).app S)\n    ((condensify_map\n      (whisker_right (laurent_measures.to_Lbar_nat_trans r') (PFPNGT₁_to_CHFPNG₁ₑₗ r'))).app S) :=\nbegin\n  refine condensify_exact _ _ id id le_rfl le_rfl _ _ _ _ S,\n  { apply invpoly.to_laurent_measures_injective },\n  { intro S, ext F s (_|n); refl, },\n  { rintro S c F ⟨hF1, hF2⟩,\n    simp only [whisker_right_app, laurent_measures.to_Lbar_nat_trans_app, functor.comp_map,\n      set.mem_preimage, set.mem_singleton_iff] at hF1 hF2,\n    change laurent_measures.to_Lbar r' S F = 0 at hF1,\n    change F ∈ pseudo_normed_group.filtration (laurent_measures r' S) c at hF2,\n    show F ∈ invpoly.to_laurent_measures r' S ''\n      (pseudo_normed_group.filtration (invpoly r' S) c),\n    have hd := laurent_measures.bdd_filtration_spec\n      (show (0 : ℝ) < r', by norm_cast; exact fact.elim infer_instance)\n      (by norm_cast; exact fact.elim infer_instance)\n      F,\n    refine ⟨invpoly.of_laurent_measures r' S F, _, _⟩,\n    { change ∥_∥₊ ≤ c,\n      change ∥_∥₊ ≤ c at hF2,\n      exact le_trans (invpoly.of_laurent_measures_strict r' S F) hF2 },\n    { ext s n,\n      change invpoly.to_laurent_measures_fun r' S _ s _ = _,\n      rcases n with (_|n)|n,\n      {\n        change invpoly.to_laurent_measures_fun r' S _ s 0 = _,\n        delta invpoly.of_laurent_measures,\n        rw [invpoly.to_laurent_measures_fun_zero, invpoly.polynomial.sum_range_int_mul_X_pow_coeff],\n        split_ifs, refl,\n        push_neg at h,\n        rw [int.to_nat_le, sub_le_iff_le_add, int.coe_nat_zero, zero_add] at h,\n        symmetry,\n        apply hd,\n        rwa int.lt_iff_add_one_le },\n      { change invpoly.to_laurent_measures_fun r' S _ s (n + 1 : ℕ) = _,\n        rw invpoly.to_laurent_measures_fun_pos,\n        unfold laurent_measures.to_Lbar at hF1,\n        rw ext_iff at hF1,\n        symmetry,\n        convert congr_fun (congr_fun hF1 s) (n + 1) },\n      { rw invpoly.to_laurent_measures_fun_neg,\n        delta invpoly.of_laurent_measures,\n        rw invpoly.polynomial.sum_range_int_mul_X_pow_coeff,\n        split_ifs, refl,\n        symmetry,\n        apply hd,\n        push_neg at h,\n        rw [int.to_nat_le, sub_le_iff_le_add', int.coe_nat_add, ← add_assoc, int.coe_nat_one,\n          le_add_iff_nonneg_left] at h,\n        rwa [int.neg_succ_of_nat_coe', int.lt_iff_add_one_le, sub_add_cancel,\n          neg_le_iff_add_nonneg] }, } },\n  { rintro S c F hF,\n    refine ⟨laurent_measures.to_Lbar_section r' S F, _, _⟩,\n    { apply laurent_measures.to_Lbar_section_mem_filtration,\n      exact pseudo_normed_group.filtration_mono le_rfl hF, },\n    { apply laurent_measures.to_Lbar_section_to_Lbar } }\nend\n\nend Lbar\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/Lbar/ses.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390162, "lm_q2_score": 0.626124191181315, "lm_q1q2_score": 0.46344107376482485}}
{"text": "import data.nat.basic\n\nuniverse u\n\ndef string.drop_chars (c : char) (s : string) : string := \n⟨s.data.drop_while (λ x, x = c)⟩ \n\ndef string.reverse (s : string) : string := ⟨s.data.reverse⟩ \n\ndef update (α : Type u) (k : nat) (a : α) (f : nat → α) : nat → α := \nλ x : nat, if x = k then a else f x\n\nlemma forall_lt_zero (p : nat → Prop) : ∀ x < 0, p x := \nλ x h, by cases h\n\naxiom any {P : Prop} : P\n\nlemma forall_lt_succ (p : nat → Prop) (k : nat) : \n  p k → (∀ x < k, p x) → (∀ x < k.succ, p x) := \nbegin\n  intros h1 h2 m h3,\n  apply or.elim (nat.lt_succ_iff_lt_or_eq.elim_left h3); intro h4,\n  apply h2 m h4, \n  apply @eq.rec _ _ p h1 _ h4.symm, \nend\n\nlemma forall_lt_succ_iff (p : nat → Prop) (k : nat) : \n  (∀ x < k.succ, p x) ↔ (p k ∧ (∀ x < k, p x)) := \niff.intro \n  (λ h, ⟨ h k (nat.lt_succ_self k), \n          λ x h2, h x (lt.trans h2 (nat.lt_succ_self k))⟩) \n  (λ h, forall_lt_succ p k h.left h.right)\n\ninstance forall_lt.decidable (p : nat → Prop) [decidable_pred p] : \n  ∀ k : nat, decidable (∀ x < k, p x) \n| 0     := decidable.is_true (forall_lt_zero p)\n| (k+1) := decidable_of_iff' _ (forall_lt_succ_iff p k)\n\nopen tactic\n\nmeta def get_default (αx : expr) : tactic expr := \nto_expr ``(@inhabited.default %%αx _)\n", "meta": {"author": "skbaek", "repo": "cvx", "sha": "c50c790c9116f9fac8dfe742903a62bdd7292c15", "save_path": "github-repos/lean/skbaek-cvx", "path": "github-repos/lean/skbaek-cvx/cvx-c50c790c9116f9fac8dfe742903a62bdd7292c15/src/misc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46330181806109033}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Andrew Yang\n-/\nimport category_theory.monoidal.functor\n\n/-!\n# Endofunctors as a monoidal category.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe give the monoidal category structure on `C ⥤ C`,\nand show that when `C` itself is monoidal, it embeds via a monoidal functor into `C ⥤ C`.\n\n## TODO\n\nCan we use this to show coherence results, e.g. a cheap proof that `λ_ (𝟙_ C) = ρ_ (𝟙_ C)`?\nI suspect this is harder than is usually made out.\n-/\n\nuniverses v u\n\nnamespace category_theory\n\nvariables (C : Type u) [category.{v} C]\n\n/--\nThe category of endofunctors of any category is a monoidal category,\nwith tensor product given by composition of functors\n(and horizontal composition of natural transformations).\n-/\ndef endofunctor_monoidal_category : monoidal_category (C ⥤ C) :=\n{ tensor_obj   := λ F G, F ⋙ G,\n  tensor_hom   := λ F G F' G' α β, α ◫ β,\n  tensor_unit  := 𝟭 C,\n  associator   := λ F G H, functor.associator F G H,\n  left_unitor  := λ F, functor.left_unitor F,\n  right_unitor := λ F, functor.right_unitor F, }.\n\nopen category_theory.monoidal_category\n\nlocal attribute [instance] endofunctor_monoidal_category\nlocal attribute [reducible] endofunctor_monoidal_category\n\n/--\nTensoring on the right gives a monoidal functor from `C` into endofunctors of `C`.\n-/\n@[simps]\ndef tensoring_right_monoidal [monoidal_category.{v} C] : monoidal_functor C (C ⥤ C) :=\n{ ε := (right_unitor_nat_iso C).inv,\n  μ := λ X Y,\n  { app := λ Z, (α_ Z X Y).hom,\n    naturality' := λ Z Z' f, by { dsimp, rw associator_naturality, simp, } },\n  μ_natural' := λ X Y X' Y' f g, by { ext Z, dsimp,\n    simp only [←id_tensor_comp_tensor_id g f, id_tensor_comp, ←tensor_id, category.assoc,\n      associator_naturality, associator_naturality_assoc], },\n  associativity' := λ X Y Z, by { ext W, dsimp, simp [pentagon], },\n  left_unitality' := λ X, by { ext Y, dsimp, rw [category.id_comp, triangle, ←tensor_comp], simp, },\n  right_unitality' := λ X,\n  begin\n    ext Y, dsimp,\n    rw [tensor_id, category.comp_id, right_unitor_tensor_inv, category.assoc, iso.inv_hom_id_assoc,\n      ←id_tensor_comp, iso.inv_hom_id, tensor_id],\n  end,\n  ε_is_iso := by apply_instance,\n  μ_is_iso := λ X Y,\n    -- We could avoid needing to do this explicitly by\n    -- constructing a partially applied analogue of `associator_nat_iso`.\n  ⟨⟨{ app := λ Z, (α_ Z X Y).inv,\n      naturality' := λ Z Z' f, by { dsimp, rw ←associator_inv_naturality, simp, } },\n    by tidy⟩⟩,\n  ..tensoring_right C }.\n\nvariable {C}\nvariables {M : Type*} [category M] [monoidal_category M] (F : monoidal_functor M (C ⥤ C))\n\n@[simp, reassoc]\nlemma μ_hom_inv_app (i j : M) (X : C) :\n  (F.μ i j).app X ≫ (F.μ_iso i j).inv.app X = 𝟙 _ := (F.μ_iso i j).hom_inv_id_app X\n\n@[simp, reassoc]\nlemma μ_inv_hom_app (i j : M) (X : C) :\n   (F.μ_iso i j).inv.app X ≫ (F.μ i j).app X = 𝟙 _ := (F.μ_iso i j).inv_hom_id_app X\n\n@[simp, reassoc]\nlemma ε_hom_inv_app (X : C) :\n  F.ε.app X ≫ F.ε_iso.inv.app X = 𝟙 _ := F.ε_iso.hom_inv_id_app X\n\n@[simp, reassoc]\nlemma ε_inv_hom_app (X : C) :\n  F.ε_iso.inv.app X ≫ F.ε.app X = 𝟙 _ := F.ε_iso.inv_hom_id_app X\n\n@[simp, reassoc]\nlemma ε_naturality {X Y : C} (f : X ⟶ Y) :\n  F.ε.app X ≫ (F.obj (𝟙_M)).map f = f ≫ F.ε.app Y := (F.ε.naturality f).symm\n\n@[simp, reassoc]\nlemma ε_inv_naturality {X Y : C} (f : X ⟶ Y) :\n  (F.obj (𝟙_M)).map f ≫ F.ε_iso.inv.app Y = F.ε_iso.inv.app X ≫ f :=\nF.ε_iso.inv.naturality f\n\n@[simp, reassoc]\nlemma μ_naturality {m n : M} {X Y : C} (f : X ⟶ Y) :\n  (F.obj n).map ((F.obj m).map f) ≫ (F.μ m n).app Y = (F.μ m n).app X ≫ (F.obj _).map f :=\n(F.to_lax_monoidal_functor.μ m n).naturality f\n\n-- This is a simp lemma in the reverse direction via `nat_trans.naturality`.\n@[reassoc]\nlemma μ_inv_naturality {m n : M} {X Y : C} (f : X ⟶ Y) :\n  (F.μ_iso m n).inv.app X ≫ (F.obj n).map ((F.obj m).map f) =\n    (F.obj _).map f ≫ (F.μ_iso m n).inv.app Y :=\n((F.μ_iso m n).inv.naturality f).symm\n\n-- This is not a simp lemma since it could be proved by the lemmas later.\n@[reassoc]\nlemma μ_naturality₂ {m n m' n' : M} (f : m ⟶ m') (g : n ⟶ n') (X : C) :\n  (F.map g).app ((F.obj m).obj X) ≫ (F.obj n').map ((F.map f).app X) ≫ (F.μ m' n').app X =\n    (F.μ m n).app X ≫ (F.map (f ⊗ g)).app X :=\nbegin\n  have := congr_app (F.to_lax_monoidal_functor.μ_natural f g) X,\n  dsimp at this,\n  simpa using this,\nend\n\n@[simp, reassoc]\nlemma μ_naturalityₗ {m n m' : M} (f : m ⟶ m') (X : C) :\n  (F.obj n).map ((F.map f).app X) ≫ (F.μ m' n).app X =\n    (F.μ m n).app X ≫ (F.map (f ⊗ 𝟙 n)).app X :=\nbegin\n  rw ← μ_naturality₂ F f (𝟙 n) X,\n  simp,\nend\n\n@[simp, reassoc]\nlemma μ_naturalityᵣ {m n n' : M} (g : n ⟶ n') (X : C) :\n  (F.map g).app ((F.obj m).obj X) ≫ (F.μ m n').app X =\n    (F.μ m n).app X ≫ (F.map (𝟙 m ⊗ g)).app X :=\nbegin\n  rw ← μ_naturality₂ F (𝟙 m) g X,\n  simp,\nend\n\n@[simp, reassoc]\nlemma μ_inv_naturalityₗ {m n m' : M} (f : m ⟶ m') (X : C) :\n  (F.μ_iso m n).inv.app X ≫ (F.obj n).map ((F.map f).app X) =\n    (F.map (f ⊗ 𝟙 n)).app X ≫ (F.μ_iso m' n).inv.app X :=\nbegin\n  rw [← is_iso.comp_inv_eq, category.assoc, ← is_iso.eq_inv_comp],\n  simp,\nend\n\n@[simp, reassoc]\nlemma μ_inv_naturalityᵣ {m n n' : M} (g : n ⟶ n') (X : C) :\n  (F.μ_iso m n).inv.app X ≫ (F.map g).app ((F.obj m).obj X) =\n    (F.map (𝟙 m ⊗ g)).app X ≫ (F.μ_iso m n').inv.app X :=\nbegin\n  rw [← is_iso.comp_inv_eq, category.assoc, ← is_iso.eq_inv_comp],\n  simp,\nend\n\n@[reassoc]\nlemma left_unitality_app (n : M) (X : C) :\n  (F.obj n).map (F.ε.app X) ≫ (F.μ (𝟙_M) n).app X\n    ≫ (F.map (λ_ n).hom).app X = 𝟙 _ :=\nbegin\n  have := congr_app (F.to_lax_monoidal_functor.left_unitality n) X,\n  dsimp at this,\n  simpa using this.symm,\nend\n\n@[reassoc, simp]\nlemma obj_ε_app (n : M) (X : C) :\n  (F.obj n).map (F.ε.app X) =\n    (F.map (λ_ n).inv).app X ≫ (F.μ_iso (𝟙_M) n).inv.app X :=\nbegin\n  refine eq.trans _ (category.id_comp _),\n  rw [← category.assoc, ← is_iso.comp_inv_eq, ← is_iso.comp_inv_eq, category.assoc],\n  convert left_unitality_app F n X,\n  { simp },\n  { ext, simpa }\nend\n\n@[reassoc, simp]\n\n\n@[reassoc]\nlemma right_unitality_app (n : M) (X : C) :\n  F.ε.app ((F.obj n).obj X) ≫ (F.μ n (𝟙_M)).app X ≫ (F.map (ρ_ n).hom).app X = 𝟙 _ :=\nbegin\n  have := congr_app (F.to_lax_monoidal_functor.right_unitality n) X,\n  dsimp at this,\n  simpa using this.symm,\nend\n\n@[simp]\nlemma ε_app_obj (n : M) (X : C) :\n  F.ε.app ((F.obj n).obj X) =\n    (F.map (ρ_ n).inv).app X ≫ (F.μ_iso n (𝟙_M)).inv.app X :=\nbegin\n  refine eq.trans _ (category.id_comp _),\n  rw [← category.assoc, ← is_iso.comp_inv_eq, ← is_iso.comp_inv_eq, category.assoc],\n  convert right_unitality_app F n X,\n  { simp },\n  { ext, simpa }\nend\n\n@[simp]\nlemma ε_inv_app_obj (n : M) (X : C) :\n  F.ε_iso.inv.app ((F.obj n).obj X) =\n    (F.μ n (𝟙_M)).app X ≫ (F.map (ρ_ n).hom).app X :=\nbegin\n  rw [← cancel_mono (F.ε.app ((F.obj n).obj X)), ε_inv_hom_app],\n  simpa\nend\n\n@[reassoc]\nlemma associativity_app (m₁ m₂ m₃: M) (X : C) :\n  (F.obj m₃).map ((F.μ m₁ m₂).app X) ≫ (F.μ (m₁ ⊗ m₂) m₃).app X ≫\n    (F.map (α_ m₁ m₂ m₃).hom).app X =\n  (F.μ m₂ m₃).app ((F.obj m₁).obj X) ≫ (F.μ m₁ (m₂ ⊗ m₃)).app X :=\nbegin\n  have := congr_app (F.to_lax_monoidal_functor.associativity m₁ m₂ m₃) X,\n  dsimp at this,\n  simpa using this,\nend\n\n@[reassoc, simp]\nlemma obj_μ_app (m₁ m₂ m₃ : M) (X : C) :\n  (F.obj m₃).map ((F.μ m₁ m₂).app X) =\n  (F.μ m₂ m₃).app ((F.obj m₁).obj X) ≫ (F.μ m₁ (m₂ ⊗ m₃)).app X ≫\n    (F.map (α_ m₁ m₂ m₃).inv).app X ≫ (F.μ_iso (m₁ ⊗ m₂) m₃).inv.app X :=\nbegin\n  rw [← associativity_app_assoc],\n  dsimp,\n  simp,\n  dsimp,\n  simp,\nend\n\n@[reassoc, simp]\nlemma obj_μ_inv_app (m₁ m₂ m₃ : M) (X : C) :\n  (F.obj m₃).map ((F.μ_iso m₁ m₂).inv.app X) =\n  (F.μ (m₁ ⊗ m₂) m₃).app X ≫ (F.map (α_ m₁ m₂ m₃).hom).app X ≫\n  (F.μ_iso m₁ (m₂ ⊗ m₃)).inv.app X ≫\n  (F.μ_iso m₂ m₃).inv.app ((F.obj m₁).obj X) :=\nbegin\n  rw ← is_iso.inv_eq_inv,\n  convert obj_μ_app F m₁ m₂ m₃ X using 1,\n  { ext, rw ← functor.map_comp, simp },\n  { simp only [monoidal_functor.μ_iso_hom, category.assoc, nat_iso.inv_inv_app, is_iso.inv_comp],\n    congr,\n    { ext, simp },\n    { ext, simpa } }\nend\n\n@[simp, reassoc]\nlemma obj_zero_map_μ_app {m : M} {X Y : C} (f : X ⟶ (F.obj m).obj Y) :\n  (F.obj (𝟙_M)).map f ≫ (F.μ m (𝟙_M)).app _ =\n    F.ε_iso.inv.app _ ≫ f ≫ (F.map (ρ_ m).inv).app _ :=\nbegin\n  rw [← is_iso.inv_comp_eq, ← is_iso.comp_inv_eq],\n  simp,\nend\n\n@[simp]\nlemma obj_μ_zero_app (m₁ m₂ : M) (X : C) :\n  (F.obj m₂).map ((F.μ m₁ (𝟙_M)).app X) =\n  (F.μ (𝟙_M) m₂).app ((F.obj m₁).obj X) ≫ (F.map (λ_ m₂).hom).app ((F.obj m₁).obj X) ≫\n    (F.obj m₂).map ((F.map (ρ_ m₁).inv).app X) :=\nbegin\n  rw [← obj_ε_inv_app_assoc, ← functor.map_comp],\n  congr, simp,\nend\n\n/-- If `m ⊗ n ≅ 𝟙_M`, then `F.obj m` is a left inverse of `F.obj n`. -/\n@[simps] noncomputable\ndef unit_of_tensor_iso_unit (m n : M) (h : m ⊗ n ≅ 𝟙_M) : F.obj m ⋙ F.obj n ≅ 𝟭 C :=\nF.μ_iso m n ≪≫ F.to_functor.map_iso h ≪≫ F.ε_iso.symm\n\n/-- If `m ⊗ n ≅ 𝟙_M` and `n ⊗ m ≅ 𝟙_M` (subject to some commuting constraints),\n  then `F.obj m` and `F.obj n` forms a self-equivalence of `C`. -/\n@[simps] noncomputable\ndef equiv_of_tensor_iso_unit (m n : M) (h₁ : m ⊗ n ≅ 𝟙_M) (h₂ : n ⊗ m ≅ 𝟙_M)\n  (H : (h₁.hom ⊗ 𝟙 m) ≫ (λ_ m).hom = (α_ m n m).hom ≫ (𝟙 m ⊗ h₂.hom) ≫ (ρ_ m).hom) : C ≌ C :=\n{ functor := F.obj m,\n  inverse := F.obj n,\n  unit_iso := (unit_of_tensor_iso_unit F m n h₁).symm,\n  counit_iso := unit_of_tensor_iso_unit F n m h₂,\n  functor_unit_iso_comp' :=\n  begin\n    intro X,\n    dsimp,\n    simp only [μ_naturalityᵣ_assoc, μ_naturalityₗ_assoc, ε_inv_app_obj, category.assoc,\n      obj_μ_inv_app, functor.map_comp, μ_inv_hom_app_assoc, obj_ε_app,\n      unit_of_tensor_iso_unit_inv_app],\n    simp [← nat_trans.comp_app, ← F.to_functor.map_comp, ← H, - functor.map_comp]\n  end }\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/monoidal/End.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46330181806109033}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.comma\n\n/-!\n# The category of arrows\n\nThe category of arrows, with morphisms commutative squares.\nWe set this up as a specialization of the comma category `comma L R`,\nwhere `L` and `R` are both the identity functor.\n\nWe also define the typeclass `has_lift`, representing a choice of a lift\nof a commutative square (that is, a diagonal morphism making the two triangles commute).\n\n## Tags\n\ncomma, arrow\n-/\n\nnamespace category_theory\n\nuniverses v u -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u} [category.{v} T]\n\nsection\nvariables (T)\n\n/-- The arrow category of `T` has as objects all morphisms in `T` and as morphisms commutative\n     squares in `T`. -/\n@[derive category]\ndef arrow := comma.{v v v} (𝟭 T) (𝟭 T)\n\n-- Satisfying the inhabited linter\ninstance arrow.inhabited [inhabited T] : inhabited (arrow T) :=\n{ default := show comma (𝟭 T) (𝟭 T), from default }\n\nend\n\nnamespace arrow\n\n@[simp] lemma id_left (f : arrow T) : comma_morphism.left (𝟙 f) = 𝟙 (f.left) := rfl\n@[simp] lemma id_right (f : arrow T) : comma_morphism.right (𝟙 f) = 𝟙 (f.right) := rfl\n\n/-- An object in the arrow category is simply a morphism in `T`. -/\n@[simps]\ndef mk {X Y : T} (f : X ⟶ Y) : arrow T :=\n{ left := X,\n  right := Y,\n  hom := f }\n\ntheorem mk_injective (A B : T) :\n  function.injective (arrow.mk : (A ⟶ B) → arrow T) :=\nλ f g h, by { cases h, refl }\n\ntheorem mk_inj (A B : T) {f g : A ⟶ B} : arrow.mk f = arrow.mk g ↔ f = g :=\n(mk_injective A B).eq_iff\ninstance {X Y : T} : has_coe (X ⟶ Y) (arrow T) := ⟨mk⟩\n\n/-- A morphism in the arrow category is a commutative square connecting two objects of the arrow\n    category. -/\n@[simps]\ndef hom_mk {f g : arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}\n  (w : u ≫ g.hom = f.hom ≫ v) : f ⟶ g :=\n{ left := u,\n  right := v,\n  w' := w }\n\n/-- We can also build a morphism in the arrow category out of any commutative square in `T`. -/\n@[simps]\ndef hom_mk' {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}\n  (w : u ≫ g = f ≫ v) : arrow.mk f ⟶ arrow.mk g :=\n{ left := u,\n  right := v,\n  w' := w }\n\n@[simp, reassoc] lemma w {f g : arrow T} (sq : f ⟶ g) : sq.left ≫ g.hom = f.hom ≫ sq.right := sq.w\n\n-- `w_mk_left` is not needed, as it is a consequence of `w` and `mk_hom`.\n@[simp, reassoc] lemma w_mk_right {f : arrow T} {X Y : T} {g : X ⟶ Y} (sq : f ⟶ mk g) :\n  sq.left ≫ g = f.hom ≫ sq.right :=\nsq.w\n\nlemma is_iso_of_iso_left_of_is_iso_right\n  {f g : arrow T} (ff : f ⟶ g) [is_iso ff.left] [is_iso ff.right] : is_iso ff :=\n{ out := ⟨⟨inv ff.left, inv ff.right⟩,\n          by { ext; dsimp; simp only [is_iso.hom_inv_id] },\n          by { ext; dsimp; simp only [is_iso.inv_hom_id] }⟩ }\n\n/-- Create an isomorphism between arrows,\nby providing isomorphisms between the domains and codomains,\nand a proof that the square commutes. -/\n@[simps] def iso_mk {f g : arrow T}\n  (l : f.left ≅ g.left) (r : f.right ≅ g.right) (h : l.hom ≫ g.hom = f.hom ≫ r.hom) :\n  f ≅ g :=\ncomma.iso_mk l r h\n\nsection\n\nvariables {f g : arrow T} (sq : f ⟶ g)\n\ninstance is_iso_left [is_iso sq] : is_iso sq.left :=\n{ out := ⟨(inv sq).left, by simp only [← comma.comp_left, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_left, eq_self_iff_true, and_self]⟩ }\n\ninstance is_iso_right [is_iso sq] : is_iso sq.right :=\n{ out := ⟨(inv sq).right, by simp only [← comma.comp_right, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_right, eq_self_iff_true, and_self]⟩ }\n\n@[simp] lemma inv_left [is_iso sq] : (inv sq).left = inv sq.left :=\nis_iso.eq_inv_of_hom_inv_id $ by rw [← comma.comp_left, is_iso.hom_inv_id, id_left]\n\n@[simp] lemma inv_right [is_iso sq] : (inv sq).right = inv sq.right :=\nis_iso.eq_inv_of_hom_inv_id $ by rw [← comma.comp_right, is_iso.hom_inv_id, id_right]\n\n@[simp] lemma left_hom_inv_right [is_iso sq] : sq.left ≫ g.hom ≫ inv sq.right = f.hom :=\nby simp only [← category.assoc, is_iso.comp_inv_eq, w]\n\n-- simp proves this\nlemma inv_left_hom_right [is_iso sq] : inv sq.left ≫ f.hom ≫ sq.right = g.hom :=\nby simp only [w, is_iso.inv_comp_eq]\n\ninstance mono_left [mono sq] : mono sq.left :=\n{ right_cancellation := λ Z φ ψ h, begin\n    let aux : (Z ⟶ f.left) → (arrow.mk (𝟙 Z) ⟶ f) := λ φ, { left := φ, right := φ ≫ f.hom },\n    show (aux φ).left = (aux ψ).left,\n    congr' 1,\n    rw ← cancel_mono sq,\n    ext,\n    { exact h },\n    { simp only [comma.comp_right, category.assoc, ← arrow.w],\n      simp only [← category.assoc, h], },\n  end }\n\ninstance epi_right [epi sq] : epi sq.right :=\n{ left_cancellation := λ Z φ ψ h, begin\n    let aux : (g.right ⟶ Z) → (g ⟶ arrow.mk (𝟙 Z)) := λ φ, { right := φ, left := g.hom ≫ φ },\n    show (aux φ).right = (aux ψ).right,\n    congr' 1,\n    rw ← cancel_epi sq,\n    ext,\n    { simp only [comma.comp_left, category.assoc, arrow.w_assoc, h], },\n    { exact h },\n  end }\n\nend\n\n/-- Given a square from an arrow `i` to an isomorphism `p`, express the source part of `sq`\nin terms of the inverse of `p`. -/\n@[simp] lemma square_to_iso_invert (i : arrow T) {X Y : T} (p : X ≅ Y) (sq : i ⟶ arrow.mk p.hom) :\n  i.hom ≫ sq.right ≫ p.inv = sq.left :=\nby simpa only [category.assoc] using (iso.comp_inv_eq p).mpr ((arrow.w_mk_right sq).symm)\n\n/-- Given a square from an isomorphism `i` to an arrow `p`, express the target part of `sq`\nin terms of the inverse of `i`. -/\nlemma square_from_iso_invert {X Y : T} (i : X ≅ Y) (p : arrow T) (sq : arrow.mk i.hom ⟶ p) :\n  i.inv ≫ sq.left ≫ p.hom = sq.right :=\nby simp only [iso.inv_hom_id_assoc, arrow.w, arrow.mk_hom]\n\n/-- A lift of a commutative square is a diagonal morphism making the two triangles commute. -/\n@[ext] structure lift_struct {f g : arrow T} (sq : f ⟶ g) :=\n(lift : f.right ⟶ g.left)\n(fac_left' : f.hom ≫ lift = sq.left . obviously)\n(fac_right' : lift ≫ g.hom = sq.right . obviously)\n\nrestate_axiom lift_struct.fac_left'\nrestate_axiom lift_struct.fac_right'\n\ninstance lift_struct_inhabited {X : T} : inhabited (lift_struct (𝟙 (arrow.mk (𝟙 X)))) :=\n⟨⟨𝟙 _, category.id_comp _, category.comp_id _⟩⟩\n\n/-- `has_lift sq` says that there is some `lift_struct sq`, i.e., that it is possible to find a\n    diagonal morphism making the two triangles commute. -/\nclass has_lift {f g : arrow T} (sq : f ⟶ g) : Prop :=\nmk' :: (exists_lift : nonempty (lift_struct sq))\n\nlemma has_lift.mk {f g : arrow T} {sq : f ⟶ g} (s : lift_struct sq) : has_lift sq :=\n⟨nonempty.intro s⟩\n\nattribute [simp, reassoc] lift_struct.fac_left lift_struct.fac_right\n\n/-- Given `has_lift sq`, obtain a lift. -/\nnoncomputable def has_lift.struct {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : lift_struct sq :=\nclassical.choice has_lift.exists_lift\n\n/-- If there is a lift of a commutative square `sq`, we can access it by saying `lift sq`. -/\nnoncomputable abbreviation lift {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : f.right ⟶ g.left :=\n(has_lift.struct sq).lift\n\nlemma lift.fac_left {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : f.hom ≫ lift sq = sq.left :=\nby simp\n\nlemma lift.fac_right {f g : arrow T} (sq : f ⟶ g) [has_lift sq] : lift sq ≫ g.hom = sq.right :=\nby simp\n\n@[simp, reassoc]\nlemma lift.fac_right_of_to_mk {X Y : T} {f : arrow T} {g : X ⟶ Y} (sq : f ⟶ mk g) [has_lift sq] :\n  lift sq ≫ g = sq.right :=\nby simp only [←mk_hom g, lift.fac_right]\n\n@[simp, reassoc]\nlemma lift.fac_left_of_from_mk {X Y : T} {f : X ⟶ Y} {g : arrow T} (sq : mk f ⟶ g) [has_lift sq] :\n  f ≫ lift sq = sq.left :=\nby simp only [←mk_hom f, lift.fac_left]\n\n@[simp, reassoc]\nlemma lift_mk'_left {X Y P Q : T} {f : X ⟶ Y} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}\n  (h : u ≫ g = f ≫ v) [has_lift $ arrow.hom_mk' h] : f ≫ lift (arrow.hom_mk' h) = u :=\nby simp only [←arrow.mk_hom f, lift.fac_left, arrow.hom_mk'_left]\n\n@[simp, reassoc]\nlemma lift_mk'_right {X Y P Q : T} {f : X ⟶ Y} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}\n  (h : u ≫ g = f ≫ v) [has_lift $ arrow.hom_mk' h] : lift (arrow.hom_mk' h) ≫ g = v :=\nby simp only [←arrow.mk_hom g, lift.fac_right, arrow.hom_mk'_right]\n\nsection\n\ninstance subsingleton_lift_struct_of_epi {f g : arrow T} (sq : f ⟶ g) [epi f.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ λ a b, lift_struct.ext a b $ (cancel_epi f.hom).1 $ by simp\n\ninstance subsingleton_lift_struct_of_mono {f g : arrow T} (sq : f ⟶ g) [mono g.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ λ a b, lift_struct.ext a b $ (cancel_mono g.hom).1 $ by simp\n\nend\n\nvariables {C : Type u} [category.{v} C]\n/-- A helper construction: given a square between `i` and `f ≫ g`, produce a square between\n`i` and `g`, whose top leg uses `f`:\nA  → X\n     ↓f\n↓i   Y             --> A → Y\n     ↓g                ↓i  ↓g\nB  → Z                 B → Z\n -/\n@[simps] def square_to_snd {X Y Z: C} {i : arrow C} {f : X ⟶ Y} {g : Y ⟶ Z}\n  (sq : i ⟶ arrow.mk (f ≫ g)) :\n  i ⟶ arrow.mk g :=\n{ left := sq.left ≫ f,\n  right := sq.right }\n\n/-- The functor sending an arrow to its source. -/\n@[simps] def left_func : arrow C ⥤ C := comma.fst _ _\n\n/-- The functor sending an arrow to its target. -/\n@[simps] def right_func : arrow C ⥤ C := comma.snd _ _\n\n/-- The natural transformation from `left_func` to `right_func`, given by the arrow itself. -/\n@[simps]\ndef left_to_right : (left_func : arrow C ⥤ C) ⟶ right_func :=\n{ app := λ f, f.hom }\n\nend arrow\n\nnamespace functor\n\nuniverses v₁ v₂ u₁ u₂\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/\n@[simps]\ndef map_arrow (F : C ⥤ D) : arrow C ⥤ arrow D :=\n{ obj := λ a,\n  { left := F.obj a.left,\n    right := F.obj a.right,\n    hom := F.map a.hom, },\n  map := λ a b f,\n  { left := F.map f.left,\n    right := F.map f.right,\n    w' := by { have w := f.w, simp only [id_map] at w, dsimp, simp only [←F.map_comp, w], } } }\n\nend functor\n\nend category_theory\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/category_theory/arrow.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.46329455002305403}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Rémy Degenne\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.measure_theory.measure_space\nimport Mathlib.algebra.big_operators.intervals\nimport Mathlib.data.finset.intervals\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Independence of sets of sets and measure spaces (σ-algebras)\n\n* A family of sets of sets `π : ι → set (set α)` is independent with respect to a measure `μ` if for\n  any finite set of indices `s = {i_1, ..., i_n}`, for any sets `f i_1 ∈ π i_1, ..., f i_n ∈ π i_n`,\n  `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `. It will be used for families of π-systems.\n* A family of measurable space structures (i.e. of σ-algebras) is independent with respect to a\n  measure `μ` (typically defined on a finer σ-algebra) if the family of sets of measurable sets they\n  define is independent. I.e., `m : ι → measurable_space α` is independent with respect to a\n  measure `μ` if for any finite set of indices `s = {i_1, ..., i_n}`, for any sets\n  `f i_1 ∈ m i_1, ..., f i_n ∈ m i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i)`.\n* Independence of sets (or events in probabilistic parlance) is defined as independence of the\n  measurable space structures they generate: a set `s` generates the measurable space structure with\n  measurable sets `∅, s, sᶜ, univ`.\n* Independence of functions (or random variables) is also defined as independence of the measurable\n  space structures they generate: a function `f` for which we have a measurable space `m` on the\n  codomain generates `measurable_space.comap f m`.\n\n## Main statements\n\n* TODO: `Indep_of_Indep_sets`: if π-systems are independent as sets of sets, then the\nmeasurable space structures they generate are independent.\n* `indep_of_indep_sets`: variant with two π-systems.\n\n## Implementation notes\n\nWe provide one main definition of independence:\n* `Indep_sets`: independence of a family of sets of sets `pi : ι → set (set α)`.\nThree other independence notions are defined using `Indep_sets`:\n* `Indep`: independence of a family of measurable space structures `m : ι → measurable_space α`,\n* `Indep_set`: independence of a family of sets `s : ι → set α`,\n* `Indep_fun`: independence of a family of functions. For measurable spaces\n  `m : Π (i : ι), measurable_space (β i)`, we consider functions `f : Π (i : ι), α → β i`.\n\nAdditionally, we provide four corresponding statements for two measurable space structures (resp.\nsets of sets, sets, functions) instead of a family. These properties are denoted by the same names\nas for a family, but without a capital letter, for example `indep_fun` is the version of `Indep_fun`\nfor two functions.\n\nThe definition of independence for `Indep_sets` uses finite sets (`finset`). An alternative and\nequivalent way of defining independence would have been to use countable sets.\nTODO: prove that equivalence.\n\nMost of the definitions and lemma in this file list all variables instead of using the `variables`\nkeyword at the beginning of a section, for example\n`lemma indep.symm {α} {m₁ m₂ : measurable_space α} [measurable_space α] {μ : measure α} ...` .\nThis is intentional, to be able to control the order of the `measurable_space` variables. Indeed\nwhen defining `μ` in the example above, the measurable space used is the last one defined, here\n`[measurable_space α]`, and not `m₁` or `m₂`.\n\n## References\n\n* Williams, David. Probability with martingales. Cambridge university press, 1991.\nPart A, Chapter 4.\n-/\n\nnamespace probability_theory\n\n\n/-- A family of sets of sets `π : ι → set (set α)` is independent with respect to a measure `μ` if\nfor any finite set of indices `s = {i_1, ..., i_n}`, for any sets\n`f i_1 ∈ π i_1, ..., f i_n ∈ π i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `.\nIt will be used for families of pi_systems. -/\ndef Indep_sets {α : Type u_1} {ι : Type u_2} [measurable_space α] (π : ι → set (set α)) (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  ∀ (s : finset ι) {f : ι → set α} (H : ∀ (i : ι), i ∈ s → f i ∈ π i),\n    coe_fn μ (set.Inter fun (i : ι) => set.Inter fun (H : i ∈ s) => f i) = finset.prod s fun (i : ι) => coe_fn μ (f i)\n\n/-- Two sets of sets `s₁, s₂` are independent with respect to a measure `μ` if for any sets\n`t₁ ∈ p₁, t₂ ∈ s₂`, then `μ (t₁ ∩ t₂) = μ (t₁) * μ (t₂)` -/\ndef indep_sets {α : Type u_1} [measurable_space α] (s1 : set (set α)) (s2 : set (set α)) (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  ∀ (t1 t2 : set α), t1 ∈ s1 → t2 ∈ s2 → coe_fn μ (t1 ∩ t2) = coe_fn μ t1 * coe_fn μ t2\n\n/-- A family of measurable space structures (i.e. of σ-algebras) is independent with respect to a\nmeasure `μ` (typically defined on a finer σ-algebra) if the family of sets of measurable sets they\ndefine is independent. `m : ι → measurable_space α` is independent with respect to measure `μ` if\nfor any finite set of indices `s = {i_1, ..., i_n}`, for any sets\n`f i_1 ∈ m i_1, ..., f i_n ∈ m i_n`, then `μ (⋂ i in s, f i) = ∏ i in s, μ (f i) `. -/\ndef Indep {α : Type u_1} {ι : Type u_2} (m : ι → measurable_space α) [measurable_space α] (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  Indep_sets fun (x : ι) => measurable_space.is_measurable' (m x)\n\n/-- Two measurable space structures (or σ-algebras) `m₁, m₂` are independent with respect to a\nmeasure `μ` (defined on a third σ-algebra) if for any sets `t₁ ∈ m₁, t₂ ∈ m₂`,\n`μ (t₁ ∩ t₂) = μ (t₁) * μ (t₂)` -/\ndef indep {α : Type u_1} (m₁ : measurable_space α) (m₂ : measurable_space α) [measurable_space α] (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  indep_sets (measurable_space.is_measurable' m₁) (measurable_space.is_measurable' m₂)\n\n/-- A family of sets is independent if the family of measurable space structures they generate is\nindependent. For a set `s`, the generated measurable space has measurable sets `∅, s, sᶜ, univ`. -/\ndef Indep_set {α : Type u_1} {ι : Type u_2} [measurable_space α] (s : ι → set α) (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  Indep fun (i : ι) => measurable_space.generate_from (singleton (s i))\n\n/-- Two sets are independent if the two measurable space structures they generate are independent.\nFor a set `s`, the generated measurable space structure has measurable sets `∅, s, sᶜ, univ`. -/\ndef indep_set {α : Type u_1} [measurable_space α] {s : set α} {t : set α} (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  indep (measurable_space.generate_from (singleton s)) (measurable_space.generate_from (singleton t))\n\n/-- A family of functions defined on the same space `α` and taking values in possibly different\nspaces, each with a measurable space structure, is independent if the family of measurable space\nstructures they generate on `α` is independent. For a function `g` with codomain having measurable\nspace structure `m`, the generated measurable space structure is `measurable_space.comap g m`. -/\ndef Indep_fun {α : Type u_1} {ι : Type u_2} [measurable_space α] {β : ι → Type u_3} (m : (x : ι) → measurable_space (β x)) (f : (x : ι) → α → β x) (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  Indep fun (x : ι) => measurable_space.comap (f x) (m x)\n\n/-- Two functions are independent if the two measurable space structures they generate are\nindependent. For a function `f` with codomain having measurable space structure `m`, the generated\nmeasurable space structure is `measurable_space.comap f m`. -/\ndef indep_fun {α : Type u_1} {β : Type u_2} {γ : Type u_3} [measurable_space α] (mβ : measurable_space β) (mγ : measurable_space γ) {f : α → β} {g : α → γ} (μ : autoParam (measure_theory.measure α)\n  (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.measure_theory.volume_tac\")\n    (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"measure_theory\") \"volume_tac\")\n    [])) :=\n  indep (measurable_space.comap f mβ) (measurable_space.comap g mγ)\n\ntheorem indep_sets.symm {α : Type u_1} {s₁ : set (set α)} {s₂ : set (set α)} [measurable_space α] {μ : measure_theory.measure α} (h : indep_sets s₁ s₂) : indep_sets s₂ s₁ := sorry\n\ntheorem indep.symm {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} [measurable_space α] {μ : measure_theory.measure α} (h : indep m₁ m₂) : indep m₂ m₁ :=\n  indep_sets.symm h\n\ntheorem indep_sets_of_indep_sets_of_le_left {α : Type u_1} {s₁ : set (set α)} {s₂ : set (set α)} {s₃ : set (set α)} [measurable_space α] {μ : measure_theory.measure α} (h_indep : indep_sets s₁ s₂) (h31 : s₃ ⊆ s₁) : indep_sets s₃ s₂ :=\n  fun (t1 t2 : set α) (ht1 : t1 ∈ s₃) (ht2 : t2 ∈ s₂) => h_indep t1 t2 (set.mem_of_subset_of_mem h31 ht1) ht2\n\ntheorem indep_sets_of_indep_sets_of_le_right {α : Type u_1} {s₁ : set (set α)} {s₂ : set (set α)} {s₃ : set (set α)} [measurable_space α] {μ : measure_theory.measure α} (h_indep : indep_sets s₁ s₂) (h32 : s₃ ⊆ s₂) : indep_sets s₁ s₃ :=\n  fun (t1 t2 : set α) (ht1 : t1 ∈ s₁) (ht2 : t2 ∈ s₃) => h_indep t1 t2 ht1 (set.mem_of_subset_of_mem h32 ht2)\n\ntheorem indep_of_indep_of_le_left {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} {m₃ : measurable_space α} [measurable_space α] {μ : measure_theory.measure α} (h_indep : indep m₁ m₂) (h31 : m₃ ≤ m₁) : indep m₃ m₂ :=\n  fun (t1 t2 : set α) (ht1 : t1 ∈ measurable_space.is_measurable' m₃) (ht2 : t2 ∈ measurable_space.is_measurable' m₂) =>\n    h_indep t1 t2 (h31 t1 ht1) ht2\n\ntheorem indep_of_indep_of_le_right {α : Type u_1} {m₁ : measurable_space α} {m₂ : measurable_space α} {m₃ : measurable_space α} [measurable_space α] {μ : measure_theory.measure α} (h_indep : indep m₁ m₂) (h32 : m₃ ≤ m₂) : indep m₁ m₃ :=\n  fun (t1 t2 : set α) (ht1 : t1 ∈ measurable_space.is_measurable' m₁) (ht2 : t2 ∈ measurable_space.is_measurable' m₃) =>\n    h_indep t1 t2 ht1 (h32 t2 ht2)\n\ntheorem indep_sets.union {α : Type u_1} [measurable_space α] {s₁ : set (set α)} {s₂ : set (set α)} {s' : set (set α)} {μ : measure_theory.measure α} (h₁ : indep_sets s₁ s') (h₂ : indep_sets s₂ s') : indep_sets (s₁ ∪ s₂) s' := sorry\n\n@[simp] theorem indep_sets.union_iff {α : Type u_1} [measurable_space α] {s₁ : set (set α)} {s₂ : set (set α)} {s' : set (set α)} {μ : measure_theory.measure α} : indep_sets (s₁ ∪ s₂) s' ↔ indep_sets s₁ s' ∧ indep_sets s₂ s' := sorry\n\ntheorem indep_sets.Union {α : Type u_1} {ι : Sort u_2} [measurable_space α] {s : ι → set (set α)} {s' : set (set α)} {μ : measure_theory.measure α} (hyp : ∀ (n : ι), indep_sets (s n) s') : indep_sets (set.Union fun (n : ι) => s n) s' := sorry\n\ntheorem indep_sets.inter {α : Type u_1} [measurable_space α] {s₁ : set (set α)} {s' : set (set α)} (s₂ : set (set α)) {μ : measure_theory.measure α} (h₁ : indep_sets s₁ s') : indep_sets (s₁ ∩ s₂) s' :=\n  fun (t1 t2 : set α) (ht1 : t1 ∈ s₁ ∩ s₂) (ht2 : t2 ∈ s') =>\n    h₁ t1 t2 (and.left (iff.mp (set.mem_inter_iff t1 s₁ s₂) ht1)) ht2\n\ntheorem indep_sets.Inter {α : Type u_1} {ι : Sort u_2} [measurable_space α] {s : ι → set (set α)} {s' : set (set α)} {μ : measure_theory.measure α} (h : ∃ (n : ι), indep_sets (s n) s') : indep_sets (set.Inter fun (n : ι) => s n) s' :=\n  id\n    fun (t1 t2 : set α) (ht1 : t1 ∈ set.Inter fun (n : ι) => s n) (ht2 : t2 ∈ s') =>\n      Exists.dcases_on h fun (n : ι) (h : indep_sets (s n) s') => h t1 t2 (iff.mp set.mem_Inter ht1 n) ht2\n\n/-! ### Deducing `indep` from `Indep` -/\n\ntheorem Indep_sets.indep_sets {α : Type u_1} {ι : Type u_2} {s : ι → set (set α)} [measurable_space α] {μ : measure_theory.measure α} (h_indep : Indep_sets s) {i : ι} {j : ι} (hij : i ≠ j) : indep_sets (s i) (s j) := sorry\n\ntheorem Indep.indep {α : Type u_1} {ι : Type u_2} {m : ι → measurable_space α} [measurable_space α] {μ : measure_theory.measure α} (h_indep : Indep m) {i : ι} {j : ι} (hij : i ≠ j) : indep (m i) (m j) :=\n  id (Indep_sets.indep_sets h_indep hij)\n\n/-!\n## π-system lemma\n\nIndependence of measurable spaces is equivalent to independence of generating π-systems.\n-/\n\n/-! ### Independence of measurable space structures implies independence of generating π-systems -/\n\ntheorem Indep.Indep_sets {α : Type u_1} {ι : Type u_2} [measurable_space α] {μ : measure_theory.measure α} {m : ι → measurable_space α} {s : ι → set (set α)} (hms : ∀ (n : ι), m n = measurable_space.generate_from (s n)) (h_indep : Indep m) : Indep_sets s := sorry\n\ntheorem indep.indep_sets {α : Type u_1} [measurable_space α] {μ : measure_theory.measure α} {s1 : set (set α)} {s2 : set (set α)} (h_indep : indep (measurable_space.generate_from s1) (measurable_space.generate_from s2)) : indep_sets s1 s2 :=\n  fun (t1 t2 : set α) (ht1 : t1 ∈ s1) (ht2 : t2 ∈ s2) =>\n    h_indep t1 t2 (measurable_space.is_measurable_generate_from ht1) (measurable_space.is_measurable_generate_from ht2)\n\n/-! ### Independence of generating π-systems implies independence of measurable space structures -/\n\ntheorem indep_sets.indep {α : Type u_1} {m1 : measurable_space α} {m2 : measurable_space α} {m : measurable_space α} {μ : measure_theory.measure α} [measure_theory.probability_measure μ] {p1 : set (set α)} {p2 : set (set α)} (h1 : m1 ≤ m) (h2 : m2 ≤ m) (hp1 : is_pi_system p1) (hp2 : is_pi_system p2) (hpm1 : m1 = measurable_space.generate_from p1) (hpm2 : m2 = measurable_space.generate_from p2) (hyp : indep_sets p1 p2) : indep m1 m2 := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/probability_theory/independence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.6688802471698041, "lm_q1q2_score": 0.46329454936688547}}
{"text": "/-\nCopyright (c) 2021 Yourong Zang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yourong Zang\n-/\nimport topology.separation\nimport topology.opens\n\n/-!\n# The Alexandroff Compactification\nWe construct the Alexandroff compactification of an arbitrary topological space `X` and prove\nsome properties inherited from `X`.\n\n## Main defintion\n* `alexandroff`: the Alexandroff compactification\n* `of`: the inclusion map defined by `option.some`. This map requires the argument\n        `topological_space X`\n* `infty`: the extra point\n\n## Main results\n* The topological structure of `alexandroff X`\n* The connectedness of `alexandroff X` for a noncompact, preconnected `X`\n* `alexandroff X` is `T₁` for a T₁ space `X`\n* `alexandroff X` is Hausdorff if `X` is locally compact and Hausdorff\n-/\n\nnoncomputable theory\nopen set\nopen_locale classical topological_space\n\nsection basic\n\n/-- The Alexandroff extension of an arbitrary topological space `X` -/\n@[nolint unused_arguments]\ndef alexandroff (X : Type*) [topological_space X] := option X\n\nvariables {X : Type*} [topological_space X]\n\n/-- The embedding of `X` to its Alexandroff extension -/\ndef of : X → alexandroff X := some\n\n/-- The range of the embedding -/\ndef range_of (X : Type*) [topological_space X] : set (alexandroff X) := of '' (univ : set X)\n\nlemma of_apply {x : X} : of x = some x := rfl\n\nlemma of_injective : function.injective (@of X _) :=\noption.some_injective X\n\n/-- The point at infinity -/\ndef infty : alexandroff X := none\nlocalized \"notation `∞` := infty\" in alexandroff\n\nnamespace alexandroff\n\ninstance : has_coe_t X (alexandroff X) := ⟨of⟩\n\ninstance : inhabited(alexandroff X) := ⟨∞⟩\n\n@[norm_cast] \nlemma coe_eq_coe {x y : X} : (x : alexandroff X) = y ↔ x = y :=\nof_injective.eq_iff\n\n@[simp] lemma coe_ne_infty (x : X) : (x : alexandroff X) ≠ ∞  .\n@[simp] lemma infty_ne_coe (x : X) : ∞ ≠ (x : alexandroff X) .\n@[simp] lemma of_eq_coe {x : X} : (of x : alexandroff X) = x := rfl\n\n/-- Recursor for `alexandroff` using the preferred forms `∞` and `↑x`. -/\n@[elab_as_eliminator]\ndef rec_infty_coe (C : alexandroff X → Sort*) (h₁ : C infty) (h₂ : Π (x : X), C x) :\n  Π (z : alexandroff X), C z :=\noption.rec h₁ h₂\n\nlemma ne_infty_iff_exists {x : alexandroff X} : \n  x ≠ ∞ ↔ ∃ (y : X), x = y :=\nby { induction x using alexandroff.rec_infty_coe; simp }\n\n@[simp] lemma coe_mem_range_of (x : X) : (x : alexandroff X) ∈ (range_of X) :=\nby simp [range_of]\n\nlemma union_infty_eq_univ : (range_of X ∪ {∞}) = univ :=\nbegin\n  refine le_antisymm (subset_univ _) (λ x hx, _),\n  induction x using alexandroff.rec_infty_coe; simp\nend\n\n@[simp] lemma infty_not_mem_range_of : ∞ ∉ range_of X :=\nby simp [range_of]\n\n@[simp] lemma not_mem_range_of_iff (x : alexandroff X) :\n  x ∉ range_of X ↔ x = ∞ :=\nby { induction x using alexandroff.rec_infty_coe; simp [infty_not_mem_range_of] }\n\nattribute [nolint simp_nf] not_mem_range_of_iff\n\nlemma infty_not_mem_image_of {s : set X} : ∞ ∉ of '' s :=\nnot_mem_subset (image_subset _ $ subset_univ _) infty_not_mem_range_of\n\nlemma inter_infty_eq_empty : (range_of X) ∩ {∞} = ∅ :=\nby { ext x, induction x using alexandroff.rec_infty_coe; simp }\n\nlemma of_preimage_infty : (of⁻¹' {∞} : set X) = ∅ :=\nby { ext, simp }\n\nend alexandroff\n\nend basic\n\nopen alexandroff\nopen_locale alexandroff\n\nsection topology\n\nvariables {X : Type*} [topological_space X]\n\ninstance : topological_space (alexandroff X) :=\n{ is_open := λ s, if ∞ ∈ s then is_compact (of⁻¹' s)ᶜ ∧ is_open (of⁻¹' s)\n    else is_open (of⁻¹' s),\n  is_open_univ := by simp,\n  is_open_inter :=\n  λ s t hs ht, begin\n    split_ifs at hs ht with h h' h' h' h,\n    { simpa [h, h', compl_inter] using and.intro (hs.1.union ht.1) (hs.2.inter ht.2) },\n    { simpa [h, h'] using hs.inter ht.2 },\n    { simpa [h, h'] using hs.2.inter ht },\n    { simpa [h, h'] using hs.inter ht }\n  end,\n  is_open_sUnion :=\n  λ S ht, begin\n    suffices : is_open (of⁻¹' ⋃₀S),\n    { split_ifs with h,\n      { obtain ⟨(a : set (alexandroff X)), ha, ha'⟩ := mem_sUnion.mp h,\n        specialize ht a ha,\n        rw if_pos ha' at ht,\n        refine ⟨compact_of_is_closed_subset ht.left this.is_closed_compl _, this⟩,\n        rw [compl_subset_compl, preimage_subset_iff],\n        intros y hy,\n        refine ⟨a, ha, hy⟩ },\n      { exact this } },\n     rw is_open_iff_forall_mem_open,\n     simp only [and_imp, exists_prop, mem_Union, preimage_sUnion, mem_preimage, of_eq_coe,\n                exists_imp_distrib],\n     intros y s hs hy,\n     refine ⟨of ⁻¹' s, subset_subset_Union _ (subset_subset_Union hs (subset.refl _)), _,\n        mem_preimage.mpr hy⟩,\n     specialize ht s hs,\n     split_ifs at ht,\n     { exact ht.right },\n     { exact ht }\n  end }\n\nvariables {s : set (alexandroff X)} {s' : set X}\n\nlemma is_open_alexandroff_iff_aux :\n  is_open s ↔ if ∞ ∈ s then is_compact (of⁻¹' s)ᶜ ∧ is_open (of⁻¹' s)\n  else is_open (of⁻¹' s) :=\niff.rfl\n\nlemma is_open_iff_of_mem' (h : ∞ ∈ s) :\n  is_open s ↔ is_compact (of⁻¹' s)ᶜ ∧ is_open (of⁻¹' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_iff_of_mem (h : ∞ ∈ s) :\n  is_open s ↔ is_compact (of⁻¹' s)ᶜ ∧ is_closed (of⁻¹' s)ᶜ :=\nby simp [is_open_alexandroff_iff_aux, h, is_closed_compl_iff]\n\nlemma is_open_iff_of_not_mem (h : ∞ ∉ s) :\n  is_open s ↔ is_open (of⁻¹' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_of_is_open (h : is_open s) :\n  is_open (of⁻¹' s) :=\nbegin\n  by_cases H : ∞ ∈ s,\n  { simpa using ((is_open_iff_of_mem H).mp h).2 },\n  { exact (is_open_iff_of_not_mem H).mp h }\nend\n \nend topology\n\nsection topological_prop\n\nvariables {X : Type*} [topological_space X]\n\n@[continuity] lemma continuous_of : continuous (@of X _) :=\ncontinuous_def.mpr (λ s hs, is_open_of_is_open hs)\n\n/-- An open set in `alexandroff X` constructed from a closed compact set in `X` -/\ndef opens_of_compl {s : set X} (h : is_compact s ∧ is_closed s) :\n  topological_space.opens (alexandroff X) :=\n⟨(of '' s)ᶜ, by { rw [is_open_iff_of_mem ((mem_compl_iff _ _).mpr infty_not_mem_image_of),\n  preimage_compl, compl_compl, of_injective.preimage_image _], exact h }⟩\n\nlemma infty_mem_opens_of_compl {s : set X} (h : is_compact s ∧ is_closed s) :\n  ∞ ∈ (opens_of_compl h) :=\nby { simp only [opens_of_compl, topological_space.opens.coe_mk],\n     exact mem_compl infty_not_mem_image_of }\n\nlemma is_open_map_of : is_open_map (@of X _) :=\nλ s hs, begin\n  rw [← preimage_image_eq s of_injective] at hs,\n  rwa is_open_iff_of_not_mem infty_not_mem_image_of\nend\n\nlemma is_open_range_of : is_open (@range_of X _) :=\nis_open_map_of _ is_open_univ\n\ninstance : compact_space (alexandroff X) :=\n{ compact_univ :=\n  begin\n    refine is_compact_of_finite_subcover (λ ι Z h H, _),\n    simp only [univ_subset_iff] at H ⊢,\n    rcases Union_eq_univ_iff.mp H ∞ with ⟨K, hK⟩,\n    have minor₁ : is_compact (of⁻¹' Z K)ᶜ,\n    { specialize h K, rw is_open_iff_of_mem hK at h, exact h.1 },\n    let p : ι → set X := λ i, of⁻¹' Z i,\n    have minor₂ : ∀ i, is_open (p i) := λ i, is_open_of_is_open (h i),\n    have minor₃ : (of⁻¹' Z K)ᶜ ⊆ ⋃ i, p i :=\n      by simp only [p, ← preimage_Union, H, preimage_univ, subset_univ],\n    rcases is_compact_iff_finite_subcover.mp minor₁ p minor₂ minor₃ with ⟨ι', H'⟩,\n    refine ⟨insert K ι', _⟩,\n    rw ← preimage_compl at H',\n    simp only [Union_eq_univ_iff],\n    intros x,\n    by_cases hx : x ∈ Z K,\n    { exact ⟨K, mem_Union.mpr ⟨finset.mem_insert_self _ _, hx⟩⟩ },\n    { have triv₁ : x ≠ ∞ := (ne_of_mem_of_not_mem hK hx).symm,\n      rcases ne_infty_iff_exists.mp triv₁ with ⟨y, hy⟩,\n      have triv₂ : (y : alexandroff X) ∈ {x} := mem_singleton_of_eq hy.symm,\n      rw [← mem_compl_iff, ← singleton_subset_iff] at hx,\n      have : of⁻¹' {x} ⊆ of⁻¹' (Z K)ᶜ := λ y hy, hx hy,\n      have key : y ∈ ⋃ (i : ι) (H : i ∈ ι'), p i := this.trans H' (mem_preimage.mpr triv₂),\n      rcases mem_bUnion_iff'.mp key with ⟨i, hi, hyi⟩,\n      refine ⟨i, mem_Union.mpr ⟨finset.subset_insert _ ι' hi, _⟩⟩,\n      simpa [hy] using hyi }\n  end }\n\nlemma dense_range_of (h : ¬ is_compact (univ : set X)) : dense (@range_of X _) :=\nbegin\n  refine dense_iff_inter_open.mpr (λ s hs Hs, _),\n  by_cases H : ∞ ∈ s,\n  { rw is_open_iff_of_mem H at hs,\n    have minor₁ : s ≠ {∞},\n    { by_contra w,\n      rw [not_not.mp w, of_preimage_infty, compl_empty] at hs,\n      exact h hs.1 },\n    have minor₂ : of⁻¹' s ≠ ∅,\n    { by_contra w,\n      rw [not_not, eq_empty_iff_forall_not_mem] at w,\n      simp only [mem_preimage] at w,\n      have : ∀ z ∈ s, z = ∞ := λ z hz,\n        by_contra (λ w', let ⟨x, hx⟩ := ne_infty_iff_exists.mp w' in\n          by rw hx at hz; exact (w x) hz),\n      exact minor₁ (eq_singleton_iff_unique_mem.mpr ⟨H, this⟩) },\n    rcases ne_empty_iff_nonempty.mp minor₂ with ⟨x, hx⟩,\n    exact ⟨of x, hx, x, mem_univ _, rfl⟩ },\n  { rcases Hs with ⟨z, hz⟩,\n    rcases ne_infty_iff_exists.mp (ne_of_mem_of_not_mem hz H) with ⟨x, hx⟩,\n    rw hx at hz,\n    exact ⟨of x, hz, x, mem_univ _, rfl⟩ }\nend\n\nlemma connected_space_alexandroff [preconnected_space X] (h : ¬ is_compact (univ : set X)) :\n  connected_space (alexandroff X) :=\n{ is_preconnected_univ :=\n  begin\n    rw ← dense_iff_closure_eq.mp (dense_range_of h),\n    exact is_preconnected.closure\n      (is_preconnected_univ.image of continuous_of.continuous_on)\n  end,\n  to_nonempty := ⟨∞⟩ }\n\ninstance [t1_space X] : t1_space (alexandroff X) :=\n{ t1 :=\n  λ z, begin\n    induction z using alexandroff.rec_infty_coe,\n    { rw [← is_open_compl_iff, compl_eq_univ_diff, ← union_infty_eq_univ,\n          union_diff_cancel_right (subset.antisymm_iff.mp inter_infty_eq_empty).1],\n      exact is_open_range_of },\n    { have : ∞ ∈ ({z}ᶜ : set (alexandroff X)) :=\n        mem_compl (λ w, (infty_ne_coe z) (mem_singleton_iff.mp w)),\n      rw [← is_open_compl_iff, is_open_iff_of_mem this],\n      rw [preimage_compl, compl_compl, ← of_eq_coe, \n          ← image_singleton, of_injective.preimage_image _],\n      exact ⟨is_compact_singleton, is_closed_singleton⟩ }\n  end }\n\ninstance [locally_compact_space X] [t2_space X] : t2_space (alexandroff X) :=\n{ t2 :=\n  λ x y hxy, begin\n    have key : ∀ (z : alexandroff X), z ≠ ∞ →\n      ∃ (u v : set (alexandroff X)), is_open u ∧ is_open v ∧ ∞ ∈ u ∧ z ∈ v ∧ u ∩ v = ∅ :=\n    λ z h, begin\n      rcases ne_infty_iff_exists.mp h with ⟨y', hy'⟩,\n      rcases exists_open_with_compact_closure y' with ⟨u, hu, huy', Hu⟩,\n      have minor₁ : _ ∧ is_closed (closure u) := ⟨Hu, is_closed_closure⟩,\n      refine ⟨opens_of_compl minor₁, of '' u, _⟩,\n      refine ⟨(opens_of_compl minor₁).2, is_open_map_of _ hu,\n        infty_mem_opens_of_compl minor₁, ⟨y', huy', hy'.symm⟩, _⟩,\n      simp only [opens_of_compl, topological_space.opens.coe_mk],\n      have minor₂ : (of '' closure u)ᶜ ∩ of '' u ⊆ (of '' u)ᶜ ∩ of '' u,\n      { apply inter_subset_inter_left,\n        simp only [compl_subset_compl, image_subset _ (subset_closure)] },\n      rw compl_inter_self at minor₂,\n      exact eq_empty_of_subset_empty minor₂\n    end,\n    induction x using alexandroff.rec_infty_coe; induction y using alexandroff.rec_infty_coe,\n    { simpa using hxy },\n    { simpa using key y hxy.symm },\n    { rcases key x hxy with ⟨u, v, hu, hv, hxu, hyv, huv⟩,\n      exact ⟨v, u, hv, hu, hyv, hxu, (inter_comm u v) ▸ huv⟩ },\n    { have hxy' : x ≠ y := λ w, hxy (coe_eq_coe.mpr w),\n      rcases t2_separation hxy' with ⟨u, v, hu, hv, hxu, hyv, huv⟩,\n      refine ⟨of '' u, of '' v, is_open_map_of _ hu, is_open_map_of _ hv,\n        ⟨x, hxu, rfl⟩, ⟨y, hyv, rfl⟩, _⟩,\n      simp only [image_inter of_injective, huv, image_empty], }\n  end }\n\nend topological_prop\n\nnamespace alexandroff\n\nsection arithmetic\n\nvariables {X : Type*} [topological_space X]\n\ninstance [has_zero X] : has_zero (alexandroff X) := with_top.has_zero\n\ninstance [has_one X] : has_one (alexandroff X) := with_top.has_one\n\ninstance [has_add X] : has_add (alexandroff X) := with_top.has_add\n\n@[simp] lemma coe_add [has_add X] {x y : X} : ((x + y : X) : alexandroff X) = x + y := rfl\n\n@[simp] lemma add_infty [has_add X] {x : (alexandroff X)} : x + ∞ = ∞ :=\nwith_top.add_top\n\n@[simp] lemma infty_add [has_add X] {x : (alexandroff X)} : ∞ + x = ∞ :=\nwith_top.top_add\n\nend arithmetic\n\nend alexandroff", "meta": {"author": "justadzr", "repo": "lean-2021", "sha": "dfc6b30de2f27bdba5fbc51183e2b84e73a920d1", "save_path": "github-repos/lean/justadzr-lean-2021", "path": "github-repos/lean/justadzr-lean-2021/lean-2021-dfc6b30de2f27bdba5fbc51183e2b84e73a920d1/src/alexandroff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.4632945457792839}}
{"text": "import category_theory.equivalence\n\nopen category_theory\n\nvariables {C : Type*} [category C]\nvariables {D : Type*} [category D]\n\nlemma equiv_reflects_mono {X Y : C} (f : X ⟶ Y) (e : C ≌ D)\n  (hef : mono (e.functor.map f)) : mono f :=\nbegin\n  split,\n  intros Z g h w,\n  -- Let's think about the maths here.\n  -- We're trying to prove an equation between morphisms in `C`,\n  -- but the only thing we know, namely `hef`, lives over in `D`.\n  -- So lets use the injectivity of an equivalence at the level of morphisms:\n  apply e.functor.map_injective,\n  sorry\nend\n", "meta": {"author": "leanprover-community", "repo": "lftcm2020", "sha": "cc683e2b074b61909310746d6acc1fb3d42d6ee2", "save_path": "github-repos/lean/leanprover-community-lftcm2020", "path": "github-repos/lean/leanprover-community-lftcm2020/lftcm2020-cc683e2b074b61909310746d6acc1fb3d42d6ee2/src/hints/category_theory/exercise3/hint2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.5698526514141572, "lm_q1q2_score": 0.4632145963176556}}
{"text": "theorem test (p q : Prop) (hp : p) (hq : q) : p ∧ q ∧ p := by\n  apply And.intro hp\n  exact And.intro hq hp", "meta": {"author": "leanprover", "repo": "LeanInk", "sha": "499cf46f571562bebee0c8c193a7f9dcf5a30187", "save_path": "github-repos/lean/leanprover-LeanInk", "path": "github-repos/lean/leanprover-LeanInk/LeanInk-499cf46f571562bebee0c8c193a7f9dcf5a30187/test/theorem_proving/004.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128672997041659, "lm_q2_score": 0.5698526514141572, "lm_q1q2_score": 0.46321458598428533}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.arrow\n! leanprover-community/mathlib commit 32253a1a1071173b33dc7d6a218cf722c6feb514\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Comma\n\n/-!\n# The category of arrows\n\nThe category of arrows, with morphisms commutative squares.\nWe set this up as a specialization of the comma category `Comma L R`,\nwhere `L` and `R` are both the identity functor.\n\n## Tags\n\ncomma, arrow\n-/\n\n\nnamespace CategoryTheory\n\nuniverse v u\n\n-- morphism levels before object levels. See note [CategoryTheory universes].\nvariable {T : Type u} [Category.{v} T]\n\nsection\n\nvariable (T)\n\n/-- The arrow category of `T` has as objects all morphisms in `T` and as morphisms commutative\n     squares in `T`. -/\ndef Arrow :=\n  Comma.{v, v, v} (𝟭 T) (𝟭 T)\n#align category_theory.arrow CategoryTheory.Arrow\n\n/- Porting note: could not derive `Category` above so this instance works in its place-/\ninstance : Category (Arrow T) := commaCategory\n\n-- Satisfying the inhabited linter\ninstance Arrow.inhabited [Inhabited T] : Inhabited (Arrow T)\n    where default := show Comma (𝟭 T) (𝟭 T) from default\n#align category_theory.arrow.inhabited CategoryTheory.Arrow.inhabited\n\nend\n\nnamespace Arrow\n\n@[simp]\ntheorem id_left (f : Arrow T) : CommaMorphism.left (𝟙 f) = 𝟙 f.left :=\n  rfl\n#align category_theory.arrow.id_left CategoryTheory.Arrow.id_left\n\n@[simp]\ntheorem id_right (f : Arrow T) : CommaMorphism.right (𝟙 f) = 𝟙 f.right :=\n  rfl\n#align category_theory.arrow.id_right CategoryTheory.Arrow.id_right\n\n/-- An object in the arrow category is simply a morphism in `T`. -/\n@[simps]\ndef mk {X Y : T} (f : X ⟶ Y) : Arrow T where\n  left := X\n  right := Y\n  hom := f\n#align category_theory.arrow.mk CategoryTheory.Arrow.mk\n\n@[simp]\ntheorem mk_eq (f : Arrow T) : Arrow.mk f.hom = f := by\n  cases f\n  rfl\n#align category_theory.arrow.mk_eq CategoryTheory.Arrow.mk_eq\n\ntheorem mk_injective (A B : T) : Function.Injective (Arrow.mk : (A ⟶ B) → Arrow T) := fun f g h =>\n  by\n  cases h\n  rfl\n#align category_theory.arrow.mk_injective CategoryTheory.Arrow.mk_injective\n\n\n\n/- Porting note : was marked as dangerous instance so changed from `Coe` to `CoeOut` -/\ninstance {X Y : T} : CoeOut (X ⟶ Y) (Arrow T) where\n  coe := mk\n\n/-- A morphism in the arrow category is a commutative square connecting two objects of the arrow\n    category. -/\n@[simps]\ndef homMk {f g : Arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}\n    (w : u ≫ g.hom = f.hom ≫ v) : f ⟶ g where\n  left := u\n  right := v\n  w := w\n#align category_theory.arrow.hom_mk CategoryTheory.Arrow.homMk\n\n/-- We can also build a morphism in the arrow category out of any commutative square in `T`. -/\n@[simps]\ndef homMk' {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q} (w : u ≫ g = f ≫ v) :\n    Arrow.mk f ⟶ Arrow.mk g where\n  left := u\n  right := v\n  w := w\n#align category_theory.arrow.hom_mk' CategoryTheory.Arrow.homMk'\n\n/- Porting note : was warned simp could prove reassoc'd version. Found simp could not.\nAdded nolint. -/\n@[reassoc (attr := simp, nolint simpNF)]\ntheorem w {f g : Arrow T} (sq : f ⟶ g) : sq.left ≫ g.hom = f.hom ≫ sq.right :=\n  sq.w\n#align category_theory.arrow.w CategoryTheory.Arrow.w\n\n-- `w_mk_left` is not needed, as it is a consequence of `w` and `mk_hom`.\n@[reassoc (attr := simp)]\ntheorem w_mk_right {f : Arrow T} {X Y : T} {g : X ⟶ Y} (sq : f ⟶ mk g) :\n    sq.left ≫ g = f.hom ≫ sq.right :=\n  sq.w\n#align category_theory.arrow.w_mk_right CategoryTheory.Arrow.w_mk_right\n\ntheorem isIso_of_iso_left_of_isIso_right {f g : Arrow T} (ff : f ⟶ g) [IsIso ff.left]\n    [IsIso ff.right] : IsIso ff where\n  out := by\n    let inverse : g ⟶ f := ⟨inv ff.left, inv ff.right, (by simp)⟩\n    apply Exists.intro inverse\n    constructor\n    · apply CommaMorphism.ext\n      · rw [Comma.comp_left, IsIso.hom_inv_id, ←Comma.id_left]\n      · rw [Comma.comp_right, IsIso.hom_inv_id, ←Comma.id_right]\n    · apply CommaMorphism.ext\n      · rw [Comma.comp_left, IsIso.inv_hom_id, ←Comma.id_left]\n      · rw [Comma.comp_right, IsIso.inv_hom_id, ←Comma.id_right]\n#align category_theory.arrow.is_iso_of_iso_left_of_is_iso_right CategoryTheory.Arrow.isIso_of_iso_left_of_isIso_right\n\n/-- Create an isomorphism between arrows,\nby providing isomorphisms between the domains and codomains,\nand a proof that the square commutes. -/\n@[simps!]\ndef isoMk {f g : Arrow T} (l : f.left ≅ g.left) (r : f.right ≅ g.right)\n    (h : l.hom ≫ g.hom = f.hom ≫ r.hom) : f ≅ g :=\n  Comma.isoMk l r h\n#align category_theory.arrow.iso_mk CategoryTheory.Arrow.isoMk\n\n/-- A variant of `Arrow.isoMk` that creates an iso between two `Arrow.mk`s with a better type\nsignature. -/\nabbrev isoMk' {W X Y Z : T} (f : W ⟶ X) (g : Y ⟶ Z) (e₁ : W ≅ Y) (e₂ : X ≅ Z)\n    (h : e₁.hom ≫ g = f ≫ e₂.hom) : Arrow.mk f ≅ Arrow.mk g :=\n  Arrow.isoMk e₁ e₂ h\n#align category_theory.arrow.iso_mk' CategoryTheory.Arrow.isoMk'\n\ntheorem hom.congr_left {f g : Arrow T} {φ₁ φ₂ : f ⟶ g} (h : φ₁ = φ₂) : φ₁.left = φ₂.left := by\n  rw [h]\n#align category_theory.arrow.hom.congr_left CategoryTheory.Arrow.hom.congr_left\n\n@[simp]\ntheorem hom.congr_right {f g : Arrow T} {φ₁ φ₂ : f ⟶ g} (h : φ₁ = φ₂) : φ₁.right = φ₂.right := by\n  rw [h]\n#align category_theory.arrow.hom.congr_right CategoryTheory.Arrow.hom.congr_right\n\ntheorem iso_w {f g : Arrow T} (e : f ≅ g) : g.hom = e.inv.left ≫ f.hom ≫ e.hom.right := by\n  have eq := Arrow.hom.congr_right e.inv_hom_id\n  dsimp at eq\n  erw [Arrow.w_assoc, ←Comma.comp_right, eq, Category.comp_id]\n#align category_theory.arrow.iso_w CategoryTheory.Arrow.iso_w\n\ntheorem iso_w' {W X Y Z : T} {f : W ⟶ X} {g : Y ⟶ Z} (e : Arrow.mk f ≅ Arrow.mk g) :\n    g = e.inv.left ≫ f ≫ e.hom.right :=\n  iso_w e\n#align category_theory.arrow.iso_w' CategoryTheory.Arrow.iso_w'\n\nsection\n\nvariable {f g : Arrow T} (sq : f ⟶ g)\n\ninstance isIso_left [IsIso sq] : IsIso sq.left where\n  out := by\n    apply Exists.intro (inv sq).left\n    simp only [← Comma.comp_left, IsIso.hom_inv_id, IsIso.inv_hom_id, Arrow.id_left,\n      eq_self_iff_true, and_self_iff]\n    simp\n#align category_theory.arrow.is_iso_left CategoryTheory.Arrow.isIso_left\n\ninstance isIso_right [IsIso sq] : IsIso sq.right where\n  out := by\n    apply Exists.intro (inv sq).right\n    simp only [← Comma.comp_right, IsIso.hom_inv_id, IsIso.inv_hom_id, Arrow.id_right,\n      eq_self_iff_true, and_self_iff]\n    simp\n#align category_theory.arrow.is_iso_right CategoryTheory.Arrow.isIso_right\n\n@[simp]\ntheorem inv_left [IsIso sq] : (inv sq).left = inv sq.left :=\n  IsIso.eq_inv_of_hom_inv_id <| by rw [← Comma.comp_left, IsIso.hom_inv_id, id_left]\n#align category_theory.arrow.inv_left CategoryTheory.Arrow.inv_left\n\n@[simp]\ntheorem inv_right [IsIso sq] : (inv sq).right = inv sq.right :=\n  IsIso.eq_inv_of_hom_inv_id <| by rw [← Comma.comp_right, IsIso.hom_inv_id, id_right]\n#align category_theory.arrow.inv_right CategoryTheory.Arrow.inv_right\n\n/- Porting note : simp can prove this so removed @[simp] -/\ntheorem left_hom_inv_right [IsIso sq] : sq.left ≫ g.hom ≫ inv sq.right = f.hom := by\n  simp only [← Category.assoc, IsIso.comp_inv_eq, w]\n#align category_theory.arrow.left_hom_inv_right CategoryTheory.Arrow.left_hom_inv_right\n\n-- simp proves this\ntheorem inv_left_hom_right [IsIso sq] : inv sq.left ≫ f.hom ≫ sq.right = g.hom := by\n  simp only [w, IsIso.inv_comp_eq]\n#align category_theory.arrow.inv_left_hom_right CategoryTheory.Arrow.inv_left_hom_right\n\ninstance mono_left [Mono sq] : Mono sq.left where\n  right_cancellation {Z} φ ψ h := by\n    let aux : (Z ⟶ f.left) → (Arrow.mk (𝟙 Z) ⟶ f) := fun φ =>\n      { left := φ\n        right := φ ≫ f.hom }\n    have : ∀ g, (aux g).right = g ≫ f.hom := fun g => by dsimp\n    show (aux φ).left = (aux ψ).left\n    congr 1\n    rw [← cancel_mono sq]\n    apply CommaMorphism.ext\n    · exact h\n    · rw [Comma.comp_right, Comma.comp_right, this, this, Category.assoc, Category.assoc]\n      rw [←Arrow.w]\n      simp only [← Category.assoc, h]\n#align category_theory.arrow.mono_left CategoryTheory.Arrow.mono_left\n\ninstance epi_right [Epi sq] : Epi sq.right where\n  left_cancellation {Z} φ ψ h := by\n    let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>\n      { right := φ\n        left := g.hom ≫ φ }\n    show (aux φ).right = (aux ψ).right\n    congr 1\n    rw [← cancel_epi sq]\n    apply CommaMorphism.ext\n    · rw [Comma.comp_left, Comma.comp_left, Arrow.w_assoc, Arrow.w_assoc, h]\n    · exact h\n#align category_theory.arrow.epi_right CategoryTheory.Arrow.epi_right\n\nend\n\n/-- Given a square from an arrow `i` to an isomorphism `p`, express the source part of `sq`\nin terms of the inverse of `p`. -/\n@[simp]\ntheorem square_to_iso_invert (i : Arrow T) {X Y : T} (p : X ≅ Y) (sq : i ⟶ Arrow.mk p.hom) :\n    i.hom ≫ sq.right ≫ p.inv = sq.left := by\n  simpa only [Category.assoc] using (Iso.comp_inv_eq p).mpr (Arrow.w_mk_right sq).symm\n#align category_theory.arrow.square_to_iso_invert CategoryTheory.Arrow.square_to_iso_invert\n\n/-- Given a square from an isomorphism `i` to an arrow `p`, express the target part of `sq`\nin terms of the inverse of `i`. -/\ntheorem square_from_iso_invert {X Y : T} (i : X ≅ Y) (p : Arrow T) (sq : Arrow.mk i.hom ⟶ p) :\n    i.inv ≫ sq.left ≫ p.hom = sq.right := by simp only [Iso.inv_hom_id_assoc, Arrow.w, Arrow.mk_hom]\n#align category_theory.arrow.square_from_iso_invert CategoryTheory.Arrow.square_from_iso_invert\n\nvariable {C : Type u} [Category.{v} C]\n\n/-- A helper construction: given a square between `i` and `f ≫ g`, produce a square between\n`i` and `g`, whose top leg uses `f`:\nA  → X\n     ↓f\n↓i   Y             --> A → Y\n     ↓g                ↓i  ↓g\nB  → Z                 B → Z\n -/\n@[simps]\ndef squareToSnd {X Y Z : C} {i : Arrow C} {f : X ⟶ Y} {g : Y ⟶ Z} (sq : i ⟶ Arrow.mk (f ≫ g)) :\n    i ⟶ Arrow.mk g where\n  left := sq.left ≫ f\n  right := sq.right\n#align category_theory.arrow.square_to_snd CategoryTheory.Arrow.squareToSnd\n\n/-- The functor sending an arrow to its source. -/\n@[simps!]\ndef leftFunc : Arrow C ⥤ C :=\n  Comma.fst _ _\n#align category_theory.arrow.left_func CategoryTheory.Arrow.leftFunc\n\n/-- The functor sending an arrow to its target. -/\n@[simps!]\ndef rightFunc : Arrow C ⥤ C :=\n  Comma.snd _ _\n#align category_theory.arrow.right_func CategoryTheory.Arrow.rightFunc\n\n/-- The natural transformation from `leftFunc` to `rightFunc`, given by the arrow itself. -/\n@[simps]\ndef leftToRight : (leftFunc : Arrow C ⥤ C) ⟶ rightFunc where app f := f.hom\n#align category_theory.arrow.left_to_right CategoryTheory.Arrow.leftToRight\n\nend Arrow\n\nnamespace Functor\n\nuniverse v₁ v₂ u₁ u₂\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]\n\n/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/\n@[simps]\ndef mapArrow (F : C ⥤ D) : Arrow C ⥤ Arrow D where\n  obj a :=\n    { left := F.obj a.left\n      right := F.obj a.right\n      hom := F.map a.hom }\n  map f :=\n    { left := F.map f.left\n      right := F.map f.right\n      w := by\n        let w := f.w\n        simp only [id_map] at w\n        dsimp\n        simp only [← F.map_comp, w] }\n  map_id := by aesop_cat\n  map_comp := fun f g => by\n    apply CommaMorphism.ext\n    · dsimp; rw [Comma.comp_left,F.map_comp]; rw [Comma.comp_left]\n    · dsimp; rw [Comma.comp_right,F.map_comp]; rw [Comma.comp_right]\n#align category_theory.functor.map_arrow CategoryTheory.Functor.mapArrow\n\nend Functor\n\n/-- The images of `f : Arrow C` by two isomorphic functors `F : C ⥤ D` are\nisomorphic arrows in `D`. -/\ndef Arrow.isoOfNatIso {C D : Type _} [Category C] [Category D] {F G : C ⥤ D} (e : F ≅ G)\n    (f : Arrow C) : F.mapArrow.obj f ≅ G.mapArrow.obj f :=\n  Arrow.isoMk (e.app f.left) (e.app f.right) (by simp)\n#align category_theory.arrow.iso_of_nat_iso CategoryTheory.Arrow.isoOfNatIso\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Arrow.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6959583376458153, "lm_q1q2_score": 0.46309802631740576}}
{"text": "/-\nCopyright (c) 2022 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\nimport algebra.category.Ring.constructions\nimport algebra.category.Ring.colimits\nimport category_theory.isomorphism\nimport ring_theory.localization.away\nimport ring_theory.is_tensor_product\n\n/-!\n# Properties of ring homomorphisms\n\nWe provide the basic framework for talking about properties of ring homomorphisms.\nThe following meta-properties of predicates on ring homomorphisms are defined\n\n* `ring_hom.respects_iso`: `P` respects isomorphisms if `P f → P (e ≫ f)` and\n  `P f → P (f ≫ e)`, where `e` is an isomorphism.\n* `ring_hom.stable_under_composition`: `P` is stable under composition if `P f → P g → P (f ≫ g)`.\n* `ring_hom.stable_under_base_change`: `P` is stable under base change if `P (S ⟶ Y)`\n  implies `P (X ⟶ X ⊗[S] Y)`.\n\n-/\n\nuniverse u\n\nopen category_theory opposite category_theory.limits\n\nnamespace ring_hom\n\nvariable (P : ∀ {R S : Type u} [comm_ring R] [comm_ring S] (f : by exactI R →+* S), Prop)\n\ninclude P\n\nsection respects_iso\n\n/-- A property `respects_iso` if it still holds when composed with an isomorphism -/\ndef respects_iso : Prop :=\n(∀ {R S T : Type u} [comm_ring R] [comm_ring S] [comm_ring T], by exactI\n    ∀ (f : R →+* S) (e : S ≃+* T) (hf : P f), P (e.to_ring_hom.comp f)) ∧\n  (∀ {R S T : Type u} [comm_ring R] [comm_ring S] [comm_ring T], by exactI\n    ∀ (f : S →+* T) (e : R ≃+* S) (hf : P f), P (f.comp e.to_ring_hom))\n\nvariable {P}\n\nlemma respects_iso.cancel_left_is_iso (hP : respects_iso @P) {R S T : CommRing}\n  (f : R ⟶ S) (g : S ⟶ T)\n  [is_iso f] : P (f ≫ g) ↔ P g :=\n⟨λ H, by { convert hP.2 (f ≫ g) (as_iso f).symm.CommRing_iso_to_ring_equiv H,\n  exact (is_iso.inv_hom_id_assoc _ _).symm }, hP.2 g (as_iso f).CommRing_iso_to_ring_equiv⟩\n\nlemma respects_iso.cancel_right_is_iso (hP : respects_iso @P) {R S T : CommRing}\n  (f : R ⟶ S) (g : S ⟶ T)\n  [is_iso g] : P (f ≫ g) ↔ P f :=\n⟨λ H, by { convert hP.1 (f ≫ g) (as_iso g).symm.CommRing_iso_to_ring_equiv H,\n  change f = f ≫ g ≫ (inv g), simp }, hP.1 f (as_iso g).CommRing_iso_to_ring_equiv⟩\n\nlemma respects_iso.is_localization_away_iff (hP : ring_hom.respects_iso @P) {R S : Type*}\n  (R' S' : Type*) [comm_ring R] [comm_ring S] [comm_ring R'] [comm_ring S'] [algebra R R']\n  [algebra S S'] (f : R →+* S) (r : R) [is_localization.away r R'] [is_localization.away (f r) S'] :\n  P (localization.away_map f r) ↔ P (is_localization.away.map R' S' f r) :=\nbegin\n  let e₁ : R' ≃+* localization.away r :=\n    (is_localization.alg_equiv (submonoid.powers r) _ _).to_ring_equiv,\n  let e₂ : localization.away (f r) ≃+* S' :=\n    (is_localization.alg_equiv (submonoid.powers (f r)) _ _).to_ring_equiv,\n  refine (hP.cancel_left_is_iso e₁.to_CommRing_iso.hom (CommRing.of_hom _)).symm.trans _,\n  refine (hP.cancel_right_is_iso (CommRing.of_hom _) e₂.to_CommRing_iso.hom).symm.trans _,\n  rw ← eq_iff_iff,\n  congr' 1,\n  dsimp [CommRing.of_hom, CommRing.of, bundled.of],\n  refine is_localization.ring_hom_ext (submonoid.powers r) _,\n  ext1,\n  revert e₁ e₂,\n  dsimp [ring_equiv.to_ring_hom, is_localization.away.map],\n  simp only [category_theory.comp_apply, ring_equiv.refl_apply, is_localization.alg_equiv_apply,\n    is_localization.ring_equiv_of_ring_equiv_apply, ring_hom.coe_mk, ring_equiv.to_fun_eq_coe,\n    is_localization.ring_equiv_of_ring_equiv_eq, is_localization.map_eq],\nend\n\nend respects_iso\n\nsection stable_under_composition\n\n/-- A property is `stable_under_composition` if the composition of two such morphisms\nstill falls in the class. -/\ndef stable_under_composition : Prop :=\n  ∀ ⦃R S T⦄ [comm_ring R] [comm_ring S] [comm_ring T],\n    by exactI ∀ (f : R →+* S) (g : S →+* T) (hf : P f) (hg : P g), P (g.comp f)\n\nvariable {P}\n\nlemma stable_under_composition.respects_iso (hP : ring_hom.stable_under_composition @P)\n  (hP' : ∀ {R S : Type*} [comm_ring R] [comm_ring S] (e : by exactI R ≃+* S),\n    by exactI P e.to_ring_hom) : ring_hom.respects_iso @P :=\nbegin\n  split,\n  { introv H, resetI, apply hP, exacts [H, hP' e] },\n  { introv H, resetI, apply hP, exacts [hP' e, H] }\nend\n\nend stable_under_composition\n\nsection stable_under_base_change\n\n/-- A morphism property `P` is `stable_under_base_change` if `P(S →+* A)` implies\n`P(B →+* A ⊗[S] B)`. -/\ndef stable_under_base_change : Prop :=\n  ∀ (R S R' S') [comm_ring R] [comm_ring S] [comm_ring R'] [comm_ring S'],\n    by exactI ∀ [algebra R S] [algebra R R'] [algebra R S'] [algebra S S'] [algebra R' S'],\n    by exactI ∀ [is_scalar_tower R S S'] [is_scalar_tower R R' S'],\n    by exactI ∀ [algebra.is_pushout R S R' S'], P (algebra_map R S) → P (algebra_map R' S')\n\nlemma stable_under_base_change.mk\n  (h₁ : respects_iso @P)\n  (h₂ : ∀ ⦃R S T⦄ [comm_ring R] [comm_ring S] [comm_ring T],\n    by exactI ∀ [algebra R S] [algebra R T], by exactI (P (algebra_map R T) →\n      P (algebra.tensor_product.include_left.to_ring_hom : S →+* tensor_product R S T))) :\n  stable_under_base_change @P :=\nbegin\n  introv R h H,\n  resetI,\n  let e := h.symm.1.equiv,\n  let f' := algebra.tensor_product.product_map (is_scalar_tower.to_alg_hom R R' S')\n    (is_scalar_tower.to_alg_hom R S S'),\n  have : ∀ x, e x = f' x,\n  { intro x,\n    change e.to_linear_map.restrict_scalars R x = f'.to_linear_map x,\n    congr' 1,\n    apply tensor_product.ext',\n    intros x y,\n    simp [is_base_change.equiv_tmul, algebra.smul_def] },\n  convert h₁.1 _ _ (h₂ H : P (_ : R' →+* _)),\n  swap,\n  { refine { map_mul' := λ x y, _, ..e },\n    change e (x * y) = e x * e y,\n    simp_rw this,\n    exact map_mul f' _ _ },\n  { ext,\n    change _ = e (x ⊗ₜ[R] 1),\n    dsimp only [e],\n    rw [h.symm.1.equiv_tmul, algebra.smul_def, alg_hom.to_linear_map_apply, map_one, mul_one] }\nend\n\nomit P\n\nlocal attribute [instance] algebra.tensor_product.right_algebra\n\nlemma stable_under_base_change.pushout_inl\n  (hP : ring_hom.stable_under_base_change @P) (hP' : ring_hom.respects_iso @P) {R S T : CommRing}\n  (f : R ⟶ S) (g : R ⟶ T) (H : P g) : P (pushout.inl : S ⟶ pushout f g) :=\nbegin\n  rw [← (show _ = pushout.inl, from colimit.iso_colimit_cocone_ι_inv\n    ⟨_, CommRing.pushout_cocone_is_colimit f g⟩ walking_span.left), hP'.cancel_right_is_iso],\n  letI := f.to_algebra,\n  letI := g.to_algebra,\n  dsimp only [CommRing.pushout_cocone_inl, pushout_cocone.ι_app_left],\n  apply hP R T S (tensor_product R S T),\n  exact H,\nend\n\nend stable_under_base_change\n\nend ring_hom\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/ring_hom_properties.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4630980128856029}}
{"text": "/-\nCopyright (c) 2020 Fox Thomson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fox Thomson\n\n! This file was ported from Lean 3 source module computability.language\n! leanprover-community/mathlib commit e97cf15cd1aec9bd5c193b2ffac5a6dc9118912b\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Hom.Ring\nimport Mathbin.Algebra.Order.Kleene\nimport Mathbin.Data.List.Join\nimport Mathbin.Data.Set.Lattice\n\n/-!\n# Languages\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains the definition and operations on formal languages over an alphabet. Note strings\nare implemented as lists over the alphabet.\nThe operations in this file define a [Kleene algebra](https://en.wikipedia.org/wiki/Kleene_algebra)\nover the languages.\n-/\n\n\nopen List Set\n\nopen Computability\n\nuniverse v\n\nvariable {α β γ : Type _}\n\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_mem[has_mem] (list[list] α) -/\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_singleton[has_singleton] (list[list] α) -/\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_insert[has_insert] (list[list] α) -/\n#print Language /-\n/-- A language is a set of strings over an alphabet. -/\ndef Language (α) :=\n  Set (List α)deriving\n  «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_mem[has_mem] (list[list] α)»,\n  «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_singleton[has_singleton] (list[list] α)»,\n  «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_insert[has_insert] (list[list] α)»,\n  CompleteBooleanAlgebra\n#align language Language\n-/\n\nnamespace Language\n\nvariable {l m : Language α} {a b x : List α}\n\nattribute [local reducible] Language\n\n/-- Zero language has no elements. -/\ninstance : Zero (Language α) :=\n  ⟨(∅ : Set _)⟩\n\n/-- `1 : language α` contains only one element `[]`. -/\ninstance : One (Language α) :=\n  ⟨{[]}⟩\n\ninstance : Inhabited (Language α) :=\n  ⟨0⟩\n\n/-- The sum of two languages is their union. -/\ninstance : Add (Language α) :=\n  ⟨(· ∪ ·)⟩\n\n/-- The product of two languages `l` and `m` is the language made of the strings `x ++ y` where\n`x ∈ l` and `y ∈ m`. -/\ninstance : Mul (Language α) :=\n  ⟨image2 (· ++ ·)⟩\n\n#print Language.zero_def /-\ntheorem zero_def : (0 : Language α) = (∅ : Set _) :=\n  rfl\n#align language.zero_def Language.zero_def\n-/\n\n#print Language.one_def /-\ntheorem one_def : (1 : Language α) = {[]} :=\n  rfl\n#align language.one_def Language.one_def\n-/\n\n/- warning: language.add_def -> Language.add_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α) (m : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) l m) (Union.union.{u1} (Language.{u1} α) (Set.hasUnion.{u1} (List.{u1} α)) l m)\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α) (m : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) l m) (Union.union.{u1} (Set.{u1} (List.{u1} α)) (Set.instUnionSet.{u1} (List.{u1} α)) l m)\nCase conversion may be inaccurate. Consider using '#align language.add_def Language.add_defₓ'. -/\ntheorem add_def (l m : Language α) : l + m = l ∪ m :=\n  rfl\n#align language.add_def Language.add_def\n\n#print Language.mul_def /-\ntheorem mul_def (l m : Language α) : l * m = image2 (· ++ ·) l m :=\n  rfl\n#align language.mul_def Language.mul_def\n-/\n\n/-- The Kleene star of a language `L` is the set of all strings which can be written by\nconcatenating strings from `L`. -/\ninstance : KStar (Language α) :=\n  ⟨fun l => { x | ∃ L : List (List α), x = L.join ∧ ∀ y ∈ L, y ∈ l }⟩\n\n#print Language.kstar_def /-\ntheorem kstar_def (l : Language α) :\n    l∗ = { x | ∃ L : List (List α), x = L.join ∧ ∀ y ∈ L, y ∈ l } :=\n  rfl\n#align language.kstar_def Language.kstar_def\n-/\n\n#print Language.not_mem_zero /-\n@[simp]\ntheorem not_mem_zero (x : List α) : x ∉ (0 : Language α) :=\n  id\n#align language.not_mem_zero Language.not_mem_zero\n-/\n\n#print Language.mem_one /-\n@[simp]\ntheorem mem_one (x : List α) : x ∈ (1 : Language α) ↔ x = [] := by rfl\n#align language.mem_one Language.mem_one\n-/\n\n#print Language.nil_mem_one /-\ntheorem nil_mem_one : [] ∈ (1 : Language α) :=\n  Set.mem_singleton _\n#align language.nil_mem_one Language.nil_mem_one\n-/\n\n/- warning: language.mem_add -> Language.mem_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α) (m : Language.{u1} α) (x : List.{u1} α), Iff (Membership.Mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (Language.hasMem.{u1} α) x (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) l m)) (Or (Membership.Mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (Language.hasMem.{u1} α) x l) (Membership.Mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (Language.hasMem.{u1} α) x m))\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α) (m : Language.{u1} α) (x : List.{u1} α), Iff (Membership.mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (instMembershipListLanguage.{u1} α) x (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) l m)) (Or (Membership.mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (instMembershipListLanguage.{u1} α) x l) (Membership.mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (instMembershipListLanguage.{u1} α) x m))\nCase conversion may be inaccurate. Consider using '#align language.mem_add Language.mem_addₓ'. -/\ntheorem mem_add (l m : Language α) (x : List α) : x ∈ l + m ↔ x ∈ l ∨ x ∈ m :=\n  Iff.rfl\n#align language.mem_add Language.mem_add\n\n#print Language.mem_mul /-\ntheorem mem_mul : x ∈ l * m ↔ ∃ a b, a ∈ l ∧ b ∈ m ∧ a ++ b = x :=\n  mem_image2\n#align language.mem_mul Language.mem_mul\n-/\n\n#print Language.append_mem_mul /-\ntheorem append_mem_mul : a ∈ l → b ∈ m → a ++ b ∈ l * m :=\n  mem_image2_of_mem\n#align language.append_mem_mul Language.append_mem_mul\n-/\n\n#print Language.mem_kstar /-\ntheorem mem_kstar : x ∈ l∗ ↔ ∃ L : List (List α), x = L.join ∧ ∀ y ∈ L, y ∈ l :=\n  Iff.rfl\n#align language.mem_kstar Language.mem_kstar\n-/\n\n#print Language.join_mem_kstar /-\ntheorem join_mem_kstar {L : List (List α)} (h : ∀ y ∈ L, y ∈ l) : L.join ∈ l∗ :=\n  ⟨L, rfl, h⟩\n#align language.join_mem_kstar Language.join_mem_kstar\n-/\n\n#print Language.nil_mem_kstar /-\ntheorem nil_mem_kstar (l : Language α) : [] ∈ l∗ :=\n  ⟨[], rfl, fun _ => False.elim⟩\n#align language.nil_mem_kstar Language.nil_mem_kstar\n-/\n\ninstance : Semiring (Language α) where\n  add := (· + ·)\n  add_assoc := union_assoc\n  zero := 0\n  zero_add := empty_union\n  add_zero := union_empty\n  add_comm := union_comm\n  mul := (· * ·)\n  mul_assoc _ _ _ := image2_assoc append_assoc\n  zero_mul _ := image2_empty_left\n  mul_zero _ := image2_empty_right\n  one := 1\n  one_mul l := by simp [mul_def, one_def]\n  mul_one l := by simp [mul_def, one_def]\n  natCast n := if n = 0 then 0 else 1\n  natCast_zero := rfl\n  natCast_succ n := by cases n <;> simp [Nat.cast, add_def, zero_def]\n  left_distrib _ _ _ := image2_union_right\n  right_distrib _ _ _ := image2_union_left\n\n/- warning: language.add_self -> Language.add_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) l l) l\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) l l) l\nCase conversion may be inaccurate. Consider using '#align language.add_self Language.add_selfₓ'. -/\n@[simp]\ntheorem add_self (l : Language α) : l + l = l :=\n  sup_idem\n#align language.add_self Language.add_self\n\n/- warning: language.map -> Language.map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}}, (α -> β) -> (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}}, (α -> β) -> (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.instSemiringLanguage.{u2} β)))\nCase conversion may be inaccurate. Consider using '#align language.map Language.mapₓ'. -/\n/-- Maps the alphabet of a language. -/\ndef map (f : α → β) : Language α →+* Language β\n    where\n  toFun := image (List.map f)\n  map_zero' := image_empty _\n  map_one' := image_singleton\n  map_add' := image_union _\n  map_mul' _ _ := image_image2_distrib <| map_append _\n#align language.map Language.map\n\n/- warning: language.map_id -> Language.map_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α))) (fun (_x : RingHom.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α))) => (Language.{u1} α) -> (Language.{u1} α)) (RingHom.hasCoeToFun.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α))) (Language.map.{u1, u1} α α (id.{succ u1} α)) l) l\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} α) => Language.{u1} α) l) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))) (Language.{u1} α) (fun (_x : Language.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} α) => Language.{u1} α) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))) (Language.{u1} α) (Language.{u1} α) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))) (Language.{u1} α) (Language.{u1} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))) (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (RingHom.instRingHomClassRingHom.{u1, u1} (Language.{u1} α) (Language.{u1} α) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α)))))) (Language.map.{u1, u1} α α (id.{succ u1} α)) l) l\nCase conversion may be inaccurate. Consider using '#align language.map_id Language.map_idₓ'. -/\n@[simp]\ntheorem map_id (l : Language α) : map id l = l := by simp [map]\n#align language.map_id Language.map_id\n\n/- warning: language.map_map -> Language.map_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (g : β -> γ) (f : α -> β) (l : Language.{u1} α), Eq.{succ u3} (Language.{u3} γ) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} (Language.{u2} β) (Language.{u3} γ) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} γ) (Language.semiring.{u3} γ))) (fun (_x : RingHom.{u2, u3} (Language.{u2} β) (Language.{u3} γ) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} γ) (Language.semiring.{u3} γ))) => (Language.{u2} β) -> (Language.{u3} γ)) (RingHom.hasCoeToFun.{u2, u3} (Language.{u2} β) (Language.{u3} γ) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} γ) (Language.semiring.{u3} γ))) (Language.map.{u2, u3} β γ g) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (fun (_x : RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) => (Language.{u1} α) -> (Language.{u2} β)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (Language.map.{u1, u2} α β f) l)) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} (Language.{u1} α) (Language.{u3} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} γ) (Language.semiring.{u3} γ))) (fun (_x : RingHom.{u1, u3} (Language.{u1} α) (Language.{u3} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} γ) (Language.semiring.{u3} γ))) => (Language.{u1} α) -> (Language.{u3} γ)) (RingHom.hasCoeToFun.{u1, u3} (Language.{u1} α) (Language.{u3} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} γ) (Language.semiring.{u3} γ))) (Language.map.{u1, u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ g f)) l)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} (g : β -> γ) (f : α -> β) (l : Language.{u3} α), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} β) => Language.{u2} γ) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (fun (a : Language.{u3} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u3} α) => Language.{u1} β) a) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u3} (Language.{u3} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} α) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} α) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u3, u1} α β f) l)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} (Language.{u1} β) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u1} β) (fun (_x : Language.{u1} β) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} β) => Language.{u2} γ) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} (Language.{u1} β) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u1} β) (Language.{u2} γ) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} γ) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} (Language.{u1} β) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u1} β) (Language.{u2} γ) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} (Language.{u1} β) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u1} β) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ)) (RingHom.instRingHomClassRingHom.{u1, u2} (Language.{u1} β) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ)))))) (Language.map.{u1, u2} β γ g) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (fun (_x : Language.{u3} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u3} α) => Language.{u1} β) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u3} (Language.{u3} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} α) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} α) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u3, u1} (Language.{u3} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u3, u1} α β f) l)) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} (Language.{u3} α) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u3} α) (fun (_x : Language.{u3} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u3} α) => Language.{u2} γ) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} (Language.{u3} α) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u3} α) (Language.{u2} γ) (NonUnitalNonAssocSemiring.toMul.{u3} (Language.{u3} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} α) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)))) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} γ) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ)))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} (Language.{u3} α) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u3} α) (Language.{u2} γ) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} α) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} (Language.{u3} α) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ))) (Language.{u3} α) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ)) (RingHom.instRingHomClassRingHom.{u3, u2} (Language.{u3} α) (Language.{u2} γ) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} α) (Language.instSemiringLanguage.{u3} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} γ) (Language.instSemiringLanguage.{u2} γ)))))) (Language.map.{u3, u2} α γ (Function.comp.{succ u3, succ u1, succ u2} α β γ g f)) l)\nCase conversion may be inaccurate. Consider using '#align language.map_map Language.map_mapₓ'. -/\n@[simp]\ntheorem map_map (g : β → γ) (f : α → β) (l : Language α) : map g (map f l) = map (g ∘ f) l := by\n  simp [map, image_image]\n#align language.map_map Language.map_map\n\n#print Language.kstar_def_nonempty /-\ntheorem kstar_def_nonempty (l : Language α) :\n    l∗ = { x | ∃ S : List (List α), x = S.join ∧ ∀ y ∈ S, y ∈ l ∧ y ≠ [] } :=\n  by\n  ext x\n  constructor\n  · rintro ⟨S, rfl, h⟩\n    refine' ⟨S.filter fun l => ¬List.isEmpty l, by simp, fun y hy => _⟩\n    rw [mem_filter, empty_iff_eq_nil] at hy\n    exact ⟨h y hy.1, hy.2⟩\n  · rintro ⟨S, hx, h⟩\n    exact ⟨S, hx, fun y hy => (h y hy).1⟩\n#align language.kstar_def_nonempty Language.kstar_def_nonempty\n-/\n\n/- warning: language.le_iff -> Language.le_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α) (m : Language.{u1} α), Iff (LE.le.{u1} (Language.{u1} α) (Set.hasLe.{u1} (List.{u1} α)) l m) (Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) l m) m)\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α) (m : Language.{u1} α), Iff (LE.le.{u1} (Language.{u1} α) (Preorder.toLE.{u1} (Language.{u1} α) (PartialOrder.toPreorder.{u1} (Language.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)))))))) l m) (Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) l m) m)\nCase conversion may be inaccurate. Consider using '#align language.le_iff Language.le_iffₓ'. -/\ntheorem le_iff (l m : Language α) : l ≤ m ↔ l + m = m :=\n  sup_eq_right.symm\n#align language.le_iff Language.le_iff\n\n#print Language.le_mul_congr /-\ntheorem le_mul_congr {l₁ l₂ m₁ m₂ : Language α} : l₁ ≤ m₁ → l₂ ≤ m₂ → l₁ * l₂ ≤ m₁ * m₂ :=\n  by\n  intro h₁ h₂ x hx\n  simp only [mul_def, exists_and_left, mem_image2, image_prod] at hx⊢\n  tauto\n#align language.le_mul_congr Language.le_mul_congr\n-/\n\n/- warning: language.le_add_congr -> Language.le_add_congr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {l₁ : Language.{u1} α} {l₂ : Language.{u1} α} {m₁ : Language.{u1} α} {m₂ : Language.{u1} α}, (LE.le.{u1} (Language.{u1} α) (Set.hasLe.{u1} (List.{u1} α)) l₁ m₁) -> (LE.le.{u1} (Language.{u1} α) (Set.hasLe.{u1} (List.{u1} α)) l₂ m₂) -> (LE.le.{u1} (Language.{u1} α) (Set.hasLe.{u1} (List.{u1} α)) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) l₁ l₂) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) m₁ m₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {l₁ : Language.{u1} α} {l₂ : Language.{u1} α} {m₁ : Language.{u1} α} {m₂ : Language.{u1} α}, (LE.le.{u1} (Language.{u1} α) (Preorder.toLE.{u1} (Language.{u1} α) (PartialOrder.toPreorder.{u1} (Language.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)))))))) l₁ m₁) -> (LE.le.{u1} (Language.{u1} α) (Preorder.toLE.{u1} (Language.{u1} α) (PartialOrder.toPreorder.{u1} (Language.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)))))))) l₂ m₂) -> (LE.le.{u1} (Language.{u1} α) (Preorder.toLE.{u1} (Language.{u1} α) (PartialOrder.toPreorder.{u1} (Language.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)))))))) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) l₁ l₂) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) m₁ m₂))\nCase conversion may be inaccurate. Consider using '#align language.le_add_congr Language.le_add_congrₓ'. -/\ntheorem le_add_congr {l₁ l₂ m₁ m₂ : Language α} : l₁ ≤ m₁ → l₂ ≤ m₂ → l₁ + l₂ ≤ m₁ + m₂ :=\n  sup_le_sup\n#align language.le_add_congr Language.le_add_congr\n\n/- warning: language.mem_supr -> Language.mem_supᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u2}} {ι : Sort.{u1}} {l : ι -> (Language.{u2} α)} {x : List.{u2} α}, Iff (Membership.Mem.{u2, u2} (List.{u2} α) (Language.{u2} α) (Language.hasMem.{u2} α) x (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => l i))) (Exists.{u1} ι (fun (i : ι) => Membership.Mem.{u2, u2} (List.{u2} α) (Language.{u2} α) (Language.hasMem.{u2} α) x (l i)))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Sort.{u2}} {l : ι -> (Language.{u1} α)} {x : List.{u1} α}, Iff (Membership.mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (instMembershipListLanguage.{u1} α) x (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => l i))) (Exists.{u2} ι (fun (i : ι) => Membership.mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (instMembershipListLanguage.{u1} α) x (l i)))\nCase conversion may be inaccurate. Consider using '#align language.mem_supr Language.mem_supᵢₓ'. -/\ntheorem mem_supᵢ {ι : Sort v} {l : ι → Language α} {x : List α} : (x ∈ ⨆ i, l i) ↔ ∃ i, x ∈ l i :=\n  mem_unionᵢ\n#align language.mem_supr Language.mem_supᵢ\n\n/- warning: language.supr_mul -> Language.supᵢ_mul is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u2}} {ι : Sort.{u1}} (l : ι -> (Language.{u2} α)) (m : Language.{u2} α), Eq.{succ u2} (Language.{u2} α) (HMul.hMul.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHMul.{u2} (Language.{u2} α) (Language.hasMul.{u2} α)) (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => l i)) m) (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => HMul.hMul.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHMul.{u2} (Language.{u2} α) (Language.hasMul.{u2} α)) (l i) m))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Sort.{u2}} (l : ι -> (Language.{u1} α)) (m : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.instMulLanguage.{u1} α)) (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => l i)) m) (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.instMulLanguage.{u1} α)) (l i) m))\nCase conversion may be inaccurate. Consider using '#align language.supr_mul Language.supᵢ_mulₓ'. -/\ntheorem supᵢ_mul {ι : Sort v} (l : ι → Language α) (m : Language α) :\n    (⨆ i, l i) * m = ⨆ i, l i * m :=\n  image2_unionᵢ_left _ _ _\n#align language.supr_mul Language.supᵢ_mul\n\n/- warning: language.mul_supr -> Language.mul_supᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u2}} {ι : Sort.{u1}} (l : ι -> (Language.{u2} α)) (m : Language.{u2} α), Eq.{succ u2} (Language.{u2} α) (HMul.hMul.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHMul.{u2} (Language.{u2} α) (Language.hasMul.{u2} α)) m (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => l i))) (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => HMul.hMul.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHMul.{u2} (Language.{u2} α) (Language.hasMul.{u2} α)) m (l i)))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Sort.{u2}} (l : ι -> (Language.{u1} α)) (m : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.instMulLanguage.{u1} α)) m (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => l i))) (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.instMulLanguage.{u1} α)) m (l i)))\nCase conversion may be inaccurate. Consider using '#align language.mul_supr Language.mul_supᵢₓ'. -/\ntheorem mul_supᵢ {ι : Sort v} (l : ι → Language α) (m : Language α) :\n    (m * ⨆ i, l i) = ⨆ i, m * l i :=\n  image2_unionᵢ_right _ _ _\n#align language.mul_supr Language.mul_supᵢ\n\n/- warning: language.supr_add -> Language.supᵢ_add is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : Nonempty.{u1} ι] (l : ι -> (Language.{u2} α)) (m : Language.{u2} α), Eq.{succ u2} (Language.{u2} α) (HAdd.hAdd.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHAdd.{u2} (Language.{u2} α) (Language.hasAdd.{u2} α)) (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => l i)) m) (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => HAdd.hAdd.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHAdd.{u2} (Language.{u2} α) (Language.hasAdd.{u2} α)) (l i) m))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : Nonempty.{u2} ι] (l : ι -> (Language.{u1} α)) (m : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => l i)) m) (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) (l i) m))\nCase conversion may be inaccurate. Consider using '#align language.supr_add Language.supᵢ_addₓ'. -/\ntheorem supᵢ_add {ι : Sort v} [Nonempty ι] (l : ι → Language α) (m : Language α) :\n    (⨆ i, l i) + m = ⨆ i, l i + m :=\n  supᵢ_sup\n#align language.supr_add Language.supᵢ_add\n\n/- warning: language.add_supr -> Language.add_supᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : Nonempty.{u1} ι] (l : ι -> (Language.{u2} α)) (m : Language.{u2} α), Eq.{succ u2} (Language.{u2} α) (HAdd.hAdd.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHAdd.{u2} (Language.{u2} α) (Language.hasAdd.{u2} α)) m (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => l i))) (supᵢ.{u2, u1} (Language.{u2} α) (Set.hasSup.{u2} (List.{u2} α)) ι (fun (i : ι) => HAdd.hAdd.{u2, u2, u2} (Language.{u2} α) (Language.{u2} α) (Language.{u2} α) (instHAdd.{u2} (Language.{u2} α) (Language.hasAdd.{u2} α)) m (l i)))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : Nonempty.{u2} ι] (l : ι -> (Language.{u1} α)) (m : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) m (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => l i))) (supᵢ.{u1, u2} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) ι (fun (i : ι) => HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) m (l i)))\nCase conversion may be inaccurate. Consider using '#align language.add_supr Language.add_supᵢₓ'. -/\ntheorem add_supᵢ {ι : Sort v} [Nonempty ι] (l : ι → Language α) (m : Language α) :\n    (m + ⨆ i, l i) = ⨆ i, m + l i :=\n  sup_supᵢ\n#align language.add_supr Language.add_supᵢ\n\n/- warning: language.mem_pow -> Language.mem_pow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {l : Language.{u1} α} {x : List.{u1} α} {n : Nat}, Iff (Membership.Mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (Language.hasMem.{u1} α) x (HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.semiring.{u1} α))))) l n)) (Exists.{succ u1} (List.{u1} (List.{u1} α)) (fun (S : List.{u1} (List.{u1} α)) => And (Eq.{succ u1} (List.{u1} α) x (List.join.{u1} α S)) (And (Eq.{1} Nat (List.length.{u1} (List.{u1} α) S) n) (forall (y : List.{u1} α), (Membership.Mem.{u1, u1} (List.{u1} α) (List.{u1} (List.{u1} α)) (List.hasMem.{u1} (List.{u1} α)) y S) -> (Membership.Mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (Language.hasMem.{u1} α) y l)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {l : Language.{u1} α} {x : List.{u1} α} {n : Nat}, Iff (Membership.mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (instMembershipListLanguage.{u1} α) x (HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))))) l n)) (Exists.{succ u1} (List.{u1} (List.{u1} α)) (fun (S : List.{u1} (List.{u1} α)) => And (Eq.{succ u1} (List.{u1} α) x (List.join.{u1} α S)) (And (Eq.{1} Nat (List.length.{u1} (List.{u1} α) S) n) (forall (y : List.{u1} α), (Membership.mem.{u1, u1} (List.{u1} α) (List.{u1} (List.{u1} α)) (List.instMembershipList.{u1} (List.{u1} α)) y S) -> (Membership.mem.{u1, u1} (List.{u1} α) (Language.{u1} α) (instMembershipListLanguage.{u1} α) y l)))))\nCase conversion may be inaccurate. Consider using '#align language.mem_pow Language.mem_powₓ'. -/\ntheorem mem_pow {l : Language α} {x : List α} {n : ℕ} :\n    x ∈ l ^ n ↔ ∃ S : List (List α), x = S.join ∧ S.length = n ∧ ∀ y ∈ S, y ∈ l :=\n  by\n  induction' n with n ihn generalizing x\n  · simp only [mem_one, pow_zero, length_eq_zero]\n    constructor\n    · rintro rfl\n      exact ⟨[], rfl, rfl, fun y h => h.elim⟩\n    · rintro ⟨_, rfl, rfl, _⟩\n      rfl\n  · simp only [pow_succ, mem_mul, ihn]\n    constructor\n    · rintro ⟨a, b, ha, ⟨S, rfl, rfl, hS⟩, rfl⟩\n      exact ⟨a :: S, rfl, rfl, forall_mem_cons.2 ⟨ha, hS⟩⟩\n    · rintro ⟨_ | ⟨a, S⟩, rfl, hn, hS⟩ <;> cases hn\n      rw [forall_mem_cons] at hS\n      exact ⟨a, _, hS.1, ⟨S, rfl, rfl, hS.2⟩, rfl⟩\n#align language.mem_pow Language.mem_pow\n\n/- warning: language.kstar_eq_supr_pow -> Language.kstar_eq_supᵢ_pow is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (KStar.kstar.{u1} (Language.{u1} α) (Language.hasKstar.{u1} α) l) (supᵢ.{u1, 1} (Language.{u1} α) (Set.hasSup.{u1} (List.{u1} α)) Nat (fun (i : Nat) => HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.semiring.{u1} α))))) l i))\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (KStar.kstar.{u1} (Language.{u1} α) (Language.instKStarLanguage.{u1} α) l) (supᵢ.{u1, 1} (Language.{u1} α) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} α) (instCompleteBooleanAlgebraLanguage.{u1} α)) Nat (fun (i : Nat) => HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))))) l i))\nCase conversion may be inaccurate. Consider using '#align language.kstar_eq_supr_pow Language.kstar_eq_supᵢ_powₓ'. -/\ntheorem kstar_eq_supᵢ_pow (l : Language α) : l∗ = ⨆ i : ℕ, l ^ i :=\n  by\n  ext x\n  simp only [mem_kstar, mem_supr, mem_pow]\n  constructor\n  · rintro ⟨S, rfl, hS⟩\n    exact ⟨_, S, rfl, rfl, hS⟩\n  · rintro ⟨_, S, rfl, rfl, hS⟩\n    exact ⟨S, rfl, hS⟩\n#align language.kstar_eq_supr_pow Language.kstar_eq_supᵢ_pow\n\n/- warning: language.map_kstar -> Language.map_kstar is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (l : Language.{u1} α), Eq.{succ u2} (Language.{u2} β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (fun (_x : RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) => (Language.{u1} α) -> (Language.{u2} β)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (Language.map.{u1, u2} α β f) (KStar.kstar.{u1} (Language.{u1} α) (Language.hasKstar.{u1} α) l)) (KStar.kstar.{u2} (Language.{u2} β) (Language.hasKstar.{u2} β) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (fun (_x : RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) => (Language.{u1} α) -> (Language.{u2} β)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (Language.map.{u1, u2} α β f) l))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (l : Language.{u2} α), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} α) => Language.{u1} β) (KStar.kstar.{u2} (Language.{u2} α) (Language.instKStarLanguage.{u2} α) l)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (fun (_x : Language.{u2} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} α) => Language.{u1} β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u2, u1} α β f) (KStar.kstar.{u2} (Language.{u2} α) (Language.instKStarLanguage.{u2} α) l)) (KStar.kstar.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} α) => Language.{u1} β) l) (Language.instKStarLanguage.{u1} β) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (fun (_x : Language.{u2} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} α) => Language.{u1} β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u2, u1} α β f) l))\nCase conversion may be inaccurate. Consider using '#align language.map_kstar Language.map_kstarₓ'. -/\n@[simp]\ntheorem map_kstar (f : α → β) (l : Language α) : map f l∗ = (map f l)∗ :=\n  by\n  rw [kstar_eq_supr_pow, kstar_eq_supr_pow]\n  simp_rw [← map_pow]\n  exact image_Union\n#align language.map_kstar Language.map_kstar\n\n#print Language.mul_self_kstar_comm /-\ntheorem mul_self_kstar_comm (l : Language α) : l∗ * l = l * l∗ := by\n  simp only [kstar_eq_supr_pow, mul_supr, supr_mul, ← pow_succ, ← pow_succ']\n#align language.mul_self_kstar_comm Language.mul_self_kstar_comm\n-/\n\n/- warning: language.one_add_self_mul_kstar_eq_kstar -> Language.one_add_self_mul_kstar_eq_kstar is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) (OfNat.ofNat.{u1} (Language.{u1} α) 1 (OfNat.mk.{u1} (Language.{u1} α) 1 (One.one.{u1} (Language.{u1} α) (Language.hasOne.{u1} α)))) (HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.hasMul.{u1} α)) l (KStar.kstar.{u1} (Language.{u1} α) (Language.hasKstar.{u1} α) l))) (KStar.kstar.{u1} (Language.{u1} α) (Language.hasKstar.{u1} α) l)\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) (OfNat.ofNat.{u1} (Language.{u1} α) 1 (One.toOfNat1.{u1} (Language.{u1} α) (Language.instOneLanguage.{u1} α))) (HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.instMulLanguage.{u1} α)) l (KStar.kstar.{u1} (Language.{u1} α) (Language.instKStarLanguage.{u1} α) l))) (KStar.kstar.{u1} (Language.{u1} α) (Language.instKStarLanguage.{u1} α) l)\nCase conversion may be inaccurate. Consider using '#align language.one_add_self_mul_kstar_eq_kstar Language.one_add_self_mul_kstar_eq_kstarₓ'. -/\n@[simp]\ntheorem one_add_self_mul_kstar_eq_kstar (l : Language α) : 1 + l * l∗ = l∗ :=\n  by\n  simp only [kstar_eq_supr_pow, mul_supr, ← pow_succ, ← pow_zero l]\n  exact sup_supᵢ_nat_succ _\n#align language.one_add_self_mul_kstar_eq_kstar Language.one_add_self_mul_kstar_eq_kstar\n\n/- warning: language.one_add_kstar_mul_self_eq_kstar -> Language.one_add_kstar_mul_self_eq_kstar is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) (OfNat.ofNat.{u1} (Language.{u1} α) 1 (OfNat.mk.{u1} (Language.{u1} α) 1 (One.one.{u1} (Language.{u1} α) (Language.hasOne.{u1} α)))) (HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.hasMul.{u1} α)) (KStar.kstar.{u1} (Language.{u1} α) (Language.hasKstar.{u1} α) l) l)) (KStar.kstar.{u1} (Language.{u1} α) (Language.hasKstar.{u1} α) l)\nbut is expected to have type\n  forall {α : Type.{u1}} (l : Language.{u1} α), Eq.{succ u1} (Language.{u1} α) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) (OfNat.ofNat.{u1} (Language.{u1} α) 1 (One.toOfNat1.{u1} (Language.{u1} α) (Language.instOneLanguage.{u1} α))) (HMul.hMul.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHMul.{u1} (Language.{u1} α) (Language.instMulLanguage.{u1} α)) (KStar.kstar.{u1} (Language.{u1} α) (Language.instKStarLanguage.{u1} α) l) l)) (KStar.kstar.{u1} (Language.{u1} α) (Language.instKStarLanguage.{u1} α) l)\nCase conversion may be inaccurate. Consider using '#align language.one_add_kstar_mul_self_eq_kstar Language.one_add_kstar_mul_self_eq_kstarₓ'. -/\n@[simp]\ntheorem one_add_kstar_mul_self_eq_kstar (l : Language α) : 1 + l∗ * l = l∗ := by\n  rw [mul_self_kstar_comm, one_add_self_mul_kstar_eq_kstar]\n#align language.one_add_kstar_mul_self_eq_kstar Language.one_add_kstar_mul_self_eq_kstar\n\ninstance : KleeneAlgebra (Language α) :=\n  { Language.semiring, Set.completeBooleanAlgebra,\n    Language.hasKstar with\n    one_le_kstar := fun a l hl => ⟨[], hl, by simp⟩\n    mul_kstar_le_kstar := fun a => (one_add_self_mul_kstar_eq_kstar a).le.trans' le_sup_right\n    kstar_mul_le_kstar := fun a => (one_add_kstar_mul_self_eq_kstar a).le.trans' le_sup_right\n    kstar_mul_le_self := fun l m h =>\n      by\n      rw [kstar_eq_supr_pow, supr_mul]\n      refine' supᵢ_le fun n => _\n      induction' n with n ih\n      · simp\n      rw [pow_succ', mul_assoc (l ^ n) l m]\n      exact le_trans (le_mul_congr le_rfl h) ih\n    mul_kstar_le_self := fun l m h =>\n      by\n      rw [kstar_eq_supr_pow, mul_supr]\n      refine' supᵢ_le fun n => _\n      induction' n with n ih\n      · simp\n      rw [pow_succ, ← mul_assoc m l (l ^ n)]\n      exact le_trans (le_mul_congr h le_rfl) ih }\n\nend Language\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Computability/Language.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4630600144769033}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen\n-/\nimport linear_algebra.multilinear.basis\nimport linear_algebra.matrix.reindex\nimport ring_theory.algebra_tower\nimport linear_algebra.matrix.nonsingular_inverse\nimport linear_algebra.matrix.basis\n\n/-!\n# Determinant of families of vectors\n\nThis file defines the determinant of an endomorphism, and of a family of vectors\nwith respect to some basis. For the determinant of a matrix, see the file\n`linear_algebra.matrix.determinant`.\n\n## Main definitions\n\nIn the list below, and in all this file, `R` is a commutative ring (semiring\nis sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite\ntypes used for indexing.\n\n * `basis.det`: the determinant of a family of vectors with respect to a basis,\n   as a multilinear map\n * `linear_map.det`: the determinant of an endomorphism `f : End R M` as a\n   multiplicative homomorphism (if `M` does not have a finite `R`-basis, the\n   result is `1` instead)\n\n## Tags\n\nbasis, det, determinant\n-/\n\nnoncomputable theory\n\nopen_locale big_operators\nopen_locale matrix\n\nopen linear_map\nopen submodule\n\nuniverses u v w\n\nopen linear_map matrix set function\n\nvariables {R : Type*} [comm_ring R]\nvariables {M : Type*} [add_comm_group M] [module R M]\nvariables {M' : Type*} [add_comm_group M'] [module R M']\nvariables {ι : Type*} [decidable_eq ι] [fintype ι]\nvariables (e : basis ι R M)\n\nsection conjugate\n\nvariables {A : Type*} [comm_ring A]\nvariables {m n : Type*} [fintype m] [fintype n]\n\n/-- If `R^m` and `R^n` are linearly equivalent, then `m` and `n` are also equivalent. -/\ndef equiv_of_pi_lequiv_pi {R : Type*} [comm_ring R] [is_domain R]\n  (e : (m → R) ≃ₗ[R] (n → R)) : m ≃ n :=\nbasis.index_equiv (basis.of_equiv_fun e.symm) (pi.basis_fun _ _)\n\nnamespace matrix\n\n/-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to\nequivalence of types. -/\ndef index_equiv_of_inv [is_domain A] [decidable_eq m] [decidable_eq n]\n  {M : matrix m n A} {M' : matrix n m A}\n  (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :\n  m ≃ n :=\nequiv_of_pi_lequiv_pi (to_lin'_of_inv hMM' hM'M)\n\nlemma det_comm [decidable_eq n] (M N : matrix n n A) : det (M ⬝ N) = det (N ⬝ M) :=\nby rw [det_mul, det_mul, mul_comm]\n\n/-- If there exists a two-sided inverse `M'` for `M` (indexed differently),\nthen `det (N ⬝ M) = det (M ⬝ N)`. -/\nlemma det_comm' [is_domain A] [decidable_eq m] [decidable_eq n]\n  {M : matrix n m A} {N : matrix m n A} {M' : matrix m n A}\n  (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :\n  det (M ⬝ N) = det (N ⬝ M) :=\n-- Although `m` and `n` are different a priori, we will show they have the same cardinality.\n-- This turns the problem into one for square matrices, which is easy.\nlet e := index_equiv_of_inv hMM' hM'M in\nby rw [← det_minor_equiv_self e, minor_mul_equiv _ _ _ (equiv.refl n) _, det_comm,\n  ← minor_mul_equiv, equiv.coe_refl, minor_id_id]\n\n/-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M ⬝ N ⬝ M') = det N`. -/\nlemma det_conj [is_domain A] [decidable_eq m] [decidable_eq n]\n  {M : matrix m n A} {M' : matrix n m A} {N : matrix n n A}\n  (hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :\n  det (M ⬝ N ⬝ M') = det N :=\nby rw [← det_comm' hM'M hMM', ← matrix.mul_assoc, hM'M, matrix.one_mul]\n\nend matrix\n\nend conjugate\n\nnamespace linear_map\n\n/-! ### Determinant of a linear map -/\n\nvariables {A : Type*} [comm_ring A] [is_domain A] [module A M]\nvariables {κ : Type*} [fintype κ]\n\n/-- The determinant of `linear_map.to_matrix` does not depend on the choice of basis. -/\nlemma det_to_matrix_eq_det_to_matrix [decidable_eq κ]\n  (b : basis ι A M) (c : basis κ A M) (f : M →ₗ[A] M) :\n  det (linear_map.to_matrix b b f) = det (linear_map.to_matrix c c f) :=\nby rw [← linear_map_to_matrix_mul_basis_to_matrix c b c,\n       ← basis_to_matrix_mul_linear_map_to_matrix b c b,\n       matrix.det_conj]; rw [basis.to_matrix_mul_to_matrix, basis.to_matrix_self]\n\n/-- The determinant of an endomorphism given a basis.\n\nSee `linear_map.det` for a version that populates the basis non-computably.\n\nAlthough the `trunc (basis ι A M)` parameter makes it slightly more convenient to switch bases,\nthere is no good way to generalize over universe parameters, so we can't fully state in `det_aux`'s\ntype that it does not depend on the choice of basis. Instead you can use the `det_aux_def'` lemma,\nor avoid mentioning a basis at all using `linear_map.det`.\n-/\ndef det_aux : trunc (basis ι A M) → (M →ₗ[A] M) →* A :=\ntrunc.lift\n  (λ b : basis ι A M,\n    (det_monoid_hom).comp (to_matrix_alg_equiv b : (M →ₗ[A] M) →* matrix ι ι A))\n  (λ b c, monoid_hom.ext $ det_to_matrix_eq_det_to_matrix b c)\n\n/-- Unfold lemma for `det_aux`.\n\nSee also `det_aux_def'` which allows you to vary the basis.\n-/\nlemma det_aux_def (b : basis ι A M) (f : M →ₗ[A] M) :\n  linear_map.det_aux (trunc.mk b) f = matrix.det (linear_map.to_matrix b b f) :=\nrfl\n\n-- Discourage the elaborator from unfolding `det_aux` and producing a huge term.\nattribute [irreducible] linear_map.det_aux\n\nlemma det_aux_def' {ι' : Type*} [fintype ι'] [decidable_eq ι']\n  (tb : trunc $ basis ι A M) (b' : basis ι' A M) (f : M →ₗ[A] M) :\n  linear_map.det_aux tb f = matrix.det (linear_map.to_matrix b' b' f) :=\nby { apply trunc.induction_on tb, intro b, rw [det_aux_def, det_to_matrix_eq_det_to_matrix b b'] }\n\n@[simp]\nlemma det_aux_id (b : trunc $ basis ι A M) : linear_map.det_aux b (linear_map.id) = 1 :=\n(linear_map.det_aux b).map_one\n\n@[simp]\nlemma det_aux_comp (b : trunc $ basis ι A M) (f g : M →ₗ[A] M) :\n  linear_map.det_aux b (f.comp g) = linear_map.det_aux b f * linear_map.det_aux b g :=\n(linear_map.det_aux b).map_mul f g\n\nsection\nopen_locale classical\n\n-- Discourage the elaborator from unfolding `det` and producing a huge term by marking it\n-- as irreducible.\n/-- The determinant of an endomorphism independent of basis.\n\nIf there is no finite basis on `M`, the result is `1` instead.\n-/\n@[irreducible] protected def det : (M →ₗ[A] M) →* A :=\nif H : ∃ (s : finset M), nonempty (basis s A M)\nthen linear_map.det_aux (trunc.mk H.some_spec.some)\nelse 1\n\nlemma coe_det [decidable_eq M] : ⇑(linear_map.det : (M →ₗ[A] M) →* A) =\n  if H : ∃ (s : finset M), nonempty (basis s A M)\n  then linear_map.det_aux (trunc.mk H.some_spec.some)\n  else 1 :=\nby { ext, unfold linear_map.det,\n     split_ifs,\n     { congr }, -- use the correct `decidable_eq` instance\n     refl }\n\nend\n\n-- Auxiliary lemma, the `simp` normal form goes in the other direction\n-- (using `linear_map.det_to_matrix`)\nlemma det_eq_det_to_matrix_of_finset [decidable_eq M]\n  {s : finset M} (b : basis s A M) (f : M →ₗ[A] M) :\n  f.det = matrix.det (linear_map.to_matrix b b f) :=\nhave ∃ (s : finset M), nonempty (basis s A M),\nfrom ⟨s, ⟨b⟩⟩,\nby rw [linear_map.coe_det, dif_pos, det_aux_def' _ b]; assumption\n\n@[simp] lemma det_to_matrix\n  (b : basis ι A M) (f : M →ₗ[A] M) :\n  matrix.det (to_matrix b b f) = f.det :=\nby { haveI := classical.dec_eq M,\n     rw [det_eq_det_to_matrix_of_finset b.reindex_finset_range, det_to_matrix_eq_det_to_matrix b] }\n\n@[simp] lemma det_to_matrix' {ι : Type*} [fintype ι] [decidable_eq ι]\n  (f : (ι → A) →ₗ[A] (ι → A)) :\n  det f.to_matrix' = f.det :=\nby simp [← to_matrix_eq_to_matrix']\n\n/-- To show `P f.det` it suffices to consider `P (to_matrix _ _ f).det` and `P 1`. -/\n@[elab_as_eliminator]\nlemma det_cases [decidable_eq M] {P : A → Prop} (f : M →ₗ[A] M)\n  (hb : ∀ (s : finset M) (b : basis s A M), P (to_matrix b b f).det) (h1 : P 1) :\n  P f.det :=\nbegin\n  unfold linear_map.det,\n  split_ifs with h,\n  { convert hb _ h.some_spec.some,\n    apply det_aux_def' },\n  { exact h1 }\nend\n\n@[simp]\nlemma det_comp (f g : M →ₗ[A] M) : (f.comp g).det = f.det * g.det :=\nlinear_map.det.map_mul f g\n\n@[simp]\nlemma det_id : (linear_map.id : M →ₗ[A] M).det = 1 :=\nlinear_map.det.map_one\n\n/-- Multiplying a map by a scalar `c` multiplies its determinant by `c ^ dim M`. -/\n@[simp] lemma det_smul {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]\n  (c : 𝕜) (f : M →ₗ[𝕜] M) :\n  linear_map.det (c • f) = c ^ (finite_dimensional.finrank 𝕜 M) * linear_map.det f :=\nbegin\n  by_cases H : ∃ (s : finset M), nonempty (basis s 𝕜 M),\n  { haveI : finite_dimensional 𝕜 M,\n    { rcases H with ⟨s, ⟨hs⟩⟩, exact finite_dimensional.of_finset_basis hs },\n    simp only [← det_to_matrix (finite_dimensional.fin_basis 𝕜 M), linear_equiv.map_smul,\n              fintype.card_fin, det_smul] },\n  { classical,\n    have : finite_dimensional.finrank 𝕜 M = 0 := finrank_eq_zero_of_not_exists_basis H,\n    simp [coe_det, H, this] }\nend\n\nlemma det_zero' {ι : Type*} [fintype ι] [nonempty ι] (b : basis ι A M) :\n  linear_map.det (0 : M →ₗ[A] M) = 0 :=\nby { haveI := classical.dec_eq ι,\n     rw [← det_to_matrix b, linear_equiv.map_zero, det_zero],\n     assumption }\n\n/-- In a finite-dimensional vector space, the zero map has determinant `1` in dimension `0`,\nand `0` otherwise. -/\n@[simp] lemma det_zero {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M] :\n  linear_map.det (0 : M →ₗ[𝕜] M) = (0 : 𝕜) ^ (finite_dimensional.finrank 𝕜 M) :=\nby simp only [← zero_smul 𝕜 (1 : M →ₗ[𝕜] M), det_smul, mul_one, monoid_hom.map_one]\n\n/-- Conjugating a linear map by a linear equiv does not change its determinant. -/\n@[simp] lemma det_conj {N : Type*} [add_comm_group N] [module A N]\n  (f : M →ₗ[A] M) (e : M ≃ₗ[A] N) :\n  linear_map.det ((e : M →ₗ[A] N) ∘ₗ (f ∘ₗ (e.symm : N →ₗ[A] M))) = linear_map.det f :=\nbegin\n  classical,\n  by_cases H : ∃ (s : finset M), nonempty (basis s A M),\n  { rcases H with ⟨s, ⟨b⟩⟩,\n    rw [← det_to_matrix b f, ← det_to_matrix (b.map e), to_matrix_comp (b.map e) b (b.map e),\n        to_matrix_comp (b.map e) b b, ← matrix.mul_assoc, matrix.det_conj],\n    { rw [← to_matrix_comp, linear_equiv.comp_coe, e.symm_trans_self,\n          linear_equiv.refl_to_linear_map, to_matrix_id] },\n    { rw [← to_matrix_comp, linear_equiv.comp_coe, e.self_trans_symm,\n          linear_equiv.refl_to_linear_map, to_matrix_id] } },\n  { have H' : ¬ (∃ (t : finset N), nonempty (basis t A N)),\n    { contrapose! H,\n      rcases H with ⟨s, ⟨b⟩⟩,\n      exact ⟨_, ⟨(b.map e.symm).reindex_finset_range⟩⟩ },\n    simp only [coe_det, H, H', pi.one_apply, dif_neg, not_false_iff] }\nend\n\nend linear_map\n\n-- Cannot be stated using `linear_map.det` because `f` is not an endomorphism.\nlemma linear_equiv.is_unit_det (f : M ≃ₗ[R] M') (v : basis ι R M) (v' : basis ι R M') :\n  is_unit (linear_map.to_matrix v v' f).det :=\nbegin\n  apply is_unit_det_of_left_inverse,\n  simpa using (linear_map.to_matrix_comp v v' v f.symm f).symm\nend\n\n/-- Specialization of `linear_equiv.is_unit_det` -/\nlemma linear_equiv.is_unit_det' {A : Type*} [comm_ring A] [is_domain A] [module A M]\n  (f : M ≃ₗ[A] M) : is_unit (linear_map.det (f : M →ₗ[A] M)) :=\nby haveI := classical.dec_eq M; exact\n(f : M →ₗ[A] M).det_cases (λ s b, f.is_unit_det _ _) is_unit_one\n\n/-- Builds a linear equivalence from a linear map whose determinant in some bases is a unit. -/\n@[simps]\ndef linear_equiv.of_is_unit_det {f : M →ₗ[R] M'} {v : basis ι R M} {v' : basis ι R M'}\n  (h : is_unit (linear_map.to_matrix v v' f).det) : M ≃ₗ[R] M' :=\n{ to_fun := f,\n  map_add' := f.map_add,\n  map_smul' := f.map_smul,\n  inv_fun := to_lin v' v (to_matrix v v' f)⁻¹,\n  left_inv := λ x,\n    calc to_lin v' v (to_matrix v v' f)⁻¹ (f x)\n        = to_lin v v ((to_matrix v v' f)⁻¹ ⬝ to_matrix v v' f) x :\n      by { rw [to_lin_mul v v' v, to_lin_to_matrix, linear_map.comp_apply] }\n    ... = x : by simp [h],\n  right_inv := λ x,\n    calc f (to_lin v' v (to_matrix v v' f)⁻¹ x)\n        = to_lin v' v' (to_matrix v v' f ⬝ (to_matrix v v' f)⁻¹) x :\n      by { rw [to_lin_mul v' v v', linear_map.comp_apply, to_lin_to_matrix v v'] }\n    ... = x : by simp [h] }\n\n/-- Builds a linear equivalence from a linear map on a finite-dimensional vector space whose\ndeterminant is nonzero. -/\n@[reducible] def linear_map.equiv_of_det_ne_zero\n  {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]\n  [finite_dimensional 𝕜 M] (f : M →ₗ[𝕜] M) (hf : linear_map.det f ≠ 0) :\n  M ≃ₗ[𝕜] M :=\nhave is_unit (linear_map.to_matrix (finite_dimensional.fin_basis 𝕜 M)\n  (finite_dimensional.fin_basis 𝕜 M) f).det :=\n    by simp only [linear_map.det_to_matrix, is_unit_iff_ne_zero.2 hf],\nlinear_equiv.of_is_unit_det this\n\n/-- The determinant of a family of vectors with respect to some basis, as an alternating\nmultilinear map. -/\ndef basis.det : alternating_map R M R ι :=\n{ to_fun := λ v, det (e.to_matrix v),\n  map_add' := begin\n    intros v i x y,\n    simp only [e.to_matrix_update, linear_equiv.map_add],\n    apply det_update_column_add\n  end,\n  map_smul' := begin\n    intros u i c x,\n    simp only [e.to_matrix_update, algebra.id.smul_eq_mul, linear_equiv.map_smul],\n    apply det_update_column_smul\n  end,\n  map_eq_zero_of_eq' := begin\n    intros v i j h hij,\n    rw [←function.update_eq_self i v, h, ←det_transpose, e.to_matrix_update,\n        ←update_row_transpose, ←e.to_matrix_transpose_apply],\n    apply det_zero_of_row_eq hij,\n    rw [update_row_ne hij.symm, update_row_self],\n  end }\n\nlemma basis.det_apply (v : ι → M) : e.det v = det (e.to_matrix v) := rfl\n\nlemma basis.det_self : e.det e = 1 :=\nby simp [e.det_apply]\n\n/-- `basis.det` is not the zero map. -/\nlemma basis.det_ne_zero [nontrivial R] : e.det ≠ 0 :=\nλ h, by simpa [h] using e.det_self\n\nlemma is_basis_iff_det {v : ι → M} :\n  linear_independent R v ∧ span R (set.range v) = ⊤ ↔ is_unit (e.det v) :=\nbegin\n  split,\n  { rintro ⟨hli, hspan⟩,\n    set v' := basis.mk hli hspan with v'_eq,\n    rw e.det_apply,\n    convert linear_equiv.is_unit_det (linear_equiv.refl _ _) v' e using 2,\n    ext i j,\n    simp },\n  { intro h,\n    rw [basis.det_apply, basis.to_matrix_eq_to_matrix_constr] at h,\n    set v' := basis.map e (linear_equiv.of_is_unit_det h) with v'_def,\n    have : ⇑ v' = v,\n    { ext i, rw [v'_def, basis.map_apply, linear_equiv.of_is_unit_det_apply, e.constr_basis] },\n    rw ← this,\n    exact ⟨v'.linear_independent, v'.span_eq⟩ },\nend\n\nlemma basis.is_unit_det (e' : basis ι R M) : is_unit (e.det e') :=\n(is_basis_iff_det e).mp ⟨e'.linear_independent, e'.span_eq⟩\n\n/-- Any alternating map to `R` where `ι` has the cardinality of a basis equals the determinant\nmap with respect to that basis, multiplied by the value of that alternating map on that basis. -/\nlemma alternating_map.eq_smul_basis_det (f : alternating_map R M R ι) : f = f e • e.det :=\nbegin\n  refine basis.ext_alternating e (λ i h, _),\n  let σ : equiv.perm ι := equiv.of_bijective i (fintype.injective_iff_bijective.1 h),\n  change f (e ∘ σ) = (f e • e.det) (e ∘ σ),\n  simp [alternating_map.map_perm, basis.det_self]\nend\n\nvariables {A : Type*} [comm_ring A] [is_domain A] [module A M]\n\n@[simp] lemma basis.det_comp (e : basis ι A M) (f : M →ₗ[A] M) (v : ι → M) :\n  e.det (f ∘ v) = f.det * e.det v :=\nby { rw [basis.det_apply, basis.det_apply, ← f.det_to_matrix e, ← matrix.det_mul,\n         e.to_matrix_eq_to_matrix_constr (f ∘ v), e.to_matrix_eq_to_matrix_constr v,\n         ← to_matrix_comp, e.constr_comp] }\n\nlemma basis.det_reindex {ι' : Type*} [fintype ι'] [decidable_eq ι']\n  (b : basis ι R M) (v : ι' → M) (e : ι ≃ ι') :\n  (b.reindex e).det v = b.det (v ∘ e) :=\nby rw [basis.det_apply, basis.to_matrix_reindex', det_reindex_alg_equiv, basis.det_apply]\n\nlemma basis.det_reindex_symm {ι' : Type*} [fintype ι'] [decidable_eq ι']\n  (b : basis ι R M) (v : ι → M) (e : ι' ≃ ι) :\n  (b.reindex e.symm).det (v ∘ e) = b.det v :=\nby rw [basis.det_reindex, function.comp.assoc, e.self_comp_symm, function.comp.right_id]\n\n@[simp]\nlemma basis.det_map (b : basis ι R M) (f : M ≃ₗ[R] M') (v : ι → M') :\n  (b.map f).det v = b.det (f.symm ∘ v) :=\nby { rw [basis.det_apply, basis.to_matrix_map, basis.det_apply] }\n\n@[simp] lemma pi.basis_fun_det : (pi.basis_fun R ι).det = matrix.det_row_alternating :=\nbegin\n  ext M,\n  rw [basis.det_apply, basis.coe_pi_basis_fun.to_matrix_eq_transpose, det_transpose],\nend\n\n/-- If we fix a background basis `e`, then for any other basis `v`, we can characterise the\ncoordinates provided by `v` in terms of determinants relative to `e`. -/\nlemma basis.det_smul_mk_coord_eq_det_update {v : ι → M}\n  (hli : linear_independent R v) (hsp : span R (range v) = ⊤) (i : ι) :\n  (e.det v) • (basis.mk hli hsp).coord i = e.det.to_multilinear_map.to_linear_map v i :=\nbegin\n  apply (basis.mk hli hsp).ext,\n  intros k,\n  rcases eq_or_ne k i with rfl | hik;\n  simp only [algebra.id.smul_eq_mul, basis.coe_mk, linear_map.smul_apply, linear_map.coe_mk,\n    multilinear_map.to_linear_map_apply],\n  { rw [basis.mk_coord_apply_eq, mul_one, update_eq_self], congr, },\n  { rw [basis.mk_coord_apply_ne hik, mul_zero, eq_comm],\n    exact e.det.map_eq_zero_of_eq _ (by simp [hik, function.update_apply]) hik, },\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/linear_algebra/determinant.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.4630600043588331}}
{"text": "\nclass category (C : Type) :=\n( hom : C → C → Type )\n( id : (X : C) → hom X X )\n( comp : {X Y Z : C} → hom X Y → hom Y Z → hom X Z )\n( id_comp {X Y : C} (f : hom X Y) : comp (id X) f = f )\n( comp_id {X Y : C} (f : hom X Y) : comp f (id Y) = f )\n( assoc {W X Y Z : C} (f : hom W X) (g : hom X Y) (h : hom Y Z) :\n    comp (comp f g) h = comp f (comp g h) )\n\nnotation \" 𝟙 \" => category.id\ninfixr: 80 \" ≫ \" => category.comp\ninfixr: 10 \" ⟶ \" => category.hom\n\nvariable (C : Type) [category C]\n\ninductive prod_coprod : Type\n| of_cat' : C → prod_coprod\n| prod : prod_coprod → prod_coprod → prod_coprod\n| coprod : prod_coprod → prod_coprod → prod_coprod\n\nvariable {C}\n\nnamespace prod_coprod\n\n@[simp] def size : prod_coprod C → Nat\n| of_cat' _ => 1\n| prod X Y => size X + size Y + 1\n| coprod X Y => size X + size Y + 1\n\ninductive syn : (X Y : prod_coprod C) → Type\n| of_cat {X Y : C} : (X ⟶ Y) → syn (of_cat' X) (of_cat' Y)\n| prod_mk {X Y Z : prod_coprod C} : syn X Y → syn X Z → syn X (Y.prod Z)\n| fst {X Y : prod_coprod C} : syn (X.prod Y) X\n| snd {X Y : prod_coprod C} : syn (X.prod Y) Y\n| coprod_mk {X Y Z : prod_coprod C} : syn X Z → syn Y Z → syn (X.coprod Y) Z\n| inl {X Y : prod_coprod C} : syn X (X.coprod Y)\n| inr {X Y : prod_coprod C} : syn Y (X.coprod Y)\n| id (X : prod_coprod C) : syn X X\n| comp {X Y Z : prod_coprod C} : syn X Y → syn Y Z → syn X Z\n\nnamespace syn\n\ninductive rel : {X Y : prod_coprod C} → syn X Y → syn X Y → Prop\n| refl {X Y : prod_coprod C} (f : syn X Y) : rel f f\n| symm {X Y : prod_coprod C} {f g : syn X Y} : rel f g → rel g f\n| trans {X Y : prod_coprod C} {f g h : syn X Y} : rel f g → rel g h → rel f h\n| comp_congr {X Y Z : prod_coprod C} {f₁ f₂ : syn X Y} {g₁ g₂ : syn Y Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (f₁.comp g₁) (f₂.comp g₂)\n| prod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : syn X Y} {g₁ g₂ : syn X Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (f₁.prod_mk g₁) (f₂.prod_mk g₂)\n| coprod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : syn X Z} {g₁ g₂ : syn Y Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (f₁.coprod_mk g₁) (f₂.coprod_mk g₂)\n| id_comp {X Y : prod_coprod C} (f : syn X Y) : rel ((syn.id X).comp f) f\n| comp_id {X Y : prod_coprod C} (f : syn X Y) : rel (f.comp (syn.id Y)) f\n| assoc {W X Y Z : prod_coprod C} (f : syn W X) (g : syn X Y) (h : syn Y Z) :\n  rel ((f.comp g).comp h) (f.comp (g.comp h))\n| of_cat_id {X : C} : rel (syn.of_cat (𝟙 X)) (syn.id (of_cat' X))\n| of_cat_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  rel (syn.of_cat (f ≫ g)) (syn.comp (syn.of_cat f) (syn.of_cat g))\n| mk_fst_comp {X Y Z : prod_coprod C} (f : syn X Y) (g : syn X Z) :\n  rel (syn.comp (syn.prod_mk f g) syn.fst) f\n| mk_snd_comp {X Y Z : prod_coprod C} (f : syn X Y) (g : syn X Z) :\n  rel (syn.comp (syn.prod_mk f g) syn.snd) g\n| prod_eta {X Y Z : prod_coprod C} (f : syn X (Y.prod Z)) :\n  rel (syn.prod_mk (f.comp syn.fst) (f.comp syn.snd)) f\n| inl_comp_mk {X Y Z : prod_coprod C} (f : syn X Z) (g : syn Y Z) :\n  rel (syn.comp syn.inl (syn.coprod_mk f g)) f\n| inr_comp_mk {X Y Z : prod_coprod C} (f : syn X Z) (g : syn Y Z) :\n  rel (syn.comp syn.inr (syn.coprod_mk f g)) g\n| coprod_eta {X Y Z : prod_coprod C} (f : syn (X.coprod Y) Z) :\n  rel (syn.coprod_mk (syn.inl.comp f) (syn.inr.comp f)) f\n\ninfixl:50 \" ♥ \" => rel\n\ninstance : Trans (@rel C _ X Y) (@rel C _ X Y) (@rel C _ X Y) where\n  trans := rel.trans\n\ntheorem rel_prod {X Y Z : prod_coprod C} {f g : syn X (Y.prod Z)}\n  (h₁ : rel (f.comp syn.fst) (g.comp syn.fst))\n  (h₂ : rel (f.comp syn.snd) (g.comp syn.snd)) :\n  rel f g :=\nrel.trans (rel.symm (rel.prod_eta f)) (rel.trans (rel.prod_mk_congr h₁ h₂) (rel.prod_eta g))\n\ntheorem rel_coprod {X Y Z : prod_coprod C} {f g : syn (X.coprod Y) Z}\n  (h₁ : rel (syn.inl.comp f) (syn.inl.comp g))\n  (h₂ : rel (syn.inr.comp f) (syn.inr.comp g)) :\n  rel f g :=\nrel.trans (rel.symm (rel.coprod_eta f)) (rel.trans (rel.coprod_mk_congr h₁ h₂) (rel.coprod_eta g))\n\nend syn\n\ninductive norm_hom : (X Y : prod_coprod C) → Type\n| of_cat {X Y : C} (f : X ⟶ Y) : norm_hom (of_cat' X) (of_cat' Y)\n| coprod_mk {X Y Z : prod_coprod C} (f : norm_hom X Z) (g : norm_hom Y Z) :\n  norm_hom (X.coprod Y) Z\n| prod_mk {X Y Z : prod_coprod C} (f : norm_hom X Y) (g : norm_hom X Z) :\n  norm_hom X (prod Y Z)\n| comp_inl {X Y Z : prod_coprod C} (f : norm_hom X Y) :\n  norm_hom X (coprod Y Z)\n| comp_inr {X Y Z : prod_coprod C} (f : norm_hom X Z) :\n  norm_hom X (coprod Y Z)\n| fst_comp {X Y Z : prod_coprod C} (f : norm_hom X Z) :\n  norm_hom (prod X Y) Z\n| snd_comp {X Y Z : prod_coprod C} (f : norm_hom Y Z) :\n  norm_hom (prod X Y) Z\n\nnamespace norm_hom\n\ninductive rel : {X Y : prod_coprod C} → norm_hom X Y → norm_hom X Y → Prop\n| refl {X Y : prod_coprod C} (f : norm_hom X Y) : rel f f\n| symm {X Y : prod_coprod C} {f g : norm_hom X Y} : rel g f → rel f g\n| trans {X Y : prod_coprod C} {f g h : norm_hom X Y} : rel f g → rel g h → rel f h\n| coprod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Z} {g₁ g₂ : norm_hom Y Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (coprod_mk f₁ g₁) (coprod_mk f₂ g₂)\n| prod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Y} {g₁ g₂ : norm_hom X Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (prod_mk f₁ g₁) (prod_mk f₂ g₂)\n| comp_inl_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Y} :\n  rel f₁ f₂ → rel (comp_inl f₁ : norm_hom X (coprod Y Z)) (comp_inl f₂)\n| comp_inr_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Z} :\n  rel f₁ f₂ → rel (comp_inr f₁ : norm_hom X (coprod Y Z)) (comp_inr f₂)\n| fst_comp_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Z} :\n  rel f₁ f₂ → rel (fst_comp f₁ : norm_hom (prod X Y) Z) (fst_comp f₂)\n| snd_comp_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom Y Z} :\n  rel f₁ f₂ → rel (snd_comp f₁ : norm_hom (prod X Y) Z) (snd_comp f₂)\n| fst_comp_prod_mk {W X Y Z : prod_coprod C} (f : norm_hom X Y) (g : norm_hom X Z) :\n  rel (fst_comp (prod_mk f g) : norm_hom (prod X W) (prod Y Z)) (prod_mk f.fst_comp g.fst_comp)\n| snd_comp_prod_mk {W X Y Z : prod_coprod C} (f : norm_hom X Y) (g : norm_hom X Z) :\n  rel (snd_comp (prod_mk f g) : norm_hom (prod W X) (prod Y Z)) (prod_mk f.snd_comp g.snd_comp)\n| comp_inl_coprod_mk {W X Y Z : prod_coprod C} (f : norm_hom W Y) (g : norm_hom X Y) :\n  rel (comp_inl (coprod_mk f g) : norm_hom (coprod W X) (coprod Y Z))\n    (coprod_mk f.comp_inl g.comp_inl)\n| comp_inr_coprod_mk {W X Y Z : prod_coprod C} (f : norm_hom W Y) (g : norm_hom X Y) :\n  rel (comp_inr (coprod_mk f g) : norm_hom (coprod W X) (coprod Z Y))\n    (coprod_mk f.comp_inr g.comp_inr)\n| fst_comp_comp_inl {W X Y Z : prod_coprod C} (f : norm_hom W Y) :\n  rel (f.fst_comp.comp_inl : norm_hom (prod W X) (coprod Y Z)) f.comp_inl.fst_comp\n| snd_comp_comp_inl {W X Y Z : prod_coprod C} (f : norm_hom X Y) :\n  rel (f.snd_comp.comp_inl : norm_hom (prod W X) (coprod Y Z)) f.comp_inl.snd_comp\n| fst_comp_comp_inr {W X Y Z : prod_coprod C} (f : norm_hom W Z) :\n  rel (f.fst_comp.comp_inr : norm_hom (prod W X) (coprod Y Z)) f.comp_inr.fst_comp\n| snd_comp_comp_inr {W X Y Z : prod_coprod C} (f : norm_hom X Z) :\n  rel (f.snd_comp.comp_inr : norm_hom (prod W X) (coprod Y Z)) f.comp_inr.snd_comp\n\ndef to_inj : {X Y Z : prod_coprod C} → (f : norm_hom X (coprod Y Z)) →\n  Option ((norm_hom X Y) ⊕ (norm_hom X Z))\n| _, _, _, comp_inl f => some (Sum.inl f)\n| _, _, _, comp_inr f => some (Sum.inr f)\n| _, _, _, fst_comp f =>\n  match to_inj f with\n  | none => none\n  | some (Sum.inl f) => some (Sum.inl (fst_comp f))\n  | some (Sum.inr f) => some (Sum.inr (fst_comp f))\n| _, _, _, snd_comp f =>\n  match to_inj f with\n  | none => none\n  | some (Sum.inl f) => some (Sum.inl (snd_comp f))\n  | some (Sum.inr f) => some (Sum.inr (snd_comp f))\n| _, _, _, coprod_mk f g =>\n  match to_inj f, to_inj g with\n  | some (Sum.inl f), some (Sum.inl g) => some (Sum.inl (coprod_mk f g))\n  | some (Sum.inr f), some (Sum.inr g) => some (Sum.inr (coprod_mk f g))\n  | _, _ => none\n\ntheorem to_inj_eq_inl : {X Y Z : prod_coprod C} → {f : norm_hom X (coprod Y Z)} →\n  {g : norm_hom X Y} → to_inj f = some (Sum.inl g) → rel f g.comp_inl\n| _, _, _, comp_inl f, g, h => by\n  simp [to_inj] at h\n  simp [h]\n  exact rel.refl _\n  | _, _, _, comp_inr f, g, h => by\n  simp [to_inj] at h\n| _, _, _, snd_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inl i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inl i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.snd_comp_congr (to_inj_eq_inl hi))\n    (rel.snd_comp_comp_inl i).symm\n| _, _, _, fst_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inl i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inl i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.fst_comp_congr (to_inj_eq_inl hi))\n    (rel.fst_comp_comp_inl i).symm\n| _, _, _, coprod_mk f g, i, h =>\n  have hi : ∃ f' g', to_inj f = some (Sum.inl f') ∧ to_inj g = some (Sum.inl g') := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f, to_inj g with\n    | some (Sum.inl f'), some (Sum.inl g') => intro h; exact ⟨f', g', rfl, rfl⟩\n    | some (Sum.inr _), some (Sum.inr _) => simp\n    | none, _ => simp\n    | _, none => simp\n    | some (Sum.inl _), some (Sum.inr _) => simp\n    | some (Sum.inr _), some (Sum.inl _) => simp }\n  match hi with\n  | ⟨f', g', hf, hg⟩ => by\n  simp [hf, hg, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.coprod_mk_congr (to_inj_eq_inl hf) (to_inj_eq_inl hg))\n    (rel.comp_inl_coprod_mk _ _).symm\n\ntheorem to_inj_eq_inr : {X Y Z : prod_coprod C} → {f : norm_hom X (coprod Y Z)} →\n  {g : norm_hom X Z} → to_inj f = some (Sum.inr g) → rel f g.comp_inr\n| _, _, _, comp_inr f, g, h => by\n  simp [to_inj] at h\n  simp [h]\n  exact rel.refl _\n  | _, _, _, comp_inl f, g, h => by\n  simp [to_inj] at h\n| _, _, _, snd_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inr i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inr i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.snd_comp_congr (to_inj_eq_inr hi))\n    (rel.snd_comp_comp_inr i).symm\n| _, _, _, fst_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inr i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inr i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.fst_comp_congr (to_inj_eq_inr hi))\n    (rel.fst_comp_comp_inr i).symm\n| _, _, _, coprod_mk f g, i, h =>\n  have hi : ∃ f' g', to_inj f = some (Sum.inr f') ∧ to_inj g = some (Sum.inr g') := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f, to_inj g with\n    | some (Sum.inr f'), some (Sum.inr g') => intro _; exact ⟨f', g', rfl, rfl⟩\n    | some (Sum.inl _), some (Sum.inl _) => simp\n    | none, _ => simp\n    | _, none => simp\n    | some (Sum.inr _), some (Sum.inl _) => simp\n    | some (Sum.inl _), some (Sum.inr _) => simp }\n  match hi with\n  | ⟨f', g', hf, hg⟩ => by\n  simp [hf, hg, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.coprod_mk_congr (to_inj_eq_inr hf) (to_inj_eq_inr hg))\n    (rel.comp_inr_coprod_mk _ _).symm\n\ntheorem to_inj_eq_none {X Y Z : prod_coprod C} {f : norm_hom X (coprod Y Z)}\n  (hf : to_inj f = none) {g : norm_hom X Z} : ¬rel f g.comp_inr := by\nintro h\ncases h\nsimp at hf\n\n\nend norm_hom", "meta": {"author": "ChrisHughes24", "repo": "lean4stuff", "sha": "2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346", "save_path": "github-repos/lean/ChrisHughes24-lean4stuff", "path": "github-repos/lean/ChrisHughes24-lean4stuff/lean4stuff-2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346/Stuff/prod_coprod3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4630600019949434}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.finite_dimensional\nimport Mathlib.ring_theory.integral_closure\nimport Mathlib.data.polynomial.integral_normalization\nimport Mathlib.PostPort\n\nuniverses u v u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Algebraic elements and algebraic extensions\n\nAn element of an R-algebra is algebraic over R if it is the root of a nonzero polynomial.\nAn R-algebra is algebraic over R if and only if all its elements are algebraic over R.\nThe main result in this file proves transitivity of algebraicity:\na tower of algebraic field extensions is algebraic.\n-/\n\n/-- An element of an R-algebra is algebraic over R if it is the root of a nonzero polynomial. -/\ndef is_algebraic (R : Type u) {A : Type v} [comm_ring R] [ring A] [algebra R A] (x : A) :=\n  ∃ (p : polynomial R), p ≠ 0 ∧ coe_fn (polynomial.aeval x) p = 0\n\n/-- A subalgebra is algebraic if all its elements are algebraic. -/\ndef subalgebra.is_algebraic {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A]\n    (S : subalgebra R A) :=\n  ∀ (x : A), x ∈ S → is_algebraic R x\n\n/-- An algebra is algebraic if all its elements are algebraic. -/\ndef algebra.is_algebraic (R : Type u) (A : Type v) [comm_ring R] [ring A] [algebra R A] :=\n  ∀ (x : A), is_algebraic R x\n\n/-- A subalgebra is algebraic if and only if it is algebraic an algebra. -/\ntheorem subalgebra.is_algebraic_iff {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A]\n    (S : subalgebra R A) : subalgebra.is_algebraic S ↔ algebra.is_algebraic R ↥S :=\n  sorry\n\n/-- An algebra is algebraic if and only if it is algebraic as a subalgebra. -/\ntheorem algebra.is_algebraic_iff {R : Type u} {A : Type v} [comm_ring R] [ring A] [algebra R A] :\n    algebra.is_algebraic R A ↔ subalgebra.is_algebraic ⊤ :=\n  sorry\n\n/-- An integral element of an algebra is algebraic.-/\ntheorem is_integral.is_algebraic (R : Type u) {A : Type v} [comm_ring R] [nontrivial R] [ring A]\n    [algebra R A] {x : A} (h : is_integral R x) : is_algebraic R x :=\n  sorry\n\n/-- An element of an algebra over a field is algebraic if and only if it is integral.-/\ntheorem is_algebraic_iff_is_integral (K : Type u) {A : Type v} [field K] [ring A] [algebra K A]\n    {x : A} : is_algebraic K x ↔ is_integral K x :=\n  sorry\n\ntheorem is_algebraic_iff_is_integral' (K : Type u) {A : Type v} [field K] [ring A] [algebra K A] :\n    algebra.is_algebraic K A ↔ algebra.is_integral K A :=\n  { mp :=\n      fun (h : algebra.is_algebraic K A) (x : A) => iff.mp (is_algebraic_iff_is_integral K) (h x),\n    mpr :=\n      fun (h : algebra.is_integral K A) (x : A) => iff.mpr (is_algebraic_iff_is_integral K) (h x) }\n\nnamespace algebra\n\n\n/-- If L is an algebraic field extension of K and A is an algebraic algebra over L,\nthen A is algebraic over K. -/\ntheorem is_algebraic_trans {K : Type u_1} {L : Type u_2} {A : Type u_3} [field K] [field L]\n    [comm_ring A] [algebra K L] [algebra L A] [algebra K A] [is_scalar_tower K L A]\n    (L_alg : is_algebraic K L) (A_alg : is_algebraic L A) : is_algebraic K A :=\n  sorry\n\n/-- A field extension is algebraic if it is finite. -/\ntheorem is_algebraic_of_finite {K : Type u_1} {L : Type u_2} [field K] [field L] [algebra K L]\n    [finite : finite_dimensional K L] : is_algebraic K L :=\n  fun (x : L) =>\n    iff.mpr (is_algebraic_iff_is_integral K)\n      (is_integral_of_submodule_noetherian ⊤\n        (is_noetherian_of_submodule_of_noetherian K L (↑⊤) finite) x mem_top)\n\nend algebra\n\n\ntheorem exists_integral_multiple {R : Type u_1} {S : Type u_2} [integral_domain R] [comm_ring S]\n    [algebra R S] {z : S} (hz : is_algebraic R z)\n    (inj : ∀ (x : R), coe_fn (algebra_map R S) x = 0 → x = 0) :\n    ∃ (x : ↥(integral_closure R S)), ∃ (y : ↥(integral_closure R S)), ∃ (H : y ≠ 0), z * ↑y = ↑x :=\n  sorry\n\ntheorem inv_eq_of_aeval_div_X_ne_zero {K : Type u_3} {L : Type u_4} [field K] [field L]\n    [algebra K L] {x : L} {p : polynomial K}\n    (aeval_ne : coe_fn (polynomial.aeval x) (polynomial.div_X p) ≠ 0) :\n    x⁻¹ =\n        coe_fn (polynomial.aeval x) (polynomial.div_X p) /\n          (coe_fn (polynomial.aeval x) p - coe_fn (algebra_map K L) (polynomial.coeff p 0)) :=\n  sorry\n\ntheorem inv_eq_of_root_of_coeff_zero_ne_zero {K : Type u_3} {L : Type u_4} [field K] [field L]\n    [algebra K L] {x : L} {p : polynomial K} (aeval_eq : coe_fn (polynomial.aeval x) p = 0)\n    (coeff_zero_ne : polynomial.coeff p 0 ≠ 0) :\n    x⁻¹ =\n        -(coe_fn (polynomial.aeval x) (polynomial.div_X p) /\n            coe_fn (algebra_map K L) (polynomial.coeff p 0)) :=\n  sorry\n\ntheorem subalgebra.inv_mem_of_root_of_coeff_zero_ne_zero {K : Type u_3} {L : Type u_4} [field K]\n    [field L] [algebra K L] (A : subalgebra K L) {x : ↥A} {p : polynomial K}\n    (aeval_eq : coe_fn (polynomial.aeval x) p = 0) (coeff_zero_ne : polynomial.coeff p 0 ≠ 0) :\n    ↑x⁻¹ ∈ A :=\n  sorry\n\ntheorem subalgebra.inv_mem_of_algebraic {K : Type u_3} {L : Type u_4} [field K] [field L]\n    [algebra K L] (A : subalgebra K L) {x : ↥A} (hx : is_algebraic K ↑x) : ↑x⁻¹ ∈ A :=\n  sorry\n\n/-- In an algebraic extension L/K, an intermediate subalgebra is a field. -/\ntheorem subalgebra.is_field_of_algebraic {K : Type u_3} {L : Type u_4} [field K] [field L]\n    [algebra K L] (A : subalgebra K L) (hKL : algebra.is_algebraic K L) : is_field ↥A :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/algebraic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.4630599969359084}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.binary_products\nimport Mathlib.category_theory.limits.preserves.basic\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v \n\nnamespace Mathlib\n\n/-!\n# Preserving binary products\n\nConstructions to relate the notions of preserving binary products and reflecting binary products\nto concrete binary fans.\n\nIn particular, we show that `prod_comparison G X Y` is an isomorphism iff `G` preserves\nthe product of `X` and `Y`.\n-/\n\nnamespace category_theory.limits\n\n\n/--\nThe map of a binary fan is a limit iff the fork consisting of the mapped morphisms is a limit. This\nessentially lets us commute `binary_fan.mk` with `functor.map_cone`.\n-/\ndef is_limit_map_cone_binary_fan_equiv {C : Type u₁} [category C] {D : Type u₂} [category D]\n    (G : C ⥤ D) {P : C} {X : C} {Y : C} (f : P ⟶ X) (g : P ⟶ Y) :\n    is_limit (functor.map_cone G (binary_fan.mk f g)) ≃\n        is_limit (binary_fan.mk (functor.map G f) (functor.map G g)) :=\n  equiv.trans\n    (equiv.symm\n      (is_limit.postcompose_hom_equiv (diagram_iso_pair (pair X Y ⋙ G))\n        (functor.map_cone G (binary_fan.mk f g))))\n    (is_limit.equiv_iso_limit\n      (cones.ext\n        (iso.refl\n          (cone.X\n            (functor.obj (cones.postcompose (iso.hom (diagram_iso_pair (pair X Y ⋙ G))))\n              (functor.map_cone G (binary_fan.mk f g)))))\n        sorry))\n\n/-- The property of preserving products expressed in terms of binary fans. -/\ndef map_is_limit_of_preserves_of_is_limit {C : Type u₁} [category C] {D : Type u₂} [category D]\n    (G : C ⥤ D) {P : C} {X : C} {Y : C} (f : P ⟶ X) (g : P ⟶ Y) [preserves_limit (pair X Y) G]\n    (l : is_limit (binary_fan.mk f g)) :\n    is_limit (binary_fan.mk (functor.map G f) (functor.map G g)) :=\n  coe_fn (is_limit_map_cone_binary_fan_equiv G f g) (preserves_limit.preserves l)\n\n/-- The property of reflecting products expressed in terms of binary fans. -/\ndef is_limit_of_reflects_of_map_is_limit {C : Type u₁} [category C] {D : Type u₂} [category D]\n    (G : C ⥤ D) {P : C} {X : C} {Y : C} (f : P ⟶ X) (g : P ⟶ Y) [reflects_limit (pair X Y) G]\n    (l : is_limit (binary_fan.mk (functor.map G f) (functor.map G g))) :\n    is_limit (binary_fan.mk f g) :=\n  reflects_limit.reflects (coe_fn (equiv.symm (is_limit_map_cone_binary_fan_equiv G f g)) l)\n\n/--\nIf `G` preserves binary products and `C` has them, then the binary fan constructed of the mapped\nmorphisms of the binary product cone is a limit.\n-/\ndef is_limit_of_has_binary_product_of_preserves_limit {C : Type u₁} [category C] {D : Type u₂}\n    [category D] (G : C ⥤ D) (X : C) (Y : C) [has_binary_product X Y]\n    [preserves_limit (pair X Y) G] :\n    is_limit (binary_fan.mk (functor.map G prod.fst) (functor.map G prod.snd)) :=\n  map_is_limit_of_preserves_of_is_limit G prod.fst prod.snd (prod_is_prod X Y)\n\n/--\nIf the product comparison map for `G` at `(X,Y)` is an isomorphism, then `G` preserves the\npair of `(X,Y)`.\n-/\ndef preserves_pair.of_iso_comparison {C : Type u₁} [category C] {D : Type u₂} [category D]\n    (G : C ⥤ D) (X : C) (Y : C) [has_binary_product X Y]\n    [has_binary_product (functor.obj G X) (functor.obj G Y)] [i : is_iso (prod_comparison G X Y)] :\n    preserves_limit (pair X Y) G :=\n  preserves_limit_of_preserves_limit_cone (prod_is_prod X Y)\n    (coe_fn (equiv.symm (is_limit_map_cone_binary_fan_equiv G prod.fst prod.snd))\n      (is_limit.of_point_iso (limit.is_limit (pair (functor.obj G X) (functor.obj G Y)))))\n\n/--\nIf `G` preserves the product of `(X,Y)`, then the product comparison map for `G` at `(X,Y)` is\nan isomorphism.\n-/\ndef preserves_pair.iso {C : Type u₁} [category C] {D : Type u₂} [category D] (G : C ⥤ D) (X : C)\n    (Y : C) [has_binary_product X Y] [has_binary_product (functor.obj G X) (functor.obj G Y)]\n    [preserves_limit (pair X Y) G] : functor.obj G (X ⨯ Y) ≅ functor.obj G X ⨯ functor.obj G Y :=\n  is_limit.cone_point_unique_up_to_iso (is_limit_of_has_binary_product_of_preserves_limit G X Y)\n    (limit.is_limit (pair (functor.obj G X) (functor.obj G Y)))\n\n@[simp] theorem preserves_pair.iso_hom {C : Type u₁} [category C] {D : Type u₂} [category D]\n    (G : C ⥤ D) (X : C) (Y : C) [has_binary_product X Y]\n    [has_binary_product (functor.obj G X) (functor.obj G Y)] [preserves_limit (pair X Y) G] :\n    iso.hom (preserves_pair.iso G X Y) = prod_comparison G X Y :=\n  rfl\n\nprotected instance prod_comparison.category_theory.is_iso {C : Type u₁} [category C] {D : Type u₂}\n    [category D] (G : C ⥤ D) (X : C) (Y : C) [has_binary_product X Y]\n    [has_binary_product (functor.obj G X) (functor.obj G Y)] [preserves_limit (pair X Y) G] :\n    is_iso (prod_comparison G X Y) :=\n  eq.mpr sorry (is_iso.of_iso (preserves_pair.iso G X Y))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/preserves/shapes/binary_products_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.63341024983754, "lm_q1q2_score": 0.46305999693590827}}
{"text": "/-\nCopyright (c) 2016 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n\nAuthors: Floris van Doorn\n\nGraphs and operations on graphs\n\nCurrently we only define the notion of a path in a graph, and prove properties and operations on\npaths.\n-/\nimport ..arity ..eq2 .relation ..cubical.pathover2\nuniverses u v w\n\nnamespace hott\nhott_theory\n\n/-\n  A path is a list of vertexes which are adjacent. We maybe use a weird ordering of cons, because\n  the major example where we use this is a category where this ordering makes more sense.\n  For the operations on paths we use the names from the corresponding operations on lists. Opening\n  both the list and the paths namespace will lead to many name clashes, so that is not advised.\n-/\n\ninductive paths {A : Type u} (R : A → A → Type v) : A → A → Type (max u v)\n| nil {} : Π{a : A}, paths a a\n| cons   : Π{a₁ a₂ a₃ : A} (r : R a₂ a₃), paths a₁ a₂ → paths a₁ a₃\n\nnamespace graph\n  export paths\n\n  local notation h :: t  := cons h t\n  local notation `[` l:(foldr `, ` (h t, cons h t) nil `]`) := l\n\n  variables {A : Type _} {R : A → A → Type _} {a a' a₁ a₂ a₃ a₄ : A}\n\n  @[hott] def concat (r : R a₁ a₂) (l : paths R a₂ a₃) : paths R a₁ a₃ :=\n  begin\n    hinduction l with a a₂ a₃ a₄ r' l IH,\n    { exact [r]},\n    { exact r' :: IH r}\n  end\n\n  @[hott] theorem concat_nil (r : R a₁ a₂) : concat r (@nil A R a₂) = [r] := idp\n\n  @[hott] theorem concat_cons (r : R a₁ a₂) (r' : R a₃ a₄) (l : paths R a₂ a₃)\n    : concat r (r'::l)  = r'::(concat r l) := idp\n\n  @[hott] def append (l₂ : paths R a₂ a₃) (l₁ : paths R a₁ a₂) :\n    paths R a₁ a₃ :=\n  begin\n    hinduction l₂ with a₂ a₂ a₃ a₄ r l₂ IH,\n    { exact l₁ },\n    { exact cons r (IH l₁) }\n  end\n\n  local infix ` ++ ` := append\n\n  @[hott] def nil_append (l : paths R a₁ a₂) : nil ++ l = l := idp\n  @[hott] def cons_append (r : R a₃ a₄) (l₂ : paths R a₂ a₃) (l₁ : paths R a₁ a₂) :\n    (r :: l₂) ++ l₁ = r :: (l₂ ++ l₁) := idp\n\n  @[hott] def singleton_append (r : R a₂ a₃) (l : paths R a₁ a₂) : [r] ++ l = r :: l := idp\n  @[hott] def append_singleton (l : paths R a₂ a₃) (r : R a₁ a₂) : l ++ [r] = concat r l :=\n  begin\n    hinduction l with a₁ a₁ a₂ a₃ r l IH,\n    { refl },\n    { exact ap (cons r) (IH _) }\n  end\n\n  @[hott] def append_nil (l : paths R a₁ a₂) : l ++ nil = l :=\n  begin\n    hinduction l with a₁ a₁ a₂ a₃ r l IH,\n    { refl },\n    { exact ap (cons r) IH }\n  end\n\n  @[hott] def append_assoc (l₃ : paths R a₃ a₄) (l₂ : paths R a₂ a₃)\n    (l₁ : paths R a₁ a₂) : (l₃ ++ l₂) ++ l₁ = l₃ ++ (l₂ ++ l₁) :=\n  begin\n    hinduction l₃ with a₃ a₃ a₄ a₅ r l₃ IH,\n    { refl },\n    { refine ap (cons r) (IH _) }\n  end\n\n  @[hott] theorem append_concat (l₂ : paths R a₃ a₄) (l₁ : paths R a₂ a₃) (r : R a₁ a₂) :\n    l₂ ++ concat r l₁ = concat r (l₂ ++ l₁) :=\n  begin\n    hinduction l₂ with a₂ a₂ a₃ a₄ r' l₂ IH,\n    { refl },\n    { exact ap (cons r') (IH _) }\n  end\n\n  @[hott] def concat_append (l₂ : paths R a₃ a₄) (r : R a₂ a₃) (l₁ : paths R a₁ a₂) :\n    concat r l₂ ++ l₁ = l₂ ++ r :: l₁ :=\n  begin\n    hinduction l₂ with a₂ a₂ a₃ a₄ r' l₂ IH,\n    { refl },\n    { exact ap (cons r') (IH _) }\n  end\n\n  @[hott] def paths.rec_tail {C : Π⦃a a' : A⦄, paths R a a' → Type _}\n  (H0 : Π {a : A}, @C a a nil)\n  (H1 : Π {a₁ a₂ a₃ : A} (r : R a₁ a₂) (l : paths R a₂ a₃), C l → C (concat r l)) :\n  Π{a a' : A} (l : paths R a a'), C l :=\n  begin\n    have : Π{a₁ a₂ a₃ : A} (l₂ : paths R a₂ a₃) (l₁ : paths R a₁ a₂) (c : C l₂),\n      C (l₂ ++ l₁),\n    begin\n      intros, revert a₃ l₂ c, hinduction l₁ with a₁ a₁ a₂ a₄ r l₁ IH; intros a₃ l₂ c,\n      { rwr append_nil, exact c },\n      { rwr [←concat_append], apply IH, apply H1, exact c }\n    end,\n    intros, rwr [←nil_append l], apply this, apply H0\n  end\n\n  @[hott] def cons_eq_concat (r : R a₂ a₃) (l : paths R a₁ a₂) :\n    Σa (r' : R a₁ a) (l' : paths R a a₃), r :: l = concat r' l' :=\n  begin\n    revert a₃ r, hinduction l with a₁ a₁ a₂ a₃ r l IH; intros a₃' r',\n    { exact ⟨a₃', r', nil, idp⟩ },\n    { cases (IH r) with a₄ w, cases w with r₂ w, cases w with l p, clear IH,\n      exact ⟨a₄, r₂, r' :: l, ap (cons r') p⟩ }\n  end\n\n  @[hott] def length (l : paths R a₁ a₂) : ℕ :=\n  begin\n    hinduction l with a₁ a₁ a₂ a₃ r l IH,\n    { exact 0 },\n    { exact IH.succ }\n  end\n\n  /- If we can reverse edges in the graph we can reverse paths -/\n\n  @[hott] def reverse (rev : Π⦃a a'⦄, R a a' → R a' a) (l : paths R a₁ a₂) :\n    paths R a₂ a₁ :=\n  begin\n    hinduction l with a₁ a₁ a₂ a₃ r l IH,\n    { exact nil},\n    { exact concat (rev r) IH}\n  end\n\n  @[hott] theorem reverse_nil (rev : Π⦃a a'⦄, R a a' → R a' a) : reverse rev (@nil A R a₁) = [] := idp\n\n  @[hott] theorem reverse_cons (rev : Π⦃a a'⦄, R a a' → R a' a) (r : R a₂ a₃) (l : paths R a₁ a₂) :\n    reverse rev (r::l) = concat (rev r) (reverse rev l) := idp\n\n  @[hott] theorem reverse_singleton (rev : Π⦃a a'⦄, R a a' → R a' a) (r : R a₁ a₂) :\n    reverse rev [r] = [rev r] := idp\n\n  @[hott] theorem reverse_pair (rev : Π⦃a a'⦄, R a a' → R a' a) (r₂ : R a₂ a₃) (r₁ : R a₁ a₂) :\n    reverse rev [r₂, r₁] = [rev r₁, rev r₂] := idp\n\n  @[hott] theorem reverse_concat (rev : Π⦃a a'⦄, R a a' → R a' a) (r : R a₁ a₂) (l : paths R a₂ a₃) :\n    reverse rev (concat r l) = rev r :: (reverse rev l) :=\n  begin\n    hinduction l with a₁ a₁ a₂ a₃ r l IH,\n    { refl },\n    { rwr [concat_cons, reverse_cons, IH]}\n  end\n\n  @[hott] theorem reverse_append (rev : Π⦃a a'⦄, R a a' → R a' a) (l₂ : paths R a₂ a₃)\n    (l₁ : paths R a₁ a₂) : reverse rev (l₂ ++ l₁) = reverse rev l₁ ++ reverse rev l₂ :=\n  begin\n    hinduction l₂ with a₂ a₂ a₃ a₄ r l₂ IH,\n    { exact (append_nil _)⁻¹ },\n    { rwr [cons_append, reverse_cons, reverse_cons, append_concat, IH] }\n  end\n\n  @[hott] def realize (P : A → A → Type _) (f : Π⦃a a'⦄, R a a' → P a a') (ρ : Πa, P a a)\n    (c : Π⦃a₁ a₂ a₃⦄, P a₁ a₂ → P a₂ a₃ → P a₁ a₃)\n    ⦃a a' : A⦄ (l : paths R a a') : P a a' :=\n  begin\n    hinduction l with a a₁ a₂ a₃ r l IH,\n    { exact ρ a },\n    { exact c IH (f r) }\n  end\n\n  @[hott, hsimp] def realize_nil (P : A → A → Type _) (f : Π⦃a a'⦄, R a a' → P a a') \n    (ρ : Πa, P a a) (c : Π⦃a₁ a₂ a₃⦄, P a₁ a₂ → P a₂ a₃ → P a₁ a₃) (a : A) :\n    realize P f ρ c nil = ρ a :=\n  by refl\n\n  @[hott, hsimp] def realize_cons (P : A → A → Type _) (f : Π⦃a a'⦄, R a a' → P a a') (ρ : Πa, P a a)\n    (c : Π⦃a₁ a₂ a₃⦄, P a₁ a₂ → P a₂ a₃ → P a₁ a₃)\n    ⦃a₁ a₂ a₃ : A⦄ (r : R a₂ a₃) (l : paths R a₁ a₂) :\n    realize P f ρ c (r :: l) = c (realize P f ρ c l) (f r) :=\n  by refl\n\n  @[hott] theorem realize_singleton {P : A → A → Type _} {f : Π⦃a a'⦄, R a a' → P a a'} {ρ : Πa, P a a}\n    {c : Π⦃a₁ a₂ a₃⦄, P a₁ a₂ → P a₂ a₃ → P a₁ a₃}\n    (id_left : Π⦃a₁ a₂⦄ (p : P a₁ a₂), c (ρ a₁) p = p)\n    ⦃a₁ a₂ : A⦄ (r : R a₁ a₂) :\n    realize P f ρ c [r] = f r :=\n  id_left (f r)\n\n  @[hott] theorem realize_pair {P : A → A → Type _} {f : Π⦃a a'⦄, R a a' → P a a'} {ρ : Πa, P a a}\n    {c : Π⦃a₁ a₂ a₃⦄, P a₁ a₂ → P a₂ a₃ → P a₁ a₃}\n    (id_left : Π⦃a₁ a₂⦄ (p : P a₁ a₂), c (ρ a₁) p = p)\n    ⦃a₁ a₂ a₃ : A⦄ (r₂ : R a₂ a₃) (r₁ : R a₁ a₂) :\n    realize P f ρ c [r₂, r₁] = c (f r₁) (f r₂) :=\n  ap (λx, c x (f r₂)) (realize_singleton id_left r₁)\n\n  @[hott] def realize_append {P : A → A → Type _} {f : Π⦃a a'⦄, R a a' → P a a'} {ρ : Πa, P a a}\n    {c : Π⦃a₁ a₂ a₃⦄, P a₁ a₂ → P a₂ a₃ → P a₁ a₃}\n    (assoc : Π⦃a₁ a₂ a₃ a₄⦄ (p : P a₁ a₂) (q : P a₂ a₃) (r : P a₃ a₄), c (c p q) r = c p (c q r))\n    (id_right : Π⦃a₁ a₂⦄ (p : P a₁ a₂), c p (ρ a₂) = p)\n    ⦃a₁ a₂ a₃ : A⦄ (l₂ : paths R a₂ a₃) (l₁ : paths R a₁ a₂) :\n    realize P f ρ c (l₂ ++ l₁) = c (realize P f ρ c l₁) (realize P f ρ c l₂) :=\n  begin\n    hinduction l₂ with a₂ a₂ a₃ a₄ r l₂ IH,\n    { exact (id_right _)⁻¹ },\n    { rwr [cons_append, realize_cons, realize_cons, IH, assoc] }\n  end\n\n  /-\n    We sometimes want to take quotients of paths (this library was developed to define the pushout of\n    categories). The definition paths_rel will - given some basic reduction rules codified by Q -\n    extend the reduction to a reflexive transitive relation respecting concatenation of paths.\n  -/\n\n  inductive paths_rel {A : Type u} {R : A → A → Type v}\n    (Q : Π⦃a a' : A⦄, paths R a a' → paths R a a' → Type w)\n    : Π⦃a a' : A⦄, paths R a a' → paths R a a' → Type (max u v w)\n  | rrefl  : Π{a a' : A} (l : paths R a a'), paths_rel l l\n  | rel    : Π{a₁ a₂ a₃ : A} {l₂ l₃ : paths R a₂ a₃} (l : paths R a₁ a₂) (q : Q l₂ l₃),\n      paths_rel (l₂ ++ l) (l₃ ++ l)\n  | rcons  : Π{a₁ a₂ a₃ : A} {l₁ l₂ : paths R a₁ a₂} (r : R a₂ a₃),\n      paths_rel l₁ l₂ → paths_rel (cons r l₁) (cons r l₂)\n  | rtrans : Π{a₁ a₂ : A} {l₁ l₂ l₃ : paths R a₁ a₂},\n      paths_rel l₁ l₂ → paths_rel l₂ l₃ → paths_rel l₁ l₃\n\n  open paths_rel\n  attribute [refl] rrefl\n  attribute [trans] rtrans\n  variables {Q : Π⦃a a' : A⦄, paths R a a' → paths R a a' → Type _}\n\n  @[hott] def paths_rel_of_Q {l₁ l₂ : paths R a₁ a₂} (q : Q l₁ l₂) :\n    paths_rel Q l₁ l₂ :=\n  begin\n    rwr [←append_nil l₁, ←append_nil l₂], exact rel nil q,\n  end\n\n  @[hott] theorem rel_respect_append_left (l : paths R a₂ a₃) {l₃ l₄ : paths R a₁ a₂}\n    (H : paths_rel Q l₃ l₄) : paths_rel Q (l ++ l₃) (l ++ l₄) :=\n  begin\n    hinduction l with a₁ a₁ a₂ a₃ r l IH,\n    { exact H },\n    { exact rcons r (IH H) }\n  end\n\n  @[hott] theorem rel_respect_append_right {l₁ l₂ : paths R a₂ a₃} (l : paths R a₁ a₂)\n    (H₁ : paths_rel Q l₁ l₂) : paths_rel Q (l₁ ++ l) (l₂ ++ l) :=\n  begin\n    hinduction H₁ with a₁ a₂ l₁\n                      a₂ a₃ a₄ l₂ l₂' l₁ q\n                      a₂ a₃ a₄ l₁ l₂ r H₁ IH\n                      a₂ a₃ l₁ l₂ l₂' H₁ H₁' IH IH',\n    { refl },\n    { rwr [append_assoc, append_assoc], exact rel _ q},\n    { exact rcons r (IH l) },\n    { exact rtrans (IH l) (IH' l)}\n  end\n\n  @[hott] theorem rel_respect_append {l₁ l₂ : paths R a₂ a₃} {l₃ l₄ : paths R a₁ a₂}\n    (H₁ : paths_rel Q l₁ l₂) (H₂ : paths_rel Q l₃ l₄) :\n    paths_rel Q (l₁ ++ l₃) (l₂ ++ l₄) :=\n  begin\n    hinduction H₁ with a₁ a₂ l\n                       a₂ a₃ a₄ l₂ l₂' l q\n                       a₂ a₃ a₄ l₁ l₂ r H₁ IH\n                       a₂ a₃ l₁ l₂ l₂' H₁ H₁' IH IH',\n    { exact rel_respect_append_left _ H₂},\n    { rwr [append_assoc, append_assoc], transitivity _, exact rel _ q,\n      apply rel_respect_append_left, apply rel_respect_append_left, exact H₂},\n    { exact rcons r (IH H₂) },\n    { refine rtrans (IH H₂) _, apply rel_respect_append_right, exact H₁'}\n  end\n\n  /- assuming some extra properties the relation respects reversing -/\n\n  @[hott] theorem rel_respect_reverse (rev : Π⦃a a'⦄, R a a' → R a' a) {l₁ l₂ : paths R a₁ a₂}\n    (H : paths_rel Q l₁ l₂)\n    (rev_rel : Π⦃a a' : A⦄ {l l' : paths R a a'},\n      Q l l' → paths_rel Q (reverse rev l) (reverse rev l')) :\n    paths_rel Q (reverse rev l₁) (reverse rev l₂) :=\n  begin\n    hinduction H with a₁ a₂ l\n                      a₂ a₃ a₄ l₂ l₂' l q\n                      a₂ a₃ a₄ l₁ l₂ r H₁ IH\n                      a₂ a₃ l₁ l₂ l₂' H₁ H₁' IH IH',\n    { refl },\n    { rwr [reverse_append, reverse_append], apply rel_respect_append_left, apply rev_rel q },\n    { rwr [reverse_cons, reverse_cons,←append_singleton, ←append_singleton], \n      apply rel_respect_append_right, exact IH },\n    { exact rtrans IH IH' }\n  end\n\n  @[hott] theorem rel_left_inv (rev : Π⦃a a'⦄, R a a' → R a' a) (l : paths R a₁ a₂)\n    (li : Π⦃a a' : A⦄ (r : R a a'), paths_rel Q [rev r, r] nil) :\n    paths_rel Q (reverse rev l ++ l) nil :=\n  begin\n    hinduction l with a₁ a₁ a₂ a₃ r l IH,\n    { refl },\n    { rwr [reverse_cons, concat_append],\n      refine rtrans _ IH, apply rel_respect_append_left,\n      exact rel_respect_append_right _ (li r)}\n  end\n\n  @[hott] theorem rel_right_inv (rev : Π⦃a a'⦄, R a a' → R a' a) (l : paths R a₁ a₂)\n    (ri : Π⦃a a' : A⦄ (r : R a a'), paths_rel Q [r, rev r] nil) :\n    paths_rel Q (l ++ reverse rev l) nil :=\n  begin\n    hinduction l using paths.rec_tail,\n    { refl },\n    { rwr [reverse_concat, concat_append],\n      refine rtrans _ a, apply rel_respect_append_left,\n      exact rel_respect_append_right _ (ri r)}\n  end\n\n  @[hott] def realize_eq {P : A → A → Type _} {f : Π⦃a a'⦄, R a a' → P a a'} {ρ : Πa, P a a}\n    {c : Π⦃a₁ a₂ a₃⦄, P a₁ a₂ → P a₂ a₃ → P a₁ a₃}\n    (assoc : Π⦃a₁ a₂ a₃ a₄⦄ (p : P a₁ a₂) (q : P a₂ a₃) (r : P a₃ a₄), c (c p q) r = c p (c q r))\n    (id_right : Π⦃a₁ a₂⦄ (p : P a₁ a₂), c p (ρ a₂) = p)\n    (resp_rel : Π⦃a₁ a₂⦄ {l₁ l₂ : paths R a₁ a₂}, Q l₁ l₂ →\n      realize P f ρ c l₁ = realize P f ρ c l₂)\n    ⦃a a' : A⦄ {l l' : paths R a a'} (H : paths_rel Q l l') :\n    realize P f ρ c l = realize P f ρ c l' :=\n  begin\n    hinduction H with a₁ a₂ l\n                      a₂ a₃ a₄ l₂ l₂' l q\n                      a₂ a₃ a₄ l₁ l₂ r H₁ IH\n                      a₂ a₃ l₁ l₂ l₂' H₁ H₁' IH IH',\n    { refl },\n    { rwr [realize_append assoc id_right, realize_append assoc id_right], \n      apply ap (c _), exact resp_rel q },\n    { exact ap (λx, c x (f r)) IH },\n    { exact IH ⬝ IH' }\n  end\n\n\nend graph\n\n/- the following are words of paths in a graph, which means that for example\n   (p ++ q) ++ r and p ++ (q ++ r) are different words. Furthermore, the paths can be reversed.\n   This is used to represent 2-constructors in hit.two_quotient  -/\ninductive pwords {A : Type u} (R : A → A → Type v) : A → A → Type (max u v)\n| of_rel : Π{a a'} (r : R a a'), pwords a a'\n| of_path : Π{a a'} (pp : a = a'), pwords a a'\n| symm : Π{a a'} (r : pwords a a'), pwords a' a\n| trans : Π{a a' a''} (r : pwords a a') (r' : pwords a' a''), pwords a a''\n\nnamespace graph\n  export pwords\n  infix ` ⬝r `:75 := pwords.trans\n  postfix `⁻¹ʳ`:(max+10) := pwords.symm\n  notation `[`:max a `]`:0 := pwords.of_rel a\n  notation `<`:max p `>`:0 := pwords.of_path _ p\n  abbreviation rfl {A : Type _} {R : A → A → Type _} {a : A} := of_path R (idpath a)\nend graph\n\nnamespace graph\n\nsection\nparameters {A : Type _}\n            {R : A → A → Type _}\nprivate abbreviation T := pwords R\n\nvariables ⦃a a' a'' : A⦄ {s : R a a'} {r : T a a} {B : Type _} {C : Type _}\n\n@[hott] protected def pwords.elim {f : A → B}\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a') (t : T a a') : f a = f a' :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n    exact e r,\n    exact ap f pp,\n    exact IH⁻¹,\n    exact IH₁ ⬝ IH₂\nend\n\n@[hott, hsimp] protected def pwords.elim_symm {f : A → B}\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a') (t : T a a') : \n    pwords.elim e t⁻¹ʳ = (pwords.elim e t)⁻¹ :=\nby refl\n\n@[hott, hsimp] protected def pwords.elim_trans {f : A → B}\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a') (t : T a a') (t' : T a' a'') : \n    pwords.elim e (t ⬝r t') = pwords.elim e t ⬝ pwords.elim e t' :=\nby refl\n\n@[hott] def ap_pwords_elim_h {B C : Type _} {f : A → B} {g : B → C}\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a')\n  {e' : Π⦃a a' : A⦄, R a a' → g (f a) = g (f a')}\n  (p : Π⦃a a' : A⦄ (s : R a a'), ap g (e s) = e' s) (t : T a a')\n  : ap g (pwords.elim e t) = pwords.elim e' t :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n    apply p,\n    induction pp, refl,\n    exact ap_inv g (pwords.elim e r) ⬝ inverse2 IH,\n    exact ap_con g (pwords.elim e r) (pwords.elim e r') ⬝ (IH₁ ◾ IH₂)\nend\n\n@[hott, hsimp] def ap_pwords_elim_h_symm {B C : Type _} {f : A → B} {g : B → C}\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a')\n  {e' : Π⦃a a' : A⦄, R a a' → g (f a) = g (f a')}\n  (p : Π⦃a a' : A⦄ (s : R a a'), ap g (e s) = e' s) (t : T a a') : \n  ap_pwords_elim_h e p t⁻¹ʳ = ap_inv g (pwords.elim e t) ⬝ (ap_pwords_elim_h e p t)⁻² :=\nby refl\n\n@[hott, hsimp] def ap_pwords_elim_h_trans {B C : Type _} {f : A → B} {g : B → C}\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a')\n  {e' : Π⦃a a' : A⦄, R a a' → g (f a) = g (f a')}\n  (p : Π⦃a a' : A⦄ (s : R a a'), ap g (e s) = e' s) (t₁ : T a a') (t₂ : T a' a'') : \n  ap_pwords_elim_h e p (t₁ ⬝r t₂) = ap_con g (pwords.elim e t₁) (pwords.elim e t₂) ⬝ \n    ap_pwords_elim_h e p t₁ ◾ ap_pwords_elim_h e p t₂ :=\nby refl\n\n@[hott] def ap_pwords_elim {B C : Type _} {f : A → B} (g : B → C)\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a') (t : T a a')\n  : ap g (pwords.elim e t) = pwords.elim (λa a' r, ap g (e r)) t :=\nap_pwords_elim_h e (λa a' s, idp) t\n\n@[hott, hsimp] def ap_pwords_elim_symm {B C : Type _} {f : A → B} (g : B → C)\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a') (t : T a a')\n  : ap_pwords_elim g e t⁻¹ʳ = ap_inv g (pwords.elim e t) ⬝ (ap_pwords_elim g e t)⁻² :=\nby refl\n\n@[hott, hsimp] def ap_pwords_elim_trans {B C : Type _} {f : A → B} (g : B → C)\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a') (t : T a a') (t' : T a' a'')\n  : ap_pwords_elim g e (t ⬝r t') = ap_con g (pwords.elim e t) (pwords.elim e t') ⬝\n    (ap_pwords_elim g e t ◾ ap_pwords_elim g e t') :=\nby refl\n\n@[hott] def pwords_elim_eq {f : A → B}\n  {e e' : Π⦃a a' : A⦄, R a a' → f a = f a'} (p : e ~3 e') (t : T a a')\n  : pwords.elim e t = pwords.elim e' t :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n    apply p,\n    refl,\n    exact IH⁻²,\n    exact IH₁ ◾ IH₂\nend\n\n-- TODO: formulate and prove this without using function extensionality,\n-- and modify the proofs using this to also not use function extensionality\n-- strategy: use `pwords_elim_eq` instead of `ap ... (eq_of_homotopy3 p)`\n@[hott] def ap_pwords_elim_h_eq {B C : Type _} {f : A → B} {g : B → C}\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a')\n  {e' : Π⦃a a' : A⦄, R a a' → g (f a) = g (f a')}\n  (p : Π⦃a a' : A⦄ (s : R a a'), ap g (e s) = e' s) (t : T a a')\n  : ap_pwords_elim_h e p t =\n    ap_pwords_elim g e t ⬝ ap (λx, pwords.elim x t) (eq_of_homotopy3 p) :=\nbegin\n  fapply homotopy3.rec_on p,\n  intro q, dsimp at q, hinduction q,\n  dsimp [ap_pwords_elim], \n  symmetry, refine whisker_left _ (ap02 _ (by exact eq_of_homotopy3_id _)) ⬝ _,\n  refl\nend\n\n@[hott] def ap_ap_pwords_elim_h {B C D : Type _} {f : A → B}\n  {g : B → C} (h : C → D)\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a')\n  {e' : Π⦃a a' : A⦄, R a a' → g (f a) = g (f a')}\n  (p : Π⦃a a' : A⦄ (s : R a a'), ap g (e s) = e' s) (t : T a a')\n  : square (ap (ap h) (ap_pwords_elim_h e p t))\n            (ap_pwords_elim_h e (λa a' s, ap_compose h g (e s)) t)\n            (ap_compose h g (pwords.elim e t))⁻¹\n            (ap_pwords_elim_h e' (λa a' s, (ap (ap h) (p s))⁻¹) t) :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n  { dsimp,\n    apply square_of_eq, exact con.right_inv _ ⬝ (con.left_inv _)⁻¹ },\n  { induction pp, apply ids},\n  { dsimp, rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_inv _ _ _))⁻¹ᵛ ⬝h _,\n    rwr [con_inv, eq.inv_inv, ←inv2_inv],\n    exact ap_inv2 _ ⬝v square_inv2 IH },\n  { dsimp, rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_con _ _ _ _))⁻¹ᵛ ⬝h _,\n    rwr [con_inv, eq.inv_inv, con2_inv],\n    refine ap_con2 _ _ ⬝v square_con2 IH₁ IH₂ },\nend\n\n@[hott] def ap_ap_pwords_elim {B C D : Type _} {f : A → B}\n  (g : B → C) (h : C → D)\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a') (t : T a a')\n  : square (ap (ap h) (ap_pwords_elim g e t))\n            (ap_pwords_elim_h e (λa a' s, ap_compose h g (e s)) t)\n            (ap_compose h g (pwords.elim e t))⁻¹\n            (ap_pwords_elim h (λa a' r, ap g (e r)) t) :=\nap_ap_pwords_elim_h _ _ _ _\n\n@[hott] def ap_pwords_elim_h_compose {B C D : Type _} {f : A → B}\n  {g : B → C} (h : C → D)\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a')\n  {e' : Π⦃a a' : A⦄, R a a' → h (g (f a)) = h (g (f a'))}\n  (p : Π⦃a a' : A⦄ (s : R a a'), ap (h ∘ g) (e s) = e' s) (t : T a a') : \n    square (ap02 h (ap_pwords_elim g e t)) \n           (ap_pwords_elim_h e p t)\n           (ap_compose h g (pwords.elim e t))⁻¹ \n           (ap_pwords_elim_h (λa a' s, ap g (e s)) (λa a' s, (ap_compose h g (e s))⁻¹ ⬝ p s) t) :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n  { dsimp [ap_pwords_elim_h, ap_pwords_elim, ap02, pwords.elim], \n    apply square_of_eq, apply idp_con },\n  { induction pp, apply ids },\n  -- the rest of the proof is almost the same as the proof of ap_ap_pwords_elim[_h].\n  -- Is there a connection between these theorems?\n  { dsimp [ap02], rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_inv _ _ _))⁻¹ᵛ ⬝h _,\n    rwr [con_inv, eq.inv_inv, ←inv2_inv],\n    exact ap_inv2 _ ⬝v square_inv2 IH },\n  { dsimp [ap02], rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_con _ _ _ _))⁻¹ᵛ ⬝h _,\n    rwr [con_inv, eq.inv_inv, con2_inv],\n    refine ap_con2 _ _ ⬝v square_con2 IH₁ IH₂ },\nend\n\n@[hott] def ap_pwords_elim_h_zigzag {B C D : Type _} {f : A → B}\n  {g : B → C} (h : C → D)\n  (e : Π⦃a a' : A⦄, R a a' → f a = f a')\n  {e' : Π⦃a a' : A⦄, R a a' → h (g (f a)) = h (g (f a'))}\n  (p : Π⦃a a' : A⦄ (s : R a a'), ap (h ∘ g) (e s) = e' s) (t : T a a')\n  : ap_pwords_elim   h (λa a' s, ap g (e s)) t ⬝\n    (ap_pwords_elim_h e (λa a' s, ap_compose h g (e s)) t)⁻¹ ⬝\n    ap_pwords_elim_h e p t =\n    ap_pwords_elim_h (λa a' s, ap g (e s)) (λa a' s, (ap_compose h g (e s))⁻¹ ⬝ p s) t :=\nbegin\n  refine whisker_right _ (eq_of_square (ap_ap_pwords_elim g h e t)⁻¹ʰ)⁻¹ ⬝ _,\n  refine con.assoc _ _ _ ⬝ _, apply inv_con_eq_of_eq_con, apply eq_of_square,\n  apply transpose,\n  -- the rest of the proof is almost the same as the proof of ap_ap_pwords_elim[_h].\n  -- Is there a connection between these theorems?\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n  { dsimp, apply square_of_eq, apply idp_con },\n  { induction pp, apply ids },\n  { dsimp, rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_inv _ _ _))⁻¹ᵛ ⬝h _,\n    rwr [con_inv, eq.inv_inv, ←inv2_inv],\n    exact ap_inv2 _ ⬝v square_inv2 IH },\n  { dsimp, rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_con _ _ _ _))⁻¹ᵛ ⬝h _,\n    rwr [con_inv, eq.inv_inv, con2_inv],\n    refine ap_con2 _ _ ⬝v square_con2 IH₁ IH₂ },\nend\n\nopen hott.relation\n@[hott] def is_equivalence_pwords : is_equivalence T :=\nbegin\n  constructor,\n    intro a, exact rfl,\n    intros a a' t, exact t⁻¹ʳ,\n    intros a a' a'' t t', exact t ⬝r t',\nend\n\n/- dependent elimination -/\n\nvariables {P : B → Type _} {Q : C → Type _} {f : A → B} {g : B → C} {f' : Π(a : A), P (f a)}\n@[hott] protected def pwords.elimo (p : Π⦃a a' : A⦄, R a a' → f a = f a')\n  (po : Π⦃a a' : A⦄ (s : R a a'), f' a =[p s] f' a') (t : T a a')\n  : f' a =[pwords.elim p t] f' a' :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n    exact po r,\n    induction pp, constructor,\n    exact IH⁻¹ᵒ,\n    exact IH₁ ⬝o IH₂\nend\n\n@[hott, hsimp] def elimo_symm (p : Π⦃a a' : A⦄, R a a' → f a = f a')\n  (po : Π⦃a a' : A⦄ (s : R a a'), f' a =[p s] f' a') (t : T a a')\n  : pwords.elimo p po t⁻¹ʳ = (pwords.elimo p po t)⁻¹ᵒ :=\nby refl\n\n@[hott, hsimp] def elimo_trans (p : Π⦃a a' : A⦄, R a a' → f a = f a')\n  (po : Π⦃a a' : A⦄ (s : R a a'), f' a =[p s] f' a') (t : T a a') (t' : T a' a'')\n  : pwords.elimo p po (t ⬝r t') = pwords.elimo p po t ⬝o pwords.elimo p po t' :=\nby refl\n\n@[hott] def ap_pwords_elimo_h  {g' : Πb, Q (g b)}\n  (p : Π⦃a a' : A⦄, R a a' → f a = f a')\n  (po : Π⦃a a' : A⦄ (s : R a a'), g' (f a) =[p s; Q ∘ g] g' (f a'))\n  (q : Π⦃a a' : A⦄ (s : R a a'), apd g' (p s) = po s)\n  (t : T a a') : apd g' (pwords.elim p t) = pwords.elimo p po t :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n    apply q,\n    induction pp, refl,\n    exact apd_inv g' (pwords.elim p r) ⬝ IH⁻²ᵒ,\n    exact apd_con g' (pwords.elim p r) (pwords.elim p r') ⬝ (IH₁ ◾o IH₂)\nend\n\n@[hott] theorem pwords_elimo_ap {g' : Π(a : A), Q (g (f a))}\n  (p : Π⦃a a' : A⦄, R a a' → f a = f a')\n  (po : Π⦃a a' : A⦄ (s : R a a'), g' a =[ap g (p s)] g' a')\n  (t : T a a') : pwords.elimo p (λa a' s, pathover_of_pathover_ap Q g (po s)) t =\n    pathover_of_pathover_ap Q g (change_path (ap_pwords_elim g p t)⁻¹\n      (pwords.elimo (λa a' r, ap g (p r)) po t)) :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH₁ IH₂,\n  { refl },\n  { induction pp; refl },\n  { rwr [elimo_symm, ap_pwords_elim_symm, IH, con_inv, change_path_con, ←inv2_inv], dsimp,\n    rwr [change_path_invo, pathover_of_pathover_ap_invo] },\n  { rwr [elimo_trans, elimo_trans, ap_pwords_elim_trans, IH₁, IH₂, con_inv, change_path_con], \n    dsimp, rwr [con2_inv, change_path_cono, pathover_of_pathover_ap_cono] },\nend\n\nend\nend graph\nend hott", "meta": {"author": "gebner", "repo": "hott3", "sha": "7ead7a8a2503049eacd45cbff6587802bae2add2", "save_path": "github-repos/lean/gebner-hott3", "path": "github-repos/lean/gebner-hott3/hott3-7ead7a8a2503049eacd45cbff6587802bae2add2/src/hott/algebra/graph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4630599945720184}}
{"text": "import types\n\ndef assign_lit (l : literal) : formula → formula\n| [] := []\n| (x :: f) :=\n  (if l ∈ x then [] else [list.remove_all x [l_not l]]) ++ assign_lit f\n\ndef assign_all (f : formula) (lits : list literal) :=\nlist.foldl (λ f l, assign_lit l f) f lits\n\nlemma assign_removes : ∀ (f : formula) (l : literal),\n  l ∉ (assign_lit l f).join ∧ l_not l ∉ (assign_lit l f).join:=\nbegin\n  intros f l,\n  induction' f;\n  rw assign_lit;\n  simp,\n  apply and.intro;\n  intro h;\n  cases' h;\n  cases' h;\n  cases' h,\n  {\n    cases' classical.em (l ∈ hd);\n    simp [h] at left,\n    {\n      assumption,\n    },\n    {\n      rw left at right,\n      rw list.remove_all at right,\n      simp [h] at right,\n      assumption,\n    },\n  },\n  {\n    have not_in := ih l,\n    simp at not_in,\n\n    have not_in := (and.elim_left not_in) w left,\n    exact not_in right,\n  },\n  {\n    cases' classical.em (l ∈ hd);\n    simp [h] at left,\n    {\n      assumption,\n    },\n    {\n      rw left at right,\n      rw list.remove_all at right,\n      simp [h] at right,\n      assumption,\n    },\n\n  },\n  {\n    have not_in := ih l,\n    simp at not_in,\n\n    have not_in := (and.elim_right not_in) w left,\n    exact not_in right,\n  },\nend\n\nlemma assign_subset : ∀ (f : formula) (l : literal),\n  (assign_lit l f).join ⊆ f.join :=\nbegin\n  intros f l_assign l h,\n  induction f;\n  rw assign_lit at h;\n  simp [h],\n  {\n    apply h,\n  },\n  {\n    simp at h,\n    cases' h,\n    {\n      cases' h,\n      cases' h,\n      cases' classical.em (l_assign ∈ f_hd);\n      simp [h] at left,\n      {\n        apply classical.by_contradiction,\n        intros,\n        assumption,\n      },\n      {\n        rw left at right,\n        have sub : list.remove_all f_hd [l_not l_assign] ⊆ f_hd :=\n          by apply list.filter_subset,\n        apply or.intro_left,\n        apply sub,\n        assumption,\n      },\n    },\n    {\n      cases' h,\n      cases' h,\n      apply or.intro_right,\n      simp at f_ih,\n      apply f_ih w left right,\n    },\n  },\nend\n\nlemma list_not_in_append {α : Type} (a b : list  α) (c : α) : c ∉ a ++ b ↔ c ∉ a ∧ c ∉ b :=\nbegin\n  apply iff.intro,\n  {\n    intro h,\n\n    induction' a,\n    {\n      simp at h,\n      simp [h],\n    },\n    {\n      simp [h],\n      rw not_or_distrib,\n      have n_in :=  list.ne_and_not_mem_of_not_mem_cons h,\n      cases' n_in,\n      simp [left],\n      apply ih,\n      exact right,\n    },\n  },\n  {\n    intro h,\n    cases' h,\n    exact list.not_mem_append left right,\n  },\nend\n\nlemma assign_when_not_in_out : ∀ (f : formula) (l : literal) (c : clause),\n  c ∈ f → c ∉ assign_lit l f → l_not l ∈ c ∨ l ∈ c :=\nbegin\n  intros f l c c_f c_n_a_f,\n  induction' f,\n  {\n    simp at c_f,\n    contradiction,\n  },\n  {\n    cases' classical.em (c ∈ f),\n    {\n      rw assign_lit at c_n_a_f,\n\n      apply ih,\n      {\n        assumption,\n      },\n      {\n        rw list_not_in_append at c_n_a_f,\n        cases' c_n_a_f,\n        assumption,\n      },\n    },\n    {\n      have eq : c = hd := begin\n        cases' c_f,\n        {\n          assumption,\n        },\n        {\n          contradiction,\n        },\n      end,\n      rw assign_lit at c_n_a_f,\n      rw eq,\n      rw eq at c_n_a_f,\n\n      apply classical.by_contradiction,\n      intro h,\n      rw not_or_distrib at h,\n      cases h,\n      simp [h_left, h_right] at c_n_a_f,\n      rw not_or_distrib at c_n_a_f,\n      cases c_n_a_f,\n\n      have h_eq : list.remove_all hd [l_not l] = hd  := begin\n        rw list.remove_all,\n        simp,\n        rw list.filter_eq_self,\n        intros a h,\n        intro h_eq,\n        rw ←h_eq at h_left,\n        contradiction,\n      end,\n\n      rw h_eq at c_n_a_f_left,\n      contradiction,\n    },\n  },\nend\n\nlemma remove_all_length_impl {α : Type} [decidable_eq α]\n  (l : list α) (r : α) : (l.remove_all [r]).length + (if r ∈ l then 1 else 0) ≤ l.length :=\nbegin\n  induction' l,\n  {\n    rw list.remove_all,\n    simp,\n\n  },\n  {\n    rw list.remove_all,\n    rw list.filter,\n    simp,\n    cases' classical.em (hd = r);\n    have ih := ih r;\n    rw list.remove_all at ih;\n    cases' classical.em (r ∈ l);\n    simp [h, h_1];\n    simp [h_1] at ih,\n    linarith,\n    linarith,\n    linarith,\n    have neq := ne.symm h,\n    simp [neq],\n    apply ih,\n  },\nend\n\nlemma remove_all_leq_length {α : Type} [decidable_eq α]\n  (l : list α) (r : α) : (l.remove_all [r]).length ≤ l.length :=\nbegin\n  have h := remove_all_length_impl l r,\n  cases' classical.em (r ∈ l);\n  simp [h_1] at h;\n  linarith,\nend\n\nlemma remove_all_less_length {α : Type} [decidable_eq α]\n  (l : list α) (r : α) (h : r ∈ l) : (l.remove_all [r]).length < l.length :=\nbegin\n  have h_impl := remove_all_length_impl l r,\n  simp [h] at h_impl,\n  linarith,\nend\n\nlemma assign_without_present_eq  (f : formula) (l : literal) :\nl ∉ f.join ∧ l_not l ∉ f.join → assign_lit l f = f :=\nbegin\n  intro h,\n  induction' f;\n  rw assign_lit,\n  simp at h,\n  cases' h,\n  rw not_or_distrib at left,\n  rw not_or_distrib at right,\n  cases' left,\n  cases' right,\n  simp [left],\n  apply and.intro,\n  {\n    rw list.remove_all,\n    rw list.filter_eq_self,\n    simp,\n    intros a h_in,\n    intro eq,\n    rw eq at h_in,\n    contradiction,\n  },\n  {\n    apply ih,\n    simp [right, right_1],\n  },\nend\n\nlemma assign_with_present_reduces_size :\n∀ (f : formula) (l : literal),\nl ∈ f.join ∨ l_not l ∈ f.join →\nformula_size (assign_lit l f) < formula_size f :=\nbegin\n  intros f l h,\n  rw formula_size,\n  rw formula_size,\n  induction' f,\n  {\n    simp at h,\n    contradiction,\n  },\n  {\n    cases' classical.em (l ∈ f.join ∨ l_not l ∈ f.join),\n    {\n      rw assign_lit,\n      simp,\n      have leq : (list.map list.length (ite (l ∈ hd) list.nil\n                  [list.remove_all hd [l_not l]])).sum ≤ hd.length :=\n      begin\n        cases' classical.em (l ∈ hd);\n        simp [h_2],\n        apply remove_all_leq_length,\n      end,\n      have ih := ih l h_1,\n      simp at ih,\n      linarith,\n    },\n    {\n      rw not_or_distrib at h_1,\n      have h_in : l ∈ hd ∨ l_not l ∈ hd := begin\n        simp [h_1] at h,\n        apply h,\n      end,\n\n      rw assign_lit,\n      have h_eq := assign_without_present_eq _ _ h_1,\n      rw h_eq,\n      simp,\n\n      cases classical.em (l ∈ hd);\n      simp [h_2],\n      {\n        exact list.length_pos_of_mem h_2,\n      },\n      {\n        simp [h_2] at h_in,\n        exact remove_all_less_length _ _ h_in,\n      },\n    },\n  },\nend\n\n\nlemma assign_leq_size (f : formula) (l : literal) :\nformula_size (assign_lit l f) ≤ formula_size f :=\nbegin\n  cases' classical.em (l ∉ f.join ∧ l_not l ∉ f.join),\n  {\n    have h := assign_without_present_eq _ _ h,\n    rw h,\n  },\n  {\n    rw not_and_distrib at h,\n    have h : l ∈ f.join ∨ l_not l ∈ f.join := begin\n      simp,\n      simp at h,\n      apply h,\n    end,\n\n    have less := assign_with_present_reduces_size _ _ h,\n    linarith,\n  },\nend\n\nlemma list_containment_l {α : Type} : ∀ (a b : list α) (c : α),\n  c ∉ b → c ∈ a ++ b → c ∈ a :=\nbegin\n  intros a b c h_1 h_2,\n  induction' a;\n  finish,\nend\n\nlemma removed_literal_must_be_contained\n  (f : formula) (l : literal) (c : clause):\n  c ∈ f → c ∉ assign_lit l f → l ∉ c → l_not l ∈ c →\n  c.remove_all [l_not l] ∈ assign_lit l f :=\nbegin\n  intros h_in_f h_n_in_a_f l_n_in_c n_l_in_c,\n  induction' f,\n  {\n    simp at h_in_f,\n    contradiction,\n  },\n  {\n    cases' classical.em (c = hd),\n    {\n      rw assign_lit,\n      rw h at l_n_in_c,\n      simp [l_n_in_c],\n      apply or.inl,\n      rw h,\n    },\n    {\n      have in_f : c ∈ f := list.mem_of_ne_of_mem h h_in_f,\n      rw assign_lit,\n      simp,\n      apply or.inr,\n      apply ih _ _ l_n_in_c n_l_in_c in_f,\n\n      rw assign_lit at h_n_in_a_f,\n      simp at h_n_in_a_f,\n      rw not_or_distrib at h_n_in_a_f,\n      cases' h_n_in_a_f,\n      assumption,\n    },\n  },\nend\n\ndef add_l_to_assign (a : assignment) (l : literal) : assignment :=\nsubtype.mk (a.val.remove_all [l_not l] ++ [l]) begin\n  intros l_other h_l_in,\n  simp,\n  rw not_or_distrib,\n  cases' classical.em (l = l_other),\n  {\n    rw h,\n    apply and.intro,\n    {\n      intro h_in,\n      apply list.of_mem_filter h_in,\n      simp,\n    },\n    {\n      intro h_eq,\n      have neq := l_not_neq l_other,\n      rw h_eq at neq,\n      contradiction,\n    },\n  },\n  {\n    apply and.intro,\n    {\n      have in_filtered : l_other ∈ a.val.remove_all [l_not l] := begin\n        apply list_containment_l _ _ _ _ h_l_in,\n        simp,\n        intro h_eq,\n        rw h_eq at h,\n        contradiction,\n      end,\n      have other_in : l_other ∈ a.val := begin\n        rw list.remove_all at in_filtered,\n        rw list.mem_filter at in_filtered,\n        cases' in_filtered,\n        exact left,\n      end,\n      have not_not_in : l_not l_other  ∉ a.val := begin\n        apply a.property,\n        exact other_in,\n      end,\n      rw list.remove_all,\n      rw list.mem_filter,\n      rw not_and_distrib,\n      apply or.inl not_not_in,\n    },\n    {\n      intro h_eq,\n      rw ←h_eq at h_l_in,\n      simp at h_l_in,\n      apply list.of_mem_filter h_l_in,\n      simp,\n    },\n  },\nend\n\nlemma assign_sat_implies_sat :\n∀ (f : formula) (l : literal), sat (assign_lit l f) → sat f := begin\n  intros f l h,\n  set a_f := assign_lit l f,\n  cases' h,\n  let assigned := [l],\n  let filtered := (w.val.remove_all [l_not l]),\n  let new_a := filtered ++ assigned,\n\n  apply exists.intro (add_l_to_assign w l),\n  rw add_l_to_assign,\n  rw formula_sat,\n  intros c h_in_f,\n  rw clause_sat,\n\n  cases' classical.em (c ∈ a_f),\n  {\n    rw formula_sat at h,\n    cases' (h c h_1),\n    apply exists.intro w_1,\n    cases' h_2,\n    simp [right],\n\n    have actually_in : w_1 ∈ list.join (assign_lit l f) := begin\n      simp,\n      apply exists.intro c,\n      simp [h_1, right],\n    end,\n    have w_neq : w_1 ≠ l_not l := begin\n      cases' (assign_removes f l),\n      intro h_eq,\n      rw h_eq at actually_in,\n      contradiction,\n    end,\n\n    have h_in : w_1 ∈ filtered := begin\n      apply list.mem_filter_of_mem,\n      assumption,\n      simp,\n      apply w_neq,\n    end,\n\n    have is_in : w_1 ∈ new_a := by simp [h_in],\n    simp only [new_a, filtered] at is_in,\n    apply is_in,\n  },\n  {\n    cases' classical.em (l ∈ c),\n    {\n      apply exists.intro l,\n      simp [h_2],\n      have l_in : l ∈ (filtered ++ assigned) := begin\n        simp only [assigned],\n        simp,\n      end,\n      apply l_in,\n    },\n    {\n      have either := assign_when_not_in_out _ _ _ h_in_f h_1,\n      simp [h_2] at either,\n\n      let removed := c.remove_all [l_not l],\n      have removed_in : removed ∈ a_f :=\n        removed_literal_must_be_contained _ _ _ h_in_f h_1 h_2 either,\n      rw formula_sat at h,\n      have h := h removed removed_in,\n      cases' h,\n      apply exists.intro w_1,\n      cases' h_3,\n      have removed_sub : removed ⊆ c := by apply list.filter_subset,\n      have neq_l : w_1 ≠ l := begin\n        intro h,\n        rw h at right,\n        have in_c : l ∈ c := begin\n          apply removed_sub,\n          exact right,\n        end,\n        contradiction,\n      end,\n      have neq_n_l : w_1 ≠ l_not l := begin\n        intro h,\n        rw h at right,\n        apply list.of_mem_filter right,\n        simp,\n      end,\n      apply and.intro,\n      {\n        apply list.mem_append_left,\n        apply list.mem_filter_of_mem left,\n        simp,\n        exact neq_n_l,\n      },\n      {\n        apply removed_sub,\n        exact right,\n      },\n    },\n  },\nend\n\nlemma must_exist_filtered_clause (f : formula) (l : literal) (c : clause):\nc ∉ f → c ∈ assign_lit l f →\n(∃ (c' : clause), c'.remove_all [l_not l] = c ∧ c' ∈ f) :=\nbegin\n  intros h_n_in_f h_in_a_f,\n  induction' f,\n  {\n    rw assign_lit at h_in_a_f,\n    simp at h_in_a_f,\n    contradiction,\n  },\n  {\n    cases' classical.em (hd.remove_all [l_not l] = c),\n    {\n      apply exists.intro hd,\n      apply and.intro,\n      {\n        exact h,\n      },\n      {\n        simp,\n      },\n    },\n    {\n      rw assign_lit at h_in_a_f,\n      simp at h_in_a_f,\n      cases' h_in_a_f,\n      {\n        cases' classical.em (l ∈ hd);\n        simp [h_2] at h_1,\n        {\n          contradiction,\n        },\n        {\n          rw h_1 at h,\n          contradiction,\n        },\n      },\n      {\n        have ih := ih _ _ (list.not_mem_of_not_mem_cons h_n_in_f) h_1,\n        cases' ih,\n        apply exists.intro w,\n        simp [h_2],\n      },\n    },\n  },\nend\n\nlemma sat_implies_assign_sat_or_cant_exist (f : formula) (l : literal) :\n(∃ (a : assignment), formula_sat a f ∧ l ∈ a) →\nsat (assign_lit l f) :=\nbegin\n  intros assign_exists,\n  cases' assign_exists,\n  cases' h,\n  apply exists.intro w,\n  rw formula_sat,\n  intros c c_in,\n  rw formula_sat at left,\n  cases' classical.em (c ∈ f),\n  {\n    exact left c h,\n  },\n  {\n    have exists_filtered := must_exist_filtered_clause _ _ _ h c_in,\n    cases' exists_filtered,\n    cases' h_1,\n    have clause_sat_other := left w_1 right_1,\n    rw clause_sat at clause_sat_other,\n    cases' clause_sat_other,\n    apply exists.intro w_2,\n    simp [h_1],\n    rw ←left_1,\n    apply list.mem_filter_of_mem,\n    {\n      simp [h_1],\n    },\n    {\n      intro h,\n      simp at h,\n      cases' h_1,\n      rw h at left_2,\n      apply w.property _ right left_2,\n    },\n  },\nend\n\nlemma assign_all_leq_size (f : formula) (lits : list literal)\n: formula_size (assign_all f lits) ≤ formula_size f :=\nbegin\n  rw assign_all,\n  induction' lits;\n  simp,\n  have ih := ih (assign_lit hd f),\n  have less : formula_size (assign_lit hd f) ≤ formula_size f :=\n    by apply assign_leq_size,\n  linarith,\nend\n", "meta": {"author": "rgreenblatt", "repo": "verified_sat", "sha": "2ca61677cf72df76a4ea6b0982998ec867102da1", "save_path": "github-repos/lean/rgreenblatt-verified_sat", "path": "github-repos/lean/rgreenblatt-verified_sat/verified_sat-2ca61677cf72df76a4ea6b0982998ec867102da1/src/assign.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185944046238982, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.46293656665629696}}
{"text": "/-\nCopyright (c) 2022 Yakov Pechersky. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard,\nAmelia Livingston, Yury Kudryashov, Yakov Pechersky, Jireh Loreaux\n-/\nimport group_theory.subsemigroup.basic\n\n/-!\n# Operations on `subsemigroup`s\n\nIn this file we define various operations on `subsemigroup`s and `mul_hom`s.\n\n## Main definitions\n\n### Conversion between multiplicative and additive definitions\n\n* `subsemigroup.to_add_subsemigroup`, `subsemigroup.to_add_subsemigroup'`,\n  `add_subsemigroup.to_subsemigroup`, `add_subsemigroup.to_subsemigroup'`:\n  convert between multiplicative and additive subsemigroups of `M`,\n  `multiplicative M`, and `additive M`. These are stated as `order_iso`s.\n\n### (Commutative) semigroup structure on a subsemigroup\n\n* `subsemigroup.to_semigroup`, `subsemigroup.to_comm_semigroup`: a subsemigroup inherits a\n  (commutative) semigroup structure.\n\n### Operations on subsemigroups\n\n* `subsemigroup.comap`: preimage of a subsemigroup under a semigroup homomorphism as a subsemigroup\n  of the domain;\n* `subsemigroup.map`: image of a subsemigroup under a semigroup homomorphism as a subsemigroup of\n  the codomain;\n* `subsemigroup.prod`: product of two subsemigroups `s : subsemigroup M` and `t : subsemigroup N`\n  as a subsemigroup of `M × N`;\n\n### Semigroup homomorphisms between subsemigroups\n\n* `subsemigroup.subtype`: embedding of a subsemigroup into the ambient semigroup.\n* `subsemigroup.inclusion`: given two subsemigroups `S`, `T` such that `S ≤ T`, `S.inclusion T` is\n  the inclusion of `S` into `T` as a semigroup homomorphism;\n* `mul_equiv.subsemigroup_congr`: converts a proof of `S = T` into a semigroup isomorphism between\n  `S` and `T`.\n* `subsemigroup.prod_equiv`: semigroup isomorphism between `s.prod t` and `s × t`;\n\n### Operations on `mul_hom`s\n\n* `mul_hom.srange`: range of a semigroup homomorphism as a subsemigroup of the codomain;\n* `mul_hom.restrict`: restrict a semigroup homomorphism to a subsemigroup;\n* `mul_hom.cod_restrict`: restrict the codomain of a semigroup homomorphism to a subsemigroup;\n* `mul_hom.srange_restrict`: restrict a semigroup homomorphism to its range;\n\n### Implementation notes\n\nThis file follows closely `group_theory/submonoid/operations.lean`, omitting only that which is\nnecessary.\n\n## Tags\n\nsubsemigroup, range, product, map, comap\n-/\n\nvariables {M N P σ : Type*}\n\n/-!\n### Conversion to/from `additive`/`multiplicative`\n-/\n\nsection\n\nvariables [has_mul M]\n\n/-- Subsemigroups of semigroup `M` are isomorphic to additive subsemigroups of `additive M`. -/\n@[simps]\ndef subsemigroup.to_add_subsemigroup : subsemigroup M ≃o add_subsemigroup (additive M) :=\n{ to_fun := λ S,\n  { carrier := additive.to_mul ⁻¹' S,\n    add_mem' := S.mul_mem' },\n  inv_fun := λ S,\n  { carrier := additive.of_mul ⁻¹' S,\n    mul_mem' := S.add_mem' },\n  left_inv := λ x, by cases x; refl,\n  right_inv := λ x, by cases x; refl,\n  map_rel_iff' := λ a b, iff.rfl, }\n\n/-- Additive subsemigroups of an additive semigroup `additive M` are isomorphic to subsemigroups\nof `M`. -/\nabbreviation add_subsemigroup.to_subsemigroup' : add_subsemigroup (additive M) ≃o subsemigroup M :=\nsubsemigroup.to_add_subsemigroup.symm\n\nlemma subsemigroup.to_add_subsemigroup_closure (S : set M) :\n  (subsemigroup.closure S).to_add_subsemigroup = add_subsemigroup.closure (additive.to_mul ⁻¹' S) :=\nle_antisymm\n  (subsemigroup.to_add_subsemigroup.le_symm_apply.1 $\n    subsemigroup.closure_le.2 add_subsemigroup.subset_closure)\n  (add_subsemigroup.closure_le.2 subsemigroup.subset_closure)\n\nlemma add_subsemigroup.to_subsemigroup'_closure (S : set (additive M)) :\n  (add_subsemigroup.closure S).to_subsemigroup' =\n    subsemigroup.closure (multiplicative.of_add ⁻¹' S) :=\nle_antisymm\n  (add_subsemigroup.to_subsemigroup'.le_symm_apply.1 $\n    add_subsemigroup.closure_le.2 subsemigroup.subset_closure)\n  (subsemigroup.closure_le.2 add_subsemigroup.subset_closure)\n\nend\n\nsection\n\nvariables {A : Type*} [has_add A]\n\n/-- Additive subsemigroups of an additive semigroup `A` are isomorphic to\nmultiplicative subsemigroups of `multiplicative A`. -/\n@[simps]\ndef add_subsemigroup.to_subsemigroup : add_subsemigroup A ≃o subsemigroup (multiplicative A) :=\n{ to_fun := λ S,\n  { carrier := multiplicative.to_add ⁻¹' S,\n    mul_mem' := S.add_mem' },\n  inv_fun := λ S,\n  { carrier := multiplicative.of_add ⁻¹' S,\n    add_mem' := S.mul_mem' },\n  left_inv := λ x, by cases x; refl,\n  right_inv := λ x, by cases x; refl,\n  map_rel_iff' := λ a b, iff.rfl, }\n\n/-- Subsemigroups of a semigroup `multiplicative A` are isomorphic to additive subsemigroups\nof `A`. -/\nabbreviation subsemigroup.to_add_subsemigroup' :\n  subsemigroup (multiplicative A) ≃o add_subsemigroup A :=\nadd_subsemigroup.to_subsemigroup.symm\n\nlemma add_subsemigroup.to_subsemigroup_closure (S : set A) :\n  (add_subsemigroup.closure S).to_subsemigroup =\n    subsemigroup.closure (multiplicative.to_add ⁻¹' S) :=\nle_antisymm\n  (add_subsemigroup.to_subsemigroup.to_galois_connection.l_le $\n    add_subsemigroup.closure_le.2 subsemigroup.subset_closure)\n  (subsemigroup.closure_le.2 add_subsemigroup.subset_closure)\n\nlemma subsemigroup.to_add_subsemigroup'_closure (S : set (multiplicative A)) :\n  (subsemigroup.closure S).to_add_subsemigroup' =\n    add_subsemigroup.closure (additive.of_mul ⁻¹' S) :=\nle_antisymm\n  (subsemigroup.to_add_subsemigroup'.to_galois_connection.l_le $\n    subsemigroup.closure_le.2 add_subsemigroup.subset_closure)\n  (add_subsemigroup.closure_le.2 subsemigroup.subset_closure)\n\nend\n\nnamespace subsemigroup\n\nopen set\n\n/-!\n### `comap` and `map`\n-/\n\nvariables [has_mul M] [has_mul N] [has_mul P] (S : subsemigroup M)\n\n/-- The preimage of a subsemigroup along a semigroup homomorphism is a subsemigroup. -/\n@[to_additive \"The preimage of an `add_subsemigroup` along an `add_semigroup` homomorphism is an\n`add_subsemigroup`.\"]\ndef comap (f : M →ₙ* N) (S : subsemigroup N) : subsemigroup M :=\n{ carrier := (f ⁻¹' S),\n  mul_mem' := λ a b ha hb,\n    show f (a * b) ∈ S, by rw map_mul; exact mul_mem ha hb }\n\n@[simp, to_additive]\nlemma coe_comap (S : subsemigroup N) (f : M →ₙ* N) : (S.comap f : set M) = f ⁻¹' S := rfl\n\n@[simp, to_additive]\nlemma mem_comap {S : subsemigroup N} {f : M →ₙ* N} {x : M} : x ∈ S.comap f ↔ f x ∈ S := iff.rfl\n\n@[to_additive]\nlemma comap_comap (S : subsemigroup P) (g : N →ₙ* P) (f : M →ₙ* N) :\n  (S.comap g).comap f = S.comap (g.comp f) :=\nrfl\n\n@[simp, to_additive]\nlemma comap_id (S : subsemigroup P) : S.comap (mul_hom.id _) = S :=\next (by simp)\n\n/-- The image of a subsemigroup along a semigroup homomorphism is a subsemigroup. -/\n@[to_additive \"The image of an `add_subsemigroup` along an `add_semigroup` homomorphism is\nan `add_subsemigroup`.\"]\ndef map (f : M →ₙ* N) (S : subsemigroup M) : subsemigroup N :=\n{ carrier := (f '' S),\n  mul_mem' := begin rintros _ _ ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩,\n    exact ⟨x * y, @mul_mem (subsemigroup M) M _ _ _ _ _ _ hx hy, by rw map_mul; refl⟩ end }\n\n@[simp, to_additive]\nlemma coe_map (f : M →ₙ* N) (S : subsemigroup M) :\n  (S.map f : set N) = f '' S := rfl\n\n@[simp, to_additive]\nlemma mem_map {f : M →ₙ* N} {S : subsemigroup M} {y : N} :\n  y ∈ S.map f ↔ ∃ x ∈ S, f x = y :=\nmem_image_iff_bex\n\n@[to_additive]\nlemma mem_map_of_mem (f : M →ₙ* N) {S : subsemigroup M} {x : M} (hx : x ∈ S) : f x ∈ S.map f :=\nmem_image_of_mem f hx\n\n@[to_additive]\nlemma apply_coe_mem_map (f : M →ₙ* N) (S : subsemigroup M) (x : S) : f x ∈ S.map f :=\nmem_map_of_mem f x.prop\n\n@[to_additive]\nlemma map_map (g : N →ₙ* P) (f : M →ₙ* N) : (S.map f).map g = S.map (g.comp f) :=\nset_like.coe_injective $ image_image _ _ _\n\n@[to_additive]\nlemma mem_map_iff_mem {f : M →ₙ* N} (hf : function.injective f) {S : subsemigroup M} {x : M} :\n  f x ∈ S.map f ↔ x ∈ S :=\nhf.mem_set_image\n\n@[to_additive]\nlemma map_le_iff_le_comap {f : M →ₙ* N} {S : subsemigroup M} {T : subsemigroup N} :\n  S.map f ≤ T ↔ S ≤ T.comap f :=\nimage_subset_iff\n\n@[to_additive]\nlemma gc_map_comap (f : M →ₙ* N) : galois_connection (map f) (comap f) :=\nλ S T, map_le_iff_le_comap\n\n@[to_additive]\nlemma map_le_of_le_comap {T : subsemigroup N} {f : M →ₙ* N} : S ≤ T.comap f → S.map f ≤ T :=\n(gc_map_comap f).l_le\n\n@[to_additive]\nlemma le_comap_of_map_le {T : subsemigroup N} {f : M →ₙ* N} : S.map f ≤ T → S ≤ T.comap f :=\n(gc_map_comap f).le_u\n\n@[to_additive]\nlemma le_comap_map {f : M →ₙ* N} : S ≤ (S.map f).comap f :=\n(gc_map_comap f).le_u_l _\n\n@[to_additive]\nlemma map_comap_le {S : subsemigroup N} {f : M →ₙ* N} : (S.comap f).map f ≤ S :=\n(gc_map_comap f).l_u_le _\n\n@[to_additive]\nlemma monotone_map {f : M →ₙ* N} : monotone (map f) :=\n(gc_map_comap f).monotone_l\n\n@[to_additive]\nlemma monotone_comap {f : M →ₙ* N} : monotone (comap f) :=\n(gc_map_comap f).monotone_u\n\n@[simp, to_additive]\nlemma map_comap_map {f : M →ₙ* N} : ((S.map f).comap f).map f = S.map f :=\n(gc_map_comap f).l_u_l_eq_l _\n\n@[simp, to_additive]\nlemma comap_map_comap {S : subsemigroup N} {f : M →ₙ* N} :\n  ((S.comap f).map f).comap f = S.comap f :=\n(gc_map_comap f).u_l_u_eq_u _\n\n@[to_additive]\nlemma map_sup (S T : subsemigroup M) (f : M →ₙ* N) : (S ⊔ T).map f = S.map f ⊔ T.map f :=\n(gc_map_comap f).l_sup\n\n@[to_additive]\nlemma map_supr {ι : Sort*} (f : M →ₙ* N) (s : ι → subsemigroup M) :\n  (supr s).map f = ⨆ i, (s i).map f :=\n(gc_map_comap f).l_supr\n\n@[to_additive]\nlemma comap_inf (S T : subsemigroup N) (f : M →ₙ* N) : (S ⊓ T).comap f = S.comap f ⊓ T.comap f :=\n(gc_map_comap f).u_inf\n\n@[to_additive]\nlemma comap_infi {ι : Sort*} (f : M →ₙ* N) (s : ι → subsemigroup N) :\n  (infi s).comap f = ⨅ i, (s i).comap f :=\n(gc_map_comap f).u_infi\n\n@[simp, to_additive] lemma map_bot (f : M →ₙ* N) : (⊥ : subsemigroup M).map f = ⊥ :=\n(gc_map_comap f).l_bot\n\n@[simp, to_additive] lemma comap_top (f : M →ₙ* N) : (⊤ : subsemigroup N).comap f = ⊤ :=\n(gc_map_comap f).u_top\n\n@[simp, to_additive] lemma map_id (S : subsemigroup M) : S.map (mul_hom.id M) = S :=\next (λ x, ⟨λ ⟨_, h, rfl⟩, h, λ h, ⟨_, h, rfl⟩⟩)\n\nsection galois_coinsertion\n\nvariables {ι : Type*} {f : M →ₙ* N} (hf : function.injective f)\n\ninclude hf\n\n/-- `map f` and `comap f` form a `galois_coinsertion` when `f` is injective. -/\n@[to_additive /-\" `map f` and `comap f` form a `galois_coinsertion` when `f` is injective. \"-/]\ndef gci_map_comap : galois_coinsertion (map f) (comap f) :=\n(gc_map_comap f).to_galois_coinsertion\n  (λ S x, by simp [mem_comap, mem_map, hf.eq_iff])\n\n@[to_additive]\nlemma comap_map_eq_of_injective (S : subsemigroup M) : (S.map f).comap f = S :=\n(gci_map_comap hf).u_l_eq _\n\n@[to_additive]\nlemma comap_surjective_of_injective : function.surjective (comap f) :=\n(gci_map_comap hf).u_surjective\n\n@[to_additive]\nlemma map_injective_of_injective : function.injective (map f) :=\n(gci_map_comap hf).l_injective\n\n@[to_additive]\nlemma comap_inf_map_of_injective (S T : subsemigroup M) : (S.map f ⊓ T.map f).comap f = S ⊓ T :=\n(gci_map_comap hf).u_inf_l _ _\n\n@[to_additive]\nlemma comap_infi_map_of_injective (S : ι → subsemigroup M) : (⨅ i, (S i).map f).comap f = infi S :=\n(gci_map_comap hf).u_infi_l _\n\n@[to_additive]\nlemma comap_sup_map_of_injective (S T : subsemigroup M) : (S.map f ⊔ T.map f).comap f = S ⊔ T :=\n(gci_map_comap hf).u_sup_l _ _\n\n@[to_additive]\nlemma comap_supr_map_of_injective (S : ι → subsemigroup M) : (⨆ i, (S i).map f).comap f = supr S :=\n(gci_map_comap hf).u_supr_l _\n\n@[to_additive]\nlemma map_le_map_iff_of_injective {S T : subsemigroup M} : S.map f ≤ T.map f ↔ S ≤ T :=\n(gci_map_comap hf).l_le_l_iff\n\n@[to_additive]\nlemma map_strict_mono_of_injective : strict_mono (map f) :=\n(gci_map_comap hf).strict_mono_l\n\nend galois_coinsertion\n\nsection galois_insertion\n\nvariables {ι : Type*} {f : M →ₙ* N} (hf : function.surjective f)\n\ninclude hf\n\n/-- `map f` and `comap f` form a `galois_insertion` when `f` is surjective. -/\n@[to_additive /-\" `map f` and `comap f` form a `galois_insertion` when `f` is surjective. \"-/]\ndef gi_map_comap : galois_insertion (map f) (comap f) :=\n(gc_map_comap f).to_galois_insertion\n  (λ S x h, let ⟨y, hy⟩ := hf x in mem_map.2 ⟨y, by simp [hy, h]⟩)\n\n@[to_additive]\nlemma map_comap_eq_of_surjective (S : subsemigroup N) : (S.comap f).map f = S :=\n(gi_map_comap hf).l_u_eq _\n\n@[to_additive]\nlemma map_surjective_of_surjective : function.surjective (map f) :=\n(gi_map_comap hf).l_surjective\n\n@[to_additive]\nlemma comap_injective_of_surjective : function.injective (comap f) :=\n(gi_map_comap hf).u_injective\n\n@[to_additive]\nlemma map_inf_comap_of_surjective (S T : subsemigroup N) : (S.comap f ⊓ T.comap f).map f = S ⊓ T :=\n(gi_map_comap hf).l_inf_u _ _\n\n@[to_additive]\nlemma map_infi_comap_of_surjective (S : ι → subsemigroup N) : (⨅ i, (S i).comap f).map f = infi S :=\n(gi_map_comap hf).l_infi_u _\n\n@[to_additive]\nlemma map_sup_comap_of_surjective (S T : subsemigroup N) : (S.comap f ⊔ T.comap f).map f = S ⊔ T :=\n(gi_map_comap hf).l_sup_u _ _\n\n@[to_additive]\nlemma map_supr_comap_of_surjective (S : ι → subsemigroup N) : (⨆ i, (S i).comap f).map f = supr S :=\n(gi_map_comap hf).l_supr_u _\n\n@[to_additive]\nlemma comap_le_comap_iff_of_surjective {S T : subsemigroup N} : S.comap f ≤ T.comap f ↔ S ≤ T :=\n(gi_map_comap hf).u_le_u_iff\n\n@[to_additive]\nlemma comap_strict_mono_of_surjective : strict_mono (comap f) :=\n(gi_map_comap hf).strict_mono_u\n\nend galois_insertion\n\nend subsemigroup\n\nnamespace mul_mem_class\n\nvariables {A : Type*} [has_mul M] [set_like A M] [hA : mul_mem_class A M] (S' : A)\ninclude hA\n\n/-- A submagma of a magma inherits a multiplication. -/\n@[to_additive \"An additive submagma of an additive magma inherits an addition.\",\npriority 900] -- lower priority so other instances are found first\ninstance has_mul : has_mul S' := ⟨λ a b, ⟨a.1 * b.1, mul_mem a.2 b.2⟩⟩\n\n@[simp, norm_cast, to_additive, priority 900]\n-- lower priority so later simp lemmas are used first; to appease simp_nf\nlemma coe_mul (x y : S') : (↑(x * y) : M) = ↑x * ↑y := rfl\n\n@[simp, to_additive, priority 900]\n-- lower priority so later simp lemmas are used first; to appease simp_nf\nlemma mk_mul_mk (x y : M) (hx : x ∈ S') (hy : y ∈ S') :\n  (⟨x, hx⟩ : S') * ⟨y, hy⟩ = ⟨x * y, mul_mem hx hy⟩ := rfl\n\n@[to_additive] lemma mul_def (x y : S') : x * y = ⟨x * y, mul_mem x.2 y.2⟩ := rfl\n\nomit hA\n\n/-- A subsemigroup of a semigroup inherits a semigroup structure. -/\n@[to_additive \"An `add_subsemigroup` of an `add_semigroup` inherits an `add_semigroup` structure.\"]\ninstance to_semigroup {M : Type*} [semigroup M] {A : Type*} [set_like A M] [mul_mem_class A M]\n  (S : A) : semigroup S :=\nsubtype.coe_injective.semigroup coe (λ _ _, rfl)\n\n/-- A subsemigroup of a `comm_semigroup` is a `comm_semigroup`. -/\n@[to_additive \"An `add_subsemigroup` of an `add_comm_semigroup` is an `add_comm_semigroup`.\"]\ninstance to_comm_semigroup {M} [comm_semigroup M] {A : Type*} [set_like A M] [mul_mem_class A M]\n  (S : A) : comm_semigroup S :=\nsubtype.coe_injective.comm_semigroup coe (λ _ _, rfl)\n\ninclude hA\n\n/-- The natural semigroup hom from a subsemigroup of semigroup `M` to `M`. -/\n@[to_additive \"The natural semigroup hom from an `add_subsemigroup` of `add_semigroup` `M` to `M`.\"]\ndef subtype : S' →ₙ* M := ⟨coe, λ _ _, rfl⟩\n\n@[simp, to_additive] \n\nend mul_mem_class\n\nnamespace subsemigroup\n\nvariables [has_mul M] [has_mul N] [has_mul P] (S : subsemigroup M)\n\n/-- The top subsemigroup is isomorphic to the semigroup. -/\n@[to_additive \"The top additive subsemigroup is isomorphic to the additive semigroup.\", simps]\ndef top_equiv : (⊤ : subsemigroup M) ≃* M :=\n{ to_fun    := λ x, x,\n  inv_fun   := λ x, ⟨x, mem_top x⟩,\n  left_inv  := λ x, x.eta _,\n  right_inv := λ _, rfl,\n  map_mul'  := λ _ _, rfl }\n\n@[simp, to_additive] lemma top_equiv_to_mul_hom :\n  (top_equiv : _ ≃* M).to_mul_hom = mul_mem_class.subtype (⊤ : subsemigroup M) :=\nrfl\n\n/-- A subsemigroup is isomorphic to its image under an injective function -/\n@[to_additive \"An additive subsemigroup is isomorphic to its image under an injective function\"]\nnoncomputable def equiv_map_of_injective\n  (f : M →ₙ* N) (hf : function.injective f) : S ≃* S.map f :=\n{ map_mul' := λ _ _, subtype.ext (map_mul f _ _), ..equiv.set.image f S hf }\n\n@[simp, to_additive] lemma coe_equiv_map_of_injective_apply\n  (f : M →ₙ* N) (hf : function.injective f) (x : S) :\n  (equiv_map_of_injective S f hf x : N) = f x := rfl\n\n@[simp, to_additive]\nlemma closure_closure_coe_preimage {s : set M} : closure ((coe : closure s → M) ⁻¹' s) = ⊤ :=\neq_top_iff.2 $ λ x, subtype.rec_on x $ λ x hx _, begin\n  refine closure_induction' _ (λ g hg, _) (λ g₁ g₂ hg₁ hg₂, _) hx,\n  { exact subset_closure hg },\n  { exact subsemigroup.mul_mem _ },\nend\n\n/-- Given `subsemigroup`s `s`, `t` of semigroups `M`, `N` respectively, `s × t` as a subsemigroup\nof `M × N`. -/\n@[to_additive prod \"Given `add_subsemigroup`s `s`, `t` of `add_semigroup`s `A`, `B` respectively,\n`s × t` as an `add_subsemigroup` of `A × B`.\"]\ndef prod (s : subsemigroup M) (t : subsemigroup N) : subsemigroup (M × N) :=\n{ carrier := (s : set M) ×ˢ (t : set N),\n  mul_mem' := λ p q hp hq, ⟨s.mul_mem hp.1 hq.1, t.mul_mem hp.2 hq.2⟩ }\n\n@[to_additive coe_prod]\nlemma coe_prod (s : subsemigroup M) (t : subsemigroup N) :\n (s.prod t : set (M × N)) = (s : set M) ×ˢ (t : set N) :=\nrfl\n\n@[to_additive mem_prod]\nlemma mem_prod {s : subsemigroup M} {t : subsemigroup N} {p : M × N} :\n  p ∈ s.prod t ↔ p.1 ∈ s ∧ p.2 ∈ t := iff.rfl\n\n@[to_additive prod_mono]\nlemma prod_mono {s₁ s₂ : subsemigroup M} {t₁ t₂ : subsemigroup N} (hs : s₁ ≤ s₂) (ht : t₁ ≤ t₂) :\n  s₁.prod t₁ ≤ s₂.prod t₂ :=\nset.prod_mono hs ht\n\n@[to_additive prod_top]\nlemma prod_top (s : subsemigroup M) :\n  s.prod (⊤ : subsemigroup N) = s.comap (mul_hom.fst M N) :=\next $ λ x, by simp [mem_prod, mul_hom.coe_fst]\n\n@[to_additive top_prod]\nlemma top_prod (s : subsemigroup N) :\n  (⊤ : subsemigroup M).prod s = s.comap (mul_hom.snd M N) :=\next $ λ x, by simp [mem_prod, mul_hom.coe_snd]\n\n@[simp, to_additive top_prod_top]\nlemma top_prod_top : (⊤ : subsemigroup M).prod (⊤ : subsemigroup N) = ⊤ :=\n(top_prod _).trans $ comap_top _\n\n@[to_additive] lemma bot_prod_bot : (⊥ : subsemigroup M).prod (⊥ : subsemigroup N) = ⊥ :=\nset_like.coe_injective $ by simp [coe_prod, prod.one_eq_mk]\n\n/-- The product of subsemigroups is isomorphic to their product as semigroups. -/\n@[to_additive prod_equiv \"The product of additive subsemigroups is isomorphic to their product\nas additive semigroups\"]\ndef prod_equiv (s : subsemigroup M) (t : subsemigroup N) : s.prod t ≃* s × t :=\n{ map_mul' := λ x y, rfl, .. equiv.set.prod ↑s ↑t }\n\nopen mul_hom\n\n@[to_additive]\nlemma mem_map_equiv {f : M ≃* N} {K : subsemigroup M} {x : N} :\n  x ∈ K.map f.to_mul_hom ↔ f.symm x ∈ K :=\n@set.mem_image_equiv _ _ ↑K f.to_equiv x\n\n@[to_additive]\nlemma map_equiv_eq_comap_symm (f : M ≃* N) (K : subsemigroup M) :\n  K.map f.to_mul_hom = K.comap f.symm.to_mul_hom :=\nset_like.coe_injective (f.to_equiv.image_eq_preimage K)\n\n@[to_additive]\nlemma comap_equiv_eq_map_symm (f : N ≃* M) (K : subsemigroup M) :\n  K.comap f.to_mul_hom = K.map f.symm.to_mul_hom :=\n(map_equiv_eq_comap_symm f.symm K).symm\n\n@[simp, to_additive]\nlemma map_equiv_top (f : M ≃* N) : (⊤ : subsemigroup M).map f.to_mul_hom = ⊤ :=\nset_like.coe_injective $ set.image_univ.trans f.surjective.range_eq\n\n@[to_additive le_prod_iff]\nlemma le_prod_iff {s : subsemigroup M} {t : subsemigroup N} {u : subsemigroup (M × N)} :\n  u ≤ s.prod t ↔ u.map (fst M N) ≤ s ∧ u.map (snd M N) ≤ t :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros x ⟨⟨y1,y2⟩, ⟨hy1,rfl⟩⟩, exact (h hy1).1 },\n    { rintros x ⟨⟨y1,y2⟩, ⟨hy1,rfl⟩⟩, exact (h hy1).2 }, },\n  { rintros ⟨hH, hK⟩ ⟨x1, x2⟩ h, exact ⟨hH ⟨_ , h, rfl⟩, hK ⟨ _, h, rfl⟩⟩, }\nend\n\nend subsemigroup\n\nnamespace mul_hom\n\nopen subsemigroup\n\nvariables [has_mul M] [has_mul N] [has_mul P] (S : subsemigroup M)\n\n/-- The range of a semigroup homomorphism is a subsemigroup. See Note [range copy pattern]. -/\n@[to_additive \"The range of an `add_hom` is an `add_subsemigroup`.\"]\ndef srange (f : M →ₙ* N) : subsemigroup N :=\n((⊤ : subsemigroup M).map f).copy (set.range f) set.image_univ.symm\n\n@[simp, to_additive]\nlemma coe_srange (f : M →ₙ* N) :\n  (f.srange : set N) = set.range f :=\nrfl\n\n@[simp, to_additive] lemma mem_srange {f : M →ₙ* N} {y : N} :\n  y ∈ f.srange ↔ ∃ x, f x = y :=\niff.rfl\n\n@[to_additive] lemma srange_eq_map (f : M →ₙ* N) : f.srange = (⊤ : subsemigroup M).map f :=\ncopy_eq _\n\n@[to_additive]\nlemma map_srange (g : N →ₙ* P) (f : M →ₙ* N) : f.srange.map g = (g.comp f).srange :=\nby simpa only [srange_eq_map] using (⊤ : subsemigroup M).map_map g f\n\n@[to_additive]\nlemma srange_top_iff_surjective {N} [has_mul N] {f : M →ₙ* N} :\n  f.srange = (⊤ : subsemigroup N) ↔ function.surjective f :=\nset_like.ext'_iff.trans $ iff.trans (by rw [coe_srange, coe_top]) set.range_iff_surjective\n\n/-- The range of a surjective semigroup hom is the whole of the codomain. -/\n@[to_additive \"The range of a surjective `add_semigroup` hom is the whole of the codomain.\"]\nlemma srange_top_of_surjective {N} [has_mul N] (f : M →ₙ* N) (hf : function.surjective f) :\n  f.srange = (⊤ : subsemigroup N) :=\nsrange_top_iff_surjective.2 hf\n\n@[to_additive]\nlemma mclosure_preimage_le (f : M →ₙ* N) (s : set N) :\n  closure (f ⁻¹' s) ≤ (closure s).comap f :=\nclosure_le.2 $ λ x hx, set_like.mem_coe.2 $ mem_comap.2 $ subset_closure hx\n\n/-- The image under a semigroup hom of the subsemigroup generated by a set equals the subsemigroup\ngenerated by the image of the set. -/\n@[to_additive \"The image under an `add_semigroup` hom of the `add_subsemigroup` generated by a set\nequals the `add_subsemigroup` generated by the image of the set.\"]\nlemma map_mclosure (f : M →ₙ* N) (s : set M) :\n  (closure s).map f = closure (f '' s) :=\nle_antisymm\n  (map_le_iff_le_comap.2 $ le_trans (closure_mono $ set.subset_preimage_image _ _)\n    (mclosure_preimage_le _ _))\n  (closure_le.2 $ set.image_subset _ subset_closure)\n\n/-- Restriction of a semigroup hom to a subsemigroup of the domain. -/\n@[to_additive \"Restriction of an add_semigroup hom to an `add_subsemigroup` of the domain.\"]\ndef restrict {N : Type*} [has_mul N] [set_like σ M] [mul_mem_class σ M] (f : M →ₙ* N) (S : σ) :\n  S →ₙ* N :=\nf.comp (mul_mem_class.subtype S)\n\n@[simp, to_additive]\nlemma restrict_apply {N : Type*} [has_mul N] [set_like σ M] [mul_mem_class σ M] (f : M →ₙ* N)\n  {S : σ} (x : S) : f.restrict S x = f x :=\nrfl\n\n/-- Restriction of a semigroup hom to a subsemigroup of the codomain. -/\n@[to_additive \"Restriction of an `add_semigroup` hom to an `add_subsemigroup` of the\ncodomain.\", simps]\ndef cod_restrict [set_like σ N] [mul_mem_class σ N] (f : M →ₙ* N) (S : σ) (h : ∀ x, f x ∈ S) :\n  M →ₙ* S :=\n{ to_fun := λ n, ⟨f n, h n⟩,\n  map_mul' := λ x y, subtype.eq (map_mul f x y) }\n\n/-- Restriction of a semigroup hom to its range interpreted as a subsemigroup. -/\n@[to_additive \"Restriction of an `add_semigroup` hom to its range interpreted as a subsemigroup.\"]\ndef srange_restrict {N} [has_mul N] (f : M →ₙ* N) : M →ₙ* f.srange :=\nf.cod_restrict f.srange $ λ x, ⟨x, rfl⟩\n\n@[simp, to_additive]\nlemma coe_srange_restrict {N} [has_mul N] (f : M →ₙ* N) (x : M) :\n  (f.srange_restrict x : N) = f x :=\nrfl\n\n@[to_additive]\nlemma srange_restrict_surjective (f : M →ₙ* N) : function.surjective f.srange_restrict :=\nλ ⟨_, ⟨x, rfl⟩⟩, ⟨x, rfl⟩\n\n@[to_additive]\nlemma prod_map_comap_prod' {M' : Type*} {N' : Type*} [has_mul M'] [has_mul N']\n  (f : M →ₙ* N) (g : M' →ₙ* N') (S : subsemigroup N) (S' : subsemigroup N') :\n  (S.prod S').comap (prod_map f g) = (S.comap f).prod (S'.comap g) :=\nset_like.coe_injective $ set.preimage_prod_map_prod f g _ _\n\n/-- The `mul_hom` from the preimage of a subsemigroup to itself. -/\n@[to_additive \"the `add_hom` from the preimage of an additive subsemigroup to itself.\", simps]\ndef subsemigroup_comap (f : M →ₙ* N) (N' : subsemigroup N) :\n  N'.comap f →ₙ* N' :=\n{ to_fun := λ x, ⟨f x, x.prop⟩,\n  map_mul' := λ x y, subtype.eq (@map_mul M N _ _ _ _ f x y) }\n\n/-- The `mul_hom` from a subsemigroup to its image.\nSee `mul_equiv.subsemigroup_map` for a variant for `mul_equiv`s. -/\n@[to_additive \"the `add_hom` from an additive subsemigroup to its image. See\n`add_equiv.add_subsemigroup_map` for a variant for `add_equiv`s.\", simps]\ndef subsemigroup_map (f : M →ₙ* N) (M' : subsemigroup M) :\n  M' →ₙ* M'.map f :=\n{ to_fun := λ x, ⟨f x, ⟨x, x.prop, rfl⟩⟩,\n  map_mul' := λ x y, subtype.eq $ @map_mul M N _ _ _ _ f x y }\n\n@[to_additive]\nlemma subsemigroup_map_surjective (f : M →ₙ* N) (M' : subsemigroup M) :\n  function.surjective (f.subsemigroup_map M') :=\nby { rintro ⟨_, x, hx, rfl⟩, exact ⟨⟨x, hx⟩, rfl⟩ }\n\nend mul_hom\n\nnamespace subsemigroup\nopen mul_hom\n\nvariables [has_mul M] [has_mul N] [has_mul P] (S : subsemigroup M)\n\n@[simp, to_additive]\nlemma srange_fst [nonempty N] : (fst M N).srange = ⊤ :=\n(fst M N).srange_top_of_surjective $ prod.fst_surjective\n\n@[simp, to_additive]\nlemma srange_snd [nonempty M] : (snd M N).srange = ⊤ :=\n(snd M N).srange_top_of_surjective $ prod.snd_surjective\n\n@[to_additive]\nlemma prod_eq_top_iff [nonempty M] [nonempty N] {s : subsemigroup M} {t : subsemigroup N} :\n  s.prod t = ⊤ ↔ s = ⊤ ∧ t = ⊤ :=\nby simp only [eq_top_iff, le_prod_iff, ← (gc_map_comap _).le_iff_le, ← srange_eq_map,\n  srange_fst, srange_snd]\n\n/-- The semigroup hom associated to an inclusion of subsemigroups. -/\n@[to_additive \"The `add_semigroup` hom associated to an inclusion of subsemigroups.\"]\ndef inclusion {S T : subsemigroup M} (h : S ≤ T) : S →ₙ* T :=\n(mul_mem_class.subtype S).cod_restrict _ (λ x, h x.2)\n\n@[simp, to_additive]\nlemma range_subtype (s : subsemigroup M) : (mul_mem_class.subtype s).srange = s :=\nset_like.coe_injective $ (coe_srange _).trans $ subtype.range_coe\n\n@[to_additive] lemma eq_top_iff' : S = ⊤ ↔ ∀ x : M, x ∈ S :=\neq_top_iff.trans ⟨λ h m, h $ mem_top m, λ h m _, h m⟩\n\nend subsemigroup\n\nnamespace mul_equiv\n\nvariables [has_mul M] [has_mul N] {S T : subsemigroup M}\n\n/-- Makes the identity isomorphism from a proof that two subsemigroups of a multiplicative\n    semigroup are equal. -/\n@[to_additive \"Makes the identity additive isomorphism from a proof two\nsubsemigroups of an additive semigroup are equal.\"]\ndef subsemigroup_congr (h : S = T) : S ≃* T :=\n{ map_mul' :=  λ _ _, rfl, ..equiv.set_congr $ congr_arg _ h }\n\n-- this name is primed so that the version to `f.range` instead of `f.srange` can be unprimed.\n/-- A semigroup homomorphism `f : M →ₙ* N` with a left-inverse `g : N → M` defines a multiplicative\nequivalence between `M` and `f.srange`.\n\nThis is a bidirectional version of `mul_hom.srange_restrict`. -/\n@[to_additive /-\"\nAn additive semigroup homomorphism `f : M →+ N` with a left-inverse `g : N → M` defines an additive\nequivalence between `M` and `f.srange`.\n\nThis is a bidirectional version of `add_hom.srange_restrict`. \"-/, simps {simp_rhs := tt}]\ndef of_left_inverse (f : M →ₙ* N) {g : N → M} (h : function.left_inverse g f) : M ≃* f.srange :=\n{ to_fun := f.srange_restrict,\n  inv_fun := g ∘ (mul_mem_class.subtype f.srange),\n  left_inv := h,\n  right_inv := λ x, subtype.ext $\n    let ⟨x', hx'⟩ := mul_hom.mem_srange.mp x.prop in\n    show f (g x) = x, by rw [←hx', h x'],\n  .. f.srange_restrict }\n\n/-- A `mul_equiv` `φ` between two semigroups `M` and `N` induces a `mul_equiv` between\na subsemigroup `S ≤ M` and the subsemigroup `φ(S) ≤ N`.\nSee `mul_hom.subsemigroup_map` for a variant for `mul_hom`s. -/\n@[to_additive \"An `add_equiv` `φ` between two additive semigroups `M` and `N` induces an `add_equiv`\nbetween a subsemigroup `S ≤ M` and the subsemigroup `φ(S) ≤ N`. See `add_hom.add_subsemigroup_map`\nfor a variant for `add_hom`s.\", simps]\ndef subsemigroup_map (e : M ≃* N) (S : subsemigroup M) : S ≃* S.map e.to_mul_hom :=\n{ to_fun := λ x, ⟨e x, _⟩,\n  inv_fun := λ x, ⟨e.symm x, _⟩, -- we restate this for `simps` to avoid `⇑e.symm.to_equiv x`\n  ..e.to_mul_hom.subsemigroup_map S,\n  ..e.to_equiv.image S }\n\nend mul_equiv\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/group_theory/subsemigroup/operations.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7185944046238981, "lm_q1q2_score": 0.46293655683934015}}
{"text": "/-\nCopyright (c) 2021 James Gallicchio.\n\nAuthors: James Gallicchio\n-/\n\nimport LeanColls.AuxLemmas\n\n/-!\n# Finger Trees\n\nTODO: Describe\n\n## References\n\nSee [Matthieu2007], section 4\n\n-/\n\ninductive Digit (τ : Type u) (msr : τ → M) [Monoid M]\n| Digit1 : (a : τ) →\n            Cached (msr a) → Digit τ msr\n| Digit2 : (a : τ) → (b : τ) →\n            Cached (msr a ++ msr b) → Digit τ msr\n| Digit3 : (a : τ) → (b : τ) → (c : τ) →\n            Cached (msr a ++ msr b ++ msr c) → Digit τ msr\n| Digit4 : (a : τ) → (b : τ) → (c : τ) → (d : τ) →\n            Cached (msr a ++ msr b ++ msr c ++ msr d) → Digit τ msr\n\nnamespace Digit\nvariable {msr : τ → M} [Monoid M] (d : Digit τ msr)\n\n@[inline]\ndef tryAddLeft (a : τ) (av : Cached (msr a)) (sc : Digit τ msr → α) (fc : τ → τ → τ → τ → α) : α :=\n  match d with\n  | Digit1 b       v => sc (Digit2 a b ⟨av.1 ++ v.1,by simp [av.2]⟩)\n  | Digit2 b c     v => sc (Digit3 a b c ⟨av.1 ++ v.1,by simp [av.2]⟩)\n  | Digit3 b c d   v => sc (Digit4 a b c d ⟨av.1 ++ v.1,by simp [av.2]⟩)\n  | Digit4 b c d e _ => fc b c d e\n\n@[inline]\ndef tryFront (sc : τ → Digit τ msr → α) (fc : (a : τ) → Cached (msr a) → α) : α :=\n  match d with\n  | Digit1 a       v => fc a v\n  | Digit2 a b     _ => sc a (Digit1 b (cached (msr b)))\n  | Digit3 a b c   _ => sc a (Digit2 b c (cached (msr b ++ msr c)))\n  | Digit4 a b c d _ => sc a (Digit3 b c d (cached (msr b ++ msr c ++ msr d)))\n\n@[inline]\ndef tryAddRight (z : τ) (zv : Cached (msr z)) (sc : Digit τ msr → α) (fc : τ → τ → τ → τ → α) : α :=\n  match h':d with\n  | Digit1 y       v => sc (Digit2 y z ⟨v.1 ++ zv.1,by simp [zv.2]⟩)\n  | Digit2 x y     v => sc (Digit3 x y z ⟨v.1 ++ zv.1,by simp [zv.2]⟩)\n  | Digit3 w x y   v => sc (Digit4 w x y z ⟨v.1 ++ zv.1,by simp [zv.2]⟩)\n  | Digit4 v w x y _ => fc v w x y\n\n@[inline]\ndef tryBack (sc : τ → Digit τ msr → α) (fc : (a : τ) → Cached (msr a) → α) : α :=\n  match d with\n  | Digit1 z       v => fc z v\n  | Digit2 y z     v => sc z (Digit1 y (cached (msr y)))\n  | Digit3 x y z   v => sc z (Digit2 x y (cached (msr x ++ msr y)))\n  | Digit4 w x y z v => sc z (Digit3 w x y (cached (msr w ++ msr x ++ msr y)))\n\ndef toList : Digit τ msr → List τ\n| Digit1 a       _ => [a]\n| Digit2 a b     _ => [a,b]\n| Digit3 a b c   _ => [a,b,c]\n| Digit4 a b c d _ => [a,b,c,d]\n\n\nend Digit\n\nopen Digit\n\n\ninductive Node (τ : Type u) (msr : τ → M) [Monoid M]\n| Node2 : (a : τ) → (b : τ) →\n          Cached (msr a ++ msr b) → Node τ msr\n| Node3 : (a : τ) → (b : τ) → (c : τ) →\n          Cached (msr a ++ msr b ++ msr c) → Node τ msr\n\nnamespace Node\n\ndef toDigit {msr : τ → M} [Monoid M] : Node τ msr → Digit τ msr\n| Node2 a b   => Digit.Digit2 a b (cached (msr a ++ msr b))\n| Node3 a b c => Digit.Digit3 a b c (cached (msr a ++ msr b ++ msr c))\n\ndef toList {msr : τ → M} [Monoid M] : Node τ msr → List τ\n| Node2 a b   => [a,b]\n| Node3 a b c => [a,b,c]\n\nend  Node\n\nopen Node\n\n\ninductive FingerTree [Monoid M] : (τ : Type u) → (msr : τ → M) → Type (u+3000)\n| Empty : FingerTree τ msr\n| Single : (t : τ) → FingerTree τ msr \n| Deep : Digit τ msr → FingerTree (Node τ) msr → Digit τ msr → FingerTree τ msr\n\nnamespace FingerTree\n\ndef toList : FingerTree τ → List τ\n| Empty => []\n| Single x => [x]\n| Deep pr tr sf => pr.toList ++ (tr.toList.bind Node.toList) ++ sf.toList\n\n@[inline]\ndef cons (f : FingerTree τ) (a : τ) : FingerTree τ :=\n  match f with\n  | Empty => Single a\n  | Single b => Deep (Digit1 a) Empty (Digit1 b)\n  | Deep pr tr sf =>\n    tryAddLeft pr a\n      (λ pr' => Deep pr' tr sf)\n      (λ b c d e => Deep (Digit2 a b) (tr.cons (Node3 c d e)) sf)\n\n@[inline]\ndef front? (f : FingerTree τ) : Option (τ × FingerTree τ) :=\n  match f with\n  | Empty         => none\n  | Single a      => some (a, Empty)\n  | Deep pr tr sf => some (\n    tryFront pr\n      (λ a pr' => (a, Deep pr' tr sf))\n      (λ a => /- pr = Digit1 a -/ (a,\n        match front? tr with\n        | some (n, tr') => Deep n.toDigit tr' sf\n        | none => /- tr empty -/\n          tryFront sf\n            (λ b sf' => Deep (Digit1 b) Empty sf')\n            (λ b => /- sf = Digit1 b -/\n              Single b))))\n\ntheorem toList_cons (f : FingerTree τ) (a : τ)\n  : (f.cons a).toList = a :: f.toList\n  := by\n  induction f\n  simp [cons, toList]\n  simp [cons, toList, Digit.toList, List.bind, List.map, List.join]\n  case Deep pr tr sf ih =>\n  simp [cons, tryAddLeft]\n  split\n  simp [toList, Digit.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, List.bind, List.map, List.join]\n  case h_4 b c d e =>\n  simp [toList, Digit.toList, List.bind, List.map, List.join, ih]\n  split\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join]\n\ntheorem toList_front (f : FingerTree τ)\n  : f.front?.map (λ (a,f') => (a,f'.toList)) = f.toList.front?\n  := by\n  induction f\n  simp [front?, toList, List.front?, Option.map, Option.bind]\n  simp [front?, toList, List.front?, Option.map, Option.bind]\n  case Deep pr tr sf ih =>\n  match pr with\n  | Digit2 a b     => simp [front?, toList, List.front?, tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append]\n  | Digit3 a b c   => simp [front?, toList, List.front?, tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append]\n  | Digit4 a b c d => simp [front?, toList, List.front?, tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append]\n  | Digit1 a =>\n    match h:front? tr with\n    | some (t,tr') =>\n      rw [h] at ih\n      simp [Option.map, Option.bind, List.front?] at ih\n      split at ih\n      contradiction\n      case h_2 h_tr x =>\n      cases x\n      simp [h,h_tr,front?, toList, List.front?, tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append, List.bind, List.map, List.join]\n      cases t\n      repeat {simp [Digit.toList, Node.toDigit, Node.toList]}\n    | none =>\n      rw [h] at ih\n      simp [Option.map, Option.bind, List.front?] at ih\n      split at ih\n      focus {\n        case h_1 h_tr x =>\n        simp [h,h_tr,front?, toList, List.front?, tryFront, Option.map, Option.bind, HAppend.hAppend, Append.append, List.append, List.bind, List.map, List.join]\n        split\n        simp [Digit.toList, toList, List.bind, List.join, List.map]\n        simp [Digit.toList, toList, List.bind, List.join, List.map]\n        simp [Digit.toList, toList, List.bind, List.join, List.map]\n        simp [Digit.toList, toList, List.bind, List.join, List.map]\n      }\n      contradiction\n\ndef snoc (f : FingerTree τ) (z : τ) : FingerTree τ :=\n  match f with\n  | Empty => Single z\n  | Single b => Deep (Digit1 b) Empty (Digit1 z)\n  | Deep pr tr sf =>\n    tryAddRight sf z\n      (λ sf' => Deep pr tr sf')\n      (λ a b c d => Deep pr (tr.snoc (Node3 a b c)) (Digit2 d z))\n\ndef back? (f : FingerTree τ) : Option (FingerTree τ × τ) :=\n  match f with\n  | Empty         => none\n  | Single z      => some (Empty, z)\n  | Deep pr tr sf => some (\n    tryBack pr\n      (λ z sf' => (Deep pr tr sf', z))\n      (λ z => /- sf = Digit1 z -/ (\n        match back? tr with\n        | some (tr', n) => Deep pr tr' n.toDigit\n        | none => /- tr empty -/\n          tryBack pr\n            (λ y pr' => Deep pr' Empty (Digit1 y))\n            (λ y => /- pr = Digit1 y -/\n              Single y),\n        z)))\n\ntheorem toList_snoc (f : FingerTree τ) (a : τ)\n  : (f.snoc a).toList = f.toList.concat a\n  := by\n  induction f\n  simp [snoc, toList, List.concat]\n  simp [snoc, toList, Digit.toList, List.bind, List.map, List.join, List.concat]\n  case Deep pr tr sf ih =>\n  simp [snoc, tryAddRight]\n  split\n  simp [toList, Digit.toList, List.bind, List.map, List.join, List.concat_append, List.concat]\n  simp [toList, Digit.toList, List.bind, List.map, List.join, List.concat_append, List.concat]\n  simp [toList, Digit.toList, List.bind, List.map, List.join, List.concat_append, List.concat]\n  case h_4 b c d e =>\n  simp [toList, Digit.toList, List.bind, List.map, List.join, ih, List.concat_append, List.concat]\n  split\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join, List.concat_append, List.concat, List.map_concat, List.join_concat, List.append_assoc]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join, List.concat_append, List.concat, List.map_concat, List.join_concat, List.append_assoc]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join, List.concat_append, List.concat, List.map_concat, List.join_concat, List.append_assoc]\n  simp [toList, Digit.toList, Node.toList, List.bind, List.map, List.join, List.concat_append, List.concat, List.map_concat, List.join_concat, List.append_assoc]\n\ntheorem toList_back (f : FingerTree τ)\n  : f.back?.map (λ (f',a) => (f'.toList,a)) = f.toList.back?\n  := by sorry\n\n\ndef append (f1 f2 : FingerTree τ) : FingerTree τ :=\n  match f1, f2 with\n  | f1, Empty => f1\n  | Empty, f2 => f2\n  | f1, Single z => f1.snoc z\n  | Single a, f1 => f1.cons a\n  | Deep pr1 tr1 sf1, Deep pr2 tr2 sf2 =>\n    let tr' := match sf1, pr2 with\n    | Digit1 a, Digit1 b => (tr1.snoc (Node2 a b)).append tr2\n    | Digit2 a b, Digit1 c => (tr1.snoc (Node3 a b c)).append tr2\n    | Digit1 a, Digit2 b c => tr1.append (tr2.cons (Node3 a b c))\n    | Digit3 a b c, Digit1 d => (tr1.snoc (Node2 a b)).append (tr2.cons (Node2 c d))\n    | Digit2 a b, Digit2 c d => (tr1.snoc (Node2 a b)).append (tr2.cons (Node2 c d))\n    | Digit1 a, Digit3 b c d => (tr1.snoc (Node2 a b)).append (tr2.cons (Node2 c d))\n    | Digit4 a b c d, Digit1 e => (tr1.snoc (Node3 a b c)).append (tr2.cons (Node2 d e))\n    | Digit3 a b c, Digit2 d e => (tr1.snoc (Node3 a b c)).append (tr2.cons (Node2 d e))\n    | Digit2 a b, Digit3 c d e => (tr1.snoc (Node2 a b)).append (tr2.cons (Node3 c d e))\n    | Digit1 a, Digit4 b c d e => (tr1.snoc (Node2 a b)).append (tr2.cons (Node3 c d e))\n    | Digit4 a b c d, Digit2 e f => (tr1.snoc (Node3 a b c)).append (tr2.cons (Node3 d e f))\n    | Digit3 a b c, Digit3 d e f => (tr1.snoc (Node3 a b c)).append (tr2.cons (Node3 d e f))\n    | Digit2 a b, Digit4 c d e f => (tr1.snoc (Node3 a b c)).append (tr2.cons (Node3 d e f))\n    | Digit4 a b c d, Digit3 e f g => (tr1.snoc (Node3 a b c)).append ((tr2.cons (Node2 f g)).cons (Node2 d e))\n    | Digit3 a b c, Digit4 d e f g => ((tr1.snoc (Node2 a b)).snoc (Node2 c d)).append (tr2.cons (Node3 e f g))\n    | Digit4 a b c d, Digit4 e f g h => (tr1.snoc (Node3 a b c)).append ((tr2.cons (Node3 f g h)).cons (Node2 d e))\n\n    Deep pr1 tr' sf2\n\nend FingerTree", "meta": {"author": "JamesGallicchio", "repo": "LeanColls", "sha": "9cb0a0c9a838bea24be80eace168bcc5f9481596", "save_path": "github-repos/lean/JamesGallicchio-LeanColls", "path": "github-repos/lean/JamesGallicchio-LeanColls/LeanColls-9cb0a0c9a838bea24be80eace168bcc5f9481596/LeanColls/FingerTree/AugFingerTree.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4628525020014989}}
{"text": "/-\nCopyright (c) 2021 Alena Gusakov, Bhavik Mehta, Kyle Miller. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alena Gusakov, Bhavik Mehta, Kyle Miller\n-/\nimport data.fintype.basic\nimport data.set.finite\n\n/-!\n# Hall's Marriage Theorem for finite index types\n\nThis module proves the basic form of Hall's theorem.\nIn constrast to the theorem described in `combinatorics.hall.basic`, this\nversion requires that the indexed family `t : ι → finset α` have `ι` be a `fintype`.\nThe `combinatorics.hall.basic` module applies a compactness argument to this version\nto remove the `fintype` constraint on `ι`.\n\nThe modules are split like this since the generalized statement\ndepends on the topology and category theory libraries, but the finite\ncase in this module has few dependencies.\n\nA description of this formalization is in [Gusakov2021].\n\n## Main statements\n\n* `finset.all_card_le_bUnion_card_iff_exists_injective'` is Hall's theorem with\n  a finite index set.  This is elsewhere generalized to\n  `finset.all_card_le_bUnion_card_iff_exists_injective`.\n\n## Tags\n\nHall's Marriage Theorem, indexed families\n-/\n\nopen finset\n\nuniverses u v\n\nnamespace hall_marriage_theorem\n\nvariables {ι : Type u} {α : Type v} [fintype ι]\n\ntheorem hall_hard_inductive_zero (t : ι → finset α) (hn : fintype.card ι = 0) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  rw fintype.card_eq_zero_iff at hn,\n  exactI ⟨is_empty_elim, is_empty_elim, is_empty_elim⟩,\nend\n\nvariables {t : ι → finset α} [decidable_eq α]\n\nlemma hall_cond_of_erase {x : ι} (a : α)\n  (ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card)\n  (s' : finset {x' : ι | x' ≠ x}) :\n  s'.card ≤ (s'.bUnion (λ x', (t x').erase a)).card :=\nbegin\n  haveI := classical.dec_eq ι,\n  specialize ha (s'.image coe),\n  rw [nonempty.image_iff, finset.card_image_of_injective s' subtype.coe_injective] at ha,\n  by_cases he : s'.nonempty,\n  { have ha' : s'.card < (s'.bUnion (λ x, t x)).card,\n    { specialize ha he (λ h, by { have h' := mem_univ x, rw ←h at h', simpa using h' }),\n      convert ha using 2,\n      ext x,\n      simp only [mem_image, mem_bUnion, exists_prop, set_coe.exists,\n                 exists_and_distrib_right, exists_eq_right, subtype.coe_mk], },\n    rw ←erase_bUnion,\n    by_cases hb : a ∈ s'.bUnion (λ x, t x),\n    { rw card_erase_of_mem hb,\n      exact nat.le_pred_of_lt ha' },\n    { rw erase_eq_of_not_mem hb,\n      exact nat.le_of_lt ha' }, },\n  { rw [nonempty_iff_ne_empty, not_not] at he,\n    subst s',\n    simp },\nend\n\n/--\nFirst case of the inductive step: assuming that\n`∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_A {n : ℕ} (hn : fintype.card ι = n + 1)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),\n        by exactI fintype.card ι' ≤ n →\n                  (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                  ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)\n  (ha : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  haveI : nonempty ι := fintype.card_pos_iff.mp (hn.symm ▸ nat.succ_pos _),\n  haveI := classical.dec_eq ι,\n  /- Choose an arbitrary element `x : ι` and `y : t x`. -/\n  let x := classical.arbitrary ι,\n  have tx_ne : (t x).nonempty,\n  { rw ←finset.card_pos,\n    apply nat.lt_of_lt_of_le nat.one_pos,\n    convert ht {x},\n    rw finset.singleton_bUnion, },\n  rcases classical.indefinite_description _ tx_ne with ⟨y, hy⟩,\n  /- Restrict to everything except `x` and `y`. -/\n  let ι' := {x' : ι | x' ≠ x},\n  let t' : ι' → finset α := λ x', (t x').erase y,\n  have card_ι' : fintype.card ι' = n,\n  { convert congr_arg (λ m, m - 1) hn,\n    convert set.card_ne_eq _, },\n  rcases ih t' card_ι'.le (hall_cond_of_erase y ha) with ⟨f', hfinj, hfr⟩,\n  /- Extend the resulting function. -/\n  refine ⟨λ z, if h : z = x then y else f' ⟨z, h⟩, _, _⟩,\n  { rintro z₁ z₂,\n    have key : ∀ {x}, y ≠ f' x,\n    { intros x h,\n      specialize hfr x,\n      rw ←h at hfr,\n      simpa using hfr, },\n    by_cases h₁ : z₁ = x; by_cases h₂ : z₂ = x; simp [h₁, h₂, hfinj.eq_iff, key, key.symm], },\n  { intro z,\n    split_ifs with hz,\n    { rwa hz },\n    { specialize hfr ⟨z, hz⟩,\n      rw mem_erase at hfr,\n      exact hfr.2, }, },\nend\n\nlemma hall_cond_of_restrict {ι : Type u} {t : ι → finset α} {s : finset ι}\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (s' : finset (s : set ι)) :\n  s'.card ≤ (s'.bUnion (λ a', t a')).card :=\nbegin\n  haveI := classical.dec_eq ι,\n  convert ht (s'.image coe) using 1,\n  { rw card_image_of_injective _ subtype.coe_injective, },\n  { apply congr_arg,\n    ext y,\n    simp, },\nend\n\nlemma hall_cond_of_compl {ι : Type u} {t : ι → finset α} {s : finset ι}\n  (hus : s.card = (s.bUnion t).card)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (s' : finset (sᶜ : set ι)) :\n  s'.card ≤ (s'.bUnion (λ x', t x' \\ s.bUnion t)).card :=\nbegin\n  haveI := classical.dec_eq ι,\n  have : s'.card = (s ∪ s'.image coe).card - s.card,\n  { rw [card_disjoint_union, add_tsub_cancel_left,\n        card_image_of_injective _ subtype.coe_injective],\n    simp only [disjoint_left, not_exists, mem_image, exists_prop, set_coe.exists,\n               exists_and_distrib_right, exists_eq_right, subtype.coe_mk],\n    intros x hx hc h,\n    exact (hc hx).elim },\n  rw [this, hus],\n  apply (tsub_le_tsub_right (ht _) _).trans _,\n  rw ← card_sdiff,\n  { have : (s ∪ s'.image subtype.val).bUnion t \\ s.bUnion t ⊆ s'.bUnion (λ x', t x' \\ s.bUnion t),\n    { intros t,\n      simp only [mem_bUnion, mem_sdiff, not_exists, mem_image, and_imp, mem_union,\n                 exists_and_distrib_right, exists_imp_distrib],\n      rintro x (hx | ⟨x', hx', rfl⟩) rat hs,\n      { exact (hs x hx rat).elim },\n      { exact ⟨⟨x', hx', rat⟩, hs⟩, } },\n    exact (card_le_of_subset this).trans le_rfl, },\n  { apply bUnion_subset_bUnion_of_subset_left,\n    apply subset_union_left }\nend\n\n/--\nSecond case of the inductive step: assuming that\n`∃ (s : finset ι), s ≠ univ → s.card = (s.bUnion t).card`\nand that the statement of Hall's Marriage Theorem is true for all\n`ι'` of cardinality ≤ `n`, then it is true for `ι` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_B {n : ℕ} (hn : fintype.card ι = n + 1)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),\n        by exactI fintype.card ι' ≤ n →\n                  (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                  ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x)\n  (s : finset ι)\n  (hs : s.nonempty)\n  (hns : s ≠ univ)\n  (hus : s.card = (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  haveI := classical.dec_eq ι,\n  /- Restrict to `s` -/\n  let t' : s → finset α := λ x', t x',\n  rw nat.add_one at hn,\n  have card_ι'_le : fintype.card s ≤ n,\n  { apply nat.le_of_lt_succ,\n    rw ←hn,\n    convert (card_lt_iff_ne_univ _).mpr hns,\n    convert fintype.card_coe _ },\n  rcases ih t' card_ι'_le (hall_cond_of_restrict ht) with ⟨f', hf', hsf'⟩,\n  /- Restrict to `sᶜ` in the domain and `(s.bUnion t)ᶜ` in the codomain. -/\n  set ι'' := (s : set ι)ᶜ with ι''_def,\n  let t'' : ι'' → finset α := λ a'', t a'' \\ s.bUnion t,\n  have card_ι''_le : fintype.card ι'' ≤ n,\n  { apply nat.le_of_lt_succ,\n    rw ←hn,\n    convert (card_compl_lt_iff_nonempty _).mpr hs,\n    convert fintype.card_coe (sᶜ),\n    exact (finset.coe_compl s).symm },\n  rcases ih t'' card_ι''_le (hall_cond_of_compl hus ht) with ⟨f'', hf'', hsf''⟩,\n  /- Put them together -/\n  have f'_mem_bUnion : ∀ {x'} (hx' : x' ∈ s), f' ⟨x', hx'⟩ ∈ s.bUnion t,\n  { intros x' hx',\n    rw mem_bUnion,\n    exact ⟨x', hx', hsf' _⟩, },\n  have f''_not_mem_bUnion : ∀ {x''} (hx'' : ¬ x'' ∈ s), ¬ f'' ⟨x'', hx''⟩ ∈ s.bUnion t,\n  { intros x'' hx'',\n    have h := hsf'' ⟨x'', hx''⟩,\n    rw mem_sdiff at h,\n    exact h.2, },\n  have im_disj : ∀ {x' x'' : ι} {hx' : x' ∈ s} {hx'' : ¬x'' ∈ s}, f' ⟨x', hx'⟩ ≠ f'' ⟨x'', hx''⟩,\n  { intros _ _ hx' hx'' h,\n    apply f''_not_mem_bUnion hx'',\n    rw ←h,\n    apply f'_mem_bUnion, },\n  refine ⟨λ x, if h : x ∈ s then f' ⟨x, h⟩ else f'' ⟨x, h⟩, _, _⟩,\n  { exact hf'.dite _ hf'' @im_disj },\n  { intro x,\n    split_ifs,\n    { exact hsf' ⟨x, h⟩ },\n    { exact sdiff_subset _ _ (hsf'' ⟨x, h⟩) } }\nend\n\n/--\nIf `ι` has cardinality `n + 1` and the statement of Hall's Marriage Theorem\nis true for all `ι'` of cardinality ≤ `n`, then it is true for `ι`.\n-/\ntheorem hall_hard_inductive_step {n : ℕ} (hn : fintype.card ι = n + 1)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card)\n  (ih : ∀ {ι' : Type u} [fintype ι'] (t' : ι' → finset α),\n        by exactI fintype.card ι' ≤ n →\n                  (∀ (s' : finset ι'), s'.card ≤ (s'.bUnion t').card) →\n                  ∃ (f : ι' → α), function.injective f ∧ ∀ x, f x ∈ t' x) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  by_cases h : ∀ (s : finset ι), s.nonempty → s ≠ univ → s.card < (s.bUnion t).card,\n  { exact hall_hard_inductive_step_A hn ht @ih h, },\n  { push_neg at h,\n    rcases h with ⟨s, sne, snu, sle⟩,\n    have seq := nat.le_antisymm (ht _) sle,\n    exact hall_hard_inductive_step_B hn ht @ih s sne snu seq, },\nend\n\n/--\nHere we combine the base case and the inductive step into\na full strong induction proof, thus completing the proof\nof the second direction.\n-/\ntheorem hall_hard_inductive {n : ℕ} (hn : fintype.card ι = n)\n  (ht : ∀ (s : finset ι), s.card ≤ (s.bUnion t).card) :\n  ∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x :=\nbegin\n  tactic.unfreeze_local_instances,\n  revert ι,\n  refine nat.strong_induction_on n (λ n' ih, _),\n  intros _ _ t hn ht,\n  rcases n' with (_|_),\n  { exact hall_hard_inductive_zero t hn },\n  { apply hall_hard_inductive_step hn ht,\n    introsI ι' _ _ hι',\n    exact ih (fintype.card ι') (nat.lt_succ_of_le hι') rfl, },\nend\n\nend hall_marriage_theorem\n\n/--\nThis is the version of **Hall's Marriage Theorem** in terms of indexed\nfamilies of finite sets `t : ι → finset α` with `ι` a `fintype`.\nIt states that there is a set of distinct representatives if and only\nif every union of `k` of the sets has at least `k` elements.\n\nSee `finset.all_card_le_bUnion_card_iff_exists_injective` for a version\nwhere the `fintype ι` constraint is removed.\n-/\ntheorem finset.all_card_le_bUnion_card_iff_exists_injective'\n  {ι α : Type*} [fintype ι] [decidable_eq α] (t : ι → finset α) :\n  (∀ (s : finset ι), s.card ≤ (s.bUnion t).card) ↔\n    (∃ (f : ι → α), function.injective f ∧ ∀ x, f x ∈ t x) :=\nbegin\n  split,\n  { exact hall_marriage_theorem.hall_hard_inductive rfl },\n  { rintro ⟨f, hf₁, hf₂⟩ s,\n    rw ←card_image_of_injective s hf₁,\n    apply card_le_of_subset,\n    intro _,\n    rw [mem_image, mem_bUnion],\n    rintros ⟨x, hx, rfl⟩,\n    exact ⟨x, hx, hf₂ x⟩, },\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/combinatorics/hall/finite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499941, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.4628524973380361}}
{"text": "import tactic\nimport inverse_row_insertion\n\n/-\n\nDefining \"inverse_row_bump\" by successive inverse row insertions\n\nThis isn't figured out nicely yet. This file needs to define inverse row bumping\nby repeated inverse_row_insertion. There are two challenges here:\n\n1. Row bumping starts in an arbitrary row, so inverse row bumping should\n  *end* in an arbitrary (given) row. This is a little awkward.\n2. Inverse row bumping needs to have the reverse inductive structure to \n  forward row bumping. Forward row bumping is defined inductively as\n    rbwf(T) = rbwf(rbs(T)) where rbs is one step\n  so, inverse row bumping needs to be defined as\n    irbwf(T) = irbs(irbwf(T)) where irbs is one step\n  in other words, \"do the first n-1 steps, then 1 more step\" is the inverse\n  of \"do 1 step, then the last n-1 steps\".\n\nCurrently I run into problems trying to prove that rbwf and irbwf are inverses\nand also in trying to prove the analog of [row_bump.lean/ssyt.rbs_cert.rbwf_pieri]\nsince the statements are just kind of complicated...\n\nI run into \"motive not correct\" errors involving dependent types. \nAlso I'm not sure I have strong enough inductive statements.\n\nShould the rbs_cert and irbs_cert structures be changed to not be structures?\n\n-/\n\nsection inverse_row_bump\n\nsection irb_inductive\n\n-- def ssyt.irbs_cert.irb_inductive :\n--   Π {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n--   (end_after : ℕ) (i : ℕ) (hi : h.i = end_after + i), ssyt μ\n-- | μ T h end_after 0 hi := h.irbs\n-- | μ T h end_after (nat.succ n) hi :=\n--   ssyt.irbs_cert.irb_inductive\n--     (h.next_cert (by convert nat.succ_ne_zero _))\n--     end_after n (by convert congr_arg nat.pred hi)\n  -- why did these converts work??\n  -- fuller definition:\n  -- ssyt.irbs_cert.irb_inductive\n  --   (h.next_cert (by { rw [hi, nat.add_succ], apply nat.succ_ne_zero }))\n  --   end_after n (by { change h.i.pred = _, rw [hi, nat.add_succ, nat.pred_succ] })\n\n-- stops before doing row i and stores the final irbs_cert\ndef ssyt.irbs_cert.irb_inductive :\n  Π {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i),\n  Σ (T : ssyt μ), T.irbs_cert\n| μ T h end_before 0 hi := ⟨T, h⟩\n| μ T h end_before (nat.succ n) hi :=\n  ssyt.irbs_cert.irb_inductive\n    (h.next_cert (by convert nat.succ_ne_zero _))\n    (by convert congr_arg nat.pred hi)\n-- why did these converts work??\n\nlemma ssyt.irbs_cert.irb_inductive_def_zero\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before : ℕ} (hi : h.i = end_before + 0) :\n  h.irb_inductive hi = ⟨T, h⟩ := rfl\nlemma ssyt.irbs_cert.irb_inductive_def_pos\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before n : ℕ} (hi : h.i = end_before + n.succ) :\n  h.irb_inductive hi =\n  ssyt.irbs_cert.irb_inductive\n    (h.next_cert (by convert nat.succ_ne_zero _))\n    (by convert congr_arg nat.pred hi) := rfl\n\n\nlemma ssyt.irbs_cert.irb_inductive_out_cert_row :\n  Π {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i),\n  (h.irb_inductive hi).2.i = end_before\n| μ T h end_before 0 hi := hi\n| μ T h end_before (nat.succ n) hi :=\nbegin\n  rw ssyt.irbs_cert.irb_inductive,\n  rw ssyt.irbs_cert.irb_inductive_out_cert_row,\nend\n\n\n-- can the induction be turned inside out here?\n-- currently it is irb_inductive(T,n) = irb_inductive(T.next, n-1),\n-- that is, do 1 step, then do by induction.\n-- can it be changed to irb_inductive = irb_inductive(T, n-1).next ?\n-- probably easier to show inverse!\n\nlemma ssyt.irbs_cert.irb_inductive_wt :\n  Π {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  (end_before : ℕ) (i : ℕ) (hi : h.i = end_before + i) (val : ℕ),\n  (h.irb_inductive hi).1.wt val + ite (val = (h.irb_inductive hi).2.val) 1 0 =\n  T.wt val + ite (val = h.val) 1 0\n| μ T h end_before 0 hi val := rfl\n| μ T h end_before (nat.succ n) hi val := begin\n  rw [ssyt.irbs_cert.irb_inductive, ssyt.irbs_cert.irb_inductive_wt],\n  apply ssyt.irbs_cert.irbs_wt,\nend\n\nlemma ssyt.irbs_cert.irb_inductive_entry_eq_self_of_gt_row :\nΠ {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  (i' j' : ℕ) (hi' : i' > h.i),\n  (h.irb_inductive hi).1 i' j' = T i' j'\n| μ T h end_before 0 hi i' j' hi' := rfl\n| μ T h end_before (nat.succ n) hi i' j' hi' := begin\n  rw [ssyt.irbs_cert.irb_inductive,\n      ssyt.irbs_cert.irb_inductive_entry_eq_self_of_gt_row,\n      h.irbs_entry_eq_of_ne_row (ne_of_gt hi')],\n  exact lt_of_le_of_lt (nat.pred_le _) hi'\nend\n\nlemma ssyt.irbs_cert.irb_inductive_entry_eq_self_of_le_end :\nΠ {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  (i' j' : ℕ) (hi' : i' ≤ end_before),\n  (h.irb_inductive hi).1 i' j' = T i' j'\n| μ T h end_before 0 hi i' j' hi' := rfl\n| μ T h end_before (nat.succ n) hi i' j' hi' := begin\n  rw [ssyt.irbs_cert.irb_inductive,\n      ssyt.irbs_cert.irb_inductive_entry_eq_self_of_le_end _ _ _ _ hi',\n      h.irbs_entry_eq_of_ne_row],\n  apply ne_of_lt (lt_of_le_of_lt hi' _),\n  rw [hi, lt_add_iff_pos_right],\n  apply nat.succ_pos,\nend\n\nlemma ssyt.irbs_cert.irb_inductive_entry_eq_self\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  (i' j' : ℕ) (hi' : i' ≤ end_before ∨ h.i < i') :\n  (h.irb_inductive hi).1 i' j' = T i' j' :=\nbegin\n  cases hi',\n    rw ssyt.irbs_cert.irb_inductive_entry_eq_self_of_le_end, exact hi',\n    rw ssyt.irbs_cert.irb_inductive_entry_eq_self_of_gt_row, exact hi',\nend\n\n-- could maybe be golfed\nlemma ssyt.irbs_cert.irb_inductive_entry_eq_of_eq_mid :\nΠ {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  {ν : young_diagram} {T' : ssyt ν} (h' : T'.irbs_cert)\n  (hi' : h'.i = h.i) (hval : h'.val = h.val)\n  (eq_cell : ∀ i j (hi'' : end_before < i ∧ i ≤ h.i), (i, j) ∈ μ ↔ (i, j) ∈ ν)\n  (eq_row_mid : ∀ i j (hi'' : end_before < i ∧ i ≤ h.i), T i j = T' i j)\n  (i j : ℕ) (hi'' : end_before < i ∧ i ≤ h.i),\n(h.irb_inductive hi).1 i j = \n(h'.irb_inductive (by {rw hi at hi', exact hi'})).1 i j\n| μ T h end_before 0 hi\n  ν T' h' \n  hi' hval eq_cell eq_row_mid\n  i j hi'' := eq_row_mid _ _ ⟨hi''.1, hi''.2⟩\n| μ T h end_before (nat.succ n) hi\n  ν T' h' \n  hi' hval eq_cell eq_row_mid\n  i j hi'' := \nbegin\n  have hi''' : end_before < h.i := \n    by { rw [hi, lt_add_iff_pos_right], apply nat.succ_pos },\n  have hj : h'.j = h.j := by {\n    rw [ssyt.irbs_cert.j, ssyt.irbs_cert.j],\n    apply T'.irbc_eq_of_eq_row' T,\n      intro j, rw [hi', eq_cell _ _ ⟨hi''', by refl⟩],\n      intro j, rw [hi', eq_row_mid _ _ ⟨hi''', by refl⟩],\n      exact hi'.symm, exact hval.symm,\n  },\n  rw [ssyt.irbs_cert.irb_inductive, ssyt.irbs_cert.irb_inductive],\n  cases lt_or_eq_of_le hi''.2,\n  { apply ssyt.irbs_cert.irb_inductive_entry_eq_of_eq_mid,\n      { exact congr_arg nat.pred hi' },\n      { change T' _ _ = T _ _, rw [hi', hj, eq_row_mid _ _ ⟨hi''', by refl⟩] },\n      { intros i' j' hij', \n        rw eq_cell _ _ ⟨hij'.1, hij'.2.trans (nat.pred_le _)⟩ },\n      { intros i' j' hij',\n        have key : i' < h.i,\n          apply lt_of_le_of_lt hij'.2,\n          apply nat.pred_lt (ne_of_gt _),\n          apply lt_of_le_of_lt (nat.zero_le _) hi''',\n        rw [h.irbs_entry_eq_of_ne_row (ne_of_lt key), \n            h'.irbs_entry_eq_of_ne_row (ne_of_lt _)],\n        apply eq_row_mid _ _ ⟨hij'.1, le_of_lt key⟩,\n        rw hi', exact key },\n      { exact ⟨hi''.1, nat.le_pred_of_lt h_1⟩ }\n   },\n  { repeat {rw [ssyt.irbs_cert.irb_inductive_entry_eq_self_of_gt_row,\n                ssyt.irbs_cert.irbs_entry]},\n    rw [hi', hval, hj, eq_row_mid _ _ hi''],\n    all_goals { change nat.pred _ < i, rw h_1 }, rw hi',\n    all_goals { apply nat.pred_lt (ne_of_gt _),\n                apply lt_of_le_of_lt (nat.zero_le _) hi''' }\n  },\nend\n\n-- outputs the final tableau together with the removed value\ndef ssyt.irbs_cert.irb\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert) : ssyt μ × ℕ :=\n  let out := h.irb_inductive (add_comm h.i 0) in\n  (out.2.irbs, out.2.out)\n\nlemma ssyt.irbs_cert.irb_wt\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert) (val : ℕ) :\n  h.irb.1.wt val + ite (val = h.irb.2) 1 0 =\n  T.wt val + ite (val = h.val) 1 0 :=\nbegin\n  rw ssyt.irbs_cert.irb,\n  rw ssyt.irbs_cert.irbs_wt,\n  apply ssyt.irbs_cert.irb_inductive_wt,\nend\n\n-- the full operation, starting from a corner\ndef ssyt.inverse_row_bump\n  {μ : young_diagram} (T : ssyt μ) (c : μ.inner_corner) : ssyt c.del × ℕ :=\ndite (c.i = 0) \n  (λ _, (T.del c, T c.i c.j))\n  (λ pos, (T.irbs_cert_of_inner_corner c pos).irb)\n\n-- three goals:\n-- analog of [row_bump.lean/ssyt.rbs_cert.rbwf_pieri] to define inverse_rsk\n-- irb_inductive' ∘ rbwf = id (start and end in row i)\n-- rbwf ∘ irb_inductive' = id (start from an actual corner, not arbitrary)\n\nend irb_inductive\n\nsection pieri\n\nlemma ssyt.irbs_cert.irb_irbs_comm\n  {μ : young_diagram} (T : ssyt μ) (h h1 : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  (h_h1_i : h1.i ≤ end_before ∨ h1.i > h.i)\n  (h' : h1.irbs.irbs_cert) (hi' : h'.i = h.i) (hval' : h'.val = h.val)\n  (h1' : (h.irb_inductive hi).1.irbs_cert) \n    (h1i' : h1'.i = h1.i) (h1val' : h1'.val = h1.val) :\n∀ i' j', (h'.irb_inductive (by {rw hi at hi', use hi' })).1 i' j' =\n          h1'.irbs i' j' :=\nbegin\n  have hj : h1'.j = h1.j :=\n    by { symmetry,\n         apply ssyt.irbc_eq_of_eq_row' _ _ (λ _, iff.rfl) _ _ _ h1i' h1val',\n         intro j, rw h.irb_inductive_entry_eq_self _ _ _ h_h1_i },\n  intros i' j',\n  by_cases h_i' : (i' ≤ end_before ∨ h'.i < i'),\n  { rw [h'.irb_inductive_entry_eq_self _ _ _ h_i',\n        h1'.irbs_entry, h1i', h1val', hj,\n        h.irb_inductive_entry_eq_self _ _ _ _], \n    refl, exact hi' ▸ h_i' },\n  { push_neg at h_i',\n    rw h1'.irbs_entry_eq_of_ne_row,\n    rw h.irb_inductive_entry_eq_of_eq_mid _ _ hi' hval'\n      (λ _ _ _, iff.rfl) _ _, \n      rwa hi' at h_i',\n      intros i'' j'' hi'', rw h1.irbs_entry_eq_of_ne_row,\n      rintro rfl, apply absurd h_h1_i, push_neg, exact hi'',\n    rintro rfl, rw [hi', h1i'] at h_i',\n    apply absurd h_h1_i, push_neg, exact h_i' },\nend\n\n\n\n\n-- lemma ssyt.irbs_cert.irb_pieri :\n-- Π {μ : young_diagram} (T : ssyt μ) (h : T.irbs_cert)\n--   {end_before i : ℕ} (hi : h.i = end_before + i)\n--   (h' : (h.irb_inductive hi).1.irbs_cert)\n--   (hi' : h'.i = h.i) (hval' : h'.val ≤ h.val) (hj' : h'.j < h.j),\n-- (h'.irb_inductive (by {rw hi at hi', use hi'})).2.j <\n-- (h.irb_inductive hi).2.j\n-- | μ T h end_before 0 hi := begin\n--     rw ssyt.irbs_cert.irb_inductive, dsimp only,\n--     intros h' hi' hval' hj',\n--     apply absurd hj', push_neg,\n--     rw ssyt.le_irbc_iff, rw hi', split, exact h.cell,\n    \n--     dsimp,\n    \n--     -- rw ssyt.irbc_lt_iff at hj',\n\n--     rw ssyt.irbs_cert.irb_inductive, dsimp only at *,\n--     rw [ssyt.irbc_lt_iff],\n    \n--     intro cell',\n--     apply hval'.trans, --apply le_trans _ (T.row_weak hj' cell'),\n--     have := h.out_lt_val,\n    \n    \n--     -- rw ssyt.irbc_le_iff,\n\n--     -- simp_rw ssyt.irbs_cert.irb_inductive,\n-- end\n\n\n\n\nend pieri\n\nend inverse_row_bump\n\nsection inverse_row_bump'\n\n-- stops before doing row i and stores the final irbs_cert\ndef ssyt.irbs_cert.irb_inductive' :\n  Π {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i),\n  Σ' (T : ssyt μ) (h : T.irbs_cert), h.i = end_before\n| μ T h end_before 0 hi := ⟨T, h, hi⟩\n| μ T h end_before (nat.succ n) hi :=\nhave hii : h.i = end_before.succ + n :=\n  (hi.trans (end_before.succ_add_eq_succ_add n).symm),\n⟨_,\n (h.irb_inductive' hii).2.1.next_cert (by { rw (h.irb_inductive' hii).2.2, apply nat.succ_ne_zero }),\n by {\n   convert end_before.pred_succ,\n   rw [ssyt.irbs_cert.next_cert_i, (h.irb_inductive' hii).2.2],\n }⟩\n\nlemma ssyt.irbs_cert.irb_inductive'_row_zero\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before : ℕ} (hi : h.i = end_before + 0) :\n  h.irb_inductive' hi = ⟨T, h, hi⟩ := rfl\n\nlemma ssyt.irbs_cert.irb_inductive'_row_succ\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before n : ℕ} (hi : h.i = end_before + n.succ) :\n  h.irb_inductive' hi =  \nlet out' := (h.irb_inductive'\n    (hi.trans (end_before.succ_add_eq_succ_add n).symm)) in\n  ⟨_, \n   out'.2.1.next_cert (by { rw out'.2.2, apply nat.succ_ne_zero }),\n   by {\n     change nat.pred _ = _, rw out'.2.2, apply nat.pred_succ,\n   }⟩ := rfl\n\nlemma ssyt.irbs_cert.irb_inductive'_out_row\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i) :\n  (h.irb_inductive' hi).2.1.i = end_before := (h.irb_inductive' hi).2.2\n\n-- lemma ssyt.irbs_cert.irb_inductive'_cert_val_zero\n--   {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n--   {end_before : ℕ} (hi : h.i = end_before + 0) :\n--   (h.irb_inductive' hi).2.1.val = h.val := rfl\n\n-- lemma ssyt.irbs_cert.irb_inductive'_cert_val_succ\n--   {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n--   {end_before n : ℕ} (hi : h.i = end_before + n.succ) :\n--   (h.irb_inductive' hi).2.1.val =  \n-- let out' := (h.irb_inductive'\n--     (hi.trans (end_before.succ_add_eq_succ_add n).symm)) in\n--   ⟨_, \n--    out'.2.1.next_cert (by { rw out'.2.2, apply nat.succ_ne_zero }),\n--    by {\n--      change nat.pred _ = _, rw out'.2.2, apply nat.pred_succ,\n--    }⟩ := rfl\n\nlemma ssyt.irbs_cert.irb_inductive'_wt :\n  Π {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  (end_before : ℕ) (i : ℕ) (hi : h.i = end_before + i) (val : ℕ),\n  (h.irb_inductive' hi).1.wt val + ite (val = (h.irb_inductive' hi).2.1.val) 1 0 =\n  T.wt val + ite (val = h.val) 1 0\n| μ T h end_before 0 hi val := rfl\n| μ T h end_before (nat.succ n) hi val := begin\n  rw ssyt.irbs_cert.irb_inductive'_row_succ, dsimp,\n  simp_rw ssyt.irbs_cert.irbs_wt,\n  rw ssyt.irbs_cert.irb_inductive'_wt,\nend\n\nlemma ssyt.irbs_cert.irb_inductive'_entry_eq_self_of_gt_row :\nΠ {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  (i' j' : ℕ) (hi' : i' > h.i),\n  (h.irb_inductive' hi).1 i' j' = T i' j'\n| μ T h end_before 0 hi i' j' hi' := rfl\n| μ T h end_before (nat.succ n) hi i' j' hi' := begin\n  rw ssyt.irbs_cert.irb_inductive'_row_succ, dsimp,\n  rw [ssyt.irbs_cert.irbs_entry_eq_of_ne_row,\n      ssyt.irbs_cert.irb_inductive'_entry_eq_self_of_gt_row _ _ _ _ hi'],\n  rw ssyt.irbs_cert.irb_inductive'_out_row,\n  apply ne_of_gt (lt_of_le_of_lt _ hi'),\n  rw [hi, ← nat.succ_add_eq_succ_add], exact le_self_add,\nend\n\nlemma ssyt.irbs_cert.irb_inductive'_entry_eq_self_of_le_end :\nΠ {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  (i' j' : ℕ) (hi' : i' ≤ end_before),\n  (h.irb_inductive' hi).1 i' j' = T i' j'\n| μ T h end_before 0 hi i' j' hi' := rfl\n| μ T h end_before (nat.succ n) hi i' j' hi' := begin\n  rw ssyt.irbs_cert.irb_inductive'_row_succ, dsimp,\n  rw [ssyt.irbs_cert.irbs_entry_eq_of_ne_row,\n      ssyt.irbs_cert.irb_inductive'_entry_eq_self_of_le_end],\n  exact nat.le_succ_of_le hi',\n  apply ne_of_lt (lt_of_le_of_lt hi' _),\n  rw ssyt.irbs_cert.irb_inductive'_out_row,\n  exact lt_add_one _,\nend\n\nlemma ssyt.irbs_cert.irb_inductive'_entry_eq_self\n  {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  (i' j' : ℕ) (hi' : i' ≤ end_before ∨ h.i < i') :\n  (h.irb_inductive' hi).1 i' j' = T i' j' :=\nbegin\n  cases hi',\n    rw ssyt.irbs_cert.irb_inductive'_entry_eq_self_of_le_end, exact hi',\n    rw ssyt.irbs_cert.irb_inductive'_entry_eq_self_of_gt_row, exact hi',\nend\n\nlemma ssyt.irbs_cert.irb_inductive'_eq_mid_of_eq_mid :\nΠ {μ : young_diagram} {T : ssyt μ} (h : T.irbs_cert)\n  {end_before i : ℕ} (hi : h.i = end_before + i)\n  {ν : young_diagram} {T' : ssyt ν} (h' : T'.irbs_cert)\n  (hi' : h'.i = h.i) (hval : h'.val = h.val) (hj : h'.j = h.j)\n  (eq_cell : ∀ i j (hi'' : end_before < i ∧ i ≤ h.i), (i, j) ∈ μ ↔ (i, j) ∈ ν)\n  (eq_row_mid : ∀ i j (hi'' : end_before < i ∧ i ≤ h.i), T i j = T' i j),\n(h.irb_inductive' hi).2.1.val = (h'.irb_inductive' (hi'.trans hi)).2.1.val\n--∧ (h.irb_inductive' hi).2.1.j = (h'.irb_inductive' (hi'.trans hi)).2.1.j\n∧ ∀ (i j : ℕ) (hi'' : end_before < i ∧ i ≤ h.i),\n(h.irb_inductive' hi).1 i j = (h'.irb_inductive' (hi'.trans hi)).1 i j \n| μ T h end_before 0 hi\n  ν T' h' \n  hi' hval hj eq_cell eq_row_mid := begin\n    rw [h.irb_inductive'_row_zero, h'.irb_inductive'_row_zero], dsimp,\n    exact ⟨hval.symm,\n          --  hj.symm,\n           eq_row_mid⟩,\n  end\n| μ T h end_before (nat.succ n) hi\n  ν T' h' \n  hi' hval hj eq_cell eq_row_mid := \nbegin\n  have hi_succ : h.i = end_before.succ + n :=\n    hi.trans (nat.succ_add_eq_succ_add _ _).symm,\n  have hi'_succ : h'.i = end_before.succ + n :=\n    hi'.trans hi_succ,\n  -- have hi''' : end_before < h.i := \n  --   by { rw [hi, lt_add_iff_pos_right], apply nat.succ_pos },\n  have hval'' : (h.irb_inductive' hi_succ).2.1.val = \n    (h'.irb_inductive' hi'_succ).2.1.val := by {\n    rw (ssyt.irbs_cert.irb_inductive'_eq_mid_of_eq_mid\n          _ _ _ hi' hval hj _ _).1,\n    { rintros i' j' ⟨h1, h2⟩, rw eq_cell _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n    { rintros i' j' ⟨h1, h2⟩, rw eq_row_mid _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n  },\n  have hj' : (h.irb_inductive' hi_succ).2.1.j = \n    (h'.irb_inductive' hi'_succ).2.1.j := by {\n    sorry,\n    -- cases n, exact hj.symm,\n    -- -- rw ssyt.irbs_cert.irb_inductive'_row_succ,\n    -- -- rw ssyt.irbs_cert.irb_inductive'_row_succ, dsimp,\n    -- rw ssyt.irbs_cert.j, rw ssyt.irbs_cert.j,\n    -- rw ssyt.irbc_eq_of_eq_row',\n    -- -- { intro j, rw eq_cell _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n    -- intro j, rw eq_cell, rw [h.irb_inductive'_out_row, hi_succ], \n    -- exact ⟨lt_add_one _, nat.le_add_right _ _⟩,\n    -- rotate, rw [h.irb_inductive'_out_row, h'.irb_inductive'_out_row],\n    -- rw hval'',\n    -- intro j, rw [h.irb_inductive'_out_row],\n    -- rw ssyt.irbs_cert.irb_inductive'_row_succ,\n    -- rw ssyt.irbs_cert.irb_inductive'_row_succ, dsimp,\n\n    -- rw (ssyt.irbs_cert.irb_inductive'_eq_mid_of_eq_mid\n    --       _ _ _ _ _ _ _ _).2,\n    -- { rintros i' j' ⟨h1, h2⟩, rw eq_cell _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n    -- { rintros i' j' ⟨h1, h2⟩, rw eq_row_mid _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n  },\n\n  rw [ssyt.irbs_cert.irb_inductive'_row_succ,\n      ssyt.irbs_cert.irb_inductive'_row_succ], dsimp only,\n  split,\n  { dsimp, rw [ssyt.irbs_cert.out, ssyt.irbs_cert.out],\n    rw [h.irb_inductive'_out_row, h'.irb_inductive'_out_row],\n    rw ← hj',\n    rw [h.irb_inductive'_entry_eq_self_of_le_end,\n        h'.irb_inductive'_entry_eq_self_of_le_end, eq_row_mid],\n    rw hi_succ, exact ⟨lt_add_one _, nat.le_add_right _ _⟩, refl, refl },\n  -- split,\n  -- { sorry ,\n  --   -- rw ssyt.irbs_cert.j, rw ssyt.irbs_cert.j,\n  --   -- rw ssyt.irbc_eq_of_eq_row',\n  --   -- rotate 2,\n  --   -- repeat {rw ssyt.irbs_cert.next_cert_i},\n  --   -- rw [h.irb_inductive'_out_row, h'.irb_inductive'_out_row],\n  --   -- sorry,\n  --   -- intro j, rw [h.irb_inductive'_out_row, nat.pred_succ],\n  -- },\n  intros i j hi'',\n  cases lt_or_eq_of_le (nat.succ_le_iff.mpr hi''.1),\n  { rw [ssyt.irbs_cert.irbs_entry_eq_of_ne_row,\n        ssyt.irbs_cert.irbs_entry_eq_of_ne_row,\n        (ssyt.irbs_cert.irb_inductive'_eq_mid_of_eq_mid\n          _ _ _ hi' hval hj _ _).2],\n    exact ⟨h_1, hi''.2⟩,\n    { rintros i' j' ⟨h1, h2⟩, rw eq_cell _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n    { rintros i' j' ⟨h1, h2⟩, rw eq_row_mid _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n    rw ssyt.irbs_cert.irb_inductive'_out_row, exact ne_of_gt h_1,\n    rw ssyt.irbs_cert.irb_inductive'_out_row, exact ne_of_gt h_1 },\n  \n  subst i,\n  rw [ssyt.irbs_cert.irbs_entry, ssyt.irbs_cert.irbs_entry],\n  rw [h.irb_inductive'_out_row, h'.irb_inductive'_out_row, ← hj'],\n  repeat {simp_rw [prod.mk.inj_iff, and_iff_right]},\n  split_ifs,\n  rw hval'',\n  rw [h.irb_inductive'_entry_eq_self_of_le_end,\n      h'.irb_inductive'_entry_eq_self_of_le_end,\n      eq_row_mid _ _ hi''],\n  refl, refl,\n  \n\n  -- rw [ssyt.irbs_cert.irbs_entry],\n  -- -- rw [ssyt.irbs_cert.irbs_entry, ssyt.irbs_cert.irbs_entry],\n  -- rw [ssyt.irbs_cert.irb_inductive'_out_row],\n  -- rw if_neg,\n\n  \n  \n\n  -- rw ssyt.irbs_cert.irb_inductive'_entry_eq_of_eq_mid,\n  -- { rintros i' j' ⟨h1, h2⟩, rw eq_cell _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n  -- { rintros i' j' ⟨h1, h2⟩, rw eq_row_mid _ _ ⟨(lt_add_one _).trans h1, h2⟩ },\n  -- exact ⟨h_1, hi''.2⟩,\n  --     -- ssyt.irbs_cert.irb_inductive'_out_row],\n  \n  -- rw ssyt.irbs_cert.irb_inductive'_entry_eq_self_of_gt_row,\n  \n  -- { apply ssyt.irbs_cert.irb_inductive'_entry_eq_of_eq_mid,\n  --     { exact congr_arg nat.pred hi' },\n  --     { change T' _ _ = T _ _, rw [hi', hj, eq_row_mid _ _ ⟨hi''', by refl⟩] },\n  --     { intros i' j' hij', \n  --       rw eq_cell _ _ ⟨hij'.1, hij'.2.trans (nat.pred_le _)⟩ },\n  --     { intros i' j' hij',\n  --       have key : i' < h.i,\n  --         apply lt_of_le_of_lt hij'.2,\n  --         apply nat.pred_lt (ne_of_gt _),\n  --         apply lt_of_le_of_lt (nat.zero_le _) hi''',\n  --       rw [h.irbs_entry_eq_of_ne_row (ne_of_lt key), \n  --           h'.irbs_entry_eq_of_ne_row (ne_of_lt _)],\n  --       apply eq_row_mid _ _ ⟨hij'.1, le_of_lt key⟩,\n  --       rw hi', exact key },\n  --     { exact ⟨hi''.1, nat.le_pred_of_lt h_1⟩ }\n  --  },\n  -- { repeat {rw [ssyt.irbs_cert.irb_inductive_entry_eq_self_of_gt_row,\n  --               ssyt.irbs_cert.irbs_entry]},\n  --   rw [hi', hval, hj, eq_row_mid _ _ hi''],\n  --   all_goals { change nat.pred _ < i, rw h_1 }, rw hi',\n  --   all_goals { apply nat.pred_lt (ne_of_gt _),\n  --               apply lt_of_le_of_lt (nat.zero_le _) hi''' }\n  -- },\nend\n\n\n-- can the induction be turned inside out here?\n-- currently it is irb_inductive(T,n) = irb_inductive(T.next, n-1),\n-- that is, do 1 step, then do by induction.\n-- can it be changed to irb_inductive = irb_inductive(T, n-1).next ?\n-- probably easier to show inverse!\n\n\nend inverse_row_bump'", "meta": {"author": "jakelev", "repo": "lean-rsk", "sha": "dbd97f8fe9fc2ba13d080d37e298ae87d03ff541", "save_path": "github-repos/lean/jakelev-lean-rsk", "path": "github-repos/lean/jakelev-lean-rsk/lean-rsk-dbd97f8fe9fc2ba13d080d37e298ae87d03ff541/src/inverse_row_bump.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6619228691808011, "lm_q1q2_score": 0.4628524926745734}}
{"text": "import Logic.Predicate.Term\nimport Mathlib.Data.W.Basic\n\nuniverse u v\n\nvariable {L : Language.{u}} [∀ k, Encodable (L.func k)] {μ : Type v} [Encodable μ]\n\nnamespace SubTerm\nopen Encodable\nvariable {n : ℕ}\n\n-- 本来 \" + 1\"は必要ないがofNatの停止性の証明がより簡易になるためつけている\ndef toNat : SubTerm L μ n → ℕ \n  | #x                    => (Nat.bit false $ Nat.bit false (encode x)) + 1\n  | &x                    => (Nat.bit false $ Nat.bit true (encode x)) + 1\n  | func (arity := k) f v => (Nat.bit true  $ Nat.mkpair k $\n      Nat.mkpair (encode f) (Matrix.vecToNat $ fun i => (v i).toNat)) + 1\n\ndef ofNat : ℕ → Option (SubTerm L μ n)\n| 0  => none\n| e + 1 =>\n  match e.bodd with\n  | false => \n    match e.div2.bodd with\n    | false => (decode₂ (Fin n) e.div2.div2).map bvar\n    | true  => (decode₂ μ e.div2.div2).map fvar\n  | true  =>\n      let x := e.div2\n      let k := x.unpair.1\n      let f' : Option (L.func k) := decode₂ (L.func k) x.unpair.2.unpair.1\n      let w : Fin k → ℕ := Nat.unvector x.unpair.2.unpair.2\n      have : ∀ i, w i < e + 1 := fun i =>\n        Nat.lt_succ_of_le (le_trans (Nat.unvector_le x.unpair.2.unpair.2 i)\n          (le_trans (Nat.unpair_right_le _) $\n            le_trans (Nat.unpair_right_le _) $ by simp[Nat.div2_val]; exact Nat.div_le_self e 2))\n      let v' : Option (Fin k → SubTerm L μ n) := Matrix.toOptionVec (fun i => ofNat (w i))\n      f'.bind fun f => v'.map fun v => func f v\n  decreasing_by exact this i\n\n@[simp] lemma ofNat_toNat : ∀ t : SubTerm L μ n, ofNat (toNat t) = some t\n  | #x => by simp[ofNat, toNat]; rw[Nat.bodd_bit, Nat.div2_bit]; simp; rw[Nat.bodd_bit, Nat.div2_bit]; simp\n  | &x => by simp[ofNat, toNat]; rw[Nat.bodd_bit, Nat.div2_bit]; simp; rw[Nat.bodd_bit, Nat.div2_bit]; simp\n  | func f v => by\n      simp[ofNat, toNat]\n      rw[Nat.bodd_bit, Nat.div2_bit, Nat.unpair_mkpair]; simp[fun i => ofNat_toNat (v i)];\n\ninstance : Encodable (SubTerm L μ n) where\n  encode := toNat\n  decode := ofNat\n  encodek := ofNat_toNat\n\nvariable [∀ k, DecidableEq (L.func k)]\n\ndef enumLtList : ℕ → List (SyntacticTerm L)\n| 0     => []\n| s + 1 => (Encodable.decode₂ (SyntacticTerm L) s).toList ++ enumLtList s\n\nlemma mem_enumLtList_of_lt {i} {t : SyntacticTerm L} (h : encode t < i) : t ∈ enumLtList i := by\n  induction' i with i ih <;> simp[enumLtList]\n  · contradiction\n  · have : encode t < i ∨ encode t = i := lt_or_eq_of_le (Nat.lt_succ.mp h)\n    rcases this with (h | rfl) <;> simp[*]\n\ndef enumLt (s : ℕ) : Finset (SyntacticTerm L) := (enumLtList s).toFinset\n\n@[simp] lemma enumLt_zero : (enumLt 0 : Finset (SyntacticTerm L)) = ∅ := rfl \n\nlemma mem_enumLt_of_lt {i} {t : SyntacticTerm L} (h : encode t < i) : t ∈ enumLt i :=\n  by simp[enumLt]; exact mem_enumLtList_of_lt h\n\n#eval enumLt (L := Language.oring) 100\n\nend SubTerm", "meta": {"author": "iehality", "repo": "lean4-logic", "sha": "ef518051931fb1ecd0b89e94240b2900cd54d95c", "save_path": "github-repos/lean/iehality-lean4-logic", "path": "github-repos/lean/iehality-lean4-logic/lean4-logic-ef518051931fb1ecd0b89e94240b2900cd54d95c/Logic/Predicate/Coding.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4625918686930709}}
{"text": "import implementation.model.sys_state\n\nnamespace predicate\n\nvariables {pid_t pstate_t msg_t : Type} [protocol pid_t pstate_t msg_t]\n\n-- An invariant is a predicate on states which holds at all reachable states.\ndef invariant (p : sys_state pid_t pstate_t msg_t → Prop) : Prop :=\n  ∀ (s : sys_state pid_t pstate_t msg_t), s.reachable → p s\n\n-- A predicate is stable if, whenever it holds at u and v can be stepped-to from\n-- u, the predicate also holds at v.\ndef stable (p : sys_state pid_t pstate_t msg_t → Prop) : Prop :=\n  (∀ (u v : sys_state pid_t pstate_t msg_t), p u → u.possible_next v → p v)\n\n-- An inductive invariant is an stable predicate which holds at the initial\n-- state.\ndef inductive_invariant (p : sys_state pid_t pstate_t msg_t → Prop) : Prop :=\n  (∀ (s : sys_state pid_t pstate_t msg_t), s.is_initial → p s) ∧\n    stable p\n\n-- Any inductive invariant is an invariant.\nlemma ind_inv_is_inv {p : sys_state pid_t pstate_t msg_t → Prop} :\n  inductive_invariant p → invariant p :=\nbegin\nrintro ⟨initial, inductive_step⟩,\nsuffices key : ∀ (n : ℕ) (s : sys_state pid_t pstate_t msg_t), s.reachable_in n → p s,\nby {\n  intro s,\n  rintros ⟨n, reachable_in_n_steps⟩,\n  exact key n s reachable_in_n_steps },\nintro n,\ninduction n with k hk,\n{ exact initial },\nintros s hyp,\ncases hyp with step_required step_not_required,\n{ rcases step_required with ⟨u, reach_u_in_k, s_is_u_next⟩,\n  exact inductive_step u s (hk u reach_u_in_k) s_is_u_next },\nexact hk s step_not_required\nend\n\n-- Stronger invariants imply weaker ones.\nlemma invariants_imply {stronger weaker : sys_state pid_t pstate_t msg_t → Prop} :\n  (∀ (s : sys_state pid_t pstate_t msg_t), stronger s → weaker s) →\n     invariant stronger → invariant weaker :=\nbegin\nintros strength inv_stronger s reachable,\nexact strength s (inv_stronger s reachable)\nend\n\n-- A predicate is an invariant whenever it is an inductive invariant (as long as\n-- we restrict only to reachable states).\n--\n-- NOTE(gnanabit): It is not true that invariant inv ↔ inductive_invariant inv,\n-- specifically the → direction.\nlemma inv_iff_ind_inv (inv : sys_state pid_t pstate_t msg_t → Prop) :\n  invariant inv ↔ inductive_invariant (λ s, s.reachable ∧ inv s) :=\nbegin\nsplit,\n{ intro hyp,\n  split,\n  { intros s hs,\n    have s_r : s.reachable := ⟨0, hs⟩,\n    exact ⟨s_r, hyp s s_r⟩ },\n  intros u v,\n  rintros ⟨⟨steps_r, u_r⟩, inv_u⟩,\n  intro u_pn_v,\n  have v_r : v.reachable := ⟨steps_r.succ, or.inl ⟨u, u_r, u_pn_v⟩⟩,\n  exact ⟨v_r, hyp v v_r⟩ },\nintro hyp,\nsuffices key : ∀ (s : sys_state pid_t pstate_t msg_t), s.reachable ∧ inv s → inv s,\nby { exact invariants_imply key (ind_inv_is_inv hyp) },\nintros s hs,\nexact hs.right\nend\n\n-- This result allows us to use all already-proven invariants in the inductive\n-- step.\ntheorem use_any_invariant (p : sys_state pid_t pstate_t msg_t → Prop) :\n  invariant p ↔\n    (∀ (s : sys_state pid_t pstate_t msg_t), s.is_initial → p s) ∧\n    (∀ (u v : sys_state pid_t pstate_t msg_t), u.reachable → p u → u.possible_next v → v.reachable → p v) :=\nbegin\nrw inv_iff_ind_inv,\nsplit,\n{ intro hyp,\n  split,\n  { intros s hs,\n    exact (hyp.left s hs).right },\n  intros u v u_r p_u u_pn_v h_v,\n  exact (hyp.right u v ⟨u_r, p_u⟩ u_pn_v).right },\nrintros ⟨h_init, h_step⟩,\nsplit,\n{ intros s hs,\n  exact ⟨⟨0, hs⟩, h_init s hs⟩ },\nintros u v,\nrintros ⟨u_r, p_u⟩,\nintro u_pn_v,\nhave key : v.reachable,\n  by { cases u_r with steps_r u_r, exact ⟨steps_r.succ, or.inl ⟨u, u_r, u_pn_v⟩⟩ },\nexact ⟨key, by { exact h_step u v u_r p_u u_pn_v key }⟩,\nend\n\nend predicate\n", "meta": {"author": "gnanabite", "repo": "colocated-paxos", "sha": "f60308e27d3013665809077fe80a4b2af8a42278", "save_path": "github-repos/lean/gnanabite-colocated-paxos", "path": "github-repos/lean/gnanabite-colocated-paxos/colocated-paxos-f60308e27d3013665809077fe80a4b2af8a42278/src/implementation/model/predicate.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4625918616115392}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.data.nat.default\nimport Mathlib.Lean3Lib.init.data.fin.basic\n \n\nnamespace Mathlib\n\nnamespace fin\n\n\nprotected def succ {n : ℕ} : fin n → fin (Nat.succ n) :=\n  sorry\n\ndef of_nat {n : ℕ} (a : ℕ) : fin (Nat.succ n) :=\n  { val := a % Nat.succ n, property := sorry }\n\nprotected def add {n : ℕ} : fin n → fin n → fin n :=\n  sorry\n\nprotected def mul {n : ℕ} : fin n → fin n → fin n :=\n  sorry\n\nprotected def sub {n : ℕ} : fin n → fin n → fin n :=\n  sorry\n\nprotected def mod {n : ℕ} : fin n → fin n → fin n :=\n  sorry\n\nprotected def div {n : ℕ} : fin n → fin n → fin n :=\n  sorry\n\nprotected instance has_zero {n : ℕ} : HasZero (fin (Nat.succ n)) :=\n  { zero := { val := 0, property := nat.succ_pos n } }\n\nprotected instance has_one {n : ℕ} : HasOne (fin (Nat.succ n)) :=\n  { one := of_nat 1 }\n\nprotected instance has_add {n : ℕ} : Add (fin n) :=\n  { add := fin.add }\n\nprotected instance has_sub {n : ℕ} : Sub (fin n) :=\n  { sub := fin.sub }\n\nprotected instance has_mul {n : ℕ} : Mul (fin n) :=\n  { mul := fin.mul }\n\nprotected instance has_mod {n : ℕ} : Mod (fin n) :=\n  { mod := fin.mod }\n\nprotected instance has_div {n : ℕ} : Div (fin n) :=\n  { div := fin.div }\n\ntheorem of_nat_zero {n : ℕ} : of_nat 0 = 0 :=\n  rfl\n\ntheorem add_def {n : ℕ} (a : fin n) (b : fin n) : subtype.val (a + b) = (subtype.val a + subtype.val b) % n := sorry\n\ntheorem mul_def {n : ℕ} (a : fin n) (b : fin n) : subtype.val (a * b) = subtype.val a * subtype.val b % n := sorry\n\ntheorem sub_def {n : ℕ} (a : fin n) (b : fin n) : subtype.val (a - b) = subtype.val a - subtype.val b := sorry\n\ntheorem mod_def {n : ℕ} (a : fin n) (b : fin n) : subtype.val (a % b) = subtype.val a % subtype.val b := sorry\n\ntheorem div_def {n : ℕ} (a : fin n) (b : fin n) : subtype.val (a / b) = subtype.val a / subtype.val b := sorry\n\ntheorem lt_def {n : ℕ} (a : fin n) (b : fin n) : a < b = (subtype.val a < subtype.val b) := sorry\n\ntheorem le_def {n : ℕ} (a : fin n) (b : fin n) : a ≤ b = (subtype.val a ≤ subtype.val b) := sorry\n\ntheorem val_zero {n : ℕ} : subtype.val 0 = 0 :=\n  rfl\n\ndef pred {n : ℕ} (i : fin (Nat.succ n)) : i ≠ 0 → fin n :=\n  sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/data/fin/ops.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4625918616115391}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad, Mario Carneiro\n\nThe M construction as a multivariate polynomial functor.\n-/\nimport mvpfunctor.basic pfunctor\nuniverse u\n\nnamespace mvpfunctor\nopen typevec\n\nvariables {n : ℕ} (P : mvpfunctor.{u} (n+1))\n\ninductive M_path : P.last.M → fin' n → Type u\n| root (x : P.last.M) (a : P.A) (f : P.last.B a → P.last.M) (h : pfunctor.M_dest x = ⟨a, f⟩)\n       (i : fin' n) (c : P.drop.B a i) :\n    M_path x i\n| child (x : P.last.M) (a : P.A) (f : P.last.B a → P.last.M) (h : pfunctor.M_dest x = ⟨a, f⟩)\n      (j : P.last.B a) (i : fin' n) (c : M_path (f j) i) :\n    M_path x i\n\ndef Mp : mvpfunctor n :=\n{ A := P.last.M, B := P.M_path }\n\ndef M (α : typevec n) : Type* := P.Mp.apply α\n\ninstance mvfunctor_M : mvfunctor P.M := by delta M; apply_instance\n\ndef M_corec_shape {β : Type u}\n    (g₀ : β → P.A)\n    (g₂ : Π b : β, P.last.B (g₀ b) → β) :\n  β → P.last.M :=\npfunctor.M_corec (λ b, ⟨g₀ b, g₂ b⟩)\n\ndef cast_dropB {a a' : P.A} (h : a = a') : P.drop.B a ⟹ P.drop.B a' :=\nλ i b, eq.rec_on h b\n\ndef cast_lastB {a a' : P.A} (h : a = a') : P.last.B a → P.last.B a' :=\nλ b, eq.rec_on h b\n\ndef M_corec_contents {α : typevec.{u} n} {β : Type u}\n    (g₀ : β → P.A)\n    (g₁ : Π b : β, P.drop.B (g₀ b) ⟹ α)\n    (g₂ : Π b : β, P.last.B (g₀ b) → β) :\n  Π x b, x = P.M_corec_shape g₀ g₂ b → P.M_path x ⟹ α\n| ._ b h ._ (M_path.root x a f h' i c)    :=\n  have a = g₀ b,\n    by { rw [h, M_corec_shape, pfunctor.M_dest_corec] at h', cases h', refl },\n  g₁ b i (P.cast_dropB this i c)\n| ._ b h ._ (M_path.child x a f h' j i c) :=\n  have h₀ : a = g₀ b,\n    by { rw [h, M_corec_shape, pfunctor.M_dest_corec] at h', cases h', refl },\n  have h₁ : f j = M_corec_shape P g₀ g₂ (g₂ b (cast_lastB P h₀ j)),\n    by { rw [h, M_corec_shape, pfunctor.M_dest_corec] at h', cases h', refl },\n  M_corec_contents (f j) (g₂ b (P.cast_lastB h₀ j)) h₁ i c\n\ndef M_corec' {α : typevec n} {β : Type u}\n    (g₀ : β → P.A)\n    (g₁ : Π b : β, P.drop.B (g₀ b) ⟹ α)\n    (g₂ : Π b : β, P.last.B (g₀ b) → β) :\n  β → P.M α :=\nλ b, ⟨M_corec_shape P g₀ g₂ b, M_corec_contents P g₀ g₁ g₂ _ _ rfl⟩\n\ndef M_corec {α : typevec n} {β : Type u} (g : β → P.apply (α.append1 β)) :\n  β → P.M α :=\nM_corec' P\n  (λ b, (g b).fst)\n  (λ b, drop_fun (g b).snd)\n  (λ b, last_fun (g b).snd)\n\ndef M_path_dest_left {α : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a → P.last.M} (h : pfunctor.M_dest x = ⟨a, f⟩)\n    (f' : P.M_path x ⟹ α) :\n  P.drop.B a ⟹ α :=\nλ i c, f' i (M_path.root x a f h i c)\n\ndef M_path_dest_right {α : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a → P.last.M} (h : pfunctor.M_dest x = ⟨a, f⟩)\n    (f' : P.M_path x ⟹ α) :\n  Π j : P.last.B a, P.M_path (f j) ⟹ α :=\nλ j i c, f' i (M_path.child x a f h j i c)\n\ndef M_dest' {α : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a → P.last.M} (h : pfunctor.M_dest x = ⟨a, f⟩)\n    (f' : P.M_path x ⟹ α) :\n  P.apply (α.append1 (P.M α)) :=\n⟨a, split_fun (P.M_path_dest_left h f') (λ x, ⟨f x, P.M_path_dest_right h f' x⟩)⟩\n\ndef M_dest {α : typevec n} (x : P.M α) : P.apply (α.append1 (P.M α)) :=\nP.M_dest' (sigma.eta $ pfunctor.M_dest x.fst).symm x.snd\n\ndef M_mk  {α : typevec n} : P.apply (α.append1 (P.M α)) → P.M α :=\nM_corec _ (λ i, append_fun id (M_dest P) <$$> i)\n\ntheorem M_dest'_eq_dest' {α : typevec n} {x : P.last.M}\n    {a₁ : P.A} {f₁ : P.last.B a₁ → P.last.M} (h₁ : pfunctor.M_dest x = ⟨a₁, f₁⟩)\n    {a₂ : P.A} {f₂ : P.last.B a₂ → P.last.M} (h₂ : pfunctor.M_dest x = ⟨a₂, f₂⟩)\n    (f' : P.M_path x ⟹ α) : M_dest' P h₁ f' = M_dest' P h₂ f' :=\nby cases h₁.symm.trans h₂; refl\n\ntheorem M_dest_eq_dest' {α : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a → P.last.M} (h : pfunctor.M_dest x = ⟨a, f⟩)\n    (f' : P.M_path x ⟹ α) : M_dest P ⟨x, f'⟩ = M_dest' P h f' :=\nM_dest'_eq_dest' _ _ _ _\n\ntheorem M_dest_corec' {α : typevec.{u} n} {β : Type u}\n    (g₀ : β → P.A)\n    (g₁ : Π b : β, P.drop.B (g₀ b) ⟹ α)\n    (g₂ : Π b : β, P.last.B (g₀ b) → β)\n    (x : β) :\n  P.M_dest (P.M_corec' g₀ g₁ g₂ x) =\n    ⟨g₀ x, split_fun (g₁ x) (P.M_corec' g₀ g₁ g₂ ∘ (g₂ x))⟩ :=\nrfl\n\ntheorem M_dest_corec {α : typevec n} {β : Type u} (g : β → P.apply (α.append1 β)) (x : β) :\n  P.M_dest (P.M_corec g x) = append_fun id (P.M_corec g) <$$> g x :=\nbegin\n  transitivity, apply M_dest_corec',\n  cases g x with a f, dsimp,\n  rw mvpfunctor.map_eq, congr,\n  conv { to_rhs, rw [←split_drop_fun_last_fun f, append_fun_comp_split_fun] },\n  refl\nend\n\nlemma M_bisim_lemma {α : typevec n}\n  {a₁ : (Mp P).A} {f₁ : (Mp P).B a₁ ⟹ α}\n  {a' : P.A} {f' : (P.B a').drop ⟹ α} {f₁' : (P.B a').last → M P α}\n  (e₁ : M_dest P ⟨a₁, f₁⟩ = ⟨a', split_fun f' f₁'⟩) :\n  ∃ g₁' (e₁' : pfunctor.M_dest a₁ = ⟨a', g₁'⟩),\n    f' = M_path_dest_left P e₁' f₁ ∧\n    f₁' = λ (x : (last P).B a'),\n      ⟨g₁' x, M_path_dest_right P e₁' f₁ x⟩ :=\nbegin\n  generalize_hyp ef : @split_fun n _ (append1 α (M P α)) f' f₁' = ff at e₁,\n  cases e₁' : pfunctor.M_dest a₁ with a₁' g₁',\n  rw M_dest_eq_dest' _ e₁' at e₁,\n  cases e₁, exact ⟨_, e₁', split_fun_inj ef⟩,\nend\n\ntheorem M_bisim {α : typevec n} (R : P.M α → P.M α → Prop)\n  (h : ∀ x y, R x y → ∃ a f f₁ f₂,\n    P.M_dest x = ⟨a, split_fun f f₁⟩ ∧\n    P.M_dest y = ⟨a, split_fun f f₂⟩ ∧\n    ∀ i, R (f₁ i) (f₂ i))\n  (x y) (r : R x y) : x = y :=\nbegin\n  cases x with a₁ f₁,\n  cases y with a₂ f₂,\n  dsimp [Mp] at *,\n  have : a₁ = a₂, {\n    refine pfunctor.M_bisim\n      (λ a₁ a₂, ∃ x y, R x y ∧ x.1 = a₁ ∧ y.1 = a₂) _ _ _\n      ⟨⟨a₁, f₁⟩, ⟨a₂, f₂⟩, r, rfl, rfl⟩,\n    rintro _ _ ⟨⟨a₁, f₁⟩, ⟨a₂, f₂⟩, r, rfl, rfl⟩,\n    rcases h _ _ r with ⟨a', f', f₁', f₂', e₁, e₂, h'⟩,\n    rcases M_bisim_lemma P e₁ with ⟨g₁', e₁', rfl, rfl⟩,\n    rcases M_bisim_lemma P e₂ with ⟨g₂', e₂', _, rfl⟩,\n    rw [e₁', e₂'],\n    exact ⟨_, _, _, rfl, rfl, λ b, ⟨_, _, h' b, rfl, rfl⟩⟩ },\n  subst this, congr, ext i p,\n  induction p with x a f h' i c x a f h' i c p IH generalizing f₁ f₂;\n  try {\n    rcases h _ _ r with ⟨a', f', f₁', f₂', e₁, e₂, h''⟩,\n    rcases M_bisim_lemma P e₁ with ⟨g₁', e₁', rfl, rfl⟩,\n    rcases M_bisim_lemma P e₂ with ⟨g₂', e₂', e₃, rfl⟩,\n    cases h'.symm.trans e₁',\n    cases h'.symm.trans e₂' },\n  { exact (congr_fun (congr_fun e₃ i) c : _) },\n  { exact IH _ _ (h'' _) }\nend\n\ntheorem M_dest_map {α β : typevec n} (g : α ⟹ β) (x : P.M α) :\n  P.M_dest (g <$$> x) = append_fun g (λ x, g <$$> x) <$$> P.M_dest x :=\nbegin\n  cases x with a f,\n  rw map_eq,\n  conv { to_rhs, rw [M_dest, M_dest', map_eq, append_fun_comp_split_fun] },\n  reflexivity\nend\n\nend mvpfunctor\n", "meta": {"author": "avigad", "repo": "qpf", "sha": "debe2eacb8cf46b21aba2eaf3f2e20940da0263b", "save_path": "github-repos/lean/avigad-qpf", "path": "github-repos/lean/avigad-qpf/qpf-debe2eacb8cf46b21aba2eaf3f2e20940da0263b/src/mvpfunctor/M.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4625918616115391}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\n\nimport Mathlib\n\n/-!\n# Inductive type variant of `Fin`\n\n`Fin` is defined as a subtype of `Nat`. This file defines an equivalent type, `PFin2`, which is\ndefined inductively, and is universe polymorphic. This is useful for its induction principle and \ndifferent definitional equalities.\n\n\n## Main declarations\n\n* `PFin2 n`: Inductive and universe polymorphic type variant of `Fin n`. `fz` corresponds to `0` and \n  `fs n` corresponds to `n`.\n* `Fin2 n`: shorthand for `PFin2.{0} n`, i.e., it lives in `Type`\n* `toNat`, `optOfNat`, `ofNat'`: Conversions to and from `Nat`. `ofNat' m` takes a proof that\n  `m < n` through the class `is_lt`.\n* `add k`: Takes `i : PFin2 n` to `i + k : PFin2 (n + k)`.\n* `left`: Embeds `PFin2 n` into `PFin2 (n + k)`.\n* `insertPerm a`: Permutation of `PFin2 n` which cycles `0, ..., a - 1` and leaves `a, ..., n - 1`\n  unchanged.\n* `remapLeft f`: Function `PFin2 (m + k) → PFin2 (n + k)` by applying `f : PFin2 m → PFin2 n` to\n  `0, ..., m - 1` and sending `m + i` to `n + i`.\n-/\n\n\nopen Nat\n\nuniverse u\n\n/-- An alternate definition of `fin n` defined as an inductive type instead of a subtype of `Nat`. -/\ninductive PFin2 : Nat → Type u\n  | /-- `0` as a member of `fin (succ n)` (`fin 0` is empty) -/\n  fz {n} : PFin2 (succ n)\n  | /-- `n` as a member of `fin (succ n)` -/\n  fs {n} : PFin2 n → PFin2 (succ n)\n  deriving DecidableEq\n\nnamespace PFin2\n\n/-- Define a dependent function on `PFin2 (succ n)` by giving its value at\nzero (`H1`) and by giving a dependent function on the rest (`H2`). -/\n-- @[elab_as_eliminator]\nprotected def cases' {n} {C : PFin2 (succ n) → Sort u} (H1 : C fz) (H2 : ∀ n, C (fs n)) : ∀ i : PFin2 (succ n), C i\n  | fz => H1\n  | fs n => H2 n\n\n/-- Ex falso. The dependent eliminator for the empty `PFin2 0` type. -/\ndef elim0 {C : PFin2 0 → Sort u} : ∀ i : PFin2 0, C i :=\n  by intro i; cases i\n\n/-- Converts a `PFin2` into a natural. -/\ndef toNat : ∀ {n}, PFin2 n → Nat\n  | _, @fz n => 0\n  | _, @fs n i => succ (toNat i)\n\n/-- Shows that `toNat` produces a natural withing the range -/\ntheorem toNat_in_range (i : PFin2 n) :\n  i.toNat < n :=\nby\n  induction i\n  case fz       => apply succ_pos\n  case fs _ ih  => apply lt_succ_of_le ih\n\n/-- Converts a `PFin2` into the a `Fin` -/\ndef toFin : PFin2 n → Fin n\n  := fun i => ⟨i.toNat, toNat_in_range i⟩\n\n\n/-- Converts a natural into a `PFin2` if it is in range -/\ndef optOfNat : ∀ {n} (k : Nat), Option (PFin2 n)\n  | 0, _ => none\n  | succ n, 0 => some fz\n  | succ n, succ k => fs <$> @optOfNat n k\n\n/-- Converts a natural into a `PFin2` given a proof that it is in range -/\ndef ofNatLt : ∀ {n} (k : Nat) (h : k < n), PFin2 n\n  | 0, _, h            => by contradiction\n  | succ n, 0, h       => fz\n  | succ n, succ k, h  => fs $ @ofNatLt n k (lt_of_succ_lt_succ h)\n\n\n/-- Converts a `Fin` into a `PFin2` -/\ndef ofFin : Fin n → PFin2 n\n  := fun ⟨i, h⟩ => ofNatLt i h\n\n\n/-- `i + k : PFin2 (n + k)` when `i : PFin2 n` and `k : Nat` -/\ndef add {n} (i : PFin2 n) : ∀ k, PFin2 (n + k)\n  | 0 => i\n  | succ k => fs (add i k)\n\n/-- `left k` is the embedding `PFin2 n → PFin2 (k + n)` -/\ndef left k : ∀ {n}, PFin2 n → PFin2 (k + n)\n  | _, @fz n => fz\n  | _, @fs n i => fs (left k i)\n\n/-- `insertPerm a` is a permutation of `PFin2 n` with the following properties:\n  * `insertPerm a i = i+1` if `i < a`\n  * `insertPerm a a = 0`\n  * `insertPerm a i = i` if `i > a` -/\ndef insertPerm : ∀ {n}, PFin2 n → PFin2 n → PFin2 n\n  | _, @fz n, @fz _ => fz\n  | _, @fz n, @fs _ j => fs j\n  | _, @fs (succ n) i, @fz _ => fs fz\n  | _, @fs (succ n) i, @fs _ j =>\n    match insertPerm i j with\n    | fz => fz\n    | fs k => fs (fs k)\n\n/-- `remapLeft f k : PFin2 (m + k) → PFin2 (n + k)` applies the function\n  `f : PFin2 m → PFin2 n` to inputs less than `m`, and leaves the right part\n  on the right (that is, `remapLeft f k (m + i) = n + i`). -/\ndef remapLeft {m n} (f : PFin2 m → PFin2 n) : ∀ k, PFin2 (m + k) → PFin2 (n + k)\n  | 0, i => f i\n  | succ k, @fz _ => fz\n  | succ k, @fs _ i => fs (remapLeft f _ i)\n\n/-- This is a simple type class inference prover for proof obligations\n  of the form `m < n` where `m n : Nat`. -/\nclass IsLt (m n : Nat) where\n  h : m < n\n\ninstance IsLt.zero n : IsLt 0 (succ n) :=\n  ⟨succ_pos _⟩\n\ninstance IsLt.succ m n [l : IsLt m n] : IsLt (succ m) (succ n) :=\n  ⟨succ_lt_succ l.h⟩\n\n/-- Use type class inference to infer the boundedness proof, so that we can directly convert a\n`nat` into a `PFin2 n`. This supports notation like `&1 : fin 3`. -/\ndef ofNat' : ∀ {n} m [IsLt m n], PFin2 n\n  | 0, m, ⟨h⟩ => absurd h (Nat.not_lt_zero _)\n  | succ n, 0, ⟨h⟩ => fz\n  | succ n, succ m, ⟨h⟩ => fs (@ofNat' n m ⟨lt_of_succ_lt_succ h⟩)\n\n-- mathport name: «expr& »\nlocal prefix:arg \"&\" => ofNat'\n\ninstance : Inhabited (PFin2 1) :=\n  ⟨fz⟩\n\n/-- There is only one function with empty domain `PFin2 0` -/\ndef eq_fn0 {α} (f g : PFin2 0 → α) : f = g := \nby funext i; cases i\n\n/-- There is only one function with empty domain `PFin2 0`\n    We take `PFin2.elim0` to be the \"normalized\" such function\n -/ \n@[simp] def eq_fn0_elim0 {α} (f g : PFin2 0 → α) : f = PFin2.elim0\n  := by apply eq_fn0\n\n\n/--\n  Try to lower the bound on some `PFin2`, which fails iff the value is equal to the upper bound\n-/\ndef strengthen : ∀{n}, PFin2 (succ n) → Option (PFin2 n)\n  | 0, _            => none\n  | (succ n), fz    => some fz\n  | (succ n), fs k  => fs <$> strengthen k\n\n\n/--\n  Weakens the bound on a `PFin2`, without changing the value\n-/\ndef weaken : PFin2 n → PFin2 (succ n)\n  | fz   => fz\n  | fs k => fs $ weaken k\n\n/--\n  Decrements a `PFin2` by one, simultaneously lowering the bound\n-/\ndef decr : PFin2 (Nat.succ $ Nat.succ n) → PFin2 (Nat.succ n)\n  | fz    => fz\n  | fs j  => j\n\n/--\n  The maximal element of `PFin2 (n+1)`, i.e., `n`\n-/\ndef last : {n : Nat} → PFin2 (n+1) \n  | 0   => fz\n  | n+1 => fs (@last n)\n\n/--\n  The inverse of `i` w.r.t. addition modulo `n`, i.e., .last - i\n-/\ndef inv : {n : Nat} → PFin2.{u} n → PFin2.{u} n\n  | 0,    _     => by contradiction\n  | 1,    .fs _ => by contradiction\n  | n+1,  .fz   => last\n  | n+2,  .fs i => i.inv.weaken\n\n\n@[simp]\ntheorem strengthen_last_is_none {n : Nat} :\n  (@last n).strengthen = none :=\nby\n  induction n;\n  simp [last]\n  simp [strengthen, last, *]\n\n\ntheorem strengthen_is_none_imp_eq_last {n : Nat} {i : PFin2 (n+1)} :\n  i.strengthen = none → i = last :=\nby\n  induction n;\n  . cases i;\n    . simp [strengthen]\n    . intros; contradiction\n  case succ n ih => \n    simp [strengthen, last, *]\n    cases i\n    case fz => simp [strengthen]\n    case fs i =>\n      simp [strengthen, last]\n      apply ih;\n  \n\ntheorem strengthen_toNat_eq {n : Nat} {i : PFin2 (n+1)} {k : PFin2 n} :\n  i.strengthen = some k → i.toNat = k.toNat :=\nby \n  intro h;\n  induction k\n  <;> cases i\n  . simp [toNat]\n  . simp [strengthen] at h\n  . simp [strengthen] at h\n  . simp [strengthen] at h\n    simp [toNat, *]\n\n\n@[simp]\ntheorem strengthen_weaken_is_some {n : Nat} {i : PFin2 n} :\n  i.weaken.strengthen = some i :=\nby\n  induction i\n  <;> simp [weaken, strengthen, *]\n\ntheorem weaken_strengthen_of_some {n : Nat} {i : PFin2 (n+1)} {k : PFin2 n} :\n  i.strengthen = some k → k.weaken = i :=\nby\n  induction k\n  <;> cases i\n  <;> simp [weaken, strengthen, *]\n  case fs ih _ => {\n    apply ih\n  }\n\n\n@[simp]\ntheorem weaken_to_nat_eq_to_nat {n : Nat} (i : PFin2 n) :\n  i.weaken.toNat = i.toNat :=\nby \n  induction i;\n  case fz => rfl\n  case fs ih =>\n    simp [weaken, toNat, ih];\n\ntheorem eq_of_to_nat_eq {n : Nat} (i j : PFin2 n) :\n  i.toNat = j.toNat → i = j :=\nby\n  induction i\n  <;> cases j\n  <;> simp [toNat]\n  case fs x ih y  => {\n    apply ih;\n  }\n\n\ntheorem inv_last_eq_fz {n : Nat} :\n  (@last n).inv = .fz :=\nby\n  induction n <;> simp [inv, last, weaken, *]\n\ntheorem inv_weaken_eq_fs_inv {n : Nat} (i : PFin2 n):\n  inv (weaken  i) = .fs (inv i) :=\nby\n  induction i\n  <;> simp[inv, weaken, last]\n  case fs n i ih =>\n    simp[ih]\n    cases n\n    . contradiction\n    . simp[inv, weaken]\n    \n\n@[simp]\ntheorem inv_involution {i : PFin2 n} :\n  i.inv.inv = i :=\nby\n    induction i\n    <;> simp[inv]\n    case fz => apply inv_last_eq_fz\n    case fs n i ih => {\n      cases n;\n      case zero => contradiction\n      case succ n =>\n        simp[inv]\n        rw[inv_weaken_eq_fs_inv i.inv]\n        apply congrArg\n        apply ih\n    }\n\n\n    -- case zero.fs => contradiction\n    -- case succ.fs => simp[inv_last_eq_fz, weaken]\n\n\n/--\n  Typeclass instances to make it easier to work with `PFin2`'s\n-/\n@[simp]\ninstance (n : Nat) : OfNat (PFin2 (n+1)) (nat_lit 0) := ⟨fz⟩\ninstance (n : Nat) : OfNat (PFin2 (n+2)) (nat_lit 1) := ⟨fs 0⟩\ninstance (n : Nat) : OfNat (PFin2 (n+3)) (nat_lit 2) := ⟨fs 1⟩\n\n\n/-\n  ## LT / LE\n-/\ninstance instOrd (n : Nat) : Ord (PFin2 n) where\n  compare := (compare ·.toNat ·.toNat)\n\ninstance instLT {n : Nat} : LT (PFin2 n) := ⟨(Nat.lt ·.toNat ·.toNat)⟩\ninstance instLE {n : Nat} : LE (PFin2 n) := ⟨(Nat.le ·.toNat ·.toNat)⟩\n\ninstance decidable_lt (n : Nat) : DecidableRel (@LT.lt (PFin2 n) instLT) := fun a b =>\n    let d : Decidable (a.toNat < b.toNat) := by infer_instance\n    match d with\n    | isTrue h  => isTrue  $ by assumption\n    | isFalse h => isFalse $ by intro a_lt_b; apply h a_lt_b\n\ninstance decidable_le {n : Nat} : DecidableRel (@LE.le (PFin2 n) instLE) := fun a b =>\n    let d : Decidable (a.toNat ≤ b.toNat) := by infer_instance\n    match d with\n    | isTrue h  => isTrue  $ by assumption\n    | isFalse h => isFalse $ by intro a_le_b; apply h a_le_b\n\ninstance instLinOrd : LinearOrder (PFin2 n) where  \n  le_refl _             := by apply Nat.le_refl;\n  le_trans _ _ _        := by apply Nat.le_trans;\n  lt_iff_le_not_le _ _  := by simp[LT.lt, LE.le]; exact le_of_lt\n  le_antisymm x y h₁ h₂ := by simp[LE.le] at h₁ h₂;\n                              suffices toNat x = toNat y\n                              from by clear h₁ h₂;\n                                      induction x \n                                      <;> cases y\n                                      <;> simp[toNat] at this;\n                                      rfl;\n                                      case fs x ih y => {\n                                        simp;\n                                        apply ih;\n                                        apply this;\n                                      }\n                              apply Nat.le_antisymm h₁ h₂\n  le_total _ _          := by apply Nat.le_total\n  decidable_le          := decidable_le\n\ndef le_refl {n : Nat} : \n  ∀ (x : PFin2 n), x ≤ x := \n  instLinOrd.le_refl\n\ndef le_trans {n : Nat} : \n  ∀ (x y z : PFin2 n), x ≤ y → y ≤ z → x ≤ z \n:= instLinOrd.le_trans\n\ndef lt_iff_le_not_le : \n  ∀ (x y : PFin2 n), x < y ↔ x ≤ y ∧ ¬y ≤ x \n:= instLinOrd.lt_iff_le_not_le\n\ndef le_antisymm : \n  ∀ (x y : PFin2 n), x ≤ y → y ≤ x → x = y\n:= instLinOrd.le_antisymm\n\ndef le_total :\n  ∀ (x y : PFin2 n), x ≤ y ∨ y ≤ x\n:= instLinOrd.le_total\n\ndef lt_trichotomy {n : Nat}  : \n  ∀(a b : PFin2 n), a < b ∨ a = b ∨ b < a\n:= _root_.lt_trichotomy\n\ndef zero_le {n : Nat} (i : PFin2 (n+1)) :\n  .fz ≤ i :=\nby\n  simp [LE.le, toNat];\n  apply Nat.zero_le\n\n\ntheorem last_is_maximal {n : Nat} (i : PFin2 (n+1)) :\n  i ≤ last :=\nby\n  induction n;\n  case zero =>\n    cases i;\n    . simp;\n    . contradiction\n  case succ n ih =>\n    cases i;\n    . simp [LE.le, toNat]\n      apply Nat.zero_le \n    . simp [LE.le, toNat] at ih\n      apply Nat.succ_le_succ\n      apply ih\n\n\n@[simp]\ntheorem strengthen_is_some_of_lt {n : Nat} {i j : PFin2 (n+1)} :\n  i < j → ∃k, i.strengthen = some k :=\nby\n  intro lt;\n  cases h : strengthen i;\n  case some => simp\n  case none =>\n    have : i = last := by apply strengthen_is_none_imp_eq_last h;\n    cases this;\n    have : j ≤ last   := by apply last_is_maximal;\n    have : ¬ last < j := by simp[this];\n    contradiction\n\n\n\n  def ofFin2 : Fin2 n → PFin2 n\n    | .fz   => .fz\n    | .fs i => .fs <| ofFin2 i\n\n  def toFin2 : PFin2 n → Fin2 n\n    | .fz   => .fz\n    | .fs i => .fs <| toFin2 i\n\n  @[simp]\n  theorem ofFin2_toFin2_iso {i : Fin2 n} :\n    (toFin2 <| ofFin2 i) = i :=\n  by \n    induction i\n    . rfl\n    . simp [ofFin2, toFin2, *]\n\n  @[simp]\n  theorem toFin2_ofFin2_iso {i : PFin2 n} :\n    (ofFin2 <| toFin2 i) = i :=\n  by \n    induction i\n    . rfl\n    . simp [ofFin2, toFin2, *]\n\n  instance : Coe (Fin2 n) (PFin2 n) := ⟨ofFin2⟩\n  instance : Coe (PFin2 n) (Fin2 n) := ⟨toFin2⟩\n\n  instance : Coe (PFin2 n) (Fin n) := ⟨toFin⟩\n  instance : Coe (Fin n) (PFin2 n) := ⟨ofFin⟩\n\n  instance : Coe (Fin n) (Fin2 n) := ⟨fun i => toFin2 <| ofFin.{0} i⟩\n  instance : Coe (Fin2 n) (Fin n) := ⟨fun i => toFin <| ofFin2.{0} i⟩\n\nend PFin2\n\n\nnamespace Fin2\n  /--\n  Typeclass instances to make it easier to work with `PFin2`'s\n-/\n@[simp]\ninstance (n : Nat) : OfNat (Fin2 (n+1)) (nat_lit 0) := ⟨fz⟩\ninstance (n : Nat) : OfNat (Fin2 (n+2)) (nat_lit 1) := ⟨fs 0⟩\ninstance (n : Nat) : OfNat (Fin2 (n+3)) (nat_lit 2) := ⟨fs 1⟩\n\n  def inv : Fin2 n → Fin2 n\n    := fun i => (PFin2.inv.{0} i : PFin2 n)\n\nend Fin2", "meta": {"author": "alexkeizer", "repo": "qpf4", "sha": "980f97425b9d5a5e3897073df33794192b3b3124", "save_path": "github-repos/lean/alexkeizer-qpf4", "path": "github-repos/lean/alexkeizer-qpf4/qpf4-980f97425b9d5a5e3897073df33794192b3b3124/Qpf/MathlibPort/Fin2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.46259186161153903}}
{"text": "import tutorial_world.level15_simp -- hide\nopen IncidencePlane -- hide\n\n/- Tactic : exfalso\n\n## Summary\n\nChanges the goal to `⊢ false`.\n\n## Details\n\nThis may seem hard to prove,\nbut it is useful when we have a contradiction in the hypotheses.\n\nFor example, if we have `h : ¬ P` as a hypothesis and we apply `exfalso`\nwe can then `apply h` to transform the goal into `⊢ P`.\n-/\n\n\n/-\n# Tutorial World\n\n## Level 16: the `exfalso` tactic. \n\nIn this level we introduce the new tactic `exfalso`. It satifies the **Principle of explosion** of classical logic, \naccording to which any statement can be proven from a contradiction. In Lean, if we type `exfalso`, the goal will turn\ninto `⊢ false`. Let's solve this level to see how it works! \n\nDelete the `sorry` and take a look at the hypothesis `h`, according to which the point P is not an element of the line \nthat passes through the points P and Q. This is a contradiction that can be rewritten as `¬ (P ∈ line_through P Q)`, where \nthe symbol **¬** means \"not\". Moreover, it can also be rewritten as `P ∈ line_through P Q → false`. This last way of representing\nthe contradiction is key to complete this level. By typing `exfalso`, we know that the goal will change into `⊢ false`. Then, look\nfor a tactic that can turn the goal into `⊢ P ∈ line_through P Q` and you will be almost done! In case you get stuck, click right below for a hint.\n-/\n\n/- Hint : Click here for a hint, in case you get stuck.\nThe `apply` tactic changes the goal from `⊢ Q` to `⊢ P` when we have a hypothesis of the form `h : P → Q`. In this case, `h : P ∉ line_through P Q`\ncan be interpreted as `P ∈ line_through P Q → false`. Then, because the goal is `⊢ false', `apply h,` will make progress. Still bewildered? Click on \"View source\" \n(located on the top right corner of the game screen) to see the solution. \n-/\n\nvariables {Ω : Type} [IncidencePlane Ω] --hide\n\n/- Lemma : no-side-bar\nProve that 2+2 is 5, using a false hypothesis.\n-/\nlemma two_plus_two_equals_five (P Q : Ω) (h: P ∉ line_through P Q) : 2 + 2 = 5:=\nbegin\n\n  exfalso,\n  apply h,\n  exact line_through_left P Q,\n  \nend \n", "meta": {"author": "luisscastillo", "repo": "lean-game", "sha": "44c454ca6f4dcb8de76401790cf3f4fa91738fc1", "save_path": "github-repos/lean/luisscastillo-lean-game", "path": "github-repos/lean/luisscastillo-lean-game/lean-game-44c454ca6f4dcb8de76401790cf3f4fa91738fc1/src/tutorial_world/level16_exfalso.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.4625918564066458}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport algebraic_topology.dold_kan.decomposition\nimport tactic.fin_cases\n\n/-!\n\n# Behaviour of P_infty with respect to degeneracies\n\nFor any `X : simplicial_object C` where `C` is an abelian category,\nthe projector `P_infty : K[X] ⟶ K[X]` is supposed to be the projection\non the normalized subcomplex, parallel to the degenerate subcomplex, i.e.\nthe subcomplex generated by the images of all `X.σ i`.\n\nIn this file, we obtain `degeneracy_comp_P_infty` which states that\nif `X : simplicial_object C` with `C` a preadditive category,\n`θ : [n] ⟶ Δ'` is a non injective map in `simplex_category`, then\n`X.map θ.op ≫ P_infty.f n = 0`. It follows from the more precise\nstatement vanishing statement `σ_comp_P_eq_zero` for the `P q`.\n\n-/\n\nopen category_theory category_theory.category category_theory.limits\n  category_theory.preadditive opposite\nopen_locale simplicial dold_kan\n\nnamespace algebraic_topology\n\nnamespace dold_kan\n\nvariables {C : Type*} [category C] [preadditive C]\n\nlemma higher_faces_vanish.comp_σ {Y : C} {X : simplicial_object C} {n b q : ℕ} {φ : Y ⟶ X _[n+1]}\n  (v : higher_faces_vanish q φ) (hnbq : n + 1 = b + q) :\n    higher_faces_vanish q (φ ≫ X.σ ⟨b,\n    by simpa only [hnbq, nat.lt_succ_iff, le_add_iff_nonneg_right] using zero_le q⟩) :=\nλ j hj, begin\n  rw [assoc, simplicial_object.δ_comp_σ_of_gt', fin.pred_succ,\n    v.comp_δ_eq_zero_assoc _ _ hj, zero_comp],\n  { intro hj',\n    simpa only [hj', hnbq, fin.coe_zero, zero_add, add_comm b, add_assoc, false_and,\n      add_le_iff_nonpos_right, le_zero_iff, add_eq_zero_iff, nat.one_ne_zero] using hj, },\n  { simp only [fin.lt_iff_coe_lt_coe, nat.lt_iff_add_one_le,\n      fin.succ_mk, fin.coe_mk, fin.coe_succ, add_le_add_iff_right],\n    linarith, },\nend\n\nlemma σ_comp_P_eq_zero (X : simplicial_object C)\n  {n q : ℕ} (i : fin (n + 1)) (hi : n + 1 ≤ i + q) : (X.σ i) ≫ (P q).f (n + 1) = 0 :=\nbegin\n  induction q with q hq generalizing i hi,\n  { exfalso,\n    have h := fin.is_lt i,\n    linarith, },\n  { by_cases n+1 ≤ (i : ℕ) + q,\n    { unfold P,\n      simp only [homological_complex.comp_f, ← assoc],\n      rw [hq i h, zero_comp], },\n    { have hi' : n = (i : ℕ) + q,\n      { cases le_iff_exists_add.mp hi with j hj,\n        rw [← nat.lt_succ_iff, nat.succ_eq_add_one, add_assoc, hj, not_lt,\n          add_le_iff_nonpos_right, nonpos_iff_eq_zero] at h,\n        rw [← add_left_inj 1, add_assoc, hj, self_eq_add_right, h], },\n      cases n,\n      { fin_cases i,\n        rw [show q = 0, by linarith],\n        unfold P,\n        simp only [id_comp, homological_complex.add_f_apply, comp_add, homological_complex.id_f,\n          Hσ, homotopy.null_homotopic_map'_f (c_mk 2 1 rfl) (c_mk 1 0 rfl),\n          alternating_face_map_complex.obj_d_eq],\n        erw [hσ'_eq' (zero_add 0).symm, hσ'_eq' (add_zero 1).symm, comp_id,\n          fin.sum_univ_two, fin.sum_univ_succ, fin.sum_univ_two],\n        simp only [pow_zero, pow_one, pow_two, fin.coe_zero, fin.coe_one, fin.coe_two,\n          one_zsmul, neg_zsmul, fin.mk_zero, fin.mk_one, fin.coe_succ, pow_add, one_mul,\n          neg_mul, neg_neg, fin.succ_zero_eq_one, fin.succ_one_eq_two, comp_neg, neg_comp,\n          add_comp, comp_add],\n        erw [simplicial_object.δ_comp_σ_self, simplicial_object.δ_comp_σ_self_assoc,\n          simplicial_object.δ_comp_σ_succ, comp_id, simplicial_object.δ_comp_σ_of_le X\n            (show (0 : fin(2)) ≤ fin.cast_succ 0, by rw fin.cast_succ_zero),\n          simplicial_object.δ_comp_σ_self_assoc, simplicial_object.δ_comp_σ_succ_assoc],\n        abel, },\n      { rw [← id_comp (X.σ i), ← (P_add_Q_f q n.succ : _ = 𝟙 (X.obj _)), add_comp, add_comp],\n        have v : higher_faces_vanish q ((P q).f n.succ ≫ X.σ i) :=\n          (higher_faces_vanish.of_P q n).comp_σ hi',\n        unfold P,\n        erw [← assoc, v.comp_P_eq_self, homological_complex.add_f_apply,\n          preadditive.comp_add, comp_id, v.comp_Hσ_eq hi', assoc,\n          simplicial_object.δ_comp_σ_succ'_assoc, fin.eta,\n          decomposition_Q n q, sum_comp, sum_comp, finset.sum_eq_zero, add_zero,\n          add_neg_eq_zero], swap,\n        { ext, simp only [fin.coe_mk, fin.coe_succ], },\n        { intros j hj,\n          simp only [true_and, finset.mem_univ, finset.mem_filter] at hj,\n          simp only [nat.succ_eq_add_one] at hi',\n          obtain ⟨k, hk⟩ := nat.le.dest (nat.lt_succ_iff.mp (fin.is_lt j)),\n          rw add_comm at hk,\n          have hi'' : i = fin.cast_succ ⟨i, by linarith⟩ :=\n            by { ext, simp only [fin.cast_succ_mk, fin.eta], },\n          have eq := hq j.rev.succ begin\n            simp only [← hk, fin.rev_eq j hk.symm, nat.succ_eq_add_one, fin.succ_mk, fin.coe_mk],\n            linarith,\n          end,\n          rw [homological_complex.comp_f, assoc, assoc, assoc, hi'',\n            simplicial_object.σ_comp_σ_assoc, reassoc_of eq, zero_comp, comp_zero,\n            comp_zero, comp_zero],\n          simp only [fin.rev_eq j hk.symm, fin.le_iff_coe_le_coe, fin.coe_mk],\n          linarith, }, }, }, }\nend\n\n@[simp, reassoc]\nlemma σ_comp_P_infty (X : simplicial_object C) {n : ℕ} (i : fin (n+1)) :\n  (X.σ i) ≫ P_infty.f (n+1) = 0 :=\nbegin\n  rw [P_infty_f, σ_comp_P_eq_zero X i],\n  simp only [le_add_iff_nonneg_left, zero_le],\nend\n\n@[reassoc]\nlemma degeneracy_comp_P_infty (X : simplicial_object C)\n  (n : ℕ) {Δ' : simplex_category} (θ : [n] ⟶ Δ') (hθ : ¬mono θ) :\n  X.map θ.op ≫ P_infty.f n = 0 :=\nbegin\n  rw simplex_category.mono_iff_injective at hθ,\n  cases n,\n  { exfalso,\n    apply hθ,\n    intros x y h,\n    fin_cases x,\n    fin_cases y, },\n  { obtain ⟨i, α, h⟩ := simplex_category.eq_σ_comp_of_not_injective θ hθ,\n    rw [h, op_comp, X.map_comp, assoc, (show X.map (simplex_category.σ i).op = X.σ i, by refl),\n      σ_comp_P_infty, comp_zero], },\nend\n\nend dold_kan\n\nend algebraic_topology\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebraic_topology/dold_kan/degeneracies.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4625918545300072}}
{"text": "import .definitions2 .qi .soundness\n\n-- This theorem states that any proposition `P` that is valid with instantiations `⟪ P ⟫` \n-- is also a valid proposition without quantifier instantiation `⦃ P ⦄`:\ntheorem vc_valid_without_instantiations (P: prop):\n  ⟪ P ⟫ → ⦃ P ⦄\n\n  := @vc_valid_from_inst_valid P -- actual proof in qi.lean\n\n\n-- This theorem states that a verified source program `e` does not get stuck,\n-- i.e. its evaluation always results either in a value or in a runtime stack `s` that can be\n-- further evaluated. The proof internally uses lemmas for progress and preservation.\ntheorem verification_safety (e: exp) (s: stack) (Q: propctx):\n  (value.true ⊢ e: Q) → ((env.empty, e) ⟶* s) → (is_value s ∨ ∃s', s ⟶ s')\n  \n  := @soundness_source_programs e s Q -- actual proof in soundness.lean\n", "meta": {"author": "levjj", "repo": "esverify-theory", "sha": "8565b123c87b0113f83553d7732cd6696c9b5807", "save_path": "github-repos/lean/levjj-esverify-theory", "path": "github-repos/lean/levjj-esverify-theory/esverify-theory-8565b123c87b0113f83553d7732cd6696c9b5807/src/theorems.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.4625580844596068}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Sean Leather\n\n! This file was ported from Lean 3 source module data.list.sigma\n! leanprover-community/mathlib commit f808feb6c18afddb25e66a71d317643cf7fb5fbb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.List.Range\nimport Mathbin.Data.List.Perm\n\n/-!\n# Utilities for lists of sigmas\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file includes several ways of interacting with `list (sigma β)`, treated as a key-value store.\n\nIf `α : Type*` and `β : α → Type*`, then we regard `s : sigma β` as having key `s.1 : α` and value\n`s.2 : β s.1`. Hence, `list (sigma β)` behaves like a key-value store.\n\n## Main Definitions\n\n- `list.keys` extracts the list of keys.\n- `list.nodupkeys` determines if the store has duplicate keys.\n- `list.lookup`/`lookup_all` accesses the value(s) of a particular key.\n- `list.kreplace` replaces the first value with a given key by a given value.\n- `list.kerase` removes a value.\n- `list.kinsert` inserts a value.\n- `list.kunion` computes the union of two stores.\n- `list.kextract` returns a value with a given key and the rest of the values.\n-/\n\n\nuniverse u v\n\nnamespace List\n\nvariable {α : Type u} {β : α → Type v} {l l₁ l₂ : List (Sigma β)}\n\n/-! ### `keys` -/\n\n\n#print List.keys /-\n/-- List of keys from a list of key-value pairs -/\ndef keys : List (Sigma β) → List α :=\n  map Sigma.fst\n#align list.keys List.keys\n-/\n\n#print List.keys_nil /-\n@[simp]\ntheorem keys_nil : @keys α β [] = [] :=\n  rfl\n#align list.keys_nil List.keys_nil\n-/\n\n#print List.keys_cons /-\n@[simp]\ntheorem keys_cons {s} {l : List (Sigma β)} : (s :: l).keys = s.1 :: l.keys :=\n  rfl\n#align list.keys_cons List.keys_cons\n-/\n\n#print List.mem_keys_of_mem /-\ntheorem mem_keys_of_mem {s : Sigma β} {l : List (Sigma β)} : s ∈ l → s.1 ∈ l.keys :=\n  mem_map_of_mem Sigma.fst\n#align list.mem_keys_of_mem List.mem_keys_of_mem\n-/\n\n#print List.exists_of_mem_keys /-\ntheorem exists_of_mem_keys {a} {l : List (Sigma β)} (h : a ∈ l.keys) :\n    ∃ b : β a, Sigma.mk a b ∈ l :=\n  let ⟨⟨a', b'⟩, m, e⟩ := exists_of_mem_map h\n  Eq.recOn e (Exists.intro b' m)\n#align list.exists_of_mem_keys List.exists_of_mem_keys\n-/\n\n#print List.mem_keys /-\ntheorem mem_keys {a} {l : List (Sigma β)} : a ∈ l.keys ↔ ∃ b : β a, Sigma.mk a b ∈ l :=\n  ⟨exists_of_mem_keys, fun ⟨b, h⟩ => mem_keys_of_mem h⟩\n#align list.mem_keys List.mem_keys\n-/\n\n#print List.not_mem_keys /-\ntheorem not_mem_keys {a} {l : List (Sigma β)} : a ∉ l.keys ↔ ∀ b : β a, Sigma.mk a b ∉ l :=\n  (not_congr mem_keys).trans not_exists\n#align list.not_mem_keys List.not_mem_keys\n-/\n\n#print List.not_eq_key /-\ntheorem not_eq_key {a} {l : List (Sigma β)} : a ∉ l.keys ↔ ∀ s : Sigma β, s ∈ l → a ≠ s.1 :=\n  Iff.intro (fun h₁ s h₂ e => absurd (mem_keys_of_mem h₂) (by rwa [e] at h₁)) fun f h₁ =>\n    let ⟨b, h₂⟩ := exists_of_mem_keys h₁\n    f _ h₂ rfl\n#align list.not_eq_key List.not_eq_key\n-/\n\n/-! ### `nodupkeys` -/\n\n\n#print List.NodupKeys /-\n/-- Determines whether the store uses a key several times. -/\ndef NodupKeys (l : List (Sigma β)) : Prop :=\n  l.keys.Nodup\n#align list.nodupkeys List.NodupKeys\n-/\n\n#print List.nodupKeys_iff_pairwise /-\ntheorem nodupKeys_iff_pairwise {l} : NodupKeys l ↔ Pairwise (fun s s' : Sigma β => s.1 ≠ s'.1) l :=\n  pairwise_map' _\n#align list.nodupkeys_iff_pairwise List.nodupKeys_iff_pairwise\n-/\n\n#print List.NodupKeys.pairwise_ne /-\ntheorem NodupKeys.pairwise_ne {l} (h : NodupKeys l) :\n    Pairwise (fun s s' : Sigma β => s.1 ≠ s'.1) l :=\n  nodupKeys_iff_pairwise.1 h\n#align list.nodupkeys.pairwise_ne List.NodupKeys.pairwise_ne\n-/\n\n#print List.nodupKeys_nil /-\n@[simp]\ntheorem nodupKeys_nil : @NodupKeys α β [] :=\n  Pairwise.nil\n#align list.nodupkeys_nil List.nodupKeys_nil\n-/\n\n#print List.nodupKeys_cons /-\n@[simp]\ntheorem nodupKeys_cons {s : Sigma β} {l : List (Sigma β)} :\n    NodupKeys (s :: l) ↔ s.1 ∉ l.keys ∧ NodupKeys l := by simp [keys, nodupkeys]\n#align list.nodupkeys_cons List.nodupKeys_cons\n-/\n\n#print List.not_mem_keys_of_nodupKeys_cons /-\ntheorem not_mem_keys_of_nodupKeys_cons {s : Sigma β} {l : List (Sigma β)} (h : NodupKeys (s :: l)) :\n    s.1 ∉ l.keys :=\n  (nodupKeys_cons.1 h).1\n#align list.not_mem_keys_of_nodupkeys_cons List.not_mem_keys_of_nodupKeys_cons\n-/\n\n#print List.nodupKeys_of_nodupKeys_cons /-\ntheorem nodupKeys_of_nodupKeys_cons {s : Sigma β} {l : List (Sigma β)} (h : NodupKeys (s :: l)) :\n    NodupKeys l :=\n  (nodupKeys_cons.1 h).2\n#align list.nodupkeys_of_nodupkeys_cons List.nodupKeys_of_nodupKeys_cons\n-/\n\n#print List.NodupKeys.eq_of_fst_eq /-\ntheorem NodupKeys.eq_of_fst_eq {l : List (Sigma β)} (nd : NodupKeys l) {s s' : Sigma β} (h : s ∈ l)\n    (h' : s' ∈ l) : s.1 = s'.1 → s = s' :=\n  @Pairwise.forall_of_forall _ (fun s s' : Sigma β => s.1 = s'.1 → s = s') _\n    (fun s s' H h => (H h.symm).symm) (fun x h _ => rfl)\n    ((nodupKeys_iff_pairwise.1 nd).imp fun s s' h h' => (h h').elim) _ h _ h'\n#align list.nodupkeys.eq_of_fst_eq List.NodupKeys.eq_of_fst_eq\n-/\n\n#print List.NodupKeys.eq_of_mk_mem /-\ntheorem NodupKeys.eq_of_mk_mem {a : α} {b b' : β a} {l : List (Sigma β)} (nd : NodupKeys l)\n    (h : Sigma.mk a b ∈ l) (h' : Sigma.mk a b' ∈ l) : b = b' := by\n  cases nd.eq_of_fst_eq h h' rfl <;> rfl\n#align list.nodupkeys.eq_of_mk_mem List.NodupKeys.eq_of_mk_mem\n-/\n\n#print List.nodupKeys_singleton /-\ntheorem nodupKeys_singleton (s : Sigma β) : NodupKeys [s] :=\n  nodup_singleton _\n#align list.nodupkeys_singleton List.nodupKeys_singleton\n-/\n\n#print List.NodupKeys.sublist /-\ntheorem NodupKeys.sublist {l₁ l₂ : List (Sigma β)} (h : l₁ <+ l₂) : NodupKeys l₂ → NodupKeys l₁ :=\n  Nodup.sublist <| h.map _\n#align list.nodupkeys.sublist List.NodupKeys.sublist\n-/\n\n#print List.NodupKeys.nodup /-\nprotected theorem NodupKeys.nodup {l : List (Sigma β)} : NodupKeys l → Nodup l :=\n  Nodup.of_map _\n#align list.nodupkeys.nodup List.NodupKeys.nodup\n-/\n\n#print List.perm_nodupKeys /-\ntheorem perm_nodupKeys {l₁ l₂ : List (Sigma β)} (h : l₁ ~ l₂) : NodupKeys l₁ ↔ NodupKeys l₂ :=\n  (h.map _).nodup_iff\n#align list.perm_nodupkeys List.perm_nodupKeys\n-/\n\n#print List.nodupKeys_join /-\ntheorem nodupKeys_join {L : List (List (Sigma β))} :\n    NodupKeys (join L) ↔ (∀ l ∈ L, NodupKeys l) ∧ Pairwise Disjoint (L.map keys) :=\n  by\n  rw [nodupkeys_iff_pairwise, pairwise_join, pairwise_map]\n  refine' and_congr (ball_congr fun l h => by simp [nodupkeys_iff_pairwise]) _\n  apply iff_of_eq; congr with (l₁ l₂)\n  simp [keys, disjoint_iff_ne]\n#align list.nodupkeys_join List.nodupKeys_join\n-/\n\n#print List.nodup_enum_map_fst /-\ntheorem nodup_enum_map_fst (l : List α) : (l.enum.map Prod.fst).Nodup := by simp [List.nodup_range]\n#align list.nodup_enum_map_fst List.nodup_enum_map_fst\n-/\n\n#print List.mem_ext /-\ntheorem mem_ext {l₀ l₁ : List (Sigma β)} (nd₀ : l₀.Nodup) (nd₁ : l₁.Nodup)\n    (h : ∀ x, x ∈ l₀ ↔ x ∈ l₁) : l₀ ~ l₁ :=\n  by\n  induction' l₀ with x xs generalizing l₁ <;> cases' l₁ with y ys\n  · constructor\n  iterate 2 \n    first |specialize h x|specialize h y; simp at h\n    cases h\n  simp at nd₀ nd₁\n  classical\n    obtain rfl | h' := eq_or_ne x y\n    · constructor\n      refine' l₀_ih nd₀.2 nd₁.2 fun a => _\n      specialize h a\n      simp at h\n      obtain rfl | h' := eq_or_ne a x\n      · exact iff_of_false nd₀.1 nd₁.1\n      · simpa [h'] using h\n    · trans x :: y :: ys.erase x\n      · constructor\n        refine' l₀_ih nd₀.2 ((nd₁.2.eraseₓ _).cons fun h => nd₁.1 <| mem_of_mem_erase h) fun a => _\n        · specialize h a\n          simp at h\n          obtain rfl | h' := eq_or_ne a x\n          · exact iff_of_false nd₀.1 fun h => h.elim h' nd₁.2.not_mem_erase\n          · rw [or_iff_right h'] at h\n            rw [h, mem_cons_iff]\n            exact or_congr_right (mem_erase_of_ne h').symm\n      trans y :: x :: ys.erase x\n      · constructor\n      · constructor\n        symm\n        apply perm_cons_erase\n        specialize h x\n        simp [h'] at h\n        exact h\n#align list.mem_ext List.mem_ext\n-/\n\nvariable [DecidableEq α]\n\n/-! ### `lookup` -/\n\n\n#print List.dlookup /-\n/-- `lookup a l` is the first value in `l` corresponding to the key `a`,\n  or `none` if no such element exists. -/\ndef dlookup (a : α) : List (Sigma β) → Option (β a)\n  | [] => none\n  | ⟨a', b⟩ :: l => if h : a' = a then some (Eq.recOn h b) else lookup l\n#align list.lookup List.dlookup\n-/\n\n#print List.dlookup_nil /-\n@[simp]\ntheorem dlookup_nil (a : α) : dlookup a [] = @none (β a) :=\n  rfl\n#align list.lookup_nil List.dlookup_nil\n-/\n\n#print List.dlookup_cons_eq /-\n@[simp]\ntheorem dlookup_cons_eq (l) (a : α) (b : β a) : dlookup a (⟨a, b⟩ :: l) = some b :=\n  dif_pos rfl\n#align list.lookup_cons_eq List.dlookup_cons_eq\n-/\n\n#print List.dlookup_cons_ne /-\n@[simp]\ntheorem dlookup_cons_ne (l) {a} : ∀ s : Sigma β, a ≠ s.1 → dlookup a (s :: l) = dlookup a l\n  | ⟨a', b⟩, h => dif_neg h.symm\n#align list.lookup_cons_ne List.dlookup_cons_ne\n-/\n\n#print List.dlookup_isSome /-\ntheorem dlookup_isSome {a : α} : ∀ {l : List (Sigma β)}, (dlookup a l).isSome ↔ a ∈ l.keys\n  | [] => by simp\n  | ⟨a', b⟩ :: l => by\n    by_cases h : a = a'\n    · subst a'\n      simp\n    · simp [h, lookup_is_some]\n#align list.lookup_is_some List.dlookup_isSome\n-/\n\n#print List.dlookup_eq_none /-\ntheorem dlookup_eq_none {a : α} {l : List (Sigma β)} : dlookup a l = none ↔ a ∉ l.keys := by\n  simp [← lookup_is_some, Option.isNone_iff_eq_none]\n#align list.lookup_eq_none List.dlookup_eq_none\n-/\n\n#print List.of_mem_dlookup /-\ntheorem of_mem_dlookup {a : α} {b : β a} :\n    ∀ {l : List (Sigma β)}, b ∈ dlookup a l → Sigma.mk a b ∈ l\n  | ⟨a', b'⟩ :: l, H => by\n    by_cases h : a = a'\n    · subst a'\n      simp at H\n      simp [H]\n    · simp [h] at H\n      exact Or.inr (of_mem_lookup H)\n#align list.of_mem_lookup List.of_mem_dlookup\n-/\n\n#print List.mem_dlookup /-\ntheorem mem_dlookup {a} {b : β a} {l : List (Sigma β)} (nd : l.NodupKeys) (h : Sigma.mk a b ∈ l) :\n    b ∈ dlookup a l :=\n  by\n  cases' option.is_some_iff_exists.mp (lookup_is_some.mpr (mem_keys_of_mem h)) with b' h'\n  cases nd.eq_of_mk_mem h (of_mem_lookup h')\n  exact h'\n#align list.mem_lookup List.mem_dlookup\n-/\n\n#print List.map_dlookup_eq_find /-\ntheorem map_dlookup_eq_find (a : α) :\n    ∀ l : List (Sigma β), (dlookup a l).map (Sigma.mk a) = find? (fun s => a = s.1) l\n  | [] => rfl\n  | ⟨a', b'⟩ :: l => by\n    by_cases h : a = a'\n    · subst a'\n      simp\n    · simp [h, map_lookup_eq_find]\n#align list.map_lookup_eq_find List.map_dlookup_eq_find\n-/\n\n#print List.mem_dlookup_iff /-\ntheorem mem_dlookup_iff {a : α} {b : β a} {l : List (Sigma β)} (nd : l.NodupKeys) :\n    b ∈ dlookup a l ↔ Sigma.mk a b ∈ l :=\n  ⟨of_mem_dlookup, mem_dlookup nd⟩\n#align list.mem_lookup_iff List.mem_dlookup_iff\n-/\n\n#print List.perm_dlookup /-\ntheorem perm_dlookup (a : α) {l₁ l₂ : List (Sigma β)} (nd₁ : l₁.NodupKeys) (nd₂ : l₂.NodupKeys)\n    (p : l₁ ~ l₂) : dlookup a l₁ = dlookup a l₂ := by\n  ext b <;> simp [mem_lookup_iff, nd₁, nd₂] <;> exact p.mem_iff\n#align list.perm_lookup List.perm_dlookup\n-/\n\n#print List.lookup_ext /-\ntheorem lookup_ext {l₀ l₁ : List (Sigma β)} (nd₀ : l₀.NodupKeys) (nd₁ : l₁.NodupKeys)\n    (h : ∀ x y, y ∈ l₀.dlookup x ↔ y ∈ l₁.dlookup x) : l₀ ~ l₁ :=\n  mem_ext nd₀.Nodup nd₁.Nodup fun ⟨a, b⟩ => by\n    rw [← mem_lookup_iff, ← mem_lookup_iff, h] <;> assumption\n#align list.lookup_ext List.lookup_ext\n-/\n\n/-! ### `lookup_all` -/\n\n\n#print List.lookupAll /-\n/-- `lookup_all a l` is the list of all values in `l` corresponding to the key `a`. -/\ndef lookupAll (a : α) : List (Sigma β) → List (β a)\n  | [] => []\n  | ⟨a', b⟩ :: l => if h : a' = a then Eq.recOn h b :: lookup_all l else lookup_all l\n#align list.lookup_all List.lookupAll\n-/\n\n#print List.lookupAll_nil /-\n@[simp]\ntheorem lookupAll_nil (a : α) : lookupAll a [] = @nil (β a) :=\n  rfl\n#align list.lookup_all_nil List.lookupAll_nil\n-/\n\n#print List.lookupAll_cons_eq /-\n@[simp]\ntheorem lookupAll_cons_eq (l) (a : α) (b : β a) : lookupAll a (⟨a, b⟩ :: l) = b :: lookupAll a l :=\n  dif_pos rfl\n#align list.lookup_all_cons_eq List.lookupAll_cons_eq\n-/\n\n#print List.lookupAll_cons_ne /-\n@[simp]\ntheorem lookupAll_cons_ne (l) {a} : ∀ s : Sigma β, a ≠ s.1 → lookupAll a (s :: l) = lookupAll a l\n  | ⟨a', b⟩, h => dif_neg h.symm\n#align list.lookup_all_cons_ne List.lookupAll_cons_ne\n-/\n\n#print List.lookupAll_eq_nil /-\ntheorem lookupAll_eq_nil {a : α} :\n    ∀ {l : List (Sigma β)}, lookupAll a l = [] ↔ ∀ b : β a, Sigma.mk a b ∉ l\n  | [] => by simp\n  | ⟨a', b⟩ :: l => by\n    by_cases h : a = a'\n    · subst a'\n      simp\n    · simp [h, lookup_all_eq_nil]\n#align list.lookup_all_eq_nil List.lookupAll_eq_nil\n-/\n\n#print List.head?_lookupAll /-\ntheorem head?_lookupAll (a : α) : ∀ l : List (Sigma β), head? (lookupAll a l) = dlookup a l\n  | [] => by simp\n  | ⟨a', b⟩ :: l => by\n    by_cases h : a = a' <;>\n      [·\n        subst h\n        simp, simp [*]]\n#align list.head_lookup_all List.head?_lookupAll\n-/\n\n#print List.mem_lookupAll /-\ntheorem mem_lookupAll {a : α} {b : β a} :\n    ∀ {l : List (Sigma β)}, b ∈ lookupAll a l ↔ Sigma.mk a b ∈ l\n  | [] => by simp\n  | ⟨a', b'⟩ :: l => by\n    by_cases h : a = a' <;>\n      [·\n        subst h\n        simp [*], simp [*]]\n#align list.mem_lookup_all List.mem_lookupAll\n-/\n\n#print List.lookupAll_sublist /-\ntheorem lookupAll_sublist (a : α) : ∀ l : List (Sigma β), (lookupAll a l).map (Sigma.mk a) <+ l\n  | [] => by simp\n  | ⟨a', b'⟩ :: l => by\n    by_cases h : a = a'\n    · subst h\n      simp\n      exact (lookup_all_sublist l).cons₂ _ _ _\n    · simp [h]\n      exact (lookup_all_sublist l).cons _ _ _\n#align list.lookup_all_sublist List.lookupAll_sublist\n-/\n\n#print List.lookupAll_length_le_one /-\ntheorem lookupAll_length_le_one (a : α) {l : List (Sigma β)} (h : l.NodupKeys) :\n    length (lookupAll a l) ≤ 1 := by\n  have := nodup.sublist ((lookup_all_sublist a l).map _) h <;> rw [map_map] at this <;>\n    rwa [← nodup_replicate, ← map_const _ a]\n#align list.lookup_all_length_le_one List.lookupAll_length_le_one\n-/\n\n#print List.lookupAll_eq_dlookup /-\ntheorem lookupAll_eq_dlookup (a : α) {l : List (Sigma β)} (h : l.NodupKeys) :\n    lookupAll a l = (dlookup a l).toList :=\n  by\n  rw [← head_lookup_all]\n  have := lookup_all_length_le_one a h; revert this\n  rcases lookup_all a l with (_ | ⟨b, _ | ⟨c, l⟩⟩) <;> intro <;> try rfl\n  exact absurd this (by decide)\n#align list.lookup_all_eq_lookup List.lookupAll_eq_dlookup\n-/\n\n#print List.lookupAll_nodup /-\ntheorem lookupAll_nodup (a : α) {l : List (Sigma β)} (h : l.NodupKeys) : (lookupAll a l).Nodup := by\n  rw [lookup_all_eq_lookup a h] <;> apply Option.toList_nodup\n#align list.lookup_all_nodup List.lookupAll_nodup\n-/\n\n#print List.perm_lookupAll /-\ntheorem perm_lookupAll (a : α) {l₁ l₂ : List (Sigma β)} (nd₁ : l₁.NodupKeys) (nd₂ : l₂.NodupKeys)\n    (p : l₁ ~ l₂) : lookupAll a l₁ = lookupAll a l₂ := by\n  simp [lookup_all_eq_lookup, nd₁, nd₂, perm_lookup a nd₁ nd₂ p]\n#align list.perm_lookup_all List.perm_lookupAll\n-/\n\n/-! ### `kreplace` -/\n\n\n#print List.kreplace /-\n/-- Replaces the first value with key `a` by `b`. -/\ndef kreplace (a : α) (b : β a) : List (Sigma β) → List (Sigma β) :=\n  lookmap fun s => if a = s.1 then some ⟨a, b⟩ else none\n#align list.kreplace List.kreplace\n-/\n\n#print List.kreplace_of_forall_not /-\ntheorem kreplace_of_forall_not (a : α) (b : β a) {l : List (Sigma β)}\n    (H : ∀ b : β a, Sigma.mk a b ∉ l) : kreplace a b l = l :=\n  lookmap_of_forall_not _ <| by\n    rintro ⟨a', b'⟩ h; dsimp; split_ifs\n    · subst a'\n      exact H _ h; · rfl\n#align list.kreplace_of_forall_not List.kreplace_of_forall_not\n-/\n\n#print List.kreplace_self /-\ntheorem kreplace_self {a : α} {b : β a} {l : List (Sigma β)} (nd : NodupKeys l)\n    (h : Sigma.mk a b ∈ l) : kreplace a b l = l :=\n  by\n  refine' (lookmap_congr _).trans (lookmap_id' (Option.guard fun s => a = s.1) _ _)\n  · rintro ⟨a', b'⟩ h'\n    dsimp [Option.guard]\n    split_ifs\n    · subst a'\n      exact ⟨rfl, hEq_of_eq <| nd.eq_of_mk_mem h h'⟩\n    · rfl\n  · rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩\n    dsimp [Option.guard]\n    split_ifs\n    · exact id\n    · rintro ⟨⟩\n#align list.kreplace_self List.kreplace_self\n-/\n\n#print List.keys_kreplace /-\ntheorem keys_kreplace (a : α) (b : β a) : ∀ l : List (Sigma β), (kreplace a b l).keys = l.keys :=\n  lookmap_map_eq _ _ <| by\n    rintro ⟨a₁, b₂⟩ ⟨a₂, b₂⟩ <;> dsimp <;> split_ifs <;> simp (config := { contextual := true }) [h]\n#align list.keys_kreplace List.keys_kreplace\n-/\n\n#print List.kreplace_nodupKeys /-\ntheorem kreplace_nodupKeys (a : α) (b : β a) {l : List (Sigma β)} :\n    (kreplace a b l).NodupKeys ↔ l.NodupKeys := by simp [nodupkeys, keys_kreplace]\n#align list.kreplace_nodupkeys List.kreplace_nodupKeys\n-/\n\n#print List.Perm.kreplace /-\ntheorem Perm.kreplace {a : α} {b : β a} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :\n    l₁ ~ l₂ → kreplace a b l₁ ~ kreplace a b l₂ :=\n  perm_lookmap _ <| by\n    refine' nd.pairwise_ne.imp _\n    intro x y h z h₁ w h₂\n    split_ifs  at h₁ h₂ <;> cases h₁ <;> cases h₂\n    exact (h (h_2.symm.trans h_1)).elim\n#align list.perm.kreplace List.Perm.kreplace\n-/\n\n/-! ### `kerase` -/\n\n\n#print List.kerase /-\n/-- Remove the first pair with the key `a`. -/\ndef kerase (a : α) : List (Sigma β) → List (Sigma β) :=\n  eraseP fun s => a = s.1\n#align list.kerase List.kerase\n-/\n\n#print List.kerase_nil /-\n@[simp]\ntheorem kerase_nil {a} : @kerase _ β _ a [] = [] :=\n  rfl\n#align list.kerase_nil List.kerase_nil\n-/\n\n#print List.kerase_cons_eq /-\n@[simp]\ntheorem kerase_cons_eq {a} {s : Sigma β} {l : List (Sigma β)} (h : a = s.1) :\n    kerase a (s :: l) = l := by simp [kerase, h]\n#align list.kerase_cons_eq List.kerase_cons_eq\n-/\n\n#print List.kerase_cons_ne /-\n@[simp]\ntheorem kerase_cons_ne {a} {s : Sigma β} {l : List (Sigma β)} (h : a ≠ s.1) :\n    kerase a (s :: l) = s :: kerase a l := by simp [kerase, h]\n#align list.kerase_cons_ne List.kerase_cons_ne\n-/\n\n#print List.kerase_of_not_mem_keys /-\n@[simp]\ntheorem kerase_of_not_mem_keys {a} {l : List (Sigma β)} (h : a ∉ l.keys) : kerase a l = l := by\n  induction' l with _ _ ih <;> [rfl,\n    · simp [not_or] at h\n      simp [h.1, ih h.2]]\n#align list.kerase_of_not_mem_keys List.kerase_of_not_mem_keys\n-/\n\n#print List.kerase_sublist /-\ntheorem kerase_sublist (a : α) (l : List (Sigma β)) : kerase a l <+ l :=\n  eraseP_sublist _\n#align list.kerase_sublist List.kerase_sublist\n-/\n\n#print List.kerase_keys_subset /-\ntheorem kerase_keys_subset (a) (l : List (Sigma β)) : (kerase a l).keys ⊆ l.keys :=\n  ((kerase_sublist a l).map _).Subset\n#align list.kerase_keys_subset List.kerase_keys_subset\n-/\n\n#print List.mem_keys_of_mem_keys_kerase /-\ntheorem mem_keys_of_mem_keys_kerase {a₁ a₂} {l : List (Sigma β)} :\n    a₁ ∈ (kerase a₂ l).keys → a₁ ∈ l.keys :=\n  @kerase_keys_subset _ _ _ _ _ _\n#align list.mem_keys_of_mem_keys_kerase List.mem_keys_of_mem_keys_kerase\n-/\n\n#print List.exists_of_kerase /-\ntheorem exists_of_kerase {a : α} {l : List (Sigma β)} (h : a ∈ l.keys) :\n    ∃ (b : β a)(l₁ l₂ : List (Sigma β)),\n      a ∉ l₁.keys ∧ l = l₁ ++ ⟨a, b⟩ :: l₂ ∧ kerase a l = l₁ ++ l₂ :=\n  by\n  induction l\n  case nil => cases h\n  case cons hd tl ih =>\n    by_cases e : a = hd.1\n    · subst e\n      exact ⟨hd.2, [], tl, by simp, by cases hd <;> rfl, by simp⟩\n    · simp at h\n      cases h\n      case inl h => exact absurd h e\n      case inr h =>\n        rcases ih h with ⟨b, tl₁, tl₂, h₁, h₂, h₃⟩\n        exact\n          ⟨b, hd :: tl₁, tl₂, not_mem_cons_of_ne_of_not_mem e h₁, by rw [h₂] <;> rfl, by\n            simp [e, h₃]⟩\n#align list.exists_of_kerase List.exists_of_kerase\n-/\n\n#print List.mem_keys_kerase_of_ne /-\n@[simp]\ntheorem mem_keys_kerase_of_ne {a₁ a₂} {l : List (Sigma β)} (h : a₁ ≠ a₂) :\n    a₁ ∈ (kerase a₂ l).keys ↔ a₁ ∈ l.keys :=\n  Iff.intro mem_keys_of_mem_keys_kerase fun p =>\n    if q : a₂ ∈ l.keys then\n      match l, kerase a₂ l, exists_of_kerase q, p with\n      | _, _, ⟨_, _, _, _, rfl, rfl⟩, p => by simpa [keys, h] using p\n    else by simp [q, p]\n#align list.mem_keys_kerase_of_ne List.mem_keys_kerase_of_ne\n-/\n\n/- warning: list.keys_kerase -> List.keys_kerase is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] {a : α} {l : List.{max u1 u2} (Sigma.{u1, u2} α β)}, Eq.{succ u1} (List.{u1} α) (List.keys.{u1, u2} α β (List.kerase.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a l)) (List.eraseₓ.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (List.keys.{u1, u2} α β l) a)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] {a : α} {l : List.{max u2 u1} (Sigma.{u1, u2} α β)}, Eq.{succ u1} (List.{u1} α) (List.keys.{u1, u2} α β (List.kerase.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a l)) (List.erase.{u1} α (instBEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (List.keys.{u1, u2} α β l) a)\nCase conversion may be inaccurate. Consider using '#align list.keys_kerase List.keys_keraseₓ'. -/\ntheorem keys_kerase {a} {l : List (Sigma β)} : (kerase a l).keys = l.keys.eraseₓ a := by\n  rw [keys, kerase, ← erasep_map Sigma.fst l, erase_eq_erasep]\n#align list.keys_kerase List.keys_kerase\n\n#print List.kerase_kerase /-\ntheorem kerase_kerase {a a'} {l : List (Sigma β)} :\n    (kerase a' l).kerase a = (kerase a l).kerase a' :=\n  by\n  by_cases a = a'\n  · subst a'\n  induction' l with x xs; · rfl\n  · by_cases a' = x.1\n    · subst a'\n      simp [kerase_cons_ne h, kerase_cons_eq rfl]\n    by_cases h' : a = x.1\n    · subst a\n      simp [kerase_cons_eq rfl, kerase_cons_ne (Ne.symm h)]\n    · simp [kerase_cons_ne, *]\n#align list.kerase_kerase List.kerase_kerase\n-/\n\n#print List.NodupKeys.kerase /-\ntheorem NodupKeys.kerase (a : α) : NodupKeys l → (kerase a l).NodupKeys :=\n  NodupKeys.sublist <| kerase_sublist _ _\n#align list.nodupkeys.kerase List.NodupKeys.kerase\n-/\n\n#print List.Perm.kerase /-\ntheorem Perm.kerase {a : α} {l₁ l₂ : List (Sigma β)} (nd : l₁.NodupKeys) :\n    l₁ ~ l₂ → kerase a l₁ ~ kerase a l₂ :=\n  Perm.erasep _ <| (nodupKeys_iff_pairwise.1 nd).imp <| by rintro x y h rfl <;> exact h\n#align list.perm.kerase List.Perm.kerase\n-/\n\n#print List.not_mem_keys_kerase /-\n@[simp]\ntheorem not_mem_keys_kerase (a) {l : List (Sigma β)} (nd : l.NodupKeys) : a ∉ (kerase a l).keys :=\n  by\n  induction l\n  case nil => simp\n  case cons hd tl ih =>\n    simp at nd\n    by_cases h : a = hd.1\n    · subst h\n      simp [nd.1]\n    · simp [h, ih nd.2]\n#align list.not_mem_keys_kerase List.not_mem_keys_kerase\n-/\n\n#print List.dlookup_kerase /-\n@[simp]\ntheorem dlookup_kerase (a) {l : List (Sigma β)} (nd : l.NodupKeys) :\n    dlookup a (kerase a l) = none :=\n  dlookup_eq_none.mpr (not_mem_keys_kerase a nd)\n#align list.lookup_kerase List.dlookup_kerase\n-/\n\n#print List.dlookup_kerase_ne /-\n@[simp]\ntheorem dlookup_kerase_ne {a a'} {l : List (Sigma β)} (h : a ≠ a') :\n    dlookup a (kerase a' l) = dlookup a l :=\n  by\n  induction l\n  case nil => rfl\n  case cons hd tl ih =>\n    cases' hd with ah bh\n    by_cases h₁ : a = ah <;> by_cases h₂ : a' = ah\n    · substs h₁ h₂\n      cases Ne.irrefl h\n    · subst h₁\n      simp [h₂]\n    · subst h₂\n      simp [h]\n    · simp [h₁, h₂, ih]\n#align list.lookup_kerase_ne List.dlookup_kerase_ne\n-/\n\n#print List.kerase_append_left /-\ntheorem kerase_append_left {a} :\n    ∀ {l₁ l₂ : List (Sigma β)}, a ∈ l₁.keys → kerase a (l₁ ++ l₂) = kerase a l₁ ++ l₂\n  | [], _, h => by cases h\n  | s :: l₁, l₂, h₁ =>\n    if h₂ : a = s.1 then by simp [h₂]\n    else by simp at h₁ <;> cases h₁ <;> [exact absurd h₁ h₂, simp [h₂, kerase_append_left h₁]]\n#align list.kerase_append_left List.kerase_append_left\n-/\n\n#print List.kerase_append_right /-\ntheorem kerase_append_right {a} :\n    ∀ {l₁ l₂ : List (Sigma β)}, a ∉ l₁.keys → kerase a (l₁ ++ l₂) = l₁ ++ kerase a l₂\n  | [], _, h => rfl\n  | _ :: l₁, l₂, h => by simp [not_or] at h <;> simp [h.1, kerase_append_right h.2]\n#align list.kerase_append_right List.kerase_append_right\n-/\n\n#print List.kerase_comm /-\ntheorem kerase_comm (a₁ a₂) (l : List (Sigma β)) :\n    kerase a₂ (kerase a₁ l) = kerase a₁ (kerase a₂ l) :=\n  if h : a₁ = a₂ then by simp [h]\n  else\n    if ha₁ : a₁ ∈ l.keys then\n      if ha₂ : a₂ ∈ l.keys then\n        match l, kerase a₁ l, exists_of_kerase ha₁, ha₂ with\n        | _, _, ⟨b₁, l₁, l₂, a₁_nin_l₁, rfl, rfl⟩, a₂_in_l₁_app_l₂ =>\n          if h' : a₂ ∈ l₁.keys then by\n            simp [kerase_append_left h',\n              kerase_append_right (mt (mem_keys_kerase_of_ne h).mp a₁_nin_l₁)]\n          else by\n            simp [kerase_append_right h', kerase_append_right a₁_nin_l₁,\n              @kerase_cons_ne _ _ _ a₂ ⟨a₁, b₁⟩ _ (Ne.symm h)]\n      else by simp [ha₂, mt mem_keys_of_mem_keys_kerase ha₂]\n    else by simp [ha₁, mt mem_keys_of_mem_keys_kerase ha₁]\n#align list.kerase_comm List.kerase_comm\n-/\n\n/- warning: list.sizeof_kerase -> List.sizeOf_kerase is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_2 : DecidableEq.{succ u1} α] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u1, u2} α β)] (x : α) (xs : List.{max u1 u2} (Sigma.{u1, u2} α β)), LE.le.{0} Nat Nat.hasLe (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} α β)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} α β) _inst_3) (List.kerase.{u1, u2} α β (fun (a : α) (b : α) => _inst_2 a b) x xs)) (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} α β)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} α β) _inst_3) xs)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : α -> Type.{u1}} [_inst_2 : DecidableEq.{succ u2} α] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u2, u1} α β)] (x : α) (xs : List.{max u1 u2} (Sigma.{u2, u1} α β)), LE.le.{0} Nat instLENat (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} α β)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} α β) _inst_3) (List.kerase.{u2, u1} α β (fun (a : α) (b : α) => _inst_2 a b) x xs)) (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} α β)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} α β) _inst_3) xs)\nCase conversion may be inaccurate. Consider using '#align list.sizeof_kerase List.sizeOf_keraseₓ'. -/\ntheorem sizeOf_kerase {α} {β : α → Type _} [DecidableEq α] [SizeOf (Sigma β)] (x : α)\n    (xs : List (Sigma β)) : SizeOf.sizeOf (List.kerase x xs) ≤ SizeOf.sizeOf xs :=\n  by\n  unfold_wf\n  induction' xs with y ys\n  · simp\n  · by_cases x = y.1 <;> simp [*, List.sizeof]\n#align list.sizeof_kerase List.sizeOf_kerase\n\n/-! ### `kinsert` -/\n\n\n#print List.kinsert /-\n/-- Insert the pair `⟨a, b⟩` and erase the first pair with the key `a`. -/\ndef kinsert (a : α) (b : β a) (l : List (Sigma β)) : List (Sigma β) :=\n  ⟨a, b⟩ :: kerase a l\n#align list.kinsert List.kinsert\n-/\n\n#print List.kinsert_def /-\n@[simp]\ntheorem kinsert_def {a} {b : β a} {l : List (Sigma β)} : kinsert a b l = ⟨a, b⟩ :: kerase a l :=\n  rfl\n#align list.kinsert_def List.kinsert_def\n-/\n\n#print List.mem_keys_kinsert /-\ntheorem mem_keys_kinsert {a a'} {b' : β a'} {l : List (Sigma β)} :\n    a ∈ (kinsert a' b' l).keys ↔ a = a' ∨ a ∈ l.keys := by by_cases h : a = a' <;> simp [h]\n#align list.mem_keys_kinsert List.mem_keys_kinsert\n-/\n\n#print List.kinsert_nodupKeys /-\ntheorem kinsert_nodupKeys (a) (b : β a) {l : List (Sigma β)} (nd : l.NodupKeys) :\n    (kinsert a b l).NodupKeys :=\n  nodupKeys_cons.mpr ⟨not_mem_keys_kerase a nd, nd.kerase a⟩\n#align list.kinsert_nodupkeys List.kinsert_nodupKeys\n-/\n\n#print List.Perm.kinsert /-\ntheorem Perm.kinsert {a} {b : β a} {l₁ l₂ : List (Sigma β)} (nd₁ : l₁.NodupKeys) (p : l₁ ~ l₂) :\n    kinsert a b l₁ ~ kinsert a b l₂ :=\n  (p.kerase nd₁).cons _\n#align list.perm.kinsert List.Perm.kinsert\n-/\n\n#print List.dlookup_kinsert /-\ntheorem dlookup_kinsert {a} {b : β a} (l : List (Sigma β)) : dlookup a (kinsert a b l) = some b :=\n  by simp only [kinsert, lookup_cons_eq]\n#align list.lookup_kinsert List.dlookup_kinsert\n-/\n\n#print List.dlookup_kinsert_ne /-\ntheorem dlookup_kinsert_ne {a a'} {b' : β a'} {l : List (Sigma β)} (h : a ≠ a') :\n    dlookup a (kinsert a' b' l) = dlookup a l := by simp [h]\n#align list.lookup_kinsert_ne List.dlookup_kinsert_ne\n-/\n\n/-! ### `kextract` -/\n\n\n#print List.kextract /-\n/-- Finds the first entry with a given key `a` and returns its value (as an `option` because there\nmight be no entry with key `a`) alongside with the rest of the entries. -/\ndef kextract (a : α) : List (Sigma β) → Option (β a) × List (Sigma β)\n  | [] => (none, [])\n  | s :: l =>\n    if h : s.1 = a then (some (Eq.recOn h s.2), l)\n    else\n      let (b', l') := kextract l\n      (b', s :: l')\n#align list.kextract List.kextract\n-/\n\n#print List.kextract_eq_dlookup_kerase /-\n@[simp]\ntheorem kextract_eq_dlookup_kerase (a : α) :\n    ∀ l : List (Sigma β), kextract a l = (dlookup a l, kerase a l)\n  | [] => rfl\n  | ⟨a', b⟩ :: l => by\n    simp [kextract]; dsimp; split_ifs\n    · subst a'\n      simp [kerase]\n    · simp [kextract, Ne.symm h, kextract_eq_lookup_kerase l, kerase]\n#align list.kextract_eq_lookup_kerase List.kextract_eq_dlookup_kerase\n-/\n\n/-! ### `dedupkeys` -/\n\n\n#print List.dedupKeys /-\n/-- Remove entries with duplicate keys from `l : list (sigma β)`. -/\ndef dedupKeys : List (Sigma β) → List (Sigma β) :=\n  List.foldr (fun x => kinsert x.1 x.2) []\n#align list.dedupkeys List.dedupKeys\n-/\n\n#print List.dedupKeys_cons /-\ntheorem dedupKeys_cons {x : Sigma β} (l : List (Sigma β)) :\n    dedupKeys (x :: l) = kinsert x.1 x.2 (dedupKeys l) :=\n  rfl\n#align list.dedupkeys_cons List.dedupKeys_cons\n-/\n\n#print List.nodupKeys_dedupKeys /-\ntheorem nodupKeys_dedupKeys (l : List (Sigma β)) : NodupKeys (dedupKeys l) :=\n  by\n  dsimp [dedupkeys]\n  generalize hl : nil = l'\n  have : nodupkeys l' := by\n    rw [← hl]\n    apply nodup_nil\n  clear hl\n  induction' l with x xs\n  · apply this\n  · cases x\n    simp [dedupkeys]\n    constructor\n    · simp [keys_kerase]\n      apply l_ih.not_mem_erase\n    · exact l_ih.kerase _\n#align list.nodupkeys_dedupkeys List.nodupKeys_dedupKeys\n-/\n\n#print List.dlookup_dedupKeys /-\ntheorem dlookup_dedupKeys (a : α) (l : List (Sigma β)) : dlookup a (dedupKeys l) = dlookup a l :=\n  by\n  induction l; rfl\n  cases' l_hd with a' b\n  by_cases a = a'\n  · subst a'\n    rw [dedupkeys_cons, lookup_kinsert, lookup_cons_eq]\n  · rw [dedupkeys_cons, lookup_kinsert_ne h, l_ih, lookup_cons_ne]\n    exact h\n#align list.lookup_dedupkeys List.dlookup_dedupKeys\n-/\n\n/- warning: list.sizeof_dedupkeys -> List.sizeOf_dedupKeys is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_2 : DecidableEq.{succ u1} α] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u1, u2} α β)] (xs : List.{max u1 u2} (Sigma.{u1, u2} α β)), LE.le.{0} Nat Nat.hasLe (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} α β)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} α β) _inst_3) (List.dedupKeys.{u1, u2} α β (fun (a : α) (b : α) => _inst_2 a b) xs)) (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} α β)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} α β) _inst_3) xs)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : α -> Type.{u1}} [_inst_2 : DecidableEq.{succ u2} α] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u2, u1} α β)] (xs : List.{max u1 u2} (Sigma.{u2, u1} α β)), LE.le.{0} Nat instLENat (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} α β)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} α β) _inst_3) (List.dedupKeys.{u2, u1} α β (fun (a : α) (b : α) => _inst_2 a b) xs)) (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} α β)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} α β) _inst_3) xs)\nCase conversion may be inaccurate. Consider using '#align list.sizeof_dedupkeys List.sizeOf_dedupKeysₓ'. -/\ntheorem sizeOf_dedupKeys {α} {β : α → Type _} [DecidableEq α] [SizeOf (Sigma β)]\n    (xs : List (Sigma β)) : SizeOf.sizeOf (List.dedupKeys xs) ≤ SizeOf.sizeOf xs :=\n  by\n  unfold_wf\n  induction' xs with x xs\n  · simp [List.dedupKeys]\n  · simp only [dedupkeys_cons, List.sizeof, kinsert_def, add_le_add_iff_left, Sigma.eta]\n    trans\n    apply sizeof_kerase\n    assumption\n#align list.sizeof_dedupkeys List.sizeOf_dedupKeys\n\n/-! ### `kunion` -/\n\n\n#print List.kunion /-\n/-- `kunion l₁ l₂` is the append to l₁ of l₂ after, for each key in l₁, the\nfirst matching pair in l₂ is erased. -/\ndef kunion : List (Sigma β) → List (Sigma β) → List (Sigma β)\n  | [], l₂ => l₂\n  | s :: l₁, l₂ => s :: kunion l₁ (kerase s.1 l₂)\n#align list.kunion List.kunion\n-/\n\n#print List.nil_kunion /-\n@[simp]\ntheorem nil_kunion {l : List (Sigma β)} : kunion [] l = l :=\n  rfl\n#align list.nil_kunion List.nil_kunion\n-/\n\n#print List.kunion_nil /-\n@[simp]\ntheorem kunion_nil : ∀ {l : List (Sigma β)}, kunion l [] = l\n  | [] => rfl\n  | _ :: l => by rw [kunion, kerase_nil, kunion_nil]\n#align list.kunion_nil List.kunion_nil\n-/\n\n#print List.kunion_cons /-\n@[simp]\ntheorem kunion_cons {s} {l₁ l₂ : List (Sigma β)} :\n    kunion (s :: l₁) l₂ = s :: kunion l₁ (kerase s.1 l₂) :=\n  rfl\n#align list.kunion_cons List.kunion_cons\n-/\n\n#print List.mem_keys_kunion /-\n@[simp]\ntheorem mem_keys_kunion {a} {l₁ l₂ : List (Sigma β)} :\n    a ∈ (kunion l₁ l₂).keys ↔ a ∈ l₁.keys ∨ a ∈ l₂.keys :=\n  by\n  induction l₁ generalizing l₂\n  case nil => simp\n  case cons s l₁ ih => by_cases h : a = s.1 <;> [simp [h], simp [h, ih]]\n#align list.mem_keys_kunion List.mem_keys_kunion\n-/\n\n#print List.kunion_kerase /-\n@[simp]\ntheorem kunion_kerase {a} :\n    ∀ {l₁ l₂ : List (Sigma β)}, kunion (kerase a l₁) (kerase a l₂) = kerase a (kunion l₁ l₂)\n  | [], _ => rfl\n  | s :: _, l => by by_cases h : a = s.1 <;> simp [h, kerase_comm a s.1 l, kunion_kerase]\n#align list.kunion_kerase List.kunion_kerase\n-/\n\n#print List.NodupKeys.kunion /-\ntheorem NodupKeys.kunion (nd₁ : l₁.NodupKeys) (nd₂ : l₂.NodupKeys) : (kunion l₁ l₂).NodupKeys :=\n  by\n  induction l₁ generalizing l₂\n  case nil => simp only [nil_kunion, nd₂]\n  case cons s l₁ ih =>\n    simp at nd₁\n    simp [not_or, nd₁.1, nd₂, ih nd₁.2 (nd₂.kerase s.1)]\n#align list.nodupkeys.kunion List.NodupKeys.kunion\n-/\n\n#print List.Perm.kunion_right /-\ntheorem Perm.kunion_right {l₁ l₂ : List (Sigma β)} (p : l₁ ~ l₂) (l) : kunion l₁ l ~ kunion l₂ l :=\n  by\n  induction p generalizing l\n  case nil => rfl\n  case cons hd tl₁ tl₂ p ih => simp [ih (kerase hd.1 l), perm.cons]\n  case swap s₁ s₂ l => simp [kerase_comm, perm.swap]\n  case trans l₁ l₂ l₃ p₁₂ p₂₃ ih₁₂ ih₂₃ => exact perm.trans (ih₁₂ l) (ih₂₃ l)\n#align list.perm.kunion_right List.Perm.kunion_right\n-/\n\n#print List.Perm.kunion_left /-\ntheorem Perm.kunion_left :\n    ∀ (l) {l₁ l₂ : List (Sigma β)}, l₁.NodupKeys → l₁ ~ l₂ → kunion l l₁ ~ kunion l l₂\n  | [], _, _, _, p => p\n  | s :: l, l₁, l₂, nd₁, p => by simp [((p.kerase nd₁).kunion_left l <| nd₁.kerase s.1).cons s]\n#align list.perm.kunion_left List.Perm.kunion_left\n-/\n\n#print List.Perm.kunion /-\ntheorem Perm.kunion {l₁ l₂ l₃ l₄ : List (Sigma β)} (nd₃ : l₃.NodupKeys) (p₁₂ : l₁ ~ l₂)\n    (p₃₄ : l₃ ~ l₄) : kunion l₁ l₃ ~ kunion l₂ l₄ :=\n  (p₁₂.kunion_right l₃).trans (p₃₄.kunion_left l₂ nd₃)\n#align list.perm.kunion List.Perm.kunion\n-/\n\n#print List.dlookup_kunion_left /-\n@[simp]\ntheorem dlookup_kunion_left {a} {l₁ l₂ : List (Sigma β)} (h : a ∈ l₁.keys) :\n    dlookup a (kunion l₁ l₂) = dlookup a l₁ :=\n  by\n  induction' l₁ with s _ ih generalizing l₂ <;> simp at h <;> cases h <;> cases' s with a'\n  · subst h\n    simp\n  · rw [kunion_cons]\n    by_cases h' : a = a'\n    · subst h'\n      simp\n    · simp [h', ih h]\n#align list.lookup_kunion_left List.dlookup_kunion_left\n-/\n\n#print List.dlookup_kunion_right /-\n@[simp]\ntheorem dlookup_kunion_right {a} {l₁ l₂ : List (Sigma β)} (h : a ∉ l₁.keys) :\n    dlookup a (kunion l₁ l₂) = dlookup a l₂ :=\n  by\n  induction l₁ generalizing l₂\n  case nil => simp\n  case cons _ _ ih => simp [not_or] at h; simp [h.1, ih h.2]\n#align list.lookup_kunion_right List.dlookup_kunion_right\n-/\n\n#print List.mem_dlookup_kunion /-\n@[simp]\ntheorem mem_dlookup_kunion {a} {b : β a} {l₁ l₂ : List (Sigma β)} :\n    b ∈ dlookup a (kunion l₁ l₂) ↔ b ∈ dlookup a l₁ ∨ a ∉ l₁.keys ∧ b ∈ dlookup a l₂ :=\n  by\n  induction l₁ generalizing l₂\n  case nil => simp\n  case cons s _ ih =>\n    cases' s with a'\n    by_cases h₁ : a = a'\n    · subst h₁\n      simp\n    · let h₂ := @ih (kerase a' l₂)\n      simp [h₁] at h₂\n      simp [h₁, h₂]\n#align list.mem_lookup_kunion List.mem_dlookup_kunion\n-/\n\n#print List.mem_dlookup_kunion_middle /-\ntheorem mem_dlookup_kunion_middle {a} {b : β a} {l₁ l₂ l₃ : List (Sigma β)}\n    (h₁ : b ∈ dlookup a (kunion l₁ l₃)) (h₂ : a ∉ keys l₂) :\n    b ∈ dlookup a (kunion (kunion l₁ l₂) l₃) :=\n  match mem_dlookup_kunion.mp h₁ with\n  | Or.inl h => mem_dlookup_kunion.mpr (Or.inl (mem_dlookup_kunion.mpr (Or.inl h)))\n  | Or.inr h => mem_dlookup_kunion.mpr <| Or.inr ⟨mt mem_keys_kunion.mp (not_or.mpr ⟨h.1, h₂⟩), h.2⟩\n#align list.mem_lookup_kunion_middle List.mem_dlookup_kunion_middle\n-/\n\nend List\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/List/Sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.4625580803588928}}
{"text": "/-\n  Currently using this file as a playground to learn about meta programming in \n  LEAN but eventally I will implement a tactic that normalises simple ring expressions.\n\n  Monads in LEAN :\n\n  consider a function summing the 2/5/7 elements of a list, returning the value\n  rapped in some if there are enough elements in the list and none otherwise. \n  A naive implementation is the following,\n\n-/\n\ndef sum₂₅₇1 (l: list ℕ) : option ℕ :=\nmatch list.nth l 1 with \n| option.none    := option.none \n| option.some n₂ := match list.nth l 4 with \n                    | option.none    := option.none\n                    | option.some n₅ := match list.nth l 6 with \n                                        | option.none    := option.none \n                                        | option.some n₇ := option.some (n₂ + n₅ + n₇)\n                                        end\n                    end\nend\n\n/-\n  If we had a function that allow us to update the internal value of a option α via\n  a fn on the left we could rewrite this in a more imperative manner. \n-/\n\ndef connect {α β : Type} : option α → (α → option β) → option β \n| option.none _    := option.none \n| (option.some a) f := f a\n\n\ndef sum₂₅₇2 (l: list ℕ) : option ℕ := connect (list.nth l 1) \n                                      (λ n₂, connect (list.nth l 4) \n                                      (λ n₅, connect (list.nth l 6)\n                                      (λ n₇, option.some (n₂ + n₅ +n₇))))\n\n/-\n  connect is rewritten as >>= and pronounced \"bind\". \n  the function n ↦ some n is rewritten as \"pure\"\n-/\n\ndef sum₂₅₇3 (l: list ℕ) : option ℕ := \n  (list.nth l 1) >>= (λ n₂, \n  (list.nth l 4) >>= (λ n₅, \n  (list.nth l 6) >>= (λ n₇, \n  pure (n₂ + n₅ + n₇))))\n\n/-\n  this looks a lot like the imperative program\n  let n₂ = l[1];\n  let n₅ = l[4];\n  let n₆ = l[5];\n  return n₂ + n₅ + n₇\n\n  Functional programming languages the following notation\n  do x ← ma, t    is equiv to    ma >>= (λ x, t) \n-/\n\ndef sum₂₅₇4 (l: list ℕ) : option ℕ := do n₂ ← list.nth l 1,\n                                      (do n₅ ← list.nth l 4,\n                                      (do n₇ ← list.nth l 6,\n                                          pure (n₂ + n₅ + n₇)))\n\n \n/-\n  This look even more like an imperative program.\n\n  we can check that the following laws hold for option:\n  (*)\n  pure a >>= f = f a\n  m >>= pure = m\n  (m >>= f) >>= g = m >>= (λ x, (f x) >>= g)\n\n  so do x ← (pure a), pure (f x) = pure a >>= (λ x, pure (f x)) = pure (f a)\n  so we can think of the last term as the return value. (m >>= f) >>= g = m >>= (λ x, (f x) >>= g)\n  means we don't really care how the do's are bracketed in sum₂₅₇ so we can just drop them. \n-/\n\ndef sum₂₅₇5 (l: list ℕ) : option ℕ :=\n  do n₂ ← list.nth l 1,\n     n₅ ← list.nth l 5,\n     n₇ ← list.nth l 7,\n     pure (n₂ + n₅ + n₇)\n\n\n/-\n  any fn m : Type u → Type u with similar operations >>= and pure satifying (*)\n  is called a monad. Using >>= and pure we can defn m₁ >> m₂ = m₁ >>= (λ a, m₂).\n  do s, t is sugar for s >> t. <|> : m a → m a → m a trys the 1st arg then tries the\n  2nd.\n-/\n\n/-\n  The following stuff is from a meta programming paper.\n\n  Framework :\n\n  Add metaconstants -- to the axiomatic foundation are just opaque constants but when the\n  bytecode is evaluates them they are assoicted with internally defn gadgets. \n\n  An example is tactic_state which represents the internal elaborator state in the contex where\n  the tatic is invoked. \n\n  The metaprogramming API provides access to fns that operate on these. \n\n  the keyword meta gives access to these extensions.\n\n  Using these primatives a tactics monad is defined. This is also an instance of \n  the alternative type class so <|> can be used. \n\n  (a bit about names that I don't really understand)\n\n  Expressions in LEAN are represented using the following data types. \n\n  inductive level\n  | zero  : level\n  | succ  : level → level\n  | max   : level → level → level\n  | imax  : level → level → level\n  | param : name → level\n  | mvar  : name → level\n\n  inductive expr\n  | var    : nat → expr\n  | lconst : name → name → expr\n  | mvar   : name → expr → expr\n  | sort   : level → expr\n  | const  : name → list level → expr\n  | app    : expr → expr → expr\n  | lam    : name → binfo → expr → expr → expr\n  | pi     : name → binfo → expr → expr → expr\n  | elet   : name → expr → expr → expr → expr\n\n  the nats are de brujin indies, lconst/mvar should never be in any proof terms.\n\n-/\n\n\n", "meta": {"author": "CameronTorrance", "repo": "Schemes", "sha": "f407ce80b8407101231170680b03b55984c42496", "save_path": "github-repos/lean/CameronTorrance-Schemes", "path": "github-repos/lean/CameronTorrance-Schemes/Schemes-f407ce80b8407101231170680b03b55984c42496/src/misc/placetolearntactics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.46255807625817885}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport topology.category.Top.opens\n\n/-!\n# The category of open neighborhoods of a point\n\nGiven an object `X` of the category `Top` of topological spaces and a point `x : X`, this file\nbuilds the type `open_nhds x` of open neighborhoods of `x` in `X` and endows it with the partial\norder given by inclusion and the corresponding category structure (as a full subcategory of the\nposet category `set X`). This is used in `topology.sheaves.stalks` to build the stalk of a sheaf\nat `x` as a limit over `open_nhds x`.\n\n## Main declarations\n\nBesides `open_nhds`, the main constructions here are:\n\n* `inclusion (x : X)`: the obvious functor `open_nhds x ⥤ opens X`\n* `functor_nhds`: An open map `f : X ⟶ Y` induces a functor `open_nhds x ⥤ open_nhds (f x)`\n* `adjunction_nhds`: An open map `f : X ⟶ Y` induces an adjunction between `open_nhds x` and\n                     `open_nhds (f x)`.\n-/\n\nopen category_theory\nopen topological_space\nopen opposite\n\nuniverse u\n\nvariables {X Y : Top.{u}} (f : X ⟶ Y)\n\nnamespace topological_space\n\n/-- The type of open neighbourhoods of a point `x` in a (bundled) topological space. -/\ndef open_nhds (x : X) := full_subcategory (λ (U : opens X), x ∈ U)\n\nnamespace open_nhds\n\ninstance (x : X) : partial_order (open_nhds x) :=\n{ le := λ U V, U.1 ≤ V.1,\n  le_refl := λ _, le_rfl,\n  le_trans := λ _ _ _, le_trans,\n  le_antisymm := λ _ _ i j, full_subcategory.ext _ _ $ le_antisymm i j }\n\ninstance (x : X) : lattice (open_nhds x) :=\n{ inf := λ U V, ⟨U.1 ⊓ V.1, ⟨U.2, V.2⟩⟩,\n  le_inf := λ U V W, @le_inf _ _ U.1.1 V.1.1 W.1.1,\n  inf_le_left := λ U V, @inf_le_left _ _ U.1.1 V.1.1,\n  inf_le_right := λ U V, @inf_le_right _ _ U.1.1 V.1.1,\n  sup := λ U V, ⟨U.1 ⊔ V.1, V.1.1.mem_union_left U.2⟩,\n  sup_le := λ U V W, @sup_le _ _ U.1.1 V.1.1 W.1.1,\n  le_sup_left := λ U V, @le_sup_left _ _ U.1.1 V.1.1,\n  le_sup_right := λ U V, @le_sup_right _ _ U.1.1 V.1.1,\n  ..open_nhds.partial_order x }\n\ninstance (x : X) : order_top (open_nhds x) :=\n{ top := ⟨⊤, trivial⟩,\n  le_top := λ _, le_top }\n\ninstance (x : X) : inhabited (open_nhds x) := ⟨⊤⟩\n\ninstance open_nhds_category (x : X) : category.{u} (open_nhds x) :=\nby {unfold open_nhds, apply_instance}\n\ninstance opens_nhds_hom_has_coe_to_fun {x : X} {U V : open_nhds x} :\n  has_coe_to_fun (U ⟶ V) (λ _, U.1 → V.1) :=\n⟨λ f x, ⟨x, f.le x.2⟩⟩\n\n/--\nThe inclusion `U ⊓ V ⟶ U` as a morphism in the category of open sets.\n-/\ndef inf_le_left {x : X} (U V : open_nhds x) : U ⊓ V ⟶ U :=\nhom_of_le inf_le_left\n\n/--\nThe inclusion `U ⊓ V ⟶ V` as a morphism in the category of open sets.\n-/\ndef inf_le_right {x : X} (U V : open_nhds x) : U ⊓ V ⟶ V :=\nhom_of_le inf_le_right\n\n/-- The inclusion functor from open neighbourhoods of `x`\nto open sets in the ambient topological space. -/\ndef inclusion (x : X) : open_nhds x ⥤ opens X :=\nfull_subcategory_inclusion _\n\n@[simp] lemma inclusion_obj (x : X) (U) (p) : (inclusion x).obj ⟨U,p⟩ = U := rfl\n\nlemma open_embedding {x : X} (U : open_nhds x) : open_embedding (U.1.inclusion) :=\nU.1.open_embedding\n\n/-- The preimage functor from neighborhoods of `f x` to neighborhoods of `x`. -/\ndef map (x : X) : open_nhds (f x) ⥤ open_nhds x :=\n{ obj := λ U, ⟨(opens.map f).obj U.1, U.2⟩,\n  map := λ U V i, (opens.map f).map i }\n\n@[simp] lemma map_obj (x : X) (U) (q) : (map f x).obj ⟨U, q⟩ = ⟨(opens.map f).obj U, by tidy⟩ :=\nrfl\n@[simp] lemma map_id_obj (x : X) (U) : (map (𝟙 X) x).obj U = U :=\nby tidy\n@[simp] lemma map_id_obj' (x : X) (U) (p) (q) : (map (𝟙 X) x).obj ⟨⟨U, p⟩, q⟩ = ⟨⟨U, p⟩, q⟩ :=\nrfl\n\n@[simp] lemma map_id_obj_unop (x : X) (U : (open_nhds x)ᵒᵖ) : (map (𝟙 X) x).obj (unop U) = unop U :=\nby simp\n@[simp] lemma op_map_id_obj (x : X) (U : (open_nhds x)ᵒᵖ) : (map (𝟙 X) x).op.obj U = U :=\nby simp\n\n/-- `opens.map f` and `open_nhds.map f` form a commuting square (up to natural isomorphism)\nwith the inclusion functors into `opens X`. -/\ndef inclusion_map_iso (x : X) : inclusion (f x) ⋙ opens.map f ≅ map f x ⋙ inclusion x :=\nnat_iso.of_components\n  (λ U, begin split, exact 𝟙 _, exact 𝟙 _ end)\n  (by tidy)\n\n@[simp] lemma inclusion_map_iso_hom (x : X) : (inclusion_map_iso f x).hom = 𝟙 _ := rfl\n@[simp] lemma inclusion_map_iso_inv (x : X) : (inclusion_map_iso f x).inv = 𝟙 _ := rfl\n\nend open_nhds\n\nend topological_space\n\nnamespace is_open_map\n\nopen topological_space\n\nvariables {f}\n\n/--\nAn open map `f : X ⟶ Y` induces a functor `open_nhds x ⥤ open_nhds (f x)`.\n-/\n@[simps]\ndef functor_nhds (h : is_open_map f) (x : X) :\n  open_nhds x ⥤ open_nhds (f x) :=\n{ obj := λ U, ⟨h.functor.obj U.1, ⟨x, U.2, rfl⟩⟩,\n  map := λ U V i, h.functor.map i }\n\n/--\nAn open map `f : X ⟶ Y` induces an adjunction between `open_nhds x` and `open_nhds (f x)`.\n-/\ndef adjunction_nhds (h : is_open_map f) (x : X) :\n  is_open_map.functor_nhds h x ⊣ open_nhds.map f x :=\nadjunction.mk_of_unit_counit\n{ unit := { app := λ U, hom_of_le $ λ x hxU, ⟨x, hxU, rfl⟩ },\n  counit := { app := λ V, hom_of_le $ λ y ⟨x, hfxV, hxy⟩, hxy ▸ hfxV } }\n\nend is_open_map\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/category/Top/open_nhds.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6584174871563662, "lm_q1q2_score": 0.46255807504196883}}
{"text": "/-\nCopyright (c) 2016 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura\n-/\nprelude\nimport Init.SimpLemmas\nimport Init.Data.Nat.Basic\nopen Decidable List\n\nuniverses u v w\n\nvariable {α : Type u} {β : Type v} {γ : Type w}\n\nnamespace List\n\n@[simp] theorem length_nil : length ([] : List α) = 0 :=\n  rfl\n\ndef reverseAux : List α → List α → List α\n  | [],   r => r\n  | a::l, r => reverseAux l (a::r)\n\ndef reverse (as : List α) :List α :=\n  reverseAux as []\n\nprotected def append (as bs : List α) : List α :=\n  reverseAux as.reverse bs\n\ninstance : Append (List α) := ⟨List.append⟩\n\ntheorem reverseAux_reverseAux_nil (as bs : List α) : reverseAux (reverseAux as bs) [] = reverseAux bs as := by\n  induction as generalizing bs with\n  | nil => rfl\n  | cons a as ih => simp [reverseAux, ih]\n\n@[simp] theorem nil_append (as : List α) : [] ++ as = as := rfl\n\n@[simp] theorem append_nil (as : List α) : as ++ [] = as := by\n  show reverseAux (reverseAux as []) [] = as\n  simp [reverseAux_reverseAux_nil, reverseAux]\n\ntheorem reverseAux_reverseAux (as bs cs : List α) : reverseAux (reverseAux as bs) cs = reverseAux bs (reverseAux (reverseAux as []) cs) := by\n  induction as generalizing bs cs with\n  | nil => rfl\n  | cons a as ih => simp [reverseAux, ih (a::bs), ih [a]]\n\n@[simp] theorem cons_append (a : α) (as bs : List α) : (a::as) ++ bs = a::(as ++ bs) :=\n  reverseAux_reverseAux as [a] bs\n\ntheorem append_assoc (as bs cs : List α) : (as ++ bs) ++ cs = as ++ (bs ++ cs) := by\n  induction as with\n  | nil => rfl\n  | cons a as ih => simp [ih]\n\ninstance : EmptyCollection (List α) := ⟨List.nil⟩\n\nprotected def erase {α} [BEq α] : List α → α → List α\n  | [],    b => []\n  | a::as, b => match a == b with\n    | true  => as\n    | false => a :: List.erase as b\n\ndef eraseIdx : List α → Nat → List α\n  | [],    _   => []\n  | a::as, 0   => as\n  | a::as, n+1 => a :: eraseIdx as n\n\ndef isEmpty : List α → Bool\n  | []     => true\n  | _ :: _ => false\n\n@[specialize] def map (f : α → β) : List α → List β\n  | []    => []\n  | a::as => f a :: map f as\n\n@[specialize] def map₂ (f : α → β → γ) : List α → List β → List γ\n  | [],    _     => []\n  | _,     []    => []\n  | a::as, b::bs => f a b :: map₂ f as bs\n\ndef join : List (List α) → List α\n  | []      => []\n  | a :: as => a ++ join as\n\n@[specialize] def filterMap (f : α → Option β) : List α → List β\n  | []   => []\n  | a::as =>\n    match f a with\n    | none   => filterMap f as\n    | some b => b :: filterMap f as\n\n@[specialize] def filterAux (p : α → Bool) : List α → List α → List α\n  | [],    rs => rs.reverse\n  | a::as, rs => match p a with\n     | true  => filterAux p as (a::rs)\n     | false => filterAux p as rs\n\n@[inline] def filter (p : α → Bool) (as : List α) : List α :=\n  filterAux p as []\n\n@[specialize] def partitionAux (p : α → Bool) : List α → List α × List α → List α × List α\n  | [],    (bs, cs) => (bs.reverse, cs.reverse)\n  | a::as, (bs, cs) =>\n    match p a with\n    | true  => partitionAux p as (a::bs, cs)\n    | false => partitionAux p as (bs, a::cs)\n\n@[inline] def partition (p : α → Bool) (as : List α) : List α × List α :=\n  partitionAux p as ([], [])\n\ndef dropWhile (p : α → Bool) : List α → List α\n  | []   => []\n  | a::l => match p a with\n    | true  => dropWhile p l\n    | false =>  a::l\n\ndef find? (p : α → Bool) : List α → Option α\n  | []    => none\n  | a::as => match p a with\n    | true  => some a\n    | false => find? p as\n\ndef findSome? (f : α → Option β) : List α → Option β\n  | []    => none\n  | a::as => match f a with\n    | some b => some b\n    | none   => findSome? f as\n\ndef replace [BEq α] : List α → α → α → List α\n  | [],    _, _ => []\n  | a::as, b, c => match a == b with\n    | true  => c::as\n    | false => a :: (replace as b c)\n\ndef elem [BEq α] (a : α) : List α → Bool\n  | []    => false\n  | b::bs => match a == b with\n    | true  => true\n    | false => elem a bs\n\ndef notElem [BEq α] (a : α) (as : List α) : Bool :=\n  !(as.elem a)\n\nabbrev contains [BEq α] (as : List α) (a : α) : Bool :=\n  elem a as\n\ndef eraseDupsAux {α} [BEq α] : List α → List α → List α\n  | [],    bs => bs.reverse\n  | a::as, bs => match bs.elem a with\n    | true  => eraseDupsAux as bs\n    | false => eraseDupsAux as (a::bs)\n\ndef eraseDups {α} [BEq α] (as : List α) : List α :=\n  eraseDupsAux as []\n\ndef eraseRepsAux {α} [BEq α] : α → List α → List α → List α\n  | a, [], rs => (a::rs).reverse\n  | a, a'::as, rs => match a == a' with\n    | true  => eraseRepsAux a as rs\n    | false => eraseRepsAux a' as (a::rs)\n\n/-- Erase repeated adjacent elements. -/\ndef eraseReps {α} [BEq α] : List α → List α\n  | []    => []\n  | a::as => eraseRepsAux a as []\n\n@[specialize] def spanAux (p : α → Bool) : List α → List α → List α × List α\n  | [],    rs => (rs.reverse, [])\n  | a::as, rs => match p a with\n    | true  => spanAux p as (a::rs)\n    | false => (rs.reverse, a::as)\n\n@[inline] def span (p : α → Bool) (as : List α) : List α × List α :=\n  spanAux p as []\n\n@[specialize] def groupByAux (eq : α → α → Bool) : List α → List (List α) → List (List α)\n  | a::as, (ag::g)::gs => match eq a ag with\n    | true  => groupByAux eq as ((a::ag::g)::gs)\n    | false => groupByAux eq as ([a]::(ag::g).reverse::gs)\n  | _, gs => gs.reverse\n\n@[specialize] def groupBy (p : α → α → Bool) : List α → List (List α)\n  | []    => []\n  | a::as => groupByAux p as [[a]]\n\ndef lookup [BEq α] : α → List (α × β) → Option β\n  | _, []        => none\n  | a, (k,b)::es => match a == k with\n    | true  => some b\n    | false => lookup a es\n\ndef removeAll [BEq α] (xs ys : List α) : List α :=\n  xs.filter (fun x => ys.notElem x)\n\ndef drop : Nat → List α → List α\n  | 0,   a     => a\n  | n+1, []    => []\n  | n+1, a::as => drop n as\n\ndef take : Nat → List α → List α\n  | 0,   a     => []\n  | n+1, []    => []\n  | n+1, a::as => a :: take n as\n\n@[specialize] def foldr (f : α → β → β) (init : β) : List α → β\n  | []     => init\n  | a :: l => f a (foldr f init l)\n\n@[inline] def any (l : List α) (p : α → Bool) : Bool :=\n  foldr (fun a r => p a || r) false l\n\n@[inline] def all (l : List α) (p : α → Bool) : Bool :=\n  foldr (fun a r => p a && r) true l\n\ndef or  (bs : List Bool) : Bool := bs.any id\n\ndef and (bs : List Bool) : Bool := bs.all id\n\ndef zipWith (f : α → β → γ) : List α → List β → List γ\n  | x::xs, y::ys => f x y :: zipWith f xs ys\n  | _,     _     => []\n\ndef zip : List α → List β → List (Prod α β) :=\n  zipWith Prod.mk\n\ndef unzip : List (α × β) → List α × List β\n  | []          => ([], [])\n  | (a, b) :: t => match unzip t with | (al, bl) => (a::al, b::bl)\n\ndef rangeAux : Nat → List Nat → List Nat\n  | 0,   ns => ns\n  | n+1, ns => rangeAux n (n::ns)\n\ndef range (n : Nat) : List Nat :=\n  rangeAux n []\n\ndef iota : Nat → List Nat\n  | 0       => []\n  | m@(n+1) => m :: iota n\n\ndef enumFrom : Nat → List α → List (Nat × α)\n  | n, [] => nil\n  | n, x :: xs   => (n, x) :: enumFrom (n + 1) xs\n\ndef enum : List α → List (Nat × α) := enumFrom 0\n\ndef init : List α → List α\n  | []   => []\n  | [a]  => []\n  | a::l => a::init l\n\ndef intersperse (sep : α) : List α → List α\n  | []    => []\n  | [x]   => [x]\n  | x::xs => x :: sep :: intersperse sep xs\n\ndef intercalate (sep : List α) (xs : List (List α)) : List α :=\n  join (intersperse sep xs)\n\n@[inline] protected def bind {α : Type u} {β : Type v} (a : List α) (b : α → List β) : List β := join (map b a)\n\n@[inline] protected def pure {α : Type u} (a : α) : List α := [a]\n\ninductive lt [LT α] : List α → List α → Prop where\n  | nil  (b : α) (bs : List α) : lt [] (b::bs)\n  | head {a : α} (as : List α) {b : α} (bs : List α) : a < b → lt (a::as) (b::bs)\n  | tail {a : α} {as : List α} {b : α} {bs : List α} : ¬ a < b → ¬ b < a → lt as bs → lt (a::as) (b::bs)\n\ninstance [LT α] : LT (List α) := ⟨List.lt⟩\n\ninstance hasDecidableLt [LT α] [h : DecidableRel (α:=α) (·<·)] : (l₁ l₂ : List α) → Decidable (l₁ < l₂)\n  | [],    []    => isFalse (fun h => nomatch h)\n  | [],    b::bs => isTrue (List.lt.nil _ _)\n  | a::as, []    => isFalse (fun h => nomatch h)\n  | a::as, b::bs =>\n    match h a b with\n    | isTrue h₁  => isTrue (List.lt.head _ _ h₁)\n    | isFalse h₁ =>\n      match h b a with\n      | isTrue h₂  => isFalse (fun h => match h with\n         | List.lt.head _ _ h₁' => absurd h₁' h₁\n         | List.lt.tail _ h₂' _ => absurd h₂ h₂')\n      | isFalse h₂ =>\n        match hasDecidableLt as bs with\n        | isTrue h₃  => isTrue (List.lt.tail h₁ h₂ h₃)\n        | isFalse h₃ => isFalse (fun h => match h with\n           | List.lt.head _ _ h₁' => absurd h₁' h₁\n           | List.lt.tail _ _ h₃' => absurd h₃' h₃)\n\n@[reducible] protected def le [LT α] (a b : List α) : Prop := ¬ b < a\n\ninstance [LT α] : LE (List α) := ⟨List.le⟩\n\ninstance [LT α] [h : DecidableRel ((· < ·) : α → α → Prop)] : (l₁ l₂ : List α) → Decidable (l₁ ≤ l₂) :=\n  fun a b => inferInstanceAs (Decidable (Not _))\n\n/--  `isPrefixOf l₁ l₂` returns `true` Iff `l₁` is a prefix of `l₂`. -/\ndef isPrefixOf [BEq α] : List α → List α → Bool\n  | [],    _     => true\n  | _,     []    => false\n  | a::as, b::bs => a == b && isPrefixOf as bs\n\n/--  `isSuffixOf l₁ l₂` returns `true` Iff `l₁` is a suffix of `l₂`. -/\ndef isSuffixOf [BEq α] (l₁ l₂ : List α) : Bool :=\n  isPrefixOf l₁.reverse l₂.reverse\n\n@[specialize] def isEqv : List α → List α → (α → α → Bool) → Bool\n  | [],    [],    _   => true\n  | a::as, b::bs, eqv => eqv a b && isEqv as bs eqv\n  | _,     _,     eqv => false\n\nprotected def beq [BEq α] : List α → List α → Bool\n  | [],    []    => true\n  | a::as, b::bs => a == b && List.beq as bs\n  | _,     _     => false\n\ninstance [BEq α] : BEq (List α) := ⟨List.beq⟩\n\ndef replicate {α : Type u} (n : Nat) (a : α) : List α :=\n  let rec loop : Nat → List α → List α\n    | 0, as => as\n    | n+1, as => loop n (a::as)\n  loop n []\n\ndef dropLast {α} : List α → List α\n  | []    => []\n  | [a]   => []\n  | a::as => a :: dropLast as\n\n@[simp] theorem length_replicate (n : Nat) (a : α) : (replicate n a).length = n :=\n  let rec aux (n : Nat) (as : List α) : (replicate.loop a n as).length = n + as.length := by\n    induction n generalizing as with\n    | zero => simp [replicate.loop]\n    | succ n ih => simp [replicate.loop, ih, Nat.succ_add, Nat.add_succ]\n  aux n []\n\n@[simp] theorem length_concat (as : List α) (a : α) : (concat as a).length = as.length + 1 := by\n  induction as with\n  | nil => rfl\n  | cons x xs ih => simp [concat, ih]\n\n@[simp] theorem length_set (as : List α) (i : Nat) (a : α) : (as.set i a).length = as.length := by\n  induction as generalizing i with\n  | nil => rfl\n  | cons x xs ih =>\n    cases i with\n    | zero => rfl\n    | succ i => simp [set, ih]\n\n@[simp] theorem length_dropLast (as : List α) : as.dropLast.length = as.length - 1 := by\n  match as with\n  | []       => rfl\n  | [a]      => rfl\n  | a::b::as =>\n    have ih := length_dropLast (b::as)\n    simp[dropLast, ih]\n    rfl\n\nend List\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/stage0/src/Init/Data/List/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.7520125848754472, "lm_q1q2_score": 0.46255381876429735}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Mario Carneiro, Scott Morrison, Floris van Doorn\n-/\nimport category_theory.adjunction.basic\nimport category_theory.limits.cones\n\n/-!\n# Limits and colimits\n\nWe set up the general theory of limits and colimits in a category.\nIn this introduction we only describe the setup for limits;\nit is repeated, with slightly different names, for colimits.\n\nThe main structures defined in this file is\n* `is_limit c`, for `c : cone F`, `F : J ⥤ C`, expressing that `c` is a limit cone,\n\nSee also `category_theory.limits.has_limits` which further builds:\n* `limit_cone F`, which consists of a choice of cone for `F` and the fact it is a limit cone, and\n* `has_limit F`, asserting the mere existence of some limit cone for `F`.\n\n## Implementation\nAt present we simply say everything twice, in order to handle both limits and colimits.\nIt would be highly desirable to have some automation support,\ne.g. a `@[dualize]` attribute that behaves similarly to `@[to_additive]`.\n\n## References\n* [Stacks: Limits and colimits](https://stacks.math.columbia.edu/tag/002D)\n\n-/\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.functor opposite\n\nnamespace category_theory.limits\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄\n\nvariables {J : Type u₁} [category.{v₁} J] {K : Type u₂} [category.{v₂} K]\nvariables {C : Type u₃} [category.{v₃} C]\n\nvariables {F : J ⥤ C}\n\n/--\nA cone `t` on `F` is a limit cone if each cone on `F` admits a unique\ncone morphism to `t`.\n\nSee <https://stacks.math.columbia.edu/tag/002E>.\n  -/\n@[nolint has_inhabited_instance]\nstructure is_limit (t : cone F) :=\n(lift  : Π (s : cone F), s.X ⟶ t.X)\n(fac'  : ∀ (s : cone F) (j : J), lift s ≫ t.π.app j = s.π.app j . obviously)\n(uniq' : ∀ (s : cone F) (m : s.X ⟶ t.X) (w : ∀ j : J, m ≫ t.π.app j = s.π.app j),\n  m = lift s . obviously)\n\nrestate_axiom is_limit.fac'\nattribute [simp, reassoc] is_limit.fac\nrestate_axiom is_limit.uniq'\n\nnamespace is_limit\n\ninstance subsingleton {t : cone F} : subsingleton (is_limit t) :=\n⟨by intros P Q; cases P; cases Q; congr; ext; solve_by_elim⟩\n\n/-- Given a natural transformation `α : F ⟶ G`, we give a morphism from the cone point\nof any cone over `F` to the cone point of a limit cone over `G`. -/\ndef map {F G : J ⥤ C} (s : cone F) {t : cone G} (P : is_limit t)\n  (α : F ⟶ G) : s.X ⟶ t.X :=\nP.lift ((cones.postcompose α).obj s)\n\n@[simp, reassoc] lemma map_π {F G : J ⥤ C} (c : cone F) {d : cone G} (hd : is_limit d)\n  (α : F ⟶ G) (j : J) : hd.map c α ≫ d.π.app j = c.π.app j ≫ α.app j :=\nfac _ _ _\n\nlemma lift_self {c : cone F} (t : is_limit c) : t.lift c = 𝟙 c.X :=\n(t.uniq _ _ (λ j, id_comp _)).symm\n\n/- Repackaging the definition in terms of cone morphisms. -/\n\n/-- The universal morphism from any other cone to a limit cone. -/\n@[simps]\ndef lift_cone_morphism {t : cone F} (h : is_limit t) (s : cone F) : s ⟶ t :=\n{ hom := h.lift s }\n\nlemma uniq_cone_morphism {s t : cone F} (h : is_limit t) {f f' : s ⟶ t} :\n  f = f' :=\nhave ∀ {g : s ⟶ t}, g = h.lift_cone_morphism s, by intro g; ext; exact h.uniq _ _ g.w,\nthis.trans this.symm\n\n/-- Restating the definition of a limit cone in terms of the ∃! operator. -/\nlemma exists_unique {t : cone F} (h : is_limit t) (s : cone F) :\n  ∃! (l : s.X ⟶ t.X), ∀ j, l ≫ t.π.app j = s.π.app j :=\n⟨h.lift s, h.fac s, h.uniq s⟩\n\n/-- Noncomputably make a colimit cocone from the existence of unique factorizations. -/\ndef of_exists_unique {t : cone F}\n  (ht : ∀ s : cone F, ∃! l : s.X ⟶ t.X, ∀ j, l ≫ t.π.app j = s.π.app j) : is_limit t :=\nby { choose s hs hs' using ht, exact ⟨s, hs, hs'⟩ }\n\n/--\nAlternative constructor for `is_limit`,\nproviding a morphism of cones rather than a morphism between the cone points\nand separately the factorisation condition.\n-/\n@[simps]\ndef mk_cone_morphism {t : cone F}\n  (lift : Π (s : cone F), s ⟶ t)\n  (uniq' : ∀ (s : cone F) (m : s ⟶ t), m = lift s) : is_limit t :=\n{ lift := λ s, (lift s).hom,\n  uniq' := λ s m w,\n    have cone_morphism.mk m w = lift s, by apply uniq',\n    congr_arg cone_morphism.hom this }\n\n/-- Limit cones on `F` are unique up to isomorphism. -/\n@[simps]\ndef unique_up_to_iso {s t : cone F} (P : is_limit s) (Q : is_limit t) : s ≅ t :=\n{ hom := Q.lift_cone_morphism s,\n  inv := P.lift_cone_morphism t,\n  hom_inv_id' := P.uniq_cone_morphism,\n  inv_hom_id' := Q.uniq_cone_morphism }\n\n/-- Any cone morphism between limit cones is an isomorphism. -/\nlemma hom_is_iso {s t : cone F} (P : is_limit s) (Q : is_limit t) (f : s ⟶ t) : is_iso f :=\n⟨⟨P.lift_cone_morphism t, ⟨P.uniq_cone_morphism, Q.uniq_cone_morphism⟩⟩⟩\n\n/-- Limits of `F` are unique up to isomorphism. -/\ndef cone_point_unique_up_to_iso {s t : cone F} (P : is_limit s) (Q : is_limit t) : s.X ≅ t.X :=\n(cones.forget F).map_iso (unique_up_to_iso P Q)\n\n@[simp, reassoc] lemma cone_point_unique_up_to_iso_hom_comp {s t : cone F} (P : is_limit s)\n  (Q : is_limit t) (j : J) : (cone_point_unique_up_to_iso P Q).hom ≫ t.π.app j = s.π.app j :=\n(unique_up_to_iso P Q).hom.w _\n\n@[simp, reassoc] lemma cone_point_unique_up_to_iso_inv_comp {s t : cone F} (P : is_limit s)\n  (Q : is_limit t) (j : J) : (cone_point_unique_up_to_iso P Q).inv ≫ s.π.app j = t.π.app j :=\n(unique_up_to_iso P Q).inv.w _\n\n@[simp, reassoc] lemma lift_comp_cone_point_unique_up_to_iso_hom {r s t : cone F}\n  (P : is_limit s) (Q : is_limit t) :\n  P.lift r ≫ (cone_point_unique_up_to_iso P Q).hom = Q.lift r :=\nQ.uniq _ _ (by simp)\n\n@[simp, reassoc] lemma lift_comp_cone_point_unique_up_to_iso_inv {r s t : cone F}\n  (P : is_limit s) (Q : is_limit t) :\n  Q.lift r ≫ (cone_point_unique_up_to_iso P Q).inv = P.lift r :=\nP.uniq _ _ (by simp)\n\n/-- Transport evidence that a cone is a limit cone across an isomorphism of cones. -/\ndef of_iso_limit {r t : cone F} (P : is_limit r) (i : r ≅ t) : is_limit t :=\nis_limit.mk_cone_morphism\n  (λ s, P.lift_cone_morphism s ≫ i.hom)\n  (λ s m, by rw ←i.comp_inv_eq; apply P.uniq_cone_morphism)\n\n@[simp] lemma of_iso_limit_lift {r t : cone F} (P : is_limit r) (i : r ≅ t) (s) :\n  (P.of_iso_limit i).lift s = P.lift s ≫ i.hom.hom :=\nrfl\n\n/-- Isomorphism of cones preserves whether or not they are limiting cones. -/\ndef equiv_iso_limit {r t : cone F} (i : r ≅ t) : is_limit r ≃ is_limit t :=\n{ to_fun := λ h, h.of_iso_limit i,\n  inv_fun := λ h, h.of_iso_limit i.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\n@[simp] lemma equiv_iso_limit_apply {r t : cone F} (i : r ≅ t) (P : is_limit r) :\n  equiv_iso_limit i P = P.of_iso_limit i := rfl\n\n@[simp] lemma equiv_iso_limit_symm_apply {r t : cone F} (i : r ≅ t) (P : is_limit t) :\n  (equiv_iso_limit i).symm P = P.of_iso_limit i.symm := rfl\n\n/--\nIf the canonical morphism from a cone point to a limiting cone point is an iso, then the\nfirst cone was limiting also.\n-/\ndef of_point_iso {r t : cone F} (P : is_limit r) [i : is_iso (P.lift t)] : is_limit t :=\nof_iso_limit P\nbegin\n  haveI : is_iso (P.lift_cone_morphism t).hom := i,\n  haveI : is_iso (P.lift_cone_morphism t) := cones.cone_iso_of_hom_iso _,\n  symmetry,\n  apply as_iso (P.lift_cone_morphism t),\nend\n\nvariables {t : cone F}\n\nlemma hom_lift (h : is_limit t) {W : C} (m : W ⟶ t.X) :\n  m = h.lift { X := W, π := { app := λ b, m ≫ t.π.app b } } :=\nh.uniq { X := W, π := { app := λ b, m ≫ t.π.app b } } m (λ b, rfl)\n\n/-- Two morphisms into a limit are equal if their compositions with\n  each cone morphism are equal. -/\nlemma hom_ext (h : is_limit t) {W : C} {f f' : W ⟶ t.X}\n  (w : ∀ j, f ≫ t.π.app j = f' ≫ t.π.app j) : f = f' :=\nby rw [h.hom_lift f, h.hom_lift f']; congr; exact funext w\n\n/--\nGiven a right adjoint functor between categories of cones,\nthe image of a limit cone is a limit cone.\n-/\ndef of_right_adjoint {D : Type u₄} [category.{v₄} D] {G : K ⥤ D}\n  (h : cone G ⥤ cone F) [is_right_adjoint h] {c : cone G} (t : is_limit c) :\n  is_limit (h.obj c) :=\nmk_cone_morphism\n  (λ s, (adjunction.of_right_adjoint h).hom_equiv s c (t.lift_cone_morphism _))\n  (λ s m, (adjunction.eq_hom_equiv_apply _ _ _).2 t.uniq_cone_morphism)\n\n/--\nGiven two functors which have equivalent categories of cones, we can transport a limiting cone\nacross the equivalence.\n-/\ndef of_cone_equiv {D : Type u₄} [category.{v₄} D] {G : K ⥤ D}\n  (h : cone G ≌ cone F) {c : cone G} :\n  is_limit (h.functor.obj c) ≃ is_limit c :=\n{ to_fun := λ P, of_iso_limit (of_right_adjoint h.inverse P) (h.unit_iso.symm.app c),\n  inv_fun := of_right_adjoint h.functor,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\n@[simp] lemma of_cone_equiv_apply_desc {D : Type u₄} [category.{v₄} D] {G : K ⥤ D}\n  (h : cone G ≌ cone F) {c : cone G} (P : is_limit (h.functor.obj c)) (s) :\n  (of_cone_equiv h P).lift s =\n    ((h.unit_iso.hom.app s).hom ≫\n      (h.functor.inv.map (P.lift_cone_morphism (h.functor.obj s))).hom) ≫\n      (h.unit_iso.inv.app c).hom :=\nrfl\n\n@[simp] \n\n/--\nA cone postcomposed with a natural isomorphism is a limit cone if and only if the original cone is.\n-/\ndef postcompose_hom_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cone F) :\n  is_limit ((cones.postcompose α.hom).obj c) ≃ is_limit c :=\nof_cone_equiv (cones.postcompose_equivalence α)\n\n/--\nA cone postcomposed with the inverse of a natural isomorphism is a limit cone if and only if\nthe original cone is.\n-/\ndef postcompose_inv_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cone G) :\n  is_limit ((cones.postcompose α.inv).obj c) ≃ is_limit c :=\npostcompose_hom_equiv α.symm c\n\n/--\nConstructing an equivalence `is_limit c ≃ is_limit d` from a natural isomorphism\nbetween the underlying functors, and then an isomorphism between `c` transported along this and `d`.\n-/\ndef equiv_of_nat_iso_of_iso {F G : J ⥤ C} (α : F ≅ G) (c : cone F) (d : cone G)\n  (w : (cones.postcompose α.hom).obj c ≅ d) :\n  is_limit c ≃ is_limit d :=\n(postcompose_hom_equiv α _).symm.trans (equiv_iso_limit w)\n\n/--\nThe cone points of two limit cones for naturally isomorphic functors\nare themselves isomorphic.\n-/\n@[simps]\ndef cone_points_iso_of_nat_iso {F G : J ⥤ C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) : s.X ≅ t.X :=\n{ hom := Q.map s w.hom,\n  inv := P.map t w.inv,\n  hom_inv_id' := P.hom_ext (by tidy),\n  inv_hom_id' := Q.hom_ext (by tidy), }\n\n@[reassoc]\nlemma cone_points_iso_of_nat_iso_hom_comp {F G : J ⥤ C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).hom ≫ t.π.app j = s.π.app j ≫ w.hom.app j :=\nby simp\n\n@[reassoc]\nlemma cone_points_iso_of_nat_iso_inv_comp {F G : J ⥤ C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).inv ≫ s.π.app j = t.π.app j ≫ w.inv.app j :=\nby simp\n\n@[reassoc]\nlemma lift_comp_cone_points_iso_of_nat_iso_hom {F G : J ⥤ C} {r s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F ≅ G) :\n  P.lift r ≫ (cone_points_iso_of_nat_iso P Q w).hom = Q.map r w.hom :=\nQ.hom_ext (by simp)\n\n@[reassoc]\nlemma lift_comp_cone_points_iso_of_nat_iso_inv {F G : J ⥤ C} {r s : cone G} {t : cone F}\n  (P : is_limit t) (Q : is_limit s) (w : F ≅ G) :\n  Q.lift r ≫ (cone_points_iso_of_nat_iso P Q w).inv = P.map r w.inv :=\nP.hom_ext (by simp)\n\nsection equivalence\nopen category_theory.equivalence\n\n/--\nIf `s : cone F` is a limit cone, so is `s` whiskered by an equivalence `e`.\n-/\ndef whisker_equivalence {s : cone F} (P : is_limit s) (e : K ≌ J) :\n  is_limit (s.whisker e.functor) :=\nof_right_adjoint (cones.whiskering_equivalence e).functor P\n\n/--\nIf `s : cone F` whiskered by an equivalence `e` is a limit cone, so is `s`.\n-/\ndef of_whisker_equivalence {s : cone F} (e : K ≌ J) (P : is_limit (s.whisker e.functor)) :\n  is_limit s :=\nequiv_iso_limit ((cones.whiskering_equivalence e).unit_iso.app s).symm\n  (of_right_adjoint (cones.whiskering_equivalence e).inverse P : _)\n\n/--\nGiven an equivalence of diagrams `e`, `s` is a limit cone iff `s.whisker e.functor` is.\n-/\ndef whisker_equivalence_equiv {s : cone F} (e : K ≌ J) :\n  is_limit s ≃ is_limit (s.whisker e.functor) :=\n⟨λ h, h.whisker_equivalence e, of_whisker_equivalence e, by tidy, by tidy⟩\n\n/--\nWe can prove two cone points `(s : cone F).X` and `(t.cone G).X` are isomorphic if\n* both cones are limit cones\n* their indexing categories are equivalent via some `e : J ≌ K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor ⋙ G ≅ F`.\n\nThis is the most general form of uniqueness of cone points,\nallowing relabelling of both the indexing category (up to equivalence)\nand the functor (up to natural isomorphism).\n-/\n@[simps]\ndef cone_points_iso_of_equivalence {F : J ⥤ C} {s : cone F} {G : K ⥤ C} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (e : J ≌ K) (w : e.functor ⋙ G ≅ F) : s.X ≅ t.X :=\nlet w' : e.inverse ⋙ F ≅ G := (iso_whisker_left e.inverse w).symm ≪≫ inv_fun_id_assoc e G in\n{ hom := Q.lift ((cones.equivalence_of_reindexing e.symm w').functor.obj s),\n  inv := P.lift ((cones.equivalence_of_reindexing e w).functor.obj t),\n  hom_inv_id' :=\n  begin\n    apply hom_ext P, intros j,\n    dsimp,\n    simp only [limits.cone.whisker_π, limits.cones.postcompose_obj_π, fac, whisker_left_app,\n      assoc, id_comp, inv_fun_id_assoc_hom_app, fac_assoc, nat_trans.comp_app],\n    rw [counit_app_functor, ←functor.comp_map, w.hom.naturality],\n    simp,\n  end,\n  inv_hom_id' := by { apply hom_ext Q, tidy, }, }\n\nend equivalence\n\n/-- The universal property of a limit cone: a map `W ⟶ X` is the same as\n  a cone on `F` with vertex `W`. -/\ndef hom_iso (h : is_limit t) (W : C) : ulift.{u₁} (W ⟶ t.X : Type v₃) ≅ (const J).obj W ⟶ F :=\n{ hom := λ f, (t.extend f.down).π,\n  inv := λ π, ⟨h.lift { X := W, π := π }⟩,\n  hom_inv_id' := by ext f; apply h.hom_ext; intro j; simp; dsimp; refl }\n\n@[simp] lemma hom_iso_hom (h : is_limit t) {W : C} (f : ulift.{u₁} (W ⟶ t.X)) :\n  (is_limit.hom_iso h W).hom f = (t.extend f.down).π := rfl\n\n/-- The limit of `F` represents the functor taking `W` to\n  the set of cones on `F` with vertex `W`. -/\ndef nat_iso (h : is_limit t) : yoneda.obj t.X ⋙ ulift_functor.{u₁} ≅ F.cones :=\nnat_iso.of_components (λ W, is_limit.hom_iso h (unop W)) (by tidy).\n\n/--\nAnother, more explicit, formulation of the universal property of a limit cone.\nSee also `hom_iso`.\n-/\ndef hom_iso' (h : is_limit t) (W : C) :\n  ulift.{u₁} ((W ⟶ t.X) : Type v₃) ≅\n    { p : Π j, W ⟶ F.obj j // ∀ {j j'} (f : j ⟶ j'), p j ≫ F.map f = p j' } :=\nh.hom_iso W ≪≫\n{ hom := λ π,\n  ⟨λ j, π.app j, λ j j' f,\n   by convert ←(π.naturality f).symm; apply id_comp⟩,\n  inv := λ p,\n  { app := λ j, p.1 j,\n    naturality' := λ j j' f, begin dsimp, rw [id_comp], exact (p.2 f).symm end } }\n\n/-- If G : C → D is a faithful functor which sends t to a limit cone,\n  then it suffices to check that the induced maps for the image of t\n  can be lifted to maps of C. -/\ndef of_faithful {t : cone F} {D : Type u₄} [category.{v₄} D] (G : C ⥤ D) [faithful G]\n  (ht : is_limit (G.map_cone t)) (lift : Π (s : cone F), s.X ⟶ t.X)\n  (h : ∀ s, G.map (lift s) = ht.lift (G.map_cone s)) : is_limit t :=\n{ lift := lift,\n  fac' := λ s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := λ s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cone s) _ (λ j, _),\n    convert ←congr_arg (λ f, G.map f) (w j),\n    apply G.map_comp\n  end }\n\n/--\nIf `F` and `G` are naturally isomorphic, then `F.map_cone c` being a limit implies\n`G.map_cone c` is also a limit.\n-/\ndef map_cone_equiv {D : Type u₄} [category.{v₄} D]\n  {K : J ⥤ C} {F G : C ⥤ D} (h : F ≅ G) {c : cone K}\n  (t : is_limit (F.map_cone c)) : is_limit (G.map_cone c) :=\nbegin\n  apply postcompose_inv_equiv (iso_whisker_left K h : _) (G.map_cone c) _,\n  apply t.of_iso_limit (postcompose_whisker_left_map_cone h.symm c).symm,\nend\n\n/--\nA cone is a limit cone exactly if\nthere is a unique cone morphism from any other cone.\n-/\ndef iso_unique_cone_morphism {t : cone F} :\n  is_limit t ≅ Π s, unique (s ⟶ t) :=\n{ hom := λ h s,\n  { default := h.lift_cone_morphism s,\n    uniq := λ _, h.uniq_cone_morphism },\n  inv := λ h,\n  { lift := λ s, (h s).default.hom,\n    uniq' := λ s f w, congr_arg cone_morphism.hom ((h s).uniq ⟨f, w⟩) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : yoneda.obj X ⋙ ulift_functor.{u₁} ≅ F.cones)\n\n/-- If `F.cones` is represented by `X`, each morphism `f : Y ⟶ X` gives a cone with cone point\n`Y`. -/\ndef cone_of_hom {Y : C} (f : Y ⟶ X) : cone F :=\n{ X := Y, π := h.hom.app (op Y) ⟨f⟩ }\n\n/-- If `F.cones` is represented by `X`, each cone `s` gives a morphism `s.X ⟶ X`. -/\ndef hom_of_cone (s : cone F) : s.X ⟶ X := (h.inv.app (op s.X) s.π).down\n\n@[simp] lemma cone_of_hom_of_cone (s : cone F) : cone_of_hom h (hom_of_cone h s) = s :=\nbegin\n  dsimp [cone_of_hom, hom_of_cone], cases s, congr, dsimp,\n  convert congr_fun (congr_fun (congr_arg nat_trans.app h.inv_hom_id) (op s_X)) s_π,\n  exact ulift.up_down _\nend\n\n@[simp] lemma hom_of_cone_of_hom {Y : C} (f : Y ⟶ X) : hom_of_cone h (cone_of_hom h f) = f :=\ncongr_arg ulift.down (congr_fun (congr_fun (congr_arg nat_trans.app h.hom_inv_id) (op Y)) ⟨f⟩ : _)\n\n/-- If `F.cones` is represented by `X`, the cone corresponding to the identity morphism on `X`\nwill be a limit cone. -/\ndef limit_cone : cone F :=\ncone_of_hom h (𝟙 X)\n\n/-- If `F.cones` is represented by `X`, the cone corresponding to a morphism `f : Y ⟶ X` is\nthe limit cone extended by `f`. -/\nlemma cone_of_hom_fac {Y : C} (f : Y ⟶ X) :\ncone_of_hom h f = (limit_cone h).extend f :=\nbegin\n  dsimp [cone_of_hom, limit_cone, cone.extend],\n  congr' with j,\n  have t := congr_fun (h.hom.naturality f.op) ⟨𝟙 X⟩,\n  dsimp at t,\n  simp only [comp_id] at t,\n  rw congr_fun (congr_arg nat_trans.app t) j,\n  refl,\nend\n\n/-- If `F.cones` is represented by `X`, any cone is the extension of the limit cone by the\ncorresponding morphism. -/\nlemma cone_fac (s : cone F) : (limit_cone h).extend (hom_of_cone h s) = s :=\nbegin\n  rw ←cone_of_hom_of_cone h s,\n  conv_lhs { simp only [hom_of_cone_of_hom] },\n  apply (cone_of_hom_fac _ _).symm,\nend\n\nend of_nat_iso\n\nsection\nopen of_nat_iso\n\n/--\nIf `F.cones` is representable, then the cone corresponding to the identity morphism on\nthe representing object is a limit cone.\n-/\ndef of_nat_iso {X : C} (h : yoneda.obj X ⋙ ulift_functor.{u₁} ≅ F.cones) :\n  is_limit (limit_cone h) :=\n{ lift := λ s, hom_of_cone h s,\n  fac' := λ s j,\n  begin\n    have h := cone_fac h s,\n    cases s,\n    injection h with h₁ h₂,\n    simp only [heq_iff_eq] at h₂,\n    conv_rhs { rw ← h₂ }, refl,\n  end,\n  uniq' := λ s m w,\n  begin\n    rw ←hom_of_cone_of_hom h m,\n    congr,\n    rw cone_of_hom_fac,\n    dsimp [cone.extend], cases s, congr' with j, exact w j,\n  end }\nend\n\nend is_limit\n\n/--\nA cocone `t` on `F` is a colimit cocone if each cocone on `F` admits a unique\ncocone morphism from `t`.\n\nSee <https://stacks.math.columbia.edu/tag/002F>.\n-/\n@[nolint has_inhabited_instance]\nstructure is_colimit (t : cocone F) :=\n(desc  : Π (s : cocone F), t.X ⟶ s.X)\n(fac'  : ∀ (s : cocone F) (j : J), t.ι.app j ≫ desc s = s.ι.app j . obviously)\n(uniq' : ∀ (s : cocone F) (m : t.X ⟶ s.X) (w : ∀ j : J, t.ι.app j ≫ m = s.ι.app j),\n  m = desc s . obviously)\n\nrestate_axiom is_colimit.fac'\nattribute [simp,reassoc] is_colimit.fac\nrestate_axiom is_colimit.uniq'\n\nnamespace is_colimit\n\ninstance subsingleton {t : cocone F} : subsingleton (is_colimit t) :=\n⟨by intros P Q; cases P; cases Q; congr; ext; solve_by_elim⟩\n\n/-- Given a natural transformation `α : F ⟶ G`, we give a morphism from the cocone point\nof a colimit cocone over `F` to the cocone point of any cocone over `G`. -/\ndef map {F G : J ⥤ C} {s : cocone F} (P : is_colimit s) (t : cocone G)\n  (α : F ⟶ G) : s.X ⟶ t.X :=\nP.desc ((cocones.precompose α).obj t)\n\n@[simp, reassoc]\nlemma ι_map {F G : J ⥤ C} {c : cocone F} (hc : is_colimit c) (d : cocone G) (α : F ⟶ G)\n  (j : J) : c.ι.app j ≫ is_colimit.map hc d α = α.app j ≫ d.ι.app j :=\nfac _ _ _\n\n@[simp]\nlemma desc_self {t : cocone F} (h : is_colimit t) : h.desc t = 𝟙 t.X :=\n(h.uniq _ _ (λ j, comp_id _)).symm\n\n/- Repackaging the definition in terms of cocone morphisms. -/\n\n/-- The universal morphism from a colimit cocone to any other cocone. -/\n@[simps]\ndef desc_cocone_morphism {t : cocone F} (h : is_colimit t) (s : cocone F) : t ⟶ s :=\n{ hom := h.desc s }\n\nlemma uniq_cocone_morphism {s t : cocone F} (h : is_colimit t) {f f' : t ⟶ s} :\n  f = f' :=\nhave ∀ {g : t ⟶ s}, g = h.desc_cocone_morphism s, by intro g; ext; exact h.uniq _ _ g.w,\nthis.trans this.symm\n\n/-- Restating the definition of a colimit cocone in terms of the ∃! operator. -/\nlemma exists_unique {t : cocone F} (h : is_colimit t) (s : cocone F) :\n  ∃! (d : t.X ⟶ s.X), ∀ j, t.ι.app j ≫ d = s.ι.app j :=\n⟨h.desc s, h.fac s, h.uniq s⟩\n\n/-- Noncomputably make a colimit cocone from the existence of unique factorizations. -/\ndef of_exists_unique {t : cocone F}\n  (ht : ∀ s : cocone F, ∃! d : t.X ⟶ s.X, ∀ j, t.ι.app j ≫ d = s.ι.app j) : is_colimit t :=\nby { choose s hs hs' using ht, exact ⟨s, hs, hs'⟩ }\n\n/--\nAlternative constructor for `is_colimit`,\nproviding a morphism of cocones rather than a morphism between the cocone points\nand separately the factorisation condition.\n-/\n@[simps]\ndef mk_cocone_morphism {t : cocone F}\n  (desc : Π (s : cocone F), t ⟶ s)\n  (uniq' : ∀ (s : cocone F) (m : t ⟶ s), m = desc s) : is_colimit t :=\n{ desc := λ s, (desc s).hom,\n  uniq' := λ s m w,\n    have cocone_morphism.mk m w = desc s, by apply uniq',\n    congr_arg cocone_morphism.hom this }\n\n/-- Colimit cocones on `F` are unique up to isomorphism. -/\n@[simps]\ndef unique_up_to_iso {s t : cocone F} (P : is_colimit s) (Q : is_colimit t) : s ≅ t :=\n{ hom := P.desc_cocone_morphism t,\n  inv := Q.desc_cocone_morphism s,\n  hom_inv_id' := P.uniq_cocone_morphism,\n  inv_hom_id' := Q.uniq_cocone_morphism }\n\n/-- Any cocone morphism between colimit cocones is an isomorphism. -/\nlemma hom_is_iso {s t : cocone F} (P : is_colimit s) (Q : is_colimit t) (f : s ⟶ t) : is_iso f :=\n⟨⟨Q.desc_cocone_morphism s, ⟨P.uniq_cocone_morphism, Q.uniq_cocone_morphism⟩⟩⟩\n\n/-- Colimits of `F` are unique up to isomorphism. -/\ndef cocone_point_unique_up_to_iso {s t : cocone F} (P : is_colimit s) (Q : is_colimit t) :\n  s.X ≅ t.X :=\n(cocones.forget F).map_iso (unique_up_to_iso P Q)\n\n@[simp, reassoc] lemma comp_cocone_point_unique_up_to_iso_hom {s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) (j : J) : s.ι.app j ≫ (cocone_point_unique_up_to_iso P Q).hom = t.ι.app j :=\n(unique_up_to_iso P Q).hom.w _\n\n@[simp, reassoc] lemma comp_cocone_point_unique_up_to_iso_inv {s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) (j : J) : t.ι.app j ≫ (cocone_point_unique_up_to_iso P Q).inv = s.ι.app j :=\n(unique_up_to_iso P Q).inv.w _\n\n@[simp, reassoc] lemma cocone_point_unique_up_to_iso_hom_desc {r s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) : (cocone_point_unique_up_to_iso P Q).hom ≫ Q.desc r = P.desc r :=\nP.uniq _ _ (by simp)\n\n@[simp, reassoc] lemma cocone_point_unique_up_to_iso_inv_desc {r s t : cocone F} (P : is_colimit s)\n  (Q : is_colimit t) : (cocone_point_unique_up_to_iso P Q).inv ≫ P.desc r = Q.desc r :=\nQ.uniq _ _ (by simp)\n\n/-- Transport evidence that a cocone is a colimit cocone across an isomorphism of cocones. -/\ndef of_iso_colimit {r t : cocone F} (P : is_colimit r) (i : r ≅ t) : is_colimit t :=\nis_colimit.mk_cocone_morphism\n  (λ s, i.inv ≫ P.desc_cocone_morphism s)\n  (λ s m, by rw i.eq_inv_comp; apply P.uniq_cocone_morphism)\n\n@[simp] lemma of_iso_colimit_desc {r t : cocone F} (P : is_colimit r) (i : r ≅ t) (s) :\n  (P.of_iso_colimit i).desc s = i.inv.hom ≫ P.desc s :=\nrfl\n\n/-- Isomorphism of cocones preserves whether or not they are colimiting cocones. -/\ndef equiv_iso_colimit {r t : cocone F} (i : r ≅ t) : is_colimit r ≃ is_colimit t :=\n{ to_fun := λ h, h.of_iso_colimit i,\n  inv_fun := λ h, h.of_iso_colimit i.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\n@[simp] lemma equiv_iso_colimit_apply {r t : cocone F} (i : r ≅ t) (P : is_colimit r) :\n  equiv_iso_colimit i P = P.of_iso_colimit i := rfl\n\n@[simp] lemma equiv_iso_colimit_symm_apply {r t : cocone F} (i : r ≅ t) (P : is_colimit t) :\n  (equiv_iso_colimit i).symm P = P.of_iso_colimit i.symm := rfl\n\n/--\nIf the canonical morphism to a cocone point from a colimiting cocone point is an iso, then the\nfirst cocone was colimiting also.\n-/\ndef of_point_iso {r t : cocone F} (P : is_colimit r) [i : is_iso (P.desc t)] : is_colimit t :=\nof_iso_colimit P\nbegin\n  haveI : is_iso (P.desc_cocone_morphism t).hom := i,\n  haveI : is_iso (P.desc_cocone_morphism t) := cocones.cocone_iso_of_hom_iso _,\n  apply as_iso (P.desc_cocone_morphism t),\nend\n\nvariables {t : cocone F}\n\nlemma hom_desc (h : is_colimit t) {W : C} (m : t.X ⟶ W) :\n  m = h.desc { X := W, ι := { app := λ b, t.ι.app b ≫ m,\n    naturality' := by intros; erw [←assoc, t.ι.naturality, comp_id, comp_id] } } :=\nh.uniq { X := W, ι := { app := λ b, t.ι.app b ≫ m, naturality' := _ } } m (λ b, rfl)\n\n/-- Two morphisms out of a colimit are equal if their compositions with\n  each cocone morphism are equal. -/\nlemma hom_ext (h : is_colimit t) {W : C} {f f' : t.X ⟶ W}\n  (w : ∀ j, t.ι.app j ≫ f = t.ι.app j ≫ f') : f = f' :=\nby rw [h.hom_desc f, h.hom_desc f']; congr; exact funext w\n\n/--\nGiven a left adjoint functor between categories of cocones,\nthe image of a colimit cocone is a colimit cocone.\n-/\ndef of_left_adjoint {D : Type u₄} [category.{v₄} D] {G : K ⥤ D}\n  (h : cocone G ⥤ cocone F) [is_left_adjoint h] {c : cocone G} (t : is_colimit c) :\n  is_colimit (h.obj c) :=\nmk_cocone_morphism\n  (λ s, ((adjunction.of_left_adjoint h).hom_equiv c s).symm (t.desc_cocone_morphism _))\n  (λ s m, (adjunction.hom_equiv_apply_eq _ _ _).1 t.uniq_cocone_morphism)\n\n/--\nGiven two functors which have equivalent categories of cocones,\nwe can transport a colimiting cocone across the equivalence.\n-/\ndef of_cocone_equiv {D : Type u₄} [category.{v₄} D] {G : K ⥤ D}\n  (h : cocone G ≌ cocone F) {c : cocone G} :\n  is_colimit (h.functor.obj c) ≃ is_colimit c :=\n{ to_fun := λ P, of_iso_colimit (of_left_adjoint h.inverse P) (h.unit_iso.symm.app c),\n  inv_fun := of_left_adjoint h.functor,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\n@[simp] lemma of_cocone_equiv_apply_desc {D : Type u₄} [category.{v₄} D] {G : K ⥤ D}\n  (h : cocone G ≌ cocone F) {c : cocone G} (P : is_colimit (h.functor.obj c)) (s) :\n  (of_cocone_equiv h P).desc s =\n    (h.unit.app c).hom ≫\n    (h.inverse.map (P.desc_cocone_morphism (h.functor.obj s))).hom ≫\n    (h.unit_inv.app s).hom :=\nrfl\n\n@[simp] lemma of_cocone_equiv_symm_apply_desc {D : Type u₄} [category.{v₄} D] {G : K ⥤ D}\n  (h : cocone G ≌ cocone F) {c : cocone G} (P : is_colimit c) (s) :\n  ((of_cocone_equiv h).symm P).desc s =\n    (h.functor.map (P.desc_cocone_morphism (h.inverse.obj s))).hom ≫ (h.counit.app s).hom :=\nrfl\n\n/--\nA cocone precomposed with a natural isomorphism is a colimit cocone\nif and only if the original cocone is.\n-/\ndef precompose_hom_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cocone G) :\n  is_colimit ((cocones.precompose α.hom).obj c) ≃ is_colimit c :=\nof_cocone_equiv (cocones.precompose_equivalence α)\n\n/--\nA cocone precomposed with the inverse of a natural isomorphism is a colimit cocone\nif and only if the original cocone is.\n-/\ndef precompose_inv_equiv {F G : J ⥤ C} (α : F ≅ G) (c : cocone F) :\n  is_colimit ((cocones.precompose α.inv).obj c) ≃ is_colimit c :=\nprecompose_hom_equiv α.symm c\n\n/--\nConstructing an equivalence `is_colimit c ≃ is_colimit d` from a natural isomorphism\nbetween the underlying functors, and then an isomorphism between `c` transported along this and `d`.\n-/\ndef equiv_of_nat_iso_of_iso {F G : J ⥤ C} (α : F ≅ G) (c : cocone F) (d : cocone G)\n  (w : (cocones.precompose α.inv).obj c ≅ d) :\n  is_colimit c ≃ is_colimit d :=\n(precompose_inv_equiv α _).symm.trans (equiv_iso_colimit w)\n\n/--\nThe cocone points of two colimit cocones for naturally isomorphic functors\nare themselves isomorphic.\n-/\n@[simps]\ndef cocone_points_iso_of_nat_iso {F G : J ⥤ C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) : s.X ≅ t.X :=\n{ hom := P.map t w.hom,\n  inv := Q.map s w.inv,\n  hom_inv_id' := P.hom_ext (by tidy),\n  inv_hom_id' := Q.hom_ext (by tidy) }\n\n@[reassoc]\nlemma comp_cocone_points_iso_of_nat_iso_hom {F G : J ⥤ C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) (j : J) :\n  s.ι.app j ≫ (cocone_points_iso_of_nat_iso P Q w).hom = w.hom.app j ≫ t.ι.app j :=\nby simp\n\n@[reassoc]\nlemma comp_cocone_points_iso_of_nat_iso_inv {F G : J ⥤ C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) (j : J) :\n  t.ι.app j ≫ (cocone_points_iso_of_nat_iso P Q w).inv = w.inv.app j ≫ s.ι.app j :=\nby simp\n\n@[reassoc]\nlemma cocone_points_iso_of_nat_iso_hom_desc {F G : J ⥤ C} {s : cocone F} {r t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F ≅ G) :\n  (cocone_points_iso_of_nat_iso P Q w).hom ≫ Q.desc r = P.map _ w.hom :=\nP.hom_ext (by simp)\n\n@[reassoc]\nlemma cocone_points_iso_of_nat_iso_inv_desc {F G : J ⥤ C} {s : cocone G} {r t : cocone F}\n  (P : is_colimit t) (Q : is_colimit s) (w : F ≅ G) :\n  (cocone_points_iso_of_nat_iso P Q w).inv ≫ P.desc r = Q.map _ w.inv :=\nQ.hom_ext (by simp)\n\nsection equivalence\nopen category_theory.equivalence\n\n/--\nIf `s : cocone F` is a colimit cocone, so is `s` whiskered by an equivalence `e`.\n-/\ndef whisker_equivalence {s : cocone F} (P : is_colimit s) (e : K ≌ J) :\n  is_colimit (s.whisker e.functor) :=\nof_left_adjoint (cocones.whiskering_equivalence e).functor P\n\n/--\nIf `s : cocone F` whiskered by an equivalence `e` is a colimit cocone, so is `s`.\n-/\ndef of_whisker_equivalence {s : cocone F} (e : K ≌ J) (P : is_colimit (s.whisker e.functor)) :\n  is_colimit s :=\nequiv_iso_colimit ((cocones.whiskering_equivalence e).unit_iso.app s).symm\n  (of_left_adjoint (cocones.whiskering_equivalence e).inverse P : _)\n\n/--\nGiven an equivalence of diagrams `e`, `s` is a colimit cocone iff `s.whisker e.functor` is.\n-/\ndef whisker_equivalence_equiv {s : cocone F} (e : K ≌ J) :\n  is_colimit s ≃ is_colimit (s.whisker e.functor) :=\n⟨λ h, h.whisker_equivalence e, of_whisker_equivalence e, by tidy, by tidy⟩\n\n/--\nWe can prove two cocone points `(s : cocone F).X` and `(t.cocone G).X` are isomorphic if\n* both cocones are colimit cocones\n* their indexing categories are equivalent via some `e : J ≌ K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor ⋙ G ≅ F`.\n\nThis is the most general form of uniqueness of cocone points,\nallowing relabelling of both the indexing category (up to equivalence)\nand the functor (up to natural isomorphism).\n-/\n@[simps]\ndef cocone_points_iso_of_equivalence {F : J ⥤ C} {s : cocone F} {G : K ⥤ C} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (e : J ≌ K) (w : e.functor ⋙ G ≅ F) : s.X ≅ t.X :=\nlet w' : e.inverse ⋙ F ≅ G := (iso_whisker_left e.inverse w).symm ≪≫ inv_fun_id_assoc e G in\n{ hom := P.desc ((cocones.equivalence_of_reindexing e w).functor.obj t),\n  inv := Q.desc ((cocones.equivalence_of_reindexing e.symm w').functor.obj s),\n  hom_inv_id' :=\n  begin\n    apply hom_ext P, intros j,\n    dsimp,\n    simp only [limits.cocone.whisker_ι, fac, inv_fun_id_assoc_inv_app, whisker_left_app, assoc,\n      comp_id, limits.cocones.precompose_obj_ι, fac_assoc, nat_trans.comp_app],\n    rw [counit_inv_app_functor, ←functor.comp_map, ←w.inv.naturality_assoc],\n    dsimp,\n    simp,\n  end,\n  inv_hom_id' := by { apply hom_ext Q, tidy, }, }\n\nend equivalence\n\n/-- The universal property of a colimit cocone: a map `X ⟶ W` is the same as\n  a cocone on `F` with vertex `W`. -/\ndef hom_iso (h : is_colimit t) (W : C) : ulift.{u₁} (t.X ⟶ W : Type v₃) ≅ (F ⟶ (const J).obj W) :=\n{ hom := λ f, (t.extend f.down).ι,\n  inv := λ ι, ⟨h.desc { X := W, ι := ι }⟩,\n  hom_inv_id' := by ext f; apply h.hom_ext; intro j; simp; dsimp; refl }\n\n@[simp] lemma hom_iso_hom (h : is_colimit t) {W : C} (f : ulift (t.X ⟶ W)) :\n  (is_colimit.hom_iso h W).hom f = (t.extend f.down).ι := rfl\n\n/-- The colimit of `F` represents the functor taking `W` to\n  the set of cocones on `F` with vertex `W`. -/\ndef nat_iso (h : is_colimit t) : coyoneda.obj (op t.X) ⋙ ulift_functor.{u₁} ≅ F.cocones :=\nnat_iso.of_components (is_colimit.hom_iso h) (by intros; ext; dsimp; rw ←assoc; refl)\n\n/--\nAnother, more explicit, formulation of the universal property of a colimit cocone.\nSee also `hom_iso`.\n-/\ndef hom_iso' (h : is_colimit t) (W : C) :\n  ulift.{u₁} ((t.X ⟶ W) : Type v₃) ≅\n    { p : Π j, F.obj j ⟶ W // ∀ {j j' : J} (f : j ⟶ j'), F.map f ≫ p j' = p j } :=\nh.hom_iso W ≪≫\n{ hom := λ ι,\n  ⟨λ j, ι.app j, λ j j' f,\n   by convert ←(ι.naturality f); apply comp_id⟩,\n  inv := λ p,\n  { app := λ j, p.1 j,\n    naturality' := λ j j' f, begin dsimp, rw [comp_id], exact (p.2 f) end } }\n\n/-- If G : C → D is a faithful functor which sends t to a colimit cocone,\n  then it suffices to check that the induced maps for the image of t\n  can be lifted to maps of C. -/\ndef of_faithful {t : cocone F} {D : Type u₄} [category.{v₄} D] (G : C ⥤ D) [faithful G]\n  (ht : is_colimit (G.map_cocone t)) (desc : Π (s : cocone F), t.X ⟶ s.X)\n  (h : ∀ s, G.map (desc s) = ht.desc (G.map_cocone s)) : is_colimit t :=\n{ desc := desc,\n  fac' := λ s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := λ s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cocone s) _ (λ j, _),\n    convert ←congr_arg (λ f, G.map f) (w j),\n    apply G.map_comp\n  end }\n\n/--\nIf `F` and `G` are naturally isomorphic, then `F.map_cone c` being a colimit implies\n`G.map_cone c` is also a colimit.\n-/\ndef map_cocone_equiv {D : Type u₄} [category.{v₄} D] {K : J ⥤ C} {F G : C ⥤ D} (h : F ≅ G)\n  {c : cocone K} (t : is_colimit (F.map_cocone c)) : is_colimit (G.map_cocone c) :=\nbegin\n  apply is_colimit.of_iso_colimit _ (precompose_whisker_left_map_cocone h c),\n  apply (precompose_inv_equiv (iso_whisker_left K h : _) _).symm t,\nend\n\n/--\nA cocone is a colimit cocone exactly if\nthere is a unique cocone morphism from any other cocone.\n-/\ndef iso_unique_cocone_morphism {t : cocone F} :\n  is_colimit t ≅ Π s, unique (t ⟶ s) :=\n{ hom := λ h s,\n  { default := h.desc_cocone_morphism s,\n    uniq := λ _, h.uniq_cocone_morphism },\n  inv := λ h,\n  { desc := λ s, (h s).default.hom,\n    uniq' := λ s f w, congr_arg cocone_morphism.hom ((h s).uniq ⟨f, w⟩) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : coyoneda.obj (op X) ⋙ ulift_functor.{u₁} ≅ F.cocones)\n\n/-- If `F.cocones` is corepresented by `X`, each morphism `f : X ⟶ Y` gives a cocone with cone\npoint `Y`. -/\ndef cocone_of_hom {Y : C} (f : X ⟶ Y) : cocone F :=\n{ X := Y, ι := h.hom.app Y ⟨f⟩ }\n\n/-- If `F.cocones` is corepresented by `X`, each cocone `s` gives a morphism `X ⟶ s.X`. -/\ndef hom_of_cocone (s : cocone F) : X ⟶ s.X := (h.inv.app s.X s.ι).down\n\n@[simp] lemma cocone_of_hom_of_cocone (s : cocone F) : cocone_of_hom h (hom_of_cocone h s) = s :=\nbegin\n  dsimp [cocone_of_hom, hom_of_cocone], cases s, congr, dsimp,\n  convert congr_fun (congr_fun (congr_arg nat_trans.app h.inv_hom_id) s_X) s_ι,\n  exact ulift.up_down _\nend\n\n@[simp] lemma hom_of_cocone_of_hom {Y : C} (f : X ⟶ Y) : hom_of_cocone h (cocone_of_hom h f) = f :=\ncongr_arg ulift.down (congr_fun (congr_fun (congr_arg nat_trans.app h.hom_inv_id) Y) ⟨f⟩ : _)\n\n/-- If `F.cocones` is corepresented by `X`, the cocone corresponding to the identity morphism on `X`\nwill be a colimit cocone. -/\ndef colimit_cocone : cocone F :=\ncocone_of_hom h (𝟙 X)\n\n/-- If `F.cocones` is corepresented by `X`, the cocone corresponding to a morphism `f : Y ⟶ X` is\nthe colimit cocone extended by `f`. -/\nlemma cocone_of_hom_fac {Y : C} (f : X ⟶ Y) :\ncocone_of_hom h f = (colimit_cocone h).extend f :=\nbegin\n  dsimp [cocone_of_hom, colimit_cocone, cocone.extend],\n  congr' with j,\n  have t := congr_fun (h.hom.naturality f) ⟨𝟙 X⟩,\n  dsimp at t,\n  simp only [id_comp] at t,\n  rw congr_fun (congr_arg nat_trans.app t) j,\n  refl,\nend\n\n/-- If `F.cocones` is corepresented by `X`, any cocone is the extension of the colimit cocone by the\ncorresponding morphism. -/\nlemma cocone_fac (s : cocone F) : (colimit_cocone h).extend (hom_of_cocone h s) = s :=\nbegin\n  rw ←cocone_of_hom_of_cocone h s,\n  conv_lhs { simp only [hom_of_cocone_of_hom] },\n  apply (cocone_of_hom_fac _ _).symm,\nend\n\nend of_nat_iso\n\nsection\nopen of_nat_iso\n\n/--\nIf `F.cocones` is corepresentable, then the cocone corresponding to the identity morphism on\nthe representing object is a colimit cocone.\n-/\ndef of_nat_iso {X : C} (h : coyoneda.obj (op X) ⋙ ulift_functor.{u₁} ≅ F.cocones) :\n  is_colimit (colimit_cocone h) :=\n{ desc := λ s, hom_of_cocone h s,\n  fac' := λ s j,\n  begin\n    have h := cocone_fac h s,\n    cases s,\n    injection h with h₁ h₂,\n    simp only [heq_iff_eq] at h₂,\n    conv_rhs { rw ← h₂ }, refl,\n  end,\n  uniq' := λ s m w,\n  begin\n    rw ←hom_of_cocone_of_hom h m,\n    congr,\n    rw cocone_of_hom_fac,\n    dsimp [cocone.extend], cases s, congr' with j, exact w j,\n  end }\nend\n\nend is_colimit\n\nend category_theory.limits\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/is_limit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.615087848460224, "lm_q1q2_score": 0.4625537960089492}}
{"text": "import laurent_measures.basic\nimport laurent_measures.aux_lemmas\nimport analysis.special_functions.pow\nimport laurent_measures.thm69\n\nopen nnreal laurent_measures aux_thm69\nopen_locale nnreal\n\nnoncomputable theory\n\nsection slm\n\n--  This is the same as before, from here to...\n-- parameter {p : ℝ≥0}\n\n/--  This is the same `r` as before. -/\n-- def r : ℝ≥0 := 2⁻¹ ^ (p:ℝ)\n\n-- lemma r_pos : 0 < r :=\n-- suffices 0 < (2 : ℝ≥0)⁻¹ ^ (p : ℝ), by simpa [r],\n-- rpow_pos (nnreal.inv_pos.mpr zero_lt_two)\n\n-- lemma r_lt_one [fact(0 < p)] : r < 1 :=\n-- begin\n--   refine rpow_lt_one zero_le' (half_lt_self one_ne_zero) _,\n--   rw nnreal.coe_pos,\n--   exact fact.out _\n-- end\n\nvariables {r : ℝ≥0} [fact (0 < r)] [fact (r < 1)]\n\nlocal notation `ℒ` := laurent_measures r\n\nvariables {S : Fintype}\n\n-- /--  Let `F : ℒ S` be a Laurent measure.  `laurent_measures.d` chooses a bound `d ∈ ℤ` for `F`,\n-- such that, for all `s : S`, the sequence `F s` is zero from `d-1` and below. -/\n-- def laurent_measures.d (F : ℒ S) : ℤ :=\n-- (exists_bdd_filtration (fact.out _ : 0 < r) (fact.out _ : r < 1) F).some\n\n-- lemma lt_d_eq_zero (F : ℒ S) (s : S) (n : ℤ) :\n--   n < F.d → F s n = 0 :=\n-- (exists_bdd_filtration (fact.out _ : 0 < r) (fact.out _ : r < 1) F).some_spec s n\n--  ... here!\n\n\nsection new_stuff\n/--  Simpler Laurent measures? -/\nstructure slm (r : ℝ≥0) (S : Fintype) :=\n(to_fun    : S → ℤ → ℤ)\n(d         : ℤ)\n(summable' : ∀ s, summable (λ n : ℕ, ∥to_fun s n∥₊ * r ^ n))\n(zero_lt_d : ∀ s n, n < d → to_fun s n = 0)\n\n/--  A \"usual\" Laurent Measure `F : ℒ S` gives rise to a Simple Laurent Measure of type `slm S`. -/\ndef _root_.laurent_measures.to_slm (F : ℒ S) : slm r S :=\n{ to_fun    := F.to_fun,\n  d         := F.d,\n  zero_lt_d := λ n s, lt_d_eq_zero F _ _,\n  summable' := begin\n    refine λ s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (λ (n : ℤ), ∥F.to_fun s n∥ * r ^ n)).mp _).1,\n    { convert summable_coe.mpr (F.summable' s),\n      simp }\n  end }\n\n/--  A Simple Laurent Measure `F : slm S` \"usual\" Laurent Measure of type `ℒ S`. -/\n--  The \"main\" input is `int_summable_iff`, proving that a series over `ℤ` is summable if and only\n--  if both its restrictions to `ℕ` and to \"`-ℕ`\" are summable.\ndef slm.to_laurent_measures {r : ℝ≥0} (F : slm r S) : laurent_measures r S :=\n{ to_fun := F.to_fun,\n  summable' := begin\n    refine λ s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (λ (n : ℤ), ∥F.to_fun s n∥ * r ^ n)).mpr _),\n    { simp },\n    { refine ⟨_, summable_of_eventually_zero (λ (n : ℤ), ∥F.to_fun s n∥ * ↑r ^ n) F.d (λ n nd, _)⟩,\n      { convert summable_coe.mpr (F.summable' s), },\n      { simp [F.zero_lt_d s n nd] } }\n  end }\n\nlemma slm_lm_to_fun_eq {r : ℝ≥0} (F : slm r S) : F.to_fun = F.to_laurent_measures.to_fun := rfl\n\nlemma lm_slm_to_fun_eq (F : ℒ S) : F.to_fun = F.to_slm.to_fun := rfl\n\nend new_stuff\n\nend slm\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/laurent_measures/simpler_laurent_measures.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4625402018862748}}
{"text": "/-\nCopyright (c) 2022 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Yury Kudryashov\n\n! This file was ported from Lean 3 source module order.monotone.extension\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.ConditionallyCompleteLattice.Basic\n\n/-!\n# Extension of a monotone function from a set to the whole space\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we prove that if a function is monotone and is bounded on a set `s`, then it admits a\nmonotone extension to the whole space.\n-/\n\n\nopen Set\n\nvariable {α β : Type _} [LinearOrder α] [ConditionallyCompleteLinearOrder β] {f : α → β} {s : Set α}\n  {a b : α}\n\n/- warning: monotone_on.exists_monotone_extension -> MonotoneOn.exists_monotone_extension is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : ConditionallyCompleteLinearOrder.{u2} β] {f : α -> β} {s : Set.{u1} α}, (MonotoneOn.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) f s) -> (BddBelow.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) (Set.image.{u1, u2} α β f s)) -> (BddAbove.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) (Set.image.{u1, u2} α β f s)) -> (Exists.{max (succ u1) (succ u2)} (α -> β) (fun (g : α -> β) => And (Monotone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) g) (Set.EqOn.{u1, u2} α β f g s)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : ConditionallyCompleteLinearOrder.{u1} β] {f : α -> β} {s : Set.{u2} α}, (MonotoneOn.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) f s) -> (BddBelow.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) (Set.image.{u2, u1} α β f s)) -> (BddAbove.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) (Set.image.{u2, u1} α β f s)) -> (Exists.{max (succ u2) (succ u1)} (α -> β) (fun (g : α -> β) => And (Monotone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) g) (Set.EqOn.{u2, u1} α β f g s)))\nCase conversion may be inaccurate. Consider using '#align monotone_on.exists_monotone_extension MonotoneOn.exists_monotone_extensionₓ'. -/\n/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to\nthe whole space. -/\ntheorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))\n    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by\n  classical\n    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values\n      of `f`  to the left of `x` for `x ≥ a`. -/\n    rcases hl with ⟨a, ha⟩\n    have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>\n      hu.mono (image_subset _ (inter_subset_right _ _))\n    set g : α → β := fun x => if Disjoint (Iic x) s then a else Sup (f '' (Iic x ∩ s))\n    have hgs : eq_on f g s := by\n      intro x hx\n      simp only [g]\n      have : IsGreatest (Iic x ∩ s) x := ⟨⟨right_mem_Iic, hx⟩, fun y hy => hy.1⟩\n      rw [if_neg this.nonempty.not_disjoint,\n        ((h.mono <| inter_subset_right _ _).map_isGreatest this).csupₛ_eq]\n    refine' ⟨g, fun x y hxy => _, hgs⟩\n    by_cases hx : Disjoint (Iic x) s <;> by_cases hy : Disjoint (Iic y) s <;>\n      simp only [g, if_pos, if_neg, not_false_iff, *]\n    · rcases not_disjoint_iff_nonempty_inter.1 hy with ⟨z, hz⟩\n      exact le_csupₛ_of_le (hu' _) (mem_image_of_mem _ hz) (ha <| mem_image_of_mem _ hz.2)\n    · exact (hx <| hy.mono_left <| Iic_subset_Iic.2 hxy).elim\n    · rw [not_disjoint_iff_nonempty_inter] at hx hy\n      refine' csupₛ_le_csupₛ (hu' _) (hx.image _) (image_subset _ _)\n      exact inter_subset_inter_left _ (Iic_subset_Iic.2 hxy)\n#align monotone_on.exists_monotone_extension MonotoneOn.exists_monotone_extension\n\n/- warning: antitone_on.exists_antitone_extension -> AntitoneOn.exists_antitone_extension is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : ConditionallyCompleteLinearOrder.{u2} β] {f : α -> β} {s : Set.{u1} α}, (AntitoneOn.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) f s) -> (BddBelow.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) (Set.image.{u1, u2} α β f s)) -> (BddAbove.{u2} β (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) (Set.image.{u1, u2} α β f s)) -> (Exists.{max (succ u1) (succ u2)} (α -> β) (fun (g : α -> β) => And (Antitone.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) (PartialOrder.toPreorder.{u2} β (SemilatticeInf.toPartialOrder.{u2} β (Lattice.toSemilatticeInf.{u2} β (ConditionallyCompleteLattice.toLattice.{u2} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} β _inst_2))))) g) (Set.EqOn.{u1, u2} α β f g s)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : ConditionallyCompleteLinearOrder.{u1} β] {f : α -> β} {s : Set.{u2} α}, (AntitoneOn.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) f s) -> (BddBelow.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) (Set.image.{u2, u1} α β f s)) -> (BddAbove.{u1} β (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) (Set.image.{u2, u1} α β f s)) -> (Exists.{max (succ u2) (succ u1)} (α -> β) (fun (g : α -> β) => And (Antitone.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) (PartialOrder.toPreorder.{u1} β (SemilatticeInf.toPartialOrder.{u1} β (Lattice.toSemilatticeInf.{u1} β (ConditionallyCompleteLattice.toLattice.{u1} β (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} β _inst_2))))) g) (Set.EqOn.{u2, u1} α β f g s)))\nCase conversion may be inaccurate. Consider using '#align antitone_on.exists_antitone_extension AntitoneOn.exists_antitone_extensionₓ'. -/\n/-- If a function is antitone and is bounded on a set `s`, then it admits an antitone extension to\nthe whole space. -/\ntheorem AntitoneOn.exists_antitone_extension (h : AntitoneOn f s) (hl : BddBelow (f '' s))\n    (hu : BddAbove (f '' s)) : ∃ g : α → β, Antitone g ∧ EqOn f g s :=\n  h.dual_right.exists_monotone_extension hu hl\n#align antitone_on.exists_antitone_extension AntitoneOn.exists_antitone_extension\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Monotone/Extension.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4625402018862748}}
{"text": "import code\nimport frespects_pfun\nimport log_lemmas\n\nopen num (to_bits of_bits)\n\ndef time : code → ℕ →. ℕ\n| code.fst := λ v, pure (nat.log 2 v + 1)\n| code.snd := λ v, pure (nat.log 2 v + 1)\n| (code.bit _) := λ v, pure (nat.log 2 v + 1)\n| (code.pair c₁ c₂) := λ v, (+3) <$> (time c₁ v) + (time c₂ v)\n| (code.comp c₁ c₂) := λ v, (+1) <$> (time c₂ v) + (c₂.eval v >>= time c₁)\n| (code.case c₁ c₂ c₃) := λ v, (+1) <$> (match to_bits v with\n  | [] := time c₃ 0\n  | (ff :: xs) := time c₁ (of_bits xs)\n  | (tt :: xs) := time c₂ (of_bits xs)\nend)\n| (code.fix f) := λ v₀, (+1) <$> (@pfun.fix (ℕ × ℕ) ℕ $ \n  λ vt, (time f vt.1) >>= λ t',\n    (f.eval vt.1).map (λ v' : ℕ,\n      if v'.unpair'.1 = 0 then sum.inl (vt.2+t')\n      else sum.inr (v'.unpair'.2, vt.2+t'))\n  ) (v₀, 0)\n\nlemma add_def (x y : part ℕ) : x + y = x >>= λ x', y >>= (λ y', pure (x' + y')) :=\nby { simp only [(+), (<*>)], simp, refl, }\n\nprivate lemma time_frespects_once_eval_aux (f : code)\n  (ih : ∀ (n : ℕ), (time f n).dom ↔ (f.eval n).dom) :\n  pfun.frespects_once\n  (λ (vt : ℕ × ℕ), (time f vt.1) >>= λ t',\n    (f.eval vt.1).map (λ v' : ℕ,\n      if v'.unpair'.1 = 0 then sum.inl (vt.2+t')\n      else sum.inr (v'.unpair'.2, vt.2+t')))\n  (λ (v : ℕ), (f.eval v).map $ λ v',\n    if (nat.unpair' v').1 = 0 then sum.inl (nat.unpair' v').2 else sum.inr (nat.unpair' v').2)\n  prod.fst :=\nbegin\n  intro a, split,\n  { simp [ih], }, split,\n  { intro a',\n    simp only [part.bind_eq_bind, part.mem_bind_iff, part.mem_map_iff, exists_prop, forall_exists_index, and_imp],\n    intros n hn e he h, use e, refine ⟨he, _⟩,\n    split_ifs at h, { contradiction, },\n    rw ← h, split_ifs; refl,  },\n  simp only [part.bind_eq_bind, part.mem_bind_iff, part.mem_map_iff, exists_prop, forall_exists_index, and_imp],\n  intros n₁ n₂ hn₂ b hb h,\n  refine ⟨b.unpair'.snd, b, hb, _⟩,\n  split_ifs at h ⊢, { refl, }, { contradiction, },\nend\n\nlemma time_dom_iff_eval_dom (c : code) (n : ℕ) : (time c n).dom ↔ (c.eval n).dom :=\nbegin\n  induction c generalizing n,\n  iterate 3 { simp [time], refl, },\n  case code.pair : c₁ c₂ c₁ih c₂ih { simp [time, add_def, c₁ih, c₂ih], },\n  case code.comp : c₁ c₂ c₁ih c₂ih { simp [time, add_def, c₁ih, c₂ih], tauto, },\n  case code.case : c₁ c₂ c₃ c₁ih c₂ih c₃ih { simp only [time, code.eval],\n    rcases (to_bits n) with _|_|_; simp [c₁ih, c₂ih, c₃ih, time], },\n  case code.fix : f ih\n  { simp only [time, code.eval], refine pfun.eq_dom_of_frespects_once prod.fst _ _,\n    exact time_frespects_once_eval_aux _ ih, }\nend\n\nlemma exists_mem_time_iff_exists_mem_dom (c : code) (n : ℕ) : (∃ t, t ∈ time c n) ↔ ∃ m, m ∈ c.eval n :=\nby { rw [← part.dom_iff_mem, ← part.dom_iff_mem], apply time_dom_iff_eval_dom, }\n\nlemma time_frespects_once_eval (f : code) :\n  pfun.frespects_once\n  (λ (vt : ℕ × ℕ), (time f vt.1) >>= λ t',\n    (f.eval vt.1).map (λ v' : ℕ,\n      if v'.unpair'.1 = 0 then sum.inl (vt.2+t')\n      else sum.inr (v'.unpair'.2, vt.2+t')))\n  (λ (v : ℕ), (f.eval v).map $ λ v',\n    if (nat.unpair' v').1 = 0 then sum.inl (nat.unpair' v').2 else sum.inr (nat.unpair' v').2)\n  prod.fst :=\nby { apply time_frespects_once_eval_aux, simp [time_dom_iff_eval_dom], }\n\ndef time_bound (c : code) (bound : ℕ → ℕ) : Prop :=\n∀ (n m : ℕ), n ≤ m → ∃ t ∈ time c n, t ≤ bound (nat.log 2 m)\n\ndef time_bound_of_monotonic_iff (c : code) {bound : ℕ → ℕ} (mono : monotone bound) :\n  time_bound c bound ↔ ∀ n, ∃ t ∈ time c n, t ≤ bound (nat.log 2 n) :=\nbegin\n  split, { intros h n, exact h n n rfl.le, },\n  intros h n m hnm,\n  obtain ⟨t, ht, H⟩ := h n,\n  use [t, ht],\n  refine H.trans _,\n  apply mono, exact nat.log_le_log_of_le hnm,\nend\n\nlemma time_bound_of_time_bound_le {c : code} {b₁ : ℕ → ℕ} (hb : time_bound c b₁) (b₂ : ℕ → ℕ) (b₁_le_b₂ : ∀ n, b₁ n ≤ b₂ n) : time_bound c b₂ :=\nλ n N h, let ⟨t, ht, hb⟩ := hb n N h in ⟨t, ht, hb.trans (b₁_le_b₂ _)⟩\n\n/- Why isn't this already a lemma? -/\nlemma sq_mono : monotone (λ n : ℕ, n^2) := by { intros x y hxy, nlinarith, }\n\nlemma pair_bound {v₁ v₂ b₁ b₂ : ℕ} (hv₁ : nat.log 2 v₁ ≤ b₁^2) (hv₂ : nat.log 2 v₂ ≤ b₂^2) :\n  nat.log 2 (nat.mkpair' v₁ v₂) ≤ (b₁ + b₂ + 3)^2 :=\nbegin\n  have :=\n    calc 2 * nat.log 2 (nat.log 2 v₁ + 1)\n      ≤ 2 * nat.log 2 (b₁^2 + 1) : by { mono*,  { apply nat.log_monotone, mono, }, all_goals { exact zero_le _, }, }\n  ... ≤ 2 * nat.log 2 ((b₁ + 1)^2) : by { mono*, { apply nat.log_monotone, ring_nf SOP, simp, }, all_goals { exact zero_le _, }, }\n  ... ≤ 2 * (2 * (nat.log 2 (b₁ + 1) + 1)) : by { mono, { apply nat.log_pow_k_le, }, all_goals { exact zero_le _, }, }\n  ... = 4 * nat.log 2 (b₁ + 1) + 4 : by ring\n  ... ≤ 4 * b₁ + 4 : by { mono*, { exact nat.log_succ_le _ _, }, all_goals { exact zero_le _, }, },\n  \n  exact calc nat.log 2 (nat.mkpair' v₁ v₂)\n      ≤ nat.log 2 v₁ + nat.log 2 v₂ + 2 * nat.log 2 (nat.log 2 v₁ + 1) + 5 : nat.mkpair'_le v₁ v₂\n  ... ≤ b₁^2 + b₂^2 + (4 * b₁ + 4) + 5 : by mono*\n  ... ≤ (b₁ + b₂ + 3)^2 : by { ring_nf, nlinarith, }\nend\n\nlemma eval_le_time {c : code} {n m t : ℕ} (hm : m ∈ c.eval n) (ht : t ∈ time c n) : nat.log 2 m ≤ t^2 :=\nbegin\n  induction c generalizing n m t,\n  -- TODO: these 3 cases are very similar (only the last part is different),\n  -- but iterate gives some weird error, figure out why\n  case code.fst : { simp only [time, part.pure_eq_some, code.eval, part.mem_some_iff] at hm ht, subst ht, subst hm,\n    rw sq, exact (le_add_right (nat.log_le_log_of_le (nat.unpair'_fst_le n))).trans (nat.le_mul_self _), },\n  case code.snd : { simp only [time, part.pure_eq_some, code.eval, part.mem_some_iff] at hm ht, subst ht, subst hm,\n    rw sq, exact (le_add_right (nat.log_le_log_of_le (nat.unpair'_snd_le n))).trans (nat.le_mul_self _), },\n  case code.bit : b { simp only [time, part.pure_eq_some, code.eval, part.mem_some_iff, pfun.coe_val] at hm ht, subst ht, subst hm,\n    rw sq, refine trans _ (nat.le_mul_self _), cases n, { cases b; simp [nat.bit], }, cases b; simp [nat.bit, nat.bit0_val n.succ, nat.bit1_val n.succ], },\n  case code.pair : c₁ c₂ c₁ih c₂ih\n  { simp only [time, add_def, part.map_eq_map, part.pure_eq_some, part.bind_eq_bind, part.bind_some_eq_map, part.bind_map,\n  part.mem_bind_iff, part.mem_map_iff, exists_prop, code.eval, part.ret_eq_some] at hm ht,\n    obtain ⟨t₁, ht₁, t₂, ht₂, ht⟩ := ht, subst ht,\n    obtain ⟨v₁, hv₁, v₂, hv₂, hm⟩ := hm, subst hm,\n    rw [add_assoc t₁ 3 t₂, add_comm 3 t₂, ← add_assoc t₁ t₂ 3],\n    exact pair_bound (c₁ih hv₁ ht₁) (c₂ih hv₂ ht₂), },\n  case code.comp : c₁ c₂ c₁ih c₂ih\n  { simp only [time, code.eval, exists_prop, part.pure_eq_some, part.bind_eq_bind, part.bind_map, part.map_eq_map, part.mem_bind_iff, add_def] at hm ht,\n    obtain ⟨t₂, ht₂, t₁, ⟨v, hv, ht₁⟩, ht⟩ := ht,\n    obtain ⟨v', hv', hm⟩ := hm, have := part.mem_unique hv hv', subst this,\n    refine (c₁ih hm ht₁).trans _, apply sq_mono, simp only [part.mem_some_iff] at ht, rw ht,\n    simp, },\n  case code.case : c₁ c₂ c₃ c₁ih c₂ih c₃ih\n  { simp only [time, part.map_eq_map, part.mem_map_iff, exists_prop, code.eval] at hm ht,\n    rcases to_bits n with _|_|_; simp only [time, code.eval],\n    { rintros h ⟨t₃, ht₃, ht⟩, refine (c₃ih h ht₃).trans _,  apply sq_mono, rw ← ht, simp, },\n    { rintros h ⟨t₁, ht₁, ht⟩, refine (c₁ih h ht₁).trans _, apply sq_mono, rw ← ht, simp, },\n    { rintros h ⟨t₂, ht₂, ht⟩, refine (c₂ih h ht₂).trans _, apply sq_mono, rw ← ht, simp, }, },\n  case code.fix : f ih\n  { simp only [time, part.mem_map_iff, part.map_eq_map] at ht,\n    rename t t_succ, obtain ⟨t, ht, ht_succ⟩ := ht,\n    obtain ⟨⟨mL, tL⟩, htime, heval⟩ := pfun.frespects_last_step (time_frespects_once_eval f) ht hm,\n    simp only [part.mem_map_iff, exists_prop, part.bind_eq_bind, part.mem_bind_iff] at htime heval,\n    obtain ⟨m', hm', hmm'⟩ := heval, obtain ⟨tf, htf, m'', hm'', htL⟩ := htime,\n    have : m' = m'' := part.mem_unique hm' hm'', subst this, clear hm'',\n    split_ifs at hmm' htL, swap, { contradiction, },\n    exact calc nat.log 2 m ≤ nat.log 2 m' : by { apply nat.log_monotone, rw ← hmm', exact nat.unpair'_snd_le _, }\n                      ...  ≤ tf^2 : ih hm' htf\n                      ...  ≤ t_succ^2 : by { rw [← ht_succ, ← htL], mono, apply le_add_right, simp, }, },\nend\n\nlemma one_le_time {c : code} {n t : ℕ} (ht : t ∈ time c n) : 1 ≤ t :=\nbegin\n  cases c,\n  iterate 3 { simp [time] at ht, simp [ht], },\n  all_goals { simp only [time, add_def, part.map_eq_map, part.pure_eq_some, part.bind_eq_bind, part.bind_some_eq_map, part.bind_map,\n      part.mem_bind_iff, part.mem_map_iff, exists_prop] at ht, },\n  { obtain ⟨_, _, _, _, ht⟩ := ht, rw ← ht, nlinarith only, },\n  { obtain ⟨_, _, _, _, ht⟩ := ht, rw ← ht, nlinarith only, },\n  { obtain ⟨_, _, ht⟩ := ht, rw ← ht, nlinarith only, },\n  { obtain ⟨_, _, ht⟩ := ht, rw ← ht, nlinarith only, },\nend\n\nlemma time_bound_fst : time_bound code.fst (λ t, t+1) :=\nby { rw time_bound_of_monotonic_iff, { simp [time], }, { intros x y h, simpa }, }\n\nlemma time_bound_snd : time_bound code.snd (λ t, t+1) :=\nby { rw time_bound_of_monotonic_iff, { simp [time], }, { intros x y h, simpa }, }\n\nlemma time_bound_bit (b : bool) : time_bound (code.bit b) (λ t, t+1) :=\nby { rw time_bound_of_monotonic_iff, { simp [time], }, { intros x y h, simpa }, }\n\nlemma time_bound_pair {c₁ c₂ : code} {b₁ b₂ : ℕ → ℕ} (hb₁ : time_bound c₁ b₁) (hb₂ : time_bound c₂ b₂) :\n  time_bound (code.pair c₁ c₂) (λ t, (b₁ t) + (b₂ t) + 3) :=\nbegin\n  intros n N h,\n  obtain ⟨t₁, ht₁, hb₁⟩ := hb₁ n N h, obtain ⟨t₂, ht₂, hb₂⟩ := hb₂ n N h,\n  use (t₁ + t₂ + 3), split,\n  { rw ← part.eq_some_iff at ht₁ ht₂, simp [time, ht₁, ht₂, add_def], ring, },\n  { mono*, },\nend\n\nlemma time_bound_comp {c₁ c₂ : code} {b₁ b₂ : ℕ → ℕ} (hb₁ : time_bound c₁ b₁) (hb₂ : time_bound c₂ b₂) :\n  time_bound (code.comp c₁ c₂) (λ t, (b₂ t) + (b₁ ((b₂ t)^2 + 1)) + 1) :=\nbegin\n  intros n N h,\n  obtain ⟨t₂, ht₂, hb₂⟩ := hb₂ n N h,\n  obtain ⟨m, hm⟩ := (exists_mem_time_iff_exists_mem_dom c₂ n).mp ⟨_, ht₂⟩,\n  obtain ⟨t₁, ht₁, hb₁⟩ := hb₁ m (2^((b₂ $ nat.log 2 N)^2 + 1)) _,\n  { use t₁ + t₂ + 1, split,\n    { rw ← part.eq_some_iff at ht₁ ht₂ hm, simp [time, ht₁, ht₂, add_def, hm], ring, },\n    rw add_comm t₁ t₂, mono*, rwa nat.log_pow (show 1 < 2, by norm_num) at hb₁, },\n  apply le_of_lt, apply nat.lt_pow_succ_of_log_le, { norm_num },\n  exact calc nat.log 2 m ≤ t₂^2 : eval_le_time hm ht₂\n                     ... ≤ (b₂ $ nat.log 2 N)^2 : by mono,\nend\n\nlemma time_bound_case {c₁ c₂ c₃ : code} {b₁ b₂ b₃ : ℕ → ℕ} (hb₁ : time_bound c₁ b₁) (hb₂ : time_bound c₂ b₂) (hb₃ : time_bound c₃ b₃) :\n  time_bound (code.case c₁ c₂ c₃) (λ t, (max (max (b₁ t) (b₂ t)) (b₃ 0)) + 1) :=\nbegin\n  intros n N h, \n  rcases e : (to_bits n) with _ |_|_,\n  { obtain ⟨t, ht, hb⟩ := hb₃ 0 0 rfl.le, use (t+1),\n    split, { simpa [time, e], }, norm_num at hb, mono, simp only [le_max_iff], right, assumption, },\n  { obtain ⟨t, ht, hb⟩ := hb₁ (of_bits this_tl) N _, use t+1, split,\n    { simpa [time, e], }, { mono, simp only [le_max_iff], left, left, assumption, },\n    transitivity (of_bits (to_bits n) : ℕ),\n    { apply le_of_lt, apply num.of_bits_strict_mono, rw e, simp, },\n    simpa, },\n  { obtain ⟨t, ht, hb⟩ := hb₂ (of_bits this_tl) N _, use t+1, split,\n    { simpa [time, e], }, { mono, simp only [le_max_iff], left, right, assumption, },\n    transitivity (of_bits (to_bits n) : ℕ),\n    { apply le_of_lt, apply num.of_bits_strict_mono, rw e, simp, },\n    simpa, },\nend\n\nlemma time_bound_case' {c₁ c₂ c₃ : code} {b₁ b₂ b₃ : ℕ → ℕ} (hb₁ : time_bound c₁ b₁) (hb₂ : time_bound c₂ b₂) (hb₃ : time_bound c₃ b₃) :\n  time_bound (code.case c₁ c₂ c₃) (λ t, (b₁ t) + (b₂ t) + (b₃ 0) + 1) :=\nbegin\n  apply time_bound_of_time_bound_le (time_bound_case hb₁ hb₂ hb₃),\n  intro n, simp, split; nlinarith only,\nend\n\n\n", "meta": {"author": "prakol16", "repo": "lean_complexity_theory_polytime_defs", "sha": "b4e5f5544e11cd5aca1a5a4b5b0231537af4962c", "save_path": "github-repos/lean/prakol16-lean_complexity_theory_polytime_defs", "path": "github-repos/lean/prakol16-lean_complexity_theory_polytime_defs/lean_complexity_theory_polytime_defs-b4e5f5544e11cd5aca1a5a4b5b0231537af4962c/src/time_bound.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.46245969350142574}}
{"text": "-- import for_mathlib.short_exact_sequence\nimport data.int.interval\nimport data.finset.nat_antidiagonal\nimport laurent_measures.aux_lemmas\nimport laurent_measures.basic\nimport laurent_measures.theta\nimport linear_algebra.basic\nimport order.filter.at_top_bot tactic.linarith\nimport for_mathlib.nnreal\n\n/-!\nThis file introduces the maps\n* `θ`, which is the specialization of evaluation-at-ξ map `ϑ` from `laurent_measures.theta`\n  at `ξ=2⁻¹`.\n* `ϕ` which corresponds to multiplying a Laurent series in `ℒ S = (laurent_measures r S)`\n  for `r = 2^(1/p)` by `T⁻¹-2`.\n* `ψ` corresponds to dividing a Laurent series by `(T⁻¹-2)`. It is defined only on series\n  vanishing at `2⁻¹`, so that it again takes values in `ℒ S`\n* The maps `Θ`, `Φ` and `Ψ` are the \"measurifications\" of `θ`, `ϕ` and `ψ`,\n  so they are morphisms in the right category (**[FAE]** Not here any more!)\n\nThe main results are\n* `injective_ϕ` stating that `ϕ` is injective;\n* `θ_ϕ_complex` stating that `ϕ ∘ θ = 0`; and\n* `θ_ϕ_exact` stating that the kernel of `θ` coincides with the image of `ϕ`.\nTogether with `ϑ_surjective` from `laurent_measures.theta` (specialized at `ξ=2⁻¹`, so that `ϑ` is\n`θ`) this is the statement of Theorem 6.9 of `Analytic.pdf` of interest to us, although only \"on\nelements\" and not yet as a Short Exact Sequence in the right category.\n-/\n\nnoncomputable theory\n\nopen nnreal theta laurent_measures aux_thm69 finset\nopen_locale nnreal classical big_operators topological_space\n\nsection phi\n\nparameter {r : ℝ≥0}\n\nlocal notation `ℒ` := laurent_measures r\nvariables [fact (0 < r)]\nvariable {S : Fintype}\n\ndef ϕ : ℒ S → ℒ S :=\nλ F, shift (1) F - 2 • F\n\nlemma ϕ_apply (F : ℒ S) (s : S) (n : ℤ) : ϕ F s n = F s (n+1) - 2 * F s n :=\nby simp only [ϕ, sub_apply, nsmul_apply, shift_to_fun_to_fun, nsmul_eq_mul]; refl\n\nlemma ϕ_natural (S T : Fintype) (f : S ⟶ T) : --[fact (0 < p)] [fact ( p ≤ 1)] :\n  ϕ ∘ laurent_measures.map_hom f = laurent_measures.map_hom f ∘ ϕ :=\nbegin\n  ext F t n,\n  simp only [ϕ, sum_sub_distrib, mul_sum, function.comp_app, map_hom_to_fun, sub_apply,\n    nsmul_apply, shift_to_fun_to_fun,\n    map_apply, nsmul_eq_mul, mul_ite, mul_zero], -- squeezed for time\nend\n\n-- #check @ϕ\n\n-- lemma tsum_reindex (F : ℒ S) (N : ℤ) (s : S) : ∑' (l : ℕ), (F s (N + l) : ℝ) * (2 ^ l)⁻¹ =\n--  2 ^ N * ∑' (m : {m : ℤ // N ≤ m}), (F s m : ℝ) * (2 ^ m.1)⁻¹ :=\n-- begin\n--   have h_shift := int_tsum_shift (λ n, (F s n : ℝ) * (2 ^ (-n))) N,\n--   simp only at h_shift,\n--   simp_rw [subtype.val_eq_coe, ← zpow_neg],\n--   rw [← h_shift, ← _root_.tsum_mul_left, tsum_congr],\n--   intro n,\n--   rw [mul_comm (_ ^ N), mul_assoc, ← (zpow_add₀ (@two_ne_zero ℝ _ _)), neg_add_rev,\n--     neg_add_cancel_comm, zpow_neg, zpow_coe_nat, add_comm],\n-- end\n\nvariable [fact (r < 1)]\n\nlemma injective_ϕ (F : ℒ S) (H : ϕ F = 0) : F = 0 :=\nbegin\n  dsimp only [ϕ] at H, rw [sub_eq_zero] at H,\n  replace H : ∀ n : ℤ, ∀ s : S, 2 * F s (n - 1) = F s n,\n  { intros n s,\n    rw laurent_measures.ext_iff at H,\n    convert (H s (n-1)).symm using 1,\n    { rw [two_smul, two_mul], refl, },\n    { simp [shift] } },\n  ext s n,\n  apply int.induction_on' n (F.d - 1),\n  { refine lt_d_eq_zero _ _ (F.d - 1) _,\n    simp only [sub_lt_self_iff, zero_lt_one], },\n  { intros k h hk₀,\n    simp [← H (k + 1) s, add_sub_cancel, hk₀, mul_zero] },\n  { intros k h hk₀,\n    simpa only [hk₀, mul_eq_zero, bit0_eq_zero, one_ne_zero, false_or, zero_apply] using H k s }\nend\n\nlemma injective_ϕ' : function.injective (ϕ : ℒ S → ℒ S) :=\nbegin\n  let PHI : comphaus_filtered_pseudo_normed_group_hom (ℒ S) (ℒ S) :=\n    shift (1) - 2 • comphaus_filtered_pseudo_normed_group_hom.id,\n  apply (injective_iff_map_eq_zero (PHI.to_add_monoid_hom)).mpr,\n  exact injective_ϕ\nend\n\nend phi\n\nsection mem_exact\n\nparameter {p : ℝ≥0}\n\n/-- `r`, or `r(p)`, is `2⁻ᵖ`. -/\ndef r : ℝ≥0 := 2⁻¹ ^ (p : ℝ)\n\nlemma r_pos : 0 < r :=\nsuffices 0 < (2 : ℝ≥0)⁻¹ ^ (p : ℝ), by simpa [r],\nrpow_pos (nnreal.inv_pos.mpr zero_lt_two)\n\ninstance r_pos' : fact (0 < r) := ⟨r_pos⟩\n\nlemma r_coe : (2⁻¹ : ℝ) ^ (p : ℝ) = r :=\nbegin\n  have : (2⁻¹ : ℝ) = ((2⁻¹ : ℝ≥0) : ℝ),\n  simp only [one_div, nonneg.coe_inv, nnreal.coe_bit0, nonneg.coe_one],\n  rw [this, ← nnreal.coe_rpow, nnreal.coe_eq],\n  refl,\nend\n\nvariable [fact(0 < p)]\n\nlemma r_lt_one : r < 1 :=\nbegin\n  refine rpow_lt_one two_inv_lt_one _,\n  rw nnreal.coe_pos,\n  exact fact.out _\nend\n\ninstance r_lt_one' : fact (r < 1) := ⟨r_lt_one⟩\n\nvariable {S : Fintype}\n\nlocal notation `ℒ` := laurent_measures r\nlocal notation `ℳ` := real_measures p\n\ntheorem nnreal.rpow_int_cast (x : nnreal) (n : ℤ) : x ^ (n : ℝ) = x ^ n :=\nbegin\n  apply subtype.ext,\n  simp,\nend\n\ndef θ : ℒ S → ℳ S := ϑ 2⁻¹ r p S\n\nlemma θ_natural [fact (0 < p)] [fact (p ≤ 1)] (S T : Fintype) (f : S ⟶ T) (F : ℒ S) (t : T) :\n  θ (map f F) t = real_measures.map f (θ F) t :=\nbegin\n  simp only [θ, ϑ, one_div, map_apply, int.cast_sum, inv_zpow', zpow_neg, real_measures.map_apply],\n  rw ← tsum_sum,\n  { congr', ext n, exact sum_mul, },\n  intros,\n  rw mem_filter at H,\n  rcases H with ⟨-, rfl⟩,\n  have := F.summable i,\n  refine summable.add_compl (_ : summable (_ ∘ (coe : {n : ℤ | 0 ≤ n} → ℤ))) _,\n  { have moo := summable.comp_injective this\n      (subtype.coe_injective : function.injective (coe : {n : ℤ | 0 ≤ n} → ℤ)),\n    refine summable_of_norm_bounded _ (moo) _, clear moo this,\n    rintro ⟨n, (hn : 0 ≤ n)⟩,\n    simp only [function.comp_app, subtype.coe_mk, norm_mul, norm_inv, norm_zpow, real.norm_two],\n    rw (F i n).norm_cast_real,\n    apply mul_le_mul_of_nonneg_left _ (norm_nonneg _),\n    delta r,\n    delta r,\n    rw (by push_cast : ((2 : ℝ) ^ n)⁻¹ = ((2 ^ n)⁻¹ : nnreal)),\n    norm_cast,\n    rw [← nnreal.rpow_int_cast, ← inv_rpow],\n    rw nnreal.rpow_int_cast,\n    set m := n.nat_abs with hm,\n    have hmn : n = m := by { rw hm, exact int.eq_nat_abs_of_zero_le hn },\n    rw hmn,\n    norm_cast,\n    apply pow_le_pow_of_le, clear hn hmn hm m n,\n    apply nnreal.le_self_rpow' (two_inv_lt_one.le),\n    norm_cast,\n    exact fact.out _,\n  },\n  {\n    obtain ⟨d, hd⟩ := exists_bdd_filtration (r_pos) (r_lt_one) F,\n    apply summable_of_ne_finset_zero, -- missing finset\n    swap, exact (finset.subtype _ (finset.Ico d 0)),\n    rintros ⟨z, (hz : ¬ (0 ≤ z))⟩ hz2,\n    simp only [subtype.coe_mk, mul_eq_zero, int.cast_eq_zero, inv_eq_zero],\n    left,\n    apply hd,\n    simp only [mem_subtype, subtype.coe_mk, mem_Ico, not_and, not_le] at hz2,\n    by_contra h,\n    push_neg at h,\n    apply hz,\n    specialize hz2 h,\n    push_neg at hz2,\n    exact hz2 },\nend\n\nvariables [fact (p < 1)]\n\nlemma half_lt_r : 2⁻¹ < r :=\ncalc (2⁻¹:ℝ≥0)\n    = 2⁻¹ ^ (1:ℝ) : (rpow_one (2⁻¹:ℝ≥0)).symm\n... < r : rpow_lt_rpow_of_exponent_gt (begin rw nnreal.inv_pos, norm_num, end)\n  (begin apply nnreal.inv_lt_one, norm_num end) $\n(nnreal.coe_lt_coe.mpr (fact.out _)).trans_le (nnreal.coe_one).le\n\nlemma one_lt_two_r : 1 < 2 * r :=\nbegin\n  have := half_lt_r,\n  have this2 : (2⁻¹ : ℝ) < r,\n    assumption_mod_cast,\n  rw inv_pos_lt_iff_one_lt_mul' at this2, assumption_mod_cast,\n  norm_num,\nend\n\nlemma r_inv_lt_2 : r⁻¹ < 2 :=\nbegin\n  rw ← inv_inv (2 : ℝ≥0),\n  exact nnreal.inv_lt_inv (by norm_num) half_lt_r,\nend\n\nlemma laurent_measures.summable_half (F : ℒ S) (s : S) :\n  summable (λ n, ((F s n) : ℝ) * 2⁻¹ ^ n) :=\naux_thm69.summable_smaller_radius F.d (F.summable s) (λ n hn, lt_d_eq_zero _ _ _ hn) half_lt_r\n\nlemma θ_ϕ_complex (F : ℒ S) : (θ ∘ ϕ) F = 0 :=\nbegin\n  have t0 : (2 : ℝ)⁻¹ ≠ 0 := inv_ne_zero two_ne_zero,\n  funext s,\n  convert_to ∑' (n : ℤ), ((F s (n + 1) - 2 * F s n) : ℝ) * 2⁻¹ ^ n = 0,\n  { apply tsum_congr,\n    intro b,\n    field_simp [ϕ] },\n  simp_rw [sub_mul],\n  rw [tsum_sub, sub_eq_zero],\n  -- old proof was slicker :-(\n  { refine tsum_eq_tsum_of_ne_zero_bij (λ i, (i.val : ℤ) - 1) _ _ _,\n    { rintros ⟨x, _⟩ ⟨y, _⟩ h, dsimp at *, linarith },\n    { rintros x hx,\n      refine ⟨⟨x + 1, _⟩, _⟩,\n      { rw function.mem_support at ⊢ hx,\n        convert hx using 1,\n        simp [zpow_add₀],\n        ring },\n      { simp } },\n    { rintro ⟨i, hi⟩,\n      simp [zpow_sub₀],\n      ring } },\n  { rw ← (equiv.add_group_add (-1 : ℤ)).summable_iff,\n    simp only [function.comp, one_div, inv_zpow', equiv.add_group_add_apply,\n      neg_add_cancel_comm],\n    convert summable.mul_right 2 (F.summable_half s),\n    ext x,\n    simp [zpow_add₀], ring },\n  { simp_rw [mul_assoc],\n    convert (F.summable_half s).mul_left 2 },\nend\n.\n\n/-!\n\n### Definition of ψ\n\nThis involves dividing by T⁻¹ - 2 and we have to check that this process converges.\nThe proof below is pretty icky. It's \"do some trivial rearrangements and it boils\ndown to the fact that you can interchange the order of summation in a ℝ≥0-valued\nsum of sums\"\n\n-/\n\nlemma nnreal.summable_mul_left_iff {X : Type*} {f : X → ℝ≥0} {a : ℝ≥0} (ha : a ≠ 0) :\nsummable f ↔ summable (λ (x : X), a * f x) :=\nbegin\n  rw [← nnreal.summable_coe, ← nnreal.summable_coe],\n  rw summable_mul_left_iff (by exact_mod_cast ha : (a : ℝ) ≠ 0),\n  apply summable_congr,\n  intro b,\n  norm_cast,\nend\n\nlemma psi_def_summable {S : Fintype} (n : ℕ)\n  (F : ℒ S)\n  (s : S) :\n  summable\n    (λ (k : ℕ),\n       r ^ (F.d + ↑n) *\n         (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=\nbegin\n  have := F.summable_half s,\n  apply summable.mul_left,\n  have h : (2⁻¹ : ℝ≥0) ≠ 0 := by norm_num,\n  rw nnreal.summable_mul_left_iff (show ((2⁻¹ : ℝ≥0) ^ (F.d + n) ≠ 0), from zpow_ne_zero _ h),\n  simp only [← mul_assoc, ← zpow_add₀ h],\n  have this2 := lt_d_eq_zero F s,\n  rw ← summable_norm_iff at this,\n  simp_rw ← _root_.coe_nnnorm at this,\n  rw summable_coe at this,\n  rw nnreal.summable_iff_on_nat_less_shift F.d _ (F.d + n) at this,\n  { convert this,\n    ext1 k,\n    rw mul_comm,\n    simp only [inv_zpow', neg_add_rev, nnnorm_mul, nnnorm_zpow, real.nnnorm_two],\n    congr' },\n  { intros n hn,\n    simp [this2 n hn] },\nend\n\nlemma psi_def_summable2 {S : Fintype}\n  [fact (0 < p)]\n  [fact (p < 1)]\n  (F : ℒ S)\n  (s : ↥S) :\n  ∀ (k : ℕ),\n    summable\n      (λ (n : ℕ),\n         r ^ (F.d + ↑n) *\n           ((2⁻¹ : ℝ≥0) ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=\nbegin\n  intro k,\n  have hhalf : (2⁻¹ : ℝ≥0) ≠ 0, by norm_num,\n  have hhalf' : (2⁻¹ : ℝ≥0) ≠ 0, by norm_num,\n  have hr : r ≠ 0 := r_pos.ne.symm,\n  rw nnreal.summable_mul_left_iff\n    (show (2⁻¹ : ℝ≥0) ^ (-(k : ℤ)) * r ^ (k : ℤ) ≠ 0, from mul_ne_zero (zpow_ne_zero _ hhalf') (zpow_ne_zero _ hr)),\n  have : ∀ x : ℕ, 2⁻¹ ^ -(k : ℤ) * r ^ (k : ℤ) * (r ^ (F.d + ↑x) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑x + ↑k)∥₊))\n    = r ^ (F.d + x + k) * ∥F s (F.d + ↑x + ↑k)∥₊,\n  { intro x,\n    rw (show (2⁻¹ : ℝ≥0) ^ -(k : ℤ) * r ^ (k : ℤ) * (r ^ (F.d + ↑x) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑x + ↑k)∥₊))\n      = (2⁻¹ : ℝ≥0) ^ -(k : ℤ) * 2⁻¹ ^ (k : ℤ) * r ^ (k : ℤ) * r ^ (F.d + ↑x) *  ∥F s (F.d + ↑x + ↑k)∥₊, by ring),\n    simp only [zpow_add₀ hr, ← zpow_add₀ hhalf'],\n    simp,\n    left,\n    ring,\n    },\n  rw summable_congr this, clear this,\n  have := F.summable' s,\n  rw nnreal.summable_iff_on_nat_less_shift F.d _ (F.d + k) at this,\n  { convert this,\n    ext n,\n    rw [mul_comm, add_right_comm],\n    refl },\n  { intros n hn,\n    convert zero_mul _,\n    convert nnnorm_zero,\n    exact lt_d_eq_zero F s n hn },\nend\n\nlemma psi_def_summable3 {S : Fintype}\n  [fact (0 < p)]\n  [fact (p < 1)]\n  (F : ℒ S)\n  (s : ↥S) :\n  summable\n    (λ (k : ℕ),\n       ∑' (n : ℕ),\n         r ^ (F.d + ↑n) *\n           (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊)) :=\nbegin\n  -- take 2⁻¹^k out the tsum,\n  -- put r^k into the tsum,\n  -- bounded by sum of GP,\n  have bdd : ∀ k : ℕ, ∑' (n : ℕ),\n         r ^ (F.d + ↑n + k) * ∥F s (F.d + ↑n + ↑k)∥₊ ≤\n           ∑' (t : ℤ),\n         r ^ t * ∥F s t∥₊,\n  { intro k,\n    simp_rw add_right_comm,\n    have hinj : function.injective (λ (m : ℕ), F.d + k + m),\n    { rintros a b (h2 : F.d + k + a = F.d + k + b),\n      simpa using h2 },\n      refine tsum_le_tsum_of_inj _ hinj _ _ _ _,\n      { intros, apply zero_le' },\n      { intro, refl },\n      { rw ← @nnreal.summable_iff_on_nat_less_shift (λ (z : ℤ), r ^ z * ∥F s z∥₊) F.d _ (F.d + k),\n        { convert F.summable' s,\n          ext z,\n          rw mul_comm,\n          refl },\n        { intros n hn,\n          simp [lt_d_eq_zero F s n hn] } },\n      { convert F.summable' s,\n        ext z,\n        rw mul_comm,\n        refl } },\n  have : ∀ k : ℕ, ∑' (n : ℕ), r ^ (F.d + ↑n) * (2⁻¹ ^ (k : ℤ) * ∥F s (F.d + ↑n + ↑k)∥₊) =\n   (∑' (n : ℕ), r ^ (F.d + ↑n + k) * (∥F s (F.d + ↑n + ↑k)∥₊)) * (2⁻¹ * r⁻¹) ^ (k : ℤ),\n  { intro k,\n    rw ← nnreal.tsum_mul_right,\n    apply tsum_congr,\n    intro n,\n    simp only [zpow_add₀ r_pos.ne.symm, zpow_coe_nat, one_div, inv_pow, div_zpow],\n    have foo : (2 * r) ^ k ≠ 0,\n    { apply pow_ne_zero, apply mul_ne_zero,\n      { norm_num },\n      { exact r_pos.ne.symm },\n\n    },\n    field_simp [foo],\n    rw mul_pow,\n    ring, },\n  rw summable_congr this, clear this,\n  suffices : summable (λ k : ℕ, (∑' (t : ℤ), r ^ t * ∥F s t∥₊) * (2⁻¹ * r⁻¹) ^ k),\n  { refine summable_of_le _ this,\n    intro k,\n    rw zpow_coe_nat,\n    apply nnreal.mul_le_mul_right (bdd k),\n  },\n  apply summable.mul_left,\n  apply summable_geometric,\n  exact div_lt_one_of_lt half_lt_r,\nend\n\n\n\nlemma psi_def_aux_4 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable\n  (λ (m : ℕ),\n     ∥(2 : ℝ) ^ (F.d + ↑m)∥₊ *\n       ((∑' (k : ℕ), ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k)) * r ^ (F.d + ↑m))) :=\nbegin\n  -- tidy up\n  simp_rw [nnnorm_zpow, real.nnnorm_two],\n  have : ∀ m : ℕ, (2 : ℝ≥0) ^ (F.d + ↑m) *\n  ((∑' (k : ℕ), ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k)) * r ^ (F.d + ↑m)) =\n  ∑' (k : ℕ), (2 : ℝ≥0) ^ (F.d + ↑m) * ∥F s (F.d + ↑m + ↑k)∥₊ * 2⁻¹ ^ (F.d + ↑m + ↑k) * r ^ (F.d + ↑m),\n  { intro m,\n    rw [← nnreal.tsum_mul_right, ← nnreal.tsum_mul_left],\n    apply tsum_congr,\n    intro b,\n    ring },\n  rw summable_congr this, clear this,\n  -- TODO : maybe now is the time to tidy up a bit (e.g. cancel the 2^x and 2⁻¹^x)\n  suffices : summable\n  (λ (m : ℕ), ∑' (k : ℕ),\n       ∥F s (F.d + ↑m + ↑k)∥₊ *\n       2⁻¹ ^ (k : ℤ) * r ^ (F.d + ↑m)),\n  { refine (summable_congr _).2 this,\n    intro m,\n    apply tsum_congr,\n    intro b,\n    rw [inv_zpow , inv_zpow],\n    rw [← zpow_neg, ←zpow_neg],\n    have h2 : (2 : ℝ≥0) ≠ 0 := two_ne_zero,\n    simp only [zpow_add₀, ne.def, bit0_eq_zero, one_ne_zero, not_false_iff, zpow_coe_nat, neg_add_rev, zpow_neg,\n  mul_eq_mul_right_iff],\n    field_simp [zpow_ne_zero _ h2], left,\n    ring,\n  },\n  simp_rw [mul_comm],\n  -- change order of summation\n  apply nnreal.summable_symm,\n  -- check various things are summable\n  have := F.summable_half s,\n  { intro n,\n    apply psi_def_summable },\n  { apply psi_def_summable2 },\n  -- sum is then bounded above by a GP.\n  { apply psi_def_summable3, },\nend\n\nlemma psi_def_aux_3 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable\n  (λ (n : ℤ),\n     ∥-(2 : ℝ) ^ (n - 1)∥₊ *\n       ite (F.d ≤ n) ((∑' (k : ℕ), ∥F s (n + ↑k)∥₊ * 2⁻¹ ^ (n + ↑k)) * r ^ n) 0) :=\nbegin\n  -- get rid of factor of -2⁻¹\n  simp_rw [_root_.nnnorm_neg, zpow_sub₀ (two_ne_zero : (2 : ℝ) ≠ 0), nnnorm_div, zpow_one,\n    div_eq_mul_inv _ ∥(2 : ℝ)∥₊, mul_comm _ ∥(2 : ℝ)∥₊⁻¹, mul_assoc],\n  apply summable.mul_left,\n  have hinj : function.injective (λ (m : ℕ), F.d + m),\n  { rintros a b (h2 : F.d + a = F.d + b),\n    simpa using h2 },\n  -- change outer sum to m : ℕ with n : ℤ = F.d + m\n  suffices : summable (λ (m : ℕ),\n     ∥(2 : ℝ) ^ (F.d + m)∥₊ *\n       ((∑' (k : ℕ), ∥F s (F.d + m + ↑k)∥₊ * 2⁻¹ ^ (F.d + m + ↑k)) * r ^ (F.d + m))),\n  refine nnreal.summable_of_comp_injective hinj _ _,\n  { intros a ha,\n    rw [if_neg], simp,\n    intro hda, apply ha,\n    use (a - F.d).to_nat,\n    simp, rw int.to_nat_of_nonneg, ring, linarith },\n  { refine (summable_congr _).1 this,\n    simp },\n  exact psi_def_aux_4 F s,\nend\n\nlemma psi_def_aux_2 {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) : summable\n  (λ (n : ℤ),\n     ite (F.d ≤ n) ∥-(2 : ℝ) ^ (n - 1) * ∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k) * r ^ n∥₊ 0) :=\nbegin\n  simp_rw [nnnorm_mul],\n  -- next : put norm inside inner tsum (a one way implication)\n  suffices : summable\n  (λ (n : ℤ), ∥-(2 : ℝ) ^ (n - 1)∥₊ *\n     ite (F.d ≤ n)\n     ((∑' (k : ℕ), ∥F s (n + ↑k)∥₊ * 2⁻¹ ^ (n + ↑k)) * r ^ n)\n       0),\n  refine summable_of_le _ this,\n  { intro n,\n    split_ifs,\n    { simp only [_root_.nnnorm_neg, nnnorm_zpow, real.nnnorm_two, one_div, inv_zpow', neg_add_rev],\n      refine mul_le_mul_of_nonneg_left _ _,\n      { refine le_trans (nnnorm_tsum_le _) _,\n        { clear this, have := F.summable_half s,\n          simp_rw nnnorm_mul,\n          apply summable.mul_right,\n          rw ← summable_norm_iff at this,\n          simp_rw ← _root_.coe_nnnorm at this,\n          rw nnreal.summable_coe at this,\n          have hinj : function.injective (λ (b : ℕ), n + b),\n          { rintros a b (h2 : n + a = n + b),\n            simpa using h2 },\n            convert summable_comp_injective this hinj,\n            ext1 k,\n            simp [← zpow_neg] },\n        { rw ← nnreal.tsum_mul_right,\n          apply le_of_eq,\n          apply tsum_congr,\n          { intro k,\n            simp only [nnnorm_mul, nnnorm_zpow, real.nnnorm_two, nnnorm_eq, mul_eq_mul_right_iff],\n            left, left,\n            congr } } },\n      { simp } },\n    { simp } },\n  exact psi_def_aux_3 _ _,\nend\n\nlemma psi_def_aux {S : Fintype} [fact (0 < p)] [fact (p < 1)] (F : ℒ S) (s : ↥S) :\n  summable (λ (n : ℤ), ∥ite (F.d ≤ n) (-(2 : ℝ) ^ (n - 1) *\n    ∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k)) 0∥₊ * r ^ n) :=\nbegin\n  suffices :  summable (λ (n : ℤ), ite (F.d ≤ n) ∥-(2 : ℝ) ^ (n - 1) *\n    ∑' (k : ℕ), ↑(F s (n + ↑k)) * 2⁻¹ ^ (n + ↑k) * r ^ n∥₊ 0),\n  refine summable_of_le _ this,\n  { intro n,\n    split_ifs,\n    { apply le_of_eq,\n      simp_rw _root_.tsum_mul_right,\n      rw [ ← mul_assoc, nnnorm_mul _ ((r : ℝ) ^ n)],\n      simp },\n    { simp } },\n  exact psi_def_aux_2 _ _,\nend\n\ndef ψ (F : ℒ S) (hF : θ F = 0) : ℒ S :=\n{ to_fun := λ s n, if F.d ≤ n then\n    ∑ l in range (n - F.d).nat_abs.succ, F s (n - 1 - l) * (2 ^ l)\n    else 0,\n  summable' := λ s, begin\n    -- make everything real\n    change summable (λ (n : ℤ),\n     ∥((ite (F.d ≤ n)\n       (∑ (l : ℕ) in range (n - F.d).nat_abs.succ, F s (n - 1 - ↑l) * 2 ^ l) 0 : ℤ) : ℝ)∥₊\n     * r ^ n),\n    push_cast,\n    -- hypothesis that infinite sum converges at r>2⁻¹\n    -- get hypothesis that infinite sum is 0 at 2⁻¹\n    simp only [θ, ϑ] at hF,\n    replace hF := congr_fun hF s, dsimp at hF,\n    -- change sum from ℤ to ℕ\n    --rw nnreal.summable_iff_on_nat_less F.d, swap,\n    --{ intros n hn, simp [if_neg hn.not_le] },\n    have h1 : ∀ (n : ℤ),\n      ite (F.d ≤ n) (∑ (l : ℕ) in range (n - F.d).nat_abs.succ, (F s (n - 1 - ↑l) : ℝ) * 2 ^ l) 0 =\n      ite (F.d ≤ n) (-(2 : ℝ)^(n-1)*∑' (k : ℕ), F s (n + k) * 2⁻¹ ^ (n + k)) 0,\n    { intro n,\n      split_ifs with hn, swap, refl,\n      rw [← inv_mul_eq_iff_eq_mul₀, ← neg_inv, neg_mul, mul_sum, neg_eq_iff_add_eq_zero, ← hF],\n        swap, exact neg_ne_zero.2 (zpow_ne_zero _ two_ne_zero),\n      convert @tsum_add_tsum_compl ℝ ℤ _ _ _ _ _ {x : ℤ | x < n}\n        (summable.subtype (F.summable_half s) _) (summable.subtype (F.summable_half s) _) using 2,\n      { simp_rw [← inv_zpow, mul_comm ((2⁻¹ : ℝ)^(n-1)), mul_assoc],\n        simp_rw (show ∀ (x : ℕ), (2 : ℝ)^x = 2⁻¹^(-(x : ℤ)), by {intros, simp}),\n        simp_rw [← zpow_add₀ (by norm_num : (2⁻¹ : ℝ) ≠ 0), add_comm, ← sub_eq_add_neg],\n        rw ← tsum_eq_sum,\n        convert @equiv.tsum_eq ℝ _ _ _ _ _\n          (⟨λ m, ⟨n - 1 - m, lt_of_le_of_lt (sub_le_self _ (int.coe_zero_le m)) (sub_one_lt n)⟩,\n           (λ z, (n - 1 - z.1).nat_abs), λ m, by simp, λ ⟨z, hz⟩, subtype.ext begin\n--             squeeze_simp,\n             change n - 1 - (n - 1 - z).nat_abs = z,\n             rw ← int.eq_nat_abs_of_zero_le (sub_nonneg_of_le (int.le_sub_one_of_lt hz)),\n             ring, end⟩ : ℕ ≃ {z : ℤ // z < n}) _,\n        { ext, refl },\n        { intros b hb,\n          rw mul_eq_zero, left,\n          norm_cast,\n          apply lt_d_eq_zero,\n          by_contra h, push_neg at h, apply hb,\n          rw [mem_range, nat.succ_eq_add_one, ← int.coe_nat_lt, int.coe_nat_add,\n            ← int.eq_nat_abs_of_zero_le]; linarith } },\n      { convert @equiv.tsum_eq ℝ _ _ _ _ _\n          (⟨λ x, ⟨n + x, (int.le.intro rfl).not_lt⟩, (λ z, (z.1 - n).nat_abs),\n            λ x, by simp, λ ⟨x, hx⟩, subtype.ext begin\n              change n + _ = x,\n              rw ← int.eq_nat_abs_of_zero_le (sub_nonneg.2 (le_of_not_lt hx)),\n              exact add_eq_of_eq_sub' rfl,\n            end⟩ : ℕ ≃ {z : ℤ // ¬ z < n}) _,\n        ext, refl },\n    },\n    suffices : summable (λ (n : ℤ),\n     ∥ite (F.d ≤ n) (-(2 : ℝ)^(n-1)*∑' (k : ℕ), ↑(F s (n + k)) * 2⁻¹ ^ (n + k)) 0∥₊ *\n       r ^ n),\n    { refine (summable_congr _).2 this,\n      intro n,\n      congr' 2,\n      apply h1 n,\n    }, clear h1,\n    clear hF,\n    exact psi_def_aux F s,\n  end }\n\ntheorem θ_ϕ_split_exact (F : ℒ S) (hF : θ F = 0) : ϕ (ψ F hF) = F :=\nbegin\n  ext s n,\n  simp only [ϕ, ψ, sub_apply, shift_to_fun_to_fun, laurent_measures.coe_mk, nsmul_apply,\n    nsmul_eq_mul, int.nat_cast_eq_coe_nat, int.coe_nat_succ, int.coe_nat_zero, zero_add],\n  split_ifs with h1 h2,\n  { rw [sum_range_succ', (by norm_num : (1 : ℤ) + 1 = 2), mul_sum],\n    convert add_sub_cancel' _ _,\n    { rw [nat.succ_eq_add_one, (by ring : n + 1 - F.d = n - F.d + 1)],\n      obtain ⟨m, hm⟩ := (int.eq_coe_of_zero_le (sub_nonneg.mpr h2)),\n      rw hm,\n      norm_cast },\n    { ext,\n      push_cast,\n      ring_exp,\n      congr' 2,\n      ring },\n    { simp } },\n  { have hF : F.d = n + 1, linarith,\n    simp [hF] },\n  { linarith },\n  { exact (lt_d_eq_zero F s n (not_le.mp h)).symm },\nend\n\ntheorem θ_ϕ_exact (F : ℒ S) (hF : θ F = 0) : ∃ G, ϕ G = F :=\n⟨ψ F hF, θ_ϕ_split_exact F hF⟩\n\nend mem_exact\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/laurent_measures/thm69.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.46239592015176184}}
{"text": "import tactic\n\nuniverses u v\n\nstructure edge : Type 1 :=\n( op_type : Type )\n( type : Type )\n( R : op_type → type → Prop )\n\nnamespace edge\n\ndef op (E : edge) : edge :=\n{ op_type := E.type,\n  type := E.op_type,\n  R := λ x y, E.R y x }\n\nstructure hom (X Y : edge) : Type :=\n( op_hom : Y.op_type → X.op_type )\n( hom : X.type → Y.type )\n( adj : ∀ (x : X.type) (y : Y.op_type), X.R (op_hom y) x ↔ Y.R y (hom x) )\n\ndef functional (E : edge) : Prop :=\n∃ f : E.op_type → E.type, ∀ x y, E.R x y ↔ f x = y\n\ndef id (X : edge) : hom X X :=\n{ op_hom := id,\n  hom := id,\n  adj := λ _ _, iff.rfl }\n\ndef comp {X Y Z : edge} (f : hom Y Z) (g : hom X Y) : hom X Z :=\n{ op_hom := g.op_hom ∘ f.op_hom,\n  hom := f.hom ∘ g.hom,\n  adj := λ x y, by simp [f.adj, g.adj] }\n\ndef pullback (E : edge) : Type := { x : E.op_type × E.type // E.R x.1 x.2 }\n\ndef id_edge (X : Type) : edge :=\n{ op_type := X,\n  type := X,\n  R := eq }\n\ndef of_fun {X Y : Type} (f : X → Y) : edge :=\n{ op_type := X,\n  type := Y,\n  R := λ x y, f x = y }\n\ndef id_to_of_fun {X Y : Type} (f : X → Y) : hom (id_edge Y) (of_fun f) :=\n{ op_hom := f,\n  hom := _root_.id,\n  adj := begin\n    intros, refl,\n  end }\n\n-- def thing (X : Type) : Type :=\n-- Π (f : Π x : X, {l : list X // x ∈ l}) (x : X), {l : list (list X) // (f x).1 ∈ l}\n\n-- inductive list.rel_lift {A B : Type} (R : A → B → Prop) : list A → list B → Prop\n-- | nil : list.rel_lift [] []\n-- | cons : ∀ a b l₁ l₂, list.rel_lift l₁ l₂ → R a b → list.rel_lift (a :: l₁) (b::l₂)\n\n-- def thing' (E : edge) : Type := \n-- Π (f : Π x : E.type, { l : list E.op_type // ∃ (y : E.op_type) (h : E.R y x), y ∈ l }) (x : E.op_type),\n--   {l : list (list E.type) // ∃ (y : E.type) (h : E.R x y) \n--     (l' : list E.type) (h : list.rel_lift E.R (f y).1 l'), l' ∈ l  }\n\n-- def thing'_map {X Y : edge} (f : hom X Y) (t : thing' X) : thing' Y :=\n-- λ g y, begin\n--   dsimp only [thing', thing] at t,\n--   let g' : Π (x : X.type), { l : list X.op_type // ∃ (y : X.op_type) (h : X.R y x ), y ∈ l },\n--     from λ x, ⟨(g (f.hom x)).1.map f.op_hom, begin\n--       rcases (g (f.hom x)).2 with ⟨y, hy₁, hy₂⟩,\n--       existsi f.op_hom y,\n--       rw [f.adj],\n--       use hy₁,\n--       rw [list.mem_map],\n--       use y,\n--       simpa using hy₂,\n--     end⟩,\n--   let l := t g' (f.op_hom y),\n--   fsplit,\n--   exact l.1.map (list.map f.hom),\n--   rcases l.2 with ⟨x, hxy, l', hl', hll⟩,\n--   use f.hom x,\n--   rw ← f.adj,\n--   use hxy,\n--   use l'.map f.hom,\n--   split,\n--   intros,\n--   clear_except hl' ,\n--   dsimp [g'] at hl',\n--   simp,\n--   generalize hk : (↑(g (f.hom x)) : list _) = k,\n--   rw hk at hl',\n--   clear_except hl',\n--   generalize hm : list.map f.op_hom k = m,\n--   rw hm at hl', \n--   induction hl' generalizing k,\n--   { simp * at *, constructor },\n--   { cases k,\n--     simp * at *,\n--     simp at hm,\n--     cases hm with hm1 hm2,\n--     subst hm1,\n--     constructor,\n--     apply hl'_ih,\n--     assumption,\n--     rwa ← f.adj },\n--   simp,\n--   use l',\n--   simp * at *\n-- end\n\n-- @[simp] lemma list.map_id {A : Type} : list.map (_root_.id : A → A) = _root_.id := \n-- by funext; simp\n\n-- lemma list.map_comp {A B C : Type} (f : A → B) (g : B → C) : \n--   list.map (g ∘ f) = list.map g ∘ list.map f := \n-- by funext; simp\n\n-- lemma thing'_map_id (X : edge) : thing'_map (edge.id X) = _root_.id :=\n-- begin\n--   cases X, funext, simp [thing'_map],\n--   refine subtype.ext _,\n--   dsimp [id] at *,\n--   rw [list.map_id, list.map_id],\n--   simp,\n--   congr,\n--   simp,\n--   simp,\n--   simp,\n--   simp,\n--   simp,\n-- end\n\n-- lemma thing'_map_comp  (X Y Z : edge) (f : hom X Y) (g : hom Y Z) : \n--   thing'_map (comp g f) =  thing'_map g ∘ thing'_map f :=\n-- begin\n--   cases X, cases Y, cases Z, cases f, cases g, funext, simp [thing'_map, comp],\n--   congr,\n--   simp,\n--   simp,\n--   simp,\n--   simp,\n--   simp,\n-- end\n\ndef id2 (E : edge) : Type := E.type\n\ndef id2_map {E₁ E₂ : edge} (f : hom E₁ E₂) : id2 E₁ → id2 E₂ := f.hom\n\nlemma id2_map_id (E : edge) : id2_map (id E) = _root_.id := rfl\n\nlemma id2_map_comp (E₁ E₂ E₃ : edge) (f : hom E₁ E₂) (g : hom E₂ E₃) : \n  id2_map (comp g f) = id2_map g ∘ id2_map f := rfl\n\ndef set2 (E : edge) : Type := E.op_type → Prop\n\ndef set2_map {E₁ E₂ : edge} (f : hom E₁ E₂) : set2 E₁ → set2 E₂ := (∘ f.op_hom)\n\nlemma set2_map_id (E : edge) : set2_map (id E) = _root_.id := rfl\n\nlemma set2_map_comp (E₁ E₂ E₃ : edge) (f : hom E₁ E₂) (g : hom E₂ E₃) : \n  set2_map (comp g f) = set2_map g ∘ set2_map f := rfl\n\nstructure group2 (E : edge) : Type :=\n( one : E.type )\n( inv : E.op_type → E.type )\n( mul : E.op_type → E.op_type → E.type )\n( one_mul : ∀ (x : E.op_type) (one' : E.op_type) (h1 : E.R one' one), mul one' x = one  )\n(inv_mul : ∀ (x : E.op_type), ∀ (inv_y : E.op_type) (hi : E.R inv_y (inv x)), mul inv_y x = one )\n( mul_assoc : ∀ (x y z : E.op_type),\n    ∀ (mul_y_z : E.op_type) (mul_x_y : E.op_type) (hyz : E.R mul_y_z (mul y z))\n      (hxy : E.R mul_x_y (mul x y)),\n    mul x mul_y_z = mul mul_x_y z )\n\ndef group2_map {X Y : edge} (f : hom X Y) (G : group2 X) : group2 Y :=\n{ one := f.hom G.one,\n  inv := λ x, f.hom (G.inv (f.op_hom x)),\n  mul := λ x y, f.hom (G.mul (f.op_hom x) (f.op_hom y)),\n  one_mul := λ x one' h1,\n    by rw G.one_mul (f.op_hom x) (f.op_hom one') ((f.adj _ _).2 h1),\n  inv_mul := λ x y hxy, \n    by rw (G.inv_mul (f.op_hom x) (f.op_hom y)) ((f.adj _ _).2 hxy),\n  mul_assoc := λ x y z mul_y_z mul_x_y h1 h2, begin \n    rw G.mul_assoc,\n    apply (f.adj _ _).2,\n    assumption,\n    apply (f.adj _ _).2,\n    assumption\n  end, }\n\nlemma group2_map_id {X : edge} : group2_map (id X) = _root_.id :=\nbegin\n  funext,\n  cases G,\n  refl,\nend\n\nlemma group2_map_comp {X Y Z : edge} (f : hom X Y) (g : hom Y Z ) : \n   group2_map (comp g f) = group2_map g ∘ group2_map f :=\nbegin\n  funext,\n  cases G,\n  refl,\nend\n\nend edge", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/parametricity/edge_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.46237458584530855}}
{"text": "/-\nCopyright © 2020 Nicolò Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Nicolò Cavalleri.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.subset_properties\nimport Mathlib.topology.tactic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 \n\nnamespace Mathlib\n\n/-!\n# Continuous bundled map\n\nIn this file we define the type `continuous_map` of continuous bundled maps.\n-/\n\n/-- Bundled continuous maps. -/\nstructure continuous_map (α : Type u_1) (β : Type u_2) [topological_space α] [topological_space β]\n    where\n  to_fun : α → β\n  continuous_to_fun :\n    autoParam (continuous to_fun)\n      (Lean.Syntax.ident Lean.SourceInfo.none\n        (String.toSubstring \"Mathlib.tactic.interactive.continuity'\")\n        (Lean.Name.mkStr\n          (Lean.Name.mkStr\n            (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"tactic\")\n            \"interactive\")\n          \"continuity'\")\n        [])\n\nnamespace continuous_map\n\n\nprotected instance has_coe_to_fun {α : Type u_1} {β : Type u_2} [topological_space α]\n    [topological_space β] : has_coe_to_fun (continuous_map α β) :=\n  has_coe_to_fun.mk (fun (x : continuous_map α β) => α → β) continuous_map.to_fun\n\nprotected theorem continuous {α : Type u_1} {β : Type u_2} [topological_space α]\n    [topological_space β] (f : continuous_map α β) : continuous ⇑f :=\n  continuous_map.continuous_to_fun f\n\ntheorem coe_continuous {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β]\n    {f : continuous_map α β} : continuous ⇑f :=\n  continuous_map.continuous_to_fun f\n\ntheorem ext {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β]\n    {f : continuous_map α β} {g : continuous_map α β} (H : ∀ (x : α), coe_fn f x = coe_fn g x) :\n    f = g :=\n  sorry\n\nprotected instance inhabited {α : Type u_1} {β : Type u_2} [topological_space α]\n    [topological_space β] [Inhabited β] : Inhabited (continuous_map α β) :=\n  { default := mk fun (_x : α) => Inhabited.default }\n\ntheorem coe_inj {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β]\n    {f : continuous_map α β} {g : continuous_map α β} (h : ⇑f = ⇑g) : f = g :=\n  sorry\n\n/-- The identity as a continuous map. -/\ndef id {α : Type u_1} [topological_space α] : continuous_map α α := mk id\n\n/-- The composition of continuous maps, as a continuous map. -/\ndef comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [topological_space α] [topological_space β]\n    [topological_space γ] (f : continuous_map β γ) (g : continuous_map α β) : continuous_map α γ :=\n  mk (⇑f ∘ ⇑g)\n\n/-- Constant map as a continuous map -/\ndef const {α : Type u_1} {β : Type u_2} [topological_space α] [topological_space β] (b : β) :\n    continuous_map α β :=\n  mk fun (x : α) => b\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/continuous_map_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4623745759413505}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Mario Carneiro, Reid Barton, Andrew Yang\n-/\nimport category_theory.limits.kan_extension\nimport category_theory.adjunction\nimport topology.category.Top.opens\n\n/-!\n# Presheaves on a topological space\n\nWe define `presheaf C X` simply as `(opens X)ᵒᵖ ⥤ C`,\nand inherit the category structure with natural transformations as morphisms.\n\nWe define\n* `pushforward_obj {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : X.presheaf C) : Y.presheaf C`\nwith notation `f _* ℱ`\nand for `ℱ : X.presheaf C` provide the natural isomorphisms\n* `pushforward.id : (𝟙 X) _* ℱ ≅ ℱ`\n* `pushforward.comp : (f ≫ g) _* ℱ ≅ g _* (f _* ℱ)`\nalong with their `@[simp]` lemmas.\n\nWe also define the functors `pushforward` and `pullback` between the categories\n`X.presheaf C` and `Y.presheaf C`, and provide their adjunction at\n`pushforward_pullback_adjunction`.\n-/\n\nuniverses v u\n\nopen category_theory\nopen topological_space\nopen opposite\n\nvariables (C : Type u) [category.{v} C]\n\nnamespace Top\n\n/-- The category of `C`-valued presheaves on a (bundled) topological space `X`. -/\n@[derive category, nolint has_inhabited_instance]\ndef presheaf (X : Top.{v}) := (opens X)ᵒᵖ ⥤ C\n\nvariables {C}\n\nnamespace presheaf\n\n/-- Pushforward a presheaf on `X` along a continuous map `f : X ⟶ Y`, obtaining a presheaf\non `Y`. -/\ndef pushforward_obj {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : X.presheaf C) : Y.presheaf C :=\n(opens.map f).op ⋙ ℱ\n\ninfix ` _* `: 80 := pushforward_obj\n\n@[simp] lemma pushforward_obj_obj {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : X.presheaf C) (U : (opens Y)ᵒᵖ) :\n  (f _* ℱ).obj U = ℱ.obj ((opens.map f).op.obj U) := rfl\n\n@[simp] lemma pushforward_obj_map {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : X.presheaf C)\n  {U V : (opens Y)ᵒᵖ} (i : U ⟶ V) :\n  (f _* ℱ).map i = ℱ.map ((opens.map f).op.map i) := rfl\n\n/--\nAn equality of continuous maps induces a natural isomorphism between the pushforwards of a presheaf\nalong those maps.\n-/\ndef pushforward_eq {X Y : Top.{v}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.presheaf C) :\n  f _* ℱ ≅ g _* ℱ :=\niso_whisker_right (nat_iso.op (opens.map_iso f g h).symm) ℱ\n\nlemma pushforward_eq' {X Y : Top.{v}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.presheaf C) :\n  f _* ℱ = g _* ℱ :=\nby rw h\n\n@[simp] lemma pushforward_eq_hom_app\n  {X Y : Top.{v}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.presheaf C) (U) :\n  (pushforward_eq h ℱ).hom.app U =\n    ℱ.map (begin dsimp [functor.op], apply quiver.hom.op, apply eq_to_hom, rw h, end) :=\nby simp [pushforward_eq]\n\n@[simp]\nlemma pushforward_eq_rfl {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : X.presheaf C) (U) :\n  (pushforward_eq (rfl : f = f) ℱ).hom.app (op U) = 𝟙 _ :=\nbegin\n  dsimp [pushforward_eq],\n  simp,\nend\n\nlemma pushforward_eq_eq {X Y : Top.{v}} {f g : X ⟶ Y} (h₁ h₂ : f = g) (ℱ : X.presheaf C) :\n  ℱ.pushforward_eq h₁ = ℱ.pushforward_eq h₂ :=\nrfl\n\nnamespace pushforward\nvariables {X : Top.{v}} (ℱ : X.presheaf C)\n\n/-- The natural isomorphism between the pushforward of a presheaf along the identity continuous map\nand the original presheaf. -/\ndef id : (𝟙 X) _* ℱ ≅ ℱ :=\n(iso_whisker_right (nat_iso.op (opens.map_id X).symm) ℱ) ≪≫ functor.left_unitor _\n\nlemma id_eq : (𝟙 X) _* ℱ = ℱ :=\nby { unfold pushforward_obj, rw opens.map_id_eq, erw functor.id_comp }\n\n@[simp] lemma id_hom_app' (U) (p) :\n  (id ℱ).hom.app (op ⟨U, p⟩) = ℱ.map (𝟙 (op ⟨U, p⟩)) :=\nby { dsimp [id], simp, }\n\nlocal attribute [tidy] tactic.op_induction'\n\n@[simp, priority 990] lemma id_hom_app (U) :\n  (id ℱ).hom.app U = ℱ.map (eq_to_hom (opens.op_map_id_obj U)) := by tidy\n\n@[simp] lemma id_inv_app' (U) (p) : (id ℱ).inv.app (op ⟨U, p⟩) = ℱ.map (𝟙 (op ⟨U, p⟩)) :=\nby { dsimp [id], simp, }\n\n/-- The natural isomorphism between\nthe pushforward of a presheaf along the composition of two continuous maps and\nthe corresponding pushforward of a pushforward. -/\ndef comp {Y Z : Top.{v}} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g) _* ℱ ≅ g _* (f _* ℱ) :=\niso_whisker_right (nat_iso.op (opens.map_comp f g).symm) ℱ\n\n\n\n@[simp] lemma comp_hom_app {Y Z : Top.{v}} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :\n  (comp ℱ f g).hom.app U = 𝟙 _ :=\nby { dsimp [comp], tidy, }\n\n@[simp] lemma comp_inv_app {Y Z : Top.{v}} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :\n  (comp ℱ f g).inv.app U = 𝟙 _ :=\nby { dsimp [comp], tidy, }\n\nend pushforward\n\n/--\nA morphism of presheaves gives rise to a morphisms of the pushforwards of those presheaves.\n-/\n@[simps]\ndef pushforward_map {X Y : Top.{v}} (f : X ⟶ Y) {ℱ 𝒢 : X.presheaf C} (α : ℱ ⟶ 𝒢) :\n  f _* ℱ ⟶ f _* 𝒢 :=\n{ app := λ U, α.app _,\n  naturality' := λ U V i, by { erw α.naturality, refl, } }\n\nopen category_theory.limits\nsection pullback\nvariable [has_colimits C]\nnoncomputable theory\n\n/--\nPullback a presheaf on `Y` along a continuous map `f : X ⟶ Y`, obtaining a presheaf on `X`.\n\nThis is defined in terms of left Kan extensions, which is just a fancy way of saying\n\"take the colimits over the open sets whose preimage contains U\".\n-/\n@[simps]\ndef pullback_obj {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : Y.presheaf C) : X.presheaf C :=\n(Lan (opens.map f).op).obj ℱ\n\n/-- Pulling back along continuous maps is functorial. -/\ndef pullback_map {X Y : Top.{v}} (f : X ⟶ Y) {ℱ 𝒢 : Y.presheaf C} (α : ℱ ⟶ 𝒢) :\n  pullback_obj f ℱ ⟶ pullback_obj f 𝒢 :=\n(Lan (opens.map f).op).map α\n\n/-- If `f '' U` is open, then `f⁻¹ℱ U ≅ ℱ (f '' U)`.  -/\n@[simps]\ndef pullback_obj_obj_of_image_open {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : Y.presheaf C) (U : opens X)\n  (H : is_open (f '' U)) : (pullback_obj f ℱ).obj (op U) ≅ ℱ.obj (op ⟨_, H⟩) :=\nbegin\n  let x : costructured_arrow (opens.map f).op (op U) :=\n  { left := op ⟨f '' U, H⟩,\n    hom := ((@hom_of_le _ _ _ ((opens.map f).obj ⟨_, H⟩) (set.image_preimage.le_u_l _)).op :\n    op ((opens.map f).obj (⟨⇑f '' ↑U, H⟩)) ⟶ op U) },\n  have hx : is_terminal x :=\n  { lift := λ s,\n    begin\n      fapply costructured_arrow.hom_mk,\n      change op (unop _) ⟶ op (⟨_, H⟩ : opens _),\n      refine (hom_of_le _).op,\n      exact (set.image_subset f s.X.hom.unop.le).trans (set.image_preimage.l_u_le ↑(unop s.X.left)),\n      simp\n    end },\n  exact is_colimit.cocone_point_unique_up_to_iso\n    (colimit.is_colimit _)\n    (colimit_of_diagram_terminal hx _),\nend\n\nnamespace pullback\nvariables {X Y : Top.{v}} (ℱ : Y.presheaf C)\n\n/-- The pullback along the identity is isomorphic to the original presheaf. -/\ndef id : pullback_obj (𝟙 _) ℱ ≅ ℱ :=\nnat_iso.of_components\n  (λ U, pullback_obj_obj_of_image_open (𝟙 _) ℱ (unop U) (by simpa using U.unop.2) ≪≫\n    ℱ.map_iso (eq_to_iso (by simp)))\n  (λ U V i,\n  begin\n      ext, simp [-eq_to_hom_map,-eq_to_iso_map],\n      erw colimit.pre_desc_assoc,\n      erw colimit.ι_desc_assoc,\n      erw colimit.ι_desc_assoc,\n      dsimp, simp only [←ℱ.map_comp], congr\n  end)\n\nlemma id_inv_app (U : opens Y) :\n  (id ℱ).inv.app (op U) = colimit.ι (Lan.diagram (opens.map (𝟙 Y)).op ℱ (op U))\n    (@costructured_arrow.mk _ _ _ _ _ (op U) _ (eq_to_hom (by simp))) :=\nbegin\n  dsimp[id], simp[-eq_to_hom_map,-eq_to_iso_map],dsimp[colimit_of_diagram_terminal],\n  delta Lan.diagram,\n  refine eq.trans _ (category.id_comp _),\n  rw ← ℱ.map_id,\n  congr,\n  any_goals { apply subsingleton.helim },\n  all_goals { simp }\nend\n\nend pullback\nend pullback\nvariable (C)\n\n/--\nThe pushforward functor.\n-/\ndef pushforward {X Y : Top.{v}} (f : X ⟶ Y) : X.presheaf C ⥤ Y.presheaf C :=\n{ obj := pushforward_obj f,\n  map := @pushforward_map _ _ X Y f }\n\nlemma id_pushforward {X : Top.{v}} : pushforward C (𝟙 X) = 𝟭 (X.presheaf C) :=\nbegin\n  apply category_theory.functor.ext,\n  { intros, ext U, have h := f.congr,\n    erw h (opens.op_map_id_obj U), simpa },\n  { intros, apply pushforward.id_eq },\nend\n\nsection iso\n\n/-- A homeomorphism of spaces gives an equivalence of categories of presheaves. -/\n@[simps] def presheaf_equiv_of_iso {X Y : Top} (H : X ≅ Y) :\n  X.presheaf C ≌ Y.presheaf C :=\nequivalence.congr_left (opens.map_map_iso H).symm.op\n\nvariable {C}\n\n/--\nIf `H : X ≅ Y` is a homeomorphism,\nthen given an `H _* ℱ ⟶ 𝒢`, we may obtain an `ℱ ⟶ H ⁻¹ _* 𝒢`.\n-/\ndef to_pushforward_of_iso {X Y : Top} (H : X ≅ Y) {ℱ : X.presheaf C} {𝒢 : Y.presheaf C}\n  (α : H.hom _* ℱ ⟶ 𝒢) : ℱ ⟶ H.inv _* 𝒢 :=\n(presheaf_equiv_of_iso _ H).to_adjunction.hom_equiv ℱ 𝒢 α\n\n@[simp]\nlemma to_pushforward_of_iso_app {X Y : Top} (H₁ : X ≅ Y) {ℱ : X.presheaf C} {𝒢 : Y.presheaf C}\n  (H₂ : H₁.hom _* ℱ ⟶ 𝒢) (U : (opens X)ᵒᵖ) :\n(to_pushforward_of_iso H₁ H₂).app U =\n  ℱ.map (eq_to_hom (by simp [opens.map, set.preimage_preimage])) ≫\n  H₂.app (op ((opens.map H₁.inv).obj (unop U))) :=\nbegin\n  delta to_pushforward_of_iso,\n  simp only [equiv.to_fun_as_coe, nat_trans.comp_app, equivalence.equivalence_mk'_unit,\n    eq_to_hom_map, presheaf_equiv_of_iso_unit_iso_hom_app_app, equivalence.to_adjunction,\n    equivalence.equivalence_mk'_counit, presheaf_equiv_of_iso_inverse_map_app,\n    adjunction.mk_of_unit_counit_hom_equiv_apply],\n  congr\nend\n\n/--\nIf `H : X ≅ Y` is a homeomorphism,\nthen given an `H _* ℱ ⟶ 𝒢`, we may obtain an `ℱ ⟶ H ⁻¹ _* 𝒢`.\n-/\ndef pushforward_to_of_iso {X Y : Top} (H₁ : X ≅ Y) {ℱ : Y.presheaf C} {𝒢 : X.presheaf C}\n  (H₂ : ℱ ⟶ H₁.hom _* 𝒢) : H₁.inv _* ℱ ⟶ 𝒢 :=\n((presheaf_equiv_of_iso _ H₁.symm).to_adjunction.hom_equiv ℱ 𝒢).symm H₂\n\n@[simp]\nlemma pushforward_to_of_iso_app {X Y : Top} (H₁ : X ≅ Y) {ℱ : Y.presheaf C} {𝒢 : X.presheaf C}\n  (H₂ : ℱ ⟶ H₁.hom _* 𝒢) (U : (opens X)ᵒᵖ) :\n(pushforward_to_of_iso H₁ H₂).app U =\n  H₂.app (op ((opens.map H₁.inv).obj (unop U))) ≫\n  𝒢.map (eq_to_hom (by simp [opens.map, set.preimage_preimage])) :=\nby simpa [pushforward_to_of_iso, equivalence.to_adjunction]\n\nend iso\n\nvariables (C) [has_colimits C]\n\n/-- Pullback a presheaf on `Y` along a continuous map `f : X ⟶ Y`, obtaining a presheaf\non `X`. -/\n@[simps map_app]\ndef pullback {X Y : Top.{v}} (f : X ⟶ Y) : Y.presheaf C ⥤ X.presheaf C := Lan (opens.map f).op\n\n@[simp] lemma pullback_obj_eq_pullback_obj {C} [category C] [has_colimits C] {X Y : Top.{v}}\n  (f : X ⟶ Y) (ℱ : Y.presheaf C) : (pullback C f).obj ℱ = pullback_obj f ℱ := rfl\n\n/-- The pullback and pushforward along a continuous map are adjoint to each other. -/\n@[simps unit_app_app counit_app_app]\ndef pushforward_pullback_adjunction {X Y : Top.{v}} (f : X ⟶ Y) :\n  pullback C f ⊣ pushforward C f := Lan.adjunction _ _\n\n/-- Pulling back along a homeomorphism is the same as pushing forward along its inverse. -/\ndef pullback_hom_iso_pushforward_inv {X Y : Top.{v}} (H : X ≅ Y) :\n  pullback C H.hom ≅ pushforward C H.inv :=\nadjunction.left_adjoint_uniq\n  (pushforward_pullback_adjunction C H.hom)\n  (presheaf_equiv_of_iso C H.symm).to_adjunction\n\n/-- Pulling back along the inverse of a homeomorphism is the same as pushing forward along it. -/\ndef pullback_inv_iso_pushforward_hom {X Y : Top.{v}} (H : X ≅ Y) :\n  pullback C H.inv ≅ pushforward C H.hom :=\nadjunction.left_adjoint_uniq\n  (pushforward_pullback_adjunction C H.inv)\n  (presheaf_equiv_of_iso C H).to_adjunction\n\nend presheaf\nend Top\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/topology/sheaves/presheaf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.46237456827268436}}
{"text": "/-\nCopyright (c) 2022 Joachim Breitner. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joachim Breitner\n\n! This file was ported from Lean 3 source module group_theory.noncomm_pi_coprod\n! leanprover-community/mathlib commit ef7acf407d265ad4081c8998687e994fa80ba70c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.GroupTheory.OrderOfElement\nimport Mathbin.Data.Finset.NoncommProd\nimport Mathbin.Data.Fintype.BigOperators\nimport Mathbin.Data.Nat.Gcd.BigOperators\nimport Mathbin.Order.SupIndep\n\n/-!\n# Canonical homomorphism from a finite family of monoids\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the construction of the canonical homomorphism from a family of monoids.\n\nGiven a family of morphisms `ϕ i : N i →* M` for each `i : ι` where elements in the\nimages of different morphisms commute, we obtain a canonical morphism\n`monoid_hom.noncomm_pi_coprod : (Π i, N i) →* M` that coincides with `ϕ`\n\n## Main definitions\n\n* `monoid_hom.noncomm_pi_coprod : (Π i, N i) →* M` is the main homomorphism\n* `subgroup.noncomm_pi_coprod : (Π i, H i) →* G` is the specialization to `H i : subgroup G`\n   and the subgroup embedding.\n\n## Main theorems\n\n* `monoid_hom.noncomm_pi_coprod` coincides with `ϕ i` when restricted to `N i`\n* `monoid_hom.noncomm_pi_coprod_mrange`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `⨆ (i : ι), (ϕ i).mrange`\n* `monoid_hom.noncomm_pi_coprod_range`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `⨆ (i : ι), (ϕ i).range`\n* `subgroup.noncomm_pi_coprod_range`: The range of `subgroup.noncomm_pi_coprod` is `⨆ (i : ι), H i`.\n* `monoid_hom.injective_noncomm_pi_coprod_of_independent`: in the case of groups, `pi_hom.hom` is\n   injective if the `ϕ` are injective and the ranges of the `ϕ` are independent.\n* `monoid_hom.independent_range_of_coprime_order`: If the `N i` have coprime orders, then the ranges\n   of the `ϕ` are independent.\n* `subgroup.independent_of_coprime_order`: If commuting normal subgroups `H i` have coprime orders,\n   they are independent.\n\n-/\n\n\nopen BigOperators\n\nnamespace Subgroup\n\nvariable {G : Type _} [Group G]\n\n/- warning: subgroup.eq_one_of_noncomm_prod_eq_one_of_independent -> Subgroup.eq_one_of_noncommProd_eq_one_of_independent is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} (s : Finset.{u2} ι) (f : ι -> G) (comm : Set.Pairwise.{u2} ι ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} ι) (Set.{u2} ι) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} ι) (Set.{u2} ι) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} ι) (Set.{u2} ι) (Finset.Set.hasCoeT.{u2} ι))) s) (fun (a : ι) (b : ι) => Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (f a) (f b))) (K : ι -> (Subgroup.{u1} G _inst_1)), (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) K) -> (forall (x : ι), (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) x s) -> (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (f x) (K x))) -> (Eq.{succ u1} G (Finset.noncommProd.{u2, u1} ι G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) s f comm) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))))) -> (forall (i : ι), (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) i s) -> (Eq.{succ u1} G (f i) (OfNat.ofNat.{u1} G 1 (OfNat.mk.{u1} G 1 (One.one.{u1} G (MulOneClass.toHasOne.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} (s : Finset.{u2} ι) (f : ι -> G) (comm : Set.Pairwise.{u2} ι (Finset.toSet.{u2} ι s) (fun (a : ι) (b : ι) => Commute.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (f a) (f b))) (K : ι -> (Subgroup.{u1} G _inst_1)), (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u1} G _inst_1) K) -> (forall (x : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) x s) -> (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) (f x) (K x))) -> (Eq.{succ u1} G (Finset.noncommProd.{u2, u1} ι G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) s f comm) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1))))))) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Finset.{u2} ι) (Finset.instMembershipFinset.{u2} ι) i s) -> (Eq.{succ u1} G (f i) (OfNat.ofNat.{u1} G 1 (One.toOfNat1.{u1} G (InvOneClass.toOne.{u1} G (DivInvOneMonoid.toInvOneClass.{u1} G (DivisionMonoid.toDivInvOneMonoid.{u1} G (Group.toDivisionMonoid.{u1} G _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align subgroup.eq_one_of_noncomm_prod_eq_one_of_independent Subgroup.eq_one_of_noncommProd_eq_one_of_independentₓ'. -/\n/-- `finset.noncomm_prod` is “injective” in `f` if `f` maps into independent subgroups.  This\ngeneralizes (one direction of) `subgroup.disjoint_iff_mul_eq_one`. -/\n@[to_additive\n      \"`finset.noncomm_sum` is “injective” in `f` if `f` maps into independent subgroups.\\nThis generalizes (one direction of) `add_subgroup.disjoint_iff_add_eq_zero`. \"]\ntheorem eq_one_of_noncommProd_eq_one_of_independent {ι : Type _} (s : Finset ι) (f : ι → G) (comm)\n    (K : ι → Subgroup G) (hind : CompleteLattice.Independent K) (hmem : ∀ x ∈ s, f x ∈ K x)\n    (heq1 : s.noncommProd f comm = 1) : ∀ i ∈ s, f i = 1 := by\n  classical\n    revert heq1\n    induction' s using Finset.induction_on with i s hnmem ih\n    · simp\n    · have hcomm := comm.mono (Finset.coe_subset.2 <| Finset.subset_insert _ _)\n      simp only [Finset.forall_mem_insert] at hmem\n      have hmem_bsupr : s.noncomm_prod f hcomm ∈ ⨆ i ∈ (s : Set ι), K i :=\n        by\n        refine' Subgroup.noncommProd_mem _ _ _\n        intro x hx\n        have : K x ≤ ⨆ i ∈ (s : Set ι), K i := le_supᵢ₂ x hx\n        exact this (hmem.2 x hx)\n      intro heq1\n      rw [Finset.noncommProd_insert_of_not_mem _ _ _ _ hnmem] at heq1\n      have hnmem' : i ∉ (s : Set ι) := by simpa\n      obtain ⟨heq1i : f i = 1, heq1S : s.noncomm_prod f _ = 1⟩ :=\n        subgroup.disjoint_iff_mul_eq_one.mp (hind.disjoint_bsupr hnmem') hmem.1 hmem_bsupr heq1\n      intro i h\n      simp only [Finset.mem_insert] at h\n      rcases h with ⟨rfl | _⟩\n      · exact heq1i\n      · exact ih hcomm hmem.2 heq1S _ h\n#align subgroup.eq_one_of_noncomm_prod_eq_one_of_independent Subgroup.eq_one_of_noncommProd_eq_one_of_independent\n#align add_subgroup.eq_zero_of_noncomm_sum_eq_zero_of_independent AddSubgroup.eq_zero_of_noncommSum_eq_zero_of_independent\n\nend Subgroup\n\nsection FamilyOfMonoids\n\nvariable {M : Type _} [Monoid M]\n\n-- We have a family of monoids\n-- The fintype assumption is not always used, but declared here, to keep things in order\nvariable {ι : Type _} [hdec : DecidableEq ι] [Fintype ι]\n\nvariable {N : ι → Type _} [∀ i, Monoid (N i)]\n\n-- And morphisms ϕ into G\nvariable (ϕ : ∀ i : ι, N i →* M)\n\n-- We assume that the elements of different morphism commute\nvariable (hcomm : Pairwise fun i j => ∀ x y, Commute (ϕ i x) (ϕ j y))\n\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `Π (i : ι), N i`\nvariable (f g : ∀ i : ι, N i)\n\nnamespace MonoidHom\n\n/- warning: monoid_hom.noncomm_pi_coprod -> MonoidHom.noncommPiCoprod is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {ι : Type.{u2}} [_inst_2 : Fintype.{u2} ι] {N : ι -> Type.{u3}} [_inst_3 : forall (i : ι), Monoid.{u3} (N i)] (ϕ : forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)), (Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : N i) (y : N j), Commute.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N i) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ i) x) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N j) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ j) y))) -> (MonoidHom.{max u2 u3, u1} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {ι : Type.{u2}} [_inst_2 : Fintype.{u2} ι] {N : ι -> Type.{u3}} [_inst_3 : forall (i : ι), Monoid.{u3} (N i)] (ϕ : forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)), (Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : N i) (y : N j), Commute.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) (Monoid.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) _inst_1)) (FunLike.coe.{max (succ u1) (succ u3), succ u3, succ u1} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N i) (fun (_x : N i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) _x) (MulHomClass.toFunLike.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N i) M (MulOneClass.toMul.{u3} (N i) (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1) (MonoidHom.monoidHomClass.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)))) (ϕ i) x) (FunLike.coe.{max (succ u1) (succ u3), succ u3, succ u1} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N j) (fun (_x : N j) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N j) => M) _x) (MulHomClass.toFunLike.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N j) M (MulOneClass.toMul.{u3} (N j) (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j))) (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1) (MonoidHom.monoidHomClass.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)))) (ϕ j) y))) -> (MonoidHom.{max u2 u3, u1} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.noncomm_pi_coprod MonoidHom.noncommPiCoprodₓ'. -/\n/-- The canonical homomorphism from a family of monoids. -/\n@[to_additive\n      \"The canonical homomorphism from a family of additive monoids.\\n\\nSee also `linear_map.lsum` for a linear version without the commutativity assumption.\"]\ndef noncommPiCoprod : (∀ i : ι, N i) →* M\n    where\n  toFun f := Finset.univ.noncommProd (fun i => ϕ i (f i)) fun i _ j _ h => hcomm h _ _\n  map_one' := by\n    apply (Finset.noncommProd_eq_pow_card _ _ _ _ _).trans (one_pow _)\n    simp\n  map_mul' f g := by\n    classical\n      convert@Finset.noncommProd_mul_distrib _ _ _ _ (fun i => ϕ i (f i)) (fun i => ϕ i (g i)) _ _ _\n      · ext i\n        exact map_mul (ϕ i) (f i) (g i)\n      · rintro i - j - h\n        exact hcomm h _ _\n#align monoid_hom.noncomm_pi_coprod MonoidHom.noncommPiCoprod\n#align add_monoid_hom.noncomm_pi_coprod AddMonoidHom.noncommPiCoprod\n\nvariable {hcomm}\n\ninclude hdec\n\n/- warning: monoid_hom.noncomm_pi_coprod_mul_single -> MonoidHom.noncommPiCoprod_mulSingle is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {ι : Type.{u2}} [hdec : DecidableEq.{succ u2} ι] [_inst_2 : Fintype.{u2} ι] {N : ι -> Type.{u3}} [_inst_3 : forall (i : ι), Monoid.{u3} (N i)] (ϕ : forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) {hcomm : Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : N i) (y : N j), Commute.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N i) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ i) x) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N j) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ j) y))} (i : ι) (y : N i), Eq.{succ u1} M (coeFn.{max (succ u1) (succ (max u2 u3)), max (succ (max u2 u3)) (succ u1)} (MonoidHom.{max u2 u3, u1} (forall (i : ι), (fun (i : ι) => N i) i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => (fun (i : ι) => N i) i) (fun (i : ι) => Monoid.toMulOneClass.{u3} ((fun (i : ι) => N i) i) ((fun (i : ι) => _inst_3 i) i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{max u2 u3, u1} (forall (i : ι), (fun (i : ι) => N i) i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => (fun (i : ι) => N i) i) (fun (i : ι) => Monoid.toMulOneClass.{u3} ((fun (i : ι) => N i) i) ((fun (i : ι) => _inst_3 i) i))) (Monoid.toMulOneClass.{u1} M _inst_1)) => (forall (i : ι), (fun (i : ι) => N i) i) -> M) (MonoidHom.hasCoeToFun.{max u2 u3, u1} (forall (i : ι), (fun (i : ι) => N i) i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => (fun (i : ι) => N i) i) (fun (i : ι) => Monoid.toMulOneClass.{u3} ((fun (i : ι) => N i) i) ((fun (i : ι) => _inst_3 i) i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.noncommPiCoprod.{u1, u2, u3} M _inst_1 ι _inst_2 (fun (i : ι) => N i) (fun (i : ι) => _inst_3 i) ϕ hcomm) (Pi.mulSingle.{u2, u3} ι (fun (i : ι) => (fun (i : ι) => N i) i) (fun (a : ι) (b : ι) => hdec a b) (fun (i : ι) => MulOneClass.toHasOne.{u3} ((fun (i : ι) => N i) i) (Monoid.toMulOneClass.{u3} ((fun (i : ι) => N i) i) (_inst_3 i))) i y)) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N i) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ i) y)\nbut is expected to have type\n  forall {M : Type.{u3}} [_inst_1 : Monoid.{u3} M] {ι : Type.{u2}} [hdec : DecidableEq.{succ u2} ι] [_inst_2 : Fintype.{u2} ι] {N : ι -> Type.{u1}} [_inst_3 : forall (i : ι), Monoid.{u1} (N i)] (ϕ : forall (i : ι), MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) {hcomm : Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : N i) (y : N j), Commute.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) (MulOneClass.toMul.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) (Monoid.toMulOneClass.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) _inst_1)) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N i) (fun (_x : N i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) _x) (MulHomClass.toFunLike.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N i) M (MulOneClass.toMul.{u1} (N i) (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (MulOneClass.toMul.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)))) (ϕ i) x) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (MonoidHom.{u1, u3} (N j) M (Monoid.toMulOneClass.{u1} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N j) (fun (_x : N j) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N j) => M) _x) (MulHomClass.toFunLike.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (N j) M (Monoid.toMulOneClass.{u1} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N j) M (MulOneClass.toMul.{u1} (N j) (Monoid.toMulOneClass.{u1} (N j) (_inst_3 j))) (MulOneClass.toMul.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (N j) M (Monoid.toMulOneClass.{u1} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N j) M (Monoid.toMulOneClass.{u1} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{u1, u3} (N j) M (Monoid.toMulOneClass.{u1} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u3} M _inst_1)))) (ϕ j) y))} (i : ι) (y : N i), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : ι), N i) => M) (Pi.mulSingle.{u2, u1} ι (fun (i : ι) => N i) (fun (a : ι) (b : ι) => hdec a b) (fun (i : ι) => Monoid.toOne.{u1} (N i) (_inst_3 i)) i y)) (FunLike.coe.{max (max (succ u3) (succ u2)) (succ u1), max (succ u2) (succ u1), succ u3} (MonoidHom.{max u2 u1, u3} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (forall (i : ι), N i) (fun (_x : forall (i : ι), N i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : ι), N i) => M) _x) (MulHomClass.toFunLike.{max (max u3 u2) u1, max u2 u1, u3} (MonoidHom.{max u2 u1, u3} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (forall (i : ι), N i) M (MulOneClass.toMul.{max u2 u1} (forall (i : ι), N i) (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)))) (MulOneClass.toMul.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHomClass.toMulHomClass.{max (max u3 u2) u1, max u2 u1, u3} (MonoidHom.{max u2 u1, u3} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{max u2 u1, u3} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)))) (MonoidHom.noncommPiCoprod.{u3, u2, u1} M _inst_1 ι _inst_2 (fun (i : ι) => N i) (fun (i : ι) => _inst_3 i) ϕ hcomm) (Pi.mulSingle.{u2, u1} ι (fun (i : ι) => N i) (fun (a : ι) (b : ι) => hdec a b) (fun (i : ι) => Monoid.toOne.{u1} (N i) (_inst_3 i)) i y)) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N i) (fun (_x : N i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) _x) (MulHomClass.toFunLike.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N i) M (MulOneClass.toMul.{u1} (N i) (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (MulOneClass.toMul.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)))) (ϕ i) y)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.noncomm_pi_coprod_mul_single MonoidHom.noncommPiCoprod_mulSingleₓ'. -/\n@[simp, to_additive]\ntheorem noncommPiCoprod_mulSingle (i : ι) (y : N i) :\n    noncommPiCoprod ϕ hcomm (Pi.mulSingle i y) = ϕ i y :=\n  by\n  change finset.univ.noncomm_prod (fun j => ϕ j (Pi.mulSingle i y j)) _ = ϕ i y\n  simp (config := { singlePass := true }) only [← Finset.insert_erase (Finset.mem_univ i)]\n  rw [Finset.noncommProd_insert_of_not_mem _ _ _ _ (Finset.not_mem_erase i _)]\n  rw [Pi.mulSingle_eq_same]\n  rw [Finset.noncommProd_eq_pow_card]\n  · rw [one_pow]\n    exact mul_one _\n  · intro j hj\n    simp only [Finset.mem_erase] at hj\n    simp [hj]\n#align monoid_hom.noncomm_pi_coprod_mul_single MonoidHom.noncommPiCoprod_mulSingle\n#align add_monoid_hom.noncomm_pi_coprod_single AddMonoidHom.noncommPiCoprod_single\n\nomit hcomm\n\n/- warning: monoid_hom.noncomm_pi_coprod_equiv -> MonoidHom.noncommPiCoprodEquiv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {ι : Type.{u2}} [hdec : DecidableEq.{succ u2} ι] [_inst_2 : Fintype.{u2} ι] {N : ι -> Type.{u3}} [_inst_3 : forall (i : ι), Monoid.{u3} (N i)], Equiv.{max 1 (succ u2) (succ u1) (succ u3), max (succ u1) (succ (max u2 u3))} (Subtype.{max (succ u2) (succ u1) (succ u3)} (forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (ϕ : forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : N i) (y : N j), Commute.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N i) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ i) x) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N j) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ j) y)))) (MonoidHom.{max u2 u3, u1} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {ι : Type.{u2}} [hdec : DecidableEq.{succ u2} ι] [_inst_2 : Fintype.{u2} ι] {N : ι -> Type.{u3}} [_inst_3 : forall (i : ι), Monoid.{u3} (N i)], Equiv.{max 1 (max (succ u1) (succ u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Subtype.{max (max (succ u1) (succ u2)) (succ u3)} (forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (ϕ : forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : N i) (y : N j), Commute.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) (Monoid.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) x) _inst_1)) (FunLike.coe.{max (succ u1) (succ u3), succ u3, succ u1} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N i) (fun (_x : N i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N i) => M) _x) (MulHomClass.toFunLike.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N i) M (MulOneClass.toMul.{u3} (N i) (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1) (MonoidHom.monoidHomClass.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)))) (ϕ i) x) (FunLike.coe.{max (succ u1) (succ u3), succ u3, succ u1} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N j) (fun (_x : N j) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : N j) => M) _x) (MulHomClass.toFunLike.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N j) M (MulOneClass.toMul.{u3} (N j) (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j))) (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u1 u3, u3, u1} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1) (MonoidHom.monoidHomClass.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)))) (ϕ j) y)))) (MonoidHom.{max u2 u3, u1} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.noncomm_pi_coprod_equiv MonoidHom.noncommPiCoprodEquivₓ'. -/\n/-- The universal property of `noncomm_pi_coprod` -/\n@[to_additive \"The universal property of `noncomm_pi_coprod`\"]\ndef noncommPiCoprodEquiv :\n    { ϕ : ∀ i, N i →* M // Pairwise fun i j => ∀ x y, Commute (ϕ i x) (ϕ j y) } ≃ ((∀ i, N i) →* M)\n    where\n  toFun ϕ := noncommPiCoprod ϕ.1 ϕ.2\n  invFun f :=\n    ⟨fun i => f.comp (MonoidHom.single N i), fun i j hij x y =>\n      Commute.map (Pi.mulSingle_commute hij x y) f⟩\n  left_inv ϕ := by\n    ext\n    simp\n  right_inv f := pi_ext fun i x => by simp\n#align monoid_hom.noncomm_pi_coprod_equiv MonoidHom.noncommPiCoprodEquiv\n#align add_monoid_hom.noncomm_pi_coprod_equiv AddMonoidHom.noncommPiCoprodEquiv\n\nomit hdec\n\ninclude hcomm\n\n/- warning: monoid_hom.noncomm_pi_coprod_mrange -> MonoidHom.noncommPiCoprod_mrange is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] {ι : Type.{u2}} [_inst_2 : Fintype.{u2} ι] {N : ι -> Type.{u3}} [_inst_3 : forall (i : ι), Monoid.{u3} (N i)] (ϕ : forall (i : ι), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) {hcomm : Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : N i) (y : N j), Commute.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N i) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ i) x) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) => (N j) -> M) (MonoidHom.hasCoeToFun.{u3, u1} (N j) M (Monoid.toMulOneClass.{u3} (N j) (_inst_3 j)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ j) y))}, Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.mrange.{max u2 u3, u1, max u1 u2 u3} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1) (MonoidHom.{max u2 u3, u1} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.monoidHomClass.{max u2 u3, u1} (forall (i : ι), N i) M (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => N i) (fun (i : ι) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.noncommPiCoprod.{u1, u2, u3} M _inst_1 ι _inst_2 (fun (i : ι) => N i) (fun (i : ι) => _inst_3 i) ϕ hcomm)) (supᵢ.{u1, succ u2} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (ConditionallyCompleteLattice.toHasSup.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.completeLattice.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))) ι (fun (i : ι) => MonoidHom.mrange.{u3, u1, max u1 u3} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1) (MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.monoidHomClass.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (ϕ i)))\nbut is expected to have type\n  forall {M : Type.{u3}} [_inst_1 : Monoid.{u3} M] {ι : Type.{u2}} [_inst_2 : DecidableEq.{succ u2} ι] [N : Fintype.{u2} ι] {_inst_3 : ι -> Type.{u1}} [ϕ : forall (i : ι), Monoid.{u1} (_inst_3 i)] (hcomm : forall (i : ι), MonoidHom.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1)) {hcomm_1 : Pairwise.{u2} ι (fun (i : ι) (j : ι) => forall (x : _inst_3 i) (y : _inst_3 j), Commute.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_3 i) => M) x) (MulOneClass.toMul.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_3 i) => M) x) (Monoid.toMulOneClass.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_3 i) => M) x) _inst_1)) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (MonoidHom.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 i) (fun (a : _inst_3 i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_3 i) => M) a) (MulHomClass.toFunLike.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 i) M (MulOneClass.toMul.{u1} (_inst_3 i) (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i))) (MulOneClass.toMul.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1)))) (hcomm i) x) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (MonoidHom.{u1, u3} (_inst_3 j) M (Monoid.toMulOneClass.{u1} (_inst_3 j) (ϕ j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 j) (fun (a : _inst_3 j) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_3 j) => M) a) (MulHomClass.toFunLike.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_3 j) M (Monoid.toMulOneClass.{u1} (_inst_3 j) (ϕ j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 j) M (MulOneClass.toMul.{u1} (_inst_3 j) (Monoid.toMulOneClass.{u1} (_inst_3 j) (ϕ j))) (MulOneClass.toMul.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHomClass.toMulHomClass.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_3 j) M (Monoid.toMulOneClass.{u1} (_inst_3 j) (ϕ j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 j) M (Monoid.toMulOneClass.{u1} (_inst_3 j) (ϕ j)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{u1, u3} (_inst_3 j) M (Monoid.toMulOneClass.{u1} (_inst_3 j) (ϕ j)) (Monoid.toMulOneClass.{u3} M _inst_1)))) (hcomm j) y))}, Eq.{succ u3} (Submonoid.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHom.mrange.{max u2 u1, u3, max (max u1 u2) u3} (forall (i : ι), _inst_3 i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => _inst_3 i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i))) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.{max u2 u1, u3} (forall (i : ι), _inst_3 i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => _inst_3 i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHom.monoidHomClass.{max u2 u1, u3} (forall (i : ι), _inst_3 i) M (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => _inst_3 i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHom.noncommPiCoprod.{u3, u2, u1} M _inst_1 ι N (fun (i : ι) => _inst_3 i) (fun (i : ι) => ϕ i) hcomm hcomm_1)) (supᵢ.{u3, succ u2} (Submonoid.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (ConditionallyCompleteLattice.toSupSet.{u3} (Submonoid.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (CompleteLattice.toConditionallyCompleteLattice.{u3} (Submonoid.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u3} M (Monoid.toMulOneClass.{u3} M _inst_1)))) ι (fun (i : ι) => MonoidHom.mrange.{u1, u3, max u3 u1} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHom.monoidHomClass.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (ϕ i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (hcomm i)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.noncomm_pi_coprod_mrange MonoidHom.noncommPiCoprod_mrangeₓ'. -/\n@[to_additive]\ntheorem noncommPiCoprod_mrange : (noncommPiCoprod ϕ hcomm).mrange = ⨆ i : ι, (ϕ i).mrange := by\n  classical\n    apply le_antisymm\n    · rintro x ⟨f, rfl⟩\n      refine' Submonoid.noncommProd_mem _ _ _ _ _\n      intro i hi\n      apply Submonoid.mem_supₛ_of_mem\n      · use i\n      simp\n    · refine' supᵢ_le _\n      rintro i x ⟨y, rfl⟩\n      refine' ⟨Pi.mulSingle i y, noncomm_pi_coprod_mul_single _ _ _⟩\n#align monoid_hom.noncomm_pi_coprod_mrange MonoidHom.noncommPiCoprod_mrange\n#align add_monoid_hom.noncomm_pi_coprod_mrange AddMonoidHom.noncommPiCoprod_mrange\n\nend MonoidHom\n\nend FamilyOfMonoids\n\nsection FamilyOfGroups\n\nvariable {G : Type _} [Group G]\n\nvariable {ι : Type _} [hdec : DecidableEq ι] [hfin : Fintype ι]\n\nvariable {H : ι → Type _} [∀ i, Group (H i)]\n\nvariable (ϕ : ∀ i : ι, H i →* G)\n\nvariable {hcomm : ∀ i j : ι, i ≠ j → ∀ (x : H i) (y : H j), Commute (ϕ i x) (ϕ j y)}\n\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `Π (i : ι), H i`\nvariable (f g : ∀ i : ι, H i)\n\ninclude hfin\n\nnamespace MonoidHom\n\n/- warning: monoid_hom.noncomm_pi_coprod_range -> MonoidHom.noncommPiCoprod_range is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hfin : Fintype.{u2} ι] {H : ι -> Type.{u3}} [_inst_2 : forall (i : ι), Group.{u3} (H i)] (ϕ : forall (i : ι), MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) {hcomm : forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : H i) (y : H j), Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (H i) -> G) (MonoidHom.hasCoeToFun.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (ϕ i) x) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (H j) -> G) (MonoidHom.hasCoeToFun.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (ϕ j) y))}, Eq.{succ u1} (Subgroup.{u1} G _inst_1) (MonoidHom.range.{max u2 u3, u1} (forall (i : ι), H i) (Pi.group.{u2, u3} ι (fun (i : ι) => H i) (fun (i : ι) => _inst_2 i)) G _inst_1 (MonoidHom.noncommPiCoprod.{u1, u2, u3} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) ι hfin (fun (i : ι) => H i) (fun (i : ι) => DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i))) ϕ hcomm)) (supᵢ.{u1, succ u2} (Subgroup.{u1} G _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subgroup.{u1} G _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1))) ι (fun (i : ι) => MonoidHom.range.{u3, u1} (H i) (_inst_2 i) G _inst_1 (ϕ i)))\nbut is expected to have type\n  forall {G : Type.{u3}} [_inst_1 : Group.{u3} G] {ι : Type.{u2}} [hfin : DecidableEq.{succ u2} ι] [H : Fintype.{u2} ι] {_inst_2 : ι -> Type.{u1}} [ϕ : forall (i : ι), Group.{u1} (_inst_2 i)] (hcomm : forall (i : ι), MonoidHom.{u1, u3} (_inst_2 i) G (Monoid.toMulOneClass.{u1} (_inst_2 i) (DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) {hcomm_1 : forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : _inst_2 i) (y : _inst_2 j), Commute.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (MulOneClass.toMul.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (Monoid.toMulOneClass.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (DivInvMonoid.toMonoid.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (Group.toDivInvMonoid.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) _inst_1)))) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (MonoidHom.{u1, u3} (_inst_2 i) G (Monoid.toMulOneClass.{u1} (_inst_2 i) (DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (_inst_2 i) (fun (a : _inst_2 i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) a) (MulHomClass.toFunLike.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_2 i) G (Monoid.toMulOneClass.{u1} (_inst_2 i) (DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (_inst_2 i) G (MulOneClass.toMul.{u1} (_inst_2 i) (Monoid.toMulOneClass.{u1} (_inst_2 i) (DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i))))) (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_2 i) G (Monoid.toMulOneClass.{u1} (_inst_2 i) (DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (_inst_2 i) G (Monoid.toMulOneClass.{u1} (_inst_2 i) (DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1))) (MonoidHom.monoidHomClass.{u1, u3} (_inst_2 i) G (Monoid.toMulOneClass.{u1} (_inst_2 i) (DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))))) (hcomm i) x) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (MonoidHom.{u1, u3} (_inst_2 j) G (Monoid.toMulOneClass.{u1} (_inst_2 j) (DivInvMonoid.toMonoid.{u1} (_inst_2 j) (Group.toDivInvMonoid.{u1} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (_inst_2 j) (fun (a : _inst_2 j) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 j) => G) a) (MulHomClass.toFunLike.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_2 j) G (Monoid.toMulOneClass.{u1} (_inst_2 j) (DivInvMonoid.toMonoid.{u1} (_inst_2 j) (Group.toDivInvMonoid.{u1} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (_inst_2 j) G (MulOneClass.toMul.{u1} (_inst_2 j) (Monoid.toMulOneClass.{u1} (_inst_2 j) (DivInvMonoid.toMonoid.{u1} (_inst_2 j) (Group.toDivInvMonoid.{u1} (_inst_2 j) (ϕ j))))) (MulOneClass.toMul.{u3} G (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u3 u1, u1, u3} (MonoidHom.{u1, u3} (_inst_2 j) G (Monoid.toMulOneClass.{u1} (_inst_2 j) (DivInvMonoid.toMonoid.{u1} (_inst_2 j) (Group.toDivInvMonoid.{u1} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) (_inst_2 j) G (Monoid.toMulOneClass.{u1} (_inst_2 j) (DivInvMonoid.toMonoid.{u1} (_inst_2 j) (Group.toDivInvMonoid.{u1} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1))) (MonoidHom.monoidHomClass.{u1, u3} (_inst_2 j) G (Monoid.toMulOneClass.{u1} (_inst_2 j) (DivInvMonoid.toMonoid.{u1} (_inst_2 j) (Group.toDivInvMonoid.{u1} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))))) (hcomm j) y))}, Eq.{succ u3} (Subgroup.{u3} G _inst_1) (MonoidHom.range.{max u2 u1, u3} (forall (i : ι), _inst_2 i) (Pi.group.{u2, u1} ι (fun (i : ι) => _inst_2 i) (fun (i : ι) => ϕ i)) G _inst_1 (MonoidHom.noncommPiCoprod.{u3, u2, u1} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)) ι H (fun (i : ι) => _inst_2 i) (fun (i : ι) => DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (ϕ i))) hcomm hcomm_1)) (supᵢ.{u3, succ u2} (Subgroup.{u3} G _inst_1) (ConditionallyCompleteLattice.toSupSet.{u3} (Subgroup.{u3} G _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u3} (Subgroup.{u3} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u3} G _inst_1))) ι (fun (i : ι) => MonoidHom.range.{u1, u3} (_inst_2 i) (ϕ i) G _inst_1 (hcomm i)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.noncomm_pi_coprod_range MonoidHom.noncommPiCoprod_rangeₓ'. -/\n-- The subgroup version of `noncomm_pi_coprod_mrange`\n@[to_additive]\ntheorem noncommPiCoprod_range : (noncommPiCoprod ϕ hcomm).range = ⨆ i : ι, (ϕ i).range := by\n  classical\n    apply le_antisymm\n    · rintro x ⟨f, rfl⟩\n      refine' Subgroup.noncommProd_mem _ _ _\n      intro i hi\n      apply Subgroup.mem_supₛ_of_mem\n      · use i\n      simp\n    · refine' supᵢ_le _\n      rintro i x ⟨y, rfl⟩\n      refine' ⟨Pi.mulSingle i y, noncomm_pi_coprod_mul_single _ _ _⟩\n#align monoid_hom.noncomm_pi_coprod_range MonoidHom.noncommPiCoprod_range\n#align add_monoid_hom.noncomm_pi_coprod_range AddMonoidHom.noncommPiCoprod_range\n\n/- warning: monoid_hom.injective_noncomm_pi_coprod_of_independent -> MonoidHom.injective_noncommPiCoprod_of_independent is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hfin : Fintype.{u2} ι] {H : ι -> Type.{u3}} [_inst_2 : forall (i : ι), Group.{u3} (H i)] (ϕ : forall (i : ι), MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) {hcomm : forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : H i) (y : H j), Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (H i) -> G) (MonoidHom.hasCoeToFun.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (ϕ i) x) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (H j) -> G) (MonoidHom.hasCoeToFun.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (ϕ j) y))}, (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) (fun (i : ι) => MonoidHom.range.{u3, u1} (H i) (_inst_2 i) G _inst_1 (ϕ i))) -> (forall (i : ι), Function.Injective.{succ u3, succ u1} (H i) G (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (H i) -> G) (MonoidHom.hasCoeToFun.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (ϕ i))) -> (Function.Injective.{max (succ u2) (succ u3), succ u1} (forall (i : ι), (fun (i : ι) => H i) i) G (coeFn.{max (succ u1) (succ (max u2 u3)), max (succ (max u2 u3)) (succ u1)} (MonoidHom.{max u2 u3, u1} (forall (i : ι), (fun (i : ι) => H i) i) G (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => (fun (i : ι) => H i) i) (fun (i : ι) => Monoid.toMulOneClass.{u3} ((fun (i : ι) => H i) i) ((fun (i : ι) => DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i))) i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{max u2 u3, u1} (forall (i : ι), (fun (i : ι) => H i) i) G (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => (fun (i : ι) => H i) i) (fun (i : ι) => Monoid.toMulOneClass.{u3} ((fun (i : ι) => H i) i) ((fun (i : ι) => DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i))) i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (forall (i : ι), (fun (i : ι) => H i) i) -> G) (MonoidHom.hasCoeToFun.{max u2 u3, u1} (forall (i : ι), (fun (i : ι) => H i) i) G (Pi.mulOneClass.{u2, u3} ι (fun (i : ι) => (fun (i : ι) => H i) i) (fun (i : ι) => Monoid.toMulOneClass.{u3} ((fun (i : ι) => H i) i) ((fun (i : ι) => DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i))) i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MonoidHom.noncommPiCoprod.{u1, u2, u3} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) ι hfin (fun (i : ι) => H i) (fun (i : ι) => DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i))) ϕ hcomm)))\nbut is expected to have type\n  forall {G : Type.{u2}} [_inst_1 : Group.{u2} G] {ι : Type.{u3}} [hfin : Fintype.{u3} ι] {H : ι -> Type.{u1}} [_inst_2 : forall (i : ι), Group.{u1} (H i)] (ϕ : forall (i : ι), MonoidHom.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) {hcomm : forall (i : ι) (j : ι), (Ne.{succ u3} ι i j) -> (forall (x : H i) (y : H j), Commute.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H i) => G) x) (MulOneClass.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H i) => G) x) (Monoid.toMulOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H i) => G) x) (DivInvMonoid.toMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H i) => G) x) (Group.toDivInvMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H i) => G) x) _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H i) (fun (_x : H i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H i) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H i) G (MulOneClass.toMul.{u1} (H i) (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))))) (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (MonoidHom.monoidHomClass.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))))) (ϕ i) x) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} (H j) G (Monoid.toMulOneClass.{u1} (H j) (DivInvMonoid.toMonoid.{u1} (H j) (Group.toDivInvMonoid.{u1} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H j) (fun (_x : H j) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H j) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} (H j) G (Monoid.toMulOneClass.{u1} (H j) (DivInvMonoid.toMonoid.{u1} (H j) (Group.toDivInvMonoid.{u1} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H j) G (MulOneClass.toMul.{u1} (H j) (Monoid.toMulOneClass.{u1} (H j) (DivInvMonoid.toMonoid.{u1} (H j) (Group.toDivInvMonoid.{u1} (H j) (_inst_2 j))))) (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} (H j) G (Monoid.toMulOneClass.{u1} (H j) (DivInvMonoid.toMonoid.{u1} (H j) (Group.toDivInvMonoid.{u1} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H j) G (Monoid.toMulOneClass.{u1} (H j) (DivInvMonoid.toMonoid.{u1} (H j) (Group.toDivInvMonoid.{u1} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (MonoidHom.monoidHomClass.{u1, u2} (H j) G (Monoid.toMulOneClass.{u1} (H j) (DivInvMonoid.toMonoid.{u1} (H j) (Group.toDivInvMonoid.{u1} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))))) (ϕ j) y))}, (CompleteLattice.Independent.{succ u3, u2} ι (Subgroup.{u2} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u2} G _inst_1) (fun (i : ι) => MonoidHom.range.{u1, u2} (H i) (_inst_2 i) G _inst_1 (ϕ i))) -> (forall (i : ι), Function.Injective.{succ u1, succ u2} (H i) G (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (MonoidHom.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H i) (fun (_x : H i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : H i) => G) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H i) G (MulOneClass.toMul.{u1} (H i) (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))))) (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u1, u2} (MonoidHom.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (MonoidHom.monoidHomClass.{u1, u2} (H i) G (Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))))) (ϕ i))) -> (Function.Injective.{max (succ u3) (succ u1), succ u2} (forall (i : ι), H i) G (FunLike.coe.{max (max (succ u2) (succ u3)) (succ u1), max (succ u3) (succ u1), succ u2} (MonoidHom.{max u3 u1, u2} (forall (i : ι), H i) G (Pi.mulOneClass.{u3, u1} ι (fun (i : ι) => H i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (forall (i : ι), H i) (fun (_x : forall (i : ι), H i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : ι), H i) => G) _x) (MulHomClass.toFunLike.{max (max u2 u3) u1, max u3 u1, u2} (MonoidHom.{max u3 u1, u2} (forall (i : ι), H i) G (Pi.mulOneClass.{u3, u1} ι (fun (i : ι) => H i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (forall (i : ι), H i) G (MulOneClass.toMul.{max u3 u1} (forall (i : ι), H i) (Pi.mulOneClass.{u3, u1} ι (fun (i : ι) => H i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i)))))) (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max (max u2 u3) u1, max u3 u1, u2} (MonoidHom.{max u3 u1, u2} (forall (i : ι), H i) G (Pi.mulOneClass.{u3, u1} ι (fun (i : ι) => H i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (forall (i : ι), H i) G (Pi.mulOneClass.{u3, u1} ι (fun (i : ι) => H i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (MonoidHom.monoidHomClass.{max u3 u1, u2} (forall (i : ι), H i) G (Pi.mulOneClass.{u3, u1} ι (fun (i : ι) => H i) (fun (i : ι) => Monoid.toMulOneClass.{u1} (H i) (DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))))) (MonoidHom.noncommPiCoprod.{u2, u3, u1} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)) ι hfin (fun (i : ι) => H i) (fun (i : ι) => DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))) ϕ hcomm)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.injective_noncomm_pi_coprod_of_independent MonoidHom.injective_noncommPiCoprod_of_independentₓ'. -/\n@[to_additive]\ntheorem injective_noncommPiCoprod_of_independent\n    (hind : CompleteLattice.Independent fun i => (ϕ i).range)\n    (hinj : ∀ i, Function.Injective (ϕ i)) : Function.Injective (noncommPiCoprod ϕ hcomm) := by\n  classical\n    apply (MonoidHom.ker_eq_bot_iff _).mp\n    apply eq_bot_iff.mpr\n    intro f heq1\n    change finset.univ.noncomm_prod (fun i => ϕ i (f i)) _ = 1 at heq1\n    change f = 1\n    have : ∀ i, i ∈ Finset.univ → ϕ i (f i) = 1 :=\n      Subgroup.eq_one_of_noncommProd_eq_one_of_independent _ _ _ _ hind (by simp) heq1\n    ext i\n    apply hinj\n    simp [this i (Finset.mem_univ i)]\n#align monoid_hom.injective_noncomm_pi_coprod_of_independent MonoidHom.injective_noncommPiCoprod_of_independent\n#align add_monoid_hom.injective_noncomm_pi_coprod_of_independent AddMonoidHom.injective_noncommPiCoprod_of_independent\n\nvariable (hcomm)\n\nomit hfin\n\n/- warning: monoid_hom.independent_range_of_coprime_order -> MonoidHom.independent_range_of_coprime_order is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} {H : ι -> Type.{u3}} [_inst_2 : forall (i : ι), Group.{u3} (H i)] (ϕ : forall (i : ι), MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))), (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : H i) (y : H j), Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (H i) -> G) (MonoidHom.hasCoeToFun.{u3, u1} (H i) G (Monoid.toMulOneClass.{u3} (H i) (DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (ϕ i) x) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (MonoidHom.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (H j) -> G) (MonoidHom.hasCoeToFun.{u3, u1} (H j) G (Monoid.toMulOneClass.{u3} (H j) (DivInvMonoid.toMonoid.{u3} (H j) (Group.toDivInvMonoid.{u3} (H j) (_inst_2 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (ϕ j) y))) -> (forall [_inst_3 : Finite.{succ u2} ι] [_inst_4 : forall (i : ι), Fintype.{u3} (H i)], (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (Nat.coprime (Fintype.card.{u3} (H i) (_inst_4 i)) (Fintype.card.{u3} (H j) (_inst_4 j)))) -> (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) (fun (i : ι) => MonoidHom.range.{u3, u1} (H i) (_inst_2 i) G _inst_1 (ϕ i))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u3}} [H : DecidableEq.{succ u3} ι] {_inst_2 : ι -> Type.{u2}} [ϕ : forall (i : ι), Group.{u2} (_inst_2 i)] (hcomm : forall (i : ι), MonoidHom.{u2, u1} (_inst_2 i) G (Monoid.toMulOneClass.{u2} (_inst_2 i) (DivInvMonoid.toMonoid.{u2} (_inst_2 i) (Group.toDivInvMonoid.{u2} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))), (forall (i : ι) (j : ι), (Ne.{succ u3} ι i j) -> (forall (x : _inst_2 i) (y : _inst_2 j), Commute.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (Monoid.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (DivInvMonoid.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) (Group.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) x) _inst_1)))) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (MonoidHom.{u2, u1} (_inst_2 i) G (Monoid.toMulOneClass.{u2} (_inst_2 i) (DivInvMonoid.toMonoid.{u2} (_inst_2 i) (Group.toDivInvMonoid.{u2} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (_inst_2 i) (fun (a : _inst_2 i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 i) => G) a) (MulHomClass.toFunLike.{max u1 u2, u2, u1} (MonoidHom.{u2, u1} (_inst_2 i) G (Monoid.toMulOneClass.{u2} (_inst_2 i) (DivInvMonoid.toMonoid.{u2} (_inst_2 i) (Group.toDivInvMonoid.{u2} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (_inst_2 i) G (MulOneClass.toMul.{u2} (_inst_2 i) (Monoid.toMulOneClass.{u2} (_inst_2 i) (DivInvMonoid.toMonoid.{u2} (_inst_2 i) (Group.toDivInvMonoid.{u2} (_inst_2 i) (ϕ i))))) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u2, u1} (MonoidHom.{u2, u1} (_inst_2 i) G (Monoid.toMulOneClass.{u2} (_inst_2 i) (DivInvMonoid.toMonoid.{u2} (_inst_2 i) (Group.toDivInvMonoid.{u2} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (_inst_2 i) G (Monoid.toMulOneClass.{u2} (_inst_2 i) (DivInvMonoid.toMonoid.{u2} (_inst_2 i) (Group.toDivInvMonoid.{u2} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (MonoidHom.monoidHomClass.{u2, u1} (_inst_2 i) G (Monoid.toMulOneClass.{u2} (_inst_2 i) (DivInvMonoid.toMonoid.{u2} (_inst_2 i) (Group.toDivInvMonoid.{u2} (_inst_2 i) (ϕ i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))) (hcomm i) x) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (MonoidHom.{u2, u1} (_inst_2 j) G (Monoid.toMulOneClass.{u2} (_inst_2 j) (DivInvMonoid.toMonoid.{u2} (_inst_2 j) (Group.toDivInvMonoid.{u2} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (_inst_2 j) (fun (a : _inst_2 j) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : _inst_2 j) => G) a) (MulHomClass.toFunLike.{max u1 u2, u2, u1} (MonoidHom.{u2, u1} (_inst_2 j) G (Monoid.toMulOneClass.{u2} (_inst_2 j) (DivInvMonoid.toMonoid.{u2} (_inst_2 j) (Group.toDivInvMonoid.{u2} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (_inst_2 j) G (MulOneClass.toMul.{u2} (_inst_2 j) (Monoid.toMulOneClass.{u2} (_inst_2 j) (DivInvMonoid.toMonoid.{u2} (_inst_2 j) (Group.toDivInvMonoid.{u2} (_inst_2 j) (ϕ j))))) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u2, u1} (MonoidHom.{u2, u1} (_inst_2 j) G (Monoid.toMulOneClass.{u2} (_inst_2 j) (DivInvMonoid.toMonoid.{u2} (_inst_2 j) (Group.toDivInvMonoid.{u2} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (_inst_2 j) G (Monoid.toMulOneClass.{u2} (_inst_2 j) (DivInvMonoid.toMonoid.{u2} (_inst_2 j) (Group.toDivInvMonoid.{u2} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (MonoidHom.monoidHomClass.{u2, u1} (_inst_2 j) G (Monoid.toMulOneClass.{u2} (_inst_2 j) (DivInvMonoid.toMonoid.{u2} (_inst_2 j) (Group.toDivInvMonoid.{u2} (_inst_2 j) (ϕ j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))) (hcomm j) y))) -> (forall [_inst_4 : Finite.{succ u3} ι] [hcoprime : forall (i : ι), Fintype.{u2} (_inst_2 i)], (forall (i : ι) (j : ι), (Ne.{succ u3} ι i j) -> (Nat.coprime (Fintype.card.{u2} (_inst_2 i) (hcoprime i)) (Fintype.card.{u2} (_inst_2 j) (hcoprime j)))) -> (CompleteLattice.Independent.{succ u3, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u1} G _inst_1) (fun (i : ι) => MonoidHom.range.{u2, u1} (_inst_2 i) (ϕ i) G _inst_1 (hcomm i))))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.independent_range_of_coprime_order MonoidHom.independent_range_of_coprime_orderₓ'. -/\n@[to_additive]\ntheorem independent_range_of_coprime_order [Finite ι] [∀ i, Fintype (H i)]\n    (hcoprime : ∀ i j, i ≠ j → Nat.coprime (Fintype.card (H i)) (Fintype.card (H j))) :\n    CompleteLattice.Independent fun i => (ϕ i).range :=\n  by\n  cases nonempty_fintype ι\n  classical\n    rintro i\n    rw [disjoint_iff_inf_le]\n    rintro f ⟨hxi, hxp⟩\n    dsimp at hxi hxp\n    rw [supᵢ_subtype', ← noncomm_pi_coprod_range] at hxp\n    rotate_left\n    · intro _ _ hj\n      apply hcomm\n      exact hj ∘ Subtype.ext\n    cases' hxp with g hgf\n    cases' hxi with g' hg'f\n    have hxi : orderOf f ∣ Fintype.card (H i) :=\n      by\n      rw [← hg'f]\n      exact (orderOf_map_dvd _ _).trans orderOf_dvd_card_univ\n    have hxp : orderOf f ∣ ∏ j : { j // j ≠ i }, Fintype.card (H j) :=\n      by\n      rw [← hgf, ← Fintype.card_pi]\n      exact (orderOf_map_dvd _ _).trans orderOf_dvd_card_univ\n    change f = 1\n    rw [← pow_one f, ← orderOf_dvd_iff_pow_eq_one]\n    convert← Nat.dvd_gcd hxp hxi\n    rw [← Nat.coprime_iff_gcd_eq_one]\n    apply Nat.coprime_prod_left\n    intro j _\n    apply hcoprime\n    exact j.2\n#align monoid_hom.independent_range_of_coprime_order MonoidHom.independent_range_of_coprime_order\n#align add_monoid_hom.independent_range_of_coprime_order AddMonoidHom.independent_range_of_coprime_order\n\nend MonoidHom\n\nend FamilyOfGroups\n\nnamespace Subgroup\n\n-- We have an family of subgroups\nvariable {G : Type _} [Group G]\n\nvariable {ι : Type _} [hdec : DecidableEq ι] [hfin : Fintype ι] {H : ι → Subgroup G}\n\n-- Elements of `Π (i : ι), H i` are called `f` and `g` here\nvariable (f g : ∀ i : ι, H i)\n\nsection CommutingSubgroups\n\n-- We assume that the elements of different subgroups commute\nvariable (hcomm : ∀ i j : ι, i ≠ j → ∀ x y : G, x ∈ H i → y ∈ H j → Commute x y)\n\ninclude hcomm\n\n/- warning: subgroup.commute_subtype_of_commute -> Subgroup.commute_subtype_of_commute is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} {H : ι -> (Subgroup.{u1} G _inst_1)}, (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x (H i)) -> (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))) -> (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (y : coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)), Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Subgroup.toGroup.{u1} G _inst_1 (H i))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Subgroup.toGroup.{u1} G _inst_1 (H i))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) -> G) (MonoidHom.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Subgroup.toGroup.{u1} G _inst_1 (H i))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subgroup.subtype.{u1} G _inst_1 (H i)) x) (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) G (Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (Subgroup.toGroup.{u1} G _inst_1 (H j))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) G (Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (Subgroup.toGroup.{u1} G _inst_1 (H j))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) -> G) (MonoidHom.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) G (Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (Subgroup.toGroup.{u1} G _inst_1 (H j))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subgroup.subtype.{u1} G _inst_1 (H j)) y)))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} {H : ι -> (Subgroup.{u1} G _inst_1)}, (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i)) -> (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))) -> (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (y : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))), Commute.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => G) x) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => G) x) (Monoid.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => G) x) (DivInvMonoid.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => G) x) (Group.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => G) x) _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (_x : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => G) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (MulOneClass.toMul.{u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i)))) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (MonoidHom.monoidHomClass.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))) (Subgroup.subtype.{u1} G _inst_1 (H i)) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H j))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) (fun (_x : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) => G) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H j))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) G (MulOneClass.toMul.{u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H j)))) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H j))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H j))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (MonoidHom.monoidHomClass.{u1, u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H j))) G (Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H j))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))) (Subgroup.subtype.{u1} G _inst_1 (H j)) y)))\nCase conversion may be inaccurate. Consider using '#align subgroup.commute_subtype_of_commute Subgroup.commute_subtype_of_commuteₓ'. -/\n@[to_additive]\ntheorem commute_subtype_of_commute (i j : ι) (hne : i ≠ j) :\n    ∀ (x : H i) (y : H j), Commute ((H i).Subtype x) ((H j).Subtype y) :=\n  by\n  rintro ⟨x, hx⟩ ⟨y, hy⟩\n  exact hcomm i j hne x y hx hy\n#align subgroup.commute_subtype_of_commute Subgroup.commute_subtype_of_commute\n#align add_subgroup.commute_subtype_of_commute AddSubgroup.commute_subtype_of_commute\n\ninclude hfin\n\n/- warning: subgroup.noncomm_pi_coprod -> Subgroup.noncommPiCoprod is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hfin : Fintype.{u2} ι] {H : ι -> (Subgroup.{u1} G _inst_1)}, (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x (H i)) -> (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))) -> (MonoidHom.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (fun (i : ι) => Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Subgroup.toGroup.{u1} G _inst_1 (H i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hfin : Fintype.{u2} ι] {H : ι -> (Subgroup.{u1} G _inst_1)}, (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i)) -> (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))) -> (MonoidHom.{max u1 u2, u1} (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))))\nCase conversion may be inaccurate. Consider using '#align subgroup.noncomm_pi_coprod Subgroup.noncommPiCoprodₓ'. -/\n/-- The canonical homomorphism from a family of subgroups where elements from different subgroups\ncommute -/\n@[to_additive\n      \"The canonical homomorphism from a family of additive subgroups where elements from\\ndifferent subgroups commute\"]\ndef noncommPiCoprod : (∀ i : ι, H i) →* G :=\n  MonoidHom.noncommPiCoprod (fun i => (H i).Subtype) (commute_subtype_of_commute hcomm)\n#align subgroup.noncomm_pi_coprod Subgroup.noncommPiCoprod\n#align add_subgroup.noncomm_pi_coprod AddSubgroup.noncommPiCoprod\n\nvariable {hcomm}\n\ninclude hdec\n\n/- warning: subgroup.noncomm_pi_coprod_mul_single -> Subgroup.noncommPiCoprod_mulSingle is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hdec : DecidableEq.{succ u2} ι] [hfin : Fintype.{u2} ι] {H : ι -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x (H i)) -> (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))} (i : ι) (y : coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)), Eq.{succ u1} G (coeFn.{max (succ u1) (succ (max u2 u1)), max (succ (max u2 u1)) (succ u1)} (MonoidHom.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (fun (i : ι) => Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : ι) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (fun (i : ι) => Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : ι) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) -> G) (MonoidHom.hasCoeToFun.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (fun (i : ι) => Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : ι) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subgroup.noncommPiCoprod.{u1, u2} G _inst_1 ι hfin (fun (i : ι) => H i) hcomm) (Pi.mulSingle.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (fun (a : ι) (b : ι) => hdec a b) (fun (i : ι) => Subgroup.one.{u1} G _inst_1 ((fun (i : ι) => H i) i)) i y)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) G (coeSubtype.{succ u1} G (fun (x : G) => Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x (H i)))))) y)\nbut is expected to have type\n  forall {G : Type.{u2}} [_inst_1 : Group.{u2} G] {ι : Type.{u1}} [hdec : DecidableEq.{succ u1} ι] [hfin : Fintype.{u1} ι] {H : ι -> (Subgroup.{u2} G _inst_1)} {hcomm : forall (i : ι) (j : ι), (Ne.{succ u1} ι i j) -> (forall (x : G) (y : G), (Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i)) -> (Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) y (H j)) -> (Commute.{u2} G (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) x y))} (i : ι) (y : Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) => G) (Pi.mulSingle.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (a : ι) (b : ι) => hdec a b) (fun (i : ι) => Subgroup.one.{u2} G _inst_1 (H i)) i y)) (FunLike.coe.{max (succ u2) (succ u1), max (succ u2) (succ u1), succ u2} (MonoidHom.{max u2 u1, u2} (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (Subgroup.toSubmonoid.{u2} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (_x : forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) => G) _x) (MulHomClass.toFunLike.{max u2 u1, max u2 u1, u2} (MonoidHom.{max u2 u1, u2} (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (Subgroup.toSubmonoid.{u2} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) G (MulOneClass.toMul.{max u2 u1} (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (Pi.mulOneClass.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (Subgroup.toSubmonoid.{u2} G _inst_1 (H i))))) (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u2 u1, max u2 u1, u2} (MonoidHom.{max u2 u1, u2} (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (Subgroup.toSubmonoid.{u2} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (Subgroup.toSubmonoid.{u2} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (MonoidHom.monoidHomClass.{max u2 u1, u2} (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1))) (Subgroup.toSubmonoid.{u2} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))))) (Subgroup.noncommPiCoprod.{u2, u1} G _inst_1 ι hfin (fun (i : ι) => H i) hcomm) (Pi.mulSingle.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (H i))) (fun (a : ι) (b : ι) => hdec a b) (fun (i : ι) => Subgroup.one.{u2} G _inst_1 (H i)) i y)) (Subtype.val.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Set.{u2} G) (Set.instMembershipSet.{u2} G) x (SetLike.coe.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1) (H i))) y)\nCase conversion may be inaccurate. Consider using '#align subgroup.noncomm_pi_coprod_mul_single Subgroup.noncommPiCoprod_mulSingleₓ'. -/\n@[simp, to_additive]\ntheorem noncommPiCoprod_mulSingle (i : ι) (y : H i) :\n    noncommPiCoprod hcomm (Pi.mulSingle i y) = y := by apply MonoidHom.noncommPiCoprod_mulSingle\n#align subgroup.noncomm_pi_coprod_mul_single Subgroup.noncommPiCoprod_mulSingle\n#align add_subgroup.noncomm_pi_coprod_single AddSubgroup.noncommPiCoprod_single\n\nomit hdec\n\n/- warning: subgroup.noncomm_pi_coprod_range -> Subgroup.noncommPiCoprod_range is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hfin : Fintype.{u2} ι] {H : ι -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x (H i)) -> (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))}, Eq.{succ u1} (Subgroup.{u1} G _inst_1) (MonoidHom.range.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (Pi.group.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (fun (i : ι) => Subgroup.toGroup.{u1} G _inst_1 (H i))) G _inst_1 (Subgroup.noncommPiCoprod.{u1, u2} G _inst_1 ι hfin (fun (i : ι) => H i) hcomm)) (supᵢ.{u1, succ u2} (Subgroup.{u1} G _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subgroup.{u1} G _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1))) ι (fun (i : ι) => H i))\nbut is expected to have type\n  forall {G : Type.{u2}} [_inst_1 : Group.{u2} G] {ι : Type.{u1}} [hfin : DecidableEq.{succ u1} ι] [H : Fintype.{u1} ι] {hcomm : ι -> (Subgroup.{u2} G _inst_1)} {hcomm_1 : forall (i : ι) (j : ι), (Ne.{succ u1} ι i j) -> (forall (x : G) (y : G), (Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (hcomm i)) -> (Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) y (hcomm j)) -> (Commute.{u2} G (MulOneClass.toMul.{u2} G (Monoid.toMulOneClass.{u2} G (DivInvMonoid.toMonoid.{u2} G (Group.toDivInvMonoid.{u2} G _inst_1)))) x y))}, Eq.{succ u2} (Subgroup.{u2} G _inst_1) (MonoidHom.range.{max u2 u1, u2} (forall (i : ι), Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (hcomm i))) (Pi.group.{u1, u2} ι (fun (i : ι) => Subtype.{succ u2} G (fun (x : G) => Membership.mem.{u2, u2} G (Subgroup.{u2} G _inst_1) (SetLike.instMembership.{u2, u2} (Subgroup.{u2} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u2} G _inst_1)) x (hcomm i))) (fun (i : ι) => Subgroup.toGroup.{u2} G _inst_1 (hcomm i))) G _inst_1 (Subgroup.noncommPiCoprod.{u2, u1} G _inst_1 ι H (fun (i : ι) => hcomm i) hcomm_1)) (supᵢ.{u2, succ u1} (Subgroup.{u2} G _inst_1) (ConditionallyCompleteLattice.toSupSet.{u2} (Subgroup.{u2} G _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subgroup.{u2} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u2} G _inst_1))) ι (fun (i : ι) => hcomm i))\nCase conversion may be inaccurate. Consider using '#align subgroup.noncomm_pi_coprod_range Subgroup.noncommPiCoprod_rangeₓ'. -/\n@[to_additive]\ntheorem noncommPiCoprod_range : (noncommPiCoprod hcomm).range = ⨆ i : ι, H i := by\n  simp [noncomm_pi_coprod, MonoidHom.noncommPiCoprod_range]\n#align subgroup.noncomm_pi_coprod_range Subgroup.noncommPiCoprod_range\n#align add_subgroup.noncomm_pi_coprod_range AddSubgroup.noncommPiCoprod_range\n\n/- warning: subgroup.injective_noncomm_pi_coprod_of_independent -> Subgroup.injective_noncommPiCoprod_of_independent is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hfin : Fintype.{u2} ι] {H : ι -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x (H i)) -> (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))}, (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) H) -> (Function.Injective.{max (succ u2) (succ u1), succ u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) G (coeFn.{max (succ u1) (succ (max u2 u1)), max (succ (max u2 u1)) (succ u1)} (MonoidHom.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (fun (i : ι) => Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : ι) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (fun (_x : MonoidHom.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (fun (i : ι) => Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : ι) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) -> G) (MonoidHom.hasCoeToFun.{max u2 u1, u1} (forall (i : ι), coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (fun (i : ι) => Monoid.toMulOneClass.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (DivInvMonoid.toMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) ((fun (i : ι) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : ι) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subgroup.noncommPiCoprod.{u1, u2} G _inst_1 ι hfin (fun (i : ι) => H i) hcomm)))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [hfin : Fintype.{u2} ι] {H : ι -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i)) -> (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))}, (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u1} G _inst_1) H) -> (Function.Injective.{max (succ u1) (succ u2), succ u1} (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (FunLike.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2), succ u1} (MonoidHom.{max u1 u2, u1} (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (_x : forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) => G) _x) (MulHomClass.toFunLike.{max u1 u2, max u1 u2, u1} (MonoidHom.{max u1 u2, u1} (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (MulOneClass.toMul.{max u1 u2} (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i))))) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (MonoidHomClass.toMulHomClass.{max u1 u2, max u1 u2, u1} (MonoidHom.{max u1 u2, u1} (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (MonoidHom.monoidHomClass.{max u1 u2, u1} (forall (i : ι), Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) G (Pi.mulOneClass.{u2, u1} ι (fun (i : ι) => Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (H i))) (fun (i : ι) => Submonoid.toMulOneClass.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1))) (Subgroup.toSubmonoid.{u1} G _inst_1 (H i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))) (Subgroup.noncommPiCoprod.{u1, u2} G _inst_1 ι hfin (fun (i : ι) => H i) hcomm)))\nCase conversion may be inaccurate. Consider using '#align subgroup.injective_noncomm_pi_coprod_of_independent Subgroup.injective_noncommPiCoprod_of_independentₓ'. -/\n@[to_additive]\ntheorem injective_noncommPiCoprod_of_independent (hind : CompleteLattice.Independent H) :\n    Function.Injective (noncommPiCoprod hcomm) :=\n  by\n  apply MonoidHom.injective_noncommPiCoprod_of_independent\n  · simpa using hind\n  · intro i\n    exact Subtype.coe_injective\n#align subgroup.injective_noncomm_pi_coprod_of_independent Subgroup.injective_noncommPiCoprod_of_independent\n#align add_subgroup.injective_noncomm_pi_coprod_of_independent AddSubgroup.injective_noncommPiCoprod_of_independent\n\nvariable (hcomm)\n\nomit hfin\n\n/- warning: subgroup.independent_of_coprime_order -> Subgroup.independent_of_coprime_order is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} {H : ι -> (Subgroup.{u1} G _inst_1)}, (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) x (H i)) -> (Membership.Mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.hasMem.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) y (H j)) -> (Commute.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))) -> (forall [_inst_2 : Finite.{succ u2} ι] [_inst_3 : forall (i : ι), Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i))], (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (Nat.coprime (Fintype.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H i)) (_inst_3 i)) (Fintype.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Subgroup.{u1} G _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.setLike.{u1} G _inst_1)) (H j)) (_inst_3 j)))) -> (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) H))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {ι : Type.{u2}} [H : DecidableEq.{succ u2} ι] {hcomm : ι -> (Subgroup.{u1} G _inst_1)}, (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (forall (x : G) (y : G), (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (hcomm i)) -> (Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) y (hcomm j)) -> (Commute.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) x y))) -> (forall [_inst_3 : Finite.{succ u2} ι] [hcoprime : forall (i : ι), Fintype.{u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (hcomm i)))], (forall (i : ι) (j : ι), (Ne.{succ u2} ι i j) -> (Nat.coprime (Fintype.card.{u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (hcomm i))) (hcoprime i)) (Fintype.card.{u1} (Subtype.{succ u1} G (fun (x : G) => Membership.mem.{u1, u1} G (Subgroup.{u1} G _inst_1) (SetLike.instMembership.{u1, u1} (Subgroup.{u1} G _inst_1) G (Subgroup.instSetLikeSubgroup.{u1} G _inst_1)) x (hcomm j))) (hcoprime j)))) -> (CompleteLattice.Independent.{succ u2, u1} ι (Subgroup.{u1} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u1} G _inst_1) hcomm))\nCase conversion may be inaccurate. Consider using '#align subgroup.independent_of_coprime_order Subgroup.independent_of_coprime_orderₓ'. -/\n@[to_additive]\ntheorem independent_of_coprime_order [Finite ι] [∀ i, Fintype (H i)]\n    (hcoprime : ∀ i j, i ≠ j → Nat.coprime (Fintype.card (H i)) (Fintype.card (H j))) :\n    CompleteLattice.Independent H := by\n  simpa using\n    MonoidHom.independent_range_of_coprime_order (fun i => (H i).Subtype)\n      (commute_subtype_of_commute hcomm) hcoprime\n#align subgroup.independent_of_coprime_order Subgroup.independent_of_coprime_order\n#align add_subgroup.independent_of_coprime_order AddSubgroup.independent_of_coprime_order\n\nend CommutingSubgroups\n\nend Subgroup\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/GroupTheory/NoncommPiCoprod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.46237456827268436}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport tactic.basic\n\nnamespace option\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\nlemma coe_def : (coe : α → option α) = some := rfl\n\nlemma some_ne_none (x : α) : some x ≠ none := λ h, option.no_confusion h\n\nprotected lemma «forall» {p : option α → Prop} : (∀ x, p x) ↔ p none ∧ ∀ x, p (some x) :=\n⟨λ h, ⟨h _, λ x, h _⟩, λ h x, option.cases_on x h.1 h.2⟩\n\nprotected lemma «exists» {p : option α → Prop} : (∃ x, p x) ↔ p none ∨ ∃ x, p (some x) :=\n⟨λ ⟨x, hx⟩, (option.cases_on x or.inl $ λ x hx, or.inr ⟨x, hx⟩) hx,\n  λ h, h.elim (λ h, ⟨_, h⟩) (λ ⟨x, hx⟩, ⟨_, hx⟩)⟩\n\n@[simp] theorem get_mem : ∀ {o : option α} (h : is_some o), option.get h ∈ o\n| (some a) _ := rfl\n\ntheorem get_of_mem {a : α} : ∀ {o : option α} (h : is_some o), a ∈ o → option.get h = a\n| _ _ rfl := rfl\n\n@[simp] lemma not_mem_none (a : α) : a ∉ (none : option α) :=\nλ h, option.no_confusion h\n\n@[simp] lemma some_get : ∀ {x : option α} (h : is_some x), some (option.get h) = x\n| (some x) hx := rfl\n\n@[simp] lemma get_some (x : α) (h : is_some (some x)) : option.get h = x := rfl\n\n@[simp] lemma get_or_else_some (x y : α) : option.get_or_else (some x) y = x := rfl\n\n@[simp] lemma get_or_else_coe (x y : α) : option.get_or_else ↑x y = x := rfl\n\nlemma get_or_else_of_ne_none {x : option α} (hx : x ≠ none) (y : α) : some (x.get_or_else y) = x :=\nby cases x; [contradiction, rw get_or_else_some]\n\ntheorem mem_unique {o : option α} {a b : α} (ha : a ∈ o) (hb : b ∈ o) : a = b :=\noption.some.inj $ ha.symm.trans hb\n\ntheorem mem.left_unique : relator.left_unique ((∈) : α → option α → Prop) :=\n⟨λ a o b, mem_unique⟩\n\ntheorem some_injective (α : Type*) : function.injective (@some α) :=\nλ _ _, some_inj.mp\n\n/-- `option.map f` is injective if `f` is injective. -/\ntheorem map_injective {f : α → β} (Hf : function.injective f) : function.injective (option.map f)\n| none      none      H := rfl\n| (some a₁) (some a₂) H := by rw Hf (option.some.inj H)\n\n@[ext] theorem ext : ∀ {o₁ o₂ : option α}, (∀ a, a ∈ o₁ ↔ a ∈ o₂) → o₁ = o₂\n| none     none     H := rfl\n| (some a) o        H := ((H _).1 rfl).symm\n| o        (some b) H := (H _).2 rfl\n\ntheorem eq_none_iff_forall_not_mem {o : option α} :\n  o = none ↔ (∀ a, a ∉ o) :=\n⟨λ e a h, by rw e at h; cases h, λ h, ext $ by simpa⟩\n\n@[simp] theorem none_bind {α β} (f : α → option β) : none >>= f = none := rfl\n\n@[simp] theorem some_bind {α β} (a : α) (f : α → option β) : some a >>= f = f a := rfl\n\n@[simp] theorem none_bind' (f : α → option β) : none.bind f = none := rfl\n\n@[simp] theorem some_bind' (a : α) (f : α → option β) : (some a).bind f = f a := rfl\n\n@[simp] theorem bind_some : ∀ x : option α, x >>= some = x :=\n@bind_pure α option _ _\n\n@[simp] theorem bind_eq_some {α β} {x : option α} {f : α → option β} {b : β} :\n  x >>= f = some b ↔ ∃ a, x = some a ∧ f a = some b :=\nby cases x; simp\n\n@[simp] theorem bind_eq_some' {x : option α} {f : α → option β} {b : β} :\n  x.bind f = some b ↔ ∃ a, x = some a ∧ f a = some b :=\nby cases x; simp\n\n@[simp] theorem bind_eq_none' {o : option α} {f : α → option β} :\n  o.bind f = none ↔ (∀ b a, a ∈ o → b ∉ f a) :=\nby simp only [eq_none_iff_forall_not_mem, not_exists, not_and, mem_def, bind_eq_some']\n\n@[simp] theorem bind_eq_none {α β} {o : option α} {f : α → option β} :\n  o >>= f = none ↔ (∀ b a, a ∈ o → b ∉ f a) :=\nbind_eq_none'\n\nlemma bind_comm {α β γ} {f : α → β → option γ} (a : option α) (b : option β) :\n  a.bind (λx, b.bind (f x)) = b.bind (λy, a.bind (λx, f x y)) :=\nby cases a; cases b; refl\n\nlemma bind_assoc (x : option α) (f : α → option β) (g : β → option γ) :\n  (x.bind f).bind g = x.bind (λ y, (f y).bind g) := by cases x; refl\n\nlemma join_eq_some {x : option (option α)} {a : α} : x.join = some a ↔ x = some (some a) := by simp\n\nlemma join_ne_none {x : option (option α)} : x.join ≠ none ↔ ∃ z, x = some (some z) := by simp\n\nlemma join_ne_none' {x : option (option α)} : ¬(x.join = none) ↔ ∃ z, x = some (some z) := by simp\n\nlemma join_eq_none {o : option (option α)} : o.join = none ↔ o = none ∨ o = some none :=\nby rcases o with _|_|_; simp\n\nlemma bind_id_eq_join {x : option (option α)} : x >>= id = x.join := by simp\n\nlemma join_eq_join : mjoin = @join α :=\nfunext (λ x, by rw [mjoin, bind_id_eq_join])\n\nlemma bind_eq_bind {α β : Type*} {f : α → option β} {x : option α} :\n  x >>= f = x.bind f := rfl\n\n@[simp] lemma map_eq_map {α β} {f : α → β} :\n  (<$>) f = option.map f := rfl\n\ntheorem map_none {α β} {f : α → β} : f <$> none = none := rfl\n\ntheorem map_some {α β} {a : α} {f : α → β} : f <$> some a = some (f a) := rfl\n\n@[simp] theorem map_none' {f : α → β} : option.map f none = none := rfl\n\n@[simp] theorem map_some' {a : α} {f : α → β} : option.map f (some a) = some (f a) := rfl\n\ntheorem map_eq_some {α β} {x : option α} {f : α → β} {b : β} :\n  f <$> x = some b ↔ ∃ a, x = some a ∧ f a = b :=\nby cases x; simp\n\n@[simp] theorem map_eq_some' {x : option α} {f : α → β} {b : β} :\n  x.map f = some b ↔ ∃ a, x = some a ∧ f a = b :=\nby cases x; simp\n\nlemma map_eq_none {α β} {x : option α} {f : α → β} :\n  f <$> x = none ↔ x = none :=\nby { cases x; simp only [map_none, map_some, eq_self_iff_true] }\n\n@[simp] lemma map_eq_none' {x : option α} {f : α → β} :\n  x.map f = none ↔ x = none :=\nby { cases x; simp only [map_none', map_some', eq_self_iff_true] }\n\nlemma map_congr {f g : α → β} {x : option α} (h : ∀ a ∈ x, f a = g a) :\n  option.map f x = option.map g x :=\nby { cases x; simp only [map_none', map_some', h, mem_def] }\n\n@[simp] theorem map_id' : option.map (@id α) = id := map_id\n\n@[simp] lemma map_map (h : β → γ) (g : α → β) (x : option α) :\n  option.map h (option.map g x) = option.map (h ∘ g) x :=\nby { cases x; simp only [map_none', map_some'] }\n\nlemma comp_map (h : β → γ) (g : α → β) (x : option α) :\n  option.map (h ∘ g) x = option.map h (option.map g x) := (map_map _ _ _).symm\n\n@[simp] lemma map_comp_map (f : α → β) (g : β → γ) :\n  option.map g ∘ option.map f = option.map (g ∘ f) :=\nby { ext x, rw comp_map }\n\nlemma mem_map_of_mem {α β : Type*} {a : α} {x : option α} (g : α → β) (h : a ∈ x) : g a ∈ x.map g :=\nmem_def.mpr ((mem_def.mp h).symm ▸ map_some')\n\nlemma bind_map_comm {α β} {x : option (option α) } {f : α → β} :\n  x >>= option.map f = x.map (option.map f) >>= id :=\nby { cases x; simp }\n\nlemma join_map_eq_map_join {f : α → β} {x : option (option α)} :\n  (x.map (option.map f)).join = x.join.map f :=\nby { rcases x with _ | _ | x; simp }\n\nlemma join_join {x : option (option (option α))} :\n  x.join.join = (x.map join).join :=\nby { rcases x with _ | _ | _ | x; simp }\n\nlemma mem_of_mem_join {a : α} {x : option (option α)} (h : a ∈ x.join) : some a ∈ x :=\nmem_def.mpr ((mem_def.mp h).symm ▸ join_eq_some.mp h)\n\nsection pmap\n\nvariables {p : α → Prop} (f : Π (a : α), p a → β) (x : option α)\n\n@[simp] lemma pbind_eq_bind (f : α → option β) (x : option α) :\n  x.pbind (λ a _, f a) = x.bind f :=\nby { cases x; simp only [pbind, none_bind', some_bind'] }\n\nlemma map_bind {α β γ} (f : β → γ) (x : option α) (g : α → option β) :\n  option.map f (x >>= g) = (x >>= λ a, option.map f (g a)) :=\nby simp_rw [←map_eq_map, ←bind_pure_comp_eq_map,is_lawful_monad.bind_assoc]\n\nlemma map_bind' (f : β → γ) (x : option α) (g : α → option β) :\n  option.map f (x.bind g) = x.bind (λ a, option.map f (g a)) :=\nby { cases x; simp }\n\nlemma map_pbind (f : β → γ) (x : option α) (g : Π a, a ∈ x → option β) :\n  option.map f (x.pbind g) = (x.pbind (λ a H, option.map f (g a H))) :=\nby { cases x; simp only [pbind, map_none'] }\n\nlemma pbind_map (f : α → β) (x : option α) (g : Π (b : β), b ∈ x.map f → option γ) :\n  pbind (option.map f x) g = x.pbind (λ a h, g (f a) (mem_map_of_mem _ h)) :=\nby { cases x; refl }\n\n@[simp] lemma pmap_none (f : Π (a : α), p a → β) {H} : pmap f (@none α) H = none := rfl\n\n@[simp] lemma pmap_some (f : Π (a : α), p a → β) {x : α} (h : p x) :\n  pmap f (some x) = λ _, some (f x h) := rfl\n\nlemma mem_pmem {a : α} (h : ∀ a ∈ x, p a) (ha : a ∈ x) :\n  f a (h a ha) ∈ pmap f x h :=\nby { rw mem_def at ha ⊢, subst ha, refl }\n\nlemma pmap_map (g : γ → α) (x : option γ) (H) :\n  pmap f (x.map g) H = pmap (λ a h, f (g a) h) x (λ a h, H _ (mem_map_of_mem _ h)) :=\nby { cases x; simp only [map_none', map_some', pmap] }\n\nlemma map_pmap (g : β → γ) (f : Π a, p a → β) (x H) :\n  option.map g (pmap f x H) = pmap (λ a h, g (f a h)) x H :=\nby { cases x; simp only [map_none', map_some', pmap] }\n\n@[simp] lemma pmap_eq_map (p : α → Prop) (f : α → β) (x H) :\n  @pmap _ _ p (λ a _, f a) x H = option.map f x :=\nby { cases x; simp only [map_none', map_some', pmap] }\n\n\n\nlemma bind_pmap {α β γ} {p : α → Prop} (f : Π a, p a → β) (x : option α) (g : β → option γ) (H) :\n  (pmap f x H) >>= g = x.pbind (λ a h, g (f a (H _ h))) :=\nby { cases x; simp only [pmap, none_bind, some_bind, pbind] }\n\nvariables {f x}\n\nlemma pbind_eq_none {f : Π (a : α), a ∈ x → option β}\n  (h' : ∀ a ∈ x, f a H = none → x = none) :\n  x.pbind f = none ↔ x = none :=\nbegin\n  cases x,\n  { simp },\n  { simp only [pbind, iff_false],\n    intro h,\n    cases h' x rfl h }\nend\n\nlemma pbind_eq_some {f : Π (a : α), a ∈ x → option β} {y : β} :\n  x.pbind f = some y ↔ ∃ (z ∈ x), f z H = some y :=\nbegin\n  cases x,\n  { simp },\n  { simp only [pbind],\n    split,\n    { intro h,\n      use x,\n      simpa only [mem_def, exists_prop_of_true] using h },\n    { rintro ⟨z, H, hz⟩,\n      simp only [mem_def] at H,\n      simpa only [H] using hz } }\nend\n\n@[simp] lemma pmap_eq_none_iff {h} :\n  pmap f x h = none ↔ x = none :=\nby { cases x; simp }\n\n@[simp] lemma pmap_eq_some_iff {hf} {y : β} :\n  pmap f x hf = some y ↔ ∃ (a : α) (H : x = some a), f a (hf a H) = y :=\nbegin\n  cases x,\n  { simp only [not_mem_none, exists_false, pmap, not_false_iff, exists_prop_of_false] },\n  { split,\n    { intro h,\n      simp only [pmap] at h,\n      exact ⟨x, rfl, h⟩ },\n    { rintro ⟨a, H, rfl⟩,\n      simp only [mem_def] at H,\n      simp only [H, pmap] } }\nend\n\n@[simp] lemma join_pmap_eq_pmap_join {f : Π a, p a → β} {x : option (option α)} (H) :\n  (pmap (pmap f) x H).join = pmap f x.join (λ a h, H (some a) (mem_of_mem_join h) _ rfl) :=\nby { rcases x with _ | _ | x; simp }\n\nend pmap\n\n@[simp] theorem seq_some {α β} {a : α} {f : α → β} : some f <*> some a = some (f a) := rfl\n\n@[simp] theorem some_orelse' (a : α) (x : option α) : (some a).orelse x = some a := rfl\n\n@[simp] theorem some_orelse (a : α) (x : option α) : (some a <|> x) = some a := rfl\n\n@[simp] theorem none_orelse' (x : option α) : none.orelse x = x :=\nby cases x; refl\n\n@[simp] theorem none_orelse (x : option α) : (none <|> x) = x := none_orelse' x\n\n@[simp] theorem orelse_none' (x : option α) : x.orelse none = x :=\nby cases x; refl\n\n@[simp] theorem orelse_none (x : option α) : (x <|> none) = x := orelse_none' x\n\n@[simp] theorem is_some_none : @is_some α none = ff := rfl\n\n@[simp] theorem is_some_some {a : α} : is_some (some a) = tt := rfl\n\ntheorem is_some_iff_exists {x : option α} : is_some x ↔ ∃ a, x = some a :=\nby cases x; simp [is_some]; exact ⟨_, rfl⟩\n\n@[simp] theorem is_none_none : @is_none α none = tt := rfl\n\n@[simp] theorem is_none_some {a : α} : is_none (some a) = ff := rfl\n\n@[simp] theorem not_is_some {a : option α} : is_some a = ff ↔ a.is_none = tt :=\nby cases a; simp\n\nlemma eq_some_iff_get_eq {o : option α} {a : α} :\n  o = some a ↔ ∃ h : o.is_some, option.get h = a :=\nby cases o; simp\n\nlemma not_is_some_iff_eq_none {o : option α} :  ¬o.is_some ↔ o = none :=\nby cases o; simp\n\nlemma ne_none_iff_is_some {o : option α} : o ≠ none ↔ o.is_some :=\nby cases o; simp\n\nlemma ne_none_iff_exists {o : option α} : o ≠ none ↔ ∃ (x : α), some x = o :=\nby {cases o; simp}\n\nlemma ne_none_iff_exists' {o : option α} : o ≠ none ↔ ∃ (x : α), o = some x :=\nne_none_iff_exists.trans $ exists_congr $ λ _, eq_comm\n\nlemma bex_ne_none {p : option α → Prop} :\n  (∃ x ≠ none, p x) ↔ ∃ x, p (some x) :=\n⟨λ ⟨x, hx, hp⟩, ⟨get $ ne_none_iff_is_some.1 hx, by rwa [some_get]⟩,\n  λ ⟨x, hx⟩, ⟨some x, some_ne_none x, hx⟩⟩\n\nlemma ball_ne_none {p : option α → Prop} :\n  (∀ x ≠ none, p x) ↔ ∀ x, p (some x) :=\n⟨λ h x, h (some x) (some_ne_none x),\n  λ h x hx, by simpa only [some_get] using h (get $ ne_none_iff_is_some.1 hx)⟩\n\ntheorem iget_mem [inhabited α] : ∀ {o : option α}, is_some o → o.iget ∈ o\n| (some a) _ := rfl\n\ntheorem iget_of_mem [inhabited α] {a : α} : ∀ {o : option α}, a ∈ o → o.iget = a\n| _ rfl := rfl\n\n@[simp] theorem guard_eq_some {p : α → Prop} [decidable_pred p] {a b : α} :\n  guard p a = some b ↔ a = b ∧ p a :=\nby by_cases p a; simp [option.guard, h]; intro; contradiction\n\n@[simp] theorem guard_eq_some' {p : Prop} [decidable p] :\n  ∀ u, _root_.guard p = some u ↔ p\n| () := by by_cases p; simp [guard, h, pure]; intro; contradiction\n\ntheorem lift_or_get_choice {f : α → α → α} (h : ∀ a b, f a b = a ∨ f a b = b) :\n  ∀ o₁ o₂, lift_or_get f o₁ o₂ = o₁ ∨ lift_or_get f o₁ o₂ = o₂\n| none     none     := or.inl rfl\n| (some a) none     := or.inl rfl\n| none     (some b) := or.inr rfl\n| (some a) (some b) := by simpa [lift_or_get] using h a b\n\n@[simp] lemma lift_or_get_none_left {f} {b : option α} : lift_or_get f none b = b :=\nby cases b; refl\n\n@[simp] lemma lift_or_get_none_right {f} {a : option α} : lift_or_get f a none = a :=\nby cases a; refl\n\n@[simp] lemma lift_or_get_some_some {f} {a b : α} :\n  lift_or_get f (some a) (some b) = f a b := rfl\n\n/-- given an element of `a : option α`, a default element `b : β` and a function `α → β`, apply this\nfunction to `a` if it comes from `α`, and return `b` otherwise. -/\ndef cases_on' : option α → β → (α → β) → β\n| none     n s := n\n| (some a) n s := s a\n\n@[simp] lemma cases_on'_none (x : β) (f : α → β) : cases_on' none x f = x := rfl\n\n@[simp] lemma cases_on'_some (x : β) (f : α → β) (a : α) : cases_on' (some a) x f = f a := rfl\n\n@[simp] lemma cases_on'_coe (x : β) (f : α → β) (a : α) : cases_on' (a : option α) x f = f a := rfl\n\n@[simp] lemma cases_on'_none_coe (f : option α → β) (o : option α) :\n  cases_on' o (f none) (f ∘ coe) = f o :=\nby cases o; refl\n\nsection\nopen_locale classical\n\n/-- An arbitrary `some a` with `a : α` if `α` is nonempty, and otherwise `none`. -/\nnoncomputable def choice (α : Type*) : option α :=\nif h : nonempty α then\n  some h.some\nelse\n  none\n\nlemma choice_eq {α : Type*} [subsingleton α] (a : α) : choice α = some a :=\nbegin\n  dsimp [choice],\n  rw dif_pos (⟨a⟩ : nonempty α),\n  congr,\nend\n\nlemma choice_eq_none {α : Type*} (h : α → false) : choice α = none :=\nbegin\n  dsimp [choice],\n  rw dif_neg (not_nonempty_iff_imp_false.mpr h),\nend\n\nlemma choice_is_some_iff_nonempty {α : Type*} : (choice α).is_some ↔ nonempty α :=\nbegin\n  fsplit,\n  { intro h, exact ⟨option.get h⟩, },\n  { rintro ⟨a⟩,\n    dsimp [choice],\n    rw dif_pos,\n    fsplit,\n    exact ⟨a⟩, },\nend\n\nend\n\nend option\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/option/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.4623298507072146}}
{"text": "structure Pos where\n  protected succ :: protected pred : Nat\n  deriving Repr\n\nprotected def Pos.add : Pos → Pos → Pos\n  | .succ x, .succ y => .succ (x + y).succ\n\ninstance : Add Pos := ⟨Pos.add⟩\n\ninstance (x : Nat) : OfNat Pos x.succ := ⟨.succ x⟩\n\n/-- View for `Pos` type. -/\ninductive PosView where\n  | one\n  | succ (x : Pos)\n\n/--\n  Convert `Pos` into `PosView`.\n  Remark: nonrecursive views do not impact performance of the generated code if marked as `[inline]`\n -/\n@[inline] def Pos.view (p : Pos) : PosView :=\n  match p with\n  | { pred := 0 }          => PosView.one\n  | { pred := Nat.succ n } => PosView.succ ⟨n⟩\n\n/--\n  Helper theorem for proving termination.\n  In the future, we should be able to mark it as a forward reasoning theorem for `decreasing_tactic`,\n  and it will be applied automatically for us. -/\ntheorem sizeof_lt_of_view_eq (h : Pos.view p₁ = PosView.succ p₂) : sizeOf p₂ < sizeOf p₁ := by\n  match p₁, p₂ with\n  | { pred := Nat.succ n }, { pred := Nat.succ m } => simp [Pos.view] at h; simp_arith [h]\n  | { pred := Nat.succ n }, { pred := 0 }          => simp [Pos.view] at h; simp_arith [h]\n  | { pred := 0 },          _                      => simp [Pos.view] at h\n\n/-- `1` as notation for `PosView.one` -/\ninstance : OfNat PosView (nat_lit 1) where\n  ofNat := PosView.one\n\ndef f (p : Pos) : Pos :=\n  match h : p.view with -- It would also be nice to have a feature to force Lean to applies \"views\" automatically for us.\n  | 1 => 1\n  | .succ x =>\n    have : sizeOf x < sizeOf p := sizeof_lt_of_view_eq h -- See comment at `sizeof_lt_of_view_eq`\n    f x + x + 1\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/posView.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.4623298492694978}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.images\nimport Mathlib.category_theory.limits.shapes.kernels\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# The morphism from `image f` to `kernel g` when `f ≫ g = 0`\n\nWe define the map, as the lift of `image.ι f` to `kernel g`,\nand check some basic properties:\n\n* this map is a monomorphism\n* given `A --0--> B --g--> C`, where `[mono g]`, this map is an epimorphism\n* given `A --f--> B --0--> C`, where `[epi f]`, this map is an epimorphism\n\nIn later files, we define the homology of complex as the cokernel of this map,\nand say a complex is exact at a point if this map is an epimorphism.\n-/\n\nnamespace category_theory\n\n\n/-!\nAt this point we assume that we have all images, and all equalizers.\nWe need to assume all equalizers, not just kernels, so that\n`factor_thru_image` is an epimorphism.\n-/\n\n/--\nThe morphism from `image f` to `kernel g` when `f ≫ g = 0`.\n-/\ndef image_to_kernel_map {V : Type u} [category V] [limits.has_zero_morphisms V]\n    [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C)\n    (w : f ≫ g = 0) : limits.image f ⟶ limits.kernel g :=\n  limits.kernel.lift g (limits.image.ι f) sorry\n\n@[simp] theorem image_to_kernel_map_zero_left {V : Type u} [category V]\n    [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V}\n    {C : V} (g : B ⟶ C) [limits.has_zero_object V] {w : 0 ≫ g = 0} :\n    image_to_kernel_map 0 g w = 0 :=\n  sorry\n\ntheorem image_to_kernel_map_zero_right {V : Type u} [category V] [limits.has_zero_morphisms V]\n    [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B)\n    {w : f ≫ 0 = 0} : image_to_kernel_map f 0 w = limits.image.ι f ≫ inv (limits.kernel.ι 0) :=\n  sorry\n\ntheorem image_to_kernel_map_comp_right {V : Type u} [category V] [limits.has_zero_morphisms V]\n    [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C)\n    {D : V} (h : C ⟶ D) (w : f ≫ g = 0) :\n    image_to_kernel_map f (g ≫ h)\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : A ⟶ D) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ D) (e_2 : ᾰ = ᾰ_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (f ≫ g ≫ h) 0 (Eq.trans (reassoc_of w D h) limits.zero_comp) 0 0 (Eq.refl 0))\n                (propext (eq_self_iff_true 0))))\n            trivial) =\n        image_to_kernel_map f g w ≫\n          limits.kernel.lift (g ≫ h) (limits.kernel.ι g)\n            (eq.mpr\n              (id\n                (Eq.trans\n                  ((fun (a a_1 : limits.kernel g ⟶ D) (e_1 : a = a_1) (ᾰ ᾰ_1 : limits.kernel g ⟶ D)\n                      (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n                    (limits.kernel.ι g ≫ g ≫ h) 0\n                    (Eq.trans (limits.kernel.condition_assoc g h) limits.zero_comp) 0 0 (Eq.refl 0))\n                  (propext (eq_self_iff_true 0))))\n              trivial) :=\n  sorry\n\ntheorem image_to_kernel_map_comp_left {V : Type u} [category V] [limits.has_zero_morphisms V]\n    [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C)\n    {Z : V} (h : Z ⟶ A) (w : f ≫ g = 0) :\n    image_to_kernel_map (h ≫ f) g\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : Z ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : Z ⟶ C) (e_2 : ᾰ = ᾰ_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  ((h ≫ f) ≫ g) 0\n                  (Eq.trans\n                    (Eq.trans (category.assoc h f g)\n                      ((fun (ᾰ ᾰ_1 : Z ⟶ A) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : A ⟶ C) (e_2 : ᾰ_2 = ᾰ_3) =>\n                          congr (congr_arg category_struct.comp e_1) e_2)\n                        h h (Eq.refl h) (f ≫ g) 0 w))\n                    limits.comp_zero)\n                  0 0 (Eq.refl 0))\n                (propext (eq_self_iff_true 0))))\n            trivial) =\n        limits.image.pre_comp h f ≫ image_to_kernel_map f g w :=\n  sorry\n\n@[simp] theorem image_to_kernel_map_comp_iso {V : Type u} [category V] [limits.has_zero_morphisms V]\n    [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C)\n    {D : V} (h : C ⟶ D) [is_iso h] (w : f ≫ g ≫ h = 0) :\n    image_to_kernel_map f (g ≫ h) w =\n        image_to_kernel_map f g\n            (iff.mp (cancel_mono h)\n              (eq.mpr\n                (id\n                  ((fun (a a_1 : A ⟶ D) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ D) (e_2 : ᾰ = ᾰ_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    ((f ≫ g) ≫ h) (f ≫ g ≫ h) (category.assoc f g h) (0 ≫ h) 0 limits.zero_comp))\n                (eq.mp (Eq.refl (f ≫ g ≫ h = 0)) w))) ≫\n          iso.inv (limits.kernel_comp_is_iso g h) :=\n  sorry\n\n@[simp] theorem image_to_kernel_map_iso_comp {V : Type u} [category V] [limits.has_zero_morphisms V]\n    [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C)\n    {Z : V} (h : Z ⟶ A) [is_iso h] (w : (h ≫ f) ≫ g = 0) :\n    image_to_kernel_map (h ≫ f) g w =\n        limits.image.pre_comp h f ≫\n          image_to_kernel_map f g\n            (iff.mp (cancel_epi h)\n              (eq.mpr\n                (id\n                  ((fun (a a_1 : Z ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : Z ⟶ C) (e_2 : ᾰ = ᾰ_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    (h ≫ f ≫ g) (h ≫ f ≫ g) (Eq.refl (h ≫ f ≫ g)) (h ≫ 0) 0 limits.comp_zero))\n                (eq.mp\n                  ((fun (a a_1 : Z ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : Z ⟶ C) (e_2 : ᾰ = ᾰ_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    ((h ≫ f) ≫ g) (h ≫ f ≫ g) (category.assoc h f g) 0 0 (Eq.refl 0))\n                  w))) :=\n  sorry\n\n@[simp] theorem image_to_kernel_map_comp_hom_inv_comp {V : Type u} [category V]\n    [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V}\n    {C : V} (f : A ⟶ B) (g : B ⟶ C) {Z : V} {i : B ≅ Z} (w : (f ≫ iso.hom i) ≫ iso.inv i ≫ g = 0) :\n    image_to_kernel_map (f ≫ iso.hom i) (iso.inv i ≫ g) w =\n        iso.inv (limits.image.post_comp_is_iso f (iso.hom i)) ≫\n          image_to_kernel_map f g\n              (eq.mpr (id (Eq.refl (f ≫ g = 0)))\n                (eq.mp\n                  ((fun (a a_1 : A ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ C) (e_2 : ᾰ = ᾰ_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    ((f ≫ iso.hom i) ≫ iso.inv i ≫ g) (f ≫ g)\n                    (Eq.trans (category.assoc f (iso.hom i) (iso.inv i ≫ g))\n                      ((fun (ᾰ ᾰ_1 : A ⟶ B) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : B ⟶ C) (e_2 : ᾰ_2 = ᾰ_3) =>\n                          congr (congr_arg category_struct.comp e_1) e_2)\n                        f f (Eq.refl f) (iso.hom i ≫ iso.inv i ≫ g) g (iso.hom_inv_id_assoc i g)))\n                    0 0 (Eq.refl 0))\n                  w)) ≫\n            iso.inv (limits.kernel_is_iso_comp (iso.inv i) g) :=\n  sorry\n\n/--\n`image_to_kernel_map` for `A --0--> B --g--> C`, where `[mono g]` is an epi\n(i.e. the sequence is exact at `B`).\n-/\ntheorem image_to_kernel_map_epi_of_zero_of_mono {V : Type u} [category V]\n    [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V}\n    {C : V} (g : B ⟶ C) [mono g] [limits.has_zero_object V] :\n    epi\n        (image_to_kernel_map 0 g\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : A ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ C) (e_2 : ᾰ = ᾰ_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (0 ≫ g) 0 limits.zero_comp 0 0 (Eq.refl 0))\n                (propext (eq_self_iff_true 0))))\n            trivial)) :=\n  sorry\n\n/--\n`image_to_kernel_map` for `A --f--> B --0--> C`, where `[epi g]` is an epi\n(i.e. the sequence is exact at `B`).\n-/\ntheorem image_to_kernel_map_epi_of_epi_of_zero {V : Type u} [category V]\n    [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V}\n    {C : V} (f : A ⟶ B) [epi f] :\n    epi\n        (image_to_kernel_map f 0\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : A ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ C) (e_2 : ᾰ = ᾰ_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (f ≫ 0) 0 limits.comp_zero 0 0 (Eq.refl 0))\n                (propext (eq_self_iff_true 0))))\n            trivial)) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/homology/image_to_kernel_map_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4623298390671944}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes Hölzl\n\nLinear structures on function with finite support `ι →₀ β`.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.mv_polynomial.default\nimport Mathlib.linear_algebra.dimension\nimport Mathlib.linear_algebra.direct_sum.finsupp\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 u v w \n\nnamespace Mathlib\n\nnamespace finsupp\n\n\ntheorem linear_independent_single {R : Type u_1} {M : Type u_2} {ι : Type u_3} [ring R]\n    [add_comm_group M] [module R M] {φ : ι → Type u_4} {f : (ι : ι) → φ ι → M}\n    (hf : ∀ (i : ι), linear_independent R (f i)) :\n    linear_independent R\n        fun (ix : sigma fun (i : ι) => φ i) =>\n          single (sigma.fst ix) (f (sigma.fst ix) (sigma.snd ix)) :=\n  sorry\n\ntheorem is_basis_single {R : Type u_1} {M : Type u_2} {ι : Type u_3} [ring R] [add_comm_group M]\n    [module R M] {φ : ι → Type u_4} (f : (ι : ι) → φ ι → M) (hf : ∀ (i : ι), is_basis R (f i)) :\n    is_basis R\n        fun (ix : sigma fun (i : ι) => φ i) =>\n          single (sigma.fst ix) (f (sigma.fst ix) (sigma.snd ix)) :=\n  sorry\n\ntheorem is_basis_single_one {R : Type u_1} {ι : Type u_3} [ring R] :\n    is_basis R fun (i : ι) => single i 1 :=\n  sorry\n\n/-- If b : ι → M and c : κ → N are bases then so is λ i, b i.1 ⊗ₜ c i.2 : ι × κ → M ⊗ N. -/\ntheorem is_basis.tensor_product {R : Type u_1} {M : Type u_2} {N : Type u_3} {ι : Type u_4}\n    {κ : Type u_5} [comm_ring R] [add_comm_group M] [module R M] [add_comm_group N] [module R N]\n    {b : ι → M} (hb : is_basis R b) {c : κ → N} (hc : is_basis R c) :\n    is_basis R fun (i : ι × κ) => tensor_product.tmul R (b (prod.fst i)) (c (prod.snd i)) :=\n  sorry\n\ntheorem dim_eq {K : Type u} {V : Type v} {ι : Type v} [field K] [add_comm_group V]\n    [vector_space K V] : vector_space.dim K (ι →₀ V) = cardinal.mk ι * vector_space.dim K V :=\n  sorry\n\nend finsupp\n\n\n/- We use `universe variables` instead of `universes` here because universes introduced by the\n   `universes` keyword do not get replaced by metavariables once a lemma has been proven. So if you\n   prove a lemma using universe `u`, you can only apply it to universe `u` in other lemmas of the\n   same section. -/\n\ntheorem equiv_of_dim_eq_lift_dim {K : Type u} {V : Type v} {V' : Type w} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V']\n    (h : cardinal.lift (vector_space.dim K V) = cardinal.lift (vector_space.dim K V')) :\n    Nonempty (linear_equiv K V V') :=\n  sorry\n\n/-- Two `K`-vector spaces are equivalent if their dimension is the same. -/\ndef equiv_of_dim_eq_dim {K : Type u} {V₁ : Type v} {V₂ : Type v} [field K] [add_comm_group V₁]\n    [vector_space K V₁] [add_comm_group V₂] [vector_space K V₂]\n    (h : vector_space.dim K V₁ = vector_space.dim K V₂) : linear_equiv K V₁ V₂ :=\n  Classical.choice sorry\n\n/-- An `n`-dimensional `K`-vector space is equivalent to `fin n → K`. -/\ndef fin_dim_vectorspace_equiv {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (n : ℕ) (hn : vector_space.dim K V = ↑n) : linear_equiv K V (fin n → K) :=\n  Classical.choice sorry\n\ntheorem eq_bot_iff_dim_eq_zero {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (p : submodule K V) (h : vector_space.dim K ↥p = 0) : p = ⊥ :=\n  let e : linear_equiv K ↥p ↥⊥ :=\n    equiv_of_dim_eq_dim\n      (eq.mpr (id (Eq._oldrec (Eq.refl (vector_space.dim K ↥p = vector_space.dim K ↥⊥)) dim_bot))\n        h);\n  linear_equiv.eq_bot_of_equiv p e\n\ntheorem injective_of_surjective {K : Type u} {V₁ : Type v} {V₂ : Type v} [field K]\n    [add_comm_group V₁] [vector_space K V₁] [add_comm_group V₂] [vector_space K V₂]\n    (f : linear_map K V₁ V₂) (hV₁ : vector_space.dim K V₁ < cardinal.omega)\n    (heq : vector_space.dim K V₂ = vector_space.dim K V₁) (hf : linear_map.range f = ⊤) :\n    linear_map.ker f = ⊥ :=\n  sorry\n\ntheorem cardinal_mk_eq_cardinal_mk_field_pow_dim {K : Type u} {V : Type u} [field K]\n    [add_comm_group V] [vector_space K V] (h : vector_space.dim K V < cardinal.omega) :\n    cardinal.mk V = cardinal.mk K ^ vector_space.dim K V :=\n  sorry\n\ntheorem cardinal_lt_omega_of_dim_lt_omega {K : Type u} {V : Type u} [field K] [add_comm_group V]\n    [vector_space K V] [fintype K] (h : vector_space.dim K V < cardinal.omega) :\n    cardinal.mk V < cardinal.omega :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (cardinal.mk V < cardinal.omega))\n        (cardinal_mk_eq_cardinal_mk_field_pow_dim h)))\n    (cardinal.power_lt_omega (iff.mpr cardinal.lt_omega_iff_fintype (Nonempty.intro infer_instance))\n      h)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/finsupp_vector_space_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119538534297, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4623298390671943}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nA data type for semiquotients, which are classically equivalent to\nnonempty sets, but are useful for programming; the idea is that\na semiquotient set `S` represents some (particular but unknown)\nelement of `S`. This can be used to model nondeterministic functions,\nwhich return something in a range of values (represented by the\npredicate `S`) but are not completely determined.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.set.lattice\nimport Mathlib.PostPort\n\nuniverses u u_1 l u_2 u_3 u_4 u_5 \n\nnamespace Mathlib\n\n/-- A member of `semiquot α` is classically a nonempty `set α`,\n  and in the VM is represented by an element of `α`; the relation\n  between these is that the VM element is required to be a member\n  of the set `s`. The specific element of `s` that the VM computes\n  is hidden by a quotient construction, allowing for the representation\n  of nondeterministic functions. -/\nstructure semiquot (α : Type u_1) where\n  mk' :: (s : set α) (val : trunc ↥s)\n\nnamespace semiquot\n\n\nprotected instance has_mem {α : Type u_1} : has_mem α (semiquot α) :=\n  has_mem.mk fun (a : α) (q : semiquot α) => a ∈ s q\n\n/-- Construct a `semiquot α` from `h : a ∈ s` where `s : set α`. -/\ndef mk {α : Type u_1} {a : α} {s : set α} (h : a ∈ s) : semiquot α :=\n  mk' s (trunc.mk { val := a, property := h })\n\ntheorem ext_s {α : Type u_1} {q₁ : semiquot α} {q₂ : semiquot α} : q₁ = q₂ ↔ s q₁ = s q₂ := sorry\n\ntheorem ext {α : Type u_1} {q₁ : semiquot α} {q₂ : semiquot α} :\n    q₁ = q₂ ↔ ∀ (a : α), a ∈ q₁ ↔ a ∈ q₂ :=\n  iff.trans ext_s set.ext_iff\n\ntheorem exists_mem {α : Type u_1} (q : semiquot α) : ∃ (a : α), a ∈ q := sorry\n\ntheorem eq_mk_of_mem {α : Type u_1} {q : semiquot α} {a : α} (h : a ∈ q) : q = mk h :=\n  iff.mpr ext_s rfl\n\ntheorem nonempty {α : Type u_1} (q : semiquot α) : set.nonempty (s q) := exists_mem q\n\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure {α : Type u_1} (a : α) : semiquot α := mk (set.mem_singleton a)\n\n@[simp] theorem mem_pure' {α : Type u_1} {a : α} {b : α} : a ∈ semiquot.pure b ↔ a = b :=\n  set.mem_singleton_iff\n\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' {α : Type u_1} (q : semiquot α) {s : set α} (h : s q ⊆ s) : semiquot α :=\n  mk' s\n    (trunc.lift (fun (a : ↥(s q)) => trunc.mk { val := subtype.val a, property := sorry }) sorry\n      (val q))\n\n/-- Replace `s` in a `q : semiquot α` with a union `s ∪ q.s` -/\ndef blur {α : Type u_1} (s : set α) (q : semiquot α) : semiquot α := blur' q sorry\n\ntheorem blur_eq_blur' {α : Type u_1} (q : semiquot α) (s : set α) (h : s q ⊆ s) :\n    blur s q = blur' q h :=\n  sorry\n\n@[simp] theorem mem_blur' {α : Type u_1} (q : semiquot α) {s : set α} (h : s q ⊆ s) {a : α} :\n    a ∈ blur' q h ↔ a ∈ s :=\n  iff.rfl\n\n/-- Convert a `trunc α` to a `semiquot α`. -/\ndef of_trunc {α : Type u_1} (q : trunc α) : semiquot α :=\n  mk' set.univ (trunc.map (fun (a : α) => { val := a, property := trivial }) q)\n\n/-- Convert a `semiquot α` to a `trunc α`. -/\ndef to_trunc {α : Type u_1} (q : semiquot α) : trunc α := trunc.map subtype.val (val q)\n\n/-- If `f` is a constant on `q.s`, then `q.lift_on f` is the value of `f`\nat any point of `q`. -/\ndef lift_on {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → β)\n    (h : ∀ (a b : α), a ∈ q → b ∈ q → f a = f b) : β :=\n  trunc.lift_on (val q) (fun (x : ↥(s q)) => f (subtype.val x)) sorry\n\ntheorem lift_on_of_mem {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → β)\n    (h : ∀ (a b : α), a ∈ q → b ∈ q → f a = f b) (a : α) (aq : a ∈ q) : lift_on q f h = f a :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (∀ (h : ∀ (a b : α), a ∈ q → b ∈ q → f a = f b), lift_on q f h = f a))\n        (eq_mk_of_mem aq)))\n    (fun (h : ∀ (a_1 b : α), a_1 ∈ mk aq → b ∈ mk aq → f a_1 = f b) =>\n      Eq.refl (lift_on (mk aq) f h))\n    h\n\ndef map {α : Type u_1} {β : Type u_2} (f : α → β) (q : semiquot α) : semiquot β :=\n  mk' (f '' s q)\n    (trunc.map (fun (x : ↥(s q)) => { val := f (subtype.val x), property := sorry }) (val q))\n\n@[simp] theorem mem_map {α : Type u_1} {β : Type u_2} (f : α → β) (q : semiquot α) (b : β) :\n    b ∈ map f q ↔ ∃ (a : α), a ∈ q ∧ f a = b :=\n  set.mem_image (fun (a : α) => f a) (s q) b\n\ndef bind {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → semiquot β) : semiquot β :=\n  mk' (set.Union fun (a : α) => set.Union fun (H : a ∈ s q) => s (f a))\n    (trunc.bind (val q)\n      fun (a : ↥(s q)) =>\n        trunc.map\n          (fun (b : ↥(s (f (subtype.val a)))) => { val := subtype.val b, property := sorry })\n          (val (f (subtype.val a))))\n\n@[simp] theorem mem_bind {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → semiquot β)\n    (b : β) : b ∈ bind q f ↔ ∃ (a : α), ∃ (H : a ∈ q), b ∈ f a :=\n  set.mem_bUnion_iff\n\nprotected instance monad : Monad semiquot :=\n  { toApplicative :=\n      { toFunctor := { map := map, mapConst := fun (α β : Type u_1) => map ∘ function.const β },\n        toPure := { pure := semiquot.pure },\n        toSeq :=\n          { seq :=\n              fun (α β : Type u_1) (f : semiquot (α → β)) (x : semiquot α) =>\n                bind f fun (_x : α → β) => map _x x },\n        toSeqLeft :=\n          { seqLeft :=\n              fun (α β : Type u_1) (a : semiquot α) (b : semiquot β) =>\n                (fun (α β : Type u_1) (f : semiquot (α → β)) (x : semiquot α) =>\n                    bind f fun (_x : α → β) => map _x x)\n                  β α (map (function.const β) a) b },\n        toSeqRight :=\n          { seqRight :=\n              fun (α β : Type u_1) (a : semiquot α) (b : semiquot β) =>\n                (fun (α β : Type u_1) (f : semiquot (α → β)) (x : semiquot α) =>\n                    bind f fun (_x : α → β) => map _x x)\n                  β β (map (function.const α id) a) b } },\n    toBind := { bind := bind } }\n\n@[simp] theorem map_def {α : Type u_1} {β : Type u_1} : Functor.map = map := rfl\n\n@[simp] theorem bind_def {α : Type u_1} {β : Type u_1} : bind = bind := rfl\n\n@[simp] theorem mem_pure {α : Type u_1} {a : α} {b : α} : a ∈ pure b ↔ a = b :=\n  set.mem_singleton_iff\n\ntheorem mem_pure_self {α : Type u_1} (a : α) : a ∈ pure a := set.mem_singleton a\n\n@[simp] theorem pure_inj {α : Type u_1} {a : α} {b : α} : pure a = pure b ↔ a = b :=\n  iff.trans ext_s set.singleton_eq_singleton_iff\n\nprotected instance is_lawful_monad : is_lawful_monad semiquot := sorry\n\nprotected instance has_le {α : Type u_1} : HasLessEq (semiquot α) :=\n  { LessEq := fun (s t : semiquot α) => s s ⊆ s t }\n\nprotected instance partial_order {α : Type u_1} : partial_order (semiquot α) :=\n  partial_order.mk (fun (s t : semiquot α) => ∀ {x : α}, x ∈ s → x ∈ t)\n    (preorder.lt._default fun (s t : semiquot α) => ∀ {x : α}, x ∈ s → x ∈ t) sorry sorry sorry\n\nprotected instance semilattice_sup {α : Type u_1} : semilattice_sup (semiquot α) :=\n  semilattice_sup.mk (fun (s : semiquot α) => blur (s s)) partial_order.le partial_order.lt sorry\n    sorry sorry sorry sorry sorry\n\n@[simp] theorem pure_le {α : Type u_1} {a : α} {s : semiquot α} : pure a ≤ s ↔ a ∈ s :=\n  set.singleton_subset_iff\n\ndef is_pure {α : Type u_1} (q : semiquot α) := ∀ (a b : α), a ∈ q → b ∈ q → a = b\n\ndef get {α : Type u_1} (q : semiquot α) (h : is_pure q) : α := lift_on q id h\n\ntheorem get_mem {α : Type u_1} {q : semiquot α} (p : is_pure q) : get q p ∈ q := sorry\n\ntheorem eq_pure {α : Type u_1} {q : semiquot α} (p : is_pure q) : q = pure (get q p) := sorry\n\n@[simp] theorem pure_is_pure {α : Type u_1} (a : α) : is_pure (pure a) :=\n  fun (a_1 b : α) (H : a_1 ∈ pure a) (H_1 : b ∈ pure a) =>\n    idRhs (a_1 = b)\n      (of_eq_true\n        (eq_true_intro\n          (Eq.trans (eq.mp (propext mem_pure) H) (Eq.symm (eq.mp (propext mem_pure) H_1)))))\n\ntheorem is_pure_iff {α : Type u_1} {s : semiquot α} : is_pure s ↔ ∃ (a : α), s = pure a := sorry\n\ntheorem is_pure.mono {α : Type u_1} {s : semiquot α} {t : semiquot α} (st : s ≤ t) (h : is_pure t) :\n    is_pure s :=\n  fun (a b : α) (H : a ∈ s) (H_1 : b ∈ s) => idRhs (a = b) (h a b (st H) (st H_1))\n\ntheorem is_pure.min {α : Type u_1} {s : semiquot α} {t : semiquot α} (h : is_pure t) :\n    s ≤ t ↔ s = t :=\n  sorry\n\ntheorem is_pure_of_subsingleton {α : Type u_1} [subsingleton α] (q : semiquot α) : is_pure q :=\n  fun (a b : α) (H : a ∈ q) (H : b ∈ q) => idRhs (a = b) (subsingleton.elim a b)\n\n/-- `univ : semiquot α` represents an unspecified element of `univ : set α`. -/\ndef univ {α : Type u_1} [Inhabited α] : semiquot α := mk sorry\n\nprotected instance inhabited {α : Type u_1} [Inhabited α] : Inhabited (semiquot α) :=\n  { default := univ }\n\n@[simp] theorem mem_univ {α : Type u_1} [Inhabited α] (a : α) : a ∈ univ := set.mem_univ\n\ntheorem univ_unique {α : Type u_1} (I : Inhabited α) (J : Inhabited α) : univ = univ := sorry\n\n@[simp] theorem is_pure_univ {α : Type u_1} [Inhabited α] : is_pure univ ↔ subsingleton α := sorry\n\nprotected instance order_top {α : Type u_1} [Inhabited α] : order_top (semiquot α) :=\n  order_top.mk univ partial_order.le partial_order.lt sorry sorry sorry sorry\n\nprotected instance semilattice_sup_top {α : Type u_1} [Inhabited α] :\n    semilattice_sup_top (semiquot α) :=\n  semilattice_sup_top.mk order_top.top order_top.le order_top.lt sorry sorry sorry sorry\n    semilattice_sup.sup sorry sorry sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/semiquot_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4623298368414765}}
{"text": "/-\nCopyright (c) 2021 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Aaron Anderson\n-/\nimport data.set_like.basic\nimport model_theory.semantics\n\n/-!\n# Definable Sets\nThis file defines what it means for a set over a first-order structure to be definable.\n\n## Main Definitions\n* `set.definable` is defined so that `A.definable L s` indicates that the\nset `s` of a finite cartesian power of `M` is definable with parameters in `A`.\n* `set.definable₁` is defined so that `A.definable₁ L s` indicates that\n`(s : set M)` is definable with parameters in `A`.\n* `set.definable₂` is defined so that `A.definable₂ L s` indicates that\n`(s : set (M × M))` is definable with parameters in `A`.\n* A `first_order.language.definable_set` is defined so that `L.definable_set A α` is the boolean\n  algebra of subsets of `α → M` defined by formulas with parameters in `A`.\n\n## Main Results\n* `L.definable_set A α` forms a `boolean_algebra`\n* `set.definable.image_comp` shows that definability is closed under projections in finite\n  dimensions.\n\n-/\n\nuniverses u v w\n\nnamespace set\n\nvariables {M : Type w} (A : set M) (L : first_order.language.{u v}) [L.Structure M]\nopen_locale first_order\nopen first_order.language first_order.language.Structure\n\nvariables {α : Type*} {β : Type*}\n\n/-- A subset of a finite Cartesian product of a structure is definable over a set `A` when\n  membership in the set is given by a first-order formula with parameters from `A`. -/\ndef definable (s : set (α → M)) : Prop :=\n∃ (φ : L[[A]].formula α), s = set_of φ.realize\n\nvariables {L} {A} {B : set M} {s : set (α → M)}\n\nlemma definable.map_expansion {L' : first_order.language} [L'.Structure M] (h : A.definable L s)\n  (φ : L →ᴸ L') [φ.is_expansion_on M] :\n  A.definable L' s :=\nbegin\n  obtain ⟨ψ, rfl⟩ := h,\n  refine ⟨(φ.add_constants A).on_formula ψ, _⟩,\n  ext x,\n  simp only [mem_set_of_eq, Lhom.realize_on_formula],\nend\n\nlemma empty_definable_iff :\n  (∅ : set M).definable L s ↔ ∃ (φ : L.formula α), s = set_of φ.realize :=\nbegin\n  rw [definable, equiv.exists_congr_left (Lequiv.add_empty_constants L (∅ : set M)).on_formula],\n  simp,\nend\n\nlemma definable_iff_empty_definable_with_params :\n  A.definable L s ↔ (∅ : set M).definable (L[[A]]) s :=\nempty_definable_iff.symm\n\nlemma definable.mono (hAs : A.definable L s) (hAB : A ⊆ B) :\n  B.definable L s :=\nbegin\n  rw [definable_iff_empty_definable_with_params] at *,\n  exact hAs.map_expansion (L.Lhom_with_constants_map (set.inclusion hAB)),\nend\n\n@[simp]\nlemma definable_empty : A.definable L (∅ : set (α → M)) :=\n⟨⊥, by {ext, simp} ⟩\n\n@[simp]\nlemma definable_univ : A.definable L (univ : set (α → M)) :=\n⟨⊤, by {ext, simp} ⟩\n\n@[simp]\nlemma definable.inter {f g : set (α → M)} (hf : A.definable L f) (hg : A.definable L g) :\n  A.definable L (f ∩ g) :=\nbegin\n  rcases hf with ⟨φ, rfl⟩,\n  rcases hg with ⟨θ, rfl⟩,\n  refine ⟨φ ⊓ θ, _⟩,\n  ext,\n  simp,\nend\n\n@[simp]\nlemma definable.union {f g : set (α → M)} (hf : A.definable L f) (hg : A.definable L g) :\n  A.definable L (f ∪ g) :=\nbegin\n  rcases hf with ⟨φ, hφ⟩,\n  rcases hg with ⟨θ, hθ⟩,\n  refine ⟨φ ⊔ θ, _⟩,\n  ext,\n  rw [hφ, hθ, mem_set_of_eq, formula.realize_sup, mem_union, mem_set_of_eq,\n    mem_set_of_eq],\nend\n\nlemma definable_finset_inf {ι : Type*} {f : Π (i : ι), set (α → M)}\n  (hf : ∀ i, A.definable L (f i)) (s : finset ι) :\n  A.definable L (s.inf f) :=\nbegin\n  classical,\n  refine finset.induction definable_univ (λ i s is h, _) s,\n  rw finset.inf_insert,\n  exact (hf i).inter h,\nend\n\nlemma definable_finset_sup {ι : Type*} {f : Π (i : ι), set (α → M)}\n  (hf : ∀ i, A.definable L (f i)) (s : finset ι) :\n  A.definable L (s.sup f) :=\nbegin\n  classical,\n  refine finset.induction definable_empty (λ i s is h, _) s,\n  rw finset.sup_insert,\n  exact (hf i).union h,\nend\n\nlemma definable_finset_bInter {ι : Type*} {f : Π (i : ι), set (α → M)}\n  (hf : ∀ i, A.definable L (f i)) (s : finset ι) :\n  A.definable L (⋂ i ∈ s, f i) :=\nbegin\n  rw ← finset.inf_set_eq_bInter,\n  exact definable_finset_inf hf s,\nend\n\nlemma definable_finset_bUnion {ι : Type*} {f : Π (i : ι), set (α → M)}\n  (hf : ∀ i, A.definable L (f i)) (s : finset ι) :\n  A.definable L (⋃ i ∈ s, f i) :=\nbegin\n  rw ← finset.sup_set_eq_bUnion,\n  exact definable_finset_sup hf s,\nend\n\n@[simp]\nlemma definable.compl {s : set (α → M)} (hf : A.definable L s) :\n  A.definable L sᶜ :=\nbegin\n  rcases hf with ⟨φ, hφ⟩,\n  refine ⟨φ.not, _⟩,\n  rw hφ,\n  refl,\nend\n\n@[simp]\nlemma definable.sdiff {s t : set (α → M)} (hs : A.definable L s)\n  (ht : A.definable L t) :\n  A.definable L (s \\ t) :=\nhs.inter ht.compl\n\nlemma definable.preimage_comp (f : α → β) {s : set (α → M)}\n  (h : A.definable L s) :\n  A.definable L ((λ g : β → M, g ∘ f) ⁻¹' s) :=\nbegin\n  obtain ⟨φ, rfl⟩ := h,\n  refine ⟨(φ.relabel f), _⟩,\n  ext,\n  simp only [set.preimage_set_of_eq, mem_set_of_eq, formula.realize_relabel],\nend\n\nlemma definable.image_comp_equiv {s : set (β → M)}\n  (h : A.definable L s) (f : α ≃ β) :\n  A.definable L ((λ g : β → M, g ∘ f) '' s) :=\nbegin\n  refine (congr rfl _).mp (h.preimage_comp f.symm),\n  rw image_eq_preimage_of_inverse,\n  { intro i,\n    ext b,\n    simp only [function.comp_app, equiv.apply_symm_apply], },\n  { intro i,\n    ext a,\n    simp }\nend\n\n/-- This lemma is only intended as a helper for `definable.image_comp. -/\nlemma definable.image_comp_sum_inl_fin (m : ℕ) {s : set ((α ⊕ fin m) → M)}\n  (h : A.definable L s) :\n  A.definable L ((λ g : (α ⊕ fin m) → M, g ∘ sum.inl) '' s) :=\nbegin\n  obtain ⟨φ, rfl⟩ := h,\n  refine ⟨(bounded_formula.relabel id φ).exs, _⟩,\n  ext x,\n  simp only [set.mem_image, mem_set_of_eq, bounded_formula.realize_exs,\n    bounded_formula.realize_relabel, function.comp.right_id, fin.cast_add_zero, fin.cast_refl],\n  split,\n  { rintro ⟨y, hy, rfl⟩,\n    exact ⟨y ∘ sum.inr,\n      (congr (congr rfl (sum.elim_comp_inl_inr y).symm) (funext fin_zero_elim)).mp hy⟩ },\n  { rintro ⟨y, hy⟩,\n    exact ⟨sum.elim x y, (congr rfl (funext fin_zero_elim)).mp hy, sum.elim_comp_inl _ _⟩, },\nend\n\n/-- Shows that definability is closed under finite projections. -/\nlemma definable.image_comp_embedding {s : set (β → M)} (h : A.definable L s)\n  (f : α ↪ β) [finite β] :\n  A.definable L ((λ g : β → M, g ∘ f) '' s) :=\nbegin\n  classical,\n  casesI nonempty_fintype β,\n  refine (congr rfl (ext (λ x, _))).mp (((h.image_comp_equiv\n    (equiv.set.sum_compl (range f))).image_comp_equiv (equiv.sum_congr\n    (equiv.of_injective f f.injective) (fintype.equiv_fin _).symm)).image_comp_sum_inl_fin _),\n  simp only [mem_preimage, mem_image, exists_exists_and_eq_and],\n  refine exists_congr (λ y, and_congr_right (λ ys, eq.congr_left (funext (λ a, _)))),\n  simp,\nend\n\n/-- Shows that definability is closed under finite projections. -/\nlemma definable.image_comp {s : set (β → M)} (h : A.definable L s)\n  (f : α → β) [finite α] [finite β] :\n  A.definable L ((λ g : β → M, g ∘ f) '' s) :=\nbegin\n  classical,\n  casesI nonempty_fintype α,\n  casesI nonempty_fintype β,\n  have h := (((h.image_comp_equiv (equiv.set.sum_compl (range f))).image_comp_equiv\n    (equiv.sum_congr (_root_.equiv.refl _)\n    (fintype.equiv_fin _).symm)).image_comp_sum_inl_fin _).preimage_comp (range_splitting f),\n  have h' : A.definable L ({ x : α → M |\n    ∀ a, x a = x (range_splitting f (range_factorization f a))}),\n  { have h' : ∀ a, A.definable L {x : α → M | x a =\n      x (range_splitting f (range_factorization f a))},\n    { refine λ a, ⟨(var a).equal (var (range_splitting f (range_factorization f a))), ext _⟩,\n      simp, },\n    refine (congr rfl (ext _)).mp (definable_finset_bInter h' finset.univ),\n    simp },\n  refine (congr rfl (ext (λ x, _))).mp (h.inter h'),\n  simp only [equiv.coe_trans, mem_inter_iff, mem_preimage, mem_image,\n    exists_exists_and_eq_and, mem_set_of_eq],\n  split,\n  { rintro ⟨⟨y, ys, hy⟩, hx⟩,\n    refine ⟨y, ys, _⟩,\n    ext a,\n    rw [hx a, ← function.comp_apply x, ← hy],\n    simp, },\n  { rintro ⟨y, ys, rfl⟩,\n    refine ⟨⟨y, ys, _⟩, λ a, _⟩,\n    { ext,\n      simp [set.apply_range_splitting f] },\n    { rw [function.comp_apply, function.comp_apply, apply_range_splitting f,\n        range_factorization_coe], }}\nend\n\nvariables (L) {M} (A)\n\n/-- A 1-dimensional version of `definable`, for `set M`. -/\ndef definable₁ (s : set M) : Prop := A.definable L { x : fin 1 → M | x 0 ∈ s }\n\n/-- A 2-dimensional version of `definable`, for `set (M × M)`. -/\ndef definable₂ (s : set (M × M)) : Prop := A.definable L { x : fin 2 → M | (x 0, x 1) ∈ s }\n\nend set\n\nnamespace first_order\nnamespace language\nopen set\n\nvariables (L : first_order.language.{u v}) {M : Type w} [L.Structure M] (A : set M) (α : Type*)\n\n/-- Definable sets are subsets of finite Cartesian products of a structure such that membership is\n  given by a first-order formula. -/\ndef definable_set := { s : set (α → M) // A.definable L s}\n\nnamespace definable_set\nvariables {L A α} {s t : L.definable_set A α} {x : α → M}\n\ninstance : set_like (L.definable_set A α) (α → M) :=\n{ coe := subtype.val,\n  coe_injective' := subtype.val_injective }\n\ninstance : has_top (L.definable_set A α) := ⟨⟨⊤, definable_univ⟩⟩\ninstance : has_bot (L.definable_set A α) := ⟨⟨⊥, definable_empty⟩⟩\ninstance : has_sup (L.definable_set A α) := ⟨λ s t, ⟨s ∪ t, s.2.union t.2⟩⟩\ninstance : has_inf (L.definable_set A α) := ⟨λ s t, ⟨s ∩ t, s.2.inter t.2⟩⟩\ninstance : has_compl (L.definable_set A α) := ⟨λ s, ⟨sᶜ, s.2.compl⟩⟩\ninstance : has_sdiff (L.definable_set A α) := ⟨λ s t, ⟨s \\ t, s.2.sdiff t.2⟩⟩\n\ninstance : inhabited (L.definable_set A α) := ⟨⊥⟩\n\nlemma le_iff : s ≤ t ↔ (s : set (α → M)) ≤ (t : set (α → M)) := iff.rfl\n\n@[simp] lemma mem_top : x ∈ (⊤ : L.definable_set A α) := mem_univ x\n@[simp] lemma not_mem_bot {x : α → M} : ¬ x ∈ (⊥ : L.definable_set A α) := not_mem_empty x\n@[simp] \n\n@[simp, norm_cast] lemma coe_top : ((⊤ : L.definable_set A α) : set (α → M)) = univ := rfl\n@[simp, norm_cast] lemma coe_bot : ((⊥ : L.definable_set A α) : set (α → M)) = ∅ := rfl\n@[simp, norm_cast] lemma coe_sup (s t : L.definable_set A α) : (↑(s ⊔ t) : set (α → M)) = s ∪ t :=\nrfl\n@[simp, norm_cast] lemma coe_inf (s t : L.definable_set A α) : (↑(s ⊓ t) : set (α → M)) = s ∩ t :=\nrfl\n@[simp, norm_cast] lemma coe_compl (s : L.definable_set A α) : (↑(sᶜ) : set (α → M)) = sᶜ := rfl\n@[simp, norm_cast] lemma coe_sdiff (s t : L.definable_set A α) : (↑(s \\ t) : set (α → M)) = s \\ t :=\nrfl\n\ninstance : boolean_algebra (L.definable_set A α) :=\nsubtype.coe_injective.boolean_algebra _ coe_sup coe_inf coe_top coe_bot coe_compl coe_sdiff\n\nend definable_set\nend language\nend first_order\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/model_theory/definability.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.4623298331780416}}
{"text": "-- 5.8 Exercises\n-- #1\n\n-- 3.7 Exercises\n-- #3\n\nvariable p : Prop\n\nexample : ¬ (p ↔ ¬ p) :=\nbegin\n  intro h,\n  cases h with h1 h2,\n  have hnp : ¬ p := λ hp : p, (h1 hp) hp,\n  have hp : p := h2 hnp,\n  contradiction,\nend\n", "meta": {"author": "agryman", "repo": "theorem-proving-in-lean", "sha": "cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9", "save_path": "github-repos/lean/agryman-theorem-proving-in-lean", "path": "github-repos/lean/agryman-theorem-proving-in-lean/theorem-proving-in-lean-cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9/src/05-Tactics/example-5.8-3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.4623298317403248}}
{"text": "/- The formalism of forcing, following Justin Moore's notes -/\n\nimport order.bounded_lattice tactic order.complete_boolean_algebra set_theory.zfc .to_mathlib\n\nopen lattice\n\nuniverse u\n\n@[class]def forcing_notion (α : Type u) : Type u := order_top α\n\n-- @[instance]def has_top_forcing_notion (α : Type u) [H : forcing_notion α] : has_top α := sorry\n\ninstance partial_order_of_forcing_notion (α : Type u) [H : forcing_notion α] : partial_order α :=\n{ le := H.le,\n  lt := H.lt,\n  le_refl := H.le_refl,\n  le_trans := H.le_trans,\n  lt_iff_le_not_le := H.lt_iff_le_not_le,\n  le_antisymm := H.le_antisymm }\n\ndef order_top.mk {α : Type u} [H₁ : partial_order α] [H₂ : has_top α] (H : ∀ a : α, a ≤ ⊤) : order_top α :=\n{ top := ⊤,\n  le := (≤),\n  lt := (<),\n  le_refl := H₁.le_refl,\n  le_trans := H₁.le_trans,\n  lt_iff_le_not_le := H₁.lt_iff_le_not_le,\n  le_antisymm := H₁.le_antisymm,\n  le_top := H }\n\n@[instance]example {α : Type u} : forcing_notion (set α) :=\norder_top.mk (λ _, le_top)\n\n/- A pfilter is an order-theoretic filter on the partial order α  -/\nstructure pfilter (α : Type u) [partial_order α] : Type u :=\n(X : set α)\n(nonempty : X ≠ ∅)\n(upward_closed : ∀ (p q : α) (H_le : p ≤ q) (H_mem : p ∈ X), q ∈ X)\n(downward_directed : ∀ (p q ∈ X), ∃ r ∈ X, r ≤ p ∧ r ≤ q)\n\ninductive Name (P : Type u) [forcing_notion P] : Type (u+1)\n| mk (α : Type u) (A : α → Name) (B : α → P) : Name\n\npostfix `-name`:100 := Name\n\ninstance : partial_order punit :=\n{ le := λ _ _, true,\n  lt := λ _ _, false,\n  le_refl := by simp,\n  le_trans := by simp,\n  lt_iff_le_not_le := by simp,\n  le_antisymm := by finish }\n\ninstance : has_top punit := ⟨punit.star⟩\n\ninstance : forcing_notion punit := order_top.mk (by finish)\n\ninstance forcing_notion_complete_boolean_algebra {α : Type u} [complete_boolean_algebra α] : forcing_notion α := order_top.mk (by finish)\n\n--TODO(jesse) rewrite in terms of pSet.rec and Name.rec\ndef pSet_equiv_trivial_name : pSet.{u} ≃ (punit-name : Type (u+1)) :=\n{ to_fun := λ u,\n  begin\n    induction u with α A ih,\n    from ⟨α, ih, λ _, punit.star⟩\n  end,\n  inv_fun := λ v,\n  begin\n    induction v with α A B ih,\n    from ⟨α, ih⟩\n  end,\n  left_inv :=\n    λ x, by induction x; finish,\n  right_inv :=\n    λ y, by induction y; finish }\n\n-- def Pcheck {P} [forcing_notion P] : pSet.{u} → (P-name : Type (u+1))\n-- | ⟨α, A⟩ := ⟨α, λ a, Pcheck (A a), λ _, ⊤⟩\n\n\nnamespace pfilter\n\n-- note: this will require a smallness argument, since we're going to be reconstructing a type in the ground model\n\n/-\nfrom Moore's \"The method of forcing\":\n\nIf G is any filter and ẋ is any Q-name, define\nẋ(G) recursively by ẋ(G) := { ẏ(G) : ∃p ∈ G (( ẏ, p) ∈ ẋ)}\n\nx ↦ ẋ is a map (Name α).{u} → Type u, parametrized by a pfilter (G : pfilter α)\n\nHowever, what does it mean for a filter in this case to be generic?\n-/\ndef eval {P : Type u} [forcing_notion P] (𝒢 : pfilter P) : P-name → Type u\n| ⟨α, A, B⟩ := Σ p : {a : α // B a ∈ 𝒢.X}, eval (A p.1)\n\ndef eval_image {P : Type u} [forcing_notion P] (𝒢 : pfilter P): Type (u + 1) :=\n{α // ∃ x, α = eval 𝒢 x} -- this should be our new model of set theory\n\n--TODO 6.8. 6.9, and 6.10 from Moore's notes\n\n-- def foo {P : Type u} [forcing_notion P] (𝒢 : pfilter P)  : pSet.{u} → (eval_image.{u} 𝒢) := λ x, ⟨eval 𝒢 (Pcheck x), ⟨_, rfl⟩⟩\n\n-- now foo is the canonical map from pSet to eval_image\n-- need to check that (foo x) is \"equivalent\" to x again in some way\n\nend pfilter\n", "meta": {"author": "flypitch", "repo": "flypitch", "sha": "aea5800db1f4cce53fc4a113711454b27388ecf8", "save_path": "github-repos/lean/flypitch-flypitch", "path": "github-repos/lean/flypitch-flypitch/flypitch-aea5800db1f4cce53fc4a113711454b27388ecf8/src/abstract_forcing.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.46227573411988776}}
{"text": "import game.limits.Blockus_Time\nimport game.sets.L01defs\nimport game.sup_inf.GLBprop_if_LUBprop\nimport game.limits.bounded_if_convergent\nimport data.real.basic\nimport tactic.linarith\nimport game.limits.seq_limitProd\nimport game.limits.Lemmas\n\nnamespace xena -- hide\n/-\n# Chapter 7 : Limits\n\n## Level 12\n\n\nProve the reciprocal property of limits. Good luck. \n-/\n\n\n/-\nLemma : stuff1 \n{a b : ℝ} (ha : a ≠ 0) (hb : b ≠ 0) : | ( 1 /a - 1 / b) | = | (b - a) / (a * b) |\n-/\n\n/-\nLemma : stuff2 \n{a b : ℝ} (ha : a ≠ 0) (hb : b ≠ 0) :  | (b - a) / ( a * b) | = 1 / (|a| * |b|) * |a - b| \n-/\n\n/-\nLemma : stuff3\n{a b : ℝ} (ha : a ≠ 0) (hb : b ≠ 0) (pb : 0 < b) (c : a ≥ b) : 1 / a ≤ 1 / b \n-/\n\n/-\nLemma : stuff4\n{a b c : ℝ} (ha : a ≠ 0) (hb : b ≠ 0) (hc : c ≠ 0) (hab : a ≥ b) : 1 / (a * c) ≤ 1 / (b * c)\n-/\n\n/-\nLemma : stuff5\n{a b c : ℝ} (ha : 0 < a) (hb : 0 ≤ b) (hc : 0 < c) (hbc : b < c)\n-/\n\n\n\nlocal notation `|`x`|` := abs x\n\nlemma lim_recip (b : ℕ → ℝ) (k : ℝ) (hk : k ≠ 0) (hb : is_limit b k) (hbnz : ∀ n : ℕ, b n ≠ 0) : \nis_limit (λn , 1 / b n) (1 / k) :=\nbegin \n\n  apply lim_le_iff_lim_lt.mpr,\n  \n  intro ε,\n  intro hε, \n\n  unfold_coes, \n  have R := lim_nz_ev_bd_away_from_zero, \n  have D := R b _ _, \n  unfold ev_bd_away_from_zero at D, \n  cases D with c hc, cases hc with y hy, \n  cases hy with N1 hN1, \n\n  ------\n  swap, exact k, swap, exact hk, swap, exact hb, \n  -----\n  unfold is_limit at hb, \n  have H1 := hb(c * |k| * ε), \n  have duh4 := abs_pos_of_ne_zero hk,\n  have H2 : 0 < (c * |k|), exact mul_pos y duh4, \n  have H3 : 0 < (c * |k| * ε), exact mul_pos H2 hε, \n  specialize H1 H3, cases H1 with N2 hN2,  \n  use max N1 N2, \n\n  intros n hn,\n  rw max_le_iff at hn,\n  cases hn with hn1 hn2, \n  have L : | 1 / b n - 1 / k | = | (k - b n) / ( b n * k) |, \n  have L1 := hbnz n, revert hk, revert L1, exact stuff1 _ _, \n\n  rw L, \n  have L2 : | (k - b n) / ( b n * k) | = 1 / (|b n| * |k|) * |b n - k|, have L1 := hbnz n,\n  revert hk, revert L1, exact stuff2 _ _,  \n  rw L2, \n\n  have L1 := hbnz n,\n  have L3 := hN1 n hn1,  \n  have duh : | b n | ≠ 0, linarith, \n  have duh2 : c ≠ 0, linarith, \n\n  have L4 : 1 / |b n| ≤ 1 / c, exact stuff3 duh duh2 y L3, \n  have duh3 := abs_nonneg (b n - k), \n  have duh4 := abs_pos_of_ne_zero hk, \n  have duh5 := abs_nonneg (k), \n\n\n\n     \n  have L5 : c * |k| ≤ |b n| * |k|, exact mul_le_mul_right1 duh5 L3, \n  have L505 : 0 < |b n|, linarith, \n  have L5051 : |k| ≠ 0, linarith, \n  have L51 : 0 < c * |k|, exact mul_pos y duh4, \n  have L5101 : 0 < (1 : ℝ), linarith, \n  have L511 : 0 < 1 / (c * |k|), exact div_pos (L5101) (L51), \n  have L512 : 0 ≤ 1 / (c * |k|), exact lt_imp_le L511,   \n  have L52 : 0 < |b n| * |k|, exact mul_pos L505 duh4,  \n  have L6 : 1 / (|b n| * |k|) ≤ 1 / (c * |k|), exact stuff4 duh duh2 L5051 L3,      \n  have L7 : (1 / (|b n| * |k|)) * |b n - k| ≤ (1 / (c * |k|)) * |b n - k|, exact mul_le_mul_right1 duh3 L6,\n    \n  have duh6 : |b n - k| < (c * |k| * ε), have H4 := hN2(n), specialize H4 hn2, exact H4, \n  \n\n  have W : 0 < 1 / (c * |k|), linarith, \n  have H6 : (1 / (c * |k|)) * |b n - k| < (1 / (c * |k|)) * (c * |k| * ε), \n  exact stuff5 L511 duh3 H3 duh6,      \n     \n  have L65 : (c * |k|) ≠ 0, linarith, \n  have H7 : 1 / (c * |k|) * (c * |k| * ε) = ε, exact soul_sucking_deep_sadness hε L65, \n  rw H7 at H6,\n\n  have H8 := bs_lemma L505 y duh4 duh3 hε duh L5051 duh2 L3 _, \n  swap, have H9 : 1 / (c * |k|) * |b n - k| ≤ ε, exact lt_imp_le H6, exact H9, \n  exact H8,\n\nend \n\nend xena ", "meta": {"author": "DavidTalone", "repo": "Real-Number-Game", "sha": "b159ae1219209c3da97566b64b8986b146ec9053", "save_path": "github-repos/lean/DavidTalone-Real-Number-Game", "path": "github-repos/lean/DavidTalone-Real-Number-Game/Real-Number-Game-b159ae1219209c3da97566b64b8986b146ec9053/src/game/limits/lim_recip.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.46221939333551443}}
{"text": "import order.hom.complete_lattice\nimport program\nimport order.fixed_points\nimport .complete_lattice.I\nopen tv\nopen order_hom\n\n\n\ndef xT_propagate (i_pos i_neg : I) : Program -> I\n| [] := i_pos\n| (r::p) := (i_pos.assign r.head (r.eval_body i_pos i_neg)) ⊔ (xT_propagate p)\ndef T_propagate (p : Program) (i_neg i_pos : I) : I := xT_propagate i_pos i_neg p\n\n\ntheorem T_monotone (p : Program) (i_neg : I) : monotone (T_propagate p i_neg) := λ a b c, begin\n  induction p,\n  exact c,\n  refine sup_le_sup _ p_ih,\n  refine I.assign_step c _,\n  exact Rule.eval_body_monotone p_hd i_neg c,\nend\n\ndef T (p : Program) (i_neg : I) : I →o I := ⟨T_propagate p i_neg, T_monotone p i_neg⟩\n\n\nlemma T_increasing {p : Program} {i ii : I} : ii <= T p i ii := begin\n  induction p, refl,\n  exact le_sup_of_le_right p_ih,\nend\n\n\n@[simp] lemma  T_fp_le_eq_iff {p : Program} {i ii : I} : T p i ii <= ii ↔ T p i ii = ii := \n  (iff.intro (λ h, le_antisymm h T_increasing) (λ h, (eq.symm h).ge))\n\nlemma T_fp_eq_unstep {p_tl : Program} {p_hd : Rule}  {i ii : I} (h : i = T (p_hd::p_tl) ii i) : i = T p_tl ii i  := \n  le_antisymm T_increasing (sup_le_iff.mp (le_antisymm_iff.mp h).right).right\n\nlemma T_fp_rule_sat_iff {p : Program} {i ii : I} : i = T p ii i ↔ ∀ r ∈ p, Rule.reduct_satisfied r i ii := begin\n  -- ==>\n  split; assume h,\n  induction p,\n  by_contradiction, finish,\n  assume r rmem,\n  change r.eval_body i ii <= r.eval_head i,\n  cases rmem, rw <- rmem at h,\n  change i = (λ b, if r.head = b then (r.eval_body i ii) else i b) ⊔ (xT_propagate i ii p_tl) at h,  \n  cases r.eval_body i ii,\n  any_goals { rw h, unfold Rule.eval_head, refine le_sup_iff.mpr _, left, simp },\n  exact p_ih (T_fp_eq_unstep h) r rmem,\n  -- <==\n  refine le_antisymm T_increasing _,\n  induction p, \n  exact rfl.ge,\n  change (i.assign p_hd.head (p_hd.eval_body i ii)) ⊔ (xT_propagate i ii p_tl) <= i,\n  apply sup_le_iff.mpr,\n  split,\n  have h2 := @h p_hd (or.inl rfl), change p_hd.eval_body i ii <= p_hd.eval_head i at h2,\n  unfold I.assign,\n  refine I.less_than_or_equal.mk _, assume a,\n  split_ifs,\n  rw <- h_1, exact h2,\n  exact rfl.le,\n  refine p_ih _, simp at *, assume r rmem, exact h.right r rmem,\nend\n\ntheorem T_fp_model_iff {p : Program} {i : I} : i = T p i i ↔ p.model i :=\n  (iff.intro (λ h, ⟨ T_fp_rule_sat_iff.mp h ⟩)\n             (λ h, T_fp_rule_sat_iff.mpr h.p))\n\n\ndef Program.is_local_op (p : Program) (f : I -> I) := ∀ {i : I}, p.localize (f i) = f (p.localize i)\n\n\ndef Program.is_local_biop (p : Program) (f : I -> I -> I) := ∀ {i1 i2 : I}, p.localize (f i1 i2) = f (p.localize i1) (p.localize i2)\n\n\nlemma I.assign.is_local_op {p : Program} (v : tv) {a : atom} (amem : a ∈ p.atoms) : p.is_local_op (I.assign' a v) := begin\n  assume i, unfold I.assign', unfold I.assign, ext,\n  unfold Program.localize, simp, unfold localize, split_ifs, repeat{refl},\n  rw h_1 at amem, contradiction, repeat{refl},\nend\n\nlemma I.sup_right.is_local_biop {p : Program} : p.is_local_biop I.sup := begin\n  intros i1 i2, ext a, unfold I.sup, unfold Program.localize, simp, unfold localize, split_ifs, repeat{refl},\nend\n\nlemma I.eval.unlocalize {p : Program} {i : I} {atoms : list atom} : (∀ a ∈ atoms, a ∈ p.atoms) -> (p.localize i).eval atoms = i.eval atoms := begin\n  intro all_atoms,\n  induction atoms, refl,\n  unfold I.eval, repeat {rw list.map_cons},\n  have atoms_hd_pmem : atoms_hd ∈ p.atoms := all_atoms atoms_hd (list.mem_cons_self atoms_hd atoms_tl),\n  have atoms_hd_unchanged : p.localize i atoms_hd = i atoms_hd := by {unfold Program.localize, simp, unfold localize, split_ifs, refl},\n  rw atoms_hd_unchanged,\n  have rest_eq : list.map ((p.localize) i) atoms_tl = list.map i atoms_tl := begin\n    apply atoms_ih, intros b bmem, apply all_atoms, exact list.mem_of_mem_tail bmem,\n  end,\n  rw rest_eq,\nend\n\nlemma Rule.eval_pbody.unlocalize {p : Program} {r : Rule} (i : I) (pmem : r ∈ p) : r.eval_pbody (p.localize i) = r.eval_pbody i := by {\n  unfold Rule.eval_pbody, rw I.eval.unlocalize (r.atom_program_mem_pbody pmem) }\nlemma Rule.eval_nbody.unlocalize {p : Program} {r : Rule} (i : I) (pmem : r ∈ p) : r.eval_nbody (p.localize i) = r.eval_nbody i := by {\n  unfold Rule.eval_nbody, rw I.eval.unlocalize (r.atom_program_mem_nbody pmem) }\nlemma Rule.eval_body.unlocalize {p : Program} {r : Rule} (i ii : I) (pmem : r ∈ p) : r.eval_body (p.localize i) (p.localize ii) = r.eval_body i ii := by {\n  unfold Rule.eval_body, rw [Rule.eval_pbody.unlocalize i pmem, Rule.eval_nbody.unlocalize ii pmem]}\nlemma Rule.eval_body_pos.unlocalize {p : Program} {r : Rule} {i ii : I} (pmem : r ∈ p) : r.eval_body (p.localize i) ii = r.eval_body i ii := by {\n  unfold Rule.eval_body, rw [Rule.eval_pbody.unlocalize i pmem]}\n\n\nlemma T.is_local_op {p : Program} {ii : I} : p.is_local_op (T p ii) := λ i, begin\n  have generalized : ∀ {p' : Program}, p ⊆ p' -> (p'.localize) ((T p ii) i) = (T p ii) ((p'.localize) i) := λ p' pss, begin\n    unfold T, simp, unfold T_propagate, induction p, refl, unfold xT_propagate, unfold has_sup.sup,\n    rw [I.sup_right.is_local_biop, I.assign_eq_assign', I.assign.is_local_op, <-I.assign_eq_assign'],\n    have p_hd_mem_p' : p_hd ∈ p' := pss (list.mem_cons_self p_hd p_tl),\n    rw [Rule.eval_body_pos.unlocalize p_hd_mem_p'],\n    refine sup_eq_sup_split (and.intro rfl _), simp,\n    exact p_ih (list.cons_subset.mp pss).right,\n    exact Exists.intro p_hd (Exists.intro ((list.cons_subset.mp pss).left) (or.inl rfl)),\n  end,\n  exact generalized rfl.subset,\nend\n\n\n\n\n-- @[reducible]\n-- def T_repeat (p : Program) (i_neg : I) : Π(i_pos : I), I\n-- | i := \n\n-- def T_lfp (p : Program) (i_neg : I) := T_repeat p i_neg I.bot\n\n-- theorem T_lfp_lattice_lfp_mp {p : Program} {ii : I} : lfp (T p ii) = T_lfp p ii := begin\n  \n-- end\n\n\n-- example {p : Program} {i : I} : i = lfp (T p i) := begin\n--   unfold_coes,\n-- end\n\ntheorem T_fp_stable_model_iff {p : Program} {i : I}: i = lfp (T p i) ↔ p.stable_model i := begin\nsplit; assume h,\nunfold lfp at h, simp at h,\nchange i = Inf {a : I | (T p i) a = a} at h,\nhave i_fp : (T p i) i = i := begin\n  -- suggest,\nend,\nrefine Program.stable_model.mk (T_fp_model_iff.mp h) _,\n\nend", "meta": {"author": "sjkillen", "repo": "Lean", "sha": "323e99f48fecfa4fc6ad9155eac4d939b2097930", "save_path": "github-repos/lean/sjkillen-Lean", "path": "github-repos/lean/sjkillen-Lean/Lean-323e99f48fecfa4fc6ad9155eac4d939b2097930/april-asp/src/asp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.46221938674133894}}
{"text": "import freealg \n\nopen interactive\nopen lean.parser\nopen tactic\nopen tactic.interactive («let» «have» simp refl)\nopen freealg\n\n------------------------- Conversion Tactic: [(finset α) or (set α) or boolean_lattice] to [boolean_ring] \n\nlemma finset.inter_is_inf (α : Type) [decidable_eq α] (X Y : finset α) : X ∩ Y = X ⊓ Y := rfl\nlemma finset.union_is_sup (α : Type) [decidable_eq α] (X Y : finset α) : X ∪ Y = X ⊔ Y := rfl\nlemma finset.empt_is_bot (α : Type) [decidable_eq α] : (finset.has_emptyc.emptyc : finset α) = ⊥ := rfl\nlemma finset.subset_is_le (α : Type) [decidable_eq α] (X Y : finset α) : (X ⊆ Y) = (X ≤ Y) := rfl \n\nlemma set.union_is_sup (α : Type) (X Y : set α) : X ∪ Y = X ⊔ Y := rfl\nlemma set.inter_is_inf (α : Type) (X Y : set α) : X ∩ Y = X ⊓ Y := rfl\nlemma set.empt_is_bot (α : Type) : (set.has_emptyc.emptyc : set α) = ⊥ := rfl \nlemma set.univ_is_top (α : Type) : (set.univ : set α) = ⊤ := rfl \nlemma set.subset_is_le (α : Type) (X Y : set α) : (X ⊆ Y) = (X ≤ Y) := rfl \n\nlemma ne_is_not_eq {α : Type} [boolean_algebra α] {X Y : α} : (X ≠ Y) = ¬(X = Y) := rfl \n\n\nmeta def to_ring_eqn : tactic unit := do\n`[\n  try {simp only\n  [finset.inter_is_inf, finset.union_is_sup, finset.empt_is_bot, finset.subset_is_le] at *}, \n  try {simp only \n  [set.union_is_sup, set.inter_is_inf, set.empt_is_bot, set.univ_is_top, set.subset_is_le] at *}, \n  try {simp only \n  [top_to_ring, bot_to_ring, symm_diff_to_ring,diff_to_ring, compl_to_ring, le_to_ring] at *}, \n  try {simp only [inf_to_ring, sup_to_ring] at *},\n  try {simp only [ne_is_not_eq] at *},\n  try {rw [bring_to_left] at *}\n]\n\n#check and\n\nlemma convert_ands {A B A' B' : Prop} :\n  A = A' → B = B' → (A ∧ B) = (A' ∧ B') :=\nbegin\n  cc,\nend\n\nmeta def get_proof_normalization : expr → tactic (expr × expr)\n| e := do\n  match e with \n  | `(%%L ∧ %%R) := do\n    (pfLT, pfLE) <- get_proof_normalization L,\n    (pfRT, pfRE) <- get_proof_normalization R,\n    match (pfLT, pfRT) with\n    | (`(_ = %%newL), `(_ = %%newR)) := do\n      proof_type <- to_expr ``(%%e = (%%newL ∧ %%newR)),\n      proof_expr <- to_expr \n        ``(convert_ands %%pfLE %%pfRE : \n            %%proof_type),\n      return (proof_type, proof_expr)\n    | _ := fail \"Not here\"\n    end\n   | `(%%A = %%B) := do\n    proof_type <- to_expr ``(%%e = (%%A + %%B + 1 = 1)),\n    proof_expr <- to_expr ``(bring_to_left : %%proof_type),\n    return (proof_type, proof_expr)\n  | _ := fail \"Not here\"\n  end\n\nmeta def normalize_target : tactic unit := do\n  texpr <- target,\n  name <- get_unused_name `Hnormal,\n  (newTargetExpr, proofTerm) <- get_proof_normalization texpr,\n  hypExpr <- assertv name newTargetExpr proofTerm,\n  rewrite_target hypExpr,\n  clear hypExpr,\n  return ()\n\nmeta def find_splittable_hyp : tactic expr := do\n  hyps <- local_context,\n  hyps <- hyps.mfilter (fun hyp, \n    (do `(%%A ∧ %%B) <- infer_type hyp,\n        return tt)\n    <|> return ff),\n  match hyps with\n  | (x :: xs) := return x\n  | [] := fail \"No splittable hypothesis found\"\n  end\n\nmeta def split_hyps : tactic unit := do\n  repeat $ (do\n    hyp <- find_splittable_hyp,\n    cases hyp,\n    skip)\n\n------------------------------ Normalization Tactics (in a free boolean algebra) -------------------------\nmeta def ids_list : lean.parser (list name) := types.list_of ident\nmeta def meta_build_vector : list pexpr -> pexpr\n| [] := ``(vector.nil)\n| (v :: vs) := ``(vector.cons %%v %%(meta_build_vector vs))\nmeta def list_with_idx {T : Type} : (list T) → nat -> list (nat × T)\n| [] n := []\n| (v :: vs) n := (n, v) :: list_with_idx vs (n + 1)\n\nmeta def tactic.interactive.introduce_varmap_rewrite (vname : parse ident) (vars : parse ids_list) : tactic unit :=\n  do\n    names <- vars.mmap (fun name, get_local name),\n    («let» vname ``(vector _ %%(vars.length)) $ meta_build_vector (names.map to_pexpr)),\n    mmap \n      (λ (pair : (nat × expr)),\n        let name := prod.snd pair in\n        let idx := prod.fst pair in\n        do \n          vname_expr <- get_local vname,\n          hname <- get_unused_name `Hv,\n          -- TODO: maybe clean this up with definev/assertv instead.\n          («have» hname ``(%%name = _) ``(on_var %%vname_expr %%idx (by norm_num))),\n          hname_expr <- get_local hname,\n          tactic.try (rewrite_target hname_expr),\n          clear hname_expr,\n          return ())\n      (list_with_idx names 0),\n    return ()\n\nmeta def find_matching_type (e : expr) : list expr → tactic expr\n| []         := tactic.failed\n| (H :: Hs)  := do t ← tactic.infer_type H,\n                   (tactic.unify e t >> return H) <|> find_matching_type Hs\nset_option pp.all false\nmeta def get_sets_in_expr : expr → tactic (list name) \n-- TODO maybe return the expressions themselves as they're less fragile then raw names\n-- something something expressions have a unique and a pretty name, which is slightly concerning\n-- (maybe).\n| e :=\n  match e with\n  -- This mostly handles basic expressions \n  | expr.local_const unique pretty _ _ :=\n    do\n      expr <- get_local pretty,\n      ((do\n        `(%%typ) <- tactic.infer_type expr,\n        boolalg_hyp <- to_expr ``(infer_instance : boolean_algebra %%typ),\n        return [pretty])\n      <|>\n        return [])\n  | expr.app e1 e2 := \n    do l1 <- get_sets_in_expr e1, \n       l2 <- get_sets_in_expr e2,\n       return (l1 ++ l2)\n  | _ := do return []\n  end\n\nmeta def assert_expr_is_boolalg (e : expr) : tactic unit :=\ndo\n  typ <- tactic.infer_type e,\n  boolalg_hyp <- to_expr ``(infer_instance : boolean_algebra %%typ),\n  return ()\n  \nmeta def is_boolalg_eqn : expr → tactic bool\n| e :=\n  ((do `(%%L = %%R) <- (infer_type e),\n    assert_expr_is_boolalg L,\n    assert_expr_is_boolalg R,\n    return tt)\n  <|>\n  (do `(%%L ≠ %%R) <- (infer_type e),\n    assert_expr_is_boolalg L,\n    assert_expr_is_boolalg R,\n    return tt)\n  <|>\n  (do `(¬ %%L = %%R) <- (infer_type e),\n    assert_expr_is_boolalg L,\n    assert_expr_is_boolalg R,\n    return tt)\n  <|>\n  (return ff))\n\ndef keep_unique {T: Type}[decidable_eq T]: list T -> list T \n| [] := []\n| (x :: xs) := let tl := keep_unique xs in\n                if list.mem x tl then tl else x :: tl\n\n/- A bound variable with a de-Bruijn index. -/\n-- | var _ := tactic.failed ()\n/- A type universe: `Sort u` -/\n-- | sort l := do return ()\n/- A global constant. These include definitions, constants and inductive type stuff present\nin the environment as well as hard-coded definitions. -/\n-- | const name l := do return ()\n/- [WARNING] Do not trust the types for `mvar` and `local_const`,\nthey are sometimes dummy values. Use `tactic.infer_type` instead. -/\n/- An `mvar` is a 'hole' yet to be filled in by the elaborator or tactic state. -/\n-- | mvar unique pretty type := do return ()\n/- A local constant. For example, if our tactic state was `h : P ⊢ Q`, `h` would be a local constant. -/\n-- | local_const unique pretty binder type := do return ()\n/- Function application. -/\n-- | app e1 e2 := do return ()\n/- Lambda abstraction. eg ```(λ a : α, x)`` -/\n-- | lam name binder type body := do return ()\n/- Pi type constructor. eg ```(Π a : α, x)`` and ```(α → β)`` -/\n-- | pi name binder type body := do return ()\n/- An explicit let binding. -/\n--| elet name type assignment body := do return ()\n/- A macro, see the docstring for `macro_def`.\n  The list of expressions are local constants and metavariables that the macro depends on.\n  -/\n-- | expr.macro macro_def body := do return () \nmeta def dummy : tactic unit :=\n  do tactic.trace \"Hello World\"\n\nlemma switch_target {T : Type} [boolean_algebra T] (A B C : T):\n  (A = 1) → (A * B = A * C) → B = C :=\n  λ h1 h2, by {rw [h1,one_mul, one_mul] at h2, from h2}\n    \n-- expects that goal is conjunction of ring equations\n-- expects that assumptions are just ring equations\nmeta def simplify_one_set (extra_sets : list name): tactic unit :=\n  do   \n    -- Convert to ring equations, and also\n    -- convert ring hypothesis to be of the form <eqn> = 1\n\n    -- TODO: gather sets from goals and hypothesis evntually\n    -- before we convert the goal as that's expensive.\n    timetac \"rewrite to ring equation\" $ to_ring_eqn,\n    normalize_target,\n    timetac \"rewrite ∧ to ring equns\" $ try `[apply no_inverses],\n    context <- tactic.local_context,\n    boolalg_hyps <- timetac \"get boolalg hyp\" $ context.mfilter is_boolalg_eqn,\n    -- Rewrite target to be Π (hypothesis) * original target\n    -- Clear original ring hypothesis as they are not needed anymore\n    tactic.timetac \"rewrite target\" $ boolalg_hyps.mmap\n      (fun (hyp : expr), do\n        `(%%Lh = 1) <- infer_type hyp,\n        `(%%Ltarget = %%Rtarget) <- target,\n        `[apply (switch_target %%Lh %%Ltarget %%Rtarget %%hyp)],\n        return ()\n      ),\n\n    -- Gather sets in the goal\n    texpr <- target,\n    list_of_sets <- timetac \"get set names\" $ get_sets_in_expr texpr,\n    vname <- get_unused_name `V,\n    tactic.timetac \"rewrite names\" $ tactic.interactive.introduce_varmap_rewrite vname\n      (keep_unique $ list_of_sets ++ extra_sets),\n    vname_expr <- get_local vname,\n\n    -- Some goals are already discharged by this point, so everything else\n    -- goes in a try block.\n    tactic.timetac \"final simp\" $\n    tactic.try (simp none tt ([``(freealg.on_one %%vname_expr),\n                   ``(freealg.on_add %%vname_expr),\n                   ``(freealg.on_mul %%vname_expr),\n                   ``(freealg.on_zero %%vname_expr),\n                   ``(freealg.on_var %%vname_expr)].map simp_arg_type.expr)\n                    list.nil loc.wildcard),\n    tactic.timetac \"evaluate ring stuff\" $ tactic.try (refl)\n\nmeta def split_goal (solver : tactic unit): tactic unit := do\n  texpr <- target,\n  match texpr with\n  | `(%%A ∨ %%B) := do\n    (left >> split_goal <|> right >> split_goal)\n  | _ := solver\n  end\n\nmeta def tactic.interactive.timed_simplify_sets \n  (extra_sets : (parse (optional ids_list))): tactic unit :=\n    do timetac \"simplify sets\" $ simplify_one_set (match extra_sets with | some l := l | none := [] end)\n\nlemma fourlemma (T : Type) (A B C D : set T) : A ⊆ B → C ⊆ Bᶜ → D ⊆ Bᶜ → ((A ∩ C = ∅ ) ∧ (A ∩ D = ∅)):=\nbegin\n  intros,\n  timed_simplify_sets,\nend\n\n--lemma fourtrans (T : Type) (A B C D : set T) : (A ⊆ B) → (B ⊆ C) → (C ⊆ D) → (A ⊆ D) :=\n--begin\n--  intros,\n--  timed_simplify_sets,\n--end\n\n--lemma dummylemma (T: Type) (X Y Z : set T) : (T = nat) → (X ⊆ Y) → (X ∩ Z) ⊆ (Y ∩ Z) :=\n--begin\n--  intros H1 H2,      \n--  simplify_sets,\n--end\n\n--lemma foo_alg2 (α : Type) (A: boolean_algebra α) (X Y Z P Q W: α): \n--  (X ⊔ (Y ⊔ Z)) ⊔ ((W ⊓ P ⊓ Q)ᶜ ⊔ (P ⊔ W ⊔ Q)) = ⊤ :=\n--begin\n--  simplify_sets, \n--end\n", "meta": {"author": "apnelson1", "repo": "lean-set-tactic", "sha": "9f79d8adb5bc946d67831b3495ce723a60510ce0", "save_path": "github-repos/lean/apnelson1-lean-set-tactic", "path": "github-repos/lean/apnelson1-lean-set-tactic/lean-set-tactic-9f79d8adb5bc946d67831b3495ce723a60510ce0/old/boolring_tactic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.46221938674133883}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module control.bifunctor\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Control.Functor\nimport Mathbin.Data.Sum.Basic\n\n/-!\n# Functors with two arguments\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines bifunctors.\n\nA bifunctor is a function `F : Type* → Type* → Type*` along with a bimap which turns `F α β` into\n`F α' β'` given two functions `α → α'` and `β → β'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') ∘ (bimap f g) = bimap (f' ∘ f) (g' ∘ g)`\n\n## Main declarations\n\n* `bifunctor`: A typeclass for the bare bimap of a bifunctor.\n* `is_lawful_bifunctor`: A typeclass asserting this bimap respects the bifunctor laws.\n-/\n\n\nuniverse u₀ u₁ u₂ v₀ v₁ v₂\n\nopen Function\n\n#print Bifunctor /-\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass Bifunctor (F : Type u₀ → Type u₁ → Type u₂) where\n  bimap : ∀ {α α' β β'}, (α → α') → (β → β') → F α β → F α' β'\n#align bifunctor Bifunctor\n-/\n\nexport Bifunctor (bimap)\n\n#print LawfulBifunctor /-\n/-- Bifunctor. This typeclass asserts that a lawless `bifunctor` is lawful. -/\nclass LawfulBifunctor (F : Type u₀ → Type u₁ → Type u₂) [Bifunctor F] where\n  id_bimap : ∀ {α β} (x : F α β), bimap id id x = x\n  bimap_bimap :\n    ∀ {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀),\n      bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x\n#align is_lawful_bifunctor LawfulBifunctor\n-/\n\nexport LawfulBifunctor (id_bimap bimap_bimap)\n\nattribute [higher_order.1bimap_id_id] id_bimap\n\nattribute [higher_order.1bimap_comp_bimap] bimap_bimap\n\nexport LawfulBifunctor (bimap_id_id bimap_comp_bimap)\n\nvariable {F : Type u₀ → Type u₁ → Type u₂} [Bifunctor F]\n\nnamespace Bifunctor\n\n#print Bifunctor.fst /-\n/-- Left map of a bifunctor. -/\n@[reducible]\ndef fst {α α' β} (f : α → α') : F α β → F α' β :=\n  bimap f id\n#align bifunctor.fst Bifunctor.fst\n-/\n\n#print Bifunctor.snd /-\n/-- Right map of a bifunctor. -/\n@[reducible]\ndef snd {α β β'} (f : β → β') : F α β → F α β' :=\n  bimap id f\n#align bifunctor.snd Bifunctor.snd\n-/\n\nvariable [LawfulBifunctor F]\n\n#print Bifunctor.id_fst /-\n@[higher_order.1fst_id]\ntheorem id_fst : ∀ {α β} (x : F α β), fst id x = x :=\n  @id_bimap _ _ _\n#align bifunctor.id_fst Bifunctor.id_fst\n-/\n\n#print Bifunctor.id_snd /-\n@[higher_order.1snd_id]\ntheorem id_snd : ∀ {α β} (x : F α β), snd id x = x :=\n  @id_bimap _ _ _\n#align bifunctor.id_snd Bifunctor.id_snd\n-/\n\n#print Bifunctor.comp_fst /-\n@[higher_order.1fst_comp_fst]\ntheorem comp_fst {α₀ α₁ α₂ β} (f : α₀ → α₁) (f' : α₁ → α₂) (x : F α₀ β) :\n    fst f' (fst f x) = fst (f' ∘ f) x := by simp [fst, bimap_bimap]\n#align bifunctor.comp_fst Bifunctor.comp_fst\n-/\n\n#print Bifunctor.fst_snd /-\n@[higher_order.1fst_comp_snd]\ntheorem fst_snd {α₀ α₁ β₀ β₁} (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n    fst f (snd f' x) = bimap f f' x := by simp [fst, bimap_bimap]\n#align bifunctor.fst_snd Bifunctor.fst_snd\n-/\n\n#print Bifunctor.snd_fst /-\n@[higher_order.1snd_comp_fst]\ntheorem snd_fst {α₀ α₁ β₀ β₁} (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀) :\n    snd f' (fst f x) = bimap f f' x := by simp [snd, bimap_bimap]\n#align bifunctor.snd_fst Bifunctor.snd_fst\n-/\n\n#print Bifunctor.comp_snd /-\n@[higher_order.1snd_comp_snd]\ntheorem comp_snd {α β₀ β₁ β₂} (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α β₀) :\n    snd g' (snd g x) = snd (g' ∘ g) x := by simp [snd, bimap_bimap]\n#align bifunctor.comp_snd Bifunctor.comp_snd\n-/\n\nattribute [functor_norm]\n  bimap_bimap comp_snd comp_fst snd_comp_snd snd_comp_fst fst_comp_snd fst_comp_fst bimap_comp_bimap bimap_id_id fst_id snd_id\n\nend Bifunctor\n\nopen Functor\n\ninstance : Bifunctor Prod where bimap := @Prod.map\n\ninstance : LawfulBifunctor Prod := by refine' { .. } <;> intros <;> cases x <;> rfl\n\n#print Bifunctor.const /-\ninstance Bifunctor.const : Bifunctor Const where bimap α α' β β f _ := f\n#align bifunctor.const Bifunctor.const\n-/\n\n#print LawfulBifunctor.const /-\ninstance LawfulBifunctor.const : LawfulBifunctor Const := by refine' { .. } <;> intros <;> rfl\n#align is_lawful_bifunctor.const LawfulBifunctor.const\n-/\n\n#print Bifunctor.flip /-\ninstance Bifunctor.flip : Bifunctor (flip F)\n    where bimap α α' β β' f f' x := (bimap f' f x : F β' α')\n#align bifunctor.flip Bifunctor.flip\n-/\n\n#print LawfulBifunctor.flip /-\ninstance LawfulBifunctor.flip [LawfulBifunctor F] : LawfulBifunctor (flip F) := by\n  refine' { .. } <;> intros <;> simp [bimap, functor_norm]\n#align is_lawful_bifunctor.flip LawfulBifunctor.flip\n-/\n\ninstance : Bifunctor Sum where bimap := @Sum.map\n\ninstance : LawfulBifunctor Sum := by refine' { .. } <;> intros <;> cases x <;> rfl\n\nopen Bifunctor Functor\n\n#print Bifunctor.functor /-\ninstance (priority := 10) Bifunctor.functor {α} : Functor (F α) where map _ _ := snd\n#align bifunctor.functor Bifunctor.functor\n-/\n\n#print Bifunctor.lawfulFunctor /-\ninstance (priority := 10) Bifunctor.lawfulFunctor [LawfulBifunctor F] {α} : LawfulFunctor (F α) :=\n  by refine' { .. } <;> intros <;> simp [Functor.map, functor_norm]\n#align bifunctor.is_lawful_functor Bifunctor.lawfulFunctor\n-/\n\nsection Bicompl\n\nvariable (G : Type _ → Type u₀) (H : Type _ → Type u₁) [Functor G] [Functor H]\n\ninstance : Bifunctor (bicompl F G H)\n    where bimap α α' β β' f f' x := (bimap (map f) (map f') x : F (G α') (H β'))\n\ninstance [LawfulFunctor G] [LawfulFunctor H] [LawfulBifunctor F] :\n    LawfulBifunctor (bicompl F G H) := by\n  constructor <;> intros <;> simp [bimap, map_id, map_comp_map, functor_norm]\n\nend Bicompl\n\nsection Bicompr\n\nvariable (G : Type u₂ → Type _) [Functor G]\n\ninstance : Bifunctor (bicompr G F)\n    where bimap α α' β β' f f' x := (map (bimap f f') x : G (F α' β'))\n\ninstance [LawfulFunctor G] [LawfulBifunctor F] : LawfulBifunctor (bicompr G F) := by\n  constructor <;> intros <;> simp [bimap, functor_norm]\n\nend Bicompr\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Control/Bifunctor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.4622149081278475}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad\n\nMultivariate polynomial functors.\n\nNote: eventually the W and M constructions as multivariate polynomial functors will go here.\n-/\nimport ..mvfunctor ..pfunctor\nimport for_mathlib\nuniverses u v\n\n/-\nmultivariate polynomial functors\n-/\n\nstructure mvpfunctor (n : ℕ) :=\n(A : Type.{u}) (B : A → typevec.{u} n)\n\nnamespace mvpfunctor\nopen mvfunctor (liftp liftr)\n\nvariables {n m : ℕ} (P : mvpfunctor.{u} n)\n\ndef apply (α : typevec.{u} n) : Type u := Σ a : P.A, P.B a ⟹ α\n\ndef map {α β : typevec n} (f : α ⟹ β) : P.apply α → P.apply β :=\nλ ⟨a, g⟩, ⟨a, typevec.comp f g⟩\n\ninstance : mvfunctor P.apply :=\n⟨@mvpfunctor.map n P⟩\n\ntheorem map_eq {α β : typevec n} (g : α ⟹ β) (a : P.A) (f : P.B a ⟹ α) :\n  @mvfunctor.map _ P.apply _ _ _ g ⟨a, f⟩ = ⟨a, g ⊚ f⟩ :=\nrfl\n\ntheorem id_map {α : typevec n} : ∀ x : P.apply α, typevec.id <$$> x = x\n| ⟨a, g⟩ := rfl\n\ntheorem comp_map {α β γ : typevec n} (f : α ⟹ β) (g : β ⟹ γ) :\n  ∀ x : P.apply α, (g ⊚ f) <$$> x = g <$$> (f <$$> x)\n| ⟨a, h⟩ := rfl\n\ndef comp (P : mvpfunctor.{u} n) (Q : fin' n → mvpfunctor.{u} m) : mvpfunctor m :=\n{ A := Σ a₂ : P.1, Π i, P.2 a₂ i → (Q i).1,\n  B := λ a, λ i, Σ j (b : P.2 a.1 j), (Q j).2 (a.snd j b) i }\n\nvariables {P} {Q : fin' n → mvpfunctor.{u} m} {α β : typevec.{u} m}\n\ndef comp.mk (x : P.apply (λ i, (Q i).apply α)) : (comp P Q).apply α :=\n⟨ ⟨ x.1, λ i a, (x.2 _ a).1  ⟩, λ i a, (x.snd a.fst (a.snd).fst).snd i (a.snd).snd ⟩\n\ndef comp.get (x : (comp P Q).apply α) : P.apply (λ i, (Q i).apply α) :=\n⟨ x.1.1, λ i a, ⟨x.fst.snd i a, λ (j : fin' m) (b : (Q i).B _ j), x.snd j ⟨i, ⟨a, b⟩⟩⟩ ⟩\n\nlemma comp.get_map (f : α ⟹ β) (x : (comp P Q).apply α) :\n  comp.get (f <$$> x) = (λ i (x : (Q i).apply α), f <$$> x) <$$> comp.get x :=\nby cases x; refl\n\n@[simp]\nlemma comp.get_mk (x : P.apply (λ i, (Q i).apply α)) : comp.get (comp.mk x) = x :=\nbegin\n  cases x,\n  simp! [comp.get,comp.mk],\n  ext; intros; refl\nend\n\n@[simp]\nlemma comp.mk_get (x : (comp P Q).apply α) : comp.mk (comp.get x) = x :=\nbegin\n  cases x,\n  dsimp [comp.get,comp.mk],\n  ext; intros, refl, refl,\n  congr, ext; intros; refl,\n  ext, congr, rcases x_1 with ⟨a,b,c⟩; refl,\nend\n\n/-\nlifting predicates and relations\n-/\n\ntheorem liftp_iff {α : typevec n} (p : Π ⦃i⦄ , α i → Prop) (x : P.apply α) :\n  liftp p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i j, p (f i j) :=\nbegin\n  split,\n  { rintros ⟨y, hy⟩, cases h : y with a f,\n    refine ⟨a, λ i j, (f i j).val, _, λ i j, (f i j).property⟩,\n    rw [←hy, h, map_eq], refl },\n  rintros ⟨a, f, xeq, pf⟩,\n  use ⟨a, λ i j, ⟨f i j, pf i j⟩⟩,\n  rw [xeq], reflexivity\nend\n\ntheorem liftr_iff {α : typevec n} (r : Π ⦃i⦄, α i → α i → Prop) (x y : P.apply α) :\n  liftr r x y ↔ ∃ a f₀ f₁, x = ⟨a, f₀⟩ ∧ y = ⟨a, f₁⟩ ∧ ∀ i j, r (f₀ i j) (f₁ i j) :=\nbegin\n  split,\n  { rintros ⟨u, xeq, yeq⟩, cases h : u with a f,\n    use [a, λ i j, (f i j).val.fst, λ i j, (f i j).val.snd],\n    split, { rw [←xeq, h], refl },\n    split, { rw [←yeq, h], refl },\n    intros i j, exact (f i j).property },\n  rintros ⟨a, f₀, f₁, xeq, yeq, h⟩,\n  use ⟨a, λ i j, ⟨(f₀ i j, f₁ i j), h i j⟩⟩,\n  dsimp, split,\n  { rw [xeq], refl },\n  rw [yeq], refl\nend\n\nend mvpfunctor\n\n/-\nDecomposing an n+1-ary pfunctor.\n-/\n\nnamespace mvpfunctor\nopen typevec\nvariables {n : ℕ} (P : mvpfunctor.{u} (n+1))\n\ndef drop : mvpfunctor n :=\n{ A := P.A, B := λ a, (P.B a).drop }\n\ndef last : pfunctor :=\n{ A := P.A, B := λ a, (P.B a).last }\n\n@[reducible] def append_contents {α : typevec n} {β : Type*}\n    {a : P.A} (f' : P.drop.B a ⟹ α) (f : P.last.B a → β) :\n  P.B a ⟹ α.append1 β :=\nsplit_fun f' f\n\nend mvpfunctor", "meta": {"author": "avigad", "repo": "qpf", "sha": "debe2eacb8cf46b21aba2eaf3f2e20940da0263b", "save_path": "github-repos/lean/avigad-qpf", "path": "github-repos/lean/avigad-qpf/qpf-debe2eacb8cf46b21aba2eaf3f2e20940da0263b/src/mvpfunctor/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.705785040214066, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.46221490742682964}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Scott Morrison, Jakob von Raumer\n-/\nimport category_theory.monoidal.braided\nimport category_theory.closed.monoidal\nimport algebra.category.Module.basic\nimport linear_algebra.tensor_product\nimport category_theory.linear.yoneda\nimport category_theory.monoidal.linear\n\n/-!\n# The symmetric monoidal category structure on R-modules\n\nMostly this uses existing machinery in `linear_algebra.tensor_product`.\nWe just need to provide a few small missing pieces to build the\n`monoidal_category` instance and then the `symmetric_category` instance.\n\nNote the universe level of the modules must be at least the universe level of the ring,\nso that we have a monoidal unit.\nFor now, we simplify by insisting both universe levels are the same.\n\nWe then construct the monoidal closed structure on `Module R`.\n\nIf you're happy using the bundled `Module R`, it may be possible to mostly\nuse this as an interface and not need to interact much with the implementation details.\n-/\n\nuniverses v w x u\n\nopen category_theory\n\nnamespace Module\n\nvariables {R : Type u} [comm_ring R]\n\nnamespace monoidal_category\n-- The definitions inside this namespace are essentially private.\n-- After we build the `monoidal_category (Module R)` instance,\n-- you should use that API.\n\nopen_locale tensor_product\nlocal attribute [ext] tensor_product.ext\n\n/-- (implementation) tensor product of R-modules -/\ndef tensor_obj (M N : Module R) : Module R := Module.of R (M ⊗[R] N)\n/-- (implementation) tensor product of morphisms R-modules -/\ndef tensor_hom {M N M' N' : Module R} (f : M ⟶ N) (g : M' ⟶ N') :\n  tensor_obj M M' ⟶ tensor_obj N N' :=\ntensor_product.map f g\n\nlemma tensor_id (M N : Module R) : tensor_hom (𝟙 M) (𝟙 N) = 𝟙 (Module.of R (M ⊗ N)) :=\nby { ext1, refl }\n\nlemma tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : Module R}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :\n    tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) = tensor_hom f₁ f₂ ≫ tensor_hom g₁ g₂ :=\nby { ext1, refl }\n\n/-- (implementation) the associator for R-modules -/\ndef associator (M : Module.{v} R) (N : Module.{w} R) (K : Module.{x} R) :\n  tensor_obj (tensor_obj M N) K ≅ tensor_obj M (tensor_obj N K) :=\n(tensor_product.assoc R M N K).to_Module_iso\n\nsection\n\n/-! The `associator_naturality` and `pentagon` lemmas below are very slow to elaborate.\n\nWe give them some help by expressing the lemmas first non-categorically, then using\n`convert _aux using 1` to have the elaborator work as little as possible. -/\n\nopen tensor_product (assoc map)\n\nprivate lemma associator_naturality_aux\n  {X₁ X₂ X₃ : Type*}\n  [add_comm_monoid X₁] [add_comm_monoid X₂] [add_comm_monoid X₃]\n  [module R X₁] [module R X₂] [module R X₃]\n  {Y₁ Y₂ Y₃ : Type*}\n  [add_comm_monoid Y₁] [add_comm_monoid Y₂] [add_comm_monoid Y₃]\n  [module R Y₁] [module R Y₂] [module R Y₃]\n  (f₁ : X₁ →ₗ[R] Y₁) (f₂ : X₂ →ₗ[R] Y₂) (f₃ : X₃ →ₗ[R] Y₃) :\n  (↑(assoc R Y₁ Y₂ Y₃) ∘ₗ (map (map f₁ f₂) f₃)) = ((map f₁ (map f₂ f₃)) ∘ₗ ↑(assoc R X₁ X₂ X₃)) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl\nend\n\nvariables (R)\n\nprivate lemma pentagon_aux\n  (W X Y Z : Type*)\n  [add_comm_monoid W] [add_comm_monoid X] [add_comm_monoid Y] [add_comm_monoid Z]\n  [module R W] [module R X] [module R Y] [module R Z] :\n  ((map (1 : W →ₗ[R] W) (assoc R X Y Z).to_linear_map).comp (assoc R W (X ⊗[R] Y) Z).to_linear_map)\n    .comp (map ↑(assoc R W X Y) (1 : Z →ₗ[R] Z)) =\n  (assoc R W X (Y ⊗[R] Z)).to_linear_map.comp (assoc R (W ⊗[R] X) Y Z).to_linear_map :=\nbegin\n  apply tensor_product.ext_fourfold,\n  intros w x y z,\n  refl\nend\n\nend\n\nlemma associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : Module R}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :\n    tensor_hom (tensor_hom f₁ f₂) f₃ ≫ (associator Y₁ Y₂ Y₃).hom =\n    (associator X₁ X₂ X₃).hom ≫ tensor_hom f₁ (tensor_hom f₂ f₃) :=\nby convert associator_naturality_aux f₁ f₂ f₃ using 1\n\nlemma pentagon (W X Y Z : Module R) :\n  tensor_hom (associator W X Y).hom (𝟙 Z) ≫ (associator W (tensor_obj X Y) Z).hom\n  ≫ tensor_hom (𝟙 W) (associator X Y Z).hom =\n    (associator (tensor_obj W X) Y Z).hom ≫ (associator W X (tensor_obj Y Z)).hom :=\nby convert pentagon_aux R W X Y Z using 1\n\n/-- (implementation) the left unitor for R-modules -/\ndef left_unitor (M : Module.{u} R) : Module.of R (R ⊗[R] M) ≅ M :=\n(linear_equiv.to_Module_iso (tensor_product.lid R M) : of R (R ⊗ M) ≅ of R M).trans (of_self_iso M)\n\n\n\n/-- (implementation) the right unitor for R-modules -/\ndef right_unitor (M : Module.{u} R) : Module.of R (M ⊗[R] R) ≅ M :=\n(linear_equiv.to_Module_iso (tensor_product.rid R M) : of R (M ⊗ R) ≅ of R M).trans (of_self_iso M)\n\nlemma right_unitor_naturality {M N : Module R} (f : M ⟶ N) :\n  tensor_hom f (𝟙 (Module.of R R)) ≫ (right_unitor N).hom = (right_unitor M).hom ≫ f :=\nbegin\n  ext x y, dsimp,\n  erw [tensor_product.rid_tmul, tensor_product.rid_tmul],\n  rw linear_map.map_smul,\n  refl,\nend\n\nlemma triangle (M N : Module.{u} R) :\n  (associator M (Module.of R R) N).hom ≫ tensor_hom (𝟙 M) (left_unitor N).hom =\n    tensor_hom (right_unitor M).hom (𝟙 N) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  change R at y,\n  dsimp [tensor_hom, associator],\n  erw [tensor_product.lid_tmul, tensor_product.rid_tmul],\n  exact (tensor_product.smul_tmul _ _ _).symm\nend\n\nend monoidal_category\n\nopen monoidal_category\n\ninstance monoidal_category : monoidal_category (Module.{u} R) :=\n{ -- data\n  tensor_obj   := tensor_obj,\n  tensor_hom   := @tensor_hom _ _,\n  tensor_unit  := Module.of R R,\n  associator   := associator,\n  left_unitor  := left_unitor,\n  right_unitor := right_unitor,\n  -- properties\n  tensor_id'               := λ M N, tensor_id M N,\n  tensor_comp'             := λ M N K M' N' K' f g h, tensor_comp f g h,\n  associator_naturality'   := λ M N K M' N' K' f g h, associator_naturality f g h,\n  left_unitor_naturality'  := λ M N f, left_unitor_naturality f,\n  right_unitor_naturality' := λ M N f, right_unitor_naturality f,\n  pentagon'                := λ M N K L, pentagon M N K L,\n  triangle'                := λ M N, triangle M N, }\n\n/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/\ninstance : comm_ring ((𝟙_ (Module.{u} R) : Module.{u} R) : Type u) :=\n(by apply_instance : comm_ring R)\n\nnamespace monoidal_category\n\n@[simp]\nlemma hom_apply {K L M N : Module.{u} R} (f : K ⟶ L) (g : M ⟶ N) (k : K) (m : M) :\n  (f ⊗ g) (k ⊗ₜ m) = f k ⊗ₜ g m := rfl\n\n@[simp]\nlemma left_unitor_hom_apply {M : Module.{u} R} (r : R) (m : M) :\n  ((λ_ M).hom : 𝟙_ (Module R) ⊗ M ⟶ M) (r ⊗ₜ[R] m) = r • m :=\ntensor_product.lid_tmul m r\n\n@[simp]\nlemma left_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((λ_ M).inv : M ⟶ 𝟙_ (Module.{u} R) ⊗ M) m = 1 ⊗ₜ[R] m :=\ntensor_product.lid_symm_apply m\n\n@[simp]\nlemma right_unitor_hom_apply {M : Module.{u} R} (m : M) (r : R) :\n  ((ρ_ M).hom : M ⊗ 𝟙_ (Module R) ⟶ M) (m ⊗ₜ r) = r • m :=\ntensor_product.rid_tmul m r\n\n@[simp]\nlemma right_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((ρ_ M).inv : M ⟶ M ⊗ 𝟙_ (Module.{u} R)) m = m ⊗ₜ[R] 1 :=\ntensor_product.rid_symm_apply m\n\n@[simp]\nlemma associator_hom_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((α_ M N K).hom : (M ⊗ N) ⊗ K ⟶ M ⊗ (N ⊗ K)) ((m ⊗ₜ n) ⊗ₜ k) = (m ⊗ₜ (n ⊗ₜ k)) := rfl\n\n@[simp]\nlemma associator_inv_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((α_ M N K).inv : M ⊗ (N ⊗ K) ⟶ (M ⊗ N) ⊗ K) (m ⊗ₜ (n ⊗ₜ k)) = ((m ⊗ₜ n) ⊗ₜ k) := rfl\n\nend monoidal_category\n\n/-- (implementation) the braiding for R-modules -/\ndef braiding (M N : Module R) : tensor_obj M N ≅ tensor_obj N M :=\nlinear_equiv.to_Module_iso (tensor_product.comm R M N)\n\n@[simp] lemma braiding_naturality {X₁ X₂ Y₁ Y₂ : Module.{u} R} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :\n  (f ⊗ g) ≫ (Y₁.braiding Y₂).hom =\n    (X₁.braiding X₂).hom ≫ (g ⊗ f) :=\nbegin\n  apply tensor_product.ext',\n  intros x y,\n  refl\nend\n\n@[simp] lemma hexagon_forward (X Y Z : Module.{u} R) :\n  (α_ X Y Z).hom ≫ (braiding X _).hom ≫ (α_ Y Z X).hom =\n  ((braiding X Y).hom ⊗ 𝟙 Z) ≫ (α_ Y X Z).hom ≫ (𝟙 Y ⊗ (braiding X Z).hom) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl,\nend\n\n@[simp] lemma hexagon_reverse (X Y Z : Module.{u} R) :\n  (α_ X Y Z).inv ≫ (braiding _ Z).hom ≫ (α_ Z X Y).inv =\n  (𝟙 X ⊗ (Y.braiding Z).hom) ≫ (α_ X Z Y).inv ≫ ((X.braiding Z).hom ⊗ 𝟙 Y) :=\nbegin\n  apply (cancel_epi (α_ X Y Z).hom).1,\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl,\nend\n\nlocal attribute [ext] tensor_product.ext\n\n/-- The symmetric monoidal structure on `Module R`. -/\ninstance symmetric_category : symmetric_category (Module.{u} R) :=\n{ braiding := braiding,\n  braiding_naturality' := λ X₁ X₂ Y₁ Y₂ f g, braiding_naturality f g,\n  hexagon_forward' := hexagon_forward,\n  hexagon_reverse' := hexagon_reverse, }\n\nnamespace monoidal_category\n\n@[simp] lemma braiding_hom_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((β_ M N).hom : M ⊗ N ⟶ N ⊗ M) (m ⊗ₜ n) = n ⊗ₜ m := rfl\n\n@[simp] lemma braiding_inv_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((β_ M N).inv : N ⊗ M ⟶ M ⊗ N) (n ⊗ₜ m) = m ⊗ₜ n := rfl\n\nend monoidal_category\n\nopen opposite\n\ninstance : monoidal_preadditive (Module.{u} R) :=\nby refine ⟨_, _, _, _⟩; dsimp only [auto_param]; intros;\n  refine tensor_product.ext (linear_map.ext $ λ x, linear_map.ext $ λ y, _);\n  simp only [linear_map.compr₂_apply, tensor_product.mk_apply, monoidal_category.hom_apply,\n    linear_map.zero_apply, tensor_product.tmul_zero, tensor_product.zero_tmul,\n    linear_map.add_apply, tensor_product.tmul_add, tensor_product.add_tmul]\n\ninstance : monoidal_linear R (Module.{u} R) :=\nby refine ⟨_, _⟩; dsimp only [auto_param]; intros;\n  refine tensor_product.ext (linear_map.ext $ λ x, linear_map.ext $ λ y, _);\n  simp only [linear_map.compr₂_apply, tensor_product.mk_apply, monoidal_category.hom_apply,\n    linear_map.smul_apply, tensor_product.tmul_smul, tensor_product.smul_tmul]\n\n/--\nAuxiliary definition for the `monoidal_closed` instance on `Module R`.\n(This is only a separate definition in order to speed up typechecking. )\n-/\n@[simps]\ndef monoidal_closed_hom_equiv (M N P : Module.{u} R) :\n  ((monoidal_category.tensor_left M).obj N ⟶ P) ≃\n    (N ⟶ ((linear_coyoneda R (Module R)).obj (op M)).obj P) :=\n{ to_fun := λ f, linear_map.compr₂ (tensor_product.mk R N M) ((β_ N M).hom ≫ f),\n  inv_fun := λ f, (β_ M N).hom ≫ tensor_product.lift f,\n  left_inv := λ f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr₂_apply,\n      function.comp_app, coe_comp, monoidal_category.braiding_hom_apply],\n  end,\n  right_inv := λ f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr₂_apply,\n      symmetric_category.symmetry_assoc],\n  end, }\n\ninstance : monoidal_closed (Module.{u} R) :=\n{ closed' := λ M,\n  { is_adj :=\n    { right := (linear_coyoneda R (Module.{u} R)).obj (op M),\n      adj := adjunction.mk_of_hom_equiv\n      { hom_equiv := λ N P, monoidal_closed_hom_equiv M N P, } } } }\n\nlemma ihom_map_apply {M N P : Module.{u} R} (f : N ⟶ P) (g : Module.of R (M ⟶ N)) :\n  (ihom M).map f g = g ≫ f := rfl\n\n-- I can't seem to express the function coercion here without writing `@coe_fn`.\n@[simp]\nlemma monoidal_closed_curry {M N P : Module.{u} R} (f : M ⊗ N ⟶ P) (x : M) (y : N) :\n  @coe_fn _ _ linear_map.has_coe_to_fun ((monoidal_closed.curry f : N →ₗ[R] (M →ₗ[R] P)) y) x =\n    f (x ⊗ₜ[R] y) :=\nrfl\n\n@[simp]\nlemma monoidal_closed_uncurry {M N P : Module.{u} R}\n  (f : N ⟶ (M ⟶[Module.{u} R] P)) (x : M) (y : N) :\n  monoidal_closed.uncurry f (x ⊗ₜ[R] y) = (@coe_fn _ _ linear_map.has_coe_to_fun (f y)) x :=\nrfl\n\n/-- Describes the counit of the adjunction `M ⊗ - ⊣ Hom(M, -)`. Given an `R`-module `N` this\nshould give a map `M ⊗ Hom(M, N) ⟶ N`, so we flip the order of the arguments in the identity map\n`Hom(M, N) ⟶ (M ⟶ N)` and uncurry the resulting map `M ⟶ Hom(M, N) ⟶ N.` -/\nlemma ihom_ev_app (M N : Module.{u} R) :\n  (ihom.ev M).app N = tensor_product.uncurry _ _ _ _ linear_map.id.flip :=\nbegin\n  ext,\n  exact Module.monoidal_closed_uncurry _ _ _,\nend\n\n/-- Describes the unit of the adjunction `M ⊗ - ⊣ Hom(M, -)`. Given an `R`-module `N` this should\ndefine a map `N ⟶ Hom(M, M ⊗ N)`, which is given by flipping the arguments in the natural\n`R`-bilinear map `M ⟶ N ⟶ M ⊗ N`. -/\nlemma ihom_coev_app (M N : Module.{u} R) :\n  (ihom.coev M).app N = (tensor_product.mk _ _ _).flip :=\nrfl\n\nlemma monoidal_closed_pre_app {M N : Module.{u} R} (P : Module.{u} R) (f : N ⟶ M) :\n  (monoidal_closed.pre f).app P = linear_map.lcomp R _ f :=\nrfl\n\nend Module\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/category/Module/monoidal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4622149040750134}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Adam Topaz\n\n! This file was ported from Lean 3 source module category_theory.limits.concrete_category\n! leanprover-community/mathlib commit c3019c79074b0619edb4b27553a91b2e82242395\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Limits.Preserves.Basic\nimport Mathlib.CategoryTheory.Limits.Types\nimport Mathlib.CategoryTheory.Limits.Shapes.WidePullbacks\nimport Mathlib.CategoryTheory.Limits.Shapes.Multiequalizer\nimport Mathlib.CategoryTheory.ConcreteCategory.Basic\nimport Mathlib.CategoryTheory.Limits.Shapes.Kernels\nimport Mathlib.Tactic.ApplyFun\n\n/-!\n# Facts about (co)limits of functors into concrete categories\n-/\n\n\nuniverse w v u\n\nopen CategoryTheory\n\nnamespace CategoryTheory.Limits\n\nattribute [local instance] ConcreteCategory.hasCoeToFun ConcreteCategory.hasCoeToSort\n\nsection Limits\n\nvariable {C : Type u} [Category.{v} C] [ConcreteCategory.{max w v} C] {J : Type w} [SmallCategory J]\n  (F : J ⥤ C) [PreservesLimit F (forget C)]\n\ntheorem Concrete.to_product_injective_of_isLimit {D : Cone F} (hD : IsLimit D) :\n    Function.Injective fun (x : D.pt) (j : J) => D.π.app j x := by\n  let E := (forget C).mapCone D\n  let hE : IsLimit E := isLimitOfPreserves _ hD\n  let G := Types.limitCone.{w, v} (F ⋙ forget C)\n  let hG := Types.limitConeIsLimit.{w, v} (F ⋙ forget C)\n  let T : E.pt ≅ G.pt := hE.conePointUniqueUpToIso hG\n  change Function.Injective (T.hom ≫ fun x j => G.π.app j x)\n  have h : Function.Injective T.hom := by\n    intro a b h\n    suffices T.inv (T.hom a) = T.inv (T.hom b) by simpa\n    rw [h]\n  suffices Function.Injective fun (x : G.pt) j => G.π.app j x by exact this.comp h\n  apply Subtype.ext\n#align category_theory.limits.concrete.to_product_injective_of_is_limit CategoryTheory.Limits.Concrete.to_product_injective_of_isLimit\n\ntheorem Concrete.isLimit_ext {D : Cone F} (hD : IsLimit D) (x y : D.pt) :\n    (∀ j, D.π.app j x = D.π.app j y) → x = y := fun h =>\n  Concrete.to_product_injective_of_isLimit _ hD (funext h)\n#align category_theory.limits.concrete.is_limit_ext CategoryTheory.Limits.Concrete.isLimit_ext\n\ntheorem Concrete.limit_ext [HasLimit F] (x y : ↑(limit F)) :\n    (∀ j, limit.π F j x = limit.π F j y) → x = y :=\n  Concrete.isLimit_ext F (limit.isLimit _) _ _\n#align category_theory.limits.concrete.limit_ext CategoryTheory.Limits.Concrete.limit_ext\n\nsection WidePullback\n\nopen WidePullback\n\nopen WidePullbackShape\n\ntheorem Concrete.widePullback_ext {B : C} {ι : Type w} {X : ι → C} (f : ∀ j : ι, X j ⟶ B)\n    [HasWidePullback B X f] [PreservesLimit (wideCospan B X f) (forget C)]\n    (x y : ↑(widePullback B X f)) (h₀ : base f x = base f y) (h : ∀ j, π f j x = π f j y) :\n    x = y := by\n  apply Concrete.limit_ext\n  rintro (_ | j)\n  · exact h₀\n  · apply h\n#align category_theory.limits.concrete.wide_pullback_ext CategoryTheory.Limits.Concrete.widePullback_ext\n\ntheorem Concrete.widePullback_ext' {B : C} {ι : Type w} [Nonempty ι] {X : ι → C}\n    (f : ∀ j : ι, X j ⟶ B) [HasWidePullback.{w} B X f]\n    [PreservesLimit (wideCospan B X f) (forget C)] (x y : ↑(widePullback B X f))\n    (h : ∀ j, π f j x = π f j y) : x = y := by\n  apply Concrete.widePullback_ext _ _ _ _ h\n  inhabit ι\n  simp only [← π_arrow f default, comp_apply, h]\n#align category_theory.limits.concrete.wide_pullback_ext' CategoryTheory.Limits.Concrete.widePullback_ext'\n\nend WidePullback\n\nsection Multiequalizer\n\ntheorem Concrete.multiequalizer_ext {I : MulticospanIndex.{w} C} [HasMultiequalizer I]\n    [PreservesLimit I.multicospan (forget C)] (x y : ↑(multiequalizer I))\n    (h : ∀ t : I.L, Multiequalizer.ι I t x = Multiequalizer.ι I t y) : x = y := by\n  apply Concrete.limit_ext\n  rintro (a | b)\n  · apply h\n  · rw [← limit.w I.multicospan (WalkingMulticospan.Hom.fst b), comp_apply, comp_apply, h]\n#align category_theory.limits.concrete.multiequalizer_ext CategoryTheory.Limits.Concrete.multiequalizer_ext\n\n/-- An auxiliary equivalence to be used in `multiequalizerEquiv` below.-/\ndef Concrete.multiequalizerEquivAux (I : MulticospanIndex C) :\n    (I.multicospan ⋙ forget C).sections ≃\n      { x : ∀ i : I.L, I.left i // ∀ i : I.R, I.fst i (x _) = I.snd i (x _) }\n    where\n  toFun x :=\n    ⟨fun i => x.1 (WalkingMulticospan.left _), fun i =>\n      by\n      have a := x.2 (WalkingMulticospan.Hom.fst i)\n      have b := x.2 (WalkingMulticospan.Hom.snd i)\n      rw [← b] at a\n      exact a⟩\n  invFun x :=\n    { val := fun j =>\n        match j with\n        | WalkingMulticospan.left a => x.1 _\n        | WalkingMulticospan.right b => I.fst b (x.1 _)\n      property := by\n        rintro (a | b) (a' | b') (f | f | f)\n        · change (I.multicospan.map (𝟙 _)) _ = _\n          simp\n        · rfl\n        · dsimp\n          erw [← x.2 b']\n        · change (I.multicospan.map (𝟙 _)) _ = _\n          simp }\n  left_inv := by\n    intro x; ext (a | b)\n    · rfl\n    · change _ = x.val _\n      rw [← x.2 (WalkingMulticospan.Hom.fst b)]\n      rfl\n  right_inv := by\n    intro x\n    ext i\n    rfl\n#align category_theory.limits.concrete.multiequalizer_equiv_aux CategoryTheory.Limits.Concrete.multiequalizerEquivAux\n\n/-- The equivalence between the noncomputable multiequalizer and\nand the concrete multiequalizer. -/\nnoncomputable def Concrete.multiequalizerEquiv (I : MulticospanIndex.{w} C) [HasMultiequalizer I]\n    [PreservesLimit I.multicospan (forget C)] :\n    (multiequalizer I : C) ≃\n      { x : ∀ i : I.L, I.left i // ∀ i : I.R, I.fst i (x _) = I.snd i (x _) } := by\n  let h1 := limit.isLimit I.multicospan\n  let h2 := isLimitOfPreserves (forget C) h1\n  let E := h2.conePointUniqueUpToIso (Types.limitConeIsLimit.{w, v} _)\n  exact Equiv.trans E.toEquiv (Concrete.multiequalizerEquivAux.{w, v} I)\n#align category_theory.limits.concrete.multiequalizer_equiv CategoryTheory.Limits.Concrete.multiequalizerEquiv\n\n@[simp]\ntheorem Concrete.multiequalizerEquiv_apply (I : MulticospanIndex.{w} C) [HasMultiequalizer I]\n    [PreservesLimit I.multicospan (forget C)] (x : ↑(multiequalizer I)) (i : I.L) :\n    ((Concrete.multiequalizerEquiv I) x : ∀ i : I.L, I.left i) i = Multiequalizer.ι I i x :=\n  rfl\n#align category_theory.limits.concrete.multiequalizer_equiv_apply CategoryTheory.Limits.Concrete.multiequalizerEquiv_apply\n\nend Multiequalizer\n\n-- TODO: Add analogous lemmas about products and equalizers.\nend Limits\n\nsection Colimits\n\n-- We don't mark this as an `@[ext]` lemma as we don't always want to work elementwise.\ntheorem cokernel_funext {C : Type _} [Category C] [HasZeroMorphisms C] [ConcreteCategory C]\n    {M N K : C} {f : M ⟶ N} [HasCokernel f] {g h : cokernel f ⟶ K}\n    (w : ∀ n : N, g (cokernel.π f n) = h (cokernel.π f n)) : g = h := by\n  apply coequalizer.hom_ext\n  apply ConcreteCategory.hom_ext _ _\n  simpa using w\n#align category_theory.limits.cokernel_funext CategoryTheory.Limits.cokernel_funext\n\nvariable {C : Type u} [Category.{v} C] [ConcreteCategory.{v} C] {J : Type v} [SmallCategory J]\n  (F : J ⥤ C) [PreservesColimit F (forget C)]\n\n\n\ntheorem Concrete.isColimit_exists_rep {D : Cocone F} (hD : IsColimit D) (x : D.pt) :\n    ∃ (j : J)(y : F.obj j), D.ι.app j y = x := by\n  obtain ⟨a, rfl⟩ := Concrete.from_union_surjective_of_isColimit F hD x\n  exact ⟨a.1, a.2, rfl⟩\n#align category_theory.limits.concrete.is_colimit_exists_rep CategoryTheory.Limits.Concrete.isColimit_exists_rep\n\ntheorem Concrete.colimit_exists_rep [HasColimit F] (x : ↑(colimit F)) :\n    ∃ (j : J)(y : F.obj j), colimit.ι F j y = x :=\n  Concrete.isColimit_exists_rep F (colimit.isColimit _) x\n#align category_theory.limits.concrete.colimit_exists_rep CategoryTheory.Limits.Concrete.colimit_exists_rep\n\ntheorem Concrete.isColimit_rep_eq_of_exists {D : Cocone F} {i j : J} (hD : IsColimit D)\n    (x : F.obj i) (y : F.obj j) (h : ∃ (k : _)(f : i ⟶ k)(g : j ⟶ k), F.map f x = F.map g y) :\n    D.ι.app i x = D.ι.app j y := by\n  let E := (forget C).mapCocone D\n  let hE : IsColimit E := isColimitOfPreserves _ hD\n  let G := Types.colimitCocone.{v, v} (F ⋙ forget C)\n  let hG := Types.colimitCoconeIsColimit.{v, v} (F ⋙ forget C)\n  let T : E ≅ G := hE.uniqueUpToIso hG\n  let TX : E.pt ≅ G.pt := (Cocones.forget _).mapIso T\n  -- porting note: `apply_fun TX.hom` does not work here\n  apply (show Function.Bijective TX.hom by\n    rw [← isIso_iff_bijective]\n    apply IsIso.of_iso).1\n  change (E.ι.app i ≫ TX.hom) x = (E.ι.app j ≫ TX.hom) y\n  erw [T.hom.w, T.hom.w]\n  obtain ⟨k, f, g, h⟩ := h\n  have : G.ι.app i x = (G.ι.app k (F.map f x) : G.pt) := Quot.sound ⟨f, rfl⟩\n  rw [this, h]\n  symm\n  exact Quot.sound ⟨g, rfl⟩\n#align category_theory.limits.concrete.is_colimit_rep_eq_of_exists CategoryTheory.Limits.Concrete.isColimit_rep_eq_of_exists\n\ntheorem Concrete.colimit_rep_eq_of_exists [HasColimit F] {i j : J} (x : F.obj i) (y : F.obj j)\n    (h : ∃ (k : _)(f : i ⟶ k)(g : j ⟶ k), F.map f x = F.map g y) :\n    colimit.ι F i x = colimit.ι F j y :=\n  Concrete.isColimit_rep_eq_of_exists F (colimit.isColimit _) x y h\n#align category_theory.limits.concrete.colimit_rep_eq_of_exists CategoryTheory.Limits.Concrete.colimit_rep_eq_of_exists\n\nsection FilteredColimits\n\nvariable [IsFiltered J]\n\ntheorem Concrete.isColimit_exists_of_rep_eq {D : Cocone F} {i j : J} (hD : IsColimit D)\n    (x : F.obj i) (y : F.obj j) (h : D.ι.app _ x = D.ι.app _ y) :\n    ∃ (k : _)(f : i ⟶ k)(g : j ⟶ k), F.map f x = F.map g y := by\n  let E := (forget C).mapCocone D\n  let hE : IsColimit E := isColimitOfPreserves _ hD\n  let G := Types.colimitCocone.{v, v} (F ⋙ forget C)\n  let hG := Types.colimitCoconeIsColimit.{v, v} (F ⋙ forget C)\n  let T : E ≅ G := hE.uniqueUpToIso hG\n  let TX : E.pt ≅ G.pt := (Cocones.forget _).mapIso T\n  -- porting note: `apply_fun TX.hom at h` does not work here\n  replace h := congr_arg TX.hom h\n  change (E.ι.app i ≫ TX.hom) x = (E.ι.app j ≫ TX.hom) y at h\n  erw [T.hom.w, T.hom.w] at h\n  replace h := Quot.exact _ h\n  suffices\n    ∀ (a b : Σj, F.obj j) (_ : EqvGen (Limits.Types.Quot.Rel.{v, v} (F ⋙ forget C)) a b),\n      ∃ (k : _)(f : a.1 ⟶ k)(g : b.1 ⟶ k), F.map f a.2 = F.map g b.2\n    by exact this ⟨i, x⟩ ⟨j, y⟩ h\n  intro a b h\n  induction h\n  case rel x y hh =>\n    obtain ⟨e, he⟩ := hh\n    use y.1, e, 𝟙 _\n    simpa using he.symm\n  case refl x =>\n    exact ⟨x.1, 𝟙 _, 𝟙 _, rfl⟩\n  case symm x y _ hh =>\n    obtain ⟨k, f, g, hh⟩ := hh\n    exact ⟨k, g, f, hh.symm⟩\n  case trans x y z _ _ hh1 hh2 =>\n    obtain ⟨k1, f1, g1, h1⟩ := hh1\n    obtain ⟨k2, f2, g2, h2⟩ := hh2\n    let k0 : J := IsFiltered.max k1 k2\n    let e1 : k1 ⟶ k0 := IsFiltered.leftToMax _ _\n    let e2 : k2 ⟶ k0 := IsFiltered.rightToMax _ _\n    let k : J := IsFiltered.coeq (g1 ≫ e1) (f2 ≫ e2)\n    let e : k0 ⟶ k := IsFiltered.coeqHom _ _\n    use k, f1 ≫ e1 ≫ e, g2 ≫ e2 ≫ e\n    simp only [F.map_comp, comp_apply, h1, ← h2]\n    simp only [← comp_apply, ← F.map_comp]\n    rw [IsFiltered.coeq_condition]\n#align category_theory.limits.concrete.is_colimit_exists_of_rep_eq CategoryTheory.Limits.Concrete.isColimit_exists_of_rep_eq\n\ntheorem Concrete.isColimit_rep_eq_iff_exists {D : Cocone F} {i j : J} (hD : IsColimit D)\n    (x : F.obj i) (y : F.obj j) :\n    D.ι.app i x = D.ι.app j y ↔ ∃ (k : _)(f : i ⟶ k)(g : j ⟶ k), F.map f x = F.map g y :=\n  ⟨Concrete.isColimit_exists_of_rep_eq _ hD _ _, Concrete.isColimit_rep_eq_of_exists _ hD _ _⟩\n#align category_theory.limits.concrete.is_colimit_rep_eq_iff_exists CategoryTheory.Limits.Concrete.isColimit_rep_eq_iff_exists\n\ntheorem Concrete.colimit_exists_of_rep_eq [HasColimit F] {i j : J} (x : F.obj i) (y : F.obj j)\n    (h : colimit.ι F _ x = colimit.ι F _ y) :\n    ∃ (k : _)(f : i ⟶ k)(g : j ⟶ k), F.map f x = F.map g y :=\n  Concrete.isColimit_exists_of_rep_eq F (colimit.isColimit _) x y h\n#align category_theory.limits.concrete.colimit_exists_of_rep_eq CategoryTheory.Limits.Concrete.colimit_exists_of_rep_eq\n\ntheorem Concrete.colimit_rep_eq_iff_exists [HasColimit F] {i j : J} (x : F.obj i) (y : F.obj j) :\n    colimit.ι F i x = colimit.ι F j y ↔ ∃ (k : _)(f : i ⟶ k)(g : j ⟶ k), F.map f x = F.map g y :=\n  ⟨Concrete.colimit_exists_of_rep_eq _ _ _, Concrete.colimit_rep_eq_of_exists _ _ _⟩\n#align category_theory.limits.concrete.colimit_rep_eq_iff_exists CategoryTheory.Limits.Concrete.colimit_rep_eq_iff_exists\n\nend FilteredColimits\n\nsection WidePushout\n\nopen WidePushout\n\nopen WidePushoutShape\n\ntheorem Concrete.widePushout_exists_rep {B : C} {α : Type _} {X : α → C} (f : ∀ j : α, B ⟶ X j)\n    [HasWidePushout.{v} B X f] [PreservesColimit (wideSpan B X f) (forget C)]\n    (x : ↑(widePushout B X f)) : (∃ y : B, head f y = x) ∨ ∃ (i : α)(y : X i), ι f i y = x := by\n  obtain ⟨_ | j, y, rfl⟩ := Concrete.colimit_exists_rep _ x\n  · left\n    use y\n  · right\n    use j, y\n#align category_theory.limits.concrete.wide_pushout_exists_rep CategoryTheory.Limits.Concrete.widePushout_exists_rep\n\ntheorem Concrete.widePushout_exists_rep' {B : C} {α : Type _} [Nonempty α] {X : α → C}\n    (f : ∀ j : α, B ⟶ X j) [HasWidePushout.{v} B X f] [PreservesColimit (wideSpan B X f) (forget C)]\n    (x : ↑(widePushout B X f)) : ∃ (i : α)(y : X i), ι f i y = x := by\n  rcases Concrete.widePushout_exists_rep f x with (⟨y, rfl⟩ | ⟨i, y, rfl⟩)\n  · inhabit α\n    use default, f _ y\n    simp only [← arrow_ι _ default, comp_apply]\n  · use i, y\n#align category_theory.limits.concrete.wide_pushout_exists_rep' CategoryTheory.Limits.Concrete.widePushout_exists_rep'\n\nend WidePushout\n\n-- TODO: Add analogous lemmas about coproducts and coequalizers.\nend Colimits\n\nend CategoryTheory.Limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Limits/ConcreteCategory.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.7057850278370111, "lm_q1q2_score": 0.46221490407501337}}
{"text": "import .geom1d\n\nopen_locale affine\n\nsection fix_this_name \n\nuniverses u\n\n/-\n3D Geometric Space with Std Coordinate System\n-/\nnoncomputable def std_3d_geom :=  \n    (mk_prod_spc (mk_prod_spc geom1d_std_space geom1d_std_space) geom1d_std_space)\nabbreviation geom3d_frame := std_3d_geom.frame_type\nabbreviation geom3d_space (f : geom3d_frame) := spc real_scalar f\nnoncomputable def geom3d_std_frame := std_3d_geom.frame\nnoncomputable def geom3d_std_space : geom3d_space geom3d_std_frame := std_3d_geom\n\n\n/-\nPositions are points in this space.\n-/\n\n-- public \nstructure position3d {f : geom3d_frame} (s : geom3d_space f ) extends point s\n\n-- public, to enable certain proofs that clients might want to write\n@[ext] lemma position3d.ext : ∀  {f : geom3d_frame} {s : geom3d_space f } (x y : position3d s),\n    x.to_point = y.to_point → x = y :=\n    begin\n        intros f s x y e,\n        cases x,\n        cases y,\n        simp *,\n        have h₁ : ({to_point := x} : position3d s).to_point = x := rfl,\n        simp [h₁] at e,\n        exact e \n    end\n\nnoncomputable def position3d.coords {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) :=\n    λi : fin 3, (p.to_point.coords i).coord\n\n/-\nUser can use coordinates to build an object, but once this is done, the coordinates should\ndisappear inside the object. From there, you should be able to ask the object to return its\ncoordinates *in any given ACS (on the same physical dimension).\n\nnoncomputable def position3d.coords_in_s' {f f': geom3d_frame} {s : geom3d_space f } (p :position3d s) (s' : geom3d_space f' ) :=\n    p.to_point.coords -- should get back (transform p) . coords.\n-/\n\n/-\n\ndef point.expressed_in \n    {dim : ℕ} {id_vec : fin dim → ℕ} {f: fm K dim id_vec} {s : spc K f}  \n    {f2: fm K dim id_vec} {s2 : spc K f2} \n    \n    (p1 : point s) (s2 : spc K f2) : point s2 :=\n    (s.fm_tr s2).transform_point p1\n\ndef vectr.expressed_in \n    {dim : ℕ} {id_vec : fin dim → ℕ} {f: fm K dim id_vec} {s : spc K f}  \n    {f2: fm K dim id_vec} {s2 : spc K f2} \n    \n    (v1 : vectr s) (s2 : spc K f2) : vectr s2 :=\n    (s.fm_tr s2).transform_vectr v1\n-/\n\nnoncomputable def position3d.expressed_in {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) \n    : Π {f' : geom3d_frame} (s' : geom3d_space f' ), position3d s' := \n        λ f' s',\n        ⟨(p.to_point.expressed_in s')⟩\n\n\nnoncomputable def position3d.coords_in {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) \n    : Π {f' : geom3d_frame} (s' : geom3d_space f' ), fin 3 → scalar := \n        λ f' s',\n        λi, ((p.expressed_in s').to_point.coords i).coord\n\nnoncomputable def position3d.x {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) : real_scalar :=\n    (p.to_point.coords 0).coord\n\nnoncomputable def position3d.y {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) : real_scalar :=\n    (p.to_point.coords 1).coord\n\nnoncomputable def position3d.z {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) : real_scalar :=\n    (p.to_point.coords 2).coord\n\nnoncomputable def mk_position3d \n    {f : geom3d_frame} \n    (s : geom3d_space f ) \n    (k₁ k₂ k₃ : real_scalar) : \n    position3d s := \nposition3d.mk (mk_point s ⟨[k₁,k₂,k₃],rfl⟩) \n\n-- Private\n@[simp]\ndef mk_position3d' {f : geom3d_frame} (s : geom3d_space f ) (p : point s) : position3d s := position3d.mk p  \n\n\n\n-- Private\n@[simp]\nnoncomputable def mk_position3d'' {f1 f2 f3 : geom1d_frame } { s1 : geom1d_space f1} {s2 : geom1d_space f2} { s3 : geom1d_space f3}\n    (p1 : position1d s1) (p2 : position1d s2) (p3 : position1d s3 )\n    : position3d (mk_prod_spc (mk_prod_spc s1 s2) s3) :=\n    ⟨mk_point_prod (mk_point_prod p1.to_point p2.to_point) p3.to_point⟩\n    \n/-\nDisplacements are vectors in this affine coordinate space\n-/\n\n-- Public\nstructure displacement3d {f : geom3d_frame} (s : geom3d_space f ) extends vectr s \n@[ext] lemma displacement3d.ext : ∀  {f : geom3d_frame} {s : geom3d_space f } (x y : displacement3d s),\n    x.to_vectr = y.to_vectr → x = y :=\n    begin\n        intros f s x y e,\n        cases x,\n        cases y,\n        simp *,\n        have h₁ : ({to_vectr := x} : displacement3d s).to_vectr = x := rfl,\n        simp [h₁] at e,\n        exact e \n    end\n\n-- Public\ndef displacement3d.frame {f : geom3d_frame} {s : geom3d_space f } (d :displacement3d s) :=\n    f\n\n-- Public\n\nnoncomputable def displacement3d.expressed_in {f : geom3d_frame} {s : geom3d_space f } (p : displacement3d s) \n    : Π {f' : geom3d_frame} (s' : geom3d_space f' ), displacement3d s' := \n        λ f' s',\n        ⟨(p.to_vectr.expressed_in s')⟩\n\n\nnoncomputable def displacement3d.coords_in {f : geom3d_frame} {s : geom3d_space f } (p : displacement3d s) \n    : Π {f' : geom3d_frame} (s' : geom3d_space f' ), fin 3 → scalar := \n        λ f' s',\n        λi, ((p.expressed_in s').to_vectr.coords i).coord\n\n\nnoncomputable def displacement3d.coords {f : geom3d_frame} {s : geom3d_space f } (d :displacement3d s) :=\n    λi : fin 3, (d.to_vectr.coords i).coord\n\nnoncomputable def displacement3d.x {f : geom3d_frame} {s : geom3d_space f } (p :displacement3d s) : real_scalar :=\n    (p.to_vectr.coords 0).coord\n\nnoncomputable def displacement3d.y {f : geom3d_frame} {s : geom3d_space f } (p :displacement3d s) : real_scalar :=\n    (p.to_vectr.coords 1).coord\n\nnoncomputable def displacement3d.z {f : geom3d_frame} {s : geom3d_space f } (p :displacement3d s) : real_scalar :=\n    (p.to_vectr.coords 2).coord\n-- Private\n@[simp]\ndef mk_displacement3d' {f : geom3d_frame} (s : geom3d_space f ) (v : vectr s) : displacement3d s := displacement3d.mk v\n@[simp]\nnoncomputable def mk_displacement3d  {f : geom3d_frame} (s : geom3d_space f ) (k₁ k₂ k₃ : real_scalar) : displacement3d s := displacement3d.mk (mk_vectr s ⟨[k₁,k₂,k₃],rfl⟩) \n\n-- Private\n@[simp]\nnoncomputable def mk_displacement3d'' {f1 f2 f3 : geom1d_frame } { s1 : geom1d_space f1} {s2 : geom1d_space f2} { s3 : geom1d_space f3}\n    (p1 : displacement1d s1) (p2 : displacement1d s2) (p3 : displacement1d s3 )\n    : displacement3d (mk_prod_spc (mk_prod_spc s1 s2) s3) :=\n    ⟨mk_vectr_prod (mk_vectr_prod p1.to_vectr p2.to_vectr) p3.to_vectr⟩\n\n\n-- Public\n@[simp]\nnoncomputable def mk_geom3d_frame {parent : geom3d_frame} {s : spc real_scalar parent} (p : position3d s) \n    (v0 : displacement3d s) (v1 : displacement3d s) (v2 : displacement3d s)\n    : geom3d_frame :=\n    (mk_frame p.to_point ⟨(λi, if i = 0 then v0.to_vectr else if i = 1 then v1.to_vectr else v2.to_vectr),sorry,sorry⟩)\n\n-- Public\n@[simp]\nnoncomputable def mk_geom3d_space (fr : geom3d_frame) : geom3d_space _ := mk_space fr\n\n\nend fix_this_name\n\nsection fix_this_name_too \n\n/-\nProof that geom3d is an affine coordinate space\n-/\n\nnamespace geom3d\nvariables {f : geom3d_frame} {s : geom3d_space f } \n@[simp]\nnoncomputable def add_displacement3d_displacement3d (v3 v2 : displacement3d s) : displacement3d s := \n    mk_displacement3d' s (v3.to_vectr + v2.to_vectr)\n@[simp]\nnoncomputable def smul_displacement3d (k : real_scalar) (v : displacement3d s) : displacement3d s := \n    mk_displacement3d' s (k • v.to_vectr)\n@[simp]\nnoncomputable def neg_displacement3d (v : displacement3d s) : displacement3d s := \n    mk_displacement3d' s ((-1 : real_scalar) • v.to_vectr)\n@[simp]\nnoncomputable def sub_displacement3d_displacement3d (v3 v2 : displacement3d s) : displacement3d s :=    -- v3-v2\n    add_displacement3d_displacement3d v3 (neg_displacement3d v2)\n\nnoncomputable instance has_add_displacement3d : has_add (displacement3d s) := ⟨ add_displacement3d_displacement3d ⟩\nlemma add_assoc_displacement3d : ∀ a b c : displacement3d s, a + b + c = a + (b + c) := begin\n    intros,\n    ext,\n    dsimp only [has_add.add],\n    dsimp only [add_displacement3d_displacement3d, has_add.add],\n    dsimp only [add_vectr_vectr, has_add.add],\n    dsimp only [add_vec_vec, mk_displacement3d', mk_vectr'],\n    simp only [add_assoc],\nend\nnoncomputable instance add_semigroup_displacement3d : add_semigroup (displacement3d s) := ⟨ add_displacement3d_displacement3d, add_assoc_displacement3d⟩ \n@[simp]\nnoncomputable def displacement3d_zero  := mk_displacement3d s 0 0 0\nnoncomputable instance : inhabited (displacement3d s) := ⟨displacement3d_zero⟩\nnoncomputable instance has_zero_displacement3d : has_zero (displacement3d s) := ⟨displacement3d_zero⟩\n\nlemma zero_add_displacement3d : ∀ a : displacement3d s, 0 + a = a := \nbegin\n    intros,\n    ext,\n    dsimp only [has_zero.zero, has_add.add],\n    dsimp only [add_displacement3d_displacement3d, displacement3d_zero, mk_displacement3d', mk_displacement3d, has_add.add],\n    dsimp only [add_vectr_vectr, mk_vectr', mk_vectr, mk_vec_n, has_add.add],\n    dsimp only [add_vec_vec, mk_vec, vector.nth],\n    cases x,\n    dsimp only [fin.mk],\n    cases x_val with x',\n    simp only [list.nth_le, zero_add],\n    simp only [add_left_eq_self, list.nth_le],\n    cases x' with x'',\n    simp only [list.nth_le, zero_add],\n    simp only [add_left_eq_self, list.nth_le],\n    cases x'' with x''',\n    simp only [list.nth_le, zero_add],\n    have h₀ : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h₁ : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h₀, h₁] at x_property,\n    have h₂ : x'''.succ + 3 ≤ 0 + 3 := begin\n        dsimp only [has_lt.lt, nat.lt] at x_property,\n        dsimp only [has_le.le],\n        exact x_property,\n    end,\n    have h₃ := (add_le_add_iff_right 3).1 h₂,\n    simp only [nat.not_succ_le_zero] at h₃,\n    contradiction,\nend\n\nlemma add_zero_displacement3d : ∀ a : displacement3d s, a + 0 = a := \nbegin\n    intros,\n    ext,\n    dsimp only [has_zero.zero, has_add.add],\n    dsimp only [add_displacement3d_displacement3d, displacement3d_zero, mk_displacement3d', mk_displacement3d, has_add.add],\n    dsimp only [add_vectr_vectr, mk_vectr', mk_vectr, mk_vec_n, has_add.add],\n    dsimp only [add_vec_vec, mk_vec, vector.nth],\n    cases x,\n    dsimp only [fin.mk],\n    cases x_val with x',\n    simp only [list.nth_le, add_zero],\n    simp only [add_left_eq_self, list.nth_le],\n    cases x' with x'',\n    simp only [list.nth_le, add_zero],\n    simp only [add_left_eq_self, list.nth_le],\n    cases x'' with x''',\n    simp only [list.nth_le, add_zero],\n    have h₀ : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h₁ : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h₀, h₁] at x_property,\n    have h₂ : x'''.succ + 3 ≤ 0 + 3 := begin\n        dsimp only [has_lt.lt, nat.lt] at x_property,\n        dsimp only [has_le.le],\n        exact x_property,\n    end,\n    have h₃ := (add_le_add_iff_right 3).1 h₂,\n    simp only [nat.not_succ_le_zero] at h₃,\n    contradiction,\nend\n\n@[simp]\nnoncomputable def nsmul_displacement3d : ℕ → (displacement3d s) → (displacement3d s) \n| nat.zero v := displacement3d_zero\n--| 3 v := v\n| (nat.succ n) v := (add_displacement3d_displacement3d) v (nsmul_displacement3d n v)\n\nnoncomputable instance add_monoid_displacement3d : add_monoid (displacement3d s) := ⟨ \n    -- add_semigroup\n    add_displacement3d_displacement3d, \n    add_assoc_displacement3d, \n    -- has_zero\n    displacement3d_zero,\n    -- new structure \n    @zero_add_displacement3d f s, \n    add_zero_displacement3d,\n    nsmul_displacement3d,\n    begin\n        admit\n    end,\n    begin\n        admit\n    end\n⟩\n\nnoncomputable instance has_neg_displacement3d : has_neg (displacement3d s) := ⟨neg_displacement3d⟩\nnoncomputable instance has_sub_displacement3d : has_sub (displacement3d s) := ⟨ sub_displacement3d_displacement3d⟩ \nlemma sub_eq_add_neg_displacement3d : ∀ a b : displacement3d s, a - b = a + -b := \nbegin\n    intros,ext,\n    refl,\nend \n\nnoncomputable instance sub_neg_monoid_displacement3d : sub_neg_monoid (displacement3d s) := \n{\n    neg := neg_displacement3d ,\n    ..(show add_monoid (displacement3d s), by apply_instance)\n}\n\nlemma add_left_neg_displacement3d : ∀ a : displacement3d s, -a + a = 0 := \nbegin\n    intros,\n    ext,\n    dsimp only [has_zero.zero, has_add.add, has_neg.neg],\n    dsimp only [neg_displacement3d, has_scalar.smul],\n    dsimp only [add_displacement3d_displacement3d, smul_vectr, has_add.add, has_scalar.smul],\n    dsimp only [add_vectr_vectr, smul_vec, mk_displacement3d', mk_vectr', has_add.add],\n    dsimp only [add_vec_vec],\n    simp only [neg_mul_eq_neg_mul_symm, one_mul, mk_vectr, displacement3d_zero, mk_displacement3d, add_left_neg],\n    dsimp only [mk_vec_n, mk_vec, vector.nth],\n    cases x,\n    dsimp only [fin.mk],\n    cases x_val with x',\n    simp only [list.nth_le],\n    simp only [add_left_eq_self, list.nth_le],\n    cases x' with x'',\n    simp only [list.nth_le],\n    simp only [add_left_eq_self, list.nth_le],\n    cases x'' with x''',\n    simp only [list.nth_le],\n    have h₀ : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h₁ : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h₀, h₁] at x_property,\n    have h₂ : x'''.succ + 3 ≤ 0 + 3 := begin\n        dsimp only [has_lt.lt, nat.lt] at x_property,\n        dsimp only [has_le.le],\n        exact x_property,\n    end,\n    have h₃ := (add_le_add_iff_right 3).1 h₂,\n    simp only [nat.not_succ_le_zero] at h₃,\n    contradiction,\nend\n\nnoncomputable instance : add_group (displacement3d s) := {\n    add_left_neg := begin\n        exact add_left_neg_displacement3d,\n    end,\n..(show sub_neg_monoid (displacement3d s), by apply_instance),\n\n}\n\nlemma add_comm_displacement3d : ∀ a b : displacement3d s, a + b = b + a :=\nbegin\n    intros,\n    ext,\n    dsimp only [has_add.add],\n    dsimp only [add_displacement3d_displacement3d, has_add.add],\n    dsimp only [add_vectr_vectr, has_add.add],\n    dsimp only [add_vec_vec, mk_displacement3d', mk_vectr'],\n    simp only [add_comm],\nend\nnoncomputable instance add_comm_semigroup_displacement3d : add_comm_semigroup (displacement3d s) := ⟨\n    -- add_semigroup\n    add_displacement3d_displacement3d, \n    add_assoc_displacement3d,\n    add_comm_displacement3d,\n⟩\n\nnoncomputable instance add_comm_monoid_displacement3d : add_comm_monoid (displacement3d s) := {\n    add_comm := begin\n        exact add_comm_displacement3d\n    end, \n    ..(show add_monoid (displacement3d s), by apply_instance)\n}\n\nnoncomputable instance has_scalar_displacement3d : has_scalar real_scalar (displacement3d s) := ⟨\nsmul_displacement3d,\n⟩\n\nlemma one_smul_displacement3d : ∀ b : displacement3d s, (1 : real_scalar) • b = b := begin\n    intros,\n    ext,\n    dsimp only [has_scalar.smul],\n    dsimp only [smul_displacement3d, has_scalar.smul],\n    dsimp only [smul_vectr, has_scalar.smul],\n    dsimp only [smul_vec, mk_displacement3d', mk_vectr'],\n    simp only [one_mul],\nend\nlemma mul_smul_displacement3d : ∀ (x y : real_scalar) (b : displacement3d s), (x * y) • b = x • y • b := \nbegin\n    intros,\n    cases b,\n    ext,\n    exact mul_assoc x y _,\nend\n\nnoncomputable instance mul_action_displacement3d : mul_action real_scalar (displacement3d s) := ⟨\none_smul_displacement3d,\nmul_smul_displacement3d,\n⟩ \n\nlemma smul_add_displacement3d : ∀(r : real_scalar) (x y : displacement3d s), r • (x + y) = r • x + r • y := begin\n    intros,\n    ext,\n    dsimp only [has_scalar.smul, has_add.add],\n    dsimp only [smul_displacement3d, add_displacement3d_displacement3d, has_scalar.smul, has_add.add],\n    dsimp only [smul_vectr, add_vectr_vectr, has_scalar.smul, has_add.add],\n    dsimp only [smul_vec, add_vec_vec, mk_displacement3d', mk_vectr'],\n    simp only [distrib.left_distrib],\n    refl,\nend\nlemma smul_zero_displacement3d : ∀(r : real_scalar), r • (0 : displacement3d s) = 0 := begin\n    intros,\n    ext,\n    dsimp only [has_scalar.smul, has_zero.zero],\n    dsimp only [smul_displacement3d, displacement3d_zero, has_scalar.smul],\n    dsimp only [smul_vectr, has_scalar.smul],\n    dsimp only [smul_vec, mk_displacement3d', mk_vectr', mk_displacement3d, mk_vectr, mk_vec_n, mk_vec, vector.nth],\n    cases x,\n    dsimp only [fin.mk],\n    cases x_val with x',\n    simp only [list.nth_le, mul_zero],\n    simp only [list.nth_le],\n    cases x' with x'',\n    simp only [list.nth_le, mul_zero],\n    simp only [list.nth_le],\n    cases x'' with x''',\n    simp only [list.nth_le, mul_zero],\n    have h₀ : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h₁ : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h₀, h₁] at x_property,\n    have h₂ : x'''.succ + 3 ≤ 0 + 3 := begin\n        dsimp only [has_lt.lt, nat.lt] at x_property,\n        dsimp only [has_le.le],\n        exact x_property,\n    end,\n    have h₃ := (add_le_add_iff_right 3).1 h₂,\n    simp only [nat.not_succ_le_zero] at h₃,\n    contradiction,\nend\nnoncomputable instance distrib_mul_action_K_displacement3d : distrib_mul_action real_scalar (displacement3d s) := ⟨\nsmul_add_displacement3d,\nsmul_zero_displacement3d,\n⟩ \n\n-- renaming vs template due to clash with name \"s\" for prevailing variable\nlemma add_smul_displacement3d : ∀ (a b : real_scalar) (x : displacement3d s), (a + b) • x = a • x + b • x := \nbegin\n  intros,\n  ext,\n  exact right_distrib _ _ _,\nend\nlemma zero_smul_displacement3d : ∀ (x : displacement3d s), (0 : real_scalar) • x = 0 := begin\n    intros,\n    ext,\n    dsimp only [has_scalar.smul, has_zero.zero],\n    dsimp only [smul_displacement3d, displacement3d_zero, has_scalar.smul],\n    dsimp only [smul_vectr, has_scalar.smul],\n    dsimp only [smul_vec, mk_displacement3d', mk_vectr', mk_displacement3d, mk_vectr, mk_vec_n, mk_vec, vector.nth],\n    cases x_1,\n    dsimp only [fin.mk],\n    cases x_1_val with x',\n    simp only [list.nth_le, mul_eq_zero],\n    apply or.inl,\n    refl,\n    simp only [list.nth_le],\n    cases x' with x'',\n    simp only [list.nth_le, mul_eq_zero],\n    apply or.inl,\n    refl,\n    simp only [list.nth_le],\n    cases x'' with x''',\n    simp only [list.nth_le, mul_eq_zero],\n    apply or.inl,\n    refl,\n    have h₀ : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h₁ : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h₀, h₁] at x_1_property,\n    have h₂ : x'''.succ + 3 ≤ 0 + 3 := begin\n        dsimp only [has_lt.lt, nat.lt] at x_1_property,\n        dsimp only [has_le.le],\n        exact x_1_property,\n    end,\n    have h₃ := (add_le_add_iff_right 3).1 h₂,\n    simp only [nat.not_succ_le_zero] at h₃,\n    contradiction,\nend\nnoncomputable instance module_K_displacement3d : module real_scalar (displacement3d s) := ⟨ add_smul_displacement3d, zero_smul_displacement3d ⟩ \n\nnoncomputable instance add_comm_group_displacement3d : add_comm_group (displacement3d s) := {\n    add_comm := begin\n        exact add_comm_displacement3d\n    end,\n..(show add_group (displacement3d s), by apply_instance)\n}\nnoncomputable instance : module real_scalar (displacement3d s) := @geom3d.module_K_displacement3d f s\n\n\n/-\n    ********************\n    *** Affine space ***\n    ********************\n-/\n\n\n/-\nAffine operations\n-/\nnoncomputable instance : has_add (displacement3d s) := ⟨add_displacement3d_displacement3d⟩\nnoncomputable instance : has_zero (displacement3d s) := ⟨displacement3d_zero⟩\nnoncomputable instance : has_neg (displacement3d s) := ⟨neg_displacement3d⟩\n\n/-\nLemmas needed to implement affine space API\n-/\n@[simp]\nnoncomputable def sub_position3d_position3d {f : geom3d_frame} {s : geom3d_space f } (p3 p2 : position3d s) : displacement3d s := \n    mk_displacement3d' s (p3.to_point -ᵥ p2.to_point)\n@[simp]\nnoncomputable def add_position3d_displacement3d {f : geom3d_frame} {s : geom3d_space f } (p : position3d s) (v : displacement3d s) : position3d s := \n    mk_position3d' s (v.to_vectr +ᵥ p.to_point) -- reorder assumes order is irrelevant\n@[simp]\nnoncomputable def add_displacement3d_position3d {f : geom3d_frame} {s : geom3d_space f } (v : displacement3d s) (p : position3d s) : position3d s := \n    mk_position3d' s (v.to_vectr +ᵥ p.to_point)\n--@[simp]\n--def aff_displacement3d_group_action : displacement3d s → position3d s → position3d s := add_displacement3d_position3d real_scalar\nnoncomputable instance : has_vadd (displacement3d s) (position3d s) := ⟨add_displacement3d_position3d⟩\n\nlemma zero_displacement3d_vadd'_a3 : ∀ p : position3d s, (0 : displacement3d s) +ᵥ p = p := begin\n    intros,\n    ext,\n    dsimp only [has_vadd.vadd, has_zero.zero],\n    dsimp only [add_displacement3d_position3d, displacement3d_zero, has_vadd.vadd],\n    dsimp only [add_vectr_point, has_vadd.vadd],\n    dsimp only [aff_vec_group_action, add_vec_pt, mk_position3d', mk_point', mk_displacement3d, mk_vectr, mk_vec_n, mk_vec, vector.nth],\n    cases x,\n    dsimp only [fin.mk],\n    cases x_val with x',\n    simp only [list.nth_le, add_zero],\n    simp only [list.nth_le],\n    cases x' with x'',\n    simp only [list.nth_le, add_zero],\n    simp only [list.nth_le],\n    cases x'' with x''',\n    simp only [list.nth_le, add_zero],\n    have h₀ : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h₁ : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h₀, h₁] at x_property,\n    have h₂ : x'''.succ + 3 ≤ 0 + 3 := begin\n        dsimp only [has_lt.lt, nat.lt] at x_property,\n        dsimp only [has_le.le],\n        exact x_property,\n    end,\n    have h₃ := (add_le_add_iff_right 3).1 h₂,\n    simp only [nat.not_succ_le_zero] at h₃,\n    contradiction,\nend\nlemma displacement3d_add_assoc'_a3 : ∀ (g3 g2 : displacement3d s) (p : position3d s), g3 +ᵥ (g2 +ᵥ p) = (g3 + g2) +ᵥ p := begin\n    intros,\n    ext,\n    dsimp only [has_add.add, has_vadd.vadd],\n    dsimp only [add_displacement3d_position3d, add_displacement3d_displacement3d, has_add.add, has_vadd.vadd],\n    dsimp only [add_vectr_point, add_vectr_vectr, has_add.add, has_vadd.vadd],\n    dsimp only [aff_vec_group_action, add_vec_vec, add_vec_pt, mk_position3d', mk_point', mk_displacement3d', mk_vectr'],\n    simp only [add_assoc, add_right_inj],\n    simp only [add_comm],\nend\n\n\nnoncomputable instance displacement3d_add_action: add_action (displacement3d s) (position3d s) := \n⟨ zero_displacement3d_vadd'_a3, \nbegin\n    let h0 := displacement3d_add_assoc'_a3,\n    intros,\n    exact (h0 g₁ g₂ p).symm\nend⟩ \n--@[simp]\n\nnoncomputable instance position3d_has_vsub : has_vsub (displacement3d s) (position3d s) := ⟨ sub_position3d_position3d⟩ \n\ninstance : nonempty (position3d s) := ⟨mk_position3d s 0 0 0⟩\nnoncomputable instance : inhabited (position3d s) := ⟨mk_position3d s 0 0 0⟩\n\nlemma position3d_vsub_vadd_a3 : ∀ (p3 p2 : (position3d s)), (p3 -ᵥ p2) +ᵥ p2 = p3 := begin\n    intros,\n    ext,\n    dsimp only [has_vsub.vsub, has_vadd.vadd],\n    dsimp only [add_displacement3d_position3d, sub_position3d_position3d, has_vsub.vsub, has_vadd.vadd],\n    dsimp only [add_vectr_point, aff_point_group_sub, sub_point_point, has_vsub.vsub, has_vadd.vadd],\n    dsimp only [aff_vec_group_action, aff_point_group_sub, add_vec_pt, aff_pt_group_sub, sub_pt_pt, mk_position3d', mk_point', mk_displacement3d', mk_vectr'],\n    simp only [add_sub_cancel'_right],\nend\nlemma position3d_vadd_vsub_a3 : ∀ (g : displacement3d s) (p : position3d s), g +ᵥ p -ᵥ p = g := \nbegin\n    intros, ext,\n    repeat {\n    have h0 : ((g +ᵥ p -ᵥ p) : displacement3d s).to_vectr = (g.to_vectr +ᵥ p.to_point -ᵥ p.to_point) := rfl,\n    rw h0,\n    simp *,\n    }\n    \nend\n\nnoncomputable instance aff_geom3d_torsor : add_torsor (displacement3d s) (position3d s) := \n⟨ \n    begin\n        exact position3d_vsub_vadd_a3,\n    end,\n    begin\n        exact position3d_vadd_vsub_a3,\n    end,\n⟩\n\nopen_locale affine\n\nnoncomputable instance : affine_space (displacement3d s) (position3d s) := @geom3d.aff_geom3d_torsor f s\n\nend geom3d -- ha ha\n\n\nend fix_this_name_too\n\n/-\nTransformations in 3d geometric space\n-/\n\n/-\nNewer version\nTradeoff - Does not directly extend from affine equiv. Base class is an equiv on points and vectrs\nExtension methods are provided to directly transform Times and Duration between frames\n-/\n@[ext]\nstructure geom3d_transform {f3 : geom3d_frame} {f2 : geom3d_frame} (sp3 : geom3d_space f3) (sp2 : geom3d_space f2)\n  extends fm_tr sp3 sp2\n\n\nnoncomputable def geom3d_space.mk_geom3d_transform_to {f3 : geom3d_frame} (s3 : geom3d_space f3) : Π {f2 : geom3d_frame} (s2 : geom3d_space f2), \n        geom3d_transform s3 s2 := --(position3d s2) ≃ᵃ[scalar] (position3d s3) := \n    λ f2 s2,\n        ⟨s3.fm_tr s2⟩\n\n\nnoncomputable instance g3tr_inh {f3 : geom3d_frame} {f2 : geom3d_frame} (sp3 : geom3d_space f3) (sp2 : geom3d_space f2) \n    : inhabited (geom3d_transform  sp3 sp2) := ⟨sp3.mk_geom3d_transform_to sp2⟩\n\n\nnoncomputable def geom3d_transform.symm \n    {f3 : geom3d_frame} {f2 : geom3d_frame} {sp3 : geom3d_space f3} {sp2 : geom3d_space f2} (ttr : geom3d_transform sp3 sp2)\n    : geom3d_transform sp2 sp3 := ⟨(ttr.1).symm⟩\n\n\nnoncomputable def geom3d_transform.trans \n    {f1 : geom3d_frame} {f2 : geom3d_frame} {f3 : geom3d_frame} {sp1 : geom3d_space f1} {sp2 : geom3d_space f2} {sp3 : geom3d_space f3} \n    (ttr : geom3d_transform sp1 sp2)\n    : geom3d_transform sp2 sp3 → geom3d_transform sp1 sp3 := λttr_, ⟨(ttr.1).trans ttr_.1⟩\n\nnoncomputable def geom3d_transform.transform_position3d\n    {f3 : geom3d_frame} {s3 : geom3d_space f3}\n    {f2 : geom3d_frame} {s2 : geom3d_space f2}\n    (tr: geom3d_transform s3 s2 ) : position3d s3 → position3d s2 :=\n    λt : position3d s3,\n    ⟨tr.to_fm_tr.to_equiv t.to_point⟩\n\nnoncomputable def geom3d_transform.transform_displacement3d\n    {f3 : geom3d_frame} {s3 : geom3d_space f3}\n    {f2 : geom3d_frame} {s2 : geom3d_space f2}\n    (tr: geom3d_transform s3 s2 ) : displacement3d s3 → displacement3d s2 :=\n    λd,\n    let as_pt : point s3 := ⟨λi, mk_pt real_scalar (d.coords i).coord⟩ in\n    let tr_pt := (tr.to_equiv as_pt) in\n    ⟨⟨λi, mk_vec real_scalar (tr_pt.coords i).coord⟩⟩\n\n\n/-\nOrientation in 3D\n-/\n\n\nvariables {f : geom3d_frame} (s : geom3d_space f )\n\n/-\nBackground for the following definition:\n\nIn an orientation object, id_vec keeps track of the\nphysical dimension to which each basis vector belongs,\nallowing us to represent things like the product of a\ngeometric space and a time space. \n\norientation : Π {dim : ℕ} {id_vec : fin dim → ℕ} {f : fm K dim id_vec}, spc K f → Type\n-/\n\nstructure orientation3d extends orientation s :=\nmk ::\n\nnoncomputable instance o3i : inhabited (orientation3d s) := ⟨\n    ⟨mk_orientation s (λi, mk_vectr s ⟨[0,0,0],rfl⟩)⟩\n⟩\n\nnoncomputable def mk_orientation3d' /-(s1 s2 s3 s4 s5 s6 s7 s8 s9 : real_scalar)-/\n    (ax1 : displacement3d s) (ax2 : displacement3d s) (ax3 : displacement3d s)\n    --: orientation3d s := ⟨mk_orientation s (λi, if i.1 = 0 then (mk_displacement3d s s1 s2 s3).to_vectr else \n    --                                            if i.1 = 1 then (mk_displacement3d s s4 s5 s6).to_vectr \n    --                                            else (mk_displacement3d s s7 s8 s9).to_vectr )⟩\n\n    : orientation3d s := ⟨mk_orientation s (λi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )⟩\n\n\nnoncomputable def mk_orientation3d (s1 s2 s3 s4 s5 s6 s7 s8 s9 : real_scalar)\n    : orientation3d s := ⟨mk_orientation s (λi, if i.1 = 0 then (mk_displacement3d s s1 s2 s3).to_vectr else \n                                                if i.1 = 1 then (mk_displacement3d s s4 s5 s6).to_vectr \n                                                else (mk_displacement3d s s7 s8 s9).to_vectr )⟩\n\n/-\nR = Ry(1)*Rx(2)*Rz(3)\n  = | cos 1*cos 3+sin 1*sin 2*sin 3  cos 3*sin 1*sin 2-sin 3*cos 1  cos 2*sin 1 |\n    |                   cos 2*sin 3                    cos 3*cos 2       -sin 2 |\n    | sin 3*cos 1*sin 2-sin 1*cos 3  sin 1*sin 3+cos 3*cos 1*sin 2  cos 2*cos 1 |\n-/\n--okay, i can fill in this function now...\nnoncomputable def mk_orientation3d_from_euler_angles (s1 s2 s3 : real_scalar)--(ax1 : displacement3d s) (ax2 : displacement3d s) (ax3 : displacement3d s)\n    : orientation3d s := ⟨mk_orientation s \n        (λi, if i.1 = 0 then (mk_displacement3d s \n            ((real.cos s1)*(real.cos s3) + (real.sin s1*(real.sin s2)*(real.sin s3))) ((real.cos s3)*(real.sin s1)*(real.sin s2) - (real.sin s3)*(real.cos s1)) ((real.cos s2)*(real.sin s1))).to_vectr \n        else if i.1 = 1 then (mk_displacement3d s \n            ((real.cos s2)*(real.sin s3)) ((real.cos s3)*(real.cos s2)) (-(real.sin s2))).to_vectr \n        else (mk_displacement3d s \n            ((real.sin s3)*(real.cos s1)*(real.sin s2) - (real.sin s1)*(real.cos s3)) ((real.sin s1)*(real.sin s3) + (real.cos s3)*(real.cos s1)*(real.sin s2)) ((real.cos s2)*(real.cos s1))).to_vectr )⟩\n\n\nnoncomputable def mk_orientation3d_from_quaternion (s1 s2 s3 s4 : real_scalar)--(ax1 : displacement3d s) (ax2 : displacement3d s) (ax3 : displacement3d s)\n    : orientation3d s := mk_orientation3d s \n        (2*(s1*s1 + s2*s2) - 1) (2*(s2*s3 - s1*s4)) (2*(s2*s4 + s1*s3))\n        (2*(s2*s3 + s1*s4)) (2*(s1*s1 + s3*s3)) (2*(s3*s4 - s1*s2))\n        (2*(s2*s4 - s1*s3)) (2*(s3*s4 + s1*s2)) (2*(s1*s1 + s1*s1 + s4*s4) - 1)\n    --: orientation3d s := ⟨mk_orientation s (λi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )⟩\n\nnoncomputable def geom3d_transform.transform_orientation\n    {f3 : geom3d_frame} {s3 : geom3d_space f3}\n    {f2 : geom3d_frame} {s2 : geom3d_space f2}\n    (tr: geom3d_transform s3 s2 ) : orientation3d s3 → orientation3d s2 :=\n    λo : orientation3d s3,\n    ⟨mk_orientation s2 \n        (λi, if i.1 = 0 then (tr.to_fm_tr.transform_vectr (o.to_orientation.to_vectr_basis.basis_vectrs ⟨0,by linarith⟩)) \n        else if i.1 = 1 then (tr.to_fm_tr.transform_vectr (o.to_orientation.to_vectr_basis.basis_vectrs ⟨1,by linarith⟩))\n        else (tr.to_fm_tr.transform_vectr (o.to_orientation.to_vectr_basis.basis_vectrs ⟨2,by linarith⟩)) )⟩\n\n\n   -- ⟨tr.to_fm_tr.transform_orientation o.to_orientation⟩⟩\n\n\n/-\nRotations\n-/\n\nstructure rotation3d extends rotation s :=\nmk ::\n\n/-\nnoncomputable def mk_rotation3d (ax1 : displacement3d s) (ax2 : displacement3d s) (ax3 : displacement3d s)\n    : rotation3d s := ⟨mk_rotation s (λi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )⟩\n-/\nnoncomputable def mk_rotation3d (s1 s2 s3 s4 s5 s6 s7 s8 s9 : real_scalar)--(ax1 : displacement3d s) (ax2 : displacement3d s) (ax3 : displacement3d s)\n    : rotation3d s := ⟨mk_rotation s (λi, if i.1 = 0 then (mk_displacement3d s s1 s2 s3).to_vectr else if i.1 = 1 then (mk_displacement3d s s4 s5 s6).to_vectr else (mk_displacement3d s s7 s8 s9).to_vectr )⟩\n\nnoncomputable instance r3i : inhabited (rotation3d s) := ⟨\n    mk_rotation3d s 1 1 1 1 1 1 1 1 1\n⟩\n\nnoncomputable def mk_rotation3d_from_quaternion (s1 s2 s3 s4 : real_scalar)--(ax1 : displacement3d s) (ax2 : displacement3d s) (ax3 : displacement3d s)\n    : rotation3d s := mk_rotation3d s \n        (2*(s1*s1 + s2*s2) - 1) (2*(s2*s3 - s1*s4)) (2*(s2*s4 + s1*s3))\n        (2*(s2*s3 + s1*s4)) (2*(s1*s1 + s3*s3)) (2*(s3*s4 - s1*s2))\n        (2*(s2*s4 - s1*s3)) (2*(s3*s4 + s1*s2)) (2*(s1*s1 + s1*s1 + s4*s4) - 1)\n    --: orientation3d s := ⟨mk_orientation s (λi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )⟩\n\n\n/-\nPoses\n-/\n\nstructure pose3d :=\nmk ::\n    (orientation : orientation3d s)\n    (position : position3d s)\n\ndef mk_pose3d (orientation : orientation3d s)\n    (position : position3d s) : pose3d s := ⟨orientation,position⟩\n \n noncomputable instance p3i : inhabited (pose3d s) := ⟨\n    (\n    mk_pose3d _ \n    (mk_orientation3d _ 0 0 0 0 0 0 0 0 0)\n    (mk_position3d _ 0 0 0)\n    )\n⟩\n\n\nnoncomputable def geom3d_transform.transform_pose3d\n    {f3 : geom3d_frame} {s3 : geom3d_space f3}\n    {f2 : geom3d_frame} {s2 : geom3d_space f2}\n    (tr: geom3d_transform s3 s2 ) : pose3d s3 → pose3d s2 :=\n    λp :_,\n    (⟨tr.transform_orientation p.orientation, tr.transform_position3d p.position⟩:pose3d s2)\n\n\nnotation tr⬝t := geom3d_transform.transform_pose3d tr t\n\n\nnoncomputable def geom3d_transform.translation \n    {f3 : geom3d_frame} {s3 : geom3d_space f3}\n    {f2 : geom3d_frame} {s2 : geom3d_space f2}\n    (tr: geom3d_transform s3 s2 ) : geom3d_transform s3 s2 → displacement3d s2 :=\n    inhabited.default _ /- how to fill this in -/\n\nnoncomputable def geom3d_transform.rotation \n    {f3 : geom3d_frame} {s3 : geom3d_space f3}\n    {f2 : geom3d_frame} {s2 : geom3d_space f2}\n    (tr: geom3d_transform s3 s2 ) : geom3d_transform s3 s2 → orientation3d s2 :=\n    inhabited.default _ /- how to fill this in -/", "meta": {"author": "kevinsullivan", "repo": "phys", "sha": "ebc2df3779d3605ff7a9b47eeda25c2a551e011f", "save_path": "github-repos/lean/kevinsullivan-phys", "path": "github-repos/lean/kevinsullivan-phys/phys-ebc2df3779d3605ff7a9b47eeda25c2a551e011f/geom/geom3d.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370111, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.46221489456730985}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Johan Commelin, Bhavik Mehta\n-/\nimport category_theory.isomorphism\nimport category_theory.functor_category\nimport category_theory.eq_to_hom\n\n/-!\n# Comma categories\n\nA comma category is a construction in category theory, which builds a category out of two functors\nwith a common codomain. Specifically, for functors `L : A ⥤ T` and `R : B ⥤ T`, an object in\n`comma L R` is a morphism `hom : L.obj left ⟶ R.obj right` for some objects `left : A` and\n`right : B`, and a morphism in `comma L R` between `hom : L.obj left ⟶ R.obj right` and\n`hom' : L.obj left' ⟶ R.obj right'` is a commutative square\n\n```\nL.obj left   ⟶   L.obj left'\n      |               |\n  hom |               | hom'\n      ↓               ↓\nR.obj right  ⟶   R.obj right',\n```\n\nwhere the top and bottom morphism come from morphisms `left ⟶ left'` and `right ⟶ right'`,\nrespectively.\n\n## Main definitions\n\n* `comma L R`: the comma category of the functors `L` and `R`.\n* `over X`: the over category of the object `X` (developed in `over.lean`).\n* `under X`: the under category of the object `X` (also developed in `over.lean`).\n* `arrow T`: the arrow category of the category `T` (developed in `arrow.lean`).\n\n## References\n\n* <https://ncatlab.org/nlab/show/comma+category>\n\n## Tags\n\ncomma, slice, coslice, over, under, arrow\n-/\n\n\nnamespace category_theory\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v₁ v₂ v₃ v₄ v₅ u₁ u₂ u₃ u₄ u₅\nvariables {A : Type u₁} [category.{v₁} A]\nvariables {B : Type u₂} [category.{v₂} B]\nvariables {T : Type u₃} [category.{v₃} T]\n\n/-- The objects of the comma category are triples of an object `left : A`, an object\n   `right : B` and a morphism `hom : L.obj left ⟶ R.obj right`.  -/\nstructure comma (L : A ⥤ T) (R : B ⥤ T) : Type (max u₁ u₂ v₃) :=\n(left : A . obviously)\n(right : B . obviously)\n(hom : L.obj left ⟶ R.obj right)\n\n-- Satisfying the inhabited linter\ninstance comma.inhabited [inhabited T] : inhabited (comma (𝟭 T) (𝟭 T)) :=\n{ default :=\n  { left := default T,\n    right := default T,\n    hom := 𝟙 (default T) } }\n\nvariables {L : A ⥤ T} {R : B ⥤ T}\n\n/-- A morphism between two objects in the comma category is a commutative square connecting the\n    morphisms coming from the two objects using morphisms in the image of the functors `L` and `R`.\n-/\n@[ext] structure comma_morphism (X Y : comma L R) :=\n(left : X.left ⟶ Y.left . obviously)\n(right : X.right ⟶ Y.right . obviously)\n(w' : L.map left ≫ Y.hom = X.hom ≫ R.map right . obviously)\n\n-- Satisfying the inhabited linter\ninstance comma_morphism.inhabited [inhabited (comma L R)] :\n  inhabited (comma_morphism (default (comma L R)) (default (comma L R))) :=\n{ default :=\n  { left := 𝟙 _,\n    right := 𝟙 _ } }\n\nrestate_axiom comma_morphism.w'\nattribute [simp, reassoc] comma_morphism.w\n\ninstance comma_category : category (comma L R) :=\n{ hom := comma_morphism,\n  id := λ X,\n  { left := 𝟙 X.left,\n    right := 𝟙 X.right },\n  comp := λ X Y Z f g,\n  { left := f.left ≫ g.left,\n    right := f.right ≫ g.right } }\n\nnamespace comma\n\nsection\nvariables {X Y Z : comma L R} {f : X ⟶ Y} {g : Y ⟶ Z}\n\n@[simp] lemma id_left  : ((𝟙 X) : comma_morphism X X).left = 𝟙 X.left := rfl\n@[simp] lemma id_right : ((𝟙 X) : comma_morphism X X).right = 𝟙 X.right := rfl\n@[simp] lemma comp_left  : (f ≫ g).left  = f.left ≫ g.left   := rfl\n@[simp] lemma comp_right : (f ≫ g).right = f.right ≫ g.right := rfl\n\nend\n\nvariables (L) (R)\n\n/-- The functor sending an object `X` in the comma category to `X.left`. -/\n@[simps]\ndef fst : comma L R ⥤ A :=\n{ obj := λ X, X.left,\n  map := λ _ _ f, f.left }\n\n/-- The functor sending an object `X` in the comma category to `X.right`. -/\n@[simps]\ndef snd : comma L R ⥤ B :=\n{ obj := λ X, X.right,\n  map := λ _ _ f, f.right }\n\n/-- We can interpret the commutative square constituting a morphism in the comma category as a\n    natural transformation between the functors `fst ⋙ L` and `snd ⋙ R` from the comma category\n    to `T`, where the components are given by the morphism that constitutes an object of the comma\n    category. -/\n@[simps]\ndef nat_trans : fst L R ⋙ L ⟶ snd L R ⋙ R :=\n{ app := λ X, X.hom }\n\n@[simp] lemma eq_to_hom_left (X Y : comma L R) (H : X = Y) :\n  comma_morphism.left (eq_to_hom H) = eq_to_hom (by { cases H, refl }) := by { cases H, refl }\n\n@[simp] lemma eq_to_hom_right (X Y : comma L R) (H : X = Y) :\n  comma_morphism.right (eq_to_hom H) = eq_to_hom (by { cases H, refl }) := by { cases H, refl }\n\nsection\nvariables {L₁ L₂ L₃ : A ⥤ T} {R₁ R₂ R₃ : B ⥤ T}\n\n/--\nConstruct an isomorphism in the comma category given isomorphisms of the objects whose forward\ndirections give a commutative square.\n-/\n@[simps]\ndef iso_mk {X Y : comma L₁ R₁} (l : X.left ≅ Y.left) (r : X.right ≅ Y.right)\n  (h : L₁.map l.hom ≫ Y.hom = X.hom ≫ R₁.map r.hom) : X ≅ Y :=\n{ hom := { left := l.hom, right := r.hom },\n  inv :=\n  { left := l.inv,\n    right := r.inv,\n    w' := begin\n      rw [←L₁.map_iso_inv l, iso.inv_comp_eq, L₁.map_iso_hom, reassoc_of h, ← R₁.map_comp],\n      simp\n    end, } }\n\n/-- A natural transformation `L₁ ⟶ L₂` induces a functor `comma L₂ R ⥤ comma L₁ R`. -/\n@[simps]\ndef map_left (l : L₁ ⟶ L₂) : comma L₂ R ⥤ comma L₁ R :=\n{ obj := λ X,\n  { left  := X.left,\n    right := X.right,\n    hom   := l.app X.left ≫ X.hom },\n  map := λ X Y f,\n  { left  := f.left,\n    right := f.right } }\n\n/-- The functor `comma L R ⥤ comma L R` induced by the identity natural transformation on `L` is\n    naturally isomorphic to the identity functor. -/\n@[simps]\ndef map_left_id : map_left R (𝟙 L) ≅ 𝟭 _ :=\n{ hom :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } },\n  inv :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } } }\n\n/-- The functor `comma L₁ R ⥤ comma L₃ R` induced by the composition of two natural transformations\n    `l : L₁ ⟶ L₂` and `l' : L₂ ⟶ L₃` is naturally isomorphic to the composition of the two functors\n    induced by these natural transformations. -/\n@[simps]\ndef map_left_comp (l : L₁ ⟶ L₂) (l' : L₂ ⟶ L₃) :\n  (map_left R (l ≫ l')) ≅ (map_left R l') ⋙ (map_left R l) :=\n{ hom :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } },\n  inv :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } } }\n\n/-- A natural transformation `R₁ ⟶ R₂` induces a functor `comma L R₁ ⥤ comma L R₂`. -/\n@[simps]\ndef map_right (r : R₁ ⟶ R₂) : comma L R₁ ⥤ comma L R₂ :=\n{ obj := λ X,\n  { left  := X.left,\n    right := X.right,\n    hom   := X.hom ≫ r.app X.right },\n  map := λ X Y f,\n  { left  := f.left,\n    right := f.right } }\n\n/-- The functor `comma L R ⥤ comma L R` induced by the identity natural transformation on `R` is\n    naturally isomorphic to the identity functor. -/\n@[simps]\ndef map_right_id : map_right L (𝟙 R) ≅ 𝟭 _ :=\n{ hom :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } },\n  inv :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } } }\n\n/-- The functor `comma L R₁ ⥤ comma L R₃` induced by the composition of the natural transformations\n    `r : R₁ ⟶ R₂` and `r' : R₂ ⟶ R₃` is naturally isomorphic to the composition of the functors\n    induced by these natural transformations. -/\n@[simps]\ndef map_right_comp (r : R₁ ⟶ R₂) (r' : R₂ ⟶ R₃) :\n  (map_right L (r ≫ r')) ≅ (map_right L r) ⋙ (map_right L r') :=\n{ hom :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } },\n  inv :=\n  { app := λ X, { left := 𝟙 _, right := 𝟙 _ } } }\n\nend\n\nsection\nvariables {C : Type u₄} [category.{v₄} C] {D : Type u₅} [category.{v₅} D]\n\n/-- The functor `(F ⋙ L, R) ⥤ (L, R)` -/\n@[simps] def pre_left (F: C ⥤ A) (L : A ⥤ T) (R : B ⥤ T) : comma (F ⋙ L) R ⥤ comma L R :=\n{ obj := λ X, { left := F.obj X.left, right := X.right, hom := X.hom },\n  map := λ X Y f, { left := F.map f.left, right := f.right, w' := by simpa using f.w } }\n\n/-- The functor `(F ⋙ L, R) ⥤ (L, R)` -/\n@[simps] def pre_right (L : A ⥤ T) (F: C ⥤ B) (R : B ⥤ T) : comma L (F ⋙ R) ⥤ comma L R :=\n{ obj := λ X, { left := X.left, right := F.obj X.right, hom := X.hom },\n  map := λ X Y f, { left := f.left, right := F.map f.right, w' := by simp } }\n\n/-- The functor `(L, R) ⥤ (L ⋙ F, R ⋙ F)` -/\n@[simps] def post (L : A ⥤ T) (R : B ⥤ T) (F: T ⥤ C) : comma L R ⥤ comma (L ⋙ F) (R ⋙ F) :=\n{ obj := λ X, { left := X.left, right := X.right, hom := F.map X.hom },\n  map := λ X Y f, { left := f.left, right := f.right, w' :=\n    by { simp only [functor.comp_map, ←F.map_comp, f.w] } } }\n\nend\nend comma\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/comma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.46221489121549353}}
{"text": "import function.misc\nimport function.bijection\nimport data.list.misc\nimport data.list.map_partial\nimport data.finord\nimport data.subtype.misc\nimport tactic.unirewrite\nimport .basic\n\nnamespace exhaustive_list\n\n--- Forget proofs to exhibit an `exhaustive_list` on a subtype of `α` as a list of `α`.\n@[reducible,inline]\nprotected\ndefinition underlying {α : Type _} {p : α → Prop} (l : exhaustive_list (subtype p)) : list α :=\n  l.val.map subtype.val\n\n--- Two `exhaustive_list`s on a subtype equal to each other precisely if their underlying `list`s do.\nprotected\nlemma eq_of_underlying {α : Type _} {p : α → Prop} {l₁ l₂ : exhaustive_list (subtype p)} : l₁.underlying = l₂.underlying → l₁ = l₂ :=\n  λ h, subtype.eq (list.inj_of_map_inj subtype.val_injective h)\n\nprotected\nlemma underlying_nodup {α : Type _} {p : α → Prop} (l : exhaustive_list (subtype p)) : l.underlying.nodup :=\n  begin\n    dunfold exhaustive_list.underlying,\n    apply list.nodup_map_of_nodup subtype.val_injective,\n    exact l.property.left\n  end\n\nprotected\nlemma underlying_exhaustive {α : Type _} {p : α → Prop} (l : exhaustive_list (subtype p)) : ∀ x, p x → x ∈ l.underlying :=\n  begin\n    intros x hx,\n    dunfold exhaustive_list.underlying,\n    unirewrite x with (subtype.mk x hx).val,\n    exact list.mem_map_of_mem _ _ (l.property.right _)\n  end\n\nprotected\nlemma underlying_mem_iff {α : Type _} {p : α → Prop} (l : exhaustive_list (subtype p)) : ∀ x, p x ↔ x ∈ l.underlying :=\n  begin\n    intros x,\n    split,\n    show p x → _,\n      from l.underlying_exhaustive x,\n    show _ → p x, {\n      intros hx,\n      dunfold exhaustive_list.underlying at hx,\n      cases l.val.inverse_of_mem_map hx with w hw,\n      rw [hw.left]; exact w.property\n    }\n  end\n\n--- For every pair of `exhaustive_list`s of a subtype, they are the same underlying list up to permutations.\nprotected\nlemma underlying_perm {α : Type _} {p : α → Prop} (l₁ l₂ : exhaustive_list (subtype p)) : list.perm l₁.underlying l₂.underlying :=\n  list.perm.map subtype.val (l₁.perm l₂)\n\n--- The empty list is exhaustive on empty subtypes.\n@[reducible]\nprotected\ndefinition of_empty {α : Type _} {p : α → Prop} (h : ∀ a, ¬p a) : exhaustive_list (subtype p) :=\n  subtype.mk [] $\n    begin\n      split; try { exact list.nodup.nil },\n      intros x,\n      exact false.elim (h x x.property)\n    end\n\n--- Every `exhaustive_list` on an empty subtype is `nil`.\nprotected\nlemma is_empty {α : Type _} {p : α → Prop} (h : ∀ a, ¬p a) (l : exhaustive_list (subtype p)) : l.val = [] :=\n  begin\n    apply list.is_nil_of_no_mem,\n    intros x,\n    exfalso,\n    exact h x.val x.property\n  end\n\n--- The underlying `list` of `exhaustive_list` of empty subtype is `nil`.\nprotected\nlemma of_empty_underlying {α : Type _} {p : α → Prop} (h : ∀ a, ¬p a) (l : exhaustive_list (subtype p)) : l.underlying = [] :=\n  begin\n    dunfold exhaustive_list.underlying,\n    rw [l.is_empty h],\n    refl\n  end\n\n--- `exhaustive_list` of singleton subset.\nprotected\ndefinition singleton {α : Type _} [decidable_eq α] (a : α) : exhaustive_list {x // x=a} :=\n  subtype.mk [⟨a,rfl⟩] $\n    begin\n      split,\n      exact list.nodup.cons (list.not_mem_nil _) list.nodup.nil,\n      show ∀ x, _, {\n        intros x,\n        have : x = ⟨a,rfl⟩ := subtype.eq x.property,\n        rw [this],\n        exact list.mem_cons_self _ _\n      }\n    end\n\n--- The underlying `list` of `exhaustive_list` of singleton subtypes.\nprotected\nlemma singleton_underlying {α : Type _} [decidable_eq α] {a : α} : (exhaustive_list.singleton a).underlying = [a] :=\n  rfl\n\n--- The uniqueness of `exhaustive_list` on singleton subtypes.\nprotected\nlemma singleton_unique {α : Type _} [decidable_eq α] {a : α} : ∀ (l :exhaustive_list {x // x=a}), l = exhaustive_list.singleton a :=\n  begin\n    intros l,\n    apply exhaustive_list.eq_of_underlying,\n    have : list.perm l.underlying [a],\n      from l.underlying_perm (exhaustive_list.singleton a),\n    exact this.eq_singleton\n  end\n\n--- `exhaustive_list`s of two subtypes classified by eqiuvalent predicators can be translated to one another.\n@[reducible]\nprotected\ndefinition of_iff {α : Type _} {p q : α → Prop} (h : ∀ a, p a ↔ q a) (l : exhaustive_list (subtype p)) : exhaustive_list (subtype q) :=\n  l.translate (bijection.subtype_equiv h).is_bijective\n\n--- Equivalent condition translation of `exhaustive_list` does nothing on the underlying `list`.\n@[simp]\nprotected\nlemma of_iff_underlying {α : Type _} {p q : α → Prop} (h : ∀ a, p a  ↔ q a) (l : exhaustive_list (subtype p)) : (l.of_iff h).underlying = l.underlying:=\n  begin\n    dsimp [\n      exhaustive_list.of_iff,\n      exhaustive_list.translate,\n      bijection.subtype_equiv,\n      exhaustive_list.underlying\n    ],\n    rw [list.map_map_safe],\n    exact list.map_equiv (by intros x; cases x; refl)\n  end\n\n--- If `α` has an `exhaustive_list`, then each decidable subtype of `α` does.\n@[reducible]\nprotected\ndefinition restrict {α : Type _} (l : exhaustive_list α) (p : α → Prop) [decidable_pred p] : exhaustive_list (subtype p) :=\n  subtype.mk (l.val.filter_to_subtype p) $\n    begin\n      split,\n      exact list.nodup_map_partial_of_nodup (function.partial.coinj_inj) l.property.left,\n      intros x,\n      have hx : (function.partial.coinj p).is_defined_at x.val,\n        from (function.partial.coinj_domain x.val).mpr x.property,\n      have : x = (function.partial.coinj p).to_fun ⟨x.val,hx⟩, {\n        symmetry,\n        suffices : function.partial.coinj p x.val = some x,\n          from (function.partial.coinj p).to_fun_value_of_eq this,\n        cases hinjx : function.partial.coinj p x.val with y,\n        exfalso; exact hx hinjx,\n        dunfold function.partial.coinj at hinjx,\n        rw [dif_pos x.property] at hinjx,\n        apply congr_arg some; apply subtype.eq,\n        let hyxval := congr_arg subtype.val (option.some.inj hinjx.symm),\n        exact hyxval,\n      },\n      rw [this],\n      refine list.mem_map_partial_of_mem _ _ _,\n      exact l.property.right _\n    end\n\n--- `exhaustive_list.restrict` is nothing but `filter` on the underlying `list`.\n@[simp]\nprotected\nlemma restrict_underlying {α : Type _} (l : exhaustive_list α) {p : α → Prop} [decidable_pred p] : (l.restrict p).underlying = l.val.filter p :=\n  begin\n    dunfold exhaustive_list.underlying,\n    dsimp [exhaustive_list.restrict],\n    rw [list.val_of_filter_to_subtype]\n  end\n\n--- Restrict an `exhaustive_list` on a subtype to a smaller subtype.\n@[simp]\nprotected\ndefinition subrestrict {α : Type _} {p : α → Prop} (l : exhaustive_list (subtype p)) (q : α → Prop) [decidable_pred q] : exhaustive_list {x // p x ∧ q x} :=\n  let l' := (l.restrict (q ∘ subtype.val))\n  in l'.translate bijection.subtype_uncurry.is_bijective\n\n--- `exhaustive_list.subrestrict` is nothing but `filter` on the underlying `list`.\n@[simp]\nprotected\nlemma subrestrict_underlying {α : Type _} {p : α → Prop} (l : exhaustive_list (subtype p)) (q : α → Prop) [decidable_pred q] : (l.subrestrict q).underlying = l.underlying.filter q :=\n  begin\n    dsimp [exhaustive_list.subrestrict],\n    dsimp [exhaustive_list.translate],\n    dsimp [bijection.subtype_uncurry],\n    dsimp [exhaustive_list.underlying],\n    rw [list.map_map_safe],\n    dunfold function.comp; dsimp *,\n    have : ∀ (x : {x : subtype p // q x.val}), x.val.val = (subtype.val ∘ subtype.val) x,\n      by intros; refl,\n    rw [list.map_equiv this]; dsimp *,\n    rw [←list.map_map_safe],\n    rw [list.val_of_filter_to_subtype],\n    rw [list.filter_of_map]\n  end\n\n--- Partitioning an `exhaustive_list α` with a decidable predicator `p : α → Prop`.\n@[reducible]\nprotected\ndefinition partition {α : Type _} (p : α → Prop) [decidable_pred p] (l : exhaustive_list α) : exhaustive_list (subtype p) × exhaustive_list {x // ¬p x} :=\n  (l.restrict p, l.restrict (not ∘ p))\n\n--- Underlying lists of partitioned `exhaustive_list`.\n@[simp]\nprotected\nlemma partition_underlying {α : Type _} {p : α → Prop} [decidable_pred p] {l : exhaustive_list α} : (l.partition p).map exhaustive_list.underlying exhaustive_list.underlying = l.val.partition p :=\n  begin\n    dunfold exhaustive_list.partition,\n    dunfold prod.map,\n    repeat { rw [exhaustive_list.restrict_underlying] },\n    rw [list.partition_eq_filter_filter_safe]\n  end\n\n--- Partitioning an `exhaustive_list` on a subtype with a decidable predicator `p`.\n@[reducible]\nprotected\ndefinition subpartition {α : Type _} {p : α → Prop} (l : exhaustive_list (subtype p)) (q : α → Prop) [decidable_pred q] : exhaustive_list {x // p x ∧ q x} × exhaustive_list {x // p x ∧ ¬q x} :=\n  (l.subrestrict q, l.subrestrict (not ∘ q))\n\n--- Underlying lists of partitioned `exhaustive_list`.\n@[simp]\nprotected\nlemma subpartition_underlying {α : Type _} {p : α → Prop} {l : exhaustive_list (subtype p)} {q : α → Prop} [decidable_pred q]: (l.subpartition q).map exhaustive_list.underlying exhaustive_list.underlying = l.underlying.partition q :=\n  begin\n    dunfold exhaustive_list.subpartition,\n    dunfold prod.map,\n    repeat { rw [exhaustive_list.subrestrict_underlying] },\n    rw [list.partition_eq_filter_filter_safe],\n  end\n\n--- If two subtypes respectively admit exhaustive lists, then so does their union.\n@[reducible]\nprotected\ndefinition union {α : Type _} [decidable_eq α] {p q : α → Prop} (lp : exhaustive_list (subtype p)) (lq : exhaustive_list (subtype q)) : exhaustive_list {x // p x ∨ q x} :=\n  subtype.mk\n    (list.union (lp.val.map subtype.inl) (lq.val.map subtype.inr)) $\n    begin\n      split,\n      show list.nodup _, {\n        apply list.nodup_union,\n        exact list.nodup_map_of_nodup subtype.relax_inj lp.property.left,\n        exact list.nodup_map_of_nodup subtype.relax_inj lq.property.left,\n      },\n      show ∀ x, x ∈ _, {\n        intros x,\n        apply list.mem_union_iff.mp,\n        cases x.property with hx hx,\n        case or.inl /- p x.val -/ {\n          left,\n          have : x = subtype.inl ⟨x.val,hx⟩,\n            by cases x; refl,\n          rw [this],\n          apply list.mem_map_of_mem _ _,\n          exact lp.property.right _\n        },\n        case or.inr /- q x.val -/ {\n          right,\n          have : x = subtype.inr ⟨x.val,hx⟩,\n            by cases x; refl,\n          rw [this],\n          apply list.mem_map_of_mem _ _,\n          exact lq.property.right _\n        },\n      },\n    end\n\n--- The underlying list of `union` of `exhaustive_list`s.\n@[simp]\nprotected\nlemma union_underlying {α : Type _} [decidable_eq α] {p q : α → Prop} {lp : exhaustive_list (subtype p)} {lq : exhaustive_list (subtype q)} : (lp.union lq).underlying = lp.underlying ∪ lq.underlying :=\n  begin\n    cases lp; cases lq,\n    dsimp [exhaustive_list.union, exhaustive_list.underlying],\n    drefold @has_union.union (list {x // p x ∨ q x}) _,\n    rw [list.union_of_map_inj (@subtype.val_injective α _)],\n    rw [list.map_map_safe, list.map_map_safe],\n    rw [list.map_equiv subtype.val_inl],\n    rw [list.map_equiv subtype.val_inr]\n  end\n\n--- The underlying list of `union` of `exhaustive_list`s for two disjoint subtypes.\n@[simp]\nprotected\nlemma disjoint_union_underlying {α : Type _} [decidable_eq α] {p q : α → Prop} {lp : exhaustive_list (subtype p)} {lq : exhaustive_list (subtype q)} : (∀ x, ¬(p x ∧ q x)) → (lp.union lq).underlying = lp.underlying ++ lq.underlying :=\n  begin\n    intros hnpq,\n    rw [exhaustive_list.union_underlying],\n    apply list.nodup.disjoint_union lp.underlying_nodup,\n    intros x hlpx hlqx,\n    have hpx : p x,\n      from (lp.underlying_mem_iff x).mpr hlpx,\n    have hqx : q x,\n      from (lq.underlying_mem_iff x).mpr hlqx,\n    exact hnpq x ⟨hpx,hqx⟩\n  end\n\nend exhaustive_list\n\nnamespace is_finite\n\n--- Empty subtype is finite\ndefinition of_empty {α : Type _} {p : α → Prop} (h : ∀ x, ¬p x) : is_finite {x // p x} :=\n  begin\n    constructor,\n    existsi 0,\n    existsi (λ x, false.elim $ finord.zero_empty x),\n    split,\n    show function.injective _, {\n      intros x,\n      exfalso; exact finord.zero_empty x,\n    },\n    show function.surjective _, {\n      intros x,\n      exfalso; exact h x.val x.property\n    }\n  end\n\n--- Decidable subtypes of a finite type is finite.\ninstance of_subtype {α : Type _} [decidable_eq α] [is_finite α] {p : α → Prop} [decidable_pred p] : is_finite (subtype p) :=\n  begin\n    cases has_exhaustive_list α with l,\n    exact is_finite.of_exhaustive_list (l.restrict p)\n  end\n\n--- If a subtype is finite, then every equivalent subtype is also finite.\nprotected\nlemma of_iff {α : Type _} [decidable_eq α] {p q : α → Prop} (hpq : ∀ x, p x ↔ q x) : is_finite (subtype p) → is_finite (subtype q) :=\n  begin\n    intros hp; cases @has_exhaustive_list _ hp with lp,\n    exact is_finite.of_exhaustive_list (lp.of_iff hpq),\n  end\n\n--- Decidable subtype of a finite subtype is a finite subtype.\nlemma of_subrestrict {α : Type _} [decidable_eq α] {p : α → Prop} : is_finite (subtype p) → Π (q : α → Prop) [decidable_pred q], is_finite {x // p x ∧ q x} :=\n  begin\n    intros hp; cases @has_exhaustive_list _ hp with lp,\n    intros q hdec,\n    apply is_finite.of_exhaustive_list,\n    exact @exhaustive_list.subrestrict _ _ lp q hdec\n  end\n\n--- The union of finite subtypes is finite\nlemma of_union {α : Type _} [decidable_eq α] {p q : α → Prop} : is_finite (subtype p) → is_finite (subtype q) → is_finite {x // p x ∨ q x} :=\n  begin\n    intro hp; cases @has_exhaustive_list _ hp with lp,\n    intro hq; cases @has_exhaustive_list _ hq with lq,\n    exact is_finite.of_exhaustive_list (lp.union lq)\n  end\n\n--- Every finite subtype of a subtype is internally-decidable in the superset.\nlemma idec_in_super {α : Type _} [decidable_eq α] {p : α → Prop} {q : subtype p → Prop} : is_finite (subtype q) → ∀ (a : α), idecidable (∃ (h : p a), q ⟨a,h⟩) :=\n  begin\n    intros hfin a,\n    constructor,\n    cases @is_finite.has_exhaustive_list _ hfin with l,\n    refine dite (a ∈ l.underlying.map subtype.val) _ _,\n    show a ∈ _ → _, {\n      intros ha; left,\n      let ha' := list.inverse_of_mem_map _ ha,\n      cases hha: ha' with x hxa; clear hha,\n      have hqx : q x,\n        from (l.underlying_mem_iff x).mpr hxa.right,\n      have hpa : p a,\n        from hxa.left.symm ▸ x.property,\n      have : x = ⟨a,hpa⟩,\n        from subtype.eq hxa.left.symm,\n      rw [this] at hqx,\n      exact ⟨hpa,hqx⟩\n    },\n    show a ∉ _ → _, {\n      intros ha; right,\n      intros h; cases h with hpa hqa,\n      let x : subtype p := ⟨a,hpa⟩,\n      have : x ∈ l.underlying,\n        from (l.underlying_mem_iff x).mp hqa,\n      have: x.val ∈ list.map subtype.val l.underlying,\n        from l.underlying.mem_map_of_mem x this,\n      exact ha this\n    }\n  end\n\n--- Every subtype of a subtype that is decidable in a finite supertype is finite.\nlemma is_finite_of_superdec {α : Type _} [decidable_eq α] [is_finite α] {p : α → Prop} {q : subtype p → Prop} [∀ (a : α), decidable (∃ (h : p a), q ⟨a,h⟩)] : is_finite (subtype q) :=\n  begin\n    cases is_finite.has_exhaustive_list α with l,\n    apply is_finite.of_exhaustive_list,\n    let l' := l.restrict (λ a, ∃ (h : p a), q ⟨a,h⟩),\n    have : ∀ a, (∃ h, q ⟨a,h⟩) ↔ (p a ∧ ∀ h, q ⟨a,h⟩), {\n      intros a,\n      split,\n      show (∃ h, q ⟨a,h⟩) → _, {\n        intros hh; cases hh with hpa hqa,\n        refine and.intro hpa _,\n        intro h,\n        have : h = hpa, from rfl,\n        rw [this],\n        exact hqa\n      },\n      show (p a ∧ ∀ h, q ⟨a,h⟩) → _, {\n        intros hpqa,\n        exact ⟨hpqa.left, hpqa.right hpqa.left⟩\n      }\n    },\n    let l'' := l'.of_iff this,\n    let f : {a // p a ∧ ∀ h, q ⟨a,h⟩} → subtype q :=\n      λ x, subtype.mk ⟨x.val, x.property.left⟩ $\n        x.property.right x.property.left,\n    have : function.bijective f, {\n      split,\n      show function.injective f, {\n        intros x y,\n        dsimp [f],\n        intros hxy,\n        let hxy' := congr_arg (subtype.val∘subtype.val) hxy,\n        dsimp * at hxy',\n        apply subtype.eq; exact hxy'\n      },\n      show function.surjective f, {\n        intros z,\n        let hqa := z.property,\n        rw [←subtype.eta z.val z.val.property] at hqa,\n        let x : {a // p a ∧ ∀ h, q ⟨a,h⟩} :=\n          subtype.mk z.val.val\n            (and.intro z.val.property (λ h, hqa)),\n        existsi x,\n        dsimp [f],\n        apply subtype.eq; apply subtype.eq,\n        dsimp *; refl\n      }\n    },\n    exact l''.translate this\n  end\n\nend is_finite\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/logic/finite/subtype.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4622148864616419}}
{"text": "/-\nCopyright (c) 2021 Jakob von Raumer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jakob von Raumer\n\n! This file was ported from Lean 3 source module category_theory.monoidal.rigid.basic\n! leanprover-community/mathlib commit 3d7987cda72abc473c7cdbbb075170e9ac620042\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Monoidal.CoherenceLemmas\nimport Mathbin.CategoryTheory.Closed.Monoidal\nimport Mathbin.Tactic.ApplyFun\n\n/-!\n# Rigid (autonomous) monoidal categories\n\nThis file defines rigid (autonomous) monoidal categories and the necessary theory about\nexact pairings and duals.\n\n## Main definitions\n\n* `exact_pairing` of two objects of a monoidal category\n* Type classes `has_left_dual` and `has_right_dual` that capture that a pairing exists\n* The `right_adjoint_mate f` as a morphism `fᘁ : Yᘁ ⟶ Xᘁ` for a morphism `f : X ⟶ Y`\n* The classes of `right_rigid_category`, `left_rigid_category` and `rigid_category`\n\n## Main statements\n\n* `comp_right_adjoint_mate`: The adjoint mates of the composition is the composition of\n  adjoint mates.\n\n## Notations\n\n* `η_` and `ε_` denote the coevaluation and evaluation morphism of an exact pairing.\n* `Xᘁ` and `ᘁX` denote the right and left dual of an object, as well as the adjoint\n  mate of a morphism.\n\n## Future work\n\n* Show that `X ⊗ Y` and `Yᘁ ⊗ Xᘁ` form an exact pairing.\n* Show that the left adjoint mate of the right adjoint mate of a morphism is the morphism itself.\n* Simplify constructions in the case where a symmetry or braiding is present.\n* Show that `ᘁ` gives an equivalence of categories `C ≅ (Cᵒᵖ)ᴹᵒᵖ`.\n* Define pivotal categories (rigid categories equipped with a natural isomorphism `ᘁᘁ ≅ 𝟙 C`).\n\n## Notes\n\nAlthough we construct the adjunction `tensor_left Y ⊣ tensor_left X` from `exact_pairing X Y`,\nthis is not a bijective correspondence.\nI think the correct statement is that `tensor_left Y` and `tensor_left X` are\nmodule endofunctors of `C` as a right `C` module category,\nand `exact_pairing X Y` is in bijection with adjunctions compatible with this right `C` action.\n\n## References\n\n* <https://ncatlab.org/nlab/show/rigid+monoidal+category>\n\n## Tags\n\nrigid category, monoidal category\n\n-/\n\n\nopen CategoryTheory\n\nuniverse v v₁ v₂ v₃ u u₁ u₂ u₃\n\nnoncomputable section\n\nnamespace CategoryTheory\n\nvariable {C : Type u₁} [Category.{v₁} C] [MonoidalCategory C]\n\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`coevaluation] [] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`evaluation] [] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`coevaluation_evaluation'] [] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`evaluation_coevaluation'] [] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- An exact pairing is a pair of objects `X Y : C` which admit\n  a coevaluation and evaluation morphism which fulfill two triangle equalities. -/\nclass ExactPairing (X Y : C) where\n  coevaluation : 𝟙_ C ⟶ X ⊗ Y\n  evaluation : Y ⊗ X ⟶ 𝟙_ C\n  coevaluation_evaluation' :\n    (𝟙 Y ⊗ coevaluation) ≫ (α_ _ _ _).inv ≫ (evaluation ⊗ 𝟙 Y) = (ρ_ Y).Hom ≫ (λ_ Y).inv := by\n    obviously\n  evaluation_coevaluation' :\n    (coevaluation ⊗ 𝟙 X) ≫ (α_ _ _ _).Hom ≫ (𝟙 X ⊗ evaluation) = (λ_ X).Hom ≫ (ρ_ X).inv := by\n    obviously\n#align category_theory.exact_pairing CategoryTheory.ExactPairing\n\nopen ExactPairing\n\n-- mathport name: exprη_\nnotation \"η_\" => ExactPairing.coevaluation\n\n-- mathport name: exprε_\nnotation \"ε_\" => ExactPairing.evaluation\n\nrestate_axiom coevaluation_evaluation'\n\nattribute [simp, reassoc.1] exact_pairing.coevaluation_evaluation\n\nrestate_axiom evaluation_coevaluation'\n\nattribute [simp, reassoc.1] exact_pairing.evaluation_coevaluation\n\ninstance exactPairingUnit : ExactPairing (𝟙_ C) (𝟙_ C)\n    where\n  coevaluation := (ρ_ _).inv\n  evaluation := (ρ_ _).Hom\n  coevaluation_evaluation' := by coherence\n  evaluation_coevaluation' := by coherence\n#align category_theory.exact_pairing_unit CategoryTheory.exactPairingUnit\n\n/-- A class of objects which have a right dual. -/\nclass HasRightDual (X : C) where\n  rightDual : C\n  [exact : ExactPairing X right_dual]\n#align category_theory.has_right_dual CategoryTheory.HasRightDual\n\n/-- A class of objects with have a left dual. -/\nclass HasLeftDual (Y : C) where\n  leftDual : C\n  [exact : ExactPairing left_dual Y]\n#align category_theory.has_left_dual CategoryTheory.HasLeftDual\n\nattribute [instance] has_right_dual.exact\n\nattribute [instance] has_left_dual.exact\n\nopen ExactPairing HasRightDual HasLeftDual MonoidalCategory\n\n-- mathport name: left_dual\nprefix:1024 \"ᘁ\" => leftDual\n\n-- mathport name: right_dual\npostfix:1024 \"ᘁ\" => rightDual\n\ninstance hasRightDualUnit : HasRightDual (𝟙_ C) where rightDual := 𝟙_ C\n#align category_theory.has_right_dual_unit CategoryTheory.hasRightDualUnit\n\ninstance hasLeftDualUnit : HasLeftDual (𝟙_ C) where leftDual := 𝟙_ C\n#align category_theory.has_left_dual_unit CategoryTheory.hasLeftDualUnit\n\ninstance hasRightDualLeftDual {X : C} [HasLeftDual X] : HasRightDual ᘁX where rightDual := X\n#align category_theory.has_right_dual_left_dual CategoryTheory.hasRightDualLeftDual\n\ninstance hasLeftDualRightDual {X : C} [HasRightDual X] : HasLeftDual Xᘁ where leftDual := X\n#align category_theory.has_left_dual_right_dual CategoryTheory.hasLeftDualRightDual\n\n@[simp]\ntheorem leftDual_rightDual {X : C} [HasRightDual X] : ᘁXᘁ = X :=\n  rfl\n#align category_theory.left_dual_right_dual CategoryTheory.leftDual_rightDual\n\n@[simp]\ntheorem rightDual_leftDual {X : C} [HasLeftDual X] : (ᘁX)ᘁ = X :=\n  rfl\n#align category_theory.right_dual_left_dual CategoryTheory.rightDual_leftDual\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- The right adjoint mate `fᘁ : Xᘁ ⟶ Yᘁ` of a morphism `f : X ⟶ Y`. -/\ndef rightAdjointMate {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) : Yᘁ ⟶ Xᘁ :=\n  (ρ_ _).inv ≫ (𝟙 _ ⊗ η_ _ _) ≫ (𝟙 _ ⊗ f ⊗ 𝟙 _) ≫ (α_ _ _ _).inv ≫ (ε_ _ _ ⊗ 𝟙 _) ≫ (λ_ _).Hom\n#align category_theory.right_adjoint_mate CategoryTheory.rightAdjointMate\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- The left adjoint mate `ᘁf : ᘁY ⟶ ᘁX` of a morphism `f : X ⟶ Y`. -/\ndef leftAdjointMate {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) : ᘁY ⟶ ᘁX :=\n  (λ_ _).inv ≫ (η_ (ᘁX) X ⊗ 𝟙 _) ≫ ((𝟙 _ ⊗ f) ⊗ 𝟙 _) ≫ (α_ _ _ _).Hom ≫ (𝟙 _ ⊗ ε_ _ _) ≫ (ρ_ _).Hom\n#align category_theory.left_adjoint_mate CategoryTheory.leftAdjointMate\n\n-- mathport name: right_adjoint_mate\nnotation f \"ᘁ\" => rightAdjointMate f\n\n-- mathport name: left_adjoint_mate\nnotation \"ᘁ\" f => leftAdjointMate f\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem rightAdjointMate_id {X : C} [HasRightDual X] : 𝟙 Xᘁ = 𝟙 (Xᘁ) := by\n  simp only [right_adjoint_mate, monoidal_category.tensor_id, category.id_comp,\n    coevaluation_evaluation_assoc, category.comp_id, iso.inv_hom_id]\n#align category_theory.right_adjoint_mate_id CategoryTheory.rightAdjointMate_id\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem leftAdjointMate_id {X : C} [HasLeftDual X] : (ᘁ𝟙 X) = 𝟙 (ᘁX) := by\n  simp only [left_adjoint_mate, monoidal_category.tensor_id, category.id_comp,\n    evaluation_coevaluation_assoc, category.comp_id, iso.inv_hom_id]\n#align category_theory.left_adjoint_mate_id CategoryTheory.leftAdjointMate_id\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem rightAdjointMate_comp {X Y Z : C} [HasRightDual X] [HasRightDual Y] {f : X ⟶ Y}\n    {g : Xᘁ ⟶ Z} :\n    fᘁ ≫ g =\n      (ρ_ (Yᘁ)).inv ≫\n        (𝟙 _ ⊗ η_ X (Xᘁ)) ≫ (𝟙 _ ⊗ f ⊗ g) ≫ (α_ (Yᘁ) Y Z).inv ≫ (ε_ Y (Yᘁ) ⊗ 𝟙 _) ≫ (λ_ Z).Hom :=\n  by\n  dsimp only [right_adjoint_mate]\n  rw [category.assoc, category.assoc, associator_inv_naturality_assoc,\n    associator_inv_naturality_assoc, ← tensor_id_comp_id_tensor g, category.assoc, category.assoc,\n    category.assoc, category.assoc, id_tensor_comp_tensor_id_assoc, ← left_unitor_naturality,\n    tensor_id_comp_id_tensor_assoc]\n#align category_theory.right_adjoint_mate_comp CategoryTheory.rightAdjointMate_comp\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem leftAdjointMate_comp {X Y Z : C} [HasLeftDual X] [HasLeftDual Y] {f : X ⟶ Y}\n    {g : (ᘁX) ⟶ Z} :\n    (ᘁf) ≫ g =\n      (λ_ _).inv ≫\n        (η_ (ᘁX) X ⊗ 𝟙 _) ≫ ((g ⊗ f) ⊗ 𝟙 _) ≫ (α_ _ _ _).Hom ≫ (𝟙 _ ⊗ ε_ _ _) ≫ (ρ_ _).Hom :=\n  by\n  dsimp only [left_adjoint_mate]\n  rw [category.assoc, category.assoc, associator_naturality_assoc, associator_naturality_assoc, ←\n    id_tensor_comp_tensor_id _ g, category.assoc, category.assoc, category.assoc, category.assoc,\n    tensor_id_comp_id_tensor_assoc, ← right_unitor_naturality, id_tensor_comp_tensor_id_assoc]\n#align category_theory.left_adjoint_mate_comp CategoryTheory.leftAdjointMate_comp\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- The composition of right adjoint mates is the adjoint mate of the composition. -/\n@[reassoc.1]\ntheorem comp_rightAdjointMate {X Y Z : C} [HasRightDual X] [HasRightDual Y] [HasRightDual Z]\n    {f : X ⟶ Y} {g : Y ⟶ Z} : (f ≫ g)ᘁ = gᘁ ≫ fᘁ :=\n  by\n  rw [right_adjoint_mate_comp]\n  simp only [right_adjoint_mate, comp_tensor_id, iso.cancel_iso_inv_left, id_tensor_comp,\n    category.assoc]\n  symm; iterate 5 trans; rw [← category.id_comp g, tensor_comp]\n  rw [← category.assoc]\n  symm; iterate 2 trans; rw [← category.assoc]; apply eq_whisker\n  repeat' rw [← id_tensor_comp]; congr 1\n  rw [← id_tensor_comp_tensor_id (λ_ (Xᘁ)).Hom g, id_tensor_right_unitor_inv, category.assoc,\n    category.assoc, right_unitor_inv_naturality_assoc, ← associator_naturality_assoc, tensor_id,\n    tensor_id_comp_id_tensor_assoc, ← associator_naturality_assoc]\n  slice_rhs 2 3 =>\n    rw [← tensor_comp, tensor_id, category.comp_id, ← category.id_comp (η_ Y (Yᘁ)), tensor_comp]\n  rw [← id_tensor_comp_tensor_id _ (η_ Y (Yᘁ)), ← tensor_id]\n  repeat' rw [category.assoc]\n  rw [pentagon_hom_inv_assoc, ← associator_naturality_assoc, associator_inv_naturality_assoc]\n  slice_rhs 5 7 => rw [← comp_tensor_id, ← comp_tensor_id, evaluation_coevaluation, comp_tensor_id]\n  rw [associator_inv_naturality_assoc]\n  slice_rhs 4 5 => rw [← tensor_comp, left_unitor_naturality, tensor_comp]\n  repeat' rw [category.assoc]\n  rw [triangle_assoc_comp_right_inv_assoc, ← left_unitor_tensor_assoc, left_unitor_naturality_assoc,\n    unitors_equal, ← category.assoc, ← category.assoc]\n  simp\n#align category_theory.comp_right_adjoint_mate CategoryTheory.comp_rightAdjointMate\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- The composition of left adjoint mates is the adjoint mate of the composition. -/\n@[reassoc.1]\ntheorem comp_leftAdjointMate {X Y Z : C} [HasLeftDual X] [HasLeftDual Y] [HasLeftDual Z] {f : X ⟶ Y}\n    {g : Y ⟶ Z} : (ᘁf ≫ g) = (ᘁg) ≫ ᘁf :=\n  by\n  rw [left_adjoint_mate_comp]\n  simp only [left_adjoint_mate, id_tensor_comp, iso.cancel_iso_inv_left, comp_tensor_id,\n    category.assoc]\n  symm; iterate 5 trans; rw [← category.id_comp g, tensor_comp]\n  rw [← category.assoc]\n  symm; iterate 2 trans; rw [← category.assoc]; apply eq_whisker\n  repeat' rw [← comp_tensor_id]; congr 1\n  rw [← tensor_id_comp_id_tensor g (ρ_ (ᘁX)).Hom, left_unitor_inv_tensor_id, category.assoc,\n    category.assoc, left_unitor_inv_naturality_assoc, ← associator_inv_naturality_assoc, tensor_id,\n    id_tensor_comp_tensor_id_assoc, ← associator_inv_naturality_assoc]\n  slice_rhs 2 3 =>\n    rw [← tensor_comp, tensor_id, category.comp_id, ← category.id_comp (η_ (ᘁY) Y), tensor_comp]\n  rw [← tensor_id_comp_id_tensor (η_ (ᘁY) Y), ← tensor_id]\n  repeat' rw [category.assoc]\n  rw [pentagon_inv_hom_assoc, ← associator_inv_naturality_assoc, associator_naturality_assoc]\n  slice_rhs 5 7 => rw [← id_tensor_comp, ← id_tensor_comp, coevaluation_evaluation, id_tensor_comp]\n  rw [associator_naturality_assoc]\n  slice_rhs 4 5 => rw [← tensor_comp, right_unitor_naturality, tensor_comp]\n  repeat' rw [category.assoc]\n  rw [triangle_assoc_comp_left_inv_assoc, ← right_unitor_tensor_assoc,\n    right_unitor_naturality_assoc, ← unitors_equal, ← category.assoc, ← category.assoc]\n  simp\n#align category_theory.comp_left_adjoint_mate CategoryTheory.comp_leftAdjointMate\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Given an exact pairing on `Y Y'`,\nwe get a bijection on hom-sets `(Y' ⊗ X ⟶ Z) ≃ (X ⟶ Y ⊗ Z)`\nby \"pulling the string on the left\" up or down.\n\nThis gives the adjunction `tensor_left_adjunction Y Y' : tensor_left Y' ⊣ tensor_left Y`.\n\nThis adjunction is often referred to as \"Frobenius reciprocity\" in the\nfusion categories / planar algebras / subfactors literature.\n-/\ndef tensorLeftHomEquiv (X Y Y' Z : C) [ExactPairing Y Y'] : (Y' ⊗ X ⟶ Z) ≃ (X ⟶ Y ⊗ Z)\n    where\n  toFun f := (λ_ _).inv ≫ (η_ _ _ ⊗ 𝟙 _) ≫ (α_ _ _ _).Hom ≫ (𝟙 _ ⊗ f)\n  invFun f := (𝟙 Y' ⊗ f) ≫ (α_ _ _ _).inv ≫ (ε_ _ _ ⊗ 𝟙 _) ≫ (λ_ _).Hom\n  left_inv f := by\n    dsimp\n    simp only [id_tensor_comp]\n    slice_lhs 4 5 => rw [associator_inv_naturality]\n    slice_lhs 5 6 => rw [tensor_id, id_tensor_comp_tensor_id, ← tensor_id_comp_id_tensor]\n    slice_lhs 2 5 => simp only [← tensor_id, associator_inv_conjugation]\n    have c :\n      (α_ Y' (Y ⊗ Y') X).Hom ≫\n          (𝟙 Y' ⊗ (α_ Y Y' X).Hom) ≫ (α_ Y' Y (Y' ⊗ X)).inv ≫ (α_ (Y' ⊗ Y) Y' X).inv =\n        (α_ _ _ _).inv ⊗ 𝟙 _\n    pure_coherence\n    slice_lhs 4 7 => rw [c]\n    slice_lhs 3 5 => rw [← comp_tensor_id, ← comp_tensor_id, coevaluation_evaluation]\n    simp only [left_unitor_conjugation]\n    coherence\n  right_inv f := by\n    dsimp\n    simp only [id_tensor_comp]\n    slice_lhs 3 4 => rw [← associator_naturality]\n    slice_lhs 2 3 => rw [tensor_id, tensor_id_comp_id_tensor, ← id_tensor_comp_tensor_id]\n    slice_lhs 3 6 => simp only [← tensor_id, associator_inv_conjugation]\n    have c :\n      (α_ (Y ⊗ Y') Y Z).Hom ≫\n          (α_ Y Y' (Y ⊗ Z)).Hom ≫ (𝟙 Y ⊗ (α_ Y' Y Z).inv) ≫ (α_ Y (Y' ⊗ Y) Z).inv =\n        (α_ _ _ _).Hom ⊗ 𝟙 Z\n    pure_coherence\n    slice_lhs 5 8 => rw [c]\n    slice_lhs 4 6 => rw [← comp_tensor_id, ← comp_tensor_id, evaluation_coevaluation]\n    simp only [left_unitor_conjugation]\n    coherence\n#align category_theory.tensor_left_hom_equiv CategoryTheory.tensorLeftHomEquiv\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Given an exact pairing on `Y Y'`,\nwe get a bijection on hom-sets `(X ⊗ Y ⟶ Z) ≃ (X ⟶ Z ⊗ Y')`\nby \"pulling the string on the right\" up or down.\n-/\ndef tensorRightHomEquiv (X Y Y' Z : C) [ExactPairing Y Y'] : (X ⊗ Y ⟶ Z) ≃ (X ⟶ Z ⊗ Y')\n    where\n  toFun f := (ρ_ _).inv ≫ (𝟙 _ ⊗ η_ _ _) ≫ (α_ _ _ _).inv ≫ (f ⊗ 𝟙 _)\n  invFun f := (f ⊗ 𝟙 _) ≫ (α_ _ _ _).Hom ≫ (𝟙 _ ⊗ ε_ _ _) ≫ (ρ_ _).Hom\n  left_inv f := by\n    dsimp\n    simp only [comp_tensor_id]\n    slice_lhs 4 5 => rw [associator_naturality]\n    slice_lhs 5 6 => rw [tensor_id, tensor_id_comp_id_tensor, ← id_tensor_comp_tensor_id]\n    slice_lhs 2 5 => simp only [← tensor_id, associator_conjugation]\n    have c :\n      (α_ X (Y ⊗ Y') Y).inv ≫\n          ((α_ X Y Y').inv ⊗ 𝟙 Y) ≫ (α_ (X ⊗ Y) Y' Y).Hom ≫ (α_ X Y (Y' ⊗ Y)).Hom =\n        𝟙 _ ⊗ (α_ _ _ _).Hom\n    pure_coherence\n    slice_lhs 4 7 => rw [c]\n    slice_lhs 3 5 => rw [← id_tensor_comp, ← id_tensor_comp, evaluation_coevaluation]\n    simp only [right_unitor_conjugation]\n    coherence\n  right_inv f := by\n    dsimp\n    simp only [comp_tensor_id]\n    slice_lhs 3 4 => rw [← associator_inv_naturality]\n    slice_lhs 2 3 => rw [tensor_id, id_tensor_comp_tensor_id, ← tensor_id_comp_id_tensor]\n    slice_lhs 3 6 => simp only [← tensor_id, associator_conjugation]\n    have c :\n      (α_ Z Y' (Y ⊗ Y')).inv ≫\n          (α_ (Z ⊗ Y') Y Y').inv ≫ ((α_ Z Y' Y).Hom ⊗ 𝟙 Y') ≫ (α_ Z (Y' ⊗ Y) Y').Hom =\n        𝟙 _ ⊗ (α_ _ _ _).inv\n    pure_coherence\n    slice_lhs 5 8 => rw [c]\n    slice_lhs 4 6 => rw [← id_tensor_comp, ← id_tensor_comp, coevaluation_evaluation]\n    simp only [right_unitor_conjugation]\n    coherence\n#align category_theory.tensor_right_hom_equiv CategoryTheory.tensorRightHomEquiv\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem tensorLeftHomEquiv_naturality {X Y Y' Z Z' : C} [ExactPairing Y Y'] (f : Y' ⊗ X ⟶ Z)\n    (g : Z ⟶ Z') :\n    (tensorLeftHomEquiv X Y Y' Z') (f ≫ g) = (tensorLeftHomEquiv X Y Y' Z) f ≫ (𝟙 Y ⊗ g) :=\n  by\n  dsimp [tensor_left_hom_equiv]\n  simp only [id_tensor_comp, category.assoc]\n#align category_theory.tensor_left_hom_equiv_naturality CategoryTheory.tensorLeftHomEquiv_naturality\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem tensorLeftHomEquiv_symm_naturality {X X' Y Y' Z : C} [ExactPairing Y Y'] (f : X ⟶ X')\n    (g : X' ⟶ Y ⊗ Z) :\n    (tensorLeftHomEquiv X Y Y' Z).symm (f ≫ g) =\n      (𝟙 _ ⊗ f) ≫ (tensorLeftHomEquiv X' Y Y' Z).symm g :=\n  by\n  dsimp [tensor_left_hom_equiv]\n  simp only [id_tensor_comp, category.assoc]\n#align category_theory.tensor_left_hom_equiv_symm_naturality CategoryTheory.tensorLeftHomEquiv_symm_naturality\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem tensorRightHomEquiv_naturality {X Y Y' Z Z' : C} [ExactPairing Y Y'] (f : X ⊗ Y ⟶ Z)\n    (g : Z ⟶ Z') :\n    (tensorRightHomEquiv X Y Y' Z') (f ≫ g) = (tensorRightHomEquiv X Y Y' Z) f ≫ (g ⊗ 𝟙 Y') :=\n  by\n  dsimp [tensor_right_hom_equiv]\n  simp only [comp_tensor_id, category.assoc]\n#align category_theory.tensor_right_hom_equiv_naturality CategoryTheory.tensorRightHomEquiv_naturality\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem tensorRightHomEquiv_symm_naturality {X X' Y Y' Z : C} [ExactPairing Y Y'] (f : X ⟶ X')\n    (g : X' ⟶ Z ⊗ Y') :\n    (tensorRightHomEquiv X Y Y' Z).symm (f ≫ g) =\n      (f ⊗ 𝟙 Y) ≫ (tensorRightHomEquiv X' Y Y' Z).symm g :=\n  by\n  dsimp [tensor_right_hom_equiv]\n  simp only [comp_tensor_id, category.assoc]\n#align category_theory.tensor_right_hom_equiv_symm_naturality CategoryTheory.tensorRightHomEquiv_symm_naturality\n\n/-- If `Y Y'` have an exact pairing,\nthen the functor `tensor_left Y'` is left adjoint to `tensor_left Y`.\n-/\ndef tensorLeftAdjunction (Y Y' : C) [ExactPairing Y Y'] : tensorLeft Y' ⊣ tensorLeft Y :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Z => tensorLeftHomEquiv X Y Y' Z\n      homEquiv_naturality_left_symm := fun X X' Z f g => tensorLeftHomEquiv_symm_naturality f g\n      homEquiv_naturality_right := fun X Z Z' f g => tensorLeftHomEquiv_naturality f g }\n#align category_theory.tensor_left_adjunction CategoryTheory.tensorLeftAdjunction\n\n/-- If `Y Y'` have an exact pairing,\nthen the functor `tensor_right Y` is left adjoint to `tensor_right Y'`.\n-/\ndef tensorRightAdjunction (Y Y' : C) [ExactPairing Y Y'] : tensorRight Y ⊣ tensorRight Y' :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Z => tensorRightHomEquiv X Y Y' Z\n      homEquiv_naturality_left_symm := fun X X' Z f g => tensorRightHomEquiv_symm_naturality f g\n      homEquiv_naturality_right := fun X Z Z' f g => tensorRightHomEquiv_naturality f g }\n#align category_theory.tensor_right_adjunction CategoryTheory.tensorRightAdjunction\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/--\nIf `Y` has a left dual `ᘁY`, then it is a closed object, with the internal hom functor `Y ⟶[C] -`\ngiven by left tensoring by `ᘁY`.\nThis has to be a definition rather than an instance to avoid diamonds, for example between\n`category_theory.monoidal_closed.functor_closed` and\n`category_theory.monoidal.functor_has_left_dual`. Moreover, in concrete applications there is often\na more useful definition of the internal hom object than `ᘁY ⊗ X`, in which case the closed\nstructure shouldn't come from `has_left_dual` (e.g. in the category `FinVect k`, it is more\nconvenient to define the internal hom as `Y →ₗ[k] X` rather than `ᘁY ⊗ X` even though these are\nnaturally isomorphic).\n-/\ndef closedOfHasLeftDual (Y : C) [HasLeftDual Y] : Closed Y\n    where isAdj := ⟨_, tensorLeftAdjunction (ᘁY) Y⟩\n#align category_theory.closed_of_has_left_dual CategoryTheory.closedOfHasLeftDual\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- `tensor_left_hom_equiv` commutes with tensoring on the right -/\ntheorem tensorLeftHomEquiv_tensor {X X' Y Y' Z Z' : C} [ExactPairing Y Y'] (f : X ⟶ Y ⊗ Z)\n    (g : X' ⟶ Z') :\n    (tensorLeftHomEquiv (X ⊗ X') Y Y' (Z ⊗ Z')).symm ((f ⊗ g) ≫ (α_ _ _ _).Hom) =\n      (α_ _ _ _).inv ≫ ((tensorLeftHomEquiv X Y Y' Z).symm f ⊗ g) :=\n  by\n  dsimp [tensor_left_hom_equiv]\n  simp only [id_tensor_comp]\n  simp only [associator_inv_conjugation]\n  slice_lhs 2 2 => rw [← id_tensor_comp_tensor_id]\n  conv_rhs => rw [← id_tensor_comp_tensor_id, comp_tensor_id, comp_tensor_id]\n  simp; coherence\n#align category_theory.tensor_left_hom_equiv_tensor CategoryTheory.tensorLeftHomEquiv_tensor\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- `tensor_right_hom_equiv` commutes with tensoring on the left -/\ntheorem tensorRightHomEquiv_tensor {X X' Y Y' Z Z' : C} [ExactPairing Y Y'] (f : X ⟶ Z ⊗ Y')\n    (g : X' ⟶ Z') :\n    (tensorRightHomEquiv (X' ⊗ X) Y Y' (Z' ⊗ Z)).symm ((g ⊗ f) ≫ (α_ _ _ _).inv) =\n      (α_ _ _ _).Hom ≫ (g ⊗ (tensorRightHomEquiv X Y Y' Z).symm f) :=\n  by\n  dsimp [tensor_right_hom_equiv]\n  simp only [comp_tensor_id]\n  simp only [associator_conjugation]\n  slice_lhs 2 2 => rw [← tensor_id_comp_id_tensor]\n  conv_rhs => rw [← tensor_id_comp_id_tensor, id_tensor_comp, id_tensor_comp]\n  simp only [← tensor_id, associator_conjugation]\n  simp; coherence\n#align category_theory.tensor_right_hom_equiv_tensor CategoryTheory.tensorRightHomEquiv_tensor\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorLeftHomEquiv_symm_coevaluation_comp_id_tensor {Y Y' Z : C} [ExactPairing Y Y']\n    (f : Y' ⟶ Z) : (tensorLeftHomEquiv _ _ _ _).symm (η_ _ _ ≫ (𝟙 Y ⊗ f)) = (ρ_ _).Hom ≫ f :=\n  by\n  dsimp [tensor_left_hom_equiv]\n  rw [id_tensor_comp]\n  slice_lhs 2 3 => rw [associator_inv_naturality]\n  slice_lhs 3 4 => rw [tensor_id, id_tensor_comp_tensor_id, ← tensor_id_comp_id_tensor]\n  slice_lhs 1 3 => rw [coevaluation_evaluation]\n  simp\n#align category_theory.tensor_left_hom_equiv_symm_coevaluation_comp_id_tensor CategoryTheory.tensorLeftHomEquiv_symm_coevaluation_comp_id_tensor\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorLeftHomEquiv_symm_coevaluation_comp_tensor_id {X Y : C} [HasRightDual X]\n    [HasRightDual Y] (f : X ⟶ Y) :\n    (tensorLeftHomEquiv _ _ _ _).symm (η_ _ _ ≫ (f ⊗ 𝟙 (Xᘁ))) = (ρ_ _).Hom ≫ fᘁ :=\n  by\n  dsimp [tensor_left_hom_equiv, right_adjoint_mate]\n  simp\n#align category_theory.tensor_left_hom_equiv_symm_coevaluation_comp_tensor_id CategoryTheory.tensorLeftHomEquiv_symm_coevaluation_comp_tensor_id\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorRightHomEquiv_symm_coevaluation_comp_id_tensor {X Y : C} [HasLeftDual X]\n    [HasLeftDual Y] (f : X ⟶ Y) :\n    (tensorRightHomEquiv _ (ᘁY) _ _).symm (η_ (ᘁX) X ≫ (𝟙 (ᘁX) ⊗ f)) = (λ_ _).Hom ≫ ᘁf :=\n  by\n  dsimp [tensor_right_hom_equiv, left_adjoint_mate]\n  simp\n#align category_theory.tensor_right_hom_equiv_symm_coevaluation_comp_id_tensor CategoryTheory.tensorRightHomEquiv_symm_coevaluation_comp_id_tensor\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorRightHomEquiv_symm_coevaluation_comp_tensor_id {Y Y' Z : C} [ExactPairing Y Y']\n    (f : Y ⟶ Z) : (tensorRightHomEquiv _ Y _ _).symm (η_ Y Y' ≫ (f ⊗ 𝟙 Y')) = (λ_ _).Hom ≫ f :=\n  by\n  dsimp [tensor_right_hom_equiv]\n  rw [comp_tensor_id]\n  slice_lhs 2 3 => rw [associator_naturality]\n  slice_lhs 3 4 => rw [tensor_id, tensor_id_comp_id_tensor, ← id_tensor_comp_tensor_id]\n  slice_lhs 1 3 => rw [evaluation_coevaluation]\n  simp\n#align category_theory.tensor_right_hom_equiv_symm_coevaluation_comp_tensor_id CategoryTheory.tensorRightHomEquiv_symm_coevaluation_comp_tensor_id\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorLeftHomEquiv_id_tensor_comp_evaluation {Y Z : C} [HasLeftDual Z] (f : Y ⟶ ᘁZ) :\n    (tensorLeftHomEquiv _ _ _ _) ((𝟙 Z ⊗ f) ≫ ε_ _ _) = f ≫ (ρ_ _).inv :=\n  by\n  dsimp [tensor_left_hom_equiv]\n  rw [id_tensor_comp]\n  slice_lhs 3 4 => rw [← associator_naturality]\n  slice_lhs 2 3 => rw [tensor_id, tensor_id_comp_id_tensor, ← id_tensor_comp_tensor_id]\n  slice_lhs 3 5 => rw [evaluation_coevaluation]\n  simp\n#align category_theory.tensor_left_hom_equiv_id_tensor_comp_evaluation CategoryTheory.tensorLeftHomEquiv_id_tensor_comp_evaluation\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorLeftHomEquiv_tensor_id_comp_evaluation {X Y : C} [HasLeftDual X] [HasLeftDual Y]\n    (f : X ⟶ Y) : (tensorLeftHomEquiv _ _ _ _) ((f ⊗ 𝟙 _) ≫ ε_ _ _) = (ᘁf) ≫ (ρ_ _).inv :=\n  by\n  dsimp [tensor_left_hom_equiv, left_adjoint_mate]\n  simp\n#align category_theory.tensor_left_hom_equiv_tensor_id_comp_evaluation CategoryTheory.tensorLeftHomEquiv_tensor_id_comp_evaluation\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorRightHomEquiv_id_tensor_comp_evaluation {X Y : C} [HasRightDual X] [HasRightDual Y]\n    (f : X ⟶ Y) : (tensorRightHomEquiv _ _ _ _) ((𝟙 (Yᘁ) ⊗ f) ≫ ε_ _ _) = fᘁ ≫ (λ_ _).inv :=\n  by\n  dsimp [tensor_right_hom_equiv, right_adjoint_mate]\n  simp\n#align category_theory.tensor_right_hom_equiv_id_tensor_comp_evaluation CategoryTheory.tensorRightHomEquiv_id_tensor_comp_evaluation\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensorRightHomEquiv_tensor_id_comp_evaluation {X Y : C} [HasRightDual X] (f : Y ⟶ Xᘁ) :\n    (tensorRightHomEquiv _ _ _ _) ((f ⊗ 𝟙 X) ≫ ε_ X (Xᘁ)) = f ≫ (λ_ _).inv :=\n  by\n  dsimp [tensor_right_hom_equiv]\n  rw [comp_tensor_id]\n  slice_lhs 3 4 => rw [← associator_inv_naturality]\n  slice_lhs 2 3 => rw [tensor_id, id_tensor_comp_tensor_id, ← tensor_id_comp_id_tensor]\n  slice_lhs 3 5 => rw [coevaluation_evaluation]\n  simp\n#align category_theory.tensor_right_hom_equiv_tensor_id_comp_evaluation CategoryTheory.tensorRightHomEquiv_tensor_id_comp_evaluation\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n-- Next four lemmas passing `fᘁ` or `ᘁf` through (co)evaluations.\ntheorem coevaluation_comp_rightAdjointMate {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) :\n    η_ Y (Yᘁ) ≫ (𝟙 _ ⊗ fᘁ) = η_ _ _ ≫ (f ⊗ 𝟙 _) :=\n  by\n  apply_fun (tensor_left_hom_equiv _ Y (Yᘁ) _).symm\n  simp\n#align category_theory.coevaluation_comp_right_adjoint_mate CategoryTheory.coevaluation_comp_rightAdjointMate\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem leftAdjointMate_comp_evaluation {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) :\n    (𝟙 X ⊗ ᘁf) ≫ ε_ _ _ = (f ⊗ 𝟙 _) ≫ ε_ _ _ :=\n  by\n  apply_fun tensor_left_hom_equiv _ (ᘁX) X _\n  simp\n#align category_theory.left_adjoint_mate_comp_evaluation CategoryTheory.leftAdjointMate_comp_evaluation\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem coevaluation_comp_leftAdjointMate {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X ⟶ Y) :\n    η_ (ᘁY) Y ≫ ((ᘁf) ⊗ 𝟙 Y) = η_ (ᘁX) X ≫ (𝟙 (ᘁX) ⊗ f) :=\n  by\n  apply_fun (tensor_right_hom_equiv _ (ᘁY) Y _).symm\n  simp\n#align category_theory.coevaluation_comp_left_adjoint_mate CategoryTheory.coevaluation_comp_leftAdjointMate\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem rightAdjointMate_comp_evaluation {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X ⟶ Y) :\n    (fᘁ ⊗ 𝟙 X) ≫ ε_ X (Xᘁ) = (𝟙 (Yᘁ) ⊗ f) ≫ ε_ Y (Yᘁ) :=\n  by\n  apply_fun tensor_right_hom_equiv _ X (Xᘁ) _\n  simp\n#align category_theory.right_adjoint_mate_comp_evaluation CategoryTheory.rightAdjointMate_comp_evaluation\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Transport an exact pairing across an isomorphism in the first argument. -/\ndef exactPairingCongrLeft {X X' Y : C} [ExactPairing X' Y] (i : X ≅ X') : ExactPairing X Y\n    where\n  evaluation := (𝟙 Y ⊗ i.Hom) ≫ ε_ _ _\n  coevaluation := η_ _ _ ≫ (i.inv ⊗ 𝟙 Y)\n  evaluation_coevaluation' := by\n    rw [id_tensor_comp, comp_tensor_id]\n    slice_lhs 2 3 => rw [associator_naturality]\n    slice_lhs 3 4 => rw [tensor_id, tensor_id_comp_id_tensor, ← id_tensor_comp_tensor_id]\n    slice_lhs 4 5 => rw [tensor_id_comp_id_tensor, ← id_tensor_comp_tensor_id]\n    slice_lhs 2 3 => rw [← associator_naturality]\n    slice_lhs 1 2 => rw [tensor_id, tensor_id_comp_id_tensor, ← id_tensor_comp_tensor_id]\n    slice_lhs 2 4 => rw [evaluation_coevaluation]\n    slice_lhs 1 2 => rw [left_unitor_naturality]\n    slice_lhs 3 4 => rw [← right_unitor_inv_naturality]\n    simp\n  coevaluation_evaluation' := by\n    rw [id_tensor_comp, comp_tensor_id]\n    simp only [iso.inv_hom_id_assoc, associator_conjugation, category.assoc]\n    slice_lhs 2 3 =>\n      rw [← tensor_comp]\n      simp\n    simp\n#align category_theory.exact_pairing_congr_left CategoryTheory.exactPairingCongrLeft\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Transport an exact pairing across an isomorphism in the second argument. -/\ndef exactPairingCongrRight {X Y Y' : C} [ExactPairing X Y'] (i : Y ≅ Y') : ExactPairing X Y\n    where\n  evaluation := (i.Hom ⊗ 𝟙 X) ≫ ε_ _ _\n  coevaluation := η_ _ _ ≫ (𝟙 X ⊗ i.inv)\n  evaluation_coevaluation' := by\n    rw [id_tensor_comp, comp_tensor_id]\n    simp only [iso.inv_hom_id_assoc, associator_conjugation, category.assoc]\n    slice_lhs 3 4 =>\n      rw [← tensor_comp]\n      simp\n    simp\n  coevaluation_evaluation' := by\n    rw [id_tensor_comp, comp_tensor_id]\n    slice_lhs 3 4 => rw [← associator_inv_naturality]\n    slice_lhs 2 3 => rw [tensor_id, id_tensor_comp_tensor_id, ← tensor_id_comp_id_tensor]\n    slice_lhs 1 2 => rw [id_tensor_comp_tensor_id, ← tensor_id_comp_id_tensor]\n    slice_lhs 3 4 => rw [associator_inv_naturality]\n    slice_lhs 4 5 => rw [tensor_id, id_tensor_comp_tensor_id, ← tensor_id_comp_id_tensor]\n    slice_lhs 2 4 => rw [coevaluation_evaluation]\n    slice_lhs 1 2 => rw [right_unitor_naturality]\n    slice_lhs 3 4 => rw [← left_unitor_inv_naturality]\n    simp\n#align category_theory.exact_pairing_congr_right CategoryTheory.exactPairingCongrRight\n\n/-- Transport an exact pairing across isomorphisms. -/\ndef exactPairingCongr {X X' Y Y' : C} [ExactPairing X' Y'] (i : X ≅ X') (j : Y ≅ Y') :\n    ExactPairing X Y :=\n  haveI : exact_pairing X' Y := exact_pairing_congr_right j\n  exact_pairing_congr_left i\n#align category_theory.exact_pairing_congr CategoryTheory.exactPairingCongr\n\n/-- Right duals are isomorphic. -/\ndef rightDualIso {X Y₁ Y₂ : C} (_ : ExactPairing X Y₁) (_ : ExactPairing X Y₂) : Y₁ ≅ Y₂\n    where\n  Hom := @rightAdjointMate C _ _ X X ⟨Y₂⟩ ⟨Y₁⟩ (𝟙 X)\n  inv := @rightAdjointMate C _ _ X X ⟨Y₁⟩ ⟨Y₂⟩ (𝟙 X)\n  hom_inv_id' := by rw [← comp_right_adjoint_mate, category.comp_id, right_adjoint_mate_id]\n  inv_hom_id' := by rw [← comp_right_adjoint_mate, category.comp_id, right_adjoint_mate_id]\n#align category_theory.right_dual_iso CategoryTheory.rightDualIso\n\n/-- Left duals are isomorphic. -/\ndef leftDualIso {X₁ X₂ Y : C} (p₁ : ExactPairing X₁ Y) (p₂ : ExactPairing X₂ Y) : X₁ ≅ X₂\n    where\n  Hom := @leftAdjointMate C _ _ Y Y ⟨X₂⟩ ⟨X₁⟩ (𝟙 Y)\n  inv := @leftAdjointMate C _ _ Y Y ⟨X₁⟩ ⟨X₂⟩ (𝟙 Y)\n  hom_inv_id' := by rw [← comp_left_adjoint_mate, category.comp_id, left_adjoint_mate_id]\n  inv_hom_id' := by rw [← comp_left_adjoint_mate, category.comp_id, left_adjoint_mate_id]\n#align category_theory.left_dual_iso CategoryTheory.leftDualIso\n\n@[simp]\ntheorem rightDualIso_id {X Y : C} (p : ExactPairing X Y) : rightDualIso p p = Iso.refl Y :=\n  by\n  ext\n  simp only [right_dual_iso, iso.refl_hom, right_adjoint_mate_id]\n#align category_theory.right_dual_iso_id CategoryTheory.rightDualIso_id\n\n@[simp]\ntheorem leftDualIso_id {X Y : C} (p : ExactPairing X Y) : leftDualIso p p = Iso.refl X :=\n  by\n  ext\n  simp only [left_dual_iso, iso.refl_hom, left_adjoint_mate_id]\n#align category_theory.left_dual_iso_id CategoryTheory.leftDualIso_id\n\n/-- A right rigid monoidal category is one in which every object has a right dual. -/\nclass RightRigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where\n  [rightDual : ∀ X : C, HasRightDual X]\n#align category_theory.right_rigid_category CategoryTheory.RightRigidCategory\n\n/-- A left rigid monoidal category is one in which every object has a right dual. -/\nclass LeftRigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where\n  [leftDual : ∀ X : C, HasLeftDual X]\n#align category_theory.left_rigid_category CategoryTheory.LeftRigidCategory\n\nattribute [instance] right_rigid_category.right_dual\n\nattribute [instance] left_rigid_category.left_dual\n\n/-- Any left rigid category is monoidal closed, with the internal hom `X ⟶[C] Y = ᘁX ⊗ Y`.\nThis has to be a definition rather than an instance to avoid diamonds, for example between\n`category_theory.monoidal_closed.functor_category` and\n`category_theory.monoidal.left_rigid_functor_category`. Moreover, in concrete applications there is\noften a more useful definition of the internal hom object than `ᘁY ⊗ X`, in which case the monoidal\nclosed structure shouldn't come the rigid structure (e.g. in the category `FinVect k`, it is more\nconvenient to define the internal hom as `Y →ₗ[k] X` rather than `ᘁY ⊗ X` even though these are\nnaturally isomorphic). -/\ndef monoidalClosedOfLeftRigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C]\n    [LeftRigidCategory C] : MonoidalClosed C where closed' X := closedOfHasLeftDual X\n#align category_theory.monoidal_closed_of_left_rigid_category CategoryTheory.monoidalClosedOfLeftRigidCategory\n\n/-- A rigid monoidal category is a monoidal category which is left rigid and right rigid. -/\nclass RigidCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] extends\n  RightRigidCategory C, LeftRigidCategory C\n#align category_theory.rigid_category CategoryTheory.RigidCategory\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Monoidal/Rigid/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370114, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.46221488505960634}}
{"text": "import .basic\n\nnamespace data.containers\nnamespace rbtree\n\nopen color\n\n/-- An insert_result is a generalization of the tree to allow\na node with 2-keys and 3-children each of which should have the\nsame height.\n\nThis is used\nSpecifically, it is either a tree that respects the red-black rules,\nor a the concatenation of three trees with the same height.\n-/\ninductive insert_result (E : Type _)\n| tree : Π (t : rbtree E), insert_result\n-- When inserting into a binary tree that respects the ordering\n-- and red-black color rules, by construction we know that the trees\n-- are in ascending order, either the first or third tree are colored\n-- black, and the center node is colored black.\n| triple : rbtree E → E → rbtree E →  E → rbtree E → insert_result\n\nnamespace insert_result\nsection\nparameters {E:Type _}\n\n/--\nConvert an insert result to a tree.\n\nN.B. This may increase the black-height, so should only be called in contexts\nwhere that matters (i.e. at the roto.)\n-/\ndef as_tree : insert_result E → rbtree E\n| (tree u) := u\n| (triple l x c y r) :=\n  match l with\n  | bin red ll lx lr := bin black (bin black ll lx lr) x (bin black c y r)\n  | _ := bin black (bin red l x c) y r\n  end\n\ndef to_list : insert_result E → list E\n| (tree t) := t.to_list\n| (triple l x c y r) := l.to_list ++ [x] ++ c.to_list ++ [y] ++ r.to_list\n\nparameters [has_preordering E]\n\n/-- Check whether a insert_result respects the ordering relation. -/\ndef is_ordered : insert_result E → Prop\n| (tree t) := t.is_ordered\n| (triple l x c y r) :=\n   l.is_ordered\n   ∧ all_lt l x\n   ∧ all_gt c x\n   ∧ c.is_ordered ∧ has_ordering.cmp x y = ordering.lt\n   ∧ all_lt c y\n   ∧ all_gt r y\n   ∧ r.is_ordered\n\ninstance (r : insert_result E) : decidable (is_ordered r) :=\nbegin\n  cases r; simp [is_ordered]; apply_instance,\nend\n\n/- Return true if keys on right spine of rbtree are less then k. -/\ndef all_lt : insert_result E → E → Prop\n| (tree t) a := t.all_lt a\n| (triple l x c y r) a :=\n  has_ordering.cmp y a = ordering.lt ∧ r.all_lt a\n\n/- Return true if keys on right spine of rbtree are less then k. -/\ndef all_gt : insert_result E → E → Prop\n| (tree t) a := t.all_gt a\n| (triple l x c y r) a :=\n  has_ordering.cmp a x = ordering.lt ∧ l.all_gt a\n\nend\nend insert_result\n\nsection insert_def\nparameters {E:Type _}\n\nopen insert_result\n\ndef balanceL : color → insert_result E → E → rbtree E → insert_result E\n-- In this case, the caller should be able to guarantee that co is black, so the\n-- black depth of the tree should not change.\n| co (triple ll lx lc ly lr) x r :=\n  tree (bin red (bin black ll lx lc) ly (bin black lr x r))\n| co (tree l) x r :=\n  match (co, l) with\n  | (red, bin red ll lx lr) := triple ll lx lr x r\n  | _ := tree (bin co l x r)\n  end\n\ndef balanceR : color → rbtree E → E → insert_result E → insert_result E\n-- In this case co is guaranteed to be black, so the\n-- black depth of the tree should not change.\n| co l x (triple rl rx rc ry rr) :=\n  tree (bin red (bin black l x rl) rx (bin black rc ry rr))\n| co l x (tree r) :=\n  match (co, r) with\n  | (red, bin red rl rx rr) := triple l x rl rx rr\n  | _ := tree (bin co l x r)\n  end\n\nparameters [has_preordering E]\n\ndef insert_core (y : E) : rbtree E → insert_result E\n| empty := tree (bin red empty y empty)\n| (bin c l x r) :=\n  match has_ordering.cmp y x with\n  | ordering.lt := balanceL c (insert_core l) x r\n  | ordering.eq := tree (bin c l y r)\n  | ordering.gt := balanceR c l x (insert_core r)\n  end\n\ndef insert (y : E) (t : rbtree E) : rbtree E :=\n  (insert_core y t).as_tree\n\nend insert_def\n\n-----------------------------------------------------------------------\n-- to_list\n\nsection to_list_theorems\nparameters {E:Type _}\n\ntheorem to_list_balanceL (c : color) (l : insert_result E) (x : E) (r : rbtree E)\n: (balanceL c l x r).to_list  = l.to_list ++ [x] ++ r.to_list :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc }; cases c, };\n  simp [*, balanceL, insert_result.to_list, to_list],\nend\n\ntheorem to_list_balanceR\n(c : color) (l : rbtree E) (x : E) (r : insert_result E)\n: (balanceR c l x r).to_list = l.to_list ++ [x] ++ r.to_list :=\nbegin\n  cases r with t l x tc y r;\n    try {\n      cases t with rc rl rx rr; try { cases rc };\n        cases c,\n    };\n  simp [*, balanceR, insert_result.to_list, to_list],\nend\n\ntheorem to_list_as_tree (r : insert_result E)\n: r.as_tree.to_list = r.to_list :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases tl with tlc tll tlx tlr;  try { cases tlc }, };\n    simp [insert_result.as_tree, rbtree.tree_color, insert_result.to_list, to_list],\nend\n\nparameters [has_preordering E]\n\ntheorem to_list_insert_core (y : E) (t : rbtree E)\n: is_ordered t\n→ (insert_core y t).to_list\n    = t.to_list.filter (key_is_lt y) ++ y :: t.to_list.filter (key_is_gt y) :=\nbegin\n  induction t,\n  case empty {\n    intros,\n    simp [insert_core, insert_result.to_list, to_list],\n  },\n  case bin c l x r l_ind r_ind {\n    simp [is_ordered, insert_core, to_list, list.filter, key_is_lt, key_is_gt],\n\n    have g1 : (ordering.gt ≠ ordering.lt), exact dec_trivial,\n    have g2 : ordering.lt ≤ ordering.eq, exact dec_trivial,\n    have g3 : ordering.eq ≤ ordering.eq, exact dec_trivial,\n    have g4 : ordering.eq ≠ ordering.lt, exact dec_trivial,\n\n    have cmp_x_y_eq : has_ordering.cmp x y = (has_ordering.cmp y x).swap,\n    { rw [has_preordering.swap_cmp], },\n\n    intros iso_l iso_r all_gt_r_x all_lt_l_x,\n    have all_lt_r_key := all_lt_congr l x y,\n    have all_gt_r_key := all_gt_congr r y x,\n    have l_lt := filter_lt_of_all_lt l y,\n    have l_gt := filter_gt_of_all_lt l y,\n    have r_lt := filter_lt_of_all_gt r y,\n    have r_gt := filter_gt_of_all_gt r y,\n    destruct (has_ordering.cmp y x); intro cmp_y_x;\n      simp [cmp_y_x, ordering.swap] at cmp_x_y_eq,\n    { simp [insert_core, *, to_list_balanceL, l_ind], },\n    { simp [insert_core, *, insert_result.to_list, to_list ], },\n    { simp [insert_core, *, to_list_balanceR, r_ind], },\n  },\nend\n\ntheorem to_list_insert (y : E) (t : rbtree E) : is_ordered t\n → to_list (insert y t)\n    = t.to_list.filter (key_is_lt y) ++ y :: t.to_list.filter (key_is_gt y) :=\nbegin\n  intros,\n  simp [insert, to_list_as_tree, to_list_insert_core, *],\nend\n\ntheorem insert_eq (y : E)\n: ∀{t u : rbtree E},\n   is_ordered t\n   → is_ordered u\n   → t.to_list = u.to_list\n   → to_list (insert y t) = to_list (insert y t) :=\nbegin\n  intros x y x_order y_order x_eq_y,\n  simp [to_list_insert, *],\nend\n\nend to_list_theorems\n\n-----------------------------------------------------------------------\n-- is_ordered\n\nsection is_ordered_theorems\nparameters {E:Type _}\n\nparameters [has_preordering E]\nlocal attribute [simp] balanceL balanceR insert_result.is_ordered is_ordered\n  insert_result.all_lt all_lt insert_result.all_gt all_gt\n  insert_core\n\nsection balanceL\nparameters (c : color) (l : insert_result E) (y : E) (r : rbtree E)\n\ntheorem all_lt_balanceL (a : E)\n  (all_lt_l : l.all_lt a)\n  (y_lt_bnd : has_ordering.cmp y a = ordering.lt)\n  (all_lt_r : all_lt r a)\n: (balanceL c l y r).all_lt a :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc }; cases c, };\n  try { simp at all_lt_l, simp [*], },\nend\n\ntheorem all_gt_balanceL (a : E)\n  (iso : l.is_ordered)\n  (a_lt_y : has_ordering.cmp a y = ordering.lt)\n  (all_gt_l : l.all_gt a)\n: (balanceL c l y r).all_gt a :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc }; cases c, };\n  try { simp at all_gt_l, simp [*], },\n  simp at iso,\n  apply has_preordering.lt_of_lt_of_lt a tx ty; simp [*],\nend\n\ntheorem is_ordered_balanceL\n  (l_iso : l.is_ordered)\n  (all_lt_l_y : l.all_lt y)\n  (all_gt_r_y : all_gt r y)\n  (iso_r : is_ordered r)\n: (balanceL c l y r).is_ordered :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc }; cases c, };\n  try {   simp at l_iso all_lt_l_y, simp [*],},\nend\nend balanceL\n\nsection balanceR\nparameters (c : color) (l : rbtree E) (y : E) (r : insert_result E)\n\ntheorem all_lt_balanceR (a : E)\n  (iso : r.is_ordered)\n  (y_lt_a : has_ordering.cmp y a = ordering.lt)\n  (all_lt_r_a : r.all_lt a)\n: (balanceR c l y r).all_lt a :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases t with rc rl rx rr; try { cases rc }; cases c, };\n  try { simp at all_lt_r_a, simp [*], },\n  simp at iso,\n  apply has_preordering.lt_of_lt_of_lt tx ty a; simp [*],\nend\n\ntheorem all_gt_balanceR (a : E)\n  (a_lt_y : has_ordering.cmp a y = ordering.lt)\n  (all_gt_l : all_gt l a)\n  (all_gt_r : r.all_gt a)\n: (balanceR c l y r).all_gt a :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases t with rc rl rx rr; try { cases rc }; cases c, };\n  try { simp at all_gt_r, simp[*], },\nend\n\ntheorem is_ordered_balanceR\n  (l_iso : is_ordered l)\n  (all_lt_l_y : all_lt l y)\n  (all_gt_r_y : r.all_gt y)\n  (r_iso : r.is_ordered)\n: (balanceR c l y r).is_ordered :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases t with rc rl rx rr; try { cases rc }; cases c, };\n  try { simp at all_gt_r_y r_iso, simp[*], },\nend\nend balanceR\n\ntheorem is_ordered_as_tree {r : insert_result E}\n  (iso : r.is_ordered)\n: r.as_tree.is_ordered :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases tl with lc ll lx lr; try { cases lc}, };\n  simp at iso; simp [insert_result.as_tree, *],\nend\n\ntheorem insert_core_preserves (y : E) {t : rbtree E}\n  (iso : is_ordered t)\n: (insert_core y t).is_ordered\n∧ (∀ (a : E), has_ordering.cmp y a = ordering.lt\n            → t.all_lt a\n            → (insert_core y t).all_lt a)\n∧ (∀ (a:E), has_ordering.cmp a y = ordering.lt\n               → t.all_gt a\n               → (insert_core y t).all_gt a) :=\nbegin\n  induction t,\n  case empty {\n    intros,\n    simp,\n  },\n  case bin c l x r l_ind r_ind {\n    simp at iso,\n    simp only [iso, true_implies_iff] at l_ind r_ind,\n    have l_all_lt := l_ind.right.left,\n    have r_all_gt := r_ind.right.right,\n    destruct (has_ordering.cmp y x);\n      intro cmp_y_s;\n      simp only [cmp_y_s, insert_core, all_lt],\n    { apply and.intro,\n      { apply is_ordered_balanceL,\n        all_goals { simp [*], },\n      },\n      apply and.intro,\n      { intros a y_lt_a pr,\n        apply all_lt_balanceL,\n        apply l_all_lt,\n        all_goals { try { simp [*],} },\n        apply all_lt_congr l x a; simp[*],\n      },\n      { intros a a_lt_y pr,\n        simp at pr,\n        apply all_gt_balanceL,\n        all_goals { simp [*], },\n      }\n    },\n    { apply and.intro,\n      { simp [*],\n        apply and.intro,\n        { apply all_gt_congr r y x; simp [*], },\n        { have h0 := has_preordering.eq_symm y x,\n          apply all_lt_congr l x y; simp [*],\n        },\n      },\n      apply and.intro,\n      { intros a y_lt_a x_lt_a, simp [*], },\n      { intros a a_lt_y gt_a, simp at gt_a, simp [*], },\n    },\n    { rw [has_preordering.gt_lt_symm] at cmp_y_s,\n      apply and.intro,\n      { apply is_ordered_balanceR; simp[*], },\n      apply and.intro,\n      { intros a y_lt_a x_lt_a,\n        apply all_lt_balanceR; simp[*],\n      },\n      { intros a a_lt_y pr,\n        simp at pr,\n        apply all_gt_balanceR; try { simp[*] },\n        apply r_all_gt; try { simp[*] },\n        apply all_gt_congr r a x; try { simp[*] },\n      },\n    },\n  },\nend\n\ntheorem is_ordered_insert (y : E) (t : rbtree E)\n: is_ordered t → is_ordered (insert y t) :=\nbegin\n  intro iso,\n  simp [insert],\n  apply is_ordered_as_tree,\n  have h := insert_core_preserves y iso,\n  simp[h],\nend\nend is_ordered_theorems\n\n-----------------------------------------------------------------------\n-- to_list\n\n\nnamespace insert_result\nsection\nparameters {E:Type _}\n\ndef black_height : insert_result E → ℕ\n| (triple l _ _ _ _) := l.black_height\n| (tree t) := t.black_height\n\ndef well_formed : insert_result E → Prop\n| (triple l x c y r) :=\n  l.well_formed\n  ∧ c.well_formed\n  ∧ r.well_formed\n  ∧ l.black_height = c.black_height\n  ∧ c.black_height = r.black_height\n  ∧ c.tree_color = black\n| (tree t) := t.well_formed\n\nend\nend insert_result\n\nsection is_well_formed_theorems\nparameters {E:Type _}\nlocal attribute [simp] balanceL balanceR insert_result.well_formed well_formed\n  rbtree.tree_color insert_result.black_height black_height\n  insert_result.as_tree nat.add_succ\n  insert_core\n\ntheorem succ_eq_succ (m n :ℕ) : (nat.succ m = nat.succ n) ↔ (m = n) :=\n  iff.intro nat.succ.inj (congr_arg nat.succ)\n\nlocal attribute [simp] succ_eq_succ\n\ntheorem well_formed_balanceL_black (l : insert_result E) (x : E) (r : rbtree E)\n(l_wf : l.well_formed)\n(r_wf : r.well_formed)\n(l_ht_eq_r_ht : r.black_height = l.black_height)\n: (balanceL black l x r).well_formed  :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc } };\n    simp at l_wf l_ht_eq_r_ht;\n    simp [*],\nend\n\ntheorem well_formed_balanceL_red (l : insert_result E) (x : E) (r : rbtree E)\n(l_wf : l.well_formed)\n(r_wf : r.well_formed)\n(l_ht_eq_r_ht : r.black_height = l.black_height)\n(r_black : r.tree_color = black)\n: (balanceL red l x r).well_formed  :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc } };\n    simp at l_wf;\n    simp [*],\nend\n\ntheorem well_formed_balanceR_black (l : rbtree E) (x : E) (r : insert_result E)\n(l_wf : l.well_formed)\n(r_wf : r.well_formed)\n(l_ht_eq_r_ht : l.black_height = r.black_height)\n: (balanceR black l x r).well_formed  :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases t with rc rl rx rr; try { cases rc } };\n    simp at r_wf;\n    simp [*],\nend\n\ntheorem well_formed_balanceR_red (l : rbtree E) (x : E) (r : insert_result E)\n(l_wf : l.well_formed)\n(r_wf : r.well_formed)\n(l_ht_eq_r_ht : l.black_height = r.black_height)\n(l_black : l.tree_color = black)\n: (balanceR red l x r).well_formed  :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases t with rc rl rx rr; try { cases rc } };\n    simp at r_wf;\n    try { simp [*], },\nend\n\n\ntheorem black_height_balanceL_black (l : insert_result E) (x : E) (r : rbtree E)\n: (balanceL black l x r).black_height = l.black_height + 1 :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc } };\n    simp [*],\nend\n\ntheorem black_height_balanceL_red (l : rbtree E) (x : E) (r : rbtree E)\n: (balanceL red (insert_result.tree l) x r).black_height = l.black_height :=\nbegin\n  cases l with t tl tx tc ty tr;\n    try { cases t with lc ll lx lr; try { cases lc } };\n    simp [*],\nend\n\ntheorem black_height_balanceR_black (l : rbtree E) (x : E) (r : insert_result E)\n: (balanceR black l x r).black_height = l.black_height + 1 :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases t with rc rl rx rr; try { cases rc } };\n    simp [*],\nend\n\ntheorem black_height_balanceR_red (l : rbtree E) (x : E) (r : rbtree E)\n: (balanceR red l x (insert_result.tree r)).black_height = l.black_height :=\nbegin\n  cases r with t tl tx tc ty tr;\n    try { cases t with rc rl rx rr; try { cases rc } };\n    simp [*],\nend\n\ntheorem well_formed_as_tree (r : insert_result E)\n: r.well_formed → r.as_tree.well_formed :=\nbegin\n  intro r_wf,\n  cases r with t tl tx tc ty tr;\n    try { cases tl with tlc tll tlx tlr; try { cases tlc }, };\n    try { simp at r_wf, simp[r_wf], };\n    cc,\nend\n\n-- To simplify insert_core, we need a restricted definitions that work\n-- when the root node of the tree is colored black.  This allows us\n-- to make balanceL, balanceR, and insert_core return rbtrees rather\n-- that insert_result.\nsection\n\ndef balanceL_black : insert_result E → E → rbtree E → rbtree E\n| (insert_result.triple ll lx lc ly lr) x r :=\n  bin red (bin black ll lx lc) ly (bin black lr x r)\n| (insert_result.tree l) x r := bin black l x r\n\ndef balanceR_black : rbtree E → E → insert_result E → rbtree E\n| l x (insert_result.triple rl rx rc ry rr) :=\n bin red (bin black l x rl) rx (bin black rc ry rr)\n| l x (insert_result.tree r) := bin black l x r\n\nparameters [has_preordering E]\n\ndef insert_core_black (y : E) : rbtree E → rbtree E\n| empty := bin red empty y empty\n| (bin c l x r) :=\n  match has_ordering.cmp y x with\n  | ordering.lt := balanceL_black (insert_core y l) x r\n  | ordering.eq := bin c l y r\n  | ordering.gt := balanceR_black l x (insert_core y r)\n  end\n\ntheorem insert_core_black_eq (y : E) (t : rbtree E)\n: t.tree_color = black → insert_core y t = insert_result.tree (insert_core_black y t) :=\nbegin\n  intro isb,\n  cases t with c l x r,\n  { simp [insert_core_black], },\n  { simp at isb,\n    destruct (has_ordering.cmp y x); intro cmp_y_x;\n      simp [*, insert_core_black],\n    { cases (insert_core y l); simp [balanceL_black], },\n    { cases (insert_core y r); simp [balanceR_black], },\n  },\nend\nend\n\nparameters [has_preordering E]\n\nlocal attribute [simp]\n  black_height_balanceL_black\n  black_height_balanceL_red\n  black_height_balanceR_black\n  black_height_balanceR_red\n\ntheorem black_height_insert_core (y : E) (t : rbtree E)\n: t.well_formed → (insert_core y t).black_height = t.black_height :=\nbegin\n  induction t,\n  case empty {\n    intros,\n    simp,\n  },\n  case bin c l x r l_ind r_ind {\n    cases c,\n    case red {\n      destruct (has_ordering.cmp y x); intro cmp_y_x; simp [cmp_y_x],\n      { intros l_wf r_wf l_isb r_isb l_ht_eq,\n        simp only [insert_core_black_eq y l l_isb, insert_result.black_height ] at l_ind,\n        simp only [*, insert_core_black_eq y l l_isb, black_height_balanceL_red],\n      },\n      { intros l_wf r_wf l_isb r_isb l_ht_eq,\n        simp only [*, insert_core_black_eq y r r_isb, black_height_balanceR_red],\n      },\n    },\n    case black {\n      destruct (has_ordering.cmp y x); intro cmp_y_x; simp [cmp_y_x],\n      { intros l_wf r_wf l_ht_eq,\n        simp only [*],\n      },\n    }\n  },\nend\n\nlocal attribute [simp] black_height_insert_core\n\ntheorem well_formed_insert_core (y : E) (t : rbtree E)\n: t.well_formed → (insert_core y t).well_formed :=\nbegin\n  induction t,\n  case empty {\n    intros,\n    simp,\n  },\n  case bin c l x r l_ind r_ind {\n    cases c,\n    case red {\n      destruct (has_ordering.cmp y x);\n        intro cmp_y_x;\n        simp [cmp_y_x];\n        intros,\n      { apply well_formed_balanceL_red; simp [*], },\n      { simp[*], },\n      { apply well_formed_balanceR_red; simp[*], },\n    },\n    case black {\n      destruct (has_ordering.cmp y x);\n        intro cmp_y_x;\n        simp [cmp_y_x];\n        intros,\n      { apply well_formed_balanceL_black; simp [*], },\n      { simp[*], },\n      { apply well_formed_balanceR_black; simp[*], },\n    }\n  },\nend\n\ntheorem well_formed_insert (y : E) (t : rbtree E) : t.well_formed\n → (insert y t).well_formed :=\nbegin\n  intros,\n  apply well_formed_as_tree,\n  apply well_formed_insert_core,\n  assumption,\nend\n\nend is_well_formed_theorems\n\nend rbtree\nend data.containers\n", "meta": {"author": "joehendrix", "repo": "lean-containers", "sha": "ef6ff0533eada75f18922039f8312badf12e6124", "save_path": "github-repos/lean/joehendrix-lean-containers", "path": "github-repos/lean/joehendrix-lean-containers/lean-containers-ef6ff0533eada75f18922039f8312badf12e6124/data/containers/rbtree/insert.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6548947155710233, "lm_q1q2_score": 0.46221488505960623}}
{"text": "/-\nCopyright (c) 2017 Daniel Selsam. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Daniel Selsam\n\nPredicates.\n-/\nimport .util .id .reference .graph .compute_grad\nopen list\n\nnamespace certigrad\n\ndef is_downstream (cost : ID) : reference → list node → Prop\n| _   [] := false\n\n| tgt (⟨ref, parents, _⟩ :: nodes) :=\n  if ref.1 = cost\n  then true\n  else (tgt ∈ parents ∧ is_downstream ref nodes) ∨ is_downstream tgt nodes\n\ninstance decidable_is_downstream (cost : ID) : Π (tgt : reference) (nodes : list node), decidable (is_downstream cost tgt nodes)\n| _   [] := decidable.false\n\n| tgt (⟨ref, parents, _⟩ :: nodes) :=\n  show decidable (if ref.1 = cost then true else (tgt ∈ parents ∧ is_downstream cost ref nodes) ∨ is_downstream cost tgt nodes), from\n  have H₁ : decidable (is_downstream cost ref nodes), from begin apply decidable_is_downstream end,\n  have H₂ : decidable (is_downstream cost tgt nodes), from begin apply decidable_is_downstream end,\n  by tactic.apply_instance\n\ndef all_parents_in_env : Π (inputs : env) (nodes : list node), Prop\n| _   [] := true\n\n| inputs (⟨ref, parents, _⟩ :: nodes) :=\n  (∀ (parent : reference), parent ∈ parents → env.has_key parent inputs)\n  ∧ (∀ (x : T ref.2), all_parents_in_env (env.insert ref x inputs) nodes)\n\ndef all_costs_scalars (costs : list ID) : Π (nodes : list node), Prop\n| [] := true\n| (⟨ref, _, _⟩ :: nodes) := (ref.1 ∈ costs → ref.2 = []) ∧ all_costs_scalars nodes\n\n-- We group the decidable properties\nstructure well_formed_at (costs : list ID) (nodes : list node) (inputs : env) (tgt : reference) : Prop :=\n  (uids : uniq_ids nodes inputs)\n  (ps_in_env : all_parents_in_env inputs nodes)\n  (costs_scalars : all_costs_scalars costs nodes)\n  (m_contains_tgt : env.has_key tgt inputs)\n  (tgt_cost_scalar : tgt.1 ∈ costs → tgt.2 = [])\n\ndef grads_exist_at : list node → env → reference → Prop\n| [] _ _ := true\n\n| (⟨ref, parents, operator.det op⟩ :: nodes) m tgt  :=\n  let m' := env.insert ref (op^.f (env.get_ks parents m)) m in\n  grads_exist_at nodes m' tgt\n  ∧ (tgt ∈ parents → op^.pre (env.get_ks parents m) ∧ grads_exist_at nodes m' ref)\n\n| (⟨ref, parents, operator.rand op⟩ :: nodes) m tgt  :=\n  let m' := (λ (y : T ref.2), env.insert ref y m) in\n  (tgt ∈ parents → op^.pre (env.get_ks parents m)) ∧ (∀ y, grads_exist_at nodes (m' y) tgt)\n\ndef pdfs_exist_at : list node → env → Prop\n| [] _ := true\n\n| (⟨ref, parents, operator.det op⟩ :: nodes) m := pdfs_exist_at nodes (env.insert ref (op^.f (env.get_ks parents m)) m )\n\n| (⟨ref, parents, operator.rand op⟩ :: nodes) m :=\n  let m' := (λ (y : T ref.2), env.insert ref y m) in\n  (op^.pre (env.get_ks parents m)) ∧ (∀ y, pdfs_exist_at nodes (m' y))\n\n-- TODO(dhs): these conditions are really nitty-gritty\nnoncomputable def can_differentiate_under_integrals (costs : list ID) : list node → env → reference → Prop\n| [] _ _ := true\n\n| (⟨ref, parents, operator.det op⟩ :: nodes) inputs tgt  :=\n  let inputs' := env.insert ref (op^.f (env.get_ks parents inputs)) inputs in\n  can_differentiate_under_integrals nodes inputs' tgt\n  ∧ (tgt ∈ parents → can_differentiate_under_integrals nodes (env.insert ref (op^.f (env.get_ks parents inputs)) inputs) ref)\n\n| (⟨ref, parents, operator.rand op⟩ :: nodes) inputs tgt  :=\n  let θ : T tgt.2 := env.get tgt inputs in\n  let g : T ref.2 → T tgt.2 → ℝ :=\n  (λ (x : T ref.2) (θ₀ : T tgt.2),\n      E (graph.to_dist (λ (inputs : env), ⟦sum_costs inputs costs⟧)\n                       (env.insert ref x (env.insert tgt θ₀ inputs))\n                       nodes)\n        dvec.head) in\n  let next_inputs := (λ (y : T ref.2), env.insert ref y inputs) in\n-- Note: these conditions are redundant, but it is convenient to collect all the variations we need in one place\n (T.is_uniformly_integrable_around (λ (θ₀ : T (tgt.snd)) (x : T (ref.snd)), rand.op.pdf op (env.get_ks parents (env.insert tgt θ₀ inputs)) x ⬝ g x θ₀) θ\n\n    ∧ (T.is_uniformly_integrable_around (λ (θ₀ : T (tgt.snd)) (x : T (ref.snd)), ∇ (λ (θ₁ : T (tgt.snd)), rand.op.pdf op (env.get_ks parents (env.insert tgt θ₁ inputs)) x ⬝ g x θ₁) θ₀) θ\n       ∧ T.is_uniformly_integrable_around (λ (θ₀ : T (tgt.snd)) (x : T (ref.snd)), ∇ (λ (θ₁ : T (tgt.snd)), rand.op.pdf op (env.get_ks parents (env.insert tgt θ inputs)) x ⬝ g x θ₁) θ₀) θ)\n\n    ∧ (∀ (idx : ℕ), at_idx parents idx tgt →\n    T.is_uniformly_integrable_around (λ (θ₀ : T (tgt.snd)) (x : T (ref.snd)), rand.op.pdf op (dvec.update_at θ₀ (env.get_ks parents (env.insert tgt θ inputs)) idx) x ⬝ g x θ) θ)\n   ∧ (∀ (idx : ℕ),  at_idx parents idx tgt →\n    T.is_uniformly_integrable_around (λ (θ₀ : T (tgt.snd)) (x : T (ref.snd)),\n                                         ∇ (λ (θ₀ : T (tgt.snd)), rand.op.pdf op (dvec.update_at θ₀ (env.get_ks parents (env.insert tgt θ inputs)) idx) x ⬝ g x θ) θ₀) θ))\n∧ (∀ y, can_differentiate_under_integrals nodes (next_inputs y) tgt)\n\ndef all_pdfs_std : Π (nodes : list node), Prop\n| [] := true\n| (⟨ref, parents, operator.det op⟩ :: nodes) := all_pdfs_std nodes\n| (⟨(ref, .(shape)), [], operator.rand (rand.op.mvn_std shape)⟩ :: nodes) := all_pdfs_std nodes\n| (⟨(ref, .(shape)), [(parent₁, .(shape)), (parent₂, .(shape))], operator.rand (rand.op.mvn shape)⟩ :: nodes) := false\n\nlemma all_pdfs_std_det : Π (ref : reference) (parents : list reference) (op : det.op parents^.p2 ref.2) (nodes : list node),\n  all_pdfs_std (⟨ref, parents, operator.det op⟩ :: nodes) = all_pdfs_std nodes\n| (i, s) [] op nodes := rfl\n| (i, s) [(i', s')] op nodes := rfl\n| (i, s) [(i', s'), (i'', s'')] op nodes := rfl\n| (i, s) ((i', s') :: (i'', s'') :: a :: iss) op nodes := rfl\n\nnoncomputable def can_diff_under_ints_pdfs_std (costs : list ID) : Π (nodes : list node) (m : env) (tgt : reference), Prop\n| [] _ _ := true\n\n| (⟨ref, parents, operator.det op⟩ :: nodes) inputs tgt  :=\n  let inputs' := env.insert ref (op^.f (env.get_ks parents inputs)) inputs in\n  can_diff_under_ints_pdfs_std nodes inputs' tgt\n  ∧ (tgt ∈ parents → can_diff_under_ints_pdfs_std nodes (env.insert ref (op^.f (env.get_ks parents inputs)) inputs) ref)\n\n| (⟨ref, parents, operator.rand op⟩ :: nodes) inputs tgt  :=\n  let θ : T tgt.2 := env.get tgt inputs in\n  let g : T ref.2 → T tgt.2 → ℝ :=\n  (λ (x : T ref.2) (θ₀ : T tgt.2),\n      E (graph.to_dist (λ (inputs : env), ⟦sum_costs inputs costs⟧)\n                       (env.insert ref x (env.insert tgt θ₀ inputs))\n                       nodes)\n        dvec.head) in\n  let next_inputs := (λ (y : T ref.2), env.insert ref y inputs) in\n\n (T.is_uniformly_integrable_around (λ (θ₀ : T (tgt.snd)) (x : T (ref.snd)), T.mvn_pdf 0 1 x ⬝ g x θ₀) θ\n    ∧ T.is_uniformly_integrable_around (λ (θ₀ : T (tgt.snd)) (x : T (ref.snd)), ∇ (λ (θ₁ : T (tgt.snd)), T.mvn_pdf 0 1 x ⬝ g x θ₁) θ₀) θ)\n∧ (∀ y, can_diff_under_ints_pdfs_std nodes (next_inputs y) tgt)\n\nend certigrad\n", "meta": {"author": "dselsam", "repo": "certigrad", "sha": "c9a06e93f1ec58196d6d3b8563b29868d916727f", "save_path": "github-repos/lean/dselsam-certigrad", "path": "github-repos/lean/dselsam-certigrad/certigrad-c9a06e93f1ec58196d6d3b8563b29868d916727f/src/certigrad/predicates.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.46217379116724583}}
{"text": "\n\nimport data.real.basic\nimport data.real.nnreal\n\ntheorem exo (f: nnreal -> nnreal):\n  (forall x y, (f x) * (f y) = 2 * f (x + y*(f x)))\n  -> forall x, f x = 2\n:=\n  sorry", "meta": {"author": "ahayat16", "repo": "lean_exos", "sha": "682f2552d5b04a8c8eb9e4ab15f875a91b03845c", "save_path": "github-repos/lean/ahayat16-lean_exos", "path": "github-repos/lean/ahayat16-lean_exos/lean_exos-682f2552d5b04a8c8eb9e4ab15f875a91b03845c/src_icannos_totilas/aops/2005-IMO_Shortlist-A2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.863391624034103, "lm_q2_score": 0.5350984286266116, "lm_q1q2_score": 0.4619995013100267}}
{"text": "import adjoin\nimport subfield_stuff\nimport linear_algebra.finite_dimensional\nimport linear_algebra.basic\nimport data.set.finite\nimport field_theory.tower\nimport algebra.gcd_monoid\nimport field_theory.splitting_field\nimport field_theory.separable\n\nnoncomputable theory\nlocal attribute [instance, priority 100] classical.prop_decidable\n\n/- Some stupid lemmas used below. Maybe some of them are already in mathlib? -/\n\n-- This should go into field_theory/subfield eventually probably\nlemma is_subfield.pow_mem {K : Type*} [field K] {a : K} {n : ℤ} {s : set K} [is_subfield s] (h : a ∈ s) : a ^ n ∈ s :=\nbegin\n    by_cases hn : n ≥ 0,\n    {   lift n to ℕ using hn,\n        exact is_submonoid.pow_mem h, },\n    {   rw [(show n = (-1)*(-n), by ring), fpow_mul, fpow_neg a, fpow_one],\n        lift -n to ℕ using (show -n ≥ 0, by linarith),\n        exact is_submonoid.pow_mem (is_subfield.inv_mem h), },\nend\n\n-- Is this really not in mathlib?\n/-- If M is an algebra over a field F and x is a nonzero element of F then x as an element of M is also nonzero. -/\nlemma ne_zero_of_ne_zero (F M : Type*) [field F] [comm_semiring M] [nontrivial M] [algebra F M]\n    {x : F} (hx : x ≠ 0) : algebra_map F M x ≠ 0 :=\nbegin\n    revert hx,\n    contrapose!,\n    intro h,\n    rw ← (algebra_map F M).map_zero at h,\n    exact (algebra_map F M).injective h,\nend\n\nnamespace polynomial\n\nvariables (F : Type*) [field F]\n\nlemma gcd_eval_zero (f g : polynomial F) (α : F) (hf : f.eval α = 0) (hg : g.eval α = 0) : (euclidean_domain.gcd f g).eval α = 0 :=\nbegin\n    rw euclidean_domain.gcd_eq_gcd_ab f g,\n    rw [polynomial.eval_add,polynomial.eval_mul,polynomial.eval_mul,hf,hg,zero_mul,zero_mul,zero_add],\nend\n\nvariables {E : Type*} [field E] [algebra F E]\n\nlemma gcd_root_left (f g : polynomial F) (α : E) (hα : (euclidean_domain.gcd f g).eval₂ (algebra_map F E) α = 0) :\nf.eval₂ (algebra_map F E) α = 0 :=\nbegin\n    cases euclidean_domain.gcd_dvd_left f g with p hp,\n    rw [hp,polynomial.eval₂_mul,hα,zero_mul],\nend\n\nlemma gcd_root_right (f g : polynomial F) (α : E) (hα : (euclidean_domain.gcd f g).eval₂ (algebra_map F E) α = 0) :\ng.eval₂ (algebra_map F E) α = 0 :=\nbegin\n    cases euclidean_domain.gcd_dvd_right f g with p hp,\n    rw [hp,polynomial.eval₂_mul,hα,zero_mul],\nend\n\nend polynomial\n\n\n/- Proof of the primitive element theorem. -/\n\nopen finite_dimensional\n\nsection\nvariables (F : Type*) [field F] {E : Type*} [field E] [algebra F E]\n\n/-- Trivial case of the primitive element theorem. -/\nlemma primitive_element_trivial (F_eq_E : set.range (algebra_map F E) = (⊤ : set E)) :\n    ∃ α : E, F[α] = (⊤ : set E) :=\nbegin\n    use 0,\n    ext,\n    split,\n    exact λ _, trivial,\n    rw ← F_eq_E,\n    rintros ⟨x, rfl⟩,\n    apply adjoin.field_mem,\nend\n\n/- Primitive element theorem for finite fields. -/\n\n-- Replaces earlier messy proof, courtesy of Aaron Anderson & Markus Himmel on zulip\n/-- A finite dimensional vector space over a finite field is finite. -/\ndef finite_of_findim_over_finite [fintype F] [hE : finite_dimensional F E] : fintype E :=\n    module.fintype_of_fintype (classical.some_spec (finite_dimensional.exists_is_basis_finset F E) : _)\n\n/-- Primitive element theorem assuming E is finite. -/\nlemma primitive_element_fin_aux [fintype E] : ∃ α : E, F[α] = (⊤ : set E) :=\nbegin\n    obtain ⟨α, hα⟩ := is_cyclic.exists_generator (units E),\n    use α,\n    ext,\n    refine ⟨λ _, dec_trivial, λ _, _⟩,\n    by_cases hx : x = 0,\n    {   rw hx,\n        exact is_add_submonoid.zero_mem, },\n    {   obtain ⟨n, hn⟩ := set.mem_range.mp (hα (units.mk0 x hx)),\n        rw (show x = (α : E)^n, by norm_cast at *; simp *),\n        exact is_subfield.pow_mem (adjoin_simple_contains_element F ↑α),\n    },\nend\n\n/-- Primitive element theorem for finite dimensional extension of a finite field. -/\ntheorem primitive_element_fin [fintype F] [hfd : finite_dimensional F E] :\n    ∃ α : E, F[α] = (⊤ : set E) := \nbegin\n    haveI : fintype E := finite_of_findim_over_finite F,\n    exact primitive_element_fin_aux F,\nend \n\nend\n\n/- Primitive element theorem for infinite fields. -/\n\nsection\nvariables {F : Type*} [field F] {E : Type*} [field E] (ϕ : F →+* E)\n\nlemma primitive_element_two_aux (α β : E) {f g : polynomial F} [F_inf : infinite F] (hf : f ≠ 0) (hg : g ≠ 0) (f_monic : polynomial.monic f) (g_monic : polynomial.monic g) :\n    ∃ c : F, ∀ (α' ∈ (f.map ϕ).roots) (β' ∈ (g.map ϕ).roots), β' ≠ β → ϕ c ≠ -(α' - α)/(β' - β) :=\nbegin\n    let sf := (f.map ϕ).roots,\n    let sg := (g.map ϕ).roots,\n    let s := {c : E | ∃ (α' ∈ sf) (β' ∈ sg), β' ≠ β ∧ c = -(α' - α)/(β' - β)},\n    let s' := ϕ⁻¹' s,\n    let r : E → E → E := λ α' β', -(α' - α)/(β' - β),\n    have hr : ∀ c ∈ s, ∃ α' β', ((α' ∈ sf) ∧ (β' ∈ sg)) ∧ r α' β' = c :=\n    begin\n        intros c hc,\n        rw set.mem_set_of_eq at hc,\n        tauto,\n    end,\n    have s_fin : s.finite :=\n    begin\n        refine (set.finite.image (λ z : E × E, r z.1 z.2) (set.finite_mem_finset (sf.product sg))).subset _,\n        simpa only [set.subset_def, set.mem_image, prod.exists, finset.mem_product] using hr,\n    end,\n    have s'_fin : s'.finite := s_fin.preimage ((ring_hom.injective ϕ).inj_on (⇑ϕ ⁻¹' s)),\n    obtain ⟨c, hc⟩ := infinite.exists_not_mem_finset s'_fin.to_finset,\n    rw [set.finite.mem_to_finset, set.mem_preimage, set.mem_set_of_eq] at hc,\n    push_neg at hc,\n    exact ⟨c, hc⟩,\nend\n\nlemma primitive_element_two_inf_key_aux {β : F} {h : polynomial F} (h_ne_zero : h ≠ 0) (h_sep : h.separable)\n(h_root : h.eval β = 0) (h_splits : polynomial.splits ϕ h) (h_roots : ∀ x ∈ (h.map ϕ).roots, x = ϕ β) :\nh = (polynomial.C (polynomial.leading_coeff h)) * (polynomial.X - polynomial.C β) :=\nbegin\n    have h_map_separable : (h.map ϕ).separable :=\n    begin\n        apply polynomial.separable.map,\n        exact h_sep,\n    end,\n    rw polynomial.splits_iff_exists_multiset at h_splits,\n    cases h_splits with s hs,\n    have s_elements : ∀ x ∈ s, x = ϕ β :=\n    begin\n        intros x hx,\n        have is_root : x ∈ (h.map ϕ).roots,\n        rw polynomial.mem_roots,\n        dsimp[polynomial.is_root],\n        rw polynomial.eval_map,\n        rw polynomial.eval₂_eq_eval_map,\n        rw hs,\n        rw polynomial.eval_mul,\n        cases multiset.exists_cons_of_mem hx with y hy,\n        rw hy,\n        rw multiset.map_cons,\n        simp only [polynomial.eval_X, multiset.prod_cons, polynomial.eval_C, zero_mul, polynomial.eval_mul, polynomial.eval_sub, mul_zero, sub_self],\n        exact polynomial.map_ne_zero h_ne_zero,\n        exact h_roots x is_root,\n    end,\n    replace s_elements : ∀ x ∈ multiset.map (λ (a : E), polynomial.X - polynomial.C a) s, x = polynomial.X - polynomial.C (ϕ β) :=\n    begin\n        intros x hx,\n        rw multiset.mem_map at hx,\n        cases hx with a ha,\n        specialize s_elements a ha.1,\n        rw s_elements at ha,\n        exact ha.2.symm,\n    end,\n    replace s_elements := multiset.eq_repeat_of_mem s_elements,\n    rw s_elements at hs,\n    rw multiset.prod_repeat at hs,\n    rw multiset.card_map at hs,\n    rw hs at h_map_separable,\n    have hf : ¬is_unit (polynomial.X - polynomial.C (ϕ β)) :=\n    begin\n        rw polynomial.is_unit_iff_degree_eq_zero,\n        rw polynomial.degree_X_sub_C,\n        exact dec_trivial,\n    end,\n    have map_injective := polynomial.map_injective ϕ ϕ.injective,\n    have hn : s.card ≠ 0 :=\n    begin\n        intro hs_card,\n        rw hs_card at hs,\n        rw pow_zero at hs,\n        rw mul_one at hs,\n        rw ←polynomial.map_C at hs,\n        replace hs := map_injective hs,\n        rw hs at h_root,\n        rw polynomial.eval_C at h_root,\n        rw polynomial.leading_coeff_eq_zero at h_root,\n        exact h_ne_zero h_root,\n    end,\n    rw (polynomial.separable.of_pow hf hn (polynomial.separable.of_mul_right h_map_separable)).2 at hs,\n    rw pow_one at hs,\n    apply map_injective,\n    rw hs,\n    rw polynomial.map_mul,\n    rw polynomial.map_C,\n    rw polynomial.map_sub,\n    rw polynomial.map_X,\n    rw polynomial.map_C,\nend\n\nend\n\nvariables {F : Type*} [field F] {E : Type*} [field E] [algebra F E]\n\nlemma primitive_element_two_inf_key (α β : E) [F_sep : is_separable F E]\n    (F_inf : infinite F) : ∃ c : F, β ∈ F[α + (algebra_map F E) c * β] :=\nbegin\n    rcases F_sep α with ⟨hα, hf⟩,\n    rcases F_sep β with ⟨hβ, hg⟩,\n    let f := minimal_polynomial hα,\n    let g := minimal_polynomial hβ,\n    let f_E := f.map (algebra_map F E),\n    let g_E := g.map (algebra_map F E),\n    let E' := polynomial.splitting_field g_E,\n    let ιFE := algebra_map F E,\n    let ιEE' := algebra_map E E',\n    let ιFE' := ιEE'.comp(ιFE),\n    have key := primitive_element_two_aux ιFE' (ιEE' α) (ιEE' β) (minimal_polynomial.ne_zero hα) (minimal_polynomial.ne_zero hβ) (minimal_polynomial.monic hα) (minimal_polynomial.monic hβ),\n    cases key with c hc,\n    use c,\n    let γ := α+(ιFE c)*β,\n    let f' := f_E.comp(polynomial.C γ-(polynomial.C (ιFE c)) * (polynomial.X)),\n    let h := euclidean_domain.gcd f' g_E,\n    have h_sep : h.separable :=\n    begin\n        have div := euclidean_domain.gcd_dvd_right f' g_E,\n        cases div with p mul,\n        dsimp[←h] at mul,\n        apply polynomial.separable.of_mul_left,\n        rw ←mul,\n        exact polynomial.separable.map hg,\n    end,\n    have h_ne_zero : h ≠ 0 :=\n    begin\n        intro h_eq_zero,\n        rw euclidean_domain.gcd_eq_zero_iff at h_eq_zero,\n        apply polynomial.map_monic_ne_zero (minimal_polynomial.monic hβ) h_eq_zero.2,\n    end,\n    have h_map_separable : (h.map ιEE').separable :=\n    begin\n        apply polynomial.separable.map,\n        exact h_sep,\n    end,\n    have h_root : h.eval β = 0 :=\n    begin\n        apply polynomial.gcd_eval_zero,\n        rw [polynomial.eval_comp,polynomial.eval_sub,polynomial.eval_mul,polynomial.eval_C,polynomial.eval_C,polynomial.eval_X,add_sub_cancel],\n        rw [polynomial.eval_map,←polynomial.aeval_def,minimal_polynomial.aeval],\n        rw [polynomial.eval_map,←polynomial.aeval_def,minimal_polynomial.aeval],\n    end,\n    have h_splits : polynomial.splits (algebra_map E E') h :=\n        polynomial.splits_of_splits_of_dvd (algebra_map E E') (polynomial.map_ne_zero (minimal_polynomial.ne_zero hβ)) (polynomial.splitting_field.splits g_E) (euclidean_domain.gcd_dvd_right f' g_E),\n    have h_roots : ∀ x ∈ (h.map ιEE').roots, x = algebra_map E E' β :=\n    begin\n        intros x hx,\n        rw polynomial.mem_roots at hx,\n        dsimp[polynomial.is_root] at hx,\n        rw polynomial.eval_map at hx,\n        have f_root : f'.eval₂ (algebra_map E E') x = 0 := polynomial.gcd_root_left E f' g_E x hx,\n        simp only [polynomial.eval₂_comp,polynomial.eval₂_map,polynomial.eval₂_sub,polynomial.eval₂_mul,polynomial.eval₂_C,polynomial.eval₂_X] at f_root,\n        replace f_root : _ ∈ (f.map ιFE').roots,\n        rw polynomial.mem_roots,\n        dsimp[polynomial.is_root],\n        rw polynomial.eval_map,\n        exact f_root,\n        exact polynomial.map_ne_zero (minimal_polynomial.ne_zero hα),\n        specialize hc _ f_root,\n        have g_root : g_E.eval₂ (algebra_map E E') x = 0 := polynomial.gcd_root_right E f' g_E x hx,\n        simp only [polynomial.eval₂_map] at g_root,\n        replace g_root : _ ∈ (g.map ιFE').roots,\n        rw polynomial.mem_roots,\n        dsimp[polynomial.is_root],\n        rw polynomial.eval_map,\n        exact g_root,\n        exact polynomial.map_ne_zero (minimal_polynomial.ne_zero hβ),\n        specialize hc _ g_root,\n        by_contradiction,\n        specialize hc a,\n        apply hc,\n        dsimp[ιEE'],\n        rw[neg_sub,ring_hom.map_add,←sub_add,←sub_sub,sub_self,zero_sub,neg_add_eq_sub,ring_hom.map_mul,←mul_sub],\n        symmetry,\n        apply mul_div_cancel,\n        rw sub_ne_zero,\n        exact a,\n        exact polynomial.map_ne_zero h_ne_zero,\n    end,\n    replace key := primitive_element_two_inf_key_aux ιEE' h_ne_zero h_sep h_root h_splits h_roots,\n    let f_Fγ := (f.map(algebra_map F F[γ])).comp(polynomial.C (adjoin_simple.gen F γ)-(polynomial.C ↑c) * (polynomial.X)),\n    let g_Fγ := g.map(algebra_map F F[γ]),\n    have composition2 : (algebra_map F[γ] E).comp(algebra_map F F[γ]) = algebra_map F E := by ext;refl,\n    have f_map : f_Fγ.map(algebra_map F[γ] E) = f' :=\n    begin\n        dsimp[f_Fγ,f',f_E],\n        rw ←composition2,\n        rw ←polynomial.map_map,\n        set p := f.map(algebra_map F F[γ]),\n        dsimp[←p],\n        rw polynomial.map_comp (algebra_map F[γ] E) p (polynomial.C (adjoin_simple.gen F γ)-(polynomial.C ↑c) * (polynomial.X)),\n        rw [polynomial.map_sub,polynomial.map_C,adjoin_simple.gen_eq_alpha,polynomial.map_mul,polynomial.map_C,polynomial.map_X],\n        refl,\n    end,\n    have g_map : g_Fγ.map(algebra_map F[γ] E) = g_E :=\n    begin\n        rw polynomial.map_map,\n        rw composition2,\n    end,\n    dsimp[h] at key,\n    rw [←f_map,←g_map] at key,\n    have swap : euclidean_domain.gcd (f_Fγ.map(algebra_map F[γ] E)) (g_Fγ.map(algebra_map F[γ] E)) = (euclidean_domain.gcd f_Fγ g_Fγ).map(algebra_map F[γ] E),\n    convert polynomial.gcd_map (algebra_map F[γ] E),\n    rw swap at key,\n    set p := euclidean_domain.gcd f_Fγ g_Fγ,\n    set k := (p.map(algebra_map F[γ] E)).leading_coeff,\n    dsimp[←k] at key,\n    rw mul_sub at key,\n    rw ←polynomial.C_mul at key,\n    have coeff0 : algebra_map F[γ] E (p.coeff 0) = -(k*β) :=\n        by rw [←polynomial.coeff_map,key, polynomial.coeff_sub, polynomial.coeff_C_mul, polynomial.coeff_C_zero, polynomial.coeff_X_zero, mul_zero, zero_sub],\n    have coeff1 : algebra_map F[γ] E (p.coeff 1) = k :=\n    begin\n        rw [←polynomial.coeff_map,key,polynomial.coeff_sub,polynomial.coeff_mul_X,polynomial.coeff_C_zero,polynomial.coeff_C],\n        change k - 0 = k,\n        rw sub_zero,\n    end,\n    have k_ne_zero : k≠0 :=\n    begin\n        intro k_eq_zero,\n        rw [polynomial.leading_coeff_eq_zero,←polynomial.map_zero (algebra_map F[γ] E)] at k_eq_zero,\n        replace k_eq_zero := polynomial.map_injective (algebra_map F[γ] E) (algebra_map F[γ] E).injective k_eq_zero,\n        rw euclidean_domain.gcd_eq_zero_iff at k_eq_zero,\n        apply polynomial.map_monic_ne_zero (minimal_polynomial.monic hβ) k_eq_zero.2,\n    end,\n    have last_step : β = algebra_map F[γ] E (-p.coeff 0 / p.coeff 1) :=\n        by rw [division_def,ring_hom.map_mul,ring_hom.map_neg,ring_hom.map_inv,coeff0,coeff1,neg_neg,mul_comm,←mul_assoc,inv_mul_cancel k_ne_zero,one_mul],\n    change β = ↑(-p.coeff 0 / p.coeff 1) at last_step,\n    have h := subtype.mem (-p.coeff 0 / p.coeff 1),\n    rw ←last_step at h,\n    exact h,\nend\n\n/-- Primitive element theorem for adjoining two elements to an infinite field. -/\nlemma primitive_element_two_inf (α β : E) (F_sep : is_separable F E)\n    (F_inf : infinite F) :  ∃ γ : E, F[α, β] = F[γ] :=\nbegin\n    obtain ⟨c, β_in_Fγ⟩ := primitive_element_two_inf_key α β F_inf,\n    let c' := algebra_map F E c,\n    let γ := α + c'*β,\n    have γ_in_Fγ : γ ∈ F[γ] := adjoin_simple_contains_element F γ,\n    have c_in_Fγ : c' ∈ F[γ] := adjoin.field_mem F {γ} c,\n    have cβ_in_Fγ : c'*β ∈ F[γ] := is_submonoid.mul_mem c_in_Fγ β_in_Fγ,\n    have α_in_Fγ : α ∈ F[γ] := by rw (show α = γ - c'*β, by simp *);\n        exact is_add_subgroup.sub_mem F[γ] γ (c'*β) γ_in_Fγ cβ_in_Fγ,\n    have αβ_in_Fγ : {α, β} ⊆ F[γ] := λ x hx, by cases hx; cases hx; assumption,\n    have Fαβ_sub_Fγ : F[α, β] ⊆ F[γ] := adjoin_subset' F {α, β} αβ_in_Fγ,\n    have α_in_Fαβ : α ∈ F[α, β] := adjoin.set_mem F {α, β} ⟨α, set.mem_insert α {β}⟩,\n    have β_in_Fαβ : β ∈ F[α, β] := adjoin.set_mem F {α, β} ⟨β, set.mem_insert_of_mem α rfl⟩,\n    have c_in_Fαβ : c' ∈ (F[α, β] : set E) := adjoin.field_mem F {α, β} c,\n    have cβ_in_Fαβ : c'*β ∈ F[α, β] := is_submonoid.mul_mem c_in_Fαβ β_in_Fαβ,\n    have γ_in_Fαβ : γ ∈ F[α, β] := is_add_submonoid.add_mem α_in_Fαβ cβ_in_Fαβ,\n    have Fγ_sub_Fαβ : F[γ] ⊆ F[α, β] := adjoin_simple_subset' F γ γ_in_Fαβ,\n    exact ⟨γ, set.subset.antisymm Fαβ_sub_Fγ Fγ_sub_Fαβ⟩,\nend\n\nuniverse u\n\n/-- Primitive element theorem for infinite fields. -/\ntheorem primitive_element_inf (F E : Type u) [field F] [field E] [algebra F E] (F_sep : is_separable F E) (F_findim: finite_dimensional F E) \n    (F_inf : infinite F) (n : ℕ) (hn : findim F E = n) : (∃ α : E, F[α] = (⊤ : set E)) :=\nbegin\n    tactic.unfreeze_local_instances,\n    revert F,\n    apply n.strong_induction_on,\n    clear n,\n    intros n ih F hF hFE F_sep F_findim F_inf hn,\n    by_cases F_neq_E : set.range (algebra_map F E) = (⊤ : set E),\n    {   exact primitive_element_trivial F F_neq_E, },\n    {   have : ∃ α : E, α ∉ set.range (algebra_map F E) :=\n        begin\n            revert F_neq_E,\n            contrapose!,\n            exact λ h, set.ext (λ x, ⟨λ _, dec_trivial, λ _, h x⟩),\n        end,\n        rcases this with ⟨α, hα⟩,\n        by_cases h : F[α] = (⊤ : set E),\n        {   exact ⟨α, h⟩,   },\n        {   have Fα_findim : finite_dimensional F[α] E := adjoin_findim_of_findim F α,\n            have Fα_le_n : findim F[α] E < n := by rw ← hn; exact adjoin_dim_lt F hα,\n            have Fα_inf : infinite F[α] := adjoin_inf_of_inf F {α} F_inf,\n            have Fα_sep : is_separable F[α] E := adjoin_separable F {α},\n            obtain ⟨β, hβ⟩ := ih (findim F[α] E) Fα_le_n F[α]\n                Fα_sep Fα_findim Fα_inf rfl,\n            obtain ⟨γ, hγ⟩ := primitive_element_two_inf α β F_sep F_inf,\n            rw [adjoin_simple_twice, hγ] at hβ,\n            exact ⟨γ, hβ⟩,\n        },\n    },\nend\n\n/- Actual primitive element theorem. -/\n\n/-- Primitive element theorem in same universe. -/\ntheorem primitive_element_aux (F E : Type u) [field F] [field E] [algebra F E]\n(F_sep : is_separable F E)  (F_findim : finite_dimensional F E) :\n    (∃ α : E, F[α] = (⊤ : set E)) :=\nbegin\n    by_cases F_finite : nonempty (fintype F),\n    exact nonempty.elim F_finite (λ h : fintype F, @primitive_element_fin F _ E _ _ h F_findim),\n    exact primitive_element_inf F E F_sep F_findim (not_nonempty_fintype.mp F_finite) (findim F E) rfl,\nend\n\n/-- Primitive element theorem in different universes. -/\ntheorem primitive_element (F_sep : is_separable F E)  (F_findim : finite_dimensional F E) :\n    (∃ α : E, F[α] = (⊤ : set E)) :=\nbegin\n    set F' := set.range (algebra_map F E) with hF',\n    have F'_sep : is_separable F' E := inclusion.separable F_sep,\n    have F'_findim : finite_dimensional F' E := inclusion.finite_dimensional F_findim,\n    obtain ⟨α, hα⟩ := primitive_element_aux F' E F'_sep F'_findim,\n    exact ⟨α, by simp only [*, adjoin_equals_adjoin_range]⟩,\nend", "meta": {"author": "pglutz", "repo": "galois_theory", "sha": "4561c2c97d4c49377356e1d7a2051dedc87d30ba", "save_path": "github-repos/lean/pglutz-galois_theory", "path": "github-repos/lean/pglutz-galois_theory/galois_theory-4561c2c97d4c49377356e1d7a2051dedc87d30ba/src/primitive_element.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.46198720486178635}}
{"text": "import Mathlib\n\nnamespace Option \n\nprotected def elim : Option α → β → (α → β) → β\n  | (some x), y, f => f x\n  | none,     y, f => y\n\ninstance : Bind (Option) := ⟨Option.bind⟩\n\ninstance : Mem α (Option α) := ⟨λ a b => b = some a⟩\n\n@[simp] theorem mem_def {a : α} {b : Option α} : a ∈ b ↔ b = some a := sorry\n\nlemma ne_none_iff_exists {o : Option α} : \n  o ≠ none ↔ ∃ (x : α), some x = o := \n  sorry\n\nlemma bind_eq_bind {f : α → Option β} {x : Option α} :\n  x >>= f = x.bind f := \n  rfl\n\n@[simp] theorem bind_eq_some {x : Option α} {f : α → Option β} {b : β} :\n  x >>= f = some b ↔ ∃ a, x = some a ∧ f a = some b := \n  sorry\n\n@[simp] theorem bind_eq_none {o : Option α} {f : α → Option β} :\n  o >>= f = none ↔ (∀ b a, a ∈ o → b ∉ f a) := \n  sorry\n\n@[simp] theorem some_orelse (a : α) (x : Option α) : (some a <|> x) = some a := sorry\n\n@[simp] theorem orelse_none (x : Option α) : (x <|> none) = x := sorry\n\n@[simp] theorem none_bind {α β} (f : α → Option β) : none >>= f = none := sorry\n\nend Option", "meta": {"author": "marcusrossel", "repo": "model-checking", "sha": "ed9b6f557769b7146ce1db749f0b258603d25235", "save_path": "github-repos/lean/marcusrossel-model-checking", "path": "github-repos/lean/marcusrossel-model-checking/model-checking-ed9b6f557769b7146ce1db749f0b258603d25235/ModelChecking/Mathlib/Option.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577158, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4619871986545828}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport topology.opens\nimport ring_theory.ideal.prod\nimport linear_algebra.finsupp\nimport algebra.punit_instances\n\n/-!\n# Prime spectrum of a commutative ring\n\nThe prime spectrum of a commutative ring is the type of all prime ideals.\nIt is naturally endowed with a topology: the Zariski topology.\n\n(It is also naturally endowed with a sheaf of rings,\nwhich is constructed in `algebraic_geometry.structure_sheaf`.)\n\n## Main definitions\n\n* `prime_spectrum R`: The prime spectrum of a commutative ring `R`,\n  i.e., the set of all prime ideals of `R`.\n* `zero_locus s`: The zero locus of a subset `s` of `R`\n  is the subset of `prime_spectrum R` consisting of all prime ideals that contain `s`.\n* `vanishing_ideal t`: The vanishing ideal of a subset `t` of `prime_spectrum R`\n  is the intersection of points in `t` (viewed as prime ideals).\n\n## Conventions\n\nWe denote subsets of rings with `s`, `s'`, etc...\nwhereas we denote subsets of prime spectra with `t`, `t'`, etc...\n\n## Inspiration/contributors\n\nThe contents of this file draw inspiration from\n<https://github.com/ramonfmir/lean-scheme>\nwhich has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,\nand Chris Hughes (on an earlier repository).\n\n-/\n\nnoncomputable theory\nopen_locale classical\n\nuniverse variables u v\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The prime spectrum of a commutative ring `R`\nis the type of all prime ideals of `R`.\n\nIt is naturally endowed with a topology (the Zariski topology),\nand a sheaf of commutative rings (see `algebraic_geometry.structure_sheaf`).\nIt is a fundamental building block in algebraic geometry. -/\n@[nolint has_inhabited_instance]\ndef prime_spectrum := {I : ideal R // I.is_prime}\n\nvariable {R}\n\nnamespace prime_spectrum\n\n/-- A method to view a point in the prime spectrum of a commutative ring\nas an ideal of that ring. -/\nabbreviation as_ideal (x : prime_spectrum R) : ideal R := x.val\n\ninstance is_prime (x : prime_spectrum R) :\n  x.as_ideal.is_prime := x.2\n\n/--\nThe prime spectrum of the zero ring is empty.\n-/\nlemma punit (x : prime_spectrum punit) : false :=\nx.1.ne_top_iff_one.1 x.2.1 $ subsingleton.elim (0 : punit) 1 ▸ x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of\n    `R` and the prime spectrum of `S`. -/\nnoncomputable def prime_spectrum_prod :\n  prime_spectrum (R × S) ≃ prime_spectrum R ⊕ prime_spectrum S :=\nideal.prime_ideals_equiv R S\n\nvariables {R S}\n\n@[simp] lemma prime_spectrum_prod_symm_inl_as_ideal (x : prime_spectrum R) :\n  ((prime_spectrum_prod R S).symm (sum.inl x)).as_ideal = ideal.prod x.as_ideal ⊤ :=\nby { cases x, refl }\n@[simp] lemma prime_spectrum_prod_symm_inr_as_ideal (x : prime_spectrum S) :\n  ((prime_spectrum_prod R S).symm (sum.inr x)).as_ideal = ideal.prod ⊤ x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y ↔ x.as_ideal = y.as_ideal :=\nsubtype.ext_iff_val\n\n/-- The zero locus of a set `s` of elements of a commutative ring `R`\nis the set of all prime ideals of the ring that contain the set `s`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `zero_locus s` is exactly the subset of `prime_spectrum R`\nwhere all \"functions\" in `s` vanish simultaneously.\n-/\ndef zero_locus (s : set R) : set (prime_spectrum R) :=\n{x | s ⊆ x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x ∈ zero_locus s ↔ s ⊆ x.as_ideal := iff.rfl\n\n@[simp] lemma zero_locus_span (s : set R) :\n  zero_locus (ideal.span s : set R) = zero_locus s :=\nby { ext x, exact (submodule.gi R R).gc s x.as_ideal }\n\n/-- The vanishing ideal of a set `t` of points\nof the prime spectrum of a commutative ring `R`\nis the intersection of all the prime ideals in the set `t`.\n\nAn element `f` of `R` can be thought of as a dependent function\non the prime spectrum of `R`.\nAt a point `x` (a prime ideal)\nthe function (i.e., element) `f` takes values in the quotient ring `R` modulo the prime ideal `x`.\nIn this manner, `vanishing_ideal t` is exactly the ideal of `R`\nconsisting of all \"functions\" that vanish on all of `t`.\n-/\ndef vanishing_ideal (t : set (prime_spectrum R)) : ideal R :=\n⨅ (x : prime_spectrum R) (h : x ∈ t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal} :=\nbegin\n  ext f,\n  rw [vanishing_ideal, set_like.mem_coe, submodule.mem_infi],\n  apply forall_congr, intro x,\n  rw [submodule.mem_infi],\nend\n\nlemma mem_vanishing_ideal (t : set (prime_spectrum R)) (f : R) :\n  f ∈ vanishing_ideal t ↔ ∀ x : prime_spectrum R, x ∈ t → f ∈ x.as_ideal :=\nby rw [← set_like.mem_coe, coe_vanishing_ideal, set.mem_set_of_eq]\n\n@[simp] lemma vanishing_ideal_singleton (x : prime_spectrum R) :\n  vanishing_ideal ({x} : set (prime_spectrum R)) = x.as_ideal :=\nby simp [vanishing_ideal]\n\nlemma subset_zero_locus_iff_le_vanishing_ideal (t : set (prime_spectrum R)) (I : ideal R) :\n  t ⊆ zero_locus I ↔ I ≤ vanishing_ideal t :=\n⟨λ h f k, (mem_vanishing_ideal _ _).mpr (λ x j, (mem_zero_locus _ _).mpr (h j) k), λ h,\n  λ x j, (mem_zero_locus _ _).mpr (le_trans h (λ f h, ((mem_vanishing_ideal _ _).mp h) x j))⟩\n\nsection gc\nvariable (R)\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc : @galois_connection\n  (ideal R) (order_dual (set (prime_spectrum R))) _ _\n  (λ I, zero_locus I) (λ t, vanishing_ideal t) :=\nλ I t, subset_zero_locus_iff_le_vanishing_ideal t I\n\n/-- `zero_locus` and `vanishing_ideal` form a galois connection. -/\nlemma gc_set : @galois_connection\n  (set R) (order_dual (set (prime_spectrum R))) _ _\n  (λ s, zero_locus s) (λ t, vanishing_ideal t) :=\nhave ideal_gc : galois_connection (ideal.span) coe := (submodule.gi R R).gc,\nby simpa [zero_locus_span, function.comp] using galois_connection.compose _ _ _ _ ideal_gc (gc R)\n\nlemma subset_zero_locus_iff_subset_vanishing_ideal (t : set (prime_spectrum R)) (s : set R) :\n  t ⊆ zero_locus s ↔ s ⊆ vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s ⊆ vanishing_ideal (zero_locus s) :=\n(gc_set R).le_u_l s\n\nlemma le_vanishing_ideal_zero_locus (I : ideal R) :\n  I ≤ vanishing_ideal (zero_locus I) :=\n(gc R).le_u_l I\n\n@[simp] lemma vanishing_ideal_zero_locus_eq_radical (I : ideal R) :\n  vanishing_ideal (zero_locus (I : set R)) = I.radical := ideal.ext $ λ f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact ⟨(λ h x hx, h ⟨x, hx.2⟩ hx.1), (λ h x hx, h x.1 ⟨hx, x.2⟩)⟩\nend\n\n@[simp] lemma zero_locus_radical (I : ideal R) : zero_locus (I.radical : set R) = zero_locus I :=\nvanishing_ideal_zero_locus_eq_radical I ▸ congr_fun (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t ⊆ zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s ⊆ t) : zero_locus t ⊆ zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s ≤ t) :\n  zero_locus (t : set R) ⊆ zero_locus (s : set R) :=\n(gc R).monotone_l h\n\nlemma vanishing_ideal_anti_mono {s t : set (prime_spectrum R)} (h : s ⊆ t) :\n  vanishing_ideal t ≤ vanishing_ideal s :=\n(gc R).monotone_u h\n\nlemma zero_locus_subset_zero_locus_iff (I J : ideal R) :\n  zero_locus (I : set R) ⊆ zero_locus (J : set R) ↔ J ≤ I.radical :=\n⟨λ h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I ▸\n  vanishing_ideal_zero_locus_eq_radical J ▸ vanishing_ideal_anti_mono h),\nλ h, zero_locus_radical I ▸ zero_locus_anti_mono_ideal h⟩\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) ⊆ zero_locus {g} ↔ g ∈ (ideal.span ({f} : set R)).radical :=\nby rw [← zero_locus_span {f}, ← zero_locus_span {g}, zero_locus_subset_zero_locus_iff,\n    ideal.span_le, set.singleton_subset_iff, set_like.mem_coe]\n\nlemma zero_locus_bot :\n  zero_locus ((⊥ : ideal R) : set R) = set.univ :=\n(gc R).l_bot\n\n@[simp] lemma zero_locus_singleton_zero :\n  zero_locus ({0} : set R) = set.univ :=\nzero_locus_bot\n\n@[simp] lemma zero_locus_empty :\n  zero_locus (∅ : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (∅ : set (prime_spectrum R)) = ⊤ :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) ∈ s) :\n  zero_locus s = ∅ :=\nbegin\n  rw set.eq_empty_iff_forall_not_mem,\n  intros x hx,\n  rw mem_zero_locus at hx,\n  have x_prime : x.as_ideal.is_prime := by apply_instance,\n  have eq_top : x.as_ideal = ⊤, { rw ideal.eq_top_iff_one, exact hx h },\n  apply x_prime.ne_top eq_top,\nend\n\n@[simp] lemma zero_locus_singleton_one :\n  zero_locus ({1} : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_singleton (1 : R))\n\nlemma zero_locus_empty_iff_eq_top {I : ideal R} :\n  zero_locus (I : set R) = ∅ ↔ I = ⊤ :=\nbegin\n  split,\n  { contrapose!,\n    intro h,\n    apply set.ne_empty_iff_nonempty.mpr,\n    rcases ideal.exists_le_maximal I h with ⟨M, hM, hIM⟩,\n    exact ⟨⟨M, hM.is_prime⟩, hIM⟩ },\n  { rintro rfl, apply zero_locus_empty_of_one_mem, trivial }\nend\n\n@[simp] lemma zero_locus_univ :\n  zero_locus (set.univ : set R) = ∅ :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I ⊔ J : ideal R) : set R) = zero_locus I ∩ zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s ∪ s') = zero_locus s ∩ zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t ∪ t') = vanishing_ideal t ⊓ vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {ι : Sort*} (I : ι → ideal R) :\n  zero_locus ((⨆ i, I i : ideal R) : set R) = (⋂ i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {ι : Sort*} (s : ι → set R) :\n  zero_locus (⋃ i, s i) = (⋂ i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (⋃ s' ∈ s, s' : set R) = ⋂ s' ∈ s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {ι : Sort*} (t : ι → set (prime_spectrum R)) :\n  vanishing_ideal (⋃ i, t i) = (⨅ i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I ⊓ J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s ∪ zero_locus s' = zero_locus ((ideal.span s) ⊓ (ideal.span s') : ideal R) :=\nby { rw zero_locus_inf, simp }\n\nlemma zero_locus_mul (I J : ideal R) :\n  zero_locus ((I * J : ideal R) : set R) = zero_locus I ∪ zero_locus J :=\nset.ext $ λ x, by simpa using x.2.mul_le\n\nlemma zero_locus_singleton_mul (f g : R) :\n  zero_locus ({f * g} : set R) = zero_locus {f} ∪ zero_locus {g} :=\nset.ext $ λ x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : ℕ} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) ▸ (I.radical_pow n hn).symm ▸ zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : ℕ) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ λ x, by simpa using x.2.pow_mem_iff_mem n hn\n\nlemma sup_vanishing_ideal_le (t t' : set (prime_spectrum R)) :\n  vanishing_ideal t ⊔ vanishing_ideal t' ≤ vanishing_ideal (t ∩ t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro ⟨f, hf, g, hg, rfl⟩ x ⟨hxt, hxt'⟩,\n  rw mem_vanishing_ideal at hf hg,\n  apply submodule.add_mem; solve_by_elim\nend\n\nlemma mem_compl_zero_locus_iff_not_mem {f : R} {I : prime_spectrum R} :\n  I ∈ (zero_locus {f} : set (prime_spectrum R))ᶜ ↔ f ∉ I.as_ideal :=\nby rw [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]; refl\n\n/-- The Zariski topology on the prime spectrum of a commutative ring\nis defined via the closed sets of the topology:\nthey are exactly those sets that are the zero locus of a subset of the ring. -/\ninstance zariski_topology : topological_space (prime_spectrum R) :=\ntopological_space.of_closed (set.range prime_spectrum.zero_locus)\n  (⟨set.univ, by simp⟩)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs → set R := λ i, classical.some (h i.2),\n    have hf : ∀ i : Zs, ↑i = zero_locus (f i) := λ i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact ⟨_, zero_locus_Union _⟩\n  end\n  (by { rintro _ _ ⟨s, rfl⟩ ⟨t, rfl⟩, exact ⟨_, (union_zero_locus s t).symm⟩ })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U ↔ ∃ s, Uᶜ = zero_locus s :=\nby simp only [@eq_comm _ Uᶜ]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z ↔ ∃ s, Z = zero_locus s :=\nby rw [← is_open_compl_iff, is_open_iff, compl_compl]\n\nlemma is_closed_zero_locus (s : set R) :\n  is_closed (zero_locus s) :=\nby { rw [is_closed_iff_zero_locus], exact ⟨s, rfl⟩ }\n\nlemma zero_locus_vanishing_ideal_eq_closure (t : set (prime_spectrum R)) :\n  zero_locus (vanishing_ideal t : set R) = closure t :=\nbegin\n  apply set.subset.antisymm,\n  { rintro x hx t' ⟨ht', ht⟩,\n    obtain ⟨fs, rfl⟩ : ∃ s, t' = zero_locus s,\n    by rwa [is_closed_iff_zero_locus] at ht',\n    rw [subset_zero_locus_iff_subset_vanishing_ideal] at ht,\n    exact set.subset.trans ht hx },\n  { rw (is_closed_zero_locus _).closure_subset_iff,\n    exact subset_zero_locus_vanishing_ideal t }\nend\n\nlemma vanishing_ideal_closure (t : set (prime_spectrum R)) :\n  vanishing_ideal (closure t) = vanishing_ideal t :=\nzero_locus_vanishing_ideal_eq_closure t ▸ congr_fun (gc R).u_l_u_eq_u t\n\nsection comap\nvariables {S : Type v} [comm_ring S] {S' : Type*} [comm_ring S']\n\n/-- The function between prime spectra of commutative rings induced by a ring homomorphism.\nThis function is continuous. -/\ndef comap (f : R →+* S) : prime_spectrum S → prime_spectrum R :=\nλ y, ⟨ideal.comap f y.as_ideal, by exact ideal.is_prime.comap _⟩\n\nvariables (f : R →+* S)\n\n@[simp] lemma comap_as_ideal (y : prime_spectrum S) :\n  (comap f y).as_ideal = ideal.comap f y.as_ideal :=\nrfl\n\n@[simp] lemma comap_id : comap (ring_hom.id R) = id :=\nfunext $ λ _, subtype.ext $ ideal.ext $ λ _, iff.rfl\n\n@[simp] lemma comap_comp (f : R →+* S) (g : S →+* S') :\n  comap (g.comp f) = comap f ∘ comap g :=\nfunext $ λ _, subtype.ext $ ideal.ext $ λ _, iff.rfl\n\n@[simp] lemma preimage_comap_zero_locus (s : set R) :\n  (comap f) ⁻¹' (zero_locus s) = zero_locus (f '' s) :=\nbegin\n  ext x,\n  simp only [mem_zero_locus, set.mem_preimage, comap_as_ideal, set.image_subset_iff],\n  refl\nend\n\nlemma comap_continuous (f : R →+* S) : continuous (comap f) :=\nbegin\n  rw continuous_iff_is_closed,\n  simp only [is_closed_iff_zero_locus],\n  rintro _ ⟨s, rfl⟩,\n  exact ⟨_, preimage_comap_zero_locus f s⟩\nend\n\nend comap\n\nsection basic_open\n\n/-- `basic_open r` is the open subset containing all prime ideals not containing `r`. -/\ndef basic_open (r : R) : topological_space.opens (prime_spectrum R) :=\n{ val := { x | r ∉ x.as_ideal },\n  property := ⟨{r}, set.ext $ λ x, set.singleton_subset_iff.trans $ not_not.symm⟩ }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x ∈ basic_open f ↔ f ∉ x.as_ideal := iff.rfl\n\nlemma is_open_basic_open {a : R} : is_open ((basic_open a) : set (prime_spectrum R)) :=\n(basic_open a).property\n\n@[simp] lemma basic_open_eq_zero_locus_compl (r : R) :\n  (basic_open r : set (prime_spectrum R)) = (zero_locus {r})ᶜ :=\nset.ext $ λ x, by simpa only [set.mem_compl_eq, mem_zero_locus, set.singleton_subset_iff]\n\n@[simp] lemma basic_open_one : basic_open (1 : R) = ⊤ :=\ntopological_space.opens.ext $ by {simp, refl}\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = ⊥ :=\ntopological_space.opens.ext $ by {simp, refl}\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f ≤ basic_open g ↔ f ∈ (ideal.span ({g} : set R)).radical :=\nby rw [topological_space.opens.le_def, basic_open_eq_zero_locus_compl,\n    basic_open_eq_zero_locus_compl, set.le_eq_subset, set.compl_subset_compl,\n    zero_locus_subset_zero_locus_singleton_iff]\n\nlemma basic_open_mul (f g : R) : basic_open (f * g) = basic_open f ⊓ basic_open g :=\ntopological_space.opens.ext $ by {simp [zero_locus_singleton_mul]}\n\nlemma basic_open_mul_le_left (f g : R) : basic_open (f * g) ≤ basic_open f :=\nby { rw basic_open_mul f g, exact inf_le_left }\n\nlemma basic_open_mul_le_right (f g : R) : basic_open (f * g) ≤ basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : ℕ) (hn : 0 < n) : basic_open (f ^ n) = basic_open f :=\ntopological_space.opens.ext $ by simpa using zero_locus_singleton_pow f n hn\n\nlemma is_topological_basis_basic_opens : topological_space.is_topological_basis\n  (set.range (λ (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ ⟨r, rfl⟩,\n    exact is_open_basic_open },\n  { rintros p U hp ⟨s, hs⟩,\n    rw [← compl_compl U, set.mem_compl_eq, ← hs, mem_zero_locus, set.not_subset] at hp,\n    obtain ⟨f, hfs, hfp⟩ := hp,\n    refine ⟨basic_open f, ⟨f, rfl⟩, hfp, _⟩,\n    rw [← set.compl_subset_compl, ← hs, basic_open_eq_zero_locus_compl, compl_compl],\n    exact zero_locus_anti_mono (set.singleton_subset_iff.mpr hfs) }\nend\n\nlemma is_compact_basic_open (f : R) : is_compact (basic_open f : set (prime_spectrum R)) :=\ncompact_of_finite_subfamily_closed $ λ ι Z hZc hZ,\nbegin\n  let I : ι → ideal R := λ i, vanishing_ideal (Z i),\n  have hI : ∀ i, Z i = zero_locus (I i) := λ i,\n    by simpa only [zero_locus_vanishing_ideal_eq_closure] using (hZc i).closure_eq.symm,\n  rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n      set.diff_eq_empty, funext hI, ← zero_locus_supr] at hZ,\n  obtain ⟨n, hn⟩ : f ∈ (⨆ (i : ι), I i).radical,\n  { rw ← vanishing_ideal_zero_locus_eq_radical,\n    apply vanishing_ideal_anti_mono hZ,\n    exact (subset_vanishing_ideal_zero_locus {f} (set.mem_singleton f)) },\n  rcases submodule.exists_finset_of_mem_supr I hn with ⟨s, hs⟩,\n  use s,\n  -- Using simp_rw here, because `hI` and `zero_locus_supr` need to be applied underneath binders\n  simp_rw [basic_open_eq_zero_locus_compl f, set.inter_comm, ← set.diff_eq,\n           set.diff_eq_empty, hI, ← zero_locus_supr],\n  rw ← zero_locus_radical, -- this one can't be in `simp_rw` because it would loop\n  apply zero_locus_anti_mono,\n  rw set.singleton_subset_iff,\n  exact ⟨n, hs⟩\nend\n\nend basic_open\n\n/-- The prime spectrum of a commutative ring is a compact topological space. -/\ninstance : compact_space (prime_spectrum R) :=\n{ compact_univ := by { convert is_compact_basic_open (1 : R), rw basic_open_one, refl } }\n\nsection order\n\n/-!\n## The specialization order\n\nWe endow `prime_spectrum R` with a partial order,\nwhere `x ≤ y` if and only if `y ∈ closure {x}`.\n\nTODO: maybe define sober topological spaces, and generalise this instance to those\n-/\n\ninstance : partial_order (prime_spectrum R) :=\nsubtype.partial_order _\n\n@[simp] lemma as_ideal_le_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal ≤ y.as_ideal ↔ x ≤ y :=\nsubtype.coe_le_coe\n\n@[simp] lemma as_ideal_lt_as_ideal (x y : prime_spectrum R) :\n  x.as_ideal < y.as_ideal ↔ x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x ≤ y ↔ y ∈ closure ({x} : set (prime_spectrum R)) :=\nby rw [← as_ideal_le_as_ideal, ← zero_locus_vanishing_ideal_eq_closure,\n    mem_zero_locus, vanishing_ideal_singleton, set_like.coe_subset_coe]\n\nend order\n\nend prime_spectrum\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebraic_geometry/prime_spectrum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6513548714339144, "lm_q1q2_score": 0.46182306673077467}}
{"text": "open classical\n\nvariable p : Prop\n\nexample (h : ¬¬p) : p :=\n  by_contradiction\n    (assume h1 : ¬p,\n      show false, from h h1)\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0504.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.4618230539224603}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport logic.relator\n\n/-!\n# Quotient types\n\nThis module extends the core library's treatment of quotient types (`init.data.quot`).\n\n## Tags\n\nquotient\n-/\n\nvariables {α : Sort*} {β : Sort*}\n\nnamespace setoid\n\nlemma ext {α : Sort*} :\n  ∀{s t : setoid α}, (∀a b, @setoid.r α s a b ↔ @setoid.r α t a b) → s = t\n| ⟨r, _⟩ ⟨p, _⟩ eq :=\n  have r = p, from funext $ assume a, funext $ assume b, propext $ eq a b,\n  by subst this\n\nend setoid\n\nnamespace quot\nvariables {ra : α → α → Prop} {rb : β → β → Prop} {φ : quot ra → quot rb → Sort*}\nlocal notation `⟦`:max a `⟧` := quot.mk _ a\n\ninstance [inhabited α] : inhabited (quot ra) := ⟨⟦default _⟧⟩\n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂ (qa : quot ra) (qb : quot rb) (f : Π a b, φ ⟦a⟧ ⟦b⟧)\n  (ca : ∀ {b a₁ a₂}, ra a₁ a₂ → f a₁ b == f a₂ b)\n  (cb : ∀ {a b₁ b₂}, rb b₁ b₂ → f a b₁ == f a b₂) : φ qa qb :=\nquot.hrec_on qa (λ a, quot.hrec_on qb (f a) (λ b₁ b₂ pb, cb pb)) $ λ a₁ a₂ pa,\n  quot.induction_on qb $ λ b,\n    calc @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₁) (@cb _)\n          == f a₁ b                                     : by simp [heq_self_iff_true]\n      ... == f a₂ b                                     : ca pa\n      ... == @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₂) (@cb _) : by simp [heq_self_iff_true]\n\n/-- Map a function `f : α → β` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra → quot rb`. -/\nprotected def map (f : α → β) (h : (ra ⇒ rb) f f) : quot ra → quot rb :=\nquot.lift (λ x, ⟦f x⟧) $ assume x y (h₁ : ra x y), quot.sound $ h h₁\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `quot ra → quot ra'`. -/\nprotected def map_right {ra' : α → α → Prop} (h : ∀a₁ a₂, ra a₁ a₂ → ra' a₁ a₂) :\n  quot ra → quot ra' :=\nquot.map id h\n\n/-- weaken the relation of a quotient -/\ndef factor {α : Type*} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n  quot r → quot s :=\nquot.lift (quot.mk s) (λ x y rxy, quot.sound (h x y rxy))\n\nlemma factor_mk_eq {α : Type*} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n  factor r s h ∘ quot.mk _ = quot.mk _ := rfl\n\nvariables {γ : Sort*} {r : α → α → Prop} {s : β → β → Prop}\n\n/-- **Alias** of `quot.lift_beta`. -/\nlemma lift_mk (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) (a : α) :\n  quot.lift f h (quot.mk r a) = f a := quot.lift_beta f h a\n\n@[simp]\nlemma lift_on_mk (a : α) (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :\n  quot.lift_on (quot.mk r a) f h = f a := rfl\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β`. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift₂\n  (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n  (q₁ : quot r) (q₂ : quot s) : γ :=\nquot.lift (λ a, quot.lift (f a) (hr a))\n(λ a₁ a₂ ha, funext (λ q, quot.induction_on q (λ b, hs a₁ a₂ b ha)))\nq₁ q₂\n\n@[simp]\nlemma lift₂_mk (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) (a : α) (b : β) :\n  quot.lift₂ f hr hs (quot.mk r a) (quot.mk s b) = f a b := rfl\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` and applies it. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift_on₂ (p : quot r) (q : quot s) (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) : γ := quot.lift₂ f hr hs p q\n\n@[simp]\nlemma lift_on₂_mk (a : α) (b : β) (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) :\n  quot.lift_on₂ (quot.mk r a) (quot.mk s b) f hr hs = f a b := rfl\n\nvariables {t : γ → γ → Prop}\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` wih values in a quotient of\n`γ`. -/\nprotected def map₂ (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b))\n  (q₁ : quot r) (q₂ : quot s) : quot t :=\nquot.lift₂ (λ a b, quot.mk t $ f a b) (λ a b₁ b₂ hb, quot.sound (hr a b₁ b₂ hb))\n(λ a₁ a₂ b ha, quot.sound (hs a₁ a₂ b ha)) q₁ q₂\n\n@[simp]\nlemma map₂_mk (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b))\n  (a : α) (b : β) : quot.map₂ f hr hs (quot.mk r a) (quot.mk s b) = quot.mk t (f a b) := rfl\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on₂\n  {δ : quot r → quot s → Prop} (q₁ : quot r) (q₂ : quot s)\n  (h : ∀ a b, δ (quot.mk r a) (quot.mk s b)) : δ q₁ q₂ :=\nquot.ind (λ a₁, quot.ind (λ a₂, h a₁ a₂) q₂) q₁\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on₃\n  {δ : quot r → quot s → quot t → Prop} (q₁ : quot r) (q₂ : quot s) (q₃ : quot t)\n  (h : ∀ a b c, δ (quot.mk r a) (quot.mk s b) (quot.mk t c)) : δ q₁ q₂ q₃ :=\nquot.ind (λ a₁, quot.ind (λ a₂, quot.ind (λ a₃, h a₁ a₂ a₃) q₃) q₂) q₁\n\nend quot\n\nnamespace quotient\nvariables [sa : setoid α] [sb : setoid β]\nvariables {φ : quotient sa → quotient sb → Sort*}\n\ninstance [inhabited α] : inhabited (quotient sa) := ⟨⟦default _⟧⟩\n\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂ (qa : quotient sa) (qb : quotient sb) (f : Π a b, φ ⟦a⟧ ⟦b⟧)\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) : φ qa qb :=\nquot.hrec_on₂ qa qb f\n  (λ _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (λ _ _ _ p, c _ _ _ _ (setoid.refl _) p)\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : α → β) (h : ((≈) ⇒ (≈)) f f) : quotient sa → quotient sb :=\nquot.map f h\n\n@[simp] lemma map_mk (f : α → β) (h : ((≈) ⇒ (≈)) f f) (x : α) :\n  quotient.map f h (⟦x⟧ : quotient sa) = (⟦f x⟧ : quotient sb) :=\nrfl\n\nvariables {γ : Sort*} [sc : setoid γ]\n\n/-- Map a function `f : α → β → γ` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa → quotient sb → quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map₂ (f : α → β → γ) (h : ((≈) ⇒ (≈) ⇒ (≈)) f f) :\n  quotient sa → quotient sb → quotient sc :=\nquotient.lift₂ (λ x y, ⟦f x y⟧) (λ x₁ y₁ x₂ y₂ h₁ h₂, quot.sound $ h h₁ h₂)\n\nend quotient\n\nlemma quot.eq {α : Type*} {r : α → α → Prop} {x y : α} :\n  quot.mk r x = quot.mk r y ↔ eqv_gen r x y :=\n⟨quot.exact r, quot.eqv_gen_sound⟩\n\n@[simp] theorem quotient.eq [r : setoid α] {x y : α} : ⟦x⟧ = ⟦y⟧ ↔ x ≈ y :=\n⟨quotient.exact, quotient.sound⟩\n\ntheorem forall_quotient_iff {α : Type*} [r : setoid α] {p : quotient r → Prop} :\n  (∀a:quotient r, p a) ↔ (∀a:α, p ⟦a⟧) :=\n⟨assume h x, h _, assume h a, a.induction_on h⟩\n\n@[simp] lemma quotient.lift_mk [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b)\n  (x : α) :\n  quotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift_on_mk [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b)\n  (x : α) :\n  quotient.lift_on (quotient.mk x) f h = f x := rfl\n\n@[simp] theorem quotient.lift_on₂_mk {α : Sort*} {β : Sort*} [setoid α] (f : α → α → β)\n  (h : ∀ (a₁ a₂ b₁ b₂ : α), a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂) (x y : α) :\n  quotient.lift_on₂ (quotient.mk x) (quotient.mk y) f h = f x y := rfl\n\n/-- `quot.mk r` is a surjective function. -/\nlemma surjective_quot_mk (r : α → α → Prop) : function.surjective (quot.mk r) :=\nquot.exists_rep\n\n/-- `quotient.mk` is a surjective function. -/\nlemma surjective_quotient_mk (α : Sort*) [s : setoid α] :\n  function.surjective (quotient.mk : α → quotient s) :=\nquot.exists_rep\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quot.out {r : α → α → Prop} (q : quot r) : α :=\nclassical.some (quot.exists_rep q)\n\n/-- Unwrap the VM representation of a quotient to obtain an element of the equivalence class.\n  Computable but unsound. -/\nmeta def quot.unquot {r : α → α → Prop} : quot r → α := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : α → α → Prop} (q : quot r) : quot.mk r q.out = q :=\nclassical.some_spec (quot.exists_rep q)\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quotient.out [s : setoid α] : quotient s → α := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid α] (q : quotient s) : ⟦q.out⟧ = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid α] (a : α) : ⟦a⟧.out ≈ a :=\nquotient.exact (quotient.out_eq _)\n\ninstance pi_setoid {ι : Sort*} {α : ι → Sort*} [∀ i, setoid (α i)] : setoid (Π i, α i) :=\n{ r := λ a b, ∀ i, a i ≈ b i,\n  iseqv := ⟨\n    λ a i, setoid.refl _,\n    λ a b h i, setoid.symm (h _),\n    λ a b c h₁ h₂ i, setoid.trans (h₁ _) (h₂ _)⟩ }\n\n/-- Given a function `f : Π i, quotient (S i)`, returns the class of functions `Π i, α i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def quotient.choice {ι : Type*} {α : ι → Type*} [S : Π i, setoid (α i)]\n  (f : Π i, quotient (S i)) : @quotient (Π i, α i) (by apply_instance) :=\n⟦λ i, (f i).out⟧\n\ntheorem quotient.choice_eq {ι : Type*} {α : ι → Type*} [Π i, setoid (α i)]\n  (f : Π i, α i) : quotient.choice (λ i, ⟦f i⟧) = ⟦f⟧ :=\nquotient.sound $ λ i, quotient.mk_out _\n\nlemma nonempty_quotient_iff (s : setoid α) : nonempty (quotient s) ↔ nonempty α :=\n⟨assume ⟨a⟩, quotient.induction_on a nonempty.intro, assume ⟨a⟩, ⟨⟦a⟧⟩⟩\n\n/-- `trunc α` is the quotient of `α` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty α`, but unlike `nonempty α`, `trunc α` is data,\n  so the VM representation is the same as `α`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (α : Sort u) : Sort u := @quot α (λ _ _, true)\n\ntheorem true_equivalence : @equivalence α (λ _ _, true) :=\n⟨λ _, trivial, λ _ _ _, trivial, λ _ _ _ _ _, trivial⟩\n\nnamespace trunc\n\n/-- Constructor for `trunc α` -/\ndef mk (a : α) : trunc α := quot.mk _ a\n\ninstance [inhabited α] : inhabited (trunc α) := ⟨mk (default _)⟩\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : α → β) (c : ∀ a b : α, f a = f b) : trunc α → β :=\nquot.lift f (λ a b _, c a b)\n\ntheorem ind {β : trunc α → Prop} : (∀ a : α, β (mk a)) → ∀ q : trunc α, β q := quot.ind\n\nprotected theorem lift_mk (f : α → β) (c) (a : α) : lift f c (mk a) = f a := rfl\n\n/-- Lift a constant function on `q : trunc α`. -/\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc α) (f : α → β)\n  (c : ∀ a b : α, f a = f b) : β := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {β : trunc α → Prop} (q : trunc α)\n  (h : ∀ a, β (mk a)) : β q := ind h q\n\ntheorem exists_rep (q : trunc α) : ∃ a : α, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on₂ {C : trunc α → trunc β → Prop} (q₁ : trunc α) (q₂ : trunc β)\n  (h : ∀ a b, C (mk a) (mk b)) : C q₁ q₂ :=\ntrunc.induction_on q₁ $ λ a₁, trunc.induction_on q₂ (h a₁)\n\nprotected theorem eq (a b : trunc α) : a = b :=\ntrunc.induction_on₂ a b (λ x y, quot.sound trivial)\n\ninstance : subsingleton (trunc α) := ⟨trunc.eq⟩\n\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : trunc α) (f : α → trunc β) : trunc β :=\ntrunc.lift_on q f (λ a b, trunc.eq _ _)\n\n/-- A function `f : α → β` defines a function `map f : trunc α → trunc β`. -/\ndef map (f : α → β) (q : trunc α) : trunc β := bind q (trunc.mk ∘ f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := λ α q, trunc.eq _ _,\n  pure_bind := λ α β q f, rfl,\n  bind_assoc := λ α β γ x f g, trunc.eq _ _ }\n\nvariable {C : trunc α → Sort*}\n\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : Π a, C (mk a)) (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc α) : C q :=\nquot.rec f (λ a b _, h a b) q\n\n/-- A version of `trunc.rec` taking `q : trunc α` as the first argument. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc α) (f : Π a, C (mk a))\n  (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b) : C q :=\ntrunc.rec f h q\n\n/-- A version of `trunc.rec_on` assuming the codomain is a `subsingleton`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton\n   [∀ a, subsingleton (C (mk a))] (q : trunc α) (f : Π a, C (mk a)) : C q :=\ntrunc.rec f (λ a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc α` (using the axiom of choice). -/\nnoncomputable def out : trunc α → α := quot.out\n\n@[simp] theorem out_eq (q : trunc α) : mk q.out = q := trunc.eq _ _\n\nprotected theorem nonempty (q : trunc α) : nonempty α :=\nnonempty_of_exists q.exists_rep\n\nend trunc\n\nnamespace quotient\nvariables {γ : Sort*} {φ : Sort*}\n  {s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}\n\n/-! Versions of quotient definitions and lemmas ending in `'` use unification instead\nof typeclass inference for inferring the `setoid` argument. This is useful when there are\nseveral different quotient relations on a type, for example quotient groups, rings and modules. -/\n\n/-- A version of `quotient.mk` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk' (a : α) : quotient s₁ := quot.mk s₁.1 a\n\n/-- `quotient.mk'` is a surjective function. -/\nlemma surjective_quotient_mk' : function.surjective (quotient.mk' : α → quotient s₁) :=\nquot.exists_rep\n\n/-- A version of `quotient.lift_on` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s₁) (f : α → φ)\n  (h : ∀ a b, @setoid.r α s₁ a b → f a = f b) : φ := quotient.lift_on q f h\n\n@[simp]\nprotected lemma lift_on'_mk' (f : α → φ) (h) (x : α) :\n  quotient.lift_on' (@quotient.mk' _ s₁ x) f h = f x := rfl\n\n/-- A version of `quotient.lift_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on₂' (q₁ : quotient s₁) (q₂ : quotient s₂) (f : α → β → γ)\n  (h : ∀ a₁ a₂ b₁ b₂, @setoid.r α s₁ a₁ b₁ → @setoid.r β s₂ a₂ b₂ → f a₁ a₂ = f b₁ b₂) : γ :=\nquotient.lift_on₂ q₁ q₂ f h\n\n@[simp]\nprotected lemma lift_on₂'_mk' (f : α → β → γ) (h) (a : α) (b : β) :\n  quotient.lift_on₂' (@quotient.mk' _ s₁ a) (@quotient.mk' _ s₂ b) f h = f a b := rfl\n\n/-- A version of `quotient.ind` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s₁ → Prop}\n  (h : ∀ a, p (quotient.mk' a)) (q : quotient s₁) : p q :=\nquotient.ind h q\n\n/-- A version of `quotient.ind₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma ind₂' {p : quotient s₁ → quotient s₂ → Prop}\n  (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂))\n  (q₁ : quotient s₁) (q₂ : quotient s₂) : p q₁ q₂ :=\nquotient.ind₂ h q₁ q₂\n\n/-- A version of `quotient.induction_on` taking `{s : setoid α}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s₁ → Prop} (q : quotient s₁)\n  (h : ∀ a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n/-- A version of `quotient.induction_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on₂' {p : quotient s₁ → quotient s₂ → Prop} (q₁ : quotient s₁)\n  (q₂ : quotient s₂) (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂)) : p q₁ q₂ :=\nquotient.induction_on₂ q₁ q₂ h\n\n/-- A version of `quotient.induction_on₃` taking `{s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on₃' {p : quotient s₁ → quotient s₂ → quotient s₃ → Prop}\n  (q₁ : quotient s₁) (q₂ : quotient s₂) (q₃ : quotient s₃)\n  (h : ∀ a₁ a₂ a₃, p (quotient.mk' a₁) (quotient.mk' a₂) (quotient.mk' a₃)) : p q₁ q₂ q₃ :=\nquotient.induction_on₃ q₁ q₂ q₃ h\n\n/-- A version of `quotient.rec_on_subsingleton` taking `{s₁ : setoid α}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_eliminator]\nprotected def rec_on_subsingleton' {φ : quotient s₁ → Sort*}\n  [h : ∀ a, subsingleton (φ ⟦a⟧)] (q : quotient s₁) (f : Π a, φ (quotient.mk' a)) : φ q :=\nquotient.rec_on_subsingleton q f\n\n/-- A version of `quotient.rec_on_subsingleton₂` taking `{s₁ : setoid α} {s₂ : setoid α}`\nas implicit arguments instead of instance arguments. -/\nattribute [reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton₂'\n   {φ : quotient s₁ → quotient s₂ → Sort*} [h : ∀ a b, subsingleton (φ ⟦a⟧ ⟦b⟧)]\n   (q₁ : quotient s₁) (q₂ : quotient s₂) (f : Π a₁ a₂, φ (quotient.mk' a₁) (quotient.mk' a₂)) :\n   φ q₁ q₂ :=\nquotient.rec_on_subsingleton₂ q₁ q₂ f\n\n/-- Recursion on a `quotient` argument `a`, result type depends on `⟦a⟧`. -/\nprotected def hrec_on' {φ : quotient s₁ → Sort*} (qa : quotient s₁) (f : Π a, φ (quotient.mk' a))\n  (c : ∀ a₁ a₂, a₁ ≈ a₂ → f a₁ == f a₂) : φ qa :=\nquot.hrec_on qa f c\n\n@[simp] \n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂' {φ : quotient s₁ → quotient s₂ → Sort*} (qa : quotient s₁)\n  (qb : quotient s₂) (f : ∀ a b, φ (quotient.mk' a) (quotient.mk' b))\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) : φ qa qb :=\nquotient.hrec_on₂ qa qb f c\n\n@[simp] lemma hrec_on₂'_mk' {φ : quotient s₁ → quotient s₂ → Sort*}\n  (f : ∀ a b, φ (quotient.mk' a) (quotient.mk' b))\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) (x : α) (qb : quotient s₂) :\n  (quotient.mk' x).hrec_on₂' qb f c = qb.hrec_on' (f x) (λ b₁ b₂, c _ _ _ _ (setoid.refl _)) :=\nrfl\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : α → β) (h : ((≈) ⇒ (≈)) f f) :\n  quotient s₁ → quotient s₂ :=\nquot.map f h\n\n@[simp] lemma map'_mk' (f : α → β) (h) (x : α) :\n  (quotient.mk' x : quotient s₁).map' f h = (quotient.mk' (f x) : quotient s₂) :=\nrfl\n\n/-- A version of `quotient.map₂` using curly braces and unification. -/\nprotected def map₂' (f : α → β → γ) (h : ((≈) ⇒ (≈) ⇒ (≈)) f f) :\n  quotient s₁ → quotient s₂ → quotient s₃ :=\nquotient.map₂ f h\n\n@[simp] lemma map₂'_mk' (f : α → β → γ) (h) (x : α) :\n  (quotient.mk' x : quotient s₁).map₂' f h =\n    (quotient.map' (f x) (h (setoid.refl x)) : quotient s₂ → quotient s₃) :=\nrfl\n\nlemma exact' {a b : α} :\n  (quotient.mk' a : quotient s₁) = quotient.mk' b → @setoid.r _ s₁ a b :=\nquotient.exact\n\nlemma sound' {a b : α} : @setoid.r _ s₁ a b → @quotient.mk' α s₁ a = quotient.mk' b :=\nquotient.sound\n\n@[simp]\nprotected lemma eq' {a b : α} : @quotient.mk' α s₁ a = quotient.mk' b ↔ @setoid.r _ s₁ a b :=\nquotient.eq\n\n/-- A version of `quotient.out` taking `{s₁ : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : quotient s₁) : α := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s₁) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : α) : @setoid.r α s₁ (quotient.mk' a : quotient s₁).out' a :=\nquotient.exact (quotient.out_eq _)\nend quotient\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/quot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.4617647054907386}}
{"text": "import .extensionality\nimport .boolean_algebra_tactic\nimport .finset_tactic\nimport tactic\nimport tactic.interactive\nimport .set_tactic\n\n\nuniverse u\n\n/-meta def simpl_tactic : tactic unit :=\n`[simp only [simpl_sdiff, simpl_eq, ext_le, ext_bot, ext_top, ext_meet, ext_join, ext_compl] at *; tauto!]-/\n\n\n-- TODO: Lots of things are boolean algebras.  We should have a way to configure\n-- which boolean algebras we want to solve, actually.\n--\n-- Functions into boolean algebras are usually not useful, so we ignore them by default.\n-- Moreover, hypotheses are either Prop or functions which indirectly produce a Prop,\n-- so we really should probably ignore function types with Prop in them.\nmeta def get_boolalg_typ (consider_function_types := ff) (e : expr) : tactic (list expr) :=\n  ((do\n    `(%%boolalg_typ) <- tactic.infer_type e,\n    match boolalg_typ with \n    -- finset T gets returned directly \n    | `(finset %%set_typ) := do return [boolalg_typ]\n    -- set T gets returned directly\n    | `(set %%set_typ) := do return [boolalg_typ]\n    -- work needs to be done if we're not working with sets/finsets,\n    -- but with a type with a [boolean_algebra T] instance on it.\n    | _ := (do \n        boolalg_hyp <- tactic.to_expr ``(infer_instance : boolean_algebra %%boolalg_typ),\n        match boolalg_typ with \n        -- Function types are usually not useful\n        | `(_ -> _) := if consider_function_types then return [boolalg_typ] else return []\n        -- Prop is not useful\n        | `(Prop) := return []\n        -- Other types, we can (probably) return\n        | _ := return [boolalg_typ]\n        end)\n    end)\n  <|>\n    return [])\n\nmeta def boolean_algebra_types_in_expr (consider_function_types := ff) : expr → tactic (list expr)\n| e :=\n  do \n    e_inner <- (match e with\n      -- This mostly handles basic expressions \n      | expr.local_const unique pretty _ _ := get_boolalg_typ consider_function_types e\n      -- applications\n      | expr.app e1 e2 := \n        do l1 <- boolean_algebra_types_in_expr e1, \n          l2 <- boolean_algebra_types_in_expr e2,\n          return (l1 ++ l2)\n      -- abstracts\n      | expr.lam _ _ argtyp body :=\n        do l1 <- boolean_algebra_types_in_expr argtyp, \n          l2 <- boolean_algebra_types_in_expr body,\n          return (l1 ++ l2)\n      | expr.pi _ _ argtyp body :=\n        do l1 <- boolean_algebra_types_in_expr argtyp, \n          l2 <- boolean_algebra_types_in_expr body,\n          return (l1 ++ l2)\n      | expr.elet _ argtyp argval body := \n        do l1 <- boolean_algebra_types_in_expr argtyp, \n          l2 <- boolean_algebra_types_in_expr argval,\n          l3 <- boolean_algebra_types_in_expr body,\n          return (l1 ++ l2 ++ l3)\n      | _ := return []\n      end),\n    e_outer <- get_boolalg_typ consider_function_types e,\n    return (e_inner ++ e_outer)\n\ndef unique_list {T: Type*} [decidable_eq T]: list T -> list T \n| [] := []\n| (x :: xs) := let tl := unique_list xs in\n                if list.mem x tl then tl else x :: tl\n\nmeta def infer_base_simp_lemmas (type : expr) : (tactic (list pexpr)) := do\n  name <- tactic.get_unused_name `_instrw,\n  instance_type <- tactic.to_expr ``(boolalg_ext_lemmas %%type _),\n  expr <- tactic.to_expr ``(by apply_instance : %%instance_type),\n  new_hyp <- tactic.assertv name instance_type expr,\n  return [``((%%new_hyp).simpl_eq),\n          ``((%%new_hyp).simpl_lt),\n          ``((%%new_hyp).ext_le),\n          ``((%%new_hyp).ext_bot),\n          ``((%%new_hyp).ext_sdiff),\n          ``((%%new_hyp).ext_meet),\n          ``((%%new_hyp).ext_join)]\n\nmeta def infer_top_simp_lemmas (type : expr) : (tactic (list pexpr)) := (do\n  name <- tactic.get_unused_name `_instrw,\n  instance_type <- tactic.to_expr ``(boolalg_ext_lemmas_top %%type _),\n  expr <- tactic.to_expr ``(by apply_instance : %%instance_type),\n  new_hyp <- tactic.assertv name instance_type expr,\n  return [``((%%new_hyp).ext_top)]) <|> return []\n\nmeta def infer_compl_simp_lemmas (type : expr) : (tactic (list pexpr)) := (do\n  name <- tactic.get_unused_name `_instrw,\n  instance_type <- tactic.to_expr ``(boolalg_ext_lemmas_compl %%type _),\n  expr <- tactic.to_expr ``(by apply_instance : %%instance_type),\n  new_hyp <- tactic.assertv name instance_type expr,\n  return [``((%%new_hyp).ext_compl)]) <|> return []\n\nmeta def rewrite_for_type (type : expr) : (tactic unit) := do\n  simp_lemmas <- infer_base_simp_lemmas type,\n  compl_lemmas <- infer_compl_simp_lemmas type,\n  top_lemmas <- infer_top_simp_lemmas type,\n  tactic.try (tactic.interactive.simp none tt\n              ((simp_lemmas ++ compl_lemmas ++ top_lemmas).map tactic.simp_arg_type.expr)\n                  list.nil interactive.loc.wildcard),\n  tactic.skip\n\nmeta def gather_types (consider_function_types := ff) : (tactic (list expr)) := do\n  goal <- tactic.target,\n  hyps <- tactic.local_context,\n  types <- (do \n            types_in_expr <- (goal :: hyps).mmap (boolean_algebra_types_in_expr consider_function_types),\n            return (unique_list (list.foldr list.append [] types_in_expr))),\n  --tactic.trace \"Boolean algebra types:\",\n  --tactic.trace types,\n  return types\n\n\nmeta def set_ext (consider_function_types := ff) : (tactic unit) := do\n  tactic.try `[simp only [ne, ge, gt, superset, ssuperset] at *],\n  tactic.try cleanup.finset_cleanup,\n  tactic.try cleanup.set_cleanup,\n  types <- gather_types consider_function_types,\n  types.mmap rewrite_for_type,\n  tactic.skip \n\n\nmeta def specialize_all (ename : expr) : (tactic unit) := do\n  context <- tactic.local_context,\n  context.mmap (fun hyp, tactic.try $ do\n    pf <- tactic.to_expr ``(%%hyp %%ename),\n    tactic.note `H none pf,\n    tactic.skip),\n  tactic.skip\n\nmeta def introduce_and_specialize : (tactic unit) := do \n  target <- tactic.target,\n  match target with\n  | expr.lam nm _ argtyp body := do\n    let basename := (if (nm.to_string = \"ᾰ\") then `H else nm) in do\n    fname <- tactic.get_unused_name basename,\n    exp <- tactic.intro fname,\n    specialize_all exp\n  | expr.pi nm _ argtyp body := do\n    let basename := (if (nm.to_string = \"ᾰ\") then `H else nm) in do\n    fname <- tactic.get_unused_name basename,\n    ename <- tactic.intro fname,\n    specialize_all ename\n  | _ := tactic.fail \"goal not an abstraction\"\n  end\n\nmeta def clear_existential_hyp (hyp : expr) : (tactic (option expr)) := do\n  htyp <- tactic.infer_type hyp,\n  match htyp with\n  | `(@Exists _ _) := do \n      [(_, [witness, _])] <- tactic.cases hyp,\n      return (some witness)\n  | _ := return none\n  end\n\nmeta def forall_hypotheses (f : expr -> tactic unit) : (tactic unit) := do\n  context <- tactic.local_context,\n  result <- context.mmap (fun hyp, (f hyp >> return tt) <|> return ff),\n  if (result.filter (fun (x : bool), x)).empty then \n    tactic.fail \"could not apply function to any hypothesis\" \n  else tactic.skip\n\nmeta def clear_existentials_hyp_and_specialize : (tactic unit) := do\n  forall_hypotheses (fun hyp, \n    do some witness <- clear_existential_hyp hyp, specialize_all witness\n  ) <|> tactic.fail \"no existentials present\"\n\nmeta def clear_existential_goal : (tactic unit) := do\n  target <- tactic.target,\n  match target with\n  | `(@Exists %%typ _) := do\n    mvar <- tactic.mk_meta_var typ,\n    tactic.existsi mvar,\n    tactic.skip\n  | _ := tactic.fail \"goal is not existential\"\n  end\n\nmeta def split_hypothesis (hyp : expr) : (tactic unit) := do\n  htyp <- tactic.infer_type hyp,\n  match htyp with\n  | `(_ /\\ _) := tactic.cases hyp >> tactic.skip\n  | _ := tactic.fail \"hypothesis is not conjunction\"\n  end\n\nmeta def split_all_hypothesis : (tactic unit) := do\n  forall_hypotheses split_hypothesis <|> tactic.fail \"no conjunctions in hypothesis\"\n\nmeta def split_goal : (tactic unit) := do\n  target <- tactic.target,\n  match target with\n  | `(_ /\\ _) := tactic.split >> tactic.skip\n  | _ := tactic.fail \"not a conjunction\"\n  end\n \nmeta def finisher_step : (tactic unit) := do\n  -- push negatives everywhere\n  tactic.try `[push_neg at *],\n  tactic.try `[push_neg],\n  -- try introducing a name and specializing\n  introduce_and_specialize \n  <|>\n  -- if that fails, eliminate existentials in the goal by filling them in\n  -- with a metavariable.\n  -- maybe: fail instead?  We can't automatically determine what should go in.\n  clear_existential_goal\n  <|>\n  -- if that fails, attempt to clear existentials\n  clear_existentials_hyp_and_specialize\n  <|>\n  -- if that fails, split all hypothesis that are conjunctions\n  split_all_hypothesis\n  <|>\n  -- if that fails, split the goal if it is a conjunction\n  split_goal\n  <|>\n  -- if that fails, run tauto.\n  -- TODO: fill in metavariables somehow introduced by existentials????\n  -- this can be hard.\n  `[tauto! {closer := tactic.tidy}]\n\nmeta def set_solver_finisher : (tactic unit) := do\n  tactic.repeat finisher_step,\n  -- we may have a list of goals -- we need to finish all of them\n  -- in order to succeed.\n  tactic.all_goals $ (\n    tactic.target >>= (fun (target : expr),\n    match target with\n    -- if there is a disjunction in the goal, try either side\n    | `(_ \\/ _) := ((tactic.left >> set_solver_finisher) <|> (tactic.right >> set_solver_finisher)) >> tactic.skip\n    -- if there is a disjucntion in the hypothesis, split it and make sure both sides work.\n    | _ := (do \n      mvar1 <- tactic.mk_mvar,\n      mvar2 <- tactic.mk_mvar,\n      disj <- tactic.find_assumption `(%%mvar1 \\/ %%mvar2),\n      -- if we can't find such as disjunction, then we fail as the finisher could not work.\n      tactic.cases disj [],\n      tactic.all_goals set_solver_finisher,\n      tactic.skip)\n    end)),\n  tactic.skip\n\nmeta def set_solver (consider_function_types := ff) : (tactic unit) := do\n  set_ext consider_function_types,\n  set_solver_finisher\n\nexample (α : Type*) [boolean_algebra α] (X Y Z P Q W : α) :\n  (X ⊔ (Y ⊔ Z)) ⊔ ((W ⊓ P ⊓ Q)ᶜ ⊔ (P ⊔ W ⊔ Q)) = ⊤ :=\nbegin\n  set_solver,\nend\n\nexample (T : Type*) [fintype T] [decidable_eq T] (X Y Z P Q W : finset T)  :\n  (X ⊔ (Y ⊔ Z)) ⊔ ((W ⊓ P ⊓ Q)ᶜ ⊔ (P ⊔ W ⊔ Q)) = ⊤ :=\nbegin\n  set_solver,\nend\n\n-- note the lack of fintype T here\nexample (T : Type*) [decidable_eq T] (X Y Z P Q W : finset T)  :\n  (X ∪ Y) ≥ X :=\nbegin\n  set_solver,\nend\n\nexample (T : Type*) [decidable_eq T] (x z : T) (Y : set T) :\n  x ∈ ({z} : set T) → x = z :=\nbegin\n  set_solver,\nend\n\nexample (α : Type*) [boolean_algebra α]  (A B C D E F G : α) :\n  A ≤ B →\n  B ≤ C →\n  C ≤ D ⊓ E →\n  D ≤ Fᶜ →\n  (A ⊓ F = ⊥) :=\nbegin\n  set_ext,\n  tactic.timetac \"fast\" $ (`[repeat {finisher_step}]),\nend\n\nexample (α : Type*) [boolean_algebra α]  (A B C D E F G : α) :\n  A ≤ B →\n  B ≤ C →\n  C ≤ D ⊓ E →\n  D ≤ Fᶜ →\n  (A ⊓ F = ⊥) :=\nbegin\n  tactic.timetac \"slow\" $ set_solver,\nend\n \nexample (α : Type*) (C E : set α) (hCE : C ⊓ E = ∅) :\n  C ⊔ (E ⊔ C)ᶜ = Eᶜ := \nby {set_solver, }\n\nexample (α : Type*) (C E : set α) (h : C ⊓ E = ⊥) : \n  C ⊓ (C ⊔ E)ᶜ = ∅ := \nby {set_solver, } \n\nexample (X₀ X₁ X₂ X₃ X₄ X₅ X₆ X₇ X₈ X₉ : set nat) :\n  (X₀ ⊔ X₁ ⊔ (X₂ ⊓ X₃) ⊔ X₄ ⊔ X₅ ⊔ (X₆ ⊓ X₇ ⊓ X₈) ⊔ X₉)ᶜ\n    ≤ (X₉ᶜ ⊓ ((X₆ᶜ ⊔ ⊥) ⊔ X₈ᶜ ⊔ X₇ᶜᶜᶜ) ⊓ X₅ᶜ ⊓ (X₀ᶜ \\ X₁) ⊓ (X₃ᶜ ⊔ X₂ᶜ) ⊓ X₄ᶜ) :=\nbegin\n  tactic.timetac \"big_ext\" $ set_ext,\n  tactic.timetac \"big_finish\" $ set_solver_finisher\nend\n\n/-\nexample (X₀ X₁ X₂ X₃ X₄ X₅ X₆ X₇ X₈ X₉ : α) :\n  (X₀ ⊔ X₁ ⊔ (X₂ ⊓ X₃) ⊔ X₄ ⊔ X₅ ⊔ (X₆ ⊓ X₇ ⊓ X₈) ⊔ X₉)ᶜ\n    ≤ (X₉ᶜ ⊓ ((X₆ᶜ ⊔ ⊥) ⊔ X₈ᶜ ⊔ X₇ᶜᶜᶜ) ⊓ X₅ᶜ ⊓ (X₀ᶜ \\ X₁) ⊓ (X₃ᶜ ⊔ X₂ᶜ) ⊓ X₄ᶜ) :=\nby tactic.timetac \"big\" $ boolean_algebra_tactic\n\nexample (A B C D E F G : α) :\n  A ≤ B →\n  B ≤ C →\n  C ≤ D ⊓ E →\n  A ≤ E :=\nbegin\n  simp only [rw_sdiff, rw_eq, rw_le, rw_bot, rw_top, rw_sup, rw_inf, rw_compl] at *,\n  intros H1 H2 H3 u H4,\n  specialize (H1 u),\n  specialize (H2 u),\n  specialize (H3 u),\n  tauto!\nend\n\nexample (A B C D E F G : α) :\n  A ≤ B →\n  B ≤ C →\n  C ≤ D ⊓ E →\n  D ≤ Fᶜ →\n  (A ⊓ F = ⊥) :=\nbegin\n  simp only [rw_sdiff, rw_eq, rw_le, rw_bot, rw_top, rw_sup, rw_inf, rw_compl] at *,\n  intros H1 H2 H3 H4,\n  split;\n  intro u, specialize (H1 u), specialize (H2 u), specialize (H3 u), specialize (H4 u), tauto!,\n  tauto!,\nend\n-/\n", "meta": {"author": "apnelson1", "repo": "lean-matroids", "sha": "1880f5b4b9a99948368e35539672a9bf35cc09cc", "save_path": "github-repos/lean/apnelson1-lean-matroids", "path": "github-repos/lean/apnelson1-lean-matroids/lean-matroids-1880f5b4b9a99948368e35539672a9bf35cc09cc/src/old/old_aux/set_tactic/solver.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.72487026428967, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4617646903457713}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.multiset.erase_dup\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# The fold operation for a commutative associative operation over a multiset.\n-/\n\nnamespace multiset\n\n\n/-! ### fold -/\n\n/-- `fold op b s` folds a commutative associative operation `op` over\n  the multiset `s`. -/\ndef fold {α : Type u_1} (op : α → α → α) [hc : is_commutative α op] [ha : is_associative α op] :\n    α → multiset α → α :=\n  foldr op sorry\n\ntheorem fold_eq_foldr {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (s : multiset α) :\n    fold op b s = foldr op (left_comm op is_commutative.comm is_associative.assoc) b s :=\n  rfl\n\n@[simp] theorem coe_fold_r {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (l : List α) : fold op b ↑l = list.foldr op b l :=\n  rfl\n\ntheorem coe_fold_l {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (l : List α) : fold op b ↑l = list.foldl op b l :=\n  sorry\n\ntheorem fold_eq_foldl {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (s : multiset α) :\n    fold op b s = foldl op (right_comm op is_commutative.comm is_associative.assoc) b s :=\n  quot.induction_on s fun (l : List α) => coe_fold_l op b l\n\n@[simp] theorem fold_zero {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) : fold op b 0 = b :=\n  rfl\n\n@[simp] theorem fold_cons_left {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (a : α) (s : multiset α) :\n    fold op b (a ::ₘ s) = op a (fold op b s) :=\n  foldr_cons op (fold._proof_1 op)\n\ntheorem fold_cons_right {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (a : α) (s : multiset α) :\n    fold op b (a ::ₘ s) = op (fold op b s) a :=\n  sorry\n\ntheorem fold_cons'_right {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (a : α) (s : multiset α) :\n    fold op b (a ::ₘ s) = fold op (op b a) s :=\n  sorry\n\ntheorem fold_cons'_left {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (a : α) (s : multiset α) :\n    fold op b (a ::ₘ s) = fold op (op a b) s :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (fold op b (a ::ₘ s) = fold op (op a b) s)) (fold_cons'_right op b a s)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (fold op (op b a) s = fold op (op a b) s)) (is_commutative.comm b a)))\n      (Eq.refl (fold op (op a b) s)))\n\ntheorem fold_add {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b₁ : α) (b₂ : α) (s₁ : multiset α) (s₂ : multiset α) :\n    fold op (op b₁ b₂) (s₁ + s₂) = op (fold op b₁ s₁) (fold op b₂ s₂) :=\n  sorry\n\ntheorem fold_singleton {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] (b : α) (a : α) : fold op b (a ::ₘ 0) = op a b :=\n  sorry\n\ntheorem fold_distrib {α : Type u_1} {β : Type u_2} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] {f : β → α} {g : β → α} (u₁ : α) (u₂ : α) (s : multiset β) :\n    fold op (op u₁ u₂) (map (fun (x : β) => op (f x) (g x)) s) =\n        op (fold op u₁ (map f s)) (fold op u₂ (map g s)) :=\n  sorry\n\ntheorem fold_hom {α : Type u_1} {β : Type u_2} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] {op' : β → β → β} [is_commutative β op'] [is_associative β op']\n    {m : α → β} (hm : ∀ (x y : α), m (op x y) = op' (m x) (m y)) (b : α) (s : multiset α) :\n    fold op' (m b) (map m s) = m (fold op b s) :=\n  sorry\n\ntheorem fold_union_inter {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] [DecidableEq α] (s₁ : multiset α) (s₂ : multiset α) (b₁ : α)\n    (b₂ : α) :\n    op (fold op b₁ (s₁ ∪ s₂)) (fold op b₂ (s₁ ∩ s₂)) = op (fold op b₁ s₁) (fold op b₂ s₂) :=\n  sorry\n\n@[simp] theorem fold_erase_dup_idem {α : Type u_1} (op : α → α → α) [hc : is_commutative α op]\n    [ha : is_associative α op] [DecidableEq α] [hi : is_idempotent α op] (s : multiset α) (b : α) :\n    fold op b (erase_dup s) = fold op b s :=\n  sorry\n\ntheorem le_smul_erase_dup {α : Type u_1} [DecidableEq α] (s : multiset α) :\n    ∃ (n : ℕ), s ≤ n •ℕ erase_dup s :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/multiset/fold_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4617646879281374}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison\n\nDefines a functor between categories.\n\n(As it is a 'bundled' object rather than the `is_functorial` typeclass parametrised\nby the underlying function on objects, the name is capitalised.)\n\nIntroduces notations\n  `C ⥤ D` for the type of all functors from `C` to `D`.\n    (I would like a better arrow here, unfortunately ⇒ (`\\functor`) is taken by core.)\n  `F X` (a coercion) for a functor `F` acting on an object `X`.\n-/\n\nimport category_theory.category\nimport tactic.tidy\n\nnamespace category_theory\n\nuniverses u v u₁ v₁ u₂ v₂ u₃ v₃\n\n/--\n`functor C D` represents a functor between categories `C` and `D`.\n\nTo apply a functor `F` to an object use `F X` (which uses a coercion), and to a morphism use `F.map f`.\n\nThe axiom `map_id_lemma` expresses preservation of identities, and\n`map_comp_lemma` expresses functoriality.\n\nImplementation note: when constructing a `functor`, you need to define the\n`map'` field (which does not know about the coercion).\nWhen using a `functor`, use the `map` field (which makes use of the coercion).\n-/\nstructure functor (C : Type u₁) [category.{u₁ v₁} C] (D : Type u₂) [category.{u₂ v₂} D] : Type (max u₁ v₁ u₂ v₂) :=\n(obj       : C → D)\n(map'      : Π {X Y : C}, (X ⟶ Y) → ((obj X) ⟶ (obj Y)))\n(map_id'   : ∀ (X : C), map' (𝟙 X) = 𝟙 (obj X) . obviously)\n(map_comp' : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map' (f ≫ g) = (map' f) ≫ (map' g) . obviously)\n\ninfixr ` ⥤ `:70 := functor       -- type as \\func --\n\nnamespace functor\n\nsection\nvariables {C : Type u₁} [𝒞 : category.{u₁ v₁} C] {D : Type u₂} [𝒟 : category.{u₂ v₂} D]\ninclude 𝒞 𝒟\n\ninstance : has_coe_to_fun (C ⥤ D) :=\n{ F   := λ F, C → D,\n  coe := λ F, F.obj }\n\ndef map (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) : (F X) ⟶ (F Y) := F.map' f\n\n@[simp] lemma map_id (F : C ⥤ D) (X : C) : F.map (𝟙 X) = 𝟙 (F X) :=\nbegin unfold functor.map, erw F.map_id', refl end\n@[simp] lemma map_comp (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  F.map (f ≫ g) = F.map f ≫ F.map g :=\nbegin unfold functor.map, erw F.map_comp' end\n\n-- We define a refl lemma 'refolding' the coercion,\n-- and two lemmas for the coercion applied to an explicit structure.\n@[simp] lemma obj_eq_coe {F : C ⥤ D} (X : C) : F.obj X = F X := rfl\n@[simp] lemma mk_obj (o : C → D) (m mi mc) (X : C) :\n  ({ functor . obj := o, map' := m, map_id' := mi, map_comp' := mc } : C ⥤ D) X = o X := rfl\n@[simp] lemma mk_map (o : C → D) (m mi mc) {X Y : C} (f : X ⟶ Y) :\n  functor.map { functor . obj := o, map' := m, map_id' := mi, map_comp' := mc } f = m f := rfl\nend\n\nsection\nvariables (C : Type u₁) [𝒞 : category.{u₁ v₁} C]\ninclude 𝒞\n\n/-- `functor.id C` is the identity functor on a category `C`. -/\nprotected def id : C ⥤ C :=\n{ obj      := λ X, X,\n  map'     := λ _ _ f, f }\n\nvariable {C}\n\n@[simp] lemma id_obj (X : C) : (functor.id C) X = X := rfl\n@[simp] lemma id_map {X Y : C} (f : X ⟶ Y) : (functor.id C).map f = f := rfl\nend\n\nsection\nvariables {C : Type u₁} [𝒞 : category.{u₁ v₁} C]\n          {D : Type u₂} [𝒟 : category.{u₂ v₂} D]\n          {E : Type u₃} [ℰ : category.{u₃ v₃} E]\ninclude 𝒞 𝒟 ℰ\n\n/--\n`F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp (F : C ⥤ D) (G : D ⥤ E) : C ⥤ E :=\n{ obj      := λ X, G (F X),\n  map'      := λ _ _ f, G.map (F.map f) }\n\ninfixr ` ⋙ `:80 := comp\n\n@[simp] lemma comp_obj (F : C ⥤ D) (G : D ⥤ E) (X : C) : (F ⋙ G) X = G (F X) := rfl\n@[simp] lemma comp_map (F : C ⥤ D) (G : D ⥤ E) (X Y : C) (f : X ⟶ Y) :\n  (F ⋙ G).map f = G.map (F.map f) := rfl\nend\n\nsection\nvariables (C : Type u₁) [𝒞 : category.{u₁ v₁} C]\ninclude 𝒞\n\n@[simp] def ulift_down : (ulift.{u₂} C) ⥤ C :=\n{ obj := λ X, X.down,\n  map' := λ X Y f, f }\n\n@[simp] def ulift_up : C ⥤ (ulift.{u₂} C) :=\n{ obj := λ X, ⟨ X ⟩,\n  map' := λ X Y f, f }\nend\n\nend functor\n\ndef bundled.map {c : Type u → Type v} {d : Type u → Type v} (f : Π{a}, c a → d a) (s : bundled c) : bundled d :=\n{ α := s.α, str := f s.str }\n\ndef concrete_functor\n  {C : Type u → Type v} {hC : ∀{α β}, C α → C β → (α → β) → Prop} [concrete_category @hC]\n  {D : Type u → Type v} {hD : ∀{α β}, D α → D β → (α → β) → Prop} [concrete_category @hD]\n  (m : ∀{α}, C α → D α) (h : ∀{α β} {ia : C α} {ib : C β} {f}, hC ia ib f → hD (m ia) (m ib) f) :\n  bundled C ⥤ bundled D :=\n{ obj := bundled.map @m,\n  map' := λ X Y f, ⟨ f, h f.2 ⟩}\n\nend category_theory\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/category_theory/functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4617646855105029}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Johannes Hölzl, Sander Dahmen, Scott Morrison\n-/\nimport algebra.module.big_operators\nimport linear_algebra.dfinsupp\nimport linear_algebra.invariant_basis_number\nimport linear_algebra.isomorphisms\nimport linear_algebra.std_basis\nimport set_theory.cardinal.cofinality\n\n/-!\n# Dimension of modules and vector spaces\n\n## Main definitions\n\n* The rank of a module is defined as `module.rank : cardinal`.\n  This is defined as the supremum of the cardinalities of linearly independent subsets.\n\n* The rank of a linear map is defined as the rank of its range.\n\n## Main statements\n\n* `linear_map.dim_le_of_injective`: the source of an injective linear map has dimension\n  at most that of the target.\n* `linear_map.dim_le_of_surjective`: the target of a surjective linear map has dimension\n  at most that of that source.\n* `basis_fintype_of_finite_spans`:\n  the existence of a finite spanning set implies that any basis is finite.\n* `infinite_basis_le_maximal_linear_independent`:\n  if `b` is an infinite basis for a module `M`,\n  and `s` is a maximal linearly independent set,\n  then the cardinality of `b` is bounded by the cardinality of `s`.\n\nFor modules over rings satisfying the rank condition\n\n* `basis.le_span`:\n  the cardinality of a basis is bounded by the cardinality of any spanning set\n\nFor modules over rings satisfying the strong rank condition\n\n* `linear_independent_le_span`:\n  For any linearly independent family `v : ι → M`\n  and any finite spanning set `w : set M`,\n  the cardinality of `ι` is bounded by the cardinality of `w`.\n* `linear_independent_le_basis`:\n  If `b` is a basis for a module `M`,\n  and `s` is a linearly independent set,\n  then the cardinality of `s` is bounded by the cardinality of `b`.\n\nFor modules over rings with invariant basis number\n(including all commutative rings and all noetherian rings)\n\n* `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same\n  cardinality.\n\nFor vector spaces (i.e. modules over a field), we have\n\n* `dim_quotient_add_dim`: if `V₁` is a submodule of `V`, then\n  `module.rank (V/V₁) + module.rank V₁ = module.rank V`.\n* `dim_range_add_dim_ker`: the rank-nullity theorem.\n\n## Implementation notes\n\nThere is a naming discrepancy: most of the theorem names refer to `dim`,\neven though the definition is of `module.rank`.\nThis reflects that `module.rank` was originally called `dim`, and only defined for vector spaces.\n\nMany theorems in this file are not universe-generic when they relate dimensions\nin different universes. They should be as general as they can be without\ninserting `lift`s. The types `V`, `V'`, ... all live in different universes,\nand `V₁`, `V₂`, ... all live in the same universe.\n-/\n\nnoncomputable theory\n\nuniverses u v v' v'' u₁' w w'\n\nvariables {K : Type u} {V V₁ V₂ V₃ : Type v} {V' V'₁ : Type v'} {V'' : Type v''}\nvariables {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*}\n\nopen_locale classical big_operators cardinal\n\nopen basis submodule function set\n\nsection module\n\nsection\nvariables [semiring K] [add_comm_monoid V] [module K V]\ninclude K\n\nvariables (K V)\n\n/-- The rank of a module, defined as a term of type `cardinal`.\n\nWe define this as the supremum of the cardinalities of linearly independent subsets.\n\nFor a free module over any ring satisfying the strong rank condition\n(e.g. left-noetherian rings, commutative rings, and in particular division rings and fields),\nthis is the same as the dimension of the space (i.e. the cardinality of any basis).\n\nIn particular this agrees with the usual notion of the dimension of a vector space.\n\nThe definition is marked as protected to avoid conflicts with `_root_.rank`,\nthe rank of a linear map.\n-/\n@[irreducible] protected def module.rank : cardinal :=\n⨆ ι : {s : set V // linear_independent K (coe : s → V)}, #ι.1\n\nend\n\nsection\nvariables {R : Type u} [ring R]\nvariables {M : Type v} [add_comm_group M] [module R M]\nvariables {M' : Type v'} [add_comm_group M'] [module R M']\nvariables {M₁ : Type v} [add_comm_group M₁] [module R M₁]\n\ntheorem linear_map.lift_dim_le_of_injective (f : M →ₗ[R] M') (i : injective f) :\n  cardinal.lift.{v'} (module.rank R M) ≤ cardinal.lift.{v} (module.rank R M') :=\nbegin\n  dsimp [module.rank],\n  rw [cardinal.lift_supr (cardinal.bdd_above_range.{v' v'} _),\n    cardinal.lift_supr (cardinal.bdd_above_range.{v v} _)],\n  apply csupr_mono' (cardinal.bdd_above_range.{v' v} _),\n  rintro ⟨s, li⟩,\n  refine ⟨⟨f '' s, _⟩, cardinal.lift_mk_le'.mpr ⟨(equiv.set.image f s i).to_embedding⟩⟩,\n  exact (li.map' _ $ linear_map.ker_eq_bot.mpr i).image,\nend\n\ntheorem linear_map.dim_le_of_injective (f : M →ₗ[R] M₁) (i : injective f) :\n  module.rank R M ≤ module.rank R M₁ :=\ncardinal.lift_le.1 (f.lift_dim_le_of_injective i)\n\ntheorem dim_le {n : ℕ}\n  (H : ∀ s : finset M, linear_independent R (λ i : s, (i : M)) → s.card ≤ n) :\n  module.rank R M ≤ n :=\nbegin\n  rw module.rank,\n  apply csupr_le',\n  rintro ⟨s, li⟩,\n  exact linear_independent_bounded_of_finset_linear_independent_bounded H _ li,\nend\n\nlemma lift_dim_range_le (f : M →ₗ[R] M') :\n  cardinal.lift.{v} (module.rank R f.range) ≤ cardinal.lift.{v'} (module.rank R M) :=\nbegin\n  dsimp [module.rank],\n  rw [cardinal.lift_supr (cardinal.bdd_above_range.{v' v'} _)],\n  apply csupr_le',\n  rintro ⟨s, li⟩,\n  apply le_trans,\n  swap 2,\n  apply cardinal.lift_le.mpr,\n  refine (le_csupr (cardinal.bdd_above_range.{v v} _) ⟨range_splitting f '' s, _⟩),\n  { apply linear_independent.of_comp f.range_restrict,\n    convert li.comp (equiv.set.range_splitting_image_equiv f s) (equiv.injective _) using 1, },\n  { exact (cardinal.lift_mk_eq'.mpr ⟨equiv.set.range_splitting_image_equiv f s⟩).ge, },\nend\n\nlemma dim_range_le (f : M →ₗ[R] M₁) : module.rank R f.range ≤ module.rank R M :=\nby simpa using lift_dim_range_le f\n\nlemma lift_dim_map_le (f : M →ₗ[R] M') (p : submodule R M) :\n  cardinal.lift.{v} (module.rank R (p.map f)) ≤ cardinal.lift.{v'} (module.rank R p) :=\nbegin\n  have h := lift_dim_range_le (f.comp (submodule.subtype p)),\n  rwa [linear_map.range_comp, range_subtype] at h,\nend\n\nlemma dim_map_le (f : M →ₗ[R] M₁) (p : submodule R M) : module.rank R (p.map f) ≤ module.rank R p :=\nby simpa using lift_dim_map_le f p\n\nlemma dim_le_of_submodule (s t : submodule R M) (h : s ≤ t) :\n  module.rank R s ≤ module.rank R t :=\n(of_le h).dim_le_of_injective $ assume ⟨x, hx⟩ ⟨y, hy⟩ eq,\n  subtype.eq $ show x = y, from subtype.ext_iff_val.1 eq\n\n/-- Two linearly equivalent vector spaces have the same dimension, a version with different\nuniverses. -/\ntheorem linear_equiv.lift_dim_eq (f : M ≃ₗ[R] M') :\n  cardinal.lift.{v'} (module.rank R M) = cardinal.lift.{v} (module.rank R M') :=\nbegin\n  apply le_antisymm,\n  { exact f.to_linear_map.lift_dim_le_of_injective f.injective, },\n  { exact f.symm.to_linear_map.lift_dim_le_of_injective f.symm.injective, },\nend\n\n/-- Two linearly equivalent vector spaces have the same dimension. -/\ntheorem linear_equiv.dim_eq (f : M ≃ₗ[R] M₁) :\n  module.rank R M = module.rank R M₁ :=\ncardinal.lift_inj.1 f.lift_dim_eq\n\nlemma dim_eq_of_injective (f : M →ₗ[R] M₁) (h : injective f) :\n  module.rank R M = module.rank R f.range :=\n(linear_equiv.of_injective f h).dim_eq\n\n/-- Pushforwards of submodules along a `linear_equiv` have the same dimension. -/\nlemma linear_equiv.dim_map_eq (f : M ≃ₗ[R] M₁) (p : submodule R M) :\n  module.rank R (p.map (f : M →ₗ[R] M₁)) = module.rank R p :=\n(f.submodule_map p).dim_eq.symm\n\nvariables (R M)\n\n@[simp] lemma dim_top : module.rank R (⊤ : submodule R M) = module.rank R M :=\nbegin\n  have : (⊤ : submodule R M) ≃ₗ[R] M := linear_equiv.of_top ⊤ rfl,\n  rw this.dim_eq,\nend\n\nvariables {R M}\n\nlemma dim_range_of_surjective (f : M →ₗ[R] M') (h : surjective f) :\n  module.rank R f.range = module.rank R M' :=\nby rw [linear_map.range_eq_top.2 h, dim_top]\n\nlemma dim_submodule_le (s : submodule R M) : module.rank R s ≤ module.rank R M :=\nbegin\n  rw ←dim_top R M,\n  exact dim_le_of_submodule _ _ le_top,\nend\n\nlemma linear_map.dim_le_of_surjective (f : M →ₗ[R] M₁) (h : surjective f) :\n  module.rank R M₁ ≤ module.rank R M :=\nbegin\n  rw ←dim_range_of_surjective f h,\n  apply dim_range_le,\nend\n\ntheorem dim_quotient_le (p : submodule R M) :\n  module.rank R (M ⧸ p) ≤ module.rank R M :=\n(mkq p).dim_le_of_surjective (surjective_quot_mk _)\n\nvariables [nontrivial R]\n\nlemma {m} cardinal_lift_le_dim_of_linear_independent\n  {ι : Type w} {v : ι → M} (hv : linear_independent R v) :\n  cardinal.lift.{max v m} (#ι) ≤ cardinal.lift.{max w m} (module.rank R M) :=\nbegin\n  apply le_trans,\n  { exact cardinal.lift_mk_le.mpr\n      ⟨(equiv.of_injective _ hv.injective).to_embedding⟩, },\n  { simp only [cardinal.lift_le, module.rank],\n    apply le_trans,\n    swap,\n    exact le_csupr (cardinal.bdd_above_range.{v v} _) ⟨range v, hv.coe_range⟩,\n    exact le_rfl, },\nend\n\nlemma cardinal_lift_le_dim_of_linear_independent'\n  {ι : Type w} {v : ι → M} (hv : linear_independent R v) :\n  cardinal.lift.{v} (#ι) ≤ cardinal.lift.{w} (module.rank R M) :=\ncardinal_lift_le_dim_of_linear_independent.{u v w 0} hv\n\nlemma cardinal_le_dim_of_linear_independent\n  {ι : Type v} {v : ι → M} (hv : linear_independent R v) :\n  #ι ≤ module.rank R M :=\nby simpa using cardinal_lift_le_dim_of_linear_independent hv\n\nlemma cardinal_le_dim_of_linear_independent'\n  {s : set M} (hs : linear_independent R (λ x, x : s → M)) :\n  #s ≤ module.rank R M :=\ncardinal_le_dim_of_linear_independent hs\n\nvariables (R M)\n\n@[simp] lemma dim_punit : module.rank R punit = 0 :=\nbegin\n  apply le_bot_iff.mp,\n  rw module.rank,\n  apply csupr_le',\n  rintro ⟨s, li⟩,\n  apply le_bot_iff.mpr,\n  apply cardinal.mk_emptyc_iff.mpr,\n  simp only [subtype.coe_mk],\n  by_contradiction h,\n  obtain ⟨a, ha⟩ := nonempty_iff_ne_empty.2 h,\n  simpa using linear_independent.ne_zero (⟨a, ha⟩ : s) li,\nend\n\n@[simp] lemma dim_bot : module.rank R (⊥ : submodule R M) = 0 :=\nbegin\n  have : (⊥ : submodule R M) ≃ₗ[R] punit := bot_equiv_punit,\n  rw [this.dim_eq, dim_punit],\nend\n\nvariables {R M}\n\n/-- A linearly-independent family of vectors in a module over a non-trivial ring must be finite if\nthe module is Noetherian. -/\nlemma linear_independent.finite_of_is_noetherian [is_noetherian R M]\n  {v : ι → M} (hv : linear_independent R v) : finite ι :=\nbegin\n  have hwf := is_noetherian_iff_well_founded.mp (by apply_instance : is_noetherian R M),\n  refine complete_lattice.well_founded.finite_of_independent hwf\n    hv.independent_span_singleton (λ i contra, _),\n  apply hv.ne_zero i,\n  have : v i ∈ R ∙ v i := submodule.mem_span_singleton_self (v i),\n  rwa [contra, submodule.mem_bot] at this,\nend\n\nlemma linear_independent.set_finite_of_is_noetherian [is_noetherian R M]\n  {s : set M} (hi : linear_independent R (coe : s → M)) : s.finite :=\n@set.to_finite _ _ hi.finite_of_is_noetherian\n\n/--\nOver any nontrivial ring, the existence of a finite spanning set implies that any basis is finite.\n-/\n-- One might hope that a finite spanning set implies that any linearly independent set is finite.\n-- While this is true over a division ring\n-- (simply because any linearly independent set can be extended to a basis),\n-- I'm not certain what more general statements are possible.\ndef basis_fintype_of_finite_spans (w : set M) [fintype w] (s : span R w = ⊤)\n  {ι : Type w} (b : basis ι R M) : fintype ι :=\nbegin\n  -- We'll work by contradiction, assuming `ι` is infinite.\n  apply fintype_of_not_infinite _,\n  introI i,\n  -- Let `S` be the union of the supports of `x ∈ w` expressed as linear combinations of `b`.\n  -- This is a finite set since `w` is finite.\n  let S : finset ι := finset.univ.sup (λ x : w, (b.repr x).support),\n  let bS : set M := b '' S,\n  have h : ∀ x ∈ w, x ∈ span R bS,\n  { intros x m,\n    rw [←b.total_repr x, finsupp.span_image_eq_map_total, submodule.mem_map],\n    use b.repr x,\n    simp only [and_true, eq_self_iff_true, finsupp.mem_supported],\n    change (b.repr x).support ≤ S,\n    convert (finset.le_sup (by simp : (⟨x, m⟩ : w) ∈ finset.univ)),\n    refl, },\n  -- Thus this finite subset of the basis elements spans the entire module.\n  have k : span R bS = ⊤ := eq_top_iff.2 (le_trans s.ge (span_le.2 h)),\n\n  -- Now there is some `x : ι` not in `S`, since `ι` is infinite.\n  obtain ⟨x, nm⟩ := infinite.exists_not_mem_finset S,\n  -- However it must be in the span of the finite subset,\n  have k' : b x ∈ span R bS, { rw k, exact mem_top, },\n  -- giving the desire contradiction.\n  refine b.linear_independent.not_mem_span_image _ k',\n  exact nm,\nend\n\n/--\nOver any ring `R`, if `b` is a basis for a module `M`,\nand `s` is a maximal linearly independent set,\nthen the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.\n-/\n-- From [Les familles libres maximales d'un module ont-elles le meme cardinal?][lazarus1973]\nlemma union_support_maximal_linear_independent_eq_range_basis\n  {ι : Type w} (b : basis ι R M)\n  {κ : Type w'} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  (⋃ k, ((b.repr (v k)).support : set ι)) = univ :=\nbegin\n  -- If that's not the case,\n  by_contradiction h,\n  simp only [←ne.def, ne_univ_iff_exists_not_mem, mem_Union, not_exists_not,\n    finsupp.mem_support_iff, finset.mem_coe] at h,\n  -- We have some basis element `b b'` which is not in the support of any of the `v i`.\n  obtain ⟨b', w⟩ := h,\n  -- Using this, we'll construct a linearly independent family strictly larger than `v`,\n  -- by also using this `b b'`.\n  let v' : option κ → M := λ o, o.elim (b b') v,\n  have r : range v ⊆ range v',\n  { rintro - ⟨k, rfl⟩,\n    use some k,\n    refl, },\n  have r' : b b' ∉ range v,\n  { rintro ⟨k, p⟩,\n    simpa [w] using congr_arg (λ m, (b.repr m) b') p, },\n  have r'' : range v ≠ range v',\n  { intro e,\n    have p : b b' ∈ range v', { use none, refl, },\n    rw ←e at p,\n    exact r' p, },\n  have inj' : injective v',\n  { rintros (_|k) (_|k) z,\n    { refl, },\n    { exfalso, exact r' ⟨k, z.symm⟩, },\n    { exfalso, exact r' ⟨k, z⟩, },\n    { congr, exact i.injective z, }, },\n  -- The key step in the proof is checking that this strictly larger family is linearly independent.\n  have i' : linear_independent R (coe : range v' → M),\n  { rw [linear_independent_subtype_range inj', linear_independent_iff],\n    intros l z,\n    rw [finsupp.total_option] at z,\n    simp only [v', option.elim] at z,\n    change _ + finsupp.total κ M R v l.some = 0 at z,\n    -- We have some linear combination of `b b'` and the `v i`, which we want to show is trivial.\n    -- We'll first show the coefficient of `b b'` is zero,\n    -- by expressing the `v i` in the basis `b`, and using that the `v i` have no `b b'` term.\n    have l₀ : l none = 0,\n    { rw ←eq_neg_iff_add_eq_zero at z,\n      replace z := neg_eq_iff_eq_neg.mpr z,\n      apply_fun (λ x, b.repr x b') at z,\n      simp only [repr_self, linear_equiv.map_smul, mul_one, finsupp.single_eq_same, pi.neg_apply,\n        finsupp.smul_single', linear_equiv.map_neg, finsupp.coe_neg] at z,\n      erw finsupp.congr_fun (finsupp.apply_total R (b.repr : M →ₗ[R] ι →₀ R) v l.some) b' at z,\n      simpa [finsupp.total_apply, w] using z, },\n    -- Then all the other coefficients are zero, because `v` is linear independent.\n    have l₁ : l.some = 0,\n    { rw [l₀, zero_smul, zero_add] at z,\n      exact linear_independent_iff.mp i _ z, },\n    -- Finally we put those facts together to show the linear combination is trivial.\n    ext (_|a),\n    { simp only [l₀, finsupp.coe_zero, pi.zero_apply], },\n    { erw finsupp.congr_fun l₁ a,\n      simp only [finsupp.coe_zero, pi.zero_apply], }, },\n  dsimp [linear_independent.maximal] at m,\n  specialize m (range v') i' r,\n  exact r'' m,\nend\n\n/--\nOver any ring `R`, if `b` is an infinite basis for a module `M`,\nand `s` is a maximal linearly independent set,\nthen the cardinality of `b` is bounded by the cardinality of `s`.\n-/\nlemma infinite_basis_le_maximal_linear_independent'\n  {ι : Type w} (b : basis ι R M) [infinite ι]\n  {κ : Type w'} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  cardinal.lift.{w'} (#ι) ≤ cardinal.lift.{w} (#κ) :=\nbegin\n  let Φ := λ k : κ, (b.repr (v k)).support,\n  have w₁ : #ι ≤ #(set.range Φ),\n  { apply cardinal.le_range_of_union_finset_eq_top,\n    exact union_support_maximal_linear_independent_eq_range_basis b v i m, },\n  have w₂ :\n    cardinal.lift.{w'} (#(set.range Φ)) ≤ cardinal.lift.{w} (#κ) :=\n    cardinal.mk_range_le_lift,\n  exact (cardinal.lift_le.mpr w₁).trans w₂,\nend\n\n/--\nOver any ring `R`, if `b` is an infinite basis for a module `M`,\nand `s` is a maximal linearly independent set,\nthen the cardinality of `b` is bounded by the cardinality of `s`.\n-/\n-- (See `infinite_basis_le_maximal_linear_independent'` for the more general version\n-- where the index types can live in different universes.)\nlemma infinite_basis_le_maximal_linear_independent\n  {ι : Type w} (b : basis ι R M) [infinite ι]\n  {κ : Type w} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  #ι ≤ #κ :=\ncardinal.lift_le.mp (infinite_basis_le_maximal_linear_independent' b v i m)\n\nlemma complete_lattice.independent.subtype_ne_bot_le_rank [no_zero_smul_divisors R M]\n  {V : ι → submodule R M} (hV : complete_lattice.independent V) :\n  cardinal.lift.{v} (#{i : ι // V i ≠ ⊥}) ≤ cardinal.lift.{w} (module.rank R M) :=\nbegin\n  set I := {i : ι // V i ≠ ⊥},\n  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0:M),\n  { intros i,\n    rw ← submodule.ne_bot_iff,\n    exact i.prop },\n  choose v hvV hv using hI,\n  have : linear_independent R v,\n  { exact (hV.comp subtype.coe_injective).linear_independent _ hvV hv },\n  exact cardinal_lift_le_dim_of_linear_independent' this\nend\n\nend\n\nsection rank_zero\n\nvariables {R : Type u} {M : Type v}\nvariables [ring R] [nontrivial R] [add_comm_group M] [module R M] [no_zero_smul_divisors R M]\n\nlemma dim_zero_iff_forall_zero : module.rank R M = 0 ↔ ∀ x : M, x = 0 :=\nbegin\n  refine ⟨λ h, _, λ h, _⟩,\n  { contrapose! h,\n    obtain ⟨x, hx⟩ := h,\n    suffices : 1 ≤ module.rank R M,\n    { intro h, exact this.not_lt (h.symm ▸ zero_lt_one) },\n    suffices : linear_independent R (λ (y : ({x} : set M)), ↑y),\n    { simpa using (cardinal_le_dim_of_linear_independent this), },\n    exact linear_independent_singleton hx },\n  { have : (⊤ : submodule R M) = ⊥,\n    { ext x, simp [h x] },\n    rw [←dim_top, this, dim_bot] }\nend\n\nlemma dim_zero_iff : module.rank R M = 0 ↔ subsingleton M :=\ndim_zero_iff_forall_zero.trans (subsingleton_iff_forall_eq 0).symm\n\nlemma dim_pos_iff_exists_ne_zero : 0 < module.rank R M ↔ ∃ x : M, x ≠ 0 :=\nbegin\n  rw ←not_iff_not,\n  simpa using dim_zero_iff_forall_zero\nend\n\nlemma dim_pos_iff_nontrivial : 0 < module.rank R M ↔ nontrivial M :=\ndim_pos_iff_exists_ne_zero.trans (nontrivial_iff_exists_ne 0).symm\n\nlemma dim_pos [h : nontrivial M] : 0 < module.rank R M :=\ndim_pos_iff_nontrivial.2 h\n\nend rank_zero\n\nsection invariant_basis_number\n\nvariables {R : Type u} [ring R] [invariant_basis_number R]\nvariables {M : Type v} [add_comm_group M] [module R M]\n\n/-- The dimension theorem: if `v` and `v'` are two bases, their index types\nhave the same cardinalities. -/\ntheorem mk_eq_mk_of_basis (v : basis ι R M) (v' : basis ι' R M) :\n  cardinal.lift.{w'} (#ι) = cardinal.lift.{w} (#ι') :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  casesI fintype_or_infinite ι,\n  { -- `v` is a finite basis, so by `basis_fintype_of_finite_spans` so is `v'`.\n    haveI : fintype (range v) := set.fintype_range v,\n    haveI := basis_fintype_of_finite_spans _ v.span_eq v',\n    -- We clean up a little:\n    rw [cardinal.mk_fintype, cardinal.mk_fintype],\n    simp only [cardinal.lift_nat_cast, cardinal.nat_cast_inj],\n    -- Now we can use invariant basis number to show they have the same cardinality.\n    apply card_eq_of_lequiv R,\n    exact (((finsupp.linear_equiv_fun_on_finite R R ι).symm.trans v.repr.symm) ≪≫ₗ\n      v'.repr) ≪≫ₗ (finsupp.linear_equiv_fun_on_finite R R ι'), },\n  { -- `v` is an infinite basis,\n    -- so by `infinite_basis_le_maximal_linear_independent`, `v'` is at least as big,\n    -- and then applying `infinite_basis_le_maximal_linear_independent` again\n    -- we see they have the same cardinality.\n    have w₁ :=\n      infinite_basis_le_maximal_linear_independent' v _ v'.linear_independent v'.maximal,\n    rcases cardinal.lift_mk_le'.mp w₁ with ⟨f⟩,\n    haveI : infinite ι' := infinite.of_injective f f.2,\n    have w₂ :=\n      infinite_basis_le_maximal_linear_independent' v' _ v.linear_independent v.maximal,\n    exact le_antisymm w₁ w₂, }\nend\n\n/-- Given two bases indexed by `ι` and `ι'` of an `R`-module, where `R` satisfies the invariant\nbasis number property, an equiv `ι ≃ ι' `. -/\ndef basis.index_equiv (v : basis ι R M) (v' : basis ι' R M) : ι ≃ ι' :=\nnonempty.some (cardinal.lift_mk_eq.1 (cardinal.lift_umax_eq.2 (mk_eq_mk_of_basis v v')))\n\ntheorem mk_eq_mk_of_basis' {ι' : Type w} (v : basis ι R M) (v' : basis ι' R M) :\n  #ι = #ι' :=\ncardinal.lift_inj.1 $ mk_eq_mk_of_basis v v'\n\nend invariant_basis_number\n\nsection rank_condition\n\nvariables {R : Type u} [ring R] [rank_condition R]\nvariables {M : Type v} [add_comm_group M] [module R M]\n\n/--\nAn auxiliary lemma for `basis.le_span`.\n\nIf `R` satisfies the rank condition,\nthen for any finite basis `b : basis ι R M`,\nand any finite spanning set `w : set M`,\nthe cardinality of `ι` is bounded by the cardinality of `w`.\n-/\nlemma basis.le_span'' {ι : Type*} [fintype ι] (b : basis ι R M)\n  {w : set M} [fintype w] (s : span R w = ⊤) :\n  fintype.card ι ≤ fintype.card w :=\nbegin\n  -- We construct an surjective linear map `(w → R) →ₗ[R] (ι → R)`,\n  -- by expressing a linear combination in `w` as a linear combination in `ι`.\n  fapply card_le_of_surjective' R,\n  { exact b.repr.to_linear_map.comp (finsupp.total w M R coe), },\n  { apply surjective.comp,\n   apply linear_equiv.surjective,\n   rw [←linear_map.range_eq_top, finsupp.range_total],\n   simpa using s, },\nend\n\n/--\nAnother auxiliary lemma for `basis.le_span`, which does not require assuming the basis is finite,\nbut still assumes we have a finite spanning set.\n-/\nlemma basis_le_span' {ι : Type*} (b : basis ι R M)\n  {w : set M} [fintype w] (s : span R w = ⊤) :\n  #ι ≤ fintype.card w :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  haveI := basis_fintype_of_finite_spans w s b,\n  rw cardinal.mk_fintype ι,\n  simp only [cardinal.nat_cast_le],\n  exact basis.le_span'' b s,\nend\n\n/--\nIf `R` satisfies the rank condition,\nthen the cardinality of any basis is bounded by the cardinality of any spanning set.\n-/\n-- Note that if `R` satisfies the strong rank condition,\n-- this also follows from `linear_independent_le_span` below.\ntheorem basis.le_span {J : set M} (v : basis ι R M)\n   (hJ : span R J = ⊤) : #(range v) ≤ #J :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  casesI fintype_or_infinite J,\n  { rw [←cardinal.lift_le, cardinal.mk_range_eq_of_injective v.injective, cardinal.mk_fintype J],\n    convert cardinal.lift_le.{w v}.2 (basis_le_span' v hJ),\n    simp, },\n  { have := cardinal.mk_range_eq_of_injective v.injective,\n    let S : J → set ι := λ j, ↑(v.repr j).support,\n    let S' : J → set M := λ j, v '' S j,\n    have hs : range v ⊆ ⋃ j, S' j,\n    { intros b hb,\n      rcases mem_range.1 hb with ⟨i, hi⟩,\n      have : span R J ≤ comap v.repr.to_linear_map (finsupp.supported R R (⋃ j, S j)) :=\n        span_le.2 (λ j hj x hx, ⟨_, ⟨⟨j, hj⟩, rfl⟩, hx⟩),\n      rw hJ at this,\n      replace : v.repr (v i) ∈ (finsupp.supported R R (⋃ j, S j)) := this trivial,\n      rw [v.repr_self, finsupp.mem_supported,\n        finsupp.support_single_ne_zero _ one_ne_zero] at this,\n      { subst b,\n        rcases mem_Union.1 (this (finset.mem_singleton_self _)) with ⟨j, hj⟩,\n        exact mem_Union.2 ⟨j, (mem_image _ _ _).2 ⟨i, hj, rfl⟩⟩ },\n      { apply_instance } },\n    refine le_of_not_lt (λ IJ, _),\n    suffices : #(⋃ j, S' j) < #(range v),\n    { exact not_le_of_lt this ⟨set.embedding_of_subset _ _ hs⟩ },\n    refine lt_of_le_of_lt (le_trans cardinal.mk_Union_le_sum_mk\n      (cardinal.sum_le_sum _ (λ _, ℵ₀) _)) _,\n    { exact λ j, (cardinal.lt_aleph_0_of_finite _).le },\n    { simpa } },\nend\n\nend rank_condition\n\nsection strong_rank_condition\n\nvariables {R : Type u} [ring R] [strong_rank_condition R]\nvariables {M : Type v} [add_comm_group M] [module R M]\n\nopen submodule\n\n-- An auxiliary lemma for `linear_independent_le_span'`,\n-- with the additional assumption that the linearly independent family is finite.\nlemma linear_independent_le_span_aux'\n  {ι : Type*} [fintype ι] (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v ≤ span R w) :\n  fintype.card ι ≤ fintype.card w :=\nbegin\n  -- We construct an injective linear map `(ι → R) →ₗ[R] (w → R)`,\n  -- by thinking of `f : ι → R` as a linear combination of the finite family `v`,\n  -- and expressing that (using the axiom of choice) as a linear combination over `w`.\n  -- We can do this linearly by constructing the map on a basis.\n  fapply card_le_of_injective' R,\n  { apply finsupp.total,\n    exact λ i, span.repr R w ⟨v i, s (mem_range_self i)⟩, },\n  { intros f g h,\n    apply_fun finsupp.total w M R coe at h,\n    simp only [finsupp.total_total, submodule.coe_mk, span.finsupp_total_repr] at h,\n    rw [←sub_eq_zero, ←linear_map.map_sub] at h,\n    exact sub_eq_zero.mp (linear_independent_iff.mp i _ h), },\nend\n\n/--\nIf `R` satisfies the strong rank condition,\nthen any linearly independent family `v : ι → M`\ncontained in the span of some finite `w : set M`,\nis itself finite.\n-/\ndef linear_independent_fintype_of_le_span_fintype\n  {ι : Type*} (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v ≤ span R w) : fintype ι :=\nfintype_of_finset_card_le (fintype.card w) (λ t, begin\n  let v' := λ x : (t : set ι), v x,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have s' : range v' ≤ span R w := (range_comp_subset_range _ _).trans s,\n  simpa using linear_independent_le_span_aux' v' i' w s',\nend)\n\n/--\nIf `R` satisfies the strong rank condition,\nthen for any linearly independent family `v : ι → M`\ncontained in the span of some finite `w : set M`,\nthe cardinality of `ι` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span' {ι : Type*} (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v ≤ span R w) :\n  #ι ≤ fintype.card w :=\nbegin\n  haveI : fintype ι := linear_independent_fintype_of_le_span_fintype v i w s,\n  rw cardinal.mk_fintype,\n  simp only [cardinal.nat_cast_le],\n  exact linear_independent_le_span_aux' v i w s,\nend\n\n/--\nIf `R` satisfies the strong rank condition,\nthen for any linearly independent family `v : ι → M`\nand any finite spanning set `w : set M`,\nthe cardinality of `ι` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span {ι : Type*} (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : span R w = ⊤) :\n  #ι ≤ fintype.card w :=\nbegin\n  apply linear_independent_le_span' v i w,\n  rw s,\n  exact le_top,\nend\n\n/--\nAn auxiliary lemma for `linear_independent_le_basis`:\nwe handle the case where the basis `b` is infinite.\n-/\nlemma linear_independent_le_infinite_basis\n  {ι : Type*} (b : basis ι R M) [infinite ι]\n  {κ : Type*} (v : κ → M) (i : linear_independent R v) :\n  #κ ≤ #ι :=\nbegin\n  by_contradiction,\n  rw [not_le, ← cardinal.mk_finset_of_infinite ι] at h,\n  let Φ := λ k : κ, (b.repr (v k)).support,\n  obtain ⟨s, w : infinite ↥(Φ ⁻¹' {s})⟩ := cardinal.exists_infinite_fiber Φ h (by apply_instance),\n  let v' := λ k : Φ ⁻¹' {s}, v k,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have w' : fintype (Φ ⁻¹' {s}),\n  { apply linear_independent_fintype_of_le_span_fintype v' i' (s.image b),\n    rintros m ⟨⟨p,⟨rfl⟩⟩,rfl⟩,\n    simp only [set_like.mem_coe, subtype.coe_mk, finset.coe_image],\n    apply basis.mem_span_repr_support, },\n  exactI w.false,\nend\n\n/--\nOver any ring `R` satisfying the strong rank condition,\nif `b` is a basis for a module `M`,\nand `s` is a linearly independent set,\nthen the cardinality of `s` is bounded by the cardinality of `b`.\n-/\nlemma linear_independent_le_basis\n  {ι : Type*} (b : basis ι R M)\n  {κ : Type*} (v : κ → M) (i : linear_independent R v) :\n  #κ ≤ #ι :=\nbegin\n  -- We split into cases depending on whether `ι` is infinite.\n  cases fintype_or_infinite ι; resetI,\n  { -- When `ι` is finite, we have `linear_independent_le_span`,\n    rw cardinal.mk_fintype ι,\n    haveI : nontrivial R := nontrivial_of_invariant_basis_number R,\n    rw fintype.card_congr (equiv.of_injective b b.injective),\n    exact linear_independent_le_span v i (range b) b.span_eq, },\n  { -- and otherwise we have `linear_indepedent_le_infinite_basis`.\n    exact linear_independent_le_infinite_basis b v i, },\nend\n\n/-- In an `n`-dimensional space, the rank is at most `m`. -/\nlemma basis.card_le_card_of_linear_independent_aux\n  {R : Type*} [ring R] [strong_rank_condition R]\n  (n : ℕ) {m : ℕ} (v : fin m → fin n → R) :\n  linear_independent R v → m ≤ n :=\nλ h, by simpa using (linear_independent_le_basis (pi.basis_fun R (fin n)) v h)\n\n/--\nOver any ring `R` satisfying the strong rank condition,\nif `b` is an infinite basis for a module `M`,\nthen every maximal linearly independent set has the same cardinality as `b`.\n\nThis proof (along with some of the lemmas above) comes from\n[Les familles libres maximales d'un module ont-elles le meme cardinal?][lazarus1973]\n-/\n-- When the basis is not infinite this need not be true!\nlemma maximal_linear_independent_eq_infinite_basis\n  {ι : Type*} (b : basis ι R M) [infinite ι]\n  {κ : Type*} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  #κ = #ι :=\nbegin\n  apply le_antisymm,\n  { exact linear_independent_le_basis b v i, },\n  { haveI : nontrivial R := nontrivial_of_invariant_basis_number R,\n    exact infinite_basis_le_maximal_linear_independent b v i m, }\nend\n\ntheorem basis.mk_eq_dim'' {ι : Type v} (v : basis ι R M) :\n  #ι = module.rank R M :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw module.rank,\n  apply le_antisymm,\n  { transitivity,\n    swap,\n    apply le_csupr (cardinal.bdd_above_range.{v v} _),\n    exact ⟨set.range v, by { convert v.reindex_range.linear_independent, ext, simp }⟩,\n    exact (cardinal.mk_range_eq v v.injective).ge, },\n  { apply csupr_le',\n    rintro ⟨s, li⟩,\n    apply linear_independent_le_basis v _ li, },\nend\n\ntheorem basis.mk_range_eq_dim (v : basis ι R M) :\n  #(range v) = module.rank R M :=\nv.reindex_range.mk_eq_dim''\n\n/-- If a vector space has a finite basis, then its dimension (seen as a cardinal) is equal to the\ncardinality of the basis. -/\nlemma dim_eq_card_basis {ι : Type w} [fintype ι] (h : basis ι R M) :\n  module.rank R M = fintype.card ι :=\nby {haveI := nontrivial_of_invariant_basis_number R,\n  rw [←h.mk_range_eq_dim, cardinal.mk_fintype, set.card_range_of_injective h.injective] }\n\nlemma basis.card_le_card_of_linear_independent {ι : Type*} [fintype ι]\n  (b : basis ι R M) {ι' : Type*} [fintype ι'] {v : ι' → M} (hv : linear_independent R v) :\n  fintype.card ι' ≤ fintype.card ι :=\nbegin\n  letI := nontrivial_of_invariant_basis_number R,\n  simpa [dim_eq_card_basis b, cardinal.mk_fintype] using\n    cardinal_lift_le_dim_of_linear_independent' hv\nend\n\nlemma basis.card_le_card_of_submodule (N : submodule R M) [fintype ι] (b : basis ι R M)\n  [fintype ι'] (b' : basis ι' R N) : fintype.card ι' ≤ fintype.card ι :=\nb.card_le_card_of_linear_independent (b'.linear_independent.map' N.subtype N.ker_subtype)\n\nlemma basis.card_le_card_of_le\n  {N O : submodule R M} (hNO : N ≤ O) [fintype ι] (b : basis ι R O) [fintype ι']\n  (b' : basis ι' R N) : fintype.card ι' ≤ fintype.card ι :=\nb.card_le_card_of_linear_independent\n  (b'.linear_independent.map' (submodule.of_le hNO) (N.ker_of_le O _))\n\ntheorem basis.mk_eq_dim (v : basis ι R M) :\n  cardinal.lift.{v} (#ι) = cardinal.lift.{w} (module.rank R M) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [←v.mk_range_eq_dim, cardinal.mk_range_eq_of_injective v.injective]\nend\n\ntheorem {m} basis.mk_eq_dim' (v : basis ι R M) :\n  cardinal.lift.{max v m} (#ι) = cardinal.lift.{max w m} (module.rank R M) :=\nby simpa using v.mk_eq_dim\n\n/-- If a module has a finite dimension, all bases are indexed by a finite type. -/\nlemma basis.nonempty_fintype_index_of_dim_lt_aleph_0 {ι : Type*}\n  (b : basis ι R M) (h : module.rank R M < ℵ₀) :\n  nonempty (fintype ι) :=\nby rwa [← cardinal.lift_lt, ← b.mk_eq_dim,\n        -- ensure `aleph_0` has the correct universe\n        cardinal.lift_aleph_0, ← cardinal.lift_aleph_0.{u_1 v},\n        cardinal.lift_lt, cardinal.lt_aleph_0_iff_fintype] at h\n\n/-- If a module has a finite dimension, all bases are indexed by a finite type. -/\nnoncomputable def basis.fintype_index_of_dim_lt_aleph_0 {ι : Type*}\n  (b : basis ι R M) (h : module.rank R M < ℵ₀) :\n  fintype ι :=\nclassical.choice (b.nonempty_fintype_index_of_dim_lt_aleph_0 h)\n\n/-- If a module has a finite dimension, all bases are indexed by a finite set. -/\nlemma basis.finite_index_of_dim_lt_aleph_0 {ι : Type*} {s : set ι}\n  (b : basis s R M) (h : module.rank R M < ℵ₀) :\n  s.finite :=\nfinite_def.2 (b.nonempty_fintype_index_of_dim_lt_aleph_0 h)\n\nlemma dim_span {v : ι → M} (hv : linear_independent R v) :\n  module.rank R ↥(span R (range v)) = #(range v) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [←cardinal.lift_inj, ← (basis.span hv).mk_eq_dim,\n    cardinal.mk_range_eq_of_injective (@linear_independent.injective ι R M v _ _ _ _ hv)]\nend\n\nlemma dim_span_set {s : set M} (hs : linear_independent R (λ x, x : s → M)) :\n  module.rank R ↥(span R s) = #s :=\nby { rw [← @set_of_mem_eq _ s, ← subtype.range_coe_subtype], exact dim_span hs }\n\n/-- If `N` is a submodule in a free, finitely generated module,\ndo induction on adjoining a linear independent element to a submodule. -/\ndef submodule.induction_on_rank [is_domain R] [fintype ι] (b : basis ι R M)\n  (P : submodule R M → Sort*) (ih : ∀ (N : submodule R M),\n    (∀ (N' ≤ N) (x ∈ N), (∀ (c : R) (y ∈ N'), c • x + y = (0 : M) → c = 0) → P N') →\n    P N)\n  (N : submodule R M) : P N :=\nsubmodule.induction_on_rank_aux b P ih (fintype.card ι) N (λ s hs hli,\n  by simpa using b.card_le_card_of_linear_independent hli)\n\n/-- If `S` a finite-dimensional ring extension of `R` which is free as an `R`-module,\nthen the rank of an ideal `I` of `S` over `R` is the same as the rank of `S`.\n-/\nlemma ideal.rank_eq {R S : Type*} [comm_ring R] [strong_rank_condition R] [ring S] [is_domain S]\n  [algebra R S] {n m : Type*} [fintype n] [fintype m]\n  (b : basis n R S) {I : ideal S} (hI : I ≠ ⊥) (c : basis m R I) :\n  fintype.card m = fintype.card n :=\nbegin\n  obtain ⟨a, ha⟩ := submodule.nonzero_mem_of_bot_lt (bot_lt_iff_ne_bot.mpr hI),\n  have : linear_independent R (λ i, b i • a),\n  { have hb := b.linear_independent,\n    rw fintype.linear_independent_iff at ⊢ hb,\n    intros g hg,\n    apply hb g,\n    simp only [← smul_assoc, ← finset.sum_smul, smul_eq_zero] at hg,\n    exact hg.resolve_right ha },\n  exact le_antisymm\n    (b.card_le_card_of_linear_independent (c.linear_independent.map' (submodule.subtype I)\n      (linear_map.ker_eq_bot.mpr subtype.coe_injective)))\n    (c.card_le_card_of_linear_independent this),\nend\n\nvariables (R)\n\n@[simp] lemma dim_self : module.rank R R = 1 :=\nby rw [←cardinal.lift_inj, ← (basis.singleton punit R).mk_eq_dim, cardinal.mk_punit]\n\nend strong_rank_condition\n\nsection division_ring\nvariables [division_ring K] [add_comm_group V] [module K V] [add_comm_group V₁] [module K V₁]\nvariables {K V}\n\n/-- If a vector space has a finite dimension, the index set of `basis.of_vector_space` is finite. -/\nlemma basis.finite_of_vector_space_index_of_dim_lt_aleph_0 (h : module.rank K V < ℵ₀) :\n  (basis.of_vector_space_index K V).finite :=\nfinite_def.2 $ (basis.of_vector_space K V).nonempty_fintype_index_of_dim_lt_aleph_0 h\n\nvariables [add_comm_group V'] [module K V']\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ntheorem nonempty_linear_equiv_of_lift_dim_eq\n  (cond : cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V')) :\n  nonempty (V ≃ₗ[K] V') :=\nbegin\n  let B := basis.of_vector_space K V,\n  let B' := basis.of_vector_space K V',\n  have : cardinal.lift.{v' v} (#_) = cardinal.lift.{v v'} (#_),\n    by rw [B.mk_eq_dim'', cond, B'.mk_eq_dim''],\n  exact (cardinal.lift_mk_eq.{v v' 0}.1 this).map (B.equiv B')\nend\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ntheorem nonempty_linear_equiv_of_dim_eq (cond : module.rank K V = module.rank K V₁) :\n  nonempty (V ≃ₗ[K] V₁) :=\nnonempty_linear_equiv_of_lift_dim_eq $ congr_arg _ cond\n\nsection\n\nvariables (V V' V₁)\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ndef linear_equiv.of_lift_dim_eq\n  (cond : cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V')) :\n  V ≃ₗ[K] V' :=\nclassical.choice (nonempty_linear_equiv_of_lift_dim_eq cond)\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ndef linear_equiv.of_dim_eq (cond : module.rank K V = module.rank K V₁) : V ≃ₗ[K] V₁ :=\nclassical.choice (nonempty_linear_equiv_of_dim_eq cond)\n\nend\n\n/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/\ntheorem linear_equiv.nonempty_equiv_iff_lift_dim_eq :\n  nonempty (V ≃ₗ[K] V') ↔\n    cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V') :=\n⟨λ ⟨h⟩, linear_equiv.lift_dim_eq h, λ h, nonempty_linear_equiv_of_lift_dim_eq h⟩\n\n/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/\ntheorem linear_equiv.nonempty_equiv_iff_dim_eq :\n  nonempty (V ≃ₗ[K] V₁) ↔ module.rank K V = module.rank K V₁ :=\n⟨λ ⟨h⟩, linear_equiv.dim_eq h, λ h, nonempty_linear_equiv_of_dim_eq h⟩\n\n-- TODO how far can we generalise this?\n-- When `s` is finite, we could prove this for any ring satisfying the strong rank condition\n-- using `linear_independent_le_span'`\nlemma dim_span_le (s : set V) : module.rank K (span K s) ≤ #s :=\nbegin\n  obtain ⟨b, hb, hsab, hlib⟩ := exists_linear_independent K s,\n  convert cardinal.mk_le_mk_of_subset hb,\n  rw [← hsab, dim_span_set hlib]\nend\n\nlemma dim_span_of_finset (s : finset V) :\n  module.rank K (span K (↑s : set V)) < ℵ₀ :=\ncalc module.rank K (span K (↑s : set V)) ≤ #(↑s : set V) : dim_span_le ↑s\n                             ... = s.card : by rw [finset.coe_sort_coe, cardinal.mk_coe_finset]\n                             ... < ℵ₀ : cardinal.nat_lt_aleph_0 _\n\ntheorem dim_prod : module.rank K (V × V₁) = module.rank K V + module.rank K V₁ :=\nbegin\n  let b := basis.of_vector_space K V,\n  let c := basis.of_vector_space K V₁,\n  rw [← cardinal.lift_inj,\n      ← (basis.prod b c).mk_eq_dim,\n      cardinal.lift_add, ← cardinal.mk_ulift,\n      ← b.mk_eq_dim, ← c.mk_eq_dim,\n      ← cardinal.mk_ulift, ← cardinal.mk_ulift,\n      cardinal.add_def (ulift _)],\n  exact cardinal.lift_inj.1 (cardinal.lift_mk_eq.2\n      ⟨equiv.ulift.trans (equiv.sum_congr equiv.ulift equiv.ulift).symm ⟩),\nend\n\nsection fintype\nvariables [∀i, add_comm_group (φ i)] [∀i, module K (φ i)]\n\nopen linear_map\n\nlemma dim_pi [finite η] : module.rank K (Πi, φ i) = cardinal.sum (λi, module.rank K (φ i)) :=\nbegin\n  casesI nonempty_fintype η,\n  let b := assume i, basis.of_vector_space K (φ i),\n  let this : basis (Σ j, _) K (Π j, φ j) := pi.basis b,\n  rw [← cardinal.lift_inj, ← this.mk_eq_dim],\n  simp [← (b _).mk_range_eq_dim]\nend\n\nvariable [fintype η]\n\nlemma dim_fun {V η : Type u} [fintype η] [add_comm_group V] [module K V] :\n  module.rank K (η → V) = fintype.card η * module.rank K V :=\nby rw [dim_pi, cardinal.sum_const', cardinal.mk_fintype]\n\nlemma dim_fun_eq_lift_mul :\n  module.rank K (η → V) = (fintype.card η : cardinal.{max u₁' v}) *\n    cardinal.lift.{u₁'} (module.rank K V) :=\nby rw [dim_pi, cardinal.sum_const, cardinal.mk_fintype, cardinal.lift_nat_cast]\n\nlemma dim_fun' : module.rank K (η → K) = fintype.card η :=\nby rw [dim_fun_eq_lift_mul, dim_self, cardinal.lift_one, mul_one, cardinal.nat_cast_inj]\n\nlemma dim_fin_fun (n : ℕ) : module.rank K (fin n → K) = n :=\nby simp [dim_fun']\n\nend fintype\n\ntheorem dim_quotient_add_dim (p : submodule K V) :\n  module.rank K (V ⧸ p) + module.rank K p = module.rank K V :=\nby classical; exact let ⟨f⟩ := quotient_prod_linear_equiv p in dim_prod.symm.trans f.dim_eq\n\n/-- rank-nullity theorem -/\ntheorem dim_range_add_dim_ker (f : V →ₗ[K] V₁) :\n  module.rank K f.range + module.rank K f.ker = module.rank K V :=\nbegin\n  haveI := λ (p : submodule K V), classical.dec_eq (V ⧸ p),\n  rw [← f.quot_ker_equiv_range.dim_eq, dim_quotient_add_dim]\nend\n\nlemma dim_eq_of_surjective (f : V →ₗ[K] V₁) (h : surjective f) :\n  module.rank K V = module.rank K V₁ + module.rank K f.ker :=\nby rw [← dim_range_add_dim_ker f, ← dim_range_of_surjective f h]\n\nsection\nvariables [add_comm_group V₂] [module K V₂]\nvariables [add_comm_group V₃] [module K V₃]\nopen linear_map\n\n/-- This is mostly an auxiliary lemma for `dim_sup_add_dim_inf_eq`. -/\nlemma dim_add_dim_split\n  (db : V₂ →ₗ[K] V) (eb : V₃ →ₗ[K] V) (cd : V₁ →ₗ[K] V₂) (ce : V₁ →ₗ[K] V₃)\n  (hde : ⊤ ≤ db.range ⊔ eb.range)\n  (hgd : ker cd = ⊥)\n  (eq : db.comp cd = eb.comp ce)\n  (eq₂ : ∀d e, db d = eb e → (∃c, cd c = d ∧ ce c = e)) :\n  module.rank K V + module.rank K V₁ = module.rank K V₂ + module.rank K V₃ :=\nhave hf : surjective (coprod db eb),\nby rwa [←range_eq_top, range_coprod, eq_top_iff],\nbegin\n  conv {to_rhs, rw [← dim_prod, dim_eq_of_surjective _ hf] },\n  congr' 1,\n  apply linear_equiv.dim_eq,\n  refine linear_equiv.of_bijective _ ⟨_, _⟩,\n  { refine cod_restrict _ (prod cd (- ce)) _,\n    { assume c,\n      simp only [add_eq_zero_iff_eq_neg, linear_map.prod_apply, mem_ker, pi.prod,\n        coprod_apply, neg_neg, map_neg, neg_apply],\n      exact linear_map.ext_iff.1 eq c } },\n  { rw [← ker_eq_bot, ker_cod_restrict, ker_prod, hgd, bot_inf_eq] },\n  { rw [← range_eq_top, eq_top_iff, range_cod_restrict, ← map_le_iff_le_comap,\n      submodule.map_top, range_subtype],\n    rintros ⟨d, e⟩,\n    have h := eq₂ d (-e),\n    simp only [add_eq_zero_iff_eq_neg, linear_map.prod_apply, mem_ker, set_like.mem_coe,\n      prod.mk.inj_iff, coprod_apply, map_neg, neg_apply, linear_map.mem_range, pi.prod] at ⊢ h,\n    assume hde,\n    rcases h hde with ⟨c, h₁, h₂⟩,\n    refine ⟨c, h₁, _⟩,\n    rw [h₂, _root_.neg_neg] }\nend\n\nlemma dim_sup_add_dim_inf_eq (s t : submodule K V) :\n  module.rank K (s ⊔ t : submodule K V) + module.rank K (s ⊓ t : submodule K V) =\n    module.rank K s + module.rank K t :=\ndim_add_dim_split (of_le le_sup_left) (of_le le_sup_right) (of_le inf_le_left) (of_le inf_le_right)\n  begin\n    rw [← map_le_map_iff' (ker_subtype $ s ⊔ t), submodule.map_sup, submodule.map_top,\n      ← linear_map.range_comp, ← linear_map.range_comp, subtype_comp_of_le, subtype_comp_of_le,\n      range_subtype, range_subtype, range_subtype],\n    exact le_rfl\n  end\n  (ker_of_le _ _ _)\n  begin ext ⟨x, hx⟩, refl end\n  begin\n    rintros ⟨b₁, hb₁⟩ ⟨b₂, hb₂⟩ eq,\n    obtain rfl : b₁ = b₂ := congr_arg subtype.val eq,\n    exact ⟨⟨b₁, hb₁, hb₂⟩, rfl, rfl⟩\n  end\n\nlemma dim_add_le_dim_add_dim (s t : submodule K V) :\n  module.rank K (s ⊔ t : submodule K V) ≤ module.rank K s + module.rank K t :=\nby { rw [← dim_sup_add_dim_inf_eq], exact self_le_add_right _ _ }\n\nend\n\nlemma exists_mem_ne_zero_of_dim_pos {s : submodule K V} (h : 0 < module.rank K s) :\n  ∃ b : V, b ∈ s ∧ b ≠ 0 :=\nexists_mem_ne_zero_of_ne_bot $ assume eq, by rw [eq, dim_bot] at h; exact lt_irrefl _ h\n\nend division_ring\n\nsection rank\n\nsection\nvariables [ring K] [add_comm_group V] [module K V] [add_comm_group V₁] [module K V₁]\nvariables [add_comm_group V'] [module K V']\n\n/-- `rank f` is the rank of a `linear_map f`, defined as the dimension of `f.range`. -/\ndef rank (f : V →ₗ[K] V') : cardinal := module.rank K f.range\n\nlemma rank_le_range (f : V →ₗ[K] V₁) : rank f ≤ module.rank K V₁ :=\ndim_submodule_le _\n\n@[simp] lemma rank_zero [nontrivial K] : rank (0 : V →ₗ[K] V') = 0 :=\nby rw [rank, linear_map.range_zero, dim_bot]\n\nvariables [add_comm_group V''] [module K V'']\n\nlemma rank_comp_le1 (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') : rank (f.comp g) ≤ rank f :=\nbegin\n  refine dim_le_of_submodule _ _ _,\n  rw [linear_map.range_comp],\n  exact linear_map.map_le_range,\nend\n\nvariables [add_comm_group V'₁] [module K V'₁]\n\nlemma rank_comp_le2 (g : V →ₗ[K] V') (f : V' →ₗ[K] V'₁) : rank (f.comp g) ≤ rank g :=\nby rw [rank, rank, linear_map.range_comp]; exact dim_map_le _ _\n\nend\n\nend rank\n\nsection division_ring\nvariables [division_ring K] [add_comm_group V] [module K V] [add_comm_group V₁] [module K V₁]\nvariables [add_comm_group V'] [module K V']\n\nlemma rank_le_domain (f : V →ₗ[K] V₁) : rank f ≤ module.rank K V :=\nby { rw [← dim_range_add_dim_ker f], exact self_le_add_right _ _ }\n\nlemma rank_add_le (f g : V →ₗ[K] V') : rank (f + g) ≤ rank f + rank g :=\ncalc rank (f + g) ≤ module.rank K (f.range ⊔ g.range : submodule K V') :\n  begin\n    refine dim_le_of_submodule _ _ _,\n    exact (linear_map.range_le_iff_comap.2 $ eq_top_iff'.2 $\n      assume x, show f x + g x ∈ (f.range ⊔ g.range : submodule K V'), from\n        mem_sup.2 ⟨_, ⟨x, rfl⟩, _, ⟨x, rfl⟩, rfl⟩)\n  end\n  ... ≤ rank f + rank g : dim_add_le_dim_add_dim _ _\n\nlemma rank_finset_sum_le {η} (s : finset η) (f : η → V →ₗ[K] V') :\n  rank (∑ d in s, f d) ≤ ∑ d in s, rank (f d) :=\n@finset.sum_hom_rel _ _ _ _ _ (λa b, rank a ≤ b) f (λ d, rank (f d)) s (le_of_eq rank_zero)\n      (λ i g c h, le_trans (rank_add_le _ _) (add_le_add_left h _))\n\n/-- The `ι` indexed basis on `V`, where `ι` is an empty type and `V` is zero-dimensional.\n\nSee also `finite_dimensional.fin_basis`.\n-/\ndef basis.of_dim_eq_zero {ι : Type*} [is_empty ι] (hV : module.rank K V = 0) :\n  basis ι K V :=\nbegin\n  haveI : subsingleton V := dim_zero_iff.1 hV,\n  exact basis.empty _\nend\n\n@[simp] lemma basis.of_dim_eq_zero_apply {ι : Type*} [is_empty ι]\n  (hV : module.rank K V = 0) (i : ι) :\n  basis.of_dim_eq_zero hV i = 0 :=\nrfl\n\nlemma le_dim_iff_exists_linear_independent {c : cardinal} :\n  c ≤ module.rank K V ↔ ∃ s : set V, #s = c ∧ linear_independent K (coe : s → V) :=\nbegin\n  split,\n  { intro h,\n    let t := basis.of_vector_space K V,\n    rw [← t.mk_eq_dim'', cardinal.le_mk_iff_exists_subset] at h,\n    rcases h with ⟨s, hst, hsc⟩,\n    exact ⟨s, hsc, (of_vector_space_index.linear_independent K V).mono hst⟩ },\n  { rintro ⟨s, rfl, si⟩,\n    exact cardinal_le_dim_of_linear_independent si }\nend\n\nlemma le_dim_iff_exists_linear_independent_finset {n : ℕ} :\n  ↑n ≤ module.rank K V ↔\n    ∃ s : finset V, s.card = n ∧ linear_independent K (coe : (s : set V) → V) :=\nbegin\n  simp only [le_dim_iff_exists_linear_independent, cardinal.mk_set_eq_nat_iff_finset],\n  split,\n  { rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩,\n    exact ⟨t, rfl, si⟩ },\n  { rintro ⟨s, rfl, si⟩,\n    exact ⟨s, ⟨s, rfl, rfl⟩, si⟩ }\nend\n\n/-- A vector space has dimension at most `1` if and only if there is a\nsingle vector of which all vectors are multiples. -/\nlemma dim_le_one_iff : module.rank K V ≤ 1 ↔ ∃ v₀ : V, ∀ v, ∃ r : K, r • v₀ = v :=\nbegin\n  let b := basis.of_vector_space K V,\n  split,\n  { intro hd,\n    rw [← b.mk_eq_dim'', cardinal.le_one_iff_subsingleton, subsingleton_coe] at hd,\n    rcases eq_empty_or_nonempty (of_vector_space_index K V) with hb | ⟨⟨v₀, hv₀⟩⟩,\n    { use 0,\n      have h' : ∀ v : V, v = 0, { simpa [hb, submodule.eq_bot_iff] using b.span_eq.symm },\n      intro v,\n      simp [h' v] },\n    { use v₀,\n      have h' : (K ∙ v₀) = ⊤, { simpa [hd.eq_singleton_of_mem hv₀] using b.span_eq },\n      intro v,\n      have hv : v ∈ (⊤ : submodule K V) := mem_top,\n      rwa [←h', mem_span_singleton] at hv } },\n  { rintros ⟨v₀, hv₀⟩,\n    have h : (K ∙ v₀) = ⊤,\n    { ext, simp [mem_span_singleton, hv₀] },\n    rw [←dim_top, ←h],\n    convert dim_span_le _,\n    simp }\nend\n\n/-- A submodule has dimension at most `1` if and only if there is a\nsingle vector in the submodule such that the submodule is contained in\nits span. -/\nlemma dim_submodule_le_one_iff (s : submodule K V) : module.rank K s ≤ 1 ↔ ∃ v₀ ∈ s, s ≤ K ∙ v₀ :=\nbegin\n  simp_rw [dim_le_one_iff, le_span_singleton_iff],\n  split,\n  { rintro ⟨⟨v₀, hv₀⟩, h⟩,\n    use [v₀, hv₀],\n    intros v hv,\n    obtain ⟨r, hr⟩ := h ⟨v, hv⟩,\n    use r,\n    simp_rw [subtype.ext_iff, coe_smul, submodule.coe_mk] at hr,\n    exact hr },\n  { rintro ⟨v₀, hv₀, h⟩,\n    use ⟨v₀, hv₀⟩,\n    rintro ⟨v, hv⟩,\n    obtain ⟨r, hr⟩ := h v hv,\n    use r,\n    simp_rw [subtype.ext_iff, coe_smul, submodule.coe_mk],\n    exact hr }\nend\n\n/-- A submodule has dimension at most `1` if and only if there is a\nsingle vector, not necessarily in the submodule, such that the\nsubmodule is contained in its span. -/\nlemma dim_submodule_le_one_iff' (s : submodule K V) : module.rank K s ≤ 1 ↔ ∃ v₀, s ≤ K ∙ v₀ :=\nbegin\n  rw dim_submodule_le_one_iff,\n  split,\n  { rintros ⟨v₀, hv₀, h⟩,\n    exact ⟨v₀, h⟩ },\n  { rintros ⟨v₀, h⟩,\n    by_cases hw : ∃ w : V, w ∈ s ∧ w ≠ 0,\n    { rcases hw with ⟨w, hw, hw0⟩,\n      use [w, hw],\n      rcases mem_span_singleton.1 (h hw) with ⟨r', rfl⟩,\n      have h0 : r' ≠ 0,\n      { rintro rfl,\n        simpa using hw0 },\n      rwa span_singleton_smul_eq (is_unit.mk0 _ h0) _ },\n    { push_neg at hw,\n      rw ←submodule.eq_bot_iff at hw,\n      simp [hw] } }\nend\n\nlemma submodule.rank_le_one_iff_is_principal (W : submodule K V) :\n  module.rank K W ≤ 1 ↔ W.is_principal :=\nbegin\n  simp only [dim_le_one_iff, submodule.is_principal_iff, le_antisymm_iff,\n    le_span_singleton_iff, span_singleton_le_iff_mem],\n  split,\n  { rintro ⟨⟨m, hm⟩, hm'⟩,\n    choose f hf using hm',\n    exact ⟨m, ⟨λ v hv, ⟨f ⟨v, hv⟩, congr_arg coe (hf ⟨v, hv⟩)⟩, hm⟩⟩ },\n  { rintro ⟨a, ⟨h, ha⟩⟩,\n    choose f hf using h,\n    exact ⟨⟨a, ha⟩, λ v, ⟨f v.1 v.2, subtype.ext (hf v.1 v.2)⟩⟩ }\nend\n\nlemma module.rank_le_one_iff_top_is_principal :\n  module.rank K V ≤ 1 ↔ (⊤ : submodule K V).is_principal :=\nby rw [← submodule.rank_le_one_iff_is_principal, dim_top]\n\nlemma le_rank_iff_exists_linear_independent {c : cardinal} {f : V →ₗ[K] V'} :\n  c ≤ rank f ↔\n  ∃ s : set V, cardinal.lift.{v'} (#s) = cardinal.lift.{v} c ∧\n    linear_independent K (λ x : s, f x) :=\nbegin\n  rcases f.range_restrict.exists_right_inverse_of_surjective f.range_range_restrict with ⟨g, hg⟩,\n  have fg : left_inverse f.range_restrict g, from linear_map.congr_fun hg,\n  refine ⟨λ h, _, _⟩,\n  { rcases le_dim_iff_exists_linear_independent.1 h with ⟨s, rfl, si⟩,\n    refine ⟨g '' s, cardinal.mk_image_eq_lift _ _ fg.injective, _⟩,\n    replace fg : ∀ x, f (g x) = x, by { intro x, convert congr_arg subtype.val (fg x) },\n    replace si : linear_independent K (λ x : s, f (g x)),\n      by simpa only [fg] using si.map' _ (ker_subtype _),\n    exact si.image_of_comp s g f },\n  { rintro ⟨s, hsc, si⟩,\n    have : linear_independent K (λ x : s, f.range_restrict x),\n      from linear_independent.of_comp (f.range.subtype) (by convert si),\n    convert cardinal_le_dim_of_linear_independent this.image,\n    rw [← cardinal.lift_inj, ← hsc, cardinal.mk_image_eq_of_inj_on_lift],\n    exact inj_on_iff_injective.2 this.injective }\nend\n\nlemma le_rank_iff_exists_linear_independent_finset {n : ℕ} {f : V →ₗ[K] V'} :\n  ↑n ≤ rank f ↔ ∃ s : finset V, s.card = n ∧ linear_independent K (λ x : (s : set V), f x) :=\nbegin\n  simp only [le_rank_iff_exists_linear_independent, cardinal.lift_nat_cast,\n    cardinal.lift_eq_nat_iff, cardinal.mk_set_eq_nat_iff_finset],\n  split,\n  { rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩,\n    exact ⟨t, rfl, si⟩ },\n  { rintro ⟨s, rfl, si⟩,\n    exact ⟨s, ⟨s, rfl, rfl⟩, si⟩ }\nend\n\nend division_ring\n\nend module\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/linear_algebra/dimension.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4617646779380198}}
{"text": "/-\nCopyright (c) 2022 Arthur Paulino, Damiano Testa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Arthur Paulino, Damiano Testa\n\n! This file was ported from Lean 3 source module tactic.move_add\n! leanprover-community/mathlib commit 205a628e1fdc9220cb86832d66a50d1381abc103\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.Core\nimport Mathbin.Algebra.Group.Basic\n\n/-!\n# `move_add`: a tactic for moving summands\n\nCalling `move_add [a, ← b, c]`, recursively looks inside the goal for expressions involving a sum.\nWhenever it finds one, it moves the summands that unify to `a, b, c`, removing all parentheses.\n\nSee the doc-string for `tactic.interactive.move_add` for more information.\n\n##  Implementation notes\n\nThis file defines a general `move_op` tactic, intended for reordering terms in an expression\nobtained by repeated applications of a given associative, commutative binary operation.  The\nuser decides the final reordering.  Applying `move_op` without specifying the order will simply\nremove all parentheses from the expression.\nThe main user-facing tactics are `move_add` and `move_mul`, dealing with addition and\nmultiplication, respectively.\n\nIn what is below, we talk about `move_add` for definiteness, but everything applies\nto `move_mul` and to the more general `move_op`.\n\nThe implementation of `move_add` only moves the terms specified by the user (and rearranges\nparentheses).\n\nNote that the tactic `abel` already implements a very solid heuristic for normalizing terms in an\nadditive commutative semigroup and produces expressions in more or less standard form.\nThe scope of `move_add` is different: it is designed to make it easy to move individual terms\naround a sum.\n\n##  Future work\n\n* Add support for `neg/div/inv` in additive/multiplicative groups?\n* Currently the tactic has special support for `+` and `*`.  Every other operation is outsourced\n  to `ac_refl` (see the proof of `reorder_hyp`).  Should there be the desire for specialized support\n  of other operations (e.g. `∪, ∩, ⊓, ⊔, ...`), that is the definition to modify, at least in the\n  first instance.\n* Add functionality for moving terms across the two sides of an in/dis/equality.\n  E.g. it might be desirable to have `to_lhs [a]` converting `b + c = a + d` to `- a + b + c = d`.\n* Add a non-recursive version for use in `conv` mode.\n* Revise tests?\n-/\n\n\nnamespace Tactic\n\nnamespace MoveOp\n\n/-!\nThroughout this file, `op : pexpr` denotes an arbitrary (binary) operation.  We do not use,\nbut implicitly imagine, that this operation is associative, since we extract iterations of\nsuch operations, with complete disregard of the order in which these iterations arise.\n-/\n\n\n/-- Given a list `un` of `α`s and a list `bo` of `bool`s, return the sublist of `un`\nconsisting of the entries of `un` whose corresponding entry in `bo` is `tt`.\n\nUsed for error management: `un` is the list of user inputs, `bo` is the list encoding which input\nis unused (`tt`) and which input is used (`ff`).\n`return_unused` returns the unused user inputs.\n\nIf `bo` is shorter than `un`, `return_unused` will include the remainder of `un`.\n-/\ndef returnUnused {α : Type _} : List α → List Bool → List α\n  | un, [] => un\n  | [], bo => []\n  | u :: us, b :: bs => if b then u :: return_unused us bs else return_unused us bs\n#align tactic.move_op.return_unused Tactic.MoveOp.returnUnused\n\n/-- Given a list `lp` of `bool × pexpr` and a list `l_un` of `expr`, scan the elements of `lp` one\nat a time and produce 3 sublists of `l_un`.\n\nIf `(tf,pe)` is the first element of `lp`, we look for the first element of `l_un` that unifies with\n`pe.to_expr`.  If no such element exists, then we discard `(tf,pe)` and move along.\nIf `eu ∈ l_un` is the first element of `l_un` that unifies with `pe.to_expr`, then we add `eu` as\nthe next element of either the first or the second list, depending on the boolean `tf` and we remove\n`eu` from the list `l_un`.  In this case, we continue our scanning with the next element of `lp`,\nreplacing `l_un` by `l_un.erase eu`.\n\nOnce we exhaust the elements of `lp`, we return the four lists:\n* `l_tt`: the list of elements of `l_un` that came from an element of `lp` whose boolean was `tt`,\n* `l_ff`: the list of elements of `l_un` that came from an element of `lp` whose boolean was `ff`,\n* `l_un`: the un-unified elements of `l_un`,\n* `l_m`: a \"mask\" list of booleans corresponding to the elements of `lp` that were placed in `l_un`.\n\nThe ununified elements of `l_un` get used for error management: they keep track of which user inputs\nare superfluous. -/\nunsafe def move_left_or_right :\n    List (Bool × expr) →\n      List expr → List Bool → tactic (List expr × List expr × List expr × List Bool)\n  | [], l_un, l_m => return ([], [], l_un, l_m)\n  | be :: l, l_un, l_m => do\n    let ex :: _ ← l_un.filterM fun e' => succeeds <| unify be.2 e' |\n      move_left_or_right l l_un (l_m.append [true])\n    let (l_tt, l_ff, l_un, l_m) ← move_left_or_right l (l_un.eraseₓ ex) (l_m.append [false])\n    if be.1 then return (ex :: l_tt, l_ff, l_un, l_m) else return (l_tt, ex :: l_ff, l_un, l_m)\n#align tactic.move_op.move_left_or_right tactic.move_op.move_left_or_right\n\n/-- We adapt `move_left_or_right` to our goal:\n1. we convert a list of pairs `bool × pexpr` to a list of pairs `bool × expr`,\n2. we use the extra input `sl : list expr` to perform the unification and sorting step\n   `move_left_or_right`,\n3. we jam the third factor inside the first two.\n-/\nunsafe def final_sort (lp : List (Bool × pexpr)) (sl : List expr) :\n    tactic (List expr × List Bool) := do\n  let lp_exp : List (Bool × expr) ←\n    lp.mapM fun x => do\n        let e ← to_expr x.2 true false\n        return (x.1, e)\n  let (l1, l2, l3, is_unused) ← move_left_or_right lp_exp sl []\n  return (l1 ++ l3 ++ l2, is_unused)\n#align tactic.move_op.final_sort tactic.move_op.final_sort\n\n/-- `as_given_op op e` unifies the head term of `e`, which is a ≥2-argument function application,\nwith the binary operation `op`, failing if it cannot. -/\nunsafe def as_given_op (op : pexpr) : expr → tactic expr\n  | expr.app (expr.app F a) b => do\n    to_expr op tt ff >>= unify F\n    return F\n  | _ => failed\n#align tactic.move_op.as_given_op tactic.move_op.as_given_op\n\n/-- `(e, unused) ← reorder_oper op lp e` converts an expression `e` to a similar looking one.\nThe tactic scans the expression `e` looking for subexpressions that begin with the given binary\noperation `op`.  As soon as `reorder_oper` finds one such subexpression,\n* it extracts the \"`op`-summands\" in the subexpression,\n* it rearranges them according to the rules determined by `lp`,\n* it recurses into each `op`-summand.\n\nThe `unused` output is a list of booleans.  It is keeping track of which of the inputs provided\nby `lp` is actually used to perform the rearrangements.  It is useful to report unused inputs.\n\nHere are two examples:\n```lean\n#eval trace $ reorder_oper ``((=)) [(ff,``(2)), (tt,``(7))] `(∀ x y : ℕ, 2 = 0)\n--  (ℕ → ℕ → 0 = 2, [ff, tt])\n-- the input `[(ff,``(2)), (tt,``(7))]` instructs Lean to move `2` to the right and `7`\n-- to the left.  Lean reports that `2` is not unused and `7` is unused as `[ff, tt]`.\n\n#eval trace $ reorder_oper ``((+)) [(ff,``(2)), (tt,``(5))]\n  `(λ (e : ℕ), ∀ (x : ℕ), ∃ (y : ℕ),\n      2 + x * (y + (e + 5)) + y = x + 2 + e → 2 + x = x + 5 + (2 + y))\n/-  `2` moves to the right, `5` moves to the left.  Lean reports that `2, 5` are not unused\n    as `[ff,ff]`\n   (λ (e : ℕ), ∀ (x : ℕ), ∃ (y : ℕ),\n      x * (5 + y + e) + y + 2   = x + e + 2 → x + 2 = 5 + x + y + 2, [ff, ff]) -/\n```\n\nTODO: use `ext_simplify_core` instead of traversing the expression manually\n-/\nunsafe def reorder_oper (op : pexpr) (lp : List (Bool × pexpr)) : expr → tactic (expr × List Bool)\n  | F'@(expr.app F b) => do\n    let is_op ← try_core (as_given_op op F')\n    match is_op with\n      | some op => do\n        let (sort_list, is_unused) ← list_binary_operands op F' >>= final_sort lp\n        let sort_all ←\n          sort_list fun e => do\n              let (e, lu) ← reorder_oper e\n              pure (e, [lu, is_unused].transpose.map List.and)\n        let (recs, list_unused) := sort_all\n        let recs_0 :: recs_rest ← pure recs |\n          throwError\"internal error: cannot have 0 operands\"\n        let summed := recs_rest (fun e f => op [e, f]) recs_0\n        return (summed, list_unused List.and)\n      | none => do\n        let [(Fn, unused_F), (bn, unused_b)] ← [F, b].mapM <| reorder_oper\n        return <| (expr.app Fn bn, [unused_F, unused_b].transpose.map List.and)\n  | expr.pi na bi e f => do\n    let [en, fn] ← [e, f].mapM <| reorder_oper\n    return (expr.pi na bi en.1 fn.1, [en.2, fn.2].transpose.map List.and)\n  | expr.lam na bi e f => do\n    let [en, fn] ← [e, f].mapM <| reorder_oper\n    return (expr.lam na bi en.1 fn.1, [en.2, fn.2].transpose.map List.and)\n  | expr.mvar na pp e => do\n    let en\n      ←-- is it really needed to recurse here?\n          reorder_oper\n          e\n    return (expr.mvar na pp en.1, [en.2].transpose.map List.and)\n  | expr.local_const na pp bi e => do\n    let en\n      ←-- is it really needed to recurse here?\n          reorder_oper\n          e\n    return (expr.local_const na pp bi en.1, [en.2].transpose.map List.and)\n  | expr.elet na e f g => do\n    let [en, fn, gn] ← [e, f, g].mapM <| reorder_oper\n    return (expr.elet na en.1 fn.1 gn.1, [en.2, fn.2, gn.2].transpose.map List.and)\n  | expr.macro ma le => do\n    let len\n      ←-- is it really needed to recurse here?\n            le.mapM <|\n          reorder_oper\n    let (lee, lb) := len.unzip\n    return (expr.macro ma lee, lb List.and)\n  | e => pure (e, lp.map fun _ => true)\n#align tactic.move_op.reorder_oper tactic.move_op.reorder_oper\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n/-- Passes the user input `na` to `reorder_oper` at a single location, that could either be\n`none` (referring to the goal) or `some name` (referring to hypothesis `name`).  Replaces the\ngiven hypothesis/goal with the rearranged one that `reorder_hyp` receives from `reorder_oper`.\nReturns a pair consisting of a boolean and a further list of booleans.\nThe single boolean is `tt` iff the tactic did *not* change the goal on which it was acting.\nThe list of booleans records which variable in `ll` has been unified in the application:\n`tt` means that the corresponding variable has *not* been unified.\n\nThis definition is useful to streamline error catching. -/\nunsafe def reorder_hyp (op : pexpr) (lp : List (Bool × pexpr)) (na : Option Name) :\n    tactic (Bool × List Bool) := do\n  let (thyp, hyploc) ←\n    match na with\n      | none => do\n        let t ← target\n        return (t, none)\n      | some na => do\n        let hl ← get_local na\n        let th ← infer_type hl\n        return (th, some hl)\n  let (reordered, is_unused) ← reorder_oper op lp thyp\n  unify reordered thyp >> return (tt, is_unused) <|> do\n      let neq\n        ←-- the current `do` block takes place where the reordered expression is not equal to the original\n            mk_app\n            `eq [thyp, reordered]\n      let nop ← to_expr op tt ff\n      let pre ← pp reordered\n      let (_, prf) ←\n        solve_aux neq <|\n            match nop with\n            | q(Add.add) => sorry\n            | q(Mul.mul) => sorry\n            | _ =>\n              ac_refl <|>\n                fail\n                  f! \"the associative/commutative lemmas used do not suffice to prove that the initial goal equals:\n                    \n                    {pre}\n                    Hint: try adding `is_associative` or `is_commutative` instances.\n                    \"\n      match hyploc with\n        | none => replace_target reordered prf\n        | some hyploc => replace_hyp hyploc reordered prf >> skip\n      return (ff, is_unused)\n#align tactic.move_op.reorder_hyp tactic.move_op.reorder_hyp\n\nsection ParsingArgumentsForMoveOp\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\n/-- `move_op_arg` is a single elementary argument that `move_op` takes for the\nvariables to be moved.  It is either a `pexpr`, or a `pexpr` preceded by a `←`. -/\nunsafe def move_op_arg (prec : Nat) : parser (Bool × pexpr) :=\n  Prod.mk <$> Option.isSome <$> (tk \"<-\")? <*> parser.pexpr prec\n#align tactic.move_op.move_op_arg tactic.move_op.move_op_arg\n\n/-- `move_pexpr_list_or_texpr` is either a list of `move_op_arg`, possibly empty, or a single\n`move_op_arg`. -/\nunsafe def move_pexpr_list_or_texpr : parser (List (Bool × pexpr)) :=\n  list_of (move_op_arg 0) <|> List.ret <$> move_op_arg tac_rbp <|> return []\n#align tactic.move_op.move_pexpr_list_or_texpr tactic.move_op.move_pexpr_list_or_texpr\n\nend ParsingArgumentsForMoveOp\n\nend MoveOp\n\n/- ./././Mathport/Syntax/Translate/Tactic/Mathlib/Core.lean:38:34: unsupported: setup_tactic_parser -/\nopen MoveOp\n\n/-- `move_op args locat op` is the non-interactive version of the main tactics `move_add` and\n`move_mul` of this file.  Given as input `args` (a list of terms of a sequence of operands),\n`locat` (hypotheses or goal where the tactic should act) and `op` (the operation to use),\n`move_op` attempts to perform the rearrangement of the terms determined by `args`.\n\nCurrently, the tactic uses only `add/mul_comm, add/mul_assoc, add/mul_left_comm`, so other\noperations will not actually work.\n-/\nunsafe def move_op (args : parse move_pexpr_list_or_texpr) (locat : parse location) (op : pexpr) :\n    tactic Unit := do\n  let locas ← locat.get_locals\n  let tg ← target\n  let locas_with_tg := if locat.include_goal then locas ++ [tg] else locas\n  let ner ←\n    locas_with_tg.mapM fun e => reorder_hyp op args e.local_pp_name <|> reorder_hyp op args none\n  let (unch_tgts, unus_vars) := ner.unzip\n  let str_unva ←\n    match\n        (returnUnused args (unus_vars.transpose.map List.and)).map fun e : Bool × pexpr => e.2 with\n      | [] => pure []\n      | [pe] => do\n        let nm ← to_expr pe true false >>= fun ex => pp ex.replace_mvars\n        return [f! \"'{nm}' is an unused variable\"]\n      | pes => do\n        let nms ←\n          (pes.mapM fun e => to_expr e true false) >>= fun exs =>\n              (exs.map expr.replace_mvars).mapM pp\n        return [f! \"'{nms}' are unused variables\"]\n  let str_tgts :=\n    match locat with\n    | loc.wildcard => if unch_tgts.and then [f!\"nothing changed\"] else []\n    | loc.ns names =>\n      let linames := returnUnused locas unch_tgts\n      (if none ∈ returnUnused names unch_tgts then [f!\"Goal did not change\"] else []) ++\n        if linames ≠ [] then [f! \"'{linames.reverse}' did not change\"] else []\n  let [] ← pure (str_tgts ++ str_unva) |\n    fail (format.intercalate \"\\n\" (str_tgts ++ str_unva))\n  assumption <|> try (tactic.reflexivity reducible)\n#align tactic.move_op tactic.move_op\n\nnamespace Interactive\n\n/--\nCalling `move_add [a, ← b, c]`, recursively looks inside the goal for expressions involving a sum.\nWhenever it finds one, it moves the summands that unify to `a, b, c`, removing all parentheses.\nRepetitions are allowed, and are processed following the user-specified ordering.\nThe terms preceded by a `←` get placed to the left, the ones without the arrow get placed to the\nright.  Unnamed terms stay in place.  Due to re-parenthesizing, doing `move_add` with no argument\nmay change the goal. Also, the *order* in which the terms are provided matters: the tactic reads\nthem from left to right.  This is especially important if there are multiple matches for the typed\nterms in the given expressions.\n\nA single call of `move_add` moves terms across different sums in the same expression.\nHere is an example.\n\n```lean\nimport tactic.move_add\n\nexample {a b c d : ℕ} (h : c = d) : c + b + a = b + a + d :=\nbegin\n  move_add [← a, b],  -- Goal: `a + c + b = a + d + b`  -- both sides changed\n  congr,\n  exact h\nend\n\nexample {a b c d : ℕ} (h : c = d) : c + b * c + a * c = a * d + d + b * d :=\nbegin\n  move_add [_ * c, ← _ * c], -- Goal: `a * c + c + b * c = a * d + d + b * d`\n  -- the first `_ * c` unifies with `b * c` and moves to the right\n  -- the second `_ * c` unifies with `a * c` and moves to the left\n  congr;\n  assumption\nend\n```\n\nThe list of expressions that `move_add` takes is optional and a single expression can be passed\nwithout brackets.  Thus `move_add ← f` and `move_add [← f]` mean the same.\n\nFinally, `move_add` can also target one or more hypotheses.  If `hp₁, hp₂` are in the\nlocal context, then `move_add [f, ← g] at hp₁ hp₂` performs the rearranging at `hp₁` and `hp₂`.\nAs usual, passing `⊢` refers to acting on the goal.\n\n##  Reporting sub-optimal usage\n\nThe tactic could fail to prove the reordering.  One potential cause is when there are multiple\nmatches for the rearrangements and an earlier rewrite makes a subsequent one fail.  Another\npossibility is that the rearranged expression changes the *Type* of some expression and the\ntactic gets stumped.  Please, report bugs and failures in the Zulip chat!\n\nThere are three kinds of unwanted use for `move_add` that result in errors, where the tactic fails\nand flags the unwanted use.\n1. `move_add [vars]? at *` reports globally unused variables and whether *all* goals\n   are unchanged, not *each unchanged goal*.\n2. If a target of `move_add [vars]? at targets` is left unchanged by the tactic, then this will be\n   flagged (unless we are using `at *`).\n3. If a user-provided expression never unifies, then the variable is flagged.\n\nIn these cases, the tactic produces an error, reporting unused inputs and unchanged targets as\nappropriate.\n\nFor instance, `move_add ← _` always fails reporting an unchanged goal, but never an unused variable.\n\n##  Comparison with existing tactics\n\n* `tactic.interactive.abel`\n  performs a \"reduction to normal form\" that allows it to close goals involving sums with higher\n  success rate than `move_add`.  If the goal is an equality of two sums that are simply obtained by\n  reparenthesizing and permuting summands, then `move_add [appropriate terms]` can close the goal.\n  Compared to `abel`, `move_add` has the advantage of allowing the user to specify the beginning and\n  the end of the final sum, so that from there the user can continue with the proof.\n\n* `tactic.interactive.ac_change`\n  supports a wide variety of operations.  At the moment, `move_add` works with addition, `move_mul`\n  works with multiplication.  There is the possibility of supporting other operations, using the\n  non-interactive tactic `tactic.move_op`.\n  Still, on several experiments, `move_add` had a much quicker performance than `ac_change`.\n  Also, for `move_add` the user need only specify a few terms: the tactic itself takes care of\n  producing the full rearrangement and proving it \"behind the scenes\".\n\n###  Remark:\nIt is still possible that the same output of `move_add [exprs]` can be achieved by a proper sublist\nof `[exprs]`, even if the tactic does not flag anything.  For instance, giving the full re-ordering\nof the expressions in the target that we want to achieve will not complain that there are unused\nvariables, since all the user-provided variables have been matched.  Of course, specifying the order\nof all-but-the-last variable suffices to determine the permutation.  E.g., with a goal of\n`a + b = 0`, applying either one of `move_add [b,a]`, or `move_add a`, or `move_add ← b` has the\nsame effect and changes the goal to `b + a = 0`.  These are all valid uses of `move_add`.\n-/\nunsafe def move_add (args : parse move_pexpr_list_or_texpr) (locat : parse location) :\n    tactic Unit :=\n  move_op args locat ``((· + ·))\n#align tactic.interactive.move_add tactic.interactive.move_add\n\n/-- See the doc-string for `tactic.interactive.move_add` and mentally\nreplace addition with multiplication throughout. ;-) -/\nunsafe def move_mul (args : parse move_pexpr_list_or_texpr) (locat : parse location) :\n    tactic Unit :=\n  move_op args locat ``(Mul.mul)\n#align tactic.interactive.move_mul tactic.interactive.move_mul\n\n/-- `move_oper` behaves like `move_add` except that it also takes an associative, commutative,\nbinary operation as input.  The operation must be passed as a list consisting of a single element.\nFor instance\n```lean\nexample (a b : ℕ) : max a b = max b a :=\nby move_oper [max] [← a, b] at *\n```\nsolves the goal.  For more details, see the `move_add` doc-string, replacing `add` with your\nintended operation.\n-/\nunsafe def move_oper (op : parse pexpr_list) (args : parse move_pexpr_list_or_texpr)\n    (locat : parse location) : tactic Unit := do\n  let [op] ← pure op |\n    fail \"only one operation is allowed\"\n  move_op args locat op\n#align tactic.interactive.move_oper tactic.interactive.move_oper\n\nadd_tactic_doc\n  { Name := \"move_add\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.move_add]\n    tags := [\"arithmetic\"] }\n\nadd_tactic_doc\n  { Name := \"move_mul\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.move_mul]\n    tags := [\"arithmetic\"] }\n\nend Interactive\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/MoveAdd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4617646779380197}}
{"text": "/- Copyright 2022 ACL & MIdFF-/\n\nimport algebra.module.graded_module\n\nsection direct_sum\n\nuniverses u v w \nvariables {ι : Type v} [decidable_eq ι]\n\nsection mk\n\nvariables {β : ι → Type w} [Π (i : ι), add_comm_monoid (β i)]\n\nlemma direct_sum.mk_apply_of_mem {s : finset ι} {f : Π (i : (↑s : set ι)), β i.val}\n  {n : ι} (hn : n ∈ s):\n  direct_sum.mk β s f n = f ⟨n, hn⟩ := \nby simp only [direct_sum.mk, add_monoid_hom.coe_mk, dfinsupp.mk_apply, dif_pos hn]\n\nlemma direct_sum.mk_apply_of_not_mem {s : finset ι} {f : Π (i : (↑s : set ι)), β i.val}\n  {n : ι} (hn : n ∉ s):\n  direct_sum.mk β s f n = 0 := \nby simp only [direct_sum.mk, add_monoid_hom.coe_mk, dfinsupp.mk_apply, dif_neg hn]\n\nend mk\n\nsection internal\n\nvariables {M : Type w} [decidable_eq M] [add_comm_monoid M] \n\nlemma direct_sum.coe_add_monoid_hom_eq_dfinsupp_sum  \n  {M : Type w} [decidable_eq M] [add_comm_monoid M] \n  (A : ι → add_submonoid M) (x : direct_sum ι (λ i, A i)) :\n  direct_sum.coe_add_monoid_hom A x = dfinsupp.sum x (λ i, coe):= \nby simp only [direct_sum.coe_add_monoid_hom, direct_sum.to_add_monoid, \n  dfinsupp.lift_add_hom, add_equiv.coe_mk, dfinsupp.sum_add_hom_apply, \n  add_submonoid_class.coe_subtype]\n\nlemma direct_sum.coe_linear_map_eq_dfinsupp_sum \n  {R : Type u} [semiring R] [module R M] (A : ι → submodule R M) \n  (x : direct_sum ι (λ i, A i)) :\n  direct_sum.coe_linear_map A x = dfinsupp.sum x (λ i, coe):= \nby simp only [direct_sum.coe_linear_map, direct_sum.to_module, dfinsupp.lsum, \n  linear_equiv.coe_mk, linear_map.coe_mk, dfinsupp.sum_add_hom_apply, \n  linear_map.to_add_monoid_hom_coe, submodule.coe_subtype]\n\nlemma direct_sum.support_subset (A : ι → add_submonoid M) \n  (x : direct_sum ι (λ i, A i)) :\n  function.support  (λ i, (x i : M)) ⊆ ↑(dfinsupp.support x) := \nbegin\n  intro m,\n  rw [function.mem_support, finset.mem_coe, dfinsupp.mem_support_to_fun, not_imp_not],\n  intro hm', \n  rw [hm', add_submonoid.coe_zero],\nend\n\nlemma direct_sum.support_subset_submodule (R : Type*) [comm_semiring R]\n  [module R M] (A : ι → submodule R M) \n  (x : direct_sum ι (λ i, A i)) :\n  function.support  (λ i, (x i : M)) ⊆ ↑(dfinsupp.support x) := \nbegin\n  intro m,\n  rw [function.mem_support, finset.mem_coe, dfinsupp.mem_support_to_fun, not_imp_not],\n  intro hm', \n  simp only [hm', submodule.coe_zero],\nend\n\nlemma direct_sum.finite_support (A : ι → add_submonoid M) \n  (x : direct_sum ι (λ i, A i)) :\n  (function.support (λ i, (x i : M))).finite := \nset.finite.subset (dfinsupp.support x : set ι).to_finite (direct_sum.support_subset _ x)\n\nend internal\n\nend direct_sum\n\nsection\n\ntheorem linear_map.map_finsum {α R S M N : Type*} [semiring R] [semiring S] (σ : R →+* S)\n  [add_comm_monoid M] [add_comm_monoid N]  [module R M] [module S N] {f : α → M} (g : M →ₛₗ[σ] N)\n  (hf : (function.support f).finite) :\n  g (finsum (λ (i : α), f i)) = finsum (λ (i : α), g (f i)) := \nbegin\n  rw ← linear_map.to_add_monoid_hom_coe,\n  exact add_monoid_hom.map_finsum _ hf,\nend\n\nend\n\nnoncomputable theory\n\nsection direct_sum\n\nopen direct_sum\n\n/- Given an R-algebra A and a family (ι → submodule R A) of submodules\nparameterized by an additive monoid\nand statisfying `set_like.graded_monoid M` (essentially, is multiplicative)\nsuch that `direct_sum.is_internal M` (A is the direct sum of the M i),\nwe endow A with the structure of a graded algebra.\nThe submodules are the *homogeneous* parts -/\n\n\nvariables (R : Type*) [comm_semiring R] (A : Type*) [comm_semiring A] [algebra R A]\nvariables (ι : Type*) [decidable_eq ι]\n\nvariables (M : ι → submodule R A) [add_monoid ι] [set_like.graded_monoid M]\n\nvariables {R A ι M}\n\n-- The following lines were given on Zulip by Adam Topaz\n\ndef direct_sum.is_internal.coe_alg_iso (hM : direct_sum.is_internal M) :\n  direct_sum ι (λ i, ↥(M i)) ≃ₐ[R] A :=\n{ commutes' := λ r, by simp,\n  ..(ring_equiv.of_bijective (direct_sum.coe_alg_hom M) hM) }\n\ndef direct_sum.is_internal.graded_algebra (hM : direct_sum.is_internal M) :\n  graded_algebra M :=\n{ decompose' := hM.coe_alg_iso.symm, \n    -- (coe_alg_iso_of_is_internal hM).symm,\n  left_inv := hM.coe_alg_iso.symm.left_inv, \n    -- (coe_alg_iso_of_is_internal hM).symm.left_inv,\n  right_inv := hM.coe_alg_iso.left_inv, \n  -- (coe_alg_iso_of_is_internal hM).left_inv,\n  ..(infer_instance : set_like.graded_monoid M) }\n\ndef direct_sum.decomposition.graded_algebra (dM : direct_sum.decomposition M) :\n  graded_algebra M :=\n{ to_decomposition  := dM,\n  ..(infer_instance : set_like.graded_monoid M) }\n\nend direct_sum\n\n#exit\n\n\nsection weighted_homogeneous\n\n/- Here, given a weight `w : σ → M`, where `M` is an additive and commutative monoid, we endow the\n  ring of multivariate polynomials `mv_polynomial σ R` with the structure of a graded algebra -/\n\nvariables {R : Type*} [comm_semiring R] \nvariables {M : Type*} [add_comm_monoid M] [decidable_eq M]\nvariables {σ : Type*}\nvariable (w : σ → M)\n\nnamespace mv_polynomial\n\nlemma weighted_homogeneous_component_mem (w : σ → M) (φ : mv_polynomial σ R) \n  (m : M) :\n  weighted_homogeneous_component R w m φ ∈ weighted_homogeneous_submodule R w m :=\nbegin\n  rw mem_weighted_homogeneous_submodule, \n  exact weighted_homogeneous_component_is_weighted_homogeneous m φ, \nend\n\n/- \nlemma toto (p : Prop) [decidable p] (u v : M) : \n  (ite p u v = u) ↔ (¬ p → u = v) := \nbegin\n  by_cases hp : p, \n  simp only [hp, if_true, eq_self_iff_true, not_true, is_empty.forall_iff],\n  simp only [hp, if_false, not_false_iff, forall_true_left],\n  exact comm,\nend\n -/\n\nlemma decompose'_aux (φ : mv_polynomial σ R) (i : M) \n  (hi : i ∉ finset.image (weighted_degree' w) φ.support) : \n  weighted_homogeneous_component R w i φ = 0 :=\nbegin\n  apply weighted_homogeneous_component_eq_zero', \n  simp only [finset.mem_image, mem_support_iff, ne.def, exists_prop, not_exists, not_and] at hi, \n  intros m hm, \n  apply hi m, \n  rw mem_support_iff at hm, \n  exact hm, \nend\n\n/- \nlemma decompose'_aux' (φ : mv_polynomial σ R) (i : M) : \n  ite (i ∈ finset.image (weighted_degree' w) φ.support) \n    ((weighted_homogeneous_component R w i) φ) 0 \n    = (weighted_homogeneous_component R w i) φ :=\nbegin\n  split_ifs with hi hi,\n  refl,\n  rw decompose'_aux w φ i hi, \nend -/\n\nvariable (R)\ndef decompose'_fun := λ (φ : mv_polynomial σ R), direct_sum.mk \n  (λ (i : M), ↥(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) φ.support)\n  (λ m, ⟨weighted_homogeneous_component R w m φ, weighted_homogeneous_component_mem w φ m⟩)\n\nlemma decompose'_fun_apply (φ : mv_polynomial σ R) (m : M):\n  (decompose'_fun R w φ m : mv_polynomial σ R) = \n  weighted_homogeneous_component R w m φ := \nbegin\n  rw decompose'_fun,\n  by_cases hm :  m ∈ finset.image (weighted_degree' w) φ.support,\n  simp only [direct_sum.mk_apply_of_mem hm, subtype.coe_mk], \n  rw [direct_sum.mk_apply_of_not_mem hm, submodule.coe_zero, decompose'_aux w φ m hm],\nend\n\ninstance [decidable_eq σ] [decidable_eq R] :\n  Π (i : M) (x : ↥(weighted_homogeneous_submodule R w i)), decidable (x ≠ 0) :=\nbegin\n  intros m x,\n  rw [ne.def, ← set_like.coe_eq_coe], \n  apply_instance,\nend\n\n-- Rewrite direct_sum.coe_linear_map\nlemma direct_sum.coe_linear_map_eq_support_sum [decidable_eq σ] [decidable_eq R]\n  (x : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))) :\n  ((direct_sum.coe_linear_map (λ (i : M), weighted_homogeneous_submodule R w i)) x) = \n  dfinsupp.sum x  (λ m, coe) :=\nbegin\n  rw direct_sum.coe_linear_map_eq_dfinsupp_sum, \n  -- WEIRD: this is not yet finished\n  simp only [dfinsupp.sum],\n  apply finset.sum_congr,\n  ext m, \n  simp only [dfinsupp.mem_support_iff],\n  intros m hm, refl,\nend\n\n-- Rewrite direct_sum.coe_add_monoid_hom\nlemma direct_sum.coe_add_monoid_hom_eq_support_sum [decidable_eq σ] [decidable_eq R]\n  (x : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))) :\n  ((direct_sum.coe_add_monoid_hom (λ (i : M), weighted_homogeneous_submodule R w i)) x) = \n  dfinsupp.sum x  (λ m, coe) :=\n  direct_sum.coe_linear_map_eq_support_sum R w x\n\n-- Variants for finsum\nlemma direct_sum.coe_linear_map_eq_finsum [decidable_eq σ] [decidable_eq R]\n  (x : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))) \n  /- [h_dec : Π (i : M) (x : ↥(weighted_homogeneous_submodule R w i)), decidable (x ≠ 0)]  -/: \n  ((direct_sum.coe_linear_map (λ (i : M), weighted_homogeneous_submodule R w i)) x) = \n  finsum (λ m, x m) :=\nbegin\n  rw [direct_sum.coe_linear_map_eq_support_sum, dfinsupp.sum],\n  rw finsum_eq_sum_of_support_subset, \n  -- direct_sum.support_subset ne marche pas…\n  intro m, \n  rw [function.mem_support, finset.mem_coe, dfinsupp.mem_support_to_fun, not_imp_not],\n  intro hm', \n  rw [hm', submodule.coe_zero],\nend\n\nlemma direct_sum.coe_add_monoid_hom_eq_finsum [decidable_eq σ] [decidable_eq R]\n  (x : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))) \n  /- [h_dec : Π (i : M) (x : ↥(weighted_homogeneous_submodule R w i)), decidable (x ≠ 0)]  -/: \n  ((direct_sum.coe_add_monoid_hom (λ (i : M), weighted_homogeneous_submodule R w i)) x) = \n  finsum (λ m, x m) :=\n  direct_sum.coe_linear_map_eq_finsum R w x\n\n-- TODO: move to weighted_homogeneous file\nlemma weighted_homogeneous_component_weighted_homogeneous_polynomial' (m : M)\n  (x : weighted_homogeneous_submodule R w m) :\n  (weighted_homogeneous_component  R w m) ↑x = x :=\nby rw [weighted_homogeneous_component_weighted_homogeneous_polynomial m m _ x.prop, if_pos rfl]\n \nlemma weighted_homogeneous_component_direct_sum [decidable_eq σ] [decidable_eq R]\n  (x : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))) (m : M) : \n  (weighted_homogeneous_component R w m) \n    ((direct_sum.coe_linear_map (λ (i : M), weighted_homogeneous_submodule R w i)) x) = x m :=\nbegin\n  rw [direct_sum.coe_linear_map_eq_dfinsupp_sum],\n  rw dfinsupp.sum, \n  rw map_sum, \n  rw finset.sum_eq_single m, \n  { rw weighted_homogeneous_component_of_weighted_homogeneous_polynomial_same,\n    rw ← mem_weighted_homogeneous_submodule, \n    exact (x m).prop, },\n  { intros n hn hmn, \n    rw weighted_homogeneous_component_of_weighted_homogeneous_polynomial_other,\n    rw ← mem_weighted_homogeneous_submodule, \n    exact (x n).prop, exact ne.symm hmn, },\n  { rw dfinsupp.not_mem_support_iff, \n    intro hm, rw [hm, submodule.coe_zero, map_zero], },\nend\n\ndef mv_polynomial_weighted_decomposition [decidable_eq σ] [decidable_eq R] : \n  direct_sum.decomposition (weighted_homogeneous_submodule R w) := \n{ decompose'  := decompose'_fun R w,\n  left_inv    := λ φ,\n  begin\n    conv_rhs { rw [← sum_weighted_homogeneous_component w φ], },\n    rw ← direct_sum.sum_support_of (λ m, ↥(weighted_homogeneous_submodule R w m))\n      (decompose'_fun R w φ),\n    simp only [direct_sum.coe_add_monoid_hom_of, mv_polynomial.coeff_sum, map_sum],\n    apply congr_arg2,\n    { ext m,\n      simp only [dfinsupp.mem_support_to_fun, ne.def, set.finite.mem_to_finset,\n        function.mem_support, not_iff_not],\n      conv_lhs { rw ← subtype.coe_inj },\n      rw [decompose'_fun_apply, submodule.coe_zero], },\n    { apply funext, intro m, rw decompose'_fun_apply, },\n  end,\n  right_inv   := λ x,\n  begin\n    apply dfinsupp.ext, intro m, \n    rw ← subtype.coe_inj, \n    rw decompose'_fun_apply, \n    change (weighted_homogeneous_component R w m) ((direct_sum.coe_linear_map (weighted_homogeneous_submodule R w)) x) = ↑(x m), \n    rw direct_sum.coe_linear_map_eq_dfinsupp_sum, \n    rw dfinsupp.sum,\n    rw map_sum, \n    rw finset.sum_eq_single m,\n    { rw weighted_homogeneous_component_of_weighted_homogeneous_polynomial_same,\n      exact (x m).prop,  },\n    { intros n hn hmn, \n      rw weighted_homogeneous_component_of_weighted_homogeneous_polynomial_other,\n      exact (x n).prop,\n      exact ne.symm hmn, },\n    { intro hm, rw dfinsupp.not_mem_support_iff at hm, \n      simp only [hm, submodule.coe_zero, map_zero], },\n  end }\n\n/-- mv_polynomial as a graded algebra, for an arbitrary weight -/\ndef mv_polynomial_weighted_graded_algebra \n  [decidable_eq σ] [decidable_eq R] : \n  graded_algebra (weighted_homogeneous_submodule R w) :=\n{ to_decomposition  := mv_polynomial_weighted_decomposition R w,\n  to_graded_monoid  := infer_instance, }\n\nend mv_polynomial\n\nend weighted_homogeneous\n\n#exit --Unused draft below\n\n\n/- import algebra.free_algebra\nimport algebra.ring_quot\nimport algebra.triv_sq_zero_ext\nimport algebra.algebra.operations\nimport linear_algebra.multilinear.basic\nimport ring_theory.graded_algebra.basic\nimport ring_theory.tensor_product\n\nimport divided_powers.basic\nimport divided_powers.ideal_add\nimport ..weighted_homogeneous -- PR #17855\n -/\n\nsection\n/- Here, the goal is to define a graded_algebra structure on mv_polynomial with respect to a given degree map… \nFor the moment, I am stuck. -/\n\nvariables (R : Type*) [semiring R] \nvariables (ι : Type*) [decidable_eq ι]\n  {M : ι → Type* } [Π (i : ι), add_comm_monoid (M i)] [Π (i : ι), module R (M i)]\nvariables {N : Type*} [add_comm_monoid N] [module R N]\n\nlemma yala \n  (g : Π (i : ι), N →ₗ[R] M i) \n  (hg : ∀ n, {i | g i n ≠ 0}.finite) \n  (h : Π (i : ι), M i →ₗ[R] N) (n : N) :\n  (direct_sum.to_module R ι N h) (direct_sum.mk M (hg n).to_finset (λ i, g i n)) = finsum (λ i, h i (g i n)) :=\nbegin\n  classical,\n  suffices : (function.support ((λ (i : ι), (h i) ((g i) n)) ∘ plift.down)).finite, \n  let s := { i | g i n ≠ 0},\n  unfold finsum, \n  rw dif_pos this,\n\n  unfold direct_sum.mk,dsimp,\nend\n\nexample (f : ℕ →+ ℕ) (a : ι →₀ ℕ) :\n  f (finsupp.sum a (λ i m, m)) =\n  finsupp.sum (finsupp.map_range f (f.map_zero) a) (λ i m, m)\n:= \nbegin\n  rw map_finsupp_sum, \n  rw finsupp.sum_map_range_index, \n  intro i, refl, \nend\n\nexample (f : ℕ →+ ℕ) (a : ι → ℕ) (ha : (function.support a).finite):\n  f (finsum a) = finsum (λ i, f (a i)) := add_monoid_hom.map_finsum f ha\n\n#check yala\n\n\nend\n\n\n/-! \nThe divided power algebra of a module -/\n\nopen finset mv_polynomial ring_quot\n\nsection graded_algebra\n/-  The mv_polynomial algebra with a degree, as a graded algebra -/\n\nnamespace mv_polynomial\n\nvariables {R M : Type*} [comm_semiring R] [add_comm_monoid M] [decidable_eq M]\n\nvariables {σ : Type*}\nvariable (w : σ → M)\n#check weighted_degree'\ndef w_degree : (σ →₀ ℕ) → M := λ p, finsupp.sum p (λ s n, n • (w s))\n\n/- def weighted_degrees' (w : σ → M) (s : finset (σ →₀ ℕ)) : \nfinset M := finset.image (weighted_degree' w) s -/\n\nlemma weighted_homogeneous_component_mem (w : σ → M) (φ : mv_polynomial σ R) (m : M) :\n  weighted_homogeneous_component w m φ ∈ weighted_homogeneous_submodule R w m :=\nbegin\n  rw mem_weighted_homogeneous_submodule, \n  exact weighted_homogeneous_component_is_weighted_homogeneous m φ, \nend\n\nexample (s : finset ℕ) : s = ∅ ↔ s ⊆ ∅ :=\nbegin\n  rw [← finset.bot_eq_empty, eq_bot_iff, le_iff_subset],\nend\n\nlemma decompose'_aux (φ : mv_polynomial σ R) (i : M) : \n  ite (i ∈ finset.image (weighted_degree' w) φ.support) ((weighted_homogeneous_component w i) φ) 0 = (weighted_homogeneous_component w i) φ :=\nbegin\n  split_ifs with hi hi, \n  refl,\n  apply symm,\n  apply weighted_homogeneous_component_eq_zero', \n  simp only [mem_image, mem_support_iff, ne.def, exists_prop, not_exists, not_and] at hi, \n  intros m hm, \n  apply hi m, \n  rw mem_support_iff at hm, \n  exact hm, \nend\n\nvariable (R)\n\n/-- The linear map from polynomials to the direct sum of the homogeneous components -/\ndef decompose' : mv_polynomial σ R →ₗ[R] direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i)) := {\nto_fun  := λ φ, direct_sum.mk \n  (λ (i : M), ↥(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) φ.support)\n  (λ m, ⟨weighted_homogeneous_component w m φ, weighted_homogeneous_component_mem w φ m⟩),\nmap_add'  := λ φ ψ,\nbegin\n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  dsimp,\n  rw ← subtype.coe_inj,\n  rw submodule.coe_add, \n  simp only [apply_ite coe, subtype.coe_mk, submodule.coe_zero],\n  simp only [decompose'_aux], \n  rw [map_add],\nend,\nmap_smul' := \nbegin\n  intros a φ, \n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  dsimp,\n  rw ← subtype.coe_inj,\n  rw submodule.coe_smul, \n  simp only [apply_ite coe, subtype.coe_mk, submodule.coe_zero],\n  simp only [decompose'_aux], rw [map_smul],\nend }\n\n#check decompose'\n\ndef decompose'_fun : mv_polynomial σ R → direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i)) := λ φ, direct_sum.mk \n  (λ (i : M), ↥(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) φ.support)\n  (λ m, ⟨weighted_homogeneous_component w m φ, weighted_homogeneous_component_mem w φ m⟩)\nfintype\nlemma decompose'_fun_coe_apply (φ : mv_polynomial σ R) (m : M) : (decompose'_fun R w φ m : mv_polynomial σ R) = weighted_homogeneous_component w m φ := \nbegin\n  simp only [decompose'_fun],\n--   simp only [direct_sum.mk, dfinsupp.mk_apply],\n  simp only [direct_sum.mk, subtype.coe_mk, add_monoid_hom.coe_mk, dfinsupp.mk_apply, apply_dite coe, dite_eq_ite],\n  exact decompose'_aux w φ m, \nend\n\nlemma decompose'_add' : ∀ (φ ψ : mv_polynomial σ R), decompose'_fun R w (φ + ψ) = decompose'_fun R w φ + decompose'_fun R w ψ :=\nbegin\n  intros φ ψ,\n  simp only [decompose'_fun],\n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  simp only [add_monoid_hom.coe_mk, dfinsupp.mk_apply],\n  dsimp, \n  rw ← subtype.coe_inj,\n  rw submodule.coe_add, \n  simp only [apply_dite coe, subtype.coe_mk, submodule.coe_zero, dite_eq_ite],\n  simp only [decompose'_aux], \n  rw [map_add],\nend\n\nlemma decompose'_map_zero' : decompose'_fun R w 0 = 0 := \nbegin\n  simp only [decompose'_fun],\n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i,\n  simp only [mem_image, mem_support_iff, coeff_zero, ne.def, eq_self_iff_true, not_true, is_empty.exists_iff, exists_false,\n  not_false_iff, add_monoid_hom.coe_mk, dfinsupp.mk_apply, dif_neg, direct_sum.zero_apply],\nend\n\nlemma direct_sum_one_coeffs (i : M) : \n  (((1 : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))) i) : mv_polynomial σ R) \n  = ite (i = 0) (1 : mv_polynomial σ R) (0 : mv_polynomial σ R) :=\nbegin\n  conv_lhs { dsimp [has_one.one], }, \n  split_ifs,\n  rw h,\n  rw direct_sum.of_eq_same,\n  refl,\n  rw direct_sum.of_eq_of_ne,\n  refl,\n  exact ne.symm h,\nend\n\nlemma decompose'_map_one' : decompose'_fun R w 1 = 1 := \nbegin\n  classical,\n  simp only [decompose'_fun],\n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i,\n  simp only [subtype.coe_mk, add_monoid_hom.coe_mk, dfinsupp.mk_apply],\n  rw ← subtype.coe_inj,\n  simp only [apply_dite coe, subtype.coe_mk, submodule.coe_zero, dite_eq_ite],\n  simp only [decompose'_aux], \n\n  rw direct_sum_one_coeffs, \n  rw weighted_homogeneous_component_weighted_homogeneous_polynomial,\n  swap,\n  apply is_weighted_homogeneous_one,\n  by_cases hi : i = 0,\n  rw [if_pos, if_pos], exact hi, exact hi,\n  rw [if_neg hi, if_neg], exact hi,\nend\n\nlemma decompose'_map_mul' : ∀ (φ ψ : mv_polynomial σ R), decompose'_fun R w (φ * ψ) = decompose'_fun R w φ * decompose'_fun R w ψ :=\nbegin\nsorry,\nend\n\n/-- The alg_hom map from polynomials to the direct sum of the homogeneous components -/\ndef decompose'a : mv_polynomial σ R →ₐ[R] direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i)) := {\nto_fun  := λ φ, direct_sum.mk \n  (λ (i : M), ↥(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) φ.support)\n  (λ m, ⟨weighted_homogeneous_component w m φ, weighted_homogeneous_component_mem w φ m⟩),\nmap_add'  := decompose'_add' R w, \n/- map_smul' := \nbegin\n  intros a φ, \n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  dsimp,\n  rw ← subtype.coe_inj,\n  rw submodule.coe_smul, \n  simp only [apply_ite coe, subtype.coe_mk, submodule.coe_zero],\n  simp only [decompose'_aux], rw [map_smul],\nend, -/\nmap_mul'  := \nbegin\n  intros φ ψ,\n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  -- dsimp,\n  rw ← subtype.coe_inj,\n  sorry,\n  /- \n  rw submodule.coe_mul, \n  simp only [apply_ite coe, subtype.coe_mk, submodule.coe_zero],\n  simp only [decompose'_aux], rw [map_mul], -/\nend, \nmap_one'  := decompose'_map_one' R w, \nmap_zero' := decompose'_map_zero' R w,\ncommutes' := sorry }\n\n/- Better approach : this will work! -/\nlemma is_internal_direct_sum_of_weighted_homogeneous_submodules : \n  direct_sum.is_internal (weighted_homogeneous_submodule R w) := \nbegin\n  classical,\n  split,\n  { -- injectivity\n    intros p q,\n    intro hpq,\n    rw mv_polynomial.ext_iff  at hpq, \n    ext, \n    specialize hpq m, \n    rw [← direct_sum.sum_support_of _ p, ← direct_sum.sum_support_of _ q ] at hpq, \n    simp only [map_sum, direct_sum.coe_add_monoid_hom_of, mv_polynomial.coeff_sum] at hpq,\n    by_cases hi : weighted_degree' w m = i,\n    { suffices this : ∀ (x : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))) (c : M), c ≠ i → coeff m ((x c) : mv_polynomial σ R) = 0,\n      suffices this' : ∀ (x : direct_sum M (λ (i : M), ↥(weighted_homogeneous_submodule R w i))), \n      i ∉ dfinsupp.support x → coeff m ((x i) : mv_polynomial σ R) = 0,\n      rw [finset.sum_eq_single i, finset.sum_eq_single i] at hpq, \n      exact hpq,\n      exact λ b hb, this q b,\n      exact this' q,\n      exact λ b hb, this p b,\n      exact this' p,\n      { intros x hx, \n        simp only [dfinsupp.mem_support_to_fun, not_not] at hx, rw hx, \n        exact mv_polynomial.coeff_zero m, },\n      { intros x b hbi,\n        apply is_weighted_homogeneous.coeff_eq_zero _ m,\n        rw hi,\n        exact ne.symm hbi,\n        rw ← mem_weighted_homogeneous_submodule,\n        exact (x b).prop, } },\n    rw is_weighted_homogeneous.coeff_eq_zero (p i).prop m hi,\n    rw is_weighted_homogeneous.coeff_eq_zero (q i).prop m hi, },\n  { -- surjectivity \n    intro φ,\n    use decompose'_fun R w φ,\n    conv_lhs { rw ← direct_sum.sum_support_of _ (decompose'_fun R w φ) },\n    simp only [map_sum, direct_sum.coe_add_monoid_hom_of],\n    simp_rw decompose'_fun_coe_apply, \n\n    conv_rhs { rw ← sum_weighted_homogeneous_component w φ}, \n    rw finsum_eq_sum _ (weighted_homogeneous_component_finsupp φ),\n    apply congr_arg2 _ _ rfl, \n    ext m,\n    rw [dfinsupp.mem_support_to_fun, ne.def, set.finite.mem_to_finset, function.mem_support, not_iff_not], \n    conv_lhs { rw [← subtype.coe_inj, decompose'_fun_coe_apply, submodule.coe_zero], } },\nend\n\n\ndef graded_polynomial_algebra : graded_algebra \n(weighted_homogeneous_submodule R w) := graded_algebra.of_alg_hom (weighted_homogeneous_submodule R w) (decompose'a R w) (sorry) (sorry) \n\n\nend mv_polynomial\n\nend graded_algebra", "meta": {"author": "AntoineChambert-Loir", "repo": "divided_powers", "sha": "86b6f8716590d38e63ed11d34c0140de8ae2af7d", "save_path": "github-repos/lean/AntoineChambert-Loir-divided_powers", "path": "github-repos/lean/AntoineChambert-Loir-divided_powers/divided_powers-86b6f8716590d38e63ed11d34c0140de8ae2af7d/src/graded_algebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4616962167268292}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Johannes Hölzl, Sander Dahmen, Scott Morrison\n-/\nimport linear_algebra.dfinsupp\nimport linear_algebra.std_basis\nimport linear_algebra.isomorphisms\nimport set_theory.cofinality\nimport linear_algebra.invariant_basis_number\n\n/-!\n# Dimension of modules and vector spaces\n\n## Main definitions\n\n* The rank of a module is defined as `module.rank : cardinal`.\n  This is defined as the supremum of the cardinalities of linearly independent subsets.\n\n* The rank of a linear map is defined as the rank of its range.\n\n## Main statements\n\n* `linear_map.dim_le_of_injective`: the source of an injective linear map has dimension\n  at most that of the target.\n* `linear_map.dim_le_of_surjective`: the target of a surjective linear map has dimension\n  at most that of that source.\n* `basis_fintype_of_finite_spans`:\n  the existence of a finite spanning set implies that any basis is finite.\n* `infinite_basis_le_maximal_linear_independent`:\n  if `b` is an infinite basis for a module `M`,\n  and `s` is a maximal linearly independent set,\n  then the cardinality of `b` is bounded by the cardinality of `s`.\n\nFor modules over rings satisfying the rank condition\n\n* `basis.le_span`:\n  the cardinality of a basis is bounded by the cardinality of any spanning set\n\nFor modules over rings satisfying the strong rank condition\n\n* `linear_independent_le_span`:\n  For any linearly independent family `v : ι → M`\n  and any finite spanning set `w : set M`,\n  the cardinality of `ι` is bounded by the cardinality of `w`.\n* `linear_independent_le_basis`:\n  If `b` is a basis for a module `M`,\n  and `s` is a linearly independent set,\n  then the cardinality of `s` is bounded by the cardinality of `b`.\n\nFor modules over rings with invariant basis number\n(including all commutative rings and all noetherian rings)\n\n* `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same\n  cardinality.\n\nFor vector spaces (i.e. modules over a field), we have\n\n* `dim_quotient_add_dim`: if `V₁` is a submodule of `V`, then\n  `module.rank (V/V₁) + module.rank V₁ = module.rank V`.\n* `dim_range_add_dim_ker`: the rank-nullity theorem.\n\n## Implementation notes\n\nThere is a naming discrepancy: most of the theorem names refer to `dim`,\neven though the definition is of `module.rank`.\nThis reflects that `module.rank` was originally called `dim`, and only defined for vector spaces.\n\nMany theorems in this file are not universe-generic when they relate dimensions\nin different universes. They should be as general as they can be without\ninserting `lift`s. The types `V`, `V'`, ... all live in different universes,\nand `V₁`, `V₂`, ... all live in the same universe.\n-/\n\nnoncomputable theory\n\nuniverses u v v' v'' u₁' w w'\n\nvariables {K : Type u} {V V₁ V₂ V₃ : Type v} {V' V'₁ : Type v'} {V'' : Type v''}\nvariables {ι : Type w} {ι' : Type w'} {η : Type u₁'} {φ : η → Type*}\n\nopen_locale classical big_operators cardinal\n\nopen basis submodule function set\n\nsection module\n\nsection\nvariables [semiring K] [add_comm_monoid V] [module K V]\ninclude K\n\nvariables (K V)\n\n/-- The rank of a module, defined as a term of type `cardinal`.\n\nWe define this as the supremum of the cardinalities of linearly independent subsets.\n\nFor a free module over any ring satisfying the strong rank condition\n(e.g. left-noetherian rings, commutative rings, and in particular division rings and fields),\nthis is the same as the dimension of the space (i.e. the cardinality of any basis).\n\nIn particular this agrees with the usual notion of the dimension of a vector space.\n\nThe definition is marked as protected to avoid conflicts with `_root_.rank`,\nthe rank of a linear map.\n-/\nprotected def module.rank : cardinal :=\ncardinal.sup.{v v} (λ ι : {s : set V // linear_independent K (coe : s → V)}, #ι.1)\n\nend\n\nsection\nvariables {R : Type u} [ring R]\nvariables {M : Type v} [add_comm_group M] [module R M]\nvariables {M' : Type v'} [add_comm_group M'] [module R M']\nvariables {M₁ : Type v} [add_comm_group M₁] [module R M₁]\n\ntheorem linear_map.lift_dim_le_of_injective (f : M →ₗ[R] M') (i : injective f) :\n  cardinal.lift.{v'} (module.rank R M) ≤ cardinal.lift.{ v} (module.rank R M') :=\nbegin\n  dsimp [module.rank],\n  fapply cardinal.lift_sup_le_lift_sup',\n  { rintro ⟨s, li⟩,\n    use f '' s,\n    convert (li.map' f (linear_map.ker_eq_bot.mpr i)).comp\n      (equiv.set.image ⇑f s i).symm (equiv.injective _),\n    ext ⟨-, ⟨x, ⟨h, rfl⟩⟩⟩,\n    simp, },\n  { rintro ⟨s, li⟩,\n    exact cardinal.lift_mk_le'.mpr ⟨(equiv.set.image f s i).to_embedding⟩, }\nend\n\ntheorem linear_map.dim_le_of_injective (f : M →ₗ[R] M₁) (i : injective f) :\n  module.rank R M ≤ module.rank R M₁ :=\ncardinal.lift_le.1 (f.lift_dim_le_of_injective i)\n\ntheorem dim_le {n : ℕ}\n  (H : ∀ s : finset M, linear_independent R (λ i : s, (i : M)) → s.card ≤ n) :\n  module.rank R M ≤ n :=\nbegin\n  apply cardinal.sup_le.mpr,\n  rintro ⟨s, li⟩,\n  exact linear_independent_bounded_of_finset_linear_independent_bounded H _ li,\nend\n\nlemma lift_dim_range_le (f : M →ₗ[R] M') :\n  cardinal.lift.{v} (module.rank R f.range) ≤ cardinal.lift.{v'} (module.rank R M) :=\nbegin\n  dsimp [module.rank],\n  apply cardinal.lift_sup_le,\n  rintro ⟨s, li⟩,\n  apply le_trans,\n  swap 2,\n  apply cardinal.lift_le.mpr,\n  refine (cardinal.le_sup _ ⟨range_splitting f '' s, _⟩),\n  { apply linear_independent.of_comp f.range_restrict,\n    convert li.comp (equiv.set.range_splitting_image_equiv f s) (equiv.injective _) using 1, },\n  { exact (cardinal.lift_mk_eq'.mpr ⟨equiv.set.range_splitting_image_equiv f s⟩).ge, },\nend\n\nlemma dim_range_le (f : M →ₗ[R] M₁) : module.rank R f.range ≤ module.rank R M :=\nby simpa using lift_dim_range_le f\n\nlemma lift_dim_map_le (f : M →ₗ[R] M') (p : submodule R M) :\n  cardinal.lift.{v} (module.rank R (p.map f)) ≤ cardinal.lift.{v'} (module.rank R p) :=\nbegin\n  have h := lift_dim_range_le (f.comp (submodule.subtype p)),\n  rwa [linear_map.range_comp, range_subtype] at h,\nend\n\nlemma dim_map_le (f : M →ₗ[R] M₁) (p : submodule R M) : module.rank R (p.map f) ≤ module.rank R p :=\nby simpa using lift_dim_map_le f p\n\nlemma dim_le_of_submodule (s t : submodule R M) (h : s ≤ t) :\n  module.rank R s ≤ module.rank R t :=\n(of_le h).dim_le_of_injective $ assume ⟨x, hx⟩ ⟨y, hy⟩ eq,\n  subtype.eq $ show x = y, from subtype.ext_iff_val.1 eq\n\n/-- Two linearly equivalent vector spaces have the same dimension, a version with different\nuniverses. -/\ntheorem linear_equiv.lift_dim_eq (f : M ≃ₗ[R] M') :\n  cardinal.lift.{v'} (module.rank R M) = cardinal.lift.{v} (module.rank R M') :=\nbegin\n  apply le_antisymm,\n  { exact f.to_linear_map.lift_dim_le_of_injective f.injective, },\n  { exact f.symm.to_linear_map.lift_dim_le_of_injective f.symm.injective, },\nend\n\n/-- Two linearly equivalent vector spaces have the same dimension. -/\ntheorem linear_equiv.dim_eq (f : M ≃ₗ[R] M₁) :\n  module.rank R M = module.rank R M₁ :=\ncardinal.lift_inj.1 f.lift_dim_eq\n\nlemma dim_eq_of_injective (f : M →ₗ[R] M₁) (h : injective f) :\n  module.rank R M = module.rank R f.range :=\n(linear_equiv.of_injective f h).dim_eq\n\n/-- Pushforwards of submodules along a `linear_equiv` have the same dimension. -/\nlemma linear_equiv.dim_map_eq (f : M ≃ₗ[R] M₁) (p : submodule R M) :\n  module.rank R (p.map (f : M →ₗ[R] M₁)) = module.rank R p :=\n(f.of_submodule p).dim_eq.symm\n\nvariables (R M)\n\n@[simp] lemma dim_top : module.rank R (⊤ : submodule R M) = module.rank R M :=\nbegin\n  have : (⊤ : submodule R M) ≃ₗ[R] M := linear_equiv.of_top ⊤ rfl,\n  rw this.dim_eq,\nend\n\nvariables {R M}\n\nlemma dim_range_of_surjective (f : M →ₗ[R] M') (h : surjective f) :\n  module.rank R f.range = module.rank R M' :=\nby rw [linear_map.range_eq_top.2 h, dim_top]\n\nlemma dim_submodule_le (s : submodule R M) : module.rank R s ≤ module.rank R M :=\nbegin\n  rw ←dim_top R M,\n  exact dim_le_of_submodule _ _ le_top,\nend\n\nlemma linear_map.dim_le_of_surjective (f : M →ₗ[R] M₁) (h : surjective f) :\n  module.rank R M₁ ≤ module.rank R M :=\nbegin\n  rw ←dim_range_of_surjective f h,\n  apply dim_range_le,\nend\n\ntheorem dim_quotient_le (p : submodule R M) :\n  module.rank R (M ⧸ p) ≤ module.rank R M :=\n(mkq p).dim_le_of_surjective (surjective_quot_mk _)\n\nvariables [nontrivial R]\n\nlemma {m} cardinal_lift_le_dim_of_linear_independent\n  {ι : Type w} {v : ι → M} (hv : linear_independent R v) :\n  cardinal.lift.{(max v m)} (#ι) ≤ cardinal.lift.{(max w m)} (module.rank R M) :=\nbegin\n  apply le_trans,\n  { exact cardinal.lift_mk_le.mpr\n      ⟨(equiv.of_injective _ hv.injective).to_embedding⟩, },\n  { simp only [cardinal.lift_le],\n    apply le_trans,\n    swap,\n    exact cardinal.le_sup _ ⟨range v, hv.coe_range⟩,\n    exact le_refl _, },\nend\n\nlemma cardinal_lift_le_dim_of_linear_independent'\n  {ι : Type w} {v : ι → M} (hv : linear_independent R v) :\n  cardinal.lift.{v} (#ι) ≤ cardinal.lift.{w} (module.rank R M) :=\ncardinal_lift_le_dim_of_linear_independent.{u v w 0} hv\n\nlemma cardinal_le_dim_of_linear_independent\n  {ι : Type v} {v : ι → M} (hv : linear_independent R v) :\n  #ι ≤ module.rank R M :=\nby simpa using cardinal_lift_le_dim_of_linear_independent hv\n\nlemma cardinal_le_dim_of_linear_independent'\n  {s : set M} (hs : linear_independent R (λ x, x : s → M)) :\n  #s ≤ module.rank R M :=\ncardinal_le_dim_of_linear_independent hs\n\nvariables (R M)\n\n@[simp] lemma dim_punit : module.rank R punit = 0 :=\nbegin\n  apply le_bot_iff.mp,\n  apply cardinal.sup_le.mpr,\n  rintro ⟨s, li⟩,\n  apply le_bot_iff.mpr,\n  apply cardinal.mk_emptyc_iff.mpr,\n  simp only [subtype.coe_mk],\n  by_contradiction h,\n  have ne : s.nonempty := ne_empty_iff_nonempty.mp h,\n  simpa using linear_independent.ne_zero (⟨_, ne.some_mem⟩ : s) li,\nend\n\n@[simp] lemma dim_bot : module.rank R (⊥ : submodule R M) = 0 :=\nbegin\n  have : (⊥ : submodule R M) ≃ₗ[R] punit := bot_equiv_punit,\n  rw [this.dim_eq, dim_punit],\nend\n\nvariables {R M}\n\n/--\nOver any nontrivial ring, the existence of a finite spanning set implies that any basis is finite.\n-/\n-- One might hope that a finite spanning set implies that any linearly independent set is finite.\n-- While this is true over a division ring\n-- (simply because any linearly independent set can be extended to a basis),\n-- I'm not certain what more general statements are possible.\ndef basis_fintype_of_finite_spans (w : set M) [fintype w] (s : span R w = ⊤)\n  {ι : Type w} (b : basis ι R M) : fintype ι :=\nbegin\n  -- We'll work by contradiction, assuming `ι` is infinite.\n  apply fintype_of_not_infinite _,\n  introI i,\n  -- Let `S` be the union of the supports of `x ∈ w` expressed as linear combinations of `b`.\n  -- This is a finite set since `w` is finite.\n  let S : finset ι := finset.univ.sup (λ x : w, (b.repr x).support),\n  let bS : set M := b '' S,\n  have h : ∀ x ∈ w, x ∈ span R bS,\n  { intros x m,\n    rw [←b.total_repr x, finsupp.span_image_eq_map_total, submodule.mem_map],\n    use b.repr x,\n    simp only [and_true, eq_self_iff_true, finsupp.mem_supported],\n    change (b.repr x).support ≤ S,\n    convert (finset.le_sup (by simp : (⟨x, m⟩ : w) ∈ finset.univ)),\n    refl, },\n  -- Thus this finite subset of the basis elements spans the entire module.\n  have k : span R bS = ⊤ := eq_top_iff.2 (le_trans s.ge (span_le.2 h)),\n\n  -- Now there is some `x : ι` not in `S`, since `ι` is infinite.\n  obtain ⟨x, nm⟩ := infinite.exists_not_mem_finset S,\n  -- However it must be in the span of the finite subset,\n  have k' : b x ∈ span R bS, { rw k, exact mem_top, },\n  -- giving the desire contradiction.\n  refine b.linear_independent.not_mem_span_image _ k',\n  exact nm,\nend\n\n/--\nOver any ring `R`, if `b` is a basis for a module `M`,\nand `s` is a maximal linearly independent set,\nthen the union of the supports of `x ∈ s` (when written out in the basis `b`) is all of `b`.\n-/\n-- From [Les familles libres maximales d'un module ont-elles le meme cardinal?][lazarus1973]\nlemma union_support_maximal_linear_independent_eq_range_basis\n  {ι : Type w} (b : basis ι R M)\n  {κ : Type w'} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  (⋃ k, ((b.repr (v k)).support : set ι)) = univ :=\nbegin\n  -- If that's not the case,\n  by_contradiction h,\n  simp only [←ne.def, ne_univ_iff_exists_not_mem, mem_Union, not_exists_not,\n    finsupp.mem_support_iff, finset.mem_coe] at h,\n  -- We have some basis element `b b'` which is not in the support of any of the `v i`.\n  obtain ⟨b', w⟩ := h,\n  -- Using this, we'll construct a linearly independent family strictly larger than `v`,\n  -- by also using this `b b'`.\n  let v' : option κ → M := λ o, o.elim (b b') v,\n  have r : range v ⊆ range v',\n  { rintro - ⟨k, rfl⟩,\n    use some k,\n    refl, },\n  have r' : b b' ∉ range v,\n  { rintro ⟨k, p⟩,\n    simpa [w] using congr_arg (λ m, (b.repr m) b') p, },\n  have r'' : range v ≠ range v',\n  { intro e,\n    have p : b b' ∈ range v', { use none, refl, },\n    rw ←e at p,\n    exact r' p, },\n  have inj' : injective v',\n  { rintros (_|k) (_|k) z,\n    { refl, },\n    { exfalso, exact r' ⟨k, z.symm⟩, },\n    { exfalso, exact r' ⟨k, z⟩, },\n    { congr, exact i.injective z, }, },\n  -- The key step in the proof is checking that this strictly larger family is linearly independent.\n  have i' : linear_independent R (coe : range v' → M),\n  { rw [linear_independent_subtype_range inj', linear_independent_iff],\n    intros l z,\n    rw [finsupp.total_option] at z,\n    simp only [v', option.elim] at z,\n    change _ + finsupp.total κ M R v l.some = 0 at z,\n    -- We have some linear combination of `b b'` and the `v i`, which we want to show is trivial.\n    -- We'll first show the coefficient of `b b'` is zero,\n    -- by expressing the `v i` in the basis `b`, and using that the `v i` have no `b b'` term.\n    have l₀ : l none = 0,\n    { rw ←eq_neg_iff_add_eq_zero at z,\n      replace z := eq_neg_of_eq_neg z,\n      apply_fun (λ x, b.repr x b') at z,\n      simp only [repr_self, linear_equiv.map_smul, mul_one, finsupp.single_eq_same, pi.neg_apply,\n        finsupp.smul_single', linear_equiv.map_neg, finsupp.coe_neg] at z,\n      erw finsupp.congr_fun (finsupp.apply_total R (b.repr : M →ₗ[R] ι →₀ R) v l.some) b' at z,\n      simpa [finsupp.total_apply, w] using z, },\n    -- Then all the other coefficients are zero, because `v` is linear independent.\n    have l₁ : l.some = 0,\n    { rw [l₀, zero_smul, zero_add] at z,\n      exact linear_independent_iff.mp i _ z, },\n    -- Finally we put those facts together to show the linear combination is trivial.\n    ext (_|a),\n    { simp only [l₀, finsupp.coe_zero, pi.zero_apply], },\n    { erw finsupp.congr_fun l₁ a,\n      simp only [finsupp.coe_zero, pi.zero_apply], }, },\n  dsimp [linear_independent.maximal] at m,\n  specialize m (range v') i' r,\n  exact r'' m,\nend\n\n/--\nOver any ring `R`, if `b` is an infinite basis for a module `M`,\nand `s` is a maximal linearly independent set,\nthen the cardinality of `b` is bounded by the cardinality of `s`.\n-/\nlemma infinite_basis_le_maximal_linear_independent'\n  {ι : Type w} (b : basis ι R M) [infinite ι]\n  {κ : Type w'} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  cardinal.lift.{w'} (#ι) ≤ cardinal.lift.{w} (#κ) :=\nbegin\n  let Φ := λ k : κ, (b.repr (v k)).support,\n  have w₁ : #ι ≤ #(set.range Φ),\n  { apply cardinal.le_range_of_union_finset_eq_top,\n    exact union_support_maximal_linear_independent_eq_range_basis b v i m, },\n  have w₂ :\n    cardinal.lift.{w'} (#(set.range Φ)) ≤ cardinal.lift.{w} (#κ) :=\n    cardinal.mk_range_le_lift,\n  exact (cardinal.lift_le.mpr w₁).trans w₂,\nend\n\n/--\nOver any ring `R`, if `b` is an infinite basis for a module `M`,\nand `s` is a maximal linearly independent set,\nthen the cardinality of `b` is bounded by the cardinality of `s`.\n-/\n-- (See `infinite_basis_le_maximal_linear_independent'` for the more general version\n-- where the index types can live in different universes.)\nlemma infinite_basis_le_maximal_linear_independent\n  {ι : Type w} (b : basis ι R M) [infinite ι]\n  {κ : Type w} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  #ι ≤ #κ :=\ncardinal.lift_le.mp (infinite_basis_le_maximal_linear_independent' b v i m)\n\nlemma complete_lattice.independent.subtype_ne_bot_le_rank [no_zero_smul_divisors R M]\n  {V : ι → submodule R M} (hV : complete_lattice.independent V) :\n  cardinal.lift.{v} (#{i : ι // V i ≠ ⊥}) ≤ cardinal.lift.{w} (module.rank R M) :=\nbegin\n  set I := {i : ι // V i ≠ ⊥},\n  have hI : ∀ i : I, ∃ v ∈ V i, v ≠ (0:M),\n  { intros i,\n    rw ← submodule.ne_bot_iff,\n    exact i.prop },\n  choose v hvV hv using hI,\n  have : linear_independent R v,\n  { exact (hV.comp _ subtype.coe_injective).linear_independent _ hvV hv },\n  exact cardinal_lift_le_dim_of_linear_independent' this\nend\n\nend\n\nsection rank_zero\n\nvariables {R : Type u} {M : Type v}\nvariables [ring R] [nontrivial R] [add_comm_group M] [module R M] [no_zero_smul_divisors R M]\n\nlemma dim_zero_iff_forall_zero : module.rank R M = 0 ↔ ∀ x : M, x = 0 :=\nbegin\n  refine ⟨λ h, _, λ h, _⟩,\n  { contrapose! h,\n    obtain ⟨x, hx⟩ := h,\n    suffices : 1 ≤ module.rank R M,\n    { intro h, exact lt_irrefl _ (lt_of_lt_of_le cardinal.zero_lt_one (h ▸ this)) },\n    suffices : linear_independent R (λ (y : ({x} : set M)), ↑y),\n    { simpa using (cardinal_le_dim_of_linear_independent this), },\n    exact linear_independent_singleton hx },\n  { have : (⊤ : submodule R M) = ⊥,\n    { ext x, simp [h x] },\n    rw [←dim_top, this, dim_bot] }\nend\n\nlemma dim_zero_iff : module.rank R M = 0 ↔ subsingleton M :=\ndim_zero_iff_forall_zero.trans (subsingleton_iff_forall_eq 0).symm\n\nlemma dim_pos_iff_exists_ne_zero : 0 < module.rank R M ↔ ∃ x : M, x ≠ 0 :=\nbegin\n  rw ←not_iff_not,\n  simpa using dim_zero_iff_forall_zero\nend\n\nlemma dim_pos_iff_nontrivial : 0 < module.rank R M ↔ nontrivial M :=\ndim_pos_iff_exists_ne_zero.trans (nontrivial_iff_exists_ne 0).symm\n\nlemma dim_pos [h : nontrivial M] : 0 < module.rank R M :=\ndim_pos_iff_nontrivial.2 h\n\nend rank_zero\n\nsection invariant_basis_number\n\nvariables {R : Type u} [ring R] [invariant_basis_number R]\nvariables {M : Type v} [add_comm_group M] [module R M]\n\n/-- The dimension theorem: if `v` and `v'` are two bases, their index types\nhave the same cardinalities. -/\ntheorem mk_eq_mk_of_basis (v : basis ι R M) (v' : basis ι' R M) :\n  cardinal.lift.{w'} (#ι) = cardinal.lift.{w} (#ι') :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  by_cases h : #ι < ω,\n  { -- `v` is a finite basis, so by `basis_fintype_of_finite_spans` so is `v'`.\n    haveI : fintype ι := (cardinal.lt_omega_iff_fintype.mp h).some,\n    haveI : fintype (range v) := set.fintype_range ⇑v,\n    haveI := basis_fintype_of_finite_spans _ v.span_eq v',\n    -- We clean up a little:\n    rw [cardinal.mk_fintype, cardinal.mk_fintype],\n    simp only [cardinal.lift_nat_cast, cardinal.nat_cast_inj],\n    -- Now we can use invariant basis number to show they have the same cardinality.\n    apply card_eq_of_lequiv R,\n    exact (((finsupp.linear_equiv_fun_on_fintype R R ι).symm.trans v.repr.symm) ≪≫ₗ\n      v'.repr) ≪≫ₗ (finsupp.linear_equiv_fun_on_fintype R R ι'), },\n  { -- `v` is an infinite basis,\n    -- so by `infinite_basis_le_maximal_linear_independent`, `v'` is at least as big,\n    -- and then applying `infinite_basis_le_maximal_linear_independent` again\n    -- we see they have the same cardinality.\n    simp only [not_lt] at h,\n    haveI : infinite ι := cardinal.infinite_iff.mpr h,\n    have w₁ :=\n      infinite_basis_le_maximal_linear_independent' v _ v'.linear_independent v'.maximal,\n    haveI : infinite ι' := cardinal.infinite_iff.mpr (begin\n      apply cardinal.lift_le.{w' w}.mp,\n      have p := (cardinal.lift_le.mpr h).trans w₁,\n      rw cardinal.lift_omega at ⊢ p,\n      exact p,\n    end),\n    have w₂ :=\n      infinite_basis_le_maximal_linear_independent' v' _ v.linear_independent v.maximal,\n    exact le_antisymm w₁ w₂, }\nend\n\n/-- Given two basis indexed by `ι` and `ι'` of an `R`-module, where `R` satisfies the invariant\nbasis number property, an equiv `ι ≃ ι' `. -/\ndef basis.index_equiv (v : basis ι R M) (v' : basis ι' R M) : ι ≃ ι' :=\nnonempty.some (cardinal.lift_mk_eq.1 (cardinal.lift_max.2 (mk_eq_mk_of_basis v v')))\n\ntheorem mk_eq_mk_of_basis' {ι' : Type w} (v : basis ι R M) (v' : basis ι' R M) :\n  #ι = #ι' :=\ncardinal.lift_inj.1 $ mk_eq_mk_of_basis v v'\n\nend invariant_basis_number\n\nsection rank_condition\n\nvariables {R : Type u} [ring R] [rank_condition R]\nvariables {M : Type v} [add_comm_group M] [module R M]\n\n/--\nAn auxiliary lemma for `basis.le_span`.\n\nIf `R` satisfies the rank condition,\nthen for any finite basis `b : basis ι R M`,\nand any finite spanning set `w : set M`,\nthe cardinality of `ι` is bounded by the cardinality of `w`.\n-/\nlemma basis.le_span'' {ι : Type*} [fintype ι] (b : basis ι R M)\n  {w : set M} [fintype w] (s : span R w = ⊤) :\n  fintype.card ι ≤ fintype.card w :=\nbegin\n  -- We construct an surjective linear map `(w → R) →ₗ[R] (ι → R)`,\n  -- by expressing a linear combination in `w` as a linear combination in `ι`.\n  fapply card_le_of_surjective' R,\n  { exact b.repr.to_linear_map.comp (finsupp.total w M R coe), },\n  { apply surjective.comp,\n   apply linear_equiv.surjective,\n   rw [←linear_map.range_eq_top, finsupp.range_total],\n   simpa using s, },\nend\n\n/--\nAnother auxiliary lemma for `basis.le_span`, which does not require assuming the basis is finite,\nbut still assumes we have a finite spanning set.\n-/\nlemma basis_le_span' {ι : Type*} (b : basis ι R M)\n  {w : set M} [fintype w] (s : span R w = ⊤) :\n  #ι ≤ fintype.card w :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  haveI := basis_fintype_of_finite_spans w s b,\n  rw cardinal.mk_fintype ι,\n  simp only [cardinal.nat_cast_le],\n  exact basis.le_span'' b s,\nend\n\n/--\nIf `R` satisfies the rank condition,\nthen the cardinality of any basis is bounded by the cardinality of any spanning set.\n-/\n-- Note that if `R` satisfies the strong rank condition,\n-- this also follows from `linear_independent_le_span` below.\ntheorem basis.le_span {J : set M} (v : basis ι R M)\n   (hJ : span R J = ⊤) : #(range v) ≤ #J :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  casesI fintype_or_infinite J,\n  { rw [←cardinal.lift_le, cardinal.mk_range_eq_of_injective v.injective, cardinal.mk_fintype J],\n    convert cardinal.lift_le.{w v}.2 (basis_le_span' v hJ),\n    simp, },\n  { have := cardinal.mk_range_eq_of_injective v.injective,\n    let S : J → set ι := λ j, ↑(v.repr j).support,\n    let S' : J → set M := λ j, v '' S j,\n    have hs : range v ⊆ ⋃ j, S' j,\n    { intros b hb,\n      rcases mem_range.1 hb with ⟨i, hi⟩,\n      have : span R J ≤ comap v.repr.to_linear_map (finsupp.supported R R (⋃ j, S j)) :=\n        span_le.2 (λ j hj x hx, ⟨_, ⟨⟨j, hj⟩, rfl⟩, hx⟩),\n      rw hJ at this,\n      replace : v.repr (v i) ∈ (finsupp.supported R R (⋃ j, S j)) := this trivial,\n      rw [v.repr_self, finsupp.mem_supported,\n        finsupp.support_single_ne_zero one_ne_zero] at this,\n      { subst b,\n        rcases mem_Union.1 (this (finset.mem_singleton_self _)) with ⟨j, hj⟩,\n        exact mem_Union.2 ⟨j, (mem_image _ _ _).2 ⟨i, hj, rfl⟩⟩ },\n      { apply_instance } },\n    refine le_of_not_lt (λ IJ, _),\n    suffices : #(⋃ j, S' j) < #(range v),\n    { exact not_le_of_lt this ⟨set.embedding_of_subset _ _ hs⟩ },\n    refine lt_of_le_of_lt (le_trans cardinal.mk_Union_le_sum_mk\n      (cardinal.sum_le_sum _ (λ _, ω) _)) _,\n    { exact λ j, le_of_lt (cardinal.lt_omega_iff_finite.2 $ (finset.finite_to_set _).image _) },\n    { simpa } },\nend\n\nend rank_condition\n\nsection strong_rank_condition\n\nvariables {R : Type u} [ring R] [strong_rank_condition R]\nvariables {M : Type v} [add_comm_group M] [module R M]\n\nopen submodule\n\n-- An auxiliary lemma for `linear_independent_le_span'`,\n-- with the additional assumption that the linearly independent family is finite.\nlemma linear_independent_le_span_aux'\n  {ι : Type*} [fintype ι] (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v ≤ span R w) :\n  fintype.card ι ≤ fintype.card w :=\nbegin\n  -- We construct an injective linear map `(ι → R) →ₗ[R] (w → R)`,\n  -- by thinking of `f : ι → R` as a linear combination of the finite family `v`,\n  -- and expressing that (using the axiom of choice) as a linear combination over `w`.\n  -- We can do this linearly by constructing the map on a basis.\n  fapply card_le_of_injective' R,\n  { apply finsupp.total,\n    exact λ i, span.repr R w ⟨v i, s (mem_range_self i)⟩, },\n  { intros f g h,\n    apply_fun finsupp.total w M R coe at h,\n    simp only [finsupp.total_total, submodule.coe_mk, span.finsupp_total_repr] at h,\n    rw [←sub_eq_zero, ←linear_map.map_sub] at h,\n    exact sub_eq_zero.mp (linear_independent_iff.mp i _ h), },\nend\n\n/--\nIf `R` satisfies the strong rank condition,\nthen any linearly independent family `v : ι → M`\ncontained in the span of some finite `w : set M`,\nis itself finite.\n-/\ndef linear_independent_fintype_of_le_span_fintype\n  {ι : Type*} (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v ≤ span R w) : fintype ι :=\nfintype_of_finset_card_le (fintype.card w) (λ t, begin\n  let v' := λ x : (t : set ι), v x,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have s' : range v' ≤ span R w := (range_comp_subset_range _ _).trans s,\n  simpa using linear_independent_le_span_aux' v' i' w s',\nend)\n\n/--\nIf `R` satisfies the strong rank condition,\nthen for any linearly independent family `v : ι → M`\ncontained in the span of some finite `w : set M`,\nthe cardinality of `ι` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span' {ι : Type*} (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v ≤ span R w) :\n  #ι ≤ fintype.card w :=\nbegin\n  haveI : fintype ι := linear_independent_fintype_of_le_span_fintype v i w s,\n  rw cardinal.mk_fintype,\n  simp only [cardinal.nat_cast_le],\n  exact linear_independent_le_span_aux' v i w s,\nend\n\n/--\nIf `R` satisfies the strong rank condition,\nthen for any linearly independent family `v : ι → M`\nand any finite spanning set `w : set M`,\nthe cardinality of `ι` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span {ι : Type*} (v : ι → M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : span R w = ⊤) :\n  #ι ≤ fintype.card w :=\nbegin\n  apply linear_independent_le_span' v i w,\n  rw s,\n  exact le_top,\nend\n\n/-- A linearly-independent family of vectors in a module over a ring satisfying the strong rank\ncondition must be finite if the module is Noetherian. -/\nnoncomputable def fintype_of_is_noetherian_linear_independent [is_noetherian R M]\n  {v : ι → M} (hi : linear_independent R v) : fintype ι :=\nbegin\n  have hfg : (⊤ : submodule R M).fg,\n  { exact is_noetherian_def.mp infer_instance ⊤, },\n  rw submodule.fg_def at hfg,\n  choose s hs hs' using hfg,\n  haveI : fintype s := hs.fintype,\n  apply linear_independent_fintype_of_le_span_fintype v hi s,\n  simp only [hs', set.subset_univ, submodule.top_coe, set.le_eq_subset],\nend\n\n/-- A linearly-independent subset of a module over a ring satisfying the strong rank condition\nmust be finite if the module is Noetherian. -/\nlemma finite_of_is_noetherian_linear_independent [is_noetherian R M]\n  {s : set M} (hi : linear_independent R (coe : s → M)) : s.finite :=\n⟨fintype_of_is_noetherian_linear_independent hi⟩\n\n/--\nAn auxiliary lemma for `linear_independent_le_basis`:\nwe handle the case where the basis `b` is infinite.\n-/\nlemma linear_independent_le_infinite_basis\n  {ι : Type*} (b : basis ι R M) [infinite ι]\n  {κ : Type*} (v : κ → M) (i : linear_independent R v) :\n  #κ ≤ #ι :=\nbegin\n  by_contradiction,\n  rw [not_le, ← cardinal.mk_finset_eq_mk ι] at h,\n  let Φ := λ k : κ, (b.repr (v k)).support,\n  obtain ⟨s, w : infinite ↥(Φ ⁻¹' {s})⟩ := cardinal.exists_infinite_fiber Φ h (by apply_instance),\n  let v' := λ k : Φ ⁻¹' {s}, v k,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have w' : fintype (Φ ⁻¹' {s}),\n  { apply linear_independent_fintype_of_le_span_fintype v' i' (s.image b),\n    rintros m ⟨⟨p,⟨rfl⟩⟩,rfl⟩,\n    simp only [set_like.mem_coe, subtype.coe_mk, finset.coe_image],\n    apply basis.mem_span_repr_support, },\n  exactI w.false,\nend\n\n/--\nOver any ring `R` satisfying the strong rank condition,\nif `b` is a basis for a module `M`,\nand `s` is a linearly independent set,\nthen the cardinality of `s` is bounded by the cardinality of `b`.\n-/\nlemma linear_independent_le_basis\n  {ι : Type*} (b : basis ι R M)\n  {κ : Type*} (v : κ → M) (i : linear_independent R v) :\n  #κ ≤ #ι :=\nbegin\n  -- We split into cases depending on whether `ι` is infinite.\n  cases fintype_or_infinite ι; resetI,\n  { -- When `ι` is finite, we have `linear_independent_le_span`,\n    rw cardinal.mk_fintype ι,\n    haveI : nontrivial R := nontrivial_of_invariant_basis_number R,\n    rw fintype.card_congr (equiv.of_injective b b.injective),\n    exact linear_independent_le_span v i (range b) b.span_eq, },\n  { -- and otherwise we have `linear_indepedent_le_infinite_basis`.\n    exact linear_independent_le_infinite_basis b v i, },\nend\n\n/-- In an `n`-dimensional space, the rank is at most `m`. -/\nlemma basis.card_le_card_of_linear_independent_aux\n  {R : Type*} [ring R] [strong_rank_condition R]\n  (n : ℕ) {m : ℕ} (v : fin m → fin n → R) :\n  linear_independent R v → m ≤ n :=\nλ h, by simpa using (linear_independent_le_basis (pi.basis_fun R (fin n)) v h)\n\n/--\nOver any ring `R` satisfying the strong rank condition,\nif `b` is an infinite basis for a module `M`,\nthen every maximal linearly independent set has the same cardinality as `b`.\n\nThis proof (along with some of the lemmas above) comes from\n[Les familles libres maximales d'un module ont-elles le meme cardinal?][lazarus1973]\n-/\n-- When the basis is not infinite this need not be true!\nlemma maximal_linear_independent_eq_infinite_basis\n  {ι : Type*} (b : basis ι R M) [infinite ι]\n  {κ : Type*} (v : κ → M) (i : linear_independent R v) (m : i.maximal) :\n  #κ = #ι :=\nbegin\n  apply le_antisymm,\n  { exact linear_independent_le_basis b v i, },\n  { haveI : nontrivial R := nontrivial_of_invariant_basis_number R,\n    exact infinite_basis_le_maximal_linear_independent b v i m, }\nend\n\ntheorem basis.mk_eq_dim'' {ι : Type v} (v : basis ι R M) :\n  #ι = module.rank R M :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  apply le_antisymm,\n  { transitivity,\n    swap,\n    apply cardinal.le_sup,\n    exact ⟨set.range v, by { convert v.reindex_range.linear_independent, ext, simp }⟩,\n    exact (cardinal.mk_range_eq v v.injective).ge, },\n  { apply cardinal.sup_le.mpr,\n    rintro ⟨s, li⟩,\n    apply linear_independent_le_basis v _ li, },\nend\n\n-- By this stage we want to have a complete API for `module.rank`,\n-- so we set it `irreducible` here, to keep ourselves honest.\nattribute [irreducible] module.rank\n\ntheorem basis.mk_range_eq_dim (v : basis ι R M) :\n  #(range v) = module.rank R M :=\nv.reindex_range.mk_eq_dim''\n\n/-- If a vector space has a finite basis, then its dimension (seen as a cardinal) is equal to the\ncardinality of the basis. -/\nlemma dim_eq_card_basis {ι : Type w} [fintype ι] (h : basis ι R M) :\n  module.rank R M = fintype.card ι :=\nby {haveI := nontrivial_of_invariant_basis_number R,\n  rw [←h.mk_range_eq_dim, cardinal.mk_fintype, set.card_range_of_injective h.injective] }\n\nlemma basis.card_le_card_of_linear_independent {ι : Type*} [fintype ι]\n  (b : basis ι R M) {ι' : Type*} [fintype ι'] {v : ι' → M} (hv : linear_independent R v) :\n  fintype.card ι' ≤ fintype.card ι :=\nbegin\n  letI := nontrivial_of_invariant_basis_number R,\n  simpa [dim_eq_card_basis b, cardinal.mk_fintype] using\n    cardinal_lift_le_dim_of_linear_independent' hv\nend\n\nlemma basis.card_le_card_of_submodule (N : submodule R M) [fintype ι] (b : basis ι R M)\n  [fintype ι'] (b' : basis ι' R N) : fintype.card ι' ≤ fintype.card ι :=\nb.card_le_card_of_linear_independent (b'.linear_independent.map' N.subtype N.ker_subtype)\n\nlemma basis.card_le_card_of_le\n  {N O : submodule R M} (hNO : N ≤ O) [fintype ι] (b : basis ι R O) [fintype ι']\n  (b' : basis ι' R N) : fintype.card ι' ≤ fintype.card ι :=\nb.card_le_card_of_linear_independent\n  (b'.linear_independent.map' (submodule.of_le hNO) (N.ker_of_le O _))\n\ntheorem basis.mk_eq_dim (v : basis ι R M) :\n  cardinal.lift.{v} (#ι) = cardinal.lift.{w} (module.rank R M) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [←v.mk_range_eq_dim, cardinal.mk_range_eq_of_injective v.injective]\nend\n\ntheorem {m} basis.mk_eq_dim' (v : basis ι R M) :\n  cardinal.lift.{(max v m)} (#ι) = cardinal.lift.{(max w m)} (module.rank R M) :=\nby simpa using v.mk_eq_dim\n\n/-- If a module has a finite dimension, all bases are indexed by a finite type. -/\nlemma basis.nonempty_fintype_index_of_dim_lt_omega {ι : Type*}\n  (b : basis ι R M) (h : module.rank R M < ω) :\n  nonempty (fintype ι) :=\nby rwa [← cardinal.lift_lt, ← b.mk_eq_dim,\n        -- ensure `omega` has the correct universe\n        cardinal.lift_omega, ← cardinal.lift_omega.{u_1 v},\n        cardinal.lift_lt, cardinal.lt_omega_iff_fintype] at h\n\n/-- If a module has a finite dimension, all bases are indexed by a finite type. -/\nnoncomputable def basis.fintype_index_of_dim_lt_omega {ι : Type*}\n  (b : basis ι R M) (h : module.rank R M < ω) :\n  fintype ι :=\nclassical.choice (b.nonempty_fintype_index_of_dim_lt_omega h)\n\n/-- If a module has a finite dimension, all bases are indexed by a finite set. -/\nlemma basis.finite_index_of_dim_lt_omega {ι : Type*} {s : set ι}\n  (b : basis s R M) (h : module.rank R M < ω) :\n  s.finite :=\nfinite_def.2 (b.nonempty_fintype_index_of_dim_lt_omega h)\n\nlemma dim_span {v : ι → M} (hv : linear_independent R v) :\n  module.rank R ↥(span R (range v)) = #(range v) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [←cardinal.lift_inj, ← (basis.span hv).mk_eq_dim,\n    cardinal.mk_range_eq_of_injective (@linear_independent.injective ι R M v _ _ _ _ hv)]\nend\n\nlemma dim_span_set {s : set M} (hs : linear_independent R (λ x, x : s → M)) :\n  module.rank R ↥(span R s) = #s :=\nby { rw [← @set_of_mem_eq _ s, ← subtype.range_coe_subtype], exact dim_span hs }\n\n/-- If `N` is a submodule in a free, finitely generated module,\ndo induction on adjoining a linear independent element to a submodule. -/\ndef submodule.induction_on_rank [is_domain R] [fintype ι] (b : basis ι R M)\n  (P : submodule R M → Sort*) (ih : ∀ (N : submodule R M),\n    (∀ (N' ≤ N) (x ∈ N), (∀ (c : R) (y ∈ N'), c • x + y = (0 : M) → c = 0) → P N') →\n    P N)\n  (N : submodule R M) : P N :=\nsubmodule.induction_on_rank_aux b P ih (fintype.card ι) N (λ s hs hli,\n  by simpa using b.card_le_card_of_linear_independent hli)\n\n/-- If `S` a finite-dimensional ring extension of `R` which is free as an `R`-module,\nthen the rank of an ideal `I` of `S` over `R` is the same as the rank of `S`.\n-/\nlemma ideal.rank_eq {R S : Type*} [comm_ring R] [strong_rank_condition R] [ring S] [is_domain S]\n  [algebra R S] {n m : Type*} [fintype n] [fintype m]\n  (b : basis n R S) {I : ideal S} (hI : I ≠ ⊥) (c : basis m R I) :\n  fintype.card m = fintype.card n :=\nbegin\n  obtain ⟨a, ha⟩ := submodule.nonzero_mem_of_bot_lt (bot_lt_iff_ne_bot.mpr hI),\n  have : linear_independent R (λ i, b i • a),\n  { have hb := b.linear_independent,\n    rw fintype.linear_independent_iff at ⊢ hb,\n    intros g hg,\n    apply hb g,\n    simp only [← smul_assoc, ← finset.sum_smul, smul_eq_zero] at hg,\n    exact hg.resolve_right ha },\n  exact le_antisymm\n    (b.card_le_card_of_linear_independent (c.linear_independent.map' (submodule.subtype I)\n      (linear_map.ker_eq_bot.mpr subtype.coe_injective)))\n    (c.card_le_card_of_linear_independent this),\nend\n\nvariables (R)\n\n@[simp] lemma dim_self : module.rank R R = 1 :=\nby rw [←cardinal.lift_inj, ← (basis.singleton punit R).mk_eq_dim, cardinal.mk_punit]\n\nend strong_rank_condition\n\nsection division_ring\nvariables [division_ring K] [add_comm_group V] [module K V] [add_comm_group V₁] [module K V₁]\nvariables {K V}\n\n/-- If a vector space has a finite dimension, the index set of `basis.of_vector_space` is finite. -/\nlemma basis.finite_of_vector_space_index_of_dim_lt_omega (h : module.rank K V < ω) :\n  (basis.of_vector_space_index K V).finite :=\nfinite_def.2 $ (basis.of_vector_space K V).nonempty_fintype_index_of_dim_lt_omega h\n\nvariables [add_comm_group V'] [module K V']\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ntheorem nonempty_linear_equiv_of_lift_dim_eq\n  (cond : cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V')) :\n  nonempty (V ≃ₗ[K] V') :=\nbegin\n  let B := basis.of_vector_space K V,\n  let B' := basis.of_vector_space K V',\n  have : cardinal.lift.{v' v} (#_) = cardinal.lift.{v v'} (#_),\n    by rw [B.mk_eq_dim'', cond, B'.mk_eq_dim''],\n  exact (cardinal.lift_mk_eq.{v v' 0}.1 this).map (B.equiv B')\nend\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ntheorem nonempty_linear_equiv_of_dim_eq (cond : module.rank K V = module.rank K V₁) :\n  nonempty (V ≃ₗ[K] V₁) :=\nnonempty_linear_equiv_of_lift_dim_eq $ congr_arg _ cond\n\nsection\n\nvariables (V V' V₁)\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ndef linear_equiv.of_lift_dim_eq\n  (cond : cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V')) :\n  V ≃ₗ[K] V' :=\nclassical.choice (nonempty_linear_equiv_of_lift_dim_eq cond)\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ndef linear_equiv.of_dim_eq (cond : module.rank K V = module.rank K V₁) : V ≃ₗ[K] V₁ :=\nclassical.choice (nonempty_linear_equiv_of_dim_eq cond)\n\nend\n\n/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/\ntheorem linear_equiv.nonempty_equiv_iff_lift_dim_eq :\n  nonempty (V ≃ₗ[K] V') ↔\n    cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V') :=\n⟨λ ⟨h⟩, linear_equiv.lift_dim_eq h, λ h, nonempty_linear_equiv_of_lift_dim_eq h⟩\n\n/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/\ntheorem linear_equiv.nonempty_equiv_iff_dim_eq :\n  nonempty (V ≃ₗ[K] V₁) ↔ module.rank K V = module.rank K V₁ :=\n⟨λ ⟨h⟩, linear_equiv.dim_eq h, λ h, nonempty_linear_equiv_of_dim_eq h⟩\n\n-- TODO how far can we generalise this?\n-- When `s` is finite, we could prove this for any ring satisfying the strong rank condition\n-- using `linear_independent_le_span'`\nlemma dim_span_le (s : set V) : module.rank K (span K s) ≤ #s :=\nbegin\n  obtain ⟨b, hb, hsab, hlib⟩ := exists_linear_independent K s,\n  convert cardinal.mk_le_mk_of_subset hb,\n  rw [← hsab, dim_span_set hlib]\nend\n\nlemma dim_span_of_finset (s : finset V) :\n  module.rank K (span K (↑s : set V)) < ω :=\ncalc module.rank K (span K (↑s : set V)) ≤ #(↑s : set V) : dim_span_le ↑s\n                             ... = s.card : by rw [finset.coe_sort_coe, cardinal.mk_finset]\n                             ... < ω : cardinal.nat_lt_omega _\n\ntheorem dim_prod : module.rank K (V × V₁) = module.rank K V + module.rank K V₁ :=\nbegin\n  let b := basis.of_vector_space K V,\n  let c := basis.of_vector_space K V₁,\n  rw [← cardinal.lift_inj,\n      ← (basis.prod b c).mk_eq_dim,\n      cardinal.lift_add, ← cardinal.mk_ulift,\n      ← b.mk_eq_dim, ← c.mk_eq_dim,\n      ← cardinal.mk_ulift, ← cardinal.mk_ulift,\n      cardinal.add_def (ulift _)],\n  exact cardinal.lift_inj.1 (cardinal.lift_mk_eq.2\n      ⟨equiv.ulift.trans (equiv.sum_congr equiv.ulift equiv.ulift).symm ⟩),\nend\n\nsection fintype\nvariable [fintype η]\nvariables [∀i, add_comm_group (φ i)] [∀i, module K (φ i)]\n\nopen linear_map\n\nlemma dim_pi : module.rank K (Πi, φ i) = cardinal.sum (λi, module.rank K (φ i)) :=\nbegin\n  let b := assume i, basis.of_vector_space K (φ i),\n  let this : basis (Σ j, _) K (Π j, φ j) := pi.basis b,\n  rw [← cardinal.lift_inj, ← this.mk_eq_dim],\n  simp [← (b _).mk_range_eq_dim]\nend\n\nlemma dim_fun {V η : Type u} [fintype η] [add_comm_group V] [module K V] :\n  module.rank K (η → V) = fintype.card η * module.rank K V :=\nby rw [dim_pi, cardinal.sum_const', cardinal.mk_fintype]\n\nlemma dim_fun_eq_lift_mul :\n  module.rank K (η → V) = (fintype.card η : cardinal.{max u₁' v}) *\n    cardinal.lift.{u₁'} (module.rank K V) :=\nby rw [dim_pi, cardinal.sum_const, cardinal.mk_fintype, cardinal.lift_nat_cast]\n\nlemma dim_fun' : module.rank K (η → K) = fintype.card η :=\nby rw [dim_fun_eq_lift_mul, dim_self, cardinal.lift_one, mul_one, cardinal.nat_cast_inj]\n\nlemma dim_fin_fun (n : ℕ) : module.rank K (fin n → K) = n :=\nby simp [dim_fun']\n\nend fintype\n\nend division_ring\n\nsection field\nvariables [field K] [add_comm_group V] [module K V] [add_comm_group V₁] [module K V₁]\nvariables [add_comm_group V'] [module K V']\nvariables {K V}\n\ntheorem dim_quotient_add_dim (p : submodule K V) :\n  module.rank K (V ⧸ p) + module.rank K p = module.rank K V :=\nby classical; exact let ⟨f⟩ := quotient_prod_linear_equiv p in dim_prod.symm.trans f.dim_eq\n\n/-- rank-nullity theorem -/\ntheorem dim_range_add_dim_ker (f : V →ₗ[K] V₁) :\n  module.rank K f.range + module.rank K f.ker = module.rank K V :=\nbegin\n  haveI := λ (p : submodule K V), classical.dec_eq (V ⧸ p),\n  rw [← f.quot_ker_equiv_range.dim_eq, dim_quotient_add_dim]\nend\n\nlemma dim_eq_of_surjective (f : V →ₗ[K] V₁) (h : surjective f) :\n  module.rank K V = module.rank K V₁ + module.rank K f.ker :=\nby rw [← dim_range_add_dim_ker f, ← dim_range_of_surjective f h]\n\nsection\nvariables [add_comm_group V₂] [module K V₂]\nvariables [add_comm_group V₃] [module K V₃]\nopen linear_map\n\n/-- This is mostly an auxiliary lemma for `dim_sup_add_dim_inf_eq`. -/\nlemma dim_add_dim_split\n  (db : V₂ →ₗ[K] V) (eb : V₃ →ₗ[K] V) (cd : V₁ →ₗ[K] V₂) (ce : V₁ →ₗ[K] V₃)\n  (hde : ⊤ ≤ db.range ⊔ eb.range)\n  (hgd : ker cd = ⊥)\n  (eq : db.comp cd = eb.comp ce)\n  (eq₂ : ∀d e, db d = eb e → (∃c, cd c = d ∧ ce c = e)) :\n  module.rank K V + module.rank K V₁ = module.rank K V₂ + module.rank K V₃ :=\nhave hf : surjective (coprod db eb),\nbegin\n  refine (range_eq_top.1 $ top_unique $ _),\n  rwa [← map_top, ← prod_top, map_coprod_prod, ←range_eq_map, ←range_eq_map]\nend,\nbegin\n  conv {to_rhs, rw [← dim_prod, dim_eq_of_surjective _ hf] },\n  congr' 1,\n  apply linear_equiv.dim_eq,\n  refine linear_equiv.of_bijective _ _ _,\n  { refine cod_restrict _ (prod cd (- ce)) _,\n    { assume c,\n      simp only [add_eq_zero_iff_eq_neg, linear_map.prod_apply, mem_ker,\n        coprod_apply, neg_neg, map_neg, neg_apply],\n      exact linear_map.ext_iff.1 eq c } },\n  { rw [← ker_eq_bot, ker_cod_restrict, ker_prod, hgd, bot_inf_eq] },\n  { rw [← range_eq_top, eq_top_iff, range_cod_restrict, ← map_le_iff_le_comap,\n      map_top, range_subtype],\n    rintros ⟨d, e⟩,\n    have h := eq₂ d (-e),\n    simp only [add_eq_zero_iff_eq_neg, linear_map.prod_apply, mem_ker, set_like.mem_coe,\n      prod.mk.inj_iff, coprod_apply, map_neg, neg_apply, linear_map.mem_range] at ⊢ h,\n    assume hde,\n    rcases h hde with ⟨c, h₁, h₂⟩,\n    refine ⟨c, h₁, _⟩,\n    rw [h₂, _root_.neg_neg] }\nend\n\nlemma dim_sup_add_dim_inf_eq (s t : submodule K V) :\n  module.rank K (s ⊔ t : submodule K V) + module.rank K (s ⊓ t : submodule K V) =\n    module.rank K s + module.rank K t :=\ndim_add_dim_split (of_le le_sup_left) (of_le le_sup_right) (of_le inf_le_left) (of_le inf_le_right)\n  begin\n    rw [← map_le_map_iff' (ker_subtype $ s ⊔ t), map_sup, map_top,\n      ← linear_map.range_comp, ← linear_map.range_comp, subtype_comp_of_le, subtype_comp_of_le,\n      range_subtype, range_subtype, range_subtype],\n    exact le_refl _\n  end\n  (ker_of_le _ _ _)\n  begin ext ⟨x, hx⟩, refl end\n  begin\n    rintros ⟨b₁, hb₁⟩ ⟨b₂, hb₂⟩ eq,\n    have : b₁ = b₂ := congr_arg subtype.val eq,\n    subst this,\n    exact ⟨⟨b₁, hb₁, hb₂⟩, rfl, rfl⟩\n  end\n\nlemma dim_add_le_dim_add_dim (s t : submodule K V) :\n  module.rank K (s ⊔ t : submodule K V) ≤ module.rank K s + module.rank K t :=\nby { rw [← dim_sup_add_dim_inf_eq], exact self_le_add_right _ _ }\n\nend\n\nlemma exists_mem_ne_zero_of_dim_pos {s : submodule K V} (h : 0 < module.rank K s) :\n  ∃ b : V, b ∈ s ∧ b ≠ 0 :=\nexists_mem_ne_zero_of_ne_bot $ assume eq, by rw [eq, dim_bot] at h; exact lt_irrefl _ h\n\nsection rank\n\n-- TODO This definition, and some of the results about it, could be generalized to arbitrary rings.\n/-- `rank f` is the rank of a `linear_map f`, defined as the dimension of `f.range`. -/\ndef rank (f : V →ₗ[K] V') : cardinal := module.rank K f.range\n\nlemma rank_le_domain (f : V →ₗ[K] V₁) : rank f ≤ module.rank K V :=\nby { rw [← dim_range_add_dim_ker f], exact self_le_add_right _ _ }\n\nlemma rank_le_range (f : V →ₗ[K] V₁) : rank f ≤ module.rank K V₁ :=\ndim_submodule_le _\n\nlemma rank_add_le (f g : V →ₗ[K] V') : rank (f + g) ≤ rank f + rank g :=\ncalc rank (f + g) ≤ module.rank K (f.range ⊔ g.range : submodule K V') :\n  begin\n    refine dim_le_of_submodule _ _ _,\n    exact (linear_map.range_le_iff_comap.2 $ eq_top_iff'.2 $\n      assume x, show f x + g x ∈ (f.range ⊔ g.range : submodule K V'), from\n        mem_sup.2 ⟨_, ⟨x, rfl⟩, _, ⟨x, rfl⟩, rfl⟩)\n  end\n  ... ≤ rank f + rank g : dim_add_le_dim_add_dim _ _\n\n@[simp] lemma rank_zero : rank (0 : V →ₗ[K] V') = 0 :=\nby rw [rank, linear_map.range_zero, dim_bot]\n\nlemma rank_finset_sum_le {η} (s : finset η) (f : η → V →ₗ[K] V') :\n  rank (∑ d in s, f d) ≤ ∑ d in s, rank (f d) :=\n@finset.sum_hom_rel _ _ _ _ _ (λa b, rank a ≤ b) f (λ d, rank (f d)) s (le_of_eq rank_zero)\n      (λ i g c h, le_trans (rank_add_le _ _) (add_le_add_left h _))\n\nvariables [add_comm_group V''] [module K V'']\n\nlemma rank_comp_le1 (g : V →ₗ[K] V') (f : V' →ₗ[K] V'') : rank (f.comp g) ≤ rank f :=\nbegin\n  refine dim_le_of_submodule _ _ _,\n  rw [linear_map.range_comp],\n  exact linear_map.map_le_range,\nend\n\nvariables [add_comm_group V'₁] [module K V'₁]\n\nlemma rank_comp_le2 (g : V →ₗ[K] V') (f : V' →ₗ[K] V'₁) : rank (f.comp g) ≤ rank g :=\nby rw [rank, rank, linear_map.range_comp]; exact dim_map_le _ _\n\nend rank\n\n-- TODO The remainder of this file could be generalized to arbitrary rings.\n\n\n/-- The `ι` indexed basis on `V`, where `ι` is an empty type and `V` is zero-dimensional.\n\nSee also `finite_dimensional.fin_basis`.\n-/\ndef basis.of_dim_eq_zero {ι : Type*} [is_empty ι] (hV : module.rank K V = 0) :\n  basis ι K V :=\nbegin\n  haveI : subsingleton V := dim_zero_iff.1 hV,\n  exact basis.empty _\nend\n\n@[simp] lemma basis.of_dim_eq_zero_apply {ι : Type*} [is_empty ι]\n  (hV : module.rank K V = 0) (i : ι) :\n  basis.of_dim_eq_zero hV i = 0 :=\nrfl\n\nlemma le_dim_iff_exists_linear_independent {c : cardinal} :\n  c ≤ module.rank K V ↔ ∃ s : set V, #s = c ∧ linear_independent K (coe : s → V) :=\nbegin\n  split,\n  { intro h,\n    let t := basis.of_vector_space K V,\n    rw [← t.mk_eq_dim'', cardinal.le_mk_iff_exists_subset] at h,\n    rcases h with ⟨s, hst, hsc⟩,\n    exact ⟨s, hsc, (of_vector_space_index.linear_independent K V).mono hst⟩ },\n  { rintro ⟨s, rfl, si⟩,\n    exact cardinal_le_dim_of_linear_independent si }\nend\n\nlemma le_dim_iff_exists_linear_independent_finset {n : ℕ} :\n  ↑n ≤ module.rank K V ↔\n    ∃ s : finset V, s.card = n ∧ linear_independent K (coe : (s : set V) → V) :=\nbegin\n  simp only [le_dim_iff_exists_linear_independent, cardinal.mk_eq_nat_iff_finset],\n  split,\n  { rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩,\n    exact ⟨t, rfl, si⟩ },\n  { rintro ⟨s, rfl, si⟩,\n    exact ⟨s, ⟨s, rfl, rfl⟩, si⟩ }\nend\n\nlemma le_rank_iff_exists_linear_independent {c : cardinal} {f : V →ₗ[K] V'} :\n  c ≤ rank f ↔\n  ∃ s : set V, cardinal.lift.{v'} (#s) = cardinal.lift.{v} c ∧\n    linear_independent K (λ x : s, f x) :=\nbegin\n  rcases f.range_restrict.exists_right_inverse_of_surjective f.range_range_restrict with ⟨g, hg⟩,\n  have fg : left_inverse f.range_restrict g, from linear_map.congr_fun hg,\n  refine ⟨λ h, _, _⟩,\n  { rcases le_dim_iff_exists_linear_independent.1 h with ⟨s, rfl, si⟩,\n    refine ⟨g '' s, cardinal.mk_image_eq_lift _ _ fg.injective, _⟩,\n    replace fg : ∀ x, f (g x) = x, by { intro x, convert congr_arg subtype.val (fg x) },\n    replace si : linear_independent K (λ x : s, f (g x)),\n      by simpa only [fg] using si.map' _ (ker_subtype _),\n    exact si.image_of_comp s g f },\n  { rintro ⟨s, hsc, si⟩,\n    have : linear_independent K (λ x : s, f.range_restrict x),\n      from linear_independent.of_comp (f.range.subtype) (by convert si),\n    convert cardinal_le_dim_of_linear_independent this.image,\n    rw [← cardinal.lift_inj, ← hsc, cardinal.mk_image_eq_of_inj_on_lift],\n    exact inj_on_iff_injective.2 this.injective }\nend\n\nlemma le_rank_iff_exists_linear_independent_finset {n : ℕ} {f : V →ₗ[K] V'} :\n  ↑n ≤ rank f ↔ ∃ s : finset V, s.card = n ∧ linear_independent K (λ x : (s : set V), f x) :=\nbegin\n  simp only [le_rank_iff_exists_linear_independent, cardinal.lift_nat_cast,\n    cardinal.lift_eq_nat_iff, cardinal.mk_eq_nat_iff_finset],\n  split,\n  { rintro ⟨s, ⟨t, rfl, rfl⟩, si⟩,\n    exact ⟨t, rfl, si⟩ },\n  { rintro ⟨s, rfl, si⟩,\n    exact ⟨s, ⟨s, rfl, rfl⟩, si⟩ }\nend\n\n/-- A vector space has dimension at most `1` if and only if there is a\nsingle vector of which all vectors are multiples. -/\nlemma dim_le_one_iff : module.rank K V ≤ 1 ↔ ∃ v₀ : V, ∀ v, ∃ r : K, r • v₀ = v :=\nbegin\n  let b := basis.of_vector_space K V,\n  split,\n  { intro hd,\n    rw [← b.mk_eq_dim'', cardinal.le_one_iff_subsingleton, subsingleton_coe] at hd,\n    rcases eq_empty_or_nonempty (of_vector_space_index K V) with hb | ⟨⟨v₀, hv₀⟩⟩,\n    { use 0,\n      have h' : ∀ v : V, v = 0, { simpa [hb, submodule.eq_bot_iff] using b.span_eq.symm },\n      intro v,\n      simp [h' v] },\n    { use v₀,\n      have h' : (K ∙ v₀) = ⊤, { simpa [hd.eq_singleton_of_mem hv₀] using b.span_eq },\n      intro v,\n      have hv : v ∈ (⊤ : submodule K V) := mem_top,\n      rwa [←h', mem_span_singleton] at hv } },\n  { rintros ⟨v₀, hv₀⟩,\n    have h : (K ∙ v₀) = ⊤,\n    { ext, simp [mem_span_singleton, hv₀] },\n    rw [←dim_top, ←h],\n    convert dim_span_le _,\n    simp }\nend\n\n/-- A submodule has dimension at most `1` if and only if there is a\nsingle vector in the submodule such that the submodule is contained in\nits span. -/\nlemma dim_submodule_le_one_iff (s : submodule K V) : module.rank K s ≤ 1 ↔ ∃ v₀ ∈ s, s ≤ K ∙ v₀ :=\nbegin\n  simp_rw [dim_le_one_iff, le_span_singleton_iff],\n  split,\n  { rintro ⟨⟨v₀, hv₀⟩, h⟩,\n    use [v₀, hv₀],\n    intros v hv,\n    obtain ⟨r, hr⟩ := h ⟨v, hv⟩,\n    use r,\n    simp_rw [subtype.ext_iff, coe_smul, submodule.coe_mk] at hr,\n    exact hr },\n  { rintro ⟨v₀, hv₀, h⟩,\n    use ⟨v₀, hv₀⟩,\n    rintro ⟨v, hv⟩,\n    obtain ⟨r, hr⟩ := h v hv,\n    use r,\n    simp_rw [subtype.ext_iff, coe_smul, submodule.coe_mk],\n    exact hr }\nend\n\n/-- A submodule has dimension at most `1` if and only if there is a\nsingle vector, not necessarily in the submodule, such that the\nsubmodule is contained in its span. -/\nlemma dim_submodule_le_one_iff' (s : submodule K V) : module.rank K s ≤ 1 ↔ ∃ v₀, s ≤ K ∙ v₀ :=\nbegin\n  rw dim_submodule_le_one_iff,\n  split,\n  { rintros ⟨v₀, hv₀, h⟩,\n    exact ⟨v₀, h⟩ },\n  { rintros ⟨v₀, h⟩,\n    by_cases hw : ∃ w : V, w ∈ s ∧ w ≠ 0,\n    { rcases hw with ⟨w, hw, hw0⟩,\n      use [w, hw],\n      rcases mem_span_singleton.1 (h hw) with ⟨r', rfl⟩,\n      have h0 : r' ≠ 0,\n      { rintro rfl,\n        simpa using hw0 },\n      rwa span_singleton_smul_eq _ h0 },\n    { push_neg at hw,\n      rw ←submodule.eq_bot_iff at hw,\n      simp [hw] } }\nend\n\nend field\n\nend module\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/linear_algebra/dimension.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4616962097407677}}
{"text": "import Duper.RuleM\nimport Duper.Selection\nimport Duper.Util.ProofReconstruction\n\nnamespace Duper\nopen RuleM\nopen Lean\nopen Meta\n\ninitialize Lean.registerTraceClass `Rule.clausifyPropEq\n\ntheorem c1_soundness {p : Prop} {q : Prop} (h : p = q) : (p = True) ∨ (q = False) := by\n  rw [h]\n  exact Classical.propComplete q\n\n/-  From a parent clause that has the literal p = q, we want to prove c which is identical to the parent clause except:\n    1. The literal p = q is removed from c\n    2. The literals p = True and q = False are appended to the end of c (in that order)\n-/\ndef mkC1Proof (i : Nat) (premises : List Expr) (parents : List ProofParent) (transferExprs : Array Expr) (c : Clause) : MetaM Expr := do\n  Meta.forallTelescope c.toForallExpr fun xs body => do\n    let cLits := c.lits.map (fun l => l.map (fun e => e.instantiateRev xs))\n    let (parentsLits, appliedPremises, transferExprs) ← instantiatePremises parents premises xs transferExprs\n    let parentLits := parentsLits[0]!\n    let appliedPremise := appliedPremises[0]!\n    let mut proofCases : Array Expr := Array.mkEmpty parentLits.size\n    for j in [:parentLits.size] do\n      let lit := parentLits[j]!\n      if j == i then\n        --lit has the form p = q and is the propositional equality that is currently being clausified\n        --We want to derive `p = q -> L_1 ∨ ... ∨ L_{n-1} ∨ L_n` by showing p = q -> L_{n-1} ∨ L_n where L_{n-1} is p = True and L_n = q = False\n        let proofCase ← Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let proofCase ← Meta.mkAppM ``c1_soundness #[h]\n          Meta.mkLambdaFVars #[h] $ ← orSubclause (cLits.map Lit.toExpr) 2 proofCase\n        proofCases := proofCases.push proofCase\n      else\n        --lit is not the propositional equality that is currently being clausified\n        let proofCase ← Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let idx := if j ≥ i then j - 1 else j\n          Meta.mkLambdaFVars #[h] $ ← orIntro (cLits.map Lit.toExpr) idx h\n        proofCases := proofCases.push proofCase\n    let r ← orCases (parentLits.map Lit.toExpr) proofCases\n    Meta.mkLambdaFVars xs $ mkApp r appliedPremise\n\ntheorem c2_soundness {p : Prop} {q : Prop} (h : p = q) : (p = False) ∨ (q = True) := by\n  rw [h]\n  cases Classical.propComplete q with\n  | inl q_true => exact Or.intro_right _ q_true\n  | inr q_false => exact Or.intro_left _ q_false\n\n/-  From a parent clause that has the literal p = q, we want to prove c which is identical to the parent clause except:\n    1. The literal p = q is removed from c\n    2. The literals p = False and q = True are appended to the end of c (in that order)\n-/\ndef mkC2Proof (i : Nat) (premises : List Expr) (parents : List ProofParent) (transferExprs : Array Expr) (c : Clause) : MetaM Expr :=\n  Meta.forallTelescope c.toForallExpr fun xs body => do\n    let cLits := c.lits.map (fun l => l.map (fun e => e.instantiateRev xs))\n    let (parentsLits, appliedPremises, transferExprs) ← instantiatePremises parents premises xs transferExprs\n    let parentLits := parentsLits[0]!\n    let appliedPremise := appliedPremises[0]!\n    let mut proofCases : Array Expr := Array.mkEmpty parentLits.size\n    for j in [:parentLits.size] do\n      let lit := parentLits[j]!\n      if j == i then\n        --lit has the form p = q and is the propositional equality that is currently being clausified\n        --We want to derive `p = q -> L_1 ∨ ... ∨ L_{n-1} ∨ L_n` by showing p = q -> L_{n-1} ∨ L_n where L_{n-1} is p = False and L_n = q = True\n        let proofCase ← Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let proofCase ← Meta.mkAppM ``c2_soundness #[h]\n          Meta.mkLambdaFVars #[h] $ ← orSubclause (cLits.map Lit.toExpr) 2 proofCase\n        proofCases := proofCases.push proofCase\n      else\n        --lit is not the propositional equality that is currently being clausified\n        let proofCase ← Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let idx := if j ≥ i then j - 1 else j\n          Meta.mkLambdaFVars #[h] $ ← orIntro (cLits.map Lit.toExpr) idx h\n        proofCases := proofCases.push proofCase\n    let r ← orCases (parentLits.map Lit.toExpr) proofCases\n    Meta.mkLambdaFVars xs $ mkApp r appliedPremise\n\ndef clausifyPropEq (given : Clause)(c : MClause) (cNum : Nat) : RuleM (Array ClauseStream) := do\n  trace[Rule.clausifyPropEq] \"ClausifyPropEq inferences with {c.lits}\"\n  let mut streams := #[]\n  for i in [:c.lits.size] do\n    let lit := c.lits[i]!\n    if lit.sign = true && lit.ty.isProp && litSelectedOrNothingSelected c i then\n      -- TODO: check both sides?\n      if ¬ lit.rhs.isConstOf ``True && ¬ lit.rhs.isConstOf ``False then\n        let c' := c.eraseLit i\n        let c1 := c'.appendLits #[Lit.fromSingleExpr lit.lhs true, Lit.fromSingleExpr lit.rhs false]\n        let c2 := c'.appendLits #[Lit.fromSingleExpr lit.lhs false, Lit.fromSingleExpr lit.rhs true]\n        trace[Rule.clausifyPropEq] \"clausifyPropEq called on {lit} in {c.lits} to produce {c1.lits} and {c2.lits}\"\n        let loaded ← getLoadedClauses\n        let ug ← unifierGenerator #[]\n        let yield1 := do\n          setLoadedClauses loaded\n          yieldClause c1 \"clausify Prop equality\" (mkProof := some (mkC1Proof i))\n        let yield2 := do\n          setLoadedClauses loaded\n          yieldClause c2 \"clausify Prop equality\" (mkProof := some (mkC2Proof i))\n        streams := streams.append #[ClauseStream.mk ug given yield1 \"clausify Prop equality\", ClauseStream.mk ug given yield2 \"clausify Prop equality\"]\n  return streams\n\nend Duper", "meta": {"author": "leanprover-community", "repo": "duper", "sha": "96b8f8383363e800976b0fa99830c1b5e8c19b09", "save_path": "github-repos/lean/leanprover-community-duper", "path": "github-repos/lean/leanprover-community-duper/duper-96b8f8383363e800976b0fa99830c1b5e8c19b09/Duper/Rules/ClausifyPropEq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4615930056269298}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Floris van Doorn, Mario Carneiro, Martin Dvorak\n\n! This file was ported from Lean 3 source module data.list.join\n! leanprover-community/mathlib commit be24ec5de6701447e5df5ca75400ffee19d65659\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.List.BigOperators.Basic\n\n/-!\n# Join of a list of lists\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves basic properties of `list.join`, which concatenates a list of lists. It is defined\nin [`data.list.defs`](./defs).\n-/\n\n\nvariable {α β : Type _}\n\nnamespace List\n\nattribute [simp] join\n\n#print List.join_singleton /-\n@[simp]\ntheorem join_singleton (l : List α) : [l].join = l := by rw [join, join, append_nil]\n#align list.join_singleton List.join_singleton\n-/\n\n#print List.join_eq_nil /-\n@[simp]\ntheorem join_eq_nil : ∀ {L : List (List α)}, join L = [] ↔ ∀ l ∈ L, l = []\n  | [] => iff_of_true rfl (forall_mem_nil _)\n  | l :: L => by simp only [join, append_eq_nil, join_eq_nil, forall_mem_cons]\n#align list.join_eq_nil List.join_eq_nil\n-/\n\n#print List.join_append /-\n@[simp]\ntheorem join_append (L₁ L₂ : List (List α)) : join (L₁ ++ L₂) = join L₁ ++ join L₂ := by\n  induction L₁ <;> [rfl, simp only [*, join, cons_append, append_assoc]]\n#align list.join_append List.join_append\n-/\n\n#print List.join_concat /-\ntheorem join_concat (L : List (List α)) (l : List α) : join (L.concat l) = join L ++ l := by simp\n#align list.join_concat List.join_concat\n-/\n\n/- warning: list.join_filter_empty_eq_ff -> List.join_filter_isEmpty_eq_false is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} α) (fun (l : List.{u1} α) => Eq.{1} Bool (List.isEmpty.{u1} α l) Bool.false)] {L : List.{u1} (List.{u1} α)}, Eq.{succ u1} (List.{u1} α) (List.join.{u1} α (List.filterₓ.{u1} (List.{u1} α) (fun (l : List.{u1} α) => Eq.{1} Bool (List.isEmpty.{u1} α l) Bool.false) (fun (a : List.{u1} α) => _inst_1 a) L)) (List.join.{u1} α L)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} α) (fun (l : List.{u1} α) => Eq.{1} Bool (List.isEmpty.{u1} α l) Bool.false)] {L : List.{u1} (List.{u1} α)}, Eq.{succ u1} (List.{u1} α) (List.join.{u1} α (List.filter.{u1} (List.{u1} α) (fun (a : List.{u1} α) => Decidable.decide (Eq.{1} Bool (List.isEmpty.{u1} α a) Bool.false) (_inst_1 a)) L)) (List.join.{u1} α L)\nCase conversion may be inaccurate. Consider using '#align list.join_filter_empty_eq_ff List.join_filter_isEmpty_eq_falseₓ'. -/\n@[simp]\ntheorem join_filter_isEmpty_eq_false [DecidablePred fun l : List α => l.Empty = false] :\n    ∀ {L : List (List α)}, join (L.filterₓ fun l => l.Empty = false) = L.join\n  | [] => rfl\n  | [] :: L => by simp [@join_filter_empty_eq_ff L]\n  | (a :: l) :: L => by simp [@join_filter_empty_eq_ff L]\n#align list.join_filter_empty_eq_ff List.join_filter_isEmpty_eq_false\n\n/- warning: list.join_filter_ne_nil -> List.join_filter_ne_nil is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} α) (fun (l : List.{u1} α) => Ne.{succ u1} (List.{u1} α) l (List.nil.{u1} α))] {L : List.{u1} (List.{u1} α)}, Eq.{succ u1} (List.{u1} α) (List.join.{u1} α (List.filterₓ.{u1} (List.{u1} α) (fun (l : List.{u1} α) => Ne.{succ u1} (List.{u1} α) l (List.nil.{u1} α)) (fun (a : List.{u1} α) => _inst_1 a) L)) (List.join.{u1} α L)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} α) (fun (l : List.{u1} α) => Ne.{succ u1} (List.{u1} α) l (List.nil.{u1} α))] {L : List.{u1} (List.{u1} α)}, Eq.{succ u1} (List.{u1} α) (List.join.{u1} α (List.filter.{u1} (List.{u1} α) (fun (a : List.{u1} α) => Decidable.decide (Ne.{succ u1} (List.{u1} α) a (List.nil.{u1} α)) (_inst_1 a)) L)) (List.join.{u1} α L)\nCase conversion may be inaccurate. Consider using '#align list.join_filter_ne_nil List.join_filter_ne_nilₓ'. -/\n@[simp]\ntheorem join_filter_ne_nil [DecidablePred fun l : List α => l ≠ []] {L : List (List α)} :\n    join (L.filterₓ fun l => l ≠ []) = L.join := by\n  simp [join_filter_empty_eq_ff, ← empty_iff_eq_nil]\n#align list.join_filter_ne_nil List.join_filter_ne_nil\n\n#print List.join_join /-\ntheorem join_join (l : List (List (List α))) : l.join.join = (l.map join).join :=\n  by\n  induction l\n  simp\n  simp [l_ih]\n#align list.join_join List.join_join\n-/\n\n#print List.length_join /-\n@[simp]\ntheorem length_join (L : List (List α)) : length (join L) = sum (map length L) := by\n  induction L <;> [rfl, simp only [*, join, map, sum_cons, length_append]]\n#align list.length_join List.length_join\n-/\n\n/- warning: list.length_bind -> List.length_bind is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} (l : List.{u1} α) (f : α -> (List.{u2} β)), Eq.{1} Nat (List.length.{u2} β (List.bind.{u1, u2} α β l f)) (List.sum.{0} Nat Nat.hasAdd Nat.hasZero (List.map.{u1, 0} α Nat (Function.comp.{succ u1, succ u2, 1} α (List.{u2} β) Nat (List.length.{u2} β) f) l))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} (l : List.{u2} α) (f : α -> (List.{u1} β)), Eq.{1} Nat (List.length.{u1} β (List.bind.{u2, u1} α β l f)) (List.sum.{0} Nat instAddNat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero) (List.map.{u2, 0} α Nat (Function.comp.{succ u2, succ u1, 1} α (List.{u1} β) Nat (List.length.{u1} β) f) l))\nCase conversion may be inaccurate. Consider using '#align list.length_bind List.length_bindₓ'. -/\n@[simp]\ntheorem length_bind (l : List α) (f : α → List β) :\n    length (List.bind l f) = sum (map (length ∘ f) l) := by rw [List.bind, length_join, map_map]\n#align list.length_bind List.length_bind\n\n/- warning: list.bind_eq_nil -> List.bind_eq_nil is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {l : List.{u1} α} {f : α -> (List.{u2} β)}, Iff (Eq.{succ u2} (List.{u2} β) (List.bind.{u1, u2} α β l f) (List.nil.{u2} β)) (forall (x : α), (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) -> (Eq.{succ u2} (List.{u2} β) (f x) (List.nil.{u2} β)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {l : List.{u2} α} {f : α -> (List.{u1} β)}, Iff (Eq.{succ u1} (List.{u1} β) (List.bind.{u2, u1} α β l f) (List.nil.{u1} β)) (forall (x : α), (Membership.mem.{u2, u2} α (List.{u2} α) (List.instMembershipList.{u2} α) x l) -> (Eq.{succ u1} (List.{u1} β) (f x) (List.nil.{u1} β)))\nCase conversion may be inaccurate. Consider using '#align list.bind_eq_nil List.bind_eq_nilₓ'. -/\n@[simp]\ntheorem bind_eq_nil {l : List α} {f : α → List β} : List.bind l f = [] ↔ ∀ x ∈ l, f x = [] :=\n  join_eq_nil.trans <| by\n    simp only [mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]\n#align list.bind_eq_nil List.bind_eq_nil\n\n#print List.take_sum_join /-\n/-- In a join, taking the first elements up to an index which is the sum of the lengths of the\nfirst `i` sublists, is the same as taking the join of the first `i` sublists. -/\ntheorem take_sum_join (L : List (List α)) (i : ℕ) :\n    L.join.take ((L.map length).take i).Sum = (L.take i).join :=\n  by\n  induction L generalizing i; · simp\n  cases i; · simp\n  simp [take_append, L_ih]\n#align list.take_sum_join List.take_sum_join\n-/\n\n#print List.drop_sum_join /-\n/-- In a join, dropping all the elements up to an index which is the sum of the lengths of the\nfirst `i` sublists, is the same as taking the join after dropping the first `i` sublists. -/\ntheorem drop_sum_join (L : List (List α)) (i : ℕ) :\n    L.join.drop ((L.map length).take i).Sum = (L.drop i).join :=\n  by\n  induction L generalizing i; · simp\n  cases i; · simp\n  simp [drop_append, L_ih]\n#align list.drop_sum_join List.drop_sum_join\n-/\n\n#print List.drop_take_succ_eq_cons_nthLe /-\n/-- Taking only the first `i+1` elements in a list, and then dropping the first `i` ones, one is\nleft with a list of length `1` made of the `i`-th element of the original list. -/\ntheorem drop_take_succ_eq_cons_nthLe (L : List α) {i : ℕ} (hi : i < L.length) :\n    (L.take (i + 1)).drop i = [nthLe L i hi] :=\n  by\n  induction L generalizing i\n  · simp only [length] at hi\n    exact (Nat.not_succ_le_zero i hi).elim\n  cases i\n  · simp\n  have : i < L_tl.length := by\n    simp at hi\n    exact Nat.lt_of_succ_lt_succ hi\n  simp [L_ih this]\n  rfl\n#align list.drop_take_succ_eq_cons_nth_le List.drop_take_succ_eq_cons_nthLe\n-/\n\n#print List.drop_take_succ_join_eq_nthLe /-\n/-- In a join of sublists, taking the slice between the indices `A` and `B - 1` gives back the\noriginal sublist of index `i` if `A` is the sum of the lenghts of sublists of index `< i`, and\n`B` is the sum of the lengths of sublists of index `≤ i`. -/\ntheorem drop_take_succ_join_eq_nthLe (L : List (List α)) {i : ℕ} (hi : i < L.length) :\n    (L.join.take ((L.map length).take (i + 1)).Sum).drop ((L.map length).take i).Sum =\n      nthLe L i hi :=\n  by\n  have : (L.map length).take i = ((L.take (i + 1)).map length).take i := by\n    simp [map_take, take_take]\n  simp [take_sum_join, this, drop_sum_join, drop_take_succ_eq_cons_nth_le _ hi]\n#align list.drop_take_succ_join_eq_nth_le List.drop_take_succ_join_eq_nthLe\n-/\n\n#print List.sum_take_map_length_lt1 /-\n/-- Auxiliary lemma to control elements in a join. -/\ntheorem sum_take_map_length_lt1 (L : List (List α)) {i j : ℕ} (hi : i < L.length)\n    (hj : j < (nthLe L i hi).length) :\n    ((L.map length).take i).Sum + j < ((L.map length).take (i + 1)).Sum := by\n  simp [hi, sum_take_succ, hj]\n#align list.sum_take_map_length_lt1 List.sum_take_map_length_lt1\n-/\n\n#print List.sum_take_map_length_lt2 /-\n/-- Auxiliary lemma to control elements in a join. -/\ntheorem sum_take_map_length_lt2 (L : List (List α)) {i j : ℕ} (hi : i < L.length)\n    (hj : j < (nthLe L i hi).length) : ((L.map length).take i).Sum + j < L.join.length :=\n  by\n  convert lt_of_lt_of_le (sum_take_map_length_lt1 L hi hj) (monotone_sum_take _ hi)\n  have : L.length = (L.map length).length := by simp\n  simp [this, -length_map]\n#align list.sum_take_map_length_lt2 List.sum_take_map_length_lt2\n-/\n\n#print List.nthLe_join /-\n/-- The `n`-th element in a join of sublists is the `j`-th element of the `i`th sublist,\nwhere `n` can be obtained in terms of `i` and `j` by adding the lengths of all the sublists\nof index `< i`, and adding `j`. -/\ntheorem nthLe_join (L : List (List α)) {i j : ℕ} (hi : i < L.length)\n    (hj : j < (nthLe L i hi).length) :\n    nthLe L.join (((L.map length).take i).Sum + j) (sum_take_map_length_lt2 L hi hj) =\n      nthLe (nthLe L i hi) j hj :=\n  by\n  rw [nth_le_take L.join (sum_take_map_length_lt2 L hi hj) (sum_take_map_length_lt1 L hi hj),\n    nth_le_drop, nth_le_of_eq (drop_take_succ_join_eq_nth_le L hi)]\n#align list.nth_le_join List.nthLe_join\n-/\n\n#print List.eq_iff_join_eq /-\n/-- Two lists of sublists are equal iff their joins coincide, as well as the lengths of the\nsublists. -/\ntheorem eq_iff_join_eq (L L' : List (List α)) :\n    L = L' ↔ L.join = L'.join ∧ map length L = map length L' :=\n  by\n  refine' ⟨fun H => by simp [H], _⟩\n  rintro ⟨join_eq, length_eq⟩\n  apply ext_le\n  · have : length (map length L) = length (map length L') := by rw [length_eq]\n    simpa using this\n  · intro n h₁ h₂\n    rw [← drop_take_succ_join_eq_nth_le, ← drop_take_succ_join_eq_nth_le, join_eq, length_eq]\n#align list.eq_iff_join_eq List.eq_iff_join_eq\n-/\n\n#print List.join_drop_length_sub_one /-\ntheorem join_drop_length_sub_one {L : List (List α)} (h : L ≠ []) :\n    (L.drop (L.length - 1)).join = L.getLast h :=\n  by\n  induction L using List.reverseRecOn\n  · cases h rfl\n  · simp\n#align list.join_drop_length_sub_one List.join_drop_length_sub_one\n-/\n\n#print List.append_join_map_append /-\n/-- We can rebracket `x ++ (l₁ ++ x) ++ (l₂ ++ x) ++ ... ++ (lₙ ++ x)` to\n`(x ++ l₁) ++ (x ++ l₂) ++ ... ++ (x ++ lₙ) ++ x` where `L = [l₁, l₂, ..., lₙ]`. -/\ntheorem append_join_map_append (L : List (List α)) (x : List α) :\n    x ++ (List.map (fun l => l ++ x) L).join = (List.map (fun l => x ++ l) L).join ++ x :=\n  by\n  induction L\n  · rw [map_nil, join, append_nil, map_nil, join, nil_append]\n  · rw [map_cons, join, map_cons, join, append_assoc, L_ih, append_assoc, append_assoc]\n#align list.append_join_map_append List.append_join_map_append\n-/\n\n#print List.reverse_join /-\n/-- Reversing a join is the same as reversing the order of parts and reversing all parts. -/\ntheorem reverse_join (L : List (List α)) :\n    L.join.reverse = (List.map List.reverse L).reverse.join :=\n  by\n  induction L\n  · rfl\n  · rw [join, reverse_append, L_ih, map_cons, reverse_cons', join_concat]\n#align list.reverse_join List.reverse_join\n-/\n\n#print List.join_reverse /-\n/-- Joining a reverse is the same as reversing all parts and reversing the joined result. -/\ntheorem join_reverse (L : List (List α)) :\n    L.reverse.join = (List.map List.reverse L).join.reverse := by\n  simpa [reverse_reverse] using congr_arg List.reverse (reverse_join L.reverse)\n#align list.join_reverse List.join_reverse\n-/\n\nend List\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/List/Join.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.626124191181315, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.46155256196406697}}
{"text": "import ground_zero.cubical.cubes\nopen ground_zero.cubical ground_zero.types ground_zero.HITs\nopen ground_zero.HITs.interval (i₀ i₁ seg)\n\n/-\n  * Coercions.\n  * Basic path lemmas: refl, symm, cong, funext...\n  * Connections.\n  * Singleton contractibility, J elimination rule.\n  * PathP.\n-/\n\nnamespace ground_zero.cubical\n\nnamespace Path\nuniverses u v\n\ndef coe.forward (π : I → Sort u) (i : I) (x : π i₀) : π i :=\ninterval.ind x (equiv.subst seg x) (equiv.path_over_subst eq.rfl) i\n\ndef coe.back (π : I → Sort u) (i : I) (x : π i₁) : π i :=\ninterval.ind (equiv.subst seg⁻¹ x) x (begin\n  apply equiv.path_over_subst, transitivity,\n  { symmetry, apply equiv.subst_comp }, transitivity,\n  { apply eq.map (λ p, equiv.subst p x), apply eq.inv_comp },\n  reflexivity\nend) i\n\ndef coe (i k : I) (π : I → Sort u) : π i → π k :=\ncoe.forward (λ i, π i → π k) i (coe.forward π k)\n\ndef coe_inv (i k : I) (π : I → Sort u) : π i → π k :=\ncoe.back (λ i, π i → π k) i (coe.back π k)\n\nnotation `coe⁻¹` := coe_inv\n\n@[refl] def refl {α : Sort u} (a : α) : a ⇝ a := <i> a\ndef rfl {α : Sort u} {a : α} : a ⇝ a := <i> a\n\n@[symm] def symm {α : Sort u} {a b : α} (p : a ⇝ b) : b ⇝ a :=\n<i> p # −i\npostfix `⁻¹` := symm\n\nabbreviation inv {α : Sort u} {a b : α} (p : a ⇝ b) := p⁻¹\n\nexample {α : Sort u} {a b : α} (p : a ⇝ b) : b ⇝ a :=\ncoe 1 0 (λ i, b ⇝ p # i) rfl\n\ndef funext {α : Sort u} {β : α → Sort v} {f g : Π (x : α), β x}\n  (p : Π (x : α), f x ⇝ g x) : f ⇝ g :=\n<i> λ x, p x # i\n\ndef cong {α : Sort u} {β : Sort v} {a b : α}\n  (f : α → β) (p : a ⇝ b) : f a ⇝ f b :=\n<i> f (p # i)\n\ndef ap {α : Sort u} {β : α → Sort v} {a b : α}\n  (f : α → β a) (p : a ⇝ b) : f a ⇝ f b :=\n<i> f (p # i)\n\ndef subst {α : Sort u} {π : α → Sort v} {a b : α}\n  (p : a ⇝ b) (x : π a) : π b :=\ncoe 0 1 (λ i, π (p # i)) x\n\nabbreviation transport {α : Sort u} (π : α → Sort v) {a b : α}\n  (p : a ⇝ b) : π a → π b := subst p\n\ndef trans {α β : Sort u} (p : α ⇝ β) : α → β :=\ncoe 0 1 (λ i, p # i)\nabbreviation coerce {α β : Sort u} : (α ⇝ β) → (α → β) := trans\n\ndef trans_neg {α β : Sort u} (p : α ⇝ β) : β → α :=\ncoe 1 0 (λ i, p # i)\n\ndef transK {α β : Sort u} (p : α ⇝ β) (x : α) :\n  x ⇝ trans_neg p (trans p x) :=\n<i> coe i 0 (λ i, p # i) (coe 0 i (λ i, p # i) x)\n\ndef idtoeqv {α β : Sort u} (p : α ⇝ β) : α ≃ β :=\ntrans (<i> α ≃ p # i) (equiv.id α)\n\ndef test_eta {α : Sort u} {a b : α} (p : a ⇝ b) : p ⇝ p := rfl\ndef face₀ {α : Sort u} {a b : α} (p : a ⇝ b) : α := p # 0\ndef face₁ {α : Sort u} {a b : α} (p : a ⇝ b) : α := p # 1\n\ndef comp_test₀ {α : Sort u} {a b : α} (p : a ⇝ b) : p # 0 ⇝ a := rfl\ndef comp_test₁ {α : Sort u} {a b : α} (p : a ⇝ b) : p # 1 ⇝ b := rfl\n\n-- fail\n--def symm_test {α : Type u} {a b : α} (p : a ⇝ b) : (p⁻¹)⁻¹ ⇝ p := rfl\n@[trans] def composition {α : Sort u} {a b c : α}\n  (p : a ⇝ b) (q : b ⇝ c) : a ⇝ c := subst q p\n\ninfix ⬝ := composition\n\n-- this will be replaced by a more general version in future\ndef kan {α : Sort u} {a b c d : α}\n  (bottom : b ⇝ c) (left : b ⇝ a) (right : c ⇝ d) : a ⇝ d :=\nleft⁻¹ ⬝ bottom ⬝ right\n\ndef kan_op {α : Sort u} {a b : α} (p : a ⇝ a) (q : a ⇝ b) : b ⇝ b :=\nkan p q q\n\ndef interval_contr (i : I) : i₀ ⇝ i := coe 0 i (λ i, i₀ ⇝ i) rfl\ndef seg_path : i₀ ⇝ i₁ := interval_contr i₁\n\n-- or too direct way\nexample : i₀ ⇝ i₁ := <i> i\n\ndef conn_and {α : Sort u} {a b : α} (p : a ⇝ b) :\n  LineP (λ i, a ⇝ p # i) :=\nλ i, <j> p # i ∧ j\n\ndef conn_or {α : Sort u} {a b : α} (p : a ⇝ b) :\n  LineP (λ i, p # i ⇝ b) :=\nλ i, <j> p # i ∨ j\n\ndef singl {α : Sort u} (a : α) :=\nΣ' (x : α), a ⇝ x\n\ndef eta {α : Sort u} (a : α) : singl a := ⟨a, refl a⟩\n\ndef refl_contr {α : Sort u} {a b : α} (p : a ⇝ b) :\n  LineP (λ i, a ⇝ p # i) :=\ninterval.hrec _ (refl a) p (begin\n  cases p with f, unfold refl,\n  apply heq.map, funext,\n  refine interval.prop_rec _ _ i,\n  { reflexivity },\n  { apply ground_zero.support.truncation,\n    apply eq.map, exact seg }\nend)\n\n/-\nThis doesn’t pass typechecking.\n\ndef J {α : Type u} {a : α} {π : Π (b : α), a ⇝ b → Type u}\n  (h : π a (refl a)) (b : α) (p : a ⇝ b) : π b (<i> p # i) :=\ncoe (λ i, π (p # i) (conn_and p i)) h i₁\n\ndef J {α : Type u} {a : α} {π : Π (b : α), a ⇝ b → Type u}\n  (h : π a (refl a)) (b : α) (p : a ⇝ b) : π b (<i> p # i) :=\ntransport (<i> π (p # i) (<j> p # i ∧ j)) h\n-/\n\ndef J {α : Sort u} {a : α} (π : Π (b : α), a ⇝ b → Sort v)\n  (h : π a (refl a)) {b : α} (p : a ⇝ b) : π b p :=\ntrans (<i> π (p # i) (refl_contr p i)) h\n\nend Path\n\ndef {u} PathP (σ : I → Sort u) (a : σ 0) (b : σ 1) :=\nPath (equiv.subst interval.seg a) b\n\ndef {u} PathP.lam (σ : I → Sort u) (f : Π i, σ i) : PathP σ (f 0) (f 1) :=\nPath.lam (interval.rec _ _ (equiv.apd f interval.seg))\n\nend ground_zero.cubical", "meta": {"author": "jfrancese", "repo": "lean", "sha": "06e7efaecce4093d97fb5ecc75479df2ef1dbbdb", "save_path": "github-repos/lean/jfrancese-lean", "path": "github-repos/lean/jfrancese-lean/lean-06e7efaecce4093d97fb5ecc75479df2ef1dbbdb/ground_zero/cubical/path.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4615414210827503}}
{"text": "/-\nCopyright (c) 2022 Abby J. Goldberg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Abby J. Goldberg, Mario Carneiro\n-/\nimport Mathlib.Tactic.Ring\n\n/-!\n# linear_combination Tactic\n\nIn this file, the `linear_combination` tactic is created.  This tactic, which\nworks over `Ring`s, attempts to simplify the target by creating a linear combination\nof a list of equalities and subtracting it from the target.  This file also includes a\ndefinition for `linear_combination_config`.  A `linear_combination_config`\nobject can be passed into the tactic, allowing the user to specify a\nnormalization tactic.\n\n## Implementation Notes\n\nThis tactic works by creating a weighted sum of the given equations with the\ngiven coefficients.  Then, it subtracts the right side of the weighted sum\nfrom the left side so that the right side equals 0, and it does the same with\nthe target.  Afterwards, it sets the goal to be the equality between the\nlefthand side of the new goal and the lefthand side of the new weighted sum.\nLastly, calls a normalization tactic on this target.\n\n## References\n\n* <https://leanprover.zulipchat.com/#narrow/stream/239415-metaprogramming-.2F.20tactics/topic/Linear.20algebra.20tactic/near/213928196>\n\n-/\n\nnamespace Mathlib.Tactic.LinearCombination\nopen Lean hiding Rat\nopen Elab Meta Term\n\ntheorem pf_add_c [Add α] (p : a = b) (c : α) : a + c = b + c := p ▸ rfl\ntheorem c_add_pf [Add α] (p : b = c) (a : α) : a + b = a + c := p ▸ rfl\ntheorem add_pf [Add α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ + a₂ = b₁ + b₂ := p₁ ▸ p₂ ▸ rfl\ntheorem pf_sub_c [Sub α] (p : a = b) (c : α) : a - c = b - c := p ▸ rfl\ntheorem c_sub_pf [Sub α] (p : b = c) (a : α) : a - b = a - c := p ▸ rfl\ntheorem sub_pf [Sub α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ - a₂ = b₁ - b₂ := p₁ ▸ p₂ ▸ rfl\ntheorem neg_pf [Neg α] (p : (a:α) = b) : -a = -b := p ▸ rfl\ntheorem pf_mul_c [Mul α] (p : a = b) (c : α) : a * c = b * c := p ▸ rfl\ntheorem c_mul_pf [Mul α] (p : b = c) (a : α) : a * b = a * c := p ▸ rfl\ntheorem mul_pf [Mul α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ * a₂ = b₁ * b₂ := p₁ ▸ p₂ ▸ rfl\ntheorem inv_pf [Inv α] (p : (a:α) = b) : a⁻¹ = b⁻¹ := p ▸ rfl\ntheorem pf_div_c [Div α] (p : a = b) (c : α) : a / c = b / c := p ▸ rfl\ntheorem c_div_pf [Div α] (p : b = c) (a : α) : a / b = a / c := p ▸ rfl\ntheorem div_pf [Div α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ / a₂ = b₁ / b₂ := p₁ ▸ p₂ ▸ rfl\n\n/--\nPerforms macro expansion of a linear combination expression,\nusing `+`/`-`/`*`/`/` on equations and values.\n* `some p` means that `p` is a syntax corresponding to a proof of an equation.\n  For example, if `h : a = b` then `expandLinearCombo (2 * h)` returns `some (c_add_pf 2 h)`\n  which is a proof of `2 * a = 2 * b`.\n* `none` means that the input expression is not an equation but a value;\n  the input syntax itself is used in this case.\n-/\npartial def expandLinearCombo (stx : Syntax.Term) : TermElabM (Option Syntax.Term) := do\n  let mut result ← match stx with\n  | `(($e)) => expandLinearCombo e\n  | `($e₁ + $e₂) => do\n    match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with\n    | none, none => pure none\n    | some p₁, none => ``(pf_add_c $p₁ $e₂)\n    | none, some p₂ => ``(c_add_pf $p₂ $e₁)\n    | some p₁, some p₂ => ``(add_pf $p₁ $p₂)\n  | `($e₁ - $e₂) => do\n    match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with\n    | none, none => pure none\n    | some p₁, none => ``(pf_sub_c $p₁ $e₂)\n    | none, some p₂ => ``(c_sub_pf $p₂ $e₁)\n    | some p₁, some p₂ => ``(sub_pf $p₁ $p₂)\n  | `(-$e) => do\n    match ← expandLinearCombo e with\n    | none => pure none\n    | some p => ``(neg_pf $p)\n  | `(← $e) => do\n    match ← expandLinearCombo e with\n    | none => pure none\n    | some p => ``(Eq.symm $p)\n  | `($e₁ * $e₂) => do\n    match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with\n    | none, none => pure none\n    | some p₁, none => ``(pf_mul_c $p₁ $e₂)\n    | none, some p₂ => ``(c_mul_pf $p₂ $e₁)\n    | some p₁, some p₂ => ``(mul_pf $p₁ $p₂)\n  | `($e⁻¹) => do\n    match ← expandLinearCombo e with\n    | none => pure none\n    | some p => ``(inv_pf $p)\n  | `($e₁ / $e₂) => do\n    match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with\n    | none, none => pure none\n    | some p₁, none => ``(pf_div_c $p₁ $e₂)\n    | none, some p₂ => ``(c_div_pf $p₂ $e₁)\n    | some p₁, some p₂ => ``(div_pf $p₁ $p₂)\n  | e => do\n    let e ← elabTerm e none\n    let eType ← inferType e\n    let .true := (← withReducible do whnf eType).isEq | pure none\n    some <$> e.toSyntax\n  return result.map fun r => ⟨r.raw.setInfo (SourceInfo.fromRef stx true)⟩\n\n/-- A configuration object for `linear_combination`. -/\nstructure Config where\n  /-- whether or not the normalization step should be used -/\n  normalize := true\n  /-- whether to make separate subgoals for both sides or just one for `lhs - rhs = 0` -/\n  twoGoals := false\n  /-- the tactic used for normalization when checking\n  if the weighted sum is equivalent to the goal (when `normalize` is `true`). -/\n  normTac : Syntax.Tactic := Unhygienic.run `(tactic| ring_nf)\n  deriving Inhabited\n\n/-- Function elaborating `LinearCombination.Config` -/\ndeclare_config_elab elabConfig Config\n\ntheorem eq_trans₃ (p : (a:α) = b) (p₁ : a = a') (p₂ : b = b') : a' = b' := p₁ ▸ p₂ ▸ p\n\ntheorem eq_of_add [AddGroup α] (p : (a:α) = b) (H : (a' - b') - (a - b) = 0) : a' = b' := by\n  rw [← sub_eq_zero] at p ⊢; rwa [sub_eq_zero, p] at H\n\n/-- Implementation of `linear_combination` and `linear_combination2`. -/\ndef elabLinearCombination\n    (norm? : Option Syntax.Tactic) (input : Option Syntax.Term)\n    (twoGoals := false) : Tactic.TacticM Unit := Tactic.withMainContext do\n  let p ← match input with\n  | none => `(Eq.refl 0)\n  | some e => withSynthesize do\n    match ← expandLinearCombo e with\n    | none => `(Eq.refl $e)\n    | some p => pure p\n  let norm := norm?.getD (Unhygienic.run `(tactic| ring1))\n  Tactic.evalTactic <|← withFreshMacroScope <| if twoGoals then\n    `(tactic| (\n      refine eq_trans₃ $p ?a ?b\n      case' a => $norm:tactic\n      case' b => $norm:tactic))\n  else\n    `(tactic| (refine eq_of_add $p ?a; case' a => $norm:tactic))\n\n/--\nThe `(norm := $tac)` syntax says to use `tac` as a normalization postprocessor for\n`linear_combination`. The default normalizer is `ring1`, but you can override it with `ring_nf`\nto get subgoals from `linear_combination` or with `skip` to disable normalization.\n-/\nsyntax normStx := atomic(\" (\" &\"norm\" \" := \") withoutPosition(tactic) \")\"\n\n/--\n`linear_combination` attempts to simplify the target by creating a linear combination\n  of a list of equalities and subtracting it from the target.\n  The tactic will create a linear\n  combination by adding the equalities together from left to right, so the order\n  of the input hypotheses does matter.  If the `normalize` field of the\n  configuration is set to false, then the tactic will simply set the user up to\n  prove their target using the linear combination instead of normalizing the subtraction.\n\nNote: The left and right sides of all the equalities should have the same\n  type, and the coefficients should also have this type.  There must be\n  instances of `Mul` and `AddGroup` for this type.\n\n* The input `e` in `linear_combination e` is a linear combination of proofs of equalities,\n  given as a sum/difference of coefficients multiplied by expressions.\n  The coefficients may be arbitrary expressions.\n  The expressions can be arbitrary proof terms proving equalities.\n  Most commonly they are hypothesis names `h1, h2, ...`.\n* `linear_combination (norm := tac) e` runs the \"normalization tactic\" `tac`\n  on the subgoal(s) after constructing the linear combination.\n  * The default normalization tactic is `ring1`, which closes the goal or fails.\n  * To get a subgoal in the case that it is not immediately provable, use\n    `ring_nf` as the normalization tactic.\n  * To avoid normalization entirely, use `skip` as the normalization tactic.\n* `linear_combination2 e` is the same as `linear_combination e` but it produces two\n  subgoals instead of one: rather than proving that `(a - b) - (a' - b') = 0` where\n  `a' = b'` is the linear combination from `e` and `a = b` is the goal,\n  it instead attempts to prove `a = a'` and `b = b'`.\n  Because it does not use subtraction, this form is applicable also to semirings.\n  * Note that a goal which is provable by `linear_combination e` may not be provable\n    by `linear_combination2 e`; in general you may need to add a coefficient to `e`\n    to make both sides match, as in `linear_combination2 e + c`.\n  * You can also reverse equalities using `← h`, so for example if `h₁ : a = b`\n    then `2 * (← h)` is a proof of `2 * b = 2 * a`.\n\nExample Usage:\n```\nexample (x y : ℤ) (h1 : x*y + 2*x = 1) (h2 : x = y) : x*y = -2*y + 1 := by\n  linear_combination 1*h1 - 2*h2\n\nexample (x y : ℤ) (h1 : x*y + 2*x = 1) (h2 : x = y) : x*y = -2*y + 1 := by\n  linear_combination h1 - 2*h2\n\nexample (x y : ℤ) (h1 : x*y + 2*x = 1) (h2 : x = y) : x*y = -2*y + 1 := by\n  linear_combination (norm := ring_nf) -2*h2\n  /- Goal: x * y + x * 2 - 1 = 0 -/\n\nexample (x y z : ℝ) (ha : x + 2*y - z = 4) (hb : 2*x + y + z = -2)\n    (hc : x + 2*y + z = 2) :\n    -3*x - 3*y - 4*z = 2 := by\n  linear_combination ha - hb - 2*hc\n\nexample (x y : ℚ) (h1 : x + y = 3) (h2 : 3*x = 7) :\n    x*x*y + y*x*y + 6*x = 3*x*y + 14 := by\n  linear_combination x*y*h1 + 2*h2\n\nexample (x y : ℤ) (h1 : x = -3) (h2 : y = 10) : 2*x = -6 := by\n  linear_combination (norm := skip) 2*h1\n  simp\n\naxiom qc : ℚ\naxiom hqc : qc = 2*qc\n\nexample (a b : ℚ) (h : ∀ p q : ℚ, p = q) : 3*a + qc = 3*b + 2*qc := by\n  linear_combination 3 * h a b + hqc\n```\n-/\nsyntax (name := linearCombination) \"linear_combination\" (normStx)? (ppSpace colGt term)? : tactic\nelab_rules : tactic\n  | `(tactic| linear_combination $[(norm := $tac)]? $(e)?) => elabLinearCombination tac e\n\n@[inherit_doc linearCombination]\nsyntax \"linear_combination2\" (normStx)? (ppSpace colGt term)? : tactic\nelab_rules : tactic\n  | `(tactic| linear_combination2 $[(norm := $tac)]? $(e)?) => elabLinearCombination tac e true\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Tactic/LinearCombination.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46154141434045876}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Reid Barton, Bhavik Mehta\n-/\nimport category_theory.limits.creates\nimport category_theory.over\nimport category_theory.is_connected\n\n/-!\n# Connected limits in the over category\n\nShows that the forgetful functor `over B ⥤ C` creates connected limits, in particular `over B` has\nany connected limit which `C` has.\n-/\n\nuniverses v u -- morphism levels before object levels. See note [category_theory universes].\n\nnoncomputable theory\n\nopen category_theory category_theory.limits\n\nvariables {J : Type v} [small_category J]\nvariables {C : Type u} [category.{v} C]\nvariable {X : C}\n\nnamespace category_theory.over\n\nnamespace creates_connected\n\n/--\n(Impl) Given a diagram in the over category, produce a natural transformation from the\ndiagram legs to the specific object.\n-/\ndef nat_trans_in_over {B : C} (F : J ⥤ over B) :\n  F ⋙ forget B ⟶ (category_theory.functor.const J).obj B :=\n{ app := λ j, (F.obj j).hom }\n\nlocal attribute [tidy] tactic.case_bash\n\n/--\n(Impl) Given a cone in the base category, raise it to a cone in the over category. Note this is\nwhere the connected assumption is used.\n-/\n@[simps]\ndef raise_cone [is_connected J] {B : C} {F : J ⥤ over B} (c : cone (F ⋙ forget B)) :\n  cone F :=\n{ X := over.mk (c.π.app (classical.arbitrary J) ≫ (F.obj (classical.arbitrary J)).hom),\n  π :=\n  { app := λ j,\n      over.hom_mk (c.π.app j) (nat_trans_from_is_connected (c.π ≫ nat_trans_in_over F) j _) } }\n\nlemma raised_cone_lowers_to_original [is_connected J] {B : C} {F : J ⥤ over B}\n  (c : cone (F ⋙ forget B)) (t : is_limit c) :\n  (forget B).map_cone (raise_cone c) = c :=\nby tidy\n\n/-- (Impl) Show that the raised cone is a limit. -/\ndef raised_cone_is_limit [is_connected J] {B : C} {F : J ⥤ over B}\n  {c : cone (F ⋙ forget B)} (t : is_limit c) :\n  is_limit (raise_cone c) :=\n{ lift := λ s, over.hom_mk (t.lift ((forget B).map_cone s)) (by { dsimp, simp }),\n  uniq' := λ s m K, by { ext1, apply t.hom_ext, intro j, simp [← K j] } }\n\nend creates_connected\n\n/-- The forgetful functor from the over category creates any connected limit. -/\ninstance forget_creates_connected_limits\n  [is_connected J] {B : C} : creates_limits_of_shape J (forget B) :=\n{ creates_limit := λ K,\n    creates_limit_of_reflects_iso (λ c t,\n      { lifted_cone := creates_connected.raise_cone c,\n        valid_lift := eq_to_iso (creates_connected.raised_cone_lowers_to_original c t),\n        makes_limit := creates_connected.raised_cone_is_limit t } ) }\n\n/-- The over category has any connected limit which the original category has. -/\ninstance has_connected_limits\n  {B : C} [is_connected J] [has_limits_of_shape J C] : has_limits_of_shape J (over B) :=\n{ has_limit := λ F, has_limit_of_created F (forget B) }\n\nend category_theory.over\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/limits/constructions/over/connected.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.46154141434045876}}
{"text": "import GroundZero.Theorems.Pullback\n\nopen GroundZero GroundZero.Types\nopen GroundZero.Types.Equiv\nopen GroundZero.Proto\n\nopen GroundZero.Structures (prop contr)\n\nuniverse u v u' v' w w' k k'\n\n-- exercise 2.1\n\nsection\n  variable {A : Type u} {a b c : A}\n\n  hott def trans₁ (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A a (λ x _, x = c → a = c) b p (@Id.casesOn A a (λ x _, a = x) c · (idp a)) q\n\n  infixl:99 \" ⬝₁ \" => trans₁\n\n  hott def trans₂ (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A a (λ x _, x = c → a = c) b p idfun q\n\n  infixl:99 \" ⬝₂ \" => trans₂\n\n  hott def trans₃ (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A b (λ x _, a = b → a = x) c q idfun p\n\n  infixl:99 \" ⬝₃ \" => trans₃\n\n  hott def eq₁₂ (p : a = b) (q : b = c) : p ⬝₁ q = p ⬝₂ q :=\n  begin induction p; induction q; reflexivity end\n\n  hott def eq₂₃ (p : a = b) (q : b = c) : p ⬝₂ q = p ⬝₃ q :=\n  begin induction p; induction q; reflexivity end\n\n  hott def eq₁₃ (p : a = b) (q : b = c) : p ⬝₁ q = p ⬝₃ q :=\n  begin induction p; induction q; reflexivity end\nend\n\n-- exercise 2.2\n\nsection\n  variable {A : Type u} {a b c : A} (p : a = b) (q : b = c)\n\n  example : eq₁₂ p q ⬝ eq₂₃ p q = eq₁₃ p q :=\n  begin induction p; induction q; reflexivity end\nend\n\n-- exercise 2.3\n\nsection\n  variable {A : Type u} {a b c : A}\n\n  hott def trans₄ (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A b (λ x _, a = b → a = x) c q (@Id.casesOn A a (λ x _, a = x) b · (idp a)) p\n\n  infixl:99 \" ⬝₄ \" => trans₄\n\n  /-\n  example (p : a = b) (q : b = c) : p ⬝₁ q = p ⬝₄ q := idp _\n  example (p : a = b) (q : b = c) : p ⬝₂ q = p ⬝₄ q := idp _\n  example (p : a = b) (q : b = c) : p ⬝₃ q = p ⬝₄ q := idp _\n  -/\n\n  example (p : a = b) (q : b = c) : p ⬝₁ q = p ⬝₄ q :=\n  begin induction p; induction q; reflexivity end\nend\n\n-- exercise 2.4\n\nhott def nPath (A : Type u) : ℕ → Type u\n| Nat.zero   => A\n| Nat.succ n => Σ (a b : nPath A n), a = b\n\nhott def boundary {A : Type u} {n : ℕ} :\n  nPath A (n + 1) → (nPath A n) × (nPath A n) :=\nλ ⟨a, b, _⟩, (a, b)\n\n-- exercise 2.5\n\nnamespace «2.5»\n  variable {A : Type u} {B : Type v} {x y : A} (p : x = y)\n\n  hott def transconst (b : B) : transport (λ _, B) p b = b :=\n  begin induction p; reflexivity end\n\n  hott def f (φ : A → B) : φ x = φ y → transport (λ _, B) p (φ x) = φ y :=\n  λ q, transconst p (φ x) ⬝ q\n\n  hott def g (φ : A → B) : transport (λ _, B) p (φ x) = φ y → φ x = φ y :=\n  λ q, (transconst p (φ x))⁻¹ ⬝ q\n\n  example (φ : A → B) : f p φ ∘ g p φ ~ id :=\n  begin induction p; reflexivity end\n\n  example (φ : A → B) : g p φ ∘ f p φ ~ id :=\n  begin induction p; reflexivity end\nend «2.5»\n\n-- exercise 2.6\n\nexample {A : Type u} {x y z : A} (p : x = y) : biinv (@Id.trans A x y z p) :=\nbegin apply Prod.mk <;> existsi Id.trans p⁻¹ <;> intro q <;> induction p <;> induction q <;> reflexivity end\n\n-- exercise 2.7\n\nnamespace «2.7»\n  variable {A : Type u} {A' : Type u'} {B : A → Type v} {B' : A' → Type v'}\n           (g : A → A') (h : Π a, B a → B' (g a))\n\n  def φ (x : Σ a, B a) : Σ a', B' a' := ⟨g x.1, h x.1 x.2⟩\n\n  hott def prodMap : Π (x y : Σ a, B a) (p : x.1 = y.1) (q : x.2 =[p] y.2),\n      Id.map (φ g h) (Sigma.prod p q)\n    = @Sigma.prod A' B' (φ g h x) (φ g h y)\n        (@Id.map A A' x.1 y.1 g p) (depPathMap' g h q) :=\n  begin\n    intro ⟨x, H⟩ ⟨y, G⟩ (p : x = y); induction p;\n    intro (q : H = G); induction q; reflexivity\n  end\nend «2.7»\n\n-- exercise 2.8\n\nnamespace «2.8»\n  variable {A A' B B' : Type u} (g : A → A') (h : B → B')\n\n  def φ : A + B → A' + B' :=\n  Coproduct.elim (Coproduct.inl ∘ g) (Coproduct.inr ∘ h)\n\n  hott def ρ : Π {x y : A + B}, Coproduct.code x y → Coproduct.code (φ g h x) (φ g h y)\n  | Sum.inl _, Sum.inl _, p => Id.map _ p\n  | Sum.inr _, Sum.inl _, p => Empty.elim p\n  | Sum.inl _, Sum.inr _, p => Empty.elim p\n  | Sum.inr _, Sum.inr _, p => Id.map _ p\n\n  hott def mapPathSum (x y : A + B) : Π p,\n      Id.map (φ g h) (Coproduct.pathSum x y p)\n    = Coproduct.pathSum (φ g h x) (φ g h y) (ρ g h p) :=\n  begin\n    match x, y with\n    | Sum.inl x, Sum.inl y => _\n    | Sum.inr _, Sum.inl _ => _\n    | Sum.inl _, Sum.inr _ => _\n    | Sum.inr x, Sum.inr y => _;\n\n    { intro (p : x = y); induction p; reflexivity };\n    { intro; apply Empty.elim; assumption };\n    { intro; apply Empty.elim; assumption };\n    { intro (p : x = y); induction p; reflexivity }\n  end\nend «2.8»\n\n-- exercise 2.9\n\nhott def Coproduct.depUnivProperty (A : Type u) (B : Type v) (X : A + B → Type w) :\n  (Π x, X x) ≃ (Π a, X (Coproduct.inl a)) × (Π b, X (Coproduct.inr b)) :=\nbegin\n  fapply Sigma.mk; { intro φ; exact (λ a, φ (Coproduct.inl a), λ b, φ (Coproduct.inr b)) };\n  apply Qinv.toBiinv; fapply Sigma.mk;\n  { intros φ x; induction x using Sum.casesOn; apply φ.1; apply φ.2 };\n  apply Prod.mk; { intro (φ, ψ); reflexivity };\n  { intro f; apply Theorems.funext; intro z; induction z using Sum.casesOn <;> reflexivity }\nend\n\nhott def Coproduct.univProperty (A : Type u) (B : Type v) (X : Type w) :\n  (A + B → X) ≃ (A → X) × (B → X) :=\nCoproduct.depUnivProperty A B (λ _, X)\n\n-- exercise 2.10\n\nhott def sigma.assoc (A : Type u) (B : A → Type v) (C : (Σ x, B x) → Type w) :\n  (Σ x, Σ y, C ⟨x, y⟩) ≃ (Σ p, C p) :=\nbegin\n  fapply Sigma.mk; { intro w; existsi ⟨w.1, w.2.1⟩; exact w.2.2 };\n  apply Qinv.toBiinv; fapply Sigma.mk;\n  { intro w; existsi w.1.1; existsi w.1.2; apply transport C;\n    symmetry; exact Sigma.uniq w.1; exact w.2 }; apply Prod.mk;\n  { intro ⟨⟨a, b⟩, c⟩; reflexivity };\n  { intro ⟨a, ⟨b, c⟩⟩; reflexivity }\nend\n\n-- exercise 2.11\n\nnamespace «2.11»\n  variable {P : Type k} {A : Type u} {B : Type v} {C : Type w}\n           (η : pullbackSquare P A B C)\n\n  example : P ≃ pullback C η.1.right η.1.bot :=\n  Theorems.pullbackCorner η\nend «2.11»\n\n-- exercise 2.12\n\nnamespace «2.12»\n  variable {A B C D E F : Type u}\n           {f : A → C} {g : C → E} {i : A → B} {j : C → D}\n           {k : E → F} {h : B → D} {s : D → F}\n           (α : j ∘ f = h ∘ i) (β : k ∘ g = s ∘ j)\n\n  def left  : hcommSquare A C B D := ⟨j, h, f, i, α⟩\n  def right : hcommSquare C E D F := ⟨k, s, g, j, β⟩\n\n  def outer : hcommSquare A E B F :=\n  ⟨k, s ∘ h, g ∘ f, i, @Id.map (C → F) (A → F) _ _ (· ∘ f) β\n                     ⬝ @Id.map _ (A → F) _ _ (s ∘ ·) α⟩\n\n  hott def pullbackLemma (H : (right β).isPullback) :\n    (left α).isPullback ↔ (outer α β).isPullback :=\n  sorry\nend «2.12»\n\n-- exercise 2.13\n\nexample : (𝟐 ≃ 𝟐) ≃ 𝟐 := Theorems.Equiv.boolEquivEqvBool\n\n-- exercise 2.14\n\n-- Assume Γ, p : x = y ⊢ x ≡ y, let Γ = A : U, a : A. Then Γ, b : A, p : a = b ⊢ p = idp a : U,\n-- because in this context we have p : a = b, so a ≡ b, so p : a = a.\n-- “@Id.rec A a (λ b, p = idp a) (λ x, idp a) a” is then well-typed.\n-- This means that we have a proof of “Π (p : a = a), p = idp a” leading to contradiction.\n\n-- exercise 2.15\n\nhott def transportMap {A : Type u} {B : A → Type v} {x y : A} (p : x = y) :\n  transport B p = idtoeqv (Id.map B p) :=\nbegin induction p; reflexivity end\n\n-- exercise 2.18\n\nhott def transportSquare {A : Type u} {B : A → Type v} {f g : Π x, B x} (H : f ~ g) {x y : A} (p : x = y) :\n  Id.map (transport B p) (H x) ⬝ apd g p = apd f p ⬝ H y :=\nbegin induction p; transitivity; apply Id.reflRight; apply Equiv.idmap end\n", "meta": {"author": "forked-from-1kasper", "repo": "ground_zero", "sha": "58ad68bb54e355f6c39beaee2b383879eccc9952", "save_path": "github-repos/lean/forked-from-1kasper-ground_zero", "path": "github-repos/lean/forked-from-1kasper-ground_zero/ground_zero-58ad68bb54e355f6c39beaee2b383879eccc9952/GroundZero/Exercises/Chap2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.4613827427890311}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.monoidal.braided\nimport category_theory.functor.reflects_isomorphisms\nimport category_theory.monoidal.coherence\n\n/-!\n# Half braidings and the Drinfeld center of a monoidal category\n\nWe define `center C` to be pairs `⟨X, b⟩`, where `X : C` and `b` is a half-braiding on `X`.\n\nWe show that `center C` is braided monoidal,\nand provide the monoidal functor `center.forget` from `center C` back to `C`.\n\n## Future work\n\nVerifying the various axioms here is done by tedious rewriting.\nUsing the `slice` tactic may make the proofs marginally more readable.\n\nMore exciting, however, would be to make possible one of the following options:\n1. Integration with homotopy.io / globular to give \"picture proofs\".\n2. The monoidal coherence theorem, so we can ignore associators\n   (after which most of these proofs are trivial;\n   I'm unsure if the monoidal coherence theorem is even usable in dependent type theory).\n3. Automating these proofs using `rewrite_search` or some relative.\n\n-/\n\nopen category_theory\nopen category_theory.monoidal_category\n\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u₁} [category.{v₁} C] [monoidal_category C]\n\n/--\nA half-braiding on `X : C` is a family of isomorphisms `X ⊗ U ≅ U ⊗ X`,\nmonoidally natural in `U : C`.\n\nThinking of `C` as a 2-category with a single `0`-morphism, these are the same as natural\ntransformations (in the pseudo- sense) of the identity 2-functor on `C`, which send the unique\n`0`-morphism to `X`.\n-/\n@[nolint has_nonempty_instance]\nstructure half_braiding (X : C) :=\n(β : Π U, X ⊗ U ≅ U ⊗ X)\n(monoidal' : ∀ U U', (β (U ⊗ U')).hom =\n  (α_ _ _ _).inv ≫ ((β U).hom ⊗ 𝟙 U') ≫ (α_ _ _ _).hom ≫ (𝟙 U ⊗ (β U').hom) ≫ (α_ _ _ _).inv\n  . obviously)\n(naturality' : ∀ {U U'} (f : U ⟶ U'), (𝟙 X ⊗ f) ≫ (β U').hom = (β U).hom ≫ (f ⊗ 𝟙 X) . obviously)\n\nrestate_axiom half_braiding.monoidal'\nattribute [reassoc, simp] half_braiding.monoidal -- the reassoc lemma is redundant as a simp lemma\nrestate_axiom half_braiding.naturality'\nattribute [simp, reassoc] half_braiding.naturality\n\nvariables (C)\n/--\nThe Drinfeld center of a monoidal category `C` has as objects pairs `⟨X, b⟩`, where `X : C`\nand `b` is a half-braiding on `X`.\n-/\n@[nolint has_nonempty_instance]\ndef center := Σ X : C, half_braiding X\n\nnamespace center\n\nvariables {C}\n\n/-- A morphism in the Drinfeld center of `C`. -/\n@[ext, nolint has_nonempty_instance]\nstructure hom (X Y : center C) :=\n(f : X.1 ⟶ Y.1)\n(comm' : ∀ U, (f ⊗ 𝟙 U) ≫ (Y.2.β U).hom = (X.2.β U).hom ≫ (𝟙 U ⊗ f) . obviously)\n\nrestate_axiom hom.comm'\nattribute [simp, reassoc] hom.comm\n\ninstance : category (center C) :=\n{ hom := hom,\n  id := λ X, { f := 𝟙 X.1, },\n  comp := λ X Y Z f g, { f := f.f ≫ g.f, }, }\n\n@[simp] lemma id_f (X : center C) : hom.f (𝟙 X) = 𝟙 X.1 := rfl\n@[simp] lemma comp_f {X Y Z : center C} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).f = f.f ≫ g.f := rfl\n\n@[ext]\nlemma ext {X Y : center C} (f g : X ⟶ Y) (w : f.f = g.f) : f = g :=\nby { cases f, cases g, congr, exact w, }\n\n/--\nConstruct an isomorphism in the Drinfeld center from\na morphism whose underlying morphism is an isomorphism.\n-/\n@[simps]\ndef iso_mk {X Y : center C} (f : X ⟶ Y) [is_iso f.f] : X ≅ Y :=\n{ hom := f,\n  inv := ⟨inv f.f, λ U, by simp [←cancel_epi (f.f ⊗ 𝟙 U), ←comp_tensor_id_assoc, ←id_tensor_comp]⟩ }\n\ninstance is_iso_of_f_is_iso {X Y : center C} (f : X ⟶ Y) [is_iso f.f] : is_iso f :=\nbegin\n  change is_iso (iso_mk f).hom,\n  apply_instance,\nend\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_obj (X Y : center C) : center C :=\n⟨X.1 ⊗ Y.1,\n  { β := λ U, α_ _ _ _ ≪≫ (iso.refl X.1 ⊗ Y.2.β U) ≪≫ (α_ _ _ _).symm\n      ≪≫ (X.2.β U ⊗ iso.refl Y.1) ≪≫ α_ _ _ _,\n    monoidal' := λ U U',\n    begin\n      dsimp,\n      simp only [comp_tensor_id, id_tensor_comp, category.assoc, half_braiding.monoidal],\n      -- On the RHS, we'd like to commute `((X.snd.β U).hom ⊗ 𝟙 Y.fst) ⊗ 𝟙 U'`\n      -- and `𝟙 U ⊗ 𝟙 X.fst ⊗ (Y.snd.β U').hom` past each other,\n      -- but there are some associators we need to get out of the way first.\n      slice_rhs 6 8 { rw pentagon, },\n      slice_rhs 5 6 { rw associator_naturality, },\n      slice_rhs 7 8 { rw ←associator_naturality, },\n      slice_rhs 6 7 { rw [tensor_id, tensor_id, tensor_id_comp_id_tensor, ←id_tensor_comp_tensor_id,\n        ←tensor_id, ←tensor_id], },\n      -- Now insert associators as needed to make the four half-braidings look identical\n      slice_rhs 10 10 { rw associator_inv_conjugation, },\n      slice_rhs 7 7 { rw associator_inv_conjugation, },\n      slice_rhs 6 6 { rw associator_conjugation, },\n      slice_rhs 3 3 { rw associator_conjugation, },\n      -- Finish with an application of the coherence theorem.\n      coherence,\n    end,\n    naturality' := λ U U' f,\n    begin\n      dsimp,\n      rw [category.assoc, category.assoc, category.assoc, category.assoc,\n        id_tensor_associator_naturality_assoc, ←id_tensor_comp_assoc, half_braiding.naturality,\n        id_tensor_comp_assoc, associator_inv_naturality_assoc, ←comp_tensor_id_assoc,\n        half_braiding.naturality, comp_tensor_id_assoc, associator_naturality, ←tensor_id],\n    end, }⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_hom {X₁ Y₁ X₂ Y₂ : center C} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :\n  tensor_obj X₁ X₂ ⟶ tensor_obj Y₁ Y₂ :=\n{ f := f.f ⊗ g.f,\n  comm' := λ U, begin\n    dsimp,\n    rw [category.assoc, category.assoc, category.assoc, category.assoc,\n      associator_naturality_assoc, ←tensor_id_comp_id_tensor, category.assoc,\n      ←id_tensor_comp_assoc, g.comm, id_tensor_comp_assoc, tensor_id_comp_id_tensor_assoc,\n      ←id_tensor_comp_tensor_id, category.assoc, associator_inv_naturality_assoc,\n      id_tensor_associator_inv_naturality_assoc, tensor_id,\n      id_tensor_comp_tensor_id_assoc, ←tensor_id_comp_id_tensor g.f, category.assoc,\n      ←comp_tensor_id_assoc, f.comm, comp_tensor_id_assoc, id_tensor_associator_naturality,\n      associator_naturality_assoc, ←id_tensor_comp, tensor_id_comp_id_tensor],\n  end }\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_unit : center C :=\n⟨𝟙_ C,\n  { β := λ U, (λ_ U) ≪≫ (ρ_ U).symm,\n    monoidal' := λ U U', by simp,\n    naturality' := λ U U' f, begin\n      dsimp,\n      rw [left_unitor_naturality_assoc, right_unitor_inv_naturality, category.assoc],\n    end, }⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef associator (X Y Z : center C) : tensor_obj (tensor_obj X Y) Z ≅ tensor_obj X (tensor_obj Y Z) :=\niso_mk ⟨(α_ X.1 Y.1 Z.1).hom, λ U, begin\n  dsimp,\n  simp only [comp_tensor_id, id_tensor_comp, ←tensor_id, associator_conjugation],\n  coherence,\nend⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef left_unitor (X : center C) : tensor_obj tensor_unit X ≅ X :=\niso_mk ⟨(λ_ X.1).hom, λ U, begin\n  dsimp,\n  simp only [category.comp_id, category.assoc, tensor_inv_hom_id, comp_tensor_id,\n    tensor_id_comp_id_tensor, triangle_assoc_comp_right_inv],\n  rw [←left_unitor_tensor, left_unitor_naturality, left_unitor_tensor'_assoc],\nend⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef right_unitor (X : center C) : tensor_obj X tensor_unit ≅ X :=\niso_mk ⟨(ρ_ X.1).hom, λ U, begin\n  dsimp,\n  simp only [tensor_id_comp_id_tensor_assoc, triangle_assoc, id_tensor_comp, category.assoc],\n  rw [←tensor_id_comp_id_tensor_assoc (ρ_ U).inv, cancel_epi, ←right_unitor_tensor_inv_assoc,\n    ←right_unitor_inv_naturality_assoc],\n  simp,\nend⟩\n\nsection\nlocal attribute [simp] associator_naturality left_unitor_naturality right_unitor_naturality\n  pentagon\nlocal attribute [simp] center.associator center.left_unitor center.right_unitor\n\ninstance : monoidal_category (center C) :=\n{ tensor_obj := λ X Y, tensor_obj X Y,\n  tensor_hom := λ X₁ Y₁ X₂ Y₂ f g, tensor_hom f g,\n  tensor_unit := tensor_unit,\n  associator := associator,\n  left_unitor := left_unitor,\n  right_unitor := right_unitor, }\n\n@[simp] lemma tensor_fst (X Y : center C) : (X ⊗ Y).1 = X.1 ⊗ Y.1 := rfl\n\n@[simp] lemma tensor_β (X Y : center C) (U : C) :\n  (X ⊗ Y).2.β U =\n    α_ _ _ _ ≪≫ (iso.refl X.1 ⊗ Y.2.β U) ≪≫ (α_ _ _ _).symm\n      ≪≫ (X.2.β U ⊗ iso.refl Y.1) ≪≫ α_ _ _ _ :=\nrfl\n@[simp] \n\n@[simp] lemma tensor_unit_β (U : C) : (𝟙_ (center C)).2.β U = (λ_ U) ≪≫ (ρ_ U).symm := rfl\n\n@[simp] lemma associator_hom_f (X Y Z : center C) : hom.f (α_ X Y Z).hom = (α_ X.1 Y.1 Z.1).hom :=\nrfl\n\n@[simp] lemma associator_inv_f (X Y Z : center C) : hom.f (α_ X Y Z).inv = (α_ X.1 Y.1 Z.1).inv :=\nby { ext, rw [←associator_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma left_unitor_hom_f (X : center C) : hom.f (λ_ X).hom = (λ_ X.1).hom :=\nrfl\n\n@[simp] lemma left_unitor_inv_f (X : center C) : hom.f (λ_ X).inv = (λ_ X.1).inv :=\nby { ext, rw [←left_unitor_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma right_unitor_hom_f (X : center C) : hom.f (ρ_ X).hom = (ρ_ X.1).hom :=\nrfl\n\n@[simp] lemma right_unitor_inv_f (X : center C) : hom.f (ρ_ X).inv = (ρ_ X.1).inv :=\nby { ext, rw [←right_unitor_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\nend\n\nsection\nvariables (C)\n\n/-- The forgetful monoidal functor from the Drinfeld center to the original category. -/\n@[simps]\ndef forget : monoidal_functor (center C) C :=\n{ obj := λ X, X.1,\n  map := λ X Y f, f.f,\n  ε := 𝟙 (𝟙_ C),\n  μ := λ X Y, 𝟙 (X.1 ⊗ Y.1), }\n\ninstance : reflects_isomorphisms (forget C).to_functor :=\n{ reflects := λ A B f i, by { dsimp at i, resetI, change is_iso (iso_mk f).hom, apply_instance, } }\n\nend\n\n/-- Auxiliary definition for the `braided_category` instance on `center C`. -/\n@[simps]\ndef braiding (X Y : center C) : X ⊗ Y ≅ Y ⊗ X :=\niso_mk ⟨(X.2.β Y.1).hom, λ U, begin\n  dsimp,\n  simp only [category.assoc],\n  rw [←is_iso.inv_comp_eq, is_iso.iso.inv_hom, ←half_braiding.monoidal_assoc,\n    ←half_braiding.naturality_assoc, half_braiding.monoidal],\n  simp,\nend⟩\n\ninstance braided_category_center : braided_category (center C) :=\n{ braiding := braiding,\n  braiding_naturality' := λ X Y X' Y' f g, begin\n    ext,\n    dsimp,\n    rw [←tensor_id_comp_id_tensor, category.assoc, half_braiding.naturality, f.comm_assoc,\n      id_tensor_comp_tensor_id],\n  end, } -- `obviously` handles the hexagon axioms\n\nsection\nvariables [braided_category C]\n\nopen braided_category\n\n/-- Auxiliary construction for `of_braided`. -/\n@[simps]\ndef of_braided_obj (X : C) : center C :=\n⟨X, { β := λ Y, β_ X Y,\n  monoidal' := λ U U', begin\n    rw [iso.eq_inv_comp, ←category.assoc, ←category.assoc, iso.eq_comp_inv,\n      category.assoc, category.assoc],\n    exact hexagon_forward X U U',\n  end }⟩\n\nvariables (C)\n\n/--\nThe functor lifting a braided category to its center, using the braiding as the half-braiding.\n-/\n@[simps]\ndef of_braided : monoidal_functor C (center C) :=\n{ obj := of_braided_obj,\n  map := λ X X' f,\n  { f := f,\n    comm' := λ U, braiding_naturality _ _, },\n  ε :=\n  { f := 𝟙 _,\n    comm' := λ U, begin\n      dsimp,\n      rw [tensor_id, category.id_comp, tensor_id, category.comp_id, ←braiding_right_unitor,\n        category.assoc, iso.hom_inv_id, category.comp_id],\n    end, },\n  μ := λ X Y,\n  { f := 𝟙 _,\n    comm' := λ U, begin\n      dsimp,\n      rw [tensor_id, tensor_id, category.id_comp, category.comp_id,\n        ←iso.inv_comp_eq, ←category.assoc, ←category.assoc, ←iso.comp_inv_eq,\n        category.assoc, hexagon_reverse, category.assoc],\n    end, }, }\n\nend\n\nend center\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/monoidal/center.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4613827397181289}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.limits.shapes.finite_products\nimport category_theory.limits.shapes.binary_products\nimport category_theory.preadditive\n\n/-!\n# Biproducts and binary biproducts\n\nWe introduce the notion of (finite) biproducts and binary biproducts.\n\nThese are slightly unusual relative to the other shapes in the library,\nas they are simultaneously limits and colimits.\n(Zero objects are similar; they are \"biterminal\".)\n\nWe treat first the case of a general category with zero morphisms,\nand subsequently the case of a preadditive category.\n\nIn a category with zero morphisms, we model the (binary) biproduct of `P Q : C`\nusing a `binary_bicone`, which has a cone point `X`,\nand morphisms `fst : X ⟶ P`, `snd : X ⟶ Q`, `inl : P ⟶ X` and `inr : X ⟶ Q`,\nsuch that `inl ≫ fst = 𝟙 P`, `inl ≫ snd = 0`, `inr ≫ fst = 0`, and `inr ≫ snd = 𝟙 Q`.\nSuch a `binary_bicone` is a biproduct if the cone is a limit cone, and the cocone is a colimit\ncocone.\n\nIn a preadditive category,\n* any `binary_biproduct` satisfies `total : fst ≫ inl + snd ≫ inr = 𝟙 X`\n* any `binary_product` is a `binary_biproduct`\n* any `binary_coproduct` is a `binary_biproduct`\n\nFor biproducts indexed by a `fintype J`, a `bicone` again consists of a cone point `X`\nand morphisms `π j : X ⟶ F j` and `ι j : F j ⟶ X` for each `j`,\nsuch that `ι j ≫ π j'` is the identity when `j = j'` and zero otherwise.\n\nIn a preadditive category,\n* any `biproduct` satisfies `total : ∑ j : J, biproduct.π f j ≫ biproduct.ι f j = 𝟙 (⨁ f)`\n* any `product` is a `biproduct`\n* any `coproduct` is a `biproduct`\n\n## Notation\nAs `⊕` is already taken for the sum of types, we introduce the notation `X ⊞ Y` for\na binary biproduct. We introduce `⨁ f` for the indexed biproduct.\n-/\n\nnoncomputable theory\n\nuniverses v u\n\nopen category_theory\nopen category_theory.functor\n\nnamespace category_theory.limits\n\nvariables {J : Type v} [decidable_eq J]\nvariables {C : Type u} [category.{v} C] [has_zero_morphisms C]\n\n/--\nA `c : bicone F` is:\n* an object `c.X` and\n* morphisms `π j : X ⟶ F j` and `ι j : F j ⟶ X` for each `j`,\n* such that `ι j ≫ π j'` is the identity when `j = j'` and zero otherwise.\n-/\n@[nolint has_inhabited_instance]\nstructure bicone (F : J → C) :=\n(X : C)\n(π : Π j, X ⟶ F j)\n(ι : Π j, F j ⟶ X)\n(ι_π : ∀ j j', ι j ≫ π j' = if h : j = j' then eq_to_hom (congr_arg F h) else 0)\n\n@[simp] lemma bicone_ι_π_self {F : J → C} (B : bicone F) (j : J) : B.ι j ≫ B.π j = 𝟙 (F j) :=\nby simpa using B.ι_π j j\n\n@[simp] lemma bicone_ι_π_ne {F : J → C} (B : bicone F) {j j' : J} (h : j ≠ j') :\n  B.ι j ≫ B.π j' = 0 :=\nby simpa [h] using B.ι_π j j'\n\nvariables {F : J → C}\n\nnamespace bicone\n/-- Extract the cone from a bicone. -/\n@[simps]\ndef to_cone (B : bicone F) : cone (discrete.functor F) :=\n{ X := B.X,\n  π := { app := λ j, B.π j }, }\n\n/-- Extract the cocone from a bicone. -/\n@[simps]\ndef to_cocone (B : bicone F) : cocone (discrete.functor F) :=\n{ X := B.X,\n  ι := { app := λ j, B.ι j }, }\n\nend bicone\n\n/--\nA bicone over `F : J → C`, which is both a limit cone and a colimit cocone.\n-/\n@[nolint has_inhabited_instance]\nstructure limit_bicone (F : J → C) :=\n(bicone : bicone F)\n(is_limit : is_limit bicone.to_cone)\n(is_colimit : is_colimit bicone.to_cocone)\n\n/--\n`has_biproduct F` expresses the mere existence of a bicone which is\nsimultaneously a limit and a colimit of the diagram `F`.\n-/\nclass has_biproduct (F : J → C) : Prop :=\nmk' :: (exists_biproduct : nonempty (limit_bicone F))\n\nlemma has_biproduct.mk {F : J → C} (d : limit_bicone F) : has_biproduct F :=\n⟨nonempty.intro d⟩\n\n/-- Use the axiom of choice to extract explicit `biproduct_data F` from `has_biproduct F`. -/\ndef get_biproduct_data (F : J → C) [has_biproduct F] : limit_bicone F :=\nclassical.choice has_biproduct.exists_biproduct\n\n/-- A bicone for `F` which is both a limit cone and a colimit cocone. -/\ndef biproduct.bicone (F : J → C) [has_biproduct F] : bicone F :=\n(get_biproduct_data F).bicone\n\n/-- `biproduct.bicone F` is a limit cone. -/\ndef biproduct.is_limit (F : J → C) [has_biproduct F] : is_limit (biproduct.bicone F).to_cone :=\n(get_biproduct_data F).is_limit\n\n/-- `biproduct.bicone F` is a colimit cocone. -/\ndef biproduct.is_colimit (F : J → C) [has_biproduct F] :\n  is_colimit (biproduct.bicone F).to_cocone :=\n(get_biproduct_data F).is_colimit\n\n@[priority 100]\ninstance has_product_of_has_biproduct [has_biproduct F] : has_limit (discrete.functor F) :=\nhas_limit.mk { cone := (biproduct.bicone F).to_cone,\n  is_limit := biproduct.is_limit F, }\n\n@[priority 100]\ninstance has_coproduct_of_has_biproduct [has_biproduct F] : has_colimit (discrete.functor F) :=\nhas_colimit.mk { cocone := (biproduct.bicone F).to_cocone,\n  is_colimit := biproduct.is_colimit F, }\n\nvariables (J C)\n\n/--\n`C` has biproducts of shape `J` if we have\na limit and a colimit, with the same cone points,\nof every function `F : J → C`.\n-/\nclass has_biproducts_of_shape : Prop :=\n(has_biproduct : Π F : J → C, has_biproduct F)\n\nattribute [instance, priority 100] has_biproducts_of_shape.has_biproduct\n\n/-- `has_finite_biproducts C` represents a choice of biproduct for every family of objects in `C`\nindexed by a finite type with decidable equality. -/\nclass has_finite_biproducts : Prop :=\n(has_biproducts_of_shape : Π (J : Type v) [decidable_eq J] [fintype J],\n  has_biproducts_of_shape J C)\n\nattribute [instance, priority 100] has_finite_biproducts.has_biproducts_of_shape\n\n@[priority 100]\ninstance has_finite_products_of_has_finite_biproducts [has_finite_biproducts C] :\n  has_finite_products C :=\n{ out := λ J _ _, ⟨λ F, by exactI has_limit_of_iso discrete.nat_iso_functor.symm⟩ }\n\n@[priority 100]\ninstance has_finite_coproducts_of_has_finite_biproducts [has_finite_biproducts C] :\n  has_finite_coproducts C :=\n{ out := λ J _ _, ⟨λ F, by exactI has_colimit_of_iso discrete.nat_iso_functor⟩ }\n\nvariables {J C}\n\n/--\nThe isomorphism between the specified limit and the specified colimit for\na functor with a bilimit.\n-/\ndef biproduct_iso (F : J → C) [has_biproduct F] :\n  limits.pi_obj F ≅ limits.sigma_obj F :=\n(is_limit.cone_point_unique_up_to_iso (limit.is_limit _) (biproduct.is_limit F)).trans $\n  is_colimit.cocone_point_unique_up_to_iso (biproduct.is_colimit F) (colimit.is_colimit _)\n\nend category_theory.limits\n\nnamespace category_theory.limits\nvariables {J : Type v} [decidable_eq J]\nvariables {C : Type u} [category.{v} C] [has_zero_morphisms C]\n\n/-- `biproduct f` computes the biproduct of a family of elements `f`. (It is defined as an\n   abbreviation for `limit (discrete.functor f)`, so for most facts about `biproduct f`, you will\n   just use general facts about limits and colimits.) -/\nabbreviation biproduct (f : J → C) [has_biproduct f] : C :=\n(biproduct.bicone f).X\n\nnotation `⨁ ` f:20 := biproduct f\n\n/-- The projection onto a summand of a biproduct. -/\nabbreviation biproduct.π (f : J → C) [has_biproduct f] (b : J) : ⨁ f ⟶ f b :=\n(biproduct.bicone f).π b\n\n@[simp]\nlemma biproduct.bicone_π (f : J → C) [has_biproduct f] (b : J) :\n  (biproduct.bicone f).π b = biproduct.π f b := rfl\n\n/-- The inclusion into a summand of a biproduct. -/\nabbreviation biproduct.ι (f : J → C) [has_biproduct f] (b : J) : f b ⟶ ⨁ f :=\n(biproduct.bicone f).ι b\n\n@[simp]\nlemma biproduct.bicone_ι (f : J → C) [has_biproduct f] (b : J) :\n  (biproduct.bicone f).ι b = biproduct.ι f b := rfl\n\n@[reassoc]\nlemma biproduct.ι_π (f : J → C) [has_biproduct f] (j j' : J) :\n  biproduct.ι f j ≫ biproduct.π f j' = if h : j = j' then eq_to_hom (congr_arg f h) else 0 :=\n(biproduct.bicone f).ι_π j j'\n\n@[simp,reassoc]\nlemma biproduct.ι_π_self (f : J → C) [has_biproduct f] (j : J) :\n  biproduct.ι f j ≫ biproduct.π f j = 𝟙 _ :=\nby simp [biproduct.ι_π]\n\n@[simp,reassoc]\nlemma biproduct.ι_π_ne (f : J → C) [has_biproduct f] {j j' : J} (h : j ≠ j') :\n  biproduct.ι f j ≫ biproduct.π f j' = 0 :=\nby simp [biproduct.ι_π, h]\n\n/-- Given a collection of maps into the summands, we obtain a map into the biproduct. -/\nabbreviation biproduct.lift\n  {f : J → C} [has_biproduct f] {P : C} (p : Π b, P ⟶ f b) : P ⟶ ⨁ f :=\n(biproduct.is_limit f).lift (fan.mk P p)\n/-- Given a collection of maps out of the summands, we obtain a map out of the biproduct. -/\nabbreviation biproduct.desc\n  {f : J → C} [has_biproduct f] {P : C} (p : Π b, f b ⟶ P) : ⨁ f ⟶ P :=\n(biproduct.is_colimit f).desc (cofan.mk P p)\n\n@[simp, reassoc]\nlemma biproduct.lift_π {f : J → C} [has_biproduct f] {P : C} (p : Π b, P ⟶ f b) (j : J) :\n  biproduct.lift p ≫ biproduct.π f j = p j :=\n(biproduct.is_limit f).fac _ _\n\n@[simp, reassoc]\nlemma biproduct.ι_desc {f : J → C} [has_biproduct f] {P : C} (p : Π b, f b ⟶ P) (j : J) :\n  biproduct.ι f j ≫ biproduct.desc p = p j :=\n(biproduct.is_colimit f).fac _ _\n\n/-- Given a collection of maps between corresponding summands of a pair of biproducts\nindexed by the same type, we obtain a map between the biproducts. -/\nabbreviation biproduct.map [fintype J] {f g : J → C} [has_finite_biproducts C]\n  (p : Π b, f b ⟶ g b) : ⨁ f ⟶ ⨁ g :=\nis_limit.map (biproduct.bicone f).to_cone (biproduct.is_limit g) (discrete.nat_trans p)\n\n/-- An alternative to `biproduct.map` constructed via colimits.\nThis construction only exists in order to show it is equal to `biproduct.map`. -/\nabbreviation biproduct.map' [fintype J] {f g : J → C} [has_finite_biproducts C]\n  (p : Π b, f b ⟶ g b) : ⨁ f ⟶ ⨁ g :=\nis_colimit.map (biproduct.is_colimit f) (biproduct.bicone g).to_cocone (discrete.nat_trans p)\n\n@[ext] lemma biproduct.hom_ext {f : J → C} [has_biproduct f]\n  {Z : C} (g h : Z ⟶ ⨁ f)\n  (w : ∀ j, g ≫ biproduct.π f j = h ≫ biproduct.π f j) : g = h :=\n(biproduct.is_limit f).hom_ext w\n\n@[ext] lemma biproduct.hom_ext' {f : J → C} [has_biproduct f]\n  {Z : C} (g h : ⨁ f ⟶ Z)\n  (w : ∀ j, biproduct.ι f j ≫ g = biproduct.ι f j ≫ h) : g = h :=\n(biproduct.is_colimit f).hom_ext w\n\nlemma biproduct.map_eq_map' [fintype J] {f g : J → C} [has_finite_biproducts C]\n  (p : Π b, f b ⟶ g b) : biproduct.map p = biproduct.map' p :=\nbegin\n  ext j j',\n  simp only [discrete.nat_trans_app, limits.is_colimit.ι_map, limits.is_limit.map_π, category.assoc,\n    ←bicone.to_cone_π_app, ←biproduct.bicone_π, ←bicone.to_cocone_ι_app, ←biproduct.bicone_ι],\n  simp only [biproduct.bicone_ι, biproduct.bicone_π, bicone.to_cocone_ι_app, bicone.to_cone_π_app],\n  rw [biproduct.ι_π_assoc, biproduct.ι_π],\n  split_ifs,\n  { subst h, rw [eq_to_hom_refl, category.id_comp], erw category.comp_id, },\n  { simp, },\nend\n\n@[simp, reassoc]\nlemma biproduct.map_π [fintype J] {f g : J → C} [has_finite_biproducts C]\n  (p : Π j, f j ⟶ g j) (j : J) :\n  biproduct.map p ≫ biproduct.π g j = biproduct.π f j ≫ p j :=\nlimits.is_limit.map_π _ _ _ _\n\n@[simp, reassoc]\nlemma biproduct.ι_map [fintype J] {f g : J → C} [has_finite_biproducts C]\n  (p : Π j, f j ⟶ g j) (j : J) :\n  biproduct.ι f j ≫ biproduct.map p = p j ≫ biproduct.ι g j :=\nbegin\n  rw biproduct.map_eq_map',\n  convert limits.is_colimit.ι_map _ _ _ _; refl\nend\n\n@[simp, reassoc]\nlemma biproduct.map_desc [fintype J] {f g : J → C} [has_finite_biproducts C]\n  (p : Π j, f j ⟶ g j) {P : C} (k : Π j, g j ⟶ P) :\n  biproduct.map p ≫ biproduct.desc k = biproduct.desc (λ j, p j ≫ k j) :=\nby { ext, simp, }\n\n@[simp, reassoc]\nlemma biproduct.lift_map [fintype J] {f g : J → C} [has_finite_biproducts C]\n  {P : C} (k : Π j, P ⟶ f j) (p : Π j, f j ⟶ g j)  :\n  biproduct.lift k ≫ biproduct.map p = biproduct.lift (λ j, k j ≫ p j) :=\nby { ext, simp, }\n\n/-- Given a collection of isomorphisms between corresponding summands of a pair of biproducts\nindexed by the same type, we obtain an isomorphism between the biproducts. -/\n@[simps]\ndef biproduct.map_iso [fintype J] {f g : J → C} [has_finite_biproducts C]\n  (p : Π b, f b ≅ g b) : ⨁ f ≅ ⨁ g :=\n{ hom := biproduct.map (λ b, (p b).hom),\n  inv := biproduct.map (λ b, (p b).inv), }\n\nsection\nvariables [fintype J] {K : Type v} [fintype K] [decidable_eq K] {f : J → C} {g : K → C}\n  [has_finite_biproducts C]\n\n/--\nConvert a (dependently typed) matrix to a morphism of biproducts.\n-/\ndef biproduct.matrix (m : Π j k, f j ⟶ g k) : ⨁ f ⟶ ⨁ g :=\nbiproduct.desc (λ j, biproduct.lift (λ k, m j k))\n\n@[simp, reassoc]\nlemma biproduct.matrix_π (m : Π j k, f j ⟶ g k) (k : K) :\n  biproduct.matrix m ≫ biproduct.π g k = biproduct.desc (λ j, m j k) :=\nby { ext, simp [biproduct.matrix], }\n\n@[simp, reassoc]\nlemma biproduct.ι_matrix (m : Π j k, f j ⟶ g k) (j : J) :\n  biproduct.ι f j ≫ biproduct.matrix m = biproduct.lift (λ k, m j k) :=\nby { ext, simp [biproduct.matrix], }\n\n/--\nExtract the matrix components from a morphism of biproducts.\n-/\ndef biproduct.components (m : ⨁ f ⟶ ⨁ g) (j : J) (k : K) : f j ⟶ g k :=\nbiproduct.ι f j ≫ m ≫ biproduct.π g k\n\n@[simp] lemma biproduct.matrix_components (m : Π j k, f j ⟶ g k) (j : J) (k : K) :\n  biproduct.components (biproduct.matrix m) j k = m j k :=\nby simp [biproduct.components]\n\n@[simp] lemma biproduct.components_matrix (m : ⨁ f ⟶ ⨁ g) :\n  biproduct.matrix (λ j k, biproduct.components m j k) = m :=\nby { ext, simp [biproduct.components], }\n\n/-- Morphisms between direct sums are matrices. -/\n@[simps]\ndef biproduct.matrix_equiv : (⨁ f ⟶ ⨁ g) ≃ (Π j k, f j ⟶ g k) :=\n{ to_fun := biproduct.components,\n  inv_fun := biproduct.matrix,\n  left_inv := biproduct.components_matrix,\n  right_inv := λ m, by { ext, apply biproduct.matrix_components } }\n\nend\n\ninstance biproduct.ι_mono (f : J → C) [has_biproduct f]\n  (b : J) : split_mono (biproduct.ι f b) :=\n{ retraction := biproduct.desc $\n    λ b', if h : b' = b then eq_to_hom (congr_arg f h) else biproduct.ι f b' ≫ biproduct.π f b }\n\ninstance biproduct.π_epi (f : J → C) [has_biproduct f]\n  (b : J) : split_epi (biproduct.π f b) :=\n{ section_ := biproduct.lift $\n    λ b', if h : b = b' then eq_to_hom (congr_arg f h) else biproduct.ι f b ≫ biproduct.π f b' }\n\nvariables {C}\n\n/--\nA binary bicone for a pair of objects `P Q : C` consists of the cone point `X`,\nmaps from `X` to both `P` and `Q`, and maps from both `P` and `Q` to `X`,\nso that `inl ≫ fst = 𝟙 P`, `inl ≫ snd = 0`, `inr ≫ fst = 0`, and `inr ≫ snd = 𝟙 Q`\n-/\n@[nolint has_inhabited_instance]\nstructure binary_bicone (P Q : C) :=\n(X : C)\n(fst : X ⟶ P)\n(snd : X ⟶ Q)\n(inl : P ⟶ X)\n(inr : Q ⟶ X)\n(inl_fst' : inl ≫ fst = 𝟙 P . obviously)\n(inl_snd' : inl ≫ snd = 0 . obviously)\n(inr_fst' : inr ≫ fst = 0 . obviously)\n(inr_snd' : inr ≫ snd = 𝟙 Q . obviously)\n\nrestate_axiom binary_bicone.inl_fst'\nrestate_axiom binary_bicone.inl_snd'\nrestate_axiom binary_bicone.inr_fst'\nrestate_axiom binary_bicone.inr_snd'\nattribute [simp, reassoc] binary_bicone.inl_fst binary_bicone.inl_snd\n  binary_bicone.inr_fst binary_bicone.inr_snd\n\nnamespace binary_bicone\nvariables {P Q : C}\n\n/-- Extract the cone from a binary bicone. -/\ndef to_cone (c : binary_bicone P Q) : cone (pair P Q) :=\nbinary_fan.mk c.fst c.snd\n\n@[simp]\nlemma to_cone_X (c : binary_bicone P Q) :\n  c.to_cone.X = c.X := rfl\n\n@[simp]\nlemma to_cone_π_app_left (c : binary_bicone P Q) :\n  c.to_cone.π.app (walking_pair.left) = c.fst := rfl\n@[simp]\nlemma to_cone_π_app_right (c : binary_bicone P Q) :\n  c.to_cone.π.app (walking_pair.right) = c.snd := rfl\n\n/-- Extract the cocone from a binary bicone. -/\ndef to_cocone (c : binary_bicone P Q) : cocone (pair P Q) :=\nbinary_cofan.mk c.inl c.inr\n\n@[simp]\nlemma to_cocone_X (c : binary_bicone P Q) :\n  c.to_cocone.X = c.X := rfl\n\n@[simp]\nlemma to_cocone_ι_app_left (c : binary_bicone P Q) :\n  c.to_cocone.ι.app (walking_pair.left) = c.inl := rfl\n@[simp]\nlemma to_cocone_ι_app_right (c : binary_bicone P Q) :\n  c.to_cocone.ι.app (walking_pair.right) = c.inr := rfl\n\nend binary_bicone\n\nnamespace bicone\n\n/-- Convert a `bicone` over a function on `walking_pair` to a binary_bicone. -/\n@[simps]\ndef to_binary_bicone {X Y : C} (b : bicone (pair X Y).obj) : binary_bicone X Y :=\n{ X := b.X,\n  fst := b.π walking_pair.left,\n  snd := b.π walking_pair.right,\n  inl := b.ι walking_pair.left,\n  inr := b.ι walking_pair.right,\n  inl_fst' := by { simp [bicone.ι_π], refl, },\n  inr_fst' := by simp [bicone.ι_π],\n  inl_snd' := by simp [bicone.ι_π],\n  inr_snd' := by { simp [bicone.ι_π], refl, }, }\n\n/--\nIf the cone obtained from a bicone over `pair X Y` is a limit cone,\nso is the cone obtained by converting that bicone to a binary_bicone, then to a cone.\n-/\ndef to_binary_bicone_is_limit {X Y : C} {b : bicone (pair X Y).obj}\n  (c : is_limit (b.to_cone)) :\n  is_limit (b.to_binary_bicone.to_cone) :=\n{ lift := λ s, c.lift s,\n   fac' := λ s j, by { cases j; erw c.fac, },\n   uniq' := λ s m w,\n   begin\n     apply c.uniq s,\n     rintro (⟨⟩|⟨⟩),\n     exact w walking_pair.left,\n     exact w walking_pair.right,\n   end, }\n\n/--\nIf the cocone obtained from a bicone over `pair X Y` is a colimit cocone,\nso is the cocone obtained by converting that bicone to a binary_bicone, then to a cocone.\n-/\ndef to_binary_bicone_is_colimit {X Y : C} {b : bicone (pair X Y).obj}\n  (c : is_colimit (b.to_cocone)) :\n  is_colimit (b.to_binary_bicone.to_cocone) :=\n{ desc := λ s, c.desc s,\n   fac' := λ s j, by { cases j; erw c.fac, },\n   uniq' := λ s m w,\n   begin\n     apply c.uniq s,\n     rintro (⟨⟩|⟨⟩),\n     exact w walking_pair.left,\n     exact w walking_pair.right,\n   end, }\n\nend bicone\n\n/--\nA bicone over `P Q : C`, which is both a limit cone and a colimit cocone.\n-/\n@[nolint has_inhabited_instance]\nstructure binary_biproduct_data (P Q : C) :=\n(bicone : binary_bicone P Q)\n(is_limit : is_limit bicone.to_cone)\n(is_colimit : is_colimit bicone.to_cocone)\n\n/--\n`has_binary_biproduct P Q` expresses the mere existence of a bicone which is\nsimultaneously a limit and a colimit of the diagram `pair P Q`.\n-/\nclass has_binary_biproduct (P Q : C) : Prop :=\nmk' :: (exists_binary_biproduct : nonempty (binary_biproduct_data P Q))\n\nlemma has_binary_biproduct.mk {P Q : C} (d : binary_biproduct_data P Q) :\n  has_binary_biproduct P Q :=\n⟨nonempty.intro d⟩\n\n/--\nUse the axiom of choice to extract explicit `binary_biproduct_data F` from `has_binary_biproduct F`.\n-/\ndef get_binary_biproduct_data (P Q : C) [has_binary_biproduct P Q] : binary_biproduct_data P Q :=\nclassical.choice has_binary_biproduct.exists_binary_biproduct\n\n/-- A bicone for `P Q ` which is both a limit cone and a colimit cocone. -/\ndef binary_biproduct.bicone (P Q : C) [has_binary_biproduct P Q] : binary_bicone P Q :=\n(get_binary_biproduct_data P Q).bicone\n\n/-- `binary_biproduct.bicone P Q` is a limit cone. -/\ndef binary_biproduct.is_limit (P Q : C) [has_binary_biproduct P Q] :\n  is_limit (binary_biproduct.bicone P Q).to_cone :=\n(get_binary_biproduct_data P Q).is_limit\n\n/-- `binary_biproduct.bicone P Q` is a colimit cocone. -/\ndef binary_biproduct.is_colimit (P Q : C) [has_binary_biproduct P Q] :\n  is_colimit (binary_biproduct.bicone P Q).to_cocone :=\n(get_binary_biproduct_data P Q).is_colimit\n\nsection\nvariable (C)\n\n/--\n`has_binary_biproducts C` represents the existence of a bicone which is\nsimultaneously a limit and a colimit of the diagram `pair P Q`, for every `P Q : C`.\n-/\nclass has_binary_biproducts : Prop :=\n(has_binary_biproduct : Π (P Q : C), has_binary_biproduct P Q)\n\nattribute [instance, priority 100] has_binary_biproducts.has_binary_biproduct\n\n/--\nA category with finite biproducts has binary biproducts.\n\nThis is not an instance as typically in concrete categories there will be\nan alternative construction with nicer definitional properties.\n-/\nlemma has_binary_biproducts_of_finite_biproducts [has_finite_biproducts C] :\n  has_binary_biproducts C :=\n{ has_binary_biproduct := λ P Q, has_binary_biproduct.mk\n  { bicone := (biproduct.bicone (pair P Q).obj).to_binary_bicone,\n    is_limit := bicone.to_binary_bicone_is_limit (biproduct.is_limit _),\n    is_colimit := bicone.to_binary_bicone_is_colimit (biproduct.is_colimit _) } }\n\nend\n\nvariables {P Q : C}\n\ninstance has_binary_biproduct.has_limit_pair [has_binary_biproduct P Q] :\n  has_limit (pair P Q) :=\nhas_limit.mk ⟨_, binary_biproduct.is_limit P Q⟩\n\ninstance has_binary_biproduct.has_colimit_pair [has_binary_biproduct P Q] :\n  has_colimit (pair P Q) :=\nhas_colimit.mk ⟨_, binary_biproduct.is_colimit P Q⟩\n\n@[priority 100]\ninstance has_binary_products_of_has_binary_biproducts [has_binary_biproducts C] :\n  has_binary_products C :=\n{ has_limit := λ F, has_limit_of_iso (diagram_iso_pair F).symm }\n@[priority 100]\ninstance has_binary_coproducts_of_has_binary_biproducts [has_binary_biproducts C] :\n  has_binary_coproducts C :=\n{ has_colimit := λ F, has_colimit_of_iso (diagram_iso_pair F) }\n\n/--\nThe isomorphism between the specified binary product and the specified binary coproduct for\na pair for a binary biproduct.\n-/\ndef biprod_iso (X Y : C) [has_binary_biproduct X Y]  :\n  limits.prod X Y ≅ limits.coprod X Y :=\n(is_limit.cone_point_unique_up_to_iso (limit.is_limit _) (binary_biproduct.is_limit X Y)).trans $\n  is_colimit.cocone_point_unique_up_to_iso (binary_biproduct.is_colimit X Y) (colimit.is_colimit _)\n\n/-- An arbitrary choice of biproduct of a pair of objects. -/\nabbreviation biprod (X Y : C) [has_binary_biproduct X Y] := (binary_biproduct.bicone X Y).X\n\nnotation X ` ⊞ `:20 Y:20 := biprod X Y\n\n/-- The projection onto the first summand of a binary biproduct. -/\nabbreviation biprod.fst {X Y : C} [has_binary_biproduct X Y] : X ⊞ Y ⟶ X :=\n(binary_biproduct.bicone X Y).fst\n/-- The projection onto the second summand of a binary biproduct. -/\nabbreviation biprod.snd {X Y : C} [has_binary_biproduct X Y] : X ⊞ Y ⟶ Y :=\n(binary_biproduct.bicone X Y).snd\n/-- The inclusion into the first summand of a binary biproduct. -/\nabbreviation biprod.inl {X Y : C} [has_binary_biproduct X Y] : X ⟶ X ⊞ Y :=\n(binary_biproduct.bicone X Y).inl\n/-- The inclusion into the second summand of a binary biproduct. -/\nabbreviation biprod.inr {X Y : C} [has_binary_biproduct X Y] : Y ⟶ X ⊞ Y :=\n(binary_biproduct.bicone X Y).inr\n\nsection\nvariables {X Y : C} [has_binary_biproduct X Y]\n\n@[simp] lemma binary_biproduct.bicone_fst : (binary_biproduct.bicone X Y).fst = biprod.fst := rfl\n@[simp] lemma binary_biproduct.bicone_snd : (binary_biproduct.bicone X Y).snd = biprod.snd := rfl\n@[simp] lemma binary_biproduct.bicone_inl : (binary_biproduct.bicone X Y).inl = biprod.inl := rfl\n@[simp] lemma binary_biproduct.bicone_inr : (binary_biproduct.bicone X Y).inr = biprod.inr := rfl\n\nend\n\n@[simp,reassoc]\nlemma biprod.inl_fst {X Y : C} [has_binary_biproduct X Y] :\n  (biprod.inl : X ⟶ X ⊞ Y) ≫ (biprod.fst : X ⊞ Y ⟶ X) = 𝟙 X :=\n(binary_biproduct.bicone X Y).inl_fst\n@[simp,reassoc]\nlemma biprod.inl_snd {X Y : C} [has_binary_biproduct X Y] :\n  (biprod.inl : X ⟶ X ⊞ Y) ≫ (biprod.snd : X ⊞ Y ⟶ Y) = 0 :=\n(binary_biproduct.bicone X Y).inl_snd\n@[simp,reassoc]\nlemma biprod.inr_fst {X Y : C} [has_binary_biproduct X Y] :\n  (biprod.inr : Y ⟶ X ⊞ Y) ≫ (biprod.fst : X ⊞ Y ⟶ X) = 0 :=\n(binary_biproduct.bicone X Y).inr_fst\n@[simp,reassoc]\nlemma biprod.inr_snd {X Y : C} [has_binary_biproduct X Y] :\n  (biprod.inr : Y ⟶ X ⊞ Y) ≫ (biprod.snd : X ⊞ Y ⟶ Y) = 𝟙 Y :=\n(binary_biproduct.bicone X Y).inr_snd\n\n/-- Given a pair of maps into the summands of a binary biproduct,\nwe obtain a map into the binary biproduct. -/\nabbreviation biprod.lift {W X Y : C} [has_binary_biproduct X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  W ⟶ X ⊞ Y :=\n(binary_biproduct.is_limit X Y).lift (binary_fan.mk f g)\n/-- Given a pair of maps out of the summands of a binary biproduct,\nwe obtain a map out of the binary biproduct. -/\nabbreviation biprod.desc {W X Y : C} [has_binary_biproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  X ⊞ Y ⟶ W :=\n(binary_biproduct.is_colimit X Y).desc (binary_cofan.mk f g)\n\n@[simp, reassoc]\nlemma biprod.lift_fst {W X Y : C} [has_binary_biproduct X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  biprod.lift f g ≫ biprod.fst = f :=\n(binary_biproduct.is_limit X Y).fac _ walking_pair.left\n\n@[simp, reassoc]\nlemma biprod.lift_snd {W X Y : C} [has_binary_biproduct X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  biprod.lift f g ≫ biprod.snd = g :=\n(binary_biproduct.is_limit X Y).fac _ walking_pair.right\n\n@[simp, reassoc]\nlemma biprod.inl_desc {W X Y : C} [has_binary_biproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  biprod.inl ≫ biprod.desc f g = f :=\n(binary_biproduct.is_colimit X Y).fac _ walking_pair.left\n\n@[simp, reassoc]\nlemma biprod.inr_desc {W X Y : C} [has_binary_biproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  biprod.inr ≫ biprod.desc f g = g :=\n(binary_biproduct.is_colimit X Y).fac _ walking_pair.right\n\ninstance biprod.mono_lift_of_mono_left {W X Y : C} [has_binary_biproduct X Y] (f : W ⟶ X)\n  (g : W ⟶ Y) [mono f] : mono (biprod.lift f g) :=\nmono_of_mono_fac $ biprod.lift_fst _ _\n\ninstance biprod.mono_lift_of_mono_right {W X Y : C} [has_binary_biproduct X Y] (f : W ⟶ X)\n  (g : W ⟶ Y) [mono g] : mono (biprod.lift f g) :=\nmono_of_mono_fac $ biprod.lift_snd _ _\n\ninstance biprod.epi_desc_of_epi_left {W X Y : C} [has_binary_biproduct X Y] (f : X ⟶ W) (g : Y ⟶ W)\n  [epi f] : epi (biprod.desc f g) :=\nepi_of_epi_fac $ biprod.inl_desc _ _\n\ninstance biprod.epi_desc_of_epi_right {W X Y : C} [has_binary_biproduct X Y] (f : X ⟶ W) (g : Y ⟶ W)\n  [epi g] : epi (biprod.desc f g) :=\nepi_of_epi_fac $ biprod.inr_desc _ _\n\n/-- Given a pair of maps between the summands of a pair of binary biproducts,\nwe obtain a map between the binary biproducts. -/\nabbreviation biprod.map {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : W ⊞ X ⟶ Y ⊞ Z :=\nis_limit.map (binary_biproduct.bicone W X).to_cone (binary_biproduct.is_limit Y Z)\n  (@map_pair _ _ (pair W X) (pair Y Z) f g)\n\n/-- An alternative to `biprod.map` constructed via colimits.\nThis construction only exists in order to show it is equal to `biprod.map`. -/\nabbreviation biprod.map' {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : W ⊞ X ⟶ Y ⊞ Z :=\nis_colimit.map (binary_biproduct.is_colimit W X) (binary_biproduct.bicone Y Z).to_cocone\n  (@map_pair _ _ (pair W X) (pair Y Z) f g)\n\n@[ext] lemma biprod.hom_ext {X Y Z : C} [has_binary_biproduct X Y] (f g : Z ⟶ X ⊞ Y)\n  (h₀ : f ≫ biprod.fst = g ≫ biprod.fst) (h₁ : f ≫ biprod.snd = g ≫ biprod.snd) : f = g :=\nbinary_fan.is_limit.hom_ext (binary_biproduct.is_limit X Y) h₀ h₁\n\n\n@[ext] lemma biprod.hom_ext' {X Y Z : C} [has_binary_biproduct X Y] (f g : X ⊞ Y ⟶ Z)\n  (h₀ : biprod.inl ≫ f = biprod.inl ≫ g) (h₁ : biprod.inr ≫ f = biprod.inr ≫ g) : f = g :=\nbinary_cofan.is_colimit.hom_ext (binary_biproduct.is_colimit X Y) h₀ h₁\n\nlemma biprod.map_eq_map' {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : biprod.map f g = biprod.map' f g :=\nbegin\n  ext,\n  { simp only [map_pair_left, is_colimit.ι_map, is_limit.map_π, biprod.inl_fst_assoc,\n    category.assoc, ←binary_bicone.to_cone_π_app_left, ←binary_biproduct.bicone_fst,\n    ←binary_bicone.to_cocone_ι_app_left, ←binary_biproduct.bicone_inl],\n    simp },\n  { simp only [map_pair_left, is_colimit.ι_map, is_limit.map_π, zero_comp,\n      biprod.inl_snd_assoc, category.assoc,\n      ←binary_bicone.to_cone_π_app_right, ←binary_biproduct.bicone_snd,\n      ←binary_bicone.to_cocone_ι_app_left, ←binary_biproduct.bicone_inl],\n    simp },\n  { simp only [map_pair_right, biprod.inr_fst_assoc, is_colimit.ι_map, is_limit.map_π,\n      zero_comp, category.assoc,\n      ←binary_bicone.to_cone_π_app_left, ←binary_biproduct.bicone_fst,\n      ←binary_bicone.to_cocone_ι_app_right, ←binary_biproduct.bicone_inr],\n    simp },\n  { simp only [map_pair_right, is_colimit.ι_map, is_limit.map_π, biprod.inr_snd_assoc,\n      category.assoc, ←binary_bicone.to_cone_π_app_right, ←binary_biproduct.bicone_snd,\n      ←binary_bicone.to_cocone_ι_app_right, ←binary_biproduct.bicone_inr],\n    simp }\nend\n\ninstance biprod.inl_mono {X Y : C} [has_binary_biproduct X Y] :\n  split_mono (biprod.inl : X ⟶ X ⊞ Y) :=\n{ retraction := biprod.desc (𝟙 X) (biprod.inr ≫ biprod.fst) }\n\ninstance biprod.inr_mono {X Y : C} [has_binary_biproduct X Y] :\n  split_mono (biprod.inr : Y ⟶ X ⊞ Y) :=\n{ retraction := biprod.desc (biprod.inl ≫ biprod.snd) (𝟙 Y)}\n\ninstance biprod.fst_epi {X Y : C} [has_binary_biproduct X Y] :\n  split_epi (biprod.fst : X ⊞ Y ⟶ X) :=\n{ section_ := biprod.lift (𝟙 X) (biprod.inl ≫ biprod.snd) }\n\ninstance biprod.snd_epi {X Y : C} [has_binary_biproduct X Y] :\n  split_epi (biprod.snd : X ⊞ Y ⟶ Y) :=\n{ section_ := biprod.lift (biprod.inr ≫ biprod.fst) (𝟙 Y) }\n\n@[simp,reassoc]\nlemma biprod.map_fst {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) :\n  biprod.map f g ≫ biprod.fst = biprod.fst ≫ f :=\nis_limit.map_π _ _ _ walking_pair.left\n\n@[simp,reassoc]\nlemma biprod.map_snd {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) :\n  biprod.map f g ≫ biprod.snd = biprod.snd ≫ g :=\nis_limit.map_π _ _ _ walking_pair.right\n\n-- Because `biprod.map` is defined in terms of `lim` rather than `colim`,\n-- we need to provide additional `simp` lemmas.\n@[simp,reassoc]\nlemma biprod.inl_map {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) :\n  biprod.inl ≫ biprod.map f g = f ≫ biprod.inl :=\nbegin\n  rw biprod.map_eq_map',\n  exact is_colimit.ι_map (binary_biproduct.is_colimit W X) _ _ walking_pair.left\nend\n\n@[simp,reassoc]\nlemma biprod.inr_map {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) :\n  biprod.inr ≫ biprod.map f g = g ≫ biprod.inr :=\nbegin\n  rw biprod.map_eq_map',\n  exact is_colimit.ι_map (binary_biproduct.is_colimit W X) _ _ walking_pair.right\nend\n\n/-- Given a pair of isomorphisms between the summands of a pair of binary biproducts,\nwe obtain an isomorphism between the binary biproducts. -/\n@[simps]\ndef biprod.map_iso {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W ≅ Y) (g : X ≅ Z) : W ⊞ X ≅ Y ⊞ Z :=\n{ hom := biprod.map f.hom g.hom,\n  inv := biprod.map f.inv g.inv }\n\nsection\nvariables [has_binary_biproducts C]\n\n/-- The braiding isomorphism which swaps a binary biproduct. -/\n@[simps] def biprod.braiding (P Q : C) : P ⊞ Q ≅ Q ⊞ P :=\n{ hom := biprod.lift biprod.snd biprod.fst,\n  inv := biprod.lift biprod.snd biprod.fst }\n\n/--\nAn alternative formula for the braiding isomorphism which swaps a binary biproduct,\nusing the fact that the biproduct is a coproduct.\n-/\n@[simps]\ndef biprod.braiding' (P Q : C) : P ⊞ Q ≅ Q ⊞ P :=\n{ hom := biprod.desc biprod.inr biprod.inl,\n  inv := biprod.desc biprod.inr biprod.inl }\n\nlemma biprod.braiding'_eq_braiding {P Q : C} :\n  biprod.braiding' P Q = biprod.braiding P Q :=\nby tidy\n\n/-- The braiding isomorphism can be passed through a map by swapping the order. -/\n@[reassoc] lemma biprod.braid_natural {W X Y Z : C} (f : X ⟶ Y) (g : Z ⟶ W) :\n  biprod.map f g ≫ (biprod.braiding _ _).hom = (biprod.braiding _ _).hom ≫ biprod.map g f :=\nby tidy\n\n@[reassoc] lemma biprod.braiding_map_braiding {W X Y Z : C} (f : W ⟶ Y) (g : X ⟶ Z) :\n  (biprod.braiding X W).hom ≫ biprod.map f g ≫ (biprod.braiding Y Z).hom = biprod.map g f :=\nby tidy\n\n@[simp, reassoc] lemma biprod.symmetry' (P Q : C) :\n  biprod.lift biprod.snd biprod.fst ≫ biprod.lift biprod.snd biprod.fst = 𝟙 (P ⊞ Q) :=\nby tidy\n\n/-- The braiding isomorphism is symmetric. -/\n@[reassoc] lemma biprod.symmetry (P Q : C) :\n  (biprod.braiding P Q).hom ≫ (biprod.braiding Q P).hom = 𝟙 _ :=\nby simp\n\nend\n\n-- TODO:\n-- If someone is interested, they could provide the constructions:\n--   has_binary_biproducts ↔ has_finite_biproducts\n\nend category_theory.limits\n\nnamespace category_theory.limits\n\nsection preadditive\nvariables {C : Type u} [category.{v} C] [preadditive C]\nvariables {J : Type v} [decidable_eq J] [fintype J]\n\nopen category_theory.preadditive\nopen_locale big_operators\n\n/--\nIn a preadditive category, we can construct a biproduct for `f : J → C` from\nany bicone `b` for `f` satisfying `total : ∑ j : J, b.π j ≫ b.ι j = 𝟙 b.X`.\n\n(That is, such a bicone is a limit cone and a colimit cocone.)\n-/\nlemma has_biproduct_of_total {f : J → C} (b : bicone f) (total : ∑ j : J, b.π j ≫ b.ι j = 𝟙 b.X) :\n  has_biproduct f :=\nhas_biproduct.mk\n{ bicone := b,\n  is_limit :=\n  { lift := λ s, ∑ j, s.π.app j ≫ b.ι j,\n    uniq' := λ s m h,\n    begin\n      erw [←category.comp_id m, ←total, comp_sum],\n      apply finset.sum_congr rfl,\n      intros j m,\n      erw [reassoc_of (h j)],\n    end,\n    fac' := λ s j,\n    begin\n      simp only [sum_comp, category.assoc, bicone.to_cone_π_app, b.ι_π, comp_dite],\n      -- See note [dsimp, simp].\n      dsimp, simp,\n    end },\n  is_colimit :=\n  { desc := λ s, ∑ j, b.π j ≫ s.ι.app j,\n    uniq' := λ s m h,\n    begin\n      erw [←category.id_comp m, ←total, sum_comp],\n            apply finset.sum_congr rfl,\n      intros j m,\n      erw [category.assoc, h],\n    end,\n    fac' := λ s j,\n    begin\n      simp only [comp_sum, ←category.assoc, bicone.to_cocone_ι_app, b.ι_π, dite_comp],\n      dsimp, simp,\n    end } }\n\n/-- In a preadditive category, if the product over `f : J → C` exists,\n    then the biproduct over `f` exists. -/\nlemma has_biproduct.of_has_product (f : J → C) [has_product f] :\n  has_biproduct f :=\nhas_biproduct_of_total\n{ X := pi_obj f,\n  π := limits.pi.π f,\n  ι := λ j, pi.lift (λ j', if h : j = j' then eq_to_hom (congr_arg f h) else 0),\n  ι_π := λ j j', by simp, }\n(by { ext, simp [sum_comp, comp_dite] })\n\n/-- In a preadditive category, if the coproduct over `f : J → C` exists,\n    then the biproduct over `f` exists. -/\nlemma has_biproduct.of_has_coproduct (f : J → C) [has_coproduct f] :\n  has_biproduct f :=\nhas_biproduct_of_total\n{ X := sigma_obj f,\n  π := λ j, sigma.desc (λ j', if h : j' = j then eq_to_hom (congr_arg f h) else 0),\n  ι := limits.sigma.ι f,\n  ι_π := λ j j', by simp, }\nbegin\n  ext,\n  simp only [comp_sum, limits.colimit.ι_desc_assoc, eq_self_iff_true,\n    limits.colimit.ι_desc, category.comp_id],\n  dsimp,\n  simp only [dite_comp, finset.sum_dite_eq, finset.mem_univ, if_true, category.id_comp,\n    eq_to_hom_refl, zero_comp],\nend\n\n/-- A preadditive category with finite products has finite biproducts. -/\nlemma has_finite_biproducts.of_has_finite_products [has_finite_products C] :\n  has_finite_biproducts C :=\n⟨λ J _ _, { has_biproduct := λ F, by exactI has_biproduct.of_has_product _ }⟩\n\n/-- A preadditive category with finite coproducts has finite biproducts. -/\nlemma has_finite_biproducts.of_has_finite_coproducts [has_finite_coproducts C] :\n  has_finite_biproducts C :=\n⟨λ J _ _, { has_biproduct := λ F, by exactI has_biproduct.of_has_coproduct _ }⟩\n\nsection\nvariables {f : J → C} [has_biproduct f]\n\n/--\nIn any preadditive category, any biproduct satsifies\n`∑ j : J, biproduct.π f j ≫ biproduct.ι f j = 𝟙 (⨁ f)`\n-/\n@[simp] lemma biproduct.total : ∑ j : J, biproduct.π f j ≫ biproduct.ι f j = 𝟙 (⨁ f) :=\nbegin\n  ext j j',\n  simp [comp_sum, sum_comp, biproduct.ι_π, comp_dite, dite_comp],\nend\n\nlemma biproduct.lift_eq {T : C} {g : Π j, T ⟶ f j} :\n  biproduct.lift g = ∑ j, g j ≫ biproduct.ι f j :=\nbegin\n  ext j,\n  simp [sum_comp, biproduct.ι_π, comp_dite],\nend\n\nlemma biproduct.desc_eq {T : C} {g : Π j, f j ⟶ T} :\n  biproduct.desc g = ∑ j, biproduct.π f j ≫ g j :=\nbegin\n  ext j,\n  simp [comp_sum, biproduct.ι_π_assoc, dite_comp],\nend\n\n@[simp, reassoc] lemma biproduct.lift_desc {T U : C} {g : Π j, T ⟶ f j} {h : Π j, f j ⟶ U} :\n  biproduct.lift g ≫ biproduct.desc h = ∑ j : J, g j ≫ h j :=\nby simp [biproduct.lift_eq, biproduct.desc_eq, comp_sum, sum_comp, biproduct.ι_π_assoc,\n  comp_dite, dite_comp]\n\nlemma biproduct.map_eq [has_finite_biproducts C] {f g : J → C} {h : Π j, f j ⟶ g j} :\n  biproduct.map h = ∑ j : J, biproduct.π f j ≫ h j ≫ biproduct.ι g j :=\nbegin\n  ext,\n  simp [biproduct.ι_π, biproduct.ι_π_assoc, comp_sum, sum_comp, comp_dite, dite_comp],\nend\n\n@[simp, reassoc]\nlemma biproduct.matrix_desc\n  {K : Type v} [fintype K] [decidable_eq K] [has_finite_biproducts C]\n  {f : J → C} {g : K → C} (m : Π j k, f j ⟶ g k) {P} (x : Π k, g k ⟶ P) :\n  biproduct.matrix m ≫ biproduct.desc x = biproduct.desc (λ j, ∑ k, m j k ≫ x k) :=\nby { ext, simp, }\n\n@[simp, reassoc]\nlemma biproduct.lift_matrix\n  {K : Type v} [fintype K] [decidable_eq K] [has_finite_biproducts C]\n  {f : J → C} {g : K → C} {P} (x : Π j, P ⟶ f j) (m : Π j k, f j ⟶ g k)  :\n  biproduct.lift x ≫ biproduct.matrix m = biproduct.lift (λ k, ∑ j, x j ≫ m j k) :=\nby { ext, simp, }\n\n@[reassoc]\nlemma biproduct.matrix_map\n  {K : Type v} [fintype K] [decidable_eq K] [has_finite_biproducts C]\n  {f : J → C} {g : K → C} {h : K → C} (m : Π j k, f j ⟶ g k) (n : Π k, g k ⟶ h k) :\n  biproduct.matrix m ≫ biproduct.map n = biproduct.matrix (λ j k, m j k ≫ n k) :=\nby { ext, simp, }\n\n@[reassoc]\nlemma biproduct.map_matrix\n  {K : Type v} [fintype K] [decidable_eq K] [has_finite_biproducts C]\n  {f : J → C} {g : J → C} {h : K → C} (m : Π k, f k ⟶ g k) (n : Π j k, g j ⟶ h k) :\n  biproduct.map m ≫ biproduct.matrix n = biproduct.matrix (λ j k, m j ≫ n j k) :=\nby { ext, simp, }\n\nend\n\n/--\nIn a preadditive category, we can construct a binary biproduct for `X Y : C` from\nany binary bicone `b` satisfying `total : b.fst ≫ b.inl + b.snd ≫ b.inr = 𝟙 b.X`.\n\n(That is, such a bicone is a limit cone and a colimit cocone.)\n-/\nlemma has_binary_biproduct_of_total {X Y : C} (b : binary_bicone X Y)\n  (total : b.fst ≫ b.inl + b.snd ≫ b.inr = 𝟙 b.X) :\n  has_binary_biproduct X Y :=\nhas_binary_biproduct.mk\n{ bicone := b,\n  is_limit :=\n  { lift := λ s, binary_fan.fst s ≫ b.inl +\n      binary_fan.snd s ≫ b.inr,\n    uniq' := λ s m h, by erw [←category.comp_id m, ←total,\n      comp_add, reassoc_of (h walking_pair.left), reassoc_of (h walking_pair.right)],\n    fac' := λ s j, by cases j; simp, },\n  is_colimit :=\n  { desc := λ s, b.fst ≫ binary_cofan.inl s +\n      b.snd ≫ binary_cofan.inr s,\n    uniq' := λ s m h, by erw [←category.id_comp m, ←total,\n      add_comp, category.assoc, category.assoc, h walking_pair.left, h walking_pair.right],\n    fac' := λ s j, by cases j; simp, } }\n\n/-- In a preadditive category, if the product of `X` and `Y` exists, then the\n    binary biproduct of `X` and `Y` exists. -/\nlemma has_binary_biproduct.of_has_binary_product (X Y : C) [has_binary_product X Y] :\n  has_binary_biproduct X Y :=\nhas_binary_biproduct_of_total\n{ X := X ⨯ Y,\n  fst := category_theory.limits.prod.fst,\n  snd := category_theory.limits.prod.snd,\n  inl := prod.lift (𝟙 X) 0,\n  inr := prod.lift 0 (𝟙 Y) }\nbegin\n  ext; simp [add_comp],\nend\n\n/-- In a preadditive category, if all binary products exist, then all binary biproducts exist. -/\nlemma has_binary_biproducts.of_has_binary_products [has_binary_products C] :\n  has_binary_biproducts C :=\n{ has_binary_biproduct := λ X Y, has_binary_biproduct.of_has_binary_product X Y, }\n\n/-- In a preadditive category, if the coproduct of `X` and `Y` exists, then the\n    binary biproduct of `X` and `Y` exists. -/\nlemma has_binary_biproduct.of_has_binary_coproduct (X Y : C) [has_binary_coproduct X Y] :\n  has_binary_biproduct X Y :=\nhas_binary_biproduct_of_total\n{ X := X ⨿ Y,\n  fst := coprod.desc (𝟙 X) 0,\n  snd := coprod.desc 0 (𝟙 Y),\n  inl := category_theory.limits.coprod.inl,\n  inr := category_theory.limits.coprod.inr }\nbegin\n  ext; simp [add_comp],\nend\n\n/-- In a preadditive category, if all binary coproducts exist, then all binary biproducts exist. -/\nlemma has_binary_biproducts.of_has_binary_coproducts [has_binary_coproducts C] :\n  has_binary_biproducts C :=\n{ has_binary_biproduct := λ X Y, has_binary_biproduct.of_has_binary_coproduct X Y, }\n\nsection\nvariables {X Y : C} [has_binary_biproduct X Y]\n\n/--\nIn any preadditive category, any binary biproduct satsifies\n`biprod.fst ≫ biprod.inl + biprod.snd ≫ biprod.inr = 𝟙 (X ⊞ Y)`.\n-/\n@[simp] lemma biprod.total : biprod.fst ≫ biprod.inl + biprod.snd ≫ biprod.inr = 𝟙 (X ⊞ Y) :=\nbegin\n  ext; simp [add_comp],\nend\n\nlemma biprod.lift_eq {T : C} {f : T ⟶ X} {g : T ⟶ Y} :\n  biprod.lift f g = f ≫ biprod.inl + g ≫ biprod.inr :=\nbegin\n  ext; simp [add_comp],\nend\n\nlemma biprod.desc_eq {T : C} {f : X ⟶ T} {g : Y ⟶ T} :\n  biprod.desc f g = biprod.fst ≫ f + biprod.snd ≫ g :=\nbegin\n  ext; simp [add_comp],\nend\n\n@[simp, reassoc] lemma biprod.lift_desc {T U : C} {f : T ⟶ X} {g : T ⟶ Y} {h : X ⟶ U} {i : Y ⟶ U} :\n  biprod.lift f g ≫ biprod.desc h i = f ≫ h + g ≫ i :=\nby simp [biprod.lift_eq, biprod.desc_eq]\n\n\nlemma biprod.map_eq [has_binary_biproducts C] {W X Y Z : C} {f : W ⟶ Y} {g : X ⟶ Z} :\n  biprod.map f g = biprod.fst ≫ f ≫ biprod.inl + biprod.snd ≫ g ≫ biprod.inr :=\nby apply biprod.hom_ext; apply biprod.hom_ext'; simp\n\nend\n\nend preadditive\n\nend category_theory.limits\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/shapes/biproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.647798211152541, "lm_q1q2_score": 0.46138272696148236}}
{"text": "/-\nCopyright (c) 2020 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.pi\nimport Mathlib.data.prod\nimport Mathlib.logic.unique\nimport Mathlib.logic.function.basic\nimport Mathlib.PostPort\n\nuniverses u_3 l u_1 u_2 u_4 \n\nnamespace Mathlib\n\n/-!\n# Nontrivial types\n\nA type is *nontrivial* if it contains at least two elements. This is useful in particular for rings\n(where it is equivalent to the fact that zero is different from one) and for vector spaces\n(where it is equivalent to the fact that the dimension is positive).\n\nWe introduce a typeclass `nontrivial` formalizing this property.\n-/\n\n/-- Predicate typeclass for expressing that a type is not reduced to a single element. In rings,\nthis is equivalent to `0 ≠ 1`. In vector spaces, this is equivalent to positive dimension. -/\nclass nontrivial (α : Type u_3) \nwhere\n  exists_pair_ne : ∃ (x : α), ∃ (y : α), x ≠ y\n\ntheorem nontrivial_iff {α : Type u_1} : nontrivial α ↔ ∃ (x : α), ∃ (y : α), x ≠ y :=\n  { mp := fun (h : nontrivial α) => nontrivial.exists_pair_ne,\n    mpr := fun (h : ∃ (x : α), ∃ (y : α), x ≠ y) => nontrivial.mk h }\n\ntheorem exists_pair_ne (α : Type u_1) [nontrivial α] : ∃ (x : α), ∃ (y : α), x ≠ y :=\n  nontrivial.exists_pair_ne\n\ntheorem exists_ne {α : Type u_1} [nontrivial α] (x : α) : ∃ (y : α), y ≠ x := sorry\n\n-- `x` and `y` are explicit here, as they are often needed to guide typechecking of `h`.\n\ntheorem nontrivial_of_ne {α : Type u_1} (x : α) (y : α) (h : x ≠ y) : nontrivial α :=\n  nontrivial.mk (Exists.intro x (Exists.intro y h))\n\n-- `x` and `y` are explicit here, as they are often needed to guide typechecking of `h`.\n\ntheorem nontrivial_of_lt {α : Type u_1} [preorder α] (x : α) (y : α) (h : x < y) : nontrivial α :=\n  nontrivial.mk (Exists.intro x (Exists.intro y (ne_of_lt h)))\n\nprotected instance nontrivial.to_nonempty {α : Type u_1} [nontrivial α] : Nonempty α :=\n  sorry\n\n/-- An inhabited type is either nontrivial, or has a unique element. -/\ndef nontrivial_psum_unique (α : Type u_1) [Inhabited α] : psum (nontrivial α) (unique α) :=\n  dite (nontrivial α) (fun (h : nontrivial α) => psum.inl h)\n    fun (h : ¬nontrivial α) => psum.inr (unique.mk { default := Inhabited.default } sorry)\n\ntheorem subsingleton_iff {α : Type u_1} : subsingleton α ↔ ∀ (x y : α), x = y :=\n  { mp := fun (h : subsingleton α) => subsingleton.elim, mpr := fun (h : ∀ (x y : α), x = y) => subsingleton.intro h }\n\ntheorem not_nontrivial_iff_subsingleton {α : Type u_1} : ¬nontrivial α ↔ subsingleton α := sorry\n\ntheorem not_subsingleton (α : Type u_1) [h : nontrivial α] : ¬subsingleton α := sorry\n\n/-- A type is either a subsingleton or nontrivial. -/\ntheorem subsingleton_or_nontrivial (α : Type u_1) : subsingleton α ∨ nontrivial α :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (subsingleton α ∨ nontrivial α)) (Eq.symm (propext not_nontrivial_iff_subsingleton))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (¬nontrivial α ∨ nontrivial α)) (propext (or_comm (¬nontrivial α) (nontrivial α)))))\n      (classical.em (nontrivial α)))\n\ntheorem false_of_nontrivial_of_subsingleton (α : Type u_1) [nontrivial α] [subsingleton α] : False := sorry\n\nprotected instance option.nontrivial {α : Type u_1} [Nonempty α] : nontrivial (Option α) :=\n  nonempty.elim_to_inhabited\n    fun (inst : Inhabited α) =>\n      nontrivial.mk\n        (Exists.intro none\n          (Exists.intro (some Inhabited.default)\n            (id (id fun (ᾰ : none = some Inhabited.default) => option.no_confusion ᾰ))))\n\n/-- Pushforward a `nontrivial` instance along an injective function. -/\nprotected theorem function.injective.nontrivial {α : Type u_1} {β : Type u_2} [nontrivial α] {f : α → β} (hf : function.injective f) : nontrivial β := sorry\n\n/-- Pullback a `nontrivial` instance along a surjective function. -/\nprotected theorem function.surjective.nontrivial {α : Type u_1} {β : Type u_2} [nontrivial β] {f : α → β} (hf : function.surjective f) : nontrivial α := sorry\n\n/-- An injective function from a nontrivial type has an argument at\nwhich it does not take a given value. -/\nprotected theorem function.injective.exists_ne {α : Type u_1} {β : Type u_2} [nontrivial α] {f : α → β} (hf : function.injective f) (y : β) : ∃ (x : α), f x ≠ y := sorry\n\nprotected instance nontrivial_prod_right {α : Type u_1} {β : Type u_2} [Nonempty α] [nontrivial β] : nontrivial (α × β) :=\n  function.surjective.nontrivial prod.snd_surjective\n\nprotected instance nontrivial_prod_left {α : Type u_1} {β : Type u_2} [nontrivial α] [Nonempty β] : nontrivial (α × β) :=\n  function.surjective.nontrivial prod.fst_surjective\n\nnamespace pi\n\n\n/-- A pi type is nontrivial if it's nonempty everywhere and nontrivial somewhere. -/\ntheorem nontrivial_at {I : Type u_3} {f : I → Type u_4} (i' : I) [inst : ∀ (i : I), Nonempty (f i)] [nontrivial (f i')] : nontrivial ((i : I) → f i) :=\n  function.injective.nontrivial (function.update_injective (fun (i : I) => Classical.choice (inst i)) i')\n\n/--\nAs a convenience, provide an instance automatically if `(f (default I))` is nontrivial.\n\nIf a different index has the non-trivial type, then use `haveI := nontrivial_at that_index`.\n-/\nprotected instance nontrivial {I : Type u_3} {f : I → Type u_4} [Inhabited I] [inst : ∀ (i : I), Nonempty (f i)] [nontrivial (f Inhabited.default)] : nontrivial ((i : I) → f i) :=\n  nontrivial_at Inhabited.default\n\nend pi\n\n\nprotected instance function.nontrivial {α : Type u_1} {β : Type u_2} [h : Nonempty α] [nontrivial β] : nontrivial (α → β) :=\n  nonempty.elim h fun (a : α) => pi.nontrivial_at a\n\nprotected theorem subsingleton.le {α : Type u_1} [preorder α] [subsingleton α] (x : α) (y : α) : x ≤ y :=\n  le_of_eq (subsingleton.elim x y)\n\nnamespace tactic\n\n\n/--\nTries to generate a `nontrivial α` instance by performing case analysis on\n`subsingleton_or_nontrivial α`,\nattempting to discharge the subsingleton branch using lemmas with `@[nontriviality]` attribute,\nincluding `subsingleton.le` and `eq_iff_true_of_subsingleton`.\n-/\n/--\nTries to generate a `nontrivial α` instance using `nontrivial_of_ne` or `nontrivial_of_lt`\nand local hypotheses.\n-/\nend tactic\n\n\nnamespace tactic.interactive\n\n\n/--\nAttempts to generate a `nontrivial α` hypothesis.\n\nThe tactic first looks for an instance using `apply_instance`.\n\nIf the goal is an (in)equality, the type `α` is inferred from the goal.\nOtherwise, the type needs to be specified in the tactic invocation, as `nontriviality α`.\n\nThe `nontriviality` tactic will first look for strict inequalities amongst the hypotheses,\nand use these to derive the `nontrivial` instance directly.\n\nOtherwise, it will perform a case split on `subsingleton α ∨ nontrivial α`, and attempt to discharge\nthe `subsingleton` goal using `simp [lemmas] with nontriviality`, where `[lemmas]` is a list of\nadditional `simp` lemmas that can be passed to `nontriviality` using the syntax\n`nontriviality α using [lemmas]`.\n\n```\nexample {R : Type} [ordered_ring R] {a : R} (h : 0 < a) : 0 < a :=\nbegin\n  nontriviality, -- There is now a `nontrivial R` hypothesis available.\n  assumption,\nend\n```\n\n```\nexample {R : Type} [comm_ring R] {r s : R} : r * s = s * r :=\nbegin\n  nontriviality, -- There is now a `nontrivial R` hypothesis available.\n  apply mul_comm,\nend\n```\n\n```\nexample {R : Type} [ordered_ring R] {a : R} (h : 0 < a) : (2 : ℕ) ∣ 4 :=\nbegin\n  nontriviality R, -- there is now a `nontrivial R` hypothesis available.\n  dec_trivial\nend\n```\n\n```\ndef myeq {α : Type} (a b : α) : Prop := a = b\n\nexample {α : Type} (a b : α) (h : a = b) : myeq a b :=\nbegin\n  success_if_fail { nontriviality α }, -- Fails\n  nontriviality α using [myeq], -- There is now a `nontrivial α` hypothesis available\n  assumption\nend\n```\n-/\nend tactic.interactive\n\n\nnamespace bool\n\n\nprotected instance nontrivial : nontrivial Bool :=\n  nontrivial.mk (Exists.intro tt (Exists.intro false tt_eq_ff_eq_false))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/logic/nontrivial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.4612837054135786}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.list.forall2\n\n/-!\n# List sections\n\nThis file proves some stuff about `list.sections` (definition in `data.list.defs`). A section of a\nlist of lists `[l₁, ..., lₙ]` is a list whose `i`-th element comes from the `i`-th list.\n-/\n\n\nopen nat function\n\nnamespace list\nvariables {α β : Type*}\n\ntheorem mem_sections {L : list (list α)} {f} : f ∈ sections L ↔ forall₂ (∈) f L :=\nbegin\n  refine ⟨λ h, _, λ h, _⟩,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall₂.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with ⟨_, _, _, _, rfl⟩,\n    simp only [*, forall₂_cons, true_and] },\n  { induction h with a l f L al fL fs, {exact or.inl rfl},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map],\n    exact ⟨_, fs, _, al, rfl, rfl⟩ }\nend\n\ntheorem mem_sections_length {L : list (list α)} {f} (h : f ∈ sections L) : length f = length L :=\nforall₂_length_eq (mem_sections.1 h)\n\nlemma rel_sections {r : α → β → Prop} :\n  (forall₂ (forall₂ r) ⇒ forall₂ (forall₂ r)) sections sections\n| _ _ forall₂.nil := forall₂.cons forall₂.nil forall₂.nil\n| _ _ (forall₂.cons h₀ h₁) :=\n  rel_bind (rel_sections h₁) (assume _ _ hl, rel_map (assume _ _ ha, forall₂.cons ha hl) h₀)\n\nend list\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/data/list/sections.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791786861878392, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.4612836877718393}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Ken Lee, Chris Hughes\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.ring\nimport Mathlib.algebra.big_operators.basic\nimport Mathlib.data.fintype.basic\nimport Mathlib.data.int.gcd\nimport Mathlib.data.set.disjointed\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# Coprime elements of a ring\n\n## Main definitions\n\n* `is_coprime x y`: that `x` and `y` are coprime, defined to be the existence of `a` and `b` such\nthat `a * x + b * y = 1`. Note that elements with no common divisors are not necessarily coprime,\ne.g., the multivariate polynomials `x₁` and `x₂` are not coprime.\n\n-/\n\n/-- The proposition that `x` and `y` are coprime, defined to be the existence of `a` and `b` such\nthat `a * x + b * y = 1`. Note that elements with no common divisors are not necessarily coprime,\ne.g., the multivariate polynomials `x₁` and `x₂` are not coprime. -/\n@[simp] def is_coprime {R : Type u} [comm_semiring R] (x : R) (y : R) :=\n  ∃ (a : R), ∃ (b : R), a * x + b * y = 1\n\ntheorem nat.is_coprime_iff_coprime {m : ℕ} {n : ℕ} : is_coprime ↑m ↑n ↔ nat.coprime m n := sorry\n\ntheorem is_coprime.symm {R : Type u} [comm_semiring R] {x : R} {y : R} (H : is_coprime x y) : is_coprime y x := sorry\n\ntheorem is_coprime_comm {R : Type u} [comm_semiring R] {x : R} {y : R} : is_coprime x y ↔ is_coprime y x :=\n  { mp := is_coprime.symm, mpr := is_coprime.symm }\n\ntheorem is_coprime_self {R : Type u} [comm_semiring R] {x : R} : is_coprime x x ↔ is_unit x := sorry\n\ntheorem is_coprime_zero_left {R : Type u} [comm_semiring R] {x : R} : is_coprime 0 x ↔ is_unit x := sorry\n\ntheorem is_coprime_zero_right {R : Type u} [comm_semiring R] {x : R} : is_coprime x 0 ↔ is_unit x :=\n  iff.trans is_coprime_comm is_coprime_zero_left\n\ntheorem is_coprime_one_left {R : Type u} [comm_semiring R] {x : R} : is_coprime 1 x := sorry\n\ntheorem is_coprime_one_right {R : Type u} [comm_semiring R] {x : R} : is_coprime x 1 := sorry\n\ntheorem is_coprime.dvd_of_dvd_mul_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H1 : is_coprime x z) (H2 : x ∣ y * z) : x ∣ y := sorry\n\ntheorem is_coprime.dvd_of_dvd_mul_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H1 : is_coprime x y) (H2 : x ∣ y * z) : x ∣ z := sorry\n\ntheorem is_coprime.mul_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H1 : is_coprime x z) (H2 : is_coprime y z) : is_coprime (x * y) z := sorry\n\ntheorem is_coprime.mul_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H1 : is_coprime x y) (H2 : is_coprime x z) : is_coprime x (y * z) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x (y * z))) (propext is_coprime_comm)))\n    (is_coprime.mul_left (eq.mp (Eq._oldrec (Eq.refl (is_coprime x y)) (propext is_coprime_comm)) H1)\n      (eq.mp (Eq._oldrec (Eq.refl (is_coprime x z)) (propext is_coprime_comm)) H2))\n\ntheorem is_coprime.prod_left {R : Type u} [comm_semiring R] {x : R} {I : Type v} {s : I → R} {t : finset I} : (∀ (i : I), i ∈ t → is_coprime (s i) x) → is_coprime (finset.prod t fun (i : I) => s i) x := sorry\n\ntheorem is_coprime.prod_right {R : Type u} [comm_semiring R] {x : R} {I : Type v} {s : I → R} {t : finset I} : (∀ (i : I), i ∈ t → is_coprime x (s i)) → is_coprime x (finset.prod t fun (i : I) => s i) := sorry\n\ntheorem is_coprime.mul_dvd {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H : is_coprime x y) (H1 : x ∣ z) (H2 : y ∣ z) : x * y ∣ z := sorry\n\ntheorem finset.prod_dvd_of_coprime {R : Type u} [comm_semiring R] {z : R} {I : Type v} {s : I → R} {t : finset I} (Hs : set.pairwise_on (↑t) (is_coprime on s)) (Hs1 : ∀ (i : I), i ∈ t → s i ∣ z) : (finset.prod t fun (x : I) => s x) ∣ z := sorry\n\ntheorem fintype.prod_dvd_of_coprime {R : Type u} [comm_semiring R] {z : R} {I : Type v} {s : I → R} [fintype I] (Hs : pairwise (is_coprime on s)) (Hs1 : ∀ (i : I), s i ∣ z) : (finset.prod finset.univ fun (x : I) => s x) ∣ z :=\n  finset.prod_dvd_of_coprime (pairwise.pairwise_on Hs ↑finset.univ) fun (i : I) (_x : i ∈ finset.univ) => Hs1 i\n\ntheorem is_coprime.of_mul_left_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H : is_coprime (x * y) z) : is_coprime x z := sorry\n\ntheorem is_coprime.of_mul_left_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H : is_coprime (x * y) z) : is_coprime y z :=\n  is_coprime.of_mul_left_left (eq.mp (Eq._oldrec (Eq.refl (is_coprime (x * y) z)) (mul_comm x y)) H)\n\ntheorem is_coprime.of_mul_right_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H : is_coprime x (y * z)) : is_coprime x y :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x y)) (propext is_coprime_comm)))\n    (is_coprime.of_mul_left_left (eq.mp (Eq._oldrec (Eq.refl (is_coprime x (y * z))) (propext is_coprime_comm)) H))\n\ntheorem is_coprime.of_mul_right_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (H : is_coprime x (y * z)) : is_coprime x z :=\n  is_coprime.of_mul_right_left (eq.mp (Eq._oldrec (Eq.refl (is_coprime x (y * z))) (mul_comm y z)) H)\n\ntheorem is_coprime.mul_left_iff {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} : is_coprime (x * y) z ↔ is_coprime x z ∧ is_coprime y z := sorry\n\ntheorem is_coprime.mul_right_iff {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} : is_coprime x (y * z) ↔ is_coprime x y ∧ is_coprime x z := sorry\n\ntheorem is_coprime.prod_left_iff {R : Type u} [comm_semiring R] {x : R} {I : Type v} {s : I → R} {t : finset I} : is_coprime (finset.prod t fun (i : I) => s i) x ↔ ∀ (i : I), i ∈ t → is_coprime (s i) x := sorry\n\ntheorem is_coprime.prod_right_iff {R : Type u} [comm_semiring R] {x : R} {I : Type v} {s : I → R} {t : finset I} : is_coprime x (finset.prod t fun (i : I) => s i) ↔ ∀ (i : I), i ∈ t → is_coprime x (s i) := sorry\n\ntheorem is_coprime.of_prod_left {R : Type u} [comm_semiring R] {x : R} {I : Type v} {s : I → R} {t : finset I} (H1 : is_coprime (finset.prod t fun (i : I) => s i) x) (i : I) (hit : i ∈ t) : is_coprime (s i) x :=\n  iff.mp is_coprime.prod_left_iff H1 i hit\n\ntheorem is_coprime.of_prod_right {R : Type u} [comm_semiring R] {x : R} {I : Type v} {s : I → R} {t : finset I} (H1 : is_coprime x (finset.prod t fun (i : I) => s i)) (i : I) (hit : i ∈ t) : is_coprime x (s i) :=\n  iff.mp is_coprime.prod_right_iff H1 i hit\n\ntheorem is_coprime.pow_left {R : Type u} [comm_semiring R] {x : R} {y : R} {m : ℕ} (H : is_coprime x y) : is_coprime (x ^ m) y :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime (x ^ m) y)) (Eq.symm (finset.card_range m))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime (x ^ finset.card (finset.range m)) y)) (Eq.symm (finset.prod_const x))))\n      (is_coprime.prod_left fun (_x : ℕ) (_x : _x ∈ finset.range m) => H))\n\ntheorem is_coprime.pow_right {R : Type u} [comm_semiring R] {x : R} {y : R} {n : ℕ} (H : is_coprime x y) : is_coprime x (y ^ n) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x (y ^ n))) (Eq.symm (finset.card_range n))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x (y ^ finset.card (finset.range n)))) (Eq.symm (finset.prod_const y))))\n      (is_coprime.prod_right fun (_x : ℕ) (_x : _x ∈ finset.range n) => H))\n\ntheorem is_coprime.pow {R : Type u} [comm_semiring R] {x : R} {y : R} {m : ℕ} {n : ℕ} (H : is_coprime x y) : is_coprime (x ^ m) (y ^ n) :=\n  is_coprime.pow_right (is_coprime.pow_left H)\n\ntheorem is_coprime.is_unit_of_dvd {R : Type u} [comm_semiring R] {x : R} {y : R} (H : is_coprime x y) (d : x ∣ y) : is_unit x := sorry\n\ntheorem is_coprime.map {R : Type u} [comm_semiring R] {x : R} {y : R} (H : is_coprime x y) {S : Type v} [comm_semiring S] (f : R →+* S) : is_coprime (coe_fn f x) (coe_fn f y) := sorry\n\ntheorem is_coprime.of_add_mul_left_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime (x + y * z) y) : is_coprime x y := sorry\n\ntheorem is_coprime.of_add_mul_right_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime (x + z * y) y) : is_coprime x y :=\n  is_coprime.of_add_mul_left_left (eq.mp (Eq._oldrec (Eq.refl (is_coprime (x + z * y) y)) (mul_comm z y)) h)\n\ntheorem is_coprime.of_add_mul_left_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime x (y + x * z)) : is_coprime x y :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x y)) (propext is_coprime_comm)))\n    (is_coprime.of_add_mul_left_left\n      (eq.mp (Eq._oldrec (Eq.refl (is_coprime x (y + x * z))) (propext is_coprime_comm)) h))\n\ntheorem is_coprime.of_add_mul_right_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime x (y + z * x)) : is_coprime x y :=\n  is_coprime.of_add_mul_left_right (eq.mp (Eq._oldrec (Eq.refl (is_coprime x (y + z * x))) (mul_comm z x)) h)\n\ntheorem is_coprime.of_mul_add_left_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime (y * z + x) y) : is_coprime x y :=\n  is_coprime.of_add_mul_left_left (eq.mp (Eq._oldrec (Eq.refl (is_coprime (y * z + x) y)) (add_comm (y * z) x)) h)\n\ntheorem is_coprime.of_mul_add_right_left {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime (z * y + x) y) : is_coprime x y :=\n  is_coprime.of_add_mul_right_left (eq.mp (Eq._oldrec (Eq.refl (is_coprime (z * y + x) y)) (add_comm (z * y) x)) h)\n\ntheorem is_coprime.of_mul_add_left_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime x (x * z + y)) : is_coprime x y :=\n  is_coprime.of_add_mul_left_right (eq.mp (Eq._oldrec (Eq.refl (is_coprime x (x * z + y))) (add_comm (x * z) y)) h)\n\ntheorem is_coprime.of_mul_add_right_right {R : Type u} [comm_semiring R] {x : R} {y : R} {z : R} (h : is_coprime x (z * x + y)) : is_coprime x y :=\n  is_coprime.of_add_mul_right_right (eq.mp (Eq._oldrec (Eq.refl (is_coprime x (z * x + y))) (add_comm (z * x) y)) h)\n\nnamespace is_coprime\n\n\ntheorem add_mul_left_left {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime (x + y * z) y := sorry\n\ntheorem add_mul_right_left {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime (x + z * y) y :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime (x + z * y) y)) (mul_comm z y))) (add_mul_left_left h z)\n\ntheorem add_mul_left_right {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime x (y + x * z) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x (y + x * z))) (propext is_coprime_comm))) (add_mul_left_left (symm h) z)\n\ntheorem add_mul_right_right {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime x (y + z * x) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x (y + z * x))) (propext is_coprime_comm))) (add_mul_right_left (symm h) z)\n\ntheorem mul_add_left_left {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime (y * z + x) y :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime (y * z + x) y)) (add_comm (y * z) x))) (add_mul_left_left h z)\n\ntheorem mul_add_right_left {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime (z * y + x) y :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime (z * y + x) y)) (add_comm (z * y) x))) (add_mul_right_left h z)\n\ntheorem mul_add_left_right {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime x (x * z + y) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x (x * z + y))) (add_comm (x * z) y))) (add_mul_left_right h z)\n\ntheorem mul_add_right_right {R : Type u} [comm_ring R] {x : R} {y : R} (h : is_coprime x y) (z : R) : is_coprime x (z * x + y) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_coprime x (z * x + y))) (add_comm (z * x) y))) (add_mul_right_right h z)\n\ntheorem add_mul_left_left_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime (x + y * z) y ↔ is_coprime x y :=\n  { mp := of_add_mul_left_left, mpr := fun (h : is_coprime x y) => add_mul_left_left h z }\n\ntheorem add_mul_right_left_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime (x + z * y) y ↔ is_coprime x y :=\n  { mp := of_add_mul_right_left, mpr := fun (h : is_coprime x y) => add_mul_right_left h z }\n\ntheorem add_mul_left_right_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime x (y + x * z) ↔ is_coprime x y :=\n  { mp := of_add_mul_left_right, mpr := fun (h : is_coprime x y) => add_mul_left_right h z }\n\ntheorem add_mul_right_right_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime x (y + z * x) ↔ is_coprime x y :=\n  { mp := of_add_mul_right_right, mpr := fun (h : is_coprime x y) => add_mul_right_right h z }\n\ntheorem mul_add_left_left_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime (y * z + x) y ↔ is_coprime x y :=\n  { mp := of_mul_add_left_left, mpr := fun (h : is_coprime x y) => mul_add_left_left h z }\n\ntheorem mul_add_right_left_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime (z * y + x) y ↔ is_coprime x y :=\n  { mp := of_mul_add_right_left, mpr := fun (h : is_coprime x y) => mul_add_right_left h z }\n\ntheorem mul_add_left_right_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime x (x * z + y) ↔ is_coprime x y :=\n  { mp := of_mul_add_left_right, mpr := fun (h : is_coprime x y) => mul_add_left_right h z }\n\ntheorem mul_add_right_right_iff {R : Type u} [comm_ring R] {x : R} {y : R} {z : R} : is_coprime x (z * x + y) ↔ is_coprime x y :=\n  { mp := of_mul_add_right_right, mpr := fun (h : is_coprime x y) => mul_add_right_right h z }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/coprime.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.46125916730122557}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport topology.sheaves.presheaf\nimport category_theory.adjunction.fully_faithful\n\n/-!\n# Presheafed spaces\n\nIntroduces the category of topological spaces equipped with a presheaf (taking values in an\narbitrary target category `C`.)\n\nWe further describe how to apply functors and natural transformations to the values of the\npresheaves.\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.category category_theory.functor\n\nvariables (C : Type u) [category.{v} C]\n\nlocal attribute [tidy] tactic.op_induction'\n\nnamespace algebraic_geometry\n\n/-- A `PresheafedSpace C` is a topological space equipped with a presheaf of `C`s. -/\nstructure PresheafedSpace :=\n(carrier : Top)\n(presheaf : carrier.presheaf C)\n\nvariables {C}\n\nnamespace PresheafedSpace\n\nattribute [protected] presheaf\n\ninstance coe_carrier : has_coe (PresheafedSpace C) Top :=\n{ coe := λ X, X.carrier }\n\n@[simp] lemma as_coe (X : PresheafedSpace C) : X.carrier = (X : Top.{v}) := rfl\n@[simp] lemma mk_coe (carrier) (presheaf) : (({ carrier := carrier, presheaf := presheaf } :\n  PresheafedSpace.{v} C) : Top.{v}) = carrier := rfl\n\ninstance (X : PresheafedSpace.{v} C) : topological_space X := X.carrier.str\n\n/-- The constant presheaf on `X` with value `Z`. -/\ndef const (X : Top) (Z : C) : PresheafedSpace C :=\n{ carrier := X,\n  presheaf :=\n  { obj := λ U, Z,\n    map := λ U V f, 𝟙 Z, } }\n\ninstance [inhabited C] : inhabited (PresheafedSpace C) := ⟨const (Top.of pempty) default⟩\n\n/-- A morphism between presheafed spaces `X` and `Y` consists of a continuous map\n    `f` between the underlying topological spaces, and a (notice contravariant!) map\n    from the presheaf on `Y` to the pushforward of the presheaf on `X` via `f`. -/\nstructure hom (X Y : PresheafedSpace C) :=\n(base : (X : Top.{v}) ⟶ (Y : Top.{v}))\n(c : Y.presheaf ⟶ base _* X.presheaf)\n\n@[ext] lemma ext {X Y : PresheafedSpace C} (α β : hom X Y)\n  (w : α.base = β.base)\n  (h : α.c ≫ (whisker_right (eq_to_hom (by rw w)) _) = β.c) :\n  α = β :=\nbegin\n  cases α, cases β,\n  dsimp [presheaf.pushforward_obj] at *,\n  tidy, -- TODO including `injections` would make tidy work earlier.\nend\n\nlemma hext {X Y : PresheafedSpace C} (α β : hom X Y)\n  (w : α.base = β.base)\n  (h : α.c == β.c) :\n  α = β :=\nby { cases α, cases β, congr, exacts [w,h] }\n\n.\n\n/-- The identity morphism of a `PresheafedSpace`. -/\ndef id (X : PresheafedSpace C) : hom X X :=\n{ base := 𝟙 (X : Top.{v}),\n  c := eq_to_hom (presheaf.pushforward.id_eq X.presheaf).symm }\n\ninstance hom_inhabited (X : PresheafedSpace C) : inhabited (hom X X) := ⟨id X⟩\n\n/-- Composition of morphisms of `PresheafedSpace`s. -/\ndef comp {X Y Z : PresheafedSpace C} (α : hom X Y) (β : hom Y Z) : hom X Z :=\n{ base := α.base ≫ β.base,\n  c := β.c ≫ (presheaf.pushforward _ β.base).map α.c }\n\nlemma comp_c {X Y Z : PresheafedSpace C} (α : hom X Y) (β : hom Y Z) :\n  (comp α β).c = β.c ≫ (presheaf.pushforward _ β.base).map α.c := rfl\n\n\nvariables (C)\n\nsection\nlocal attribute [simp] id comp\n\n/- The proofs below can be done by `tidy`, but it is too slow,\n   and we don't have a tactic caching mechanism. -/\n/-- The category of PresheafedSpaces. Morphisms are pairs, a continuous map and a presheaf map\n    from the presheaf on the target to the pushforward of the presheaf on the source. -/\ninstance category_of_PresheafedSpaces : category (PresheafedSpace C) :=\n{ hom := hom,\n  id := id,\n  comp := λ X Y Z f g, comp f g,\n  id_comp' := λ X Y f, begin\n    ext1,\n    { rw comp_c,\n      erw eq_to_hom_map,\n      simp only [eq_to_hom_refl, assoc, whisker_right_id'],\n      erw [comp_id, comp_id] },\n    apply id_comp\n  end,\n  comp_id' := λ X Y f, begin\n    ext1,\n    { rw comp_c,\n      erw congr_hom (presheaf.id_pushforward _) f.c,\n      simp only [comp_id, functor.id_map, eq_to_hom_refl, assoc, whisker_right_id'],\n      erw eq_to_hom_trans_assoc,\n      simp only [id_comp, eq_to_hom_refl],\n      erw comp_id },\n    apply comp_id\n  end,\n  assoc' := λ W X Y Z f g h, begin\n    ext1,\n    repeat {rw comp_c},\n    simp only [eq_to_hom_refl, assoc, functor.map_comp, whisker_right_id'],\n    erw comp_id,\n    congr,\n    refl\n  end }\n\nend\n\nvariables {C}\n\n@[simp] lemma id_base (X : PresheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).base = 𝟙 (X : Top.{v}) := rfl\n\nlemma id_c (X : PresheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).c = eq_to_hom (presheaf.pushforward.id_eq X.presheaf).symm := rfl\n\n@[simp] lemma id_c_app (X : PresheafedSpace C) (U) :\n  ((𝟙 X) : X ⟶ X).c.app U = X.presheaf.map\n    (eq_to_hom (by { induction U using opposite.rec, cases U, refl })) :=\nby { induction U using opposite.rec, cases U, simp only [id_c], dsimp, simp, }\n\n@[simp] lemma comp_base {X Y Z : PresheafedSpace C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).base = f.base ≫ g.base := rfl\n\ninstance (X Y : PresheafedSpace C) : has_coe_to_fun (X ⟶ Y) (λ _, X → Y) :=\n⟨λ f, f.base⟩\n\nlemma coe_to_fun_eq {X Y : PresheafedSpace C} (f : X ⟶ Y) : (f : X → Y) = f.base := rfl\n\n-- The `reassoc` attribute was added despite the LHS not being a composition of two homs,\n-- for the reasons explained in the docstring.\n/-- Sometimes rewriting with `comp_c_app` doesn't work because of dependent type issues.\nIn that case, `erw comp_c_app_assoc` might make progress.\nThe lemma `comp_c_app_assoc` is also better suited for rewrites in the opposite direction. -/\n@[reassoc, simp] lemma comp_c_app {X Y Z : PresheafedSpace C} (α : X ⟶ Y) (β : Y ⟶ Z) (U) :\n  (α ≫ β).c.app U = (β.c).app U ≫ (α.c).app (op ((opens.map (β.base)).obj (unop U))) := rfl\n\nlemma congr_app {X Y : PresheafedSpace C} {α β : X ⟶ Y} (h : α = β) (U) :\n  α.c.app U = β.c.app U ≫ X.presheaf.map (eq_to_hom (by subst h)) :=\nby { subst h, dsimp, simp, }\n\nsection\nvariables (C)\n\n/-- The forgetful functor from `PresheafedSpace` to `Top`. -/\n@[simps]\ndef forget : PresheafedSpace C ⥤ Top :=\n{ obj := λ X, (X : Top.{v}),\n  map := λ X Y f, f.base }\n\nend\n\nsection iso\n\nvariables {X Y : PresheafedSpace C}\n\n/--\nAn isomorphism of PresheafedSpaces is a homeomorphism of the underlying space, and a\nnatural transformation between the sheaves.\n-/\n@[simps hom inv]\ndef iso_of_components (H : X.1 ≅ Y.1) (α : H.hom _* X.2 ≅ Y.2) : X ≅ Y :=\n{ hom := { base := H.hom, c := α.inv },\n  inv := { base := H.inv,\n    c := presheaf.to_pushforward_of_iso H α.hom },\n  hom_inv_id' := by { ext, { simp, erw category.id_comp, simpa }, simp },\n  inv_hom_id' :=\n  begin\n    ext x,\n    induction x using opposite.rec,\n    simp only [comp_c_app, whisker_right_app, presheaf.to_pushforward_of_iso_app,\n      nat_trans.comp_app, eq_to_hom_app, id_c_app, category.assoc],\n    erw [← α.hom.naturality],\n    have := nat_trans.congr_app (α.inv_hom_id) (op x),\n    cases x,\n    rw nat_trans.comp_app at this,\n    convert this,\n    { dsimp, simp },\n    { simp },\n    { simp }\n  end }\n\n/-- Isomorphic PresheafedSpaces have natural isomorphic presheaves. -/\n@[simps]\ndef sheaf_iso_of_iso (H : X ≅ Y) : Y.2 ≅ H.hom.base _* X.2 :=\n{ hom := H.hom.c,\n  inv := presheaf.pushforward_to_of_iso ((forget _).map_iso H).symm H.inv.c,\n  hom_inv_id' :=\n  begin\n    ext U,\n    have := congr_app H.inv_hom_id U,\n    simp only [comp_c_app, id_c_app,\n      eq_to_hom_map, eq_to_hom_trans] at this,\n    generalize_proofs h at this,\n    simpa using congr_arg (λ f, f ≫ eq_to_hom h.symm) this,\n  end,\n  inv_hom_id' :=\n  begin\n    ext U,\n    simp only [presheaf.pushforward_to_of_iso_app, nat_trans.comp_app, category.assoc,\n      nat_trans.id_app, H.hom.c.naturality],\n    have := congr_app H.hom_inv_id ((opens.map H.hom.base).op.obj U),\n    generalize_proofs h at this,\n    simpa using congr_arg (λ f, f ≫ X.presheaf.map (eq_to_hom h.symm)) this\n  end }\n\ninstance base_is_iso_of_iso (f : X ⟶ Y) [is_iso f] : is_iso f.base :=\nis_iso.of_iso ((forget _).map_iso (as_iso f))\n\ninstance c_is_iso_of_iso (f : X ⟶ Y) [is_iso f] : is_iso f.c :=\nis_iso.of_iso (sheaf_iso_of_iso (as_iso f))\n\n/-- This could be used in conjunction with `category_theory.nat_iso.is_iso_of_is_iso_app`. -/\nlemma is_iso_of_components (f : X ⟶ Y) [is_iso f.base] [is_iso f.c] : is_iso f :=\nbegin\n  convert is_iso.of_iso (iso_of_components (as_iso f.base) (as_iso f.c).symm),\n  ext, { simpa }, { simp },\nend\n\nend iso\n\nsection restrict\n\n/--\nThe restriction of a presheafed space along an open embedding into the space.\n-/\n@[simps]\ndef restrict {U : Top} (X : PresheafedSpace C)\n  {f : U ⟶ (X : Top.{v})} (h : open_embedding f) : PresheafedSpace C :=\n{ carrier := U,\n  presheaf := h.is_open_map.functor.op ⋙ X.presheaf }\n\n/--\nThe map from the restriction of a presheafed space.\n-/\n@[simps]\ndef of_restrict {U : Top} (X : PresheafedSpace C)\n  {f : U ⟶ (X : Top.{v})} (h : open_embedding f) :\n  X.restrict h ⟶ X :=\n{ base := f,\n  c := { app := λ V, X.presheaf.map (h.is_open_map.adjunction.counit.app V.unop).op,\n    naturality' := λ U V f, show _ = _ ≫ X.presheaf.map _,\n      by { rw [← map_comp, ← map_comp], refl } } }\n\ninstance of_restrict_mono {U : Top} (X : PresheafedSpace C) (f : U ⟶ X.1)\n   (hf : open_embedding f) : mono (X.of_restrict hf) :=\n begin\n   haveI : mono f := (Top.mono_iff_injective _).mpr hf.inj,\n   constructor,\n   intros Z g₁ g₂ eq,\n   ext V,\n   { induction V using opposite.rec,\n     have hV : (opens.map (X.of_restrict hf).base).obj (hf.is_open_map.functor.obj V) = V,\n     { cases V, simp[opens.map, set.preimage_image_eq _ hf.inj] },\n     haveI : is_iso (hf.is_open_map.adjunction.counit.app\n               (unop (op (hf.is_open_map.functor.obj V)))) :=\n       (nat_iso.is_iso_app_of_is_iso (whisker_left\n         hf.is_open_map.functor hf.is_open_map.adjunction.counit) V : _),\n     have := PresheafedSpace.congr_app eq (op (hf.is_open_map.functor.obj V)),\n     simp only [PresheafedSpace.comp_c_app, PresheafedSpace.of_restrict_c_app, category.assoc,\n       cancel_epi] at this,\n     have h : _ ≫ _ = _ ≫ _ ≫ _ :=\n       congr_arg (λ f, (X.restrict hf).presheaf.map (eq_to_hom hV).op ≫ f) this,\n     erw [g₁.c.naturality, g₂.c.naturality_assoc] at h,\n     simp only [presheaf.pushforward_obj_map, eq_to_hom_op,\n       category.assoc, eq_to_hom_map, eq_to_hom_trans] at h,\n     rw ←is_iso.comp_inv_eq at h,\n     simpa using h },\n   { have := congr_arg PresheafedSpace.hom.base eq,\n     simp only [PresheafedSpace.comp_base, PresheafedSpace.of_restrict_base] at this,\n     rw cancel_mono at this,\n     exact this }\n end\n\n\n\nlemma of_restrict_top_c (X : PresheafedSpace C) :\n  (X.of_restrict (opens.open_embedding ⊤)).c = eq_to_hom\n    (by { rw [restrict_top_presheaf, ←presheaf.pushforward.comp_eq],\n          erw iso.inv_hom_id, rw presheaf.pushforward.id_eq }) :=\n  /- another approach would be to prove the left hand side\n     is a natural isoomorphism, but I encountered a universe\n     issue when `apply nat_iso.is_iso_of_is_iso_app`. -/\nbegin\n  ext U, change X.presheaf.map _ = _, convert eq_to_hom_map _ _ using 1,\n  congr, simpa,\n  { induction U using opposite.rec, dsimp, congr, ext,\n    exact ⟨ λ h, ⟨⟨x,trivial⟩,h,rfl⟩, λ ⟨⟨_,_⟩,h,rfl⟩, h ⟩ },\n  /- or `rw [opens.inclusion_top_functor, ←comp_obj, ←opens.map_comp_eq],\n         erw iso.inv_hom_id, cases U, refl` after `dsimp` -/\nend\n\n/--\nThe map to the restriction of a presheafed space along the canonical inclusion from the top\nsubspace.\n-/\n@[simps]\ndef to_restrict_top (X : PresheafedSpace C) :\n  X ⟶ X.restrict (opens.open_embedding ⊤) :=\n{ base := (opens.inclusion_top_iso X.carrier).inv,\n  c := eq_to_hom (restrict_top_presheaf X) }\n\n/--\nThe isomorphism from the restriction to the top subspace.\n-/\n@[simps]\ndef restrict_top_iso (X : PresheafedSpace C) :\n  X.restrict (opens.open_embedding ⊤) ≅ X :=\n{ hom := X.of_restrict _,\n  inv := X.to_restrict_top,\n  hom_inv_id' := ext _ _ (concrete_category.hom_ext _ _ $ λ ⟨x, _⟩, rfl) $\n    by { erw comp_c, rw X.of_restrict_top_c, ext, simp },\n  inv_hom_id' := ext _ _ rfl $\n    by { erw comp_c, rw X.of_restrict_top_c, ext, simpa [-eq_to_hom_refl] } }\n\nend restrict\n\n/--\nThe global sections, notated Gamma.\n-/\n@[simps]\ndef Γ : (PresheafedSpace C)ᵒᵖ ⥤ C :=\n{ obj := λ X, (unop X).presheaf.obj (op ⊤),\n  map := λ X Y f, f.unop.c.app (op ⊤) }\n\nlemma Γ_obj_op (X : PresheafedSpace C) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\nlemma Γ_map_op {X Y : PresheafedSpace C} (f : X ⟶ Y) :\n  Γ.map f.op = f.c.app (op ⊤) := rfl\n\nend PresheafedSpace\n\nend algebraic_geometry\n\nopen algebraic_geometry algebraic_geometry.PresheafedSpace\n\nvariables {C}\n\nnamespace category_theory\n\nvariables {D : Type u} [category.{v} D]\n\nlocal attribute [simp] presheaf.pushforward_obj\n\nnamespace functor\n\n/-- We can apply a functor `F : C ⥤ D` to the values of the presheaf in any `PresheafedSpace C`,\n    giving a functor `PresheafedSpace C ⥤ PresheafedSpace D` -/\ndef map_presheaf (F : C ⥤ D) : PresheafedSpace C ⥤ PresheafedSpace D :=\n{ obj := λ X, { carrier := X.carrier, presheaf := X.presheaf ⋙ F },\n  map := λ X Y f, { base := f.base, c := whisker_right f.c F }, }\n\n@[simp] lemma map_presheaf_obj_X (F : C ⥤ D) (X : PresheafedSpace C) :\n  ((F.map_presheaf.obj X) : Top.{v}) = (X : Top.{v}) := rfl\n@[simp] lemma map_presheaf_obj_presheaf (F : C ⥤ D) (X : PresheafedSpace C) :\n  (F.map_presheaf.obj X).presheaf = X.presheaf ⋙ F := rfl\n@[simp] lemma map_presheaf_map_f (F : C ⥤ D) {X Y : PresheafedSpace C} (f : X ⟶ Y) :\n  (F.map_presheaf.map f).base = f.base := rfl\n@[simp] lemma map_presheaf_map_c (F : C ⥤ D) {X Y : PresheafedSpace C} (f : X ⟶ Y) :\n  (F.map_presheaf.map f).c = whisker_right f.c F := rfl\n\nend functor\n\nnamespace nat_trans\n\n/--\nA natural transformation induces a natural transformation between the `map_presheaf` functors.\n-/\ndef on_presheaf {F G : C ⥤ D} (α : F ⟶ G) : G.map_presheaf ⟶ F.map_presheaf :=\n{ app := λ X,\n  { base := 𝟙 _,\n    c := whisker_left X.presheaf α ≫ eq_to_hom (presheaf.pushforward.id_eq _).symm } }\n\n-- TODO Assemble the last two constructions into a functor\n--   `(C ⥤ D) ⥤ (PresheafedSpace C ⥤ PresheafedSpace D)`\nend nat_trans\n\nend category_theory\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebraic_geometry/presheafed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.4612591628440931}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport combinatorics.simplicial_complex.basic\n\nnamespace affine\nopen set\nvariables {m n : ℕ} {E : Type*} [normed_group E] [normed_space ℝ E] {S : simplicial_complex E}\n  {X Y : finset E}\n\n/--\nA simplicial complex is finite iff it has finitely many faces.\n-/\ndef simplicial_complex.finite (S : simplicial_complex E) : Prop := S.faces.finite\n\nnoncomputable def simplicial_complex.faces_finset (S : simplicial_complex E) (hS : S.finite) :\n  finset (finset E) :=\nhS.to_finset\n\n@[simp]\nlemma mem_faces_finset (hS : S.finite) :\n  X ∈ S.faces_finset hS ↔ X ∈ S.faces :=\nset.finite.mem_to_finset _\n\n/--\nA simplicial complex `S` is locally finite at the face `X` iff `X` is a subface of finitely many\nfaces in `S`.\n-/\ndef simplicial_complex.locally_finite_at (S : simplicial_complex E) (X : finset E) : Prop :=\nset.finite {Y ∈ S.faces | X ⊆ Y}\n\n/--\nA simplicial complex `S` is locally finite at the face `X` iff `X` is a subface of infinitely many\nfaces in `S`.\n-/\ndef simplicial_complex.locally_infinite_at (S : simplicial_complex E) (X : finset E) : Prop :=\nset.infinite {Y ∈ S.faces | X ⊆ Y}\n\nlemma simplicial_complex.locally_finite_at_iff_not_locally_infinite_at :\n  ¬S.locally_infinite_at X ↔ S.locally_finite_at X :=\nnot_not\n\n/--\nA simplicial complex is locally finite iff each of its nonempty faces belongs to finitely many faces.\n-/\ndef simplicial_complex.locally_finite (S : simplicial_complex E) : Prop :=\n∀ {X : finset _}, X ∈ S.faces → X.nonempty → S.locally_finite_at X\n\nexample {α : Type*} {s : set α} {p q : α → Prop} (h : ∀ x, p x → q x) :\n  {x ∈ s | p x} ⊆ {x ∈ s | q x} :=\nbegin\n  refine inter_subset_inter_right s h,\nend\n\nlemma locally_finite_at_up_closed (hX : S.locally_finite_at X) (hXY : X ⊆ Y) :\n  S.locally_finite_at Y :=\nbegin\n  apply hX.subset,\n  rintro Z ⟨_, _⟩,\n  exact ⟨‹Z ∈ S.faces›, finset.subset.trans hXY ‹Y ⊆ Z›⟩,\nend\n\nlemma locally_infinite_at_down_closed (hY : S.locally_infinite_at Y) (hXY : X ⊆ Y) :\n  S.locally_infinite_at X :=\nλ t, hY (locally_finite_at_up_closed t hXY)\n\nlemma locally_finite_of_finite (hS : S.finite) :\n  S.locally_finite :=\nλ X hX _, hS.subset (λ Y hY, hY.1)\n\n/--\nA simplicial complex is locally finite iff each point belongs to finitely many faces.\n-/\nlemma locally_finite_iff_mem_finitely_many_faces [decidable_eq E] :\n  S.locally_finite ↔ ∀ (x : E), finite {X | X ∈ S.faces ∧ x ∈ convex_hull (X : set E)} :=\nbegin\n  split,\n  { unfold simplicial_complex.locally_finite,\n    contrapose!,\n    rintro ⟨x, hx⟩,\n    by_cases hxspace : x ∈ S.space,\n    { obtain ⟨X, ⟨hX, hXhull, hXbound⟩, hXunique⟩ := combi_interiors_partition hxspace,\n      simp at hXunique,\n      use [X, hX],\n      split,\n      { apply finset.nonempty_of_ne_empty,\n        rintro rfl,\n        simpa using hXhull },\n      rintro hXlocallyfinite,\n      apply hx,\n      suffices h : {X : finset E | X ∈ S.faces ∧ x ∈ convex_hull ↑X} ⊆\n        {Y : finset E | Y ∈ S.faces ∧ X ⊆ Y},\n      { exact finite.subset hXlocallyfinite h },\n      rintro Y ⟨hY, hYhull⟩,\n      use hY,\n      have hXYhull := S.disjoint hX hY ⟨hXhull, hYhull⟩,\n      rw ←finset.coe_inter at hXYhull,\n      by_contra hXY,\n      apply hXbound,\n      have hYX : X ∩ Y ⊂ X,\n      { use finset.inter_subset_left X Y,\n        rintro hXXY,\n        exact hXY (finset.subset_inter_iff.1 hXXY).2 },\n      exact mem_combi_frontier_iff.2 ⟨X ∩ Y, hYX, hXYhull⟩ },\n    { exfalso,\n      apply hx,\n      suffices h : {X : finset E | X ∈ S.faces ∧ x ∈ convex_hull ↑X} = ∅,\n      { rw h,\n        exact finite_empty },\n      apply eq_empty_of_subset_empty,\n      rintro X ⟨hX, h⟩,\n      exact hxspace (mem_bUnion hX h) }},\n  { rintro hS X hX h,\n    obtain ⟨x, hx⟩ := h,\n    suffices h : {Y : finset E | Y ∈ S.faces ∧ X ⊆ Y} ⊆\n      {Y : finset E | Y ∈ S.faces ∧ x ∈ convex_hull ↑Y},\n    { exact (hS x).subset h },\n    rintro Y ⟨hY, hXY⟩,\n    exact ⟨hY, subset_convex_hull Y (hXY hx)⟩ }\nend\n\nend affine\n", "meta": {"author": "mmasdeu", "repo": "brouwerfixedpoint", "sha": "548270f79ecf12d7e20a256806ccb9fcf57b87e2", "save_path": "github-repos/lean/mmasdeu-brouwerfixedpoint", "path": "github-repos/lean/mmasdeu-brouwerfixedpoint/brouwerfixedpoint-548270f79ecf12d7e20a256806ccb9fcf57b87e2/src/combinatorics/simplicial_complex/finite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723317123102956, "lm_q2_score": 0.6859494614282922, "lm_q1q2_score": 0.46118557596040877}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.functor\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l u₃ v₃ \n\nnamespace Mathlib\n\n/-!\n# Unbundled functors, as a typeclass decorating the object-level function.\n-/\n\nnamespace category_theory\n\n\n/-- A unbundled functor. -/\n-- Perhaps in the future we could redefine `functor` in terms of this, but that isn't the\n\n-- immediate plan.\n\nclass functorial {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C → D) where\n  map : {X Y : C} → (X ⟶ Y) → (F X ⟶ F Y)\n  map_id' :\n    autoParam (C → map 𝟙 = 𝟙)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  map_comp' :\n    autoParam (∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = map f ≫ map g)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n/--\nIf `F : C → D` (just a function) has `[functorial F]`,\nwe can write `map F f : F X ⟶ F Y` for the action of `F` on a morphism `f : X ⟶ Y`.\n-/\ndef map {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C → D) [functorial F] {X : C}\n    {Y : C} (f : X ⟶ Y) : F X ⟶ F Y :=\n  functorial.map f\n\n@[simp] theorem map_as_map {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C → D}\n    [functorial F] {X : C} {Y : C} {f : X ⟶ Y} : functorial.map f = map F f :=\n  rfl\n\n@[simp] theorem functorial.map_id {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C → D}\n    [functorial F] {X : C} : map F 𝟙 = 𝟙 :=\n  functorial.map_id' X\n\n@[simp] theorem functorial.map_comp {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C → D} [functorial F] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} :\n    map F (f ≫ g) = map F f ≫ map F g :=\n  functorial.map_comp' f g\n\nnamespace functor\n\n\n/--\nBundle a functorial function as a functor.\n-/\ndef of {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C → D) [I : functorial F] :\n    C ⥤ D :=\n  mk F functorial.map\n\nend functor\n\n\nprotected instance functor.obj.functorial {C : Type u₁} [category C] {D : Type u₂} [category D]\n    (F : C ⥤ D) : functorial (functor.obj F) :=\n  functorial.mk (functor.map F)\n\n@[simp] theorem map_functorial_obj {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D)\n    {X : C} {Y : C} (f : X ⟶ Y) : map (functor.obj F) f = functor.map F f :=\n  rfl\n\nprotected instance functorial_id {C : Type u₁} [category C] : functorial id :=\n  functorial.mk fun (X Y : C) (f : X ⟶ Y) => f\n\n/--\n`G ∘ F` is a functorial if both `F` and `G` are.\n-/\n-- This is no longer viable as an instance in Lean 3.7,\n\n-- #lint reports an instance loop\n\n-- Will this be a problem?\n\ndef functorial_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E]\n    (F : C → D) [functorial F] (G : D → E) [functorial G] : functorial (G ∘ F) :=\n  functorial.mk (functor.map (functor.of F ⋙ functor.of G))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/functorial_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.685949467848392, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.46118557577324093}}
{"text": "/-\nCopyright (c) 2022 Joanna Choules. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joanna Choules\n-/\nimport category_theory.cofiltered_system\nimport combinatorics.simple_graph.subgraph\n\n/-!\n# Homomorphisms from finite subgraphs\n\nThis file defines the type of finite subgraphs of a `simple_graph` and proves a compactness result\nfor homomorphisms to a finite codomain.\n\n## Main statements\n\n* `simple_graph.exists_hom_of_all_finite_homs`: If every finite subgraph of a (possibly infinite)\n  graph `G` has a homomorphism to some finite graph `F`, then there is also a homomorphism `G →g F`.\n\n## Notations\n\n`→fg` is a module-local variant on `→g` where the domain is a finite subgraph of some supergraph\n`G`.\n\n## Implementation notes\n\nThe proof here uses compactness as formulated in `nonempty_sections_of_finite_inverse_system`. For\nfinite subgraphs `G'' ≤ G'`, the inverse system `finsubgraph_hom_functor` restricts homomorphisms\n`G' →fg F` to domain `G''`.\n-/\n\nopen set\n\nuniverses u v\nvariables {V : Type u} {W : Type v} {G : simple_graph V} {F : simple_graph W}\n\nnamespace simple_graph\n\n/-- The subtype of `G.subgraph` comprising those subgraphs with finite vertex sets. -/\nabbreviation finsubgraph (G : simple_graph V) := { G' : G.subgraph // G'.verts.finite }\n\n/-- A graph homomorphism from a finite subgraph of G to F. -/\nabbreviation finsubgraph_hom (G' : G.finsubgraph) (F : simple_graph W) := G'.val.coe →g F\n\nlocal infix ` →fg ` : 50 := finsubgraph_hom\n\ninstance : order_bot G.finsubgraph :=\n{ bot := ⟨⊥, finite_empty⟩,\n  bot_le := λ _, bot_le }\n\ninstance : has_sup G.finsubgraph := ⟨λ G₁ G₂, ⟨G₁ ⊔ G₂, G₁.2.union G₂.2⟩⟩\ninstance : has_inf G.finsubgraph := ⟨λ G₁ G₂, ⟨G₁ ⊓ G₂, G₁.2.subset $ inter_subset_left _ _⟩⟩\n\ninstance : distrib_lattice G.finsubgraph :=\nsubtype.coe_injective.distrib_lattice _ (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [finite V] : has_top G.finsubgraph := ⟨⟨⊤, finite_univ⟩⟩\ninstance [finite V] : has_Sup G.finsubgraph := ⟨λ s, ⟨⨆ G ∈ s, ↑G, set.to_finite _⟩⟩\ninstance [finite V] : has_Inf G.finsubgraph := ⟨λ s, ⟨⨅ G ∈ s, ↑G, set.to_finite _⟩⟩\n\ninstance [finite V] : complete_distrib_lattice G.finsubgraph :=\nsubtype.coe_injective.complete_distrib_lattice _ (λ _ _, rfl) (λ _ _, rfl) (λ _, rfl) (λ _, rfl) rfl\n  rfl\n\n/-- The finite subgraph of G generated by a single vertex. -/\ndef singleton_finsubgraph (v : V) : G.finsubgraph := ⟨simple_graph.singleton_subgraph _ v, by simp⟩\n\n/-- The finite subgraph of G generated by a single edge. -/\ndef finsubgraph_of_adj {u v : V} (e : G.adj u v) : G.finsubgraph :=\n⟨simple_graph.subgraph_of_adj _ e, by simp⟩\n\n/- Lemmas establishing the ordering between edge- and vertex-generated subgraphs. -/\n\nlemma singleton_finsubgraph_le_adj_left {u v : V} {e : G.adj u v} :\n  singleton_finsubgraph u ≤ finsubgraph_of_adj e :=\nby simp [singleton_finsubgraph, finsubgraph_of_adj]\n\nlemma singleton_finsubgraph_le_adj_right {u v : V} {e : G.adj u v} :\n  singleton_finsubgraph v ≤ finsubgraph_of_adj e :=\nby simp [singleton_finsubgraph, finsubgraph_of_adj]\n\n/-- Given a homomorphism from a subgraph to `F`, construct its restriction to a sub-subgraph. -/\ndef finsubgraph_hom.restrict {G' G'' : G.finsubgraph} (h : G'' ≤ G') (f : G' →fg F) : G'' →fg F :=\nbegin\n  refine ⟨λ ⟨v, hv⟩, f.to_fun ⟨v, h.1 hv⟩, _⟩,\n  rintros ⟨u, hu⟩ ⟨v, hv⟩ huv,\n  exact f.map_rel' (h.2 huv),\nend\n\n/-- The inverse system of finite homomorphisms. -/\ndef finsubgraph_hom_functor (G : simple_graph V) (F : simple_graph W) :\n  (G.finsubgraph)ᵒᵖ ⥤ Type (max u v) :=\n{ obj := λ G', G'.unop →fg F,\n  map := λ G' G'' g f, f.restrict (category_theory.le_of_hom g.unop), }\n\n/-- If every finite subgraph of a graph `G` has a homomorphism to a finite graph `F`, then there is\na homomorphism from the whole of `G` to `F`. -/\nlemma nonempty_hom_of_forall_finite_subgraph_hom [finite W]\n  (h : Π (G' : G.subgraph), G'.verts.finite → G'.coe →g F) : nonempty (G →g F) :=\nbegin\n  /- Obtain a `fintype` instance for `W`. -/\n  casesI nonempty_fintype W,\n  /- Establish the required interface instances. -/\n  haveI : ∀ (G' : (G.finsubgraph)ᵒᵖ), nonempty ((finsubgraph_hom_functor G F).obj G') :=\n    λ G', ⟨h G'.unop G'.unop.property⟩,\n  haveI : Π (G' : (G.finsubgraph)ᵒᵖ), fintype ((finsubgraph_hom_functor G F).obj G') :=\n  begin\n    intro G',\n    haveI : fintype (↥(G'.unop.val.verts)) := G'.unop.property.fintype,\n    haveI : fintype (↥(G'.unop.val.verts) → W) := begin\n      classical,\n      exact pi.fintype\n    end,\n    exact fintype.of_injective (λ f, f.to_fun) rel_hom.coe_fn_injective\n  end,\n  /- Use compactness to obtain a section. -/\n  obtain ⟨u, hu⟩ := nonempty_sections_of_finite_inverse_system (finsubgraph_hom_functor G F),\n  refine ⟨⟨λ v, _, _⟩⟩,\n  { /- Map each vertex using the homomorphism provided for its singleton subgraph. -/\n    exact (u (opposite.op (singleton_finsubgraph v))).to_fun\n      ⟨v, by {unfold singleton_finsubgraph, simp}⟩, },\n  { /- Prove that the above mapping preserves adjacency. -/\n    intros v v' e,\n    /- The homomorphism for each edge's singleton subgraph agrees with those for its source and\n    target vertices. -/\n    have hv : opposite.op (finsubgraph_of_adj e) ⟶ opposite.op (singleton_finsubgraph v) :=\n      quiver.hom.op (category_theory.hom_of_le singleton_finsubgraph_le_adj_left),\n    have hv' : opposite.op (finsubgraph_of_adj e) ⟶ opposite.op (singleton_finsubgraph v') :=\n      quiver.hom.op (category_theory.hom_of_le singleton_finsubgraph_le_adj_right),\n    rw [← (hu hv), ← (hu hv')],\n    apply simple_graph.hom.map_adj,\n    /- `v` and `v'` are definitionally adjacent in `finsubgraph_of_adj e` -/\n    simp [finsubgraph_of_adj], }\nend\n\nend simple_graph\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/combinatorics/simple_graph/finsubgraph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.46118555794599075}}
{"text": "import s_discrete\n\nopen_locale classical\n\nnoncomputable def s_finset {s : ℕ} (s_ne_zero : s ≠ 0) : finset ℝ :=\nbegin\n  let numerators : finset ℕ := finset.range s,\n  let div_by_s_fn : ℕ ↪ ℝ :=\n    begin\n      let div_by_s_fn : ℕ → ℝ := λ numerator, ↑numerator / ↑s,\n      have div_by_s_fn_injective : function.injective div_by_s_fn :=\n        begin\n          intros num1 num2 num1_div_by_s_eq_num2_div_by_s,\n          dsimp[div_by_s_fn] at num1_div_by_s_eq_num2_div_by_s,\n          have s_cast_ne_zero : (s : ℝ) ≠ 0 := by exact_mod_cast s_ne_zero,\n          have mul_div_cancel_fact1 := mul_div_cancel' (num1 : ℝ) s_cast_ne_zero,\n          have mul_div_cancel_fact2 := mul_div_cancel' (num2 : ℝ) s_cast_ne_zero,\n          replace num1_div_by_s_eq_num2_div_by_s : (s : ℝ) * ((num1 : ℝ) / (s : ℝ)) = (s : ℝ) * ((num2 : ℝ) / (s : ℝ)) :=\n            by rw num1_div_by_s_eq_num2_div_by_s,\n          rw [mul_div_cancel_fact1, mul_div_cancel_fact2] at num1_div_by_s_eq_num2_div_by_s,\n          exact_mod_cast num1_div_by_s_eq_num2_div_by_s,\n        end,\n      exact {to_fun := div_by_s_fn, inj' := div_by_s_fn_injective},\n    end,\n  exact finset.map div_by_s_fn numerators,\nend\n\nlemma s_finset_card {s : ℕ} (s_ne_zero : s ≠ 0) : (s_finset s_ne_zero).card = s :=\n  by {rw s_finset, simp only [finset.card_range, finset.card_map],}\n\nlemma s_finset_range {s : ℕ} {s_ne_zero : s ≠ 0} {a : ℝ} (a_in_s_finset : a ∈ s_finset s_ne_zero) : 0 ≤ a ∧ a < 1 :=\nbegin\n  rw s_finset at a_in_s_finset,\n  simp only [exists_prop, finset.mem_map, function.embedding.coe_fn_mk, finset.mem_range] at a_in_s_finset,\n  rcases a_in_s_finset with ⟨a_num, a_num_lt_s, a_num_div_s_eq_a⟩,\n  have zero_le_s : 0 ≤ s := nat.zero_le s,\n  have cast_zero_le_s : (0 : ℝ) ≤ ↑s := by {exact_mod_cast zero_le_s},\n  have cast_zero_lt_s : (0 : ℝ) < ↑s :=\n    begin\n      cases eq_or_lt_of_le cast_zero_le_s with zero_eq_s zero_lt_s,\n      { exfalso,\n        symmetry' at zero_eq_s,\n        have s_eq_zero : s = 0 := by {exact_mod_cast zero_eq_s},\n        exact s_ne_zero s_eq_zero,\n      },\n      exact zero_lt_s,\n    end,\n  have zero_le_a : 0 ≤ a :=\n    begin\n      have zero_le_a_num : 0 ≤ a_num := nat.zero_le a_num,\n      have cast_zero_le_a_num : (0 : ℝ) ≤ ↑a_num := by {exact_mod_cast zero_le_a_num},\n      rw ← a_num_div_s_eq_a,\n      exact div_nonneg cast_zero_le_a_num cast_zero_le_s,\n    end,\n  have a_lt_one : a < 1 :=\n    by {rw [← a_num_div_s_eq_a, div_lt_one cast_zero_lt_s], exact_mod_cast a_num_lt_s},\n  exact ⟨zero_le_a, a_lt_one⟩,\nend\n\nlemma s_finset_distinct_mod_one {s : ℕ} {s_ne_zero : s ≠ 0} {a : ℝ} {b : ℝ} (a_ne_b : a ≠ b) (a_in_s_finset : a ∈ s_finset s_ne_zero)\n  (b_in_s_finset : b ∈ s_finset s_ne_zero) : ne_mod_one a b :=\nbegin\n  rcases s_finset_range a_in_s_finset with ⟨zero_le_a, a_lt_one⟩,\n  rcases s_finset_range b_in_s_finset with ⟨zero_le_b, b_lt_one⟩,\n  rintro ⟨a_floor, b_floor, y, zero_le_y, y_lt_one, a_eq_a_floor_add_y, b_eq_b_floor_add_y⟩,\n  rcases eq_or_lt_or_gt a_floor b_floor with a_floor_eq_b_floor | a_floor_lt_b_floor | a_floor_gt_b_floor,\n  { rw [a_floor_eq_b_floor, ← b_eq_b_floor_add_y] at a_eq_a_floor_add_y,\n    exact a_ne_b a_eq_a_floor_add_y,\n  },\n  { have a_floor_add_one_le_b_floor := int.add_one_le_of_lt a_floor_lt_b_floor,\n    have cast_a_floor_add_one_le_b_floor : (↑a_floor : ℝ) + 1 ≤ ↑b_floor := by {exact_mod_cast a_floor_add_one_le_b_floor},\n    rw a_eq_a_floor_add_y at zero_le_a a_lt_one,\n    rw b_eq_b_floor_add_y at zero_le_b b_lt_one,\n    clear_except cast_a_floor_add_one_le_b_floor zero_le_a a_lt_one zero_le_b b_lt_one,\n    linarith,\n  },\n  rw gt at a_floor_gt_b_floor,\n  have b_floor_add_one_le_a_floor := int.add_one_le_of_lt a_floor_gt_b_floor,\n  have cast_a_floor_add_one_le_b_floor : (↑b_floor : ℝ) + 1 ≤ ↑a_floor := by {exact_mod_cast b_floor_add_one_le_a_floor},\n  rw a_eq_a_floor_add_y at zero_le_a a_lt_one,\n  rw b_eq_b_floor_add_y at zero_le_b b_lt_one,\n  clear_except cast_a_floor_add_one_le_b_floor zero_le_a a_lt_one zero_le_b b_lt_one,\n  linarith,\nend\n\nlemma inductive_replacement_lemma_helper2 {d : ℕ} {s : ℕ} (s_ne_zero : s ≠ 0) (i : fin d) (T : set (point d)) \n  (T_is_tiling : is_tiling T) (T_faceshare_free : tiling_faceshare_free T) (T_is_periodic : is_periodic T_is_tiling)\n  (coords_before_i_handled : ∀ p : point d, p ∈ T → ∀ j : fin d, j.val < i.val → \n    ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val) : \n  ∀ coords_left : ℕ, ∀ coords : finset ℝ, ∀ goal_finset : finset ℝ, goal_finset ⊆ s_finset s_ne_zero →\n  (∀ coord ∈ coords, ∀ s_val ∈ s_finset s_ne_zero, ne_mod_one coord s_val) →\n  (∀ p ∈ T, ∀ goal_val ∈ goal_finset, ne_mod_one (vector.nth p i) goal_val) →\n  coords_left = coords.card → coords.card ≤ goal_finset.card →\n  ∃ T_shifted : set (point d), ∃ T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted ∧ is_periodic T_shifted_is_tiling ∧\n  (∀ p : point d, p ∈ T_shifted → ∀ j : fin d, j.val < i.val → ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val) ∧\n  (∀ p : point d, p ∈ T_shifted → (∀ coord ∈ coords, ne_mod_one (vector.nth p i) coord) \n    ∧ ((∃ goal_val ∈ goal_finset, eq_mod_one (vector.nth p i) goal_val) ∨ p ∈ T)) ∧\n  (∀ p : point d, p ∈ T_shifted → ∀ j : fin d, j.val > i.val → ∃ p' ∈ T, vector.nth p j = vector.nth p' j) :=\nbegin\n  intro coords_left,\n  induction coords_left with coords_left_pred ih,\n  { intros coords goal_finset goal_finset_subset_s_finset coords_inter_s_finset_empty T_disjoint_goal_finset coords_empty \n      coords_card_le_goal_finset_card,\n    use [T, T_is_tiling, T_faceshare_free, T_is_periodic],\n    split, exact coords_before_i_handled, --T_shifted_property_before_i\n    split,\n    { intros p p_in_T,--Prove T_shifted_property_at_i\n      split,\n      { intros coord coord_in_coords,\n        exfalso, --Derive contradiction between coord_in_coords and coords_empty\n        symmetry' at coords_empty,\n        rw finset.card_eq_zero at coords_empty,\n        rw coords_empty at coord_in_coords,\n        exact finset.not_mem_empty coord coord_in_coords,\n      },\n      right, exact p_in_T,\n    },\n    intros p p_in_T j j_val_gt_i_val, --Prove T_shifted_property_after_i\n    use [p, p_in_T],\n  },\n  intros coords goal_finset goal_finset_subset_s_finset coords_disjoint_s_fisnet T_disjoint_goal_finset coords_left_def \n    coords_card_le_goal_finset_card,\n  let coords_list : list ℝ := finset.sort has_le.le coords,\n  let goal_list : list ℝ := finset.sort has_le.le goal_finset,\n  have coords_list_def : coords_list = finset.sort has_le.le coords := by refl,\n  have goal_list_def : goal_list = finset.sort has_le.le goal_finset := by refl,\n  cases finset.sort has_le.le coords with last_coord rest_coords,\n  { exfalso, --coords_left_def says coords.card > 0, so it is impossible that coords_list = list.nil\n    have coords_list_length_eq_coords_card : coords_list.length = coords.card := finset.length_sort real.has_le.le,\n    rw [← coords_list_length_eq_coords_card, coords_list_def, list.length] at coords_left_def,\n    exact nat.succ_ne_zero coords_left_pred coords_left_def,\n  },\n  cases finset.sort has_le.le goal_finset with last_goal rest_goal_list,\n  { exfalso, --coords.card ≤ goal_finset.card and coords.card > 0, so it is impossible that goal_list = list.nil\n    have goal_finset_card_eq_goal_list_length : goal_list.length = goal_finset.card := finset.length_sort real.has_le.le,\n    rw [← goal_finset_card_eq_goal_list_length, goal_list_def, list.length, ← coords_left_def] at coords_card_le_goal_finset_card,\n    exact nat.not_succ_le_zero coords_left_pred coords_card_le_goal_finset_card,\n  },\n  have last_goal_in_goal_finset : last_goal ∈ goal_finset :=\n    begin\n      rw ← finset.mem_sort real.has_le.le,\n      change last_goal ∈ goal_list,\n      rw goal_list_def,\n      simp only [list.mem_cons_iff, true_or, eq_self_iff_true],\n    end,\n  have last_goal_in_s_finset := finset.mem_of_subset goal_finset_subset_s_finset last_goal_in_goal_finset,\n  let rest_coords_finset : finset ℝ := rest_coords.to_finset,\n  let rest_goal_finset : finset ℝ := rest_goal_list.to_finset,\n  have rest_goal_finset_subset_goal_finset : rest_goal_finset ⊆ goal_finset := \n    begin\n      dsimp[rest_goal_finset],\n      rw finset.subset_iff,\n      intros rest_goal_val rest_goal_val_in_rest_goal_finset,\n      rw list.mem_to_finset at rest_goal_val_in_rest_goal_finset,\n      rw ← finset.mem_sort real.has_le.le,\n      change rest_goal_val ∈ goal_list,\n      rw [goal_list_def, list.mem_cons_iff],\n      right,\n      exact rest_goal_val_in_rest_goal_finset,\n    end,\n  have rest_goal_finset_subset_s_finset : rest_goal_finset ⊆ s_finset s_ne_zero :=\n    finset.subset.trans rest_goal_finset_subset_goal_finset goal_finset_subset_s_finset,\n  have rest_coords_finset_subset_coords : rest_coords_finset ⊆ coords :=\n    begin\n      dsimp[rest_coords_finset],\n      rw finset.subset_iff,\n      intros coord coord_in_rest_coords,\n      rw list.mem_to_finset at coord_in_rest_coords,\n      rw ← finset.mem_sort real.has_le.le,\n      change coord ∈ coords_list,\n      rw [coords_list_def, list.mem_cons_iff],\n      right,\n      exact coord_in_rest_coords,\n    end,\n  have rest_coords_finset_disjoint_s_finset : \n    ∀ (coord : ℝ), coord ∈ rest_coords_finset → ∀ (s_val : ℝ), s_val ∈ s_finset s_ne_zero → ne_mod_one coord s_val := \n    begin\n      intros coord coord_in_rest_coords_finset s_val s_val_in_s_finset,\n      have coord_in_coords := finset.mem_of_subset rest_coords_finset_subset_coords coord_in_rest_coords_finset,\n      exact coords_disjoint_s_fisnet coord coord_in_coords s_val s_val_in_s_finset,\n    end,\n  have rest_coords_nodup : rest_coords.nodup :=\n    begin\n      rw list.nodup,\n      have coords_list_nodup : coords_list.nodup := finset.sort_nodup real.has_le.le coords,\n      rw [list.nodup, coords_list_def, list.pairwise_cons] at coords_list_nodup,\n      exact coords_list_nodup.2,\n    end,\n  have rest_coords_card : coords_left_pred = rest_coords_finset.card := \n    begin\n      dsimp[rest_coords_finset],\n      have coords_list_length : coords_list.length = rest_coords.length + 1 :=\n        by {rw coords_list_def, exact list.length_cons last_coord rest_coords},\n      have coords_list_length_eq_coords_card : coords_list.length = coords.card :=\n        by {dsimp[coords_list], apply finset.length_sort},\n      rw ← coords_left_def at coords_list_length_eq_coords_card,\n      rw list.to_finset_card_of_nodup rest_coords_nodup,\n      clear_except coords_list_length coords_list_length_eq_coords_card,\n      omega,\n    end,\n  have T_disjoint_rest_goal_finset : \n    ∀ (p : vector ℝ d), p ∈ T → ∀ (goal_val : ℝ), goal_val ∈ rest_goal_finset → ne_mod_one (p.nth i) goal_val :=\n    begin\n      intros p p_in_T goal_val goal_val_in_rest_goal_finset,\n      have goal_val_in_goal_finset := finset.mem_of_subset rest_goal_finset_subset_goal_finset goal_val_in_rest_goal_finset,\n      exact T_disjoint_goal_finset p p_in_T goal_val goal_val_in_goal_finset,\n    end,\n  have rest_coords_card_le_rest_goal_finset_card : rest_coords_finset.card ≤ rest_goal_finset.card := \n    begin\n      rw ← rest_coords_card,\n      rw [← coords_left_def, nat.succ_eq_add_one] at coords_card_le_goal_finset_card,\n      have coords_left_pred_le_goal_finset_card_sub_one : coords_left_pred ≤ goal_finset.card - 1 :=\n        by {clear_except coords_card_le_goal_finset_card, omega},\n      have goal_finset_card : goal_finset.card = rest_goal_finset.card + 1 :=\n        begin\n          rw ← finset.length_sort real.has_le.le,\n          change goal_list.length = rest_goal_finset.card + 1,\n          dsimp[rest_goal_finset],\n          have rest_goal_list_nodup : rest_goal_list.nodup := \n            begin\n              have goal_list_nodup : goal_list.nodup := finset.sort_nodup has_le.le goal_finset,\n              rw [goal_list_def, list.nodup, list.pairwise_cons, ← list.nodup] at goal_list_nodup,\n              exact goal_list_nodup.2,\n            end,\n          rw [goal_list_def, list.length_cons, list.to_finset_card_of_nodup rest_goal_list_nodup],\n        end,\n      rw goal_finset_card at coords_left_pred_le_goal_finset_card_sub_one,\n      simp only [nat.add_succ_sub_one, add_zero] at coords_left_pred_le_goal_finset_card_sub_one,\n      exact coords_left_pred_le_goal_finset_card_sub_one,\n    end,\n  rcases ih rest_coords_finset rest_goal_finset rest_goal_finset_subset_s_finset rest_coords_finset_disjoint_s_finset\n    T_disjoint_rest_goal_finset rest_coords_card rest_coords_card_le_rest_goal_finset_card with\n    ⟨T_shifted_prev, T_shifted_prev_is_tiling, T_shifted_prev_faceshare_free, T_shifted_prev_is_periodic, T_shifted_prev_property_before_i,\n      T_shifted_prev_property_at_i, T_shifted_prev_property_after_i⟩,\n  let T_shifted := shift_tiling T_shifted_prev i last_coord (last_goal - last_coord),\n  rcases replacement_lemma d T_shifted_prev T_shifted_prev_is_tiling last_coord (last_goal - last_coord) i with\n    ⟨T_shifted_is_tiling, T_shifted_prev_faceshare_free_implication⟩,\n  use [T_shifted, T_shifted_is_tiling],\n  have last_goal_not_in_T_shifted_prev : \n    (∀ (t : point d), t ∈ T_shifted_prev → ne_mod_one (vector.nth t i) (last_coord + (last_goal - last_coord))) :=\n    begin\n      intros t t_in_T_shifted_prev,\n      simp only [add_sub_cancel'_right],\n      rcases T_shifted_prev_property_at_i t t_in_T_shifted_prev with\n        ⟨t_ne_mod_one_rest_coords, ⟨goal_val, goal_val_in_rest_goal_finset, t_eq_goal_val_mod_one⟩ | t_in_T⟩,\n      { have goal_val_ne_last_goal : goal_val ≠ last_goal :=\n          begin\n            have goal_list_nodup : goal_list.nodup := finset.sort_nodup real.has_le.le goal_finset,\n            rw [list.nodup, goal_list_def, list.pairwise_cons] at goal_list_nodup,\n            rcases goal_list_nodup with ⟨last_goal_not_in_rest_goal_list, rest_goal_list_nodup⟩,\n            dsimp[rest_goal_finset] at goal_val_in_rest_goal_finset,\n            rw list.mem_to_finset at goal_val_in_rest_goal_finset,\n            symmetry,\n            exact last_goal_not_in_rest_goal_list goal_val goal_val_in_rest_goal_finset,\n          end,\n        have goal_val_in_s_finset : goal_val ∈ s_finset s_ne_zero := \n          finset.mem_of_subset rest_goal_finset_subset_s_finset goal_val_in_rest_goal_finset,\n        have goal_val_ne_last_goal_mod_one := s_finset_distinct_mod_one goal_val_ne_last_goal goal_val_in_s_finset last_goal_in_s_finset,\n        intro t_eq_last_goal_mod_one,\n        replace t_eq_goal_val_mod_one := eq_mod_one_symmetric t_eq_goal_val_mod_one,\n        exact goal_val_ne_last_goal_mod_one (eq_mod_one_transitive t_eq_goal_val_mod_one t_eq_last_goal_mod_one),\n      },\n      exact T_disjoint_goal_finset t t_in_T last_goal last_goal_in_goal_finset,\n    end,\n  have T_shifted_faceshare_free := T_shifted_prev_faceshare_free_implication T_shifted_prev_faceshare_free last_goal_not_in_T_shifted_prev,\n  split, exact T_shifted_faceshare_free,\n  split, \n  exact shifted_periodic_tiling_still_periodic T_shifted_prev_is_tiling T_shifted_prev_is_periodic i last_coord (last_goal - last_coord) T_shifted_is_tiling,\n  split,\n  { intros p p_in_T_shifted j j_val_lt_i_val, --Prove T_shifted_property_before_i\n    dsimp[T_shifted] at p_in_T_shifted,\n    rw shift_tiling at p_in_T_shifted,\n    simp only [exists_prop, set.mem_union_eq, set.mem_set_of_eq] at p_in_T_shifted,\n    rcases p_in_T_shifted with \n      ⟨p_in_T_shifted_prev, p_ne_last_coord_mod_one⟩ | ⟨p_prev, p_prev_in_T_shifted_prev, p_def, p_prev_eq_last_coord_mod_one⟩,\n    exact T_shifted_prev_property_before_i p p_in_T_shifted_prev j j_val_lt_i_val,\n    rw [scaled_basis_vector, add_vectors] at p_def,\n    simp only [vector.nth_of_fn] at p_def,\n    rw p_def,\n    simp only [vector.nth_of_fn],\n    have i_ne_j : i ≠ j :=\n      by {intro i_eq_j, rw i_eq_j at j_val_lt_i_val, exact lt_irrefl j.val j_val_lt_i_val},\n    rw [if_neg i_ne_j, add_zero],\n    exact T_shifted_prev_property_before_i p_prev p_prev_in_T_shifted_prev j j_val_lt_i_val,\n  },\n  split,\n  { intros p p_in_T_shifted, --Prove T_shifted_property_at_i\n    dsimp[T_shifted] at p_in_T_shifted,\n    rw shift_tiling at p_in_T_shifted,\n    simp only [exists_prop, set.mem_union_eq, set.mem_set_of_eq] at p_in_T_shifted,\n    rcases p_in_T_shifted with \n      ⟨p_in_T_shifted_prev, p_ne_last_coord_mod_one⟩ | ⟨p_prev, p_prev_in_T_shifted_prev, p_def, p_prev_eq_last_coord_mod_one⟩,\n    { rcases T_shifted_prev_property_at_i p p_in_T_shifted_prev with ⟨p_ne_rest_coords_mod_one, T_shifted_second_property_at_i⟩,\n      split,\n      { intros coord coord_in_coords,\n        by_cases coord_in_rest_coords_finset : coord ∈ rest_coords_finset,\n        exact p_ne_rest_coords_mod_one coord coord_in_rest_coords_finset,\n        rename coord_in_rest_coords_finset coord_not_in_rest_coords_finset,\n        have coord_in_coords_list : coord ∈ coords_list := by {rw finset.mem_sort, exact coord_in_coords},\n        rw [coords_list_def, list.mem_cons_eq] at coord_in_coords_list,\n        cases coord_in_coords_list with coord_eq_last_coord coord_in_rest_coords,\n        { rw coord_eq_last_coord,\n          exact p_ne_last_coord_mod_one,\n        },\n        have coord_in_rest_coords_finset : coord ∈ rest_coords_finset := by {rw list.mem_to_finset, exact coord_in_rest_coords},\n        exact p_ne_rest_coords_mod_one coord coord_in_rest_coords_finset,\n      },\n      rcases T_shifted_second_property_at_i with\n        ⟨goal_val, goal_val_in_rest_goal_finset, p_eq_goal_val_mod_one⟩ | p_in_T,\n      { left,\n        have goal_val_in_goal_finset := finset.mem_of_subset rest_goal_finset_subset_goal_finset goal_val_in_rest_goal_finset,\n        use [goal_val, goal_val_in_goal_finset, p_eq_goal_val_mod_one],\n      },\n      right,\n      exact p_in_T,\n    },\n    split,\n    { intros coord coord_in_coords p_eq_coord_mod_one,\n      rw [p_def, scaled_basis_vector, add_vectors] at p_eq_coord_mod_one,\n      simp only [if_true, eq_self_iff_true, vector.nth_of_fn] at p_eq_coord_mod_one,\n      replace p_eq_coord_mod_one := subst_summand_eq_mod_one p_prev_eq_last_coord_mod_one p_eq_coord_mod_one,\n      simp only [add_sub_cancel'_right] at p_eq_coord_mod_one,\n      exact coords_disjoint_s_fisnet coord coord_in_coords last_goal last_goal_in_s_finset (eq_mod_one_symmetric p_eq_coord_mod_one),\n    },\n    left,\n    use [last_goal, last_goal_in_goal_finset],\n    rw [p_def, scaled_basis_vector, add_vectors],\n    simp only [if_true, eq_self_iff_true, vector.nth_of_fn],\n    apply subst_summand_eq_mod_one (eq_mod_one_symmetric p_prev_eq_last_coord_mod_one),\n    simp only [add_sub_cancel'_right],\n    exact eq_mod_one_reflexive last_goal,\n  },\n  intros p p_in_T_shifted j j_val_gt_i_val, --Prove T_shifted_property_after_i\n  dsimp[T_shifted] at p_in_T_shifted,\n  rw shift_tiling at p_in_T_shifted,\n  simp only [exists_prop, set.mem_union_eq, set.mem_set_of_eq] at p_in_T_shifted,\n  rcases p_in_T_shifted with \n    ⟨p_in_T_shifted_prev, p_ne_last_coord_mod_one⟩ | ⟨p_prev, p_prev_in_T_shifted_prev, p_def, p_prev_eq_last_coord_mod_one⟩,\n  exact T_shifted_prev_property_after_i p p_in_T_shifted_prev j j_val_gt_i_val,\n  rw [scaled_basis_vector, add_vectors] at p_def,\n  simp only [vector.nth_of_fn] at p_def,\n  rw p_def,\n  simp only [vector.nth_of_fn],\n  have i_ne_j : i ≠ j :=\n    by {intro i_eq_j, rw i_eq_j at j_val_gt_i_val, exact gt_irrefl j.val j_val_gt_i_val},\n  rw [if_neg i_ne_j, add_zero],\n  exact T_shifted_prev_property_after_i p_prev p_prev_in_T_shifted_prev j j_val_gt_i_val,\nend\n\nlemma inductive_replacement_lemma_helper1 {d : ℕ} {s : ℕ} (d_ne_zero : d ≠ 0) (s_ne_zero : s ≠ 0) (i : fin d) (T : set (point d)) \n  (T_is_tiling : is_tiling T) (T_faceshare_free : tiling_faceshare_free T) (T_is_periodic : is_periodic T_is_tiling) (T_is_s_discrete : is_s_discrete s T) \n  (coords_before_i_handled : ∀ p : point d, p ∈ T → ∀ j : fin d, j.val < i.val → \n    ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val) :\n  ∃ T_shifted : set (point d), ∃ T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted ∧ \n  is_periodic T_shifted_is_tiling ∧ is_s_discrete s T_shifted ∧\n  ∀ p : point d, p ∈ T_shifted → ∀ j : fin d, j.val ≤ i.val → ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val :=\nbegin\n  rcases T_is_s_discrete i with ⟨coords, coords_card_le_s, ⟨coords_distinct_mod_one, T_is_s_discrete'⟩⟩,\n  let goal_finset := {s_val ∈ s_finset s_ne_zero | ∀ coord ∈ coords, ne_mod_one coord s_val},\n  let coords_inter_s_finset := {coord ∈ coords | ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one coord s_val},\n  have coords_inter_goal_subset_of_coords : coords_inter_s_finset ⊆ coords :=\n    by {dsimp[coords_inter_s_finset], simp only [finset.filter_subset]},\n  have goal_finset_subset_s_finset : goal_finset ⊆ s_finset s_ne_zero :=\n    by {dsimp[goal_finset], apply finset.filter_subset},\n  have coords_to_handle_disjoint_s_finset : \n    ∀ (coord : ℝ), coord ∈ coords \\ coords_inter_s_finset → ∀ (s_val : ℝ), s_val ∈ s_finset s_ne_zero → ne_mod_one coord s_val :=\n    begin\n      intros coord coord_in_coords_remaining s_val s_val_in_s_finset,\n      dsimp[coords_inter_s_finset, goal_finset] at coord_in_coords_remaining,\n      simp only [not_exists, and_imp, not_and, finset.mem_sdiff, finset.mem_filter] at coord_in_coords_remaining,\n      cases coord_in_coords_remaining with coord_in_coords coord_in_coords_imp,\n      exact coord_in_coords_imp coord_in_coords s_val s_val_in_s_finset,\n    end,\n  have T_disjoint_goal_finset :\n    ∀ (p : vector ℝ d), p ∈ T → ∀ (goal_val : ℝ), goal_val ∈ goal_finset → ne_mod_one (p.nth i) goal_val :=\n    begin\n      intros p p_in_T goal_val goal_val_in_goal_finset p_eq_goal_val_mod_one,\n      dsimp[goal_finset] at goal_val_in_goal_finset,\n      simp only [finset.mem_filter] at goal_val_in_goal_finset,\n      cases goal_val_in_goal_finset with goal_val_in_s_finset goal_val_not_in_T,\n      rcases T_is_s_discrete' p p_in_T with ⟨coord, coord_in_coords, p_eq_coord_mod_one⟩,\n      replace p_eq_coord_mod_one := eq_mod_one_symmetric p_eq_coord_mod_one,\n      have coord_eq_goal_val_mod_one := eq_mod_one_transitive p_eq_coord_mod_one p_eq_goal_val_mod_one,\n      exact goal_val_not_in_T coord coord_in_coords coord_eq_goal_val_mod_one,\n    end,\n  have coords_to_handle_card_le_goal_finset_card : (coords \\ coords_inter_s_finset).card ≤ goal_finset.card := \n    begin\n      rw finset.card_sdiff,\n      { simp only [tsub_le_iff_right],\n        have goal_finset_card_add_coord_inter_s_card_eq_s_card : goal_finset.card + coords_inter_s_finset.card = (s_finset s_ne_zero).card :=\n          begin\n            let s_finset_filter_fn := (λ s_val : ℝ, ∀ (coord : ℝ), coord ∈ coords → ne_mod_one coord s_val),\n            have s_finset_filter_fn_decidable : decidable_pred s_finset_filter_fn := \n              (λ s_val, classical.prop_decidable (s_finset_filter_fn s_val)),\n            let s_finset_filter_fn_neg := (λ s_val : ℝ, ∃ coord ∈ coords, eq_mod_one coord s_val),\n            have not_s_finset_filter_fn_neg_eq_f_finset_filter_fn_neg : not ∘ s_finset_filter_fn = s_finset_filter_fn_neg :=\n              begin\n                apply funext,\n                intro s_val,\n                dsimp[s_finset_filter_fn, s_finset_filter_fn_neg],\n                simp only [exists_prop, eq_iff_iff, not_forall],\n                split,\n                { rintro ⟨coord, coord_in_coords, coord_eq_s_val_mod_one⟩,\n                  use [coord, coord_in_coords],\n                  rw [ne_mod_one, not_not] at coord_eq_s_val_mod_one,\n                  exact coord_eq_s_val_mod_one,\n                },\n                rintro ⟨coord, coord_in_coords, coord_eq_s_val_mod_one⟩,\n                use [coord, coord_in_coords],\n              end,\n            \n            rw ← @finset.filter_card_add_filter_neg_card_eq_card ℝ (s_finset s_ne_zero) s_finset_filter_fn s_finset_filter_fn_decidable,\n            have goal_finset_eq_s_finset_filtered : \n              goal_finset = @finset.filter ℝ s_finset_filter_fn s_finset_filter_fn_decidable (s_finset s_ne_zero) :=\n              begin\n                dsimp[goal_finset, s_finset_filter_fn],\n                apply finset.filter_congr_decidable,\n              end,\n            rw goal_finset_eq_s_finset_filtered,\n            simp only [add_right_inj],\n            let f : ℝ → ℝ := \n              (λ coord : ℝ,\n                begin\n                  by_cases h : ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one coord s_val,\n                  exact classical.some h,\n                  exact (-1 : ℝ),\n                end\n              ),\n            convert_to coords_inter_s_finset.card = (finset.image f coords_inter_s_finset).card,\n            { have finset_card_eq_self_card : ∀ s : finset ℝ, ∀ s' : finset ℝ, s = s' → s.card = s'.card :=\n                by {intros s s' s_eq_s', rw s_eq_s'},\n              apply finset_card_eq_self_card,\n              apply finset.ext,\n              intro s_val,\n              split,\n              { intro s_val_in_filtered_set,\n                conv at s_val_in_filtered_set\n                begin\n                  find (not ∘ s_finset_filter_fn) {rw not_s_finset_filter_fn_neg_eq_f_finset_filter_fn_neg}\n                end,\n                dsimp[s_finset_filter_fn_neg] at s_val_in_filtered_set,\n                simp only [exists_prop, finset.mem_filter] at s_val_in_filtered_set,\n                rcases s_val_in_filtered_set with ⟨s_val_in_s_finset, ⟨coord, coord_in_coords, coord_eq_s_val_mod_one⟩⟩,\n                rw finset.mem_image,\n                use coord,\n                split,\n                { dsimp[coords_inter_s_finset],\n                  simp only [exists_prop, finset.mem_filter],\n                  use [coord_in_coords, s_val, s_val_in_s_finset, coord_eq_s_val_mod_one],\n                },\n                dsimp[f],\n                have if_cond_true : ∃ (s_val : ℝ) (H : s_val ∈ s_finset s_ne_zero), eq_mod_one coord s_val := \n                  ⟨s_val, s_val_in_s_finset, coord_eq_s_val_mod_one⟩,\n                convert_to classical.some if_cond_true = s_val, apply dif_pos,\n                rcases classical.some_spec if_cond_true with ⟨classical_some_in_s_finset, coord_eq_classical_some_mod_one⟩,\n                by_contra classical_some_ne_s_val,\n                have classical_some_eq_s_val_mod_one : eq_mod_one (classical.some if_cond_true) s_val :=\n                  eq_mod_one_transitive (eq_mod_one_symmetric coord_eq_classical_some_mod_one) coord_eq_s_val_mod_one,\n                exact s_finset_distinct_mod_one classical_some_ne_s_val classical_some_in_s_finset s_val_in_s_finset\n                  classical_some_eq_s_val_mod_one,\n              },\n              intro s_val_in_image,\n              conv\n              begin\n                find (not ∘ s_finset_filter_fn) {rw not_s_finset_filter_fn_neg_eq_f_finset_filter_fn_neg}\n              end,\n              dsimp[s_finset_filter_fn_neg],\n              simp only [exists_prop, finset.mem_filter],\n              dsimp[f] at s_val_in_image,\n              rw finset.mem_image at s_val_in_image,\n              simp only [exists_prop] at s_val_in_image,\n              rcases s_val_in_image with ⟨coord, coord_in_coords_inter_s_finset, classical_some_eq_s_val⟩,\n              by_cases if_cond : ∃ (s_val : ℝ), s_val ∈ s_finset s_ne_zero ∧ eq_mod_one coord s_val,\n              { rename if_cond if_cond_true,\n                rw dif_pos if_cond_true at classical_some_eq_s_val,\n                rcases classical.some_spec if_cond_true with ⟨classical_some_in_s_finset, coord_eq_classical_some_mod_one⟩,\n                rw ← classical_some_eq_s_val,\n                have coord_in_coords : coord ∈ coords := \n                  begin\n                    dsimp[coords_inter_s_finset] at coord_in_coords_inter_s_finset,\n                    rw finset.mem_filter at coord_in_coords_inter_s_finset,\n                    cases coord_in_coords_inter_s_finset with coord_in_coords _,\n                    exact coord_in_coords,\n                  end,\n                exact ⟨classical_some_in_s_finset, ⟨coord, coord_in_coords, coord_eq_classical_some_mod_one⟩⟩,\n              },\n              rename if_cond if_cond_false,\n              exfalso, --Derive contradiction from if_cond_false\n              dsimp[coords_inter_s_finset] at coord_in_coords_inter_s_finset,\n              rw finset.mem_filter at coord_in_coords_inter_s_finset,\n              cases coord_in_coords_inter_s_finset with _ if_cond_true,\n              have if_cond_true' : ∃ s_val : ℝ, s_val ∈ s_finset s_ne_zero ∧ eq_mod_one coord s_val :=\n                begin\n                  rcases if_cond_true with ⟨s_val, s_val_in_s_finset, coord_eq_s_val_mod_one⟩,\n                  use s_val,\n                  exact ⟨s_val_in_s_finset, coord_eq_s_val_mod_one⟩,\n                end,\n              exact if_cond_false if_cond_true',\n            },\n            symmetry,\n            rw finset.card_image_eq_iff_inj_on,\n            rw set.inj_on,\n            intros coord1 coord1_in_coords_inter_s_finset coord2 coord2_in_coords_inter_s_finset f_coord1_eq_f_coord2,\n            rw finset.mem_coe at coord1_in_coords_inter_s_finset coord2_in_coords_inter_s_finset,\n            dsimp[coords_inter_s_finset] at coord1_in_coords_inter_s_finset coord2_in_coords_inter_s_finset,\n            simp only [exists_prop, finset.mem_filter] at coord1_in_coords_inter_s_finset coord2_in_coords_inter_s_finset,\n            rcases coord1_in_coords_inter_s_finset with\n              ⟨coord1_in_coords, ⟨coord1_s_val, coord1_s_val_in_s_finset, coord1_eq_coord1_s_val_mod_one⟩⟩,\n            rcases coord2_in_coords_inter_s_finset with\n              ⟨coord2_in_coords, ⟨coord2_s_val, coord2_s_val_in_s_finset, coord2_eq_coord2_s_val_mod_one⟩⟩,\n            dsimp[f] at f_coord1_eq_f_coord2,\n            have exists_s_val_eq_coord1_mod_one : ∃ (s_val : ℝ) (H : s_val ∈ s_finset s_ne_zero), eq_mod_one coord1 s_val :=\n              ⟨coord1_s_val, coord1_s_val_in_s_finset, coord1_eq_coord1_s_val_mod_one⟩,\n            have exists_s_val_eq_coord2_mod_one : ∃ (s_val : ℝ) (H : s_val ∈ s_finset s_ne_zero), eq_mod_one coord2 s_val :=\n              ⟨coord2_s_val, coord2_s_val_in_s_finset, coord2_eq_coord2_s_val_mod_one⟩,\n            rw [dif_pos exists_s_val_eq_coord1_mod_one, dif_pos exists_s_val_eq_coord2_mod_one] at f_coord1_eq_f_coord2,\n            rcases classical.some_spec exists_s_val_eq_coord1_mod_one with\n              ⟨classical_some1_in_s_finset, coord1_eq_classical_some1_mod_one⟩,\n            rcases classical.some_spec exists_s_val_eq_coord2_mod_one with\n              ⟨classical_some2_in_s_finset, coord2_eq_classical_some2_mod_one⟩, \n            rw f_coord1_eq_f_coord2 at coord1_eq_classical_some1_mod_one,\n            have coord1_eq_coord2_mod_one : eq_mod_one coord1 coord2 :=\n              eq_mod_one_transitive coord1_eq_classical_some1_mod_one (eq_mod_one_symmetric coord2_eq_classical_some2_mod_one),\n            by_contra coord1_ne_coord2,\n            exact coords_distinct_mod_one coord1 coord1_in_coords coord2 coord2_in_coords coord1_ne_coord2 coord1_eq_coord2_mod_one,\n          end,\n        rw [goal_finset_card_add_coord_inter_s_card_eq_s_card, s_finset_card s_ne_zero],\n        exact coords_card_le_s,\n      },\n      apply finset.filter_subset,\n    end,\n  rcases inductive_replacement_lemma_helper2 s_ne_zero i T T_is_tiling T_faceshare_free T_is_periodic coords_before_i_handled \n    (coords \\ coords_inter_s_finset).card (coords \\ coords_inter_s_finset) goal_finset goal_finset_subset_s_finset\n    coords_to_handle_disjoint_s_finset T_disjoint_goal_finset (by refl) coords_to_handle_card_le_goal_finset_card with\n    ⟨T_shifted, T_shifted_is_tiling, T_shifted_faceshare_free, T_shifted_is_periodic, T_shifted_property_before_i, T_shifted_property_at_i, \n      T_shifted_property_after_i⟩,\n  use [T_shifted, T_shifted_is_tiling],\n  split, exact T_shifted_faceshare_free,\n  split, exact T_shifted_is_periodic,\n  split,\n  { rw is_s_discrete,\n    intro j,\n    have j_eq_or_lt_or_gt_i := nat_eq_or_lt_or_gt j.val i.val,\n    rcases j_eq_or_lt_or_gt_i with j_val_eq_i_val | j_val_lt_i_val | j_val_gt_i_val,\n    { use s_finset s_ne_zero,\n      split,\n      { apply le_of_eq,\n        exact s_finset_card s_ne_zero,\n      },\n      split,\n      { intros coord1 coord1_in_s_finset coord2 coord2_in_s_finset coord1_ne_coord2,\n        exact s_finset_distinct_mod_one coord1_ne_coord2 coord1_in_s_finset coord2_in_s_finset,\n      },\n      intros t t_in_T_shifted,\n      have j_eq_i := fin.eq_of_veq j_val_eq_i_val,\n      rw j_eq_i,\n      cases T_shifted_property_at_i t t_in_T_shifted with coords_not_in_T_shifted T_shifted_has_goal,\n      by_contra goal_false,\n      cases T_shifted_has_goal with goal t_in_T,\n      { simp only [not_exists, exists_prop, not_and] at goal_false,\n        rcases goal with ⟨goal_val, goal_val_in_goal_finset, t_eq_goal_val_mod_one⟩,\n        have goal_val_in_s_finset := finset.mem_of_subset goal_finset_subset_s_finset goal_val_in_goal_finset,\n        exact goal_false goal_val goal_val_in_s_finset t_eq_goal_val_mod_one,\n      },\n      rcases T_is_s_discrete' t t_in_T with ⟨coord, coord_in_coords, t_eq_mod_one_coord⟩,\n      have coord_in_coords_to_handle : coord ∈ coords \\ coords_inter_s_finset :=\n        begin\n          dsimp[coords_inter_s_finset],\n          simp only [not_exists, exists_prop, not_and, finset.mem_sdiff, finset.mem_filter],\n          split, exact coord_in_coords,\n          intros coord_in_coords goal_val goal_val_in_goal_finset coord_eq_goal_val_mod_one,\n          have t_eq_goal_val_mod_one := eq_mod_one_transitive t_eq_mod_one_coord coord_eq_goal_val_mod_one,\n          simp only [not_exists, exists_prop, not_and] at goal_false,\n          exact goal_false goal_val goal_val_in_goal_finset t_eq_goal_val_mod_one,\n        end,\n      exact coords_not_in_T_shifted coord coord_in_coords_to_handle t_eq_mod_one_coord,\n    },\n    { use s_finset s_ne_zero,\n      split,\n      { apply le_of_eq,\n        exact s_finset_card s_ne_zero,\n      },\n      split,\n      { intros coord1 coord1_in_s_finset coord2 coord2_in_s_finset coord1_ne_coord2,\n        exact s_finset_distinct_mod_one coord1_ne_coord2 coord1_in_s_finset coord2_in_s_finset,\n      },\n      intros t t_in_T_shifted,\n      exact T_shifted_property_before_i t t_in_T_shifted j j_val_lt_i_val,\n    },\n    rcases T_is_s_discrete j with ⟨coords, coords_card_le_s, ⟨coords_distinct_mod_one, t_in_T_imp_t_j_in_coords⟩⟩,\n    use [coords, coords_card_le_s],\n    split, exact coords_distinct_mod_one,\n    intros t t_in_T_shifted,\n    rcases T_shifted_property_after_i t t_in_T_shifted j j_val_gt_i_val with ⟨t', t'_in_T, t_eq_t'_at_j⟩,\n    rw t_eq_t'_at_j,\n    exact t_in_T_imp_t_j_in_coords t' t'_in_T,\n  },\n  intros p p_in_T_shifted j j_val_le_i,\n  cases lt_or_eq_of_le j_val_le_i with j_val_lt_i_val j_val_eq_i_val, \n  exact T_shifted_property_before_i p p_in_T_shifted j j_val_lt_i_val,\n  have j_eq_i : j = i := fin.eq_of_veq j_val_eq_i_val,\n  rw j_eq_i,\n  replace T_shifted_property_at_i := T_shifted_property_at_i p p_in_T_shifted,\n  cases T_shifted_property_at_i with T_shifted_shifts_all_bad_coords T_shifted_coords_all_in_goal_finset,\n  by_contra p_coord_not_in_goal_finset, --Derive contradiction between p_coord_not_in_goal_finset and T_shifted_property_at_i\n  cases T_shifted_coords_all_in_goal_finset with T_shifted_coords_all_in_goal_finset p_in_T,\n  { rcases T_shifted_coords_all_in_goal_finset with ⟨goal_val, goal_val_in_goal_finset, p_eq_goal_val_mod_one⟩,\n    simp only [not_exists, exists_prop, not_and] at p_coord_not_in_goal_finset,\n    have goal_val_in_s_finset := finset.mem_of_subset goal_finset_subset_s_finset goal_val_in_goal_finset,\n    exact p_coord_not_in_goal_finset goal_val goal_val_in_s_finset p_eq_goal_val_mod_one,\n  },\n  have p_i_in_coords : ∃ coord ∈ coords, eq_mod_one (vector.nth p i) coord := T_is_s_discrete' p p_in_T,\n  rcases p_i_in_coords with ⟨coord, coord_in_coords, p_i_eq_coords_mod_one⟩,\n  by_cases coord_in_goal_finset : coord ∈ goal_finset,\n  { simp only [not_exists, exists_prop, not_and] at p_coord_not_in_goal_finset,\n    have coord_in_s_finset := finset.mem_of_subset goal_finset_subset_s_finset coord_in_goal_finset,\n    exact p_coord_not_in_goal_finset coord coord_in_s_finset p_i_eq_coords_mod_one,\n  },\n  rename coord_in_goal_finset coord_not_in_goal_finset,\n  have coord_in_coords_to_handle : coord ∈ coords \\ coords_inter_s_finset :=\n    begin\n      dsimp[coords_inter_s_finset],\n      simp only [not_exists, exists_prop, not_and, finset.mem_sdiff, finset.mem_filter],\n      split, exact coord_in_coords,\n      intros coord_in_coords goal_val goal_val_in_goal_finset coord_eq_goal_val_mod_one,\n      have p_eq_goal_val_mod_one := eq_mod_one_transitive p_i_eq_coords_mod_one coord_eq_goal_val_mod_one,\n      simp only [not_exists, exists_prop, not_and] at p_coord_not_in_goal_finset,\n      exact p_coord_not_in_goal_finset goal_val goal_val_in_goal_finset p_eq_goal_val_mod_one,\n    end,\n  exact T_shifted_shifts_all_bad_coords coord coord_in_coords_to_handle p_i_eq_coords_mod_one,\nend\n\nlemma inductive_replacement_lemma {d : ℕ} {s : ℕ} (d_ne_zero : d ≠ 0) (s_ne_zero : s ≠ 0) (T : set (point d)) \n  (T_is_tiling : is_tiling T) (T_faceshare_free : tiling_faceshare_free T) (T_is_periodic: is_periodic T_is_tiling) (T_is_s_discrete : is_s_discrete s T) :\n  ∃ T_shifted : set (point d), ∃ T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted ∧ is_periodic T_shifted_is_tiling ∧\n  (∀ i : fin d, ∀ p : point d, p ∈ T_shifted → ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p i) s_val) :=\nbegin\n  let d_sub_one : fin d := ⟨d - 1, nat.pred_lt d_ne_zero⟩,\n  have inductive_replacement_lemma_helper_fact : ∀ i : fin d, i.val < d → \n    ∃ T_shifted : set (point d), ∃ T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted ∧ \n    is_periodic T_shifted_is_tiling ∧ is_s_discrete s T_shifted ∧\n    ∀ p : point d, p ∈ T_shifted → ∀ j : fin d, j.val ≤ i.val → ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val :=\n    begin\n      intro i,\n      induction i.val,\n      { intro zero_lt_d,\n        have coords_before_zero_handled : ∀ p : point d, p ∈ T → ∀ j : fin d, j.val < 0 → \n          ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val :=\n          by {intros p p_in_T j j_lt_zero, exfalso, clear_except j_lt_zero, linarith,},\n        exact inductive_replacement_lemma_helper1 d_ne_zero s_ne_zero ⟨0, zero_lt_d⟩ T T_is_tiling T_faceshare_free\n          T_is_periodic T_is_s_discrete coords_before_zero_handled,\n      },\n      intro n_succ_lt_d,\n      have n_lt_d : n < d := nat.lt_of_succ_lt n_succ_lt_d,\n      rcases ih n_lt_d with\n        ⟨T_shifted_prev, T_shifted_prev_is_tiling, T_shifted_prev_faceshare_free, T_shifted_prev_is_periodic, T_shifted_prev_s_discrete, \n        T_shifted_prev_coord_property⟩,\n      have coords_before_n_succ_handled : \n        ∀ p : point d, p ∈ T_shifted_prev → ∀ j : fin d, j.val < n.succ → ∃ s_val ∈ s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val :=\n        begin\n          intros p p_in_T_shifted_prev j j_lt_n_succ,\n          have j_le_n := nat.le_of_lt_succ j_lt_n_succ,\n          exact T_shifted_prev_coord_property p p_in_T_shifted_prev j j_le_n,\n        end,\n      exact inductive_replacement_lemma_helper1 d_ne_zero s_ne_zero ⟨n.succ, n_succ_lt_d⟩ T_shifted_prev T_shifted_prev_is_tiling\n        T_shifted_prev_faceshare_free T_shifted_prev_is_periodic T_shifted_prev_s_discrete coords_before_n_succ_handled,\n    end,\n  rcases inductive_replacement_lemma_helper_fact d_sub_one (nat.pred_lt d_ne_zero) with\n    ⟨T_shifted, T_shifted_is_tiling, T_shifted_faceshare_free, T_shifted_is_periodic, T_shifted_s_discrete, T_shifted_only_uses_goal_coordinates⟩,\n  use [T_shifted, T_shifted_is_tiling, T_shifted_faceshare_free, T_shifted_is_periodic],\n  intros i p p_in_T_shifted,\n  have i_val_le_d_sub_one_val : i.val ≤ d_sub_one.val :=\n    begin\n      have i_val_lt_d := i.property,\n      dsimp only[d_sub_one],\n      exact nat.le_pred_of_lt i_val_lt_d,\n    end,\n  exact T_shifted_only_uses_goal_coordinates p p_in_T_shifted i i_val_le_d_sub_one_val,\nend\n\nlemma goal_clique_with_info_map_fn_yields_fin_double_s_vector {d s : ℕ} (d_ne_zero : d ≠ 0) (s_ne_zero : s ≠ 0) (T : set (point d)) (T_is_tiling : is_tiling T)\n  (T_faceshare_free : tiling_faceshare_free T) (T_is_periodic : is_periodic T_is_tiling) (T_is_s_discrete : is_s_discrete s T) (T_shifted : set (point d))\n  (T_shifted_is_tiling : is_tiling T_shifted) (T_shifted_faceshare_free : tiling_faceshare_free T_shifted)\n  (T_shifted_contains_only_s_points : \n    ∀ (i : fin d) (p : point d), p ∈ T_shifted → (∃ (s_val : ℝ) (H : s_val ∈ s_finset s_ne_zero), eq_mod_one (vector.nth p i) s_val))\n  (core_points_finset : \n    finset {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)})\n  (core_points_finset_card : core_points_finset.card = 2 ^ d)\n  (core_points_finset_property : \n    ∀ (p : point d) (h : ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)),\n      (⟨p, h⟩ : {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)}) ∈ core_points_finset)\n  (p : {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)}) :\n  ∃ fin_double_s_vector : vector (fin (2*s)) d, ∀ i : fin d, ↑(fin_double_s_vector.nth i).val = ↑s * (((point_to_corner T_shifted_is_tiling p).val).nth i) + s - 1 :=\nbegin\n  let p_corner := (point_to_corner T_shifted_is_tiling ↑p).val,\n  have p_corner_def : p_corner = (point_to_corner T_shifted_is_tiling ↑p).val := by refl,\n  have p_corner_property := (point_to_corner T_shifted_is_tiling ↑p).property,\n  rw ← p_corner_def at p_corner_property,\n  rw ← p_corner_def,\n  rcases p_corner_property with ⟨p_corner_in_T_shifted, p_in_p_corner, p_corner_unique⟩,\n  rw cube at p_in_p_corner,\n  simp only [set.mem_set_of_eq] at p_in_p_corner,\n  rw in_cube at p_in_p_corner,\n  have each_coord_is_nat : ∀ i : fin d, ∃ n : ℕ, ↑n = ↑s * vector.nth p_corner i + ↑s - 1 :=\n    begin\n      intro i,\n      rcases T_shifted_contains_only_s_points i p_corner p_corner_in_T_shifted with ⟨s_val, s_val_in_s_finset, p_corner_eq_s_val_mod_one⟩,\n      rcases s_finset_range s_val_in_s_finset with ⟨zero_le_s_val, s_val_lt_one⟩,\n      replace p_in_p_corner := p_in_p_corner i,\n      rcases p_in_p_corner with ⟨p_corner_le_p, p_lt_p_corner_add_one⟩,\n      cases p.property i with p_property unnecessary,\n      clear unnecessary,\n      cases p_property i.property with p_eq_zero p_eq_one,\n      { simp only [subtype.val_eq_coe] at p_eq_zero,\n        rw p_eq_zero at p_corner_le_p p_lt_p_corner_add_one,\n        rcases p_corner_eq_s_val_mod_one with ⟨p_corner_floor, zero, y, zero_le_y, y_lt_one, p_corner_def, s_val_def⟩,\n        have zero_eq_zero : zero = 0 :=\n          begin\n            rw s_val_def at zero_le_s_val s_val_lt_one,\n            clear_except zero_le_s_val s_val_lt_one zero_le_y y_lt_one,\n            rcases eq_or_lt_or_gt zero 0 with zero_eq_zero | zero_lt_zero | zero_gt_zero,\n            exact zero_eq_zero,\n            { have zero_le_neg_one : zero ≤ -1 := by omega,\n              have cast_zero_le_neg_one : ↑zero ≤ (-1 : ℝ) := by exact_mod_cast zero_le_neg_one,\n              linarith,\n            },\n            have zero_ge_one : zero ≥ 1 := by omega,\n            have cast_zero_ge_one : ↑zero ≥ (1 : ℝ) := by exact_mod_cast zero_ge_one,\n            linarith,\n          end,\n        have cast_zero_eq_zero : ↑zero = (0 : ℝ) := by exact_mod_cast zero_eq_zero,\n        rw [cast_zero_eq_zero, zero_add] at s_val_def,\n        rw ← s_val_def at p_corner_def,\n        by_cases s_val_eq_zero : s_val = 0,\n        { rw [s_val_eq_zero, add_zero] at p_corner_def,\n          use  s * int.to_nat(p_corner_floor) + s - 1,\n          have zero_le_p_corner_floor : 0 ≤ p_corner_floor :=\n            begin\n              clear_except p_corner_def p_lt_p_corner_add_one p_corner_le_p,\n              rw p_corner_def at p_lt_p_corner_add_one p_corner_le_p,\n              have h1 : p_corner_floor ≤ 0 := by exact_mod_cast p_corner_le_p,\n              have h2 : 0 < p_corner_floor + 1 := by exact_mod_cast p_lt_p_corner_add_one,\n              omega,\n            end,\n          have p_corner_floor_to_nat_eq_self : ↑p_corner_floor.to_nat = p_corner_floor := int.to_nat_of_nonneg zero_le_p_corner_floor,\n          have cast_p_corner_floor_to_nat_eq_self : ↑p_corner_floor.to_nat = (↑p_corner_floor : ℝ) := \n            by exact_mod_cast p_corner_floor_to_nat_eq_self,\n          have one_le_s : 1 ≤ s := \n            begin\n              rcases nat_eq_or_lt_or_gt s 0 with s_eq_zero | s_lt_zero | s_gt_zero,\n              { exfalso,\n                exact s_ne_zero s_eq_zero,\n              },\n              { exfalso,\n                exact nat.not_lt_zero s s_lt_zero,\n              },\n              clear_except s_gt_zero,\n              have zero_lt_s : 0 < s := by linarith,\n              omega,\n            end,\n          rw [nat.add_sub_assoc one_le_s, nat.cast_add (s * p_corner_floor.to_nat) (s - 1), nat.cast_sub one_le_s, nat.cast_mul,\n            cast_p_corner_floor_to_nat_eq_self, p_corner_def, ← add_sub_assoc, nat.cast_one],\n        },\n        rename s_val_eq_zero s_val_ne_zero,\n        rcases s_finset_range s_val_in_s_finset with ⟨zero_le_s_val, s_val_lt_one⟩,\n        rw s_finset at s_val_in_s_finset,\n        simp only [exists_prop, finset.mem_map, function.embedding.coe_fn_mk, finset.mem_range] at s_val_in_s_finset,\n        rcases s_val_in_s_finset with ⟨s_val_num, s_val_num_lt_s, s_val_num_div_s_eq_s_val⟩,\n        use s_val_num - 1,\n        rcases nat_eq_or_lt_or_gt s_val_num 0 with s_val_num_eq_zero | s_val_num_lt_zero | s_val_num_gt_zero,\n        { exfalso,\n          rw s_val_num_eq_zero at s_val_num_div_s_eq_s_val,\n          simp only [zero_div, nat.cast_zero] at s_val_num_div_s_eq_s_val,\n          symmetry' at s_val_num_div_s_eq_s_val,\n          exact s_val_ne_zero s_val_num_div_s_eq_s_val,\n        },\n        { exfalso,\n          clear_except s_val_num_lt_zero,\n          linarith,\n        },\n        have one_le_s_val_num : 1 ≤ s_val_num := by {clear_except s_val_num_gt_zero, omega},\n        have cast_s_ne_zero : ↑s ≠ (0 : ℝ) := by exact_mod_cast s_ne_zero,\n        have p_corner_floor_eq_neg_one : p_corner_floor = -1 :=\n          begin\n            rcases eq_or_lt_or_gt p_corner_floor (-1) with p_corner_floor_eq_neg_one | p_corner_floor_lt_neg_one | p_corner_floor_gt_neg_one,\n            exact p_corner_floor_eq_neg_one,\n            { have p_corner_floor_le_neg_two : p_corner_floor ≤ -2 := by {clear_except p_corner_floor_lt_neg_one, omega},\n              have cast_p_corner_floor_le_neg_two : ↑p_corner_floor ≤ (-2 : ℝ) := by exact_mod_cast p_corner_floor_le_neg_two,\n              linarith,\n            },\n            have zero_le_p_corner_floor : 0 ≤ p_corner_floor := by {clear_except p_corner_floor_gt_neg_one, omega},\n            have cast_zero_le_p_corner_floor : (0 : ℝ) ≤ ↑p_corner_floor := by exact_mod_cast zero_le_p_corner_floor,\n            have zero_ne_s_val : 0 ≠ s_val := by {intro zero_eq_s_val, symmetry' at zero_eq_s_val, exact s_val_ne_zero zero_eq_s_val},\n            have zero_lt_s_val : 0 < s_val := lt_of_le_of_ne zero_le_s_val zero_ne_s_val,\n            linarith,\n          end,\n        have cast_p_corner_floor_eq_neg_one : ↑p_corner_floor = (-1 : ℝ) := by exact_mod_cast p_corner_floor_eq_neg_one,\n        rw ← s_val_num_div_s_eq_s_val at p_corner_def,\n        rw [nat.cast_sub one_le_s_val_num, p_corner_def, mul_add, mul_div_of_ne_zero ↑s_val_num cast_s_ne_zero, cast_p_corner_floor_eq_neg_one],\n        simp only [nat.cast_one, mul_neg, mul_one, neg_add_cancel_comm],\n      },\n      simp only [subtype.val_eq_coe] at p_eq_one,\n      rw p_eq_one at p_corner_le_p p_lt_p_corner_add_one,\n      rcases p_corner_eq_s_val_mod_one with ⟨p_corner_floor, zero, y, zero_le_y, y_lt_one, p_corner_def, s_val_def⟩,\n       have zero_eq_zero : zero = 0 :=\n        begin\n          rw s_val_def at zero_le_s_val s_val_lt_one,\n          clear_except zero_le_s_val s_val_lt_one zero_le_y y_lt_one,\n          rcases eq_or_lt_or_gt zero 0 with zero_eq_zero | zero_lt_zero | zero_gt_zero,\n          exact zero_eq_zero,\n          { have zero_le_neg_one : zero ≤ -1 := by omega,\n            have cast_zero_le_neg_one : ↑zero ≤ (-1 : ℝ) := by exact_mod_cast zero_le_neg_one,\n            linarith,\n          },\n          have zero_ge_one : zero ≥ 1 := by omega,\n          have cast_zero_ge_one : ↑zero ≥ (1 : ℝ) := by exact_mod_cast zero_ge_one,\n          linarith,\n        end,\n      have cast_zero_eq_zero : ↑zero = (0 : ℝ) := by exact_mod_cast zero_eq_zero,\n      rw [cast_zero_eq_zero, zero_add] at s_val_def,\n      rw ← s_val_def at p_corner_def,\n      by_cases s_val_eq_zero : s_val = 0,\n      { rw [s_val_eq_zero, add_zero] at p_corner_def,\n        use s * int.to_nat(p_corner_floor) + s - 1,\n        have one_le_p_corner_floor : 1 ≤ p_corner_floor :=\n          begin\n            clear_except p_corner_def p_lt_p_corner_add_one,\n            rw p_corner_def at p_lt_p_corner_add_one,\n            have h : 1 < p_corner_floor + 1 := by exact_mod_cast p_lt_p_corner_add_one,\n            omega,\n          end,\n        have zero_le_p_corner_floor : 0 ≤ p_corner_floor := by linarith,\n        have p_corner_floor_to_nat_eq_self : ↑p_corner_floor.to_nat = p_corner_floor := int.to_nat_of_nonneg zero_le_p_corner_floor,\n        have cast_p_corner_floor_to_nat_eq_self : ↑p_corner_floor.to_nat = (↑p_corner_floor : ℝ) := \n          by exact_mod_cast p_corner_floor_to_nat_eq_self,\n        have one_le_s : 1 ≤ s := \n          begin\n            rcases nat_eq_or_lt_or_gt s 0 with s_eq_zero | s_lt_zero | s_gt_zero,\n            { exfalso,\n              exact s_ne_zero s_eq_zero,\n            },\n            { exfalso,\n              exact nat.not_lt_zero s s_lt_zero,\n            },\n            clear_except s_gt_zero,\n            have zero_lt_s : 0 < s := by linarith,\n            omega,\n          end,\n        rw [nat.add_sub_assoc one_le_s, nat.cast_add (s * p_corner_floor.to_nat) (s - 1), nat.cast_sub one_le_s, nat.cast_mul,\n          cast_p_corner_floor_to_nat_eq_self, p_corner_def, ← add_sub_assoc, nat.cast_one],\n      },\n      rename s_val_eq_zero s_val_ne_zero,\n      rcases s_finset_range s_val_in_s_finset with ⟨zero_le_s_val, s_val_lt_one⟩,\n      rw s_finset at s_val_in_s_finset,\n      simp only [exists_prop, finset.mem_map, function.embedding.coe_fn_mk, finset.mem_range] at s_val_in_s_finset,\n      rcases s_val_in_s_finset with ⟨s_val_num, s_val_num_lt_s, s_val_num_div_s_eq_s_val⟩,\n      use ↑s_val_num + ↑s - 1,\n      rcases nat_eq_or_lt_or_gt s_val_num 0 with s_val_num_eq_zero | s_val_num_lt_zero | s_val_num_gt_zero,\n      { exfalso,\n        rw s_val_num_eq_zero at s_val_num_div_s_eq_s_val,\n        simp only [zero_div, nat.cast_zero] at s_val_num_div_s_eq_s_val,\n        symmetry' at s_val_num_div_s_eq_s_val,\n        exact s_val_ne_zero s_val_num_div_s_eq_s_val,\n      },\n      { exfalso,\n        clear_except s_val_num_lt_zero,\n        linarith,\n      },\n      have one_le_s_val_num : 1 ≤ s_val_num := by {clear_except s_val_num_gt_zero, omega},\n      have one_le_s_add_s_val_num : 1 ≤ ↑s_val_num + ↑s := by linarith,\n      have cast_s_ne_zero : ↑s ≠ (0 : ℝ) := by exact_mod_cast s_ne_zero,\n      have p_corner_floor_eq_zero : p_corner_floor = 0 :=\n        begin\n          rcases eq_or_lt_or_gt p_corner_floor 0 with p_corner_floor_eq_zero | p_corner_floor_lt_zero | p_corner_floor_gt_zero,\n          exact p_corner_floor_eq_zero,\n          { have p_corner_floor_le_neg_one : p_corner_floor ≤ -1 := by {clear_except p_corner_floor_lt_zero, omega},\n            have cast_p_corner_floor_le_neg_one : ↑p_corner_floor ≤ (-1 : ℝ) := by exact_mod_cast p_corner_floor_le_neg_one,\n            linarith,\n          },\n          have one_le_p_corner_floor : 1 ≤ p_corner_floor := by {clear_except p_corner_floor_gt_zero, omega},\n          have cast_one_le_p_corner_floor : (1 : ℝ) ≤ ↑p_corner_floor := by exact_mod_cast one_le_p_corner_floor,\n          have zero_ne_s_val : 0 ≠ s_val := by {intro zero_eq_s_val, symmetry' at zero_eq_s_val, exact s_val_ne_zero zero_eq_s_val},\n          have zero_lt_s_val : 0 < s_val := lt_of_le_of_ne zero_le_s_val zero_ne_s_val,\n          linarith,\n        end,\n      have cast_p_corner_floor_eq_zero : ↑p_corner_floor = (0 : ℝ) := by exact_mod_cast p_corner_floor_eq_zero,\n      rw ← s_val_num_div_s_eq_s_val at p_corner_def,\n      rw [nat.cast_sub one_le_s_add_s_val_num, p_corner_def, mul_add, mul_div_of_ne_zero ↑s_val_num cast_s_ne_zero, cast_p_corner_floor_eq_zero],\n      simp only [nat.cast_id, nat.cast_add, zero_add, nat.cast_one, mul_zero],\n    end,\n  have each_coord_lt_double_s : ∀ i : fin d, classical.some (each_coord_is_nat i) < 2 * s :=\n    begin\n      intro i,\n      have cast_goal : ↑(classical.some (each_coord_is_nat i)) < (2 : ℝ) * ↑s :=\n        begin\n          rw classical.some_spec (each_coord_is_nat i),\n          replace p_in_p_corner := p_in_p_corner i,\n          rcases p_in_p_corner with ⟨p_corner_le_p, p_lt_p_corner_add_one⟩,\n          have p_le_one : vector.nth (↑p : point d) i ≤ (1 : ℝ) :=\n            begin\n              cases p.property i with p_property unneeded,\n              simp only [subtype.val_eq_coe] at p_property,\n              cases p_property i.property with p_eq_zero p_eq_one,\n              { rw p_eq_zero,\n                linarith,\n              },\n              rw p_eq_one,\n            end,\n          have p_corner_le_one : vector.nth p_corner i ≤ 1 := by linarith,\n          have zero_le_p : (0 : ℝ) ≤ vector.nth (↑p : point d) i :=\n            begin\n              cases p.property i with p_property unneeded,\n              simp only [subtype.val_eq_coe] at p_property,\n              cases p_property i.property with p_eq_zero p_eq_one,\n              rw p_eq_zero,\n              rw p_eq_one,\n              linarith,\n            end,\n          have neg_one_le_p_corner : -1 ≤ vector.nth p_corner i := by linarith,\n          have zero_le_cast_s : (0 : ℝ) ≤ ↑s := by exact_mod_cast (zero_le s),\n          have goal_sans_sub_one : ↑s * vector.nth p_corner i + ↑s ≤ 2 * ↑s :=\n            begin\n              rw mul_comm (2 : ℝ) ↑s,\n              convert_to ↑s * vector.nth p_corner i + ↑s * 1 ≤ ↑s * 2, rw mul_one,\n              rw ← mul_add,\n              apply mul_le_mul, exact le_refl ↑s, linarith, linarith, exact zero_le_cast_s,\n            end,\n          clear_except goal_sans_sub_one,\n          linarith,\n        end,\n      exact_mod_cast cast_goal,\n    end,\n  use vector.of_fn (λ i, ⟨classical.some (each_coord_is_nat i), each_coord_lt_double_s i⟩),\n  intro i,\n  simp only [vector.nth_of_fn],\n  rw classical.some_spec (each_coord_is_nat i),\nend\n\nnoncomputable def build_goal_clique_with_info_map_fn {d s : ℕ} (d_ne_zero : d ≠ 0) (s_ne_zero : s ≠ 0) (T : set (point d)) (T_is_tiling : is_tiling T)\n  (T_faceshare_free : tiling_faceshare_free T) (T_is_periodic : is_periodic T_is_tiling) (T_is_s_discrete : is_s_discrete s T) (T_shifted : set (point d))\n  (T_shifted_is_tiling : is_tiling T_shifted) (T_shifted_faceshare_free : tiling_faceshare_free T_shifted)\n  (T_shifted_contains_only_s_points : \n    ∀ (i : fin d) (p : point d), p ∈ T_shifted → (∃ (s_val : ℝ) (H : s_val ∈ s_finset s_ne_zero), eq_mod_one (vector.nth p i) s_val))\n  (core_points_finset : \n    finset {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)})\n  (core_points_finset_card : core_points_finset.card = 2 ^ d)\n  (core_points_finset_property : \n    ∀ (p : point d) (h : ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)),\n      (⟨p, h⟩ : {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)}) ∈ core_points_finset) : \n  {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)} →\n  {v : vector (fin (2*s)) d // ∃ p : point d, is_core_point p ∧ ∃ p_corner ∈ T_shifted, \n    p ∈ cube p_corner ∧ (∀ alt_corner : point d, alt_corner ∈ T_shifted → p ∈ cube alt_corner → alt_corner = p_corner) ∧\n    (∀ i : fin d, ↑s * (vector.nth p_corner i) + ↑s - 1 = (vector.nth v i).val)} :=\nbegin\n  intro p,\n  use classical.some \n    (goal_clique_with_info_map_fn_yields_fin_double_s_vector d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n      T_shifted_is_tiling T_shifted_faceshare_free T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n      core_points_finset_property p),\n  let res := classical.some \n    (goal_clique_with_info_map_fn_yields_fin_double_s_vector d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n      T_shifted_is_tiling T_shifted_faceshare_free T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n      core_points_finset_property p),\n  have res_def : res = classical.some \n    (goal_clique_with_info_map_fn_yields_fin_double_s_vector d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n      T_shifted_is_tiling T_shifted_faceshare_free T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n      core_points_finset_property p) := by refl,\n  rw ← res_def,\n  have res_property := classical.some_spec\n    (goal_clique_with_info_map_fn_yields_fin_double_s_vector d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n      T_shifted_is_tiling T_shifted_faceshare_free T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n      core_points_finset_property p),\n  rw ← res_def at res_property,\n  let p_corner := (point_to_corner T_shifted_is_tiling p).val,\n  have p_corner_def : p_corner = (point_to_corner T_shifted_is_tiling p).val := by refl,\n  have p_corner_property := (point_to_corner T_shifted_is_tiling p).property,\n  rw ← p_corner_def at p_corner_property,\n  rcases p_corner_property with ⟨p_corner_in_T_shifted, p_in_p_corner, p_corner_unique⟩,\n  use [p.val, (λ i, (and.elim_left (p.property i)) i.property), p_corner, p_corner_in_T_shifted, p_in_p_corner, p_corner_unique],\n  intro i,\n  symmetry,\n  exact res_property i,\nend\n\nlemma periodic_tiling_implies_clique_helper {d s : ℕ} (d_ne_zero : d ≠ 0) (s_ne_zero : s ≠ 0) (T : set (point d)) (T_is_tiling : is_tiling T)\n  (T_faceshare_free : tiling_faceshare_free T) (T_is_periodic : is_periodic T_is_tiling) (T_is_s_discrete : is_s_discrete s T)\n  (T_shifted : set (point d)) (T_shifted_is_tiling : is_tiling T_shifted) (T_shifted_faceshare_free : tiling_faceshare_free T_shifted)\n  (T_shifted_is_periodic : is_periodic T_shifted_is_tiling)\n  (T_shifted_contains_only_s_points : \n    ∀ (i : fin d) (p : point d), p ∈ T_shifted → (∃ (s_val : ℝ) (H : s_val ∈ s_finset s_ne_zero), eq_mod_one (vector.nth p i) s_val))\n  (core_points_finset : \n    finset {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)})\n  (core_points_finset_card : core_points_finset.card = 2 ^ d)\n  (core_points_finset_property : \n    ∀ (p : point d) (h : ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)),\n    (⟨p, h⟩ : {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)}) \n    ∈ core_points_finset)\n  (goal_clique_with_info_map : \n    {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)} ↪\n    {v : vector (fin (2*s)) d // ∃ (p : point d), is_core_point p ∧ ∃ (p_corner : point d) (H : p_corner ∈ T_shifted), p ∈ cube p_corner ∧\n      (∀ (alt_corner : point d), alt_corner ∈ T_shifted → p ∈ cube alt_corner → alt_corner = p_corner) ∧\n      ∀ (i : fin d), ↑s * vector.nth p_corner i + ↑s - 1 = ↑((v.nth i).val)})\n  (v1 v2 : vector (fin (2 * s)) d) (v1_ne_v2 : v1 ≠ v2) (v1' : vector (fin (2 * s)) d) (core_point1 : point d)\n  (core_point1_is_core_point : is_core_point core_point1) (core_point1_corner : point d)\n  (core_point1_corner_in_T_shifted : core_point1_corner ∈ T_shifted) (core_point1_in_core_point1_corner : core_point1 ∈ cube core_point1_corner)\n  (core_point1_corner_unique : \n    ∀ (alt_corner : point d), alt_corner ∈ T_shifted → core_point1 ∈ cube alt_corner → alt_corner = core_point1_corner)\n  (v2' : vector (fin (2 * s)) d) (core_point2 : point d) (core_point2_is_core_point : is_core_point core_point2) (core_point2_corner : point d)\n  (core_point2_corner_in_T_shifted : core_point2_corner ∈ T_shifted) (core_point2_in_core_point2_corner : core_point2 ∈ cube core_point2_corner)\n  (core_point2_corner_unique : ∀ (alt_corner : point d), alt_corner ∈ T_shifted → core_point2 ∈ cube alt_corner → alt_corner = core_point2_corner)\n  (v2_def : v2' = v2) (v1_def : v1' = v1)\n  (core_point1_corner_v1'_relationship : ∀ (i : fin d), ↑s * vector.nth core_point1_corner i + ↑s - 1 = ↑(↑(v1.nth i) : ℕ))\n  (core_point2_corner_v2'_relationship : ∀ (i : fin d), ↑s * vector.nth core_point2_corner i + ↑s - 1 = ↑(↑(v2.nth i) : ℕ))\n  (v1_not_adj_v2 : \n    (∀ (x : fin d), ↑(v1.nth x) = ↑(v2.nth x) + s → ∀ (x_1 : fin d), ¬v1.nth x_1 = v2.nth x_1 → x = x_1) ∧ \n    ∀ (x : fin d), ↑(v2.nth x) = ↑(v1.nth x) + s → ∀ (x_1 : fin d), ¬v2.nth x_1 = v1.nth x_1 → x = x_1)\n  (v1_not_adj_v2_hyp_false : ¬∃ (i : fin d), ↑(v1.nth i) = ↑(v2.nth i) + s ∨ ↑(v2.nth i) = ↑(v1.nth i) + s) :\n  let goal_clique_with_info : finset\n        {v : vector (fin (2*s)) d // ∃ (p : point d),\n           is_core_point p ∧\n             ∃ (p_corner : point d) (H : p_corner ∈ T_shifted),\n               p ∈ cube p_corner ∧\n                 (∀ (alt_corner : point d),\n                      alt_corner ∈ T_shifted →\n                      p ∈ cube alt_corner → alt_corner = p_corner) ∧\n                   ∀ (i : fin d),\n                     ↑s * vector.nth p_corner i + ↑s - 1 =\n                       ↑((v.nth i).val)} :=\n        finset.map goal_clique_with_info_map core_points_finset\n  in false :=\nbegin\n  intros goal_clique_with_info,\n  simp only [not_exists] at v1_not_adj_v2_hyp_false,\n  have core_point1_corner_ne_core_point2_corner_add_or_sub_1 :\n    ∀ i : fin d, core_point1_corner.nth i ≠ core_point2_corner.nth i + 1 ∧ core_point2_corner.nth i ≠ core_point1_corner.nth i + 1 :=\n    begin\n      intro i,\n      replace v1_not_adj_v2_hyp_false := v1_not_adj_v2_hyp_false i,\n      rw not_or_distrib at v1_not_adj_v2_hyp_false,\n      cases v1_not_adj_v2_hyp_false with v1_ne_v2_add_s v2_ne_v1_add_s,\n      replace core_point1_corner_v1'_relationship := core_point1_corner_v1'_relationship i,\n      replace core_point2_corner_v2'_relationship := core_point2_corner_v2'_relationship i,\n      have real_v1_ne_v2_add_s : (↑(↑(v1.nth i) : ℕ) : ℝ) ≠ (↑(↑(v2.nth i) : ℕ) : ℝ) + ↑s := by exact_mod_cast v1_ne_v2_add_s,\n      have real_v2_ne_v1_add_s : (↑(↑(v2.nth i) : ℕ) : ℝ) ≠ (↑(↑(v1.nth i) : ℕ) : ℝ) + ↑s := by exact_mod_cast v2_ne_v1_add_s,\n      rw [← core_point1_corner_v1'_relationship, ← core_point2_corner_v2'_relationship, add_sub_assoc, add_sub_assoc,\n        add_comm (↑s * vector.nth core_point1_corner i) (↑s - 1), \n        add_comm (↑s * vector.nth core_point2_corner i) (↑s - 1),\n        add_assoc] at real_v1_ne_v2_add_s real_v2_ne_v1_add_s,\n      simp only [ne.def, add_right_inj] at real_v1_ne_v2_add_s real_v2_ne_v1_add_s,\n      have rw1 : ↑s * vector.nth core_point1_corner i + ↑s = ↑s * vector.nth core_point1_corner i + ↑s * (1 : ℝ) := by rw mul_one,\n      have rw2 : ↑s * vector.nth core_point2_corner i + ↑s = ↑s * vector.nth core_point2_corner i + ↑s * (1 : ℝ) := by rw mul_one,\n      rw rw1 at real_v2_ne_v1_add_s,\n      rw rw2 at real_v1_ne_v2_add_s,\n      rw ← mul_add at real_v1_ne_v2_add_s real_v2_ne_v1_add_s,\n      simp only [mul_eq_mul_left_iff, nat.cast_eq_zero] at real_v1_ne_v2_add_s real_v2_ne_v1_add_s,\n      rw not_or_distrib at real_v1_ne_v2_add_s real_v2_ne_v1_add_s,\n      exact ⟨real_v1_ne_v2_add_s.1, real_v2_ne_v1_add_s.1⟩,\n    end,\n  let z : int_point d := vector.of_fn\n    (λ i, if(core_point1_corner.nth i < core_point2_corner.nth i + 1 ∧ core_point2_corner.nth i < core_point1_corner.nth i + 1) then 0\n          else if(core_point2_corner.nth i >= core_point1_corner.nth i + 1) then 1\n          else -1),\n  let int_core_point1 : int_point d := vector.of_fn (λ i, if(core_point1.nth i = 0) then 0 else 1),\n  have int_point_to_point_int_core_point1_eq_core_point1 : int_point_to_point int_core_point1 = core_point1 :=\n    begin\n      apply vector.ext,\n      intro i,\n      rw int_point_to_point,\n      dsimp only[int_core_point1],\n      simp only [vector.nth_of_fn],\n      cases core_point1_is_core_point i with core_point1_eq_zero core_point1_eq_one,\n      rw [if_pos core_point1_eq_zero, core_point1_eq_zero], refl,\n      have core_point1_ne_zero : core_point1.nth i ≠ 0 := by {rw core_point1_eq_one, norm_num},\n      rw [if_neg core_point1_ne_zero, core_point1_eq_one],\n      norm_num,\n    end,\n  replace T_shifted_is_periodic := T_shifted_is_periodic int_core_point1 z,\n  let core_point1_add_double_z_corner := (int_point_to_corner T_shifted_is_tiling (add_int_vectors int_core_point1 (double_int_vector z))).val,\n  have core_point1_add_double_z_corner_def : \n    core_point1_add_double_z_corner = (int_point_to_corner T_shifted_is_tiling (add_int_vectors int_core_point1 (double_int_vector z))).val := by refl,\n  have core_point1_add_double_z_corner_property := (int_point_to_corner T_shifted_is_tiling (add_int_vectors int_core_point1 (double_int_vector z))).property,\n  rw ← core_point1_add_double_z_corner_def at core_point1_add_double_z_corner_property,\n  rcases core_point1_add_double_z_corner_property with \n    ⟨core_point1_add_double_z_corner_in_T_shifted, core_point1_add_double_z_in_core_point1_add_double_z_corner, core_point1_add_double_z_corner_unique⟩,\n  let shared_point : point d := vector.of_fn \n    (λ i, if(core_point2_corner.nth i >= core_point1_add_double_z_corner.nth i) then core_point2_corner.nth i else core_point1_add_double_z_corner.nth i),\n  rcases T_shifted_is_tiling shared_point with ⟨unique_corner, unique_corner_in_T_shifted, shared_point_in_unique_corner, unique_corner_unique⟩,\n  have shared_point_in_core_point1_add_double_z_corner : shared_point ∈ cube core_point1_add_double_z_corner :=\n    begin\n      rw cube,\n      simp only [set.mem_set_of_eq],\n      rw in_cube,\n      simp only [vector.nth_of_fn, ge_iff_le, not_exists],\n      intro i,\n      replace core_point1_corner_ne_core_point2_corner_add_or_sub_1 := core_point1_corner_ne_core_point2_corner_add_or_sub_1 i,\n      split,\n      { by_cases h : vector.nth core_point1_add_double_z_corner i ≤ vector.nth core_point2_corner i,\n        { rw if_pos h,\n          exact h,\n        },\n        rw if_neg h,\n      },\n      by_cases h : vector.nth core_point1_add_double_z_corner i ≤ vector.nth core_point2_corner i,\n      { rw if_pos h,\n        have int_core_point1_corner_eq_core_point1_corner : ↑(int_point_to_corner T_shifted_is_tiling int_core_point1) = core_point1_corner :=\n          begin\n            rw ← subtype.val_eq_coe,\n            rcases (int_point_to_corner T_shifted_is_tiling int_core_point1).property with\n              ⟨int_core_point1_corner_in_T_shifted, int_core_point1_in_int_core_point1_corner, int_core_point1_corner_unique⟩,\n            conv at int_core_point1_in_int_core_point1_corner\n            begin\n              find (int_point_to_point int_core_point1) {rw int_point_to_point_int_core_point1_eq_core_point1},\n            end,\n            exact core_point1_corner_unique (int_point_to_corner T_shifted_is_tiling int_core_point1).val int_core_point1_corner_in_T_shifted\n              int_core_point1_in_int_core_point1_corner,\n          end,\n        rw [core_point1_add_double_z_corner_def, T_shifted_is_periodic, double_int_vector, add_vectors],\n        conv\n        begin\n          find (int_point_to_point _) {rw int_point_to_point},\n        end,\n        simp only [subtype.val_eq_coe, vector.nth_of_fn, ge_iff_le, mul_ite, mul_zero, mul_one, mul_neg],\n        by_cases z_eq_zero : vector.nth core_point1_corner i < vector.nth core_point2_corner i + 1 ∧ vector.nth core_point2_corner i < vector.nth core_point1_corner i + 1,\n        { rw [if_pos z_eq_zero, int.cast_zero, add_zero, int_core_point1_corner_eq_core_point1_corner],\n          exact z_eq_zero.2,\n        },\n        rename z_eq_zero z_ne_zero,\n        rw cube at core_point1_in_core_point1_corner core_point2_in_core_point2_corner,\n        simp only [set.mem_set_of_eq] at core_point1_in_core_point1_corner core_point2_in_core_point2_corner,\n        rw in_cube at core_point1_in_core_point1_corner core_point2_in_core_point2_corner,\n        replace core_point1_in_core_point1_corner := core_point1_in_core_point1_corner i,\n        replace core_point2_in_core_point2_corner := core_point2_in_core_point2_corner i,\n        by_cases z_eq_one : vector.nth core_point2_corner i ≥ vector.nth core_point1_corner i + 1,\n        { rw [if_neg z_ne_zero, if_pos z_eq_one, int.cast_bit0, int.cast_one, int_core_point1_corner_eq_core_point1_corner],\n          have core_point2_le_one := le_one_of_is_core_point i core_point2_is_core_point,\n          have core_point1_ge_zero := ge_zero_of_is_core_point i core_point1_is_core_point,\n          linarith,\n        },\n        rename z_eq_one z_ne_one,\n        rw [if_neg z_ne_zero, if_neg z_ne_one, int.cast_neg, int.cast_bit0, int.cast_one, int_core_point1_corner_eq_core_point1_corner],\n        rw [not_and_distrib, not_lt, not_lt] at z_ne_zero,\n        cases z_ne_zero with core_point2_corner_add_one_le_core_point1_corner core_point1_corner_add_one_le_core_point2_corner,\n        { cases lt_or_eq_of_le core_point2_corner_add_one_le_core_point1_corner with goal core_point2_corner_add_one_eq_core_point1_corner,\n          linarith,\n          exfalso,\n          symmetry' at core_point2_corner_add_one_eq_core_point1_corner,\n          exact core_point1_corner_ne_core_point2_corner_add_or_sub_1.1 core_point2_corner_add_one_eq_core_point1_corner,\n        },\n        linarith,\n      },\n      rw if_neg h,\n      norm_num,\n    end,\n  have core_point1_add_double_z_corner_eq_unique_corner := \n    unique_corner_unique core_point1_add_double_z_corner core_point1_add_double_z_corner_in_T_shifted shared_point_in_core_point1_add_double_z_corner,\n  have shared_point_in_core_point2_corner : shared_point ∈ cube core_point2_corner :=\n    begin\n      rw cube,\n      simp only [set.mem_set_of_eq],\n      rw in_cube,\n      simp only [vector.nth_of_fn, ge_iff_le, not_exists],\n      intro i,\n      replace core_point1_corner_ne_core_point2_corner_add_or_sub_1 := core_point1_corner_ne_core_point2_corner_add_or_sub_1 i,\n      split,\n      { by_cases h : vector.nth core_point1_add_double_z_corner i ≤ vector.nth core_point2_corner i,\n        rw if_pos h,\n        rw if_neg h,\n        simp only [not_le] at h,\n        exact le_of_lt h,\n      },\n      by_cases h : vector.nth core_point1_add_double_z_corner i ≤ vector.nth core_point2_corner i,\n      { rw if_pos h,\n        norm_num,\n      },\n      rw if_neg h,\n      have int_core_point1_corner_eq_core_point1_corner : ↑(int_point_to_corner T_shifted_is_tiling int_core_point1) = core_point1_corner :=\n        begin\n          rw ← subtype.val_eq_coe,\n          rcases (int_point_to_corner T_shifted_is_tiling int_core_point1).property with\n            ⟨int_core_point1_corner_in_T_shifted, int_core_point1_in_int_core_point1_corner, int_core_point1_corner_unique⟩,\n          conv at int_core_point1_in_int_core_point1_corner\n          begin\n            find (int_point_to_point int_core_point1) {rw int_point_to_point_int_core_point1_eq_core_point1},\n          end,\n          exact core_point1_corner_unique (int_point_to_corner T_shifted_is_tiling int_core_point1).val int_core_point1_corner_in_T_shifted\n            int_core_point1_in_int_core_point1_corner,\n        end,\n      rw [core_point1_add_double_z_corner_def, T_shifted_is_periodic, double_int_vector, add_vectors],\n      conv\n      begin\n        find (int_point_to_point _) {rw int_point_to_point},\n      end,\n      simp only [subtype.val_eq_coe, vector.nth_of_fn, ge_iff_le, mul_ite, mul_zero, mul_one, mul_neg],\n      by_cases z_eq_zero : vector.nth core_point1_corner i < vector.nth core_point2_corner i + 1 ∧ vector.nth core_point2_corner i < vector.nth core_point1_corner i + 1,\n      { rw [if_pos z_eq_zero, int.cast_zero, add_zero, int_core_point1_corner_eq_core_point1_corner],\n        exact z_eq_zero.1,\n      },\n      rename z_eq_zero z_ne_zero,\n      rw cube at core_point1_in_core_point1_corner core_point2_in_core_point2_corner,\n      simp only [set.mem_set_of_eq] at core_point1_in_core_point1_corner core_point2_in_core_point2_corner,\n      rw in_cube at core_point1_in_core_point1_corner core_point2_in_core_point2_corner,\n      replace core_point1_in_core_point1_corner := core_point1_in_core_point1_corner i,\n      replace core_point2_in_core_point2_corner := core_point2_in_core_point2_corner i,\n      by_cases z_eq_one : vector.nth core_point2_corner i ≥ vector.nth core_point1_corner i + 1,\n      { rw [if_neg z_ne_zero, if_pos z_eq_one, int.cast_bit0, int.cast_one, int_core_point1_corner_eq_core_point1_corner],\n        rw [not_and_distrib, not_lt, not_lt] at z_ne_zero,\n        cases z_ne_zero with core_point2_corner_add_one_le_core_point1_corner core_point1_corner_add_one_le_core_point2_corner,\n        linarith,\n        cases lt_or_eq_of_le core_point1_corner_add_one_le_core_point2_corner with goal core_point1_corner_add_one_eq_core_point2_corner,\n        linarith,\n        exfalso,\n        symmetry' at core_point1_corner_add_one_eq_core_point2_corner,\n        exact core_point1_corner_ne_core_point2_corner_add_or_sub_1.2 core_point1_corner_add_one_eq_core_point2_corner,\n      },\n      rename z_eq_one z_ne_one,\n      rw [if_neg z_ne_zero, if_neg z_ne_one, int.cast_neg, int.cast_bit0, int.cast_one, int_core_point1_corner_eq_core_point1_corner],\n      have core_point2_ge_zero := ge_zero_of_is_core_point i core_point2_is_core_point,\n      have core_point2_le_one := le_one_of_is_core_point i core_point1_is_core_point,\n      linarith,\n    end,\n  have core_point2_corner_eq_unique_corner := \n    unique_corner_unique core_point2_corner core_point2_corner_in_T_shifted shared_point_in_core_point2_corner,\n  have core_point2_corner_eq_core_point1_add_double_z_corner : core_point2_corner = core_point1_add_double_z_corner :=\n    by rw [core_point1_add_double_z_corner_eq_unique_corner, core_point2_corner_eq_unique_corner],\n  by_cases core_point1_eq_core_point2 : core_point1 = core_point2,\n  { have v1_eq_v2 : v1 = v2 :=\n      begin\n        apply vector.ext,\n        intro i,\n        have cast_cast_goal : (↑(↑(v1.nth i) : ℕ) : ℝ) = (↑(↑(v2.nth i) : ℕ) : ℝ) :=\n          begin\n            rw [← core_point1_corner_v1'_relationship i, ← core_point2_corner_v2'_relationship i],\n            simp only [sub_left_inj, add_left_inj, mul_eq_mul_left_iff, nat.cast_eq_zero],\n            left,\n            rw core_point1_eq_core_point2 at core_point1_in_core_point1_corner,\n            rw core_point2_corner_unique core_point1_corner core_point1_corner_in_T_shifted core_point1_in_core_point1_corner,\n          end,\n        have cast_goal : (↑(v1.nth i) : ℕ) = (↑(v2.nth i) : ℕ) := by exact_mod_cast cast_cast_goal,\n        apply fin.eq_of_veq,\n        simp only [fin.val_eq_coe],\n        exact_mod_cast cast_goal,\n      end,\n    exact v1_ne_v2 v1_eq_v2,\n  },\n  have core_point1_ne_core_point2 : ∃ i : fin d, core_point1.nth i ≠ core_point2.nth i :=\n    begin\n      by_contra h,\n      simp only [not_exists_not] at h,\n      exact core_point1_eq_core_point2 (vector.ext h),\n    end,\n  cases core_point1_ne_core_point2 with i core_point1_ne_core_point2,\n  replace core_point1_is_core_point := core_point1_is_core_point i,\n  replace core_point2_is_core_point := core_point2_is_core_point i,\n  rw cube at core_point1_in_core_point1_corner core_point2_in_core_point2_corner core_point1_add_double_z_in_core_point1_add_double_z_corner,\n  simp only [set.mem_set_of_eq] at core_point1_in_core_point1_corner core_point2_in_core_point2_corner core_point1_add_double_z_in_core_point1_add_double_z_corner,\n  rw in_cube at core_point1_in_core_point1_corner core_point2_in_core_point2_corner core_point1_add_double_z_in_core_point1_add_double_z_corner,\n  replace core_point1_in_core_point1_corner := core_point1_in_core_point1_corner i,\n  replace core_point2_in_core_point2_corner := core_point2_in_core_point2_corner i,\n  replace core_point1_add_double_z_in_core_point1_add_double_z_corner := core_point1_add_double_z_in_core_point1_add_double_z_corner i,\n  cases core_point1_in_core_point1_corner with core_point1_corner_le_core_point1 core_point1_lt_core_point1_corner_add_one,\n  cases core_point2_in_core_point2_corner with core_point2_corner_le_core_point2 core_point2_lt_core_point2_corner_add_one,\n  rw [int_point_to_point, add_int_vectors, double_int_vector] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n  simp only [vector.nth_of_fn, ge_iff_le, mul_ite, mul_zero, mul_one, mul_neg, int.cast_add] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n  cases core_point1_is_core_point with core_point1_eq_zero core_point1_eq_one,\n  { cases core_point2_is_core_point with core_point2_eq_zero core_point2_eq_one,\n    { rw [core_point1_eq_zero, core_point2_eq_zero] at core_point1_ne_core_point2,\n      exact core_point1_ne_core_point2 (by refl),\n    },\n    rw if_pos core_point1_eq_zero at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    simp only [int.cast_zero, zero_add] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    rw ← core_point2_corner_eq_core_point1_add_double_z_corner at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    by_cases h1 : vector.nth core_point1_corner i < vector.nth core_point2_corner i + 1 ∧ vector.nth core_point2_corner i < vector.nth core_point1_corner i + 1,\n    { rw if_pos h1 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      simp only [int.cast_zero] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      linarith,\n    },\n    rw if_neg h1 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    by_cases h2 : vector.nth core_point1_corner i + 1 ≤ vector.nth core_point2_corner i,\n    { rw if_pos h2 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      simp only [int.cast_bit0, int.cast_one] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      linarith,\n    },\n    rw if_neg h2 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    simp only [int.cast_neg, int.cast_bit0, int.cast_one] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    linarith,\n  },\n  cases core_point2_is_core_point with core_point2_eq_zero core_point2_eq_one,\n  { have core_point1_ne_zero : core_point1.nth i ≠ 0 := by {rw core_point1_eq_one, norm_num},\n    rw if_neg core_point1_ne_zero at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    simp only [int.cast_one] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    rw ← core_point2_corner_eq_core_point1_add_double_z_corner at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    by_cases h1 : vector.nth core_point1_corner i < vector.nth core_point2_corner i + 1 ∧ vector.nth core_point2_corner i < vector.nth core_point1_corner i + 1,\n    { rw if_pos h1 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      simp only [int.cast_zero, add_zero, lt_add_iff_pos_left] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      linarith,\n    },\n    rw if_neg h1 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    by_cases h2 : vector.nth core_point1_corner i + 1 ≤ vector.nth core_point2_corner i,\n    { rw if_pos h2 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      simp only [int.cast_bit0, int.cast_one] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n      linarith,\n    },\n    rw if_neg h2 at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    simp only [int.cast_neg, int.cast_bit0, int.cast_one, le_add_neg_iff_add_le, add_neg_lt_iff_le_add'] at core_point1_add_double_z_in_core_point1_add_double_z_corner,\n    linarith,\n  },\n  rw [core_point1_eq_one, core_point2_eq_one] at core_point1_ne_core_point2,\n  exact core_point1_ne_core_point2 (by refl),\nend\n\ntheorem periodic_tiling_implies_clique {d : ℕ} {s : ℕ} (d_ne_zero : d ≠ 0) (s_ne_zero : s ≠ 0) :\n  (∃ (T : set (point d)) (T_is_tiling : is_tiling T), tiling_faceshare_free T ∧ is_periodic T_is_tiling ∧ is_s_discrete s T) →\n  has_clique (Keller_graph d s) (2 ^ d) :=\nbegin\n  rintro ⟨T, T_is_tiling, T_faceshare_free, T_is_periodic, T_is_s_discrete⟩,\n  rcases inductive_replacement_lemma d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete with\n    ⟨T_shifted, T_shifted_is_tiling, T_shifted_faceshare_free, T_shifted_is_periodic, T_shifted_contains_only_s_points⟩,\n  have core_points_finset := build_core_points_finset ⟨d, lt_add_one d⟩,\n  rcases core_points_finset with ⟨core_points_finset, core_points_finset_card, core_points_finset_property⟩,\n  have goal_clique_with_info_map :\n    {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)} ↪\n    {v : vector (fin (2*s)) d // ∃ p : point d, is_core_point p ∧ ∃ p_corner ∈ T_shifted, \n      p ∈ cube p_corner ∧ (∀ alt_corner : point d, alt_corner ∈ T_shifted → p ∈ cube alt_corner → alt_corner = p_corner) ∧\n      (∀ i : fin d, ↑s * (vector.nth p_corner i) + ↑s - 1 = (vector.nth v i).val)} :=\n    begin\n      let goal_clique_with_info_map_fn :\n        {p : point d // ∀ (j : fin d), (j.val < d → vector.nth p j = 0 ∨ vector.nth p j = 1) ∧ (j.val ≥ d → vector.nth p j = 0)} →\n        {v : vector (fin (2*s)) d // ∃ p : point d, is_core_point p ∧ ∃ p_corner ∈ T_shifted, \n          p ∈ cube p_corner ∧ (∀ alt_corner : point d, alt_corner ∈ T_shifted → p ∈ cube alt_corner → alt_corner = p_corner) ∧\n          (∀ i : fin d, ↑s * (vector.nth p_corner i) + ↑s - 1 = (vector.nth v i).val)} :=\n        build_goal_clique_with_info_map_fn d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n          T_shifted_is_tiling T_shifted_faceshare_free T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n          core_points_finset_property,\n      have goal_clique_with_info_map_fn_injective : function.injective goal_clique_with_info_map_fn :=\n        begin\n          rw function.injective,\n          intros p1 p2 mapped_p1_eq_mapped_p2,\n          dsimp[goal_clique_with_info_map_fn] at mapped_p1_eq_mapped_p2,\n          rw build_goal_clique_with_info_map_fn at mapped_p1_eq_mapped_p2,\n          simp only [subtype.val_eq_coe] at mapped_p1_eq_mapped_p2,\n          let mapped_p1_statement :=\n            goal_clique_with_info_map_fn_yields_fin_double_s_vector d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n              T_shifted_is_tiling T_shifted_faceshare_free T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n              core_points_finset_property p1,\n          let mapped_p2_statement :=\n            goal_clique_with_info_map_fn_yields_fin_double_s_vector d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n              T_shifted_is_tiling T_shifted_faceshare_free T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n              core_points_finset_property p2,\n          change classical.some mapped_p1_statement = classical.some mapped_p2_statement at mapped_p1_eq_mapped_p2,\n          let mapped_p1 := classical.some mapped_p1_statement,\n          have mapped_p1_def : mapped_p1 = classical.some mapped_p1_statement := by refl,\n          have mapped_p1_property := classical.some_spec mapped_p1_statement,\n          rw ← mapped_p1_def at mapped_p1_property,\n          let mapped_p2 := classical.some mapped_p2_statement,\n          have mapped_p2_def : mapped_p2 = classical.some mapped_p2_statement := by refl,\n          have mapped_p2_property := classical.some_spec mapped_p2_statement,\n          rw ← mapped_p2_def at mapped_p2_property,\n          rw [← mapped_p1_def, ← mapped_p2_def] at mapped_p1_eq_mapped_p2,\n          let p1_corner := (point_to_corner T_shifted_is_tiling ↑p1).val,\n          have p1_corner_def : p1_corner = (point_to_corner T_shifted_is_tiling ↑p1).val := by refl,\n          have p1_corner_property := (point_to_corner T_shifted_is_tiling ↑p1).property,\n          rw ← p1_corner_def at p1_corner_property,\n          rcases p1_corner_property with ⟨p1_corner_in_T_shifted, p1_in_p1_corner, p1_corner_unique⟩,\n          let p2_corner := (point_to_corner T_shifted_is_tiling ↑p2).val,\n          have p2_corner_def : p2_corner = (point_to_corner T_shifted_is_tiling ↑p2).val := by refl,\n          have p2_corner_property := (point_to_corner T_shifted_is_tiling ↑p2).property,\n          rw ← p2_corner_def at p2_corner_property,\n          rcases p2_corner_property with ⟨p2_corner_in_T_shifted, p2_in_p2_corner, p2_corner_unique⟩,\n          have p1_corner_eq_p2_corner : p1_corner = p2_corner :=\n            begin\n              apply vector.ext,\n              intro i,\n              replace mapped_p1_property := mapped_p1_property i,\n              replace mapped_p2_property := mapped_p2_property i,\n              rw mapped_p1_eq_mapped_p2 at mapped_p1_property,\n              rw [mapped_p1_property, ← p1_corner_def, ← p2_corner_def] at mapped_p2_property,\n              simp only [add_left_inj, mul_eq_mul_left_iff, nat.cast_eq_zero, sub_left_inj, subtype.val_eq_coe] at mapped_p2_property,\n              cases mapped_p2_property with goal s_eq_zero, exact goal,\n              exfalso,\n              exact s_ne_zero s_eq_zero,\n            end,\n          apply subtype.ext,\n          apply vector.ext,\n          intro i,\n          by_contra p1_ne_p2_at_i,\n          rcases p1.property i with ⟨p1_is_core_point, unneeded1⟩,\n          rcases p2.property i with ⟨p2_is_core_point, unneeded2⟩,\n          clear unneeded1 unneeded2,\n          simp only [subtype.val_eq_coe] at p1_is_core_point p2_is_core_point,\n          replace p1_is_core_point := p1_is_core_point i.property,\n          replace p2_is_core_point := p2_is_core_point i.property,\n          rw cube at p1_in_p1_corner p2_in_p2_corner,\n          simp only [set.mem_set_of_eq] at p1_in_p1_corner p2_in_p2_corner,\n          rw in_cube at p1_in_p1_corner p2_in_p2_corner,\n          replace p1_in_p1_corner := p1_in_p1_corner i,\n          replace p2_in_p2_corner := p2_in_p2_corner i,\n          rw p1_corner_eq_p2_corner at p1_in_p1_corner,\n          cases p1_in_p1_corner with p1_corner_le_p1 p1_lt_p1_corner_add_one,\n          cases p2_in_p2_corner with p2_corner_le_p2 p2_lt_p2_corner_add_one,\n          cases p1_is_core_point with p1_eq_zero p1_eq_one,\n          { cases p2_is_core_point with p2_eq_zero p2_eq_one,\n            { rw [p1_eq_zero, p2_eq_zero] at p1_ne_p2_at_i,\n              exact p1_ne_p2_at_i (by refl),\n            },\n            rw p1_eq_zero at p1_corner_le_p1 p1_lt_p1_corner_add_one,\n            rw p2_eq_one at p2_corner_le_p2 p2_lt_p2_corner_add_one,\n            linarith,\n          },\n          cases p2_is_core_point with p2_eq_zero p2_eq_one,\n          { rw p1_eq_one at p1_corner_le_p1 p1_lt_p1_corner_add_one,\n            rw p2_eq_zero at p2_corner_le_p2 p2_lt_p2_corner_add_one,\n            linarith,\n          },\n          rw [p1_eq_one, p2_eq_one] at p1_ne_p2_at_i,\n          exact p1_ne_p2_at_i (by refl),\n        end,\n      exact {to_fun := goal_clique_with_info_map_fn, inj' := goal_clique_with_info_map_fn_injective},\n    end,\n  let goal_clique_with_info := finset.map goal_clique_with_info_map core_points_finset,\n  have goal_clique_with_info_card : goal_clique_with_info.card = core_points_finset.card := finset.card_map goal_clique_with_info_map,\n  rw core_points_finset_card at goal_clique_with_info_card,\n  simp only [] at goal_clique_with_info_card,\n  let remove_info_map :\n    {v : vector (fin (2*s)) d // ∃ p : point d, is_core_point p ∧ ∃ p_corner ∈ T_shifted, \n      p ∈ cube p_corner ∧ (∀ alt_corner : point d, alt_corner ∈ T_shifted → p ∈ cube alt_corner → alt_corner = p_corner) ∧\n      (∀ i : fin d, ↑s * (vector.nth p_corner i) + ↑s - 1 = (vector.nth v i).val)} ↪ vector (fin (2*s)) d :=\n    begin\n      let remove_info_map_fn :\n        {v : vector (fin (2*s)) d // ∃ p : point d, is_core_point p ∧ ∃ p_corner ∈ T_shifted, \n          p ∈ cube p_corner ∧ (∀ alt_corner : point d, alt_corner ∈ T_shifted → p ∈ cube alt_corner → alt_corner = p_corner) ∧\n          (∀ i : fin d, ↑s * (vector.nth p_corner i) + ↑s - 1 = (vector.nth v i).val)} → vector (fin (2*s)) d :=\n        λ v, v,\n      have remove_info_map_fn_injective : function.injective remove_info_map_fn :=\n        by {rw function.injective, dsimp[remove_info_map_fn], simp},\n      exact {to_fun := remove_info_map_fn, inj' := remove_info_map_fn_injective},\n    end,\n  let goal_clique := finset.map remove_info_map goal_clique_with_info,\n  have goal_clique_card : goal_clique.card = goal_clique_with_info.card := finset.card_map remove_info_map,\n  rw goal_clique_with_info_card at goal_clique_card,\n  use [goal_clique, goal_clique_card],\n  intros v1 v2 v1_in_goal_clique v2_in_goal_clique v1_ne_v2,\n  rw Keller_graph,\n  simp only [simple_graph.from_rel_adj, fin.val_eq_coe, exists_and_distrib_left, ne.def],\n  split, exact v1_ne_v2,\n  dsimp[goal_clique] at v1_in_goal_clique v2_in_goal_clique,\n  rw finset.mem_map at v1_in_goal_clique v2_in_goal_clique,\n  simp only [exists_prop, fin.val_eq_coe, finset.mem_map, ge_iff_le, subtype.exists] at v1_in_goal_clique v2_in_goal_clique,\n  rcases v1_in_goal_clique with \n    ⟨v1', ⟨core_point1, core_point1_is_core_point, ⟨core_point1_corner, core_point1_corner_in_T_shifted, \n    core_point1_in_core_point1_corner, core_point1_corner_unique, core_point1_corner_v1'_relationship⟩⟩, redundant, v1_def⟩,\n  clear redundant,\n  rcases v2_in_goal_clique with \n    ⟨v2', ⟨core_point2, core_point2_is_core_point, ⟨core_point2_corner, core_point2_corner_in_T_shifted, \n    core_point2_in_core_point2_corner, core_point2_corner_unique, core_point2_corner_v2'_relationship⟩⟩, redundant, v2_def⟩,\n  clear redundant,\n  dsimp[remove_info_map] at v1_def v2_def,\n  rw v1_def at core_point1_corner_v1'_relationship,\n  rw v2_def at core_point2_corner_v2'_relationship,\n  by_contra v1_not_adj_v2,\n  rw not_or_distrib at v1_not_adj_v2,\n  simp only [not_exists, not_and, not_not] at v1_not_adj_v2,\n  by_cases v1_not_adj_v2_hyp : ∃ i : fin d, ↑(v1.nth i) = ↑(v2.nth i) + s ∨ ↑(v2.nth i) = ↑(v1.nth i) + s,\n  { replace T_shifted_faceshare_free := T_shifted_faceshare_free core_point1_corner core_point1_corner_in_T_shifted\n      core_point2_corner core_point2_corner_in_T_shifted,\n    rw is_facesharing at T_shifted_faceshare_free,\n    simp only [not_exists, not_and, not_forall] at T_shifted_faceshare_free,\n    rcases v1_not_adj_v2_hyp with ⟨i, v1_eq_v2_add_s | v2_eq_v1_add_s⟩,\n    { replace v1_not_adj_v2 := (and.elim_left v1_not_adj_v2) i v1_eq_v2_add_s,\n      have core_point_corners_off_by_one : vector.nth core_point1_corner i - vector.nth core_point2_corner i = 1 :=\n        begin\n          replace core_point1_corner_v1'_relationship := core_point1_corner_v1'_relationship i,\n          replace core_point2_corner_v2'_relationship := core_point2_corner_v2'_relationship i,\n          rw v1_eq_v2_add_s at core_point1_corner_v1'_relationship,\n          rw fin.coe_eq_val at core_point1_corner_v1'_relationship core_point2_corner_v2'_relationship,\n          replace core_point1_corner_v1'_relationship : \n            ↑s * vector.nth core_point1_corner i + ↑s - (1 : ℝ) = ↑((v2.nth i).val) + ↑s := \n            by exact_mod_cast core_point1_corner_v1'_relationship,\n          rw ← core_point2_corner_v2'_relationship at core_point1_corner_v1'_relationship,\n          clear_except core_point1_corner_v1'_relationship s_ne_zero,\n          rw add_comm (↑s * vector.nth core_point2_corner i + ↑s - 1) ↑s at core_point1_corner_v1'_relationship,\n          rw [sub_eq_add_neg, sub_eq_add_neg, add_assoc (↑s * vector.nth core_point2_corner i) ↑s (-1), ← add_assoc,\n            add_assoc (↑s * vector.nth core_point1_corner i) ↑s (-1)] at core_point1_corner_v1'_relationship,\n          simp only [add_left_inj] at core_point1_corner_v1'_relationship,\n          have s_times_goal : ↑s * vector.nth core_point1_corner i - ↑s * vector.nth core_point2_corner i = ↑s := by linarith,\n          rw ← mul_sub_left_distrib at s_times_goal,\n          have s_times_goal_div_s : ↑s * (vector.nth core_point1_corner i - vector.nth core_point2_corner i) / ↑s = ↑s / ↑s :=\n            by rw s_times_goal,\n          have cast_s_ne_zero : ↑s ≠ (0 : ℝ) := by exact_mod_cast s_ne_zero,\n          rw [mul_div_cancel_left (vector.nth core_point1_corner i - vector.nth core_point2_corner i) cast_s_ne_zero, \n            div_self cast_s_ne_zero] at s_times_goal_div_s,\n          exact s_times_goal_div_s,\n        end,\n      replace T_shifted_faceshare_free := T_shifted_faceshare_free i (or.inl core_point_corners_off_by_one),\n      rcases T_shifted_faceshare_free with ⟨j, i_ne_j_and_core_point1_eq_core_point2_at_j⟩,\n      rw not_or_distrib at i_ne_j_and_core_point1_eq_core_point2_at_j,\n      cases i_ne_j_and_core_point1_eq_core_point2_at_j with i_ne_j core_point1_corner_ne_core_point2_corner_at_j,\n      have v1_ne_v2_at_j : v1.nth j ≠ v2.nth j :=\n        begin\n          replace core_point1_corner_v1'_relationship := core_point1_corner_v1'_relationship j,\n          replace core_point2_corner_v2'_relationship := core_point2_corner_v2'_relationship j,\n          intro v1_eq_v2_at_j,\n          rcases real_eq_or_lt_or_gt (core_point1_corner.nth j) (core_point2_corner.nth j) with\n            core_point1_corner_eq_core_point2_corner | core_point1_corner_lt_core_point2_corner |\n            core_point1_corner_gt_core_point2_corner,\n          exact core_point1_corner_ne_core_point2_corner_at_j core_point1_corner_eq_core_point2_corner,\n          { rw [v1_eq_v2_at_j, ← core_point2_corner_v2'_relationship] at core_point1_corner_v1'_relationship,\n            simp only [add_left_inj, mul_eq_mul_left_iff, nat.cast_eq_zero, sub_left_inj] at core_point1_corner_v1'_relationship,\n            cases core_point1_corner_v1'_relationship with core_point1_corner_eq_core_point2_corner s_eq_zero,\n            { rw core_point1_corner_eq_core_point2_corner at core_point1_corner_lt_core_point2_corner,\n              exact lt_irrefl (vector.nth core_point2_corner j) core_point1_corner_lt_core_point2_corner,\n            },\n            exact s_ne_zero s_eq_zero,\n          },\n          rw [v1_eq_v2_at_j, ← core_point2_corner_v2'_relationship] at core_point1_corner_v1'_relationship,\n          simp only [add_left_inj, mul_eq_mul_left_iff, nat.cast_eq_zero, sub_left_inj] at core_point1_corner_v1'_relationship,\n          cases core_point1_corner_v1'_relationship with core_point1_corner_eq_core_point2_corner s_eq_zero,\n          { rw core_point1_corner_eq_core_point2_corner at core_point1_corner_gt_core_point2_corner,\n            exact gt_irrefl (vector.nth core_point2_corner j) core_point1_corner_gt_core_point2_corner,\n          },\n          exact s_ne_zero s_eq_zero,\n        end,\n      exact i_ne_j (v1_not_adj_v2 j v1_ne_v2_at_j),\n    }, --Next case is symmetrical to the above case\n    replace v1_not_adj_v2 := (and.elim_right v1_not_adj_v2) i v2_eq_v1_add_s,\n    have core_point_corners_off_by_one : vector.nth core_point2_corner i - vector.nth core_point1_corner i = 1 :=\n      begin\n        replace core_point1_corner_v1'_relationship := core_point1_corner_v1'_relationship i,\n        replace core_point2_corner_v2'_relationship := core_point2_corner_v2'_relationship i,\n        rw v2_eq_v1_add_s at core_point2_corner_v2'_relationship,\n        rw fin.coe_eq_val at core_point1_corner_v1'_relationship core_point2_corner_v2'_relationship,\n        replace core_point2_corner_v2'_relationship : \n          ↑s * vector.nth core_point2_corner i + ↑s - (1 : ℝ) = ↑((v1.nth i).val) + ↑s := \n          by exact_mod_cast core_point2_corner_v2'_relationship,\n        rw ← core_point1_corner_v1'_relationship at core_point2_corner_v2'_relationship,\n        clear_except core_point2_corner_v2'_relationship s_ne_zero,\n        rw add_comm (↑s * vector.nth core_point1_corner i + ↑s - 1) ↑s at core_point2_corner_v2'_relationship,\n        rw [sub_eq_add_neg, sub_eq_add_neg, add_assoc (↑s * vector.nth core_point1_corner i) ↑s (-1), ← add_assoc,\n          add_assoc (↑s * vector.nth core_point2_corner i) ↑s (-1)] at core_point2_corner_v2'_relationship,\n        simp only [add_left_inj] at core_point2_corner_v2'_relationship,\n        have s_times_goal : ↑s * vector.nth core_point2_corner i - ↑s * vector.nth core_point1_corner i = ↑s := by linarith,\n        rw ← mul_sub_left_distrib at s_times_goal,\n        have s_times_goal_div_s : ↑s * (vector.nth core_point2_corner i - vector.nth core_point1_corner i) / ↑s = ↑s / ↑s :=\n          by rw s_times_goal,\n        have cast_s_ne_zero : ↑s ≠ (0 : ℝ) := by exact_mod_cast s_ne_zero,\n        rw [mul_div_cancel_left (vector.nth core_point2_corner i - vector.nth core_point1_corner i) cast_s_ne_zero, \n          div_self cast_s_ne_zero] at s_times_goal_div_s,\n        exact s_times_goal_div_s,\n      end,\n    replace T_shifted_faceshare_free := T_shifted_faceshare_free i (or.inr core_point_corners_off_by_one),\n    rcases T_shifted_faceshare_free with ⟨j, i_ne_j_and_core_point1_eq_core_point2_at_j⟩,\n    rw not_or_distrib at i_ne_j_and_core_point1_eq_core_point2_at_j,\n    cases i_ne_j_and_core_point1_eq_core_point2_at_j with i_ne_j core_point1_corner_ne_core_point2_corner_at_j,\n    have v2_ne_v1_at_j : v2.nth j ≠ v1.nth j :=\n      begin\n        replace core_point1_corner_v1'_relationship := core_point1_corner_v1'_relationship j,\n        replace core_point2_corner_v2'_relationship := core_point2_corner_v2'_relationship j,\n        intro v2_eq_v1_at_j,\n        rcases real_eq_or_lt_or_gt (core_point1_corner.nth j) (core_point2_corner.nth j) with\n          core_point1_corner_eq_core_point2_corner | core_point1_corner_lt_core_point2_corner |\n          core_point1_corner_gt_core_point2_corner,\n        exact core_point1_corner_ne_core_point2_corner_at_j core_point1_corner_eq_core_point2_corner,\n        { rw [← v2_eq_v1_at_j, ← core_point2_corner_v2'_relationship] at core_point1_corner_v1'_relationship,\n          simp only [add_left_inj, mul_eq_mul_left_iff, nat.cast_eq_zero, sub_left_inj] at core_point1_corner_v1'_relationship,\n          cases core_point1_corner_v1'_relationship with core_point1_corner_eq_core_point2_corner s_eq_zero,\n          { rw core_point1_corner_eq_core_point2_corner at core_point1_corner_lt_core_point2_corner,\n            exact lt_irrefl (vector.nth core_point2_corner j) core_point1_corner_lt_core_point2_corner,\n          },\n          exact s_ne_zero s_eq_zero,\n        },\n        rw [← v2_eq_v1_at_j, ← core_point2_corner_v2'_relationship] at core_point1_corner_v1'_relationship,\n        simp only [add_left_inj, mul_eq_mul_left_iff, nat.cast_eq_zero, sub_left_inj] at core_point1_corner_v1'_relationship,\n        cases core_point1_corner_v1'_relationship with core_point1_corner_eq_core_point2_corner s_eq_zero,\n        { rw core_point1_corner_eq_core_point2_corner at core_point1_corner_gt_core_point2_corner,\n          exact gt_irrefl (vector.nth core_point2_corner j) core_point1_corner_gt_core_point2_corner,\n        },\n        exact s_ne_zero s_eq_zero,\n      end,\n    exact i_ne_j (v1_not_adj_v2 j v2_ne_v1_at_j),\n  },\n  rename v1_not_adj_v2_hyp v1_not_adj_v2_hyp_false,\n  clear' remove_info_map goal_clique goal_clique_card goal_clique_with_info_card,\n  exact periodic_tiling_implies_clique_helper d_ne_zero s_ne_zero T T_is_tiling T_faceshare_free T_is_periodic T_is_s_discrete T_shifted\n    T_shifted_is_tiling T_shifted_faceshare_free T_shifted_is_periodic T_shifted_contains_only_s_points core_points_finset core_points_finset_card\n    core_points_finset_property goal_clique_with_info_map v1 v2 v1_ne_v2 v1' core_point1 core_point1_is_core_point core_point1_corner\n    core_point1_corner_in_T_shifted core_point1_in_core_point1_corner core_point1_corner_unique v2' core_point2 core_point2_is_core_point\n    core_point2_corner core_point2_corner_in_T_shifted core_point2_in_core_point2_corner core_point2_corner_unique v2_def v1_def\n    core_point1_corner_v1'_relationship core_point2_corner_v2'_relationship v1_not_adj_v2 v1_not_adj_v2_hyp_false,\nend\n\nlemma clique_nonexistence_implies_Keller_conjecture {d : ℕ} (d_gt_zero : d > 0) :\n  ¬has_clique (Keller_graph d (2^(d-1))) (2^d) → Keller_conjecture d :=\nbegin\n  intro h,\n  apply periodic_reduction d d_gt_zero,\n  contrapose h,\n  rw not_not,\n  rw periodic_Keller_conjecture at h,\n  simp only [not_forall, not_not, exists_prop, exists_and_distrib_right] at h,\n  rcases h with ⟨T, ⟨T_is_tiling, T_is_periodic⟩, T_faceshare_free⟩,\n  have T_is_s_discrete := s_discrete_upper_bound d T T_is_tiling d_gt_zero T_is_periodic,\n  have d_ne_zero : d ≠ 0 := by linarith,\n  have two_to_the_d_sub_one_ne_zero : 2^(d - 1) ≠ 0 :=\n    begin\n      have two_to_the_d_sub_one_pos : 2^(d - 1) > 0 := by norm_num,\n      linarith,\n    end,\n  apply periodic_tiling_implies_clique d_ne_zero two_to_the_d_sub_one_ne_zero,\n  use [T, T_is_tiling, T_faceshare_free, T_is_periodic, T_is_s_discrete],\nend", "meta": {"author": "JOSHCLUNE", "repo": "Keller_reduction", "sha": "dc392b3da352fc1ffcfbecb1d4717d05f5faed4a", "save_path": "github-repos/lean/JOSHCLUNE-Keller_reduction", "path": "github-repos/lean/JOSHCLUNE-Keller_reduction/Keller_reduction-dc392b3da352fc1ffcfbecb1d4717d05f5faed4a/src/no_clique_implies_keller.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.727975460709318, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.4611071385942849}}
{"text": "/-\nCopyright (c) 2021 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn\n-/\nimport data.equiv.basic\nimport order.well_founded\nimport data.nat.basic\nimport data.opposite\n\n/-!\n# Quivers\n\nThis module defines quivers. A quiver on a type `V` of vertices assigns to every\npair `a b : V` of vertices a type `a ⟶ b` of arrows from `a` to `b`. This\nis a very permissive notion of directed graph.\n\n## Implementation notes\n\nCurrently `quiver` is defined with `arrow : V → V → Sort v`.\nThis is different from the category theory setup,\nwhere we insist that morphisms live in some `Type`.\nThere's some balance here: it's nice to allow `Prop` to ensure there are no multiple arrows,\nbut it is also results in error-prone universe signatures when constraints require a `Type`.\n-/\n\nopen opposite\n\n-- We use the same universe order as in category theory.\n-- See note [category_theory universes]\nuniverses v v₁ v₂ u u₁ u₂\n\n/--\nA quiver `G` on a type `V` of vertices assigns to every pair `a b : V` of vertices\na type `a ⟶ b` of arrows from `a` to `b`.\n\nFor graphs with no repeated edges, one can use `quiver.{0} V`, which ensures\n`a ⟶ b : Prop`. For multigraphs, one can use `quiver.{v+1} V`, which ensures\n`a ⟶ b : Type v`.\n\nBecause `category` will later extend this class, we call the field `hom`.\nExcept when constructing instances, you should rarely see this, and use the `⟶` notation instead.\n-/\nclass quiver (V : Type u) :=\n(hom : V → V → Sort v)\n\ninfixr ` ⟶ `:10 := quiver.hom -- type as \\h\n\n/--\nA morphism of quivers. As we will later have categorical functors extend this structure,\nwe call it a `prefunctor`.\n-/\nstructure prefunctor (V : Type u₁) [quiver.{v₁} V] (W : Type u₂) [quiver.{v₂} W] :=\n(obj [] : V → W)\n(map : Π {X Y : V}, (X ⟶ Y) → (obj X ⟶ obj Y))\n\nnamespace prefunctor\n\n/--\nThe identity morphism between quivers.\n-/\n@[simps]\ndef id (V : Type*) [quiver V] : prefunctor V V :=\n{ obj := id,\n  map := λ X Y f, f, }\n\ninstance (V : Type*) [quiver V] : inhabited (prefunctor V V) := ⟨id V⟩\n\n/--\nComposition of morphisms between quivers.\n-/\n@[simps]\ndef comp {U : Type*} [quiver U] {V : Type*} [quiver V] {W : Type*} [quiver W]\n  (F : prefunctor U V) (G : prefunctor V W) : prefunctor U W :=\n{ obj := λ X, G.obj (F.obj X),\n  map := λ X Y f, G.map (F.map f), }\n\nend prefunctor\n\n/-- A wide subquiver `H` of `G` picks out a set `H a b` of arrows from `a` to `b`\n    for every pair of vertices `a b`.\n\n    NB: this does not work for `Prop`-valued quivers. It requires `G : quiver.{v+1} V`. -/\ndef wide_subquiver (V) [quiver.{v+1} V] :=\nΠ a b : V, set (a ⟶ b)\n\n/-- A type synonym for `V`, when thought of as a quiver having only the arrows from\nsome `wide_subquiver`. -/\n@[nolint unused_arguments has_inhabited_instance]\ndef wide_subquiver.to_Type (V) [quiver V] (H : wide_subquiver V) : Type u := V\n\ninstance wide_subquiver_has_coe_to_sort {V} [quiver V] : has_coe_to_sort (wide_subquiver V) :=\n{ S := Type u,\n  coe := λ H, wide_subquiver.to_Type V H, }\n\n/-- A wide subquiver viewed as a quiver on its own. -/\ninstance wide_subquiver.quiver {V} [quiver V] (H : wide_subquiver V) : quiver H :=\n⟨λ a b, H a b⟩\n\nnamespace quiver\n\n/-- A type synonym for a quiver with no arrows. -/\n@[nolint has_inhabited_instance]\ndef empty (V) : Type u := V\n\ninstance empty_quiver (V : Type u) : quiver.{u} (empty V) := ⟨λ a b, pempty⟩\n\n@[simp] lemma empty_arrow {V : Type u} (a b : empty V) : (a ⟶ b) = pempty := rfl\n\ninstance {V} [quiver V] : has_bot (wide_subquiver V) := ⟨λ a b, ∅⟩\ninstance {V} [quiver V] : has_top (wide_subquiver V) := ⟨λ a b, set.univ⟩\ninstance {V} [quiver V] : inhabited (wide_subquiver V) := ⟨⊤⟩\n\n/-- `Vᵒᵖ` reverses the direction of all arrows of `V`. -/\ninstance opposite {V} [quiver V] : quiver Vᵒᵖ :=\n⟨λ a b, (unop b) ⟶ (unop a)⟩\n\n/--\nThe opposite of an arrow in `V`.\n-/\ndef hom.op {V} [quiver V] {X Y : V} (f : X ⟶ Y) : op Y ⟶ op X := f\n/--\nGiven an arrow in `Vᵒᵖ`, we can take the \"unopposite\" back in `V`.\n-/\ndef hom.unop {V} [quiver V] {X Y : Vᵒᵖ} (f : X ⟶ Y) : unop Y ⟶ unop X := f\n\nattribute [irreducible] quiver.opposite\n\n/-- A type synonym for the symmetrized quiver (with an arrow both ways for each original arrow).\n    NB: this does not work for `Prop`-valued quivers. It requires `[quiver.{v+1} V]`. -/\n@[nolint has_inhabited_instance]\ndef symmetrify (V) : Type u := V\n\ninstance symmetrify_quiver (V : Type u) [quiver V] : quiver (symmetrify V) :=\n⟨λ a b : V, (a ⟶ b) ⊕ (b ⟶ a)⟩\n\n/-- `total V` is the type of _all_ arrows of `V`. -/\n-- TODO Unify with `category_theory.arrow`? (The fields have been named to match.)\n@[ext, nolint has_inhabited_instance]\nstructure total (V : Type u) [quiver.{v} V] : Sort (max (u+1) v) :=\n(left : V)\n(right : V)\n(hom : left ⟶ right)\n\n/-- A wide subquiver `H` of `G.symmetrify` determines a wide subquiver of `G`, containing an\n    an arrow `e` if either `e` or its reversal is in `H`. -/\n-- Without the explicit universe level in `quiver.{v+1}` Lean comes up with\n-- `quiver.{max u_2 u_3 + 1}`. This causes problems elsewhere, so we write `quiver.{v+1}`.\ndef wide_subquiver_symmetrify {V} [quiver.{v+1} V] :\n  wide_subquiver (symmetrify V) → wide_subquiver V :=\nλ H a b, { e | sum.inl e ∈ H a b ∨ sum.inr e ∈ H b a }\n\n/-- A wide subquiver of `G` can equivalently be viewed as a total set of arrows. -/\ndef wide_subquiver_equiv_set_total {V} [quiver V] :\n  wide_subquiver V ≃ set (total V) :=\n{ to_fun := λ H, { e | e.hom ∈ H e.left e.right },\n  inv_fun := λ S a b, { e | total.mk a b e ∈ S },\n  left_inv := λ H, rfl,\n  right_inv := by { intro S, ext, cases x, refl } }\n\n/-- `G.path a b` is the type of paths from `a` to `b` through the arrows of `G`. -/\ninductive path {V : Type u} [quiver.{v} V] (a : V) : V → Sort (max (u+1) v)\n| nil  : path a\n| cons : Π {b c : V}, path b → (b ⟶ c) → path c\n\n/-- An arrow viewed as a path of length one. -/\ndef hom.to_path {V} [quiver V] {a b : V} (e : a ⟶ b) : path a b :=\npath.nil.cons e\n\nnamespace path\n\nvariables {V : Type u} [quiver V]\n\n/-- The length of a path is the number of arrows it uses. -/\ndef length {a : V} : Π {b : V}, path a b → ℕ\n| _ path.nil        := 0\n| _ (path.cons p _) := p.length + 1\n\n@[simp] lemma length_nil {a : V} :\n  (path.nil : path a a).length = 0 := rfl\n\n@[simp] lemma length_cons (a b c : V) (p : path a b)\n  (e : b ⟶ c) : (p.cons e).length = p.length + 1 := rfl\n\n/-- Composition of paths. -/\ndef comp {a b : V} : Π {c}, path a b → path b c → path a c\n| _ p (path.nil) := p\n| _ p (path.cons q e) := (p.comp q).cons e\n\n@[simp] lemma comp_cons {a b c d : V} (p : path a b) (q : path b c) (e : c ⟶ d) :\n  p.comp (q.cons e) = (p.comp q).cons e := rfl\n@[simp] lemma comp_nil {a b : V} (p : path a b) : p.comp path.nil = p := rfl\n@[simp] lemma nil_comp {a : V} : ∀ {b} (p : path a b), path.nil.comp p = p\n| a path.nil := rfl\n| b (path.cons p e) := by rw [comp_cons, nil_comp]\n@[simp] lemma comp_assoc {a b c : V} : ∀ {d}\n  (p : path a b) (q : path b c) (r : path c d),\n    (p.comp q).comp r = p.comp (q.comp r)\n| c p q path.nil := rfl\n| d p q (path.cons r e) := by rw [comp_cons, comp_cons, comp_cons, comp_assoc]\n\nend path\n\nend quiver\n\nnamespace prefunctor\n\nopen quiver\n\nvariables {V : Type u₁} [quiver.{v₁} V] {W : Type u₂} [quiver.{v₂} W] (F : prefunctor V W)\n\n/-- The image of a path under a prefunctor. -/\ndef map_path {a : V} :\n  Π {b : V}, path a b → path (F.obj a) (F.obj b)\n| _ path.nil := path.nil\n| _ (path.cons p e) := path.cons (map_path p) (F.map e)\n\n@[simp] lemma map_path_nil (a : V) : F.map_path (path.nil : path a a) = path.nil := rfl\n@[simp] lemma map_path_cons {a b c : V} (p : path a b) (e : b ⟶ c) :\n  F.map_path (path.cons p e) = path.cons (F.map_path p) (F.map e) := rfl\n\n@[simp] lemma map_path_comp {a b : V} (p : path a b) :\n  ∀ {c : V} (q : path b c), F.map_path (p.comp q) = (F.map_path p).comp (F.map_path q)\n| _ path.nil := rfl\n| _ (path.cons p e) := begin dsimp, rw [map_path_comp], end\n\nend prefunctor\n\nnamespace quiver\n\n/-- A quiver is an arborescence when there is a unique path from the default vertex\n    to every other vertex. -/\nclass arborescence (V : Type u) [quiver.{v} V] : Type (max u v) :=\n(root : V)\n(unique_path : Π (b : V), unique (path root b))\n\n/-- The root of an arborescence. -/\ndef root (V : Type u) [quiver V] [arborescence V] : V :=\narborescence.root\n\ninstance {V : Type u} [quiver V] [arborescence V] (b : V) : unique (path (root V) b) :=\narborescence.unique_path b\n\n/-- An `L`-labelling of a quiver assigns to every arrow an element of `L`. -/\ndef labelling (V : Type u) [quiver V] (L : Sort*) := Π ⦃a b : V⦄, (a ⟶ b) → L\n\ninstance {V : Type u} [quiver V] (L) [inhabited L] : inhabited (labelling V L) :=\n⟨λ a b e, default L⟩\n\n/-- To show that `[quiver V]` is an arborescence with root `r : V`, it suffices to\n  - provide a height function `V → ℕ` such that every arrow goes from a\n    lower vertex to a higher vertex,\n  - show that every vertex has at most one arrow to it, and\n  - show that every vertex other than `r` has an arrow to it. -/\nnoncomputable def arborescence_mk {V : Type u} [quiver V] (r : V)\n  (height : V → ℕ)\n  (height_lt : ∀ ⦃a b⦄, (a ⟶ b) → height a < height b)\n  (unique_arrow : ∀ ⦃a b c : V⦄ (e : a ⟶ c) (f : b ⟶ c), a = b ∧ e == f)\n  (root_or_arrow : ∀ b, b = r ∨ ∃ a, nonempty (a ⟶ b)) : arborescence V :=\n{ root := r,\n  unique_path := λ b, ⟨classical.inhabited_of_nonempty\n    begin\n      rcases (show ∃ n, height b < n, from ⟨_, lt_add_one _⟩) with ⟨n, hn⟩,\n      induction n with n ih generalizing b,\n      { exact false.elim (nat.not_lt_zero _ hn) },\n      rcases root_or_arrow b with ⟨⟨⟩⟩ | ⟨a, ⟨e⟩⟩,\n      { exact ⟨path.nil⟩ },\n      { rcases ih a (lt_of_lt_of_le (height_lt e) (nat.lt_succ_iff.mp hn)) with ⟨p⟩,\n        exact ⟨p.cons e⟩ }\n    end,\n    begin\n      have height_le : ∀ {a b}, path a b → height a ≤ height b,\n      { intros a b p, induction p with b c p e ih, refl,\n        exact le_of_lt (lt_of_le_of_lt ih (height_lt e)) },\n      suffices : ∀ p q : path r b, p = q,\n      { intro p, apply this },\n      intros p q, induction p with a c p e ih; cases q with b _ q f,\n      { refl },\n      { exact false.elim (lt_irrefl _ (lt_of_le_of_lt (height_le q) (height_lt f))) },\n      { exact false.elim (lt_irrefl _ (lt_of_le_of_lt (height_le p) (height_lt e))) },\n      { rcases unique_arrow e f with ⟨⟨⟩, ⟨⟩⟩, rw ih },\n    end ⟩ }\n\n/-- `rooted_connected r` means that there is a path from `r` to any other vertex. -/\nclass rooted_connected {V : Type u} [quiver V] (r : V) : Prop :=\n(nonempty_path : ∀ b : V, nonempty (path r b))\n\nattribute [instance] rooted_connected.nonempty_path\n\nsection geodesic_subtree\n\nvariables {V : Type u} [quiver.{v+1} V] (r : V) [rooted_connected r]\n\n/-- A path from `r` of minimal length. -/\nnoncomputable def shortest_path (b : V) : path r b :=\nwell_founded.min (measure_wf path.length) set.univ set.univ_nonempty\n\n/-- The length of a path is at least the length of the shortest path -/\nlemma shortest_path_spec {a : V} (p : path r a) :\n  (shortest_path r a).length ≤ p.length :=\nnot_lt.mp (well_founded.not_lt_min (measure_wf _) set.univ _ trivial)\n\n/-- A subquiver which by construction is an arborescence. -/\ndef geodesic_subtree : wide_subquiver V :=\nλ a b, { e | ∃ p : path r a, shortest_path r b = p.cons e }\n\nnoncomputable instance geodesic_arborescence : arborescence (geodesic_subtree r) :=\narborescence_mk r (λ a, (shortest_path r a).length)\n(by { rintros a b ⟨e, p, h⟩,\n  rw [h, path.length_cons, nat.lt_succ_iff], apply shortest_path_spec })\n(by { rintros a b c ⟨e, p, h⟩ ⟨f, q, j⟩, cases h.symm.trans j, split; refl })\n(by { intro b, have : ∃ p, shortest_path r b = p := ⟨_, rfl⟩,\n  rcases this with ⟨p, hp⟩, cases p with a _ p e,\n  { exact or.inl rfl }, { exact or.inr ⟨a, ⟨⟨e, p, hp⟩⟩⟩ } })\n\nend geodesic_subtree\n\nvariables (V : Type u) [quiver.{v+1} V]\n\n/-- A quiver `has_reverse` if we can reverse an arrow `p` from `a` to `b` to get an arrow\n    `p.reverse` from `b` to `a`.-/\nclass has_reverse :=\n(reverse' : Π {a b : V}, (a ⟶ b) → (b ⟶ a))\n\ninstance : has_reverse (symmetrify V) := ⟨λ a b e, e.swap⟩\n\nvariables {V} [has_reverse V]\n\n/-- Reverse the direction of an arrow. -/\ndef reverse {a b : V} : (a ⟶ b) → (b ⟶ a) := has_reverse.reverse'\n\n/-- Reverse the direction of a path. -/\ndef path.reverse {a : V} : Π {b}, path a b → path b a\n| a path.nil := path.nil\n| b (path.cons p e) := (reverse e).to_path.comp p.reverse\n\nvariables (V)\n\n/-- Two vertices are related in the zigzag setoid if there is a\n    zigzag of arrows from one to the other. -/\ndef zigzag_setoid : setoid V :=\n⟨λ a b, nonempty (path (a : symmetrify V) (b : symmetrify V)),\n λ a, ⟨path.nil⟩,\n λ a b ⟨p⟩, ⟨p.reverse⟩,\n λ a b c ⟨p⟩ ⟨q⟩, ⟨p.comp q⟩⟩\n\n/-- The type of weakly connected components of a directed graph. Two vertices are\n    in the same weakly connected component if there is a zigzag of arrows from one\n    to the other. -/\ndef weakly_connected_component : Type* := quotient (zigzag_setoid V)\n\nnamespace weakly_connected_component\nvariable {V}\n\n/-- The weakly connected component corresponding to a vertex. -/\nprotected def mk : V → weakly_connected_component V := quotient.mk'\n\ninstance : has_coe_t V (weakly_connected_component V) := ⟨weakly_connected_component.mk⟩\ninstance [inhabited V] : inhabited (weakly_connected_component V) := ⟨↑(default V)⟩\n\nprotected lemma eq (a b : V) :\n  (a : weakly_connected_component V) = b ↔ nonempty (path (a : symmetrify V) (b : symmetrify V)) :=\nquotient.eq'\n\nend weakly_connected_component\n\nend quiver\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/combinatorics/quiver.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6334102775181399, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.4611071236415703}}
{"text": "/-\nCopyright (c) 2020 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor:  Aaron Anderson, Jalex Stark.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.matrix\nimport Mathlib.data.rel\nimport Mathlib.combinatorics.simple_graph.basic\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# Adjacency Matrices\n\nThis module defines the adjacency matrix of a graph, and provides theorems connecting graph\nproperties to computational properties of the matrix.\n\n## Main definitions\n\n* `adj_matrix` is the adjacency matrix of a `simple_graph` with coefficients in a given semiring.\n\n-/\n\nnamespace simple_graph\n\n\n/-- `adj_matrix G R` is the matrix `A` such that `A i j = (1 : R)` if `i` and `j` are\n  adjacent in the simple graph `G`, and otherwise `A i j = 0`. -/\ndef adj_matrix {α : Type u} [fintype α] (R : Type v) [semiring R] (G : simple_graph α) [DecidableRel (adj G)] : matrix α α R :=\n  sorry\n\n@[simp] theorem adj_matrix_apply {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (v : α) (w : α) : adj_matrix R G v w = ite (adj G v w) 1 0 :=\n  rfl\n\n@[simp] theorem transpose_adj_matrix {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] : matrix.transpose (adj_matrix R G) = adj_matrix R G := sorry\n\n@[simp] theorem adj_matrix_dot_product {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (v : α) (vec : α → R) : matrix.dot_product (adj_matrix R G v) vec = finset.sum (neighbor_finset G v) fun (u : α) => vec u := sorry\n\n@[simp] theorem dot_product_adj_matrix {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (v : α) (vec : α → R) : matrix.dot_product vec (adj_matrix R G v) = finset.sum (neighbor_finset G v) fun (u : α) => vec u := sorry\n\n@[simp] theorem adj_matrix_mul_vec_apply {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (v : α) (vec : α → R) : matrix.mul_vec (adj_matrix R G) vec v = finset.sum (neighbor_finset G v) fun (u : α) => vec u := sorry\n\n@[simp] theorem adj_matrix_vec_mul_apply {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (v : α) (vec : α → R) : matrix.vec_mul vec (adj_matrix R G) v = finset.sum (neighbor_finset G v) fun (u : α) => vec u := sorry\n\n@[simp] theorem adj_matrix_mul_apply {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (M : matrix α α R) (v : α) (w : α) : matrix.mul (adj_matrix R G) M v w = finset.sum (neighbor_finset G v) fun (u : α) => M u w := sorry\n\n@[simp] theorem mul_adj_matrix_apply {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (M : matrix α α R) (v : α) (w : α) : matrix.mul M (adj_matrix R G) v w = finset.sum (neighbor_finset G w) fun (u : α) => M v u := sorry\n\ntheorem trace_adj_matrix {α : Type u} [fintype α] (R : Type v) [semiring R] (G : simple_graph α) [DecidableRel (adj G)] : coe_fn (matrix.trace α R R) (adj_matrix R G) = 0 := sorry\n\ntheorem adj_matrix_mul_self_apply_self {α : Type u} [fintype α] {R : Type v} [semiring R] (G : simple_graph α) [DecidableRel (adj G)] (i : α) : matrix.mul (adj_matrix R G) (adj_matrix R G) i i = ↑(degree G i) := sorry\n\n@[simp] theorem adj_matrix_mul_vec_const_apply {α : Type u} [fintype α] {R : Type v} [semiring R] {G : simple_graph α} [DecidableRel (adj G)] {r : R} {v : α} : matrix.mul_vec (adj_matrix R G) (function.const α r) v = ↑(degree G v) * r := sorry\n\ntheorem adj_matrix_mul_vec_const_apply_of_regular {α : Type u} [fintype α] {R : Type v} [semiring R] {G : simple_graph α} [DecidableRel (adj G)] {d : ℕ} {r : R} (hd : is_regular_of_degree G d) {v : α} : matrix.mul_vec (adj_matrix R G) (function.const α r) v = ↑d * r := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/combinatorics/simple_graph/adj_matrix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.46110711600482995}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n\n! This file was ported from Lean 3 source module combinatorics.simple_graph.regularity.bound\n! leanprover-community/mathlib commit 7a0dd7b2466948ac029d671c2701df3b1f134b3c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.Chebyshev\nimport Mathbin.Analysis.SpecialFunctions.Pow\nimport Mathbin.Order.Partition.Equipartition\n\n/-!\n# Numerical bounds for Szemerédi Regularity Lemma\n\nThis file gathers the numerical facts required by the proof of Szemerédi's regularity lemma.\n\nThis entire file is internal to the proof of Szemerédi Regularity Lemma.\n\n## Main declarations\n\n* `szemeredi_regularity.step_bound`: During the inductive step, a partition of size `n` is blown to\n  size at most `step_bound n`.\n* `szemeredi_regularity.initial_bound`: The size of the partition we start the induction with.\n* `szemeredi_regularity.bound`: The upper bound on the size of the partition produced by our version\n  of Szemerédi's regularity lemma.\n-/\n\n\nopen Finset Fintype Function Real\n\nopen BigOperators\n\nnamespace SzemerediRegularity\n\n/-- Auxiliary function for Szemerédi's regularity lemma. Blowing up a partition of size `n` during\nthe induction results in a partition of size at most `step_bound n`. -/\ndef stepBound (n : ℕ) : ℕ :=\n  n * 4 ^ n\n#align szemeredi_regularity.step_bound SzemerediRegularity.stepBound\n\ntheorem le_stepBound : id ≤ stepBound := fun n => Nat.le_mul_of_pos_right <| pow_pos (by norm_num) n\n#align szemeredi_regularity.le_step_bound SzemerediRegularity.le_stepBound\n\ntheorem stepBound_mono : Monotone stepBound := fun a b h =>\n  Nat.mul_le_mul h <| Nat.pow_le_pow_of_le_right (by norm_num) h\n#align szemeredi_regularity.step_bound_mono SzemerediRegularity.stepBound_mono\n\ntheorem stepBound_pos_iff {n : ℕ} : 0 < stepBound n ↔ 0 < n :=\n  zero_lt_mul_right <| by positivity\n#align szemeredi_regularity.step_bound_pos_iff SzemerediRegularity.stepBound_pos_iff\n\nalias step_bound_pos_iff ↔ _ step_bound_pos\n#align szemeredi_regularity.step_bound_pos SzemerediRegularity.stepBound_pos\n\nend SzemerediRegularity\n\nopen SzemerediRegularity\n\nvariable {α : Type _} [DecidableEq α] [Fintype α] {P : Finpartition (univ : Finset α)}\n  {u : Finset α} {ε : ℝ}\n\n-- mathport name: exprm\nlocal notation \"m\" => (card α / stepBound P.parts.card : ℕ)\n\n-- mathport name: expra\nlocal notation \"a\" => (card α / P.parts.card - m * 4 ^ P.parts.card : ℕ)\n\nnamespace Tactic\n\nopen Positivity\n\nprivate theorem eps_pos {ε : ℝ} {n : ℕ} (h : 100 ≤ 4 ^ n * ε ^ 5) : 0 < ε :=\n  pow_bit1_pos_iff.1 <| pos_of_mul_pos_right (h.trans_lt' <| by norm_num) <| by positivity\n#align tactic.eps_pos tactic.eps_pos\n\nprivate theorem m_pos [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) : 0 < m :=\n  Nat.div_pos ((Nat.mul_le_mul_left _ <| Nat.pow_le_pow_of_le_left (by norm_num) _).trans hPα) <|\n    stepBound_pos (P.parts_nonempty <| univ_nonempty.ne_empty).card_pos\n#align tactic.m_pos tactic.m_pos\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/--\n      Local extension for the `positivity` tactic: A few facts that are needed many times for the\n      proof of Szemerédi's regularity lemma. -/\n    unsafe\n  def\n    positivity_szemeredi_regularity\n    : expr → tactic strictness\n    |\n        q( $ ( n ) / stepBound ( Finpartition.parts $ ( P ) ) . card )\n        =>\n        do\n          let\n              p\n                ←\n                to_expr\n                    `\n                      `(\n                        ( Finpartition.parts $ ( P ) ) . card\n                            *\n                            16 ^ ( Finpartition.parts $ ( P ) ) . card\n                          ≤\n                          $ ( n )\n                        )\n                  >>=\n                  find_assumption\n            positive <$> mk_app ` ` m_pos [ p ]\n      |\n        ε\n        =>\n        do\n          let typ ← infer_type ε\n            unify typ q( ℝ )\n            let p ← to_expr ` `( 100 ≤ 4 ^ _ * $ ( ε ) ^ 5 ) >>= find_assumption\n            positive <$> mk_app ` ` eps_pos [ p ]\n#align tactic.positivity_szemeredi_regularity tactic.positivity_szemeredi_regularity\n\nend Tactic\n\nattribute [local positivity] tactic.positivity_szemeredi_regularity\n\nnamespace SzemerediRegularity\n\ntheorem m_pos [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) : 0 < m := by\n  positivity\n#align szemeredi_regularity.m_pos SzemerediRegularity.m_pos\n\ntheorem coe_m_add_one_pos : 0 < (m : ℝ) + 1 := by positivity\n#align szemeredi_regularity.coe_m_add_one_pos SzemerediRegularity.coe_m_add_one_pos\n\ntheorem one_le_m_coe [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) : (1 : ℝ) ≤ m :=\n  Nat.one_le_cast.2 <| m_pos hPα\n#align szemeredi_regularity.one_le_m_coe SzemerediRegularity.one_le_m_coe\n\ntheorem eps_pow_five_pos (hPε : 100 ≤ 4 ^ P.parts.card * ε ^ 5) : 0 < ε ^ 5 :=\n  pos_of_mul_pos_right ((by norm_num : (0 : ℝ) < 100).trans_le hPε) <| pow_nonneg (by norm_num) _\n#align szemeredi_regularity.eps_pow_five_pos SzemerediRegularity.eps_pow_five_pos\n\ntheorem eps_pos (hPε : 100 ≤ 4 ^ P.parts.card * ε ^ 5) : 0 < ε :=\n  pow_bit1_pos_iff.1 <| eps_pow_five_pos hPε\n#align szemeredi_regularity.eps_pos SzemerediRegularity.eps_pos\n\ntheorem hundred_div_ε_pow_five_le_m [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α)\n    (hPε : 100 ≤ 4 ^ P.parts.card * ε ^ 5) : 100 / ε ^ 5 ≤ m :=\n  (div_le_of_nonneg_of_le_mul (eps_pow_five_pos hPε).le (by positivity) hPε).trans\n    (by\n      norm_cast\n      rwa [Nat.le_div_iff_mul_le'\n          (step_bound_pos (P.parts_nonempty <| univ_nonempty.ne_empty).card_pos),\n        step_bound, mul_left_comm, ← mul_pow])\n#align szemeredi_regularity.hundred_div_ε_pow_five_le_m SzemerediRegularity.hundred_div_ε_pow_five_le_m\n\ntheorem hundred_le_m [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α)\n    (hPε : 100 ≤ 4 ^ P.parts.card * ε ^ 5) (hε : ε ≤ 1) : 100 ≤ m := by\n  exact_mod_cast\n    (hundred_div_ε_pow_five_le_m hPα hPε).trans'\n      (le_div_self (by norm_num) (by positivity) <| pow_le_one _ (by positivity) hε)\n#align szemeredi_regularity.hundred_le_m SzemerediRegularity.hundred_le_m\n\ntheorem a_add_one_le_four_pow_parts_card : a + 1 ≤ 4 ^ P.parts.card :=\n  by\n  have h : 1 ≤ 4 ^ P.parts.card := one_le_pow_of_one_le (by norm_num) _\n  rw [step_bound, ← Nat.div_div_eq_div_mul, ← Nat.le_sub_iff_right h, tsub_le_iff_left, ←\n    Nat.add_sub_assoc h]\n  exact Nat.le_pred_of_lt (Nat.lt_div_mul_add h)\n#align szemeredi_regularity.a_add_one_le_four_pow_parts_card SzemerediRegularity.a_add_one_le_four_pow_parts_card\n\ntheorem card_aux₁ (hucard : u.card = m * 4 ^ P.parts.card + a) :\n    (4 ^ P.parts.card - a) * m + a * (m + 1) = u.card := by\n  rw [hucard, mul_add, mul_one, ← add_assoc, ← add_mul,\n    Nat.sub_add_cancel ((Nat.le_succ _).trans a_add_one_le_four_pow_parts_card), mul_comm]\n#align szemeredi_regularity.card_aux₁ SzemerediRegularity.card_aux₁\n\ntheorem card_aux₂ (hP : P.IsEquipartition) (hu : u ∈ P.parts)\n    (hucard : ¬u.card = m * 4 ^ P.parts.card + a) :\n    (4 ^ P.parts.card - (a + 1)) * m + (a + 1) * (m + 1) = u.card :=\n  by\n  have : m * 4 ^ P.parts.card ≤ card α / P.parts.card :=\n    by\n    rw [step_bound, ← Nat.div_div_eq_div_mul]\n    exact Nat.div_mul_le_self _ _\n  rw [Nat.add_sub_of_le this] at hucard\n  rw [(hP.card_parts_eq_average hu).resolve_left hucard, mul_add, mul_one, ← add_assoc, ← add_mul,\n    Nat.sub_add_cancel a_add_one_le_four_pow_parts_card, ← add_assoc, mul_comm,\n    Nat.add_sub_of_le this, card_univ]\n#align szemeredi_regularity.card_aux₂ SzemerediRegularity.card_aux₂\n\ntheorem pow_mul_m_le_card_part (hP : P.IsEquipartition) (hu : u ∈ P.parts) :\n    (4 : ℝ) ^ P.parts.card * m ≤ u.card := by\n  norm_cast\n  rw [step_bound, ← Nat.div_div_eq_div_mul]\n  exact (Nat.mul_div_le _ _).trans (hP.average_le_card_part hu)\n#align szemeredi_regularity.pow_mul_m_le_card_part SzemerediRegularity.pow_mul_m_le_card_part\n\nvariable (P ε) (l : ℕ)\n\n/-- Auxiliary function for Szemerédi's regularity lemma. The size of the partition by which we start\nblowing. -/\nnoncomputable def initialBound : ℕ :=\n  max 7 <| max l <| ⌊log (100 / ε ^ 5) / log 4⌋₊ + 1\n#align szemeredi_regularity.initial_bound SzemerediRegularity.initialBound\n\ntheorem le_initialBound : l ≤ initialBound ε l :=\n  (le_max_left _ _).trans <| le_max_right _ _\n#align szemeredi_regularity.le_initial_bound SzemerediRegularity.le_initialBound\n\ntheorem seven_le_initialBound : 7 ≤ initialBound ε l :=\n  le_max_left _ _\n#align szemeredi_regularity.seven_le_initial_bound SzemerediRegularity.seven_le_initialBound\n\ntheorem initialBound_pos : 0 < initialBound ε l :=\n  Nat.succ_pos'.trans_le <| seven_le_initialBound _ _\n#align szemeredi_regularity.initial_bound_pos SzemerediRegularity.initialBound_pos\n\ntheorem hundred_lt_pow_initialBound_mul {ε : ℝ} (hε : 0 < ε) (l : ℕ) :\n    100 < 4 ^ initialBound ε l * ε ^ 5 :=\n  by\n  rw [← rpow_nat_cast 4, ← div_lt_iff (pow_pos hε 5), lt_rpow_iff_log_lt _ zero_lt_four, ←\n    div_lt_iff, initial_bound, Nat.cast_max, Nat.cast_max]\n  · push_cast\n    exact lt_max_of_lt_right (lt_max_of_lt_right <| Nat.lt_floor_add_one _)\n  · exact log_pos (by norm_num)\n  · exact div_pos (by norm_num) (pow_pos hε 5)\n#align szemeredi_regularity.hundred_lt_pow_initial_bound_mul SzemerediRegularity.hundred_lt_pow_initialBound_mul\n\n/-- An explicit bound on the size of the equipartition whose existence is given by Szemerédi's\nregularity lemma. -/\nnoncomputable def bound : ℕ :=\n  (stepBound^[⌊4 / ε ^ 5⌋₊] <| initialBound ε l) *\n    16 ^ (stepBound^[⌊4 / ε ^ 5⌋₊] <| initialBound ε l)\n#align szemeredi_regularity.bound SzemerediRegularity.bound\n\ntheorem initialBound_le_bound : initialBound ε l ≤ bound ε l :=\n  (id_le_iterate_of_id_le le_stepBound _ _).trans <| Nat.le_mul_of_pos_right <| by positivity\n#align szemeredi_regularity.initial_bound_le_bound SzemerediRegularity.initialBound_le_bound\n\ntheorem le_bound : l ≤ bound ε l :=\n  (le_initialBound ε l).trans <| initialBound_le_bound ε l\n#align szemeredi_regularity.le_bound SzemerediRegularity.le_bound\n\ntheorem bound_pos : 0 < bound ε l :=\n  (initialBound_pos ε l).trans_le <| initialBound_le_bound ε l\n#align szemeredi_regularity.bound_pos SzemerediRegularity.bound_pos\n\nvariable {ι 𝕜 : Type _} [LinearOrderedField 𝕜] (r : ι → ι → Prop) [DecidableRel r] {s t : Finset ι}\n  {x : 𝕜}\n\ntheorem mul_sq_le_sum_sq (hst : s ⊆ t) (f : ι → 𝕜) (hs : x ^ 2 ≤ ((∑ i in s, f i) / s.card) ^ 2)\n    (hs' : (s.card : 𝕜) ≠ 0) : (s.card : 𝕜) * x ^ 2 ≤ ∑ i in t, f i ^ 2 :=\n  (mul_le_mul_of_nonneg_left (hs.trans sum_div_card_sq_le_sum_sq_div_card) <|\n        Nat.cast_nonneg _).trans <|\n    (mul_div_cancel' _ hs').le.trans <| sum_le_sum_of_subset_of_nonneg hst fun i _ _ => sq_nonneg _\n#align szemeredi_regularity.mul_sq_le_sum_sq SzemerediRegularity.mul_sq_le_sum_sq\n\ntheorem add_div_le_sum_sq_div_card (hst : s ⊆ t) (f : ι → 𝕜) (d : 𝕜) (hx : 0 ≤ x)\n    (hs : x ≤ |(∑ i in s, f i) / s.card - (∑ i in t, f i) / t.card|)\n    (ht : d ≤ ((∑ i in t, f i) / t.card) ^ 2) :\n    d + s.card / t.card * x ^ 2 ≤ (∑ i in t, f i ^ 2) / t.card :=\n  by\n  obtain hscard | hscard := (s.card.cast_nonneg : (0 : 𝕜) ≤ s.card).eq_or_lt\n  · simpa [← hscard] using ht.trans sum_div_card_sq_le_sum_sq_div_card\n  have htcard : (0 : 𝕜) < t.card := hscard.trans_le (Nat.cast_le.2 (card_le_of_subset hst))\n  have h₁ : x ^ 2 ≤ ((∑ i in s, f i) / s.card - (∑ i in t, f i) / t.card) ^ 2 :=\n    sq_le_sq.2 (by rwa [abs_of_nonneg hx])\n  have h₂ : x ^ 2 ≤ ((∑ i in s, f i - (∑ j in t, f j) / t.card) / s.card) ^ 2 :=\n    by\n    apply h₁.trans\n    rw [sum_sub_distrib, sum_const, nsmul_eq_mul, sub_div, mul_div_cancel_left _ hscard.ne']\n  apply (add_le_add_right ht _).trans\n  rw [← mul_div_right_comm, le_div_iff htcard, add_mul, div_mul_cancel _ htcard.ne']\n  have h₃ := mul_sq_le_sum_sq hst (fun i => f i - (∑ j in t, f j) / t.card) h₂ hscard.ne'\n  apply (add_le_add_left h₃ _).trans\n  simp [← mul_div_right_comm _ (t.card : 𝕜), sub_div' _ _ _ htcard.ne', ← sum_div, ← add_div,\n    mul_pow, div_le_iff (sq_pos_of_ne_zero _ htcard.ne'), sub_sq, sum_add_distrib, ← sum_mul, ←\n    mul_sum]\n  ring_nf\n#align szemeredi_regularity.add_div_le_sum_sq_div_card SzemerediRegularity.add_div_le_sum_sq_div_card\n\nend SzemerediRegularity\n\nnamespace Tactic\n\nopen Positivity SzemerediRegularity\n\n/-- Extension for the `positivity` tactic: `szemeredi_regularity.initial_bound` and\n`szemeredi_regularity.bound` are always positive. -/\n@[positivity]\nunsafe def positivity_szemeredi_regularity_bound : expr → tactic strictness\n  | q(SzemerediRegularity.initialBound $(ε) $(l)) => positive <$> mk_app `` initial_bound_pos [ε, l]\n  | q(SzemerediRegularity.bound $(ε) $(l)) => positive <$> mk_app `` bound_pos [ε, l]\n  | e =>\n    pp e >>=\n      fail ∘\n        format.bracket \"The expression `\"\n          \"` isn't of the form `szemeredi_regularity.initial_bound ε l` nor `szemeredi_regularity.bound ε l`\"\n#align tactic.positivity_szemeredi_regularity_bound tactic.positivity_szemeredi_regularity_bound\n\nexample (ε : ℝ) (l : ℕ) : 0 < SzemerediRegularity.initialBound ε l := by positivity\n\nexample (ε : ℝ) (l : ℕ) : 0 < SzemerediRegularity.bound ε l := by positivity\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Combinatorics/SimpleGraph/Regularity/Bound.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.46109214934333975}}
{"text": "import Qpf\n\nset_option pp.analyze true\n\n#check List\n#check (inferInstance : MvQPF (@TypeFun.ofCurried 1 List))\n\nabbrev List' : TypeFun 1\n  := TypeFun.ofCurried List\n\n\nexample {α} :\n  List α = List' ![α] :=\nby\n  rfl\n\nexample {Γ} :\n  List (Γ 0) = List' Γ :=\nby\n  rfl\n\n\n\n/-- If `a ∈ as`, return `as` with (a single occurence of) `a` removed.\n    Otherwise, if `a ∉ as`, return `none` -/\ndef List.is_rem (a : α) : List α → List α → Prop\n  | b::bs, c::cs  =>    (a = c  ∧ bs = c::cs)\n                      ∨ (b = c  ∧ bs.is_rem a cs)\n  | _, _          => false\n\n\n/-- Equates lists up-to permutation -/\ndef List.perm : List α → List α → Prop\n  | [],    []  =>  true\n  | a::as, bs  =>  ∃cs : List α, cs.is_rem a bs ∧ as.perm cs\n  | _, _       =>  false\n\nabbrev List'.perm ⦃Γ⦄ : (@TypeFun.ofCurried 1 List) Γ → (TypeFun.ofCurried List) Γ → Prop\n  := List.perm\n\ndef MultiSet := MvQPF.Quot1 List'.perm\n\nnoncomputable instance : MvQPF MultiSet := MvQPF.relQuot List'.perm (\n  by \n    intros Γ₁ Γ₂ a b f h₁;\n    dsimp[TypeFun.ofCurried, TypeFun.reverseArgs, TypeFun.ofCurriedAux] at a b;\n    induction a \n      <;> cases b\n      <;> simp[List.perm, List.is_rem] at h₁;\n\n    case nil =>\n      simp[List'.perm, List.perm]\n\n    case cons a as b bs ih =>\n      rcases h₁ with ⟨_|⟨c,cs⟩, h₁, h₂⟩\n      { contradiction }\n      dsimp[List.perm, List'.perm];\n\n      let cs' : List' Γ₂.reverse := f.reverse <$$> cs;\n      use cs';\n\n      constructor\n      {\n        simp[List.is_rem, TypeVec.last, DVec.last, Sigma.snd, MvQPF.List.box]\n        \n      } {\n        sorry\n      }\n\n\n      \n)", "meta": {"author": "alexkeizer", "repo": "qpf4", "sha": "980f97425b9d5a5e3897073df33794192b3b3124", "save_path": "github-repos/lean/alexkeizer-qpf4", "path": "github-repos/lean/alexkeizer-qpf4/qpf4-980f97425b9d5a5e3897073df33794192b3b3124/Qpf/Examples/_ZZ_Multiset.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837527911056, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4610921428431087}}
{"text": "/-\nCopyright (c) 2021 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport measure_theory.measure.measure_space\n\n/-!\n# Typeclasses for measurability of operations\n\nIn this file we define classes `has_measurable_mul` etc and prove dot-style lemmas\n(`measurable.mul`, `ae_measurable.mul` etc). For binary operations we define two typeclasses:\n\n- `has_measurable_mul` says that both left and right multiplication are measurable;\n- `has_measurable_mul₂` says that `λ p : α × α, p.1 * p.2` is measurable,\n\nand similarly for other binary operations. The reason for introducing these classes is that in case\nof topological space `α` equipped with the Borel `σ`-algebra, instances for `has_measurable_mul₂`\netc require `α` to have a second countable topology.\n\nWe define separate classes for `has_measurable_div`/`has_measurable_sub`\nbecause on some types (e.g., `ℕ`, `ℝ≥0∞`) division and/or subtraction are not defined as `a * b⁻¹` /\n`a + (-b)`.\n\nFor instances relating, e.g., `has_continuous_mul` to `has_measurable_mul` see file\n`measure_theory.borel_space`.\n\n## Implementation notes\n\nFor the heuristics of `@[to_additive]` it is important that the type with a multiplication\n(or another multiplicative operations) is the first (implicit) argument of all declarations.\n\n## Tags\n\nmeasurable function, arithmetic operator\n\n## Todo\n\n* Uniformize the treatment of `pow` and `smul`.\n* Use `@[to_additive]` to send `has_measurable_pow` to `has_measurable_smul₂`.\n* This might require changing the definition (swapping the arguments in the function that is\n  in the conclusion of `measurable_smul`.)\n-/\n\nuniverses u v\n\nopen_locale big_operators pointwise measure_theory\nopen measure_theory\n\n/-!\n### Binary operations: `(+)`, `(*)`, `(-)`, `(/)`\n-/\n\n/-- We say that a type `has_measurable_add` if `((+) c)` and `(+ c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (+)` see `has_measurable_add₂`. -/\nclass has_measurable_add (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_const_add : ∀ c : M, measurable ((+) c))\n(measurable_add_const : ∀ c : M, measurable (+ c))\n\n/-- We say that a type `has_measurable_add` if `uncurry (+)` is a measurable functions.\nFor a typeclass assuming measurability of `((+) c)` and `(+ c)` see `has_measurable_add`. -/\nclass has_measurable_add₂ (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_add : measurable (λ p : M × M, p.1 + p.2))\n\nexport has_measurable_add₂ (measurable_add)\n  has_measurable_add (measurable_const_add measurable_add_const)\n\n/-- We say that a type `has_measurable_mul` if `((*) c)` and `(* c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (*)` see `has_measurable_mul₂`. -/\n@[to_additive]\nclass has_measurable_mul (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_const_mul : ∀ c : M, measurable ((*) c))\n(measurable_mul_const : ∀ c : M, measurable (* c))\n\n/-- We say that a type `has_measurable_mul` if `uncurry (*)` is a measurable functions.\nFor a typeclass assuming measurability of `((*) c)` and `(* c)` see `has_measurable_mul`. -/\n@[to_additive has_measurable_add₂]\nclass has_measurable_mul₂ (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_mul : measurable (λ p : M × M, p.1 * p.2))\n\nexport has_measurable_mul₂ (measurable_mul)\n  has_measurable_mul (measurable_const_mul measurable_mul_const)\n\nsection mul\n\nvariables {M α : Type*} [measurable_space M] [has_mul M] {m : measurable_space α}\n  {f g : α → M} {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_mul [has_measurable_mul M] (hf : measurable f) (c : M) :\n  measurable (λ x, c * f x) :=\n(measurable_const_mul c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.const_mul [has_measurable_mul M] (hf : ae_measurable f μ) (c : M) :\n  ae_measurable (λ x, c * f x) μ :=\n(has_measurable_mul.measurable_const_mul c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.mul_const [has_measurable_mul M] (hf : measurable f) (c : M) :\n  measurable (λ x, f x * c) :=\n(measurable_mul_const c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.mul_const [has_measurable_mul M] (hf : ae_measurable f μ) (c : M) :\n  ae_measurable (λ x, f x * c) μ :=\n(measurable_mul_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.mul' [has_measurable_mul₂ M] (hf : measurable f) (hg : measurable g) :\n  measurable (f * g) :=\nmeasurable_mul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma measurable.mul [has_measurable_mul₂ M] (hf : measurable f) (hg : measurable g) :\n  measurable (λ a, f a * g a) :=\nmeasurable_mul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul' [has_measurable_mul₂ M] (hf : ae_measurable f μ)\n  (hg : ae_measurable g μ) :\n  ae_measurable (f * g) μ :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul [has_measurable_mul₂ M] (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ a, f a * g a) μ :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_mul₂.to_has_measurable_mul [has_measurable_mul₂ M] :\n  has_measurable_mul M :=\n⟨λ c, measurable_const.mul measurable_id, λ c, measurable_id.mul measurable_const⟩\n\n@[to_additive]\ninstance pi.has_measurable_mul {ι : Type*} {α : ι → Type*} [∀ i, has_mul (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_mul (α i)] :\n  has_measurable_mul (Π i, α i) :=\n⟨λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).const_mul _,\n λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).mul_const _⟩\n\n@[to_additive pi.has_measurable_add₂]\ninstance pi.has_measurable_mul₂ {ι : Type*} {α : ι → Type*} [∀ i, has_mul (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_mul₂ (α i)] :\n  has_measurable_mul₂ (Π i, α i) :=\n⟨measurable_pi_iff.mpr $ λ i, measurable_fst.eval.mul measurable_snd.eval⟩\n\nattribute [measurability] measurable.add' measurable.add ae_measurable.add ae_measurable.add'\n  measurable.const_add ae_measurable.const_add measurable.add_const ae_measurable.add_const\n\n\nend mul\n\n/-- This class assumes that the map `β × γ → β` given by `(x, y) ↦ x ^ y` is measurable. -/\nclass has_measurable_pow (β γ : Type*) [measurable_space β] [measurable_space γ] [has_pow β γ] :=\n(measurable_pow : measurable (λ p : β × γ, p.1 ^ p.2))\n\nexport has_measurable_pow (measurable_pow)\n\n/-- `monoid.has_pow` is measurable. -/\ninstance monoid.has_measurable_pow (M : Type*) [monoid M] [measurable_space M]\n  [has_measurable_mul₂ M] : has_measurable_pow M ℕ :=\n⟨measurable_from_prod_encodable $ λ n, begin\n  induction n with n ih,\n  { simp only [pow_zero, ←pi.one_def, measurable_one] },\n  { simp only [pow_succ], exact measurable_id.mul ih }\nend⟩\n\nsection pow\n\nvariables {β γ α : Type*} [measurable_space β] [measurable_space γ] [has_pow β γ]\n  [has_measurable_pow β γ] {m : measurable_space α} {μ : measure α} {f : α → β} {g : α → γ}\n\ninclude m\n\n@[measurability]\nlemma measurable.pow (hf : measurable f) (hg : measurable g) :\n  measurable (λ x, f x ^ g x) :=\nmeasurable_pow.comp (hf.prod_mk hg)\n\n@[measurability]\nlemma ae_measurable.pow (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ x, f x ^ g x) μ :=\nmeasurable_pow.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability]\nlemma measurable.pow_const (hf : measurable f) (c : γ) :\n  measurable (λ x, f x ^ c) :=\nhf.pow measurable_const\n\n@[measurability]\nlemma ae_measurable.pow_const (hf : ae_measurable f μ) (c : γ) :\n  ae_measurable (λ x, f x ^ c) μ :=\nhf.pow ae_measurable_const\n\n@[measurability]\nlemma measurable.const_pow (hg : measurable g) (c : β) :\n  measurable (λ x, c ^ g x) :=\nmeasurable_const.pow hg\n\n@[measurability]\nlemma ae_measurable.const_pow (hg : ae_measurable g μ) (c : β) :\n  ae_measurable (λ x, c ^ g x) μ :=\nae_measurable_const.pow hg\n\nomit m\n\nend pow\n\n/-- We say that a type `has_measurable_sub` if `(λ x, c - x)` and `(λ x, x - c)` are measurable\nfunctions. For a typeclass assuming measurability of `uncurry (-)` see `has_measurable_sub₂`. -/\nclass has_measurable_sub (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_const_sub : ∀ c : G, measurable (λ x, c - x))\n(measurable_sub_const : ∀ c : G, measurable (λ x, x - c))\n\n/-- We say that a type `has_measurable_sub` if `uncurry (-)` is a measurable functions.\nFor a typeclass assuming measurability of `((-) c)` and `(- c)` see `has_measurable_sub`. -/\nclass has_measurable_sub₂ (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_sub : measurable (λ p : G × G, p.1 - p.2))\n\nexport has_measurable_sub₂ (measurable_sub)\n\n/-- We say that a type `has_measurable_div` if `((/) c)` and `(/ c)` are measurable functions.\nFor a typeclass assuming measurability of `uncurry (/)` see `has_measurable_div₂`. -/\n@[to_additive] class has_measurable_div (G₀: Type*) [measurable_space G₀] [has_div G₀] : Prop :=\n(measurable_const_div : ∀ c : G₀, measurable ((/) c))\n(measurable_div_const : ∀ c : G₀, measurable (/ c))\n\n/-- We say that a type `has_measurable_div` if `uncurry (/)` is a measurable functions.\nFor a typeclass assuming measurability of `((/) c)` and `(/ c)` see `has_measurable_div`. -/\n@[to_additive has_measurable_sub₂]\nclass has_measurable_div₂ (G₀: Type*) [measurable_space G₀] [has_div G₀] : Prop :=\n(measurable_div : measurable (λ p : G₀× G₀, p.1 / p.2))\n\nexport has_measurable_div₂ (measurable_div)\n\nsection div\n\nvariables {G α : Type*} [measurable_space G] [has_div G] {m : measurable_space α} {f g : α → G}\n  {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_div [has_measurable_div G] (hf : measurable f) (c : G) :\n  measurable (λ x, c / f x) :=\n(has_measurable_div.measurable_const_div c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.const_div [has_measurable_div G] (hf : ae_measurable f μ) (c : G) :\n  ae_measurable (λ x, c / f x) μ :=\n(has_measurable_div.measurable_const_div c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.div_const [has_measurable_div G] (hf : measurable f) (c : G) :\n  measurable (λ x, f x / c) :=\n(has_measurable_div.measurable_div_const c).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.div_const [has_measurable_div G] (hf : ae_measurable f μ) (c : G) :\n  ae_measurable (λ x, f x / c) μ :=\n(has_measurable_div.measurable_div_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.div' [has_measurable_div₂ G] (hf : measurable f) (hg : measurable g) :\n  measurable (f / g) :=\nmeasurable_div.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma measurable.div [has_measurable_div₂ G] (hf : measurable f) (hg : measurable g) :\n  measurable (λ a, f a / g a) :=\nmeasurable_div.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div' [has_measurable_div₂ G] (hf : ae_measurable f μ)\n  (hg : ae_measurable g μ) :\n  ae_measurable (f / g) μ :=\nmeasurable_div.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div [has_measurable_div₂ G] (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ a, f a / g a) μ :=\nmeasurable_div.comp_ae_measurable (hf.prod_mk hg)\n\nattribute [measurability] measurable.sub measurable.sub' ae_measurable.sub ae_measurable.sub'\n  measurable.const_sub ae_measurable.const_sub measurable.sub_const ae_measurable.sub_const\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_div₂.to_has_measurable_div [has_measurable_div₂ G] :\n  has_measurable_div G :=\n⟨λ c, measurable_const.div measurable_id, λ c, measurable_id.div measurable_const⟩\n\n@[to_additive]\ninstance pi.has_measurable_div {ι : Type*} {α : ι → Type*} [∀ i, has_div (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_div (α i)] :\n  has_measurable_div (Π i, α i) :=\n⟨λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).const_div _,\n λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).div_const _⟩\n\n@[to_additive pi.has_measurable_sub₂]\ninstance pi.has_measurable_div₂ {ι : Type*} {α : ι → Type*} [∀ i, has_div (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_div₂ (α i)] :\n  has_measurable_div₂ (Π i, α i) :=\n⟨measurable_pi_iff.mpr $ λ i, measurable_fst.eval.div measurable_snd.eval⟩\n\n@[measurability]\nlemma measurable_set_eq_fun {m : measurable_space α} {E} [measurable_space E] [add_group E]\n  [measurable_singleton_class E] [has_measurable_sub₂ E] {f g : α → E}\n  (hf : measurable f) (hg : measurable g) :\n  measurable_set {x | f x = g x} :=\nbegin\n  suffices h_set_eq : {x : α | f x = g x} = {x | (f-g) x = (0 : E)},\n  { rw h_set_eq,\n    exact (hf.sub hg) measurable_set_eq, },\n  ext,\n  simp_rw [set.mem_set_of_eq, pi.sub_apply, sub_eq_zero],\nend\n\nlemma ae_eq_trim_of_measurable {α E} {m m0 : measurable_space α} {μ : measure α}\n  [measurable_space E] [add_group E] [measurable_singleton_class E] [has_measurable_sub₂ E]\n  (hm : m ≤ m0) {f g : α → E} (hf : measurable[m] f) (hg : measurable[m] g)\n  (hfg : f =ᵐ[μ] g) :\n  f =ᶠ[@measure.ae α m (μ.trim hm)] g :=\nbegin\n  rwa [filter.eventually_eq, ae_iff, trim_measurable_set_eq hm _],\n  exact (@measurable_set.compl α _ m (@measurable_set_eq_fun α m E _ _ _ _ _ _ hf hg)),\nend\n\nend div\n\n/-- We say that a type `has_measurable_neg` if `x ↦ -x` is a measurable function. -/\nclass has_measurable_neg (G : Type*) [has_neg G] [measurable_space G] : Prop :=\n(measurable_neg : measurable (has_neg.neg : G → G))\n\n/-- We say that a type `has_measurable_inv` if `x ↦ x⁻¹` is a measurable function. -/\n@[to_additive]\nclass has_measurable_inv (G : Type*) [has_inv G] [measurable_space G] : Prop :=\n(measurable_inv : measurable (has_inv.inv : G → G))\n\nexport has_measurable_inv (measurable_inv) has_measurable_neg (measurable_neg)\n\n@[priority 100, to_additive]\ninstance has_measurable_div_of_mul_inv (G : Type*) [measurable_space G]\n  [div_inv_monoid G] [has_measurable_mul G] [has_measurable_inv G] :\n  has_measurable_div G :=\n{ measurable_const_div := λ c,\n    by { convert (measurable_inv.const_mul c), ext1, apply div_eq_mul_inv },\n  measurable_div_const := λ c,\n    by { convert (measurable_id.mul_const c⁻¹), ext1, apply div_eq_mul_inv } }\n\nsection inv\n\nvariables {G α : Type*} [has_inv G] [measurable_space G] [has_measurable_inv G]\n  {m : measurable_space α} {f : α → G} {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.inv (hf : measurable f) : measurable (λ x, (f x)⁻¹) := measurable_inv.comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.inv (hf : ae_measurable f μ) : ae_measurable (λ x, (f x)⁻¹) μ :=\nmeasurable_inv.comp_ae_measurable hf\n\nattribute [measurability] measurable.neg ae_measurable.neg\n\n@[simp, to_additive] lemma measurable_inv_iff {G : Type*} [group G] [measurable_space G]\n  [has_measurable_inv G] {f : α → G} : measurable (λ x, (f x)⁻¹) ↔ measurable f :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\n@[simp, to_additive] lemma ae_measurable_inv_iff {G : Type*} [group G] [measurable_space G]\n  [has_measurable_inv G] {f : α → G} :\n  ae_measurable (λ x, (f x)⁻¹) μ ↔ ae_measurable f μ :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\n@[simp] lemma measurable_inv_iff₀ {G₀ : Type*} [group_with_zero G₀]\n  [measurable_space G₀] [has_measurable_inv G₀] {f : α → G₀} :\n  measurable (λ x, (f x)⁻¹) ↔ measurable f :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\n@[simp] lemma ae_measurable_inv_iff₀ {G₀ : Type*} [group_with_zero G₀]\n  [measurable_space G₀] [has_measurable_inv G₀] {f : α → G₀} :\n  ae_measurable (λ x, (f x)⁻¹) μ ↔ ae_measurable f μ :=\n⟨λ h, by simpa only [inv_inv] using h.inv, λ h, h.inv⟩\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_inv {ι : Type*} {α : ι → Type*} [∀ i, has_inv (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_inv (α i)] :\n  has_measurable_inv (Π i, α i) :=\n⟨measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).inv⟩\n\n@[to_additive] lemma measurable_set.inv {s : set G} (hs : measurable_set s) : measurable_set s⁻¹ :=\nmeasurable_inv hs\n\nend inv\n\n/-- `div_inv_monoid.has_pow` is measurable. -/\ninstance div_inv_monoid.has_measurable_zpow (G : Type u) [div_inv_monoid G] [measurable_space G]\n  [has_measurable_mul₂ G] [has_measurable_inv G] :\n  has_measurable_pow G ℤ :=\n⟨measurable_from_prod_encodable $ λ n, begin\n  cases n with n n,\n  { simp_rw zpow_of_nat, exact measurable_id.pow_const _ },\n  { simp_rw zpow_neg_succ_of_nat, exact (measurable_id.pow_const (n + 1)).inv }\nend⟩\n\n@[priority 100, to_additive]\ninstance has_measurable_div₂_of_mul_inv (G : Type*) [measurable_space G]\n  [div_inv_monoid G] [has_measurable_mul₂ G] [has_measurable_inv G] :\n  has_measurable_div₂ G :=\n⟨by { simp only [div_eq_mul_inv], exact measurable_fst.mul measurable_snd.inv }⟩\n\n/-- We say that the action of `M` on `α` `has_measurable_vadd` if for each `c` the map `x ↦ c +ᵥ x`\nis a measurable function and for each `x` the map `c ↦ c +ᵥ x` is a measurable function. -/\nclass has_measurable_vadd (M α : Type*) [has_vadd M α] [measurable_space M] [measurable_space α] :\n  Prop :=\n(measurable_const_vadd : ∀ c : M, measurable ((+ᵥ) c : α → α))\n(measurable_vadd_const : ∀ x : α, measurable (λ c : M, c +ᵥ x))\n\n/-- We say that the action of `M` on `α` `has_measurable_smul` if for each `c` the map `x ↦ c • x`\nis a measurable function and for each `x` the map `c ↦ c • x` is a measurable function. -/\n@[to_additive]\nclass has_measurable_smul (M α : Type*) [has_scalar M α] [measurable_space M] [measurable_space α] :\n  Prop :=\n(measurable_const_smul : ∀ c : M, measurable ((•) c : α → α))\n(measurable_smul_const : ∀ x : α, measurable (λ c : M, c • x))\n\n/-- We say that the action of `M` on `α` `has_measurable_vadd₂` if the map\n`(c, x) ↦ c +ᵥ x` is a measurable function. -/\nclass has_measurable_vadd₂ (M α : Type*) [has_vadd M α] [measurable_space M]\n  [measurable_space α] : Prop :=\n(measurable_vadd : measurable (function.uncurry (+ᵥ) : M × α → α))\n\n/-- We say that the action of `M` on `α` `has_measurable_smul₂` if the map\n`(c, x) ↦ c • x` is a measurable function. -/\n@[to_additive has_measurable_vadd₂]\nclass has_measurable_smul₂ (M α : Type*) [has_scalar M α] [measurable_space M]\n  [measurable_space α] : Prop :=\n(measurable_smul : measurable (function.uncurry (•) : M × α → α))\n\nexport has_measurable_smul (measurable_const_smul measurable_smul_const)\n  has_measurable_smul₂ (measurable_smul)\nexport has_measurable_vadd (measurable_const_vadd measurable_vadd_const)\n  has_measurable_vadd₂ (measurable_vadd)\n\n@[to_additive]\ninstance has_measurable_smul_of_mul (M : Type*) [has_mul M] [measurable_space M]\n  [has_measurable_mul M] :\n  has_measurable_smul M M :=\n⟨measurable_id.const_mul, measurable_id.mul_const⟩\n\n@[to_additive]\ninstance has_measurable_smul₂_of_mul (M : Type*) [has_mul M] [measurable_space M]\n  [has_measurable_mul₂ M] :\n  has_measurable_smul₂ M M :=\n⟨measurable_mul⟩\n\n@[to_additive] instance submonoid.has_measurable_smul {M α} [measurable_space M]\n  [measurable_space α] [monoid M] [mul_action M α] [has_measurable_smul M α] (s : submonoid M) :\n  has_measurable_smul s α :=\n⟨λ c, by simpa only using measurable_const_smul (c : M),\n  λ x, (measurable_smul_const x : measurable (λ c : M, c • x)).comp measurable_subtype_coe⟩\n\n@[to_additive] instance subgroup.has_measurable_smul {G α} [measurable_space G]\n  [measurable_space α] [group G] [mul_action G α] [has_measurable_smul G α] (s : subgroup G) :\n  has_measurable_smul s α :=\ns.to_submonoid.has_measurable_smul\n\nsection smul\n\nvariables {M β α : Type*} [measurable_space M] [measurable_space β] [has_scalar M β]\n  {m : measurable_space α} {f : α → M} {g : α → β}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.smul [has_measurable_smul₂ M β] (hf : measurable f) (hg : measurable g) :\n  measurable (λ x, f x • g x) :=\nmeasurable_smul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.smul [has_measurable_smul₂ M β]\n  {μ : measure α} (hf : ae_measurable f μ) (hg : ae_measurable g μ) :\n  ae_measurable (λ x, f x • g x) μ :=\nhas_measurable_smul₂.measurable_smul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_smul₂.to_has_measurable_smul [has_measurable_smul₂ M β] :\n  has_measurable_smul M β :=\n⟨λ c, measurable_const.smul measurable_id, λ y, measurable_id.smul measurable_const⟩\n\ninclude m\n\nvariables [has_measurable_smul M β] {μ : measure α}\n\n@[measurability, to_additive]\nlemma measurable.smul_const (hf : measurable f) (y : β) :\n  measurable (λ x, f x • y) :=\n(has_measurable_smul.measurable_smul_const y).comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.smul_const (hf : ae_measurable f μ) (y : β) :\n  ae_measurable (λ x, f x • y) μ :=\n(has_measurable_smul.measurable_smul_const y).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.const_smul' (hg : measurable g) (c : M) :\n  measurable (λ x, c • g x) :=\n(has_measurable_smul.measurable_const_smul c).comp hg\n\n@[measurability, to_additive]\nlemma measurable.const_smul (hg : measurable g) (c : M) :\n  measurable (c • g) :=\nhg.const_smul' c\n\n@[measurability, to_additive]\nlemma ae_measurable.const_smul' (hg : ae_measurable g μ) (c : M) :\n  ae_measurable (λ x, c • g x) μ :=\n(has_measurable_smul.measurable_const_smul c).comp_ae_measurable hg\n\n@[measurability, to_additive]\nlemma ae_measurable.const_smul (hf : ae_measurable g μ) (c : M) :\n  ae_measurable (c • g) μ :=\nhf.const_smul' c\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_smul {ι : Type*} {α : ι → Type*} [∀ i, has_scalar M (α i)]\n  [∀ i, measurable_space (α i)] [∀ i, has_measurable_smul M (α i)] :\n  has_measurable_smul M (Π i, α i) :=\n⟨λ g, measurable_pi_iff.mpr $ λ i, (measurable_pi_apply i).const_smul _,\n λ g, measurable_pi_iff.mpr $ λ i, measurable_smul_const _⟩\n\n/-- `add_monoid.has_scalar_nat` is measurable. -/\ninstance add_monoid.has_measurable_smul_nat₂ (M : Type*) [add_monoid M] [measurable_space M]\n  [has_measurable_add₂ M] : has_measurable_smul₂ ℕ M :=\n⟨begin\n  suffices : measurable (λ p : M × ℕ, p.2 • p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_encodable (λ n, _),\n  induction n with n ih,\n  { simp only [zero_smul, ←pi.zero_def, measurable_zero] },\n  { simp only [succ_nsmul], exact measurable_id.add ih }\nend⟩\n\n/-- `sub_neg_monoid.has_scalar_int` is measurable. -/\ninstance sub_neg_monoid.has_measurable_smul_int₂ (M : Type*) [sub_neg_monoid M] [measurable_space M]\n  [has_measurable_add₂ M] [has_measurable_neg M] : has_measurable_smul₂ ℤ M :=\n⟨begin\n  suffices : measurable (λ p : M × ℤ, p.2 • p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_encodable (λ n, _),\n  induction n with n n ih,\n  { simp only [of_nat_zsmul], exact measurable_const_smul _, },\n  { simp only [zsmul_neg_succ_of_nat], exact (measurable_const_smul _).neg }\nend⟩\n\nend smul\n\nsection mul_action\n\nvariables {M β α : Type*} [measurable_space M] [measurable_space β] [monoid M] [mul_action M β]\n  [has_measurable_smul M β] [measurable_space α] {f : α → β} {μ : measure α}\n\nvariables {G : Type*} [group G] [measurable_space G] [mul_action G β]\n  [has_measurable_smul G β]\n\n@[to_additive]\nlemma measurable_const_smul_iff (c : G) :\n  measurable (λ x, c • f x) ↔ measurable f :=\n⟨λ h, by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, λ h, h.const_smul c⟩\n\n@[to_additive]\nlemma ae_measurable_const_smul_iff (c : G) :\n  ae_measurable (λ x, c • f x) μ ↔ ae_measurable f μ :=\n⟨λ h, by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, λ h, h.const_smul c⟩\n\n@[to_additive]\ninstance : measurable_space Mˣ := measurable_space.comap (coe : Mˣ → M) ‹_›\n\n@[to_additive]\ninstance units.has_measurable_smul : has_measurable_smul Mˣ β :=\n{ measurable_const_smul := λ c, (measurable_const_smul (c : M) : _),\n  measurable_smul_const := λ x,\n    (measurable_smul_const x : measurable (λ c : M, c • x)).comp measurable_space.le_map_comap, }\n\n@[to_additive]\nlemma is_unit.measurable_const_smul_iff {c : M} (hc : is_unit c) :\n  measurable (λ x, c • f x) ↔ measurable f :=\nlet ⟨u, hu⟩ := hc in hu ▸ measurable_const_smul_iff u\n\n@[to_additive]\nlemma is_unit.ae_measurable_const_smul_iff {c : M} (hc : is_unit c) :\n  ae_measurable (λ x, c • f x) μ ↔ ae_measurable f μ :=\nlet ⟨u, hu⟩ := hc in hu ▸ ae_measurable_const_smul_iff u\n\nvariables {G₀ : Type*} [group_with_zero G₀] [measurable_space G₀] [mul_action G₀ β]\n  [has_measurable_smul G₀ β]\n\nlemma measurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) :\n  measurable (λ x, c • f x) ↔ measurable f :=\n(is_unit.mk0 c hc).measurable_const_smul_iff\n\nlemma ae_measurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) :\n  ae_measurable (λ x, c • f x) μ ↔ ae_measurable f μ :=\n(is_unit.mk0 c hc).ae_measurable_const_smul_iff\n\nend mul_action\n\n/-!\n### Opposite monoid\n-/\n\nsection opposite\nopen mul_opposite\n\n@[to_additive]\ninstance {α : Type*} [h : measurable_space α] : measurable_space αᵐᵒᵖ := measurable_space.map op h\n\n@[to_additive]\nlemma measurable_mul_op {α : Type*} [measurable_space α] : measurable (op : α → αᵐᵒᵖ) := λ s, id\n\n@[to_additive]\nlemma measurable_mul_unop {α : Type*} [measurable_space α] : measurable (unop : αᵐᵒᵖ → α) := λ s, id\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul M] :\n  has_measurable_mul Mᵐᵒᵖ :=\n⟨λ c, measurable_mul_op.comp (measurable_mul_unop.mul_const _),\n  λ c, measurable_mul_op.comp (measurable_mul_unop.const_mul _)⟩\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul₂ M] :\n  has_measurable_mul₂ Mᵐᵒᵖ :=\n⟨measurable_mul_op.comp ((measurable_mul_unop.comp measurable_snd).mul\n  (measurable_mul_unop.comp measurable_fst))⟩\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul.op {M α} [measurable_space M]\n  [measurable_space α] [has_scalar M α] [has_scalar Mᵐᵒᵖ α] [is_central_scalar M α]\n  [has_measurable_smul M α] : has_measurable_smul Mᵐᵒᵖ α :=\n⟨ mul_opposite.rec $ λ c, show measurable (λ x, op c • x),\n                          by simpa only [op_smul_eq_smul] using measurable_const_smul c,\n  λ x, show measurable (λ c, op (unop c) • x),\n       by simpa only [op_smul_eq_smul] using (measurable_smul_const x).comp measurable_mul_unop⟩\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul₂.op {M α} [measurable_space M]\n  [measurable_space α] [has_scalar M α] [has_scalar Mᵐᵒᵖ α] [is_central_scalar M α]\n  [has_measurable_smul₂ M α] : has_measurable_smul₂ Mᵐᵒᵖ α :=\n⟨show measurable (λ x : Mᵐᵒᵖ × α, op (unop x.1) • x.2), begin\n  simp_rw op_smul_eq_smul,\n  refine (measurable_mul_unop.comp measurable_fst).smul measurable_snd,\nend⟩\n\n@[to_additive]\ninstance has_measurable_smul_opposite_of_mul {M : Type*} [has_mul M] [measurable_space M]\n  [has_measurable_mul M] : has_measurable_smul Mᵐᵒᵖ M :=\n⟨λ c, measurable_mul_const (unop c), λ x, measurable_mul_unop.const_mul x⟩\n\n@[to_additive]\ninstance has_measurable_smul₂_opposite_of_mul {M : Type*} [has_mul M] [measurable_space M]\n  [has_measurable_mul₂ M] : has_measurable_smul₂ Mᵐᵒᵖ M :=\n⟨measurable_snd.mul (measurable_mul_unop.comp measurable_fst)⟩\n\nend opposite\n\n/-!\n### Big operators: `∏` and `∑`\n-/\n\nsection monoid\nvariables {M α : Type*} [monoid M] [measurable_space M] [has_measurable_mul₂ M]\n  {m : measurable_space α} {μ : measure α}\n\ninclude m\n\n@[measurability, to_additive]\nlemma list.measurable_prod' (l : list (α → M)) (hl : ∀ f ∈ l, measurable f) :\n  measurable l.prod :=\nbegin\n  induction l with f l ihl, { exact measurable_one },\n  rw [list.forall_mem_cons] at hl,\n  rw [list.prod_cons],\n  exact hl.1.mul (ihl hl.2)\nend\n\n@[measurability, to_additive]\nlemma list.ae_measurable_prod' (l : list (α → M))\n  (hl : ∀ f ∈ l, ae_measurable f μ) : ae_measurable l.prod μ :=\nbegin\n  induction l with f l ihl, { exact ae_measurable_one },\n  rw [list.forall_mem_cons] at hl,\n  rw [list.prod_cons],\n  exact hl.1.mul (ihl hl.2)\nend\n\n@[measurability, to_additive]\nlemma list.measurable_prod (l : list (α → M)) (hl : ∀ f ∈ l, measurable f) :\n  measurable (λ x, (l.map (λ f : α → M, f x)).prod) :=\nby simpa only [← pi.list_prod_apply] using l.measurable_prod' hl\n\n@[measurability, to_additive]\nlemma list.ae_measurable_prod (l : list (α → M)) (hl : ∀ f ∈ l, ae_measurable f μ) :\n  ae_measurable (λ x, (l.map (λ f : α → M, f x)).prod) μ :=\nby simpa only [← pi.list_prod_apply] using l.ae_measurable_prod' hl\n\nomit m\n\nend monoid\n\nsection comm_monoid\nvariables {M ι α : Type*} [comm_monoid M] [measurable_space M] [has_measurable_mul₂ M]\n  {m : measurable_space α} {μ : measure α} {f : ι → α → M}\n\ninclude m\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod' (l : multiset (α → M)) (hl : ∀ f ∈ l, measurable f) :\n  measurable l.prod :=\nby { rcases l with ⟨l⟩, simpa using l.measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod' (l : multiset (α → M))\n  (hl : ∀ f ∈ l, ae_measurable f μ) : ae_measurable l.prod μ :=\nby { rcases l with ⟨l⟩, simpa using l.ae_measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod (s : multiset (α → M)) (hs : ∀ f ∈ s, measurable f) :\n  measurable (λ x, (s.map (λ f : α → M, f x)).prod) :=\nby simpa only [← pi.multiset_prod_apply] using s.measurable_prod' hs\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod (s : multiset (α → M))\n  (hs : ∀ f ∈ s, ae_measurable f μ) : ae_measurable (λ x, (s.map (λ f : α → M, f x)).prod) μ :=\nby simpa only [← pi.multiset_prod_apply] using s.ae_measurable_prod' hs\n\n@[measurability, to_additive]\nlemma finset.measurable_prod' (s : finset ι) (hf : ∀i ∈ s, measurable (f i)) :\n  measurable (∏ i in s, f i) :=\nfinset.prod_induction _ _ (λ _ _, measurable.mul) (@measurable_one M _ _ _ _) hf\n\n@[measurability, to_additive]\nlemma finset.measurable_prod (s : finset ι) (hf : ∀i ∈ s, measurable (f i)) :\n  measurable (λ a, ∏ i in s, f i a) :=\nby simpa only [← finset.prod_apply] using s.measurable_prod' hf\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod' (s : finset ι) (hf : ∀i ∈ s, ae_measurable (f i) μ) :\n  ae_measurable (∏ i in s, f i) μ :=\nmultiset.ae_measurable_prod' _ $\n  λ g hg, let ⟨i, hi, hg⟩ := multiset.mem_map.1 hg in (hg ▸ hf _ hi)\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod (s : finset ι) (hf : ∀i ∈ s, ae_measurable (f i) μ) :\n  ae_measurable (λ a, ∏ i in s, f i a) μ :=\nby simpa only [← finset.prod_apply] using s.ae_measurable_prod' hf\n\nomit m\n\nend comm_monoid\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/measure_theory/group/arithmetic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.46106292043064784}}
{"text": "/-\nThis module defines operations for simplifying equalities between lists.\n\n-/\n\nuniverse variable u\n\nnamespace list\n\nvariable { α : Type u}\n\n@[simp]\ntheorem nil_eq_cons (a : α) (l : list α) : nil = (a :: l) ↔ false :=\nbegin\n  simp,\n  contradiction,\nend\n\n@[simp]\ntheorem cons_eq_nil (a : α) (l : list α) : (a :: l) = nil ↔ false :=\nbegin\n  simp,\n  contradiction,\nend\n\n@[simp]\ntheorem cons_eq_cons (a : α) (x : list α)  (b : α) (y : list α) : (a :: x) = (b :: y) ↔ a = b ∧ x = y :=\nbegin\n  apply iff.intro,\n  {\n    intro p,\n    injection p with p_a p_b,\n    apply and.intro p_a p_b,\n  },\n  {\n    intro h,\n    exact congr (congr_arg _ (and.left h)) (and.right h),\n  },\nend\n\nend list\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/list/simplify_eq.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4610629204306478}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.set.function\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u v w u_3 u' v' u_4 u_5 u_6 ua1 ua2 ub1 ub2 ug1 ug2 z \n\nnamespace Mathlib\n\n/-!\n# Equivalence between types\n\nIn this file we define two types:\n\n* `equiv α β` a.k.a. `α ≃ β`: a bijective map `α → β` bundled with its inverse map; we use this (and\n  not equality!) to express that various `Type`s or `Sort`s are equivalent.\n\n* `equiv.perm α`: the group of permutations `α ≃ α`. More lemmas about `equiv.perm` can be found in\n  `group_theory/perm`.\n\nThen we define\n\n* canonical isomorphisms between various types: e.g.,\n\n  - `equiv.refl α` is the identity map interpreted as `α ≃ α`;\n\n  - `equiv.sum_equiv_sigma_bool` is the canonical equivalence between the sum of two types `α ⊕ β`\n    and the sigma-type `Σ b : bool, cond b α β`;\n\n  - `equiv.prod_sum_distrib : α × (β ⊕ γ) ≃ (α × β) ⊕ (α × γ)` shows that type product and type sum\n    satisfy the distributive law up to a canonical equivalence;\n\n* operations on equivalences: e.g.,\n\n  - `equiv.symm e : β ≃ α` is the inverse of `e : α ≃ β`;\n\n  - `equiv.trans e₁ e₂ : α ≃ γ` is the composition of `e₁ : α ≃ β` and `e₂ : β ≃ γ` (note the order\n    of the arguments!);\n\n  - `equiv.prod_congr ea eb : α₁ × β₁ ≃ α₂ × β₂`: combine two equivalences `ea : α₁ ≃ α₂` and\n    `eb : β₁ ≃ β₂` using `prod.map`.\n\n* definitions that transfer some instances along an equivalence. By convention, we transfer\n  instances from right to left.\n\n  - `equiv.inhabited` takes `e : α ≃ β` and `[inhabited β]` and returns `inhabited α`;\n  - `equiv.unique` takes `e : α ≃ β` and `[unique β]` and returns `unique α`;\n  - `equiv.decidable_eq` takes `e : α ≃ β` and `[decidable_eq β]` and returns `decidable_eq α`.\n\n  More definitions of this kind can be found in other files. E.g., `data/equiv/transfer_instance`\n  does it for many algebraic type classes like `group`, `module`, etc.\n\n## Tags\n\nequivalence, congruence, bijective map\n-/\n\n/-- `α ≃ β` is the type of functions from `α → β` with a two-sided inverse. -/\nstructure equiv (α : Sort u_1) (β : Sort u_2) where\n  to_fun : α → β\n  inv_fun : β → α\n  left_inv : function.left_inverse inv_fun to_fun\n  right_inv : function.right_inverse inv_fun to_fun\n\ninfixl:25 \" ≃ \" => Mathlib.equiv\n\n/-- Convert an involutive function `f` to an equivalence with `to_fun = inv_fun = f`. -/\ndef function.involutive.to_equiv {α : Sort u} (f : α → α) (h : function.involutive f) : α ≃ α :=\n  equiv.mk f f (function.involutive.left_inverse h) (function.involutive.right_inverse h)\n\nnamespace equiv\n\n\n/-- `perm α` is the type of bijections from `α` to itself. -/\ndef perm (α : Sort u_1) := α ≃ α\n\nprotected instance has_coe_to_fun {α : Sort u} {β : Sort v} : has_coe_to_fun (α ≃ β) :=\n  has_coe_to_fun.mk (fun (x : α ≃ β) => α → β) to_fun\n\n@[simp] theorem coe_fn_mk {α : Sort u} {β : Sort v} (f : α → β) (g : β → α)\n    (l : function.left_inverse g f) (r : function.right_inverse g f) : ⇑(mk f g l r) = f :=\n  rfl\n\n/-- The map `coe_fn : (r ≃ s) → (r → s)` is injective. -/\ntheorem injective_coe_fn {α : Sort u} {β : Sort v} :\n    function.injective fun (e : α ≃ β) (x : α) => coe_fn e x :=\n  sorry\n\n@[simp] protected theorem coe_inj {α : Sort u} {β : Sort v} {e₁ : α ≃ β} {e₂ : α ≃ β} :\n    ⇑e₁ = ⇑e₂ ↔ e₁ = e₂ :=\n  function.injective.eq_iff injective_coe_fn\n\ntheorem ext {α : Sort u} {β : Sort v} {f : α ≃ β} {g : α ≃ β}\n    (H : ∀ (x : α), coe_fn f x = coe_fn g x) : f = g :=\n  injective_coe_fn (funext H)\n\nprotected theorem congr_arg {α : Sort u} {β : Sort v} {f : α ≃ β} {x : α} {x' : α} :\n    x = x' → coe_fn f x = coe_fn f x' :=\n  sorry\n\nprotected theorem congr_fun {α : Sort u} {β : Sort v} {f : α ≃ β} {g : α ≃ β} (h : f = g) (x : α) :\n    coe_fn f x = coe_fn g x :=\n  h ▸ rfl\n\ntheorem ext_iff {α : Sort u} {β : Sort v} {f : α ≃ β} {g : α ≃ β} :\n    f = g ↔ ∀ (x : α), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : α) => h ▸ rfl, mpr := ext }\n\ntheorem perm.ext {α : Sort u} {σ : perm α} {τ : perm α} (H : ∀ (x : α), coe_fn σ x = coe_fn τ x) :\n    σ = τ :=\n  ext H\n\nprotected theorem perm.congr_arg {α : Sort u} {f : perm α} {x : α} {x' : α} :\n    x = x' → coe_fn f x = coe_fn f x' :=\n  equiv.congr_arg\n\nprotected theorem perm.congr_fun {α : Sort u} {f : perm α} {g : perm α} (h : f = g) (x : α) :\n    coe_fn f x = coe_fn g x :=\n  equiv.congr_fun h x\n\ntheorem perm.ext_iff {α : Sort u} {σ : perm α} {τ : perm α} :\n    σ = τ ↔ ∀ (x : α), coe_fn σ x = coe_fn τ x :=\n  ext_iff\n\n/-- Any type is equivalent to itself. -/\nprotected def refl (α : Sort u_1) : α ≃ α := mk id id sorry sorry\n\nprotected instance inhabited' {α : Sort u} : Inhabited (α ≃ α) := { default := equiv.refl α }\n\n/-- Inverse of an equivalence `e : α ≃ β`. -/\nprotected def symm {α : Sort u} {β : Sort v} (e : α ≃ β) : β ≃ α :=\n  mk (inv_fun e) (to_fun e) (right_inv e) (left_inv e)\n\n/-- See Note [custom simps projection] -/\ndef simps.inv_fun {α : Sort u} {β : Sort v} (e : α ≃ β) : β → α := ⇑(equiv.symm e)\n\n/-- Composition of equivalences `e₁ : α ≃ β` and `e₂ : β ≃ γ`. -/\nprotected def trans {α : Sort u} {β : Sort v} {γ : Sort w} (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=\n  mk (⇑e₂ ∘ ⇑e₁) (⇑(equiv.symm e₁) ∘ ⇑(equiv.symm e₂)) sorry sorry\n\n@[simp] theorem to_fun_as_coe {α : Sort u} {β : Sort v} (e : α ≃ β) : to_fun e = ⇑e := rfl\n\n@[simp] theorem inv_fun_as_coe {α : Sort u} {β : Sort v} (e : α ≃ β) :\n    inv_fun e = ⇑(equiv.symm e) :=\n  rfl\n\nprotected theorem injective {α : Sort u} {β : Sort v} (e : α ≃ β) : function.injective ⇑e :=\n  function.left_inverse.injective (left_inv e)\n\nprotected theorem surjective {α : Sort u} {β : Sort v} (e : α ≃ β) : function.surjective ⇑e :=\n  function.right_inverse.surjective (right_inv e)\n\nprotected theorem bijective {α : Sort u} {β : Sort v} (f : α ≃ β) : function.bijective ⇑f :=\n  { left := equiv.injective f, right := equiv.surjective f }\n\n@[simp] theorem range_eq_univ {α : Type u_1} {β : Type u_2} (e : α ≃ β) : set.range ⇑e = set.univ :=\n  set.eq_univ_of_forall (equiv.surjective e)\n\nprotected theorem subsingleton {α : Sort u} {β : Sort v} (e : α ≃ β) [subsingleton β] :\n    subsingleton α :=\n  function.injective.subsingleton (equiv.injective e)\n\nprotected theorem subsingleton.symm {α : Sort u} {β : Sort v} (e : α ≃ β) [subsingleton α] :\n    subsingleton β :=\n  function.injective.subsingleton (equiv.injective (equiv.symm e))\n\nprotected instance equiv_subsingleton_cod {α : Sort u} {β : Sort v} [subsingleton β] :\n    subsingleton (α ≃ β) :=\n  subsingleton.intro\n    fun (f g : α ≃ β) => ext fun (x : α) => subsingleton.elim (coe_fn f x) (coe_fn g x)\n\nprotected instance equiv_subsingleton_dom {α : Sort u} {β : Sort v} [subsingleton α] :\n    subsingleton (α ≃ β) :=\n  subsingleton.intro\n    fun (f g : α ≃ β) => ext fun (x : α) => subsingleton.elim (coe_fn f x) (coe_fn g x)\n\nprotected instance perm_subsingleton {α : Sort u} [subsingleton α] : subsingleton (perm α) :=\n  equiv.equiv_subsingleton_cod\n\ntheorem perm.subsingleton_eq_refl {α : Sort u} [subsingleton α] (e : perm α) : e = equiv.refl α :=\n  subsingleton.elim e (equiv.refl α)\n\n/-- Transfer `decidable_eq` across an equivalence. -/\nprotected def decidable_eq {α : Sort u} {β : Sort v} (e : α ≃ β) [DecidableEq β] : DecidableEq α :=\n  function.injective.decidable_eq (equiv.injective e)\n\ntheorem nonempty_iff_nonempty {α : Sort u} {β : Sort v} (e : α ≃ β) : Nonempty α ↔ Nonempty β :=\n  nonempty.congr ⇑e ⇑(equiv.symm e)\n\n/-- If `α ≃ β` and `β` is inhabited, then so is `α`. -/\nprotected def inhabited {α : Sort u} {β : Sort v} [Inhabited β] (e : α ≃ β) : Inhabited α :=\n  { default := coe_fn (equiv.symm e) Inhabited.default }\n\n/-- If `α ≃ β` and `β` is a singleton type, then so is `α`. -/\nprotected def unique {α : Sort u} {β : Sort v} [unique β] (e : α ≃ β) : unique α :=\n  function.surjective.unique sorry\n\n/-- Equivalence between equal types. -/\nprotected def cast {α : Sort u_1} {β : Sort u_1} (h : α = β) : α ≃ β :=\n  mk (cast h) (cast sorry) sorry sorry\n\n@[simp] theorem coe_fn_symm_mk {α : Sort u} {β : Sort v} (f : α → β) (g : β → α)\n    (l : function.left_inverse g f) (r : function.right_inverse g f) :\n    ⇑(equiv.symm (mk f g l r)) = g :=\n  rfl\n\n@[simp] theorem coe_refl {α : Sort u} : ⇑(equiv.refl α) = id := rfl\n\n@[simp] theorem perm.coe_subsingleton {α : Type u_1} [subsingleton α] (e : perm α) : ⇑e = id :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (⇑e = id)) (perm.subsingleton_eq_refl e)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (⇑(equiv.refl α) = id)) coe_refl)) (Eq.refl id))\n\ntheorem refl_apply {α : Sort u} (x : α) : coe_fn (equiv.refl α) x = x := rfl\n\n@[simp] theorem coe_trans {α : Sort u} {β : Sort v} {γ : Sort w} (f : α ≃ β) (g : β ≃ γ) :\n    ⇑(equiv.trans f g) = ⇑g ∘ ⇑f :=\n  rfl\n\ntheorem trans_apply {α : Sort u} {β : Sort v} {γ : Sort w} (f : α ≃ β) (g : β ≃ γ) (a : α) :\n    coe_fn (equiv.trans f g) a = coe_fn g (coe_fn f a) :=\n  rfl\n\n@[simp] theorem apply_symm_apply {α : Sort u} {β : Sort v} (e : α ≃ β) (x : β) :\n    coe_fn e (coe_fn (equiv.symm e) x) = x :=\n  right_inv e x\n\n@[simp] theorem symm_apply_apply {α : Sort u} {β : Sort v} (e : α ≃ β) (x : α) :\n    coe_fn (equiv.symm e) (coe_fn e x) = x :=\n  left_inv e x\n\n@[simp] theorem symm_comp_self {α : Sort u} {β : Sort v} (e : α ≃ β) : ⇑(equiv.symm e) ∘ ⇑e = id :=\n  funext (symm_apply_apply e)\n\n@[simp] theorem self_comp_symm {α : Sort u} {β : Sort v} (e : α ≃ β) : ⇑e ∘ ⇑(equiv.symm e) = id :=\n  funext (apply_symm_apply e)\n\n@[simp] theorem symm_trans_apply {α : Sort u} {β : Sort v} {γ : Sort w} (f : α ≃ β) (g : β ≃ γ)\n    (a : γ) :\n    coe_fn (equiv.symm (equiv.trans f g)) a = coe_fn (equiv.symm f) (coe_fn (equiv.symm g) a) :=\n  rfl\n\n-- The `simp` attribute is needed to make this a `dsimp` lemma.\n\n-- `simp` will always rewrite with `equiv.symm_symm` before this has a chance to fire.\n\n@[simp] theorem symm_symm_apply {α : Sort u} {β : Sort v} (f : α ≃ β) (b : α) :\n    coe_fn (equiv.symm (equiv.symm f)) b = coe_fn f b :=\n  rfl\n\n@[simp] theorem apply_eq_iff_eq {α : Sort u} {β : Sort v} (f : α ≃ β) {x : α} {y : α} :\n    coe_fn f x = coe_fn f y ↔ x = y :=\n  function.injective.eq_iff (equiv.injective f)\n\ntheorem apply_eq_iff_eq_symm_apply {α : Sort u_1} {β : Sort u_2} (f : α ≃ β) {x : α} {y : β} :\n    coe_fn f x = y ↔ x = coe_fn (equiv.symm f) y :=\n  sorry\n\n@[simp] theorem cast_apply {α : Sort u_1} {β : Sort u_1} (h : α = β) (x : α) :\n    coe_fn (equiv.cast h) x = cast h x :=\n  rfl\n\ntheorem symm_apply_eq {α : Sort u_1} {β : Sort u_2} (e : α ≃ β) {x : β} {y : α} :\n    coe_fn (equiv.symm e) x = y ↔ x = coe_fn e y :=\n  sorry\n\ntheorem eq_symm_apply {α : Sort u_1} {β : Sort u_2} (e : α ≃ β) {x : β} {y : α} :\n    y = coe_fn (equiv.symm e) x ↔ coe_fn e y = x :=\n  iff.trans (iff.trans eq_comm (symm_apply_eq e)) eq_comm\n\n@[simp] theorem symm_symm {α : Sort u} {β : Sort v} (e : α ≃ β) : equiv.symm (equiv.symm e) = e :=\n  sorry\n\n@[simp] theorem trans_refl {α : Sort u} {β : Sort v} (e : α ≃ β) :\n    equiv.trans e (equiv.refl β) = e :=\n  sorry\n\n@[simp] theorem refl_symm {α : Sort u} : equiv.symm (equiv.refl α) = equiv.refl α := rfl\n\n@[simp] theorem refl_trans {α : Sort u} {β : Sort v} (e : α ≃ β) :\n    equiv.trans (equiv.refl α) e = e :=\n  sorry\n\n@[simp] theorem symm_trans {α : Sort u} {β : Sort v} (e : α ≃ β) :\n    equiv.trans (equiv.symm e) e = equiv.refl β :=\n  sorry\n\n@[simp] theorem trans_symm {α : Sort u} {β : Sort v} (e : α ≃ β) :\n    equiv.trans e (equiv.symm e) = equiv.refl α :=\n  sorry\n\ntheorem trans_assoc {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort u_1} (ab : α ≃ β) (bc : β ≃ γ)\n    (cd : γ ≃ δ) : equiv.trans (equiv.trans ab bc) cd = equiv.trans ab (equiv.trans bc cd) :=\n  ext fun (a : α) => rfl\n\ntheorem left_inverse_symm {α : Sort u} {β : Sort v} (f : α ≃ β) :\n    function.left_inverse ⇑(equiv.symm f) ⇑f :=\n  left_inv f\n\ntheorem right_inverse_symm {α : Sort u} {β : Sort v} (f : α ≃ β) :\n    function.right_inverse ⇑(equiv.symm f) ⇑f :=\n  right_inv f\n\n/-- If `α` is equivalent to `β` and `γ` is equivalent to `δ`, then the type of equivalences `α ≃ γ`\nis equivalent to the type of equivalences `β ≃ δ`. -/\ndef equiv_congr {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort u_1} (ab : α ≃ β) (cd : γ ≃ δ) :\n    α ≃ γ ≃ (β ≃ δ) :=\n  mk (fun (ac : α ≃ γ) => equiv.trans (equiv.trans (equiv.symm ab) ac) cd)\n    (fun (bd : β ≃ δ) => equiv.trans ab (equiv.trans bd (equiv.symm cd))) sorry sorry\n\n@[simp] theorem equiv_congr_refl {α : Sort u_1} {β : Sort u_2} :\n    equiv_congr (equiv.refl α) (equiv.refl β) = equiv.refl (α ≃ β) :=\n  ext\n    fun (x : α ≃ β) =>\n      ext\n        fun (x_1 : α) => Eq.refl (coe_fn (coe_fn (equiv_congr (equiv.refl α) (equiv.refl β)) x) x_1)\n\n@[simp] theorem equiv_congr_symm {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort u_1} (ab : α ≃ β)\n    (cd : γ ≃ δ) : equiv.symm (equiv_congr ab cd) = equiv_congr (equiv.symm ab) (equiv.symm cd) :=\n  ext\n    fun (x : β ≃ δ) =>\n      ext fun (x_1 : α) => Eq.refl (coe_fn (coe_fn (equiv.symm (equiv_congr ab cd)) x) x_1)\n\n@[simp] theorem equiv_congr_trans {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort u_1}\n    {ε : Sort u_2} {ζ : Sort u_3} (ab : α ≃ β) (de : δ ≃ ε) (bc : β ≃ γ) (ef : ε ≃ ζ) :\n    equiv.trans (equiv_congr ab de) (equiv_congr bc ef) =\n        equiv_congr (equiv.trans ab bc) (equiv.trans de ef) :=\n  ext\n    fun (x : α ≃ δ) =>\n      ext\n        fun (x_1 : γ) =>\n          Eq.refl (coe_fn (coe_fn (equiv.trans (equiv_congr ab de) (equiv_congr bc ef)) x) x_1)\n\n@[simp] theorem equiv_congr_refl_left {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} (bg : β ≃ γ)\n    (e : α ≃ β) : coe_fn (equiv_congr (equiv.refl α) bg) e = equiv.trans e bg :=\n  rfl\n\n@[simp] theorem equiv_congr_refl_right {α : Sort u_1} {β : Sort u_2} (ab : α ≃ β) (e : α ≃ β) :\n    coe_fn (equiv_congr ab (equiv.refl β)) e = equiv.trans (equiv.symm ab) e :=\n  rfl\n\n@[simp] theorem equiv_congr_apply_apply {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort u_1}\n    (ab : α ≃ β) (cd : γ ≃ δ) (e : α ≃ γ) (x : β) :\n    coe_fn (coe_fn (equiv_congr ab cd) e) x = coe_fn cd (coe_fn e (coe_fn (equiv.symm ab) x)) :=\n  rfl\n\n/-- If `α` is equivalent to `β`, then `perm α` is equivalent to `perm β`. -/\ndef perm_congr {α : Type u_1} {β : Type u_2} (e : α ≃ β) : perm α ≃ perm β := equiv_congr e e\n\ntheorem perm_congr_def {α : Type u_1} {β : Type u_2} (e : α ≃ β) (p : perm α) :\n    coe_fn (perm_congr e) p = equiv.trans (equiv.trans (equiv.symm e) p) e :=\n  rfl\n\n@[simp] theorem perm_congr_symm {α : Type u_1} {β : Type u_2} (e : α ≃ β) :\n    equiv.symm (perm_congr e) = perm_congr (equiv.symm e) :=\n  rfl\n\n@[simp] theorem perm_congr_apply {α : Type u_1} {β : Type u_2} (e : α ≃ β) (p : perm α) (x : β) :\n    coe_fn (coe_fn (perm_congr e) p) x = coe_fn e (coe_fn p (coe_fn (equiv.symm e) x)) :=\n  rfl\n\ntheorem perm_congr_symm_apply {α : Type u_1} {β : Type u_2} (e : α ≃ β) (p : perm β) (x : α) :\n    coe_fn (coe_fn (equiv.symm (perm_congr e)) p) x =\n        coe_fn (equiv.symm e) (coe_fn p (coe_fn e x)) :=\n  rfl\n\nprotected theorem image_eq_preimage {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : set α) :\n    ⇑e '' s = ⇑(equiv.symm e) ⁻¹' s :=\n  set.ext fun (x : β) => set.mem_image_iff_of_inverse (left_inv e) (right_inv e)\n\nprotected theorem subset_image {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : set α) (t : set β) :\n    t ⊆ ⇑e '' s ↔ ⇑(equiv.symm e) '' t ⊆ s :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (t ⊆ ⇑e '' s ↔ ⇑(equiv.symm e) '' t ⊆ s))\n        (propext set.image_subset_iff)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (t ⊆ ⇑e '' s ↔ t ⊆ ⇑(equiv.symm e) ⁻¹' s))\n          (equiv.image_eq_preimage e s)))\n      (iff.refl (t ⊆ ⇑(equiv.symm e) ⁻¹' s)))\n\n@[simp] theorem symm_image_image {α : Type u_1} {β : Type u_2} (f : α ≃ β) (s : set α) :\n    ⇑(equiv.symm f) '' (⇑f '' s) = s :=\n  sorry\n\n@[simp] theorem image_preimage {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : set β) :\n    ⇑e '' (⇑e ⁻¹' s) = s :=\n  function.surjective.image_preimage (equiv.surjective e) s\n\n@[simp] theorem preimage_image {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : set α) :\n    ⇑e ⁻¹' (⇑e '' s) = s :=\n  set.preimage_image_eq s (equiv.injective e)\n\nprotected theorem image_compl {α : Type u_1} {β : Type u_2} (f : α ≃ β) (s : set α) :\n    ⇑f '' (sᶜ) = (⇑f '' sᶜ) :=\n  set.image_compl_eq (equiv.bijective f)\n\n/-- If `α` is an empty type, then it is equivalent to the `empty` type. -/\ndef equiv_empty {α : Sort u} (h : α → False) : α ≃ empty :=\n  mk (fun (x : α) => false.elim (h x)) (fun (e : empty) => empty.rec (fun (e : empty) => α) e) sorry\n    sorry\n\n/-- `false` is equivalent to `empty`. -/\ndef false_equiv_empty : False ≃ empty := equiv_empty id\n\n/-- If `α` is an empty type, then it is equivalent to the `pempty` type in any universe. -/\ndef equiv_pempty {α : Sort v'} (h : α → False) : α ≃ pempty :=\n  mk (fun (x : α) => false.elim (h x)) (fun (e : pempty) => pempty.rec (fun (e : pempty) => α) e)\n    sorry sorry\n\n/-- `false` is equivalent to `pempty`. -/\ndef false_equiv_pempty : False ≃ pempty := equiv_pempty id\n\n/-- `empty` is equivalent to `pempty`. -/\ndef empty_equiv_pempty : empty ≃ pempty := equiv_pempty sorry\n\n/-- `pempty` types from any two universes are equivalent. -/\ndef pempty_equiv_pempty : pempty ≃ pempty := equiv_pempty pempty.elim\n\n/-- If `α` is not `nonempty`, then it is equivalent to `empty`. -/\ndef empty_of_not_nonempty {α : Sort u_1} (h : ¬Nonempty α) : α ≃ empty := equiv_empty sorry\n\n/-- If `α` is not `nonempty`, then it is equivalent to `pempty`. -/\ndef pempty_of_not_nonempty {α : Sort u_1} (h : ¬Nonempty α) : α ≃ pempty := equiv_pempty sorry\n\n/-- The `Sort` of proofs of a true proposition is equivalent to `punit`. -/\ndef prop_equiv_punit {p : Prop} (h : p) : p ≃ PUnit :=\n  mk (fun (x : p) => Unit.unit) sorry sorry sorry\n\n/-- `true` is equivalent to `punit`. -/\ndef true_equiv_punit : True ≃ PUnit := prop_equiv_punit trivial\n\n/-- `ulift α` is equivalent to `α`. -/\n@[simp] theorem ulift_symm_apply {α : Type v} : ⇑(equiv.symm equiv.ulift) = ulift.up :=\n  Eq.refl ⇑(equiv.symm equiv.ulift)\n\n/-- `plift α` is equivalent to `α`. -/\nprotected def plift {α : Sort u} : plift α ≃ α := mk plift.down plift.up plift.up_down plift.down_up\n\n/-- equivalence of propositions is the same as iff -/\ndef of_iff {P : Prop} {Q : Prop} (h : P ↔ Q) : P ≃ Q := mk (iff.mp h) (iff.mpr h) sorry sorry\n\n/-- If `α₁` is equivalent to `α₂` and `β₁` is equivalent to `β₂`, then the type of maps `α₁ → β₁`\nis equivalent to the type of maps `α₂ → β₂`. -/\ndef arrow_congr {α₁ : Sort u_1} {β₁ : Sort u_2} {α₂ : Sort u_3} {β₂ : Sort u_4} (e₁ : α₁ ≃ α₂)\n    (e₂ : β₁ ≃ β₂) : (α₁ → β₁) ≃ (α₂ → β₂) :=\n  mk (fun (f : α₁ → β₁) => ⇑e₂ ∘ f ∘ ⇑(equiv.symm e₁))\n    (fun (f : α₂ → β₂) => ⇑(equiv.symm e₂) ∘ f ∘ ⇑e₁) sorry sorry\n\ntheorem arrow_congr_comp {α₁ : Sort u_1} {β₁ : Sort u_2} {γ₁ : Sort u_3} {α₂ : Sort u_4}\n    {β₂ : Sort u_5} {γ₂ : Sort u_6} (ea : α₁ ≃ α₂) (eb : β₁ ≃ β₂) (ec : γ₁ ≃ γ₂) (f : α₁ → β₁)\n    (g : β₁ → γ₁) :\n    coe_fn (arrow_congr ea ec) (g ∘ f) =\n        coe_fn (arrow_congr eb ec) g ∘ coe_fn (arrow_congr ea eb) f :=\n  sorry\n\n@[simp] theorem arrow_congr_refl {α : Sort u_1} {β : Sort u_2} :\n    arrow_congr (equiv.refl α) (equiv.refl β) = equiv.refl (α → β) :=\n  rfl\n\n@[simp] theorem arrow_congr_trans {α₁ : Sort u_1} {β₁ : Sort u_2} {α₂ : Sort u_3} {β₂ : Sort u_4}\n    {α₃ : Sort u_5} {β₃ : Sort u_6} (e₁ : α₁ ≃ α₂) (e₁' : β₁ ≃ β₂) (e₂ : α₂ ≃ α₃) (e₂' : β₂ ≃ β₃) :\n    arrow_congr (equiv.trans e₁ e₂) (equiv.trans e₁' e₂') =\n        equiv.trans (arrow_congr e₁ e₁') (arrow_congr e₂ e₂') :=\n  rfl\n\n@[simp] theorem arrow_congr_symm {α₁ : Sort u_1} {β₁ : Sort u_2} {α₂ : Sort u_3} {β₂ : Sort u_4}\n    (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) :\n    equiv.symm (arrow_congr e₁ e₂) = arrow_congr (equiv.symm e₁) (equiv.symm e₂) :=\n  rfl\n\n/--\nA version of `equiv.arrow_congr` in `Type`, rather than `Sort`.\n\nThe `equiv_rw` tactic is not able to use the default `Sort` level `equiv.arrow_congr`,\nbecause Lean's universe rules will not unify `?l_1` with `imax (1 ?m_1)`.\n-/\ndef arrow_congr' {α₁ : Type u_1} {β₁ : Type u_2} {α₂ : Type u_3} {β₂ : Type u_4} (hα : α₁ ≃ α₂)\n    (hβ : β₁ ≃ β₂) : (α₁ → β₁) ≃ (α₂ → β₂) :=\n  arrow_congr hα hβ\n\n@[simp] theorem arrow_congr'_refl {α : Type u_1} {β : Type u_2} :\n    arrow_congr' (equiv.refl α) (equiv.refl β) = equiv.refl (α → β) :=\n  rfl\n\n@[simp] theorem arrow_congr'_trans {α₁ : Type u_1} {β₁ : Type u_2} {α₂ : Type u_3} {β₂ : Type u_4}\n    {α₃ : Type u_5} {β₃ : Type u_6} (e₁ : α₁ ≃ α₂) (e₁' : β₁ ≃ β₂) (e₂ : α₂ ≃ α₃) (e₂' : β₂ ≃ β₃) :\n    arrow_congr' (equiv.trans e₁ e₂) (equiv.trans e₁' e₂') =\n        equiv.trans (arrow_congr' e₁ e₁') (arrow_congr' e₂ e₂') :=\n  rfl\n\n@[simp] theorem arrow_congr'_symm {α₁ : Type u_1} {β₁ : Type u_2} {α₂ : Type u_3} {β₂ : Type u_4}\n    (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) :\n    equiv.symm (arrow_congr' e₁ e₂) = arrow_congr' (equiv.symm e₁) (equiv.symm e₂) :=\n  rfl\n\n/-- Conjugate a map `f : α → α` by an equivalence `α ≃ β`. -/\ndef conj {α : Sort u} {β : Sort v} (e : α ≃ β) : (α → α) ≃ (β → β) := arrow_congr e e\n\n@[simp] theorem conj_refl {α : Sort u} : conj (equiv.refl α) = equiv.refl (α → α) := rfl\n\n@[simp] theorem conj_symm {α : Sort u} {β : Sort v} (e : α ≃ β) :\n    equiv.symm (conj e) = conj (equiv.symm e) :=\n  rfl\n\n@[simp] theorem conj_trans {α : Sort u} {β : Sort v} {γ : Sort w} (e₁ : α ≃ β) (e₂ : β ≃ γ) :\n    conj (equiv.trans e₁ e₂) = equiv.trans (conj e₁) (conj e₂) :=\n  rfl\n\n-- This should not be a simp lemma as long as `(∘)` is reducible:\n\n-- when `(∘)` is reducible, Lean can unify `f₁ ∘ f₂` with any `g` using\n\n-- `f₁ := g` and `f₂ := λ x, x`.  This causes nontermination.\n\ntheorem conj_comp {α : Sort u} {β : Sort v} (e : α ≃ β) (f₁ : α → α) (f₂ : α → α) :\n    coe_fn (conj e) (f₁ ∘ f₂) = coe_fn (conj e) f₁ ∘ coe_fn (conj e) f₂ :=\n  arrow_congr_comp e e e f₂ f₁\n\ntheorem semiconj_conj {α₁ : Type u_1} {β₁ : Type u_2} (e : α₁ ≃ β₁) (f : α₁ → α₁) :\n    function.semiconj (⇑e) f (coe_fn (conj e) f) :=\n  sorry\n\ntheorem semiconj₂_conj {α₁ : Type u_1} {β₁ : Type u_2} (e : α₁ ≃ β₁) (f : α₁ → α₁ → α₁) :\n    function.semiconj₂ (⇑e) f (coe_fn (arrow_congr e (conj e)) f) :=\n  sorry\n\nprotected instance arrow_congr.is_associative {α₁ : Type u_1} {β₁ : Type u_2} (e : α₁ ≃ β₁)\n    (f : α₁ → α₁ → α₁) [is_associative α₁ f] :\n    is_associative β₁ (coe_fn (arrow_congr e (arrow_congr e e)) f) :=\n  function.semiconj₂.is_associative_right (semiconj₂_conj e f) (equiv.surjective e)\n\nprotected instance arrow_congr.is_idempotent {α₁ : Type u_1} {β₁ : Type u_2} (e : α₁ ≃ β₁)\n    (f : α₁ → α₁ → α₁) [is_idempotent α₁ f] :\n    is_idempotent β₁ (coe_fn (arrow_congr e (arrow_congr e e)) f) :=\n  function.semiconj₂.is_idempotent_right (semiconj₂_conj e f) (equiv.surjective e)\n\nprotected instance arrow_congr.is_left_cancel {α₁ : Type u_1} {β₁ : Type u_2} (e : α₁ ≃ β₁)\n    (f : α₁ → α₁ → α₁) [is_left_cancel α₁ f] :\n    is_left_cancel β₁ (coe_fn (arrow_congr e (arrow_congr e e)) f) :=\n  sorry\n\nprotected instance arrow_congr.is_right_cancel {α₁ : Type u_1} {β₁ : Type u_2} (e : α₁ ≃ β₁)\n    (f : α₁ → α₁ → α₁) [is_right_cancel α₁ f] :\n    is_right_cancel β₁ (coe_fn (arrow_congr e (arrow_congr e e)) f) :=\n  sorry\n\n/-- `punit` sorts in any two universes are equivalent. -/\ndef punit_equiv_punit : PUnit ≃ PUnit :=\n  mk (fun (_x : PUnit) => PUnit.unit) (fun (_x : PUnit) => PUnit.unit) sorry sorry\n\n/-- The sort of maps to `punit.{v}` is equivalent to `punit.{w}`. -/\ndef arrow_punit_equiv_punit (α : Sort u_1) : (α → PUnit) ≃ PUnit :=\n  mk (fun (f : α → PUnit) => PUnit.unit) (fun (u : PUnit) (f : α) => PUnit.unit) sorry sorry\n\n/-- The sort of maps from `punit` is equivalent to the codomain. -/\ndef punit_arrow_equiv (α : Sort u_1) : (PUnit → α) ≃ α :=\n  mk (fun (f : PUnit → α) => f PUnit.unit) (fun (a : α) (u : PUnit) => a) sorry sorry\n\n/-- The sort of maps from `true` is equivalent to the codomain. -/\ndef true_arrow_equiv (α : Sort u_1) : (True → α) ≃ α :=\n  mk (fun (f : True → α) => f trivial) (fun (a : α) (u : True) => a) sorry sorry\n\n/-- The sort of maps from `empty` is equivalent to `punit`. -/\ndef empty_arrow_equiv_punit (α : Sort u_1) : (empty → α) ≃ PUnit :=\n  mk (fun (f : empty → α) => PUnit.unit)\n    (fun (u : PUnit) (e : empty) => empty.rec (fun (e : empty) => α) e) sorry sorry\n\n/-- The sort of maps from `pempty` is equivalent to `punit`. -/\ndef pempty_arrow_equiv_punit (α : Sort u_1) : (pempty → α) ≃ PUnit :=\n  mk (fun (f : pempty → α) => PUnit.unit)\n    (fun (u : PUnit) (e : pempty) => pempty.rec (fun (e : pempty) => α) e) sorry sorry\n\n/-- The sort of maps from `false` is equivalent to `punit`. -/\ndef false_arrow_equiv_punit (α : Sort u_1) : (False → α) ≃ PUnit :=\n  equiv.trans (arrow_congr false_equiv_empty (equiv.refl α)) (empty_arrow_equiv_punit α)\n\n/-- Product of two equivalences. If `α₁ ≃ α₂` and `β₁ ≃ β₂`, then `α₁ × β₁ ≃ α₂ × β₂`. -/\n@[simp] theorem prod_congr_apply {α₁ : Type u_1} {β₁ : Type u_2} {α₂ : Type u_3} {β₂ : Type u_4}\n    (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) (x : α₁ × β₁) :\n    coe_fn (prod_congr e₁ e₂) x = prod.map (⇑e₁) (⇑e₂) x :=\n  Eq.refl (coe_fn (prod_congr e₁ e₂) x)\n\n@[simp] theorem prod_congr_symm {α₁ : Type u_1} {β₁ : Type u_2} {α₂ : Type u_3} {β₂ : Type u_4}\n    (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) :\n    equiv.symm (prod_congr e₁ e₂) = prod_congr (equiv.symm e₁) (equiv.symm e₂) :=\n  rfl\n\n/-- Type product is commutative up to an equivalence: `α × β ≃ β × α`. -/\n@[simp] theorem prod_comm_apply (α : Type u_1) (β : Type u_2) :\n    ∀ (ᾰ : α × β), coe_fn (prod_comm α β) ᾰ = prod.swap ᾰ :=\n  fun (ᾰ : α × β) => Eq.refl (coe_fn (prod_comm α β) ᾰ)\n\n@[simp] theorem prod_comm_symm (α : Type u_1) (β : Type u_2) :\n    equiv.symm (prod_comm α β) = prod_comm β α :=\n  rfl\n\n/-- Type product is associative up to an equivalence. -/\n@[simp] theorem prod_assoc_apply (α : Type u_1) (β : Type u_2) (γ : Type u_3) (p : (α × β) × γ) :\n    coe_fn (prod_assoc α β γ) p = (prod.fst (prod.fst p), prod.snd (prod.fst p), prod.snd p) :=\n  Eq.refl (coe_fn (prod_assoc α β γ) p)\n\ntheorem prod_assoc_preimage {α : Type u_1} {β : Type u_2} {γ : Type u_3} {s : set α} {t : set β}\n    {u : set γ} : ⇑(prod_assoc α β γ) ⁻¹' set.prod s (set.prod t u) = set.prod (set.prod s t) u :=\n  sorry\n\n/-- `punit` is a right identity for type product up to an equivalence. -/\n@[simp] theorem prod_punit_apply (α : Type u_1) (p : α × PUnit) :\n    coe_fn (prod_punit α) p = prod.fst p :=\n  Eq.refl (coe_fn (prod_punit α) p)\n\n/-- `punit` is a left identity for type product up to an equivalence. -/\n@[simp] theorem punit_prod_apply (α : Type u_1) :\n    ∀ (ᾰ : PUnit × α), coe_fn (punit_prod α) ᾰ = prod.snd ᾰ :=\n  fun (ᾰ : PUnit × α) => Eq.refl (prod.snd ᾰ)\n\n/-- `empty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_empty (α : Type u_1) : α × empty ≃ empty := equiv_empty sorry\n\n/-- `empty` type is a left absorbing element for type product up to an equivalence. -/\ndef empty_prod (α : Type u_1) : empty × α ≃ empty := equiv_empty sorry\n\n/-- `pempty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_pempty (α : Type u_1) : α × pempty ≃ pempty := equiv_pempty sorry\n\n/-- `pempty` type is a left absorbing element for type product up to an equivalence. -/\ndef pempty_prod (α : Type u_1) : pempty × α ≃ pempty := equiv_pempty sorry\n\n/-- `psum` is equivalent to `sum`. -/\ndef psum_equiv_sum (α : Type u_1) (β : Type u_2) : psum α β ≃ α ⊕ β :=\n  mk (fun (s : psum α β) => psum.cases_on s sum.inl sum.inr)\n    (fun (s : α ⊕ β) => sum.cases_on s psum.inl psum.inr) sorry sorry\n\n/-- If `α ≃ α'` and `β ≃ β'`, then `α ⊕ β ≃ α' ⊕ β'`. -/\ndef sum_congr {α₁ : Type u_1} {β₁ : Type u_2} {α₂ : Type u_3} {β₂ : Type u_4} (ea : α₁ ≃ α₂)\n    (eb : β₁ ≃ β₂) : α₁ ⊕ β₁ ≃ α₂ ⊕ β₂ :=\n  mk (sum.map ⇑ea ⇑eb) (sum.map ⇑(equiv.symm ea) ⇑(equiv.symm eb)) sorry sorry\n\n@[simp] theorem sum_congr_trans {α₁ : Type u_1} {α₂ : Type u_2} {β₁ : Type u_3} {β₂ : Type u_4}\n    {γ₁ : Type u_5} {γ₂ : Type u_6} (e : α₁ ≃ β₁) (f : α₂ ≃ β₂) (g : β₁ ≃ γ₁) (h : β₂ ≃ γ₂) :\n    equiv.trans (sum_congr e f) (sum_congr g h) = sum_congr (equiv.trans e g) (equiv.trans f h) :=\n  sorry\n\n@[simp] theorem sum_congr_symm {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4}\n    (e : α ≃ β) (f : γ ≃ δ) :\n    equiv.symm (sum_congr e f) = sum_congr (equiv.symm e) (equiv.symm f) :=\n  rfl\n\n@[simp] theorem sum_congr_refl {α : Type u_1} {β : Type u_2} :\n    sum_congr (equiv.refl α) (equiv.refl β) = equiv.refl (α ⊕ β) :=\n  sorry\n\nnamespace perm\n\n\n/-- Combine a permutation of `α` and of `β` into a permutation of `α ⊕ β`. -/\ndef sum_congr {α : Type u_1} {β : Type u_2} (ea : perm α) (eb : perm β) : perm (α ⊕ β) :=\n  sum_congr ea eb\n\n@[simp] theorem sum_congr_apply {α : Type u_1} {β : Type u_2} (ea : perm α) (eb : perm β)\n    (x : α ⊕ β) : coe_fn (sum_congr ea eb) x = sum.map (⇑ea) (⇑eb) x :=\n  sum_congr_apply ea eb x\n\n@[simp] theorem sum_congr_trans {α : Type u_1} {β : Type u_2} (e : perm α) (f : perm β) (g : perm α)\n    (h : perm β) :\n    equiv.trans (sum_congr e f) (sum_congr g h) = sum_congr (equiv.trans e g) (equiv.trans f h) :=\n  sum_congr_trans e f g h\n\n@[simp] theorem sum_congr_symm {α : Type u_1} {β : Type u_2} (e : perm α) (f : perm β) :\n    equiv.symm (sum_congr e f) = sum_congr (equiv.symm e) (equiv.symm f) :=\n  sum_congr_symm e f\n\n@[simp] theorem sum_congr_refl {α : Type u_1} {β : Type u_2} :\n    sum_congr (equiv.refl α) (equiv.refl β) = equiv.refl (α ⊕ β) :=\n  sum_congr_refl\n\nend perm\n\n\n/-- `bool` is equivalent the sum of two `punit`s. -/\ndef bool_equiv_punit_sum_punit : Bool ≃ PUnit ⊕ PUnit :=\n  mk (fun (b : Bool) => cond b (sum.inr PUnit.unit) (sum.inl PUnit.unit))\n    (fun (s : PUnit ⊕ PUnit) => sum.rec_on s (fun (_x : PUnit) => false) fun (_x : PUnit) => tt)\n    sorry sorry\n\n/-- `Prop` is noncomputably equivalent to `bool`. -/\ndef Prop_equiv_bool : Prop ≃ Bool :=\n  mk (fun (p : Prop) => to_bool p) (fun (b : Bool) => ↥b) sorry sorry\n\n/-- Sum of types is commutative up to an equivalence. -/\n@[simp] theorem sum_comm_apply (α : Type u_1) (β : Type u_2) :\n    ∀ (ᾰ : α ⊕ β), coe_fn (sum_comm α β) ᾰ = sum.swap ᾰ :=\n  fun (ᾰ : α ⊕ β) => Eq.refl (coe_fn (sum_comm α β) ᾰ)\n\n@[simp] theorem sum_comm_symm (α : Type u_1) (β : Type u_2) :\n    equiv.symm (sum_comm α β) = sum_comm β α :=\n  rfl\n\n/-- Sum of types is associative up to an equivalence. -/\ndef sum_assoc (α : Type u_1) (β : Type u_2) (γ : Type u_3) : (α ⊕ β) ⊕ γ ≃ α ⊕ β ⊕ γ :=\n  mk (sum.elim (sum.elim sum.inl (sum.inr ∘ sum.inl)) (sum.inr ∘ sum.inr))\n    (sum.elim (sum.inl ∘ sum.inl) (sum.elim (sum.inl ∘ sum.inr) sum.inr)) sorry sorry\n\n@[simp] theorem sum_assoc_apply_in1 {α : Type u_1} {β : Type u_2} {γ : Type u_3} (a : α) :\n    coe_fn (sum_assoc α β γ) (sum.inl (sum.inl a)) = sum.inl a :=\n  rfl\n\n@[simp] theorem sum_assoc_apply_in2 {α : Type u_1} {β : Type u_2} {γ : Type u_3} (b : β) :\n    coe_fn (sum_assoc α β γ) (sum.inl (sum.inr b)) = sum.inr (sum.inl b) :=\n  rfl\n\n@[simp] theorem sum_assoc_apply_in3 {α : Type u_1} {β : Type u_2} {γ : Type u_3} (c : γ) :\n    coe_fn (sum_assoc α β γ) (sum.inr c) = sum.inr (sum.inr c) :=\n  rfl\n\n/-- Sum with `empty` is equivalent to the original type. -/\ndef sum_empty (α : Type u_1) : α ⊕ empty ≃ α :=\n  mk (sum.elim id (empty.rec fun (n : empty) => α)) sum.inl sorry sorry\n\n@[simp] theorem sum_empty_apply_inl {α : Type u_1} (a : α) : coe_fn (sum_empty α) (sum.inl a) = a :=\n  rfl\n\n/-- The sum of `empty` with any `Sort*` is equivalent to the right summand. -/\ndef empty_sum (α : Type u_1) : empty ⊕ α ≃ α := equiv.trans (sum_comm empty α) (sum_empty α)\n\n@[simp] theorem empty_sum_apply_inr {α : Type u_1} (a : α) : coe_fn (empty_sum α) (sum.inr a) = a :=\n  rfl\n\n/-- Sum with `pempty` is equivalent to the original type. -/\ndef sum_pempty (α : Type u_1) : α ⊕ pempty ≃ α :=\n  mk (sum.elim id (pempty.rec fun (n : pempty) => α)) sum.inl sorry sorry\n\n@[simp] theorem sum_pempty_apply_inl {α : Type u_1} (a : α) :\n    coe_fn (sum_pempty α) (sum.inl a) = a :=\n  rfl\n\n/-- The sum of `pempty` with any `Sort*` is equivalent to the right summand. -/\ndef pempty_sum (α : Type u_1) : pempty ⊕ α ≃ α := equiv.trans (sum_comm pempty α) (sum_pempty α)\n\n@[simp] theorem pempty_sum_apply_inr {α : Type u_1} (a : α) :\n    coe_fn (pempty_sum α) (sum.inr a) = a :=\n  rfl\n\n/-- `option α` is equivalent to `α ⊕ punit` -/\ndef option_equiv_sum_punit (α : Type u_1) : Option α ≃ α ⊕ PUnit :=\n  mk (fun (o : Option α) => sorry) (fun (s : α ⊕ PUnit) => sorry) sorry sorry\n\n@[simp] theorem option_equiv_sum_punit_none {α : Type u_1} :\n    coe_fn (option_equiv_sum_punit α) none = sum.inr PUnit.unit :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_some {α : Type u_1} (a : α) :\n    coe_fn (option_equiv_sum_punit α) (some a) = sum.inl a :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_coe {α : Type u_1} (a : α) :\n    coe_fn (option_equiv_sum_punit α) ↑a = sum.inl a :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_symm_inl {α : Type u_1} (a : α) :\n    coe_fn (equiv.symm (option_equiv_sum_punit α)) (sum.inl a) = ↑a :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_symm_inr {α : Type u_1} (a : PUnit) :\n    coe_fn (equiv.symm (option_equiv_sum_punit α)) (sum.inr a) = none :=\n  rfl\n\n/-- The set of `x : option α` such that `is_some x` is equivalent to `α`. -/\ndef option_is_some_equiv (α : Type u_1) : (Subtype fun (x : Option α) => ↥(option.is_some x)) ≃ α :=\n  mk (fun (o : Subtype fun (x : Option α) => ↥(option.is_some x)) => option.get sorry)\n    (fun (x : α) => { val := some x, property := sorry }) sorry sorry\n\n/-- `α ⊕ β` is equivalent to a `sigma`-type over `bool`. Note that this definition assumes `α` and\n`β` to be types from the same universe, so it cannot by used directly to transfer theorems about\nsigma types to theorems about sum types. In many cases one can use `ulift` to work around this\ndifficulty. -/\ndef sum_equiv_sigma_bool (α : Type u) (β : Type u) : α ⊕ β ≃ sigma fun (b : Bool) => cond b α β :=\n  mk\n    (fun (s : α ⊕ β) => sum.elim (fun (x : α) => sigma.mk tt x) (fun (x : β) => sigma.mk false x) s)\n    (fun (s : sigma fun (b : Bool) => cond b α β) => sorry) sorry sorry\n\n/-- `sigma_preimage_equiv f` for `f : α → β` is the natural equivalence between\nthe type of all fibres of `f` and the total space `α`. -/\n@[simp] theorem sigma_preimage_equiv_symm_apply_fst {α : Type u_1} {β : Type u_2} (f : α → β)\n    (x : α) : sigma.fst (coe_fn (equiv.symm (sigma_preimage_equiv f)) x) = f x :=\n  Eq.refl (sigma.fst (coe_fn (equiv.symm (sigma_preimage_equiv f)) x))\n\n/-- A set `s` in `α × β` is equivalent to the sigma-type `Σ x, {y | (x, y) ∈ s}`. -/\ndef set_prod_equiv_sigma {α : Type u_1} {β : Type u_2} (s : set (α × β)) :\n    ↥s ≃ sigma fun (x : α) => ↥(set_of fun (y : β) => (x, y) ∈ s) :=\n  mk\n    (fun (x : ↥s) =>\n      sigma.mk (prod.fst (subtype.val x)) { val := prod.snd (subtype.val x), property := sorry })\n    (fun (x : sigma fun (x : α) => ↥(set_of fun (y : β) => (x, y) ∈ s)) =>\n      { val := (sigma.fst x, subtype.val (sigma.snd x)), property := sorry })\n    sorry sorry\n\n/-- For any predicate `p` on `α`,\nthe sum of the two subtypes `{a // p a}` and its complement `{a // ¬ p a}`\nis naturally equivalent to `α`. -/\ndef sum_compl {α : Type u_1} (p : α → Prop) [decidable_pred p] :\n    ((Subtype fun (a : α) => p a) ⊕ Subtype fun (a : α) => ¬p a) ≃ α :=\n  mk (sum.elim coe coe)\n    (fun (a : α) =>\n      dite (p a) (fun (h : p a) => sum.inl { val := a, property := h })\n        fun (h : ¬p a) => sum.inr { val := a, property := h })\n    sorry sorry\n\n@[simp] theorem sum_compl_apply_inl {α : Type u_1} (p : α → Prop) [decidable_pred p]\n    (x : Subtype fun (a : α) => p a) : coe_fn (sum_compl p) (sum.inl x) = ↑x :=\n  rfl\n\n@[simp] theorem sum_compl_apply_inr {α : Type u_1} (p : α → Prop) [decidable_pred p]\n    (x : Subtype fun (a : α) => ¬p a) : coe_fn (sum_compl p) (sum.inr x) = ↑x :=\n  rfl\n\n@[simp] theorem sum_compl_apply_symm_of_pos {α : Type u_1} (p : α → Prop) [decidable_pred p] (a : α)\n    (h : p a) : coe_fn (equiv.symm (sum_compl p)) a = sum.inl { val := a, property := h } :=\n  dif_pos h\n\n@[simp] theorem sum_compl_apply_symm_of_neg {α : Type u_1} (p : α → Prop) [decidable_pred p] (a : α)\n    (h : ¬p a) : coe_fn (equiv.symm (sum_compl p)) a = sum.inr { val := a, property := h } :=\n  dif_neg h\n\n/-- For a fixed function `x₀ : {a // p a} → β` defined on a subtype of `α`,\nthe subtype of functions `x : α → β` that agree with `x₀` on the subtype `{a // p a}`\nis naturally equivalent to the type of functions `{a // ¬ p a} → β`. -/\n@[simp] theorem subtype_preimage_apply {α : Sort u} {β : Sort v} (p : α → Prop) [decidable_pred p]\n    (x₀ : (Subtype fun (a : α) => p a) → β) (x : Subtype fun (x : α → β) => x ∘ coe = x₀)\n    (a : Subtype fun (a : α) => ¬p a) : coe_fn (subtype_preimage p x₀) x a = coe x ↑a :=\n  Eq.refl (coe_fn (subtype_preimage p x₀) x a)\n\ntheorem subtype_preimage_symm_apply_coe_pos {α : Sort u} {β : Sort v} (p : α → Prop)\n    [decidable_pred p] (x₀ : (Subtype fun (a : α) => p a) → β)\n    (x : (Subtype fun (a : α) => ¬p a) → β) (a : α) (h : p a) :\n    coe (coe_fn (equiv.symm (subtype_preimage p x₀)) x) a = x₀ { val := a, property := h } :=\n  dif_pos h\n\ntheorem subtype_preimage_symm_apply_coe_neg {α : Sort u} {β : Sort v} (p : α → Prop)\n    [decidable_pred p] (x₀ : (Subtype fun (a : α) => p a) → β)\n    (x : (Subtype fun (a : α) => ¬p a) → β) (a : α) (h : ¬p a) :\n    coe (coe_fn (equiv.symm (subtype_preimage p x₀)) x) a = x { val := a, property := h } :=\n  dif_neg h\n\n/-- If `α` has a unique term, then the type of function `α → β` is equivalent to `β`. -/\n@[simp] theorem fun_unique_apply (α : Sort u) (β : Sort v) [unique α] (f : α → β) :\n    coe_fn (fun_unique α β) f = f Inhabited.default :=\n  Eq.refl (coe_fn (fun_unique α β) f)\n\n/-- A family of equivalences `Π a, β₁ a ≃ β₂ a` generates an equivalence between `Π a, β₁ a` and\n`Π a, β₂ a`. -/\ndef Pi_congr_right {α : Sort u_1} {β₁ : α → Sort u_2} {β₂ : α → Sort u_3}\n    (F : (a : α) → β₁ a ≃ β₂ a) : ((a : α) → β₁ a) ≃ ((a : α) → β₂ a) :=\n  mk (fun (H : (a : α) → β₁ a) (a : α) => coe_fn (F a) (H a))\n    (fun (H : (a : α) → β₂ a) (a : α) => coe_fn (equiv.symm (F a)) (H a)) sorry sorry\n\n/-- Dependent `curry` equivalence: the type of dependent functions on `Σ i, β i` is equivalent\nto the type of dependent functions of two arguments (i.e., functions to the space of functions). -/\ndef Pi_curry {α : Type u_1} {β : α → Type u_2} (γ : (a : α) → β a → Sort u_3) :\n    ((x : sigma fun (i : α) => β i) → γ (sigma.fst x) (sigma.snd x)) ≃\n        ((a : α) → (b : β a) → γ a b) :=\n  mk\n    (fun (f : (x : sigma fun (i : α) => β i) → γ (sigma.fst x) (sigma.snd x)) (x : α) (y : β x) =>\n      f (sigma.mk x y))\n    (fun (f : (a : α) → (b : β a) → γ a b) (x : sigma fun (i : α) => β i) =>\n      f (sigma.fst x) (sigma.snd x))\n    sorry sorry\n\n/-- A `psigma`-type is equivalent to the corresponding `sigma`-type. -/\ndef psigma_equiv_sigma {α : Type u_1} (β : α → Type u_2) :\n    (psigma fun (i : α) => β i) ≃ sigma fun (i : α) => β i :=\n  mk (fun (a : psigma fun (i : α) => β i) => sigma.mk (psigma.fst a) (psigma.snd a))\n    (fun (a : sigma fun (i : α) => β i) => psigma.mk (sigma.fst a) (sigma.snd a)) sorry sorry\n\n/-- A family of equivalences `Π a, β₁ a ≃ β₂ a` generates an equivalence between `Σ a, β₁ a` and\n`Σ a, β₂ a`. -/\n@[simp] theorem sigma_congr_right_apply {α : Type u_1} {β₁ : α → Type u_2} {β₂ : α → Type u_3}\n    (F : (a : α) → β₁ a ≃ β₂ a) (a : sigma fun (a : α) => β₁ a) :\n    coe_fn (sigma_congr_right F) a =\n        sigma.mk (sigma.fst a) (coe_fn (F (sigma.fst a)) (sigma.snd a)) :=\n  Eq.refl (coe_fn (sigma_congr_right F) a)\n\n@[simp] theorem sigma_congr_right_trans {α : Type u_1} {β₁ : α → Type u_2} {β₂ : α → Type u_3}\n    {β₃ : α → Type u_4} (F : (a : α) → β₁ a ≃ β₂ a) (G : (a : α) → β₂ a ≃ β₃ a) :\n    equiv.trans (sigma_congr_right F) (sigma_congr_right G) =\n        sigma_congr_right fun (a : α) => equiv.trans (F a) (G a) :=\n  sorry\n\n@[simp] theorem sigma_congr_right_symm {α : Type u_1} {β₁ : α → Type u_2} {β₂ : α → Type u_3}\n    (F : (a : α) → β₁ a ≃ β₂ a) :\n    equiv.symm (sigma_congr_right F) = sigma_congr_right fun (a : α) => equiv.symm (F a) :=\n  sorry\n\n@[simp] theorem sigma_congr_right_refl {α : Type u_1} {β : α → Type u_2} :\n    (sigma_congr_right fun (a : α) => equiv.refl (β a)) = equiv.refl (sigma fun (a : α) => β a) :=\n  sorry\n\nnamespace perm\n\n\n/-- A family of permutations `Π a, perm (β a)` generates a permuation `perm (Σ a, β₁ a)`. -/\ndef sigma_congr_right {α : Type u_1} {β : α → Type u_2} (F : (a : α) → perm (β a)) :\n    perm (sigma fun (a : α) => β a) :=\n  sigma_congr_right F\n\n@[simp] theorem sigma_congr_right_trans {α : Type u_1} {β : α → Type u_2} (F : (a : α) → perm (β a))\n    (G : (a : α) → perm (β a)) :\n    equiv.trans (sigma_congr_right F) (sigma_congr_right G) =\n        sigma_congr_right fun (a : α) => equiv.trans (F a) (G a) :=\n  sigma_congr_right_trans F G\n\n@[simp] theorem sigma_congr_right_symm {α : Type u_1} {β : α → Type u_2}\n    (F : (a : α) → perm (β a)) :\n    equiv.symm (sigma_congr_right F) = sigma_congr_right fun (a : α) => equiv.symm (F a) :=\n  sigma_congr_right_symm F\n\n@[simp] theorem sigma_congr_right_refl {α : Type u_1} {β : α → Type u_2} :\n    (sigma_congr_right fun (a : α) => equiv.refl (β a)) = equiv.refl (sigma fun (a : α) => β a) :=\n  sigma_congr_right_refl\n\nend perm\n\n\n/-- An equivalence `f : α₁ ≃ α₂` generates an equivalence between `Σ a, β (f a)` and `Σ a, β a`. -/\ndef sigma_congr_left {α₁ : Type u_1} {α₂ : Type u_2} {β : α₂ → Type u_3} (e : α₁ ≃ α₂) :\n    (sigma fun (a : α₁) => β (coe_fn e a)) ≃ sigma fun (a : α₂) => β a :=\n  mk\n    (fun (a : sigma fun (a : α₁) => β (coe_fn e a)) =>\n      sigma.mk (coe_fn e (sigma.fst a)) (sigma.snd a))\n    (fun (a : sigma fun (a : α₂) => β a) =>\n      sigma.mk (coe_fn (equiv.symm e) (sigma.fst a)) (Eq._oldrec (sigma.snd a) sorry))\n    sorry sorry\n\n/-- Transporting a sigma type through an equivalence of the base -/\ndef sigma_congr_left' {α₁ : Type u_1} {α₂ : Type u_2} {β : α₁ → Type u_3} (f : α₁ ≃ α₂) :\n    (sigma fun (a : α₁) => β a) ≃ sigma fun (a : α₂) => β (coe_fn (equiv.symm f) a) :=\n  equiv.symm (sigma_congr_left (equiv.symm f))\n\n/-- Transporting a sigma type through an equivalence of the base and a family of equivalences\nof matching fibers -/\ndef sigma_congr {α₁ : Type u_1} {α₂ : Type u_2} {β₁ : α₁ → Type u_3} {β₂ : α₂ → Type u_4}\n    (f : α₁ ≃ α₂) (F : (a : α₁) → β₁ a ≃ β₂ (coe_fn f a)) : sigma β₁ ≃ sigma β₂ :=\n  equiv.trans (sigma_congr_right F) (sigma_congr_left f)\n\n/-- `sigma` type with a constant fiber is equivalent to the product. -/\n@[simp] theorem sigma_equiv_prod_symm_apply (α : Type u_1) (β : Type u_2) (a : α × β) :\n    coe_fn (equiv.symm (sigma_equiv_prod α β)) a = sigma.mk (prod.fst a) (prod.snd a) :=\n  Eq.refl (coe_fn (equiv.symm (sigma_equiv_prod α β)) a)\n\n/-- If each fiber of a `sigma` type is equivalent to a fixed type, then the sigma type\nis equivalent to the product. -/\ndef sigma_equiv_prod_of_equiv {α : Type u_1} {β : Type u_2} {β₁ : α → Type u_3}\n    (F : (a : α) → β₁ a ≃ β) : sigma β₁ ≃ α × β :=\n  equiv.trans (sigma_congr_right F) (sigma_equiv_prod α β)\n\n/-- A family of equivalences `Π (a : α₁), β₁ ≃ β₂` generates an equivalence\nbetween `β₁ × α₁` and `β₂ × α₁`. -/\ndef prod_congr_left {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3} (e : α₁ → β₁ ≃ β₂) :\n    β₁ × α₁ ≃ β₂ × α₁ :=\n  mk (fun (ab : β₁ × α₁) => (coe_fn (e (prod.snd ab)) (prod.fst ab), prod.snd ab))\n    (fun (ab : β₂ × α₁) => (coe_fn (equiv.symm (e (prod.snd ab))) (prod.fst ab), prod.snd ab)) sorry\n    sorry\n\n@[simp] theorem prod_congr_left_apply {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3}\n    (e : α₁ → β₁ ≃ β₂) (b : β₁) (a : α₁) :\n    coe_fn (prod_congr_left e) (b, a) = (coe_fn (e a) b, a) :=\n  rfl\n\ntheorem prod_congr_refl_right {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3} (e : β₁ ≃ β₂) :\n    prod_congr e (equiv.refl α₁) = prod_congr_left fun (_x : α₁) => e :=\n  sorry\n\n/-- A family of equivalences `Π (a : α₁), β₁ ≃ β₂` generates an equivalence\nbetween `α₁ × β₁` and `α₁ × β₂`. -/\ndef prod_congr_right {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3} (e : α₁ → β₁ ≃ β₂) :\n    α₁ × β₁ ≃ α₁ × β₂ :=\n  mk (fun (ab : α₁ × β₁) => (prod.fst ab, coe_fn (e (prod.fst ab)) (prod.snd ab)))\n    (fun (ab : α₁ × β₂) => (prod.fst ab, coe_fn (equiv.symm (e (prod.fst ab))) (prod.snd ab))) sorry\n    sorry\n\n@[simp] theorem prod_congr_right_apply {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3}\n    (e : α₁ → β₁ ≃ β₂) (a : α₁) (b : β₁) :\n    coe_fn (prod_congr_right e) (a, b) = (a, coe_fn (e a) b) :=\n  rfl\n\ntheorem prod_congr_refl_left {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3} (e : β₁ ≃ β₂) :\n    prod_congr (equiv.refl α₁) e = prod_congr_right fun (_x : α₁) => e :=\n  sorry\n\n@[simp] theorem prod_congr_left_trans_prod_comm {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3}\n    (e : α₁ → β₁ ≃ β₂) :\n    equiv.trans (prod_congr_left e) (prod_comm β₂ α₁) =\n        equiv.trans (prod_comm β₁ α₁) (prod_congr_right e) :=\n  sorry\n\n@[simp] theorem prod_congr_right_trans_prod_comm {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3}\n    (e : α₁ → β₁ ≃ β₂) :\n    equiv.trans (prod_congr_right e) (prod_comm α₁ β₂) =\n        equiv.trans (prod_comm α₁ β₁) (prod_congr_left e) :=\n  sorry\n\ntheorem sigma_congr_right_sigma_equiv_prod {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3}\n    (e : α₁ → β₁ ≃ β₂) :\n    equiv.trans (sigma_congr_right e) (sigma_equiv_prod α₁ β₂) =\n        equiv.trans (sigma_equiv_prod α₁ β₁) (prod_congr_right e) :=\n  sorry\n\ntheorem sigma_equiv_prod_sigma_congr_right {α₁ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3}\n    (e : α₁ → β₁ ≃ β₂) :\n    equiv.trans (equiv.symm (sigma_equiv_prod α₁ β₁)) (sigma_congr_right e) =\n        equiv.trans (prod_congr_right e) (equiv.symm (sigma_equiv_prod α₁ β₂)) :=\n  sorry\n\n/-- A variation on `equiv.prod_congr` where the equivalence in the second component can depend\n  on the first component. A typical example is a shear mapping, explaining the name of this\n  declaration. -/\n@[simp] theorem prod_shear_symm_apply {α₁ : Type u_1} {β₁ : Type u_2} {α₂ : Type u_3}\n    {β₂ : Type u_4} (e₁ : α₁ ≃ α₂) (e₂ : α₁ → β₁ ≃ β₂) :\n    ⇑(equiv.symm (prod_shear e₁ e₂)) =\n        fun (y : α₂ × β₂) =>\n          (coe_fn (equiv.symm e₁) (prod.fst y),\n          coe_fn (equiv.symm (e₂ (coe_fn (equiv.symm e₁) (prod.fst y)))) (prod.snd y)) :=\n  Eq.refl ⇑(equiv.symm (prod_shear e₁ e₂))\n\nnamespace perm\n\n\n/-- `prod_extend_right a e` extends `e : perm β` to `perm (α × β)` by sending `(a, b)` to\n`(a, e b)` and keeping the other `(a', b)` fixed. -/\ndef prod_extend_right {α₁ : Type u_1} {β₁ : Type u_2} [DecidableEq α₁] (a : α₁) (e : perm β₁) :\n    perm (α₁ × β₁) :=\n  mk (fun (ab : α₁ × β₁) => ite (prod.fst ab = a) (a, coe_fn e (prod.snd ab)) ab)\n    (fun (ab : α₁ × β₁) => ite (prod.fst ab = a) (a, coe_fn (equiv.symm e) (prod.snd ab)) ab) sorry\n    sorry\n\n@[simp] theorem prod_extend_right_apply_eq {α₁ : Type u_1} {β₁ : Type u_2} [DecidableEq α₁] (a : α₁)\n    (e : perm β₁) (b : β₁) : coe_fn (prod_extend_right a e) (a, b) = (a, coe_fn e b) :=\n  if_pos rfl\n\ntheorem prod_extend_right_apply_ne {α₁ : Type u_1} {β₁ : Type u_2} [DecidableEq α₁] (e : perm β₁)\n    {a : α₁} {a' : α₁} (h : a' ≠ a) (b : β₁) : coe_fn (prod_extend_right a e) (a', b) = (a', b) :=\n  if_neg h\n\ntheorem eq_of_prod_extend_right_ne {α₁ : Type u_1} {β₁ : Type u_2} [DecidableEq α₁] {e : perm β₁}\n    {a : α₁} {a' : α₁} {b : β₁} (h : coe_fn (prod_extend_right a e) (a', b) ≠ (a', b)) : a' = a :=\n  sorry\n\n@[simp] theorem fst_prod_extend_right {α₁ : Type u_1} {β₁ : Type u_2} [DecidableEq α₁] (a : α₁)\n    (e : perm β₁) (ab : α₁ × β₁) : prod.fst (coe_fn (prod_extend_right a e) ab) = prod.fst ab :=\n  sorry\n\nend perm\n\n\n/-- The type of functions to a product `α × β` is equivalent to the type of pairs of functions\n`γ → α` and `γ → β`. -/\ndef arrow_prod_equiv_prod_arrow (α : Type u_1) (β : Type u_2) (γ : Type u_3) :\n    (γ → α × β) ≃ (γ → α) × (γ → β) :=\n  mk (fun (f : γ → α × β) => (fun (c : γ) => prod.fst (f c), fun (c : γ) => prod.snd (f c)))\n    (fun (p : (γ → α) × (γ → β)) (c : γ) => (prod.fst p c, prod.snd p c)) sorry sorry\n\n/-- Functions `α → β → γ` are equivalent to functions on `α × β`. -/\ndef arrow_arrow_equiv_prod_arrow (α : Type u_1) (β : Type u_2) (γ : Type u_3) :\n    (α → β → γ) ≃ (α × β → γ) :=\n  mk function.uncurry function.curry function.curry_uncurry function.uncurry_curry\n\n/-- The type of functions on a sum type `α ⊕ β` is equivalent to the type of pairs of functions\non `α` and on `β`. -/\ndef sum_arrow_equiv_prod_arrow (α : Type u_1) (β : Type u_2) (γ : Type u_3) :\n    (α ⊕ β → γ) ≃ (α → γ) × (β → γ) :=\n  mk (fun (f : α ⊕ β → γ) => (f ∘ sum.inl, f ∘ sum.inr))\n    (fun (p : (α → γ) × (β → γ)) => sum.elim (prod.fst p) (prod.snd p)) sorry sorry\n\n/-- Type product is right distributive with respect to type sum up to an equivalence. -/\ndef sum_prod_distrib (α : Type u_1) (β : Type u_2) (γ : Type u_3) : (α ⊕ β) × γ ≃ α × γ ⊕ β × γ :=\n  mk (fun (p : (α ⊕ β) × γ) => sorry) (fun (s : α × γ ⊕ β × γ) => sorry) sorry sorry\n\n@[simp] theorem sum_prod_distrib_apply_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} (a : α)\n    (c : γ) : coe_fn (sum_prod_distrib α β γ) (sum.inl a, c) = sum.inl (a, c) :=\n  rfl\n\n@[simp] theorem sum_prod_distrib_apply_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} (b : β)\n    (c : γ) : coe_fn (sum_prod_distrib α β γ) (sum.inr b, c) = sum.inr (b, c) :=\n  rfl\n\n/-- Type product is left distributive with respect to type sum up to an equivalence. -/\ndef prod_sum_distrib (α : Type u_1) (β : Type u_2) (γ : Type u_3) : α × (β ⊕ γ) ≃ α × β ⊕ α × γ :=\n  equiv.trans (equiv.trans (prod_comm α (β ⊕ γ)) (sum_prod_distrib β γ α))\n    (sum_congr (prod_comm β α) (prod_comm γ α))\n\n@[simp] theorem prod_sum_distrib_apply_left {α : Type u_1} {β : Type u_2} {γ : Type u_3} (a : α)\n    (b : β) : coe_fn (prod_sum_distrib α β γ) (a, sum.inl b) = sum.inl (a, b) :=\n  rfl\n\n@[simp] theorem prod_sum_distrib_apply_right {α : Type u_1} {β : Type u_2} {γ : Type u_3} (a : α)\n    (c : γ) : coe_fn (prod_sum_distrib α β γ) (a, sum.inr c) = sum.inr (a, c) :=\n  rfl\n\n/-- The product of an indexed sum of types (formally, a `sigma`-type `Σ i, α i`) by a type `β` is\nequivalent to the sum of products `Σ i, (α i × β)`. -/\ndef sigma_prod_distrib {ι : Type u_1} (α : ι → Type u_2) (β : Type u_3) :\n    (sigma fun (i : ι) => α i) × β ≃ sigma fun (i : ι) => α i × β :=\n  mk\n    (fun (p : (sigma fun (i : ι) => α i) × β) =>\n      sigma.mk (sigma.fst (prod.fst p)) (sigma.snd (prod.fst p), prod.snd p))\n    (fun (p : sigma fun (i : ι) => α i × β) =>\n      (sigma.mk (sigma.fst p) (prod.fst (sigma.snd p)), prod.snd (sigma.snd p)))\n    sorry sorry\n\n/-- The product `bool × α` is equivalent to `α ⊕ α`. -/\ndef bool_prod_equiv_sum (α : Type u) : Bool × α ≃ α ⊕ α :=\n  equiv.trans\n    (equiv.trans (prod_congr bool_equiv_punit_sum_punit (equiv.refl α))\n      (sum_prod_distrib Unit Unit α))\n    (sum_congr (punit_prod α) (punit_prod α))\n\n/-- The function type `bool → α` is equivalent to `α × α`. -/\ndef bool_to_equiv_prod (α : Type u) : (Bool → α) ≃ α × α :=\n  equiv.trans\n    (equiv.trans (arrow_congr bool_equiv_punit_sum_punit (equiv.refl α))\n      (sum_arrow_equiv_prod_arrow Unit Unit α))\n    (prod_congr (punit_arrow_equiv α) (punit_arrow_equiv α))\n\n@[simp] theorem bool_to_equiv_prod_apply {α : Type u} (f : Bool → α) :\n    coe_fn (bool_to_equiv_prod α) f = (f false, f tt) :=\n  rfl\n\n@[simp] theorem bool_to_equiv_prod_symm_apply_ff {α : Type u} (p : α × α) :\n    coe_fn (equiv.symm (bool_to_equiv_prod α)) p false = prod.fst p :=\n  rfl\n\n@[simp] theorem bool_to_equiv_prod_symm_apply_tt {α : Type u} (p : α × α) :\n    coe_fn (equiv.symm (bool_to_equiv_prod α)) p tt = prod.snd p :=\n  rfl\n\n/-- The set of natural numbers is equivalent to `ℕ ⊕ punit`. -/\ndef nat_equiv_nat_sum_punit : ℕ ≃ ℕ ⊕ PUnit :=\n  mk (fun (n : ℕ) => sorry) (fun (s : ℕ ⊕ PUnit) => sorry) sorry sorry\n\n/-- `ℕ ⊕ punit` is equivalent to `ℕ`. -/\ndef nat_sum_punit_equiv_nat : ℕ ⊕ PUnit ≃ ℕ := equiv.symm nat_equiv_nat_sum_punit\n\n/-- The type of integer numbers is equivalent to `ℕ ⊕ ℕ`. -/\ndef int_equiv_nat_sum_nat : ℤ ≃ ℕ ⊕ ℕ :=\n  mk (fun (z : ℤ) => int.cases_on z (fun (z : ℕ) => sum.inl z) fun (z : ℕ) => sum.inr z)\n    (fun (z : ℕ ⊕ ℕ) => sum.cases_on z (fun (z : ℕ) => Int.ofNat z) fun (z : ℕ) => Int.negSucc z)\n    sorry sorry\n\n/-- An equivalence between `α` and `β` generates an equivalence between `list α` and `list β`. -/\ndef list_equiv_of_equiv {α : Type u_1} {β : Type u_2} (e : α ≃ β) : List α ≃ List β :=\n  mk (list.map ⇑e) (list.map ⇑(equiv.symm e)) sorry sorry\n\n/-- `fin n` is equivalent to `{m // m < n}`. -/\ndef fin_equiv_subtype (n : ℕ) : fin n ≃ Subtype fun (m : ℕ) => m < n :=\n  mk (fun (x : fin n) => { val := subtype.val x, property := sorry })\n    (fun (x : Subtype fun (m : ℕ) => m < n) => { val := subtype.val x, property := sorry }) sorry\n    sorry\n\n/-- If `α` is equivalent to `β`, then `unique α` is equivalent to `β`. -/\ndef unique_congr {α : Sort u} {β : Sort v} (e : α ≃ β) : unique α ≃ unique β :=\n  mk (fun (h : unique α) => equiv.unique (equiv.symm e)) (fun (h : unique β) => equiv.unique e)\n    sorry sorry\n\n/-- If `α` is equivalent to `β` and the predicates `p : α → Prop` and `q : β → Prop` are equivalent\nat corresponding points, then `{a // p a}` is equivalent to `{b // q b}`. -/\ndef subtype_congr {α : Sort u} {β : Sort v} {p : α → Prop} {q : β → Prop} (e : α ≃ β)\n    (h : ∀ (a : α), p a ↔ q (coe_fn e a)) :\n    (Subtype fun (a : α) => p a) ≃ Subtype fun (b : β) => q b :=\n  mk (fun (x : Subtype fun (a : α) => p a) => { val := coe_fn e ↑x, property := sorry })\n    (fun (y : Subtype fun (b : β) => q b) => { val := coe_fn (equiv.symm e) ↑y, property := sorry })\n    sorry sorry\n\n@[simp] theorem subtype_congr_apply {α : Sort u} {β : Sort v} {p : α → Prop} {q : β → Prop}\n    (e : α ≃ β) (h : ∀ (a : α), p a ↔ q (coe_fn e a)) (x : Subtype fun (x : α) => p x) :\n    coe_fn (subtype_congr e h) x =\n        { val := coe_fn e ↑x, property := iff.mp (h ↑x) (subtype.property x) } :=\n  rfl\n\n@[simp] theorem subtype_congr_symm_apply {α : Sort u} {β : Sort v} {p : α → Prop} {q : β → Prop}\n    (e : α ≃ β) (h : ∀ (a : α), p a ↔ q (coe_fn e a)) (y : Subtype fun (y : β) => q y) :\n    coe_fn (equiv.symm (subtype_congr e h)) y =\n        { val := coe_fn (equiv.symm e) ↑y,\n          property :=\n            iff.mpr (h (coe_fn (equiv.symm e) ↑y))\n              (Eq.symm (apply_symm_apply e ↑y) ▸ subtype.property y) } :=\n  rfl\n\n/-- If two predicates `p` and `q` are pointwise equivalent, then `{x // p x}` is equivalent to\n`{x // q x}`. -/\ndef subtype_congr_right {α : Sort u} {p : α → Prop} {q : α → Prop} (e : ∀ (x : α), p x ↔ q x) :\n    (Subtype fun (x : α) => p x) ≃ Subtype fun (x : α) => q x :=\n  subtype_congr (equiv.refl α) e\n\n/-- If `α ≃ β`, then for any predicate `p : β → Prop` the subtype `{a // p (e a)}` is equivalent\nto the subtype `{b // p b}`. -/\ndef subtype_equiv_of_subtype {α : Sort u} {β : Sort v} {p : β → Prop} (e : α ≃ β) :\n    (Subtype fun (a : α) => p (coe_fn e a)) ≃ Subtype fun (b : β) => p b :=\n  subtype_congr e sorry\n\n/-- If `α ≃ β`, then for any predicate `p : α → Prop` the subtype `{a // p a}` is equivalent\nto the subtype `{b // p (e.symm b)}`. This version is used by `equiv_rw`. -/\ndef subtype_equiv_of_subtype' {α : Sort u} {β : Sort v} {p : α → Prop} (e : α ≃ β) :\n    (Subtype fun (a : α) => p a) ≃ Subtype fun (b : β) => p (coe_fn (equiv.symm e) b) :=\n  equiv.symm (subtype_equiv_of_subtype (equiv.symm e))\n\n/-- If two predicates are equal, then the corresponding subtypes are equivalent. -/\ndef subtype_congr_prop {α : Type u_1} {p : α → Prop} {q : α → Prop} (h : p = q) :\n    Subtype p ≃ Subtype q :=\n  subtype_congr (equiv.refl α) sorry\n\n/-- The subtypes corresponding to equal sets are equivalent. -/\ndef set_congr {α : Type u_1} {s : set α} {t : set α} (h : s = t) : ↥s ≃ ↥t := subtype_congr_prop h\n\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. This\nversion allows the “inner” predicate to depend on `h : p a`. -/\ndef subtype_subtype_equiv_subtype_exists {α : Type u} (p : α → Prop) (q : Subtype p → Prop) :\n    Subtype q ≃ Subtype fun (a : α) => ∃ (h : p a), q { val := a, property := h } :=\n  mk (fun (_x : Subtype q) => sorry)\n    (fun (_x : Subtype fun (a : α) => ∃ (h : p a), q { val := a, property := h }) => sorry) sorry\n    sorry\n\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. -/\ndef subtype_subtype_equiv_subtype_inter {α : Type u} (p : α → Prop) (q : α → Prop) :\n    (Subtype fun (x : Subtype p) => q (subtype.val x)) ≃ Subtype fun (x : α) => p x ∧ q x :=\n  equiv.trans (subtype_subtype_equiv_subtype_exists p fun (x : Subtype p) => q (subtype.val x))\n    (subtype_congr_right sorry)\n\n/-- If the outer subtype has more restrictive predicate than the inner one,\nthen we can drop the latter. -/\ndef subtype_subtype_equiv_subtype {α : Type u} {p : α → Prop} {q : α → Prop}\n    (h : ∀ {x : α}, q x → p x) : (Subtype fun (x : Subtype p) => q (subtype.val x)) ≃ Subtype q :=\n  equiv.trans (subtype_subtype_equiv_subtype_inter p q) (subtype_congr_right sorry)\n\n/-- If a proposition holds for all elements, then the subtype is\nequivalent to the original type. -/\ndef subtype_univ_equiv {α : Type u} {p : α → Prop} (h : ∀ (x : α), p x) : Subtype p ≃ α :=\n  mk (fun (x : Subtype p) => ↑x) (fun (x : α) => { val := x, property := h x }) sorry sorry\n\n/-- A subtype of a sigma-type is a sigma-type over a subtype. -/\ndef subtype_sigma_equiv {α : Type u} (p : α → Type v) (q : α → Prop) :\n    (Subtype fun (y : sigma p) => q (sigma.fst y)) ≃\n        sigma fun (x : Subtype q) => p (subtype.val x) :=\n  mk\n    (fun (x : Subtype fun (y : sigma p) => q (sigma.fst y)) =>\n      sigma.mk { val := sigma.fst (subtype.val x), property := sorry } (sigma.snd (subtype.val x)))\n    (fun (x : sigma fun (x : Subtype q) => p (subtype.val x)) =>\n      { val := sigma.mk (subtype.val (sigma.fst x)) (sigma.snd x), property := sorry })\n    sorry sorry\n\n/-- A sigma type over a subtype is equivalent to the sigma set over the original type,\nif the fiber is empty outside of the subset -/\ndef sigma_subtype_equiv_of_subset {α : Type u} (p : α → Type v) (q : α → Prop)\n    (h : ∀ (x : α), p x → q x) : (sigma fun (x : Subtype q) => p ↑x) ≃ sigma fun (x : α) => p x :=\n  equiv.trans (equiv.symm (subtype_sigma_equiv p q)) (subtype_univ_equiv sorry)\n\n/-- If a predicate `p : β → Prop` is true on the range of a map `f : α → β`, then\n`Σ y : {y // p y}, {x // f x = y}` is equivalent to `α`. -/\ndef sigma_subtype_preimage_equiv {α : Type u} {β : Type v} (f : α → β) (p : β → Prop)\n    (h : ∀ (x : α), p (f x)) : (sigma fun (y : Subtype p) => Subtype fun (x : α) => f x = ↑y) ≃ α :=\n  equiv.trans\n    (sigma_subtype_equiv_of_subset (fun (y : β) => Subtype fun (x : α) => f x = y) p sorry)\n    (sigma_preimage_equiv f)\n\n/-- If for each `x` we have `p x ↔ q (f x)`, then `Σ y : {y // q y}, f ⁻¹' {y}` is equivalent\nto `{x // p x}`. -/\ndef sigma_subtype_preimage_equiv_subtype {α : Type u} {β : Type v} (f : α → β) {p : α → Prop}\n    {q : β → Prop} (h : ∀ (x : α), p x ↔ q (f x)) :\n    (sigma fun (y : Subtype q) => Subtype fun (x : α) => f x = ↑y) ≃ Subtype p :=\n  equiv.trans\n    (sigma_congr_right\n      fun (y : Subtype q) =>\n        equiv.symm\n          (equiv.trans\n            (subtype_subtype_equiv_subtype_exists p\n              fun (x : Subtype p) => { val := f ↑x, property := sorry } = y)\n            (subtype_congr_right sorry)))\n    (sigma_preimage_equiv fun (x : Subtype p) => { val := f ↑x, property := sorry })\n\n/-- The `pi`-type `Π i, π i` is equivalent to the type of sections `f : ι → Σ i, π i` of the\n`sigma` type such that for all `i` we have `(f i).fst = i`. -/\ndef pi_equiv_subtype_sigma (ι : Type u_1) (π : ι → Type u_2) :\n    ((i : ι) → π i) ≃\n        ↥(set_of fun (f : ι → sigma fun (i : ι) => π i) => ∀ (i : ι), sigma.fst (f i) = i) :=\n  mk (fun (f : (i : ι) → π i) => { val := fun (i : ι) => sigma.mk i (f i), property := sorry })\n    (fun (f : ↥(set_of fun (f : ι → sigma fun (i : ι) => π i) => ∀ (i : ι), sigma.fst (f i) = i))\n      (i : ι) => eq.mpr sorry (sigma.snd (subtype.val f i)))\n    sorry sorry\n\n/-- The set of functions `f : Π a, β a` such that for all `a` we have `p a (f a)` is equivalent\nto the set of functions `Π a, {b : β a // p a b}`. -/\ndef subtype_pi_equiv_pi {α : Sort u} {β : α → Sort v} {p : (a : α) → β a → Prop} :\n    (Subtype fun (f : (a : α) → β a) => ∀ (a : α), p a (f a)) ≃\n        ((a : α) → Subtype fun (b : β a) => p a b) :=\n  mk\n    (fun (f : Subtype fun (f : (a : α) → β a) => ∀ (a : α), p a (f a)) (a : α) =>\n      { val := subtype.val f a, property := sorry })\n    (fun (f : (a : α) → Subtype fun (b : β a) => p a b) =>\n      { val := fun (a : α) => subtype.val (f a), property := sorry })\n    sorry sorry\n\n/-- A subtype of a product defined by componentwise conditions\nis equivalent to a product of subtypes. -/\ndef subtype_prod_equiv_prod {α : Type u} {β : Type v} {p : α → Prop} {q : β → Prop} :\n    (Subtype fun (c : α × β) => p (prod.fst c) ∧ q (prod.snd c)) ≃\n        (Subtype fun (a : α) => p a) × Subtype fun (b : β) => q b :=\n  mk\n    (fun (x : Subtype fun (c : α × β) => p (prod.fst c) ∧ q (prod.snd c)) =>\n      ({ val := prod.fst (subtype.val x), property := sorry },\n      { val := prod.snd (subtype.val x), property := sorry }))\n    (fun (x : (Subtype fun (a : α) => p a) × Subtype fun (b : β) => q b) =>\n      { val := (subtype.val (prod.fst x), subtype.val (prod.snd x)), property := sorry })\n    sorry sorry\n\n/-- The type of all functions `X → Y` with prescribed values for all `x' ≠ x`\nis equivalent to the codomain `Y`. -/\ndef subtype_equiv_codomain {X : Type u_1} {Y : Type u_2} [DecidableEq X] {x : X}\n    (f : (Subtype fun (x' : X) => x' ≠ x) → Y) : (Subtype fun (g : X → Y) => g ∘ coe = f) ≃ Y :=\n  equiv.trans (subtype_preimage (fun (x' : X) => x' ≠ x) f)\n    (fun_unique (Subtype fun (a : X) => ¬a ≠ x) Y)\n\n@[simp] theorem coe_subtype_equiv_codomain {X : Type u_1} {Y : Type u_2} [DecidableEq X] {x : X}\n    (f : (Subtype fun (x' : X) => x' ≠ x) → Y) :\n    ⇑(subtype_equiv_codomain f) = fun (g : Subtype fun (g : X → Y) => g ∘ coe = f) => coe g x :=\n  rfl\n\n@[simp] theorem subtype_equiv_codomain_apply {X : Type u_1} {Y : Type u_2} [DecidableEq X] {x : X}\n    (f : (Subtype fun (x' : X) => x' ≠ x) → Y) (g : Subtype fun (g : X → Y) => g ∘ coe = f) :\n    coe_fn (subtype_equiv_codomain f) g = coe g x :=\n  rfl\n\ntheorem coe_subtype_equiv_codomain_symm {X : Type u_1} {Y : Type u_2} [DecidableEq X] {x : X}\n    (f : (Subtype fun (x' : X) => x' ≠ x) → Y) :\n    ⇑(equiv.symm (subtype_equiv_codomain f)) =\n        fun (y : Y) =>\n          { val :=\n              fun (x' : X) =>\n                dite (x' ≠ x) (fun (h : x' ≠ x) => f { val := x', property := h })\n                  fun (h : ¬x' ≠ x) => y,\n            property :=\n              funext\n                fun (x' : Subtype fun (x' : X) => x' ≠ x) =>\n                  id\n                    (eq.mpr\n                      (id\n                        (Eq._oldrec\n                          (Eq.refl\n                            ((dite (¬↑x' = x)\n                                (fun (h : ¬↑x' = x) => f { val := ↑x', property := h })\n                                fun (h : ¬¬↑x' = x) => y) =\n                              f x'))\n                          (dif_pos (subtype.property x'))))\n                      (eq.mpr\n                        (id\n                          (Eq._oldrec\n                            (Eq.refl (f { val := ↑x', property := subtype.property x' } = f x'))\n                            (subtype.coe_eta x' (subtype.property x'))))\n                        (Eq.refl (f x')))) } :=\n  rfl\n\n@[simp] theorem subtype_equiv_codomain_symm_apply {X : Type u_1} {Y : Type u_2} [DecidableEq X]\n    {x : X} (f : (Subtype fun (x' : X) => x' ≠ x) → Y) (y : Y) (x' : X) :\n    coe (coe_fn (equiv.symm (subtype_equiv_codomain f)) y) x' =\n        dite (x' ≠ x) (fun (h : x' ≠ x) => f { val := x', property := h }) fun (h : ¬x' ≠ x) => y :=\n  rfl\n\n@[simp] theorem subtype_equiv_codomain_symm_apply_eq {X : Type u_1} {Y : Type u_2} [DecidableEq X]\n    {x : X} (f : (Subtype fun (x' : X) => x' ≠ x) → Y) (y : Y) :\n    coe (coe_fn (equiv.symm (subtype_equiv_codomain f)) y) x = y :=\n  dif_neg (iff.mpr not_not rfl)\n\ntheorem subtype_equiv_codomain_symm_apply_ne {X : Type u_1} {Y : Type u_2} [DecidableEq X] {x : X}\n    (f : (Subtype fun (x' : X) => x' ≠ x) → Y) (y : Y) (x' : X) (h : x' ≠ x) :\n    coe (coe_fn (equiv.symm (subtype_equiv_codomain f)) y) x' = f { val := x', property := h } :=\n  dif_pos h\n\nnamespace set\n\n\n/-- `univ α` is equivalent to `α`. -/\n@[simp] theorem univ_symm_apply (α : Type u_1) (a : α) :\n    coe_fn (equiv.symm (set.univ α)) a = { val := a, property := trivial } :=\n  Eq.refl (coe_fn (equiv.symm (set.univ α)) a)\n\n/-- An empty set is equivalent to the `empty` type. -/\nprotected def empty (α : Type u_1) : ↥∅ ≃ empty := equiv_empty sorry\n\n/-- An empty set is equivalent to a `pempty` type. -/\nprotected def pempty (α : Type u_1) : ↥∅ ≃ pempty := equiv_pempty sorry\n\n/-- If sets `s` and `t` are separated by a decidable predicate, then `s ∪ t` is equivalent to\n`s ⊕ t`. -/\nprotected def union' {α : Type u_1} {s : set α} {t : set α} (p : α → Prop) [decidable_pred p]\n    (hs : ∀ (x : α), x ∈ s → p x) (ht : ∀ (x : α), x ∈ t → ¬p x) : ↥(s ∪ t) ≃ ↥s ⊕ ↥t :=\n  mk\n    (fun (x : ↥(s ∪ t)) =>\n      dite (p ↑x) (fun (hp : p ↑x) => sum.inl { val := subtype.val x, property := sorry })\n        fun (hp : ¬p ↑x) => sum.inr { val := subtype.val x, property := sorry })\n    (fun (o : ↥s ⊕ ↥t) => sorry) sorry sorry\n\n/-- If sets `s` and `t` are disjoint, then `s ∪ t` is equivalent to `s ⊕ t`. -/\nprotected def union {α : Type u_1} {s : set α} {t : set α} [decidable_pred fun (x : α) => x ∈ s]\n    (H : s ∩ t ⊆ ∅) : ↥(s ∪ t) ≃ ↥s ⊕ ↥t :=\n  set.union' (fun (x : α) => x ∈ s) sorry sorry\n\ntheorem union_apply_left {α : Type u_1} {s : set α} {t : set α}\n    [decidable_pred fun (x : α) => x ∈ s] (H : s ∩ t ⊆ ∅) {a : ↥(s ∪ t)} (ha : ↑a ∈ s) :\n    coe_fn (set.union H) a = sum.inl { val := ↑a, property := ha } :=\n  dif_pos ha\n\ntheorem union_apply_right {α : Type u_1} {s : set α} {t : set α}\n    [decidable_pred fun (x : α) => x ∈ s] (H : s ∩ t ⊆ ∅) {a : ↥(s ∪ t)} (ha : ↑a ∈ t) :\n    coe_fn (set.union H) a = sum.inr { val := ↑a, property := ha } :=\n  dif_neg fun (h : ↑a ∈ s) => H { left := h, right := ha }\n\n@[simp] theorem union_symm_apply_left {α : Type u_1} {s : set α} {t : set α}\n    [decidable_pred fun (x : α) => x ∈ s] (H : s ∩ t ⊆ ∅) (a : ↥s) :\n    coe_fn (equiv.symm (set.union H)) (sum.inl a) =\n        { val := ↑a, property := set.subset_union_left s t (subtype.property a) } :=\n  rfl\n\n@[simp] theorem union_symm_apply_right {α : Type u_1} {s : set α} {t : set α}\n    [decidable_pred fun (x : α) => x ∈ s] (H : s ∩ t ⊆ ∅) (a : ↥t) :\n    coe_fn (equiv.symm (set.union H)) (sum.inr a) =\n        { val := ↑a, property := set.subset_union_right s t (subtype.property a) } :=\n  rfl\n\n-- TODO: Any reason to use the same universe?\n\n/-- A singleton set is equivalent to a `punit` type. -/\nprotected def singleton {α : Type u_1} (a : α) : ↥(singleton a) ≃ PUnit :=\n  mk (fun (_x : ↥(singleton a)) => PUnit.unit)\n    (fun (_x : PUnit) => { val := a, property := set.mem_singleton a }) sorry sorry\n\n/-- Equal sets are equivalent. -/\n@[simp] theorem of_eq_symm_apply {α : Type u} {s : set α} {t : set α} (h : s = t) (x : ↥t) :\n    coe_fn (equiv.symm (set.of_eq h)) x = { val := ↑x, property := of_eq._proof_2 h x } :=\n  Eq.refl (coe_fn (equiv.symm (set.of_eq h)) x)\n\n/-- If `a ∉ s`, then `insert a s` is equivalent to `s ⊕ punit`. -/\nprotected def insert {α : Type u} {s : set α} [decidable_pred s] {a : α} (H : ¬a ∈ s) :\n    ↥(insert a s) ≃ ↥s ⊕ PUnit :=\n  equiv.trans (equiv.trans (set.of_eq sorry) (set.union sorry))\n    (sum_congr (equiv.refl ↥s) (set.singleton a))\n\n@[simp] theorem insert_symm_apply_inl {α : Type u} {s : set α} [decidable_pred s] {a : α}\n    (H : ¬a ∈ s) (b : ↥s) :\n    coe_fn (equiv.symm (set.insert H)) (sum.inl b) =\n        { val := ↑b, property := Or.inr (subtype.property b) } :=\n  rfl\n\n@[simp] theorem insert_symm_apply_inr {α : Type u} {s : set α} [decidable_pred s] {a : α}\n    (H : ¬a ∈ s) (b : PUnit) :\n    coe_fn (equiv.symm (set.insert H)) (sum.inr b) = { val := a, property := Or.inl rfl } :=\n  rfl\n\n@[simp] theorem insert_apply_left {α : Type u} {s : set α} [decidable_pred s] {a : α} (H : ¬a ∈ s) :\n    coe_fn (set.insert H) { val := a, property := Or.inl rfl } = sum.inr PUnit.unit :=\n  iff.mpr (apply_eq_iff_eq_symm_apply (set.insert H)) rfl\n\n@[simp] theorem insert_apply_right {α : Type u} {s : set α} [decidable_pred s] {a : α} (H : ¬a ∈ s)\n    (b : ↥s) :\n    coe_fn (set.insert H) { val := ↑b, property := Or.inr (subtype.property b) } = sum.inl b :=\n  iff.mpr (apply_eq_iff_eq_symm_apply (set.insert H)) rfl\n\n/-- If `s : set α` is a set with decidable membership, then `s ⊕ sᶜ` is equivalent to `α`. -/\nprotected def sum_compl {α : Type u_1} (s : set α) [decidable_pred s] : ↥s ⊕ ↥(sᶜ) ≃ α :=\n  equiv.trans (equiv.trans (equiv.symm (set.union sorry)) (set.of_eq sorry)) (set.univ α)\n\n@[simp] theorem sum_compl_apply_inl {α : Type u} (s : set α) [decidable_pred s] (x : ↥s) :\n    coe_fn (set.sum_compl s) (sum.inl x) = ↑x :=\n  rfl\n\n@[simp] theorem sum_compl_apply_inr {α : Type u} (s : set α) [decidable_pred s] (x : ↥(sᶜ)) :\n    coe_fn (set.sum_compl s) (sum.inr x) = ↑x :=\n  rfl\n\ntheorem sum_compl_symm_apply_of_mem {α : Type u} {s : set α} [decidable_pred s] {x : α}\n    (hx : x ∈ s) : coe_fn (equiv.symm (set.sum_compl s)) x = sum.inl { val := x, property := hx } :=\n  sorry\n\ntheorem sum_compl_symm_apply_of_not_mem {α : Type u} {s : set α} [decidable_pred s] {x : α}\n    (hx : ¬x ∈ s) :\n    coe_fn (equiv.symm (set.sum_compl s)) x = sum.inr { val := x, property := hx } :=\n  sorry\n\n@[simp] theorem sum_compl_symm_apply {α : Type u_1} {s : set α} [decidable_pred s] {x : ↥s} :\n    coe_fn (equiv.symm (set.sum_compl s)) ↑x = sum.inl x :=\n  subtype.cases_on x fun (x : α) (hx : x ∈ s) => sum_compl_symm_apply_of_mem hx\n\n@[simp] theorem sum_compl_symm_apply_compl {α : Type u_1} {s : set α} [decidable_pred s]\n    {x : ↥(sᶜ)} : coe_fn (equiv.symm (set.sum_compl s)) ↑x = sum.inr x :=\n  subtype.cases_on x fun (x : α) (hx : x ∈ (sᶜ)) => sum_compl_symm_apply_of_not_mem hx\n\n/-- `sum_diff_subset s t` is the natural equivalence between\n`s ⊕ (t \\ s)` and `t`, where `s` and `t` are two sets. -/\nprotected def sum_diff_subset {α : Type u_1} {s : set α} {t : set α} (h : s ⊆ t)\n    [decidable_pred s] : ↥s ⊕ ↥(t \\ s) ≃ ↥t :=\n  equiv.trans (equiv.symm (set.union sorry)) (set.of_eq sorry)\n\n@[simp] theorem sum_diff_subset_apply_inl {α : Type u_1} {s : set α} {t : set α} (h : s ⊆ t)\n    [decidable_pred s] (x : ↥s) : coe_fn (set.sum_diff_subset h) (sum.inl x) = set.inclusion h x :=\n  rfl\n\n@[simp] theorem sum_diff_subset_apply_inr {α : Type u_1} {s : set α} {t : set α} (h : s ⊆ t)\n    [decidable_pred s] (x : ↥(t \\ s)) :\n    coe_fn (set.sum_diff_subset h) (sum.inr x) = set.inclusion (set.diff_subset t s) x :=\n  rfl\n\ntheorem sum_diff_subset_symm_apply_of_mem {α : Type u_1} {s : set α} {t : set α} (h : s ⊆ t)\n    [decidable_pred s] {x : ↥t} (hx : subtype.val x ∈ s) :\n    coe_fn (equiv.symm (set.sum_diff_subset h)) x = sum.inl { val := ↑x, property := hx } :=\n  sorry\n\ntheorem sum_diff_subset_symm_apply_of_not_mem {α : Type u_1} {s : set α} {t : set α} (h : s ⊆ t)\n    [decidable_pred s] {x : ↥t} (hx : ¬subtype.val x ∈ s) :\n    coe_fn (equiv.symm (set.sum_diff_subset h)) x =\n        sum.inr { val := ↑x, property := { left := subtype.property x, right := hx } } :=\n  sorry\n\n/-- If `s` is a set with decidable membership, then the sum of `s ∪ t` and `s ∩ t` is equivalent\nto `s ⊕ t`. -/\nprotected def union_sum_inter {α : Type u} (s : set α) (t : set α) [decidable_pred s] :\n    ↥(s ∪ t) ⊕ ↥(s ∩ t) ≃ ↥s ⊕ ↥t :=\n  equiv.trans\n    (equiv.trans\n      (equiv.trans\n        (equiv.trans (eq.mpr sorry (equiv.refl (↥(s ∪ t) ⊕ ↥(s ∩ t))))\n          (sum_congr (set.union sorry) (equiv.refl ↥(s ∩ t))))\n        (sum_assoc ↥s ↥(t \\ s) ↥(s ∩ t)))\n      (sum_congr (equiv.refl ↥s) (equiv.symm (set.union' (fun (_x : α) => ¬_x ∈ s) sorry sorry))))\n    (eq.mpr sorry (equiv.refl (↥s ⊕ ↥t)))\n\n/-- Given an equivalence `e₀` between sets `s : set α` and `t : set β`, the set of equivalences\n`e : α ≃ β` such that `e ↑x = ↑(e₀ x)` for each `x : s` is equivalent to the set of equivalences\nbetween `sᶜ` and `tᶜ`. -/\nprotected def compl {α : Type u} {β : Type v} {s : set α} {t : set β} [decidable_pred s]\n    [decidable_pred t] (e₀ : ↥s ≃ ↥t) :\n    (Subtype fun (e : α ≃ β) => ∀ (x : ↥s), coe_fn e ↑x = ↑(coe_fn e₀ x)) ≃ (↥(sᶜ) ≃ ↥(tᶜ)) :=\n  mk\n    (fun (e : Subtype fun (e : α ≃ β) => ∀ (x : ↥s), coe_fn e ↑x = ↑(coe_fn e₀ x)) =>\n      subtype_congr ↑e sorry)\n    (fun (e₁ : ↥(sᶜ) ≃ ↥(tᶜ)) =>\n      { val :=\n          equiv.trans (equiv.trans (equiv.symm (set.sum_compl s)) (sum_congr e₀ e₁))\n            (set.sum_compl t),\n        property := sorry })\n    sorry sorry\n\n/-- The set product of two sets is equivalent to the type product of their coercions to types. -/\nprotected def prod {α : Type u_1} {β : Type u_2} (s : set α) (t : set β) :\n    ↥(set.prod s t) ≃ ↥s × ↥t :=\n  subtype_prod_equiv_prod\n\n/-- If a function `f` is injective on a set `s`, then `s` is equivalent to `f '' s`. -/\nprotected def image_of_inj_on {α : Type u_1} {β : Type u_2} (f : α → β) (s : set α)\n    (H : set.inj_on f s) : ↥s ≃ ↥(f '' s) :=\n  mk (fun (p : ↥s) => { val := f ↑p, property := sorry })\n    (fun (p : ↥(f '' s)) => { val := classical.some sorry, property := sorry }) sorry sorry\n\n/-- If `f` is an injective function, then `s` is equivalent to `f '' s`. -/\n@[simp] theorem image_apply {α : Type u_1} {β : Type u_2} (f : α → β) (s : set α)\n    (H : function.injective f) (p : ↥s) :\n    coe_fn (set.image f s H) p = { val := f ↑p, property := image_of_inj_on._proof_1 f s p } :=\n  Eq.refl { val := f ↑p, property := image_of_inj_on._proof_1 f s p }\n\ntheorem image_symm_preimage {α : Type u_1} {β : Type u_2} {f : α → β} (hf : function.injective f)\n    (u : set α) (s : set α) :\n    (fun (x : ↥(f '' s)) => ↑(coe_fn (equiv.symm (set.image f s hf)) x)) ⁻¹' u = coe ⁻¹' (f '' u) :=\n  sorry\n\n/-- If `f : α → β` is an injective function, then `α` is equivalent to the range of `f`. -/\n@[simp] theorem range_apply {α : Sort u_1} {β : Type u_2} (f : α → β) (H : function.injective f)\n    (x : α) : coe_fn (set.range f H) x = { val := f x, property := set.mem_range_self x } :=\n  Eq.refl (coe_fn (set.range f H) x)\n\ntheorem apply_range_symm {α : Sort u_1} {β : Type u_2} (f : α → β) (H : function.injective f)\n    (b : ↥(set.range f)) : f (coe_fn (equiv.symm (set.range f H)) b) = ↑b :=\n  sorry\n\n/-- If `α` is equivalent to `β`, then `set α` is equivalent to `set β`. -/\nprotected def congr {α : Type u_1} {β : Type u_2} (e : α ≃ β) : set α ≃ set β :=\n  mk (fun (s : set α) => ⇑e '' s) (fun (t : set β) => ⇑(equiv.symm e) '' t) (symm_image_image e)\n    sorry\n\n/-- The set `{x ∈ s | t x}` is equivalent to the set of `x : s` such that `t x`. -/\nprotected def sep {α : Type u} (s : set α) (t : α → Prop) :\n    ↥(has_sep.sep (fun (x : α) => t x) s) ≃ ↥(set_of fun (x : ↥s) => t ↑x) :=\n  equiv.symm (subtype_subtype_equiv_subtype_inter s t)\n\n/-- The set `𝒫 S := {x | x ⊆ S}` is equivalent to the type `set S`. -/\nprotected def powerset {α : Type u_1} (S : set α) : ↥(𝒫 S) ≃ set ↥S :=\n  mk (fun (x : ↥(𝒫 S)) => coe ⁻¹' ↑x) (fun (x : set ↥S) => { val := coe '' x, property := sorry })\n    sorry sorry\n\nend set\n\n\n/-- If `f` is a bijective function, then its domain is equivalent to its codomain. -/\ndef of_bijective {α : Sort u_1} {β : Type u_2} (f : α → β) (hf : function.bijective f) : α ≃ β :=\n  equiv.trans (set.range f sorry) (equiv.trans (set_congr sorry) (set.univ β))\n\ntheorem of_bijective_apply_symm_apply {α : Sort u_1} {β : Type u_2} (f : α → β)\n    (hf : function.bijective f) (x : β) : f (coe_fn (equiv.symm (of_bijective f hf)) x) = x :=\n  apply_symm_apply (of_bijective f hf) x\n\n@[simp] theorem of_bijective_symm_apply_apply {α : Sort u_1} {β : Type u_2} (f : α → β)\n    (hf : function.bijective f) (x : α) : coe_fn (equiv.symm (of_bijective f hf)) (f x) = x :=\n  symm_apply_apply (of_bijective f hf) x\n\n/-- If `f` is an injective function, then its domain is equivalent to its range. -/\n@[simp] theorem of_injective_apply {α : Sort u_1} {β : Type u_2} (f : α → β)\n    (hf : function.injective f) :\n    ∀ (ᾰ : α), coe_fn (of_injective f hf) ᾰ = { val := f ᾰ, property := set.mem_range_self ᾰ } :=\n  fun (ᾰ : α) => Eq.refl { val := f ᾰ, property := set.mem_range_self ᾰ }\n\n/-- Subtype of the quotient is equivalent to the quotient of the subtype. Let `α` be a setoid with\nequivalence relation `~`. Let `p₂` be a predicate on the quotient type `α/~`, and `p₁` be the lift\nof this predicate to `α`: `p₁ a ↔ p₂ ⟦a⟧`. Let `~₂` be the restriction of `~` to `{x // p₁ x}`.\nThen `{x // p₂ x}` is equivalent to the quotient of `{x // p₁ x}` by `~₂`. -/\ndef subtype_quotient_equiv_quotient_subtype {α : Sort u} (p₁ : α → Prop) [s₁ : setoid α]\n    [s₂ : setoid (Subtype p₁)] (p₂ : quotient s₁ → Prop)\n    (hp₂ : ∀ (a : α), p₁ a ↔ p₂ (quotient.mk a))\n    (h : ∀ (x y : Subtype p₁), setoid.r x y ↔ ↑x ≈ ↑y) :\n    (Subtype fun (x : quotient s₁) => p₂ x) ≃ quotient s₂ :=\n  mk\n    (fun (a : Subtype fun (x : quotient s₁) => p₂ x) =>\n      quotient.hrec_on (subtype.val a)\n        (fun (a : α) (h : p₂ (quotient.mk a)) => quotient.mk { val := a, property := sorry }) sorry\n        sorry)\n    (fun (a : quotient s₂) =>\n      quotient.lift_on a\n        (fun (a : Subtype p₁) => { val := quotient.mk (subtype.val a), property := sorry }) sorry)\n    sorry sorry\n\n/-- A helper function for `equiv.swap`. -/\ndef swap_core {α : Sort u} [DecidableEq α] (a : α) (b : α) (r : α) : α :=\n  ite (r = a) b (ite (r = b) a r)\n\ntheorem swap_core_self {α : Sort u} [DecidableEq α] (r : α) (a : α) : swap_core a a r = r := sorry\n\ntheorem swap_core_swap_core {α : Sort u} [DecidableEq α] (r : α) (a : α) (b : α) :\n    swap_core a b (swap_core a b r) = r :=\n  sorry\n\ntheorem swap_core_comm {α : Sort u} [DecidableEq α] (r : α) (a : α) (b : α) :\n    swap_core a b r = swap_core b a r :=\n  sorry\n\n/-- `swap a b` is the permutation that swaps `a` and `b` and\n  leaves other values as is. -/\ndef swap {α : Sort u} [DecidableEq α] (a : α) (b : α) : perm α :=\n  mk (swap_core a b) (swap_core a b) sorry sorry\n\n@[simp] theorem swap_self {α : Sort u} [DecidableEq α] (a : α) : swap a a = equiv.refl α :=\n  ext fun (r : α) => swap_core_self r a\n\ntheorem swap_comm {α : Sort u} [DecidableEq α] (a : α) (b : α) : swap a b = swap b a :=\n  ext fun (r : α) => swap_core_comm r a b\n\ntheorem swap_apply_def {α : Sort u} [DecidableEq α] (a : α) (b : α) (x : α) :\n    coe_fn (swap a b) x = ite (x = a) b (ite (x = b) a x) :=\n  rfl\n\n@[simp] theorem swap_apply_left {α : Sort u} [DecidableEq α] (a : α) (b : α) :\n    coe_fn (swap a b) a = b :=\n  if_pos rfl\n\n@[simp] theorem swap_apply_right {α : Sort u} [DecidableEq α] (a : α) (b : α) :\n    coe_fn (swap a b) b = a :=\n  sorry\n\ntheorem swap_apply_of_ne_of_ne {α : Sort u} [DecidableEq α] {a : α} {b : α} {x : α} :\n    x ≠ a → x ≠ b → coe_fn (swap a b) x = x :=\n  sorry\n\n@[simp] theorem swap_swap {α : Sort u} [DecidableEq α] (a : α) (b : α) :\n    equiv.trans (swap a b) (swap a b) = equiv.refl α :=\n  ext fun (x : α) => swap_core_swap_core x a b\n\ntheorem swap_comp_apply {α : Sort u} [DecidableEq α] {a : α} {b : α} {x : α} (π : perm α) :\n    coe_fn (equiv.trans π (swap a b)) x =\n        ite (coe_fn π x = a) b (ite (coe_fn π x = b) a (coe_fn π x)) :=\n  sorry\n\ntheorem swap_eq_update {α : Sort u} [DecidableEq α] (i : α) (j : α) :\n    ⇑(swap i j) = function.update (function.update id j i) i j :=\n  sorry\n\ntheorem comp_swap_eq_update {α : Sort u} {β : Sort v} [DecidableEq α] (i : α) (j : α) (f : α → β) :\n    f ∘ ⇑(swap i j) = function.update (function.update f j (f i)) i (f j) :=\n  sorry\n\n@[simp] theorem symm_trans_swap_trans {α : Sort u} {β : Sort v} [DecidableEq α] [DecidableEq β]\n    (a : α) (b : α) (e : α ≃ β) :\n    equiv.trans (equiv.trans (equiv.symm e) (swap a b)) e = swap (coe_fn e a) (coe_fn e b) :=\n  sorry\n\n@[simp] theorem trans_swap_trans_symm {α : Sort u} {β : Sort v} [DecidableEq α] [DecidableEq β]\n    (a : β) (b : β) (e : α ≃ β) :\n    equiv.trans (equiv.trans e (swap a b)) (equiv.symm e) =\n        swap (coe_fn (equiv.symm e) a) (coe_fn (equiv.symm e) b) :=\n  symm_trans_swap_trans a b (equiv.symm e)\n\n@[simp] theorem swap_apply_self {α : Sort u} [DecidableEq α] (i : α) (j : α) (a : α) :\n    coe_fn (swap i j) (coe_fn (swap i j) a) = a :=\n  sorry\n\n/-- A function is invariant to a swap if it is equal at both elements -/\ntheorem apply_swap_eq_self {α : Sort u} {β : Sort v} [DecidableEq α] {v : α → β} {i : α} {j : α}\n    (hv : v i = v j) (k : α) : v (coe_fn (swap i j) k) = v k :=\n  sorry\n\nnamespace perm\n\n\n@[simp] theorem sum_congr_swap_refl {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β]\n    (i : α) (j : α) : sum_congr (swap i j) (equiv.refl β) = swap (sum.inl i) (sum.inl j) :=\n  sorry\n\n@[simp] theorem sum_congr_refl_swap {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β]\n    (i : β) (j : β) : sum_congr (equiv.refl α) (swap i j) = swap (sum.inr i) (sum.inr j) :=\n  sorry\n\nend perm\n\n\n/-- Augment an equivalence with a prescribed mapping `f a = b` -/\ndef set_value {α : Sort u} {β : Sort v} [DecidableEq α] (f : α ≃ β) (a : α) (b : β) : α ≃ β :=\n  equiv.trans (swap a (coe_fn (equiv.symm f) b)) f\n\n@[simp] theorem set_value_eq {α : Sort u} {β : Sort v} [DecidableEq α] (f : α ≃ β) (a : α) (b : β) :\n    coe_fn (set_value f a b) a = b :=\n  sorry\n\nprotected theorem exists_unique_congr {α : Sort u} {β : Sort v} {p : α → Prop} {q : β → Prop}\n    (f : α ≃ β) (h : ∀ {x : α}, p x ↔ q (coe_fn f x)) :\n    (exists_unique fun (x : α) => p x) ↔ exists_unique fun (y : β) => q y :=\n  sorry\n\nprotected theorem exists_unique_congr_left' {α : Sort u} {β : Sort v} {p : α → Prop} (f : α ≃ β) :\n    (exists_unique fun (x : α) => p x) ↔ exists_unique fun (y : β) => p (coe_fn (equiv.symm f) y) :=\n  sorry\n\nprotected theorem exists_unique_congr_left {α : Sort u} {β : Sort v} {p : β → Prop} (f : α ≃ β) :\n    (exists_unique fun (x : α) => p (coe_fn f x)) ↔ exists_unique fun (y : β) => p y :=\n  iff.symm (equiv.exists_unique_congr_left' (equiv.symm f))\n\nprotected theorem forall_congr {α : Sort u} {β : Sort v} {p : α → Prop} {q : β → Prop} (f : α ≃ β)\n    (h : ∀ {x : α}, p x ↔ q (coe_fn f x)) : (∀ (x : α), p x) ↔ ∀ (y : β), q y :=\n  sorry\n\nprotected theorem forall_congr' {α : Sort u} {β : Sort v} {p : α → Prop} {q : β → Prop} (f : α ≃ β)\n    (h : ∀ {x : β}, p (coe_fn (equiv.symm f) x) ↔ q x) : (∀ (x : α), p x) ↔ ∀ (y : β), q y :=\n  iff.symm (equiv.forall_congr (equiv.symm f) fun (x : β) => iff.symm h)\n\n-- We next build some higher arity versions of `equiv.forall_congr`.\n\n-- Although they appear to just be repeated applications of `equiv.forall_congr`,\n\n-- unification of metavariables works better with these versions.\n\n-- In particular, they are necessary in `equiv_rw`.\n\n-- (Stopping at ternary functions seems reasonable: at least in 1-categorical mathematics,\n\n-- it's rare to have axioms involving more than 3 elements at once.)\n\nprotected theorem forall₂_congr {α₁ : Sort ua1} {α₂ : Sort ua2} {β₁ : Sort ub1} {β₂ : Sort ub2}\n    {p : α₁ → β₁ → Prop} {q : α₂ → β₂ → Prop} (eα : α₁ ≃ α₂) (eβ : β₁ ≃ β₂)\n    (h : ∀ {x : α₁} {y : β₁}, p x y ↔ q (coe_fn eα x) (coe_fn eβ y)) :\n    (∀ (x : α₁) (y : β₁), p x y) ↔ ∀ (x : α₂) (y : β₂), q x y :=\n  equiv.forall_congr eα fun (x : α₁) => equiv.forall_congr eβ fun (x_1 : β₁) => h\n\nprotected theorem forall₂_congr' {α₁ : Sort ua1} {α₂ : Sort ua2} {β₁ : Sort ub1} {β₂ : Sort ub2}\n    {p : α₁ → β₁ → Prop} {q : α₂ → β₂ → Prop} (eα : α₁ ≃ α₂) (eβ : β₁ ≃ β₂)\n    (h : ∀ {x : α₂} {y : β₂}, p (coe_fn (equiv.symm eα) x) (coe_fn (equiv.symm eβ) y) ↔ q x y) :\n    (∀ (x : α₁) (y : β₁), p x y) ↔ ∀ (x : α₂) (y : β₂), q x y :=\n  iff.symm (equiv.forall₂_congr (equiv.symm eα) (equiv.symm eβ) fun (x : α₂) (y : β₂) => iff.symm h)\n\nprotected theorem forall₃_congr {α₁ : Sort ua1} {α₂ : Sort ua2} {β₁ : Sort ub1} {β₂ : Sort ub2}\n    {γ₁ : Sort ug1} {γ₂ : Sort ug2} {p : α₁ → β₁ → γ₁ → Prop} {q : α₂ → β₂ → γ₂ → Prop}\n    (eα : α₁ ≃ α₂) (eβ : β₁ ≃ β₂) (eγ : γ₁ ≃ γ₂)\n    (h : ∀ {x : α₁} {y : β₁} {z : γ₁}, p x y z ↔ q (coe_fn eα x) (coe_fn eβ y) (coe_fn eγ z)) :\n    (∀ (x : α₁) (y : β₁) (z : γ₁), p x y z) ↔ ∀ (x : α₂) (y : β₂) (z : γ₂), q x y z :=\n  equiv.forall₂_congr eα eβ fun (x : α₁) (y : β₁) => equiv.forall_congr eγ fun (x_1 : γ₁) => h\n\nprotected theorem forall₃_congr' {α₁ : Sort ua1} {α₂ : Sort ua2} {β₁ : Sort ub1} {β₂ : Sort ub2}\n    {γ₁ : Sort ug1} {γ₂ : Sort ug2} {p : α₁ → β₁ → γ₁ → Prop} {q : α₂ → β₂ → γ₂ → Prop}\n    (eα : α₁ ≃ α₂) (eβ : β₁ ≃ β₂) (eγ : γ₁ ≃ γ₂)\n    (h :\n      ∀ {x : α₂} {y : β₂} {z : γ₂},\n        p (coe_fn (equiv.symm eα) x) (coe_fn (equiv.symm eβ) y) (coe_fn (equiv.symm eγ) z) ↔\n          q x y z) :\n    (∀ (x : α₁) (y : β₁) (z : γ₁), p x y z) ↔ ∀ (x : α₂) (y : β₂) (z : γ₂), q x y z :=\n  iff.symm\n    (equiv.forall₃_congr (equiv.symm eα) (equiv.symm eβ) (equiv.symm eγ)\n      fun (x : α₂) (y : β₂) (z : γ₂) => iff.symm h)\n\nprotected theorem forall_congr_left' {α : Sort u} {β : Sort v} {p : α → Prop} (f : α ≃ β) :\n    (∀ (x : α), p x) ↔ ∀ (y : β), p (coe_fn (equiv.symm f) y) :=\n  sorry\n\nprotected theorem forall_congr_left {α : Sort u} {β : Sort v} {p : β → Prop} (f : α ≃ β) :\n    (∀ (x : α), p (coe_fn f x)) ↔ ∀ (y : β), p y :=\n  iff.symm (equiv.forall_congr_left' (equiv.symm f))\n\n/--\nTransport dependent functions through an equivalence of the base space.\n-/\n@[simp] theorem Pi_congr_left'_symm_apply {α : Sort u} {β : Sort v} (P : α → Sort w) (e : α ≃ β)\n    (f : (b : β) → P (coe_fn (equiv.symm e) b)) (x : α) :\n    coe_fn (equiv.symm (Pi_congr_left' P e)) f x =\n        eq.mpr (Pi_congr_left'._proof_1 P e x) (f (coe_fn e x)) :=\n  Eq.refl (coe_fn (equiv.symm (Pi_congr_left' P e)) f x)\n\n/--\nTransporting dependent functions through an equivalence of the base,\nexpressed as a \"simplification\".\n-/\ndef Pi_congr_left {α : Sort u} {β : Sort v} (P : β → Sort w) (e : α ≃ β) :\n    ((a : α) → P (coe_fn e a)) ≃ ((b : β) → P b) :=\n  equiv.symm (Pi_congr_left' P (equiv.symm e))\n\n/--\nTransport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibers.\n-/\ndef Pi_congr {α : Sort u} {β : Sort v} {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β)\n    (h₂ : (a : α) → W a ≃ Z (coe_fn h₁ a)) : ((a : α) → W a) ≃ ((b : β) → Z b) :=\n  equiv.trans (Pi_congr_right h₂) (Pi_congr_left Z h₁)\n\n/--\nTransport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibres.\n-/\ndef Pi_congr' {α : Sort u} {β : Sort v} {W : α → Sort w} {Z : β → Sort z} (h₁ : α ≃ β)\n    (h₂ : (b : β) → W (coe_fn (equiv.symm h₁) b) ≃ Z b) : ((a : α) → W a) ≃ ((b : β) → Z b) :=\n  equiv.symm (Pi_congr (equiv.symm h₁) fun (b : β) => equiv.symm (h₂ b))\n\nend equiv\n\n\ntheorem function.injective.swap_apply {α : Sort u} {β : Sort v} [DecidableEq α] [DecidableEq β]\n    {f : α → β} (hf : function.injective f) (x : α) (y : α) (z : α) :\n    coe_fn (equiv.swap (f x) (f y)) (f z) = f (coe_fn (equiv.swap x y) z) :=\n  sorry\n\ntheorem function.injective.swap_comp {α : Sort u} {β : Sort v} [DecidableEq α] [DecidableEq β]\n    {f : α → β} (hf : function.injective f) (x : α) (y : α) :\n    ⇑(equiv.swap (f x) (f y)) ∘ f = f ∘ ⇑(equiv.swap x y) :=\n  funext fun (z : α) => function.injective.swap_apply hf x y z\n\nprotected instance ulift.subsingleton {α : Type u_1} [subsingleton α] : subsingleton (ulift α) :=\n  equiv.subsingleton equiv.ulift\n\nprotected instance plift.subsingleton {α : Sort u_1} [subsingleton α] : subsingleton (plift α) :=\n  equiv.subsingleton equiv.plift\n\nprotected instance ulift.decidable_eq {α : Type u_1} [DecidableEq α] : DecidableEq (ulift α) :=\n  equiv.decidable_eq equiv.ulift\n\nprotected instance plift.decidable_eq {α : Sort u_1} [DecidableEq α] : DecidableEq (plift α) :=\n  equiv.decidable_eq equiv.plift\n\n/-- If both `α` and `β` are singletons, then `α ≃ β`. -/\ndef equiv_of_unique_of_unique {α : Sort u} {β : Sort v} [unique α] [unique β] : α ≃ β :=\n  equiv.mk (fun (_x : α) => Inhabited.default) (fun (_x : β) => Inhabited.default) sorry sorry\n\n/-- If `α` is a singleton, then it is equivalent to any `punit`. -/\ndef equiv_punit_of_unique {α : Sort u} [unique α] : α ≃ PUnit := equiv_of_unique_of_unique\n\n/-- If `α` is a subsingleton, then it is equivalent to `α × α`. -/\ndef subsingleton_prod_self_equiv {α : Type u_1} [subsingleton α] : α × α ≃ α :=\n  equiv.mk (fun (p : α × α) => prod.fst p) (fun (a : α) => (a, a)) sorry sorry\n\n/-- To give an equivalence between two subsingleton types, it is sufficient to give any two\n    functions between them. -/\ndef equiv_of_subsingleton_of_subsingleton {α : Sort u} {β : Sort v} [subsingleton α]\n    [subsingleton β] (f : α → β) (g : β → α) : α ≃ β :=\n  equiv.mk f g sorry sorry\n\n/-- `unique (unique α)` is equivalent to `unique α`. -/\ndef unique_unique_equiv {α : Sort u} : unique (unique α) ≃ unique α :=\n  equiv_of_subsingleton_of_subsingleton (fun (h : unique (unique α)) => Inhabited.default)\n    fun (h : unique α) => unique.mk { default := h } sorry\n\nnamespace quot\n\n\n/-- An equivalence `e : α ≃ β` generates an equivalence between quotient spaces,\nif `ra a₁ a₂ ↔ rb (e a₁) (e a₂). -/\nprotected def congr {α : Sort u} {β : Sort v} {ra : α → α → Prop} {rb : β → β → Prop} (e : α ≃ β)\n    (eq : ∀ (a₁ a₂ : α), ra a₁ a₂ ↔ rb (coe_fn e a₁) (coe_fn e a₂)) : Quot ra ≃ Quot rb :=\n  equiv.mk (quot.map ⇑e sorry) (quot.map ⇑(equiv.symm e) sorry) sorry sorry\n\n/-- Quotients are congruent on equivalences under equality of their relation.\nAn alternative is just to use rewriting with `eq`, but then computational proofs get stuck. -/\nprotected def congr_right {α : Sort u} {r : α → α → Prop} {r' : α → α → Prop}\n    (eq : ∀ (a₁ a₂ : α), r a₁ a₂ ↔ r' a₁ a₂) : Quot r ≃ Quot r' :=\n  quot.congr (equiv.refl α) eq\n\n/-- An equivalence `e : α ≃ β` generates an equivalence between the quotient space of `α`\nby a relation `ra` and the quotient space of `β` by the image of this relation under `e`. -/\nprotected def congr_left {α : Sort u} {β : Sort v} {r : α → α → Prop} (e : α ≃ β) :\n    Quot r ≃ Quot fun (b b' : β) => r (coe_fn (equiv.symm e) b) (coe_fn (equiv.symm e) b') :=\n  quot.congr e sorry\n\nend quot\n\n\nnamespace quotient\n\n\n/-- An equivalence `e : α ≃ β` generates an equivalence between quotient spaces,\nif `ra a₁ a₂ ↔ rb (e a₁) (e a₂). -/\nprotected def congr {α : Sort u} {β : Sort v} {ra : setoid α} {rb : setoid β} (e : α ≃ β)\n    (eq : ∀ (a₁ a₂ : α), setoid.r a₁ a₂ ↔ setoid.r (coe_fn e a₁) (coe_fn e a₂)) :\n    quotient ra ≃ quotient rb :=\n  quot.congr e eq\n\n/-- Quotients are congruent on equivalences under equality of their relation.\nAn alternative is just to use rewriting with `eq`, but then computational proofs get stuck. -/\nprotected def congr_right {α : Sort u} {r : setoid α} {r' : setoid α}\n    (eq : ∀ (a₁ a₂ : α), setoid.r a₁ a₂ ↔ setoid.r a₁ a₂) : quotient r ≃ quotient r' :=\n  quot.congr_right eq\n\nend quotient\n\n\n/-- If a function is a bijection between two sets `s` and `t`, then it induces an\nequivalence between the the types `↥s` and ``↥t`. -/\ndef set.bij_on.equiv {α : Type u_1} {β : Type u_2} {s : set α} {t : set β} (f : α → β)\n    (h : set.bij_on f s t) : ↥s ≃ ↥t :=\n  equiv.of_bijective (set.cod_restrict (set.restrict f s) t sorry) (set.bij_on.bijective h)\n\nnamespace function\n\n\ntheorem update_comp_equiv {α : Sort u_1} {β : Sort u_2} {α' : Sort u_3} [DecidableEq α']\n    [DecidableEq α] (f : α → β) (g : α' ≃ α) (a : α) (v : β) :\n    update f a v ∘ ⇑g = update (f ∘ ⇑g) (coe_fn (equiv.symm g) a) v :=\n  sorry\n\ntheorem update_apply_equiv_apply {α : Sort u_1} {β : Sort u_2} {α' : Sort u_3} [DecidableEq α']\n    [DecidableEq α] (f : α → β) (g : α' ≃ α) (a : α) (v : β) (a' : α') :\n    update f a v (coe_fn g a') = update (f ∘ ⇑g) (coe_fn (equiv.symm g) a) v a' :=\n  congr_fun (update_comp_equiv f g a v) a'\n\nend function\n\n\n/-- The composition of an updated function with an equiv on a subset can be expressed as an\nupdated function. -/\ntheorem dite_comp_equiv_update {α : Type u_1} {β : Sort u_2} {γ : Sort u_3} {s : set α} (e : β ≃ ↥s)\n    (v : β → γ) (w : α → γ) (j : β) (x : γ) [DecidableEq β] [DecidableEq α]\n    [(j : α) → Decidable (j ∈ s)] :\n    (fun (i : α) =>\n          dite (i ∈ s)\n            (fun (h : i ∈ s) =>\n              function.update v j x (coe_fn (equiv.symm e) { val := i, property := h }))\n            fun (h : ¬i ∈ s) => w i) =\n        function.update\n          (fun (i : α) =>\n            dite (i ∈ s) (fun (h : i ∈ s) => v (coe_fn (equiv.symm e) { val := i, property := h }))\n              fun (h : ¬i ∈ s) => w i)\n          (↑(coe_fn e j)) x :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/equiv/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.668880247169804, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.4610629156001557}}
{"text": "import topology.basic\nimport data.set.basic\nimport data.rat.basic\n\nimport data.real.basic\n\nimport analysis.normed_space.basic\n\n\n-- Montrer que Z est une partie fermée de R\n\ntheorem exo:\n  is_closed (fun r, exists z: int, r = real.of_rat (rat.of_int z))\n:= sorry\n", "meta": {"author": "ahayat16", "repo": "lean_exos", "sha": "682f2552d5b04a8c8eb9e4ab15f875a91b03845c", "save_path": "github-repos/lean/ahayat16-lean_exos", "path": "github-repos/lean/ahayat16-lean_exos/lean_exos-682f2552d5b04a8c8eb9e4ab15f875a91b03845c/src_icannos_totilas/topologie-espaces-normés/cpge_ten_16.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.46103494631713404}}
{"text": "import set_category.diagram_lemmas\nimport set_category.category_set\nimport set_category.em_square\nimport help_functions\n\nnamespace coalgebra\n\nopen category_theory \n     set \n     category_set \n     diagram_lemmas \n     help_functions \n     classical\n     em_square\n\n\nuniverses v u \n\nlocal notation f ` ⊚ `:80 g:80 := category_struct.comp g f\n\n\n/-- The stucture of coalgebra of signature F -/\nstructure Coalgebra (F : Type u ⥤ Type u) : Type (u+1) :=\n    (carrier : Type u) (α : carrier ⟶ F.obj carrier)\n\nvariables {F : Type u ⥤ Type u}\n\n\n/-- Allows us to use the coalgebra as a Type referring to its carrier-/\ninstance Coalgebra_to_sort : has_coe_to_sort (Coalgebra F) := \n    ⟨Type u,  λ 𝔸, 𝔸.carrier⟩ \n\nvariables {𝔸 Β ℂ: Coalgebra F}\n \n/--\n    A Set-Category morphism(φ : A -> B) is coalgebra morphism iff\n    α_B ∘ φ =  F φ ∘ α_A\n-/\n@[simp , tidy] def is_coalgebra_homomorphism\n        (ϕ : 𝔸 →  Β) : Prop :=\n        Β.α ∘ ϕ =  (F.map ϕ) ∘ 𝔸.α\n\n/--\n    The subtype of coalgebra-homomorphism\n-/\ndef homomorphism (𝔸 Β : Coalgebra F) : set (𝔸 → Β):=\n    λ ϕ , is_coalgebra_homomorphism ϕ \n\n \n/-- Allows us to use a homomorphism as a map-/\ninstance homomorphism_to_map (𝔸 Β : Coalgebra F) : \n    has_coe_to_fun (homomorphism 𝔸 Β) := \n    { F := λ _, 𝔸 → Β, coe := λ m, m.val}\n    \n/--\n    A proof that id is a coalgebra-homomorphism\n-/\nlemma id_is_hom (𝔸 : Coalgebra F):\n     is_coalgebra_homomorphism (@id 𝔸) := \n     show 𝔸.α ∘ id =  (F.map id) ∘ 𝔸.α, from\n        calc 𝔸.α ∘ id = (𝟙 (F.obj 𝔸)) ∘ 𝔸.α     : rfl\n                ...   = (F.map (𝟙 𝔸)) ∘ 𝔸.α     : by rw ← functor.map_id' F 𝔸\n               \n/--\n    A proof that composition of two homomorphism is a coalgebra-homomorphism\n-/\nlemma comp_is_hom (φ : homomorphism 𝔸 Β) (ψ : homomorphism Β ℂ)\n    : is_coalgebra_homomorphism (ψ ∘ φ) :=\n        have ab : Β.α ∘ φ =  F.map φ ∘ 𝔸.α := φ.property,\n        have bc : ℂ.α ∘ ψ =  F.map ψ ∘ Β.α := ψ.property,\n\n        calc\n        (ℂ.α ∘ ψ) ∘ φ = (F.map ψ) ∘ Β.α  ∘ φ    : by rw bc\n        ... = (F.map ψ) ∘ (F.map φ) ∘ 𝔸.α      : by rw ab\n        ... = ((F.map ψ) ⊚ (F.map φ)) ∘ 𝔸.α   : rfl\n        ... = (F.map (ψ ⊚ φ)) ∘ 𝔸.α           : by rw ← functor.map_comp\n    \n \n\n/--\n    The category of Coalgebras of the signature F (Set-F)\n-/\ninstance coalgebra_category : category (Coalgebra F) :=\n{\n    hom  := λ 𝔸 Β, homomorphism 𝔸 Β,\n    id   := λ 𝔸 , ⟨@id 𝔸, id_is_hom 𝔸⟩ ,\n    comp := λ 𝔸 Β ℂ φ ψ, ⟨ψ ∘ φ, comp_is_hom φ ψ⟩\n}\n\n\ninstance set_F_to_set : has_coe (𝔸 ⟶ Β) (𝔸.carrier ⟶ Β.carrier)\n    := ⟨λ ϕ :𝔸 ⟶ Β, ϕ⟩ \n\nopen function\n\nlemma empty_hom_dom (ϕ : 𝔸.carrier ⟶ Β.carrier) \n    (em_𝔸 : ¬ nonempty 𝔸):\n    is_coalgebra_homomorphism ϕ := \n    begin\n        dsimp at *,\n        ext1,\n        have ex : ∃ a : 𝔸 , true := exists.intro x trivial,\n        exact absurd (nonempty_of_exists ex) em_𝔸\n    end\n\nlemma empty_hom_codom (ϕ : 𝔸.carrier ⟶ Β.carrier) \n    (em_Β : ¬ nonempty Β):\n    is_coalgebra_homomorphism ϕ := \n    begin\n        dsimp at *,\n        ext1,\n        have ex : ∃ b : Β , true := exists.intro (ϕ x) trivial,\n        exact absurd (nonempty_of_exists ex) em_Β\n    end\n\nnoncomputable \ndef empty_map (S : Type u) (emp : ¬ nonempty S) (X : Type u): \n    S → X := \n    graph_to_map (λ s fs, false) -- ∀ a : A , ∃! b : B, G a b\n    (λ s, absurd (⟨s⟩ : nonempty S) emp)\n\nlemma not_nonempty_empty : ¬ nonempty (∅: set 𝔸) := \nassume ⟨s⟩, by tidy\n\nnoncomputable\ndef empty_coalgebra : Coalgebra F :=\n    {\n        carrier := (∅ : set 𝔸),\n        α       := empty_map (∅ : set 𝔸) not_nonempty_empty (F.obj (∅ : set 𝔸))\n    } \n\n\n/--\n    The inverse of homomorphism is homomorphism if the \n    the homomorphism is bijective. \n-/\ntheorem bij_inverse_of_hom_is_hom\n    (φ : homomorphism 𝔸 Β)\n    (bij : bijective φ) :  \n        let inv : Β → 𝔸 := some (bijective_iff_has_inverse.1 bij) in\n        is_coalgebra_homomorphism inv := \n        begin \n            intro inv,\n            let hom :Β.α ∘ φ =  F.map φ ∘ 𝔸.α := φ.property,\n            have has_lr_inv :left_inverse inv φ ∧ right_inverse inv φ\n                := some_spec (bijective_iff_has_inverse.1 bij),\n\n            calc \n            𝔸.α ∘ inv = id ∘ 𝔸.α ∘ inv                     : rfl\n            ... = (𝟙 (F.obj 𝔸)) ∘ 𝔸.α ∘ inv                : rfl \n            ... = (F.map (𝟙 𝔸)) ∘ 𝔸.α ∘ inv                : by rw ← functor.map_id' \n            ... = (F.map id) ∘ 𝔸.α ∘ inv                   : rfl\n            ... = (F.map (inv ∘ φ)) ∘ 𝔸.α ∘ inv            : by rw id_of_left_inverse has_lr_inv.1\n            ... = (F.map (inv ⊚ φ)) ∘ 𝔸.α ∘ inv           : rfl\n            ... = ((F.map inv) ⊚ (F.map φ)) ∘ 𝔸.α ∘ inv   : by rw ← functor.map_comp \n            ... = (F.map inv) ∘ ((F.map φ) ∘ 𝔸.α) ∘ inv    : rfl\n            ... = (F.map inv) ∘ (Β.α ∘ φ) ∘ inv            : by rw hom\n            ... = (F.map inv) ∘ Β.α ∘ (φ ∘ inv)            : rfl \n            ... = ((F.map inv) ∘ Β.α ∘ id)                 : by rw id_of_right_inverse has_lr_inv.2\n            ... = (F.map inv) ∘ Β.α                        : rfl\n        end \n/--\n    Let 𝔸, Β, and ℂ be coalgebras and \n    f : A → B, g : B → C set maps, \n    so that ϕ := g ∘ f : A → C is a homomorphism.\n\n    If f is a surjective homomorphism, then g is a homomorphism.\n-/\nlemma surj_to_hom  \n            (f : 𝔸.carrier ⟶ Β.carrier) \n            (g : Β.carrier ⟶ ℂ.carrier) \n            (hom_gf : is_coalgebra_homomorphism (g ∘ f))\n            (hom_f : is_coalgebra_homomorphism f)\n            (ep : epi f) \n                : is_coalgebra_homomorphism g :=\n    \n        have  h1 : (ℂ.α ∘ g) ⊚ f = (F.map g ∘ Β.α) ⊚ f :=\n        calc\n        (ℂ.α ∘ g) ⊚ f = F.map (g ⊚ f) ∘ 𝔸.α   : hom_gf\n        ... = (F.map g ⊚ F.map f) ∘ 𝔸.α        : by rw functor.map_comp\n        ... = F.map g ∘ F.map f ∘ 𝔸.α           : by tidy\n        ... = F.map g ∘ Β.α ∘ f                 : by rw [eq.symm hom_f],\n        right_cancel f h1\n\n\n/--\n    If g is an injective homomorphismus, then f is a homomorphism.\n-/\nlemma inj_to_hom (f : 𝔸.carrier → Β.carrier) \n               (g : Β.carrier → ℂ.carrier) \n            (hom_gf : is_coalgebra_homomorphism (g ∘ f))\n            (hom_g : is_coalgebra_homomorphism g)\n            (inj : injective g) \n                : is_coalgebra_homomorphism f := \n    begin\n        cases classical.em (nonempty Β) with n_em_Β emp_Β,\n        have  h1 : (F.map g) ⊚ (F.map f) ⊚ 𝔸.α = F.map g ⊚ (Β.α ⊚ f) :=\n        calc\n        ((F.map g) ⊚ (F.map f)) ∘ 𝔸.α  \n                = (F.map (g ⊚ f)) ∘ 𝔸.α  : by rw functor.map_comp\n        ...     = F.map (g ∘ f) ∘ 𝔸.α     : rfl\n        ...     = ℂ.α ∘ g ∘ f             : by rw [eq.symm hom_gf]\n        ...     = (F.map g ∘ Β.α) ∘ f     : by rw [eq.symm hom_g],\n        \n        haveI inh_Β : inhabited Β := ⟨choice n_em_Β⟩, \n\n        haveI fg_mono : mono (F.map g) := mono_preserving_functor g inj,\n        \n        exact  left_cancel (F.map g) (eq.symm h1),\n\n        exact empty_hom_codom f emp_Β\n    end\n\n/--\n    Let ϕ : 𝔸 → Β, ψ : 𝔸 → ℂ be homomorphisms, \n    and ϕ is surjective.\n\n    Then there exists a unique homomorphism χ : Β ⟶ ℂ, \n    such that χ ∘ ϕ = ψ \n    iff kern ϕ ⊆ kern ψ\n-/\nlemma coalgebra_diagram (ϕ : homomorphism 𝔸 Β) \n                        (ψ : homomorphism 𝔸 ℂ)\n                        (sur : surjective ϕ)\n            :   (∃! χ : homomorphism Β ℂ , χ ∘ ϕ = ψ) ↔ \n                (sub_kern ϕ ψ)\n                :=\n    iff.intro\n    -- The \"exists such χ\" → \"kern ϕ ⊆ kern ψ\" direction:\n    begin\n        intro ex,\n        cases ex with χ h1,\n\n        exact h1.left ▸ (kern_comp ϕ χ) \n    end \n    -- The \"kern ϕ ⊆ kern ψ\" → \"exists a unique χ\" direction:\n    begin\n        intro k,\n        -- using the diagram lemma of Set-Category to \n        -- prove the existance and uniqueness of such morphism \n        have ex_uni : ∃ χ : Β → ℂ, \n            (χ ∘ ϕ = ψ  ∧ ∀ χ₁, χ₁ ∘ ϕ = ψ → χ₁ = χ)\n            := (diagram_surjective ϕ ψ sur).2 k,\n\n        cases ex_uni with χ spec,\n        -- χ : Β → ℂ\n        -- spec : χ ∘ ϕ = ψ  ∧ ∀ χ₁, χ₁ ∘ ϕ = ψ → χ₁ = χ\n\n        have hom_χ_ϕ : is_coalgebra_homomorphism (χ ∘ ϕ) :=\n            (eq.symm spec.left) ▸ ψ.property,\n\n        have hom_χ : is_coalgebra_homomorphism χ :=\n            surj_to_hom ϕ χ hom_χ_ϕ ϕ.property \n                    ((epi_iff_surjective ϕ).2 sur),\n\n        have unique : ∀ (χ₁ : homomorphism Β ℂ), \n                    χ₁ ∘ ϕ = ψ\n                    → χ₁ = ⟨χ , hom_χ⟩ := by tidy,\n\n        exact exists_unique.intro ⟨χ , hom_χ⟩ \n                                  spec.left unique\n    end\n\n\n/--\nLet Q be a nonempty set,\n    ϕ : 𝔸 ⟶ Β be a homomorphisms, \n    f : A → Q and g : Q → B be maps with ϕ = g ∘ f and\n    f surjective and g injective\n\n    Then there exists a unique α_Q : Q → F(Q) coalgebra structure\n    such that both f and g are homomorphisms.\n-/\ntheorem Factorization {Q : Type u}\n    (ϕ : homomorphism 𝔸 Β) \n    (f : 𝔸.carrier ⟶ Q)\n    (g : Q ⟶ Β.carrier)\n    (h : ϕ.val = g ∘ f)\n    (ep : epi f)\n    (inj : injective g):\n        ∃! α_Q : Q ⟶ F.obj Q , \n            @is_coalgebra_homomorphism F 𝔸 ⟨Q , α_Q⟩ f ∧ \n            @is_coalgebra_homomorphism F ⟨Q , α_Q⟩ Β g\n    := \nbegin\n    cases classical.em (nonempty 𝔸) with n_em_𝔸 emp_𝔸,\n    haveI inh_𝔸 : inhabited 𝔸 := ⟨choice n_em_𝔸⟩ ,\n    haveI inh_ℚ : inhabited Q := ⟨f (default 𝔸)⟩, \n    let hom_ϕ := ϕ.property,\n    /-\n        Using the E-M-Square \n        A      ⟶(f)⟶     Q   ⟶(Β.α ∘ g)⟶ F(B), \n        A ⟶(F f ∘ α_𝔸)⟶ F(Q)   ⟶(F g)⟶   F(B)\n    -/\n    /-\n        showing that the triangles commute\n    -/ \n\n    have commute\n        : (Β.α ∘ g) ∘ f = (F.map g) ∘ ((F.map f) ∘ 𝔸.α) := \n        calc Β.α ∘ g ∘ f = Β.α ∘ ϕ.val                      : by simp [h]\n                 ...     = (F.map ϕ.val) ∘ 𝔸.α             : hom_ϕ\n                 ...     = (F.map (g ∘ f)) ∘ 𝔸.α           : by rw [h]\n                 ...     = (F.map (g ⊚ f)) ∘ 𝔸.α           : rfl\n                 ...     = ((F.map g) ⊚ (F.map f)) ∘ 𝔸.α   : by rw functor.map_comp\n                 ...     = (F.map g) ∘ (F.map f) ∘ 𝔸.α     : by simp,\n\n    /-\n        we get the existance and the uniqueness of d \n        the diagonal of the square and the coalgebra structure\n    -/\n    have em_square : _ := E_M_square\n                f ep\n                (Β.α ∘ g) ((F.map f) ∘ 𝔸.α) (F.map g) \n                (mono_preserving_functor g inj) \n                commute,\n\n    cases em_square with d spec,\n\n    have uni_d : _ := spec.2,\n\n    let ℚ : Coalgebra F := ⟨Q , d⟩,\n    \n    have homomorphism_f : @is_coalgebra_homomorphism F 𝔸 ℚ f := \n        eq.symm spec.left.left,\n\n    have homomorphism_g : @is_coalgebra_homomorphism F ℚ Β g := \n        spec.left.right,\n\n    have unique : ∀ (α_Q : Q ⟶ F.obj Q), \n        @is_coalgebra_homomorphism F 𝔸 ⟨Q , α_Q⟩ f ∧ \n        @is_coalgebra_homomorphism F ⟨Q , α_Q⟩ Β g → \n        α_Q = d := \n        assume α_Q ⟨hom_f , hom_g⟩, \n        uni_d α_Q ⟨eq.symm hom_f , hom_g⟩,\n\n    exact\n    exists_unique.intro\n        d \n        ⟨homomorphism_f , homomorphism_g⟩\n        unique,\n\n    have A_Q : nonempty Q → nonempty 𝔸 :=\n       λ n_Q, ⟨some ((epi_iff_surjective f).1 ep (choice n_Q))⟩, \n    have em_Q : nonempty Q → false := \n        λ n_Q, emp_𝔸 (A_Q n_Q),\n    have n_Q : ¬ (nonempty Q) := em_Q,\n    let α_Q : Q → F.obj Q := empty_map Q n_Q (F.obj Q),\n    have hom_f : @is_coalgebra_homomorphism F 𝔸 ⟨Q , α_Q⟩ f\n        := empty_hom_dom f emp_𝔸,\n    exact exists_unique.intro α_Q \n        ⟨hom_f , by tidy⟩ (by tidy)    \n\nend\n\n\ntheorem factorization {Q : Type u}\n    (ϕ : homomorphism 𝔸 Β) \n    (f : 𝔸.carrier ⟶ Q) (g : Q ⟶ Β.carrier)\n    (h : ϕ.val = g ∘ f)\n    (sur : surjective f)\n    (inj : injective g) :\n        (∃! α_Q : Q ⟶ F.obj Q , \n            @is_coalgebra_homomorphism F 𝔸 ⟨Q , α_Q⟩ f)\n    := \nbegin\n    cases classical.em (nonempty 𝔸) with n_em_𝔸 emp_𝔸,\n    haveI inh : inhabited 𝔸 := ⟨choice n_em_𝔸⟩ ,\n    let hom_ϕ := ϕ.property,\n    /-\n        Using the E-M-Square \n        A      ⟶(f)⟶     Q   ⟶(Β.α ∘ g)⟶ F(B), \n        A ⟶(F f ∘ α_𝔸)⟶ F(Q)   ⟶(F g)⟶   F(B)\n    -/\n    /-\n        showing that the triangles commute\n    -/ \n    have commute\n        : (Β.α ∘ g) ∘ f = (F.map g) ∘ ((F.map f) ∘ 𝔸.α) := \n        calc Β.α ∘ g ∘ f = Β.α ∘ ϕ.val                      : by simp [h]\n                 ...     = (F.map ϕ.val) ∘ 𝔸.α             : hom_ϕ\n                 ...     = (F.map (g ∘ f)) ∘ 𝔸.α           : by rw [h]\n                 ...     = (F.map (g ⊚ f)) ∘ 𝔸.α           : rfl\n                 ...     = ((F.map g) ⊚ (F.map f)) ∘ 𝔸.α   : by rw functor.map_comp\n                 ...     = (F.map g) ∘ (F.map f) ∘ 𝔸.α     : by simp,\n    \n    haveI inh_Q : inhabited Q := ⟨f (default 𝔸)⟩ ,\n\n    haveI epi_f : epi f := (epi_iff_surjective f).2 sur,\n    haveI mono_Fg : mono (F.map g) := mono_preserving_functor g inj,\n    /-\n        we get the existance and the uniqueness of d \n        the diagonal of the square and the coalgebra structure\n    -/\n    have em_square : _ := E_M_square\n        f epi_f (Β.α ∘ g) ((F.map f) ∘ 𝔸.α) \n            (F.map g) mono_Fg commute,\n\n    cases em_square with d spec,\n    \n    have homomorphism_f : d ⊚ f = (F.map f) ⊚ 𝔸.α := \n        eq.symm spec.left.left,\n\n    have com_tri_epi := commutative_triangles_epi \n        f (Β.α ∘ g) ((F.map f) ∘ 𝔸.α) (F.map g) commute d (eq.symm homomorphism_f),\n    \n    have uni_f : ∀ (α_Q : Q ⟶ F.obj Q), \n        @is_coalgebra_homomorphism F 𝔸 ⟨Q , α_Q⟩ f → \n        α_Q = d := \n        assume α_Q hom_f, \n        have com : α_Q ⊚ f = F.map f ∘ 𝔸.α := hom_f,\n        com_tri_epi.1 α_Q (eq.symm com),\n\n    exact exists_unique.intro d \n        homomorphism_f uni_f,\n\n    have A_Q : nonempty Q → nonempty 𝔸 :=\n       λ n_Q, ⟨some (sur (choice n_Q))⟩, \n    have em_Q : nonempty Q → false := \n        λ n_Q, emp_𝔸 (A_Q n_Q),\n    have n_Q : ¬ (nonempty Q) := em_Q,\n    let α_Q : Q → F.obj Q := empty_map Q n_Q (F.obj Q),\n    have hom_f : @is_coalgebra_homomorphism F 𝔸 ⟨Q , α_Q⟩ f\n        := empty_hom_dom f emp_𝔸,\n    exact exists_unique.intro α_Q hom_f (by tidy)\nend\n\ntheorem factorization_hom {Q : Type u}\n    (ϕ : homomorphism 𝔸 Β) \n    (f : 𝔸.carrier ⟶ Q) (g : Q ⟶ Β.carrier)\n    (h : ϕ.val = g ∘ f)\n    (sur : surjective f)\n    (inj : injective g)\n    [inhabited 𝔸] :\n    let α_Q := some (factorization ϕ f g h sur inj) in\n        @is_coalgebra_homomorphism F ⟨Q , α_Q⟩ Β g := \n    begin \n        intros α_Q,\n        \n        have hom_ϕ := ϕ.property,\n        \n        have commute : (Β.α ∘ g) ∘ f = (F.map g) ∘ ((F.map f) ∘ 𝔸.α) := \n            calc Β.α ∘ g ∘ f \n                        = Β.α ∘ ϕ.val                      : by simp [h]\n                    ... = (F.map ϕ.val) ∘ 𝔸.α             : hom_ϕ\n                    ... = (F.map (g ∘ f)) ∘ 𝔸.α           : by rw [h]\n                    ... = (F.map (g ⊚ f)) ∘ 𝔸.α           : rfl\n                    ... = ((F.map g) ⊚ (F.map f)) ∘ 𝔸.α   : by rw functor.map_comp\n                    ... = (F.map g) ∘ (F.map f) ∘ 𝔸.α     : by simp,\n        haveI inh_Q : inhabited Q := ⟨f (default 𝔸)⟩ ,\n        haveI epi_f : epi f := (epi_iff_surjective f).2 sur,\n        haveI mono_Fg : mono (F.map g) := mono_preserving_functor g inj,\n\n        have spec := some_spec (factorization ϕ f g h sur inj),\n\n        have com_tri_epi : _ := commutative_triangles_epi \n            f (Β.α ∘ g) ((F.map f) ∘ 𝔸.α) (F.map g) commute α_Q (eq.symm spec.1),\n        exact com_tri_epi.2\n    end\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend coalgebra", "meta": {"author": "QaisHamarneh", "repo": "Coalgebra-in-Lean", "sha": "bd0452df98bc64b608e5dfd7babc42c301bb6a46", "save_path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean", "path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean/Coalgebra-in-Lean-bd0452df98bc64b608e5dfd7babc42c301bb6a46/src/coalgebra/Coalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4610349406317222}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Robert Y. Lewis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.ring_theory.witt_vector.truncated\nimport Mathlib.ring_theory.witt_vector.identities\nimport Mathlib.data.padics.ring_homs\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\n/-!\n\n# Comparison isomorphism between `witt_vector p (zmod p)` and `ℤ_[p]`\n\nWe construct a ring isomorphism between `witt_vector p (zmod p)` and `ℤ_[p]`.\nThis isomorphism follows from the fact that both satisfy the universal property\nof the inverse limit of `zmod (p^n)`.\n\n## Main declarations\n\n* `witt_vector.to_zmod_pow`: a family of compatible ring homs `𝕎 (zmod p) → zmod (p^k)`\n* `witt_vector.equiv`: the isomorphism\n\n-/\n\nnamespace truncated_witt_vector\n\n\ntheorem eq_of_le_of_cast_pow_eq_zero (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] [char_p R p] (i : ℕ) (hin : i ≤ n) (hpi : ↑p ^ i = 0) : i = n := sorry\n\ntheorem card_zmod (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : fintype.card (truncated_witt_vector p n (zmod p)) = p ^ n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (fintype.card (truncated_witt_vector p n (zmod p)) = p ^ n)) (card p n)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (fintype.card (zmod p) ^ n = p ^ n)) (zmod.card p))) (Eq.refl (p ^ n)))\n\ntheorem char_p_zmod (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : char_p (truncated_witt_vector p n (zmod p)) (p ^ n) :=\n  char_p_of_prime_pow_injective (truncated_witt_vector p n (zmod p)) p n (card_zmod p n)\n    (eq_of_le_of_cast_pow_eq_zero p n (zmod p))\n\n/--\nThe unique isomorphism between `zmod p^n` and `truncated_witt_vector p n (zmod p)`.\n\nThis isomorphism exists, because `truncated_witt_vector p n (zmod p)` is a finite ring\nwith characteristic and cardinality `p^n`.\n-/\ndef zmod_equiv_trunc (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) : zmod (p ^ n) ≃+* truncated_witt_vector p n (zmod p) :=\n  zmod.ring_equiv (truncated_witt_vector p n (zmod p)) (card_zmod p n)\n\ntheorem zmod_equiv_trunc_apply (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {x : zmod (p ^ n)} : coe_fn (zmod_equiv_trunc p n) x = coe_fn (zmod.cast_hom (dvd_refl (p ^ n)) (truncated_witt_vector p n (zmod p))) x :=\n  rfl\n\n/--\nThe following diagram commutes:\n```text\n          zmod (p^n) ----------------------------> zmod (p^m)\n            |                                        |\n            |                                        |\n            v                                        v\ntruncated_witt_vector p n (zmod p) ----> truncated_witt_vector p m (zmod p)\n```\nHere the vertical arrows are `truncated_witt_vector.zmod_equiv_trunc`,\nthe horizontal arrow at the top is `zmod.cast_hom`,\nand the horizontal arrow at the bottom is `truncated_witt_vector.truncate`.\n-/\ntheorem commutes (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m) : ring_hom.comp (truncate hm) (ring_equiv.to_ring_hom (zmod_equiv_trunc p m)) =\n  ring_hom.comp (ring_equiv.to_ring_hom (zmod_equiv_trunc p n)) (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n))) :=\n  ring_hom.ext_zmod (ring_hom.comp (truncate hm) (ring_equiv.to_ring_hom (zmod_equiv_trunc p m)))\n    (ring_hom.comp (ring_equiv.to_ring_hom (zmod_equiv_trunc p n)) (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n))))\n\ntheorem commutes' (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m) (x : zmod (p ^ m)) : coe_fn (truncate hm) (coe_fn (zmod_equiv_trunc p m) x) =\n  coe_fn (zmod_equiv_trunc p n) (coe_fn (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n))) x) := sorry\n\ntheorem commutes_symm' (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m) (x : truncated_witt_vector p m (zmod p)) : coe_fn (ring_equiv.symm (zmod_equiv_trunc p n)) (coe_fn (truncate hm) x) =\n  coe_fn (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n))) (coe_fn (ring_equiv.symm (zmod_equiv_trunc p m)) x) := sorry\n\n/--\nThe following diagram commutes:\n```text\ntruncated_witt_vector p n (zmod p) ----> truncated_witt_vector p m (zmod p)\n            |                                        |\n            |                                        |\n            v                                        v\n          zmod (p^n) ----------------------------> zmod (p^m)\n```\nHere the vertical arrows are `(truncated_witt_vector.zmod_equiv_trunc p _).symm`,\nthe horizontal arrow at the top is `zmod.cast_hom`,\nand the horizontal arrow at the bottom is `truncated_witt_vector.truncate`.\n-/\ntheorem commutes_symm (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {m : ℕ} (hm : n ≤ m) : ring_hom.comp (ring_equiv.to_ring_hom (ring_equiv.symm (zmod_equiv_trunc p n))) (truncate hm) =\n  ring_hom.comp (zmod.cast_hom (pow_dvd_pow p hm) (zmod (p ^ n)))\n    (ring_equiv.to_ring_hom (ring_equiv.symm (zmod_equiv_trunc p m))) :=\n  ring_hom.ext fun (x : truncated_witt_vector p m (zmod p)) => commutes_symm' p n hm x\n\nend truncated_witt_vector\n\n\nnamespace witt_vector\n\n\n/--\n`to_zmod_pow` is a family of compatible ring homs. We get this family by composing\n`truncated_witt_vector.zmod_equiv_trunc` (in right-to-left direction)\nwith `witt_vector.truncate`.\n-/\ndef to_zmod_pow (p : ℕ) [hp : fact (nat.prime p)] (k : ℕ) : witt_vector p (zmod p) →+* zmod (p ^ k) :=\n  ring_hom.comp (ring_equiv.to_ring_hom (ring_equiv.symm (truncated_witt_vector.zmod_equiv_trunc p k))) (truncate k)\n\ntheorem to_zmod_pow_compat (p : ℕ) [hp : fact (nat.prime p)] (m : ℕ) (n : ℕ) (h : m ≤ n) : ring_hom.comp (zmod.cast_hom (pow_dvd_pow p h) (zmod (p ^ m))) (to_zmod_pow p n) = to_zmod_pow p m := sorry\n\n/--\n`to_padic_int` lifts `to_zmod_pow : 𝕎 (zmod p) →+* zmod (p ^ k)` to a ring hom to `ℤ_[p]`\nusing `padic_int.lift`, the universal property of `ℤ_[p]`.\n-/\ndef to_padic_int (p : ℕ) [hp : fact (nat.prime p)] : witt_vector p (zmod p) →+* padic_int p :=\n  padic_int.lift (to_zmod_pow_compat p)\n\ntheorem zmod_equiv_trunc_compat (p : ℕ) [hp : fact (nat.prime p)] (k₁ : ℕ) (k₂ : ℕ) (hk : k₁ ≤ k₂) : ring_hom.comp (truncated_witt_vector.truncate hk)\n    (ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k₂)) (padic_int.to_zmod_pow k₂)) =\n  ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k₁)) (padic_int.to_zmod_pow k₁) := sorry\n\n/--\n`from_padic_int` uses `witt_vector.lift` to lift `truncated_witt_vector.zmod_equiv_trunc`\ncomposed with `padic_int.to_zmod_pow` to a ring hom `ℤ_[p] →+* 𝕎 (zmod p)`.\n-/\ndef from_padic_int (p : ℕ) [hp : fact (nat.prime p)] : padic_int p →+* witt_vector p (zmod p) :=\n  lift\n    (fun (k : ℕ) =>\n      ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k)) (padic_int.to_zmod_pow k))\n    (zmod_equiv_trunc_compat p)\n\ntheorem to_padic_int_comp_from_padic_int (p : ℕ) [hp : fact (nat.prime p)] : ring_hom.comp (to_padic_int p) (from_padic_int p) = ring_hom.id (padic_int p) := sorry\n\ntheorem to_padic_int_comp_from_padic_int_ext (p : ℕ) [hp : fact (nat.prime p)] (x : padic_int p) : coe_fn (ring_hom.comp (to_padic_int p) (from_padic_int p)) x = coe_fn (ring_hom.id (padic_int p)) x := sorry\n\ntheorem from_padic_int_comp_to_padic_int (p : ℕ) [hp : fact (nat.prime p)] : ring_hom.comp (from_padic_int p) (to_padic_int p) = ring_hom.id (witt_vector p (zmod p)) := sorry\n\ntheorem from_padic_int_comp_to_padic_int_ext (p : ℕ) [hp : fact (nat.prime p)] (x : witt_vector p (zmod p)) : coe_fn (ring_hom.comp (from_padic_int p) (to_padic_int p)) x = coe_fn (ring_hom.id (witt_vector p (zmod p))) x := sorry\n\n/--\nThe ring of Witt vectors over `zmod p` is isomorphic to the ring of `p`-adic integers. This\nequivalence is witnessed by `witt_vector.to_padic_int` with inverse `witt_vector.from_padic_int`.\n-/\ndef equiv (p : ℕ) [hp : fact (nat.prime p)] : witt_vector p (zmod p) ≃+* padic_int p :=\n  ring_equiv.mk (⇑(to_padic_int p)) (⇑(from_padic_int p)) (from_padic_int_comp_to_padic_int_ext p)\n    (to_padic_int_comp_from_padic_int_ext p) sorry sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/compare.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059462938815, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4610349377890161}}
{"text": "import category_theory.category\nimport category_theory.functor\nimport category_theory.types\nimport help_functions\n\nimport tactic.tidy\n\n\nnamespace diagram_lemmas\n\nuniverse u\n\nopen classical function set category_theory help_functions\n\n\nlocal notation f ` ⊚ ` :80 g:80 := category_struct.comp g f\n\nvariables {F : Type u ⥤ Type u} \n        {A B C : Type u}\n\n\nlemma diagram_injective (f: B ⟶ A)\n                        (g: C ⟶ A)\n                        (inj : injective f)\n                        : (∃! h : C ⟶ B , f ∘ h = g) ↔ \n                          (range g ⊆ range f) \n    := \n        iff.intro \n        begin\n            tidy\n        end\n        begin\n            assume im,\n            let G : C → B → Prop := λ c b , g c = f b, \n            have G1 :  ∀ c : C , ∃ b : B, G c b \n                    :=\n                        have G10 : \n                            ∀ a : A , a ∈ range g → \n                                    a ∈ range f := im,\n                        have G11 : \n                            ∀ c : C , g c ∈ range f := \n                                λ c , \n                                have G110 : g c ∈ range g := by tidy,\n                                G10 (g c) G110,\n                        have G12 : ∀ c : C , ∃ b : B , g c = f b := \n                            λ c : C,  \n                            have G110 : g c ∈ range f := G11 c,\n                            by tidy,\n                        G12,\n            have G2 :  ∀ c : C , ∃! b : B, G c b\n                    :=\n                        λ c, \n                        have G20 : G c (some (G1 c)) := some_spec (G1 c),\n                        have G21 : f (some (G1 c)) = g c := \n                            show f (some (G1 c)) = g c,\n                            from \n                                have G210 : _ := G c (some (G1 c)),\n                                by tidy,\n                        have G22 : ∀ b₁ : B, G c b₁ → \n                                    b₁ = (some (G1 c)) := \n                                    λ b₁ : B, assume cbG : G c b₁,\n                                    show b₁ = (some (G1 c)), from\n                                    have G220 : f b₁ = g c := by tidy,\n                                    have G221 : f (some (G1 c)) = f b₁ := by rw [G21 , G220],\n                                    eq.symm (inj G221),\n                        by tidy,\n            let h : C ⟶ B := graph_to_map G G2,\n            have G3 : ∀ c , (f ∘ h) c = g c:= \n                assume c,\n                have G31 : h c = some (G2 c) := by tidy,\n                have G32 : _ := some_spec (G2 c),\n                have G33 : G c (some (G2 c)) := and.left G32,\n                by tidy,\n            have G4 : f ∘ h = g := funext G3,\n            have G5 : ∀ h₁ : C ⟶ B , f ∘ h₁ = g → h₁ = h := \n                    assume h₁ fh,\n                    have G51 : f ∘ h₁ = f ∘ h := by rw [fh , G4],\n                    have G511 : f ⊚ h₁ = f ⊚ h := by tidy,\n                    have G52 : mono f := iff.elim_right (mono_iff_injective f) inj,\n                    have G53 : _ := G52.right_cancellation,\n                    G53 h₁ h G511,\n            exact exists_unique.intro h G4 G5\n        end\n\n\n\nlemma diagram_surjective\n            (f : A ⟶ B) \n            (g : A ⟶ C)\n            (sur: surjective f) \n            :   (∃! h : B ⟶ C , h ∘ f = g) ↔\n                (sub_kern f g) \n    :=\n        iff.intro\n        begin\n            assume ex : ∃ h , (h ∘ f = g ∧ \n                            ∀ h₁, h₁ ∘ f = g → h₁ = h),\n            show ∀ a₁ a₂ , kern f a₁  a₂ → kern g a₁ a₂,\n            cases ex with h spec,\n            exact spec.1 ▸ kern_comp f h\n        end\n        begin \n            assume k : ∀ a₁ a₂ , f a₁ = f a₂ → g a₁ = g a₂,\n            let h : B → C := λ b : B, g (surj_inv sur b),\n            have s2 : ∀ a , f (surj_inv sur (f a)) = f a := \n                assume a , surj_inv_eq sur (f a),\n            have s3 : ∀ a , g (surj_inv sur (f a)) = g a :=\n                assume a , k (surj_inv sur (f a)) a (s2 a),\n            have s4 : ∀ a , h (f a) = g a := \n                assume a,\n                show g (surj_inv sur (f a)) = g a,\n                from s3 a,\n            have s5:  h ∘ f = g := funext s4,\n            have s6 : ∀ h₂ :B → C , h₂ ∘ f = g → h₂ = h := \n                begin \n                    assume h₂ h2,\n                    have s61 : h₂ ∘ f = h ∘ f := by simp [s5 , h2],\n                    haveI s62 : epi f := (epi_iff_surjective f).2 sur,\n                    have left_cancel := s62.left_cancellation,\n                    have s63 : h₂ = h := left_cancel h₂ h s61,\n                    tidy\n                end,\n\n            exact exists_unique.intro h s5 s6,\n        end\n\n\n\nend diagram_lemmas", "meta": {"author": "QaisHamarneh", "repo": "Coalgebra-in-Lean", "sha": "bd0452df98bc64b608e5dfd7babc42c301bb6a46", "save_path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean", "path": "github-repos/lean/QaisHamarneh-Coalgebra-in-Lean/Coalgebra-in-Lean-bd0452df98bc64b608e5dfd7babc42c301bb6a46/src/set_category/diagram_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.46103493494631004}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.preserves.shapes.binary_products\nimport Mathlib.category_theory.limits.preserves.shapes.terminal\nimport Mathlib.category_theory.adjunction.fully_faithful\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l \n\nnamespace Mathlib\n\n/-!\n# Reflective functors\n\nBasic properties of reflective functors, especially those relating to their essential image.\n\nNote properties of reflective functors relating to limits and colimits are included in\n`category_theory.monad.limits`.\n-/\n\nnamespace category_theory\n\n\n/--\nA functor is *reflective*, or *a reflective inclusion*, if it is fully faithful and right adjoint.\n-/\nclass reflective {C : Type u₁} {D : Type u₂} [category C] [category D] (R : D ⥤ C) \nextends full R, faithful R, is_right_adjoint R\nwhere\n\n/--\nFor a reflective functor `i` (with left adjoint `L`), with unit `η`, we have `η_iL = iL η`.\n-/\n-- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions.\n\ntheorem unit_obj_eq_map_unit {C : Type u₁} {D : Type u₂} [category C] [category D] {i : D ⥤ C} [reflective i] (X : C) : nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) (functor.obj i (functor.obj (left_adjoint i) X)) =\n  functor.map i (functor.map (left_adjoint i) (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) X)) := sorry\n\n/--\nWhen restricted to objects in `D` given by `i : D ⥤ C`, the unit is an isomorphism.\nMore generally this applies to objects essentially in the reflective subcategory, see\n`functor.ess_image.unit_iso`.\n-/\nprotected instance functor.ess_image.unit_iso_restrict {C : Type u₁} {D : Type u₂} [category C] [category D] {i : D ⥤ C} [reflective i] {B : D} : is_iso (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) (functor.obj i B)) :=\n  eq.mpr sorry is_iso.inv_is_iso\n\n/--\nIf `A` is essentially in the image of a reflective functor `i`, then `η_A` is an isomorphism.\nThis gives that the \"witness\" for `A` being in the essential image can instead be given as the\nreflection of `A`, with the isomorphism as `η_A`.\n\n(For any `B` in the reflective subcategory, we automatically have that `ε_B` is an iso.)\n-/\ndef functor.ess_image.unit_is_iso {C : Type u₁} {D : Type u₂} [category C] [category D] {i : D ⥤ C} [reflective i] {A : C} (h : A ∈ functor.ess_image i) : is_iso (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) A) :=\n  eq.mpr sorry is_iso.comp_is_iso\n\n/-- If `η_A` is an isomorphism, then `A` is in the essential image of `i`. -/\ntheorem mem_ess_image_of_unit_is_iso {C : Type u₁} {D : Type u₂} [category C] [category D] {i : D ⥤ C} [is_right_adjoint i] (A : C) [is_iso (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) A)] : A ∈ functor.ess_image i :=\n  Exists.intro (functor.obj (left_adjoint i) A)\n    (Nonempty.intro (iso.symm (as_iso (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) A))))\n\n/-- If `η_A` is a split monomorphism, then `A` is in the reflective subcategory. -/\ntheorem mem_ess_image_of_unit_split_mono {C : Type u₁} {D : Type u₂} [category C] [category D] {i : D ⥤ C} [reflective i] {A : C} [split_mono (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) A)] : A ∈ functor.ess_image i :=\n  let η : 𝟭 ⟶ left_adjoint i ⋙ i := adjunction.unit (adjunction.of_right_adjoint i);\n  mem_ess_image_of_unit_is_iso A\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/adjunction/reflective.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7879311856832191, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4610194461759719}}
{"text": "import SciLean.Core.AdjDiff\n\nnamespace SciLean\n\n\nvariable {α β γ : Type}\nvariable {X Y Z W : Type} [SemiHilbert X] [SemiHilbert Y] [SemiHilbert Z] [SemiHilbert W]\nvariable {Y₁ Y₂ : Type} [SemiHilbert Y₁] [SemiHilbert Y₂]\nvariable {ι κ : Type} [Enumtype ι] [Enumtype κ]\n\n\n@[diff]\ntheorem adjoint_sum_eval\n  (f : ι → κ → X → Y) [∀ i j, HasAdjointT (f i j)]\n  : (λ (x : κ → X) => λ i => ∑ j, (f i j) (x j))†\n    =\n    λ y => λ j => ∑ i, (f i j)† (y i)\n  := by sorry -- symdiff; sorry_proof\n\n@[diff]\ntheorem adjDiff_sum_eval\n  (f : ι → κ → X → Y) [hf : ∀ i j, HasAdjDiffT (f i j)]\n  : ∂† (λ (x : κ → X) => λ i => ∑ j, (f i j) (x j))\n    =\n    λ x dy => λ j => ∑ i, ∂† (f i j) (x j) (dy i) := \nby \n  unfold adjointDifferential\n  have  := λ i j => (hf i j).1\n  have  := λ i j => (hf i j).2\n  sorry -- symdiff; symdiff\n  -- done\n\n@[diff]\ntheorem revDiff_sum_eval\n  (f : ι → κ → X → Y) [hf : ∀ i j, HasAdjDiffT (f i j)]\n  : ℛ (λ (x : κ → X) => λ i => ∑ j, (f i j) (x j))\n    =\n    λ x => (λ i => ∑ j, (f i j) (x j), \n            λ dy => λ j => ∑ i, ∂† (f i j) (x j) (dy i)) := \nby \n  unfold reverseDifferential; symdiff; done\n\n\nunif_hint adjoint_sum_eval.unif_hint_1\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → X → α → Y) (g : ι → κ → α)\nwhere\n  f? =?= λ i j x => f i j x (g i j)\n  |-\n  (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j))† \n  =?= \n  (λ (x : κ → X) => λ i => ∑ j, f i j (x j) (g i j))†\n\nunif_hint adjoint_sum_eval.unif_hint_2\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → W → α → Y) (g : ι → κ → α) (h : ι → κ → X → W)\nwhere\n  f? =?= λ i j x => f i j (h i j x) (g i j)\n  |-\n  (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j))† \n  =?= \n  (λ (x : κ → X) => λ i => ∑ j, f i j (h i j (x j)) (g i j))†\n\n\nunif_hint adjoint_sum_eval.unif_hint_3\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → W → Z → α → Y) (g : ι → κ → α) (h : ι → κ → X → W) (h' : ι → κ → X → Z)\nwhere\n  f? =?= λ i j x => f i j (h i j x) (h' i j x) (g i j)\n  |-\n  (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j))†\n  =?= \n  (λ (x : κ → X) => λ i => ∑ j, f i j (h i j (x j)) (h' i j (x j)) (g i j))†\n\n\nunif_hint adjDiff_sum_eval.unif_hint_1\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → X → α → Y) (g : ι → κ → α)\nwhere\n  f? =?= λ i j x => f i j x (g i j)\n  |-\n  ∂† (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j)) \n  =?= \n  ∂† (λ (x : κ → X) => λ i => ∑ j, f i j (x j) (g i j))\n\nunif_hint adjDiff_sum_eval.unif_hint_2\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → W → α → Y) (g : ι → κ → α) (h : ι → κ → X → W)\nwhere\n  f? =?= λ i j x => f i j (h i j x) (g i j)\n  |-\n  ∂† (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j))\n  =?= \n  ∂† (λ (x : κ → X) => λ i => ∑ j, f i j (h i j (x j)) (g i j))\n\nunif_hint adjDiff_sum_eval.unif_hint_3\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → W → Z → α → Y) (g : ι → κ → α) (h : ι → κ → X → W) (h' : ι → κ → X → Z)\nwhere\n  f? =?= λ i j x => f i j (h i j x) (h' i j x) (g i j)\n  |-\n  ∂† (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j))\n  =?= \n  ∂† (λ (x : κ → X) => λ i => ∑ j, f i j (h i j (x j)) (h' i j (x j)) (g i j))\n\nunif_hint revDiff_sum_eval.unif_hint_1\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → X → α → Y) (g : ι → κ → α)\nwhere\n  f? =?= λ i j x => f i j x (g i j)\n  |-\n  ℛ (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j)) \n  =?= \n  ℛ (λ (x : κ → X) => λ i => ∑ j, f i j (x j) (g i j))\n\nunif_hint revDiff_sum_eval.unif_hint_2\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → W → α → Y) (g : ι → κ → α) (h : ι → κ → X → W)\nwhere\n  f? =?= λ i j x => f i j (h i j x) (g i j)\n  |-\n  ℛ (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j))\n  =?= \n  ℛ (λ (x : κ → X) => λ i => ∑ j, f i j (h i j (x j)) (g i j))\n\n\nunif_hint revDiff_sum_eval.unif_hint_3\n  (f? : ι → κ → X → Y) \n  (f : ι → κ → W → Z → α → Y) (g : ι → κ → α) (h : ι → κ → X → W) (h' : ι → κ → X → Z)\nwhere\n  f? =?= λ i j x => f i j (h i j x) (h' i j x) (g i j)\n  |-\n  ℛ (λ (x : κ → X) => λ i => ∑ j, (f? i j) (x j))\n  =?= \n  ℛ (λ (x : κ → X) => λ i => ∑ j, f i j (h i j (x j)) (h' i j (x j)) (g i j))\n\n\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Core/AdjointHardCases.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.787931185683219, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.46101944617597185}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Sean Leather\n-/\nimport algebra.free_monoid\nimport algebra.opposites\nimport control.traversable.instances\nimport control.traversable.lemmas\nimport category_theory.endomorphism\nimport category_theory.types\nimport category_theory.category.Kleisli\n/-!\n\n# List folds generalized to `traversable`\n\nInformally, we can think of `foldl` as a special case of `traverse` where we do not care about the\nreconstructed data structure and, in a state monad, we care about the final state.\n\nThe obvious way to define `foldl` would be to use the state monad but it\nis nicer to reason about a more abstract interface with `fold_map` as a\nprimitive and `fold_map_hom` as a defining property.\n\n```\ndef fold_map {α ω} [has_one ω] [has_mul ω] (f : α → ω) : t α → ω := ...\n\nlemma fold_map_hom (α β)\n  [monoid α] [monoid β] (f : α →* β)\n  (g : γ → α) (x : t γ) :\n  f (fold_map g x) = fold_map (f ∘ g) x :=\n...\n```\n\n`fold_map` uses a monoid ω to accumulate a value for every element of\na data structure and `fold_map_hom` uses a monoid homomorphism to\nsubstitute the monoid used by `fold_map`. The two are sufficient to\ndefine `foldl`, `foldr` and `to_list`. `to_list` permits the\nformulation of specifications in terms of operations on lists.\n\nEach fold function can be defined using a specialized\nmonoid. `to_list` uses a free monoid represented as a list with\nconcatenation while `foldl` uses endofunctions together with function\ncomposition.\n\nThe definition through monoids uses `traverse` together with the\napplicative functor `const m` (where `m` is the monoid). As an\nimplementation, `const` guarantees that no resource is spent on\nreconstructing the structure during traversal.\n\nA special class could be defined for `foldable`, similarly to Haskell,\nbut the author cannot think of instances of `foldable` that are not also\n`traversable`.\n-/\n\nuniverses u v\n\nopen ulift category_theory mul_opposite\n\nnamespace monoid\nvariables {m : Type u → Type u} [monad m]\nvariables {α β : Type u}\n/--\nFor a list, foldl f x [y₀,y₁] reduces as follows:\n\n```\ncalc  foldl f x [y₀,y₁]\n    = foldl f (f x y₀) [y₁]      : rfl\n... = foldl f (f (f x y₀) y₁) [] : rfl\n... = f (f x y₀) y₁              : rfl\n```\nwith\n```\nf : α → β → α\nx : α\n[y₀,y₁] : list β\n```\n\nWe can view the above as a composition of functions:\n```\n... = f (f x y₀) y₁              : rfl\n... = flip f y₁ (flip f y₀ x)    : rfl\n... = (flip f y₁ ∘ flip f y₀) x  : rfl\n```\n\nWe can use traverse and const to construct this composition:\n```\ncalc   const.run (traverse (λ y, const.mk' (flip f y)) [y₀,y₁]) x\n     = const.run ((::) <$> const.mk' (flip f y₀) <*> traverse (λ y, const.mk' (flip f y)) [y₁]) x\n...  = const.run ((::) <$> const.mk' (flip f y₀) <*>\n         ( (::) <$> const.mk' (flip f y₁) <*> traverse (λ y, const.mk' (flip f y)) [] )) x\n...  = const.run ((::) <$> const.mk' (flip f y₀) <*>\n         ( (::) <$> const.mk' (flip f y₁) <*> pure [] )) x\n...  = const.run ( ((::) <$> const.mk' (flip f y₁) <*> pure []) ∘\n         ((::) <$> const.mk' (flip f y₀)) ) x\n...  = const.run ( const.mk' (flip f y₁) ∘ const.mk' (flip f y₀) ) x\n...  = const.run ( flip f y₁ ∘ flip f y₀ ) x\n...  = f (f x y₀) y₁\n```\n\nAnd this is how `const` turns a monoid into an applicative functor and\nhow the monoid of endofunctions define `foldl`.\n-/\n@[reducible] def foldl (α : Type u) : Type u := (End α)ᵐᵒᵖ\ndef foldl.mk (f : α → α) : foldl α := op f\ndef foldl.get (x : foldl α) : α → α := unop x\n@[simps] def foldl.of_free_monoid (f : β → α → β) : free_monoid α →* monoid.foldl β :=\n{ to_fun := λ xs, op $ flip (list.foldl f) xs,\n  map_one' := rfl,\n  map_mul' := by intros; simp only [free_monoid.mul_def, flip, unop_op,\n    list.foldl_append, op_inj]; refl }\n\n@[reducible] def foldr (α : Type u) : Type u := End α\ndef foldr.mk (f : α → α) : foldr α := f\ndef foldr.get (x : foldr α) : α → α := x\n@[simps] def foldr.of_free_monoid (f : α → β → β) : free_monoid α →* monoid.foldr β :=\n{ to_fun := λ xs, flip (list.foldr f) xs,\n  map_one' := rfl,\n  map_mul' :=\n    begin\n      intros,\n      simp only [free_monoid.mul_def, list.foldr_append, flip],\n      refl\n    end }\n\n\n@[reducible] def mfoldl (m : Type u → Type u) [monad m] (α : Type u) : Type u :=\nmul_opposite $ End $ Kleisli.mk m α\ndef mfoldl.mk (f : α → m α) : mfoldl m α := op f\ndef mfoldl.get (x : mfoldl m α) : α → m α := unop x\n@[simps] def mfoldl.of_free_monoid [is_lawful_monad m] (f : β → α → m β) :\n  free_monoid α →* monoid.mfoldl m β :=\n{ to_fun := λ xs, op $ flip (list.mfoldl f) xs,\n  map_one' := rfl,\n  map_mul' := by intros; apply unop_injective; ext; apply list.mfoldl_append }\n\n@[reducible] def mfoldr (m : Type u → Type u) [monad m] (α : Type u) : Type u :=\nEnd $ Kleisli.mk m α\ndef mfoldr.mk (f : α → m α) : mfoldr m α := f\ndef mfoldr.get (x : mfoldr m α) : α → m α := x\n@[simps] def mfoldr.of_free_monoid [is_lawful_monad m] (f : α → β → m β) :\n  free_monoid α →* monoid.mfoldr m β :=\n{ to_fun := λ xs, flip (list.mfoldr f) xs,\n  map_one' := rfl,\n  map_mul' := by intros; ext; apply list.mfoldr_append }\n\nend monoid\n\nnamespace traversable\nopen monoid functor\n\nsection defs\nvariables {α β : Type u} {t : Type u → Type u} [traversable t]\n\ndef fold_map {α ω} [has_one ω] [has_mul ω] (f : α → ω) : t α → ω :=\ntraverse (const.mk' ∘ f)\n\ndef foldl (f : α → β → α) (x : α) (xs : t β) : α :=\n(fold_map (foldl.mk ∘ flip f) xs).get x\n\ndef foldr (f : α → β → β) (x : β) (xs : t α) : β :=\n(fold_map (foldr.mk ∘ f) xs).get x\n\n/--\nConceptually, `to_list` collects all the elements of a collection\nin a list. This idea is formalized by\n\n  `lemma to_list_spec (x : t α) : to_list x = fold_map free_monoid.mk x`.\n\nThe definition of `to_list` is based on `foldl` and `list.cons` for\nspeed. It is faster than using `fold_map free_monoid.mk` because, by\nusing `foldl` and `list.cons`, each insertion is done in constant\ntime. As a consequence, `to_list` performs in linear.\n\nOn the other hand, `fold_map free_monoid.mk` creates a singleton list\naround each element and concatenates all the resulting lists. In\n`xs ++ ys`, concatenation takes a time proportional to `length xs`. Since\nthe order in which concatenation is evaluated is unspecified, nothing\nprevents each element of the traversable to be appended at the end\n`xs ++ [x]` which would yield a `O(n²)` run time. -/\ndef to_list : t α → list α :=\nlist.reverse ∘ foldl (flip list.cons) []\n\ndef length (xs : t α) : ℕ :=\ndown $ foldl (λ l _, up $ l.down + 1) (up 0) xs\n\nvariables {m : Type u → Type u} [monad m]\n\ndef mfoldl (f : α → β → m α) (x : α) (xs : t β) : m α :=\n(fold_map (mfoldl.mk ∘ flip f) xs).get x\n\ndef mfoldr (f : α → β → m β) (x : β) (xs : t α) : m β :=\n(fold_map (mfoldr.mk ∘ f) xs).get x\n\nend defs\n\nsection applicative_transformation\nvariables {α β γ : Type u}\n\nopen function (hiding const)\n\ndef map_fold [monoid α] [monoid β] (f : α →* β) :\n  applicative_transformation (const α) (const β) :=\n{ app := λ x, f,\n  preserves_seq'  := by { intros, simp only [f.map_mul, (<*>)], },\n  preserves_pure' := by { intros, simp only [f.map_one, pure] } }\n\ndef free.mk : α → free_monoid α := list.ret\n\ndef free.map (f : α → β) : free_monoid α →* free_monoid β :=\n{ to_fun := list.map f,\n  map_mul' := λ x y,\n    by simp only [free_monoid.mul_def, list.map_append, free_add_monoid.add_def],\n  map_one' := by simp only [free_monoid.one_def, list.map, free_add_monoid.zero_def] }\n\nlemma free.map_eq_map (f : α → β) (xs : list α) :\n  f <$> xs = free.map f xs := rfl\n\nlemma foldl.unop_of_free_monoid  (f : β → α → β) (xs : free_monoid α) (a : β) :\n  unop (foldl.of_free_monoid f xs) a = list.foldl f a xs := rfl\n\nvariables (m : Type u → Type u) [monad m] [is_lawful_monad m]\n\nvariables {t : Type u → Type u} [traversable t] [is_lawful_traversable t]\nopen is_lawful_traversable\n\nlemma fold_map_hom\n  [monoid α] [monoid β] (f : α →* β)\n  (g : γ → α) (x : t γ) :\n  f (fold_map g x) = fold_map (f ∘ g) x :=\ncalc  f (fold_map g x)\n    = f (traverse (const.mk' ∘ g) x)                                     : rfl\n... = (map_fold f).app _ (traverse (const.mk' ∘ g) x)   : rfl\n... = traverse ((map_fold f).app _ ∘ (const.mk' ∘ g)) x :\n        naturality (map_fold f) _ _\n... = fold_map (f ∘ g) x : rfl\n\nlemma fold_map_hom_free\n  [monoid β] (f : free_monoid α →* β) (x : t α) :\n  f (fold_map free.mk x) = fold_map (f ∘ free.mk) x :=\nfold_map_hom f _ x\n\nvariable {m}\n\nlemma fold_mfoldl_cons (f : α → β → m α) (x : β) (y : α) :\n  list.mfoldl f y (free.mk x) = f y x :=\nby simp only [free.mk, list.ret, list.mfoldl, bind_pure]\n\nlemma fold_mfoldr_cons (f : β → α → m α) (x : β) (y : α) :\n  list.mfoldr f y (free.mk x) = f x y :=\nby simp only [free.mk, list.ret, list.mfoldr, pure_bind]\n\nend applicative_transformation\n\nsection equalities\nopen is_lawful_traversable list (cons)\nvariables {α β γ : Type u}\nvariables {t : Type u → Type u} [traversable t] [is_lawful_traversable t]\n\n@[simp]\nlemma foldl.of_free_monoid_comp_free_mk (f : α → β → α) :\n  foldl.of_free_monoid f ∘ free.mk = foldl.mk ∘ flip f := rfl\n\n@[simp]\nlemma foldr.of_free_monoid_comp_free_mk (f : β → α → α) :\n  foldr.of_free_monoid f ∘ free.mk = foldr.mk ∘ f := rfl\n\n@[simp]\nlemma mfoldl.of_free_monoid_comp_free_mk {m} [monad m] [is_lawful_monad m] (f : α → β → m α) :\n  mfoldl.of_free_monoid f ∘ free.mk = mfoldl.mk ∘ flip f :=\nby ext; simp [(∘), mfoldl.of_free_monoid, mfoldl.mk, flip, fold_mfoldl_cons]; refl\n\n@[simp]\nlemma mfoldr.of_free_monoid_comp_free_mk {m} [monad m] [is_lawful_monad m] (f : β → α → m α) :\n  mfoldr.of_free_monoid f ∘ free.mk = mfoldr.mk ∘ f :=\nby { ext, simp [(∘), mfoldr.of_free_monoid, mfoldr.mk, flip, fold_mfoldr_cons] }\n\nlemma to_list_spec (xs : t α) :\n  to_list xs = (fold_map free.mk xs : free_monoid _) :=\neq.symm $\ncalc  fold_map free.mk xs\n    = (fold_map free.mk xs).reverse.reverse : by simp only [list.reverse_reverse]\n... = (list.foldr cons [] (fold_map free.mk xs).reverse).reverse\n                 : by simp only [list.foldr_eta]\n... = (unop (foldl.of_free_monoid (flip cons) (fold_map free.mk xs)) []).reverse\n                 : by simp [flip,list.foldr_reverse,foldl.of_free_monoid, unop_op]\n... = to_list xs : begin\n                     rw fold_map_hom_free (foldl.of_free_monoid (flip $ @cons α)),\n                     simp only [to_list, foldl, list.reverse_inj, foldl.get,\n                       foldl.of_free_monoid_comp_free_mk],\n                     all_goals { apply_instance }\n                   end\n\nlemma fold_map_map [monoid γ]  (f : α → β) (g : β → γ) (xs : t α) :\n  fold_map g (f <$> xs) = fold_map (g ∘ f) xs :=\nby simp only [fold_map,traverse_map]\n\nlemma foldl_to_list (f : α → β → α) (xs : t β) (x : α) :\n  foldl f x xs = list.foldl f x (to_list xs) :=\nbegin\n  rw ← foldl.unop_of_free_monoid,\n  simp only [foldl, to_list_spec, fold_map_hom_free,\n    foldl.of_free_monoid_comp_free_mk, foldl.get]\nend\n\nlemma foldr_to_list (f : α → β → β) (xs : t α) (x : β) :\n  foldr f x xs = list.foldr f x (to_list xs) :=\nbegin\n  change _ = foldr.of_free_monoid _ _ _,\n  simp only [foldr, to_list_spec, fold_map_hom_free,\n    foldr.of_free_monoid_comp_free_mk, foldr.get]\nend\n\nlemma to_list_map (f : α → β) (xs : t α) :\n  to_list (f <$> xs) = f <$> to_list xs := by\n{ simp only [to_list_spec,free.map_eq_map,fold_map_hom (free.map f), fold_map_map];\n  refl }\n\n@[simp] theorem foldl_map (g : β → γ) (f : α → γ → α) (a : α) (l : t β) :\n  foldl f a (g <$> l) = foldl (λ x y, f x (g y)) a l :=\nby simp only [foldl, fold_map_map, (∘), flip]\n\n@[simp] theorem foldr_map (g : β → γ) (f : γ → α → α) (a : α) (l : t β) :\n  foldr f a (g <$> l) = foldr (f ∘ g) a l :=\nby simp only [foldr, fold_map_map, (∘), flip]\n\n@[simp] theorem to_list_eq_self {xs : list α} : to_list xs = xs :=\nbegin\n  simp only [to_list_spec, fold_map, traverse],\n  induction xs,\n  case list.nil { refl },\n  case list.cons : _ _ ih { unfold list.traverse list.ret, rw ih, refl }\nend\n\ntheorem length_to_list {xs : t α} : length xs = list.length (to_list xs) :=\nbegin\n  unfold length,\n  rw foldl_to_list,\n  generalize : to_list xs = ys,\n  let f := λ (n : ℕ) (a : α), n + 1,\n  transitivity list.foldl f 0 ys,\n  { generalize : 0 = n,\n    induction ys with _ _ ih generalizing n,\n    { simp only [list.foldl_nil] },\n    { simp only [list.foldl, ih (n+1)] } },\n  { induction ys with _ tl ih,\n    { simp only [list.length, list.foldl_nil] },\n    { simp only [list.foldl, list.length],\n      rw [← ih],\n      exact tl.foldl_hom (λx, x+1) f f 0 (λ n x, rfl) } }\nend\n\nvariables {m : Type u → Type u} [monad m] [is_lawful_monad m]\n\nlemma mfoldl_to_list {f : α → β → m α} {x : α} {xs : t β} :\n  mfoldl f x xs = list.mfoldl f x (to_list xs) :=\ncalc mfoldl f x xs = unop (mfoldl.of_free_monoid f (to_list xs)) x :\n  by simp only [mfoldl, to_list_spec, fold_map_hom_free (mfoldl.of_free_monoid f),\n    mfoldl.of_free_monoid_comp_free_mk, mfoldl.get]\n... = list.mfoldl f x (to_list xs) : by simp [mfoldl.of_free_monoid, unop_op, flip]\n\nlemma mfoldr_to_list (f : α → β → m β) (x : β) (xs : t α) :\n  mfoldr f x xs = list.mfoldr f x (to_list xs) :=\nbegin\n  change _ = mfoldr.of_free_monoid f (to_list xs) x,\n  simp only [mfoldr, to_list_spec, fold_map_hom_free (mfoldr.of_free_monoid f),\n    mfoldr.of_free_monoid_comp_free_mk, mfoldr.get]\nend\n\n@[simp] theorem mfoldl_map (g : β → γ) (f : α → γ → m α) (a : α) (l : t β) :\n  mfoldl f a (g <$> l) = mfoldl (λ x y, f x (g y)) a l :=\nby simp only [mfoldl, fold_map_map, (∘), flip]\n\n@[simp] theorem mfoldr_map (g : β → γ) (f : γ → α → m α) (a : α) (l : t β) :\n  mfoldr f a (g <$> l) = mfoldr (f ∘ g) a l :=\nby simp only [mfoldr, fold_map_map, (∘), flip]\n\nend equalities\n\nend traversable\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/control/fold.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4609014209445247}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.lie.basic\nimport ring_theory.noetherian\n\n/-!\n# Lie subalgebras\n\nThis file defines Lie subalgebras of a Lie algebra and provides basic related definitions and\nresults.\n\n## Main definitions\n\n  * `lie_subalgebra`\n  * `lie_subalgebra.incl`\n  * `lie_subalgebra.map`\n  * `lie_hom.range`\n  * `lie_equiv.of_injective`\n  * `lie_equiv.of_eq`\n  * `lie_equiv.of_subalgebra`\n  * `lie_equiv.of_subalgebras`\n\n## Tags\n\nlie algebra, lie subalgebra\n-/\n\nuniverses u v w w₁ w₂\n\nsection lie_subalgebra\n\nvariables (R : Type u) (L : Type v) [comm_ring R] [lie_ring L] [lie_algebra R L]\n\nset_option old_structure_cmd true\n/-- A Lie subalgebra of a Lie algebra is submodule that is closed under the Lie bracket.\nThis is a sufficient condition for the subset itself to form a Lie algebra. -/\nstructure lie_subalgebra extends submodule R L :=\n(lie_mem' : ∀ {x y}, x ∈ carrier → y ∈ carrier → ⁅x, y⁆ ∈ carrier)\n\nattribute [nolint doc_blame] lie_subalgebra.to_submodule\n\n/-- The zero algebra is a subalgebra of any Lie algebra. -/\ninstance : has_zero (lie_subalgebra R L) :=\n⟨{ lie_mem' := λ x y hx hy, by { rw [((submodule.mem_bot R).1 hx), zero_lie],\n                                exact submodule.zero_mem (0 : submodule R L), },\n   ..(0 : submodule R L) }⟩\n\ninstance : inhabited (lie_subalgebra R L) := ⟨0⟩\ninstance : has_coe (lie_subalgebra R L) (submodule R L) := ⟨lie_subalgebra.to_submodule⟩\ninstance : has_mem L (lie_subalgebra R L) := ⟨λ x L', x ∈ (L' : set L)⟩\n\n/-- A Lie subalgebra forms a new Lie ring. -/\ninstance lie_subalgebra_lie_ring (L' : lie_subalgebra R L) : lie_ring L' :=\n{ bracket      := λ x y, ⟨⁅x.val, y.val⁆, L'.lie_mem' x.property y.property⟩,\n  lie_add      := by { intros, apply set_coe.ext, apply lie_add, },\n  add_lie      := by { intros, apply set_coe.ext, apply add_lie, },\n  lie_self     := by { intros, apply set_coe.ext, apply lie_self, },\n  leibniz_lie  := by { intros, apply set_coe.ext, apply leibniz_lie, } }\n\n/-- A Lie subalgebra forms a new Lie algebra. -/\ninstance lie_subalgebra_lie_algebra (L' : lie_subalgebra R L) : lie_algebra R L' :=\n{ lie_smul := by { intros, apply set_coe.ext, apply lie_smul } }\n\nnamespace lie_subalgebra\n\nvariables {R L} (L' : lie_subalgebra R L)\n\n@[simp] lemma zero_mem : (0 : L) ∈ L' := (L' : submodule R L).zero_mem\n\nlemma smul_mem (t : R) {x : L} (h : x ∈ L') : t • x ∈ L' := (L' : submodule R L).smul_mem t h\n\nlemma add_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (x + y : L) ∈ L' :=\n(L' : submodule R L).add_mem hx hy\n\nlemma sub_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (x - y : L) ∈ L' :=\n(L' : submodule R L).sub_mem hx hy\n\nlemma lie_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (⁅x, y⁆ : L) ∈ L' := L'.lie_mem' hx hy\n\n@[simp] lemma mem_carrier {x : L} : x ∈ L'.carrier ↔ x ∈ (L' : set L) := iff.rfl\n\n@[simp] lemma mem_coe_submodule {x : L} : x ∈ (L' : submodule R L) ↔ x ∈ L' := iff.rfl\n\nlemma mem_coe {x : L} : x ∈ (L' : set L) ↔ x ∈ L' := iff.rfl\n\n@[simp, norm_cast] lemma coe_bracket (x y : L') : (↑⁅x, y⁆ : L) = ⁅(↑x : L), ↑y⁆ := rfl\n\nlemma ext_iff (x y : L') : x = y ↔ (x : L) = y := subtype.ext_iff\n\nlemma coe_zero_iff_zero (x : L') : (x : L) = 0 ↔ x = 0 := (ext_iff L' x 0).symm\n\n@[ext] lemma ext (L₁' L₂' : lie_subalgebra R L) (h : ∀ x, x ∈ L₁' ↔ x ∈ L₂') :\n  L₁' = L₂' :=\nby { cases L₁', cases L₂', simp only [], ext x, exact h x, }\n\nlemma ext_iff' (L₁' L₂' : lie_subalgebra R L) : L₁' = L₂' ↔ ∀ x, x ∈ L₁' ↔ x ∈ L₂' :=\n⟨λ h x, by rw h, ext L₁' L₂'⟩\n\n@[simp] lemma mk_coe (S : set L) (h₁ h₂ h₃ h₄) :\n  ((⟨S, h₁, h₂, h₃, h₄⟩ : lie_subalgebra R L) : set L) = S := rfl\n\n@[simp] lemma coe_to_submodule_mk (p : submodule R L) (h) :\n  (({lie_mem' := h, ..p} : lie_subalgebra R L) : submodule R L) = p :=\nby { cases p, refl, }\n\nlemma coe_injective : function.injective (coe : lie_subalgebra R L → set L) :=\nλ L₁' L₂' h, by cases L₁'; cases L₂'; congr'\n\n@[norm_cast] theorem coe_set_eq (L₁' L₂' : lie_subalgebra R L) :\n  (L₁' : set L) = L₂' ↔ L₁' = L₂' := coe_injective.eq_iff\n\nlemma to_submodule_injective :\n  function.injective (coe : lie_subalgebra R L → submodule R L) :=\nλ L₁' L₂' h, by { rw set_like.ext'_iff at h, rw ← coe_set_eq, exact h, }\n\n@[simp] lemma coe_to_submodule_eq_iff (L₁' L₂' : lie_subalgebra R L) :\n  (L₁' : submodule R L) = (L₂' : submodule R L) ↔ L₁' = L₂' :=\nto_submodule_injective.eq_iff\n\n@[norm_cast]\nlemma coe_to_submodule : ((L' : submodule R L) : set L) = L' := rfl\n\nsection lie_module\n\nvariables {M : Type w} [add_comm_group M] [lie_ring_module L M]\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie ring module\n`M` of `L`, we may regard `M` as a Lie ring module of `L'` by restriction. -/\ninstance : lie_ring_module L' M :=\n{ bracket     := λ x m, ⁅(x : L), m⁆,\n  add_lie     := λ x y m, add_lie x y m,\n  lie_add     := λ x y m, lie_add x y m,\n  leibniz_lie := λ x y m, leibniz_lie x y m, }\n\n@[simp] lemma coe_bracket_of_module (x : L') (m : M) : ⁅x, m⁆ = ⁅(x : L), m⁆ := rfl\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie module `M` of\n`L`, we may regard `M` as a Lie module of `L'` by restriction. -/\ninstance [module R M] [lie_module R L M] : lie_module R L' M :=\n{ smul_lie := λ t x m, by simp only [coe_bracket_of_module, smul_lie, submodule.coe_smul_of_tower],\n  lie_smul := λ t x m, by simp only [coe_bracket_of_module, lie_smul], }\n\nend lie_module\n\nend lie_subalgebra\n\nvariables {R L} {L₂ : Type w} [lie_ring L₂] [lie_algebra R L₂]\nvariables (f : L →ₗ⁅R⁆ L₂)\n\n/-- The embedding of a Lie subalgebra into the ambient space as a Lie morphism. -/\ndef lie_subalgebra.incl (L' : lie_subalgebra R L) : L' →ₗ⁅R⁆ L :=\n{ map_lie' := λ x y, by { rw [linear_map.to_fun_eq_coe, submodule.subtype_apply], refl, },\n  ..L'.to_submodule.subtype }\n\nnamespace lie_hom\n\n/-- The range of a morphism of Lie algebras is a Lie subalgebra. -/\ndef range : lie_subalgebra R L₂ :=\n{ lie_mem' := λ x y,\n    show x ∈ f.to_linear_map.range → y ∈ f.to_linear_map.range → ⁅x, y⁆ ∈ f.to_linear_map.range,\n    by { repeat { rw linear_map.mem_range }, rintros ⟨x', hx⟩ ⟨y', hy⟩, refine ⟨⁅x', y'⁆, _⟩,\n         rw [←hx, ←hy], change f ⁅x', y'⁆ = ⁅f x', f y'⁆, rw map_lie, },\n  ..(f : L →ₗ[R] L₂).range }\n\n@[simp] lemma range_coe : (f.range : set L₂) = set.range f :=\nlinear_map.range_coe ↑f\n\n@[simp] lemma mem_range (x : L₂) : x ∈ f.range ↔ ∃ (y : L), f y = x := linear_map.mem_range\n\nlemma mem_range_self (x : L) : f x ∈ f.range := linear_map.mem_range_self f x\n\n/-- We can restrict a morphism to a (surjective) map to its range. -/\ndef range_restrict : L →ₗ⁅R⁆ f.range :=\n{ map_lie' := λ x y, by { apply subtype.ext, exact f.map_lie x y, },\n  ..(f : L →ₗ[R] L₂).range_restrict, }\n\n@[simp] lemma range_restrict_apply (x : L) : f.range_restrict x = ⟨f x, f.mem_range_self x⟩ := rfl\n\nlemma surjective_range_restrict : function.surjective (f.range_restrict) :=\nbegin\n  rintros ⟨y, hy⟩,\n  erw mem_range at hy, obtain ⟨x, rfl⟩ := hy,\n  use x,\n  simp only [subtype.mk_eq_mk, range_restrict_apply],\nend\n\nend lie_hom\n\nlemma submodule.exists_lie_subalgebra_coe_eq_iff (p : submodule R L) :\n  (∃ (K : lie_subalgebra R L), ↑K = p) ↔ ∀ (x y : L), x ∈ p → y ∈ p → ⁅x, y⁆ ∈ p :=\nbegin\n  split,\n  { rintros ⟨K, rfl⟩, exact K.lie_mem', },\n  { intros h, use { lie_mem' := h, ..p }, exact lie_subalgebra.coe_to_submodule_mk p _, },\nend\n\nnamespace lie_subalgebra\n\nvariables (K K' : lie_subalgebra R L) (K₂ : lie_subalgebra R L₂)\n\n@[simp] lemma incl_range : K.incl.range = K :=\nby { rw ← coe_to_submodule_eq_iff, exact (K : submodule R L).range_subtype, }\n\n/-- The image of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the\ncodomain. -/\ndef map : lie_subalgebra R L₂ :=\n{ lie_mem' := λ x y hx hy, by {\n    erw submodule.mem_map at hx, rcases hx with ⟨x', hx', hx⟩, rw ←hx,\n    erw submodule.mem_map at hy, rcases hy with ⟨y', hy', hy⟩, rw ←hy,\n    erw submodule.mem_map,\n    exact ⟨⁅x', y'⁆, K.lie_mem hx' hy', f.map_lie x' y'⟩, },\n..((K : submodule R L).map (f : L →ₗ[R] L₂)) }\n\n@[simp] lemma mem_map (x : L₂) : x ∈ K.map f ↔ ∃ (y : L), y ∈ K ∧ f y = x := submodule.mem_map\n\n-- TODO Rename and state for homs instead of equivs.\n@[simp] lemma mem_map_submodule (e : L ≃ₗ⁅R⁆ L₂) (x : L₂) :\n  x ∈ K.map (e : L →ₗ⁅R⁆ L₂) ↔ x ∈ (K : submodule R L).map (e : L →ₗ[R] L₂) :=\niff.rfl\n\n/-- The preimage of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the\ndomain. -/\ndef comap : lie_subalgebra R L :=\n{ lie_mem' := λ x y hx hy, by\n    { suffices : ⁅f x, f y⁆ ∈ K₂, by { simp [this], }, exact K₂.lie_mem hx hy, },\n  ..((K₂ : submodule R L₂).comap (f : L →ₗ[R] L₂)), }\n\nsection lattice_structure\n\nopen set\n\ninstance : partial_order (lie_subalgebra R L) :=\n{ le := λ N N', ∀ ⦃x⦄, x ∈ N → x ∈ N', -- Overriding `le` like this gives a better defeq.\n  ..partial_order.lift (coe : lie_subalgebra R L → set L) coe_injective }\n\nlemma le_def : K ≤ K' ↔ (K : set L) ⊆ K' := iff.rfl\n\n@[simp, norm_cast] lemma coe_submodule_le_coe_submodule : (K : submodule R L) ≤ K' ↔ K ≤ K' :=\niff.rfl\n\ninstance : has_bot (lie_subalgebra R L) := ⟨0⟩\n\n@[simp] lemma bot_coe : ((⊥ : lie_subalgebra R L) : set L) = {0} := rfl\n\n@[simp] lemma bot_coe_submodule : ((⊥ : lie_subalgebra R L) : submodule R L) = ⊥ := rfl\n\n@[simp] lemma mem_bot (x : L) : x ∈ (⊥ : lie_subalgebra R L) ↔ x = 0 := mem_singleton_iff\n\ninstance : has_top (lie_subalgebra R L) :=\n⟨{ lie_mem' := λ x y hx hy, mem_univ ⁅x, y⁆,\n   ..(⊤ : submodule R L) }⟩\n\n@[simp] lemma top_coe : ((⊤ : lie_subalgebra R L) : set L) = univ := rfl\n\n@[simp] lemma top_coe_submodule : ((⊤ : lie_subalgebra R L) : submodule R L) = ⊤ := rfl\n\n@[simp] lemma mem_top (x : L) : x ∈ (⊤ : lie_subalgebra R L) := mem_univ x\n\nlemma _root_.lie_hom.range_eq_map : f.range = map f ⊤ :=\nby { ext, simp }\n\ninstance : has_inf (lie_subalgebra R L) :=\n⟨λ K K', { lie_mem' := λ x y hx hy, mem_inter (K.lie_mem hx.1 hy.1) (K'.lie_mem hx.2 hy.2),\n            ..(K ⊓ K' : submodule R L) }⟩\n\ninstance : has_Inf (lie_subalgebra R L) :=\n⟨λ S, { lie_mem' := λ x y hx hy, by\n        { simp only [submodule.mem_carrier, mem_Inter, submodule.Inf_coe, mem_set_of_eq,\n            forall_apply_eq_imp_iff₂, exists_imp_distrib] at *,\n          intros K hK, exact K.lie_mem (hx K hK) (hy K hK), },\n        ..Inf {(s : submodule R L) | s ∈ S} }⟩\n\n@[simp] theorem inf_coe : (↑(K ⊓ K') : set L) = K ∩ K' := rfl\n\n@[simp] lemma Inf_coe_to_submodule (S : set (lie_subalgebra R L)) :\n  (↑(Inf S) : submodule R L) = Inf {(s : submodule R L) | s ∈ S} := rfl\n\n@[simp] lemma Inf_coe (S : set (lie_subalgebra R L)) : (↑(Inf S) : set L) = ⋂ s ∈ S, (s : set L) :=\nbegin\n  rw [← coe_to_submodule, Inf_coe_to_submodule, submodule.Inf_coe],\n  ext x,\n  simpa only [mem_Inter, mem_set_of_eq, forall_apply_eq_imp_iff₂, exists_imp_distrib],\nend\n\nlemma Inf_glb (S : set (lie_subalgebra R L)) : is_glb S (Inf S) :=\nbegin\n  have h : ∀ (K K' : lie_subalgebra R L), (K : set L) ≤ K' ↔ K ≤ K', { intros, exact iff.rfl, },\n  simp only [is_glb.of_image h, Inf_coe, is_glb_binfi],\nend\n\n/-- The set of Lie subalgebras of a Lie algebra form a complete lattice.\n\nWe provide explicit values for the fields `bot`, `top`, `inf` to get more convenient definitions\nthan we would otherwise obtain from `complete_lattice_of_Inf`. -/\ninstance : complete_lattice (lie_subalgebra R L) :=\n{ bot          := ⊥,\n  bot_le       := λ N _ h, by { rw mem_bot at h, rw h, exact N.zero_mem', },\n  top          := ⊤,\n  le_top       := λ _ _ _, trivial,\n  inf          := (⊓),\n  le_inf       := λ N₁ N₂ N₃ h₁₂ h₁₃ m hm, ⟨h₁₂ hm, h₁₃ hm⟩,\n  inf_le_left  := λ _ _ _, and.left,\n  inf_le_right := λ _ _ _, and.right,\n  ..complete_lattice_of_Inf _ Inf_glb }\n\ninstance : add_comm_monoid (lie_subalgebra R L) :=\n{ add       := (⊔),\n  add_assoc := λ _ _ _, sup_assoc,\n  zero      := ⊥,\n  zero_add  := λ _, bot_sup_eq,\n  add_zero  := λ _, sup_bot_eq,\n  add_comm  := λ _ _, sup_comm, }\n\n@[simp] lemma add_eq_sup : K + K' = K ⊔ K' := rfl\n\n@[norm_cast, simp] lemma inf_coe_to_submodule :\n  (↑(K ⊓ K') : submodule R L) = (K : submodule R L) ⊓ (K' : submodule R L) := rfl\n\n@[simp] lemma mem_inf (x : L) : x ∈ K ⊓ K' ↔ x ∈ K ∧ x ∈ K' :=\nby rw [← mem_coe_submodule, ← mem_coe_submodule, ← mem_coe_submodule, inf_coe_to_submodule,\n  submodule.mem_inf]\n\nlemma eq_bot_iff : K = ⊥ ↔ ∀ (x : L), x ∈ K → x = 0 :=\nby { rw eq_bot_iff, exact iff.rfl, }\n\n-- TODO[gh-6025]: make this an instance once safe to do so\nlemma subsingleton_of_bot : subsingleton (lie_subalgebra R ↥(⊥ : lie_subalgebra R L)) :=\nbegin\n  apply subsingleton_of_bot_eq_top,\n  ext ⟨x, hx⟩, change x ∈ ⊥ at hx, rw submodule.mem_bot at hx, subst hx,\n  simp only [true_iff, eq_self_iff_true, submodule.mk_eq_zero, mem_bot],\nend\n\nvariables (R L)\n\nlemma well_founded_of_noetherian [is_noetherian R L] :\n  well_founded ((>) : lie_subalgebra R L → lie_subalgebra R L → Prop) :=\nbegin\n  let f : ((>) : lie_subalgebra R L → lie_subalgebra R L → Prop) →r\n          ((>) : submodule R L → submodule R L → Prop) :=\n  { to_fun       := coe,\n    map_rel' := λ N N' h, h, },\n  apply f.well_founded, rw ← is_noetherian_iff_well_founded, apply_instance,\nend\n\nvariables {R L K K' f}\n\nsection nested_subalgebras\n\nvariables (h : K ≤ K')\n\n/-- Given two nested Lie subalgebras `K ⊆ K'`, the inclusion `K ↪ K'` is a morphism of Lie\nalgebras. -/\ndef hom_of_le : K →ₗ⁅R⁆ K' :=\n{ map_lie' := λ x y, rfl,\n  ..submodule.of_le h }\n\n@[simp] lemma coe_hom_of_le (x : K) : (hom_of_le h x : L) = x := rfl\n\nlemma hom_of_le_apply (x : K) : hom_of_le h x = ⟨x.1, h x.2⟩ := rfl\n\nlemma hom_of_le_injective : function.injective (hom_of_le h) :=\nλ x y, by simp only [hom_of_le_apply, imp_self, subtype.mk_eq_mk, set_like.coe_eq_coe,\n  subtype.val_eq_coe]\n\n/-- Given two nested Lie subalgebras `K ⊆ K'`, we can view `K` as a Lie subalgebra of `K'`,\nregarded as Lie algebra in its own right. -/\ndef of_le : lie_subalgebra R K' := (hom_of_le h).range\n\n@[simp] lemma mem_of_le (x : K') : x ∈ of_le h ↔ (x : L) ∈ K :=\nbegin\n  simp only [of_le, hom_of_le_apply, lie_hom.mem_range],\n  split,\n  { rintros ⟨y, rfl⟩, exact y.property, },\n  { intros h, use ⟨(x : L), h⟩, simp, },\nend\n\nlemma of_le_eq_comap_incl : of_le h = K.comap K'.incl :=\nby { ext, rw mem_of_le, refl, }\n\nend nested_subalgebras\n\nlemma map_le_iff_le_comap {K : lie_subalgebra R L} {K' : lie_subalgebra R L₂} :\n  map f K ≤ K' ↔ K ≤ comap f K' := set.image_subset_iff\n\nlemma gc_map_comap : galois_connection (map f) (comap f) := λ K K', map_le_iff_le_comap\n\nend lattice_structure\n\nsection lie_span\n\nvariables (R L) (s : set L)\n\n/-- The Lie subalgebra of a Lie algebra `L` generated by a subset `s ⊆ L`. -/\ndef lie_span : lie_subalgebra R L := Inf {N | s ⊆ N}\n\nvariables {R L s}\n\nlemma mem_lie_span {x : L} : x ∈ lie_span R L s ↔ ∀ K : lie_subalgebra R L, s ⊆ K → x ∈ K :=\nby { change x ∈ (lie_span R L s : set L) ↔ _, erw Inf_coe, exact set.mem_bInter_iff, }\n\nlemma subset_lie_span : s ⊆ lie_span R L s :=\nby { intros m hm, erw mem_lie_span, intros K hK, exact hK hm, }\n\nlemma submodule_span_le_lie_span : submodule.span R s ≤ lie_span R L s :=\nby { rw submodule.span_le, apply subset_lie_span, }\n\nlemma lie_span_le {K} : lie_span R L s ≤ K ↔ s ⊆ K :=\nbegin\n  split,\n  { exact set.subset.trans subset_lie_span, },\n  { intros hs m hm, rw mem_lie_span at hm, exact hm _ hs, },\nend\n\nlemma lie_span_mono {t : set L} (h : s ⊆ t) : lie_span R L s ≤ lie_span R L t :=\nby { rw lie_span_le, exact set.subset.trans h subset_lie_span, }\n\nlemma lie_span_eq : lie_span R L (K : set L) = K :=\nle_antisymm (lie_span_le.mpr rfl.subset) subset_lie_span\n\nlemma coe_lie_span_submodule_eq_iff {p : submodule R L} :\n  (lie_span R L (p : set L) : submodule R L) = p ↔ ∃ (K : lie_subalgebra R L), ↑K = p :=\nbegin\n  rw p.exists_lie_subalgebra_coe_eq_iff, split; intros h,\n  { intros x m hm, rw [← h, mem_coe_submodule], exact lie_mem _ (subset_lie_span hm), },\n  { rw [← coe_to_submodule_mk p h, coe_to_submodule, coe_to_submodule_eq_iff, lie_span_eq], },\nend\n\nend lie_span\n\nend lie_subalgebra\n\nend lie_subalgebra\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w}\nvariables [comm_ring R] [lie_ring L₁] [lie_ring L₂] [lie_algebra R L₁] [lie_algebra R L₂]\n\n/-- An injective Lie algebra morphism is an equivalence onto its range. -/\nnoncomputable def of_injective (f : L₁ →ₗ⁅R⁆ L₂) (h : function.injective f) :\n  L₁ ≃ₗ⁅R⁆ f.range :=\nhave h' : (f : L₁ →ₗ[R] L₂).ker = ⊥ := linear_map.ker_eq_bot_of_injective h,\n{ map_lie' := λ x y, by { apply set_coe.ext, simpa, },\n..(linear_equiv.of_injective ↑f h')}\n\n@[simp] lemma of_injective_apply (f : L₁ →ₗ⁅R⁆ L₂) (h : function.injective f) (x : L₁) :\n  ↑(of_injective f h x) = f x := rfl\n\nvariables (L₁' L₁'' : lie_subalgebra R L₁) (L₂' : lie_subalgebra R L₂)\n\n/-- Lie subalgebras that are equal as sets are equivalent as Lie algebras. -/\ndef of_eq (h : (L₁' : set L₁) = L₁'') : L₁' ≃ₗ⁅R⁆ L₁'' :=\n{ map_lie' := λ x y, by { apply set_coe.ext, simp, },\n  ..(linear_equiv.of_eq ↑L₁' ↑L₁''\n      (by {ext x, change x ∈ (L₁' : set L₁) ↔ x ∈ (L₁'' : set L₁), rw h, } )) }\n\n@[simp] lemma of_eq_apply (L L' : lie_subalgebra R L₁) (h : (L : set L₁) = L') (x : L) :\n  (↑(of_eq L L' h x) : L₁) = x := rfl\n\nvariables (e : L₁ ≃ₗ⁅R⁆ L₂)\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef of_subalgebra : L₁'' ≃ₗ⁅R⁆ (L₁''.map e : lie_subalgebra R L₂) :=\n{ map_lie' := λ x y, by { apply set_coe.ext, exact lie_hom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y, }\n  ..(linear_equiv.of_submodule (e : L₁ ≃ₗ[R] L₂) ↑L₁'') }\n\n@[simp] lemma of_subalgebra_apply (x : L₁'') : ↑(e.of_subalgebra _  x) = e x := rfl\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef of_subalgebras (h : L₁'.map ↑e = L₂') : L₁' ≃ₗ⁅R⁆ L₂' :=\n{ map_lie' := λ x y, by { apply set_coe.ext, exact lie_hom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y, },\n  ..(linear_equiv.of_submodules (e : L₁ ≃ₗ[R] L₂) ↑L₁' ↑L₂' (by { rw ←h, refl, })) }\n\n@[simp] lemma of_subalgebras_apply (h : L₁'.map ↑e = L₂') (x : L₁') :\n  ↑(e.of_subalgebras _ _ h x) = e x := rfl\n\n@[simp] lemma of_subalgebras_symm_apply (h : L₁'.map ↑e = L₂') (x : L₂') :\n  ↑((e.of_subalgebras _ _ h).symm x) = e.symm x := rfl\n\nend lie_equiv\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/lie/subalgebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.46089411354901166}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Yaël Dillies, Bhavik Mehta\n-/\nimport data.finset.lattice\nimport data.set.sigma\n\n/-!\n# Finite sets in a sigma type\n\nThis file defines a few `finset` constructions on `Σ i, α i`.\n\n## Main declarations\n\n* `finset.sigma`: Given a finset `s` in `ι` and finsets `t i` in each `α i`, `s.sigma t` is the\n  finset of the dependent sum `Σ i, α i`\n* `finset.sigma_lift`: Lifts maps `α i → β i → finset (γ i)` to a map\n  `Σ i, α i → Σ i, β i → finset (Σ i, γ i)`.\n\n## TODO\n\n`finset.sigma_lift` can be generalized to any alternative functor. But to make the generalization\nworth it, we must first refactor the functor library so that the `alternative` instance for `finset`\nis computable and universe-polymorphic.\n-/\n\nopen function multiset\n\nvariables {ι : Type*}\n\nnamespace finset\nsection sigma\nvariables {α : ι → Type*} {β : Type*} (s s₁ s₂ : finset ι) (t t₁ t₂ : Π i, finset (α i))\n\n/-- `s.sigma t` is the finset of dependent pairs `⟨i, a⟩` such that `i ∈ s` and `a ∈ t i`. -/\nprotected def sigma : finset (Σ i, α i) := ⟨_, s.nodup.sigma $ λ i, (t i).nodup⟩\n\nvariables {s s₁ s₂ t t₁ t₂}\n\n@[simp] lemma mem_sigma {a : Σ i, α i} : a ∈ s.sigma t ↔ a.1 ∈ s ∧ a.2 ∈ t a.1 := mem_sigma\n\n@[simp, norm_cast] lemma coe_sigma (s : finset ι) (t : Π i, finset (α i)) :\n  (s.sigma t : set (Σ i, α i)) = (s : set ι).sigma (λ i, t i) :=\nset.ext $ λ _, mem_sigma\n\n@[simp] lemma sigma_nonempty : (s.sigma t).nonempty ↔ ∃ i ∈ s, (t i).nonempty :=\nby simp [finset.nonempty]\n\n@[simp] lemma sigma_eq_empty : s.sigma t = ∅ ↔ ∀ i ∈ s, t i = ∅ :=\nby simp only [← not_nonempty_iff_eq_empty, sigma_nonempty, not_exists]\n\n@[mono] lemma sigma_mono (hs : s₁ ⊆ s₂) (ht : ∀ i, t₁ i ⊆ t₂ i) : s₁.sigma t₁ ⊆ s₂.sigma t₂ :=\nλ ⟨i, a⟩ h, let ⟨hi, ha⟩ := mem_sigma.1 h in mem_sigma.2 ⟨hs hi, ht i ha⟩\n\nlemma sigma_eq_bUnion [decidable_eq (Σ i, α i)] (s : finset ι) (t : Π i, finset (α i)) :\n  s.sigma t = s.bUnion (λ i, (t i).map $ embedding.sigma_mk i) :=\nby { ext ⟨x, y⟩, simp [and.left_comm] }\n\nvariables (s t) (f : (Σ i, α i) → β)\n\nlemma sup_sigma [semilattice_sup β] [order_bot β] :\n  (s.sigma t).sup f = s.sup (λ i, (t i).sup $ λ b, f ⟨i, b⟩) :=\nbegin\n  refine (sup_le _).antisymm (sup_le $ λ i hi, sup_le $ λ b hb, le_sup $ mem_sigma.2 ⟨hi, hb⟩),\n  rintro ⟨i, b⟩ hb,\n  rw mem_sigma at hb,\n  refine le_trans _ (le_sup hb.1),\n  convert le_sup hb.2,\nend\n\nlemma inf_sigma [semilattice_inf β] [order_top β] :\n  (s.sigma t).inf f = s.inf (λ i, (t i).inf $ λ b, f ⟨i, b⟩) :=\n@sup_sigma _ _ (order_dual β) _ _ _ _ _\n\nend sigma\n\nsection sigma_lift\nvariables {α β γ : ι → Type*} [decidable_eq ι]\n\n/-- Lifts maps `α i → β i → finset (γ i)` to a map `Σ i, α i → Σ i, β i → finset (Σ i, γ i)`. -/\ndef sigma_lift (f : Π ⦃i⦄, α i → β i → finset (γ i)) (a : sigma α) (b : sigma β) :\n  finset (sigma γ) :=\ndite (a.1 = b.1) (λ h, (f (h.rec a.2) b.2).map $ embedding.sigma_mk _) (λ _, ∅)\n\nlemma mem_sigma_lift (f : Π ⦃i⦄, α i → β i → finset (γ i))\n  (a : sigma α) (b : sigma β) (x : sigma γ) :\n  x ∈ sigma_lift f a b ↔ ∃ (ha : a.1 = x.1) (hb : b.1 = x.1), x.2 ∈ f (ha.rec a.2) (hb.rec b.2) :=\nbegin\n  obtain ⟨⟨i, a⟩, j, b⟩ := ⟨a, b⟩,\n  obtain rfl | h := decidable.eq_or_ne i j,\n  { split,\n    { simp_rw [sigma_lift, dif_pos rfl, mem_map, embedding.sigma_mk_apply],\n      rintro ⟨x, hx, rfl⟩,\n      exact ⟨rfl, rfl, hx⟩ },\n    { rintro ⟨⟨⟩, ⟨⟩, hx⟩,\n      rw [sigma_lift, dif_pos rfl, mem_map],\n      exact ⟨_, hx, by simp [sigma.ext_iff]⟩ } },\n  { rw [sigma_lift, dif_neg h],\n    refine iff_of_false (not_mem_empty _) _,\n    rintro ⟨⟨⟩, ⟨⟩, _⟩,\n    exact h rfl }\nend\n\nlemma mk_mem_sigma_lift (f : Π ⦃i⦄, α i → β i → finset (γ i)) (i : ι) (a : α i) (b : β i)\n  (x : γ i) :\n  (⟨i, x⟩ : sigma γ) ∈ sigma_lift f ⟨i, a⟩ ⟨i, b⟩ ↔ x ∈ f a b :=\nbegin\n  rw [sigma_lift, dif_pos rfl, mem_map],\n  refine ⟨_, λ hx, ⟨_, hx, rfl⟩⟩,\n  rintro ⟨x, hx, _, rfl⟩,\n  exact hx,\nend\n\nlemma not_mem_sigma_lift_of_ne_left (f : Π ⦃i⦄, α i → β i → finset (γ i))\n  (a : sigma α) (b : sigma β) (x : sigma γ) (h : a.1 ≠ x.1) :\n  x ∉ sigma_lift f a b :=\nby { rw mem_sigma_lift, exact λ H, h H.fst }\n\nlemma not_mem_sigma_lift_of_ne_right (f : Π ⦃i⦄, α i → β i → finset (γ i))\n  {a : sigma α} (b : sigma β) {x : sigma γ} (h : b.1 ≠ x.1) :\n  x ∉ sigma_lift f a b :=\nby { rw mem_sigma_lift, exact λ H, h H.snd.fst }\n\nvariables {f g : Π ⦃i⦄, α i → β i → finset (γ i)} {a : Σ i, α i} {b : Σ i, β i}\n\nlemma sigma_lift_nonempty :\n  (sigma_lift f a b).nonempty ↔ ∃ h : a.1 = b.1, (f (h.rec a.2) b.2).nonempty :=\nbegin\n  simp_rw nonempty_iff_ne_empty,\n  convert dite_ne_right_iff,\n  ext h,\n  simp_rw ←nonempty_iff_ne_empty,\n  exact map_nonempty.symm,\nend\n\nlemma sigma_lift_eq_empty : (sigma_lift f a b) = ∅ ↔ ∀ h : a.1 = b.1, (f (h.rec a.2) b.2) = ∅ :=\nbegin\n  convert dite_eq_right_iff,\n  exact forall_congr_eq (λ h, propext map_eq_empty.symm),\nend\n\nlemma sigma_lift_mono (h : ∀ ⦃i⦄ ⦃a : α i⦄ ⦃b : β i⦄, f a b ⊆ g a b) (a : Σ i, α i) (b : Σ i, β i) :\n  sigma_lift f a b ⊆ sigma_lift g a b :=\nbegin\n  rintro x hx,\n  rw mem_sigma_lift at ⊢ hx,\n  obtain ⟨ha, hb, hx⟩ := hx,\n  exact ⟨ha, hb, h hx⟩,\nend\n\nvariables (f a b)\n\nlemma card_sigma_lift :\n  (sigma_lift f a b).card = dite (a.1 = b.1) (λ h, (f (h.rec a.2) b.2).card) (λ _, 0) :=\nby { convert apply_dite _ _ _ _, ext h, exact (card_map _).symm }\n\nend sigma_lift\n\nend finset\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/data/finset/sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.4608940822751578}}
{"text": "/-\nCopyright (c) 2021 Julian Kuelshammer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Julian Kuelshammer\n\n! This file was ported from Lean 3 source module algebra.category.Semigroup.basic\n! leanprover-community/mathlib commit 47b51515e69f59bca5cf34ef456e6000fe205a69\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.PemptyInstances\nimport Mathbin.Algebra.Hom.Equiv.Basic\nimport Mathbin.CategoryTheory.ConcreteCategory.BundledHom\nimport Mathbin.CategoryTheory.Functor.ReflectsIsomorphisms\nimport Mathbin.CategoryTheory.Elementwise\n\n/-!\n# Category instances for has_mul, has_add, semigroup and add_semigroup\n\nWe introduce the bundled categories:\n* `Magma`\n* `AddMagma`\n* `Semigroup`\n* `AddSemigroup`\nalong with the relevant forgetful functors between them.\n\nThis closely follows `algebra.category.Mon.basic`.\n\n## TODO\n\n* Limits in these categories\n* free/forgetful adjunctions\n-/\n\n\nuniverse u v\n\nopen CategoryTheory\n\n/-- The category of magmas and magma morphisms. -/\n@[to_additive AddMagma]\ndef Magma : Type (u + 1) :=\n  Bundled Mul\n#align Magma Magma\n#align AddMagma AddMagma\n\n/-- The category of additive magmas and additive magma morphisms. -/\nadd_decl_doc AddMagma\n\nnamespace Magma\n\n@[to_additive]\ninstance bundledHom : BundledHom @MulHom :=\n  ⟨@MulHom.toFun, @MulHom.id, @MulHom.comp, @MulHom.coe_inj⟩\n#align Magma.bundled_hom Magma.bundledHom\n#align AddMagma.bundled_hom AddMagma.bundledHom\n\nderiving instance LargeCategory, ConcreteCategory for Magma\n\nattribute [to_additive] Magma.largeCategory Magma.concreteCategory\n\n@[to_additive]\ninstance : CoeSort Magma (Type _) :=\n  Bundled.hasCoeToSort\n\n/-- Construct a bundled `Magma` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [Mul M] : Magma :=\n  Bundled.of M\n#align Magma.of Magma.of\n#align AddMagma.of AddMagma.of\n\n/-- Construct a bundled `AddMagma` from the underlying type and typeclass. -/\nadd_decl_doc AddMagma.of\n\n/-- Typecheck a `mul_hom` as a morphism in `Magma`. -/\n@[to_additive]\ndef ofHom {X Y : Type u} [Mul X] [Mul Y] (f : X →ₙ* Y) : of X ⟶ of Y :=\n  f\n#align Magma.of_hom Magma.ofHom\n#align AddMagma.of_hom AddMagma.ofHom\n\n/-- Typecheck a `add_hom` as a morphism in `AddMagma`. -/\nadd_decl_doc AddMagma.ofHom\n\n@[simp, to_additive]\ntheorem ofHom_apply {X Y : Type u} [Mul X] [Mul Y] (f : X →ₙ* Y) (x : X) : ofHom f x = f x :=\n  rfl\n#align Magma.of_hom_apply Magma.ofHom_apply\n#align AddMagma.of_hom_apply AddMagma.ofHom_apply\n\n@[to_additive]\ninstance : Inhabited Magma :=\n  ⟨Magma.of PEmpty⟩\n\n@[to_additive]\ninstance (M : Magma) : Mul M :=\n  M.str\n\n@[simp, to_additive]\ntheorem coe_of (R : Type u) [Mul R] : (Magma.of R : Type u) = R :=\n  rfl\n#align Magma.coe_of Magma.coe_of\n#align AddMagma.coe_of AddMagma.coe_of\n\nend Magma\n\n/-- The category of semigroups and semigroup morphisms. -/\n@[to_additive AddSemigroupCat]\ndef SemigroupCat : Type (u + 1) :=\n  Bundled Semigroup\n#align Semigroup SemigroupCat\n#align AddSemigroup AddSemigroupCat\n\n/-- The category of additive semigroups and semigroup morphisms. -/\nadd_decl_doc AddSemigroupCat\n\nnamespace SemigroupCat\n\n@[to_additive]\ninstance : BundledHom.ParentProjection Semigroup.toHasMul :=\n  ⟨⟩\n\nderiving instance LargeCategory, ConcreteCategory for SemigroupCat\n\nattribute [to_additive] SemigroupCat.largeCategory SemigroupCat.concreteCategory\n\n@[to_additive]\ninstance : CoeSort SemigroupCat (Type _) :=\n  Bundled.hasCoeToSort\n\n/-- Construct a bundled `Semigroup` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [Semigroup M] : SemigroupCat :=\n  Bundled.of M\n#align Semigroup.of SemigroupCat.of\n#align AddSemigroup.of AddSemigroupCat.of\n\n/-- Construct a bundled `AddSemigroup` from the underlying type and typeclass. -/\nadd_decl_doc AddSemigroupCat.of\n\n/-- Typecheck a `mul_hom` as a morphism in `Semigroup`. -/\n@[to_additive]\ndef ofHom {X Y : Type u} [Semigroup X] [Semigroup Y] (f : X →ₙ* Y) : of X ⟶ of Y :=\n  f\n#align Semigroup.of_hom SemigroupCat.ofHom\n#align AddSemigroup.of_hom AddSemigroupCat.ofHom\n\n/-- Typecheck a `add_hom` as a morphism in `AddSemigroup`. -/\nadd_decl_doc AddSemigroupCat.ofHom\n\n@[simp, to_additive]\ntheorem ofHom_apply {X Y : Type u} [Semigroup X] [Semigroup Y] (f : X →ₙ* Y) (x : X) :\n    ofHom f x = f x :=\n  rfl\n#align Semigroup.of_hom_apply SemigroupCat.ofHom_apply\n#align AddSemigroup.of_hom_apply AddSemigroupCat.ofHom_apply\n\n@[to_additive]\ninstance : Inhabited SemigroupCat :=\n  ⟨SemigroupCat.of PEmpty⟩\n\n@[to_additive]\ninstance (M : SemigroupCat) : Semigroup M :=\n  M.str\n\n@[simp, to_additive]\ntheorem coe_of (R : Type u) [Semigroup R] : (SemigroupCat.of R : Type u) = R :=\n  rfl\n#align Semigroup.coe_of SemigroupCat.coe_of\n#align AddSemigroup.coe_of AddSemigroupCat.coe_of\n\n@[to_additive has_forget_to_AddMagma]\ninstance hasForgetToMagma : HasForget₂ SemigroupCat Magma :=\n  BundledHom.forget₂ _ _\n#align Semigroup.has_forget_to_Magma SemigroupCat.hasForgetToMagma\n#align AddSemigroup.has_forget_to_AddMagma AddSemigroupCat.hasForgetToAddMagma\n\nend SemigroupCat\n\nvariable {X Y : Type u}\n\nsection\n\nvariable [Mul X] [Mul Y]\n\n/-- Build an isomorphism in the category `Magma` from a `mul_equiv` between `has_mul`s. -/\n@[to_additive AddEquiv.toAddMagmaIso\n      \"Build an isomorphism in the category `AddMagma` from\\nan `add_equiv` between `has_add`s.\",\n  simps]\ndef MulEquiv.toMagmaIso (e : X ≃* Y) : Magma.of X ≅ Magma.of Y\n    where\n  Hom := e.toMulHom\n  inv := e.symm.toMulHom\n#align mul_equiv.to_Magma_iso MulEquiv.toMagmaIso\n#align add_equiv.to_AddMagma_iso AddEquiv.toAddMagmaIso\n\nend\n\nsection\n\nvariable [Semigroup X] [Semigroup Y]\n\n/-- Build an isomorphism in the category `Semigroup` from a `mul_equiv` between `semigroup`s. -/\n@[to_additive AddEquiv.toAddSemigroupIso\n      \"Build an isomorphism in the category\\n`AddSemigroup` from an `add_equiv` between `add_semigroup`s.\",\n  simps]\ndef MulEquiv.toSemigroupIso (e : X ≃* Y) : SemigroupCat.of X ≅ SemigroupCat.of Y\n    where\n  Hom := e.toMulHom\n  inv := e.symm.toMulHom\n#align mul_equiv.to_Semigroup_iso MulEquiv.toSemigroupIso\n#align add_equiv.to_AddSemigroup_iso AddEquiv.toAddSemigroupIso\n\nend\n\nnamespace CategoryTheory.Iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Magma`. -/\n@[to_additive AddMagma_iso_to_add_equiv\n      \"Build an `add_equiv` from an isomorphism in the category\\n`AddMagma`.\"]\ndef magmaIsoToMulEquiv {X Y : Magma} (i : X ≅ Y) : X ≃* Y\n    where\n  toFun := i.Hom\n  invFun := i.inv\n  left_inv x := by simp\n  right_inv y := by simp\n  map_mul' := by simp\n#align category_theory.iso.Magma_iso_to_mul_equiv CategoryTheory.Iso.magmaIsoToMulEquiv\n#align category_theory.iso.AddMagma_iso_to_add_equiv CategoryTheory.Iso.addMagmaIsoToAddEquiv\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Semigroup`. -/\n@[to_additive \"Build an `add_equiv` from an isomorphism in the category\\n`AddSemigroup`.\"]\ndef semigroupIsoToMulEquiv {X Y : SemigroupCat} (i : X ≅ Y) : X ≃* Y\n    where\n  toFun := i.Hom\n  invFun := i.inv\n  left_inv x := by simp\n  right_inv y := by simp\n  map_mul' := by simp\n#align category_theory.iso.Semigroup_iso_to_mul_equiv CategoryTheory.Iso.semigroupIsoToMulEquiv\n#align category_theory.iso.Semigroup_iso_to_add_equiv CategoryTheory.Iso.semigroupIsoToAddEquiv\n\nend CategoryTheory.Iso\n\n/-- multiplicative equivalences between `has_mul`s are the same as (isomorphic to) isomorphisms\nin `Magma` -/\n@[to_additive addEquivIsoAddMagmaIso\n      \"additive equivalences between `has_add`s are the same\\nas (isomorphic to) isomorphisms in `AddMagma`\"]\ndef mulEquivIsoMagmaIso {X Y : Type u} [Mul X] [Mul Y] : X ≃* Y ≅ Magma.of X ≅ Magma.of Y\n    where\n  Hom e := e.toMagmaIso\n  inv i := i.magmaIsoToMulEquiv\n#align mul_equiv_iso_Magma_iso mulEquivIsoMagmaIso\n#align add_equiv_iso_AddMagma_iso addEquivIsoAddMagmaIso\n\n/-- multiplicative equivalences between `semigroup`s are the same as (isomorphic to) isomorphisms\nin `Semigroup` -/\n@[to_additive addEquivIsoAddSemigroupIso\n      \"additive equivalences between `add_semigroup`s are\\nthe same as (isomorphic to) isomorphisms in `AddSemigroup`\"]\ndef mulEquivIsoSemigroupIso {X Y : Type u} [Semigroup X] [Semigroup Y] :\n    X ≃* Y ≅ SemigroupCat.of X ≅ SemigroupCat.of Y\n    where\n  Hom e := e.toSemigroupIso\n  inv i := i.semigroupIsoToMulEquiv\n#align mul_equiv_iso_Semigroup_iso mulEquivIsoSemigroupIso\n#align add_equiv_iso_AddSemigroup_iso addEquivIsoAddSemigroupIso\n\n@[to_additive]\ninstance Magma.forget_reflects_isos : ReflectsIsomorphisms (forget Magma.{u})\n    where reflects X Y f _ := by\n    skip\n    let i := as_iso ((forget Magma).map f)\n    let e : X ≃* Y := { f, i.to_equiv with }\n    exact ⟨(is_iso.of_iso e.to_Magma_iso).1⟩\n#align Magma.forget_reflects_isos Magma.forget_reflects_isos\n#align AddMagma.forget_reflects_isos AddMagma.forget_reflects_isos\n\n@[to_additive]\ninstance SemigroupCat.forget_reflects_isos : ReflectsIsomorphisms (forget SemigroupCat.{u})\n    where reflects X Y f _ := by\n    skip\n    let i := as_iso ((forget SemigroupCat).map f)\n    let e : X ≃* Y := { f, i.to_equiv with }\n    exact ⟨(is_iso.of_iso e.to_Semigroup_iso).1⟩\n#align Semigroup.forget_reflects_isos SemigroupCat.forget_reflects_isos\n#align AddSemigroup.forget_reflects_isos AddSemigroupCat.forget_reflects_isos\n\n/-!\nOnce we've shown that the forgetful functors to type reflect isomorphisms,\nwe automatically obtain that the `forget₂` functors between our concrete categories\nreflect isomorphisms.\n-/\n\n\nexample : ReflectsIsomorphisms (forget₂ SemigroupCat Magma) := by infer_instance\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Category/Semigroup/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410572017153, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.46089129820078}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison, Johannes Hölzl\n-/\nimport category_theory.fully_faithful\nimport data.equiv.basic\n\n/-!\n# The category `Type`.\n\nIn this section we set up the theory so that Lean's types and functions between them\ncan be viewed as a `large_category` in our framework.\n\nLean can not transparently view a function as a morphism in this category, and needs a hint in\norder to be able to type check. We provide the abbreviation `as_hom f` to guide type checking,\nas well as a corresponding notation `↾ f`. (Entered as `\\upr `.) The notation is enabled using\n`open_locale category_theory.Type`.\n\nWe provide various simplification lemmas for functors and natural transformations valued in `Type`.\n\nWe define `ulift_functor`, from `Type u` to `Type (max u v)`, and show that it is fully faithful\n(but not, of course, essentially surjective).\n\nWe prove some basic facts about the category `Type`:\n*  epimorphisms are surjections and monomorphisms are injections,\n* `iso` is both `iso` and `equiv` to `equiv` (at least within a fixed universe),\n* every type level `is_lawful_functor` gives a categorical functor `Type ⥤ Type`\n  (the corresponding fact about monads is in `src/category_theory/monad/types.lean`).\n-/\n\nnamespace category_theory\n\n-- morphism levels before object levels. See note [category_theory universes].\nuniverses v v' w u u'\n\ninstance types : large_category (Type u) :=\n{ hom     := λ a b, (a → b),\n  id      := λ a, id,\n  comp    := λ _ _ _ f g, g ∘ f }\n\nlemma types_hom {α β : Type u} : (α ⟶ β) = (α → β) := rfl\nlemma types_id (X : Type u) : 𝟙 X = id := rfl\nlemma types_comp {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) : f ≫ g = g ∘ f := rfl\n\n@[simp]\nlemma types_id_apply (X : Type u) (x : X) : ((𝟙 X) : X → X) x = x := rfl\n@[simp]\nlemma types_comp_apply {X Y Z : Type u} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : (f ≫ g) x = g (f x) := rfl\n\n@[simp]\nlemma hom_inv_id_apply {X Y : Type u} (f : X ≅ Y) (x : X) : f.inv (f.hom x) = x :=\ncongr_fun f.hom_inv_id x\n@[simp]\nlemma inv_hom_id_apply {X Y : Type u} (f : X ≅ Y) (y : Y) : f.hom (f.inv y) = y :=\ncongr_fun f.inv_hom_id y\n\n/-- `as_hom f` helps Lean type check a function as a morphism in the category `Type`. -/\n-- Unfortunately without this wrapper we can't use `category_theory` idioms, such as `is_iso f`.\nabbreviation as_hom {α β : Type u} (f : α → β) : α ⟶ β := f\n-- If you don't mind some notation you can use fewer keystrokes:\nlocalized \"notation  `↾` f : 200 := as_hom f\" in category_theory.Type -- type as \\upr in VScode\n\nsection -- We verify the expected type checking behaviour of `as_hom`.\nvariables (α β γ : Type u) (f : α → β) (g : β → γ)\n\nexample : α → γ := ↾f ≫ ↾g\nexample [is_iso ↾f] : mono ↾f := by apply_instance\nexample [is_iso ↾f] : ↾f ≫ inv ↾f = 𝟙 α := by simp\nend\n\nnamespace functor\nvariables {J : Type u} [category.{v} J]\n\n/--\nThe sections of a functor `J ⥤ Type` are\nthe choices of a point `u j : F.obj j` for each `j`,\nsuch that `F.map f (u j) = u j` for every morphism `f : j ⟶ j'`.\n\nWe later use these to define limits in `Type` and in many concrete categories.\n-/\ndef sections (F : J ⥤ Type w) : set (Π j, F.obj j) :=\n{ u | ∀ {j j'} (f : j ⟶ j'), F.map f (u j) = u j'}\nend functor\n\nnamespace functor_to_types\nvariables {C : Type u} [category.{v} C] (F G H : C ⥤ Type w) {X Y Z : C}\nvariables (σ : F ⟶ G) (τ : G ⟶ H)\n\n@[simp] lemma map_comp_apply (f : X ⟶ Y) (g : Y ⟶ Z) (a : F.obj X) :\n  (F.map (f ≫ g)) a = (F.map g) ((F.map f) a) :=\nby simp [types_comp]\n\n@[simp] lemma map_id_apply (a : F.obj X) : (F.map (𝟙 X)) a = a :=\nby simp [types_id]\n\nlemma naturality (f : X ⟶ Y) (x : F.obj X) : σ.app Y ((F.map f) x) = (G.map f) (σ.app X x) :=\ncongr_fun (σ.naturality f) x\n\n@[simp] lemma comp (x : F.obj X) : (σ ≫ τ).app X x = τ.app X (σ.app X x) := rfl\n\nvariables {D : Type u'} [𝒟 : category.{u'} D] (I J : D ⥤ C) (ρ : I ⟶ J) {W : D}\n\n@[simp] lemma hcomp (x : (I ⋙ F).obj W) :\n  (ρ ◫ σ).app W x = (G.map (ρ.app W)) (σ.app (I.obj W) x) :=\nrfl\n\n@[simp] \n\n@[simp] lemma hom_inv_id_app_apply (α : F ≅ G) (X) (x) : α.inv.app X (α.hom.app X x) = x :=\ncongr_fun (α.hom_inv_id_app X) x\n@[simp] lemma inv_hom_id_app_apply (α : F ≅ G) (X) (x) : α.hom.app X (α.inv.app X x) = x :=\ncongr_fun (α.inv_hom_id_app X) x\n\nend functor_to_types\n\n/--\nThe isomorphism between a `Type` which has been `ulift`ed to the same universe,\nand the original type.\n-/\ndef ulift_trivial (V : Type u) : ulift.{u} V ≅ V := by tidy\n\n/--\nThe functor embedding `Type u` into `Type (max u v)`.\nWrite this as `ulift_functor.{5 2}` to get `Type 2 ⥤ Type 5`.\n-/\ndef ulift_functor : Type u ⥤ Type (max u v) :=\n{ obj := λ X, ulift.{v} X,\n  map := λ X Y f, λ x : ulift.{v} X, ulift.up (f x.down) }\n\n@[simp] lemma ulift_functor_map {X Y : Type u} (f : X ⟶ Y) (x : ulift.{v} X) :\n  ulift_functor.map f x = ulift.up (f x.down) := rfl\n\ninstance ulift_functor_full : full.{u} ulift_functor :=\n{ preimage := λ X Y f x, (f (ulift.up x)).down }\ninstance ulift_functor_faithful : faithful ulift_functor :=\n{ map_injective' := λ X Y f g p, funext $ λ x,\n    congr_arg ulift.down ((congr_fun p (ulift.up x)) : ((ulift.up (f x)) = (ulift.up (g x)))) }\n\n/-- Any term `x` of a type `X` corresponds to a morphism `punit ⟶ X`. -/\n-- TODO We should connect this to a general story about concrete categories\n-- whose forgetful functor is representable.\ndef hom_of_element {X : Type u} (x : X) : punit ⟶ X := λ _, x\n\nlemma hom_of_element_eq_iff {X : Type u} (x y : X) :\n  hom_of_element x = hom_of_element y ↔ x = y :=\n⟨λ H, congr_fun H punit.star, by cc⟩\n\n/--\nA morphism in `Type` is a monomorphism if and only if it is injective.\n\nSee https://stacks.math.columbia.edu/tag/003C.\n-/\nlemma mono_iff_injective {X Y : Type u} (f : X ⟶ Y) : mono f ↔ function.injective f :=\nbegin\n  split,\n  { intros H x x' h,\n    resetI,\n    rw ←hom_of_element_eq_iff at ⊢ h,\n    exact (cancel_mono f).mp h },\n  { refine λ H, ⟨λ Z g h H₂, _⟩,\n    ext z,\n    replace H₂ := congr_fun H₂ z,\n    exact H H₂ }\nend\n\n/--\nA morphism in `Type` is an epimorphism if and only if it is surjective.\n\nSee https://stacks.math.columbia.edu/tag/003C.\n-/\nlemma epi_iff_surjective {X Y : Type u} (f : X ⟶ Y) : epi f ↔ function.surjective f :=\nbegin\n  split,\n  { intros H,\n    let g : Y ⟶ ulift Prop := λ y, ⟨true⟩,\n    let h : Y ⟶ ulift Prop := λ y, ⟨∃ x, f x = y⟩,\n    suffices : f ≫ g = f ≫ h,\n    { resetI,\n      rw cancel_epi at this,\n      intro y,\n      replace this := congr_fun this y,\n      replace this : true = ∃ x, f x = y := congr_arg ulift.down this,\n      rw ←this,\n      trivial },\n    ext x,\n    change true ↔ ∃ x', f x' = f x,\n    rw true_iff,\n    exact ⟨x, rfl⟩ },\n  { intro H,\n    constructor,\n    intros Z g h H₂,\n    apply funext,\n    rw ←forall_iff_forall_surj H,\n    intro x,\n    exact (congr_fun H₂ x : _) }\nend\n\nsection\n\n/-- `of_type_functor m` converts from Lean's `Type`-based `category` to `category_theory`. This\nallows us to use these functors in category theory. -/\ndef of_type_functor (m : Type u → Type v) [_root_.functor m] [is_lawful_functor m] :\n  Type u ⥤ Type v :=\n{ obj       := m,\n  map       := λα β, _root_.functor.map,\n  map_id'   := assume α, _root_.functor.map_id,\n  map_comp' := assume α β γ f g, funext $ assume a, is_lawful_functor.comp_map f g _ }\n\nvariables (m : Type u → Type v) [_root_.functor m] [is_lawful_functor m]\n\n@[simp]\nlemma of_type_functor_obj : (of_type_functor m).obj = m := rfl\n\n@[simp]\nlemma of_type_functor_map {α β} (f : α → β) :\n  (of_type_functor m).map f = (_root_.functor.map f : m α → m β) := rfl\n\nend\n\nend category_theory\n\n-- Isomorphisms in Type and equivalences.\n\nnamespace equiv\n\nuniverse u\n\nvariables {X Y : Type u}\n\n/--\nAny equivalence between types in the same universe gives\na categorical isomorphism between those types.\n-/\ndef to_iso (e : X ≃ Y) : X ≅ Y :=\n{ hom := e.to_fun,\n  inv := e.inv_fun,\n  hom_inv_id' := funext e.left_inv,\n  inv_hom_id' := funext e.right_inv }\n\n@[simp] lemma to_iso_hom {e : X ≃ Y} : e.to_iso.hom = e := rfl\n@[simp] lemma to_iso_inv {e : X ≃ Y} : e.to_iso.inv = e.symm := rfl\n\nend equiv\n\nuniverse u\n\nnamespace category_theory.iso\nopen category_theory\n\nvariables {X Y : Type u}\n\n/--\nAny isomorphism between types gives an equivalence.\n-/\ndef to_equiv (i : X ≅ Y) : X ≃ Y :=\n{ to_fun := i.hom,\n  inv_fun := i.inv,\n  left_inv := λ x, congr_fun i.hom_inv_id x,\n  right_inv := λ y, congr_fun i.inv_hom_id y }\n\n@[simp] lemma to_equiv_fun (i : X ≅ Y) : (i.to_equiv : X → Y) = i.hom := rfl\n@[simp] lemma to_equiv_symm_fun (i : X ≅ Y) : (i.to_equiv.symm : Y → X) = i.inv := rfl\n\n@[simp] lemma to_equiv_id (X : Type u) : (iso.refl X).to_equiv = equiv.refl X := rfl\n@[simp] lemma to_equiv_comp {X Y Z : Type u} (f : X ≅ Y) (g : Y ≅ Z) :\n  (f ≪≫ g).to_equiv = f.to_equiv.trans (g.to_equiv) := rfl\n\nend category_theory.iso\n\nnamespace category_theory\n\n/-- A morphism in `Type u` is an isomorphism if and only if it is bijective. -/\nlemma is_iso_iff_bijective {X Y : Type u} (f : X ⟶ Y) : is_iso f ↔ function.bijective f :=\niff.intro\n  (λ i, (by exactI as_iso f : X ≅ Y).to_equiv.bijective)\n  (λ b, is_iso.of_iso (equiv.of_bijective f b).to_iso)\n\nend category_theory\n\n-- We prove `equiv_iso_iso` and then use that to sneakily construct `equiv_equiv_iso`.\n-- (In this order the proofs are handled by `obviously`.)\n\n/-- Equivalences (between types in the same universe) are the same as (isomorphic to) isomorphisms\nof types. -/\n@[simps] def equiv_iso_iso {X Y : Type u} : (X ≃ Y) ≅ (X ≅ Y) :=\n{ hom := λ e, e.to_iso,\n  inv := λ i, i.to_equiv, }\n\n/-- Equivalences (between types in the same universe) are the same as (equivalent to) isomorphisms\nof types. -/\ndef equiv_equiv_iso {X Y : Type u} : (X ≃ Y) ≃ (X ≅ Y) :=\n(equiv_iso_iso).to_equiv\n\n@[simp] lemma equiv_equiv_iso_hom {X Y : Type u} (e : X ≃ Y) :\n  equiv_equiv_iso e = e.to_iso := rfl\n\n@[simp] lemma equiv_equiv_iso_inv {X Y : Type u} (e : X ≅ Y) :\n  equiv_equiv_iso.symm e = e.to_equiv := rfl\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/types.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105587468141, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.46089128900918613}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Rémy Degenne\n-/\nimport measure_theory.function.lp_space\nimport analysis.normed_space.lattice_ordered_group\n\n/-!\n# Order related properties of Lp spaces\n\n### Results\n\n- `Lp E p μ` is an `ordered_add_comm_group` when `E` is a `normed_lattice_add_comm_group`.\n\n### TODO\n\n- move definitions of `Lp.pos_part` and `Lp.neg_part` to this file, and define them as\n  `has_pos_part.pos` and `has_pos_part.neg` given by the lattice structure.\n- show that if `E` is a `normed_lattice_add_comm_group` then so is `Lp E p μ` for `1 ≤ p`. In\n  particular, this shows `order_closed_topology` for `Lp`.\n\n-/\n\nopen topological_space measure_theory lattice_ordered_comm_group\nopen_locale ennreal\n\nvariables {α E : Type*} {m : measurable_space α} {μ : measure α} {p : ℝ≥0∞}\n\nnamespace measure_theory\nnamespace Lp\n\nsection order\nvariables [normed_lattice_add_comm_group E]\n\nlemma coe_fn_le (f g : Lp E p μ) : f ≤ᵐ[μ] g ↔ f ≤ g :=\nby rw [← subtype.coe_le_coe, ← ae_eq_fun.coe_fn_le, ← coe_fn_coe_base, ← coe_fn_coe_base]\n\nlemma coe_fn_nonneg (f : Lp E p μ) : 0 ≤ᵐ[μ] f ↔ 0 ≤ f :=\nbegin\n  rw ← coe_fn_le,\n  have h0 := Lp.coe_fn_zero E p μ,\n  split; intro h; filter_upwards [h, h0] with _ _ h2,\n  { rwa h2, },\n  { rwa ← h2, },\nend\n\ninstance : covariant_class (Lp E p μ) (Lp E p μ) (+) (≤) :=\nbegin\n  refine ⟨λ f g₁ g₂ hg₁₂, _⟩,\n  rw ← coe_fn_le at hg₁₂ ⊢,\n  filter_upwards [coe_fn_add f g₁, coe_fn_add f g₂, hg₁₂] with _ h1 h2 h3,\n  rw [h1, h2, pi.add_apply, pi.add_apply],\n  exact add_le_add le_rfl h3,\nend\n\ninstance : ordered_add_comm_group (Lp E p μ) :=\n{ add_le_add_left := λ f g hfg f', add_le_add_left hfg f',\n  ..subtype.partial_order _, ..add_subgroup.to_add_comm_group _}\n\nend order\n\nend Lp\nend measure_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/measure_theory/function/lp_order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.4608912840393481}}
{"text": "/-\nCopyright (c) 2021 Ashvni Narayanan. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ashvni Narayanan\n-/\nimport tendsto_zero_of_sum_even_char\nimport p_adic_L_function_def\nimport general_bernoulli_number.basic\nimport zmod.chinese_remainder_units\n--import bernoulli_measure.ind_fn\nimport topology.algebra.continuous_monoid_hom\n--import topology.algebra.nonarchimedean.bases\n--import chinese_remainder_units\n\n/-!\n# A convergence property regarding (ℤ/dp^n ℤ)\nThis file proves Proposition 7.11 in Introduction to Cyclotomic Fields, Washington. \nIt gives a convergence property relating to generalized Bernoulli numbers.\n\n# Main Theorems\n * `lim_even_character`\n\n## Tags\np-adic, L-function, Bernoulli measure, Dirichlet character\n-/\n\nopen_locale big_operators\nlocal attribute [instance] zmod.topological_space\n\nopen filter ind_fn dirichlet_character\nopen_locale topological_space\n\nopen_locale big_operators\n\nvariables {p : ℕ} [fact (nat.prime p)] {d : ℕ} [fact (0 < d)] {R : Type*} [normed_comm_ring R] (m : ℕ)\n(hd : d.gcd p = 1) (χ : dirichlet_character R (d*(p^m))) {c : ℕ} (hc : c.gcd p = 1)\n(hc' : c.gcd d = 1) (na : ∀ (n : ℕ) (f : ℕ → R),\n  ∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)\n(w : continuous_monoid_hom (units (zmod d) × units ℤ_[p]) R)\n\n-- note that this works for any dirichlet character which is primitive and whose conductor divides d * p^m\nlemma helper_13 [normed_algebra ℚ_[p] R] [algebra ℚ R] [is_scalar_tower ℚ ℚ_[p] R] [fact (0 < m)]\n  {k : ℕ} (hk : 1 < k) : (λ (n : ℕ), (1 / ((d * p ^ n : ℕ) : ℚ_[p])) •\n  ∑ (i : ℕ) in finset.range (d * p ^ n), (asso_dirichlet_character (χ.mul\n  (teichmuller_character_mod_p' p R^k))) ↑i * ↑i ^ k - general_bernoulli_number\n  (χ.mul (teichmuller_character_mod_p' p R ^ k)) k) =ᶠ[filter.at_top]\n  λ (x : ℕ), -((1 / (d * p ^ x : ℕ) : ℚ_[p]) • ∑ (x_1 : ℕ) in finset.range (d * p ^ x).pred,\n  (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ k))) ↑(x_1.succ) *\n  ((algebra_map ℚ R) (bernoulli 1 * ↑k) * ↑(d * p ^ x) * ↑(1 + x_1) ^ (k - 1)) +\n  (1 / (d * p ^ x : ℕ) : ℚ_[p]) • ∑ (x_1 : ℕ) in finset.range (d * p ^ x).pred,\n  (asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ k))) ↑(x_1.succ) *\n  (↑(d * p ^ x) * ∑ (x_2 : ℕ) in finset.range (k - 1),\n  (algebra_map ℚ R) (bernoulli ((k - 1).succ - x_2) * ↑((k - 1).succ.choose x_2) *\n  (↑(1 + x_1) ^ x_2 / ↑(d * p ^ x) ^ x_2) * ↑(d * p ^ x) ^ (k - 1))) +\n  (1 / (d * p ^ x : ℕ) : ℚ_[p]) •\n  ((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character)\n  ↑(d * p ^ x) * ((algebra_map ℚ R) (↑(d * p ^ x) ^ k) *\n  (algebra_map ℚ R) (polynomial.eval (↑(d * p ^ x) / ↑(d * p ^ x)) (polynomial.bernoulli k))))) :=\nbegin\n  rw [eventually_eq, eventually_at_top],\n  refine ⟨m, λ x hx, _⟩,\n  have h1 : lcm (d * p^m) p ∣ d * p^x,\n  { rw helper_4, refine (nat.mul_dvd_mul_iff_left (fact.out _)).2 (pow_dvd_pow _ hx), }, \n  have poss : 0 < d * p^x := fact.out _,\n  have ne_zero : ((d * p^x : ℕ) : ℚ) ≠ 0 := nat.cast_ne_zero.2 (nat.ne_zero_of_lt' 0),\n  have coe_sub : (k : ℤ) - 1 = ((k - 1 : ℕ) : ℤ),\n  { change int.of_nat k - 1 = int.of_nat (k - 1),\n    rw [int.of_nat_sub (le_of_lt hk), int.of_nat_one], },\n  have : ∀ x : ℕ, asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character x =\n    asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ k)) x :=\n  asso_dirichlet_character.asso_primitive_character _ (is_primitive.mul _ _),\n  have f1 : (χ.mul (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character.conductor =\n    (χ.mul (teichmuller_character_mod_p' p R ^ k)).conductor,\n  { rw asso_primitive_conductor_eq, },\n  rw general_bernoulli_number.eq_sum_bernoulli_of_conductor_dvd _ k (dvd_trans (conductor.dvd_lev _)\n    (dvd_trans (conductor.dvd_lev _) h1)),\n  conv_lhs { conv { congr, skip, rw [coe_sub, zpow_coe_nat, ← one_mul\n    ((algebra_map ℚ R) (((d * p ^ x : ℕ) : ℚ) ^ (k - 1))), ← (algebra_map ℚ R).map_one,\n    ←one_div_mul_cancel ne_zero, (algebra_map ℚ R).map_mul, mul_assoc _ _ ((algebra_map ℚ R)\n    (((d * p ^ x : ℕ) : ℚ) ^ (k - 1))), ←(algebra_map ℚ R).map_mul, ←pow_succ,\n    nat.sub_add_cancel (le_of_lt hk), mul_assoc, algebra.algebra_map_eq_smul_one, smul_mul_assoc,\n    one_mul, finset.mul_sum],\n    congr, skip, apply_congr, skip,\n    rw [mul_comm ((algebra_map ℚ R) (((d * p ^ x : ℕ) : ℚ) ^ k)) _, mul_assoc,\n      mul_comm _ ((algebra_map ℚ R) (((d * p ^ x : ℕ) : ℚ) ^ k))], },\n    rw finset.range_eq_Ico,\n    conv { rw [finset.sum_eq_sum_Ico_succ_bot poss, nat.cast_zero, nat.cast_zero,\n      zero_pow (pos_of_gt hk), mul_zero, zero_add, ←nat.sub_add_cancel (nat.succ_le_iff.2 poss),\n      ←finset.sum_Ico_add, finset.sum_Ico_succ_top (nat.zero_le _) _, ←finset.range_eq_Ico,\n      ←nat.pred_eq_sub_one, nat.succ_pred_eq_of_pos poss], }, },\n  conv { congr, conv { congr, skip, congr, skip, congr, conv { apply_congr, skip,\n    rw [nat.pred_add_one_eq_self poss, helper_12 p d R hk x _, add_assoc, mul_add, this _,\n      add_comm _ 1],\n    conv { congr, congr, rw [nat.succ_eq_add_one, add_comm x_1 1], }, }, }, },\n  rw [finset.sum_add_distrib, div_smul_eq_div_smul p R, ←smul_sub, ←sub_sub, ←sub_sub, sub_self,\n    zero_sub, ←neg_add', smul_neg, nat.pred_add_one_eq_self poss, ←smul_add, ←smul_add],\n  congr,\n  simp_rw mul_add, rw finset.sum_add_distrib,\n  congr,\nend\n\nvariables (p d R) [complete_space R] [char_zero R]\nopen continuous_map\nvariables [normed_algebra ℚ_[p] R] [fact (0 < m)]\nopen clopen_from\n\n-- `helper_289` replaced with `helper_18`\nlemma helper_18 {n : ℕ} (hn : 1 < n) (a : (zmod d)ˣ × (zmod (p^n))ˣ) :\n  loc_const_ind_fn (_root_.char_fn R (clopen_from.is_clopen_units a)) =\n  _root_.char_fn R (@clopen_from.is_clopen p _ d n (↑(((units.chinese_remainder (nat.coprime.pow_right n hd)).symm) a))) :=\nbegin\n  ext,\n  rw loc_const_ind_fn, rw ← locally_constant.to_fun_eq_coe,\n  simp only,\n  by_cases h' : is_unit x.fst ∧ is_unit x.snd, --rw ind_fn.ind_fn_def, --simp only, split_ifs,\n  { by_cases hx : x ∈ clopen_from ↑(((units.chinese_remainder\n      (nat.coprime.pow_right n hd)).symm) a),\n    { rw ind_fn.map_ind_fn_eq_fn,\n      rw (char_fn_one R x _).1 hx, rw ← char_fn_one R _ _,\n      rw set.mem_prod, rw set.mem_preimage, rw set.mem_singleton_iff, rw set.mem_singleton_iff,\n      rw units.ext_iff, rw units.ext_iff, rw is_unit.unit_spec, rw units.coe_map,\n      rw is_unit.unit_spec, rw clopen_from.mem_clopen_from at hx, rw hx.1, rw ring_hom.to_monoid_hom_eq_coe,\n      rw ring_hom.coe_monoid_hom, rw ← hx.2, rw units.chinese_remainder_symm_apply_fst,\n      rw units.chinese_remainder_symm_apply_snd, refine ⟨rfl, rfl⟩,\n      { -- make a separate lemma\n        rw mem_clopen_from at hx, rw units.chinese_remainder_symm_apply_snd at hx,\n        rw units.chinese_remainder_symm_apply_fst at hx,\n        rw hx.1, simp only [units.is_unit, true_and],\n        apply padic_int.is_unit_to_zmod_pow_of_is_unit p hn x.snd, rw ←hx.2,\n        simp only [units.is_unit], }, },\n    { rw map_ind_fn_eq_fn _ h',\n      rw (char_fn_zero R x _).1 hx,\n      rw (char_fn_zero R _ _).1 _,\n      -- simp,\n      -- rw is_unit.unit_spec,\n      intro h', apply hx,\n      rw mem_clopen_from, rw units.chinese_remainder_symm_apply_fst,\n      rw units.chinese_remainder_symm_apply_snd,\n      rw set.mem_prod at h', rw set.mem_preimage at h', rw set.mem_singleton_iff at h', rw set.mem_singleton_iff at h',\n      rw units.ext_iff at h', rw units.ext_iff at h', rw is_unit.unit_spec at h',\n      rw units.coe_map at h', rw is_unit.unit_spec at h',\n      refine ⟨h'.1, h'.2.symm⟩, }, },\n  { -- same as above\n    rw map_ind_fn_eq_zero _ h', rw (char_fn_zero R _ _).1 _,\n    intro hx, apply h',\n    rw mem_clopen_from at hx, rw units.chinese_remainder_symm_apply_fst at hx,\n    rw units.chinese_remainder_symm_apply_snd at hx,\n    rw hx.1, simp only [units.is_unit, true_and],\n    apply padic_int.is_unit_to_zmod_pow_of_is_unit p hn x.snd, rw ←hx.2,\n    simp only [units.is_unit], },\nend\n\nvariable [fact (0 < d)]\nopen eventually_constant_seq clopen_from\n\nopen dirichlet_character\nvariable (hd)\n\nlemma lim_even_character' [nontrivial R] [no_zero_divisors R] [normed_algebra ℚ_[p] R]\n  [fact (0 < m)] {k : ℕ} [algebra ℚ R] [is_scalar_tower ℚ ℚ_[p] R] [norm_one_class R] (hk : 1 < k)\n  (hχ : χ.is_even) (hp : 2 < p)\n  (na : ∀ (n : ℕ) (f : ℕ → R), ∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥) :\n  filter.tendsto (λ n, (1/((d * p^n : ℕ) : ℚ_[p])) • ∑ i in finset.range (d * p^n),\n  ((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R ^ k))) i * i^k) )\n  (@filter.at_top ℕ _) (nhds (general_bernoulli_number\n  (χ.mul (teichmuller_character_mod_p' p R ^ k)) k)) :=\nbegin\n  refine tendsto_sub_nhds_zero_iff.1 ((filter.tendsto_congr' (helper_13 m _ hk)).2 _),\n  conv { congr, skip, skip, rw ←neg_zero, rw ←add_zero (0 : R),\n    conv { congr, congr, congr, rw ←add_zero (0 : R), }, },\n  refine tendsto.neg (tendsto.add (tendsto.add _ _) _),\n  { conv { congr, funext, conv { congr, skip, apply_congr, skip,\n      rw [mul_comm ((algebra_map ℚ R) (bernoulli 1 * ↑k) * ↑(d * p ^ x)) _, ←mul_assoc], },\n      rw [←finset.sum_mul, mul_comm _ ((algebra_map ℚ R) (bernoulli 1 * ↑k) * ↑(d * p ^ x)),\n       ←smul_mul_assoc, mul_comm ((algebra_map ℚ R) (bernoulli 1 * ↑k)) ↑(d * p ^ x),\n       ←smul_mul_assoc, ←div_smul_eq_div_smul p R (d * p ^ x) _,\n       one_div_smul_self R (@nat.ne_zero_of_lt' 0 (d * p^x) _), one_mul, ←smul_eq_mul,\n       algebra_map_smul, helper_14 p R], skip, skip,\n       rw ←@smul_zero ℚ_[p] R _ _ _ ((algebra_map ℚ ℚ_[p]) (bernoulli 1 * ↑k)), },\n    refine tendsto.const_smul _ _,\n    convert (tendsto_congr' _).2 (sum_even_character_tendsto_zero hk hχ hp na),\n    rw [eventually_eq, eventually_at_top],\n    refine ⟨m, λ x hx, _⟩,\n    have poss : 0 < d * p^x := fact.out _,\n    simp_rw [add_comm 1 _, nat.succ_eq_add_one],\n    rw [finset.range_eq_Ico, finset.sum_Ico_add' (λ x : ℕ, (asso_dirichlet_character (χ.mul\n      (teichmuller_character_mod_p' p R ^ k))) ↑x * ↑x ^ (k - 1)) 0 (d * p^x).pred 1,\n      finset.sum_eq_sum_Ico_succ_bot poss, @nat.cast_zero R _ _, zero_pow (nat.sub_pos_of_lt hk),\n      mul_zero, zero_add, zero_add, nat.pred_add_one_eq_self poss], },\n  { rw metric.tendsto_at_top,\n    intros ε hε,\n    obtain ⟨N, h⟩ := metric.tendsto_at_top.1 (tendsto.const_mul ((⨆ (x_1 : zmod (k.sub 0).pred),\n      ∥(algebra_map ℚ R) (bernoulli ((k.sub 0).pred.succ - x_1.val) *\n      ↑((k.sub 0).pred.succ.choose x_1.val))∥) *\n      (χ.mul (teichmuller_character_mod_p' p R ^ k)).bound) (tendsto_iff_norm_tendsto_zero.1\n      (nat_cast_mul_prime_pow_tendsto_zero p d R))) (ε/2) (half_pos hε),\n    simp_rw [sub_zero, mul_zero _, dist_zero_right _, real.norm_eq_abs] at h,\n    refine ⟨N, λ  x hx, _⟩,\n    rw dist_eq_norm, rw sub_zero,\n    conv { congr, congr, conv { congr, skip,\n      conv { apply_congr, skip, rw [←mul_assoc, mul_comm ((asso_dirichlet_character (χ.mul\n        (teichmuller_character_mod_p' p R ^ k))) ↑(x_1.succ)) _, mul_assoc, add_comm 1 x_1], },\n      rw ←finset.mul_sum, },\n      rw [←smul_mul_assoc, ←div_smul_eq_div_smul p R (d * p ^ x) _, one_div_smul_self R\n        (@nat.ne_zero_of_lt' 0 (d * p^x) _), one_mul], },\n    refine lt_of_le_of_lt (na _ _) (lt_of_le_of_lt (cSup_le (set.range_nonempty _) (λ b hb, _))\n      (half_lt_self hε)),\n    cases hb with y hy,\n    rw ←hy,\n    simp only,\n    refine le_trans (norm_mul_le _ _) (le_trans (mul_le_mul\n      (le_of_lt (dirichlet_character.lt_bound _ _)) (helper_15 na hk _ _) (norm_nonneg _)\n      (le_of_lt (bound_pos _))) (le_of_lt _)),\n    rw [mul_comm, mul_assoc, mul_comm],\n    apply lt_of_abs_lt (h x hx),  },\n  { have nz : ∀ x : ℕ, ((d * p^x : ℕ) : ℚ) ≠ 0 := λ x, nat.cast_ne_zero.2 (nat.ne_zero_of_lt' 0),\n    simp_rw [div_self (nz _)],\n    conv { congr, funext, rw [mul_comm ((asso_dirichlet_character (χ.mul\n      (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character) ↑(d * p ^ x))\n      ((algebra_map ℚ R) (↑(d * p ^ x) ^ k) * (algebra_map ℚ R)\n      (polynomial.eval 1 (polynomial.bernoulli k))), mul_assoc, ← smul_mul_assoc,\n      ← nat.succ_pred_eq_of_pos (pos_of_gt hk), pow_succ, (algebra_map ℚ R).map_mul,\n      ← smul_mul_assoc, ← inv_eq_one_div, map_nat_cast,--], },\n      inv_smul_self' p R (@nat.ne_zero_of_lt' 0 (d * p^x) _), one_mul, ← mul_assoc, mul_comm _\n      ((algebra_map ℚ R) (polynomial.eval 1 (polynomial.bernoulli k.pred.succ))), mul_assoc], skip,\n      skip, congr, rw ←mul_zero ((algebra_map ℚ R) (polynomial.eval 1 (polynomial.bernoulli k.pred.succ))), },\n    apply tendsto.const_mul _ _,\n    { apply_instance, },\n    { rw metric.tendsto_at_top,\n      intros ε hε,\n      obtain ⟨N, hN⟩ := metric.tendsto_at_top.1 (norm_pow_lim_eq_zero p d R 1 (nat.pred_lt_pred\n        nat.one_ne_zero hk)) (ε/((χ.mul\n        (teichmuller_character_mod_p' p R ^ k.pred.succ)).asso_primitive_character.bound))\n        (div_pos hε (bound_pos _)),\n      refine ⟨N, λ x hx, _⟩,\n      rw dist_eq_norm, rw sub_zero, rw mul_comm,\n      apply lt_of_le_of_lt (norm_mul_le _ _) _,\n      rw ← nat.cast_pow, rw map_nat_cast,\n      apply lt_trans (mul_lt_mul (lt_bound _ _) le_rfl _ _) _,\n      { rw norm_pos_iff,\n        refine nat.cast_ne_zero.2 _,\n        refine pow_ne_zero _ (nat.ne_zero_of_lt' 0), },\n      { apply le_of_lt (bound_pos _), },\n      { rw mul_comm, rw nat.cast_pow,\n        simp_rw [dist_eq_norm, mul_one, sub_zero] at hN,\n        apply (lt_div_iff (bound_pos _)).1 (hN x hx), }, }, },\nend", "meta": {"author": "laughinggas", "repo": "p-adic-L-functions", "sha": "bfc0c84fabe9b89e3da79f95d7a8eacabe8a5bb7", "save_path": "github-repos/lean/laughinggas-p-adic-L-functions", "path": "github-repos/lean/laughinggas-p-adic-L-functions/p-adic-L-functions-bfc0c84fabe9b89e3da79f95d7a8eacabe8a5bb7/src/general_bernoulli_number/lim_even_character.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4607634644016136}}
{"text": "import polyhedral_lattice.basic\nimport normed_group.pseudo_normed_group\nimport pseudo_normed_group.with_Tinv\n\nimport topology.connected\n\nimport facts\n/-!\n\n# If M is a profinitely filtered pseudo-normed group with T⁻¹ then so is Hom(Λ, M)\n\nHere Λ is a polyhedral lattice, and the T⁻¹ is in the sense\nof `pseudo_normed_group.with_Tinv`.\n\n-/\n\nnoncomputable theory\nopen_locale nnreal big_operators\n\nopen pseudo_normed_group seminormed_add_comm_group\n\nlemma int.one_mem_filtration : (1 : ℤ) ∈ filtration ℤ 1 :=\nby simp only [nnnorm_one, mem_filtration_iff]\n\nsection\n\nvariables {Λ : Type*} [polyhedral_lattice Λ]\nvariables {M : Type*} [pseudo_normed_group M]\n\nlemma generates_norm.add_monoid_hom_mem_filtration_iff {ι : Type} [fintype ι]\n  {l : ι → Λ} (hl : generates_norm l) (x : Λ →+ M) (c : ℝ≥0) :\n  x ∈ filtration (Λ →+ M) c ↔ ∀ i, x (l i) ∈ filtration M (c * ∥l i∥₊) :=\nbegin\n  refine ⟨λ H i, H (le_refl ∥l i∥₊), _⟩,\n  intros H c' l' hl',\n  obtain ⟨cᵢ, h1, h2⟩ := hl.generates_nnnorm l',\n  rw [h1, x.map_sum],\n  refine filtration_mono _ (sum_mem_filtration _ (λ i, c * cᵢ i * ∥l i∥₊) _ _),\n  { calc ∑ i, c * cᵢ i * ∥l i∥₊\n        = c * ∑ i, cᵢ i * ∥l i∥₊ : by simp only [mul_assoc, ← finset.mul_sum]\n    ... = c * ∥l'∥₊ : by rw h2\n    ... ≤ c * c' : mul_le_mul' le_rfl hl' },\n  rintro i -,\n  rw [mul_assoc, mul_left_comm, x.map_nsmul],\n  exact pseudo_normed_group.nat_smul_mem_filtration (cᵢ i) _ _ (H i),\nend\n\nend\n\nnamespace polyhedral_lattice\n\nvariables (Λ : Type*) (r' : ℝ≥0) (M : Type*) [polyhedral_lattice Λ]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M]\n\ninclude r'\n\nnamespace add_monoid_hom\n\nvariables {Λ r' M} (c : ℝ≥0)\n\ndef incl (c : ℝ≥0) : filtration (Λ →+ M) c → Π l : Λ, filtration M (c * ∥l∥₊) :=\nλ f l, ⟨f l, f.2 $ mem_filtration_nnnorm _⟩\n\n@[simp] lemma coe_incl_apply (f : filtration (Λ →+ M) c) (l : Λ) :\n  (incl c f l : M) = f l :=\nrfl\n\nvariables (Λ r' M)\n\nlemma incl_injective : function.injective (@incl Λ r' M _ _ c) :=\nbegin\n  intros f g h,\n  ext l,\n  show (incl c f l : M) = incl c g l,\n  rw h\nend\n\ninstance : topological_space (filtration (Λ →+ M) c) :=\ntopological_space.induced (incl c) infer_instance\n\nlemma incl_embedding : embedding (@incl Λ r' M _ _ c) :=\n{ induced := rfl,\n  inj := incl_injective Λ r' M c }\n\nlemma incl_inducing : inducing (@incl Λ r' M _ _ c) := ⟨rfl⟩\n\nlemma incl_continuous : continuous (@incl Λ r' M _ _ c) :=\n(incl_inducing _ _ _ _).continuous\n\ninstance : t2_space (filtration (Λ →+ M) c) :=\n(incl_embedding Λ r' M c).t2_space\n\ninstance : totally_disconnected_space (filtration (Λ →+ M) c) :=\n{ is_totally_disconnected_univ := (incl_embedding Λ r' M c).is_totally_disconnected $\n    is_totally_disconnected_of_totally_disconnected_space _ }\n\nlemma incl_range_eq :\n  (set.range (@incl Λ r' M _ _ c)) =\n    ⋂ l₁ l₂, {f | (cast_le (f (l₁ + l₂)) : filtration M (c * (∥l₁∥₊ + ∥l₂∥₊))) =\n    cast_le (add' (f l₁, f l₂))} :=\nbegin\n  ext f,\n  simp only [set.mem_range, set.mem_Inter, coe_fn_coe_base, coe_incl_apply,\n    set.mem_set_of_eq, subtype.coe_mk, subtype.ext_iff],\n  split,\n  { rintro ⟨⟨f, hf⟩, rfl⟩ l₁ l₂,\n    exact f.map_add _ _ },\n  { intro h,\n    refine ⟨⟨add_monoid_hom.mk' (λ l, f l) h, _⟩, _⟩,\n    { intros c' l hl,\n      rw mem_filtration_iff at hl,\n      exact filtration_mono (mul_le_mul' le_rfl hl) (f l).2 },\n    { ext, refl } }\nend\n\nopen profinitely_filtered_pseudo_normed_group\n  comphaus_filtered_pseudo_normed_group\n\nlemma incl_range_is_closed : (is_closed (set.range (@incl Λ r' M _ _ c))) :=\nbegin\n  rw incl_range_eq,\n  apply is_closed_Inter,\n  intro l₁,\n  apply is_closed_Inter,\n  intro l₂,\n  apply is_closed_eq,\n  { exact (continuous_cast_le _ _).comp (continuous_apply (l₁ + l₂)) },\n  { exact (continuous_cast_le _ _).comp ((continuous_add' _ _).comp\n          ((continuous_apply l₁).prod_mk (continuous_apply l₂))) },\nend\n\ninstance : compact_space (filtration (Λ →+ M) c) :=\n{ compact_univ :=\n  begin\n    rw ← (incl_inducing Λ r' M c).is_compact_iff,\n    apply is_closed.is_compact,\n    rw set.image_univ,\n    exact incl_range_is_closed _ _ _ _\n  end }\n\nlemma continuous_iff {X : Type*} [topological_space X]\n  (ϕ : X → (filtration (Λ →+ M) c)) :\n  continuous ϕ ↔ ∀ l : Λ, continuous (λ x, incl c (ϕ x) l) :=\nbegin\n  rw (incl_inducing Λ r' M c).continuous_iff,\n  split,\n  { intros h l, exact (continuous_apply l).comp h },\n  { exact continuous_pi }\nend\n\ninstance profinitely_filtered_pseudo_normed_group :\n  profinitely_filtered_pseudo_normed_group (Λ →+ M) :=\n{ continuous_add' :=\n  begin\n    intros c₁ c₂,\n    rw continuous_iff,\n    intro l,\n    have step1 :=\n      ((continuous_apply l).comp (incl_continuous Λ r' M c₁)).prod_map\n      ((continuous_apply l).comp (incl_continuous Λ r' M c₂)),\n    have step2 := (continuous_add' (c₁ * ∥l∥₊) (c₂ * ∥l∥₊)),\n    have := step2.comp step1,\n    refine (@continuous_cast_le _ _ _ _ (id _)).comp this,\n    rw add_mul, exact ⟨le_rfl⟩\n  end,\n  continuous_neg' :=\n  begin\n    intro c,\n    rw continuous_iff,\n    intro l,\n    exact (continuous_neg' _).comp ((continuous_apply l).comp (incl_continuous Λ r' M c)),\n  end,\n  continuous_cast_le :=\n  begin\n    introsI c₁ c₂ h,\n    rw continuous_iff,\n    intro l,\n    exact (continuous_cast_le _ _).comp ((continuous_apply l).comp (incl_continuous Λ r' M c₁))\n  end,\n  .. add_monoid_hom.pseudo_normed_group }\n\nend add_monoid_hom\n\nvariables {Λ r' M}\n\nopen profinitely_filtered_pseudo_normed_group_with_Tinv\n\ndef Tinv' : (Λ →+ M) →+ (Λ →+ M) :=\nadd_monoid_hom.comp_hom\n  (@Tinv r' M _).to_add_monoid_hom\n\n@[simp] lemma Tinv'_apply (f : Λ →+ M) (l : Λ) :\n  Tinv' f l = Tinv (f l) := rfl\n\nlemma Tinv'_mem_filtration (c : ℝ≥0) (f : Λ →+ M) (hf : f ∈ filtration (Λ →+ M) c) :\n  Tinv' f ∈ filtration (Λ →+ M) (r'⁻¹ * c) :=\nbegin\n  intros x l hl,\n  rw [Tinv'_apply, mul_assoc],\n  apply Tinv_mem_filtration,\n  exact hf hl\nend\n\nvariables (Λ r' M)\n\nopen profinitely_filtered_pseudo_normed_group\nopen comphaus_filtered_pseudo_normed_group\nvariables [fact (0 < r')]\n\ndef Tinv : comphaus_filtered_pseudo_normed_group_hom (Λ →+ M) (Λ →+ M) :=\ncomphaus_filtered_pseudo_normed_group_hom.mk' Tinv'\nbegin\n  refine ⟨r'⁻¹, λ c, ⟨Tinv'_mem_filtration c, _⟩⟩,\n  rw add_monoid_hom.continuous_iff,\n  intro l,\n  haveI : ∀ a, fact (a ≤ r' * (r'⁻¹ * a)) :=\n    λ a, ⟨by simp [mul_inv_cancel_left₀ (ne_of_gt (fact.out _ : 0 < r'))]⟩,\n  refine (@continuous_cast_le _ _ _ _ (id _)).comp\n    ((@Tinv₀_continuous r' M _ (c * ∥l∥₊) (r'⁻¹ * (c * ∥l∥₊)) _).comp\n    ((continuous_apply l).comp (add_monoid_hom.incl_continuous Λ r' M c))),\n  rw mul_assoc, exact ⟨le_rfl⟩\nend\n\ninstance : profinitely_filtered_pseudo_normed_group_with_Tinv r' (Λ →+ M) :=\n{ Tinv := Tinv Λ r' M,\n  Tinv_mem_filtration := Tinv'_mem_filtration,\n  .. add_monoid_hom.profinitely_filtered_pseudo_normed_group Λ r' M }\n\n@[simp] lemma Tinv_apply (x : Λ →+ M) (l : Λ) :\n  (profinitely_filtered_pseudo_normed_group_with_Tinv.Tinv x) l =\n  profinitely_filtered_pseudo_normed_group_with_Tinv.Tinv (x l) := rfl\n\nend polyhedral_lattice\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/polyhedral_lattice/pseudo_normed_group.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4607544475092444}}
{"text": "import algebra.free_monoid\nimport group_theory.congruence\nimport computability.language\nimport group_theory.free_group\n\nuniverses u v\nvariable (α : Type u) \nvariables {L L₁ L₂ L₃ L₄ : list (α × bool)}\n\nopen relation \n\nnamespace dyck\n\nvariable {α}\n\ninductive red.step : list (α × bool) → list (α × bool) → Prop\n| mul_inv {L L₁ : list (α × bool)} {x} : red.step (L ++ (x,tt) :: (x,ff) :: L₁) (L ++ L₁)\nattribute [simp] mul_inv \n\ndef red {α}  := relation.refl_trans_gen (@red.step α) \n\n@[refl] lemma red.refl : red L L := relation.refl_trans_gen.refl\n@[trans] lemma red.trans : red L₁ L₂ → red L₂ L₃ → red L₁ L₃ := relation.refl_trans_gen.trans\n\nnamespace red\n\ntheorem step.length : ∀ {L₁ L₂ : list (α × bool)}, step L₁ L₂ → L₂.length + 2 = L₁.length\n| _ _ (@red.step.mul_inv _ L₁ L₂ x) := by rw [list.length_append, list.length_append]; refl\n\n@[simp] lemma step.cons_mul_inv {x} : red.step ((x, tt) :: (x, ff) :: L) L :=\n@step.mul_inv _ [] _ _ \n\ntheorem step.append_left : ∀ {L₁ L₂ L₃ : list (α × bool)}, step L₂ L₃ → step (L₁ ++ L₂) (L₁ ++ L₃)\n| _ _ _ red.step.mul_inv := by rw [← list.append_assoc, ← list.append_assoc]; constructor\n\ntheorem step.append_right : ∀ {L₁ L₂ L₃ : list (α × bool)}, step L₁ L₂ → step (L₁ ++ L₃) (L₂ ++ L₃)\n| _ _ _ red.step.mul_inv := by simp only [list.append_assoc, list.cons_append]; constructor\n\ntheorem step.cons {x} (H : red.step L₁ L₂) : red.step (x :: L₁) (x :: L₂) :=\n@step.append_left _ [x] _ _ H\n\nlemma not_step_nil : ¬ step [] L :=\nbegin\n  generalize h' : [] = L',\n  assume h,\n  cases h with L₁ L₂,\n  simp [list.append_eq_has_append, list.nil_eq_append_iff] at h',\n  contradiction,\nend\n\nprivate lemma not_step_inv {a : α} : ¬ step [(a, ff)] L :=\nbegin\n  assume h,\n  generalize h' : [(a,ff)] = L',\n  rw h' at h,\n  cases h with L₁ L₂,\n  simp [list.append_eq_has_append, list.nil_eq_append_iff] at h',\n  cases L₁, \n  { simp only [list.append, list.nil_append, and_false] at h',\n    exact h' }, \n  { dsimp at h',\n    simp only [list.nil_eq_append_iff, and_false] at h',\n    exact h' }\nend\n\nlemma step.cons_left_iff {a : α} :\n  step ((a, tt) :: L₁) L₂ ↔ (∃ L, step L₁ L ∧ L₂ = (a, tt) :: L) ∨ (L₁ = (a, ff) :: L₂) :=\nbegin\n  split,\n  { generalize hL : ((a, tt) :: L₁ : list _) = L,\n    assume h,\n    rcases h with ⟨_ | ⟨p, s'⟩, e, a'⟩,\n    { simp at hL, simp [*] },\n    { simp at hL,\n      rcases hL with ⟨rfl, rfl⟩,\n      refine or.inl ⟨s' ++ e, step.mul_inv, _⟩,\n      simp only [list.append, eq_self_iff_true, true_and],\n      tauto } },\n  { assume h,\n    rcases h with ⟨L, h, rfl⟩ | rfl,\n    { exact step.cons h },\n    { simp only [step.cons_mul_inv] } }\nend\n\nlemma step.cons_left_of_inv_iff {a : α} :\n  step ((a, ff) :: L₁) L₂ ↔ (∃ L, step L₁ L ∧ L₂ = (a, ff) :: L) :=\nbegin\n  split, \n  { generalize hL : ((a, ff) :: L₁ : list _) = L,\n    assume h,\n    rcases h with ⟨_ | ⟨p, s'⟩, e, a'⟩,\n    { simp only [list.append, prod.mk.inj_iff, and_false, false_and, step.cons_mul_inv] at *,\n      exact false.rec (∃ (L : list (α × bool)), step L₁ L ∧ e = (a, ff) :: L) hL },\n    { simp only [list.append, eq_self_iff_true, true_and] at *,\n      rcases hL with ⟨rfl, rfl⟩,\n      simp only [eq_self_iff_true, true_and, exists_eq_right'] at *,\n      fconstructor } }, \n    { intro h,\n      rcases h with ⟨L, h, h'⟩,\n      rw h'; exact step.cons h }\nend\n\nlemma not_step_singleton : ∀ {p : α × bool}, ¬ step [p] L \n| (a, tt) := by simp [step.cons_left_iff, not_step_nil]\n| (a, ff) := by exact not_step_inv\n\nlemma step.to_red : step L₁ L₂ → red L₁ L₂ :=\nrelation.refl_trans_gen.single\n\nlemma step.cons_of_inv_cons_iff : ∀ {a : α}, step ((a, ff) :: L₁) ((a, ff) :: L₂) ↔ step L₁ L₂ :=\nbegin\n  intro a,\n  split, \n  { intro h,\n    rw step.cons_left_of_inv_iff at h,\n    rcases h with ⟨L, _, _⟩,\n    simp only [eq_self_iff_true, true_and] at h_h_right,\n    rw ← h_h_right at h_h_left,\n    exact h_h_left }, \n    { exact step.cons }\nend\n\n\nlemma cons_cons {p} : red L₁ L₂ → red (p :: L₁) (p :: L₂) :=\nrelation.refl_trans_gen.lift (list.cons p) (assume a b, step.cons)\n\nprivate theorem step.diamond_aux : ∀ {L₁ L₂ L₃ L₄ : list (α × bool)} {x1 x2 },\n  L₁ ++ (x1, tt) :: (x1, ff) :: L₂ = L₃ ++ (x2, tt) :: (x2, ff) :: L₄ →\n  L₁ ++ L₂ = L₃ ++ L₄ ∨ ∃ L₅, red.step (L₁ ++ L₂) L₅ ∧ red.step (L₃ ++ L₄) L₅\n:=\nbegin\n  intros L₁ L₂ L₃ L₄ x1 x2 h,\n  rw list.append_eq_append_iff at *,\n  induction h,\n  rcases h with ⟨a', hl, hr⟩,\n  rw list.cons_eq_append_iff at *,\n  induction hr,\n  cases hr with hrl hrr,\n  \n  simp at *,\n  left,\n  left,\n  use ([]),\n  split,\n  rw ← hrl,\n  exact hl,\n\n  simp,\n  exact hrr.2.symm,\n\n  rcases hr with ⟨a'', hrl, hrr⟩,\n  rw list.cons_eq_append_iff at *,\n  induction hrr,\n  cases hrr with hrrl hrrr,\n  simp at *,\n  exact false.rec\n  (((∃ (a' : list (α × bool)), L₃ = L₁ ++ a' ∧ L₂ = a' ++ L₄) ∨\n        ∃ (c' : list (α × bool)), L₁ = L₃ ++ c' ∧ L₄ = c' ++ L₂) ∨\n     ∃ (L₅ : list (α × bool)), step (L₁ ++ L₂) L₅ ∧ step (L₃ ++ L₄) L₅)\n  hrrr,\n\n  rcases hrr with ⟨b', hrrl, hrrr⟩,\n  rw hrrl at hrl,\n  rw hrl at hl,\n  right,\n  subst_vars,\n  use (L₁ ++ b' ++L₄),\n  split,\n  rw ← list.append_assoc,\n  generalize eq₁ : (L₁ ++ b' = LL),\n  exact step.mul_inv,\n  generalize eq₁ : (b' ++ L₄= LL),\n  simp,\n  rw eq₁,\n  exact step.mul_inv,\n\n  rcases h with ⟨c, hl, hr⟩,\n  rw list.cons_eq_append_iff at *,\n  induction hr,\n  cases hr with hrl hrr,\n  simp at *,\n  left,\n  rw hrl at *,\n  simp at *,\n  use ([]),\n  simp,\n  tauto,\n\n  rcases hr with ⟨a', hrl, hrr⟩,\n  rw list.cons_eq_append_iff at *,\n  induction hrr,\n\n  cases hrr with hrrl hrrr,\n  simp at *,\n  exact false.rec\n  (((∃ (a' : list (α × bool)), L₃ = L₁ ++ a' ∧ L₂ = a' ++ L₄) ∨\n        ∃ (c' : list (α × bool)), L₁ = L₃ ++ c' ∧ L₄ = c' ++ L₂) ∨\n     ∃ (L₅ : list (α × bool)), step (L₁ ++ L₂) L₅ ∧ step (L₃ ++ L₄) L₅)\n  hrrr,\n\n  rcases hrr with ⟨b', hrrl, hrrr⟩,\n  rw hrrl at hrl,\n  rw hrl at hl,\n  right,\n  subst_vars,\n  use (L₃ ++ b' ++ L₂),\n  split,\n  simp,\n  generalize eq₁ : (b' ++ L₂ = LL),\n  exact step.mul_inv,\n\n  rw ← list.append_assoc,\n  generalize eq₁ : (L₃ ++ b' = LL),\n  exact step.mul_inv,\nend\n\ntheorem step.diamond : ∀ {L₁ L₂ L₃ L₄ : list (α × bool)},\n  red.step L₁ L₃ → red.step L₂ L₄ → L₁ = L₂ →\n  L₃ = L₄ ∨ ∃ L₅, red.step L₃ L₅ ∧ red.step L₄ L₅\n| _ _ _ _ red.step.mul_inv red.step.mul_inv H := step.diamond_aux H\n\ntheorem church_rosser : red L₁ L₂ → red L₁ L₃ → relation.join red L₂ L₃ :=\nrelation.church_rosser (assume a b c hab hac,\nmatch b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := ⟨b, by refl, by refl⟩\n| b, c, or.inr ⟨d, hbd, hcd⟩ := ⟨d, relation.refl_gen.single hbd, hcd.to_red⟩\nend)\n\ntheorem nil_iff : red [] L ↔ L = [] :=\nrefl_trans_gen_iff_eq (assume l, red.not_step_nil)\n\ntheorem singleton_iff {x} : red [x] L₁ ↔ L₁ = [x] :=\nrefl_trans_gen_iff_eq (assume l, not_step_singleton)\n\nprivate lemma cons_nil_iff_singleton_aux {x} : \nred L [] → (∃ L', L = (x, tt) :: L') → red L.tail [(x, ff)] :=\nbegin\n  intros h,\n  apply h.head_induction_on,\n  intro h',\n  rcases h' with ⟨L', _⟩,\n  simp at *,\n  contradiction,\n  rintros a c h₂ h₃ h₄ ⟨ L', h₅⟩,\n  induction h₂ with L₁ L₂ x1,\n  have := eq.symm h₅,\n  clear h₅,\n  rw list.cons_eq_append_iff at *,\n  induction this,\n  cases this with hl hr,\n  simp at *,\n  cases hr with hrl hrr,\n  subst_vars,\n  simp at *,\n  rw ← red at *,\n  exact cons_cons h₃,\n\n  rcases this with ⟨a', hl, hr⟩,\n  subst_vars,\n  specialize h₄ _,\n  use (a' ++ L₂),\n  simp at *,\n  have : ((x, tt) :: a' ++ L₂).tail = a' ++ L₂ := by simp,\n  rw this at *,\n  clear this,\n  have : ((x, tt) :: a' ++ (x1, tt) :: (x1, ff) :: L₂).tail = a' ++ (x1, tt) :: (x1, ff) :: L₂ := by simp,\n  rw this at *,\n  clear this,\n  have h₁ : red (a' ++ (x1, tt) :: (x1, ff) :: L₂) (a' ++ L₂), {\n    refine step.to_red _,\n    exact step.mul_inv,\n  },\n  exact trans h₁ h₄,\nend\n\ntheorem cons_nil_iff_singleton {x} : red ((x, tt) :: L) [] ↔ red L [(x, ff)] :=\nbegin\n  split,\n  intro h,\n  have := @cons_nil_iff_singleton_aux α ((x, tt) :: L) x h _,\n  simp at *,\n  exact this,\n  use L,\n  intro h,\n  have h₁ : red ((x, tt) :: L) ((x, tt) :: [(x, ff)]) := cons_cons h,\n  have h₂ : red [(x, tt), (x, ff)] [], {\n    refine step.to_red _,\n    exact step.cons_mul_inv,\n  },\n  exact trans h₁ h₂,\nend  \n\n/-\nprivate lemma append_nil_iff_singleton_aux {x} : \nred L [] → (∃ L', L = L' ++ [(x, ff)]) → red (L.reverse.tail.reverse) [(x, tt)] :=\nbegin\n  intro h,\n  apply h.head_induction_on,\n  sorry,\n  intros a c h₁ h₂ h₃ h₄,\n  induction h₁ with L₁ L₂ x1,\n  rcases h₄ with ⟨L', h⟩,\n  rw list.append_eq_append_iff at *,\n  induction h,\n  rcases h_1 with ⟨a', hl, hr⟩,\n  rw list.cons_eq_append_iff at *,\n  induction hr,\n  cases hr with hrl hrr,\n  simp at *,\n  contradiction,\n  rcases hr with ⟨b, hrl, hrr⟩,\n  rw list.cons_eq_append_iff at *,\n  induction hrr,\n  cases hrr with hrrl hrrr,\n  cases hrrr with hrrrl hrrrr,\n  subst_vars,\n  simp at *,\n  repeat {sorry},\nend \n-/\n\ntheorem equivalence_join_red : equivalence (join (@red α)) :=\nequivalence_join_refl_trans_gen $ assume a b c hab hac,\n(match b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := ⟨b, by refl, by refl⟩\n| b, c, or.inr ⟨d, hbd, hcd⟩ := ⟨d, refl_gen.single hbd, refl_trans_gen.single hcd⟩\nend)\n\ntheorem join_red_of_step (h : red.step L₁ L₂) : join red L₁ L₂ :=\njoin_of_single reflexive_refl_trans_gen h.to_red\n\ntheorem eqv_gen_step_iff_join_red : eqv_gen red.step L₁ L₂ ↔ join red L₁ L₂ :=\niff.intro\n  (assume h,\n    have eqv_gen (join red) L₁ L₂ := h.mono (assume a b, join_red_of_step),\n    equivalence_join_red.eqv_gen_iff.1 this)\n  (join_of_equivalence (eqv_gen.is_equivalence _) $ assume a b,\n    refl_trans_gen_of_equivalence (eqv_gen.is_equivalence _) eqv_gen.rel)\n\nlemma to_free_group_step : step L₁ L₂ → free_group.red.step L₁ L₂ :=\nbegin\n  intro h,\n  induction h,\n  exact free_group.red.step.bnot,\nend\n\nlemma to_free_group_red : red L₁ L₂ → free_group.red L₁ L₂ :=\nbegin\n  rw red,\n  rw free_group.red,\n  refine refl_trans_gen.lift (λ {L₁ : list (α × bool)}, L₁) _,\n  intros a b,\n  exact to_free_group_step,\nend\n\ntheorem step.sublist (H : red.step L₁ L₂) : L₂ <+ L₁ :=\nbegin\n  cases H,\n  rw list.append_eq_has_append at *,\n  rw list.append_eq_has_append at *,\n  simp,\n  constructor,\n  constructor,\n  refl,\nend\n\ntheorem sublist : red L₁ L₂ → L₂ <+ L₁ :=\nrefl_trans_gen_of_transitive_reflexive\n  (λl, list.sublist.refl l) (λa b c hab hbc, list.sublist.trans hbc hab) (λa b, red.step.sublist)\n\nend red\n\nend dyck\n\n-- Definition of the dyck syntactic monoid\ndef dyck (α : Type u) : Type u :=\nquot $ @dyck.red.step α\n\nnamespace dyck\n\nvariable {α}\n\ndef mk (L) : dyck α := quot.mk red.step L\n\n@[simp] lemma quot_mk_eq_mk : quot.mk red.step L = mk L := rfl\n\n@[simp] lemma quot_lift_mk (β : Type v) (f : list (α × bool) → β)\n  (H : ∀ L₁ L₂, red.step L₁ L₂ → f L₁ = f L₂) :\nquot.lift f H (mk L) = f L := rfl\n\n@[simp] lemma quot_lift_on_mk (β : Type v) (f : list (α × bool) → β)\n  (H : ∀ L₁ L₂, red.step L₁ L₂ → f L₁ = f L₂) :\nquot.lift_on (mk L) f H = f L := rfl\n\n@[simp] lemma quot_map_mk (β : Type v) (f : list (α × bool) → list (β × bool))\n  (H : (red.step ⇒ red.step) f f) :\nquot.map f H (mk L) = mk (f L) := rfl\n\ninstance : has_one (dyck α) := ⟨mk []⟩\nlemma one_eq_mk : (1 : dyck α) = mk [] := rfl\n\ninstance : inhabited (dyck α) := ⟨1⟩\n\ninstance : has_mul (dyck α) :=\n⟨λ x y, quot.lift_on x\n    (λ L₁, quot.lift_on y (λ L₂, mk $ L₁ ++ L₂) (λ L₂ L₃ H, quot.sound $ red.step.append_left H))\n    (λ L₁ L₂ H, quot.induction_on y $ λ L₃, quot.sound $ red.step.append_right H)⟩\n@[simp] lemma mul_mk : mk L₁ * mk L₂ = mk (L₁ ++ L₂) := rfl\n\ninstance : monoid (dyck α) :=\n{ mul := (*),\n  one := 1,\n  mul_assoc := by rintros ⟨L₁⟩ ⟨L₂⟩ ⟨L₃⟩; simp,\n  one_mul := by rintros ⟨L⟩; refl,\n  mul_one := by rintros ⟨L⟩; simp [one_eq_mk],\n}\n\ndef of (x : α) : dyck α :=\nmk [(x, tt)]\n\ntheorem red.exact : mk L₁ = mk L₂ ↔ join red L₁ L₂ :=\ncalc (mk L₁ = mk L₂) ↔ eqv_gen red.step L₁ L₂ : iff.intro (quot.exact _) quot.eqv_gen_sound\n  ... ↔ join red L₁ L₂ : red.eqv_gen_step_iff_join_red\n\ntheorem of_injective : function.injective (@of α) :=\nλ _ _ H, let ⟨L₁, hx, hy⟩ := red.exact.1 H in\n  by simp [red.singleton_iff] at hx hy; cc\n\nlemma mk_one_iff {L : list (α × bool)}: mk L = 1 ↔ red L [] :=\nbegin\nsplit,\n  { intro h,\n    rw [one_eq_mk, red.exact] at h,\n    rcases h with ⟨c, hl, hr⟩,\n    rw red.nil_iff at hr,\n    rw hr at hl,\n    exact hl },\n  { intro h,\n    rw [one_eq_mk, red.exact],\n    use ([]),\n    exact ⟨h, red.refl⟩ }\nend \n\nlemma mk_mul_inv : ∀ {x : α}, mk ([(x, tt), (x, ff)]) = 1 :=\nbegin\n  intro x,\n  rw one_eq_mk,\n  rw red.exact,\n  use ([]),\n  split,\n  refine red.step.to_red _,\n  exact red.step.cons_mul_inv,\n  exact red.refl,\nend\n\ntheorem append_mul_inv_cons_eq {L L₁ : list (α × bool)} {x} : \nmk (L ++ (x, tt) :: (x, ff) :: L₁) = mk (L ++ L₁) :=\nbegin\n  have : L ++ (x, tt) :: (x, ff) :: L₁ = L ++ [(x, tt), (x, ff)] ++ L₁ := by simp,\n  rw [this, ← mul_mk, ← mul_mk, mk_mul_inv, mul_one, mul_mk],\nend \n\n\nlemma mk_free_group : mk L₁ = mk L₂ → free_group.mk L₁ = free_group.mk L₂ :=\nbegin\n  intro h,\n  rw red.exact at *,\n  rw free_group.red.exact,\n  induction h with c h,\n  use c,\n  exact ⟨red.to_free_group_red h.1, red.to_free_group_red h.2⟩,\nend\n\nend dyck", "meta": {"author": "koly777", "repo": "chomsky-schutzenberger-lean", "sha": "cdad7293d28d23ca5373805f1d1cfb38ca46f7f6", "save_path": "github-repos/lean/koly777-chomsky-schutzenberger-lean", "path": "github-repos/lean/koly777-chomsky-schutzenberger-lean/chomsky-schutzenberger-lean-cdad7293d28d23ca5373805f1d1cfb38ca46f7f6/src/dyck/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4607284383675655}}
{"text": "import field_theory.perfect_closure\n\nimport for_mathlib.nnreal\n\nimport valuation.basic\n\nlemma iterate_frobenius_apply {α : Type*} [monoid α] (p n : ℕ) (a : α) :\n  (frobenius α p)^[n] a = a^p^n :=\nbegin\n  induction n with n ih, {simp},\n  rw [nat.iterate_succ', ih, frobenius_def, ← pow_mul, nat.pow_succ]\nend\n\nnoncomputable theory\nopen_locale classical\n\nnamespace valuation\nvariables {R : Type*} [comm_ring R]\nvariables (v : valuation R nnreal)\n\nnamespace perfection\nopen nnreal\nvariables (p : ℕ) [nat.prime p] [char_p R p]\n\nprivate def f₀ : ℕ × R → nnreal :=\nλ (x : ℕ × R), (v x.2)^(p^(-x.1 : ℤ) : ℝ)\n\nprivate def hf₀ : ∀ (x₁ x₂ : ℕ × R) (h : perfect_closure.r R p x₁ x₂),\n  f₀ v p x₁ = f₀ v p x₂\n| x₁ x₂ (perfect_closure.r.intro _ n x) :=\nshow v x ^ (p ^ (-n : ℤ) : ℝ) = v (x ^ p) ^ (p ^ (-(↑n + 1) : ℤ) : ℝ),\nfrom have hp : (p : ℝ) ≠ 0 := by exact_mod_cast nat.prime.ne_zero ‹_›,\nby rw [valuation.map_pow, ← rpow_nat_cast, ← rpow_mul, neg_add_rev,\n    fpow_add hp, ← mul_assoc, fpow_inv, mul_inv_cancel hp, one_mul]\n\ndef f : perfect_closure R p → nnreal :=\nquot.lift (f₀ v p) (hf₀ v p)\n\nlemma f_zero : f v p (0 : perfect_closure R p) = 0 :=\ncalc f v p (0 : perfect_closure R p) = quot.lift (f₀ v p) (hf₀ v p) (0 : perfect_closure R p) : rfl\n  ... = (v (0:R))^(p^(-0:ℤ) : ℝ) : quot.lift_beta (f₀ v p) (hf₀ v p) (0, 0)\n  ... = 0 : by rw [v.map_zero, neg_zero, fpow_zero, rpow_one]\n\nlemma f_one : f v p (1 : perfect_closure R p) = 1 :=\ncalc f v p (1 : perfect_closure R p) = quot.lift (f₀ v p) (hf₀ v p) (1 : perfect_closure R p) : rfl\n  ... = (v (1:R))^(p^(-0:ℤ) : ℝ) : quot.lift_beta (f₀ v p) (hf₀ v p) (0, 1)\n  ... = 1 : by rw [v.map_one, neg_zero, fpow_zero, rpow_one]\n\nlemma f_mul (r s : perfect_closure R p) : f v p (r * s) = f v p r * f v p s :=\nquot.induction_on r $ λ ⟨m,x⟩, quot.induction_on s $ λ ⟨n,y⟩,\nshow f₀ v p (m + n, _) = f₀ v p (m,x) * f₀ v p (n,y), from\nhave hp : p ≠ 0 := nat.prime.ne_zero ‹_›,\nhave hpQ : (p : ℝ) ≠ 0 := by exact_mod_cast hp,\nbegin\n  clear _fun_match _fun_match _x _x,\n  dsimp only [f₀],\n  simp only [iterate_frobenius_apply, v.map_mul, v.map_pow, mul_rpow],\n  congr' 1,\n  all_goals {\n    rw [← rpow_nat_cast, ← rpow_mul, nat.cast_pow, ←fpow_of_nat, ← fpow_add hpQ],\n    { congr, rw [int.coe_nat_add, neg_add], abel }, },\nend\n\nlemma f_add (r s : perfect_closure R p) :\n  f v p (r + s) ≤ max (f v p r) (f v p s) :=\nquot.induction_on r $ λ ⟨m,x⟩, quot.induction_on s $ λ ⟨n,y⟩,\nshow f₀ v p (m + n, _) ≤ max (f₀ v p (m,x)) (f₀ v p (n,y)), from\nhave hp : p ≠ 0 := nat.prime.ne_zero ‹_›,\nhave hpQ : (p : ℝ) ≠ 0 := by exact_mod_cast hp,\nbegin\n  clear _fun_match _fun_match _x _x,\n  dsimp only [f₀],\n  rw [iterate_frobenius_apply, iterate_frobenius_apply],\n  have h := v.map_add (x^p^n) (y^p^m),\n  rw le_max_iff at h ⊢,\n  cases h with h h; [ {left, rw add_comm m}, right],\n  all_goals {\n    conv_rhs at h { rw v.map_pow },\n    refine le_trans (rpow_le_rpow _ h (fpow_nonneg_of_nonneg (nat.cast_nonneg p) _)) (le_of_eq _),\n    rw [← rpow_nat_cast, ← rpow_mul, nat.cast_pow, ←fpow_of_nat, ← fpow_add hpQ],\n    { congr, rw [int.coe_nat_add, neg_add], abel }, }\nend\n\nend perfection\n\nsection\nvariables (p : ℕ) [nat.prime p] [char_p R p]\n\ndef perfection : valuation (perfect_closure R p) nnreal :=\n{ to_fun := perfection.f v p,\n  map_zero' := perfection.f_zero v p,\n  map_one' := perfection.f_one v p,\n  map_mul' := perfection.f_mul v p,\n  map_add' :=\n  begin\n    -- TODO(jmc): This is really ugly. But Lean doesn't cooperate.\n    -- It finds two instances that aren't defeq.\n    intros r s,\n    convert perfection.f_add v p r s,\n    delta classical.DLO nnreal.decidable_linear_order,\n    congr,\n  end }\n\nend\n\nend valuation\n", "meta": {"author": "leanprover-community", "repo": "lean-perfectoid-spaces", "sha": "95a6520ce578b30a80b4c36e36ab2d559a842690", "save_path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces", "path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces/lean-perfectoid-spaces-95a6520ce578b30a80b4c36e36ab2d559a842690/src/valuation/perfection.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998663336158, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.460679668924697}}
{"text": "/-\nCopyright (c) 2020 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.natural_isomorphism\nimport Mathlib.PostPort\n\nuniverses v u l u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Quotient category\n\nConstructs the quotient of a category by an arbitrary family of relations on its hom-sets,\nby introducing a type synonym for the objects, and identifying homs as necessary.\n\nThis is analogous to 'the quotient of a group by the normal closure of a subset', rather\nthan 'the quotient of a group by a normal subgroup'.\n-/\n\nnamespace category_theory\n\n\n/-- A type synonom for `C`, thought of as the objects of the quotient category. -/\nstructure quotient {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) \nwhere\n  as : C\n\nprotected instance quotient.inhabited {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) [Inhabited C] : Inhabited (quotient r) :=\n  { default := quotient.mk Inhabited.default }\n\nnamespace quotient\n\n\n/-- Generates the closure of a family of relations w.r.t. composition from left and right. -/\ninductive comp_closure {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {s : C} {t : C} : (s ⟶ t) → (s ⟶ t) → Prop\nwhere\n| intro : ∀ {a b : C} (f : s ⟶ a) (m₁ m₂ : a ⟶ b) (g : b ⟶ t), r m₁ m₂ → comp_closure r (f ≫ m₁ ≫ g) (f ≫ m₂ ≫ g)\n\ntheorem comp_left {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : C} {b : C} {c : C} (f : a ⟶ b) (g₁ : b ⟶ c) (g₂ : b ⟶ c) (h : comp_closure r g₁ g₂) : comp_closure r (f ≫ g₁) (f ≫ g₂) := sorry\n\ntheorem comp_right {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : C} {b : C} {c : C} (g : b ⟶ c) (f₁ : a ⟶ b) (f₂ : a ⟶ b) (h : comp_closure r f₁ f₂) : comp_closure r (f₁ ≫ g) (f₂ ≫ g) := sorry\n\n/-- Hom-sets of the quotient category. -/\ndef hom {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) (s : quotient r) (t : quotient r) :=\n  Quot (comp_closure r)\n\nprotected instance hom.inhabited {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) (a : quotient r) : Inhabited (hom r a a) :=\n  { default := Quot.mk (comp_closure r) 𝟙 }\n\n/-- Composition in the quotient category. -/\ndef comp {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : quotient r} {b : quotient r} {c : quotient r} : hom r a b → hom r b c → hom r a c :=\n  fun (hf : hom r a b) (hg : hom r b c) =>\n    quot.lift_on hf\n      (fun (f : as a ⟶ as b) => quot.lift_on hg (fun (g : as b ⟶ as c) => Quot.mk (comp_closure r) (f ≫ g)) sorry) sorry\n\n@[simp] theorem comp_mk {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : quotient r} {b : quotient r} {c : quotient r} (f : as a ⟶ as b) (g : as b ⟶ as c) : comp r (Quot.mk (comp_closure r) f) (Quot.mk (comp_closure r) g) = Quot.mk (comp_closure r) (f ≫ g) :=\n  rfl\n\nprotected instance category {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) : category (quotient r) :=\n  category.mk\n\n/-- The functor from a category to its quotient. -/\n@[simp] theorem functor_map {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) (_x : C) : ∀ (_x_1 : C) (f : _x ⟶ _x_1), functor.map (functor r) f = Quot.mk (comp_closure r) f :=\n  fun (_x_1 : C) (f : _x ⟶ _x_1) => Eq.refl (functor.map (functor r) f)\n\nprotected theorem induction {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {P : {a b : quotient r} → (a ⟶ b) → Prop} (h : ∀ {x y : C} (f : x ⟶ y), P (functor.map (functor r) f)) {a : quotient r} {b : quotient r} (f : a ⟶ b) : P f := sorry\n\nprotected theorem sound {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {a : C} {b : C} {f₁ : a ⟶ b} {f₂ : a ⟶ b} (h : r f₁ f₂) : functor.map (functor r) f₁ = functor.map (functor r) f₂ := sorry\n\n/-- The induced functor on the quotient category. -/\ndef lift {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1} [category D] (F : C ⥤ D) (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) : quotient r ⥤ D :=\n  functor.mk (fun (a : quotient r) => functor.obj F (as a))\n    fun (a b : quotient r) (hf : a ⟶ b) => quot.lift_on hf (fun (f : as a ⟶ as b) => functor.map F f) sorry\n\n/-- The original functor factors through the induced functor. -/\ndef lift.is_lift {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1} [category D] (F : C ⥤ D) (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) : functor r ⋙ lift r F H ≅ F :=\n  nat_iso.of_components (fun (X : C) => iso.refl (functor.obj (functor r ⋙ lift r F H) X)) sorry\n\n@[simp] theorem lift.is_lift_hom {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1} [category D] (F : C ⥤ D) (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) (X : C) : nat_trans.app (iso.hom (lift.is_lift r F H)) X = 𝟙 :=\n  rfl\n\n@[simp] theorem lift.is_lift_inv {C : Type u} [category C] (r : {a b : C} → (a ⟶ b) → (a ⟶ b) → Prop) {D : Type u_1} [category D] (F : C ⥤ D) (H : ∀ (x y : C) (f₁ f₂ : x ⟶ y), r f₁ f₂ → functor.map F f₁ = functor.map F f₂) (X : C) : nat_trans.app (iso.inv (lift.is_lift r F H)) X = 𝟙 :=\n  rfl\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/quotient.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.46067965975212977}}
{"text": "import data.finsupp\nimport algebra.ring\nimport .to_finset\nimport .to_multiset\n\n\nlocal infix ^ := monoid.pow\n\n\nuniverse u\nvariable {α : Type u}\nvariable [semiring α]\n\ndef associated (x y : α) : Prop:=\n∃u : units α, x = u * y\n\nlocal notation a `~ᵤ` b : 50 := associated a b\n\ndef is_unit (a : α) : Prop := ∃b : units α, a = b\n\n/- is used once in UFD, but I don't understand what it does\n-/\nlemma is_unit_unit  (u : units α) : @is_unit α _ u :=\n⟨u, rfl⟩\n\n\n@[simp] lemma is_unit_one : is_unit (1 : α ) := ⟨1, rfl⟩\n\n--Should I do all these lemmas using the zero_ne_one class?\n@[simp] lemma not_is_unit_zero (h : (0 : α) ≠ 1) : ¬ is_unit (0 : α) := --Do we need semiring?\nbegin\n  intro h,\n  rcases h with ⟨u, hu⟩,\n  have h2: u.val*u.inv = 1,\n    from u.val_inv,\n  simp [units.val_coe] at *,\n  rw [←hu, _root_.zero_mul] at h2,\n  contradiction,\nend\n\nlemma ne_zero_of_is_unit {a : α} (h : (0 : α) ≠ 1) : is_unit a → a ≠ 0 :=\nbegin\n  intros h1 h2,\n  subst h2,\n  exact not_is_unit_zero h h1,\nend\n\nlemma is_unit_mul_of_is_unit_of_is_unit {a b : α} (h1 : is_unit a) (h2 : is_unit b) : is_unit (a * b) :=\nlet ⟨aᵤ, ha⟩ := h1 in\nlet ⟨bᵤ, hb⟩ := h2 in ⟨aᵤ*bᵤ, by simp [units.mul_coe, *]⟩\n\nlemma zero_associated_zero   : (0 : α) ~ᵤ 0 := ⟨1, by simp⟩\n\nlemma unit_associated_one {u : units α}: (u : α) ~ᵤ 1 := ⟨u, by simp⟩\n", "meta": {"author": "johoelzl", "repo": "mason-stother", "sha": "573ecfaada288176462c03c87b80ad05bdab4644", "save_path": "github-repos/lean/johoelzl-mason-stother", "path": "github-repos/lean/johoelzl-mason-stother/mason-stother-573ecfaada288176462c03c87b80ad05bdab4644/to_semiring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210897, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.460670736912437}}
{"text": "/-\nCopyright (c) 2022 Newell Jensen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Newell Jensen\n-/\nimport Lean\n\n/-!\n# `rfl` tactic extension for reflexive relations\n\nThis extends the `rfl` tactic so that it works on any reflexive relation,\nprovided the reflexivity lemma has been marked as `@[refl]`.\n-/\n\nnamespace Mathlib.Tactic\n\nopen Lean Meta\n\n/-- Environment extensions for `refl` lemmas -/\ninitialize reflExt :\n    SimpleScopedEnvExtension (Name × Array (DiscrTree.Key true)) (DiscrTree Name true) ←\n  registerSimpleScopedEnvExtension {\n    addEntry := fun dt (n, ks) ↦ dt.insertCore ks n\n    initial := {}\n  }\n\ninitialize registerBuiltinAttribute {\n  name := `refl\n  descr := \"reflexivity relation\"\n  add := fun decl _ kind ↦ MetaM.run' do\n    let declTy := (← getConstInfo decl).type\n    let (_, _, targetTy) ← withReducible <| forallMetaTelescopeReducing declTy\n    let fail := throwError\n      \"@[refl] attribute only applies to lemmas proving x ∼ x, got {declTy}\"\n    let .app (.app rel lhs) rhs := targetTy | fail\n    unless ← withNewMCtxDepth <| isDefEq lhs rhs do fail\n    let key ← DiscrTree.mkPath rel\n    reflExt.add (decl, key) kind\n}\n\nopen Elab.Tactic in\n/--\nThis tactic applies to a goal whose target has the form `x ~ x`, where `~` is a reflexive\nrelation, that is, a relation which has a reflexive lemma tagged with the attribute [refl].\n-/\nelab_rules : tactic\n| `(tactic| rfl) => withMainContext do\n  let tgt ← getMainTarget\n  let .app (.app rel _) _ := tgt\n    | throwError \"reflexivity lemmas only apply to binary relations, not {indentExpr tgt}\"\n  let s ← saveState\n  for lem in ← (reflExt.getState (← getEnv)).getMatch rel do\n    try\n      liftMetaTactic (·.apply (← mkConstWithFreshMVarLevels lem))\n      return\n    catch e =>\n      s.restore\n      throw e\n  throwError \"rfl failed, no lemma with @[refl] applies\"\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Tactic/Relation/Rfl.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.46067073597788794}}
{"text": "universe u\nvariables (α β : Type u)\n\nexample (f : α → β) (a : α) : (λ x, f x) a = f a := rfl\nexample (a : α) (b : α) : (a, b).1 = a := rfl\nexample : 2 + 3 = 5 := rfl\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch4/ex0206.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8080671950640465, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4604792336280477}}
{"text": "/-\nCopyright (c) 2016 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura\n\n! This file was ported from Lean 3 source module logic.basic\n! leanprover-community/mathlib commit d2d8742b0c21426362a9dacebc6005db895ca963\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Init.Logic\nimport Mathlib.Init.Function\nimport Mathlib.Init.Algebra.Classes\nimport Mathlib.Tactic.Basic\nimport Mathlib.Tactic.LeftRight\nimport Std.Util.LibraryNote\nimport Std.Tactic.Lint.Basic\n\n/-!\n# Basic logic properties\n\nThis file is one of the earliest imports in mathlib.\n\n## Implementation notes\n\nTheorems that require decidability hypotheses are in the namespace `Decidable`.\nClassical versions are in the namespace `Classical`.\n-/\n\nopen Function\nattribute [local instance 10] Classical.propDecidable\n\nsection Miscellany\n\n-- Porting note: the following `inline` attributes have been omitted,\n-- on the assumption that this issue has been dealt with properly in Lean 4.\n-- /- We add the `inline` attribute to optimize VM computation using these declarations.\n--    For example, `if p ∧ q then ... else ...` will not evaluate the decidability\n--    of `q` if `p` is false. -/\n-- attribute [inline]\n--   And.decidable Or.decidable Decidable.false Xor.decidable Iff.decidable Decidable.true\n--   Implies.decidable Not.decidable Ne.decidable Bool.decidableEq Decidable.toBool\n\nattribute [simp] cast_eq cast_heq\n\n/-- An identity function with its main argument implicit. This will be printed as `hidden` even\nif it is applied to a large term, so it can be used for elision,\nas done in the `elide` and `unelide` tactics. -/\n@[reducible] def hidden {α : Sort _} {a : α} := a\n#align hidden hidden\n\ninstance (priority := 10) decidableEq_of_subsingleton [Subsingleton α] : DecidableEq α :=\n  fun a b ↦ isTrue (Subsingleton.elim a b)\n#align decidable_eq_of_subsingleton decidableEq_of_subsingleton\n\ninstance (α : Sort _) [Subsingleton α] (p : α → Prop) : Subsingleton (Subtype p) :=\n  ⟨fun ⟨x, _⟩ ⟨y, _⟩ ↦ by cases Subsingleton.elim x y; rfl⟩\n\n#align pempty PEmpty\n\ntheorem congr_heq {α β γ : Sort _} {f : α → γ} {g : β → γ} {x : α} {y : β}\n    (h₁ : HEq f g) (h₂ : HEq x y) : f x = g y := by\n  cases h₂; cases h₁; rfl\n#align congr_heq congr_heq\n\ntheorem congr_arg_heq {α} {β : α → Sort _} (f : ∀ a, β a) :\n    ∀ {a₁ a₂ : α}, a₁ = a₂ → HEq (f a₁) (f a₂)\n  | _, _, rfl => HEq.rfl\n#align congr_arg_heq congr_arg_heq\n\ntheorem ULift.down_injective {α : Sort _} : Function.Injective (@ULift.down α)\n  | ⟨a⟩, ⟨b⟩, _ => by congr\n#align ulift.down_injective ULift.down_injective\n\n@[simp] theorem ULift.down_inj {α : Sort _} {a b : ULift α} : a.down = b.down ↔ a = b :=\n  ⟨fun h ↦ ULift.down_injective h, fun h ↦ by rw [h]⟩\n#align ulift.down_inj ULift.down_inj\n\ntheorem PLift.down_injective {α : Sort _} : Function.Injective (@PLift.down α)\n  | ⟨a⟩, ⟨b⟩, _ => by congr\n#align plift.down_injective PLift.down_injective\n\n@[simp] theorem PLift.down_inj {α : Sort _} {a b : PLift α} : a.down = b.down ↔ a = b :=\n  ⟨fun h ↦ PLift.down_injective h, fun h ↦ by rw [h]⟩\n#align plift.down_inj PLift.down_inj\n\n@[simp] theorem eq_iff_eq_cancel_left {b c : α} : (∀ {a}, a = b ↔ a = c) ↔ b = c :=\n  ⟨fun h ↦ by rw [← h], fun h a ↦ by rw [h]⟩\n#align eq_iff_eq_cancel_left eq_iff_eq_cancel_left\n\n@[simp] theorem eq_iff_eq_cancel_right {a b : α} : (∀ {c}, a = c ↔ b = c) ↔ a = b :=\n  ⟨fun h ↦ by rw [h], fun h a ↦ by rw [h]⟩\n#align eq_iff_eq_cancel_right eq_iff_eq_cancel_right\n\nlemma ne_and_eq_iff_right {α : Sort _} {a b c : α} (h : b ≠ c) : a ≠ b ∧ a = c ↔ a = c :=\n  and_iff_right_of_imp (fun h2 => h2.symm ▸ h.symm)\n#align ne_and_eq_iff_right ne_and_eq_iff_right\n\n/-- Wrapper for adding elementary propositions to the type class systems.\nWarning: this can easily be abused. See the rest of this docstring for details.\n\nCertain propositions should not be treated as a class globally,\nbut sometimes it is very convenient to be able to use the type class system\nin specific circumstances.\n\nFor example, `ZMod p` is a field if and only if `p` is a prime number.\nIn order to be able to find this field instance automatically by type class search,\nwe have to turn `p.prime` into an instance implicit assumption.\n\nOn the other hand, making `Nat.prime` a class would require a major refactoring of the library,\nand it is questionable whether making `Nat.prime` a class is desirable at all.\nThe compromise is to add the assumption `[Fact p.prime]` to `ZMod.field`.\n\nIn particular, this class is not intended for turning the type class system\ninto an automated theorem prover for first order logic. -/\nclass Fact (p : Prop) : Prop where\n  /-- `Fact.out` contains the unwrapped witness for the fact represented by the instance of\n  `Fact p`. -/\n  out : p\n#align fact Fact\n\nlibrary_note \"fact non-instances\"/--\nIn most cases, we should not have global instances of `Fact`; typeclass search only reads the head\nsymbol and then tries any instances, which means that adding any such instance will cause slowdowns\neverywhere. We instead make them as lemmata and make them local instances as required.\n-/\n\ntheorem Fact.elim {p : Prop} (h : Fact p) : p := h.1\ntheorem fact_iff {p : Prop} : Fact p ↔ p := ⟨fun h ↦ h.1, fun h ↦ ⟨h⟩⟩\n#align fact_iff fact_iff\n#align fact.elim Fact.elim\n\n/-- Swaps two pairs of arguments to a function. -/\n@[reducible] def Function.swap₂ {κ₁ : ι₁ → Sort _} {κ₂ : ι₂ → Sort _}\n    {φ : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Sort _} (f : ∀ i₁ j₁ i₂ j₂, φ i₁ j₁ i₂ j₂)\n    (i₂ j₂ i₁ j₁) : φ i₁ j₁ i₂ j₂ := f i₁ j₁ i₂ j₂\n#align function.swap₂ Function.swap₂\n\n-- Porting note: these don't work as intended any more\n-- /-- If `x : α . tac_name` then `x.out : α`. These are definitionally equal, but this can\n-- nevertheless be useful for various reasons, e.g. to apply further projection notation or in an\n-- argument to `simp`. -/\n-- def autoParam'.out {α : Sort _} {n : Name} (x : autoParam' α n) : α := x\n\n-- /-- If `x : α := d` then `x.out : α`. These are definitionally equal, but this can\n-- nevertheless be useful for various reasons, e.g. to apply further projection notation or in an\n-- argument to `simp`. -/\n-- def optParam.out {α : Sort _} {d : α} (x : α := d) : α := x\n\nend Miscellany\n\nopen Function\n\n/-!\n### Declarations about propositional connectives\n-/\n\nsection Propositional\n\n/-! ### Declarations about `implies` -/\n\ninstance : IsRefl Prop Iff := ⟨Iff.refl⟩\n\ninstance : IsTrans Prop Iff := ⟨fun _ _ _ ↦ Iff.trans⟩\n\nalias imp_congr ← Iff.imp\n#align iff.imp Iff.imp\n\n@[simp] theorem eq_true_eq_id : Eq True = id := by\n  funext _; simp only [true_iff, id.def, eq_iff_iff]\n#align eq_true_eq_id eq_true_eq_id\n\n#align imp_and_distrib imp_and\n#align imp_iff_right imp_iff_rightₓ -- reorder implicits\n#align imp_iff_not imp_iff_notₓ -- reorder implicits\n\n@[simp] theorem imp_iff_right_iff : (a → b ↔ b) ↔ a ∨ b := Decidable.imp_iff_right_iff\n#align imp_iff_right_iff imp_iff_right_iff\n\n@[simp] theorem and_or_imp : a ∧ b ∨ (a → c) ↔ a → b ∨ c := Decidable.and_or_imp\n#align and_or_imp and_or_imp\n\n/-- Provide modus tollens (`mt`) as dot notation for implications. -/\nprotected theorem Function.mt : (a → b) → ¬b → ¬a := mt\n#align function.mt Function.mt\n\n/-! ### Declarations about `not` -/\n\nalias Decidable.em ← dec_em\n#align dec_em dec_em\n\ntheorem dec_em' (p : Prop) [Decidable p] : ¬p ∨ p := (dec_em p).symm\n#align dec_em' dec_em'\n\nalias Classical.em ← em\n#align em em\n\ntheorem em' (p : Prop) : ¬p ∨ p := (em p).symm\n#align em' em'\n\ntheorem or_not {p : Prop} : p ∨ ¬p := em _\n#align or_not or_not\n\ntheorem Decidable.eq_or_ne (x y : α) [Decidable (x = y)] : x = y ∨ x ≠ y := dec_em <| x = y\n#align decidable.eq_or_ne Decidable.eq_or_ne\n\ntheorem Decidable.ne_or_eq (x y : α) [Decidable (x = y)] : x ≠ y ∨ x = y := dec_em' <| x = y\n#align decidable.ne_or_eq Decidable.ne_or_eq\n\ntheorem eq_or_ne (x y : α) : x = y ∨ x ≠ y := em <| x = y\n#align eq_or_ne eq_or_ne\n\ntheorem ne_or_eq (x y : α) : x ≠ y ∨ x = y := em' <| x = y\n#align ne_or_eq ne_or_eq\n\ntheorem by_contradiction : (¬p → False) → p := Decidable.by_contradiction\n#align classical.by_contradiction by_contradiction\n#align by_contradiction by_contradiction\n\ntheorem by_cases {q : Prop} (hpq : p → q) (hnpq : ¬p → q) : q :=\nif hp : p then hpq hp else hnpq hp\n#align classical.by_cases by_cases\n\nalias by_contradiction ← by_contra\n#align by_contra by_contra\n\nlibrary_note \"decidable namespace\"/--\nIn most of mathlib, we use the law of excluded middle (LEM) and the axiom of choice (AC) freely.\nThe `Decidable` namespace contains versions of lemmas from the root namespace that explicitly\nattempt to avoid the axiom of choice, usually by adding decidability assumptions on the inputs.\n\nYou can check if a lemma uses the axiom of choice by using `#print axioms foo` and seeing if\n`Classical.choice` appears in the list.\n-/\n\nlibrary_note \"decidable arguments\"/--\nAs mathlib is primarily classical,\nif the type signature of a `def` or `lemma` does not require any `Decidable` instances to state,\nit is preferable not to introduce any `Decidable` instances that are needed in the proof\nas arguments, but rather to use the `classical` tactic as needed.\n\nIn the other direction, when `Decidable` instances do appear in the type signature,\nit is better to use explicitly introduced ones rather than allowing Lean to automatically infer\nclassical ones, as these may cause instance mismatch errors later.\n-/\n\nexport Classical (not_not)\nattribute [simp] not_not\n#align not_not Classical.not_not\n\ntheorem of_not_not : ¬¬a → a := by_contra\n#align of_not_not of_not_not\n\ntheorem not_ne_iff : ¬a ≠ b ↔ a = b := not_not\n#align not_ne_iff not_ne_iff\n\ntheorem of_not_imp {a b : Prop} : ¬(a → b) → a := Decidable.of_not_imp\n#align of_not_imp of_not_imp\n\nalias Decidable.not_imp_symm ← Not.decidable_imp_symm\n#align not.decidable_imp_symm Not.decidable_imp_symm\n\ntheorem Not.imp_symm : (¬a → b) → ¬b → a := Not.decidable_imp_symm\n#align not.imp_symm Not.imp_symm\n\ntheorem not_imp_comm : ¬a → b ↔ ¬b → a := Decidable.not_imp_comm\n#align not_imp_comm not_imp_comm\n\n@[simp] theorem not_imp_self : ¬a → a ↔ a := Decidable.not_imp_self\n#align not_imp_self not_imp_self\n\ntheorem Imp.swap : a → b → c ↔ b → a → c := ⟨Function.swap, Function.swap⟩\n#align imp.swap Imp.swap\n\nalias not_congr ← Iff.not\ntheorem Iff.not_left (h : a ↔ ¬b) : ¬a ↔ b := h.not.trans not_not\ntheorem Iff.not_right (h : ¬a ↔ b) : a ↔ ¬b := not_not.symm.trans h.not\n#align iff.not_right Iff.not_right\n#align iff.not_left Iff.not_left\n#align iff.not Iff.not\n\n/-! ### Declarations about `xor` -/\n\n@[simp] theorem xor_true : Xor' True = Not := by simp [Xor']\n#align xor_true xor_true\n\n@[simp] theorem xor_false : Xor' False = id := by ext; simp [Xor']\n#align xor_false xor_false\n\ntheorem xor_comm (a b) : Xor' a b = Xor' b a := by simp [Xor', and_comm, or_comm]\n#align xor_comm xor_comm\n\ninstance : IsCommutative Prop Xor' := ⟨xor_comm⟩\n\n@[simp] theorem xor_self (a : Prop) : Xor' a a = False := by simp [Xor']\n@[simp] theorem xor_not_left : Xor' (¬a) b ↔ (a ↔ b) := by by_cases a <;> simp [*]\n@[simp] theorem xor_not_right : Xor' a (¬b) ↔ (a ↔ b) := by by_cases a <;> simp [*]\ntheorem xor_not_not : Xor' (¬a) (¬b) ↔ Xor' a b := by simp [Xor', or_comm, and_comm]\nprotected theorem Xor'.or (h : Xor' a b) : a ∨ b := h.imp And.left And.left\n#align xor.or Xor'.or\n#align xor_not_not xor_not_not\n#align xor_not_right xor_not_right\n#align xor_not_left xor_not_left\n#align xor_self xor_self\n\n/-! ### Declarations about `and` -/\n\nalias and_congr ← Iff.and\n#align and_congr_left and_congr_leftₓ -- reorder implicits\n#align and_congr_right' and_congr_right'ₓ -- reorder implicits\n#align and.right_comm and_right_comm\n#align and_and_distrib_left and_and_left\n#align and_and_distrib_right and_and_right\nalias and_rotate ↔ And.rotate _\n#align and.congr_right_iff and_congr_right_iff\n#align and.congr_left_iff and_congr_left_iffₓ -- reorder implicits\n#align and.rotate And.rotate\n#align iff.and Iff.and\n\ntheorem and_symm_right (a b : α) (p : Prop) : p ∧ a = b ↔ p ∧ b = a := by simp [eq_comm]\ntheorem and_symm_left (a b : α) (p : Prop) : a = b ∧ p ↔ b = a ∧ p := by simp [eq_comm]\n\n/-! ### Declarations about `or` -/\n\nalias or_congr ← Iff.or\n#align or_congr_left' or_congr_left\n#align or_congr_right' or_congr_rightₓ -- reorder implicits\n#align or.right_comm or_right_comm\nalias or_rotate ↔ Or.rotate _\n#align or.rotate Or.rotate\n#align iff.or Iff.or\n\n@[deprecated Or.imp]\ntheorem or_of_or_of_imp_of_imp (h₁ : a ∨ b) (h₂ : a → c) (h₃ : b → d) : c ∨ d := Or.imp h₂ h₃ h₁\n#align or_of_or_of_imp_of_imp or_of_or_of_imp_of_imp\n\n@[deprecated Or.imp_left]\ntheorem or_of_or_of_imp_left (h₁ : a ∨ c) (h : a → b) : b ∨ c := Or.imp_left h h₁\n#align or_of_or_of_imp_left or_of_or_of_imp_left\n\n@[deprecated Or.imp_right]\ntheorem or_of_or_of_imp_right (h₁ : c ∨ a) (h : a → b) : c ∨ b := Or.imp_right h h₁\n#align or_of_or_of_imp_right or_of_or_of_imp_right\n\ntheorem Or.elim3 {d : Prop} (h : a ∨ b ∨ c) (ha : a → d) (hb : b → d) (hc : c → d) : d :=\n  Or.elim h ha fun h₂ ↦ Or.elim h₂ hb hc\n#align or.elim3 Or.elim3\n\ntheorem Or.imp3 (had : a → d) (hbe : b → e) (hcf : c → f) : a ∨ b ∨ c → d ∨ e ∨ f :=\n  Or.imp had <| Or.imp hbe hcf\n#align or.imp3 Or.imp3\n\n#align or_imp_distrib or_imp\n\ntheorem or_iff_not_imp_left : a ∨ b ↔ ¬a → b := Decidable.or_iff_not_imp_left\n#align or_iff_not_imp_left or_iff_not_imp_left\n\ntheorem or_iff_not_imp_right : a ∨ b ↔ ¬b → a := Decidable.or_iff_not_imp_right\n#align or_iff_not_imp_right or_iff_not_imp_right\n\ntheorem not_or_of_imp : (a → b) → ¬a ∨ b := Decidable.not_or_of_imp\n#align not_or_of_imp not_or_of_imp\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.or_not_of_imp [Decidable a] (h : a → b) : b ∨ ¬a :=\n  dite _ (Or.inl ∘ h) Or.inr\n#align decidable.or_not_of_imp Decidable.or_not_of_imp\n\ntheorem or_not_of_imp : (a → b) → b ∨ ¬a := Decidable.or_not_of_imp\n#align or_not_of_imp or_not_of_imp\n\ntheorem imp_iff_not_or : a → b ↔ ¬a ∨ b := Decidable.imp_iff_not_or\n#align imp_iff_not_or imp_iff_not_or\n\ntheorem imp_iff_or_not : b → a ↔ a ∨ ¬b := Decidable.imp_iff_or_not\n#align imp_iff_or_not imp_iff_or_not\n\ntheorem not_imp_not : ¬a → ¬b ↔ b → a := Decidable.not_imp_not\n#align not_imp_not not_imp_not\n\n/-- Provide the reverse of modus tollens (`mt`) as dot notation for implications. -/\nprotected theorem Function.mtr : (¬a → ¬b) → b → a := not_imp_not.mp\n#align function.mtr Function.mtr\n\n#align decidable.or_congr_left Decidable.or_congr_left'\n#align decidable.or_congr_right Decidable.or_congr_right'\n#align decidable.or_iff_not_imp_right Decidable.or_iff_not_imp_rightₓ -- reorder implicits\n#align decidable.imp_iff_or_not Decidable.imp_iff_or_notₓ -- reorder implicits\n\ntheorem or_congr_left' (h : ¬c → (a ↔ b)) : a ∨ c ↔ b ∨ c := Decidable.or_congr_left' h\n#align or_congr_left or_congr_left'\n\ntheorem or_congr_right' (h : ¬a → (b ↔ c)) : a ∨ b ↔ a ∨ c := Decidable.or_congr_right' h\n#align or_congr_right or_congr_right'ₓ -- reorder implicits\n\n#align or_iff_left or_iff_leftₓ -- reorder implicits\n\n/-! ### Declarations about distributivity -/\n\n#align and_or_distrib_left and_or_left\n#align or_and_distrib_right or_and_right\n#align or_and_distrib_left or_and_left\n#align and_or_distrib_right and_or_right\n\n/-! Declarations about `iff` -/\n\nalias iff_congr ← Iff.iff\n#align iff.iff Iff.iff\n\n-- @[simp] -- FIXME simp ignores proof rewrites\ntheorem iff_mpr_iff_true_intro (h : P) : Iff.mpr (iff_true_intro h) True.intro = h := rfl\n#align iff_mpr_iff_true_intro iff_mpr_iff_true_intro\n\n#align decidable.imp_or_distrib Decidable.imp_or\n\ntheorem imp_or {a b c : Prop} : a → b ∨ c ↔ (a → b) ∨ (a → c) := Decidable.imp_or\n#align imp_or_distrib imp_or\n\n#align decidable.imp_or_distrib' Decidable.imp_or'\n\ntheorem imp_or' : a → b ∨ c ↔ (a → b) ∨ (a → c) := Decidable.imp_or'\n#align imp_or_distrib' imp_or'ₓ -- universes\n\ntheorem not_imp : ¬(a → b) ↔ a ∧ ¬b := Decidable.not_imp\n#align not_imp not_imp\n\ntheorem peirce (a b : Prop) : ((a → b) → a) → a := Decidable.peirce _ _\n#align peirce peirce\n\ntheorem not_iff_not : (¬a ↔ ¬b) ↔ (a ↔ b) := Decidable.not_iff_not\n#align not_iff_not not_iff_not\n\ntheorem not_iff_comm : (¬a ↔ b) ↔ (¬b ↔ a) := Decidable.not_iff_comm\n#align not_iff_comm not_iff_comm\n\ntheorem not_iff : ¬(a ↔ b) ↔ (¬a ↔ b) := Decidable.not_iff\n#align not_iff not_iff\n\ntheorem iff_not_comm : (a ↔ ¬b) ↔ (b ↔ ¬a) := Decidable.iff_not_comm\n#align iff_not_comm iff_not_comm\n\ntheorem iff_iff_and_or_not_and_not : (a ↔ b) ↔ a ∧ b ∨ ¬a ∧ ¬b :=\n  Decidable.iff_iff_and_or_not_and_not\n#align iff_iff_and_or_not_and_not iff_iff_and_or_not_and_not\n\ntheorem iff_iff_not_or_and_or_not : (a ↔ b) ↔ (¬a ∨ b) ∧ (a ∨ ¬b) :=\n  Decidable.iff_iff_not_or_and_or_not\n#align iff_iff_not_or_and_or_not iff_iff_not_or_and_or_not\n\ntheorem not_and_not_right : ¬(a ∧ ¬b) ↔ a → b := Decidable.not_and_not_right\n#align not_and_not_right not_and_not_right\n\n#align decidable_of_iff decidable_of_iff\n#align decidable_of_iff' decidable_of_iff'\n#align decidable_of_bool decidable_of_bool\n\n/-! ### De Morgan's laws -/\n\n#align decidable.not_and_distrib Decidable.not_and\n#align decidable.not_and_distrib' Decidable.not_and'\n\n/-- One of de Morgan's laws: the negation of a conjunction is logically equivalent to the\ndisjunction of the negations. -/\ntheorem not_and_or : ¬(a ∧ b) ↔ ¬a ∨ ¬b := Decidable.not_and\n#align not_and_distrib not_and_or\n\n#align not_or_distrib not_or\n\ntheorem or_iff_not_and_not : a ∨ b ↔ ¬(¬a ∧ ¬b) := Decidable.or_iff_not_and_not\n#align or_iff_not_and_not or_iff_not_and_not\n\ntheorem and_iff_not_or_not : a ∧ b ↔ ¬(¬a ∨ ¬b) := Decidable.and_iff_not_or_not\n#align and_iff_not_or_not and_iff_not_or_not\n\n@[simp] theorem not_xor (P Q : Prop) : ¬Xor' P Q ↔ (P ↔ Q) := by\n  simp only [not_and, Xor', not_or, not_not, ← iff_iff_implies_and_implies]\n#align not_xor not_xor\n\ntheorem xor_iff_not_iff (P Q : Prop) : Xor' P Q ↔ ¬ (P ↔ Q) := (not_xor P Q).not_right\ntheorem xor_iff_iff_not : Xor' a b ↔ (a ↔ ¬b) := by simp only [← @xor_not_right a, not_not]\ntheorem xor_iff_not_iff' : Xor' a b ↔ (¬a ↔ b) := by simp only [← @xor_not_left _ b, not_not]\n#align xor_iff_not_iff' xor_iff_not_iff'\n#align xor_iff_iff_not xor_iff_iff_not\n#align xor_iff_not_iff xor_iff_not_iff\n\nend Propositional\n\n/-! ### Declarations about equality -/\n\nalias ne_of_mem_of_not_mem ← Membership.mem.ne_of_not_mem\nalias ne_of_mem_of_not_mem' ← Membership.mem.ne_of_not_mem'\n\n#align has_mem.mem.ne_of_not_mem Membership.mem.ne_of_not_mem\n#align has_mem.mem.ne_of_not_mem' Membership.mem.ne_of_not_mem'\n\nsection Equality\n\n-- todo: change name\ntheorem ball_cond_comm {α} {s : α → Prop} {p : α → α → Prop} :\n    (∀ a, s a → ∀ b, s b → p a b) ↔ ∀ a b, s a → s b → p a b :=\n  ⟨fun h a b ha hb ↦ h a ha b hb, fun h a ha b hb ↦ h a b ha hb⟩\n#align ball_cond_comm ball_cond_comm\n\ntheorem ball_mem_comm {α β} [Membership α β] {s : β} {p : α → α → Prop} :\n    (∀ a (_ : a ∈ s) b (_ : b ∈ s), p a b) ↔ ∀ a b, a ∈ s → b ∈ s → p a b :=\n  ball_cond_comm\n#align ball_mem_comm ball_mem_comm\n\ntheorem ne_of_apply_ne {α β : Sort _} (f : α → β) {x y : α} (h : f x ≠ f y) : x ≠ y :=\n  fun w : x = y ↦ h (congr_arg f w)\n#align ne_of_apply_ne ne_of_apply_ne\n\ntheorem eq_equivalence : Equivalence (@Eq α) :=\n  ⟨Eq.refl, @Eq.symm _, @Eq.trans _⟩\n#align eq_equivalence eq_equivalence\n\n@[simp] theorem eq_mp_eq_cast (h : α = β) : Eq.mp h = cast h := rfl\n#align eq_mp_eq_cast eq_mp_eq_cast\n\n@[simp] theorem eq_mpr_eq_cast (h : α = β) : Eq.mpr h = cast h.symm := rfl\n#align eq_mpr_eq_cast eq_mpr_eq_cast\n\n@[simp] theorem cast_cast : ∀ (ha : α = β) (hb : β = γ) (a : α),\n    cast hb (cast ha a) = cast (ha.trans hb) a\n  | rfl, rfl, _ => rfl\n#align cast_cast cast_cast\n\n-- @[simp] -- FIXME simp ignores proof rewrites\ntheorem congr_refl_left (f : α → β) {a b : α} (h : a = b) :\n    congr (Eq.refl f) h = congr_arg f h := rfl\n#align congr_refl_left congr_refl_left\n\n-- @[simp] -- FIXME simp ignores proof rewrites\ntheorem congr_refl_right {f g : α → β} (h : f = g) (a : α) :\n    congr h (Eq.refl a) = congr_fun h a := rfl\n#align congr_refl_right congr_refl_right\n\n-- @[simp] -- FIXME simp ignores proof rewrites\ntheorem congr_arg_refl (f : α → β) (a : α) : congr_arg f (Eq.refl a) = Eq.refl (f a) := rfl\n#align congr_arg_refl congr_arg_refl\n\n-- @[simp] -- FIXME simp ignores proof rewrites\ntheorem congr_fun_rfl (f : α → β) (a : α) : congr_fun (Eq.refl f) a = Eq.refl (f a) := rfl\n#align congr_fun_rfl congr_fun_rfl\n\n-- @[simp] -- FIXME simp ignores proof rewrites\ntheorem congr_fun_congr_arg (f : α → β → γ) {a a' : α} (p : a = a') (b : β) :\n    congr_fun (congr_arg f p) b = congr_arg (fun a ↦ f a b) p := rfl\n#align congr_fun_congr_arg congr_fun_congr_arg\n\ntheorem heq_of_cast_eq : ∀ (e : α = β) (_ : cast e a = a'), HEq a a'\n  | rfl, h => Eq.recOn h (HEq.refl _)\n#align heq_of_cast_eq heq_of_cast_eq\n\ntheorem cast_eq_iff_heq : cast e a = a' ↔ HEq a a' :=\n  ⟨heq_of_cast_eq _, fun h ↦ by cases h; rfl⟩\n#align cast_eq_iff_heq cast_eq_iff_heq\n\n--Porting note: new theorem. More general version of `eqRec_heq`\ntheorem eqRec_heq' {α : Sort u_1} {a' : α} {motive : (a : α) → a' = a → Sort u}\n    (p : motive a' (rfl : a' = a')) {a : α} (t : a' = a) :\n    HEq (@Eq.rec α a' motive p a t) p :=\n  by subst t; rfl\n\ntheorem rec_heq_of_heq {C : α → Sort _} {x : C a} {y : β} (e : a = b) (h : HEq x y) :\n    HEq (e ▸ x) y := by subst e; exact h\n#align rec_heq_of_heq rec_heq_of_heq\n\ntheorem rec_heq_iff_heq {C : α → Sort _} {x : C a} {y : β} {e : a = b} :\n    HEq (e ▸ x) y ↔ HEq x y := by subst e; rfl\n#align rec_heq_iff_heq rec_heq_iff_heq\n\ntheorem heq_rec_iff_heq {C : α → Sort _} {x : β} {y : C a} {e : a = b} :\n    HEq x (e ▸ y) ↔ HEq x y := by subst e; rfl\n#align heq_rec_iff_heq heq_rec_iff_heq\n\nprotected theorem Eq.congr (h₁ : x₁ = y₁) (h₂ : x₂ = y₂) : x₁ = x₂ ↔ y₁ = y₂ := by\n  subst h₁; subst h₂; rfl\n#align eq.congr Eq.congr\n\ntheorem Eq.congr_left {x y z : α} (h : x = y) : x = z ↔ y = z := by rw [h]\n#align eq.congr_left Eq.congr_left\n\ntheorem Eq.congr_right {x y z : α} (h : x = y) : z = x ↔ z = y := by rw [h]\n#align eq.congr_right Eq.congr_right\n\nalias congrArg₂ ← congr_arg₂\n#align congr_arg2 congr_arg₂\n\nvariable {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _}\n\ntheorem congr_fun₂ {f g : ∀ a b, γ a b} (h : f = g) (a : α) (b : β a) : f a b = g a b :=\n  congr_fun (congr_fun h _) _\n#align congr_fun₂ congr_fun₂\n\ntheorem congr_fun₃ {f g : ∀ a b c, δ a b c} (h : f = g) (a : α) (b : β a) (c : γ a b) :\n    f a b c = g a b c :=\n  congr_fun₂ (congr_fun h _) _ _\n#align congr_fun₃ congr_fun₃\n\ntheorem funext₂ {f g : ∀ a b, γ a b} (h : ∀ a b, f a b = g a b) : f = g :=\n  funext fun _ ↦ funext <| h _\n#align funext₂ funext₂\n\ntheorem funext₃ {f g : ∀ a b c, δ a b c} (h : ∀ a b c, f a b c = g a b c) : f = g :=\n  funext fun _ ↦ funext₂ <| h _\n#align funext₃ funext₃\n\nend Equality\n\n/-! ### Declarations about quantifiers -/\n\n\nsection Quantifiers\nsection Dependent\n\nvariable {β : α → Sort _} {γ : ∀ a, β a → Sort _} {δ : ∀ a b, γ a b → Sort _}\n  {ε : ∀ a b c, δ a b c → Sort _}\n\ntheorem pi_congr {β' : α → Sort _} (h : ∀ a, β a = β' a) : (∀ a, β a) = ∀ a, β' a :=\n  (funext h : β = β') ▸ rfl\n#align pi_congr pi_congr\n\n-- Porting note: some higher order lemmas such as `forall₂_congr` and `exists₂_congr`\n-- were moved to `Std4`\n\ntheorem forall₂_imp {p q : ∀ a, β a → Prop} (h : ∀ a b, p a b → q a b) :\n    (∀ a b, p a b) → ∀ a b, q a b :=\n  forall_imp fun i ↦ forall_imp <| h i\n#align forall₂_imp forall₂_imp\n\ntheorem forall₃_imp {p q : ∀ a b, γ a b → Prop} (h : ∀ a b c, p a b c → q a b c) :\n    (∀ a b c, p a b c) → ∀ a b c, q a b c :=\n  forall_imp fun a ↦ forall₂_imp <| h a\n#align forall₃_imp forall₃_imp\n\ntheorem Exists₂.imp {p q : ∀ a, β a → Prop} (h : ∀ a b, p a b → q a b) :\n    (∃ a b, p a b) → ∃ a b, q a b :=\n  Exists.imp fun a ↦ Exists.imp <| h a\n#align Exists₂.imp Exists₂.imp\n\ntheorem Exists₃.imp {p q : ∀ a b, γ a b → Prop} (h : ∀ a b c, p a b c → q a b c) :\n    (∃ a b c, p a b c) → ∃ a b c, q a b c :=\n  Exists.imp fun a ↦ Exists₂.imp <| h a\n#align Exists₃.imp Exists₃.imp\n\nend Dependent\n\nvariable {κ : ι → Sort _} {p q : α → Prop}\n\n#align exists_imp_exists' Exists.imp'\n\ntheorem forall_swap {p : α → β → Prop} : (∀ x y, p x y) ↔ ∀ y x, p x y := ⟨swap, swap⟩\n#align forall_swap forall_swap\n\ntheorem forall₂_swap {κ₁ : ι₁ → Sort _} {κ₂ : ι₂ → Sort _} {p : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Prop} :\n    (∀ i₁ j₁ i₂ j₂, p i₁ j₁ i₂ j₂) ↔ ∀ i₂ j₂ i₁ j₁, p i₁ j₁ i₂ j₂ := ⟨swap₂, swap₂⟩\n#align forall₂_swap forall₂_swap\n\n/-- We intentionally restrict the type of `α` in this lemma so that this is a safer to use in simp\nthan `forall_swap`. -/\ntheorem imp_forall_iff {α : Type _} {p : Prop} {q : α → Prop} : (p → ∀ x, q x) ↔ ∀ x, p → q x :=\n  forall_swap\n#align imp_forall_iff imp_forall_iff\n\ntheorem exists_swap {p : α → β → Prop} : (∃ x y, p x y) ↔ ∃ y x, p x y :=\n  ⟨fun ⟨x, y, h⟩ ↦ ⟨y, x, h⟩, fun ⟨y, x, h⟩ ↦ ⟨x, y, h⟩⟩\n#align exists_swap exists_swap\n\n#align forall_exists_index forall_exists_index\n\n#align exists_imp_distrib exists_imp\nalias exists_imp ↔ _ not_exists_of_forall_not\n#align not_exists_of_forall_not not_exists_of_forall_not\n\n#align Exists.some Exists.choose\n#align Exists.some_spec Exists.choose_spec\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.not_forall {p : α → Prop} [Decidable (∃ x, ¬p x)]\n    [∀ x, Decidable (p x)] : (¬∀ x, p x) ↔ ∃ x, ¬p x :=\n  ⟨Not.decidable_imp_symm fun nx x ↦ nx.decidable_imp_symm fun h ↦ ⟨x, h⟩,\n   not_forall_of_exists_not⟩\n#align decidable.not_forall Decidable.not_forall\n\n@[simp]\ntheorem not_forall {p : α → Prop} : (¬∀ x, p x) ↔ ∃ x, ¬p x :=\n  Decidable.not_forall\n#align not_forall not_forall\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.not_forall_not [Decidable (∃ x, p x)] : (¬∀ x, ¬p x) ↔ ∃ x, p x :=\n  (@Decidable.not_iff_comm _ _ _ (decidable_of_iff (¬∃ x, p x) not_exists)).1 not_exists\n#align decidable.not_forall_not Decidable.not_forall_not\n\ntheorem not_forall_not : (¬∀ x, ¬p x) ↔ ∃ x, p x := Decidable.not_forall_not\n#align not_forall_not not_forall_not\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.not_exists_not [∀ x, Decidable (p x)] : (¬∃ x, ¬p x) ↔ ∀ x, p x := by\n  simp only [not_exists, Decidable.not_not]\n#align decidable.not_exists_not Decidable.not_exists_not\n\ntheorem not_exists_not : (¬∃ x, ¬p x) ↔ ∀ x, p x := Decidable.not_exists_not\n#align not_exists_not not_exists_not\n\ntheorem forall_imp_iff_exists_imp [ha : Nonempty α] : (∀ x, p x) → b ↔ ∃ x, p x → b := by\n  let ⟨a⟩ := ha\n  refine ⟨fun h ↦ not_forall_not.1 fun h' ↦ ?_, fun ⟨x, hx⟩ h ↦ hx (h x)⟩\n  exact if hb : b then h' a fun _ ↦ hb else hb <| h fun x ↦ (not_imp.1 (h' x)).1\n#align forall_imp_iff_exists_imp forall_imp_iff_exists_imp\n\ntheorem forall_true_iff : (α → True) ↔ True := imp_true_iff _\n#align forall_true_iff forall_true_iff\n\n-- Unfortunately this causes simp to loop sometimes, so we\n-- add the 2 and 3 cases as simp lemmas instead\ntheorem forall_true_iff' (h : ∀ a, p a ↔ True) : (∀ a, p a) ↔ True :=\n  iff_true_intro fun _ ↦ of_iff_true (h _)\n#align forall_true_iff' forall_true_iff'\n\n-- This is not marked `@[simp]` because `implies_true : (α → True) = True` works\ntheorem forall₂_true_iff {β : α → Sort _} : (∀ a, β a → True) ↔ True := by simp\n#align forall_2_true_iff forall₂_true_iff\n\n-- This is not marked `@[simp]` because `implies_true : (α → True) = True` works\ntheorem forall₃_true_iff {β : α → Sort _} {γ : ∀ a, β a → Sort _} :\n    (∀ (a) (b : β a), γ a b → True) ↔ True := by simp\n#align forall_3_true_iff forall₃_true_iff\n\n@[simp] theorem exists_unique_iff_exists [Subsingleton α] {p : α → Prop} :\n    (∃! x, p x) ↔ ∃ x, p x :=\n  ⟨fun h ↦ h.exists, Exists.imp fun x hx ↦ ⟨hx, fun y _ ↦ Subsingleton.elim y x⟩⟩\n#align exists_unique_iff_exists exists_unique_iff_exists\n\n-- forall_forall_const is no longer needed\n\n@[simp] theorem exists_const (α) [i : Nonempty α] : (∃ _ : α, b) ↔ b :=\n  ⟨fun ⟨_, h⟩ ↦ h, i.elim Exists.intro⟩\n#align exists_const exists_const\n\ntheorem exists_unique_const (α) [i : Nonempty α] [Subsingleton α] :\n    (∃! _ : α, b) ↔ b := by simp\n#align exists_unique_const exists_unique_const\n\n#align forall_and_distrib forall_and\n#align exists_or_distrib exists_or\n\n#align exists_and_distrib_left exists_and_left\n#align exists_and_distrib_right exists_and_right\n\ntheorem Decidable.and_forall_ne [DecidableEq α] (a : α) {p : α → Prop} :\n    (p a ∧ ∀ b, b ≠ a → p b) ↔ ∀ b, p b := by\n  simp only [← @forall_eq _ p a, ← forall_and, ← or_imp, Decidable.em, forall_const]\n#align decidable.and_forall_ne Decidable.and_forall_ne\n\ntheorem and_forall_ne (a : α) : (p a ∧ ∀ b, b ≠ a → p b) ↔ ∀ b, p b :=\n  Decidable.and_forall_ne a\n#align and_forall_ne and_forall_ne\n\ntheorem Ne.ne_or_ne {x y : α} (z : α) (h : x ≠ y) : x ≠ z ∨ y ≠ z :=\n  not_and_or.1 <| mt (and_imp.2 (· ▸ ·)) h.symm\n#align ne.ne_or_ne Ne.ne_or_ne\n\n@[simp] theorem exists_unique_eq {a' : α} : ∃! a, a = a' := by\n  simp only [eq_comm, ExistsUnique, and_self, forall_eq', exists_eq']\n#align exists_unique_eq exists_unique_eq\n\n@[simp] theorem exists_unique_eq' {a' : α} : ∃! a, a' = a := by\n  simp only [ExistsUnique, and_self, forall_eq', exists_eq']\n#align exists_unique_eq' exists_unique_eq'\n\n-- @[simp] -- FIXME simp does not apply this lemma for some reason\ntheorem exists_apply_eq_apply' (f : α → β) (a' : α) : ∃ a, f a' = f a := ⟨a', rfl⟩\n#align exists_apply_eq_apply' exists_apply_eq_apply'\n\n-- porting note: an alternative workaround theorem:\ntheorem exists_apply_eq (a : α) (b : β) : ∃ f : α → β, f a = b := ⟨fun _ ↦ b, rfl⟩\n\n@[simp] theorem exists_exists_and_eq_and {f : α → β} {p : α → Prop} {q : β → Prop} :\n    (∃ b, (∃ a, p a ∧ f a = b) ∧ q b) ↔ ∃ a, p a ∧ q (f a) :=\n  ⟨fun ⟨_, ⟨a, ha, hab⟩, hb⟩ ↦ ⟨a, ha, hab.symm ▸ hb⟩, fun ⟨a, hp, hq⟩ ↦ ⟨f a, ⟨a, hp, rfl⟩, hq⟩⟩\n#align exists_exists_and_eq_and exists_exists_and_eq_and\n\n@[simp] theorem exists_exists_eq_and {f : α → β} {p : β → Prop} :\n    (∃ b, (∃ a, f a = b) ∧ p b) ↔ ∃ a, p (f a) :=\n  ⟨fun ⟨_, ⟨a, ha⟩, hb⟩ ↦ ⟨a, ha.symm ▸ hb⟩, fun ⟨a, ha⟩ ↦ ⟨f a, ⟨a, rfl⟩, ha⟩⟩\n#align exists_exists_eq_and exists_exists_eq_and\n\n@[simp] theorem exists_or_eq_left (y : α) (p : α → Prop) : ∃ x : α, x = y ∨ p x := ⟨y, .inl rfl⟩\n#align exists_or_eq_left exists_or_eq_left\n\n@[simp] theorem exists_or_eq_right (y : α) (p : α → Prop) : ∃ x : α, p x ∨ x = y := ⟨y, .inr rfl⟩\n#align exists_or_eq_right exists_or_eq_right\n\n@[simp] theorem exists_or_eq_left' (y : α) (p : α → Prop) : ∃ x : α, y = x ∨ p x := ⟨y, .inl rfl⟩\n#align exists_or_eq_left' exists_or_eq_left'\n\n@[simp] theorem exists_or_eq_right' (y : α) (p : α → Prop) : ∃ x : α, p x ∨ y = x := ⟨y, .inr rfl⟩\n#align exists_or_eq_right' exists_or_eq_right'\n\ntheorem forall_apply_eq_imp_iff {f : α → β} {p : β → Prop} :\n    (∀ a b, f a = b → p b) ↔ ∀ a, p (f a) := by simp\n#align forall_apply_eq_imp_iff forall_apply_eq_imp_iff\n\n@[simp] theorem forall_apply_eq_imp_iff' {f : α → β} {p : β → Prop} :\n    (∀ b a, f a = b → p b) ↔ ∀ a, p (f a) := by simp [forall_swap]\n#align forall_apply_eq_imp_iff' forall_apply_eq_imp_iff'\n\ntheorem forall_eq_apply_imp_iff {f : α → β} {p : β → Prop} :\n    (∀ a b, b = f a → p b) ↔ ∀ a, p (f a) := by simp\n#align forall_eq_apply_imp_iff forall_eq_apply_imp_iff\n\n@[simp] theorem forall_eq_apply_imp_iff' {f : α → β} {p : β → Prop} :\n    (∀ b a, b = f a → p b) ↔ ∀ a, p (f a) := by simp [forall_swap]\n#align forall_eq_apply_imp_iff' forall_eq_apply_imp_iff'\n\n@[simp] theorem forall_apply_eq_imp_iff₂ {f : α → β} {p : α → Prop} {q : β → Prop} :\n    (∀ b a, p a → f a = b → q b) ↔ ∀ a, p a → q (f a) :=\n  ⟨fun h a ha ↦ h (f a) a ha rfl, fun h _ a ha hb ↦ hb ▸ h a ha⟩\n#align forall_apply_eq_imp_iff₂ forall_apply_eq_imp_iff₂\n\n@[simp] theorem exists_eq_right' {a' : α} : (∃ a, p a ∧ a' = a) ↔ p a' := by simp [@eq_comm _ a']\n#align exists_eq_right' exists_eq_right'\n\ntheorem exists_comm {p : α → β → Prop} : (∃ a b, p a b) ↔ ∃ b a, p a b :=\n  ⟨fun ⟨a, b, h⟩ ↦ ⟨b, a, h⟩, fun ⟨b, a, h⟩ ↦ ⟨a, b, h⟩⟩\n#align exists_comm exists_comm\n\ntheorem exists₂_comm {κ₁ : ι₁ → Sort _} {κ₂ : ι₂ → Sort _} {p : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Prop} :\n    (∃ i₁ j₁ i₂ j₂, p i₁ j₁ i₂ j₂) ↔ ∃ i₂ j₂ i₁ j₁, p i₁ j₁ i₂ j₂ := by\n  simp only [@exists_comm (κ₁ _), @exists_comm ι₁]\n#align exists₂_comm exists₂_comm\n\ntheorem And.exists {p q : Prop} {f : p ∧ q → Prop} : (∃ h, f h) ↔ ∃ hp hq, f ⟨hp, hq⟩ :=\n  ⟨fun ⟨h, H⟩ ↦ ⟨h.1, h.2, H⟩, fun ⟨hp, hq, H⟩ ↦ ⟨⟨hp, hq⟩, H⟩⟩\n#align and.exists And.exists\n\ntheorem forall_or_of_or_forall (h : b ∨ ∀ x, p x) (x) : b ∨ p x := h.imp_right fun h₂ ↦ h₂ x\n#align forall_or_of_or_forall forall_or_of_or_forall\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.forall_or_left {q : Prop} {p : α → Prop} [Decidable q] :\n    (∀ x, q ∨ p x) ↔ q ∨ ∀ x, p x :=\n  ⟨fun h ↦ if hq : q then Or.inl hq else\n    Or.inr fun x ↦ (h x).resolve_left hq, forall_or_of_or_forall⟩\n#align decidable.forall_or_distrib_left Decidable.forall_or_left\n\ntheorem forall_or_left {q} {p : α → Prop} : (∀ x, q ∨ p x) ↔ q ∨ ∀ x, p x :=\n  Decidable.forall_or_left\n#align forall_or_distrib_left forall_or_left\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.forall_or_right {q} {p : α → Prop} [Decidable q] :\n    (∀ x, p x ∨ q) ↔ (∀ x, p x) ∨ q := by simp [or_comm, Decidable.forall_or_left]\n#align decidable.forall_or_distrib_right Decidable.forall_or_right\n\ntheorem forall_or_right {q} {p : α → Prop} : (∀ x, p x ∨ q) ↔ (∀ x, p x) ∨ q :=\n  Decidable.forall_or_right\n#align forall_or_distrib_right forall_or_right\n\ntheorem exists_unique_prop {p q : Prop} : (∃! _ : p, q) ↔ p ∧ q := by simp\n#align exists_unique_prop exists_unique_prop\n\n@[simp] theorem exists_unique_false : ¬∃! _ : α, False := fun ⟨_, h, _⟩ ↦ h\n#align exists_unique_false exists_unique_false\n\ntheorem Exists.fst {b : Prop} {p : b → Prop} : Exists p → b\n  | ⟨h, _⟩ => h\n#align Exists.fst Exists.fst\n\ntheorem Exists.snd {b : Prop} {p : b → Prop} : ∀ h : Exists p, p h.fst\n  | ⟨_, h⟩ => h\n#align Exists.snd Exists.snd\n\ntheorem exists_prop_of_true {p : Prop} {q : p → Prop} (h : p) : (∃ h' : p, q h') ↔ q h :=\n  @exists_const (q h) p ⟨h⟩\n#align exists_prop_of_true exists_prop_of_true\n\ntheorem exists_iff_of_forall {p : Prop} {q : p → Prop} (h : ∀ h, q h) : (∃ h, q h) ↔ p :=\n  ⟨Exists.fst, fun H ↦ ⟨H, h H⟩⟩\n#align exists_iff_of_forall exists_iff_of_forall\n\ntheorem exists_unique_prop_of_true {p : Prop} {q : p → Prop} (h : p) : (∃! h' : p, q h') ↔ q h :=\n  @exists_unique_const (q h) p ⟨h⟩ _\n#align exists_unique_prop_of_true exists_unique_prop_of_true\n\ntheorem forall_prop_of_false {p : Prop} {q : p → Prop} (hn : ¬p) : (∀ h' : p, q h') ↔ True :=\n  iff_true_intro fun h ↦ hn.elim h\n#align forall_prop_of_false forall_prop_of_false\n\ntheorem exists_prop_of_false {p : Prop} {q : p → Prop} : ¬p → ¬∃ h' : p, q h' :=\n  mt Exists.fst\n#align exists_prop_of_false exists_prop_of_false\n\n@[congr]\ntheorem exists_prop_congr {p p' : Prop} {q q' : p → Prop} (hq : ∀ h, q h ↔ q' h) (hp : p ↔ p') :\n    Exists q ↔ ∃ h : p', q' (hp.2 h) :=\n  ⟨fun ⟨_, _⟩ ↦ ⟨hp.1 ‹_›, (hq _).1 ‹_›⟩, fun ⟨_, _⟩ ↦ ⟨_, (hq _).2 ‹_›⟩⟩\n#align exists_prop_congr exists_prop_congr\n\n@[congr]\ntheorem exists_prop_congr' {p p' : Prop} {q q' : p → Prop} (hq : ∀ h, q h ↔ q' h) (hp : p ↔ p') :\n    Exists q = ∃ h : p', q' (hp.2 h) :=\n  propext (exists_prop_congr hq hp)\n#align exists_prop_congr' exists_prop_congr'\n\n/-- See `IsEmpty.exists_iff` for the `false` version. -/\n@[simp] theorem exists_true_left (p : True → Prop) : (∃ x, p x) ↔ p True.intro :=\n  exists_prop_of_true _\n#align exists_true_left exists_true_left\n\n-- Porting note: `@[congr]` commented out for now.\n-- @[congr]\ntheorem forall_prop_congr {p p' : Prop} {q q' : p → Prop} (hq : ∀ h, q h ↔ q' h) (hp : p ↔ p') :\n    (∀ h, q h) ↔ ∀ h : p', q' (hp.2 h) :=\n  ⟨fun h1 h2 ↦ (hq _).1 (h1 (hp.2 h2)), fun h1 h2 ↦ (hq _).2 (h1 (hp.1 h2))⟩\n#align forall_prop_congr forall_prop_congr\n\n-- Porting note: `@[congr]` commented out for now.\n-- @[congr]\ntheorem forall_prop_congr' {p p' : Prop} {q q' : p → Prop} (hq : ∀ h, q h ↔ q' h) (hp : p ↔ p') :\n    (∀ h, q h) = ∀ h : p', q' (hp.2 h) :=\n  propext (forall_prop_congr hq hp)\n#align forall_prop_congr' forall_prop_congr'\n\n/-- See `IsEmpty.forall_iff` for the `false` version. -/\n@[simp] theorem forall_true_left (p : True → Prop) : (∀ x, p x) ↔ p True.intro :=\n  forall_prop_of_true _\n#align forall_true_left forall_true_left\n\ntheorem ExistsUnique.elim₂ {α : Sort _} {p : α → Sort _} [∀ x, Subsingleton (p x)]\n    {q : ∀ (x) (_ : p x), Prop} {b : Prop} (h₂ : ∃! (x : _) (h : p x), q x h)\n    (h₁ : ∀ (x) (h : p x), q x h → (∀ (y) (hy : p y), q y hy → y = x) → b) : b := by\n  simp only [exists_unique_iff_exists] at h₂\n  apply h₂.elim\n  exact fun x ⟨hxp, hxq⟩ H ↦ h₁ x hxp hxq fun y hyp hyq ↦ H y ⟨hyp, hyq⟩\n#align exists_unique.elim2 ExistsUnique.elim₂\n\ntheorem ExistsUnique.intro₂ {α : Sort _} {p : α → Sort _} [∀ x, Subsingleton (p x)]\n    {q : ∀ (x : α) (_ : p x), Prop} (w : α) (hp : p w) (hq : q w hp)\n    (H : ∀ (y) (hy : p y), q y hy → y = w) : ∃! (x : _) (hx : p x), q x hx := by\n  simp only [exists_unique_iff_exists]\n  exact ExistsUnique.intro w ⟨hp, hq⟩ fun y ⟨hyp, hyq⟩ ↦ H y hyp hyq\n#align exists_unique.intro2 ExistsUnique.intro₂\n\ntheorem ExistsUnique.exists₂ {α : Sort _} {p : α → Sort _} {q : ∀ (x : α) (_ : p x), Prop}\n    (h : ∃! (x : _) (hx : p x), q x hx) : ∃ (x : _) (hx : p x), q x hx :=\n  h.exists.imp fun _ hx ↦ hx.exists\n#align exists_unique.exists2 ExistsUnique.exists₂\n\ntheorem ExistsUnique.unique₂ {α : Sort _} {p : α → Sort _} [∀ x, Subsingleton (p x)]\n    {q : ∀ (x : α) (_ : p x), Prop} (h : ∃! (x : _) (hx : p x), q x hx) {y₁ y₂ : α}\n    (hpy₁ : p y₁) (hqy₁ : q y₁ hpy₁) (hpy₂ : p y₂) (hqy₂ : q y₂ hpy₂) : y₁ = y₂ := by\n  simp only [exists_unique_iff_exists] at h\n  exact h.unique ⟨hpy₁, hqy₁⟩ ⟨hpy₂, hqy₂⟩\n#align exists_unique.unique2 ExistsUnique.unique₂\n\nend Quantifiers\n\n/-! ### Classical lemmas -/\n\nnamespace Classical\nvariable {p : α → Prop}\n\n-- use shortened names to avoid conflict when classical namespace is open.\n/-- Any prop `p` is decidable classically. A shorthand for `classical.prop_decidable`. -/\nnoncomputable def dec (p : Prop) : Decidable p := by infer_instance\n#align classical.dec Classical.dec\n\n/-- Any predicate `p` is decidable classically. -/\nnoncomputable def decPred (p : α → Prop) : DecidablePred p := by infer_instance\n#align classical.dec_pred Classical.decPred\n\n/-- Any relation `p` is decidable classically. -/\nnoncomputable def decRel (p : α → α → Prop) : DecidableRel p := by infer_instance\n#align classical.dec_rel Classical.decRel\n\n/-- Any type `α` has decidable equality classically. -/\nnoncomputable def decEq (α : Sort u) : DecidableEq α := by infer_instance\n#align classical.dec_eq Classical.decEq\n\n/-- Construct a function from a default value `H0`, and a function to use if there exists a value\nsatisfying the predicate. -/\n-- @[elab_as_elim] -- FIXME\nnoncomputable def existsCases (H0 : C) (H : ∀ a, p a → C) : C :=\n  if h : ∃ a, p a then H (Classical.choose h) (Classical.choose_spec h) else H0\n#align classical.exists_cases Classical.existsCases\n\ntheorem some_spec₂ {α : Sort _} {p : α → Prop} {h : ∃ a, p a} (q : α → Prop)\n    (hpq : ∀ a, p a → q a) : q (choose h) := hpq _ <| choose_spec _\n#align classical.some_spec2 Classical.some_spec₂\n\n/-- A version of `Classical.indefiniteDescription` which is definitionally equal to a pair -/\nnoncomputable def subtype_of_exists {α : Type _} {P : α → Prop} (h : ∃ x, P x) : { x // P x } :=\n  ⟨Classical.choose h, Classical.choose_spec h⟩\n#align classical.subtype_of_exists Classical.subtype_of_exists\n\n/-- A version of `byContradiction` that uses types instead of propositions. -/\nprotected noncomputable def byContradiction' {α : Sort _} (H : ¬(α → False)) : α :=\n  Classical.choice <| (peirce _ False) fun h ↦ (H fun a ↦ h ⟨a⟩).elim\n#align classical.by_contradiction' Classical.byContradiction'\n\n/-- `classical.byContradiction'` is equivalent to lean's axiom `classical.choice`. -/\ndef choice_of_byContradiction' {α : Sort _} (contra : ¬(α → False) → α) : Nonempty α → α :=\n  fun H ↦ contra H.elim\n#align classical.choice_of_by_contradiction' Classical.choice_of_byContradiction'\n\nend Classical\n\n/-- This function has the same type as `Exists.recOn`, and can be used to case on an equality,\nbut `Exists.recOn` can only eliminate into Prop, while this version eliminates into any universe\nusing the axiom of choice. -/\n-- @[elab_as_elim] -- FIXME\nnoncomputable def Exists.classicalRecOn {p : α → Prop} (h : ∃ a, p a) {C} (H : ∀ a, p a → C) : C :=\n  H (Classical.choose h) (Classical.choose_spec h)\n#align exists.classical_rec_on Exists.classicalRecOn\n\n/-! ### Declarations about bounded quantifiers -/\n\nsection BoundedQuantifiers\nvariable {r p q : α → Prop} {P Q : ∀ x, p x → Prop} {b : Prop}\n\ntheorem bex_def : (∃ (x : _) (_ : p x), q x) ↔ ∃ x, p x ∧ q x :=\n  ⟨fun ⟨x, px, qx⟩ ↦ ⟨x, px, qx⟩, fun ⟨x, px, qx⟩ ↦ ⟨x, px, qx⟩⟩\n#align bex_def bex_def\n\ntheorem BEx.elim {b : Prop} : (∃ x h, P x h) → (∀ a h, P a h → b) → b\n  | ⟨a, h₁, h₂⟩, h' => h' a h₁ h₂\n#align bex.elim BEx.elim\n\ntheorem BEx.intro (a : α) (h₁ : p a) (h₂ : P a h₁) : ∃ (x : _) (h : p x), P x h :=\n  ⟨a, h₁, h₂⟩\n#align bex.intro BEx.intro\n\ntheorem ball_congr (H : ∀ x h, P x h ↔ Q x h) : (∀ x h, P x h) ↔ ∀ x h, Q x h :=\n  forall_congr' fun x ↦ forall_congr' (H x)\n#align ball_congr ball_congr\n\ntheorem bex_congr (H : ∀ x h, P x h ↔ Q x h) : (∃ x h, P x h) ↔ ∃ x h, Q x h :=\n  exists_congr fun x ↦ exists_congr (H x)\n#align bex_congr bex_congr\n\ntheorem bex_eq_left {a : α} : (∃ (x : _) (_ : x = a), p x) ↔ p a := by\n  simp only [exists_prop, exists_eq_left]\n#align bex_eq_left bex_eq_left\n\ntheorem BAll.imp_right (H : ∀ x h, P x h → Q x h) (h₁ : ∀ x h, P x h) (x h) : Q x h :=\n  H _ _ <| h₁ _ _\n#align ball.imp_right BAll.imp_right\n\ntheorem BEx.imp_right (H : ∀ x h, P x h → Q x h) : (∃ x h, P x h) → ∃ x h, Q x h\n  | ⟨_, _, h'⟩ => ⟨_, _, H _ _ h'⟩\n#align bex.imp_right BEx.imp_right\n\ntheorem BAll.imp_left (H : ∀ x, p x → q x) (h₁ : ∀ x, q x → r x) (x) (h : p x) : r x :=\n  h₁ _ <| H _ h\n#align ball.imp_left BAll.imp_left\n\ntheorem BEx.imp_left (H : ∀ x, p x → q x) : (∃ (x : _) (_ : p x), r x) → ∃ (x : _) (_ : q x), r x\n  | ⟨x, hp, hr⟩ => ⟨x, H _ hp, hr⟩\n#align bex.imp_left BEx.imp_left\n\ntheorem ball_of_forall (h : ∀ x, p x) (x) : p x := h x\n#align ball_of_forall ball_of_forall\n\ntheorem forall_of_ball (H : ∀ x, p x) (h : ∀ x, p x → q x) (x) : q x := h x <| H x\n#align forall_of_ball forall_of_ball\n\ntheorem bex_of_exists (H : ∀ x, p x) : (∃ x, q x) → ∃ (x : _) (_ : p x), q x\n  | ⟨x, hq⟩ => ⟨x, H x, hq⟩\n#align bex_of_exists bex_of_exists\n\ntheorem exists_of_bex : (∃ (x : _) (_ : p x), q x) → ∃ x, q x\n  | ⟨x, _, hq⟩ => ⟨x, hq⟩\n#align exists_of_bex exists_of_bex\n\ntheorem bex_imp : (∃ x h, P x h) → b ↔ ∀ x h, P x h → b := by simp\n#align bex_imp_distrib bex_imp\n\ntheorem not_bex : (¬∃ x h, P x h) ↔ ∀ x h, ¬P x h := bex_imp\n#align not_bex not_bex\n\ntheorem not_ball_of_bex_not : (∃ x h, ¬P x h) → ¬∀ x h, P x h\n  | ⟨x, h, hp⟩, al => hp <| al x h\n#align not_ball_of_bex_not not_ball_of_bex_not\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.not_ball [Decidable (∃ x h, ¬P x h)] [∀ x h, Decidable (P x h)] :\n    (¬∀ x h, P x h) ↔ ∃ x h, ¬P x h :=\n  ⟨Not.decidable_imp_symm fun nx x h ↦ nx.decidable_imp_symm\n    fun h' ↦ ⟨x, h, h'⟩, not_ball_of_bex_not⟩\n#align decidable.not_ball Decidable.not_ball\n\ntheorem not_ball : (¬∀ x h, P x h) ↔ ∃ x h, ¬P x h := Decidable.not_ball\n#align not_ball not_ball\n\ntheorem ball_true_iff (p : α → Prop) : (∀ x, p x → True) ↔ True :=\n  iff_true_intro fun _ _ ↦ trivial\n#align ball_true_iff ball_true_iff\n\ntheorem ball_and : (∀ x h, P x h ∧ Q x h) ↔ (∀ x h, P x h) ∧ ∀ x h, Q x h :=\n  Iff.trans (forall_congr' fun _ ↦ forall_and) forall_and\n#align ball_and_distrib ball_and\n\ntheorem bex_or : (∃ x h, P x h ∨ Q x h) ↔ (∃ x h, P x h) ∨ ∃ x h, Q x h :=\n  Iff.trans (exists_congr fun _ ↦ exists_or) exists_or\n#align bex_or_distrib bex_or\n\ntheorem ball_or_left : (∀ x, p x ∨ q x → r x) ↔ (∀ x, p x → r x) ∧ ∀ x, q x → r x :=\n  Iff.trans (forall_congr' fun _ ↦ or_imp) forall_and\n#align ball_or_left_distrib ball_or_left\n\ntheorem bex_or_left :\n    (∃ (x : _) (_ : p x ∨ q x), r x) ↔ (∃ (x : _) (_ : p x), r x) ∨ ∃ (x : _) (_ : q x), r x := by\n  simp only [exists_prop]\n  exact Iff.trans (exists_congr fun x ↦ or_and_right) exists_or\n#align bex_or_left_distrib bex_or_left\n\nend BoundedQuantifiers\n\n#align classical.not_ball not_ball\n\nsection ite\n\nvariable {σ : α → Sort _} (f : α → β) {P Q : Prop} [Decidable P] [Decidable Q]\n  {a b c : α} {A : P → α} {B : ¬P → α}\n\ntheorem dite_eq_iff : dite P A B = c ↔ (∃ h, A h = c) ∨ ∃ h, B h = c := by\n  by_cases P <;> simp [*, exists_prop_of_true, exists_prop_of_false]\n#align dite_eq_iff dite_eq_iff\n\ntheorem ite_eq_iff : ite P a b = c ↔ P ∧ a = c ∨ ¬P ∧ b = c :=\n  dite_eq_iff.trans <| by simp only; rw [exists_prop, exists_prop]\n#align ite_eq_iff ite_eq_iff\n\ntheorem eq_ite_iff : a = ite P b c ↔ P ∧ a = b ∨ ¬P ∧ a = c :=\neq_comm.trans <| ite_eq_iff.trans <| (Iff.rfl.and eq_comm).or (Iff.rfl.and eq_comm)\n\ntheorem dite_eq_iff' : dite P A B = c ↔ (∀ h, A h = c) ∧ ∀ h, B h = c :=\n  ⟨fun he ↦ ⟨fun h ↦ (dif_pos h).symm.trans he, fun h ↦ (dif_neg h).symm.trans he⟩, fun he ↦\n    (em P).elim (fun h ↦ (dif_pos h).trans <| he.1 h) fun h ↦ (dif_neg h).trans <| he.2 h⟩\n#align dite_eq_iff' dite_eq_iff'\n\ntheorem ite_eq_iff' : ite P a b = c ↔ (P → a = c) ∧ (¬P → b = c) := dite_eq_iff'\n#align ite_eq_iff' ite_eq_iff'\n\n@[simp] theorem dite_eq_left_iff : dite P (fun _ ↦ a) B = a ↔ ∀ h, B h = a := by\n  by_cases P <;> simp [*, forall_prop_of_true, forall_prop_of_false]\n#align dite_eq_left_iff dite_eq_left_iff\n\n@[simp] theorem dite_eq_right_iff : (dite P A fun _ ↦ b) = b ↔ ∀ h, A h = b := by\n  by_cases P <;> simp [*, forall_prop_of_true, forall_prop_of_false]\n#align dite_eq_right_iff dite_eq_right_iff\n\n@[simp] theorem ite_eq_left_iff : ite P a b = a ↔ ¬P → b = a := dite_eq_left_iff\n@[simp] theorem ite_eq_right_iff : ite P a b = b ↔ P → a = b := dite_eq_right_iff\n#align ite_eq_right_iff ite_eq_right_iff\n#align ite_eq_left_iff ite_eq_left_iff\n\ntheorem dite_ne_left_iff : dite P (fun _ ↦ a) B ≠ a ↔ ∃ h, a ≠ B h := by\n  rw [Ne.def, dite_eq_left_iff, not_forall]\n  exact exists_congr fun h ↦ by rw [ne_comm]\n#align dite_ne_left_iff dite_ne_left_iff\n\ntheorem dite_ne_right_iff : (dite P A fun _ ↦ b) ≠ b ↔ ∃ h, A h ≠ b := by\n  simp only [Ne.def, dite_eq_right_iff, not_forall]\n#align dite_ne_right_iff dite_ne_right_iff\n\ntheorem ite_ne_left_iff : ite P a b ≠ a ↔ ¬P ∧ a ≠ b :=\n  dite_ne_left_iff.trans <| by simp only; rw [exists_prop]\n#align ite_ne_left_iff ite_ne_left_iff\n\ntheorem ite_ne_right_iff : ite P a b ≠ b ↔ P ∧ a ≠ b :=\n  dite_ne_right_iff.trans <| by simp only; rw [exists_prop]\n#align ite_ne_right_iff ite_ne_right_iff\n\nprotected theorem Ne.dite_eq_left_iff (h : ∀ h, a ≠ B h) : dite P (fun _ ↦ a) B = a ↔ P :=\n  dite_eq_left_iff.trans ⟨fun H ↦ of_not_not fun h' ↦ h h' (H h').symm, fun h H ↦ (H h).elim⟩\n#align ne.dite_eq_left_iff Ne.dite_eq_left_iff\n\nprotected theorem Ne.dite_eq_right_iff (h : ∀ h, A h ≠ b) : (dite P A fun _ ↦ b) = b ↔ ¬P :=\n  dite_eq_right_iff.trans ⟨fun H h' ↦ h h' (H h'), fun h' H ↦ (h' H).elim⟩\n#align ne.dite_eq_right_iff Ne.dite_eq_right_iff\n\nprotected theorem Ne.ite_eq_left_iff (h : a ≠ b) : ite P a b = a ↔ P :=\n  Ne.dite_eq_left_iff fun _ ↦ h\n#align ne.ite_eq_left_iff Ne.ite_eq_left_iff\n\nprotected theorem Ne.ite_eq_right_iff (h : a ≠ b) : ite P a b = b ↔ ¬P :=\n  Ne.dite_eq_right_iff fun _ ↦ h\n#align ne.ite_eq_right_iff Ne.ite_eq_right_iff\n\nprotected theorem Ne.dite_ne_left_iff (h : ∀ h, a ≠ B h) : dite P (fun _ ↦ a) B ≠ a ↔ ¬P :=\n  dite_ne_left_iff.trans <| exists_iff_of_forall h\n#align ne.dite_ne_left_iff Ne.dite_ne_left_iff\n\nprotected theorem Ne.dite_ne_right_iff (h : ∀ h, A h ≠ b) : (dite P A fun _ ↦ b) ≠ b ↔ P :=\n  dite_ne_right_iff.trans <| exists_iff_of_forall h\n#align ne.dite_ne_right_iff Ne.dite_ne_right_iff\n\nprotected theorem Ne.ite_ne_left_iff (h : a ≠ b) : ite P a b ≠ a ↔ ¬P :=\n  Ne.dite_ne_left_iff fun _ ↦ h\n#align ne.ite_ne_left_iff Ne.ite_ne_left_iff\n\nprotected theorem Ne.ite_ne_right_iff (h : a ≠ b) : ite P a b ≠ b ↔ P :=\n  Ne.dite_ne_right_iff fun _ ↦ h\n#align ne.ite_ne_right_iff Ne.ite_ne_right_iff\n\nvariable (P Q a b)\n\n/-- A `dite` whose results do not actually depend on the condition may be reduced to an `ite`. -/\n@[simp] theorem dite_eq_ite : (dite P (fun _ ↦ a) fun _ ↦ b) = ite P a b := rfl\n#align dite_eq_ite dite_eq_ite\n\ntheorem dite_eq_or_eq : (∃ h, dite P A B = A h) ∨ ∃ h, dite P A B = B h :=\n  if h : _ then .inl ⟨h, dif_pos h⟩ else .inr ⟨h, dif_neg h⟩\n#align dite_eq_or_eq dite_eq_or_eq\n\ntheorem ite_eq_or_eq : ite P a b = a ∨ ite P a b = b :=\n  if h : _ then .inl (if_pos h) else .inr (if_neg h)\n#align ite_eq_or_eq ite_eq_or_eq\n\n/-- A two-argument function applied to two `dite`s is a `dite` of that two-argument function\napplied to each of the branches. -/\ntheorem apply_dite₂ (f : α → β → γ) (P : Prop) [Decidable P] (a : P → α) (b : ¬P → α)\n    (c : P → β) (d : ¬P → β) :\n    f (dite P a b) (dite P c d) = dite P (fun h ↦ f (a h) (c h)) fun h ↦ f (b h) (d h) := by\n  by_cases h : P <;> simp [h]\n#align apply_dite2 apply_dite₂\n\n/-- A two-argument function applied to two `ite`s is a `ite` of that two-argument function\napplied to each of the branches. -/\ntheorem apply_ite₂ (f : α → β → γ) (P : Prop) [Decidable P] (a b : α) (c d : β) :\n    f (ite P a b) (ite P c d) = ite P (f a c) (f b d) :=\n  apply_dite₂ f P (fun _ ↦ a) (fun _ ↦ b) (fun _ ↦ c) fun _ ↦ d\n#align apply_ite2 apply_ite₂\n\n/-- A 'dite' producing a `Pi` type `Π a, σ a`, applied to a value `a : α` is a `dite` that applies\neither branch to `a`. -/\ntheorem dite_apply (f : P → ∀ a, σ a) (g : ¬P → ∀ a, σ a) (a : α) :\n    (dite P f g) a = dite P (fun h ↦ f h a) fun h ↦ g h a := by by_cases h:P <;> simp [h]\n#align dite_apply dite_apply\n\n/-- A 'ite' producing a `Pi` type `Π a, σ a`, applied to a value `a : α` is a `ite` that applies\neither branch to `a`. -/\ntheorem ite_apply (f g : ∀ a, σ a) (a : α) : (ite P f g) a = ite P (f a) (g a) :=\n  dite_apply P (fun _ ↦ f) (fun _ ↦ g) a\n#align ite_apply ite_apply\n\ntheorem ite_and : ite (P ∧ Q) a b = ite P (ite Q a b) b := by\n  by_cases hp : P <;> by_cases hq : Q <;> simp [hp, hq]\n#align ite_and ite_and\n\ntheorem dite_dite_comm {B : Q → α} {C : ¬P → ¬Q → α} (h : P → ¬Q) :\n    (if p : P then A p else if q : Q then B q else C p q) =\n     if q : Q then B q else if p : P then A p else C p q :=\n  dite_eq_iff'.2 ⟨\n    fun p ↦ by rw [dif_neg (h p), dif_pos p],\n    fun np ↦ by congr; funext _; rw [dif_neg np]⟩\n#align dite_dite_comm dite_dite_comm\n\ntheorem ite_ite_comm (h : P → ¬Q) :\n    (if P then a else if Q then b else c) =\n     if Q then b else if P then a else c :=\n  dite_dite_comm P Q h\n#align ite_ite_comm ite_ite_comm\n\nend ite\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Logic/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.7310585786300049, "lm_q1q2_score": 0.4604021293463398}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.algebraic_topology.homotopical_algebra.model_category\n\nnoncomputable theory\n\nopen category_theory category_theory.limits opposite\n\nnamespace algebraic_topology\n\nnamespace model_category\n\nvariables {C : Type*} [category C] [model_category C] (A B X Y : C)\n\nabbreviation is_cofibrant (B : C) := cofibration (initial.to B)\nabbreviation is_fibrant (B : C) := fibration (terminal.from B)\n\nvariables {A B X Y}\n\nnamespace cofibration\n\nlemma from_initial (f : A ⟶ B) [is_cofibrant B] (hA : is_initial A) : cofibration f :=\nbegin\n  have fac : f = (is_initial.unique_up_to_iso hA initial_is_initial).hom ≫ initial.to B :=\n    by apply hA.hom_ext,\n  rw fac,\n  apply_instance,\nend\n\nend cofibration\n\nnamespace fibration\n\nlemma from_terminal (f : X ⟶ Y) [is_fibrant X] (hY : is_terminal Y) : fibration f :=\nbegin\n  have fac : f = terminal.from X ≫ (is_terminal.unique_up_to_iso terminal_is_terminal hY).hom :=\n    by apply hY.hom_ext,\n  rw fac,\n  apply_instance,\nend\n\nend fibration\n\nnamespace is_cofibrant\n\nlemma of_initial (hA : is_initial A) : is_cofibrant A :=\nbegin\n  change cofibration (initial.to A),\n  rw [show initial.to A = (is_initial.unique_up_to_iso initial_is_initial hA).hom,\n    by apply subsingleton.elim],\n  apply_instance,\nend\n\nlemma mk (f : A ⟶ B) [cofibration f] (hA : is_initial A) : is_cofibrant B :=\nbegin\n  change cofibration (initial.to B),\n  rw [show initial.to B = initial.to A ≫ f, by apply subsingleton.elim],\n  haveI : is_cofibrant A := of_initial hA,\n  apply_instance,\nend\n\nend is_cofibrant\n\nnamespace is_fibrant\n\nlemma of_terminal (hY : is_terminal Y) : is_fibrant Y :=\nbegin\n  change fibration (terminal.from Y),\n  rw [show terminal.from Y = (is_terminal.unique_up_to_iso hY terminal_is_terminal).hom,\n    by apply subsingleton.elim],\n  apply_instance,\nend\n\nlemma mk (f : X ⟶ Y) [fibration f] (hY : is_terminal Y) : is_fibrant X :=\nbegin\n  change fibration (terminal.from X),\n  rw [show terminal.from X = f ≫ terminal.from Y, by apply subsingleton.elim],\n  haveI : is_fibrant Y := of_terminal hY,\n  apply_instance,\nend\n\nlemma op (hX : is_fibrant X) : is_cofibrant (op X) :=\nbegin\n  haveI : cofibration (terminal.from X).op := fibration.op infer_instance,\n  exact is_cofibrant.mk (terminal.from X).op (initial_op_of_terminal terminal_is_terminal),\nend\n\nlemma unop {X : Cᵒᵖ} (hX : is_fibrant X) : is_cofibrant X.unop :=\nbegin\n  haveI : cofibration (terminal.from X).unop := fibration.unop infer_instance,\n  exact is_cofibrant.mk (terminal.from X).unop (initial_unop_of_terminal terminal_is_terminal),\nend\n\nend is_fibrant\n\nnamespace is_cofibrant\n\nlemma op (hB : is_cofibrant B) : is_fibrant (op B) :=\nbegin\n  haveI : fibration (initial.to B).op := cofibration.op infer_instance,\n  exact is_fibrant.mk (initial.to B).op (terminal_op_of_initial initial_is_initial),\nend\n\nlemma unop {B : Cᵒᵖ} (hB : is_cofibrant B) : is_fibrant B.unop :=\nbegin\n  haveI : fibration (initial.to B).unop := cofibration.unop infer_instance,\n  exact is_fibrant.mk (initial.to B).unop (terminal_unop_of_initial initial_is_initial),\nend\n\nend is_cofibrant\n\ninstance cofibration_coprod_inl [hB : is_cofibrant B] : cofibration (coprod.inl : A ⟶ A ⨿ B) :=\n⟨cof_is_stable_under_cobase_change.coprod_inl A B hB.property⟩\n\ninstance cofibration_coprod_inr [hA : is_cofibrant A] : cofibration (coprod.inr : B ⟶ A ⨿ B) :=\n⟨cof_is_stable_under_cobase_change.coprod_inr A B hA.property⟩\n\ninstance fibration_prod_fst [hY : is_fibrant Y] : fibration (limits.prod.fst : X ⨯ Y ⟶ X) :=\n⟨fib_is_stable_under_base_change.prod_fst X Y hY.property⟩\n\ninstance fibration_prod_snd [hX : is_fibrant X] : fibration (limits.prod.snd : X ⨯ Y ⟶ Y) :=\n⟨fib_is_stable_under_base_change.prod_snd X Y hX.property⟩\n\ninstance : is_fibrant (terminal C) :=\nby { haveI : is_iso (terminal.from (terminal C)) := by convert is_iso.id _, apply_instance, }\n\ninstance : is_cofibrant (initial C) :=\nby { haveI : is_iso (initial.to (initial C)) := by convert is_iso.id _, apply_instance, }\n\ninstance is_fibrant_CM5a_obj {X Y : C} (f : X ⟶ Y) [is_fibrant Y] :\n  is_fibrant (CM5a.obj f) :=\nbegin\n  change fibration _,\n  have eq : terminal.from (factorisation_axiom.obj CM5a f) = (CM5a.p f) ≫ terminal.from _ :=\n    subsingleton.elim _ _,\n  rw eq,\n  apply_instance,\nend\n\ninstance is_fibrant_CM5b_obj {X Y : C} (f : X ⟶ Y) [is_fibrant Y] :\n  is_fibrant (CM5b.obj f) :=\nbegin\n  change fibration _,\n  have eq : terminal.from (factorisation_axiom.obj CM5b f) = (CM5b.p f) ≫ terminal.from _ :=\n    subsingleton.elim _ _,\n  rw eq,\n  apply_instance,\nend\n\ninstance is_cofibrant_CM5a_obj {X Y : C} (f : X ⟶ Y) [is_cofibrant X] :\n  is_cofibrant (CM5a.obj f) :=\nbegin\n  change cofibration _,\n  have eq : initial.to (factorisation_axiom.obj CM5a f) = initial.to _ ≫ (CM5a.i f) :=\n    subsingleton.elim _ _,\n  rw eq,\n  apply_instance,\nend\n\ninstance is_cofibrant_CM5b_obj {X Y : C} (f : X ⟶ Y) [is_cofibrant X] :\n  is_cofibrant (CM5b.obj f) :=\nbegin\n  change cofibration _,\n  have eq : initial.to (factorisation_axiom.obj CM5b f) = initial.to _ ≫ (CM5b.i f) :=\n    subsingleton.elim _ _,\n  rw eq,\n  apply_instance,\nend\n\nend model_category\n\nend algebraic_topology\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebraic_topology/homotopical_algebra/fibrant.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110202, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.4604021270459029}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport control.monad.basic\nimport data.part\nimport order.hom.order\nimport data.nat.order.basic\nimport tactic.wlog\n\n/-!\n# Omega Complete Partial Orders\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nAn omega-complete partial order is a partial order with a supremum\noperation on increasing sequences indexed by natural numbers (which we\ncall `ωSup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only ω-sized totally ordered sets have a supremum.\n\nThe concept of an omega-complete partial order (ωCPO) is useful for the\nformalization of the semantics of programming languages. Its notion of\nsupremum helps define the meaning of recursive procedures.\n\n## Main definitions\n\n * class `omega_complete_partial_order`\n * `ite`, `map`, `bind`, `seq` as continuous morphisms\n\n## Instances of `omega_complete_partial_order`\n\n * `part`\n * every `complete_lattice`\n * pi-types\n * product types\n * `monotone_hom`\n * `continuous_hom` (with notation →𝒄)\n   * an instance of `omega_complete_partial_order (α →𝒄 β)`\n * `continuous_hom.of_fun`\n * `continuous_hom.of_mono`\n * continuous functions:\n   * `id`\n   * `ite`\n   * `const`\n   * `part.bind`\n   * `part.map`\n   * `part.seq`\n\n## References\n\n * [Chain-complete posets and directed sets with applications][markowsky1976]\n * [Recursive definitions of partial functions and their computations][cadiou1972]\n * [Semantics of Programming Languages: Structures and Techniques][gunter1992]\n-/\n\nuniverses u v\n\nlocal attribute [-simp] part.bind_eq_bind part.map_eq_map\nopen_locale classical\n\nnamespace order_hom\n\nvariables (α : Type*) (β : Type*) {γ : Type*} {φ : Type*}\nvariables [preorder α] [preorder β] [preorder γ] [preorder φ]\n\nvariables {β γ}\n\nvariables {α} {α' : Type*} {β' : Type*} [preorder α'] [preorder β']\n\n/-- `part.bind` as a monotone function -/\n@[simps]\ndef bind {β γ} (f : α →o part β) (g : α →o β → part γ) : α →o part γ :=\n{ to_fun := λ x, f x >>= g x,\n  monotone' :=\n  begin\n    intros x y h a,\n    simp only [and_imp, exists_prop, part.bind_eq_bind, part.mem_bind_iff,\n               exists_imp_distrib],\n    intros b hb ha,\n    refine ⟨b, f.monotone h _ hb, g.monotone h _ _ ha⟩,\n  end }\n\nend order_hom\n\nnamespace omega_complete_partial_order\n\n/-- A chain is a monotone sequence.\n\nSee the definition on page 114 of [gunter1992]. -/\ndef chain (α : Type u) [preorder α] :=\nℕ →o α\n\nnamespace chain\n\nvariables {α : Type u} {β : Type v} {γ : Type*}\nvariables [preorder α] [preorder β] [preorder γ]\n\ninstance : has_coe_to_fun (chain α) (λ _, ℕ → α) := order_hom.has_coe_to_fun\n\ninstance [inhabited α] : inhabited (chain α) :=\n⟨⟨default, λ _ _ _, le_rfl⟩⟩\n\ninstance : has_mem α (chain α) :=\n⟨λ a (c : ℕ →o α), ∃ i, a = c i⟩\n\nvariables (c c' : chain α)\nvariables (f : α →o β)\nvariables (g : β →o γ)\n\ninstance : has_le (chain α) :=\n{ le := λ x y, ∀ i, ∃ j, x i ≤ y j }\n\n/-- `map` function for `chain` -/\n@[simps {fully_applied := ff}] def map : chain β :=\nf.comp c\n\nvariables {f}\n\nlemma mem_map (x : α) : x ∈ c → f x ∈ chain.map c f :=\nλ ⟨i,h⟩, ⟨i, h.symm ▸ rfl⟩\n\nlemma exists_of_mem_map {b : β} : b ∈ c.map f → ∃ a, a ∈ c ∧ f a = b :=\nλ ⟨i,h⟩, ⟨c i, ⟨i, rfl⟩, h.symm⟩\n\nlemma mem_map_iff {b : β} : b ∈ c.map f ↔ ∃ a, a ∈ c ∧ f a = b :=\n⟨ exists_of_mem_map _, λ h, by { rcases h with ⟨w,h,h'⟩, subst b, apply mem_map c _ h, } ⟩\n\n@[simp]\nlemma map_id : c.map order_hom.id = c :=\norder_hom.comp_id _\n\nlemma map_comp : (c.map f).map g = c.map (g.comp f) := rfl\n\n@[mono]\nlemma map_le_map {g : α →o β} (h : f ≤ g) : c.map f ≤ c.map g :=\nλ i, by simp [mem_map_iff]; intros; existsi i; apply h\n\n/-- `chain.zip` pairs up the elements of two chains that have the same index -/\n@[simps]\ndef zip (c₀ : chain α) (c₁ : chain β) : chain (α × β) :=\norder_hom.prod c₀ c₁\n\nend chain\n\nend omega_complete_partial_order\n\nopen omega_complete_partial_order\n\nsection prio\nset_option extends_priority 50\n\n/-- An omega-complete partial order is a partial order with a supremum\noperation on increasing sequences indexed by natural numbers (which we\ncall `ωSup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only ω-sized totally ordered sets have a supremum.\n\nSee the definition on page 114 of [gunter1992]. -/\nclass omega_complete_partial_order (α : Type*) extends partial_order α :=\n(ωSup     : chain α → α)\n(le_ωSup  : ∀(c:chain α), ∀ i, c i ≤ ωSup c)\n(ωSup_le  : ∀(c:chain α) x, (∀ i, c i ≤ x) → ωSup c ≤ x)\n\nend prio\n\nnamespace omega_complete_partial_order\nvariables {α : Type u} {β : Type v} {γ : Type*}\nvariables [omega_complete_partial_order α]\n\n/-- Transfer a `omega_complete_partial_order` on `β` to a `omega_complete_partial_order` on `α`\nusing a strictly monotone function `f : β →o α`, a definition of ωSup and a proof that `f` is\ncontinuous with regard to the provided `ωSup` and the ωCPO on `α`. -/\n@[reducible]\nprotected def lift [partial_order β] (f : β →o α)\n  (ωSup₀ : chain β → β)\n  (h : ∀ x y, f x ≤ f y → x ≤ y)\n  (h' : ∀ c, f (ωSup₀ c) = ωSup (c.map f)) : omega_complete_partial_order β :=\n{ ωSup := ωSup₀,\n  ωSup_le := λ c x hx, h _ _ (by rw h'; apply ωSup_le; intro; apply f.monotone (hx i)),\n  le_ωSup := λ c i, h _ _ (by rw h'; apply le_ωSup (c.map f)) }\n\nlemma le_ωSup_of_le {c : chain α} {x : α} (i : ℕ) (h : x ≤ c i) : x ≤ ωSup c :=\nle_trans h (le_ωSup c _)\n\nlemma ωSup_total {c : chain α} {x : α} (h : ∀ i, c i ≤ x ∨ x ≤ c i) : ωSup c ≤ x ∨ x ≤ ωSup c :=\nclassical.by_cases\n  (assume : ∀ i, c i ≤ x, or.inl (ωSup_le _ _ this))\n  (assume : ¬ ∀ i, c i ≤ x,\n    have ∃ i, ¬ c i ≤ x,\n      by simp only [not_forall] at this ⊢; assumption,\n    let ⟨i, hx⟩ := this in\n    have x ≤ c i, from (h i).resolve_left hx,\n    or.inr $ le_ωSup_of_le _ this)\n\n@[mono]\nlemma ωSup_le_ωSup_of_le {c₀ c₁ : chain α} (h : c₀ ≤ c₁) : ωSup c₀ ≤ ωSup c₁ :=\nωSup_le _ _ $\nλ i, Exists.rec_on (h i) $\nλ j h, le_trans h (le_ωSup _ _)\n\nlemma ωSup_le_iff (c : chain α) (x : α) : ωSup c ≤ x ↔ (∀ i, c i ≤ x) :=\nbegin\n  split; intros,\n  { transitivity ωSup c,\n    exact le_ωSup _ _, assumption },\n  exact ωSup_le _ _ ‹_›,\nend\n\n/-- A subset `p : α → Prop` of the type closed under `ωSup` induces an\n`omega_complete_partial_order` on the subtype `{a : α // p a}`. -/\ndef subtype {α : Type*} [omega_complete_partial_order α] (p : α → Prop)\n  (hp : ∀ (c : chain α), (∀ i ∈ c, p i) → p (ωSup c)) :\n  omega_complete_partial_order (subtype p) :=\nomega_complete_partial_order.lift\n  (order_hom.subtype.val p)\n  (λ c, ⟨ωSup _, hp (c.map (order_hom.subtype.val p)) (λ i ⟨n, q⟩, q.symm ▸ (c n).2)⟩)\n  (λ x y h, h)\n  (λ c, rfl)\n\nsection continuity\nopen chain\n\nvariables [omega_complete_partial_order β]\nvariables [omega_complete_partial_order γ]\n\n/-- A monotone function `f : α →o β` is continuous if it distributes over ωSup.\n\nIn order to distinguish it from the (more commonly used) continuity from topology\n(see topology/basic.lean), the present definition is often referred to as\n\"Scott-continuity\" (referring to Dana Scott). It corresponds to continuity\nin Scott topological spaces (not defined here). -/\ndef continuous (f : α →o β) : Prop :=\n∀ c : chain α, f (ωSup c) = ωSup (c.map f)\n\n/-- `continuous' f` asserts that `f` is both monotone and continuous. -/\ndef continuous' (f : α → β) : Prop :=\n∃ hf : monotone f, continuous ⟨f, hf⟩\n\nlemma continuous'.to_monotone {f : α → β} (hf : continuous' f) : monotone f := hf.fst\n\nlemma continuous.of_bundled (f : α → β) (hf : monotone f)\n  (hf' : continuous ⟨f, hf⟩) : continuous' f := ⟨hf, hf'⟩\n\nlemma continuous.of_bundled' (f : α →o β) (hf' : continuous f) : continuous' f :=\n⟨f.mono, hf'⟩\n\nlemma continuous'.to_bundled (f : α → β) (hf : continuous' f) :\n  continuous ⟨f, hf.to_monotone⟩ := hf.snd\n\n@[simp, norm_cast] lemma continuous'_coe : ∀ {f : α →o β}, continuous' f ↔ continuous f\n| ⟨f, hf⟩ := ⟨λ ⟨hf', hc⟩, hc, λ hc, ⟨hf, hc⟩⟩\n\nvariables (f : α →o β) (g : β →o γ)\n\nlemma continuous_id : continuous (@order_hom.id α _) :=\nby intro; rw c.map_id; refl\n\nlemma continuous_comp (hfc : continuous f) (hgc : continuous g) : continuous (g.comp f):=\nbegin\n  dsimp [continuous] at *, intro,\n  rw [hfc,hgc,chain.map_comp]\nend\n\nlemma id_continuous' : continuous' (@id α) :=\ncontinuous_id.of_bundled' _\n\nlemma continuous_const (x : β) : continuous (order_hom.const α x) :=\nλ c, eq_of_forall_ge_iff $ λ z, by simp [ωSup_le_iff]\n\nlemma const_continuous' (x: β) : continuous' (function.const α x) :=\ncontinuous.of_bundled' (order_hom.const α x) (continuous_const x)\n\nend continuity\n\nend omega_complete_partial_order\n\nnamespace part\n\nvariables {α : Type u} {β : Type v} {γ : Type*}\nopen omega_complete_partial_order\n\nlemma eq_of_chain {c : chain (part α)} {a b : α} (ha : some a ∈ c) (hb : some b ∈ c) : a = b :=\nbegin\n  cases ha with i ha, replace ha := ha.symm,\n  cases hb with j hb, replace hb := hb.symm,\n  wlog h : i ≤ j, { exact (this j hb i ha (le_of_not_le h)).symm },\n  rw [eq_some_iff] at ha hb,\n  have := c.monotone h _ ha, apply mem_unique this hb\nend\n\n/-- The (noncomputable) `ωSup` definition for the `ω`-CPO structure on `part α`. -/\nprotected noncomputable def ωSup (c : chain (part α)) : part α :=\nif h : ∃a, some a ∈ c then some (classical.some h) else none\n\nlemma ωSup_eq_some {c : chain (part α)} {a : α} (h : some a ∈ c) : part.ωSup c = some a :=\nhave ∃a, some a ∈ c, from ⟨a, h⟩,\nhave a' : some (classical.some this) ∈ c, from classical.some_spec this,\ncalc part.ωSup c = some (classical.some this) : dif_pos this\n                ... = some a : congr_arg _ (eq_of_chain a' h)\n\nlemma ωSup_eq_none {c : chain (part α)} (h : ¬∃a, some a ∈ c) : part.ωSup c = none :=\ndif_neg h\n\nlemma mem_chain_of_mem_ωSup {c : chain (part α)} {a : α} (h : a ∈ part.ωSup c) : some a ∈ c :=\nbegin\n  simp [part.ωSup] at h, split_ifs at h,\n  { have h' := classical.some_spec h_1,\n    rw ← eq_some_iff at h, rw ← h, exact h' },\n  { rcases h with ⟨ ⟨ ⟩ ⟩ }\nend\n\nnoncomputable instance omega_complete_partial_order : omega_complete_partial_order (part α) :=\n{ ωSup    := part.ωSup,\n  le_ωSup := λ c i, by { intros x hx, rw ← eq_some_iff at hx ⊢,\n                         rw [ωSup_eq_some, ← hx], rw ← hx, exact ⟨i,rfl⟩ },\n  ωSup_le := by { rintros c x hx a ha, replace ha := mem_chain_of_mem_ωSup ha,\n                  cases ha with i ha, apply hx i, rw ← ha, apply mem_some } }\n\nsection inst\n\nlemma mem_ωSup (x : α) (c : chain (part α)) : x ∈ ωSup c ↔ some x ∈ c :=\nbegin\n  simp [omega_complete_partial_order.ωSup,part.ωSup],\n  split,\n  { split_ifs, swap, rintro ⟨⟨⟩⟩,\n    intro h', have hh := classical.some_spec h,\n    simp at h', subst x, exact hh },\n  { intro h,\n    have h' : ∃ (a : α), some a ∈ c := ⟨_,h⟩,\n    rw dif_pos h', have hh := classical.some_spec h',\n    rw eq_of_chain hh h, simp }\nend\n\nend inst\n\nend part\n\nnamespace pi\n\nvariables {α : Type*} {β : α → Type*} {γ : Type*}\n\nopen omega_complete_partial_order omega_complete_partial_order.chain\n\ninstance [∀a, omega_complete_partial_order (β a)] : omega_complete_partial_order (Πa, β a) :=\n{ ωSup    := λc a, ωSup (c.map (pi.eval_order_hom a)),\n  ωSup_le := assume c f hf a, ωSup_le _ _ $ by { rintro i, apply hf },\n  le_ωSup := assume c i x, le_ωSup_of_le _ $ le_rfl }\n\nnamespace omega_complete_partial_order\n\nvariables [∀ x, omega_complete_partial_order $ β x]\nvariables [omega_complete_partial_order γ]\n\nlemma flip₁_continuous'\n  (f : ∀ x : α, γ → β x) (a : α) (hf : continuous' (λ x y, f y x)) :\n  continuous' (f a) :=\ncontinuous.of_bundled _\n  (λ x y h, hf.to_monotone h a)\n  (λ c, congr_fun (hf.to_bundled _ c) a)\n\nlemma flip₂_continuous'\n  (f : γ → Π x, β x) (hf : ∀ x, continuous' (λ g, f g x)) : continuous' f :=\ncontinuous.of_bundled _\n  (λ x y h a, (hf a).to_monotone h)\n  (by intro c; ext a; apply (hf a).to_bundled _ c)\n\nend omega_complete_partial_order\n\nend pi\n\nnamespace prod\n\nopen omega_complete_partial_order\nvariables {α : Type*} {β : Type*} {γ : Type*}\nvariables [omega_complete_partial_order α]\nvariables [omega_complete_partial_order β]\nvariables [omega_complete_partial_order γ]\n\n/-- The supremum of a chain in the product `ω`-CPO. -/\n@[simps]\nprotected def ωSup (c : chain (α × β)) : α × β :=\n(ωSup (c.map order_hom.fst), ωSup (c.map order_hom.snd))\n\n@[simps ωSup_fst ωSup_snd]\ninstance : omega_complete_partial_order (α × β) :=\n{ ωSup := prod.ωSup,\n  ωSup_le := λ c ⟨x,x'⟩ h, ⟨ωSup_le _ _ $ λ i, (h i).1, ωSup_le _ _ $ λ i, (h i).2⟩,\n  le_ωSup := λ c i,\n    ⟨le_ωSup (c.map order_hom.fst) i, le_ωSup (c.map order_hom.snd) i⟩ }\n\n\n\nend prod\n\nopen omega_complete_partial_order\n\nnamespace complete_lattice\nvariables (α : Type u)\n\n/-- Any complete lattice has an `ω`-CPO structure where the countable supremum is a special case\nof arbitrary suprema. -/\n\n@[priority 100] -- see Note [lower instance priority]\ninstance [complete_lattice α] : omega_complete_partial_order α :=\n{ ωSup    := λc, ⨆ i, c i,\n  ωSup_le := λ ⟨c, _⟩ s hs, by simp only [supr_le_iff, order_hom.coe_fun_mk] at ⊢ hs;\n    intros i; apply hs i,\n  le_ωSup := assume ⟨c, _⟩ i, by simp only [order_hom.coe_fun_mk]; apply le_supr_of_le i; refl }\n\nvariables {α} {β : Type v} [omega_complete_partial_order α] [complete_lattice β]\n\nlemma Sup_continuous (s : set $ α →o β) (hs : ∀ f ∈ s, continuous f) :\n  continuous (Sup s) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  suffices : (∀ (f ∈ s) n, (f : _) (c n) ≤ z) ↔ (∀ n (f ∈ s), (f : _) (c n) ≤ z),\n    by simpa [ωSup_le_iff, hs _ _ _] { contextual := tt },\n  exact ⟨λ H n f hf, H f hf n, λ H f hf n, H n f hf⟩\nend\n\nlemma supr_continuous {ι : Sort*} {f : ι → α →o β} (h : ∀ i, continuous (f i)) :\n  continuous (⨆ i, f i) :=\nSup_continuous _ $ set.forall_range_iff.2 h\n\ntheorem Sup_continuous' (s : set (α → β)) (hc : ∀ f ∈ s, continuous' f) :\n  continuous' (Sup s) :=\nbegin\n  lift s to set (α →o β) using λ f hf, (hc f hf).to_monotone,\n  simp only [set.ball_image_iff, continuous'_coe] at hc,\n  rw [Sup_image],\n  norm_cast,\n  exact supr_continuous (λ f, supr_continuous (λ hf, hc f hf)),\nend\n\nlemma sup_continuous {f g : α →o β} (hf : continuous f) (hg : continuous g) :\n  continuous (f ⊔ g) :=\nbegin\n  rw ← Sup_pair, apply Sup_continuous,\n  rintro f (rfl|rfl|_); assumption\nend\n\nlemma top_continuous :\n  continuous (⊤ : α →o β) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [ωSup_le_iff, forall_const, chain.map_coe, (∘), function.const,\n             order_hom.has_top_top, order_hom.const_coe_coe],\nend\n\nlemma bot_continuous :\n  continuous (⊥ : α →o β) :=\nbegin\n  rw ← Sup_empty,\n  exact Sup_continuous _ (λ f hf, hf.elim),\nend\n\nend complete_lattice\n\nnamespace complete_lattice\nvariables {α β : Type*} [omega_complete_partial_order α] [complete_linear_order β]\n\nlemma inf_continuous (f g : α →o β) (hf : continuous f) (hg : continuous g) : continuous (f ⊓ g) :=\nbegin\n  refine λ c, eq_of_forall_ge_iff (λ z, _),\n  simp only [inf_le_iff, hf c, hg c, ωSup_le_iff, ←forall_or_distrib_left, ←forall_or_distrib_right,\n             function.comp_app, chain.map_coe, order_hom.has_inf_inf_coe],\n  exact ⟨λ h _, h _ _, λ h i j, (h (max i j)).imp (le_trans $ f.mono $ c.mono $ le_max_left _ _)\n    (le_trans $ g.mono $ c.mono $ le_max_right _ _)⟩,\nend\n\nlemma inf_continuous' {f g : α → β} (hf : continuous' f) (hg : continuous' g) :\n  continuous' (f ⊓ g) :=\n⟨_, inf_continuous _ _ hf.snd hg.snd⟩\n\nend complete_lattice\n\nnamespace omega_complete_partial_order\n\nvariables {α : Type u} {α' : Type*} {β : Type v} {β' : Type*} {γ : Type*} {φ : Type*}\n\nvariables [omega_complete_partial_order α] [omega_complete_partial_order β]\nvariables [omega_complete_partial_order γ] [omega_complete_partial_order φ]\nvariables [omega_complete_partial_order α'] [omega_complete_partial_order β']\n\nnamespace order_hom\n\n/-- The `ωSup` operator for monotone functions. -/\n@[simps]\nprotected def ωSup (c : chain (α →o β)) : α →o β :=\n{ to_fun := λ a, ωSup (c.map (order_hom.apply a)),\n  monotone' := λ x y h, ωSup_le_ωSup_of_le (chain.map_le_map _ $ λ a, a.monotone h) }\n\n@[simps ωSup_coe]\ninstance omega_complete_partial_order : omega_complete_partial_order (α →o β) :=\nomega_complete_partial_order.lift order_hom.coe_fn_hom order_hom.ωSup\n  (λ x y h, h) (λ c, rfl)\n\nend order_hom\n\nsection\nvariables (α β)\n\n/-- A monotone function on `ω`-continuous partial orders is said to be continuous\nif for every chain `c : chain α`, `f (⊔ i, c i) = ⊔ i, f (c i)`.\nThis is just the bundled version of `order_hom.continuous`. -/\nstructure continuous_hom extends order_hom α β :=\n(cont : continuous (order_hom.mk to_fun monotone'))\n\nattribute [nolint doc_blame] continuous_hom.to_order_hom\n\ninfixr ` →𝒄 `:25 := continuous_hom -- Input: \\r\\MIc\n\ninstance : has_coe_to_fun (α →𝒄 β) (λ _, α → β) := ⟨λ f, f.to_order_hom.to_fun⟩\n\ninstance : has_coe (α →𝒄 β) (α →o β) :=\n{ coe :=  continuous_hom.to_order_hom }\n\ninstance : partial_order (α →𝒄 β) :=\npartial_order.lift (λ f, f.to_order_hom.to_fun) $ by rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩ h; congr; exact h\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef continuous_hom.simps.apply (h : α →𝒄 β) : α → β := h\n\ninitialize_simps_projections continuous_hom\n  (to_order_hom_to_fun → apply, -to_order_hom)\n\nend\n\nnamespace continuous_hom\n\ntheorem congr_fun {f g : α →𝒄 β} (h : f = g) (x : α) : f x = g x :=\ncongr_arg (λ h : α →𝒄 β, h x) h\n\ntheorem congr_arg (f : α →𝒄 β) {x y : α} (h : x = y) : f x = f y :=\ncongr_arg (λ x : α, f x) h\n\nprotected lemma monotone (f : α →𝒄 β) : monotone f := f.monotone'\n\n@[mono] lemma apply_mono {f g : α →𝒄 β} {x y : α} (h₁ : f ≤ g) (h₂ : x ≤ y) : f x ≤ g y :=\norder_hom.apply_mono (show (f : α →o β) ≤ g, from h₁) h₂\n\nlemma ite_continuous' {p : Prop} [hp : decidable p] (f g : α → β)\n  (hf : continuous' f) (hg : continuous' g) : continuous' (λ x, if p then f x else g x) :=\nby split_ifs; simp *\n\nlemma ωSup_bind {β γ : Type v} (c : chain α) (f : α →o part β) (g : α →o β → part γ) :\n  ωSup (c.map (f.bind g)) = ωSup (c.map f) >>= ωSup (c.map g) :=\nbegin\n  apply eq_of_forall_ge_iff, intro x,\n  simp only [ωSup_le_iff, part.bind_le, chain.mem_map_iff, and_imp, order_hom.bind_coe,\n    exists_imp_distrib],\n  split; intro h''',\n  { intros b hb, apply ωSup_le _ _ _,\n    rintros i y hy, simp only [part.mem_ωSup] at hb,\n    rcases hb with ⟨j,hb⟩, replace hb := hb.symm,\n    simp only [part.eq_some_iff, chain.map_coe, function.comp_app, order_hom.apply_coe]\n      at hy hb,\n    replace hb : b ∈ f (c (max i j))   := f.mono (c.mono (le_max_right i j)) _ hb,\n    replace hy : y ∈ g (c (max i j)) b := g.mono (c.mono (le_max_left i j)) _ _ hy,\n    apply h''' (max i j),\n    simp only [exists_prop, part.bind_eq_bind, part.mem_bind_iff, chain.map_coe,\n               function.comp_app, order_hom.bind_coe],\n    exact ⟨_,hb,hy⟩, },\n  { intros i, intros y hy,\n    simp only [exists_prop, part.bind_eq_bind, part.mem_bind_iff, chain.map_coe,\n               function.comp_app, order_hom.bind_coe] at hy,\n    rcases hy with ⟨b,hb₀,hb₁⟩,\n    apply h''' b _,\n    { apply le_ωSup (c.map g) _ _ _ hb₁ },\n    { apply le_ωSup (c.map f) i _ hb₀ } },\nend\n\nlemma bind_continuous' {β γ : Type v} (f : α → part β) (g : α → β → part γ) :\n  continuous' f → continuous' g →\n  continuous' (λ x, f x >>= g x)\n| ⟨hf,hf'⟩ ⟨hg,hg'⟩ :=\ncontinuous.of_bundled' (order_hom.bind ⟨f,hf⟩ ⟨g,hg⟩)\n  (by intro c; rw [ωSup_bind, ← hf', ← hg']; refl)\n\nlemma map_continuous' {β γ : Type v} (f : β → γ) (g : α → part β)\n  (hg : continuous' g) :\n  continuous' (λ x, f <$> g x) :=\nby simp only [map_eq_bind_pure_comp];\n   apply bind_continuous' _ _ hg;\n   apply const_continuous'\n\nlemma seq_continuous' {β γ : Type v} (f : α → part (β → γ)) (g : α → part β)\n  (hf : continuous' f) (hg : continuous' g) :\n  continuous' (λ x, f x <*> g x) :=\nby simp only [seq_eq_bind_map];\n   apply bind_continuous' _ _ hf;\n   apply pi.omega_complete_partial_order.flip₂_continuous'; intro;\n   apply map_continuous' _ _ hg\n\nlemma continuous (F : α →𝒄 β) (C : chain α) : F (ωSup C) = ωSup (C.map F) :=\ncontinuous_hom.cont _ _\n\n/-- Construct a continuous function from a bare function, a continuous function, and a proof that\nthey are equal. -/\n@[simps, reducible]\ndef of_fun (f : α → β) (g : α →𝒄 β) (h : f = g) : α →𝒄 β :=\nby refine {to_order_hom := {to_fun := f, ..}, ..}; subst h; rcases g with ⟨⟨⟩⟩; assumption\n\n/-- Construct a continuous function from a monotone function with a proof of continuity. -/\n@[simps, reducible]\ndef of_mono (f : α →o β) (h : ∀ c : chain α, f (ωSup c) = ωSup (c.map f)) : α →𝒄 β :=\n{ to_fun := f,\n  monotone' := f.monotone,\n  cont := h }\n\n/-- The identity as a continuous function. -/\n@[simps]\ndef id : α →𝒄 α :=\nof_mono order_hom.id continuous_id\n\n/-- The composition of continuous functions. -/\n@[simps]\ndef comp (f : β →𝒄 γ) (g : α →𝒄 β) : α →𝒄 γ :=\nof_mono (order_hom.comp (↑f) (↑g)) (continuous_comp _ _ g.cont f.cont)\n\n@[ext]\nprotected lemma ext (f g : α →𝒄 β) (h : ∀ x, f x = g x) : f = g :=\nby cases f; cases g; congr; ext; apply h\n\nprotected lemma coe_inj (f g : α →𝒄 β) (h : (f : α → β) = g) : f = g :=\ncontinuous_hom.ext _ _ $ _root_.congr_fun h\n\n@[simp]\nlemma comp_id (f : β →𝒄 γ) : f.comp id = f := by ext; refl\n\n@[simp]\nlemma id_comp (f : β →𝒄 γ) : id.comp f = f := by ext; refl\n\n@[simp]\nlemma comp_assoc (f : γ →𝒄 φ) (g : β →𝒄 γ) (h : α →𝒄 β) : f.comp (g.comp h) = (f.comp g).comp h :=\nby ext; refl\n\n@[simp]\nlemma coe_apply (a : α) (f : α →𝒄 β) : (f : α →o β) a = f a := rfl\n\n/-- `function.const` is a continuous function. -/\ndef const (x : β) : α →𝒄 β :=\nof_mono (order_hom.const _ x) (continuous_const x)\n\n@[simp] theorem const_apply (f : β) (a : α) : const f a = f := rfl\n\ninstance [inhabited β] : inhabited (α →𝒄 β) :=\n⟨ const default ⟩\n\n\n/-- The map from continuous functions to monotone functions is itself a monotone function. -/\n@[simps]\ndef to_mono : (α →𝒄 β) →o (α →o β) :=\n{ to_fun := λ f, f,\n  monotone' := λ x y h, h }\n\n/-- When proving that a chain of applications is below a bound `z`, it suffices to consider the\nfunctions and values being selected from the same index in the chains.\n\nThis lemma is more specific than necessary, i.e. `c₀` only needs to be a\nchain of monotone functions, but it is only used with continuous functions. -/\n@[simp]\nlemma forall_forall_merge (c₀ : chain (α →𝒄 β)) (c₁ : chain α) (z : β) :\n  (∀ (i j : ℕ), (c₀ i) (c₁ j) ≤ z) ↔ ∀ (i : ℕ), (c₀ i) (c₁ i) ≤ z :=\nbegin\n  split; introv h,\n  { apply h },\n  { apply le_trans _ (h (max i j)),\n    transitivity c₀ i (c₁ (max i j)),\n    { apply (c₀ i).monotone, apply c₁.monotone, apply le_max_right },\n    { apply c₀.monotone, apply le_max_left } }\nend\n\n@[simp]\nlemma forall_forall_merge' (c₀ : chain (α →𝒄 β)) (c₁ : chain α) (z : β) :\n  (∀ (j i : ℕ), (c₀ i) (c₁ j) ≤ z) ↔ ∀ (i : ℕ), (c₀ i) (c₁ i) ≤ z :=\nby rw [forall_swap,forall_forall_merge]\n\n/-- The `ωSup` operator for continuous functions, which takes the pointwise countable supremum\nof the functions in the `ω`-chain. -/\n@[simps]\nprotected def ωSup (c : chain (α →𝒄 β)) : α →𝒄 β :=\ncontinuous_hom.of_mono (ωSup $ c.map to_mono)\nbegin\n  intro c',\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [ωSup_le_iff, (c _).continuous, chain.map_coe, order_hom.apply_coe,\n    to_mono_coe, coe_apply, order_hom.omega_complete_partial_order_ωSup_coe,\n    forall_forall_merge, forall_forall_merge', (∘), function.eval],\nend\n\n@[simps ωSup]\ninstance : omega_complete_partial_order (α →𝒄 β) :=\nomega_complete_partial_order.lift continuous_hom.to_mono continuous_hom.ωSup\n  (λ x y h, h) (λ c, rfl)\n\nnamespace prod\n\n/-- The application of continuous functions as a continuous function.  -/\n@[simps]\ndef apply : (α →𝒄 β) × α →𝒄 β :=\n{ to_fun := λ f, f.1 f.2,\n  monotone' := λ x y h, by {dsimp, transitivity y.fst x.snd; [apply h.1, apply y.1.monotone h.2]},\n  cont := begin\n    intro c,\n    apply le_antisymm,\n    { apply ωSup_le, intros i,\n      dsimp,\n      rw (c _).fst.continuous,\n      apply ωSup_le, intros j,\n      apply le_ωSup_of_le (max i j),\n      apply apply_mono,\n      exact monotone_fst (order_hom.mono _ (le_max_left _ _)),\n      exact monotone_snd (order_hom.mono _ (le_max_right _ _)), },\n    { apply ωSup_le, intros i,\n      apply le_ωSup_of_le i,\n      dsimp,\n      apply order_hom.mono _,\n      apply le_ωSup_of_le i,\n      reflexivity, }\n  end }\n\nend prod\n\nlemma ωSup_def (c : chain (α →𝒄 β)) (x : α) : ωSup c x = continuous_hom.ωSup c x := rfl\n\nlemma ωSup_apply_ωSup (c₀ : chain (α →𝒄 β)) (c₁ : chain α) :\n  ωSup c₀ (ωSup c₁) = prod.apply (ωSup (c₀.zip c₁)) :=\nby simp [prod.apply_apply, prod.ωSup_zip]\n\n/-- A family of continuous functions yields a continuous family of functions. -/\n@[simps]\ndef flip {α : Type*} (f : α → β →𝒄 γ) : β →𝒄 α → γ :=\n{ to_fun := λ x y, f y x,\n  monotone' := λ x y h a, (f a).monotone h,\n  cont := by intro; ext; change f x _ = _; rw [(f x).continuous ]; refl, }\n\n/-- `part.bind` as a continuous function. -/\n@[simps { rhs_md := reducible }]\nnoncomputable def bind {β γ : Type v}\n  (f : α →𝒄 part β) (g : α →𝒄 β → part γ) : α →𝒄 part γ :=\nof_mono (order_hom.bind (↑f) (↑g)) $ λ c, begin\n  rw [order_hom.bind, ← order_hom.bind, ωSup_bind, ← f.continuous, ← g.continuous],\n  refl\nend\n\n/-- `part.map` as a continuous function. -/\n@[simps {rhs_md := reducible}]\nnoncomputable def map {β γ : Type v} (f : β → γ) (g : α →𝒄 part β) : α →𝒄 part γ :=\nof_fun (λ x, f <$> g x) (bind g (const (pure ∘ f))) $\nby ext; simp only [map_eq_bind_pure_comp, bind_apply, order_hom.bind_coe, const_apply,\n  order_hom.const_coe_coe, coe_apply]\n\n/-- `part.seq` as a continuous function. -/\n@[simps {rhs_md := reducible}]\nnoncomputable def seq {β γ : Type v} (f : α →𝒄 part (β → γ)) (g : α →𝒄 part β) :\n  α →𝒄 part γ :=\nof_fun (λ x, f x <*> g x) (bind f $ (flip $ _root_.flip map g))\n  (by ext; simp only [seq_eq_bind_map, flip, part.bind_eq_bind, map_apply, part.mem_bind_iff,\n                      bind_apply, order_hom.bind_coe, coe_apply, flip_apply]; refl)\n\nend continuous_hom\n\nend omega_complete_partial_order\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/order/omega_complete_partial_order.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.46040136167048035}}
{"text": "namespace Foo\n\ndef y := 10\n\ndef _root_.Bla.f (x : Nat) := x + y\n\n#check Bla.f\n\nexample : Bla.f 5 = 15 := rfl\n\ndef _root_.g (x : Nat) :=\n  match x with\n  | 0 => 1\n  | x+1 => 2*g x\n\ndef _root_.Boo.g (x : Nat) :=\n  match x with\n  | 0 => 1\n  | x+1 => 3 * Boo.g x\n\nprotected def _root_.h (x : Nat) := x -- Error\n\nexample : g 3 = 8 := rfl\n\nexample : Boo.g 2 = 9 := rfl\n\nend Foo\n\ndef _root_ (y : Nat) := y + 1 -- Error\n\ndef _root_._root_ (y : Nat) := y -- Error\n\ndef _root_.f._root_ (y : Nat) := y -- Error\n\nprotected def _root_.h (x : Nat) := x -- Error\n\nprotected def _root_.Boo.h (x : Nat) := x\n\nexample : Boo.h x = x := rfl\n\n#check h -- Error\n\n#check f -- Error\n\nopen Bla\n\n#check f -- Ok\n\nnamespace Test\n\nmutual\n\n  def _root_.isEven (x : Nat) :=\n    match x with\n    | 0 => true\n    | x+1 => isOdd x\n\n  def _root_.isOdd (x : Nat) :=\n    match x with\n    | 0 => false\n    | x+1 => isEven x\n\nend\n\nprivate def _root_.prv (x : Nat) := x + x + x\n\nexample : prv 5 = 15 := rfl\n\nend Test\n\nexample : isEven 0  = true := by simp! [isOdd, isEven]\nexample : isOdd 1   = true := by simp! [isOdd, isEven]\nexample : isEven 2  = true := by simp! [isOdd, isEven]\n\nexample : prv 5 = 15 := rfl\n\nset_option pp.raw true in\n#check prv\n\nnamespace Ex\n\n@[scoped simp] theorem _root_.isEven_of_isOdd (x : Nat) : isEven (x+1) = isOdd x := by simp [isEven]\n\n@[scoped simp] theorem _root_.isOdd_of_isEven (x : Nat) : isOdd (x+1) = isEven x := by simp [isOdd]\n\nexample : isEven (x+1+1) = isEven x := by simp -- Ok\n\nend Ex\n\nexample : isEven (x+1+1) = isEven x := by simp; done -- Error\n\nopen Ex in\nexample : isEven (x+1+1) = isEven x := by simp -- Ok\n\nexample : isEven (x+1+1) = isEven x := by simp; done -- Error\n\nnamespace Foo\n\ndef _root_.Bla.g (x : Nat) : Nat :=\n  match x with\n  | 0 => 1\n  | .succ x => h x + g x\nwhere\n  h (x : Nat) :=\n    match x with\n    | 0 => 2\n    | .succ x => 2 * g x\n\n\ndef _root_.Bla.g' (x : Nat) : Nat :=\n  match x with\n  | 0 => 1\n  | .succ x => g' x\n\nend Foo\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/root.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.46040135285707795}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module data.quot\n! leanprover-community/mathlib commit 6ed6abbde29b8f630001a1b481603f657a3384f1\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Logic.Relator\n\n/-!\n# Quotient types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis module extends the core library's treatment of quotient types (`init.data.quot`).\n\n## Tags\n\nquotient\n-/\n\n\nvariable {α : Sort _} {β : Sort _}\n\nopen Function\n\nnamespace Setoid\n\n#print Setoid.ext /-\ntheorem ext {α : Sort _} :\n    ∀ {s t : Setoid α}, (∀ a b, @Setoid.r α s a b ↔ @Setoid.r α t a b) → s = t\n  | ⟨r, _⟩, ⟨p, _⟩, Eq =>\n    by\n    have : r = p := funext fun a => funext fun b => propext <| Eq a b\n    subst this\n#align setoid.ext Setoid.ext\n-/\n\nend Setoid\n\nnamespace Quot\n\nvariable {ra : α → α → Prop} {rb : β → β → Prop} {φ : Quot ra → Quot rb → Sort _}\n\n-- mathport name: mk\nlocal notation:arg \"⟦\" a \"⟧\" => Quot.mk _ a\n\ninstance (r : α → α → Prop) [Inhabited α] : Inhabited (Quot r) :=\n  ⟨⟦default⟧⟩\n\ninstance [Subsingleton α] : Subsingleton (Quot ra) :=\n  ⟨fun x => Quot.inductionOn x fun y => Quot.ind fun b => congr_arg _ (Subsingleton.elim _ _)⟩\n\n#print Quot.hrecOn₂ /-\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrecOn₂ (qa : Quot ra) (qb : Quot rb) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧)\n    (ca : ∀ {b a₁ a₂}, ra a₁ a₂ → HEq (f a₁ b) (f a₂ b))\n    (cb : ∀ {a b₁ b₂}, rb b₁ b₂ → HEq (f a b₁) (f a b₂)) : φ qa qb :=\n  Quot.hrecOn qa (fun a => Quot.hrecOn qb (f a) fun b₁ b₂ pb => cb pb) fun a₁ a₂ pa =>\n    Quot.inductionOn qb fun b =>\n      calc\n        HEq (@Quot.hrecOn _ _ (φ _) ⟦b⟧ (f a₁) (@cb _)) (f a₁ b) := by simp [hEq_self_iff_true]\n        HEq _ (f a₂ b) := (ca pa)\n        HEq _ (@Quot.hrecOn _ _ (φ _) ⟦b⟧ (f a₂) (@cb _)) := by simp [hEq_self_iff_true]\n        \n#align quot.hrec_on₂ Quot.hrecOn₂\n-/\n\n#print Quot.map /-\n/-- Map a function `f : α → β` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra → quot rb`. -/\nprotected def map (f : α → β) (h : (ra ⇒ rb) f f) : Quot ra → Quot rb :=\n  Quot.lift (fun x => ⟦f x⟧) fun x y (h₁ : ra x y) => Quot.sound <| h h₁\n#align quot.map Quot.map\n-/\n\n#print Quot.mapRight /-\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `quot ra → quot ra'`. -/\nprotected def mapRight {ra' : α → α → Prop} (h : ∀ a₁ a₂, ra a₁ a₂ → ra' a₁ a₂) :\n    Quot ra → Quot ra' :=\n  Quot.map id h\n#align quot.map_right Quot.mapRight\n-/\n\n#print Quot.factor /-\n/-- Weaken the relation of a quotient. This is the same as `quot.map id`. -/\ndef factor {α : Type _} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) : Quot r → Quot s :=\n  Quot.lift (Quot.mk s) fun x y rxy => Quot.sound (h x y rxy)\n#align quot.factor Quot.factor\n-/\n\n#print Quot.factor_mk_eq /-\ntheorem factor_mk_eq {α : Type _} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n    factor r s h ∘ Quot.mk _ = Quot.mk _ :=\n  rfl\n#align quot.factor_mk_eq Quot.factor_mk_eq\n-/\n\nvariable {γ : Sort _} {r : α → α → Prop} {s : β → β → Prop}\n\n/- warning: quot.lift_mk clashes with quot.lift_beta -> Quot.lift_mk\nCase conversion may be inaccurate. Consider using '#align quot.lift_mk Quot.lift_mkₓ'. -/\n#print Quot.lift_mk /-\n/-- **Alias** of `quot.lift_beta`. -/\ntheorem lift_mk (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) (a : α) :\n    Quot.lift f h (Quot.mk r a) = f a :=\n  rfl\n#align quot.lift_mk Quot.lift_mk\n-/\n\n#print Quot.liftOn_mk /-\n@[simp]\ntheorem liftOn_mk (a : α) (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :\n    Quot.liftOn (Quot.mk r a) f h = f a :=\n  rfl\n#align quot.lift_on_mk Quot.liftOn_mk\n-/\n\n#print Quot.surjective_lift /-\n@[simp]\ntheorem surjective_lift {f : α → γ} (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :\n    Surjective (lift f h) ↔ Surjective f :=\n  ⟨fun hf => hf.comp Quot.exists_rep, fun hf y =>\n    let ⟨x, hx⟩ := hf y\n    ⟨Quot.mk _ x, hx⟩⟩\n#align quot.surjective_lift Quot.surjective_lift\n-/\n\n#print Quot.lift₂ /-\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β`. -/\n@[reducible, elab_as_elim]\nprotected def lift₂ (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) (q₁ : Quot r) (q₂ : Quot s) : γ :=\n  Quot.lift (fun a => Quot.lift (f a) (hr a))\n    (fun a₁ a₂ ha => funext fun q => Quot.inductionOn q fun b => hs a₁ a₂ b ha) q₁ q₂\n#align quot.lift₂ Quot.lift₂\n-/\n\n/- warning: quot.lift₂_mk -> Quot.lift₂_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {r : α -> α -> Prop} {s : β -> β -> Prop} (f : α -> β -> γ) (hr : forall (a : α) (b₁ : β) (b₂ : β), (s b₁ b₂) -> (Eq.{u3} γ (f a b₁) (f a b₂))) (hs : forall (a₁ : α) (a₂ : α) (b : β), (r a₁ a₂) -> (Eq.{u3} γ (f a₁ b) (f a₂ b))) (a : α) (b : β), Eq.{u3} γ (Quot.lift₂.{u1, u2, u3} α β γ (fun (a₁ : α) (a₂ : α) => r a₁ a₂) (fun (b₁ : β) (b₂ : β) => s b₁ b₂) f hr hs (Quot.mk.{u1} α r a) (Quot.mk.{u2} β s b)) (f a b)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {γ : Sort.{u3}} {r : α -> α -> Prop} {s : β -> β -> Prop} (f : α -> β -> γ) (hr : forall (a : α) (b₁ : β) (b₂ : β), (s b₁ b₂) -> (Eq.{u3} γ (f a b₁) (f a b₂))) (hs : forall (a₁ : α) (a₂ : α) (b : β), (r a₁ a₂) -> (Eq.{u3} γ (f a₁ b) (f a₂ b))) (a : α) (b : β), Eq.{u3} γ (Quot.lift₂.{u2, u1, u3} α β γ (fun (a₁ : α) (a₂ : α) => r a₁ a₂) (fun (b₁ : β) (b₂ : β) => s b₁ b₂) f hr hs (Quot.mk.{u2} α r a) (Quot.mk.{u1} β s b)) (f a b)\nCase conversion may be inaccurate. Consider using '#align quot.lift₂_mk Quot.lift₂_mkₓ'. -/\n@[simp]\ntheorem lift₂_mk (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) (a : α) (b : β) :\n    Quot.lift₂ f hr hs (Quot.mk r a) (Quot.mk s b) = f a b :=\n  rfl\n#align quot.lift₂_mk Quot.lift₂_mk\n\n#print Quot.liftOn₂ /-\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` and applies it. -/\n@[reducible, elab_as_elim]\nprotected def liftOn₂ (p : Quot r) (q : Quot s) (f : α → β → γ)\n    (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂) (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) : γ :=\n  Quot.lift₂ f hr hs p q\n#align quot.lift_on₂ Quot.liftOn₂\n-/\n\n/- warning: quot.lift_on₂_mk -> Quot.liftOn₂_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {r : α -> α -> Prop} {s : β -> β -> Prop} (a : α) (b : β) (f : α -> β -> γ) (hr : forall (a : α) (b₁ : β) (b₂ : β), (s b₁ b₂) -> (Eq.{u3} γ (f a b₁) (f a b₂))) (hs : forall (a₁ : α) (a₂ : α) (b : β), (r a₁ a₂) -> (Eq.{u3} γ (f a₁ b) (f a₂ b))), Eq.{u3} γ (Quot.liftOn₂.{u1, u2, u3} α β γ r s (Quot.mk.{u1} α r a) (Quot.mk.{u2} β s b) f hr hs) (f a b)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {γ : Sort.{u3}} {r : α -> α -> Prop} {s : β -> β -> Prop} (a : α) (b : β) (f : α -> β -> γ) (hr : forall (a : α) (b₁ : β) (b₂ : β), (s b₁ b₂) -> (Eq.{u3} γ (f a b₁) (f a b₂))) (hs : forall (a₁ : α) (a₂ : α) (b : β), (r a₁ a₂) -> (Eq.{u3} γ (f a₁ b) (f a₂ b))), Eq.{u3} γ (Quot.liftOn₂.{u2, u1, u3} α β γ r s (Quot.mk.{u2} α r a) (Quot.mk.{u1} β s b) f hr hs) (f a b)\nCase conversion may be inaccurate. Consider using '#align quot.lift_on₂_mk Quot.liftOn₂_mkₓ'. -/\n@[simp]\ntheorem liftOn₂_mk (a : α) (b : β) (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) :\n    Quot.liftOn₂ (Quot.mk r a) (Quot.mk s b) f hr hs = f a b :=\n  rfl\n#align quot.lift_on₂_mk Quot.liftOn₂_mk\n\nvariable {t : γ → γ → Prop}\n\n#print Quot.map₂ /-\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` wih values in a quotient of\n`γ`. -/\nprotected def map₂ (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b)) (q₁ : Quot r) (q₂ : Quot s) : Quot t :=\n  Quot.lift₂ (fun a b => Quot.mk t <| f a b) (fun a b₁ b₂ hb => Quot.sound (hr a b₁ b₂ hb))\n    (fun a₁ a₂ b ha => Quot.sound (hs a₁ a₂ b ha)) q₁ q₂\n#align quot.map₂ Quot.map₂\n-/\n\n/- warning: quot.map₂_mk -> Quot.map₂_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {r : α -> α -> Prop} {s : β -> β -> Prop} {t : γ -> γ -> Prop} (f : α -> β -> γ) (hr : forall (a : α) (b₁ : β) (b₂ : β), (s b₁ b₂) -> (t (f a b₁) (f a b₂))) (hs : forall (a₁ : α) (a₂ : α) (b : β), (r a₁ a₂) -> (t (f a₁ b) (f a₂ b))) (a : α) (b : β), Eq.{u3} (Quot.{u3} γ t) (Quot.map₂.{u1, u2, u3} α β γ (fun (a₁ : α) (a₂ : α) => r a₁ a₂) (fun (b₁ : β) (b₂ : β) => s b₁ b₂) t f hr hs (Quot.mk.{u1} α r a) (Quot.mk.{u2} β s b)) (Quot.mk.{u3} γ t (f a b))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {γ : Sort.{u3}} {r : α -> α -> Prop} {s : β -> β -> Prop} {t : γ -> γ -> Prop} (f : α -> β -> γ) (hr : forall (a : α) (b₁ : β) (b₂ : β), (s b₁ b₂) -> (t (f a b₁) (f a b₂))) (hs : forall (a₁ : α) (a₂ : α) (b : β), (r a₁ a₂) -> (t (f a₁ b) (f a₂ b))) (a : α) (b : β), Eq.{u3} (Quot.{u3} γ t) (Quot.map₂.{u2, u1, u3} α β γ (fun (a₁ : α) (a₂ : α) => r a₁ a₂) (fun (b₁ : β) (b₂ : β) => s b₁ b₂) t f hr hs (Quot.mk.{u2} α r a) (Quot.mk.{u1} β s b)) (Quot.mk.{u3} γ t (f a b))\nCase conversion may be inaccurate. Consider using '#align quot.map₂_mk Quot.map₂_mkₓ'. -/\n@[simp]\ntheorem map₂_mk (f : α → β → γ) (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n    (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b)) (a : α) (b : β) :\n    Quot.map₂ f hr hs (Quot.mk r a) (Quot.mk s b) = Quot.mk t (f a b) :=\n  rfl\n#align quot.map₂_mk Quot.map₂_mk\n\n#print Quot.recOnSubsingleton₂ /-\n/-- A binary version of `quot.rec_on_subsingleton`. -/\n@[reducible, elab_as_elim]\nprotected def recOnSubsingleton₂ {φ : Quot r → Quot s → Sort _}\n    [h : ∀ a b, Subsingleton (φ ⟦a⟧ ⟦b⟧)] (q₁ : Quot r) (q₂ : Quot s) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧) :\n    φ q₁ q₂ :=\n  @Quot.recOnSubsingleton' _ r (fun q => φ q q₂) (fun a => Quot.ind (h a) q₂) q₁ fun a =>\n    Quot.recOnSubsingleton' q₂ fun b => f a b\n#align quot.rec_on_subsingleton₂ Quot.recOnSubsingleton₂\n-/\n\n/- warning: quot.induction_on₂ -> Quot.induction_on₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {r : α -> α -> Prop} {s : β -> β -> Prop} {δ : (Quot.{u1} α r) -> (Quot.{u2} β s) -> Prop} (q₁ : Quot.{u1} α r) (q₂ : Quot.{u2} β s), (forall (a : α) (b : β), δ (Quot.mk.{u1} α r a) (Quot.mk.{u2} β s b)) -> (δ q₁ q₂)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {r : α -> α -> Prop} {s : β -> β -> Prop} {δ : (Quot.{u2} α r) -> (Quot.{u1} β s) -> Prop} (q₁ : Quot.{u2} α r) (q₂ : Quot.{u1} β s), (forall (a : α) (b : β), δ (Quot.mk.{u2} α r a) (Quot.mk.{u1} β s b)) -> (δ q₁ q₂)\nCase conversion may be inaccurate. Consider using '#align quot.induction_on₂ Quot.induction_on₂ₓ'. -/\n@[elab_as_elim]\nprotected theorem induction_on₂ {δ : Quot r → Quot s → Prop} (q₁ : Quot r) (q₂ : Quot s)\n    (h : ∀ a b, δ (Quot.mk r a) (Quot.mk s b)) : δ q₁ q₂ :=\n  Quot.ind (fun a₁ => Quot.ind (fun a₂ => h a₁ a₂) q₂) q₁\n#align quot.induction_on₂ Quot.induction_on₂\n\n/- warning: quot.induction_on₃ -> Quot.induction_on₃ is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {r : α -> α -> Prop} {s : β -> β -> Prop} {t : γ -> γ -> Prop} {δ : (Quot.{u1} α r) -> (Quot.{u2} β s) -> (Quot.{u3} γ t) -> Prop} (q₁ : Quot.{u1} α r) (q₂ : Quot.{u2} β s) (q₃ : Quot.{u3} γ t), (forall (a : α) (b : β) (c : γ), δ (Quot.mk.{u1} α r a) (Quot.mk.{u2} β s b) (Quot.mk.{u3} γ t c)) -> (δ q₁ q₂ q₃)\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {γ : Sort.{u1}} {r : α -> α -> Prop} {s : β -> β -> Prop} {t : γ -> γ -> Prop} {δ : (Quot.{u3} α r) -> (Quot.{u2} β s) -> (Quot.{u1} γ t) -> Prop} (q₁ : Quot.{u3} α r) (q₂ : Quot.{u2} β s) (q₃ : Quot.{u1} γ t), (forall (a : α) (b : β) (c : γ), δ (Quot.mk.{u3} α r a) (Quot.mk.{u2} β s b) (Quot.mk.{u1} γ t c)) -> (δ q₁ q₂ q₃)\nCase conversion may be inaccurate. Consider using '#align quot.induction_on₃ Quot.induction_on₃ₓ'. -/\n@[elab_as_elim]\nprotected theorem induction_on₃ {δ : Quot r → Quot s → Quot t → Prop} (q₁ : Quot r) (q₂ : Quot s)\n    (q₃ : Quot t) (h : ∀ a b c, δ (Quot.mk r a) (Quot.mk s b) (Quot.mk t c)) : δ q₁ q₂ q₃ :=\n  Quot.ind (fun a₁ => Quot.ind (fun a₂ => Quot.ind (fun a₃ => h a₁ a₂ a₃) q₃) q₂) q₁\n#align quot.induction_on₃ Quot.induction_on₃\n\ninstance (r : α → α → Prop) (f : α → Prop) (h : ∀ a b, r a b → f a = f b) [hf : DecidablePred f] :\n    DecidablePred (Quot.lift f h) := fun q => Quot.recOnSubsingleton' q hf\n\n/-- Note that this provides `decidable_rel (quot.lift₂ f ha hb)` when `α = β`. -/\ninstance (r : α → α → Prop) (s : β → β → Prop) (f : α → β → Prop)\n    (ha : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂) (hb : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n    [hf : ∀ a, DecidablePred (f a)] (q₁ : Quot r) : DecidablePred (Quot.lift₂ f ha hb q₁) :=\n  fun q₂ => Quot.recOnSubsingleton₂ q₁ q₂ hf\n\ninstance (r : α → α → Prop) (q : Quot r) (f : α → Prop) (h : ∀ a b, r a b → f a = f b)\n    [DecidablePred f] : Decidable (Quot.liftOn q f h) :=\n  Quot.lift.decidablePred _ _ _ _\n\ninstance (r : α → α → Prop) (s : β → β → Prop) (q₁ : Quot r) (q₂ : Quot s) (f : α → β → Prop)\n    (ha : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂) (hb : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n    [∀ a, DecidablePred (f a)] : Decidable (Quot.liftOn₂ q₁ q₂ f ha hb) :=\n  Quot.lift₂.decidablePred _ _ _ _ _ _ _\n\nend Quot\n\nnamespace Quotient\n\nvariable [sa : Setoid α] [sb : Setoid β]\n\nvariable {φ : Quotient sa → Quotient sb → Sort _}\n\ninstance (s : Setoid α) [Inhabited α] : Inhabited (Quotient s) :=\n  ⟨⟦default⟧⟩\n\ninstance (s : Setoid α) [Subsingleton α] : Subsingleton (Quotient s) :=\n  Quot.Subsingleton\n\ninstance {α : Type _} [Setoid α] : IsEquiv α (· ≈ ·)\n    where\n  refl := Setoid.refl\n  symm a b := Setoid.symm\n  trans a b c := Setoid.trans\n\n#print Quotient.hrecOn₂ /-\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrecOn₂ (qa : Quotient sa) (qb : Quotient sb) (f : ∀ a b, φ ⟦a⟧ ⟦b⟧)\n    (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → HEq (f a₁ b₁) (f a₂ b₂)) : φ qa qb :=\n  Quot.hrecOn₂ qa qb f (fun _ _ _ p => c _ _ _ _ p (Setoid.refl _)) fun _ _ _ p =>\n    c _ _ _ _ (Setoid.refl _) p\n#align quotient.hrec_on₂ Quotient.hrecOn₂\n-/\n\n#print Quotient.map /-\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : α → β) (h : ((· ≈ ·) ⇒ (· ≈ ·)) f f) : Quotient sa → Quotient sb :=\n  Quot.map f h\n#align quotient.map Quotient.map\n-/\n\n/- warning: quotient.map_mk -> Quotient.map_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [sa : Setoid.{u1} α] [sb : Setoid.{u2} β] (f : α -> β) (h : Relator.LiftFun.{u1, u1, u2, u2} α α β β (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α sa)) (HasEquivₓ.Equiv.{u2} β (setoidHasEquiv.{u2} β sb)) f f) (x : α), Eq.{u2} (Quotient.{u2} β sb) (Quotient.map.{u1, u2} α β sa sb f h (Quotient.mk'.{u1} α sa x)) (Quotient.mk'.{u2} β sb (f x))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [sa : Setoid.{u2} α] [sb : Setoid.{u1} β] (f : α -> β) (h : Relator.LiftFun.{u2, u2, u1, u1} α α β β (fun (x._@.Mathlib.Data.Quot._hyg.4515 : α) (x._@.Mathlib.Data.Quot._hyg.4517 : α) => HasEquiv.Equiv.{u2, 0} α (instHasEquiv.{u2} α sa) x._@.Mathlib.Data.Quot._hyg.4515 x._@.Mathlib.Data.Quot._hyg.4517) (fun (x._@.Mathlib.Data.Quot._hyg.4530 : β) (x._@.Mathlib.Data.Quot._hyg.4532 : β) => HasEquiv.Equiv.{u1, 0} β (instHasEquiv.{u1} β sb) x._@.Mathlib.Data.Quot._hyg.4530 x._@.Mathlib.Data.Quot._hyg.4532) f f) (x : α), Eq.{u1} (Quotient.{u1} β sb) (Quotient.map.{u2, u1} α β sa sb f h (Quotient.mk.{u2} α sa x)) (Quotient.mk.{u1} β sb (f x))\nCase conversion may be inaccurate. Consider using '#align quotient.map_mk Quotient.map_mkₓ'. -/\n@[simp]\ntheorem map_mk (f : α → β) (h : ((· ≈ ·) ⇒ (· ≈ ·)) f f) (x : α) :\n    Quotient.map f h (⟦x⟧ : Quotient sa) = (⟦f x⟧ : Quotient sb) :=\n  rfl\n#align quotient.map_mk Quotient.map_mk\n\nvariable {γ : Sort _} [sc : Setoid γ]\n\n#print Quotient.map₂ /-\n/-- Map a function `f : α → β → γ` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa → quotient sb → quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map₂ (f : α → β → γ) (h : ((· ≈ ·) ⇒ (· ≈ ·) ⇒ (· ≈ ·)) f f) :\n    Quotient sa → Quotient sb → Quotient sc :=\n  Quotient.lift₂ (fun x y => ⟦f x y⟧) fun x₁ y₁ x₂ y₂ h₁ h₂ => Quot.sound <| h h₁ h₂\n#align quotient.map₂ Quotient.map₂\n-/\n\n/- warning: quotient.map₂_mk -> Quotient.map₂_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [sa : Setoid.{u1} α] [sb : Setoid.{u2} β] {γ : Sort.{u3}} [sc : Setoid.{u3} γ] (f : α -> β -> γ) (h : Relator.LiftFun.{u1, u1, imax u2 u3, imax u2 u3} α α (β -> γ) (β -> γ) (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α sa)) (Relator.LiftFun.{u2, u2, u3, u3} β β γ γ (HasEquivₓ.Equiv.{u2} β (setoidHasEquiv.{u2} β sb)) (HasEquivₓ.Equiv.{u3} γ (setoidHasEquiv.{u3} γ sc))) f f) (x : α) (y : β), Eq.{u3} (Quotient.{u3} γ sc) (Quotient.map₂.{u1, u2, u3} α β sa sb γ sc f h (Quotient.mk'.{u1} α sa x) (Quotient.mk'.{u2} β sb y)) (Quotient.mk'.{u3} γ sc (f x y))\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} [sa : Setoid.{u3} α] [sb : Setoid.{u2} β] {γ : Sort.{u1}} [sc : Setoid.{u1} γ] (f : α -> β -> γ) (h : Relator.LiftFun.{u3, u3, imax u2 u1, imax u2 u1} α α (β -> γ) (β -> γ) (fun (x._@.Mathlib.Data.Quot._hyg.4742 : α) (x._@.Mathlib.Data.Quot._hyg.4744 : α) => HasEquiv.Equiv.{u3, 0} α (instHasEquiv.{u3} α sa) x._@.Mathlib.Data.Quot._hyg.4742 x._@.Mathlib.Data.Quot._hyg.4744) (Relator.LiftFun.{u2, u2, u1, u1} β β γ γ (fun (x._@.Mathlib.Data.Quot._hyg.4760 : β) (x._@.Mathlib.Data.Quot._hyg.4762 : β) => HasEquiv.Equiv.{u2, 0} β (instHasEquiv.{u2} β sb) x._@.Mathlib.Data.Quot._hyg.4760 x._@.Mathlib.Data.Quot._hyg.4762) (fun (x._@.Mathlib.Data.Quot._hyg.4775 : γ) (x._@.Mathlib.Data.Quot._hyg.4777 : γ) => HasEquiv.Equiv.{u1, 0} γ (instHasEquiv.{u1} γ sc) x._@.Mathlib.Data.Quot._hyg.4775 x._@.Mathlib.Data.Quot._hyg.4777)) f f) (x : α) (y : β), Eq.{u1} (Quotient.{u1} γ sc) (Quotient.map₂.{u3, u2, u1} α β sa sb γ sc f h (Quotient.mk.{u3} α sa x) (Quotient.mk.{u2} β sb y)) (Quotient.mk.{u1} γ sc (f x y))\nCase conversion may be inaccurate. Consider using '#align quotient.map₂_mk Quotient.map₂_mkₓ'. -/\n@[simp]\ntheorem map₂_mk (f : α → β → γ) (h : ((· ≈ ·) ⇒ (· ≈ ·) ⇒ (· ≈ ·)) f f) (x : α) (y : β) :\n    Quotient.map₂ f h (⟦x⟧ : Quotient sa) (⟦y⟧ : Quotient sb) = (⟦f x y⟧ : Quotient sc) :=\n  rfl\n#align quotient.map₂_mk Quotient.map₂_mk\n\ninclude sa\n\ninstance (f : α → Prop) (h : ∀ a b, a ≈ b → f a = f b) [DecidablePred f] :\n    DecidablePred (Quotient.lift f h) :=\n  Quot.lift.decidablePred _ _ _\n\ninclude sb\n\n/-- Note that this provides `decidable_rel (quotient.lift₂ f h)` when `α = β`. -/\ninstance (f : α → β → Prop) (h : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ = f a₂ b₂)\n    [hf : ∀ a, DecidablePred (f a)] (q₁ : Quotient sa) : DecidablePred (Quotient.lift₂ f h q₁) :=\n  fun q₂ => Quotient.recOnSubsingleton₂ q₁ q₂ hf\n\nomit sb\n\ninstance (q : Quotient sa) (f : α → Prop) (h : ∀ a b, a ≈ b → f a = f b) [DecidablePred f] :\n    Decidable (Quotient.liftOn q f h) :=\n  Quotient.lift.decidablePred _ _ _\n\ninstance (q₁ : Quotient sa) (q₂ : Quotient sb) (f : α → β → Prop)\n    (h : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ = f a₂ b₂) [∀ a, DecidablePred (f a)] :\n    Decidable (Quotient.liftOn₂ q₁ q₂ f h) :=\n  Quotient.lift₂.decidablePred _ _ _ _\n\nend Quotient\n\n#print Quot.eq /-\ntheorem Quot.eq {α : Type _} {r : α → α → Prop} {x y : α} :\n    Quot.mk r x = Quot.mk r y ↔ EqvGen r x y :=\n  ⟨Quot.exact r, Quot.EqvGen_sound⟩\n#align quot.eq Quot.eq\n-/\n\n#print Quotient.eq' /-\n@[simp]\ntheorem Quotient.eq' [r : Setoid α] {x y : α} : ⟦x⟧ = ⟦y⟧ ↔ x ≈ y :=\n  ⟨Quotient.exact, Quotient.sound⟩\n#align quotient.eq Quotient.eq'\n-/\n\n#print forall_quotient_iff /-\ntheorem forall_quotient_iff {α : Type _} [r : Setoid α] {p : Quotient r → Prop} :\n    (∀ a : Quotient r, p a) ↔ ∀ a : α, p ⟦a⟧ :=\n  ⟨fun h x => h _, fun h a => a.inductionOn h⟩\n#align forall_quotient_iff forall_quotient_iff\n-/\n\n/- warning: quotient.lift_mk -> Quotient.lift_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [s : Setoid.{u1} α] (f : α -> β) (h : forall (a : α) (b : α), (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α s) a b) -> (Eq.{u2} β (f a) (f b))) (x : α), Eq.{u2} β (Quotient.lift.{u1, u2} α β s f h (Quotient.mk'.{u1} α s x)) (f x)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [s : Setoid.{u2} α] (f : α -> β) (h : forall (a : α) (b : α), (HasEquiv.Equiv.{u2, 0} α (instHasEquiv.{u2} α s) a b) -> (Eq.{u1} β (f a) (f b))) (x : α), Eq.{u1} β (Quotient.lift.{u2, u1} α β s f h (Quotient.mk.{u2} α s x)) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_mk Quotient.lift_mkₓ'. -/\n@[simp]\ntheorem Quotient.lift_mk [s : Setoid α] (f : α → β) (h : ∀ a b : α, a ≈ b → f a = f b) (x : α) :\n    Quotient.lift f h (Quotient.mk' x) = f x :=\n  rfl\n#align quotient.lift_mk Quotient.lift_mk\n\n/- warning: quotient.lift_comp_mk -> Quotient.lift_comp_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Setoid.{u1} α] (f : α -> β) (h : forall (a : α) (b : α), (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α _inst_1) a b) -> (Eq.{u2} β (f a) (f b))), Eq.{imax u1 u2} (α -> β) (Function.comp.{u1, u1, u2} α (Quotient.{u1} α _inst_1) β (Quotient.lift.{u1, u2} α β _inst_1 f h) (Quotient.mk'.{u1} α _inst_1)) f\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Setoid.{u2} α] (f : α -> β) (h : forall (a : α) (b : α), (HasEquiv.Equiv.{u2, 0} α (instHasEquiv.{u2} α _inst_1) a b) -> (Eq.{u1} β (f a) (f b))), Eq.{imax u2 u1} (α -> β) (Function.comp.{u2, u2, u1} α (Quotient.{u2} α _inst_1) β (Quotient.lift.{u2, u1} α β _inst_1 f h) (Quotient.mk.{u2} α _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align quotient.lift_comp_mk Quotient.lift_comp_mkₓ'. -/\n@[simp]\ntheorem Quotient.lift_comp_mk [Setoid α] (f : α → β) (h : ∀ a b : α, a ≈ b → f a = f b) :\n    Quotient.lift f h ∘ Quotient.mk' = f :=\n  rfl\n#align quotient.lift_comp_mk Quotient.lift_comp_mk\n\n/- warning: quotient.lift₂_mk -> Quotient.lift₂_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} [_inst_1 : Setoid.{u1} α] [_inst_2 : Setoid.{u2} β] (f : α -> β -> γ) (h : forall (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α _inst_1) a₁ b₁) -> (HasEquivₓ.Equiv.{u2} β (setoidHasEquiv.{u2} β _inst_2) a₂ b₂) -> (Eq.{u3} γ (f a₁ a₂) (f b₁ b₂))) (a : α) (b : β), Eq.{u3} γ (Quotient.lift₂.{u1, u2, u3} α β γ _inst_1 _inst_2 f h (Quotient.mk'.{u1} α _inst_1 a) (Quotient.mk'.{u2} β _inst_2 b)) (f a b)\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {γ : Sort.{u1}} [_inst_1 : Setoid.{u3} α] [_inst_2 : Setoid.{u2} β] (f : α -> β -> γ) (h : forall (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), (HasEquiv.Equiv.{u3, 0} α (instHasEquiv.{u3} α _inst_1) a₁ b₁) -> (HasEquiv.Equiv.{u2, 0} β (instHasEquiv.{u2} β _inst_2) a₂ b₂) -> (Eq.{u1} γ (f a₁ a₂) (f b₁ b₂))) (a : α) (b : β), Eq.{u1} γ (Quotient.lift₂.{u3, u2, u1} α β γ _inst_1 _inst_2 f h (Quotient.mk.{u3} α _inst_1 a) (Quotient.mk.{u2} β _inst_2 b)) (f a b)\nCase conversion may be inaccurate. Consider using '#align quotient.lift₂_mk Quotient.lift₂_mkₓ'. -/\n@[simp]\ntheorem Quotient.lift₂_mk {α : Sort _} {β : Sort _} {γ : Sort _} [Setoid α] [Setoid β]\n    (f : α → β → γ)\n    (h : ∀ (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂) (a : α)\n    (b : β) : Quotient.lift₂ f h (Quotient.mk' a) (Quotient.mk' b) = f a b :=\n  rfl\n#align quotient.lift₂_mk Quotient.lift₂_mk\n\n/- warning: quotient.lift_on_mk -> Quotient.liftOn_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [s : Setoid.{u1} α] (f : α -> β) (h : forall (a : α) (b : α), (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α s) a b) -> (Eq.{u2} β (f a) (f b))) (x : α), Eq.{u2} β (Quotient.liftOn.{u1, u2} α β s (Quotient.mk'.{u1} α s x) f h) (f x)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [s : Setoid.{u2} α] (f : α -> β) (h : forall (a : α) (b : α), (HasEquiv.Equiv.{u2, 0} α (instHasEquiv.{u2} α s) a b) -> (Eq.{u1} β (f a) (f b))) (x : α), Eq.{u1} β (Quotient.liftOn.{u2, u1} α β s (Quotient.mk.{u2} α s x) f h) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on_mk Quotient.liftOn_mkₓ'. -/\n@[simp]\ntheorem Quotient.liftOn_mk [s : Setoid α] (f : α → β) (h : ∀ a b : α, a ≈ b → f a = f b) (x : α) :\n    Quotient.liftOn (Quotient.mk' x) f h = f x :=\n  rfl\n#align quotient.lift_on_mk Quotient.liftOn_mk\n\n/- warning: quotient.lift_on₂_mk -> Quotient.liftOn₂_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Setoid.{u1} α] (f : α -> α -> β) (h : forall (a₁ : α) (a₂ : α) (b₁ : α) (b₂ : α), (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α _inst_1) a₁ b₁) -> (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α _inst_1) a₂ b₂) -> (Eq.{u2} β (f a₁ a₂) (f b₁ b₂))) (x : α) (y : α), Eq.{u2} β (Quotient.liftOn₂.{u1, u1, u2} α α β _inst_1 _inst_1 (Quotient.mk'.{u1} α _inst_1 x) (Quotient.mk'.{u1} α _inst_1 y) f h) (f x y)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Setoid.{u2} α] (f : α -> α -> β) (h : forall (a₁ : α) (a₂ : α) (b₁ : α) (b₂ : α), (HasEquiv.Equiv.{u2, 0} α (instHasEquiv.{u2} α _inst_1) a₁ b₁) -> (HasEquiv.Equiv.{u2, 0} α (instHasEquiv.{u2} α _inst_1) a₂ b₂) -> (Eq.{u1} β (f a₁ a₂) (f b₁ b₂))) (x : α) (y : α), Eq.{u1} β (Quotient.liftOn₂.{u2, u2, u1} α α β _inst_1 _inst_1 (Quotient.mk.{u2} α _inst_1 x) (Quotient.mk.{u2} α _inst_1 y) f h) (f x y)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on₂_mk Quotient.liftOn₂_mkₓ'. -/\n@[simp]\ntheorem Quotient.liftOn₂_mk {α : Sort _} {β : Sort _} [Setoid α] (f : α → α → β)\n    (h : ∀ a₁ a₂ b₁ b₂ : α, a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂) (x y : α) :\n    Quotient.liftOn₂ (Quotient.mk' x) (Quotient.mk' y) f h = f x y :=\n  rfl\n#align quotient.lift_on₂_mk Quotient.liftOn₂_mk\n\n#print surjective_quot_mk /-\n/-- `quot.mk r` is a surjective function. -/\ntheorem surjective_quot_mk (r : α → α → Prop) : Surjective (Quot.mk r) :=\n  Quot.exists_rep\n#align surjective_quot_mk surjective_quot_mk\n-/\n\n#print surjective_quotient_mk /-\n/-- `quotient.mk` is a surjective function. -/\ntheorem surjective_quotient_mk (α : Sort _) [s : Setoid α] :\n    Surjective (Quotient.mk' : α → Quotient s) :=\n  Quot.exists_rep\n#align surjective_quotient_mk surjective_quotient_mk\n-/\n\n#print Quot.out /-\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def Quot.out {r : α → α → Prop} (q : Quot r) : α :=\n  Classical.choose (Quot.exists_rep q)\n#align quot.out Quot.out\n-/\n\n/-- Unwrap the VM representation of a quotient to obtain an element of the equivalence class.\n  Computable but unsound. -/\nunsafe def quot.unquot {r : α → α → Prop} : Quot r → α :=\n  unchecked_cast\n#align quot.unquot quot.unquot\n\n#print Quot.out_eq /-\n@[simp]\ntheorem Quot.out_eq {r : α → α → Prop} (q : Quot r) : Quot.mk r q.out = q :=\n  Classical.choose_spec (Quot.exists_rep q)\n#align quot.out_eq Quot.out_eq\n-/\n\n#print Quotient.out /-\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def Quotient.out [s : Setoid α] : Quotient s → α :=\n  Quot.out\n#align quotient.out Quotient.out\n-/\n\n#print Quotient.out_eq /-\n@[simp]\ntheorem Quotient.out_eq [s : Setoid α] (q : Quotient s) : ⟦q.out⟧ = q :=\n  q.out_eq\n#align quotient.out_eq Quotient.out_eq\n-/\n\n#print Quotient.mk_out /-\ntheorem Quotient.mk_out [s : Setoid α] (a : α) : ⟦a⟧.out ≈ a :=\n  Quotient.exact (Quotient.out_eq _)\n#align quotient.mk_out Quotient.mk_out\n-/\n\n#print Quotient.mk_eq_iff_out /-\ntheorem Quotient.mk_eq_iff_out [s : Setoid α] {x : α} {y : Quotient s} :\n    ⟦x⟧ = y ↔ x ≈ Quotient.out y :=\n  by\n  refine' Iff.trans _ Quotient.eq'\n  rw [Quotient.out_eq y]\n#align quotient.mk_eq_iff_out Quotient.mk_eq_iff_out\n-/\n\n#print Quotient.eq_mk_iff_out /-\ntheorem Quotient.eq_mk_iff_out [s : Setoid α] {x : Quotient s} {y : α} :\n    x = ⟦y⟧ ↔ Quotient.out x ≈ y :=\n  by\n  refine' Iff.trans _ Quotient.eq'\n  rw [Quotient.out_eq x]\n#align quotient.eq_mk_iff_out Quotient.eq_mk_iff_out\n-/\n\n#print Quotient.out_equiv_out /-\n@[simp]\ntheorem Quotient.out_equiv_out {s : Setoid α} {x y : Quotient s} : x.out ≈ y.out ↔ x = y := by\n  rw [← Quotient.eq_mk_iff_out, Quotient.out_eq]\n#align quotient.out_equiv_out Quotient.out_equiv_out\n-/\n\n#print Quotient.out_injective /-\ntheorem Quotient.out_injective {s : Setoid α} : Injective (@Quotient.out α s) := fun a b h =>\n  Quotient.out_equiv_out.1 <| h ▸ Setoid.refl _\n#align quotient.out_injective Quotient.out_injective\n-/\n\n#print Quotient.out_inj /-\n@[simp]\ntheorem Quotient.out_inj {s : Setoid α} {x y : Quotient s} : x.out = y.out ↔ x = y :=\n  ⟨fun h => Quotient.out_injective h, fun h => h ▸ rfl⟩\n#align quotient.out_inj Quotient.out_inj\n-/\n\nsection Pi\n\n#print piSetoid /-\ninstance piSetoid {ι : Sort _} {α : ι → Sort _} [∀ i, Setoid (α i)] : Setoid (∀ i, α i)\n    where\n  R a b := ∀ i, a i ≈ b i\n  iseqv :=\n    ⟨fun a i => Setoid.refl _, fun a b h i => Setoid.symm (h _), fun a b c h₁ h₂ i =>\n      Setoid.trans (h₁ _) (h₂ _)⟩\n#align pi_setoid piSetoid\n-/\n\n#print Quotient.choice /-\n/-- Given a function `f : Π i, quotient (S i)`, returns the class of functions `Π i, α i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def Quotient.choice {ι : Type _} {α : ι → Type _} [S : ∀ i, Setoid (α i)]\n    (f : ∀ i, Quotient (S i)) : @Quotient (∀ i, α i) (by infer_instance) :=\n  ⟦fun i => (f i).out⟧\n#align quotient.choice Quotient.choice\n-/\n\n/- warning: quotient.choice_eq -> Quotient.choice_eq is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Type.{u2}} [_inst_1 : forall (i : ι), Setoid.{succ u2} (α i)] (f : forall (i : ι), α i), Eq.{max (succ u1) (succ u2)} (Quotient.{max (succ u1) (succ u2)} (forall (i : ι), α i) (piSetoid.{succ u1, succ u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i))) (Quotient.choice.{u1, u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (i : ι) => Quotient.mk'.{succ u2} (α i) (_inst_1 i) (f i))) (Quotient.mk'.{max (succ u1) (succ u2)} (forall (i : ι), α i) (piSetoid.{succ u1, succ u2} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)) f)\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Type.{u1}} [_inst_1 : forall (i : ι), Setoid.{succ u1} (α i)] (f : forall (i : ι), α i), Eq.{max (succ u2) (succ u1)} (Quotient.{max (succ u2) (succ u1)} (forall (i : ι), α i) (inferInstance.{max (succ u2) (succ u1)} (Setoid.{max (succ u2) (succ u1)} (forall (i : ι), α i)) (piSetoid.{succ u2, succ u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i)))) (Quotient.choice.{u2, u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i) (fun (i : ι) => Quotient.mk.{succ u1} (α i) (_inst_1 i) (f i))) (Quotient.mk.{max (succ u2) (succ u1)} (forall (i : ι), α i) (inferInstance.{max (succ u2) (succ u1)} (Setoid.{max (succ u2) (succ u1)} (forall (i : ι), α i)) (piSetoid.{succ u2, succ u1} ι (fun (i : ι) => α i) (fun (i : ι) => _inst_1 i))) f)\nCase conversion may be inaccurate. Consider using '#align quotient.choice_eq Quotient.choice_eqₓ'. -/\n@[simp]\ntheorem Quotient.choice_eq {ι : Type _} {α : ι → Type _} [∀ i, Setoid (α i)] (f : ∀ i, α i) :\n    (Quotient.choice fun i => ⟦f i⟧) = ⟦f⟧ :=\n  Quotient.sound fun i => Quotient.mk_out _\n#align quotient.choice_eq Quotient.choice_eq\n\n/- warning: quotient.induction_on_pi -> Quotient.induction_on_pi is a dubious translation:\nlean 3 declaration is\n  forall {ι : Type.{u1}} {α : ι -> Sort.{u2}} [s : forall (i : ι), Setoid.{u2} (α i)] {p : (forall (i : ι), Quotient.{u2} (α i) (s i)) -> Prop} (f : forall (i : ι), Quotient.{u2} (α i) (s i)), (forall (a : forall (i : ι), α i), p (fun (i : ι) => Quotient.mk'.{u2} (α i) (s i) (a i))) -> (p f)\nbut is expected to have type\n  forall {ι : Type.{u2}} {α : ι -> Sort.{u1}} [s : forall (i : ι), Setoid.{u1} (α i)] {p : (forall (i : ι), Quotient.{u1} (α i) (s i)) -> Prop} (f : forall (i : ι), Quotient.{u1} (α i) (s i)), (forall (a : forall (i : ι), α i), p (fun (i : ι) => Quotient.mk.{u1} (α i) (s i) (a i))) -> (p f)\nCase conversion may be inaccurate. Consider using '#align quotient.induction_on_pi Quotient.induction_on_piₓ'. -/\n@[elab_as_elim]\ntheorem Quotient.induction_on_pi {ι : Type _} {α : ι → Sort _} [s : ∀ i, Setoid (α i)]\n    {p : (∀ i, Quotient (s i)) → Prop} (f : ∀ i, Quotient (s i))\n    (h : ∀ a : ∀ i, α i, p fun i => ⟦a i⟧) : p f :=\n  by\n  rw [← (funext fun i => Quotient.out_eq (f i) : (fun i => ⟦(f i).out⟧) = f)]\n  apply h\n#align quotient.induction_on_pi Quotient.induction_on_pi\n\nend Pi\n\n#print nonempty_quotient_iff /-\ntheorem nonempty_quotient_iff (s : Setoid α) : Nonempty (Quotient s) ↔ Nonempty α :=\n  ⟨fun ⟨a⟩ => Quotient.inductionOn a Nonempty.intro, fun ⟨a⟩ => ⟨⟦a⟧⟩⟩\n#align nonempty_quotient_iff nonempty_quotient_iff\n-/\n\n/-! ### Truncation -/\n\n\n#print true_equivalence /-\ntheorem true_equivalence : @Equivalence α fun _ _ => True :=\n  ⟨fun _ => trivial, fun _ _ _ => trivial, fun _ _ _ _ _ => trivial⟩\n#align true_equivalence true_equivalence\n-/\n\n#print trueSetoid /-\n/-- Always-true relation as a `setoid`.\n\nNote that in later files the preferred spelling is `⊤ : setoid α`. -/\ndef trueSetoid : Setoid α :=\n  ⟨_, true_equivalence⟩\n#align true_setoid trueSetoid\n-/\n\n#print Trunc /-\n/-- `trunc α` is the quotient of `α` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty α`, but unlike `nonempty α`, `trunc α` is data,\n  so the VM representation is the same as `α`, and so this can be used to\n  maintain computability. -/\ndef Trunc.{u} (α : Sort u) : Sort u :=\n  @Quotient α trueSetoid\n#align trunc Trunc\n-/\n\nnamespace Trunc\n\n#print Trunc.mk /-\n/-- Constructor for `trunc α` -/\ndef mk (a : α) : Trunc α :=\n  Quot.mk _ a\n#align trunc.mk Trunc.mk\n-/\n\ninstance [Inhabited α] : Inhabited (Trunc α) :=\n  ⟨mk default⟩\n\n#print Trunc.lift /-\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : α → β) (c : ∀ a b : α, f a = f b) : Trunc α → β :=\n  Quot.lift f fun a b _ => c a b\n#align trunc.lift Trunc.lift\n-/\n\n#print Trunc.ind /-\ntheorem ind {β : Trunc α → Prop} : (∀ a : α, β (mk a)) → ∀ q : Trunc α, β q :=\n  Quot.ind\n#align trunc.ind Trunc.ind\n-/\n\n#print Trunc.lift_mk /-\nprotected theorem lift_mk (f : α → β) (c) (a : α) : lift f c (mk a) = f a :=\n  rfl\n#align trunc.lift_mk Trunc.lift_mk\n-/\n\n#print Trunc.liftOn /-\n/-- Lift a constant function on `q : trunc α`. -/\n@[reducible, elab_as_elim]\nprotected def liftOn (q : Trunc α) (f : α → β) (c : ∀ a b : α, f a = f b) : β :=\n  lift f c q\n#align trunc.lift_on Trunc.liftOn\n-/\n\n#print Trunc.induction_on /-\n@[elab_as_elim]\nprotected theorem induction_on {β : Trunc α → Prop} (q : Trunc α) (h : ∀ a, β (mk a)) : β q :=\n  ind h q\n#align trunc.induction_on Trunc.induction_on\n-/\n\n#print Trunc.exists_rep /-\ntheorem exists_rep (q : Trunc α) : ∃ a : α, mk a = q :=\n  Quot.exists_rep q\n#align trunc.exists_rep Trunc.exists_rep\n-/\n\n/- warning: trunc.induction_on₂ -> Trunc.induction_on₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {C : (Trunc.{u1} α) -> (Trunc.{u2} β) -> Prop} (q₁ : Trunc.{u1} α) (q₂ : Trunc.{u2} β), (forall (a : α) (b : β), C (Trunc.mk.{u1} α a) (Trunc.mk.{u2} β b)) -> (C q₁ q₂)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {C : (Trunc.{u2} α) -> (Trunc.{u1} β) -> Prop} (q₁ : Trunc.{u2} α) (q₂ : Trunc.{u1} β), (forall (a : α) (b : β), C (Trunc.mk.{u2} α a) (Trunc.mk.{u1} β b)) -> (C q₁ q₂)\nCase conversion may be inaccurate. Consider using '#align trunc.induction_on₂ Trunc.induction_on₂ₓ'. -/\n@[elab_as_elim]\nprotected theorem induction_on₂ {C : Trunc α → Trunc β → Prop} (q₁ : Trunc α) (q₂ : Trunc β)\n    (h : ∀ a b, C (mk a) (mk b)) : C q₁ q₂ :=\n  Trunc.induction_on q₁ fun a₁ => Trunc.induction_on q₂ (h a₁)\n#align trunc.induction_on₂ Trunc.induction_on₂\n\n#print Trunc.eq /-\nprotected theorem eq (a b : Trunc α) : a = b :=\n  Trunc.induction_on₂ a b fun x y => Quot.sound trivial\n#align trunc.eq Trunc.eq\n-/\n\ninstance : Subsingleton (Trunc α) :=\n  ⟨Trunc.eq⟩\n\n#print Trunc.bind /-\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : Trunc α) (f : α → Trunc β) : Trunc β :=\n  Trunc.liftOn q f fun a b => Trunc.eq _ _\n#align trunc.bind Trunc.bind\n-/\n\n#print Trunc.map /-\n/-- A function `f : α → β` defines a function `map f : trunc α → trunc β`. -/\ndef map (f : α → β) (q : Trunc α) : Trunc β :=\n  bind q (Trunc.mk ∘ f)\n#align trunc.map Trunc.map\n-/\n\ninstance : Monad Trunc where\n  pure := @Trunc.mk\n  bind := @Trunc.bind\n\ninstance : LawfulMonad Trunc where\n  id_map α q := Trunc.eq _ _\n  pure_bind α β q f := rfl\n  bind_assoc α β γ x f g := Trunc.eq _ _\n\nvariable {C : Trunc α → Sort _}\n\n#print Trunc.rec /-\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_elim]\nprotected def rec (f : ∀ a, C (mk a))\n    (h : ∀ a b : α, (Eq.ndrec (f a) (Trunc.eq (mk a) (mk b)) : C (mk b)) = f b) (q : Trunc α) :\n    C q :=\n  Quot.rec f (fun a b _ => h a b) q\n#align trunc.rec Trunc.rec\n-/\n\n#print Trunc.recOn /-\n/-- A version of `trunc.rec` taking `q : trunc α` as the first argument. -/\n@[reducible, elab_as_elim]\nprotected def recOn (q : Trunc α) (f : ∀ a, C (mk a))\n    (h : ∀ a b : α, (Eq.ndrec (f a) (Trunc.eq (mk a) (mk b)) : C (mk b)) = f b) : C q :=\n  Trunc.rec f h q\n#align trunc.rec_on Trunc.recOn\n-/\n\n#print Trunc.recOnSubsingleton /-\n/-- A version of `trunc.rec_on` assuming the codomain is a `subsingleton`. -/\n@[reducible, elab_as_elim]\nprotected def recOnSubsingleton [∀ a, Subsingleton (C (mk a))] (q : Trunc α) (f : ∀ a, C (mk a)) :\n    C q :=\n  Trunc.rec f (fun a b => Subsingleton.elim _ (f b)) q\n#align trunc.rec_on_subsingleton Trunc.recOnSubsingleton\n-/\n\n#print Trunc.out /-\n/-- Noncomputably extract a representative of `trunc α` (using the axiom of choice). -/\nnoncomputable def out : Trunc α → α :=\n  Quot.out\n#align trunc.out Trunc.out\n-/\n\n#print Trunc.out_eq /-\n@[simp]\ntheorem out_eq (q : Trunc α) : mk q.out = q :=\n  Trunc.eq _ _\n#align trunc.out_eq Trunc.out_eq\n-/\n\n#print Trunc.nonempty /-\nprotected theorem nonempty (q : Trunc α) : Nonempty α :=\n  nonempty_of_exists q.exists_rep\n#align trunc.nonempty Trunc.nonempty\n-/\n\nend Trunc\n\n/-! ### `quotient` with implicit `setoid` -/\n\n\nnamespace Quotient\n\nvariable {γ : Sort _} {φ : Sort _} {s₁ : Setoid α} {s₂ : Setoid β} {s₃ : Setoid γ}\n\n/-! Versions of quotient definitions and lemmas ending in `'` use unification instead\nof typeclass inference for inferring the `setoid` argument. This is useful when there are\nseveral different quotient relations on a type, for example quotient groups, rings and modules. -/\n\n\n#print Quotient.mk'' /-\n/-- A version of `quotient.mk` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk'' (a : α) : Quotient s₁ :=\n  Quot.mk s₁.1 a\n#align quotient.mk' Quotient.mk''\n-/\n\n#print Quotient.surjective_Quotient_mk'' /-\n/-- `quotient.mk'` is a surjective function. -/\ntheorem surjective_Quotient_mk'' : Surjective (Quotient.mk'' : α → Quotient s₁) :=\n  Quot.exists_rep\n#align quotient.surjective_quotient_mk' Quotient.surjective_Quotient_mk''\n-/\n\n#print Quotient.liftOn' /-\n/-- A version of `quotient.lift_on` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_elim, reducible]\nprotected def liftOn' (q : Quotient s₁) (f : α → φ) (h : ∀ a b, @Setoid.r α s₁ a b → f a = f b) :\n    φ :=\n  Quotient.liftOn q f h\n#align quotient.lift_on' Quotient.liftOn'\n-/\n\n/- warning: quotient.lift_on'_mk' -> Quotient.liftOn'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {φ : Sort.{u2}} {s₁ : Setoid.{u1} α} (f : α -> φ) (h : forall (a : α) (b : α), (Setoid.r.{u1} α s₁ a b) -> (Eq.{u2} φ (f a) (f b))) (x : α), Eq.{u2} φ (Quotient.liftOn'.{u1, u2} α φ s₁ (Quotient.mk''.{u1} α s₁ x) f h) (f x)\nbut is expected to have type\n  forall {α : Sort.{u2}} {φ : Sort.{u1}} {s₁ : Setoid.{u2} α} (f : α -> φ) (h : forall (a : α) (b : α), (Setoid.r.{u2} α s₁ a b) -> (Eq.{u1} φ (f a) (f b))) (x : α), Eq.{u1} φ (Quotient.liftOn'.{u2, u1} α φ s₁ (Quotient.mk''.{u2} α s₁ x) f h) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on'_mk' Quotient.liftOn'_mk''ₓ'. -/\n@[simp]\nprotected theorem liftOn'_mk'' (f : α → φ) (h) (x : α) :\n    Quotient.liftOn' (@Quotient.mk'' _ s₁ x) f h = f x :=\n  rfl\n#align quotient.lift_on'_mk' Quotient.liftOn'_mk''\n\n/- warning: quotient.surjective_lift_on' -> Quotient.surjective_liftOn' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {φ : Sort.{u2}} {s₁ : Setoid.{u1} α} {f : α -> φ} (h : forall (a : α) (b : α), (Setoid.r.{u1} α s₁ a b) -> (Eq.{u2} φ (f a) (f b))), Iff (Function.Surjective.{u1, u2} (Quotient.{u1} α s₁) φ (fun (x : Quotient.{u1} α s₁) => Quotient.liftOn'.{u1, u2} α φ s₁ x f h)) (Function.Surjective.{u1, u2} α φ f)\nbut is expected to have type\n  forall {α : Sort.{u2}} {φ : Sort.{u1}} {s₁ : Setoid.{u2} α} {f : α -> φ} (h : forall (a : α) (b : α), (Setoid.r.{u2} α s₁ a b) -> (Eq.{u1} φ (f a) (f b))), Iff (Function.Surjective.{u2, u1} (Quotient.{u2} α s₁) φ (fun (x : Quotient.{u2} α s₁) => Quotient.liftOn'.{u2, u1} α φ s₁ x f h)) (Function.Surjective.{u2, u1} α φ f)\nCase conversion may be inaccurate. Consider using '#align quotient.surjective_lift_on' Quotient.surjective_liftOn'ₓ'. -/\n@[simp]\ntheorem surjective_liftOn' {f : α → φ} (h : ∀ a b, @Setoid.r α s₁ a b → f a = f b) :\n    (Surjective fun x => Quotient.liftOn' x f h) ↔ Surjective f :=\n  Quot.surjective_lift _\n#align quotient.surjective_lift_on' Quotient.surjective_liftOn'\n\n#print Quotient.liftOn₂' /-\n/-- A version of `quotient.lift_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_elim, reducible]\nprotected def liftOn₂' (q₁ : Quotient s₁) (q₂ : Quotient s₂) (f : α → β → γ)\n    (h : ∀ a₁ a₂ b₁ b₂, @Setoid.r α s₁ a₁ b₁ → @Setoid.r β s₂ a₂ b₂ → f a₁ a₂ = f b₁ b₂) : γ :=\n  Quotient.liftOn₂ q₁ q₂ f h\n#align quotient.lift_on₂' Quotient.liftOn₂'\n-/\n\n/- warning: quotient.lift_on₂'_mk' -> Quotient.liftOn₂'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {s₁ : Setoid.{u1} α} {s₂ : Setoid.{u2} β} (f : α -> β -> γ) (h : forall (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), (Setoid.r.{u1} α s₁ a₁ b₁) -> (Setoid.r.{u2} β s₂ a₂ b₂) -> (Eq.{u3} γ (f a₁ a₂) (f b₁ b₂))) (a : α) (b : β), Eq.{u3} γ (Quotient.liftOn₂'.{u1, u2, u3} α β γ s₁ s₂ (Quotient.mk''.{u1} α s₁ a) (Quotient.mk''.{u2} β s₂ b) f h) (f a b)\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {γ : Sort.{u1}} {s₁ : Setoid.{u3} α} {s₂ : Setoid.{u2} β} (f : α -> β -> γ) (h : forall (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), (Setoid.r.{u3} α s₁ a₁ b₁) -> (Setoid.r.{u2} β s₂ a₂ b₂) -> (Eq.{u1} γ (f a₁ a₂) (f b₁ b₂))) (a : α) (b : β), Eq.{u1} γ (Quotient.liftOn₂'.{u3, u2, u1} α β γ s₁ s₂ (Quotient.mk''.{u3} α s₁ a) (Quotient.mk''.{u2} β s₂ b) f h) (f a b)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on₂'_mk' Quotient.liftOn₂'_mk''ₓ'. -/\n@[simp]\nprotected theorem liftOn₂'_mk'' (f : α → β → γ) (h) (a : α) (b : β) :\n    Quotient.liftOn₂' (@Quotient.mk'' _ s₁ a) (@Quotient.mk'' _ s₂ b) f h = f a b :=\n  rfl\n#align quotient.lift_on₂'_mk' Quotient.liftOn₂'_mk''\n\n#print Quotient.ind' /-\n/-- A version of `quotient.ind` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_elim]\nprotected theorem ind' {p : Quotient s₁ → Prop} (h : ∀ a, p (Quotient.mk'' a)) (q : Quotient s₁) :\n    p q :=\n  Quotient.ind h q\n#align quotient.ind' Quotient.ind'\n-/\n\n/- warning: quotient.ind₂' -> Quotient.ind₂' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {s₁ : Setoid.{u1} α} {s₂ : Setoid.{u2} β} {p : (Quotient.{u1} α s₁) -> (Quotient.{u2} β s₂) -> Prop}, (forall (a₁ : α) (a₂ : β), p (Quotient.mk''.{u1} α s₁ a₁) (Quotient.mk''.{u2} β s₂ a₂)) -> (forall (q₁ : Quotient.{u1} α s₁) (q₂ : Quotient.{u2} β s₂), p q₁ q₂)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {s₁ : Setoid.{u2} α} {s₂ : Setoid.{u1} β} {p : (Quotient.{u2} α s₁) -> (Quotient.{u1} β s₂) -> Prop}, (forall (a₁ : α) (a₂ : β), p (Quotient.mk''.{u2} α s₁ a₁) (Quotient.mk''.{u1} β s₂ a₂)) -> (forall (q₁ : Quotient.{u2} α s₁) (q₂ : Quotient.{u1} β s₂), p q₁ q₂)\nCase conversion may be inaccurate. Consider using '#align quotient.ind₂' Quotient.ind₂'ₓ'. -/\n/-- A version of `quotient.ind₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem ind₂' {p : Quotient s₁ → Quotient s₂ → Prop}\n    (h : ∀ a₁ a₂, p (Quotient.mk'' a₁) (Quotient.mk'' a₂)) (q₁ : Quotient s₁) (q₂ : Quotient s₂) :\n    p q₁ q₂ :=\n  Quotient.ind₂ h q₁ q₂\n#align quotient.ind₂' Quotient.ind₂'\n\n#print Quotient.inductionOn' /-\n/-- A version of `quotient.induction_on` taking `{s : setoid α}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_elim]\nprotected theorem inductionOn' {p : Quotient s₁ → Prop} (q : Quotient s₁)\n    (h : ∀ a, p (Quotient.mk'' a)) : p q :=\n  Quotient.inductionOn q h\n#align quotient.induction_on' Quotient.inductionOn'\n-/\n\n/- warning: quotient.induction_on₂' -> Quotient.inductionOn₂' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {s₁ : Setoid.{u1} α} {s₂ : Setoid.{u2} β} {p : (Quotient.{u1} α s₁) -> (Quotient.{u2} β s₂) -> Prop} (q₁ : Quotient.{u1} α s₁) (q₂ : Quotient.{u2} β s₂), (forall (a₁ : α) (a₂ : β), p (Quotient.mk''.{u1} α s₁ a₁) (Quotient.mk''.{u2} β s₂ a₂)) -> (p q₁ q₂)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {s₁ : Setoid.{u2} α} {s₂ : Setoid.{u1} β} {p : (Quotient.{u2} α s₁) -> (Quotient.{u1} β s₂) -> Prop} (q₁ : Quotient.{u2} α s₁) (q₂ : Quotient.{u1} β s₂), (forall (a₁ : α) (a₂ : β), p (Quotient.mk''.{u2} α s₁ a₁) (Quotient.mk''.{u1} β s₂ a₂)) -> (p q₁ q₂)\nCase conversion may be inaccurate. Consider using '#align quotient.induction_on₂' Quotient.inductionOn₂'ₓ'. -/\n/-- A version of `quotient.induction_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn₂' {p : Quotient s₁ → Quotient s₂ → Prop} (q₁ : Quotient s₁)\n    (q₂ : Quotient s₂) (h : ∀ a₁ a₂, p (Quotient.mk'' a₁) (Quotient.mk'' a₂)) : p q₁ q₂ :=\n  Quotient.induction_on₂ q₁ q₂ h\n#align quotient.induction_on₂' Quotient.inductionOn₂'\n\n/- warning: quotient.induction_on₃' -> Quotient.inductionOn₃' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {s₁ : Setoid.{u1} α} {s₂ : Setoid.{u2} β} {s₃ : Setoid.{u3} γ} {p : (Quotient.{u1} α s₁) -> (Quotient.{u2} β s₂) -> (Quotient.{u3} γ s₃) -> Prop} (q₁ : Quotient.{u1} α s₁) (q₂ : Quotient.{u2} β s₂) (q₃ : Quotient.{u3} γ s₃), (forall (a₁ : α) (a₂ : β) (a₃ : γ), p (Quotient.mk''.{u1} α s₁ a₁) (Quotient.mk''.{u2} β s₂ a₂) (Quotient.mk''.{u3} γ s₃ a₃)) -> (p q₁ q₂ q₃)\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {γ : Sort.{u1}} {s₁ : Setoid.{u3} α} {s₂ : Setoid.{u2} β} {s₃ : Setoid.{u1} γ} {p : (Quotient.{u3} α s₁) -> (Quotient.{u2} β s₂) -> (Quotient.{u1} γ s₃) -> Prop} (q₁ : Quotient.{u3} α s₁) (q₂ : Quotient.{u2} β s₂) (q₃ : Quotient.{u1} γ s₃), (forall (a₁ : α) (a₂ : β) (a₃ : γ), p (Quotient.mk''.{u3} α s₁ a₁) (Quotient.mk''.{u2} β s₂ a₂) (Quotient.mk''.{u1} γ s₃ a₃)) -> (p q₁ q₂ q₃)\nCase conversion may be inaccurate. Consider using '#align quotient.induction_on₃' Quotient.inductionOn₃'ₓ'. -/\n/-- A version of `quotient.induction_on₃` taking `{s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn₃' {p : Quotient s₁ → Quotient s₂ → Quotient s₃ → Prop}\n    (q₁ : Quotient s₁) (q₂ : Quotient s₂) (q₃ : Quotient s₃)\n    (h : ∀ a₁ a₂ a₃, p (Quotient.mk'' a₁) (Quotient.mk'' a₂) (Quotient.mk'' a₃)) : p q₁ q₂ q₃ :=\n  Quotient.induction_on₃ q₁ q₂ q₃ h\n#align quotient.induction_on₃' Quotient.inductionOn₃'\n\n#print Quotient.recOnSubsingleton' /-\n/-- A version of `quotient.rec_on_subsingleton` taking `{s₁ : setoid α}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_elim]\nprotected def recOnSubsingleton' {φ : Quotient s₁ → Sort _} [h : ∀ a, Subsingleton (φ ⟦a⟧)]\n    (q : Quotient s₁) (f : ∀ a, φ (Quotient.mk'' a)) : φ q :=\n  Quotient.recOnSubsingleton q f\n#align quotient.rec_on_subsingleton' Quotient.recOnSubsingleton'\n-/\n\n#print Quotient.recOnSubsingleton₂' /-\n/-- A version of `quotient.rec_on_subsingleton₂` taking `{s₁ : setoid α} {s₂ : setoid α}`\nas implicit arguments instead of instance arguments. -/\n@[reducible, elab_as_elim]\nprotected def recOnSubsingleton₂' {φ : Quotient s₁ → Quotient s₂ → Sort _}\n    [h : ∀ a b, Subsingleton (φ ⟦a⟧ ⟦b⟧)] (q₁ : Quotient s₁) (q₂ : Quotient s₂)\n    (f : ∀ a₁ a₂, φ (Quotient.mk'' a₁) (Quotient.mk'' a₂)) : φ q₁ q₂ :=\n  Quotient.recOnSubsingleton₂ q₁ q₂ f\n#align quotient.rec_on_subsingleton₂' Quotient.recOnSubsingleton₂'\n-/\n\n#print Quotient.hrecOn' /-\n/-- Recursion on a `quotient` argument `a`, result type depends on `⟦a⟧`. -/\nprotected def hrecOn' {φ : Quotient s₁ → Sort _} (qa : Quotient s₁) (f : ∀ a, φ (Quotient.mk'' a))\n    (c : ∀ a₁ a₂, a₁ ≈ a₂ → HEq (f a₁) (f a₂)) : φ qa :=\n  Quot.hrecOn qa f c\n#align quotient.hrec_on' Quotient.hrecOn'\n-/\n\n/- warning: quotient.hrec_on'_mk' -> Quotient.hrecOn'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {s₁ : Setoid.{u1} α} {φ : (Quotient.{u1} α s₁) -> Sort.{u2}} (f : forall (a : α), φ (Quotient.mk''.{u1} α s₁ a)) (c : forall (a₁ : α) (a₂ : α), (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α s₁) a₁ a₂) -> (HEq.{u2} (φ (Quotient.mk''.{u1} α s₁ a₁)) (f a₁) (φ (Quotient.mk''.{u1} α s₁ a₂)) (f a₂))) (x : α), Eq.{u2} (φ (Quotient.mk''.{u1} α s₁ x)) (Quotient.hrecOn'.{u1, u2} α s₁ φ (Quotient.mk''.{u1} α s₁ x) f c) (f x)\nbut is expected to have type\n  forall {α : Sort.{u2}} {s₁ : Setoid.{u2} α} {φ : (Quotient.{u2} α s₁) -> Sort.{u1}} (f : forall (a : α), φ (Quotient.mk''.{u2} α s₁ a)) (c : forall (a₁ : α) (a₂ : α), (HasEquiv.Equiv.{u2, 0} α (instHasEquiv.{u2} α s₁) a₁ a₂) -> (HEq.{u1} (φ (Quotient.mk''.{u2} α s₁ a₁)) (f a₁) (φ (Quotient.mk''.{u2} α s₁ a₂)) (f a₂))) (x : α), Eq.{u1} (φ (Quotient.mk''.{u2} α s₁ x)) (Quotient.hrecOn'.{u2, u1} α s₁ φ (Quotient.mk''.{u2} α s₁ x) f c) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.hrec_on'_mk' Quotient.hrecOn'_mk''ₓ'. -/\n@[simp]\ntheorem hrecOn'_mk'' {φ : Quotient s₁ → Sort _} (f : ∀ a, φ (Quotient.mk'' a))\n    (c : ∀ a₁ a₂, a₁ ≈ a₂ → HEq (f a₁) (f a₂)) (x : α) : (Quotient.mk'' x).hrecOn' f c = f x :=\n  rfl\n#align quotient.hrec_on'_mk' Quotient.hrecOn'_mk''\n\n#print Quotient.hrecOn₂' /-\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrecOn₂' {φ : Quotient s₁ → Quotient s₂ → Sort _} (qa : Quotient s₁)\n    (qb : Quotient s₂) (f : ∀ a b, φ (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → HEq (f a₁ b₁) (f a₂ b₂)) : φ qa qb :=\n  Quotient.hrecOn₂ qa qb f c\n#align quotient.hrec_on₂' Quotient.hrecOn₂'\n-/\n\n/- warning: quotient.hrec_on₂'_mk' -> Quotient.hrecOn₂'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {s₁ : Setoid.{u1} α} {s₂ : Setoid.{u2} β} {φ : (Quotient.{u1} α s₁) -> (Quotient.{u2} β s₂) -> Sort.{u3}} (f : forall (a : α) (b : β), φ (Quotient.mk''.{u1} α s₁ a) (Quotient.mk''.{u2} β s₂ b)) (c : forall (a₁ : α) (b₁ : β) (a₂ : α) (b₂ : β), (HasEquivₓ.Equiv.{u1} α (setoidHasEquiv.{u1} α s₁) a₁ a₂) -> (HasEquivₓ.Equiv.{u2} β (setoidHasEquiv.{u2} β s₂) b₁ b₂) -> (HEq.{u3} (φ (Quotient.mk''.{u1} α s₁ a₁) (Quotient.mk''.{u2} β s₂ b₁)) (f a₁ b₁) (φ (Quotient.mk''.{u1} α s₁ a₂) (Quotient.mk''.{u2} β s₂ b₂)) (f a₂ b₂))) (x : α) (qb : Quotient.{u2} β s₂), Eq.{u3} (φ (Quotient.mk''.{u1} α s₁ x) qb) (Quotient.hrecOn₂'.{u1, u2, u3} α β s₁ s₂ φ (Quotient.mk''.{u1} α s₁ x) qb f c) (Quotient.hrecOn'.{u2, u3} β s₂ (fun (qb : Quotient.{u2} β s₂) => φ (Quotient.mk''.{u1} α s₁ x) qb) qb (f x) (fun (b₁ : β) (b₂ : β) => c x b₁ x b₂ (Setoid.refl.{u1} α s₁ x)))\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {s₁ : Setoid.{u3} α} {s₂ : Setoid.{u2} β} {φ : (Quotient.{u3} α s₁) -> (Quotient.{u2} β s₂) -> Sort.{u1}} (f : forall (a : α) (b : β), φ (Quotient.mk''.{u3} α s₁ a) (Quotient.mk''.{u2} β s₂ b)) (c : forall (a₁ : α) (b₁ : β) (a₂ : α) (b₂ : β), (HasEquiv.Equiv.{u3, 0} α (instHasEquiv.{u3} α s₁) a₁ a₂) -> (HasEquiv.Equiv.{u2, 0} β (instHasEquiv.{u2} β s₂) b₁ b₂) -> (HEq.{u1} (φ (Quotient.mk''.{u3} α s₁ a₁) (Quotient.mk''.{u2} β s₂ b₁)) (f a₁ b₁) (φ (Quotient.mk''.{u3} α s₁ a₂) (Quotient.mk''.{u2} β s₂ b₂)) (f a₂ b₂))) (x : α) (qb : Quotient.{u2} β s₂), Eq.{u1} (φ (Quotient.mk''.{u3} α s₁ x) qb) (Quotient.hrecOn₂'.{u3, u2, u1} α β s₁ s₂ φ (Quotient.mk''.{u3} α s₁ x) qb f c) (Quotient.hrecOn'.{u2, u1} β s₂ (φ (Quotient.mk''.{u3} α s₁ x)) qb (f x) (fun (b₁ : β) (b₂ : β) => c x b₁ x b₂ (Setoid.refl.{u3} α s₁ x)))\nCase conversion may be inaccurate. Consider using '#align quotient.hrec_on₂'_mk' Quotient.hrecOn₂'_mk''ₓ'. -/\n@[simp]\ntheorem hrecOn₂'_mk'' {φ : Quotient s₁ → Quotient s₂ → Sort _}\n    (f : ∀ a b, φ (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → HEq (f a₁ b₁) (f a₂ b₂)) (x : α) (qb : Quotient s₂) :\n    (Quotient.mk'' x).hrecOn₂' qb f c = qb.hrecOn' (f x) fun b₁ b₂ => c _ _ _ _ (Setoid.refl _) :=\n  rfl\n#align quotient.hrec_on₂'_mk' Quotient.hrecOn₂'_mk''\n\n#print Quotient.map' /-\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : α → β) (h : (s₁.R ⇒ s₂.R) f f) : Quotient s₁ → Quotient s₂ :=\n  Quot.map f h\n#align quotient.map' Quotient.map'\n-/\n\n/- warning: quotient.map'_mk' -> Quotient.map'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {s₁ : Setoid.{u1} α} {s₂ : Setoid.{u2} β} (f : α -> β) (h : Relator.LiftFun.{u1, u1, u2, u2} α α β β (Setoid.r.{u1} α s₁) (Setoid.r.{u2} β s₂) f f) (x : α), Eq.{u2} (Quotient.{u2} β s₂) (Quotient.map'.{u1, u2} α β s₁ s₂ f h (Quotient.mk''.{u1} α s₁ x)) (Quotient.mk''.{u2} β s₂ (f x))\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} {s₁ : Setoid.{u2} α} {s₂ : Setoid.{u1} β} (f : α -> β) (h : Relator.LiftFun.{u2, u2, u1, u1} α α β β (Setoid.r.{u2} α s₁) (Setoid.r.{u1} β s₂) f f) (x : α), Eq.{u1} (Quotient.{u1} β s₂) (Quotient.map'.{u2, u1} α β s₁ s₂ f h (Quotient.mk''.{u2} α s₁ x)) (Quotient.mk''.{u1} β s₂ (f x))\nCase conversion may be inaccurate. Consider using '#align quotient.map'_mk' Quotient.map'_mk''ₓ'. -/\n@[simp]\ntheorem map'_mk'' (f : α → β) (h) (x : α) :\n    (Quotient.mk'' x : Quotient s₁).map' f h = (Quotient.mk'' (f x) : Quotient s₂) :=\n  rfl\n#align quotient.map'_mk' Quotient.map'_mk''\n\n#print Quotient.map₂' /-\n/-- A version of `quotient.map₂` using curly braces and unification. -/\nprotected def map₂' (f : α → β → γ) (h : (s₁.R ⇒ s₂.R ⇒ s₃.R) f f) :\n    Quotient s₁ → Quotient s₂ → Quotient s₃ :=\n  Quotient.map₂ f h\n#align quotient.map₂' Quotient.map₂'\n-/\n\n/- warning: quotient.map₂'_mk' -> Quotient.map₂'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} {s₁ : Setoid.{u1} α} {s₂ : Setoid.{u2} β} {s₃ : Setoid.{u3} γ} (f : α -> β -> γ) (h : Relator.LiftFun.{u1, u1, imax u2 u3, imax u2 u3} α α (β -> γ) (β -> γ) (Setoid.r.{u1} α s₁) (Relator.LiftFun.{u2, u2, u3, u3} β β γ γ (Setoid.r.{u2} β s₂) (Setoid.r.{u3} γ s₃)) f f) (x : α), Eq.{imax u2 u3} ((Quotient.{u2} β s₂) -> (Quotient.{u3} γ s₃)) (Quotient.map₂'.{u1, u2, u3} α β γ s₁ s₂ s₃ f h (Quotient.mk''.{u1} α s₁ x)) (Quotient.map'.{u2, u3} β γ s₂ s₃ (f x) (h x x (Setoid.refl.{u1} α s₁ x)))\nbut is expected to have type\n  forall {α : Sort.{u3}} {β : Sort.{u2}} {γ : Sort.{u1}} {s₁ : Setoid.{u3} α} {s₂ : Setoid.{u2} β} {s₃ : Setoid.{u1} γ} (f : α -> β -> γ) (h : Relator.LiftFun.{u3, u3, imax u2 u1, imax u2 u1} α α (β -> γ) (β -> γ) (Setoid.r.{u3} α s₁) (Relator.LiftFun.{u2, u2, u1, u1} β β γ γ (Setoid.r.{u2} β s₂) (Setoid.r.{u1} γ s₃)) f f) (x : α), Eq.{imax u2 u1} ((Quotient.{u2} β s₂) -> (Quotient.{u1} γ s₃)) (Quotient.map₂'.{u3, u2, u1} α β γ s₁ s₂ s₃ f h (Quotient.mk''.{u3} α s₁ x)) (Quotient.map'.{u2, u1} β γ s₂ s₃ (f x) (h x x (Setoid.refl.{u3} α s₁ x)))\nCase conversion may be inaccurate. Consider using '#align quotient.map₂'_mk' Quotient.map₂'_mk''ₓ'. -/\n@[simp]\ntheorem map₂'_mk'' (f : α → β → γ) (h) (x : α) :\n    (Quotient.mk'' x : Quotient s₁).map₂' f h =\n      (Quotient.map' (f x) (h (Setoid.refl x)) : Quotient s₂ → Quotient s₃) :=\n  rfl\n#align quotient.map₂'_mk' Quotient.map₂'_mk''\n\n#print Quotient.exact' /-\ntheorem exact' {a b : α} : (Quotient.mk'' a : Quotient s₁) = Quotient.mk'' b → @Setoid.r _ s₁ a b :=\n  Quotient.exact\n#align quotient.exact' Quotient.exact'\n-/\n\n#print Quotient.sound' /-\ntheorem sound' {a b : α} : @Setoid.r _ s₁ a b → @Quotient.mk'' α s₁ a = Quotient.mk'' b :=\n  Quotient.sound\n#align quotient.sound' Quotient.sound'\n-/\n\n#print Quotient.eq'' /-\n@[simp]\nprotected theorem eq'' {a b : α} : @Quotient.mk'' α s₁ a = Quotient.mk'' b ↔ @Setoid.r _ s₁ a b :=\n  Quotient.eq'\n#align quotient.eq' Quotient.eq''\n-/\n\n#print Quotient.out' /-\n/-- A version of `quotient.out` taking `{s₁ : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : Quotient s₁) : α :=\n  Quotient.out a\n#align quotient.out' Quotient.out'\n-/\n\n#print Quotient.out_eq' /-\n@[simp]\ntheorem out_eq' (q : Quotient s₁) : Quotient.mk'' q.out' = q :=\n  q.out_eq\n#align quotient.out_eq' Quotient.out_eq'\n-/\n\n#print Quotient.mk_out' /-\ntheorem mk_out' (a : α) : @Setoid.r α s₁ (Quotient.mk'' a : Quotient s₁).out' a :=\n  Quotient.exact (Quotient.out_eq _)\n#align quotient.mk_out' Quotient.mk_out'\n-/\n\nsection\n\nvariable [Setoid α]\n\nprotected theorem mk''_eq_mk' (x : α) : Quotient.mk'' x = ⟦x⟧ :=\n  rfl\n#align quotient.mk'_eq_mk Quotient.mk''_eq_mk'\n\n/- warning: quotient.lift_on'_mk -> Quotient.liftOn'_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Setoid.{u1} α] (x : α) (f : α -> β) (h : forall (a : α) (b : α), (Setoid.r.{u1} α _inst_1 a b) -> (Eq.{u2} β (f a) (f b))), Eq.{u2} β (Quotient.liftOn'.{u1, u2} α β _inst_1 (Quotient.mk'.{u1} α _inst_1 x) f h) (f x)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Setoid.{u2} α] (x : α) (f : α -> β) (h : forall (a : α) (b : α), (Setoid.r.{u2} α _inst_1 a b) -> (Eq.{u1} β (f a) (f b))), Eq.{u1} β (Quotient.liftOn'.{u2, u1} α β _inst_1 (Quotient.mk.{u2} α _inst_1 x) f h) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on'_mk Quotient.liftOn'_mkₓ'. -/\n@[simp]\nprotected theorem liftOn'_mk (x : α) (f : α → β) (h) : ⟦x⟧.liftOn' f h = f x :=\n  rfl\n#align quotient.lift_on'_mk Quotient.liftOn'_mk\n\n/- warning: quotient.lift_on₂'_mk -> Quotient.liftOn₂'_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Sort.{u1}} {β : Sort.{u2}} {γ : Sort.{u3}} [_inst_1 : Setoid.{u1} α] [_inst_2 : Setoid.{u2} β] (f : α -> β -> γ) (h : forall (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), (Setoid.r.{u1} α _inst_1 a₁ b₁) -> (Setoid.r.{u2} β _inst_2 a₂ b₂) -> (Eq.{u3} γ (f a₁ a₂) (f b₁ b₂))) (a : α) (b : β), Eq.{u3} γ (Quotient.liftOn₂'.{u1, u2, u3} α β γ _inst_1 _inst_2 (Quotient.mk'.{u1} α _inst_1 a) (Quotient.mk'.{u2} β _inst_2 b) f h) (f a b)\nbut is expected to have type\n  forall {α : Sort.{u2}} {β : Sort.{u3}} {γ : Sort.{u1}} [_inst_1 : Setoid.{u2} α] [_inst_2 : Setoid.{u3} β] (f : α -> β -> γ) (h : forall (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), (Setoid.r.{u2} α _inst_1 a₁ b₁) -> (Setoid.r.{u3} β _inst_2 a₂ b₂) -> (Eq.{u1} γ (f a₁ a₂) (f b₁ b₂))) (a : α) (b : β), Eq.{u1} γ (Quotient.liftOn₂'.{u2, u3, u1} α β γ _inst_1 _inst_2 (Quotient.mk.{u2} α _inst_1 a) (Quotient.mk.{u3} β _inst_2 b) f h) (f a b)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on₂'_mk Quotient.liftOn₂'_mkₓ'. -/\n@[simp]\nprotected theorem liftOn₂'_mk [Setoid β] (f : α → β → γ) (h) (a : α) (b : β) :\n    Quotient.liftOn₂' ⟦a⟧ ⟦b⟧ f h = f a b :=\n  Quotient.liftOn₂'_mk'' _ _ _ _\n#align quotient.lift_on₂'_mk Quotient.liftOn₂'_mk\n\n#print Quotient.map'_mk /-\n@[simp]\ntheorem map'_mk [Setoid β] (f : α → β) (h) (x : α) : ⟦x⟧.map' f h = ⟦f x⟧ :=\n  rfl\n#align quotient.map'_mk Quotient.map'_mk\n-/\n\nend\n\ninstance (q : Quotient s₁) (f : α → Prop) (h : ∀ a b, @Setoid.r α s₁ a b → f a = f b)\n    [DecidablePred f] : Decidable (Quotient.liftOn' q f h) :=\n  Quotient.lift.decidablePred _ _ q\n\ninstance (q₁ : Quotient s₁) (q₂ : Quotient s₂) (f : α → β → Prop)\n    (h : ∀ a₁ b₁ a₂ b₂, @Setoid.r α s₁ a₁ a₂ → @Setoid.r β s₂ b₁ b₂ → f a₁ b₁ = f a₂ b₂)\n    [∀ a, DecidablePred (f a)] : Decidable (Quotient.liftOn₂' q₁ q₂ f h) :=\n  Quotient.lift₂.decidablePred _ _ _ _\n\nend Quotient\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Quot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.6992544335934765, "lm_q1q2_score": 0.4604013470495648}}
{"text": "/-\nCopyright (c) 2020 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.uniform_space.separation\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Compact separated uniform spaces\n\n## Main statements\n\n* `compact_space_uniformity`: On a separated compact uniform space, the topology determines the\n  uniform structure, entourages are exactly the neighborhoods of the diagonal.\n* `uniform_space_of_compact_t2`: every compact T2 topological structure is induced by a uniform\n  structure. This uniform structure is described in the previous item.\n* Heine-Cantor theorem: continuous functions on compact separated uniform spaces with values in\n  uniform spaces are automatically uniformly continuous. There are several variations, the main one\n  is `compact_space.uniform_continuous_of_continuous`.\n\n## Implementation notes\n\nThe construction `uniform_space_of_compact_t2` is not declared as an instance, as it would badly\nloop.\n\n## tags\n\nuniform space, uniform continuity, compact space\n-/\n\n/-!\n### Uniformity on compact separated spaces\n-/\n\n/-- On a separated compact uniform space, the topology determines the uniform structure, entourages\nare exactly the neighborhoods of the diagonal. -/\ntheorem compact_space_uniformity {α : Type u_1} [uniform_space α] [compact_space α]\n    [separated_space α] : uniformity α = supr fun (x : α) => nhds (x, x) :=\n  sorry\n\ntheorem unique_uniformity_of_compact_t2 {α : Type u_1} [t : topological_space α] [compact_space α]\n    [t2_space α] {u : uniform_space α} {u' : uniform_space α}\n    (h : uniform_space.to_topological_space = t) (h' : uniform_space.to_topological_space = t) :\n    u = u' :=\n  sorry\n\n/-- The unique uniform structure inducing a given compact Hausdorff topological structure. -/\ndef uniform_space_of_compact_t2 {α : Type (max (max u_1 u_2 u_3) u_2)} [topological_space α]\n    [compact_space α] [t2_space α] : uniform_space α :=\n  uniform_space.mk (uniform_space.core.mk (supr fun (x : α) => nhds (x, x)) sorry sorry sorry) sorry\n\n/-!\n### Heine-Cantor theorem\n-/\n\n/-- Heine-Cantor: a continuous function on a compact separated uniform space is uniformly\ncontinuous. -/\ntheorem compact_space.uniform_continuous_of_continuous {α : Type u_1} {β : Type u_2}\n    [uniform_space α] [uniform_space β] [compact_space α] [separated_space α] {f : α → β}\n    (h : continuous f) : uniform_continuous f :=\n  sorry\n\n/-- Heine-Cantor: a continuous function on a compact separated set of a uniform space is\nuniformly continuous. -/\ntheorem is_compact.uniform_continuous_on_of_continuous' {α : Type u_1} {β : Type u_2}\n    [uniform_space α] [uniform_space β] {s : set α} {f : α → β} (hs : is_compact s)\n    (hs' : is_separated s) (hf : continuous_on f s) : uniform_continuous_on f s :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (uniform_continuous_on f s))\n        (propext uniform_continuous_on_iff_restrict)))\n    (compact_space.uniform_continuous_of_continuous\n      (eq.mp\n        (Eq._oldrec (Eq.refl (continuous_on f s)) (propext continuous_on_iff_continuous_restrict))\n        hf))\n\n/-- Heine-Cantor: a continuous function on a compact set of a separated uniform space\nis uniformly continuous. -/\ntheorem is_compact.uniform_continuous_on_of_continuous {α : Type u_1} {β : Type u_2}\n    [uniform_space α] [uniform_space β] [separated_space α] {s : set α} {f : α → β}\n    (hs : is_compact s) (hf : continuous_on f s) : uniform_continuous_on f s :=\n  is_compact.uniform_continuous_on_of_continuous' hs (is_separated_of_separated_space s) hf\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/uniform_space/compact_separated_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4603573329677877}}
{"text": "import Mathlib.Tactic.Basic\n\nexample : True := by\n  triv\n\nexample : 2 + 2 = 4 := by\n  triv\n\n-- Verify the difference in behaviour between `triv` and `trivial`.\nexample (P : Prop) (h1 : P) (h2 : ¬ P) : False := by\n  fail_if_success triv -- fails\n  trivial -- succeeds\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/test/triv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718435083355187, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.46035305210048016}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.preadditive.projective_resolution\n! leanprover-community/mathlib commit 324a7502510e835cdbd3de1519b6c66b51fb2467\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Preadditive.Projective\nimport Mathbin.Algebra.Homology.Single\nimport Mathbin.Algebra.Homology.HomotopyCategory\n\n/-!\n# Projective resolutions\n\nA projective resolution `P : ProjectiveResolution Z` of an object `Z : C` consists of\na `ℕ`-indexed chain complex `P.complex` of projective objects,\nalong with a chain map `P.π` from `C` to the chain complex consisting just of `Z` in degree zero,\nso that the augmented chain complex is exact.\n\nWhen `C` is abelian, this exactness condition is equivalent to `π` being a quasi-isomorphism.\nIt turns out that this formulation allows us to set up the basic theory of derived functors\nwithout even assuming `C` is abelian.\n\n(Typically, however, to show `has_projective_resolutions C`\none will assume `enough_projectives C` and `abelian C`.\nThis construction appears in `category_theory.abelian.projectives`.)\n\nWe show that given `P : ProjectiveResolution X` and `Q : ProjectiveResolution Y`,\nany morphism `X ⟶ Y` admits a lift to a chain map `P.complex ⟶ Q.complex`.\n(It is a lift in the sense that\nthe projection maps `P.π` and `Q.π` intertwine the lift and the original morphism.)\n\nMoreover, we show that any two such lifts are homotopic.\n\nAs a consequence, if every object admits a projective resolution,\nwe can construct a functor `projective_resolutions C : C ⥤ homotopy_category C`.\n-/\n\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nuniverse v u\n\nnamespace CategoryTheory\n\nvariable {C : Type u} [Category.{v} C]\n\nopen Projective\n\nsection\n\nvariable [HasZeroObject C] [HasZeroMorphisms C] [HasEqualizers C] [HasImages C]\n\n/--\nA `ProjectiveResolution Z` consists of a bundled `ℕ`-indexed chain complex of projective objects,\nalong with a quasi-isomorphism to the complex consisting of just `Z` supported in degree `0`.\n\n(We don't actually ask here that the chain map is a quasi-iso, just exactness everywhere:\nthat `π` is a quasi-iso is a lemma when the category is abelian.\nShould we just ask for it here?)\n\nExcept in situations where you want to provide a particular projective resolution\n(for example to compute a derived functor),\nyou will not typically need to use this bundled object, and will instead use\n* `projective_resolution Z`: the `ℕ`-indexed chain complex\n  (equipped with `projective` and `exact` instances)\n* `projective_resolution.π Z`: the chain map from `projective_resolution Z` to\n  `(single C _ 0).obj Z` (all the components are equipped with `epi` instances,\n  and when the category is `abelian` we will show `π` is a quasi-iso).\n-/\n@[nolint has_nonempty_instance]\nstructure ProjectiveResolution (Z : C) where\n  complex : ChainComplex C ℕ\n  π : HomologicalComplex.Hom Complex ((ChainComplex.single₀ C).obj Z)\n  Projective : ∀ n, Projective (Complex.pt n) := by infer_instance\n  exact₀ : Exact (Complex.d 1 0) (π.f 0)\n  exact : ∀ n, Exact (Complex.d (n + 2) (n + 1)) (Complex.d (n + 1) n)\n  Epi : Epi (π.f 0) := by infer_instance\n#align category_theory.ProjectiveResolution CategoryTheory.ProjectiveResolution\n\nattribute [instance] ProjectiveResolution.projective ProjectiveResolution.epi\n\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`out] [] -/\n/-- An object admits a projective resolution.\n-/\nclass HasProjectiveResolution (Z : C) : Prop where\n  out : Nonempty (ProjectiveResolution Z)\n#align category_theory.has_projective_resolution CategoryTheory.HasProjectiveResolution\n\nsection\n\nvariable (C)\n\n/-- You will rarely use this typeclass directly: it is implied by the combination\n`[enough_projectives C]` and `[abelian C]`.\nBy itself it's enough to set up the basic theory of derived functors.\n-/\nclass HasProjectiveResolutions : Prop where\n  out : ∀ Z : C, HasProjectiveResolution Z\n#align category_theory.has_projective_resolutions CategoryTheory.HasProjectiveResolutions\n\nattribute [instance] has_projective_resolutions.out\n\nend\n\nnamespace ProjectiveResolution\n\n@[simp]\ntheorem π_f_succ {Z : C} (P : ProjectiveResolution Z) (n : ℕ) : P.π.f (n + 1) = 0 :=\n  by\n  apply zero_of_target_iso_zero\n  dsimp; rfl\n#align category_theory.ProjectiveResolution.π_f_succ CategoryTheory.ProjectiveResolution.π_f_succ\n\n@[simp]\ntheorem complex_d_comp_π_f_zero {Z : C} (P : ProjectiveResolution Z) :\n    P.complex.d 1 0 ≫ P.π.f 0 = 0 :=\n  P.exact₀.w\n#align category_theory.ProjectiveResolution.complex_d_comp_π_f_zero CategoryTheory.ProjectiveResolution.complex_d_comp_π_f_zero\n\n@[simp]\ntheorem complex_d_succ_comp {Z : C} (P : ProjectiveResolution Z) (n : ℕ) :\n    P.complex.d (n + 2) (n + 1) ≫ P.complex.d (n + 1) n = 0 :=\n  (P.exact _).w\n#align category_theory.ProjectiveResolution.complex_d_succ_comp CategoryTheory.ProjectiveResolution.complex_d_succ_comp\n\ninstance {Z : C} (P : ProjectiveResolution Z) (n : ℕ) : CategoryTheory.Epi (P.π.f n) := by\n  cases n <;> infer_instance\n\n/-- A projective object admits a trivial projective resolution: itself in degree 0. -/\ndef self (Z : C) [CategoryTheory.Projective Z] : ProjectiveResolution Z\n    where\n  complex := (ChainComplex.single₀ C).obj Z\n  π := 𝟙 ((ChainComplex.single₀ C).obj Z)\n  Projective n := by\n    cases n\n    · dsimp\n      infer_instance\n    · dsimp\n      infer_instance\n  exact₀ := by\n    dsimp\n    exact exact_zero_mono _\n  exact n := by\n    dsimp\n    exact exact_of_zero _ _\n  Epi := by\n    dsimp\n    infer_instance\n#align category_theory.ProjectiveResolution.self CategoryTheory.ProjectiveResolution.self\n\n/-- Auxiliary construction for `lift`. -/\ndef liftFZero {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n    P.complex.pt 0 ⟶ Q.complex.pt 0 :=\n  factorThru (P.π.f 0 ≫ f) (Q.π.f 0)\n#align category_theory.ProjectiveResolution.lift_f_zero CategoryTheory.ProjectiveResolution.liftFZero\n\n/-- Auxiliary construction for `lift`. -/\ndef liftFOne {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n    P.complex.pt 1 ⟶ Q.complex.pt 1 :=\n  Exact.lift (P.complex.d 1 0 ≫ liftFZero f P Q) (Q.complex.d 1 0) (Q.π.f 0) Q.exact₀\n    (by simp [lift_f_zero, P.exact₀.w_assoc])\n#align category_theory.ProjectiveResolution.lift_f_one CategoryTheory.ProjectiveResolution.liftFOne\n\n/-- Auxiliary lemma for `lift`. -/\n@[simp]\ntheorem liftFOne_zero_comm {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y)\n    (Q : ProjectiveResolution Z) :\n    liftFOne f P Q ≫ Q.complex.d 1 0 = P.complex.d 1 0 ≫ liftFZero f P Q :=\n  by\n  dsimp [lift_f_zero, lift_f_one]\n  simp\n#align category_theory.ProjectiveResolution.lift_f_one_zero_comm CategoryTheory.ProjectiveResolution.liftFOne_zero_comm\n\n/-- Auxiliary construction for `lift`. -/\ndef liftFSucc {Y Z : C} (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) (n : ℕ)\n    (g : P.complex.pt n ⟶ Q.complex.pt n) (g' : P.complex.pt (n + 1) ⟶ Q.complex.pt (n + 1))\n    (w : g' ≫ Q.complex.d (n + 1) n = P.complex.d (n + 1) n ≫ g) :\n    Σ'g'' : P.complex.pt (n + 2) ⟶ Q.complex.pt (n + 2),\n      g'' ≫ Q.complex.d (n + 2) (n + 1) = P.complex.d (n + 2) (n + 1) ≫ g' :=\n  ⟨Exact.lift (P.complex.d (n + 2) (n + 1) ≫ g') (Q.complex.d (n + 2) (n + 1))\n      (Q.complex.d (n + 1) n) (Q.exact _) (by simp [w]),\n    by simp⟩\n#align category_theory.ProjectiveResolution.lift_f_succ CategoryTheory.ProjectiveResolution.liftFSucc\n\n/-- A morphism in `C` lifts to a chain map between projective resolutions. -/\ndef lift {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n    P.complex ⟶ Q.complex :=\n  ChainComplex.mkHom _ _ (liftFZero f _ _) (liftFOne f _ _) (liftFOne_zero_comm f _ _)\n    fun n ⟨g, g', w⟩ => liftFSucc P Q n g g' w\n#align category_theory.ProjectiveResolution.lift CategoryTheory.ProjectiveResolution.lift\n\n/-- The resolution maps intertwine the lift of a morphism and that morphism. -/\n@[simp, reassoc.1]\ntheorem lift_commutes {Y Z : C} (f : Y ⟶ Z) (P : ProjectiveResolution Y)\n    (Q : ProjectiveResolution Z) : lift f P Q ≫ Q.π = P.π ≫ (ChainComplex.single₀ C).map f :=\n  by\n  ext\n  dsimp [lift, lift_f_zero]\n  apply factor_thru_comp\n#align category_theory.ProjectiveResolution.lift_commutes CategoryTheory.ProjectiveResolution.lift_commutes\n\n-- Now that we've checked this property of the lift,\n-- we can seal away the actual definition.\nend ProjectiveResolution\n\nend\n\nnamespace ProjectiveResolution\n\nvariable [HasZeroObject C] [Preadditive C] [HasEqualizers C] [HasImages C]\n\n/-- An auxiliary definition for `lift_homotopy_zero`. -/\ndef liftHomotopyZeroZero {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n    (f : P.complex ⟶ Q.complex) (comm : f ≫ Q.π = 0) : P.complex.pt 0 ⟶ Q.complex.pt 1 :=\n  Exact.lift (f.f 0) (Q.complex.d 1 0) (Q.π.f 0) Q.exact₀\n    (congr_fun (congr_arg HomologicalComplex.Hom.f comm) 0)\n#align category_theory.ProjectiveResolution.lift_homotopy_zero_zero CategoryTheory.ProjectiveResolution.liftHomotopyZeroZero\n\n/-- An auxiliary definition for `lift_homotopy_zero`. -/\ndef liftHomotopyZeroOne {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n    (f : P.complex ⟶ Q.complex) (comm : f ≫ Q.π = 0) : P.complex.pt 1 ⟶ Q.complex.pt 2 :=\n  Exact.lift (f.f 1 - P.complex.d 1 0 ≫ liftHomotopyZeroZero f comm) (Q.complex.d 2 1)\n    (Q.complex.d 1 0) (Q.exact _) (by simp [lift_homotopy_zero_zero])\n#align category_theory.ProjectiveResolution.lift_homotopy_zero_one CategoryTheory.ProjectiveResolution.liftHomotopyZeroOne\n\n/-- An auxiliary definition for `lift_homotopy_zero`. -/\ndef liftHomotopyZeroSucc {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n    (f : P.complex ⟶ Q.complex) (n : ℕ) (g : P.complex.pt n ⟶ Q.complex.pt (n + 1))\n    (g' : P.complex.pt (n + 1) ⟶ Q.complex.pt (n + 2))\n    (w : f.f (n + 1) = P.complex.d (n + 1) n ≫ g + g' ≫ Q.complex.d (n + 2) (n + 1)) :\n    P.complex.pt (n + 2) ⟶ Q.complex.pt (n + 3) :=\n  Exact.lift (f.f (n + 2) - P.complex.d (n + 2) (n + 1) ≫ g') (Q.complex.d (n + 3) (n + 2))\n    (Q.complex.d (n + 2) (n + 1)) (Q.exact _) (by simp [w])\n#align category_theory.ProjectiveResolution.lift_homotopy_zero_succ CategoryTheory.ProjectiveResolution.liftHomotopyZeroSucc\n\n/-- Any lift of the zero morphism is homotopic to zero. -/\ndef liftHomotopyZero {Y Z : C} {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n    (f : P.complex ⟶ Q.complex) (comm : f ≫ Q.π = 0) : Homotopy f 0 :=\n  Homotopy.mkInductive _ (liftHomotopyZeroZero f comm) (by simp [lift_homotopy_zero_zero])\n    (liftHomotopyZeroOne f comm) (by simp [lift_homotopy_zero_one]) fun n ⟨g, g', w⟩ =>\n    ⟨liftHomotopyZeroSucc f n g g' w, by simp [lift_homotopy_zero_succ, w]⟩\n#align category_theory.ProjectiveResolution.lift_homotopy_zero CategoryTheory.ProjectiveResolution.liftHomotopyZero\n\n/-- Two lifts of the same morphism are homotopic. -/\ndef liftHomotopy {Y Z : C} (f : Y ⟶ Z) {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n    (g h : P.complex ⟶ Q.complex) (g_comm : g ≫ Q.π = P.π ≫ (ChainComplex.single₀ C).map f)\n    (h_comm : h ≫ Q.π = P.π ≫ (ChainComplex.single₀ C).map f) : Homotopy g h :=\n  Homotopy.equivSubZero.invFun (liftHomotopyZero _ (by simp [g_comm, h_comm]))\n#align category_theory.ProjectiveResolution.lift_homotopy CategoryTheory.ProjectiveResolution.liftHomotopy\n\n/-- The lift of the identity morphism is homotopic to the identity chain map. -/\ndef liftIdHomotopy (X : C) (P : ProjectiveResolution X) : Homotopy (lift (𝟙 X) P P) (𝟙 P.complex) :=\n  by apply lift_homotopy (𝟙 X) <;> simp\n#align category_theory.ProjectiveResolution.lift_id_homotopy CategoryTheory.ProjectiveResolution.liftIdHomotopy\n\n/-- The lift of a composition is homotopic to the composition of the lifts. -/\ndef liftCompHomotopy {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (P : ProjectiveResolution X)\n    (Q : ProjectiveResolution Y) (R : ProjectiveResolution Z) :\n    Homotopy (lift (f ≫ g) P R) (lift f P Q ≫ lift g Q R) := by apply lift_homotopy (f ≫ g) <;> simp\n#align category_theory.ProjectiveResolution.lift_comp_homotopy CategoryTheory.ProjectiveResolution.liftCompHomotopy\n\n-- We don't care about the actual definitions of these homotopies.\n/-- Any two projective resolutions are homotopy equivalent. -/\ndef homotopyEquiv {X : C} (P Q : ProjectiveResolution X) : HomotopyEquiv P.complex Q.complex\n    where\n  Hom := lift (𝟙 X) P Q\n  inv := lift (𝟙 X) Q P\n  homotopyHomInvId :=\n    by\n    refine' (lift_comp_homotopy (𝟙 X) (𝟙 X) P Q P).symm.trans _\n    simp [category.id_comp]\n    apply lift_id_homotopy\n  homotopyInvHomId :=\n    by\n    refine' (lift_comp_homotopy (𝟙 X) (𝟙 X) Q P Q).symm.trans _\n    simp [category.id_comp]\n    apply lift_id_homotopy\n#align category_theory.ProjectiveResolution.homotopy_equiv CategoryTheory.ProjectiveResolution.homotopyEquiv\n\n@[simp, reassoc.1]\ntheorem homotopyEquiv_hom_π {X : C} (P Q : ProjectiveResolution X) :\n    (homotopyEquiv P Q).Hom ≫ Q.π = P.π := by simp [HomotopyEquiv]\n#align category_theory.ProjectiveResolution.homotopy_equiv_hom_π CategoryTheory.ProjectiveResolution.homotopyEquiv_hom_π\n\n@[simp, reassoc.1]\ntheorem homotopyEquiv_inv_π {X : C} (P Q : ProjectiveResolution X) :\n    (homotopyEquiv P Q).inv ≫ P.π = Q.π := by simp [HomotopyEquiv]\n#align category_theory.ProjectiveResolution.homotopy_equiv_inv_π CategoryTheory.ProjectiveResolution.homotopyEquiv_inv_π\n\nend ProjectiveResolution\n\nsection\n\nvariable [HasZeroMorphisms C] [HasZeroObject C] [HasEqualizers C] [HasImages C]\n\n/-- An arbitrarily chosen projective resolution of an object. -/\nabbrev projectiveResolution (Z : C) [HasProjectiveResolution Z] : ChainComplex C ℕ :=\n  (HasProjectiveResolution.out Z).some.complex\n#align category_theory.projective_resolution CategoryTheory.projectiveResolution\n\n/-- The chain map from the arbitrarily chosen projective resolution `projective_resolution Z`\nback to the chain complex consisting of `Z` supported in degree `0`. -/\nabbrev projectiveResolution.π (Z : C) [HasProjectiveResolution Z] :\n    projectiveResolution Z ⟶ (ChainComplex.single₀ C).obj Z :=\n  (HasProjectiveResolution.out Z).some.π\n#align category_theory.projective_resolution.π CategoryTheory.projectiveResolution.π\n\n/-- The lift of a morphism to a chain map between the arbitrarily chosen projective resolutions. -/\nabbrev projectiveResolution.lift {X Y : C} (f : X ⟶ Y) [HasProjectiveResolution X]\n    [HasProjectiveResolution Y] : projectiveResolution X ⟶ projectiveResolution Y :=\n  ProjectiveResolution.lift f _ _\n#align category_theory.projective_resolution.lift CategoryTheory.projectiveResolution.lift\n\nend\n\nvariable (C) [Preadditive C] [HasZeroObject C] [HasEqualizers C] [HasImages C]\n  [HasProjectiveResolutions C]\n\n/-- Taking projective resolutions is functorial,\nif considered with target the homotopy category\n(`ℕ`-indexed chain complexes and chain maps up to homotopy).\n-/\ndef projectiveResolutions : C ⥤ HomotopyCategory C (ComplexShape.down ℕ)\n    where\n  obj X := (HomotopyCategory.quotient _ _).obj (projectiveResolution X)\n  map X Y f := (HomotopyCategory.quotient _ _).map (projectiveResolution.lift f)\n  map_id' X := by\n    rw [← (HomotopyCategory.quotient _ _).map_id]\n    apply HomotopyCategory.eq_of_homotopy\n    apply ProjectiveResolution.lift_id_homotopy\n  map_comp' X Y Z f g := by\n    rw [← (HomotopyCategory.quotient _ _).map_comp]\n    apply HomotopyCategory.eq_of_homotopy\n    apply ProjectiveResolution.lift_comp_homotopy\n#align category_theory.projective_resolutions CategoryTheory.projectiveResolutions\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Preadditive/ProjectiveResolution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.460353045840053}}
{"text": "import logic.function.iterate\nimport data.nat.basic\nimport data.nat.order.basic\nimport tree\n\n/-!\n# Conversion of iteration to recursion using a stack\n\nThis file essentially describes how to eliminate recursion into iteration.\n\n## Recursion with an explicit stack\n\nFor W-types, we can define a function `stack_rec`,\nwhich is similar to `rec` except that it explicitly keeps track of the\narguments on the stack, rather than allowing the recursive function to return\nhigher-order (non-encodable) functions.\n\nFor example, consider checking for equality of trees: the recursor has type `tree → tree → bool`,\nthe motive is `tree → bool`, and the inductive step calls the inductive hypotheses,\nwhich are `left : tree → bool` and `right : tree bool` on the current left and right subtrees.\n\nThis is an issue, because `tree → bool` is not encodable, and indeed, any total\ncomplexity class (e.g. the primitive recursive functions) cannot interpret itself,\nso it is not possible to have the motive be a representation of the \"code\" for `tree → bool`.\n\nIn general, for a W-type with nodes labeled by `α` and children by `β : α → Type`,\nwe write `stack_rec : W_type β → γ → δ`, defined primarily by\n  - `pre : Π x, β x → γ → γ`: \"prepares\" the arguments to the inductive hypothesis,\n    given the current node's children `Π x, β x` and the current argument `γ`\n  - `post : (Π x, (β x → δ) → δ) → γ → δ`: computes the result given the inductive\n  hypotheses `(β x → δ)` and the current argument `γ`.\n\nTODO: generalize `stack_rec` to all W-types. Tactic to automatically convert structural\nrecursion where the motive is itself a function to `stack_rec`. This will enable us\nto write functions naturally in Lean and then automatically prove that they are primitive recursive,\npolynomial time, etc. using a tactic.\n-/\n\nnamespace tree\nopen_locale tree\n\nvariables {α : Type} {β : Type} (base : α → β) (pre₁ pre₂ : tree unit → tree unit → α → α)\n  (post : β → β → tree unit → tree unit → α → β)\n\n/-- Recursion with an explicit stack for `tree unit` -/\n@[simp]\ndef stack_rec : tree unit → α → β\n| nil d := base d\n| (x △ y) d := post (stack_rec x (pre₁ x y d)) (stack_rec y (pre₂ x y d)) x y d\n\n/-- An element on the stack is either the result (`sum.inr (x : β)`), or\n  the: tree, the argument α, and potentially what the left branch computed\n  if that computation has finished (`option β`)\n  -/\nabbreviation iterator_stack (α β : Type) := (tree unit × α × option β) ⊕ β\n\n/-- Do a single step of the iteration. In particular,\n    - If the top of the stack is a result, pop the value before that and plug in the result.\n    - If the top of the stack is a tree with the left branch uncomputed, push to the stack the\n        arguments for the left branch, unless the tree is `nil`, in which case we directly\n        compute the result.\n    - If the top of the stack is a tree with the left branch computed, push to the stack the\n      arguments for the right branch.\n  This halts when the stack contains fewer than 2 elements, or the top 2 elements are both results\n  -/\n@[simp] def stack_step : list (iterator_stack α β) → list (iterator_stack α β)\n| (sum.inr res :: sum.inl (tree, arg, none) :: xs) := sum.inl (tree, arg, some res) :: xs\n| (sum.inr res :: sum.inl (tree, arg, some left_res) :: xs) :=\n    sum.inr (post left_res res tree.left tree.right arg) :: xs\n| L@(sum.inl (tree, arg, some left_res) :: xs) :=\n  sum.inl (tree.right, pre₂ tree.left tree.right arg, none) :: L\n| (sum.inl (nil, arg, none) :: xs) := sum.inr (base arg) :: xs\n| L@(sum.inl (x △ y, arg, none) :: xs) := sum.inl (x, pre₁ x y arg, none) :: L\n| x := x\n\n@[simp] lemma stack_step_nil : stack_step base pre₁ pre₂ post [] = [] := rfl\n@[simp] lemma stack_step_singleton (res : β) :\n  stack_step base pre₁ pre₂ post [sum.inr res] = [sum.inr res] := rfl\n\ndef time_steps (x : tree unit) : ℕ := 5 * x.num_nodes + 1\n\n@[simp] lemma time_steps_nil : time_steps nil = 1 := rfl\nlemma time_steps_node (a b) : time_steps (a △ b) = 1 + b.time_steps + 2 + a.time_steps + 1 :=\nby { simp only [time_steps, num_nodes, mul_add, show 5 * 1 = 1 + 2 + 1 + 1, from rfl], ac_refl, }\n\n@[simp] lemma stack_step_iterate (x : tree unit) (arg : α) (xs : list (iterator_stack α β)) :\n  (stack_step base pre₁ pre₂ post)^[x.time_steps] (sum.inl (x, arg, none) :: xs) =\n  (sum.inr $ x.stack_rec base pre₁ pre₂ post arg) :: xs :=\nby induction x using tree.unit_rec_on generalizing arg xs; simp [time_steps_node, function.iterate_add, *]\n\nlemma stack_step_iterate' (x : tree unit) (arg : α) {n : ℕ} (hn : x.time_steps ≤ n) :\n  (stack_step base pre₁ pre₂ post)^[n] [sum.inl (x, arg, none)] =\n    [sum.inr $ x.stack_rec base pre₁ pre₂ post arg] :=\nbegin\n  rcases le_iff_exists_add'.mp hn with ⟨n, rfl⟩,\n  simp [function.iterate_add, function.iterate_fixed],\nend\n\nlemma stack_step_iterate_min (x : tree unit) (arg : α) (n : ℕ) :\n  (stack_step base pre₁ pre₂ post)^[min n x.time_steps] [sum.inl (x, arg, none)] =\n    ((stack_step base pre₁ pre₂ post)^[n] [sum.inl (x, arg, none)]) :=\n(le_total n x.time_steps).elim \n  (λ H, by rw min_eq_left_iff.mpr H)\n  (λ H, by rwa [min_eq_right_iff.mpr H, stack_step_iterate, stack_step_iterate'])\n\nend tree\n\nnamespace list\nvariables {α β : Type} {γ : Type*} (base : α → β) (pre : γ → list γ → α → α)\n  (post : β → γ → list γ → α → β)\n\n@[simp] def stack_rec : list γ → α → β\n| [] a := base a\n| (x :: xs) a := post (stack_rec xs (pre x xs a)) x xs a\n\nend list\n\nnamespace nat\nvariables {α β : Type} (base : α → β) (pre : ℕ → α → α) (post : β → ℕ → α → β)\n\n@[simp] def stack_rec : ℕ → α → β\n| 0 x := base x\n| (n+1) x := post (stack_rec n (pre n x)) n x\n\nend nat\n", "meta": {"author": "prakol16", "repo": "circuits", "sha": "cdf4ce1e019d6817e4abe0d082d8d379539fddca", "save_path": "github-repos/lean/prakol16-circuits", "path": "github-repos/lean/prakol16-circuits/circuits-cdf4ce1e019d6817e4abe0d082d8d379539fddca/src/stack_rec.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426302, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4603530395796255}}
{"text": "lemma add_left_eq_zero {{a b : mynat}} (H : a + b = 0) : b = 0 :=\nbegin\ncases b with d,\nrefl,\nrw add_succ at H,\nhave f := succ_ne_zero (a + d) H,\nexfalso,\nexact f,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/6-advanced-addition-world/l10.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8479677506936879, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4603305571659798}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Mario Carneiro\n-/\nimport control.traversable.equiv\nimport data.vector.basic\n\nuniverses u v w\n\nnamespace d_array\nvariables {n : ℕ} {α : fin n → Type u}\n\ninstance [∀ i, inhabited (α i)] : inhabited (d_array n α) :=\n⟨⟨λ _, default _⟩⟩\n\nend d_array\n\nnamespace array\n\ninstance {n α} [inhabited α] : inhabited (array n α) :=\nd_array.inhabited\n\ntheorem to_list_of_heq {n₁ n₂ α} {a₁ : array n₁ α} {a₂ : array n₂ α}\n  (hn : n₁ = n₂) (ha : a₁ == a₂) : a₁.to_list = a₂.to_list :=\nby congr; assumption\n\n/- rev_list -/\n\nsection rev_list\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem rev_list_reverse_aux : ∀ i (h : i ≤ n) (t : list α),\n  (a.iterate_aux (λ _, (::)) i h []).reverse_core t = a.rev_iterate_aux (λ _, (::)) i h t\n| 0     h t := rfl\n| (i+1) h t := rev_list_reverse_aux i _ _\n\n@[simp] theorem rev_list_reverse : a.rev_list.reverse = a.to_list :=\nrev_list_reverse_aux _ _ _\n\n@[simp] theorem to_list_reverse : a.to_list.reverse = a.rev_list :=\nby rw [←rev_list_reverse, list.reverse_reverse]\n\nend rev_list\n\n/- mem -/\n\nsection mem\nvariables {n : ℕ} {α : Type u} {v : α} {a : array n α}\n\ntheorem mem.def : v ∈ a ↔ ∃ i, a.read i = v :=\niff.rfl\n\ntheorem mem_rev_list_aux : ∀ {i} (h : i ≤ n),\n  (∃ (j : fin n), (j : ℕ) < i ∧ read a j = v) ↔ v ∈ a.iterate_aux (λ _, (::)) i h []\n| 0     _ := ⟨λ ⟨i, n, _⟩, absurd n i.val.not_lt_zero, false.elim⟩\n| (i+1) h := let IH := mem_rev_list_aux (le_of_lt h) in\n  ⟨λ ⟨j, ji1, e⟩, or.elim (lt_or_eq_of_le $ nat.le_of_succ_le_succ ji1)\n    (λ ji, list.mem_cons_of_mem _ $ IH.1 ⟨j, ji, e⟩)\n    (λ je, by simp [d_array.iterate_aux]; apply or.inl; unfold read at e;\n          have H : j = ⟨i, h⟩ := fin.eq_of_veq je; rwa [←H, e]),\n  λ m, begin\n    simp [d_array.iterate_aux, list.mem] at m,\n    cases m with e m',\n    exact ⟨⟨i, h⟩, nat.lt_succ_self _, eq.symm e⟩,\n    exact let ⟨j, ji, e⟩ := IH.2 m' in\n    ⟨j, nat.le_succ_of_le ji, e⟩\n  end⟩\n\n@[simp] theorem mem_rev_list : v ∈ a.rev_list ↔ v ∈ a :=\niff.symm $ iff.trans\n  (exists_congr $ λ j, iff.symm $\n    show j.1 < n ∧ read a j = v ↔ read a j = v,\n    from and_iff_right j.2)\n  (mem_rev_list_aux _)\n\n@[simp] theorem mem_to_list : v ∈ a.to_list ↔ v ∈ a :=\nby rw ←rev_list_reverse; exact list.mem_reverse.trans mem_rev_list\n\nend mem\n\n/- foldr -/\n\nsection foldr\nvariables {n : ℕ} {α : Type u} {β : Type w} {b : β} {f : α → β → β} {a : array n α}\n\ntheorem rev_list_foldr_aux : ∀ {i} (h : i ≤ n),\n  (d_array.iterate_aux a (λ _, (::)) i h []).foldr f b = d_array.iterate_aux a (λ _, f) i h b\n| 0     h := rfl\n| (j+1) h := congr_arg (f (read a ⟨j, h⟩)) (rev_list_foldr_aux _)\n\ntheorem rev_list_foldr : a.rev_list.foldr f b = a.foldl b f :=\nrev_list_foldr_aux _\n\nend foldr\n\n/- foldl -/\n\nsection foldl\nvariables {n : ℕ} {α : Type u} {β : Type w} {b : β} {f : β → α → β} {a : array n α}\n\ntheorem to_list_foldl : a.to_list.foldl f b = a.foldl b (function.swap f) :=\nby rw [←rev_list_reverse, list.foldl_reverse, rev_list_foldr]\n\nend foldl\n\n/- length -/\n\nsection length\nvariables {n : ℕ} {α : Type u}\n\ntheorem rev_list_length_aux (a : array n α) (i h) :\n  (a.iterate_aux (λ _, (::)) i h []).length = i :=\nby induction i; simp [*, d_array.iterate_aux]\n\n@[simp] theorem rev_list_length (a : array n α) : a.rev_list.length = n :=\nrev_list_length_aux a _ _\n\n@[simp] theorem to_list_length (a : array n α) : a.to_list.length = n :=\nby rw[←rev_list_reverse, list.length_reverse, rev_list_length]\n\nend length\n\n/- nth -/\n\nsection nth\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem to_list_nth_le_aux (i : ℕ) (ih : i < n) : ∀ j {jh t h'},\n  (∀ k tl, j + k = i → list.nth_le t k tl = a.read ⟨i, ih⟩) →\n  (a.rev_iterate_aux (λ _, (::)) j jh t).nth_le i h' = a.read ⟨i, ih⟩\n| 0     _  _ _  al := al i _ $ zero_add _\n| (j+1) jh t h' al := to_list_nth_le_aux j $ λ k tl hjk,\n  show list.nth_le (a.read ⟨j, jh⟩ :: t) k tl = a.read ⟨i, ih⟩, from\n  match k, hjk, tl with\n  | 0,    e, tl := match i, e, ih with ._, rfl, _ := rfl end\n  | k'+1, _, tl := by simp[list.nth_le]; exact al _ _ (by simp [add_comm, add_assoc, *]; cc)\n  end\n\ntheorem to_list_nth_le (i : ℕ) (h h') : list.nth_le a.to_list i h' = a.read ⟨i, h⟩ :=\nto_list_nth_le_aux _ _ _ (λ k tl, absurd tl k.not_lt_zero)\n\n@[simp] theorem to_list_nth_le' (a : array n α) (i : fin n) (h') :\n  list.nth_le a.to_list i h' = a.read i :=\nby cases i; apply to_list_nth_le\n\ntheorem to_list_nth {i v} : list.nth a.to_list i = some v ↔ ∃ h, a.read ⟨i, h⟩ = v :=\nbegin\n  rw list.nth_eq_some,\n  have ll := to_list_length a,\n  split; intro h; cases h with h e; subst v,\n  { exact ⟨ll ▸ h, (to_list_nth_le _ _ _).symm⟩ },\n  { exact ⟨ll.symm ▸ h, to_list_nth_le _ _ _⟩ }\nend\n\ntheorem write_to_list {i v} : (a.write i v).to_list = a.to_list.update_nth i v :=\nlist.ext_le (by simp) $ λ j h₁ h₂, begin\n  have h₃ : j < n, {simpa using h₁},\n  rw [to_list_nth_le _ h₃],\n  refine let ⟨_, e⟩ := list.nth_eq_some.1 _ in e.symm,\n  by_cases ij : (i : ℕ) = j,\n  { subst j, rw [show (⟨(i : ℕ), h₃⟩ : fin _) = i, from fin.eq_of_veq rfl,\n      array.read_write, list.nth_update_nth_of_lt],\n    simp [h₃] },\n  { rw [list.nth_update_nth_ne _ _ ij, a.read_write_of_ne,\n        to_list_nth.2 ⟨h₃, rfl⟩],\n    exact fin.ne_of_vne ij }\nend\n\nend nth\n\n/- enum -/\n\nsection enum\nvariables {n : ℕ} {α : Type u} {a : array n α}\n\ntheorem mem_to_list_enum {i v} : (i, v) ∈ a.to_list.enum ↔ ∃ h, a.read ⟨i, h⟩ = v :=\nby simp [list.mem_iff_nth, to_list_nth, and.comm, and.assoc, and.left_comm]\n\nend enum\n\n/- to_array -/\n\nsection to_array\nvariables {n : ℕ} {α : Type u}\n\n@[simp] theorem to_list_to_array (a : array n α) : a.to_list.to_array == a :=\nheq_of_heq_of_eq\n  (@@eq.drec_on (λ m (e : a.to_list.length = m), (d_array.mk (λ v, a.to_list.nth_le v.1 v.2)) ==\n    (@d_array.mk m (λ _, α) $ λ v, a.to_list.nth_le v.1 $ e.symm ▸ v.2)) a.to_list_length heq.rfl) $\n  d_array.ext $ λ ⟨i, h⟩, to_list_nth_le i h _\n\n@[simp] theorem to_array_to_list (l : list α) : l.to_array.to_list = l :=\nlist.ext_le (to_list_length _) $ λ n h1 h2, to_list_nth_le _ h2 _\n\nend to_array\n\n/- push_back -/\n\nsection push_back\nvariables {n : ℕ} {α : Type u} {v : α} {a : array n α}\n\nlemma push_back_rev_list_aux : ∀ i h h',\n  d_array.iterate_aux (a.push_back v) (λ _, (::)) i h [] = d_array.iterate_aux a (λ _, (::)) i h' []\n| 0 h h' := rfl\n| (i+1) h h' := begin\n  simp [d_array.iterate_aux],\n  refine ⟨_, push_back_rev_list_aux _ _ _⟩,\n  dsimp [read, d_array.read, push_back],\n  rw [dif_neg], refl,\n  exact ne_of_lt h',\nend\n\n@[simp] theorem push_back_rev_list : (a.push_back v).rev_list = v :: a.rev_list :=\nbegin\n  unfold push_back rev_list foldl iterate d_array.iterate,\n  dsimp [d_array.iterate_aux, read, d_array.read, push_back],\n  rw [dif_pos (eq.refl n)],\n  apply congr_arg,\n  apply push_back_rev_list_aux\nend\n\n@[simp] theorem push_back_to_list : (a.push_back v).to_list = a.to_list ++ [v] :=\nby rw [←rev_list_reverse, ←rev_list_reverse, push_back_rev_list, list.reverse_cons]\n\n@[simp] lemma read_push_back_left (i : fin n) : (a.push_back v).read i.cast_succ = a.read i :=\nbegin\n  cases i with i hi,\n  have : ¬ i = n := ne_of_lt hi,\n  simp [push_back, this, fin.cast_succ, fin.cast_add, fin.cast_le, fin.cast_lt, read, d_array.read]\nend\n\n@[simp] lemma read_push_back_right : (a.push_back v).read (fin.last _) = v :=\nbegin\n  cases hn : fin.last n with k hk,\n  have : k = n := by simpa [fin.eq_iff_veq ] using hn.symm,\n  simp [push_back, this, fin.cast_succ, fin.cast_add, fin.cast_le, fin.cast_lt, read, d_array.read]\nend\n\nend push_back\n\n/- foreach -/\n\nsection foreach\nvariables {n : ℕ} {α : Type u} {β : Type v} {i : fin n} {f : fin n → α → β} {a : array n α}\n\n@[simp] theorem read_foreach : (foreach a f).read i = f i (a.read i) :=\nrfl\n\nend foreach\n\n/- map -/\n\nsection map\nvariables {n : ℕ} {α : Type u} {β : Type v} {i : fin n} {f : α → β} {a : array n α}\n\ntheorem read_map : (a.map f).read i = f (a.read i) :=\nread_foreach\n\nend map\n\n/- map₂ -/\n\nsection map₂\nvariables {n : ℕ} {α : Type u} {i : fin n} {f : α → α → α} {a₁ a₂ : array n α}\n\n@[simp] theorem read_map₂ : (map₂ f a₁ a₂).read i = f (a₁.read i) (a₂.read i) :=\nread_foreach\n\nend map₂\n\nend array\n\nnamespace equiv\n\n/-- The natural equivalence between length-`n` heterogeneous arrays\nand dependent functions from `fin n`. -/\ndef d_array_equiv_fin {n : ℕ} (α : fin n → Type*) : d_array n α ≃ (Π i, α i) :=\n⟨d_array.read, d_array.mk, λ ⟨f⟩, rfl, λ f, rfl⟩\n\n/-- The natural equivalence between length-`n` arrays and functions from `fin n`. -/\ndef array_equiv_fin (n : ℕ) (α : Type*) : array n α ≃ (fin n → α) :=\nd_array_equiv_fin _\n\n/-- The natural equivalence between length-`n` vectors and length-`n` arrays. -/\ndef vector_equiv_array (α : Type*) (n : ℕ) : vector α n ≃ array n α :=\n(vector_equiv_fin _ _).trans (array_equiv_fin _ _).symm\n\nend equiv\n\nnamespace array\nopen function\nvariable {n : ℕ}\n\ninstance : traversable (array n) :=\n@equiv.traversable (flip vector n) _ (λ α, equiv.vector_equiv_array α n) _\n\ninstance : is_lawful_traversable (array n) :=\n@equiv.is_lawful_traversable (flip vector n) _ (λ α, equiv.vector_equiv_array α n) _ _\n\nend array\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/array/lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132314, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.4600832451244124}}
{"text": "import GMLInit.Data.Basic\nimport GMLInit.Data.Nat\n\nnamespace Int\n\nattribute [local eliminator] Nat.recDiag\n\nprotected abbrev mk := Int.subNatNat\n\nscoped infix:55 \" ⊖ \" => Int.mk\n\ntheorem zero_mk_zero : 0 ⊖ 0 = 0 := rfl\n\ntheorem zero_mk_succ (n) : (0 ⊖ n + 1) = Int.negSucc n := rfl\n\ntheorem succ_mk_zero (m) : (m + 1 ⊖ 0) = Int.ofNat (m+1) := by\n  rw [Int.mk, Int.subNatNat, Nat.zero_sub, Nat.sub_zero]\n\ntheorem succ_mk_succ (m n) : (m + 1 ⊖ n + 1) = (m ⊖ n) := by\n  rw [Int.mk, Int.subNatNat, Int.subNatNat, Nat.succ_sub_succ, Nat.succ_sub_succ]\n\ntheorem mk_zero (m) : (m ⊖ 0) = ofNat m := by\n  rw [Int.mk, Int.subNatNat, Nat.zero_sub, Nat.sub_zero]\n\ntheorem zero_mk (n) : (0 ⊖ n) = negOfNat n :=\n  match n with\n  | 0 => rfl\n  | _+1 => rfl\n\ntheorem one_mk_zero : (1 ⊖ 0) = 1 := rfl\n\nprotected def recMk.{u} {motive : Int → Sort u} (mk : (m n : Nat) → motive (m ⊖ n)) : (i : Int) → motive i\n| Int.ofNat m => mk_zero m ▸ mk m 0\n| Int.negSucc n => mk 0 (n + 1)\n\nprotected def recMkOn.{u} {motive : Int → Sort u} (i : Int) (mk : (m n : Nat) → motive (m ⊖ n)) : motive i := Int.recMk mk i\n\nprotected def casesMkOn.{u} {motive : Int → Sort u} (i : Int) (mk : (m n : Nat) → motive (m ⊖ n)) : motive i := Int.recMk mk i\n\n-- asseert theorem add_zero (x : Int) : x + 0 = x\n\n-- assert theorem zero_add (x : Int) : 0 + x = x\n\ntheorem mk_self (m) : (m ⊖ m) = 0 := by\n  induction m with\n  | zero => rfl\n  | succ m ih => rw [succ_mk_succ]; exact ih\n\ntheorem add_mk_add_left (k m n) : (k + m ⊖ k + n) = (m ⊖ n) := by\n  induction k with\n  | zero => rw [Nat.zero_add, Nat.zero_add]\n  | succ k ih => rw [Nat.succ_add', Nat.succ_add', succ_mk_succ]; exact ih\n\ntheorem add_mk_add_right (k m n) : (m + k ⊖ n + k) = (m ⊖ n) := by\n  induction k with\n  | zero => rw [Nat.add_zero, Nat.add_zero]\n  | succ k ih => rw [Nat.add_succ' m k, Nat.add_succ' n k, succ_mk_succ]; exact ih\n\ntheorem mk_add_ofNat (m n k) : (m ⊖ n) + ofNat k = (m + k ⊖ n) := by\n  induction m, n with\n  | zero_zero => rw [zero_mk_zero, Int.zero_add, Nat.zero_add, mk_zero]\n  | zero_succ n => rw [zero_mk_succ, Nat.zero_add]; rfl\n  | succ_zero m => rw [succ_mk_zero, mk_zero]; rfl\n  | succ_succ m n ih => rw [succ_mk_succ, Nat.succ_add', succ_mk_succ, ih]\n\ntheorem mk_add_negSucc (m n k) : (m ⊖ n) + negSucc k = (m ⊖ n + k + 1) := by\n  induction m, n with\n  | zero_zero => rw [zero_mk_zero, Int.zero_add, Nat.zero_add]; rfl\n  | zero_succ n => rw [zero_mk_succ, zero_mk_succ, Nat.succ_add']; rfl\n  | succ_zero m => rw [succ_mk_zero, Nat.zero_add]; rfl\n  | succ_succ m n ih => rw [succ_mk_succ, Nat.succ_add', succ_mk_succ]; exact ih\n\ntheorem mk_add_mk (m₁ n₁ m₂ n₂) : (m₁ ⊖ n₁) + (m₂ ⊖ n₂) = (m₁ + m₂ ⊖ n₁ + n₂) := by\n  induction m₂, n₂ with\n  | zero_zero => rw [zero_mk_zero, Int.add_zero, Nat.add_zero, Nat.add_zero]\n  | zero_succ n₂ => rw [zero_mk_succ, Nat.add_succ', mk_add_negSucc]; rfl\n  | succ_zero m₂ => rw [mk_zero, mk_add_ofNat]; rfl\n  | succ_succ m₂ n₂ ih => rw [succ_mk_succ, Nat.add_succ' m₁ m₂, Nat.add_succ' n₁ n₂, succ_mk_succ]; exact ih\n\ntheorem neg_mk (m n) : -(m ⊖ n) = (n ⊖ m) := by\n  induction m, n with\n  | zero_zero => rw [zero_mk_zero]; rfl\n  | zero_succ n => rw [zero_mk_succ, succ_mk_zero]; rfl\n  | succ_zero m => rw [succ_mk_zero, zero_mk_succ]; rfl\n  | succ_succ m n ih => rw [succ_mk_succ, succ_mk_succ]; exact ih\n\ntheorem mk_sub_mk (m₁ n₁ m₂ n₂) : (m₁ ⊖ n₁) - (m₂ ⊖ n₂) = (m₁ + n₂ ⊖ n₁ + m₂) :=\n  show (m₁ ⊖ n₁) + -(m₂ ⊖ n₂) = (m₁ + n₂ ⊖ n₁ + m₂) by rw [neg_mk, mk_add_mk]\n\ntheorem nonNeg_mk (m n) : NonNeg (m ⊖ n) ↔ n ≤ m := by\n  induction m, n with\n  | zero_zero =>\n    rw [zero_mk_zero]\n    constr\n    · intro; reflexivity\n    · intro; apply NonNeg.mk\n  | zero_succ n =>\n    rw [zero_mk_succ]\n    constr\n    · intro; contradiction\n    · intro; contradiction\n  | succ_zero m =>\n    rw [succ_mk_zero]\n    constr\n    · intro; apply Nat.zero_le\n    · intro; apply NonNeg.mk\n  | succ_succ m n ih =>\n    rw [succ_mk_succ]\n    rw [Nat.succ_le_succ_iff_le]\n    exact ih\n\ntheorem mk_le_mk (m₁ n₁ m₂ n₂) : (m₁ ⊖ n₁) ≤ (m₂ ⊖ n₂) ↔ n₂ + m₁ ≤ m₂ + n₁ := by\n  simp only [LE.le, Int.le]\n  rw [mk_sub_mk, nonNeg_mk]\n  reflexivity\n\ntheorem mk_lt_mk (m₁ n₁ m₂ n₂) : (m₁ ⊖ n₁) < (m₂ ⊖ n₂) ↔ n₂ + m₁ < m₂ + n₁ := by\n  simp only [LT.lt, Int.lt, Nat.lt]\n  rw [←one_mk_zero, mk_add_mk, mk_le_mk, Nat.add_succ, Nat.add_zero]\n  reflexivity\n\n-- assert theorem add_assoc (i j k : Int) : (i + j) + k = i + (j + k)\n\n-- assert theorem add_comm (i j : Int) : i + j = j + i\n\n-- assert theorem add_left_comm (i j k : Int) : i + (j + k) = j + (i + k)\n\n-- assert theorem add_right_comm (i j k : Int) : (i + j) + k = (i + k) + j\n\nprotected theorem add_cross_comm (i₁ i₂ j₁ j₂ : Int) : (i₁ + i₂) + (j₁ + j₂) = (i₁ + j₁) + (i₂ + j₂) :=\n  calc\n  _ = i₁ + (i₂ + (j₁ + j₂)) := by rw [Int.add_assoc]\n  _ = i₁ + (j₁ + (i₂ + j₂)) := by rw [Int.add_left_comm i₂ j₁ j₂]\n  _ = (i₁ + j₁) + (i₂ + j₂) := by rw [Int.add_assoc]\n\n-- assert theorem neg_zero : -0 = 0\n\n-- assert theorem neg_neg (i : Int) : -(-i) = i\n\n-- assert theorem neg_add (i j : Int) : -(i + j) = -i + -j\n\nprotected theorem add_neg_self_left (i : Int) : -i + i = 0 := by\n  cases i using Int.casesMkOn with\n  | mk mi ni => rw [neg_mk, mk_add_mk, Nat.add_comm mi ni, mk_self]\n\nprotected theorem add_neg_self_right (i : Int) : i + -i = 0 := by\n  cases i using Int.casesMkOn with\n  | mk mi ni => rw [neg_mk, mk_add_mk, Nat.add_comm mi ni, mk_self]\n\nprotected theorem sub_eq (i j : Int) : i - j = i + -j := rfl\n\n-- assert theorem sub_zero (i : Int) : i - 0 = i\n\n-- assert theorem zero_sub (i : Int) : 0 - i = -i\n\n-- assert theorem sub_self (i : Int) : i - i = 0\n\n-- assert theorem add_sub_assoc (i j k : Int) : (i + j) - k = i + (j - k)\n\nprotected theorem sub_add_assoc (i j k : Int) : (i - j) + k = i - (j - k) :=\n  calc\n  _ = (i + -j) + k := by rw [Int.sub_eq]\n  _ = i + (-j + k) := by rw [Int.add_assoc]\n  _ = i + (-j + -(-k)) := by rw [Int.neg_neg]\n  _ = i + -(j + -k) := by rw [Int.neg_add]\n  _ = i - (j - k) := by rw [Int.sub_eq, Int.sub_eq]\n\n-- assert theorem add_sub_cancel (i j : Int) : (i + j) - j = i\n\n-- assert theorem sub_add_cancel (i j : Int) : (i - j) + j = i\n\n-- assert theorem neg_sub (i j : Int) : -(i - j) = j - i\n\nprotected theorem add_left_cancel' (i : Int) {j k : Int} (h : i + j = i + k) : j = k :=\n  calc\n  _ = 0 + j := by rw [Int.zero_add]\n  _ = (-i + i) + j := by rw [Int.add_neg_self_left]\n  _ = -i + (i + j) := by rw [Int.add_assoc]\n  _ = -i + (i + k) := by rw [h]\n  _ = (-i + i) + k := by rw [Int.add_assoc]\n  _ = 0 + k := by rw [Int.add_neg_self_left]\n  _ = k := by rw [Int.zero_add]\n\nprotected theorem add_right_cancel' (i : Int) {j k : Int} (h : j + i = k + i) : j = k :=\n  calc\n  _ = j + 0 := by rw [Int.add_zero]\n  _ = j + (i + -i) := by rw [Int.add_neg_self_right]\n  _ = (j + i) + -i := by rw [Int.add_assoc]\n  _ = (k + i) + -i := by rw [h]\n  _ = k + (i + -i) := by rw [Int.add_assoc]\n  _ = k + 0 := by rw [Int.add_neg_self_right]\n  _ = k := by rw [Int.add_zero]\n\n-- assert theorem mul_zero (i : Int) : i * 0 = 0\n\n-- assert theorem zero_mul (i : Int) : 0 * i = 0\n\n-- assert theorem mul_one (i : Int) : i * 1 = i\n\n-- assert theorem one_mul (i : Int) : 1 * i = i\n\ntheorem mk_mul_ofNat (m n k) : (m ⊖ n) * ofNat k = (m * k ⊖ n * k) := by\n  induction m, n with\n  | zero_zero => rw [Nat.zero_mul, zero_mk_zero, Int.zero_mul]\n  | zero_succ n => rw [Nat.zero_mul, zero_mk, zero_mk]; rfl\n  | succ_zero m => rw [Nat.zero_mul, mk_zero, mk_zero]; rfl\n  | succ_succ m n ih => rw [Nat.succ_mul, Nat.succ_mul, succ_mk_succ, add_mk_add_right]; exact ih\n\ntheorem mk_mul_negSucc (m n k) : (m ⊖ n) * negSucc k = (n * (k + 1) ⊖ m * (k + 1)) := by\n  induction m, n with\n  | zero_zero => rw [Nat.zero_mul, zero_mk_zero, Int.zero_mul]\n  | zero_succ n => rw [Nat.zero_mul, zero_mk, mk_zero]; rfl\n  | succ_zero m => rw [Nat.zero_mul, mk_zero, zero_mk]; rfl\n  | succ_succ m n ih => rw [Nat.succ_mul, Nat.succ_mul, succ_mk_succ, add_mk_add_right]; exact ih\n\ntheorem mk_mul_mk (m₁ n₁ m₂ n₂) : (m₁ ⊖ n₁) * (m₂ ⊖ n₂) = (m₁ * m₂ + n₁ * n₂ ⊖ m₁ * n₂ + n₁ * m₂) := by\n  induction m₂, n₂ with\n  | zero_zero => simp only [Nat.zero_mul, Nat.mul_zero, Nat.add_zero, Nat.zero_add, zero_mk_zero, Int.mul_zero]\n  | zero_succ n₂ => simp only [Nat.zero_mul, Nat.mul_zero, Nat.add_zero, Nat.zero_add, zero_mk_succ, mk_mul_negSucc]\n  | succ_zero m₂ => simp only [Nat.zero_mul, Nat.mul_zero, Nat.add_zero, Nat.zero_add, succ_mk_zero, mk_mul_ofNat, Nat.mul_comm]\n  | succ_succ m₂ n₂ ih => simp only [Nat.mul_succ, Nat.succ_mul]; rw [succ_mk_succ, Nat.add_cross_comm _ m₁ _ n₁, Nat.add_cross_comm _ m₁ _ n₁, add_mk_add_right]; exact ih\n\n-- assert theorem mul_assoc (i j k : Int) : (i * j) * k = i * (j * k)\n\n-- assert theorem mul_comm (i j : Int) : i * j = j * i\n\n-- assert theorem mul_left_comm (i j k : Int) : i * (j * k) = j * (i * k)\n\n-- assert theorem mul_right_comm (i j k : Int) : (i * j) * k = (i * k) * j\n\nprotected theorem mul_cross_comm (i₁ i₂ j₁ j₂ : Int) : (i₁ * i₂) * (j₁ * j₂) = (i₁ * j₁) * (i₂ * j₂) :=\n  calc\n  _ = i₁ * (i₂ * (j₁ * j₂)) := by rw [Int.mul_assoc]\n  _ = i₁ * (j₁ * (i₂ * j₂)) := by rw [Int.mul_left_comm i₂ j₁ j₂]\n  _ = (i₁ * j₁) * (i₂ * j₂) := by rw [Int.mul_assoc]\n\n-- assert theorem mul_neg (i j : Int) : i * (-j) = -(i * j)\n\n-- assert theorem neg_mul (i j : Int) : (-i) * j = -(i * j)\n\n-- assert theorem mul_add (i j k : Int) : i * (j + k) = i * j + i * k)\n\n-- assert theorem add_mul (i j k : Int) : (i + j) * k = i * k + j * k]\n\n-- assert theorem mul_sub (i j k : Int) : i * (j - k) = i * j - i * k\n\n-- assert theorem sub_mul (i j k : Int) : (i - j) * k = i * k - j * k\n\ntheorem le.intro' (i : Int) (k : Nat) : i ≤ i + k :=\n  show (NonNeg ((i+k)-i)) by\n  rw [Int.sub_eq, Int.add_right_comm, Int.add_neg_self_right, Int.zero_add]\n  apply NonNeg.mk\n\ntheorem le.dest' {i j : Int} : i ≤ j → ∃ (k : Nat), j = i + ofNat k := by\n  intro (h : NonNeg (j - i))\n  match hk : j - i with\n  | ofNat k => exists k; rw [←hk, Int.sub_eq, Int.add_left_comm, Int.add_neg_self_right, Int.add_zero]\n  | negSucc _ => rw [hk] at h; contradiction\n\n-- assert theorem le_refl (i : Int) : i ≤ i\n\n-- assert theorem le_trans {i j k : Int} : i ≤ j → j ≤ k → i ≤ k\n\n-- assert theorem le_antisymm {i j : Int} : i ≤ j → j ≤ i → i = j\n\n-- assert theorem le_total (i j : Int) : i ≤ j ∨ j ≤ i\n\n-- assert theorem add_le_add_left {i j : Int} : i ≤ j → ∀ (k : Int), k + i ≤ k + j\n\n-- assert theorem add_le_add_right {i j : Int} : i ≤ j → ∀ (k : Int), i + k ≤ j + k\n\n-- assert theorem sub_le_sub_right {i j : Int} : i ≤ j → ∀ (k : Int), i - k ≤ j - k\n\n-- assert theorem le_of_add_le_add_right {i j k : Int} (h : i + k ≤ j + k) : i ≤ j\n\n-- assert theorem le_of_add_le_add_left {i j k : Int} (h : i + j ≤ i + k) : j ≤ k\n\nprotected theorem le_succ_self (i : Int) : i ≤ i + 1 := le.intro' ..\n\nprotected theorem lt_iff_succ_le (i j : Int) : i < j ↔ i + 1 ≤ j := Iff.rfl\n\nprotected theorem le_iff_lt_succ (i j : Int) : i ≤ j ↔ i < j + 1 := by\n  rw [Int.lt_iff_succ_le]\n  constr\n  · apply Int.add_le_add_right (c:=1)\n  · apply Int.le_of_add_le_add_right\n\n-- assert theorem le_of_lt {i j : Int} : i < j → i ≤ j\n\n-- assert theorem lt_of_lt_of_le {i j k : Int} : i < j → j ≤ k → i < k\n\n-- assert theorem lt_of_le_of_lt {i j k : Int} : i ≤ j → j < k → i < k\n\n-- assert theorem lt_irrefl (i : Int) : ¬ i < i\n\n-- assert theorem lt_trans {i j k : Int} : i < j → j < k → i < k\n\nprotected theorem le_or_gt (i j : Int) : i ≤ j ∨ j < i := by\n  induction i using Int.casesMkOn with\n  | mk mi ni =>\n    induction j using Int.casesMkOn with\n    | mk mj nj =>\n      rw [mk_le_mk, mk_lt_mk]\n      rw [Nat.add_comm mi, Nat.add_comm mj]\n      exact Nat.le_or_gt ..\n\nprotected theorem lt_or_ge (i j : Int) : i < j ∨ j ≤ i := by\n  cases Int.le_or_gt j i with\n  | inl h => right; exact h\n  | inr h => left; exact h\n\ntheorem lt_or_eq_of_le {i j : Int} : i ≤ j → i < j ∨ i = j := by\n  intro hle\n  match le.dest' hle with\n  | ⟨0, (h : j = i + 0)⟩ =>\n    right\n    rw [h, Int.add_zero]\n  | ⟨n+1, (h : j = i + (ofNat n + 1))⟩ =>\n    left\n    rw [Int.lt_iff_succ_le]\n    rw [h, ←Int.add_assoc, Int.add_right_comm]\n    apply Int.le.intro'\n\nprotected theorem lt_of_le_of_ne {i j : Int} : i ≤ j → i ≠ j → i < j := by\n  intro hle hne\n  cases lt_or_eq_of_le hle with\n  | inl hlt => exact hlt\n  | inr heq => absurd heq; exact hne\n\nprotected theorem lt_connex {i j : Int} : i ≠ j → i < j ∨ j < i := by\n  intro hne\n  cases Int.le_or_gt i j with\n  | inl hle => left; apply Int.lt_of_le_of_ne hle hne\n  | inr hgt => right; exact hgt\n\nprotected theorem lt_compare {i j : Int} : i < j → ∀ (k : Int), i < k ∨ k < j := by\n  intro hij k\n  cases Int.le_or_gt k i with\n  | inl hle => right; exact Int.lt_of_le_of_lt hle hij\n  | inr hgt => left; exact hgt\n\ninstance : Relation.Reflexive (α:=Int) (.≤.) := ⟨Int.le_refl⟩\ninstance : Relation.Transitive (α:=Int) (.≤.) := ⟨Int.le_trans⟩\ninstance : Relation.Antisymmetric (α:=Int) (.≤.) := ⟨Int.le_antisymm⟩\ninstance : Relation.Total (α:=Int) (.≤.) := ⟨Int.le_total⟩\ninstance : Relation.Irreflexive (α:=Int) (.<.) := ⟨Int.lt_irrefl⟩\ninstance : Relation.Transitive (α:=Int) (.<.) := ⟨Int.lt_trans⟩\ninstance : Relation.Comparison (α:=Int) (.<.) := ⟨Int.lt_compare⟩\ninstance : Relation.Connex (α:=Int) (.<.) := ⟨Int.lt_connex⟩\ninstance : Relation.HTransitive (α:=Int) (.≤.) (.<.) (.<.) := ⟨Int.lt_of_le_of_lt⟩\ninstance : Relation.HTransitive (α:=Int) (.<.) (.≤.) (.<.) := ⟨Int.lt_of_lt_of_le⟩\n\nend Int\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/Int.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.45992052435528735}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\nInstances on punit.\n-/\n\nimport order.basic\nimport algebra.module algebra.group\n\nuniverses u\n\nopen lattice\n\nnamespace punit\nvariables (x y : punit.{u+1}) (s : set punit.{u+1})\n\ninstance : comm_ring punit :=\nby refine\n{ add := λ _ _, star,\n  zero := star,\n  neg := λ _, star,\n  mul := λ _ _, star,\n  one := star,\n  .. };\nintros; exact subsingleton.elim _ _\n\ninstance : comm_group punit :=\n{ inv := λ _, star,\n  mul_left_inv := λ _, subsingleton.elim _ _,\n  .. punit.comm_ring }\n\ninstance : complete_boolean_algebra punit :=\nby refine\n{ le := λ _ _, true,\n  le_antisymm := λ _ _ _ _, subsingleton.elim _ _,\n  lt := λ _ _, false,\n  lt_iff_le_not_le := λ _ _, iff_of_false not_false (λ H, H.2 trivial),\n  top := star,\n  bot := star,\n  sup := λ _ _, star,\n  inf := λ _ _, star,\n  Sup := λ _, star,\n  Inf := λ _, star,\n  sub := λ _ _, star,\n  .. punit.comm_ring, .. };\nintros; trivial\n\ninstance : canonically_ordered_monoid punit :=\nby refine\n{ lt_of_add_lt_add_left := λ _ _ _, id,\n  le_iff_exists_add := λ _ _, iff_of_true _ ⟨star, subsingleton.elim _ _⟩,\n  .. punit.comm_ring, .. punit.lattice.complete_boolean_algebra, .. };\nintros; trivial\n\ninstance : decidable_linear_ordered_cancel_comm_monoid punit :=\n{ add_left_cancel := λ _ _ _ _, subsingleton.elim _ _,\n  add_right_cancel := λ _ _ _ _, subsingleton.elim _ _,\n  le_of_add_le_add_left := λ _ _ _ _, trivial,\n  le_total := λ _ _, or.inl trivial,\n  decidable_le := λ _ _, decidable.true,\n  decidable_eq := punit.decidable_eq,\n  decidable_lt := λ _ _, decidable.false,\n  .. punit.canonically_ordered_monoid }\n\ninstance : module punit punit := module.of_core $\nby refine\n{ smul := λ _ _, star,\n  .. punit.comm_ring, .. };\nintros; exact subsingleton.elim _ _\n\n@[simp] lemma zero_eq : (0 : punit) = star := rfl\n@[simp] lemma one_eq : (1 : punit) = star := rfl\nattribute [to_additive punit.zero_eq] punit.one_eq\n@[simp] lemma add_eq : x + y = star := rfl\n@[simp] lemma mul_eq : x * y = star := rfl\nattribute [to_additive punit.add_eq] punit.mul_eq\n@[simp] lemma neg_eq : -x = star := rfl\n@[simp] lemma inv_eq : x⁻¹ = star := rfl\nattribute [to_additive punit.neg_eq] punit.inv_eq\n@[simp] lemma smul_eq : x • y = star := rfl\n@[simp] lemma top_eq : (⊤ : punit) = star := rfl\n@[simp] lemma bot_eq : (⊥ : punit) = star := rfl\n@[simp] lemma sup_eq : x ⊔ y = star := rfl\n@[simp] lemma inf_eq : x ⊓ y = star := rfl\n@[simp] lemma Sup_eq : Sup s = star := rfl\n@[simp] lemma Inf_eq : Inf s = star := rfl\n@[simp] protected lemma le : x ≤ y := trivial\n@[simp] lemma not_lt : ¬(x < y) := not_false\n\ninstance {α : Type*} [monoid α] (f : α → punit) : is_monoid_hom f :=\n⟨subsingleton.elim _ _, λ _ _, subsingleton.elim _ _⟩\n\ninstance {α : Type*} [add_monoid α] (f : α → punit) : is_add_monoid_hom f :=\n⟨subsingleton.elim _ _, λ _ _, subsingleton.elim _ _⟩\n\ninstance {α : Type*} [group α] (f : α → punit) : is_group_hom f :=\n⟨λ _ _, subsingleton.elim _ _⟩\n\ninstance {α : Type*} [add_group α] (f : α → punit) : is_add_group_hom f :=\n⟨λ _ _, subsingleton.elim _ _⟩\n\ninstance {α : Type*} [semiring α] (f : α → punit) : is_semiring_hom f :=\n{ .. punit.is_monoid_hom f, .. punit.is_add_monoid_hom f }\n\ninstance {α : Type*} [ring α] (f : α → punit) : is_ring_hom f :=\n{ .. punit.is_semiring_hom f }\n\nend punit\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/algebra/punit_instances.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4599205243552873}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nHahn decomposition theorem\n\nTODO:\n* introduce finite measures (into ℝ≥0)\n* show general for signed measures (into ℝ)\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.measure_theory.measure_space\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\nnamespace measure_theory\n\n\n-- suddenly this is necessary?!\n\ntheorem hahn_decomposition {α : Type u_1} [measurable_space α] {μ : measure α} {ν : measure α}\n    (hμ : coe_fn μ set.univ < ⊤) (hν : coe_fn ν set.univ < ⊤) :\n    ∃ (s : set α),\n        is_measurable s ∧\n          (∀ (t : set α), is_measurable t → t ⊆ s → coe_fn ν t ≤ coe_fn μ t) ∧\n            ∀ (t : set α), is_measurable t → t ⊆ (sᶜ) → coe_fn μ t ≤ coe_fn ν t :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/measure_theory/decomposition_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4599205243552873}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison, Johannes Hölzl, Reid Barton\n-/\nimport combinatorics.quiver.basic\nimport tactic.basic\n\n/-!\n# Categories\n\nDefines a category, as a type class parametrised by the type of objects.\n\n## Notations\n\nIntroduces notations\n* `X ⟶ Y` for the morphism spaces,\n* `f ≫ g` for composition in the 'arrows' convention.\n\nUsers may like to add `f ⊚ g` for composition in the standard convention, using\n```lean\nlocal notation f ` ⊚ `:80 g:80 := category.comp g f    -- type as \\oo\n```\n-/\n\n/--\nThe typeclass `category C` describes morphisms associated to objects of type `C : Type u`.\n\nThe universe levels of the objects and morphisms are independent, and will often need to be\nspecified explicitly, as `category.{v} C`.\n\nTypically any concrete example will either be a `small_category`, where `v = u`,\nwhich can be introduced as\n```\nuniverses u\nvariables {C : Type u} [small_category C]\n```\nor a `large_category`, where `u = v+1`, which can be introduced as\n```\nuniverses u\nvariables {C : Type (u+1)} [large_category C]\n```\n\nIn order for the library to handle these cases uniformly,\nwe generally work with the unconstrained `category.{v u}`,\nfor which objects live in `Type u` and morphisms live in `Type v`.\n\nBecause the universe parameter `u` for the objects can be inferred from `C`\nwhen we write `category C`, while the universe parameter `v` for the morphisms\ncan not be automatically inferred, through the category theory library\nwe introduce universe parameters with morphism levels listed first,\nas in\n```\nuniverses v u\n```\nor\n```\nuniverses v₁ v₂ u₁ u₂\n```\nwhen multiple independent universes are needed.\n\nThis has the effect that we can simply write `category.{v} C`\n(that is, only specifying a single parameter) while `u` will be inferred.\n\nOften, however, it's not even necessary to include the `.{v}`.\n(Although it was in earlier versions of Lean.)\nIf it is omitted a \"free\" universe will be used.\n-/\nlibrary_note \"category_theory universes\"\n\nuniverses v u\n\nnamespace category_theory\n\n/-- A preliminary structure on the way to defining a category,\ncontaining the data, but none of the axioms. -/\nclass category_struct (obj : Type u)\nextends quiver.{v+1} obj : Type (max u (v+1)) :=\n(id       : Π X : obj, hom X X)\n(comp     : Π {X Y Z : obj}, (X ⟶ Y) → (Y ⟶ Z) → (X ⟶ Z))\n\nnotation `𝟙` := category_struct.id -- type as \\b1\ninfixr ` ≫ `:80 := category_struct.comp -- type as \\gg\n\n/--\nThe typeclass `category C` describes morphisms associated to objects of type `C`.\nThe universe levels of the objects and morphisms are unconstrained, and will often need to be\nspecified explicitly, as `category.{v} C`. (See also `large_category` and `small_category`.)\n\nSee https://stacks.math.columbia.edu/tag/0014.\n-/\nclass category (obj : Type u)\nextends category_struct.{v} obj : Type (max u (v+1)) :=\n(id_comp' : ∀ {X Y : obj} (f : hom X Y), 𝟙 X ≫ f = f . obviously)\n(comp_id' : ∀ {X Y : obj} (f : hom X Y), f ≫ 𝟙 Y = f . obviously)\n(assoc'   : ∀ {W X Y Z : obj} (f : hom W X) (g : hom X Y) (h : hom Y Z),\n  (f ≫ g) ≫ h = f ≫ (g ≫ h) . obviously)\n\n-- `restate_axiom` is a command that creates a lemma from a structure field,\n-- discarding any auto_param wrappers from the type.\n-- (It removes a backtick from the name, if it finds one, and otherwise adds \"_lemma\".)\nrestate_axiom category.id_comp'\nrestate_axiom category.comp_id'\nrestate_axiom category.assoc'\nattribute [simp] category.id_comp category.comp_id category.assoc\nattribute [trans] category_struct.comp\n\n/--\nA `large_category` has objects in one universe level higher than the universe level of\nthe morphisms. It is useful for examples such as the category of types, or the category\nof groups, etc.\n-/\nabbreviation large_category (C : Type (u+1)) : Type (u+1) := category.{u} C\n/--\nA `small_category` has objects and morphisms in the same universe level.\n-/\nabbreviation small_category (C : Type u) : Type (u+1) := category.{u} C\n\nsection\nvariables {C : Type u} [category.{v} C] {X Y Z : C}\n\ninitialize_simps_projections category (to_category_struct_to_quiver_hom → hom,\n  to_category_struct_comp → comp, to_category_struct_id → id, -to_category_struct)\n\n/-- postcompose an equation between morphisms by another morphism -/\nlemma eq_whisker {f g : X ⟶ Y} (w : f = g) (h : Y ⟶ Z) : f ≫ h = g ≫ h :=\nby rw w\n/-- precompose an equation between morphisms by another morphism -/\nlemma whisker_eq (f : X ⟶ Y) {g h : Y ⟶ Z} (w : g = h) : f ≫ g = f ≫ h :=\nby rw w\n\ninfixr ` =≫ `:80 := eq_whisker\ninfixr ` ≫= `:80 := whisker_eq\n\nlemma eq_of_comp_left_eq {f g : X ⟶ Y} (w : ∀ {Z : C} (h : Y ⟶ Z), f ≫ h = g ≫ h) : f = g :=\nby { convert w (𝟙 Y), tidy }\nlemma eq_of_comp_right_eq {f g : Y ⟶ Z} (w : ∀ {X : C} (h : X ⟶ Y), h ≫ f = h ≫ g) : f = g :=\nby { convert w (𝟙 Y), tidy }\n\nlemma eq_of_comp_left_eq' (f g : X ⟶ Y)\n  (w : (λ {Z : C} (h : Y ⟶ Z), f ≫ h) = (λ {Z : C} (h : Y ⟶ Z), g ≫ h)) : f = g :=\neq_of_comp_left_eq (λ Z h, by convert congr_fun (congr_fun w Z) h)\nlemma eq_of_comp_right_eq' (f g : Y ⟶ Z)\n  (w : (λ {X : C} (h : X ⟶ Y), h ≫ f) = (λ {X : C} (h : X ⟶ Y), h ≫ g)) : f = g :=\neq_of_comp_right_eq (λ X h, by convert congr_fun (congr_fun w X) h)\n\nlemma id_of_comp_left_id (f : X ⟶ X) (w : ∀ {Y : C} (g : X ⟶ Y), f ≫ g = g) : f = 𝟙 X :=\nby { convert w (𝟙 X), tidy }\nlemma id_of_comp_right_id (f : X ⟶ X) (w : ∀ {Y : C} (g : Y ⟶ X), g ≫ f = g) : f = 𝟙 X :=\nby { convert w (𝟙 X), tidy }\n\n\n\nlemma dite_comp {P : Prop} [decidable P]\n  {X Y Z : C} (f : P → (X ⟶ Y)) (f' : ¬P → (X ⟶ Y)) (g : Y ⟶ Z) :\n  (if h : P then f h else f' h) ≫ g = (if h : P then f h ≫ g else f' h ≫ g) :=\nby { split_ifs; refl }\n\n/--\nA morphism `f` is an epimorphism if it can be \"cancelled\" when precomposed:\n`f ≫ g = f ≫ h` implies `g = h`.\n\nSee https://stacks.math.columbia.edu/tag/003B.\n-/\nclass epi (f : X ⟶ Y) : Prop :=\n(left_cancellation : Π {Z : C} (g h : Y ⟶ Z) (w : f ≫ g = f ≫ h), g = h)\n\n/--\nA morphism `f` is a monomorphism if it can be \"cancelled\" when postcomposed:\n`g ≫ f = h ≫ f` implies `g = h`.\n\nSee https://stacks.math.columbia.edu/tag/003B.\n-/\nclass mono (f : X ⟶ Y) : Prop :=\n(right_cancellation : Π {Z : C} (g h : Z ⟶ X) (w : g ≫ f = h ≫ f), g = h)\n\ninstance (X : C) : epi (𝟙 X) :=\n⟨λ Z g h w, by simpa using w⟩\ninstance (X : C) : mono (𝟙 X) :=\n⟨λ Z g h w, by simpa using w⟩\n\nlemma cancel_epi (f : X ⟶ Y) [epi f]  {g h : Y ⟶ Z} : (f ≫ g = f ≫ h) ↔ g = h :=\n⟨ λ p, epi.left_cancellation g h p, begin intro a, subst a end ⟩\nlemma cancel_mono (f : X ⟶ Y) [mono f] {g h : Z ⟶ X} : (g ≫ f = h ≫ f) ↔ g = h :=\n⟨ λ p, mono.right_cancellation g h p, begin intro a, subst a end ⟩\n\nlemma cancel_epi_id (f : X ⟶ Y) [epi f] {h : Y ⟶ Y} : (f ≫ h = f) ↔ h = 𝟙 Y :=\nby { convert cancel_epi f, simp, }\nlemma cancel_mono_id (f : X ⟶ Y) [mono f] {g : X ⟶ X} : (g ≫ f = f) ↔ g = 𝟙 X :=\nby { convert cancel_mono f, simp, }\n\nlemma epi_comp {X Y Z : C} (f : X ⟶ Y) [epi f] (g : Y ⟶ Z) [epi g] : epi (f ≫ g) :=\nbegin\n  split, intros Z a b w,\n  apply (cancel_epi g).1,\n  apply (cancel_epi f).1,\n  simpa using w,\nend\nlemma mono_comp {X Y Z : C} (f : X ⟶ Y) [mono f] (g : Y ⟶ Z) [mono g] : mono (f ≫ g) :=\nbegin\n  split, intros Z a b w,\n  apply (cancel_mono f).1,\n  apply (cancel_mono g).1,\n  simpa using w,\nend\n\nlemma mono_of_mono {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [mono (f ≫ g)] : mono f :=\nbegin\n  split, intros Z a b w,\n  replace w := congr_arg (λ k, k ≫ g) w,\n  dsimp at w,\n  rw [category.assoc, category.assoc] at w,\n  exact (cancel_mono _).1 w,\nend\n\nlemma mono_of_mono_fac {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [mono h] (w : f ≫ g = h) :\n  mono f :=\nby { substI h, exact mono_of_mono f g, }\n\nlemma epi_of_epi {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) [epi (f ≫ g)] : epi g :=\nbegin\n  split, intros Z a b w,\n  replace w := congr_arg (λ k, f ≫ k) w,\n  dsimp at w,\n  rw [←category.assoc, ←category.assoc] at w,\n  exact (cancel_epi _).1 w,\nend\n\nlemma epi_of_epi_fac {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} {h : X ⟶ Z} [epi h] (w : f ≫ g = h) :\n  epi g :=\nby substI h; exact epi_of_epi f g\nend\n\nsection\nvariable (C : Type u)\nvariable [category.{v} C]\n\nuniverse u'\n\ninstance ulift_category : category.{v} (ulift.{u'} C) :=\n{ hom  := λ X Y, (X.down ⟶ Y.down),\n  id   := λ X, 𝟙 X.down,\n  comp := λ _ _ _ f g, f ≫ g }\n\n-- We verify that this previous instance can lift small categories to large categories.\nexample (D : Type u) [small_category D] : large_category (ulift.{u+1} D) := by apply_instance\nend\n\nend category_theory\n\n/--\nMany proofs in the category theory library use the `dsimp, simp` pattern,\nwhich typically isn't necessary elsewhere.\n\nOne would usually hope that the same effect could be achieved simply with `simp`.\n\nThe essential issue is that composition of morphisms involves dependent types.\nWhen you have a chain of morphisms being composed, say `f : X ⟶ Y` and `g : Y ⟶ Z`,\nthen `simp` can operate succesfully on the morphisms\n(e.g. if `f` is the identity it can strip that off).\n\nHowever if we have an equality of objects, say `Y = Y'`,\nthen `simp` can't operate because it would break the typing of the composition operations.\nWe rarely have interesting equalities of objects\n(because that would be \"evil\" --- anything interesting should be expressed as an isomorphism\nand tracked explicitly),\nexcept of course that we have plenty of definitional equalities of objects.\n\n`dsimp` can apply these safely, even inside a composition.\n\nAfter `dsimp` has cleared up the object level, `simp` can resume work on the morphism level ---\nbut without the `dsimp` step, because `simp` looks at expressions syntactically,\nthe relevant lemmas might not fire.\n\nThere's no bound on how many times you potentially could have to switch back and forth,\nif the `simp` introduced new objects we again need to `dsimp`.\nIn practice this does occur, but only rarely, because `simp` tends to shorten chains of compositions\n(i.e. not introduce new objects at all).\n-/\nlibrary_note \"dsimp, simp\"\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/category_theory/category/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.45985782793833413}}
{"text": "import Mathlib.Tactic.TypeCheck\n\n/-- A term where `inferType` returns `Prop`, but which does not type check. -/\nelab \"wrong\" : term =>\n  return Lean.mkApp2 (.const ``id [.zero]) (.sort .zero) (.app (.sort .zero) (.sort .zero))\n\nexample : True := by\n  type_check Nat -- Type\n  type_check Bool.true -- Bool\n  type_check nat_lit 1 -- Nat\n  type_check (1 : Nat) -- Nat\n  type_check (True : _) -- Prop\n  type_check ∀ x y : Nat, x = y -- Prop\n  type_check fun x : Nat => 2 * x + 1 -- Nat -> Nat\n  fail_if_success type_check wrong\n  trivial\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/test/TypeCheck.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45985782271378445}}
{"text": "\nclass category (C : Type) :=\n( hom : C → C → Type )\n( id : (X : C) → hom X X )\n( comp : {X Y Z : C} → hom X Y → hom Y Z → hom X Z )\n( id_comp {X Y : C} (f : hom X Y) : comp (id X) f = f )\n( comp_id {X Y : C} (f : hom X Y) : comp f (id Y) = f )\n( assoc {W X Y Z : C} (f : hom W X) (g : hom X Y) (h : hom Y Z) :\n    comp (comp f g) h = comp f (comp g h) )\n\nnotation \" 𝟙 \" => category.id\ninfixr: 80 \" ≫ \" => category.comp\ninfixr: 10 \" ⟶ \" => category.hom\n\nvariable (C : Type) [category C]\n\ninductive prod_coprod : Type\n| of_cat' : C → prod_coprod\n| init : prod_coprod\n| prod : prod_coprod → prod_coprod → prod_coprod\n| coprod : prod_coprod → prod_coprod → prod_coprod\n| term : prod_coprod\n\n\nvariable {C}\n\nnamespace prod_coprod\n\n@[simp] def size : prod_coprod C → Nat\n| of_cat' _ => 1\n| init => 1\n| prod X Y => size X + size Y + 1\n| coprod X Y => size X + size Y + 1\n| term => 1\n\ninductive syn : (X Y : prod_coprod C) → Type\n| of_cat {X Y : C} : (X ⟶ Y) → syn (of_cat' X) (of_cat' Y)\n| prod_mk {X Y Z : prod_coprod C} : syn X Y → syn X Z → syn X (Y.prod Z)\n| fst {X Y : prod_coprod C} : syn (X.prod Y) X\n| snd {X Y : prod_coprod C} : syn (X.prod Y) Y\n| coprod_mk {X Y Z : prod_coprod C} : syn X Z → syn Y Z → syn (X.coprod Y) Z\n| inl {X Y : prod_coprod C} : syn X (X.coprod Y)\n| inr {X Y : prod_coprod C} : syn Y (X.coprod Y)\n| id (X : prod_coprod C) : syn X X\n| comp {X Y Z : prod_coprod C} : syn X Y → syn Y Z → syn X Z\n\nnamespace syn\n\ninductive rel : {X Y : prod_coprod C} → syn X Y → syn X Y → Prop\n| refl {X Y : prod_coprod C} (f : syn X Y) : rel f f\n| symm {X Y : prod_coprod C} {f g : syn X Y} : rel f g → rel g f\n| trans {X Y : prod_coprod C} {f g h : syn X Y} : rel f g → rel g h → rel f h\n| comp_congr {X Y Z : prod_coprod C} {f₁ f₂ : syn X Y} {g₁ g₂ : syn Y Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (f₁.comp g₁) (f₂.comp g₂)\n| prod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : syn X Y} {g₁ g₂ : syn X Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (f₁.prod_mk g₁) (f₂.prod_mk g₂)\n| coprod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : syn X Z} {g₁ g₂ : syn Y Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (f₁.coprod_mk g₁) (f₂.coprod_mk g₂)\n| id_comp {X Y : prod_coprod C} (f : syn X Y) : rel ((syn.id X).comp f) f\n| comp_id {X Y : prod_coprod C} (f : syn X Y) : rel (f.comp (syn.id Y)) f\n| assoc {W X Y Z : prod_coprod C} (f : syn W X) (g : syn X Y) (h : syn Y Z) :\n  rel ((f.comp g).comp h) (f.comp (g.comp h))\n| of_cat_id {X : C} : rel (syn.of_cat (𝟙 X)) (syn.id (of_cat' X))\n| of_cat_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  rel (syn.of_cat (f ≫ g)) (syn.comp (syn.of_cat f) (syn.of_cat g))\n| mk_fst_comp {X Y Z : prod_coprod C} (f : syn X Y) (g : syn X Z) :\n  rel (syn.comp (syn.prod_mk f g) syn.fst) f\n| mk_snd_comp {X Y Z : prod_coprod C} (f : syn X Y) (g : syn X Z) :\n  rel (syn.comp (syn.prod_mk f g) syn.snd) g\n| prod_eta {X Y Z : prod_coprod C} (f : syn X (Y.prod Z)) :\n  rel (syn.prod_mk (f.comp syn.fst) (f.comp syn.snd)) f\n| inl_comp_mk {X Y Z : prod_coprod C} (f : syn X Z) (g : syn Y Z) :\n  rel (syn.comp syn.inl (syn.coprod_mk f g)) f\n| inr_comp_mk {X Y Z : prod_coprod C} (f : syn X Z) (g : syn Y Z) :\n  rel (syn.comp syn.inr (syn.coprod_mk f g)) g\n| coprod_eta {X Y Z : prod_coprod C} (f : syn (X.coprod Y) Z) :\n  rel (syn.coprod_mk (syn.inl.comp f) (syn.inr.comp f)) f\n\ninfixl:50 \" ♥ \" => rel\n\ninstance : Trans (@rel C _ X Y) (@rel C _ X Y) (@rel C _ X Y) where\n  trans := rel.trans\n\ntheorem rel_prod {X Y Z : prod_coprod C} {f g : syn X (Y.prod Z)}\n  (h₁ : rel (f.comp syn.fst) (g.comp syn.fst))\n  (h₂ : rel (f.comp syn.snd) (g.comp syn.snd)) :\n  rel f g :=\nrel.trans (rel.symm (rel.prod_eta f)) (rel.trans (rel.prod_mk_congr h₁ h₂) (rel.prod_eta g))\n\ntheorem rel_coprod {X Y Z : prod_coprod C} {f g : syn (X.coprod Y) Z}\n  (h₁ : rel (syn.inl.comp f) (syn.inl.comp g))\n  (h₂ : rel (syn.inr.comp f) (syn.inr.comp g)) :\n  rel f g :=\nrel.trans (rel.symm (rel.coprod_eta f)) (rel.trans (rel.coprod_mk_congr h₁ h₂) (rel.coprod_eta g))\n\nend syn\n\ninductive norm_hom : (X Y : prod_coprod C) → Type\n| of_cat {X Y : C} (f : X ⟶ Y) : norm_hom (of_cat' X) (of_cat' Y)\n| coprod_mk {X Y Z : prod_coprod C} (f : norm_hom X Z) (g : norm_hom Y Z) :\n  norm_hom (X.coprod Y) Z\n| prod_mk {X Y Z : prod_coprod C} (f : norm_hom X Y) (g : norm_hom X Z) :\n  norm_hom X (prod Y Z)\n| comp_inl {X Y Z : prod_coprod C} (f : norm_hom X Y) :\n  norm_hom X (coprod Y Z)\n| comp_inr {X Y Z : prod_coprod C} (f : norm_hom X Z) :\n  norm_hom X (coprod Y Z)\n| fst_comp {X Y Z : prod_coprod C} (f : norm_hom X Z) :\n  norm_hom (prod X Y) Z\n| snd_comp {X Y Z : prod_coprod C} (f : norm_hom Y Z) :\n  norm_hom (prod X Y) Z\n| from_init (X : prod_coprod C) : norm_hom init X\n| to_term (X : prod_coprod C) : norm_hom X term\n\nnamespace norm_hom\n\ninductive rel : {X Y : prod_coprod C} → norm_hom X Y → norm_hom X Y → Prop\n| refl {X Y : prod_coprod C} (f : norm_hom X Y) : rel f f\n| symm {X Y : prod_coprod C} {f g : norm_hom X Y} : rel g f → rel f g\n| trans {X Y : prod_coprod C} {f g h : norm_hom X Y} : rel f g → rel g h → rel f h\n| coprod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Z} {g₁ g₂ : norm_hom Y Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (coprod_mk f₁ g₁) (coprod_mk f₂ g₂)\n| prod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Y} {g₁ g₂ : norm_hom X Z} :\n  rel f₁ f₂ → rel g₁ g₂ → rel (prod_mk f₁ g₁) (prod_mk f₂ g₂)\n| comp_inl_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Y} :\n  rel f₁ f₂ → rel (comp_inl f₁ : norm_hom X (coprod Y Z)) (comp_inl f₂)\n| comp_inr_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Z} :\n  rel f₁ f₂ → rel (comp_inr f₁ : norm_hom X (coprod Y Z)) (comp_inr f₂)\n| fst_comp_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom X Z} :\n  rel f₁ f₂ → rel (fst_comp f₁ : norm_hom (prod X Y) Z) (fst_comp f₂)\n| snd_comp_congr {X Y Z : prod_coprod C} {f₁ f₂ : norm_hom Y Z} :\n  rel f₁ f₂ → rel (snd_comp f₁ : norm_hom (prod X Y) Z) (snd_comp f₂)\n| fst_comp_prod_mk {W X Y Z : prod_coprod C} (f : norm_hom X Y) (g : norm_hom X Z) :\n  rel (fst_comp (prod_mk f g) : norm_hom (prod X W) (prod Y Z)) (prod_mk f.fst_comp g.fst_comp)\n| snd_comp_prod_mk {W X Y Z : prod_coprod C} (f : norm_hom X Y) (g : norm_hom X Z) :\n  rel (snd_comp (prod_mk f g) : norm_hom (prod W X) (prod Y Z)) (prod_mk f.snd_comp g.snd_comp)\n| comp_inl_coprod_mk {W X Y Z : prod_coprod C} (f : norm_hom W Y) (g : norm_hom X Y) :\n  rel (comp_inl (coprod_mk f g) : norm_hom (coprod W X) (coprod Y Z))\n    (coprod_mk f.comp_inl g.comp_inl)\n| comp_inr_coprod_mk {W X Y Z : prod_coprod C} (f : norm_hom W Y) (g : norm_hom X Y) :\n  rel (comp_inr (coprod_mk f g) : norm_hom (coprod W X) (coprod Z Y))\n    (coprod_mk f.comp_inr g.comp_inr)\n| fst_comp_comp_inl {W X Y Z : prod_coprod C} (f : norm_hom W Y) :\n  rel (f.fst_comp.comp_inl : norm_hom (prod W X) (coprod Y Z)) f.comp_inl.fst_comp\n| snd_comp_comp_inl {W X Y Z : prod_coprod C} (f : norm_hom X Y) :\n  rel (f.snd_comp.comp_inl : norm_hom (prod W X) (coprod Y Z)) f.comp_inl.snd_comp\n| fst_comp_comp_inr {W X Y Z : prod_coprod C} (f : norm_hom W Z) :\n  rel (f.fst_comp.comp_inr : norm_hom (prod W X) (coprod Y Z)) f.comp_inr.fst_comp\n| snd_comp_comp_inr {W X Y Z : prod_coprod C} (f : norm_hom X Z) :\n  rel (f.snd_comp.comp_inr : norm_hom (prod W X) (coprod Y Z)) f.comp_inr.snd_comp\n\ndef to_inj : {X Y Z : prod_coprod C} → (f : norm_hom X (coprod Y Z)) →\n  Option ((norm_hom X Y) ⊕ (norm_hom X Z))\n| _, _, _, comp_inl f => some (Sum.inl f)\n| _, _, _, comp_inr f => some (Sum.inr f)\n| _, _, _, fst_comp f =>\n  match to_inj f with\n  | none => none\n  | some (Sum.inl f) => some (Sum.inl (fst_comp f))\n  | some (Sum.inr f) => some (Sum.inr (fst_comp f))\n| _, _, _, snd_comp f =>\n  match to_inj f with\n  | none => none\n  | some (Sum.inl f) => some (Sum.inl (snd_comp f))\n  | some (Sum.inr f) => some (Sum.inr (snd_comp f))\n| _, _, _, coprod_mk f g =>\n  match to_inj f, to_inj g with\n  | some (Sum.inl f), some (Sum.inl g) => some (Sum.inl (coprod_mk f g))\n  | some (Sum.inr f), some (Sum.inr g) => some (Sum.inr (coprod_mk f g))\n  | _, _ => none\n| _, _, _, @from_init _ _ (coprod _ _) => some (Sum.inl (coprod_mk f g))\n\ntheorem to_inj_eq_inl : {X Y Z : prod_coprod C} → {f : norm_hom X (coprod Y Z)} →\n  {g : norm_hom X Y} → to_inj f = some (Sum.inl g) → rel f g.comp_inl\n| _, _, _, comp_inl f, g, h => by\n  simp [to_inj] at h\n  simp [h]\n  exact rel.refl _\n  | _, _, _, comp_inr f, g, h => by\n  simp [to_inj] at h\n| _, _, _, snd_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inl i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inl i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.snd_comp_congr (to_inj_eq_inl hi))\n    (rel.snd_comp_comp_inl i).symm\n| _, _, _, fst_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inl i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inl i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.fst_comp_congr (to_inj_eq_inl hi))\n    (rel.fst_comp_comp_inl i).symm\n| _, _, _, coprod_mk f g, i, h =>\n  have hi : ∃ f' g', to_inj f = some (Sum.inl f') ∧ to_inj g = some (Sum.inl g') := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f, to_inj g with\n    | some (Sum.inl f'), some (Sum.inl g') => intro h; exact ⟨f', g', rfl, rfl⟩\n    | some (Sum.inr _), some (Sum.inr _) => simp\n    | none, _ => simp\n    | _, none => simp\n    | some (Sum.inl _), some (Sum.inr _) => simp\n    | some (Sum.inr _), some (Sum.inl _) => simp }\n  match hi with\n  | ⟨f', g', hf, hg⟩ => by\n  simp [hf, hg, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.coprod_mk_congr (to_inj_eq_inl hf) (to_inj_eq_inl hg))\n    (rel.comp_inl_coprod_mk _ _).symm\n\ntheorem to_inj_eq_inr : {X Y Z : prod_coprod C} → {f : norm_hom X (coprod Y Z)} →\n  {g : norm_hom X Z} → to_inj f = some (Sum.inr g) → rel f g.comp_inr\n| _, _, _, comp_inr f, g, h => by\n  simp [to_inj] at h\n  simp [h]\n  exact rel.refl _\n  | _, _, _, comp_inl f, g, h => by\n  simp [to_inj] at h\n| _, _, _, snd_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inr i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inr i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.snd_comp_congr (to_inj_eq_inr hi))\n    (rel.snd_comp_comp_inr i).symm\n| _, _, _, fst_comp f, g, h =>\n  have hi : ∃ i, to_inj f = some (Sum.inr i) := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f with\n    | some (Sum.inr i) => intro h; exact ⟨i, rfl⟩\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | ⟨i, hi⟩ => by\n  simp [hi, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.fst_comp_congr (to_inj_eq_inr hi))\n    (rel.fst_comp_comp_inr i).symm\n| _, _, _, coprod_mk f g, i, h =>\n  have hi : ∃ f' g', to_inj f = some (Sum.inr f') ∧ to_inj g = some (Sum.inr g') := by\n  { simp [to_inj] at h\n    revert h\n    match to_inj f, to_inj g with\n    | some (Sum.inr f'), some (Sum.inr g') => intro _; exact ⟨f', g', rfl, rfl⟩\n    | some (Sum.inl _), some (Sum.inl _) => simp\n    | none, _ => simp\n    | _, none => simp\n    | some (Sum.inr _), some (Sum.inl _) => simp\n    | some (Sum.inl _), some (Sum.inr _) => simp }\n  match hi with\n  | ⟨f', g', hf, hg⟩ => by\n  simp [hf, hg, to_inj] at h\n  rw [← h]\n  exact rel.trans (rel.coprod_mk_congr (to_inj_eq_inr hf) (to_inj_eq_inr hg))\n    (rel.comp_inr_coprod_mk _ _).symm\n\ntheorem to_inj_eq_none {X Y Z : prod_coprod C} {f : norm_hom X (coprod Y Z)}\n  (hf : to_inj f = none) {g : norm_hom X Z} : ¬rel f g.comp_inr := by\nintro h\ncases h\nsimp at hf\n\n\nend norm_hom", "meta": {"author": "ChrisHughes24", "repo": "lean4stuff", "sha": "2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346", "save_path": "github-repos/lean/ChrisHughes24-lean4stuff", "path": "github-repos/lean/ChrisHughes24-lean4stuff/lean4stuff-2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346/Stuff/prod_coprod5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45985782271378445}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n\n! This file was ported from Lean 3 source module order.hom.set\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Hom.Basic\nimport Mathbin.Logic.Equiv.Set\nimport Mathbin.Data.Set.Image\n\n/-!\n# Order homomorphisms and sets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nopen OrderDual\n\nvariable {F α β γ δ : Type _}\n\nnamespace OrderIso\n\nsection LE\n\nvariable [LE α] [LE β] [LE γ]\n\n/- warning: order_iso.range_eq -> OrderIso.range_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2), Eq.{succ u2} (Set.{u2} β) (Set.range.{u2, succ u1} β α (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e)) (Set.univ.{u2} β)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2), Eq.{succ u1} (Set.{u1} β) (Set.range.{u1, succ u2} β α (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e)))) (Set.univ.{u1} β)\nCase conversion may be inaccurate. Consider using '#align order_iso.range_eq OrderIso.range_eqₓ'. -/\ntheorem range_eq (e : α ≃o β) : Set.range e = Set.univ :=\n  e.Surjective.range_eq\n#align order_iso.range_eq OrderIso.range_eq\n\n/- warning: order_iso.symm_image_image -> OrderIso.symm_image_image is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2) (s : Set.{u1} α), Eq.{succ u1} (Set.{u1} α) (Set.image.{u2, u1} β α (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} β α _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) => β -> α) (RelIso.hasCoeToFun.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) (OrderIso.symm.{u1, u2} α β _inst_1 _inst_2 e)) (Set.image.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) s)) s\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2) (s : Set.{u2} α), Eq.{succ u2} (Set.{u2} α) (Set.image.{u1, u2} β α (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β α (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} β α)) (RelEmbedding.toEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} α β _inst_1 _inst_2 e)))) (Set.image.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.symm_image_image OrderIso.symm_image_imageₓ'. -/\n@[simp]\ntheorem symm_image_image (e : α ≃o β) (s : Set α) : e.symm '' (e '' s) = s :=\n  e.toEquiv.symm_image_image s\n#align order_iso.symm_image_image OrderIso.symm_image_image\n\n/- warning: order_iso.image_symm_image -> OrderIso.image_symm_image is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2) (s : Set.{u2} β), Eq.{succ u2} (Set.{u2} β) (Set.image.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) (Set.image.{u2, u1} β α (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} β α _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) => β -> α) (RelIso.hasCoeToFun.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) (OrderIso.symm.{u1, u2} α β _inst_1 _inst_2 e)) s)) s\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2) (s : Set.{u1} β), Eq.{succ u1} (Set.{u1} β) (Set.image.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.image.{u1, u2} β α (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β α (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} β α)) (RelEmbedding.toEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} α β _inst_1 _inst_2 e)))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.image_symm_image OrderIso.image_symm_imageₓ'. -/\n@[simp]\ntheorem image_symm_image (e : α ≃o β) (s : Set β) : e '' (e.symm '' s) = s :=\n  e.toEquiv.image_symm_image s\n#align order_iso.image_symm_image OrderIso.image_symm_image\n\n/- warning: order_iso.image_eq_preimage -> OrderIso.image_eq_preimage is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2) (s : Set.{u1} α), Eq.{succ u2} (Set.{u2} β) (Set.image.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) s) (Set.preimage.{u2, u1} β α (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} β α _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) => β -> α) (RelIso.hasCoeToFun.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) (OrderIso.symm.{u1, u2} α β _inst_1 _inst_2 e)) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2) (s : Set.{u2} α), Eq.{succ u1} (Set.{u1} β) (Set.image.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) s) (Set.preimage.{u1, u2} β α (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β α (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} β α)) (RelEmbedding.toEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} α β _inst_1 _inst_2 e)))) s)\nCase conversion may be inaccurate. Consider using '#align order_iso.image_eq_preimage OrderIso.image_eq_preimageₓ'. -/\ntheorem image_eq_preimage (e : α ≃o β) (s : Set α) : e '' s = e.symm ⁻¹' s :=\n  e.toEquiv.image_eq_preimage s\n#align order_iso.image_eq_preimage OrderIso.image_eq_preimage\n\n/- warning: order_iso.preimage_symm_preimage -> OrderIso.preimage_symm_preimage is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2) (s : Set.{u1} α), Eq.{succ u1} (Set.{u1} α) (Set.preimage.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) (Set.preimage.{u2, u1} β α (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} β α _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) => β -> α) (RelIso.hasCoeToFun.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) (OrderIso.symm.{u1, u2} α β _inst_1 _inst_2 e)) s)) s\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2) (s : Set.{u2} α), Eq.{succ u2} (Set.{u2} α) (Set.preimage.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.preimage.{u1, u2} β α (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β α (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} β α)) (RelEmbedding.toEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} α β _inst_1 _inst_2 e)))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.preimage_symm_preimage OrderIso.preimage_symm_preimageₓ'. -/\n@[simp]\ntheorem preimage_symm_preimage (e : α ≃o β) (s : Set α) : e ⁻¹' (e.symm ⁻¹' s) = s :=\n  e.toEquiv.preimage_symm_preimage s\n#align order_iso.preimage_symm_preimage OrderIso.preimage_symm_preimage\n\n/- warning: order_iso.symm_preimage_preimage -> OrderIso.symm_preimage_preimage is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2) (s : Set.{u2} β), Eq.{succ u2} (Set.{u2} β) (Set.preimage.{u2, u1} β α (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} β α _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) => β -> α) (RelIso.hasCoeToFun.{u2, u1} β α (LE.le.{u2} β _inst_2) (LE.le.{u1} α _inst_1)) (OrderIso.symm.{u1, u2} α β _inst_1 _inst_2 e)) (Set.preimage.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) s)) s\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2) (s : Set.{u1} β), Eq.{succ u1} (Set.{u1} β) (Set.preimage.{u1, u2} β α (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β α (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} β α)) (RelEmbedding.toEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} α β _inst_1 _inst_2 e)))) (Set.preimage.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.symm_preimage_preimage OrderIso.symm_preimage_preimageₓ'. -/\n@[simp]\ntheorem symm_preimage_preimage (e : α ≃o β) (s : Set β) : e.symm ⁻¹' (e ⁻¹' s) = s :=\n  e.toEquiv.symm_preimage_preimage s\n#align order_iso.symm_preimage_preimage OrderIso.symm_preimage_preimage\n\n/- warning: order_iso.image_preimage -> OrderIso.image_preimage is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2) (s : Set.{u2} β), Eq.{succ u2} (Set.{u2} β) (Set.image.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) (Set.preimage.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) s)) s\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2) (s : Set.{u1} β), Eq.{succ u1} (Set.{u1} β) (Set.image.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.preimage.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.image_preimage OrderIso.image_preimageₓ'. -/\n@[simp]\ntheorem image_preimage (e : α ≃o β) (s : Set β) : e '' (e ⁻¹' s) = s :=\n  e.toEquiv.image_preimage s\n#align order_iso.image_preimage OrderIso.image_preimage\n\n/- warning: order_iso.preimage_image -> OrderIso.preimage_image is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LE.{u1} α] [_inst_2 : LE.{u2} β] (e : OrderIso.{u1, u2} α β _inst_1 _inst_2) (s : Set.{u1} α), Eq.{succ u1} (Set.{u1} α) (Set.preimage.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) (Set.image.{u1, u2} α β (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α _inst_1) (LE.le.{u2} β _inst_2)) e) s)) s\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LE.{u2} α] [_inst_2 : LE.{u1} β] (e : OrderIso.{u2, u1} α β _inst_1 _inst_2) (s : Set.{u2} α), Eq.{succ u2} (Set.{u2} α) (Set.preimage.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.image.{u2, u1} α β (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.preimage_image OrderIso.preimage_imageₓ'. -/\n@[simp]\ntheorem preimage_image (e : α ≃o β) (s : Set α) : e ⁻¹' (e '' s) = s :=\n  e.toEquiv.preimage_image s\n#align order_iso.preimage_image OrderIso.preimage_image\n\nend LE\n\nopen Set\n\nvariable [Preorder α] [Preorder β] [Preorder γ]\n\n#print OrderIso.setCongr /-\n/-- Order isomorphism between two equal sets. -/\ndef setCongr (s t : Set α) (h : s = t) : s ≃o t\n    where\n  toEquiv := Equiv.setCongr h\n  map_rel_iff' x y := Iff.rfl\n#align order_iso.set_congr OrderIso.setCongr\n-/\n\n#print OrderIso.Set.univ /-\n/-- Order isomorphism between `univ : set α` and `α`. -/\ndef Set.univ : (Set.univ : Set α) ≃o α\n    where\n  toEquiv := Equiv.Set.univ α\n  map_rel_iff' x y := Iff.rfl\n#align order_iso.set.univ OrderIso.Set.univ\n-/\n\nend OrderIso\n\n#print StrictMonoOn.orderIso /-\n/-- If a function `f` is strictly monotone on a set `s`, then it defines an order isomorphism\nbetween `s` and its image. -/\nprotected noncomputable def StrictMonoOn.orderIso {α β} [LinearOrder α] [Preorder β] (f : α → β)\n    (s : Set α) (hf : StrictMonoOn f s) : s ≃o f '' s\n    where\n  toEquiv := hf.InjOn.bijOn_image.Equiv _\n  map_rel_iff' x y := hf.le_iff_le x.2 y.2\n#align strict_mono_on.order_iso StrictMonoOn.orderIso\n-/\n\nnamespace StrictMono\n\nvariable {α β} [LinearOrder α] [Preorder β]\n\nvariable (f : α → β) (h_mono : StrictMono f) (h_surj : Function.Surjective f)\n\n#print StrictMono.orderIso /-\n/-- A strictly monotone function from a linear order is an order isomorphism between its domain and\nits range. -/\n@[simps apply]\nprotected noncomputable def orderIso : α ≃o Set.range f\n    where\n  toEquiv := Equiv.ofInjective f h_mono.Injective\n  map_rel_iff' a b := h_mono.le_iff_le\n#align strict_mono.order_iso StrictMono.orderIso\n-/\n\n#print StrictMono.orderIsoOfSurjective /-\n/-- A strictly monotone surjective function from a linear order is an order isomorphism. -/\nnoncomputable def orderIsoOfSurjective : α ≃o β :=\n  (h_mono.OrderIso f).trans <| (OrderIso.setCongr _ _ h_surj.range_eq).trans OrderIso.Set.univ\n#align strict_mono.order_iso_of_surjective StrictMono.orderIsoOfSurjective\n-/\n\n/- warning: strict_mono.coe_order_iso_of_surjective -> StrictMono.coe_orderIsoOfSurjective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : Preorder.{u2} β] (f : α -> β) (h_mono : StrictMono.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} α β f), Eq.{max (succ u1) (succ u2)} ((fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))))) (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2))) => α -> β) (StrictMono.orderIsoOfSurjective.{u1, u2} α β _inst_1 _inst_2 f h_mono h_surj)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} α β (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) (Preorder.toLE.{u2} β _inst_2)) (fun (_x : RelIso.{u1, u2} α β (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))))) (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2))) => α -> β) (RelIso.hasCoeToFun.{u1, u2} α β (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))))) (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2))) (StrictMono.orderIsoOfSurjective.{u1, u2} α β _inst_1 _inst_2 f h_mono h_surj)) f\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : Preorder.{u1} β] (f : α -> β) (h_mono : StrictMono.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 f) (h_surj : Function.Surjective.{succ u2, succ u1} α β f), Eq.{max (succ u2) (succ u1)} (forall (a : α), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) (RelEmbedding.toEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} α β (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (StrictMono.orderIsoOfSurjective.{u2, u1} α β _inst_1 _inst_2 f h_mono h_surj)))) f\nCase conversion may be inaccurate. Consider using '#align strict_mono.coe_order_iso_of_surjective StrictMono.coe_orderIsoOfSurjectiveₓ'. -/\n@[simp]\ntheorem coe_orderIsoOfSurjective : (orderIsoOfSurjective f h_mono h_surj : α → β) = f :=\n  rfl\n#align strict_mono.coe_order_iso_of_surjective StrictMono.coe_orderIsoOfSurjective\n\n/- warning: strict_mono.order_iso_of_surjective_symm_apply_self -> StrictMono.orderIsoOfSurjective_symm_apply_self is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : Preorder.{u2} β] (f : α -> β) (h_mono : StrictMono.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} α β f) (a : α), Eq.{succ u1} α (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} β α (Preorder.toLE.{u2} β _inst_2) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))))) (fun (_x : RelIso.{u2, u1} β α (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))))) => β -> α) (RelIso.hasCoeToFun.{u2, u1} β α (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))))) (OrderIso.symm.{u1, u2} α β (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) (Preorder.toLE.{u2} β _inst_2) (StrictMono.orderIsoOfSurjective.{u1, u2} α β _inst_1 _inst_2 f h_mono h_surj)) (f a)) a\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] [_inst_2 : Preorder.{u1} β] (f : α -> β) (h_mono : StrictMono.{u2, u1} α β (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) _inst_2 f) (h_surj : Function.Surjective.{succ u2, succ u1} α β f) (a : α), Eq.{succ u2} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) (f a)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} β α) β α (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} β α)) (RelEmbedding.toEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u1} β (Preorder.toLE.{u1} β _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} α β (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) (Preorder.toLE.{u1} β _inst_2) (StrictMono.orderIsoOfSurjective.{u2, u1} α β _inst_1 _inst_2 f h_mono h_surj)))) (f a)) a\nCase conversion may be inaccurate. Consider using '#align strict_mono.order_iso_of_surjective_symm_apply_self StrictMono.orderIsoOfSurjective_symm_apply_selfₓ'. -/\n@[simp]\ntheorem orderIsoOfSurjective_symm_apply_self (a : α) :\n    (orderIsoOfSurjective f h_mono h_surj).symm (f a) = a :=\n  (orderIsoOfSurjective f h_mono h_surj).symm_apply_apply _\n#align strict_mono.order_iso_of_surjective_symm_apply_self StrictMono.orderIsoOfSurjective_symm_apply_self\n\n/- warning: strict_mono.order_iso_of_surjective_self_symm_apply -> StrictMono.orderIsoOfSurjective_self_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : Preorder.{u2} β] (f : α -> β) (h_mono : StrictMono.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} α β f) (b : β), Eq.{succ u2} β (f (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} β α (Preorder.toLE.{u2} β _inst_2) (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))))) (fun (_x : RelIso.{u2, u1} β α (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))))) => β -> α) (RelIso.hasCoeToFun.{u2, u1} β α (LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2)) (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))))) (OrderIso.symm.{u1, u2} α β (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) (Preorder.toLE.{u2} β _inst_2) (StrictMono.orderIsoOfSurjective.{u1, u2} α β _inst_1 _inst_2 f h_mono h_surj)) b)) b\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : Preorder.{u2} β] (f : α -> β) (h_mono : StrictMono.{u1, u2} α β (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1))))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} α β f) (b : β), Eq.{succ u2} β (f (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} β α) β (fun (_x : β) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : β) => α) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} β α) β α (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} β α)) (RelEmbedding.toEmbedding.{u2, u1} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} β α (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : β) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : β) => LE.le.{u2} β (Preorder.toLE.{u2} β _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : α) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : α) => LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u1, u2} α β (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_1)))))) (Preorder.toLE.{u2} β _inst_2) (StrictMono.orderIsoOfSurjective.{u1, u2} α β _inst_1 _inst_2 f h_mono h_surj)))) b)) b\nCase conversion may be inaccurate. Consider using '#align strict_mono.order_iso_of_surjective_self_symm_apply StrictMono.orderIsoOfSurjective_self_symm_applyₓ'. -/\ntheorem orderIsoOfSurjective_self_symm_apply (b : β) :\n    f ((orderIsoOfSurjective f h_mono h_surj).symm b) = b :=\n  (orderIsoOfSurjective f h_mono h_surj).apply_symm_apply _\n#align strict_mono.order_iso_of_surjective_self_symm_apply StrictMono.orderIsoOfSurjective_self_symm_apply\n\nend StrictMono\n\nsection BooleanAlgebra\n\nvariable (α) [BooleanAlgebra α]\n\n#print OrderIso.compl /-\n/-- Taking complements as an order isomorphism to the order dual. -/\n@[simps]\ndef OrderIso.compl : α ≃o αᵒᵈ where\n  toFun := OrderDual.toDual ∘ compl\n  invFun := compl ∘ OrderDual.ofDual\n  left_inv := compl_compl\n  right_inv := compl_compl\n  map_rel_iff' x y := compl_le_compl_iff_le\n#align order_iso.compl OrderIso.compl\n-/\n\n#print compl_strictAnti /-\ntheorem compl_strictAnti : StrictAnti (compl : α → α) :=\n  (OrderIso.compl α).StrictMono\n#align compl_strict_anti compl_strictAnti\n-/\n\n#print compl_antitone /-\ntheorem compl_antitone : Antitone (compl : α → α) :=\n  (OrderIso.compl α).Monotone\n#align compl_antitone compl_antitone\n-/\n\nend BooleanAlgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Order/Hom/Set.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45985782271378434}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang, Scott Morrison\n-/\nimport category_theory.preadditive.injective_resolution\nimport category_theory.abelian.exact\nimport algebra.homology.homotopy_category\n\n/-!\n# Main result\n\nWhen the underlying category is abelian:\n* `category_theory.InjectiveResolution.desc`: Given `I : InjectiveResolution X` and\n  `J : InjectiveResolution Y`, any morphism `X ⟶ Y` admits a descent to a chain map\n  `J.cocomplex ⟶ I.cocomplex`. It is a descent in the sense that `I.ι` intertwines the descent and\n  the original morphism, see `category_theory.InjectiveResolution.desc_commutes`.\n* `category_theory.InjectiveResolution.desc_homotopy`: Any two such descents are homotopic.\n* `category_theory.InjectiveResolution.homotopy_equiv`: Any two injective resolutions of the same\n  object are homotopy equivalent.\n* `category_theory.injective_resolutions`: If every object admits an injective resolution, we can\n  construct a functor `injective_resolutions C : C ⥤ homotopy_category C`.\n\n* `category_theory.exact_f_d`: `f` and `injective.d f` are exact.\n* `category_theory.InjectiveResolution.of`: Hence, starting from a monomorphism `X ⟶ J`, where `J`\n  is injective, we can apply `injective.d` repeatedly to obtain an injective resolution of `X`.\n-/\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nuniverses v u\n\nnamespace category_theory\nvariables {C : Type u} [category.{v} C]\n\nopen injective\n\nnamespace InjectiveResolution\nsection\nvariables [has_zero_morphisms C] [has_zero_object C] [has_equalizers C] [has_images C]\n/-- Auxiliary construction for `desc`. -/\ndef desc_f_zero {Y Z : C} (f : Z ⟶ Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex.X 0 ⟶ I.cocomplex.X 0 :=\nfactor_thru (f ≫ I.ι.f 0) (J.ι.f 0)\n\nend\n\nsection abelian\nvariables [abelian C]\n/-- Auxiliary construction for `desc`. -/\ndef desc_f_one {Y Z : C}\n  (f : Z ⟶ Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex.X 1 ⟶ I.cocomplex.X 1 :=\nexact.desc (desc_f_zero f I J ≫ I.cocomplex.d 0 1) (J.ι.f 0) (J.cocomplex.d 0 1)\n  (abelian.exact.op _ _ J.exact₀) (by simp [←category.assoc, desc_f_zero])\n\n@[simp] lemma desc_f_one_zero_comm {Y Z : C}\n  (f : Z ⟶ Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex.d 0 1 ≫ desc_f_one f I J = desc_f_zero f I J ≫ I.cocomplex.d 0 1 :=\nby simp [desc_f_zero, desc_f_one]\n\n/-- Auxiliary construction for `desc`. -/\ndef desc_f_succ {Y Z : C}\n  (I : InjectiveResolution Y) (J : InjectiveResolution Z)\n  (n : ℕ) (g : J.cocomplex.X n ⟶ I.cocomplex.X n) (g' : J.cocomplex.X (n+1) ⟶ I.cocomplex.X (n+1))\n  (w : J.cocomplex.d n (n+1) ≫ g' = g ≫ I.cocomplex.d n (n+1)) :\n  Σ' g'' : J.cocomplex.X (n+2) ⟶ I.cocomplex.X (n+2),\n    J.cocomplex.d (n+1) (n+2) ≫ g'' = g' ≫ I.cocomplex.d (n+1) (n+2) :=\n⟨@exact.desc C _ _ _ _ _ _ _ _ _\n  (g' ≫ I.cocomplex.d (n+1) (n+2))\n  (J.cocomplex.d n (n+1))\n  (J.cocomplex.d (n+1) (n+2)) (abelian.exact.op _ _ (J.exact _))\n  (by simp [←category.assoc, w]), (by simp)⟩\n\n/-- A morphism in `C` descends to a chain map between injective resolutions. -/\ndef desc {Y Z : C}\n  (f : Z ⟶ Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex ⟶ I.cocomplex :=\ncochain_complex.mk_hom _ _ (desc_f_zero f _ _) (desc_f_one f _ _)\n  (desc_f_one_zero_comm f I J).symm\n  (λ n ⟨g, g', w⟩, ⟨(desc_f_succ I J n g g' w.symm).1, (desc_f_succ I J n g g' w.symm).2.symm⟩)\n\n/-- The resolution maps intertwine the descent of a morphism and that morphism. -/\n@[simp, reassoc]\nlemma desc_commutes {Y Z : C}\n  (f : Z ⟶ Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.ι ≫ desc f I J = (cochain_complex.single₀ C).map f ≫ I.ι :=\nbegin\n  ext n,\n  rcases n with (_|_|n);\n  { dsimp [desc, desc_f_one, desc_f_zero], simp, },\nend\n\n-- Now that we've checked this property of the descent,\n-- we can seal away the actual definition.\nattribute [irreducible] desc\n\n/-- An auxiliary definition for `desc_homotopy_zero`. -/\ndef desc_homotopy_zero_zero {Y Z : C} {I : InjectiveResolution Y} {J : InjectiveResolution Z}\n  (f : I.cocomplex ⟶ J.cocomplex)\n  (comm : I.ι ≫ f = 0) : I.cocomplex.X 1 ⟶ J.cocomplex.X 0 :=\nexact.desc (f.f 0) (I.ι.f 0) (I.cocomplex.d 0 1) (abelian.exact.op _ _ I.exact₀)\n  (congr_fun (congr_arg homological_complex.hom.f comm) 0)\n\n/-- An auxiliary definition for `desc_homotopy_zero`. -/\ndef desc_homotopy_zero_one {Y Z : C} {I : InjectiveResolution Y} {J : InjectiveResolution Z}\n  (f : I.cocomplex ⟶ J.cocomplex)\n  (comm : I.ι ≫ f = (0 : _ ⟶ J.cocomplex)) : I.cocomplex.X 2 ⟶ J.cocomplex.X 1 :=\nexact.desc (f.f 1 - desc_homotopy_zero_zero f comm ≫ J.cocomplex.d 0 1)\n  (I.cocomplex.d 0 1) (I.cocomplex.d 1 2) (abelian.exact.op _ _ (I.exact _))\n  (by simp [desc_homotopy_zero_zero, ←category.assoc])\n\n/-- An auxiliary definition for `desc_homotopy_zero`. -/\ndef desc_homotopy_zero_succ {Y Z : C} {I : InjectiveResolution Y} {J : InjectiveResolution Z}\n  (f : I.cocomplex ⟶ J.cocomplex) (n : ℕ)\n  (g : I.cocomplex.X (n + 1) ⟶ J.cocomplex.X n)\n  (g' : I.cocomplex.X (n + 2) ⟶ J.cocomplex.X (n + 1))\n  (w : f.f (n + 1) = I.cocomplex.d (n+1) (n+2) ≫ g' + g ≫ J.cocomplex.d n (n+1)) :\n  I.cocomplex.X (n + 3) ⟶ J.cocomplex.X (n + 2) :=\nexact.desc (f.f (n+2) - g' ≫ J.cocomplex.d _ _) (I.cocomplex.d (n+1) (n+2))\n  (I.cocomplex.d (n+2) (n+3)) (abelian.exact.op _ _ (I.exact _))\n  (by simp [preadditive.comp_sub, ←category.assoc, preadditive.sub_comp,\n        show I.cocomplex.d (n+1) (n+2) ≫ g' = f.f (n + 1) - g ≫ J.cocomplex.d n (n+1),\n        by {rw w, simp only [add_sub_cancel] } ])\n\n/-- Any descent of the zero morphism is homotopic to zero. -/\ndef desc_homotopy_zero {Y Z : C} {I : InjectiveResolution Y} {J : InjectiveResolution Z}\n  (f : I.cocomplex ⟶ J.cocomplex)\n  (comm : I.ι ≫ f = 0) :\n  homotopy f 0 :=\nhomotopy.mk_coinductive _ (desc_homotopy_zero_zero f comm) (by simp [desc_homotopy_zero_zero])\n  (desc_homotopy_zero_one f comm) (by simp [desc_homotopy_zero_one])\n  (λ n ⟨g, g', w⟩, ⟨desc_homotopy_zero_succ f n g g' (by simp only [w, add_comm]),\n    by simp [desc_homotopy_zero_succ, w]⟩)\n\n/-- Two descents of the same morphism are homotopic. -/\ndef desc_homotopy {Y Z : C} (f : Y ⟶ Z) {I : InjectiveResolution Y} {J : InjectiveResolution Z}\n  (g h : I.cocomplex ⟶ J.cocomplex)\n  (g_comm : I.ι ≫ g = (cochain_complex.single₀ C).map f ≫ J.ι)\n  (h_comm : I.ι ≫ h = (cochain_complex.single₀ C).map f ≫ J.ι) :\n  homotopy g h :=\nhomotopy.equiv_sub_zero.inv_fun (desc_homotopy_zero _ (by simp [g_comm, h_comm]))\n\n/-- The descent of the identity morphism is homotopic to the identity cochain map. -/\ndef desc_id_homotopy (X : C) (I : InjectiveResolution X) :\n  homotopy (desc (𝟙 X) I I) (𝟙 I.cocomplex) :=\nby apply desc_homotopy (𝟙 X); simp\n\n/-- The descent of a composition is homotopic to the composition of the descents. -/\ndef desc_comp_homotopy {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  (I : InjectiveResolution X) (J : InjectiveResolution Y) (K : InjectiveResolution Z) :\n  homotopy (desc (f ≫ g) K I) (desc f J I ≫ desc g K J)  :=\nby apply desc_homotopy (f ≫ g); simp\n\n-- We don't care about the actual definitions of these homotopies.\nattribute [irreducible] desc_homotopy_zero desc_homotopy desc_id_homotopy desc_comp_homotopy\n\n/-- Any two injective resolutions are homotopy equivalent. -/\ndef homotopy_equiv {X : C} (I J : InjectiveResolution X) :\n  homotopy_equiv I.cocomplex J.cocomplex :=\n{ hom := desc (𝟙 X) J I,\n  inv := desc (𝟙 X) I J,\n  homotopy_hom_inv_id := (desc_comp_homotopy (𝟙 X) (𝟙 X) I J I).symm.trans $\n    by simpa [category.id_comp] using desc_id_homotopy _ _,\n  homotopy_inv_hom_id := (desc_comp_homotopy (𝟙 X) (𝟙 X) J I J).symm.trans $\n    by simpa [category.id_comp] using desc_id_homotopy _ _ }\n\n@[simp, reassoc] lemma homotopy_equiv_hom_ι {X : C} (I J : InjectiveResolution X) :\n  I.ι ≫ (homotopy_equiv I J).hom = J.ι :=\nby simp [homotopy_equiv]\n\n@[simp, reassoc] lemma homotopy_equiv_inv_ι {X : C} (I J : InjectiveResolution X) :\n  J.ι ≫ (homotopy_equiv I J).inv = I.ι :=\nby simp [homotopy_equiv]\n\nend abelian\n\nend InjectiveResolution\n\nsection\nvariables [abelian C]\n\n/-- An arbitrarily chosen injective resolution of an object. -/\nabbreviation injective_resolution (Z : C) [has_injective_resolution Z] : cochain_complex C ℕ :=\n(has_injective_resolution.out Z).some.cocomplex\n\n/-- The cochain map from cochain complex consisting of `Z` supported in degree `0`\nback to the arbitrarily chosen injective resolution `injective_resolution Z`. -/\nabbreviation injective_resolution.ι (Z : C) [has_injective_resolution Z] :\n  (cochain_complex.single₀ C).obj Z ⟶ injective_resolution Z :=\n(has_injective_resolution.out Z).some.ι\n\n/-- The descent of a morphism to a cochain map between the arbitrarily chosen injective resolutions.\n-/\nabbreviation injective_resolution.desc {X Y : C} (f : X ⟶ Y)\n  [has_injective_resolution X] [has_injective_resolution Y] :\n  injective_resolution X ⟶ injective_resolution Y :=\nInjectiveResolution.desc f _ _\n\nvariables (C) [has_injective_resolutions C]\n\n/--\nTaking injective resolutions is functorial,\nif considered with target the homotopy category\n(`ℕ`-indexed cochain complexes and chain maps up to homotopy).\n-/\ndef injective_resolutions : C ⥤ homotopy_category C (complex_shape.up ℕ) :=\n{ obj := λ X, (homotopy_category.quotient _ _).obj (injective_resolution X),\n  map := λ X Y f, (homotopy_category.quotient _ _).map (injective_resolution.desc f),\n  map_id' := λ X, begin\n    rw ←(homotopy_category.quotient _ _).map_id,\n    apply homotopy_category.eq_of_homotopy,\n    apply InjectiveResolution.desc_id_homotopy,\n  end,\n  map_comp' := λ X Y Z f g, begin\n    rw ←(homotopy_category.quotient _ _).map_comp,\n    apply homotopy_category.eq_of_homotopy,\n    apply InjectiveResolution.desc_comp_homotopy,\n  end, }\n\nend\n\nsection\n\nvariables [abelian C] [enough_injectives C]\n\nlemma exact_f_d {X Y : C} (f : X ⟶ Y) : exact f (d f) :=\n(abelian.exact_iff _ _).2 $\n  ⟨by simp, zero_of_comp_mono (ι _) $ by rw [category.assoc, kernel.condition]⟩\n\nend\n\nnamespace InjectiveResolution\n/-!\nOur goal is to define `InjectiveResolution.of Z : InjectiveResolution Z`.\nThe `0`-th object in this resolution will just be `injective.under Z`,\ni.e. an arbitrarily chosen injective object with a map from `Z`.\nAfter that, we build the `n+1`-st object as `injective.syzygies`\napplied to the previously constructed morphism,\nand the map from the `n`-th object as `injective.d`.\n-/\n\nvariables [abelian C] [enough_injectives C]\n\n/-- Auxiliary definition for `InjectiveResolution.of`. -/\n@[simps]\ndef of_cocomplex (Z : C) : cochain_complex C ℕ :=\ncochain_complex.mk'\n  (injective.under Z) (injective.syzygies (injective.ι Z)) (injective.d (injective.ι Z))\n  (λ ⟨X, Y, f⟩, ⟨injective.syzygies f, injective.d f, (exact_f_d f).w⟩)\n\n/--\nIn any abelian category with enough injectives,\n`InjectiveResolution.of Z` constructs an injective resolution of the object `Z`.\n-/\n@[irreducible] def of (Z : C) : InjectiveResolution Z :=\n{ cocomplex := of_cocomplex Z,\n  ι := cochain_complex.mk_hom _ _ (injective.ι Z) 0\n    (by { simp only [of_cocomplex_d, eq_self_iff_true, eq_to_hom_refl, category.comp_id,\n      dite_eq_ite, if_true, comp_zero],\n      exact (exact_f_d (injective.ι Z)).w, } ) (λ n _, ⟨0, by ext⟩),\n  injective := by { rintros (_|_|_|n); { apply injective.injective_under, } },\n  exact₀ := by simpa using exact_f_d (injective.ι Z),\n  exact := by { rintros (_|n); { simp, apply exact_f_d } },\n  mono := injective.ι_mono Z }\n\n@[priority 100]\ninstance (Z : C) : has_injective_resolution Z :=\n{ out := ⟨of Z⟩ }\n\n@[priority 100]\ninstance : has_injective_resolutions C :=\n{ out := λ _, infer_instance }\n\nend InjectiveResolution\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/abelian/injective_resolution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.721743206297598, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.45977264811857804}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.concrete_category.bundled_hom\nimport algebra.punit_instances\nimport category_theory.functor.reflects_isomorphisms\n\n/-!\n# Category instances for monoid, add_monoid, comm_monoid, and add_comm_monoid.\n\nWe introduce the bundled categories:\n* `Mon`\n* `AddMon`\n* `CommMon`\n* `AddCommMon`\nalong with the relevant forgetful functors between them.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of monoids and monoid morphisms. -/\n@[to_additive AddMon]\ndef Mon : Type (u+1) := bundled monoid\n\n/-- The category of additive monoids and monoid morphisms. -/\nadd_decl_doc AddMon\n\nnamespace Mon\n\n/-- `monoid_hom` doesn't actually assume associativity. This alias is needed to make the category\ntheory machinery work. -/\n@[to_additive \"`add_monoid_hom` doesn't actually assume associativity. This alias is needed to make\nthe category theory machinery work.\"]\nabbreviation assoc_monoid_hom (M N : Type*) [monoid M] [monoid N] := monoid_hom M N\n\n@[to_additive]\ninstance bundled_hom : bundled_hom assoc_monoid_hom :=\n⟨λ M N [monoid M] [monoid N], by exactI @monoid_hom.to_fun M N _ _,\n λ M [monoid M], by exactI @monoid_hom.id M _,\n λ M N P [monoid M] [monoid N] [monoid P], by exactI @monoid_hom.comp M N P _ _ _,\n λ M N [monoid M] [monoid N], by exactI @monoid_hom.coe_inj M N _ _⟩\n\nattribute [derive [large_category, concrete_category]] Mon\nattribute [to_additive] Mon.large_category Mon.concrete_category\n\n@[to_additive] instance : has_coe_to_sort Mon Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `Mon` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [monoid M] : Mon := bundled.of M\n\n/-- Construct a bundled `Mon` from the underlying type and typeclass. -/\nadd_decl_doc AddMon.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `Mon`. -/\n@[to_additive] def of_hom {X Y : Type u} [monoid X] [monoid Y] (f : X →* Y) :\n  of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddMon`. -/\nadd_decl_doc AddMon.of_hom\n\n@[simp] lemma of_hom_apply {X Y : Type u} [monoid X] [monoid Y] (f : X →* Y)\n  (x : X) : of_hom f x = f x := rfl\n\n@[to_additive]\ninstance : inhabited Mon :=\n-- The default instance for `monoid punit` is derived via `punit.comm_ring`,\n-- which breaks to_additive.\n⟨@of punit $ @group.to_monoid _ $ @comm_group.to_group _ punit.comm_group⟩\n\n@[to_additive]\ninstance (M : Mon) : monoid M := M.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [monoid R] : (Mon.of R : Type u) = R := rfl\n\nend Mon\n\n/-- The category of commutative monoids and monoid morphisms. -/\n@[to_additive AddCommMon]\ndef CommMon : Type (u+1) := bundled comm_monoid\n\n/-- The category of additive commutative monoids and monoid morphisms. -/\nadd_decl_doc AddCommMon\n\nnamespace CommMon\n\n@[to_additive]\ninstance : bundled_hom.parent_projection comm_monoid.to_monoid := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommMon\nattribute [to_additive] CommMon.large_category CommMon.concrete_category\n\n@[to_additive] instance : has_coe_to_sort CommMon Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `CommMon` from the underlying type and typeclass. -/\n@[to_additive]\ndef of (M : Type u) [comm_monoid M] : CommMon := bundled.of M\n\n/-- Construct a bundled `AddCommMon` from the underlying type and typeclass. -/\nadd_decl_doc AddCommMon.of\n\n@[to_additive]\ninstance : inhabited CommMon :=\n-- The default instance for `comm_monoid punit` is derived via `punit.comm_ring`,\n-- which breaks to_additive.\n⟨@of punit $ @comm_group.to_comm_monoid _ punit.comm_group⟩\n\n@[to_additive]\ninstance (M : CommMon) : comm_monoid M := M.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [comm_monoid R] : (CommMon.of R : Type u) = R := rfl\n\n@[to_additive has_forget_to_AddMon]\ninstance has_forget_to_Mon : has_forget₂ CommMon Mon := bundled_hom.forget₂ _ _\n\n@[to_additive] instance : has_coe CommMon.{u} Mon.{u} :=\n{ coe := (forget₂ CommMon Mon).obj, }\n\nend CommMon\n\n-- We verify that the coercions of morphisms to functions work correctly:\nexample {R S : Mon}     (f : R ⟶ S) : (R : Type) → (S : Type) := f\nexample {R S : CommMon} (f : R ⟶ S) : (R : Type) → (S : Type) := f\n\n-- We verify that when constructing a morphism in `CommMon`,\n-- when we construct the `to_fun` field, the types are presented as `↥R`,\n-- rather than `R.α` or (as we used to have) `↥(bundled.map comm_monoid.to_monoid R)`.\nexample (R : CommMon.{u}) : R ⟶ R :=\n{ to_fun := λ x,\n  begin\n    match_target (R : Type u),\n    match_hyp x : (R : Type u),\n    exact x * x\n  end ,\n  map_one' := by simp,\n  map_mul' := λ x y,\n  begin rw [mul_assoc x y (x * y), ←mul_assoc y x y, mul_comm y x, mul_assoc, mul_assoc], end, }\n\nvariables {X Y : Type u}\n\nsection\nvariables [monoid X] [monoid Y]\n\n/-- Build an isomorphism in the category `Mon` from a `mul_equiv` between `monoid`s. -/\n@[to_additive add_equiv.to_AddMon_iso \"Build an isomorphism in the category `AddMon` from\nan `add_equiv` between `add_monoid`s.\", simps]\ndef mul_equiv.to_Mon_iso (e : X ≃* Y) : Mon.of X ≅ Mon.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\nend\n\nsection\nvariables [comm_monoid X] [comm_monoid Y]\n\n/-- Build an isomorphism in the category `CommMon` from a `mul_equiv` between `comm_monoid`s. -/\n@[to_additive add_equiv.to_AddCommMon_iso \"Build an isomorphism in the category `AddCommMon`\nfrom an `add_equiv` between `add_comm_monoid`s.\", simps]\ndef mul_equiv.to_CommMon_iso (e : X ≃* Y) : CommMon.of X ≅ CommMon.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\nend\n\nnamespace category_theory.iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Mon`. -/\n@[to_additive AddMon_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism in the category\n`AddMon`.\"]\ndef Mon_iso_to_mul_equiv {X Y : Mon} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\n/-- Build a `mul_equiv` from an isomorphism in the category `CommMon`. -/\n@[to_additive \"Build an `add_equiv` from an isomorphism in the category\n`AddCommMon`.\"]\ndef CommMon_iso_to_mul_equiv {X Y : CommMon} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\nend category_theory.iso\n\n/-- multiplicative equivalences between `monoid`s are the same as (isomorphic to) isomorphisms\nin `Mon` -/\n@[to_additive add_equiv_iso_AddMon_iso \"additive equivalences between `add_monoid`s are the same\nas (isomorphic to) isomorphisms in `AddMon`\"]\ndef mul_equiv_iso_Mon_iso {X Y : Type u} [monoid X] [monoid Y] :\n  (X ≃* Y) ≅ (Mon.of X ≅ Mon.of Y) :=\n{ hom := λ e, e.to_Mon_iso,\n  inv := λ i, i.Mon_iso_to_mul_equiv, }\n\n/-- multiplicative equivalences between `comm_monoid`s are the same as (isomorphic to) isomorphisms\nin `CommMon` -/\n@[to_additive add_equiv_iso_AddCommMon_iso \"additive equivalences between `add_comm_monoid`s are\nthe same as (isomorphic to) isomorphisms in `AddCommMon`\"]\ndef mul_equiv_iso_CommMon_iso {X Y : Type u} [comm_monoid X] [comm_monoid Y] :\n  (X ≃* Y) ≅ (CommMon.of X ≅ CommMon.of Y) :=\n{ hom := λ e, e.to_CommMon_iso,\n  inv := λ i, i.CommMon_iso_to_mul_equiv, }\n\n@[to_additive]\ninstance Mon.forget_reflects_isos : reflects_isomorphisms (forget Mon.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Mon).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Mon_iso).1⟩,\n  end }\n\n@[to_additive]\ninstance CommMon.forget_reflects_isos : reflects_isomorphisms (forget CommMon.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommMon).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommMon_iso).1⟩,\n  end }\n\n/-!\nOnce we've shown that the forgetful functors to type reflect isomorphisms,\nwe automatically obtain that the `forget₂` functors between our concrete categories\nreflect isomorphisms.\n-/\nexample : reflects_isomorphisms (forget₂ CommMon Mon) := by apply_instance\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/category/Mon/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819874558604, "lm_q2_score": 0.7520125737597972, "lm_q1q2_score": 0.45976694193706164}}
{"text": "import CvxLean.Tactic.DCP.Atoms\nimport CvxLean.Lib.Cones\nimport CvxLean.Lib.Missing.Real\nimport CvxLean.Lib.Missing.Matrix\nimport CvxLean.Syntax.Minimization\nimport Optbin.All\nimport Mathbin.Algebra.Order.MonoidLemmasZeroLt\nimport Mathbin.Algebra.Order.Group\n\nnamespace CvxLean\n\n-- Constraints in conic form.\nsection Cones\n\nopen Real\n\n-- Optimality for using a variable in the second argument\n-- will be hard to prove optimality for.\ndeclare_atom expCone [cone] (x : ℝ)- (z : ℝ)+ : expCone x 1 z :=\noptimality by\n  intros x' z' hx hz hexp\n  rw [←exp_iff_expCone] at *\n  exact ((exp_le_exp.2 hx).transₓ hexp).transₓ hz\n\ndeclare_atom Vec.expCone [cone] (n : Nat)& (x : (Finₓ n) → ℝ)- (z : (Finₓ n) → ℝ)+ : Vec.expCone x 1 z :=\noptimality by\n  intros x' z' hx hz hexp i\n  unfold Vec.expCone at *\n  apply (exp_iff_expCone _ _).1\n  exact ((exp_le_exp.2 (hx i)).transₓ ((exp_iff_expCone _ _).2 (hexp i))).transₓ (hz i)\n\ndeclare_atom posOrthCone [cone] (n : Nat)& (x : ℝ)+ : posOrthCone x :=\noptimality by\n  intros x' hx hx0\n  exact hx0.transₓ hx\n\ndeclare_atom Vec.posOrthCone [cone] (n : Nat)& (x : (Finₓ n) → ℝ)+ : Vec.posOrthCone x :=\noptimality by\n  intros x' hx hx0 i\n  exact (hx0 i).transₓ (hx i)\n\ndeclare_atom Matrix.posOrthCone [cone] (m : Nat)& (n : Nat)& (M : Matrix.{0,0,0} (Finₓ m) (Finₓ n) ℝ)+ :\n  Real.Matrix.posOrthCone M :=\noptimality by\n  intros x' hx hx0 i j\n  exact (hx0 i j).transₓ (hx i j)\n\ndeclare_atom rotatedSoCone [cone] (n : Nat)& (v : ℝ)+ (w : ℝ)+ (x : (Finₓ n) → ℝ)? :\n  rotatedSoCone v w x :=\noptimality by\n  intros v' w' hv hw h\n  unfold rotatedSoCone at *\n  apply And.intro\n  · apply h.1.transₓ\n    apply ZeroLt.mul_le_mul_of_nonneg_right\n    apply ZeroLt.mul_le_mul_of_le_of_le hv hw h.2.1 (h.2.2.transₓ hw)\n    have : @Zero.zero Real (MulZeroClassₓ.toHasZero Real) = 0 := by\n      rfl\n    rw [this]\n    simp only [(@Nat.cast_zero ℝ _).symm, (@Nat.cast_one ℝ _).symm]\n    apply Nat.cast_le.2\n    norm_num\n  · exact ⟨h.2.1.transₓ hv, h.2.2.transₓ hw⟩\n\ndeclare_atom Vec.rotatedSoCone [cone] (m : Nat)& (n : Nat)& (v : (Finₓ n) → ℝ)+ (w : (Finₓ n) → ℝ)+ (x : (Finₓ n) → (Finₓ m) → ℝ)? :\n  Vec.rotatedSoCone v w x :=\noptimality by\n  unfold Vec.rotatedSoCone\n  intros v' w' hv hw h i\n  apply rotatedSoCone.optimality _ _ _ _ _ _ (hv i) (hw i) (h i)\n  \ndeclare_atom Matrix.PSDCone [cone] (m : Type)& (hm : Fintype.{0} m)& (A : Matrix.{0,0,0} m m ℝ)? : \n  Matrix.PSDCone A :=\noptimality fun h => h\n\nend Cones\n\n-- NOTE: Workaround for nonterminating simp.\nattribute [-simp] Quot.lift_on_mk Quot.lift_on₂_mk Quot.lift₂_mk\n\n-- Affine operations.\nsection RealAffine\n\nopen Real\n\ndeclare_atom add [affine] (x : ℝ)+ (y : ℝ)+ : x + y :=\nbconditions\nhomogenity by\n  change _ = _ + _ + HasSmul.smul κ (Zero.zero + Zero.zero)\n  rw [smul_add, smul_add, smul_zero]\n  rfl\nadditivity by\n  simp only [add_zero, add_assoc, add_commₓ]\n  rw [add_commₓ x' y', ←add_assocₓ y y' x', add_commₓ _ x']\noptimality fun _ _ => add_le_add\n\ndeclare_atom neg [affine] (x : ℝ)- : - x :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (-x) + -Zero.zero = \n    -HasSmul.smul κ x + HasSmul.smul κ (-Zero.zero)\n  simp\n  rw [smul_zero, smul_neg, add_zeroₓ]\n  rfl\nadditivity by\n  rw [neg_add]\n  simp\n  rfl\noptimality by\n  intros x' hx\n  apply neg_le_neg hx\n\ndeclare_atom maximizeNeg [affine] (x : ℝ)- : maximizeNeg x :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (-x) + -Zero.zero = \n    -HasSmul.smul κ x + HasSmul.smul κ (-Zero.zero)\n  simp\n  rw [smul_zero, smul_neg, add_zeroₓ]\n  rfl\nadditivity by\n  unfold maximizeNeg\n  rw [neg_add]\n  simp\n  rfl\noptimality by\n  intros x' hx\n  apply neg_le_neg hx\n\ndeclare_atom sub [affine] (x : ℝ)+ (y : ℝ)- : x - y :=\nbconditions\nhomogenity by\n  rw [smul_sub, sub_self, smul_zero]\n  rfl\nadditivity by\n  rw [sub_add_comm, add_commₓ, add_sub, add_sub_assoc, sub_sub, add_commₓ y' y, \n    add_sub, sub_self, add_zeroₓ]\noptimality by\n  intros x' y' hx hy\n  apply @sub_le_sub Real _ _ \n    (@OrderedAddCommGroup.to_covariant_class_left_le Real Real.orderedAddCommGroup) \n  exact hx\n  exact hy\n\ndeclare_atom mul1 [affine] (x : ℝ)& (y : ℝ)+ : x * y :=\nbconditions (hx : 0 ≤ x)\nhomogenity by\n  change HasSmul.smul κ (x * y) + x * Zero.zero\n    = x * HasSmul.smul κ y + HasSmul.smul κ (x * Zero.zero)\n  rw [_root_.mul_zero, smul_zero, add_zeroₓ, add_zeroₓ, mul_smul_comm]\nadditivity by\n  change x * y + x * y' = x * (y + y') + x * Zero.zero\n  rw [mul_addₓ, _root_.mul_zero, add_zeroₓ]\noptimality by\n  intros y' hy\n  apply ZeroLt.mul_le_mul_of_nonneg_left hy hx\n\ndeclare_atom mul2 [affine] (x : ℝ)+ (y : ℝ)& : x * y :=\nbconditions (hy : 0 ≤ y)\nhomogenity by\n  change HasSmul.smul κ (x * y) + Zero.zero * y \n    = (HasSmul.smul κ x) * y + HasSmul.smul κ (Zero.zero * y)\n  rw [_root_.zero_mul, smul_zero, add_zeroₓ, add_zeroₓ,\n    _root_.mul_comm, _root_.mul_comm _ y, mul_smul_comm]\nadditivity by\n  change x * y + x' * y = (x + x') * y + Zero.zero * y\n  rw [add_mulₓ, _root_.zero_mul, add_zeroₓ]\noptimality by\n  intros y' hx\n  apply ZeroLt.mul_le_mul_of_nonneg_right hx hy\n\nend RealAffine\n\n-- Affine operations on vectors.\nsection VecAffine\n\ndeclare_atom Vec.nth [affine] (m : Nat)&  (x : Finₓ m → ℝ)? (i : Finₓ m)& : x i :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (x i) + Zero.zero\n    = HasSmul.smul κ x i + HasSmul.smul κ Zero.zero\n  rw [smul_zero, add_zeroₓ, add_zeroₓ]\n  rfl\nadditivity by\n  change x i + x' i = x i + x' i + Zero.zero\n  rw [add_zeroₓ]\noptimality le_reflₓ _\n\ndeclare_atom Vec.add [affine] (m : Nat)&  (x : Finₓ m → ℝ)+ (y : Finₓ m → ℝ)+ : x + y :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (x + y) + (Zero.zero + Zero.zero) \n    = HasSmul.smul κ x + HasSmul.smul κ y + HasSmul.smul κ (Zero.zero + Zero.zero)\n  rw [add_zeroₓ, add_zeroₓ, smul_zero, add_zeroₓ, smul_add]\n  rfl\nadditivity by\n  change x + y + (x' + y') = x + x' + (y + y') + (Zero.zero + Zero.zero)\n  rw [add_zeroₓ, add_zeroₓ, add_assocₓ, add_commₓ x' y', ←add_assocₓ y, add_commₓ _ x']\n  simp [add_assocₓ]\noptimality by\n  intros x' y' hx hy i\n  apply add_le_add (hx i) (hy i)\n\ndeclare_atom Vec.sub [affine] (m : Nat)&  (x : Finₓ m → ℝ)+ (y : Finₓ m → ℝ)- : x - y :=\nbconditions\nhomogenity by\n  rw [sub_self, smul_sub, smul_zero]\n  rfl\nadditivity by\n  rw [sub_add_sub_comm, sub_self, add_zeroₓ]\noptimality by\n  intros x' y' hx hy i\n  apply @sub_le_sub Real _ _ \n    (@OrderedAddCommGroup.to_covariant_class_left_le Real Real.orderedAddCommGroup)\n  exact (hx i)\n  exact (hy i)\n\ndeclare_atom Vec.sum [affine] (m : Nat)& (x : Finₓ m → ℝ)+ : Vec.sum x :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (Vec.sum x) + (∑ i, Zero.zero)\n    = Vec.sum (HasSmul.smul κ x) + HasSmul.smul κ (∑ i, Zero.zero)\n  unfold Vec.sum\n  rw [Finset.smul_sum, Finset.sum_const_zero, add_zeroₓ, smul_zero, add_zeroₓ]\n  rfl\nadditivity by\n  change (∑ i, x i) + (∑ i, x' i) = (∑ i, x i + x' i) + ∑ i, Zero.zero\n  rw [Finset.sum_const_zero, add_zeroₓ, Finset.sum_add_distrib]\noptimality by\n  intro x' hx\n  apply Finset.sum_le_sum\n  intros\n  apply hx\n\ndeclare_atom div [affine] (x : ℝ)+ (y : ℝ)& : x / y :=\nbconditions (hy : (0 : ℝ) ≤ y)\nhomogenity by\n  change κ * (x / y) + Zero.zero / y \n    = κ * x / y + κ * (Zero.zero / y)\n  rw [zero_div, add_zeroₓ, _root_.mul_zero, add_zeroₓ, mul_div]\nadditivity by\n  change x / y + x' / y = (x + x') / y + Zero.zero / y\n  rw [zero_div, add_zeroₓ, add_div]\noptimality by\n  intros x' hx\n  by_cases h : Zero.zero = y\n  · rw [←h, div_zero, div_zero]\n    exact le_reflₓ _\n  · rw [div_le_div_right]\n    apply hx\n    apply lt_of_le_of_neₓ hy h\n\ndeclare_atom Vec.dotProduct1 [affine] (m : Nat)& (x : Finₓ m → ℝ)& (y : Finₓ m → ℝ)? : Matrix.dotProduct x y := \nbconditions\nhomogenity by\n  change κ * (Matrix.dotProduct x y) + Matrix.dotProduct x Zero.zero =\n    Matrix.dotProduct x (HasSmul.smul κ y) + κ * (Matrix.dotProduct x Zero.zero)\n  rw [Matrix.dot_product_zero, add_zeroₓ, _root_.mul_zero, add_zeroₓ,\n    Matrix.dot_product_smul]\n  rfl\nadditivity by\n  change Matrix.dotProduct x y + Matrix.dotProduct x y'\n    = Matrix.dotProduct x (y + y') + Matrix.dotProduct x Zero.zero\n  rw [Matrix.dot_product_zero, add_zeroₓ, Matrix.dot_product_add]\noptimality le_reflₓ _\n\ndeclare_atom Vec.dotProduct2 [affine] (m : Nat)& (x : Finₓ m → ℝ)? (y : Finₓ m → ℝ)& : Matrix.dotProduct x y := \nbconditions\nhomogenity by\n  change κ * (Matrix.dotProduct x y) + Matrix.dotProduct Zero.zero y =\n    Matrix.dotProduct (HasSmul.smul κ x) y + κ * (Matrix.dotProduct Zero.zero y)\n  rw [Matrix.zero_dot_product, add_zeroₓ, _root_.mul_zero, add_zeroₓ,\n    Matrix.dot_product_comm (HasSmul.smul κ x), Matrix.dot_product_smul, Matrix.dot_product_comm]\n  rfl\nadditivity by\n  change Matrix.dotProduct x y + Matrix.dotProduct x' y\n    = Matrix.dotProduct (x + x' : Finₓ m → Real) y + Matrix.dotProduct Zero.zero y\n  rw [Matrix.zero_dot_product, add_zeroₓ, Matrix.add_dot_product]\noptimality le_reflₓ _\n\ndeclare_atom smul [affine] (n : ℕ)& (y : ℝ)+ : @HasSmul.smul ℕ Real AddMonoidₓ.hasSmulNat n y :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (HasSmul.smul n y) + HasSmul.smul n Zero.zero =\n    HasSmul.smul n (HasSmul.smul κ y) + HasSmul.smul κ (HasSmul.smul n Zero.zero)\n  rw [smul_zero, add_zeroₓ, smul_zero, smul_zero, add_zeroₓ, smul_comm]\nadditivity by\n  change HasSmul.smul n y + HasSmul.smul n y'\n    = HasSmul.smul n (y + y') + HasSmul.smul n Zero.zero\n  rw [smul_zero, add_zeroₓ, smul_add]\n  rfl\noptimality by\n  intros y' hy\n  apply smul_le_smul_of_nonneg hy (Nat.zero_leₓ _)\n\nend VecAffine\n\n-- Affine operations on matrices.\nsection MatrixAffine \n\ndeclare_atom Matrix.vec_cons [affine] (n : Nat)& (x : ℝ)+ (y : (Finₓ n) → ℝ)+ : \n  Matrix.vecCons x y :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (Matrix.vecCons x y) + Matrix.vecCons (Zero.zero : ℝ) (Zero.zero : (Finₓ n) → ℝ) =\n    Matrix.vecCons (κ * x) (HasSmul.smul κ y) + HasSmul.smul κ (Matrix.vecCons (Zero.zero : ℝ) (Zero.zero : (Finₓ n) → ℝ))\n  ext ⟨i, hi⟩\n  cases i\n  · simp [HasSmul.smul, Matrix.Computable.Pi.hasSmul', Matrix.Computable.Mul.toHasSmul']\n  · simp [HasSmul.smul, Matrix.Computable.Pi.hasSmul', Matrix.Computable.Mul.toHasSmul']\nadditivity by\n  change Matrix.vecCons x y + Matrix.vecCons x' y'\n    = Matrix.vecCons (x + x' : ℝ) (y + y' : (Finₓ n) → ℝ)\n      + Matrix.vecCons (Zero.zero : ℝ) (Zero.zero : (Finₓ n) → ℝ)\n  ext ⟨i, hi⟩\n  cases i\n  · simp\n  · simp\noptimality by\n  intros x' y' hx hy i\n  cases i with\n  | mk i hi =>\n    cases i with\n    | zero => simp [hx]\n    | succ i => simp [hy ⟨i, Nat.succ_lt_succ_iff.1 hi⟩]\n\ndeclare_atom Matrix.sum [affine] (m : Nat)& (X : Matrix.{0,0,0} (Finₓ m) (Finₓ m) ℝ)+ : Matrix.sum X :=\nbconditions\nhomogenity by\n  change κ * (∑ i, ∑ j, X i j) + (∑ i, ∑ j, Zero.zero)\n    = (∑ i, ∑ j, κ * X i j) + κ * (∑ i, ∑ j, Zero.zero)\n  rw [Finset.sum_const_zero, Finset.sum_const_zero, _root_.mul_zero, add_zeroₓ, add_zeroₓ]\n  simp only [Finset.mul_sum]\nadditivity by\n  change (∑ i, ∑ j, X i j) + (∑ i, ∑ j, X' i j) \n    = (∑ i, ∑ j, X i j + X' i j) + ∑ i, ∑ j, Zero.zero\n  rw [Finset.sum_const_zero, Finset.sum_const_zero, add_zeroₓ]\n  simp only [Finset.sum_add_distrib]\noptimality by\n  intros X' hX\n  apply Finset.sum_le_sum (fun i _ => Finset.sum_le_sum (fun j _ => ?_))\n  apply hX\n\ndeclare_atom Matrix.nth [affine] (m : Nat)& (X : Matrix.{0,0,0} (Finₓ m) (Finₓ m) ℝ)? (i : Finₓ m)& : X i :=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (X i) + Zero.zero = HasSmul.smul κ X i + HasSmul.smul κ Zero.zero\n  rw [add_zeroₓ, smul_zero, add_zeroₓ]\n  rfl\nadditivity by\n  change X i + X' i = HAdd.hAdd X X' i + Zero.zero\n  rw [add_zeroₓ]\n  rfl\noptimality le_reflₓ _\n\ndeclare_atom Matrix.nth2 [affine] (m : Nat)& (X : Matrix.{0,0,0} (Finₓ m) (Finₓ m) ℝ)? (i : Finₓ m)& (j : Finₓ m)& : X i j :=\nbconditions\nhomogenity by\n  change _ + Zero.zero = _ + HasSmul.smul κ Zero.zero\n  rw [smul_zero]\n  rfl\nadditivity by\n  change _ = _ + Zero.zero\n  rw [add_zeroₓ]\n  rfl\noptimality le_reflₓ _\n  \n-- TODO: make argument increasing, without breaking det-log-atom\ndeclare_atom Matrix.diag [affine] (n : ℕ)& (A : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)? : A.diag :=\nbconditions\nhomogenity by\n  change _ + Zero.zero\n    = _ + HasSmul.smul κ Zero.zero\n  rw [add_zeroₓ, smul_zero, add_zeroₓ]\n  rfl\nadditivity by\n  change _  = _ + Zero.zero\n  rw [add_zeroₓ]\n  rfl\noptimality le_reflₓ _\n\ndeclare_atom Matrix.diagonal [affine] (n : ℕ)& (d : Finₓ n → ℝ)+ : Matrix.diagonal d :=\nbconditions\nhomogenity by\n  ext i j\n  change\n    κ * (Matrix.diagonalₓ d) i j + (Matrix.diagonal fun i => Zero.zero) i j =\n    Matrix.diagonalₓ (HasSmul.smul κ d) i j + HasSmul.smul κ (Matrix.diagonal Zero.zero) i j\n  by_cases h : i = j\n  · simp [Matrix.diagonal, h]\n    change κ * d j = HasSmul.smul κ d j + κ * Zero.zero\n    rw [_root_.mul_zero, add_zeroₓ]\n    rfl\n  · simp [Matrix.diagonal, h]\n    change Zero.zero = κ * Zero.zero\n    rw [_root_.mul_zero]\nadditivity by\n  change Matrix.diagonalₓ _ + Matrix.diagonalₓ _\n    = _ + Matrix.diagonalₓ fun i => Zero.zero\n  rw [Matrix.diagonal_add, Matrix.diagonal_zero, add_zeroₓ]\n  rfl\noptimality by\n  intros d' hd i j\n  by_cases h : i = j\n  · simp [Matrix.diagonal, h, hd j]\n  · simp [Matrix.diagonal, h, hd j]\n\ndeclare_atom Matrix.diagonalₓ [affine] (n : ℕ)& (d : Finₓ n → ℝ)+ : Matrix.diagonalₓ d :=\nbconditions\nhomogenity by\n  ext i j\n  change\n    κ * (Matrix.diagonalₓ d) i j + (Matrix.diagonal fun i => Zero.zero) i j =\n    Matrix.diagonalₓ (HasSmul.smul κ d) i j + HasSmul.smul κ (Matrix.diagonal Zero.zero) i j\n  by_cases h : i = j\n  · simp [Matrix.diagonal, h]\n    change κ * d j = HasSmul.smul κ d j + κ * Zero.zero\n    rw [_root_.mul_zero, add_zeroₓ]\n    rfl\n  · simp [Matrix.diagonal, h]\n    change Zero.zero = κ * Zero.zero\n    rw [_root_.mul_zero]\nadditivity by\n  change _ = _ + Matrix.diagonalₓ fun i => Zero.zero\n  rw [Matrix.diagonal_add, Matrix.diagonal_zero, add_zeroₓ]\n  rfl\noptimality by\n  intros d' hd i j\n  by_cases h : i = j\n  · simp [Matrix.diagonal, h, hd j]\n  · simp [Matrix.diagonal, h, hd j]\n\n-- NOTE: Helper lemma needed due to mathport\nlemma zero_eq_zero [Zero α] : (0 : α) = Zero.zero := rfl\n\ndeclare_atom Matrix.trace [affine] (m : Type)& (hm : Fintype.{0} m)& (A : Matrix.{0,0,0} m m ℝ)+ : Matrix.trace A:=\nbconditions\nhomogenity by\n  change HasSmul.smul κ (Matrix.trace A) + Matrix.trace Zero.zero\n    = Matrix.trace (HasSmul.smul κ A) + HasSmul.smul κ (Matrix.trace Zero.zero)\n  rw [← Matrix.trace_smul, ← Matrix.trace_smul, smul_zero]\n  rfl\nadditivity by\n  rw [zero_eq_zero, Matrix.trace_add, Matrix.trace_zero, add_zeroₓ]\noptimality by\n  intros A' hA\n  apply Finset.sum_le_sum\n  intros i _\n  exact hA i i\n\ndeclare_atom Matrix.toUpperTri [affine] (n : ℕ)& (A : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)+ : \n  A.toUpperTri :=\nbconditions\nhomogenity by\n  ext i j\n  change κ * (Matrix.toUpperTri A) i j + (Matrix.toUpperTri 0) i j =\n    (Matrix.toUpperTri (HasSmul.smul κ A)) i j + κ * (Matrix.toUpperTri Zero.zero) i j\n  by_cases h : i ≤ j\n  · unfold Matrix.toUpperTri\n    simp [h]\n    change κ * A i j + 0 = HasSmul.smul κ A i j + κ * Zero.zero\n    rw [_root_.mul_zero]\n    rfl\n  · unfold Matrix.toUpperTri\n    simp [h]\nadditivity by\n  ext i j\n  change (Matrix.toUpperTri A) i j+ (Matrix.toUpperTri A') i j =\n    (Matrix.toUpperTri _) i j + (Matrix.toUpperTri Zero.zero) i j\n  by_cases h : i ≤ j\n  · unfold Matrix.toUpperTri\n    simp [h]\n    change A i j + A' i j = HAdd.hAdd A A' i j + Zero.zero\n    rw [add_zeroₓ]\n    rfl\n  · unfold Matrix.toUpperTri\n    simp [h]\noptimality by\n  intros A' hA\n  ext i j\n  by_cases h : i ≤ j\n  · unfold Matrix.toUpperTri\n    simp [h, hA i j]\n  · unfold Matrix.toUpperTri\n    simp [h]\n\ndeclare_atom Matrix.transpose [affine] (n : ℕ)& (A : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)+ : \n  A.transpose :=\nbconditions\nhomogenity by\n  change _ = _ + HasSmul.smul _ (Matrix.transposeₓ Zero.zero)\n  simp [zero_eq_zero, Matrix.transpose_zero]\n  rw [smul_zero]\n  rfl\nadditivity by\n  change Matrix.transposeₓ _ + Matrix.transposeₓ _\n    = Matrix.transposeₓ _ + Matrix.transposeₓ _\n  simp\n  rfl\noptimality by\n  intros _ hA\n  ext i j\n  exact hA j i\n\ndeclare_atom Matrix.transposeₓ [affine] (n : ℕ)& (A : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)+ : \n  A.transposeₓ :=\nbconditions\nhomogenity by\n  simp [zero_eq_zero, Matrix.transpose_zero]\n  rw [smul_zero, add_zeroₓ]\n  rfl\nadditivity by\n  simp\n  rfl\noptimality by\n  intros _ hA\n  ext i j\n  exact hA j i\n\n@[simp] lemma Matrix.from_blocks_zero [Zero α]: \n  Matrix.fromBlocks (0 : Matrix n l α) (0 : Matrix n m α) (0 : Matrix o l α) (0 : Matrix o m α) = 0 := by\n  ext i j\n  cases i\n  · cases j\n    rfl\n    rfl\n  · cases j\n    rfl\n    rfl\n\ndeclare_atom Matrix.fromBlocks [affine] (n : ℕ)& \n  (A : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)+ (B : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)+\n  (C : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)+ (D : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)+ :\n  Matrix.fromBlocks A B C D :=\nbconditions\nhomogenity by\n  change _ = _ + HasSmul.smul κ _\n  rw [Matrix.from_blocks_smul,  Matrix.from_blocks_zero, zero_eq_zero, smul_zero]\n  rfl\nadditivity by\n  simp [Matrix.from_blocks_add, zero_eq_zero]\noptimality by\n  intros A' B' C' D' hA hB hC hD i j\n  cases i with\n  | inl i =>\n    cases j with\n    | inl j => exact hA i j\n    | inr j => exact hB i j\n  | inr i => \n    cases j with\n    | inl j => exact hC i j\n    | inr j => exact hD i j\n\ndeclare_atom Matrix.add [affine] (m : Type)& (n : Type)& (A : Matrix.{0,0,0} m n ℝ)+ (B : Matrix.{0,0,0} m n ℝ)+ : A + B :=\nbconditions\nhomogenity by\n  rw [zero_eq_zero, add_zeroₓ, add_zeroₓ, smul_zero, add_zeroₓ, smul_add]\n  rfl\nadditivity by\n  rw [zero_eq_zero, add_zeroₓ, add_zeroₓ, add_assocₓ, add_commₓ B, add_assocₓ A', add_commₓ B']\n  simp only [add_assocₓ]\noptimality by\n  intros A' B' hA hB i j\n  apply add_le_add (hA i j) (hB i j)\n\ndeclare_atom Matrix.sub [affine] (m : Type)& (n : Type)& (A : Matrix.{0,0,0} m n ℝ)+ (B : Matrix.{0,0,0} m n ℝ)- : A - B :=\nbconditions\nhomogenity by\n  ext i j\n  rw [sub_self]\n  change\n    κ * (A - B) i j + Zero.zero =\n    κ * A i j - κ * B i j + κ * Zero.zero\n  rw [_root_.mul_zero, add_zeroₓ, add_zeroₓ, ←mul_sub]\n  rfl\nadditivity by\n  rw [sub_self, add_zeroₓ, sub_add_sub_comm]\noptimality by\n  intros A' B' hA hB i j\n  change A i j - B i j ≤ A' i j - B' i j\n  apply @sub_le_sub Real _ _ \n    (@OrderedAddCommGroup.to_covariant_class_left_le Real Real.orderedAddCommGroup)\n  exact hA i j\n  exact hB i j\n\ndeclare_atom Matrix.mul1 [affine] (m : Type)& (hm : Fintype.{0} m)&\n  (A : Matrix.{0,0,0} m m ℝ)& (B : Matrix.{0,0,0} m m ℝ)? : A ⬝ B :=\nbconditions\nhomogenity by\n  rw [zero_eq_zero, Matrix.mul_zero, smul_zero, Matrix.mul_smul]\n  rfl\nadditivity by \n  rw [Matrix.mul_add, zero_eq_zero, Matrix.mul_zero, add_zeroₓ]\noptimality le_reflₓ (A ⬝ B)\n\ndeclare_atom Matrix.mul2 [affine] (m : Type)& (hm : Fintype.{0} m)&\n  (A : Matrix.{0,0,0} m m ℝ)? (B : Matrix.{0,0,0} m m ℝ)& : A ⬝ B :=\nbconditions\nhomogenity by\n  haveI := @IsScalarTower.right Real Real Real.commSemiring Real.semiring (@Algebra.id Real Real.commSemiring)\n  rw [Matrix.smul_mul]\n  rw [zero_eq_zero, Matrix.zero_mul, smul_zero]\n  rfl\nadditivity by \n  rw [Matrix.add_mul, zero_eq_zero, Matrix.zero_mul, add_zeroₓ]\noptimality le_reflₓ (A ⬝ B)\n\ndeclare_atom Matrix.mulVec [affine] (n : ℕ)& (m : ℕ)& (M : Matrix.{0,0,0} (Finₓ m) (Finₓ n) ℝ)& (v : Finₓ n → ℝ)? :\n  Matrix.mulVecₓ M v :=\nbconditions\nhomogenity by\n  simp [zero_eq_zero]\n  rw [smul_zero, add_zeroₓ, Matrix.mul_vec_smul]\n  rfl\nadditivity by\n  simp [zero_eq_zero, Matrix.mul_vec_add]\noptimality le_reflₓ _\n\ndeclare_atom Matrix.vecMul [affine] (n : ℕ)& (m : ℕ)& (v : Finₓ m → ℝ)? (M : Matrix.{0,0,0} (Finₓ m) (Finₓ n) ℝ)& :\n  Matrix.vecMulₓ v M :=\nbconditions\nhomogenity by\n  simp [zero_eq_zero]\n  haveI := @IsScalarTower.right Real Real Real.commSemiring Real.semiring (@Algebra.id Real Real.commSemiring)\n  rw [smul_zero, add_zeroₓ, Matrix.vec_mul_smul]\n  rfl\nadditivity by\n  simp [zero_eq_zero, Matrix.add_vec_mul]\noptimality le_reflₓ _\n\n\nend MatrixAffine \n\n-- Non-affine atoms on real variables.\nsection Real\n\nopen Real\n\ndeclare_atom le [concave] (x : ℝ)- (y : ℝ)+ : x ≤ y :=\nvconditions\nimplementationVars\nimplementationObjective Real.posOrthCone (y - x)\nimplementationConstraints\nsolution\nsolutionEqualsAtom by \n  simp [Real.posOrthCone, zero_eq_zero]\nfeasibility\noptimality by\n  intros x' y' hx hy h\n  simp [Real.posOrthCone, zero_eq_zero] at h \n  exact (hx.transₓ h).transₓ hy\nvconditionElimination\n\ndeclare_atom eq [concave] (x : ℝ)? (y : ℝ)? : x = y := \nvconditions\nimplementationVars\nimplementationObjective Real.zeroCone (y - x)\nimplementationConstraints\nsolution\nsolutionEqualsAtom by \n  simp [Real.zeroCone, sub_eq_iff_eq_add, zero_add]\n  exact Iff.intro Eq.symm Eq.symm;\nfeasibility\noptimality by \n  simp [Real.zeroCone, sub_eq_iff_eq_add, zero_add]\n  intros h\n  exact Eq.symm h\nvconditionElimination\n\ndeclare_atom sq [convex] (x : ℝ)? : x ^ 2 := \nvconditions\nimplementationVars (t : ℝ)\nimplementationObjective (t)\nimplementationConstraints\n  (c1 : rotatedSoCone t (1/2) (![x] : Finₓ 1 → ℝ))\nsolution\n  (t := x ^ 2)\nsolutionEqualsAtom rfl\nfeasibility\n  (c1 : by \n    simp [rotatedSoCone]\n    refine ⟨?_, ?_, ?_⟩\n    · have : (2 : ℝ) ≠ 0 := by\n        apply ne_of_gtₓ\n        simp only [(@Nat.cast_zero ℝ _).symm, (@Nat.cast_one ℝ _).symm]\n        apply Nat.cast_lt.2\n        norm_num\n      simp [_root_.mul_assoc, div_mul_cancel _ this]\n      have : x ^ 2 = @HPow.hPow ℝ ℕ ℝ instHPow x 2 := \n        by apply Real.rpow_nat_cast\n      rw [this]\n      exact le_reflₓ _\n    · have : x ^ 2 = @HPow.hPow ℝ ℕ ℝ instHPow x 2 := \n        by apply Real.rpow_nat_cast\n      rw [this]\n      exact sq_nonneg x\n    · rw [zero_eq_zero]\n      rw [← zero_div 2]\n      have : (0 : ℝ) < (2 : ℝ) := by\n        simp only [(@Nat.cast_zero ℝ _).symm, (@Nat.cast_one ℝ _).symm]\n        apply Nat.cast_lt.2\n        norm_num\n      have := (@div_le_div_right ℝ _ 0 1 2 this).2\n      refine this ?_\n      have : ZeroLeOneClass ℝ := @OrderedSemiring.zeroLeOneClass ℝ Real.orderedSemiring\n      exact zero_le_one)\noptimality by\n  have := c1.1\n  have two_ne_zero : (2 : ℝ) ≠ 0 := by\n    apply ne_of_gtₓ\n    simp only [(@Nat.cast_zero ℝ _).symm, (@Nat.cast_one ℝ _).symm]\n    apply Nat.cast_lt.2\n    norm_num\n  simp [_root_.mul_assoc, div_mul_cancel _ two_ne_zero] at this\n  have pow_eq_pow : x ^ 2 = @HPow.hPow ℝ ℕ ℝ instHPow x 2 := \n    by apply Real.rpow_nat_cast\n  rw [pow_eq_pow]\n  exact this\nvconditionElimination \n\ndeclare_atom exp [convex] (x : ℝ)+ : Real.exp x :=\nvconditions\nimplementationVars (t : ℝ)\nimplementationObjective t\nimplementationConstraints (c_exp : expCone x 1 t)\nsolution (t := exp x)\nsolutionEqualsAtom by\n  rfl;\nfeasibility (c_exp : by\n  simp [expCone]\n  apply Or.inl;\n  refine ⟨Real.zero_lt_one, ?_⟩\n  change x / One.one ≤ x\n  rw [div_one]\n  apply le_reflₓ _)\noptimality by\n  intros x' hx\n  rw [←exp_iff_expCone] at c_exp\n  exact (exp_le_exp.2 hx).transₓ c_exp\nvconditionElimination\n\ndeclare_atom sqrt [concave] (x : ℝ)+ : Real.sqrt x := \nvconditions (cond : 0 ≤ x)\nimplementationVars (t : ℝ)\nimplementationObjective (t)\nimplementationConstraints \n  (c1 : rotatedSoCone x (1/2) (![t] : Finₓ 1 → ℝ))\nsolution (t := Real.sqrt x)\nsolutionEqualsAtom by\n  rfl;\nfeasibility \n  (c1 : by\n    unfold rotatedSoCone\n    rw [← sq_sqrt cond]\n    have : sqrt x ^ 2 = @HPow.hPow ℝ ℕ ℝ instHPow (sqrt x) 2 := \n        by apply Real.rpow_nat_cast\n    have sqf := sq.feasibility0 (sqrt x)\n    rw [this] at sqf\n    simp only [rotatedSoCone] at sqf\n    have : 2 = bit0 One.one := rfl\n    rw [this, sq_sqrt cond] at sqf\n    rw [this, sq_sqrt cond]\n    apply sqf)\noptimality by\n  intros y hy\n  have sqopt := sq.optimality t x c1\n  apply Real.le_sqrt_of_sq_le\n  have : t ^ 2 = @HPow.hPow ℝ ℕ ℝ instHPow t (bit0 One.one) := \n      by apply Real.rpow_nat_cast\n  rw [←this]\n  apply sqopt.transₓ hy\nvconditionElimination (cond : fun _ hx => c1.2.1.transₓ hx)\n\ndeclare_atom log [concave] (x : ℝ)+ : log x :=\nvconditions (cond : 0 < x)\nimplementationVars (t : ℝ)\nimplementationObjective t\nimplementationConstraints (c_exp : expCone t (1) x)\nsolution (t := log x)\nsolutionEqualsAtom by \n  rfl;\nfeasibility (c_exp : by \n  simp [expCone] \n  left\n  apply And.intro Real.zero_lt_one\n  erw [div_one, Real.exp_log cond]\n  exact le_reflₓ _)\noptimality by \n  intros x' hx;\n  simp [expCone] at c_exp\n  cases c_exp with \n  | inl h => \n    rcases h with ⟨_, h⟩\n    cases em (0 < x) with \n    | inl h0x => \n      erw [le_log_iff_exp_le (lt_of_lt_of_leₓ h0x hx)]\n      erw [div_one] at h\n      exact le_transₓ h hx\n    | inr h0x => \n      exfalso\n      cases (eq_or_lt_of_not_ltₓ h0x) with \n      | inl heq => \n        erw [div_one] at h\n        exact lt_irreflₓ 0 (lt_of_lt_of_leₓ (exp_pos t) (heq ▸ h))\n      | inr hlt =>\n        erw [div_one] at h\n        exact lt_irreflₓ 0 (lt_transₓ (lt_of_lt_of_leₓ (exp_pos t) h) hlt)\n  | inr h => \n    rcases h with ⟨_, hc, _⟩; \n    exfalso\n    exact (zero_ne_one hc.symm)\nvconditionElimination \n  (cond : by\n    simp [expCone] at c_exp\n    apply c_exp.by_cases\n    · intro h\n      exact fun _ h' => lt_of_lt_of_leₓ (lt_of_lt_of_leₓ (Real.exp_pos _) h.2) h'\n    · intro h\n      exact False.elim $ zero_ne_one h.2.1.symm)\n\ndeclare_atom abs [convex] (x : ℝ)? : abs x :=\nvconditions\nimplementationVars (t : ℝ)\nimplementationObjective t\nimplementationConstraints\n  (c_pos : posOrthCone (t - x))\n  (c_neg : posOrthCone (t + x))\nsolution (t := abs x)\nsolutionEqualsAtom rfl\nfeasibility \n  (c_pos : by\n    unfold posOrthCone\n    rw [zero_eq_zero, sub_nonneg]\n    apply le_abs_self) \n  (c_neg : by\n    unfold posOrthCone\n    rw [zero_eq_zero, ← neg_le_iff_add_nonneg' \n      (_inst_3 := @OrderedAddCommGroup.to_covariant_class_left_le Real Real.orderedAddCommGroup)]\n    apply neg_abs_le_self \n      (_inst_3 := @OrderedAddCommGroup.to_covariant_class_left_le Real Real.orderedAddCommGroup))\noptimality by\n  apply abs_le.2\n  rw [←sub_nonneg, sub_neg_eq_add, add_commₓ, ←sub_nonneg (b := x)]\n  exact ⟨c_neg, c_pos⟩\nvconditionElimination\n\nend Real\n\n-- Non-affine atoms on vectors.\nsection Vec\n\nopen Vec\n\ndeclare_atom Vec.le [concave] (n : Nat)& (x : (Finₓ n) → ℝ)- (y : (Finₓ n) → ℝ)+ : x ≤ y :=\nvconditions\nimplementationVars\nimplementationObjective Real.Vec.posOrthCone (y - x : (Finₓ n) → ℝ)\nimplementationConstraints\nsolution\nsolutionEqualsAtom by\n  unfold Real.Vec.posOrthCone\n  rw [← iff_iff_eq]\n  constructor\n  · intros h i\n    rw [←le.solEqAtom]\n    apply h\n  · intros h i\n    change Zero.zero ≤ y i - x i\n    rw [le.solEqAtom]\n    apply h\nfeasibility\noptimality by\n  intros x' y' hx hy h i\n  apply le.optimality _ _ _ _ (hx i) (hy i) (h i)\nvconditionElimination\n\ndeclare_atom Vec.exp [convex] (n : Nat)& (x : (Finₓ n) → ℝ)+ : exp x :=\nvconditions\nimplementationVars (t : Finₓ n → ℝ)\nimplementationObjective t\nimplementationConstraints (c_exp : Real.Vec.expCone x 1 t)\nsolution (t := exp x)\nsolutionEqualsAtom \n  rfl\nfeasibility \n  (c_exp: by\n    intros _ _\n    apply exp.feasibility0)\noptimality by\n  intros x' hx i\n  apply exp.optimality _ _ (c_exp i) _ (hx i)\nvconditionElimination\n\ndeclare_atom Vec.log [concave] (n : Nat)& (x : (Finₓ n) → ℝ)+ : log x :=\nvconditions (cond : ∀ i, 0 < x i)\nimplementationVars (t : (Finₓ n) → ℝ)\nimplementationObjective t\nimplementationConstraints (c_exp : Real.Vec.expCone t 1 x)\nsolution (t := log x)\nsolutionEqualsAtom rfl\nfeasibility \n  (c_exp: by\n    intros _ i\n    apply log.feasibility0\n    apply cond)\noptimality by\n  intros x' hx i\n  apply log.optimality _ _ (c_exp i) _ (hx i)\nvconditionElimination (cond : by\n  intros x' hx i\n  apply log.vcondElim0 _ _ (c_exp i) _ (hx i))\n\ndeclare_atom Vec.abs [convex] (n : Nat)& (x : (Finₓ n) → ℝ)? : abs x :=\nvconditions\nimplementationVars (t : (Finₓ n) → ℝ)\nimplementationObjective t\nimplementationConstraints\n  (c_pos : Real.Vec.posOrthCone (t - x : (Finₓ n) → ℝ))\n  (c_neg : Real.Vec.posOrthCone (t + x : (Finₓ n) → ℝ))\nsolution (t := abs x)\nsolutionEqualsAtom rfl\nfeasibility\n  (c_pos : by\n    intros _ _\n    apply abs.feasibility0)\n  (c_neg : by\n    intros _ _\n    apply abs.feasibility1)\noptimality by\n  intros i\n  apply abs.optimality _ _ (c_pos i) (c_neg i)\nvconditionElimination\n\nend Vec\n\n-- Non-affine atoms on real variables.\nnamespace Matrix\n\ndeclare_atom Matrix.PosSemidef [concave] (m : Type)& (hm : Fintype.{0} m)& (A : Matrix.{0,0,0} m m ℝ)? : Matrix.PosSemidef A :=\nvconditions\nimplementationVars\nimplementationObjective Real.Matrix.PSDCone A\nimplementationConstraints\nsolution\nsolutionEqualsAtom by simp [Real.Matrix.PSDCone]\nfeasibility\noptimality by simp [Real.Matrix.PSDCone]\nvconditionElimination\n\ndeclare_atom Matrix.logDet [concave] (n : ℕ)& (A : Matrix.{0,0,0} (Finₓ n) (Finₓ n) ℝ)? : Real.log A.det :=\nvconditions (hA : A.PosDef)\nimplementationVars (t : Finₓ n → ℝ) (Y : Matrix (Finₓ n) (Finₓ n) ℝ)\n-- The lower left values of `Y` are unused. CVXPy uses a vector `z` instead of a matrix `Y`.\nimplementationObjective Vec.sum t\nimplementationConstraints \n  (c_exp : Real.Vec.expCone t 1 Y.diag)\n  (c_posdef : Matrix.PosSemidef $\n    let Z := Y.toUpperTri;\n    let D := Matrix.diagonalₓ Y.diag\n    let X := Matrix.fromBlocks D            Z \n                               Z.transpose  A;\n    X)\nsolution \n  (t := \n    have : Decidable (A.PosDef) := Classical.dec _ \n    if h : A.PosDef then Vec.log (LDL.diagEntries h) else 0) \n  (Y :=\n    have : Decidable (A.PosDef) := Classical.dec _ \n    if h : A.PosDef then LDL.diag h ⬝ (LDL.lower h).transpose else 0) \nsolutionEqualsAtom by\n  simp only [dif_pos hA, Vec.sum, Vec.log]\n  exact Matrix.LogDetAtom.solution_eq_atom hA\nfeasibility \n  (c_exp : by\n    simp only [Real.Vec.expCone, dif_pos hA]\n    intro i\n    show \n      Real.expCone ((Real.log (LDL.diagEntries hA i))) 1\n        (Matrix.diag (LDL.diag hA ⬝ (LDL.lower hA).transpose) i)\n    rw [← Real.exp_iff_expCone, Real.exp_log]\n    exact Matrix.LogDetAtom.feasibility_exp hA i\n    exact Matrix.LDL.diag_entries_pos hA i)\n  (c_posdef : by\n    simp only [dif_pos hA]\n    apply Matrix.LogDetAtom.feasibility_pos_def' hA rfl rfl rfl)\noptimality by\n  apply Matrix.LogDetAtom.optimality _ rfl rfl c_posdef\n  intro i\n  rw [Real.exp_iff_expCone]\n  apply c_exp\nvconditionElimination \n  (hA : by\n    apply Matrix.LogDetAtom.cond_elim _ rfl rfl c_posdef\n    · exact t\n    · intro i\n      rw [Real.exp_iff_expCone]\n      apply c_exp)\n\ndeclare_atom Matrix.abs [convex] (m : Nat)& (n : Nat)& (M : Matrix.{0,0,0} (Finₓ m) (Finₓ n) ℝ)? : Matrix.abs M :=\nvconditions\nimplementationVars (T : Matrix (Finₓ m) (Finₓ n) ℝ)\nimplementationObjective T\nimplementationConstraints\n  (c_pos : Real.Matrix.posOrthCone (T - M : Matrix (Finₓ m) (Finₓ n) ℝ))\n  (c_neg : Real.Matrix.posOrthCone (T + M : Matrix (Finₓ m) (Finₓ n) ℝ))\nsolution (T := M.abs)\nsolutionEqualsAtom rfl\nfeasibility\n  (c_pos : by \n    intros _ _ _\n    apply abs.feasibility0)\n  (c_neg :  by \n    intros _ _ _\n    apply abs.feasibility1)\noptimality by\n  intros i j\n  apply abs.optimality _ _ (c_pos i j) (c_neg i j)\nvconditionElimination\n\nend Matrix\n", "meta": {"author": "verified-optimization", "repo": "CvxLean", "sha": "fc2996519f0fca96f5ab48a5a1479c6a8024f733", "save_path": "github-repos/lean/verified-optimization-CvxLean", "path": "github-repos/lean/verified-optimization-CvxLean/CvxLean-fc2996519f0fca96f5ab48a5a1479c6a8024f733/CvxLean/Tactic/DCP/AtomLibrary.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597974, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.45976693128727825}}
{"text": "import data.vector\nimport data.equiv.denumerable\nimport data.list.sort\nimport ring_theory.tensor_product\nimport algebra.category.Module.basic\n\n@[derive decidable_eq] inductive type (cT : Type) : Type\n| const : cT → type\n| arrow : type → type → type\n| tensor : type → type → type\n\nvariables (cT : Type)\n\n@[reducible] def context (cT : Type) : Type := list (string × type cT)\n\nnotation a ` ++' ` b := list.append b a\n\nnotation a ` ::' ` b := list.cons b a\n\n\nvariables {cT}\n\ninductive term (const_term : type cT → Type) : Π (Γ : context cT) (A : type cT), Type\n| const {T : type cT} (t : const_term T) : term [] T\n| var (a : string) (T : type cT) : term [(a, T)] T\n| app (Γ₁ Γ₂ : context cT) {T₁ T₂ : type cT} (f : term Γ₁ (T₁.arrow T₂)) (x : term Γ₂ T₁) : \n    term (Γ₁ ++' Γ₂) T₂\n| lambda {Γ : context cT} (a : string) (T₁ : type cT) {T₂ : type cT}\n    (t : term (Γ ::' (a, T₁)) T₂) : term Γ (T₁.arrow T₂)\n\nopen category_theory\n\nvariables {R : Type} [comm_ring R] \n\nsection\n\nvariables (cTi : cT → Module.{0 0} R) \n\nopen_locale tensor_product\n\ndef typei : type cT → Module R\n| (type.const T)     := cTi T\n| (type.arrow T₁ T₂) := Module.of R (typei T₁ →ₗ[R] typei T₂)\n| (type.tensor T₁ T₂) := Module.of R (typei T₁ ⊗[R] typei T₂)\n\ndef contexti : context cT → Module R\n| []       := Module.of R R\n| (T :: l) := Module.of R (contexti l ⊗[R] typei cTi T.2 )\n\ndef contexti_append : Π (Γ₁ Γ₂ : context cT), \n  (contexti cTi (Γ₁ ++' Γ₂)) ≃ₗ[R] contexti cTi Γ₁ ⊗[R] contexti cTi Γ₂\n| Γ₁      [] := (tensor_product.rid R (contexti cTi Γ₁)).symm\n| Γ₁ (A::Γ₂) := (tensor_product.congr  \n    (contexti_append Γ₁ Γ₂) (linear_equiv.refl R (typei cTi A.2))).trans \n  (tensor_product.assoc R _ _ _)\n\nvariables {const_term : type cT → Type}\nvariables (const_termi : Π {T : type cT}, const_term T → typei cTi T)\n\ndef termi : Π {Γ : context cT} {A : type cT} (t : term const_term Γ A),\n  contexti cTi Γ →ₗ[R] typei cTi A\n| _ A (term.const t) := linear_map.to_span_singleton _ _ (const_termi t)\n| _ _ (term.var _ A) := (tensor_product.lid _ _).to_linear_map\n| _ T₂ (@term.app  _ _ Γ₁ Γ₂ T₁ _ f x) := \n  linear_map.comp (tensor_product.uncurry R (contexti cTi Γ₁) (contexti cTi Γ₂) _\n       (linear_map.comp (linear_map.lcomp R _ (termi x)) (termi f)))\n     (contexti_append _ Γ₁ Γ₂).to_linear_map\n| Γ (type.arrow _ T₂) (term.lambda a T₁ t) := tensor_product.curry (termi t)\n\nend\n\nvariables {M : Module.{0 0} R} (op : M →ₗ[R] M →ₗ[R] M)\n\nopen term\n\ndef const_term : type unit → Type\n| (type.arrow (type.const ()) (type.arrow (type.const ()) (type.const ()))) := unit\n| _ := empty\n\ndef cTi : unit → Module R := λ _, M\n\ninclude op\n\ndef const_termi {T : type unit} (t : const_term T) : typei (@cTi R _ M) T :=\nbegin\n  cases T with _ T₁ T₂; try { apply empty.elim t },\n  cases T₁ with _ T₂ T₃; try { apply empty.elim t },\n  cases T₁,\n  cases T₂ with _ T₁ T₂; try { apply empty.elim t },\n  cases T₁ with _ T₁ T₂; try { apply empty.elim t },\n  cases T₁,\n  cases T₂ with _ T₁ T₂; try { apply empty.elim t },\n  exact op\nend\n\nomit op\n\ndef mult : const_term (type.arrow (type.const ()) (type.arrow (type.const ()) (type.const ()))) := ()\n\nnotation `T` := type.const ()\n\ndef exmpl₁ : @term unit const_term [] \n  ((type.const ()).arrow ((type.const ()).arrow ((type.const ()).arrow (type.const ())))) :=\nlambda \"a\" T $ \nlambda \"b\" T $\nlambda \"c\" T $\n  app [(\"b\", T), (\"a\", T)] [(\"c\", T)] \n  (app [] [(\"b\", T), (\"a\", T)] (const mult) \n    (app [(\"a\", T)] [(\"b\", T)] \n      (app [] [(\"a\", T)] (const mult) (var \"a\" (type.const ()))) \n        (var \"b\" (type.const ()))) : _) \n    (var \"c\" (type.const ()))\n\nexample (p q r : M) : \n  termi (@cTi R _ M) (@const_termi _ _ _ op) exmpl₁ = sorry :=\nbegin\n  dunfold exmpl₁,\n  simp[termi, contexti],\n  dsimp [typei, contexti, contexti_append, cTi, const_termi],\n  ext,\n  simp,\n\nend\n\n\n", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/linear_lambda/monoidal_lambda.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4597669312872782}}
{"text": "/-\nCopyright (c) 2020 Alexander Bentkamp. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Alexander Bentkamp.\n-/\n\nimport ring_theory.principal_ideal_domain\nimport missing_mathlib.data.polynomial\nimport missing_mathlib.data.multiset\nimport missing_mathlib.data.finsupp\nimport missing_mathlib.linear_algebra.dimension\nimport missing_mathlib.linear_algebra.finite_dimensional\nimport missing_mathlib.linear_algebra.finsupp\nimport missing_mathlib.algebra.group.units\nimport missing_mathlib.algebra.ring\nimport missing_mathlib.algebra.module\nimport missing_mathlib.algebra.group_power\nimport missing_mathlib.data.list.basic\nimport missing_mathlib.set_theory.cardinal\nimport missing_mathlib.ring_theory.algebra\nimport missing_mathlib.ring_theory.polynomial.basic\nimport analysis.complex.polynomial\nimport missing_mathlib.field_thoery.algebraic_closure\n\n/-!\n# Eigenvectors and eigenvalues\n\nThis file defines eigenvectors and eigenvalues, as well as generalized\neigenvectors and eigenvalues.\n\nAn eigenvector of a linear map `f` is a nonzero vector `x` such that `f x = μ • x` \nfor some scalar `μ`. The scalar `μ` is called an eigenvalue. We express this\nby writing `eigenvector f μ x`.\n\nA generalized eigenvector of a linear map `f` is a nonzero vector `x` such that \n`(f x - μ • x) ^ k = 0` for some scalar `μ` and some natural number `k`. The \nscalar `μ` is called a generalized eigenvalue. We express this\nby writing `generalized_eigenvector f k μ x`.\n\nWe follow Axler's approach [axler1996] that allows us to prove a lot of\nproperties of eigenvectors without choosing a basis, without determinants and\nwithout matrices. We deviate from his definitions by defining 0 not to be an\neigenvector, which seems to be the more common convention.\n\n## Notations\n\nThe expression `algebra_map α (β →ₗ[α] β)` appears very often, which is why we\nuse `am` as a local notation for it.\n\n## References\n\n* [Sheldon Axler, *Down with determinants!*,\n  https://www.maa.org/sites/default/files/pdf/awards/Axler-Ford-1996.pdf][axler1996]\n* https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors\n\n## Tags\n\neigenvector, eigenvalues, eigen\n-/\n\nuniverses u v w\n\nopen vector_space principal_ideal_ring polynomial finite_dimensional\n\nvariables {α : Type v} {β : Type w} [decidable_eq β] [add_comm_group β]\n\n/-- An eigenvector of a linear map `f` with eigenvalue `μ` is a nonzero vector\n    `x` such that `f x = μ • x`. -/\ndef eigenvector [field α] [vector_space α β] \n  (f : β →ₗ[α] β) (μ : α) (x : β) : Prop := x ≠ 0 ∧ f x = μ • x\n\nlocal notation `am` := algebra_map α (β →ₗ[α] β)\n\n/-- Every linear operator on a vector space over an algebraically closed field has\n    an eigenvalue. (Axler's Theorem 2.1.) -/\nlemma exists_eigenvector \n  [field α] [is_alg_closed α] [decidable_eq α] [vector_space α β] [finite_dimensional α β]\n  (f : β →ₗ[α] β) (hex : ∃ v : β, v ≠ 0) : \n  ∃ (x : β) (c : α), eigenvector f c x :=\nbegin\n  obtain ⟨v, hv⟩ : ∃ v : β, v ≠ 0 := hex,\n  have h_lin_dep : ¬ linear_independent α (λ n : ℕ, (f ^ n) v),\n  { intro h_lin_indep, \n    have : cardinal.mk ℕ < cardinal.omega, \n      by apply (lt_omega_of_linear_independent h_lin_indep),\n    have := cardinal.lift_lt.2 this,\n    rw [cardinal.omega, cardinal.lift_lift] at this,\n    apply lt_irrefl _ this, },\n  haveI := classical.dec (∃ (x : polynomial α), ¬(polynomial.eval₂ am f x v = 0 → x = 0)),\n  obtain ⟨p, hp⟩ : ∃ p, ¬(eval₂ am f p v = 0 → p = 0),\n  { exact not_forall.1 (λ h, h_lin_dep ((linear_independent_iff_eval₂ f v).2 h)) },\n  obtain ⟨h_eval_p, h_p_ne_0⟩ : eval₂ am f p v = 0 ∧ p ≠ 0 := not_imp.1 hp,\n  obtain ⟨q, hq_mem, hq_noninj⟩ : ∃ q ∈ factors p, ¬function.injective ⇑(eval₂ am f q), \n  { exact polynomial.exists_noninjective_factor_of_eval₂_0 f v hv p h_p_ne_0 h_eval_p },\n  have h_q_ne_0 : q ≠ 0 := ne_0_of_mem_factors h_p_ne_0 hq_mem,\n  have h_deg_q : q.degree = 1 := is_alg_closed.degree_eq_one_of_irreducible _ h_q_ne_0 \n    ((factors_spec p h_p_ne_0).1 q hq_mem),\n  have h_q_eval₂ : polynomial.eval₂ am f q = q.leading_coeff • f + am (q.coeff 0),\n  { rw [polynomial.eq_X_add_C_of_degree_eq_one h_deg_q],\n    simp [eval₂_mul_noncomm am f _ _ (λ x y, ( algebra.commutes' x y).symm)],\n    simp [leading_coeff_X_add_C _ _ (λ h, h_q_ne_0 (leading_coeff_eq_zero.1 h))],\n    refl },\n  obtain ⟨x, hx₁, hx₂⟩ : ∃ (x : β), eval₂ am f q x = 0 ∧ ¬x = 0,\n  { rw [←linear_map.ker_eq_bot, linear_map.ker_eq_bot', classical.not_forall] at hq_noninj,\n    simpa only [not_imp] using hq_noninj },\n  have h_fx_x_lin_dep: leading_coeff q • f x + coeff q 0 • x = 0,\n  { rw h_q_eval₂ at hx₁,\n    exact hx₁ },\n  show ∃ (x : β) (c : α), x ≠ 0 ∧ f x = c • x,\n  { use x, \n    use -(coeff q 0 / q.leading_coeff),\n    refine ⟨hx₂, _⟩,\n    rw neg_smul,\n    have : (leading_coeff q)⁻¹ • leading_coeff q • f x = (leading_coeff q)⁻¹ • -(coeff q 0 • x) := \n      congr_arg (λ x, (leading_coeff q)⁻¹ • x) (add_eq_zero_iff_eq_neg.1 h_fx_x_lin_dep),\n    simpa [smul_smul, inv_mul_cancel (λ h, h_q_ne_0 (leading_coeff_eq_zero.1 h)), \n      mul_comm _ (coeff q 0), div_eq_mul_inv.symm] }\nend\n\n/-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are\n    linearly independent (Axler's Proposition 2.2) -/\nlemma eigenvectors_linear_independent [field α] [decidable_eq α] [vector_space α β] \n  (f : β →ₗ[α] β) (μs : set α) (xs : μs → β) (h_eigenvec : ∀ μ : μs, eigenvector f μ (xs μ)): \n  linear_independent α xs := \nbegin\n  rw linear_independent_iff,\n  intros l hl,\n  induction h_l_support : l.support using finset.induction with μ₀ l_support' hμ₀ ih generalizing l,\n  { exact finsupp.support_eq_empty.1 h_l_support },\n  { let l'_f := (λ μ : μs, (↑μ - ↑μ₀) * l μ),\n    have h_l_support' : ∀ (μ : μs), l'_f μ ≠ 0 ↔ μ ∈ l_support',\n    { intros μ,\n      dsimp only [l'_f],\n      rw [mul_ne_zero_iff, sub_ne_zero, ←not_iff_not, not_and_distrib, not_not, not_not, ←subtype.ext_iff],\n      split,\n      { intro h,\n        cases h,\n        { rwa h }, \n        { intro h_mem_l_support',\n          apply finsupp.mem_support_iff.1 _ h,\n          rw h_l_support,\n          apply finset.subset_insert _ _ h_mem_l_support' } },\n      { intro h, \n        apply (@or_iff_not_imp_right _ _ (classical.dec _)).2,\n        intro hlμ,\n        have := finsupp.mem_support_iff.2 hlμ,\n        rw [h_l_support, finset.mem_insert] at this,\n        cc } },\n    let l' : μs →₀ α := finsupp.on_finset l_support' l'_f (λ μ, (h_l_support' μ).1),\n    have total_l' : (@linear_map.to_fun α (finsupp μs α) β _ _ _ _ _ (finsupp.total μs β α xs)) l' = 0,\n    { let g := f - am μ₀, \n      have h_gμ₀: g (l μ₀ • xs μ₀) = 0, \n        by rw [linear_map.map_smul, linear_map.sub_apply, (h_eigenvec _).2, module.endomorphism_algebra_map_apply2, sub_self, smul_zero],\n      have h_useless_filter : finset.filter (λ (a : μs), l'_f a ≠ 0) l_support' = l_support',\n      { convert @finset.filter_congr _ _ _ (classical.dec_pred _) (classical.dec_pred _) _ _,\n        { apply finset.filter_true.symm },\n        exact λ μ hμ, iff_of_true ((h_l_support' μ).2 hμ) true.intro },\n      have bodies_eq : ∀ (μ : μs), l'_f μ • xs μ = g (l μ • xs μ), \n      { intro μ,\n        dsimp only [g, l'_f],\n        rw [linear_map.map_smul, linear_map.sub_apply, (h_eigenvec _).2, module.endomorphism_algebra_map_apply2, ←sub_smul, smul_smul, mul_comm] },\n      have := finsupp.total_on_finset l_support' l'_f xs _,\n      unfold_coes at this,\n      rw [this, ←linear_map.map_zero g,\n          ←congr_arg g hl, finsupp.total_apply, finsupp.sum, linear_map.map_sum, h_l_support,\n          finset.sum_insert hμ₀, h_gμ₀, zero_add, h_useless_filter],\n      simp only [bodies_eq] },\n    have h_l'_support_eq : l'.support = l_support',\n    { dsimp only [l'],\n      ext μ,\n      rw finsupp.on_finset_mem_support l_support' l'_f _ μ,\n      by_cases h_cases: μ ∈ l_support',\n      { refine iff_of_true _ h_cases,\n        exact (h_l_support' μ).2 h_cases },\n      { refine iff_of_false _ h_cases,\n        rwa not_iff_not.2 (h_l_support' μ) } },\n    have l'_eq_0 : l' = 0 := ih l' total_l' h_l'_support_eq,\n    \n    have h_mul_eq_0 : ∀ μ : μs, (↑μ - ↑μ₀) * l μ = 0,\n    { intro μ,\n      calc (↑μ - ↑μ₀) * l μ = l' μ : rfl\n      ... = 0 : by { rw [l'_eq_0], refl } },\n\n    have h_lμ_eq_0 : ∀ μ : μs, μ ≠ μ₀ → l μ = 0,\n    { intros μ hμ,\n      apply classical.or_iff_not_imp_left.1 (mul_eq_zero.1 (h_mul_eq_0 μ)),\n      rwa [sub_eq_zero, ←subtype.ext_iff] },\n\n    have h_sum_l_support'_eq_0 : finset.sum l_support' (λ (μ : ↥μs), l μ • xs μ) = 0,\n    { rw ←finset.sum_const_zero,\n      apply finset.sum_congr rfl,\n      intros μ hμ,\n      rw h_lμ_eq_0,\n      apply zero_smul,\n      intro h,\n      rw h at hμ,\n      contradiction },\n\n    have : l μ₀ = 0,\n    { rw [finsupp.total_apply, finsupp.sum, h_l_support, \n          finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl,\n      by_contra h,\n      exact (h_eigenvec μ₀).1 ((vector_space.smul_neq_zero (xs μ₀) h).1 hl) },\n\n    show l = 0,\n    { ext μ,\n      by_cases h_cases : μ = μ₀,\n      { rw h_cases, \n        assumption },\n      exact h_lμ_eq_0 μ h_cases } }\nend\n\n/-- A generalized eigenvector (also called eventual eigenvector) of a linear map\n    $f$ is a nonzero vector $x$ such that $(f - \\mu I) ^ k) x = 0$ for some\n    scalar $\\mu$ and some natural number $k$ (where $I$ is the identity map). \n\n    We deviate from Axler's definition by requiring that $x$ is nonzero, which\n    implies that $k$ is nonzero, too. -/\ndef generalized_eigenvector [field α] [vector_space α β] \n  (f : β →ₗ[α] β) (k : ℕ) (μ : α) (x : β) : Prop := x ≠ 0 ∧ ((f - am μ) ^ k) x = 0\n\n/-- The natural number of a generalized eigenvector is never 0. -/\nlemma exp_ne_zero_of_generalized_eigenvector_ne_zero [field α] [vector_space α β] \n  {f : β →ₗ[α] β} {k : ℕ} {μ : α} {x : β} (h : generalized_eigenvector f k μ x) : \n  k ≠ 0 :=\nbegin\n  rcases h with ⟨h_nz, h⟩,\n  contrapose h_nz,\n  rw not_not at h_nz ⊢,\n  rwa [h_nz, pow_zero] at h\nend\n\n/-- A generalized eigenvector for some number `k` is also a generalized\n    eigenvector for number larger than `k`. -/\nlemma generalized_eigenvector_zero_beyond [field α] [vector_space α β] \n  {f : β →ₗ[α] β} {k : ℕ} {μ : α} {x : β} (h : generalized_eigenvector f k μ x) :\n  ∀ m : ℕ, k ≤ m → generalized_eigenvector f m μ x :=\nbegin\n  intros m hm,\n  refine ⟨h.1, _⟩,\n  rw ←pow_eq_pow_sub_mul _ hm,\n  change ((f - am μ) ^ (m - k)) (((f - am μ) ^ k) x) = 0,\n  unfold generalized_eigenvector at h,\n  rw [h.2, linear_map.map_zero]\nend\n\n/-- All eigenvectors are generalized eigenvectors. -/\nlemma generalized_eigenvector_of_eigenvector [field α] [vector_space α β] \n  {f : β →ₗ[α] β} {k : ℕ} {μ : α} {x : β} (hx : eigenvector f μ x) (hk : k > 0) :\n  generalized_eigenvector f k μ x :=\nbegin\n  rw [generalized_eigenvector, ←nat.succ_pred_eq_of_pos hk, pow_succ'],\n  change x ≠ 0 ∧ ((f - am μ) ^ nat.pred k) ((f - am μ) x) = 0,\n  have : (f - am μ) x = 0 := by simp [hx.2, module.endomorphism_algebra_map_apply2],\n  simp [this, hx.1]\nend\n\n/-- The set of generalized eigenvectors of f corresponding to an eigenvalue μ\n    equals the kernel of (f - am μ) ^ n, where n is the dimension of \n    the vector space (Axler's Lemma 3.1). -/\nlemma generalized_eigenvector_dim \n  [field α] [decidable_eq α] [vector_space α β] [finite_dimensional α β]\n  (f : β →ₗ[α] β) (μ : α) (x : β) : \n  (∃ k : ℕ, generalized_eigenvector f k μ x) \n    ↔ generalized_eigenvector f (findim α β) μ x :=\nbegin\n  split,\n  { show (∃ (k : ℕ), generalized_eigenvector f k μ x) → x ≠ 0 ∧ ((f - am μ) ^ findim α β) x = 0,\n    intro h_exists_eigenvec,\n    let k := @nat.find (λ k : ℕ, generalized_eigenvector f k μ x) (classical.dec_pred _) h_exists_eigenvec,\n    let z := (λ i : fin k, ((f - am μ) ^ (i : ℕ)) x),\n\n    have h_x_nz : x ≠ 0, \n    { rcases h_exists_eigenvec with ⟨k, h⟩,\n      exact h.1 },\n\n    have h_lin_indep : linear_independent α z,\n    { rw linear_independent_iff,\n      intros l hl,\n      ext i,\n      induction h_i_val : i.val using nat.strong_induction_on with i_val ih generalizing i,\n      simp only [h_i_val.symm] at *,\n      clear h_i_val i_val,\n\n      have h_zero_of_lt : ∀ j, j < i → ((f - am μ) ^ (k - i.val - 1)) (l j • z j) = 0,\n      { intros j hj,\n        simp [ih j hj j rfl] }, \n\n      have h_zero_beyond_k : ∀ m, k ≤ m → ((f - am μ) ^ m) x = 0,\n      { intros m hm,\n        apply (generalized_eigenvector_zero_beyond \n            (@nat.find_spec (λ k : ℕ, generalized_eigenvector f k μ x) (classical.dec_pred _) h_exists_eigenvec) _ hm).2 },\n\n      have h_zero_of_gt : ∀ j, j > i → ((f - am μ) ^ (k - i.val - 1)) (l j • z j) = 0,\n      { intros j hj,\n        dsimp only [z],\n        rw [linear_map.map_smul],\n        change l j • ((f - am μ) ^ (k - i.val - 1) * ((f - am μ) ^ ↑j)) x = 0,\n        rw [←pow_add, h_zero_beyond_k, smul_zero],\n        rw [nat.sub_sub, ←nat.sub_add_comm (nat.succ_le_of_lt i.2)],\n        apply nat.le_sub_right_of_add_le,\n        apply nat.add_le_add_left,\n        rw ←nat.lt_iff_add_one_le,\n        unfold_coes,\n        change i.val < (j : ℕ),\n        exact hj }, \n\n      have h_zero_of_ne : ∀ j, j ≠ i → ((f - am μ) ^ (k - i.val - 1)) (l j • z j) = 0,\n      { intros j hj,\n        cases lt_or_gt_of_ne hj with h_lt h_gt,\n        apply h_zero_of_lt j h_lt,\n        apply h_zero_of_gt j h_gt }, \n\n      have h_zero_of_not_support : i ∉ l.support → ((f - am μ) ^ (k - i.val - 1)) (l i • z i) = 0,\n      { intros hi,\n        rw [finsupp.mem_support_iff, not_not] at hi,\n        rw [hi, zero_smul, linear_map.map_zero] },\n\n      have h_l_smul_pow_k_sub_1 : l i • (((f - am μ) ^ (k - 1)) x) = 0,\n      { have h_k_sub_1 : k - i.val - 1 + i.val = k - 1,\n        { rw ←nat.sub_add_comm,\n          { rw nat.sub_add_cancel,\n            apply le_of_lt i.2 },\n          { apply nat.le_sub_left_of_add_le,\n            apply nat.succ_le_of_lt i.2 } },\n        rw [←h_k_sub_1, pow_add],\n        let g := (f - am μ) ^ (k - i.val - 1),\n        rw [finsupp.total_apply, finsupp.sum] at hl,\n        have := congr_arg g hl,\n        rw [linear_map.map_sum, linear_map.map_zero g] at this,\n        dsimp only [g] at this,\n        rw finset.sum_eq_single i (λ j _, h_zero_of_ne j) h_zero_of_not_support at this,\n        simp only [linear_map.map_smul, z] at this,\n        apply this },\n\n      have h_pow_k_sub_1 : ((f - am μ) ^ (k - 1)) x ≠ 0 :=\n        not_and.1 (@nat.find_min (λ k : ℕ, generalized_eigenvector f k μ x) (classical.dec_pred _) h_exists_eigenvec _\n            (nat.sub_lt (nat.lt_of_le_of_lt (nat.zero_le _) i.2) nat.zero_lt_one)) h_x_nz,\n\n      show l i = 0,\n      { contrapose h_pow_k_sub_1 with h_li_ne_0,\n        rw not_not,\n        apply (vector_space.smul_neq_zero _ h_li_ne_0).1, \n        apply h_l_smul_pow_k_sub_1 } },\n\n    show x ≠ 0 ∧ ((f - am μ) ^ findim α β) x = 0,\n    { split,\n      { exact h_x_nz },\n      apply (generalized_eigenvector_zero_beyond \n        (@nat.find_spec (λ k : ℕ, generalized_eigenvector f k μ x) (classical.dec_pred _) h_exists_eigenvec) _ _).2,\n      rw [←cardinal.nat_cast_le, ←cardinal.lift_mk_fin _, ←cardinal.lift_le, cardinal.lift_lift],\n      rw findim_eq_dim,\n      apply h_lin_indep.le_lift_dim} },\n\n  { show generalized_eigenvector f (findim α β) μ x → (∃ (k : ℕ), generalized_eigenvector f k μ x),\n    exact λh, ⟨_, h⟩, }\nend\n\nlemma generalized_eigenvector_restrict_aux [field α] [vector_space α β] \n  (f : β →ₗ[α] β) (p : submodule α β) (k : ℕ) (μ : α) (x : p) \n  (hfp : ∀ (x : β), x ∈ p → f x ∈ p) : \n  (((f.restrict p p hfp - algebra_map _ _ μ) ^ k) x : β) \n  = ((f - algebra_map _ _ μ) ^ k) x :=\nbegin\n  induction k with k ih,\n  { rw [pow_zero, pow_zero, linear_map.one_app, linear_map.one_app] },\n  { rw [pow_succ, pow_succ], \n    change ((f.restrict p p hfp - algebra_map _ _ μ) (((f.restrict p p hfp - algebra_map _ _ μ) ^ k) x) : β) =\n        (f - algebra_map _ _ μ) (((f - algebra_map _ _ μ) ^ k) x),\n    rw [linear_map.sub_apply, linear_map.sub_apply, linear_map.restrict_apply, ←ih], \n    refl }\nend\n\n/-- If `f` maps a subspace `p` into itself, then the generalized eigenvectors of\n    `f` restricted to `p` are the generalized eigenvectors of `f` that lie in\n    `p`.\n-/\nlemma generalized_eigenvector_restrict [field α] [vector_space α β] \n  (f : β →ₗ[α] β) (p : submodule α β) (k : ℕ) (μ : α) (x : p) (hfp : ∀ (x : β), x ∈ p → f x ∈ p) : \n  generalized_eigenvector (linear_map.restrict f p p hfp) k μ x \n    ↔ generalized_eigenvector f k μ x :=\nbegin \n  rw [generalized_eigenvector, subtype.ext_iff,  generalized_eigenvector_restrict_aux], \n  simp [generalized_eigenvector]\nend\n\n/-- If a vector is a generalized eigenvector for some number `k`, then it is\n    also a generalized eigenvector for the dimension of the vector space. -/\nlemma generalized_eigenvector_dim_of_any\n  [field α] [decidable_eq α] [vector_space α β] [finite_dimensional α β]\n  {f : β →ₗ[α] β} {μ : α}\n  {k : ℕ} {x : β} (h : generalized_eigenvector f k μ x) :\n  generalized_eigenvector f (findim α β) μ x :=\nbegin\n  rw ←generalized_eigenvector_dim,\n  { exact ⟨k, h⟩ }\nend\n\n/-- Kernel and range of $(f - \\mu I) ^ n$ are disjoint, where $f$ is a linear\n    map, $\\mu$ is a scalar, $I$ is the identity matrix, and $n$ is the dimension of\n    the vector space. -/\nlemma generalized_eigenvec_disjoint_range_ker\n  [field α] [decidable_eq α] [vector_space α β] [finite_dimensional α β]\n  (f : β →ₗ[α] β) (μ : α) : \n  disjoint ((f - am μ) ^ findim α β).range ((f - am μ) ^ findim α β).ker :=\nbegin\n  rintros v ⟨⟨u, _, hu⟩, hv⟩,\n  have h2n : ((f - am μ) ^ (findim α β + findim α β)) u = 0,\n  { rw [pow_add, ←linear_map.mem_ker.1 hv, ←hu], refl },\n  have hn : ((f - am μ) ^ findim α β) u = 0, \n  { by_cases h_cases: u = 0, \n    { simp [h_cases] },\n    { apply (generalized_eigenvector_dim_of_any ⟨h_cases, h2n⟩).2 } },\n  have hv0 : v = 0, by rw [←hn, hu],\n  show v ∈ ↑⊥, by simp [hv0]\nend\n\n/-- The kernel of $(f - \\mu I) ^ k$ for $k > 0$ has positive dimension if $\\mu$\n    is an eigenvalue. -/\nlemma pos_dim_eigenker_of_eigenvec [field α] [is_alg_closed α] [vector_space α β] \n  {f : β →ₗ[α] β} {n : ℕ} {μ : α} {x : β} (hx : eigenvector f μ x) : \n  0 < dim α ((f - am μ) ^ n.succ).ker :=\nbegin\n  have x_mem : x ∈ ((f - am μ) ^ n.succ).ker,\n  { simp [pow_succ', hx.2, module.endomorphism_algebra_map_apply2] },\n  apply dim_pos_of_mem_ne_zero (⟨x, x_mem⟩ : ((f - am μ) ^ n.succ).ker),\n  intros h,\n  apply hx.1,\n  exact congr_arg subtype.val h,\nend\n\n/-- Variant of `pos_dim_eigenker_of_eigenvec` for finite dimensional vector spaces. -/\nlemma pos_findim_eigenker_of_eigenvec \n  [field α] [is_alg_closed α] [vector_space α β] [finite_dimensional α β]\n  {f : β →ₗ[α] β} {n : ℕ} {μ : α} {x : β} (hx : eigenvector f μ x) : \n  0 < findim α ((f - am μ) ^ n.succ).ker :=\nbegin\n  apply cardinal.nat_cast_lt.1,\n  rw findim_eq_dim,\n  apply pos_dim_eigenker_of_eigenvec hx,\nend\n\n/-- The kernel of $(f - \\mu I) ^ k$ is contained in the span of all generalized eigenvectors. -/\nlemma eigenker_le_span_gen_eigenvec [field α] [vector_space α β] \n  (f : β →ₗ[α] β) (μ₀ : α) (n : ℕ) :\n((f - am μ₀) ^ n).ker \n  ≤ submodule.span α ({x : β | ∃ (k : ℕ) (μ : α), generalized_eigenvector f k μ x}) :=\nbegin\n  intros x hx,\n  by_cases h_cases: x = 0,\n  { simp [h_cases] },\n  { apply submodule.subset_span,\n    exact ⟨n, μ₀, h_cases, linear_map.mem_ker.1 hx⟩ }\nend\n\n/-- If $x$ is in the range of $(f - \\mu I) ^ k$, then so is $f(x)$. -/\nlemma image_mem_eigenrange_of_mem_eigenrange [field α] [vector_space α β] \n  {f : β →ₗ[α] β} {μ : α} {x : β} {n : ℕ}\n  (hx : x ∈ ((f - am μ) ^ n).range) : \n  f x ∈ ((f - am μ) ^ n).range :=\nbegin\n  rw linear_map.mem_range at *,\n  rcases hx with ⟨w, hw⟩,\n  use f w,\n  have hcommutes : f.comp ((f - am μ) ^ n) = ((f - am μ) ^ n).comp f := \n    algebra.mul_sub_algebra_map_pow_commutes f μ n,\n  rw [←linear_map.comp_apply, ←hcommutes, linear_map.comp_apply, hw],\nend\n\n/-- The generalized eigenvectors of f span the vectorspace β. (Axler's Proposition 3.4). -/\nlemma generalized_eigenvector_span \n  [field α] [is_alg_closed α] [decidable_eq α] [vector_space α β] [finite_dimensional α β]\n  (f : β →ₗ[α] β) : \n  submodule.span α {x | ∃ k μ, generalized_eigenvector f k μ x} = ⊤ :=\nbegin\n  rw ←top_le_iff,\n  tactic.unfreeze_local_instances,\n  induction h_dim : findim α β using nat.strong_induction_on with n ih generalizing β,\n  cases n,\n  { have h_findim_top: findim α (⊤ : submodule α β) = 0 := eq.trans (@finite_dimensional.findim_top α β _ _ _ _) h_dim,\n    have h_top_eq_bot : (⊤ : submodule α β) = ⊥ := bot_of_findim_zero _ h_findim_top,\n    simp only [h_top_eq_bot, bot_le] },\n  { have h_dim_pos : 0 < findim α β,\n    { rw [h_dim],\n      apply nat.zero_lt_succ },\n    obtain ⟨x, μ₀, hx_ne_0, hμ₀⟩ : ∃ (x : β) (μ₀ : α), x ≠ 0 ∧ f x = μ₀ • x,\n    { apply exists_eigenvector f \n        (exists_mem_ne_zero_of_findim_pos h_dim_pos) },\n    let V₁ := ((f - am μ₀) ^ n.succ).ker,\n    let V₂ := ((f - am μ₀) ^ n.succ).range,\n    have h_disjoint : disjoint V₂ V₁,\n    { simp only [V₁, V₂, h_dim.symm],\n      exact generalized_eigenvec_disjoint_range_ker f μ₀ },\n    have h_dim_add : findim α V₂ + findim α V₁ = findim α β,\n    { apply linear_map.findim_range_add_findim_ker },\n    have h_dim_V₁_pos : 0 < findim α V₁,\n    { apply pos_findim_eigenker_of_eigenvec ⟨hx_ne_0, hμ₀⟩ },\n    have h_findim_V₂ : findim α V₂ < n.succ := by linarith,\n    have h_f_V₂ : ∀ (x : β), x ∈ V₂ → f x ∈ V₂, \n    { intros x hx, \n      apply image_mem_eigenrange_of_mem_eigenrange hx, },\n    have hV₂ : V₂ ≤ submodule.span α ({x : β | ∃ (k : ℕ) (μ : α), generalized_eigenvector f k μ x}),\n    { have : V₂ ≤ submodule.span α ({x : β | ∃ (k : ℕ) (μ : α), generalized_eigenvector f k μ x} ∩ V₂),\n      { rw ←subtype.image_preimage_val,\n        rw ←submodule.subtype_eq_val V₂,\n        rw submodule.span_image (submodule.subtype V₂),\n        rw set.preimage_set_of_eq,\n        rw submodule.subtype_eq_val,\n        have h₀ : ∀ p, submodule.map (submodule.subtype V₂) ⊤ \n              ≤ submodule.map (submodule.subtype V₂) p \n              ↔ ⊤ ≤ p\n            := λ _, (linear_map.map_le_map_iff' (submodule.ker_subtype V₂)),\n        have := submodule.range_subtype V₂,\n        unfold linear_map.range at this,\n        rw this at h₀,\n        rw h₀,\n        have := ih (findim α V₂) h_findim_V₂ (f.restrict V₂ V₂ h_f_V₂) rfl,\n        simp only [generalized_eigenvector_restrict] at this,\n        apply this },\n      refine le_trans this _,\n      apply submodule.span_mono,\n      apply set.inter_subset_left },\n    have hV₁ : V₁ ≤ submodule.span α ({x : β | ∃ (k : ℕ) (μ : α), generalized_eigenvector f k μ x}),\n    { apply eigenker_le_span_gen_eigenvec },\n    show ⊤ ≤ submodule.span α {x : β | ∃ (k : ℕ) (μ : α), generalized_eigenvector f k μ x},\n    { rw ←finite_dimensional.eq_top_of_disjoint V₂ V₁ h_dim_add h_disjoint,\n      apply sup_le hV₂ hV₁ } }\nend\n\n", "meta": {"author": "abentkamp", "repo": "spectral", "sha": "751645679ef1cb6266316349de9e492eff85484c", "save_path": "github-repos/lean/abentkamp-spectral", "path": "github-repos/lean/abentkamp-spectral/spectral-751645679ef1cb6266316349de9e492eff85484c/src/eigenvector.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.45976693128727814}}
{"text": "/-\nCopyright (c) 2019 Bruno Bentzen. All rights reserved.\nReleased under the Apache License 2.0 (see \"License\");\nAuthor: Bruno Bentzen\n-/\n\nimport ...core.path\n\nopen interval path \n\n-- non-dependent inversion and composition of lines\n\nnamespace path\n\ndef refl {A : Type} (a : A) : path A a a :=\npath.abs (λ _, a) rfl rfl \n\ndef inv.filler {A : Type} {a b : A} (kan : has_hcom A) :\n  path A a b → I → I → A :=\nbegin\n  intro p, induction p with p _ _ p0 p1,\n  unfold eq.mp at *; simp at *,\n  apply (hcom (λ _, p i0) [[ p ; (λ _, p i0) ]] kan),\nend\n\ndef inv {A : Type} {a b : A} (kan : has_hcom A) :\n  path A a b → path A b a :=\nbegin\n  intro p, fapply pathdp.abs,\n  { exact inv.filler kan p i1 },\n  repeat { reflexivity }, \n  induction p, transitivity, apply kan.eq0, assumption, \n  induction p, transitivity, apply kan.eq1, assumption, \nend\n\ndef comp.filler {A : Type} {a b c : A} (kan : has_hcom A) :\n  path A a b → path A b c → I → I → A :=\nbegin\n  intros p q,\n  induction p with p _ _ p0 p1,\n  induction q with q _ _ q0 q1,\n  induction q0,\n  exact (kan.hcom (horn1.mk p (λ _, p i0) q rfl p1)),\nend\n\ndef comp {A : Type} {a b c : A} (kan : has_hcom A) :\n  path A a b → path A b c → path A a c :=\nbegin\n  intro p, induction p with p _ _ p0 p1,\n  unfold eq.mp at *; simp at *,\n  rw p0.symm, rw p1.symm,\n  intro q, induction q with q _ _ q0 q1,\n  unfold eq.mp at *; simp at *,\n  rw q1.symm,\n  fapply pathdp.abs,\n  { apply (kan.hcom (horn1.mk p (λ _, p i0) q rfl q0.symm)) i1 },\n  repeat { reflexivity },\n  { transitivity, apply kan.eq0, unfold eq.mp; simp },\n  { transitivity, apply kan.eq1, unfold eq.mp; simp }, \nend\n\nend path\n\nnamespace refl\n\nlemma eq {A : Type} {a : A} {p : I → A} (h : p = λ _, a ) {h0 : p i0 = a } {h1 : p i1 = a} : \n  path.refl a = abs p h0 h1 :=\nby cases h; refl\n\nend refl ", "meta": {"author": "bbentzen", "repo": "cubicalean", "sha": "3b94cd2aefdfc2163c263bd3fc6f2086fef814b5", "save_path": "github-repos/lean/bbentzen-cubicalean", "path": "github-repos/lean/bbentzen-cubicalean/cubicalean-3b94cd2aefdfc2163c263bd3fc6f2086fef814b5/src/path/groupoid/ops.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125626441471, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.45976692449136997}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.big_operators.basic\nimport algebra.big_operators.pi\nimport category_theory.limits.shapes.biproducts\nimport category_theory.preadditive\nimport category_theory.preadditive.additive_functor\nimport data.matrix.dmatrix\nimport data.matrix.basic\nimport category_theory.Fintype\nimport category_theory.preadditive.single_obj\nimport algebra.opposites\n\n/-!\n# Matrices over a category.\n\nWhen `C` is a preadditive category, `Mat_ C` is the preadditive category\nwhose objects are finite tuples of objects in `C`, and\nwhose morphisms are matrices of morphisms from `C`.\n\nThere is a functor `Mat_.embedding : C ⥤ Mat_ C` sending morphisms to one-by-one matrices.\n\n`Mat_ C` has finite biproducts.\n\n## The additive envelope\n\nWe show that this construction is the \"additive envelope\" of `C`,\nin the sense that any additive functor `F : C ⥤ D` to a category `D` with biproducts\nlifts to a functor `Mat_.lift F : Mat_ C ⥤ D`,\nMoreover, this functor is unique (up to natural isomorphisms) amongst functors `L : Mat_ C ⥤ D`\nsuch that `embedding C ⋙ L ≅ F`.\n(As we don't have 2-category theory, we can't explicitly state that `Mat_ C` is\nthe initial object in the 2-category of categories under `C` which have biproducts.)\n\nAs a consequence, when `C` already has finite biproducts we have `Mat_ C ≌ C`.\n\n## Future work\n\nWe should provide a more convenient `Mat R`, when `R` is a ring,\nas a category with objects `n : FinType`,\nand whose morphisms are matrices with components in `R`.\n\nIdeally this would conveniently interact with both `Mat_` and `matrix`.\n\n-/\n\nopen category_theory category_theory.preadditive\nopen_locale big_operators\nnoncomputable theory\n\nnamespace category_theory\n\nuniverses w v₁ v₂ u₁ u₂\nvariables (C : Type u₁) [category.{v₁} C] [preadditive C]\n\n/--\nAn object in `Mat_ C` is a finite tuple of objects in `C`.\n-/\nstructure Mat_ : Type (max (v₁+1) u₁) :=\n(ι : Type v₁)\n[F : fintype ι]\n[D : decidable_eq ι]\n(X : ι → C)\n\nattribute [instance] Mat_.F Mat_.D\n\nnamespace Mat_\n\nvariables {C}\n\n/-- A morphism in `Mat_ C` is a dependently typed matrix of morphisms. -/\n@[nolint has_inhabited_instance]\ndef hom (M N : Mat_ C) : Type v₁ := dmatrix M.ι N.ι (λ i j, M.X i ⟶ N.X j)\n\nnamespace hom\n\n/-- The identity matrix consists of identity morphisms on the diagonal, and zeros elsewhere. -/\ndef id (M : Mat_ C) : hom M M := λ i j, if h : i = j then eq_to_hom (congr_arg M.X h) else 0\n\n/-- Composition of matrices using matrix multiplication. -/\ndef comp {M N K : Mat_ C} (f : hom M N) (g : hom N K) : hom M K :=\nλ i k, ∑ j : N.ι, f i j ≫ g j k\n\nend hom\n\nsection\nlocal attribute [simp] hom.id hom.comp\n\ninstance : category.{v₁} (Mat_ C) :=\n{ hom := hom,\n  id := hom.id,\n  comp := λ M N K f g, f.comp g,\n  id_comp' := λ M N f, by simp [dite_comp],\n  comp_id' := λ M N f, by simp [comp_dite],\n  assoc' := λ M N K L f g h, begin\n    ext i k,\n    simp_rw [hom.comp, sum_comp, comp_sum, category.assoc],\n    rw finset.sum_comm,\n  end, }.\n\nlemma id_def (M : Mat_ C) :\n  (𝟙 M : hom M M) = λ i j, if h : i = j then eq_to_hom (congr_arg M.X h) else 0 :=\nrfl\n\nlemma id_apply (M : Mat_ C) (i j : M.ι) :\n  (𝟙 M : hom M M) i j = if h : i = j then eq_to_hom (congr_arg M.X h) else 0 :=\nrfl\n\n@[simp] lemma id_apply_self (M : Mat_ C) (i : M.ι) :\n  (𝟙 M : hom M M) i i = 𝟙 _ :=\nby simp [id_apply]\n\n@[simp] lemma id_apply_of_ne (M : Mat_ C) (i j : M.ι) (h : i ≠ j) :\n  (𝟙 M : hom M M) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat_ C} (f : M ⟶ N) (g : N ⟶ K) :\n  (f ≫ g) = λ i k, ∑ j : N.ι, f i j ≫ g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat_ C} (f : M ⟶ N) (g : N ⟶ K) (i k) :\n  (f ≫ g) i k = ∑ j : N.ι, f i j ≫ g j k := rfl\n\ninstance (M N : Mat_ C) : inhabited (M ⟶ N) := ⟨λ i j, (0 : M.X i ⟶ N.X j)⟩\n\nend\n\ninstance : preadditive (Mat_ C) :=\n{ hom_group := λ M N, by { change add_comm_group (dmatrix M.ι N.ι _), apply_instance, },\n  add_comp' := λ M N K f f' g, by { ext, simp [finset.sum_add_distrib], },\n  comp_add' := λ M N K f g g', by { ext, simp [finset.sum_add_distrib], }, }\n\n@[simp] lemma add_apply {M N : Mat_ C} (f g : M ⟶ N) (i j) : (f + g) i j = f i j + g i j := rfl\n\nopen category_theory.limits\n\n/--\nWe now prove that `Mat_ C` has finite biproducts.\n\nBe warned, however, that `Mat_ C` is not necessarily Krull-Schmidt,\nand so the internal indexing of a biproduct may have nothing to do with the external indexing,\neven though the construction we give uses a sigma type.\nSee however `iso_biproduct_embedding`.\n-/\ninstance has_finite_biproducts : has_finite_biproducts (Mat_ C) :=\n{ has_biproducts_of_shape := λ J 𝒟 ℱ, by exactI\n  { has_biproduct := λ f,\n    has_biproduct_of_total\n    { X := ⟨Σ j : J, (f j).ι, λ p, (f p.1).X p.2⟩,\n      π := λ j x y,\n      begin\n        dsimp at x ⊢,\n        refine if h : x.1 = j then _ else 0,\n        refine if h' : (@eq.rec J x.1 (λ j, (f j).ι) x.2 _ h) = y then _ else 0,\n        apply eq_to_hom,\n        substs h h', -- Notice we were careful not to use `subst` until we had a goal in `Prop`.\n      end,\n      ι := λ j x y,\n      begin\n        dsimp at y ⊢,\n        refine if h : y.1 = j then _ else 0,\n        refine if h' : (@eq.rec J y.1 (λ j, (f j).ι) y.2 _ h) = x then _ else 0,\n        apply eq_to_hom,\n        substs h h',\n      end,\n      ι_π := λ j j',\n      begin\n        ext x y,\n        dsimp,\n        simp_rw [dite_comp, comp_dite],\n        simp only [if_t_t, dite_eq_ite, dif_ctx_congr, limits.comp_zero, limits.zero_comp,\n          eq_to_hom_trans, finset.sum_congr],\n        erw finset.sum_sigma,\n        dsimp,\n        simp only [if_congr, if_true, dif_ctx_congr, finset.sum_dite_irrel, finset.mem_univ,\n          finset.sum_const_zero, finset.sum_congr, finset.sum_dite_eq'],\n        split_ifs with h h',\n        { substs h h',\n          simp only [category_theory.eq_to_hom_refl, category_theory.Mat_.id_apply_self], },\n        { subst h,\n          simp only [id_apply_of_ne _ _ _ h', category_theory.eq_to_hom_refl], },\n        { refl, },\n      end, }\n    begin\n      dsimp,\n      funext i₁,\n      dsimp at i₁ ⊢,\n      rcases i₁ with ⟨j₁, i₁⟩,\n      -- I'm not sure why we can't just `simp` by `finset.sum_apply`: something doesn't quite match\n      convert finset.sum_apply _ _ _ using 1,\n      { refl, },\n      { apply heq_of_eq,\n        symmetry,\n        funext i₂,\n        rcases i₂ with ⟨j₂, i₂⟩,\n        simp only [comp_apply, dite_comp, comp_dite,\n          if_t_t, dite_eq_ite, if_congr, if_true, dif_ctx_congr,\n          finset.sum_dite_irrel, finset.sum_dite_eq, finset.mem_univ, finset.sum_const_zero,\n          finset.sum_congr, finset.sum_dite_eq, finset.sum_apply,\n          limits.comp_zero, limits.zero_comp, eq_to_hom_trans, Mat_.id_apply],\n        by_cases h : j₁ = j₂,\n        { subst h, simp, },\n        { simp [h], }, },\n    end }}.\n\nend Mat_\n\nnamespace functor\nvariables {C} {D : Type*} [category.{v₁} D] [preadditive D]\n\nlocal attribute [simp] Mat_.id_apply\n\n/--\nA functor induces a functor of matrix categories.\n-/\n@[simps]\ndef map_Mat_ (F : C ⥤ D) [functor.additive F] : Mat_ C ⥤ Mat_ D :=\n{ obj := λ M, ⟨M.ι, λ i, F.obj (M.X i)⟩,\n  map := λ M N f i j, F.map (f i j),\n  map_comp' := λ M N K f g, by { ext i k, simp,}, }\n\n/--\nThe identity functor induces the identity functor on matrix categories.\n-/\n@[simps]\ndef map_Mat_id : (𝟭 C).map_Mat_ ≅ 𝟭 (Mat_ C) :=\nnat_iso.of_components (λ M, eq_to_iso (by { cases M, refl, }))\n(λ M N f, begin\n  ext i j,\n  cases M, cases N,\n  simp [comp_dite, dite_comp],\nend)\n\n/--\nComposite functors induce composite functors on matrix categories.\n-/\n@[simps]\ndef map_Mat_comp {E : Type*} [category.{v₁} E] [preadditive E]\n  (F : C ⥤ D) [functor.additive F] (G : D ⥤ E) [functor.additive G] :\n  (F ⋙ G).map_Mat_ ≅ F.map_Mat_ ⋙ G.map_Mat_ :=\nnat_iso.of_components (λ M, eq_to_iso (by { cases M, refl, }))\n(λ M N f, begin\n  ext i j,\n  cases M, cases N,\n  simp [comp_dite, dite_comp],\nend)\n\nend functor\n\nnamespace Mat_\n\nvariables (C)\n\n/-- The embedding of `C` into `Mat_ C` as one-by-one matrices.\n(We index the summands by `punit`.) -/\n@[simps]\ndef embedding : C ⥤ Mat_ C :=\n{ obj := λ X, ⟨punit, λ _, X⟩,\n  map := λ X Y f, λ _ _, f,\n  map_id' := λ X, by { ext ⟨⟩ ⟨⟩, simp, },\n  map_comp' := λ X Y Z f g, by { ext ⟨⟩ ⟨⟩, simp, }, }\n\nnamespace embedding\n\ninstance : faithful (embedding C) :=\n{ map_injective' := λ X Y f g h, congr_fun (congr_fun h punit.star) punit.star, }\n\ninstance : full (embedding C) :=\n{ preimage := λ X Y f, f punit.star punit.star, }\n\ninstance : functor.additive (embedding C) := {}\n\nend embedding\n\ninstance [inhabited C] : inhabited (Mat_ C) := ⟨(embedding C).obj default⟩\n\nopen category_theory.limits\n\nvariables {C}\n\n/--\nEvery object in `Mat_ C` is isomorphic to the biproduct of its summands.\n-/\n@[simps]\ndef iso_biproduct_embedding (M : Mat_ C) : M ≅ ⨁ (λ i, (embedding C).obj (M.X i)) :=\n{ hom := biproduct.lift (λ i j k, if h : j = i then eq_to_hom (congr_arg M.X h) else 0),\n  inv := biproduct.desc (λ i j k, if h : i = k then eq_to_hom (congr_arg M.X h) else 0),\n  hom_inv_id' :=\n  begin\n    simp only [biproduct.lift_desc],\n    funext i,\n    dsimp,\n    convert finset.sum_apply _ _ _,\n    { dsimp, refl, },\n    { apply heq_of_eq,\n      symmetry,\n      funext j,\n      simp only [finset.sum_apply],\n      dsimp,\n      simp [dite_comp, comp_dite, Mat_.id_apply], }\n  end,\n  inv_hom_id' :=\n  begin\n    apply biproduct.hom_ext,\n    intro i,\n    apply biproduct.hom_ext',\n    intro j,\n    simp only [category.id_comp, category.assoc,\n      biproduct.lift_π, biproduct.ι_desc_assoc, biproduct.ι_π],\n    ext ⟨⟩ ⟨⟩,\n    simp [dite_comp, comp_dite],\n    split_ifs,\n    { subst h, simp, },\n    { simp [h], },\n  end, }.\n\nvariables {D : Type u₁} [category.{v₁} D] [preadditive D]\n\n/-- Every `M` is a direct sum of objects from `C`, and `F` preserves biproducts. -/\n@[simps]\ndef additive_obj_iso_biproduct (F : Mat_ C ⥤ D) [functor.additive F] (M : Mat_ C) :\n  F.obj M ≅ ⨁ (λ i, F.obj ((embedding C).obj (M.X i))) :=\n(F.map_iso (iso_biproduct_embedding M)) ≪≫ (F.map_biproduct _)\n\nvariables [has_finite_biproducts D]\n\n@[reassoc] lemma additive_obj_iso_biproduct_naturality (F : Mat_ C ⥤ D) [functor.additive F]\n  {M N : Mat_ C} (f : M ⟶ N) :\n  F.map f ≫ (additive_obj_iso_biproduct F N).hom =\n    (additive_obj_iso_biproduct F M).hom ≫\n      biproduct.matrix (λ i j, F.map ((embedding C).map (f i j))) :=\nbegin\n  -- This is disappointingly tedious.\n  ext,\n  simp only [additive_obj_iso_biproduct_hom, category.assoc, biproduct.lift_π, functor.map_bicone_π,\n    biproduct.bicone_π, biproduct.lift_matrix],\n  dsimp [embedding],\n  simp only [←F.map_comp, biproduct.lift_π, biproduct.matrix_π, category.assoc],\n  simp only [←F.map_comp, ←F.map_sum, biproduct.lift_desc, biproduct.lift_π_assoc, comp_sum],\n  simp only [comp_def, comp_dite, comp_zero, finset.sum_dite_eq', finset.mem_univ, if_true],\n  dsimp,\n  simp only [finset.sum_singleton, dite_comp, zero_comp],\n  congr,\n  symmetry,\n  convert finset.sum_fn _ _, -- It's hard to use this as a simp lemma!\n  simp only [finset.sum_fn, finset.sum_dite_eq],\n  ext,\n  simp,\nend\n\n@[reassoc] lemma additive_obj_iso_biproduct_naturality' (F : Mat_ C ⥤ D) [functor.additive F]\n  {M N : Mat_ C} (f : M ⟶ N) :\n  (additive_obj_iso_biproduct F M).inv ≫ F.map f =\n    biproduct.matrix (λ i j, F.map ((embedding C).map (f i j)) : _) ≫\n      (additive_obj_iso_biproduct F N).inv :=\nby rw [iso.inv_comp_eq, ←category.assoc, iso.eq_comp_inv, additive_obj_iso_biproduct_naturality]\n\n/-- Any additive functor `C ⥤ D` to a category `D` with finite biproducts extends to\na functor `Mat_ C ⥤ D`. -/\n@[simps]\ndef lift (F : C ⥤ D) [functor.additive F] : Mat_ C ⥤ D :=\n{ obj := λ X, ⨁ (λ i, F.obj (X.X i)),\n  map := λ X Y f, biproduct.matrix (λ i j, F.map (f i j)),\n  map_id' := λ X, begin\n    ext i j,\n    by_cases h : i = j,\n    { subst h, simp, },\n    { simp [h, Mat_.id_apply], },\n  end,\n  map_comp' := λ X Y Z f g, by { ext i j, simp, }, }.\n\ninstance lift_additive (F : C ⥤ D) [functor.additive F] : functor.additive (lift F) := {}\n\n/-- An additive functor `C ⥤ D` factors through its lift to `Mat_ C ⥤ D`. -/\n@[simps]\ndef embedding_lift_iso (F : C ⥤ D) [functor.additive F] : embedding C ⋙ lift F ≅ F :=\nnat_iso.of_components (λ X,\n  { hom := biproduct.desc (λ P, 𝟙 (F.obj X)),\n    inv := biproduct.lift (λ P, 𝟙 (F.obj X)), })\n(λ X Y f, begin\n  dsimp,\n  ext,\n  simp only [category.id_comp, biproduct.ι_desc_assoc],\n  erw biproduct.ι_matrix_assoc, -- Not sure why this doesn't fire via `simp`.\n  simp,\nend).\n\n/--\n`Mat_.lift F` is the unique additive functor `L : Mat_ C ⥤ D` such that `F ≅ embedding C ⋙ L`.\n-/\ndef lift_unique (F : C ⥤ D) [functor.additive F] (L : Mat_ C ⥤ D) [functor.additive L]\n  (α : embedding C ⋙ L ≅ F) :\n  L ≅ lift F :=\nnat_iso.of_components\n  (λ M, (additive_obj_iso_biproduct L M) ≪≫\n    (biproduct.map_iso (λ i, α.app (M.X i))) ≪≫\n    (biproduct.map_iso (λ i, (embedding_lift_iso F).symm.app (M.X i))) ≪≫\n    (additive_obj_iso_biproduct (lift F) M).symm)\n(λ M N f, begin\n  dsimp only [iso.trans_hom, iso.symm_hom, biproduct.map_iso_hom],\n  simp only [additive_obj_iso_biproduct_naturality_assoc],\n  simp only [biproduct.matrix_map_assoc, category.assoc],\n  simp only [additive_obj_iso_biproduct_naturality'],\n  simp only [biproduct.map_matrix_assoc, category.assoc],\n  congr,\n  ext j k ⟨⟩,\n  dsimp, simp,\n  convert α.hom.naturality (f j k),\n  erw [biproduct.matrix_π],\n  simp,\nend).\n\n-- TODO is there some uniqueness statement for the natural isomorphism in `lift_unique`?\n\n/-- Two additive functors `Mat_ C ⥤ D` are naturally isomorphic if\ntheir precompositions with `embedding C` are naturally isomorphic as functors `C ⥤ D`. -/\n@[ext]\ndef ext {F G : Mat_ C ⥤ D} [functor.additive F] [functor.additive G]\n  (α : embedding C ⋙ F ≅ embedding C ⋙ G) : F ≅ G :=\n(lift_unique (embedding C ⋙ G) _ α) ≪≫ (lift_unique _ _ (iso.refl _)).symm\n\n/--\nNatural isomorphism needed in the construction of `equivalence_self_of_has_finite_biproducts`.\n-/\ndef equivalence_self_of_has_finite_biproducts_aux [has_finite_biproducts C] :\n  embedding C ⋙ 𝟭 (Mat_ C) ≅ embedding C ⋙ lift (𝟭 C) ⋙ embedding C :=\nfunctor.right_unitor _ ≪≫\n  (functor.left_unitor _).symm ≪≫\n  (iso_whisker_right (embedding_lift_iso _).symm _) ≪≫\n  functor.associator _ _ _\n\n/--\nA preadditive category that already has finite biproducts is equivalent to its additive envelope.\n\nNote that we only prove this for a large category;\notherwise there are universe issues that I haven't attempted to sort out.\n-/\ndef equivalence_self_of_has_finite_biproducts\n  (C : Type (u₁+1)) [large_category C] [preadditive C] [has_finite_biproducts C] :\n  Mat_ C ≌ C :=\nequivalence.mk -- I suspect this is already an adjoint equivalence, but it seems painful to verify.\n  (lift (𝟭 C))\n  (embedding C)\n  (ext equivalence_self_of_has_finite_biproducts_aux)\n  (embedding_lift_iso (𝟭 C))\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_functor\n  {C : Type (u₁+1)} [large_category C] [preadditive C] [has_finite_biproducts C] :\n  (equivalence_self_of_has_finite_biproducts C).functor = lift (𝟭 C) :=\nrfl\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_inverse\n  {C : Type (u₁+1)} [large_category C] [preadditive C] [has_finite_biproducts C] :\n  (equivalence_self_of_has_finite_biproducts C).inverse = embedding C :=\nrfl\n\nend Mat_\n\nuniverse u\n\n/-- A type synonym for `Fintype`, which we will equip with a category structure\nwhere the morphisms are matrices with components in `R`. -/\n@[nolint unused_arguments, derive inhabited]\ndef Mat (R : Type u) := Fintype.{u}\n\ninstance (R : Type u) : has_coe_to_sort (Mat R) (Type u) := bundled.has_coe_to_sort\n\nopen_locale classical matrix\n\ninstance (R : Type u) [semiring R] : category (Mat R) :=\n{ hom := λ X Y, matrix X Y R,\n  id := λ X, 1,\n  comp := λ X Y Z f g, f ⬝ g,\n  assoc' := by { intros, simp [matrix.mul_assoc], }, }\n\nnamespace Mat\n\nsection\nvariables (R : Type u) [semiring R]\n\nlemma id_def (M : Mat R) :\n  𝟙 M = λ i j, if h : i = j then 1 else 0 :=\nrfl\n\nlemma id_apply (M : Mat R) (i j : M) :\n  (𝟙 M : matrix M M R) i j = if h : i = j then 1 else 0 :=\nrfl\n\n@[simp] lemma id_apply_self (M : Mat R) (i : M) :\n  (𝟙 M : matrix M M R) i i = 1 :=\nby simp [id_apply]\n\n@[simp] lemma id_apply_of_ne (M : Mat R) (i j : M) (h : i ≠ j) :\n  (𝟙 M : matrix M M R) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat R} (f : M ⟶ N) (g : N ⟶ K) :\n  (f ≫ g) = λ i k, ∑ j : N, f i j * g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat R} (f : M ⟶ N) (g : N ⟶ K) (i k) :\n  (f ≫ g) i k = ∑ j : N, f i j * g j k := rfl\n\ninstance (M N : Mat R) : inhabited (M ⟶ N) := ⟨λ (i : M) (j : N), (0 : R)⟩\n\nend\n\nvariables (R : Type u) [ring R]\n\nopen opposite\n\n/-- Auxiliary definition for `category_theory.Mat.equivalence_single_obj`. -/\n@[simps]\ndef equivalence_single_obj_inverse : Mat_ (single_obj Rᵐᵒᵖ) ⥤ Mat R :=\n{ obj := λ X, Fintype.of X.ι,\n  map := λ X Y f i j, mul_opposite.unop (f i j),\n  map_id' := λ X, by { ext i j, simp [id_def, Mat_.id_def], split_ifs; refl, }, }\n\ninstance : faithful (equivalence_single_obj_inverse R) :=\n{ map_injective' := λ X Y f g w, begin\n    ext i j,\n    apply_fun mul_opposite.unop using mul_opposite.unop_injective,\n    exact (congr_fun (congr_fun w i) j),\n  end }\n\ninstance : full (equivalence_single_obj_inverse R) :=\n{ preimage := λ X Y f i j, mul_opposite.op (f i j), }\n\ninstance : ess_surj (equivalence_single_obj_inverse R) :=\n{ mem_ess_image := λ X,\n  ⟨{ ι := X, X := λ _, punit.star }, ⟨eq_to_iso (by { dsimp, cases X, congr, })⟩⟩, }\n\n/-- The categorical equivalence between the category of matrices over a ring,\nand the category of matrices over that ring considered as a single-object category. -/\ndef equivalence_single_obj : Mat R ≌ Mat_ (single_obj Rᵐᵒᵖ) :=\nbegin\n  haveI := equivalence.of_fully_faithfully_ess_surj (equivalence_single_obj_inverse R),\n  exact (equivalence_single_obj_inverse R).as_equivalence.symm,\nend\n\ninstance : preadditive (Mat R) :=\n{ add_comp' := by { intros, ext, simp [add_mul, finset.sum_add_distrib], },\n  comp_add' := by { intros, ext, simp [mul_add, finset.sum_add_distrib], }, }\n\n-- TODO show `Mat R` has biproducts, and that `biprod.map` \"is\" forming a block diagonal matrix.\n\nend Mat\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/preadditive/Mat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.459716524128613}}
{"text": "import algebra.homology.homological_complex\n\nopen category_theory category_theory.limits\n\nnamespace homological_complex\n\nuniverses w' w v v' u u'\n\nvariables {V : Type u} [category.{v} V] {J : Type w} [category.{w'} J]\nvariables {ι : Type u'} {c : complex_shape ι}\n\n-- move this\nsection\nvariables {C : Type u} [category.{v} C] {Z : C → Prop}\n@[simps]\ndef lift_iso {X Y : { X : C // Z X }} (h : (X : C) ≅ Y) : X ≅ Y :=\n{ hom := h.hom, inv := h.inv, hom_inv_id' := h.hom_inv_id, inv_hom_id' := h.inv_hom_id }\nend\n\nsection walking_complex\n\n@[nolint unused_arguments]\ndef walking_complex (c : complex_shape ι) := ι\n\ninductive walking_complex_hom : walking_complex c → walking_complex c → Type u'\n| id : Π i, walking_complex_hom i i\n| d : Π {i j}, c.rel i j → walking_complex_hom i j\n| zero : Π i j, walking_complex_hom i j\n\nsection\n\nopen walking_complex_hom\n\ndef walking_complex_hom_comp (i j k : walking_complex c) :\n  walking_complex_hom i j → walking_complex_hom j k → walking_complex_hom i k :=\nbegin\n  intros f g,\n  cases f with _ _ _ r,\n  { exact g },\n  { cases g, exacts [walking_complex_hom.d r, walking_complex_hom.zero _ _, walking_complex_hom.zero _ _] },\n  { exact walking_complex_hom.zero _ _ },\nend\n\ninstance : category_struct (walking_complex c) :=\n{ hom := walking_complex_hom,\n  id := walking_complex_hom.id,\n  comp :=\n  begin\n    intros i j k f g,\n    cases f with _ _ _ r,\n    { exact g },\n    { cases g, exacts [walking_complex_hom.d r, walking_complex_hom.zero _ _, walking_complex_hom.zero _ _] },\n    { exact walking_complex_hom.zero _ _ },\n  end }\nend\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance : category (walking_complex c) := {}\n.\n\ninstance walking_complex_hom_has_zero (i j : walking_complex c) : has_zero (i ⟶ j) :=\n⟨walking_complex_hom.zero i j⟩\n\ninstance : has_zero_morphisms (walking_complex c) := {}\n.\n\n@[simp] lemma walking_complex_hom_id (i : walking_complex c) : walking_complex_hom.id i = 𝟙 i :=\nrfl\n@[simp] lemma walking_complex_hom_zero (i : walking_complex c) : walking_complex_hom.zero i = 0 :=\nrfl\n\ndef walking_complex_d {i j : walking_complex c} (r : c.rel i j) : i ⟶ j :=\n  walking_complex_hom.d r\n\n@[simp] lemma walking_complex_d_eq {i j : walking_complex c} (r : c.rel i j) :\n  walking_complex_hom.d r = walking_complex_d r := rfl\n\n@[simp] lemma walking_complex_hom_d_comp_d {i j k : walking_complex c}\n  (r : c.rel i j) (r' : c.rel j k) : walking_complex_d r ≫ walking_complex_d r' = 0 := rfl\n\nvariable [has_zero_morphisms V]\n\ndef complex_to_functor_map\n  (h : homological_complex V c) {i j : walking_complex c} (f : i ⟶ j) : h.X i ⟶ h.X j :=\nbegin\n  cases f, exacts [𝟙 _, h.d _ _, 0]\nend\n\n@[simp]\nlemma complex_to_functor_map_id\n  (h : homological_complex V c) (i : walking_complex c) : complex_to_functor_map h (𝟙 i) = 𝟙 _ :=\nrfl\n\n@[simp]\nlemma complex_to_functor_map_zero\n  (h : homological_complex V c) (i j : walking_complex c) :\n    complex_to_functor_map h (0 : i ⟶ j) = 0 :=\nrfl\n\n@[simp]\nlemma complex_to_functor_map_d\n  (h : homological_complex V c) {i j : walking_complex c} (r : c.rel i j) :\n    complex_to_functor_map h (walking_complex_d r) = h.d _ _ := rfl\n\n@[simps]\ndef complex_to_functor (h : homological_complex V c) :\n  walking_complex c ⥤ V :=\n{ obj := h.X, map := λ i j f, complex_to_functor_map h f }\n.\n\nvariable [decidable_rel c.rel]\n\n@[simps]\ndef functor_to_complex (F : walking_complex c ⥤ V)\n  (hF : ∀ i j, F.map (0 : i ⟶ j) = 0) :\n  homological_complex V c :=\n{ X := F.obj,\n  d := λ i j, if r : c.rel i j then F.map (walking_complex_d r) else 0,\n  d_comp_d' := by { introv r r',\n    rw [dif_pos r, dif_pos r', ← F.map_comp, walking_complex_hom_d_comp_d, hF] } }\n.\nvariables (c V)\n\n@[simps]\ndef complex_to_functor_functor :\n  homological_complex V c ⥤ { F : walking_complex c ⥤ V // ∀ i j, F.map (0 : i ⟶ j) = 0 } :=\n{ obj := λ X, ⟨complex_to_functor X, λ _ _, rfl⟩, map := λ X Y f, { app := f.f } }\n\n@[simps]\ndef functor_to_complex_functor :\n  { F : walking_complex c ⥤ V // ∀ i j, F.map (0 : i ⟶ j) = 0 } ⥤ homological_complex V c :=\n{ obj := λ F, functor_to_complex F.1 F.2,\n  map := λ F G f, { f := f.app, comm' := by { intros i j r, simp [dif_pos r] } } }\n.\n\n@[simps]\ndef complex_equiv_functor_unit :\n  𝟭 _ ≅ complex_to_functor_functor V c ⋙ functor_to_complex_functor V c :=\nnat_iso.of_components\n  (λ X, hom.iso_of_components (λ i, iso.refl _) (by { introv r, dsimp, simp [if_pos r] }))\n  (by { intros, ext, dsimp, simp })\n\n@[simps]\ndef complex_equiv_functor_counit :\n  functor_to_complex_functor V c ⋙ complex_to_functor_functor V c ≅ 𝟭 _ :=\nnat_iso.of_components\n  (λ F, lift_iso $ nat_iso.of_components (λ i, iso.refl _)\n    (by { introv, cases F with F hF, cases f; dsimp; simp [*, hF] }))\n  (by { introv, ext, dsimp, erw [nat_trans.comp_app, nat_trans.comp_app], dsimp, simp })\n\n@[simps]\ndef complex_equiv_functor :\n  homological_complex V c ≌ { F : walking_complex c ⥤ V // ∀ i j, F.map (0 : i ⟶ j) = 0 } :=\n{ functor := complex_to_functor_functor V c,\n  inverse := functor_to_complex_functor V c,\n  unit_iso := complex_equiv_functor_unit V c,\n  counit_iso := complex_equiv_functor_counit V c,\n  functor_unit_iso_comp' :=\n    by { intro x, ext, erw [nat_trans.comp_app, nat_trans.id_app], dsimp, simp } }\n.\n\ninstance : is_equivalence (complex_to_functor_functor V c) :=\nis_equivalence.of_equivalence (complex_equiv_functor V c)\ninstance : is_equivalence (functor_to_complex_functor V c) :=\nis_equivalence.of_equivalence_inverse (complex_equiv_functor V c)\n\n@[simps, derive [full, faithful]]\ndef complex_to_functor_category_functor : homological_complex V c ⥤ walking_complex c ⥤ V :=\ncomplex_to_functor_functor V c ⋙ induced_functor _\n\nend walking_complex\n\nsection walking_preadditive_complex\n\n/-\nTODO : If `V` is preadditive, then the cateogory of homological complexes is equivalent to the\ncategory of additive functors from a preadditive category `walking_preadditive_complex` to `V`.\n-/\n\nend walking_preadditive_complex\n\nend homological_complex\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/for_mathlib/homological_complex_equiv_functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.4597165017367949}}
{"text": "import homotopy_theory.formal.cylinder.homotopy\nimport .definitions\nimport .lemmas\n\nuniverses v u\n\nopen category_theory\nopen category_theory.category\nlocal notation f ` ∘ `:80 g:80 := g ≫ f\n\nnamespace homotopy_theory.cofibrations\nopen homotopy_theory.cylinder\n\nnamespace equiv_private\nsection\nopen category_theory.has_initial_object category_theory.preserves_initial_object\nopen category_theory.preserves_coproducts\nopen precofibration_category I_category\n\n/-\n\nGoal: If j : a → b is a cofibration, then homotopy rel j is an\nequivalence relation. More generally, we will prove the\nfollowing. Suppose that G : Ia → x is a homotopy. In the diagram\n\n  f₀  - f₁\n  |\n  f₀' - f₁'\n\nsuppose that f₀ ≃ f₀' rel j and that f₀ ≃ f₁ and f₀' ≃ f₁' via\nhomotopies that each restrict to G on a. Then f₁ ≃ f₁' rel j. By\ntaking G to be a constant homotopy, we conclude in particular that\nhomotopy rel j is an equivalence relation.\n\n-/\n\nparameters {C : Type u} [category.{v} C] [has_initial_object.{v} C]\n  [has_coproducts.{v} C] [I_category.{v} C]\n\nparameters {a b : C} (j : a ⟶ b) (hj : is_cof j)\nparameters {x : C} {f₀ f₀' f₁ f₁' : b ⟶ x}\nparameters {G : I.obj a ⟶ x}\nparameters {H₀ : homotopy f₀ f₀'} (h₀ : H₀.is_rel j)\n\n-- Furthermore, we generalize over the direction of the homotopies\n-- between f₀ and f₁ and between f₀' and f₁'.\nparameters (ε : endpoint)\nparameters {H : homotopy_dir ε f₀ f₁} (h : H.H ∘ I &> j = G)\nparameters {H' : homotopy_dir ε f₀' f₁'} (h' : H'.H ∘ I &> j = G)\n-- Goal: construct a homotopy from f₁ to f₂ rel j.\n\n/-\n  a ⊔ a →   Ia\n    ↓       ↓\n  b ⊔ b → b_Ia_b\n-/\n\ndef Po : pushout (∂I &> j) (ii @> a) := pushout_by_cof _ _ (cof_coprod hj hj)\ndef b_Ia_b := Po.ob\n\n-- I preserves the above pushout.\ndef Ipo : Is_pushout (I &> (∂I &> j)) (I &> (ii @> a)) (I &> Po.map₀) (I &> Po.map₁) :=\nI_preserves_pushout_by_cof (cof_coprod hj hj) Po.is_pushout\n-- Moreover, I(a ⊔ a) = Ia ⊔ Ia and I(b ⊔ b) = Ib ⊔ Ib.\ndef Ia_Ia : Is_coproduct (I &> (i₀ : a ⟶ a ⊔ a)) (I &> (i₁ : a ⟶ a ⊔ a)) :=\nI_of_coprod_is_coproduct\ndef Ib_Ib : Is_coproduct (I &> (i₀ : b ⟶ b ⊔ b)) (I &> (i₁ : b ⟶ b ⊔ b)) :=\nI_of_coprod_is_coproduct\n-- Thus, we can \"glue\" the homotopies H and H' to form a map I(b ⊔ b) → X.\ndef HH' : I.obj (b ⊔ b) ⟶ x :=\nIb_Ib.induced H.H H'.H\n-- Because the homotopies agree on a, the restriction of this map to I(a ⊔ a)\n-- extends to a map I(Ia) → X. Then we get an induced map on I(b ⊔ₐ Ia ⊔ₐ b).\ndef GIp : I.obj (I.obj a) ⟶ x := G ∘ I &> (p @> a)\n\ninclude h h'\ndef HH'' : I.obj b_Ia_b ⟶ x :=\nIpo.induced HH' GIp $\n  -- This is a bit awful\n  begin\n    apply Ia_Ia.uniqueness;\n    rw [←assoc, ←assoc, ←I.map_comp, ←I.map_comp];\n    change\n      _ ∘ I &> (coprod_of_maps j j ∘ _) =\n      _ ∘ I &> (coprod.induced (i 0 @> a) (i 1 @> a) ∘ _);\n    simp [HH', GIp]; rw h <|> rw h';\n    rw [←assoc, ←I.map_comp]; simp\n  end\nomit h h'\n\n-- The map guaranteed to be a cofibration by the relative cylinder axiom.\n-- Induced map in same pushout square as above.\ndef j' := Po.is_pushout.induced (ii @> b) (I &> j) (ii.naturality _)\n\ninclude h₀\nlemma HH''iε : H₀.H ∘ j' = HH'' ∘ i ε @> _ :=\nhave t : ∀ {z} (k : z ⟶ _), H₀.H ∘ j' ∘ k = H₀.H ∘ (j' ∘ k), by simp,\nbegin\n  unfold HH'' HH',\n  apply Po.is_pushout.uniqueness,\n  -- This is truly awful\n  { rw i_nat_assoc,\n    apply coprod.uniqueness;\n    { simp, erw i_nat_assoc, simp,\n      rw t, unfold j' ii, simp, rw ←assoc, simp,\n      erw H₀.Hi₀ <|> erw H₀.Hi₁,\n      erw H.Hiε <|> erw H'.Hiε } },\n  { rw [i_nat_assoc, t], unfold j' GIp, simp,\n    erw [←i_nat_assoc, ←h, ←i_nat_assoc, H.Hiε],\n    exact h₀ }\nend\nomit h₀\n\n-- Now we can apply the homotopy extension property of j'\nlemma Ex_E : ∃ (E : I.obj (I.obj b) ⟶ x),\n  E ∘ i ε @> (I.obj b) = H₀.H ∧ E ∘ I &> j' = HH'' :=\nhep_cof j' (relative_cylinder j hj) ε _ _ _ HH''iε\n\nsection E\nparameters (E : I.obj (I.obj b) ⟶ x)\n  (hE : E ∘ i ε @> I.obj b = H₀.H ∧ E ∘ I &> j' = HH'')\n-- Now E ∘ i ε.v is supposed to be a homotopy from f₁ to f₁' rel j.\n\ninclude hE\nlemma Eiεvi_ :\n  E ∘ i ε.v @> I.obj b ∘ i 0 @> b = f₁ ∧\n  E ∘ i ε.v @> I.obj b ∘ i 1 @> b = f₁' :=\nhave\n  i.{v} ε.v @> I.obj b ∘ i 0 @> b = I &> j' ∘ I &> Po.map₀ ∘ i ε.v @> _ ∘ i₀ ∧\n  i.{v} ε.v @> I.obj b ∘ i 1 @> b = I &> j' ∘ I &> Po.map₀ ∘ i ε.v @> _ ∘ i₁, begin\n  split;\n  { rw ←I.map_comp, unfold j', simp, erw i_nat_assoc,\n    rw ←I.map_comp, dsimp [ii], simp,\n    apply (i _).naturality }\nend,\nbegin\n  split;\n  { rw ←assoc, rw this.1 <|> rw this.2,\n    simp [hE.2, HH'', HH'],\n    erw i_nat_assoc, dsimp, simp,\n    -- dsimp: coprod vs (has_coproducts.coproduct _ _).ob?\n    exact H.Hiεv <|> exact H'.Hiεv }\nend\n\ndef Eiε : homotopy f₁ f₁' :=\n{ H := E ∘ i ε.v @> I.obj b, Hi₀ := Eiεvi_.1, Hi₁ := Eiεvi_.2 }\n\nlemma Eiε_is_rel : Eiε.is_rel j :=\nhave i ε.v @> I.obj b ∘ I &> j = I &> j' ∘ I &> Po.map₁ ∘ i ε.v @> I.obj a, begin\n  rw ←I.map_comp, unfold j', simp,\n  rw ←(i ε.v).naturality, refl\nend,\nbegin\n  dsimp [homotopy.is_rel, Eiε] { iota := tt },\n  rw [←assoc, this], simp [hE.2, HH'', GIp],\n  rw [←h, ←i_nat_assoc, ←i_nat_assoc, H.Hiεv]\nend\n\nend E\n\nlemma f₁_f₂ : f₁ ≃ f₁' rel j :=\nlet ⟨E, hE⟩ := Ex_E in ⟨Eiε E hE, Eiε_is_rel E hE⟩\n\nend\nend equiv_private\n\nend homotopy_theory.cofibrations\n\n-- TODO: Is this a sensible place to put these?\nnamespace homotopy_theory.cylinder\nopen homotopy_theory.cofibrations\n\nvariables {C : Type u} [category.{v} C]\n  [has_initial_object.{v} C] [has_coproducts.{v} C] [I_category.{v} C]\nvariables {a b : C} {j : a ⟶ b} (hj : is_cof j)\n\nlemma homotopic_rel.symm_trans {x : C} {f₀ f₁ f₂ : b ⟶ x} :\n  f₀ ≃ f₁ rel j → f₀ ≃ f₂ rel j → f₁ ≃ f₂ rel j :=\nassume ⟨H₁, h₁⟩ ⟨H₂, h₂⟩, equiv_private.f₁_f₂ j hj homotopy.refl_is_rel 0 h₁ h₂\n\nlemma homotopic_rel.symm {x : C} {f₀ f₁ : b ⟶ x} (h : f₀ ≃ f₁ rel j) : f₁ ≃ f₀ rel j :=\nhomotopic_rel.symm_trans hj h (homotopic_rel.refl _)\n\nlemma homotopic_rel.trans {x : C} {f₀ f₁ f₂ : b ⟶ x}\n  (h₁ : f₀ ≃ f₁ rel j) (h₂ : f₁ ≃ f₂ rel j) : f₀ ≃ f₂ rel j :=\nhomotopic_rel.symm_trans hj (h₁.symm hj) h₂\n\nlemma homotopic_rel_is_equivalence {x : C} :\n  equivalence (homotopic_rel j : (b ⟶ x) → (b ⟶ x) → Prop) :=\n⟨homotopic_rel.refl,\n λ f₀ f₁, homotopic_rel.symm hj,\n λ f₀ f₁ f₂, homotopic_rel.trans hj⟩\n\n@[symm] lemma homotopic.symm {x : C} {f₀ f₁ : b ⟶ x} (h : f₀ ≃ f₁) : f₁ ≃ f₀ :=\nbegin\n  rw ←(homotopic_rel_initial Ii_initial (! b)) at ⊢ h,\n  exact homotopic_rel.symm (all_objects_cofibrant.cofibrant.{v} b) h,\nend\n\n@[trans] lemma homotopic.trans {x : C} {f₀ f₁ f₂ : b ⟶ x} (h₁ : f₀ ≃ f₁) (h₂ : f₁ ≃ f₂) : f₀ ≃ f₂ :=\nbegin\n  rw ←(homotopic_rel_initial Ii_initial (! b)) at ⊢ h₁ h₂,\n  exact homotopic_rel.trans (all_objects_cofibrant.cofibrant.{v} b) h₁ h₂,\nend\n\nlemma homotopic_is_equivalence {x : C} :\n  equivalence (homotopic : (b ⟶ x) → (b ⟶ x) → Prop) :=\n⟨homotopic.refl, λ f₀ f₁, homotopic.symm, λ f₀ f₁ f₂, homotopic.trans⟩\n\nend homotopy_theory.cylinder\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/homotopy_theory/formal/i_category/homotopy_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6261241842048093, "lm_q1q2_score": 0.4596499898891977}}
{"text": "/-\nCopyright 2021 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\n\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.sum\nimport formal_ml.lattice\nimport formal_ml.measurable_space\nimport formal_ml.classical\nimport data.equiv.list\nimport formal_ml.prod_measure\nimport formal_ml.finite_pi_measure\nimport formal_ml.probability_space\n\n/-!\n  This file focuses on more esoteric proofs that random variables are identical\n  and independent. These are based upon the monotone class theorem.\n\n  Semi-algebras are the basic object. A sigma algebra or algebra is a semi-algebra.\n  For example, the set of (closed, open, half-open) intervals on the real line form a \n  semi-algebra. The simplest sets in a product of a measurable space form a semi-algebra.\n  \n  If you close a semi-algebra under finite disjoint union, it becomes an algebra.\n\n  An algebra is defined as containing the universal set and being closed under set \n  difference. However, it is also closed under finite union, intersection, complement,\n  and it contains the empty set.\n\n  The monotone class of a set is the closure under monotone intersection and monotone\n  union. The monotone class of an algebra is a sigma algebra (the monotone class theorem).\n\n  This file contains the definition of a monotone class, a semi-algebra, and an algebra.\n  (set.monotone_class, set.is_semialgebra, and set.is_algebra). It also contains\n  the definition of closure under finite disjoint union.\n\n\n  This is most useful for proving independent and identical random variables, when\n  considered as an aggregate random variable, are identical.\n\n  The core is the monotone class theorem, measurable_space.generate_from_monotone_class.\n-/\n\n\n/-- A monotone class: an extension of a set of sets to be closed under\n   monotone intersection and union.\n   When a monotone class extends an algebra (not a sigma algebra, just a regular algebra),\n   it is equivalent to the\n   measurable space generated from the algebra.\n\n   First, we introduce the properties of algebras. Then, we show that the\n   result of a monotone class of an algebra is an algebra. Finally, we\n   show the monotone class of an algebra is a sigma algebra (i.e., a\n   measurable space).\n   See measurable_space.generate_from_monotone_class\n -/\ninductive set.monotone_class {α:Type*} (s : set (set α)) : set α → Prop\n| basic : ∀ u, u∈ s → set.monotone_class u \n| inter : ∀ f : ℕ → set α, (∀ n, set.monotone_class (f n)) → \n                           (∀ (i:ℕ), f i.succ ⊆ f i) →  \n                           set.monotone_class (set.Inter f)\n| union : ∀ f : ℕ → set α, (∀ n, set.monotone_class (f n)) →\n                           monotone f →\n                            set.monotone_class (set.Union f)\n\n--namespace measure_theory\n\nstructure set.is_algebra {α:Type*} (s:set (set α)) :=\n  (univ : set.univ ∈ s)\n  (diff : ∀ a b, a ∈ s →  b ∈ s → (a \\ b) ∈ s)\n\n\nlemma set.is_algebra.compl {α:Type*} {s:set (set α)} (A:s.is_algebra):\n  (∀ a, a∈ s → aᶜ ∈ s) := begin\n  intros a h_a,\n  have h3:aᶜ = set.univ \\ a,\n  { ext ω, split; intros h3_1; simp at h3_1; simp [h3_1] },\n  rw h3,\n  apply A.diff,\n  apply A.univ,\n  apply h_a\nend \n\nlemma set.is_algebra.empty {α:Type*} {s:set (set α)} (A:s.is_algebra):\n  (∅ ∈ s) := begin\n  rw ← set.compl_univ,\n  apply A.compl,\n  apply A.univ,\nend\n\n\n\nlemma set.is_algebra.inter {α:Type*} {s:set (set α)} (A:s.is_algebra):\n  (∀ a b, a∈ s → b∈ s→ a∩ b ∈ s) := begin\n  intros a b h_a h_b,\n  have h3:a ∩ b = a \\ bᶜ,\n  { ext ω, split; intros h3_1; simp at h3_1; simp [h3_1] },\n  rw h3,\n  apply A.diff,\n  apply h_a,\n  apply A.compl,\n  apply h_b,\nend\n\n\nlemma set.is_algebra.union {α:Type*} {s : set (set α)} (A:s.is_algebra):\n  (∀ a b, a∈ s → b ∈ s → a ∪ b ∈ s) := begin\n  intros a b h_a h_b,\n  have h3:a ∪ b = (aᶜ ∩ bᶜ)ᶜ,\n  { rw set.union_eq_compl_compl_inter_compl },\n  rw h3,\n  apply A.compl,\n  apply A.inter,\n  apply A.compl,\n  apply h_a,\n  apply A.compl,\n  apply h_b,\nend\n\n\nlemma set.Union_succ {α:Type*} (j_n:ℕ) (f:ℕ → set α):\n  (⋃ (i : ℕ) (h : i ≤ j_n.succ), f i) = (f j_n.succ) ∪ (⋃ (i : ℕ) (h : i ≤ j_n), f i) := \nbegin\n  ext a, split; intros h1; simp at h1; simp [h1],\n  cases h1 with i h1,\n  cases decidable.em (i = j_n.succ) with h2 h2,\n  { subst i, simp [h1] },\n  { right, apply exists.intro i,\n    split,\n    apply nat.le_of_lt_succ,\n    rw lt_iff_le_and_ne, split,\n    apply h1.left,\n    apply h2, apply h1.right },\n  cases h1 with h1 h1,\n  { apply exists.intro j_n.succ, \n    split, apply le_refl _,\n    apply h1 },\n  { cases h1 with i h1,\n    apply exists.intro i,\n    split,\n    apply le_trans h1.left (le_of_lt (nat.lt_succ_self j_n)),\n    apply h1.right },\nend\n\nlemma set.is_algebra.finite_union {α:Type*} {s : set (set α)} (A:s.is_algebra):\n  (∀ (f:ℕ → (set α)), (∀ i, f i ∈ s) → (∀ j, (⋃ (i:ℕ) (h:i ≤ j), f i) ∈ s)) := begin\n  intros f h3 j,\n  induction j,\n  { have h4:(⋃ (i : ℕ) (h : i ≤ 0), f i) = f 0,\n   { ext a; split; intros h4_1, simp at h4_1, apply h4_1,\n     simp, apply h4_1 }, rw h4, apply h3 },\n  { rw set.Union_succ,\n    apply A.union,\n    apply h3,\n    apply j_ih },\nend\n\n\n\nlemma set.monotone_class.compl {α:Type*} {s : set (set α)} : \n  (∀ a ∈ s, aᶜ ∈ s) →\n  (∀ (a:set α), s.monotone_class a → s.monotone_class aᶜ) := begin\n  intros h1 a h2,\n  induction h2 with a' h_a' f h_rec h_mono h_ind f h_rec h_mono h_ind,\n  { apply set.monotone_class.basic,\n    apply h1, apply h_a' },\n  { rw set.compl_Inter,\n    apply set.monotone_class.union,\n    { intros n, apply h_ind },\n    { apply @monotone_of_monotone_nat (set α) _ (λ (i : ℕ), (f i)ᶜ),\n      intros n, simp, rw set.compl_subset_compl, apply h_mono } },\n  { rw set.compl_Union,\n    apply set.monotone_class.inter,\n    { intros n, apply h_ind },\n    { intros n, rw set.compl_subset_compl, apply h_mono, apply nat.le_of_lt,\n      apply nat.lt_succ_self } },\nend\n\nlemma set.diff_Inter_eq_Union_diff {α:Type*} (a':set α) (f_b:ℕ → set α):\n  a' \\ (set.Inter f_b) = set.Union (λ i, a' \\ (f_b i)) :=\nbegin\n  ext ω, split; intros h5_1; simp at h5_1; simp [h5_1],\nend\n\nlemma set.Inter_diff_distrib {α:Type*} (a':set α) (f_b:ℕ → set α):\n  (set.Inter f_b) \\ a' = set.Inter (λ i, (f_b i) \\ a') :=\nbegin\n  ext ω, split; intros h5_1; simp at h5_1; simp [h5_1],\n  apply (h5_1 0).right,\nend\n\nlemma set.diff_Union_eq_Inter_diff {α:Type*} (a':set α) (f_b:ℕ → set α):\n  a' \\ (set.Union f_b) = set.Inter (λ i, a' \\ (f_b i)) :=\nbegin\n  ext ω, split; intros h5_1; simp at h5_1; simp [h5_1],\n  apply (h5_1 0).left,\nend\n\nlemma set.Union_diff_distrib {α:Type*} (a':set α) (f_b:ℕ → set α):\n  (set.Union f_b) \\ a' = set.Union (λ i, (f_b i) \\ a') :=\nbegin\n  ext ω, split; intros h5_1; simp at h5_1; simp [h5_1],\nend\n\n/- Effectively proves the monotone class of an algebra is an algebra. -/\nlemma set.monotone_class.diff {α:Type*} {s : set (set α)} : \n  (∀ a b, a∈ s → b ∈ s → a \\ b ∈ s) →\n  (∀ (a b:set α), s.monotone_class a → s.monotone_class b →\n                  s.monotone_class (a \\ b)) := begin\n  intros h2 a b h3, revert b,\n  induction h3 with a' h_a' f_a h_rec_a h_mono_a h_ind_a f_a h_rec_a \n  h_mono_a h_ind_a, \n  intros b h4,\n  \n  induction h4 with b' h_b' f_b h_rec_b h_mono_b h_ind_b f_b h_rec_b \n  h_mono_b h_ind_b,\n  { apply set.monotone_class.basic, apply h2, apply h_a', apply h_b' },\n  { have h5:a' \\ (set.Inter f_b) = set.Union (λ i, a' \\ (f_b i)),\n    { rw set.diff_Inter_eq_Union_diff },\n    rw h5, apply set.monotone_class.union,\n    { apply h_ind_b },\n    { apply @monotone_of_monotone_nat (set α) _ (λ (i : ℕ), a' \\ f_b i),\n      intros n, simp, apply set.diff_subset_diff_right,\n      apply h_mono_b } },\n  { rw set.diff_Union_eq_Inter_diff,\n    apply set.monotone_class.inter,\n    { apply h_ind_b },\n    { intros n,\n      apply set.diff_subset_diff_right,\n      apply h_mono_b,\n      apply le_of_lt,\n      apply nat.lt_succ_self } },\n  { intros b h4,\n    rw set.Inter_diff_distrib,\n    apply set.monotone_class.inter,\n    intros n,\n    apply h_ind_a,\n    apply h4,\n    intros i,\n    apply set.diff_subset_diff_left,\n    apply h_mono_a },\n  { intros b h4,\n    rw set.Union_diff_distrib,\n    apply set.monotone_class.union,\n    { intros n, apply h_ind_a, apply h4 },\n    intros i j h_le, simp, apply set.diff_subset_diff_left,\n    apply h_mono_a, apply h_le },\nend\n\nlemma set.monotone_class.univ {α:Type*} {s : set (set α)} : \n  (set.univ ∈ s) →\n  (s.monotone_class set.univ) := begin\n  intros h1,\n  apply set.monotone_class.basic,\n  apply h1\nend\n\nlemma set.is_algebra.monotone_class {α:Type*} {s : set (set α)} (A:s.is_algebra):\n  set.is_algebra s.monotone_class := {\n  univ := @set.monotone_class.univ α s (A.univ),\n  diff := @set.monotone_class.diff α s (A.diff),\n}\n\nlemma set.monotone_class.pair_inter {α:Type*} {s : set (set α)} (A:s.is_algebra): \n  (∀ (a b:set α), s.monotone_class a → s.monotone_class b →\n                  s.monotone_class (a ∩ b)) := begin\n  have AM := A.monotone_class,\n  apply AM.inter,\nend\n\nlemma measurable_space.generate_measurable.inter {α:Type*} (s : set (set α)):\n ∀ f : ℕ → set α, (∀ n, measurable_space.generate_measurable s (f n)) → \n  measurable_space.generate_measurable s (⋂ i, f i) :=\nbegin\n  intros f h1,\n  rw set.Inter_eq_comp_Union_comp,\n  apply measurable_space.generate_measurable.compl,\n  apply measurable_space.generate_measurable.union,\n  intros n,\n  apply measurable_space.generate_measurable.compl,\n  apply h1,\nend\n\n/- The monotone class theorem (for sets) -/\nlemma measurable_space.generate_from_monotone_class {α:Type*} (s : set (set α)) (A:s.is_algebra):\n  (s.monotone_class = measurable_space.generate_measurable s) :=\nbegin\n  have h3:∀ a ∈ s, aᶜ ∈ s,\n  { apply  A.compl  },\n  have h4:∅ ∈ s,\n  { apply A.empty },\n  have AM := A.monotone_class,\n \n  ext a, split; intros h,\n  { induction h with a' h_a' h_f h_rec h_mono h_ih,\n    { apply measurable_space.generate_measurable.basic, apply h_a' },\n    { apply measurable_space.generate_measurable.inter,\n      intros n, apply h_ih }, \n    { apply measurable_space.generate_measurable.union,\n      intros n, apply h_ih } },\n  { induction h with a' h_a' a' h_a' h_ind f h_rec h_ind h_X4 h_X5,\n    { apply set.monotone_class.basic, apply h_a' },\n    { apply set.monotone_class.basic, apply h4 },\n    { apply set.monotone_class.compl h3,\n      apply h_ind },\n    { let g:ℕ → set α := λ j, ⋃ (i:ℕ) (h:i ≤ j), (f i),\n      begin\n        have h7:set.Union f = set.Union g,\n        { simp [g], ext a, split; intros h7_1;\n          simp at h7_1; cases h7_1 with i h7_1;\n          simp, existsi [i, i], simp [h7_1], \n          cases h7_1 with j h7_1, existsi [j], simp [h7_1],  },\n        rw h7,\n        apply set.monotone_class.union,\n        intros n,\n        simp [g],\n        apply AM.finite_union f,\n        {apply h_ind },\n        apply @monotone_of_monotone_nat (set α) _ g,\n        intros n, simp [g],\n        rw set.Union_succ,\n        apply set.subset_union_right,\n      end   },  },\nend\n\ndef set.disjoint_union_closure {α:Type*} (S:set (set α)):set (set α) :=\n  {s|∃ (m:ℕ) (f:fin m → set α), (∀ i, f i ∈ S) ∧ (pairwise (disjoint on f)) ∧ (s=(⋃ i, f i)) }\n\nlemma set.mem_disjoint_union_closure_iff {α:Type*} (S:set (set α)) (s:set α):\n  s ∈ S.disjoint_union_closure ↔ \n  (∃ (m:ℕ) (f:fin m → set α), (∀ i, f i ∈ S) ∧ (pairwise (disjoint on f)) ∧ (s=(⋃ i, f i))) := begin\n  unfold set.disjoint_union_closure,\n  simp,\nend\n\nlemma set.disjoint_union_closure_intro {α β:Type*} [fintype β] (S:set (set α)) (f:β → set α):\n  (∀ b, f b ∈ S) →\n  (pairwise (disjoint on f)) →\n  (set.Union f) ∈ S.disjoint_union_closure := begin\n  classical,\n  intros h1 h2,\n  simp [set.disjoint_union_closure],\n  have h3:=fintype.exists_equiv_fin β,\n  cases h3 with n h3,\n  apply exists.intro n,\n  let g := classical.choice h3,\n  let h:fin n → set α := f ∘ g.inv_fun,\n  begin\n    apply exists.intro h,\n    split,\n    { intros i, simp [h,g,h1] },\n    split,\n    { intros i j h_ne,\n      simp [function.on_fun, h],\n      have h_ne2:g.symm i ≠ g.symm j,\n      { simp, apply h_ne },\n      have h_disj := h2 (g.symm i) (g.symm j) h_ne2,\n      apply h_disj,\n       },\n    { ext ω, split; intros h4; simp at h4; cases h4 with i h4; simp [h4],\n      { apply exists.intro (g i), simp [h, h4] },\n      { apply exists.intro (g.symm i), apply h4  } },\n  end \nend\n\nlemma set.disjoint_union_closure_self {α:Type*} (S:set (set α)) (s:set α):\n  (s ∈ S) →\n  (s∈ S.disjoint_union_closure) := begin\n  let f:unit → (set α) := (λ _, s),\n  begin\n    intros h0,\n    have h1:set.Union f = s,\n    { simp [f], ext a, split; intros h1_1,\n      simp at h1_1, apply h1_1,\n      simp, apply h1_1 },\n    rw ← h1,\n    apply set.disjoint_union_closure_intro,\n    intros n, simp [f, h0],\n    intros i j h_ne,\n    exfalso,\n    apply h_ne,\n    simp,\n  end\nend\n\n\nstructure set.is_semialgebra {α:Type*} (s:set (set α)) :=\n  (univ : set.univ ∈ s)\n  (empty : ∅ ∈ s)\n  (inter : ∀ (a b:set α), a ∈ s → b ∈ s → a ∩ b ∈ s) \n  (compl : ∀ (b:set α), b ∈ s → bᶜ ∈ s.disjoint_union_closure)\n\n\nlemma set.disjoint_union_closure_inter {α:Type*} (S:set (set α)):\n  (∀ (s t:set α), s ∈ S → t ∈ S → s ∩ t ∈ S) →\n  (∀ (s t:set α), s ∈ S.disjoint_union_closure →\n   t ∈ S.disjoint_union_closure → (s∩ t) ∈ S.disjoint_union_closure) := begin\n  intros h1 s t h2 h3,\n  simp [set.disjoint_union_closure] at h2,\n  simp [set.disjoint_union_closure] at h3,\n  cases h2 with m_s h2,\n  cases h2 with f_s h2,\n  cases h3 with m_t h3,\n  cases h3 with f_t h3,\n  cases h2 with h_in_s h2,\n  cases h2 with h_pairwise_s h_def_s,\n  subst s,\n  cases h3 with h_in_t h3,\n  cases h3 with h_pairwise_t h_def_t,\n  subst t,\n  let f:(fin m_s × fin m_t) → set α := (λ p, f_s p.fst ∩ f_t p.snd),\n  begin\n    have h4:set.Union f_s ∩ set.Union f_t  = set.Union f,\n    { ext ω, split; intros h4_1; simp [f] at h4_1; cases h4_1 with h4_1 h4_2;\n      cases h4_1 with i_s h4_1; cases h4_2 with i_t h4_2;\n      simp [f]; split,\n      { apply exists.intro i_s, apply h4_1 },\n      { apply exists.intro i_t, apply h4_2 },\n      { apply exists.intro i_s, apply h4_1 },\n      { apply exists.intro i_t, apply h4_2 },      \n       },\n   rw h4,\n   apply set.disjoint_union_closure_intro,\n   { intros p, simp [f], apply h1, apply h_in_s, apply h_in_t },\n   { intros i j h_ne, simp [function.on_fun, f],\n     rw disjoint_iff, simp, rw ← set.subset_empty_iff,\n     have h_ne_alt:i.fst ≠ j.fst ∨ i.snd ≠ j.snd,\n     { cases i, cases j, simp, cases classical.em (i_fst = j_fst) with h1 h1,\n       { subst j_fst, right, intros contra, subst j_snd, apply h_ne, simp },\n       simp [h1] },\n     cases h_ne_alt with h_ne_fst h_ne_snd,\n     { apply set.subset.trans, apply set.inter_subset_inter,\n       apply set.inter_subset_left,\n       apply set.inter_subset_left,\n       have h_disj_s := h_pairwise_s i.fst j.fst h_ne_fst,\n       simp [function.on_fun] at h_disj_s, rw disjoint_iff at h_disj_s, simp at h_disj_s,\n       rw set.subset_empty_iff,\n       apply h_disj_s },\n     { apply set.subset.trans, apply set.inter_subset_inter,\n       apply set.inter_subset_right,\n       apply set.inter_subset_right,\n       have h_disj_t := h_pairwise_t i.snd j.snd h_ne_snd,\n       simp [function.on_fun] at h_disj_t, rw disjoint_iff at h_disj_t, simp at h_disj_t,\n       rw set.subset_empty_iff,\n       apply h_disj_t },\n     }, \n  end\nend\n\nlemma set.disjoint_union_closure_univ {α:Type*} (S:set (set α)):\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n   (set.univ ∈ S.disjoint_union_closure) := begin\n  intros h1 h2,\n  rw ← set.compl_empty,\n  apply h1,\n  apply h2,\nend\n\nlemma set.disjoint_union_closure_finite_Inter_finset {α β:Type*} (S:set (set α))\n  {f:β → set α} (T:finset β):\n  (∀ (s t:set α), s ∈ S → t ∈ S → s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (∀ (b:β), (f b) ∈ S.disjoint_union_closure) →\n   ((⋂ i ∈ T, f i) ∈ S.disjoint_union_closure) := begin\n  classical,\n  intros h1 h2 h3 h4,\n  have h5 := set.disjoint_union_closure_univ S h2 h3,\n  apply finset.induction_on T,\n  { simp, apply h5 },\n  { intros a s h_a_notin_s h_ind,\n    simp, apply set.disjoint_union_closure_inter S h1,\n    apply h4, apply h_ind },\nend\n\nlemma set.disjoint_union_closure_finite_Inter {α β:Type*} [fintype β] (S:set (set α))\n  {f:β → set α}:\n  (∀ (s t:set α), s ∈ S → t ∈ S → s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (∀ (b:β), (f b) ∈ S.disjoint_union_closure) →\n   ((⋂ i, f i) ∈ S.disjoint_union_closure) := begin\n  intros h1 h2 h3 h4,\n  have h5:(⋂ i, f i) = (⋂ i ∈ finset.univ, f i),\n  { ext a, split; intros h5_1; simp at h5_1; simp [h5_1],\n    intros i, apply h5_1, apply finset.mem_univ },\n  rw h5,\n  apply @set.disjoint_union_closure_finite_Inter_finset α β S f finset.univ\n    h1 h2 h3 h4,\nend\n\nlemma set.disjoint_union_closure_compl {α:Type*}  (S:set (set α)):\n  (∀ (s t:set α), s ∈ S → t ∈ S → s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (∀ s ∈ S.disjoint_union_closure, sᶜ ∈ S.disjoint_union_closure) := begin\n  intros h1 h2 h3 s h4,\n  rw set.mem_disjoint_union_closure_iff at h4,\n  cases h4 with m h4,\n  cases h4 with f h4,\n  cases h4 with h4 h5,\n  cases h5 with h5 h6,\n  subst s,\n  rw set.compl_Union,\n  apply set.disjoint_union_closure_finite_Inter S h1 h2 h3,\n  intros b, apply h2, apply h4,\n  apply fin.fintype,\nend\n\nlemma set.disjoint_union_closure_diff {α:Type*}  (S:set (set α)):\n  (∀ (s t:set α), s ∈ S → t ∈ S → s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (∀ s t, s ∈ S.disjoint_union_closure → t ∈ S.disjoint_union_closure → \n   (s \\ t) ∈ S.disjoint_union_closure) := begin\n  intros h1 h2 h3 s t h_s h_t,\n  rw set.diff_eq,\n  apply set.disjoint_union_closure_inter S h1,\n  apply h_s,\n  apply set.disjoint_union_closure_compl S h1 h2 h3,\n  apply h_t, \nend\n\n/- A key connection. The closure of a semi-algebra is an algebra. -/\nlemma set.is_semialgebra.disjoint_union_closure {α:Type*} {S:set (set α)} (A:S.is_semialgebra):\n  S.disjoint_union_closure.is_algebra := {\n  univ := set.disjoint_union_closure_univ S (A.compl) (A.empty),\n  diff := set.disjoint_union_closure_diff S (A.inter) (A.compl) (A.empty),\n}\n\nlemma measurable_space.disjoint_union_encodable {α β:Type*} (S:set (set α)) \n  [E:encodable β] (f:β → (set α)):\n  (∀ (b:β), f b ∈ S) →\n  (pairwise (disjoint on f)) →\n  (∅ ∈ S) → \n  (∃ (g:ℕ → (set α)), (set.Union f = set.Union g) ∧ (pairwise (disjoint on g)) \n   ∧ (∀ i, g i ∈ S)) := begin\n  intros h1 h2 h3,\n  let g:ℕ → set α := λ (n:ℕ), (option.map f (encodable.decode2 β n)).get_or_else ∅,\n  begin\n    apply exists.intro g,\n    split,\n    ext1 ω, split; intros h4; simp [g] at h4; simp [h4, g]; cases h4 with i h4,\n    { apply exists.intro (encodable.encode i),\n      rw encodable.encodek2,\n      simp [h4] },\n    destruct (encodable.decode2 β i),\n    { intros h5,\n      rw h5 at h4,\n      simp [option.map, option.get_or_else] at h4,\n      exfalso, apply h4 },\n    { intros b h6, rw h6 at h4,\n      simp [option.map, option.get_or_else] at h4,\n      apply exists.intro b,\n      apply h4 },\n    split,\n    { intros i j h_ne,\n      simp [function.on_fun, g],\n      rw disjoint_iff,\n      destruct (encodable.decode2 β i),\n      { intros h7, simp [h7, option.map, option.get_or_else] },\n      intros i_val h_i,\n      simp [h_i, option.map, option.get_or_else],\n      destruct (encodable.decode2 β j),\n      { intros h8, simp [h8, option.map, option.get_or_else] },\n      intros j_val h_j,\n      simp [h_j, option.map, option.get_or_else],\n      have h9: i_val ≠ j_val,\n      { intros contra, apply h_ne,\n        have h_partial:=@encodable.decode2_is_partial_inv β E,\n        simp [function.is_partial_inv] at h_partial,\n        subst j_val,\n        rw h_partial at h_i,\n        rw h_partial at h_j,\n        rw ← h_i,\n        rw ← h_j },\n      have h10 := h2 i_val j_val h9,\n      simp [function.on_fun, disjoint_iff] at h10,\n      apply h10 },\n    intros i,\n    simp [g],\n    cases (encodable.decode2 β i),\n    repeat {simp [option.map, option.get_or_else, h3, h1]},\n  end\nend \n\n\nlemma measurable_space.closure_union_Union {α:Type*} (S:set (set α)) (f:ℕ → (set α)):\n  (∀ i, f i ∈ S.disjoint_union_closure) →\n  (pairwise (disjoint on f)) →\n  (∅ ∈ S) →  \n  (∃ (g:ℕ → (set α)), (set.Union f = set.Union g) ∧ (pairwise (disjoint on g))\n    ∧ (∀ i, g i ∈ S)) := begin\n  intros h1 h0,\n  have h2 := (λ i, (set.mem_disjoint_union_closure_iff S (f i)).1 (h1 i)),\n  rw classical.skolem at h2,\n  cases h2 with m h2,\n  have h3 := classical.axiom_of_choice h2,\n  cases h3 with f' h3,\n  let f'':(Σ (i:ℕ), fin (m i)) → set α := λ p, f' (p.fst) (p.snd),\n  begin\n    have h4:set.Union f'' = set.Union f,\n    { ext, split; intros h4_1; simp [f''] at h4_1; simp [f'']; cases h4_1 with i h4_1;\n      apply exists.intro i; have h4_2 := (h3 i).right.right,\n      { cases h4_1 with b h4_1,\n        rw h4_2, simp, apply exists.intro b,\n        apply h4_1 },\n      { rw h4_2 at h4_1,\n        simp at h4_1,\n        cases h4_1 with b h4_2,\n        apply exists.intro b,\n        apply h4_2 },\n        },\n    rw ← h4,\n    have h6:∀ i, ∀ (j:fin (m i)), f'' (sigma.mk i j) ⊆ f i,\n    { intros i j, simp [f''], rw (h3 i).right.right,  simp,\n      have h6_1:f' (sigma.mk i j).fst j = f' i j := rfl,\n      rw h6_1, apply set.subset_Union },\n    apply measurable_space.disjoint_union_encodable,\n    { intros b, have h5 := (h3 b.fst).left b.snd, \n      apply h5 },\n    intros i j h_ne,\n    cases i, cases j,\n    simp at h_ne,\n    simp [function.on_fun],\n    rw disjoint_iff,\n    simp [f''],\n    cases classical.em (i_fst = j_fst) with h5 h5,\n    { have h_ne_snd := h_ne h5,\n      subst j_fst,\n      have h_ne_snd2:i_snd ≠ j_snd,\n      { intros contra, apply h_ne_snd, rw contra },\n      have h_disj := (h3 i_fst).right.left i_snd j_snd h_ne_snd2, \n      simp [function.on_fun] at h_disj, rw disjoint_iff at h_disj,  simp at h_disj,\n      apply h_disj },\n    { rw ← set.subset_empty_iff,\n      apply set.subset.trans,\n      apply set.inter_subset_inter,\n      apply h6, apply h6,\n      have h7 := h0 i_fst j_fst h5,\n      simp [function.on_fun] at h7,\n      rw disjoint_iff at h7, simp at h7, simp [h7] },\n  end\nend\n\nlemma set.disjoint_union_closure_Inter {α:Type*} (S:set (set α)) \n  (f:ℕ → (set α)) (j:ℕ):\n  (∀ s t∈ S, s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (∀ i, f i ∈ S.disjoint_union_closure) →\n  ((⋂ (i_1 : ℕ) (H : i_1 < j), f i_1) ∈ S.disjoint_union_closure) := begin\n  intros h1 h2 h3 h4,\n  induction j,\n  { simp, rw ← set.compl_empty, apply h2, apply h3 },\n  { have h5:(⋂ (i_1 : ℕ) (H : i_1 < j_n.succ), f i_1) = \n    (f j_n) ∩ (⋂ (i_1 : ℕ) (H : i_1 < j_n), f i_1),\n    { ext a, split; intros h5_1; simp at h5_1; simp,\n      split,\n      apply h5_1,\n      apply nat.lt_succ_self,\n      intros i h5_2, \n      apply h5_1,\n      apply lt_trans h5_2,\n      apply nat.lt_succ_self,\n      intros i h5_2,\n      cases classical.em (i = j_n) with h5_3 h5_3,\n      subst i,\n      apply h5_1.left,\n      apply h5_1.right,\n      rw lt_iff_le_and_ne,\n      split,\n      rw ← nat.lt_succ_iff,\n      apply h5_2,\n      apply h5_3 },\n    rw h5,\n    apply set.disjoint_union_closure_inter,\n    apply h1,\n    apply h4,\n    apply j_ih },\nend\n\nlemma measurable_space.union_to_disjoint {α:Type*} (S:set (set α)) (f:ℕ → (set α)):\n  (∀ s t∈ S, s ∩ t ∈ S) →\n  (∀ s ∈ S, sᶜ ∈ S.disjoint_union_closure) →  \n  (∅ ∈ S) →\n  (∀ i, f i ∈ S) →\n  (∃ (g:ℕ → (set α)), (set.Union f = set.Union g) ∧ (pairwise (disjoint on g))\n    ∧ (∀ i, g i ∈ S)) := begin\n  intros h1 h2 h3 h4,\n  have h5:∃ f':ℕ → set α, (set.Union f = set.Union f') ∧ (∀ i, f' i ∈ S.disjoint_union_closure) ∧\n  (pairwise (disjoint on f')),\n  { apply exists.intro (set.disjointed f),\n    split,\n    rw set.Union_disjointed,\n    rw and.comm,\n    split,\n    apply set.disjoint_disjointed,\n    intros i,\n    simp [set.disjointed],\n    apply set.disjoint_union_closure_inter,\n    apply h1,\n    apply set.disjoint_union_closure_self,\n    apply h4, \n    apply set.disjoint_union_closure_Inter,\n    apply h1, apply h2, \n    apply h3,\n    intros i,\n    apply h2,\n    apply h4 },\n  cases h5 with f' h5,\n  rw h5.left,\n  apply measurable_space.closure_union_Union S f' h5.right.left h5.right.right,\n  apply h3,\nend\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/monotone_class.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6261241632752915, "lm_q1q2_score": 0.45964997452443}}
{"text": "import ..mcrl2_encap.mcrl2_encap\n\nopen mcrl2\n\nvariable {α : Type}\nvariable [comm_semigroup_with_zero α]\nvariable {β : Type}\n\n/- The relation used to prove congruence of the summation operator.-/\ninductive R_sum {f g} {D : set β} (R_α : ∀a, a ∈ D → mcrl2 α → mcrl2 α → Prop) : \nmcrl2 α → mcrl2 α → Prop \n| R {x y a} {ha} (h : R_α a ha x y) : R_sum x y\n| basel : R_sum (sum D f) (sum D g)\n| baser : R_sum (sum D g) (sum D f)\n| stepl {d} \n  (h₁ : R_sum (sum D f) (sum D g)) (h₁ : R_sum (sum D g) (sum D f))\n  (h₂: d ∈ D) :\n  R_sum (f d) (g d)\n| stepr {d} \n  (h₁ : R_sum (sum D f) (sum D g)) (h₁ : R_sum (sum D g) (sum D f)) \n  (h₂: d ∈ D) :\n  R_sum (g d) (f d)\n\nlemma R_sum.symm {f g} {D : set β} (R_α : ∀a, a ∈ D → mcrl2 α → mcrl2 α → Prop) \n  (R_α_symm : ∀a ha, symmetric (R_α a ha)) :\nsymmetric (@R_sum α _ β f g D R_α) :=\nbegin\n  intros x y h,\n  cases h,\n  { apply R_sum.R,\n    apply R_α_symm,\n    assumption},\n  { apply R_sum.baser},\n  { apply R_sum.basel},\n  { apply R_sum.stepr; assumption},\n  { apply R_sum.stepl; assumption}\nend\n\nlemma bisim.sum {f g : β → mcrl2 α} {D} (h : ∀a, a ∈ D → f a ≈ g a) :\nsum D f ≈ sum D g :=\nbegin\n  choose R R₁x R_bisim using h,\n  apply exists.intro (R_sum R),\n  apply and.intro,\n  exact R_sum.basel,\n  apply and.intro,\n  { intros x y x' a h₁ h₂, \n    cases h₁,\n    { have h : (∃y', transition y a y' ∧ option.rel (R h₁_a h₁_ha) x' y'),\n      by exact bisim_lift (R_bisim h₁_a h₁_ha) h₁_h h₂,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro w,\n      apply and.intro haw,\n      apply option.rel.mono _ hRw,\n      intros x y,\n      apply R_sum.R},\n    { cases h₂,\n      simp [transition.sum_iff, ←exists_and_distrib_right, and_assoc],\n      have h : (∃y', transition (g h₂_a') a y' ∧ option.rel (R h₂_a' h₂_ha') x' y'),\n      by exact bisim_lift (R_bisim h₂_a' h₂_ha') (R₁x h₂_a' h₂_ha') h₂_h,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro w,\n      apply exists.intro h₂_a',\n      apply and.intro h₂_ha',\n      apply and.intro haw,\n      apply option.rel.mono _ hRw,\n      intros x y,\n      exact R_sum.R},\n    { cases h₂,\n      simp [transition.sum_iff, ←exists_and_distrib_right, and_assoc],\n      have h : (∃y', transition (f h₂_a') a y' ∧ option.rel (R h₂_a' h₂_ha') x' y'),\n      by exact bisim_lift (R_bisim h₂_a' h₂_ha') ((R_bisim h₂_a' h₂_ha').right (R₁x h₂_a' h₂_ha')) h₂_h,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro w,\n      apply exists.intro h₂_a',\n      apply and.intro h₂_ha',\n      apply and.intro haw,\n      apply option.rel.mono _ hRw,\n      intros x y,\n      exact R_sum.R},\n    { have h : (∃y', transition (g h₁_d) a y' ∧ option.rel (R h₁_d h₁_h₂) x' y'),\n      by exact bisim_lift (R_bisim h₁_d h₁_h₂) (R₁x h₁_d h₁_h₂) h₂,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro w,\n      apply and.intro haw,\n      apply option.rel.mono _ hRw,\n      intros x y,\n      exact R_sum.R},\n    { have h : (∃y', transition (f h₁_d) a y' ∧ option.rel (R h₁_d h₁_h₂) x' y'),\n      by exact bisim_lift (R_bisim h₁_d h₁_h₂) ((R_bisim h₁_d h₁_h₂).right (R₁x h₁_d h₁_h₂)) h₂,\n      rcases h with ⟨w, haw, hRw⟩,\n      apply exists.intro w,\n      apply and.intro haw,\n      apply option.rel.mono _ hRw,\n      intros x y,\n      exact R_sum.R}},\n    { choose R_bisim R_symm using R_bisim,\n      exact R_sum.symm R R_symm}\nend", "meta": {"author": "Wolfb34", "repo": "mucrl2lean_public", "sha": "0d687d0ad00a6f276f1c1e9acbfc3dd4c0b2ce39", "save_path": "github-repos/lean/Wolfb34-mucrl2lean_public", "path": "github-repos/lean/Wolfb34-mucrl2lean_public/mucrl2lean_public-0d687d0ad00a6f276f1c1e9acbfc3dd4c0b2ce39/Lean/mcrl2_sum/sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772883, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.45938114349624176}}
{"text": "import geometry.tarski_6\nopen classical set\nnamespace Euclidean_plane\nvariables {point : Type} [Euclidean_plane point]\n\nlocal attribute [instance, priority 0] prop_decidable \n\ntheorem col_of_perp {a b p q : point} : p ≠ q → R a p q → R b p q → col p a b :=\nλ h, not_3dim (seven12b h.symm).symm (seven5 p q).2\n\ntheorem coplanar {a : point} (b : point) {A : set point} : line A → a ∉ A → b ∈ pl A a :=\nbegin\nintros h h1,\ncases exists_of_exists_unique (eight17 h h1) with p hp,\nby_cases h2 : b ∈ A,\n  exact or.inr (or.inl h2),\ncases ten15 h hp.2.2.1 h2 with c hc,\nsuffices : col p a c,\n  by_cases h_1 : B c p a,\n    apply (or.inr (or.inr ((nine8 _).2 hc.2).symm)),\n    exact ⟨h, (nine11 hc.2).2.1, h1, p, hp.2.2.1, h_1⟩,\n  apply or.inl (hc.2.symm.trans _),\n  exact nine12 h hp.2.2.1 (six4.2 ⟨(four11 this).2.2.2.1, h_1⟩) (nine11 hc.2).2.1,\nrcases six22 h hp.2.2.1 with ⟨q, h3, h4⟩,\nsubst h4,\napply col_of_perp h3,\n  suffices : xperp p (l p q) (l a p),\n    exact (this.2.2.2.2 (six17b p q) (six17a a p)).symm,\n  exact eight15 ⟨p, hp⟩ (six17a p q) (six17b a p),\nsuffices : xperp p (l p q) (l c p),\n  exact (this.2.2.2.2 (six17b p q) (six17a c p)).symm,\nexact eight15 hc.1 (six17a p q) (six17b c p)\nend\n\ndef Pl : set point := planeof (P1 : point) P2 P3\n\ntheorem planePl : plane (Pl : set point) := ⟨P1, P2, P3, six24, rfl⟩\n\ntheorem in_Pl {a : point} : a ∈ (Pl : set point) :=\ncoplanar a (six14 (six26 six24).1) six24\n\ntheorem unique_plane {Q : set point} : plane Q → Q = Pl :=\nbegin\nrintros ⟨x, y, z, h, h1⟩,\nsubst h1,\nexact (nine26 h planePl in_Pl in_Pl in_Pl).symm\nend\n\ntheorem unique_perp (a : point) {L : set point} : line L → ∃! A : set point, a ∈ A ∧ perp L A :=\nbegin\nintro h,\nby_cases h_1 : a ∈ L,\n  rcases six22 h h_1 with ⟨b, h1, hb⟩,\n  subst hb,\n  rcases eight21 h1 a with ⟨p, t, hp, ht⟩,\n  clear ht,\n  replace hp := eight15 hp (six17a a b) (six17b p a),\n  refine exists_unique.intro (l p a) ⟨six17b p a, a, hp⟩ _,\n  intros Y hy,\n  apply six18 (eight14e hy.2).2 (six13 hp.2.1) _ hy.1,\n  rcases six22 (eight14e hy.2).2 hy.1 with ⟨z, hz, h5⟩,\n  subst h5,\n  replace hy := (eight15 hy.2 (six17a a b) (six17a a z)).symm.2.2.2.2,\n  exact col_of_perp h1 (hy (six17b a z) (six17b a b)) (hp.symm.2.2.2.2 (six17a p a) (six17b a b)),\ncases eight17 h h_1 with x hx,\ndsimp at hx,\nrefine ⟨l a x, ⟨(six17a a x), x, hx.1⟩, _⟩,\nrintros Y ⟨h1, y, h2⟩,\nsuffices : Y = l a y,\n  subst this,\n  rw (hx.2 y h2),\napply six18 h2.2.1 _ h1 h2.2.2.2.1,\nintro h_2,\nsubst y,\nexact h_1 h2.2.2.1\nend\n\ntheorem unique_xperp {a : point} {L : set point} : line L → a ∈ L → ∃! A : set point, xperp a L A :=\nbegin\nintros h h1,\nrcases (unique_perp a h) with ⟨A, h2, h3⟩,\nexact ⟨A, eight15 h2.2 h1 h2.1, λ Y hy, h3 Y ⟨hy.2.2.2.1, a, hy⟩⟩\nend\n\ntheorem eleven15d {a b c d : point} (h : eqa a b c a b d) (h1 : line (l a b)) : sided b c d ∨ sided b c (Sl (l a b) d) :=\nbegin\nby_cases h_1 : col a b c,\n  left,\n  cases six1 h_1,\n    exact ⟨h.2.1, h.2.2.2.1, five2 h.1 h_2 (eleven21b h_2 h)⟩,\n  exact h_2.symm.trans ((eleven21a h_2).1 h),\ncases coplanar d h1 h_1,\n  exact or.inl (eleven15c h h_2.symm),\ncases h_2,\n  exact (h_1 (eleven21d h_2 h.symm)).elim,\nright,\nhave h2 : side (l a b) c (Sl (l a b) d),\n  exact ⟨d, h_2, (ten14 h1 h_2.2.2.1).symm⟩,\napply eleven15c (h.trans _) h2,\nsimpa [ten3b h1 (six17a a b), ten3b h1 (six17b a b)] using eleven12a h1 h.1 h.2.2.2.1\nend\n\n-- Parallel lines\n\ndef dpar (A B : set point) : Prop := line A ∧ line B ∧ ¬∃ x, x ∈ A ∧ x ∈ B\n\ndef par (A B : set point) : Prop := dpar A B ∨ line A ∧ A = B\n\ntheorem dpar_of_par_neq {A B : set point} : par A B → A ≠ B → dpar A B :=\nλ h h1, h.elim id (λ h_1, absurd h_1.2 h1)\n\ntheorem line_of_par {A B : set point} : par A B → line A ∧ line B :=\nλ h, h.elim (λ h, ⟨h.1, h.2.1⟩) (λ h, ⟨h.1, h.2 ▸ h.1⟩)\n\ntheorem not_par_of_perp {A B : set point} : perp A B → ¬par A B :=\nbegin\nintro h,\ncases h with x hx,\nintro h_1,\ncases h_1,\n  exact h_1.2.2 ⟨x, hx.2.2.1, hx.2.2.2.1⟩,\nexact (eight14b hx) h_1.2\nend\n\ntheorem is_iff_not_par {A B : set point} : (∃ x, is x A B) ↔ line A ∧ line B ∧ ¬par A B :=\nbegin\nsplit,\n  intro h,\n  cases h with x hx,\n  refine ⟨hx.1, hx.2.1, _⟩,\n  intro h_1,\n  cases h_1,\n    exact h_1.2.2 ⟨x, hx.2.2.2.1, hx.2.2.2.2⟩,\n  exact hx.2.2.1 h_1.2,\nrintro ⟨h, h1, h2⟩,\nrw [par, not_or_distrib] at h2,\nhave h3 : ∃ x, x ∈ A ∧ x ∈ B,\n  by_contradiction h_1,\n  exact h2.1 ⟨h, h1, h_1⟩,\ncases h3 with x hx,\nrefine ⟨x, h, h1, _, hx.1, hx.2⟩,\nintro h_1,\nsubst B,\nexact h2.2 ⟨h1, rfl⟩\nend\n\ntheorem twelve1 {A B : set point} : dpar A B → A ≠ B :=\nbegin\nintros h h1,\nrcases h.1 with ⟨x, y, h2, h3⟩,\nsubst_vars,\nexact h.2.2 ⟨x, six17a x y, six17a x y⟩\nend\n\ntheorem twelve2 {A B : set point} {a : point} : dpar A B → a ∈ A → a ∉ B :=\nλ h h1 h2, h.2.2 ⟨a, h1, h2⟩\n\ntheorem twelve3 {a b c : point} : par (l a b) (l a c) → col a b c :=\nbegin\nintro h,\ncases h,\n  exact (h.2.2 ⟨a, six17a a b, six17a a c⟩).elim,\nchange c ∈ l a b,\nsimp [h.2]\nend\n\ntheorem par.refl {A : set point} : line A → par A A :=\nλ h, or.inr ⟨h, rfl⟩\n\ntheorem dpar.symm {A B : set point} : dpar A B → dpar B A :=\nλ h, ⟨h.2.1, h.1, λ ⟨x, hx⟩, h.2.2 ⟨x, hx.symm⟩⟩\n\ntheorem par.symm {A B : set point} : par A B → par B A :=\nλ h, h.elim (λ h, or.inl h.symm) (λ h, or.inr ⟨h.2 ▸ h.1, h.2.symm⟩)\n\ntheorem twelve5 {A B : set point} {x : point} : par A B → x ∈ A → x ∈ B → A = B :=\nλ h h1 h2, h.elim (λ h, (h.2.2 ⟨x, h1, h2⟩).elim) (and.right)\n\ntheorem twelve6 {A B : set point} : dpar A B → ∀ {b b'}, b ∈ B → b' ∈ B → side A b b' :=\nbegin\nintros h b b' h1 h2,\nhave h3 : b ∉ A,\n  intro h_1,\n  exact h.2.2 ⟨b, h_1, h1⟩,\ncases coplanar b' h.1 h3,\n  exact h_1.symm,\ncases h_1,\n  exact (h.2.2 ⟨b', h_1, h2⟩).elim,\ncases h_1.2.2.2 with x hx,\napply (h.2.2 ⟨x, hx.1, _⟩).elim,\nsuffices : B = l b b',\n  rw this,\n  exact or.inr (or.inl hx.2.symm),\nexact six18 h.2.1 (nine2 h_1) h1 h2\nend\n\ntheorem twelve7 {a b c d : point} : dpar (l a b) (l c d) ↔ side (l a b) c d ∧ ¬∃ x, col a b x ∧ col c d x :=\nbegin\nsplit,\n  intro h,\n  refine ⟨twelve6 h (six17a c d) (six17b c d), _⟩,\n  rintros ⟨x, hx⟩,\n  exact h.2.2 ⟨x, hx.1, hx.2⟩,\nrintros ⟨h, h1⟩,\nhave h2 := six13 (nine11 h).1,\nhave h3 : c ≠ d,\n  intro h_1,\n  subst d,\n  exact h1 ⟨b, or.inl (three1 a b), or.inl (three3 c b)⟩,\nrefine ⟨six14 h2, six14 h3, λ h_1, _⟩,\ncases h_1 with x hx,\nexact h1 ⟨x, hx.1, hx.2⟩\nend\n\ntheorem twelve9 {A B C : set point} : perp A C → perp B C → par A B :=\nbegin\nintros h h1,\nby_cases h_1 : A = B,\n  exact or.inr ⟨(eight14e h).1, h_1⟩,\nrefine or.inl ⟨(eight14e h).1, (eight14e h1).1, λ h_2, _⟩,\ncases h_2 with x hx,\napply h_1,\nexact unique_of_exists_unique (unique_perp x (eight14e h1).2) ⟨hx.1, h.symm⟩ ⟨hx.2, h1.symm⟩\nend\n\ntheorem twelve10 {A : set point} {a : point} : line A → ∃ B, par A B ∧ a ∈ B :=\nbegin\nintro h,\nby_cases h1 : a ∈ A,\n  exact ⟨A, or.inr ⟨h, rfl⟩, h1⟩,\ncases exists_of_exists_unique (unique_perp a h) with C hc,\ncases exists_of_exists_unique (unique_perp a (eight14e hc.2).2) with B hb,\nexact ⟨B, twelve9 hc.2 hb.2.symm, hb.1⟩\nend\n\ntheorem twelve11 {A B C : set point} {a : point} : line A → a ∉ A → par A B → a ∈ B → par A C → a ∈ C → B = C :=\nbegin\nintros h h1 h2 h3 h4 h5,\nreplace h2 : dpar A B,\n  apply h2.elim (id),\n  intro h_2,\n  exact (h1 (h_2.2.symm ▸ h3)).elim,\nreplace h4 : dpar A C,\n  apply h4.elim (id),\n  intro h_2,\n  exact (h1 (h_2.2.symm ▸ h5)).elim,\nby_contradiction h_1,\nrcases h with ⟨s, t, h, h6⟩,\nsubst h6,\nsuffices : ∃ c', c' ∈ C ∧ Bl t B c',\n  rcases this with ⟨c', hc1, hc2⟩,\n  cases hc2.2.2.2 with b hb,\n  cases three14 c' a with c hc,\n  cases pasch hc.1.symm hb.2 with d hd,\n  have h6 : a ≠ b,\n    intro h_2,\n    subst b,\n    suffices : c' ≠ a,\n      apply twelve2 h4 (six17b s t),\n      rw (six18 h4.2.1 this hc1 h5),\n      exact or.inl hb.2.symm,\n    intro h_2,\n    subst h_2,\n    exact hc2.2.2.1 h3,\n  have h7 : c ∈ C,\n    rw (six18 h4.2.1 _ hc1 h5),\n    exact or.inl hc.1,\n    intro h_2,\n    subst h_2,\n    exact hc2.2.2.1 h3,\n  suffices : a ≠ d,\n    rcases euclids hd.1 hd.2 this with ⟨⟨x, y⟩, hx, hy, ht⟩,\n    suffices : side (l s t) a t,\n      exact (nine11 this).2.2 (six17b s t),\n    apply nine17a (twelve6 h2 h3 _) (twelve6 h4 h5 _) ht,\n      rw six18 h2.2.1 h6 h3 hb.1,\n      exact or.inl hx,\n    rw six18 h4.2.1 hc.2 h5 h7,\n    exact or.inl hy,\n  intro h_2,\n  subst h_2,\n  apply h_1,\n  rw [six18 h2.2.1 h6 h3 hb.1, six18 h4.2.1 hc.2 h5 h7],\n  exact six16 h6 hc.2 (or.inr (or.inr hd.2.symm)),\ncases six22 h4.2.1 h5 with x hx,\nrw hx.2,\ncases coplanar x h2.2.1 (twelve2 h2 (six17b s t)),\n  refine ⟨S a x, (seven24 (six14 hx.1) (six17a a x)).1 (six17b a x), _⟩,\n  exact (nine8 (nine1 h2.2.1 h3 (nine11 h_2).2.1)).2 h_2,\ncases h_2,\n  apply (h_1 _).elim,\n  apply six21 hx.1 h2.2.1 h4.2.1 h3 h5 h_2,\n  rw hx.2,\n  simp,\nexact ⟨x, six17b a x, h_2⟩\nend\n\ntheorem twelve13 {A : set point} (a : point) : line A → ∃! B, par A B ∧ a ∈ B :=\nbegin\nintro h,\napply exists_unique_of_exists_of_unique,\n  exact twelve10 h,\nintros X Y hx hy,\nby_cases h_1 : a ∈ A,\n  exact (twelve5 hx.1 h_1 hx.2).symm.trans (twelve5 hy.1 h_1 hy.2),\nexact twelve11 h h_1 hx.1 hx.2 hy.1 hy.2\nend\n\ntheorem par.trans {A B C : set point} : par A B → par B C → par A C :=\nbegin\nintros h h1,\ncases h,\n  cases h1,\n    rw [par, or_iff_not_and_not],\n    simp [h.1],\n    intro h2,\n    replace h2 : ∃ x, x ∈ A ∧ x ∈ C,\n      by_contradiction h_1,\n      exact h2 ⟨h.1, h1.2.1, h_1⟩,\n    cases h2 with x hx,\n    exact twelve11 h.2.1 (twelve2 h hx.1) (or.inl h.symm) hx.1 (or.inl h1) hx.2,\n  rw h1.2.symm,\n  exact or.inl h,\nrwa h.2\nend\n\ntheorem twelve17 {a b c d p : point} : M a p c → M b p d → a ≠ b → par (l a b) (l c d) :=\nbegin\nintros h h1 h2,\nreplace h := seven6 h,\nreplace h1 := seven6 h1,\nrw [h, h1],\nby_cases h3 : col a b p,\n  refine or.inr ⟨six14 h2, six18 (six14 h2) (two7 (seven13 p a b) h2) _ _⟩;\n  apply (seven24 (six14 h2) h3).1;\n  simp,\nrefine or.inl ⟨six14 h2, six14 (two7 (seven13 p a b) h2), _⟩,\nintro h_1,\nrcases h_1 with ⟨x, hx1, hx2⟩,\nhave h4 : x ≠ p,\n  intro h_1,\n  subst p,\n  exact h3 hx1,\nsuffices : l a b = l (S p a) (S p b),\n  apply h3,\n  apply (six27 (six14 h2) (six17a a b) _ (seven5 p a).1),\n  simpa [this],\napply six21 (seven12b h4).symm (six14 h2) (six14 (two7 (seven13 p a b) h2)) hx1 hx2,\n  rw [←seven7 p a, ←seven7 p b],\n  exact (S_of_col p).1 hx2,\nexact (S_of_col p).1 hx1\nend\n\ntheorem par_of_S {a b : point} (p : point) : a ≠ b → par (l a b) (l (S p a) (S p b)) :=\ntwelve17 (seven5 p a) (seven5 p b)\n\ntheorem twelve18 {a b c d p : point} : eqd a b c d → eqd b c d a → ¬col a b c → b ≠ d → col a p c → \ncol b p d → par (l a b) (l c d) ∧ par (l b c) (l d a) ∧ Bl b (l a c) d ∧ Bl a (l b d) c :=\nbegin\nintros h h1 h2 h3 h4 h5,\nhave h6 := seven21 h2 h3 h h1 h4 h5,\nrefine ⟨twelve17 h6.1 h6.2 (six26 h2).1, twelve17 h6.2 h6.1.symm (six26 h2).2.1, _⟩,\nsplit,\n  rw seven6 h6.2,\n  exact nine1 (six14 (six26 h2).2.2) (four11 h4).1 (four10 h2).1,\nrw seven6 h6.1,\napply nine1 (six14 h3) (four11 h5).1,\nintro h_1,\nsuffices : c ∈ l b d,\n  exact h2 (six23.2 ⟨l b d, six14 h3, h_1, six17a b d, this⟩),\nrw seven6 h6.1,\nexact (seven24 (six14 h3) (four11 h5).1).1 h_1\nend\n\ntheorem twelve19 {a b c d : point} : ¬col a b c → par (l a b) (l c d) → par (l b c) (l d a) → \neqd a b c d ∧ eqd b c d a ∧ Bl b (l a c) d ∧ Bl a (l b d) c :=\nbegin\nintros h h1 h2,\ngeneralize hp : mid a c = p,\nreplace hp : c = S p a,\n  rw ←hp,\n  exact (mid_to_Sa a c).symm,\nsubst c,\nhave h3 : eqd b (S p a) (S p b) a,\n  have h4 := seven13 p b (S p a),\n  simpa using h4,\nhave h4 := twelve18 (seven13 p a b) h3 h _ (or.inl (seven5 p a).1) (or.inl (seven5 p b).1),\n  suffices : d = S p b,\n    rw this,\n    exact ⟨seven13 p a b, h3, h4.2.2.1, h4.2.2.2⟩,\n  have h5 := twelve3 (h1.symm.trans h4.1),\n  have h6 := (h2.symm.trans h4.2.1),\n  rw [six17, six17 (S p b) a] at h6,\n  replace h6 := twelve3 h6,\n  by_contradiction h_1,\n  apply h,\n  rw S_of_col p,\n  simp,\n  exact (four11 (five4 (ne.symm h_1) (four11 h5).2.2.2.2 (four11 h6).2.2.2.2)).2.1,\napply (seven12b _).symm,\nintro h_1,\nsubst p,\nexact h (or.inl (seven5 b a).1)\nend\n\ntheorem twelve20 {a b c d : point} : par (l a b) (l c d) → eqd a b c d → Bl b (l a c) d → \npar (l b c) (l d a) ∧ eqd b c d a ∧ Bl a (l b d) c :=\nbegin\nintros h h1 h2,\ngeneralize hp : mid b d = p,\nreplace hp : d = S p b,\n  rw ←hp,\n  exact (mid_to_Sa b d).symm,\nsubst d,\nhave h3 : p ∉ l a b,\n  intro h_1,\n  suffices : a ∈ l c (S p b),\n    exact h2.2.2.1 (four11 this).2.2.2.1,\n  suffices : l a b = l c (S p b),\n    simpa [this.symm],\n  exact twelve5 h ((seven24 (line_of_par h).1 h_1).1 (six17b a b)) (six17b c (S p b)),\nhave h4 : par (l b (S p a)) (l (S p b) a),\n  suffices : par(l b (S p a)) (l (S p b) (S p (S p a))),\n    simpa [this],\n  apply par_of_S p,\n  intro h_1,\n  subst b,\n  exact (four10 h3).1 (or.inl (seven5 p a).1),\nhave h5 := twelve19 (λ h_1, h3 (six27 (six14 (six26 h2.2.1).2.2) (six17a a b) h_1 (seven5 p a).1)) (par_of_S p (six26 h2.2.1).2.2) h4,\nsuffices : c = S p a,\n  subst c,\n  exact ⟨h4, h5.2.1, h5.2.2.2⟩,\nhave h6 := h.symm.trans (par_of_S p (six26 h2.2.1).2.2),\nrw [six17, six17 (S p a)] at h6,\napply six11a (six4.2 ⟨(four11 (twelve3 h6)).2.1, _⟩) (h1.symm.flip.trans (seven13 p a b).flip),\nintro h_1,\nhave h7 : p ∉ l a c,\n  intro h_2,\n  apply h2.2.1,\n  apply six27 h2.1 ((seven24 h2.1 h_2).1 (six17b a c)) (six17a a c),\n  rw [←seven7 p a, ←seven7 p b],\n  exact (seven15 p).1 h_1,\napply nine9 h2,\nsuffices : side (l a c) (S p a) (S p c),\n  apply side.trans _ (this.symm.trans _),\n    suffices : sided a b (S p c),\n      exact nine12 h2.1 (six17a a c) this h2.2.1,\n    apply six7 _ (six26 h2.2.1).2.2.symm,\n    rw [←seven7 p a, ←seven7 p b],\n    exact (seven15 p).1 h_1.symm,\n  suffices : sided c (S p b) (S p a),\n    exact (nine12 h2.1 (six17b a c) this h2.2.2.1).symm,\n  exact six7 h_1 (six13 (line_of_par h).2).symm,\nsuffices : side (l a c) p (S p a),\n  apply this.symm.trans,\n  apply nine12 h2.1 (six17b a c) (six7 (seven5 p c).1 _) h7,\n  intro h_1,\n  subst p,\n  exact h7 (six17b a c),\napply nine12 h2.1 (six17a a c) (six7 (seven5 p a).1 _) h7,\nintro h_1,\nsubst p,\nexact h7 (six17a a c)\nend\n\ntheorem twelve21 {a b c d : point} : Bl b (l a c) d → (par (l a b) (l c d) ↔ eqa b a c d c a) :=\nbegin\nintro h,\ncases exists_of_exists_unique (six11 (six26 h.2.2.1).2.1.symm\n  (six26 h.2.1).2.2) with d' hd,\nreplace h : Bl b (l a c) d',\n    apply ((nine8 h.symm).2 _).symm,\n    exact nine12 h.1 (six17b a c) hd.1.symm h.2.2.1,\nsplit,\n  intro h1,\n  rw (six16a hd.1.symm) at h1,\n  suffices : eqa b a c d' c a,\n    exact eleven10 this (six5 this.1) (six5 this.2.1) hd.1.symm (six5 this.2.2.2.1),\n  apply eleven11 (six13 (line_of_par h1).1).symm (six13 h.1).symm,\n  exact ⟨hd.2.symm.flip, eqd_refl a c, (twelve20 h1 hd.2.symm h).2.1⟩,\nintro h1,\nreplace h1 := eleven10 h1 (six5 h1.1) (six5 h1.2.1) hd.1 (six5 h1.2.2.2.1),\nrw (six16a hd.1.symm),\napply (twelve18 hd.2.symm (SAS h1 hd.2.symm.flip (eqd_refl c a)).1 (four10 h.2.1).1 (nine2 h) (or.inl (ten1 a c).1) _).1,\nsuffices : d' = S (mid a c) b,\n  rw this,\n  exact or.inl (seven5 (mid a c) b).1,\napply six11a _,\n  apply hd.2.trans,\n  suffices : eqd a b (S (mid a c) a) (S (mid a c) b),\n    simpa [(mid_to_Sa a c)] using this,\n  exact (seven13 (mid a c) a b),\napply eleven15b h.2.2.1 h.2.2.1 (eqa.refl h1.2.2.2.1 h1.2.2.1) (side.refla h.2.2.1),\n  apply h1.symm.flip.trans,\n  simpa [mid_to_Sa a c, mid_to_Sb a c] using (eleven12 (mid a c) h1.2.1 h1.1),\nexact ((nine8 h.symm).1 ((nine1 h.1 (or.inr (or.inl (ten1 a c).1.symm)) h.2.1).symm)).symm\nend\n\ntheorem twelve22 {a b c d p : point} : sided p a c → side (l p a) b d → (par (l a b) (l c d) ↔ eqa b a p d c p) :=\nbegin\nintros h h1,\ngeneralize hp : mid p a = q,\nreplace hp : p = S q a,\n  rw ←hp,\n  exact (mid_to_Sb p a).symm,\nsubst p,\nhave h2 := eleven12 q (six26 (nine11 h1).2.1).2.1.symm h.1.symm,\nrw seven7 at h2,\nreplace h2 := eleven10 h2 (six5 h2.1) (six5 h2.2.1) (six5 h2.2.2.1) h.symm,\nhave h3 := par_of_S q (six26 (nine11 h1).2.1).2.1,\nhave h4 : Bl (S q b) (l (S q a) c) d,\n  exact (six16a h) ▸ ((nine8 (nine1 (nine11 h1).1 (or.inr (or.inl (seven5 q a).1)) (nine11 h1).2.1)).2 h1).symm,\nexact ⟨λ h5, h2.trans ((twelve21 h4).1 (h3.symm.trans h5)), λ h5, h3.trans ((twelve21 h4).2 (h2.symm.trans h5))⟩\nend\n\ntheorem twelve23 {a b c : point} : ¬col a b c → ∃ b' c', Bl b (l a c) b' ∧ Bl c (l a b) c' ∧ \nB b' a c' ∧ eqa a b c b a c' ∧ eqa a c b c a b' :=\nbegin\nintro h,\nhave h1 := nine1 (six14 (six26 h).2.2) (or.inr (or.inl (ten1 a c).1.symm)) (four10 h).1,\nhave h2 := nine1 (six14 (six26 h).1) (or.inr (or.inl (ten1 a b).1.symm)) h,\nhave h3 := eleven12 (mid a b) (six26 h).1 (six26 h).2.1.symm,\nhave h4 := eleven12 (mid a c) (six26 h).2.2 (six26 h).2.1,\nsimp at h3 h4,\nrefine ⟨S (mid a c) b, S (mid a b) c, h1, h2, _, h3, h4⟩,\nhave h5 : col a (S (mid a c) b) (S (mid a b) c),\n  apply twelve3,\n  rw six17 at h1 h2,\n  suffices : par (l b c) (l a (S (mid a c) b)),\n    exact this.symm.trans ((twelve21 h2).2 h3.flip),\n  exact six17 c b ▸ ((twelve21 h1).2 h4.flip),\nexact ((nine18 h2.1 (six17a a b) (four11 h5).2.2.1).1 ((nine8 h2).2 (nine15 (λ h_1, h (mid_to_Sa a c\n ▸ (seven24 h2.1 h_1).1 (six17a a b))) (ten1 a c).1 (seven5 (mid a c) b).1))).1\nend\n\ntheorem thirteen8 {o p q u v : point} : col o p q → col o u v → o ≠ u → o ≠ v → R o u p → R o v q → \n(sided o p q ↔ sided o u v) :=\nbegin\nintros h h1 h2 h3 h4 h5,\nby_cases h_1 : col o u p,\n  cases eight9 h4 h_1,\n    exact (h2 h_2).elim,\n  subst p,\n  cases eight9 h5 (five4 h2 h1 h),\n    exact (h3 h_2).elim,\n  rw h_2,\nhave h6 : q ≠ v,\n  intro h_1,\n  subst q,\n  exact h_1 (six23.2 ⟨l o v, six14 h3, six17a o v, (four11 h1).1, (four11 h).1⟩),\nhave h7 : xperp u (l o u) (l p u),\n  exact eight13.2 ⟨six14 h2, six14 (six26 h_1).2.1.symm, six17b o u, six17b p u, o, p, six17a o u, six17a p u, h2, (six26 h_1).2.1.symm, h4⟩,\nhave h8 : xperp v (l o u) (l q v),\n  exact eight13.2 ⟨six14 h2, six14 h6, h1, six17b q v, o, q, six17a o u, six17a q v, h3, h6, h5⟩,\ncases exists_of_exists_unique (unique_perp o (six14 h2)) with L hl,\nreplace h7 := twelve9 hl.2.symm ⟨u, h7.symm⟩,\nreplace h8 := twelve9 hl.2.symm ⟨v, h8.symm⟩,\ncases h7,\n  cases h8,\n    replace h7 := twelve6 h7 (six17a p u) (six17b p u),\n    replace h8 := twelve6 h8 (six17a q v) (six17b q v),\n    split,\n      intro h9,\n      apply (nine19 (nine11 h7).1 hl.1 (four11 h1).2.2.1 (h7.symm.trans (side.trans _ h8))).1,\n      exact nine12 (nine11 h7).1 hl.1 h9 (nine11 h7).2.1,\n    intro h9,\n    apply (nine19 (nine11 h7).1 hl.1 (four11 h).2.2.1 (h7.trans (side.trans _ h8.symm))).1,\n    exact nine12 (nine11 h7).1 hl.1 h9 (nine11 h7).2.2,\n  rw h8.2 at *,\n  exact ((eight9 h5.symm hl.1).elim h6 h3).elim,\nrw h7.2 at *,\nexact (h_1 (four11 hl.1).2.2.2.2).elim\nend\n\nlemma twelve24a {a b c d e f x y : point} : eqa a b c d e f → xperp x (l b c) (l a x) → xperp y (l e f) (l d y) → sided b c x → sided e f y :=\nbegin\nintros h h1 h2 h3,\nreplace h := eleven10 h (six5 h.1) h3.symm (six5 h.2.2.1) (six5 h.2.2.2.1),\nrw (six16a h3) at h1,\nclear h3,\nrcases eleven5.1 h with ⟨p, q, h3⟩,\nhave h4 : R e q p,\n  exact eleven17 (h1.2.2.2.2 (six17a b x) (six17a a x)) (eleven11 h.2.1.symm (six13 h1.2.1) (four4 h3.2.2).2.2.1),\nhave h5 : R e y d,\n  exact h2.2.2.2.2 (six17a e f) (six17a d y),\napply h3.2.1.symm.trans ((thirteen8 (four11 (six4.1 h3.1).1).2.1 _ h3.2.1.1.symm _ h4 h5).1 h3.1),\n  show y ∈ l e q,\n  rw six16a h3.2.1,\n  exact h2.2.2.1,\nintro h_1,\nsubst y,\nhave h6 : R d e f,\n  exact h2.symm.2.2.2.2 (six17a d e) (six17b e f),\napply h.2.1,\nexact eight7 (h1.symm.2.2.2.2 (six17a a x) (six17a b x)) (eleven17 h6 h.symm)\nend\n\ntheorem twelve24 {a b c d e f x y : point} : eqa a b c d e f → xperp x (l b c) (l a x) → xperp y (l e f) (l d y) → (sided b c x ↔ sided e f y) :=\nλ h h1 h2, ⟨twelve24a h h1 h2, twelve24a h.symm h2 h1⟩\n\ntheorem twelve25 {A B C : set point} : par A B → perp A C → perp B C :=\nbegin\nintros h h1,\nhave h2 : ¬par B C,\n  intro h_1,\n  exact (not_par_of_perp h1) (h.trans h_1),\ncases is_iff_not_par.2 ⟨(line_of_par h).2, (eight14e h1).2, h2⟩ with x hx,\ncases exists_of_exists_unique (unique_perp x hx.2.1) with L hl,\nsuffices : B = L,\n  subst L,\n  exact hl.2.symm,\napply unique_of_exists_unique (twelve13 x (line_of_par h).1) ⟨h, hx.2.2.2.1⟩,\nexact ⟨twelve9 h1 hl.2.symm, hl.1⟩\nend\n\n-- distance + angle interface\n\ninstance eqd_setoid : setoid (point × point) :=\n{ r := λ a b, eqd a.1 a.2 b.1 b.2,\n  iseqv := ⟨ λ ⟨a,b⟩, eqd.refl a b, λ ⟨a,b⟩ ⟨c,d⟩, eqd.symm, λ ⟨a,b⟩ ⟨c,d⟩ ⟨e,f⟩, eqd.trans⟩\n}\n\ndefinition dist (point : Type) [Euclidean_plane point] := \nquotient (@Euclidean_plane.eqd_setoid point _)\n\ninstance dist_order : linear_order (dist point) :=\n{ le := λ a b, quotient.lift_on₂ a b (λ x y, distle x.1 x.2 y.1 y.2) (λ a b c d h h1,\n    begin rw ←iff_iff_eq, split; intro h2, exact five6 h2 h h1, exact five6 h2 h.symm h1.symm end),\n  le_refl := λ a, quotient.induction_on a $ λ x, distle.refl x.1 x.2,\n  le_trans := λ a b c, quotient.induction_on₃ a b c $ λ x y z, distle.trans,\n  le_antisymm := λ a b, quotient.induction_on₂ a b $\n    λ x y h h1, quotient.sound (five9 h h1),\n  le_total := λ a b, quotient.induction_on₂ a b $\n    λ x y, five10 x.1 x.2 y.1 y.2 }\n\ninstance zero_dist : has_zero (dist point) := ⟨⟦(P1, P1)⟧⟩\n\n@[simp] theorem zero_dist_def : ⟦(P1, P1)⟧ = (0 : dist point) := rfl\n\n@[simp] theorem zero_class (a : point) : ⟦(a, a)⟧ = (0 : dist point) :=\nquotient.sound (two8 a P1)\n\ntheorem eq_of_zero_dist {a b  : point} : ⟦(a, b)⟧ = (0 : dist point) → a = b :=\nλ h, id_eqd (quotient.exact (h.trans zero_dist_def.symm))\n\ntheorem non_zero_dist_of_neq {a b : point} : a ≠ b → ⟦(a, b)⟧ ≠ (0 : dist point) :=\nλ h h1, h (id_eqd (quotient.exact h1))\n\ndef seg_cons_dist {a b : point} (hab : a ≠ b) (D : dist point) : {x // B a b x ∧ quotient.mk (b, x) = D} :=\n⟨quotient.lift_on D (λ x : point × point, (seg_cons b x.1 x.2 a).1) \n(begin\nrintros ⟨x, y⟩ ⟨p, q⟩ h,\ndsimp,\ngeneralize h1 : seg_cons b x y a = z,\ngeneralize h2 : seg_cons b p q a = r,\nexact two12 hab z.2.1 z.2.2 r.2.1 (r.2.2.trans h.symm)\nend), begin apply quotient.induction_on D,\nrintros ⟨x, y⟩,\nexact ⟨(seg_cons b x y a).2.1, quotient.sound (seg_cons b x y a).2.2⟩ end⟩\n\ndef sided_seg_cons {a b : point} {C : dist point} : a ≠ b → C ≠ 0 → {x // sided b a x ∧ ⟦(b, x)⟧ = C} :=\nbegin\nintros h h1,\ncases three14 a b with d hd,\ncases seg_cons_dist hd.2.symm C with x hx,\nrefine ⟨x, (six2 h _ hd.2.symm hd.1).1 hx.1.symm, hx.2⟩,\nintro h_1,\nsubst x,\napply h1.symm,\nsimpa using hx.2\nend\n\ndef set_angle (point : Type) := {x : point × point × point // x.1 ≠ x.2.1 ∧ x.2.2 ≠ x.2.1}\n\ndef eqa_set_angle (x y : set_angle point) : Prop := eqa x.1.1 x.1.2.1 x.1.2.2 y.1.1 y.1.2.1 y.1.2.2\n\ninstance eqa_setoid : setoid (set_angle point) :=\n{ r := eqa_set_angle, iseqv := ⟨ λ x, eqa.refl x.2.1 x.2.2, λ x y, eqa.symm, λ x y z, eqa.trans⟩\n}\n\ndefinition angle (point : Type) [Euclidean_plane point] := \nquotient (@Euclidean_plane.eqa_setoid point _)\n\ninstance angle_order : linear_order (angle point) :=\n{ le := λ α β, quotient.lift_on₂ α β (λ x y, ang_le x.1.1 x.1.2.1 x.1.2.2 y.1.1 y.1.2.1 y.1.2.2) (λ a b c d h h1, \n    begin rw ←iff_iff_eq, split; intro h2, exact eleven30 h2 h h1, exact eleven30 h2 h.symm h1.symm end),\n  le_refl := λ α, quotient.induction_on α $ λ x, ang_le.refl x.2.1 x.2.2,\n  le_trans := λ α β γ, quotient.induction_on₃ α β γ $ λ x y z, ang_le.trans,\n  le_antisymm := λ α β, quotient.induction_on₂ α β $\n    λ x y h h1, quotient.sound (eleven34 h h1),\n  le_total := λ α β, quotient.induction_on₂ α β $\n    λ x y, eleven35 x.2.1 x.2.2 y.2.1 y.2.2 }\n\ninstance zero_angle : has_zero (angle point) := ⟨⟦⟨⟨P1, P2, P1⟩, three13, three13⟩⟧⟩\n\ntheorem zero_angle_def : (0 : angle point) = ⟦⟨⟨P1, P2, P1⟩, three13, three13⟩⟧ := rfl \n\ntheorem zero_iff_sided {x : set_angle point} : ⟦x⟧ = (0 : angle point) ↔ sided x.1.2.1 x.1.1 x.1.2.2 :=\n⟨λ h, (eleven21a (six5 three13)).1 (quotient.exact h.symm), λ h, (quotient.sound ((eleven21a h).2 (six5 three13)))⟩\n\ndef acute_triple (x : set_angle point) : Prop := ang_acute x.1.1 x.1.2.1 x.1.2.2\n\ntheorem acute_well_defined (x y : set_angle point) : x ≈ y → acute_triple x = acute_triple y :=\nbegin\nintro h,\nsuffices : acute_triple x ↔ acute_triple y,\n  rw this,\nsplit,\n  intro h1,\n  exact h1.trans h,\nintro h1,\nexact h1.trans h.symm\nend\n\ndef acute := quotient.lift acute_triple (@acute_well_defined point _)\n\ndef obtuse_triple (x : set_angle point) : Prop := ang_obtuse x.1.1 x.1.2.1 x.1.2.2\n\ntheorem obtuse_well_defined (x y : set_angle point) : x ≈ y → obtuse_triple x = obtuse_triple y :=\nbegin\nintro h,\nsuffices : obtuse_triple x ↔ obtuse_triple y,\n  rw this,\nsplit,\n  intro h1,\n  exact h1.trans h,\nintro h1,\nexact h1.trans h.symm\nend\n\ndef obtuse := quotient.lift obtuse_triple (@obtuse_well_defined point _)\n\ndef right_triple (x : set_angle point) : Prop := ang_right x.1.1 x.1.2.1 x.1.2.2\n\ntheorem right_well_defined (x y : set_angle point) : x ≈ y → right_triple x = right_triple y :=\nbegin\nintro h,\nsuffices : right_triple x ↔ right_triple y,\n  rw this,\nsplit,\n  intro h1,\n  exact h1.trans h,\nintro h1,\nexact h1.trans h.symm\nend\n\ndef right := quotient.lift right_triple (@right_well_defined point _)\n\ntheorem angle_trichotomy (α : angle point) : acute α ∨ right α ∨ obtuse α :=\nbegin\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h⟩, h1⟩,\nsubst α,\nexact right_total h.1 h.2\nend\n\ndef supp_triple (x : set_angle point) : set_angle point := ⟨⟨x.1.1, x.1.2.1, S x.1.2.1 x.1.2.2⟩, x.2.1, (seven12a x.2.2)⟩\n\ndef supp_well_defined (x y : set_angle point) : x ≈ y → supp_triple x ≈ supp_triple y :=\nbegin\nintro h,\nrcases x with ⟨⟨a, b, c⟩, h1⟩,\nrcases y with ⟨⟨d, e, f⟩, h2⟩,\nrefine (eleven13 h.flip (seven12a h1.2)\n(seven5 b c).1 (seven12a h2.2) (seven5 e f).1).flip\nend\n\ndef supp := quotient.lift (λ x, ⟦supp_triple x⟧) (λ x y h, quotient.sound (@supp_well_defined point _ x y h))\n\ntheorem supp_def {a b c : point} (h : a ≠ b) (h1 : c ≠ b) : supp ⟦⟨⟨a, b, c⟩, h, h1⟩⟧ = ⟦⟨⟨a, b, S b c⟩, h, seven12a h1⟩⟧ :=\nquotient.sound (eqa.refl h (seven12a h1))\n\n@[simp] theorem supp_of_supp (α : angle point) : supp (supp α) = α :=\nbegin\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h⟩, hx⟩,\nsubst α,\nunfold supp supp_triple,\napply quotient.sound,\nsimpa using eqa.refl h.1 h.2\nend\n\ntheorem supp_of_acute (α : angle point) : acute α ↔ obtuse (supp α) :=\nbegin\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h⟩, h1⟩,\nsubst α,\nexact (eleven40a h.1 h.2 (seven12a h.2) (seven5 b c).1)\nend\n\ntheorem supp_of_obtuse {α : angle point} : obtuse α ↔ acute (supp α) :=\nbegin\nrw ←(supp_of_supp α),\nsimpa using (supp_of_acute (supp α)).symm\nend\n\ntheorem supp_of_right {α : angle point} : right α ↔ right (supp α) :=\nbegin\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h⟩, h1⟩,\nsubst α,\nexact (eleven40b h.1 h.2 (seven12a h.2) (seven5 b c).1)\nend\n\nnoncomputable def thirteen3 {a b c : point} {C : dist point} : ¬col a b c → C ≠ 0 → {x : point × point // sided b a x.1 ∧ ⟦(b, x.1)⟧ = C ∧ xperp x.2 (l b c) (l x.1 x.2)} :=\nbegin\nintros h h1,\ncases three14 a b with d hd,\ncases seg_cons_dist hd.2.symm C with p hp,\nhave h2 : b ≠ p,\n  intro h_1,\n  subst p,\n  apply h1,\n  rw ←zero_class b,\n  exact hp.2.symm,\nhave h3 : sided b a p,\n  exact ⟨(six26 h).1, h2.symm, five2 hd.2.symm hd.1.symm hp.1⟩,\nhave h4 : ¬col b c p,\n  intro h_1,\n  apply (four10 h).2.1,\n  exact five4 h2 (four11 (six4.1 h3).1).2.2.1 (four11 h_1).1,\ncases indefinite_description (λ x, xperp x (l b c) (l p x)) (exists_of_exists_unique (eight17 (six14 (six26 h).2.1) h4)) with x hx,\nexact ⟨⟨p, x⟩, h3, hp.2, hx⟩\nend\n \nnoncomputable def cos_triple (x : set_angle point) (C : dist point) : dist point :=\nif h : C = 0 then 0 else\n(if h1 : (col x.1.1 x.1.2.1 x.1.2.2) then C else (\nquotient.mk ((((x.val).snd).fst), (thirteen3 h1 h).1.2)))\n\nnoncomputable def cos (α : angle point) (C : dist point) : dist point :=\nquotient.lift_on α (λ x : set_angle point, cos_triple x C) (λ x y h, \nbegin\ndsimp,\nunfold cos_triple,\nby_cases h1 : C = 0,\n  rw [dif_pos h1, dif_pos h1],\nrw [dif_neg h1, dif_neg h1],\nrcases x with ⟨⟨a, b, c⟩, h2⟩,\nrcases y with ⟨⟨d, e, f⟩, h3⟩,\ndsimp [- ne.def] at *,\nchange eqa a b c d e f at h,\nby_cases h4 : col a b c,\n  have h5 := eleven21d h4 h,\n  rw [dif_pos h4, dif_pos h5],\nhave h5 : ¬col d e f,\n  intro h_1,\n  exact h4 (eleven21d h_1 h.symm),\nrw [dif_neg h4, dif_neg h5],\napply quotient.sound,\nrcases thirteen3 h4 h1 with ⟨⟨p, x⟩, h6⟩,\nrcases thirteen3 h5 h1 with ⟨⟨q, y⟩, h7⟩,\ndsimp at h7 h6 ⊢,\nreplace h := eleven10 h h6.1.symm (six5 h.2.1) h7.1.symm (six5 h.2.2.2.1),\ncases six1 (four11 h6.2.2.2.2.1).2.1,\n  by_cases h_2 : b = x,\n    subst x,\n    suffices : e = y,\n      subst y,\n      exact two8 b e,\n    have h8 : xperp e (l e f) (l q e),\n      exact eight13.2 ⟨h7.2.2.1, six14 h.2.2.1, six17a e f, six17b q e, f, q, six17b e f, \n      six17a q e, h3.2, h.2.2.1, eleven17 (h6.2.2.2.2.2.2 (six17b b c) (six17a p b)) h.flip⟩,\n    have h9 : ¬col e f q,\n      intro h_2,\n      exact h5 (eleven21d (four11 h_2).2.2.2.1 (eleven9 h7.1 (six5 h3.2))),\n    exact unique_of_exists_unique (eight17 h8.1 h9) h8 h7.2.2,\n  have h_3 : e ≠ y,\n    intro h_3,\n    subst y,\n    have h8 : xperp b (l b c) (l p b),\n      exact eight13.2 ⟨h6.2.2.1, six14 h.1, six17a b c, six17b p b, c, p, six17b b c, \n      six17a p b, h2.2, h.1, eleven17 (h7.2.2.2.2.2.2 (six17b e f) (six17a q e)) h.symm.flip⟩,\n    have h9 : ¬col b c p,\n      intro h_2,\n      exact h4 (eleven21d (four11 h_2).2.2.2.1 (eleven9 h6.1 (six5 h2.2))),\n    exact h_2 (unique_of_exists_unique (eight17 h8.1 h9) h8 h6.2.2),\n  replace h := eleven13 h.flip (ne.symm h_2) h_1 h_3.symm _,\n  apply (AAS _ _ h.flip (quotient.exact (h6.2.1.trans h7.2.1.symm)).flip).2.1,\n      intro h_4,\n      apply eight14b h6.2.2 (six18 h6.2.2.1 (six13 h6.2.2.2.1) _ h6.2.2.2.2.1),\n      exact six23.2 ⟨l b x, six14 h_2, six17a b x, or.inr (or.inr h_1), (four11 h_4).2.2.1⟩,\n    exact eleven16 h_2 (six13 h6.2.2.2.1) h_3 (six13 h7.2.2.2.1) \n    (h6.2.2.2.2.2.2 (six17a b c) (six17a p x)) (h7.2.2.2.2.2.2 (six17a e f) (six17a q y)),\n  by_contradiction h_4,\n  suffices : sided e f y,\n    exact (six4.1 ((twelve24 h h6.2.2 h7.2.2).2 this)).2 h_1,\n  simpa [h_4] using (six1 (four11 h7.2.2.2.2.1).2.1),\nhave h8 : sided e f y,\n  exact (twelve24 h h6.2.2 h7.2.2).1 h_1,\nreplace h := eleven10 h (six5 h.1) h_1.symm (six5 h.2.2.1) h8.symm,\napply (AAS _ _ h (quotient.exact (h6.2.1.trans h7.2.1.symm)).flip).2.1,\n  intro h_2,\n  apply eight14b h6.2.2 (six18 h6.2.2.1 (six13 h6.2.2.2.1) _ h6.2.2.2.2.1),\n  rw (six16a h_1),\n  exact (four11 h_2).2.2.1,\nexact eleven16 h_1.2.1.symm (six13 h6.2.2.2.1) h8.2.1.symm (six13 h7.2.2.2.1) \n(h6.2.2.2.2.2.2 (six17a b c) (six17a p x)) (h7.2.2.2.2.2.2 (six17a e f) (six17a q y))\nend)\n\ntheorem cos_to_cos_triple {a b c : point} (hab : a ≠ b) (hcb : c ≠ b) : cos ⟦⟨⟨a, b, c⟩, hab, hcb⟩⟧ = cos_triple ⟨⟨a, b, c⟩, hab, hcb⟩ :=\nrfl\n\ntheorem thirteen5a {α : angle point} {x : set_angle point} {d : point} : \n⟦x⟧ = α → ¬col x.1.1 x.1.2.1 x.1.2.2 → xperp d (l x.1.2.1 x.1.2.2) (l x.1.1 d) → ⟦(x.1.2.1, d)⟧ = cos α ⟦(x.1.1, x.1.2.1)⟧ :=\nbegin\nintros h h1 h2,\nrcases x with ⟨⟨a, b, c⟩, h3, h4⟩,\nrw [←h, cos],\nunfold cos_triple,\ndsimp at *,\nrw [dif_neg (non_zero_dist_of_neq h3), dif_neg h1, quotient.sound],\nrcases thirteen3 h1 (non_zero_dist_of_neq h3) with ⟨⟨p, t⟩, ht⟩,\ndsimp at *,\nsuffices : t = d,\n  rw this,\nsuffices : p = a,\n  subst p,\n  exact unique_of_exists_unique (eight17 h2.1 (four10 h1).2.2.1) ht.2.2 h2,\nexact unique_of_exists_unique (six11 h3 h3) ⟨ht.1.symm, quotient.exact ht.2.1⟩ ⟨six5 h3, eqd_refl b a⟩\nend\n\ntheorem thirteen5b {a b c : point} (h : a ≠ b) (h1 : c ≠ b) : R a c b → ⟦(c, b)⟧ = cos ⟦⟨(a, b, c), ⟨h, h1⟩⟩⟧ ⟦(a, b)⟧ :=\nbegin\nintro h2,\nunfold cos cos_triple,\ndsimp,\nrw dif_neg (non_zero_dist_of_neq h),\nby_cases h_1 : col a b c,\n  rw dif_pos h_1,\n  suffices : c = a,\n    rw this,\n  exact (eight9 h2 (four11 h_1).1).elim eq.symm (λ h_2, (h1.symm h_2).elim),\nrw dif_neg h_1,\nrcases thirteen3 h_1 (non_zero_dist_of_neq h) with ⟨⟨p, x⟩, h3⟩,\ndsimp at h3 ⊢,\nsuffices : x = c,\n  rw this,\n  exact quotient.sound (eqd_refl c b),\nsuffices : p = a,\n  subst p,\n  exact unique_of_exists_unique (eight17 h3.2.2.1 (four10 h_1).2.2.1) h3.2.2 (eight13.2 ⟨h3.2.2.1, \n  six14 (six26 h_1).2.2, six17b b c, six17b a c, b, a, six17a b c, six17a a c, h1.symm, (six26 h_1).2.2, h2.symm⟩),\nexact unique_of_exists_unique (six11 h3.1.1 h3.1.1) ⟨h3.1.symm, quotient.exact h3.2.1⟩ ⟨six5 h, eqd_refl b a⟩\nend\n\ntheorem cos_zero {C : dist point} : cos 0 C = C :=\nbegin\nshow cos_triple ⟨⟨P1, P2, P1⟩, three13, three13⟩ C = C,\nunfold cos_triple,\nby_cases h_1 : C = 0,\n  rw [dif_pos h_1, h_1],\nrw [dif_neg h_1, dif_pos (four11 (four12 P1 P2)).1]\nend\n\ntheorem cos_right {α : angle point} {C : dist point} : right α → cos α C = 0 :=\nbegin\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h1, h2⟩, h3⟩,\nsubst α,\ndsimp [right, right_triple, cos, cos_triple] at *,\nintro h,\nby_cases h_1 : C = 0,\n  rw dif_pos h_1,\nrw dif_neg h_1,\nhave h3 := not_col_of_right h,\nrw dif_neg h3,\nrcases thirteen3 h3 h_1 with ⟨⟨p, x⟩, h4⟩,\ndsimp at *,\nreplace h := h.trans (eleven9 h4.1.symm (six5 h2)),\nsuffices : b = x,\n  simp [this],\napply unique_of_exists_unique (eight17 h4.2.2.1 (four10 (not_col_of_right h)).2.2.1) _ h4.2.2,\nrw six17 b c,\nexact xperp_of_R h.2.1 h.1 h.2.2.symm\nend\n\n@[simp] theorem cos_times_zero (α : angle point) : cos α 0 = 0 :=\nbegin\ncases quotient.exists_rep α with x hx,\nsubst α,\ndsimp [cos, cos_triple],\nrw dif_pos rfl\nend\n\ntheorem cos_supp (α : angle point) : cos α = cos (supp α) :=\nbegin\next C,\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h1, h2⟩, h3⟩,\nsubst α,\nunfold cos cos_triple,\nrw supp_def,\ndsimp,\nby_cases h_1 : C = 0,\n  rw [dif_pos h_1, dif_pos h_1],\nrw [dif_neg h_1, dif_neg h_1],\nby_cases h_2 : col a b c,\n  rw [dif_pos h_2, dif_pos _],\n  exact (seven24 (six14 h1) (six17b a b)).1 h_2,\nhave h3 : ¬col a b (S b c),\n  intro h_3,\n  exact h_2 ((seven24 (six14 h1) (six17b a b)).2 h_3),\nrw [dif_neg h_2, dif_neg h3],\nrcases thirteen3 h_2 h_1 with ⟨⟨p, x⟩, h4⟩,\nrcases thirteen3 h3 h_1 with ⟨⟨q, y⟩, h5⟩,\napply quotient.sound,\nsuffices : x = y,\n  subst x,\nsuffices : p = q,\n  subst q,\n  have h6 := (six18 h5.2.2.1 (ne.symm h2) (six17a b (S b c)) (or.inr (or.inr (seven5 b c).1))),\n  rw h6 at h5,\n  apply unique_of_exists_unique (eight17 h4.2.2.1 _) h4.2.2 h5.2.2,\n  intro h_3,\n  exact h_2 (eleven21d (four11 h_3).2.2.2.1 (eleven9 h5.1 (six5 h2))),\nexact unique_of_exists_unique (six11 h4.1.2.1 h4.1.2.1.symm) ⟨six5 h4.1.2.1, eqd.refl b p⟩\n⟨h5.1.symm.trans h4.1, quotient.exact (h5.2.1.trans h4.2.1.symm)⟩\nend\n\ntheorem thirteen6a {C : dist point} {α : angle point} : C ≠ 0 → cos α C = 0 → right α :=\nbegin\nunfold cos cos_triple,\nintros h h1,\nsimp only [dif_neg h] at h1,\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h2, h3⟩, h4⟩,\nrw ←h4 at h1 ⊢,\ndsimp at *,\nby_cases h_1 : col a b c,\n  rw dif_pos h_1 at h1,\n  exact (h h1).elim,\nrw dif_neg h_1 at h1,\nrcases thirteen3 h_1 h with ⟨⟨p, x⟩, h5⟩,\ndsimp at *,\nintro h1,\nreplace h1 := eq_of_zero_dist h1,\nsubst x,\nunfold right,\ndsimp,\nunfold right_triple,\ndsimp,\napply ang_right.trans _ (eleven9 h5.1 (six5 h3)),\nexact ⟨h5.1.2.1, h3, h5.2.2.symm.2.2.2.2 (six17a p b) (six17b b c)⟩\nend\n\ntheorem thirteen6 {C D : dist point} {α : angle point} : ¬right α → cos α C = cos α D → C = D :=\nbegin\nintros h h1,\nby_cases h_1 : C = 0,\n  subst C,\n  rw [cos_times_zero] at h1,\n  by_contradiction h_1,\n  exact h (thirteen6a (ne.symm h_1) h1.symm),\nby_cases h_2 : D = 0,\n  subst D,\n  rw [cos_times_zero] at h1,\n  by_contradiction h_2,\n  exact h (thirteen6a h_2 h1),\nrcases quotient.exists_rep α with ⟨⟨⟨a, b, c⟩, h2, h3⟩, h4⟩,\nrw ←h4 at *,\nunfold right at h,\nunfold cos cos_triple at h1,\ndsimp at *,\nunfold right_triple at h,\nrw [dif_neg h_1, dif_neg h_2] at h1,\nby_cases h_3 : col a b c,\n  rwa [dif_pos h_3, dif_pos h_3] at h1,\nrw [dif_neg h_3, dif_neg h_3] at h1,\nrcases thirteen3 h_3 h_1 with ⟨⟨p, x⟩, h5⟩,\nrcases thirteen3 h_3 h_2 with ⟨⟨q, y⟩, h6⟩,\ndsimp at *,\nintro h1,\nhave h7 : b ≠ x,\n  intro h_4,\n  subst x,\n  apply h,\n  apply ang_right.trans _ (eleven9 h5.1 (six5 h3)),\n  exact ⟨h5.1.2.1, h3, h5.2.2.symm.2.2.2.2 (six17a p b) (six17b b c)⟩,\nhave h8 : b ≠ y,\n  intro h_4,\n  subst y,\n  exact h7 (id_eqd (quotient.exact h1)),\nsuffices : p = q,\n  subst q,\n  exact h5.2.1.symm.trans h6.2.1,\nsuffices : x = y,\n  subst y,\n  apply six21a (six14 h2) h5.2.2.2.1 _ (six4.1 h5.1).1 (six17a p x) (six4.1 h6.1).1 _,\n    intro h_4,\n    rw ←h_4 at h5,\n    exact h7 (eight14d (eight15 ⟨x, h5.2.2⟩ (six17a b c) (six17b a b)) h5.2.2),\n  rw unique_of_exists_unique (unique_xperp h5.2.2.1 h5.2.2.2.2.1) h5.2.2 h6.2.2,\n  simp,\nsuffices : sided b x y,\n  exact unique_of_exists_unique (six11 this.1 this.1) ⟨six5 this.1, eqd_refl b x⟩ ⟨this.symm, two5 (quotient.exact h1).symm⟩,\nexact (thirteen8 (four11 (six4.1 (h5.1.symm.trans h6.1)).1).2.1 (six23.2 ⟨l b c, h5.2.2.1, six17a b c, h5.2.2.2.2.1, h6.2.2.2.2.1⟩) \nh7 h8 (h5.2.2.2.2.2.2 (six17a b c) (six17a p x)) (h6.2.2.2.2.2.2 (six17a b c) (six17a q y))).1 (h5.1.symm.trans h6.1)\nend\n\nend Euclidean_plane", "meta": {"author": "ImperialCollegeLondon", "repo": "xena-UROP-2018", "sha": "b111fb87f343cf79eca3b886f99ee15c1dd9884b", "save_path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018", "path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018/xena-UROP-2018-b111fb87f343cf79eca3b886f99ee15c1dd9884b/src/Geometry/tarski_7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929104825006, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4593293470591112}}
{"text": "import loops.basic\nimport inductive_constructions\nimport to_mathlib.partition\nimport analysis.locally_convex.with_seminorms -- to obtain that normed spaces are locally connected\nimport to_mathlib.order.filter.eventually_constant\n\n/-!\n# Surrounding families of loops\n\nIn order to carry out the corrugation technique of convex integration, one needs to a family of\nloops with various prescribed properties.\n\nThis file begins the work of constructing such a family.\n\nThe key definitions are:\n * `surrounded`\n * `surrounding_pts`\n * `surrounding_family`\n\nThe key results are:\n * `surrounded_iff_mem_interior_convex_hull_aff_basis`\n * `surrounded_of_convex_hull`\n * `smooth_surrounding`\n * `eventually_surrounding_pts_of_tendsto_of_tendsto`\n * `surrounding_loop_of_convex_hull`\n * `local_loops`\n * `satisfied_or_refund`\n * `extend_loops`\n * `exists_surrounding_loops`\n-/\n\nopen set function finite_dimensional int prod function path filter topological_space\nopen_locale classical topology unit_interval big_operators\n\nnamespace is_path_connected\n-- we redo `exists_path_through_family` to use `def`s\n\nvariables {X : Type*} [topological_space X] {F : set X}\n\n/-- An arbitrary path joining `x` and `y` in `F`. -/\nnoncomputable def some_path (hF : is_path_connected F) {x y : X} (hx : x ∈ F) (hy : y ∈ F) :\n  path x y :=\n(hF.joined_in x hx y hy).some_path\n\nlemma some_path_mem (hF : is_path_connected F) {x y : X} (hx : x ∈ F) (hy : y ∈ F)\n  (t : I) : hF.some_path hx hy t ∈ F :=\njoined_in.some_path_mem _ t\n\nlemma range_some_path_subset (hF : is_path_connected F) {x y : X} (hx : x ∈ F) (hy : y ∈ F) :\n  range (hF.some_path hx hy) ⊆ F :=\nby { rintro _ ⟨t, rfl⟩, apply some_path_mem }\n\n/-- A path through `p 0`, ..., `p n`. Usually this is used with `n := m`. -/\nnoncomputable def path_through (hF : is_path_connected F) {m : ℕ} {p : fin (m+1) → X}\n  (hp : ∀ i, p i ∈ F) : ∀ n : ℕ, path (p 0) (p n)\n| 0     := path.refl (p 0)\n| (n+1) := (path_through n).trans $ hF.some_path (hp _) (hp _)\n\nattribute [simp] path.trans_range\nlemma range_path_through_subset (hF : is_path_connected F) {m : ℕ} {p : fin (m+1) → X}\n  (hp : ∀ i, p i ∈ F) : ∀ {n : ℕ}, range (hF.path_through hp n) ⊆ F\n| 0     := by simp [path_through, hp]\n| (n+1) := by simp [path_through, hp, range_some_path_subset, @range_path_through_subset n]\n\nlemma mem_range_path_through' (hF : is_path_connected F) {m : ℕ} {p : fin (m+1) → X}\n  (hp : ∀ i, p i ∈ F) {i n : ℕ} (h : i ≤ n) : p i ∈ range (hF.path_through hp n) :=\nbegin\n  induction h with n hn ih,\n  { exact ⟨1, by simp⟩ },\n  { simp only [path_through, path.trans_range, mem_union, ih, true_or] }\nend\n\nlemma mem_range_path_through (hF : is_path_connected F) {m : ℕ} {p : fin (m+1) → X}\n  (hp : ∀ i, p i ∈ F) {i : fin (m+1)} : p i ∈ range (hF.path_through hp m) :=\nby { convert hF.mem_range_path_through' hp (nat.le_of_lt_succ i.2), simp }\n\nend is_path_connected\n\nnoncomputable theory\n\nvariables {E : Type*} [normed_add_comm_group E] [normed_space ℝ E]\n          {F : Type*} [normed_add_comm_group F] [normed_space ℝ F]\n\nlocal notation `d` := finrank ℝ F\n\n/-\nThe definition below gets a prime because it clashes with a manifold definition\nin mathlib which is in the root namespace.\n-/\n\n/-- `f` is smooth at `x` if `f` is smooth on some neighborhood of `x`. -/\ndef smooth_at' (f : E → F) (x : E) : Prop := ∃ s ∈ 𝓝 x, smooth_on f s\n\nsection surrounding_points\n\nlocal notation `ι` := fin (d + 1)\n\n-- def:surrounds_points\n/-- `p` is a collection of points surrounding `f` with weights `w` (that are positive and sum to 1)\nif the weighted average of the points `p` is `f` and the points `p` form an affine basis of the\nspace. -/\nstructure surrounding_pts (f : F) (p : ι → F) (w : ι → ℝ) : Prop :=\n(indep : affine_independent ℝ p)\n(w_pos : ∀ i, 0 < w i)\n(w_sum : ∑ i, w i = 1)\n(avg : ∑ i, w i • p i = f)\n\nlemma surrounding_pts.tot [finite_dimensional ℝ F]\n  {f : F} {p : ι → F} {w : ι → ℝ} (h : surrounding_pts f p w) :\n  affine_span ℝ (range p) = ⊤ :=\nh.indep.affine_span_eq_top_iff_card_eq_finrank_add_one.mpr (fintype.card_fin _)\n\nlemma surrounding_pts.mem_affine_bases [finite_dimensional ℝ F]\n  {f : F} {p : ι → F} {w : ι → ℝ} (h : surrounding_pts f p w) :\n  p ∈ affine_bases ι ℝ F :=\n⟨h.indep, h.tot⟩\n\nlemma surrounding_pts.coord_eq_w [finite_dimensional ℝ F]\n  {f : F} {p : ι → F} {w : ι → ℝ} (h : surrounding_pts f p w) :\n  (⟨p, h.indep, h.tot⟩ : affine_basis ι ℝ F).coords f = w :=\nbegin\n  let b : affine_basis ι ℝ F := ⟨p, h.indep, h.tot⟩,\n  change b.coords f = w,\n  ext i,\n  rw [← h.avg, ← finset.univ.affine_combination_eq_linear_combination _ w h.w_sum, affine_basis.coords_apply],\n  exact affine_basis.coord_apply_combination_of_mem _ (finset.mem_univ i) h.w_sum,\nend\n\n/-- `f` is surrounded by a set `s` if there is an affine basis `p` in `s` with weighted average `f`.\n-/\ndef surrounded (f : F) (s : set F) : Prop :=\n∃ p w, surrounding_pts f p w ∧ ∀ i, p i ∈ s\n\nlemma surrounded_iff_mem_interior_convex_hull_aff_basis [finite_dimensional ℝ F]\n  {f : F} {s : set F} :\n  surrounded f s ↔ ∃ (b : set F)\n                     (h₀ : b ⊆ s)\n                     (h₁ : affine_independent ℝ (coe : b → F))\n                     (h₂ : affine_span ℝ b = ⊤),\n                     f ∈ interior (convex_hull ℝ b) :=\nbegin\n  split,\n  { rintros ⟨p, w, ⟨⟨indep, w_pos, w_sum, rfl⟩, h_mem⟩⟩,\n    have h_tot : affine_span ℝ (range p) = ⊤ :=\n      indep.affine_span_eq_top_iff_card_eq_finrank_add_one.mpr (fintype.card_fin _),\n    refine ⟨range p, range_subset_iff.mpr h_mem, indep.range, h_tot, _⟩,\n    let basis : affine_basis ι ℝ F := ⟨p, indep, h_tot⟩,\n    erw basis.interior_convex_hull,\n    intros i,\n    erw [← finset.affine_combination_eq_linear_combination _ _ _ w_sum,\n      basis.coord_apply_combination_of_mem (finset.mem_univ i) w_sum],\n    exact w_pos i, },\n  { rintros ⟨b, h₀, h₁, h₂, h₃⟩,\n    haveI : fintype b := (finite_set_of_fin_dim_affine_independent ℝ h₁).fintype,\n    have hb : fintype.card b = d + 1,\n    { rw [← h₁.affine_span_eq_top_iff_card_eq_finrank_add_one, subtype.range_coe_subtype,\n        set_of_mem_eq, h₂], },\n    let p := (coe : _ → F) ∘ (fintype.equiv_fin_of_card_eq hb).symm,\n    have hp : b = range p,\n    { ext x,\n      exact ⟨by { intros h, use fintype.equiv_fin_of_card_eq hb ⟨x, h⟩, simp [p], },\n             by { rintros ⟨y, rfl⟩, apply subtype.coe_prop, }⟩, },\n    rw hp at h₀ h₂ h₃,\n    replace h₁ : affine_independent ℝ p :=\n      h₁.comp_embedding (fintype.equiv_fin_of_card_eq hb).symm.to_embedding,\n    let basis : affine_basis ι ℝ F := ⟨_, h₁, h₂⟩,\n    erw [basis.interior_convex_hull, mem_set_of_eq] at h₃,\n    refine ⟨p, λ i, basis.coord i f, ⟨h₁, h₃, _, _⟩, λ i, h₀ (mem_range_self i)⟩,\n    { exact basis.sum_coord_apply_eq_one f, },\n    { erw [← finset.univ.affine_combination_eq_linear_combination p _\n        (basis.sum_coord_apply_eq_one f),\n        basis.affine_combination_coord_eq_self] } }\nend\n\n--- prop:surrounded_by_open\nlemma surrounded_of_convex_hull [finite_dimensional ℝ F]\n  {f : F} {s : set F} (hs : is_open s) (hsf : f ∈ convex_hull ℝ s) :\n  surrounded f s :=\nbegin\n  rw surrounded_iff_mem_interior_convex_hull_aff_basis,\n  obtain ⟨t, hts, hai, hf⟩ :=\n    (by simpa only [exists_prop, mem_Union] using convex_hull_eq_union.subst hsf :\n    ∃ (t : finset F), (t : set F) ⊆ s ∧ affine_independent ℝ (coe : t → F) ∧\n      f ∈ convex_hull ℝ (t : set F)),\n  have htne : (t : set F).nonempty := (@convex_hull_nonempty_iff ℝ _ _ _ _ _).mp ⟨f, hf⟩,\n  obtain ⟨b, hb₁, hb₂, hb₃, hb₄⟩ :=\n    hs.exists_between_affine_independent_span_eq_top hts htne hai,\n  have hb₀ : b.finite, { exact finite_set_of_fin_dim_affine_independent ℝ hb₃, },\n  obtain ⟨c, hc⟩ := interior_convex_hull_nonempty_iff_affine_span_eq_top.mpr hb₄,\n  rw ← hs.interior_eq at hb₂,\n  obtain ⟨ε, hε, hcs⟩ :=\n    (eventually_homothety_image_subset_of_finite_subset_interior ℝ c hb₀ hb₂).exists_gt,\n  have hbε := convex.subset_interior_image_homothety_of_one_lt (convex_convex_hull ℝ _) hc ε hε,\n  rw affine_map.image_convex_hull at hbε,\n  let t : units ℝ := units.mk0 ε (by linarith),\n  refine ⟨affine_map.homothety c (t : ℝ) '' b, hcs, _, _, hbε (convex_hull_mono hb₁ hf)⟩,\n  { rwa (affine_equiv.homothety_units_mul_hom c t).affine_independent_set_of_eq_iff, },\n  { exact (affine_equiv.homothety_units_mul_hom c t).span_eq_top_iff.mp hb₄, },\nend\n\n-- lem:smooth_barycentric_coord\nlemma smooth_surrounding [finite_dimensional ℝ F] {x : F} {p : ι → F} {w : ι → ℝ}\n  (h : surrounding_pts x p w) :\n  ∃ W : F → (ι → F) → (ι → ℝ),\n  ∀ᶠ (yq : F × (ι → F)) in 𝓝 (x, p), smooth_at' (uncurry W) yq ∧\n                             (∀ i, 0 < W yq.1 yq.2 i) ∧\n                             ∑ i, W yq.1 yq.2 i = 1 ∧\n                             ∑ i, W yq.1 yq.2 i • yq.2 i = yq.1 :=\nbegin\n  classical,\n  use eval_barycentric_coords ι ℝ F,\n  let V : set (ι → ℝ) := set.pi set.univ (λ i, Ioi (0 : ℝ)),\n  let W' : F × (ι → F) → (ι → ℝ) := uncurry (eval_barycentric_coords ι ℝ F),\n  let A : set (F × (ι → F)) := univ ×ˢ affine_bases ι ℝ F,\n  let U : set (F × (ι → F)) := A ∩ (W' ⁻¹' V),\n  have hι : fintype.card ι = d + 1 := fintype.card_fin _,\n  have hp : p ∈ affine_bases ι ℝ F := h.mem_affine_bases,\n  have hV : is_open V := is_open_set_pi finite_univ (λ _ _, is_open_Ioi),\n  have hW' : continuous_on W' A := (smooth_barycentric ι ℝ F hι).continuous_on,\n  have hxp : W' (x, p) ∈ V, { simp [W', hp, h.coord_eq_w, h.w_pos], },\n  have hA : is_open A,\n  { simp only [A, affine_bases_findim ι ℝ F hι],\n    exact is_open_univ.prod (is_open_affine_independent ℝ F), },\n  have hU₁ : U ⊆ A := set.inter_subset_left _ _,\n  have hU₂ : is_open U := hW'.preimage_open_of_open hA hV,\n  have hU₃ : U ∈ 𝓝 (x, p) :=\n    mem_nhds_iff.mpr ⟨U, le_refl U, hU₂, set.mem_inter (by simp [hp]) (mem_preimage.mpr hxp)⟩,\n  apply eventually_of_mem hU₃,\n  rintros ⟨y, q⟩ hyq,\n  have hq : q ∈ affine_bases ι ℝ F, { simpa using hU₁ hyq, },\n  have hyq' : (y, q) ∈ W' ⁻¹' V := (set.inter_subset_right _ _) hyq,\n  refine ⟨⟨U, mem_nhds_iff.mpr ⟨U, le_refl U, hU₂, hyq⟩, (smooth_barycentric ι ℝ F hι).mono hU₁⟩, _, _, _⟩,\n  { simpa using hyq', },\n  { simp [hq], },\n  { simp [hq], exact affine_basis.linear_combination_coord_eq_self _ y, },\nend\n\nlemma smooth_surrounding_pts [finite_dimensional ℝ F] {x : F} {p : ι → F} {w : ι → ℝ}\n  (h : surrounding_pts x p w) :\n  ∃ W : F → (ι → F) → (ι → ℝ),\n  ∀ᶠ (yq : F × (ι → F)) in 𝓝 (x, p), smooth_at' (uncurry W) yq ∧\n    surrounding_pts yq.1 yq.2 (W yq.1 yq.2) :=\nbegin\n  refine exists_imp_exists (λ W hW, _) (smooth_surrounding h),\n  rw [nhds_prod_eq] at hW ⊢,\n  have := (is_open.eventually_mem (is_open_affine_independent ℝ F) h.indep).prod_inr (𝓝 x),\n  filter_upwards [hW, this], rintro ⟨y, q⟩ ⟨hW, h2W, h3W, hq⟩ h2q,\n  exact ⟨hW, h2q, h2W, h3W, hq⟩\nend\n\nlemma surrounding_pts_eval_barycentric_coords_iff\n  (q : F) (v : ι → F) [decidable_pred (∈ affine_bases ι ℝ F)] :\n  surrounding_pts q v (eval_barycentric_coords ι ℝ F q v) ↔\n  ∀ i, 0 < eval_barycentric_coords ι ℝ F q v i :=\nbegin\n  refine ⟨λ h, h.w_pos, λ h, _⟩,\n  have hv : v ∈ affine_bases ι ℝ F,\n  { by_contra contra,\n    simpa [eval_barycentric_coords_apply_of_not_mem_bases ι ℝ F q contra] using h 0, },\n  have hv' : ∑ i, eval_barycentric_coords ι ℝ F q v i = 1,\n  { simp [eval_barycentric_coords_apply_of_mem_bases ι ℝ F q hv], },\n  refine ⟨hv.1, h, hv', _⟩,\n  simp_rw [← finset.univ.affine_combination_eq_linear_combination v _ hv',\n    eval_barycentric_coords_apply_of_mem_bases ι ℝ F q hv],\n  convert affine_basis.affine_combination_coord_eq_self _ q,\n  refl,\nend\n\nend surrounding_points\n\nsection surrounding_points_limits\n\nvariables {X Y : Type*} [finite_dimensional ℝ F]\n\nlocal notation `ι` := fin (finite_dimensional.finrank ℝ F + 1)\n\nlemma eventually_surrounding_pts_of_tendsto_of_tendsto {l : filter X} {m : filter Y}\n  {v : ι → F} {q : F} {p : ι → X → F} {f : Y → F}\n  (hq : ∃ w, surrounding_pts q v w)\n  (hp : ∀ i, tendsto (p i) l (𝓝 (v i)))\n  (hf : tendsto f m (𝓝 q)) :\n  ∀ᶠ (z : X × Y) in l.prod m, ∃ w, surrounding_pts (f z.2) (λ i, p i z.1) w :=\nbegin\n  classical,\n  obtain ⟨w, hw⟩ := hq,\n  let V : set (ι → ℝ) := set.pi set.univ (λ i, Ioi (0 : ℝ)),\n  let W' : F × (ι → F) → (ι → ℝ) := uncurry (eval_barycentric_coords ι ℝ F),\n  let A : set (F × (ι → F)) := (univ : set F) ×ˢ affine_bases ι ℝ F,\n  let S : set (F × (ι → F)) := W' ⁻¹' V,\n  have hι : fintype.card ι = finite_dimensional.finrank ℝ F + 1 := fintype.card_fin _,\n  have hq' : v ∈ affine_bases ι ℝ F := hw.mem_affine_bases,\n  have hqv : (q, v) ∈ A, { simp [hq'], },\n  have hxp : W' (q, v) ∈ V, { simp [W', hq', hw.coord_eq_w, hw.w_pos], },\n  have hV' : V ∈ 𝓝 (W' (q, v)) := (is_open_set_pi finite_univ (λ _ _, is_open_Ioi)).mem_nhds hxp,\n  have hA : is_open A,\n  { simp only [A, affine_bases_findim ι ℝ F hι],\n    exact is_open_univ.prod (is_open_affine_independent ℝ F), },\n  have hW' : continuous_at W' (q, v) := (smooth_barycentric ι ℝ F hι).continuous_on.continuous_at\n    (mem_nhds_iff.mpr ⟨A, subset.rfl, hA, hqv⟩),\n  have hS : S ∈ 𝓝 (q, v) := hW'.preimage_mem_nhds hV',\n  obtain ⟨n₁, hn₁, n₂, hn₂, hS'⟩ := mem_nhds_prod_iff.mp hS,\n  have hn₁' := tendsto_def.mp hf _ hn₁,\n  have hn₂' := tendsto_def.mp (tendsto_pi_nhds.mpr hp) _ hn₂,\n  have come_on : ((swap p)⁻¹' n₂) ×ˢ (f⁻¹' n₁) ∈ l.prod m :=\n    mem_prod_iff.mpr ⟨_, hn₂', _, hn₁', subset.rfl⟩,\n  refine eventually_of_mem come_on _,\n  rintros ⟨y₂, y₁⟩ ⟨hy₂ : swap p y₂ ∈ n₂, hy₁ : f y₁ ∈ n₁⟩,\n  refine ⟨W' (f y₁, swap p y₂), (surrounding_pts_eval_barycentric_coords_iff\n    (f y₁) (swap p y₂)).mpr (λ i, _)⟩,\n  change W' (f y₁, swap p y₂) i ∈ Ioi (0 : ℝ),\n  suffices : (f y₁, swap p y₂) ∈ S,\n  { rw [set.mem_preimage] at this, exact set.mem_pi.mp this i (mem_univ _), },\n  apply hS',\n  simp [hy₁, hy₂],\nend\n\nlemma eventually_surrounding_pts_of_tendsto_of_tendsto'\n  {v : ι → F} {q : F} {p : ι → X → F} {l : filter X} {f : X → F}\n  (hq : ∃ w, surrounding_pts q v w)\n  (hp : ∀ i, tendsto (p i) l (𝓝 (v i)))\n  (hf : tendsto f l (𝓝 q)) :\n  ∀ᶠ y in l, ∃ w, surrounding_pts (f y) (λ i, p i y) w :=\nbegin\n  have := eventually_surrounding_pts_of_tendsto_of_tendsto hq hp hf,\n  simp_rw [eventually_iff_exists_mem, mem_prod_iff] at this,\n  obtain ⟨nnn, ⟨n₁, hn₁, n₂, hn₂, hh⟩, h⟩ := this,\n  rw eventually_iff_exists_mem,\n  exact ⟨n₁ ∩ n₂, inter_mem hn₁ hn₂, λ y hy, h (y, y) (by { apply hh, simpa using hy, })⟩,\nend\n\nend surrounding_points_limits\n\nnamespace loop\n\nvariables {γ γ' : loop F} {x y : F} {t : ℝ}\n\n/-- A loop `γ` surrounds a point `x` if `x` is surrounded by values of `γ`. -/\ndef surrounds (γ : loop F) (x : F) : Prop :=\n∃ t w : fin (d + 1) → ℝ, surrounding_pts x (γ ∘ t) w\n\nlemma surrounds_iff_range_subset_range :\n  γ.surrounds x ↔ ∃ (p : fin (d + 1) → F) (w : fin (d + 1) → ℝ),\n  surrounding_pts x p w ∧ range p ⊆ range γ :=\nbegin\n  split,\n  { exact λ ⟨t, w, h⟩, ⟨(γ ∘ t), w, h, range_comp_subset_range _ _⟩ },\n  { rintros ⟨p, w, h₀, h₁⟩,\n    rw range_subset_iff at h₁,\n    choose t ht using h₁,\n    have hpt : γ ∘ t = p := funext ht,\n    exact ⟨t, w, hpt.symm ▸ h₀⟩ }\nend\n\nlemma affine_equiv_surrounds_iff (e : F ≃ᵃ[ℝ] F) :\n  γ.surrounds x ↔ (γ.transform e).surrounds (e x) :=\nbegin\n  suffices : ∀ (γ : loop F) x (e : F ≃ᵃ[ℝ] F), γ.surrounds x → (γ.transform e).surrounds (e x),\n  { refine ⟨this γ x e, λ h, _⟩,\n    specialize this (γ.transform e) (e x) e.symm h,\n    rw affine_equiv.symm_apply_apply at this,\n    convert this,\n    ext,\n    simp, },\n  rintros γ x e ⟨t, w, indep, w_pos, w_sum, rfl⟩,\n  refine ⟨t, w, ⟨e.affine_independent_iff.mpr indep, w_pos, w_sum, _⟩⟩,\n  simp only [← finset.affine_combination_eq_linear_combination _ _ _ w_sum],\n  erw finset.map_affine_combination _ (γ ∘ t) _ w_sum (e : F →ᵃ[ℝ] F),\n  congr,\nend\n\nlemma vadd_surrounds : γ.surrounds x ↔ (y +ᵥ γ).surrounds (y + x) :=\nbegin\n  rw add_comm,\n  convert affine_equiv_surrounds_iff (affine_equiv.vadd_const ℝ y),\n  ext u,\n  simp [add_comm y],\nend\n\nlemma surrounds.vadd (h : γ.surrounds x) : (y +ᵥ γ).surrounds (y + x) :=\nvadd_surrounds.mp h\n\nlemma surrounds.vadd0 (h : γ.surrounds 0) : (y +ᵥ γ).surrounds y :=\nby { convert h.vadd, rw [add_zero] }\n\nlemma surrounds.smul0 (h : γ.surrounds 0) (ht : t ≠ 0) : (t • γ).surrounds 0 :=\nbegin\n  rw [affine_equiv_surrounds_iff (affine_equiv.homothety_units_mul_hom (0 : F) (units.mk0 t ht)⁻¹),\n    affine_equiv.coe_homothety_units_mul_hom_apply, affine_map.homothety_apply_same],\n  convert h,\n  ext u,\n  simp [affine_map.homothety_apply, smul_smul, inv_mul_cancel ht],\nend\n\nlemma surrounds.mono (h : γ.surrounds x) (h2 : range γ ⊆ range γ') : γ'.surrounds x :=\nbegin\n  revert h, simp_rw [loop.surrounds_iff_range_subset_range],\n  refine exists_imp_exists (λ t, _),\n  refine exists_imp_exists (λ w, _),\n  exact and.imp_right (λ h3, subset.trans h3 h2),\nend\n\nprotected lemma surrounds.reparam (h : γ.surrounds x) {φ : equivariant_map}\n  (hφ : continuous φ) : (γ.reparam φ).surrounds x :=\nbegin\n  refine h.mono _,\n  convert subset_of_eq (range_comp γ φ).symm,\n  rw [(φ.surjective hφ).range_eq, image_univ]\nend\n\n\n/-- This is only a stepping stone potentially useful for `surrounding_family.surrounds_of_close`,\n  but not needed by itself. -/\nlemma surrounds.eventually_surrounds [finite_dimensional ℝ F] (h : γ.surrounds x) :\n  ∃ ε > 0, ∀ (γ' : loop F) (y : F), (∀ z, dist (γ' z) (γ z) < ε) → dist y x < ε → γ'.surrounds y :=\nbegin\n  obtain ⟨t, w, h⟩ := h,\n  obtain ⟨W, hW⟩ := smooth_surrounding_pts h,\n  obtain ⟨ε, hε, h⟩ := metric.eventually_nhds_iff.mp hW,\n  refine ⟨ε, hε, λ γ' y hγ' hy, ⟨t, W y (γ' ∘ t), _⟩⟩,\n  refine (@h ⟨y, γ' ∘ t⟩ _).2,\n  simp_rw [prod.dist_eq, max_lt_iff, dist_pi_lt_iff hε],\n  exact ⟨hy, λ b, hγ' (t b)⟩\nend\n\n\nend loop\n\nsection surrounding_loop\n\nvariables {O : set F} {f b : F} {p : fin (d + 1) → F}\n  (O_conn : is_path_connected O)\n  (hp : ∀ i, p i ∈ O)\n  (hb : b ∈ O)\n\n/-- witness of `surrounding_loop_of_convex_hull` -/\ndef surrounding_loop : ℝ → loop F :=\nloop.round_trip_family $ (O_conn.some_path hb (hp 0)).trans $ O_conn.path_through hp d\n\nvariables {O_conn hp hb}\n\n/-- TODO: continuity note -/\nlemma continuous_surrounding_loop : continuous ↿(surrounding_loop O_conn hp hb) :=\nloop.round_trip_family_continuous\n\n@[simp] lemma surrounding_loop_zero_right (t : ℝ) : surrounding_loop O_conn hp hb t 0 = b :=\nloop.round_trip_family_based_at t\n\n@[simp] lemma surrounding_loop_zero_left (s : ℝ) : surrounding_loop O_conn hp hb 0 s = b :=\nby { simp only [surrounding_loop, loop.round_trip_family_zero], refl }\n\nlemma surrounding_loop_mem (t s : ℝ) : surrounding_loop O_conn hp hb t s ∈ O :=\nbegin\n  revert s,\n  rw ← range_subset_iff,\n  simp only [surrounding_loop, loop.round_trip_family, path.trans_range, loop.round_trip_range,\n    cast_coe],\n  refine subset.trans (truncate_range _) _,\n  simp only [trans_range, union_subset_iff, O_conn.range_some_path_subset,\n    O_conn.range_path_through_subset, true_and]\nend\n\nlemma surrounding_loop_surrounds {w : fin (d + 1) → ℝ} (h : surrounding_pts f p w) :\n  (surrounding_loop O_conn hp hb 1).surrounds f :=\nbegin\n  rw loop.surrounds_iff_range_subset_range,\n  refine ⟨p, w, h, _⟩,\n  simp only [surrounding_loop, loop.round_trip_family_one, loop.round_trip_range, trans_range,\n    range_subset_iff, mem_union, O_conn.mem_range_path_through, or_true, forall_true_iff]\nend\n\nlemma surrounding_loop_proj_I (t : ℝ) :\n  surrounding_loop O_conn hp hb (proj_I t) = surrounding_loop O_conn hp hb t :=\nloop.round_trip_eq $ λ s, by simp_rw [path.cast_coe, truncate_proj_I_right]\n\n-- unused\nlemma surrounding_loop_of_le_zero (s : ℝ) {t : ℝ} (ht : t ≤ 0) :\n  surrounding_loop O_conn hp hb t s = b :=\nby rw [← surrounding_loop_proj_I, proj_I_eq_zero.mpr ht, surrounding_loop_zero_left]\n\n-- unused\nlemma surrounding_loop_of_ge_one (s : ℝ) {t : ℝ} (ht : 1 ≤ t) :\n  surrounding_loop O_conn hp hb t s = surrounding_loop O_conn hp hb 1 s :=\nby rw [← surrounding_loop_proj_I t, proj_I_eq_one.mpr ht]\n\nlemma surrounding_loop_of_convex_hull [finite_dimensional ℝ F] {f b : F} {O : set F}\n  (O_op : is_open O) (O_conn : is_connected O)\n  (hsf : f ∈ convex_hull ℝ O) (hb : b ∈ O) :\n  ∃ γ : ℝ → loop F, continuous ↿γ ∧\n                    (∀ t, γ t 0 = b) ∧\n                    (∀ s, γ 0 s = b) ∧\n                    (∀ s t, γ (proj_I t) s = γ t s) ∧\n                    (∀ t s, γ t s ∈ O) ∧\n                    (γ 1).surrounds f :=\nbegin\n  rcases surrounded_of_convex_hull O_op hsf with ⟨p, w, h, hp⟩,\n  rw ← O_op.is_connected_iff_is_path_connected at O_conn,\n  exact ⟨surrounding_loop O_conn hp hb, continuous_surrounding_loop, surrounding_loop_zero_right,\n    surrounding_loop_zero_left, λ s t, by rw surrounding_loop_proj_I,\n    surrounding_loop_mem, surrounding_loop_surrounds h⟩\nend\n\nend surrounding_loop\n\n/-- `γ` forms a family of loops surrounding `g` with base `b`.\nIn contrast to the notes we assume that `base` and `t₀` hold universally. -/\n@[protect_proj]\nstructure surrounding_family (g b : E → F) (γ : E → ℝ → loop F) (U : set E) : Prop :=\n(base : ∀ (x : E) (t : ℝ), γ x t 0 = b x)\n(t₀ : ∀ (x : E) (s : ℝ), γ x 0 s = b x)\n(proj_I : ∀ (x : E) (t : ℝ) (s : ℝ), γ x (proj_I t) s = γ x t s)\n(surrounds : ∀ x ∈ U, (γ x 1).surrounds $ g x)\n(cont : continuous ↿γ)\n\n/-- `γ` forms a family of loops surrounding `g` with base `b` in `Ω`. -/\nstructure surrounding_family_in (g b : E → F) (γ : E → ℝ → loop F) (U : set E) (Ω : set $ E × F)\n  extends surrounding_family g b γ U : Prop :=\n(val_in' : ∀ (x ∈ U) (t ∈ I) (s ∈ I), (x, γ x t s) ∈ Ω)\n\nnamespace surrounding_family\n\nvariables {g b : E → F} {γ : E → ℝ → loop F} {U : set E}\n\nprotected lemma one (h : surrounding_family g b γ U) (x : E) (t : ℝ) : γ x t 1 = b x :=\nby rw [loop.one, h.base]\n\nprotected lemma t_le_zero (h : surrounding_family g b γ U) (x : E) (s : ℝ) {t : ℝ} (ht : t ≤ 0) :\n  γ x t s = γ x 0 s :=\nby rw [← h.proj_I, proj_I_eq_zero.mpr ht]\n\nprotected lemma t_le_zero_eq_b (h : surrounding_family g b γ U) (x : E) (s : ℝ) {t : ℝ}\n  (ht : t ≤ 0) : γ x t s = b x :=\nby rw [h.t_le_zero x s ht, h.t₀]\n\nprotected lemma t_ge_one (h : surrounding_family g b γ U) (x : E) (s : ℝ) {t : ℝ} (ht : 1 ≤ t) :\n  γ x t s = γ x 1 s :=\nby rw [← h.proj_I, proj_I_eq_one.mpr ht]\n\nprotected lemma mono (h : surrounding_family g b γ U) {V : set E} (hVU : V ⊆ U) :\n  surrounding_family g b γ V :=\n⟨h.base, h.t₀, h.proj_I, λ x hx, h.surrounds x (hVU hx), h.cont⟩\n\nprotected lemma surrounds_of_close_univ [finite_dimensional ℝ E] [finite_dimensional ℝ F]\n  (hg : continuous g)\n  (h : surrounding_family g b γ univ) :\n  ∃ ε : E → ℝ, (∀ x, 0 < ε x) ∧ continuous ε ∧\n  ∀ x (γ' : loop F), (∀ z, dist (γ' z) (γ x 1 z) < ε x) → γ'.surrounds (g x) :=\nbegin\n  let P : E → ℝ → Prop := λ x t, 0 < t ∧\n    ∀ (γ' : loop F), (∀ z, dist (γ' z) (γ x 1 z) < t) → γ'.surrounds (g x),\n  have hP : ∀ x, convex ℝ {t | P x t} :=\n  begin\n    intros x,\n    rw [convex_iff_ord_connected],\n    constructor,\n    rintro ε₁ hε₁ ε₂ hε₂ ε₃ ⟨hε₁₃, hε₃₂⟩,\n    refine ⟨hε₁.1.trans_le hε₁₃, λ γ hγ, hε₂.2 γ $ λ z, (hγ z).trans_le hε₃₂⟩\n  end,\n  obtain ⟨ε, hε, hPε⟩ := exists_cont_diff_of_convex hP _,\n  { refine ⟨ε, λ x, (hPε x).1, cont_diff_zero.mp hε, λ x, (hPε x).2⟩ },\n  intros x,\n  obtain ⟨ε, hε, h2⟩ := (h.surrounds x (mem_univ _)).eventually_surrounds,\n  have h3 : {y : E | dist (g y) (g x) < ε} ∈ 𝓝 x :=\n    (metric.is_open_ball.preimage hg).mem_nhds\n    (by simp_rw [mem_preimage, metric.mem_ball, dist_self, hε.lt]),\n  have h4 : {y : E | ∀ z, dist (γ y 1 z) (γ x 1 z) < ε / 2} ∈ 𝓝 x,\n  { refine is_open.mem_nhds _ (λ z, by simp_rw [dist_self, half_pos hε]),\n    have hc : continuous ↿(λ y s, dist (γ y 1 s) (γ x 1 s)) :=\n    (h.cont.comp₃ continuous_fst continuous_const continuous_snd).dist\n      (h.cont.comp₃ continuous_const continuous_const continuous_snd),\n    have : is_open {y : E | Sup ((λ z, dist (γ y 1 z) (γ x 1 z)) '' I) < ε / 2},\n    { refine is_open_lt (is_compact_Icc.continuous_Sup hc) continuous_const },\n    have hc : ∀ y, continuous (λ s, dist (γ y 1 s) (γ x 1 s)) :=\n    λ y, hc.comp₂ continuous_const continuous_id,\n    simp_rw [is_compact_Icc.Sup_lt_iff_of_continuous\n      (nonempty_Icc.mpr zero_le_one) (hc _).continuous_on] at this,\n    convert this,\n    ext y,\n    refine ⟨λ h z hz, h z, λ h z, _⟩,\n    rw [← (γ y 1).fract_eq, ← (γ x 1).fract_eq],\n    exact h _ (unit_interval.fract_mem _) },\n  refine ⟨_, inter_mem h4 h3, λ _, ε / 2, cont_diff_on_const,\n    λ y hy, ⟨half_pos hε, λ γ' hγ', h2 _ _ (λ z, _) hy.2⟩⟩,\n  refine (dist_triangle _ _ _).trans_lt\n    ((add_lt_add (hγ' z) (hy.1 z)).trans_le (add_halves ε).le)\nend\n/- proof using `surrounds_of_close` -/\n-- begin\n--   obtain ⟨ε, hε, hcε, hγε⟩ := h.surrounds_of_close hg is_open_univ,\n--   exact ⟨ε, λ x, hε x (mem_univ _), continuous_iff_continuous_on_univ.mpr hcε,\n--     λ x, hγε x (mem_univ _)⟩\n-- end\n\n/-- A surrounding family induces a family of paths from `b x` to `b x`.\nWe defined the concatenation we need on `path`, so we need to turn a surrounding\nfamily into the family of paths. -/\n@[simps]\nprotected def path (h : surrounding_family g b γ U) (x : E) (t : ℝ) :\n  path (b x) (b x) :=\n{ to_fun := λ s, γ x t s,\n  continuous_to_fun :=\n    (h.cont.comp₃ continuous_const continuous_const continuous_id).comp continuous_subtype_coe,\n  source' := h.base x t,\n  target' := h.one x t }\n\nlemma continuous_path {X : Type*} [topological_space X] (h : surrounding_family g b γ U)\n  {t : X → ℝ} {f : X → E} {s : X → I} (hf : continuous f) (ht : continuous t)\n  (hs : continuous s) : continuous (λ x, h.path (f x) (t x) (s x)) :=\nh.cont.comp₃ hf ht hs.subtype_coe\n\n@[simp]\nlemma path_extend_fract (h : surrounding_family g b γ U) (t s : ℝ) (x : E) :\n  (h.path x t).extend (fract s) = γ x t s :=\nby { rw [extend_extends _ (unit_interval.fract_mem s), ← loop.fract_eq], refl }\n\n@[simp]\nlemma range_path (h : surrounding_family g b γ U) (x : E) (t : ℝ) :\n  range (h.path x t) = range (γ x t) :=\nby simp only [path.coe_mk, surrounding_family.path, range_comp _ coe, subtype.range_coe,\n    loop.range_eq_image]\n\n@[simp]\nlemma path_t₀ (h : surrounding_family g b γ U) (x : E) : h.path x 0 = refl (b x) :=\nby { ext t, exact h.t₀ x t }\n\nend surrounding_family\n\nvariables {g b : E → F} {U K C : set E} {Ω : set (E × F)}\n\nnamespace surrounding_family_in\n\nvariables {γ : E → ℝ → loop F}\n\n/-- Abbreviation for `to_surrounding_family` -/\nlemma to_sf (h : surrounding_family_in g b γ U Ω) : surrounding_family g b γ U :=\nh.to_surrounding_family\n\nlemma val_in (h : surrounding_family_in g b γ U Ω) {x : E} (hx : x ∈ U) {t : ℝ} {s : ℝ} :\n  (x, γ x t s) ∈ Ω :=\nby { rw [← loop.fract_eq, ← h.proj_I],\n  exact h.val_in' x hx (proj_I t) proj_I_mem_Icc (fract s) (unit_interval.fract_mem s) }\n\nprotected lemma mono (h : surrounding_family_in g b γ U Ω) {V : set E} (hVU : V ⊆ U) :\n  surrounding_family_in g b γ V Ω :=\n⟨h.to_sf.mono hVU, λ x hx, h.val_in' x (hVU hx)⟩\n\n/-- Continuously reparameterize a `surrounding_family_in` so that it is constant near\n  `s ∈ {0,1}` and `t ∈ {0,1}` -/\nprotected lemma reparam (h : surrounding_family_in g b γ U Ω) :\n  surrounding_family_in g b (λ x t, (γ x (linear_reparam t)).reparam linear_reparam) U Ω :=\nbegin\n  refine ⟨⟨_, _, _, _, _⟩, _⟩,\n  { intros x t, simp_rw [loop.reparam_apply, linear_reparam_zero, h.base] },\n  { intros x s, simp_rw [loop.reparam_apply, linear_reparam_zero, h.t₀] },\n  { intros x t s, simp_rw [loop.reparam_apply, linear_reparam_proj_I, h.proj_I] },\n  { intros x hx, simp_rw [linear_reparam_one],\n    exact (h.surrounds x hx).reparam continuous_linear_reparam },\n  { exact h.cont.comp₃ continuous_fst continuous_linear_reparam.fst'.snd'\n      continuous_linear_reparam.snd'.snd' },\n  { intros x hx t ht s hs, exact h.val_in hx },\nend\n\nend surrounding_family_in\n\nsection local_loops\nvariables {x₀ : E} (hΩ_conn : is_path_connected (prod.mk x₀ ⁻¹' Ω))\n  (hb_in : (x₀, b x₀) ∈ Ω)\n  {p : fin (d + 1) → F}\n  (hp : ∀ i, p i ∈ prod.mk x₀ ⁻¹' Ω)\n\n-- /-- The witness of `local_loops`. -/\n-- def local_loops_def (x : E) (t : ℝ) : loop F :=\n-- b x - b x₀ +ᵥ surrounding_loop hΩ_conn hp hb_in t\n\n/--\nNote: The conditions in this lemma are currently a bit weaker than the ones mentioned in the\nblueprint.\nTODO: use `local_loops_def`\n-/\nlemma local_loops [finite_dimensional ℝ F]\n  {x₀ : E}\n  (hΩ_op : ∃ U ∈ 𝓝 x₀, is_open (Ω ∩ fst ⁻¹' U))\n  (hg : continuous_at g x₀) (hb : continuous b)\n  (hconv : g x₀ ∈ convex_hull ℝ (connected_component_in (prod.mk x₀ ⁻¹' Ω) $ b x₀)) :\n  ∃ (γ : E → ℝ → loop F) (U ∈ 𝓝 x₀), surrounding_family_in g b γ U Ω :=\nbegin\n  have hbx₀ : continuous_at b x₀ := hb.continuous_at,\n  have hΩ_op_x₀ : is_open (connected_component_in (prod.mk x₀ ⁻¹' Ω) $ b x₀) :=\n    (is_open_slice_of_is_open_over hΩ_op).connected_component_in,\n  have b_in : b x₀ ∈ prod.mk x₀ ⁻¹' Ω :=\n    connected_component_in_nonempty_iff.mp (convex_hull_nonempty_iff.mp ⟨g x₀, hconv⟩),\n  have hΩ_conn : is_connected (connected_component_in (prod.mk x₀ ⁻¹' Ω) $ b x₀) :=\n  is_connected_connected_component_in_iff.mpr b_in,\n  have hb_in : b x₀ ∈ (connected_component_in (prod.mk x₀ ⁻¹' Ω) $ b x₀) :=\n    mem_connected_component_in b_in,\n  rcases surrounding_loop_of_convex_hull hΩ_op_x₀ hΩ_conn hconv hb_in with\n    ⟨γ, h1γ, h2γ, h3γ, h4γ, h5γ, h6γ⟩,\n  have h5γ : ∀ (t s : ℝ), γ t s ∈ mk x₀ ⁻¹' Ω := λ t s, connected_component_in_subset _ _ (h5γ t s),\n  let δ : E → ℝ → loop F := λ x t, b x - b x₀ +ᵥ γ t,\n  have hδ : continuous ↿δ,\n  { dsimp only [δ, has_uncurry.uncurry, loop.vadd_apply],\n    refine (hb.fst'.sub continuous_const).add h1γ.snd' },\n  have hδx₀ : ∀ t s, δ x₀ t s = γ t s,\n  { intros t s, simp only [zero_add, loop.vadd_apply, sub_self] },\n  have hδs0 : ∀ x t, δ x t 0 = b x,\n  { intros x t, simp only [h2γ, loop.vadd_apply, sub_add_cancel] },\n  have hδt0 : ∀ x s, δ x 0 s = b x,\n  { intros x s, simp [h3γ, sub_add_cancel] },\n  have hδt1 : ∀ x t s, δ x (proj_I t) s = δ x t s,\n  { intros x t s, simp [h4γ] },\n  have hδΩ : ∀ᶠ x in 𝓝 x₀, ∀ (t ∈ I) (s ∈ I), (x, δ x t s) ∈ Ω,\n  { rcases hΩ_op with ⟨U, hUx₀, hU⟩,\n    -- todo: this is nicer with `is_compact.eventually_forall_of_forall_eventually` twice, but then\n    -- we need the continuity of `δ` with the arguments reassociated differently.\n    have : ∀ᶠ (x : E) in 𝓝 x₀, ∀ (ts : ℝ × ℝ), ts ∈ I ×ˢ I → (x, δ x ts.1 ts.2) ∈ Ω,\n    { refine is_compact.eventually_forall_mem (is_compact_Icc.prod is_compact_Icc)\n        (continuous_fst.prod_mk hδ) _,\n      rintro ⟨t, s⟩ ⟨ht, hs⟩,\n      rw [hδx₀],\n      show Ω ∈ 𝓝 (x₀, γ t s),\n      exact mem_nhds_iff.mpr\n        ⟨_, inter_subset_left _ _, hU, ⟨h5γ t s, show x₀ ∈ U, from mem_of_mem_nhds hUx₀⟩⟩ },\n    refine this.mono _, intros x h t ht s hs, exact h (t, s) ⟨ht, hs⟩ },\n  have hδsurr : ∀ᶠ x in 𝓝 x₀, (δ x 1).surrounds (g x),\n  { rcases h6γ with ⟨p, w, h⟩,\n    obtain ⟨W, hW⟩ := smooth_surrounding_pts h,\n    let c : E → F × (fin (d+1) → F) := λ x, (g x, δ x 1 ∘ p),\n    have hc : continuous_at c x₀ := hg.prod\n      (((continuous_at_pi.2 (λ _, hbx₀)).sub continuous_at_const).add continuous_at_const),\n    have hcx₀ : c x₀ = (g x₀, γ 1 ∘ p),\n    { simp only [c, hδx₀, function.comp, prod.mk.inj_iff, eq_self_iff_true, and_self] },\n    rw [← hcx₀] at hW,\n    filter_upwards [hc.tendsto.eventually hW], rintro x ⟨hW, hx⟩,\n    exact ⟨_, _, hx⟩ },\n  exact ⟨δ, _, hδΩ.and hδsurr, ⟨⟨hδs0, hδt0, hδt1, λ x, and.right, hδ⟩, λ x, and.left⟩⟩\nend\n\n/-- A tiny reformulation of `local_loops` where the existing `U` is open. -/\nlemma local_loops_open [finite_dimensional ℝ F]\n  {x₀ : E}\n  (hΩ_op : ∃ U ∈ 𝓝 x₀, is_open (Ω ∩ fst ⁻¹' U))\n  (hg : continuous_at g x₀) (hb : continuous b)\n  (hconv : g x₀ ∈ convex_hull ℝ (connected_component_in (prod.mk x₀ ⁻¹' Ω) $ b x₀)) :\n  ∃ (γ : E → ℝ → loop F) (U : set E), is_open U ∧ x₀ ∈ U ∧ surrounding_family_in g b γ U Ω :=\nbegin\n  obtain ⟨γ, U, hU, hγ⟩ := local_loops hΩ_op hg hb hconv,\n  obtain ⟨V, hVU, hV, hx₀V⟩ := mem_nhds_iff.mp hU,\n  exact ⟨γ, V, hV, hx₀V, hγ.mono hVU⟩\nend\n\nend local_loops\n\n/-- Function used in `satisfied_or_refund`. Rename. -/\ndef ρ (t : ℝ) : ℝ := proj_I $ 2 * (1 - t)\n\nlemma continuous_ρ : continuous ρ :=\ncontinuous_proj_I.comp $ continuous_const.mul $ continuous_const.sub continuous_id\n\n@[simp] lemma ρ_eq_one {x : ℝ} : ρ x = 1 ↔ x ≤ 1 / 2 :=\nby { rw [ρ, proj_I_eq_one], split; intros; linarith }\n\n@[simp] lemma ρ_eq_one_of_le {x : ℝ} (h : x ≤ 1 / 2) : ρ x = 1 :=\nρ_eq_one.mpr h\n\n@[simp] lemma ρ_eq_one_of_nonpos {x : ℝ} (h : x ≤ 0) : ρ x = 1 :=\nρ_eq_one_of_le $ h.trans $ by norm_num\n\n@[simp] lemma ρ_eq_zero {x : ℝ} : ρ x = 0 ↔ 1 ≤ x :=\nby { rw [ρ, proj_I_eq_zero], split; intros; linarith }\n\n@[simp] lemma ρ_eq_zero_of_le {x : ℝ} (h : 1 ≤ x) : ρ x = 0 :=\nρ_eq_zero.mpr h\n\nlemma ρ_mem_I {x : ℝ} : ρ x ∈ I := proj_I_mem_Icc\n\nsection satisfied_or_refund\n\nvariables {γ₀ γ₁ : E → ℝ → loop F}\nvariables (h₀ : surrounding_family g b γ₀ U) (h₁ : surrounding_family g b γ₁ U)\n\n/-- The homotopy of surrounding families of loops used in lemma `satisfied_or_refund`.\n  Having this as a separate definition is useful, because the construction actually gives some\n  more information about the homotopy than the theorem `satisfied_or_refund` gives. -/\ndef sf_homotopy (τ : ℝ) (x : E) (t : ℝ) :=\nloop.of_path $ (h₀.path x $ ρ τ * proj_I t).strans (h₁.path x $ ρ (1 - τ) * proj_I t) $\n  proj_Icc 0 1 zero_le_one (1 - τ)\n\nvariables {h₀ h₁}\n\n@[simp] lemma sf_homotopy_zero : sf_homotopy h₀ h₁ 0 = γ₀ :=\nbegin\n  ext x t s,\n  simp only [sf_homotopy, one_mul, ρ_eq_one_of_nonpos, surrounding_family.path_extend_fract,\n    sub_zero, loop.of_path_apply, Icc.mk_one, proj_Icc_right, path.strans_one, h₀.proj_I]\nend\n\n@[simp] lemma sf_homotopy_one : sf_homotopy h₀ h₁ 1 = γ₁ :=\nbegin\n  ext x t s,\n  simp only [sf_homotopy, path.strans_zero, Icc.mk_zero, one_mul, ρ_eq_one_of_nonpos,\n    surrounding_family.path_extend_fract, proj_Icc_left, loop.of_path_apply, sub_self,\n    h₁.proj_I]\nend\n\nlemma _root_.continuous.sf_homotopy {X : Type*} [uniform_space X]\n  [separated_space X] [locally_compact_space X]\n  {τ t s : X → ℝ} {f : X → E} (hτ : continuous τ) (hf : continuous f) (ht : continuous t)\n  (hs : continuous s) : continuous (λ x, sf_homotopy h₀ h₁ (τ x) (f x) (t x) (s x)) :=\nbegin\n  refine continuous.of_path _ _ _ _ hs,\n  refine continuous.path_strans _ _ _ _ _ continuous_snd,\n  { refine h₀.continuous_path hf.fst'.fst' _ continuous_snd,\n    exact (continuous_ρ.comp hτ.fst'.fst').mul (continuous_proj_I.comp ht.fst'.fst') },\n  { refine h₁.continuous_path hf.fst'.fst' _ continuous_snd,\n    refine (continuous_ρ.comp _).mul (continuous_proj_I.comp ht.fst'.fst'),\n    exact continuous_const.sub hτ.fst'.fst' },\n  { intros x s hs, simp only [proj_Icc_eq_zero, sub_nonpos] at hs,\n    simp only [hs, h₀.t₀, zero_mul, surrounding_family.path_apply, ρ_eq_zero_of_le] },\n  { intros x s hs, simp only [proj_Icc_eq_one] at hs,\n    simp only [hs, h₁.t₀, zero_mul, surrounding_family.path_apply, ρ_eq_zero_of_le] },\n  { refine continuous_proj_Icc.comp (continuous_const.sub hτ.fst') }\nend\n\n/-- In this lemmas and the lemmas below we add `finite_dimensional ℝ E` so that we can conclude\n `locally_compact_space E`. -/\nlemma continuous_sf_homotopy [finite_dimensional ℝ E] : continuous ↿(sf_homotopy h₀ h₁) :=\ncontinuous.sf_homotopy continuous_fst continuous_snd.fst continuous_snd.snd.fst\n  continuous_snd.snd.snd\n\nlemma surrounding_family_sf_homotopy [finite_dimensional ℝ E] (τ : ℝ) :\n  surrounding_family g b (sf_homotopy h₀ h₁ τ) U :=\nbegin\n  constructor,\n  { intros x t, simp only [sf_homotopy, Icc.mk_zero, zero_le_one, extend_extends,\n      path.source, loop.of_path_apply, left_mem_Icc, fract_zero] },\n  { intros x s,\n    -- have h2t : ρ τ * t ≤ 0 := mul_nonpos_of_nonneg_of_nonpos (ρ_nonneg τ) ht,\n    -- have h3t : ρ (1 - τ) * t ≤ 0 := mul_nonpos_of_nonneg_of_nonpos (ρ_nonneg _) ht,\n    -- have h4t : t ≤ 1 := ht.trans zero_le_one,\n    simp only [sf_homotopy, path.refl_strans_refl, path.refl_extend, loop.of_path_apply,\n      proj_I_zero, mul_zero, surrounding_family.path_t₀] },\n  { intros x t s, simp only [sf_homotopy, proj_I_proj_I] },\n  -- { intros x t s ht, simp only [sf_homotopy, min_eq_left ht, min_self] },\n  { intros x hx, cases le_total τ (1 / 2) with h h,\n    { have : τ < 1 := h.trans_lt (by norm_num),\n      refine (h₀.surrounds x hx).mono _,\n      simp only [mul_one, loop.range_of_path, sf_homotopy, proj_I_one],\n      refine subset.trans (by simp only [surrounding_family.range_path, ρ_eq_one_of_le, h])\n        (subset_range_strans_left $ by simp [this]) },\n    { have : 0 < τ := lt_of_lt_of_le (by norm_num) h,\n      have h : 1 - τ ≤ 1 / 2, { rw [sub_le_comm], convert h, norm_num },\n      refine (h₁.surrounds x hx).mono _,\n      simp only [mul_one, loop.range_of_path, sf_homotopy, proj_I_one],\n      refine subset.trans (by simp only [surrounding_family.range_path, ρ_eq_one_of_le, h])\n        (subset_range_strans_right $ by simp [this]) } },\n  { exact continuous_const.sf_homotopy continuous_fst continuous_snd.fst continuous_snd.snd }\nend\n\n/-- A more precise version of `sf_homotopy_in`. -/\nlemma sf_homotopy_in' {ι} (h₀ : surrounding_family g b γ₀ U) (h₁ : surrounding_family g b γ₁ U)\n  (τ : ι → ℝ) (x : ι → E) (i : ι) {V : set E} (hx : x i ∈ V) {t : ℝ} (ht : t ∈ I) {s : ℝ}\n  (h_in₀ : ∀ i (hx : x i ∈ V) (t ∈ I) (s : ℝ), τ i ≠ 1 → (x i, γ₀ (x i) t s) ∈ Ω)\n  (h_in₁ : ∀ i (hx : x i ∈ V) (t ∈ I) (s : ℝ), τ i ≠ 0 → (x i, γ₁ (x i) t s) ∈ Ω) :\n  (x i, sf_homotopy h₀ h₁ (τ i) (x i) t s) ∈ Ω :=\nbegin\n  by_cases hτ0 : τ i = 0, { simp [hτ0], exact h_in₀ i hx t ht s (by norm_num [hτ0]) },\n  by_cases hτ1 : τ i = 1, { simp [hτ1], exact h_in₁ i hx t ht s (by norm_num [hτ1]) },\n  generalize hy : sf_homotopy h₀ h₁ (τ i) (x i) t s = y,\n  have h2y : y ∈ range (sf_homotopy h₀ h₁ (τ i) (x i) t), { rw [← hy], exact mem_range_self _},\n  rw [sf_homotopy, loop.range_of_path, proj_I_eq_self.mpr ht] at h2y,\n  replace h2y := range_strans_subset h2y,\n  rcases h2y with ⟨s', rfl⟩|⟨s', rfl⟩,\n  { exact h_in₀ _ hx _ (unit_interval.mul_mem ρ_mem_I ht) _ hτ1 },\n  { exact h_in₁ _ hx _ (unit_interval.mul_mem ρ_mem_I ht) _ hτ0 }\nend\n\nlemma sf_homotopy_in (h₀ : surrounding_family_in g b γ₀ U Ω) (h₁ : surrounding_family_in g b γ₁ U Ω)\n  (τ : ℝ) ⦃x : E⦄ (hx : x ∈ U) {t : ℝ} (ht : t ∈ I) {s : ℝ} :\n  (x, sf_homotopy h₀.to_sf h₁.to_sf τ x t s) ∈ Ω :=\nsf_homotopy_in' h₀.to_sf h₁.to_sf (λ _, τ) (λ _, x) () hx ht\n  (λ i hx t ht s _, h₀.val_in hx)\n  (λ i hx t ht s _, h₁.val_in hx)\n\nlemma surrounding_family_in_sf_homotopy [finite_dimensional ℝ E]\n  (h₀ : surrounding_family_in g b γ₀ U Ω) (h₁ : surrounding_family_in g b γ₁ U Ω) (τ : ℝ) :\n  surrounding_family_in g b (sf_homotopy h₀.to_sf h₁.to_sf τ) U Ω :=\n⟨surrounding_family_sf_homotopy _, λ x hx t ht s hs, sf_homotopy_in _ _ _ hx ht⟩\n\nlemma satisfied_or_refund [finite_dimensional ℝ E] {γ₀ γ₁ : E → ℝ → loop F}\n  (h₀ : surrounding_family_in g b γ₀ U Ω) (h₁ : surrounding_family_in g b γ₁ U Ω) :\n  ∃ γ : ℝ → E → ℝ → loop F,\n    (∀ τ, surrounding_family_in g b (γ τ) U Ω) ∧\n    γ 0 = γ₀ ∧\n    γ 1 = γ₁ ∧\n    continuous ↿γ :=\n⟨sf_homotopy h₀.to_sf h₁.to_sf, surrounding_family_in_sf_homotopy h₀ h₁, sf_homotopy_zero,\n  sf_homotopy_one, continuous_sf_homotopy⟩\n\nend satisfied_or_refund\n\nsection extend_loops\n\nvariables [finite_dimensional ℝ E]\n\n/-\nNote: we also want add the condition that `γ = γ₀` outside a neighborhood of `U₁ᶜ`.\nThis makes it easier to find the limit of a sequence of these constructions.\n-/\nlemma extend_loops {U₀ U₁ K₀ K₁ : set E} (hU₀ : is_open U₀) (hU₁ : is_open U₁)\n  (hK₀ : is_closed K₀) (hK₁ : is_closed K₁) (hKU₀ : K₀ ⊆ U₀) (hKU₁ : K₁ ⊆ U₁)\n  {γ₀ γ₁ : E → ℝ → loop F}\n  (h₀ : surrounding_family_in g b γ₀ U₀ Ω) (h₁ : surrounding_family_in g b γ₁ U₁ Ω) :\n  ∃ (U ∈ 𝓝ˢ (K₀ ∪ K₁)) (γ : E → ℝ → loop F),\n    surrounding_family_in g b γ U Ω ∧\n    (∀ᶠ x in 𝓝ˢ K₀, γ x = γ₀ x) ∧\n    (∀ᶠ x in 𝓝ˢ U₁ᶜ, γ x = γ₀ x) :=\nbegin\n  obtain ⟨V₀, hV₀, hKV₀, hVU₀⟩ := normal_exists_closure_subset hK₀ hU₀ hKU₀,\n  let L₁ := K₁ \\ U₀,\n  have hL₁ : is_closed L₁ := hK₁.sdiff hU₀,\n  have hV₀L₁ : disjoint (closure V₀) L₁ := disjoint_sdiff_self_right.mono hVU₀ subset.rfl,\n  obtain ⟨V₂, hV₂, hLV₂, h2V₂⟩ :=\n  normal_exists_closure_subset hL₁\n    (is_closed_closure.is_open_compl.inter hU₁)\n    (subset_inter (subset_compl_iff_disjoint_left.mpr hV₀L₁) $ (diff_subset _ _).trans hKU₁),\n  obtain ⟨V₁, hV₁, hLV₁, hV₁₂⟩ :=\n    normal_exists_closure_subset hL₁ hV₂ hLV₂,\n  rw [subset_inter_iff, subset_compl_iff_disjoint_left] at h2V₂,\n  rcases h2V₂ with ⟨hV₀₂, hV₂U₁⟩,\n  have hVU₁ : V₁ ⊆ U₁ := subset_closure.trans (hV₁₂.trans $ subset_closure.trans hV₂U₁),\n  have hdisj : disjoint (closure V₀ ∪ V₂ᶜ) (closure V₁),\n  { refine disjoint.union_left (hV₀₂.mono_right (hV₁₂.trans subset_closure)) _,\n    rw [← subset_compl_iff_disjoint_left, compl_compl], exact hV₁₂ },\n  refine ⟨V₀ ∪ (U₁ ∩ U₀) ∪ V₁, ((hV₀.union $ hU₁.inter hU₀).union hV₁).mem_nhds_set.mpr _, _⟩,\n  { refine union_subset (hKV₀.trans $ (subset_union_left _ _).trans $ subset_union_left _ _) _,\n    rw [← inter_union_diff K₁], exact\n      union_subset_union ((inter_subset_inter_left _ hKU₁).trans $ subset_union_right _ _) hLV₁ },\n  obtain ⟨ρ, h0ρ, h1ρ, hρ⟩ := exists_continuous_zero_one_of_closed\n    (is_closed_closure.union hV₂.is_closed_compl) is_closed_closure hdisj,\n  let h₀' : surrounding_family_in g b γ₀ (U₁ ∩ U₀) Ω := h₀.mono (inter_subset_right _ _),\n  let h₁' : surrounding_family_in g b γ₁ (U₁ ∩ U₀) Ω := h₁.mono (inter_subset_left _ _),\n  let γ := sf_homotopy h₀'.to_sf h₁'.to_sf,\n  have hγ : ∀ τ, surrounding_family_in g b (γ τ) (U₁ ∩ U₀) Ω :=\n    surrounding_family_in_sf_homotopy _ _,\n  have heq1 : ∀ x ∈ closure V₀ ∪ V₂ᶜ, γ (ρ x) x = γ₀ x,\n  { intros x hx, simp_rw [γ, h0ρ hx, pi.zero_apply, sf_homotopy_zero] },\n  have heq2 : ∀ x ∈ V₀, γ (ρ x) x = γ₀ x :=\n  λ x hx, heq1 x (subset_closure.trans (subset_union_left _ _) hx),\n  refine ⟨λ x t, γ (ρ x) x t, _, _, _⟩,\n  { refine ⟨⟨λ x, (hγ $ ρ x).base x, λ x, (hγ $ ρ x).t₀ x,\n      λ x, (hγ $ ρ x).proj_I x, _, _⟩, _⟩,\n    { rintro x ((hx|hx)|hx),\n      { simp_rw [heq2 x hx, h₀.surrounds x (hVU₀ $ subset_closure hx)] },\n      { simp_rw [γ, (hγ $ ρ x).surrounds x hx] },\n      { simp_rw [γ, h1ρ (subset_closure hx), pi.one_apply, sf_homotopy_one,\n          h₁.surrounds x (hVU₁ hx)] } },\n    { exact continuous.sf_homotopy ρ.continuous.fst' continuous_fst\n        continuous_snd.fst continuous_snd.snd },\n    { intros x hx t ht s _, refine sf_homotopy_in' _ _ _ id _ hx ht _ _,\n      { intros x hx t ht s hρx, refine h₀.val_in _, rcases hx with (hx|⟨-,hx⟩)|hx,\n        { exact (subset_closure.trans hVU₀) hx },\n        { exact hx },\n        { exact (hρx $ h1ρ $ subset_closure hx).elim } },\n      { intros x hx t ht s hρx, refine h₁.val_in _, rcases hx with (hx|⟨hx,-⟩)|hx,\n        { exact (hρx $ h0ρ $ subset_closure.trans (subset_union_left _ _) hx).elim },\n        { exact hx },\n        { exact hVU₁ hx } } } },\n  { exact eventually_of_mem (hV₀.mem_nhds_set.mpr hKV₀) heq2 },\n  { refine eventually_of_mem\n      (is_closed_closure.is_open_compl.mem_nhds_set.mpr $ compl_subset_compl.mpr hV₂U₁)\n      (λ x hx, heq1 x $ mem_union_right _ $ compl_subset_compl.mpr subset_closure hx) },\nend\n\nend extend_loops\n\ndef continuous_germ {x : E} (φ : germ (𝓝 x) (ℝ → loop F)) : Prop :=\nquotient.lift_on' φ (λ γ, ∀ (t s : ℝ), continuous_at (λ p : E × ℝ × ℝ, γ p.1 p.2.1 p.2.2) (x, t, s))\nbegin\n  rintros γ γ' (h : {x | γ x = γ' x} ∈ 𝓝 x),\n  ext,\n  refine forall_congr (λ t, forall_congr (λ s, continuous_at_congr _)),\n  rw [nhds_prod_eq],\n  apply mem_of_superset (filter.prod_mem_prod h univ_mem),\n  rintros ⟨x', p⟩ ⟨hx' : γ x' = γ' x', -⟩,\n  simp only [mem_set_of_eq, hx']\nend\n\nvariables (g b Ω)\n\nstructure loop_family_germ (x : E) (φ : germ (𝓝 x) (ℝ → loop F)) : Prop :=\n(base : ∀ t, φ.value t 0 = b x)\n(t₀ : ∀ s, φ.value 0 s = b x)\n(proj_I : ∀ (t : ℝ) (s : ℝ), φ.value (proj_I t) s = φ.value t s)\n(cont : continuous_germ φ)\n\nstructure surrounding_family_germ (x : E) (φ : germ (𝓝 x) (ℝ → loop F)) : Prop :=\n(surrounds : (φ.value 1).surrounds $ g x)\n(val_in' : ∀ (t ∈ I) (s ∈ I), (x, φ.value t s) ∈ Ω)\n\nvariables {g b Ω}\n\n/-\nThe following proof is slightly tedious because the definition of `surrounding_family_in`\nsplits weirdly into `surrounding_family` which includes one condition on `C`\nand one extra condition on `C` instead of putting everything which does not depend on `C`\non one side and the two conditions depending on `C` on the other side as we do here.\n-/\nlemma surrounding_family_in_iff_germ {γ : E → ℝ → loop F} :\n  surrounding_family_in g b γ C Ω ↔ (∀ x, loop_family_germ b x γ) ∧\n                                    (∀ x ∈ C, surrounding_family_germ g Ω x γ) :=\nbegin\n  split,\n  { rintro ⟨⟨base, t₀, proj_I, family_surrounds, family_cont⟩, H⟩,\n    exact ⟨λ x, ⟨base x, t₀ x, proj_I x, λ t s, family_cont.continuous_at⟩,\n           λ x x_in, ⟨family_surrounds x x_in, H x x_in⟩⟩ },\n  { rintro ⟨h, h'⟩,\n    refine ⟨⟨λ x, (h x).base, λ x, (h x).t₀, λ x, (h x).proj_I,  λ x hx, (h' x hx).surrounds, _⟩,\n            λ x hx, (h' x hx).val_in'⟩,\n    apply continuous_iff_continuous_at.mpr,\n    rintros ⟨x, t, s⟩,\n    apply (h x).cont }\nend\n\nvariables [finite_dimensional ℝ E] [finite_dimensional ℝ F] [second_countable_topology E]\n\nlemma exists_surrounding_loops\n  (hK : is_closed K)\n  (hΩ_op : is_open Ω)\n  (hg : ∀ x, continuous_at g x) (hb : continuous b)\n  (hconv : ∀ x, g x ∈ convex_hull ℝ (connected_component_in (prod.mk x ⁻¹' Ω) $ b x))\n  {γ₀ :  E → ℝ → loop F}\n  (hγ₀_surr : ∃ V ∈ 𝓝ˢ K, surrounding_family_in g b γ₀ V Ω) :\n  ∃ γ : E → ℝ → loop F, surrounding_family_in g b γ univ Ω ∧ ∀ᶠ x in 𝓝ˢ K, γ x = γ₀ x :=\nbegin\n  rcases hγ₀_surr with ⟨V, V_in, hV⟩,\n  cases surrounding_family_in_iff_germ.mp hV with hV h'V,\n  simp only [surrounding_family_in_iff_germ, mem_univ, forall_true_left, ← forall_and_distrib],\n  apply inductive_construction' (loop_family_germ b) (surrounding_family_germ g Ω) hK hV\n    (mem_of_superset V_in h'V),\n  { intros x,\n    rcases local_loops ⟨univ, univ_mem, by  simp only [preimage_univ, inter_univ,hΩ_op ]⟩\n      (hg x) hb (hconv x) with ⟨γ, U, U_in, H⟩,\n    cases surrounding_family_in_iff_germ.mp H with H H',\n    exact ⟨γ, H, mem_of_superset U_in H'⟩ },\n  { intros U₁ U₂ K₁  K₂ γ₁ γ₂ hU₁ hU₂ hK₁ hK₂ hKU₁ hKU₂ hγ₁ hγ₂ h'γ₁ h'γ₂,\n    rcases extend_loops hU₁ hU₂ hK₁ hK₂ hKU₁ hKU₂ (surrounding_family_in_iff_germ.mpr ⟨hγ₁, h'γ₁⟩)\n      (surrounding_family_in_iff_germ.mpr ⟨hγ₂, h'γ₂⟩) with ⟨U, U_in, γ, H, H''⟩,\n    cases surrounding_family_in_iff_germ.mp H with H H',\n    refine ⟨γ, H, mem_of_superset U_in H', eventually_nhds_set_union.mpr H''⟩ }\nend\n\n-- #lint\n-- #print axioms satisfied_or_refund\n-- #print axioms extend_loops\n-- #print axioms exists_surrounding_loops\n", "meta": {"author": "leanprover-community", "repo": "sphere-eversion", "sha": "324e02c1509db6177cf363618f6ac5be343ce2f5", "save_path": "github-repos/lean/leanprover-community-sphere-eversion", "path": "github-repos/lean/leanprover-community-sphere-eversion/sphere-eversion-324e02c1509db6177cf363618f6ac5be343ce2f5/src/loops/surrounding.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512488, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.45930134896801733}}
{"text": "/-\nCopyright (c) 2022 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport algebra.star.basic\nimport algebra.ring.prod\nimport algebra.module.prod\n\n/-!\n# `star` on product types\n\nWe put a `has_star` structure on product types that operates elementwise.\n-/\n\nuniverses u v w\nvariables {R : Type u} {S : Type v}\n\nnamespace prod\n\ninstance [has_star R] [has_star S] : has_star (R × S) :=\n{ star := λ x, (star x.1, star x.2) }\n\n@[simp] lemma fst_star [has_star R] [has_star S] (x : R × S) : (star x).1 = star x.1 := rfl\n@[simp] lemma snd_star [has_star R] [has_star S] (x : R × S) : (star x).2 = star x.2 := rfl\n\nlemma star_def [has_star R] [has_star S] (x : R × S) : star x = (star x.1, star x.2) := rfl\n\ninstance [has_involutive_star R] [has_involutive_star S] : has_involutive_star (R × S) :=\n{ star_involutive := λ _, prod.ext (star_star _) (star_star _) }\n\ninstance [semigroup R] [semigroup S] [star_semigroup R] [star_semigroup S] :\n  star_semigroup (R × S) :=\n{ star_mul := λ _ _, prod.ext (star_mul _ _) (star_mul _ _) }\n\ninstance [add_monoid R] [add_monoid S] [star_add_monoid R] [star_add_monoid S] :\n  star_add_monoid (R × S) :=\n{ star_add := λ _ _, prod.ext (star_add _ _) (star_add _ _) }\n\ninstance [non_unital_semiring R] [non_unital_semiring S] [star_ring R] [star_ring S] :\n  star_ring (R × S) :=\n{ ..prod.star_add_monoid, ..(prod.star_semigroup : star_semigroup (R × S)) }\n\ninstance {α : Type w} [has_smul α R] [has_smul α S] [has_star α] [has_star R] [has_star S]\n  [star_module α R] [star_module α S] :\n  star_module α (R × S) :=\n{ star_smul := λ r x, prod.ext (star_smul _ _) (star_smul _ _) }\n\nend prod\n\n@[simp] lemma units.embed_product_star [monoid R] [star_semigroup R] (u : Rˣ) :\n  units.embed_product R (star u) = star (units.embed_product R u) := rfl\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/algebra/star/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.45930134414699264}}
{"text": "/-\nCopyright (c) 2022 Antoine Labelle, Rémi Bottinelli. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Labelle, Rémi Bottinelli\n\n! This file was ported from Lean 3 source module combinatorics.quiver.cast\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Combinatorics.Quiver.Basic\nimport Mathbin.Combinatorics.Quiver.Path\n\n/-!\n\n# Rewriting arrows and paths along vertex equalities\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis files defines `hom.cast` and `path.cast` (and associated lemmas) in order to allow\nrewriting arrows and paths along equalities of their endpoints.\n\n-/\n\n\nuniverse v v₁ v₂ u u₁ u₂\n\nvariable {U : Type _} [Quiver.{u + 1} U]\n\nnamespace Quiver\n\n/-!\n### Rewriting arrows along equalities of vertices\n-/\n\n\n#print Quiver.Hom.cast /-\n/-- Change the endpoints of an arrow using equalities. -/\ndef Hom.cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : u' ⟶ v' :=\n  Eq.ndrec (Eq.ndrec e hv) hu\n#align quiver.hom.cast Quiver.Hom.cast\n-/\n\n/- warning: quiver.hom.cast_eq_cast -> Quiver.Hom.cast_eq_cast is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (e : Quiver.Hom.{succ u1, u2} U _inst_1 u v), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') (Quiver.Hom.cast.{u1, u2} U _inst_1 u v u' v' hu hv e) (cast.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') (Eq.mpr.{0} (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u2} U u (fun (_a : U) => Eq.{1} Prop (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 _a v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v'))) (rfl.{1} Prop (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v'))) u' hu)) (Eq.mpr.{0} (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') (Quiver.Hom.{succ u1, u2} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u2} U v (fun (_a : U) => Eq.{1} Prop (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' _a) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v'))) (rfl.{1} Prop (Eq.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v) (Quiver.Hom.{succ u1, u2} U _inst_1 u' v'))) v' hv)) (rfl.{succ (succ u1)} Type.{u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v')))) e)\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (e : Quiver.Hom.{succ u2, u1} U _inst_1 u v), Eq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') (Quiver.Hom.cast.{u2, u1} U _inst_1 u v u' v' hu hv e) (cast.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') (Eq.mpr.{0} (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (id.{0} (Eq.{1} Prop (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u1} U u (fun (_a : U) => Eq.{1} Prop (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 _a v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v'))) (Eq.refl.{1} Prop (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v'))) u' hu)) (Eq.mpr.{0} (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (id.{0} (Eq.{1} Prop (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') (Quiver.Hom.{succ u2, u1} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u1} U v (fun (_a : U) => Eq.{1} Prop (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' _a) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v'))) (Eq.refl.{1} Prop (Eq.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v) (Quiver.Hom.{succ u2, u1} U _inst_1 u' v'))) v' hv)) (Eq.refl.{succ (succ u2)} Type.{u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v')))) e)\nCase conversion may be inaccurate. Consider using '#align quiver.hom.cast_eq_cast Quiver.Hom.cast_eq_castₓ'. -/\ntheorem Hom.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) :\n    e.cast hu hv = cast (by rw [hu, hv]) e :=\n  by\n  subst_vars\n  rfl\n#align quiver.hom.cast_eq_cast Quiver.Hom.cast_eq_cast\n\n/- warning: quiver.hom.cast_rfl_rfl -> Quiver.Hom.cast_rfl_rfl is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} (e : Quiver.Hom.{succ u1, u2} U _inst_1 u v), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u v) (Quiver.Hom.cast.{u1, u2} U _inst_1 u v u v (rfl.{succ u2} U u) (rfl.{succ u2} U v) e) e\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} (e : Quiver.Hom.{succ u2, u1} U _inst_1 u v), Eq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u v) (Quiver.Hom.cast.{u2, u1} U _inst_1 u v u v (rfl.{succ u1} U u) (rfl.{succ u1} U v) e) e\nCase conversion may be inaccurate. Consider using '#align quiver.hom.cast_rfl_rfl Quiver.Hom.cast_rfl_rflₓ'. -/\n@[simp]\ntheorem Hom.cast_rfl_rfl {u v : U} (e : u ⟶ v) : e.cast rfl rfl = e :=\n  rfl\n#align quiver.hom.cast_rfl_rfl Quiver.Hom.cast_rfl_rfl\n\n/- warning: quiver.hom.cast_cast -> Quiver.Hom.cast_cast is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} {u'' : U} {v'' : U} (e : Quiver.Hom.{succ u1, u2} U _inst_1 u v) (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (hu' : Eq.{succ u2} U u' u'') (hv' : Eq.{succ u2} U v' v''), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u'' v'') (Quiver.Hom.cast.{u1, u2} U _inst_1 u' v' u'' v'' hu' hv' (Quiver.Hom.cast.{u1, u2} U _inst_1 u v u' v' hu hv e)) (Quiver.Hom.cast.{u1, u2} U _inst_1 u v u'' v'' (Eq.trans.{succ u2} U u u' u'' hu hu') (Eq.trans.{succ u2} U v v' v'' hv hv') e)\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} {u'' : U} {v'' : U} (e : Quiver.Hom.{succ u2, u1} U _inst_1 u v) (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (hu' : Eq.{succ u1} U u' u'') (hv' : Eq.{succ u1} U v' v''), Eq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u'' v'') (Quiver.Hom.cast.{u2, u1} U _inst_1 u' v' u'' v'' hu' hv' (Quiver.Hom.cast.{u2, u1} U _inst_1 u v u' v' hu hv e)) (Quiver.Hom.cast.{u2, u1} U _inst_1 u v u'' v'' (Eq.trans.{succ u1} U u u' u'' hu hu') (Eq.trans.{succ u1} U v v' v'' hv hv') e)\nCase conversion may be inaccurate. Consider using '#align quiver.hom.cast_cast Quiver.Hom.cast_castₓ'. -/\n@[simp]\ntheorem Hom.cast_cast {u v u' v' u'' v'' : U} (e : u ⟶ v) (hu : u = u') (hv : v = v')\n    (hu' : u' = u'') (hv' : v' = v'') :\n    (e.cast hu hv).cast hu' hv' = e.cast (hu.trans hu') (hv.trans hv') :=\n  by\n  subst_vars\n  rfl\n#align quiver.hom.cast_cast Quiver.Hom.cast_cast\n\n/- warning: quiver.hom.cast_heq -> Quiver.Hom.cast_heq is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (e : Quiver.Hom.{succ u1, u2} U _inst_1 u v), HEq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') (Quiver.Hom.cast.{u1, u2} U _inst_1 u v u' v' hu hv e) (Quiver.Hom.{succ u1, u2} U _inst_1 u v) e\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (e : Quiver.Hom.{succ u2, u1} U _inst_1 u v), HEq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') (Quiver.Hom.cast.{u2, u1} U _inst_1 u v u' v' hu hv e) (Quiver.Hom.{succ u2, u1} U _inst_1 u v) e\nCase conversion may be inaccurate. Consider using '#align quiver.hom.cast_heq Quiver.Hom.cast_heqₓ'. -/\ntheorem Hom.cast_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) :\n    HEq (e.cast hu hv) e := by\n  subst_vars\n  rfl\n#align quiver.hom.cast_heq Quiver.Hom.cast_heq\n\n/- warning: quiver.hom.cast_eq_iff_heq -> Quiver.Hom.cast_eq_iff_heq is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (e : Quiver.Hom.{succ u1, u2} U _inst_1 u v) (e' : Quiver.Hom.{succ u1, u2} U _inst_1 u' v'), Iff (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') (Quiver.Hom.cast.{u1, u2} U _inst_1 u v u' v' hu hv e) e') (HEq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u v) e (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') e')\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (e : Quiver.Hom.{succ u2, u1} U _inst_1 u v) (e' : Quiver.Hom.{succ u2, u1} U _inst_1 u' v'), Iff (Eq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') (Quiver.Hom.cast.{u2, u1} U _inst_1 u v u' v' hu hv e) e') (HEq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u v) e (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') e')\nCase conversion may be inaccurate. Consider using '#align quiver.hom.cast_eq_iff_heq Quiver.Hom.cast_eq_iff_heqₓ'. -/\ntheorem Hom.cast_eq_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) (e' : u' ⟶ v') :\n    e.cast hu hv = e' ↔ HEq e e' := by\n  rw [hom.cast_eq_cast]\n  exact cast_eq_iff_heq\n#align quiver.hom.cast_eq_iff_heq Quiver.Hom.cast_eq_iff_heq\n\n/- warning: quiver.hom.eq_cast_iff_heq -> Quiver.Hom.eq_cast_iff_heq is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (e : Quiver.Hom.{succ u1, u2} U _inst_1 u v) (e' : Quiver.Hom.{succ u1, u2} U _inst_1 u' v'), Iff (Eq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') e' (Quiver.Hom.cast.{u1, u2} U _inst_1 u v u' v' hu hv e)) (HEq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 u' v') e' (Quiver.Hom.{succ u1, u2} U _inst_1 u v) e)\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (e : Quiver.Hom.{succ u2, u1} U _inst_1 u v) (e' : Quiver.Hom.{succ u2, u1} U _inst_1 u' v'), Iff (Eq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') e' (Quiver.Hom.cast.{u2, u1} U _inst_1 u v u' v' hu hv e)) (HEq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 u' v') e' (Quiver.Hom.{succ u2, u1} U _inst_1 u v) e)\nCase conversion may be inaccurate. Consider using '#align quiver.hom.eq_cast_iff_heq Quiver.Hom.eq_cast_iff_heqₓ'. -/\ntheorem Hom.eq_cast_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) (e' : u' ⟶ v') :\n    e' = e.cast hu hv ↔ HEq e' e :=\n  by\n  rw [eq_comm, hom.cast_eq_iff_heq]\n  exact ⟨HEq.symm, HEq.symm⟩\n#align quiver.hom.eq_cast_iff_heq Quiver.Hom.eq_cast_iff_heq\n\n/-!\n### Rewriting paths along equalities of vertices\n-/\n\n\nopen Path\n\n#print Quiver.Path.cast /-\n/-- Change the endpoints of a path using equalities. -/\ndef Path.cast {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v) : Path u' v' :=\n  Eq.ndrec (Eq.ndrec p hv) hu\n#align quiver.path.cast Quiver.Path.cast\n-/\n\n/- warning: quiver.path.cast_eq_cast -> Quiver.Path.cast_eq_cast is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (p : Quiver.Path.{succ u1, u2} U _inst_1 u v), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v') (Quiver.Path.cast.{u1, u2} U _inst_1 u v u' v' hu hv p) (cast.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v') (Eq.mpr.{0} (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u2} U u (fun (_a : U) => Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 _a v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v'))) (rfl.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v'))) u' hu)) (Eq.mpr.{0} (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v') (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v') (Quiver.Path.{succ u1, u2} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u2} U v (fun (_a : U) => Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' _a) (Quiver.Path.{succ u1, u2} U _inst_1 u' v'))) (rfl.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v) (Quiver.Path.{succ u1, u2} U _inst_1 u' v'))) v' hv)) (rfl.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v')))) p)\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (p : Quiver.Path.{succ u2, u1} U _inst_1 u v), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v') (Quiver.Path.cast.{u2, u1} U _inst_1 u v u' v' hu hv p) (cast.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v') (Eq.mpr.{0} (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (id.{0} (Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u1} U u (fun (_a : U) => Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 _a v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v'))) (Eq.refl.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v'))) u' hu)) (Eq.mpr.{0} (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v') (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (id.{0} (Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v') (Quiver.Path.{succ u2, u1} U _inst_1 u' v'))) (Eq.ndrec.{0, succ u1} U v (fun (_a : U) => Eq.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v')) (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' _a) (Quiver.Path.{succ u2, u1} U _inst_1 u' v'))) (Eq.refl.{1} Prop (Eq.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v) (Quiver.Path.{succ u2, u1} U _inst_1 u' v'))) v' hv)) (Eq.refl.{succ (max (succ u2) (succ u1))} Sort.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v')))) p)\nCase conversion may be inaccurate. Consider using '#align quiver.path.cast_eq_cast Quiver.Path.cast_eq_castₓ'. -/\ntheorem Path.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v) :\n    p.cast hu hv = cast (by rw [hu, hv]) p :=\n  Eq.drec (Eq.drec (Eq.refl (Path.cast (Eq.refl u) (Eq.refl v) p)) hu) hv\n#align quiver.path.cast_eq_cast Quiver.Path.cast_eq_cast\n\n/- warning: quiver.path.cast_rfl_rfl -> Quiver.Path.cast_rfl_rfl is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} (p : Quiver.Path.{succ u1, u2} U _inst_1 u v), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v) (Quiver.Path.cast.{u1, u2} U _inst_1 u v u v (rfl.{succ u2} U u) (rfl.{succ u2} U v) p) p\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} (p : Quiver.Path.{succ u2, u1} U _inst_1 u v), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v) (Quiver.Path.cast.{u2, u1} U _inst_1 u v u v (rfl.{succ u1} U u) (rfl.{succ u1} U v) p) p\nCase conversion may be inaccurate. Consider using '#align quiver.path.cast_rfl_rfl Quiver.Path.cast_rfl_rflₓ'. -/\n@[simp]\ntheorem Path.cast_rfl_rfl {u v : U} (p : Path u v) : p.cast rfl rfl = p :=\n  rfl\n#align quiver.path.cast_rfl_rfl Quiver.Path.cast_rfl_rfl\n\n/- warning: quiver.path.cast_cast -> Quiver.Path.cast_cast is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} {u'' : U} {v'' : U} (p : Quiver.Path.{succ u1, u2} U _inst_1 u v) (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (hu' : Eq.{succ u2} U u' u'') (hv' : Eq.{succ u2} U v' v''), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u'' v'') (Quiver.Path.cast.{u1, u2} U _inst_1 u' v' u'' v'' hu' hv' (Quiver.Path.cast.{u1, u2} U _inst_1 u v u' v' hu hv p)) (Quiver.Path.cast.{u1, u2} U _inst_1 u v u'' v'' (Eq.trans.{succ u2} U u u' u'' hu hu') (Eq.trans.{succ u2} U v v' v'' hv hv') p)\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} {u'' : U} {v'' : U} (p : Quiver.Path.{succ u2, u1} U _inst_1 u v) (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (hu' : Eq.{succ u1} U u' u'') (hv' : Eq.{succ u1} U v' v''), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u'' v'') (Quiver.Path.cast.{u2, u1} U _inst_1 u' v' u'' v'' hu' hv' (Quiver.Path.cast.{u2, u1} U _inst_1 u v u' v' hu hv p)) (Quiver.Path.cast.{u2, u1} U _inst_1 u v u'' v'' (Eq.trans.{succ u1} U u u' u'' hu hu') (Eq.trans.{succ u1} U v v' v'' hv hv') p)\nCase conversion may be inaccurate. Consider using '#align quiver.path.cast_cast Quiver.Path.cast_castₓ'. -/\n@[simp]\ntheorem Path.cast_cast {u v u' v' u'' v'' : U} (p : Path u v) (hu : u = u') (hv : v = v')\n    (hu' : u' = u'') (hv' : v' = v'') :\n    (p.cast hu hv).cast hu' hv' = p.cast (hu.trans hu') (hv.trans hv') :=\n  by\n  subst_vars\n  rfl\n#align quiver.path.cast_cast Quiver.Path.cast_cast\n\n/- warning: quiver.path.cast_nil -> Quiver.Path.cast_nil is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {u' : U} (hu : Eq.{succ u2} U u u'), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' u') (Quiver.Path.cast.{u1, u2} U _inst_1 u u u' u' hu hu (Quiver.Path.nil.{succ u1, u2} U _inst_1 u)) (Quiver.Path.nil.{succ u1, u2} U _inst_1 u')\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {u' : U} (hu : Eq.{succ u1} U u u'), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' u') (Quiver.Path.cast.{u2, u1} U _inst_1 u u u' u' hu hu (Quiver.Path.nil.{succ u2, u1} U _inst_1 u)) (Quiver.Path.nil.{succ u2, u1} U _inst_1 u')\nCase conversion may be inaccurate. Consider using '#align quiver.path.cast_nil Quiver.Path.cast_nilₓ'. -/\n@[simp]\ntheorem Path.cast_nil {u u' : U} (hu : u = u') : (Path.nil : Path u u).cast hu hu = Path.nil :=\n  by\n  subst_vars\n  rfl\n#align quiver.path.cast_nil Quiver.Path.cast_nil\n\n/- warning: quiver.path.cast_heq -> Quiver.Path.cast_heq is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (p : Quiver.Path.{succ u1, u2} U _inst_1 u v), HEq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v') (Quiver.Path.cast.{u1, u2} U _inst_1 u v u' v' hu hv p) (Quiver.Path.{succ u1, u2} U _inst_1 u v) p\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (p : Quiver.Path.{succ u2, u1} U _inst_1 u v), HEq.{max (succ u1) (succ u2)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v') (Quiver.Path.cast.{u2, u1} U _inst_1 u v u' v' hu hv p) (Quiver.Path.{succ u2, u1} U _inst_1 u v) p\nCase conversion may be inaccurate. Consider using '#align quiver.path.cast_heq Quiver.Path.cast_heqₓ'. -/\ntheorem Path.cast_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v) :\n    HEq (p.cast hu hv) p := by\n  rw [path.cast_eq_cast]\n  exact cast_hEq _ _\n#align quiver.path.cast_heq Quiver.Path.cast_heq\n\n/- warning: quiver.path.cast_eq_iff_heq -> Quiver.Path.cast_eq_iff_heq is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (p : Quiver.Path.{succ u1, u2} U _inst_1 u v) (p' : Quiver.Path.{succ u1, u2} U _inst_1 u' v'), Iff (Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v') (Quiver.Path.cast.{u1, u2} U _inst_1 u v u' v' hu hv p) p') (HEq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v) p (Quiver.Path.{succ u1, u2} U _inst_1 u' v') p')\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (p : Quiver.Path.{succ u2, u1} U _inst_1 u v) (p' : Quiver.Path.{succ u2, u1} U _inst_1 u' v'), Iff (Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v') (Quiver.Path.cast.{u2, u1} U _inst_1 u v u' v' hu hv p) p') (HEq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v) p (Quiver.Path.{succ u2, u1} U _inst_1 u' v') p')\nCase conversion may be inaccurate. Consider using '#align quiver.path.cast_eq_iff_heq Quiver.Path.cast_eq_iff_heqₓ'. -/\ntheorem Path.cast_eq_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v)\n    (p' : Path u' v') : p.cast hu hv = p' ↔ HEq p p' :=\n  by\n  rw [path.cast_eq_cast]\n  exact cast_eq_iff_heq\n#align quiver.path.cast_eq_iff_heq Quiver.Path.cast_eq_iff_heq\n\n/- warning: quiver.path.eq_cast_iff_heq -> Quiver.Path.eq_cast_iff_heq is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u2} U u u') (hv : Eq.{succ u2} U v v') (p : Quiver.Path.{succ u1, u2} U _inst_1 u v) (p' : Quiver.Path.{succ u1, u2} U _inst_1 u' v'), Iff (Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v') p' (Quiver.Path.cast.{u1, u2} U _inst_1 u v u' v' hu hv p)) (HEq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' v') p' (Quiver.Path.{succ u1, u2} U _inst_1 u v) p)\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {u' : U} {v' : U} (hu : Eq.{succ u1} U u u') (hv : Eq.{succ u1} U v v') (p : Quiver.Path.{succ u2, u1} U _inst_1 u v) (p' : Quiver.Path.{succ u2, u1} U _inst_1 u' v'), Iff (Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v') p' (Quiver.Path.cast.{u2, u1} U _inst_1 u v u' v' hu hv p)) (HEq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' v') p' (Quiver.Path.{succ u2, u1} U _inst_1 u v) p)\nCase conversion may be inaccurate. Consider using '#align quiver.path.eq_cast_iff_heq Quiver.Path.eq_cast_iff_heqₓ'. -/\ntheorem Path.eq_cast_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v)\n    (p' : Path u' v') : p' = p.cast hu hv ↔ HEq p' p :=\n  ⟨fun h => ((p.cast_eq_iff_heq hu hv p').1 h.symm).symm, fun h =>\n    ((p.cast_eq_iff_heq hu hv p').2 h.symm).symm⟩\n#align quiver.path.eq_cast_iff_heq Quiver.Path.eq_cast_iff_heq\n\n/- warning: quiver.path.cast_cons -> Quiver.Path.cast_cons is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {w : U} {u' : U} {w' : U} (p : Quiver.Path.{succ u1, u2} U _inst_1 u v) (e : Quiver.Hom.{succ u1, u2} U _inst_1 v w) (hu : Eq.{succ u2} U u u') (hw : Eq.{succ u2} U w w'), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u' w') (Quiver.Path.cast.{u1, u2} U _inst_1 u w u' w' hu hw (Quiver.Path.cons.{succ u1, u2} U _inst_1 u v w p e)) (Quiver.Path.cons.{succ u1, u2} U _inst_1 u' v w' (Quiver.Path.cast.{u1, u2} U _inst_1 u v u' v hu (rfl.{succ u2} U v) p) (Quiver.Hom.cast.{u1, u2} U _inst_1 v w v w' (rfl.{succ u2} U v) hw e))\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {w : U} {u' : U} {w' : U} (p : Quiver.Path.{succ u2, u1} U _inst_1 u v) (e : Quiver.Hom.{succ u2, u1} U _inst_1 v w) (hu : Eq.{succ u1} U u u') (hw : Eq.{succ u1} U w w'), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u' w') (Quiver.Path.cast.{u2, u1} U _inst_1 u w u' w' hu hw (Quiver.Path.cons.{succ u2, u1} U _inst_1 u v w p e)) (Quiver.Path.cons.{succ u2, u1} U _inst_1 u' v w' (Quiver.Path.cast.{u2, u1} U _inst_1 u v u' v hu (rfl.{succ u1} U v) p) (Quiver.Hom.cast.{u2, u1} U _inst_1 v w v w' (rfl.{succ u1} U v) hw e))\nCase conversion may be inaccurate. Consider using '#align quiver.path.cast_cons Quiver.Path.cast_consₓ'. -/\ntheorem Path.cast_cons {u v w u' w' : U} (p : Path u v) (e : v ⟶ w) (hu : u = u') (hw : w = w') :\n    (p.cons e).cast hu hw = (p.cast hu rfl).cons (e.cast rfl hw) :=\n  by\n  subst_vars\n  rfl\n#align quiver.path.cast_cons Quiver.Path.cast_cons\n\n/- warning: quiver.cast_eq_of_cons_eq_cons -> Quiver.cast_eq_of_cons_eq_cons is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {v' : U} {w : U} {p : Quiver.Path.{succ u1, u2} U _inst_1 u v} {p' : Quiver.Path.{succ u1, u2} U _inst_1 u v'} {e : Quiver.Hom.{succ u1, u2} U _inst_1 v w} {e' : Quiver.Hom.{succ u1, u2} U _inst_1 v' w} (h : Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u w) (Quiver.Path.cons.{succ u1, u2} U _inst_1 u v w p e) (Quiver.Path.cons.{succ u1, u2} U _inst_1 u v' w p' e')), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u v') (Quiver.Path.cast.{u1, u2} U _inst_1 u v u v' (rfl.{succ u2} U u) (Quiver.Path.obj_eq_of_cons_eq_cons.{u2, succ u1} U _inst_1 u v v' w p p' e e' h) p) p'\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {v' : U} {w : U} {p : Quiver.Path.{succ u2, u1} U _inst_1 u v} {p' : Quiver.Path.{succ u2, u1} U _inst_1 u v'} {e : Quiver.Hom.{succ u2, u1} U _inst_1 v w} {e' : Quiver.Hom.{succ u2, u1} U _inst_1 v' w} (h : Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u w) (Quiver.Path.cons.{succ u2, u1} U _inst_1 u v w p e) (Quiver.Path.cons.{succ u2, u1} U _inst_1 u v' w p' e')), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u v') (Quiver.Path.cast.{u2, u1} U _inst_1 u v u v' (rfl.{succ u1} U u) (Quiver.Path.obj_eq_of_cons_eq_cons.{succ u2, u1} U _inst_1 u v v' w p p' e e' h) p) p'\nCase conversion may be inaccurate. Consider using '#align quiver.cast_eq_of_cons_eq_cons Quiver.cast_eq_of_cons_eq_consₓ'. -/\ntheorem cast_eq_of_cons_eq_cons {u v v' w : U} {p : Path u v} {p' : Path u v'} {e : v ⟶ w}\n    {e' : v' ⟶ w} (h : p.cons e = p'.cons e') : p.cast rfl (obj_eq_of_cons_eq_cons h) = p' :=\n  by\n  rw [path.cast_eq_iff_heq]\n  exact heq_of_cons_eq_cons h\n#align quiver.cast_eq_of_cons_eq_cons Quiver.cast_eq_of_cons_eq_cons\n\n/- warning: quiver.hom_cast_eq_of_cons_eq_cons -> Quiver.hom_cast_eq_of_cons_eq_cons is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} {v' : U} {w : U} {p : Quiver.Path.{succ u1, u2} U _inst_1 u v} {p' : Quiver.Path.{succ u1, u2} U _inst_1 u v'} {e : Quiver.Hom.{succ u1, u2} U _inst_1 v w} {e' : Quiver.Hom.{succ u1, u2} U _inst_1 v' w} (h : Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 u w) (Quiver.Path.cons.{succ u1, u2} U _inst_1 u v w p e) (Quiver.Path.cons.{succ u1, u2} U _inst_1 u v' w p' e')), Eq.{succ u1} (Quiver.Hom.{succ u1, u2} U _inst_1 v' w) (Quiver.Hom.cast.{u1, u2} U _inst_1 v w v' w (Quiver.Path.obj_eq_of_cons_eq_cons.{u2, succ u1} U _inst_1 u v v' w p p' e e' h) (rfl.{succ u2} U w) e) e'\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} {v' : U} {w : U} {p : Quiver.Path.{succ u2, u1} U _inst_1 u v} {p' : Quiver.Path.{succ u2, u1} U _inst_1 u v'} {e : Quiver.Hom.{succ u2, u1} U _inst_1 v w} {e' : Quiver.Hom.{succ u2, u1} U _inst_1 v' w} (h : Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 u w) (Quiver.Path.cons.{succ u2, u1} U _inst_1 u v w p e) (Quiver.Path.cons.{succ u2, u1} U _inst_1 u v' w p' e')), Eq.{succ u2} (Quiver.Hom.{succ u2, u1} U _inst_1 v' w) (Quiver.Hom.cast.{u2, u1} U _inst_1 v w v' w (Quiver.Path.obj_eq_of_cons_eq_cons.{succ u2, u1} U _inst_1 u v v' w p p' e e' h) (rfl.{succ u1} U w) e) e'\nCase conversion may be inaccurate. Consider using '#align quiver.hom_cast_eq_of_cons_eq_cons Quiver.hom_cast_eq_of_cons_eq_consₓ'. -/\ntheorem hom_cast_eq_of_cons_eq_cons {u v v' w : U} {p : Path u v} {p' : Path u v'} {e : v ⟶ w}\n    {e' : v' ⟶ w} (h : p.cons e = p'.cons e') : e.cast (obj_eq_of_cons_eq_cons h) rfl = e' :=\n  by\n  rw [hom.cast_eq_iff_heq]\n  exact hom_heq_of_cons_eq_cons h\n#align quiver.hom_cast_eq_of_cons_eq_cons Quiver.hom_cast_eq_of_cons_eq_cons\n\n/- warning: quiver.eq_nil_of_length_zero -> Quiver.eq_nil_of_length_zero is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u2}} [_inst_1 : Quiver.{succ u1, u2} U] {u : U} {v : U} (p : Quiver.Path.{succ u1, u2} U _inst_1 u v) (hzero : Eq.{1} Nat (Quiver.Path.length.{u2, succ u1} U _inst_1 u v p) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u1, u2} U _inst_1 v v) (Quiver.Path.cast.{u1, u2} U _inst_1 u v v v (Quiver.Path.eq_of_length_zero.{u2, succ u1} U _inst_1 u v p hzero) (rfl.{succ u2} U v) p) (Quiver.Path.nil.{succ u1, u2} U _inst_1 v)\nbut is expected to have type\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{succ u2, u1} U] {u : U} {v : U} (p : Quiver.Path.{succ u2, u1} U _inst_1 u v) (hzero : Eq.{1} Nat (Quiver.Path.length.{u1, succ u2} U _inst_1 u v p) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))), Eq.{max (succ u2) (succ u1)} (Quiver.Path.{succ u2, u1} U _inst_1 v v) (Quiver.Path.cast.{u2, u1} U _inst_1 u v v v (Quiver.Path.eq_of_length_zero.{succ u2, u1} U _inst_1 u v p hzero) (rfl.{succ u1} U v) p) (Quiver.Path.nil.{succ u2, u1} U _inst_1 v)\nCase conversion may be inaccurate. Consider using '#align quiver.eq_nil_of_length_zero Quiver.eq_nil_of_length_zeroₓ'. -/\ntheorem eq_nil_of_length_zero {u v : U} (p : Path u v) (hzero : p.length = 0) :\n    p.cast (eq_of_length_zero p hzero) rfl = Path.nil := by\n  cases p <;> simpa only [Nat.succ_ne_zero, length_cons] using hzero\n#align quiver.eq_nil_of_length_zero Quiver.eq_nil_of_length_zero\n\nend Quiver\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Combinatorics/Quiver/Cast.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.45930134100198183}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.limits.shapes.split_coequalizer\n! leanprover-community/mathlib commit 024a4231815538ac739f52d08dd20a55da0d6b23\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Limits.Shapes.Equalizers\n\n/-!\n# Split coequalizers\n\nWe define what it means for a triple of morphisms `f g : X ⟶ Y`, `π : Y ⟶ Z` to be a split\ncoequalizer: there is a section `s` of `π` and a section `t` of `g`, which additionally satisfy\n`t ≫ f = π ≫ s`.\n\nIn addition, we show that every split coequalizer is a coequalizer\n(`CategoryTheory.IsSplitCoequalizer.isCoequalizer`) and absolute\n(`CategoryTheory.IsSplitCoequalizer.map`)\n\nA pair `f g : X ⟶ Y` has a split coequalizer if there is a `Z` and `π : Y ⟶ Z` making `f,g,π` a\nsplit coequalizer.\nA pair `f g : X ⟶ Y` has a `G`-split coequalizer if `G f, G g` has a split coequalizer.\n\nThese definitions and constructions are useful in particular for the monadicity theorems.\n\n## TODO\n\nDualise to split equalizers.\n-/\n\n\nnamespace CategoryTheory\n\nuniverse v v₂ u u₂\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\nvariable (G : C ⥤ D)\n\nvariable {X Y : C} (f g : X ⟶ Y)\n\n/-- A split coequalizer diagram consists of morphisms\n\n      f   π\n    X ⇉ Y → Z\n      g\n\nsatisfying `f ≫ π = g ≫ π` together with morphisms\n\n      t   s\n    X ← Y ← Z\n\nsatisfying `s ≫ π = 𝟙 Z`, `t ≫ g = 𝟙 Y` and `t ≫ f = π ≫ s`.\n\nThe name \"coequalizer\" is appropriate, since any split coequalizer is a coequalizer, see\n`Category_theory.IsSplitCoequalizer.isCoequalizer`.\nSplit coequalizers are also absolute, since a functor preserves all the structure above.\n-/\nstructure IsSplitCoequalizer {Z : C} (π : Y ⟶ Z) where\n  /-- A map from the coequalizer to `Y` -/\n  rightSection : Z ⟶ Y\n  /-- A map in the opposite direction to `f` and `g` -/\n  leftSection : Y ⟶ X\n  /-- Composition of `π` with `f` and with `g` agree -/\n  condition : f ≫ π = g ≫ π\n  /-- `rightSection` splits `π` -/\n  rightSection_π : rightSection ≫ π = 𝟙 Z\n  /-- `leftSection` splits `g` -/\n  leftSection_bottom : leftSection ≫ g = 𝟙 Y\n  /-- `leftSection` composed with `f` is `pi` composed with `rightSection` -/\n  leftSection_top : leftSection ≫ f = π ≫ rightSection\n#align category_theory.is_split_coequalizer CategoryTheory.IsSplitCoequalizer\n#align category_theory.is_split_coequalizer.right_section CategoryTheory.IsSplitCoequalizer.rightSection\n#align category_theory.is_split_coequalizer.left_section CategoryTheory.IsSplitCoequalizer.leftSection\n#align category_theory.is_split_coequalizer.right_section_π CategoryTheory.IsSplitCoequalizer.rightSection_π\n#align category_theory.is_split_coequalizer.left_section_bottom CategoryTheory.IsSplitCoequalizer.leftSection_bottom\n#align category_theory.is_split_coequalizer.left_section_top CategoryTheory.IsSplitCoequalizer.leftSection_top\n\ninstance {X : C} : Inhabited (IsSplitCoequalizer (𝟙 X) (𝟙 X) (𝟙 X)) where\n  default := ⟨𝟙 X, 𝟙 X, rfl, Category.id_comp _, Category.id_comp _, rfl⟩\n\nopen IsSplitCoequalizer\n\nattribute [reassoc] condition\n\nattribute [reassoc (attr := simp)] rightSection_π leftSection_bottom leftSection_top\n\nvariable {f g}\n\n/-- Split coequalizers are absolute: they are preserved by any functor. -/\n@[simps]\ndef IsSplitCoequalizer.map {Z : C} {π : Y ⟶ Z} (q : IsSplitCoequalizer f g π) (F : C ⥤ D) :\n    IsSplitCoequalizer (F.map f) (F.map g) (F.map π)\n    where\n  rightSection := F.map q.rightSection\n  leftSection := F.map q.leftSection\n  condition := by rw [← F.map_comp, q.condition, F.map_comp]\n  rightSection_π := by rw [← F.map_comp, q.rightSection_π, F.map_id]\n  leftSection_bottom := by rw [← F.map_comp, q.leftSection_bottom, F.map_id]\n  leftSection_top := by rw [← F.map_comp, q.leftSection_top, F.map_comp]\n#align category_theory.is_split_coequalizer.map CategoryTheory.IsSplitCoequalizer.map\n\nsection\n\nopen Limits\n\n/-- A split coequalizer clearly induces a cofork. -/\n@[simps! pt]\ndef IsSplitCoequalizer.asCofork {Z : C} {h : Y ⟶ Z} (t : IsSplitCoequalizer f g h) :\n    Cofork f g := Cofork.ofπ h t.condition\n#align category_theory.is_split_coequalizer.as_cofork CategoryTheory.IsSplitCoequalizer.asCofork\n\n@[simp]\ntheorem IsSplitCoequalizer.asCofork_π {Z : C} {h : Y ⟶ Z} (t : IsSplitCoequalizer f g h) :\n    t.asCofork.π = h := rfl\n#align category_theory.is_split_coequalizer.as_cofork_π CategoryTheory.IsSplitCoequalizer.asCofork_π\n\n/--\nThe cofork induced by a split coequalizer is a coequalizer, justifying the name. In some cases it\nis more convenient to show a given cofork is a coequalizer by showing it is split.\n-/\ndef IsSplitCoequalizer.isCoequalizer {Z : C} {h : Y ⟶ Z} (t : IsSplitCoequalizer f g h) :\n    IsColimit t.asCofork :=\n  Cofork.IsColimit.mk' _ fun s =>\n    ⟨t.rightSection ≫ s.π, by\n      dsimp\n      rw [← t.leftSection_top_assoc, s.condition, t.leftSection_bottom_assoc], fun hm => by\n      simp [← hm]⟩\n#align category_theory.is_split_coequalizer.is_coequalizer CategoryTheory.IsSplitCoequalizer.isCoequalizer\n\nend\n\nvariable (f g)\n\n/--\nThe pair `f,g` is a split pair if there is a `h : Y ⟶ Z` so that `f, g, h` forms a split coequalizer\nin `C`.\n-/\nclass HasSplitCoequalizer : Prop where\n  /-- There is some split coequalizer -/\n  splittable : ∃ (Z : C)(h : Y ⟶ Z), Nonempty (IsSplitCoequalizer f g h)\n#align category_theory.has_split_coequalizer CategoryTheory.HasSplitCoequalizer\n\n/--\nThe pair `f,g` is a `G`-split pair if there is a `h : G Y ⟶ Z` so that `G f, G g, h` forms a split\ncoequalizer in `D`.\n-/\nabbrev Functor.IsSplitPair : Prop :=\n  HasSplitCoequalizer (G.map f) (G.map g)\n#align category_theory.functor.is_split_pair CategoryTheory.Functor.IsSplitPair\n\n/-- Get the coequalizer object from the typeclass `IsSplitPair`. -/\nnoncomputable def HasSplitCoequalizer.coequalizerOfSplit [HasSplitCoequalizer f g] : C :=\n  (@splittable _ _ _ _ f g).choose\n#align category_theory.has_split_coequalizer.coequalizer_of_split CategoryTheory.HasSplitCoequalizer.coequalizerOfSplit\n\n/-- Get the coequalizer morphism from the typeclass `IsSplitPair`. -/\nnoncomputable def HasSplitCoequalizer.coequalizerπ [HasSplitCoequalizer f g] :\n    Y ⟶ HasSplitCoequalizer.coequalizerOfSplit f g :=\n  (@splittable _ _ _ _ f g).choose_spec.choose\n#align category_theory.has_split_coequalizer.coequalizer_π CategoryTheory.HasSplitCoequalizer.coequalizerπ\n\n/-- The coequalizer morphism `coequalizeπ` gives a split coequalizer on `f,g`. -/\nnoncomputable def HasSplitCoequalizer.isSplitCoequalizer [HasSplitCoequalizer f g] :\n    IsSplitCoequalizer f g (HasSplitCoequalizer.coequalizerπ f g) :=\n  Classical.choice (@splittable _ _ _ _ f g).choose_spec.choose_spec\n#align category_theory.has_split_coequalizer.is_split_coequalizer CategoryTheory.HasSplitCoequalizer.isSplitCoequalizer\n\n/-- If `f, g` is split, then `G f, G g` is split. -/\ninstance map_is_split_pair [HasSplitCoequalizer f g] : HasSplitCoequalizer (G.map f) (G.map g)\n    where splittable :=\n    ⟨_, _, ⟨IsSplitCoequalizer.map (HasSplitCoequalizer.isSplitCoequalizer f g) _⟩⟩\n#align category_theory.map_is_split_pair CategoryTheory.map_is_split_pair\n\nnamespace Limits\n\n/-- If a pair has a split coequalizer, it has a coequalizer. -/\ninstance (priority := 1) hasCoequalizer_of_hasSplitCoequalizer [HasSplitCoequalizer f g] :\n    HasCoequalizer f g :=\n  HasColimit.mk ⟨_, (HasSplitCoequalizer.isSplitCoequalizer f g).isCoequalizer⟩\n#align category_theory.limits.has_coequalizer_of_has_split_coequalizer CategoryTheory.Limits.hasCoequalizer_of_hasSplitCoequalizer\n\nend Limits\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Limits/Shapes/SplitCoequalizer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.45930133618095703}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport algebra.category.Mon.basic\nimport category_theory.endomorphism\n\n/-!\n# Category instances for group, add_group, comm_group, and add_comm_group.\n\nWe introduce the bundled categories:\n* `Group`\n* `AddGroup`\n* `CommGroup`\n* `AddCommGroup`\nalong with the relevant forgetful functors between them, and to the bundled monoid categories.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of groups and group morphisms. -/\n@[to_additive AddGroup]\ndef Group : Type (u+1) := bundled group\n\n/-- The category of additive groups and group morphisms -/\nadd_decl_doc AddGroup\n\nnamespace Group\n\n@[to_additive]\ninstance : bundled_hom.parent_projection group.to_monoid := ⟨⟩\n\nattribute [derive [has_coe_to_sort, large_category, concrete_category]] Group AddGroup\n\n/-- Construct a bundled `Group` from the underlying type and typeclass. -/\n@[to_additive] def of (X : Type u) [group X] : Group := bundled.of X\n\n/-- Construct a bundled `AddGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddGroup.of\n\n@[to_additive]\ninstance (G : Group) : group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [group R] : (Group.of R : Type u) = R := rfl\n\n@[to_additive]\ninstance : has_one Group := ⟨Group.of punit⟩\n\n@[to_additive]\ninstance : inhabited Group := ⟨1⟩\n\n@[to_additive]\ninstance one.unique : unique (1 : Group) :=\n{ default := 1,\n  uniq := λ a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : Group) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[ext, to_additive]\n\n\n-- should to_additive do this automatically?\nattribute [ext] AddGroup.ext\n\n@[to_additive has_forget_to_AddMon]\ninstance has_forget_to_Mon : has_forget₂ Group Mon := bundled_hom.forget₂ _ _\n\nend Group\n\n/-- The category of commutative groups and group morphisms. -/\n@[to_additive AddCommGroup]\ndef CommGroup : Type (u+1) := bundled comm_group\n\n/-- The category of additive commutative groups and group morphisms. -/\nadd_decl_doc AddCommGroup\n\n/-- `Ab` is an abbreviation for `AddCommGroup`, for the sake of mathematicians' sanity. -/\nabbreviation Ab := AddCommGroup\n\nnamespace CommGroup\n\n@[to_additive]\ninstance : bundled_hom.parent_projection comm_group.to_group := ⟨⟩\n\nattribute [derive [has_coe_to_sort, large_category, concrete_category]] CommGroup AddCommGroup\n\n/-- Construct a bundled `CommGroup` from the underlying type and typeclass. -/\n@[to_additive] def of (G : Type u) [comm_group G] : CommGroup := bundled.of G\n\n/-- Construct a bundled `AddCommGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddCommGroup.of\n\n@[to_additive]\ninstance comm_group_instance (G : CommGroup) : comm_group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [comm_group R] : (CommGroup.of R : Type u) = R := rfl\n\n@[to_additive] instance : has_one CommGroup := ⟨CommGroup.of punit⟩\n\n@[to_additive] instance : inhabited CommGroup := ⟨1⟩\n\n@[to_additive]\ninstance one.unique : unique (1 : CommGroup) :=\n{ default := 1,\n  uniq := λ a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : CommGroup) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[to_additive,ext]\nlemma ext (G H : CommGroup) (f₁ f₂ : G ⟶ H) (w : ∀ x, f₁ x = f₂ x) : f₁ = f₂ :=\nby { ext1, apply w }\n\nattribute [ext] AddCommGroup.ext\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget₂ CommGroup Group := bundled_hom.forget₂ _ _\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget₂ CommGroup CommMon :=\ninduced_category.has_forget₂ (λ G : CommGroup, CommMon.of G)\n\nend CommGroup\n\n-- This example verifies an improvement possible in Lean 3.8.\n-- Before that, to have `monoid_hom.map_map` usable by `simp` here,\n-- we had to mark all the concrete category `has_coe_to_sort` instances reducible.\n-- Now, it just works.\n@[to_additive]\nexample {R S : CommGroup} (i : R ⟶ S) (r : R) (h : r = 1) : i r = 1 :=\nby simp [h]\n\nnamespace AddCommGroup\n\n/-- Any element of an abelian group gives a unique morphism from `ℤ` sending\n`1` to that element. -/\n-- Note that because `ℤ : Type 0`, this forces `G : AddCommGroup.{0}`,\n-- so we write this explicitly to be clear.\n-- TODO generalize this, requiring a `ulift_instances.lean` file\ndef as_hom {G : AddCommGroup.{0}} (g : G) : (AddCommGroup.of ℤ) ⟶ G :=\ngmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : ℤ) : (as_hom g) i = i • g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\nλ h k w, by convert congr_arg (λ k : (AddCommGroup.of ℤ) ⟶ G, (k : ℤ → G) (1 : ℤ)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of ℤ) ⟶ G) (w : f (1 : ℤ) = g (1 : ℤ)) : f = g :=\nadd_monoid_hom.ext_int w\n\n-- TODO: this argument should be generalised to the situation where\n-- the forgetful functor is representable.\nlemma injective_of_mono {G H : AddCommGroup.{0}} (f : G ⟶ H) [mono f] : function.injective f :=\nλ g₁ g₂ h,\nbegin\n  have t0 : as_hom g₁ ≫ f = as_hom g₂ ≫ f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g₁ = as_hom g₂ := (cancel_mono _).1 t0,\n  apply as_hom_injective t1,\nend\n\nend AddCommGroup\n\nvariables {X Y : Type u}\n\n/-- Build an isomorphism in the category `Group` from a `mul_equiv` between `group`s. -/\n@[to_additive add_equiv.to_AddGroup_iso, simps]\ndef mul_equiv.to_Group_iso [group X] [group Y] (e : X ≃* Y) : Group.of X ≅ Group.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddGroup` from an `add_equiv` between `add_group`s. -/\nadd_decl_doc add_equiv.to_AddGroup_iso\n\n/-- Build an isomorphism in the category `CommGroup` from a `mul_equiv` between `comm_group`s. -/\n@[to_additive add_equiv.to_AddCommGroup_iso, simps]\ndef mul_equiv.to_CommGroup_iso [comm_group X] [comm_group Y] (e : X ≃* Y) :\n  CommGroup.of X ≅ CommGroup.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddCommGroup` from a `add_equiv` between\n`add_comm_group`s. -/\nadd_decl_doc add_equiv.to_AddCommGroup_iso\n\nnamespace category_theory.iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Group`. -/\n@[to_additive AddGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism in the category\n`AddGroup`.\", simps]\ndef Group_iso_to_mul_equiv {X Y : Group} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\n/-- Build a `mul_equiv` from an isomorphism in the category `CommGroup`. -/\n@[to_additive AddCommGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism\nin the category `AddCommGroup`.\", simps]\ndef CommGroup_iso_to_mul_equiv {X Y : CommGroup} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\nend category_theory.iso\n\n/-- multiplicative equivalences between `group`s are the same as (isomorphic to) isomorphisms\nin `Group` -/\n@[to_additive add_equiv_iso_AddGroup_iso \"additive equivalences between `add_group`s are the same\nas (isomorphic to) isomorphisms in `AddGroup`\"]\ndef mul_equiv_iso_Group_iso {X Y : Type u} [group X] [group Y] :\n  (X ≃* Y) ≅ (Group.of X ≅ Group.of Y) :=\n{ hom := λ e, e.to_Group_iso,\n  inv := λ i, i.Group_iso_to_mul_equiv, }\n\n/-- multiplicative equivalences between `comm_group`s are the same as (isomorphic to) isomorphisms\nin `CommGroup` -/\n@[to_additive add_equiv_iso_AddCommGroup_iso \"additive equivalences between `add_comm_group`s are\nthe same as (isomorphic to) isomorphisms in `AddCommGroup`\"]\ndef mul_equiv_iso_CommGroup_iso {X Y : Type u} [comm_group X] [comm_group Y] :\n  (X ≃* Y) ≅ (CommGroup.of X ≅ CommGroup.of Y) :=\n{ hom := λ e, e.to_CommGroup_iso,\n  inv := λ i, i.CommGroup_iso_to_mul_equiv, }\n\nnamespace category_theory.Aut\n\n/-- The (bundled) group of automorphisms of a type is isomorphic to the (bundled) group\nof permutations. -/\ndef iso_perm {α : Type u} : Group.of (Aut α) ≅ Group.of (equiv.perm α) :=\n{ hom := ⟨λ g, g.to_equiv, (by tidy), (by tidy)⟩,\n  inv := ⟨λ g, g.to_iso, (by tidy), (by tidy)⟩ }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {α : Type u} : Aut α ≃* equiv.perm α :=\niso_perm.Group_iso_to_mul_equiv\n\nend category_theory.Aut\n\n@[to_additive]\ninstance Group.forget_reflects_isos : reflects_isomorphisms (forget Group.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Group_iso).1⟩,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommGroup_iso).1⟩,\n  end }\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/category/Group/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982315512489, "lm_q2_score": 0.7090191214879992, "lm_q1q2_score": 0.459301333035946}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Reid Barton\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.images\nimport Mathlib.category_theory.filtered\nimport Mathlib.tactic.equiv_rw\nimport Mathlib.PostPort\n\nuniverses u \n\nnamespace Mathlib\n\nnamespace category_theory.limits.types\n\n\n/--\n(internal implementation) the limit cone of a functor,\nimplemented as flat sections of a pi type\n-/\ndef limit_cone {J : Type u} [small_category J] (F : J ⥤ Type u) : cone F :=\n  cone.mk (↥(functor.sections F))\n    (nat_trans.mk\n      fun (j : J) (u : functor.obj (functor.obj (functor.const J) ↥(functor.sections F)) j) => subtype.val u j)\n\n/-- (internal implementation) the fact that the proposed limit cone is the limit -/\ndef limit_cone_is_limit {J : Type u} [small_category J] (F : J ⥤ Type u) : is_limit (limit_cone F) :=\n  is_limit.mk fun (s : cone F) (v : cone.X s) => { val := fun (j : J) => nat_trans.app (cone.π s) j v, property := sorry }\n\n/--\nThe category of types has all limits.\n\nSee https://stacks.math.columbia.edu/tag/002U.\n-/\nprotected instance sort.category_theory.limits.has_limits : has_limits (Type u) :=\n  has_limits.mk\n    fun (J : Type u) (𝒥 : small_category J) =>\n      has_limits_of_shape.mk fun (F : J ⥤ Type u) => has_limit.mk (limit_cone.mk (limit_cone F) (limit_cone_is_limit F))\n\n/--\nThe equivalence between a limiting cone of `F` in `Type u` and the \"concrete\" definition as the\nsections of `F`.\n-/\ndef is_limit_equiv_sections {J : Type u} [small_category J] {F : J ⥤ Type u} {c : cone F} (t : is_limit c) : cone.X c ≃ ↥(functor.sections F) :=\n  iso.to_equiv (is_limit.cone_point_unique_up_to_iso t (limit_cone_is_limit F))\n\n@[simp] theorem is_limit_equiv_sections_apply {J : Type u} [small_category J] {F : J ⥤ Type u} {c : cone F} (t : is_limit c) (j : J) (x : cone.X c) : coe (coe_fn (is_limit_equiv_sections t) x) j = nat_trans.app (cone.π c) j x :=\n  rfl\n\n@[simp] theorem is_limit_equiv_sections_symm_apply {J : Type u} [small_category J] {F : J ⥤ Type u} {c : cone F} (t : is_limit c) (x : ↥(functor.sections F)) (j : J) : nat_trans.app (cone.π c) j (coe_fn (equiv.symm (is_limit_equiv_sections t)) x) = coe x j := sorry\n\n/--\nThe equivalence between the abstract limit of `F` in `Type u`\nand the \"concrete\" definition as the sections of `F`.\n-/\ndef limit_equiv_sections {J : Type u} [small_category J] (F : J ⥤ Type u) : limit F ≃ ↥(functor.sections F) :=\n  is_limit_equiv_sections (limit.is_limit F)\n\n@[simp] theorem limit_equiv_sections_apply {J : Type u} [small_category J] (F : J ⥤ Type u) (x : limit F) (j : J) : coe (coe_fn (limit_equiv_sections F) x) j = limit.π F j x :=\n  rfl\n\n@[simp] theorem limit_equiv_sections_symm_apply {J : Type u} [small_category J] (F : J ⥤ Type u) (x : ↥(functor.sections F)) (j : J) : limit.π F j (coe_fn (equiv.symm (limit_equiv_sections F)) x) = coe x j :=\n  is_limit_equiv_sections_symm_apply (limit.is_limit F) x j\n\n/--\nConstruct a term of `limit F : Type u` from a family of terms `x : Π j, F.obj j`\nwhich are \"coherent\": `∀ (j j') (f : j ⟶ j'), F.map f (x j) = x j'`.\n-/\ndef limit.mk {J : Type u} [small_category J] (F : J ⥤ Type u) (x : (j : J) → functor.obj F j) (h : ∀ (j j' : J) (f : j ⟶ j'), functor.map F f (x j) = x j') : limit F :=\n  coe_fn (equiv.symm (limit_equiv_sections F)) { val := x, property := h }\n\n@[simp] theorem limit.π_mk {J : Type u} [small_category J] (F : J ⥤ Type u) (x : (j : J) → functor.obj F j) (h : ∀ (j j' : J) (f : j ⟶ j'), functor.map F f (x j) = x j') (j : J) : limit.π F j (limit.mk F x h) = x j := sorry\n\n-- PROJECT: prove this for concrete categories where the forgetful functor preserves limits\n\ntheorem limit_ext {J : Type u} [small_category J] (F : J ⥤ Type u) (x : limit F) (y : limit F) (w : ∀ (j : J), limit.π F j x = limit.π F j y) : x = y := sorry\n\ntheorem limit_ext_iff {J : Type u} [small_category J] (F : J ⥤ Type u) (x : limit F) (y : limit F) : x = y ↔ ∀ (j : J), limit.π F j x = limit.π F j y :=\n  { mp := fun (t : x = y) (_x : J) => t ▸ rfl, mpr := limit_ext F x y }\n\n-- TODO: are there other limits lemmas that should have `_apply` versions?\n\n-- Can we generate these like with `@[reassoc]`?\n\n-- PROJECT: prove these for any concrete category where the forgetful functor preserves limits?\n\n@[simp] theorem limit.w_apply {J : Type u} [small_category J] {F : J ⥤ Type u} {j : J} {j' : J} {x : limit F} (f : j ⟶ j') : functor.map F f (limit.π F j x) = limit.π F j' x :=\n  congr_fun (limit.w F f) x\n\n@[simp] theorem limit.lift_π_apply {J : Type u} [small_category J] (F : J ⥤ Type u) (s : cone F) (j : J) (x : cone.X s) : limit.π F j (limit.lift F s x) = nat_trans.app (cone.π s) j x :=\n  congr_fun (limit.lift_π s j) x\n\n@[simp] theorem limit.map_π_apply {J : Type u} [small_category J] {F : J ⥤ Type u} {G : J ⥤ Type u} (α : F ⟶ G) (j : J) (x : limit F) : limit.π G j (lim_map α x) = nat_trans.app α j (limit.π F j x) :=\n  congr_fun (lim_map_π α j) x\n\n/--\nThe relation defining the quotient type which implements the colimit of a functor `F : J ⥤ Type u`.\nSee `category_theory.limits.types.quot`.\n-/\ndef quot.rel {J : Type u} [small_category J] (F : J ⥤ Type u) : (sigma fun (j : J) => functor.obj F j) → (sigma fun (j : J) => functor.obj F j) → Prop :=\n  fun (p p' : sigma fun (j : J) => functor.obj F j) =>\n    ∃ (f : sigma.fst p ⟶ sigma.fst p'), sigma.snd p' = functor.map F f (sigma.snd p)\n\n/--\nA quotient type implementing the colimit of a functor `F : J ⥤ Type u`,\nas pairs `⟨j, x⟩` where `x : F.obj j`, modulo the equivalence relation generated by\n`⟨j, x⟩ ~ ⟨j', x'⟩` whenever there is a morphism `f : j ⟶ j'` so `F.map f x = x'`.\n-/\ndef quot {J : Type u} [small_category J] (F : J ⥤ Type u) :=\n  Quot sorry\n\n/--\n(internal implementation) the colimit cocone of a functor,\nimplemented as a quotient of a sigma type\n-/\ndef colimit_cocone {J : Type u} [small_category J] (F : J ⥤ Type u) : cocone F :=\n  cocone.mk (quot F) (nat_trans.mk fun (j : J) (x : functor.obj F j) => Quot.mk (quot.rel F) (sigma.mk j x))\n\n/-- (internal implementation) the fact that the proposed colimit cocone is the colimit -/\ndef colimit_cocone_is_colimit {J : Type u} [small_category J] (F : J ⥤ Type u) : is_colimit (colimit_cocone F) :=\n  is_colimit.mk\n    fun (s : cocone F) =>\n      Quot.lift (fun (p : sigma fun (j : J) => functor.obj F j) => nat_trans.app (cocone.ι s) (sigma.fst p) (sigma.snd p))\n        sorry\n\n/--\nThe category of types has all colimits.\n\nSee https://stacks.math.columbia.edu/tag/002U.\n-/\nprotected instance sort.category_theory.limits.has_colimits : has_colimits (Type u) :=\n  has_colimits.mk\n    fun (J : Type u) (𝒥 : small_category J) =>\n      has_colimits_of_shape.mk\n        fun (F : J ⥤ Type u) => has_colimit.mk (colimit_cocone.mk (colimit_cocone F) (colimit_cocone_is_colimit F))\n\n/--\nThe equivalence between the abstract colimit of `F` in `Type u`\nand the \"concrete\" definition as a quotient.\n-/\ndef colimit_equiv_quot {J : Type u} [small_category J] (F : J ⥤ Type u) : colimit F ≃ quot F :=\n  iso.to_equiv (is_colimit.cocone_point_unique_up_to_iso (colimit.is_colimit F) (colimit_cocone_is_colimit F))\n\n@[simp] theorem colimit_equiv_quot_symm_apply {J : Type u} [small_category J] (F : J ⥤ Type u) (j : J) (x : functor.obj F j) : coe_fn (equiv.symm (colimit_equiv_quot F)) (Quot.mk (quot.rel F) (sigma.mk j x)) = colimit.ι F j x :=\n  rfl\n\n@[simp] theorem colimit_equiv_quot_apply {J : Type u} [small_category J] (F : J ⥤ Type u) (j : J) (x : functor.obj F j) : coe_fn (colimit_equiv_quot F) (colimit.ι F j x) = Quot.mk (quot.rel F) (sigma.mk j x) := sorry\n\n@[simp] theorem colimit.w_apply {J : Type u} [small_category J] {F : J ⥤ Type u} {j : J} {j' : J} {x : functor.obj F j} (f : j ⟶ j') : colimit.ι F j' (functor.map F f x) = colimit.ι F j x :=\n  congr_fun (colimit.w F f) x\n\n@[simp] theorem colimit.ι_desc_apply {J : Type u} [small_category J] (F : J ⥤ Type u) (s : cocone F) (j : J) (x : functor.obj F j) : colimit.desc F s (colimit.ι F j x) = nat_trans.app (cocone.ι s) j x :=\n  congr_fun (colimit.ι_desc s j) x\n\n@[simp] theorem colimit.ι_map_apply {J : Type u} [small_category J] {F : J ⥤ Type u} {G : J ⥤ Type u} (α : F ⟶ G) (j : J) (x : functor.obj F j) : functor.map colim α (colimit.ι F j x) = colimit.ι G j (nat_trans.app α j x) :=\n  congr_fun (colimit.ι_map α j) x\n\ntheorem colimit_sound {J : Type u} [small_category J] {F : J ⥤ Type u} {j : J} {j' : J} {x : functor.obj F j} {x' : functor.obj F j'} (f : j ⟶ j') (w : functor.map F f x = x') : colimit.ι F j x = colimit.ι F j' x' := sorry\n\ntheorem colimit_sound' {J : Type u} [small_category J] {F : J ⥤ Type u} {j : J} {j' : J} {x : functor.obj F j} {x' : functor.obj F j'} {j'' : J} (f : j ⟶ j'') (f' : j' ⟶ j'') (w : functor.map F f x = functor.map F f' x') : colimit.ι F j x = colimit.ι F j' x' := sorry\n\ntheorem colimit_eq {J : Type u} [small_category J] {F : J ⥤ Type u} {j : J} {j' : J} {x : functor.obj F j} {x' : functor.obj F j'} (w : colimit.ι F j x = colimit.ι F j' x') : eqv_gen (quot.rel F) (sigma.mk j x) (sigma.mk j' x') := sorry\n\ntheorem jointly_surjective {J : Type u} [small_category J] (F : J ⥤ Type u) {t : cocone F} (h : is_colimit t) (x : cocone.X t) : ∃ (j : J), ∃ (y : functor.obj F j), nat_trans.app (cocone.ι t) j y = x := sorry\n\n/-- A variant of `jointly_surjective` for `x : colimit F`. -/\ntheorem jointly_surjective' {J : Type u} [small_category J] {F : J ⥤ Type u} (x : colimit F) : ∃ (j : J), ∃ (y : functor.obj F j), colimit.ι F j y = x :=\n  jointly_surjective F (colimit.is_colimit F) x\n\nnamespace filtered_colimit\n\n\n/- For filtered colimits of types, we can give an explicit description\n  of the equivalence relation generated by the relation used to form\n  the colimit.  -/\n\n/--\nAn alternative relation on `Σ j, F.obj j`,\nwhich generates the same equivalence relation as we use to define the colimit in `Type` above,\nbut that is more convenient when working with filtered colimits.\n\nElements in `F.obj j` and `F.obj j'` are equivalent if there is some `k : J` to the right\nwhere their images are equal.\n-/\nprotected def r {J : Type u} [small_category J] (F : J ⥤ Type u) (x : sigma fun (j : J) => functor.obj F j) (y : sigma fun (j : J) => functor.obj F j) :=\n  ∃ (k : J),\n    ∃ (f : sigma.fst x ⟶ k), ∃ (g : sigma.fst y ⟶ k), functor.map F f (sigma.snd x) = functor.map F g (sigma.snd y)\n\nprotected theorem r_ge {J : Type u} [small_category J] (F : J ⥤ Type u) (x : sigma fun (j : J) => functor.obj F j) (y : sigma fun (j : J) => functor.obj F j) : (∃ (f : sigma.fst x ⟶ sigma.fst y), sigma.snd y = functor.map F f (sigma.snd x)) → filtered_colimit.r F x y := sorry\n\n/-- Recognizing filtered colimits of types. -/\ndef is_colimit_of {J : Type u} [small_category J] (F : J ⥤ Type u) (t : cocone F) (hsurj : ∀ (x : cocone.X t), ∃ (i : J), ∃ (xi : functor.obj F i), x = nat_trans.app (cocone.ι t) i xi) (hinj : ∀ (i j : J) (xi : functor.obj F i) (xj : functor.obj F j),\n  nat_trans.app (cocone.ι t) i xi = nat_trans.app (cocone.ι t) j xj →\n    ∃ (k : J), ∃ (f : i ⟶ k), ∃ (g : j ⟶ k), functor.map F f xi = functor.map F g xj) : is_colimit t :=\n  is_colimit.of_iso_colimit (colimit.is_colimit F)\n    (cocones.ext (equiv.to_iso (equiv.of_bijective (colimit.desc F t) sorry)) sorry)\n\n-- Strategy: Prove that the map from \"the\" colimit of F (defined above) to t.X\n\n-- is a bijection.\n\nprotected theorem r_equiv {J : Type u} [small_category J] (F : J ⥤ Type u) [is_filtered_or_empty J] : equivalence (filtered_colimit.r F) := sorry\n\nprotected theorem r_eq {J : Type u} [small_category J] (F : J ⥤ Type u) [is_filtered_or_empty J] : filtered_colimit.r F =\n  eqv_gen\n    fun (x y : sigma fun (j : J) => functor.obj F j) =>\n      ∃ (f : sigma.fst x ⟶ sigma.fst y), sigma.snd y = functor.map F f (sigma.snd x) := sorry\n\ntheorem colimit_eq_iff_aux {J : Type u} [small_category J] (F : J ⥤ Type u) [is_filtered_or_empty J] {i : J} {j : J} {xi : functor.obj F i} {xj : functor.obj F j} : nat_trans.app (cocone.ι (colimit_cocone F)) i xi = nat_trans.app (cocone.ι (colimit_cocone F)) j xj ↔\n  ∃ (k : J), ∃ (f : i ⟶ k), ∃ (g : j ⟶ k), functor.map F f xi = functor.map F g xj := sorry\n\ntheorem is_colimit_eq_iff {J : Type u} [small_category J] (F : J ⥤ Type u) {t : cocone F} [is_filtered_or_empty J] (ht : is_colimit t) {i : J} {j : J} {xi : functor.obj F i} {xj : functor.obj F j} : nat_trans.app (cocone.ι t) i xi = nat_trans.app (cocone.ι t) j xj ↔\n  ∃ (k : J), ∃ (f : i ⟶ k), ∃ (g : j ⟶ k), functor.map F f xi = functor.map F g xj := sorry\n\ntheorem colimit_eq_iff {J : Type u} [small_category J] (F : J ⥤ Type u) [is_filtered_or_empty J] {i : J} {j : J} {xi : functor.obj F i} {xj : functor.obj F j} : colimit.ι F i xi = colimit.ι F j xj ↔ ∃ (k : J), ∃ (f : i ⟶ k), ∃ (g : j ⟶ k), functor.map F f xi = functor.map F g xj :=\n  is_colimit_eq_iff F (colimit.is_colimit F)\n\nend filtered_colimit\n\n\n/-- the image of a morphism in Type is just `set.range f` -/\ndef image {α : Type u} {β : Type u} (f : α ⟶ β) :=\n  ↥(set.range f)\n\nprotected instance image.inhabited {α : Type u} {β : Type u} (f : α ⟶ β) [Inhabited α] : Inhabited (image f) :=\n  { default := { val := f Inhabited.default, property := sorry } }\n\n/-- the inclusion of `image f` into the target -/\ndef image.ι {α : Type u} {β : Type u} (f : α ⟶ β) : image f ⟶ β :=\n  subtype.val\n\nprotected instance image.ι.category_theory.mono {α : Type u} {β : Type u} (f : α ⟶ β) : mono (image.ι f) :=\n  iff.mpr (mono_iff_injective (image.ι f)) subtype.val_injective\n\n/-- the universal property for the image factorisation -/\ndef image.lift {α : Type u} {β : Type u} {f : α ⟶ β} (F' : mono_factorisation f) : image f ⟶ mono_factorisation.I F' :=\n  fun (x : image f) =>\n    mono_factorisation.e F'\n      (subtype.val (classical.indefinite_description (fun (x_1 : α) => f x_1 = subtype.val x) sorry))\n\ntheorem image.lift_fac {α : Type u} {β : Type u} {f : α ⟶ β} (F' : mono_factorisation f) : image.lift F' ≫ mono_factorisation.m F' = image.ι f := sorry\n\n/-- the factorisation of any morphism in Type through a mono. -/\ndef mono_factorisation {α : Type u} {β : Type u} (f : α ⟶ β) : mono_factorisation f :=\n  mono_factorisation.mk (image f) (image.ι f) (set.range_factorization f)\n\n/-- the facorisation through a mono has the universal property of the image. -/\ndef is_image {α : Type u} {β : Type u} (f : α ⟶ β) : is_image (mono_factorisation f) :=\n  is_image.mk image.lift\n\nprotected instance category_theory.limits.has_image {α : Type u} {β : Type u} (f : α ⟶ β) : has_image f :=\n  has_image.mk (image_factorisation.mk (mono_factorisation f) (is_image f))\n\nprotected instance sort.category_theory.limits.has_images : has_images (Type u) :=\n  has_images.mk sorry\n\nprotected instance sort.category_theory.limits.has_image_maps : has_image_maps (Type u) :=\n  has_image_maps.mk sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/limits/types.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4593013282149213}}
{"text": "-- Copyright © 2019 François G. Dorais. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n\nimport .basic\nimport .relation\n\n@[derive decidable_eq]\ninductive {u} index {α : Type u} : list α → Type u\n| head (x : α) (xs : list α) : index (x :: xs)\n| tail (x : α) (xs : list α) : index xs → index (x :: xs)\n\nnamespace index\nvariable {α : Type*}\n\n@[reducible]\ndefinition val : Π {xs : list α}, index xs → α\n| _ (index.head x _) := x\n| _ (index.tail _ _ i) := val i\n\n@[simp] theorem val_head (x : α) (xs : list α) : val (index.head x xs) = x := rfl\n\n@[simp] theorem val_tail (x : α) (xs : list α) (i : index xs) : val (index.tail x xs i) = val i := rfl\n\ndefinition nil_elim {C : Sort*} : Π (i : index (@list.nil α)), C .\n\n@[simp] theorem val_eq_rec : Π {xs ys : list α} (h : xs = ys) (i : index xs), val (eq.rec_on h i : index ys) = i.val\n| _ _ rfl _ := rfl\n\nsection map\nvariables {β : Type*} (f : α → β)\n\ndefinition map : Π {xs : list α}, index xs → index (xs.map f)\n| _ (index.head _ _) := index.head _ _\n| _ (index.tail _ _ i) := index.tail _ _ (map i)\n\n@[simp] theorem map_head (x : α) (xs : list α) : map f (index.head x xs) = index.head (f x) (xs.map f) := rfl\n\n@[simp] theorem map_tail (x : α) (xs : list α) (i : index xs) : map f (index.tail x xs i) = index.tail (f x) (xs.map f) (map f i) := rfl\n\n@[simp] theorem val_map : ∀ {xs : list α} (i : index xs), (i.map f).val = f i.val\n| _ (index.head _ _) := rfl\n| _ (index.tail _ _ i) := val_map i\n\ndefinition unmap : Π {xs : list α}, index (xs.map f) → index xs\n| (_::_) (index.head _ _) := index.head _ _\n| (_::_) (index.tail _ _ i) := index.tail _ _ (unmap i)\n\n@[simp] theorem map_unmap : ∀ {xs : list α} (i : index (xs.map f)), map f (unmap f i) = i\n| (_::_) (index.head _ _) := rfl\n| (_::_) (index.tail _ _ i) := congr_arg (index.tail _ _) (map_unmap i)\n\n@[simp] theorem unmap_map : ∀ {xs : list α} (i : index xs), unmap f (map f i) = i\n| _ (index.head _ _) := rfl\n| _ (index.tail _ _ i) := congr_arg (index.tail _ _) (unmap_map i)\n\nend map\n\nsection append\n\ndefinition append_left : Π (xs ys : list α), index xs → index (xs ++ ys)\n| (x::xs) ys (index.head _ _) := index.head x (xs ++ ys)\n| (x::xs) ys (index.tail _ _ i) := index.tail x (xs ++ ys) (append_left xs ys i)\n\n@[simp] theorem append_left_val : ∀ (xs ys : list α) (i : index xs), (append_left xs ys i).val = i.val\n| (x::xs) ys (index.head _ _) := rfl\n| (x::xs) ys (index.tail _ _ i) := append_left_val xs ys i\n\ndefinition append_right : Π (xs ys : list α), index ys → index (xs ++ ys)\n| [] ys i := i\n| (x::xs) ys i := index.tail x (xs ++ ys) (append_right xs ys i)\n\n@[simp] theorem append_right_val : ∀ (xs ys : list α) (i : index ys), (append_right xs ys i).val = i.val\n| [] ys _ := rfl\n| (x::xs) ys i := append_right_val xs ys i\n\nend append\n\nsection join\n\ndefinition join_map : Π (xss : list (list α)) (i : index xss), index i.val → index xss.join\n| (xs::xss) (index.head _ _) j := append_left xs xss.join j\n| (xs::xss) (index.tail _ _ i) j := append_right xs xss.join $ join_map xss i j\n\n@[simp] theorem join_map_val : ∀ (xss : list (list α)) (i : index xss) (j : index i.val), (join_map xss i j).val = j.val\n| (xs::xss) (index.head _ _) j := append_left_val xs xss.join j\n| (xs::xss) (index.tail _ _ i) j := eq.trans (append_right_val xs xss.join (join_map xss i j)) (join_map_val xss i j)\n\nend join\n\ndefinition iota : Π (xs : list α), list (index xs)\n| [] := []\n| (x :: xs) := (index.head x xs) :: list.map (index.tail x xs) (iota xs)\n\ndefinition iota_index : Π {xs : list α}, index xs → index (iota xs)\n| _ (index.head _ _) := index.head _ _\n| _ (index.tail _ _ i) := index.tail _ _ (map _ $ iota_index i)\n\n@[simp] theorem iota_index_val : Π {xs : list α} (i : index xs), (iota_index i).val = i\n| _ (index.head _ _) := rfl\n| _ (index.tail x xs i) := by rw [iota_index, val_tail, val_map, iota_index_val i]\n\ndefinition to_fin : Π {xs : list α}, index xs → fin xs.length\n| _ (index.head x xs) := eq.rec_on (eq.symm $ list.length_cons x xs) 0\n| _ (index.tail x xs i) := eq.rec_on (eq.symm $ list.length_cons x xs) (fin.succ $ to_fin i)\n\ndefinition of_fin : Π {xs : list α}, fin xs.length → index xs\n| [] ⟨i, hi⟩ := absurd hi (nat.not_lt_zero i)\n| (x :: xs) ⟨0, _⟩ := index.head x xs\n| (x :: xs) ⟨i+1, hi⟩ := index.tail x xs (of_fin ⟨i, nat.lt_of_succ_lt_succ hi⟩)\n\nabbreviation to_nat {xs : list α} (i : index xs) : nat := (to_fin i).val\n\ntheorem to_nat_lt_lenth {xs : list α} (i : index xs) : i.to_nat < xs.length := (to_fin i).is_lt\n\ndefinition of_nat {xs : list α} (i : nat) : option (index xs) :=\nif hi : i < xs.length then some (of_fin ⟨i, hi⟩) else none\n\nabbreviation of_nat_lt_length {xs : list α} (i : nat) : i < xs.length → index xs := λ hi, of_fin ⟨i, hi⟩\n\nabbreviation dtup {xs : list α} (β : index xs → Sort*) := Π i, β i\n\nnamespace dtup\n\nsection nil\nvariable {β : index (@list.nil α) → Sort*}\n\ndefinition nil : Π i, β i .\n\n@[simp] theorem eq_nil (t : Π i, β i) : t = nil := funext $ λ i, nil i\n\ntheorem eq_of_nil (t₁ t₂ : Π i, β i) : t₁ = t₂ := by rw [dtup.eq_nil t₁, dtup.eq_nil t₂]\n\nend nil\n\nsection cons\nvariables {x : α} {xs : list α} {β : index (x :: xs) → Sort*}\n\nabbreviation head : (Π i, β i) → β (index.head x xs) := λ t, t (index.head x xs) \n\nabbreviation tail : (Π i, β i) → (Π i, β (index.tail x xs i)) := λ t i, t (index.tail x xs i) \n\ndefinition cons : head β → (Π i, tail β i) → (Π i, β i)\n| h _ (index.head _ _) := h\n| _ t (index.tail _ _ i) := t i\n\n@[simp] theorem cons_head_tail (t : Π i, β i) : cons (head t) (tail t) = t :=\nfunext $ λ i, match i with\n| (index.head _ _) := rfl\n| (index.tail _ _ i) := rfl\nend\n\nvariables (h : head β) (t : Π i, tail β i)\n\n@[simp] theorem cons_of_index_head : cons h t (index.head x xs) = h := rfl\n\n@[simp] theorem cons_of_index_tail (i : index xs) : cons h t (index.tail x xs i) = t i := rfl\n\n@[simp] theorem head_cons : head (cons h t) = h := rfl\n\n@[simp] theorem tail_cons : tail (cons h t) = t := rfl\n\nend cons\n\nsection enum\nvariables {xs : list α} {β : index xs → Type*} (t : Π i, β i) \n\nabbreviation enum : list (sigma β) := list.map (λ i, ⟨i, t i⟩) (iota xs)\n\nabbreviation enum_index : index xs → index (enum t) := λ i, map _ (iota_index i)\n\n@[simp] theorem enum_index_val (i : index xs) : (enum_index t i).val = ⟨i, t i⟩ :=\nby rw [val_map, iota_index_val]\n\nend enum\n\nabbreviation to_list {xs : list α} {β : Type*} (t : index xs → β) : list β :=\nlist.map (λ (z : sigma (λ _, β)), sigma.snd z) (enum t)\n\nabbreviation to_list_index {xs : list α} {β : Type*} (t : index xs → β) : index xs → index (to_list t) :=\nλ i, index.map (λ (z : sigma (λ _, β)), sigma.snd z) (enum_index t i)\n\n@[simp] theorem to_list_index_val {xs : list α} {β : Type*} (t : index xs → β) (i : index xs) : (to_list_index t i).val = t i :=\nby rw [val_map, enum_index_val]\n\nsection fold\n\ndefinition foldl : Π {xs : list α} {β : index xs → Sort*} {γ : Sort*} (f : Π {{i}}, γ → β i → γ), γ → (Π i, β i) → γ\n| [] _ _ _ z _ := z\n| (_::_) _ _ f z t := f (foldl (tail f) z (tail t)) (head t)\n\ndefinition foldr : Π {xs : list α} {β : index xs → Sort*} {γ : Sort*} (f : Π {{i}}, β i → γ → γ), γ → (Π i, β i) → γ\n| [] _ _ _ z _ := z\n| (_::_) _ _ f z t := f (head t) (foldr (tail f) z (tail t))\n\n@[simp] theorem foldl_nil {β : index (@list.nil α) → Sort*} {γ : Sort*} (f : Π {{i}}, γ → β i → γ) (z : γ) :\nfoldl f z nil = z := rfl\n\n@[simp] theorem foldr_nil {β : index (@list.nil α) → Sort*} {γ : Sort*} (f : Π {{i}}, β i → γ → γ) (z : γ) :\nfoldr f z nil = z := rfl\n\nvariables {x : α} {xs : list α} {β : index (x :: xs) → Sort*} {γ : Sort*}\n\n@[simp] theorem foldl_cons (f : Π {{i}}, γ → β i → γ) (z : γ) (h : head β) (t : Π i, tail β i) :\nfoldl f z (cons h t) = f (foldl (tail f) z t) h := rfl\n\n@[simp] theorem foldr_cons (f : Π {{i}}, β i → γ → γ) (z : γ) (h : head β) (t : Π i, tail β i) :\nfoldr f z (cons h t) = f h (foldr (tail f) z t) := rfl\n\n@[simp] theorem foldl_head_tail (f : Π {{i}}, γ → β i → γ) (z : γ) (t : Π i, β i) :\nfoldl f z t = f (foldl (tail f) z (tail t)) (head t) := rfl\n\n@[simp] theorem foldr_head_tail (f : Π {{i}}, β i → γ → γ) (z : γ) (t : Π i, β i) :\nfoldr f z t = f (head t) (foldr (tail f) z (tail t)) := rfl\n\nend fold\n\nend dtup\n\ndefinition decidable_exists_def : Π {xs : list α} (p : index xs → Prop) (dp : ∀ i, decidable (p i)), decidable (∃ i, p i)\n| [] _ _ := decidable.is_false (λ ⟨i,_⟩, nil_elim i)\n| (_::_) p dp :=\n  match decidable_exists_def (dtup.tail p) (dtup.tail dp) with\n  | decidable.is_true ht := decidable.is_true (exists.elim ht $ λ i hi, ⟨_, hi⟩)\n  | decidable.is_false ht :=\n    match dtup.head dp with\n    | decidable.is_true hh := decidable.is_true ⟨_, hh⟩\n    | decidable.is_false hh :=\n      have ¬ ∃ i, p i, \n      begin\n      intro h,\n      cases h with i hi,\n      cases i,\n      exact hh hi,\n      exact ht ⟨_, hi⟩,\n      end,\n      decidable.is_false this\n    end\n  end\n\ninstance decidable_exists {xs : list α} (p : index xs → Prop) [dp : Π i, decidable (p i)] : decidable (∃ i, p i) := decidable_exists_def p dp\n\ndefinition decidable_forall_def : Π {xs : list α} (p : index xs → Prop) (dp : ∀ i, decidable (p i)), decidable (∀ i, p i)\n| [] _ _ := decidable.is_true (λ i, nil_elim i)\n| (_::_) p dp :=\n  match decidable_forall_def (dtup.tail p) (dtup.tail dp) with\n  | decidable.is_false ht := decidable.is_false (λ h, ht (dtup.tail h))\n  | decidable.is_true ht :=\n    match dtup.head dp with\n    | decidable.is_false hh := decidable.is_false (λ h, hh (dtup.head h))\n    | decidable.is_true hh := decidable.is_true (dtup.cons hh ht)\n    end\n  end\n\ninstance decidable_forall {xs : list α} (p : index xs → Prop) [dp : Π i, decidable (p i)] : decidable (∀ i, p i) := decidable_forall_def p dp\n\ntheorem choice : ∀ {xs : list α} {β : index xs → Sort*}, (∀ i, nonempty (β i)) → nonempty (Π i, β i)\n| [] _ _ := nonempty.intro dtup.nil\n| (_::_) C H := \n  have Hh : nonempty (dtup.head C), from dtup.head H,\n  have Ht : nonempty (Π i, dtup.tail C i), from choice (dtup.tail H),\n  nonempty.elim Hh $ λ h, nonempty.elim Ht $ λ t, nonempty.intro (dtup.cons h t)\n\nsection relation\nopen relation\n\ntheorem ec_of_ec_tail {x : α} {xs : list α} {β : index (x :: xs) → Sort*} {r : Π i, β i → β i → Prop} (hhr : reflexive (dtup.head r)) {h : dtup.head β} {t₁ t₂ : Π i, dtup.tail β i} :\nec (pi (dtup.tail r)) t₁ t₂ → ec (pi r) (dtup.cons h t₁) (dtup.cons h t₂) :=\nλ e, ec.rec_on e\n  (λ _ _ hxy, ec.base $ dtup.cons (hhr h) hxy) \n  (λ _, ec.refl _) \n  (λ _ _ _ _ _ hxy hxz, ec.eucl hxy hxz)\n\ntheorem ec_of_ec_head {x : α} {xs : list α} {β : index (x :: xs) → Sort*} {r : Π i, β i → β i → Prop} (htr : reflexive (pi (dtup.tail r))) {h₁ h₂ : dtup.head β} {t : Π i, dtup.tail β i} :\nec (dtup.head r) h₁ h₂ → ec (pi r) (dtup.cons h₁ t) (dtup.cons h₂ t) :=\nλ e, ec.rec_on e\n  (λ _ _ hxy, ec.base $ dtup.cons hxy (htr _)) \n  (λ _, ec.refl _) \n  (λ _ _ _ _ _ hxy hxz, ec.eucl hxy hxz)\n\ntheorem ec_of_ec_head_tail {x : α} {xs : list α} {β : index (x :: xs) → Sort*} {r : Π i, β i → β i → Prop} (hr : ∀ i, reflexive (r i)) {h₁ h₂ : dtup.head β} {t₁ t₂ : Π i, dtup.tail β i} :\nec (dtup.head r) h₁ h₂ → ec (pi (dtup.tail r)) t₁ t₂ → ec (pi r) (dtup.cons h₁ t₁) (dtup.cons h₂ t₂) :=\nλ eh et,\nhave hhr : reflexive (dtup.head r), from dtup.head hr,\nhave htr : reflexive (pi (dtup.tail r)), from pi_reflexive (dtup.tail hr),\nhave e₁ : ec (pi r) (dtup.cons h₁ t₁) (dtup.cons h₂ t₁), from ec_of_ec_head htr eh, \nhave e₂ : ec (pi r) (dtup.cons h₂ t₁) (dtup.cons h₂ t₂), from ec_of_ec_tail hhr et,\nec.trans e₁ e₂\n\ntheorem ec_pi_of_pi_ec : ∀ {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (hr : ∀ i, reflexive (r i)) {t₁ t₂ : Π i, β i}, pi (λ i, ec (r i)) t₁ t₂ → ec (pi r) t₁ t₂\n| [] _ _ _ t₁ t₂ _ := by { rw [dtup.eq_nil t₁, dtup.eq_nil t₂], apply ec.refl _ }\n| (_::_) _ r hr t₁ t₂ h :=\n  have eh : ec (dtup.head r) (dtup.head t₁) (dtup.head t₂), from dtup.head h,\n  have et : ec (pi (dtup.tail r)) (dtup.tail t₁) (dtup.tail t₂), from ec_pi_of_pi_ec (dtup.tail hr) (dtup.tail h),\n  by {rw [← dtup.cons_head_tail t₁, ← dtup.cons_head_tail t₂], exact ec_of_ec_head_tail hr eh et }\n\nvariables {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (hr : ∀ i, reflexive (r i))\n\ntheorem pi_ec_iff_ec_pi (t₁ t₂ : Π i, β i) : pi (λ i, ec (r i)) t₁ t₂ ↔ ec (pi r) t₁ t₂ :=\n⟨ec_pi_of_pi_ec hr, pi_ec_of_ec_pi⟩\n\ntheorem pi_ec_eq_ec_pi : pi (λ i, ec (r i)) = ec (pi r) :=\nfunext $ λ t₁, funext $ λ t₂, propext $ pi_ec_iff_ec_pi hr t₁ t₂\n\nend relation\n\nsection setoid\n\ninstance setoid {xs : list α} (β : index xs → Sort*) [Π i, setoid (β i)] : setoid (Π i, β i) :=\n{ r := λ x y, ∀ i, x i ≈ y i\n, iseqv := mk_equivalence _\n  (λ x i, setoid.refl (x i))\n  (λ _ _ h i, setoid.symm (h i))\n  (λ _ _ _ hxy hyz i, setoid.trans (hxy i) (hyz i))\n}\n\ntheorem setoid.r_iff {xs : list α} {C : index xs → Sort*} [Π i, setoid (C i)] (t₁ t₂ : Π i, C i) :\nt₁ ≈ t₂ ↔ (∀ i, t₁ i ≈ t₂ i) := iff.rfl\n\ntheorem setoid.r_cons_iff {x : α} {xs : list α} {C : index (x :: xs) → Sort*} [Π i, setoid (C i)] (t₁ t₂ : Π i, C i) :\nt₁ ≈ t₂ ↔ dtup.head t₁ ≈ dtup.head t₂ ∧ dtup.tail t₁ ≈ dtup.tail t₂ :=\n⟨ λ h, have h : ∀ i, t₁ i ≈ t₂ i, from (setoid.r_iff t₁ t₂).mp h, ⟨dtup.head h, dtup.tail h⟩\n, λ ⟨hh, ht⟩, have h : ∀ i, t₁ i ≈ t₂ i, from dtup.cons hh ht, (setoid.r_iff t₁ t₂).mpr h\n⟩\n\ntheorem setoid.r_cons {x : α} {xs : list α} {C : index (x :: xs) → Sort*} [Π i, setoid (C i)]\n(h₁ h₂ : dtup.head C) (t₁ t₂ : Π i, dtup.tail C i) : h₁ ≈ h₂ → t₁ ≈ t₂ → dtup.cons h₁ t₁ ≈ dtup.cons h₂ t₂ :=\nbegin\nintros eh et,\nrw setoid.r_cons_iff,\nsimp only [dtup.head_cons, dtup.tail_cons],\nsplit; assumption\nend\n\nend setoid\n\nend index\n\nnamespace quot\nopen index\nopen relation\nvariable {α : Type*}\n\nabbreviation index_mk {xs : list α} {β : index xs → Sort*} (r : Π i, β i → β i → Prop) (t : Π i, β i) : Π i, quot (r i) := λ i, quot.mk (r i) (t i)\n\n@[elab_as_eliminator]\ntheorem index_ind : ∀ {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (hr : ∀ i, reflexive (r i)) {P : (Π i, quot (r i)) → Prop},\n(∀ (t : Π i, β i), P (λ i, quot.mk (r i) (t i))) → ∀ q, P q\n| [] β r hr P H q := by { rw [dtup.eq_nil q, ← dtup.eq_nil (λ i, @quot.mk (β i) (r i) (dtup.nil i))], apply H }\n| (x::xs) β r hr P H q :=\n  have ∀ (h : dtup.head β) (t : Π i, dtup.tail β i), (λ i, quot.mk (r i) (dtup.cons h t i)) = dtup.cons (quot.mk (dtup.head r) h) (λ i, quot.mk (dtup.tail r i) (t i)), by { intros, funext i, cases i; reflexivity },\n  have IH : ∀ (h : dtup.head β) (q : Π i, quot (dtup.tail r i)), P (dtup.cons (quot.mk (dtup.head r) h) q),\n  from λ h q, index_ind (dtup.tail hr) (by {introv, rw ← this, apply H}) q,\n  begin\n  rw [← dtup.cons_head_tail q],\n  induction (dtup.head q) using quot.ind with h,\n  apply IH,\n  end\n\n@[elab_as_eliminator]\ntheorem index_induction_on {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (hr : ∀ i, reflexive (r i)) {P : (Π i, quot (r i)) → Prop} (q : Π i, quot (r i)) :\n(∀ (t : Π i, β i), P (λ i, quot.mk (r i) (t i))) → P q :=\nλ H, index_ind hr H q\n\ndef index_map {xs : list α} {β : index xs → Sort*} (r : Π i, β i → β i → Prop) :\nquot (pi r) → Π i, quot (r i) :=\nquot.lift (λ (t : Π i, β i) (i : index xs), quot.mk (r i) (t i)) $\nλ (t₁ t₂ : Π i, β i) (h : pi r t₁ t₂), funext $ λ i, quot.sound (h i)\n\ndef index_map_beta {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (t : Π i, β i) :\nindex_map r (quot.mk (pi r) t) = λ i, quot.mk (r i) (t i) := rfl\n\nsection index_cons\nvariables {x : α} {xs : list α} {β : index (x :: xs) → Sort*} {r : Π i, β i → β i → Prop}\n\ndef index_cons_func (hr : reflexive (dtup.head r)) : dtup.head β → quot (pi (dtup.tail r)) → quot (pi r) :=\nλ h, quot.lift (λ t, quot.mk (pi r) (dtup.cons h t)) $\nλ t₁ t₂ ht, quot.sound (dtup.cons (hr h) ht)\n\ntheorem index_cons_func_beta {hr : reflexive (dtup.head r)} (h : dtup.head β) (t : Π i, dtup.tail β i) :\nindex_cons_func hr h (quot.mk (pi (dtup.tail r)) t) = quot.mk (pi r) (dtup.cons h t) := rfl\n\ndef index_cons (hr : ∀ i, reflexive (r i)) : quot (dtup.head r) → quot (pi (dtup.tail r)) → quot (pi r) :=\nquot.lift (index_cons_func (dtup.head hr)) $\nbegin\nintros h₁ h₂ hh,\nfunext t,\ninduction t using quot.ind,\nrw index_cons_func_beta,\nrw index_cons_func_beta,\napply quot.sound,\napply dtup.cons,\nexact hh,\nexact pi_reflexive (dtup.tail hr) t,\nend\n\ntheorem index_cons_beta {hr : ∀ i, reflexive (r i)} (h : dtup.head β) (t : Π i, dtup.tail β i) :\nindex_cons hr (quot.mk (dtup.head r) h) (quot.mk (pi (dtup.tail r)) t) = quot.mk (pi r) (dtup.cons h t) := rfl\n\nend index_cons\n\ndef index_inv : Π {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (hr : Π i, reflexive (r i)), \n(Π i, quot (r i)) → quot (pi r)\n| [] _ r _ _ := quot.mk (pi r) dtup.nil\n| (_::_) _ _ hr q := index_cons hr (dtup.head q) (index_inv (dtup.tail hr) (dtup.tail q))\n\ntheorem index_inv_nil {β : index (@list.nil α) → Sort*} {r : Π i, β i → β i → Prop} {hr : Π i, reflexive (r i)} :\nindex_inv hr dtup.nil = quot.mk (pi r) dtup.nil := rfl\n\ntheorem index_inv_cons {x : α} {xs : list α} {β : index (x :: xs) → Sort*} {r : Π i, β i → β i → Prop} {hr : Π i, reflexive (r i)} (h : quot (dtup.head r)) (t : Π i, quot (dtup.tail r i)) :\nindex_inv hr (dtup.cons h t) = index_cons hr h (index_inv (dtup.tail hr) t) := rfl\n\ntheorem index_inv_head_tail {x : α} {xs : list α} {β : index (x :: xs) → Sort*} {r : Π i, β i → β i → Prop} {hr : Π i, reflexive (r i)} (q : Π i, quot (r i)) :\nindex_inv hr q = index_cons hr (dtup.head q) (index_inv (dtup.tail hr) (dtup.tail q)) := rfl\n\ntheorem index_inv_beta : Π {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} {hr : Π i, reflexive (r i)} (t : Π i, β i), \nindex_inv hr (λ i, quot.mk (r i) (t i)) = quot.mk (pi r) t\n| [] _ _ _ t := by { rw [dtup.eq_nil t], reflexivity }\n| (x::xs) β r hr t := by { rw [index_inv_head_tail, index_inv_beta, index_cons_beta], simp }\n\ntheorem index_inv_map {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} {hr : ∀ i, reflexive (r i)} :\n∀ (q : quot (pi r)), index_inv hr (index_map r q) = q := quot.ind (by intro; rw [index_map_beta, index_inv_beta])\n\ntheorem index_map_inv {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} {hr : ∀ i, reflexive (r i)} :\n∀ (q : Π i, quot (r i)), index_map r (index_inv hr q) = q := quot.index_ind hr (by intro; rw [index_inv_beta, index_map_beta])\n\n@[elab_as_eliminator, reducible]\ndef index_lift {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (hr : Π i, reflexive (r i)) {γ : Sort*} (f : (Π i, β i) → γ) :\n(∀ t₁ t₂, pi r t₁ t₂ → f t₁ = f t₂) → (Π i, quot (r i)) → γ := λ H q, quot.lift f H (index_inv hr q)\n\n@[elab_as_eliminator, reducible]\nabbreviation index_lift_on {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} (hr : Π i, reflexive (r i)) (q : Π i, quot (r i)) {γ : Sort*} (f : (Π i, β i) → γ) :\n(∀ t₁ t₂, pi r t₁ t₂ → f t₁ = f t₂) → γ := λ H, index_lift hr f H q\n\ntheorem index_lift_def {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} {hr : Π i, reflexive (r i)} {γ : Sort*} (f : (Π i, β i) → γ) {H : ∀ t₁ t₂, pi r t₁ t₂ → f t₁ = f t₂} (q : Π i, quot (r i)) :\nindex_lift hr f H q = quot.lift f H (index_inv hr q) := rfl\n\ntheorem index_lift_map {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} {hr : Π i, reflexive (r i)} {γ : Sort*} (f : (Π i, β i) → γ) {H : ∀ t₁ t₂, pi r t₁ t₂ → f t₁ = f t₂} (q : quot (pi r)) :\nindex_lift hr f H (index_map r q) = quot.lift f H q := by rw [← index_inv_map q] {occs:=occurrences.pos[2]}\n\ntheorem index_lift_beta {xs : list α} {β : index xs → Sort*} {r : Π i, β i → β i → Prop} {hr : Π i, reflexive (r i)} {γ : Sort*} (f : (Π i, β i) → γ) {H : ∀ t₁ t₂, pi r t₁ t₂ → f t₁ = f t₂} (t : Π i, β i) :\nindex_lift hr f H (λ i, quot.mk (r i) (t i)) = f t := by rw [← index_map_beta, index_lift_map]\n\nend quot\n\nnamespace quotient\nopen index\nvariables {α : Type*} {xs : list α} {β : index xs → Sort*} [s : Π i, setoid (β i)]\ninclude s\n\ndefinition index_lift {γ : Sort*} (f : (Π i, β i) → γ) :\n(∀ (t₁ t₂ : Π i, β i), (∀ i, t₁ i ≈ t₂ i) → f t₁ = f t₂) → (Π i, quotient (s i)) → γ :=\nhave hr : ∀ i, reflexive (setoid.r : β i → β i → Prop), from λ i, (s i).iseqv.refl,\nquot.index_lift hr f\n\ntheorem index_lift_beta {γ : Sort*} (f : (Π i, β i) → γ) {H : ∀ (t₁ t₂ : Π i, β i), (∀ i, t₁ i ≈ t₂ i) → f t₁ = f t₂} :\n∀ (t : Π i, β i), index_lift f H (λ i, ⟦t i⟧) = f t := \nhave hr : ∀ i, reflexive (setoid.r : β i → β i → Prop), from λ i, (s i).iseqv.refl,\nbegin\nintro,\ndunfold index_lift,\napply quot.index_lift_beta,\nend\n\ntheorem index_ind {P : (Π i, quotient (s i)) → Prop} :\n(∀ (t : Π i, β i), P (λ i, ⟦t i⟧)) → ∀ q, P q := \nhave hr : ∀ i, reflexive (setoid.r : β i → β i → Prop), from λ i, (s i).iseqv.refl,\nλ H, quot.index_ind hr H\n\ntheorem index_induction_on {P : (Π i, quotient (s i)) → Prop} (q : Π i, quotient (s i)) :\n(∀ (t : Π i, β i), P (λ i, ⟦t i⟧)) → P q := λ H, index_ind H q\n\nend quotient\n\nnamespace list\nvariable {α : Type*}\n\ntheorem mem_join (x : α) : Π {xss : list (list α)} (i : index xss), x ∈ i.val → x ∈ xss.join\n| _ (index.head xs xss) hi := show x ∈ xs ++ xss.join, by { rw mem_append, left, exact hi }\n| _ (index.tail xs xss i) hi := show x ∈ xs ++ xss.join, by { rw mem_append, right, exact mem_join i hi }\n\nend list\n", "meta": {"author": "fgdorais", "repo": "lean-universal", "sha": "9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1", "save_path": "github-repos/lean/fgdorais-lean-universal", "path": "github-repos/lean/fgdorais-lean-universal/lean-universal-9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1/src/util/index.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529715, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.45930131773486493}}
{"text": "import .form\n\nvariables {α : Type} \n\nnamespace form\n\n\ndef skolem_term (k ms) : term := \nlist.foldl (λ t1 m, t1 ^* # m) (& k) ms\n\ndef snf_core : nat → form → (nat × form)\n| k ⊤*        := (k, ⊤*) \n| k ⊥*        := (k, ⊥*) \n| k (m ** ts) := (k, m ** ts)\n| k (¬* p)    := (k, ¬* p)\n| k (p ∧* q)  := \n  let (m, p') := snf_core k p in \n  let (n, q') := snf_core m q in \n  (n, p' ∧* q')\n| k (p ∨* q)  := \n  let (m, p') := snf_core k p in \n  let (n, q') := snf_core m q in \n  (n, p' ∨* q')\n| k (∀* p)    := \n  let (m, p') := snf_core k p in (m, ∀* p')\n| k (∃* p)    := \n  let (m, p') := snf_core k p in \n  let xs := fv p' in\n  (m+1, subst 0 (skolem_term m (fv p')) p')\n\ndef snf (p) := (snf_core (fresh_func_idx p) p).snd\n\n#exit\n\nlemma snf_equisat : ∀ p, (sat α (snf p) ↔ sat α p) := sorry\n\n\nend form", "meta": {"author": "skbaek", "repo": "clausify", "sha": "d09b071bdcce7577c3fffacd0893b776285b1590", "save_path": "github-repos/lean/skbaek-clausify", "path": "github-repos/lean/skbaek-clausify/clausify-d09b071bdcce7577c3fffacd0893b776285b1590/snf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424528443251, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4592310973260725}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Patrick Massot\n\n! This file was ported from Lean 3 source module topology.algebra.order.proj_Icc\n! leanprover-community/mathlib commit 50832daea47b195a48b5b33b1c8b2162c48c3afc\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Intervals.ProjIcc\nimport Mathbin.Topology.Order.Basic\n\n/-!\n# Projection onto a closed interval\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nIn this file we prove that the projection `set.proj_Icc f a b h` is a quotient map, and use it\nto show that `Icc_extend h f` is continuous if and only if `f` is continuous.\n-/\n\n\nopen Set Filter\n\nopen Filter Topology\n\nvariable {α β γ : Type _} [LinearOrder α] [TopologicalSpace γ] {a b c : α} {h : a ≤ b}\n\n/- warning: filter.tendsto.Icc_extend -> Filter.Tendsto.IccExtend' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u3} γ] {a : α} {b : α} {h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b} (f : γ -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) {z : γ} {l : Filter.{u1} α} {l' : Filter.{u2} β}, (Filter.Tendsto.{max u3 u1, u2} (Prod.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) β (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (γ -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (Prod.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) β (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} γ ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β (Function.hasUncurryBase.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β)) f) (Filter.prod.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) (nhds.{u3} γ _inst_2 z) (Filter.map.{u1, u1} α (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) (Set.projIcc.{u1} α _inst_1 a b h) l)) l') -> (Filter.Tendsto.{max u3 u1, u2} (Prod.{u3, u1} γ α) β (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (γ -> α -> β) (Prod.{u3, u1} γ α) β (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} γ (α -> β) α β (Function.hasUncurryBase.{u1, u2} α β)) (Function.comp.{succ u3, max (succ u1) (succ u2), max (succ u1) (succ u2)} γ ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (α -> β) (Set.IccExtend.{u1, u2} α β _inst_1 a b h) f)) (Filter.prod.{u3, u1} γ α (nhds.{u3} γ _inst_2 z) l) l')\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : LinearOrder.{u3} α] [_inst_2 : TopologicalSpace.{u1} γ] {a : α} {b : α} {h : LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1)))))) a b} (f : γ -> (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) {z : γ} {l : Filter.{u3} α} {l' : Filter.{u2} β}, (Filter.Tendsto.{max u3 u1, u2} (Prod.{u1, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b))) β (Function.HasUncurry.uncurry.{max (max u3 u2) u1, max u3 u1, u2} (γ -> (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) (Prod.{u1, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b))) β (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} γ ((Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) β (Function.hasUncurryBase.{u3, u2} (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) β)) f) (Filter.prod.{u1, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) (nhds.{u1} γ _inst_2 z) (Filter.map.{u3, u3} α (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) (Set.projIcc.{u3} α _inst_1 a b h) l)) l') -> (Filter.Tendsto.{max u3 u1, u2} (Prod.{u1, u3} γ α) β (Function.HasUncurry.uncurry.{max (max u3 u2) u1, max u3 u1, u2} (γ -> α -> β) (Prod.{u1, u3} γ α) β (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} γ (α -> β) α β (Function.hasUncurryBase.{u3, u2} α β)) (Function.comp.{succ u1, max (succ u2) (succ u3), max (succ u2) (succ u3)} γ ((Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) (α -> β) (Set.IccExtend.{u3, u2} α β _inst_1 a b h) f)) (Filter.prod.{u1, u3} γ α (nhds.{u1} γ _inst_2 z) l) l')\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.Icc_extend Filter.Tendsto.IccExtend'ₓ'. -/\ntheorem Filter.Tendsto.IccExtend' (f : γ → Icc a b → β) {z : γ} {l : Filter α} {l' : Filter β}\n    (hf : Tendsto (↿f) (𝓝 z ×ᶠ l.map (projIcc a b h)) l') :\n    Tendsto (↿(IccExtend h ∘ f)) (𝓝 z ×ᶠ l) l' :=\n  show Tendsto (↿f ∘ Prod.map id (projIcc a b h)) (𝓝 z ×ᶠ l) l' from\n    hf.comp <| tendsto_id.Prod_map tendsto_map\n#align filter.tendsto.Icc_extend Filter.Tendsto.IccExtend'\n\nvariable [TopologicalSpace α] [OrderTopology α] [TopologicalSpace β]\n\n#print continuous_projIcc /-\n@[continuity]\ntheorem continuous_projIcc : Continuous (projIcc a b h) :=\n  (continuous_const.max <| continuous_const.min continuous_id).subtype_mk _\n#align continuous_proj_Icc continuous_projIcc\n-/\n\n#print quotientMap_projIcc /-\ntheorem quotientMap_projIcc : QuotientMap (projIcc a b h) :=\n  quotientMap_iff.2\n    ⟨projIcc_surjective h, fun s =>\n      ⟨fun hs => hs.Preimage continuous_projIcc, fun hs =>\n        ⟨_, hs, by\n          ext\n          simp⟩⟩⟩\n#align quotient_map_proj_Icc quotientMap_projIcc\n-/\n\n/- warning: continuous_Icc_extend_iff -> continuous_IccExtend_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} {h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} α] [_inst_4 : OrderTopology.{u1} α _inst_3 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_5 : TopologicalSpace.{u2} β] {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β}, Iff (Continuous.{u1, u2} α β _inst_3 _inst_5 (Set.IccExtend.{u1, u2} α β _inst_1 a b h f)) (Continuous.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) _inst_3) _inst_5 f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} {h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u2} α] [_inst_4 : OrderTopology.{u2} α _inst_3 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} β] {f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β}, Iff (Continuous.{u2, u1} α β _inst_3 _inst_5 (Set.IccExtend.{u2, u1} α β _inst_1 a b h f)) (Continuous.{u2, u1} (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) β (instTopologicalSpaceSubtype.{u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) _inst_3) _inst_5 f)\nCase conversion may be inaccurate. Consider using '#align continuous_Icc_extend_iff continuous_IccExtend_iffₓ'. -/\n@[simp]\ntheorem continuous_IccExtend_iff {f : Icc a b → β} : Continuous (IccExtend h f) ↔ Continuous f :=\n  quotientMap_projIcc.continuous_iff.symm\n#align continuous_Icc_extend_iff continuous_IccExtend_iff\n\n/- warning: continuous.Icc_extend -> Continuous.IccExtend is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u3} γ] {a : α} {b : α} {h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} α] [_inst_4 : OrderTopology.{u1} α _inst_3 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_5 : TopologicalSpace.{u2} β] {f : γ -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β} {g : γ -> α}, (Continuous.{max u3 u1, u2} (Prod.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) β (Prod.topologicalSpace.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) _inst_2 (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (γ -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (Prod.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) β (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} γ ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β (Function.hasUncurryBase.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β)) f)) -> (Continuous.{u3, u1} γ α _inst_2 _inst_3 g) -> (Continuous.{u3, u2} γ β _inst_2 _inst_5 (fun (a_1 : γ) => Set.IccExtend.{u1, u2} α β _inst_1 a b h (f a_1) (g a_1)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_1 : LinearOrder.{u3} α] [_inst_2 : TopologicalSpace.{u2} γ] {a : α} {b : α} {h : LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u3} α] [_inst_4 : OrderTopology.{u3} α _inst_3 (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} β] {f : γ -> (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β} {g : γ -> α}, (Continuous.{max u3 u2, u1} (Prod.{u2, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b))) β (instTopologicalSpaceProd.{u2, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) _inst_2 (instTopologicalSpaceSubtype.{u3} α (fun (x : α) => Membership.mem.{u3, u3} α (Set.{u3} α) (Set.instMembershipSet.{u3} α) x (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (γ -> (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) (Prod.{u2, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b))) β (Function.hasUncurryInduction.{u2, max u3 u1, u3, u1} γ ((Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) β (Function.hasUncurryBase.{u3, u1} (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) β)) f)) -> (Continuous.{u2, u3} γ α _inst_2 _inst_3 g) -> (Continuous.{u2, u1} γ β _inst_2 _inst_5 (fun (a_1 : γ) => Set.IccExtend.{u3, u1} α β _inst_1 a b h (f a_1) (g a_1)))\nCase conversion may be inaccurate. Consider using '#align continuous.Icc_extend Continuous.IccExtendₓ'. -/\n/-- See Note [continuity lemma statement]. -/\ntheorem Continuous.IccExtend {f : γ → Icc a b → β} {g : γ → α} (hf : Continuous ↿f)\n    (hg : Continuous g) : Continuous fun a => IccExtend h (f a) (g a) :=\n  hf.comp <| continuous_id.prod_mk <| continuous_projIcc.comp hg\n#align continuous.Icc_extend Continuous.IccExtend\n\n/- warning: continuous.Icc_extend' -> Continuous.Icc_extend' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrder.{u1} α] {a : α} {b : α} {h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} α] [_inst_4 : OrderTopology.{u1} α _inst_3 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_5 : TopologicalSpace.{u2} β] {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β}, (Continuous.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) _inst_3) _inst_5 f) -> (Continuous.{u1, u2} α β _inst_3 _inst_5 (Set.IccExtend.{u1, u2} α β _inst_1 a b h f))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrder.{u2} α] {a : α} {b : α} {h : LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u2} α] [_inst_4 : OrderTopology.{u2} α _inst_3 (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} β] {f : (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) -> β}, (Continuous.{u2, u1} (Set.Elem.{u2} α (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) β (instTopologicalSpaceSubtype.{u2} α (fun (x : α) => Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x (Set.Icc.{u2} α (PartialOrder.toPreorder.{u2} α (SemilatticeInf.toPartialOrder.{u2} α (Lattice.toSemilatticeInf.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α _inst_1))))) a b)) _inst_3) _inst_5 f) -> (Continuous.{u2, u1} α β _inst_3 _inst_5 (Set.IccExtend.{u2, u1} α β _inst_1 a b h f))\nCase conversion may be inaccurate. Consider using '#align continuous.Icc_extend' Continuous.Icc_extend'ₓ'. -/\n/-- A useful special case of `continuous.Icc_extend`. -/\n@[continuity]\ntheorem Continuous.Icc_extend' {f : Icc a b → β} (hf : Continuous f) : Continuous (IccExtend h f) :=\n  hf.comp continuous_projIcc\n#align continuous.Icc_extend' Continuous.Icc_extend'\n\n/- warning: continuous_at.Icc_extend -> ContinuousAt.IccExtend is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : LinearOrder.{u1} α] [_inst_2 : TopologicalSpace.{u3} γ] {a : α} {b : α} {h : LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} α] [_inst_4 : OrderTopology.{u1} α _inst_3 (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1))))] [_inst_5 : TopologicalSpace.{u2} β] {x : γ} (f : γ -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) {g : γ -> α}, (ContinuousAt.{max u3 u1, u2} (Prod.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) β (Prod.topologicalSpace.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) _inst_2 (Subtype.topologicalSpace.{u1} α (fun (x : α) => Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (γ -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (Prod.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b))) β (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} γ ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) -> β) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β (Function.hasUncurryBase.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) β)) f) (Prod.mk.{u3, u1} γ (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.Icc.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_1)))) a b)) x (Set.projIcc.{u1} α _inst_1 a b h (g x)))) -> (ContinuousAt.{u3, u1} γ α _inst_2 _inst_3 g x) -> (ContinuousAt.{u3, u2} γ β _inst_2 _inst_5 (fun (a_1 : γ) => Set.IccExtend.{u1, u2} α β _inst_1 a b h (f a_1) (g a_1)) x)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_1 : LinearOrder.{u3} α] [_inst_2 : TopologicalSpace.{u2} γ] {a : α} {b : α} {h : LE.le.{u3} α (Preorder.toLE.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u3} α] [_inst_4 : OrderTopology.{u3} α _inst_3 (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} β] {x : γ} (f : γ -> (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) {g : γ -> α}, (ContinuousAt.{max u3 u2, u1} (Prod.{u2, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b))) β (instTopologicalSpaceProd.{u2, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) _inst_2 (instTopologicalSpaceSubtype.{u3} α (fun (x : α) => Membership.mem.{u3, u3} α (Set.{u3} α) (Set.instMembershipSet.{u3} α) x (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (γ -> (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) (Prod.{u2, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b))) β (Function.hasUncurryInduction.{u2, max u3 u1, u3, u1} γ ((Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) -> β) (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) β (Function.hasUncurryBase.{u3, u1} (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) β)) f) (Prod.mk.{u2, u3} γ (Set.Elem.{u3} α (Set.Icc.{u3} α (PartialOrder.toPreorder.{u3} α (SemilatticeInf.toPartialOrder.{u3} α (Lattice.toSemilatticeInf.{u3} α (DistribLattice.toLattice.{u3} α (instDistribLattice.{u3} α _inst_1))))) a b)) x (Set.projIcc.{u3} α _inst_1 a b h (g x)))) -> (ContinuousAt.{u2, u3} γ α _inst_2 _inst_3 g x) -> (ContinuousAt.{u2, u1} γ β _inst_2 _inst_5 (fun (a_1 : γ) => Set.IccExtend.{u3, u1} α β _inst_1 a b h (f a_1) (g a_1)) x)\nCase conversion may be inaccurate. Consider using '#align continuous_at.Icc_extend ContinuousAt.IccExtendₓ'. -/\ntheorem ContinuousAt.IccExtend {x : γ} (f : γ → Icc a b → β) {g : γ → α}\n    (hf : ContinuousAt (↿f) (x, projIcc a b h (g x))) (hg : ContinuousAt g x) :\n    ContinuousAt (fun a => IccExtend h (f a) (g a)) x :=\n  show ContinuousAt (↿f ∘ fun x => (x, projIcc a b h (g x))) x from\n    ContinuousAt.comp hf <| continuousAt_id.Prod <| continuous_projIcc.ContinuousAt.comp hg\n#align continuous_at.Icc_extend ContinuousAt.IccExtend\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/Algebra/Order/ProjIcc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478255, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4590916336368799}}
{"text": "import Playground.Category.Instances.Set\nimport Playground.Category.Instances.Product\nimport Playground.Category.Functor.Category\n\nnamespace Category.Functor\n\nsection\n  open Natural_Transformation\n\n  section\n    abbrev Bi (C D E) [Category C] [Category D] [Category E] := (C × D) ⥤ E\n  end\n  \n  namespace Bi\n  section\n\n    def swap {C D E} [Category C] [Category D] [Category E]\n      (F : Bi C D E) : Bi D C E where\n      obj_map := λ ⟨Y, X⟩ => F ⟨X, Y⟩\n      hom_map := λ ⟨g, f⟩ => F.hom_map ⟨f, g⟩\n      hom_map_comp := λ ⟨g₁, f₁⟩ ⟨g₂, f₂⟩ => by\n        show F.hom_map (_, _ ≫ _) = F.hom_map _ ≫ F.hom_map _ \n        rw [←hom_map_comp]\n        show F.hom_map (_, _ ≫ _) = F.hom_map ((_ ≫ _), (_ ≫ _))\n        simp\n      hom_map_id := λ Y => by\n        show F.hom_map (𝟙 _) = 𝟙 _ \n        simp\n\n    def fixLeft {C D E} [Category C] [Category D] [Category E]\n      (F : Bi C D E) (X : C) : D ⥤ E where\n      obj_map := λ Y => F ⟨X, Y⟩\n      hom_map := @λ Y₁ Y₂ g => \n        show F ⟨X, Y₁⟩ ⟶ F ⟨X, Y₂⟩ from\n        F.hom_map ⟨𝟙 _, g⟩\n      hom_map_comp := λ {Y₁ Y₂ Y₃} g₁ g₂ => by\n        show F.hom_map (_, _ ≫ _) = F.hom_map _ ≫ F.hom_map _ \n        rw [←hom_map_comp]\n        show F.hom_map (_, _ ≫ _) = F.hom_map ((_ ≫ _), (_ ≫ _))\n        simp\n      hom_map_id := λ Y => by\n        show F.hom_map (𝟙 _) = 𝟙 _ \n        simp\n\n    def fixRight {C D E} [Category C] [Category D] [Category E]\n      (F : Bi C D E) (Y : D) : C ⥤ E := F.swap.fixLeft Y\n\n    def curry {C D E} [Category C] [Category D] [Category E]\n      (F : Bi C D E) : C ⥤ D ⥤ E where\n      obj_map := F.fixLeft\n      hom_map {X₁ X₂} f := {\n        component := λ Y => F.hom_map (f, 𝟙 Y)\n        naturality := λ {Y₁ Y₂} g => by\n          show F.hom_map _ ≫ F.hom_map _ = F.hom_map _ ≫ F.hom_map _\n          rw [←hom_map_comp, ←hom_map_comp]\n          apply congrArg F.hom_map\n          show (_ ≫ _, _ ≫ _) = (_ ≫ _, _ ≫ _)\n          simp\n      }\n      hom_map_comp {X₁ X₂ X₃} f₁ f₂ := by\n        apply eq_of_component_eq\n        funext Y\n        show F.hom_map _ = F.hom_map _ ≫ F.hom_map _\n        rw [←hom_map_comp]\n        apply congrArg F.hom_map\n        show _ = (_ ≫ _, _ ≫ _)\n        simp\n      hom_map_id X := by\n        apply eq_of_component_eq\n        funext Y\n        show F.hom_map (𝟙 _) = 𝟙 _ \n        simp\n  end\n  end Bi\n\n  section\n    def asLHSofBi {C D E} [Category C] [Category D] [Category E]\n      (F : C ⥤ E) : Bi C D E where\n      obj_map := λ ⟨X, _⟩ => F X\n      hom_map := λ ⟨f, _⟩ => F.hom_map f\n      hom_map_comp _ _ := by simp\n      hom_map_id _ := by simp\n\n    def asRHSofBi {C D E} [Category C] [Category D] [Category E]\n      (F : D ⥤ E) : Bi C D E where\n      obj_map := λ ⟨_, Y⟩ => F Y\n      hom_map := λ ⟨_, f⟩ => F.hom_map f\n      hom_map_comp _ _ := by simp\n      hom_map_id _ := by simp\n\n    def pack {C D₁ D₂} [Category C] [Category D₁] [Category D₂] \n      (F₁ : C ⥤ D₁) (F₂ : C ⥤ D₂) : C ⥤ D₁ × D₂ where\n      obj_map X := ⟨F₁ X, F₂ X⟩\n      hom_map f := ⟨F₁.hom_map f, F₂.hom_map f⟩\n      hom_map_comp f g := by simp; rfl\n      hom_map_id X := by simp; rfl\n\n    def prod {C D E₁ E₂} [Category C] [Category D] [Category E₁] [Category E₂]\n      (F₁ : C ⥤ E₁) (F₂ : D ⥤ E₂) : Bi C D (E₁ × E₂) :=\n      F₁.asLHSofBi.pack F₂.asRHSofBi\n  end\n\n  section\n    def fixLeft {C D E} [Category C] [Category D] [Category E]\n      (F : C ⥤ D ⥤ E) (X : C) : D ⥤ E := F X\n\n    def fixRight {C D E} [Category C] [Category D] [Category E]\n      (F : C ⥤ D ⥤ E) (Y : D) : C ⥤ E where\n      obj_map := λ X => F X Y\n      hom_map := λ {X₁ X₂} f => (F.hom_map f).component Y\n      hom_map_comp := by simp\n      hom_map_id X := by simp; rfl\n\n    def uncurry {C D E} [Category C] [Category D] [Category E]\n      (F : C ⥤ D ⥤ E) : Bi C D E where\n      obj_map := λ ⟨X, Y⟩ => F X Y\n      hom_map := @λ ⟨X₁, Y₁⟩ ⟨X₂, Y₂⟩ ⟨f, g⟩ => \n        show F X₁ Y₁ ⟶ F X₂ Y₂ from\n        (F X₁).hom_map g ≫ (F.fixRight Y₂).hom_map f\n      hom_map_comp := @λ ⟨X₁, Y₁⟩ ⟨X₂, Y₂⟩ ⟨X₃, Y₃⟩ ⟨f₁, g₁⟩ ⟨f₂, g₂⟩ => by\n        simp [fixRight]\n        rw [assoc ((F X₁).hom_map g₁), ←assoc ((F X₁).hom_map g₂)]\n        rw [naturality, assoc, assoc]\n      hom_map_id _ := by simp; rfl\n\n    def swap {C D E} [Category C] [Category D] [Category E]\n      (F : C ⥤ D ⥤ E) : D ⥤ C ⥤ E := F.uncurry.swap.curry\n  end\n\n  section\n    namespace Bi\n    -- define the evaluation bifunctor : X, F ↦ F X\n    def evaluation (C D) [Category C] [Category D] : Bi C (C ⥤ D) D :=\n      (𝟭 (C ⥤ D)).uncurry.swap\n\n    --\n    -- def ofLeftAndRightFunctors {C D E} [Category C] [Category D] [Category E]\n    --   (F : C ⥤ E)\n    --   : Bi C D E := sorry\n\n    end Bi\n  end\n\n  section\n    def isom_images_of_isom_functors {C D} [Category C] [Category D] {F G : C ⥤ D} (α : F ≅ G) (X : C) \n      : F X ≅ G X :=\n      ((Bi.evaluation C D).fixLeft X).isom_images_of_isom_objects α\n\n    -- example {C D} [Category C] [Category D] {F G : C ⥤ D} (h : ∀ X, F X ≅ G X) : F ≅ G :=\n    --   sorry\n\n  end\nend\n\nend Category.Functor\n", "meta": {"author": "michelsol", "repo": "lean-playground", "sha": "0bfffb7bd41729fb9f95974e93f6ecbc0b6e59ca", "save_path": "github-repos/lean/michelsol-lean-playground", "path": "github-repos/lean/michelsol-lean-playground/lean-playground-0bfffb7bd41729fb9f95974e93f6ecbc0b6e59ca/Playground/Category/Functor/Bi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891261650247, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4590503835869462}}
{"text": "variable {α : Type*}\n\ndef is_prefix (l₁ : list α) (l₂ : list α) : Prop :=\n∃ t, l₁ ++ t = l₂\n\ninfix ` <+: `:50 := is_prefix\n\nsection\nlocal attribute [simp]\ntheorem list.is_prefix_refl (l : list α) : l <+: l :=\n⟨[], by simp⟩\n\nexample : [1, 2, 3] <+: [1, 2, 3] := by simp\nend\n\n-- example : [1, 2, 3] <+: [1, 2, 3] := by simp\n", "meta": {"author": "agryman", "repo": "theorem-proving-in-lean", "sha": "cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9", "save_path": "github-repos/lean/agryman-theorem-proving-in-lean", "path": "github-repos/lean/agryman-theorem-proving-in-lean/theorem-proving-in-lean-cf5a3a19d0d9d9c0a4f178f79e9b0fa67c5cddb9/src/06-Interacting-with-Lean/example-6.4-2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.45896492701046077}}
{"text": "/-\nCopyright (c) 2017 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sebastian Ullrich\n\n! This file was ported from Lean 3 source module init.control.lawful\n! leanprover-community/mathlib commit 9af482290ef68e8aaa5ead01aa7b09b7be7019fd\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nprelude\nimport Leanbin.Init.Control.Monad\nimport Leanbin.Init.Meta.Interactive\nimport Leanbin.Init.Control.State\nimport Leanbin.Init.Control.Except\nimport Leanbin.Init.Control.Reader\nimport Leanbin.Init.Control.Option\n\nuniverse u v\n\nopen Function\n\nopen Tactic\n\nunsafe def control_laws_tac :=\n  (whnf_target >> intros) >> to_expr ``(rfl) >>= exact\n#align control_laws_tac control_laws_tac\n\n#print LawfulFunctor /-\nclass LawfulFunctor (f : Type u → Type v) [Functor f] : Prop where\n  mapConst_eq :\n    ∀ {α β : Type u},\n      ((· <$ ·) : α → f β → f α) =\n        (· <$> ·) ∘ const β := by\n    intros\n    rfl\n  -- `functor` is indeed a categorical functor\n  id_map : ∀ {α : Type u} (x : f α), id <$> x = x\n  comp_map : ∀ {α β γ : Type u} (g : α → β) (h : β → γ) (x : f α), (h ∘ g) <$> x = h <$> g <$> x\n#align is_lawful_functor LawfulFunctor\n-/\n\nexport LawfulFunctor (mapConst_eq id_map comp_map)\n\nattribute [simp] id_map\n\n#print LawfulApplicative /-\n-- `comp_map` does not make a good simp lemma\nclass LawfulApplicative (f : Type u → Type v) [Applicative f] extends LawfulFunctor f : Prop where\n  seqLeft_eq :\n    ∀ {α β : Type u} (a : f α) (b : f β),\n      a <* b = const β <$> a <*> b := by\n    intros\n    rfl\n  seqRight_eq :\n    ∀ {α β : Type u} (a : f α) (b : f β),\n      a *> b = const α id <$> a <*> b := by\n    intros\n    rfl\n  -- applicative laws\n  pure_seq : ∀ {α β : Type u} (g : α → β) (x : f α), pure g <*> x = g <$> x\n  map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> (pure x : f α) = pure (g x)\n  seq_pure : ∀ {α β : Type u} (g : f (α → β)) (x : α), g <*> pure x = (fun g : α → β => g x) <$> g\n  seq_assoc :\n    ∀ {α β γ : Type u} (x : f α) (g : f (α → β)) (h : f (β → γ)),\n      h <*> (g <*> x) = @comp α β γ <$> h <*> g <*> x\n  -- default functor law\n  comp_map := (by intros <;> simp [(pure_seq_eq_map _ _).symm, seq_assoc, map_pure, seq_pure])\n#align is_lawful_applicative LawfulApplicative\n-/\n\nexport LawfulApplicative (seqLeft_eq seqRight_eq pure_seq map_pure seq_pure seq_assoc)\n\nattribute [simp] map_pure seq_pure\n\n/- warning: pure_id_seq -> pure_id_seq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {f : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} f] [_inst_2 : LawfulApplicative.{u1, u2} f _inst_1] (x : f α), Eq.{succ u2} (f α) (Seq.seq.{u1, u2} f (Applicative.toHasSeq.{u1, u2} f _inst_1) α α (Pure.pure.{u1, u2} f (Applicative.toHasPure.{u1, u2} f _inst_1) (α -> α) (id.{succ u1} α)) x) x\nbut is expected to have type\n  forall {α : Type.{u2} -> Type.{u1}} {f : Type.{u2}} [_inst_1 : Applicative.{u2, u1} α] [_inst_2 : LawfulApplicative.{u2, u1} α _inst_1] (x : α f), Eq.{succ u1} (α f) (Seq.seq.{u2, u1} α (Applicative.toSeq.{u2, u1} α _inst_1) f f (Pure.pure.{u2, u1} α (Applicative.toPure.{u2, u1} α _inst_1) (f -> f) (id.{succ u2} f)) (fun (x._@.Init.Control.Lawful._hyg.566 : Unit) => x)) x\nCase conversion may be inaccurate. Consider using '#align pure_id_seq pure_id_seqₓ'. -/\n-- applicative \"law\" derivable from other laws\n@[simp]\ntheorem pure_id_seq {α : Type u} {f : Type u → Type v} [Applicative f] [LawfulApplicative f]\n    (x : f α) : pure id <*> x = x := by simp [pure_seq_eq_map]\n#align pure_id_seq pure_id_seq\n\n#print LawfulMonad /-\nclass LawfulMonad (m : Type u → Type v) [Monad m] extends LawfulApplicative m : Prop where\n  bind_pure_comp_eq_map :\n    ∀ {α β : Type u} (f : α → β) (x : m α),\n      x >>= pure ∘ f = f <$> x := by\n    intros\n    rfl\n  bind_map_eq_seq :\n    ∀ {α β : Type u} (f : m (α → β)) (x : m α),\n      f >>= (· <$> x) = f <*> x := by\n    intros\n    rfl\n  -- monad laws\n  pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x\n  bind_assoc :\n    ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ),\n      x >>= f >>= g = x >>= fun x => f x >>= g\n  pure_seq := (by intros <;> rw [← bind_map_eq_seq] <;> simp [pure_bind])\n  map_pure := (by intros <;> rw [← bind_pure_comp_eq_map] <;> simp [pure_bind])\n  seq_pure := (by intros <;> rw [← bind_map_eq_seq] <;> simp [map_pure, bind_pure_comp_eq_map])\n  seq_assoc :=\n    (by\n      intros <;>\n        simp [(bind_pure_comp_eq_map _ _).symm, (bind_map_eq_seq _ _).symm, bind_assoc, pure_bind])\n#align is_lawful_monad LawfulMonad\n-/\n\nexport LawfulMonad (bind_pure_comp_eq_map bind_map_eq_seq pure_bind bind_assoc)\n\nattribute [simp] pure_bind\n\n/- warning: bind_pure -> bind_pure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {m : Type.{u1} -> Type.{u2}} [_inst_1 : Monad.{u1, u2} m] [_inst_2 : LawfulMonad.{u1, u2} m _inst_1] (x : m α), Eq.{succ u2} (m α) (Bind.bind.{u1, u2} m (Monad.toHasBind.{u1, u2} m _inst_1) α α x (Pure.pure.{u1, u2} m (Applicative.toHasPure.{u1, u2} m (Monad.toApplicative.{u1, u2} m _inst_1)) α)) x\nbut is expected to have type\n  forall {α : Type.{u2} -> Type.{u1}} {m : Type.{u2}} [_inst_1 : Monad.{u2, u1} α] [_inst_2 : LawfulMonad.{u2, u1} α _inst_1] (x : α m), Eq.{succ u1} (α m) (Bind.bind.{u2, u1} α (Monad.toBind.{u2, u1} α _inst_1) m m x (Pure.pure.{u2, u1} α (Applicative.toPure.{u2, u1} α (Monad.toApplicative.{u2, u1} α _inst_1)) m)) x\nCase conversion may be inaccurate. Consider using '#align bind_pure bind_pureₓ'. -/\n-- monad \"law\" derivable from other laws\n@[simp]\ntheorem bind_pure {α : Type u} {m : Type u → Type v} [Monad m] [LawfulMonad m] (x : m α) :\n    x >>= pure = x :=\n  show x >>= pure ∘ id = x by rw [bind_pure_comp_eq_map] <;> simp [id_map]\n#align bind_pure bind_pure\n\ntheorem bind_ext_congr {α β} {m : Type u → Type v} [Bind m] {x : m α} {f g : α → m β} :\n    (∀ a, f a = g a) → x >>= f = x >>= g := fun h => by simp [show f = g from funext h]\n#align bind_ext_congr bind_ext_congr\n\ntheorem map_ext_congr {α β} {m : Type u → Type v} [Functor m] {x : m α} {f g : α → β} :\n    (∀ a, f a = g a) → (f <$> x : m β) = g <$> x := fun h => by simp [show f = g from funext h]\n#align map_ext_congr map_ext_congr\n\n-- instances of previously defined monads\nnamespace id\n\nvariable {α β : Type}\n\n@[simp]\ntheorem map_eq (x : id α) (f : α → β) : f <$> x = f x :=\n  rfl\n#align id.map_eq id.map_eq\n\n@[simp]\ntheorem bind_eq (x : id α) (f : α → id β) : x >>= f = f x :=\n  rfl\n#align id.bind_eq id.bind_eq\n\n@[simp]\ntheorem pure_eq (a : α) : (pure a : id α) = a :=\n  rfl\n#align id.pure_eq id.pure_eq\n\nend id\n\ninstance : LawfulMonad id := by refine' { .. } <;> intros <;> rfl\n\nnamespace StateT\n\nsection\n\nvariable {σ : Type u}\n\nvariable {m : Type u → Type v}\n\nvariable {α β : Type u}\n\nvariable (x : StateT σ m α) (st : σ)\n\ntheorem ext {x x' : StateT σ m α} (h : ∀ st, x.run st = x'.run st) : x = x' := by\n  cases x <;> cases x' <;> simp [show x = x' from funext h]\n#align state_t.ext StateTₓ.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : StateT σ m α).run st = pure (a, st) :=\n  rfl\n#align state_t.run_pure StateTₓ.run_pure\n\n@[simp]\ntheorem run_bind (f : α → StateT σ m β) :\n    (x >>= f).run st = x.run st >>= fun p => (f p.1).run p.2 := by\n  apply bind_ext_congr <;> intro a <;> cases a <;> simp [StateT.bind, StateT.run]\n#align state_t.run_bind StateTₓ.run_bind\n\n@[simp]\ntheorem run_map (f : α → β) [LawfulMonad m] :\n    (f <$> x).run st = (fun p : α × σ => (f (Prod.fst p), Prod.snd p)) <$> x.run st :=\n  by\n  rw [← bind_pure_comp_eq_map _ (x.run st)]\n  change (x >>= pure ∘ f).run st = _\n  simp\n#align state_t.run_map StateTₓ.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n α) :\n    (monadLift x : StateT σ m α).run st = do\n      let a ← (monadLift x : m α)\n      pure (a, st) :=\n  rfl\n#align state_t.run_monad_lift StateTₓ.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : ∀ {α}, n α → n' α) :\n    (monadMap (@f) x : StateT σ m' α).run st = monadMap (@f) (x.run st) :=\n  rfl\n#align state_t.run_monad_map StateTₓ.run_monadMap\n\n@[simp]\ntheorem run_adapt {σ' σ''} (st : σ) (split : σ → σ' × σ'') (join : σ' → σ'' → σ)\n    (x : StateT σ' m α) :\n    (StateT.adapt split join x : StateT σ m α).run st = do\n      let (st, ctx) := split st\n      let (a, st') ← x.run st\n      pure (a, join st' ctx) :=\n  by delta StateT.adapt <;> rfl\n#align state_t.run_adapt StateTₓ.run_adapt\n\n@[simp]\ntheorem run_get : (StateT.get : StateT σ m σ).run st = pure (st, st) :=\n  rfl\n#align state_t.run_get StateTₓ.run_get\n\n@[simp]\ntheorem run_put (st') : (StateT.put st' : StateT σ m _).run st = pure (PUnit.unit, st') :=\n  rfl\n#align state_t.run_put StateTₓ.run_put\n\nend\n\nend StateT\n\ninstance (m : Type u → Type v) [Monad m] [LawfulMonad m] (σ : Type u) : LawfulMonad (StateT σ m)\n    where\n  id_map := by intros <;> apply StateT.ext <;> intro <;> simp <;> erw [id_map]\n  pure_bind := by\n    intros\n    apply StateT.ext\n    simp\n  bind_assoc := by\n    intros\n    apply StateT.ext\n    simp [bind_assoc]\n\nnamespace ExceptT\n\nvariable {α β ε : Type u} {m : Type u → Type v} (x : ExceptT ε m α)\n\ntheorem ext {x x' : ExceptT ε m α} (h : x.run = x'.run) : x = x' := by\n  cases x <;> cases x' <;> simp_all\n#align except_t.ext ExceptTₓ.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : ExceptT ε m α).run = pure (@Except.ok ε α a) :=\n  rfl\n#align except_t.run_pure ExceptTₓ.run_pure\n\n@[simp]\ntheorem run_bind (f : α → ExceptT ε m β) : (x >>= f).run = x.run >>= ExceptT.bindCont f :=\n  rfl\n#align except_t.run_bind ExceptTₓ.run_bind\n\n@[simp]\ntheorem run_map (f : α → β) [LawfulMonad m] : (f <$> x).run = Except.map f <$> x.run :=\n  by\n  rw [← bind_pure_comp_eq_map _ x.run]\n  change x.run >>= ExceptT.bindCont (pure ∘ f) = _\n  apply bind_ext_congr\n  intro a <;> cases a <;> simp [ExceptT.bindCont, Except.map]\n#align except_t.run_map ExceptTₓ.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n α) :\n    (monadLift x : ExceptT ε m α).run = Except.ok <$> (monadLift x : m α) :=\n  rfl\n#align except_t.run_monad_lift ExceptTₓ.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : ∀ {α}, n α → n' α) :\n    (monadMap (@f) x : ExceptT ε m' α).run = monadMap (@f) x.run :=\n  rfl\n#align except_t.run_monad_map ExceptTₓ.run_monadMap\n\nend ExceptT\n\ninstance (m : Type u → Type v) [Monad m] [LawfulMonad m] (ε : Type u) : LawfulMonad (ExceptT ε m)\n    where\n  id_map := by\n    intros ; apply ExceptT.ext; simp only [ExceptT.run_map]\n    rw [map_ext_congr, id_map]\n    intro a; cases a <;> rfl\n  bind_pure_comp_eq_map := by\n    intros ; apply ExceptT.ext; simp only [ExceptT.run_map, ExceptT.run_bind]\n    rw [bind_ext_congr, bind_pure_comp_eq_map]\n    intro a; cases a <;> rfl\n  bind_assoc := by\n    intros ; apply ExceptT.ext; simp only [ExceptT.run_bind, bind_assoc]\n    rw [bind_ext_congr]\n    intro a; cases a <;> simp [ExceptT.bindCont]\n  pure_bind := by intros <;> apply ExceptT.ext <;> simp [ExceptT.bindCont]\n\nnamespace ReaderT\n\nsection\n\nvariable {ρ : Type u}\n\nvariable {m : Type u → Type v}\n\nvariable {α β : Type u}\n\nvariable (x : ReaderT ρ m α) (r : ρ)\n\ntheorem ext {x x' : ReaderT ρ m α} (h : ∀ r, x.run r = x'.run r) : x = x' := by\n  cases x <;> cases x' <;> simp [show x = x' from funext h]\n#align reader_t.ext ReaderTₓ.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : ReaderT ρ m α).run r = pure a :=\n  rfl\n#align reader_t.run_pure ReaderTₓ.run_pure\n\n@[simp]\ntheorem run_bind (f : α → ReaderT ρ m β) : (x >>= f).run r = x.run r >>= fun a => (f a).run r :=\n  rfl\n#align reader_t.run_bind ReaderTₓ.run_bind\n\n@[simp]\ntheorem run_map (f : α → β) [LawfulMonad m] : (f <$> x).run r = f <$> x.run r := by\n  rw [← bind_pure_comp_eq_map _ (x.run r)] <;> rfl\n#align reader_t.run_map ReaderTₓ.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n α) :\n    (monadLift x : ReaderT ρ m α).run r = (monadLift x : m α) :=\n  rfl\n#align reader_t.run_monad_lift ReaderTₓ.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : ∀ {α}, n α → n' α) :\n    (monadMap (@f) x : ReaderT ρ m' α).run r = monadMap (@f) (x.run r) :=\n  rfl\n#align reader_t.run_monad_map ReaderTₓ.run_monadMap\n\n@[simp]\ntheorem run_read : (ReaderT.read : ReaderT ρ m ρ).run r = pure r :=\n  rfl\n#align reader_t.run_read ReaderTₓ.run_read\n\nend\n\nend ReaderT\n\ninstance (ρ : Type u) (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (ReaderT ρ m)\n    where\n  id_map := by intros <;> apply ReaderT.ext <;> intro <;> simp\n  pure_bind := by intros <;> apply ReaderT.ext <;> intro <;> simp\n  bind_assoc := by intros <;> apply ReaderT.ext <;> intro <;> simp [bind_assoc]\n\nnamespace OptionT\n\nvariable {α β : Type u} {m : Type u → Type v} (x : OptionT m α)\n\ntheorem ext {x x' : OptionT m α} (h : x.run = x'.run) : x = x' := by\n  cases x <;> cases x' <;> simp_all\n#align option_t.ext OptionTₓ.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : OptionT m α).run = pure (some a) :=\n  rfl\n#align option_t.run_pure OptionTₓ.run_pure\n\n@[simp]\ntheorem run_bind (f : α → OptionT m β) : (x >>= f).run = x.run >>= OptionT.bindCont f :=\n  rfl\n#align option_t.run_bind OptionTₓ.run_bind\n\n@[simp]\ntheorem run_map (f : α → β) [LawfulMonad m] : (f <$> x).run = Option.map f <$> x.run :=\n  by\n  rw [← bind_pure_comp_eq_map _ x.run]\n  change x.run >>= OptionT.bindCont (pure ∘ f) = _\n  apply bind_ext_congr\n  intro a <;> cases a <;> simp [OptionT.bindCont, Option.map, Option.bind]\n#align option_t.run_map OptionTₓ.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n α) :\n    (monadLift x : OptionT m α).run = some <$> (monadLift x : m α) :=\n  rfl\n#align option_t.run_monad_lift OptionTₓ.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : ∀ {α}, n α → n' α) :\n    (monadMap (@f) x : OptionT m' α).run = monadMap (@f) x.run :=\n  rfl\n#align option_t.run_monad_map OptionTₓ.run_monadMap\n\nend OptionT\n\ninstance (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m)\n    where\n  id_map := by\n    intros ; apply OptionT.ext; simp only [OptionT.run_map]\n    rw [map_ext_congr, id_map]\n    intro a; cases a <;> rfl\n  bind_assoc := by\n    intros ; apply OptionT.ext; simp only [OptionT.run_bind, bind_assoc]\n    rw [bind_ext_congr]\n    intro a; cases a <;> simp [OptionT.bindCont]\n  pure_bind := by intros <;> apply OptionT.ext <;> simp [OptionT.bindCont]\n\n", "meta": {"author": "leanprover-community", "repo": "lean3port", "sha": "9ed1898f23e4379865ee93d62cb6353e5ed6c270", "save_path": "github-repos/lean/leanprover-community-lean3port", "path": "github-repos/lean/leanprover-community-lean3port/lean3port-9ed1898f23e4379865ee93d62cb6353e5ed6c270/Leanbin/Init/Control/Lawful.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.45896492266889516}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.limits.preserves.limits\n\nopen category_theory category_theory.category\n\nnamespace category_theory.limits\n\nuniverses v v₂ u -- morphism levels before object levels. See note [category_theory universes].\n\nvariables {C : Type u} [category.{v} C]\n\nvariables {J K : Type v} [small_category J] [category.{v₂} K]\n\n@[simp, reassoc]\nlemma limit.lift_π_app (H : J ⥤ K ⥤ C) [has_limit H] (c : cone H) (j : J) (k : K) :\n  (limit.lift H c).app k ≫ (limit.π H j).app k = (c.π.app j).app k :=\ncongr_app (limit.lift_π c j) k\n\n@[simp, reassoc]\nlemma colimit.ι_desc_app (H : J ⥤ K ⥤ C) [has_colimit H] (c : cocone H) (j : J) (k : K) :\n  (colimit.ι H j).app k ≫ (colimit.desc H c).app k = (c.ι.app j).app k :=\ncongr_app (colimit.ι_desc c j) k\n\n/--\nThe evaluation functors jointly reflect limits: that is, to show a cone is a limit of `F`\nit suffices to show that each evaluation cone is a limit. In other words, to prove a cone is\nlimiting you can show it's pointwise limiting.\n-/\ndef evaluation_jointly_reflects_limits {F : J ⥤ K ⥤ C} (c : cone F)\n  (t : Π (k : K), is_limit (((evaluation K C).obj k).map_cone c)) : is_limit c :=\n{ lift := λ s,\n  { app := λ k, (t k).lift ⟨s.X.obj k, whisker_right s.π ((evaluation K C).obj k)⟩,\n    naturality' := λ X Y f, (t Y).hom_ext $ λ j,\n    begin\n      rw [assoc, (t Y).fac _ j],\n      simpa using\n        ((t X).fac_assoc ⟨s.X.obj X, whisker_right s.π ((evaluation K C).obj X)⟩ j _).symm,\n    end },\n  fac' := λ s j, nat_trans.ext _ _ $ funext $ λ k, (t k).fac _ j,\n  uniq' := λ s m w, nat_trans.ext _ _ $ funext $ λ x, (t x).hom_ext $ λ j,\n      (congr_app (w j) x).trans\n        ((t x).fac ⟨s.X.obj _, whisker_right s.π ((evaluation K C).obj _)⟩ j).symm }\n\n/--\nGiven a functor `F` and a collection of limit cones for each diagram `X ↦ F X k`, we can stitch\nthem together to give a cone for the diagram `F`.\n`combined_is_limit` shows that the new cone is limiting, and `eval_combined` shows it is\n(essentially) made up of the original cones.\n-/\n@[simps] def combine_cones (F : J ⥤ K ⥤ C) (c : Π (k : K), limit_cone (F.flip.obj k)) :\n  cone F :=\n{ X :=\n  { obj := λ k, (c k).cone.X,\n    map := λ k₁ k₂ f, (c k₂).is_limit.lift ⟨_, (c k₁).cone.π ≫ F.flip.map f⟩,\n    map_id' := λ k, (c k).is_limit.hom_ext (λ j, by { dsimp, simp }),\n    map_comp' := λ k₁ k₂ k₃ f₁ f₂, (c k₃).is_limit.hom_ext (λ j, by simp) },\n  π :=\n  { app := λ j, { app := λ k, (c k).cone.π.app j },\n    naturality' := λ j₁ j₂ g, nat_trans.ext _ _ $ funext $ λ k, (c k).cone.π.naturality g } }\n\n/-- The stitched together cones each project down to the original given cones (up to iso). -/\ndef evaluate_combined_cones (F : J ⥤ K ⥤ C) (c : Π (k : K), limit_cone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cone (combine_cones F c) ≅ (c k).cone :=\ncones.ext (iso.refl _) (by tidy)\n\n/-- Stitching together limiting cones gives a limiting cone. -/\ndef combined_is_limit (F : J ⥤ K ⥤ C) (c : Π (k : K), limit_cone (F.flip.obj k)) :\n  is_limit (combine_cones F c) :=\nevaluation_jointly_reflects_limits _\n  (λ k, (c k).is_limit.of_iso_limit (evaluate_combined_cones F c k).symm)\n\n/--\nThe evaluation functors jointly reflect colimits: that is, to show a cocone is a colimit of `F`\nit suffices to show that each evaluation cocone is a colimit. In other words, to prove a cocone is\ncolimiting you can show it's pointwise colimiting.\n-/\ndef evaluation_jointly_reflects_colimits {F : J ⥤ K ⥤ C} (c : cocone F)\n  (t : Π (k : K), is_colimit (((evaluation K C).obj k).map_cocone c)) : is_colimit c :=\n{ desc := λ s,\n  { app := λ k, (t k).desc ⟨s.X.obj k, whisker_right s.ι ((evaluation K C).obj k)⟩,\n    naturality' := λ X Y f, (t X).hom_ext $ λ j,\n    begin\n      rw [(t X).fac_assoc _ j],\n      erw ← (c.ι.app j).naturality_assoc f,\n      erw (t Y).fac ⟨s.X.obj _, whisker_right s.ι _⟩ j,\n      dsimp,\n      simp,\n    end },\n  fac' := λ s j, nat_trans.ext _ _ $ funext $ λ k, (t k).fac _ j,\n  uniq' := λ s m w, nat_trans.ext _ _ $ funext $ λ x, (t x).hom_ext $ λ j,\n      (congr_app (w j) x).trans\n        ((t x).fac ⟨s.X.obj _, whisker_right s.ι ((evaluation K C).obj _)⟩ j).symm }\n\n/--\nGiven a functor `F` and a collection of colimit cocones for each diagram `X ↦ F X k`, we can stitch\nthem together to give a cocone for the diagram `F`.\n`combined_is_colimit` shows that the new cocone is colimiting, and `eval_combined` shows it is\n(essentially) made up of the original cocones.\n-/\n@[simps] def combine_cocones (F : J ⥤ K ⥤ C) (c : Π (k : K), colimit_cocone (F.flip.obj k)) :\n  cocone F :=\n{ X :=\n  { obj := λ k, (c k).cocone.X,\n    map := λ k₁ k₂ f, (c k₁).is_colimit.desc ⟨_, F.flip.map f ≫ (c k₂).cocone.ι⟩,\n    map_id' := λ k, (c k).is_colimit.hom_ext (λ j, by { dsimp, simp }),\n    map_comp' := λ k₁ k₂ k₃ f₁ f₂, (c k₁).is_colimit.hom_ext (λ j, by simp) },\n  ι :=\n  { app := λ j, { app := λ k, (c k).cocone.ι.app j },\n    naturality' := λ j₁ j₂ g, nat_trans.ext _ _ $ funext $ λ k, (c k).cocone.ι.naturality g } }\n\n/-- The stitched together cocones each project down to the original given cocones (up to iso). -/\ndef evaluate_combined_cocones\n  (F : J ⥤ K ⥤ C) (c : Π (k : K), colimit_cocone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cocone (combine_cocones F c) ≅ (c k).cocone :=\ncocones.ext (iso.refl _) (by tidy)\n\n/-- Stitching together colimiting cocones gives a colimiting cocone. -/\ndef combined_is_colimit (F : J ⥤ K ⥤ C) (c : Π (k : K), colimit_cocone (F.flip.obj k)) :\n  is_colimit (combine_cocones F c) :=\nevaluation_jointly_reflects_colimits _\n  (λ k, (c k).is_colimit.of_iso_colimit (evaluate_combined_cocones F c k).symm)\n\nnoncomputable theory\n\ninstance functor_category_has_limits_of_shape\n  [has_limits_of_shape J C] : has_limits_of_shape J (K ⥤ C) :=\n{ has_limit := λ F, has_limit.mk\n  { cone := combine_cones F (λ k, get_limit_cone _),\n    is_limit := combined_is_limit _ _ } }\n\ninstance functor_category_has_colimits_of_shape\n  [has_colimits_of_shape J C] : has_colimits_of_shape J (K ⥤ C) :=\n{ has_colimit := λ F, has_colimit.mk\n  { cocone := combine_cocones _ (λ k, get_colimit_cocone _),\n    is_colimit := combined_is_colimit _ _ } }\n\ninstance functor_category_has_limits [has_limits C] : has_limits (K ⥤ C) := {}\n\ninstance functor_category_has_colimits [has_colimits C] : has_colimits (K ⥤ C) := {}\n\ninstance evaluation_preserves_limits_of_shape [has_limits_of_shape J C] (k : K) :\n  preserves_limits_of_shape J ((evaluation K C).obj k) :=\n{ preserves_limit :=\n  λ F, preserves_limit_of_preserves_limit_cone (combined_is_limit _ _) $\n    is_limit.of_iso_limit (limit.is_limit _)\n      (evaluate_combined_cones F _ k).symm }\n\n/--\nIf `F : J ⥤ K ⥤ C` is a functor into a functor category which has a limit,\nthen the evaluation of that limit at `k` is the limit of the evaluations of `F.obj j` at `k`.\n-/\ndef limit_obj_iso_limit_comp_evaluation [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :\n  (limit F).obj k ≅ limit (F ⋙ ((evaluation K C).obj k)) :=\npreserves_limit_iso ((evaluation K C).obj k) F\n\n@[simp, reassoc]\nlemma limit_obj_iso_limit_comp_evaluation_hom_π\n  [has_limits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K) :\n  (limit_obj_iso_limit_comp_evaluation F k).hom ≫ limit.π (F ⋙ ((evaluation K C).obj k)) j =\n    (limit.π F j).app k :=\nbegin\n  dsimp [limit_obj_iso_limit_comp_evaluation],\n  simp,\nend\n\n@[simp, reassoc]\nlemma limit_obj_iso_limit_comp_evaluation_inv_π_app\n  [has_limits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K):\n  (limit_obj_iso_limit_comp_evaluation F k).inv ≫ (limit.π F j).app k =\n    limit.π (F ⋙ ((evaluation K C).obj k)) j :=\nbegin\n  dsimp [limit_obj_iso_limit_comp_evaluation],\n  rw iso.inv_comp_eq,\n  simp,\nend\n\n@[ext]\nlemma limit_obj_ext {H : J ⥤ K ⥤ C} [has_limits_of_shape J C]\n  {k : K} {W : C} {f g : W ⟶ (limit H).obj k}\n  (w : ∀ j, f ≫ (limits.limit.π H j).app k = g ≫ (limits.limit.π H j).app k) : f = g :=\nbegin\n  apply (cancel_mono (limit_obj_iso_limit_comp_evaluation H k).hom).1,\n  ext,\n  simpa using w j,\nend\n\ninstance evaluation_preserves_colimits_of_shape [has_colimits_of_shape J C] (k : K) :\n  preserves_colimits_of_shape J ((evaluation K C).obj k) :=\n{ preserves_colimit :=\n  λ F, preserves_colimit_of_preserves_colimit_cocone (combined_is_colimit _ _) $\n    is_colimit.of_iso_colimit (colimit.is_colimit _)\n      (evaluate_combined_cocones F _ k).symm }\n\n/--\nIf `F : J ⥤ K ⥤ C` is a functor into a functor category which has a colimit,\nthen the evaluation of that colimit at `k` is the colimit of the evaluations of `F.obj j` at `k`.\n-/\ndef colimit_obj_iso_colimit_comp_evaluation [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :\n  (colimit F).obj k ≅ colimit (F ⋙ ((evaluation K C).obj k)) :=\npreserves_colimit_iso ((evaluation K C).obj k) F\n\n@[simp, reassoc]\nlemma colimit_obj_iso_colimit_comp_evaluation_ι_inv\n  [has_colimits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K) :\n  colimit.ι (F ⋙ ((evaluation K C).obj k)) j ≫ (colimit_obj_iso_colimit_comp_evaluation F k).inv =\n    (colimit.ι F j).app k :=\nbegin\n  dsimp [colimit_obj_iso_colimit_comp_evaluation],\n  simp,\nend\n\n@[simp, reassoc]\nlemma colimit_obj_iso_colimit_comp_evaluation_ι_app_hom\n  [has_colimits_of_shape J C] (F : J ⥤ (K ⥤ C)) (j : J) (k : K) :\n  (colimit.ι F j).app k ≫ (colimit_obj_iso_colimit_comp_evaluation F k).hom =\n     colimit.ι (F ⋙ ((evaluation K C).obj k)) j :=\nbegin\n  dsimp [colimit_obj_iso_colimit_comp_evaluation],\n  rw ←iso.eq_comp_inv,\n  simp,\nend\n\n@[ext]\nlemma colimit_obj_ext {H : J ⥤ K ⥤ C} [has_colimits_of_shape J C]\n  {k : K} {W : C} {f g : (colimit H).obj k ⟶ W}\n  (w : ∀ j, (colimit.ι H j).app k ≫ f = (colimit.ι H j).app k ≫ g) : f = g :=\nbegin\n  apply (cancel_epi (colimit_obj_iso_colimit_comp_evaluation H k).inv).1,\n  ext,\n  simpa using w j,\nend\n\ninstance evaluation_preserves_limits [has_limits C] (k : K) :\n  preserves_limits ((evaluation K C).obj k) :=\n{ preserves_limits_of_shape := λ J 𝒥, by resetI; apply_instance }\n\ninstance evaluation_preserves_colimits [has_colimits C] (k : K) :\n  preserves_colimits ((evaluation K C).obj k) :=\n{ preserves_colimits_of_shape := λ J 𝒥, by resetI; apply_instance }\n\nend category_theory.limits\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190475, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4589649226688951}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport order.hom.basic\nimport order.bounded_order\n\n/-!\n# Bounded order homomorphisms\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines (bounded) order homomorphisms.\n\nWe use the `fun_like` design, so each type of morphisms has a companion typeclass which is meant to\nbe satisfied by itself and all stricter types.\n\n## Types of morphisms\n\n* `top_hom`: Maps which preserve `⊤`.\n* `bot_hom`: Maps which preserve `⊥`.\n* `bounded_order_hom`: Bounded order homomorphisms. Monotone maps which preserve `⊤` and `⊥`.\n\n## Typeclasses\n\n* `top_hom_class`\n* `bot_hom_class`\n* `bounded_order_hom_class`\n-/\n\nopen function order_dual\n\nvariables {F α β γ δ : Type*}\n\n/-- The type of `⊤`-preserving functions from `α` to `β`. -/\nstructure top_hom (α β : Type*) [has_top α] [has_top β] :=\n(to_fun   : α → β)\n(map_top' : to_fun ⊤ = ⊤)\n\n/-- The type of `⊥`-preserving functions from `α` to `β`. -/\nstructure bot_hom (α β : Type*) [has_bot α] [has_bot β] :=\n(to_fun   : α → β)\n(map_bot' : to_fun ⊥ = ⊥)\n\n/-- The type of bounded order homomorphisms from `α` to `β`. -/\nstructure bounded_order_hom (α β : Type*) [preorder α] [preorder β] [bounded_order α]\n  [bounded_order β]\n  extends order_hom α β :=\n(map_top' : to_fun ⊤ = ⊤)\n(map_bot' : to_fun ⊥ = ⊥)\n\nsection\nset_option old_structure_cmd true\n\n/-- `top_hom_class F α β` states that `F` is a type of `⊤`-preserving morphisms.\n\nYou should extend this class when you extend `top_hom`. -/\nclass top_hom_class (F : Type*) (α β : out_param $ Type*) [has_top α] [has_top β]\n  extends fun_like F α (λ _, β) :=\n(map_top (f : F) : f ⊤ = ⊤)\n\n/-- `bot_hom_class F α β` states that `F` is a type of `⊥`-preserving morphisms.\n\nYou should extend this class when you extend `bot_hom`. -/\nclass bot_hom_class (F : Type*) (α β : out_param $ Type*) [has_bot α] [has_bot β]\n  extends fun_like F α (λ _, β) :=\n(map_bot (f : F) : f ⊥ = ⊥)\n\n/-- `bounded_order_hom_class F α β` states that `F` is a type of bounded order morphisms.\n\nYou should extend this class when you extend `bounded_order_hom`. -/\nclass bounded_order_hom_class (F : Type*) (α β : out_param $ Type*) [has_le α] [has_le β]\n  [bounded_order α] [bounded_order β]\n  extends rel_hom_class F ((≤) : α → α → Prop) ((≤) : β → β → Prop) :=\n(map_top (f : F) : f ⊤ = ⊤)\n(map_bot (f : F) : f ⊥ = ⊥)\n\nend\n\nexport top_hom_class (map_top) bot_hom_class (map_bot)\n\nattribute [simp] map_top map_bot\n\n@[priority 100] -- See note [lower instance priority]\ninstance bounded_order_hom_class.to_top_hom_class [has_le α] [has_le β]\n  [bounded_order α] [bounded_order β] [bounded_order_hom_class F α β] :\n  top_hom_class F α β :=\n{ .. ‹bounded_order_hom_class F α β› }\n\n@[priority 100] -- See note [lower instance priority]\ninstance bounded_order_hom_class.to_bot_hom_class [has_le α] [has_le β]\n  [bounded_order α] [bounded_order β] [bounded_order_hom_class F α β] :\n  bot_hom_class F α β :=\n{ .. ‹bounded_order_hom_class F α β› }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_top_hom_class [has_le α] [order_top α] [partial_order β] [order_top β]\n  [order_iso_class F α β] :\n  top_hom_class F α β :=\n{ map_top := λ f, top_le_iff.1 $ (map_inv_le_iff f).1 le_top,\n  .. show order_hom_class F α β, from infer_instance }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_bot_hom_class [has_le α] [order_bot α] [partial_order β] [order_bot β]\n  [order_iso_class F α β] :\n  bot_hom_class F α β :=\n--⟨λ f, le_bot_iff.1 $ (le_map_inv_iff f).1 bot_le⟩\n{ map_bot := λ f, le_bot_iff.1 $ (le_map_inv_iff f).1 bot_le,\n  .. show order_hom_class F α β, from infer_instance }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_bounded_order_hom_class [has_le α] [bounded_order α] [partial_order β]\n  [bounded_order β] [order_iso_class F α β] :\n  bounded_order_hom_class F α β :=\n{ ..show order_hom_class F α β, from infer_instance,\n  ..order_iso_class.to_top_hom_class,\n  ..order_iso_class.to_bot_hom_class }\n\n@[simp] lemma map_eq_top_iff [has_le α] [order_top α] [partial_order β] [order_top β]\n  [order_iso_class F α β] (f : F) {a : α} : f a = ⊤ ↔ a = ⊤ :=\nby rw [←map_top f, (equiv_like.injective f).eq_iff]\n\n@[simp] lemma map_eq_bot_iff [has_le α] [order_bot α] [partial_order β] [order_bot β]\n  [order_iso_class F α β] (f : F) {a : α} : f a = ⊥ ↔ a = ⊥ :=\nby rw [←map_bot f, (equiv_like.injective f).eq_iff]\n\ninstance [has_top α] [has_top β] [top_hom_class F α β] : has_coe_t F (top_hom α β) :=\n⟨λ f, ⟨f, map_top f⟩⟩\n\ninstance [has_bot α] [has_bot β] [bot_hom_class F α β] : has_coe_t F (bot_hom α β) :=\n⟨λ f, ⟨f, map_bot f⟩⟩\n\ninstance [preorder α] [preorder β] [bounded_order α] [bounded_order β]\n  [bounded_order_hom_class F α β] : has_coe_t F (bounded_order_hom α β) :=\n⟨λ f, { to_fun := f, map_top' := map_top f, map_bot' := map_bot f, ..(f : α →o β) }⟩\n\n/-! ### Top homomorphisms -/\n\nnamespace top_hom\nvariables [has_top α]\n\nsection has_top\nvariables [has_top β] [has_top γ] [has_top δ]\n\ninstance : top_hom_class (top_hom α β) α β :=\n{ coe := top_hom.to_fun,\n  coe_injective' := λ f g h, by cases f; cases g; congr',\n  map_top := top_hom.map_top' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (top_hom α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : top_hom α β} : f.to_fun = (f : α → β) := rfl\n\n-- this must come after the coe_to_fun definition\ninitialize_simps_projections top_hom (to_fun → apply)\n\n@[ext] lemma ext {f g : top_hom α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of a `top_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : top_hom α β) (f' : α → β) (h : f' = f) : top_hom α β :=\n{ to_fun := f',\n  map_top' := h.symm ▸ f.map_top' }\n\n@[simp] lemma coe_copy (f : top_hom α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl\nlemma copy_eq (f : top_hom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f := fun_like.ext' h\n\ninstance : inhabited (top_hom α β) := ⟨⟨λ _, ⊤, rfl⟩⟩\n\nvariables (α)\n\n/-- `id` as a `top_hom`. -/\nprotected def id : top_hom α α := ⟨id, rfl⟩\n\n@[simp] lemma coe_id : ⇑(top_hom.id α) = id := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : top_hom.id α a = a := rfl\n\n/-- Composition of `top_hom`s as a `top_hom`. -/\ndef comp (f : top_hom β γ) (g : top_hom α β) : top_hom α γ :=\n{ to_fun := f ∘ g,\n  map_top' := by rw [comp_apply, map_top, map_top] }\n\n@[simp] lemma coe_comp (f : top_hom β γ) (g : top_hom α β) : (f.comp g : α → γ) = f ∘ g := rfl\n@[simp] lemma comp_apply (f : top_hom β γ) (g : top_hom α β) (a : α) :\n  (f.comp g) a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : top_hom γ δ) (g : top_hom β γ) (h : top_hom α β) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : top_hom α β) : f.comp (top_hom.id α) = f := top_hom.ext $ λ a, rfl\n@[simp] lemma id_comp (f : top_hom α β) : (top_hom.id β).comp f = f := top_hom.ext $ λ a, rfl\n\nlemma cancel_right {g₁ g₂ : top_hom β γ} {f : top_hom α β} (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, top_hom.ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : top_hom β γ} {f₁ f₂ : top_hom α β} (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, top_hom.ext $ λ a, hg $\n  by rw [←top_hom.comp_apply, h, top_hom.comp_apply], congr_arg _⟩\n\nend has_top\n\ninstance [preorder β] [has_top β] : preorder (top_hom α β) :=\npreorder.lift (coe_fn : top_hom α β → α → β)\n\ninstance [partial_order β] [has_top β] : partial_order (top_hom α β) :=\npartial_order.lift _ fun_like.coe_injective\n\nsection order_top\nvariables [preorder β] [order_top β]\n\ninstance : order_top (top_hom α β) := ⟨⟨⊤, rfl⟩, λ _, le_top⟩\n\n@[simp] lemma coe_top : ⇑(⊤ : top_hom α β) = ⊤ := rfl\n@[simp] lemma top_apply (a : α) : (⊤ : top_hom α β) a = ⊤ := rfl\n\nend order_top\n\nsection semilattice_inf\nvariables [semilattice_inf β] [order_top β] (f g : top_hom α β)\n\ninstance : has_inf (top_hom α β) :=\n⟨λ f g, ⟨f ⊓ g, by rw [pi.inf_apply, map_top, map_top, inf_top_eq]⟩⟩\n\ninstance : semilattice_inf (top_hom α β) := fun_like.coe_injective.semilattice_inf _ $ λ _ _, rfl\n\n@[simp] lemma coe_inf : ⇑(f ⊓ g) = f ⊓ g := rfl\n@[simp] lemma inf_apply (a : α) : (f ⊓ g) a = f a ⊓ g a := rfl\n\nend semilattice_inf\n\nsection semilattice_sup\nvariables [semilattice_sup β] [order_top β] (f g : top_hom α β)\n\ninstance : has_sup (top_hom α β) :=\n⟨λ f g, ⟨f ⊔ g, by rw [pi.sup_apply, map_top, map_top, sup_top_eq]⟩⟩\n\ninstance : semilattice_sup (top_hom α β) := fun_like.coe_injective.semilattice_sup _ $ λ _ _, rfl\n\n@[simp] lemma coe_sup : ⇑(f ⊔ g) = f ⊔ g := rfl\n@[simp] lemma sup_apply (a : α) : (f ⊔ g) a = f a ⊔ g a := rfl\n\nend semilattice_sup\n\ninstance [lattice β] [order_top β] : lattice (top_hom α β) :=\nfun_like.coe_injective.lattice _ (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [distrib_lattice β] [order_top β] : distrib_lattice (top_hom α β) :=\nfun_like.coe_injective.distrib_lattice _ (λ _ _, rfl) (λ _ _, rfl)\n\nend top_hom\n\n/-! ### Bot homomorphisms -/\n\nnamespace bot_hom\nvariables [has_bot α]\n\nsection has_bot\nvariables [has_bot β] [has_bot γ] [has_bot δ]\n\ninstance : bot_hom_class (bot_hom α β) α β :=\n{ coe := bot_hom.to_fun,\n  coe_injective' := λ f g h, by cases f; cases g; congr',\n  map_bot := bot_hom.map_bot' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (bot_hom α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : bot_hom α β} : f.to_fun = (f : α → β) := rfl\n\n-- this must come after the coe_to_fun definition\ninitialize_simps_projections bot_hom (to_fun → apply)\n\n@[ext] lemma ext {f g : bot_hom α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of a `bot_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (f : bot_hom α β) (f' : α → β) (h : f' = f) : bot_hom α β :=\n{ to_fun := f',\n  map_bot' := h.symm ▸ f.map_bot' }\n\n@[simp] lemma coe_copy (f : bot_hom α β) (f' : α → β) (h : f' = f) : ⇑(f.copy f' h) = f' := rfl\nlemma copy_eq (f : bot_hom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f := fun_like.ext' h\n\ninstance : inhabited (bot_hom α β) := ⟨⟨λ _, ⊥, rfl⟩⟩\n\nvariables (α)\n\n/-- `id` as a `bot_hom`. -/\nprotected def id : bot_hom α α := ⟨id, rfl⟩\n\n@[simp] lemma coe_id : ⇑(bot_hom.id α) = id := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : bot_hom.id α a = a := rfl\n\n/-- Composition of `bot_hom`s as a `bot_hom`. -/\ndef comp (f : bot_hom β γ) (g : bot_hom α β) : bot_hom α γ :=\n{ to_fun := f ∘ g,\n  map_bot' := by rw [comp_apply, map_bot, map_bot] }\n\n@[simp] lemma coe_comp (f : bot_hom β γ) (g : bot_hom α β) : (f.comp g : α → γ) = f ∘ g := rfl\n@[simp] lemma comp_apply (f : bot_hom β γ) (g : bot_hom α β) (a : α) :\n  (f.comp g) a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : bot_hom γ δ) (g : bot_hom β γ) (h : bot_hom α β) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : bot_hom α β) : f.comp (bot_hom.id α) = f := bot_hom.ext $ λ a, rfl\n@[simp] lemma id_comp (f : bot_hom α β) : (bot_hom.id β).comp f = f := bot_hom.ext $ λ a, rfl\n\nlemma cancel_right {g₁ g₂ : bot_hom β γ} {f : bot_hom α β} (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, bot_hom.ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : bot_hom β γ} {f₁ f₂ : bot_hom α β} (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, bot_hom.ext $ λ a, hg $\n  by rw [←bot_hom.comp_apply, h, bot_hom.comp_apply], congr_arg _⟩\n\nend has_bot\n\ninstance [preorder β] [has_bot β] : preorder (bot_hom α β) :=\npreorder.lift (coe_fn : bot_hom α β → α → β)\n\ninstance [partial_order β] [has_bot β] : partial_order (bot_hom α β) :=\npartial_order.lift _ fun_like.coe_injective\n\nsection order_bot\nvariables [preorder β] [order_bot β]\n\ninstance : order_bot (bot_hom α β) := ⟨⟨⊥, rfl⟩, λ _, bot_le⟩\n\n@[simp] lemma coe_bot : ⇑(⊥ : bot_hom α β) = ⊥ := rfl\n@[simp] lemma bot_apply (a : α) : (⊥ : bot_hom α β) a = ⊥ := rfl\n\nend order_bot\n\nsection semilattice_inf\nvariables [semilattice_inf β] [order_bot β] (f g : bot_hom α β)\n\ninstance : has_inf (bot_hom α β) :=\n⟨λ f g, ⟨f ⊓ g, by rw [pi.inf_apply, map_bot, map_bot, inf_bot_eq]⟩⟩\n\ninstance : semilattice_inf (bot_hom α β) := fun_like.coe_injective.semilattice_inf _ $ λ _ _, rfl\n\n@[simp] lemma coe_inf : ⇑(f ⊓ g) = f ⊓ g := rfl\n@[simp] lemma inf_apply (a : α) : (f ⊓ g) a = f a ⊓ g a := rfl\n\nend semilattice_inf\n\nsection semilattice_sup\nvariables [semilattice_sup β] [order_bot β] (f g : bot_hom α β)\n\ninstance : has_sup (bot_hom α β) :=\n⟨λ f g, ⟨f ⊔ g, by rw [pi.sup_apply, map_bot, map_bot, sup_bot_eq]⟩⟩\n\ninstance : semilattice_sup (bot_hom α β) := fun_like.coe_injective.semilattice_sup _ $ λ _ _, rfl\n\n@[simp] lemma coe_sup : ⇑(f ⊔ g) = f ⊔ g := rfl\n@[simp] lemma sup_apply (a : α) : (f ⊔ g) a = f a ⊔ g a := rfl\n\nend semilattice_sup\n\ninstance [lattice β] [order_bot β] : lattice (bot_hom α β) :=\nfun_like.coe_injective.lattice _ (λ _ _, rfl) (λ _ _, rfl)\n\ninstance [distrib_lattice β] [order_bot β] : distrib_lattice (bot_hom α β) :=\nfun_like.coe_injective.distrib_lattice _ (λ _ _, rfl) (λ _ _, rfl)\n\nend bot_hom\n\n/-! ### Bounded order homomorphisms -/\n\nnamespace bounded_order_hom\nvariables [preorder α] [preorder β] [preorder γ] [preorder δ] [bounded_order α] [bounded_order β]\n  [bounded_order γ] [bounded_order δ]\n\n/-- Reinterpret a `bounded_order_hom` as a `top_hom`. -/\ndef to_top_hom (f : bounded_order_hom α β) : top_hom α β := { ..f }\n\n/-- Reinterpret a `bounded_order_hom` as a `bot_hom`. -/\ndef to_bot_hom (f : bounded_order_hom α β) : bot_hom α β := { ..f }\n\ninstance : bounded_order_hom_class (bounded_order_hom α β) α β :=\n{ coe := λ f, f.to_fun,\n  coe_injective' := λ f g h, by obtain ⟨⟨_, _⟩, _⟩ := f; obtain ⟨⟨_, _⟩, _⟩ := g; congr',\n  map_rel := λ f, f.monotone',\n  map_top := λ f, f.map_top',\n  map_bot := λ f, f.map_bot' }\n\n/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`\ndirectly. -/\ninstance : has_coe_to_fun (bounded_order_hom α β) (λ _, α → β) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : bounded_order_hom α β} : f.to_fun = (f : α → β) := rfl\n\n@[ext] lemma ext {f g : bounded_order_hom α β} (h : ∀ a, f a = g a) : f = g := fun_like.ext f g h\n\n/-- Copy of a `bounded_order_hom` with a new `to_fun` equal to the old one. Useful to fix\ndefinitional equalities. -/\nprotected def copy (f : bounded_order_hom α β) (f' : α → β) (h : f' = f) : bounded_order_hom α β :=\n{ .. f.to_order_hom.copy f' h, .. f.to_top_hom.copy f' h, .. f.to_bot_hom.copy f' h }\n\n@[simp] lemma coe_copy (f : bounded_order_hom α β) (f' : α → β) (h : f' = f) :\n  ⇑(f.copy f' h) = f' :=\nrfl\n\nlemma copy_eq (f : bounded_order_hom α β) (f' : α → β) (h : f' = f) : f.copy f' h = f :=\nfun_like.ext' h\n\nvariables (α)\n\n/-- `id` as a `bounded_order_hom`. -/\nprotected def id : bounded_order_hom α α := { ..order_hom.id, ..top_hom.id α, ..bot_hom.id α }\n\ninstance : inhabited (bounded_order_hom α α) := ⟨bounded_order_hom.id α⟩\n\n@[simp] lemma coe_id : ⇑(bounded_order_hom.id α) = id := rfl\n\nvariables {α}\n\n@[simp] lemma id_apply (a : α) : bounded_order_hom.id α a = a := rfl\n\n/-- Composition of `bounded_order_hom`s as a `bounded_order_hom`. -/\ndef comp (f : bounded_order_hom β γ) (g : bounded_order_hom α β) : bounded_order_hom α γ :=\n{ ..f.to_order_hom.comp g.to_order_hom,\n  ..f.to_top_hom.comp g.to_top_hom, ..f.to_bot_hom.comp g.to_bot_hom }\n\n@[simp] lemma coe_comp (f : bounded_order_hom β γ) (g : bounded_order_hom α β) :\n  (f.comp g : α → γ) = f ∘ g := rfl\n@[simp] lemma comp_apply (f : bounded_order_hom β γ) (g : bounded_order_hom α β) (a : α) :\n  (f.comp g) a = f (g a) := rfl\n@[simp] lemma coe_comp_order_hom (f : bounded_order_hom β γ) (g : bounded_order_hom α β) :\n  (f.comp g : order_hom α γ) = (f : order_hom β γ).comp g := rfl\n@[simp] lemma coe_comp_top_hom (f : bounded_order_hom β γ) (g : bounded_order_hom α β) :\n  (f.comp g : top_hom α γ) = (f : top_hom β γ).comp g := rfl\n@[simp] lemma coe_comp_bot_hom (f : bounded_order_hom β γ) (g : bounded_order_hom α β) :\n  (f.comp g : bot_hom α γ) = (f : bot_hom β γ).comp g := rfl\n@[simp] lemma comp_assoc (f : bounded_order_hom γ δ) (g : bounded_order_hom β γ)\n  (h : bounded_order_hom α β) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : bounded_order_hom α β) : f.comp (bounded_order_hom.id α) = f :=\nbounded_order_hom.ext $ λ a, rfl\n@[simp] lemma id_comp (f : bounded_order_hom α β) : (bounded_order_hom.id β).comp f = f :=\nbounded_order_hom.ext $ λ a, rfl\n\nlemma cancel_right {g₁ g₂ : bounded_order_hom β γ} {f : bounded_order_hom α β} (hf : surjective f) :\n  g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=\n⟨λ h, bounded_order_hom.ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _⟩\n\nlemma cancel_left {g : bounded_order_hom β γ} {f₁ f₂ : bounded_order_hom α β} (hg : injective g) :\n  g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ :=\n⟨λ h, bounded_order_hom.ext $ λ a, hg $\n  by rw [←bounded_order_hom.comp_apply, h, bounded_order_hom.comp_apply], congr_arg _⟩\n\nend bounded_order_hom\n\n/-! ### Dual homs -/\n\nnamespace top_hom\nvariables [has_le α] [order_top α] [has_le β] [order_top β] [has_le γ] [order_top γ]\n\n/-- Reinterpret a top homomorphism as a bot homomorphism between the dual lattices. -/\n@[simps] protected def dual : top_hom α β ≃ bot_hom αᵒᵈ βᵒᵈ :=\n{ to_fun := λ f, ⟨f, f.map_top'⟩,\n  inv_fun := λ f, ⟨f, f.map_bot'⟩,\n  left_inv := λ f, top_hom.ext $ λ _, rfl,\n  right_inv := λ f, bot_hom.ext $ λ _, rfl }\n\n@[simp] lemma dual_id : (top_hom.id α).dual = bot_hom.id _ := rfl\n@[simp] lemma dual_comp (g : top_hom β γ) (f : top_hom α β) :\n  (g.comp f).dual = g.dual.comp f.dual := rfl\n\n@[simp] lemma symm_dual_id : top_hom.dual.symm (bot_hom.id _) = top_hom.id α := rfl\n@[simp] lemma symm_dual_comp (g : bot_hom βᵒᵈ γᵒᵈ) (f : bot_hom αᵒᵈ βᵒᵈ) :\n  top_hom.dual.symm (g.comp f) = (top_hom.dual.symm g).comp (top_hom.dual.symm f) := rfl\n\nend top_hom\n\nnamespace bot_hom\nvariables [has_le α] [order_bot α] [has_le β] [order_bot β] [has_le γ] [order_bot γ]\n\n/-- Reinterpret a bot homomorphism as a top homomorphism between the dual lattices. -/\n@[simps] protected def dual : bot_hom α β ≃ top_hom αᵒᵈ βᵒᵈ :=\n{ to_fun := λ f, ⟨f, f.map_bot'⟩,\n  inv_fun := λ f, ⟨f, f.map_top'⟩,\n  left_inv := λ f, bot_hom.ext $ λ _, rfl,\n  right_inv := λ f, top_hom.ext $ λ _, rfl }\n\n@[simp] lemma dual_id : (bot_hom.id α).dual = top_hom.id _ := rfl\n@[simp] lemma dual_comp (g : bot_hom β γ) (f : bot_hom α β) :\n  (g.comp f).dual = g.dual.comp f.dual := rfl\n\n@[simp] lemma symm_dual_id : bot_hom.dual.symm (top_hom.id _) = bot_hom.id α := rfl\n@[simp] lemma symm_dual_comp (g : top_hom βᵒᵈ γᵒᵈ) (f : top_hom αᵒᵈ βᵒᵈ) :\n  bot_hom.dual.symm (g.comp f) = (bot_hom.dual.symm g).comp (bot_hom.dual.symm f) := rfl\n\nend bot_hom\n\nnamespace bounded_order_hom\nvariables [preorder α] [bounded_order α] [preorder β] [bounded_order β] [preorder γ]\n  [bounded_order γ]\n\n/-- Reinterpret a bounded order homomorphism as a bounded order homomorphism between the dual\norders. -/\n@[simps] protected def dual : bounded_order_hom α β ≃ bounded_order_hom αᵒᵈ βᵒᵈ :=\n{ to_fun := λ f, ⟨f.to_order_hom.dual, f.map_bot', f.map_top'⟩,\n  inv_fun := λ f, ⟨order_hom.dual.symm f.to_order_hom, f.map_bot', f.map_top'⟩,\n  left_inv := λ f, ext $ λ a, rfl,\n  right_inv := λ f, ext $ λ a, rfl }\n\n@[simp] lemma dual_id : (bounded_order_hom.id α).dual = bounded_order_hom.id _ := rfl\n@[simp] lemma dual_comp (g : bounded_order_hom β γ) (f : bounded_order_hom α β) :\n  (g.comp f).dual = g.dual.comp f.dual := rfl\n\n@[simp] lemma symm_dual_id :\n  bounded_order_hom.dual.symm (bounded_order_hom.id _) = bounded_order_hom.id α := rfl\n@[simp] lemma symm_dual_comp (g : bounded_order_hom βᵒᵈ γᵒᵈ) (f : bounded_order_hom αᵒᵈ βᵒᵈ) :\n  bounded_order_hom.dual.symm (g.comp f) =\n    (bounded_order_hom.dual.symm g).comp (bounded_order_hom.dual.symm f) := rfl\n\nend bounded_order_hom\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/order/hom/bounded.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.679178692681616, "lm_q1q2_score": 0.4589649182806306}}
{"text": "/-\nCopyright (c) 2019 Jean Lo. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jean Lo\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.pointwise\nimport Mathlib.analysis.normed_space.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l \n\nnamespace Mathlib\n\n/-!\n# Seminorms and Local Convexity\n\nThis file introduces the following notions, defined for a vector space\nover a normed field:\n\n- the subset properties of being `absorbent` and `balanced`,\n\n- a `seminorm`, a function to the reals that is positive-semidefinite,\n  absolutely homogeneous, and subadditive.\n\nWe prove related properties.\n\n## TODO\n\nDefine and show equivalence of two notions of local convexity for a\ntopological vector space over ℝ or ℂ: that it has a local base of\nbalanced convex absorbent sets, and that it carries the initial\ntopology induced by a family of seminorms.\n\n## References\n* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]\n-/\n\n/-!\n### Subset Properties\n\nAbsorbent and balanced sets in a vector space over a\nnondiscrete normed field.\n-/\n\n/-- A set `A` absorbs another set `B` if `B` is contained in scaling\n`A` by elements of sufficiently large norms. -/\ndef absorbs (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (A : set E) (B : set E) :=\n  ∃ (r : ℝ), ∃ (H : r > 0), ∀ (a : 𝕜), r ≤ norm a → B ⊆ a • A\n\n/-- A set is absorbent if it absorbs every singleton. -/\ndef absorbent (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (A : set E) :=\n  ∀ (x : E), ∃ (r : ℝ), ∃ (H : r > 0), ∀ (a : 𝕜), r ≤ norm a → x ∈ a • A\n\n/-- A set `A` is balanced if `a • A` is contained in `A` whenever `a`\nhas norm no greater than one. -/\ndef balanced (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (A : set E) :=\n  ∀ (a : 𝕜), norm a ≤ 1 → a • A ⊆ A\n\n/-- A balanced set absorbs itself. -/\ntheorem balanced.absorbs_self {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] {A : set E} (hA : balanced 𝕜 A) : absorbs 𝕜 A A := sorry\n\n/-!\nProperties of balanced and absorbing sets in a topological vector space:\n-/\n\n/-- Every neighbourhood of the origin is absorbent. -/\ntheorem absorbent_nhds_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E] [topological_vector_space 𝕜 E] (hA : A ∈ nhds 0) : absorbent 𝕜 A := sorry\n\n/-- The union of `{0}` with the interior of a balanced set\n    is balanced. -/\ntheorem balanced_zero_union_interior {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E] [topological_vector_space 𝕜 E] (hA : balanced 𝕜 A) : balanced 𝕜 (singleton 0 ∪ interior A) := sorry\n\n/-- The interior of a balanced set is balanced if it contains the origin. -/\ntheorem balanced.interior {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E] [topological_vector_space 𝕜 E] (hA : balanced 𝕜 A) (h : 0 ∈ interior A) : balanced 𝕜 (interior A) := sorry\n\n/-- The closure of a balanced set is balanced. -/\ntheorem balanced.closure {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E] [topological_vector_space 𝕜 E] (hA : balanced 𝕜 A) : balanced 𝕜 (closure A) := sorry\n\n/-!\n### Seminorms\n-/\n\n/-- A seminorm on a vector space over a normed field is a function to\nthe reals that is positive semidefinite, positive homogeneous, and\nsubadditive. -/\nstructure seminorm (𝕜 : Type u_1) (E : Type u_2) [normed_field 𝕜] [add_comm_group E] [vector_space 𝕜 E] \nwhere\n  to_fun : E → ℝ\n  smul' : ∀ (a : 𝕜) (x : E), to_fun (a • x) = norm a * to_fun x\n  triangle' : ∀ (x y : E), to_fun (x + y) ≤ to_fun x + to_fun y\n\nprotected instance seminorm.inhabited {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] : Inhabited (seminorm 𝕜 E) :=\n  { default := seminorm.mk (fun (_x : E) => 0) sorry sorry }\n\nprotected instance seminorm.has_coe_to_fun {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] : has_coe_to_fun (seminorm 𝕜 E) :=\n  has_coe_to_fun.mk (fun (p : seminorm 𝕜 E) => E → ℝ) fun (p : seminorm 𝕜 E) => seminorm.to_fun p\n\nnamespace seminorm\n\n\nprotected theorem smul {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (c : 𝕜) (x : E) : coe_fn p (c • x) = norm c * coe_fn p x :=\n  smul' p c x\n\nprotected theorem triangle {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (y : E) : coe_fn p (x + y) ≤ coe_fn p x + coe_fn p y :=\n  triangle' p x y\n\n@[simp] protected theorem zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) : coe_fn p 0 = 0 := sorry\n\n@[simp] protected theorem neg {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) : coe_fn p (-x) = coe_fn p x := sorry\n\ntheorem nonneg {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) : 0 ≤ coe_fn p x := sorry\n\ntheorem sub_rev {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (y : E) : coe_fn p (x - y) = coe_fn p (y - x) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn p (x - y) = coe_fn p (y - x))) (Eq.symm (neg_sub y x))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn p (-(y - x)) = coe_fn p (y - x))) (seminorm.neg p (y - x))))\n      (Eq.refl (coe_fn p (y - x))))\n\n/-- The ball of radius `r` at `x` with respect to seminorm `p`\n    is the set of elements `y` with `p (y - x) < `r`. -/\ndef ball {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (r : ℝ) : set E :=\n  set_of fun (y : E) => coe_fn p (y - x) < r\n\ntheorem mem_ball {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (y : E) (r : ℝ) : y ∈ ball p x r ↔ coe_fn p (y - x) < r :=\n  iff.rfl\n\ntheorem mem_ball_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (y : E) (r : ℝ) : y ∈ ball p 0 r ↔ coe_fn p y < r :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (y ∈ ball p 0 r ↔ coe_fn p y < r)) (propext (mem_ball p 0 y r))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn p (y - 0) < r ↔ coe_fn p y < r)) (sub_zero y))) (iff.refl (coe_fn p y < r)))\n\ntheorem ball_zero_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (r : ℝ) : ball p 0 r = set_of fun (y : E) => coe_fn p y < r := sorry\n\n/-- Seminorm-balls at the origin are balanced. -/\ntheorem balanced_ball_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (r : ℝ) : balanced 𝕜 (ball p 0 r) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/seminorm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6757645879592642, "lm_q1q2_score": 0.4589649137989685}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport logic.relator\n\n/-!\n# Quotient types\n\nThis module extends the core library's treatment of quotient types (`init.data.quot`).\n\n## Tags\n\nquotient\n-/\n\nvariables {α : Sort*} {β : Sort*}\n\nnamespace setoid\n\nlemma ext {α : Sort*} :\n  ∀{s t : setoid α}, (∀a b, @setoid.r α s a b ↔ @setoid.r α t a b) → s = t\n| ⟨r, _⟩ ⟨p, _⟩ eq :=\n  have r = p, from funext $ assume a, funext $ assume b, propext $ eq a b,\n  by subst this\n\nend setoid\n\nnamespace quot\nvariables {ra : α → α → Prop} {rb : β → β → Prop} {φ : quot ra → quot rb → Sort*}\nlocal notation `⟦`:max a `⟧` := quot.mk _ a\n\ninstance [inhabited α] : inhabited (quot ra) := ⟨⟦default⟧⟩\n\ninstance [subsingleton α] : subsingleton (quot ra) :=\n⟨λ x, quot.induction_on x (λ y, quot.ind (λ b, congr_arg _ (subsingleton.elim _ _)))⟩\n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂ (qa : quot ra) (qb : quot rb) (f : Π a b, φ ⟦a⟧ ⟦b⟧)\n  (ca : ∀ {b a₁ a₂}, ra a₁ a₂ → f a₁ b == f a₂ b)\n  (cb : ∀ {a b₁ b₂}, rb b₁ b₂ → f a b₁ == f a b₂) : φ qa qb :=\nquot.hrec_on qa (λ a, quot.hrec_on qb (f a) (λ b₁ b₂ pb, cb pb)) $ λ a₁ a₂ pa,\n  quot.induction_on qb $ λ b,\n    calc @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₁) (@cb _)\n          == f a₁ b                                     : by simp [heq_self_iff_true]\n      ... == f a₂ b                                     : ca pa\n      ... == @quot.hrec_on _ _ (φ _) ⟦b⟧ (f a₂) (@cb _) : by simp [heq_self_iff_true]\n\n/-- Map a function `f : α → β` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra → quot rb`. -/\nprotected def map (f : α → β) (h : (ra ⇒ rb) f f) : quot ra → quot rb :=\nquot.lift (λ x, ⟦f x⟧) $ assume x y (h₁ : ra x y), quot.sound $ h h₁\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `quot ra → quot ra'`. -/\nprotected def map_right {ra' : α → α → Prop} (h : ∀a₁ a₂, ra a₁ a₂ → ra' a₁ a₂) :\n  quot ra → quot ra' :=\nquot.map id h\n\n/-- weaken the relation of a quotient -/\ndef factor {α : Type*} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n  quot r → quot s :=\nquot.lift (quot.mk s) (λ x y rxy, quot.sound (h x y rxy))\n\nlemma factor_mk_eq {α : Type*} (r s : α → α → Prop) (h : ∀ x y, r x y → s x y) :\n  factor r s h ∘ quot.mk _ = quot.mk _ := rfl\n\nvariables {γ : Sort*} {r : α → α → Prop} {s : β → β → Prop}\n\n/-- **Alias** of `quot.lift_beta`. -/\nlemma lift_mk (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) (a : α) :\n  quot.lift f h (quot.mk r a) = f a := quot.lift_beta f h a\n\n@[simp]\nlemma lift_on_mk (a : α) (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :\n  quot.lift_on (quot.mk r a) f h = f a := rfl\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β`. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift₂\n  (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b)\n  (q₁ : quot r) (q₂ : quot s) : γ :=\nquot.lift (λ a, quot.lift (f a) (hr a))\n(λ a₁ a₂ ha, funext (λ q, quot.induction_on q (λ b, hs a₁ a₂ b ha)))\nq₁ q₂\n\n@[simp]\nlemma lift₂_mk (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) (a : α) (b : β) :\n  quot.lift₂ f hr hs (quot.mk r a) (quot.mk s b) = f a b := rfl\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` and applies it. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift_on₂ (p : quot r) (q : quot s) (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) : γ := quot.lift₂ f hr hs p q\n\n@[simp]\nlemma lift_on₂_mk (a : α) (b : β) (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → f a b₁ = f a b₂)\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → f a₁ b = f a₂ b) :\n  quot.lift_on₂ (quot.mk r a) (quot.mk s b) f hr hs = f a b := rfl\n\nvariables {t : γ → γ → Prop}\n\n/-- Descends a function `f : α → β → γ` to quotients of `α` and `β` wih values in a quotient of\n`γ`. -/\nprotected def map₂ (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b))\n  (q₁ : quot r) (q₂ : quot s) : quot t :=\nquot.lift₂ (λ a b, quot.mk t $ f a b) (λ a b₁ b₂ hb, quot.sound (hr a b₁ b₂ hb))\n(λ a₁ a₂ b ha, quot.sound (hs a₁ a₂ b ha)) q₁ q₂\n\n@[simp]\nlemma map₂_mk (f : α → β → γ)\n  (hr : ∀ a b₁ b₂, s b₁ b₂ → t (f a b₁) (f a b₂))\n  (hs : ∀ a₁ a₂ b, r a₁ a₂ → t (f a₁ b) (f a₂ b))\n  (a : α) (b : β) : quot.map₂ f hr hs (quot.mk r a) (quot.mk s b) = quot.mk t (f a b) := rfl\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on₂\n  {δ : quot r → quot s → Prop} (q₁ : quot r) (q₂ : quot s)\n  (h : ∀ a b, δ (quot.mk r a) (quot.mk s b)) : δ q₁ q₂ :=\nquot.ind (λ a₁, quot.ind (λ a₂, h a₁ a₂) q₂) q₁\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on₃\n  {δ : quot r → quot s → quot t → Prop} (q₁ : quot r) (q₂ : quot s) (q₃ : quot t)\n  (h : ∀ a b c, δ (quot.mk r a) (quot.mk s b) (quot.mk t c)) : δ q₁ q₂ q₃ :=\nquot.ind (λ a₁, quot.ind (λ a₂, quot.ind (λ a₃, h a₁ a₂ a₃) q₃) q₂) q₁\n\nend quot\n\nnamespace quotient\nvariables [sa : setoid α] [sb : setoid β]\nvariables {φ : quotient sa → quotient sb → Sort*}\n\ninstance [inhabited α] : inhabited (quotient sa) := ⟨⟦default⟧⟩\n\ninstance (s : setoid α) [subsingleton α] : subsingleton (quotient s) :=\nquot.subsingleton\n\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂ (qa : quotient sa) (qb : quotient sb) (f : Π a b, φ ⟦a⟧ ⟦b⟧)\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) : φ qa qb :=\nquot.hrec_on₂ qa qb f\n  (λ _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (λ _ _ _ p, c _ _ _ _ (setoid.refl _) p)\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : α → β) (h : ((≈) ⇒ (≈)) f f) : quotient sa → quotient sb :=\nquot.map f h\n\n@[simp] lemma map_mk (f : α → β) (h : ((≈) ⇒ (≈)) f f) (x : α) :\n  quotient.map f h (⟦x⟧ : quotient sa) = (⟦f x⟧ : quotient sb) :=\nrfl\n\nvariables {γ : Sort*} [sc : setoid γ]\n\n/-- Map a function `f : α → β → γ` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa → quotient sb → quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map₂ (f : α → β → γ) (h : ((≈) ⇒ (≈) ⇒ (≈)) f f) :\n  quotient sa → quotient sb → quotient sc :=\nquotient.lift₂ (λ x y, ⟦f x y⟧) (λ x₁ y₁ x₂ y₂ h₁ h₂, quot.sound $ h h₁ h₂)\n\n@[simp] lemma map₂_mk (f : α → β → γ) (h : ((≈) ⇒ (≈) ⇒ (≈)) f f) (x : α) (y : β) :\n  quotient.map₂ f h (⟦x⟧ : quotient sa) (⟦y⟧ : quotient sb) = (⟦f x y⟧ : quotient sc) := rfl\n\nend quotient\n\nlemma quot.eq {α : Type*} {r : α → α → Prop} {x y : α} :\n  quot.mk r x = quot.mk r y ↔ eqv_gen r x y :=\n⟨quot.exact r, quot.eqv_gen_sound⟩\n\n@[simp] theorem quotient.eq [r : setoid α] {x y : α} : ⟦x⟧ = ⟦y⟧ ↔ x ≈ y :=\n⟨quotient.exact, quotient.sound⟩\n\ntheorem forall_quotient_iff {α : Type*} [r : setoid α] {p : quotient r → Prop} :\n  (∀a:quotient r, p a) ↔ (∀a:α, p ⟦a⟧) :=\n⟨assume h x, h _, assume h a, a.induction_on h⟩\n\n@[simp] lemma quotient.lift_mk [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b)\n  (x : α) :\n  quotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift₂_mk {α : Sort*} {β : Sort*} {γ : Sort*} [setoid α] [setoid β]\n  (f : α → β → γ)\n  (h : ∀ (a₁ : α) (a₂ : β) (b₁ : α) (b₂ : β), a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂)\n  (a : α) (b : β) :\n  quotient.lift₂ f h (quotient.mk a) (quotient.mk b) = f a b := rfl\n\n@[simp] lemma quotient.lift_on_mk [s : setoid α] (f : α → β) (h : ∀ (a b : α), a ≈ b → f a = f b)\n  (x : α) :\n  quotient.lift_on (quotient.mk x) f h = f x := rfl\n\n@[simp] theorem quotient.lift_on₂_mk {α : Sort*} {β : Sort*} [setoid α] (f : α → α → β)\n  (h : ∀ (a₁ a₂ b₁ b₂ : α), a₁ ≈ b₁ → a₂ ≈ b₂ → f a₁ a₂ = f b₁ b₂) (x y : α) :\n  quotient.lift_on₂ (quotient.mk x) (quotient.mk y) f h = f x y := rfl\n\n/-- `quot.mk r` is a surjective function. -/\nlemma surjective_quot_mk (r : α → α → Prop) : function.surjective (quot.mk r) :=\nquot.exists_rep\n\n/-- `quotient.mk` is a surjective function. -/\nlemma surjective_quotient_mk (α : Sort*) [s : setoid α] :\n  function.surjective (quotient.mk : α → quotient s) :=\nquot.exists_rep\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quot.out {r : α → α → Prop} (q : quot r) : α :=\nclassical.some (quot.exists_rep q)\n\n/-- Unwrap the VM representation of a quotient to obtain an element of the equivalence class.\n  Computable but unsound. -/\nmeta def quot.unquot {r : α → α → Prop} : quot r → α := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : α → α → Prop} (q : quot r) : quot.mk r q.out = q :=\nclassical.some_spec (quot.exists_rep q)\n\n/-- Choose an element of the equivalence class using the axiom of choice.\n  Sound but noncomputable. -/\nnoncomputable def quotient.out [s : setoid α] : quotient s → α := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid α] (q : quotient s) : ⟦q.out⟧ = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid α] (a : α) : ⟦a⟧.out ≈ a :=\nquotient.exact (quotient.out_eq _)\n\nlemma quotient.mk_eq_iff_out [s : setoid α] {x : α} {y : quotient s} :\n  ⟦x⟧ = y ↔ x ≈ quotient.out y :=\nbegin\n  refine iff.trans _ quotient.eq,\n  rw quotient.out_eq y,\nend\n\nlemma quotient.eq_mk_iff_out [s : setoid α] {x : quotient s} {y : α} :\n  x = ⟦y⟧ ↔ quotient.out x ≈ y  :=\nbegin\n  refine iff.trans _ quotient.eq,\n  rw quotient.out_eq x,\nend\n\n@[simp] lemma quotient.out_equiv_out [s : setoid α] {x y : quotient s} :\n  x.out ≈ y.out ↔ x = y :=\nby rw [← quotient.eq_mk_iff_out, quotient.out_eq]\n\n@[simp] lemma quotient.out_inj [s : setoid α] {x y : quotient s} :\n  x.out = y.out ↔ x = y :=\n⟨λ h, quotient.out_equiv_out.1 $ h ▸ setoid.refl _, λ h, h ▸ rfl⟩\n\nsection pi\n\ninstance pi_setoid {ι : Sort*} {α : ι → Sort*} [∀ i, setoid (α i)] : setoid (Π i, α i) :=\n{ r := λ a b, ∀ i, a i ≈ b i,\n  iseqv := ⟨\n    λ a i, setoid.refl _,\n    λ a b h i, setoid.symm (h _),\n    λ a b c h₁ h₂ i, setoid.trans (h₁ _) (h₂ _)⟩ }\n\n/-- Given a function `f : Π i, quotient (S i)`, returns the class of functions `Π i, α i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def quotient.choice {ι : Type*} {α : ι → Type*} [S : Π i, setoid (α i)]\n  (f : Π i, quotient (S i)) : @quotient (Π i, α i) (by apply_instance) :=\n⟦λ i, (f i).out⟧\n\n@[simp] theorem quotient.choice_eq {ι : Type*} {α : ι → Type*} [Π i, setoid (α i)]\n  (f : Π i, α i) : quotient.choice (λ i, ⟦f i⟧) = ⟦f⟧ :=\nquotient.sound $ λ i, quotient.mk_out _\n\n@[elab_as_eliminator] lemma quotient.induction_on_pi\n   {ι : Type*} {α : ι → Sort*} [s : ∀ i, setoid (α i)]\n   {p : (Π i, quotient (s i)) → Prop} (f : Π i, quotient (s i))\n   (h : ∀ a : Π i, α i, p (λ i, ⟦a i⟧)) : p f :=\nbegin\n  rw ← (funext (λ i, quotient.out_eq (f i)) : (λ i,  ⟦(f i).out⟧) = f),\n  apply h,\nend\n\nend pi\n\nlemma nonempty_quotient_iff (s : setoid α) : nonempty (quotient s) ↔ nonempty α :=\n⟨assume ⟨a⟩, quotient.induction_on a nonempty.intro, assume ⟨a⟩, ⟨⟦a⟧⟩⟩\n\n/-- `trunc α` is the quotient of `α` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty α`, but unlike `nonempty α`, `trunc α` is data,\n  so the VM representation is the same as `α`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (α : Sort u) : Sort u := @quot α (λ _ _, true)\n\ntheorem true_equivalence : @equivalence α (λ _ _, true) :=\n⟨λ _, trivial, λ _ _ _, trivial, λ _ _ _ _ _, trivial⟩\n\nnamespace trunc\n\n/-- Constructor for `trunc α` -/\ndef mk (a : α) : trunc α := quot.mk _ a\n\ninstance [inhabited α] : inhabited (trunc α) := ⟨mk default⟩\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : α → β) (c : ∀ a b : α, f a = f b) : trunc α → β :=\nquot.lift f (λ a b _, c a b)\n\ntheorem ind {β : trunc α → Prop} : (∀ a : α, β (mk a)) → ∀ q : trunc α, β q := quot.ind\n\nprotected theorem lift_mk (f : α → β) (c) (a : α) : lift f c (mk a) = f a := rfl\n\n/-- Lift a constant function on `q : trunc α`. -/\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc α) (f : α → β)\n  (c : ∀ a b : α, f a = f b) : β := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {β : trunc α → Prop} (q : trunc α)\n  (h : ∀ a, β (mk a)) : β q := ind h q\n\ntheorem exists_rep (q : trunc α) : ∃ a : α, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on₂ {C : trunc α → trunc β → Prop} (q₁ : trunc α) (q₂ : trunc β)\n  (h : ∀ a b, C (mk a) (mk b)) : C q₁ q₂ :=\ntrunc.induction_on q₁ $ λ a₁, trunc.induction_on q₂ (h a₁)\n\nprotected theorem eq (a b : trunc α) : a = b :=\ntrunc.induction_on₂ a b (λ x y, quot.sound trivial)\n\ninstance : subsingleton (trunc α) := ⟨trunc.eq⟩\n\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : trunc α) (f : α → trunc β) : trunc β :=\ntrunc.lift_on q f (λ a b, trunc.eq _ _)\n\n/-- A function `f : α → β` defines a function `map f : trunc α → trunc β`. -/\ndef map (f : α → β) (q : trunc α) : trunc β := bind q (trunc.mk ∘ f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := λ α q, trunc.eq _ _,\n  pure_bind := λ α β q f, rfl,\n  bind_assoc := λ α β γ x f g, trunc.eq _ _ }\n\nvariable {C : trunc α → Sort*}\n\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : Π a, C (mk a)) (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc α) : C q :=\nquot.rec f (λ a b _, h a b) q\n\n/-- A version of `trunc.rec` taking `q : trunc α` as the first argument. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc α) (f : Π a, C (mk a))\n  (h : ∀ (a b : α), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b) : C q :=\ntrunc.rec f h q\n\n/-- A version of `trunc.rec_on` assuming the codomain is a `subsingleton`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton\n   [∀ a, subsingleton (C (mk a))] (q : trunc α) (f : Π a, C (mk a)) : C q :=\ntrunc.rec f (λ a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc α` (using the axiom of choice). -/\nnoncomputable def out : trunc α → α := quot.out\n\n@[simp] theorem out_eq (q : trunc α) : mk q.out = q := trunc.eq _ _\n\nprotected theorem nonempty (q : trunc α) : nonempty α :=\nnonempty_of_exists q.exists_rep\n\nend trunc\n\nnamespace quotient\nvariables {γ : Sort*} {φ : Sort*}\n  {s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}\n\n/-! Versions of quotient definitions and lemmas ending in `'` use unification instead\nof typeclass inference for inferring the `setoid` argument. This is useful when there are\nseveral different quotient relations on a type, for example quotient groups, rings and modules. -/\n\n/-- A version of `quotient.mk` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk' (a : α) : quotient s₁ := quot.mk s₁.1 a\n\n/-- `quotient.mk'` is a surjective function. -/\nlemma surjective_quotient_mk' : function.surjective (quotient.mk' : α → quotient s₁) :=\nquot.exists_rep\n\n/-- A version of `quotient.lift_on` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s₁) (f : α → φ)\n  (h : ∀ a b, @setoid.r α s₁ a b → f a = f b) : φ := quotient.lift_on q f h\n\n@[simp]\nprotected lemma lift_on'_mk' (f : α → φ) (h) (x : α) :\n  quotient.lift_on' (@quotient.mk' _ s₁ x) f h = f x := rfl\n\n/-- A version of `quotient.lift_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on₂' (q₁ : quotient s₁) (q₂ : quotient s₂) (f : α → β → γ)\n  (h : ∀ a₁ a₂ b₁ b₂, @setoid.r α s₁ a₁ b₁ → @setoid.r β s₂ a₂ b₂ → f a₁ a₂ = f b₁ b₂) : γ :=\nquotient.lift_on₂ q₁ q₂ f h\n\n@[simp]\nprotected lemma lift_on₂'_mk' (f : α → β → γ) (h) (a : α) (b : β) :\n  quotient.lift_on₂' (@quotient.mk' _ s₁ a) (@quotient.mk' _ s₂ b) f h = f a b := rfl\n\n/-- A version of `quotient.ind` taking `{s : setoid α}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s₁ → Prop}\n  (h : ∀ a, p (quotient.mk' a)) (q : quotient s₁) : p q :=\nquotient.ind h q\n\n/-- A version of `quotient.ind₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma ind₂' {p : quotient s₁ → quotient s₂ → Prop}\n  (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂))\n  (q₁ : quotient s₁) (q₂ : quotient s₂) : p q₁ q₂ :=\nquotient.ind₂ h q₁ q₂\n\n/-- A version of `quotient.induction_on` taking `{s : setoid α}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s₁ → Prop} (q : quotient s₁)\n  (h : ∀ a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n/-- A version of `quotient.induction_on₂` taking `{s₁ : setoid α} {s₂ : setoid β}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on₂' {p : quotient s₁ → quotient s₂ → Prop} (q₁ : quotient s₁)\n  (q₂ : quotient s₂) (h : ∀ a₁ a₂, p (quotient.mk' a₁) (quotient.mk' a₂)) : p q₁ q₂ :=\nquotient.induction_on₂ q₁ q₂ h\n\n/-- A version of `quotient.induction_on₃` taking `{s₁ : setoid α} {s₂ : setoid β} {s₃ : setoid γ}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on₃' {p : quotient s₁ → quotient s₂ → quotient s₃ → Prop}\n  (q₁ : quotient s₁) (q₂ : quotient s₂) (q₃ : quotient s₃)\n  (h : ∀ a₁ a₂ a₃, p (quotient.mk' a₁) (quotient.mk' a₂) (quotient.mk' a₃)) : p q₁ q₂ q₃ :=\nquotient.induction_on₃ q₁ q₂ q₃ h\n\n/-- A version of `quotient.rec_on_subsingleton` taking `{s₁ : setoid α}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_eliminator]\nprotected def rec_on_subsingleton' {φ : quotient s₁ → Sort*}\n  [h : ∀ a, subsingleton (φ ⟦a⟧)] (q : quotient s₁) (f : Π a, φ (quotient.mk' a)) : φ q :=\nquotient.rec_on_subsingleton q f\n\n/-- A version of `quotient.rec_on_subsingleton₂` taking `{s₁ : setoid α} {s₂ : setoid α}`\nas implicit arguments instead of instance arguments. -/\nattribute [reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton₂'\n   {φ : quotient s₁ → quotient s₂ → Sort*} [h : ∀ a b, subsingleton (φ ⟦a⟧ ⟦b⟧)]\n   (q₁ : quotient s₁) (q₂ : quotient s₂) (f : Π a₁ a₂, φ (quotient.mk' a₁) (quotient.mk' a₂)) :\n   φ q₁ q₂ :=\nquotient.rec_on_subsingleton₂ q₁ q₂ f\n\n/-- Recursion on a `quotient` argument `a`, result type depends on `⟦a⟧`. -/\nprotected def hrec_on' {φ : quotient s₁ → Sort*} (qa : quotient s₁) (f : Π a, φ (quotient.mk' a))\n  (c : ∀ a₁ a₂, a₁ ≈ a₂ → f a₁ == f a₂) : φ qa :=\nquot.hrec_on qa f c\n\n@[simp] \n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `⟦a⟧` and `⟦b⟧`. -/\nprotected def hrec_on₂' {φ : quotient s₁ → quotient s₂ → Sort*} (qa : quotient s₁)\n  (qb : quotient s₂) (f : ∀ a b, φ (quotient.mk' a) (quotient.mk' b))\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) : φ qa qb :=\nquotient.hrec_on₂ qa qb f c\n\n@[simp] lemma hrec_on₂'_mk' {φ : quotient s₁ → quotient s₂ → Sort*}\n  (f : ∀ a b, φ (quotient.mk' a) (quotient.mk' b))\n  (c : ∀ a₁ b₁ a₂ b₂, a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ == f a₂ b₂) (x : α) (qb : quotient s₂) :\n  (quotient.mk' x).hrec_on₂' qb f c = qb.hrec_on' (f x) (λ b₁ b₂, c _ _ _ _ (setoid.refl _)) :=\nrfl\n\n/-- Map a function `f : α → β` that sends equivalent elements to equivalent elements\nto a function `quotient sa → quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : α → β) (h : ((≈) ⇒ (≈)) f f) :\n  quotient s₁ → quotient s₂ :=\nquot.map f h\n\n@[simp] lemma map'_mk' (f : α → β) (h) (x : α) :\n  (quotient.mk' x : quotient s₁).map' f h = (quotient.mk' (f x) : quotient s₂) :=\nrfl\n\n/-- A version of `quotient.map₂` using curly braces and unification. -/\nprotected def map₂' (f : α → β → γ) (h : ((≈) ⇒ (≈) ⇒ (≈)) f f) :\n  quotient s₁ → quotient s₂ → quotient s₃ :=\nquotient.map₂ f h\n\n@[simp] lemma map₂'_mk' (f : α → β → γ) (h) (x : α) :\n  (quotient.mk' x : quotient s₁).map₂' f h =\n    (quotient.map' (f x) (h (setoid.refl x)) : quotient s₂ → quotient s₃) :=\nrfl\n\nlemma exact' {a b : α} :\n  (quotient.mk' a : quotient s₁) = quotient.mk' b → @setoid.r _ s₁ a b :=\nquotient.exact\n\nlemma sound' {a b : α} : @setoid.r _ s₁ a b → @quotient.mk' α s₁ a = quotient.mk' b :=\nquotient.sound\n\n@[simp]\nprotected lemma eq' {a b : α} : @quotient.mk' α s₁ a = quotient.mk' b ↔ @setoid.r _ s₁ a b :=\nquotient.eq\n\n/-- A version of `quotient.out` taking `{s₁ : setoid α}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : quotient s₁) : α := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s₁) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : α) : @setoid.r α s₁ (quotient.mk' a : quotient s₁).out' a :=\nquotient.exact (quotient.out_eq _)\n\nend quotient\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/data/quot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.45894104714166645}}
{"text": "/-\nCopyright (c) 2019 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n-/\nimport measure_theory.integral.lebesgue\n\n/-!\n# The Giry monad\n\nLet X be a measurable space. The collection of all measures on X again\nforms a measurable space. This construction forms a monad on\nmeasurable spaces and measurable functions, called the Giry monad.\n\nNote that most sources use the term \"Giry monad\" for the restriction\nto *probability* measures. Here we include all measures on X.\n\nSee also `measure_theory/category/Meas.lean`, containing an upgrade of the type-level\nmonad to an honest monad of the functor `Measure : Meas ⥤ Meas`.\n\n## References\n\n* <https://ncatlab.org/nlab/show/Giry+monad>\n\n## Tags\n\ngiry monad\n-/\n\nnoncomputable theory\nopen_locale classical big_operators ennreal\n\nopen classical set filter\n\nvariables {α β : Type*}\n\nnamespace measure_theory\n\nnamespace measure\n\nvariables [measurable_space α] [measurable_space β]\n\n/-- Measurability structure on `measure`: Measures are measurable w.r.t. all projections -/\ninstance : measurable_space (measure α) :=\n⨆ (s : set α) (hs : measurable_set s), (borel ℝ≥0∞).comap (λ μ, μ s)\n\nlemma measurable_coe {s : set α} (hs : measurable_set s) : measurable (λ μ : measure α, μ s) :=\nmeasurable.of_comap_le $ le_supr_of_le s $ le_supr_of_le hs $ le_rfl\n\nlemma measurable_of_measurable_coe (f : β → measure α)\n  (h : ∀ (s : set α) (hs : measurable_set s), measurable (λ b, f b s)) :\n  measurable f :=\nmeasurable.of_le_map $ supr₂_le $ assume s hs, measurable_space.comap_le_iff_le_map.2 $\n  by rw [measurable_space.map_comp]; exact h s hs\n\ninstance {α : Type*} {m : measurable_space α} : has_measurable_add₂ (measure α) :=\nbegin\n  refine ⟨measure.measurable_of_measurable_coe _ (λ s hs, _)⟩,\n  simp_rw [measure.coe_add, pi.add_apply],\n  refine measurable.add _ _,\n  { exact (measure.measurable_coe hs).comp measurable_fst, },\n  { exact (measure.measurable_coe hs).comp measurable_snd, },\nend\n\nlemma measurable_measure {μ : α → measure β} :\n  measurable μ ↔ ∀ (s : set β) (hs : measurable_set s), measurable (λ b, μ b s) :=\n⟨λ hμ s hs, (measurable_coe hs).comp hμ, measurable_of_measurable_coe μ⟩\n\nlemma measurable_map (f : α → β) (hf : measurable f) :\n  measurable (λ μ : measure α, map f μ) :=\nbegin\n  refine measurable_of_measurable_coe _ (λ s hs, _),\n  simp_rw map_apply hf hs,\n  exact measurable_coe (hf hs),\nend\n\nlemma measurable_dirac : measurable (measure.dirac : α → measure α) :=\nbegin\n  refine measurable_of_measurable_coe _ (λ s hs, _),\n  simp_rw [dirac_apply' _ hs],\n  exact measurable_one.indicator hs\nend\n\nlemma measurable_lintegral {f : α → ℝ≥0∞} (hf : measurable f) :\n  measurable (λ μ : measure α, ∫⁻ x, f x ∂μ) :=\nbegin\n  simp only [lintegral_eq_supr_eapprox_lintegral, hf, simple_func.lintegral],\n  refine measurable_supr (λ n, finset.measurable_sum _ (λ i _, _)),\n  refine measurable.const_mul _ _,\n  exact measurable_coe ((simple_func.eapprox f n).measurable_set_preimage _)\nend\n\n/-- Monadic join on `measure` in the category of measurable spaces and measurable\nfunctions. -/\ndef join (m : measure (measure α)) : measure α :=\nmeasure.of_measurable\n  (λ s hs, ∫⁻ μ, μ s ∂m)\n  (by simp only [measure_empty, lintegral_const, zero_mul])\n  begin\n    assume f hf h,\n    simp_rw [measure_Union h hf],\n    apply lintegral_tsum,\n    assume i, exact (measurable_coe (hf i)).ae_measurable\n  end\n\n@[simp] lemma join_apply {m : measure (measure α)} {s : set α} (hs : measurable_set s) :\n  join m s = ∫⁻ μ, μ s ∂m :=\nmeasure.of_measurable_apply s hs\n\n@[simp] lemma join_zero : (0 : measure (measure α)).join = 0 :=\nby { ext1 s hs, simp only [hs, join_apply, lintegral_zero_measure, coe_zero, pi.zero_apply], }\n\nlemma measurable_join : measurable (join : measure (measure α) → measure α) :=\nmeasurable_of_measurable_coe _ $ assume s hs,\n  by simp only [join_apply hs]; exact measurable_lintegral (measurable_coe hs)\n\nlemma lintegral_join {m : measure (measure α)} {f : α → ℝ≥0∞} (hf : measurable f) :\n  ∫⁻ x, f x ∂(join m) = ∫⁻ μ, ∫⁻ x, f x ∂μ ∂m :=\nbegin\n  simp_rw [lintegral_eq_supr_eapprox_lintegral hf,\n    simple_func.lintegral, join_apply (simple_func.measurable_set_preimage _ _)],\n  suffices : ∀ (s : ℕ → finset ℝ≥0∞) (f : ℕ → ℝ≥0∞ → measure α → ℝ≥0∞)\n    (hf : ∀ n r, measurable (f n r)) (hm : monotone (λ n μ, ∑ r in s n, r * f n r μ)),\n    (⨆ n, ∑ r in s n, r * ∫⁻ μ, f n r μ ∂m) = ∫⁻ μ, ⨆ n, ∑ r in s n, r * f n r μ ∂m,\n  { refine this (λ n, simple_func.range (simple_func.eapprox f n))\n      (λ n r μ, μ (simple_func.eapprox f n ⁻¹' {r})) _ _,\n    { exact λ n r, measurable_coe (simple_func.measurable_set_preimage _ _), },\n    { exact λ n m h μ, simple_func.lintegral_mono (simple_func.monotone_eapprox _ h) le_rfl, }, },\n  intros s f hf hm,\n  rw lintegral_supr _ hm,\n  swap, { exact λ n, finset.measurable_sum _ (λ r _, (hf _ _).const_mul _) },\n  congr,\n  funext n,\n  rw lintegral_finset_sum (s n),\n  { simp_rw lintegral_const_mul _ (hf _ _), },\n  { exact λ r _, (hf _ _).const_mul _ },\nend\n\n/-- Monadic bind on `measure`, only works in the category of measurable spaces and measurable\nfunctions. When the function `f` is not measurable the result is not well defined. -/\ndef bind (m : measure α) (f : α → measure β) : measure β := join (map f m)\n\n@[simp] lemma bind_zero_left (f : α → measure β) : bind 0 f = 0 :=\nby simp [bind]\n\n@[simp] lemma bind_zero_right (m : measure α) :\n  bind m (0 : α → measure β) = 0 :=\nbegin\n  ext1 s hs,\n  simp only [bind, hs, join_apply, coe_zero, pi.zero_apply],\n  rw [lintegral_map (measurable_coe hs) measurable_zero],\n  simp only [pi.zero_apply, coe_zero, lintegral_const, zero_mul],\nend\n\n@[simp] lemma bind_zero_right' (m : measure α) :\n  bind m (λ _, 0 : α → measure β) = 0 :=\nbind_zero_right m\n\n@[simp] lemma bind_apply {m : measure α} {f : α → measure β} {s : set β}\n  (hs : measurable_set s) (hf : measurable f) :\n  bind m f s = ∫⁻ a, f a s ∂m :=\nby rw [bind, join_apply hs, lintegral_map (measurable_coe hs) hf]\n\nlemma measurable_bind' {g : α → measure β} (hg : measurable g) : measurable (λ m, bind m g) :=\nmeasurable_join.comp (measurable_map _ hg)\n\nlemma lintegral_bind {m : measure α} {μ : α → measure β} {f : β → ℝ≥0∞}\n  (hμ : measurable μ) (hf : measurable f) :\n  ∫⁻ x, f x ∂ (bind m μ) = ∫⁻ a, ∫⁻ x, f x ∂(μ a) ∂m :=\n(lintegral_join hf).trans (lintegral_map (measurable_lintegral hf) hμ)\n\nlemma bind_bind {γ} [measurable_space γ] {m : measure α} {f : α → measure β} {g : β → measure γ}\n  (hf : measurable f) (hg : measurable g) :\n  bind (bind m f) g = bind m (λ a, bind (f a) g) :=\nbegin\n  ext1 s hs,\n  simp_rw [bind_apply hs hg, bind_apply hs ((measurable_bind' hg).comp hf),\n    lintegral_bind hf ((measurable_coe hs).comp hg), (bind_apply hs hg)],\nend\n\nlemma bind_dirac {f : α → measure β} (hf : measurable f) (a : α) : bind (dirac a) f = f a :=\nby { ext1 s hs, rw [bind_apply hs hf, lintegral_dirac' a ((measurable_coe hs).comp hf)], }\n\nlemma dirac_bind {m : measure α} : bind m dirac = m :=\nbegin\n  ext1 s hs,\n  simp only [bind_apply hs measurable_dirac, dirac_apply' _ hs, lintegral_indicator 1 hs,\n    pi.one_apply, lintegral_one, restrict_apply, measurable_set.univ, univ_inter],\nend\n\nlemma join_eq_bind (μ : measure (measure α)) : join μ = bind μ id :=\nby rw [bind, map_id]\n\nlemma join_map_map {f : α → β} (hf : measurable f) (μ : measure (measure α)) :\n  join (map (map f) μ) = map f (join μ) :=\nbegin\n  ext1 s hs,\n  rw [join_apply hs, map_apply hf hs, join_apply (hf hs),\n    lintegral_map (measurable_coe hs) (measurable_map f hf)],\n  simp_rw map_apply hf hs,\nend\n\nlemma join_map_join (μ : measure (measure (measure α))) :\n  join (map join μ) = join (join μ) :=\nbegin\n  show bind μ join = join (join μ),\n  rw [join_eq_bind, join_eq_bind, bind_bind measurable_id measurable_id],\n  apply congr_arg (bind μ),\n  funext ν,\n  exact join_eq_bind ν\nend\n\nlemma join_map_dirac (μ : measure α) : join (map dirac μ) = μ :=\ndirac_bind\n\nlemma join_dirac (μ : measure α) : join (dirac μ) = μ :=\n(join_eq_bind (dirac μ)).trans (bind_dirac measurable_id _)\n\nend measure\n\nend measure_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/measure_theory/measure/giry_monad.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.458941033140202}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel, Floris van Doorn, Mario Carneiro, Martin Dvorak\n-/\nimport data.list.big_operators.basic\n\n/-!\n# Join of a list of lists\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves basic properties of `list.join`, which concatenates a list of lists. It is defined\nin [`data.list.defs`](./defs).\n-/\n\nvariables {α β : Type*}\n\nnamespace list\n\nattribute [simp] join\n\n@[simp] lemma join_singleton (l : list α) : [l].join = l :=\nby rw [join, join, append_nil]\n\n@[simp] lemma join_eq_nil : ∀ {L : list (list α)}, join L = [] ↔ ∀ l ∈ L, l = []\n| []       := iff_of_true rfl (forall_mem_nil _)\n| (l :: L) := by simp only [join, append_eq_nil, join_eq_nil, forall_mem_cons]\n\n@[simp] lemma join_append (L₁ L₂ : list (list α)) : join (L₁ ++ L₂) = join L₁ ++ join L₂ :=\nby induction L₁; [refl, simp only [*, join, cons_append, append_assoc]]\n\nlemma join_concat (L : list (list α)) (l : list α) : join (L.concat l) = join L ++ l :=\nby simp\n\n@[simp] lemma join_filter_empty_eq_ff [decidable_pred (λ l : list α, l.empty = ff)] :\n  ∀ {L : list (list α)}, join (L.filter (λ l, l.empty = ff)) = L.join\n| []              := rfl\n| ([] :: L)       := by simp [@join_filter_empty_eq_ff L]\n| ((a :: l) :: L) := by simp [@join_filter_empty_eq_ff L]\n\n@[simp] lemma join_filter_ne_nil [decidable_pred (λ l : list α, l ≠ [])] {L : list (list α)} :\n  join (L.filter (λ l, l ≠ [])) = L.join :=\nby simp [join_filter_empty_eq_ff, ← empty_iff_eq_nil]\n\nlemma join_join (l : list (list (list α))) : l.join.join = (l.map join).join :=\nby { induction l, simp, simp [l_ih] }\n\n@[simp] lemma length_join (L : list (list α)) : length (join L) = sum (map length L) :=\nby induction L; [refl, simp only [*, join, map, sum_cons, length_append]]\n\n@[simp] lemma length_bind (l : list α) (f : α → list β) :\n  length (list.bind l f) = sum (map (length ∘ f) l) :=\nby rw [list.bind, length_join, map_map]\n\n@[simp] lemma bind_eq_nil {l : list α} {f : α → list β} :\n  list.bind l f = [] ↔ ∀ x ∈ l, f x = [] :=\njoin_eq_nil.trans $ by simp only [mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]\n\n/-- In a join, taking the first elements up to an index which is the sum of the lengths of the\nfirst `i` sublists, is the same as taking the join of the first `i` sublists. -/\nlemma take_sum_join (L : list (list α)) (i : ℕ) :\n  L.join.take ((L.map length).take i).sum = (L.take i).join :=\nbegin\n  induction L generalizing i, { simp },\n  cases i, { simp },\n  simp [take_append, L_ih]\nend\n\n/-- In a join, dropping all the elements up to an index which is the sum of the lengths of the\nfirst `i` sublists, is the same as taking the join after dropping the first `i` sublists. -/\nlemma drop_sum_join (L : list (list α)) (i : ℕ) :\n  L.join.drop ((L.map length).take i).sum = (L.drop i).join :=\nbegin\n  induction L generalizing i, { simp },\n  cases i, { simp },\n  simp [drop_append, L_ih],\nend\n\n/-- Taking only the first `i+1` elements in a list, and then dropping the first `i` ones, one is\nleft with a list of length `1` made of the `i`-th element of the original list. -/\nlemma drop_take_succ_eq_cons_nth_le (L : list α) {i : ℕ} (hi : i < L.length) :\n  (L.take (i+1)).drop i = [nth_le L i hi] :=\nbegin\n  induction L generalizing i,\n  { simp only [length] at hi, exact (nat.not_succ_le_zero i hi).elim },\n  cases i, { simp },\n  have : i < L_tl.length,\n  { simp at hi,\n    exact nat.lt_of_succ_lt_succ hi },\n  simp [L_ih this],\n  refl\nend\n\n/-- In a join of sublists, taking the slice between the indices `A` and `B - 1` gives back the\noriginal sublist of index `i` if `A` is the sum of the lenghts of sublists of index `< i`, and\n`B` is the sum of the lengths of sublists of index `≤ i`. -/\nlemma drop_take_succ_join_eq_nth_le (L : list (list α)) {i : ℕ} (hi : i < L.length) :\n  (L.join.take ((L.map length).take (i+1)).sum).drop ((L.map length).take i).sum = nth_le L i hi :=\nbegin\n  have : (L.map length).take i = ((L.take (i+1)).map length).take i, by simp [map_take, take_take],\n  simp [take_sum_join, this, drop_sum_join, drop_take_succ_eq_cons_nth_le _ hi]\nend\n\n/-- Auxiliary lemma to control elements in a join. -/\nlemma sum_take_map_length_lt1 (L : list (list α)) {i j : ℕ}\n  (hi : i < L.length) (hj : j < (nth_le L i hi).length) :\n  ((L.map length).take i).sum + j < ((L.map length).take (i+1)).sum :=\nby simp [hi, sum_take_succ, hj]\n\n/-- Auxiliary lemma to control elements in a join. -/\nlemma sum_take_map_length_lt2 (L : list (list α)) {i j : ℕ}\n  (hi : i < L.length) (hj : j < (nth_le L i hi).length) :\n  ((L.map length).take i).sum + j < L.join.length :=\nbegin\n  convert lt_of_lt_of_le (sum_take_map_length_lt1 L hi hj) (monotone_sum_take _ hi),\n  have : L.length = (L.map length).length, by simp,\n  simp [this, -length_map]\nend\n\n/-- The `n`-th element in a join of sublists is the `j`-th element of the `i`th sublist,\nwhere `n` can be obtained in terms of `i` and `j` by adding the lengths of all the sublists\nof index `< i`, and adding `j`. -/\nlemma nth_le_join (L : list (list α)) {i j : ℕ}\n  (hi : i < L.length) (hj : j < (nth_le L i hi).length) :\n  nth_le L.join (((L.map length).take i).sum + j) (sum_take_map_length_lt2 L hi hj) =\n  nth_le (nth_le L i hi) j hj :=\nby rw [nth_le_take L.join (sum_take_map_length_lt2 L hi hj) (sum_take_map_length_lt1 L hi hj),\n  nth_le_drop, nth_le_of_eq (drop_take_succ_join_eq_nth_le L hi)]\n\n/-- Two lists of sublists are equal iff their joins coincide, as well as the lengths of the\nsublists. -/\ntheorem eq_iff_join_eq (L L' : list (list α)) :\n  L = L' ↔ L.join = L'.join ∧ map length L = map length L' :=\nbegin\n  refine ⟨λ H, by simp [H], _⟩,\n  rintros ⟨join_eq, length_eq⟩,\n  apply ext_le,\n  { have : length (map length L) = length (map length L'), by rw length_eq,\n    simpa using this },\n  { assume n h₁ h₂,\n    rw [← drop_take_succ_join_eq_nth_le, ← drop_take_succ_join_eq_nth_le, join_eq, length_eq] }\nend\n\nlemma join_drop_length_sub_one {L : list (list α)} (h : L ≠ []) :\n  (L.drop (L.length - 1)).join = L.last h :=\nbegin\n  induction L using list.reverse_rec_on,\n  { cases h rfl },\n  { simp },\nend\n\n/-- We can rebracket `x ++ (l₁ ++ x) ++ (l₂ ++ x) ++ ... ++ (lₙ ++ x)` to\n`(x ++ l₁) ++ (x ++ l₂) ++ ... ++ (x ++ lₙ) ++ x` where `L = [l₁, l₂, ..., lₙ]`. -/\nlemma append_join_map_append (L : list (list α)) (x : list α) :\n  x ++ (list.map (λ l, l ++ x) L).join = (list.map (λ l, x ++ l) L).join ++ x :=\nbegin\n  induction L,\n  { rw [map_nil, join, append_nil, map_nil, join, nil_append] },\n  { rw [map_cons, join, map_cons, join, append_assoc, L_ih, append_assoc, append_assoc] },\nend\n\n/-- Reversing a join is the same as reversing the order of parts and reversing all parts. -/\nlemma reverse_join (L : list (list α)) :\n  L.join.reverse = (list.map list.reverse L).reverse.join :=\nbegin\n  induction L,\n  { refl },\n  { rw [join, reverse_append, L_ih, map_cons, reverse_cons', join_concat] },\nend\n\n/-- Joining a reverse is the same as reversing all parts and reversing the joined result. -/\nlemma join_reverse (L : list (list α)) :\n  L.reverse.join = (list.map list.reverse L).join.reverse :=\nby simpa [reverse_reverse] using congr_arg list.reverse (reverse_join L.reverse)\n\nend list\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/list/join.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.7461389873857264, "lm_q1q2_score": 0.4589410296680158}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Floris van Doorn, Mario Carneiro, Reid Barton, Johan Commelin\n-/\n\nimport Mathlib.Util.Tactic\nimport Mathlib.Logic.Function.Basic\n\n/-!\n# `choose` tactic\nPerforms Skolemization, that is, given `h : ∀ a:α, ∃ b:β, p a b |- G` produces\n`f : α → β, hf: ∀ a, p a (f a) |- G`.\n\nTODO: switch to `rcases` syntax: `choose ⟨i, j, h₁ -⟩ := expr`.\n-/\n\nopen Lean Meta Elab Tactic\n\nnamespace Mathlib.Tactic.Choose\n\n/-- Given `α : Sort u`, `nonemp : Nonempty α`, `p : α → Prop`, a context of free variables\n`ctx`, and a pair of an element `val : α` and `spec : p val`,\n`mk_sometimes u α nonemp p ctx (val, spec)` produces another pair `val', spec'`\nsuch that `val'` does not have any free variables from elements of `ctx` whose types are\npropositions. This is done by applying `Function.sometimes` to abstract over all the propositional\narguments. -/\ndef mk_sometimes (u : Level) (α nonemp p : Expr) :\n  List Expr → Expr × Expr → MetaM (Expr × Expr)\n| [], (val, spec) => pure (val, spec)\n| (e :: ctx), (val, spec) => do\n  let (val, spec) ← mk_sometimes u α nonemp p ctx (val, spec)\n  let t ← inferType e\n  let b ← isProp t\n  if b then do\n    let val' ← mkLambdaFVars #[e] val\n    pure\n      (mkApp4 (Expr.const ``Function.sometimes [Level.zero, u]) t α nonemp val',\n      mkApp7 (Expr.const ``Function.sometimes_spec [u]) t α nonemp p val' e spec)\n  else pure (val, spec)\n\n/-- Results of searching for nonempty instances,\nto eliminate dependencies on propositions (`choose!`).\n`success` means we found at least one instance;\n`failure ts` means we didn't find instances for any `t ∈ ts`.\n(`failure []` means we didn't look for instances at all.)\n\nRationale:\n`choose!` means we are expected to succeed at least once\nin eliminating dependencies on propositions.\n-/\ninductive ElimStatus\n| success\n| failure (ts : List Expr)\n\n/-- Combine two statuses, keeping a success from either side\nor merging the failures. -/\ndef ElimStatus.merge : ElimStatus → ElimStatus → ElimStatus\n| success, _ => success\n| _, success => success\n| failure ts₁, failure ts₂ => failure (ts₁ ++ ts₂)\n\n/-- `mkFreshNameFrom orig base` returns `mkFreshUserName base` if ``orig = `_``\nand `orig` otherwise. -/\ndef mkFreshNameFrom (orig base : Name) : CoreM Name :=\n  if orig = `_ then mkFreshUserName base else pure orig\n\n/-- Changes `(h : ∀xs, ∃a:α, p a) ⊢ g` to `(d : ∀xs, a) ⊢ (s : ∀xs, p (d xs)) → g` and\n`(h : ∀xs, p xs ∧ q xs) ⊢ g` to `(d : ∀xs, p xs) ⊢ (s : ∀xs, q xs) → g`.\n`choose1` returns a tuple of\n\n- the error result (see `ElimStatus`)\n- the data new free variable that was \"chosen\"\n- the new goal (which contains the spec of the data as domain of an arrow type)\n\nIf `nondep` is true and `α` is inhabited, then it will remove the dependency of `d` on\nall propositional assumptions in `xs`. For example if `ys` are propositions then\n`(h : ∀xs ys, ∃a:α, p a) ⊢ g` becomes `(d : ∀xs, a) (s : ∀xs ys, p (d xs)) ⊢ g`. -/\ndef choose1 (g : MVarId) (nondep : Bool) (h : Option Expr) (data : Name) :\n  MetaM (ElimStatus × Expr × MVarId) := do\n  let (g, h) ← match h with\n  | some e => pure (g, e)\n  | none   => do\n    let (e, g) ← g.intro1P\n    pure (g, .fvar e)\n  g.withContext do\n    let h ← instantiateMVars h\n    let t ← inferType h\n    forallTelescopeReducing t fun ctx t ↦ do\n      (← withTransparency .all (whnf t)).withApp fun\n      | .const ``Exists [u], #[α, p] => do\n        let data ← mkFreshNameFrom data ((← p.getBinderName).getD `h)\n        let ((neFail : ElimStatus), (nonemp : Option Expr)) ← if nondep then\n          let ne := (Expr.const ``Nonempty [u]).app α\n          let m ← mkFreshExprMVar ne\n          let mut g' := m.mvarId!\n          for e in ctx do\n            if (← isProof e) then continue\n            let ty ← whnf (← inferType e)\n            let nety := (Expr.const ``Nonempty [u]).app ty\n            let neval := mkApp2 (Expr.const ``Nonempty.intro [u]) ty e\n            g' ← g'.assert .anonymous nety neval\n          (_, g') ← g'.intros\n          g'.withContext do\n            match ← synthInstance? (← g'.getType) with\n            | some e => do\n              g'.assign e\n              let m ← instantiateMVars m\n              pure (.success, some m)\n            | none => pure (.failure [ne], none)\n        else pure (.failure [], none)\n        let ctx' ← if nonemp.isSome then ctx.filterM (not <$> isProof ·) else pure ctx\n        let dataTy ← mkForallFVars ctx' α\n        let mut dataVal := mkApp3 (.const ``Classical.choose [u]) α p (mkAppN h ctx)\n        let mut specVal := mkApp3 (.const ``Classical.choose_spec [u]) α p (mkAppN h ctx)\n        if let some nonemp := nonemp then\n          (dataVal, specVal) ← mk_sometimes u α nonemp p ctx.toList (dataVal, specVal)\n        dataVal ← mkLambdaFVars ctx' dataVal\n        specVal ← mkLambdaFVars ctx specVal\n        let (fvar, g) ← withLocalDeclD .anonymous dataTy fun d ↦ do\n          let specTy ← mkForallFVars ctx (p.app (mkAppN d ctx')).headBeta\n          g.withContext <| withLocalDeclD data dataTy fun d' ↦ do\n            let mvarTy ← mkArrow (specTy.replaceFVar d d') (← g.getType)\n            let newMVar ← mkFreshExprSyntheticOpaqueMVar mvarTy (← g.getTag)\n            g.assign <| mkApp2 (← mkLambdaFVars #[d'] newMVar) dataVal specVal\n            pure (d', newMVar.mvarId!)\n        let g ← match h with\n        | .fvar v => g.clear v\n        | _ => pure g\n        return (neFail, fvar, g)\n      | .const ``And _, #[p, q] => do\n        let data ← mkFreshNameFrom data `h\n        let e1 ← mkLambdaFVars ctx $ mkApp3 (.const ``And.left  []) p q (mkAppN h ctx)\n        let e2 ← mkLambdaFVars ctx $ mkApp3 (.const ``And.right []) p q (mkAppN h ctx)\n        let t1 ← inferType e1\n        let t2 ← inferType e2\n        let (fvar, g) ← (← (← g.assert .anonymous t2 e2).assert data t1 e1).intro1P\n        let g ← match h with\n        | .fvar v => g.clear v\n        | _ => pure g\n        return (.success, .fvar fvar, g)\n      -- TODO: support Σ, ×, or even any inductive type with 1 constructor ?\n      | _, _ => throwError \"expected a term of the shape `∀xs, ∃a, p xs a` or `∀xs, p xs ∧ q xs`\"\n\n/-- A wrapper around `choose1` that parses identifiers and adds variable info to new variables. -/\ndef choose1WithInfo (g : MVarId) (nondep : Bool) (h : Option Expr) (data : TSyntax ``binderIdent) :\n  TermElabM (ElimStatus × MVarId) := do\n  let n := if let `(binderIdent| $n:ident) := data then n.getId else `_\n  let (status, fvar, g) ← choose1 g nondep h n\n  g.withContext <| fvar.addLocalVarInfoForBinderIdent data\n  pure (status, g)\n\n/-- A loop around `choose1`. The main entry point for the `choose` tactic. -/\ndef elabChoose (nondep : Bool) (h : Option Expr) :\n  List (TSyntax ``binderIdent) → ElimStatus → MVarId → TermElabM MVarId\n| [], _, _ => throwError \"expect list of variables\"\n| [n], status, g =>\n  match nondep, status with\n  | true, .failure tys => do -- We expected some elimination, but it didn't happen.\n    let mut msg := m!\"choose!: failed to synthesize any nonempty instances\"\n    for ty in tys do\n      msg := msg ++ m!\"{(← mkFreshExprMVar ty).mvarId!}\"\n    throwError msg\n  | _, _ => do\n    let (fvar, g) ← match n with\n    | `(binderIdent| $n:ident) => g.intro n.getId\n    | _ => g.intro1\n    g.withContext <| (Expr.fvar fvar).addLocalVarInfoForBinderIdent n\n    return g\n| n::ns, status, g => do\n  let (status', g) ← choose1WithInfo g nondep h n\n  elabChoose nondep none ns (status.merge status') g\n\n/--\n* `choose a b h h' using hyp` takes a hypothesis `hyp` of the form\n  `∀ (x : X) (y : Y), ∃ (a : A) (b : B), P x y a b ∧ Q x y a b`\n  for some `P Q : X → Y → A → B → Prop` and outputs\n  into context a function `a : X → Y → A`, `b : X → Y → B` and two assumptions:\n  `h : ∀ (x : X) (y : Y), P x y (a x y) (b x y)` and\n  `h' : ∀ (x : X) (y : Y), Q x y (a x y) (b x y)`. It also works with dependent versions.\n\n* `choose! a b h h' using hyp` does the same, except that it will remove dependency of\n  the functions on propositional arguments if possible. For example if `Y` is a proposition\n  and `A` and `B` are nonempty in the above example then we will instead get\n  `a : X → A`, `b : X → B`, and the assumptions\n  `h : ∀ (x : X) (y : Y), P x y (a x) (b x)` and\n  `h' : ∀ (x : X) (y : Y), Q x y (a x) (b x)`.\n\nThe `using hyp` part can be ommited,\nwhich will effectively cause `choose` to start with an `intro hyp`.\n\nExamples:\n\n```\nexample (h : ∀ n m : ℕ, ∃ i j, m = n + i ∨ m + j = n) : True := by\n  choose i j h using h\n  guard_hyp i : ℕ → ℕ → ℕ\n  guard_hyp j : ℕ → ℕ → ℕ\n  guard_hyp h : ∀ (n m : ℕ), m = n + i n m ∨ m + j n m = n\n  trivial\n```\n\n```\nexample (h : ∀ i : ℕ, i < 7 → ∃ j, i < j ∧ j < i+i) : True := by\n  choose! f h h' using h\n  guard_hyp f : ℕ → ℕ\n  guard_hyp h : ∀ (i : ℕ), i < 7 → i < f i\n  guard_hyp h' : ∀ (i : ℕ), i < 7 → f i < i + i\n  trivial\n```\n-/\nsyntax (name := choose) \"choose\" \"!\"? (colGt binderIdent)+ (\" using \" term)? : tactic\nelab_rules : tactic\n| `(tactic| choose $[!%$b]? $[$ids]* $[using $h]?) => withMainContext do\n  let h ← h.mapM (Elab.Tactic.elabTerm · none)\n  let g ← elabChoose b.isSome h ids.toList (.failure []) (← getMainGoal)\n  replaceMainGoal [g]\n\n@[inherit_doc choose]\nsyntax \"choose!\" (colGt binderIdent)+ (\" using \" term)? : tactic\nmacro_rules\n  | `(tactic| choose! $[$ids]* $[using $h]?) => `(tactic| choose ! $[$ids]* $[using $h]?)\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Tactic/Choose.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4589410261958296}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Stephen Morgan, Scott Morrison, Floris van Doorn\n\n! This file was ported from Lean 3 source module category_theory.discrete_category\n! leanprover-community/mathlib commit 369525b73f229ccd76a6ec0e0e0bf2be57599768\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.EqToHom\nimport Mathlib.Data.ULift\nimport Mathlib.Tactic.CasesM\n\n/-!\n# Discrete categories\n\nWe define `Discrete α` as a structure containing a term `a : α` for any type `α`,\nand use this type alias to provide a `SmallCategory` instance\nwhose only morphisms are the identities.\n\nThere is an annoying technical difficulty that it has turned out to be inconvenient\nto allow categories with morphisms living in `Prop`,\nso instead of defining `X ⟶ Y` in `Discrete α` as `X = Y`,\none might define it as `PLift (X = Y)`.\nIn fact, to allow `Discrete α` to be a `SmallCategory`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X ⟶ Y` as `ULift (PLift (X = Y))`.\n\n`Discrete.functor` promotes a function `f : I → C` (for any category `C`) to a functor\n`Discrete.functor f : Discrete I ⥤ C`.\n\nSimilarly, `Discrete.natTrans` and `Discrete.natIso` promote `I`-indexed families of morphisms,\nor `I`-indexed families of isomorphisms to natural transformations or natural isomorphism.\n\nWe show equivalences of types are the same as (categorical) equivalences of the corresponding\ndiscrete categories.\n-/\n\nnamespace CategoryTheory\n\n-- morphism levels before object levels. See note [CategoryTheory universes].\nuniverse v₁ v₂ v₃ u₁ u₁' u₂ u₃\n\n-- This is intentionally a structure rather than a type synonym\n-- to enforce using `DiscreteEquiv` (or `Discrete.mk` and `Discrete.as`) to move between\n-- `Discrete α` and `α`. Otherwise there is too much API leakage.\n/-- A wrapper for promoting any type to a category,\nwith the only morphisms being equalities.\n-/\n@[ext]\nstructure Discrete (α : Type u₁) where\n  /-- A wrapper for promoting any type to a category,\n  with the only morphisms being equalities.\n  -/\n  as : α\n#align category_theory.discrete CategoryTheory.Discrete\n\n@[simp]\ntheorem Discrete.mk_as {α : Type u₁} (X : Discrete α) : Discrete.mk X.as = X := by\n  ext\n  rfl\n#align category_theory.discrete.mk_as CategoryTheory.Discrete.mk_as\n\n/-- `Discrete α` is equivalent to the original type `α`.-/\n@[simps]\ndef discreteEquiv {α : Type u₁} : Discrete α ≃ α where\n  toFun := Discrete.as\n  invFun := Discrete.mk\n  left_inv := by aesop_cat\n  right_inv := by aesop_cat\n#align category_theory.discrete_equiv CategoryTheory.discreteEquiv\n\ninstance {α : Type u₁} [DecidableEq α] : DecidableEq (Discrete α) :=\n  discreteEquiv.decidableEq\n\n/-- The \"Discrete\" category on a type, whose morphisms are equalities.\n\nBecause we do not allow morphisms in `Prop` (only in `Type`),\nsomewhat annoyingly we have to define `X ⟶ Y` as `ULift (PLift (X = Y))`.\n\nSee <https://stacks.math.columbia.edu/tag/001A>\n-/\ninstance discreteCategory (α : Type u₁) : SmallCategory (Discrete α) where\n  Hom X Y := ULift (PLift (X.as = Y.as))\n  id X := ULift.up (PLift.up rfl)\n  comp {X Y Z} g f := by\n    cases X\n    cases Y\n    cases Z\n    rcases f with ⟨⟨⟨⟩⟩⟩\n    exact g\n#align category_theory.discrete_category CategoryTheory.discreteCategory\n\nnamespace Discrete\n\nvariable {α : Type u₁}\n\ninstance [Inhabited α] : Inhabited (Discrete α) :=\n  ⟨⟨default⟩⟩\n\ninstance [Subsingleton α] : Subsingleton (Discrete α) :=\n  ⟨by\n    intros\n    ext\n    apply Subsingleton.elim⟩\n\ninstance (X Y : Discrete α) : Subsingleton (X ⟶ Y) :=\n  show Subsingleton (ULift (PLift _)) from inferInstance\n\n/-\nPorting note: It seems that `aesop` currently has no way to add lemmas locally.\n\nattribute [local tidy] tactic.discrete_cases\n`[cases_matching* [discrete _, (_ : discrete _) ⟶ (_ : discrete _), PLift _]]\n-/\n\n/- Porting note: rewrote `discrete_cases` tactic -/\n/-- A simple tactic to run `cases` on any `discrete α` hypotheses. -/\nmacro \"discrete_cases\": tactic =>\n  `(tactic|casesm* Discrete _, (_ : Discrete _) ⟶ (_ : Discrete _), PLift _)\n\ninstance [Unique α] : Unique (Discrete α) :=\n  Unique.mk' (Discrete α)\n\n/-- Extract the equation from a morphism in a discrete category. -/\ntheorem eq_of_hom {X Y : Discrete α} (i : X ⟶ Y) : X.as = Y.as :=\n  i.down.down\n#align category_theory.discrete.eq_of_hom CategoryTheory.Discrete.eq_of_hom\n\n/-- Promote an equation between the wrapped terms in `X Y : Discrete α` to a morphism `X ⟶ Y`\nin the discrete category. -/\nprotected abbrev eqToHom {X Y : Discrete α} (h : X.as = Y.as) : X ⟶ Y :=\n  eqToHom\n    (by\n      ext\n      exact h)\n#align category_theory.discrete.eq_to_hom CategoryTheory.Discrete.eqToHom\n\n/-- Promote an equation between the wrapped terms in `X Y : Discrete α` to an isomorphism `X ≅ Y`\nin the discrete category. -/\nprotected abbrev eqToIso {X Y : Discrete α} (h : X.as = Y.as) : X ≅ Y :=\n  eqToIso\n    (by\n      ext\n      exact h)\n#align category_theory.discrete.eq_to_iso CategoryTheory.Discrete.eqToIso\n\n/-- A variant of `eqToHom` that lifts terms to the discrete category. -/\nabbrev eqToHom' {a b : α} (h : a = b) : Discrete.mk a ⟶ Discrete.mk b :=\n  Discrete.eqToHom h\n#align category_theory.discrete.eq_to_hom' CategoryTheory.Discrete.eqToHom'\n\n/-- A variant of `eqToIso` that lifts terms to the discrete category. -/\nabbrev eqToIso' {a b : α} (h : a = b) : Discrete.mk a ≅ Discrete.mk b :=\n  Discrete.eqToIso h\n#align category_theory.discrete.eq_to_iso' CategoryTheory.Discrete.eqToIso'\n\n@[simp]\ntheorem id_def (X : Discrete α) : ULift.up (PLift.up (Eq.refl X.as)) = 𝟙 X :=\n  rfl\n#align category_theory.discrete.id_def CategoryTheory.Discrete.id_def\n\nvariable {C : Type u₂} [Category.{v₂} C]\n\ninstance {I : Type u₁} {i j : Discrete I} (f : i ⟶ j) : IsIso f :=\n  ⟨⟨Discrete.eqToHom (eq_of_hom f).symm, by aesop_cat⟩⟩\n\n/-- Any function `I → C` gives a functor `Discrete I ⥤ C`.-/\ndef functor {I : Type u₁} (F : I → C) : Discrete I ⥤ C where\n  obj := F ∘ Discrete.as\n  map {X Y} f := by\n    dsimp\n    rcases f with ⟨⟨h⟩⟩\n    exact eqToHom (congrArg _ h)\n  map_id := by aesop_cat\n  map_comp := fun {X Y Z} f g => by\n    discrete_cases\n    aesop_cat\n#align category_theory.discrete.functor CategoryTheory.Discrete.functor\n\n@[simp]\ntheorem functor_obj {I : Type u₁} (F : I → C) (i : I) :\n    (Discrete.functor F).obj (Discrete.mk i) = F i :=\n  rfl\n#align category_theory.discrete.functor_obj CategoryTheory.Discrete.functor_obj\n\ntheorem functor_map {I : Type u₁} (F : I → C) {i : Discrete I} (f : i ⟶ i) :\n    (Discrete.functor F).map f = 𝟙 (F i.as) := by aesop_cat\n#align category_theory.discrete.functor_map CategoryTheory.Discrete.functor_map\n\n/-- The discrete functor induced by a composition of maps can be written as a\ncomposition of two discrete functors.\n-/\n@[simps!]\ndef functorComp {I : Type u₁} {J : Type u₁'} (f : J → C) (g : I → J) :\n    Discrete.functor (f ∘ g) ≅ Discrete.functor (Discrete.mk ∘ g) ⋙ Discrete.functor f :=\n  NatIso.ofComponents (fun X => Iso.refl _) (by aesop_cat)\n#align category_theory.discrete.functor_comp CategoryTheory.Discrete.functorComp\n\n/-- For functors out of a discrete category,\na natural transformation is just a collection of maps,\nas the naturality squares are trivial.\n-/\n@[simps]\ndef natTrans {I : Type u₁} {F G : Discrete I ⥤ C} (f : ∀ i : Discrete I, F.obj i ⟶ G.obj i) : F ⟶ G\n    where\n  app := f\n  naturality := fun {X Y} ⟨⟨g⟩⟩ => by\n    discrete_cases\n    rcases g\n    change F.map (𝟙 _) ≫ _ = _ ≫ G.map (𝟙 _)\n    simp\n#align category_theory.discrete.nat_trans CategoryTheory.Discrete.natTrans\n\n/-- For functors out of a discrete category,\na natural isomorphism is just a collection of isomorphisms,\nas the naturality squares are trivial.\n-/\n@[simps!]\ndef natIso {I : Type u₁} {F G : Discrete I ⥤ C} (f : ∀ i : Discrete I, F.obj i ≅ G.obj i) : F ≅ G :=\n  NatIso.ofComponents f fun ⟨⟨g⟩⟩ => by\n    discrete_cases\n    rcases g\n    change F.map (𝟙 _) ≫ _ = _ ≫ G.map (𝟙 _)\n    simp\n#align category_theory.discrete.nat_iso CategoryTheory.Discrete.natIso\n\n@[simp]\ntheorem natIso_app {I : Type u₁} {F G : Discrete I ⥤ C} (f : ∀ i : Discrete I, F.obj i ≅ G.obj i)\n    (i : Discrete I) : (Discrete.natIso f).app i = f i := by aesop_cat\n#align category_theory.discrete.nat_iso_app CategoryTheory.Discrete.natIso_app\n\n/-- Every functor `F` from a discrete category is naturally isomorphic (actually, equal) to\n  `discrete.functor (F.obj)`. -/\n@[simp]\ndef natIsoFunctor {I : Type u₁} {F : Discrete I ⥤ C} : F ≅ Discrete.functor (F.obj ∘ Discrete.mk) :=\n  natIso fun _ => Iso.refl _\n#align category_theory.discrete.nat_iso_functor CategoryTheory.Discrete.natIsoFunctor\n\n/-- Composing `discrete.functor F` with another functor `G` amounts to composing `F` with `G.obj` -/\n@[simp]\ndef compNatIsoDiscrete {I : Type u₁} {D : Type u₃} [Category.{v₃} D] (F : I → C) (G : C ⥤ D) :\n    Discrete.functor F ⋙ G ≅ Discrete.functor (G.obj ∘ F) :=\n  natIso fun _ => Iso.refl _\n#align category_theory.discrete.comp_nat_iso_discrete CategoryTheory.Discrete.compNatIsoDiscrete\n\n/-- We can promote a type-level `Equiv` to\nan equivalence between the corresponding `discrete` categories.\n-/\n@[simps]\ndef equivalence {I : Type u₁} {J : Type u₂} (e : I ≃ J) : Discrete I ≌ Discrete J where\n  functor := Discrete.functor (Discrete.mk ∘ (e : I → J))\n  inverse := Discrete.functor (Discrete.mk ∘ (e.symm : J → I))\n  unitIso :=\n    Discrete.natIso fun i =>\n      eqToIso\n        (by\n          discrete_cases\n          simp)\n  counitIso :=\n    Discrete.natIso fun j =>\n      eqToIso\n        (by\n          discrete_cases\n          simp)\n#align category_theory.discrete.equivalence CategoryTheory.Discrete.equivalence\n\n/-- We can convert an equivalence of `discrete` categories to a type-level `Equiv`. -/\n@[simps]\ndef equivOfEquivalence {α : Type u₁} {β : Type u₂} (h : Discrete α ≌ Discrete β) : α ≃ β where\n  toFun := Discrete.as ∘ h.functor.obj ∘ Discrete.mk\n  invFun := Discrete.as ∘ h.inverse.obj ∘ Discrete.mk\n  left_inv a := by simpa using eq_of_hom (h.unitIso.app (Discrete.mk a)).2\n  right_inv a := by simpa using eq_of_hom (h.counitIso.app (Discrete.mk a)).1\n#align category_theory.discrete.equiv_of_equivalence CategoryTheory.Discrete.equivOfEquivalence\n\nend Discrete\n\nnamespace Discrete\n\nvariable {J : Type v₁}\n\nopen Opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\n@[simps! functor_obj_as inverse_obj]\nprotected def opposite (α : Type u₁) : (Discrete α)ᵒᵖ ≌ Discrete α :=\n  let F : Discrete α ⥤ (Discrete α)ᵒᵖ := Discrete.functor fun x => op (Discrete.mk x)\n  Equivalence.mk F.leftOp F\n  (NatIso.ofComponents (fun ⟨X⟩ => Iso.refl _) <| fun {X Y} ⟨⟨f⟩⟩ => by\n      induction X using Opposite.rec\n      induction Y using Opposite.rec\n      discrete_cases\n      rcases f\n      aesop_cat)\n  (Discrete.natIso <| fun ⟨X⟩ => Iso.refl _)\n\n/-\n  Porting note:\n  The following is what was generated by mathport:\n\n  refine'\n    Equivalence.mk (F.leftOp) F _\n      (Discrete.natIso fun X =>\n        by\n          discrete_cases\n          rfl)\n  refine'\n    NatIso.ofComponents\n      (fun X =>\n        by\n        discrete_cases\n        induction X using Opposite.rec\n        discrete_cases\n        exact Iso.refl _)\n-/\n\n#align category_theory.discrete.opposite CategoryTheory.Discrete.opposite\n\nvariable {C : Type u₂} [Category.{v₂} C]\n\n@[simp]\ntheorem functor_map_id (F : Discrete J ⥤ C) {j : Discrete J} (f : j ⟶ j) : F.map f = 𝟙 (F.obj j) :=\n  by\n  have h : f = 𝟙 j := by\n    rcases f with ⟨⟨f⟩⟩\n    rfl\n  rw [h]\n  simp\n#align category_theory.discrete.functor_map_id CategoryTheory.Discrete.functor_map_id\n\nend Discrete\n\nend CategoryTheory\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/DiscreteCategory.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4589159631540297}}
{"text": "import lib.list.defs\n\nvariables {α : Type*} {R : α → α → α → Prop}\n\nnamespace list\n\ntheorem chain3_split {a b c d : α} {l1 l2 : list α} : \n  chain3 R a b (l1 ++ c :: d :: l2) ↔\n  chain3 R a b (l1 ++ [c, d]) ∧ chain3 R c d l2 := \nby induction l1 with x l1 IH generalizing a b;\n  simp only [*, nil_append, cons_append, chain3.nil, chain3_cons, and_true, and_assoc]\n\n@[simp] theorem chain3_append_cons3 {a b c d e : α} {l1 l2 : list α} :\n  chain3 R a b (l1 ++ c :: d :: e :: l2) ↔ \n  chain3 R a b (l1 ++ [c, d]) ∧ R c d e ∧ \n  chain3 R d e l2 := \nby rw [chain3_split, chain3_cons]\n\n@[simp] theorem chain3'_nil : chain3' R [] := trivial\n\n@[simp] theorem chain3'_singleton (a : α) : chain3' R [a] := trivial\n\n@[simp] theorem chain3'_pair (a b : α) : chain3' R [a, b] := chain3.nil\n\n@[simp] theorem chain3'_cons {x y z l} : \n  chain3' R (x :: y :: z :: l) ↔ R x y z ∧ chain3' R (y :: z :: l) := \nchain3_cons \n\ntheorem chain3'_split {a b : α}: ∀ {l1 l2 : list α},\n  chain3' R (l1 ++ a :: b :: l2) ↔\n  chain3' R (l1 ++ [a, b]) ∧ chain3' R (a :: b :: l2)\n| [] l2 := (and_iff_right (chain3'_pair a b)).symm\n| [c] l2 := by simp -- todo\n| (c :: d :: l1) l2 := chain3_split \n\n@[simp] theorem chain3'_append_cons3 {a b c : α} {l1 l2 : list α} :\n  chain3' R (l1 ++ a :: b :: c :: l2) ↔\n  chain3' R (l1 ++ [a, b]) ∧ R a b c ∧\n  chain3' R (b :: c :: l2) :=\nby rw [chain3'_split, chain3'_cons]\n\ntheorem chain3'.left_of_append {l1 l2 : list α}\n  (h : chain3' R (l1 ++ l2)) : chain3' R l1 :=\nbegin\n  induction l1 with a l1 ih, simp,\n  cases l1 with b l1, simp,\n  cases l1 with c l1, simp,\n  simp at ⊢ h, tauto,\nend\n\ntheorem chain3'.right_of_append {l1 l2 : list α}\n  (h : chain3' R (l1 ++ l2)) : chain3' R l2 :=\nbegin\n  revert l2,\n  induction l1 with a l1 ih, intros l2 h', exact h',\n  intros l2 h', \n  cases l1 with b l1,\n  { cases l2 with c l2, simp,\n    cases l2 with d l2, simp,\n    simp at h', exact h'.right, },\n  cases l1 with c l1,\n  { cases l2 with d l2, simp,\n    cases l2 with e l2, simp,\n    simp at h', exact h'.right.right, },\n  apply ih, simp at ⊢ h', exact h'.right,\nend\n\ntheorem chain3'.infix {l₁ l : list α } \n  (h : chain3' R l) (h' : l₁ <:+: l) : chain3' R l₁ :=\nby { rcases h' with ⟨l₂, l₃, rfl⟩, exact h.left_of_append.right_of_append }\n\ntheorem chain3'.suffix \n  {l₁ l : list α} (h : chain3' R l) (h' : l₁ <:+ l) : chain3' R l₁ := \n  h.infix h'.is_infix\n\ntheorem chain3'.prefix \n  {l₁ l : list α} (h : chain3' R l) (h' : l₁ <+: l) : chain3' R l₁ := \n  h.infix h'.is_infix\n\ntheorem chain3'.drop \n  {l : list α} (h : chain3' R l) (n : ℕ) : chain3' R (drop n l) := \n  h.suffix (drop_suffix _ _)\n\ntheorem chain3'.init \n  {l : list α} (h : chain3' R l) : chain3' R l.init := \n  h.prefix l.init_prefix\n\ntheorem chain3'.take \n  {l : list α} (h : chain3' R l) (n : ℕ) : chain3' R (take n l) := \n  h.prefix (take_prefix _ _)\n\ntheorem chain3'.tail \n  {l : list α} (h : chain3' R l) : chain3' R l.tail :=\nbegin\n  cases l with a l, simp, \n  cases l with b l, simp,\n  cases l with c l, simp,\n  simp at ⊢ h, exact h.right,\nend \n\ntheorem chain3'_mirror [linear_order α] {l : list α} : \n  chain3' (mirror3 R) l.mirror ↔ chain3' R l :=\nbegin\n  induction l with a l ih, simp,\n  cases l with b l, simp,\n  cases l with c l, \n  rw list.mirror, simp, \n  rw list.mirror, simp, \n  simp [list.mirror] at ih, rw ←ih,\n  rw mirror3, simp, exact and.comm\nend\n\nend list", "meta": {"author": "jcpaik", "repo": "erdos-tuza-valtr", "sha": "7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef", "save_path": "github-repos/lean/jcpaik-erdos-tuza-valtr", "path": "github-repos/lean/jcpaik-erdos-tuza-valtr/erdos-tuza-valtr-7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef/src/lib/list/chain3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.4589159586725886}}
{"text": "import tactic\n\nuniverses u\n\n@[notation_class] class has_succ (α : Sort*) := (succ : α → α)\n\nprefix `Succ `:85 := has_succ.succ\n\ndef numeral {α : Type*} [has_zero α] [has_succ α] : ℕ → α\n| 0       := 0\n| (n + 1) := Succ (numeral n)\n\ninstance numeral_has_one {α : Type*} [has_zero α] [has_succ α] : has_one α := ⟨Succ 0⟩\n\nlemma numeral_one_def  {α : Type*} [has_zero α] [has_succ α] : (1 : α) = Succ 0 := rfl \n\n@[notation_class] class has_eq (α : out_param (Sort*)) (β : Sort*) := (eq : α → α → β)\n\n@[notation_class] class has_prec (α : out_param (Sort*)) (β : Sort*) := (prec : α → α → β)\n\n@[notation_class] class has_preceq (α : out_param (Sort*)) (β : Sort*) := (preceq : α → α → β)\n\n@[notation_class] class has_elem (α : out_param (Sort*)) (β : Sort*) := (elem : α → α → β)\n\n@[notation_class] class has_negation (α : Sort*) := (neg : α → α)\n\n@[notation_class] class has_arrow (α : Sort*) := (arrow : α → α → α)\n\n@[notation_class] class has_univ_quantifier (α : Sort*) := (univ : α → α)\n\n@[notation_class] class has_exists_quantifier (α : Sort*) := (ex : α → α)\n\n@[notation_class] class has_univ_quantifier' (α : ℕ → Sort*) := (univ : Π {n}, α (n + 1) → α n)\n\n@[notation_class] class has_exists_quantifier' (α : ℕ → Sort*) := (ex : Π {n}, α (n + 1) → α n)\n\nlocalized \"infix (name := has_eq.eq) ` =' `:50 := has_eq.eq\" in logic_symbol\nlocalized \"infix (name := has_prec.prec) ` ≺ `:50 := has_prec.prec\" in logic_symbol\nlocalized \"infix (name := has_preceq.preceq) ` ≼ `:50 := has_preceq.preceq\" in logic_symbol\nlocalized \"infix (name := has_elem.elem) ` ∊ `:50 := has_elem.elem\" in logic_symbol\nlocalized \"prefix (name := has_negation.neg) `∼`:75 := has_negation.neg\" in logic_symbol\nlocalized \"infixr (name := has_arrow.arrow) ` ⟶ `:60 := has_arrow.arrow\" in logic_symbol\nlocalized \"prefix (name := has_univ_quantifier.univ) `∀.`:64 := has_univ_quantifier.univ\" in logic_symbol\nlocalized \"prefix (name := has_exists_quantifier.ex) `∃.`:64 := has_exists_quantifier.ex\" in logic_symbol\nlocalized \"prefix (name := has_univ_quantifier'.univ) `∀'`:64 := has_univ_quantifier'.univ\" in logic_symbol\nlocalized \"prefix (name := has_exists_quantifier'.ex) `∃'`:64 := has_exists_quantifier'.ex\" in logic_symbol\nopen_locale logic_symbol\n\nsection has_univ_quantifier'\nvariables  {α : ℕ → Sort*} [has_univ_quantifier' α]\n\ndef nforall {n} : Π (k), α (n + k) → α n\n| 0     a := a\n| (k+1) a := nforall _ ∀'a\n\n@[simp] def universal_closure : Π {n}, α n → α 0\n| 0     a := a\n| (k+1) a := universal_closure ∀'a\n\nlocalized \"notation (name := universal_closure) `∀'*`:64 := universal_closure\" in logic_symbol\n\nend has_univ_quantifier'\n\nsection has_exists_quantifier'\nvariables {α : ℕ → Sort*} [has_exists_quantifier' α]\n\ndef nexists {n} : Π (k), α (n + k) → α n\n| 0     a := a\n| (k+1) a := nexists _ ∃'a\n\n@[simp] def exists_close : Π {n}, α n → α 0\n| 0     a := a\n| (k+1) a := exists_close ∃'a\n\nlocalized \"notation (name := exists_close) `∃'*`:64 := exists_close\" in logic_symbol\n\nend has_exists_quantifier'\n\n@[reducible] def has_eq.ineq {α : out_param (Sort*)} {β : Sort*}\n  [has_eq α β] [has_negation β] (a b : α) : β := ∼(a =' b)\n\nlocalized \"infix (name := has_eq.ineq) ` ≠' `:50 := has_eq.ineq\" in logic_symbol\n\n@[notation_class] class has_turnstile (α : Sort*) := (turnstile : set α → α → Prop)\n\ninfix ` ⊢ `:45 := has_turnstile.turnstile\nnotation T ` ⊢{`:45 β `} `:45 p := has_turnstile.turnstile T β p\n\nnamespace has_turnstile\nvariables {α : Type*} [has_turnstile α]\n\ndef turnstile_set (T : set α) (Γ : set α) : Prop := ∀ p ∈ Γ, T ⊢ p\n\ninfix ` ⊢* `:45 := turnstile_set\n\nend has_turnstile\n\n@[notation_class] class has_Longarrow (α : Sort*) := (Longarrow : set α → α → Type u)\n\ninfix ` ⟹ `:45 := has_Longarrow.Longarrow\n\ndef has_arrow.lrarrow {α : Type*} [has_arrow α] [has_inf α] (a b : α) : α := (a ⟶ b) ⊓ (b ⟶ a)\n\nlocalized \"infix (name := has_arrow.lrarrow) ` ⟷ `:59 := has_arrow.lrarrow\" in logic_symbol\n\nlemma lrarrow_def {α : Type*} [has_arrow α] [has_inf α] (a b : α) : a ⟷ b = (a ⟶ b) ⊓ (b ⟶ a) := rfl\n\n@[notation_class] class has_double_turnstile (α : Sort*) (β : Sort*) := (double_turnstile : α → β → Prop)\n\ninfix ` ⊧ ` :55 := has_double_turnstile.double_turnstile\n\nnamespace has_double_turnstile\nvariables {α : Type*} {β : Type*} [has_double_turnstile α β]\n\ndef double_turnstile_set (T : α) (S : set β) : Prop := ∀ p ∈ S, T ⊧ p\n\ninfix ` ⊧* `:45 := double_turnstile_set\n\nend has_double_turnstile\n\nclass has_logic_symbol (F : Sort*)\n  extends has_negation F, has_arrow F, has_inf F, has_sup F, has_top F, has_bot F\n\nsection \nvariables (F : Type*) (top : F) (neg : F → F) (imply : F → F → F)\n\ndef logic_simbol_default (F : Type*) (top : F) (neg : F → F) (imply : F → F → F) : has_logic_symbol F :=\n{ bot := neg top,\n  top := top,\n  sup := λ p q, imply (neg p) q,\n  inf := λ p q, neg (imply p (neg q)),\n  arrow := imply,\n  neg := neg }\n\nlemma default_bot_def :\n  @has_bot.bot F (@has_logic_symbol.to_has_bot F (logic_simbol_default F top neg imply)) =\n  @has_negation.neg F (@has_logic_symbol.to_has_negation F (logic_simbol_default F top neg imply))\n    (@has_top.top F (@has_logic_symbol.to_has_top F (logic_simbol_default F top neg imply))) := rfl\n\nlemma default_top_def :\n  @has_top.top F (@has_logic_symbol.to_has_top F (logic_simbol_default F top neg imply)) = top := rfl\n\nlemma default_or_def (p q : F) :\n  @has_sup.sup F (@has_logic_symbol.to_has_sup F (logic_simbol_default F top neg imply)) p q =\n  @has_arrow.arrow F (@has_logic_symbol.to_has_arrow F (logic_simbol_default F top neg imply))\n    (@has_negation.neg F (@has_logic_symbol.to_has_negation F (logic_simbol_default F top neg imply)) p) q := rfl\n\nlemma default_and_def (p q : F) :\n  @has_inf.inf F (@has_logic_symbol.to_has_inf F (logic_simbol_default F top neg imply)) p q =\n  @has_negation.neg F (@has_logic_symbol.to_has_negation F (logic_simbol_default F top neg imply))\n    (@has_arrow.arrow F (@has_logic_symbol.to_has_arrow F (logic_simbol_default F top neg imply))\n      p (@has_negation.neg F (@has_logic_symbol.to_has_negation F (logic_simbol_default F top neg imply)) q)) := rfl\n\nlemma default_imply_def (p q : F) :\n  @has_arrow.arrow F (@has_logic_symbol.to_has_arrow F (logic_simbol_default F top neg imply)) p q = imply p q := rfl\n\nlemma default_neg_def (p : F) :\n  @has_negation.neg F (@has_logic_symbol.to_has_negation F (logic_simbol_default F top neg imply)) p = neg p := rfl\n\nend \n\n-- Tait formula\nnamespace Tait\n\nvariables (F : Type*) (top : F) (bot : F) (neg : F → F) (and : F → F → F) (or : F → F → F)\n\n@[reducible] def logic_simbol_default : has_logic_symbol F :=\n{ bot := bot,\n  top := top,\n  sup := or,\n  inf := and,\n  arrow := λ p q, or (neg p) q,\n  neg := neg }\n\nlemma default_imply_def (p q) :\n  @has_arrow.arrow F (@has_logic_symbol.to_has_arrow F (logic_simbol_default F top bot neg and or)) p q =\n  @has_sup.sup F (@has_logic_symbol.to_has_sup F (logic_simbol_default F top bot neg and or))\n    (@has_negation.neg F (@has_logic_symbol.to_has_negation F (logic_simbol_default F top bot neg and or)) p)\n    q := rfl\n\nend Tait", "meta": {"author": "iehality", "repo": "lean-logic", "sha": "201cef2500203f7de83deb7fa8287934e2e142b2", "save_path": "github-repos/lean/iehality-lean-logic", "path": "github-repos/lean/iehality-lean-logic/lean-logic-201cef2500203f7de83deb7fa8287934e2e142b2/src/lib/notation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.45891595405106933}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.natural_isomorphism\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ u₃ v₁ v₂ v₃ u₄ v₄ u₅ v₅ \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\nIf `α : G ⟶ H` then\n`whisker_left F α : (F ⋙ G) ⟶ (F ⋙ H)` has components `α.app (F.obj X)`.\n-/\n@[simp] theorem whisker_left_app {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ⟶ H) (X : C) : nat_trans.app (whisker_left F α) X = nat_trans.app α (functor.obj F X) :=\n  Eq.refl (nat_trans.app (whisker_left F α) X)\n\n/--\nIf `α : G ⟶ H` then\n`whisker_right α F : (G ⋙ F) ⟶ (G ⋙ F)` has components `F.map (α.app X)`.\n-/\ndef whisker_right {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) : G ⋙ F ⟶ H ⋙ F :=\n  nat_trans.mk fun (X : C) => functor.map F (nat_trans.app α X)\n\n/--\nLeft-composition gives a functor `(C ⥤ D) ⥤ ((D ⥤ E) ⥤ (C ⥤ E))`.\n\n`(whiskering_lift.obj F).obj G` is `F ⋙ G`, and\n`(whiskering_lift.obj F).map α` is `whisker_left F α`.\n-/\ndef whiskering_left (C : Type u₁) [category C] (D : Type u₂) [category D] (E : Type u₃) [category E] : (C ⥤ D) ⥤ (D ⥤ E) ⥤ C ⥤ E :=\n  functor.mk (fun (F : C ⥤ D) => functor.mk (fun (G : D ⥤ E) => F ⋙ G) fun (G H : D ⥤ E) (α : G ⟶ H) => whisker_left F α)\n    fun (F G : C ⥤ D) (τ : F ⟶ G) =>\n      nat_trans.mk fun (H : D ⥤ E) => nat_trans.mk fun (c : C) => functor.map H (nat_trans.app τ c)\n\n/--\nRight-composition gives a functor `(D ⥤ E) ⥤ ((C ⥤ D) ⥤ (C ⥤ E))`.\n\n`(whiskering_right.obj H).obj F` is `F ⋙ H`, and\n`(whiskering_right.obj H).map α` is `whisker_right α H`.\n-/\n@[simp] theorem whiskering_right_obj_map (C : Type u₁) [category C] (D : Type u₂) [category D] (E : Type u₃) [category E] (H : D ⥤ E) (_x : C ⥤ D) : ∀ (_x_1 : C ⥤ D) (α : _x ⟶ _x_1), functor.map (functor.obj (whiskering_right C D E) H) α = whisker_right α H :=\n  fun (_x_1 : C ⥤ D) (α : _x ⟶ _x_1) => Eq.refl (functor.map (functor.obj (whiskering_right C D E) H) α)\n\n@[simp] theorem whisker_left_id {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} : whisker_left F (nat_trans.id G) = nat_trans.id (F ⋙ G) :=\n  rfl\n\n@[simp] theorem whisker_left_id' {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} : whisker_left F 𝟙 = 𝟙 :=\n  rfl\n\n@[simp] theorem whisker_right_id {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} (F : D ⥤ E) : whisker_right (nat_trans.id G) F = nat_trans.id (G ⋙ F) :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_right_id' {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} (F : D ⥤ E) : whisker_right 𝟙 F = 𝟙 :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_left_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} {K : D ⥤ E} (α : G ⟶ H) (β : H ⟶ K) : whisker_left F (α ≫ β) = whisker_left F α ≫ whisker_left F β :=\n  rfl\n\n@[simp] theorem whisker_right_comp {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} {K : C ⥤ D} (α : G ⟶ H) (β : H ⟶ K) (F : D ⥤ E) : whisker_right (α ≫ β) F = whisker_right α F ≫ whisker_right β F :=\n  functor.map_comp (functor.obj (whiskering_right C D E) F) α β\n\n/--\nIf `α : G ≅ H` is a natural isomorphism then\n`iso_whisker_left F α : (F ⋙ G) ≅ (F ⋙ H)` has components `α.app (F.obj X)`.\n-/\ndef iso_whisker_left {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ≅ H) : F ⋙ G ≅ F ⋙ H :=\n  functor.map_iso (functor.obj (whiskering_left C D E) F) α\n\n@[simp] theorem iso_whisker_left_hom {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ≅ H) : iso.hom (iso_whisker_left F α) = whisker_left F (iso.hom α) :=\n  rfl\n\n@[simp] theorem iso_whisker_left_inv {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ≅ H) : iso.inv (iso_whisker_left F α) = whisker_left F (iso.inv α) :=\n  rfl\n\n/--\nIf `α : G ≅ H` then\n`iso_whisker_right α F : (G ⋙ F) ≅ (G ⋙ F)` has components `F.map_iso (α.app X)`.\n-/\ndef iso_whisker_right {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) : G ⋙ F ≅ H ⋙ F :=\n  functor.map_iso (functor.obj (whiskering_right C D E) F) α\n\n@[simp] theorem iso_whisker_right_hom {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) : iso.hom (iso_whisker_right α F) = whisker_right (iso.hom α) F :=\n  rfl\n\n@[simp] theorem iso_whisker_right_inv {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) : iso.inv (iso_whisker_right α F) = whisker_right (iso.inv α) F :=\n  rfl\n\nprotected instance is_iso_whisker_left {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] (F : C ⥤ D) {G : D ⥤ E} {H : D ⥤ E} (α : G ⟶ H) [is_iso α] : is_iso (whisker_left F α) :=\n  is_iso.mk (iso.inv (iso_whisker_left F (as_iso α)))\n\nprotected instance is_iso_whisker_right {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {G : C ⥤ D} {H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) [is_iso α] : is_iso (whisker_right α F) :=\n  is_iso.mk (iso.inv (iso_whisker_right (as_iso α) F))\n\n@[simp] theorem whisker_left_twice {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {B : Type u₄} [category B] (F : B ⥤ C) (G : C ⥤ D) {H : D ⥤ E} {K : D ⥤ E} (α : H ⟶ K) : whisker_left F (whisker_left G α) = whisker_left (F ⋙ G) α :=\n  rfl\n\n@[simp] theorem whisker_right_twice {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {B : Type u₄} [category B] {H : B ⥤ C} {K : B ⥤ C} (F : C ⥤ D) (G : D ⥤ E) (α : H ⟶ K) : whisker_right (whisker_right α F) G = whisker_right α (F ⋙ G) :=\n  rfl\n\ntheorem whisker_right_left {C : Type u₁} [category C] {D : Type u₂} [category D] {E : Type u₃} [category E] {B : Type u₄} [category B] (F : B ⥤ C) {G : C ⥤ D} {H : C ⥤ D} (α : G ⟶ H) (K : D ⥤ E) : whisker_right (whisker_left F α) K = whisker_left F (whisker_right α K) :=\n  rfl\n\nnamespace functor\n\n\n/--\nThe left unitor, a natural isomorphism `((𝟭 _) ⋙ F) ≅ F`.\n-/\n@[simp] theorem left_unitor_hom_app {A : Type u₁} [category A] {B : Type u₂} [category B] (F : A ⥤ B) (X : A) : nat_trans.app (iso.hom (left_unitor F)) X = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.hom (left_unitor F)) X)\n\n/--\nThe right unitor, a natural isomorphism `(F ⋙ (𝟭 B)) ≅ F`.\n-/\n@[simp] theorem right_unitor_hom_app {A : Type u₁} [category A] {B : Type u₂} [category B] (F : A ⥤ B) (X : A) : nat_trans.app (iso.hom (right_unitor F)) X = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.hom (right_unitor F)) X)\n\n/--\nThe associator for functors, a natural isomorphism `((F ⋙ G) ⋙ H) ≅ (F ⋙ (G ⋙ H))`.\n\n(In fact, `iso.refl _` will work here, but it tends to make Lean slow later,\nand it's usually best to insert explicit associators.)\n-/\n@[simp] theorem associator_inv_app {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃} [category C] {D : Type u₄} [category D] (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D) (_x : A) : nat_trans.app (iso.inv (associator F G H)) _x = 𝟙 :=\n  Eq.refl (nat_trans.app (iso.inv (associator F G H)) _x)\n\ntheorem triangle {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃} [category C] (F : A ⥤ B) (G : B ⥤ C) : iso.hom (associator F 𝟭 G) ≫ whisker_left F (iso.hom (left_unitor G)) = whisker_right (iso.hom (right_unitor F)) G := sorry\n\ntheorem pentagon {A : Type u₁} [category A] {B : Type u₂} [category B] {C : Type u₃} [category C] {D : Type u₄} [category D] {E : Type u₅} [category E] (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D) (K : D ⥤ E) : whisker_right (iso.hom (associator F G H)) K ≫\n    iso.hom (associator F (G ⋙ H) K) ≫ whisker_left F (iso.hom (associator G H K)) =\n  iso.hom (associator (F ⋙ G) H K) ≫ iso.hom (associator F G (H ⋙ K)) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/whiskering.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979746, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.45891594550842096}}
{"text": "import tactic order.zorn\n\nnamespace tukey\nvariables {α : Type*} {F : set α → Prop}\n\ndef finite_charactor (P : set α → Prop) : Prop := ∀ a, P a ↔ (∀ s ⊆ a, s.finite → P s)\n\nlemma of_ss (H : finite_charactor F) {a} (ha : F a) {b} (ss : b ⊆ a) : F b :=\nbegin\n  have : ∀ s ⊆ a, s.finite → F s, from (H a).mp ha,\n  have : ∀ s ⊆ b, s.finite → F s,\n  { intros s hs s_fin, exact this s (set.subset.trans hs ss) s_fin },\n  exact (H b).mpr this\nend\n\nlemma empty_of_nonempty (H : finite_charactor F) {a} (ha : F a) : F ∅ :=\nof_ss H ha (by simp)\n\nlemma finite_chain_sup (H : finite_charactor F) {c : set (set α)} (ch : is_chain has_subset.subset c) :\n  ∀ {d : set (set α)} (hs : d.finite) (nemp : d.nonempty) (ss : d ⊆ c), ∃ m ∈ d, ⋃₀d ⊆ m :=\nbegin\n  intros d d_fin,\n  refine set.finite.induction_on d_fin (by simp) _,\n  intros a s ha s_fin IH _ ss,\n  by_cases nemp : s.nonempty,\n  { have : ∃ (m ∈ s), ⋃₀ s ⊆ m, from IH nemp (set.subset.trans (by simp) ss),\n    rcases this with ⟨m, mem, hs⟩,\n    have : m ⊆ a ∨ a ⊆ m, from is_chain.total ch (show m ∈ c, from ss (by simp[mem])) (show a ∈ c, from ss (by simp)),\n    rcases this,\n    { refine ⟨a, by simp, _⟩,\n      simp at hs ⊢, refine ⟨by refl, λ t ht, set.subset.trans (hs t ht) this⟩ },\n    { refine ⟨m, by simp[mem], _⟩,\n      simp at hs ⊢, refine ⟨this, hs⟩ } },\n  { have : s = ∅, from set.not_nonempty_iff_eq_empty.mp nemp, rcases this with rfl,\n    refine ⟨a, by simp⟩ }\nend\n\ntheorem exists_maximum (H : finite_charactor F) (a : set α) (ha : F a) :\n  ∃ m, F m ∧ a ⊆ m ∧ ∀ s, F s → m ⊆ s → s = m :=\nbegin\n  suffices : ∃ (m : set α) (H : m ∈ {x : set α | F x}),\n  a ⊆ m ∧ ∀ (a : set α), a ∈ {x : set α | F x} → m ⊆ a → a = m,\n  { simp at this, exact this },\n  refine zorn_subset_nonempty {x | F x} _ a ha, simp,\n  rintros c hF hc nemp,\n  have : F (⋃₀ c),\n  { have : ∀ s ⊆ ⋃₀ c, s.finite → F s,\n    { rw[set.sUnion_eq_Union], intros s s_ss s_fin,\n      have : ∃ (d : set (set α)), d ⊆ c ∧ d.finite ∧ s ⊆ ⋃₀ d,\n      { rcases set.finite_subset_Union s_fin s_ss with ⟨I, I_fin, s_ss⟩,  simp at s_ss,\n        refine ⟨coe '' I, by simp, set.finite.image coe I_fin, by simpa using s_ss⟩ },\n      rcases this with ⟨d, d_ss, d_fin, hs⟩,\n      by_cases d_nemp : d.nonempty,\n      { have : ∃ m ∈ d, ⋃₀d ⊆ m, from finite_chain_sup H hc d_fin d_nemp d_ss,\n        rcases this with ⟨m, m_mem, ss_m⟩,\n        exact of_ss H (show F m, from hF (d_ss m_mem)) (show s ⊆ m, from set.subset.trans hs ss_m) },\n      { have : d = ∅, from set.not_nonempty_iff_eq_empty.mp d_nemp, rcases this with rfl,\n        simp at hs, have : s = ∅, exact set.subset_eq_empty hs rfl, rcases this with rfl,\n        rcases set.nonempty_def.mp nemp with ⟨x, hx⟩, refine empty_of_nonempty H (hF hx) } },\n    refine (H (⋃₀ c)).mpr this },\n  refine ⟨⋃₀ c, this, λ _, set.subset_sUnion_of_mem⟩\nend \n\nend tukey", "meta": {"author": "iehality", "repo": "lean-logic", "sha": "201cef2500203f7de83deb7fa8287934e2e142b2", "save_path": "github-repos/lean/iehality-lean-logic", "path": "github-repos/lean/iehality-lean-logic/lean-logic-201cef2500203f7de83deb7fa8287934e2e142b2/src/lib/tukey.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.737158174177441, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4588509840884702}}
{"text": "import condensed.top_comparison\nimport condensed.filtered_colimits\nimport condensed.adjunctions\nimport for_mathlib.pow_functor\nimport for_mathlib.nat_trans\n\nopen category_theory\nopen category_theory.limits\n\nnamespace CondensedSet\n\nuniverses u\n\nvariables {J K : Type (u+1)} [small_category J] [small_category K]\n  [fin_category K] (F : K ⥤ J ⥤ CondensedSet.{u})\n\nnoncomputable\ndef colim_to_lim :\n  colimit (limit F) ⟶ limit (colimit F.flip) :=\ncolimit.desc (limit F) ⟨limit (colimit F.flip),\n{ app := λ j, limit.lift (colimit F.flip) ⟨(limit F).obj j,\n  { app := λ k, (limit.π F k).app j ≫ (colimit.ι F.flip j).app k,\n    naturality' := λ X Y f, by begin\n      erw [functor.const_obj_map, category.id_comp, category.assoc],\n      rw [← nat_trans.naturality, ← category.assoc],\n      simp only [functor.flip_obj_map, ← nat_trans.comp_app, limit.w],\n    end }⟩,\n  naturality' := λ X Y f, begin\n    erw [functor.const_obj_map, category.comp_id],\n    apply limit.hom_ext, intro k,\n    simp only [category.assoc, limit.lift_π, nat_trans.naturality_assoc],\n    simp only [← functor.flip_map_app, ← nat_trans.comp_app, colimit.w],\n  end }⟩\n\nnoncomputable\ninstance preserves_filtered_colimits :\n  preserves_filtered_colimits CondensedSet_to_presheaf.{u} :=\nbegin\n  constructor, introsI J _ _, constructor, intros F,\n  apply preserves_colimit_of_preserves_colimit_cocone\n    (filtered_cocone_is_colimit F),\n  let e : CondensedSet_to_presheaf.map_cocone (filtered_cocone F) ≅ colimit.cocone _ :=\n    cocones.ext (iso.refl _) _,\n  swap,\n  { intros j, dsimp, simpa },\n  apply is_colimit.of_iso_colimit _ e.symm,\n  exact colimit.is_colimit _,\nend\n\ninstance full_CondesensedSet_to_presheaf :\n  full CondensedSet_to_presheaf :=\nshow full (Sheaf_to_presheaf _ _), by apply_instance\n\ninstance faithful_CondesensedSet_to_presheaf :\n  faithful CondensedSet_to_presheaf :=\nshow faithful (Sheaf_to_presheaf _ _), by apply_instance\n\nnoncomputable\ninstance preserves_limits_CondesensedSet_to_presheaf :\n  preserves_limits CondensedSet_to_presheaf :=\nadjunction.right_adjoint_preserves_limits CondensedSet_presheaf_adjunction\n\nsection\n\nnoncomputable theory\n\n-- set_option pp.universes true\n\ndef _root_.category_theory.functor.map_limit {C D J : Type*}\n  [category C] [category D] [small_category J]\n  (G : C ⥤ D) (F : J ⥤ C)\n  [has_limit F] [has_limit (F ⋙ G)] [preserves_limit F G] :\n  G.obj (limit F) ≅ limit (F ⋙ G) :=\nis_limit.cone_point_unique_up_to_iso\n  (is_limit_of_preserves G (limit.is_limit _))\n  (limit.is_limit _)\n\n@[simp, reassoc]\nlemma _root_.category_theory.functor.map_limit_hom_π {J C D : Type*}\n  [small_category J] [category C] [category D]\n  (G : C ⥤ D) (F : J ⥤ C)\n  [has_limit F] [has_limit (F ⋙ G)] [preserves_limit F G]\n  (j : J) :\n  (G.map_limit F).hom ≫ limit.π (F ⋙ G) j = G.map (limit.π F j) :=\nby simp only [category_theory.functor.map_limit, functor.map_cone_π_app,\n    limit.cone_point_unique_up_to_iso_hom_comp, limit.cone_π]\n\ndef _root_.category_theory.functor.map_colimit {J C D : Type*}\n  [small_category J] [category C] [category D]\n  (G : C ⥤ D) (F : J ⥤ C)\n  [has_colimit F] [has_colimit (F ⋙ G)] [preserves_colimit F G] :\n  G.obj (colimit F) ≅ colimit (F ⋙ G) :=\nis_colimit.cocone_point_unique_up_to_iso\n  (is_colimit_of_preserves G (colimit.is_colimit _))\n  (colimit.is_colimit _)\n\n@[simp, reassoc]\nlemma _root_.category_theory.functor.ι_map_colimit_inv {J C D : Type*}\n  [small_category J] [category C] [category D]\n  (G : C ⥤ D) (F : J ⥤ C)\n  [has_colimit F] [has_colimit (F ⋙ G)] [preserves_colimit F G]\n  (j : J) :\n  colimit.ι (F ⋙ G) j ≫ (G.map_colimit F).inv = G.map (colimit.ι F j) :=\nby simp only [category_theory.functor.map_colimit, functor.map_cocone_ι_app,\n    colimit.comp_cocone_point_unique_up_to_iso_inv, colimit.cocone_ι]\n\ndef limit_comp_iso {J K C D : Type*} [small_category J] [small_category K]\n  [category C] [category D] [has_limits_of_shape J C] [has_limits_of_shape J D]\n  (F : J ⥤ K ⥤ C) (G : C ⥤ D) [has_limit F]\n  [H : ∀ k, has_limit (F.flip.obj k)] [∀ k, preserves_limit (F.flip.obj k) G]\n  [∀ k, preserves_limit F ((category_theory.evaluation K C).obj k)] :\n  limit F ⋙ G ≅ F.flip ⋙ ((whiskering_right _ _ _).obj G) ⋙ lim :=\nbegin\n  refine nat_iso.of_components _ _,\n  { intro k,\n    refine G.map_iso _ ≪≫ G.map_limit _,\n    letI : has_limit (F ⋙ (category_theory.evaluation K C).obj k) := H k,\n    refine ((category_theory.evaluation _ _).obj k).map_limit _ ≪≫ _,\n    refine limits.lim.map_iso _,\n    exact iso.refl _ },\n  { intros k₁ k₂ f,\n    ext j,\n    dsimp,\n    simp only [functor.map_comp, category_theory.functor.map_limit_hom_π, category.assoc,\n      lim_map_π, whisker_right_app, functor.flip_map_app,\n      category_theory.functor.map_limit_hom_π_assoc],\n    simp only [← functor.map_comp, category.assoc], congr' 1,\n    simp only [lim_map_π, lim_map_π_assoc, category_theory.functor.map_limit_hom_π_assoc,\n      category_theory.functor.map_limit_hom_π],\n    erw [← evaluation_map_app K C, ← category.assoc, ← nat_trans.naturality],\n    erw [nat_trans.id_app, nat_trans.id_app, category.comp_id, category.id_comp],\n    refl }\nend\n.\n\ndef colimit_comp_iso {J K C D : Type*} [small_category J] [small_category K]\n  [category C] [category D] [has_colimits_of_shape J C] [has_colimits_of_shape J D]\n  (F : J ⥤ K ⥤ C) (G : C ⥤ D) [has_colimit F]\n  [H : ∀ k, has_colimit (F.flip.obj k)] [∀ k, preserves_colimit (F.flip.obj k) G]\n  [∀ k, preserves_colimit F ((category_theory.evaluation K C).obj k)] :\n  colimit F ⋙ G ≅ F.flip ⋙ ((whiskering_right _ _ _).obj G) ⋙ colim :=\nbegin\n  refine nat_iso.of_components _ _,\n  { intro k,\n    refine G.map_iso _ ≪≫ G.map_colimit _,\n    letI : has_colimit (F ⋙ (category_theory.evaluation K C).obj k) := H k,\n    refine ((category_theory.evaluation _ _).obj k).map_colimit _ ≪≫ _,\n    refine colim.map_iso _,\n    exact iso.refl _ },\n  { intros k₁ k₂ f,\n    rw [← iso.inv_comp_eq, ← category.assoc, ← iso.eq_comp_inv],\n    ext j,\n    dsimp,\n    simp only [category.assoc, category_theory.functor.ι_map_colimit_inv_assoc, colimit.ι_map_assoc,\n      whisker_right_app, functor.flip_map_app],\n    simp only [← functor.map_comp, category.assoc], congr' 1,\n    simp only [colimit.ι_map_assoc, category_theory.functor.ι_map_colimit_inv_assoc,\n      category_theory.functor.ι_map_colimit_inv],\n    rw [← evaluation_map_app K C, nat_trans.naturality],\n    erw [nat_trans.id_app, nat_trans.id_app, category.id_comp, category.id_comp],\n    refl }\nend\n.\n\nvariables [is_filtered J]\n\ndef is_iso_colim_to_lim_component_e₁ (S : Profinite.{u}ᵒᵖ) :\n  (colimit (limit F)).val.obj S ≅ colimit (curry.obj (category_theory.prod.swap J K ⋙\n    (uncurry.{u+1 u+1}.obj F ⋙\n    (CondensedSet_to_presheaf.{u} ⋙ (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}ᵒᵖ (Type (u+1))).obj S))) ⋙ lim) :=\nbegin\n  let VS := CondensedSet_to_presheaf.{u} ⋙ (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}ᵒᵖ (Type (u+1))).obj S,\n  refine VS.map_colimit (limit F) ≪≫ _,\n  refine colim.map_iso _,\n  refine limit_comp_iso _ _ ≪≫ _,\n  refine (functor.associator _ _ _).symm ≪≫ _,\n  refine ((whiskering_right _ _ _).obj lim).map_iso _,\n  refine nat_iso.of_components _ _,\n  { intro k, refine nat_iso.of_components (λ j, iso.refl _) _,\n    intros i j f, dsimp,\n    simp only [category.id_comp, category.comp_id, (F.obj j).map_id, nat_trans.id_app, Sheaf.hom.id_val], },\n  { intros k l f, ext j : 2, dsimp,\n    simp only [category.id_comp, category.comp_id, F.map_id, nat_trans.id_app, Sheaf.hom.id_val], }\nend\n.\n\ndef is_iso_colim_to_lim_component_e₂ (S : Profinite.{u}ᵒᵖ) :\n  (limit (colimit F.flip)).val.obj S ≅\n  limit (curry.obj (uncurry.{u+1 u+1}.obj F ⋙\n    (CondensedSet_to_presheaf.{u} ⋙ (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}ᵒᵖ (Type (u+1))).obj S)) ⋙ colim) :=\nbegin\n  let VS := CondensedSet_to_presheaf.{u} ⋙ (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}ᵒᵖ (Type (u+1))).obj S,\n  refine VS.map_limit (colimit F.flip) ≪≫ _,\n  refine limits.lim.map_iso _,\n  refine colimit_comp_iso _ _ ≪≫ _,\n  refine (functor.associator _ _ _).symm ≪≫ _,\n  refine ((whiskering_right _ _ _).obj colim).map_iso _,\n  refine nat_iso.of_components _ _,\n  { intro k, refine nat_iso.of_components (λ j, iso.refl _) _,\n    intros i j f, dsimp,\n    simp only [category.id_comp, category.comp_id, F.map_id, nat_trans.id_app, Sheaf.hom.id_val], },\n  { intros k l f, ext j : 2, dsimp,\n    simp only [category.id_comp, category.comp_id, (F.obj l).map_id, nat_trans.id_app, Sheaf.hom.id_val], }\nend\n.\n\nlocal attribute [reassoc] Sheaf.hom.comp_val\n\nlemma is_iso_colim_to_lim_component (S : Profinite.{u}ᵒᵖ) :\n  is_iso ((colim_to_lim F).val.app S) :=\nbegin\n  /-\n  The forgetful functor to presheaves preserves filtered colimits and all limits,\n  while the same holds for evaluation, hence this morphism should be isomorphic to\n  `colimit_limit_to_limit_colimit` which is an isomorphism.\n  -/\n  suffices : (colim_to_lim F).val.app S =\n    (is_iso_colim_to_lim_component_e₁ F S).hom ≫ colimit_limit_to_limit_colimit _ ≫ (is_iso_colim_to_lim_component_e₂ F S).inv,\n  { rw [this, is_iso_iff_is_iso_comp_left, is_iso_iff_is_iso_comp_right], apply_instance },\n  rw [← iso.inv_comp_eq, iso.eq_comp_inv, category.assoc],\n  ext j k : 2,\n  dsimp [colimit_limit_to_limit_colimit, is_iso_colim_to_lim_component_e₁, is_iso_colim_to_lim_component_e₂],\n  simp only [category.assoc, limit.lift_π, colimit.ι_desc, colimit.ι_map_assoc,\n    category_theory.functor.ι_map_colimit_inv_assoc,\n    category_theory.functor.map_limit_hom_π_assoc,\n    lim_map_π, nat_trans.comp_app, whisker_right_app, category.id_comp,\n    functor.associator_hom_app, functor.associator_inv_app,\n    limit_comp_iso, colimit_comp_iso, iso.trans_hom, iso.trans_inv,\n    nat_iso.of_components_hom_app, nat_iso.of_components_inv_app,\n    functor.map_iso_hom, functor.map_iso_inv,\n    functor.comp_map, CondensedSet_to_presheaf_map, evaluation_obj_map],\n  simp only [← functor.map_iso_hom, ← functor.map_iso_inv, iso.inv_comp_eq],\n  simp only [← category.assoc, ← iso.eq_comp_inv],\n  simp only [category.assoc, functor.map_iso_hom, functor.map_iso_inv,\n    colimit.ι_map_assoc, lim_map_eq_lim_map, lim_map_π_assoc,\n    nat_iso.of_components_hom_app, nat_iso.of_components_inv_app],\n  conv_rhs\n  { erw [category_theory.functor.ι_map_colimit_inv,\n      category_theory.functor.map_limit_hom_π_assoc,\n      iso.refl_hom, iso.refl_inv, category.id_comp, category.id_comp], },\n  simp only [← nat_trans.comp_app, ← Sheaf.hom.comp_val,\n    CondensedSet_to_presheaf_map, evaluation_obj_map, functor.comp_map,\n    ← category_theory.nat_trans.comp_app_assoc, ← category_theory.Sheaf.hom.comp_val_assoc],\n  simp only [colim_to_lim, colimit.ι_desc_assoc, limit.lift_π_assoc, category.assoc],\n  congr' 2,\n  simp only [← lim_map_eq_lim_map, ← functor.map_iso_hom, ← functor.map_iso_inv, iso.inv_comp_eq],\n  simp only [← category.assoc, ← iso.eq_comp_inv],\n  simp only [functor.map_iso_hom, functor.map_iso_inv, category.assoc,\n    lim_map_eq_lim_map, lim_map_π_assoc, colimit.ι_map_assoc,\n    category_theory.functor.ι_map_colimit_inv, category_theory.functor.map_limit_hom_π_assoc,\n    iso.refl_hom, iso.refl_inv, category.id_comp, nat_trans.id_app],\n  refl,\nend\n\nend\n\ndef prod_eval_iso (α : Type (u+1))\n  (X : α → J ⥤ CondensedSet.{u}) (j) :\n  (∏ X).obj j ≅ ∏ (λ i, (X i).obj j) :=\npreserves_limit_iso ((category_theory.evaluation _ _).obj j) _ ≪≫\nhas_limit.iso_of_nat_iso (discrete.nat_iso $ λ i, iso.refl _)\n\ndef is_colimit_pow_functor_map_cocone_aux (α : Type (u+1)) [fintype α] (F : J ⥤ CondensedSet)\n  (S : cocone (F ⋙ pow_functor CondensedSet α)) :\n  cocone (∏ λ (i : α), F) :=\n{ X := S.X,\n  ι :=\n  { app := λ j, begin\n      refine (prod_eval_iso _ _ _).hom ≫ _,\n      refine S.ι.app j,\n    end,\n    naturality' := begin\n      intros i j f, dsimp [prod_eval_iso], simp only [category.comp_id, category.assoc],\n      rw ← S.w f,\n      simp only [← category.assoc], congr' 1, simp only [category.assoc], dsimp,\n      apply limit.hom_ext, intros k,\n      dsimp [pow_functor], simp only [category.assoc, has_limit.iso_of_nat_iso_hom_π,\n        discrete.nat_iso_hom_app, preserves_limits_iso_hom_π_assoc,\n        evaluation_obj_map, nat_trans.naturality_assoc, lim_map_π, discrete.nat_trans_app,\n        has_limit.iso_of_nat_iso_hom_π_assoc],\n      dsimp [discrete.functor], simp,\n    end } }\n\nvariables [is_filtered J]\n\nlemma is_iso_colim_to_lim : is_iso (colim_to_lim F) :=\nbegin\n  suffices : is_iso (CondensedSet_to_presheaf.map (colim_to_lim F)),\n  { resetI, apply is_iso_of_fully_faithful CondensedSet_to_presheaf },\n  apply_with nat_iso.is_iso_of_is_iso_app { instances := ff },\n  intros S,\n  apply is_iso_colim_to_lim_component,\nend\n\nnoncomputable\ndef colimit_limit_iso_limit_colimit :\n  colimit (limit F) ≅ limit (colimit F.flip) :=\n@as_iso _ _ _ _ (colim_to_lim F) (is_iso_colim_to_lim _)\n\nopen_locale classical\n\nnoncomputable\ndef colimit_pow_iso (α : Type (u+1)) [fintype α] (F : J ⥤ CondensedSet.{u}) :\n  colimit (∏ λ i : α, F) ≅ ∏ (λ i : α, colimit F) :=\ncolimit_limit_iso_limit_colimit (discrete.functor $ λ i : α, F) ≪≫\nhas_limit.iso_of_nat_iso (discrete.nat_iso $ λ i,\nbegin\n  refine (preserves_colimit_iso ((category_theory.evaluation _ _).obj i) _) ≪≫ _,\n  refine has_colimit.iso_of_nat_iso _,\n  refine nat_iso.of_components (λ j, iso.refl _) _,\n  intros j k f, dsimp,\n  simp only [category.comp_id, category.id_comp], refl\nend)\n.\n\ndef is_colimit_pow_functor_map_cocone (α : Type (u+1)) [fintype α] (F : J ⥤ CondensedSet) :\n  is_colimit ((pow_functor CondensedSet α).map_cocone (colimit.cocone F)) :=\n{ desc := λ S, (colimit_pow_iso α F).inv ≫\n    colimit.desc (∏ λ (i : α), F) (is_colimit_pow_functor_map_cocone_aux α F S),\n  fac' := begin\n    intros S j, dsimp,  simp only [← category.assoc], let t := _, change t ≫ _ = _,\n    have ht : t = (prod_eval_iso _ _ _).inv ≫ colimit.ι _ j,\n    { rw iso.eq_inv_comp,\n      dsimp [t], rw [← category.assoc, iso.comp_inv_eq], dsimp [prod_eval_iso, colimit_pow_iso,\n        pow_functor, colimit_limit_iso_limit_colimit, colim_to_lim],\n      simp only [category.assoc, colimit.ι_desc_assoc, has_limit.lift_iso_of_nat_iso_hom],\n      apply limit.hom_ext, intros k,\n      simp only [category.assoc, lim_map_π, discrete.nat_trans_app,\n        has_limit.iso_of_nat_iso_hom_π_assoc, discrete.nat_iso_hom_app,\n        preserves_limits_iso_hom_π_assoc, evaluation_obj_map, limit.lift_π,\n        cones.postcompose_obj_π, nat_trans.comp_app, iso.trans_hom],\n      dsimp, simp only [category.id_comp],\n      erw (is_colimit_of_preserves ((category_theory.evaluation\n        (discrete α) CondensedSet).obj k) _).fac_assoc,\n      erw colimit.ι_desc, refl },\n    rw [ht, category.assoc, colimit.ι_desc],\n    dsimp [is_colimit_pow_functor_map_cocone_aux], simp,\n  end,\n  uniq' := begin\n    intros S m hm, rw iso.eq_inv_comp, apply colimit.hom_ext, intros j,\n    dsimp [colimit_pow_iso], simp only [category.assoc, colimit.ι_desc],\n    erw colimit.ι_desc_assoc, dsimp [is_colimit_pow_functor_map_cocone_aux],\n    simp_rw [← hm, ← category.assoc], congr' 1, apply limit.hom_ext, intros k,\n    dsimp [pow_functor, prod_eval_iso],\n    simp only [has_limit.lift_iso_of_nat_iso_hom, limit.lift_π, cones.postcompose_obj_π,\n      nat_trans.comp_app, discrete.nat_iso_hom_app, iso.trans_hom, category.assoc, lim_map_π,\n      discrete.nat_trans_app, has_limit.iso_of_nat_iso_hom_π_assoc,\n      preserves_limits_iso_hom_π_assoc, evaluation_obj_map],\n    erw (is_colimit_of_preserves ((category_theory.evaluation\n      (discrete α) CondensedSet).obj k) _).fac_assoc,\n    erw colimit.ι_desc,\n    dsimp, simp,\n  end }\n\n-- Filtered colimits commute with finite products in condensed sets\nnoncomputable\ninstance pow_functor_preserves_filtered_colimits (α : Type (u+1)) [fintype α] :\n  preserves_filtered_colimits\n  (pow_functor CondensedSet.{u} α) :=\nbegin\n  constructor, introsI J _ _, constructor, intros F,\n  apply preserves_colimit_of_preserves_colimit_cocone (colimit.is_colimit F),\n  apply is_colimit_pow_functor_map_cocone,\nend\n\nend CondensedSet\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/filtered_colimits_commute_with_finite_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4588509768998382}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.functor\nimport Mathlib.PostPort\n\nuniverses v u l u₂ v₂ \n\nnamespace Mathlib\n\n/-!\n# Isomorphisms\n\nThis file defines isomorphisms between objects of a category.\n\n## Main definitions\n\n- `structure iso` : a bundled isomorphism between two objects of a category;\n- `class is_iso` : an unbundled version of `iso`; note that `is_iso f` is usually *not* a `Prop`,\n  because it holds the inverse morphism;\n- `as_iso` : convert from `is_iso` to `iso`;\n- `of_iso` : convert from `iso` to `is_iso`;\n- standard operations on isomorphisms (composition, inverse etc)\n\n## Notations\n\n- `X ≅ Y` : same as `iso X Y`;\n- `α ≪≫ β` : composition of two isomorphisms; it is called `iso.trans`\n\n## Tags\n\ncategory, category theory, isomorphism\n-/\n\nnamespace category_theory\n\n\n/--\nAn isomorphism (a.k.a. an invertible morphism) between two objects of a category.\nThe inverse morphism is bundled.\n\nSee also `category_theory.core` for the category with the same objects and isomorphisms playing\nthe role of morphisms.\n\nSee https://stacks.math.columbia.edu/tag/0017.\n-/\nstructure iso {C : Type u} [category C] (X : C) (Y : C) where\n  hom : X ⟶ Y\n  inv : Y ⟶ X\n  hom_inv_id' :\n    autoParam (hom ≫ inv = 𝟙)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  inv_hom_id' :\n    autoParam (inv ≫ hom = 𝟙)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n@[simp] theorem iso.hom_inv_id {C : Type u} [category C] {X : C} {Y : C} (c : iso X Y) :\n    iso.hom c ≫ iso.inv c = 𝟙 :=\n  sorry\n\n@[simp] theorem iso.inv_hom_id {C : Type u} [category C] {X : C} {Y : C} (c : iso X Y) :\n    iso.inv c ≫ iso.hom c = 𝟙 :=\n  sorry\n\n@[simp] theorem iso.hom_inv_id_assoc {C : Type u} [category C] {X : C} {Y : C} (c : iso X Y)\n    {X' : C} (f' : X ⟶ X') : iso.hom c ≫ iso.inv c ≫ f' = f' :=\n  sorry\n\ninfixr:10 \" ≅ \" => Mathlib.category_theory.iso\n\nnamespace iso\n\n\ntheorem ext {C : Type u} [category C] {X : C} {Y : C} {α : X ≅ Y} {β : X ≅ Y} (w : hom α = hom β) :\n    α = β :=\n  sorry\n\n/-- Inverse isomorphism. -/\ndef symm {C : Type u} [category C] {X : C} {Y : C} (I : X ≅ Y) : Y ≅ X := mk (inv I) (hom I)\n\n@[simp] theorem symm_hom {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    hom (symm α) = inv α :=\n  rfl\n\n@[simp] theorem symm_inv {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    inv (symm α) = hom α :=\n  rfl\n\n@[simp] theorem symm_mk {C : Type u} [category C] {X : C} {Y : C} (hom : X ⟶ Y) (inv : Y ⟶ X)\n    (hom_inv_id : hom ≫ inv = 𝟙) (inv_hom_id : inv ≫ hom = 𝟙) : symm (mk hom inv) = mk inv hom :=\n  rfl\n\n@[simp] theorem symm_symm_eq {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    symm (symm α) = α :=\n  sorry\n\n@[simp] theorem symm_eq_iff {C : Type u} [category C] {X : C} {Y : C} {α : X ≅ Y} {β : X ≅ Y} :\n    symm α = symm β ↔ α = β :=\n  { mp := fun (h : symm α = symm β) => symm_symm_eq α ▸ symm_symm_eq β ▸ congr_arg symm h,\n    mpr := congr_arg symm }\n\n/-- Identity isomorphism. -/\n@[simp] theorem refl_inv {C : Type u} [category C] (X : C) : inv (refl X) = 𝟙 :=\n  Eq.refl (inv (refl X))\n\nprotected instance inhabited {C : Type u} [category C] {X : C} : Inhabited (X ≅ X) :=\n  { default := refl X }\n\n@[simp] theorem refl_symm {C : Type u} [category C] (X : C) : symm (refl X) = refl X := rfl\n\n/-- Composition of two isomorphisms -/\ndef trans {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y) (β : Y ≅ Z) : X ≅ Z :=\n  mk (hom α ≫ hom β) (inv β ≫ inv α)\n\ninfixr:80 \" ≪≫ \" => Mathlib.category_theory.iso.trans\n\n@[simp] theorem trans_mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} (hom : X ⟶ Y)\n    (inv : Y ⟶ X) (hom_inv_id : hom ≫ inv = 𝟙) (inv_hom_id : inv ≫ hom = 𝟙) (hom' : Y ⟶ Z)\n    (inv' : Z ⟶ Y) (hom_inv_id' : hom' ≫ inv' = 𝟙) (inv_hom_id' : inv' ≫ hom' = 𝟙)\n    (hom_inv_id'' : (hom ≫ hom') ≫ inv' ≫ inv = 𝟙) (inv_hom_id'' : (inv' ≫ inv) ≫ hom ≫ hom' = 𝟙) :\n    mk hom inv ≪≫ mk hom' inv' = mk (hom ≫ hom') (inv' ≫ inv) :=\n  rfl\n\n@[simp] theorem trans_symm {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y)\n    (β : Y ≅ Z) : symm (α ≪≫ β) = symm β ≪≫ symm α :=\n  rfl\n\n@[simp] theorem trans_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {Z' : C} (α : X ≅ Y)\n    (β : Y ≅ Z) (γ : Z ≅ Z') : (α ≪≫ β) ≪≫ γ = α ≪≫ β ≪≫ γ :=\n  sorry\n\n@[simp] theorem refl_trans {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    refl X ≪≫ α = α :=\n  ext (category.id_comp (hom α))\n\n@[simp] theorem trans_refl {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    α ≪≫ refl Y = α :=\n  ext (category.comp_id (hom α))\n\n@[simp] theorem symm_self_id {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    symm α ≪≫ α = refl Y :=\n  ext (inv_hom_id α)\n\n@[simp] theorem self_symm_id {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) :\n    α ≪≫ symm α = refl X :=\n  ext (hom_inv_id α)\n\n@[simp] theorem symm_self_id_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y)\n    (β : Y ≅ Z) : symm α ≪≫ α ≪≫ β = β :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (symm α ≪≫ α ≪≫ β = β)) (Eq.symm (trans_assoc (symm α) α β))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((symm α ≪≫ α) ≪≫ β = β)) (symm_self_id α)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (refl Y ≪≫ β = β)) (refl_trans β))) (Eq.refl β)))\n\n@[simp] theorem self_symm_id_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y)\n    (β : X ≅ Z) : α ≪≫ symm α ≪≫ β = β :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (α ≪≫ symm α ≪≫ β = β)) (Eq.symm (trans_assoc α (symm α) β))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((α ≪≫ symm α) ≪≫ β = β)) (self_symm_id α)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (refl X ≪≫ β = β)) (refl_trans β))) (Eq.refl β)))\n\ntheorem inv_comp_eq {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y) {f : X ⟶ Z}\n    {g : Y ⟶ Z} : inv α ≫ f = g ↔ f = hom α ≫ g :=\n  sorry\n\ntheorem eq_inv_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y) {f : X ⟶ Z}\n    {g : Y ⟶ Z} : g = inv α ≫ f ↔ hom α ≫ g = f :=\n  iff.symm (inv_comp_eq (symm α))\n\ntheorem comp_inv_eq {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y) {f : Z ⟶ Y}\n    {g : Z ⟶ X} : f ≫ inv α = g ↔ f = g ≫ hom α :=\n  sorry\n\ntheorem eq_comp_inv {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ≅ Y) {f : Z ⟶ Y}\n    {g : Z ⟶ X} : g = f ≫ inv α ↔ g ≫ hom α = f :=\n  iff.symm (comp_inv_eq (symm α))\n\ntheorem inv_eq_inv {C : Type u} [category C] {X : C} {Y : C} (f : X ≅ Y) (g : X ≅ Y) :\n    inv f = inv g ↔ hom f = hom g :=\n  sorry\n\ntheorem hom_comp_eq_id {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) {f : Y ⟶ X} :\n    hom α ≫ f = 𝟙 ↔ f = inv α :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (hom α ≫ f = 𝟙 ↔ f = inv α)) (Eq.symm (propext (eq_inv_comp α)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (f = inv α ≫ 𝟙 ↔ f = inv α)) (category.comp_id (inv α))))\n      (iff.refl (f = inv α)))\n\ntheorem comp_hom_eq_id {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) {f : Y ⟶ X} :\n    f ≫ hom α = 𝟙 ↔ f = inv α :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (f ≫ hom α = 𝟙 ↔ f = inv α)) (Eq.symm (propext (eq_comp_inv α)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (f = 𝟙 ≫ inv α ↔ f = inv α)) (category.id_comp (inv α))))\n      (iff.refl (f = inv α)))\n\ntheorem hom_eq_inv {C : Type u} [category C] {X : C} {Y : C} (α : X ≅ Y) (β : Y ≅ X) :\n    hom α = inv β ↔ hom β = inv α :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (hom α = inv β ↔ hom β = inv α)) (propext (inv_eq_inv (symm α) β))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (hom (symm α) = hom β ↔ hom β = inv α)) (propext eq_comm)))\n      (iff.refl (hom β = hom (symm α))))\n\nend iso\n\n\n/-- `is_iso` typeclass expressing that a morphism is invertible.\n    This contains the data of the inverse, but is a subsingleton type. -/\nclass is_iso {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) where\n  inv : Y ⟶ X\n  hom_inv_id' :\n    autoParam (f ≫ inv = 𝟙)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  inv_hom_id' :\n    autoParam (inv ≫ f = 𝟙)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n/-- Reinterpret a morphism `f` with an `is_iso f` instance as an `iso`. -/\ndef as_iso {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [h : is_iso f] : X ≅ Y :=\n  iso.mk f (inv f)\n\n@[simp] theorem as_iso_hom {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [is_iso f] :\n    iso.hom (as_iso f) = f :=\n  rfl\n\n@[simp] theorem as_iso_inv {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [is_iso f] :\n    iso.inv (as_iso f) = inv f :=\n  rfl\n\nnamespace is_iso\n\n\n@[simp] theorem hom_inv_id {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [is_iso f] :\n    f ≫ inv f = 𝟙 :=\n  hom_inv_id'\n\n@[simp] theorem inv_hom_id {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [is_iso f] :\n    inv f ≫ f = 𝟙 :=\n  inv_hom_id'\n\n@[simp] theorem hom_inv_id_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    [is_iso f] (g : X ⟶ Z) : f ≫ inv f ≫ g = g :=\n  iso.hom_inv_id_assoc (as_iso f) g\n\n@[simp] theorem inv_hom_id_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    [is_iso f] (g : Y ⟶ Z) : inv f ≫ f ≫ g = g :=\n  iso.inv_hom_id_assoc (as_iso f) g\n\nprotected instance id {C : Type u} [category C] (X : C) : is_iso 𝟙 := mk 𝟙\n\nprotected instance of_iso {C : Type u} [category C] {X : C} {Y : C} (f : X ≅ Y) :\n    is_iso (iso.hom f) :=\n  mk (iso.inv f)\n\nprotected instance of_iso_inv {C : Type u} [category C] {X : C} {Y : C} (f : X ≅ Y) :\n    is_iso (iso.inv f) :=\n  is_iso.of_iso (iso.symm f)\n\nprotected instance inv_is_iso {C : Type u} [category C] {X : C} {Y : C} {f : X ⟶ Y} [is_iso f] :\n    is_iso (inv f) :=\n  is_iso.of_iso_inv (as_iso f)\n\nprotected instance comp_is_iso {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y}\n    {h : Y ⟶ Z} [is_iso f] [is_iso h] : is_iso (f ≫ h) :=\n  is_iso.of_iso (as_iso f ≪≫ as_iso h)\n\n@[simp] theorem inv_id {C : Type u} [category C] {X : C} : inv 𝟙 = 𝟙 := rfl\n\n@[simp] theorem inv_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X ⟶ Y} {h : Y ⟶ Z}\n    [is_iso f] [is_iso h] : inv (f ≫ h) = inv h ≫ inv f :=\n  rfl\n\n@[simp] theorem inv_inv {C : Type u} [category C] {X : C} {Y : C} {f : X ⟶ Y} [is_iso f] :\n    inv (inv f) = f :=\n  rfl\n\n@[simp] theorem iso.inv_inv {C : Type u} [category C] {X : C} {Y : C} (f : X ≅ Y) :\n    inv (iso.inv f) = iso.hom f :=\n  rfl\n\n@[simp] theorem iso.inv_hom {C : Type u} [category C] {X : C} {Y : C} (f : X ≅ Y) :\n    inv (iso.hom f) = iso.inv f :=\n  rfl\n\n@[simp] theorem inv_comp_eq {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ⟶ Y) [is_iso α]\n    {f : X ⟶ Z} {g : Y ⟶ Z} : inv α ≫ f = g ↔ f = α ≫ g :=\n  iso.inv_comp_eq (as_iso α)\n\n@[simp] theorem eq_inv_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ⟶ Y) [is_iso α]\n    {f : X ⟶ Z} {g : Y ⟶ Z} : g = inv α ≫ f ↔ α ≫ g = f :=\n  iso.eq_inv_comp (as_iso α)\n\n@[simp] theorem comp_inv_eq {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ⟶ Y) [is_iso α]\n    {f : Z ⟶ Y} {g : Z ⟶ X} : f ≫ inv α = g ↔ f = g ≫ α :=\n  iso.comp_inv_eq (as_iso α)\n\n@[simp] theorem eq_comp_inv {C : Type u} [category C] {X : C} {Y : C} {Z : C} (α : X ⟶ Y) [is_iso α]\n    {f : Z ⟶ Y} {g : Z ⟶ X} : g = f ≫ inv α ↔ g ≫ α = f :=\n  iso.eq_comp_inv (as_iso α)\n\nprotected instance epi_of_iso {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [is_iso f] :\n    epi f :=\n  epi.mk\n    fun (Z : C) (g h : Y ⟶ Z) (w : f ≫ g = f ≫ h) =>\n      eq.mpr (id (Eq._oldrec (Eq.refl (g = h)) (Eq.symm (inv_hom_id_assoc f g))))\n        (eq.mpr (id (Eq._oldrec (Eq.refl (inv f ≫ f ≫ g = h)) w))\n          (eq.mpr (id (Eq._oldrec (Eq.refl (inv f ≫ f ≫ h = h)) (inv_hom_id_assoc f h)))\n            (Eq.refl h)))\n\nprotected instance mono_of_iso {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) [is_iso f] :\n    mono f :=\n  mono.mk\n    fun (Z : C) (g h : Z ⟶ X) (w : g ≫ f = h ≫ f) =>\n      eq.mpr (id (Eq._oldrec (Eq.refl (g = h)) (Eq.symm (category.comp_id g))))\n        (eq.mpr (id (Eq._oldrec (Eq.refl (g ≫ 𝟙 = h)) (Eq.symm (category.comp_id h))))\n          (eq.mpr (id (Eq._oldrec (Eq.refl (g ≫ 𝟙 = h ≫ 𝟙)) (Eq.symm (hom_inv_id f))))\n            (eq.mpr\n              (id\n                (Eq._oldrec (Eq.refl (g ≫ f ≫ inv f = h ≫ f ≫ inv f))\n                  (Eq.symm (category.assoc g f (inv f)))))\n              (eq.mpr (id (Eq._oldrec (Eq.refl ((g ≫ f) ≫ inv f = h ≫ f ≫ inv f)) w))\n                (eq.mpr\n                  (id\n                    (Eq._oldrec (Eq.refl ((h ≫ f) ≫ inv f = h ≫ f ≫ inv f))\n                      (Eq.symm (category.assoc h f (inv f)))))\n                  (Eq.refl ((h ≫ f) ≫ inv f)))))))\n\nend is_iso\n\n\ntheorem eq_of_inv_eq_inv {C : Type u} [category C] {X : C} {Y : C} {f : X ⟶ Y} {g : X ⟶ Y}\n    [is_iso f] [is_iso g] (p : inv f = inv g) : f = g :=\n  sorry\n\nprotected instance is_iso.subsingleton {C : Type u} [category C] {X : C} {Y : C} (f : X ⟶ Y) :\n    subsingleton (is_iso f) :=\n  sorry\n\ntheorem is_iso.inv_eq_inv {C : Type u} [category C] {X : C} {Y : C} {f : X ⟶ Y} {g : X ⟶ Y}\n    [is_iso f] [is_iso g] : inv f = inv g ↔ f = g :=\n  iso.inv_eq_inv (as_iso f) (as_iso g)\n\ntheorem hom_comp_eq_id {C : Type u} [category C] {X : C} {Y : C} (g : X ⟶ Y) [is_iso g]\n    {f : Y ⟶ X} : g ≫ f = 𝟙 ↔ f = inv g :=\n  iso.hom_comp_eq_id (as_iso g)\n\ntheorem comp_hom_eq_id {C : Type u} [category C] {X : C} {Y : C} (g : X ⟶ Y) [is_iso g]\n    {f : Y ⟶ X} : f ≫ g = 𝟙 ↔ f = inv g :=\n  iso.comp_hom_eq_id (as_iso g)\n\nnamespace iso\n\n\n/-!\nAll these cancellation lemmas can be solved by `simp [cancel_mono]` (or `simp [cancel_epi]`),\nbut with the current design `cancel_mono` is not a good `simp` lemma,\nbecause it generates a typeclass search.\n\nWhen we can see syntactically that a morphism is a `mono` or an `epi`\nbecause it came from an isomorphism, it's fine to do the cancellation via `simp`.\n\nIn the longer term, it might be worth exploring making `mono` and `epi` structures,\nrather than typeclasses, with coercions back to `X ⟶ Y`.\nPresumably we could write `X ↪ Y` and `X ↠ Y`.\n-/\n\n@[simp] theorem cancel_iso_hom_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ≅ Y)\n    (g : Y ⟶ Z) (g' : Y ⟶ Z) : hom f ≫ g = hom f ≫ g' ↔ g = g' :=\n  sorry\n\n@[simp] theorem cancel_iso_inv_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : Y ≅ X)\n    (g : Y ⟶ Z) (g' : Y ⟶ Z) : inv f ≫ g = inv f ≫ g' ↔ g = g' :=\n  sorry\n\n@[simp] theorem cancel_iso_hom_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    (f' : X ⟶ Y) (g : Y ≅ Z) : f ≫ hom g = f' ≫ hom g ↔ f = f' :=\n  sorry\n\n@[simp] theorem cancel_iso_inv_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X ⟶ Y)\n    (f' : X ⟶ Y) (g : Z ≅ Y) : f ≫ inv g = f' ≫ inv g ↔ f = f' :=\n  sorry\n\n/-\nUnfortunately cancelling an isomorphism from the right of a chain of compositions is awkward.\nWe would need separate lemmas for each chain length (worse: for each pair of chain lengths).\n\nWe provide two more lemmas, for case of three morphisms, because this actually comes up in practice,\nbut then stop.\n-/\n\n@[simp] theorem cancel_iso_hom_right_assoc {C : Type u} [category C] {W : C} {X : C} {X' : C}\n    {Y : C} {Z : C} (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) (h : Y ≅ Z) :\n    f ≫ g ≫ hom h = f' ≫ g' ≫ hom h ↔ f ≫ g = f' ≫ g' :=\n  sorry\n\n@[simp] theorem cancel_iso_inv_right_assoc {C : Type u} [category C] {W : C} {X : C} {X' : C}\n    {Y : C} {Z : C} (f : W ⟶ X) (g : X ⟶ Y) (f' : W ⟶ X') (g' : X' ⟶ Y) (h : Z ≅ Y) :\n    f ≫ g ≫ inv h = f' ≫ g' ≫ inv h ↔ f ≫ g = f' ≫ g' :=\n  sorry\n\nend iso\n\n\nnamespace functor\n\n\n/-- A functor `F : C ⥤ D` sends isomorphisms `i : X ≅ Y` to isomorphisms `F.obj X ≅ F.obj Y` -/\ndef map_iso {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D) {X : C} {Y : C}\n    (i : X ≅ Y) : obj F X ≅ obj F Y :=\n  iso.mk (map F (iso.hom i)) (map F (iso.inv i))\n\n@[simp] theorem map_iso_hom {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D) {X : C}\n    {Y : C} (i : X ≅ Y) : iso.hom (map_iso F i) = map F (iso.hom i) :=\n  rfl\n\n@[simp] theorem map_iso_inv {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D) {X : C}\n    {Y : C} (i : X ≅ Y) : iso.inv (map_iso F i) = map F (iso.inv i) :=\n  rfl\n\n@[simp] theorem map_iso_symm {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D)\n    {X : C} {Y : C} (i : X ≅ Y) : map_iso F (iso.symm i) = iso.symm (map_iso F i) :=\n  rfl\n\n@[simp] theorem map_iso_trans {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D)\n    {X : C} {Y : C} {Z : C} (i : X ≅ Y) (j : Y ≅ Z) :\n    map_iso F (i ≪≫ j) = map_iso F i ≪≫ map_iso F j :=\n  iso.ext (map_comp F (iso.hom i) (iso.hom j))\n\n@[simp] theorem map_iso_refl {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D)\n    (X : C) : map_iso F (iso.refl X) = iso.refl (obj F X) :=\n  iso.ext (map_id F X)\n\nprotected instance map_is_iso {C : Type u} [category C] {X : C} {Y : C} {D : Type u₂} [category D]\n    (F : C ⥤ D) (f : X ⟶ Y) [is_iso f] : is_iso (map F f) :=\n  is_iso.of_iso (map_iso F (as_iso f))\n\n@[simp] theorem map_inv {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D) {X : C}\n    {Y : C} (f : X ⟶ Y) [is_iso f] : map F (inv f) = inv (map F f) :=\n  rfl\n\ntheorem map_hom_inv {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D) {X : C} {Y : C}\n    (f : X ⟶ Y) [is_iso f] : map F f ≫ map F (inv f) = 𝟙 :=\n  sorry\n\ntheorem map_inv_hom {C : Type u} [category C] {D : Type u₂} [category D] (F : C ⥤ D) {X : C} {Y : C}\n    (f : X ⟶ Y) [is_iso f] : map F (inv f) ≫ map F f = 𝟙 :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/isomorphism_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4588509768998382}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\n\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.ennreal\nimport formal_ml.sum\nimport formal_ml.lattice\nimport formal_ml.measurable_space\nimport formal_ml.classical\nimport formal_ml.core\nimport formal_ml.characteristic\nimport data.equiv.list\n\n\nlemma measure_theory.measure_unmeasurable {α:Type*} [M:measurable_space α] \n(μ:measure_theory.measure α)\n(S:set α):\nμ S = ⨅ (t : set α) (st : S ⊆ t) (ht : measurable_set t), μ t :=\nbegin\n  have h1:μ S = μ.to_outer_measure.trim S,\n  { rw μ.trimmed,  rw measure_theory.to_outer_measure_apply },\n  rw measure_theory.outer_measure.trim_eq_infi at h1,\n  apply h1,\nend\n\n\nlemma measure_theory.measurable_sequence {α:Type*} [M:measurable_space α] \n(μ:measure_theory.measure α)\n(S:set α):\n(μ S ≠ ⊤) →\n∃ (f:ℕ → set α),\n∀ n, measurable_set (f n) ∧ (S ⊆ f n) ∧ μ (f n) ≤ ((μ S) + (1)/((n:ennreal) + 1)) :=   \nbegin\n  intros h1,\n  \n  have h2 : μ S = ⨅ (t : set α) (st : S ⊆ t) (ht : measurable_set t), μ t,\n  { apply measure_theory.measure_unmeasurable },\n  rw ←  ennreal.lt_top_iff_ne_top at h1,\n  have h4 := h1,\n \n   rw h2 at h1,\n  have h:∀ (n:ℕ), ∃ (T:set α), measurable_set T ∧ (S ⊆ T) ∧ \n          μ T ≤ ((μ S) + (1)/((n:ennreal) + 1)),\n  { intros n,\n    have h3_4 : μ S + ((n:ennreal) + 1)⁻¹ < ⊤,\n    { rw ennreal.add_lt_top,  split, apply h4,\n      simp, apply ennreal.add_pos_of_pos, apply ennreal.zero_lt_one },\n    have h3_1:0< (1)/((n:nnreal) + 1) := nnreal.unit_frac_pos n,\n    have h3_2:= @ennreal.le_of_infi _ _ ((1)/((n:nnreal) + 1)) h1 h3_1,\n    cases h3_2 with t h3_2,\n    simp at h3_2,\n    rw ← h2 at h3_2,\n    have h3_5 : S ⊆ t,\n    { apply ennreal.infi_prop_le_elim (S ⊆ t),\n      apply lt_of_le_of_lt h3_2,\n      apply h3_4, }, \n    rw infi_prop_def at h3_2,\n    --apply h3_5,\n    have h3_6 : measurable_set t,\n    { apply ennreal.infi_prop_le_elim (measurable_set t),\n      apply lt_of_le_of_lt h3_2,\n      apply h3_4, }, \n    rw infi_prop_def at h3_2,\n    apply exists.intro t,\n    split,\n    apply h3_6,\n    split,\n    apply h3_5,\n    --simp, \n    have h3_7:1 / ((n:ennreal) + 1) = ((n:ennreal) + 1)⁻¹,\n    { rw ennreal.one_div, },\n    rw h3_7,\n    apply h3_2,\n    apply h3_6,\n    apply h3_5 },\n  rw classical.skolem at h,\n  apply h,--sorry\nend\n\n\nlemma measure_theory.measurable_eq {α:Type*} [M:measurable_space α]\n(μ:measure_theory.measure α) (S:set α):∃ T:set α, \nmeasurable_set T ∧ μ T = μ S ∧ S ⊆ T := \nbegin\n  have h1:μ S = μ.to_outer_measure.trim S,\n  { rw μ.trimmed,  rw measure_theory.to_outer_measure_apply },\n  rw measure_theory.outer_measure.trim_eq_infi at h1,\n  --rw h1,\n  have h2 : ((μ S) = (⊤:ennreal)) ∨ ((μ S) ≠ (⊤:ennreal)),\n  { apply em },\n  cases h2,\n  { apply exists.intro set.univ, split,\n    apply measurable_set.univ, split,\n    rw h2, rw ← top_le_iff, \n    rw ← h2, apply measure_theory.measure_mono, simp, simp },\n  { have h3 := measure_theory.measurable_sequence μ S h2,\n    cases h3 with f h3,\n    have h7:S ⊆ ⋂ (n:ℕ), f n,\n    { rw set.subset_Inter_iff, intro n, apply (h3 n).right.left },\n    apply exists.intro (⋂ n, f n),\n    split,\n    apply measurable_set.Inter,\n    apply (λ n, (h3 n).left),\n    split,\n    apply le_antisymm,\n    { apply ennreal.le_of_forall_pos_le_add,\n      intros ε h4 h5,\n      have h6 := nnreal.exists_unit_frac_lt_pos h4,\n      cases h6 with n h6,\n      apply @le_trans _ _ _ (μ (f n)),\n      apply measure_theory.measure_mono, apply set.Inter_subset,\n      --apply le_ _,\n      apply le_trans ((h3 n).right.right),\n      --apply ennreal.le_of_add_le_add_left,\n      --apply h5,\n      \n      apply @add_le_add_left ennreal _ _, \n      apply le_of_lt _,\n      \n      rw ← ennreal.coe_one,\n      have C8A1:(n:ennreal) = ((n:nnreal):ennreal),\n      { simp },\n      rw C8A1,\n      rw ← ennreal.coe_add,\n      rw ← ennreal.coe_div,\n      rw ennreal.coe_lt_coe,\n      apply h6,\n      simp },\n      apply measure_theory.measure_mono,\n      apply h7,\n      apply h7 },\nend \n\n/--\n  This is like measure_theory.measure_eq_inter_diff, but leverages measure_theory.le_to_outer_measure_caratheodory,  which could be considered an implementation detail.\n -/\nlemma measure_theory.measure_eq_inter_diff' {α:Type*} [M:measurable_space α] \n  {μ:measure_theory.measure α} {s t:set α}:measurable_set t → μ s = μ (s ∩ t) + μ (s \\ t) :=\nbegin\n  intros A1,\n  have A2:M ≤ μ.to_outer_measure.caratheodory := measure_theory.le_to_outer_measure_caratheodory μ,\n  have A3:μ.to_outer_measure.caratheodory.measurable_set' t,\n  {apply A2,apply A1},\n  rw measure_theory.outer_measure.is_caratheodory_iff at A3,\n  apply A3,\nend  \n\n\n\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/measure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.458850969711206}}
{"text": "def is_smooth {α β} (f : α → β) : Prop := sorry\n\nclass IsSmooth {α β} (f : α → β) : Prop where\n  (proof : is_smooth f)\n\ninstance identity : IsSmooth fun a : α => a := sorry\ninstance const (b : β) : IsSmooth fun a : α => b := sorry\ninstance swap (f : α → β → γ) [∀ a, IsSmooth (f a)] : IsSmooth (λ b a => f a b) := sorry\ninstance parm (f : α → β → γ) [IsSmooth f] (b : β) : IsSmooth (λ a => f a b) := sorry\ninstance comp (f : β → γ) (g : α → β) [IsSmooth f] [IsSmooth g] : IsSmooth (fun a => f (g a)) := sorry\ninstance diag (f : β → δ → γ) (g : α → β) (h : α → δ) [IsSmooth f] [∀ b, IsSmooth (f b)] [IsSmooth g] [IsSmooth h] : IsSmooth (λ a => f (g a) (h a)) := sorry\n\nset_option trace.Meta.synthInstance true\nset_option trace.Meta.synthInstance.globalInstances false\nset_option trace.Meta.synthInstance.newSubgoal false\nset_option trace.Meta.synthInstance.tryResolve false\nset_option trace.Meta.synthInstance.resume false\nset_option trace.Meta.synthInstance.generate false\nset_option trace.Meta.synthInstance.newAnswer false\nset_option trace.Meta.synthInstance.unusedArgs true\nexample (f : β → δ → γ) [IsSmooth f] (d : δ) : IsSmooth (λ (g : α → β) a => f (g a) d) := by infer_instance\n", "meta": {"author": "Kha", "repo": "lean4-nightly", "sha": "b4c92de57090e6c47b29d3575df53d86fce52752", "save_path": "github-repos/lean/Kha-lean4-nightly", "path": "github-repos/lean/Kha-lean4-nightly/lean4-nightly-b4c92de57090e6c47b29d3575df53d86fce52752/tests/lean/815b.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.4588509645484036}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.adjunction.lifting\n! leanprover-community/mathlib commit 9bc7dfa6e50f902fb0684c9670a680459ebaed68\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Shapes.Equalizers\nimport Mathbin.CategoryTheory.Limits.Shapes.Reflexive\nimport Mathbin.CategoryTheory.Monad.Adjunction\nimport Mathbin.CategoryTheory.Monad.Coequalizer\n\n/-!\n# Adjoint lifting\n\nThis file gives two constructions for building left adjoints: the adjoint triangle theorem and the\nadjoint lifting theorem.\nThe adjoint triangle theorem says that given a functor `U : B ⥤ C` with a left adjoint `F` such\nthat `ε_X : FUX ⟶ X` is a regular epi. Then for any category `A` with coequalizers of reflexive\npairs, a functor `R : A ⥤ B` has a left adjoint if (and only if) the composite `R ⋙ U` does.\nNote that the condition on `U` regarding `ε_X` is automatically satisfied in the case when `U` is\na monadic functor, giving the corollary: `monadic_adjoint_triangle_lift`, i.e. if `U` is monadic,\n`A` has reflexive coequalizers then `R : A ⥤ B` has a left adjoint provided `R ⋙ U` does.\n\nThe adjoint lifting theorem says that given a commutative square of functors (up to isomorphism):\n\n      Q\n    A → B\n  U ↓   ↓ V\n    C → D\n      R\n\nwhere `U` and `V` are monadic and `A` has reflexive coequalizers, then if `R` has a left adjoint\nthen `Q` has a left adjoint.\n\n## Implementation\n\nIt is more convenient to prove this theorem by assuming we are given the explicit adjunction rather\nthan just a functor known to be a right adjoint. In docstrings, we write `(η, ε)` for the unit\nand counit of the adjunction `adj₁ : F ⊣ U` and `(ι, δ)` for the unit and counit of the adjunction\n`adj₂ : F' ⊣ R ⋙ U`.\n\n## TODO\n\nDualise to lift right adjoints through comonads (by reversing 1-cells) and dualise to lift right\nadjoints through monads (by reversing 2-cells), and the combination.\n\n## References\n* https://ncatlab.org/nlab/show/adjoint+triangle+theorem\n* https://ncatlab.org/nlab/show/adjoint+lifting+theorem\n* Adjoint Lifting Theorems for Categories of Algebras (PT Johnstone, 1975)\n* A unified approach to the lifting of adjoints (AJ Power, 1988)\n-/\n\n\nnamespace CategoryTheory\n\nopen Category Limits\n\nuniverse v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄\n\nvariable {A : Type u₁} {B : Type u₂} {C : Type u₃}\n\nvariable [Category.{v₁} A] [Category.{v₂} B] [Category.{v₃} C]\n\n-- Hide implementation details in this namespace\nnamespace LiftAdjoint\n\nvariable {U : B ⥤ C} {F : C ⥤ B} (R : A ⥤ B) (F' : C ⥤ A)\n\nvariable (adj₁ : F ⊣ U) (adj₂ : F' ⊣ R ⋙ U)\n\n/-- To show that `ε_X` is a coequalizer for `(FUε_X, ε_FUX)`, it suffices to assume it's always a\ncoequalizer of something (i.e. a regular epi).\n-/\ndef counitCoequalises [∀ X : B, RegularEpi (adj₁.counit.app X)] (X : B) :\n    IsColimit (Cofork.ofπ (adj₁.counit.app X) (adj₁.counit_naturality _)) :=\n  Cofork.IsColimit.mk' _ fun s =>\n    by\n    refine' ⟨(regular_epi.desc' (adj₁.counit.app X) s.π _).1, _, _⟩\n    · rw [← cancel_epi (adj₁.counit.app (regular_epi.W (adj₁.counit.app X)))]\n      rw [← adj₁.counit_naturality_assoc]\n      dsimp only [functor.comp_obj]\n      rw [← s.condition, ← F.map_comp_assoc, ← U.map_comp, regular_epi.w, U.map_comp,\n        F.map_comp_assoc, s.condition, ← adj₁.counit_naturality_assoc]\n    · apply (regular_epi.desc' (adj₁.counit.app X) s.π _).2\n    · intro m hm\n      rw [← cancel_epi (adj₁.counit.app X)]\n      apply hm.trans (regular_epi.desc' (adj₁.counit.app X) s.π _).2.symm\n#align category_theory.lift_adjoint.counit_coequalises CategoryTheory.LiftAdjoint.counitCoequalises\n\ninclude adj₁ adj₂\n\n/-- (Implementation)\nTo construct the left adjoint, we use the coequalizer of `F' U ε_Y` with the composite\n\n`F' U F U X ⟶ F' U F U R F U' X ⟶ F' U R F' U X ⟶ F' U X`\n\nwhere the first morphism is `F' U F ι_UX`, the second is `F' U ε_RF'UX`, and the third is `δ_F'UX`.\nWe will show that this coequalizer exists and that it forms the object map for a left adjoint to\n`R`.\n-/\ndef otherMap (X) : F'.obj (U.obj (F.obj (U.obj X))) ⟶ F'.obj (U.obj X) :=\n  F'.map (U.map (F.map (adj₂.Unit.app _) ≫ adj₁.counit.app _)) ≫ adj₂.counit.app _\n#align category_theory.lift_adjoint.other_map CategoryTheory.LiftAdjoint.otherMap\n\n/--\n`(F'Uε_X, other_map X)` is a reflexive pair: in particular if `A` has reflexive coequalizers then\nit has a coequalizer.\n-/\ninstance (X : B) :\n    IsReflexivePair (F'.map (U.map (adj₁.counit.app X))) (otherMap _ _ adj₁ adj₂ X) :=\n  IsReflexivePair.mk' (F'.map (adj₁.Unit.app (U.obj X)))\n    (by\n      rw [← F'.map_comp, adj₁.right_triangle_components]\n      apply F'.map_id)\n    (by\n      dsimp [other_map]\n      rw [← F'.map_comp_assoc, U.map_comp, adj₁.unit_naturality_assoc,\n        adj₁.right_triangle_components, comp_id, adj₂.left_triangle_components])\n\nvariable [HasReflexiveCoequalizers A]\n\n/-- Construct the object part of the desired left adjoint as the coequalizer of `F'Uε_Y` with\n`other_map`.\n-/\nnoncomputable def constructLeftAdjointObj (Y : B) : A :=\n  coequalizer (F'.map (U.map (adj₁.counit.app Y))) (otherMap _ _ adj₁ adj₂ Y)\n#align category_theory.lift_adjoint.construct_left_adjoint_obj CategoryTheory.LiftAdjoint.constructLeftAdjointObj\n\n/-- The homset equivalence which helps show that `R` is a right adjoint. -/\n@[simps (config := { rhsMd := semireducible })]\nnoncomputable def constructLeftAdjointEquiv [∀ X : B, RegularEpi (adj₁.counit.app X)] (Y : A)\n    (X : B) : (constructLeftAdjointObj _ _ adj₁ adj₂ X ⟶ Y) ≃ (X ⟶ R.obj Y) :=\n  calc\n    (constructLeftAdjointObj _ _ adj₁ adj₂ X ⟶ Y) ≃\n        { f : F'.obj (U.obj X) ⟶ Y //\n          F'.map (U.map (adj₁.counit.app X)) ≫ f = otherMap _ _ adj₁ adj₂ _ ≫ f } :=\n      Cofork.IsColimit.homIso (colimit.isColimit _) _\n    _ ≃\n        { g : U.obj X ⟶ U.obj (R.obj Y) //\n          U.map (F.map g ≫ adj₁.counit.app _) = U.map (adj₁.counit.app _) ≫ g } :=\n      by\n      apply (adj₂.hom_equiv _ _).subtypeEquiv _\n      intro f\n      rw [← (adj₂.hom_equiv _ _).Injective.eq_iff, eq_comm, adj₂.hom_equiv_naturality_left,\n        other_map, assoc, adj₂.hom_equiv_naturality_left, ← adj₂.counit_naturality,\n        adj₂.hom_equiv_naturality_left, adj₂.hom_equiv_unit, adj₂.right_triangle_components,\n        comp_id, functor.comp_map, ← U.map_comp, assoc, ← adj₁.counit_naturality,\n        adj₂.hom_equiv_unit, adj₂.hom_equiv_unit, F.map_comp, assoc]\n      rfl\n    _ ≃ { z : F.obj (U.obj X) ⟶ R.obj Y // _ } :=\n      by\n      apply (adj₁.hom_equiv _ _).symm.subtypeEquiv\n      intro g\n      rw [← (adj₁.hom_equiv _ _).symm.Injective.eq_iff, adj₁.hom_equiv_counit,\n        adj₁.hom_equiv_counit, adj₁.hom_equiv_counit, F.map_comp, assoc, U.map_comp, F.map_comp,\n        assoc, adj₁.counit_naturality, adj₁.counit_naturality_assoc]\n      apply eq_comm\n    _ ≃ (X ⟶ R.obj Y) := (Cofork.IsColimit.homIso (counitCoequalises adj₁ X) _).symm\n    \n#align category_theory.lift_adjoint.construct_left_adjoint_equiv CategoryTheory.LiftAdjoint.constructLeftAdjointEquiv\n\n/-- Construct the left adjoint to `R`, with object map `construct_left_adjoint_obj`. -/\nnoncomputable def constructLeftAdjoint [∀ X : B, RegularEpi (adj₁.counit.app X)] : B ⥤ A :=\n  by\n  refine'\n    adjunction.left_adjoint_of_equiv (fun X Y => construct_left_adjoint_equiv R _ adj₁ adj₂ Y X) _\n  intro X Y Y' g h\n  rw [construct_left_adjoint_equiv_apply, construct_left_adjoint_equiv_apply, Function.comp_apply,\n    Function.comp_apply, Equiv.trans_apply, Equiv.trans_apply, Equiv.trans_apply, Equiv.trans_apply,\n    Equiv.symm_apply_eq, Subtype.ext_iff, cofork.is_colimit.hom_iso_natural, Equiv.apply_symm_apply,\n    Equiv.subtypeEquiv_apply, Equiv.subtypeEquiv_apply, Equiv.subtypeEquiv_apply,\n    Equiv.subtypeEquiv_apply, Subtype.coe_mk, Subtype.coe_mk, Subtype.coe_mk, Subtype.coe_mk, ←\n    adj₁.hom_equiv_naturality_right_symm, cofork.is_colimit.hom_iso_natural,\n    adj₂.hom_equiv_naturality_right, functor.comp_map]\n#align category_theory.lift_adjoint.construct_left_adjoint CategoryTheory.LiftAdjoint.constructLeftAdjoint\n\nend LiftAdjoint\n\n/-- The adjoint triangle theorem: Suppose `U : B ⥤ C` has a left adjoint `F` such that each counit\n`ε_X : FUX ⟶ X` is a regular epimorphism. Then if a category `A` has coequalizers of reflexive\npairs, then a functor `R : A ⥤ B` has a left adjoint if the composite `R ⋙ U` does.\n\nNote the converse is true (with weaker assumptions), by `adjunction.comp`.\nSee https://ncatlab.org/nlab/show/adjoint+triangle+theorem\n-/\nnoncomputable def adjointTriangleLift {U : B ⥤ C} {F : C ⥤ B} (R : A ⥤ B) (adj₁ : F ⊣ U)\n    [∀ X : B, RegularEpi (adj₁.counit.app X)] [HasReflexiveCoequalizers A]\n    [IsRightAdjoint (R ⋙ U)] : IsRightAdjoint R\n    where\n  left := LiftAdjoint.constructLeftAdjoint R _ adj₁ (Adjunction.ofRightAdjoint _)\n  adj := Adjunction.adjunctionOfEquivLeft _ _\n#align category_theory.adjoint_triangle_lift CategoryTheory.adjointTriangleLift\n\n/-- If `R ⋙ U` has a left adjoint, the domain of `R` has reflexive coequalizers and `U` is a monadic\nfunctor, then `R` has a left adjoint.\nThis is a special case of `adjoint_triangle_lift` which is often more useful in practice.\n-/\nnoncomputable def monadicAdjointTriangleLift (U : B ⥤ C) [MonadicRightAdjoint U] {R : A ⥤ B}\n    [HasReflexiveCoequalizers A] [IsRightAdjoint (R ⋙ U)] : IsRightAdjoint R :=\n  by\n  let R' : A ⥤ _ := R ⋙ monad.comparison (adjunction.of_right_adjoint U)\n  rsuffices : is_right_adjoint R'\n  · let this : is_right_adjoint (R' ⋙ (monad.comparison (adjunction.of_right_adjoint U)).inv) := by\n      infer_instance\n    · let this : R' ⋙ (monad.comparison (adjunction.of_right_adjoint U)).inv ≅ R :=\n        (iso_whisker_left R (monad.comparison _).asEquivalence.unitIso.symm : _) ≪≫ R.right_unitor\n      exact adjunction.right_adjoint_of_nat_iso this\n  let this : is_right_adjoint (R' ⋙ monad.forget (adjunction.of_right_adjoint U).toMonad) :=\n    adjunction.right_adjoint_of_nat_iso\n      (iso_whisker_left R (monad.comparison_forget (adjunction.of_right_adjoint U)).symm : _)\n  let this : ∀ X, regular_epi ((monad.adj (adjunction.of_right_adjoint U).toMonad).counit.app X) :=\n    by\n    intro X\n    simp only [monad.adj_counit]\n    exact ⟨_, _, _, _, monad.beck_algebra_coequalizer X⟩\n  exact adjoint_triangle_lift R' (monad.adj _)\n#align category_theory.monadic_adjoint_triangle_lift CategoryTheory.monadicAdjointTriangleLift\n\nvariable {D : Type u₄}\n\nvariable [Category.{v₄} D]\n\n/-- Suppose we have a commutative square of functors\n\n      Q\n    A → B\n  U ↓   ↓ V\n    C → D\n      R\n\nwhere `U` has a left adjoint, `A` has reflexive coequalizers and `V` has a left adjoint such that\neach component of the counit is a regular epi.\nThen `Q` has a left adjoint if `R` has a left adjoint.\n\nSee https://ncatlab.org/nlab/show/adjoint+lifting+theorem\n-/\nnoncomputable def adjointSquareLift (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (R : C ⥤ D)\n    (comm : U ⋙ R ≅ Q ⋙ V) [IsRightAdjoint U] [IsRightAdjoint V] [IsRightAdjoint R]\n    [∀ X, RegularEpi ((Adjunction.ofRightAdjoint V).counit.app X)] [HasReflexiveCoequalizers A] :\n    IsRightAdjoint Q :=\n  by\n  let this := adjunction.right_adjoint_of_nat_iso comm\n  exact adjoint_triangle_lift Q (adjunction.of_right_adjoint V)\n#align category_theory.adjoint_square_lift CategoryTheory.adjointSquareLift\n\n/-- Suppose we have a commutative square of functors\n\n      Q\n    A → B\n  U ↓   ↓ V\n    C → D\n      R\n\nwhere `U` has a left adjoint, `A` has reflexive coequalizers and `V` is monadic.\nThen `Q` has a left adjoint if `R` has a left adjoint.\n\nSee https://ncatlab.org/nlab/show/adjoint+lifting+theorem\n-/\nnoncomputable def monadicAdjointSquareLift (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (R : C ⥤ D)\n    (comm : U ⋙ R ≅ Q ⋙ V) [IsRightAdjoint U] [MonadicRightAdjoint V] [IsRightAdjoint R]\n    [HasReflexiveCoequalizers A] : IsRightAdjoint Q :=\n  by\n  let this := adjunction.right_adjoint_of_nat_iso comm\n  exact monadic_adjoint_triangle_lift V\n#align category_theory.monadic_adjoint_square_lift CategoryTheory.monadicAdjointSquareLift\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Adjunction/Lifting.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.45883786260447895}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport category_theory.category.Bipointed\nimport order.category.PartialOrder\nimport order.hom.bounded\n\n/-!\n# The category of bounded orders\n\nThis defines `BoundedOrder`, the category of bounded orders.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of bounded orders with monotone functions. -/\nstructure BoundedOrder :=\n(to_PartialOrder : PartialOrder)\n[is_bounded_order : bounded_order to_PartialOrder]\n\nnamespace BoundedOrder\n\ninstance : has_coe_to_sort BoundedOrder Type* := induced_category.has_coe_to_sort to_PartialOrder\ninstance (X : BoundedOrder) : partial_order X := X.to_PartialOrder.str\n\nattribute [instance]  BoundedOrder.is_bounded_order\n\n/-- Construct a bundled `BoundedOrder` from a `fintype` `partial_order`. -/\ndef of (α : Type*) [partial_order α] [bounded_order α] : BoundedOrder := ⟨⟨α⟩⟩\n\n@[simp] lemma coe_of (α : Type*) [partial_order α] [bounded_order α] : ↥(of α) = α := rfl\n\ninstance : inhabited BoundedOrder := ⟨of punit⟩\n\ninstance large_category : large_category.{u} BoundedOrder :=\n{ hom := λ X Y, bounded_order_hom X Y,\n  id := λ X, bounded_order_hom.id X,\n  comp := λ X Y Z f g, g.comp f,\n  id_comp' := λ X Y, bounded_order_hom.comp_id,\n  comp_id' := λ X Y, bounded_order_hom.id_comp,\n  assoc' := λ W X Y Z _ _ _, bounded_order_hom.comp_assoc _ _ _ }\n\ninstance concrete_category : concrete_category BoundedOrder :=\n{ forget := ⟨coe_sort, λ X Y, coe_fn, λ X, rfl, λ X Y Z f g, rfl⟩,\n  forget_faithful := ⟨λ X Y, by convert fun_like.coe_injective⟩ }\n\ninstance has_forget_to_PartialOrder : has_forget₂ BoundedOrder PartialOrder :=\n{ forget₂ := { obj := λ X, X.to_PartialOrder, map := λ X Y, bounded_order_hom.to_order_hom } }\n\ninstance has_forget_to_Bipointed : has_forget₂ BoundedOrder Bipointed :=\n{ forget₂ := { obj := λ X, ⟨X, ⊥, ⊤⟩, map := λ X Y f, ⟨f, map_bot f, map_top f⟩ },\n  forget_comp := rfl }\n\n/-- `order_dual` as a functor. -/\n@[simps] def dual : BoundedOrder ⥤ BoundedOrder :=\n{ obj := λ X, of (order_dual X), map := λ X Y, bounded_order_hom.dual }\n\n/-- Constructs an equivalence between bounded orders from an order isomorphism between them. -/\n@[simps] def iso.mk {α β : BoundedOrder.{u}} (e : α ≃o β) : α ≅ β :=\n{ hom := e,\n  inv := e.symm,\n  hom_inv_id' := by { ext, exact e.symm_apply_apply _ },\n  inv_hom_id' := by { ext, exact e.apply_symm_apply _ } }\n\n/-- The equivalence between `BoundedOrder` and itself induced by `order_dual` both ways. -/\n@[simps functor inverse] def dual_equiv : BoundedOrder ≌ BoundedOrder :=\nequivalence.mk dual dual\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n\nend BoundedOrder\n\nlemma BoundedOrder_dual_comp_forget_to_PartialOrder :\n  BoundedOrder.dual ⋙ forget₂ BoundedOrder PartialOrder =\n    forget₂ BoundedOrder PartialOrder ⋙ PartialOrder.dual := rfl\n\nlemma BoundedOrder_dual_comp_forget_to_Bipointed :\n  BoundedOrder.dual ⋙ forget₂ BoundedOrder Bipointed =\n    forget₂ BoundedOrder Bipointed ⋙ Bipointed.swap := rfl\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/order/category/BoundedOrder.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6442251201477016, "lm_q1q2_score": 0.4588378565942714}}
{"text": "/-\nCopyright (c) 2020 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n\n! This file was ported from Lean 3 source module linear_algebra.tensor_algebra.basic\n! leanprover-community/mathlib commit b8d2eaa69d69ce8f03179a5cda774fc0cde984e4\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.FreeAlgebra\nimport Mathbin.Algebra.RingQuot\nimport Mathbin.Algebra.TrivSqZeroExt\nimport Mathbin.Algebra.Algebra.Operations\nimport Mathbin.LinearAlgebra.Multilinear.Basic\n\n/-!\n# Tensor Algebras\n\nGiven a commutative semiring `R`, and an `R`-module `M`, we construct the tensor algebra of `M`.\nThis is the free `R`-algebra generated (`R`-linearly) by the module `M`.\n\n## Notation\n\n1. `tensor_algebra R M` is the tensor algebra itself. It is endowed with an R-algebra structure.\n2. `tensor_algebra.ι R` is the canonical R-linear map `M → tensor_algebra R M`.\n3. Given a linear map `f : M → A` to an R-algebra `A`, `lift R f` is the lift of `f` to an\n  `R`-algebra morphism `tensor_algebra R M → A`.\n\n## Theorems\n\n1. `ι_comp_lift` states that the composition `(lift R f) ∘ (ι R)` is identical to `f`.\n2. `lift_unique` states that whenever an R-algebra morphism `g : tensor_algebra R M → A` is\n  given whose composition with `ι R` is `f`, then one has `g = lift R f`.\n3. `hom_ext` is a variant of `lift_unique` in the form of an extensionality theorem.\n4. `lift_comp_ι` is a combination of `ι_comp_lift` and `lift_unique`. It states that the lift\n  of the composition of an algebra morphism with `ι` is the algebra morphism itself.\n\n## Implementation details\n\nAs noted above, the tensor algebra of `M` is constructed as the free `R`-algebra generated by `M`,\nmodulo the additional relations making the inclusion of `M` into an `R`-linear map.\n-/\n\n\nvariable (R : Type _) [CommSemiring R]\n\nvariable (M : Type _) [AddCommMonoid M] [Module R M]\n\nnamespace TensorAlgebra\n\n/-- An inductively defined relation on `pre R M` used to force the initial algebra structure on\nthe associated quotient.\n-/\ninductive Rel : FreeAlgebra R M → FreeAlgebra R M → Prop-- force `ι` to be linear\n\n  | add {a b : M} : Rel (FreeAlgebra.ι R (a + b)) (FreeAlgebra.ι R a + FreeAlgebra.ι R b)\n  |\n  smul {r : R} {a : M} :\n    Rel (FreeAlgebra.ι R (r • a)) (algebraMap R (FreeAlgebra R M) r * FreeAlgebra.ι R a)\n#align tensor_algebra.rel TensorAlgebra.Rel\n\nend TensorAlgebra\n\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler algebra[algebra] R -/\n/-- The tensor algebra of the module `M` over the commutative semiring `R`.\n-/\ndef TensorAlgebra :=\n  RingQuot (TensorAlgebra.Rel R M)deriving Inhabited, Semiring,\n  «./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler algebra[algebra] R»\n#align tensor_algebra TensorAlgebra\n\nnamespace TensorAlgebra\n\ninstance {S : Type _} [CommRing S] [Module S M] : Ring (TensorAlgebra S M) :=\n  RingQuot.ring (Rel S M)\n\nvariable {M}\n\n/-- The canonical linear map `M →ₗ[R] tensor_algebra R M`.\n-/\nirreducible_def ι : M →ₗ[R] TensorAlgebra R M :=\n  { toFun := fun m => RingQuot.mkAlgHom R _ (FreeAlgebra.ι R m)\n    map_add' := fun x y => by\n      rw [← AlgHom.map_add]\n      exact RingQuot.mkAlgHom_rel R rel.add\n    map_smul' := fun r x => by\n      rw [← AlgHom.map_smul]\n      exact RingQuot.mkAlgHom_rel R rel.smul }\n#align tensor_algebra.ι TensorAlgebra.ι\n\ntheorem ringQuot_mkAlgHom_freeAlgebra_ι_eq_ι (m : M) :\n    RingQuot.mkAlgHom R (Rel R M) (FreeAlgebra.ι R m) = ι R m :=\n  by\n  rw [ι]\n  rfl\n#align tensor_algebra.ring_quot_mk_alg_hom_free_algebra_ι_eq_ι TensorAlgebra.ringQuot_mkAlgHom_freeAlgebra_ι_eq_ι\n\n/-- Given a linear map `f : M → A` where `A` is an `R`-algebra, `lift R f` is the unique lift\nof `f` to a morphism of `R`-algebras `tensor_algebra R M → A`.\n-/\n@[simps symm_apply]\nirreducible_def lift {A : Type _} [Semiring A] [Algebra R A] :\n  (M →ₗ[R] A) ≃ (TensorAlgebra R M →ₐ[R] A) :=\n  { toFun :=\n      RingQuot.liftAlgHom R ∘ fun f =>\n        ⟨FreeAlgebra.lift R ⇑f, fun x y (h : Rel R M x y) => by\n          induction h <;>\n            simp only [Algebra.smul_def, FreeAlgebra.lift_ι_apply, LinearMap.map_smulₛₗ,\n              RingHom.id_apply, map_mul, AlgHom.commutes, map_add]⟩\n    invFun := fun F => F.toLinearMap.comp (ι R)\n    left_inv := fun f => by\n      rw [ι]\n      ext1 x\n      exact (RingQuot.liftAlgHom_mkAlgHom_apply _ _ _ _).trans (FreeAlgebra.lift_ι_apply f x)\n    right_inv := fun F =>\n      RingQuot.ringQuot_ext' _ _ _ <|\n        FreeAlgebra.hom_ext <|\n          funext fun x => by\n            rw [ι]\n            exact\n              (RingQuot.liftAlgHom_mkAlgHom_apply _ _ _ _).trans (FreeAlgebra.lift_ι_apply _ _) }\n#align tensor_algebra.lift TensorAlgebra.lift\n\nvariable {R}\n\n@[simp]\ntheorem ι_comp_lift {A : Type _} [Semiring A] [Algebra R A] (f : M →ₗ[R] A) :\n    (lift R f).toLinearMap.comp (ι R) = f :=\n  by\n  convert(lift R).symm_apply_apply f\n  simp only [lift, Equiv.coe_fn_symm_mk]\n#align tensor_algebra.ι_comp_lift TensorAlgebra.ι_comp_lift\n\n@[simp]\ntheorem lift_ι_apply {A : Type _} [Semiring A] [Algebra R A] (f : M →ₗ[R] A) (x) :\n    lift R f (ι R x) = f x := by\n  conv_rhs => rw [← ι_comp_lift f]\n  rfl\n#align tensor_algebra.lift_ι_apply TensorAlgebra.lift_ι_apply\n\n@[simp]\ntheorem lift_unique {A : Type _} [Semiring A] [Algebra R A] (f : M →ₗ[R] A)\n    (g : TensorAlgebra R M →ₐ[R] A) : g.toLinearMap.comp (ι R) = f ↔ g = lift R f :=\n  by\n  rw [← (lift R).symm_apply_eq]\n  simp only [lift, Equiv.coe_fn_symm_mk]\n#align tensor_algebra.lift_unique TensorAlgebra.lift_unique\n\n-- Marking `tensor_algebra` irreducible makes `ring` instances inaccessible on quotients.\n-- https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/algebra.2Esemiring_to_ring.20breaks.20semimodule.20typeclass.20lookup/near/212580241\n-- For now, we avoid this by not marking it irreducible.\n@[simp]\ntheorem lift_comp_ι {A : Type _} [Semiring A] [Algebra R A] (g : TensorAlgebra R M →ₐ[R] A) :\n    lift R (g.toLinearMap.comp (ι R)) = g :=\n  by\n  rw [← lift_symm_apply]\n  exact (lift R).apply_symm_apply g\n#align tensor_algebra.lift_comp_ι TensorAlgebra.lift_comp_ι\n\n/-- See note [partially-applied ext lemmas]. -/\n@[ext]\ntheorem hom_ext {A : Type _} [Semiring A] [Algebra R A] {f g : TensorAlgebra R M →ₐ[R] A}\n    (w : f.toLinearMap.comp (ι R) = g.toLinearMap.comp (ι R)) : f = g :=\n  by\n  rw [← lift_symm_apply, ← lift_symm_apply] at w\n  exact (lift R).symm.Injective w\n#align tensor_algebra.hom_ext TensorAlgebra.hom_ext\n\n-- This proof closely follows `free_algebra.induction`\n/-- If `C` holds for the `algebra_map` of `r : R` into `tensor_algebra R M`, the `ι` of `x : M`,\nand is preserved under addition and muliplication, then it holds for all of `tensor_algebra R M`.\n-/\n@[elab_as_elim]\ntheorem induction {C : TensorAlgebra R M → Prop}\n    (h_grade0 : ∀ r, C (algebraMap R (TensorAlgebra R M) r)) (h_grade1 : ∀ x, C (ι R x))\n    (h_mul : ∀ a b, C a → C b → C (a * b)) (h_add : ∀ a b, C a → C b → C (a + b))\n    (a : TensorAlgebra R M) : C a :=\n  by\n  -- the arguments are enough to construct a subalgebra, and a mapping into it from M\n  let s : Subalgebra R (TensorAlgebra R M) :=\n    { carrier := C\n      mul_mem' := h_mul\n      add_mem' := h_add\n      algebraMap_mem' := h_grade0 }\n  let of : M →ₗ[R] s := (ι R).codRestrict s.to_submodule h_grade1\n  -- the mapping through the subalgebra is the identity\n  have of_id : AlgHom.id R (TensorAlgebra R M) = s.val.comp (lift R of) :=\n    by\n    ext\n    simp [of]\n  -- finding a proof is finding an element of the subalgebra\n  convert Subtype.prop (lift R of a)\n  exact AlgHom.congr_fun of_id a\n#align tensor_algebra.induction TensorAlgebra.induction\n\n/-- The left-inverse of `algebra_map`. -/\ndef algebraMapInv : TensorAlgebra R M →ₐ[R] R :=\n  lift R (0 : M →ₗ[R] R)\n#align tensor_algebra.algebra_map_inv TensorAlgebra.algebraMapInv\n\nvariable (M)\n\ntheorem algebraMap_leftInverse :\n    Function.LeftInverse algebraMapInv (algebraMap R <| TensorAlgebra R M) := fun x => by\n  simp [algebra_map_inv]\n#align tensor_algebra.algebra_map_left_inverse TensorAlgebra.algebraMap_leftInverse\n\n@[simp]\ntheorem algebraMap_inj (x y : R) :\n    algebraMap R (TensorAlgebra R M) x = algebraMap R (TensorAlgebra R M) y ↔ x = y :=\n  (algebraMap_leftInverse M).Injective.eq_iff\n#align tensor_algebra.algebra_map_inj TensorAlgebra.algebraMap_inj\n\n@[simp]\ntheorem algebraMap_eq_zero_iff (x : R) : algebraMap R (TensorAlgebra R M) x = 0 ↔ x = 0 :=\n  map_eq_zero_iff (algebraMap _ _) (algebraMap_leftInverse _).Injective\n#align tensor_algebra.algebra_map_eq_zero_iff TensorAlgebra.algebraMap_eq_zero_iff\n\n@[simp]\ntheorem algebraMap_eq_one_iff (x : R) : algebraMap R (TensorAlgebra R M) x = 1 ↔ x = 1 :=\n  map_eq_one_iff (algebraMap _ _) (algebraMap_leftInverse _).Injective\n#align tensor_algebra.algebra_map_eq_one_iff TensorAlgebra.algebraMap_eq_one_iff\n\nvariable {M}\n\n/-- The canonical map from `tensor_algebra R M` into `triv_sq_zero_ext R M` that sends\n`tensor_algebra.ι` to `triv_sq_zero_ext.inr`. -/\ndef toTrivSqZeroExt [Module Rᵐᵒᵖ M] [IsCentralScalar R M] :\n    TensorAlgebra R M →ₐ[R] TrivSqZeroExt R M :=\n  lift R (TrivSqZeroExt.inrHom R M)\n#align tensor_algebra.to_triv_sq_zero_ext TensorAlgebra.toTrivSqZeroExt\n\n@[simp]\ntheorem toTrivSqZeroExt_ι (x : M) [Module Rᵐᵒᵖ M] [IsCentralScalar R M] :\n    toTrivSqZeroExt (ι R x) = TrivSqZeroExt.inr x :=\n  lift_ι_apply _ _\n#align tensor_algebra.to_triv_sq_zero_ext_ι TensorAlgebra.toTrivSqZeroExt_ι\n\n/-- The left-inverse of `ι`.\n\nAs an implementation detail, we implement this using `triv_sq_zero_ext` which has a suitable\nalgebra structure. -/\ndef ιInv : TensorAlgebra R M →ₗ[R] M :=\n  by\n  letI : Module Rᵐᵒᵖ M := Module.compHom _ ((RingHom.id R).fromOpposite mul_comm)\n  haveI : IsCentralScalar R M := ⟨fun r m => rfl⟩\n  exact (TrivSqZeroExt.sndHom R M).comp to_triv_sq_zero_ext.to_linear_map\n#align tensor_algebra.ι_inv TensorAlgebra.ιInv\n\ntheorem ι_leftInverse : Function.LeftInverse ιInv (ι R : M → TensorAlgebra R M) := fun x => by\n  simp [ι_inv]\n#align tensor_algebra.ι_left_inverse TensorAlgebra.ι_leftInverse\n\nvariable (R)\n\n@[simp]\ntheorem ι_inj (x y : M) : ι R x = ι R y ↔ x = y :=\n  ι_leftInverse.Injective.eq_iff\n#align tensor_algebra.ι_inj TensorAlgebra.ι_inj\n\n@[simp]\ntheorem ι_eq_zero_iff (x : M) : ι R x = 0 ↔ x = 0 := by rw [← ι_inj R x 0, LinearMap.map_zero]\n#align tensor_algebra.ι_eq_zero_iff TensorAlgebra.ι_eq_zero_iff\n\nvariable {R}\n\n@[simp]\ntheorem ι_eq_algebraMap_iff (x : M) (r : R) : ι R x = algebraMap R _ r ↔ x = 0 ∧ r = 0 :=\n  by\n  refine' ⟨fun h => _, _⟩\n  · letI : Module Rᵐᵒᵖ M := Module.compHom _ ((RingHom.id R).fromOpposite mul_comm)\n    haveI : IsCentralScalar R M := ⟨fun r m => rfl⟩\n    have hf0 : to_triv_sq_zero_ext (ι R x) = (0, x) := lift_ι_apply _ _\n    rw [h, AlgHom.commutes] at hf0\n    have : r = 0 ∧ 0 = x := Prod.ext_iff.1 hf0\n    exact this.symm.imp_left Eq.symm\n  · rintro ⟨rfl, rfl⟩\n    rw [LinearMap.map_zero, RingHom.map_zero]\n#align tensor_algebra.ι_eq_algebra_map_iff TensorAlgebra.ι_eq_algebraMap_iff\n\n@[simp]\ntheorem ι_ne_one [Nontrivial R] (x : M) : ι R x ≠ 1 :=\n  by\n  rw [← (algebraMap R (TensorAlgebra R M)).map_one, Ne.def, ι_eq_algebra_map_iff]\n  exact one_ne_zero ∘ And.right\n#align tensor_algebra.ι_ne_one TensorAlgebra.ι_ne_one\n\n/-- The generators of the tensor algebra are disjoint from its scalars. -/\ntheorem ι_range_disjoint_one :\n    Disjoint (LinearMap.range (ι R : M →ₗ[R] TensorAlgebra R M))\n      (1 : Submodule R (TensorAlgebra R M)) :=\n  by\n  rw [Submodule.disjoint_def]\n  rintro _ ⟨x, hx⟩ ⟨r, rfl : algebraMap _ _ _ = _⟩\n  rw [ι_eq_algebra_map_iff x] at hx\n  rw [hx.2, RingHom.map_zero]\n#align tensor_algebra.ι_range_disjoint_one TensorAlgebra.ι_range_disjoint_one\n\nvariable (R M)\n\n/-- Construct a product of `n` elements of the module within the tensor algebra.\n\nSee also `pi_tensor_product.tprod`. -/\ndef tprod (n : ℕ) : MultilinearMap R (fun i : Fin n => M) (TensorAlgebra R M) :=\n  (MultilinearMap.mkPiAlgebraFin R n (TensorAlgebra R M)).compLinearMap fun _ => ι R\n#align tensor_algebra.tprod TensorAlgebra.tprod\n\n@[simp]\ntheorem tprod_apply {n : ℕ} (x : Fin n → M) : tprod R M n x = (List.ofFn fun i => ι R (x i)).Prod :=\n  rfl\n#align tensor_algebra.tprod_apply TensorAlgebra.tprod_apply\n\nvariable {R M}\n\nend TensorAlgebra\n\nnamespace FreeAlgebra\n\nvariable {R M}\n\n/-- The canonical image of the `free_algebra` in the `tensor_algebra`, which maps\n`free_algebra.ι R x` to `tensor_algebra.ι R x`. -/\ndef toTensor : FreeAlgebra R M →ₐ[R] TensorAlgebra R M :=\n  FreeAlgebra.lift R (TensorAlgebra.ι R)\n#align free_algebra.to_tensor FreeAlgebra.toTensor\n\n@[simp]\ntheorem toTensor_ι (m : M) : (FreeAlgebra.ι R m).toTensor = TensorAlgebra.ι R m := by\n  simp [to_tensor]\n#align free_algebra.to_tensor_ι FreeAlgebra.toTensor_ι\n\nend FreeAlgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/LinearAlgebra/TensorAlgebra/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4588378547343552}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.images\nimport Mathlib.category_theory.limits.shapes.kernels\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# The morphism from `image f` to `kernel g` when `f ≫ g = 0`\n\nWe define the map, as the lift of `image.ι f` to `kernel g`,\nand check some basic properties:\n\n* this map is a monomorphism\n* given `A --0--> B --g--> C`, where `[mono g]`, this map is an epimorphism\n* given `A --f--> B --0--> C`, where `[epi f]`, this map is an epimorphism\n\nIn later files, we define the homology of complex as the cokernel of this map,\nand say a complex is exact at a point if this map is an epimorphism.\n-/\n\nnamespace category_theory\n\n\n/-!\nAt this point we assume that we have all images, and all equalizers.\nWe need to assume all equalizers, not just kernels, so that\n`factor_thru_image` is an epimorphism.\n-/\n\n/--\nThe morphism from `image f` to `kernel g` when `f ≫ g = 0`.\n-/\ndef image_to_kernel_map {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C) (w : f ≫ g = 0) : limits.image f ⟶ limits.kernel g :=\n  limits.kernel.lift g (limits.image.ι f) sorry\n\n@[simp] theorem image_to_kernel_map_zero_left {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (g : B ⟶ C) [limits.has_zero_object V] {w : 0 ≫ g = 0} : image_to_kernel_map 0 g w = 0 := sorry\n\ntheorem image_to_kernel_map_zero_right {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) {w : f ≫ 0 = 0} : image_to_kernel_map f 0 w = limits.image.ι f ≫ inv (limits.kernel.ι 0) := sorry\n\ntheorem image_to_kernel_map_comp_right {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C) {D : V} (h : C ⟶ D) (w : f ≫ g = 0) : image_to_kernel_map f (g ≫ h)\n    (eq.mpr\n      (id\n        (Eq.trans\n          ((fun (a a_1 : A ⟶ D) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ D) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n            (f ≫ g ≫ h) 0 (Eq.trans (reassoc_of w D h) limits.zero_comp) 0 0 (Eq.refl 0))\n          (propext (eq_self_iff_true 0))))\n      trivial) =\n  image_to_kernel_map f g w ≫\n    limits.kernel.lift (g ≫ h) (limits.kernel.ι g)\n      (eq.mpr\n        (id\n          (Eq.trans\n            ((fun (a a_1 : limits.kernel g ⟶ D) (e_1 : a = a_1) (ᾰ ᾰ_1 : limits.kernel g ⟶ D) (e_2 : ᾰ = ᾰ_1) =>\n                congr (congr_arg Eq e_1) e_2)\n              (limits.kernel.ι g ≫ g ≫ h) 0 (Eq.trans (limits.kernel.condition_assoc g h) limits.zero_comp) 0 0\n              (Eq.refl 0))\n            (propext (eq_self_iff_true 0))))\n        trivial) := sorry\n\ntheorem image_to_kernel_map_comp_left {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C) {Z : V} (h : Z ⟶ A) (w : f ≫ g = 0) : image_to_kernel_map (h ≫ f) g\n    (eq.mpr\n      (id\n        (Eq.trans\n          ((fun (a a_1 : Z ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : Z ⟶ C) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n            ((h ≫ f) ≫ g) 0\n            (Eq.trans\n              (Eq.trans (category.assoc h f g)\n                ((fun (ᾰ ᾰ_1 : Z ⟶ A) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : A ⟶ C) (e_2 : ᾰ_2 = ᾰ_3) =>\n                    congr (congr_arg category_struct.comp e_1) e_2)\n                  h h (Eq.refl h) (f ≫ g) 0 w))\n              limits.comp_zero)\n            0 0 (Eq.refl 0))\n          (propext (eq_self_iff_true 0))))\n      trivial) =\n  limits.image.pre_comp h f ≫ image_to_kernel_map f g w := sorry\n\n@[simp] theorem image_to_kernel_map_comp_iso {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C) {D : V} (h : C ⟶ D) [is_iso h] (w : f ≫ g ≫ h = 0) : image_to_kernel_map f (g ≫ h) w =\n  image_to_kernel_map f g\n      (iff.mp (cancel_mono h)\n        (eq.mpr\n          (id\n            ((fun (a a_1 : A ⟶ D) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ D) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n              ((f ≫ g) ≫ h) (f ≫ g ≫ h) (category.assoc f g h) (0 ≫ h) 0 limits.zero_comp))\n          (eq.mp (Eq.refl (f ≫ g ≫ h = 0)) w))) ≫\n    iso.inv (limits.kernel_comp_is_iso g h) := sorry\n\n@[simp] theorem image_to_kernel_map_iso_comp {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C) {Z : V} (h : Z ⟶ A) [is_iso h] (w : (h ≫ f) ≫ g = 0) : image_to_kernel_map (h ≫ f) g w =\n  limits.image.pre_comp h f ≫\n    image_to_kernel_map f g\n      (iff.mp (cancel_epi h)\n        (eq.mpr\n          (id\n            ((fun (a a_1 : Z ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : Z ⟶ C) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n              (h ≫ f ≫ g) (h ≫ f ≫ g) (Eq.refl (h ≫ f ≫ g)) (h ≫ 0) 0 limits.comp_zero))\n          (eq.mp\n            ((fun (a a_1 : Z ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : Z ⟶ C) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n              ((h ≫ f) ≫ g) (h ≫ f ≫ g) (category.assoc h f g) 0 0 (Eq.refl 0))\n            w))) := sorry\n\n@[simp] theorem image_to_kernel_map_comp_hom_inv_comp {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) (g : B ⟶ C) {Z : V} {i : B ≅ Z} (w : (f ≫ iso.hom i) ≫ iso.inv i ≫ g = 0) : image_to_kernel_map (f ≫ iso.hom i) (iso.inv i ≫ g) w =\n  iso.inv (limits.image.post_comp_is_iso f (iso.hom i)) ≫\n    image_to_kernel_map f g\n        (eq.mpr (id (Eq.refl (f ≫ g = 0)))\n          (eq.mp\n            ((fun (a a_1 : A ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ C) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2)\n              ((f ≫ iso.hom i) ≫ iso.inv i ≫ g) (f ≫ g)\n              (Eq.trans (category.assoc f (iso.hom i) (iso.inv i ≫ g))\n                ((fun (ᾰ ᾰ_1 : A ⟶ B) (e_1 : ᾰ = ᾰ_1) (ᾰ_2 ᾰ_3 : B ⟶ C) (e_2 : ᾰ_2 = ᾰ_3) =>\n                    congr (congr_arg category_struct.comp e_1) e_2)\n                  f f (Eq.refl f) (iso.hom i ≫ iso.inv i ≫ g) g (iso.hom_inv_id_assoc i g)))\n              0 0 (Eq.refl 0))\n            w)) ≫\n      iso.inv (limits.kernel_is_iso_comp (iso.inv i) g) := sorry\n\n/--\n`image_to_kernel_map` for `A --0--> B --g--> C`, where `[mono g]` is an epi\n(i.e. the sequence is exact at `B`).\n-/\ntheorem image_to_kernel_map_epi_of_zero_of_mono {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (g : B ⟶ C) [mono g] [limits.has_zero_object V] : epi\n  (image_to_kernel_map 0 g\n    (eq.mpr\n      (id\n        (Eq.trans\n          ((fun (a a_1 : A ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ C) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2) (0 ≫ g)\n            0 limits.zero_comp 0 0 (Eq.refl 0))\n          (propext (eq_self_iff_true 0))))\n      trivial)) := sorry\n\n/--\n`image_to_kernel_map` for `A --f--> B --0--> C`, where `[epi g]` is an epi\n(i.e. the sequence is exact at `B`).\n-/\ntheorem image_to_kernel_map_epi_of_epi_of_zero {V : Type u} [category V] [limits.has_zero_morphisms V] [limits.has_images V] [limits.has_equalizers V] {A : V} {B : V} {C : V} (f : A ⟶ B) [epi f] : epi\n  (image_to_kernel_map f 0\n    (eq.mpr\n      (id\n        (Eq.trans\n          ((fun (a a_1 : A ⟶ C) (e_1 : a = a_1) (ᾰ ᾰ_1 : A ⟶ C) (e_2 : ᾰ = ᾰ_1) => congr (congr_arg Eq e_1) e_2) (f ≫ 0)\n            0 limits.comp_zero 0 0 (Eq.refl 0))\n          (propext (eq_self_iff_true 0))))\n      trivial)) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/homology/image_to_kernel_map.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4588378547343552}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.pi.basic\nimport category_theory.limits.has_limits\n\n/-!\n# Limits in the category of indexed families of objects.\n\nGiven a functor `F : J ⥤ Π i, C i` into a category of indexed families,\n1. we can assemble a collection of cones over `F ⋙ pi.eval C i` into a cone over `F`\n2. if all those cones are limit cones, the assembled cone is a limit cone, and\n3. if we have limits for each of `F ⋙ pi.eval C i`, we can produce a\n   `has_limit F` instance\n-/\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory.pi\n\nuniverses v₁ v₂ u₁ u₂\n\nvariables {I : Type v₁} {C : I → Type u₁} [Π i, category.{v₁} (C i)]\nvariables {J : Type v₁} [small_category J]\nvariables {F : J ⥤ Π i, C i}\n\n/--\nA cone over `F : J ⥤ Π i, C i` has as its components cones over each of the `F ⋙ pi.eval C i`.\n-/\ndef cone_comp_eval (c : cone F) (i : I) : cone (F ⋙ pi.eval C i) :=\n{ X := c.X i,\n  π :=\n  { app := λ j, c.π.app j i,\n    naturality' := λ j j' f, congr_fun (c.π.naturality f) i, } }\n\n/--\nA cocone over `F : J ⥤ Π i, C i` has as its components cocones over each of the `F ⋙ pi.eval C i`.\n-/\ndef cocone_comp_eval (c : cocone F) (i : I) : cocone (F ⋙ pi.eval C i) :=\n{ X := c.X i,\n  ι :=\n  { app := λ j, c.ι.app j i,\n    naturality' := λ j j' f, congr_fun (c.ι.naturality f) i, } }\n\n/--\nGiven a family of cones over the `F ⋙ pi.eval C i`, we can assemble these together as a `cone F`.\n-/\ndef cone_of_cone_comp_eval (c : Π i, cone (F ⋙ pi.eval C i)) : cone F :=\n{ X := λ i, (c i).X,\n  π :=\n  { app := λ j i, (c i).π.app j,\n    naturality' := λ j j' f, by { ext i, exact (c i).π.naturality f, } } }\n\n/--\nGiven a family of cocones over the `F ⋙ pi.eval C i`,\nwe can assemble these together as a `cocone F`.\n-/\ndef cocone_of_cocone_comp_eval (c : Π i, cocone (F ⋙ pi.eval C i)) : cocone F :=\n{ X := λ i, (c i).X,\n  ι :=\n  { app := λ j i, (c i).ι.app j,\n    naturality' := λ j j' f, by { ext i, exact (c i).ι.naturality f, } } }\n\n/--\nGiven a family of limit cones over the `F ⋙ pi.eval C i`,\nassembling them together as a `cone F` produces a limit cone.\n-/\ndef cone_of_cone_eval_is_limit {c : Π i, cone (F ⋙ pi.eval C i)} (P : Π i, is_limit (c i)) :\n  is_limit (cone_of_cone_comp_eval c) :=\n{ lift := λ s i, (P i).lift (cone_comp_eval s i),\n  fac' := λ s j,\n  begin\n    ext i,\n    exact (P i).fac (cone_comp_eval s i) j,\n  end,\n  uniq' := λ s m w,\n  begin\n    ext i,\n    exact (P i).uniq (cone_comp_eval s i) (m i) (λ j, congr_fun (w j) i)\n  end }\n\n/--\nGiven a family of colimit cocones over the `F ⋙ pi.eval C i`,\nassembling them together as a `cocone F` produces a colimit cocone.\n-/\ndef cocone_of_cocone_eval_is_colimit\n  {c : Π i, cocone (F ⋙ pi.eval C i)} (P : Π i, is_colimit (c i)) :\n  is_colimit (cocone_of_cocone_comp_eval c) :=\n{ desc := λ s i, (P i).desc (cocone_comp_eval s i),\n  fac' := λ s j,\n  begin\n    ext i,\n    exact (P i).fac (cocone_comp_eval s i) j,\n  end,\n  uniq' := λ s m w,\n  begin\n    ext i,\n    exact (P i).uniq (cocone_comp_eval s i) (m i) (λ j, congr_fun (w j) i)\n  end }\n\nsection\n\nvariables [∀ i, has_limit (F ⋙ pi.eval C i)]\n\n/--\nIf we have a functor `F : J ⥤ Π i, C i` into a category of indexed families,\nand we have limits for each of the `F ⋙ pi.eval C i`,\nthen `F` has a limit.\n-/\nlemma has_limit_of_has_limit_comp_eval : has_limit F :=\nhas_limit.mk\n{ cone := cone_of_cone_comp_eval (λ i, limit.cone _),\n  is_limit := cone_of_cone_eval_is_limit (λ i, limit.is_limit _), }\n\nend\n\nsection\n\nvariables [∀ i, has_colimit (F ⋙ pi.eval C i)]\n\n/--\nIf we have a functor `F : J ⥤ Π i, C i` into a category of indexed families,\nand colimits exist for each of the `F ⋙ pi.eval C i`,\nthere is a colimit for `F`.\n-/\nlemma has_colimit_of_has_colimit_comp_eval : has_colimit F :=\nhas_colimit.mk\n{ cocone := cocone_of_cocone_comp_eval (λ i, colimit.cocone _),\n  is_colimit := cocone_of_cocone_eval_is_colimit (λ i, colimit.is_colimit _), }\n\nend\n\n/-!\nAs an example, we can use this to construct particular shapes of limits\nin a category of indexed families.\n\nWith the addition of\n`import category_theory.limits.shapes.types`\nwe can use:\n```\nlocal attribute [instance] has_limit_of_has_limit_comp_eval\nexample : has_binary_products (I → Type v₁) := ⟨by apply_instance⟩\n```\n-/\n\nend category_theory.pi\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/pi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.458837837134191}}
{"text": "\nimport unitb.models.nondet\n\nnamespace decomposition\n\nopen nondet unitb function\n\nsection\n\nparameter α : Type\n\n@[reducible]\nprivate def pred := α → Prop\n\nstructure program : Type 2 :=\n  (asm : α → α → Prop)\n  (mch : nondet.program α)\n\nparameter {α}\n\nstructure compatible {t : Type} (hasm : α → α → Prop) (m : t → program) : Prop :=\n  (step : ∀ i j, i ≠ j → ∀ s s', is_step (m j).mch s s' → (m i).asm s s')\n  (asm : ∀ i, ∀ s s', hasm s s' → (m i).asm s s')\n\nnoncomputable def compose {t : Type} (m : t → program) {s₀ : α}\n  (hasm : α → α → Prop)\n  (h₀ : ∀ i, (m i).mch.first s₀)\n  (h : compatible hasm m)\n  [scheduling.sched t]\n  [∀ i, scheduling.sched (m i).mch.lbl]\n: program :=\n{ mch :=\n    { lbl := Σ i, (m i).mch.lbl\n    , lbl_is_sched := by apply_instance\n    , first := λ s, ∀ i, (m i).mch.first s\n    , first_fis := ⟨_,h₀⟩\n    , event' := λ i, (m i.1).mch.event' i.2 }\n, asm := hasm }\n\ndef step (p : program) (s s' : α) : Prop :=\nnondet.is_step p.mch s s' ∨ p.asm s s'\n\ninstance : system program :=\n{ σ := α\n, init := nondet.program.init ∘ program.mch\n, step := step\n, transient := nondet.program.transient ∘ program.mch\n, transient_false := λ s, @system.transient_false _ _ s.mch\n, transient_antimono := λ s, @system.transient_antimono _ _ s.mch }\n\nstructure program.ex (s : program) (τ : stream α) : Prop :=\n    (init : s.mch.first (τ 0))\n    (safety : unitb.saf_ex s τ)\n    (liveness : ∀ e, fair' s.mch e τ)\n\nlemma ex_of_ex_mch (s : program) (τ : stream α)\n  (h : s.mch.ex τ)\n: s.ex τ :=\nbegin\n  apply decomposition.program.ex.mk,\n  { apply h.init },\n  { unfold saf_ex,\n    refine temporal.henceforth_entails_henceforth _ _ h.safety,\n    apply temporal.action_entails_action,\n    intros s s',\n    unfold unitb.step has_safety.step is_step step,\n    apply or.intro_left },\n  { apply h.liveness },\nend\n\ninstance : system_sem program :=\n{ (_ : system program) with\n  ex := λ p, program.ex p\n, init_sem  := λ s p τ Hτ H₀, by { apply H₀, apply Hτ.init }\n, inhabited := λ s, exists_imp_exists (ex_of_ex_mch s) (system_sem.inhabited s.mch)\n, safety    := λ s p, decomposition.program.ex.safety\n, transient_sem := λ s p q τ Hτ T, by apply transient.semantics' _ Hτ.liveness T }\n\nend\n\nend decomposition\n", "meta": {"author": "unitb", "repo": "unitb-semantics", "sha": "07607ddb2ced4044af121f1fd989e058e19c3c9c", "save_path": "github-repos/lean/unitb-unitb-semantics", "path": "github-repos/lean/unitb-unitb-semantics/unitb-semantics-07607ddb2ced4044af121f1fd989e058e19c3c9c/src/unitb/decomposition/component.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246118695629, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4588346691771767}}
{"text": "import linear_algebra.dimension\nimport analysis.topology.topological_structures\nimport algebra.pi_instances\nimport field_theory.subfield\nimport ring_theory.ideal_operations\nimport .topological_group\nimport .algebra_tensor\n\nlocal attribute [instance] classical.prop_decidable\n\nuniverses u v\n\nset_option eqn_compiler.zeta true\n\nclass is_alg_closed_field (F : Type u) [field F] : Prop :=\n(alg_closed : ∀ f : polynomial F, f.degree > 1 → ∃ x, f.eval x = 0)\n\nvariables {F : Type u} [discrete_field F]\n\nclass is_integral {K : Type v} [comm_ring K] (i : algebra F K) : Prop :=\n(integral : ∀ x : K, ∃ f : polynomial F, f.monic ∧ polynomial.aeval F i x f = 0)\n\ninstance discrete_field_of_subalgebra_of_integral {K : Type v} [discrete_field K] (i : algebra F K)\n  [is_integral i] (S : subalgebra i) : discrete_field S := sorry\n\nclass is_algebraic_closure {K : Type v} [discrete_field K] (i : algebra F K) extends is_alg_closed_field K, is_integral i : Prop\n\nstructure Gal {K : Type v} [comm_ring K] (i : algebra F K) extends K ≃ K :=\n(hom : is_ring_hom to_fun)\n(fix : ∀ x : F, to_fun (i x) = i x)\nattribute [instance] Gal.hom\n\ninstance Gal.hom' {K : Type v} [comm_ring K] (i : algebra F K) (f : Gal i) : is_ring_hom f.to_equiv := f.hom\n\ntheorem Gal.ext {K : Type v} [comm_ring K] (i : algebra F K) : ∀ f g : Gal i, (∀ x, f.to_equiv x = g.to_equiv x) → f = g\n| ⟨_, _, _⟩ ⟨_, _, _⟩ H := by rw Gal.mk.inj_eq; from equiv.ext _ _ H\n\ndef is_reduced_comm_ring (R : Type u) [comm_ring R] : Prop :=\n(⊥ : ideal R).radical = ⊥\n\ndef algebraic_closure_field (F : Type u) [discrete_field F] : Type u := sorry\ninstance (F : Type u) [discrete_field F] : discrete_field (algebraic_closure_field F) := sorry\ndef algebraic_closure (F : Type u) [discrete_field F] : algebra F (algebraic_closure_field F) := sorry\ninstance (F : Type u) [discrete_field F] : is_algebraic_closure (algebraic_closure F) := sorry\n\n-- http://www.math.uconn.edu/~kconrad/blurbs/galoistheory/separable2.pdf\nclass is_separable (S : subalgebra $ algebraic_closure F) : Prop :=\n(separable : is_reduced_comm_ring (S.algebra.mod ⊗ (algebraic_closure F).mod))\n\nvariables F\nstructure finite_Galois_extension : Type u :=\n(S : subalgebra $ algebraic_closure F)\n(finite : vector_space.dim F S.algebra.mod < cardinal.omega)\n(separable : is_separable S)\n(proj : Gal (algebraic_closure F) → Gal S.algebra)\n(proj_commutes : ∀ f : Gal (algebraic_closure F), ∀ x : S, ((proj f).to_equiv x).1 = f.to_equiv x.1)\nattribute [instance] finite_Galois_extension.separable\n\nvariables {F}\ninstance Gal.group {K : Type v} [comm_ring K] (i : algebra F K) : group (Gal i) :=\n{ mul := λ f g, ⟨f.to_equiv.trans g.to_equiv,\n    @@is_ring_hom.comp _ _ _ f.hom _ _ g.hom,\n    λ _, by simp [equiv.trans, f.fix, g.fix]⟩,\n  mul_assoc := λ _ _ _, Gal.ext _ _ _ $ λ _, by simp,\n  one := ⟨equiv.refl _, is_ring_hom.id, λ _, rfl⟩,\n  one_mul := λ _, Gal.ext _ _ _ $ λ _, rfl,\n  mul_one := λ _, Gal.ext _ _ _ $ λ _, rfl,\n  inv := λ f, ⟨f.to_equiv.symm,\n      ⟨show f.to_equiv.symm 1 = 1,\n        by rw [equiv.symm_apply_eq, is_ring_hom.map_one f.to_equiv],\n      λ x y, show f.to_equiv.symm (x * y) = f.to_equiv.symm x * f.to_equiv.symm y,\n        by rw [equiv.symm_apply_eq, is_ring_hom.map_mul f.to_equiv];\n          rw [equiv.apply_inverse_apply, equiv.apply_inverse_apply],\n      λ x y, show f.to_equiv.symm (x + y) = f.to_equiv.symm x + f.to_equiv.symm y,\n        by rw [equiv.symm_apply_eq, is_ring_hom.map_add f.to_equiv];\n          rw [equiv.apply_inverse_apply, equiv.apply_inverse_apply]⟩,\n    λ x, show f.to_equiv.symm (i x) = i x,\n      by rw equiv.symm_apply_eq; from (f.fix x).symm⟩,\n  mul_left_inv := λ _, Gal.ext _ _ _ $ λ _,\n    equiv.apply_inverse_apply _ _ }\n\ninstance Gal.finite_Galois_extension.topological_space (E : finite_Galois_extension F) :\n  topological_space (Gal E.S.algebra) := ⊤\n\ninstance Gal.finite_Galois_extension.topological_group (E : finite_Galois_extension F) :\n  topological_group (Gal E.S.algebra) :=\n{ continuous_mul := λ x1 h1, by apply is_open_prod_iff.2; intros x y H;\n    refine ⟨{x}, {y}, trivial, trivial, _, _, _⟩; simp; simpa using H,\n  continuous_inv := continuous_top }\n\nvariables (F)\ninstance Gal_algebraic_closure.topological_space : topological_space (Gal $ algebraic_closure F) :=\n@topological_space.induced _\n  (Π E : finite_Galois_extension F, Gal E.S.algebra)\n  (λ f E, E.proj f)\n  (@Pi.topological_space _ _ (λ _, ⊤))\n\ninstance Gal.topological_group : topological_group (Gal $ algebraic_closure F) :=\n@topological_group.induced _ _ _ _ _\n  (@Pi.topological_group (finite_Galois_extension F) (λ E, Gal E.S.algebra) _ _ _)\n  (λ f S, S.proj f)\n  (by constructor; intros f g; funext S; apply Gal.ext; intro x;\n    apply subtype.eq; have := S.proj_commutes; dsimp at this ⊢;\n    change ((S.proj (f * g)).to_equiv x).1 = ((S.proj f * S.proj g).to_equiv x).1;\n    dsimp [(*), semigroup.mul, monoid.mul, group.mul]; simp [this])\n\nvariables {F}\ndef subalgebra.Gal {K : Type v} [comm_ring K] {i : algebra F K} (S : subalgebra i) : set (Gal i) :=\n{ f | ∀ x ∈ S, f.to_equiv x = x }\n\ninstance Gal.intermediate.subgroup {K : Type v} [comm_ring K] {i : algebra F K} (S : subalgebra i) :\n  is_subgroup S.Gal :=\n{ mul_mem := λ f g H1 H2 x hx,\n    show f.to_equiv.trans g.to_equiv x = x,\n    by simp [H1 x hx, H2 x hx],\n  one_mem := λ x hx, rfl,\n  inv_mem := λ f H1 x hx,\n    show f.to_equiv.symm x = x,\n    by rw equiv.symm_apply_eq; from (H1 x hx).symm }\n\ninstance Gal.normal (E : finite_Galois_extension F) :\n  normal_subgroup E.S.Gal :=\n{ normal := λ f hf g x hx,\n    show g.to_equiv.trans (f.to_equiv.trans g.to_equiv.symm) x = x,\n    from have _ := E.proj_commutes g ⟨x, hx⟩,\n    by simp at this ⊢; rw [← this, hf, this];\n      [simp, from (((E.proj g).to_equiv) ⟨x, hx⟩).2] }\n\ninstance Gal.intermediate.topological_group (E : finite_Galois_extension F) :\n  topological_group E.S.Gal :=\ntopological_group.induced _ _ subtype.val", "meta": {"author": "kckennylau", "repo": "local-langlands-abelian", "sha": "ee22666898357dab800a0432214a22c519ed26a9", "save_path": "github-repos/lean/kckennylau-local-langlands-abelian", "path": "github-repos/lean/kckennylau-local-langlands-abelian/local-langlands-abelian-ee22666898357dab800a0432214a22c519ed26a9/src/field_extensions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245787544824, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4588346509437695}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Scott Morrison, Jakob von Raumer\n-/\nimport category_theory.monoidal.braided\nimport category_theory.closed.monoidal\nimport algebra.category.Module.basic\nimport linear_algebra.tensor_product\nimport category_theory.linear.yoneda\nimport category_theory.monoidal.preadditive\n\n/-!\n# The symmetric monoidal category structure on R-modules\n\nMostly this uses existing machinery in `linear_algebra.tensor_product`.\nWe just need to provide a few small missing pieces to build the\n`monoidal_category` instance and then the `symmetric_category` instance.\n\nNote the universe level of the modules must be at least the universe level of the ring,\nso that we have a monoidal unit.\nFor now, we simplify by insisting both universe levels are the same.\n\nWe then construct the monoidal closed structure on `Module R`.\n\nIf you're happy using the bundled `Module R`, it may be possible to mostly\nuse this as an interface and not need to interact much with the implementation details.\n-/\n\nuniverses u\n\nopen category_theory\n\nnamespace Module\n\nvariables {R : Type u} [comm_ring R]\n\nnamespace monoidal_category\n-- The definitions inside this namespace are essentially private.\n-- After we build the `monoidal_category (Module R)` instance,\n-- you should use that API.\n\nopen_locale tensor_product\nlocal attribute [ext] tensor_product.ext\n\n/-- (implementation) tensor product of R-modules -/\ndef tensor_obj (M N : Module R) : Module R := Module.of R (M ⊗[R] N)\n/-- (implementation) tensor product of morphisms R-modules -/\ndef tensor_hom {M N M' N' : Module R} (f : M ⟶ N) (g : M' ⟶ N') :\n  tensor_obj M M' ⟶ tensor_obj N N' :=\ntensor_product.map f g\n\nlemma tensor_id (M N : Module R) : tensor_hom (𝟙 M) (𝟙 N) = 𝟙 (Module.of R (↥M ⊗ ↥N)) :=\nby tidy\n\nlemma tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : Module R}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :\n    tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) = tensor_hom f₁ f₂ ≫ tensor_hom g₁ g₂ :=\nby tidy\n\n/-- (implementation) the associator for R-modules -/\ndef associator (M N K : Module R) : tensor_obj (tensor_obj M N) K ≅ tensor_obj M (tensor_obj N K) :=\nlinear_equiv.to_Module_iso (tensor_product.assoc R M N K)\n\nsection\n\n/-! The `associator_naturality` and `pentagon` lemmas below are very slow to elaborate.\n\nWe give them some help by expressing the lemmas first non-categorically, then using\n`convert _aux using 1` to have the elaborator work as little as possible. -/\n\nopen tensor_product (assoc map)\n\nprivate lemma associator_naturality_aux\n  {X₁ X₂ X₃ : Type*}\n  [add_comm_monoid X₁] [add_comm_monoid X₂] [add_comm_monoid X₃]\n  [module R X₁] [module R X₂] [module R X₃]\n  {Y₁ Y₂ Y₃ : Type*}\n  [add_comm_monoid Y₁] [add_comm_monoid Y₂] [add_comm_monoid Y₃]\n  [module R Y₁] [module R Y₂] [module R Y₃]\n  (f₁ : X₁ →ₗ[R] Y₁) (f₂ : X₂ →ₗ[R] Y₂) (f₃ : X₃ →ₗ[R] Y₃) :\n  (↑(assoc R Y₁ Y₂ Y₃) ∘ₗ (map (map f₁ f₂) f₃)) = ((map f₁ (map f₂ f₃)) ∘ₗ ↑(assoc R X₁ X₂ X₃)) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl\nend\n\nvariables (R)\n\nprivate lemma pentagon_aux\n  (W X Y Z : Type*)\n  [add_comm_monoid W] [add_comm_monoid X] [add_comm_monoid Y] [add_comm_monoid Z]\n  [module R W] [module R X] [module R Y] [module R Z] :\n  ((map (1 : W →ₗ[R] W) (assoc R X Y Z).to_linear_map).comp (assoc R W (X ⊗[R] Y) Z).to_linear_map)\n    .comp (map ↑(assoc R W X Y) (1 : Z →ₗ[R] Z)) =\n  (assoc R W X (Y ⊗[R] Z)).to_linear_map.comp (assoc R (W ⊗[R] X) Y Z).to_linear_map :=\nbegin\n  apply tensor_product.ext_fourfold,\n  intros w x y z,\n  refl\nend\n\nend\n\nlemma associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : Module R}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :\n    tensor_hom (tensor_hom f₁ f₂) f₃ ≫ (associator Y₁ Y₂ Y₃).hom =\n    (associator X₁ X₂ X₃).hom ≫ tensor_hom f₁ (tensor_hom f₂ f₃) :=\nby convert associator_naturality_aux f₁ f₂ f₃ using 1\n\nlemma pentagon (W X Y Z : Module R) :\n  tensor_hom (associator W X Y).hom (𝟙 Z) ≫ (associator W (tensor_obj X Y) Z).hom\n  ≫ tensor_hom (𝟙 W) (associator X Y Z).hom =\n    (associator (tensor_obj W X) Y Z).hom ≫ (associator W X (tensor_obj Y Z)).hom :=\nby convert pentagon_aux R W X Y Z using 1\n\n/-- (implementation) the left unitor for R-modules -/\ndef left_unitor (M : Module.{u} R) : Module.of R (R ⊗[R] M) ≅ M :=\n(linear_equiv.to_Module_iso (tensor_product.lid R M) : of R (R ⊗ M) ≅ of R M).trans (of_self_iso M)\n\n\n\n/-- (implementation) the right unitor for R-modules -/\ndef right_unitor (M : Module.{u} R) : Module.of R (M ⊗[R] R) ≅ M :=\n(linear_equiv.to_Module_iso (tensor_product.rid R M) : of R (M ⊗ R) ≅ of R M).trans (of_self_iso M)\n\nlemma right_unitor_naturality {M N : Module R} (f : M ⟶ N) :\n  tensor_hom f (𝟙 (Module.of R R)) ≫ (right_unitor N).hom = (right_unitor M).hom ≫ f :=\nbegin\n  ext x y, simp,\n  erw [tensor_product.rid_tmul, tensor_product.rid_tmul],\n  rw linear_map.map_smul,\n  refl,\nend\n\nlemma triangle (M N : Module.{u} R) :\n  (associator M (Module.of R R) N).hom ≫ tensor_hom (𝟙 M) (left_unitor N).hom =\n    tensor_hom (right_unitor M).hom (𝟙 N) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  change R at y,\n  dsimp [tensor_hom, associator],\n  erw [tensor_product.lid_tmul, tensor_product.rid_tmul],\n  exact (tensor_product.smul_tmul _ _ _).symm\nend\n\nend monoidal_category\n\nopen monoidal_category\n\ninstance monoidal_category : monoidal_category (Module.{u} R) :=\n{ -- data\n  tensor_obj   := tensor_obj,\n  tensor_hom   := @tensor_hom _ _,\n  tensor_unit  := Module.of R R,\n  associator   := associator,\n  left_unitor  := left_unitor,\n  right_unitor := right_unitor,\n  -- properties\n  tensor_id'               := λ M N, tensor_id M N,\n  tensor_comp'             := λ M N K M' N' K' f g h, tensor_comp f g h,\n  associator_naturality'   := λ M N K M' N' K' f g h, associator_naturality f g h,\n  left_unitor_naturality'  := λ M N f, left_unitor_naturality f,\n  right_unitor_naturality' := λ M N f, right_unitor_naturality f,\n  pentagon'                := λ M N K L, pentagon M N K L,\n  triangle'                := λ M N, triangle M N, }\n\n/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/\ninstance : comm_ring ((𝟙_ (Module.{u} R) : Module.{u} R) : Type u) :=\n(by apply_instance : comm_ring R)\n\nnamespace monoidal_category\n\n@[simp]\nlemma hom_apply {K L M N : Module.{u} R} (f : K ⟶ L) (g : M ⟶ N) (k : K) (m : M) :\n  (f ⊗ g) (k ⊗ₜ m) = f k ⊗ₜ g m := rfl\n\n@[simp]\nlemma left_unitor_hom_apply {M : Module.{u} R} (r : R) (m : M) :\n  ((λ_ M).hom : 𝟙_ (Module R) ⊗ M ⟶ M) (r ⊗ₜ[R] m) = r • m :=\ntensor_product.lid_tmul m r\n\n@[simp]\nlemma left_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((λ_ M).inv : M ⟶ 𝟙_ (Module.{u} R) ⊗ M) m = 1 ⊗ₜ[R] m :=\ntensor_product.lid_symm_apply m\n\n@[simp]\nlemma right_unitor_hom_apply {M : Module.{u} R} (m : M) (r : R) :\n  ((ρ_ M).hom : M ⊗ 𝟙_ (Module R) ⟶ M) (m ⊗ₜ r) = r • m :=\ntensor_product.rid_tmul m r\n\n@[simp]\nlemma right_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((ρ_ M).inv : M ⟶ M ⊗ 𝟙_ (Module.{u} R)) m = m ⊗ₜ[R] 1 :=\ntensor_product.rid_symm_apply m\n\n@[simp]\nlemma associator_hom_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((α_ M N K).hom : (M ⊗ N) ⊗ K ⟶ M ⊗ (N ⊗ K)) ((m ⊗ₜ n) ⊗ₜ k) = (m ⊗ₜ (n ⊗ₜ k)) := rfl\n\n@[simp]\nlemma associator_inv_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((α_ M N K).inv : M ⊗ (N ⊗ K) ⟶ (M ⊗ N) ⊗ K) (m ⊗ₜ (n ⊗ₜ k)) = ((m ⊗ₜ n) ⊗ₜ k) := rfl\n\nend monoidal_category\n\n/-- (implementation) the braiding for R-modules -/\ndef braiding (M N : Module R) : tensor_obj M N ≅ tensor_obj N M :=\nlinear_equiv.to_Module_iso (tensor_product.comm R M N)\n\n@[simp] lemma braiding_naturality {X₁ X₂ Y₁ Y₂ : Module.{u} R} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :\n  (f ⊗ g) ≫ (Y₁.braiding Y₂).hom =\n    (X₁.braiding X₂).hom ≫ (g ⊗ f) :=\nbegin\n  apply tensor_product.ext',\n  intros x y,\n  refl\nend\n\n@[simp] lemma hexagon_forward (X Y Z : Module.{u} R) :\n  (α_ X Y Z).hom ≫ (braiding X _).hom ≫ (α_ Y Z X).hom =\n  ((braiding X Y).hom ⊗ 𝟙 Z) ≫ (α_ Y X Z).hom ≫ (𝟙 Y ⊗ (braiding X Z).hom) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl,\nend\n\n@[simp] lemma hexagon_reverse (X Y Z : Module.{u} R) :\n  (α_ X Y Z).inv ≫ (braiding _ Z).hom ≫ (α_ Z X Y).inv =\n  (𝟙 X ⊗ (Y.braiding Z).hom) ≫ (α_ X Z Y).inv ≫ ((X.braiding Z).hom ⊗ 𝟙 Y) :=\nbegin\n  apply (cancel_epi (α_ X Y Z).hom).1,\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl,\nend\n\nlocal attribute [ext] tensor_product.ext\n\n/-- The symmetric monoidal structure on `Module R`. -/\ninstance symmetric_category : symmetric_category (Module.{u} R) :=\n{ braiding := braiding,\n  braiding_naturality' := λ X₁ X₂ Y₁ Y₂ f g, braiding_naturality f g,\n  hexagon_forward' := hexagon_forward,\n  hexagon_reverse' := hexagon_reverse, }\n\nnamespace monoidal_category\n\n@[simp] lemma braiding_hom_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((β_ M N).hom : M ⊗ N ⟶ N ⊗ M) (m ⊗ₜ n) = n ⊗ₜ m := rfl\n\n@[simp] lemma braiding_inv_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((β_ M N).inv : N ⊗ M ⟶ M ⊗ N) (n ⊗ₜ m) = m ⊗ₜ n := rfl\n\nend monoidal_category\n\nopen opposite\n\ninstance : monoidal_preadditive (Module.{u} R) :=\n{ tensor_zero' := by { intros, ext, simp, },\n  zero_tensor' := by { intros, ext, simp, },\n  tensor_add' := by { intros, ext, simp [tensor_product.tmul_add], },\n  add_tensor' := by { intros, ext, simp [tensor_product.add_tmul], }, }\n\n/--\nAuxiliary definition for the `monoidal_closed` instance on `Module R`.\n(This is only a separate definition in order to speed up typechecking. )\n-/\n@[simps]\ndef monoidal_closed_hom_equiv (M N P : Module.{u} R) :\n  ((monoidal_category.tensor_left M).obj N ⟶ P) ≃\n    (N ⟶ ((linear_coyoneda R (Module R)).obj (op M)).obj P) :=\n{ to_fun := λ f, linear_map.compr₂ (tensor_product.mk R N M) ((β_ N M).hom ≫ f),\n  inv_fun := λ f, (β_ M N).hom ≫ tensor_product.lift f,\n  left_inv := λ f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr₂_apply,\n      function.comp_app, coe_comp, monoidal_category.braiding_hom_apply],\n  end,\n  right_inv := λ f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr₂_apply,\n      symmetric_category.symmetry_assoc],\n  end, }\n\ninstance : monoidal_closed (Module.{u} R) :=\n{ closed' := λ M,\n  { is_adj :=\n    { right := (linear_coyoneda R (Module.{u} R)).obj (op M),\n      adj := adjunction.mk_of_hom_equiv\n      { hom_equiv := λ N P, monoidal_closed_hom_equiv M N P, } } } }\n\n-- I can't seem to express the function coercion here without writing `@coe_fn`.\n@[simp]\nlemma monoidal_closed_curry {M N P : Module.{u} R} (f : M ⊗ N ⟶ P) (x : M) (y : N) :\n  @coe_fn _ _ linear_map.has_coe_to_fun ((monoidal_closed.curry f : N →ₗ[R] (M →ₗ[R] P)) y) x =\n    f (x ⊗ₜ[R] y) :=\nrfl\n\n@[simp]\nlemma monoidal_closed_uncurry {M N P : Module.{u} R}\n  (f : N ⟶ (M ⟶[Module.{u} R] P)) (x : M) (y : N) :\n  monoidal_closed.uncurry f (x ⊗ₜ[R] y) = (@coe_fn _ _ linear_map.has_coe_to_fun (f y)) x :=\nby { simp only [monoidal_closed.uncurry, ihom.adjunction, is_left_adjoint.adj], simp, }\n\nend Module\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebra/category/Module/monoidal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4588180500672312}}
{"text": "/-\nCopyright (c) 2020 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Adam Topaz\n-/\n\nimport data.fintype.basic\nimport data.fin\nimport category_theory.concrete_category.bundled\nimport category_theory.concrete_category\nimport category_theory.full_subcategory\nimport category_theory.skeletal\n\n/-!\n# The category of finite types.\n\nWe define the category of finite types, denoted `Fintype` as\n(bundled) types with a `fintype` instance.\n\nWe also define `Fintype.skeleton`, the standard skeleton of `Fintype` whose objects are `fin n`\nfor `n : ℕ`. We prove that the obvious inclusion functor `Fintype.skeleton ⥤ Fintype` is an\nequivalence of categories in `Fintype.skeleton.equivalence`.\nWe prove that `Fintype.skeleton` is a skeleton of `Fintype` in `Fintype.is_skeleton`.\n-/\n\nopen_locale classical\nopen category_theory\n\n/-- The category of finite types. -/\n@[derive has_coe_to_sort]\ndef Fintype := bundled fintype\n\nnamespace Fintype\n\n/-- Construct a bundled `Fintype` from the underlying type and typeclass. -/\ndef of (X : Type*) [fintype X] : Fintype := bundled.of X\ninstance : inhabited Fintype := ⟨⟨pempty⟩⟩\ninstance {X : Fintype} : fintype X := X.2\n\ninstance : category Fintype := induced_category.category bundled.α\n\n/-- The fully faithful embedding of `Fintype` into the category of types. -/\n@[derive [full, faithful], simps]\ndef incl : Fintype ⥤ Type* := induced_functor _\n\ninstance : concrete_category Fintype := ⟨incl⟩\n\n/--\nThe \"standard\" skeleton for `Fintype`. This is the full subcategory of `Fintype` spanned by objects\nof the form `fin n` for `n : ℕ`. We parameterize the objects of `Fintype.skeleton` directly as `ℕ`,\nas the type `fin m ≃ fin n` is nonempty if and only if `n = m`.\n-/\ndef skeleton := ℕ\n\nnamespace skeleton\n\n/-- Given any natural number `n`, this creates the associated object of `Fintype.skeleton`. -/\ndef mk : ℕ → skeleton := id\n\ninstance : inhabited skeleton := ⟨mk 0⟩\n\n/-- Given any object of `Fintype.skeleton`, this returns the associated natural number. -/\ndef to_nat : skeleton → ℕ := id\n\ninstance : category skeleton :=\n{ hom := λ X Y, fin X → fin Y,\n  id := λ _, id,\n  comp := λ _ _ _ f g, g ∘ f }\n\nlemma is_skeletal : skeletal skeleton := λ X Y ⟨h⟩, fin.equiv_iff_eq.mp $ nonempty.intro $\n{ to_fun := h.1,\n  inv_fun := h.2,\n  left_inv := λ _, by {change (h.hom ≫ h.inv) _ = _, simpa},\n  right_inv := λ _, by {change (h.inv ≫ h.hom) _ = _, simpa} }\n\n/-- The canonical fully faithful embedding of `Fintype.skeleton` into `Fintype`. -/\ndef incl : skeleton ⥤ Fintype :=\n{ obj := λ X, Fintype.of (fin X),\n  map := λ _ _ f, f }\n\ninstance : full incl := { preimage := λ _ _ f, f }\ninstance : faithful incl := {}\ninstance : ess_surj incl :=\n{ mem_ess_image := λ X,\n  let F := fintype.equiv_fin X in\n  ⟨fintype.card X, ⟨⟨F.symm, F, F.self_comp_symm, F.symm_comp_self⟩⟩⟩ }\n\nnoncomputable instance : is_equivalence incl :=\nequivalence.equivalence_of_fully_faithfully_ess_surj _\n\n/-- The equivalence between `Fintype.skeleton` and `Fintype`. -/\nnoncomputable def equivalence : skeleton ≌ Fintype := incl.as_equivalence\n\n@[simp] lemma incl_mk_nat_card (n : ℕ) : fintype.card (incl.obj (mk n)) = n := finset.card_fin n\n\nend skeleton\n\n/-- `Fintype.skeleton` is a skeleton of `Fintype`. -/\nnoncomputable def is_skeleton : is_skeleton_of Fintype skeleton skeleton.incl :=\n{ skel := skeleton.is_skeletal,\n  eqv := by apply_instance }\n\nend Fintype\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/Fintype.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710085, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.4588180457729531}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport tactic.core\n\nopen tactic\n\nstructure C :=\n ( w : Type )\n ( x : list w )\n ( y : Type )\n ( z : prod w y )\n\ndef test_terminal_goal_1 : C :=\n begin\n    fapply C.mk, -- We don't just split here, as we want the goals in order.\n    success_if_fail { tactic.terminal_goal },\n    exact ℕ,\n    terminal_goal,\n    exact [],\n    success_if_fail { terminal_goal },\n    exact bool,\n    terminal_goal,\n    exact (0, tt)\n end\n\n -- verifying that terminal_goal correctly considers all propositional goals as terminal\nstructure terminal_goal_struct :=\n(x : ℕ)\n(p : x = 0)\n\nlemma test_terminal_goal_2 : ∃ F : terminal_goal_struct, F = ⟨ 0, by refl ⟩ :=\nbegin\n  split,\n  swap,\n  split,\n  terminal_goal,\n  swap,\n  success_if_fail { terminal_goal },\n  exact 0,\n  refl,\n  refl,\nend\n\nstructure terminal_goal_struct' :=\n ( w : ℕ → Type )\n ( x : list (w 0) )\n\ndef test_terminal_goal_3 : terminal_goal_struct' :=\nbegin\n  split,\n  swap,\n  success_if_fail { terminal_goal },\n  intros,\n  success_if_fail { terminal_goal },\n  exact ℕ,\n  exact []\nend\n\ndef f : unit → Type := λ _, ℕ\n\ndef test_terminal_goal_4 : Σ x : unit, f x :=\nbegin\n  split,\n  terminal_goal,\n  swap,\n  terminal_goal,\n  exact (),\n  dsimp [f],\n  exact 0\nend\n\ndef test_subsingleton_goal_1 : 0 = 0 :=\nbegin\n subsingleton_goal,\n refl\nend\n\ndef test_subsingleton_goal_2 : list ℕ :=\nbegin\n success_if_fail { subsingleton_goal },\n exact []\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/terminal_goal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494421679929, "lm_q2_score": 0.6688802537704064, "lm_q1q2_score": 0.4588180369509958}}
{"text": "import tactic\n\nnamespace vilnius\n\n\n/- ### implication -/\n\nexample (P Q : Prop) : P → Q → P :=\nbegin\n  sorry\nend\n\n/- ### not -/\n\nexample (P Q : Prop) : (P → ¬ Q) → (Q → ¬ P) :=\nbegin\n  sorry\nend\n\n\n/- ### and -/\n\nexample (P Q : Prop) : P ∧ Q → Q :=\nbegin\n  sorry\nend\n\nexample (P Q : Prop) : P → Q → P ∧ Q :=\nbegin\n  sorry,\nend\n\n\nexample (P Q : Prop) : P ∧ Q → Q ∧ P :=\nbegin\n  sorry\nend\n\n\nexample (P : Prop) : P ∧ ¬ P → false :=\nbegin\n  sorry,\nend\n\n\n/- ## Or -/\n\n\nexample (P Q : Prop) : ¬ P ∨ Q → P → Q :=\nbegin\n  sorry,\nend\n\n\nexample (P Q R : Prop) : P ∨ (Q ∧ R) → ¬ P → ¬ Q → false :=\nbegin\n  sorry,\nend\n\n\nend vilnius\n\n", "meta": {"author": "faenuccio", "repo": "May22_Vilnius", "sha": "2ff937dc7568e6118473b1e7f479ccb2a5fa9767", "save_path": "github-repos/lean/faenuccio-May22_Vilnius", "path": "github-repos/lean/faenuccio-May22_Vilnius/May22_Vilnius-2ff937dc7568e6118473b1e7f479ccb2a5fa9767/src/A_Logic/Exercices.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.458704951839603}}
{"text": "/-\nCopyright (c) 2018 Andreas Swerdlow. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andreas Swerdlow\n-/\nimport algebra.module.linear_map\nimport linear_algebra.basis.bilinear\nimport linear_algebra.bilinear_map\nimport algebra.euclidean_domain.instances\nimport ring_theory.non_zero_divisors\n\n/-!\n# Sesquilinear form\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis files provides properties about sesquilinear forms. The maps considered are of the form\n`M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R`, where `I₁ : R₁ →+* R` and `I₂ : R₂ →+* R` are ring homomorphisms and\n`M₁` is a module over `R₁` and `M₂` is a module over `R₂`.\nSesquilinear forms are the special case that `M₁ = M₂`, `R₁ = R₂ = R`, and `I₁ = ring_hom.id R`.\nTaking additionally `I₂ = ring_hom.id R`, then one obtains bilinear forms.\n\nThese forms are a special case of the bilinear maps defined in `bilinear_map.lean` and all basic\nlemmas about construction and elementary calculations are found there.\n\n## Main declarations\n\n* `is_ortho`: states that two vectors are orthogonal with respect to a sesquilinear form\n* `is_symm`, `is_alt`: states that a sesquilinear form is symmetric and alternating, respectively\n* `orthogonal_bilin`: provides the orthogonal complement with respect to sesquilinear form\n\n## References\n\n* <https://en.wikipedia.org/wiki/Sesquilinear_form#Over_arbitrary_rings>\n\n## Tags\n\nSesquilinear form,\n-/\n\nopen_locale big_operators\n\nvariables {R R₁ R₂ R₃ M M₁ M₂ Mₗ₁ Mₗ₁' Mₗ₂ Mₗ₂' K K₁ K₂ V V₁ V₂ n : Type*}\n\nnamespace linear_map\n\n/-! ### Orthogonal vectors -/\n\nsection comm_ring\n\n-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables [comm_semiring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  [comm_semiring R₂] [add_comm_monoid M₂] [module R₂ M₂]\n  {I₁ : R₁ →+* R} {I₂ : R₂ →+* R} {I₁' : R₁ →+* R}\n\n/-- The proposition that two elements of a sesquilinear form space are orthogonal -/\ndef is_ortho (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x y) : Prop := B x y = 0\n\nlemma is_ortho_def {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} {x y} : B.is_ortho x y ↔ B x y = 0 := iff.rfl\n\nlemma is_ortho_zero_left (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x) : is_ortho B (0 : M₁) x :=\nby { dunfold is_ortho, rw [ map_zero B, zero_apply] }\n\nlemma is_ortho_zero_right (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) (x) : is_ortho B x (0 : M₂) :=\nmap_zero (B x)\n\n\n\n/-- A set of vectors `v` is orthogonal with respect to some bilinear form `B` if and only\nif for all `i ≠ j`, `B (v i) (v j) = 0`. For orthogonality between two elements, use\n`bilin_form.is_ortho` -/\ndef is_Ortho (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R) (v : n → M₁) : Prop :=\npairwise (B.is_ortho on v)\n\nlemma is_Ortho_def {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R} {v : n → M₁} :\n  B.is_Ortho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 := iff.rfl\n\nlemma is_Ortho_flip (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₁'] R) {v : n → M₁} :\n  B.is_Ortho v ↔ B.flip.is_Ortho v :=\nbegin\n  simp_rw is_Ortho_def,\n  split; intros h i j hij,\n  { rw flip_apply,\n    exact h j i (ne.symm hij) },\n  simp_rw flip_apply at h,\n  exact h j i (ne.symm hij),\nend\n\nend comm_ring\nsection field\n\nvariables [field K] [field K₁] [add_comm_group V₁] [module K₁ V₁]\n  [field K₂] [add_comm_group V₂] [module K₂ V₂]\n  {I₁ : K₁ →+* K} {I₂ : K₂ →+* K} {I₁' : K₁ →+* K}\n  {J₁ : K →+* K} {J₂ : K →+* K}\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J₁ is invertible\nlemma ortho_smul_left {B : V₁ →ₛₗ[I₁] V₂ →ₛₗ[I₂] K} {x y} {a : K₁} (ha : a ≠ 0) :\n  (is_ortho B x y) ↔ (is_ortho B (a • x) y) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smulₛₗ₂, H, smul_zero]},\n  { rw [map_smulₛₗ₂, smul_eq_zero] at H,\n    cases H,\n    { rw map_eq_zero I₁ at H, trivial },\n    { exact H }}\nend\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J₂ is invertible\nlemma ortho_smul_right {B : V₁ →ₛₗ[I₁] V₂ →ₛₗ[I₂] K} {x y} {a : K₂} {ha : a ≠ 0} :\n(is_ortho B x y) ↔ (is_ortho B x (a • y)) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smulₛₗ, H, smul_zero] },\n  { rw [map_smulₛₗ, smul_eq_zero] at H,\n    cases H,\n    { simp at H,\n      exfalso,\n      exact ha H },\n    { exact H }}\nend\n\n/-- A set of orthogonal vectors `v` with respect to some sesquilinear form `B` is linearly\n  independent if for all `i`, `B (v i) (v i) ≠ 0`. -/\nlemma linear_independent_of_is_Ortho {B : V₁ →ₛₗ[I₁] V₁ →ₛₗ[I₁'] K} {v : n → V₁}\n  (hv₁ : B.is_Ortho v) (hv₂ : ∀ i, ¬ B.is_ortho (v i) (v i)) : linear_independent K₁ v :=\nbegin\n  classical,\n  rw linear_independent_iff',\n  intros s w hs i hi,\n  have : B (s.sum $ λ (i : n), w i • v i) (v i) = 0,\n  { rw [hs, map_zero, zero_apply] },\n  have hsum : s.sum (λ (j : n), I₁(w j) * B (v j) (v i)) = I₁(w i) * B (v i) (v i),\n  { apply finset.sum_eq_single_of_mem i hi,\n    intros j hj hij,\n    rw [is_Ortho_def.1 hv₁ _ _ hij, mul_zero], },\n  simp_rw [B.map_sum₂, map_smulₛₗ₂, smul_eq_mul, hsum] at this,\n  apply (map_eq_zero I₁).mp,\n  exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv₂ i) this,\nend\n\nend field\n\n\n/-! ### Reflexive bilinear forms -/\n\nsection reflexive\n\nvariables [comm_semiring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  {I₁ : R₁ →+* R} {I₂ : R₁ →+* R}\n  {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n\n/-- The proposition that a sesquilinear form is reflexive -/\ndef is_refl (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : Prop :=\n  ∀ (x y), B x y = 0 → B y x = 0\n\nnamespace is_refl\n\nvariable (H : B.is_refl)\n\nlemma eq_zero : ∀ {x y}, B x y = 0 → B y x = 0 := λ x y, H x y\n\nlemma ortho_comm {x y} : is_ortho B x y ↔ is_ortho B y x := ⟨eq_zero H, eq_zero H⟩\n\nlemma dom_restrict_refl (H : B.is_refl) (p : submodule R₁ M₁) : (B.dom_restrict₁₂ p p).is_refl :=\nλ _ _, by { simp_rw dom_restrict₁₂_apply, exact H _ _}\n\n@[simp] lemma flip_is_refl_iff : B.flip.is_refl ↔ B.is_refl :=\n⟨λ h x y H, h y x ((B.flip_apply _ _).trans H), λ h x y, h y x⟩\n\nlemma ker_flip_eq_bot (H : B.is_refl) (h : B.ker = ⊥) : B.flip.ker = ⊥ :=\nbegin\n  refine ker_eq_bot'.mpr (λ _ hx, ker_eq_bot'.mp h _ _),\n  ext,\n  exact H _ _ (linear_map.congr_fun hx _),\nend\n\nlemma ker_eq_bot_iff_ker_flip_eq_bot (H : B.is_refl) : B.ker = ⊥ ↔ B.flip.ker = ⊥ :=\nbegin\n  refine ⟨ker_flip_eq_bot H, λ h, _⟩,\n  exact (congr_arg _ B.flip_flip.symm).trans (ker_flip_eq_bot (flip_is_refl_iff.mpr H) h),\nend\n\n\nend is_refl\nend reflexive\n\n/-! ### Symmetric bilinear forms -/\n\nsection symmetric\n\nvariables [comm_semiring R] [add_comm_monoid M] [module R M]\n  {I : R →+* R} {B : M →ₛₗ[I] M →ₗ[R] R}\n\n/-- The proposition that a sesquilinear form is symmetric -/\ndef is_symm (B : M →ₛₗ[I] M →ₗ[R] R) : Prop :=\n  ∀ (x y), I (B x y) = B y x\n\nnamespace is_symm\n\nprotected lemma eq (H : B.is_symm) (x y) : I (B x y) = B y x := H x y\n\nlemma is_refl (H : B.is_symm) : B.is_refl := λ x y H1, by { rw ←H.eq, simp [H1] }\n\nlemma ortho_comm (H : B.is_symm) {x y} : is_ortho B x y ↔ is_ortho B y x := H.is_refl.ortho_comm\n\nlemma dom_restrict_symm (H : B.is_symm) (p : submodule R M) : (B.dom_restrict₁₂ p p).is_symm :=\nλ _ _, by { simp_rw dom_restrict₁₂_apply, exact H _ _}\n\nend is_symm\n\nlemma is_symm_iff_eq_flip {B : M →ₗ[R] M →ₗ[R] R} : B.is_symm ↔ B = B.flip :=\nbegin\n  split; intro h,\n  { ext,\n    rw [←h, flip_apply, ring_hom.id_apply] },\n  intros x y,\n  conv_lhs { rw h },\n  rw [flip_apply, ring_hom.id_apply],\nend\n\nend symmetric\n\n\n/-! ### Alternating bilinear forms -/\n\nsection alternating\n\nvariables [comm_ring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  {I₁ : R₁ →+* R} {I₂ : R₁ →+* R} {I : R₁ →+* R} {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n\n/-- The proposition that a sesquilinear form is alternating -/\ndef is_alt (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : Prop := ∀ x, B x x = 0\n\nnamespace is_alt\n\nvariable (H : B.is_alt)\ninclude H\n\nlemma self_eq_zero (x) : B x x = 0 := H x\n\nlemma neg (x y) : - B x y = B y x :=\nbegin\n  have H1 : B (y + x) (y + x) = 0,\n  { exact self_eq_zero H (y + x) },\n  simp [map_add, self_eq_zero H] at H1,\n  rw [add_eq_zero_iff_neg_eq] at H1,\n  exact H1,\nend\n\nlemma is_refl : B.is_refl :=\nbegin\n  intros x y h,\n  rw [←neg H, h, neg_zero],\nend\n\nlemma ortho_comm {x y} : is_ortho B x y ↔ is_ortho B y x := H.is_refl.ortho_comm\n\nend is_alt\n\nlemma is_alt_iff_eq_neg_flip  [no_zero_divisors R] [char_zero R] {B : M₁ →ₛₗ[I] M₁ →ₛₗ[I] R} :\n  B.is_alt ↔ B = -B.flip :=\nbegin\n  split; intro h,\n  { ext,\n    simp_rw [neg_apply, flip_apply],\n    exact (h.neg _ _).symm },\n  intros x,\n  let h' := congr_fun₂ h x x,\n  simp only [neg_apply, flip_apply, ←add_eq_zero_iff_eq_neg] at h',\n  exact add_self_eq_zero.mp h',\nend\n\nend alternating\n\nend linear_map\n\nnamespace submodule\n\n/-! ### The orthogonal complement -/\n\nvariables [comm_ring R] [comm_ring R₁] [add_comm_group M₁] [module R₁ M₁]\n  {I₁ : R₁ →+* R} {I₂ : R₁ →+* R}\n  {B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R}\n\n/-- The orthogonal complement of a submodule `N` with respect to some bilinear form is the set of\nelements `x` which are orthogonal to all elements of `N`; i.e., for all `y` in `N`, `B x y = 0`.\n\nNote that for general (neither symmetric nor antisymmetric) bilinear forms this definition has a\nchirality; in addition to this \"left\" orthogonal complement one could define a \"right\" orthogonal\ncomplement for which, for all `y` in `N`, `B y x = 0`.  This variant definition is not currently\nprovided in mathlib. -/\ndef orthogonal_bilin (N : submodule R₁ M₁) (B : M₁ →ₛₗ[I₁] M₁ →ₛₗ[I₂] R) : submodule R₁ M₁ :=\n{ carrier := { m | ∀ n ∈ N, B.is_ortho n m },\n  zero_mem' := λ x _, B.is_ortho_zero_right x,\n  add_mem' := λ x y hx hy n hn,\n    by rw [linear_map.is_ortho, map_add, show B n x = 0, by exact hx n hn,\n        show B n y = 0, by exact hy n hn, zero_add],\n  smul_mem' := λ c x hx n hn,\n    by rw [linear_map.is_ortho, linear_map.map_smulₛₗ, show B n x = 0, by exact hx n hn,\n        smul_zero] }\n\nvariables {N L : submodule R₁ M₁}\n\n@[simp] lemma mem_orthogonal_bilin_iff {m : M₁} :\n  m ∈ N.orthogonal_bilin B ↔ ∀ n ∈ N, B.is_ortho n m := iff.rfl\n\nlemma orthogonal_bilin_le (h : N ≤ L) : L.orthogonal_bilin B ≤ N.orthogonal_bilin B :=\nλ _ hn l hl, hn l (h hl)\n\nlemma le_orthogonal_bilin_orthogonal_bilin (b : B.is_refl) :\n  N ≤ (N.orthogonal_bilin B).orthogonal_bilin B :=\nλ n hn m hm, b _ _ (hm n hn)\n\nend submodule\n\nnamespace linear_map\n\nsection orthogonal\n\nvariables [field K] [add_comm_group V] [module K V]\n  [field K₁] [add_comm_group V₁] [module K₁ V₁]\n  {J : K →+* K} {J₁ : K₁ →+* K} {J₁' : K₁ →+* K}\n\n-- ↓ This lemma only applies in fields as we require `a * b = 0 → a = 0 ∨ b = 0`\nlemma span_singleton_inf_orthogonal_eq_bot\n  (B : V₁ →ₛₗ[J₁] V₁ →ₛₗ[J₁'] K) (x : V₁) (hx : ¬ B.is_ortho x x) :\n  (K₁ ∙ x) ⊓ submodule.orthogonal_bilin (K₁ ∙ x) B = ⊥ :=\nbegin\n  rw ← finset.coe_singleton,\n  refine eq_bot_iff.2 (λ y h, _),\n  rcases mem_span_finset.1 h.1 with ⟨μ, rfl⟩,\n  have := h.2 x _,\n  { rw finset.sum_singleton at this ⊢,\n    suffices hμzero : μ x = 0,\n    { rw [hμzero, zero_smul, submodule.mem_bot] },\n    change B x (μ x • x) = 0 at this, rw [map_smulₛₗ, smul_eq_mul] at this,\n    exact or.elim (zero_eq_mul.mp this.symm)\n    (λ y, by { simp at y, exact y })\n    (λ hfalse, false.elim $ hx hfalse) },\n  { rw submodule.mem_span; exact λ _ hp, hp $ finset.mem_singleton_self _ }\nend\n\n-- ↓ This lemma only applies in fields since we use the `mul_eq_zero`\nlemma orthogonal_span_singleton_eq_to_lin_ker {B : V →ₗ[K] V →ₛₗ[J] K} (x : V) :\n  submodule.orthogonal_bilin (K ∙ x) B = (B x).ker :=\nbegin\n  ext y,\n  simp_rw [submodule.mem_orthogonal_bilin_iff, linear_map.mem_ker,\n           submodule.mem_span_singleton ],\n  split,\n  { exact λ h, h x ⟨1, one_smul _ _⟩ },\n  { rintro h _ ⟨z, rfl⟩,\n    rw [is_ortho, map_smulₛₗ₂, smul_eq_zero],\n    exact or.intro_right _ h }\nend\n\n\n-- todo: Generalize this to sesquilinear maps\nlemma span_singleton_sup_orthogonal_eq_top {B : V →ₗ[K] V →ₗ[K] K}\n  {x : V} (hx : ¬ B.is_ortho x x) :\n  (K ∙ x) ⊔ submodule.orthogonal_bilin (K ∙ x) B = ⊤ :=\nbegin\n  rw orthogonal_span_singleton_eq_to_lin_ker,\n  exact (B x).span_singleton_sup_ker_eq_top hx,\nend\n\n\n-- todo: Generalize this to sesquilinear maps\n/-- Given a bilinear form `B` and some `x` such that `B x x ≠ 0`, the span of the singleton of `x`\n  is complement to its orthogonal complement. -/\nlemma is_compl_span_singleton_orthogonal {B : V →ₗ[K] V →ₗ[K] K}\n  {x : V} (hx : ¬ B.is_ortho x x) : is_compl (K ∙ x) (submodule.orthogonal_bilin (K ∙ x) B) :=\n{ disjoint := disjoint_iff.2 $ span_singleton_inf_orthogonal_eq_bot B x hx,\n  codisjoint := codisjoint_iff.2 $ span_singleton_sup_orthogonal_eq_top hx }\n\nend orthogonal\n\n/-! ### Adjoint pairs -/\n\nsection adjoint_pair\n\nsection add_comm_monoid\n\nvariables [comm_semiring R]\nvariables [add_comm_monoid M] [module R M]\nvariables [add_comm_monoid M₁] [module R M₁]\nvariables [add_comm_monoid M₂] [module R M₂]\nvariables {I : R →+* R}\nvariables {B F : M →ₗ[R] M →ₛₗ[I] R} {B' : M₁ →ₗ[R] M₁ →ₛₗ[I] R} {B'' : M₂ →ₗ[R] M₂ →ₛₗ[I] R}\nvariables {f f' : M →ₗ[R] M₁} {g g' : M₁ →ₗ[R] M}\n\nvariables (B B' f g)\n\n/-- Given a pair of modules equipped with bilinear forms, this is the condition for a pair of\nmaps between them to be mutually adjoint. -/\ndef is_adjoint_pair := ∀ x y, B' (f x) y = B x (g y)\n\nvariables {B B' f g}\n\nlemma is_adjoint_pair_iff_comp_eq_compl₂ :\n  is_adjoint_pair B B' f g ↔ B'.comp f = B.compl₂ g :=\nbegin\n  split; intros h,\n  { ext x y, rw [comp_apply, compl₂_apply], exact h x y },\n  { intros _ _, rw [←compl₂_apply, ←comp_apply, h] },\nend\n\nlemma is_adjoint_pair_zero : is_adjoint_pair B B' 0 0 :=\nλ _ _, by simp only [zero_apply, map_zero]\n\nlemma is_adjoint_pair_id : is_adjoint_pair B B 1 1 := λ x y, rfl\n\nlemma is_adjoint_pair.add (h : is_adjoint_pair B B' f g) (h' : is_adjoint_pair B B' f' g') :\n  is_adjoint_pair B B' (f + f') (g + g') :=\nλ x _, by rw [f.add_apply, g.add_apply, B'.map_add₂, (B x).map_add, h, h']\n\nlemma is_adjoint_pair.comp {f' : M₁ →ₗ[R] M₂} {g' : M₂ →ₗ[R] M₁}\n  (h : is_adjoint_pair B B' f g) (h' : is_adjoint_pair B' B'' f' g') :\n  is_adjoint_pair B B'' (f'.comp f) (g.comp g') :=\nλ _ _, by rw [linear_map.comp_apply, linear_map.comp_apply, h', h]\n\nlemma is_adjoint_pair.mul\n  {f g f' g' : module.End R M} (h : is_adjoint_pair B B f g) (h' : is_adjoint_pair B B f' g') :\n  is_adjoint_pair B B (f * f') (g' * g) :=\nh'.comp h\n\nend add_comm_monoid\n\nsection add_comm_group\n\nvariables [comm_ring R]\nvariables [add_comm_group M] [module R M]\nvariables [add_comm_group M₁] [module R M₁]\nvariables {B F : M →ₗ[R] M →ₗ[R] R} {B' : M₁ →ₗ[R] M₁ →ₗ[R] R}\nvariables {f f' : M →ₗ[R] M₁} {g g' : M₁ →ₗ[R] M}\n\nlemma is_adjoint_pair.sub (h : is_adjoint_pair B B' f g) (h' : is_adjoint_pair B B' f' g') :\n  is_adjoint_pair B B' (f - f') (g - g') :=\nλ x _, by rw [f.sub_apply, g.sub_apply, B'.map_sub₂, (B x).map_sub, h, h']\n\nlemma is_adjoint_pair.smul (c : R) (h : is_adjoint_pair B B' f g) :\n  is_adjoint_pair B B' (c • f) (c • g) :=\nλ _ _, by simp only [smul_apply, map_smul, smul_eq_mul, h _ _]\n\nend add_comm_group\n\nend adjoint_pair\n\n/-! ### Self-adjoint pairs-/\n\nsection selfadjoint_pair\n\nsection add_comm_monoid\n\nvariables [comm_semiring R]\nvariables [add_comm_monoid M] [module R M]\nvariables {I : R →+* R}\nvariables (B F : M →ₗ[R] M →ₛₗ[I] R)\n\n/-- The condition for an endomorphism to be \"self-adjoint\" with respect to a pair of bilinear forms\non the underlying module. In the case that these two forms are identical, this is the usual concept\nof self adjointness. In the case that one of the forms is the negation of the other, this is the\nusual concept of skew adjointness. -/\ndef is_pair_self_adjoint (f : module.End R M) := is_adjoint_pair B F f f\n\n/-- An endomorphism of a module is self-adjoint with respect to a bilinear form if it serves as an\nadjoint for itself. -/\nprotected def is_self_adjoint (f : module.End R M) := is_adjoint_pair B B f f\n\nend add_comm_monoid\n\nsection add_comm_group\n\nvariables [comm_ring R]\nvariables [add_comm_group M] [module R M]\nvariables [add_comm_group M₁] [module R M₁]\n(B F : M →ₗ[R] M →ₗ[R] R)\n\n/-- The set of pair-self-adjoint endomorphisms are a submodule of the type of all endomorphisms. -/\ndef is_pair_self_adjoint_submodule : submodule R (module.End R M) :=\n{ carrier   := { f | is_pair_self_adjoint B F f },\n  zero_mem' := is_adjoint_pair_zero,\n  add_mem'  := λ f g hf hg, hf.add hg,\n  smul_mem' := λ c f h, h.smul c, }\n\n/-- An endomorphism of a module is skew-adjoint with respect to a bilinear form if its negation\nserves as an adjoint. -/\ndef is_skew_adjoint (f : module.End R M) := is_adjoint_pair B B f (-f)\n\n/-- The set of self-adjoint endomorphisms of a module with bilinear form is a submodule. (In fact\nit is a Jordan subalgebra.) -/\ndef self_adjoint_submodule := is_pair_self_adjoint_submodule B B\n\n/-- The set of skew-adjoint endomorphisms of a module with bilinear form is a submodule. (In fact\nit is a Lie subalgebra.) -/\ndef skew_adjoint_submodule := is_pair_self_adjoint_submodule (-B) B\n\nvariables {B F}\n\n@[simp] lemma mem_is_pair_self_adjoint_submodule (f : module.End R M) :\n  f ∈ is_pair_self_adjoint_submodule B F ↔ is_pair_self_adjoint B F f :=\niff.rfl\n\nlemma is_pair_self_adjoint_equiv (e : M₁ ≃ₗ[R] M) (f : module.End R M) :\n  is_pair_self_adjoint B F f ↔\n    is_pair_self_adjoint (B.compl₁₂ ↑e ↑e) (F.compl₁₂ ↑e ↑e) (e.symm.conj f) :=\nbegin\n  have hₗ : (F.compl₁₂ (↑e : M₁ →ₗ[R] M) (↑e : M₁ →ₗ[R] M)).comp (e.symm.conj f) =\n    (F.comp f).compl₁₂ (↑e : M₁ →ₗ[R] M) (↑e : M₁ →ₗ[R] M) :=\n  by { ext, simp only [linear_equiv.symm_conj_apply, coe_comp, linear_equiv.coe_coe, compl₁₂_apply,\n    linear_equiv.apply_symm_apply], },\n  have hᵣ : (B.compl₁₂ (↑e : M₁ →ₗ[R] M) (↑e : M₁ →ₗ[R] M)).compl₂ (e.symm.conj f) =\n    (B.compl₂ f).compl₁₂ (↑e : M₁ →ₗ[R] M) (↑e : M₁ →ₗ[R] M) :=\n  by { ext, simp only [linear_equiv.symm_conj_apply, compl₂_apply, coe_comp, linear_equiv.coe_coe,\n      compl₁₂_apply, linear_equiv.apply_symm_apply] },\n  have he : function.surjective (⇑(↑e : M₁ →ₗ[R] M) : M₁ → M) := e.surjective,\n  simp_rw [is_pair_self_adjoint, is_adjoint_pair_iff_comp_eq_compl₂, hₗ, hᵣ,\n    compl₁₂_inj he he],\nend\n\nlemma is_skew_adjoint_iff_neg_self_adjoint (f : module.End R M) :\n  B.is_skew_adjoint f ↔ is_adjoint_pair (-B) B f f :=\nshow (∀ x y, B (f x) y = B x ((-f) y)) ↔ ∀ x y, B (f x) y = (-B) x (f y),\nby simp\n\n@[simp] lemma mem_self_adjoint_submodule (f : module.End R M) :\n  f ∈ B.self_adjoint_submodule ↔ B.is_self_adjoint f := iff.rfl\n\n@[simp] lemma mem_skew_adjoint_submodule (f : module.End R M) :\n  f ∈ B.skew_adjoint_submodule ↔ B.is_skew_adjoint f :=\nby { rw is_skew_adjoint_iff_neg_self_adjoint, exact iff.rfl }\n\nend add_comm_group\n\nend selfadjoint_pair\n\n/-! ### Nondegenerate bilinear forms -/\n\nsection nondegenerate\n\nsection comm_semiring\nvariables [comm_semiring R] [comm_semiring R₁] [add_comm_monoid M₁] [module R₁ M₁]\n  [comm_semiring R₂] [add_comm_monoid M₂] [module R₂ M₂]\n  {I₁ : R₁ →+* R} {I₂ : R₂ →+* R} {I₁' : R₁ →+* R}\n\n/-- A bilinear form is called left-separating if\nthe only element that is left-orthogonal to every other element is `0`; i.e.,\nfor every nonzero `x` in `M₁`, there exists `y` in `M₂` with `B x y ≠ 0`.-/\ndef separating_left (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) : Prop :=\n∀ x : M₁, (∀ y : M₂, B x y = 0) → x = 0\n\nvariables (M₁ M₂ I₁ I₂)\n\n/-- In a non-trivial module, zero is not non-degenerate. -/\nlemma not_separating_left_zero [nontrivial M₁] : ¬(0 : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R).separating_left :=\nlet ⟨m, hm⟩ := exists_ne (0 : M₁) in λ h, hm (h m $ λ n, rfl)\n\nvariables {M₁ M₂ I₁ I₂}\n\nlemma separating_left.ne_zero [nontrivial M₁] {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R}\n  (h : B.separating_left) : B ≠ 0 :=\nλ h0, not_separating_left_zero M₁ M₂ I₁ I₂ $ h0 ▸ h\n\nsection linear\n\nvariables [add_comm_monoid Mₗ₁] [add_comm_monoid Mₗ₂] [add_comm_monoid Mₗ₁'] [add_comm_monoid Mₗ₂']\nvariables [module R Mₗ₁] [module R Mₗ₂] [module R Mₗ₁'] [module R Mₗ₂']\nvariables {B : Mₗ₁ →ₗ[R] Mₗ₂ →ₗ[R] R} (e₁ : Mₗ₁ ≃ₗ[R] Mₗ₁') (e₂ : Mₗ₂ ≃ₗ[R] Mₗ₂')\n\nlemma separating_left.congr (h : B.separating_left) :\n  (e₁.arrow_congr (e₂.arrow_congr (linear_equiv.refl R R)) B).separating_left :=\nbegin\n  intros x hx,\n  rw ←e₁.symm.map_eq_zero_iff,\n  refine h (e₁.symm x) (λ y, _),\n  specialize hx (e₂ y),\n  simp only [linear_equiv.arrow_congr_apply, linear_equiv.symm_apply_apply,\n    linear_equiv.map_eq_zero_iff] at hx,\n  exact hx,\nend\n\n@[simp] lemma separating_left_congr_iff :\n  (e₁.arrow_congr (e₂.arrow_congr (linear_equiv.refl R R)) B).separating_left ↔ B.separating_left :=\n⟨λ h, begin\n  convert h.congr e₁.symm e₂.symm,\n  ext x y,\n  simp,\nend, separating_left.congr e₁ e₂⟩\n\nend linear\n\n/-- A bilinear form is called right-separating if\nthe only element that is right-orthogonal to every other element is `0`; i.e.,\nfor every nonzero `y` in `M₂`, there exists `x` in `M₁` with `B x y ≠ 0`.-/\ndef separating_right (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) : Prop :=\n∀ y : M₂, (∀ x : M₁, B x y = 0) → y = 0\n\n/-- A bilinear form is called non-degenerate if it is left-separating and right-separating. -/\ndef nondegenerate (B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R) : Prop := separating_left B ∧ separating_right B\n\n@[simp] lemma flip_separating_right {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.flip.separating_right ↔ B.separating_left := ⟨λ hB x hy, hB x hy, λ hB x hy, hB x hy⟩\n\n@[simp] lemma flip_separating_left {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.flip.separating_left ↔ separating_right B := by rw [←flip_separating_right, flip_flip]\n\n@[simp] lemma flip_nondegenerate {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.flip.nondegenerate ↔ B.nondegenerate :=\niff.trans and.comm (and_congr flip_separating_right flip_separating_left)\n\nlemma separating_left_iff_linear_nontrivial {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_left ↔ ∀ x : M₁, B x = 0 → x = 0 :=\nbegin\n  split; intros h x hB,\n  { let h' := h x,\n    simp only [hB, zero_apply, eq_self_iff_true, forall_const] at h',\n    exact h' },\n  have h' : B x = 0 := by { ext, rw [zero_apply], exact hB _ },\n  exact h x h',\nend\n\nlemma separating_right_iff_linear_flip_nontrivial {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_right ↔ ∀ y : M₂, B.flip y = 0 → y = 0 :=\nby rw [←flip_separating_left, separating_left_iff_linear_nontrivial]\n\n/-- A bilinear form is left-separating if and only if it has a trivial kernel. -/\ntheorem separating_left_iff_ker_eq_bot {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_left ↔ B.ker = ⊥ :=\niff.trans separating_left_iff_linear_nontrivial linear_map.ker_eq_bot'.symm\n\n/-- A bilinear form is right-separating if and only if its flip has a trivial kernel. -/\ntheorem separating_right_iff_flip_ker_eq_bot {B : M₁ →ₛₗ[I₁] M₂ →ₛₗ[I₂] R} :\n  B.separating_right ↔ B.flip.ker = ⊥ :=\nby rw [←flip_separating_left, separating_left_iff_ker_eq_bot]\n\nend comm_semiring\n\nsection comm_ring\n\nvariables [comm_ring R] [add_comm_group M] [module R M]\n  {I I' : R →+* R}\n\nlemma is_refl.nondegenerate_of_separating_left {B : M →ₗ[R] M →ₗ[R] R}\n  (hB : B.is_refl) (hB' : B.separating_left) : B.nondegenerate :=\nbegin\n  refine ⟨hB', _⟩,\n  rw [separating_right_iff_flip_ker_eq_bot, hB.ker_eq_bot_iff_ker_flip_eq_bot.mp],\n  rwa ←separating_left_iff_ker_eq_bot,\nend\n\nlemma is_refl.nondegenerate_of_separating_right {B : M →ₗ[R] M →ₗ[R] R}\n  (hB : B.is_refl) (hB' : B.separating_right) : B.nondegenerate :=\nbegin\n  refine ⟨_, hB'⟩,\n  rw [separating_left_iff_ker_eq_bot, hB.ker_eq_bot_iff_ker_flip_eq_bot.mpr],\n  rwa ←separating_right_iff_flip_ker_eq_bot,\nend\n\n/-- The restriction of a reflexive bilinear form `B` onto a submodule `W` is\nnondegenerate if `W` has trivial intersection with its orthogonal complement,\nthat is `disjoint W (W.orthogonal_bilin B)`. -/\nlemma nondegenerate_restrict_of_disjoint_orthogonal\n  {B : M →ₗ[R] M →ₗ[R] R} (hB : B.is_refl)\n  {W : submodule R M} (hW : disjoint W (W.orthogonal_bilin B)) :\n  (B.dom_restrict₁₂ W W).nondegenerate :=\nbegin\n  refine (hB.dom_restrict_refl W).nondegenerate_of_separating_left  _,\n  rintro ⟨x, hx⟩ b₁,\n  rw [submodule.mk_eq_zero, ← submodule.mem_bot R],\n  refine hW.le_bot ⟨hx, λ y hy, _⟩,\n  specialize b₁ ⟨y, hy⟩,\n  simp_rw [dom_restrict₁₂_apply, submodule.coe_mk] at b₁,\n  rw hB.ortho_comm,\n  exact b₁,\nend\n\n/-- An orthogonal basis with respect to a left-separating bilinear form has no self-orthogonal\nelements. -/\nlemma is_Ortho.not_is_ortho_basis_self_of_separating_left [nontrivial R]\n  {B : M →ₛₗ[I] M →ₛₗ[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_left)\n  (i : n) : ¬B.is_ortho (v i) (v i) :=\nbegin\n  intro ho,\n  refine v.ne_zero i (hB (v i) $ λ m, _),\n  obtain ⟨vi, rfl⟩ := v.repr.symm.surjective m,\n  rw [basis.repr_symm_apply, finsupp.total_apply, finsupp.sum, map_sum],\n  apply finset.sum_eq_zero,\n  rintros j -,\n  rw map_smulₛₗ,\n  convert mul_zero _ using 2,\n  obtain rfl | hij := eq_or_ne i j,\n  { exact ho },\n  { exact h hij },\nend\n\n/-- An orthogonal basis with respect to a right-separating bilinear form has no self-orthogonal\nelements. -/\nlemma is_Ortho.not_is_ortho_basis_self_of_separating_right [nontrivial R]\n  {B : M →ₛₗ[I] M →ₛₗ[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_right)\n  (i : n) : ¬B.is_ortho (v i) (v i) :=\nbegin\n  rw is_Ortho_flip at h,\n  rw is_ortho_flip,\n  exact h.not_is_ortho_basis_self_of_separating_left (flip_separating_left.mpr hB) i,\nend\n\n/-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is left-separating\nif the basis has no elements which are self-orthogonal. -/\nlemma is_Ortho.separating_left_of_not_is_ortho_basis_self [no_zero_divisors R]\n  {B : M →ₗ[R] M →ₗ[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : ∀ i, ¬B.is_ortho (v i) (v i)) :\n  B.separating_left :=\nbegin\n  intros m hB,\n  obtain ⟨vi, rfl⟩ := v.repr.symm.surjective m,\n  rw linear_equiv.map_eq_zero_iff,\n  ext i,\n  rw [finsupp.zero_apply],\n  specialize hB (v i),\n  simp_rw [basis.repr_symm_apply, finsupp.total_apply, finsupp.sum, map_sum₂, map_smulₛₗ₂,\n    smul_eq_mul] at hB,\n  rw finset.sum_eq_single i at hB,\n  { exact eq_zero_of_ne_zero_of_mul_right_eq_zero (h i) hB, },\n  { intros j hj hij, convert mul_zero _ using 2, exact hO hij, },\n  { intros hi, convert zero_mul _ using 2, exact finsupp.not_mem_support_iff.mp hi }\nend\n\n/-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is right-separating\nif the basis has no elements which are self-orthogonal. -/\nlemma is_Ortho.separating_right_iff_not_is_ortho_basis_self [no_zero_divisors R]\n  {B : M →ₗ[R] M →ₗ[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : ∀ i, ¬B.is_ortho (v i) (v i)) :\n  B.separating_right :=\nbegin\n  rw is_Ortho_flip at hO,\n  rw [←flip_separating_left],\n  refine is_Ortho.separating_left_of_not_is_ortho_basis_self v hO (λ i, _),\n  rw is_ortho_flip,\n  exact h i,\nend\n\n/-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is nondegenerate\nif the basis has no elements which are self-orthogonal. -/\nlemma is_Ortho.nondegenerate_of_not_is_ortho_basis_self [no_zero_divisors R]\n  {B : M →ₗ[R] M →ₗ[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : ∀ i, ¬B.is_ortho (v i) (v i)) :\n  B.nondegenerate :=\n⟨is_Ortho.separating_left_of_not_is_ortho_basis_self v hO h,\n  is_Ortho.separating_right_iff_not_is_ortho_basis_self v hO h⟩\n\nend comm_ring\n\nend nondegenerate\n\nend linear_map\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/linear_algebra/sesquilinear_form.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.4587049392124738}}
{"text": "theorem tst1 {α : Type} {p : Prop} (xs : List α) (h₁ : (a : α) → (as : List α) → xs = a :: as → p) (h₂ : xs = [] → p) : p :=\nby match (generalizing := false) h : xs with\n   | []    => exact h₂ h\n   | z::zs => apply h₁ z zs; assumption\n\ntheorem tst1' {α : Type} {p : Prop} (xs : List α) (h₁ : (a : α) → (as : List α) → xs = a :: as → p) (h₂ : xs = [] → p) : p :=\nby match xs with\n   | []    => exact h₂ rfl\n   | z::zs => exact h₁ z zs rfl\n\ntheorem tst2 {α : Type} {p : Prop} (xs : List α) (h₁ : (a : α) → (as : List α) → xs = a :: as → p) (h₂ : xs = [] → p) : p :=\nby match (generalizing := false) h:xs with\n   | []    => ?nilCase\n   | z::zs => ?consCase;\n   case consCase => exact h₁ z zs h;\n   case nilCase => exact h₂ h\n\ndef tst3 {α β γ : Type} (h : α × β × γ) : β × α × γ :=\nby {\n  match h with\n  | (a, b, c) => exact (b, a, c)\n}\n\ntheorem tst4 {α : Type} {p : Prop} (xs : List α) (h₁ : (a : α) → (as : List α) → xs = a :: as → p) (h₂ : xs = [] → p) : p := by\nmatch (generalizing := false) h : xs with\n| []    => _\n| z::zs => _\ncase match_2 => exact h₁ z zs h\nexact h₂ h\n\ntheorem tst5 {p q r} (h : p ∨ q ∨ r) : r ∨ q ∨ p:= by\nmatch h with\n| Or.inl h          => exact Or.inr (Or.inr h)\n| Or.inr (Or.inl h) => ?c1\n| Or.inr (Or.inr h) => ?c2\ncase c2 =>\n  apply Or.inl\n  assumption\ncase c1 =>\n  apply Or.inr\n  apply Or.inl\n  assumption\n\ntheorem tst6 {p q r} (h : p ∨ q ∨ r) : r ∨ q ∨ p:= by\nmatch h with\n| Or.inl h          => exact Or.inr (Or.inr h)\n| Or.inr (Or.inl h) => ?c1\n| Or.inr (Or.inr h) =>\n  apply Or.inl\n  assumption\ncase c1 => apply Or.inr; apply Or.inl; assumption\n\ntheorem tst7 {p q r} (h : p ∨ q ∨ r) : r ∨ q ∨ p:=\nby match h with\n   | Or.inl h =>\n     exact Or.inr (Or.inr h)\n   | Or.inr (Or.inl h) =>\n     apply Or.inr;\n     apply Or.inl;\n     assumption\n   | Or.inr (Or.inr h) =>\n     apply Or.inl;\n     assumption\n\ninductive ListLast.{u} {α : Type u} : List α → Type u\n| empty    : ListLast []\n| nonEmpty : (as : List α) → (a : α) → ListLast (as ++ [a])\n\naxiom last {α} (xs : List α) : ListLast xs\naxiom back {α} [Inhabited α] (xs : List α) : α\naxiom popBack {α} : List α → List α\naxiom backEq {α} [Inhabited α] : (xs : List α) → (x : α) → back (xs ++ [x]) = x\naxiom popBackEq {α} : (xs : List α) → (x : α) → popBack (xs ++ [x]) = xs\n\ntheorem tst8 {α} [Inhabited α] (xs : List α) : xs ≠ [] → xs = popBack xs ++ [back xs] :=\nmatch (generalizing := false) xs, h:last xs with\n| _, ListLast.empty         => fun h => absurd rfl h\n| _, ListLast.nonEmpty ys y => fun _ => sorry\n\ntheorem tst9 {α} [Inhabited α] (xs : List α) : xs ≠ [] → xs = popBack xs ++ [back xs] := by\n  match (generalizing := false) xs, h:last xs with\n  | _, ListLast.empty         => intro h; exact absurd rfl h\n  | _, ListLast.nonEmpty ys y => intro; rw [popBackEq, backEq]\n\ntheorem tst8' {α} [Inhabited α] (xs : List α) : xs ≠ [] → xs = popBack xs ++ [back xs] :=\nmatch xs, last xs with\n| _, ListLast.empty         => fun h => absurd rfl h\n| _, ListLast.nonEmpty ys y => fun _ => sorry\n\ntheorem tst8'' {α} [Inhabited α] (xs : List α) (h : xs ≠ []) : xs = popBack xs ++ [back xs] :=\nmatch xs, last xs with\n| _, ListLast.empty         => absurd rfl h\n| _, ListLast.nonEmpty ys y => sorry\n\nexample (xs : List α) : xs = xs := by\n  match xs with\n  | [] | [x] | x::x'::xs => rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/matchtac.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.689305616785446, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.45867123103886115}}
{"text": "import analysis.complex.basic\nimport analysis.calculus.deriv\nimport tactic.pi_instances\nimport ring_theory.subring.basic\nimport analysis.normed_space.basic\nimport analysis.calculus.deriv\nimport analysis.analytic.basic\n\n\n\nlocal attribute [instance] classical.prop_decidable\nnoncomputable theory\n\nuniverses u v\nopen_locale classical topological_space big_operators filter\nopen filter complex asymptotics\n\nsection\nvariables {α : Type*} {β : Type*} {s : set α}\n\ndef extend_by_zero [has_zero β] (f : s → β) : α → β :=\nλ z, if h : z ∈ s then f ⟨z, h⟩ else 0\n\nlemma extend_by_zero_eq_of_mem [has_zero β] (f : s → β) (x : α) (hx : x ∈ s):\n  (extend_by_zero f) x = f ⟨ x, hx ⟩ :=\nbegin\n  rw extend_by_zero, dsimp, split_ifs, tauto,\nend\n\nlemma extend_by_zero_zero [has_zero β] :\nextend_by_zero (λ s, 0 : s → β) = (λ h, 0) :=\nby ext z; by_cases h : z ∈ s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_zero' [has_zero β] :\nextend_by_zero (0 : s → β) = 0 :=\nby ext z; by_cases h : z ∈ s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_f_eq_zero [has_zero β] (f : s → β)\n(h : extend_by_zero f = 0) : f = 0 :=\nbegin\n\nsorry,\nend\n\nlemma extend_by_zero_f_neq_zero [has_zero β] (f : s → β)\n(h : extend_by_zero f ≠ 0) : f ≠ 0 :=\nbegin\n\nsorry,\nend\n\nlemma extend_by_zero_add [add_group β] (f g : s → β) :\nextend_by_zero (f + g) = extend_by_zero f + extend_by_zero g :=\nby ext z; by_cases h : z ∈ s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_sum [add_comm_monoid β] (ι  : finset α) (F : ι →  s → β) :\nextend_by_zero (λ (x : s), ∑ (i : ι ), F i x) = ∑ (i : ι), extend_by_zero (F i) :=\nbegin\next z,\nby_cases h : z ∈ s,\nsimp only [extend_by_zero, h, finset.sum_apply, dif_pos],\nsimp only [extend_by_zero, h, finset.sum_apply, dif_neg, not_false_iff, finset.sum_const_zero],\nend\n\nlemma extend_by_zero_mul [semiring β] (f g : s → β) :\nextend_by_zero (f * g) = extend_by_zero f * extend_by_zero g :=\nby ext z; by_cases h : z ∈ s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_neg [add_group β] (f : s → β) :\nextend_by_zero (-f) = -extend_by_zero f :=\nby ext z; by_cases h : z ∈ s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_smul [ring β] (c : β) (f : s → β) :\n  extend_by_zero (c • f) = c • extend_by_zero f :=\n  by ext z; by_cases h : z ∈ s; simp [extend_by_zero, h]\n\nend\n\ndef open_subs := topological_space.opens ℂ\n\n/--A function is Holomorphic on an open subset of the complex numbers, if for every point in the domain\nthere is a neibourhood around the point containing the derivative of the function. In order to make it work\nwith has_deriv_within_at, we first extend the function by zero to the entire complex plane. -/\n\n\ndef is_holomorphic_on {D : open_subs} (f : D.1 → ℂ) : Prop :=\n  ∀ z : D.1, ∃ f', has_deriv_within_at (extend_by_zero f) (f') D.1 z\n\n\nlemma is_holomorphic_on_iff_differentiable_on  (D : open_subs) (f : D.1 → ℂ):\n  differentiable_on ℂ (extend_by_zero f) D.1 ↔ is_holomorphic_on f:=\nbegin\n  rw is_holomorphic_on,\n  split,\n  rw differentiable_on,\n  intros hd z,\n  have h1:= hd z.1 z.2,\n  have h2:=  differentiable_within_at.has_fderiv_within_at h1,\n  simp_rw has_deriv_within_at,\n  simp_rw has_deriv_at_filter,\n  simp_rw has_fderiv_within_at at h2,\n  simp at *,\n  dunfold fderiv_within at h2,\n  dunfold differentiable_within_at at h1,\n  rw dif_pos h1 at h2,\n  use classical.some h1 1,\n  simp,\n  exact h2,\n  intro hz,\n  rw differentiable_on,\n  intros x hx,\n  have h1:= hz ⟨x, hx⟩,\n  have h2:= classical.some_spec h1,\n  apply has_deriv_within_at.differentiable_within_at  h2,\nend\n\nvariable {D : open_subs}\n\nlemma ext_by_zero_eq (D: open_subs) (c : ℂ):\n∀ (y : ℂ), (y ∈ (D.1 : set ℂ)) → extend_by_zero (λ z : D.1, (c : ℂ)) y = c :=\nbegin\n  intros y hy,\n  rw extend_by_zero,\n  simp only [dite_eq_ite],\n  cases D,\n  dsimp at *,\n  simp only [ite_eq_left_iff] at *,\n  intros A,\n  solve_by_elim,\nend\n\nlemma ext_by_zero_eq' (D: open_subs) (f : D.1 → ℂ) (y : ℂ) (h: y ∈ (D.1 : set ℂ)):\n  extend_by_zero (f ) y = (f ⟨ y, h⟩) :=\nbegin\n  rw extend_by_zero,\n  simp,\n  cases D,\n  dsimp at *,\n  exact dif_pos h,\nend\n\nlemma ext_by_zero_apply (D: open_subs) (f : D.1 → ℂ) (y : D.1) :\n  extend_by_zero (f ) y = (f y) :=\nbegin\n  have:= ext_by_zero_eq' D f y y.2,\n  rw this,\n  simp,\nend\n\nlemma const_hol  (c : ℂ) : is_holomorphic_on (λ z : D.1, (c : ℂ)) :=\nbegin\n  rw is_holomorphic_on,\n  intro z,\n  use (0: ℂ),\n  have h1:=has_deriv_within_at_const  z.1 D.1 c,\n  have H:= has_deriv_within_at.congr_of_eventually_eq_of_mem h1 _ z.property ,\n  convert H,\n  rw  eventually_eq,\n  rw eventually_iff_exists_mem,\n  use D.1,\n  have H2:= ext_by_zero_eq D c,\n  split,\n  have h3:= D.2,\n  simp at h3,\n  have h4:=is_open.mem_nhds h3 z.2,\n  simp only [subtype.val_eq_coe],\n  convert h4,\n  simp,\n  rw nhds_within,\n  simp only [inf_eq_left, le_principal_iff],\n  exact h4,\n  exact H2,\nend\n\nlemma zero_hol (D: open_subs) : is_holomorphic_on (λ z : D.1, (0 : ℂ)) :=\nbegin\n  apply const_hol (0:ℂ ),\nend\n\nlemma one_hol (D: open_subs) : is_holomorphic_on (λ z : D.1, (1 : ℂ)) :=\nbegin\napply const_hol (1: ℂ),\n\nend\nlemma add_hol (f g : D.1 → ℂ) (f_hol : is_holomorphic_on f) (g_hol : is_holomorphic_on g) :\n  is_holomorphic_on (f + g) :=\nbegin\n  intro z₀,\n  cases f_hol z₀ with f'z₀ Hf,\n  cases g_hol z₀ with g'z₀ Hg,\n  existsi (f'z₀ + g'z₀),\n  rw extend_by_zero_add,\n  have:=has_deriv_within_at.add Hf Hg,\n  exact this,\nend\n\nlemma mul_hol (f g : D.1 → ℂ) (f_hol : is_holomorphic_on f) (g_hol : is_holomorphic_on g) :\n  is_holomorphic_on (f * g) :=\nbegin\n  intro z₀,\n  cases f_hol z₀ with f'z₀ Hf,\n  cases g_hol z₀ with g'z₀ Hg,\n  existsi f'z₀*(extend_by_zero g z₀) + (extend_by_zero f z₀)*g'z₀,\n  rw extend_by_zero_mul,\n  have:=has_deriv_within_at.mul Hf Hg,\n  exact this,\nend\n\nlemma neg_hol (f : D.1 → ℂ) (f_hol : is_holomorphic_on f) : is_holomorphic_on (-f) :=\nbegin\n  intro z₀,\n  cases f_hol z₀ with f'z₀ H,\n  existsi -f'z₀,\n  rw extend_by_zero_neg,\n  have h3:=has_deriv_within_at.neg H,\n  exact h3,\nend\n\n/--The ring of holomorphic functions-/\ndef hol_ring (D: open_subs) : subring (D.1 → ℂ) :=\n{ carrier := {f : D.1 → ℂ | is_holomorphic_on f},\n  zero_mem' := zero_hol D,\n  add_mem'  := add_hol,\n  neg_mem'  := neg_hol,\n  mul_mem'  := mul_hol,\n  one_mem'  := one_hol D\n}\n\nlemma smul_hol (c : ℂ) (f : D.1 → ℂ) (f_hol : is_holomorphic_on f) : is_holomorphic_on (c • f) :=\nbegin\n  intro z₀,\n  cases f_hol z₀ with f'z₀ Hf,\n  existsi c * f'z₀,\n  rw extend_by_zero_smul,\n  have h2:= has_deriv_within_at.const_smul c Hf,\n  exact h2,\n\nend\n\ndef hol_submodule (D: open_subs) : submodule (ℂ)  (D.1 → ℂ) :=\n{ carrier := {f : D.1 → ℂ | is_holomorphic_on f},\n  zero_mem' := zero_hol D,\n  add_mem' := add_hol,\n  smul_mem' := smul_hol}\n\nlemma aux (s t d : set ℂ) (h :  s ⊆ t) : s ∩ d ⊆ t :=\nbegin\n  intros x hx,\n  apply h,\n  simp at *,\n  apply hx.1,\nend\n\nlemma aux2 (x : ℂ) (a b : ℝ) : metric.ball x a ∩ metric.ball x b = metric.ball x (min a b) :=\nbegin\n  ext,\n  split,\n  simp only [and_imp, metric.mem_ball, set.mem_inter_iff, lt_min_iff],\n  intros ha hb,\n  simp only [ha, hb, and_self],\n  simp only [and_imp, metric.mem_ball, set.mem_inter_iff, lt_min_iff],\n  intros ha hb,\n  simp only [ha, hb, and_self],\nend\n\n\nlemma diff_on_diff (f : D.1 → ℂ) (h : ∀ x : D.1, ∃ (ε: ℝ), 0 < ε ∧ (metric.ball x.1 ε ⊆ D.val ) ∧\n  differentiable_on ℂ (extend_by_zero f) (metric.ball x ε)) :\n  differentiable_on ℂ (extend_by_zero f) D.1 :=\nbegin\n  simp_rw differentiable_on at *,\n  simp_rw differentiable_within_at at *,\n  intros x hx,\n  have hh := h ⟨x, hx⟩,\n  obtain ⟨ε, hε, hb, H⟩:= hh,\n  have HH:= H x,\n  simp only [metric.mem_ball, subtype.coe_mk, dist_self] at HH,\n  have HHH:= HH hε,\n  obtain ⟨f', hf'⟩:= HHH,\n  use f',\n  simp_rw has_fderiv_within_at_iff_tendsto at *,\n  rw metric.tendsto_nhds at *,\n  intros δ hδ,\n  have hf2 := hf'  δ hδ,\n  rw filter.eventually_iff_exists_mem at *,\n  simp only [exists_prop, metric.mem_ball, gt_iff_lt, topological_space.opens.mem_coe,\n    dist_zero_right, continuous_linear_map.map_sub, set_coe.forall, subtype.coe_mk,\n    subtype.val_eq_coe,norm_eq_abs, norm_mul, norm_inv] at *,\n  obtain ⟨S, hS, HD⟩ := hf2,\n  simp_rw metric.mem_nhds_within_iff at *,\n  obtain ⟨e, he, HE⟩:= hS,\n  use S,\n  split,\n  use min e ε,\n  simp only [gt_iff_lt, topological_space.opens.mem_coe, lt_min_iff, subtype.val_eq_coe] at *,\n  simp only [he, hε, and_self],\n  simp only [true_and],\n  have : metric.ball x e ∩ metric.ball x ε = metric.ball x (min e ε), by {apply aux2,},\n  rw this at HE,\n  apply aux _ _ _ HE,\n  apply HD,\nend\n\nlemma tendsto_unif_extend_by_zero (F : ℕ → D.1 → ℂ) (f : D.1 → ℂ)\n(h: tendsto_uniformly F f filter.at_top ) :\n  tendsto_uniformly_on (λ (n : ℕ), extend_by_zero (F n)) (extend_by_zero f) filter.at_top D.1 :=\nbegin\n  simp_rw metric.tendsto_uniformly_on_iff,\n  rw metric.tendsto_uniformly_iff at h,\n  intros ε hε,\n  have h2:= h ε hε,\n  simp only [gt_iff_lt, topological_space.opens.mem_coe, ge_iff_le, nonempty_of_inhabited,\n  set_coe.forall, eventually_at_top, subtype.val_eq_coe] at *,\n  obtain ⟨a, ha⟩:= h2,\n  use a,\n  intros b hb x hx,\n  have hf:= ext_by_zero_apply D f ⟨x, hx⟩,\n  have hFb:= ext_by_zero_apply D (F b) ⟨x, hx⟩,\n  simp only [topological_space.opens.mem_coe, subtype.coe_mk, subtype.val_eq_coe] at *,\n  rw hf,\n  rw hFb,\n  apply ha b hb x hx,\nend", "meta": {"author": "ferrandf", "repo": "valenceformula", "sha": "c542edc32e3fc0ef142d69a0c897192f040e4b3e", "save_path": "github-repos/lean/ferrandf-valenceformula", "path": "github-repos/lean/ferrandf-valenceformula/valenceformula-c542edc32e3fc0ef142d69a0c897192f040e4b3e/src/holomorphic_functions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.4584755826497137}}
{"text": "/-\nCopyright (c) 2017 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\n! This file was ported from Lean 3 source module control.applicative\n! leanprover-community/mathlib commit 70d50ecfd4900dd6d328da39ab7ebd516abe4025\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Algebra.Group.Defs\nimport Mathlib.Control.Functor\n\n/-!\n# `applicative` instances\n\nThis file provides `Applicative` instances for concrete functors:\n* `id`\n* `Functor.comp`\n* `Functor.const`\n* `Functor.add_const`\n-/\n\nuniverse u v w\n\nsection Lemmas\n\nopen Function\n\nvariable {F : Type u → Type v}\n\nvariable [Applicative F] [LawfulApplicative F]\n\nvariable {α β γ σ : Type u}\n\ntheorem Applicative.map_seq_map (f : α → β → γ) (g : σ → β) (x : F α) (y : F σ) :\n    f <$> x <*> g <$> y = (flip (· ∘ ·) g ∘ f) <$> x <*> y := by simp [flip, functor_norm]\n#align applicative.map_seq_map Applicative.map_seq_map\n\ntheorem Applicative.pure_seq_eq_map' (f : α → β) : (· <*> ·) (pure f : F (α → β)) = (· <$> ·) f :=\n  by ext; simp [functor_norm]\n#align applicative.pure_seq_eq_map' Applicative.pure_seq_eq_map'\n\ntheorem Applicative.ext {F} :\n    ∀ {A1 : Applicative F} {A2 : Applicative F} [@LawfulApplicative F A1] [@LawfulApplicative F A2],\n      (∀ {α : Type u} (x : α), @Pure.pure _ A1.toPure _ x = @Pure.pure _ A2.toPure _ x) →\n      (∀ {α β : Type u} (f : F (α → β)) (x : F α),\n          @Seq.seq _ A1.toSeq _ _ f (fun _ => x) = @Seq.seq _ A2.toSeq _ _ f (fun _ => x)) →\n      A1 = A2\n  | { toFunctor := F1, seq := s1, pure := p1, seqLeft := sl1, seqRight := sr1 },\n    { toFunctor := F2, seq := s2, pure := p2, seqLeft := sl2, seqRight := sr2 }, L1, L2, H1, H2 =>\n    by\n    obtain rfl : @p1 = @p2 := by\n      funext α x\n      apply H1\n    obtain rfl : @s1 = @s2 := by\n      funext α β f x\n      exact H2 f (x Unit.unit)\n    obtain ⟨seqLeft_eq1, seqRight_eq1, pure_seq1, -⟩ := L1\n    obtain ⟨seqLeft_eq2, seqRight_eq2, pure_seq2, -⟩ := L2\n    obtain rfl : F1 = F2 := by\n      apply Functor.ext\n      intros\n      exact (pure_seq1 _ _).symm.trans (pure_seq2 _ _)\n    congr <;> funext α β x y\n    · exact (seqLeft_eq1 _ (y Unit.unit)).trans (seqLeft_eq2 _ _).symm\n    · exact (seqRight_eq1 _ (y Unit.unit)).trans (seqRight_eq2 _ (y Unit.unit)).symm\n\n#align applicative.ext Applicative.ext\n\nend Lemmas\n\n-- Porting note: mathport failed to see the #align on `CommApplicative`,\n-- therefore using `IsCommApplicative` instead.\n\n-- Porting note: we have a monad instance for `Id` but not `id`, mathport can't tell\n-- which one is intended\n\ninstance : CommApplicative Id := by refine' { .. } <;> intros <;> rfl\n\nnamespace Functor\n\nnamespace Comp\n\nopen Function hiding comp\n\nopen Functor\n\nvariable {F : Type u → Type w} {G : Type v → Type u}\n\nvariable [Applicative F] [Applicative G]\n\nvariable [LawfulApplicative F] [LawfulApplicative G]\n\nvariable {α β γ : Type v}\n\ntheorem map_pure (f : α → β) (x : α) : (f <$> pure x : Comp F G β) = pure (f x) :=\n  Comp.ext <| by simp\n#align functor.comp.map_pure Functor.Comp.map_pure\n\ntheorem seq_pure (f : Comp F G (α → β)) (x : α) : f <*> pure x = (fun g : α → β => g x) <$> f :=\n  Comp.ext <| by simp [(· ∘ ·), functor_norm]\n#align functor.comp.seq_pure Functor.Comp.seq_pure\n\ntheorem seq_assoc (x : Comp F G α) (f : Comp F G (α → β)) (g : Comp F G (β → γ)) :\n    g <*> (f <*> x) = @Function.comp α β γ <$> g <*> f <*> x :=\n  Comp.ext <| by simp [(· ∘ ·), functor_norm]\n#align functor.comp.seq_assoc Functor.Comp.seq_assoc\n\ntheorem pure_seq_eq_map (f : α → β) (x : Comp F G α) : pure f <*> x = f <$> x :=\n  Comp.ext <| by simp [Applicative.pure_seq_eq_map', functor_norm]\n#align functor.comp.pure_seq_eq_map Functor.Comp.pure_seq_eq_map\n\n-- TODO: the first two results were handled by `control_laws_tac` in mathlib3\ninstance : LawfulApplicative (Comp F G) where\n  seqLeft_eq := by intros; rfl\n  seqRight_eq := by intros; rfl\n  pure_seq := @Comp.pure_seq_eq_map F G _ _ _ _\n  map_pure := @Comp.map_pure F G _ _ _ _\n  seq_pure := @Comp.seq_pure F G _ _ _ _\n  seq_assoc := @Comp.seq_assoc F G _ _ _ _\n\n-- Porting note: mathport wasn't aware of the new implicit parameter omission in these `fun` binders\n\ntheorem applicative_id_comp {F} [AF : Applicative F] [LawfulApplicative F] :\n    @instApplicativeComp Id F _ _ = AF :=\n  @Applicative.ext F _ _ (@instLawfulApplicativeCompInstApplicativeComp Id F _ _ _ _) _\n    (fun _ => rfl) (fun _ _ => rfl)\n#align functor.comp.applicative_id_comp Functor.Comp.applicative_id_comp\n\ntheorem applicative_comp_id {F} [AF : Applicative F] [LawfulApplicative F] :\n    @Comp.instApplicativeComp F Id _ _ = AF :=\n  @Applicative.ext F _ _ (@Comp.instLawfulApplicativeCompInstApplicativeComp F Id _ _ _ _) _\n    (fun _ => rfl) (fun f x => show id <$> f <*> x = f <*> x by rw [id_map])\n#align functor.comp.applicative_comp_id Functor.Comp.applicative_comp_id\n\nopen CommApplicative\n\ninstance {f : Type u → Type w} {g : Type v → Type u} [Applicative f] [Applicative g]\n    [CommApplicative f] [CommApplicative g] : CommApplicative (Comp f g) := by\n  refine' { @instLawfulApplicativeCompInstApplicativeComp f g _ _ _ _ with .. }\n  intros\n  simp! [map, Seq.seq, functor_norm]\n  rw [commutative_map]\n  simp [Comp.mk, flip, (· ∘ ·), functor_norm]\n  congr\n  funext x y\n  rw [commutative_map]\n  congr\n\nend Comp\n\nend Functor\n\nopen Functor\n\n@[functor_norm]\ntheorem Comp.seq_mk {α β : Type w} {f : Type u → Type v} {g : Type w → Type u} [Applicative f]\n    [Applicative g] (h : f (g (α → β))) (x : f (g α)) :\n    Comp.mk h <*> Comp.mk x = Comp.mk ((· <*> ·) <$> h <*> x) :=\n  rfl\n#align comp.seq_mk Comp.seq_mk\n\n-- Porting note: There is some awkwardness in the following definition now that we have `HMul`.\n\ninstance {α} [One α] [Mul α] : Applicative (Const α) where\n  pure _ := (1 : α)\n  seq f x := (show α from f) * (show α from x Unit.unit)\n\n-- Porting note: `(· <*> ·)` needed to change to `Seq.seq` in the `simp`.\n-- Also, `simp` didn't close `refl` goals.\n\ninstance {α} [Monoid α] : LawfulApplicative (Const α) := by\n  refine' { .. } <;> intros <;> simp [mul_assoc, (· <$> ·), Seq.seq, pure] <;> rfl\n\ninstance {α} [Zero α] [Add α] : Applicative (AddConst α) where\n  pure _ := (0 : α)\n  seq f x := (show α from f) + (show α from x Unit.unit)\n\ninstance {α} [AddMonoid α] : LawfulApplicative (AddConst α) := by\n  refine' { .. } <;> intros <;> simp [add_assoc, (· <$> ·), Seq.seq, pure] <;> rfl\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Control/Applicative.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6619228758499942, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.4584755734109877}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.logic.embedding\nimport Mathlib.order.rel_classes\nimport Mathlib.data.set.intervals.basic\nimport Mathlib.PostPort\n\nuniverses u_4 u_5 l u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-- A relation homomorphism with respect to a given pair of relations `r` and `s`\nis a function `f : α → β` such that `r a b → s (f a) (f b)`. -/\nstructure rel_hom {α : Type u_4} {β : Type u_5} (r : α → α → Prop) (s : β → β → Prop) where\n  to_fun : α → β\n  map_rel' : ∀ {a b : α}, r a b → s (to_fun a) (to_fun b)\n\ninfixl:25 \" →r \" => Mathlib.rel_hom\n\nnamespace rel_hom\n\n\nprotected instance has_coe_to_fun {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} : has_coe_to_fun (r →r s) :=\n  has_coe_to_fun.mk (fun (_x : r →r s) => α → β) fun (o : r →r s) => to_fun o\n\ntheorem map_rel {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} (f : r →r s)\n    {a : α} {b : α} : r a b → s (coe_fn f a) (coe_fn f b) :=\n  map_rel' f\n\n@[simp] theorem coe_fn_mk {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : α → β) (o : ∀ {a b : α}, r a b → s (f a) (f b)) : ⇑(mk f o) = f :=\n  rfl\n\n@[simp] theorem coe_fn_to_fun {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r →r s) : to_fun f = ⇑f :=\n  rfl\n\n/-- The map `coe_fn : (r →r s) → (α → β)` is injective. We can't use `function.injective`\nhere but mimic its signature by using `⦃e₁ e₂⦄`. -/\ntheorem coe_fn_inj {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {e₁ : r →r s}\n    {e₂ : r →r s} : ⇑e₁ = ⇑e₂ → e₁ = e₂ :=\n  sorry\n\ntheorem ext {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {f : r →r s}\n    {g : r →r s} (h : ∀ (x : α), coe_fn f x = coe_fn g x) : f = g :=\n  coe_fn_inj (funext h)\n\ntheorem ext_iff {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {f : r →r s}\n    {g : r →r s} : f = g ↔ ∀ (x : α), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : α) => h ▸ rfl,\n    mpr := fun (h : ∀ (x : α), coe_fn f x = coe_fn g x) => ext h }\n\n/-- Identity map is a relation homomorphism. -/\nprotected def id {α : Type u_1} (r : α → α → Prop) : r →r r := mk id sorry\n\n/-- Composition of two relation homomorphisms is a relation homomorphism. -/\nprotected def comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → α → Prop}\n    {s : β → β → Prop} {t : γ → γ → Prop} (g : s →r t) (f : r →r s) : r →r t :=\n  mk (to_fun g ∘ to_fun f) sorry\n\n@[simp] theorem id_apply {α : Type u_1} {r : α → α → Prop} (x : α) : coe_fn (rel_hom.id r) x = x :=\n  rfl\n\n@[simp] theorem comp_apply {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → α → Prop}\n    {s : β → β → Prop} {t : γ → γ → Prop} (g : s →r t) (f : r →r s) (a : α) :\n    coe_fn (rel_hom.comp g f) a = coe_fn g (coe_fn f a) :=\n  rfl\n\n/-- A relation homomorphism is also a relation homomorphism between dual relations. -/\nprotected def swap {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r →r s) : function.swap r →r function.swap s :=\n  mk ⇑f sorry\n\n/-- A function is a relation homomorphism from the preimage relation of `s` to `s`. -/\ndef preimage {α : Type u_1} {β : Type u_2} (f : α → β) (s : β → β → Prop) : f ⁻¹'o s →r s :=\n  mk f sorry\n\nprotected theorem is_irrefl {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r →r s) [is_irrefl β s] : is_irrefl α r :=\n  sorry\n\nprotected theorem is_asymm {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r →r s) [is_asymm β s] : is_asymm α r :=\n  sorry\n\nprotected theorem acc {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r →r s) (a : α) : acc s (coe_fn f a) → acc r a :=\n  sorry\n\nprotected theorem well_founded {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r →r s) (h : well_founded s) : well_founded r :=\n  well_founded.dcases_on h\n    fun (h : ∀ (a : β), acc s a) =>\n      idRhs (well_founded r) (well_founded.intro fun (a : α) => rel_hom.acc f a (h (coe_fn f a)))\n\ntheorem map_inf {α : Type u_1} {β : Type u_2} [semilattice_inf α] [linear_order β]\n    (a : Less →r Less) (m : β) (n : β) : coe_fn a (m ⊓ n) = coe_fn a m ⊓ coe_fn a n :=\n  sorry\n\ntheorem map_sup {α : Type u_1} {β : Type u_2} [semilattice_sup α] [linear_order β] (a : gt →r gt)\n    (m : β) (n : β) : coe_fn a (m ⊔ n) = coe_fn a m ⊔ coe_fn a n :=\n  sorry\n\nend rel_hom\n\n\n/-- An increasing function is injective -/\ntheorem injective_of_increasing {α : Type u_1} {β : Type u_2} (r : α → α → Prop) (s : β → β → Prop)\n    [is_trichotomous α r] [is_irrefl β s] (f : α → β) (hf : ∀ {x y : α}, r x y → s (f x) (f y)) :\n    function.injective f :=\n  sorry\n\n/-- An increasing function is injective -/\ntheorem rel_hom.injective_of_increasing {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} [is_trichotomous α r] [is_irrefl β s] (f : r →r s) : function.injective ⇑f :=\n  injective_of_increasing r s ⇑f fun (x y : α) => rel_hom.map_rel f\n\ntheorem surjective.well_founded_iff {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} {f : α → β} (hf : function.surjective f)\n    (o : ∀ {a b : α}, r a b ↔ s (f a) (f b)) : well_founded r ↔ well_founded s :=\n  sorry\n\n/-- A relation embedding with respect to a given pair of relations `r` and `s`\nis an embedding `f : α ↪ β` such that `r a b ↔ s (f a) (f b)`. -/\nstructure rel_embedding {α : Type u_4} {β : Type u_5} (r : α → α → Prop) (s : β → β → Prop)\n    extends α ↪ β where\n  map_rel_iff' : ∀ {a b : α}, s (coe_fn _to_embedding a) (coe_fn _to_embedding b) ↔ r a b\n\ninfixl:25 \" ↪r \" => Mathlib.rel_embedding\n\n/-- An order embedding is an embedding `f : α ↪ β` such that `a ≤ b ↔ (f a) ≤ (f b)`.\nThis definition is an abbreviation of `rel_embedding (≤) (≤)`. -/\ndef order_embedding (α : Type u_1) (β : Type u_2) [HasLessEq α] [HasLessEq β] := LessEq ↪r LessEq\n\ninfixl:25 \" ↪o \" => Mathlib.order_embedding\n\n/-- The induced relation on a subtype is an embedding under the natural inclusion. -/\ndef subtype.rel_embedding {X : Type u_1} (r : X → X → Prop) (p : X → Prop) :\n    subtype.val ⁻¹'o r ↪r r :=\n  rel_embedding.mk (function.embedding.subtype p) sorry\n\ntheorem preimage_equivalence {α : Sort u_1} {β : Sort u_2} (f : α → β) {s : β → β → Prop}\n    (hs : equivalence s) : equivalence (f ⁻¹'o s) :=\n  sorry\n\nnamespace rel_embedding\n\n\n/-- A relation embedding is also a relation homomorphism -/\ndef to_rel_hom {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} (f : r ↪r s) :\n    r →r s :=\n  rel_hom.mk (function.embedding.to_fun (to_embedding f)) sorry\n\n-- see Note [function coercion]\n\nprotected instance rel_hom.has_coe {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} : has_coe (r ↪r s) (r →r s) :=\n  has_coe.mk to_rel_hom\n\nprotected instance has_coe_to_fun {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} : has_coe_to_fun (r ↪r s) :=\n  has_coe_to_fun.mk (fun (_x : r ↪r s) => α → β) fun (o : r ↪r s) => ⇑(to_embedding o)\n\n@[simp] theorem to_rel_hom_eq_coe {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) : to_rel_hom f = ↑f :=\n  rfl\n\n@[simp] theorem coe_coe_fn {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) : ⇑↑f = ⇑f :=\n  rfl\n\ntheorem injective {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} (f : r ↪r s) :\n    function.injective ⇑f :=\n  function.embedding.inj' (to_embedding f)\n\ntheorem map_rel_iff {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} (f : r ↪r s)\n    {a : α} {b : α} : s (coe_fn f a) (coe_fn f b) ↔ r a b :=\n  map_rel_iff' f\n\n@[simp] theorem coe_fn_mk {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : α ↪ β) (o : ∀ {a b : α}, s (coe_fn f a) (coe_fn f b) ↔ r a b) : ⇑(mk f o) = ⇑f :=\n  rfl\n\n@[simp] theorem coe_fn_to_embedding {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) : ⇑(to_embedding f) = ⇑f :=\n  rfl\n\n/-- The map `coe_fn : (r ↪r s) → (α → β)` is injective. We can't use `function.injective`\nhere but mimic its signature by using `⦃e₁ e₂⦄`. -/\ntheorem coe_fn_inj {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {e₁ : r ↪r s}\n    {e₂ : r ↪r s} : ⇑e₁ = ⇑e₂ → e₁ = e₂ :=\n  sorry\n\ntheorem ext {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {f : r ↪r s}\n    {g : r ↪r s} (h : ∀ (x : α), coe_fn f x = coe_fn g x) : f = g :=\n  coe_fn_inj (funext h)\n\ntheorem ext_iff {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {f : r ↪r s}\n    {g : r ↪r s} : f = g ↔ ∀ (x : α), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : α) => h ▸ rfl,\n    mpr := fun (h : ∀ (x : α), coe_fn f x = coe_fn g x) => ext h }\n\n/-- Identity map is a relation embedding. -/\nprotected def refl {α : Type u_1} (r : α → α → Prop) : r ↪r r :=\n  mk (function.embedding.refl α) sorry\n\n/-- Composition of two relation embeddings is a relation embedding. -/\nprotected def trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → α → Prop}\n    {s : β → β → Prop} {t : γ → γ → Prop} (f : r ↪r s) (g : s ↪r t) : r ↪r t :=\n  mk (function.embedding.trans (to_embedding f) (to_embedding g)) sorry\n\nprotected instance inhabited {α : Type u_1} (r : α → α → Prop) : Inhabited (r ↪r r) :=\n  { default := rel_embedding.refl r }\n\n@[simp] theorem refl_apply {α : Type u_1} {r : α → α → Prop} (x : α) :\n    coe_fn (rel_embedding.refl r) x = x :=\n  rfl\n\ntheorem trans_apply {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → α → Prop}\n    {s : β → β → Prop} {t : γ → γ → Prop} (f : r ↪r s) (g : s ↪r t) (a : α) :\n    coe_fn (rel_embedding.trans f g) a = coe_fn g (coe_fn f a) :=\n  rfl\n\n@[simp] theorem coe_trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → α → Prop}\n    {s : β → β → Prop} {t : γ → γ → Prop} (f : r ↪r s) (g : s ↪r t) :\n    ⇑(rel_embedding.trans f g) = ⇑g ∘ ⇑f :=\n  rfl\n\n/-- A relation embedding is also a relation embedding between dual relations. -/\nprotected def swap {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) : function.swap r ↪r function.swap s :=\n  mk (to_embedding f) sorry\n\n/-- If `f` is injective, then it is a relation embedding from the\n  preimage relation of `s` to `s`. -/\ndef preimage {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : β → β → Prop) : ⇑f ⁻¹'o s ↪r s :=\n  mk f sorry\n\ntheorem eq_preimage {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) : r = ⇑f ⁻¹'o s :=\n  funext fun (a : α) => funext fun (b : α) => propext (iff.symm (map_rel_iff f))\n\nprotected theorem is_irrefl {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_irrefl β s] : is_irrefl α r :=\n  is_irrefl.mk fun (a : α) => mt (iff.mpr (map_rel_iff f)) (irrefl (coe_fn f a))\n\nprotected theorem is_refl {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_refl β s] : is_refl α r :=\n  is_refl.mk fun (a : α) => iff.mp (map_rel_iff f) (refl (coe_fn f a))\n\nprotected theorem is_symm {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_symm β s] : is_symm α r :=\n  is_symm.mk fun (a b : α) => imp_imp_imp (iff.mpr (map_rel_iff f)) (iff.mp (map_rel_iff f)) symm\n\nprotected theorem is_asymm {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_asymm β s] : is_asymm α r :=\n  is_asymm.mk\n    fun (a b : α) (h₁ : r a b) (h₂ : r b a) =>\n      asymm (iff.mpr (map_rel_iff f) h₁) (iff.mpr (map_rel_iff f) h₂)\n\nprotected theorem is_antisymm {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_antisymm β s] : is_antisymm α r :=\n  sorry\n\nprotected theorem is_trans {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_trans β s] : is_trans α r :=\n  sorry\n\nprotected theorem is_total {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_total β s] : is_total α r :=\n  sorry\n\nprotected theorem is_preorder {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_preorder β s] : is_preorder α r :=\n  idRhs (is_preorder α r) is_preorder.mk\n\nprotected theorem is_partial_order {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) [is_partial_order β s] : is_partial_order α r :=\n  idRhs (is_partial_order α r) is_partial_order.mk\n\nprotected theorem is_linear_order {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) [is_linear_order β s] : is_linear_order α r :=\n  idRhs (is_linear_order α r) is_linear_order.mk\n\nprotected theorem is_strict_order {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) [is_strict_order β s] : is_strict_order α r :=\n  idRhs (is_strict_order α r) is_strict_order.mk\n\nprotected theorem is_trichotomous {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) [is_trichotomous β s] : is_trichotomous α r :=\n  sorry\n\nprotected theorem is_strict_total_order' {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) [is_strict_total_order' β s] : is_strict_total_order' α r :=\n  idRhs (is_strict_total_order' α r) is_strict_total_order'.mk\n\nprotected theorem acc {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) (a : α) : acc s (coe_fn f a) → acc r a :=\n  sorry\n\nprotected theorem well_founded {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) (h : well_founded s) : well_founded r :=\n  well_founded.dcases_on h\n    fun (h : ∀ (a : β), acc s a) =>\n      idRhs (well_founded r)\n        (well_founded.intro fun (a : α) => rel_embedding.acc f a (h (coe_fn f a)))\n\nprotected theorem is_well_order {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ↪r s) [is_well_order β s] : is_well_order α r :=\n  idRhs (is_well_order α r) (is_well_order.mk (rel_embedding.well_founded f is_well_order.wf))\n\n/-- It suffices to prove `f` is monotone between strict relations\n  to show it is a relation embedding. -/\ndef of_monotone {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    [is_trichotomous α r] [is_asymm β s] (f : α → β) (H : ∀ (a b : α), r a b → s (f a) (f b)) :\n    r ↪r s :=\n  mk (function.embedding.mk f sorry) sorry\n\n@[simp] theorem of_monotone_coe {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    [is_trichotomous α r] [is_asymm β s] (f : α → β) (H : ∀ (a b : α), r a b → s (f a) (f b)) :\n    ⇑(of_monotone f H) = f :=\n  rfl\n\n/-- Embeddings of partial orders that preserve `<` also preserve `≤`  -/\ndef order_embedding_of_lt_embedding {α : Type u_1} {β : Type u_2} [partial_order α]\n    [partial_order β] (f : Less ↪r Less) : α ↪o β :=\n  mk (to_embedding f) sorry\n\nend rel_embedding\n\n\nnamespace order_embedding\n\n\n/-- lt is preserved by order embeddings of preorders -/\ndef lt_embedding {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β) :\n    Less ↪r Less :=\n  rel_embedding.mk (rel_embedding.to_embedding f) sorry\n\n@[simp] theorem lt_embedding_apply {α : Type u_1} {β : Type u_2} [preorder α] [preorder β]\n    (f : α ↪o β) (x : α) : coe_fn (lt_embedding f) x = coe_fn f x :=\n  rfl\n\n@[simp] theorem le_iff_le {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β)\n    {a : α} {b : α} : coe_fn f a ≤ coe_fn f b ↔ a ≤ b :=\n  rel_embedding.map_rel_iff f\n\n@[simp] theorem lt_iff_lt {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β)\n    {a : α} {b : α} : coe_fn f a < coe_fn f b ↔ a < b :=\n  rel_embedding.map_rel_iff (lt_embedding f)\n\n@[simp] theorem eq_iff_eq {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β)\n    {a : α} {b : α} : coe_fn f a = coe_fn f b ↔ a = b :=\n  function.injective.eq_iff (rel_embedding.injective f)\n\nprotected theorem monotone {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β) :\n    monotone ⇑f :=\n  fun (x y : α) => iff.mpr (le_iff_le f)\n\nprotected theorem strict_mono {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β) :\n    strict_mono ⇑f :=\n  fun (x y : α) => iff.mpr (lt_iff_lt f)\n\nprotected theorem acc {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β) (a : α) :\n    acc Less (coe_fn f a) → acc Less a :=\n  rel_embedding.acc (lt_embedding f) a\n\nprotected theorem well_founded {α : Type u_1} {β : Type u_2} [preorder α] [preorder β]\n    (f : α ↪o β) : well_founded Less → well_founded Less :=\n  rel_embedding.well_founded (lt_embedding f)\n\nprotected theorem is_well_order {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β)\n    [is_well_order β Less] : is_well_order α Less :=\n  rel_embedding.is_well_order (lt_embedding f)\n\n/-- An order embedding is also an order embedding between dual orders. -/\nprotected def dual {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ↪o β) :\n    order_dual α ↪o order_dual β :=\n  rel_embedding.mk (rel_embedding.to_embedding f) sorry\n\n/-- A sctrictly monotone map from a linear order is an order embedding. --/\ndef of_strict_mono {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β] (f : α → β)\n    (h : strict_mono f) : α ↪o β :=\n  rel_embedding.mk (function.embedding.mk f (strict_mono.injective h)) sorry\n\n@[simp] theorem coe_of_strict_mono {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β]\n    {f : α → β} (h : strict_mono f) : ⇑(of_strict_mono f h) = f :=\n  rfl\n\n/-- Embedding of a subtype into the ambient type as an `order_embedding`. -/\ndef subtype {α : Type u_1} [preorder α] (p : α → Prop) : Subtype p ↪o α :=\n  rel_embedding.mk (function.embedding.subtype p) sorry\n\n@[simp] theorem coe_subtype {α : Type u_1} [preorder α] (p : α → Prop) : ⇑(subtype p) = coe := rfl\n\nend order_embedding\n\n\n/-- A relation isomorphism is an equivalence that is also a relation embedding. -/\nstructure rel_iso {α : Type u_4} {β : Type u_5} (r : α → α → Prop) (s : β → β → Prop) extends α ≃ β\n    where\n  map_rel_iff' : ∀ {a b : α}, s (coe_fn _to_equiv a) (coe_fn _to_equiv b) ↔ r a b\n\ninfixl:25 \" ≃r \" => Mathlib.rel_iso\n\n/-- An order isomorphism is an equivalence such that `a ≤ b ↔ (f a) ≤ (f b)`.\nThis definition is an abbreviation of `rel_iso (≤) (≤)`. -/\ndef order_iso (α : Type u_1) (β : Type u_2) [HasLessEq α] [HasLessEq β] := LessEq ≃r LessEq\n\ninfixl:25 \" ≃o \" => Mathlib.order_iso\n\nnamespace rel_iso\n\n\n/-- Convert an `rel_iso` to an `rel_embedding`. This function is also available as a coercion\nbut often it is easier to write `f.to_rel_embedding` than to write explicitly `r` and `s`\nin the target type. -/\ndef to_rel_embedding {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ≃r s) : r ↪r s :=\n  rel_embedding.mk (equiv.to_embedding (to_equiv f)) (map_rel_iff' f)\n\n-- see Note [function coercion]\n\nprotected instance rel_embedding.has_coe {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} : has_coe (r ≃r s) (r ↪r s) :=\n  has_coe.mk to_rel_embedding\n\nprotected instance has_coe_to_fun {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} : has_coe_to_fun (r ≃r s) :=\n  has_coe_to_fun.mk (fun (_x : r ≃r s) => α → β) fun (f : r ≃r s) => ⇑f\n\n@[simp] theorem to_rel_embedding_eq_coe {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ≃r s) : to_rel_embedding f = ↑f :=\n  rfl\n\n@[simp] theorem coe_coe_fn {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ≃r s) : ⇑↑f = ⇑f :=\n  rfl\n\ntheorem map_rel_iff {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} (f : r ≃r s)\n    {a : α} {b : α} : s (coe_fn f a) (coe_fn f b) ↔ r a b :=\n  map_rel_iff' f\n\n@[simp] theorem coe_fn_mk {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : α ≃ β) (o : ∀ {a b : α}, s (coe_fn f a) (coe_fn f b) ↔ r a b) : ⇑(mk f o) = ⇑f :=\n  rfl\n\n@[simp] theorem coe_fn_to_equiv {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ≃r s) : ⇑(to_equiv f) = ⇑f :=\n  rfl\n\ntheorem injective_to_equiv {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} :\n    function.injective to_equiv :=\n  sorry\n\n/-- The map `coe_fn : (r ≃r s) → (α → β)` is injective. Lean fails to parse\n`function.injective (λ e : r ≃r s, (e : α → β))`, so we use a trick to say the same. -/\ntheorem injective_coe_fn {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} :\n    function.injective fun (e : r ≃r s) (x : α) => coe_fn e x :=\n  function.injective.comp equiv.injective_coe_fn injective_to_equiv\n\ntheorem ext {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {f : r ≃r s}\n    {g : r ≃r s} (h : ∀ (x : α), coe_fn f x = coe_fn g x) : f = g :=\n  injective_coe_fn (funext h)\n\ntheorem ext_iff {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} {f : r ≃r s}\n    {g : r ≃r s} : f = g ↔ ∀ (x : α), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : α) => h ▸ rfl,\n    mpr := fun (h : ∀ (x : α), coe_fn f x = coe_fn g x) => ext h }\n\n/-- Identity map is a relation isomorphism. -/\nprotected def refl {α : Type u_1} (r : α → α → Prop) : r ≃r r := mk (equiv.refl α) sorry\n\n/-- Inverse map of a relation isomorphism is a relation isomorphism. -/\nprotected def symm {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ≃r s) : s ≃r r :=\n  mk (equiv.symm (to_equiv f)) sorry\n\n/-- Composition of two relation isomorphisms is a relation isomorphism. -/\nprotected def trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → α → Prop}\n    {s : β → β → Prop} {t : γ → γ → Prop} (f₁ : r ≃r s) (f₂ : s ≃r t) : r ≃r t :=\n  mk (equiv.trans (to_equiv f₁) (to_equiv f₂)) sorry\n\nprotected instance inhabited {α : Type u_1} (r : α → α → Prop) : Inhabited (r ≃r r) :=\n  { default := rel_iso.refl r }\n\n@[simp] theorem default_def {α : Type u_1} (r : α → α → Prop) :\n    Inhabited.default = rel_iso.refl r :=\n  rfl\n\n/-- a relation isomorphism is also a relation isomorphism between dual relations. -/\nprotected def swap {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ≃r s) : function.swap r ≃r function.swap s :=\n  mk (to_equiv f) sorry\n\n@[simp] theorem coe_fn_symm_mk {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : α ≃ β) (o : ∀ {a b : α}, s (coe_fn f a) (coe_fn f b) ↔ r a b) :\n    ⇑(rel_iso.symm (mk f o)) = ⇑(equiv.symm f) :=\n  rfl\n\n@[simp] theorem refl_apply {α : Type u_1} {r : α → α → Prop} (x : α) :\n    coe_fn (rel_iso.refl r) x = x :=\n  rfl\n\n@[simp] theorem trans_apply {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → α → Prop}\n    {s : β → β → Prop} {t : γ → γ → Prop} (f : r ≃r s) (g : s ≃r t) (a : α) :\n    coe_fn (rel_iso.trans f g) a = coe_fn g (coe_fn f a) :=\n  rfl\n\n@[simp] theorem apply_symm_apply {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) (x : β) : coe_fn e (coe_fn (rel_iso.symm e) x) = x :=\n  equiv.apply_symm_apply (to_equiv e) x\n\n@[simp] theorem symm_apply_apply {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) (x : α) : coe_fn (rel_iso.symm e) (coe_fn e x) = x :=\n  equiv.symm_apply_apply (to_equiv e) x\n\ntheorem rel_symm_apply {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) {x : α} {y : β} : r x (coe_fn (rel_iso.symm e) y) ↔ s (coe_fn e x) y :=\n  sorry\n\ntheorem symm_apply_rel {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) {x : β} {y : α} : r (coe_fn (rel_iso.symm e) x) y ↔ s x (coe_fn e y) :=\n  sorry\n\nprotected theorem bijective {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) : function.bijective ⇑e :=\n  equiv.bijective (to_equiv e)\n\nprotected theorem injective {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) : function.injective ⇑e :=\n  equiv.injective (to_equiv e)\n\nprotected theorem surjective {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) : function.surjective ⇑e :=\n  equiv.surjective (to_equiv e)\n\n@[simp] theorem range_eq {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (e : r ≃r s) : set.range ⇑e = set.univ :=\n  function.surjective.range_eq (rel_iso.surjective e)\n\n@[simp] theorem eq_iff_eq {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (f : r ≃r s) {a : α} {b : α} : coe_fn f a = coe_fn f b ↔ a = b :=\n  function.injective.eq_iff (rel_iso.injective f)\n\n/-- Any equivalence lifts to a relation isomorphism between `s` and its preimage. -/\nprotected def preimage {α : Type u_1} {β : Type u_2} (f : α ≃ β) (s : β → β → Prop) :\n    ⇑f ⁻¹'o s ≃r s :=\n  mk f sorry\n\n/-- A surjective relation embedding is a relation isomorphism. -/\ndef of_surjective {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop} (f : r ↪r s)\n    (H : function.surjective ⇑f) : r ≃r s :=\n  mk (equiv.of_bijective ⇑f sorry) sorry\n\n@[simp] theorem of_surjective_coe {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (f : r ↪r s) (H : function.surjective ⇑f) : ⇑(of_surjective f H) = ⇑f :=\n  rfl\n\n/--\nGiven relation isomorphisms `r₁ ≃r r₂` and `s₁ ≃r s₂`, construct a relation isomorphism for the\nlexicographic orders on the sum.\n-/\ndef sum_lex_congr {α₁ : Type u_1} {α₂ : Type u_2} {β₁ : Type u_3} {β₂ : Type u_4}\n    {r₁ : α₁ → α₁ → Prop} {r₂ : α₂ → α₂ → Prop} {s₁ : β₁ → β₁ → Prop} {s₂ : β₂ → β₂ → Prop}\n    (e₁ : r₁ ≃r r₂) (e₂ : s₁ ≃r s₂) : sum.lex r₁ s₁ ≃r sum.lex r₂ s₂ :=\n  mk (equiv.sum_congr (to_equiv e₁) (to_equiv e₂)) sorry\n\n/--\nGiven relation isomorphisms `r₁ ≃r r₂` and `s₁ ≃r s₂`, construct a relation isomorphism for the\nlexicographic orders on the product.\n-/\ndef prod_lex_congr {α₁ : Type u_1} {α₂ : Type u_2} {β₁ : Type u_3} {β₂ : Type u_4}\n    {r₁ : α₁ → α₁ → Prop} {r₂ : α₂ → α₂ → Prop} {s₁ : β₁ → β₁ → Prop} {s₂ : β₂ → β₂ → Prop}\n    (e₁ : r₁ ≃r r₂) (e₂ : s₁ ≃r s₂) : prod.lex r₁ s₁ ≃r prod.lex r₂ s₂ :=\n  mk (equiv.prod_congr (to_equiv e₁) (to_equiv e₂)) sorry\n\nprotected instance group {α : Type u_1} {r : α → α → Prop} : group (r ≃r r) :=\n  group.mk (fun (f₁ f₂ : r ≃r r) => rel_iso.trans f₂ f₁) sorry (rel_iso.refl r) sorry sorry\n    rel_iso.symm\n    (div_inv_monoid.div._default (fun (f₁ f₂ : r ≃r r) => rel_iso.trans f₂ f₁) sorry\n      (rel_iso.refl r) sorry sorry rel_iso.symm)\n    sorry\n\n@[simp] theorem coe_one {α : Type u_1} {r : α → α → Prop} : ⇑1 = id := rfl\n\n@[simp] theorem coe_mul {α : Type u_1} {r : α → α → Prop} (e₁ : r ≃r r) (e₂ : r ≃r r) :\n    ⇑(e₁ * e₂) = ⇑e₁ ∘ ⇑e₂ :=\n  rfl\n\ntheorem mul_apply {α : Type u_1} {r : α → α → Prop} (e₁ : r ≃r r) (e₂ : r ≃r r) (x : α) :\n    coe_fn (e₁ * e₂) x = coe_fn e₁ (coe_fn e₂ x) :=\n  rfl\n\n@[simp] theorem inv_apply_self {α : Type u_1} {r : α → α → Prop} (e : r ≃r r) (x : α) :\n    coe_fn (e⁻¹) (coe_fn e x) = x :=\n  symm_apply_apply e x\n\n@[simp] theorem apply_inv_self {α : Type u_1} {r : α → α → Prop} (e : r ≃r r) (x : α) :\n    coe_fn e (coe_fn (e⁻¹) x) = x :=\n  apply_symm_apply e x\n\nend rel_iso\n\n\nnamespace order_iso\n\n\n/-- Reinterpret an order isomorphism as an order embedding. -/\ndef to_order_embedding {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] (e : α ≃o β) :\n    α ↪o β :=\n  rel_iso.to_rel_embedding e\n\n@[simp] theorem coe_to_order_embedding {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β]\n    (e : α ≃o β) : ⇑(to_order_embedding e) = ⇑e :=\n  rfl\n\nprotected theorem bijective {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] (e : α ≃o β) :\n    function.bijective ⇑e :=\n  equiv.bijective (rel_iso.to_equiv e)\n\nprotected theorem injective {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] (e : α ≃o β) :\n    function.injective ⇑e :=\n  equiv.injective (rel_iso.to_equiv e)\n\nprotected theorem surjective {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β]\n    (e : α ≃o β) : function.surjective ⇑e :=\n  equiv.surjective (rel_iso.to_equiv e)\n\n@[simp] theorem range_eq {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] (e : α ≃o β) :\n    set.range ⇑e = set.univ :=\n  function.surjective.range_eq (order_iso.surjective e)\n\n@[simp] theorem apply_eq_iff_eq {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β]\n    (e : α ≃o β) {x : α} {y : α} : coe_fn e x = coe_fn e y ↔ x = y :=\n  equiv.apply_eq_iff_eq (rel_iso.to_equiv e)\n\n/-- Inverse of an order isomorphism. -/\ndef symm {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] (e : α ≃o β) : β ≃o α :=\n  rel_iso.symm e\n\n@[simp] theorem apply_symm_apply {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β]\n    (e : α ≃o β) (x : β) : coe_fn e (coe_fn (symm e) x) = x :=\n  equiv.apply_symm_apply (rel_iso.to_equiv e) x\n\n@[simp] theorem symm_apply_apply {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β]\n    (e : α ≃o β) (x : α) : coe_fn (symm e) (coe_fn e x) = x :=\n  equiv.symm_apply_apply (rel_iso.to_equiv e) x\n\ntheorem symm_apply_eq {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] (e : α ≃o β) {x : α}\n    {y : β} : coe_fn (symm e) y = x ↔ y = coe_fn e x :=\n  equiv.symm_apply_eq (rel_iso.to_equiv e)\n\n@[simp] theorem symm_symm {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] (e : α ≃o β) :\n    symm (symm e) = e :=\n  rel_iso.ext fun (x : α) => Eq.refl (coe_fn (symm (symm e)) x)\n\ntheorem symm_injective {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β] :\n    function.injective symm :=\n  sorry\n\n@[simp] theorem to_equiv_symm {α : Type u_1} {β : Type u_2} [HasLessEq α] [HasLessEq β]\n    (e : α ≃o β) : equiv.symm (rel_iso.to_equiv e) = rel_iso.to_equiv (symm e) :=\n  rfl\n\n/-- Composition of two order isomorphisms is an order isomorphism. -/\ndef trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} [HasLessEq α] [HasLessEq β] [HasLessEq γ]\n    (e : α ≃o β) (e' : β ≃o γ) : α ≃o γ :=\n  rel_iso.trans e e'\n\n@[simp] theorem coe_trans {α : Type u_1} {β : Type u_2} {γ : Type u_3} [HasLessEq α] [HasLessEq β]\n    [HasLessEq γ] (e : α ≃o β) (e' : β ≃o γ) : ⇑(trans e e') = ⇑e' ∘ ⇑e :=\n  rfl\n\ntheorem trans_apply {α : Type u_1} {β : Type u_2} {γ : Type u_3} [HasLessEq α] [HasLessEq β]\n    [HasLessEq γ] (e : α ≃o β) (e' : β ≃o γ) (x : α) :\n    coe_fn (trans e e') x = coe_fn e' (coe_fn e x) :=\n  rfl\n\nprotected theorem monotone {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β) :\n    monotone ⇑e :=\n  order_embedding.monotone (to_order_embedding e)\n\nprotected theorem strict_mono {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β) :\n    strict_mono ⇑e :=\n  order_embedding.strict_mono (to_order_embedding e)\n\n@[simp] theorem le_iff_le {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    {x : α} {y : α} : coe_fn e x ≤ coe_fn e y ↔ x ≤ y :=\n  rel_iso.map_rel_iff e\n\n@[simp] theorem lt_iff_lt {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    {x : α} {y : α} : coe_fn e x < coe_fn e y ↔ x < y :=\n  order_embedding.lt_iff_lt (to_order_embedding e)\n\n@[simp] theorem preimage_Iic {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (b : β) : ⇑e ⁻¹' set.Iic b = set.Iic (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ici {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (b : β) : ⇑e ⁻¹' set.Ici b = set.Ici (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Iio {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (b : β) : ⇑e ⁻¹' set.Iio b = set.Iio (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ioi {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (b : β) : ⇑e ⁻¹' set.Ioi b = set.Ioi (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Icc {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (a : β) (b : β) : ⇑e ⁻¹' set.Icc a b = set.Icc (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ico {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (a : β) (b : β) : ⇑e ⁻¹' set.Ico a b = set.Ico (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ioc {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (a : β) (b : β) : ⇑e ⁻¹' set.Ioc a b = set.Ioc (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ioo {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (e : α ≃o β)\n    (a : β) (b : β) : ⇑e ⁻¹' set.Ioo a b = set.Ioo (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n/-- To show that `f : α → β`, `g : β → α` make up an order isomorphism of linear orders,\n    it suffices to prove `cmp a (g b) = cmp (f a) b`. --/\ndef of_cmp_eq_cmp {α : Type u_1} {β : Type u_2} [linear_order α] [linear_order β] (f : α → β)\n    (g : β → α) (h : ∀ (a : α) (b : β), cmp a (g b) = cmp (f a) b) : α ≃o β :=\n  (fun (gf : ∀ (a : α), a = g (f a)) => rel_iso.mk (equiv.mk f g sorry sorry) sorry) sorry\n\n/-- Order isomorphism between two equal sets. -/\ndef set_congr {α : Type u_1} [preorder α] (s : set α) (t : set α) (h : s = t) : ↥s ≃o ↥t :=\n  rel_iso.mk (equiv.set_congr h) sorry\n\n/-- Order isomorphism between `univ : set α` and `α`. -/\ndef set.univ {α : Type u_1} [preorder α] : ↥set.univ ≃o α := rel_iso.mk (equiv.set.univ α) sorry\n\nend order_iso\n\n\n/-- If a function `f` is strictly monotone on a set `s`, then it defines an order isomorphism\nbetween `s` and its image. -/\nprotected def strict_mono_incr_on.order_iso {α : Type u_1} {β : Type u_2} [linear_order α]\n    [preorder β] (f : α → β) (s : set α) (hf : strict_mono_incr_on f s) : ↥s ≃o ↥(f '' s) :=\n  rel_iso.mk (set.bij_on.equiv f sorry) sorry\n\n/-- A strictly monotone function from a linear order is an order isomorphism between its domain and\nits range. -/\nprotected def strict_mono.order_iso {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β]\n    (f : α → β) (h_mono : strict_mono f) : α ≃o ↥(set.range f) :=\n  rel_iso.mk (equiv.set.range f (strict_mono.injective h_mono)) sorry\n\n/-- A strictly monotone surjective function from a linear order is an order isomorphism. -/\ndef strict_mono.order_iso_of_surjective {α : Type u_1} {β : Type u_2} [linear_order α] [preorder β]\n    (f : α → β) (h_mono : strict_mono f) (h_surj : function.surjective f) : α ≃o β :=\n  order_iso.trans (strict_mono.order_iso f h_mono)\n    (order_iso.trans\n      (order_iso.set_congr (set.range f) set.univ (function.surjective.range_eq h_surj))\n      order_iso.set.univ)\n\n/-- `subrel r p` is the inherited relation on a subset. -/\ndef subrel {α : Type u_1} (r : α → α → Prop) (p : set α) : ↥p → ↥p → Prop := coe ⁻¹'o r\n\n@[simp] theorem subrel_val {α : Type u_1} (r : α → α → Prop) (p : set α) {a : ↥p} {b : ↥p} :\n    subrel r p a b ↔ r (subtype.val a) (subtype.val b) :=\n  iff.rfl\n\nnamespace subrel\n\n\n/-- The relation embedding from the inherited relation on a subset. -/\nprotected def rel_embedding {α : Type u_1} (r : α → α → Prop) (p : set α) : subrel r p ↪r r :=\n  rel_embedding.mk (function.embedding.subtype fun (x : α) => x ∈ p) sorry\n\n@[simp] theorem rel_embedding_apply {α : Type u_1} (r : α → α → Prop) (p : set α) (a : ↥p) :\n    coe_fn (subrel.rel_embedding r p) a = subtype.val a :=\n  rfl\n\nprotected instance is_well_order {α : Type u_1} (r : α → α → Prop) [is_well_order α r] (p : set α) :\n    is_well_order (↥p) (subrel r p) :=\n  rel_embedding.is_well_order (subrel.rel_embedding r p)\n\nend subrel\n\n\n/-- Restrict the codomain of a relation embedding. -/\ndef rel_embedding.cod_restrict {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {s : β → β → Prop}\n    (p : set β) (f : r ↪r s) (H : ∀ (a : α), coe_fn f a ∈ p) : r ↪r subrel s p :=\n  rel_embedding.mk (function.embedding.cod_restrict p (rel_embedding.to_embedding f) H)\n    (rel_embedding.map_rel_iff' f)\n\n@[simp] theorem rel_embedding.cod_restrict_apply {α : Type u_1} {β : Type u_2} {r : α → α → Prop}\n    {s : β → β → Prop} (p : set β) (f : r ↪r s) (H : ∀ (a : α), coe_fn f a ∈ p) (a : α) :\n    coe_fn (rel_embedding.cod_restrict p f H) a = { val := coe_fn f a, property := H a } :=\n  rfl\n\nprotected def order_iso.dual {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α ≃o β) :\n    order_dual α ≃o order_dual β :=\n  rel_iso.mk (rel_iso.to_equiv f) sorry\n\ntheorem order_iso.map_bot' {α : Type u_1} {β : Type u_2} [partial_order α] [partial_order β]\n    (f : α ≃o β) {x : α} {y : β} (hx : ∀ (x' : α), x ≤ x') (hy : ∀ (y' : β), y ≤ y') :\n    coe_fn f x = y :=\n  sorry\n\ntheorem order_iso.map_bot {α : Type u_1} {β : Type u_2} [order_bot α] [order_bot β] (f : α ≃o β) :\n    coe_fn f ⊥ = ⊥ :=\n  order_iso.map_bot' f (fun (_x : α) => bot_le) fun (_x : β) => bot_le\n\ntheorem order_iso.map_top' {α : Type u_1} {β : Type u_2} [partial_order α] [partial_order β]\n    (f : α ≃o β) {x : α} {y : β} (hx : ∀ (x' : α), x' ≤ x) (hy : ∀ (y' : β), y' ≤ y) :\n    coe_fn f x = y :=\n  order_iso.map_bot' (order_iso.dual f) hx hy\n\ntheorem order_iso.map_top {α : Type u_1} {β : Type u_2} [order_top α] [order_top β] (f : α ≃o β) :\n    coe_fn f ⊤ = ⊤ :=\n  order_iso.map_bot (order_iso.dual f)\n\ntheorem order_embedding.map_inf_le {α : Type u_1} {β : Type u_2} [semilattice_inf α]\n    [semilattice_inf β] (f : α ↪o β) (x : α) (y : α) : coe_fn f (x ⊓ y) ≤ coe_fn f x ⊓ coe_fn f y :=\n  monotone.map_inf_le (order_embedding.monotone f) x y\n\ntheorem order_iso.map_inf {α : Type u_1} {β : Type u_2} [semilattice_inf α] [semilattice_inf β]\n    (f : α ≃o β) (x : α) (y : α) : coe_fn f (x ⊓ y) = coe_fn f x ⊓ coe_fn f y :=\n  sorry\n\ntheorem order_embedding.le_map_sup {α : Type u_1} {β : Type u_2} [semilattice_sup α]\n    [semilattice_sup β] (f : α ↪o β) (x : α) (y : α) : coe_fn f x ⊔ coe_fn f y ≤ coe_fn f (x ⊔ y) :=\n  monotone.le_map_sup (order_embedding.monotone f) x y\n\ntheorem order_iso.map_sup {α : Type u_1} {β : Type u_2} [semilattice_sup α] [semilattice_sup β]\n    (f : α ≃o β) (x : α) (y : α) : coe_fn f (x ⊔ y) = coe_fn f x ⊔ coe_fn f y :=\n  order_iso.map_inf (order_iso.dual f) x y\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/order/rel_iso_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.4584755696310939}}
{"text": "/-\nCopyright (c) 2022 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport computational_monads.simulation_semantics.simulate.support\n\n/-!\n# State Masking for Simulation Oracles\n\nThis file defines a construction for masking the state of an oracle using some equivalence.\nThis is particularlly useful when combining multiple oracles,\nas this can lead to irrelevent extra bits of the state floating around.\nThe definition is in terms of an equivalence `S ≃ S'` between types (i.e. a bijection),\nwith `S` the original state and `S'` the new one.\n\nWe also give the natural lemmas for the compatibility of masking with `support` and `eval_dist`,\nshowing that the masking doesn't affect their values (up to applying the mask to the state).\n-/\n\nvariables {α β γ : Type} {spec spec' : oracle_spec} {S S' S'' : Type}\n\nopen oracle_comp oracle_spec\n\nnamespace sim_oracle\n\n/-- Mask the state value of an oracle, without changing the oracle's behaviour.\nWe capture this unchanged functionality by using an equivalence for the masking.\nConvenient when working with composed or appended oracles, to remove unneeded state elements.\nIn particular `unit` state values that start spreading can be avoided.\n-/\ndef mask_state (so : sim_oracle spec spec' S) (mask : S ≃ S') :\n  sim_oracle spec spec' S' :=\n{ default_state := mask so.default_state,\n  o := λ i x, prod.map id mask <$> (so.o i $ prod.map id mask.symm x) }\n\nvariables (so : sim_oracle spec spec' S) (mask : S ≃ S') (mask' : S' ≃ S'')\n  (a : α) (i : spec.ι) (t : spec.domain i) (oa : oracle_comp spec α)\n  (ob : α → oracle_comp spec β) (s : S) (s' : S') (s'' : S'')\n  (x : spec.domain i × S') (y : spec.range i × S')\n\nlemma mask_state_apply_eq : so.mask_state mask i x =\n  prod.map id mask <$> (so.o i $ prod.map id mask.symm x) := rfl\n\nsection support\n\n/-- The `support` of a simulation with masked state is the same as the support without masking -/\n@[simp]\ntheorem support_simulate_mask_eq_image_support_simulate :\n  (simulate (so.mask_state mask) oa s').support =\n    (prod.map id mask) '' (simulate so oa (mask.symm s')).support :=\nbegin\n  refine support_simulate_eq_induction (so.mask_state mask) oa s' (λ α a s, _) _ (λ i t s, _),\n  { rw [support_simulate_return, set.image_singleton, prod_map, id.def, equiv.apply_symm_apply] },\n  { refine λ α β oa ob s, set.ext (λ x, _),\n    simp_rw [support_simulate_bind, set.image_Union, set.mem_Union],\n    refine ⟨λ h, _, λ h, _⟩,\n    { obtain ⟨⟨a, t⟩, hta, hx⟩ := h,\n      exact ⟨(a, mask t), ⟨(a, t), hta, rfl⟩, (mask.symm_apply_apply t).symm ▸ hx⟩ },\n    { obtain ⟨⟨a, t⟩, ⟨⟨a', t'⟩, ⟨htas, hta⟩⟩, hx⟩ := h,\n      rw [prod.map_mk, prod.eq_iff_fst_eq_snd_eq] at hta,\n      have : mask.symm t = t' := (congr_arg _ hta.2.symm).trans (mask.symm_apply_apply t'),\n      exact ⟨(a', mask.symm t), this.symm ▸ htas, hta.1.symm ▸ hx⟩ } },\n  { simpa only [simulate_query, mask_state_apply_eq, support_map] }\nend\n\nlemma support_simulate_mask_eq_preimage_support_simulate :\n  (simulate (so.mask_state mask) oa s').support =\n    (prod.map id mask.symm) ⁻¹' (simulate so oa (mask.symm s')).support :=\nbegin\n  rw [support_simulate_mask_eq_image_support_simulate],\n  refine congr_fun (set.image_eq_preimage_of_inverse _ _) _;\n  exact λ x, by simp only [prod_map, id.def, equiv.symm_apply_apply,\n    equiv.apply_symm_apply, prod.mk.eta]\nend\n\n/-- The `support` of a regular simulation can be represented as the image of a simulation\nwith a masked state, with the image applying an unmask function for the masking -/\nlemma support_simulate_eq_image_support_simulate_mask : (simulate so oa s).support =\n  (prod.map id mask.symm) '' (simulate (so.mask_state mask) oa (mask s)).support :=\nby simp_rw [support_simulate_mask_eq_image_support_simulate, set.image_image, prod.map_map,\n  equiv.symm_comp_self, equiv.symm_apply_apply, function.comp.right_id, prod.map_id, set.image_id]\n\nlemma support_simulate_eq_preimage_support_simulate_mask : (simulate so oa s).support =\n  (prod.map id mask) ⁻¹' (simulate (so.mask_state mask) oa (mask s)).support :=\nby simp_rw [support_simulate_mask_eq_preimage_support_simulate, set.preimage_preimage,\n  prod.map_map, equiv.symm_comp_self, equiv.symm_apply_apply, function.comp.right_id,\n    prod.map_id, set.preimage_id]\n\n@[simp]\nlemma support_simulate'_mask_eq_support_simulate' :\n  (simulate' (so.mask_state mask) oa s').support = (simulate' so oa (mask.symm s')).support :=\nby simpa only [support_simulate', support_simulate_mask_eq_image_support_simulate, set.image_image]\n\nlemma support_simulate'_eq_support_simulate'_mask :\n  (simulate' so oa s).support = (simulate' (so.mask_state mask) oa (mask s)).support :=\nby rw [support_simulate'_mask_eq_support_simulate', equiv.symm_apply_apply]\n\nlemma support_simulate_mask_mask_eq_support_simulate_mask_comp :\n  (simulate ((so.mask_state mask).mask_state mask') oa s'').support =\n    (simulate (so.mask_state $ mask.trans mask') oa s'').support :=\nby simpa only [support_simulate_mask_eq_image_support_simulate, set.image_image, prod.map_map,\n  equiv.symm_trans_apply, function.comp.right_id]\n\nend support\n\nsection fin_support\n\nend fin_support\n\nsection distribution_semantics\n\nsection eval_dist\n\n@[simp]\nlemma eval_dist_mask_apply : ⁅so.mask_state mask i (t, s')⁆ =\n  (⁅so i (t, mask.symm s')⁆).map (prod.map id mask) :=\nby simpa only [mask_state_apply_eq, eval_dist_map]\n\n@[simp]\ntheorem eval_dist_simulate_mask : ⁅simulate (so.mask_state mask) oa s'⁆\n  = (⁅simulate so oa (mask.symm s')⁆).map (prod.map id mask) :=\nbegin\n  induction oa using oracle_comp.induction_on with α a α β oa ob hoa hob i t generalizing s',\n  { simp only [pmf.pure_map, simulate_return, eval_dist_return,\n      prod.map_mk, id.def, equiv.apply_symm_apply] },\n  { simp_rw [eval_dist_simulate_bind, hoa, hob, pmf.map_bind, pmf.bind_map],\n    refine congr_arg _ (funext $ λ x, _),\n    simp only [function.comp_app, prod_map, id.def, equiv.symm_apply_apply] },\n  { simp only [eval_dist_mask_apply, simulate_query] }\nend\n\n@[simp]\nlemma eval_dist_simulate_mask_apply (x : α × S') : ⁅simulate (so.mask_state mask) oa s'⁆ x =\n  ⁅simulate so oa (mask.symm s')⁆ (x.1, mask.symm x.2) :=\nbegin\n  simp only [eval_dist_simulate_mask, pmf.map_apply],\n  refine (tsum_eq_single (x.1, mask.symm x.2) $ λ y hy, _).trans _,\n  { have : x ≠ prod.map id ⇑mask y := λ hx, hy (by rw [hx, prod.map_fst, prod.map_snd,\n      equiv.symm_apply_apply, id.def, prod.mk.eta]),\n    simp_rw [this, if_false] },\n  { simp only [prod.map_mk, id.def, equiv.apply_symm_apply, prod.mk.eta,\n      eq_self_iff_true, if_true] }\nend\n\n@[simp]\nlemma eval_dist_simulate'_mask : ⁅simulate' (so.mask_state mask) oa s'⁆ =\n  ⁅simulate' so oa (mask.symm s')⁆ :=\nby simp_rw [eval_dist_simulate', eval_dist_simulate_mask, pmf.map_comp,\n  prod.map_fst', function.comp.left_id]\n\nlemma eval_dist_simulate'_mask_apply : ⁅simulate' (so.mask_state mask) oa s'⁆ a =\n  ⁅simulate' so oa (mask.symm s')⁆ a :=\nby rw [eval_dist_simulate'_mask]\n\nend eval_dist\n\nsection equiv\n\n\n\nend equiv\n\nsection prob_event\n\n@[simp]\nlemma prob_event_mask_apply (e : set (spec.range i × S')) :\n  ⁅e | so.mask_state mask i (t, s')⁆ = ⁅(prod.map id mask) ⁻¹' e | so i (t, mask.symm s')⁆ :=\nby simpa only [mask_state_apply_eq, prob_event_map, prod_map, id.def]\n\n/-- The probability of an event holding after masking state is the same as the\nprobability of the preimage of the event holding on the unmasked computation. -/\n@[simp]\ntheorem prob_event_simulate_mask_eq_preimage (e : set (α × S')) :\n  ⁅e | simulate (so.mask_state mask) oa s'⁆ =\n    ⁅(prod.map id mask) ⁻¹' e | simulate so oa (mask.symm s')⁆ :=\nby simp_rw [prob_event.def, eval_dist_simulate_mask, pmf.to_outer_measure_map_apply]\n\nlemma prob_event_simulate_mask_eq_image (e : set (α × S')) :\n  ⁅e | simulate (so.mask_state mask) oa s'⁆ =\n    ⁅(prod.map id mask.symm) '' e | simulate so oa (mask.symm s')⁆ :=\nbegin\n  convert (prob_event_simulate_mask_eq_preimage so mask oa s' e),\n  ext x,\n  simp only [prod_map, id.def, set.mem_image, set.mem_preimage],\n  exact ⟨λ ⟨x', hx'⟩, by simpa only [← hx'.2, equiv.apply_symm_apply, prod.mk.eta] using hx'.1,\n    λ h, ⟨(x.1, mask x.2), h, prod.eq_iff_fst_eq_snd_eq.2 ⟨rfl, equiv.symm_apply_apply _ _⟩⟩⟩\nend\n\nend prob_event\n\nend distribution_semantics\n\nend sim_oracle", "meta": {"author": "dtumad", "repo": "lean-crypto-formalization", "sha": "f975a9a9882120b509553a7ced9aa05b745ff154", "save_path": "github-repos/lean/dtumad-lean-crypto-formalization", "path": "github-repos/lean/dtumad-lean-crypto-formalization/lean-crypto-formalization-f975a9a9882120b509553a7ced9aa05b745ff154/src/computational_monads/simulation_semantics/mask_state.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455589, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.45847556501173103}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Yury G. Kudryashov\n-/\nimport logic.function.basic\n\n/-!\n# More theorems about the sum type\n-/\n\nuniverses u v w x\nvariables {α : Type u} {α' : Type w} {β : Type v} {β' : Type x}\nopen sum\n\n/-- Check if a sum is `inl` and if so, retrieve its contents. -/\n@[simp] def sum.get_left {α β} : α ⊕ β → option α\n| (inl a) := some a\n| (inr _) := none\n\n/-- Check if a sum is `inr` and if so, retrieve its contents. -/\n@[simp] def sum.get_right {α β} : α ⊕ β → option β\n| (inr b) := some b\n| (inl _) := none\n\n/-- Check if a sum is `inl`. -/\n@[simp] def sum.is_left {α β} : α ⊕ β → bool\n| (inl _) := tt\n| (inr _) := ff\n\n/-- Check if a sum is `inr`. -/\n@[simp] def sum.is_right {α β} : α ⊕ β → bool\n| (inl _) := ff\n| (inr _) := tt\n\nattribute [derive decidable_eq] sum\n\n@[simp] theorem sum.forall {p : α ⊕ β → Prop} : (∀ x, p x) ↔ (∀ a, p (inl a)) ∧ (∀ b, p (inr b)) :=\n⟨λ h, ⟨λ a, h _, λ b, h _⟩, λ ⟨h₁, h₂⟩, sum.rec h₁ h₂⟩\n\n@[simp] theorem sum.exists {p : α ⊕ β → Prop} : (∃ x, p x) ↔ (∃ a, p (inl a)) ∨ ∃ b, p (inr b) :=\n⟨λ h, match h with\n| ⟨inl a, h⟩ := or.inl ⟨a, h⟩\n| ⟨inr b, h⟩ := or.inr ⟨b, h⟩\nend, λ h, match h with\n| or.inl ⟨a, h⟩ := ⟨inl a, h⟩\n| or.inr ⟨b, h⟩ := ⟨inr b, h⟩\nend⟩\n\nnamespace sum\n\nlemma inl_injective : function.injective (sum.inl : α → α ⊕ β) :=\nλ x y, sum.inl.inj\n\nlemma inr_injective : function.injective (sum.inr : β → α ⊕ β) :=\nλ x y, sum.inr.inj\n\n/-- Map `α ⊕ β` to `α' ⊕ β'` sending `α` to `α'` and `β` to `β'`. -/\nprotected def map (f : α → α') (g : β → β')  : α ⊕ β → α' ⊕ β'\n| (sum.inl x) := sum.inl (f x)\n| (sum.inr x) := sum.inr (g x)\n\n@[simp] lemma map_inl (f : α → α') (g : β → β') (x : α) : (inl x).map f g = inl (f x) := rfl\n@[simp] lemma map_inr (f : α → α') (g : β → β') (x : β) : (inr x).map f g = inr (g x) := rfl\n\n@[simp] lemma map_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :\n  ∀ x : α ⊕ β, (x.map f g).map f' g' = x.map (f' ∘ f) (g' ∘ g)\n| (inl a) := rfl\n| (inr b) := rfl\n\n@[simp] lemma map_comp_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :\n  (sum.map f' g') ∘ (sum.map f g) = sum.map (f' ∘ f) (g' ∘ g) :=\nfunext $ map_map f' g' f g\n\n@[simp] lemma map_id_id (α β) : sum.map (@id α) (@id β) = id :=\nfunext $ λ x, sum.rec_on x (λ _, rfl) (λ _, rfl)\n\ntheorem inl.inj_iff {a b} : (inl a : α ⊕ β) = inl b ↔ a = b :=\n⟨inl.inj, congr_arg _⟩\n\ntheorem inr.inj_iff {a b} : (inr a : α ⊕ β) = inr b ↔ a = b :=\n⟨inr.inj, congr_arg _⟩\n\ntheorem inl_ne_inr {a : α} {b : β} : inl a ≠ inr b.\n\ntheorem inr_ne_inl {a : α} {b : β} : inr b ≠ inl a.\n\n/-- Define a function on `α ⊕ β` by giving separate definitions on `α` and `β`. -/\nprotected def elim {α β γ : Sort*} (f : α → γ) (g : β → γ) : α ⊕ β → γ := λ x, sum.rec_on x f g\n\n@[simp] lemma elim_inl {α β γ : Sort*} (f : α → γ) (g : β → γ) (x : α) :\n  sum.elim f g (inl x) = f x := rfl\n\n@[simp] lemma elim_inr {α β γ : Sort*} (f : α → γ) (g : β → γ) (x : β) :\n  sum.elim f g (inr x) = g x := rfl\n\n@[simp] lemma elim_comp_inl {α β γ : Sort*} (f : α → γ) (g : β → γ) :\n  sum.elim f g ∘ inl = f := rfl\n\n@[simp] lemma elim_comp_inr {α β γ : Sort*} (f : α → γ) (g : β → γ) :\n  sum.elim f g ∘ inr = g := rfl\n\n@[simp] lemma elim_inl_inr {α β : Sort*} :\n  @sum.elim α β _ inl inr = id :=\nfunext $ λ x, sum.cases_on x (λ _, rfl) (λ _, rfl)\n\nlemma comp_elim {α β γ δ : Sort*} (f : γ → δ) (g : α → γ) (h : β → γ):\n  f ∘ sum.elim g h = sum.elim (f ∘ g) (f ∘ h) :=\nfunext $ λ x, sum.cases_on x (λ _, rfl) (λ _, rfl)\n\n@[simp] lemma elim_comp_inl_inr {α β γ : Sort*} (f : α ⊕ β → γ) :\n  sum.elim (f ∘ inl) (f ∘ inr) = f :=\nfunext $ λ x, sum.cases_on x (λ _, rfl) (λ _, rfl)\n\nopen function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_of_forall_ne)\n\n@[simp] lemma update_elim_inl {α β γ} [decidable_eq α] [decidable_eq (α ⊕ β)]\n  {f : α → γ} {g : β → γ} {i : α} {x : γ} :\n  update (sum.elim f g) (inl i) x = sum.elim (update f i x) g :=\nupdate_eq_iff.2 ⟨by simp, by simp { contextual := tt }⟩\n\n@[simp] lemma update_elim_inr {α β γ} [decidable_eq β] [decidable_eq (α ⊕ β)]\n  {f : α → γ} {g : β → γ} {i : β} {x : γ} :\n  update (sum.elim f g) (inr i) x = sum.elim f (update g i x) :=\nupdate_eq_iff.2 ⟨by simp, by simp { contextual := tt }⟩\n\n@[simp] lemma update_inl_comp_inl {α β γ} [decidable_eq α] [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i : α} {x : γ} :\n  update f (inl i) x ∘ inl = update (f ∘ inl) i x :=\nupdate_comp_eq_of_injective _ inl_injective _ _\n\n@[simp] lemma update_inl_apply_inl {α β γ} [decidable_eq α] [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i j : α} {x : γ} :\n  update f (inl i) x (inl j) = update (f ∘ inl) i x j :=\nby rw ← update_inl_comp_inl\n\n@[simp] lemma update_inl_comp_inr {α β γ} [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i : α} {x : γ} :\n  update f (inl i) x ∘ inr = f ∘ inr :=\nupdate_comp_eq_of_forall_ne _ _ $ λ _, inr_ne_inl\n\n@[simp] lemma update_inl_apply_inr {α β γ} [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i : α} {j : β} {x : γ} :\n  update f (inl i) x (inr j) = f (inr j) :=\nfunction.update_noteq inr_ne_inl _ _\n\n@[simp] lemma update_inr_comp_inl {α β γ} [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i : β} {x : γ} :\n  update f (inr i) x ∘ inl = f ∘ inl :=\nupdate_comp_eq_of_forall_ne _ _ $ λ _, inl_ne_inr\n\n@[simp] lemma update_inr_apply_inl {α β γ} [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i : α} {j : β} {x : γ} :\n  update f (inr j) x (inl i) = f (inl i) :=\nfunction.update_noteq inl_ne_inr _ _\n\n@[simp] lemma update_inr_comp_inr {α β γ} [decidable_eq β] [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i : β} {x : γ} :\n  update f (inr i) x ∘ inr = update (f ∘ inr) i x :=\nupdate_comp_eq_of_injective _ inr_injective _ _\n\n@[simp] lemma update_inr_apply_inr {α β γ} [decidable_eq β] [decidable_eq (α ⊕ β)]\n  {f : α ⊕ β → γ} {i j : β} {x : γ} :\n  update f (inr i) x (inr j) = update (f ∘ inr) i x j :=\nby rw ← update_inr_comp_inr\n\nsection\n  variables (ra : α → α → Prop) (rb : β → β → Prop)\n\n  /-- Lexicographic order for sum. Sort all the `inl a` before the `inr b`,\n    otherwise use the respective order on `α` or `β`. -/\n  inductive lex : α ⊕ β → α ⊕ β → Prop\n  | inl {a₁ a₂} (h : ra a₁ a₂) : lex (inl a₁) (inl a₂)\n  | inr {b₁ b₂} (h : rb b₁ b₂) : lex (inr b₁) (inr b₂)\n  | sep (a b) : lex (inl a) (inr b)\n\n  variables {ra rb}\n\n  @[simp] theorem lex_inl_inl {a₁ a₂} : lex ra rb (inl a₁) (inl a₂) ↔ ra a₁ a₂ :=\n  ⟨λ h, by cases h; assumption, lex.inl⟩\n\n  @[simp] theorem lex_inr_inr {b₁ b₂} : lex ra rb (inr b₁) (inr b₂) ↔ rb b₁ b₂ :=\n  ⟨λ h, by cases h; assumption, lex.inr⟩\n\n  @[simp] theorem lex_inr_inl {b a} : ¬ lex ra rb (inr b) (inl a) :=\n  λ h, by cases h\n\n  attribute [simp] lex.sep\n\n  theorem lex_acc_inl {a} (aca : acc ra a) : acc (lex ra rb) (inl a) :=\n  begin\n    induction aca with a H IH,\n    constructor, intros y h,\n    cases h with a' _ h',\n    exact IH _ h'\n  end\n\n  theorem lex_acc_inr (aca : ∀ a, acc (lex ra rb) (inl a)) {b} (acb : acc rb b) :\n    acc (lex ra rb) (inr b) :=\n  begin\n    induction acb with b H IH,\n    constructor, intros y h,\n    cases h with _ _ _ b' _ h' a,\n    { exact IH _ h' },\n    { exact aca _ }\n  end\n\n  theorem lex_wf (ha : well_founded ra) (hb : well_founded rb) : well_founded (lex ra rb) :=\n  have aca : ∀ a, acc (lex ra rb) (inl a), from λ a, lex_acc_inl (ha.apply a),\n  ⟨λ x, sum.rec_on x aca (λ b, lex_acc_inr aca (hb.apply b))⟩\n\nend\n\n/-- Swap the factors of a sum type -/\n@[simp] def swap : α ⊕ β → β ⊕ α\n| (inl a) := inr a\n| (inr b) := inl b\n\n@[simp] lemma swap_swap (x : α ⊕ β) : swap (swap x) = x :=\nby cases x; refl\n\n@[simp] lemma swap_swap_eq : swap ∘ swap = @id (α ⊕ β) :=\nfunext $ swap_swap\n\n@[simp] lemma swap_left_inverse : function.left_inverse (@swap α β) swap :=\nswap_swap\n\n@[simp] lemma swap_right_inverse : function.right_inverse (@swap α β) swap :=\nswap_swap\n\nend sum\n\nnamespace function\n\nopen sum\n\nlemma injective.sum_elim {γ} {f : α → γ} {g : β → γ}\n  (hf : injective f) (hg : injective g) (hfg : ∀ a b, f a ≠ g b) :\n  injective (sum.elim f g)\n| (inl x) (inl y) h := congr_arg inl $ hf h\n| (inl x) (inr y) h := (hfg x y h).elim\n| (inr x) (inl y) h := (hfg y x h.symm).elim\n| (inr x) (inr y) h := congr_arg inr $ hg h\n\nlemma injective.sum_map {f : α → β} {g : α' → β'} (hf : injective f) (hg : injective g) :\n  injective (sum.map f g)\n| (inl x) (inl y) h := congr_arg inl $ hf $ inl.inj h\n| (inr x) (inr y) h := congr_arg inr $ hg $ inr.inj h\n\nlemma surjective.sum_map {f : α → β} {g : α' → β'} (hf : surjective f) (hg : surjective g) :\n  surjective (sum.map f g)\n| (inl y) := let ⟨x, hx⟩ := hf y in ⟨inl x, congr_arg inl hx⟩\n| (inr y) := let ⟨x, hx⟩ := hg y in ⟨inr x, congr_arg inr hx⟩\n\nend function\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.629774621301746, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.4584604663684526}}
{"text": "constants p q : Prop\n\ntheorem t1 : p → q → p := λ hp : p, λ hq : q, hp\n\n#print t1\n\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0202.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6297745935070806, "lm_q1q2_score": 0.4584604349844524}}
{"text": "/-\nCopyright (c) 2020 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\nimport data.list.range\n\n/-! \n# Lemmas about list.*_with_index functions.\n\nSome specification lemmas for `list.map_with_index`, `list.mmap_with_index`, `list.foldl_with_index`\nand `list.foldr_with_index`.\n-/\n\nuniverses u v\n\nopen function\n\nnamespace list\n\nvariables {α : Type u} {β : Type v}\n\nsection map_with_index\n\nlemma map_with_index_core_eq (l : list α) (f : ℕ → α → β) (n : ℕ) :\n  l.map_with_index_core f n = l.map_with_index (λ i a, f (i + n) a) :=\nbegin\n  induction l with hd tl hl generalizing f n,\n  { simp [map_with_index, map_with_index_core] },\n  { rw [map_with_index],\n    simp [map_with_index_core, hl, add_left_comm, add_assoc, add_comm] }\nend\n\nlemma map_with_index_eq_enum_map (l : list α) (f : ℕ → α → β) :\n  l.map_with_index f = l.enum.map (function.uncurry f) :=\nbegin\n  induction l with hd tl hl generalizing f,\n  { simp [map_with_index, map_with_index_core, list.enum_eq_zip_range] },\n  { rw [map_with_index, map_with_index_core, map_with_index_core_eq, hl],\n    simp [enum_eq_zip_range, range_succ_eq_map, zip_with_map_left,\n    map_uncurry_zip_eq_zip_with] }\nend\n\nend map_with_index\n\nsection foldr_with_index\n\n/-- Specification of `foldr_with_index_aux`. -/\ndef foldr_with_index_aux_spec (f : ℕ → α → β → β) (start : ℕ) (b : β)\n  (as : list α) : β :=\nfoldr (uncurry f) b $ enum_from start as\n\ntheorem foldr_with_index_aux_spec_cons (f : ℕ → α → β → β) (start b a as) :\n  foldr_with_index_aux_spec f start b (a :: as) =\n  f start a (foldr_with_index_aux_spec f (start + 1) b as) :=\nrfl\n\ntheorem foldr_with_index_aux_eq_foldr_with_index_aux_spec (f : ℕ → α → β → β)\n  (start b as) :\n  foldr_with_index_aux f start b as = foldr_with_index_aux_spec f start b as :=\nbegin\n  induction as generalizing start,\n  { refl },\n  { simp only [foldr_with_index_aux, foldr_with_index_aux_spec_cons, *] }\nend\n\ntheorem foldr_with_index_eq_foldr_enum (f : ℕ → α → β → β) (b : β) (as : list α) :\n  foldr_with_index f b as = foldr (uncurry f) b (enum as) :=\nby simp only\n    [foldr_with_index, foldr_with_index_aux_spec,\n     foldr_with_index_aux_eq_foldr_with_index_aux_spec, enum]\n\nend foldr_with_index\n\n\ntheorem indexes_values_eq_filter_enum (p : α → Prop) [decidable_pred p]\n  (as : list α) :\n  indexes_values p as = filter (p ∘ prod.snd) (enum as) :=\nby simp [indexes_values, foldr_with_index_eq_foldr_enum, uncurry, filter_eq_foldr]\n\ntheorem find_indexes_eq_map_indexes_values (p : α → Prop) [decidable_pred p]\n  (as : list α) :\n  find_indexes p as = map prod.fst (indexes_values p as) :=\nby simp only\n    [indexes_values_eq_filter_enum, map_filter_eq_foldr, find_indexes,\n     foldr_with_index_eq_foldr_enum, uncurry]\n\n\nsection foldl_with_index\n\n/-- Specification of `foldl_with_index_aux`. -/\ndef foldl_with_index_aux_spec (f : ℕ → α → β → α) (start : ℕ) (a : α)\n  (bs : list β) : α :=\nfoldl (λ a (p : ℕ × β), f p.fst a p.snd) a $ enum_from start bs\n\ntheorem foldl_with_index_aux_spec_cons (f : ℕ → α → β → α) (start a b bs) :\n  foldl_with_index_aux_spec f start a (b :: bs) =\n  foldl_with_index_aux_spec f (start + 1) (f start a b) bs :=\nrfl\n\ntheorem foldl_with_index_aux_eq_foldl_with_index_aux_spec (f : ℕ → α → β → α)\n  (start a bs) :\n  foldl_with_index_aux f start a bs = foldl_with_index_aux_spec f start a bs :=\nbegin\n  induction bs generalizing start a,\n  { refl },\n  { simp [foldl_with_index_aux, foldl_with_index_aux_spec_cons, *] }\nend\n\ntheorem foldl_with_index_eq_foldl_enum (f : ℕ → α → β → α) (a : α) (bs : list β) :\n  foldl_with_index f a bs =\n  foldl (λ a (p : ℕ × β), f p.fst a p.snd) a (enum bs) :=\nby simp only\n    [foldl_with_index, foldl_with_index_aux_spec,\n     foldl_with_index_aux_eq_foldl_with_index_aux_spec, enum]\n\nend foldl_with_index\n\n\nsection mfold_with_index\n\nvariables {m : Type u → Type v} [monad m]\n\ntheorem mfoldr_with_index_eq_mfoldr_enum {α β} (f : ℕ → α → β → m β) (b : β) (as : list α) :\n  mfoldr_with_index f b as = mfoldr (uncurry f) b (enum as) :=\nby simp only\n    [mfoldr_with_index, mfoldr_eq_foldr, foldr_with_index_eq_foldr_enum, uncurry]\n\ntheorem mfoldl_with_index_eq_mfoldl_enum [is_lawful_monad m] {α β}\n  (f : ℕ → β → α → m β) (b : β) (as : list α) :\n  mfoldl_with_index f b as =\n    mfoldl (λ b (p : ℕ × α), f p.fst b p.snd) b (enum as) :=\nby rw [mfoldl_with_index, mfoldl_eq_foldl, foldl_with_index_eq_foldl_enum]\n\nend mfold_with_index\n\n\nsection mmap_with_index\n\nvariables {m : Type u → Type v} [applicative m]\n\n/-- Specification of `mmap_with_index_aux`. -/\ndef mmap_with_index_aux_spec {α β} (f : ℕ → α → m β) (start : ℕ) (as : list α) :\n  m (list β) :=\nlist.traverse (uncurry f) $ enum_from start as\n-- Note: `traverse` the class method would require a less universe-polymorphic\n-- `m : Type u → Type u`.\n\ntheorem mmap_with_index_aux_spec_cons {α β} (f : ℕ → α → m β) (start : ℕ)\n  (a : α) (as : list α) :\n  mmap_with_index_aux_spec f start (a :: as) =\n    list.cons <$> f start a <*> mmap_with_index_aux_spec f (start + 1) as :=\nrfl\n\ntheorem mmap_with_index_aux_eq_mmap_with_index_aux_spec {α β} (f : ℕ → α → m β)\n  (start : ℕ) (as : list α) :\n  mmap_with_index_aux f start as = mmap_with_index_aux_spec f start as :=\nbegin\n  induction as generalizing start,\n  { refl },\n  { simp [mmap_with_index_aux, mmap_with_index_aux_spec_cons, *] }\nend\n\ntheorem mmap_with_index_eq_mmap_enum {α β} (f : ℕ → α → m β) (as : list α) :\n  mmap_with_index f as = list.traverse (uncurry f) (enum as) :=\nby simp only\n    [mmap_with_index, mmap_with_index_aux_spec,\n     mmap_with_index_aux_eq_mmap_with_index_aux_spec, enum ]\n\nend mmap_with_index\n\n\nsection mmap_with_index'\n\nvariables {m : Type u → Type v} [applicative m] [is_lawful_applicative m]\n\ntheorem mmap_with_index'_aux_eq_mmap_with_index_aux {α} (f : ℕ → α → m punit)\n  (start : ℕ) (as : list α) :\n  mmap_with_index'_aux f start as =\n  mmap_with_index_aux f start as *> pure punit.star :=\nby induction as generalizing start;\n    simp [mmap_with_index'_aux, mmap_with_index_aux, *, seq_right_eq, const, -comp_const]\n      with functor_norm\n\ntheorem mmap_with_index'_eq_mmap_with_index {α} (f : ℕ → α → m punit) (as : list α) :\n  mmap_with_index' f as = mmap_with_index f as *> pure punit.star :=\nby apply mmap_with_index'_aux_eq_mmap_with_index_aux\n\nend mmap_with_index'\n\nend list\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/list/indexes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.45832626699879786}}
{"text": "/-\nCopyright (c) 2022 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n-/\nimport ring_theory.valuation.integers\nimport ring_theory.ideal.local_ring\nimport ring_theory.localization.fraction_ring\nimport ring_theory.localization.integer\nimport ring_theory.discrete_valuation_ring\nimport ring_theory.bezout\nimport tactic.field_simp\n\n/-!\n# Valuation Rings\n\nA valuation ring is a domain such that for every pair of elements `a b`, either `a` divides\n`b` or vice-versa.\n\nAny valuation ring induces a natural valuation on its fraction field, as we show in this file.\nNamely, given the following instances:\n`[comm_ring A] [is_domain A] [valuation_ring A] [field K] [algebra A K] [is_fraction_ring A K]`,\nthere is a natural valuation `valuation A K` on `K` with values in `value_group A K` where\nthe image of `A` under `algebra_map A K` agrees with `(valuation A K).integer`.\n\nWe also provide the equivalence of the following notions for a domain `R` in `valuation_ring.tfae`.\n1. `R` is a valuation ring.\n2. For each `x : fraction_ring K`, either `x` or `x⁻¹` is in `R`.\n3. \"divides\" is a total relation on the elements of `R`.\n4. \"contains\" is a total relation on the ideals of `R`.\n5. `R` is a local bezout domain.\n\n-/\n\nuniverses u v w\n\n/-- An integral domain is called a `valuation ring` provided that for any pair\nof elements `a b : A`, either `a` divides `b` or vice versa. -/\nclass valuation_ring (A : Type u) [comm_ring A] [is_domain A] : Prop :=\n(cond [] : ∀ a b : A, ∃ c : A, a * c = b ∨ b * c = a)\n\nnamespace valuation_ring\n\nsection\nvariables (A : Type u) [comm_ring A]\nvariables (K : Type v) [field K] [algebra A K]\n\n/-- The value group of the valuation ring `A`. Note: this is actually a group with zero. -/\ndef value_group : Type v := quotient (mul_action.orbit_rel Aˣ K)\n\ninstance : inhabited (value_group A K) := ⟨quotient.mk' 0⟩\n\ninstance : has_le (value_group A K) := has_le.mk $ λ x y,\nquotient.lift_on₂' x y (λ a b, ∃ c : A, c • b = a)\nbegin\n  rintros _ _ a b ⟨c,rfl⟩ ⟨d,rfl⟩, ext,\n  split,\n  { rintros ⟨e,he⟩, use ((c⁻¹ : Aˣ) * e * d),\n    apply_fun (λ t, c⁻¹ • t) at he,\n    simpa [mul_smul] using he },\n  { rintros ⟨e,he⟩, dsimp,\n    use (d⁻¹ : Aˣ) * c * e,\n    erw [← he, ← mul_smul, ← mul_smul],\n    congr' 1,\n    rw mul_comm,\n    simp only [← mul_assoc, ← units.coe_mul, mul_inv_self, one_mul] }\nend\n\ninstance : has_zero (value_group A K) := ⟨quotient.mk' 0⟩\ninstance : has_one (value_group A K) := ⟨quotient.mk' 1⟩\n\ninstance : has_mul (value_group A K) := has_mul.mk $ λ x y,\nquotient.lift_on₂' x y (λ a b, quotient.mk' $ a * b)\nbegin\n  rintros _ _ a b ⟨c,rfl⟩ ⟨d,rfl⟩,\n  apply quotient.sound',\n  dsimp,\n  use c * d,\n  simp only [mul_smul, algebra.smul_def, units.smul_def, ring_hom.map_mul,\n    units.coe_mul],\n  ring,\nend\n\ninstance : has_inv (value_group A K) := has_inv.mk $ λ x,\nquotient.lift_on' x (λ a, quotient.mk' a⁻¹)\nbegin\n  rintros _ a ⟨b,rfl⟩,\n  apply quotient.sound',\n  use b⁻¹,\n  dsimp,\n  rw [units.smul_def, units.smul_def, algebra.smul_def, algebra.smul_def,\n    mul_inv, map_units_inv],\nend\n\nvariables [is_domain A] [valuation_ring A] [is_fraction_ring A K]\n\nprotected lemma le_total (a b : value_group A K) : a ≤ b ∨ b ≤ a :=\nbegin\n  rcases a with ⟨a⟩, rcases b with ⟨b⟩,\n  obtain ⟨xa,ya,hya,rfl⟩ : ∃ (a b : A), _ := is_fraction_ring.div_surjective a,\n  obtain ⟨xb,yb,hyb,rfl⟩ : ∃ (a b : A), _ := is_fraction_ring.div_surjective b,\n  have : (algebra_map A K) ya ≠ 0 :=\n    is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hya,\n  have : (algebra_map A K) yb ≠ 0 :=\n    is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hyb,\n  obtain ⟨c,(h|h)⟩ := valuation_ring.cond (xa * yb) (xb * ya),\n  { right,\n    use c,\n    rw algebra.smul_def,\n    field_simp,\n    simp only [← ring_hom.map_mul, ← h], congr' 1, ring },\n  { left,\n    use c,\n    rw algebra.smul_def,\n    field_simp,\n    simp only [← ring_hom.map_mul, ← h], congr' 1, ring }\nend\n\nnoncomputable\ninstance : linear_ordered_comm_group_with_zero (value_group A K) :=\n{ le_refl := by { rintro ⟨⟩, use 1, rw one_smul },\n  le_trans := by { rintros ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨e,rfl⟩ ⟨f,rfl⟩, use (e * f), rw mul_smul },\n  le_antisymm := begin\n    rintros ⟨a⟩ ⟨b⟩ ⟨e,rfl⟩ ⟨f,hf⟩,\n    by_cases hb : b = 0, { simp [hb] },\n    have : is_unit e,\n    { apply is_unit_of_dvd_one,\n      use f, rw mul_comm,\n      rw [← mul_smul, algebra.smul_def] at hf,\n      nth_rewrite 1 ← one_mul b at hf,\n      rw ← (algebra_map A K).map_one at hf,\n      exact is_fraction_ring.injective _ _ (mul_right_cancel₀ hb hf).symm },\n    apply quotient.sound',\n    use [this.unit, rfl],\n  end,\n  le_total := valuation_ring.le_total _ _,\n  decidable_le := by { classical, apply_instance },\n  mul_assoc := by { rintros ⟨a⟩ ⟨b⟩ ⟨c⟩, apply quotient.sound', rw mul_assoc, apply setoid.refl' },\n  one_mul := by { rintros ⟨a⟩, apply quotient.sound', rw one_mul, apply setoid.refl' },\n  mul_one := by { rintros ⟨a⟩, apply quotient.sound', rw mul_one, apply setoid.refl' },\n  mul_comm := by { rintros ⟨a⟩ ⟨b⟩, apply quotient.sound', rw mul_comm, apply setoid.refl' },\n  mul_le_mul_left := begin\n    rintros ⟨a⟩ ⟨b⟩ ⟨c,rfl⟩ ⟨d⟩,\n    use c, simp only [algebra.smul_def], ring,\n  end,\n  zero_mul := by { rintros ⟨a⟩, apply quotient.sound', rw zero_mul, apply setoid.refl' },\n  mul_zero := by { rintros ⟨a⟩, apply quotient.sound', rw mul_zero, apply setoid.refl' },\n  zero_le_one := ⟨0, by rw zero_smul⟩,\n  exists_pair_ne := begin\n    use [0,1],\n    intro c, obtain ⟨d,hd⟩ := quotient.exact' c,\n    apply_fun (λ t, d⁻¹ • t) at hd,\n    simpa using hd,\n  end,\n  inv_zero := by { apply quotient.sound', rw inv_zero, apply setoid.refl' },\n  mul_inv_cancel := begin\n    rintros ⟨a⟩ ha,\n    apply quotient.sound',\n    use 1,\n    simp only [one_smul],\n    apply (mul_inv_cancel _).symm,\n    contrapose ha,\n    simp only [not_not] at ha ⊢,\n    rw ha, refl,\n  end,\n  ..(infer_instance : has_le (value_group A K)),\n  ..(infer_instance : has_mul (value_group A K)),\n  ..(infer_instance : has_inv (value_group A K)),\n  ..(infer_instance : has_zero (value_group A K)),\n  ..(infer_instance : has_one (value_group A K)) }\n\n/-- Any valuation ring induces a valuation on its fraction field. -/\ndef valuation : valuation K (value_group A K) :=\n{ to_fun := quotient.mk',\n  map_zero' := rfl,\n  map_one' := rfl,\n  map_mul' := λ _ _, rfl,\n  map_add_le_max' := begin\n    intros a b,\n    obtain ⟨xa,ya,hya,rfl⟩ : ∃ (a b : A), _ := is_fraction_ring.div_surjective a,\n    obtain ⟨xb,yb,hyb,rfl⟩ : ∃ (a b : A), _ := is_fraction_ring.div_surjective b,\n    have : (algebra_map A K) ya ≠ 0 :=\n      is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hya,\n    have : (algebra_map A K) yb ≠ 0 :=\n      is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hyb,\n    obtain ⟨c,(h|h)⟩ := valuation_ring.cond (xa * yb) (xb * ya),\n    dsimp,\n    { apply le_trans _ (le_max_left _ _),\n      use (c + 1),\n      rw algebra.smul_def,\n      field_simp,\n      simp only [← ring_hom.map_mul, ← ring_hom.map_add, ← (algebra_map A K).map_one, ← h],\n      congr' 1, ring },\n    { apply le_trans _ (le_max_right _ _),\n      use (c + 1),\n      rw algebra.smul_def,\n      field_simp,\n      simp only [← ring_hom.map_mul, ← ring_hom.map_add, ← (algebra_map A K).map_one, ← h],\n      congr' 1, ring }\n  end }\n\nlemma mem_integer_iff (x : K) : x ∈ (valuation A K).integer ↔ ∃ a : A, algebra_map A K a = x :=\nbegin\n  split,\n  { rintros ⟨c,rfl⟩,\n    use c,\n    rw [algebra.smul_def, mul_one] },\n  { rintro ⟨c,rfl⟩,\n    use c,\n    rw [algebra.smul_def, mul_one] }\nend\n\n/-- The valuation ring `A` is isomorphic to the ring of integers of its associated valuation. -/\nnoncomputable def equiv_integer : A ≃+* (valuation A K).integer :=\nring_equiv.of_bijective (show A →ₙ+* (valuation A K).integer, from\n{ to_fun := λ a, ⟨algebra_map A K a, (mem_integer_iff _ _ _).mpr ⟨a,rfl⟩⟩,\n  map_mul' := λ _ _, by { ext1, exact (algebra_map A K).map_mul _ _ },\n  map_zero' := by { ext1, exact (algebra_map A K).map_zero },\n  map_add' := λ _ _, by { ext1, exact (algebra_map A K).map_add _ _ } })\nbegin\n  split,\n  { intros x y h,\n    apply_fun (coe : _ → K) at h,\n    dsimp at h,\n    exact is_fraction_ring.injective _ _ h },\n  { rintros ⟨a,(ha : a ∈ (valuation A K).integer)⟩,\n    rw mem_integer_iff at ha,\n    obtain ⟨a,rfl⟩ := ha,\n    use [a, rfl] }\nend\n\n@[simp]\nlemma coe_equiv_integer_apply (a : A) : (equiv_integer A K a : K) = algebra_map A K a := rfl\n\nlemma range_algebra_map_eq : (valuation A K).integer = (algebra_map A K).range :=\nby { ext, exact mem_integer_iff _ _ _ }\n\nend\n\nsection\n\nvariables (A : Type u) [comm_ring A] [is_domain A] [valuation_ring A]\n\n@[priority 100]\ninstance : local_ring A :=\nlocal_ring.of_is_unit_or_is_unit_one_sub_self\nbegin\n  intros a,\n  obtain ⟨c,(h|h)⟩ := valuation_ring.cond a (1-a),\n  { left,\n    apply is_unit_of_mul_eq_one _ (c+1),\n    simp [mul_add, h] },\n  { right,\n    apply is_unit_of_mul_eq_one _ (c+1),\n    simp [mul_add, h] }\nend\n\ninstance [decidable_rel ((≤) : ideal A → ideal A → Prop)] : linear_order (ideal A) :=\n{ le_total := begin\n    intros α β,\n    by_cases h : α ≤ β, { exact or.inl h },\n    erw not_forall at h,\n    push_neg at h,\n    obtain ⟨a,h₁,h₂⟩ := h,\n    right,\n    intros b hb,\n    obtain ⟨c,(h|h)⟩ := valuation_ring.cond a b,\n    { rw ← h,\n      exact ideal.mul_mem_right _ _ h₁ },\n    { exfalso, apply h₂, rw ← h,\n      apply ideal.mul_mem_right _ _ hb },\n  end,\n  decidable_le := infer_instance,\n  ..(infer_instance : complete_lattice (ideal A)) }\n\nend\n\nsection\n\nvariables {R : Type*} [comm_ring R] [is_domain R] {K : Type*}\nvariables [field K] [algebra R K] [is_fraction_ring R K]\n\nlemma iff_dvd_total :\n  valuation_ring R ↔ is_total R (∣) :=\nbegin\n  classical,\n  refine ⟨λ H, ⟨λ a b, _⟩, λ H, ⟨λ a b, _⟩⟩; resetI,\n  { obtain ⟨c,rfl|rfl⟩ := @@valuation_ring.cond _ _ H a b; simp },\n  { obtain (⟨c, rfl⟩|⟨c, rfl⟩) := @is_total.total _ _ H a b; use c; simp }\nend\n\nlemma iff_ideal_total :\n  valuation_ring R ↔ is_total (ideal R) (≤) :=\nbegin\n  classical,\n  refine ⟨λ _, by exactI ⟨le_total⟩, λ H, iff_dvd_total.mpr ⟨λ a b, _⟩⟩,\n  have := @is_total.total _ _ H (ideal.span {a}) (ideal.span {b}),\n  simp_rw ideal.span_singleton_le_span_singleton at this,\n  exact this.symm\nend\n\nvariables {R} (K)\n\nlemma dvd_total [h : valuation_ring R] (x y : R) : x ∣ y ∨ y ∣ x :=\n@@is_total.total _ (iff_dvd_total.mp h) x y\n\nlemma unique_irreducible [valuation_ring R] ⦃p q : R⦄\n  (hp : irreducible p) (hq : irreducible q) : associated p q :=\nbegin\n  have := dvd_total p q,\n  rw [irreducible.dvd_comm hp hq, or_self] at this,\n  exact associated_of_dvd_dvd (irreducible.dvd_symm hq hp this) this,\nend\n\nvariable (R)\n\nlemma iff_is_integer_or_is_integer :\n  valuation_ring R ↔ ∀ x : K, is_localization.is_integer R x ∨ is_localization.is_integer R x⁻¹ :=\nbegin\n  split,\n  { introsI H x,\n    obtain ⟨x : R, y, hy, rfl⟩ := is_fraction_ring.div_surjective x,\n    any_goals { apply_instance },\n    have := (map_ne_zero_iff _ (is_fraction_ring.injective R K)).mpr (non_zero_divisors.ne_zero hy),\n    obtain ⟨s, rfl|rfl⟩ := valuation_ring.cond x y,\n    { exact or.inr ⟨s, eq_inv_of_mul_eq_one_left $\n        by rwa [mul_div, div_eq_one_iff_eq, map_mul, mul_comm]⟩ },\n    { exact or.inl ⟨s, by rwa [eq_div_iff, map_mul, mul_comm]⟩ } },\n  { intro H,\n    constructor,\n    intros a b,\n    by_cases ha : a = 0, { subst ha, exact ⟨0, or.inr $ mul_zero b⟩ },\n    by_cases hb : b = 0, { subst hb, exact ⟨0, or.inl $ mul_zero a⟩ },\n    replace ha := (map_ne_zero_iff _ (is_fraction_ring.injective R K)).mpr ha,\n    replace hb := (map_ne_zero_iff _ (is_fraction_ring.injective R K)).mpr hb,\n    obtain ⟨c, e⟩|⟨c, e⟩ := H (algebra_map R K a / algebra_map R K b),\n    { rw [eq_div_iff hb, ← map_mul, (is_fraction_ring.injective R K).eq_iff, mul_comm] at e,\n      exact ⟨c, or.inr e⟩ },\n    { rw [inv_div, eq_div_iff ha, ← map_mul,\n        (is_fraction_ring.injective R K).eq_iff, mul_comm c] at e,\n      exact ⟨c, or.inl e⟩ } }\nend\n\nvariable {K}\n\nlemma is_integer_or_is_integer [h : valuation_ring R] (x : K) :\n  is_localization.is_integer R x ∨ is_localization.is_integer R x⁻¹ :=\n(iff_is_integer_or_is_integer R K).mp h x\n\nvariable {R}\n\n-- This implies that valuation rings are integrally closed through typeclass search.\n@[priority 100]\ninstance [valuation_ring R] : is_bezout R :=\nbegin\n  classical,\n  rw is_bezout.iff_span_pair_is_principal,\n  intros x y,\n  rw ideal.span_insert,\n  cases le_total (ideal.span {x} : ideal R) (ideal.span {y}),\n  { erw sup_eq_right.mpr h, exact ⟨⟨_, rfl⟩⟩ },\n  { erw sup_eq_left.mpr h, exact ⟨⟨_, rfl⟩⟩ }\nend\n\nlemma iff_local_bezout_domain :\n  valuation_ring R ↔ local_ring R ∧ is_bezout R :=\nbegin\n  classical,\n  refine ⟨λ H, by exactI ⟨infer_instance, infer_instance⟩, _⟩,\n  rintro ⟨h₁, h₂⟩,\n  resetI,\n  refine iff_dvd_total.mpr ⟨λ a b, _⟩,\n  obtain ⟨g, e : _ = ideal.span _⟩ := is_bezout.span_pair_is_principal a b,\n  obtain ⟨a, rfl⟩ := ideal.mem_span_singleton'.mp\n    (show a ∈ ideal.span {g}, by { rw [← e], exact ideal.subset_span (by simp) }),\n  obtain ⟨b, rfl⟩ := ideal.mem_span_singleton'.mp\n    (show b ∈ ideal.span {g}, by { rw [← e], exact ideal.subset_span (by simp) }),\n  obtain ⟨x, y, e'⟩ := ideal.mem_span_pair.mp\n    (show g ∈ ideal.span {a * g, b * g}, by { rw e, exact ideal.subset_span (by simp) }),\n  cases eq_or_ne g 0 with h h, { simp [h] },\n  have : x * a + y * b = 1,\n  { apply mul_left_injective₀ h, convert e'; ring_nf },\n  cases local_ring.is_unit_or_is_unit_of_add_one this with h' h',\n  left, swap, right,\n  all_goals\n  { exact mul_dvd_mul_right (is_unit_iff_forall_dvd.mp (is_unit_of_mul_is_unit_right h') _) _ },\nend\n\nprotected lemma tfae (R : Type u) [comm_ring R] [is_domain R] :\n  tfae [valuation_ring R,\n    ∀ x : fraction_ring R, is_localization.is_integer R x ∨ is_localization.is_integer R x⁻¹,\n    is_total R (∣),\n    is_total (ideal R) (≤),\n    local_ring R ∧ is_bezout R] :=\nbegin\n  tfae_have : 1 ↔ 2, { exact iff_is_integer_or_is_integer R _ },\n  tfae_have : 1 ↔ 3, { exact iff_dvd_total },\n  tfae_have : 1 ↔ 4, { exact iff_ideal_total },\n  tfae_have : 1 ↔ 5, { exact iff_local_bezout_domain },\n  tfae_finish\nend\n\nend\n\nlemma _root_.function.surjective.valuation_ring {R S : Type*} [comm_ring R] [is_domain R]\n  [valuation_ring R] [comm_ring S] [is_domain S] (f : R →+* S) (hf : function.surjective f) :\n  valuation_ring S :=\n⟨λ a b, begin\n  obtain ⟨⟨a, rfl⟩, ⟨b, rfl⟩⟩ := ⟨hf a, hf b⟩,\n  obtain ⟨c, rfl|rfl⟩ := valuation_ring.cond a b,\n  exacts [⟨f c, or.inl $ (map_mul _ _ _).symm⟩, ⟨f c, or.inr $ (map_mul _ _ _).symm⟩],\nend⟩\n\nsection\n\nvariables {𝒪 : Type u} {K : Type v} {Γ : Type w}\n  [comm_ring 𝒪] [is_domain 𝒪] [field K] [algebra 𝒪 K]\n  [linear_ordered_comm_group_with_zero Γ]\n  (v : _root_.valuation K Γ) (hh : v.integers 𝒪)\n\ninclude hh\n\n/-- If `𝒪` satisfies `v.integers 𝒪` where `v` is a valuation on a field, then `𝒪`\nis a valuation ring. -/\nlemma of_integers : valuation_ring 𝒪 :=\nbegin\n  constructor,\n  intros a b,\n  cases le_total (v (algebra_map 𝒪 K a)) (v (algebra_map 𝒪 K b)),\n  { obtain ⟨c,hc⟩ := valuation.integers.dvd_of_le hh h,\n    use c, exact or.inr hc.symm },\n  { obtain ⟨c,hc⟩ := valuation.integers.dvd_of_le hh h,\n    use c, exact or.inl hc.symm }\nend\n\nend\n\nsection\n\nvariables (K : Type u) [field K]\n\n/-- A field is a valuation ring. -/\n@[priority 100]\ninstance of_field : valuation_ring K :=\nbegin\n  constructor,\n  intros a b,\n  by_cases b = 0,\n  { use 0, left, simp [h] },\n  { use a * b⁻¹, right, field_simp, rw mul_comm }\nend\n\nend\n\nsection\n\nvariables (A : Type u) [comm_ring A] [is_domain A] [discrete_valuation_ring A]\n\n/-- A DVR is a valuation ring. -/\n@[priority 100]\ninstance of_discrete_valuation_ring : valuation_ring A :=\nbegin\n  constructor,\n  intros a b,\n  by_cases ha : a = 0, { use 0, right, simp [ha] },\n  by_cases hb : b = 0, { use 0, left, simp [hb] },\n  obtain ⟨ϖ,hϖ⟩ := discrete_valuation_ring.exists_irreducible A,\n  obtain ⟨m,u,rfl⟩ := discrete_valuation_ring.eq_unit_mul_pow_irreducible ha hϖ,\n  obtain ⟨n,v,rfl⟩ := discrete_valuation_ring.eq_unit_mul_pow_irreducible hb hϖ,\n  cases le_total m n with h h,\n  { use (u⁻¹ * v : Aˣ) * ϖ^(n-m), left,\n    simp_rw [mul_comm (u : A), units.coe_mul, ← mul_assoc, mul_assoc _ (u : A)],\n    simp only [units.mul_inv, mul_one, mul_comm _ (v : A), mul_assoc, ← pow_add],\n    congr' 2,\n    linarith },\n  { use (v⁻¹ * u : Aˣ) * ϖ^(m-n), right,\n    simp_rw [mul_comm (v : A), units.coe_mul, ← mul_assoc, mul_assoc _ (v : A)],\n    simp only [units.mul_inv, mul_one, mul_comm _ (u : A), mul_assoc, ← pow_add],\n    congr' 2,\n    linarith }\nend\n\nend\n\nend valuation_ring\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/valuation/valuation_ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.45832626311172103}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Scott Morrison\n\nFacts about epimorphisms and monomorphisms.\n\nThe definitions of `epi` and `mono` are in `category_theory.category`,\nsince they are used by some lemmas for `iso`, which is used everywhere.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.adjunction.basic\nimport Mathlib.category_theory.opposites\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\ntheorem left_adjoint_preserves_epi {C : Type u₁} [category C] {D : Type u₂} [category D] {F : C ⥤ D}\n    {G : D ⥤ C} (adj : F ⊣ G) {X : C} {Y : C} {f : X ⟶ Y} (hf : epi f) : epi (functor.map F f) :=\n  sorry\n\ntheorem right_adjoint_preserves_mono {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {F : C ⥤ D} {G : D ⥤ C} (adj : F ⊣ G) {X : D} {Y : D} {f : X ⟶ Y} (hf : mono f) :\n    mono (functor.map G f) :=\n  sorry\n\ntheorem faithful_reflects_epi {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D)\n    [faithful F] {X : C} {Y : C} {f : X ⟶ Y} (hf : epi (functor.map F f)) : epi f :=\n  sorry\n\ntheorem faithful_reflects_mono {C : Type u₁} [category C] {D : Type u₂} [category D] (F : C ⥤ D)\n    [faithful F] {X : C} {Y : C} {f : X ⟶ Y} (hf : mono (functor.map F f)) : mono f :=\n  sorry\n\n/--\nA split monomorphism is a morphism `f : X ⟶ Y` admitting a retraction `retraction f : Y ⟶ X`\nsuch that `f ≫ retraction f = 𝟙 X`.\n\nEvery split monomorphism is a monomorphism.\n-/\nclass split_mono {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y) where\n  retraction : Y ⟶ X\n  id' :\n    autoParam (f ≫ retraction = 𝟙)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n/--\nA split epimorphism is a morphism `f : X ⟶ Y` admitting a section `section_ f : Y ⟶ X`\nsuch that `section_ f ≫ f = 𝟙 Y`.\n(Note that `section` is a reserved keyword, so we append an underscore.)\n\nEvery split epimorphism is an epimorphism.\n-/\nclass split_epi {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y) where\n  section_ : Y ⟶ X\n  id' :\n    autoParam (section_ ≫ f = 𝟙)\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n/-- The chosen retraction of a split monomorphism. -/\ndef retraction {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y) [split_mono f] : Y ⟶ X :=\n  split_mono.retraction f\n\n@[simp] theorem split_mono.id_assoc {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [split_mono f] {X' : C} (f' : X ⟶ X') : f ≫ retraction f ≫ f' = f' :=\n  sorry\n\n/-- The retraction of a split monomorphism is itself a split epimorphism. -/\nprotected instance retraction_split_epi {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [split_mono f] : split_epi (retraction f) :=\n  split_epi.mk f\n\n/-- A split mono which is epi is an iso. -/\ndef is_iso_of_epi_of_split_mono {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [split_mono f] [epi f] : is_iso f :=\n  is_iso.mk (retraction f)\n\n/--\nThe chosen section of a split epimorphism.\n(Note that `section` is a reserved keyword, so we append an underscore.)\n-/\ndef section_ {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y) [split_epi f] : Y ⟶ X :=\n  split_epi.section_ f\n\n@[simp] theorem split_epi.id_assoc {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [split_epi f] {X' : C} (f' : Y ⟶ X') : section_ f ≫ f ≫ f' = f' :=\n  sorry\n\n/-- The section of a split epimorphism is itself a split monomorphism. -/\nprotected instance section_split_mono {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [split_epi f] : split_mono (section_ f) :=\n  split_mono.mk f\n\n/-- A split epi which is mono is an iso. -/\ndef is_iso_of_mono_of_split_epi {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y) [mono f]\n    [split_epi f] : is_iso f :=\n  is_iso.mk (section_ f)\n\n/-- Every iso is a split mono. -/\nprotected instance split_mono.of_iso {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [is_iso f] : split_mono f :=\n  split_mono.mk (inv f)\n\n/-- Every iso is a split epi. -/\nprotected instance split_epi.of_iso {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [is_iso f] : split_epi f :=\n  split_epi.mk (inv f)\n\n/-- Every split mono is a mono. -/\nprotected instance split_mono.mono {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [split_mono f] : mono f :=\n  sorry\n\n/-- Every split epi is an epi. -/\nprotected instance split_epi.epi {C : Type u₁} [category C] {X : C} {Y : C} (f : X ⟶ Y)\n    [split_epi f] : epi f :=\n  epi.mk\n    fun (Z : C) (g h : Y ⟶ Z) (w : f ≫ g = f ≫ h) =>\n      eq.mpr (id (Eq.refl (g = h)))\n        (eq.mp\n          ((fun (a a_1 : Y ⟶ Z) (e_1 : a = a_1) (ᾰ ᾰ_1 : Y ⟶ Z) (e_2 : ᾰ = ᾰ_1) =>\n              congr (congr_arg Eq e_1) e_2)\n            (section_ f ≫ f ≫ g) g (split_epi.id_assoc f g) (section_ f ≫ f ≫ h) h\n            (split_epi.id_assoc f h))\n          (section_ f ≫= w))\n\n/-- Every split mono whose retraction is mono is an iso. -/\ndef is_iso.of_mono_retraction {C : Type u₁} [category C] {X : C} {Y : C} {f : X ⟶ Y} [split_mono f]\n    [mono (retraction f)] : is_iso f :=\n  is_iso.mk (retraction f)\n\n/-- Every split epi whose section is epi is an iso. -/\ndef is_iso.of_epi_section {C : Type u₁} [category C] {X : C} {Y : C} {f : X ⟶ Y} [split_epi f]\n    [epi (section_ f)] : is_iso f :=\n  is_iso.mk (section_ f)\n\nprotected instance unop_mono_of_epi {C : Type u₁} [category C] {A : Cᵒᵖ} {B : Cᵒᵖ} (f : A ⟶ B)\n    [epi f] : mono (has_hom.hom.unop f) :=\n  mono.mk\n    fun (Z : C) (g h : Z ⟶ opposite.unop B)\n      (eq : g ≫ has_hom.hom.unop f = h ≫ has_hom.hom.unop f) =>\n      has_hom.hom.op_inj (iff.mp (cancel_epi f) (has_hom.hom.unop_inj eq))\n\nprotected instance unop_epi_of_mono {C : Type u₁} [category C] {A : Cᵒᵖ} {B : Cᵒᵖ} (f : A ⟶ B)\n    [mono f] : epi (has_hom.hom.unop f) :=\n  epi.mk\n    fun (Z : C) (g h : opposite.unop A ⟶ Z)\n      (eq : has_hom.hom.unop f ≫ g = has_hom.hom.unop f ≫ h) =>\n      has_hom.hom.op_inj (iff.mp (cancel_mono f) (has_hom.hom.unop_inj eq))\n\nprotected instance op_mono_of_epi {C : Type u₁} [category C] {A : C} {B : C} (f : A ⟶ B) [epi f] :\n    mono (has_hom.hom.op f) :=\n  mono.mk\n    fun (Z : Cᵒᵖ) (g h : Z ⟶ opposite.op B) (eq : g ≫ has_hom.hom.op f = h ≫ has_hom.hom.op f) =>\n      has_hom.hom.unop_inj (iff.mp (cancel_epi f) (has_hom.hom.op_inj eq))\n\nprotected instance op_epi_of_mono {C : Type u₁} [category C] {A : C} {B : C} (f : A ⟶ B) [mono f] :\n    epi (has_hom.hom.op f) :=\n  epi.mk\n    fun (Z : Cᵒᵖ) (g h : opposite.op A ⟶ Z) (eq : has_hom.hom.op f ≫ g = has_hom.hom.op f ≫ h) =>\n      has_hom.hom.unop_inj (iff.mp (cancel_mono f) (has_hom.hom.op_inj eq))\n\n/-- Split monomorphisms are also absolute monomorphisms. -/\nprotected instance functor.map.split_mono {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {X : C} {Y : C} (f : X ⟶ Y) [split_mono f] (F : C ⥤ D) : split_mono (functor.map F f) :=\n  split_mono.mk (functor.map F (retraction f))\n\n/-- Split epimorphisms are also absolute epimorphisms. -/\nprotected instance functor.map.split_epi {C : Type u₁} [category C] {D : Type u₂} [category D]\n    {X : C} {Y : C} (f : X ⟶ Y) [split_epi f] (F : C ⥤ D) : split_epi (functor.map F f) :=\n  split_epi.mk (functor.map F (section_ f))\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/epi_mono_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.45832626311172103}}
{"text": "/-\nCopyright (c) 2020 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\nimport data.list.basic\nimport data.list.defs\nimport data.list.zip\nimport data.list.range\nimport logic.basic\n\nuniverses u v\n\nopen function\n\nnamespace list\n\nvariables {α : Type u} {β : Type v}\n\nsection map_with_index\n\nlemma map_with_index_core_eq (l : list α) (f : ℕ → α → β) (n : ℕ) :\n  l.map_with_index_core f n = l.map_with_index (λ i a, f (i + n) a) :=\nbegin\n  induction l with hd tl hl generalizing f n,\n  { simp [map_with_index, map_with_index_core] },\n  { rw [map_with_index],\n    simp [map_with_index_core, hl, add_left_comm, add_assoc, add_comm] }\nend\n\nlemma map_with_index_eq_enum_map (l : list α) (f : ℕ → α → β) :\n  l.map_with_index f = l.enum.map (function.uncurry f) :=\nbegin\n  induction l with hd tl hl generalizing f,\n  { simp [map_with_index, map_with_index_core, list.enum_eq_zip_range] },\n  { rw [map_with_index, map_with_index_core, map_with_index_core_eq, hl],\n    simp [enum_eq_zip_range, range_succ_eq_map, zip_with_map_left,\n    map_uncurry_zip_eq_zip_with] }\nend\n\nend map_with_index\n\nsection foldr_with_index\n\n/-- Specification of `foldr_with_index_aux`. -/\ndef foldr_with_index_aux_spec (f : ℕ → α → β → β) (start : ℕ) (b : β)\n  (as : list α) : β :=\nfoldr (uncurry f) b $ enum_from start as\n\ntheorem foldr_with_index_aux_spec_cons (f : ℕ → α → β → β) (start b a as) :\n  foldr_with_index_aux_spec f start b (a :: as) =\n  f start a (foldr_with_index_aux_spec f (start + 1) b as) :=\nrfl\n\ntheorem foldr_with_index_aux_eq_foldr_with_index_aux_spec (f : ℕ → α → β → β)\n  (start b as) :\n  foldr_with_index_aux f start b as = foldr_with_index_aux_spec f start b as :=\nbegin\n  induction as generalizing start,\n  { refl },\n  { simp only [foldr_with_index_aux, foldr_with_index_aux_spec_cons, *] }\nend\n\ntheorem foldr_with_index_eq_foldr_enum (f : ℕ → α → β → β) (b : β) (as : list α) :\n  foldr_with_index f b as = foldr (uncurry f) b (enum as) :=\nby simp only\n    [foldr_with_index, foldr_with_index_aux_spec,\n     foldr_with_index_aux_eq_foldr_with_index_aux_spec, enum]\n\nend foldr_with_index\n\n\ntheorem indexes_values_eq_filter_enum (p : α → Prop) [decidable_pred p]\n  (as : list α) :\n  indexes_values p as = filter (p ∘ prod.snd) (enum as) :=\nby simp [indexes_values, foldr_with_index_eq_foldr_enum, uncurry, filter_eq_foldr]\n\ntheorem find_indexes_eq_map_indexes_values (p : α → Prop) [decidable_pred p]\n  (as : list α) :\n  find_indexes p as = map prod.fst (indexes_values p as) :=\nby simp only\n    [indexes_values_eq_filter_enum, map_filter_eq_foldr, find_indexes,\n     foldr_with_index_eq_foldr_enum, uncurry]\n\n\nsection foldl_with_index\n\n/-- Specification of `foldl_with_index_aux`. -/\ndef foldl_with_index_aux_spec (f : ℕ → α → β → α) (start : ℕ) (a : α)\n  (bs : list β) : α :=\nfoldl (λ a (p : ℕ × β), f p.fst a p.snd) a $ enum_from start bs\n\ntheorem foldl_with_index_aux_spec_cons (f : ℕ → α → β → α) (start a b bs) :\n  foldl_with_index_aux_spec f start a (b :: bs) =\n  foldl_with_index_aux_spec f (start + 1) (f start a b) bs :=\nrfl\n\ntheorem foldl_with_index_aux_eq_foldl_with_index_aux_spec (f : ℕ → α → β → α)\n  (start a bs) :\n  foldl_with_index_aux f start a bs = foldl_with_index_aux_spec f start a bs :=\nbegin\n  induction bs generalizing start a,\n  { refl },\n  { simp [foldl_with_index_aux, foldl_with_index_aux_spec_cons, *] }\nend\n\ntheorem foldl_with_index_eq_foldl_enum (f : ℕ → α → β → α) (a : α) (bs : list β) :\n  foldl_with_index f a bs =\n  foldl (λ a (p : ℕ × β), f p.fst a p.snd) a (enum bs) :=\nby simp only\n    [foldl_with_index, foldl_with_index_aux_spec,\n     foldl_with_index_aux_eq_foldl_with_index_aux_spec, enum]\n\nend foldl_with_index\n\n\nsection mfold_with_index\n\nvariables {m : Type u → Type v} [monad m]\n\ntheorem mfoldr_with_index_eq_mfoldr_enum {α β} (f : ℕ → α → β → m β) (b : β) (as : list α) :\n  mfoldr_with_index f b as = mfoldr (uncurry f) b (enum as) :=\nby simp only\n    [mfoldr_with_index, mfoldr_eq_foldr, foldr_with_index_eq_foldr_enum, uncurry]\n\ntheorem mfoldl_with_index_eq_mfoldl_enum [is_lawful_monad m] {α β}\n  (f : ℕ → β → α → m β) (b : β) (as : list α) :\n  mfoldl_with_index f b as =\n    mfoldl (λ b (p : ℕ × α), f p.fst b p.snd) b (enum as) :=\nby rw [mfoldl_with_index, mfoldl_eq_foldl, foldl_with_index_eq_foldl_enum]\n\nend mfold_with_index\n\n\nsection mmap_with_index\n\nvariables {m : Type u → Type v} [applicative m]\n\n/-- Specification of `mmap_with_index_aux`. -/\ndef mmap_with_index_aux_spec {α β} (f : ℕ → α → m β) (start : ℕ) (as : list α) :\n  m (list β) :=\nlist.traverse (uncurry f) $ enum_from start as\n-- Note: `traverse` the class method would require a less universe-polymorphic\n-- `m : Type u → Type u`.\n\ntheorem mmap_with_index_aux_spec_cons {α β} (f : ℕ → α → m β) (start : ℕ)\n  (a : α) (as : list α) :\n  mmap_with_index_aux_spec f start (a :: as) =\n    list.cons <$> f start a <*> mmap_with_index_aux_spec f (start + 1) as :=\nrfl\n\ntheorem mmap_with_index_aux_eq_mmap_with_index_aux_spec {α β} (f : ℕ → α → m β)\n  (start : ℕ) (as : list α) :\n  mmap_with_index_aux f start as = mmap_with_index_aux_spec f start as :=\nbegin\n  induction as generalizing start,\n  { refl },\n  { simp [mmap_with_index_aux, mmap_with_index_aux_spec_cons, *] }\nend\n\ntheorem mmap_with_index_eq_mmap_enum {α β} (f : ℕ → α → m β) (as : list α) :\n  mmap_with_index f as = list.traverse (uncurry f) (enum as) :=\nby simp only\n    [mmap_with_index, mmap_with_index_aux_spec,\n     mmap_with_index_aux_eq_mmap_with_index_aux_spec, enum ]\n\nend mmap_with_index\n\n\nsection mmap_with_index'\n\nvariables {m : Type u → Type v} [applicative m] [is_lawful_applicative m]\n\ntheorem mmap_with_index'_aux_eq_mmap_with_index_aux {α} (f : ℕ → α → m punit)\n  (start : ℕ) (as : list α) :\n  mmap_with_index'_aux f start as =\n  mmap_with_index_aux f start as *> pure punit.star :=\nby induction as generalizing start;\n    simp [mmap_with_index'_aux, mmap_with_index_aux, *, seq_right_eq, const, -comp_const]\n      with functor_norm\n\ntheorem mmap_with_index'_eq_mmap_with_index {α} (f : ℕ → α → m punit) (as : list α) :\n  mmap_with_index' f as = mmap_with_index f as *> pure punit.star :=\nby apply mmap_with_index'_aux_eq_mmap_with_index_aux\n\nend mmap_with_index'\n\nend list\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/list/indexes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.7154239957834732, "lm_q1q2_score": 0.4583262631117209}}
{"text": "import system_of_complexes.basic\n\n\n/-!\n# The normed snake dual lemma: weak and non-weak\n\nThis file proves the weak normed snake dual lemma and the normed snake dual lemma: they are the\nstatements `weak_normed_snake_dual` and `normed_snake_dual`, respectively.\n\nThe principal definitions of the concepts in this file appear in Section 4 of the blueprint.\n\nThe two main results prove `is_(weak_)bounded_exact` for certain `system_of_complexes`. The\nLean-definitions of these concepts appears in `system_of_complexes.basic`.\n\nIntuitively, the two predicates assert a version of exactness for a complex whose overall shape is\nan inequality of the form\n```lean\n∥res ? - (M.d ??) ?∥ ≤ const * ∥(M.d ?? ?∥ + ε.\n```\n(Recall that `res` is a restriction among certain complexes, `M.d` stands for a differential,\n`const` is a constant; the error `ε` is a non-negative real number.  For the weak version, we\nquantify over all `0 < ε ∈ ℝ`.  For the non-weak version, we use `ε = 0`.)\n\nMore in detail, at the heart of the computation, is a proof of an inequality of the form\n```lean\n∥res m - (M.d (i - 1) i) y∥ ≤ K * (1 + K' * r₁ * r₂) * ∥(M.d i (i + 1)) m∥ + ε.\n```\nIn the weak normed snake dual lemma, for any choice of positive `0 < ε`, we should be able to fix\nthe parameters so that the inequality above is satisfied.  In the normed snake dual lemma, we want\nthe inequality above with `ε = 0`.  As you will see, the bulk of the proof of the normed snake dual\nlemma recycles the proof of the weak version.\n\nThe proof involves several estimations: we broke these proofs into smaller partial inequalities,\nfor three reasons.  First, it streamlines the formalization.  Second, it helps Lean processing the\nstatements, reducing processing times.  Third, it allows us to us a large part of the argument for\nboth `weak_normed_snake_dual` and `normed_snake_dual`.\n\n# Remark\n\nWhile following the proof, keep an eye out for how the factor `ρ = 1 + K' * r₁ * r₂` forms itself.\nOnce the factor `ρ` is formed, we can almost treat it as a new strictly positive variable.\n-/\n\nuniverse variables u\n\nnoncomputable theory\nopen_locale nnreal\nopen category_theory opposite normed_add_group_hom system_of_complexes\n\nvariables {M N P : system_of_complexes.{u}} {f : M ⟶ N} {g : N ⟶ P}\n\n/-  I (DT) extracted this lemma to speed up the proof of `weak_normed_snake_dual`. -/\nlemma ε₁_le_ε {ε ε₁ : ℝ} (hε : 0 ≤ ε) (mK : ℝ≥0) (hε₁ : ε₁ = ε / 2 * (1 + mK)⁻¹) :\n  ε₁ ≤ ε :=\nby { rw [hε₁, div_eq_mul_inv, mul_assoc, ← mul_inv],\n     exact mul_le_of_le_one_right hε (inv_le_one $ nnreal.coe_le_coe.mpr $\n      one_le_mul one_le_two $ le_add_of_nonneg_right mK.2) }\n\n/-!\nFirst, we break off the main term `∥res m - (M.d i' i) m₁∥` into a sum of two expressions:\n\n* `∥(res (f m) : N c i) - N.d i' i (res n₁)∥`, and\n* `∥(N.d i' i ((N.d i'' i') n₂ + nnew₁) : N c i)∥`.\n-/\nlemma norm_sub_le_split {k' c c₁ : ℝ≥0} {i i' i'' : ℕ}\n  [hk' : fact (1 ≤ k')] [fc : fact (c ≤ c₁)]\n  (hfnorm : ∀ (c : ℝ≥0) (i : ℕ) (x : (M c i)), ∥(f.apply) x∥ = ∥x∥)\n  {n₁ : N (k' * c) i'} {n₂ : N c i''} {nnew₁ : N c i'} {m₁ : M c i'} {m : (M c₁ i)}\n  (hm₁ : f m₁ = res n₁ - ((N.d i'' i') n₂) - nnew₁) :\n  ∥res m - (M.d i' i) m₁∥ ≤\n    ∥(res (f m) : N c i) - N.d i' i (res n₁)∥ + ∥(N.d i' i ((N.d i'' i') n₂ + nnew₁) : N c i)∥ :=\ncalc ∥res m - (M.d i' i) m₁∥\n      = ∥f (res m - (M.d i' i) m₁)∥ : (hfnorm _ _ _).symm\n  ... = ∥res (f m) - (N.d i' i (res n₁) - N.d i' i ((N.d i'' i') n₂ + nnew₁))∥ :\n    by rw [hom_apply, _root_.map_sub, ←hom_apply, ←hom_apply, ←res_apply,\n      ←d_apply, hm₁, sub_sub, _root_.map_sub]\n  ... = ∥(res (f m) - N.d i' i (res n₁)) + N.d i' i ((N.d i'' i') n₂ + nnew₁)∥ :\n    by rw [sub_eq_add_neg, neg_sub, sub_eq_neg_add, ← add_assoc, ← sub_eq_add_neg]\n  ... ≤ ∥res (f m) - N.d i' i (res n₁)∥ + ∥N.d i' i ((N.d i'' i') n₂ + nnew₁)∥ : norm_add_le _ _\n\n/-!\nWe then massage the left-hand side.  The proof of this lemma is deceptively simple, since\nthere is a lot of typeclass work happening in the background.  In particular, the `c` in the sea of\nunderscores of the second line is crucial for the *previous* line to compile.\n\n(The hypothesis `(hN_adm : N.admissible)` is only used via `(hN_adm.res_norm_noninc _ c _ _ _)`,\nproducing the inequality\n`(dis : ∥(res (res (f m) - (N.d i' i) n₁) : N c i)∥ ≤ ∥res (f m) - (N.d i' i) n₁∥)`.)\n-/\nlemma norm_sub_le_mul_norm_add_lhs {k' K c c₁ : ℝ≥0} {ε₁ : ℝ} {i i' : ℕ}\n  [hk' : fact (1 ≤ k')] [fc₁ : fact (k' * c ≤ c₁)] [fc : fact (c ≤ c₁)]\n  {n₁ : N (k' * c) i'} {m : (M c₁ i)}\n  (hN_adm : N.admissible)\n  (hn₁ : ∥res (f m) - (N.d i' i) n₁∥ ≤ K * ∥(N.d i (i + 1)) (f m)∥ + ε₁) :\n  ∥(res (f m) : N c i) - N.d i' i (res n₁)∥ ≤ K * ∥(N.d i (i + 1)) (f m)∥ + ε₁ :=\ncalc ∥(res (f m) : N c i) - N.d i' i (res n₁)∥\n      = ∥res (res (f m) - (N.d i' i) n₁)∥ : by rw [_root_.map_sub, d_res, ← res_res]\n  ... ≤ K * ∥(N.d i (i + 1)) (f m)∥ + ε₁  : trans (hN_adm.res_norm_noninc _ c _ _ _) hn₁\n\n/-!\nAnd we also massage the right-hand side.  Here, the factor `K' * r₁ * r₂` appears.\n\n(The hypothesis `(hN_adm : N.admissible)` is only used via `(hN_adm.d_norm_noninc _ _ i' i nnew₁)`,\nproducing the inequality `(dis : ∥(N.d i' i) nnew₁∥ ≤ ∥nnew₁∥)`.)\n-/\nlemma norm_sub_le_mul_norm_add_rhs {k' K K' r₁ r₂ c c₁ : ℝ≥0} {ε₁ ε₂ : ℝ}\n  {i i' i'' : ℕ} (hii' : i' + 1 = i)\n  [hk' : fact (1 ≤ k')] [fc₁ : fact (k' * c ≤ c₁)]\n  (hgnorm : ∀ (c : ℝ≥0) (i : ℕ) (x : (N c i)), ∥g x∥ ≤ ↑r₁ * ∥x∥)\n  {n₁ : N (k' * c) i'} {n₂ : N c i''} {nnew₁ : N c i'} {m : (M c₁ i)}\n  (hN_adm : N.admissible)\n  (hn₁ : ∥res (f m) - (N.d i' i) n₁∥ ≤ K * ∥(N.d i (i + 1)) (f m)∥ + ε₁)\n  (hp₂ : ∥res (g n₁) - (P.d i'' i') (g n₂)∥ ≤ K' * ∥(P.d i' (i' + 1)) (g n₁)∥ + ε₂)\n  (hnormnnew₁ : ∥nnew₁∥ ≤ r₂ * ∥g (res n₁ - ((N.d i'' i') n₂))∥)\n  (hfm : ∥g ((N.d i' i) n₁)∥ = ∥g (res (f m) - (N.d i' i) n₁)∥) :\n  ∥(N.d i' i ((N.d i'' i') n₂ + nnew₁) : N c i)∥ ≤\n    K * K' * r₁ * r₂ * ∥(N.d i (i+1)) (f m)∥ + K' * r₁ * r₂ * ε₁ + r₂ * ε₂ :=\ncalc ∥(N.d i' i ((N.d i'' i') n₂ + nnew₁) : N c i)∥\n      = ∥N.d i' i nnew₁∥ : by simp only [map_add, zero_add, d_d]\n  ... ≤ r₂ * ∥g (res n₁ - (N.d i'' i') n₂)∥ : trans (hN_adm.d_norm_noninc _ _ i' i nnew₁) hnormnnew₁\n  ... = r₂ * ∥res (g n₁) - P.d i'' i' (g n₂)∥ :\n    by rw [hom_apply, _root_.map_sub, ←hom_apply, ←hom_apply, ←res_apply _ _ g, ←d_apply]\n  ... ≤ r₂ * (K' * ∥P.d i' (i'+1) (g n₁)∥ + ε₂) : mul_le_mul_of_nonneg_left hp₂ r₂.coe_nonneg\n  ... = r₂ * (K' * ∥g (res (f m) - N.d i' i n₁)∥ + ε₂) : by rw [d_apply _ _ g _, hii', hfm]\n  ... ≤ r₂ * (K' * (r₁ * ∥res (f m) - N.d i' i n₁∥) + ε₂) :\n    mul_le_mul_of_nonneg_left (add_le_add_right (mul_le_mul_of_nonneg_left\n      (hgnorm _ _ _) K'.coe_nonneg) _) $ r₂.coe_nonneg\n  ... = r₂ * (K' * r₁ * ∥res (f m) - N.d i' i n₁∥ + ε₂) : by rw mul_assoc\n  ... ≤ r₂ * (K' * r₁ * (K * ∥(N.d i (i+1)) (f m)∥ + ε₁) + ε₂) :\n    mul_le_mul_of_nonneg_left (add_le_add_right (mul_le_mul_of_nonneg_left\n      hn₁ $ mul_nonneg K'.coe_nonneg r₁.coe_nonneg) _) r₂.coe_nonneg\n  ... = _ : by ring\n\n/-!\nWe collect the inequalities obtained so far:\n\n* use `norm_sub_le_split` to split the norm into a sum of two terme;\n* apply `norm_sub_le_mul_norm_add_lhs` to the left-hand-side;\n* apply `norm_sub_le_mul_norm_add_rhs` to the right-hand-side.\n\nThe rest is simple manipulations of real numbers.\n-/\nlemma norm_sub_le_mul_norm_add {k' K K' r₁ r₂ c c₁ : ℝ≥0} {ε ε₁ ε₂ : ℝ}\n  {i i' i'' : ℕ} (hii' : i' + 1 = i)\n  [hk' : fact (1 ≤ k')] [fc₁ : fact (k' * c ≤ c₁)] [fc : fact (c ≤ c₁)]\n  (hN_adm : N.admissible)\n  (hgnorm : ∀ (c : ℝ≥0) (i : ℕ) (x : (N c i)), ∥g x∥ ≤ ↑r₁ * ∥x∥)\n  (hfnorm : ∀ (c : ℝ≥0) (i : ℕ) (x : (M c i)), ∥(f.apply) x∥ = ∥x∥)\n  {n₁ : N (k' * c) i'} {n₂ : N c i''} {nnew₁ : N c i'} {m₁ : M c i'} {m : (M c₁ i)}\n  (hmulε₁ : ε₁ * (1 + K' * r₁ * r₂) = ε / 2)\n  (hle : (r₂ : ℝ) * ε₂ ≤ ε / 2)\n  (hn₁ : ∥res (f m) - (N.d i' i) n₁∥ ≤ K * ∥(N.d i (i + 1)) (f m)∥ + ε₁)\n  (hp₂ : ∥res (g n₁) - (P.d i'' i') (g n₂)∥ ≤ K' * ∥(P.d i' (i' + 1)) (g n₁)∥ + ε₂)\n  (hnormnnew₁ : ∥nnew₁∥ ≤ r₂ * ∥g (res n₁ - ((N.d i'' i') n₂))∥)\n  (hm₁ : f m₁ = res n₁ - ((N.d i'' i') n₂) - nnew₁)\n  (hfm : ∥g ((N.d i' i) n₁)∥ = ∥g (res (f m) - (N.d i' i) n₁)∥) :\n  ∥res m - (M.d i' i) m₁∥ ≤ (K + r₁ * r₂ * K * K') * ∥(M.d i (i + 1)) m∥ + ε :=\ncalc\n∥res m - (M.d i' i) m₁∥ ≤ ∥res (f m) - N.d i' i (res n₁)∥ + ∥N.d i' i ((N.d i'' i') n₂ + nnew₁)∥ :\n    norm_sub_le_split hfnorm hm₁\n  ... ≤ (K * ∥(N.d i (i + 1)) (f m)∥ + ε₁) +\n        (K * K' * r₁ * r₂ * ∥(N.d i (i+1)) (f m)∥ + K' * r₁ * r₂ * ε₁ + r₂ * ε₂) : add_le_add\n      (norm_sub_le_mul_norm_add_lhs hN_adm hn₁)\n      (norm_sub_le_mul_norm_add_rhs hii' hgnorm hN_adm hn₁ hp₂ hnormnnew₁ hfm)\n  ... = (K + r₁ * r₂ * K * K') * ∥N.d i (i+1) (f m)∥ + ε₁ * (1 + K' * r₁ * r₂) + r₂ * ε₂ : by ring\n  ... = (K + r₁ * r₂ * K * K') * ∥N.d i (i+1) (f m)∥ + ε / 2 + r₂ * ε₂ :\n    congr_arg (λ e, (↑K + ↑r₁ * ↑r₂ * ↑K * ↑K') * ∥(N.d i (i + 1)) (f m)∥ + e + ↑r₂ * ε₂) hmulε₁\n  ... ≤ (K + r₁ * r₂ * K * K') * ∥N.d i (i+1) (f m)∥ + ε / 2 + ε / 2 : add_le_add_left hle _\n  ... = (K + r₁ * r₂ * K * K') * ∥(M.d i (i+1)) m∥ + ε :\n    by rw [add_assoc, add_halves', d_apply, hom_apply, hfnorm]\n\n/-!\nWe shall apply this lemma with `ρ = K + r₁ * r₂ * K * K' = K * (1 + K' * r₁ * r₂)`.\n-/\nlemma exists_norm_sub_le_mul_add {k k' c ρ : ℝ≥0}\n  {i : ℕ}\n  [hk : fact (1 ≤ k)] [hk' : fact (1 ≤ k')]\n  (hM_adm : M.admissible)\n  (ex_le : (∀ (m : (M (k * (k' * c)) i)) (ε : ℝ), 0 < ε →\n        (∃ (i₀ : ℕ) (hi₀ : i₀ = i - 1) (y : (M c i₀)),\n           ∥res m - (M.d i₀ i) y∥ ≤ ↑ρ * ∥(M.d i (i + 1)) m∥ + ε)))\n  {m₁ : (M (k * k' * c) i)}\n  {ε : ℝ} (hε : 0 < ε) :\n  ∃ (i₀ j : ℕ) (hi₀ : i₀ = i - 1) (hj : i + 1 = j) (y : (M c i₀)),\n      ∥res m₁ - (M.d i₀ i) y∥ ≤ ↑ρ * ∥(M.d i j) m₁∥ + ε :=\nbegin\n  haveI : fact (k * (k' * c) ≤ k * k' * c) := { out := (mul_assoc _ _ _).symm.le },\n  rcases ex_le (res m₁) ε hε with ⟨i₀, rfl, y, hy⟩,\n  rw [res_res, d_res] at hy,\n  refine ⟨i - 1, _, rfl, rfl, _⟩,\n  refine ⟨y, hy.trans (add_le_add_right (mul_le_mul_of_nonneg_left _ ρ.2) ε)⟩,\n  exact hM_adm.res_norm_noninc _ _ _ _ _,\nend\n\n/-!\nThis argument proves the main inequality in the case where the indices are `0` or `1`.\n-/\nlemma norm_sub_le_mul_mul_norm_add {M N : system_of_complexes} {f : M ⟶ N}\n  {k k' K c : ℝ≥0} (mK : ℝ≥0) {ε ε₁ : ℝ} {m : M (k * (k' * c)) 0} {n₁ : N (k' * c) 0} {m₁ : M c 0}\n  (ee1 : ε₁ ≤ ε)\n  [hk : fact (1 ≤ k)] [hk' : fact (1 ≤ k')]\n  (hfnorm : ∀ (c : ℝ≥0) (i : ℕ) (x : (M c i)), ∥(f.apply) x∥ = ∥x∥)\n  (inadm : ∥((res (res m : (M (k' * c) 0))) : (M c 0))∥ ≤ ∥(res m : (M (k' * c) 0))∥ )\n  (hn₁ : ∥res (f m) - (N.d 0 0) n₁∥ ≤ ↑K * ∥(N.d 0 (0 + 1)) (f m)∥ + ε₁) :\n  ∥res m - (M.d 0 0) m₁∥ ≤ (K * (1 + mK)) * ∥(M.d 0 (0 + 1)) m∥ + ε :=\nbegin\n  simp only [d_self_apply, sub_zero, nnreal.coe_add, nnreal.coe_mul] at hn₁ ⊢,\n  rw [res_apply, hom_apply f (res m), hfnorm] at hn₁,\n  have new : fact (c ≤ k' * c) := { out := le_mul_of_one_le_left c.2 hk'.out },\n  rw ←res_res _ _ _ new,\n  refine le_trans inadm (le_trans hn₁ _),\n  rw [d_apply, hom_apply f _, hfnorm],\n  refine add_le_add _ ee1,\n  rw mul_assoc,\n  refine (mul_le_mul_of_nonneg_left _ K.2),\n  exact le_mul_of_one_le_left (norm_nonneg _) (le_add_of_nonneg_right mK.2),\nend\n\n/-!\nNote that `ε = 0` is allowed.  Indeed, the weak normed snake dual lemma uses `0 ≤ ε`, while the\nnormed snake dual lemma uses `ε = 0`.\n-/\nlemma exist_norm_sub_le_mul_norm_add {k k' K K' r₁ r₂ c₀ c : ℝ≥0}\n  {a i : ℕ} {ε : ℝ} (hε : 0 ≤ ε)\n  [hk : fact (1 ≤ k)] [hk' : fact (1 ≤ k')]\n  (hN_adm : N.admissible)\n  (hgnrm : ∀ (c : ℝ≥0) (i : ℕ) (x : (N c i)), ∥g x∥ ≤ r₁ * ∥x∥)\n  (Hg : ∀ (c : ℝ≥0) [_inst_1 : fact (c₀ ≤ c)] (i : ℕ),\n          i ≤ a + 1 + 1 → ∀ (y : (P c i)), ∃ (x : (N c i)), g x = y ∧ ∥x∥ ≤ r₂ * ∥y∥)\n  (hg : ∀ (c : ℝ≥0) (i : ℕ), (range f.apply : add_subgroup (N c i)) = ker g.apply)\n  (hf : ∀ (c : ℝ≥0) (i : ℕ), (isometry (f.apply : M c i ⟶ N c i) : _))\n  (hc : fact (c₀ ≤ c))\n  (hi : i ≤ a)\n  {m : M (k * (k' * c)) i} {n₁ : N (k' * c) (i - 1)}\n  (hn₁ : ∥res (f m) - (N.d (i - 1) i) n₁∥ ≤\n    K * ∥(N.d i (i + 1)) (f m)∥ + ε / 2 * (1 + K' * r₁ * r₂)⁻¹)\n  (Hi' : i - 1 ≤ a + 1)\n  (p₂ : P c (i - 1 - 1)) (hp₂ : ∥res (g n₁) - (P.d (i - 1 - 1) (i - 1)) p₂∥ ≤\n    K' * ∥(P.d (i - 1) (i - 1 + 1)) (g n₁)∥ + ite (r₂ = 0) 1 (ε / 2 * (r₂)⁻¹)) :\n  ∃ (i₀ : ℕ) (hi₀ : i₀ = i - 1) (y : (M c i₀)),\n    ∥res m - (M.d i₀ i) y∥ ≤ (K + r₁ * r₂ * K * K') * ∥(M.d i (i + 1)) m∥ + ε :=\nbegin\n  obtain ⟨n₂, rfl, hnormn₂⟩ :=\n    Hg c (i - 1 - 1) (trans (nat.pred_le _) (trans Hi' (nat.le_succ _))) p₂,\n  let n₁' := N.d (i - 1 - 1) (i - 1) n₂,\n  obtain ⟨nnew₁, hnnew₁, hnrmnew₁⟩ := Hg c (i - 1) (trans Hi' a.succ.le_succ) (g (res n₁ - n₁')),\n  have hker : (res n₁ - n₁') - nnew₁ ∈ g.apply.ker,\n  { rw [mem_ker, _root_.map_sub, sub_eq_zero, ←hom_apply, ←hom_apply, hnnew₁] },\n  rw ←hg at hker,\n  obtain ⟨m₁, hm₁ : f m₁ = res n₁ - n₁' - nnew₁⟩ := (mem_range _ _).1 hker,\n  refine ⟨i - 1, rfl, m₁, _⟩,\n  have hfnrm : ∀ c i (x : M c i), ∥f.apply x∥ = ∥x∥ := λ c i x, (add_monoid_hom_class.isometry_iff_norm _).1 (hf c i) x,\n  by_cases hizero : i = 0,\n  { subst hizero,\n    convert norm_sub_le_mul_mul_norm_add (K' * r₁ * r₂) _ hfnrm _ hn₁,\n    { norm_cast, ring },\n    { exact ε₁_le_ε hε (K' * r₁ * r₂) rfl },\n    { exact (admissible_of_isometry hN_adm hf).res_norm_noninc _ _ _ _ _ } },\n  { refine norm_sub_le_mul_norm_add _ hN_adm hgnrm hfnrm _ _ hn₁ hp₂ hnrmnew₁ hm₁ _,\n    { exact nat.succ_pred_eq_of_pos (nat.pos_of_ne_zero hizero) },\n    { rw inv_mul_cancel_right₀,\n      exact ne_of_gt (add_pos_of_pos_of_nonneg zero_lt_one (zero_le (K' * r₁ * r₂))) },\n    { by_cases H : r₂ = 0,\n      { simp only [H, nnreal.coe_zero, if_true, zero_mul, (div_nonneg hε zero_le_two)] },\n      { simp only [H, nnreal.coe_eq_zero, if_false, mul_comm,\n          mul_inv_cancel_left₀ (nnreal.coe_ne_zero.mpr H)] } },\n    { have : f (res m : M (k' * c) i) ∈ f.apply.range, { rw mem_range, exact ⟨res m, rfl⟩ },\n      rw [hg, mem_ker] at this,\n      rw [hom_apply g (res (f m) - (N.d (i - 1) i) n₁), res_apply, _root_.map_sub, this,\n        zero_sub, norm_neg, ←hom_apply] } }\nend\n\n/-!\nWe apply this lemma with `ρ = K + r₁ * r₂ * K * K'`.\n-/\nlemma exists_norm_sub_le_mul {M : system_of_complexes} {k k' c ρ : ℝ≥0}\n  {i : ℕ}\n  [hk : fact (1 ≤ k)] [hk' : fact (1 ≤ k')]\n  (hM_adm : M.admissible)\n  (ex_le : (∀ (m : (M (k * (k' * c)) i)),\n        (∃ (i₀ : ℕ) (hi₀ : i₀ = i - 1) (y : (M c i₀)),\n           ∥res m - (M.d i₀ i) y∥ ≤ ↑ρ * ∥(M.d i (i + 1)) m∥)))\n  (m₁ : (M (k * k' * c) i)) :\n  ∃ (i₀ j : ℕ) (hi₀ : i₀ = i - 1) (hj : i + 1 = j) (y : (M c i₀)),\n      ∥res m₁ - (M.d i₀ i) y∥ ≤ ↑ρ * ∥(M.d i j) m₁∥ :=\nbegin\n  haveI : fact (k * (k' * c) ≤ k * k' * c) := { out := (mul_assoc _ _ _).symm.le },\n  rcases ex_le (res m₁) with ⟨i₀, rfl, y, hy⟩,\n  rw [res_res, d_res] at hy,\n  refine ⟨i - 1, _, rfl, rfl, _⟩,\n  refine ⟨y, hy.trans (mul_le_mul_of_nonneg_left _ ρ.2)⟩,\n  exact hM_adm.res_norm_noninc _ _ _ _ _,\nend\n\nvariables (M N P f g)\n\n/-!\nFinally, we state and prove the weak normed snake dual lemma.\n-/\nlemma weak_normed_snake_dual (k k' K K' r₁ r₂ : ℝ≥0)\n  [hk : fact (1 ≤ k)] [hk' : fact (1 ≤ k')]\n  {a : ℕ} {c₀ : ℝ≥0}\n  (hN : N.is_weak_bounded_exact k K (a + 1) c₀)\n  (hP : P.is_weak_bounded_exact k' K' (a + 1) c₀)\n  (hN_adm : N.admissible)\n  (hgnrm : ∀ c i (x : N c i), ∥g x∥ ≤ r₁ * ∥x∥)\n  (Hg : ∀ (c : ℝ≥0) [fact (c₀ ≤ c)] (i : ℕ) (hi : i ≤ a + 1 + 1) (y : P c i),\n    ∃ (x : N c i), g x = y ∧ ∥x∥ ≤ r₂ * ∥y∥)\n  (hg : ∀ c i, (f.apply : M c i ⟶ N c i).range = g.apply.ker)\n  (hf : ∀ c i, @isometry (M c i) (N c i) _ _ f.apply) :\n  M.is_weak_bounded_exact (k * k') (K + r₁ * r₂ * K * K') a c₀ :=\nbegin\n  introsI c hc i hi,\n  apply exists_norm_sub_le_mul_add (admissible_of_isometry hN_adm hf),\n  intros m ε hε,\n\n  have hε₁ : 0 < ε / 2 * (1 + K' * r₁ * r₂)⁻¹ := mul_pos (half_pos hε)\n    (inv_pos.2 $ add_pos_of_pos_of_nonneg zero_lt_one ((K' * r₁ * r₂).coe_nonneg)),\n  obtain ⟨_, _, rfl, rfl, n₁, hn₁⟩ :=\n    hN _ ⟨hc.out.trans $ le_mul_of_one_le_left' hk'.out⟩ _ (trans hi a.le_succ) (f m) _ hε₁,\n  have Hi' : i - 1 ≤ a + 1 := trans i.pred_le (trans hi a.le_succ),\n  obtain ⟨_, _, rfl, rfl, p₂, hp₂⟩ := hP _ hc _ Hi' (g n₁)\n    (if (r₂ : ℝ) = 0 then 1 else (ε / 2) * r₂⁻¹) _,\n  { simp_rw [nnreal.coe_eq_zero r₂] at hp₂,\n    apply exist_norm_sub_le_mul_norm_add hε.le hN_adm hgnrm Hg hg hf hc hi hn₁ Hi' p₂,\n    convert hp₂, },\n  { by_cases H : r₂ = 0,\n    { simp only [H, zero_lt_one, if_true, eq_self_iff_true, nnreal.coe_eq_zero] },\n    { simp only [H, nnreal.coe_eq_zero, if_false],\n      exact mul_pos (half_pos hε) (inv_pos.2 (nnreal.coe_pos.2 (zero_lt_iff.2 H))) } }\nend\n\n/-!\nAnd also the normed snake dual lemma.\n-/\nlemma normed_snake_dual {k k' K K' r₁ r₂ : ℝ≥0}\n  [hk : fact (1 ≤ k)] [hk' : fact (1 ≤ k')]\n  {a : ℕ} {c₀ : ℝ≥0}\n  (hN : N.is_bounded_exact k K (a + 1) c₀)\n  (hP : P.is_bounded_exact k' K' (a + 1) c₀)\n  (hN_adm : N.admissible)\n  (hgnorm : ∀ c i (x : N c i), ∥g x∥ ≤ r₁ * ∥x∥)\n  (Hg : ∀ (c : ℝ≥0) [fact (c₀ ≤ c)] (i : ℕ) (hi : i ≤ a + 1 + 1) (y : P c i),\n    ∃ (x : N c i), g x = y ∧ ∥x∥ ≤ r₂ * ∥y∥)\n  (hg : ∀ c i, (f.apply : M c i ⟶ N c i).range = g.apply.ker)\n  (hf : ∀ c i, @isometry (M c i) (N c i) _ _ f.apply) :\n  M.is_bounded_exact (k * k') (K + r₁ * r₂ * K * K') a c₀ :=\nbegin\n  introsI c hc i hi,\n  refine exists_norm_sub_le_mul (admissible_of_isometry hN_adm hf) _,\n  intro m,\n\n  obtain ⟨_, _, rfl, rfl, n₁, hn₁⟩ :=\n    hN _ ⟨hc.out.trans $ le_mul_of_one_le_left' hk'.out⟩ _ (trans hi a.le_succ) (f m),\n  have Hi' : (i - 1) ≤ a + 1 := trans i.pred_le (trans hi a.le_succ),\n  obtain ⟨_, _, rfl, rfl, p₂, hp₂⟩ := hP _ hc _ Hi' (g n₁),\n  rw ← add_zero (_ * ∥_∥) at ⊢,\n  have hn₁₁ :  ∥res (f m) - (N.d (i - 1) i) n₁∥ ≤\n    K * ∥(N.d i (i + 1)) (f m)∥ + 0 / 2 * (1 + K' * r₁ * r₂)⁻¹, rwa [zero_div, zero_mul, add_zero],\n  obtain F := exist_norm_sub_le_mul_norm_add rfl.le hN_adm hgnorm Hg hg hf hc hi hn₁₁ Hi' p₂,\n  by_cases hr : r₂ = 0,\n  { subst hr,\n    simp at ⊢ F,\n    exact F (trans hp₂ (le_add_of_nonneg_right zero_le_one)) },\n  { exact F (by { convert hp₂, simp [hr] } ) }\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/normed_snake_dual.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.45832625533756716}}
{"text": "import operations\nimport params\n\nimport category_theory.category.basic\n\nopen operations\nopen params\n\nopen category_theory\n\nnamespace operations_examples\n\nvariable [category (bitvec word_len)]\n\n/-!\n  # Formalized examples from the spec\n\n  https://cr.yp.to/snuffle/spec.pdf\n\n  Notes:\n\n  - Examples are formalized as `lemma`s instead of `example`\n  so they show up in the documentation.\n-/\n\n/-- 0xc0a8787e ⊕ 0x9fd1161d = 0x5f796e63 -/\nlemma example_xor : bitvec.xor (bitvec.of_nat word_len 0xc0a8787e)\n  (bitvec.of_nat word_len 0x9fd1161d) = 0x5f796e63 :=\nbegin\n  rw [word_len, bitvec.of_nat],\n  norm_num1,\n  refl,\nend\n\n/-- 0xc0a8787e + 0x9fd1161d = 0x60798e9b -/\nlemma example_mod : 0xc0a8787e MOD 0x9fd1161d = 0x60798e9b :=\nbegin\n  rw [operations.mod, params.max_bitvec, params.mod, word_len],\n  dunfold bitvec.of_nat,\n  norm_num1,\n  refl,\nend\n\n/-- 0xc0a8787e <<< 5 = 0x150f0fd8 -/\nlemma example_rotl : (rotl (bitvec.of_nat word_len 0xc0a8787e) 5) = 0x150f0fd8 :=\nbegin\n  rw [rotl, bitvec.shl, bitvec.ushr, bitvec.fill_shr, word_len],\n  dunfold bitvec.of_nat,\n  norm_num1,\n  refl,\nend\n\n/-! # Inverse examples -/\n\n/-- 0x5f796e63 ⊕ 0x9fd1161d = 0xc0a8787e -/\nlemma example_inverse_xor : bitvec.xor (bitvec.of_nat word_len 0x5f796e63)\n  (bitvec.of_nat word_len 0x9fd1161d) = 0xc0a8787e :=\nbegin\n  rw word_len,\n  dunfold bitvec.of_nat,\n  norm_num1,\n  refl,\nend\n\n/-- 0x150f0fd8 <<<⁻¹ 5 = 0xc0a8787e -/\nlemma example_rotl_inv : rotl_inv (bitvec.of_nat word_len 0x150f0fd8) 5 =\n  0xc0a8787e :=\nbegin\n  rw [rotl_inv, bitvec.shl, bitvec.ushr, bitvec.fill_shr, word_len],\n  dunfold bitvec.of_nat,\n  norm_num1,\n  refl,\nend\n\nend operations_examples\n", "meta": {"author": "oxarbitrage", "repo": "salsa20", "sha": "12d0ebb3c27801931e61d470fb2ed548a5562578", "save_path": "github-repos/lean/oxarbitrage-salsa20", "path": "github-repos/lean/oxarbitrage-salsa20/salsa20-12d0ebb3c27801931e61d470fb2ed548a5562578/src/examples/operations.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484143, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.4583262455203231}}
{"text": "import topology.category.Profinite\nimport category_theory.filtered\n\nimport locally_constant.analysis\nimport analysis.normed.group.SemiNormedGroup.kernels\n\n/-!\n\n# The functor of locally constant maps\n\nThe functor sending a seminormed group `V` and a profinite type `S` to the seminormed group\nof locally constant maps from `S` to `V` (with the sup norm).\n\n## Main definition\n\n- `LocallyConstant : SemiNormedGroup ⥤ Profiniteᵒᵖ ⥤ SemiNormedGroup` : the functor.\n\n-/\n\nnoncomputable theory\n\nset_option pp.proofs true\n\nnamespace SemiNormedGroup\nopen opposite locally_constant\n\nlocal attribute [instance] locally_constant.seminormed_add_comm_group locally_constant.pseudo_metric_space\n\n/-- The bifunctor of locally constant maps from profinite spaces to seminormed groups.\n    The effects on homs of groups or space are defined in terms of push-forward\n    (ie. post-composition) and pull-back (ie. pre-composition) of locally constant maps\n    respectively. -/\n@[simps]\ndef LocallyConstant : SemiNormedGroup ⥤ Profiniteᵒᵖ ⥤ SemiNormedGroup :=\n{ obj := λ V,\n  { obj := λ S, SemiNormedGroup.of $ locally_constant (unop S : Profinite) V,\n    map := λ S₁ S₂ f, comap_hom (f.unop) (f.unop.continuous),\n    map_id' := λ S, comap_hom_id,\n    map_comp' := λ S₁ S₂ S₃ f g, (comap_hom_comp _ _ _ _).symm },\n  map := λ V W f,\n  { app := λ S, map_hom f,\n    naturality' := λ S₁ S₂ g,\n    begin\n      dsimp, ext,\n      simp only [map_hom_apply, comap_hom_apply, category_theory.coe_comp,\n        function.comp_app, map_apply, coe_comap, g.unop.continuous]\n    end } ,\n  map_id' := by { intros, ext, refl },\n  map_comp' := by { intros, ext, refl } }\n\n@[simp]\nlemma LocallyConstant_map_apply (M : SemiNormedGroup) (X Y : Profinite) (f : X ⟶ Y)\n  (g : (LocallyConstant.obj M).obj (op Y)) (x : X) :\n  ((LocallyConstant.obj M).map f.op g).to_fun x = g.to_fun (f x) :=\nbegin\n  dsimp [LocallyConstant, comap],\n  split_ifs,\n  { refl },\n  all_goals { exfalso, apply h, continuity }\nend\n\nlemma LocallyConstant_obj_map_norm_noninc (V : SemiNormedGroup) (X Y : Profiniteᵒᵖ) (φ : X ⟶ Y) :\n  ((LocallyConstant.obj V).map φ).norm_noninc :=\ncomap_hom_norm_noninc _ _\n\nopen category_theory\n\nuniverse u\n\n-- TODO: Fix the statement below using bounded colimits.\n--@[nolint unused_arguments]\n--instance {M : SemiNormedGroup.{u}} {J : Type u} [small_category J] [is_filtered J] :\n--  limits.preserves_colimits_of_shape J (LocallyConstant.obj M) := by admit\n\nend SemiNormedGroup\n\n#lint- only unused_arguments def_lemma doc_blame\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/locally_constant/SemiNormedGroup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4582340673694571}}
{"text": "import for_mathlib.exact_seq\nimport for_mathlib.abelian_category\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nuniverses v u\n\nvariables {𝒜 : Type u} [category.{v} 𝒜] [abelian 𝒜]\nvariables {A B C : 𝒜} {f : A ⟶ B} {g : B ⟶ C}\n\nnamespace category_theory\n\nnamespace exact_seq\n\nlemma drop : ∀ {L : list (arrow 𝒜)} (h : exact_seq 𝒜 L) (n : ℕ),\n  exact_seq 𝒜 (L.drop n)\n| _ nil               0     := nil\n| _ nil               (n+1) := nil\n| _ (single f)        0     := single f\n| _ (single f)        (n+1) := drop nil n\n| _ (cons f g h L hL) 0     := cons f g h L hL\n| _ (cons f g h L hL) (n+1) := hL.drop n\n\nlemma pair : ∀ {L : list (arrow 𝒜)} (h : exact_seq 𝒜 (f :: g :: L)),\n  exact f g\n| L (cons _ _ h _ _) := h\n\nend exact_seq\n\nnamespace exact\n\nlemma mono_of_eq_zero (h : exact f g) (hf : f = 0) : mono g :=\nby rwa [(abelian.tfae_mono A g).out 0 2, ← hf]\n\nlemma eq_zero_of_mono (h : exact f g) (hg : mono g) : f = 0 :=\nby rw [← cancel_mono g, h.w, zero_comp]\n\nlemma mono_iff_eq_zero (h : exact f g) : mono g ↔ f = 0 :=\n⟨h.eq_zero_of_mono, h.mono_of_eq_zero⟩\n\nlemma epi_of_eq_zero (h : exact f g) (hg : g = 0) : category_theory.epi f :=\nby rwa [(abelian.tfae_epi C f).out 0 2, ← hg]\n\nlemma eq_zero_of_epi (h : exact f g) (hf : category_theory.epi f) : g = 0 :=\nby rw [← cancel_epi f, h.w, comp_zero]\n\nlemma epi_iff_eq_zero (h : exact f g) : category_theory.epi f ↔ g = 0 :=\n⟨h.eq_zero_of_epi, h.epi_of_eq_zero⟩\n\nlemma mono_of_is_zero (h : exact f g) (hA : is_zero A) : mono g :=\nby { rw h.mono_iff_eq_zero, exact hA.eq_of_src f _ }\n\nlemma epi_of_is_zero (h : exact f g) (hA : is_zero C) : category_theory.epi f :=\nby { rw h.epi_iff_eq_zero, exact hA.eq_of_tgt g _ }\n\nlemma is_zero_of_eq_zero_eq_zero (h : exact f g) (hf : f = 0) (hg : g = 0) : is_zero B :=\nis_zero_of_exact_zero_zero' _ _ h hf hg\n\nlemma is_zero_of_is_zero_is_zero (h : exact f g) (hA : is_zero A) (hC : is_zero C) : is_zero B :=\nis_zero_of_exact_is_zero_is_zero _ _ h hA hC\n\nprotected lemma exact_seq (h : exact f g) : exact_seq 𝒜 [f, g] :=\n(exact_iff_exact_seq _ _).mp h\n\nlemma cons (h : exact f g) {L : list (arrow 𝒜)} (hL : exact_seq 𝒜 (g :: L)) :\n  exact_seq 𝒜 (f :: g :: L) :=\nexact_seq.cons f g h L hL\n\nend exact\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/exact_seq2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.45823406736945704}}
{"text": "\nimport data.fix.parser.basic\n\nuniverses u\n\nnamespace hidden\n\nuniverses u_1 u_2 u_3\n\nset_option trace.app_builder true\nset_option pp.universes true\n\nqpf list_F'' (α β : Type)\n| cons : ℤ → (ℕ → α) → (list ℕ → α) → (ℤ → β) → list_F''\n| a : α → list_F''\n| b : β → list_F''\n| nil : list_F''\n-- #exit\n-- @[derive mvqpf]\nqpf list_F (α : Type)\n| nil : list_F\n| cons : ℤ → α → list_F\n\n-- #exit\n-- -- #print hidden.list_F.head_t\n-- #print prefix hidden.list_F\n-- #print hidden.list_F.child_t\n-- -- #print hidden.list_F.pfunctor\n\n-- -- #test list_F.internal_eq\n-- -- #test @list_F.map\n\n-- example : ∀ (α : Type), list_F.internal (typevec.of_ind (typevec.ind.cons α typevec.ind.nil)) = list_F α :=\n-- list_F.internal_eq\n\n-- example : Π (α β : typevec 1), α ⟹ β → list_F.internal α → list_F.internal β :=\n-- list_F.internal.map\n\n-- -- #test hidden.list_F.internal.map._equation_0\n-- -- #test hidden.list_F.internal.map._equation_1\n\n-- example : ∀ (α α' : Type) (f0 : α → α'),\n--   list_F.internal.map (typevec.of_ind (typevec.ind.cons α typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons α' typevec.ind.nil))\n--       (typevec.append_fun typevec.nil_fun f0)\n--       _ =\n--     list_F.nil α' :=\n-- list_F.internal.map._equation_0\n\n-- example : ∀ (α α' : Type) (f0 : α → α') (a : ℤ) (a_1 : α),\n--   list_F.internal.map (typevec.of_ind (typevec.ind.cons α typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons α' typevec.ind.nil))\n--       (typevec.append_fun typevec.nil_fun f0)\n--       _ =\n--     list_F.cons a (f0 a_1) :=\n-- list_F.internal.map._equation_1\n\n\n-- @[derive mvqpf]\n\n-- @[user_command]\n-- meta def my_cmd (_ : interactive.parse (lean.parser.tk \"my_cmd\")) : lean.parser unit :=\n-- do lean.parser.with_input lean.parser.command_like\n-- \"inductive list_F (a : Type)\n-- | nil : list_F\",\n--    pure ().\n\n-- my_cmd\n\n-- #check @list_F.no_confusion\n\n-- -- #print hidden.list_F'.head_t\n-- -- #print hidden.list_F'.child_t.α\n-- -- #print hidden.list_F'.child_t.β\n-- -- #print hidden.list_F'.child_t\n-- -- #print hidden.list_F'.pfunctor\n\n-- -- #test list_F'.internal_eq\n-- -- #test @list_F'.map\n\n-- example : ∀ (α β : Type),\n--   list_F'.internal (typevec.of_ind (typevec.ind.cons α (typevec.ind.cons β typevec.ind.nil))) = list_F' α β :=\n-- list_F'.internal_eq\n\n-- example : Π (α β : typevec 2), α ⟹ β → list_F'.internal α → list_F'.internal β :=\n-- list_F'.internal.map\n\n-- -- #test hidden.list_F'.internal.map._equation_0\n-- -- #test hidden.list_F'.internal.map._equation_1\n\n-- example : ∀ (α β α' β' : Type) (f0 : α → α') (f1 : β → β'),\n--   list_F'.internal.map (typevec.of_ind (typevec.ind.cons α (typevec.ind.cons β typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons α' (typevec.ind.cons β' typevec.ind.nil)))\n--       (typevec.append_fun (typevec.append_fun typevec.nil_fun f1) f0)\n--       _ =\n--     list_F'.nil α' β' :=\n-- list_F'.internal.map._equation_0\n\n-- example : ∀ (α β α' β' : Type) (f0 : α → α') (f1 : β → β') (a : α) (a_1 : β),\n--   list_F'.internal.map (typevec.of_ind (typevec.ind.cons α (typevec.ind.cons β typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons α' (typevec.ind.cons β' typevec.ind.nil)))\n--       (typevec.append_fun (typevec.append_fun typevec.nil_fun f1) f0)\n--       _ =\n--     list_F'.cons (f0 a) (f1 a_1) :=\n-- list_F'.internal.map._equation_1\nset_option trace.app_builder true\nset_option pp.universes true\n\n-- @[derive mvqpf]\nqpf list_F''_ (α β γ : Type u)\n| nil : (β → γ) → list_F''_\n| cons : (α → β) → list_F''_\n\n-- #exit\n-- #print hidden.list_F''.head_t\n-- #print hidden.list_F''.child_t.γ\n-- #print hidden.list_F''.child_t\n-- #print hidden.list_F''.pfunctor\n\n-- #check list_F''.internal_eq\n-- #check @list_F''.map\n\n-- example : ∀ (α : Type*) (β : Type*) (γ : Type*),\n--     list_F''.internal α β (typevec.of_ind (typevec.ind.cons γ typevec.ind.nil)) = list_F'' α β γ :=\n-- list_F''.internal_eq\n\n-- example : Π (α : Type*) (β : Type*) (α_1 β_1 : typevec 1),\n--     α_1 ⟹ β_1 → list_F''.internal α β α_1 → list_F''.internal α β β_1 :=\n-- @list_F''.internal.map\n\n-- #test hidden.list_F''.internal.map._equation_0\n-- #test hidden.list_F''.internal.map._equation_1\n\n-- #check list_F''.internal.map\n\n-- example : ∀ (α : Type u_1) (β : Type u_1) (γ γ' : Type u_1) (f2 : γ → γ') (a : β → γ),\n--   list_F''.internal.map α β (typevec.of_ind (typevec.ind.cons γ typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons γ' typevec.ind.nil))\n--       (typevec.append_fun typevec.nil_fun f2)\n--       _ =\n--     list_F''.nil α (λ (a_1 : β), f2 (a a_1)) :=\n-- list_F''.internal.map._equation_0\n\n-- example : ∀ (α : Type u_1) (β : Type u_1) (γ γ' : Type u_1) (f2 : γ → γ') (a : α → β),\n--   list_F''.internal.map α β (typevec.of_ind (typevec.ind.cons γ typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons γ' typevec.ind.nil))\n--       (typevec.append_fun typevec.nil_fun f2)\n--       _ =\n--     list_F''.cons γ' (λ (a_1 : α), a a_1) :=\n-- list_F''.internal.map._equation_1\n\n-- @[derive mvqpf]\nqpf list_F''' (α β γ : Type u)\n| nil : list_F'''\n| cons : (γ → β) → list_F'''\n\n-- #check hidden.list_F'''.pfunctor.cons\n\n-- #exit\n-- #print hidden.list_F'''.head_t\n-- #print hidden.list_F'''.child_t.α\n-- #print hidden.list_F'''.child_t.β\n-- #print hidden.list_F'''.child_t\n-- #print hidden.list_F'''.pfunctor\n\n-- #check list_F'''.internal_eq\n-- #check @list_F'''.map\n\n-- example : ∀ (α β γ : Type*),\n--     list_F'''.internal γ (typevec.of_ind (typevec.ind.cons α (typevec.ind.cons β typevec.ind.nil))) =\n--       list_F''' α β γ :=\n-- list_F'''.internal_eq\n\n-- example : Π (γ : Type*) (α β : typevec 2), α ⟹ β → list_F'''.internal γ α → list_F'''.internal γ β :=\n-- @list_F'''.internal.map\n\n-- -- #test hidden.list_F'''.internal.map._equation_0\n-- -- #test hidden.list_F'''.internal.map._equation_1\n\n-- example : ∀ (α β γ α' β' : Type u) (f0 : α → α') (f1 : β → β'),\n--   list_F'''.internal.map γ (typevec.of_ind (typevec.ind.cons α (typevec.ind.cons β typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons α' (typevec.ind.cons β' typevec.ind.nil)))\n--       (typevec.append_fun (typevec.append_fun typevec.nil_fun f1) f0)\n--       _ = --(list_F'''.nil α β γ) =\n--     list_F'''.nil α' β' γ :=\n-- list_F'''.internal.map._equation_0\n\n-- example : ∀ (α β γ α' β' : Type u) (f0 : α → α') (f1 : β → β') (a : γ → β),\n--   list_F'''.internal.map γ (typevec.of_ind (typevec.ind.cons α (typevec.ind.cons β typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons α' (typevec.ind.cons β' typevec.ind.nil)))\n--       (typevec.append_fun (typevec.append_fun typevec.nil_fun f1) f0)\n--       ( _ ) =\n--     list_F'''.cons α' (λ (a_1 : γ), f1 (a a_1)) :=\n-- list_F'''.internal.map._equation_1\n\n-- @[derive mvqpf]\nqpf list_F'''' (α β γ : Type u)\n| nil : (β → γ) → (γ → α) → list_F''''\n| cons : (α → β) → list_F''''\n\n-- #print prefix hidden.list_F''''\n-- #check hidden.list_F''''.pfunctor.cons\n\n-- #print hidden.list_F''''.head_t\n-- #print hidden.list_F''''.child_t\n-- #print hidden.list_F''''.pfunctor\n\n-- #check @list_F''''.internal_eq\n-- #check @list_F''''.internal.map\n\n-- example : ∀ (α : Type*) (β : Type*) (γ : Type*),\n--     list_F''''.internal α β γ (typevec.of_ind typevec.ind.nil) = list_F'''' α β γ :=\n-- @list_F''''.internal_eq\n\nexample : Π (α : Type*) (β : Type*) (γ : Type*) (α_1 β_1 : typevec 0),\n    α_1 ⟹ β_1 → list_F''''.internal α β γ α_1 → list_F''''.internal α β γ β_1 :=\n@list_F''''.internal.map\n\n-- #test hidden.list_F''''.internal.map._equation_0\n\nexample : ∀ (α : Type u_1) (β : Type u_1) (γ : Type u_1) (a : β → γ) (a_1 : γ → α),\n  list_F''''.internal.map α β γ ⦃ ⦄ ⦃ ⦄ typevec.nil_fun\n      _ =\n    list_F''''.nil (λ (a_1 : β), a a_1) (λ (a : γ), a_1 a) :=\nlist_F''''.internal.map._equation_0\n\nexample : ∀ (α : Type u_1) (β : Type u_1) (γ : Type u_1) (a : α → β),\n  list_F''''.internal.map α β γ (⦃ ⦄) ( ⦃ ⦄ ) typevec.nil_fun\n      _ =\n    list_F''''.cons γ (λ (a_1 : α), a a_1) :=\nlist_F''''.internal.map._equation_1\n\n-- data list\n-- | nil : list\n-- | cons : ℤ → list → list\n\nend hidden\n", "meta": {"author": "avigad", "repo": "qpf", "sha": "debe2eacb8cf46b21aba2eaf3f2e20940da0263b", "save_path": "github-repos/lean/avigad-qpf", "path": "github-repos/lean/avigad-qpf/qpf-debe2eacb8cf46b21aba2eaf3f2e20940da0263b/test/qpf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.45823406736945704}}
{"text": "/-\nCopyright (c) 2016 Leonardo de Moura. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport data.set.lattice\n\n/-!\n# Functoriality of `set`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the functor structure of `set`.\n-/\n\nuniverses u\n\nopen function\n\nnamespace set\nvariables {α β : Type u} {s : set α} {f : α → set β} {g : set (α → β)}\n\ninstance : monad.{u} set :=\n{ pure       := λ α a, {a},\n  bind       := λ α β s f, ⋃ i ∈ s, f i,\n  seq        := λ α β, set.seq,\n  map        := λ α β, set.image }\n\n@[simp] lemma bind_def : s >>= f = ⋃ i ∈ s, f i := rfl\n@[simp] lemma fmap_eq_image (f : α → β) : f <$> s = f '' s := rfl\n@[simp] lemma seq_eq_set_seq (s : set (α → β)) (t : set α) : s <*> t = s.seq t := rfl\n@[simp] lemma pure_def (a : α) : (pure a : set α) = {a} := rfl\n\n/-- `set.image2` in terms of monadic operations. Note that this can't be taken as the definition\nbecause of the lack of universe polymorphism. -/\nlemma image2_def {α β γ : Type*} (f : α → β → γ) (s : set α) (t : set β) :\n  image2 f s t = f <$> s <*> t :=\nby { ext, simp }\n\ninstance : is_lawful_monad set :=\n{ id_map                := λ α, image_id,\n  comp_map              := λ α β γ f g s, image_comp _ _ _,\n  pure_bind             := λ α β, bUnion_singleton,\n  bind_assoc            := λ α β γ s f g, by simp only [bind_def, bUnion_Union],\n  bind_pure_comp_eq_map := λ α β f s, (image_eq_Union _ _).symm,\n  bind_map_eq_seq       := λ α β s t, seq_def.symm }\n\ninstance : is_comm_applicative (set : Type u → Type u) :=\n⟨ λ α β s t, prod_image_seq_comm s t ⟩\n\ninstance : alternative set :=\n{ orelse := λ α, (∪),\n  failure := λ α, ∅,\n  .. set.monad }\n\nend set\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/set/functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.45823114552839217}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.monoidal.braided\nimport category_theory.functor.reflects_isomorphisms\n\n/-!\n# Half braidings and the Drinfeld center of a monoidal category\n\nWe define `center C` to be pairs `⟨X, b⟩`, where `X : C` and `b` is a half-braiding on `X`.\n\nWe show that `center C` is braided monoidal,\nand provide the monoidal functor `center.forget` from `center C` back to `C`.\n\n## Future work\n\nVerifying the various axioms here is done by tedious rewriting.\nUsing the `slice` tactic may make the proofs marginally more readable.\n\nMore exciting, however, would be to make possible one of the following options:\n1. Integration with homotopy.io / globular to give \"picture proofs\".\n2. The monoidal coherence theorem, so we can ignore associators\n   (after which most of these proofs are trivial;\n   I'm unsure if the monoidal coherence theorem is even usable in dependent type theory).\n3. Automating these proofs using `rewrite_search` or some relative.\n\n-/\n\nopen category_theory\nopen category_theory.monoidal_category\n\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u₁} [category.{v₁} C] [monoidal_category C]\n\n/--\nA half-braiding on `X : C` is a family of isomorphisms `X ⊗ U ≅ U ⊗ X`,\nmonoidally natural in `U : C`.\n\nThinking of `C` as a 2-category with a single `0`-morphism, these are the same as natural\ntransformations (in the pseudo- sense) of the identity 2-functor on `C`, which send the unique\n`0`-morphism to `X`.\n-/\n@[nolint has_inhabited_instance]\nstructure half_braiding (X : C) :=\n(β : Π U, X ⊗ U ≅ U ⊗ X)\n(monoidal' : ∀ U U', (β (U ⊗ U')).hom =\n  (α_ _ _ _).inv ≫ ((β U).hom ⊗ 𝟙 U') ≫ (α_ _ _ _).hom ≫ (𝟙 U ⊗ (β U').hom) ≫ (α_ _ _ _).inv\n  . obviously)\n(naturality' : ∀ {U U'} (f : U ⟶ U'), (𝟙 X ⊗ f) ≫ (β U').hom = (β U).hom ≫ (f ⊗ 𝟙 X) . obviously)\n\nrestate_axiom half_braiding.monoidal'\nattribute [reassoc, simp] half_braiding.monoidal -- the reassoc lemma is redundant as a simp lemma\nrestate_axiom half_braiding.naturality'\nattribute [simp, reassoc] half_braiding.naturality\n\nvariables (C)\n/--\nThe Drinfeld center of a monoidal category `C` has as objects pairs `⟨X, b⟩`, where `X : C`\nand `b` is a half-braiding on `X`.\n-/\n@[nolint has_inhabited_instance]\ndef center := Σ X : C, half_braiding X\n\nnamespace center\n\nvariables {C}\n\n/-- A morphism in the Drinfeld center of `C`. -/\n@[ext, nolint has_inhabited_instance]\nstructure hom (X Y : center C) :=\n(f : X.1 ⟶ Y.1)\n(comm' : ∀ U, (f ⊗ 𝟙 U) ≫ (Y.2.β U).hom = (X.2.β U).hom ≫ (𝟙 U ⊗ f) . obviously)\n\nrestate_axiom hom.comm'\nattribute [simp, reassoc] hom.comm\n\ninstance : category (center C) :=\n{ hom := hom,\n  id := λ X, { f := 𝟙 X.1, },\n  comp := λ X Y Z f g, { f := f.f ≫ g.f, }, }\n\n@[simp] lemma id_f (X : center C) : hom.f (𝟙 X) = 𝟙 X.1 := rfl\n@[simp] lemma comp_f {X Y Z : center C} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).f = f.f ≫ g.f := rfl\n\n@[ext]\nlemma ext {X Y : center C} (f g : X ⟶ Y) (w : f.f = g.f) : f = g :=\nby { cases f, cases g, congr, exact w, }\n\n/--\nConstruct an isomorphism in the Drinfeld center from\na morphism whose underlying morphism is an isomorphism.\n-/\n@[simps]\ndef iso_mk {X Y : center C} (f : X ⟶ Y) [is_iso f.f] : X ≅ Y :=\n{ hom := f,\n  inv := ⟨inv f.f, λ U, by simp [←cancel_epi (f.f ⊗ 𝟙 U), ←comp_tensor_id_assoc, ←id_tensor_comp]⟩ }\n\ninstance is_iso_of_f_is_iso {X Y : center C} (f : X ⟶ Y) [is_iso f.f] : is_iso f :=\nbegin\n  change is_iso (iso_mk f).hom,\n  apply_instance,\nend\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_obj (X Y : center C) : center C :=\n⟨X.1 ⊗ Y.1,\n  { β := λ U, α_ _ _ _ ≪≫ (iso.refl X.1 ⊗ Y.2.β U) ≪≫ (α_ _ _ _).symm\n      ≪≫ (X.2.β U ⊗ iso.refl Y.1) ≪≫ α_ _ _ _,\n    monoidal' := λ U U',\n    begin\n      dsimp,\n      simp only [comp_tensor_id, id_tensor_comp, category.assoc, half_braiding.monoidal],\n      rw [pentagon_assoc, pentagon_inv_assoc, iso.eq_inv_comp, ←pentagon_assoc,\n        ←id_tensor_comp_assoc, iso.hom_inv_id, tensor_id, category.id_comp,\n        ←associator_naturality_assoc, cancel_epi, cancel_epi,\n        ←associator_inv_naturality_assoc (X.2.β U).hom,\n        associator_inv_naturality_assoc _ _ (Y.2.β U').hom, tensor_id, tensor_id,\n        id_tensor_comp_tensor_id_assoc, associator_naturality_assoc (X.2.β U).hom,\n        ←associator_naturality_assoc _ _ (Y.2.β U').hom, tensor_id, tensor_id,\n        tensor_id_comp_id_tensor_assoc, ←id_tensor_comp_tensor_id, tensor_id, category.comp_id,\n        ←is_iso.inv_comp_eq, inv_tensor, is_iso.inv_id, is_iso.iso.inv_inv, pentagon_assoc,\n        iso.hom_inv_id_assoc, cancel_epi, cancel_epi, ←is_iso.inv_comp_eq, is_iso.iso.inv_hom,\n        ←pentagon_inv_assoc, ←comp_tensor_id_assoc, iso.inv_hom_id, tensor_id, category.id_comp,\n        ←associator_inv_naturality_assoc, cancel_epi, cancel_epi, ←is_iso.inv_comp_eq, inv_tensor,\n        is_iso.iso.inv_hom, is_iso.inv_id, pentagon_inv_assoc, iso.inv_hom_id, category.comp_id],\n    end,\n    naturality' := λ U U' f,\n    begin\n      dsimp,\n      rw [category.assoc, category.assoc, category.assoc, category.assoc,\n        id_tensor_associator_naturality_assoc, ←id_tensor_comp_assoc, half_braiding.naturality,\n        id_tensor_comp_assoc, associator_inv_naturality_assoc, ←comp_tensor_id_assoc,\n        half_braiding.naturality, comp_tensor_id_assoc, associator_naturality, ←tensor_id],\n    end, }⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_hom {X₁ Y₁ X₂ Y₂ : center C} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :\n  tensor_obj X₁ X₂ ⟶ tensor_obj Y₁ Y₂ :=\n{ f := f.f ⊗ g.f,\n  comm' := λ U, begin\n    dsimp,\n    rw [category.assoc, category.assoc, category.assoc, category.assoc,\n      associator_naturality_assoc, ←tensor_id_comp_id_tensor, category.assoc,\n      ←id_tensor_comp_assoc, g.comm, id_tensor_comp_assoc, tensor_id_comp_id_tensor_assoc,\n      ←id_tensor_comp_tensor_id, category.assoc, associator_inv_naturality_assoc,\n      id_tensor_associator_inv_naturality_assoc, tensor_id,\n      id_tensor_comp_tensor_id_assoc, ←tensor_id_comp_id_tensor g.f, category.assoc,\n      ←comp_tensor_id_assoc, f.comm, comp_tensor_id_assoc, id_tensor_associator_naturality,\n      associator_naturality_assoc, ←id_tensor_comp, tensor_id_comp_id_tensor],\n  end }\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_unit : center C :=\n⟨𝟙_ C,\n  { β := λ U, (λ_ U) ≪≫ (ρ_ U).symm,\n    monoidal' := λ U U', by simp,\n    naturality' := λ U U' f, begin\n      dsimp,\n      rw [left_unitor_naturality_assoc, right_unitor_inv_naturality, category.assoc],\n    end, }⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef associator (X Y Z : center C) : tensor_obj (tensor_obj X Y) Z ≅ tensor_obj X (tensor_obj Y Z) :=\niso_mk ⟨(α_ X.1 Y.1 Z.1).hom, λ U, begin\n  dsimp,\n  simp only [category.assoc, comp_tensor_id, id_tensor_comp],\n  rw [pentagon, pentagon_assoc, ←associator_naturality_assoc (𝟙 X.1) (𝟙 Y.1), tensor_id, cancel_epi,\n    cancel_epi, iso.eq_inv_comp, ←pentagon_assoc, ←id_tensor_comp_assoc, iso.hom_inv_id, tensor_id,\n    category.id_comp, ←associator_naturality_assoc, cancel_epi, cancel_epi, ←is_iso.inv_comp_eq,\n    inv_tensor, is_iso.inv_id, is_iso.iso.inv_inv, pentagon_assoc, iso.hom_inv_id_assoc, ←tensor_id,\n    ←associator_naturality_assoc],\nend⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef left_unitor (X : center C) : tensor_obj tensor_unit X ≅ X :=\niso_mk ⟨(λ_ X.1).hom, λ U, begin\n  dsimp,\n  simp only [category.comp_id, category.assoc, tensor_inv_hom_id, comp_tensor_id,\n    tensor_id_comp_id_tensor, triangle_assoc_comp_right_inv],\n  rw [←left_unitor_tensor, left_unitor_naturality, left_unitor_tensor'_assoc],\nend⟩\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef right_unitor (X : center C) : tensor_obj X tensor_unit ≅ X :=\niso_mk ⟨(ρ_ X.1).hom, λ U, begin\n  dsimp,\n  simp only [tensor_id_comp_id_tensor_assoc, triangle_assoc, id_tensor_comp, category.assoc],\n  rw [←tensor_id_comp_id_tensor_assoc (ρ_ U).inv, cancel_epi, ←right_unitor_tensor_inv_assoc,\n    ←right_unitor_inv_naturality_assoc],\n  simp,\nend⟩\n\nsection\nlocal attribute [simp] associator_naturality left_unitor_naturality right_unitor_naturality\n  pentagon\nlocal attribute [simp] center.associator center.left_unitor center.right_unitor\n\ninstance : monoidal_category (center C) :=\n{ tensor_obj := λ X Y, tensor_obj X Y,\n  tensor_hom := λ X₁ Y₁ X₂ Y₂ f g, tensor_hom f g,\n  tensor_unit := tensor_unit,\n  associator := associator,\n  left_unitor := left_unitor,\n  right_unitor := right_unitor, }\n\n@[simp] lemma tensor_fst (X Y : center C) : (X ⊗ Y).1 = X.1 ⊗ Y.1 := rfl\n\n@[simp] lemma tensor_β (X Y : center C) (U : C) :\n  (X ⊗ Y).2.β U =\n    α_ _ _ _ ≪≫ (iso.refl X.1 ⊗ Y.2.β U) ≪≫ (α_ _ _ _).symm\n      ≪≫ (X.2.β U ⊗ iso.refl Y.1) ≪≫ α_ _ _ _ :=\nrfl\n@[simp] \n\n@[simp] lemma tensor_unit_β (U : C) : (𝟙_ (center C)).2.β U = (λ_ U) ≪≫ (ρ_ U).symm := rfl\n\n@[simp] lemma associator_hom_f (X Y Z : center C) : hom.f (α_ X Y Z).hom = (α_ X.1 Y.1 Z.1).hom :=\nrfl\n\n@[simp] lemma associator_inv_f (X Y Z : center C) : hom.f (α_ X Y Z).inv = (α_ X.1 Y.1 Z.1).inv :=\nby { ext, rw [←associator_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma left_unitor_hom_f (X : center C) : hom.f (λ_ X).hom = (λ_ X.1).hom :=\nrfl\n\n@[simp] lemma left_unitor_inv_f (X : center C) : hom.f (λ_ X).inv = (λ_ X.1).inv :=\nby { ext, rw [←left_unitor_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma right_unitor_hom_f (X : center C) : hom.f (ρ_ X).hom = (ρ_ X.1).hom :=\nrfl\n\n@[simp] lemma right_unitor_inv_f (X : center C) : hom.f (ρ_ X).inv = (ρ_ X.1).inv :=\nby { ext, rw [←right_unitor_hom_f, ←comp_f, iso.hom_inv_id], refl, }\n\nend\n\nsection\nvariables (C)\n\n/-- The forgetful monoidal functor from the Drinfeld center to the original category. -/\n@[simps]\ndef forget : monoidal_functor (center C) C :=\n{ obj := λ X, X.1,\n  map := λ X Y f, f.f,\n  ε := 𝟙 (𝟙_ C),\n  μ := λ X Y, 𝟙 (X.1 ⊗ Y.1), }\n\ninstance : reflects_isomorphisms (forget C).to_functor :=\n{ reflects := λ A B f i, by { dsimp at i, resetI, change is_iso (iso_mk f).hom, apply_instance, } }\n\nend\n\n/-- Auxiliary definition for the `braided_category` instance on `center C`. -/\n@[simps]\ndef braiding (X Y : center C) : X ⊗ Y ≅ Y ⊗ X :=\niso_mk ⟨(X.2.β Y.1).hom, λ U, begin\n  dsimp,\n  simp only [category.assoc],\n  rw [←is_iso.inv_comp_eq, is_iso.iso.inv_hom, ←half_braiding.monoidal_assoc,\n    ←half_braiding.naturality_assoc, half_braiding.monoidal],\n  simp,\nend⟩\n\ninstance braided_category_center : braided_category (center C) :=\n{ braiding := braiding,\n  braiding_naturality' := λ X Y X' Y' f g, begin\n    ext,\n    dsimp,\n    rw [←tensor_id_comp_id_tensor, category.assoc, half_braiding.naturality, f.comm_assoc,\n      id_tensor_comp_tensor_id],\n  end, } -- `obviously` handles the hexagon axioms\n\nsection\nvariables [braided_category C]\n\nopen braided_category\n\n/-- Auxiliary construction for `of_braided`. -/\n@[simps]\ndef of_braided_obj (X : C) : center C :=\n⟨X, { β := λ Y, β_ X Y,\n  monoidal' := λ U U', begin\n    rw [iso.eq_inv_comp, ←category.assoc, ←category.assoc, iso.eq_comp_inv,\n      category.assoc, category.assoc],\n    exact hexagon_forward X U U',\n  end }⟩\n\nvariables (C)\n\n/--\nThe functor lifting a braided category to its center, using the braiding as the half-braiding.\n-/\n@[simps]\ndef of_braided : monoidal_functor C (center C) :=\n{ obj := of_braided_obj,\n  map := λ X X' f,\n  { f := f,\n    comm' := λ U, braiding_naturality _ _, },\n  ε :=\n  { f := 𝟙 _,\n    comm' := λ U, begin\n      dsimp,\n      rw [tensor_id, category.id_comp, tensor_id, category.comp_id, ←braiding_right_unitor,\n        category.assoc, iso.hom_inv_id, category.comp_id],\n    end, },\n  μ := λ X Y,\n  { f := 𝟙 _,\n    comm' := λ U, begin\n      dsimp,\n      rw [tensor_id, tensor_id, category.id_comp, category.comp_id,\n        ←iso.inv_comp_eq, ←category.assoc, ←category.assoc, ←iso.comp_inv_eq,\n        category.assoc, hexagon_reverse, category.assoc],\n    end, }, }\n\nend\n\nend center\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/monoidal/center.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.45823114552839217}}
{"text": "/-\nCopyright (c) 2020 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Floris van Doorn\n-/\nimport measure_theory.integral.lebesgue\nimport measure_theory.measure.regular\nimport measure_theory.group.measurable_equiv\n\n/-!\n# Measures on Groups\n\nWe develop some properties of measures on (topological) groups\n\n* We define properties on measures: left and right invariant measures.\n* We define the measure `μ.inv : A ↦ μ(A⁻¹)` and show that it is right invariant iff\n  `μ` is left invariant.\n* We define a class `is_haar_measure μ`, requiring that the measure `μ` is left-invariant, finite\n  on compact sets, and positive on open sets.\n\nWe also give analogues of all these notions in the additive world.\n-/\n\nnoncomputable theory\n\nopen_locale ennreal pointwise big_operators\nopen has_inv set function measure_theory.measure\n\nnamespace measure_theory\n\nvariables {G : Type*}\n\nsection\n\nvariables [measurable_space G] [has_mul G]\n\n/-- A measure `μ` on a topological group is left invariant\n  if the measure of left translations of a set are equal to the measure of the set itself.\n  To left translate sets we use preimage under left multiplication,\n  since preimages are nicer to work with than images. -/\n@[to_additive \"A measure on a topological group is left invariant\n  if the measure of left translations of a set are equal to the measure of the set itself.\n  To left translate sets we use preimage under left addition,\n  since preimages are nicer to work with than images.\"]\ndef is_mul_left_invariant (μ : set G → ℝ≥0∞) : Prop :=\n∀ (g : G) {A : set G} (h : measurable_set A), μ ((λ h, g * h) ⁻¹' A) = μ A\n\n/-- A measure `μ` on a topological group is right invariant\n  if the measure of right translations of a set are equal to the measure of the set itself.\n  To right translate sets we use preimage under right multiplication,\n  since preimages are nicer to work with than images. -/\n@[to_additive \"A measure on a topological group is right invariant\n  if the measure of right translations of a set are equal to the measure of the set itself.\n  To right translate sets we use preimage under right addition,\n  since preimages are nicer to work with than images.\"]\ndef is_mul_right_invariant (μ : set G → ℝ≥0∞) : Prop :=\n∀ (g : G) {A : set G} (h : measurable_set A), μ ((λ h, h * g) ⁻¹' A) = μ A\n\n@[to_additive measure_theory.is_add_left_invariant.smul]\nlemma is_mul_left_invariant.smul {μ : measure G} (h : is_mul_left_invariant μ) (c : ℝ≥0∞) :\n  is_mul_left_invariant ((c • μ : measure G) : set G → ℝ≥0∞) :=\nλ g A hA, by rw [smul_apply, smul_apply, h g hA]\n\n@[to_additive measure_theory.is_add_right_invariant.smul]\nlemma is_mul_right_invariant.smul {μ : measure G} (h : is_mul_right_invariant μ) (c : ℝ≥0∞) :\n  is_mul_right_invariant ((c • μ : measure G) : set G → ℝ≥0∞) :=\nλ g A hA, by rw [smul_apply, smul_apply, h g hA]\n\nend\n\nnamespace measure\n\nvariables [measurable_space G]\n\n@[to_additive]\nlemma map_mul_left_eq_self [topological_space G] [has_mul G] [has_continuous_mul G] [borel_space G]\n  {μ : measure G} : (∀ g, measure.map ((*) g) μ = μ) ↔ is_mul_left_invariant μ :=\nbegin\n  apply forall_congr, intro g, rw [measure.ext_iff], apply forall_congr, intro A,\n  apply forall_congr, intro hA, rw [map_apply (measurable_const_mul g) hA]\nend\n\n@[to_additive]\nlemma _root_.measure_theory.is_mul_left_invariant.measure_preimage_mul\n  [topological_space G] [group G] [topological_group G] [borel_space G]\n  {μ : measure G} (h : is_mul_left_invariant μ) (g : G) (A : set G) :\n  μ ((λ h, g * h) ⁻¹' A) = μ A :=\ncalc μ ((λ h, g * h) ⁻¹' A) = measure.map (λ h, g * h) μ A :\n  ((homeomorph.mul_left g).to_measurable_equiv.map_apply A).symm\n... = μ A : by rw map_mul_left_eq_self.2 h g\n\n@[to_additive]\nlemma map_mul_right_eq_self [topological_space G] [has_mul G] [has_continuous_mul G] [borel_space G]\n  {μ : measure G} :\n  (∀ g, measure.map (λ h, h * g) μ = μ) ↔ is_mul_right_invariant μ :=\nbegin\n  apply forall_congr, intro g, rw [measure.ext_iff], apply forall_congr, intro A,\n  apply forall_congr, intro hA, rw [map_apply (measurable_mul_const g) hA]\nend\n\n/-- The measure `A ↦ μ (A⁻¹)`, where `A⁻¹` is the pointwise inverse of `A`. -/\n@[to_additive \"The measure `A ↦ μ (- A)`, where `- A` is the pointwise negation of `A`.\"]\nprotected def inv [has_inv G] (μ : measure G) : measure G :=\nmeasure.map inv μ\n\nvariables [group G] [topological_space G] [topological_group G] [borel_space G]\n\n@[to_additive]\nlemma inv_apply (μ : measure G) (s : set G) :\n  μ.inv s = μ s⁻¹ :=\n(measurable_equiv.inv G).map_apply s\n\n@[simp, to_additive] protected lemma inv_inv (μ : measure G) : μ.inv.inv = μ :=\n(measurable_equiv.inv G).map_symm_map\n\nvariables {μ : measure G}\n\n@[to_additive]\ninstance regular.inv [t2_space G] [regular μ] : regular μ.inv :=\nregular.map (homeomorph.inv G)\n\nend measure\n\nsection inv\nvariables [measurable_space G] [group G] [topological_space G] [topological_group G] [borel_space G]\n  {μ : measure G}\n\n@[simp, to_additive] lemma regular_inv_iff [t2_space G] : μ.inv.regular ↔ μ.regular :=\nbegin\n  split,\n  { introI h,\n    rw ←μ.inv_inv,\n    exact measure.regular.inv },\n  { introI h,\n    exact measure.regular.inv }\nend\n\n@[to_additive]\nlemma is_mul_left_invariant.inv (h : is_mul_left_invariant μ) :\n  is_mul_right_invariant μ.inv :=\nbegin\n  intros g A hA,\n  rw [μ.inv_apply, μ.inv_apply],\n  convert h g⁻¹ (measurable_inv hA) using 2,\n  simp only [←preimage_comp, ← inv_preimage],\n  apply preimage_congr,\n  intro h,\n  simp only [mul_inv_rev, comp_app, inv_inv]\nend\n\n@[to_additive]\nlemma is_mul_right_invariant.inv (h : is_mul_right_invariant μ) : is_mul_left_invariant μ.inv :=\nbegin\n  intros g A hA,\n  rw [μ.inv_apply, μ.inv_apply],\n  convert h g⁻¹ (measurable_inv hA) using 2,\n  simp only [←preimage_comp, ← inv_preimage],\n  apply preimage_congr,\n  intro h,\n  simp only [mul_inv_rev, comp_app, inv_inv]\nend\n\n@[simp, to_additive]\nlemma is_mul_right_invariant_inv : is_mul_right_invariant μ.inv ↔ is_mul_left_invariant μ :=\n⟨λ h, by { rw ← μ.inv_inv, exact h.inv }, λ h, h.inv⟩\n\n@[simp, to_additive]\nlemma is_mul_left_invariant_inv : is_mul_left_invariant μ.inv ↔ is_mul_right_invariant μ :=\n⟨λ h, by { rw ← μ.inv_inv, exact h.inv }, λ h, h.inv⟩\n\nend inv\n\nsection group\n\nvariables [measurable_space G] [topological_space G] [borel_space G] {μ : measure G}\nvariables [group G] [topological_group G]\n\n/-- If a left-invariant measure gives positive mass to a compact set, then\nit gives positive mass to any open set. -/\n@[to_additive]\nlemma is_mul_left_invariant.measure_pos_of_is_open (hμ : is_mul_left_invariant μ)\n  (K : set G) (hK : is_compact K) (h : μ K ≠ 0) {U : set G} (hU : is_open U) (h'U : U.nonempty) :\n  0 < μ U :=\nbegin\n  contrapose! h,\n  rw ← nonpos_iff_eq_zero,\n  rw nonpos_iff_eq_zero at h,\n  rw ← hU.interior_eq at h'U,\n  obtain ⟨t, hKt⟩ : ∃ (t : finset G), K ⊆ ⋃ (g : G) (H : g ∈ t), (λ (h : G), g * h) ⁻¹' U :=\n    compact_covered_by_mul_left_translates hK h'U,\n  calc μ K ≤ μ (⋃ (g : G) (H : g ∈ t), (λ (h : G), g * h) ⁻¹' U) : measure_mono hKt\n  ... ≤ ∑ g in t, μ ((λ (h : G), g * h) ⁻¹' U) : measure_bUnion_finset_le _ _\n  ... = 0 : by simp [hμ _ hU.measurable_set, h]\nend\n\n/-! A nonzero left-invariant regular measure gives positive mass to any open set. -/\n@[to_additive]\nlemma is_mul_left_invariant.null_iff_empty [regular μ] (hμ : is_mul_left_invariant μ)\n  (h3μ : μ ≠ 0) {s : set G} (hs : is_open s) :\n  μ s = 0 ↔ s = ∅ :=\nbegin\n  obtain ⟨K, hK, h2K⟩ := regular.exists_compact_not_null.mpr h3μ,\n  refine ⟨λ h, _, λ h, by simp only [h, measure_empty]⟩,\n  contrapose h,\n  exact (hμ.measure_pos_of_is_open K hK h2K hs (ne_empty_iff_nonempty.mp h)).ne'\nend\n\n@[to_additive]\nlemma is_mul_left_invariant.null_iff [regular μ] (h2μ : is_mul_left_invariant μ)\n  {s : set G} (hs : is_open s) :\n  μ s = 0 ↔ s = ∅ ∨ μ = 0 :=\nbegin\n  by_cases h3μ : μ = 0, { simp [h3μ] },\n  simp only [h3μ, or_false],\n  exact h2μ.null_iff_empty h3μ hs,\nend\n\n@[to_additive]\nlemma is_mul_left_invariant.measure_ne_zero_iff_nonempty [regular μ]\n  (h2μ : is_mul_left_invariant μ) (h3μ : μ ≠ 0) {s : set G} (hs : is_open s) :\n  μ s ≠ 0 ↔ s.nonempty :=\nby simp_rw [← ne_empty_iff_nonempty, ne.def, h2μ.null_iff_empty h3μ hs]\n\n@[to_additive]\nlemma is_mul_left_invariant.measure_pos_iff_nonempty [regular μ]\n  (h2μ : is_mul_left_invariant μ) (h3μ : μ ≠ 0) {s : set G} (hs : is_open s) :\n  0 < μ s ↔ s.nonempty :=\npos_iff_ne_zero.trans $ h2μ.measure_ne_zero_iff_nonempty h3μ hs\n\n/-- If a left-invariant measure gives finite mass to a nonempty open set, then\nit gives finite mass to any compact set. -/\n@[to_additive]\nlemma is_mul_left_invariant.measure_lt_top_of_is_compact (hμ : is_mul_left_invariant μ)\n  (U : set G) (hU : is_open U) (h'U : U.nonempty) (h : μ U ≠ ∞) {K : set G} (hK : is_compact K) :\n  μ K < ∞ :=\nbegin\n  rw ← hU.interior_eq at h'U,\n  obtain ⟨t, hKt⟩ : ∃ (t : finset G), K ⊆ ⋃ (g : G) (H : g ∈ t), (λ (h : G), g * h) ⁻¹' U :=\n    compact_covered_by_mul_left_translates hK h'U,\n  calc μ K ≤ μ (⋃ (g : G) (H : g ∈ t), (λ (h : G), g * h) ⁻¹' U) : measure_mono hKt\n  ... ≤ ∑ g in t, μ ((λ (h : G), g * h) ⁻¹' U) : measure_bUnion_finset_le _ _\n  ... = finset.card t * μ U : by simp only [hμ _ hU.measurable_set, finset.sum_const, nsmul_eq_mul]\n  ... < ∞ : ennreal.mul_lt_top ennreal.coe_nat_ne_top h\nend\n\n/-- If a left-invariant measure gives finite mass to a set with nonempty interior, then\nit gives finite mass to any compact set. -/\n@[to_additive]\nlemma is_mul_left_invariant.measure_lt_top_of_is_compact' (hμ : is_mul_left_invariant μ)\n  (U : set G) (hU : (interior U).nonempty) (h : μ U ≠ ∞) {K : set G} (hK : is_compact K) :\n  μ K < ∞ :=\nhμ.measure_lt_top_of_is_compact (interior U) is_open_interior hU\n  ((measure_mono (interior_subset)).trans_lt (lt_top_iff_ne_top.2 h)).ne hK\n\n/-- For nonzero regular left invariant measures, the integral of a continuous nonnegative function\n  `f` is 0 iff `f` is 0. -/\n@[to_additive]\nlemma lintegral_eq_zero_of_is_mul_left_invariant [regular μ]\n  (h2μ : is_mul_left_invariant μ) (h3μ : μ ≠ 0) {f : G → ℝ≥0∞} (hf : continuous f) :\n  ∫⁻ x, f x ∂μ = 0 ↔ f = 0 :=\nbegin\n  split, swap, { rintro rfl, simp_rw [pi.zero_apply, lintegral_zero] },\n  intro h, contrapose h,\n  simp_rw [funext_iff, not_forall, pi.zero_apply] at h, cases h with x hx,\n  obtain ⟨r, h1r, h2r⟩ : ∃ r : ℝ≥0∞, 0 < r ∧ r < f x :=\n  exists_between (pos_iff_ne_zero.mpr hx),\n  have h3r := hf.is_open_preimage (Ioi r) is_open_Ioi,\n  let s := Ioi r,\n  rw [← ne.def, ← pos_iff_ne_zero],\n  have : 0 < r * μ (f ⁻¹' Ioi r),\n  { have : (f ⁻¹' Ioi r).nonempty, from ⟨x, h2r⟩,\n    simpa [h1r.ne', h2μ.measure_pos_iff_nonempty h3μ h3r, h1r] },\n  refine this.trans_le _,\n  rw [← set_lintegral_const, ← lintegral_indicator _ h3r.measurable_set],\n  apply lintegral_mono,\n  refine indicator_le (λ y, le_of_lt),\nend\n\nend group\n\nsection integration\n\nvariables [measurable_space G] [topological_space G] [borel_space G] {μ : measure G}\nvariables [group G] [has_continuous_mul G]\nopen measure\n\n/-- Translating a function by left-multiplication does not change its `lintegral` with respect to\na left-invariant measure. -/\n@[to_additive]\nlemma lintegral_mul_left_eq_self (hμ : is_mul_left_invariant μ) (f : G → ℝ≥0∞) (g : G) :\n  ∫⁻ x, f (g * x) ∂μ = ∫⁻ x, f x ∂μ :=\nbegin\n  have : measure.map (has_mul.mul g) μ = μ,\n  { rw ← map_mul_left_eq_self at hμ,\n    exact hμ g },\n  convert (lintegral_map_equiv f (homeomorph.mul_left g).to_measurable_equiv).symm,\n  simp [this]\nend\n\n/-- Translating a function by right-multiplication does not change its `lintegral` with respect to\na right-invariant measure. -/\n@[to_additive]\nlemma lintegral_mul_right_eq_self (hμ : is_mul_right_invariant μ) (f : G → ℝ≥0∞) (g : G) :\n  ∫⁻ x, f (x * g) ∂μ = ∫⁻ x, f x ∂μ :=\nbegin\n  have : measure.map (λ g', g' * g) μ = μ,\n  { rw ← map_mul_right_eq_self at hμ,\n    exact hμ g },\n  convert (lintegral_map_equiv f (homeomorph.mul_right g).to_measurable_equiv).symm,\n  simp [this]\nend\n\nend integration\n\nsection haar\nnamespace measure\n\n/-- A measure on a group is a Haar measure if it is left-invariant, and gives finite mass to compact\nsets and positive mass to open sets. -/\nclass is_haar_measure {G : Type*} [group G] [topological_space G] [measurable_space G]\n  (μ : measure G) : Prop :=\n(left_invariant : is_mul_left_invariant μ)\n(compact_lt_top : ∀ (K : set G), is_compact K → μ K < ∞)\n(open_pos : ∀ (U : set G), is_open U → U.nonempty → 0 < μ U)\n\n/-- A measure on an additive group is an additive Haar measure if it is left-invariant, and gives\nfinite mass to compact sets and positive mass to open sets. -/\nclass is_add_haar_measure {G : Type*} [add_group G] [topological_space G] [measurable_space G]\n  (μ : measure G) : Prop :=\n(add_left_invariant : is_add_left_invariant μ)\n(compact_lt_top : ∀ (K : set G), is_compact K → μ K < ∞)\n(open_pos : ∀ (U : set G), is_open U → U.nonempty → 0 < μ U)\n\nattribute [to_additive] is_haar_measure\n\nsection\n\nvariables [group G] [measurable_space G] [topological_space G] (μ : measure G) [is_haar_measure μ]\n\n@[to_additive]\nlemma _root_.is_compact.haar_lt_top {K : set G} (hK : is_compact K) :\n  μ K < ∞ :=\nis_haar_measure.compact_lt_top K hK\n\n@[to_additive]\nlemma _root_.is_open.haar_pos {U : set G} (hU : is_open U) (h'U : U.nonempty) :\n  0 < μ U :=\nis_haar_measure.open_pos U hU h'U\n\n@[to_additive]\nlemma haar_pos_of_nonempty_interior {U : set G} (hU : (interior U).nonempty) : 0 < μ U :=\nlt_of_lt_of_le (is_open_interior.haar_pos μ hU) (measure_mono (interior_subset))\n\n@[to_additive]\nlemma is_mul_left_invariant_haar : is_mul_left_invariant μ :=\nis_haar_measure.left_invariant\n\n@[simp, to_additive]\nlemma haar_preimage_mul [topological_group G] [borel_space G] (g : G) (A : set G) :\n  μ ((λ h, g * h) ⁻¹' A) = μ A :=\n(is_mul_left_invariant_haar μ).measure_preimage_mul _ _\n\n@[simp, to_additive]\nlemma haar_singleton [topological_group G] [borel_space G] (g : G) :\n  μ {g} = μ {(1 : G)} :=\nbegin\n  convert haar_preimage_mul μ (g⁻¹) _,\n  simp only [mul_one, preimage_mul_left_singleton, inv_inv],\nend\n\n@[simp, to_additive]\nlemma haar_preimage_mul_right {G : Type*}\n  [comm_group G] [measurable_space G] [topological_space G] (μ : measure G) [is_haar_measure μ]\n  [topological_group G] [borel_space G] (g : G) (A : set G) :\n  μ ((λ h, h * g) ⁻¹' A) = μ A :=\nby simp_rw [mul_comm, haar_preimage_mul μ g A]\n\n@[to_additive measure_theory.measure.is_add_haar_measure.smul]\nlemma is_haar_measure.smul {c : ℝ≥0∞} (cpos : c ≠ 0) (ctop : c ≠ ∞) :\n  is_haar_measure (c • μ) :=\n{ left_invariant := (is_mul_left_invariant_haar μ).smul _,\n  compact_lt_top := λ K hK, begin\n    change c * μ K < ∞,\n    simp [lt_top_iff_ne_top, (hK.haar_lt_top μ).ne, cpos, ctop],\n  end,\n  open_pos := λ U U_open U_ne, bot_lt_iff_ne_bot.2 $ begin\n    change c * μ U ≠ 0,\n    simp [cpos, (_root_.is_open.haar_pos μ U_open U_ne).ne'],\n  end }\n\n/-- If a left-invariant measure gives positive mass to some compact set with nonempty interior, then\nit is a Haar measure -/\n@[to_additive]\nlemma is_haar_measure_of_is_compact_nonempty_interior [topological_group G] [borel_space G]\n  (μ : measure G) (hμ : is_mul_left_invariant μ)\n  (K : set G) (hK : is_compact K) (h'K : (interior K).nonempty) (h : μ K ≠ 0) (h' : μ K ≠ ∞) :\n  is_haar_measure μ :=\n{ left_invariant := hμ,\n  compact_lt_top := λ L hL, hμ.measure_lt_top_of_is_compact' _ h'K h' hL,\n  open_pos := λ U hU, hμ.measure_pos_of_is_open K hK h hU }\n\n/-- The image of a Haar measure under a group homomorphism which is also a homeomorphism is again\na Haar measure. -/\n@[to_additive]\nlemma is_haar_measure_map [borel_space G] [topological_group G] {H : Type*} [group H]\n  [topological_space H] [measurable_space H] [borel_space H] [t2_space H] [topological_group H]\n  (f : G ≃* H) (hf : continuous f) (hfsymm : continuous f.symm) :\n  is_haar_measure (measure.map f μ) :=\n{ left_invariant := begin\n    rw ← map_mul_left_eq_self,\n    assume h,\n    rw map_map (continuous_mul_left h).measurable hf.measurable,\n    conv_rhs { rw ← map_mul_left_eq_self.2 (is_mul_left_invariant_haar μ) (f.symm h) },\n    rw map_map hf.measurable (continuous_mul_left _).measurable,\n    congr' 2,\n    ext y,\n    simp only [mul_equiv.apply_symm_apply, comp_app, mul_equiv.map_mul],\n  end,\n  compact_lt_top := begin\n    assume K hK,\n    rw map_apply hf.measurable hK.measurable_set,\n    have : f.symm '' K = f ⁻¹' K := equiv.image_eq_preimage _ _,\n    rw ← this,\n    exact is_compact.haar_lt_top _ (hK.image hfsymm)\n  end,\n  open_pos := begin\n    assume U hU h'U,\n    rw map_apply hf.measurable hU.measurable_set,\n    refine (hU.preimage hf).haar_pos _ _,\n    have : f.symm '' U = f ⁻¹' U := equiv.image_eq_preimage _ _,\n    rw ← this,\n    simp [h'U],\n  end }\n\n/-- A Haar measure on a sigma-compact space is sigma-finite. -/\n@[priority 100, to_additive] -- see Note [lower instance priority]\ninstance is_haar_measure.sigma_finite\n  {G : Type*} [group G] [measurable_space G] [topological_space G] [sigma_compact_space G]\n  (μ : measure G) [μ.is_haar_measure] :\n  sigma_finite μ :=\n⟨⟨{ set := compact_covering G,\n  set_mem := λ n, mem_univ _,\n  finite := λ n, is_compact.haar_lt_top μ $ is_compact_compact_covering G n,\n  spanning := Union_compact_covering G }⟩⟩\n\nopen_locale topological_space\nopen filter\n\n/-- If the neutral element of a group is not isolated, then a Haar measure on this group has\nno atom.\n\nThis applies in particular to show that an additive Haar measure on a nontrivial\nfinite-dimensional real vector space has no atom. -/\n@[priority 100, to_additive]\ninstance is_haar_measure.has_no_atoms\n  {G : Type*} [group G] [measurable_space G] [topological_space G] [t1_space G]\n  [topological_group G] [locally_compact_space G] [borel_space G] [(𝓝[{(1 : G)}ᶜ] (1 : G)).ne_bot]\n  (μ : measure G) [μ.is_haar_measure] :\n  has_no_atoms μ :=\nbegin\n  suffices H : μ {(1 : G)} ≤ 0, by { constructor, simp [le_bot_iff.1 H] },\n  obtain ⟨K, K_compact, K_int⟩ : ∃ (K : set G), is_compact K ∧ (1 : G) ∈ interior K,\n  { rcases exists_compact_subset is_open_univ (mem_univ (1 : G)) with ⟨K, hK⟩,\n    exact ⟨K, hK.1, hK.2.1⟩ },\n  have K_inf : set.infinite K := infinite_of_mem_nhds (1 : G) (mem_interior_iff_mem_nhds.1 K_int),\n  have μKlt : μ K ≠ ∞ := (K_compact.haar_lt_top μ).ne,\n  have I : ∀ (n : ℕ), μ {(1 : G)} ≤ μ K / n,\n  { assume n,\n    obtain ⟨t, tK, tn⟩ : ∃ (t : finset G), ↑t ⊆ K ∧ t.card = n := K_inf.exists_subset_card_eq n,\n    have A : μ t ≤ μ K := measure_mono tK,\n    have B : μ t = n * μ {(1 : G)},\n    { rw ← bUnion_of_singleton ↑t,\n      change μ (⋃ (x ∈ t), {x}) = n * μ {1},\n      rw @measure_bUnion_finset G G _ μ t (λ i, {i}),\n      { simp only [tn, finset.sum_const, nsmul_eq_mul, haar_singleton] },\n      { assume x hx y hy xy,\n        simp only [on_fun, xy.symm, mem_singleton_iff, not_false_iff, disjoint_singleton_right] },\n      { assume b hb, exact measurable_set_singleton b } },\n    rw B at A,\n    rwa [ennreal.le_div_iff_mul_le _ (or.inr μKlt), mul_comm],\n    right,\n    apply ne_of_gt (haar_pos_of_nonempty_interior μ ⟨_, K_int⟩) },\n  have J : tendsto (λ (n : ℕ),  μ K / n) at_top (𝓝 (μ K / ∞)) :=\n    ennreal.tendsto.const_div ennreal.tendsto_nat_nhds_top (or.inr μKlt),\n  simp only [ennreal.div_top] at J,\n  exact ge_of_tendsto' J I,\nend\n\n/- The above instance applies in particular to show that an additive Haar measure on a nontrivial\nfinite-dimensional real vector space has no atom. -/\nexample {E : Type*} [normed_group E] [normed_space ℝ E] [nontrivial E] [finite_dimensional ℝ E]\n  [measurable_space E] [borel_space E] (μ : measure E) [is_add_haar_measure μ] :\n  has_no_atoms μ := by apply_instance\n\nend\n\nend measure\nend haar\n\nend measure_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/measure_theory/group/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.4582311418889623}}
{"text": "import tactic.interactive\n\ndef X := [1,2,3]\ndef g (n : ℕ) := [n, 7*n]\n\ndef Z : list ℕ :=\ndo x ← X,\n   y ← g x,\n   return y\n\n#eval Z\n-- set_option pp.notation false\n#print Z\n-- https://github.com/leanprover-community/mathlib/blob/master/docs/extras/tactic_writing.md\n\ndef h (n : ℕ) := if 2 ∣ n then some (n/2) else none\n\ndef Y (n : ℕ) :=\ndo n ← h n,\n   n ← h n,\n   n ← h n,\n   return n\n\n#eval Y 24\n#eval Y 12\n\ndef monad_list : monad list := by apply_instance\n#print monad_list\n#print list.monad\n\ndef option_monad : monad option :=\n{ pure := @option.some, bind := λ α β o f, match o with | none := none | some a := f a end, map := λ α β f o, match o with | none := none | some a := some (f a) end}\n\nexample : is_lawful_monad option :=\n{pure_bind := begin intros, refl, end,\n bind_assoc := begin intros, cases x,\n refl,\n refl, end}\n\ndef Z' : list ℕ :=\ndo x ← X,\n   y ← g x,\n   guard (3 ∣ y),\n   return y\n\n#eval Z'\n\n/-\nA monad is just a monoid object in the monoidal category\nof natural endomorphisms of a functor.\n\nTo a computer scientist, all functors are functors from Type to Type.\nα → list α is a functor. So is option\n-/\n\n/-\nA functor from C to D, takes objects of C to objects of D,\nand arrows in C to arrows in D, respecting all the structure \n(sources, targets, identities, compositions).\n\nA natural transformation from a function `F : C ⥤ D` to another `G : C ⥤ D`,\ncompares the values of `F` and `G`. That is, for each object `X : C`,\nit gives an arrow (in `D`) from `F.obj X` to `G.obj X`.\n\nIt satisfies a compatibility condition: for every arrow in `C`, `f : X ⟶ Y`.\nThen the two arrows F X  → F Y → G Y and F X → G X → G Y are equal:\n\n* GL_n is a functor from rings to groups under matrix multiplication. det is a\nnatural transformation from GL_n to GL_1, as factors Ring ⥤ Grp.\n\nA monad is a functor `T` from Type to Type, along with natural transformations\n`η : 1 ⟶ T` and `μ : TT ⟶ T`.\ni.e. for each Type α, the component of η at α is a function from α → T α (`pure`).\ni.e. for each Type α, the component of μ at α is a function from T T α → T α.\n-/\n\ndef state_ (σ : Type) (α : Type) := σ → σ × α\n\ninstance (σ : Type) : monad (state_ σ) :=\n{pure := λ α a s, (s, a),\n bind := λ α β f k s, \n begin have p := f s, clear s f, have q := k p.2, clear k, exact q p.1, end}\n\n#print tactic\nmeta def tactic_monad : monad tactic := by apply_instance\n#print tactic_monad\n\n#print interaction_monad.monad\n\nopen tactic\nmeta def swap' : tactic unit :=\ndo gs ← get_goals,\n   match gs with\n    | (a :: b :: rem) := set_goals (b :: a :: rem)\n    | _ := skip\n   end\n\nmeta def swap'' : tactic unit :=\ndo a :: b :: t ← get_goals | fail \"There must be at least two goals!\",\n   set_goals (b :: a :: t)\n\nexample : true :=\nbegin\n    success_if_fail {swap''},\n    trivial,\nend\n\nexample : true ∧ 1=1 :=\nbegin\n    split,\n    swap'',\n    refl,\n    trivial,\nend\n\nmeta def swap''' : tactic unit :=\ndo a :: b :: t ← get_goals | fail \"There must be at least two goals!\",\n   set_goals [b,a]\n\nexample : true ∧ true ∧ 1 = 2 :=\nbegin\n    (do result >>= trace),\n    split; [skip, split],\n    (do result >>= trace),\n    swap''',\n    (do result >>= trace),\n    trivial,\n    (do result >>= trace),\n    trivial,\n    (do result >>= trace),\n    -- :-) .... :-(\n    recover,\n    sorry,\nend\n\nmeta def show_locals : tactic unit :=\ndo ctx ← local_context,\n   trace ctx,\n   ctx.mmap infer_type >>= trace,\n   skip\n\nmeta def target' : tactic expr :=\ndo gs ← get_goals,\n   match gs with\n    | [] := fail \"No tactics left!\"\n    | (h :: rem) := infer_type h\nend\n\nmeta def try_0_on_all_goals : tactic unit :=\n`[all_goals {try {exact 0}}]\n\n#check unify\nmeta def try_0_on_all_goals' : tactic unit :=\ndo gs ← get_goals,\n   z ← to_expr ``(0 : ℕ),\n   trace gs,\n   gs.mmap' (λ g, try_core $ unify g z),\n   trace gs,\n   skip\n\nset_option pp.instantiate_mvars false\ndef bar : ℕ × ℕ × list ℤ :=\nbegin\n    split; [skip, split],\n    try_0_on_all_goals',\n    (do result >>= trace),\nend\n", "meta": {"author": "MartinSkilleter", "repo": "real_ip_spaces", "sha": "1ad1e0456602038711cbb0de7aa92b88d6eff06f", "save_path": "github-repos/lean/MartinSkilleter-real_ip_spaces", "path": "github-repos/lean/MartinSkilleter-real_ip_spaces/real_ip_spaces-1ad1e0456602038711cbb0de7aa92b88d6eff06f/src/10.04.2019/monads.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.4582311361988503}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Markus Himmel, Bhavik Mehta, Andrew Yang\n\n! This file was ported from Lean 3 source module category_theory.limits.shapes.pullbacks\n! leanprover-community/mathlib commit 7316286ff2942aa14e540add9058c6b0aa1c8070\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.CategoryTheory.Limits.Shapes.WidePullbacks\nimport Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts\n\n/-!\n# Pullbacks\n\nWe define a category `WalkingCospan` (resp. `WalkingSpan`), which is the index category\nfor the given data for a pullback (resp. pushout) diagram. Convenience methods `cospan f g`\nand `span f g` construct functors from the walking (co)span, hitting the given morphisms.\n\nWe define `pullback f g` and `pushout f g` as limits and colimits of such functors.\n\n## References\n* [Stacks: Fibre products](https://stacks.math.columbia.edu/tag/001U)\n* [Stacks: Pushouts](https://stacks.math.columbia.edu/tag/0025)\n-/\n\n\nnoncomputable section\n\nopen CategoryTheory\n\nnamespace CategoryTheory.Limits\n\nuniverse w v₁ v₂ v u u₂\n\n-- attribute [local tidy] tactic.case_bash Porting note: no tidy, no local\n\n/-- The type of objects for the diagram indexing a pullback, defined as a special case of\n`WidePullbackShape`. -/\nabbrev WalkingCospan : Type :=\n  WidePullbackShape WalkingPair\n#align category_theory.limits.walking_cospan CategoryTheory.Limits.WalkingCospan\n\n/-- The left point of the walking cospan. -/\n@[match_pattern]\nabbrev WalkingCospan.left : WalkingCospan :=\n  some WalkingPair.left\n#align category_theory.limits.walking_cospan.left CategoryTheory.Limits.WalkingCospan.left\n\n/-- The right point of the walking cospan. -/\n@[match_pattern]\nabbrev WalkingCospan.right : WalkingCospan :=\n  some WalkingPair.right\n#align category_theory.limits.walking_cospan.right CategoryTheory.Limits.WalkingCospan.right\n\n/-- The central point of the walking cospan. -/\n@[match_pattern]\nabbrev WalkingCospan.one : WalkingCospan :=\n  none\n#align category_theory.limits.walking_cospan.one CategoryTheory.Limits.WalkingCospan.one\n\n/-- The type of objects for the diagram indexing a pushout, defined as a special case of\n`WidePushoutShape`.\n-/\nabbrev WalkingSpan : Type :=\n  WidePushoutShape WalkingPair\n#align category_theory.limits.walking_span CategoryTheory.Limits.WalkingSpan\n\n/-- The left point of the walking span. -/\n@[match_pattern]\nabbrev WalkingSpan.left : WalkingSpan :=\n  some WalkingPair.left\n#align category_theory.limits.walking_span.left CategoryTheory.Limits.WalkingSpan.left\n\n/-- The right point of the walking span. -/\n@[match_pattern]\nabbrev WalkingSpan.right : WalkingSpan :=\n  some WalkingPair.right\n#align category_theory.limits.walking_span.right CategoryTheory.Limits.WalkingSpan.right\n\n/-- The central point of the walking span. -/\n@[match_pattern]\nabbrev WalkingSpan.zero : WalkingSpan :=\n  none\n#align category_theory.limits.walking_span.zero CategoryTheory.Limits.WalkingSpan.zero\n\nnamespace WalkingCospan\n\n/-- The type of arrows for the diagram indexing a pullback. -/\nabbrev Hom : WalkingCospan → WalkingCospan → Type :=\n  WidePullbackShape.Hom\n#align category_theory.limits.walking_cospan.hom CategoryTheory.Limits.WalkingCospan.Hom\n\n/-- The left arrow of the walking cospan. -/\n@[match_pattern]\nabbrev Hom.inl : left ⟶ one :=\n  WidePullbackShape.Hom.term _\n#align category_theory.limits.walking_cospan.hom.inl CategoryTheory.Limits.WalkingCospan.Hom.inl\n\n/-- The right arrow of the walking cospan. -/\n@[match_pattern]\nabbrev Hom.inr : right ⟶ one :=\n  WidePullbackShape.Hom.term _\n#align category_theory.limits.walking_cospan.hom.inr CategoryTheory.Limits.WalkingCospan.Hom.inr\n\n/-- The identity arrows of the walking cospan. -/\n@[match_pattern]\nabbrev Hom.id (X : WalkingCospan) : X ⟶ X :=\n  WidePullbackShape.Hom.id X\n#align category_theory.limits.walking_cospan.hom.id CategoryTheory.Limits.WalkingCospan.Hom.id\n\ninstance (X Y : WalkingCospan) : Subsingleton (X ⟶ Y) := by constructor; intros; simp\n\nend WalkingCospan\n\nnamespace WalkingSpan\n\n/-- The type of arrows for the diagram indexing a pushout. -/\nabbrev Hom : WalkingSpan → WalkingSpan → Type :=\n  WidePushoutShape.Hom\n#align category_theory.limits.walking_span.hom CategoryTheory.Limits.WalkingSpan.Hom\n\n/-- The left arrow of the walking span. -/\n@[match_pattern]\nabbrev Hom.fst : zero ⟶ left :=\n  WidePushoutShape.Hom.init _\n#align category_theory.limits.walking_span.hom.fst CategoryTheory.Limits.WalkingSpan.Hom.fst\n\n/-- The right arrow of the walking span. -/\n@[match_pattern]\nabbrev Hom.snd : zero ⟶ right :=\n  WidePushoutShape.Hom.init _\n#align category_theory.limits.walking_span.hom.snd CategoryTheory.Limits.WalkingSpan.Hom.snd\n\n/-- The identity arrows of the walking span. -/\n@[match_pattern]\nabbrev Hom.id (X : WalkingSpan) : X ⟶ X :=\n  WidePushoutShape.Hom.id X\n#align category_theory.limits.walking_span.hom.id CategoryTheory.Limits.WalkingSpan.Hom.id\n\ninstance (X Y : WalkingSpan) : Subsingleton (X ⟶ Y) := by constructor; intros a b; simp\n\nend WalkingSpan\n\nopen WalkingSpan.Hom WalkingCospan.Hom WidePullbackShape.Hom WidePushoutShape.Hom\n\nvariable {C : Type u} [Category.{v} C]\n\n/-- To construct an isomorphism of cones over the walking cospan,\nit suffices to construct an isomorphism\nof the cone points and check it commutes with the legs to `left` and `right`. -/\ndef WalkingCospan.ext {F : WalkingCospan ⥤ C} {s t : Cone F} (i : s.pt ≅ t.pt)\n    (w₁ : s.π.app WalkingCospan.left = i.hom ≫ t.π.app WalkingCospan.left)\n    (w₂ : s.π.app WalkingCospan.right = i.hom ≫ t.π.app WalkingCospan.right) : s ≅ t := by\n  apply Cones.ext i\n  rintro (⟨⟩ | ⟨⟨⟩⟩)\n  · have h₁ := s.π.naturality WalkingCospan.Hom.inl\n    dsimp at h₁\n    simp only [Category.id_comp] at h₁\n    have h₂ := t.π.naturality WalkingCospan.Hom.inl\n    dsimp at h₂\n    simp only [Category.id_comp] at h₂\n    simp_rw [h₂, ← Category.assoc, ← w₁, ← h₁]\n  · exact w₁\n  · exact w₂\n#align category_theory.limits.walking_cospan.ext CategoryTheory.Limits.WalkingCospan.ext\n\n/-- To construct an isomorphism of cocones over the walking span,\nit suffices to construct an isomorphism\nof the cocone points and check it commutes with the legs from `left` and `right`. -/\ndef WalkingSpan.ext {F : WalkingSpan ⥤ C} {s t : Cocone F} (i : s.pt ≅ t.pt)\n    (w₁ : s.ι.app WalkingCospan.left ≫ i.hom = t.ι.app WalkingCospan.left)\n    (w₂ : s.ι.app WalkingCospan.right ≫ i.hom = t.ι.app WalkingCospan.right) : s ≅ t := by\n  apply Cocones.ext i\n  rintro (⟨⟩ | ⟨⟨⟩⟩)\n  · have h₁ := s.ι.naturality WalkingSpan.Hom.fst\n    dsimp at h₁\n    simp only [Category.comp_id] at h₁\n    have h₂ := t.ι.naturality WalkingSpan.Hom.fst\n    dsimp at h₂\n    simp only [Category.comp_id] at h₂\n    simp_rw [← h₁, Category.assoc, w₁, h₂]\n  · exact w₁\n  · exact w₂\n#align category_theory.limits.walking_span.ext CategoryTheory.Limits.WalkingSpan.ext\n\n/-- `cospan f g` is the functor from the walking cospan hitting `f` and `g`. -/\ndef cospan {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : WalkingCospan ⥤ C :=\n  WidePullbackShape.wideCospan Z (fun j => WalkingPair.casesOn j X Y) fun j =>\n    WalkingPair.casesOn j f g\n#align category_theory.limits.cospan CategoryTheory.Limits.cospan\n\n/-- `span f g` is the functor from the walking span hitting `f` and `g`. -/\ndef span {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : WalkingSpan ⥤ C :=\n  WidePushoutShape.wideSpan X (fun j => WalkingPair.casesOn j Y Z) fun j =>\n    WalkingPair.casesOn j f g\n#align category_theory.limits.span CategoryTheory.Limits.span\n\n@[simp]\ntheorem cospan_left {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (cospan f g).obj WalkingCospan.left = X :=\n  rfl\n#align category_theory.limits.cospan_left CategoryTheory.Limits.cospan_left\n\n@[simp]\ntheorem span_left {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).obj WalkingSpan.left = Y :=\n  rfl\n#align category_theory.limits.span_left CategoryTheory.Limits.span_left\n\n@[simp]\ntheorem cospan_right {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n    (cospan f g).obj WalkingCospan.right = Y := rfl\n#align category_theory.limits.cospan_right CategoryTheory.Limits.cospan_right\n\n@[simp]\ntheorem span_right {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).obj WalkingSpan.right = Z :=\n  rfl\n#align category_theory.limits.span_right CategoryTheory.Limits.span_right\n\n@[simp]\ntheorem cospan_one {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (cospan f g).obj WalkingCospan.one = Z :=\n  rfl\n#align category_theory.limits.cospan_one CategoryTheory.Limits.cospan_one\n\n@[simp]\ntheorem span_zero {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).obj WalkingSpan.zero = X :=\n  rfl\n#align category_theory.limits.span_zero CategoryTheory.Limits.span_zero\n\n@[simp]\ntheorem cospan_map_inl {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n    (cospan f g).map WalkingCospan.Hom.inl = f := rfl\n#align category_theory.limits.cospan_map_inl CategoryTheory.Limits.cospan_map_inl\n\n@[simp]\ntheorem span_map_fst {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).map WalkingSpan.Hom.fst = f :=\n  rfl\n#align category_theory.limits.span_map_fst CategoryTheory.Limits.span_map_fst\n\n@[simp]\ntheorem cospan_map_inr {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n    (cospan f g).map WalkingCospan.Hom.inr = g := rfl\n#align category_theory.limits.cospan_map_inr CategoryTheory.Limits.cospan_map_inr\n\n@[simp]\ntheorem span_map_snd {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).map WalkingSpan.Hom.snd = g :=\n  rfl\n#align category_theory.limits.span_map_snd CategoryTheory.Limits.span_map_snd\n\ntheorem cospan_map_id {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (w : WalkingCospan) :\n    (cospan f g).map (WalkingCospan.Hom.id w) = 𝟙 _ := rfl\n#align category_theory.limits.cospan_map_id CategoryTheory.Limits.cospan_map_id\n\ntheorem span_map_id {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) (w : WalkingSpan) :\n    (span f g).map (WalkingSpan.Hom.id w) = 𝟙 _ := rfl\n#align category_theory.limits.span_map_id CategoryTheory.Limits.span_map_id\n\n/-- Every diagram indexing an pullback is naturally isomorphic (actually, equal) to a `cospan` -/\n-- @[simps (config := { rhsMd := semireducible })]  Porting note: no semireducible\n@[simps!]\ndef diagramIsoCospan (F : WalkingCospan ⥤ C) : F ≅ cospan (F.map inl) (F.map inr) :=\n  NatIso.ofComponents\n  (fun j => eqToIso (by rcases j with (⟨⟩ | ⟨⟨⟩⟩) <;> rfl))\n  (by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)\n#align category_theory.limits.diagram_iso_cospan CategoryTheory.Limits.diagramIsoCospan\n\n/-- Every diagram indexing a pushout is naturally isomorphic (actually, equal) to a `span` -/\n-- @[simps (config := { rhsMd := semireducible })]  Porting note: no semireducible\n@[simps!]\ndef diagramIsoSpan (F : WalkingSpan ⥤ C) : F ≅ span (F.map fst) (F.map snd) :=\n  NatIso.ofComponents\n  (fun j => eqToIso (by rcases j with (⟨⟩ | ⟨⟨⟩⟩) <;> rfl))\n  (by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)\n#align category_theory.limits.diagram_iso_span CategoryTheory.Limits.diagramIsoSpan\n\nvariable {D : Type u₂} [Category.{v₂} D]\n\n/-- A functor applied to a cospan is a cospan. -/\ndef cospanCompIso (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n    cospan f g ⋙ F ≅ cospan (F.map f) (F.map g) :=\n  NatIso.ofComponents (by rintro (⟨⟩ | ⟨⟨⟩⟩) <;> exact Iso.refl _)\n    (by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)\n#align category_theory.limits.cospan_comp_iso CategoryTheory.Limits.cospanCompIso\n\nsection\n\nvariable (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n\n@[simp]\ntheorem cospanCompIso_app_left : (cospanCompIso F f g).app WalkingCospan.left = Iso.refl _ := rfl\n#align category_theory.limits.cospan_comp_iso_app_left CategoryTheory.Limits.cospanCompIso_app_left\n\n@[simp]\ntheorem cospanCompIso_app_right : (cospanCompIso F f g).app WalkingCospan.right = Iso.refl _ :=\n  rfl\n#align category_theory.limits.cospan_comp_iso_app_right CategoryTheory.Limits.cospanCompIso_app_right\n\n@[simp]\ntheorem cospanCompIso_app_one : (cospanCompIso F f g).app WalkingCospan.one = Iso.refl _ := rfl\n#align category_theory.limits.cospan_comp_iso_app_one CategoryTheory.Limits.cospanCompIso_app_one\n\n@[simp]\ntheorem cospanCompIso_hom_app_left : (cospanCompIso F f g).hom.app WalkingCospan.left = 𝟙 _ :=\n  rfl\n#align category_theory.limits.cospan_comp_iso_hom_app_left CategoryTheory.Limits.cospanCompIso_hom_app_left\n\n@[simp]\ntheorem cospanCompIso_hom_app_right : (cospanCompIso F f g).hom.app WalkingCospan.right = 𝟙 _ :=\n  rfl\n#align category_theory.limits.cospan_comp_iso_hom_app_right CategoryTheory.Limits.cospanCompIso_hom_app_right\n\n@[simp]\ntheorem cospanCompIso_hom_app_one : (cospanCompIso F f g).hom.app WalkingCospan.one = 𝟙 _ := rfl\n#align category_theory.limits.cospan_comp_iso_hom_app_one CategoryTheory.Limits.cospanCompIso_hom_app_one\n\n@[simp]\ntheorem cospanCompIso_inv_app_left : (cospanCompIso F f g).inv.app WalkingCospan.left = 𝟙 _ :=\n  rfl\n#align category_theory.limits.cospan_comp_iso_inv_app_left CategoryTheory.Limits.cospanCompIso_inv_app_left\n\n@[simp]\ntheorem cospanCompIso_inv_app_right : (cospanCompIso F f g).inv.app WalkingCospan.right = 𝟙 _ :=\n  rfl\n#align category_theory.limits.cospan_comp_iso_inv_app_right CategoryTheory.Limits.cospanCompIso_inv_app_right\n\n@[simp]\ntheorem cospanCompIso_inv_app_one : (cospanCompIso F f g).inv.app WalkingCospan.one = 𝟙 _ := rfl\n#align category_theory.limits.cospan_comp_iso_inv_app_one CategoryTheory.Limits.cospanCompIso_inv_app_one\n\nend\n\n/-- A functor applied to a span is a span. -/\ndef spanCompIso (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :\n    span f g ⋙ F ≅ span (F.map f) (F.map g) :=\n  NatIso.ofComponents (by rintro (⟨⟩ | ⟨⟨⟩⟩) <;> exact Iso.refl _)\n    (by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)\n#align category_theory.limits.span_comp_iso CategoryTheory.Limits.spanCompIso\n\nsection\n\nvariable (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)\n\n@[simp]\ntheorem spanCompIso_app_left : (spanCompIso F f g).app WalkingSpan.left = Iso.refl _ := rfl\n#align category_theory.limits.span_comp_iso_app_left CategoryTheory.Limits.spanCompIso_app_left\n\n@[simp]\ntheorem spanCompIso_app_right : (spanCompIso F f g).app WalkingSpan.right = Iso.refl _ := rfl\n#align category_theory.limits.span_comp_iso_app_right CategoryTheory.Limits.spanCompIso_app_right\n\n@[simp]\ntheorem spanCompIso_app_zero : (spanCompIso F f g).app WalkingSpan.zero = Iso.refl _ := rfl\n#align category_theory.limits.span_comp_iso_app_zero CategoryTheory.Limits.spanCompIso_app_zero\n\n@[simp]\ntheorem spanCompIso_hom_app_left : (spanCompIso F f g).hom.app WalkingSpan.left = 𝟙 _ := rfl\n#align category_theory.limits.span_comp_iso_hom_app_left CategoryTheory.Limits.spanCompIso_hom_app_left\n\n@[simp]\ntheorem spanCompIso_hom_app_right : (spanCompIso F f g).hom.app WalkingSpan.right = 𝟙 _ := rfl\n#align category_theory.limits.span_comp_iso_hom_app_right CategoryTheory.Limits.spanCompIso_hom_app_right\n\n@[simp]\ntheorem spanCompIso_hom_app_zero : (spanCompIso F f g).hom.app WalkingSpan.zero = 𝟙 _ := rfl\n#align category_theory.limits.span_comp_iso_hom_app_zero CategoryTheory.Limits.spanCompIso_hom_app_zero\n\n@[simp]\ntheorem spanCompIso_inv_app_left : (spanCompIso F f g).inv.app WalkingSpan.left = 𝟙 _ := rfl\n#align category_theory.limits.span_comp_iso_inv_app_left CategoryTheory.Limits.spanCompIso_inv_app_left\n\n@[simp]\ntheorem spanCompIso_inv_app_right : (spanCompIso F f g).inv.app WalkingSpan.right = 𝟙 _ := rfl\n#align category_theory.limits.span_comp_iso_inv_app_right CategoryTheory.Limits.spanCompIso_inv_app_right\n\n@[simp]\ntheorem spanCompIso_inv_app_zero : (spanCompIso F f g).inv.app WalkingSpan.zero = 𝟙 _ := rfl\n#align category_theory.limits.span_comp_iso_inv_app_zero CategoryTheory.Limits.spanCompIso_inv_app_zero\n\nend\n\nsection\n\nvariable {X Y Z X' Y' Z' : C} (iX : X ≅ X') (iY : Y ≅ Y') (iZ : Z ≅ Z')\n\nsection\n\nvariable {f : X ⟶ Z} {g : Y ⟶ Z} {f' : X' ⟶ Z'} {g' : Y' ⟶ Z'}\n\n/-- Construct an isomorphism of cospans from components. -/\ndef cospanExt (wf : iX.hom ≫ f' = f ≫ iZ.hom) (wg : iY.hom ≫ g' = g ≫ iZ.hom) :\n    cospan f g ≅ cospan f' g' :=\n  NatIso.ofComponents\n    (by rintro (⟨⟩ | ⟨⟨⟩⟩); exacts [iZ, iX, iY])\n    (by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp [wf, wg])\n#align category_theory.limits.cospan_ext CategoryTheory.Limits.cospanExt\n\nvariable (wf : iX.hom ≫ f' = f ≫ iZ.hom) (wg : iY.hom ≫ g' = g ≫ iZ.hom)\n\n@[simp]\ntheorem cospanExt_app_left : (cospanExt iX iY iZ wf wg).app WalkingCospan.left = iX := by\n  dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_app_left CategoryTheory.Limits.cospanExt_app_left\n\n@[simp]\ntheorem cospanExt_app_right : (cospanExt iX iY iZ wf wg).app WalkingCospan.right = iY := by\n  dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_app_right CategoryTheory.Limits.cospanExt_app_right\n\n@[simp]\ntheorem cospanExt_app_one : (cospanExt iX iY iZ wf wg).app WalkingCospan.one = iZ := by\n  dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_app_one CategoryTheory.Limits.cospanExt_app_one\n\n@[simp]\ntheorem cospanExt_hom_app_left : (cospanExt iX iY iZ wf wg).hom.app WalkingCospan.left = iX.hom :=\n  by dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_hom_app_left CategoryTheory.Limits.cospanExt_hom_app_left\n\n@[simp]\ntheorem cospanExt_hom_app_right : (cospanExt iX iY iZ wf wg).hom.app WalkingCospan.right = iY.hom :=\n  by dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_hom_app_right CategoryTheory.Limits.cospanExt_hom_app_right\n\n@[simp]\ntheorem cospanExt_hom_app_one : (cospanExt iX iY iZ wf wg).hom.app WalkingCospan.one = iZ.hom := by\n  dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_hom_app_one CategoryTheory.Limits.cospanExt_hom_app_one\n\n@[simp]\ntheorem cospanExt_inv_app_left : (cospanExt iX iY iZ wf wg).inv.app WalkingCospan.left = iX.inv :=\n  by dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_inv_app_left CategoryTheory.Limits.cospanExt_inv_app_left\n\n@[simp]\ntheorem cospanExt_inv_app_right : (cospanExt iX iY iZ wf wg).inv.app WalkingCospan.right = iY.inv :=\n  by dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_inv_app_right CategoryTheory.Limits.cospanExt_inv_app_right\n\n@[simp]\ntheorem cospanExt_inv_app_one : (cospanExt iX iY iZ wf wg).inv.app WalkingCospan.one = iZ.inv := by\n  dsimp [cospanExt]\n#align category_theory.limits.cospan_ext_inv_app_one CategoryTheory.Limits.cospanExt_inv_app_one\n\nend\n\nsection\n\nvariable {f : X ⟶ Y} {g : X ⟶ Z} {f' : X' ⟶ Y'} {g' : X' ⟶ Z'}\n\n/-- Construct an isomorphism of spans from components. -/\ndef spanExt (wf : iX.hom ≫ f' = f ≫ iY.hom) (wg : iX.hom ≫ g' = g ≫ iZ.hom) :\n    span f g ≅ span f' g' :=\n  NatIso.ofComponents (by rintro (⟨⟩ | ⟨⟨⟩⟩); exacts [iX, iY, iZ])\n    (by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp [wf, wg])\n#align category_theory.limits.span_ext CategoryTheory.Limits.spanExt\n\nvariable (wf : iX.hom ≫ f' = f ≫ iY.hom) (wg : iX.hom ≫ g' = g ≫ iZ.hom)\n\n@[simp]\ntheorem spanExt_app_left : (spanExt iX iY iZ wf wg).app WalkingSpan.left = iY := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_app_left CategoryTheory.Limits.spanExt_app_left\n\n@[simp]\ntheorem spanExt_app_right : (spanExt iX iY iZ wf wg).app WalkingSpan.right = iZ := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_app_right CategoryTheory.Limits.spanExt_app_right\n\n@[simp]\ntheorem spanExt_app_one : (spanExt iX iY iZ wf wg).app WalkingSpan.zero = iX := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_app_one CategoryTheory.Limits.spanExt_app_one\n\n@[simp]\ntheorem spanExt_hom_app_left : (spanExt iX iY iZ wf wg).hom.app WalkingSpan.left = iY.hom := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_hom_app_left CategoryTheory.Limits.spanExt_hom_app_left\n\n@[simp]\ntheorem spanExt_hom_app_right : (spanExt iX iY iZ wf wg).hom.app WalkingSpan.right = iZ.hom := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_hom_app_right CategoryTheory.Limits.spanExt_hom_app_right\n\n@[simp]\ntheorem spanExt_hom_app_zero : (spanExt iX iY iZ wf wg).hom.app WalkingSpan.zero = iX.hom := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_hom_app_zero CategoryTheory.Limits.spanExt_hom_app_zero\n\n@[simp]\ntheorem spanExt_inv_app_left : (spanExt iX iY iZ wf wg).inv.app WalkingSpan.left = iY.inv := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_inv_app_left CategoryTheory.Limits.spanExt_inv_app_left\n\n@[simp]\ntheorem spanExt_inv_app_right : (spanExt iX iY iZ wf wg).inv.app WalkingSpan.right = iZ.inv := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_inv_app_right CategoryTheory.Limits.spanExt_inv_app_right\n\n@[simp]\ntheorem spanExt_inv_app_zero : (spanExt iX iY iZ wf wg).inv.app WalkingSpan.zero = iX.inv := by\n  dsimp [spanExt]\n#align category_theory.limits.span_ext_inv_app_zero CategoryTheory.Limits.spanExt_inv_app_zero\n\nend\n\nend\n\nvariable {W X Y Z : C}\n\n/-- A pullback cone is just a cone on the cospan formed by two morphisms `f : X ⟶ Z` and\n    `g : Y ⟶ Z`.-/\nabbrev PullbackCone (f : X ⟶ Z) (g : Y ⟶ Z) :=\n  Cone (cospan f g)\n#align category_theory.limits.pullback_cone CategoryTheory.Limits.PullbackCone\n\nnamespace PullbackCone\n\nvariable {f : X ⟶ Z} {g : Y ⟶ Z}\n\n/-- The first projection of a pullback cone. -/\nabbrev fst (t : PullbackCone f g) : t.pt ⟶ X :=\n  t.π.app WalkingCospan.left\n#align category_theory.limits.pullback_cone.fst CategoryTheory.Limits.PullbackCone.fst\n\n/-- The second projection of a pullback cone. -/\nabbrev snd (t : PullbackCone f g) : t.pt ⟶ Y :=\n  t.π.app WalkingCospan.right\n#align category_theory.limits.pullback_cone.snd CategoryTheory.Limits.PullbackCone.snd\n\n@[simp]\ntheorem π_app_left (c : PullbackCone f g) : c.π.app WalkingCospan.left = c.fst := rfl\n#align category_theory.limits.pullback_cone.π_app_left CategoryTheory.Limits.PullbackCone.π_app_left\n\n@[simp]\ntheorem π_app_right (c : PullbackCone f g) : c.π.app WalkingCospan.right = c.snd := rfl\n#align category_theory.limits.pullback_cone.π_app_right CategoryTheory.Limits.PullbackCone.π_app_right\n\n@[simp]\ntheorem condition_one (t : PullbackCone f g) : t.π.app WalkingCospan.one = t.fst ≫ f := by\n  have w := t.π.naturality WalkingCospan.Hom.inl\n  dsimp at w; simpa using w\n#align category_theory.limits.pullback_cone.condition_one CategoryTheory.Limits.PullbackCone.condition_one\n\n/-- This is a slightly more convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content -/\ndef isLimitAux (t : PullbackCone f g) (lift : ∀ s : PullbackCone f g, s.pt ⟶ t.pt)\n    (fac_left : ∀ s : PullbackCone f g, lift s ≫ t.fst = s.fst)\n    (fac_right : ∀ s : PullbackCone f g, lift s ≫ t.snd = s.snd)\n    (uniq : ∀ (s : PullbackCone f g) (m : s.pt ⟶ t.pt)\n      (_ : ∀ j : WalkingCospan, m ≫ t.π.app j = s.π.app j), m = lift s) : IsLimit t :=\n  { lift\n    fac := fun s j => Option.casesOn j (by\n        rw [← s.w inl, ← t.w inl, ← Category.assoc]\n        congr\n        exact fac_left s)\n      fun j' => WalkingPair.casesOn j' (fac_left s) (fac_right s)\n    uniq := uniq }\n#align category_theory.limits.pullback_cone.is_limit_aux CategoryTheory.Limits.PullbackCone.isLimitAux\n\n/-- This is another convenient method to verify that a pullback cone is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef isLimitAux' (t : PullbackCone f g)\n    (create :\n      ∀ s : PullbackCone f g,\n        { l //\n          l ≫ t.fst = s.fst ∧\n            l ≫ t.snd = s.snd ∧ ∀ {m}, m ≫ t.fst = s.fst → m ≫ t.snd = s.snd → m = l }) :\n    Limits.IsLimit t :=\n  PullbackCone.isLimitAux t (fun s => (create s).1) (fun s => (create s).2.1)\n    (fun s => (create s).2.2.1) fun s _ w =>\n    (create s).2.2.2 (w WalkingCospan.left) (w WalkingCospan.right)\n#align category_theory.limits.pullback_cone.is_limit_aux' CategoryTheory.Limits.PullbackCone.isLimitAux'\n\n/-- A pullback cone on `f` and `g` is determined by morphisms `fst : W ⟶ X` and `snd : W ⟶ Y`\n    such that `fst ≫ f = snd ≫ g`. -/\n@[simps]\ndef mk {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : PullbackCone f g where\n  pt := W\n  π := { app := fun j => Option.casesOn j (fst ≫ f) fun j' => WalkingPair.casesOn j' fst snd\n         naturality := by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) j <;> cases j <;> dsimp <;> simp [eq] }\n#align category_theory.limits.pullback_cone.mk CategoryTheory.Limits.PullbackCone.mk\n\n@[simp]\ntheorem mk_π_app_left {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    (mk fst snd eq).π.app WalkingCospan.left = fst := rfl\n#align category_theory.limits.pullback_cone.mk_π_app_left CategoryTheory.Limits.PullbackCone.mk_π_app_left\n\n@[simp]\ntheorem mk_π_app_right {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    (mk fst snd eq).π.app WalkingCospan.right = snd := rfl\n#align category_theory.limits.pullback_cone.mk_π_app_right CategoryTheory.Limits.PullbackCone.mk_π_app_right\n\n@[simp]\ntheorem mk_π_app_one {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    (mk fst snd eq).π.app WalkingCospan.one = fst ≫ f := rfl\n#align category_theory.limits.pullback_cone.mk_π_app_one CategoryTheory.Limits.PullbackCone.mk_π_app_one\n\n@[simp]\ntheorem mk_fst {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    (mk fst snd eq).fst = fst := rfl\n#align category_theory.limits.pullback_cone.mk_fst CategoryTheory.Limits.PullbackCone.mk_fst\n\n@[simp]\ntheorem mk_snd {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :\n    (mk fst snd eq).snd = snd := rfl\n#align category_theory.limits.pullback_cone.mk_snd CategoryTheory.Limits.PullbackCone.mk_snd\n\n@[reassoc]\ntheorem condition (t : PullbackCone f g) : fst t ≫ f = snd t ≫ g :=\n  (t.w inl).trans (t.w inr).symm\n#align category_theory.limits.pullback_cone.condition CategoryTheory.Limits.PullbackCone.condition\n\n/-- To check whether a morphism is equalized by the maps of a pullback cone, it suffices to check\n  it for `fst t` and `snd t` -/\ntheorem equalizer_ext (t : PullbackCone f g) {W : C} {k l : W ⟶ t.pt} (h₀ : k ≫ fst t = l ≫ fst t)\n    (h₁ : k ≫ snd t = l ≫ snd t) : ∀ j : WalkingCospan, k ≫ t.π.app j = l ≫ t.π.app j\n  | some WalkingPair.left => h₀\n  | some WalkingPair.right => h₁\n  | none => by rw [← t.w inl]; dsimp [h₀]; simp only [← Category.assoc, congrArg (· ≫ f) h₀]\n#align category_theory.limits.pullback_cone.equalizer_ext CategoryTheory.Limits.PullbackCone.equalizer_ext\n\ntheorem IsLimit.hom_ext {t : PullbackCone f g} (ht : IsLimit t) {W : C} {k l : W ⟶ t.pt}\n    (h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) : k = l :=\n  ht.hom_ext <| equalizer_ext _ h₀ h₁\n#align category_theory.limits.pullback_cone.is_limit.hom_ext CategoryTheory.Limits.PullbackCone.IsLimit.hom_ext\n\ntheorem mono_snd_of_is_pullback_of_mono {t : PullbackCone f g} (ht : IsLimit t) [Mono f] :\n    Mono t.snd := by\n  refine ⟨fun {W} h k i => IsLimit.hom_ext ht ?_ i⟩\n  rw [← cancel_mono f, Category.assoc, Category.assoc, condition]\n  have := congrArg (· ≫ g) i; dsimp at this\n  rwa [Category.assoc, Category.assoc] at this\n#align category_theory.limits.pullback_cone.mono_snd_of_is_pullback_of_mono CategoryTheory.Limits.PullbackCone.mono_snd_of_is_pullback_of_mono\n\ntheorem mono_fst_of_is_pullback_of_mono {t : PullbackCone f g} (ht : IsLimit t) [Mono g] :\n    Mono t.fst := by\n  refine ⟨fun {W} h k i => IsLimit.hom_ext ht i ?_⟩\n  rw [← cancel_mono g, Category.assoc, Category.assoc, ←condition]\n  have := congrArg (· ≫ f) i; dsimp at this\n  rwa [Category.assoc, Category.assoc] at this\n#align category_theory.limits.pullback_cone.mono_fst_of_is_pullback_of_mono CategoryTheory.Limits.PullbackCone.mono_fst_of_is_pullback_of_mono\n\n/-- To construct an isomorphism of pullback cones, it suffices to construct an isomorphism\nof the cone points and check it commutes with `fst` and `snd`. -/\ndef ext {s t : PullbackCone f g} (i : s.pt ≅ t.pt) (w₁ : s.fst = i.hom ≫ t.fst)\n    (w₂ : s.snd = i.hom ≫ t.snd) : s ≅ t :=\n  WalkingCospan.ext i w₁ w₂\n#align category_theory.limits.pullback_cone.ext CategoryTheory.Limits.PullbackCone.ext\n\n-- porting note: `IsLimit.lift` and the two following simp lemmas were introduced to ease the port\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W ⟶ X` and `k : W ⟶ Y` are such that\n    `h ≫ f = k ≫ g`, then we get `l : W ⟶ t.pt`, which satisfies `l ≫ fst t = h`\n    and `l ≫ snd t = k`, see `IsLimit.lift_fst` and `IsLimit.lift_snd`. -/\ndef IsLimit.lift {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)\n    (w : h ≫ f = k ≫ g) : W ⟶ t.pt :=\n  ht.lift <| PullbackCone.mk _ _ w\n\n@[reassoc (attr := simp)]\nlemma IsLimit.lift_fst {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)\n    (w : h ≫ f = k ≫ g) : IsLimit.lift ht h k w ≫ fst t = h := ht.fac _ _\n\n@[reassoc (attr := simp)]\nlemma IsLimit.lift_snd {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)\n    (w : h ≫ f = k ≫ g) : IsLimit.lift ht h k w ≫ snd t = k := ht.fac _ _\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W ⟶ X` and `k : W ⟶ Y` are such that\n    `h ≫ f = k ≫ g`, then we have `l : W ⟶ t.pt` satisfying `l ≫ fst t = h` and `l ≫ snd t = k`.\n    -/\ndef IsLimit.lift' {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)\n    (w : h ≫ f = k ≫ g) : { l : W ⟶ t.pt // l ≫ fst t = h ∧ l ≫ snd t = k } :=\n  ⟨IsLimit.lift ht h k w, by simp⟩\n#align category_theory.limits.pullback_cone.is_limit.lift' CategoryTheory.Limits.PullbackCone.IsLimit.lift'\n\n/-- This is a more convenient formulation to show that a `PullbackCone` constructed using\n`PullbackCone.mk` is a limit cone.\n-/\ndef IsLimit.mk {W : C} {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g)\n    (lift : ∀ s : PullbackCone f g, s.pt ⟶ W)\n    (fac_left : ∀ s : PullbackCone f g, lift s ≫ fst = s.fst)\n    (fac_right : ∀ s : PullbackCone f g, lift s ≫ snd = s.snd)\n    (uniq :\n      ∀ (s : PullbackCone f g) (m : s.pt ⟶ W) (_ : m ≫ fst = s.fst) (_ : m ≫ snd = s.snd),\n        m = lift s) :\n    IsLimit (mk fst snd eq) :=\n  isLimitAux _ lift fac_left fac_right fun s m w =>\n    uniq s m (w WalkingCospan.left) (w WalkingCospan.right)\n#align category_theory.limits.pullback_cone.is_limit.mk CategoryTheory.Limits.PullbackCone.IsLimit.mk\n\n/-- The flip of a pullback square is a pullback square. -/\ndef flipIsLimit {W : C} {h : W ⟶ X} {k : W ⟶ Y} {comm : h ≫ f = k ≫ g}\n    (t : IsLimit (mk _ _ comm.symm)) : IsLimit (mk _ _ comm) :=\n  isLimitAux' _ fun s =>\n    by\n    refine'\n      ⟨(IsLimit.lift' t _ _ s.condition.symm).1, (IsLimit.lift' t _ _ _).2.2,\n        (IsLimit.lift' t _ _ _).2.1, fun m₁ m₂ => t.hom_ext _⟩\n    apply (mk k h _).equalizer_ext\n    · rwa [(IsLimit.lift' t _ _ _).2.1]\n    · rwa [(IsLimit.lift' t _ _ _).2.2]\n#align category_theory.limits.pullback_cone.flip_is_limit CategoryTheory.Limits.PullbackCone.flipIsLimit\n\n/--\nThe pullback cone `(𝟙 X, 𝟙 X)` for the pair `(f, f)` is a limit if `f` is a mono. The converse is\nshown in `mono_of_pullback_is_id`.\n-/\ndef isLimitMkIdId (f : X ⟶ Y) [Mono f] : IsLimit (mk (𝟙 X) (𝟙 X) rfl : PullbackCone f f) :=\n  IsLimit.mk _ (fun s => s.fst) (fun s => Category.comp_id _)\n    (fun s => by rw [← cancel_mono f, Category.comp_id, s.condition]) fun s m m₁ _ => by\n    simpa using m₁\n#align category_theory.limits.pullback_cone.is_limit_mk_id_id CategoryTheory.Limits.PullbackCone.isLimitMkIdId\n\n/--\n`f` is a mono if the pullback cone `(𝟙 X, 𝟙 X)` is a limit for the pair `(f, f)`. The converse is\ngiven in `PullbackCone.is_id_of_mono`.\n-/\ntheorem mono_of_isLimitMkIdId (f : X ⟶ Y) (t : IsLimit (mk (𝟙 X) (𝟙 X) rfl : PullbackCone f f)) :\n    Mono f :=\n  ⟨fun {Z} g h eq => by\n    rcases PullbackCone.IsLimit.lift' t _ _ eq with ⟨_, rfl, rfl⟩\n    rfl⟩\n#align category_theory.limits.pullback_cone.mono_of_is_limit_mk_id_id CategoryTheory.Limits.PullbackCone.mono_of_isLimitMkIdId\n\n/-- Suppose `f` and `g` are two morphisms with a common codomain and `s` is a limit cone over the\n    diagram formed by `f` and `g`. Suppose `f` and `g` both factor through a monomorphism `h` via\n    `x` and `y`, respectively.  Then `s` is also a limit cone over the diagram formed by `x` and\n    `y`.  -/\ndef isLimitOfFactors (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ Z) [Mono h] (x : X ⟶ W) (y : Y ⟶ W)\n    (hxh : x ≫ h = f) (hyh : y ≫ h = g) (s : PullbackCone f g) (hs : IsLimit s) :\n    IsLimit\n      (PullbackCone.mk _ _\n        (show s.fst ≫ x = s.snd ≫ y from\n          (cancel_mono h).1 <| by simp only [Category.assoc, hxh, hyh, s.condition])) :=\n  PullbackCone.isLimitAux' _ fun t =>\n    have : fst t ≫ x ≫ h = snd t ≫ y ≫ h := by  -- Porting note: reassoc workaround\n      rw [← Category.assoc, ← Category.assoc]\n      apply congrArg (· ≫ h) t.condition\n    ⟨hs.lift (PullbackCone.mk t.fst t.snd <| by rw [← hxh, ← hyh, this]),\n      ⟨hs.fac _ WalkingCospan.left, hs.fac _ WalkingCospan.right, fun hr hr' =>\n        by\n        apply PullbackCone.IsLimit.hom_ext hs <;>\n              simp only [PullbackCone.mk_fst, PullbackCone.mk_snd] at hr hr'⊢ <;>\n            simp only [hr, hr'] <;>\n          symm\n        exacts[hs.fac _ WalkingCospan.left, hs.fac _ WalkingCospan.right]⟩⟩\n#align category_theory.limits.pullback_cone.is_limit_of_factors CategoryTheory.Limits.PullbackCone.isLimitOfFactors\n\n/-- If `W` is the pullback of `f, g`,\nit is also the pullback of `f ≫ i, g ≫ i` for any mono `i`. -/\ndef isLimitOfCompMono (f : X ⟶ W) (g : Y ⟶ W) (i : W ⟶ Z) [Mono i] (s : PullbackCone f g)\n    (H : IsLimit s) :\n    IsLimit\n      (PullbackCone.mk _ _\n        (show s.fst ≫ f ≫ i = s.snd ≫ g ≫ i by\n          rw [← Category.assoc, ← Category.assoc, s.condition])) := by\n  apply PullbackCone.isLimitAux'\n  intro s\n  rcases PullbackCone.IsLimit.lift' H s.fst s.snd\n      ((cancel_mono i).mp (by simpa using s.condition)) with\n    ⟨l, h₁, h₂⟩\n  refine' ⟨l, h₁, h₂, _⟩\n  intro m hm₁ hm₂\n  exact (PullbackCone.IsLimit.hom_ext H (hm₁.trans h₁.symm) (hm₂.trans h₂.symm) : _)\n#align category_theory.limits.pullback_cone.is_limit_of_comp_mono CategoryTheory.Limits.PullbackCone.isLimitOfCompMono\n\nend PullbackCone\n\n/-- A pushout cocone is just a cocone on the span formed by two morphisms `f : X ⟶ Y` and\n    `g : X ⟶ Z`.-/\nabbrev PushoutCocone (f : X ⟶ Y) (g : X ⟶ Z) :=\n  Cocone (span f g)\n#align category_theory.limits.pushout_cocone CategoryTheory.Limits.PushoutCocone\n\nnamespace PushoutCocone\n\nvariable {f : X ⟶ Y} {g : X ⟶ Z}\n\n/-- The first inclusion of a pushout cocone. -/\nabbrev inl (t : PushoutCocone f g) : Y ⟶ t.pt :=\n  t.ι.app WalkingSpan.left\n#align category_theory.limits.pushout_cocone.inl CategoryTheory.Limits.PushoutCocone.inl\n\n/-- The second inclusion of a pushout cocone. -/\nabbrev inr (t : PushoutCocone f g) : Z ⟶ t.pt :=\n  t.ι.app WalkingSpan.right\n#align category_theory.limits.pushout_cocone.inr CategoryTheory.Limits.PushoutCocone.inr\n\n@[simp]\ntheorem ι_app_left (c : PushoutCocone f g) : c.ι.app WalkingSpan.left = c.inl := rfl\n#align category_theory.limits.pushout_cocone.ι_app_left CategoryTheory.Limits.PushoutCocone.ι_app_left\n\n@[simp]\ntheorem ι_app_right (c : PushoutCocone f g) : c.ι.app WalkingSpan.right = c.inr := rfl\n#align category_theory.limits.pushout_cocone.ι_app_right CategoryTheory.Limits.PushoutCocone.ι_app_right\n\n@[simp]\ntheorem condition_zero (t : PushoutCocone f g) : t.ι.app WalkingSpan.zero = f ≫ t.inl := by\n  have w := t.ι.naturality WalkingSpan.Hom.fst\n  dsimp at w; simpa using w.symm\n#align category_theory.limits.pushout_cocone.condition_zero CategoryTheory.Limits.PushoutCocone.condition_zero\n\n/-- This is a slightly more convenient method to verify that a pushout cocone is a colimit cocone.\n    It only asks for a proof of facts that carry any mathematical content -/\ndef isColimitAux (t : PushoutCocone f g) (desc : ∀ s : PushoutCocone f g, t.pt ⟶ s.pt)\n    (fac_left : ∀ s : PushoutCocone f g, t.inl ≫ desc s = s.inl)\n    (fac_right : ∀ s : PushoutCocone f g, t.inr ≫ desc s = s.inr)\n    (uniq : ∀ (s : PushoutCocone f g) (m : t.pt ⟶ s.pt)\n    (_ : ∀ j : WalkingSpan, t.ι.app j ≫ m = s.ι.app j), m = desc s) : IsColimit t :=\n  { desc\n    fac := fun s j =>\n      Option.casesOn j (by simp [← s.w fst, ← t.w fst, fac_left s]) fun j' =>\n        WalkingPair.casesOn j' (fac_left s) (fac_right s)\n    uniq := uniq }\n#align category_theory.limits.pushout_cocone.is_colimit_aux CategoryTheory.Limits.PushoutCocone.isColimitAux\n\n/-- This is another convenient method to verify that a pushout cocone is a colimit cocone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef isColimitAux' (t : PushoutCocone f g)\n    (create :\n      ∀ s : PushoutCocone f g,\n        { l //\n          t.inl ≫ l = s.inl ∧\n            t.inr ≫ l = s.inr ∧ ∀ {m}, t.inl ≫ m = s.inl → t.inr ≫ m = s.inr → m = l }) :\n    IsColimit t :=\n  isColimitAux t (fun s => (create s).1) (fun s => (create s).2.1) (fun s => (create s).2.2.1)\n    fun s _ w => (create s).2.2.2 (w WalkingCospan.left) (w WalkingCospan.right)\n#align category_theory.limits.pushout_cocone.is_colimit_aux' CategoryTheory.Limits.PushoutCocone.isColimitAux'\n\n/-- A pushout cocone on `f` and `g` is determined by morphisms `inl : Y ⟶ W` and `inr : Z ⟶ W` such\n    that `f ≫ inl = g ↠ inr`. -/\n@[simps]\ndef mk {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) : PushoutCocone f g where\n  pt := W\n  ι := { app := fun j => Option.casesOn j (f ≫ inl) fun j' => WalkingPair.casesOn j' inl inr\n         naturality := by\n          rintro (⟨⟩|⟨⟨⟩⟩) (⟨⟩|⟨⟨⟩⟩) <;> intro f <;> cases f <;> dsimp <;> aesop }\n#align category_theory.limits.pushout_cocone.mk CategoryTheory.Limits.PushoutCocone.mk\n\n@[simp]\ntheorem mk_ι_app_left {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    (mk inl inr eq).ι.app WalkingSpan.left = inl := rfl\n#align category_theory.limits.pushout_cocone.mk_ι_app_left CategoryTheory.Limits.PushoutCocone.mk_ι_app_left\n\n@[simp]\ntheorem mk_ι_app_right {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    (mk inl inr eq).ι.app WalkingSpan.right = inr := rfl\n#align category_theory.limits.pushout_cocone.mk_ι_app_right CategoryTheory.Limits.PushoutCocone.mk_ι_app_right\n\n@[simp]\ntheorem mk_ι_app_zero {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    (mk inl inr eq).ι.app WalkingSpan.zero = f ≫ inl := rfl\n#align category_theory.limits.pushout_cocone.mk_ι_app_zero CategoryTheory.Limits.PushoutCocone.mk_ι_app_zero\n\n@[simp]\ntheorem mk_inl {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    (mk inl inr eq).inl = inl := rfl\n#align category_theory.limits.pushout_cocone.mk_inl CategoryTheory.Limits.PushoutCocone.mk_inl\n\n@[simp]\ntheorem mk_inr {W : C} (inl : Y ⟶ W) (inr : Z ⟶ W) (eq : f ≫ inl = g ≫ inr) :\n    (mk inl inr eq).inr = inr := rfl\n#align category_theory.limits.pushout_cocone.mk_inr CategoryTheory.Limits.PushoutCocone.mk_inr\n\n@[reassoc]\ntheorem condition (t : PushoutCocone f g) : f ≫ inl t = g ≫ inr t :=\n  (t.w fst).trans (t.w snd).symm\n#align category_theory.limits.pushout_cocone.condition CategoryTheory.Limits.PushoutCocone.condition\n\n/-- To check whether a morphism is coequalized by the maps of a pushout cocone, it suffices to check\n  it for `inl t` and `inr t` -/\ntheorem coequalizer_ext (t : PushoutCocone f g) {W : C} {k l : t.pt ⟶ W}\n    (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) :\n    ∀ j : WalkingSpan, t.ι.app j ≫ k = t.ι.app j ≫ l\n  | some WalkingPair.left => h₀\n  | some WalkingPair.right => h₁\n  | none => by rw [← t.w fst, Category.assoc, Category.assoc, h₀]\n#align category_theory.limits.pushout_cocone.coequalizer_ext CategoryTheory.Limits.PushoutCocone.coequalizer_ext\n\ntheorem IsColimit.hom_ext {t : PushoutCocone f g} (ht : IsColimit t) {W : C} {k l : t.pt ⟶ W}\n    (h₀ : inl t ≫ k = inl t ≫ l) (h₁ : inr t ≫ k = inr t ≫ l) : k = l :=\n  ht.hom_ext <| coequalizer_ext _ h₀ h₁\n#align category_theory.limits.pushout_cocone.is_colimit.hom_ext CategoryTheory.Limits.PushoutCocone.IsColimit.hom_ext\n\n-- porting note: `IsColimit.desc` and the two following simp lemmas were introduced to ease the port\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y ⟶ W` and `k : Z ⟶ W` are\n    morphisms satisfying `f ≫ h = g ≫ k`, then we have a factorization `l : t.pt ⟶ W` such that\n    `inl t ≫ l = h` and `inr t ≫ l = k`, see `IsColimit.inl_desc` and `IsColimit.inr_desc`-/\ndef IsColimit.desc {t : PushoutCocone f g} (ht : IsColimit t) {W : C} (h : Y ⟶ W) (k : Z ⟶ W)\n    (w : f ≫ h = g ≫ k) : t.pt ⟶ W :=\n  ht.desc (PushoutCocone.mk _ _ w)\n\n@[reassoc (attr := simp)]\nlemma IsColimit.inl_desc {t : PushoutCocone f g} (ht : IsColimit t) {W : C} (h : Y ⟶ W) (k : Z ⟶ W)\n    (w : f ≫ h = g ≫ k) : inl t ≫ IsColimit.desc ht h k w = h :=\n  ht.fac _ _\n\n@[reassoc (attr := simp)]\nlemma IsColimit.inr_desc {t : PushoutCocone f g} (ht : IsColimit t) {W : C} (h : Y ⟶ W) (k : Z ⟶ W)\n    (w : f ≫ h = g ≫ k) : inr t ≫ IsColimit.desc ht h k w = k :=\n  ht.fac _ _\n\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y ⟶ W` and `k : Z ⟶ W` are\n    morphisms satisfying `f ≫ h = g ≫ k`, then we have a factorization `l : t.pt ⟶ W` such that\n    `inl t ≫ l = h` and `inr t ≫ l = k`. -/\ndef IsColimit.desc' {t : PushoutCocone f g} (ht : IsColimit t) {W : C} (h : Y ⟶ W) (k : Z ⟶ W)\n    (w : f ≫ h = g ≫ k) : { l : t.pt ⟶ W // inl t ≫ l = h ∧ inr t ≫ l = k } :=\n  ⟨IsColimit.desc ht h k w, by simp⟩\n#align category_theory.limits.pushout_cocone.is_colimit.desc' CategoryTheory.Limits.PushoutCocone.IsColimit.desc'\n\ntheorem epi_inr_of_is_pushout_of_epi {t : PushoutCocone f g} (ht : IsColimit t) [Epi f] :\n    Epi t.inr :=\n  ⟨fun {W} h k i => IsColimit.hom_ext ht (by simp [← cancel_epi f, t.condition_assoc, i]) i⟩\n#align category_theory.limits.pushout_cocone.epi_inr_of_is_pushout_of_epi CategoryTheory.Limits.PushoutCocone.epi_inr_of_is_pushout_of_epi\n\ntheorem epi_inl_of_is_pushout_of_epi {t : PushoutCocone f g} (ht : IsColimit t) [Epi g] :\n    Epi t.inl :=\n  ⟨fun {W} h k i => IsColimit.hom_ext ht i (by simp [← cancel_epi g, ← t.condition_assoc, i])⟩\n#align category_theory.limits.pushout_cocone.epi_inl_of_is_pushout_of_epi CategoryTheory.Limits.PushoutCocone.epi_inl_of_is_pushout_of_epi\n\n/-- To construct an isomorphism of pushout cocones, it suffices to construct an isomorphism\nof the cocone points and check it commutes with `inl` and `inr`. -/\ndef ext {s t : PushoutCocone f g} (i : s.pt ≅ t.pt) (w₁ : s.inl ≫ i.hom = t.inl)\n    (w₂ : s.inr ≫ i.hom = t.inr) : s ≅ t :=\n  WalkingSpan.ext i w₁ w₂\n#align category_theory.limits.pushout_cocone.ext CategoryTheory.Limits.PushoutCocone.ext\n\n/-- This is a more convenient formulation to show that a `PushoutCocone` constructed using\n`PushoutCocone.mk` is a colimit cocone.\n-/\ndef IsColimit.mk {W : C} {inl : Y ⟶ W} {inr : Z ⟶ W} (eq : f ≫ inl = g ≫ inr)\n    (desc : ∀ s : PushoutCocone f g, W ⟶ s.pt)\n    (fac_left : ∀ s : PushoutCocone f g, inl ≫ desc s = s.inl)\n    (fac_right : ∀ s : PushoutCocone f g, inr ≫ desc s = s.inr)\n    (uniq :\n      ∀ (s : PushoutCocone f g) (m : W ⟶ s.pt) (_ : inl ≫ m = s.inl) (_ : inr ≫ m = s.inr),\n        m = desc s) :\n    IsColimit (mk inl inr eq) :=\n  isColimitAux _ desc fac_left fac_right fun s m w =>\n    uniq s m (w WalkingCospan.left) (w WalkingCospan.right)\n#align category_theory.limits.pushout_cocone.is_colimit.mk CategoryTheory.Limits.PushoutCocone.IsColimit.mk\n\n/-- The flip of a pushout square is a pushout square. -/\ndef flipIsColimit {W : C} {h : Y ⟶ W} {k : Z ⟶ W} {comm : f ≫ h = g ≫ k}\n    (t : IsColimit (mk _ _ comm.symm)) : IsColimit (mk _ _ comm) :=\n  isColimitAux' _ fun s =>\n    by\n    refine'\n      ⟨(IsColimit.desc' t _ _ s.condition.symm).1, (IsColimit.desc' t _ _ _).2.2,\n        (IsColimit.desc' t _ _ _).2.1, fun m₁ m₂ => t.hom_ext _⟩\n    apply (mk k h _).coequalizer_ext\n    · rwa [(IsColimit.desc' t _ _ _).2.1]\n    · rwa [(IsColimit.desc' t _ _ _).2.2]\n#align category_theory.limits.pushout_cocone.flip_is_colimit CategoryTheory.Limits.PushoutCocone.flipIsColimit\n\n/--\nThe pushout cocone `(𝟙 X, 𝟙 X)` for the pair `(f, f)` is a colimit if `f` is an epi. The converse is\nshown in `epi_of_isColimit_mk_id_id`.\n-/\ndef isColimitMkIdId (f : X ⟶ Y) [Epi f] : IsColimit (mk (𝟙 Y) (𝟙 Y) rfl : PushoutCocone f f) :=\n  IsColimit.mk _ (fun s => s.inl) (fun s => Category.id_comp _)\n    (fun s => by rw [← cancel_epi f, Category.id_comp, s.condition]) fun s m m₁ _ => by\n    simpa using m₁\n#align category_theory.limits.pushout_cocone.is_colimit_mk_id_id CategoryTheory.Limits.PushoutCocone.isColimitMkIdId\n\n/-- `f` is an epi if the pushout cocone `(𝟙 X, 𝟙 X)` is a colimit for the pair `(f, f)`.\nThe converse is given in `PushoutCocone.isColimitMkIdId`.\n-/\ntheorem epi_of_isColimitMkIdId (f : X ⟶ Y)\n    (t : IsColimit (mk (𝟙 Y) (𝟙 Y) rfl : PushoutCocone f f)) : Epi f :=\n  ⟨fun {Z} g h eq =>\n    by\n    rcases PushoutCocone.IsColimit.desc' t _ _ eq with ⟨_, rfl, rfl⟩\n    rfl⟩\n#align category_theory.limits.pushout_cocone.epi_of_is_colimit_mk_id_id CategoryTheory.Limits.PushoutCocone.epi_of_isColimitMkIdId\n\n/-- Suppose `f` and `g` are two morphisms with a common domain and `s` is a colimit cocone over the\n    diagram formed by `f` and `g`. Suppose `f` and `g` both factor through an epimorphism `h` via\n    `x` and `y`, respectively. Then `s` is also a colimit cocone over the diagram formed by `x` and\n    `y`.  -/\ndef isColimitOfFactors (f : X ⟶ Y) (g : X ⟶ Z) (h : X ⟶ W) [Epi h] (x : W ⟶ Y) (y : W ⟶ Z)\n    (hhx : h ≫ x = f) (hhy : h ≫ y = g) (s : PushoutCocone f g) (hs : IsColimit s) :\n    have reassoc₁ : h ≫ x ≫ inl s = f ≫ inl s := by  -- Porting note: working around reassoc\n      rw [← Category.assoc]; apply congrArg (· ≫ inl s) hhx\n    have reassoc₂ : h ≫ y ≫ inr s = g ≫ inr s := by\n      rw [← Category.assoc]; apply congrArg (· ≫ inr s) hhy\n    IsColimit (PushoutCocone.mk _ _ (show x ≫ s.inl = y ≫ s.inr from\n          (cancel_epi h).1 <| by rw [reassoc₁, reassoc₂, s.condition])) :=\n  PushoutCocone.isColimitAux' _ fun t => ⟨hs.desc (PushoutCocone.mk t.inl t.inr <| by\n    rw [← hhx, ← hhy, Category.assoc, Category.assoc, t.condition]),\n      ⟨hs.fac _ WalkingSpan.left, hs.fac _ WalkingSpan.right, fun hr hr' => by\n        apply PushoutCocone.IsColimit.hom_ext hs;\n        · simp only [PushoutCocone.mk_inl, PushoutCocone.mk_inr] at hr hr'⊢\n          simp only [hr, hr']\n          symm\n          exact hs.fac _ WalkingSpan.left\n        · simp only [PushoutCocone.mk_inl, PushoutCocone.mk_inr] at hr hr'⊢\n          simp only [hr, hr']\n          symm\n          exact hs.fac _ WalkingSpan.right⟩⟩\n#align category_theory.limits.pushout_cocone.is_colimit_of_factors CategoryTheory.Limits.PushoutCocone.isColimitOfFactors\n\n/-- If `W` is the pushout of `f, g`,\nit is also the pushout of `h ≫ f, h ≫ g` for any epi `h`. -/\ndef isColimitOfEpiComp (f : X ⟶ Y) (g : X ⟶ Z) (h : W ⟶ X) [Epi h] (s : PushoutCocone f g)\n    (H : IsColimit s) :\n    IsColimit\n      (PushoutCocone.mk _ _\n        (show (h ≫ f) ≫ s.inl = (h ≫ g) ≫ s.inr by\n          rw [Category.assoc, Category.assoc, s.condition])) := by\n  apply PushoutCocone.isColimitAux'\n  intro s\n  rcases PushoutCocone.IsColimit.desc' H s.inl s.inr\n      ((cancel_epi h).mp (by simpa using s.condition)) with\n    ⟨l, h₁, h₂⟩\n  refine' ⟨l, h₁, h₂, _⟩\n  intro m hm₁ hm₂\n  exact (PushoutCocone.IsColimit.hom_ext H (hm₁.trans h₁.symm) (hm₂.trans h₂.symm) : _)\n#align category_theory.limits.pushout_cocone.is_colimit_of_epi_comp CategoryTheory.Limits.PushoutCocone.isColimitOfEpiComp\n\nend PushoutCocone\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pullbacks. Given `F : WalkingCospan ⥤ C`, which is really the same as\n    `cospan (F.map inl) (F.map inr)`, and a pullback cone on `F.map inl` and `F.map inr`, we\n    get a cone on `F`.\n\n    If you're thinking about using this, have a look at `hasPullbacks_of_hasLimit_cospan`,\n    which you may find to be an easier way of achieving your goal. -/\n@[simps]\ndef Cone.ofPullbackCone {F : WalkingCospan ⥤ C} (t : PullbackCone (F.map inl) (F.map inr)) : Cone F\n    where\n  pt := t.pt\n  π := t.π ≫ (diagramIsoCospan F).inv\n#align category_theory.limits.cone.of_pullback_cone CategoryTheory.Limits.Cone.ofPullbackCone\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    pushout. Given `F : WalkingSpan ⥤ C`, which is really the same as\n    `span (F.map fst) (F.mal snd)`, and a pushout cocone on `F.map fst` and `F.map snd`,\n    we get a cocone on `F`.\n\n    If you're thinking about using this, have a look at `hasPushouts_of_hasColimit_span`, which\n    you may find to be an easiery way of achieving your goal.  -/\n@[simps]\ndef Cocone.ofPushoutCocone {F : WalkingSpan ⥤ C} (t : PushoutCocone (F.map fst) (F.map snd)) :\n    Cocone F where\n  pt := t.pt\n  ι := (diagramIsoSpan F).hom ≫ t.ι\n#align category_theory.limits.cocone.of_pushout_cocone CategoryTheory.Limits.Cocone.ofPushoutCocone\n\n/-- Given `F : WalkingCospan ⥤ C`, which is really the same as `cospan (F.map inl) (F.map inr)`,\n    and a cone on `F`, we get a pullback cone on `F.map inl` and `F.map inr`. -/\n@[simps]\ndef PullbackCone.ofCone {F : WalkingCospan ⥤ C} (t : Cone F) : PullbackCone (F.map inl) (F.map inr)\n    where\n  pt := t.pt\n  π := t.π ≫ (diagramIsoCospan F).hom\n#align category_theory.limits.pullback_cone.of_cone CategoryTheory.Limits.PullbackCone.ofCone\n\n/-- A diagram `WalkingCospan ⥤ C` is isomorphic to some `PullbackCone.mk` after\ncomposing with `diagramIsoCospan`. -/\n@[simps!]\ndef PullbackCone.isoMk {F : WalkingCospan ⥤ C} (t : Cone F) :\n    (Cones.postcompose (diagramIsoCospan.{v} _).hom).obj t ≅\n      PullbackCone.mk (t.π.app WalkingCospan.left) (t.π.app WalkingCospan.right)\n        ((t.π.naturality inl).symm.trans (t.π.naturality inr : _)) :=\n  Cones.ext (Iso.refl _) <| by\n    rintro (_ | (_ | _)) <;>\n      · dsimp\n        simp\n#align category_theory.limits.pullback_cone.iso_mk CategoryTheory.Limits.PullbackCone.isoMk\n\n/-- Given `F : WalkingSpan ⥤ C`, which is really the same as `span (F.map fst) (F.map snd)`,\n    and a cocone on `F`, we get a pushout cocone on `F.map fst` and `F.map snd`. -/\n@[simps]\ndef PushoutCocone.ofCocone {F : WalkingSpan ⥤ C} (t : Cocone F) :\n    PushoutCocone (F.map fst) (F.map snd) where\n  pt := t.pt\n  ι := (diagramIsoSpan F).inv ≫ t.ι\n#align category_theory.limits.pushout_cocone.of_cocone CategoryTheory.Limits.PushoutCocone.ofCocone\n\n/-- A diagram `WalkingSpan ⥤ C` is isomorphic to some `PushoutCocone.mk` after composing with\n`diagramIsoSpan`. -/\n@[simps!]\ndef PushoutCocone.isoMk {F : WalkingSpan ⥤ C} (t : Cocone F) :\n    (Cocones.precompose (diagramIsoSpan.{v} _).inv).obj t ≅\n      PushoutCocone.mk (t.ι.app WalkingSpan.left) (t.ι.app WalkingSpan.right)\n        ((t.ι.naturality fst).trans (t.ι.naturality snd).symm) :=\n  Cocones.ext (Iso.refl _) <| by\n    rintro (_ | (_ | _)) <;>\n      · dsimp\n        simp\n#align category_theory.limits.pushout_cocone.iso_mk CategoryTheory.Limits.PushoutCocone.isoMk\n\n/-- `HasPullback f g` represents a particular choice of limiting cone\nfor the pair of morphisms `f : X ⟶ Z` and `g : Y ⟶ Z`.\n-/\nabbrev HasPullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :=\n  HasLimit (cospan f g)\n#align category_theory.limits.has_pullback CategoryTheory.Limits.HasPullback\n\n/-- `HasPushout f g` represents a particular choice of colimiting cocone\nfor the pair of morphisms `f : X ⟶ Y` and `g : X ⟶ Z`.\n-/\nabbrev HasPushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :=\n  HasColimit (span f g)\n#align category_theory.limits.has_pushout CategoryTheory.Limits.HasPushout\n\n/-- `pullback f g` computes the pullback of a pair of morphisms with the same target. -/\nabbrev pullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g] :=\n  limit (cospan f g)\n#align category_theory.limits.pullback CategoryTheory.Limits.pullback\n\n/-- `pushout f g` computes the pushout of a pair of morphisms with the same source. -/\nabbrev pushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g] :=\n  colimit (span f g)\n#align category_theory.limits.pushout CategoryTheory.Limits.pushout\n\n/-- The first projection of the pullback of `f` and `g`. -/\nabbrev pullback.fst {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] : pullback f g ⟶ X :=\n  limit.π (cospan f g) WalkingCospan.left\n#align category_theory.limits.pullback.fst CategoryTheory.Limits.pullback.fst\n\n/-- The second projection of the pullback of `f` and `g`. -/\nabbrev pullback.snd {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] : pullback f g ⟶ Y :=\n  limit.π (cospan f g) WalkingCospan.right\n#align category_theory.limits.pullback.snd CategoryTheory.Limits.pullback.snd\n\n/-- The first inclusion into the pushout of `f` and `g`. -/\nabbrev pushout.inl {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] : Y ⟶ pushout f g :=\n  colimit.ι (span f g) WalkingSpan.left\n#align category_theory.limits.pushout.inl CategoryTheory.Limits.pushout.inl\n\n/-- The second inclusion into the pushout of `f` and `g`. -/\nabbrev pushout.inr {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] : Z ⟶ pushout f g :=\n  colimit.ι (span f g) WalkingSpan.right\n#align category_theory.limits.pushout.inr CategoryTheory.Limits.pushout.inr\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `pullback.lift : W ⟶ pullback f g`. -/\nabbrev pullback.lift {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X) (k : W ⟶ Y)\n    (w : h ≫ f = k ≫ g) : W ⟶ pullback f g :=\n  limit.lift _ (PullbackCone.mk h k w)\n#align category_theory.limits.pullback.lift CategoryTheory.Limits.pullback.lift\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `pushout.desc : pushout f g ⟶ W`. -/\nabbrev pushout.desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W) (k : Z ⟶ W)\n    (w : f ≫ h = g ≫ k) : pushout f g ⟶ W :=\n  colimit.desc _ (PushoutCocone.mk h k w)\n#align category_theory.limits.pushout.desc CategoryTheory.Limits.pushout.desc\n\n@[simp]\ntheorem PullbackCone.fst_colimit_cocone {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n    [HasLimit (cospan f g)] : PullbackCone.fst (limit.cone (cospan f g)) = pullback.fst := rfl\n#align category_theory.limits.pullback_cone.fst_colimit_cocone CategoryTheory.Limits.PullbackCone.fst_colimit_cocone\n\n@[simp]\ntheorem PullbackCone.snd_colimit_cocone {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n    [HasLimit (cospan f g)] : PullbackCone.snd (limit.cone (cospan f g)) = pullback.snd := rfl\n#align category_theory.limits.pullback_cone.snd_colimit_cocone CategoryTheory.Limits.PullbackCone.snd_colimit_cocone\n\n-- Porting note: simp can prove this; removed simp\ntheorem PushoutCocone.inl_colimit_cocone {X Y Z : C} (f : Z ⟶ X) (g : Z ⟶ Y)\n    [HasColimit (span f g)] : PushoutCocone.inl (colimit.cocone (span f g)) = pushout.inl := rfl\n#align category_theory.limits.pushout_cocone.inl_colimit_cocone CategoryTheory.Limits.PushoutCocone.inl_colimit_cocone\n\n-- Porting note: simp can prove this; removed simp\ntheorem PushoutCocone.inr_colimit_cocone {X Y Z : C} (f : Z ⟶ X) (g : Z ⟶ Y)\n    [HasColimit (span f g)] : PushoutCocone.inr (colimit.cocone (span f g)) = pushout.inr := rfl\n#align category_theory.limits.pushout_cocone.inr_colimit_cocone CategoryTheory.Limits.PushoutCocone.inr_colimit_cocone\n\n-- Porting note: simp can prove this and reassoced version; removed simp\n@[reassoc]\ntheorem pullback.lift_fst {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X)\n    (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : pullback.lift h k w ≫ pullback.fst = h :=\n  limit.lift_π _ _\n#align category_theory.limits.pullback.lift_fst CategoryTheory.Limits.pullback.lift_fst\n\n-- Porting note: simp can prove this and reassoced version; removed simp\n@[reassoc]\ntheorem pullback.lift_snd {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X)\n    (k : W ⟶ Y) (w : h ≫ f = k ≫ g) : pullback.lift h k w ≫ pullback.snd = k :=\n  limit.lift_π _ _\n#align category_theory.limits.pullback.lift_snd CategoryTheory.Limits.pullback.lift_snd\n\n-- Porting note: simp can prove this and reassoced version; removed simp\n@[reassoc]\ntheorem pushout.inl_desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W)\n    (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout.inl ≫ pushout.desc h k w = h :=\n  colimit.ι_desc _ _\n#align category_theory.limits.pushout.inl_desc CategoryTheory.Limits.pushout.inl_desc\n\n-- Porting note: simp can prove this and reassoced version; removed simp\n@[reassoc]\ntheorem pushout.inr_desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W)\n    (k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout.inr ≫ pushout.desc h k w = k :=\n  colimit.ι_desc _ _\n#align category_theory.limits.pushout.inr_desc CategoryTheory.Limits.pushout.inr_desc\n\n/-- A pair of morphisms `h : W ⟶ X` and `k : W ⟶ Y` satisfying `h ≫ f = k ≫ g` induces a morphism\n    `l : W ⟶ pullback f g` such that `l ≫ pullback.fst = h` and `l ≫ pullback.snd = k`. -/\ndef pullback.lift' {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X) (k : W ⟶ Y)\n    (w : h ≫ f = k ≫ g) : { l : W ⟶ pullback f g // l ≫ pullback.fst = h ∧ l ≫ pullback.snd = k } :=\n  ⟨pullback.lift h k w, pullback.lift_fst _ _ _, pullback.lift_snd _ _ _⟩\n#align category_theory.limits.pullback.lift' CategoryTheory.Limits.pullback.lift'\n\n/-- A pair of morphisms `h : Y ⟶ W` and `k : Z ⟶ W` satisfying `f ≫ h = g ≫ k` induces a morphism\n    `l : pushout f g ⟶ W` such that `pushout.inl ≫ l = h` and `pushout.inr ≫ l = k`. -/\ndef pullback.desc' {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W) (k : Z ⟶ W)\n    (w : f ≫ h = g ≫ k) : { l : pushout f g ⟶ W // pushout.inl ≫ l = h ∧ pushout.inr ≫ l = k } :=\n  ⟨pushout.desc h k w, pushout.inl_desc _ _ _, pushout.inr_desc _ _ _⟩\n#align category_theory.limits.pullback.desc' CategoryTheory.Limits.pullback.desc'\n\n@[reassoc]\ntheorem pullback.condition {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] :\n    (pullback.fst : pullback f g ⟶ X) ≫ f = pullback.snd ≫ g :=\n  PullbackCone.condition _\n#align category_theory.limits.pullback.condition CategoryTheory.Limits.pullback.condition\n\n@[reassoc]\ntheorem pushout.condition {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] :\n    f ≫ (pushout.inl : Y ⟶ pushout f g) = g ≫ pushout.inr :=\n  PushoutCocone.condition _\n#align category_theory.limits.pushout.condition CategoryTheory.Limits.pushout.condition\n\n/-- Given such a diagram, then there is a natural morphism `W ×ₛ X ⟶ Y ×ₜ Z`.\n\n    W  ⟶  Y\n      ↘      ↘\n        S  ⟶  T\n      ↗      ↗\n    X  ⟶  Z\n\n-/\nabbrev pullback.map {W X Y Z S T : C} (f₁ : W ⟶ S) (f₂ : X ⟶ S) [HasPullback f₁ f₂] (g₁ : Y ⟶ T)\n    (g₂ : Z ⟶ T) [HasPullback g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T)\n    (eq₁ : f₁ ≫ i₃ = i₁ ≫ g₁) (eq₂ : f₂ ≫ i₃ = i₂ ≫ g₂) : pullback f₁ f₂ ⟶ pullback g₁ g₂ :=\n  pullback.lift (pullback.fst ≫ i₁) (pullback.snd ≫ i₂)\n    (by simp [← eq₁, ← eq₂, pullback.condition_assoc])\n#align category_theory.limits.pullback.map CategoryTheory.Limits.pullback.map\n\n/-- The canonical map `X ×ₛ Y ⟶ X ×ₜ Y` given `S ⟶ T`. -/\nabbrev pullback.mapDesc {X Y S T : C} (f : X ⟶ S) (g : Y ⟶ S) (i : S ⟶ T) [HasPullback f g]\n    [HasPullback (f ≫ i) (g ≫ i)] : pullback f g ⟶ pullback (f ≫ i) (g ≫ i) :=\n  pullback.map f g (f ≫ i) (g ≫ i) (𝟙 _) (𝟙 _) i (Category.id_comp _).symm (Category.id_comp _).symm\n#align category_theory.limits.pullback.map_desc CategoryTheory.Limits.pullback.mapDesc\n\n/-- Given such a diagram, then there is a natural morphism `W ⨿ₛ X ⟶ Y ⨿ₜ Z`.\n\n        W  ⟶  Y\n      ↗      ↗\n    S  ⟶  T\n      ↘      ↘\n        X  ⟶  Z\n\n-/\nabbrev pushout.map {W X Y Z S T : C} (f₁ : S ⟶ W) (f₂ : S ⟶ X) [HasPushout f₁ f₂] (g₁ : T ⟶ Y)\n    (g₂ : T ⟶ Z) [HasPushout g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T) (eq₁ : f₁ ≫ i₁ = i₃ ≫ g₁)\n    (eq₂ : f₂ ≫ i₂ = i₃ ≫ g₂) : pushout f₁ f₂ ⟶ pushout g₁ g₂ :=\n  pushout.desc (i₁ ≫ pushout.inl) (i₂ ≫ pushout.inr)\n    (by\n      simp only [← Category.assoc, eq₁, eq₂]\n      simp [pushout.condition])\n#align category_theory.limits.pushout.map CategoryTheory.Limits.pushout.map\n\n/-- The canonical map `X ⨿ₛ Y ⟶ X ⨿ₜ Y` given `S ⟶ T`. -/\nabbrev pushout.mapLift {X Y S T : C} (f : T ⟶ X) (g : T ⟶ Y) (i : S ⟶ T) [HasPushout f g]\n    [HasPushout (i ≫ f) (i ≫ g)] : pushout (i ≫ f) (i ≫ g) ⟶ pushout f g :=\n  pushout.map (i ≫ f) (i ≫ g) f g (𝟙 _) (𝟙 _) i (Category.comp_id _) (Category.comp_id _)\n#align category_theory.limits.pushout.map_lift CategoryTheory.Limits.pushout.mapLift\n\n/-- Two morphisms into a pullback are equal if their compositions with the pullback morphisms are\n    equal -/\n@[ext 1100]\ntheorem pullback.hom_ext {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] {W : C}\n    {k l : W ⟶ pullback f g} (h₀ : k ≫ pullback.fst = l ≫ pullback.fst)\n    (h₁ : k ≫ pullback.snd = l ≫ pullback.snd) : k = l :=\n  limit.hom_ext <| PullbackCone.equalizer_ext _ h₀ h₁\n#align category_theory.limits.pullback.hom_ext CategoryTheory.Limits.pullback.hom_ext\n\n/-- The pullback cone built from the pullback projections is a pullback. -/\ndef pullbackIsPullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g] :\n    IsLimit (PullbackCone.mk (pullback.fst : pullback f g ⟶ _) pullback.snd pullback.condition) :=\n  PullbackCone.IsLimit.mk _ (fun s => pullback.lift s.fst s.snd s.condition) (by simp) (by simp)\n    (by aesop_cat)\n#align category_theory.limits.pullback_is_pullback CategoryTheory.Limits.pullbackIsPullback\n\n/-- The pullback of a monomorphism is a monomorphism -/\ninstance pullback.fst_of_mono {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] [Mono g] :\n    Mono (pullback.fst : pullback f g ⟶ X) :=\n  PullbackCone.mono_fst_of_is_pullback_of_mono (limit.isLimit _)\n#align category_theory.limits.pullback.fst_of_mono CategoryTheory.Limits.pullback.fst_of_mono\n\n/-- The pullback of a monomorphism is a monomorphism -/\ninstance pullback.snd_of_mono {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] [Mono f] :\n    Mono (pullback.snd : pullback f g ⟶ Y) :=\n  PullbackCone.mono_snd_of_is_pullback_of_mono (limit.isLimit _)\n#align category_theory.limits.pullback.snd_of_mono CategoryTheory.Limits.pullback.snd_of_mono\n\n/-- The map `X ×[Z] Y ⟶ X × Y` is mono. -/\ninstance mono_pullback_to_prod {C : Type _} [Category C] {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)\n    [HasPullback f g] [HasBinaryProduct X Y] :\n    Mono (prod.lift pullback.fst pullback.snd : pullback f g ⟶ _) :=\n  ⟨fun {W} i₁ i₂ h => by\n    ext\n    · simpa using congrArg (fun f => f ≫ prod.fst) h\n    · simpa using congrArg (fun f => f ≫ prod.snd) h⟩\n#align category_theory.limits.mono_pullback_to_prod CategoryTheory.Limits.mono_pullback_to_prod\n\n/-- Two morphisms out of a pushout are equal if their compositions with the pushout morphisms are\n    equal -/\n@[ext 1100]\ntheorem pushout.hom_ext {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] {W : C}\n    {k l : pushout f g ⟶ W} (h₀ : pushout.inl ≫ k = pushout.inl ≫ l)\n    (h₁ : pushout.inr ≫ k = pushout.inr ≫ l) : k = l :=\n  colimit.hom_ext <| PushoutCocone.coequalizer_ext _ h₀ h₁\n#align category_theory.limits.pushout.hom_ext CategoryTheory.Limits.pushout.hom_ext\n\n/-- The pushout cocone built from the pushout coprojections is a pushout. -/\ndef pushoutIsPushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g] :\n    IsColimit (PushoutCocone.mk (pushout.inl : _ ⟶ pushout f g) pushout.inr pushout.condition) :=\n  PushoutCocone.IsColimit.mk _ (fun s => pushout.desc s.inl s.inr s.condition) (by simp) (by simp)\n    (by aesop_cat)\n#align category_theory.limits.pushout_is_pushout CategoryTheory.Limits.pushoutIsPushout\n\n/-- The pushout of an epimorphism is an epimorphism -/\ninstance pushout.inl_of_epi {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] [Epi g] :\n    Epi (pushout.inl : Y ⟶ pushout f g) :=\n  PushoutCocone.epi_inl_of_is_pushout_of_epi (colimit.isColimit _)\n#align category_theory.limits.pushout.inl_of_epi CategoryTheory.Limits.pushout.inl_of_epi\n\n/-- The pushout of an epimorphism is an epimorphism -/\ninstance pushout.inr_of_epi {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] [Epi f] :\n    Epi (pushout.inr : Z ⟶ pushout f g) :=\n  PushoutCocone.epi_inr_of_is_pushout_of_epi (colimit.isColimit _)\n#align category_theory.limits.pushout.inr_of_epi CategoryTheory.Limits.pushout.inr_of_epi\n\n/-- The map ` X ⨿ Y ⟶ X ⨿[Z] Y` is epi. -/\ninstance epi_coprod_to_pushout {C : Type _} [Category C] {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)\n    [HasPushout f g] [HasBinaryCoproduct Y Z] :\n    Epi (coprod.desc pushout.inl pushout.inr : _ ⟶ pushout f g) :=\n  ⟨fun {W} i₁ i₂ h => by\n    ext\n    · simpa using congrArg (fun f => coprod.inl ≫ f) h\n    · simpa using congrArg (fun f => coprod.inr ≫ f) h⟩\n#align category_theory.limits.epi_coprod_to_pushout CategoryTheory.Limits.epi_coprod_to_pushout\n\ninstance pullback.map_isIso {W X Y Z S T : C} (f₁ : W ⟶ S) (f₂ : X ⟶ S) [HasPullback f₁ f₂]\n    (g₁ : Y ⟶ T) (g₂ : Z ⟶ T) [HasPullback g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T)\n    (eq₁ : f₁ ≫ i₃ = i₁ ≫ g₁) (eq₂ : f₂ ≫ i₃ = i₂ ≫ g₂) [IsIso i₁] [IsIso i₂] [IsIso i₃] :\n    IsIso (pullback.map f₁ f₂ g₁ g₂ i₁ i₂ i₃ eq₁ eq₂) := by\n  refine' ⟨⟨pullback.map _ _ _ _ (inv i₁) (inv i₂) (inv i₃) _ _, _, _⟩⟩\n  · rw [IsIso.comp_inv_eq, Category.assoc, eq₁, IsIso.inv_hom_id_assoc]\n  · rw [IsIso.comp_inv_eq, Category.assoc, eq₂, IsIso.inv_hom_id_assoc]\n  · aesop_cat\n  · aesop_cat\n#align category_theory.limits.pullback.map_is_iso CategoryTheory.Limits.pullback.map_isIso\n\n/-- If `f₁ = f₂` and `g₁ = g₂`, we may construct a canonical\nisomorphism `pullback f₁ g₁ ≅ pullback f₂ g₂` -/\n@[simps! hom]\ndef pullback.congrHom {X Y Z : C} {f₁ f₂ : X ⟶ Z} {g₁ g₂ : Y ⟶ Z} (h₁ : f₁ = f₂) (h₂ : g₁ = g₂)\n    [HasPullback f₁ g₁] [HasPullback f₂ g₂] : pullback f₁ g₁ ≅ pullback f₂ g₂ :=\n  asIso <| pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂])\n#align category_theory.limits.pullback.congr_hom CategoryTheory.Limits.pullback.congrHom\n\n@[simp]\ntheorem pullback.congrHom_inv {X Y Z : C} {f₁ f₂ : X ⟶ Z} {g₁ g₂ : Y ⟶ Z} (h₁ : f₁ = f₂)\n    (h₂ : g₁ = g₂) [HasPullback f₁ g₁] [HasPullback f₂ g₂] :\n    (pullback.congrHom h₁ h₂).inv =\n      pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂]) := by\n  ext\n  · erw [pullback.lift_fst]\n    rw [Iso.inv_comp_eq]\n    erw [pullback.lift_fst_assoc]\n    rw [Category.comp_id, Category.comp_id]\n  · erw [pullback.lift_snd]\n    rw [Iso.inv_comp_eq]\n    erw [pullback.lift_snd_assoc]\n    rw [Category.comp_id, Category.comp_id]\n#align category_theory.limits.pullback.congr_hom_inv CategoryTheory.Limits.pullback.congrHom_inv\n\ninstance pushout.map_isIso {W X Y Z S T : C} (f₁ : S ⟶ W) (f₂ : S ⟶ X) [HasPushout f₁ f₂]\n    (g₁ : T ⟶ Y) (g₂ : T ⟶ Z) [HasPushout g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T)\n    (eq₁ : f₁ ≫ i₁ = i₃ ≫ g₁) (eq₂ : f₂ ≫ i₂ = i₃ ≫ g₂) [IsIso i₁] [IsIso i₂] [IsIso i₃] :\n    IsIso (pushout.map f₁ f₂ g₁ g₂ i₁ i₂ i₃ eq₁ eq₂) := by\n  refine' ⟨⟨pushout.map _ _ _ _ (inv i₁) (inv i₂) (inv i₃) _ _, _, _⟩⟩\n  · rw [IsIso.comp_inv_eq, Category.assoc, eq₁, IsIso.inv_hom_id_assoc]\n  · rw [IsIso.comp_inv_eq, Category.assoc, eq₂, IsIso.inv_hom_id_assoc]\n  · aesop_cat\n  · aesop_cat\n#align category_theory.limits.pushout.map_is_iso CategoryTheory.Limits.pushout.map_isIso\n\ntheorem pullback.mapDesc_comp {X Y S T S' : C} (f : X ⟶ T) (g : Y ⟶ T) (i : T ⟶ S) (i' : S ⟶ S')\n    [HasPullback f g] [HasPullback (f ≫ i) (g ≫ i)] [HasPullback (f ≫ i ≫ i') (g ≫ i ≫ i')]\n    [HasPullback ((f ≫ i) ≫ i') ((g ≫ i) ≫ i')] :\n    pullback.mapDesc f g (i ≫ i') = pullback.mapDesc f g i ≫ pullback.mapDesc _ _ i' ≫\n    (pullback.congrHom (Category.assoc _ _ _) (Category.assoc _ _ _)).hom := by\n  aesop_cat\n#align category_theory.limits.pullback.map_desc_comp CategoryTheory.Limits.pullback.mapDesc_comp\n\n/-- If `f₁ = f₂` and `g₁ = g₂`, we may construct a canonical\nisomorphism `pushout f₁ g₁ ≅ pullback f₂ g₂` -/\n@[simps! hom]\ndef pushout.congrHom {X Y Z : C} {f₁ f₂ : X ⟶ Y} {g₁ g₂ : X ⟶ Z} (h₁ : f₁ = f₂) (h₂ : g₁ = g₂)\n    [HasPushout f₁ g₁] [HasPushout f₂ g₂] : pushout f₁ g₁ ≅ pushout f₂ g₂ :=\n  asIso <| pushout.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂])\n#align category_theory.limits.pushout.congr_hom CategoryTheory.Limits.pushout.congrHom\n\n@[simp]\ntheorem pushout.congrHom_inv {X Y Z : C} {f₁ f₂ : X ⟶ Y} {g₁ g₂ : X ⟶ Z} (h₁ : f₁ = f₂)\n    (h₂ : g₁ = g₂) [HasPushout f₁ g₁] [HasPushout f₂ g₂] :\n    (pushout.congrHom h₁ h₂).inv =\n      pushout.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂]) := by\n  ext\n  · erw [pushout.inl_desc]\n    rw [Iso.comp_inv_eq, Category.id_comp]\n    erw [pushout.inl_desc]\n    rw [Category.id_comp]\n  · erw [pushout.inr_desc]\n    rw [Iso.comp_inv_eq, Category.id_comp]\n    erw [pushout.inr_desc]\n    rw [Category.id_comp]\n#align category_theory.limits.pushout.congr_hom_inv CategoryTheory.Limits.pushout.congrHom_inv\n\ntheorem pushout.mapLift_comp {X Y S T S' : C} (f : T ⟶ X) (g : T ⟶ Y) (i : S ⟶ T) (i' : S' ⟶ S)\n    [HasPushout f g] [HasPushout (i ≫ f) (i ≫ g)] [HasPushout (i' ≫ i ≫ f) (i' ≫ i ≫ g)]\n    [HasPushout ((i' ≫ i) ≫ f) ((i' ≫ i) ≫ g)] :\n    pushout.mapLift f g (i' ≫ i) =\n      (pushout.congrHom (Category.assoc _ _ _) (Category.assoc _ _ _)).hom ≫\n        pushout.mapLift _ _ i' ≫ pushout.mapLift f g i := by\n  aesop_cat\n#align category_theory.limits.pushout.map_lift_comp CategoryTheory.Limits.pushout.mapLift_comp\n\nsection\n\nvariable (G : C ⥤ D)\n\n/-- The comparison morphism for the pullback of `f,g`.\nThis is an isomorphism iff `G` preserves the pullback of `f,g`; see\n`CategoryTheory/Limits/Preserves/Shapes/Pullbacks.lean`\n-/\ndef pullbackComparison (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g] [HasPullback (G.map f) (G.map g)] :\n    G.obj (pullback f g) ⟶ pullback (G.map f) (G.map g) :=\n  pullback.lift (G.map pullback.fst) (G.map pullback.snd)\n    (by simp only [← G.map_comp, pullback.condition])\n#align category_theory.limits.pullback_comparison CategoryTheory.Limits.pullbackComparison\n\n@[reassoc (attr := simp)]\ntheorem pullbackComparison_comp_fst (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g]\n    [HasPullback (G.map f) (G.map g)] :\n    pullbackComparison G f g ≫ pullback.fst = G.map pullback.fst :=\n  pullback.lift_fst _ _ _\n#align category_theory.limits.pullback_comparison_comp_fst CategoryTheory.Limits.pullbackComparison_comp_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackComparison_comp_snd (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g]\n    [HasPullback (G.map f) (G.map g)] :\n    pullbackComparison G f g ≫ pullback.snd = G.map pullback.snd :=\n  pullback.lift_snd _ _ _\n#align category_theory.limits.pullback_comparison_comp_snd CategoryTheory.Limits.pullbackComparison_comp_snd\n\n@[reassoc (attr := simp)]\ntheorem map_lift_pullbackComparison (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g]\n    [HasPullback (G.map f) (G.map g)] {W : C} {h : W ⟶ X} {k : W ⟶ Y} (w : h ≫ f = k ≫ g) :\n    G.map (pullback.lift _ _ w) ≫ pullbackComparison G f g =\n      pullback.lift (G.map h) (G.map k) (by simp only [← G.map_comp, w]) := by\n  ext <;> simp [← G.map_comp]\n#align category_theory.limits.map_lift_pullback_comparison CategoryTheory.Limits.map_lift_pullbackComparison\n\n/-- The comparison morphism for the pushout of `f,g`.\nThis is an isomorphism iff `G` preserves the pushout of `f,g`; see\n`CategoryTheory/Limits/Preserves/Shapes/Pullbacks.lean`\n-/\ndef pushoutComparison (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g] [HasPushout (G.map f) (G.map g)] :\n    pushout (G.map f) (G.map g) ⟶ G.obj (pushout f g) :=\n  pushout.desc (G.map pushout.inl) (G.map pushout.inr)\n    (by simp only [← G.map_comp, pushout.condition])\n#align category_theory.limits.pushout_comparison CategoryTheory.Limits.pushoutComparison\n\n@[reassoc (attr := simp)]\ntheorem inl_comp_pushoutComparison (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g]\n    [HasPushout (G.map f) (G.map g)] : pushout.inl ≫ pushoutComparison G f g = G.map pushout.inl :=\n  pushout.inl_desc _ _ _\n#align category_theory.limits.inl_comp_pushout_comparison CategoryTheory.Limits.inl_comp_pushoutComparison\n\n@[reassoc (attr := simp)]\ntheorem inr_comp_pushoutComparison (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g]\n    [HasPushout (G.map f) (G.map g)] : pushout.inr ≫ pushoutComparison G f g = G.map pushout.inr :=\n  pushout.inr_desc _ _ _\n#align category_theory.limits.inr_comp_pushout_comparison CategoryTheory.Limits.inr_comp_pushoutComparison\n\n@[reassoc (attr := simp)]\ntheorem pushoutComparison_map_desc (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g]\n    [HasPushout (G.map f) (G.map g)] {W : C} {h : Y ⟶ W} {k : Z ⟶ W} (w : f ≫ h = g ≫ k) :\n    pushoutComparison G f g ≫ G.map (pushout.desc _ _ w) =\n      pushout.desc (G.map h) (G.map k) (by simp only [← G.map_comp, w]) := by\n  ext <;> simp [← G.map_comp]\n#align category_theory.limits.pushout_comparison_map_desc CategoryTheory.Limits.pushoutComparison_map_desc\n\nend\n\nsection PullbackSymmetry\n\nopen WalkingCospan\n\nvariable (f : X ⟶ Z) (g : Y ⟶ Z)\n\n/-- Making this a global instance would make the typeclass seach go in an infinite loop. -/\ntheorem hasPullback_symmetry [HasPullback f g] : HasPullback g f :=\n  ⟨⟨⟨PullbackCone.mk _ _ pullback.condition.symm,\n        PullbackCone.flipIsLimit (pullbackIsPullback _ _)⟩⟩⟩\n#align category_theory.limits.has_pullback_symmetry CategoryTheory.Limits.hasPullback_symmetry\n\nattribute [local instance] hasPullback_symmetry\n\n/-- The isomorphism `X ×[Z] Y ≅ Y ×[Z] X`. -/\ndef pullbackSymmetry [HasPullback f g] : pullback f g ≅ pullback g f :=\n  IsLimit.conePointUniqueUpToIso\n    (PullbackCone.flipIsLimit (pullbackIsPullback f g) :\n      IsLimit (PullbackCone.mk _ _ pullback.condition.symm))\n    (limit.isLimit _)\n#align category_theory.limits.pullback_symmetry CategoryTheory.Limits.pullbackSymmetry\n\n@[reassoc (attr := simp)]\ntheorem pullbackSymmetry_hom_comp_fst [HasPullback f g] :\n    (pullbackSymmetry f g).hom ≫ pullback.fst = pullback.snd := by simp [pullbackSymmetry]\n#align category_theory.limits.pullback_symmetry_hom_comp_fst CategoryTheory.Limits.pullbackSymmetry_hom_comp_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackSymmetry_hom_comp_snd [HasPullback f g] :\n    (pullbackSymmetry f g).hom ≫ pullback.snd = pullback.fst := by simp [pullbackSymmetry]\n#align category_theory.limits.pullback_symmetry_hom_comp_snd CategoryTheory.Limits.pullbackSymmetry_hom_comp_snd\n\n@[reassoc (attr := simp)]\ntheorem pullbackSymmetry_inv_comp_fst [HasPullback f g] :\n    (pullbackSymmetry f g).inv ≫ pullback.fst = pullback.snd := by simp [Iso.inv_comp_eq]\n#align category_theory.limits.pullback_symmetry_inv_comp_fst CategoryTheory.Limits.pullbackSymmetry_inv_comp_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackSymmetry_inv_comp_snd [HasPullback f g] :\n    (pullbackSymmetry f g).inv ≫ pullback.snd = pullback.fst := by simp [Iso.inv_comp_eq]\n#align category_theory.limits.pullback_symmetry_inv_comp_snd CategoryTheory.Limits.pullbackSymmetry_inv_comp_snd\n\nend PullbackSymmetry\n\nsection PushoutSymmetry\n\nopen WalkingCospan\n\nvariable (f : X ⟶ Y) (g : X ⟶ Z)\n\n/-- Making this a global instance would make the typeclass seach go in an infinite loop. -/\ntheorem hasPushout_symmetry [HasPushout f g] : HasPushout g f :=\n  ⟨⟨⟨PushoutCocone.mk _ _ pushout.condition.symm,\n        PushoutCocone.flipIsColimit (pushoutIsPushout _ _)⟩⟩⟩\n#align category_theory.limits.has_pushout_symmetry CategoryTheory.Limits.hasPushout_symmetry\n\nattribute [local instance] hasPushout_symmetry\n\n/-- The isomorphism `Y ⨿[X] Z ≅ Z ⨿[X] Y`. -/\ndef pushoutSymmetry [HasPushout f g] : pushout f g ≅ pushout g f :=\n  IsColimit.coconePointUniqueUpToIso\n    (PushoutCocone.flipIsColimit (pushoutIsPushout f g) :\n      IsColimit (PushoutCocone.mk _ _ pushout.condition.symm))\n    (colimit.isColimit _)\n#align category_theory.limits.pushout_symmetry CategoryTheory.Limits.pushoutSymmetry\n\n@[reassoc (attr := simp)]\ntheorem inl_comp_pushoutSymmetry_hom [HasPushout f g] :\n    pushout.inl ≫ (pushoutSymmetry f g).hom = pushout.inr :=\n  (colimit.isColimit (span f g)).comp_coconePointUniqueUpToIso_hom\n    (PushoutCocone.flipIsColimit (pushoutIsPushout g f)) _\n#align category_theory.limits.inl_comp_pushout_symmetry_hom CategoryTheory.Limits.inl_comp_pushoutSymmetry_hom\n\n@[reassoc (attr := simp)]\ntheorem inr_comp_pushoutSymmetry_hom [HasPushout f g] :\n    pushout.inr ≫ (pushoutSymmetry f g).hom = pushout.inl :=\n  (colimit.isColimit (span f g)).comp_coconePointUniqueUpToIso_hom\n    (PushoutCocone.flipIsColimit (pushoutIsPushout g f)) _\n#align category_theory.limits.inr_comp_pushout_symmetry_hom CategoryTheory.Limits.inr_comp_pushoutSymmetry_hom\n\n@[reassoc (attr := simp)]\ntheorem inl_comp_pushoutSymmetry_inv [HasPushout f g] :\n    pushout.inl ≫ (pushoutSymmetry f g).inv = pushout.inr := by simp [Iso.comp_inv_eq]\n#align category_theory.limits.inl_comp_pushout_symmetry_inv CategoryTheory.Limits.inl_comp_pushoutSymmetry_inv\n\n@[reassoc (attr := simp)]\ntheorem inr_comp_pushoutSymmetry_inv [HasPushout f g] :\n    pushout.inr ≫ (pushoutSymmetry f g).inv = pushout.inl := by simp [Iso.comp_inv_eq]\n#align category_theory.limits.inr_comp_pushout_symmetry_inv CategoryTheory.Limits.inr_comp_pushoutSymmetry_inv\n\nend PushoutSymmetry\n\nsection PullbackLeftIso\n\nopen WalkingCospan\n\n/-- The pullback of `f, g` is also the pullback of `f ≫ i, g ≫ i` for any mono `i`. -/\nnoncomputable def pullbackIsPullbackOfCompMono (f : X ⟶ W) (g : Y ⟶ W) (i : W ⟶ Z) [Mono i]\n    [HasPullback f g] : IsLimit (PullbackCone.mk pullback.fst pullback.snd\n      (show pullback.fst ≫ f ≫ i = pullback.snd ≫ g ≫ i from by -- Porting note: used to be _\n        simp only [← Category.assoc]; rw [cancel_mono]; apply pullback.condition )) :=\n  PullbackCone.isLimitOfCompMono f g i _ (limit.isLimit (cospan f g))\n#align category_theory.limits.pullback_is_pullback_of_comp_mono CategoryTheory.Limits.pullbackIsPullbackOfCompMono\n\ninstance hasPullback_of_comp_mono (f : X ⟶ W) (g : Y ⟶ W) (i : W ⟶ Z) [Mono i] [HasPullback f g] :\n    HasPullback (f ≫ i) (g ≫ i) :=\n  ⟨⟨⟨_, pullbackIsPullbackOfCompMono f g i⟩⟩⟩\n#align category_theory.limits.has_pullback_of_comp_mono CategoryTheory.Limits.hasPullback_of_comp_mono\n\nvariable (f : X ⟶ Z) (g : Y ⟶ Z) [IsIso f]\n\n/-- If `f : X ⟶ Z` is iso, then `X ×[Z] Y ≅ Y`. This is the explicit limit cone. -/\ndef pullbackConeOfLeftIso : PullbackCone f g :=\n  PullbackCone.mk (g ≫ inv f) (𝟙 _) <| by simp\n#align category_theory.limits.pullback_cone_of_left_iso CategoryTheory.Limits.pullbackConeOfLeftIso\n\n@[simp]\ntheorem pullbackConeOfLeftIso_x : (pullbackConeOfLeftIso f g).pt = Y := rfl\nset_option linter.uppercaseLean3 false in\n#align category_theory.limits.pullback_cone_of_left_iso_X CategoryTheory.Limits.pullbackConeOfLeftIso_x\n\n@[simp]\ntheorem pullbackConeOfLeftIso_fst : (pullbackConeOfLeftIso f g).fst = g ≫ inv f := rfl\n#align category_theory.limits.pullback_cone_of_left_iso_fst CategoryTheory.Limits.pullbackConeOfLeftIso_fst\n\n@[simp]\ntheorem pullbackConeOfLeftIso_snd : (pullbackConeOfLeftIso f g).snd = 𝟙 _ := rfl\n#align category_theory.limits.pullback_cone_of_left_iso_snd CategoryTheory.Limits.pullbackConeOfLeftIso_snd\n\n-- Porting note: simp can prove this; removed simp\ntheorem pullbackConeOfLeftIso_π_app_none : (pullbackConeOfLeftIso f g).π.app none = g := by simp\n#align category_theory.limits.pullback_cone_of_left_iso_π_app_none CategoryTheory.Limits.pullbackConeOfLeftIso_π_app_none\n\n@[simp]\ntheorem pullbackConeOfLeftIso_π_app_left : (pullbackConeOfLeftIso f g).π.app left = g ≫ inv f :=\n  rfl\n#align category_theory.limits.pullback_cone_of_left_iso_π_app_left CategoryTheory.Limits.pullbackConeOfLeftIso_π_app_left\n\n@[simp]\ntheorem pullbackConeOfLeftIso_π_app_right : (pullbackConeOfLeftIso f g).π.app right = 𝟙 _ := rfl\n#align category_theory.limits.pullback_cone_of_left_iso_π_app_right CategoryTheory.Limits.pullbackConeOfLeftIso_π_app_right\n\n/-- Verify that the constructed limit cone is indeed a limit. -/\ndef pullbackConeOfLeftIsoIsLimit : IsLimit (pullbackConeOfLeftIso f g) :=\n  PullbackCone.isLimitAux' _ fun s => ⟨s.snd, by simp [← s.condition_assoc]⟩\n#align category_theory.limits.pullback_cone_of_left_iso_is_limit CategoryTheory.Limits.pullbackConeOfLeftIsoIsLimit\n\ntheorem hasPullback_of_left_iso : HasPullback f g :=\n  ⟨⟨⟨_, pullbackConeOfLeftIsoIsLimit f g⟩⟩⟩\n#align category_theory.limits.has_pullback_of_left_iso CategoryTheory.Limits.hasPullback_of_left_iso\n\nattribute [local instance] hasPullback_of_left_iso\n\ninstance pullback_snd_iso_of_left_iso : IsIso (pullback.snd : pullback f g ⟶ _) := by\n  refine' ⟨⟨pullback.lift (g ≫ inv f) (𝟙 _) (by simp), _, by simp⟩⟩\n  ext\n  · simp [← pullback.condition_assoc]\n  · simp [pullback.condition_assoc]\n#align category_theory.limits.pullback_snd_iso_of_left_iso CategoryTheory.Limits.pullback_snd_iso_of_left_iso\n\nvariable (i : Z ⟶ W) [Mono i]\n\ninstance hasPullback_of_right_factors_mono (f : X ⟶ Z) : HasPullback i (f ≫ i) := by\n  conv =>\n    congr\n    rw [← Category.id_comp i]\n  infer_instance\n#align category_theory.limits.has_pullback_of_right_factors_mono CategoryTheory.Limits.hasPullback_of_right_factors_mono\n\ninstance pullback_snd_iso_of_right_factors_mono (f : X ⟶ Z) :\n    IsIso (pullback.snd : pullback i (f ≫ i) ⟶ _) := by\n  convert (congrArg IsIso (show _ ≫ pullback.snd = _ from\n    limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono (𝟙 _) f i⟩ WalkingCospan.right)).mp\n    inferInstance;\n  · exact (Category.id_comp _).symm\n  · exact (Category.id_comp _).symm\n#align category_theory.limits.pullback_snd_iso_of_right_factors_mono CategoryTheory.Limits.pullback_snd_iso_of_right_factors_mono\n\nend PullbackLeftIso\n\nsection PullbackRightIso\n\nopen WalkingCospan\n\nvariable (f : X ⟶ Z) (g : Y ⟶ Z) [IsIso g]\n\n/-- If `g : Y ⟶ Z` is iso, then `X ×[Z] Y ≅ X`. This is the explicit limit cone. -/\ndef pullbackConeOfRightIso : PullbackCone f g :=\n  PullbackCone.mk (𝟙 _) (f ≫ inv g) <| by simp\n#align category_theory.limits.pullback_cone_of_right_iso CategoryTheory.Limits.pullbackConeOfRightIso\n\n@[simp]\ntheorem pullbackConeOfRightIso_x : (pullbackConeOfRightIso f g).pt = X := rfl\nset_option linter.uppercaseLean3 false in\n#align category_theory.limits.pullback_cone_of_right_iso_X CategoryTheory.Limits.pullbackConeOfRightIso_x\n\n@[simp]\ntheorem pullbackConeOfRightIso_fst : (pullbackConeOfRightIso f g).fst = 𝟙 _ := rfl\n#align category_theory.limits.pullback_cone_of_right_iso_fst CategoryTheory.Limits.pullbackConeOfRightIso_fst\n\n@[simp]\ntheorem pullbackConeOfRightIso_snd : (pullbackConeOfRightIso f g).snd = f ≫ inv g := rfl\n#align category_theory.limits.pullback_cone_of_right_iso_snd CategoryTheory.Limits.pullbackConeOfRightIso_snd\n\n-- Porting note: simp can prove this; removed simps\ntheorem pullbackConeOfRightIso_π_app_none : (pullbackConeOfRightIso f g).π.app none = f := by simp\n#align category_theory.limits.pullback_cone_of_right_iso_π_app_none CategoryTheory.Limits.pullbackConeOfRightIso_π_app_none\n\n@[simp]\ntheorem pullbackConeOfRightIso_π_app_left : (pullbackConeOfRightIso f g).π.app left = 𝟙 _ :=\n  rfl\n#align category_theory.limits.pullback_cone_of_right_iso_π_app_left CategoryTheory.Limits.pullbackConeOfRightIso_π_app_left\n\n@[simp]\ntheorem pullbackConeOfRightIso_π_app_right : (pullbackConeOfRightIso f g).π.app right = f ≫ inv g\n  := rfl\n#align category_theory.limits.pullback_cone_of_right_iso_π_app_right CategoryTheory.Limits.pullbackConeOfRightIso_π_app_right\n\n/-- Verify that the constructed limit cone is indeed a limit. -/\ndef pullbackConeOfRightIsoIsLimit : IsLimit (pullbackConeOfRightIso f g) :=\n  PullbackCone.isLimitAux' _ fun s => ⟨s.fst, by simp [s.condition_assoc]⟩\n#align category_theory.limits.pullback_cone_of_right_iso_is_limit CategoryTheory.Limits.pullbackConeOfRightIsoIsLimit\n\ntheorem hasPullback_of_right_iso : HasPullback f g :=\n  ⟨⟨⟨_, pullbackConeOfRightIsoIsLimit f g⟩⟩⟩\n#align category_theory.limits.has_pullback_of_right_iso CategoryTheory.Limits.hasPullback_of_right_iso\n\nattribute [local instance] hasPullback_of_right_iso\n\ninstance pullback_snd_iso_of_right_iso : IsIso (pullback.fst : pullback f g ⟶ _) := by\n  refine' ⟨⟨pullback.lift (𝟙 _) (f ≫ inv g) (by simp), _, by simp⟩⟩\n  ext\n  · simp\n  · simp [pullback.condition_assoc]\n#align category_theory.limits.pullback_snd_iso_of_right_iso CategoryTheory.Limits.pullback_snd_iso_of_right_iso\n\nvariable (i : Z ⟶ W) [Mono i]\n\ninstance hasPullback_of_left_factors_mono (f : X ⟶ Z) : HasPullback (f ≫ i) i := by\n  conv =>\n    congr\n    case g => rw [← Category.id_comp i]\n  infer_instance\n#align category_theory.limits.has_pullback_of_left_factors_mono CategoryTheory.Limits.hasPullback_of_left_factors_mono\n\ninstance pullback_snd_iso_of_left_factors_mono (f : X ⟶ Z) :\n    IsIso (pullback.fst : pullback (f ≫ i) i ⟶ _) := by\n  convert (congrArg IsIso (show _ ≫ pullback.fst = _ from\n    limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono f (𝟙 _) i⟩ WalkingCospan.left)).mp\n    inferInstance;\n  · exact (Category.id_comp _).symm\n  · exact (Category.id_comp _).symm\n#align category_theory.limits.pullback_snd_iso_of_left_factors_mono CategoryTheory.Limits.pullback_snd_iso_of_left_factors_mono\n\nend PullbackRightIso\n\nsection PushoutLeftIso\n\nopen WalkingSpan\n\n/-- The pushout of `f, g` is also the pullback of `h ≫ f, h ≫ g` for any epi `h`. -/\nnoncomputable def pushoutIsPushoutOfEpiComp (f : X ⟶ Y) (g : X ⟶ Z) (h : W ⟶ X) [Epi h]\n    [HasPushout f g] : IsColimit (PushoutCocone.mk pushout.inl pushout.inr\n    (show (h ≫ f) ≫ pushout.inl = (h ≫ g) ≫ pushout.inr from by\n    simp only [Category.assoc]; rw [cancel_epi]; exact pushout.condition)) :=\n  PushoutCocone.isColimitOfEpiComp f g h _ (colimit.isColimit (span f g))\n#align category_theory.limits.pushout_is_pushout_of_epi_comp CategoryTheory.Limits.pushoutIsPushoutOfEpiComp\n\ninstance hasPushout_of_epi_comp (f : X ⟶ Y) (g : X ⟶ Z) (h : W ⟶ X) [Epi h] [HasPushout f g] :\n    HasPushout (h ≫ f) (h ≫ g) :=\n  ⟨⟨⟨_, pushoutIsPushoutOfEpiComp f g h⟩⟩⟩\n#align category_theory.limits.has_pushout_of_epi_comp CategoryTheory.Limits.hasPushout_of_epi_comp\n\nvariable (f : X ⟶ Y) (g : X ⟶ Z) [IsIso f]\n\n/-- If `f : X ⟶ Y` is iso, then `Y ⨿[X] Z ≅ Z`. This is the explicit colimit cocone. -/\ndef pushoutCoconeOfLeftIso : PushoutCocone f g :=\n  PushoutCocone.mk (inv f ≫ g) (𝟙 _) <| by simp\n#align category_theory.limits.pushout_cocone_of_left_iso CategoryTheory.Limits.pushoutCoconeOfLeftIso\n\n@[simp]\ntheorem pushoutCoconeOfLeftIso_x : (pushoutCoconeOfLeftIso f g).pt = Z := rfl\nset_option linter.uppercaseLean3 false in\n#align category_theory.limits.pushout_cocone_of_left_iso_X CategoryTheory.Limits.pushoutCoconeOfLeftIso_x\n\n@[simp]\ntheorem pushoutCoconeOfLeftIso_inl : (pushoutCoconeOfLeftIso f g).inl = inv f ≫ g := rfl\n#align category_theory.limits.pushout_cocone_of_left_iso_inl CategoryTheory.Limits.pushoutCoconeOfLeftIso_inl\n\n@[simp]\ntheorem pushoutCoconeOfLeftIso_inr : (pushoutCoconeOfLeftIso f g).inr = 𝟙 _ := rfl\n#align category_theory.limits.pushout_cocone_of_left_iso_inr CategoryTheory.Limits.pushoutCoconeOfLeftIso_inr\n\n-- Porting note: simp can prove this; removed simp\ntheorem pushoutCoconeOfLeftIso_ι_app_none : (pushoutCoconeOfLeftIso f g).ι.app none = g := by\n  simp\n#align category_theory.limits.pushout_cocone_of_left_iso_ι_app_none CategoryTheory.Limits.pushoutCoconeOfLeftIso_ι_app_none\n\n@[simp]\ntheorem pushoutCoconeOfLeftIso_ι_app_left : (pushoutCoconeOfLeftIso f g).ι.app left = inv f ≫ g :=\n  rfl\n#align category_theory.limits.pushout_cocone_of_left_iso_ι_app_left CategoryTheory.Limits.pushoutCoconeOfLeftIso_ι_app_left\n\n@[simp]\ntheorem pushoutCoconeOfLeftIso_ι_app_right : (pushoutCoconeOfLeftIso f g).ι.app right = 𝟙 _ := rfl\n#align category_theory.limits.pushout_cocone_of_left_iso_ι_app_right CategoryTheory.Limits.pushoutCoconeOfLeftIso_ι_app_right\n\n/-- Verify that the constructed cocone is indeed a colimit. -/\ndef pushoutCoconeOfLeftIsoIsLimit : IsColimit (pushoutCoconeOfLeftIso f g) :=\n  PushoutCocone.isColimitAux' _ fun s => ⟨s.inr, by simp [← s.condition]⟩\n#align category_theory.limits.pushout_cocone_of_left_iso_is_limit CategoryTheory.Limits.pushoutCoconeOfLeftIsoIsLimit\n\n\n\nattribute [local instance] hasPushout_of_left_iso\n\ninstance pushout_inr_iso_of_left_iso : IsIso (pushout.inr : _ ⟶ pushout f g) := by\n  refine' ⟨⟨pushout.desc (inv f ≫ g) (𝟙 _) (by simp), by simp, _⟩⟩\n  ext\n  · simp [← pushout.condition]\n  · simp [pushout.condition_assoc]\n#align category_theory.limits.pushout_inr_iso_of_left_iso CategoryTheory.Limits.pushout_inr_iso_of_left_iso\n\nvariable (h : W ⟶ X) [Epi h]\n\ninstance hasPushout_of_right_factors_epi (f : X ⟶ Y) : HasPushout h (h ≫ f) := by\n  conv =>\n    congr\n    rw [← Category.comp_id h]\n  infer_instance\n#align category_theory.limits.has_pushout_of_right_factors_epi CategoryTheory.Limits.hasPushout_of_right_factors_epi\n\ninstance pushout_inr_iso_of_right_factors_epi (f : X ⟶ Y) :\n    IsIso (pushout.inr : _ ⟶ pushout h (h ≫ f)) := by\n  convert (congrArg IsIso (show pushout.inr ≫ _ = _ from colimit.isoColimitCocone_ι_inv\n    ⟨_, pushoutIsPushoutOfEpiComp (𝟙 _) f h⟩ WalkingSpan.right)).mp\n    inferInstance\n  · apply (Category.comp_id _).symm\n  · apply (Category.comp_id _).symm\n#align category_theory.limits.pushout_inr_iso_of_right_factors_epi CategoryTheory.Limits.pushout_inr_iso_of_right_factors_epi\n\nend PushoutLeftIso\n\nsection PushoutRightIso\n\nopen WalkingSpan\n\nvariable (f : X ⟶ Y) (g : X ⟶ Z) [IsIso g]\n\n/-- If `f : X ⟶ Z` is iso, then `Y ⨿[X] Z ≅ Y`. This is the explicit colimit cocone. -/\ndef pushoutCoconeOfRightIso : PushoutCocone f g :=\n  PushoutCocone.mk (𝟙 _) (inv g ≫ f) <| by simp\n#align category_theory.limits.pushout_cocone_of_right_iso CategoryTheory.Limits.pushoutCoconeOfRightIso\n\n@[simp]\ntheorem pushoutCoconeOfRightIso_x : (pushoutCoconeOfRightIso f g).pt = Y := rfl\nset_option linter.uppercaseLean3 false in\n#align category_theory.limits.pushout_cocone_of_right_iso_X CategoryTheory.Limits.pushoutCoconeOfRightIso_x\n\n@[simp]\ntheorem pushoutCoconeOfRightIso_inl : (pushoutCoconeOfRightIso f g).inl = 𝟙 _ := rfl\n#align category_theory.limits.pushout_cocone_of_right_iso_inl CategoryTheory.Limits.pushoutCoconeOfRightIso_inl\n\n@[simp]\ntheorem pushoutCoconeOfRightIso_inr : (pushoutCoconeOfRightIso f g).inr = inv g ≫ f := rfl\n#align category_theory.limits.pushout_cocone_of_right_iso_inr CategoryTheory.Limits.pushoutCoconeOfRightIso_inr\n\n-- Porting note: simp can prove this; removed simp\ntheorem pushoutCoconeOfRightIso_ι_app_none : (pushoutCoconeOfRightIso f g).ι.app none = f := by\n  simp\n#align category_theory.limits.pushout_cocone_of_right_iso_ι_app_none CategoryTheory.Limits.pushoutCoconeOfRightIso_ι_app_none\n\n@[simp]\ntheorem pushoutCoconeOfRightIso_ι_app_left : (pushoutCoconeOfRightIso f g).ι.app left = 𝟙 _ := rfl\n#align category_theory.limits.pushout_cocone_of_right_iso_ι_app_left CategoryTheory.Limits.pushoutCoconeOfRightIso_ι_app_left\n\n@[simp]\ntheorem pushoutCoconeOfRightIso_ι_app_right :\n    (pushoutCoconeOfRightIso f g).ι.app right = inv g ≫ f := rfl\n#align category_theory.limits.pushout_cocone_of_right_iso_ι_app_right CategoryTheory.Limits.pushoutCoconeOfRightIso_ι_app_right\n\n/-- Verify that the constructed cocone is indeed a colimit. -/\ndef pushoutCoconeOfRightIsoIsLimit : IsColimit (pushoutCoconeOfRightIso f g) :=\n  PushoutCocone.isColimitAux' _ fun s => ⟨s.inl, by simp [← s.condition]⟩\n#align category_theory.limits.pushout_cocone_of_right_iso_is_limit CategoryTheory.Limits.pushoutCoconeOfRightIsoIsLimit\n\ntheorem hasPushout_of_right_iso : HasPushout f g :=\n  ⟨⟨⟨_, pushoutCoconeOfRightIsoIsLimit f g⟩⟩⟩\n#align category_theory.limits.has_pushout_of_right_iso CategoryTheory.Limits.hasPushout_of_right_iso\n\nattribute [local instance] hasPushout_of_right_iso\n\ninstance pushout_inl_iso_of_right_iso : IsIso (pushout.inl : _ ⟶ pushout f g) := by\n  refine' ⟨⟨pushout.desc (𝟙 _) (inv g ≫ f) (by simp), by simp, _⟩⟩\n  ext\n  · simp [← pushout.condition]\n  · simp [pushout.condition]\n#align category_theory.limits.pushout_inl_iso_of_right_iso CategoryTheory.Limits.pushout_inl_iso_of_right_iso\n\nvariable (h : W ⟶ X) [Epi h]\n\ninstance hasPushout_of_left_factors_epi (f : X ⟶ Y) : HasPushout (h ≫ f) h := by\n  conv =>\n    congr\n    case g => rw [← Category.comp_id h]\n  infer_instance\n#align category_theory.limits.has_pushout_of_left_factors_epi CategoryTheory.Limits.hasPushout_of_left_factors_epi\n\ninstance pushout_inl_iso_of_left_factors_epi (f : X ⟶ Y) :\n    IsIso (pushout.inl : _ ⟶ pushout (h ≫ f) h) := by\n  convert (congrArg IsIso (show pushout.inl ≫ _ = _ from colimit.isoColimitCocone_ι_inv\n    ⟨_, pushoutIsPushoutOfEpiComp f (𝟙 _) h⟩ WalkingSpan.left)).mp\n        inferInstance;\n  · exact (Category.comp_id _).symm\n  · exact (Category.comp_id _).symm\n#align category_theory.limits.pushout_inl_iso_of_left_factors_epi CategoryTheory.Limits.pushout_inl_iso_of_left_factors_epi\n\nend PushoutRightIso\n\nsection\n\nopen WalkingCospan\n\nvariable (f : X ⟶ Y)\n\ninstance has_kernel_pair_of_mono [Mono f] : HasPullback f f :=\n  ⟨⟨⟨_, PullbackCone.isLimitMkIdId f⟩⟩⟩\n#align category_theory.limits.has_kernel_pair_of_mono CategoryTheory.Limits.has_kernel_pair_of_mono\n\ntheorem fst_eq_snd_of_mono_eq [Mono f] : (pullback.fst : pullback f f ⟶ _) = pullback.snd :=\n  ((PullbackCone.isLimitMkIdId f).fac (getLimitCone (cospan f f)).cone left).symm.trans\n    ((PullbackCone.isLimitMkIdId f).fac (getLimitCone (cospan f f)).cone right : _)\n#align category_theory.limits.fst_eq_snd_of_mono_eq CategoryTheory.Limits.fst_eq_snd_of_mono_eq\n\n@[simp]\ntheorem pullbackSymmetry_hom_of_mono_eq [Mono f] : (pullbackSymmetry f f).hom = 𝟙 _ := by\n  ext; simp [fst_eq_snd_of_mono_eq]; simp [fst_eq_snd_of_mono_eq]\n#align category_theory.limits.pullback_symmetry_hom_of_mono_eq CategoryTheory.Limits.pullbackSymmetry_hom_of_mono_eq\n\ninstance fst_iso_of_mono_eq [Mono f] : IsIso (pullback.fst : pullback f f ⟶ _) := by\n  refine' ⟨⟨pullback.lift (𝟙 _) (𝟙 _) (by simp), _, by simp⟩⟩\n  ext\n  · simp\n  · simp [fst_eq_snd_of_mono_eq]\n#align category_theory.limits.fst_iso_of_mono_eq CategoryTheory.Limits.fst_iso_of_mono_eq\n\ninstance snd_iso_of_mono_eq [Mono f] : IsIso (pullback.snd : pullback f f ⟶ _) := by\n  rw [← fst_eq_snd_of_mono_eq]\n  infer_instance\n#align category_theory.limits.snd_iso_of_mono_eq CategoryTheory.Limits.snd_iso_of_mono_eq\n\nend\n\nsection\n\nopen WalkingSpan\n\nvariable (f : X ⟶ Y)\n\ninstance has_cokernel_pair_of_epi [Epi f] : HasPushout f f :=\n  ⟨⟨⟨_, PushoutCocone.isColimitMkIdId f⟩⟩⟩\n#align category_theory.limits.has_cokernel_pair_of_epi CategoryTheory.Limits.has_cokernel_pair_of_epi\n\ntheorem inl_eq_inr_of_epi_eq [Epi f] : (pushout.inl : _ ⟶ pushout f f) = pushout.inr :=\n  ((PushoutCocone.isColimitMkIdId f).fac (getColimitCocone (span f f)).cocone left).symm.trans\n    ((PushoutCocone.isColimitMkIdId f).fac (getColimitCocone (span f f)).cocone right : _)\n#align category_theory.limits.inl_eq_inr_of_epi_eq CategoryTheory.Limits.inl_eq_inr_of_epi_eq\n\n@[simp]\ntheorem pullback_symmetry_hom_of_epi_eq [Epi f] : (pushoutSymmetry f f).hom = 𝟙 _ := by\n  ext <;> simp [inl_eq_inr_of_epi_eq]\n#align category_theory.limits.pullback_symmetry_hom_of_epi_eq CategoryTheory.Limits.pullback_symmetry_hom_of_epi_eq\n\ninstance inl_iso_of_epi_eq [Epi f] : IsIso (pushout.inl : _ ⟶ pushout f f) := by\n  refine' ⟨⟨pushout.desc (𝟙 _) (𝟙 _) (by simp), by simp, _⟩⟩\n  apply pushout.hom_ext\n  · simp\n  · simp [inl_eq_inr_of_epi_eq]\n#align category_theory.limits.inl_iso_of_epi_eq CategoryTheory.Limits.inl_iso_of_epi_eq\n\ninstance inr_iso_of_epi_eq [Epi f] : IsIso (pushout.inr : _ ⟶ pushout f f) := by\n  rw [← inl_eq_inr_of_epi_eq]\n  infer_instance\n#align category_theory.limits.inr_iso_of_epi_eq CategoryTheory.Limits.inr_iso_of_epi_eq\n\nend\n\nsection PasteLemma\n\nvariable {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C} (f₁ : X₁ ⟶ X₂) (f₂ : X₂ ⟶ X₃) (g₁ : Y₁ ⟶ Y₂) (g₂ : Y₂ ⟶ Y₃)\n\nvariable (i₁ : X₁ ⟶ Y₁) (i₂ : X₂ ⟶ Y₂) (i₃ : X₃ ⟶ Y₃)\n\nvariable (h₁ : i₁ ≫ g₁ = f₁ ≫ i₂) (h₂ : i₂ ≫ g₂ = f₂ ≫ i₃)\n\n/-- Given\n\nX₁ - f₁ -> X₂ - f₂ -> X₃\n|          |          |\ni₁         i₂         i₃\n∨          ∨          ∨\nY₁ - g₁ -> Y₂ - g₂ -> Y₃\n\nThen the big square is a pullback if both the small squares are.\n-/\ndef bigSquareIsPullback (H : IsLimit (PullbackCone.mk _ _ h₂))\n    (H' : IsLimit (PullbackCone.mk _ _ h₁)) :\n    IsLimit\n      (PullbackCone.mk _ _\n        (show i₁ ≫ g₁ ≫ g₂ = (f₁ ≫ f₂) ≫ i₃ by\n          rw [← Category.assoc, h₁, Category.assoc, h₂, Category.assoc])) := by\n  fapply PullbackCone.isLimitAux'\n  intro s\n  have : (s.fst ≫ g₁) ≫ g₂ = s.snd ≫ i₃ := by rw [← s.condition, Category.assoc]\n  rcases PullbackCone.IsLimit.lift' H (s.fst ≫ g₁) s.snd this with ⟨l₁, hl₁, hl₁'⟩\n  rcases PullbackCone.IsLimit.lift' H' s.fst l₁ hl₁.symm with ⟨l₂, hl₂, hl₂'⟩\n  use l₂\n  use hl₂\n  use\n    show l₂ ≫ f₁ ≫ f₂ = s.snd by\n      rw [← hl₁', ← hl₂', Category.assoc]\n      rfl\n  intro m hm₁ hm₂\n  apply PullbackCone.IsLimit.hom_ext H'\n  · erw [hm₁, hl₂]\n  · apply PullbackCone.IsLimit.hom_ext H\n    · erw [Category.assoc, ← h₁, ← Category.assoc, hm₁, ← hl₂, Category.assoc, Category.assoc, h₁]\n      rfl\n    · erw [Category.assoc, hm₂, ← hl₁', ← hl₂']\n#align category_theory.limits.big_square_is_pullback CategoryTheory.Limits.bigSquareIsPullback\n\n/-- Given\n\nX₁ - f₁ -> X₂ - f₂ -> X₃\n|          |          |\ni₁         i₂         i₃\n∨          ∨          ∨\nY₁ - g₁ -> Y₂ - g₂ -> Y₃\n\nThen the big square is a pushout if both the small squares are.\n-/\ndef bigSquareIsPushout (H : IsColimit (PushoutCocone.mk _ _ h₂))\n    (H' : IsColimit (PushoutCocone.mk _ _ h₁)) :\n    IsColimit\n      (PushoutCocone.mk _ _\n        (show i₁ ≫ g₁ ≫ g₂ = (f₁ ≫ f₂) ≫ i₃ by\n          rw [← Category.assoc, h₁, Category.assoc, h₂, Category.assoc])) := by\n  fapply PushoutCocone.isColimitAux'\n  intro s\n  have : i₁ ≫ s.inl = f₁ ≫ f₂ ≫ s.inr := by rw [s.condition, Category.assoc]\n  rcases PushoutCocone.IsColimit.desc' H' s.inl (f₂ ≫ s.inr) this with ⟨l₁, hl₁, hl₁'⟩\n  rcases PushoutCocone.IsColimit.desc' H l₁ s.inr hl₁' with ⟨l₂, hl₂, hl₂'⟩\n  use l₂\n  use\n    show (g₁ ≫ g₂) ≫ l₂ = s.inl by\n      rw [← hl₁, ← hl₂, Category.assoc]\n      rfl\n  use hl₂'\n  intro m hm₁ hm₂\n  apply PushoutCocone.IsColimit.hom_ext H\n  · apply PushoutCocone.IsColimit.hom_ext H'\n    · erw [← Category.assoc, hm₁, hl₂, hl₁]\n    · erw [← Category.assoc, h₂, Category.assoc, hm₂, ← hl₂', ← Category.assoc, ← Category.assoc, ←\n        h₂]\n      rfl\n  · erw [hm₂, hl₂']\n#align category_theory.limits.big_square_is_pushout CategoryTheory.Limits.bigSquareIsPushout\n\n/-- Given\n\nX₁ - f₁ -> X₂ - f₂ -> X₃\n|          |          |\ni₁         i₂         i₃\n∨          ∨          ∨\nY₁ - g₁ -> Y₂ - g₂ -> Y₃\n\nThen the left square is a pullback if the right square and the big square are.\n-/\ndef leftSquareIsPullback (H : IsLimit (PullbackCone.mk _ _ h₂))\n    (H' :\n      IsLimit\n        (PullbackCone.mk _ _\n          (show i₁ ≫ g₁ ≫ g₂ = (f₁ ≫ f₂) ≫ i₃ by\n            rw [← Category.assoc, h₁, Category.assoc, h₂, Category.assoc]))) :\n    IsLimit (PullbackCone.mk _ _ h₁) := by\n  fapply PullbackCone.isLimitAux'\n  intro s\n  have : s.fst ≫ g₁ ≫ g₂ = (s.snd ≫ f₂) ≫ i₃ := by\n    rw [← Category.assoc, s.condition, Category.assoc, Category.assoc, h₂]\n  rcases PullbackCone.IsLimit.lift' H' s.fst (s.snd ≫ f₂) this with ⟨l₁, hl₁, hl₁'⟩\n  use l₁\n  use hl₁\n  constructor\n  · apply PullbackCone.IsLimit.hom_ext H\n    · erw [Category.assoc, ← h₁, ← Category.assoc, hl₁, s.condition]\n      rfl\n    · erw [Category.assoc, hl₁']\n      rfl\n  · intro m hm₁ hm₂\n    apply PullbackCone.IsLimit.hom_ext H'\n    · erw [hm₁, hl₁]\n    · erw [hl₁', ← hm₂]\n      exact (Category.assoc _ _ _).symm\n#align category_theory.limits.left_square_is_pullback CategoryTheory.Limits.leftSquareIsPullback\n\n/-- Given\n\nX₁ - f₁ -> X₂ - f₂ -> X₃\n|          |          |\ni₁         i₂         i₃\n∨          ∨          ∨\nY₁ - g₁ -> Y₂ - g₂ -> Y₃\n\nThen the right square is a pushout if the left square and the big square are.\n-/\ndef rightSquareIsPushout (H : IsColimit (PushoutCocone.mk _ _ h₁))\n    (H' :\n      IsColimit\n        (PushoutCocone.mk _ _\n          (show i₁ ≫ g₁ ≫ g₂ = (f₁ ≫ f₂) ≫ i₃ by\n            rw [← Category.assoc, h₁, Category.assoc, h₂, Category.assoc]))) :\n    IsColimit (PushoutCocone.mk _ _ h₂) := by\n  fapply PushoutCocone.isColimitAux'\n  intro s\n  have : i₁ ≫ g₁ ≫ s.inl = (f₁ ≫ f₂) ≫ s.inr := by\n    rw [Category.assoc, ← s.condition, ← Category.assoc, ← Category.assoc, h₁]\n  rcases PushoutCocone.IsColimit.desc' H' (g₁ ≫ s.inl) s.inr this with ⟨l₁, hl₁, hl₁'⟩\n  dsimp at *\n  use l₁\n  refine' ⟨_, _, _⟩\n  · apply PushoutCocone.IsColimit.hom_ext H\n    · erw [← Category.assoc, hl₁]\n      rfl\n    · erw [← Category.assoc, h₂, Category.assoc, hl₁', s.condition]\n  · exact hl₁'\n  · intro m hm₁ hm₂\n    apply PushoutCocone.IsColimit.hom_ext H'\n    · erw [hl₁, Category.assoc, hm₁]\n    · erw [hm₂, hl₁']\n#align category_theory.limits.right_square_is_pushout CategoryTheory.Limits.rightSquareIsPushout\n\nend PasteLemma\n\nsection\n\nvariable (f : X ⟶ Z) (g : Y ⟶ Z) (f' : W ⟶ X)\n\nvariable [HasPullback f g] [HasPullback f' (pullback.fst : pullback f g ⟶ _)]\n\nvariable [HasPullback (f' ≫ f) g]\n\n/-- The canonical isomorphism `W ×[X] (X ×[Z] Y) ≅ W ×[Z] Y` -/\nnoncomputable def pullbackRightPullbackFstIso :\n    pullback f' (pullback.fst : pullback f g ⟶ _) ≅ pullback (f' ≫ f) g := by\n  let this :=\n    bigSquareIsPullback (pullback.snd : pullback f' (pullback.fst : pullback f g ⟶ _) ⟶ _)\n      pullback.snd f' f pullback.fst pullback.fst g pullback.condition pullback.condition\n      (pullbackIsPullback _ _) (pullbackIsPullback _ _)\n  exact (this.conePointUniqueUpToIso (pullbackIsPullback _ _) : _)\n#align category_theory.limits.pullback_right_pullback_fst_iso CategoryTheory.Limits.pullbackRightPullbackFstIso\n\n@[reassoc (attr := simp)]\ntheorem pullbackRightPullbackFstIso_hom_fst :\n    (pullbackRightPullbackFstIso f g f').hom ≫ pullback.fst = pullback.fst :=\n  IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left\n#align category_theory.limits.pullback_right_pullback_fst_iso_hom_fst CategoryTheory.Limits.pullbackRightPullbackFstIso_hom_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackRightPullbackFstIso_hom_snd :\n    (pullbackRightPullbackFstIso f g f').hom ≫ pullback.snd = pullback.snd ≫ pullback.snd :=\n  IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.right\n#align category_theory.limits.pullback_right_pullback_fst_iso_hom_snd CategoryTheory.Limits.pullbackRightPullbackFstIso_hom_snd\n\n@[reassoc (attr := simp)]\ntheorem pullbackRightPullbackFstIso_inv_fst :\n    (pullbackRightPullbackFstIso f g f').inv ≫ pullback.fst = pullback.fst :=\n  IsLimit.conePointUniqueUpToIso_inv_comp _ _ WalkingCospan.left\n#align category_theory.limits.pullback_right_pullback_fst_iso_inv_fst CategoryTheory.Limits.pullbackRightPullbackFstIso_inv_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackRightPullbackFstIso_inv_snd_snd :\n    (pullbackRightPullbackFstIso f g f').inv ≫ pullback.snd ≫ pullback.snd = pullback.snd :=\n  IsLimit.conePointUniqueUpToIso_inv_comp _ _ WalkingCospan.right\n#align category_theory.limits.pullback_right_pullback_fst_iso_inv_snd_snd CategoryTheory.Limits.pullbackRightPullbackFstIso_inv_snd_snd\n\n@[reassoc (attr := simp)]\ntheorem pullbackRightPullbackFstIso_inv_snd_fst :\n    (pullbackRightPullbackFstIso f g f').inv ≫ pullback.snd ≫ pullback.fst = pullback.fst ≫ f' := by\n  rw [← pullback.condition]\n  exact pullbackRightPullbackFstIso_inv_fst_assoc _ _ _ _\n#align category_theory.limits.pullback_right_pullback_fst_iso_inv_snd_fst CategoryTheory.Limits.pullbackRightPullbackFstIso_inv_snd_fst\n\nend\n\nsection\n\nvariable (f : X ⟶ Y) (g : X ⟶ Z) (g' : Z ⟶ W)\n\nvariable [HasPushout f g] [HasPushout (pushout.inr : _ ⟶ pushout f g) g']\n\nvariable [HasPushout f (g ≫ g')]\n\n/-- The canonical isomorphism `(Y ⨿[X] Z) ⨿[Z] W ≅ Y ×[X] W` -/\nnoncomputable def pushoutLeftPushoutInrIso :\n    pushout (pushout.inr : _ ⟶ pushout f g) g' ≅ pushout f (g ≫ g') :=\n  ((bigSquareIsPushout g g' _ _ f _ _ pushout.condition pushout.condition (pushoutIsPushout _ _)\n          (pushoutIsPushout _ _)).coconePointUniqueUpToIso\n      (pushoutIsPushout _ _) :\n    _)\n#align category_theory.limits.pushout_left_pushout_inr_iso CategoryTheory.Limits.pushoutLeftPushoutInrIso\n\n@[reassoc (attr := simp)]\ntheorem inl_pushoutLeftPushoutInrIso_inv :\n    pushout.inl ≫ (pushoutLeftPushoutInrIso f g g').inv = pushout.inl ≫ pushout.inl :=\n  ((bigSquareIsPushout g g' _ _ f _ _ pushout.condition pushout.condition (pushoutIsPushout _ _)\n          (pushoutIsPushout _ _)).comp_coconePointUniqueUpToIso_inv\n      (pushoutIsPushout _ _) WalkingSpan.left :\n    _)\n#align category_theory.limits.inl_pushout_left_pushout_inr_iso_inv CategoryTheory.Limits.inl_pushoutLeftPushoutInrIso_inv\n\n@[reassoc (attr := simp)]\ntheorem inr_pushoutLeftPushoutInrIso_hom :\n    pushout.inr ≫ (pushoutLeftPushoutInrIso f g g').hom = pushout.inr :=\n  ((bigSquareIsPushout g g' _ _ f _ _ pushout.condition pushout.condition (pushoutIsPushout _ _)\n          (pushoutIsPushout _ _)).comp_coconePointUniqueUpToIso_hom\n      (pushoutIsPushout _ _) WalkingSpan.right :\n    _)\n#align category_theory.limits.inr_pushout_left_pushout_inr_iso_hom CategoryTheory.Limits.inr_pushoutLeftPushoutInrIso_hom\n\n@[reassoc (attr := simp)]\ntheorem inr_pushoutLeftPushoutInrIso_inv :\n    pushout.inr ≫ (pushoutLeftPushoutInrIso f g g').inv = pushout.inr := by\n  rw [Iso.comp_inv_eq, inr_pushoutLeftPushoutInrIso_hom]\n#align category_theory.limits.inr_pushout_left_pushout_inr_iso_inv CategoryTheory.Limits.inr_pushoutLeftPushoutInrIso_inv\n\n@[reassoc (attr := simp)]\ntheorem inl_inl_pushoutLeftPushoutInrIso_hom :\n    pushout.inl ≫ pushout.inl ≫ (pushoutLeftPushoutInrIso f g g').hom = pushout.inl := by\n  rw [← Category.assoc, ← Iso.eq_comp_inv, inl_pushoutLeftPushoutInrIso_inv]\n#align category_theory.limits.inl_inl_pushout_left_pushout_inr_iso_hom CategoryTheory.Limits.inl_inl_pushoutLeftPushoutInrIso_hom\n\n@[reassoc (attr := simp)]\ntheorem inr_inl_pushoutLeftPushoutInrIso_hom :\n    pushout.inr ≫ pushout.inl ≫ (pushoutLeftPushoutInrIso f g g').hom = g' ≫ pushout.inr := by\n  rw [← Category.assoc, ← Iso.eq_comp_inv, Category.assoc, inr_pushoutLeftPushoutInrIso_inv,\n    pushout.condition]\n#align category_theory.limits.inr_inl_pushout_left_pushout_inr_iso_hom CategoryTheory.Limits.inr_inl_pushoutLeftPushoutInrIso_hom\n\nend\n\nsection PullbackAssoc\n\n/-\nThe objects and morphisms are as follows:\n\n           Z₂ - g₄ -> X₃\n           |          |\n           g₃         f₄\n           ∨          ∨\nZ₁ - g₂ -> X₂ - f₃ -> Y₂\n|          |\ng₁         f₂\n∨          ∨\nX₁ - f₁ -> Y₁\n\nwhere the two squares are pullbacks.\n\nWe can then construct the pullback squares\n\nW  - l₂ -> Z₂ - g₄ -> X₃\n|                     |\nl₁                    f₄\n∨                     ∨\nZ₁ - g₂ -> X₂ - f₃ -> Y₂\n\nand\n\nW' - l₂' -> Z₂\n|           |\nl₁'         g₃\n∨           ∨\nZ₁          X₂\n|           |\ng₁          f₂\n∨           ∨\nX₁ -  f₁ -> Y₁\n\nWe will show that both `W` and `W'` are pullbacks over `g₁, g₂`, and thus we may construct a\ncanonical isomorphism between them. -/\nvariable {X₁ X₂ X₃ Y₁ Y₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₁) (f₃ : X₂ ⟶ Y₂)\n\nvariable (f₄ : X₃ ⟶ Y₂) [HasPullback f₁ f₂] [HasPullback f₃ f₄]\n\n-- include f₁ f₂ f₃ f₄ Porting note: removed\n\nlocal notation \"Z₁\" => pullback f₁ f₂\n\nlocal notation \"Z₂\" => pullback f₃ f₄\n\nlocal notation \"g₁\" => (pullback.fst : Z₁ ⟶ X₁)\n\nlocal notation \"g₂\" => (pullback.snd : Z₁ ⟶ X₂)\n\nlocal notation \"g₃\" => (pullback.fst : Z₂ ⟶ X₂)\n\nlocal notation \"g₄\" => (pullback.snd : Z₂ ⟶ X₃)\n\nlocal notation \"W\" => pullback (g₂ ≫ f₃) f₄\n\nlocal notation \"W'\" => pullback f₁ (g₃ ≫ f₂)\n\nlocal notation \"l₁\" => (pullback.fst : W ⟶ Z₁)\n\nlocal notation \"l₂\" =>\n  (pullback.lift (pullback.fst ≫ g₂) pullback.snd\n      (Eq.trans (Category.assoc _ _ _) pullback.condition) :\n    W ⟶ Z₂)\n\nlocal notation \"l₁'\" =>\n  (pullback.lift pullback.fst (pullback.snd ≫ g₃)\n      (pullback.condition.trans (Eq.symm (Category.assoc _ _ _))) :\n    W' ⟶ Z₁)\n\nlocal notation \"l₂'\" => (pullback.snd : W' ⟶ Z₂)\n\n/-- `(X₁ ×[Y₁] X₂) ×[Y₂] X₃` is the pullback `(X₁ ×[Y₁] X₂) ×[X₂] (X₂ ×[Y₂] X₃)`. -/\ndef pullbackPullbackLeftIsPullback [HasPullback (g₂ ≫ f₃) f₄] :\n    IsLimit (PullbackCone.mk l₁ l₂ (show l₁ ≫ g₂ = l₂ ≫ g₃ from (pullback.lift_fst _ _ _).symm)) :=\n  by\n  apply leftSquareIsPullback\n  exact pullbackIsPullback f₃ f₄\n  convert pullbackIsPullback (g₂ ≫ f₃) f₄\n  rw [pullback.lift_snd]\n#align category_theory.limits.pullback_pullback_left_is_pullback CategoryTheory.Limits.pullbackPullbackLeftIsPullback\n\n/-- `(X₁ ×[Y₁] X₂) ×[Y₂] X₃` is the pullback `X₁ ×[Y₁] (X₂ ×[Y₂] X₃)`. -/\ndef pullbackAssocIsPullback [HasPullback (g₂ ≫ f₃) f₄] :\n    IsLimit\n      (PullbackCone.mk (l₁ ≫ g₁) l₂\n        (show (l₁ ≫ g₁) ≫ f₁ = l₂ ≫ g₃ ≫ f₂ by\n          rw [pullback.lift_fst_assoc, Category.assoc, Category.assoc, pullback.condition])) := by\n  apply PullbackCone.flipIsLimit\n  apply bigSquareIsPullback\n  · apply PullbackCone.flipIsLimit\n    exact pullbackIsPullback f₁ f₂\n  · apply PullbackCone.flipIsLimit\n    apply pullbackPullbackLeftIsPullback\n  · exact pullback.lift_fst _ _ _\n  · exact pullback.condition.symm\n#align category_theory.limits.pullback_assoc_is_pullback CategoryTheory.Limits.pullbackAssocIsPullback\n\ntheorem hasPullback_assoc [HasPullback (g₂ ≫ f₃) f₄] : HasPullback f₁ (g₃ ≫ f₂) :=\n  ⟨⟨⟨_, pullbackAssocIsPullback f₁ f₂ f₃ f₄⟩⟩⟩\n#align category_theory.limits.has_pullback_assoc CategoryTheory.Limits.hasPullback_assoc\n\n/-- `X₁ ×[Y₁] (X₂ ×[Y₂] X₃)` is the pullback `(X₁ ×[Y₁] X₂) ×[X₂] (X₂ ×[Y₂] X₃)`. -/\ndef pullbackPullbackRightIsPullback [HasPullback f₁ (g₃ ≫ f₂)] :\n    IsLimit (PullbackCone.mk l₁' l₂' (show l₁' ≫ g₂ = l₂' ≫ g₃ from pullback.lift_snd _ _ _)) := by\n  apply PullbackCone.flipIsLimit\n  apply leftSquareIsPullback\n  · apply PullbackCone.flipIsLimit\n    exact pullbackIsPullback f₁ f₂\n  · apply PullbackCone.flipIsLimit\n    convert pullbackIsPullback f₁ (g₃ ≫ f₂)\n    rw [pullback.lift_fst]\n  · exact pullback.condition.symm\n#align category_theory.limits.pullback_pullback_right_is_pullback CategoryTheory.Limits.pullbackPullbackRightIsPullback\n\n/-- `X₁ ×[Y₁] (X₂ ×[Y₂] X₃)` is the pullback `(X₁ ×[Y₁] X₂) ×[Y₂] X₃`. -/\ndef pullbackAssocSymmIsPullback [HasPullback f₁ (g₃ ≫ f₂)] :\n    IsLimit\n      (PullbackCone.mk l₁' (l₂' ≫ g₄)\n        (show l₁' ≫ g₂ ≫ f₃ = (l₂' ≫ g₄) ≫ f₄ by\n          rw [pullback.lift_snd_assoc, Category.assoc, Category.assoc, pullback.condition])) := by\n  apply bigSquareIsPullback\n  exact pullbackIsPullback f₃ f₄\n  apply pullbackPullbackRightIsPullback\n#align category_theory.limits.pullback_assoc_symm_is_pullback CategoryTheory.Limits.pullbackAssocSymmIsPullback\n\ntheorem hasPullback_assoc_symm [HasPullback f₁ (g₃ ≫ f₂)] : HasPullback (g₂ ≫ f₃) f₄ :=\n  ⟨⟨⟨_, pullbackAssocSymmIsPullback f₁ f₂ f₃ f₄⟩⟩⟩\n#align category_theory.limits.has_pullback_assoc_symm CategoryTheory.Limits.hasPullback_assoc_symm\n\n/- Porting note : these don't seem to be propogating change from\n-- variable [HasPullback (g₂ ≫ f₃) f₄] [HasPullback f₁ (g₃ ≫ f₂)] -/\nvariable [HasPullback (g₂ ≫ f₃) f₄] [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)]\n\n/-- The canonical isomorphism `(X₁ ×[Y₁] X₂) ×[Y₂] X₃ ≅ X₁ ×[Y₁] (X₂ ×[Y₂] X₃)`. -/\nnoncomputable def pullbackAssoc [HasPullback ((pullback.snd : Z₁ ⟶ X₂) ≫ f₃) f₄]\n    [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)] :\n    pullback (pullback.snd ≫ f₃ : pullback f₁ f₂ ⟶ _) f₄ ≅\n      pullback f₁ (pullback.fst ≫ f₂ : pullback f₃ f₄ ⟶ _) :=\n  (pullbackPullbackLeftIsPullback f₁ f₂ f₃ f₄).conePointUniqueUpToIso\n    (pullbackPullbackRightIsPullback f₁ f₂ f₃ f₄)\n#align category_theory.limits.pullback_assoc CategoryTheory.Limits.pullbackAssoc\n\n@[reassoc (attr := simp)]\ntheorem pullbackAssoc_inv_fst_fst [HasPullback ((pullback.snd : Z₁ ⟶ X₂) ≫ f₃) f₄]\n    [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)]:\n    (pullbackAssoc f₁ f₂ f₃ f₄).inv ≫ pullback.fst ≫ pullback.fst = pullback.fst := by\n  trans l₁' ≫ pullback.fst\n  rw [← Category.assoc]\n  congr 1\n  exact IsLimit.conePointUniqueUpToIso_inv_comp _ _ WalkingCospan.left\n  exact pullback.lift_fst _ _ _\n#align category_theory.limits.pullback_assoc_inv_fst_fst CategoryTheory.Limits.pullbackAssoc_inv_fst_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackAssoc_hom_fst [HasPullback ((pullback.snd : Z₁ ⟶ X₂) ≫ f₃) f₄]\n    [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)] :\n    (pullbackAssoc f₁ f₂ f₃ f₄).hom ≫ pullback.fst = pullback.fst ≫ pullback.fst := by\n  rw [← Iso.eq_inv_comp, pullbackAssoc_inv_fst_fst]\n#align category_theory.limits.pullback_assoc_hom_fst CategoryTheory.Limits.pullbackAssoc_hom_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackAssoc_hom_snd_fst [HasPullback ((pullback.snd : Z₁ ⟶ X₂) ≫ f₃) f₄]\n    [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)] :\n    (pullbackAssoc f₁ f₂ f₃ f₄).hom ≫ pullback.snd ≫ pullback.fst = pullback.fst ≫ pullback.snd :=\n  by\n  trans l₂ ≫ pullback.fst\n  rw [← Category.assoc]\n  congr 1\n  exact IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.right\n  exact pullback.lift_fst _ _ _\n#align category_theory.limits.pullback_assoc_hom_snd_fst CategoryTheory.Limits.pullbackAssoc_hom_snd_fst\n\n@[reassoc (attr := simp)]\ntheorem pullbackAssoc_hom_snd_snd [HasPullback ((pullback.snd : Z₁ ⟶ X₂) ≫ f₃) f₄]\n    [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)] :\n    (pullbackAssoc f₁ f₂ f₃ f₄).hom ≫ pullback.snd ≫ pullback.snd = pullback.snd := by\n  trans l₂ ≫ pullback.snd\n  rw [← Category.assoc]\n  congr 1\n  exact IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.right\n  exact pullback.lift_snd _ _ _\n#align category_theory.limits.pullback_assoc_hom_snd_snd CategoryTheory.Limits.pullbackAssoc_hom_snd_snd\n\n@[reassoc (attr := simp)]\ntheorem pullbackAssoc_inv_fst_snd [HasPullback ((pullback.snd : Z₁ ⟶ X₂) ≫ f₃) f₄]\n    [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)] :\n    (pullbackAssoc f₁ f₂ f₃ f₄).inv ≫ pullback.fst ≫ pullback.snd = pullback.snd ≫ pullback.fst :=\n  by rw [Iso.inv_comp_eq, pullbackAssoc_hom_snd_fst]\n#align category_theory.limits.pullback_assoc_inv_fst_snd CategoryTheory.Limits.pullbackAssoc_inv_fst_snd\n\n@[reassoc (attr := simp)]\ntheorem pullbackAssoc_inv_snd [HasPullback ((pullback.snd : Z₁ ⟶ X₂) ≫ f₃) f₄]\n    [HasPullback f₁ ((pullback.fst : Z₂ ⟶  X₂) ≫ f₂)] :\n    (pullbackAssoc f₁ f₂ f₃ f₄).inv ≫ pullback.snd = pullback.snd ≫ pullback.snd := by\n  rw [Iso.inv_comp_eq, pullbackAssoc_hom_snd_snd]\n#align category_theory.limits.pullback_assoc_inv_snd CategoryTheory.Limits.pullbackAssoc_inv_snd\n\nend PullbackAssoc\n\nsection PushoutAssoc\n\n/-\nThe objects and morphisms are as follows:\n\n           Z₂ - g₄ -> X₃\n           |          |\n           g₃         f₄\n           ∨          ∨\nZ₁ - g₂ -> X₂ - f₃ -> Y₂\n|          |\ng₁         f₂\n∨          ∨\nX₁ - f₁ -> Y₁\n\nwhere the two squares are pushouts.\n\nWe can then construct the pushout squares\n\nZ₁ - g₂ -> X₂ - f₃ -> Y₂\n|                     |\ng₁                    l₂\n∨                     ∨\nX₁ - f₁ -> Y₁ - l₁ -> W\n\nand\n\nZ₂ - g₄  -> X₃\n|           |\ng₃          f₄\n∨           ∨\nX₂          Y₂\n|           |\nf₂          l₂'\n∨           ∨\nY₁ - l₁' -> W'\n\nWe will show that both `W` and `W'` are pushouts over `f₂, f₃`, and thus we may construct a\ncanonical isomorphism between them. -/\nvariable {X₁ X₂ X₃ Z₁ Z₂ : C} (g₁ : Z₁ ⟶ X₁) (g₂ : Z₁ ⟶ X₂) (g₃ : Z₂ ⟶ X₂)\n\nvariable (g₄ : Z₂ ⟶ X₃) [HasPushout g₁ g₂] [HasPushout g₃ g₄]\n\n-- include g₁ g₂ g₃ g₄ Porting note: removed\n\nlocal notation \"Y₁\" => pushout g₁ g₂\n\nlocal notation \"Y₂\" => pushout g₃ g₄\n\nlocal notation \"f₁\" => (pushout.inl : X₁ ⟶ Y₁)\n\nlocal notation \"f₂\" => (pushout.inr : X₂ ⟶ Y₁)\n\nlocal notation \"f₃\" => (pushout.inl : X₂ ⟶ Y₂)\n\nlocal notation \"f₄\" => (pushout.inr : X₃ ⟶ Y₂)\n\nlocal notation \"W\" => pushout g₁ (g₂ ≫ f₃)\n\nlocal notation \"W'\" => pushout (g₃ ≫ f₂) g₄\n\nlocal notation \"l₁\" =>\n  (pushout.desc pushout.inl (f₃ ≫ pushout.inr) (pushout.condition.trans (Category.assoc _ _ _)) :\n    Y₁ ⟶ W)\n\nlocal notation \"l₂\" => (pushout.inr : Y₂ ⟶ W)\n\nlocal notation \"l₁'\" => (pushout.inl : Y₁ ⟶ W')\n\nlocal notation \"l₂'\" =>\n  (pushout.desc (f₂ ≫ pushout.inl) pushout.inr\n      (Eq.trans (Eq.symm (Category.assoc _ _ _)) pushout.condition) :\n    Y₂ ⟶ W')\n\n/-- `(X₁ ⨿[Z₁] X₂) ⨿[Z₂] X₃` is the pushout `(X₁ ⨿[Z₁] X₂) ×[X₂] (X₂ ⨿[Z₂] X₃)`. -/\ndef pushoutPushoutLeftIsPushout [HasPushout (g₃ ≫ f₂) g₄] :\n    IsColimit\n      (PushoutCocone.mk l₁' l₂' (show f₂ ≫ l₁' = f₃ ≫ l₂' from (pushout.inl_desc _ _ _).symm)) := by\n  apply PushoutCocone.flipIsColimit\n  apply rightSquareIsPushout\n  · apply PushoutCocone.flipIsColimit\n    exact pushoutIsPushout _ _\n  · apply PushoutCocone.flipIsColimit\n    convert pushoutIsPushout (g₃ ≫ f₂) g₄\n    exact pushout.inr_desc _ _ _\n  · exact pushout.condition.symm\n#align category_theory.limits.pushout_pushout_left_is_pushout CategoryTheory.Limits.pushoutPushoutLeftIsPushout\n\n/-- `(X₁ ⨿[Z₁] X₂) ⨿[Z₂] X₃` is the pushout `X₁ ⨿[Z₁] (X₂ ⨿[Z₂] X₃)`. -/\ndef pushoutAssocIsPushout [HasPushout (g₃ ≫ f₂) g₄] :\n    IsColimit\n      (PushoutCocone.mk (f₁ ≫ l₁') l₂'\n        (show g₁ ≫ f₁ ≫ l₁' = (g₂ ≫ f₃) ≫ l₂' by\n          rw [Category.assoc, pushout.inl_desc, pushout.condition_assoc])) := by\n  apply bigSquareIsPushout\n  · apply pushoutPushoutLeftIsPushout\n  · exact pushoutIsPushout _ _\n#align category_theory.limits.pushout_assoc_is_pushout CategoryTheory.Limits.pushoutAssocIsPushout\n\ntheorem hasPushout_assoc [HasPushout (g₃ ≫ f₂) g₄] : HasPushout g₁ (g₂ ≫ f₃) :=\n  ⟨⟨⟨_, pushoutAssocIsPushout g₁ g₂ g₃ g₄⟩⟩⟩\n#align category_theory.limits.has_pushout_assoc CategoryTheory.Limits.hasPushout_assoc\n\n/-- `X₁ ⨿[Z₁] (X₂ ⨿[Z₂] X₃)` is the pushout `(X₁ ⨿[Z₁] X₂) ×[X₂] (X₂ ⨿[Z₂] X₃)`. -/\ndef pushoutPushoutRightIsPushout [HasPushout g₁ (g₂ ≫ f₃)] :\n    IsColimit (PushoutCocone.mk l₁ l₂ (show f₂ ≫ l₁ = f₃ ≫ l₂ from pushout.inr_desc _ _ _)) := by\n  apply rightSquareIsPushout\n  · exact pushoutIsPushout _ _\n  · convert pushoutIsPushout g₁ (g₂ ≫ f₃)\n    rw [pushout.inl_desc]\n#align category_theory.limits.pushout_pushout_right_is_pushout CategoryTheory.Limits.pushoutPushoutRightIsPushout\n\n/-- `X₁ ⨿[Z₁] (X₂ ⨿[Z₂] X₃)` is the pushout `(X₁ ⨿[Z₁] X₂) ⨿[Z₂] X₃`. -/\ndef pushoutAssocSymmIsPushout [HasPushout g₁ (g₂ ≫ f₃)] :\n    IsColimit\n      (PushoutCocone.mk l₁ (f₄ ≫ l₂)\n        (show (g₃ ≫ f₂) ≫ l₁ = g₄ ≫ f₄ ≫ l₂ by\n          rw [Category.assoc, pushout.inr_desc, pushout.condition_assoc])) := by\n  apply PushoutCocone.flipIsColimit\n  apply bigSquareIsPushout\n  · apply PushoutCocone.flipIsColimit\n    apply pushoutPushoutRightIsPushout\n  · apply PushoutCocone.flipIsColimit\n    exact pushoutIsPushout _ _\n  · exact pushout.condition.symm\n  · exact (pushout.inr_desc _ _ _).symm\n#align category_theory.limits.pushout_assoc_symm_is_pushout CategoryTheory.Limits.pushoutAssocSymmIsPushout\n\ntheorem hasPushout_assoc_symm [HasPushout g₁ (g₂ ≫ f₃)] : HasPushout (g₃ ≫ f₂) g₄ :=\n  ⟨⟨⟨_, pushoutAssocSymmIsPushout g₁ g₂ g₃ g₄⟩⟩⟩\n#align category_theory.limits.has_pushout_assoc_symm CategoryTheory.Limits.hasPushout_assoc_symm\n\n-- Porting note: these are not propogating so moved into statements\n-- variable [HasPushout (g₃ ≫ f₂) g₄] [HasPushout g₁ (g₂ ≫ f₃)]\n\n/-- The canonical isomorphism `(X₁ ⨿[Z₁] X₂) ⨿[Z₂] X₃ ≅ X₁ ⨿[Z₁] (X₂ ⨿[Z₂] X₃)`. -/\nnoncomputable def pushoutAssoc [HasPushout (g₃ ≫ (pushout.inr : X₂ ⟶  Y₁)) g₄]\n    [HasPushout g₁ (g₂ ≫ (pushout.inl : X₂ ⟶  Y₂))]:\n    pushout (g₃ ≫ pushout.inr : _ ⟶ pushout g₁ g₂) g₄ ≅\n      pushout g₁ (g₂ ≫ pushout.inl : _ ⟶ pushout g₃ g₄) :=\n  (pushoutPushoutLeftIsPushout g₁ g₂ g₃ g₄).coconePointUniqueUpToIso\n    (pushoutPushoutRightIsPushout g₁ g₂ g₃ g₄)\n#align category_theory.limits.pushout_assoc CategoryTheory.Limits.pushoutAssoc\n\n@[reassoc (attr := simp)]\ntheorem inl_inl_pushoutAssoc_hom [HasPushout (g₃ ≫ (pushout.inr : X₂ ⟶  Y₁)) g₄]\n    [HasPushout g₁ (g₂ ≫ (pushout.inl : X₂ ⟶  Y₂))] :\n    pushout.inl ≫ pushout.inl ≫ (pushoutAssoc g₁ g₂ g₃ g₄).hom = pushout.inl := by\n  trans f₁ ≫ l₁\n  · congr 1\n    exact\n      (pushoutPushoutLeftIsPushout g₁ g₂ g₃ g₄).comp_coconePointUniqueUpToIso_hom _\n        WalkingCospan.left\n  · exact pushout.inl_desc _ _ _\n#align category_theory.limits.inl_inl_pushout_assoc_hom CategoryTheory.Limits.inl_inl_pushoutAssoc_hom\n\n@[reassoc (attr := simp)]\ntheorem inr_inl_pushoutAssoc_hom [HasPushout (g₃ ≫ (pushout.inr : X₂ ⟶  Y₁)) g₄]\n    [HasPushout g₁ (g₂ ≫ (pushout.inl : X₂ ⟶  Y₂))] :\n    pushout.inr ≫ pushout.inl ≫ (pushoutAssoc g₁ g₂ g₃ g₄).hom = pushout.inl ≫ pushout.inr := by\n  trans f₂ ≫ l₁\n  · congr 1\n    exact\n      (pushoutPushoutLeftIsPushout g₁ g₂ g₃ g₄).comp_coconePointUniqueUpToIso_hom _\n        WalkingCospan.left\n  · exact pushout.inr_desc _ _ _\n#align category_theory.limits.inr_inl_pushout_assoc_hom CategoryTheory.Limits.inr_inl_pushoutAssoc_hom\n\n@[reassoc (attr := simp)]\ntheorem inr_inr_pushoutAssoc_inv [HasPushout (g₃ ≫ (pushout.inr : X₂ ⟶  Y₁)) g₄]\n    [HasPushout g₁ (g₂ ≫ (pushout.inl : X₂ ⟶  Y₂))] :\n    pushout.inr ≫ pushout.inr ≫ (pushoutAssoc g₁ g₂ g₃ g₄).inv = pushout.inr := by\n  trans f₄ ≫ l₂'\n  · congr 1\n    exact\n      (pushoutPushoutLeftIsPushout g₁ g₂ g₃ g₄).comp_coconePointUniqueUpToIso_inv\n        (pushoutPushoutRightIsPushout g₁ g₂ g₃ g₄) WalkingCospan.right\n  · exact pushout.inr_desc _ _ _\n#align category_theory.limits.inr_inr_pushout_assoc_inv CategoryTheory.Limits.inr_inr_pushoutAssoc_inv\n\n@[reassoc (attr := simp)]\ntheorem inl_pushoutAssoc_inv [HasPushout (g₃ ≫ (pushout.inr : X₂ ⟶  Y₁)) g₄]\n    [HasPushout g₁ (g₂ ≫ (pushout.inl : X₂ ⟶  Y₂))] :\n    pushout.inl ≫ (pushoutAssoc g₁ g₂ g₃ g₄).inv = pushout.inl ≫ pushout.inl := by\n  rw [Iso.comp_inv_eq, Category.assoc, inl_inl_pushoutAssoc_hom]\n#align category_theory.limits.inl_pushout_assoc_inv CategoryTheory.Limits.inl_pushoutAssoc_inv\n\n@[reassoc (attr := simp)]\ntheorem inl_inr_pushoutAssoc_inv [HasPushout (g₃ ≫ (pushout.inr : X₂ ⟶  Y₁)) g₄]\n    [HasPushout g₁ (g₂ ≫ (pushout.inl : X₂ ⟶  Y₂))] :\n    pushout.inl ≫ pushout.inr ≫ (pushoutAssoc g₁ g₂ g₃ g₄).inv = pushout.inr ≫ pushout.inl := by\n  rw [← Category.assoc, Iso.comp_inv_eq, Category.assoc, inr_inl_pushoutAssoc_hom]\n#align category_theory.limits.inl_inr_pushout_assoc_inv CategoryTheory.Limits.inl_inr_pushoutAssoc_inv\n\n@[reassoc (attr := simp)]\ntheorem inr_pushoutAssoc_hom [HasPushout (g₃ ≫ (pushout.inr : X₂ ⟶  Y₁)) g₄]\n    [HasPushout g₁ (g₂ ≫ (pushout.inl : X₂ ⟶  Y₂))] :\n    pushout.inr ≫ (pushoutAssoc g₁ g₂ g₃ g₄).hom = pushout.inr ≫ pushout.inr := by\n  rw [← Iso.eq_comp_inv, Category.assoc, inr_inr_pushoutAssoc_inv]\n#align category_theory.limits.inr_pushout_assoc_hom CategoryTheory.Limits.inr_pushoutAssoc_hom\n\nend PushoutAssoc\n\nvariable (C)\n\n/-- `HasPullbacks` represents a choice of pullback for every pair of morphisms\n\nSee <https://stacks.math.columbia.edu/tag/001W>\n-/\nabbrev HasPullbacks :=\n  HasLimitsOfShape WalkingCospan C\n#align category_theory.limits.has_pullbacks CategoryTheory.Limits.HasPullbacks\n\n/-- `HasPushouts` represents a choice of pushout for every pair of morphisms -/\nabbrev HasPushouts :=\n  HasColimitsOfShape WalkingSpan C\n#align category_theory.limits.has_pushouts CategoryTheory.Limits.HasPushouts\n\n/-- If `C` has all limits of diagrams `cospan f g`, then it has all pullbacks -/\ntheorem hasPullbacks_of_hasLimit_cospan\n    [∀ {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z}, HasLimit (cospan f g)] : HasPullbacks C :=\n  { has_limit := fun F => hasLimitOfIso (diagramIsoCospan F).symm }\n#align category_theory.limits.has_pullbacks_of_has_limit_cospan CategoryTheory.Limits.hasPullbacks_of_hasLimit_cospan\n\n/-- If `C` has all colimits of diagrams `span f g`, then it has all pushouts -/\ntheorem hasPushouts_of_hasColimit_span\n    [∀ {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z}, HasColimit (span f g)] : HasPushouts C :=\n  { has_colimit := fun F => hasColimitOfIso (diagramIsoSpan F) }\n#align category_theory.limits.has_pushouts_of_has_colimit_span CategoryTheory.Limits.hasPushouts_of_hasColimit_span\n\n/-- The duality equivalence `WalkingSpanᵒᵖ ≌ WalkingCospan` -/\n@[simps!]\ndef walkingSpanOpEquiv : WalkingSpanᵒᵖ ≌ WalkingCospan :=\n  widePushoutShapeOpEquiv _\n#align category_theory.limits.walking_span_op_equiv CategoryTheory.Limits.walkingSpanOpEquiv\n\n/-- The duality equivalence `WalkingCospanᵒᵖ ≌ WalkingSpan` -/\n@[simps!]\ndef walkingCospanOpEquiv : WalkingCospanᵒᵖ ≌ WalkingSpan :=\n  widePullbackShapeOpEquiv _\n#align category_theory.limits.walking_cospan_op_equiv CategoryTheory.Limits.walkingCospanOpEquiv\n\n-- see Note [lower instance priority]\n/-- Having wide pullback at any universe level implies having binary pullbacks. -/\ninstance (priority := 100) hasPullbacks_of_hasWidePullbacks (D : Type u) [h : Category.{v} D]\n    [h' : HasWidePullbacks.{w} D] : HasPullbacks.{v,u} D := by\n  haveI I := @hasWidePullbacks_shrink.{0, w} D h h'\n  infer_instance\n#align category_theory.limits.has_pullbacks_of_has_wide_pullbacks CategoryTheory.Limits.hasPullbacks_of_hasWidePullbacks\n\nvariable {C}\n\n-- Porting note: removed semireducible from the simps config\n/-- Given a morphism `f : X ⟶ Y`, we can take morphisms over `Y` to morphisms over `X` via\npullbacks. This is right adjoint to `over.map` (TODO) -/\n@[simps! (config := { simpRhs := true}) obj_left obj_hom map_left]\ndef baseChange [HasPullbacks C] {X Y : C} (f : X ⟶ Y) : Over Y ⥤ Over X where\n  obj g := Over.mk (pullback.snd : pullback g.hom f ⟶ _)\n  map i := Over.homMk (pullback.map _ _ _ _ i.left (𝟙 _) (𝟙 _) (by simp) (by simp)) (by simp)\n  map_id Z := by\n    apply Over.OverMorphism.ext; apply pullback.hom_ext\n    · dsimp; simp\n    · dsimp; simp\n  map_comp f g := by\n    apply Over.OverMorphism.ext; apply pullback.hom_ext\n    · dsimp; simp\n    · dsimp; simp\n#align category_theory.limits.base_change CategoryTheory.Limits.baseChange\n\nend CategoryTheory.Limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/CategoryTheory/Limits/Shapes/Pullbacks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.4582311361988503}}
{"text": "import ring_theory.tensor_product\n\nvariables {R : Type*} [comm_ring R]\nvariables {A B : Type*} [comm_ring A] [comm_ring B] [algebra R A] [algebra R B]\n\nexample : semiring (tensor_product R A B) :=\nbegin\napply_instance, \nend\n\nexample : algebra R (tensor_product R A B) :=\nbegin\napply_instance,\nend\n\nvariables {ι : Type*} [add_monoid ι] \n\nexample : add_monoid (unit) := infer_instance\n\nexample : add_monoid (with_top unit) := infer_instance\n\nexample : with_top unit := unit.star\n\nexample : with_top unit := 0\n\nexample : (0 : with_top unit) = unit.star := rfl\n\nexample : with_top unit := ⊤\n\nexample : (unit.star  : with_top unit) ≠ (⊤ : with_top unit) := with_top.coe_ne_top\n\n#check unit.star\n\n#eval unit.star\n\n", "meta": {"author": "AntoineChambert-Loir", "repo": "divided_powers", "sha": "86b6f8716590d38e63ed11d34c0140de8ae2af7d", "save_path": "github-repos/lean/AntoineChambert-Loir-divided_powers", "path": "github-repos/lean/AntoineChambert-Loir-divided_powers/divided_powers-86b6f8716590d38e63ed11d34c0140de8ae2af7d/src/tp_algebra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8688267898240861, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.458146722229067}}
{"text": "import ring_theory.principal_ideal_domain ring_theory.ideal.basic\nimport order.zorn data.real.basic\n\nvariables {V M : Type*} [integral_domain V] [is_principal_ideal_ring V] \n   [add_comm_group M] -- I added field here, it *may* break things\n   [module V M]\n\nopen module\nopen ideal zorn\n\nvariables (Iₙ : ℕ → (set (ideal V))) (hIₙ : ∀ i j, i < j → Iₙ i ⊆ Iₙ j) (n : ℕ)\n\n/-- An ideal is maximal if it is maximal in the collection of proper ideals. -/\nclass is_maximal_set (S : set (ideal V)) : Prop := (out : is_coatom S)\n\n\nlemma first_sub_all (I : set (ideal V)) (Iₙ : ℕ → (set I))\n  {hIₙ : ∀ i j, i < j → Iₙ i ⊆ Iₙ j} (n : ℕ) : Iₙ 0 ⊆ Iₙ n :=\nbegin\n  induction n with m h₂,\n  { refl},\n  { -- have H : Iₙ n = Iₙ (n + 1),\n    have H := hIₙ m (m + 1) (show m < m + 1, by linarith),\n    tauto\n  },\nend\n\nlemma second (I : set (ideal V)) {Iₙ : ℕ → (set I)} \n  {hIₙ : ∀ i j, i < j → Iₙ i ⊆ Iₙ j} (n : ℕ) (a : I) : a ∈ Iₙ 0 → a ∈ Iₙ n := \nbegin\n  have H := first_sub_all I Iₙ n,\n  rw set.subset_def at H,\n  exact H a,\n  exact hIₙ,\nend\n\n/-\nbegin\n  induction n with m hm, \n  { intro x, exact x},\n  { intro a_in_I_zero,\n    specialize hm a_in_I_zero,\n    have H := hIₙ m (m + 1) (show m < m + 1, by linarith),\n    rw set.subset_def at H, \n    exact H a hm, \n  },\nend\n-/\n\nlemma third (Iₙ : ℕ → (set (ideal V)))\n  (hIₙ : ∀ i j, i < j → Iₙ i ⊆ Iₙ j) (a : ideal V) : a ∈ Iₙ 0 → a ∈ ⋃ n, Iₙ n :=\nbegin\n  intros ha,\n  rw set.mem_Union,\n  use 0,\n  exact ha,\nend \n\n#check ⋃ n, Iₙ n\nvariables (J : set (⋃ n, Iₙ n)) (x : ideal V) (hx : x ∈ Iₙ 0) \n#check zorn.chain (≤) (Iₙ 0)\n#check nonempty J\n#check J.nonempty\n\n#check third Iₙ hIₙ x hx\nopen set\n\nlemma big_union_nonempty {Iₙ : ℕ → set(ideal V)} (hIₙ : ∀ i j, i < j → Iₙ i ⊆ Iₙ j) : \n  (Iₙ 0).nonempty → (⋃ n, Iₙ n).nonempty :=\nbegin\n  intros hIₙ, \n  rw set.nonempty_def at hIₙ,\n  cases hIₙ with x hx,\n  rw set.nonempty_def,\n  use x,\n  exact third Iₙ hIₙ x hx,\nend\n\nexample (I : set (ideal V)) : zorn.chain (≤) I :=\nbegin\n  rw [zorn.chain, pairwise_on],\n  intros i hi j hj hij,\n  by_cases (i < j),\n  { rw le_iff_lt_or_eq,\n    left, left,\n    exact h,\n  },\n  { right,\n    rw le_iff_lt_or_eq,\n    left,\n    -- rw lt_or_eq_of_le,\n    -- rw not_lt at h, -- why are you like this.\n    sorry},\nend\n\n\n\n\n-- ∃ (m : ?m_1) (H : m ∈ ?m_2), ∀ (z : ?m_1), z ∈ ?m_2 → m ≤ z → z = m\nlemma exists_maximal_in_set (I : set (ideal V)) (H : zorn.chain (≤) I) (hI : I.nonempty)\n  {Iₙ : ℕ → set(ideal V)} {hIₙ : ∀ i j, i < j → Iₙ i ⊆ Iₙ j}\n  : ∃ s ∈ I, ∀ t ∈ I, s ≤ t → t = s:=\nbegin\n  apply zorn.zorn_partial_order₀,\n  intros X hXI XChain,\n  -- use (⨆ n, Iₙ n),\n  sorry\nend\n\n#exit \n\n\n#check set (ideal V)\nvariables (S : set(ideal V)) (T : set(set(ideal V))) (a b : S)\n#check a ≤ b\n#check S.nonempty\n#check ideal.exists_maximal V \n\nlemma test (hS : zorn.chain (≤) T) : ∃ ub, ∀ a ∈ T, a ≤ ub := sorry\n\n#check zorn.exists_maximal_of_chains_bounded test _\n\nlemma ideals_nonempty (S : set (ideal V)) : S.nonempty := -- not necessarily true\nbegin\n  rw set.nonempty_def,\n  use 0,\n  -- apply ideal.zero_mem,\n  sorry\nend", "meta": {"author": "jamesa9283", "repo": "structure-theorem", "sha": "33404351c1275a030eafb00242253341568f5aea", "save_path": "github-repos/lean/jamesa9283-structure-theorem", "path": "github-repos/lean/jamesa9283-structure-theorem/structure-theorem-33404351c1275a030eafb00242253341568f5aea/src/useless_files/test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950907764118, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4581196596320422}}
{"text": "-- Note: see tweet https://twitter.com/dwrensha/status/1475207151534710790?s=20\n-- This now contains the fix.\n\nimport tactic\nimport data.int.basic\nimport data.nat.basic\nimport data.stream.init\nimport tactic.binder_matching\n\nopen classical\n\n-- https://github.com/leanprover-community/mathlib/blob/master/test/coinductive.lean\n-- https://leanprover-community.github.io/mathlib_docs/data/stream/init.\n-- https://leanprover-community.github.io/mathlib_docs/tactics.html\n\nconstant alphabet : Type\ndef String := ℕ → alphabet\nconstant a : String\n\n-- States that substring [i, j) is decent\nconstant decent : ℕ → ℕ → String → Prop\ndef indecent (i j : ℕ) (a : String) : Prop := ¬ decent i j a\n\ndef prefix_decent (i : ℕ) (a : String) : Prop :=\n  ∀ (j : ℕ), i < j → decent i j a\n\nlemma lemma0 {a : Prop} {b : Prop} : ¬ (a → b) → a :=\nbegin\n  tautology!,\nend\n\ndef breakable (a : String)\n              (prop : ℕ → ℕ → String → Prop) : Prop\n              := ∃ (P : ℕ → Prop),\n                 ∃ (n : ℕ),\n                 (∃ (i : ℕ), (P i)) ∧\n                  ∀ (i : ℕ), (P i) → ∃ (j : ℕ), i < j ∧ prop i j a ∧ P j\n\ntheorem kolmogorov : breakable a decent ∨ breakable a indecent :=\nbegin\n  by_cases h : ∃ (n : ℕ), ∀ (i : ℕ), n < i → ¬ prefix_decent i a,\n    cases h with n h1,\n    -- Suppose we have h\n      right,\n        unfold breakable,\n        let P : ℕ → Prop, intro i, exact n < i,\n        existsi [P, n],\n          split, \n            apply exists.intro, simp [P],\n            apply nat.lt_succ_iff.mpr, trivial,\n\n            simp_intros i hj [P],\n              have : n < i, finish,\n              have h1 : ∃ (x : ℕ), ¬(i < x → decent i x a),\n                apply not_forall.mp, tautology!,\n              cases h1 with j h6,\n                have : i < j, finish,\n                existsi j,\n                  split,\n                    assumption,\n                    split, tautology, linarith,\n\n      -- Suppose not...\n      left,\n        unfold breakable,\n          -- The property Q i says we can start a new decent word at position i\n          let Q : ℕ → Prop := λ i, 0 < i ∧ prefix_decent i a,\n          existsi [Q, 0],\n            -- We can start the ball rolling at i\n            have q : ∃ (i : ℕ), ¬(0 < i → ¬prefix_decent i a),\n              from not_forall.mp (forall_not_of_not_exists h 0),\n            cases q with i m11,\n              split, finish,\n                -- And now we need to keep the ball rolling\n                intros i,\n                  intro,\n                    have k : ∃ (j : ℕ), ¬(i < j → ¬prefix_decent j a),\n                      from not_forall.mp (forall_not_of_not_exists h i),\n                    cases k with j h15,\n                      existsi j, have : i < j, finish,\n                        split,\n                          assumption,                          \n                          split,\n                            tautology,\n                            finish\nend", "meta": {"author": "dpiponi", "repo": "LeanScratch", "sha": "08e1f9f7933e79425e5fe86468c25337da9ceb9f", "save_path": "github-repos/lean/dpiponi-LeanScratch", "path": "github-repos/lean/dpiponi-LeanScratch/LeanScratch-08e1f9f7933e79425e5fe86468c25337da9ceb9f/kolmogorov.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45800541988162496}}
{"text": "/-\nCopyright (c) 2021 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\n\nimport topology.category.Profinite\nimport category_theory.sites.pretopology\nimport category_theory.sites.sheaf_of_types\nimport category_theory.sites.sheaf\nimport category_theory.limits.opposites\nimport algebra.category.Group\n\n/-!\n# Proetale site of a point on Profinite\n\nDefines the proetale site of a point on the category of Profinite sets.\n-/\nopen category_theory category_theory.limits\n\nuniverses v u\n\nvariables {C : Type u} [category.{v} C]\n\n-- This section is in the process of being generalised for mathlib, PR #7436.\nsection to_generalise\n\n/-- A terminal Profinite type, which has the important property that morphisms to `X` are the same\nthing as elements of `X`. -/\ndef point : Profinite.{u} := Profinite.of punit\n\n/-- There is a (natural) bijection between morphisms `* ⟶ X` and elements of `X`.  -/\ndef from_point {X : Profinite.{u}} :\n  (point ⟶ X) ≃ X :=\n{ to_fun := λ f, f punit.star,\n  inv_fun := λ x, ⟨λ _, x⟩,\n  left_inv := λ x, by { ext ⟨⟩, refl },\n  right_inv := λ x, rfl}\n\nlemma from_point_apply {X Y : Profinite} (f : point ⟶ X) (g : X ⟶ Y) :\n  g (from_point f) = from_point (f ≫ g) :=\nrfl\n\nnoncomputable def mk_pullback {X Y Z : Profinite.{u}} {f : X ⟶ Z} {g : Y ⟶ Z} {x : X} {y : Y}\n  (h : f x = g y) :\n  (pullback f g : Profinite) :=\nfrom_point (pullback.lift (from_point.symm x) (from_point.symm y) (by { ext ⟨⟩, exact h }))\n\nlemma mk_pullback_fst {X Y Z : Profinite} {f : X ⟶ Z} {g : Y ⟶ Z} {x : X} {y : Y}\n  {h : f x = g y} : (pullback.fst : pullback f g ⟶ _) (mk_pullback h) = x :=\nbegin\n  rw [mk_pullback, from_point_apply],\n  simp\nend\n\nlemma mk_pullback_snd {X Y Z : Profinite.{u}} {f : X ⟶ Z} {g : Y ⟶ Z} {x : X} {y : Y}\n  {h : f x = g y} : (pullback.snd : pullback f g ⟶ _) (mk_pullback h) = y :=\nbegin\n  rw [mk_pullback, from_point_apply],\n  simp\nend\n\nend to_generalise\n\n/-- The proetale pretopology on Profinites. -/\ndef proetale_pretopology : pretopology.{u} Profinite.{u} :=\n{ coverings := λ X S, ∃ (ι : Type u) [fintype ι] (Y : ι → Profinite) (f : Π (i : ι), Y i ⟶ X),\n      (∀ (x : X), ∃ i (y : Y i), f i y = x) ∧ S = presieve.of_arrows Y f,\n  has_isos := λ X Y f i,\n  begin\n    refine ⟨punit, infer_instance, λ _, Y, λ _, f, _, _⟩,\n    { introI x,\n      refine ⟨punit.star, inv f x, _⟩,\n      change (inv f ≫ f) x = x,\n      rw is_iso.inv_hom_id,\n      simp },\n    { rw presieve.of_arrows_punit },\n  end,\n  pullbacks := λ X Y f S,\n  begin\n    rintro ⟨ι, hι, Z, g, hg, rfl⟩,\n    refine ⟨ι, hι, λ i, pullback (g i) f, λ i, pullback.snd, _, _⟩,\n    { intro y,\n      rcases hg (f y) with ⟨i, z, hz⟩,\n      exact ⟨i, mk_pullback hz, mk_pullback_snd⟩ },\n    { rw presieve.of_arrows_pullback }\n  end,\n  transitive := λ X S Ti,\n  begin\n    rintro ⟨ι, hι, Z, g, hY, rfl⟩ hTi,\n    choose j hj W k hk₁ hk₂ using hTi,\n    resetI,\n    refine ⟨Σ (i : ι), j (g i) (presieve.of_arrows.mk _), infer_instance, λ i, W _ _ i.2, _, _, _⟩,\n    { intro ij,\n      exact k _ _ ij.2 ≫ g ij.1 },\n    { intro x,\n      obtain ⟨i, y, rfl⟩ := hY x,\n      obtain ⟨i', z, rfl⟩ := hk₁ (g i) (presieve.of_arrows.mk _) y,\n      refine ⟨⟨i, i'⟩, z, rfl⟩ },\n    { have : Ti = λ Y f H, presieve.of_arrows (W f H) (k f H),\n      { ext Y f H : 3,\n        apply hk₂ },\n      rw this,\n      apply presieve.of_arrows_bind },\n  end }\n\ndef proetale_topology : grothendieck_topology.{u} Profinite.{u} :=\nproetale_pretopology.to_grothendieck _\n\n-- TODO (BM): We either want to generalise this topology to coherent? categories, or (less\n-- generally) appropriate concrete categories; or (even less generally) repeat the construction for\n-- ED and CH.\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/proetale_site.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019595, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45800541988162496}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\n\nimport data.nat.multiplicity\nimport data.zmod.algebra\nimport ring_theory.witt_vector.basic\nimport ring_theory.witt_vector.is_poly\nimport field_theory.perfect_closure\n\n\n/-!\n## The Frobenius operator\n\nIf `R` has characteristic `p`, then there is a ring endomorphism `frobenius R p`\nthat raises `r : R` to the power `p`.\nBy applying `witt_vector.map` to `frobenius R p`, we obtain a ring endomorphism `𝕎 R →+* 𝕎 R`.\nIt turns out that this endomorphism can be described by polynomials over `ℤ`\nthat do not depend on `R` or the fact that it has characteristic `p`.\nIn this way, we obtain a Frobenius endomorphism `witt_vector.frobenius_fun : 𝕎 R → 𝕎 R`\nfor every commutative ring `R`.\n\nUnfortunately, the aforementioned polynomials can not be obtained using the machinery\nof `witt_structure_int` that was developed in `structure_polynomial.lean`.\nWe therefore have to define the polynomials by hand, and check that they have the required property.\n\nIn case `R` has characteristic `p`, we show in `frobenius_fun_eq_map_frobenius`\nthat `witt_vector.frobenius_fun` is equal to `witt_vector.map (frobenius R p)`.\n\n### Main definitions and results\n\n* `frobenius_poly`: the polynomials that describe the coefficients of `frobenius_fun`;\n* `frobenius_fun`: the Frobenius endomorphism on Witt vectors;\n* `frobenius_fun_is_poly`: the tautological assertion that Frobenius is a polynomial function;\n* `frobenius_fun_eq_map_frobenius`: the fact that in characteristic `p`, Frobenius is equal to\n  `witt_vector.map (frobenius R p)`.\n\nTODO: Show that `witt_vector.frobenius_fun` is a ring homomorphism,\nand bundle it into `witt_vector.frobenius`.\n\n## References\n\n* [Hazewinkel, *Witt Vectors*][Haze09]\n\n* [Commelin and Lewis, *Formalizing the Ring of Witt Vectors*][CL21]\n-/\n\nnamespace witt_vector\n\nvariables {p : ℕ} {R S : Type*} [hp : fact p.prime] [comm_ring R] [comm_ring S]\nlocal notation `𝕎` := witt_vector p -- type as `\\bbW`\n\nnoncomputable theory\nopen mv_polynomial finset\nopen_locale big_operators\n\nvariables (p)\ninclude hp\n\n/-- The rational polynomials that give the coefficients of `frobenius x`,\nin terms of the coefficients of `x`.\nThese polynomials actually have integral coefficients,\nsee `frobenius_poly` and `map_frobenius_poly`. -/\ndef frobenius_poly_rat (n : ℕ) : mv_polynomial ℕ ℚ :=\nbind₁ (witt_polynomial p ℚ ∘ λ n, n + 1) (X_in_terms_of_W p ℚ n)\n\nlemma bind₁_frobenius_poly_rat_witt_polynomial (n : ℕ) :\n  bind₁ (frobenius_poly_rat p) (witt_polynomial p ℚ n) = (witt_polynomial p ℚ (n+1)) :=\nbegin\n  delta frobenius_poly_rat,\n  rw [← bind₁_bind₁, bind₁_X_in_terms_of_W_witt_polynomial, bind₁_X_right],\nend\n\n/-- An auxiliary definition, to avoid an excessive amount of finiteness proofs\nfor `multiplicity p n`. -/\nprivate def pnat_multiplicity (n : ℕ+) : ℕ :=\n(multiplicity p n).get $ multiplicity.finite_nat_iff.mpr $ ⟨ne_of_gt hp.1.one_lt, n.2⟩\n\nlocal notation `v` := pnat_multiplicity\n\n/-- An auxiliary polynomial over the integers, that satisfies\n`p * (frobenius_poly_aux p n) + X n ^ p = frobenius_poly p n`.\nThis makes it easy to show that `frobenius_poly p n` is congruent to `X n ^ p`\nmodulo `p`. -/\nnoncomputable def frobenius_poly_aux : ℕ → mv_polynomial ℕ ℤ\n| n := X (n + 1) - ∑ i : fin n, have _ := i.is_lt,\n  ∑ j in range (p ^ (n - i)),\n    (X i ^ p) ^ (p ^ (n - i) - (j + 1)) *\n      (frobenius_poly_aux i) ^ (j + 1) *\n      C ↑((p ^ (n - i)).choose (j + 1) / (p ^ (n - i - v p ⟨j + 1, nat.succ_pos j⟩)) *\n      ↑p ^ (j - v p ⟨j + 1, nat.succ_pos j⟩) : ℕ)\n\nlemma frobenius_poly_aux_eq (n : ℕ) :\n  frobenius_poly_aux p n =\n  X (n + 1) - ∑ i in range n, ∑ j in range (p ^ (n - i)),\n    (X i ^ p) ^ (p ^ (n - i) - (j + 1)) *\n    (frobenius_poly_aux p i) ^ (j + 1) *\n    C ↑((p ^ (n - i)).choose (j + 1) / (p ^ (n - i - v p ⟨j + 1, nat.succ_pos j⟩)) *\n      ↑p ^ (j - v p ⟨j + 1, nat.succ_pos j⟩) : ℕ) :=\nby { rw [frobenius_poly_aux, ← fin.sum_univ_eq_sum_range] }\n\n/-- The polynomials that give the coefficients of `frobenius x`,\nin terms of the coefficients of `x`. -/\ndef frobenius_poly (n : ℕ) : mv_polynomial ℕ ℤ :=\nX n ^ p + C ↑p * (frobenius_poly_aux p n)\n\n/-\nOur next goal is to prove\n```\nlemma map_frobenius_poly (n : ℕ) :\n  mv_polynomial.map (int.cast_ring_hom ℚ) (frobenius_poly p n) = frobenius_poly_rat p n\n```\nThis lemma has a rather long proof, but it mostly boils down to applying induction,\nand then using the following two key facts at the right point.\n-/\n\n/-- A key divisibility fact for the proof of `witt_vector.map_frobenius_poly`. -/\nlemma map_frobenius_poly.key₁ (n j : ℕ) (hj : j < p ^ (n)) :\n  p ^ (n - v p ⟨j + 1, j.succ_pos⟩) ∣ (p ^ n).choose (j + 1) :=\nbegin\n  apply multiplicity.pow_dvd_of_le_multiplicity,\n  rw [hp.out.multiplicity_choose_prime_pow hj j.succ_ne_zero],\n  refl,\nend\n\n/-- A key numerical identity needed for the proof of `witt_vector.map_frobenius_poly`. -/\nlemma map_frobenius_poly.key₂ {n i j : ℕ} (hi : i ≤ n) (hj : j < p ^ (n - i)) :\n  j - v p ⟨j + 1, j.succ_pos⟩ + n = i + j + (n - i - v p ⟨j + 1, j.succ_pos⟩) :=\nbegin\n  generalize h : (v p ⟨j + 1, j.succ_pos⟩) = m,\n  rsuffices ⟨h₁, h₂⟩ : m ≤ n - i ∧ m ≤ j,\n  { rw [tsub_add_eq_add_tsub h₂, add_comm i j,\n      add_tsub_assoc_of_le (h₁.trans (nat.sub_le n i)), add_assoc, tsub_right_comm, add_comm i,\n      tsub_add_cancel_of_le (le_tsub_of_add_le_right ((le_tsub_iff_left hi).mp h₁))] },\n  have hle : p ^ m ≤ j + 1,\n    from h ▸ nat.le_of_dvd j.succ_pos (multiplicity.pow_multiplicity_dvd _),\n  exact ⟨(pow_le_pow_iff hp.1.one_lt).1 (hle.trans hj),\n    nat.le_of_lt_succ ((nat.lt_pow_self hp.1.one_lt m).trans_le hle)⟩\nend\n\nlemma map_frobenius_poly (n : ℕ) :\n  mv_polynomial.map (int.cast_ring_hom ℚ) (frobenius_poly p n) = frobenius_poly_rat p n :=\nbegin\n  rw [frobenius_poly, ring_hom.map_add, ring_hom.map_mul, ring_hom.map_pow, map_C, map_X,\n      eq_int_cast, int.cast_coe_nat, frobenius_poly_rat],\n  apply nat.strong_induction_on n, clear n,\n  intros n IH,\n  rw [X_in_terms_of_W_eq],\n  simp only [alg_hom.map_sum, alg_hom.map_sub, alg_hom.map_mul, alg_hom.map_pow, bind₁_C_right],\n  have h1 : (↑p ^ n) * (⅟ (↑p : ℚ) ^ n) = 1 := by rw [←mul_pow, mul_inv_of_self, one_pow],\n  rw [bind₁_X_right, function.comp_app, witt_polynomial_eq_sum_C_mul_X_pow, sum_range_succ,\n      sum_range_succ, tsub_self, add_tsub_cancel_left, pow_zero, pow_one, pow_one, sub_mul,\n      add_mul, add_mul, mul_right_comm, mul_right_comm (C (↑p ^ (n + 1))), ←C_mul, ←C_mul, pow_succ,\n      mul_assoc ↑p (↑p ^ n), h1, mul_one, C_1, one_mul, add_comm _ (X n ^ p), add_assoc, ←add_sub,\n      add_right_inj, frobenius_poly_aux_eq, ring_hom.map_sub, map_X, mul_sub, sub_eq_add_neg,\n      add_comm _ (C ↑p * X (n + 1)), ←add_sub, add_right_inj, neg_eq_iff_eq_neg, neg_sub, eq_comm],\n  simp only [ring_hom.map_sum, mul_sum, sum_mul, ←sum_sub_distrib],\n  apply sum_congr rfl,\n  intros i hi,\n  rw mem_range at hi,\n  rw [← IH i hi],\n  clear IH,\n  rw [add_comm (X i ^ p), add_pow, sum_range_succ', pow_zero, tsub_zero, nat.choose_zero_right,\n      one_mul, nat.cast_one, mul_one, mul_add, add_mul, nat.succ_sub (le_of_lt hi),\n      nat.succ_eq_add_one (n - i), pow_succ, pow_mul, add_sub_cancel, mul_sum, sum_mul],\n  apply sum_congr rfl,\n  intros j hj,\n  rw mem_range at hj,\n  rw [ring_hom.map_mul, ring_hom.map_mul, ring_hom.map_pow, ring_hom.map_pow, ring_hom.map_pow,\n      ring_hom.map_pow, ring_hom.map_pow, map_C, map_X, mul_pow],\n  rw [mul_comm (C ↑p ^ i), mul_comm _ ((X i ^ p) ^ _), mul_comm (C ↑p ^ (j + 1)), mul_comm (C ↑p)],\n  simp only [mul_assoc],\n  apply congr_arg,\n  apply congr_arg,\n  rw [←C_eq_coe_nat],\n  simp only [←ring_hom.map_pow, ←C_mul],\n  rw C_inj,\n  simp only [inv_of_eq_inv, eq_int_cast, inv_pow, int.cast_coe_nat, nat.cast_mul,\n    int.cast_mul],\n  rw [rat.coe_nat_div _ _ (map_frobenius_poly.key₁ p (n - i) j hj)],\n  simp only [nat.cast_pow, pow_add, pow_one],\n  suffices : ((p ^ (n - i)).choose (j + 1) * p ^ (j - v p ⟨j + 1, j.succ_pos⟩) * p * p ^ n : ℚ) =\n    p ^ j * p * ((p ^ (n - i)).choose (j + 1) * p ^ i) * p ^ (n - i - v p ⟨j + 1, j.succ_pos⟩),\n  { have aux : ∀ k : ℕ, (p ^ k : ℚ) ≠ 0,\n    { intro, apply pow_ne_zero, exact_mod_cast hp.1.ne_zero },\n    simpa [aux, -one_div] with field_simps using this.symm },\n  rw [mul_comm _ (p : ℚ), mul_assoc, mul_assoc, ← pow_add, map_frobenius_poly.key₂ p hi.le hj],\n  ring_exp\nend\n\nlemma frobenius_poly_zmod (n : ℕ) :\n  mv_polynomial.map (int.cast_ring_hom (zmod p)) (frobenius_poly p n) = X n ^ p :=\nbegin\n  rw [frobenius_poly, ring_hom.map_add, ring_hom.map_pow, ring_hom.map_mul, map_X, map_C],\n  simp only [int.cast_coe_nat, add_zero, eq_int_cast, zmod.nat_cast_self, zero_mul, C_0],\nend\n\n@[simp]\nlemma bind₁_frobenius_poly_witt_polynomial (n : ℕ) :\n  bind₁ (frobenius_poly p) (witt_polynomial p ℤ n) = (witt_polynomial p ℤ (n+1)) :=\nbegin\n  apply mv_polynomial.map_injective (int.cast_ring_hom ℚ) int.cast_injective,\n  simp only [map_bind₁, map_frobenius_poly, bind₁_frobenius_poly_rat_witt_polynomial,\n    map_witt_polynomial],\nend\n\n\nvariables {p}\n\n/-- `frobenius_fun` is the function underlying the ring endomorphism\n`frobenius : 𝕎 R →+* frobenius 𝕎 R`. -/\ndef frobenius_fun (x : 𝕎 R) : 𝕎 R :=\nmk p $ λ n, mv_polynomial.aeval x.coeff (frobenius_poly p n)\n\nlemma coeff_frobenius_fun (x : 𝕎 R) (n : ℕ) :\n  coeff (frobenius_fun x) n = mv_polynomial.aeval x.coeff (frobenius_poly p n) :=\nby rw [frobenius_fun, coeff_mk]\n\nvariables (p)\n\n/-- `frobenius_fun` is tautologically a polynomial function.\n\nSee also `frobenius_is_poly`. -/\n@[is_poly] lemma frobenius_fun_is_poly : is_poly p (λ R _Rcr, @frobenius_fun p R _ _Rcr) :=\n⟨⟨frobenius_poly p, by { introsI, funext n, apply coeff_frobenius_fun }⟩⟩\n\nvariable {p}\n\n@[ghost_simps] lemma ghost_component_frobenius_fun (n : ℕ) (x : 𝕎 R) :\n  ghost_component n (frobenius_fun x) = ghost_component (n + 1) x :=\nby simp only [ghost_component_apply, frobenius_fun, coeff_mk,\n    ← bind₁_frobenius_poly_witt_polynomial, aeval_bind₁]\n\n/--\nIf `R` has characteristic `p`, then there is a ring endomorphism\nthat raises `r : R` to the power `p`.\nBy applying `witt_vector.map` to this endomorphism,\nwe obtain a ring endomorphism `frobenius R p : 𝕎 R →+* 𝕎 R`.\n\nThe underlying function of this morphism is `witt_vector.frobenius_fun`.\n-/\ndef frobenius : 𝕎 R →+* 𝕎 R :=\n{ to_fun := frobenius_fun,\n  map_zero' :=\n  begin\n    refine is_poly.ext\n      ((frobenius_fun_is_poly p).comp (witt_vector.zero_is_poly))\n      ((witt_vector.zero_is_poly).comp (frobenius_fun_is_poly p)) _ _ 0,\n    ghost_simp\n  end,\n  map_one' :=\n  begin\n    refine is_poly.ext\n      ((frobenius_fun_is_poly p).comp (witt_vector.one_is_poly))\n      ((witt_vector.one_is_poly).comp (frobenius_fun_is_poly p)) _ _ 0,\n    ghost_simp\n  end,\n  map_add' := by ghost_calc _ _; ghost_simp,\n  map_mul' := by ghost_calc _ _; ghost_simp }\n\nlemma coeff_frobenius (x : 𝕎 R) (n : ℕ) :\n  coeff (frobenius x) n = mv_polynomial.aeval x.coeff (frobenius_poly p n) :=\ncoeff_frobenius_fun _ _\n\n@[ghost_simps] lemma ghost_component_frobenius (n : ℕ) (x : 𝕎 R) :\n  ghost_component n (frobenius x) = ghost_component (n + 1) x :=\nghost_component_frobenius_fun _ _\n\nvariables (p)\n\n/-- `frobenius` is tautologically a polynomial function. -/\n@[is_poly] lemma frobenius_is_poly : is_poly p (λ R _Rcr, @frobenius p R _ _Rcr) :=\nfrobenius_fun_is_poly _\n\nsection char_p\nvariables [char_p R p]\n\n@[simp]\nlemma coeff_frobenius_char_p (x : 𝕎 R) (n : ℕ) :\n  coeff (frobenius x) n = (x.coeff n) ^ p :=\nbegin\n  rw [coeff_frobenius],\n  -- outline of the calculation, proofs follow below\n  calc aeval (λ k, x.coeff k) (frobenius_poly p n)\n      = aeval (λ k, x.coeff k)\n          (mv_polynomial.map (int.cast_ring_hom (zmod p)) (frobenius_poly p n)) : _\n  ... = aeval (λ k, x.coeff k) (X n ^ p : mv_polynomial ℕ (zmod p)) : _\n  ... = (x.coeff n) ^ p : _,\n  { conv_rhs { rw [aeval_eq_eval₂_hom, eval₂_hom_map_hom] },\n    apply eval₂_hom_congr (ring_hom.ext_int _ _) rfl rfl },\n  { rw frobenius_poly_zmod },\n  { rw [alg_hom.map_pow, aeval_X] }\nend\n\nlemma frobenius_eq_map_frobenius :\n  @frobenius p R _ _ = map (_root_.frobenius R p) :=\nbegin\n  ext x n,\n  simp only [coeff_frobenius_char_p, map_coeff, frobenius_def],\nend\n\n@[simp]\nlemma frobenius_zmodp (x : 𝕎 (zmod p)) :\n  (frobenius x) = x :=\nby simp only [ext_iff, coeff_frobenius_char_p, zmod.pow_card, eq_self_iff_true, forall_const]\n\nvariables (p R)\n/-- `witt_vector.frobenius` as an equiv. -/\n@[simps {fully_applied := ff}]\ndef frobenius_equiv [perfect_ring R p] : witt_vector p R ≃+* witt_vector p R :=\n{ to_fun := witt_vector.frobenius,\n  inv_fun := map (pth_root R p),\n  left_inv := λ f, ext $ λ n, by { rw frobenius_eq_map_frobenius, exact pth_root_frobenius _ },\n  right_inv := λ f, ext $ λ n, by { rw frobenius_eq_map_frobenius, exact frobenius_pth_root _ },\n   ..(witt_vector.frobenius : witt_vector p R →+* witt_vector p R) }\n\nlemma frobenius_bijective [perfect_ring R p] :\n  function.bijective (@witt_vector.frobenius p R _ _) :=\n(frobenius_equiv p R).bijective\n\nend char_p\n\nend witt_vector\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/witt_vector/frobenius.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390164, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4580054127885801}}
{"text": "universe variables u v w\n\nnamespace list\n\nvariable {m : Type u → Type v}\n\n@[simp]\ntheorem mfoldl_nil [monad m]\n                   {s : Type u}\n                   {α : Type w}\n                   (f : s → α → m s)\n                   (x : s)\n: mfoldl f x nil = pure x :=\nby simp [mfoldl, return]\n\ntheorem mfoldl_cons [monad m]\n                    {s : Type u}\n                    {α : Type w}\n                    (f : s → α → m s)\n                    (x : s)\n                    (h : α)\n                    (r : list α)\n: mfoldl f x (h :: r) =  f x h >>= λy, mfoldl f y r :=\nby simp [mfoldl]\n\nend list\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/category/combinators.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743620390162, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45800541278858}}
{"text": "/-\nCopyright (c) 2021 Yakov Pechersky. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yakov Pechersky\n-/\nimport data.multiset.sort\nimport data.fintype.list\nimport data.list.rotate\n\n/-!\n# Cycles of a list\n\nLists have an equivalence relation of whether they are rotational permutations of one another.\nThis relation is defined as `is_rotated`.\n\nBased on this, we define the quotient of lists by the rotation relation, called `cycle`.\n\nWe also define a representation of concrete cycles, available when viewing them in a goal state or\nvia `#eval`, when over representatble types. For example, the cycle `(2 1 4 3)` will be shown\nas `c[1, 4, 3, 2]`. The representation of the cycle sorts the elements by the string value of the\nunderlying element. This representation also supports cycles that can contain duplicates.\n\n-/\n\nnamespace list\n\nvariables {α : Type*} [decidable_eq α]\n\n/-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/\ndef next_or : Π (xs : list α) (x default : α), α\n| [] x default := default\n| [y] x default := default -- Handles the not-found and the wraparound case\n| (y :: z :: xs) x default := if x = y then z else next_or (z :: xs) x default\n\n@[simp] lemma next_or_nil (x d : α) : next_or [] x d = d := rfl\n\n@[simp] lemma next_or_singleton (x y d : α) : next_or [y] x d = d := rfl\n\n@[simp] lemma next_or_self_cons_cons (xs : list α) (x y d : α) :\n  next_or (x :: y :: xs) x d = y :=\nif_pos rfl\n\nlemma next_or_cons_of_ne (xs : list α) (y x d : α) (h : x ≠ y) :\n  next_or (y :: xs) x d = next_or xs x d :=\nbegin\n  cases xs with z zs,\n  { refl },\n  { exact if_neg h }\nend\n\n/-- `next_or` does not depend on the default value, if the next value appears. -/\nlemma next_or_eq_next_or_of_mem_of_ne (xs : list α) (x d d' : α)\n  (x_mem : x ∈ xs) (x_ne : x ≠ xs.last (ne_nil_of_mem x_mem)) :\n  next_or xs x d = next_or xs x d' :=\nbegin\n  induction xs with y ys IH,\n  { cases x_mem },\n  cases ys with z zs,\n  { simp at x_mem x_ne, contradiction },\n  by_cases h : x = y,\n  { rw [h, next_or_self_cons_cons, next_or_self_cons_cons] },\n  { rw [next_or, next_or, IH];\n      simpa [h] using x_mem }\nend\n\nlemma mem_of_next_or_ne {xs : list α} {x d : α} (h : next_or xs x d ≠ d) :\n  x ∈ xs :=\nbegin\n  induction xs with y ys IH,\n  { simpa using h },\n  cases ys with z zs,\n  { simpa using h },\n  { by_cases hx : x = y,\n    { simp [hx] },\n    { rw [next_or_cons_of_ne _ _ _ _ hx] at h,\n      simpa [hx] using IH h } }\nend\n\nlemma next_or_concat {xs : list α} {x : α} (d : α) (h : x ∉ xs) :\n  next_or (xs ++ [x]) x d = d :=\nbegin\n  induction xs with z zs IH,\n  { simp },\n  { obtain ⟨hz, hzs⟩ := not_or_distrib.mp (mt (mem_cons_iff _ _ _).mp h),\n    rw [cons_append, next_or_cons_of_ne _ _ _ _ hz, IH hzs] }\nend\n\nlemma next_or_mem {xs : list α} {x d : α} (hd : d ∈ xs) :\n  next_or xs x d ∈ xs :=\nbegin\n  revert hd,\n  suffices : ∀ (xs' : list α) (h : ∀ x ∈ xs, x ∈ xs') (hd : d ∈ xs'), next_or xs x d ∈ xs',\n  { exact this xs (λ _, id) },\n  intros xs' hxs' hd,\n  induction xs with y ys ih,\n  { exact hd },\n  cases ys with z zs,\n  { exact hd },\n  rw next_or,\n  split_ifs with h,\n  { exact hxs' _ (mem_cons_of_mem _ (mem_cons_self _ _)) },\n  { exact ih (λ _ h, hxs' _ (mem_cons_of_mem _ h)) },\nend\n\n/--\nGiven an element `x : α` of `l : list α` such that `x ∈ l`, get the next\nelement of `l`. This works from head to tail, (including a check for last element)\nso it will match on first hit, ignoring later duplicates.\n\nFor example:\n * `next [1, 2, 3] 2 _ = 3`\n * `next [1, 2, 3] 3 _ = 1`\n * `next [1, 2, 3, 2, 4] 2 _ = 3`\n * `next [1, 2, 3, 2] 2 _ = 3`\n * `next [1, 1, 2, 3, 2] 1 _ = 1`\n-/\ndef next (l : list α) (x : α) (h : x ∈ l) : α :=\nnext_or l x (l.nth_le 0 (length_pos_of_mem h))\n\n/--\nGiven an element `x : α` of `l : list α` such that `x ∈ l`, get the previous\nelement of `l`. This works from head to tail, (including a check for last element)\nso it will match on first hit, ignoring later duplicates.\n\n * `prev [1, 2, 3] 2 _ = 1`\n * `prev [1, 2, 3] 1 _ = 3`\n * `prev [1, 2, 3, 2, 4] 2 _ = 1`\n * `prev [1, 2, 3, 4, 2] 2 _ = 1`\n * `prev [1, 1, 2] 1 _ = 2`\n-/\ndef prev : Π (l : list α) (x : α) (h : x ∈ l), α\n| []             _ h := by simpa using h\n| [y]            _ _ := y\n| (y :: z :: xs) x h := if hx : x = y then (last (z :: xs) (cons_ne_nil _ _)) else\n  if x = z then y else prev (z :: xs) x (by simpa [hx] using h)\n\nvariables (l : list α) (x : α) (h : x ∈ l)\n\n@[simp] lemma next_singleton (x y : α) (h : x ∈ [y]) :\n  next [y] x h = y := rfl\n\n@[simp] lemma prev_singleton (x y : α) (h : x ∈ [y]) :\n  prev [y] x h = y := rfl\n\nlemma next_cons_cons_eq' (y z : α) (h : x ∈ (y :: z :: l)) (hx : x = y) :\n  next (y :: z :: l) x h = z :=\nby rw [next, next_or, if_pos hx]\n\n@[simp] lemma next_cons_cons_eq (z : α) (h : x ∈ (x :: z :: l)) :\n  next (x :: z :: l) x h = z :=\nnext_cons_cons_eq' l x x z h rfl\n\nlemma next_ne_head_ne_last (y : α) (h : x ∈ (y :: l)) (hy : x ≠ y)\n  (hx : x ≠ last (y :: l) (cons_ne_nil _ _)) :\n  next (y :: l) x h = next l x (by simpa [hy] using h) :=\nbegin\n  rw [next, next, next_or_cons_of_ne _ _ _ _ hy, next_or_eq_next_or_of_mem_of_ne],\n  { rwa last_cons at hx },\n  { simpa [hy] using h }\nend\n\nlemma next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l)\n  (h : x ∈ y :: l ++ [x] := mem_append_right _ (mem_singleton_self x)) :\n  next (y :: l ++ [x]) x h = y :=\nbegin\n  rw [next, next_or_concat],\n  { refl },\n  { simp [hy, hx] }\nend\n\nlemma next_last_cons (y : α) (h : x ∈ (y :: l)) (hy : x ≠ y)\n  (hx : x = last (y :: l) (cons_ne_nil _ _)) (hl : nodup l) :\n  next (y :: l) x h = y :=\nbegin\n  rw [next, nth_le, ←init_append_last (cons_ne_nil y l), hx, next_or_concat],\n  subst hx,\n  intro H,\n  obtain ⟨_ | k, hk, hk'⟩ := nth_le_of_mem H,\n  { simpa [init_eq_take, nth_le_take', hy.symm] using hk' },\n  suffices : k.succ = l.length,\n  { simpa [this] using hk },\n  cases l with hd tl,\n  { simpa using hk },\n  { rw nodup_iff_nth_le_inj at hl,\n    rw [length, nat.succ_inj'],\n    apply hl,\n    simpa [init_eq_take, nth_le_take', last_eq_nth_le] using hk' }\nend\n\nlemma prev_last_cons' (y : α) (h : x ∈ (y :: l)) (hx : x = y) :\n  prev (y :: l) x h = last (y :: l) (cons_ne_nil _ _) :=\nbegin\n  cases l;\n  simp [prev, hx]\nend\n\n@[simp] lemma prev_last_cons (h : x ∈ (x :: l)) :\n  prev (x :: l) x h = last (x :: l) (cons_ne_nil _ _) :=\nprev_last_cons' l x x h rfl\n\nlemma prev_cons_cons_eq' (y z : α) (h : x ∈ (y :: z :: l)) (hx : x = y) :\n  prev (y :: z :: l) x h = last (z :: l) (cons_ne_nil _ _) :=\nby rw [prev, dif_pos hx]\n\n@[simp] lemma prev_cons_cons_eq (z : α) (h : x ∈ (x :: z :: l)) :\n  prev (x :: z :: l) x h = last (z :: l) (cons_ne_nil _ _) :=\nprev_cons_cons_eq' l x x z h rfl\n\nlemma prev_cons_cons_of_ne' (y z : α) (h : x ∈ (y :: z :: l)) (hy : x ≠ y) (hz : x = z) :\n  prev (y :: z :: l) x h = y :=\nbegin\n  cases l,\n  { simp [prev, hy, hz] },\n  { rw [prev, dif_neg hy, if_pos hz] }\nend\n\nlemma prev_cons_cons_of_ne (y : α) (h : x ∈ (y :: x :: l)) (hy : x ≠ y) :\n  prev (y :: x :: l) x h = y :=\nprev_cons_cons_of_ne' _ _ _ _ _ hy rfl\n\nlemma prev_ne_cons_cons (y z : α) (h : x ∈ (y :: z :: l)) (hy : x ≠ y) (hz : x ≠ z) :\n  prev (y :: z :: l) x h = prev (z :: l) x (by simpa [hy] using h) :=\nbegin\n  cases l,\n  { simpa [hy, hz] using h },\n  { rw [prev, dif_neg hy, if_neg hz] }\nend\n\ninclude h\n\nlemma next_mem : l.next x h ∈ l :=\nnext_or_mem (nth_le_mem _ _ _)\n\nlemma prev_mem : l.prev x h ∈ l :=\nbegin\n  cases l with hd tl,\n  { simpa using h },\n  induction tl with hd' tl hl generalizing hd,\n  { simp },\n  { by_cases hx : x = hd,\n    { simp only [hx, prev_cons_cons_eq],\n      exact mem_cons_of_mem _ (last_mem _) },\n    { rw [prev, dif_neg hx],\n      split_ifs with hm,\n      { exact mem_cons_self _ _ },\n      { exact mem_cons_of_mem _ (hl _ _) } } }\nend\n\nlemma next_nth_le (l : list α) (h : nodup l) (n : ℕ) (hn : n < l.length) :\n  next l (l.nth_le n hn) (nth_le_mem _ _ _) = l.nth_le ((n + 1) % l.length)\n    (nat.mod_lt _ (n.zero_le.trans_lt hn)) :=\nbegin\n  cases l with x l,\n  { simpa using hn },\n  induction l with y l hl generalizing x n,\n  { simp },\n  { cases n,\n    { simp },\n    { have hn' : n.succ ≤ l.length.succ,\n      { refine nat.succ_le_of_lt _,\n        simpa [nat.succ_lt_succ_iff] using hn },\n      have hx': (x :: y :: l).nth_le n.succ hn ≠ x,\n      { intro H,\n        suffices : n.succ = 0,\n        { simpa },\n        rw nodup_iff_nth_le_inj at h,\n        refine h _ _ hn nat.succ_pos' _,\n        simpa using H },\n      rcases hn'.eq_or_lt with hn''|hn'',\n      { rw [next_last_cons],\n        { simp [hn''] },\n        { exact hx' },\n        { simp [last_eq_nth_le, hn''] },\n        { exact nodup_of_nodup_cons h } },\n      { have : n < l.length := by simpa [nat.succ_lt_succ_iff] using hn'' ,\n        rw [next_ne_head_ne_last _ _ _ _ hx'],\n        { simp [nat.mod_eq_of_lt (nat.succ_lt_succ (nat.succ_lt_succ this)),\n                hl _ _ (nodup_of_nodup_cons h), nat.mod_eq_of_lt (nat.succ_lt_succ this)] },\n        { rw last_eq_nth_le,\n          intro H,\n          suffices : n.succ = l.length.succ,\n          { exact absurd hn'' this.ge.not_lt },\n          rw nodup_iff_nth_le_inj at h,\n          refine h _ _ hn _ _,\n          { simp },\n          { simpa using H } } } } }\nend\n\nlemma prev_nth_le (l : list α) (h : nodup l) (n : ℕ) (hn : n < l.length) :\n  prev l (l.nth_le n hn) (nth_le_mem _ _ _) = l.nth_le ((n + (l.length - 1)) % l.length)\n    (nat.mod_lt _ (n.zero_le.trans_lt hn)) :=\nbegin\n  cases l with x l,\n  { simpa using hn },\n  induction l with y l hl generalizing n x,\n  { simp },\n  { rcases n with _|_|n,\n    { simpa [last_eq_nth_le, nat.mod_eq_of_lt (nat.succ_lt_succ l.length.lt_succ_self)] },\n    { simp only [mem_cons_iff, nodup_cons] at h,\n      push_neg at h,\n      simp [add_comm, prev_cons_cons_of_ne, h.left.left.symm] },\n    { rw [prev_ne_cons_cons],\n      { convert hl _ _ (nodup_of_nodup_cons h) _ using 1,\n        have : ∀ k hk, (y :: l).nth_le k hk = (x :: y :: l).nth_le (k + 1) (nat.succ_lt_succ hk),\n        { intros,\n          simpa },\n        rw [this],\n        congr,\n        simp only [nat.add_succ_sub_one, add_zero, length],\n        simp only [length, nat.succ_lt_succ_iff] at hn,\n        set k := l.length,\n        rw [nat.succ_add, ←nat.add_succ, nat.add_mod_right, nat.succ_add, ←nat.add_succ _ k,\n            nat.add_mod_right, nat.mod_eq_of_lt, nat.mod_eq_of_lt],\n        { exact nat.lt_succ_of_lt hn },\n        { exact nat.succ_lt_succ (nat.lt_succ_of_lt hn) } },\n      { intro H,\n        suffices : n.succ.succ = 0,\n        { simpa },\n        rw nodup_iff_nth_le_inj at h,\n        refine h _ _ hn nat.succ_pos' _,\n        simpa using H },\n      { intro H,\n        suffices : n.succ.succ = 1,\n        { simpa },\n        rw nodup_iff_nth_le_inj at h,\n        refine h _ _ hn (nat.succ_lt_succ nat.succ_pos') _,\n        simpa using H } } }\nend\n\nlemma pmap_next_eq_rotate_one (h : nodup l) :\n  l.pmap l.next (λ _ h, h) = l.rotate 1 :=\nbegin\n  apply list.ext_le,\n  { simp },\n  { intros,\n    rw [nth_le_pmap, nth_le_rotate, next_nth_le _ h] }\nend\n\nlemma pmap_prev_eq_rotate_length_sub_one (h : nodup l) :\n  l.pmap l.prev (λ _ h, h) = l.rotate (l.length - 1) :=\nbegin\n  apply list.ext_le,\n  { simp },\n  { intros n hn hn',\n    rw [nth_le_rotate, nth_le_pmap, prev_nth_le _ h] }\nend\n\nlemma prev_next (l : list α) (h : nodup l) (x : α) (hx : x ∈ l) :\n  prev l (next l x hx) (next_mem _ _ _) = x :=\nbegin\n  obtain ⟨n, hn, rfl⟩ := nth_le_of_mem hx,\n  simp only [next_nth_le, prev_nth_le, h, nat.mod_add_mod],\n  cases l with hd tl,\n  { simp },\n  { have : n < 1 + tl.length := by simpa [add_comm] using hn,\n    simp [add_left_comm, add_comm, add_assoc, nat.mod_eq_of_lt this] }\nend\n\nlemma next_prev (l : list α) (h : nodup l) (x : α) (hx : x ∈ l) :\n  next l (prev l x hx) (prev_mem _ _ _) = x :=\nbegin\n  obtain ⟨n, hn, rfl⟩ := nth_le_of_mem hx,\n  simp only [next_nth_le, prev_nth_le, h, nat.mod_add_mod],\n  cases l with hd tl,\n  { simp },\n  { have : n < 1 + tl.length := by simpa [add_comm] using hn,\n    simp [add_left_comm, add_comm, add_assoc, nat.mod_eq_of_lt this] }\nend\n\nlemma prev_reverse_eq_next (l : list α) (h : nodup l) (x : α) (hx : x ∈ l) :\n  prev l.reverse x (mem_reverse.mpr hx) = next l x hx :=\nbegin\n  obtain ⟨k, hk, rfl⟩ := nth_le_of_mem hx,\n  have lpos : 0 < l.length := k.zero_le.trans_lt hk,\n  have key : l.length - 1 - k < l.length :=\n    (nat.sub_le _ _).trans_lt (tsub_lt_self lpos nat.succ_pos'),\n  rw ←nth_le_pmap l.next (λ _ h, h) (by simpa using hk),\n  simp_rw [←nth_le_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h],\n  rw ←nth_le_pmap l.reverse.prev (λ _ h, h),\n  { simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,\n             length_reverse, nat.mod_eq_of_lt (tsub_lt_self lpos nat.succ_pos'),\n             tsub_tsub_cancel_of_le (nat.succ_le_of_lt lpos)],\n    rw ←nth_le_reverse,\n    { simp [tsub_tsub_cancel_of_le (nat.le_pred_of_lt hk)] },\n    { simpa using (nat.sub_le _ _).trans_lt (tsub_lt_self lpos nat.succ_pos') } },\n  { simpa using (nat.sub_le _ _).trans_lt (tsub_lt_self lpos nat.succ_pos') }\nend\n\nlemma next_reverse_eq_prev (l : list α) (h : nodup l) (x : α) (hx : x ∈ l) :\n  next l.reverse x (mem_reverse.mpr hx) = prev l x hx :=\nbegin\n  convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm,\n  exact (reverse_reverse l).symm\nend\n\nlemma is_rotated_next_eq {l l' : list α} (h : l ~r l') (hn : nodup l) {x : α} (hx : x ∈ l) :\n  l.next x hx = l'.next x (h.mem_iff.mp hx) :=\nbegin\n  obtain ⟨k, hk, rfl⟩ := nth_le_of_mem hx,\n  obtain ⟨n, rfl⟩ := id h,\n  rw [next_nth_le _ hn],\n  simp_rw ←nth_le_rotate' _ n k,\n  rw [next_nth_le _ (h.nodup_iff.mp hn), ←nth_le_rotate' _ n],\n  simp [add_assoc]\nend\n\nlemma is_rotated_prev_eq {l l' : list α} (h : l ~r l') (hn : nodup l) {x : α} (hx : x ∈ l) :\n  l.prev x hx = l'.prev x (h.mem_iff.mp hx) :=\nbegin\n  rw [←next_reverse_eq_prev _ hn, ←next_reverse_eq_prev _ (h.nodup_iff.mp hn)],\n  exact is_rotated_next_eq h.reverse (nodup_reverse.mpr hn) _\nend\n\nend list\n\nopen list\n\n/--\n`cycle α` is the quotient of `list α` by cyclic permutation.\nDuplicates are allowed.\n-/\ndef cycle (α : Type*) : Type* := quotient (is_rotated.setoid α)\n\nnamespace cycle\n\nvariables {α : Type*}\n\ninstance : has_coe (list α) (cycle α) := ⟨quot.mk _⟩\n\n@[simp] lemma coe_eq_coe {l₁ l₂ : list α} : (l₁ : cycle α) = l₂ ↔ (l₁ ~r l₂) :=\n@quotient.eq _ (is_rotated.setoid _) _ _\n\n@[simp] lemma mk_eq_coe (l : list α) :\n  quot.mk _ l = (l : cycle α) := rfl\n\n@[simp] lemma mk'_eq_coe (l : list α) :\n  quotient.mk' l = (l : cycle α) := rfl\n\ninstance : inhabited (cycle α) := ⟨(([] : list α) : cycle α)⟩\n\n/--\nFor `x : α`, `s : cycle α`, `x ∈ s` indicates that `x` occurs at least once in `s`.\n-/\ndef mem (a : α) (s : cycle α) : Prop :=\nquot.lift_on s (λ l, a ∈ l) (λ l₁ l₂ (e : l₁ ~r l₂), propext $ e.mem_iff)\n\ninstance : has_mem α (cycle α) := ⟨mem⟩\n\n@[simp] lemma mem_coe_iff {a : α} {l : list α} :\n  a ∈ (l : cycle α) ↔ a ∈ l := iff.rfl\n\ninstance [decidable_eq α] : decidable_eq (cycle α) :=\nλ s₁ s₂, quotient.rec_on_subsingleton₂' s₁ s₂ (λ l₁ l₂,\n  decidable_of_iff' _ quotient.eq')\n\ninstance [decidable_eq α] (x : α) (s : cycle α) : decidable (x ∈ s) :=\nquotient.rec_on_subsingleton' s (λ l, list.decidable_mem x l)\n\n/--\nReverse a `s : cycle α` by reversing the underlying `list`.\n-/\ndef reverse (s : cycle α) : cycle α :=\nquot.map reverse (λ l₁ l₂ (e : l₁ ~r l₂), e.reverse) s\n\n@[simp] lemma reverse_coe (l : list α) :\n  (l : cycle α).reverse = l.reverse := rfl\n\n@[simp] lemma mem_reverse_iff {a : α} {s : cycle α} :\n  a ∈ s.reverse ↔ a ∈ s :=\nquot.induction_on s (λ _, mem_reverse)\n\n@[simp] lemma reverse_reverse (s : cycle α) :\n  s.reverse.reverse = s :=\nquot.induction_on s (λ _, by simp)\n\n/--\nThe length of the `s : cycle α`, which is the number of elements, counting duplicates.\n-/\ndef length (s : cycle α) : ℕ :=\nquot.lift_on s length (λ l₁ l₂ (e : l₁ ~r l₂), e.perm.length_eq)\n\n@[simp] lemma length_coe (l : list α) :\n  length (l : cycle α) = l.length := rfl\n\n@[simp] lemma length_reverse (s : cycle α) :\n  s.reverse.length = s.length :=\nquot.induction_on s length_reverse\n\n/--\nA `s : cycle α` that is at most one element.\n-/\ndef subsingleton (s : cycle α) : Prop :=\ns.length ≤ 1\n\nlemma length_subsingleton_iff {s : cycle α} :\n  subsingleton s ↔ length s ≤ 1 := iff.rfl\n\n@[simp] lemma subsingleton_reverse_iff {s : cycle α} :\n  s.reverse.subsingleton ↔ s.subsingleton :=\nby simp [length_subsingleton_iff]\n\nlemma subsingleton.congr {s : cycle α} (h : subsingleton s) :\n  ∀ ⦃x⦄ (hx : x ∈ s) ⦃y⦄ (hy : y ∈ s), x = y :=\nbegin\n  induction s using quot.induction_on with l,\n  simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, nat.lt_add_one_iff,\n             length_eq_zero, length_eq_one, nat.not_lt_zero, false_or] at h,\n  rcases h with rfl|⟨z, rfl⟩;\n  simp\nend\n\n/--\nA `s : cycle α` that is made up of at least two unique elements.\n-/\ndef nontrivial (s : cycle α) : Prop := ∃ (x y : α) (h : x ≠ y), x ∈ s ∧ y ∈ s\n\n@[simp] lemma nontrivial_coe_nodup_iff {l : list α} (hl : l.nodup) :\n  nontrivial (l : cycle α) ↔ 2 ≤ l.length :=\nbegin\n  rw nontrivial,\n  rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩),\n  { simp },\n  { simp },\n  { simp only [mem_cons_iff, exists_prop, mem_coe_iff, list.length, ne.def, nat.succ_le_succ_iff,\n               zero_le, iff_true],\n    refine ⟨hd, hd', _, by simp⟩,\n    simp only [not_or_distrib, mem_cons_iff, nodup_cons] at hl,\n    exact hl.left.left }\nend\n\n@[simp] lemma nontrivial_reverse_iff {s : cycle α} :\n  s.reverse.nontrivial ↔ s.nontrivial :=\nby simp [nontrivial]\n\nlemma length_nontrivial {s : cycle α} (h : nontrivial s) :\n  2 ≤ length s :=\nbegin\n  obtain ⟨x, y, hxy, hx, hy⟩ := h,\n  induction s using quot.induction_on with l,\n  rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩),\n  { simpa using hx },\n  { simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy,\n    simpa [hx, hy] using hxy },\n  { simp [bit0] }\nend\n\n/--\nThe `s : cycle α` contains no duplicates.\n-/\ndef nodup (s : cycle α) : Prop :=\nquot.lift_on s nodup (λ l₁ l₂ (e : l₁ ~r l₂), propext $ e.nodup_iff)\n\n@[simp] lemma nodup_coe_iff {l : list α} :\n  nodup (l : cycle α) ↔ l.nodup := iff.rfl\n\n@[simp] lemma nodup_reverse_iff {s : cycle α} :\n  s.reverse.nodup ↔ s.nodup :=\nquot.induction_on s (λ _, nodup_reverse)\n\nlemma subsingleton.nodup {s : cycle α} (h : subsingleton s) :\n  nodup s :=\nbegin\n  induction s using quot.induction_on with l,\n  cases l with hd tl,\n  { simp },\n  { have : tl = [] := by simpa [subsingleton, length_eq_zero] using h,\n    simp [this] }\nend\n\nlemma nodup.nontrivial_iff {s : cycle α} (h : nodup s) :\n  nontrivial s ↔ ¬ subsingleton s :=\nbegin\n  rw length_subsingleton_iff,\n  induction s using quotient.induction_on',\n  simp only [mk'_eq_coe, nodup_coe_iff] at h,\n  simp [h, nat.succ_le_iff]\nend\n\n/--\nThe `s : cycle α` as a `multiset α`.\n-/\ndef to_multiset (s : cycle α) : multiset α :=\nquotient.lift_on' s (λ l, (l : multiset α)) (λ l₁ l₂ (h : l₁ ~r l₂), multiset.coe_eq_coe.mpr h.perm)\n\n/--\nThe lift of `list.map`.\n-/\ndef map {β : Type*} (f : α → β) : cycle α → cycle β :=\nquotient.map' (list.map f) $ λ l₁ l₂ h, h.map _\n\n/--\nThe `multiset` of lists that can make the cycle.\n-/\ndef lists (s : cycle α) : multiset (list α) :=\nquotient.lift_on' s\n  (λ l, (l.cyclic_permutations : multiset (list α))) $\n  λ l₁ l₂ (h : l₁ ~r l₂), by simpa using h.cyclic_permutations.perm\n\n@[simp] lemma mem_lists_iff_coe_eq {s : cycle α} {l : list α} :\n  l ∈ s.lists ↔ (l : cycle α) = s :=\nbegin\n  induction s using quotient.induction_on',\n  rw [lists, quotient.lift_on'_mk'],\n  simp\nend\n\nsection decidable\n\nvariable [decidable_eq α]\n\n/--\nAuxiliary decidability algorithm for lists that contain at least two unique elements.\n-/\ndef decidable_nontrivial_coe : Π (l : list α), decidable (nontrivial (l : cycle α))\n| []            := is_false (by simp [nontrivial])\n| [x]           := is_false (by simp [nontrivial])\n| (x :: y :: l) := if h : x = y\n  then @decidable_of_iff' _ (nontrivial ((x :: l) : cycle α))\n    (by simp [h, nontrivial])\n    (decidable_nontrivial_coe (x :: l))\n  else is_true ⟨x, y, h, by simp, by simp⟩\n\ninstance {s : cycle α} : decidable (nontrivial s) :=\nquot.rec_on_subsingleton s decidable_nontrivial_coe\n\ninstance {s : cycle α} : decidable (nodup s) :=\nquot.rec_on_subsingleton s (λ (l : list α), list.nodup_decidable l)\n\ninstance fintype_nodup_cycle [fintype α] : fintype {s : cycle α // s.nodup} :=\nfintype.of_surjective (λ (l : {l : list α // l.nodup}), ⟨l.val, by simpa using l.prop⟩) (λ ⟨s, hs⟩,\n  begin\n    induction s using quotient.induction_on',\n    exact ⟨⟨s, hs⟩, by simp⟩\n  end)\n\ninstance fintype_nodup_nontrivial_cycle [fintype α] :\n  fintype {s : cycle α // s.nodup ∧ s.nontrivial} :=\nfintype.subtype (((finset.univ : finset {s : cycle α // s.nodup}).map\n  (function.embedding.subtype _)).filter cycle.nontrivial)\n  (by simp)\n\n/--\nThe `s : cycle α` as a `finset α`.\n-/\ndef to_finset (s : cycle α) : finset α :=\ns.to_multiset.to_finset\n\n/-- Given a `s : cycle α` such that `nodup s`, retrieve the next element after `x ∈ s`. -/\ndef next : Π (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s), α :=\nλ s, quot.hrec_on s (λ l hn x hx, next l x hx)\n  (λ l₁ l₂ (h : l₁ ~r l₂),\n  function.hfunext (propext h.nodup_iff) (λ h₁ h₂ he, function.hfunext rfl\n    (λ x y hxy, function.hfunext (propext (by simpa [eq_of_heq hxy] using h.mem_iff))\n    (λ hm hm' he', heq_of_eq (by simpa [eq_of_heq hxy] using is_rotated_next_eq h h₁ _)))))\n\n/-- Given a `s : cycle α` such that `nodup s`, retrieve the previous element before `x ∈ s`. -/\ndef prev : Π (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s), α :=\nλ s, quot.hrec_on s (λ l hn x hx, prev l x hx)\n  (λ l₁ l₂ (h : l₁ ~r l₂),\n  function.hfunext (propext h.nodup_iff) (λ h₁ h₂ he, function.hfunext rfl\n    (λ x y hxy, function.hfunext (propext (by simpa [eq_of_heq hxy] using h.mem_iff))\n    (λ hm hm' he', heq_of_eq (by simpa [eq_of_heq hxy] using is_rotated_prev_eq h h₁ _)))))\n\n@[simp] lemma prev_reverse_eq_next (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s) :\n  s.reverse.prev (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.next hs x hx :=\n(quotient.induction_on' s prev_reverse_eq_next) hs x hx\n\n@[simp] lemma next_reverse_eq_prev (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s) :\n  s.reverse.next (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.prev hs x hx :=\nby simp [←prev_reverse_eq_next]\n\n@[simp] lemma next_mem (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s) :\n  s.next hs x hx ∈ s :=\nbegin\n  induction s using quot.induction_on,\n  exact next_mem _ _ _\nend\n\nlemma prev_mem (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s) :\n  s.prev hs x hx ∈ s :=\nby { rw [←next_reverse_eq_prev, ←mem_reverse_iff], exact next_mem _ _ _ _ }\n\n@[simp] lemma prev_next (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s) :\n  s.prev hs (s.next hs x hx) (next_mem s hs x hx) = x :=\n(quotient.induction_on' s prev_next) hs x hx\n\n@[simp] lemma next_prev (s : cycle α) (hs : nodup s) (x : α) (hx : x ∈ s) :\n  s.next hs (s.prev hs x hx) (prev_mem s hs x hx) = x :=\n(quotient.induction_on' s next_prev) hs x hx\n\nend decidable\n\n/--\nWe define a representation of concrete cycles, available when viewing them in a goal state or\nvia `#eval`, when over representatble types. For example, the cycle `(2 1 4 3)` will be shown\nas `c[1, 4, 3, 2]`. The representation of the cycle sorts the elements by the string value of the\nunderlying element. This representation also supports cycles that can contain duplicates.\n-/\ninstance [has_repr α] : has_repr (cycle α) :=\n⟨λ s, \"c[\" ++ string.intercalate \", \" ((s.map repr).lists.sort (≤)).head ++ \"]\"⟩\n\nend cycle\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/list/cycle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.7490872075132152, "lm_q1q2_score": 0.4579784150988348}}
{"text": "-- Copyright (c) 2017 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Stephen Morgan, Scott Morrison\n\nimport .obviously\n\n\n\n\n-- **** Begin caching stuff ****\n\n-- **** Enable tactic block caching (just include) ****\nimport tactic.tcache.enable\n\n-- Trace which declarations have blocks being cached\nset_option trace.tcache true\n\n-- Uncomment to clear the cache (recomment afterword)\n-- #clear tcache\n\n-- **** End of caching stuff ****\n\n\n\n\nopen category_theory\n\nnamespace category_theory.adjunctions\n\nsection\n\nuniverses u₁ v₁ u₂ v₂\n\nvariables {C : Type u₁} [𝒞 : category.{v₁ u₁} C] {D : Type u₂} [𝒟 : category.{v₂ u₂} D]\ninclude 𝒞 𝒟\n\nstructure Adjunction (L : C ⥤ D) (R : D ⥤ C) :=\n  (unit       : functor.id _ ⟹ (L ⋙ R))\n  (counit     : (R ⋙ L) ⟹ functor.id _)\n  (triangle_1 : ∀ X : D, (unit.app (R.obj X)) ≫ (R.map (counit.app X)) = 𝟙 (R.obj X))\n  (triangle_2 : ∀ X : C, (L.map (unit.app X)) ≫ (counit.app (L.obj X)) = 𝟙 (L.obj X))\n\nattribute [simp,search] Adjunction.triangle_1 Adjunction.triangle_2\n\nlemma Adjunctions_pointwise_equal\n  (L : C ⥤ D) (R : D ⥤ C) (A B : Adjunction L R)\n  (w1 : A.unit = B.unit) (w2 : A.counit = B.counit) : A = B :=\n  begin\n    induction A,\n    induction B,\n    tidy\n  end\n\n@[simp,search] lemma Adjunction.unit_naturality {L : C ⥤ D} {R : D ⥤ C} (A : Adjunction L R) {X Y : C} (f : X ⟶ Y) : (A.unit.app X) ≫ (R.map (L.map f)) = f ≫ (A.unit.app Y) :=\nby obviously\n\n@[simp,search] lemma Adjunction.counit_naturality {L : C ⥤ D} {R : D ⥤ C} (A : Adjunction L R) {X Y : D} (f : X ⟶ Y) : (L.map (R.map f)) ≫ (A.counit.app Y) = (A.counit.app X) ≫ f :=\nby obviously\n\nend\n\ninfix ` ⊣ `:50 := Adjunction\n\nsection\nuniverses u₁ v₁\n\nvariables {C : Type u₁} [𝒞 : category.{v₁ u₁} C] {D : Type u₁} [𝒟 : category.{v₁ u₁} D]\ninclude 𝒞 𝒟 \n\ndef hom_adjunction (L : C ⥤ D) (R : D ⥤ C) :=\n    ((functor.prod L.op (functor.id D)) ⋙ (functor.hom D))\n      ≅ \n    (functor.prod (functor.id (Cᵒᵖ)) R) ⋙ (functor.hom C)\n\ndef mate {L : C ⥤ D} {R : D ⥤ C} (A : hom_adjunction L R) {X : C} {Y : D} (f : (L.obj X) ⟶ Y) : \n  X ⟶ (R.obj Y) := \n((A.hom).app (op X, Y)) f\n\nend\nend category_theory.adjunctions\n\nnamespace category_theory.adjunctions\n\nuniverses u v v₁ u₁ u₂ v₂ u₃ v₃ u₄ v₄\n\nsection\nvariables {A : Type u₁} [𝒜 : category.{v₁ u₁} A] {B : Type u₂} [ℬ : category.{v₂ u₂} B] {C : Type u₃} [𝒞 : category.{v₃ u₃} C] {D : Type u₄} [𝒟 : category.{v₄ u₄} D]\ninclude 𝒜 ℬ 𝒞 𝒟\n\n@[simp,search] lemma prod_obj' (F : A ⥤ B) (G : C ⥤ D) (a : A) (c : C) : (functor.prod F G).obj (a, c) = (F.obj a, G.obj c) := rfl\n@[simp,search] lemma prod_app' {F G : A ⥤ B} {H I : C ⥤ D} (α : F ⟹ G) (β : H ⟹ I) (a : A) (c : C) : (nat_trans.prod α β).app (a, c) = (α.app a, β.app c) := rfl\nend\n\nvariables {C : Type u₁} [𝒞 : category.{v₁ u₁} C] {D : Type u₁} [𝒟 : category.{v₁ u₁} D]\ninclude 𝒞 𝒟\nvariables {L : C ⥤ D} {R : D ⥤ C}\n\n@[reducible] private def Adjunction_to_HomAdjunction_morphism (A : L ⊣ R)\n  : ((functor.prod L.op (functor.id D)) ⋙ (functor.hom D)) ⟹\n                          (functor.prod (functor.id (Cᵒᵖ)) R) ⋙ (functor.hom C) :=\n{ app := λ P,\n    -- We need to construct the map from D.Hom (L P.1) P.2 to C.Hom P.1 (R P.2)\n    λ f, (A.unit.app (unop P.1)) ≫ (R.map f) }\n\n@[reducible] private def Adjunction_to_HomAdjunction_inverse (A : L ⊣ R)\n  : (functor.prod (functor.id (Cᵒᵖ)) R) ⋙ (functor.hom C) ⟹\n                          ((functor.prod L.op (functor.id D)) ⋙ (functor.hom D)) :=\n{ app := λ P,\n    -- We need to construct the map back to D.Hom (L P.1) P.2 from C.Hom P.1 (R P.2)\n    λ f, (L.map f) ≫ (A.counit.app P.2) }\n\ndef Adjunction_to_HomAdjunction (A : L ⊣ R) : hom_adjunction L R :=\n{ hom := Adjunction_to_HomAdjunction_morphism A,\n  inv := Adjunction_to_HomAdjunction_inverse A }\n\n@[simp,search] lemma mate_of_L (A : hom_adjunction L R) {X Y : C} (f : X ⟶ Y) : (((A.hom).app (op X, L.obj X)) (𝟙 (L.obj X))) ≫\n      (R.map (L.map f))\n      = ((A.hom).app (op X, L.obj Y)) (L.map f) :=\nbegin\n  have p := @nat_trans.naturality _ _ _ _ _ _ A.hom (op X, L.obj X) (op X, L.obj Y) (𝟙 (op X), L.map f),\n  have q := congr_fun p (L.map (𝟙 X)),\n  tidy,\n  erw category_theory.functor.map_id at q,\n  obviously,\nend\n\n@[simp,search] lemma mate_of_L' (A : hom_adjunction L R) {X Y : C} (f : X ⟶ Y) : f ≫ (((A.hom).app (op Y, L.obj Y)) (𝟙 (L.obj Y)))\n      = ((A.hom).app (op X, L.obj Y)) (L.map f) :=\nbegin\n  have p := @nat_trans.naturality _ _ _ _ _ _ A.hom (op Y, L.obj Y) (op X, L.obj Y) (f.op, 𝟙 (L.obj Y)),\n  have q := congr_fun p (L.map (𝟙 Y)),\n  obviously,\nend\n\n@[simp,search] lemma mate_of_R (A : hom_adjunction L R) {X Y : D} (f : X ⟶ Y) : (L.map (R.map f)) ≫ (((A.inv).app (op (R.obj Y), Y)) (𝟙 (R.obj Y)))\n      = ((A.inv).app (op (R.obj X), Y)) (R.map f) :=\nbegin\n  have p := @nat_trans.naturality _ _ _ _ _ _ A.inv (op (R.obj Y), Y) (op (R.obj X), Y) ((R.map f).op, 𝟙 Y),\n  have q := congr_fun p (R.map (𝟙 Y)),\n  tidy,\nend\n\n@[simp,search] lemma mate_of_R' (A : hom_adjunction L R) {X Y : D} (f : X ⟶ Y) : (((A.inv).app (op (R.obj X), X)) (𝟙 (R.obj X))) ≫ f =\n    ((A.inv).app (op (R.obj X), Y)) (R.map f) :=\nbegin\n  have p := @nat_trans.naturality _ _ _ _ _ _ A.inv (op (R.obj X), X) (op (R.obj X), Y) (𝟙 (op (R.obj X)), f),\n  have q := congr_fun p (R.map (𝟙 X)),\n  obviously,\nend\n\nprivate def counit_from_HomAdjunction (A : hom_adjunction L R) : (R ⋙ L) ⟹ (functor.id _) :=\n{ app := λ X : D, (A.inv.app (op (R.obj X), X)) (𝟙 (R.obj X)) }\n\nprivate def unit_from_HomAdjunction (A : hom_adjunction L R) : (functor.id _) ⟹ (L ⋙ R) :=\n{ app := λ X : C, (A.hom.app (op X, L.obj X)) (𝟙 (L.obj X)) }\n\nend category_theory.adjunctions", "meta": {"author": "khoek", "repo": "leancache-example", "sha": "5c55bb5a792c6a711ab12e6e6d2c7118d99a936c", "save_path": "github-repos/lean/khoek-leancache-example", "path": "github-repos/lean/khoek-leancache-example/leancache-example-5c55bb5a792c6a711ab12e6e6d2c7118d99a936c/src/somemaths-comparisons.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.45793805223943546}}
{"text": "/-\nCopyright (c) 2021 Rémy Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Zhouhang Zhou, Yury Kudryashov\n-/\n\nimport measure_theory.function.l1_space\nimport analysis.normed_space.indicator_function\n\n/-! # Functions integrable on a set and at a filter\n\nWe define `integrable_on f s μ := integrable f (μ.restrict s)` and prove theorems like\n`integrable_on_union : integrable_on f (s ∪ t) μ ↔ integrable_on f s μ ∧ integrable_on f t μ`.\n\nNext we define a predicate `integrable_at_filter (f : α → E) (l : filter α) (μ : measure α)`\nsaying that `f` is integrable at some set `s ∈ l` and prove that a measurable function is integrable\nat `l` with respect to `μ` provided that `f` is bounded above at `l ⊓ μ.ae` and `μ` is finite\nat `l`.\n\n-/\n\nnoncomputable theory\nopen set filter topological_space measure_theory function\nopen_locale classical topology interval big_operators filter ennreal measure_theory\n\nvariables {α β E F : Type*} [measurable_space α]\n\nsection\n\nvariables [topological_space β] {l l' : filter α} {f g : α → β} {μ ν : measure α}\n\n/-- A function `f` is strongly measurable at a filter `l` w.r.t. a measure `μ` if it is\nae strongly measurable w.r.t. `μ.restrict s` for some `s ∈ l`. -/\ndef strongly_measurable_at_filter (f : α → β) (l : filter α) (μ : measure α . volume_tac) :=\n∃ s ∈ l, ae_strongly_measurable f (μ.restrict s)\n\n@[simp] lemma strongly_measurable_at_bot {f : α → β} : strongly_measurable_at_filter f ⊥ μ :=\n⟨∅, mem_bot, by simp⟩\n\nprotected lemma strongly_measurable_at_filter.eventually (h : strongly_measurable_at_filter f l μ) :\n  ∀ᶠ s in l.small_sets, ae_strongly_measurable f (μ.restrict s) :=\n(eventually_small_sets' $ λ s t, ae_strongly_measurable.mono_set).2 h\n\nprotected lemma strongly_measurable_at_filter.filter_mono\n  (h : strongly_measurable_at_filter f l μ) (h' : l' ≤ l) :\n  strongly_measurable_at_filter f l' μ :=\nlet ⟨s, hsl, hs⟩ := h in ⟨s, h' hsl, hs⟩\n\nprotected lemma measure_theory.ae_strongly_measurable.strongly_measurable_at_filter\n  (h : ae_strongly_measurable f μ) :\n  strongly_measurable_at_filter f l μ :=\n⟨univ, univ_mem, by rwa measure.restrict_univ⟩\n\nlemma ae_strongly_measurable.strongly_measurable_at_filter_of_mem\n  {s} (h : ae_strongly_measurable f (μ.restrict s)) (hl : s ∈ l) :\n  strongly_measurable_at_filter f l μ :=\n⟨s, hl, h⟩\n\nprotected lemma measure_theory.strongly_measurable.strongly_measurable_at_filter\n  (h : strongly_measurable f) :\n  strongly_measurable_at_filter f l μ :=\nh.ae_strongly_measurable.strongly_measurable_at_filter\n\nend\n\nnamespace measure_theory\n\nsection normed_add_comm_group\n\nlemma has_finite_integral_restrict_of_bounded [normed_add_comm_group E] {f : α → E} {s : set α}\n  {μ : measure α} {C}  (hs : μ s < ∞) (hf : ∀ᵐ x ∂(μ.restrict s), ‖f x‖ ≤ C) :\n  has_finite_integral f (μ.restrict s) :=\nby haveI : is_finite_measure (μ.restrict s) := ⟨by rwa [measure.restrict_apply_univ]⟩;\n  exact has_finite_integral_of_bounded hf\n\nvariables [normed_add_comm_group E] {f g : α → E} {s t : set α} {μ ν : measure α}\n\n/-- A function is `integrable_on` a set `s` if it is almost everywhere strongly measurable on `s`\nand if the integral of its pointwise norm over `s` is less than infinity. -/\ndef integrable_on (f : α → E) (s : set α) (μ : measure α . volume_tac) : Prop :=\nintegrable f (μ.restrict s)\n\nlemma integrable_on.integrable (h : integrable_on f s μ) :\n  integrable f (μ.restrict s) := h\n\n@[simp] lemma integrable_on_empty : integrable_on f ∅ μ :=\nby simp [integrable_on, integrable_zero_measure]\n\n@[simp] lemma integrable_on_univ : integrable_on f univ μ ↔ integrable f μ :=\nby rw [integrable_on, measure.restrict_univ]\n\nlemma integrable_on_zero : integrable_on (λ _, (0:E)) s μ := integrable_zero _ _ _\n\n@[simp] lemma integrable_on_const {C : E} : integrable_on (λ _, C) s μ ↔ C = 0 ∨ μ s < ∞ :=\nintegrable_const_iff.trans $ by rw [measure.restrict_apply_univ]\n\nlemma integrable_on.mono (h : integrable_on f t ν) (hs : s ⊆ t) (hμ : μ ≤ ν) :\n  integrable_on f s μ :=\nh.mono_measure $ measure.restrict_mono hs hμ\n\nlemma integrable_on.mono_set (h : integrable_on f t μ) (hst : s ⊆ t) :\n  integrable_on f s μ :=\nh.mono hst le_rfl\n\nlemma integrable_on.mono_measure (h : integrable_on f s ν) (hμ : μ ≤ ν) :\n  integrable_on f s μ :=\nh.mono (subset.refl _) hμ\n\nlemma integrable_on.mono_set_ae (h : integrable_on f t μ) (hst : s ≤ᵐ[μ] t) :\n  integrable_on f s μ :=\nh.integrable.mono_measure $ measure.restrict_mono_ae hst\n\nlemma integrable_on.congr_set_ae (h : integrable_on f t μ) (hst : s =ᵐ[μ] t) :\n  integrable_on f s μ :=\nh.mono_set_ae hst.le\n\nlemma integrable_on.congr_fun' (h : integrable_on f s μ) (hst : f =ᵐ[μ.restrict s] g) :\n  integrable_on g s μ :=\nintegrable.congr h hst\n\nlemma integrable_on.congr_fun (h : integrable_on f s μ) (hst : eq_on f g s)\n  (hs : measurable_set s) :\n  integrable_on g s μ :=\nh.congr_fun' ((ae_restrict_iff' hs).2 (eventually_of_forall hst))\n\nlemma integrable.integrable_on (h : integrable f μ) : integrable_on f s μ :=\nh.mono_measure $ measure.restrict_le_self\n\nlemma integrable.integrable_on' (h : integrable f (μ.restrict s)) : integrable_on f s μ :=\nh\n\nlemma integrable_on.restrict (h : integrable_on f s μ) (hs : measurable_set s) :\n  integrable_on f s (μ.restrict t) :=\nby { rw [integrable_on, measure.restrict_restrict hs], exact h.mono_set (inter_subset_left _ _) }\n\nlemma integrable_on.left_of_union (h : integrable_on f (s ∪ t) μ) : integrable_on f s μ :=\nh.mono_set $ subset_union_left _ _\n\nlemma integrable_on.right_of_union (h : integrable_on f (s ∪ t) μ) : integrable_on f t μ :=\nh.mono_set $ subset_union_right _ _\n\nlemma integrable_on.union (hs : integrable_on f s μ) (ht : integrable_on f t μ) :\n  integrable_on f (s ∪ t) μ :=\n(hs.add_measure ht).mono_measure $ measure.restrict_union_le _ _\n\n@[simp] lemma integrable_on_union :\n  integrable_on f (s ∪ t) μ ↔ integrable_on f s μ ∧ integrable_on f t μ :=\n⟨λ h, ⟨h.left_of_union, h.right_of_union⟩, λ h, h.1.union h.2⟩\n\n@[simp] lemma integrable_on_singleton_iff {x : α} [measurable_singleton_class α] :\n  integrable_on f {x} μ ↔ f x = 0 ∨ μ {x} < ∞ :=\nbegin\n  have : f =ᵐ[μ.restrict {x}] (λ y, f x),\n  { filter_upwards [ae_restrict_mem (measurable_set_singleton x)] with _ ha,\n    simp only [mem_singleton_iff.1 ha], },\n  rw [integrable_on, integrable_congr this, integrable_const_iff],\n  simp,\nend\n\n@[simp] lemma integrable_on_finite_bUnion {s : set β} (hs : s.finite)\n  {t : β → set α} : integrable_on f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, integrable_on f (t i) μ :=\nbegin\n  apply hs.induction_on,\n  { simp },\n  { intros a s ha hs hf, simp [hf, or_imp_distrib, forall_and_distrib] }\nend\n\n@[simp] lemma integrable_on_finset_Union {s : finset β} {t : β → set α} :\n  integrable_on f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, integrable_on f (t i) μ :=\nintegrable_on_finite_bUnion s.finite_to_set\n\n@[simp] lemma integrable_on_finite_Union [finite β] {t : β → set α} :\n  integrable_on f (⋃ i, t i) μ ↔ ∀ i, integrable_on f (t i) μ :=\nby { casesI nonempty_fintype β,\n  simpa using @integrable_on_finset_Union _ _ _ _ _ f μ finset.univ t }\n\nlemma integrable_on.add_measure (hμ : integrable_on f s μ) (hν : integrable_on f s ν) :\n  integrable_on f s (μ + ν) :=\nby { delta integrable_on, rw measure.restrict_add, exact hμ.integrable.add_measure hν }\n\n@[simp] lemma integrable_on_add_measure :\n  integrable_on f s (μ + ν) ↔ integrable_on f s μ ∧ integrable_on f s ν :=\n⟨λ h, ⟨h.mono_measure (measure.le_add_right le_rfl),\n  h.mono_measure (measure.le_add_left le_rfl)⟩,\n  λ h, h.1.add_measure h.2⟩\n\nlemma _root_.measurable_embedding.integrable_on_map_iff [measurable_space β] {e : α → β}\n  (he : measurable_embedding e) {f : β → E} {μ : measure α} {s : set β} :\n  integrable_on f s (measure.map e μ) ↔ integrable_on (f ∘ e) (e ⁻¹' s) μ :=\nby simp only [integrable_on, he.restrict_map, he.integrable_map_iff]\n\nlemma integrable_on_map_equiv [measurable_space β] (e : α ≃ᵐ β) {f : β → E} {μ : measure α}\n  {s : set β} :\n  integrable_on f s (measure.map e μ) ↔ integrable_on (f ∘ e) (e ⁻¹' s) μ :=\nby simp only [integrable_on, e.restrict_map, integrable_map_equiv e]\n\nlemma measure_preserving.integrable_on_comp_preimage [measurable_space β] {e : α → β} {ν}\n  (h₁ : measure_preserving e μ ν) (h₂ : measurable_embedding e) {f : β → E} {s : set β} :\n  integrable_on (f ∘ e) (e ⁻¹' s) μ ↔ integrable_on f s ν :=\n(h₁.restrict_preimage_emb h₂ s).integrable_comp_emb h₂\n\nlemma measure_preserving.integrable_on_image [measurable_space β] {e : α → β} {ν}\n  (h₁ : measure_preserving e μ ν) (h₂ : measurable_embedding e) {f : β → E} {s : set α} :\n  integrable_on f (e '' s) ν ↔  integrable_on (f ∘ e) s μ :=\n((h₁.restrict_image_emb h₂ s).integrable_comp_emb h₂).symm\n\nlemma integrable_indicator_iff (hs : measurable_set s) :\n  integrable (indicator s f) μ ↔ integrable_on f s μ :=\nby simp [integrable_on, integrable, has_finite_integral, nnnorm_indicator_eq_indicator_nnnorm,\n  ennreal.coe_indicator, lintegral_indicator _ hs, ae_strongly_measurable_indicator_iff hs]\n\nlemma integrable_on.integrable_indicator (h : integrable_on f s μ) (hs : measurable_set s) :\n  integrable (indicator s f) μ :=\n(integrable_indicator_iff hs).2 h\n\nlemma integrable.indicator (h : integrable f μ) (hs : measurable_set s) :\n  integrable (indicator s f) μ :=\nh.integrable_on.integrable_indicator hs\n\nlemma integrable_on.indicator (h : integrable_on f s μ) (ht : measurable_set t) :\n  integrable_on (indicator t f) s μ :=\nintegrable.indicator h ht\n\nlemma integrable_indicator_const_Lp {E} [normed_add_comm_group E]\n  {p : ℝ≥0∞} {s : set α} (hs : measurable_set s) (hμs : μ s ≠ ∞) (c : E) :\n  integrable (indicator_const_Lp p hs hμs c) μ :=\nbegin\n  rw [integrable_congr indicator_const_Lp_coe_fn, integrable_indicator_iff hs, integrable_on,\n    integrable_const_iff, lt_top_iff_ne_top],\n  right,\n  simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply] using hμs,\nend\n\n/-- If a function is integrable on a set `s` and nonzero there, then the measurable hull of `s` is\nwell behaved: the restriction of the measure to `to_measurable μ s` coincides with its restriction\nto `s`. -/\nlemma integrable_on.restrict_to_measurable (hf : integrable_on f s μ) (h's : ∀ x ∈ s, f x ≠ 0) :\n  μ.restrict (to_measurable μ s) = μ.restrict s :=\nbegin\n  rcases exists_seq_strict_anti_tendsto (0 : ℝ) with ⟨u, u_anti, u_pos, u_lim⟩,\n  let v := λ n, to_measurable (μ.restrict s) {x | u n ≤ ‖f x‖},\n  have A : ∀ n, μ (s ∩ v n) ≠ ∞,\n  { assume n,\n    rw [inter_comm, ← measure.restrict_apply (measurable_set_to_measurable _ _),\n      measure_to_measurable],\n    exact (hf.measure_ge_lt_top (u_pos n)).ne },\n  apply measure.restrict_to_measurable_of_cover _ A,\n  assume x hx,\n  have : 0 < ‖f x‖, by simp only [h's x hx, norm_pos_iff, ne.def, not_false_iff],\n  obtain ⟨n, hn⟩ : ∃ n, u n < ‖f x‖, from ((tendsto_order.1 u_lim).2 _ this).exists,\n  refine mem_Union.2 ⟨n, _⟩,\n  exact subset_to_measurable _ _ hn.le\nend\n\n/-- If a function is integrable on a set `s`, and vanishes on `t \\ s`, then it is integrable on `t`\nif `t` is null-measurable. -/\nlemma integrable_on.of_ae_diff_eq_zero (hf : integrable_on f s μ)\n  (ht : null_measurable_set t μ) (h't : ∀ᵐ x ∂μ, x ∈ t \\ s → f x = 0) :\n  integrable_on f t μ :=\nbegin\n  let u := {x ∈ s | f x ≠ 0},\n  have hu : integrable_on f u μ := hf.mono_set (λ x hx, hx.1),\n  let v := to_measurable μ u,\n  have A : integrable_on f v μ,\n  { rw [integrable_on, hu.restrict_to_measurable],\n    { exact hu },\n    { assume x hx, exact hx.2 } },\n  have B : integrable_on f (t \\ v) μ,\n  { apply integrable_on_zero.congr,\n    filter_upwards [ae_restrict_of_ae h't, ae_restrict_mem₀\n      (ht.diff (measurable_set_to_measurable μ u).null_measurable_set)] with x hxt hx,\n    by_cases h'x : x ∈ s,\n    { by_contra H,\n      exact hx.2 (subset_to_measurable μ u ⟨h'x, ne.symm H⟩) },\n    { exact (hxt ⟨hx.1, h'x⟩).symm, } },\n  apply (A.union B).mono_set _,\n  rw union_diff_self,\n  exact subset_union_right _ _\nend\n\n/-- If a function is integrable on a set `s`, and vanishes on `t \\ s`, then it is integrable on `t`\nif `t` is measurable. -/\nlemma integrable_on.of_forall_diff_eq_zero (hf : integrable_on f s μ)\n  (ht : measurable_set t) (h't : ∀ x ∈ t \\ s, f x = 0) :\n  integrable_on f t μ :=\nhf.of_ae_diff_eq_zero ht.null_measurable_set (eventually_of_forall h't)\n\n/-- If a function is integrable on a set `s` and vanishes almost everywhere on its complement,\nthen it is integrable. -/\nlemma integrable_on.integrable_of_ae_not_mem_eq_zero (hf : integrable_on f s μ)\n  (h't : ∀ᵐ x ∂μ, x ∉ s → f x = 0) : integrable f μ :=\nbegin\n  rw ← integrable_on_univ,\n  apply hf.of_ae_diff_eq_zero null_measurable_set_univ,\n  filter_upwards [h't] with x hx h'x using hx h'x.2,\nend\n\n/-- If a function is integrable on a set `s` and vanishes everywhere on its complement,\nthen it is integrable. -/\nlemma integrable_on.integrable_of_forall_not_mem_eq_zero (hf : integrable_on f s μ)\n  (h't : ∀ x ∉ s, f x = 0) : integrable f μ :=\nhf.integrable_of_ae_not_mem_eq_zero (eventually_of_forall (λ x hx, h't x hx))\n\nlemma integrable_on_iff_integrable_of_support_subset (h1s : support f ⊆ s) :\n  integrable_on f s μ ↔ integrable f μ :=\nbegin\n  refine ⟨λ h, _, λ h, h.integrable_on⟩,\n  apply h.integrable_of_forall_not_mem_eq_zero (λ x hx, _),\n  contrapose! hx,\n  exact h1s (mem_support.2 hx),\nend\n\nlemma integrable_on_Lp_of_measure_ne_top {E} [normed_add_comm_group E]\n  {p : ℝ≥0∞} {s : set α} (f : Lp E p μ) (hp : 1 ≤ p) (hμs : μ s ≠ ∞) :\n  integrable_on f s μ :=\nbegin\n  refine mem_ℒp_one_iff_integrable.mp _,\n  have hμ_restrict_univ : (μ.restrict s) set.univ < ∞,\n    by simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply, lt_top_iff_ne_top],\n  haveI hμ_finite : is_finite_measure (μ.restrict s) := ⟨hμ_restrict_univ⟩,\n  exact ((Lp.mem_ℒp _).restrict s).mem_ℒp_of_exponent_le hp,\nend\n\nlemma integrable.lintegral_lt_top {f : α → ℝ} (hf : integrable f μ) :\n  ∫⁻ x, ennreal.of_real (f x) ∂μ < ∞ :=\ncalc ∫⁻ x, ennreal.of_real (f x) ∂μ\n    ≤ ∫⁻ x, ↑‖f x‖₊ ∂μ : lintegral_of_real_le_lintegral_nnnorm f\n... < ∞ : hf.2\n\nlemma integrable_on.set_lintegral_lt_top {f : α → ℝ} {s : set α} (hf : integrable_on f s μ) :\n  ∫⁻ x in s, ennreal.of_real (f x) ∂μ < ∞ :=\nintegrable.lintegral_lt_top hf\n\n/-- We say that a function `f` is *integrable at filter* `l` if it is integrable on some\nset `s ∈ l`. Equivalently, it is eventually integrable on `s` in `l.small_sets`. -/\ndef integrable_at_filter (f : α → E) (l : filter α) (μ : measure α . volume_tac) :=\n∃ s ∈ l, integrable_on f s μ\n\nvariables {l l' : filter α}\n\nlemma integrable.integrable_at_filter (h : integrable f μ) (l : filter α) :\n  integrable_at_filter f l μ :=\n⟨univ, filter.univ_mem, integrable_on_univ.2 h⟩\n\nprotected lemma integrable_at_filter.eventually (h : integrable_at_filter f l μ) :\n  ∀ᶠ s in l.small_sets, integrable_on f s μ :=\niff.mpr (eventually_small_sets' $ λ s t hst ht, ht.mono_set hst) h\n\nlemma integrable_at_filter.filter_mono (hl : l ≤ l') (hl' : integrable_at_filter f l' μ) :\n  integrable_at_filter f l μ :=\nlet ⟨s, hs, hsf⟩ := hl' in ⟨s, hl hs, hsf⟩\n\nlemma integrable_at_filter.inf_of_left (hl : integrable_at_filter f l μ) :\n  integrable_at_filter f (l ⊓ l') μ :=\nhl.filter_mono inf_le_left\n\nlemma integrable_at_filter.inf_of_right (hl : integrable_at_filter f l μ) :\n  integrable_at_filter f (l' ⊓ l) μ :=\nhl.filter_mono inf_le_right\n\n@[simp] lemma integrable_at_filter.inf_ae_iff {l : filter α} :\n  integrable_at_filter f (l ⊓ μ.ae) μ ↔ integrable_at_filter f l μ :=\nbegin\n  refine ⟨_, λ h, h.filter_mono inf_le_left⟩,\n  rintros ⟨s, ⟨t, ht, u, hu, rfl⟩, hf⟩,\n  refine ⟨t, ht, _⟩,\n  refine hf.integrable.mono_measure (λ v hv, _),\n  simp only [measure.restrict_apply hv],\n  refine measure_mono_ae (mem_of_superset hu $ λ x hx, _),\n  exact λ ⟨hv, ht⟩, ⟨hv, ⟨ht, hx⟩⟩\nend\n\nalias integrable_at_filter.inf_ae_iff ↔ integrable_at_filter.of_inf_ae _\n\n/-- If `μ` is a measure finite at filter `l` and `f` is a function such that its norm is bounded\nabove at `l`, then `f` is integrable at `l`. -/\nlemma measure.finite_at_filter.integrable_at_filter {l : filter α} [is_measurably_generated l]\n  (hfm : strongly_measurable_at_filter f l μ) (hμ : μ.finite_at_filter l)\n  (hf : l.is_bounded_under (≤) (norm ∘ f)) :\n  integrable_at_filter f l μ :=\nbegin\n  obtain ⟨C, hC⟩ : ∃ C, ∀ᶠ s in l.small_sets, ∀ x ∈ s, ‖f x‖ ≤ C,\n    from hf.imp (λ C hC, eventually_small_sets.2 ⟨_, hC, λ t, id⟩),\n  rcases (hfm.eventually.and (hμ.eventually.and hC)).exists_measurable_mem_of_small_sets\n    with ⟨s, hsl, hsm, hfm, hμ, hC⟩,\n  refine ⟨s, hsl, ⟨hfm, has_finite_integral_restrict_of_bounded hμ _⟩⟩,\n  exact C,\n  rw [ae_restrict_eq hsm, eventually_inf_principal],\n  exact eventually_of_forall hC\nend\n\nlemma measure.finite_at_filter.integrable_at_filter_of_tendsto_ae\n  {l : filter α} [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l μ)\n  (hμ : μ.finite_at_filter l) {b} (hf : tendsto f (l ⊓ μ.ae) (𝓝 b)) :\n  integrable_at_filter f l μ :=\n(hμ.inf_of_left.integrable_at_filter (hfm.filter_mono inf_le_left)\n  hf.norm.is_bounded_under_le).of_inf_ae\n\nalias measure.finite_at_filter.integrable_at_filter_of_tendsto_ae ←\n  _root_.filter.tendsto.integrable_at_filter_ae\n\nlemma measure.finite_at_filter.integrable_at_filter_of_tendsto {l : filter α}\n  [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l μ)\n  (hμ : μ.finite_at_filter l) {b} (hf : tendsto f l (𝓝 b)) :\n  integrable_at_filter f l μ :=\nhμ.integrable_at_filter hfm hf.norm.is_bounded_under_le\n\nalias measure.finite_at_filter.integrable_at_filter_of_tendsto ←\n  _root_.filter.tendsto.integrable_at_filter\n\nlemma integrable_add_of_disjoint {f g : α → E}\n  (h : disjoint (support f) (support g)) (hf : strongly_measurable f) (hg : strongly_measurable g) :\n  integrable (f + g) μ ↔ integrable f μ ∧ integrable g μ :=\nbegin\n  refine ⟨λ hfg, ⟨_, _⟩, λ h, h.1.add h.2⟩,\n  { rw ← indicator_add_eq_left h, exact hfg.indicator hf.measurable_set_support },\n  { rw ← indicator_add_eq_right h, exact hfg.indicator hg.measurable_set_support }\nend\n\nend normed_add_comm_group\n\nend measure_theory\n\nopen measure_theory\n\nvariables [normed_add_comm_group E]\n\n/-- A function which is continuous on a set `s` is almost everywhere measurable with respect to\n`μ.restrict s`. -/\nlemma continuous_on.ae_measurable [topological_space α] [opens_measurable_space α]\n  [measurable_space β] [topological_space β] [borel_space β]\n  {f : α → β} {s : set α} {μ : measure α} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_measurable f (μ.restrict s) :=\nbegin\n  nontriviality α, inhabit α,\n  have : piecewise s f (λ _, f default) =ᵐ[μ.restrict s] f := piecewise_ae_eq_restrict hs,\n  refine ⟨piecewise s f (λ _, f default), _, this.symm⟩,\n  apply measurable_of_is_open,\n  assume t ht,\n  obtain ⟨u, u_open, hu⟩ : ∃ (u : set α), is_open u ∧ f ⁻¹' t ∩ s = u ∩ s :=\n    _root_.continuous_on_iff'.1 hf t ht,\n  rw [piecewise_preimage, set.ite, hu],\n  exact (u_open.measurable_set.inter hs).union ((measurable_const ht.measurable_set).diff hs)\nend\n\n/-- A function which is continuous on a separable set `s` is almost everywhere strongly measurable\nwith respect to `μ.restrict s`. -/\nlemma continuous_on.ae_strongly_measurable_of_is_separable\n  [topological_space α] [pseudo_metrizable_space α] [opens_measurable_space α]\n  [topological_space β] [pseudo_metrizable_space β]\n  {f : α → β} {s : set α} {μ : measure α} (hf : continuous_on f s) (hs : measurable_set s)\n  (h's : topological_space.is_separable s) :\n  ae_strongly_measurable f (μ.restrict s) :=\nbegin\n  letI := pseudo_metrizable_space_pseudo_metric α,\n  borelize β,\n  rw ae_strongly_measurable_iff_ae_measurable_separable,\n  refine ⟨hf.ae_measurable hs, f '' s, hf.is_separable_image h's, _⟩,\n  exact mem_of_superset (self_mem_ae_restrict hs) (subset_preimage_image _ _),\nend\n\n/-- A function which is continuous on a set `s` is almost everywhere strongly measurable with\nrespect to `μ.restrict s` when either the source space or the target space is second-countable. -/\nlemma continuous_on.ae_strongly_measurable\n  [topological_space α] [topological_space β] [h : second_countable_topology_either α β]\n  [opens_measurable_space α] [pseudo_metrizable_space β]\n  {f : α → β} {s : set α} {μ : measure α} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_strongly_measurable f (μ.restrict s) :=\nbegin\n  borelize β,\n  refine ae_strongly_measurable_iff_ae_measurable_separable.2 ⟨hf.ae_measurable hs, f '' s, _,\n    mem_of_superset (self_mem_ae_restrict hs) (subset_preimage_image _ _)⟩,\n  casesI h.out,\n  { let f' : s → β := s.restrict f,\n    have A : continuous f' := continuous_on_iff_continuous_restrict.1 hf,\n    have B : is_separable (univ : set s) := is_separable_of_separable_space _,\n    convert is_separable.image B A using 1,\n    ext x,\n    simp },\n  { exact is_separable_of_separable_space _ }\nend\n\n/-- A function which is continuous on a compact set `s` is almost everywhere strongly measurable\nwith respect to `μ.restrict s`. -/\nlemma continuous_on.ae_strongly_measurable_of_is_compact\n  [topological_space α] [opens_measurable_space α] [topological_space β] [pseudo_metrizable_space β]\n  {f : α → β} {s : set α} {μ : measure α}\n  (hf : continuous_on f s) (hs : is_compact s) (h's : measurable_set s) :\n  ae_strongly_measurable f (μ.restrict s) :=\nbegin\n  letI := pseudo_metrizable_space_pseudo_metric β,\n  borelize β,\n  rw ae_strongly_measurable_iff_ae_measurable_separable,\n  refine ⟨hf.ae_measurable h's, f '' s, _, _⟩,\n  { exact (hs.image_of_continuous_on hf).is_separable },\n  { exact mem_of_superset (self_mem_ae_restrict h's) (subset_preimage_image _ _) }\nend\n\nlemma continuous_on.integrable_at_nhds_within_of_is_separable\n  [topological_space α] [pseudo_metrizable_space α]\n  [opens_measurable_space α] {μ : measure α} [is_locally_finite_measure μ]\n  {a : α} {t : set α} {f : α → E} (hft : continuous_on f t) (ht : measurable_set t)\n  (h't : topological_space.is_separable t) (ha : a ∈ t) :\n  integrable_at_filter f (𝓝[t] a) μ :=\nbegin\n  haveI : (𝓝[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter ⟨_, self_mem_nhds_within,\n    hft.ae_strongly_measurable_of_is_separable ht h't⟩ (μ.finite_at_nhds_within _ _),\nend\n\nlemma continuous_on.integrable_at_nhds_within\n  [topological_space α] [second_countable_topology_either α E]\n  [opens_measurable_space α] {μ : measure α} [is_locally_finite_measure μ]\n  {a : α} {t : set α} {f : α → E} (hft : continuous_on f t) (ht : measurable_set t) (ha : a ∈ t) :\n  integrable_at_filter f (𝓝[t] a) μ :=\nbegin\n  haveI : (𝓝[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter ⟨_, self_mem_nhds_within, hft.ae_strongly_measurable ht⟩\n    (μ.finite_at_nhds_within _ _),\nend\n\nlemma continuous.integrable_at_nhds\n  [topological_space α] [second_countable_topology_either α E]\n  [opens_measurable_space α] {μ : measure α} [is_locally_finite_measure μ]\n  {f : α → E} (hf : continuous f) (a : α) :\n  integrable_at_filter f (𝓝 a) μ :=\nbegin\n  rw ← nhds_within_univ,\n  exact hf.continuous_on.integrable_at_nhds_within measurable_set.univ (mem_univ a),\nend\n\n/-- If a function is continuous on an open set `s`, then it is strongly measurable at the filter\n`𝓝 x` for all `x ∈ s` if either the source space or the target space is second-countable. -/\nlemma continuous_on.strongly_measurable_at_filter [topological_space α]\n  [opens_measurable_space α] [topological_space β] [pseudo_metrizable_space β]\n  [second_countable_topology_either α β] {f : α → β} {s : set α} {μ : measure α}\n  (hs : is_open s) (hf : continuous_on f s) :\n  ∀ x ∈ s, strongly_measurable_at_filter f (𝓝 x) μ :=\nλ x hx, ⟨s, is_open.mem_nhds hs hx, hf.ae_strongly_measurable hs.measurable_set⟩\n\nlemma continuous_at.strongly_measurable_at_filter\n  [topological_space α] [opens_measurable_space α] [second_countable_topology_either α E]\n  {f : α → E} {s : set α} {μ : measure α} (hs : is_open s) (hf : ∀ x ∈ s, continuous_at f x) :\n  ∀ x ∈ s, strongly_measurable_at_filter f (𝓝 x) μ :=\ncontinuous_on.strongly_measurable_at_filter hs $ continuous_at.continuous_on hf\n\nlemma continuous.strongly_measurable_at_filter [topological_space α] [opens_measurable_space α]\n  [topological_space β] [pseudo_metrizable_space β] [second_countable_topology_either α β]\n  {f : α → β} (hf : continuous f) (μ : measure α) (l : filter α) :\n  strongly_measurable_at_filter f l μ :=\nhf.strongly_measurable.strongly_measurable_at_filter\n\n/-- If a function is continuous on a measurable set `s`, then it is measurable at the filter\n  `𝓝[s] x` for all `x`. -/\nlemma continuous_on.strongly_measurable_at_filter_nhds_within {α β : Type*} [measurable_space α]\n  [topological_space α] [opens_measurable_space α] [topological_space β] [pseudo_metrizable_space β]\n  [second_countable_topology_either α β] {f : α → β} {s : set α} {μ : measure α}\n  (hf : continuous_on f s) (hs : measurable_set s) (x : α) :\n  strongly_measurable_at_filter f (𝓝[s] x) μ :=\n⟨s, self_mem_nhds_within, hf.ae_strongly_measurable hs⟩\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/measure_theory/integral/integrable_on.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.4579380481349749}}
{"text": "import data.nat.prime\nimport data.list\n-- import data.bool\n\n-- set_option trace.simplify true\nset_option trace.simplify.rewrite true\nset_option trace.simplify.failure false\nset_option trace.simplify.rewrite_failure false\n\nnamespace first\nconstants a b : ℤ\nconstant f : ℤ → ℤ\nconstant g : ℤ → ℤ → ℤ\n\n#check λ x : ℤ, g (f (g a x)) (g x _)\n-- λ (x : ℤ), g (f (g a x)) (g x ?M_1) : ℤ → ℤ\n#check λx, g (f (g a x)) (g x b)\n-- λ x <=> λx\nend first\n\nnamespace trools\n-- constant trool : Type\n\n-- constants trool.true trool.false trool.maybe : trool\ninductive trool\n| true : trool\n| false : trool\n| maybe : trool\n\n#check trool.true -- trool.true : trool\n\ndef trool_to_bool (x : trool) : bool :=\nmatch x with\n| trool.true := tt\n| trool.false := ff\n| _ := ff\nend\n\ndef trool_to_bool₂: trool → bool\n| trool.true := tt\n| trool.false := ff\n| _ := ff\n\n-- def prime (p : ℕ) := 2 ≤ p ∧ ∀ m ∣ p, m = 1 ∨ m = p\ndef or (a b : trool) := (a = trool.true) ∨ (b = trool.true)\n\n-- or a a = (a = trool.true) ∨ (a = trool.true) = X ∨ X = X = (a = trool.true)\n-- (a = trool.true) => \n-- case 1: trool_to_bool trool.true  ↔ (trool.true  = trool.true)\n-- case 2: trool_to_bool trool.false ↔ (trool.false = trool.true)\n-- case 3: trool_to_bool trool.maybe ↔ (trool.maybe = trool.true)\n-- \nlemma or_self (a : trool) : or a a = trool_to_bool a :=\nbegin\n  simp [or],\n  cases a; dsimp [trool_to_bool],\n  {\n    -- rw [eq.refl trool.true], -- do nothing :D\n    rw eq_self_iff_true,\n    rw bool.coe_sort_tt, -- I'm found it from idea of coe_sort_ff + (if exist ff then exist tt)\n  },\n  {\n    -- simp [trool_to_bool],\n    -- [bool.coe_sort_ff]: ↥ff ==> false\n    -- [iff_self]: false ↔ false ==> true\n    rw bool.coe_sort_ff,\n    -- apply iff.symm,\n    -- change false ↔ false, -- fails\n    simp,\n\n    -- all below not useful and generated by suggest\n    -- refine iff.symm _\n    -- refine iff_of_eq _\n    -- refine eq.to_iff _\n    -- refine iff_false_intro _\n  },\n  {\n    simp,\n  },\nend\nend trools\n\nnamespace axiom_examples\nconstants a b : ℤ\n-- lemma a_less_b : a < b := sorry \n-- <=>\naxiom a_less_b : a < b\naxiom symm_lt (x y : ℤ): x < y → y > x\naxiom not_eq_imp_lt (x y : ℤ): x ≠ y → x < y ∨ x > y\n\nexample : b > a :=\nbegin\n  have s := symm_lt _ _ a_less_b,\n  exact s,\nend\n\nlemma p_q_not (P Q: Prop) : P = Q → P ∧ ¬ Q → false := \nbegin\n  intro pq,\n  rw ← pq,\n  intro h,\n  simp at h,\n  exact h,\nend\n\nexample (x: nat): x = x := \nbegin\n  have h1: 1 = 1,{refl,},\n  have h2: 2 = 2 := rfl,\n  -- have h3 := h1 ∧ h2, -- wrong\n  have h3 := and.intro h1 h2, -- right\n  refl,\nend\n\nconstants P Q : Type\n-- lemma p_q_not (p : P)(q : Q) : p = q → p ∧ ¬ q → false := sorry\n\n\nlemma example_forward_proof (p : Prop) : p = p :=\nbegin\n  -- simp, -- [simplify.rewrite] [eq_self_iff_true]: p = p ==> true\n  -- refl,\n  -- apply eq_self_iff_true p,\n\n  have h1 := eq_self_iff_true p, -- we don't need this, only for example\n  have h2 := h1.to_eq, -- also works: propext h1\n  have h3 := h1.mpr,\n  have h4 := h3 true.intro,\n  exact h4,\nend\n\n#print example_forward_proof\n-- λ (p : Prop), (eq_self_iff_true p).mpr true.intro\n\n-- this can be proved by reflexivity\nlemma example_forward_proof₂ (p : Prop) : p = p := eq.refl _\n\n#print example_forward_proof₂ -- λ (p : Prop), eq.refl p\n\nlemma example_forward_proof₃ (p q : Prop) : p = q → (p ∧ q) = p :=\nbegin\n  assume h1 : p = q,\n  have h2 : p ∧ p ↔ p := and_self p,\n  have h3 : (p ∧ p) = p := h2.to_eq, -- iff.to_eq\n  have h4 : (p ∧ p) = p → (p ∧ q) = p := \n    assume (h: (p ∧ p) = p), eq.subst h1 h,\n  show (p ∧ q) = p, from h4 h3, -- ≈ exact h4 h3, but more readable\nend\n\nexample (expr : Prop): (expr ∨ expr) → true :=\nbegin\n  -- simp,\n-- 0. [simplify.rewrite] [or_self]: expr ∨ expr ==> expr\n-- 0. [simplify.rewrite] [forall_true_iff]: expr → true ==> true\n  rw or_self,\n  rw forall_true_iff,\n  exact true.intro,\nend\n\n-- id <=> ∀ A : Type, A → A\nexample : ∀ A : Type, A → A := λ _, id\nexample : ∀ A : Type, A → A := λ A, @id A\nexample : ∀ A : Type, A → A := assume A, @id A\nexample (A : Type) : A → A := id -- explicit (argument)\nexample {A : Type} : A → A := id -- implicit {argument}\nexample ⦃A : Type⦄ : A → A := id -- i don't know, but possible\n\nexample (x y : ℤ): ¬ (x = y) ∧ ¬ (x > y) → (y > x) :=\nbegin\n  assume f : ¬x = y ∧ ¬x > y,\n  apply symm_lt,\n  -- exact a_less_b, -- not works\n  have f₂ : _ ∧ _ := f, -- example pattern matching\n  clear f₂,\n  have h₂ : ¬ (x = y) → x ≠ y, by {\n    tactic.trace_state,\n  -- simp,\n  -- [ne.def]: x ≠ y ==> ¬x = y\n  -- [classical.not_not]: ¬¬x = y ==> x = y\n  -- [imp_self]: ¬x = y → ¬x = y ==> true\n    show_term { rw [ne.def], },\n    exact id, -- id <=> ∀ A : Type, A → A\n    tactic.trace_result,\n  },\n  have f1 := f.1,\n  have f2 := f.2,\n  clear f,\n  have not_eq_xy : x ≠ y := h₂ f1,\n  have h₃ : x < y ∨ x > y := not_eq_imp_lt _ _ not_eq_xy,\n  cases h₃ with first second,\n  {\n    -- first : x < y\n    -- i think this one command `exact first` must be solution\n    exact first,\n  }, \n  {\n    -- contradiction,\n    exfalso,\n    -- have t₁ := p_q_not second f2,\n    -- have h₅ := p_q_not _ _,\n\n    -- have u := and.intro second f2,\n    -- simp [second] at u,\n    -- exact u,\n    exact absurd second f2,\n  },\nend \n\n\nend axiom_examples\n\nnamespace backward_proofs\n/-\nForward proof:\nFrom a and a → b, we have b. (Goal unchanged)\nFrom b and b → c, we have c, as desired.\n* A forward proof only manipulates theorems, not goals.\n\nBackward proof:\nTo prove c, by b → c it suffices to prove b. (Goal changed from ⊢ c to ⊢ b)\nTo prove b, by a → b it suffices to prove a. (Goal changed from ⊢ b to ⊢ a)\nTo prove a, we use a.\n* A Backward proof start from the goal and work backwards towards the already proved lemmas.\n-/\n\n-- Example of forward proof:\nlemma fst_of_two_props :\n  ∀ a b : Prop, a → b → (a → b) :=\nbegin -- ⊢ ∀ (a b : Prop), a → b → a\n  introv,\n  intros ha hb,\n  have h := imp_intro hb, -- it's example very trivial\n  exact h,\nend\n\n-- Example of backward proof:\nlemma fst_of_two_props' :\n  ∀ a b : Prop, a → b → a :=\nbegin -- ⊢ ∀ (a b : Prop), a → b → a\n  introv, -- ⊢ a → b → a (Goal changed)\n  intros ha hb, -- ⊢ a (Goal changed)\n  apply ha, -- goals accomplished (Goal changed)\nend\n\nlemma and_swap :\n  ∀ a b : Prop, a ∧ b → b ∧ a :=\nbegin\n  intros a b hab,\n  apply and.intro,\n  -- { exact hab.2 },\n  -- { exact hab.1 },\n  { exact and.elim_right hab },\n  { exact and.elim_left hab },\nend\n\ndef double (n : ℕ) := n + n\n\nlemma nat_exists_double_iden :\n  ∃ n : ℕ, double n = n :=\nbegin\n  apply exists.intro 0, -- ↔ use 0\n  refl,\nend\n\nlemma double_prop : ∀ n : ℕ, n ≠ 1 → double n ≠ n + 1 :=\nbegin\n  type_check double.equations._eqn_1, -- ∀ (n : ℕ), double n = n + n\n  intros,\n  apply not.intro,\n  induction n with x hx,\n  simp [double],\n  have a2 : x ≠ 0, from sorry,\n  dsimp only [double],\n  simp,\n  -- simp at hx ⊢, -- example how to simplify goal and hypothesis simultaniously\n  simp only [a],\n  -- show_term { trivial, }, -- λ (a_1 : false), false.rec false a_1\n  exact id, -- shortest proof\nend\n\n#print double_prop\n\nend backward_proofs\n\nnamespace lemma_statements\n\nset_option trace.simplify.rewrite_failure true\n\nlemma my_add_comm (m n : ℕ) :\n  nat.add m n = nat.add n m :=\nbegin\n  simp,\n  simp only [backward_proofs.double_prop, nat.add_comm],  --\n  -- output:\n  -- perm rejected: n + m !< m + n\n  -- [simplify.rewrite] [nat.add_comm]: n + m ==> m + n\n\n  -- simp works only with second part of equation n + m = m + n:\n  -- n + m = (m + n) ==> n + m = (n + m) ==> true\n  -- 1. because theorem nat.add_comm is ∀ (m n : ℕ), m + n = n + m [it's wrong]\n  -- 2. \n  -- maybe simp use lecsicographical order? \nend\n\n#print nat.add_comm\n\nlemma and_swap (a b : Prop) :\n  a ∧ b → b ∧ a :=\nbegin\n  intro hab,\n  apply and.intro,\n  -- {\n        -- apply and.elim_right,\n        -- exact hab,\n  -- }\n  -- <=>\n  -- apply and.elim_right hab, <=>\n  exact hab.2,\n  exact hab.1,\nend\n\n/-\n  3.1 Structured Proofs\n-/\n\nlemma fst_of_two_props'' :\n  ∀ a b : Prop, a → b → a :=\nassume a b : Prop,\nassume (ha : a)(hb : b),\nshow a, from ha\n\nlemma snd_of_two_props'' :\n  ∀ a b : Prop, a → b → b :=\nassume _ b : Prop,\nassume (_)(hb : b),\nshow _, from hb -- placeholder _ is important thing\n\nlemma prop_comp (a b c : Prop) (hab : a → b) (hbc : b → c) :\n  a → c :=\nassume ha : a,\nhave hb : b := hab ha,\nhave hc : c := hbc hb,\nshow c, from hc\n\n#print fst_of_two_props''\n-- λ (a b : Prop) (ha : a) (hb : b), show a, from ha\n#print snd_of_two_props''\n-- λ (_x b : Prop) (_x : _x) (hb : b), show b, from hb\n#print prop_comp\n-- λ (a b c : Prop) (hab : a → b) (hbc : b → c) (ha : a),\n--   have hb : b, from hab ha,\n--   have hc : c, from hbc hb,\n--   show c, from hc\n\n\n/-\n  3.3 Forward Reasoning about Connectives and Quantifiers\n-/\n\n-- lemma forall.one_point {α : Type} (t : α) (p : α → Prop) :\n--   (∀x, x = t → p x) ↔ p t :=\n-- iff.intro\n--   (assume hall : ∀x, x = t → p x,\n--     show p t, from\n--      begin\n--        apply hall t,\n--        refl\n--      end)\n--   (assume hp : p t,\n--     fix x,\n--     assume heq : x = t,\n--     show p x, from\n--     begin\n--       rewrite heq,\n--       exact hp\n--     end)\n\n\n\nexample : 1 = 2 → 2 = 3 → 1 = 3 := \n  λ (h₁ : 1 = 2) (h₂ : 2 = 3), @eq.subst nat (λ n, 1 = n) 2 3 h₂ h₁\n\nexample : 1 = 2 → 2 = 3 → 1 = 3 := by {\n  intros h1 h2,\n  -- apply @eq.subst nat (λ n, 1 = n) 2 3 h2 h1,\n  -- exact eq.subst h2 h1,\n  exact h2 ▸ h1,\n}\n\nlemma forall.one_point' {α : Type} (t : α) (p : α → Prop) :\n  (∀x, x = t → p x) ↔ p t :=\niff.intro\n  (assume hall: ∀ x, x = t → p x, \n   have h₁ : t = t → p t, from hall t,\n   show p t, from h₁ (rfl : t = t))\n  (λ h₁ x (h₂ : x = t), \n  show p x, from (h₂.symm : t = x) ▸ (h₁ : p t)) -- λ ↔ assume\n  --by {\n    -- refine @eq.subst α _ t x h₂.symm h₁,\n  -- exact h₂.symm ▸ h₁ }\n\nlemma beast_666 (beast : ℕ) :\n  (∀n, n = 666 → beast ≥ n) ↔ beast ≥ 666 :=\nforall.one_point' 666 (λ n, nat.le n beast) -- x ≥ y ↔ ge x y ↔ le y x\n -- nat.ge don't exists because developers of lean lib want to minimize number of equivalent functions\n-- λ (beast : ℕ), forall.one_point' 666 (λ (n : ℕ), beast ≥ n)\n\n#print beast_666\n\n/-\n  3.4 Calculational Proofs\n-/\n-- Calculational proof example:\nlemma two_mul_example (m n : nat) :\n  2 * m + n = m + n + m :=\ncalc  2 * m + n\n    = (m + m) + n : by rewrite two_mul\n    ... = m + n + m : by cc\n\n-- Forward proof example:\nlemma two_mul_example₂ (m n : nat) :\n  2 * m + n = m + n + m :=\nhave h₁ : 2 * m + n = (m + m) + n :=\n  by rewrite two_mul,\nhave h₂ : (m + m) + n = m + n + m :=\n  by show_term { cc },\nshow _, from\n  eq.trans h₁ h₂\n\nend lemma_statements\n\nnamespace proofs_by_induction\n\nconstant add : ℕ → ℕ → ℕ\n\naxiom add_zero (m : ℕ): add m 0 = m\naxiom add_succ (m n : ℕ): add n (nat.succ n) = nat.succ (add m n)\n\n-- lemma add_zero (n : ℕ)\n\nend proofs_by_induction\n\nnamespace induction_by_pattern_matching\n\ndef reverse {α : Type} : list α → list α\n| []       := []\n| (x :: xs) := reverse xs ++ [x]\n\n-- The induction step is:\n-- ih : ∀xs, reverse (reverse xs) = xs ⊢ reverse (reverse xs ++ [x]) = x :: xs\n\n/-\nWe need a way to \"distribute\" the outer reverse over ++ to obtain a term\nmatches the induction hypothesis's left-hand side. The trick is to prove\nand use the following lemma:\n-/\n\n-- Step 1:\n-- lemma reverse_append {α : Type} :\n--   ∀xs ys : list α, reverse (xs ++ ys) = reverse ys ++ reverse xs\n-- | [] ys := sorry\n-- | (x :: xs) ys := sorry\n\n-- Step 2:\n\n-- failed to prove recursive application is decreasing, well founded relation\nlemma reverse_append_wrong {α : Type} :\n  ∀ xs ys : list α, reverse (xs ++ ys) = reverse ys ++ reverse xs\n| [] ys := begin\n  -- rw reverse,\n  -- simp,\n  rw reverse_append_wrong,\nend\n| (x :: xs) ys := begin\n  simp [reverse, reverse_append_wrong xs],\nend\n\n-- OK\nlemma reverse_append {α : Type} :\n  ∀ xs ys : list α, reverse (xs ++ ys) = reverse ys ++ reverse xs\n| [] ys := begin\n  rw reverse,\n  simp only [list.nil_append, list.append_nil],\n  -- rw reverse_append,\nend\n| (x :: xs) ys := begin\n  simp only [reverse, reverse_append xs, list.append_assoc, list.cons_append],\nend\n\nlemma reverse_append₂ {α : Type} (xs ys : list α) :\n  reverse (xs ++ ys) = reverse ys ++ reverse xs :=\nbegin\n  induction xs with xs list_h ih,\n  case nil {\n    simp [reverse],\n  },\n  case cons {\n    simp [reverse, ih],\n  },\nend\n\nset_option trace.simp_lemmas false\n\nlemma reverse_reverse {α : Type} :\n  ∀xs : list α, reverse (reverse xs) = xs\n| [] := rfl\n| (x :: xs) := begin\n  -- rw reverse_reverse, -- failed to prove recursive application is decreasing\n  rw reverse,\n  rw reverse_append,\n  rw reverse_reverse,\n  rw reverse.equations._eqn_2,\n  rw reverse.equations._eqn_1,\n  rw list.nil_append,\n  rw list.cons_append,\n  rw list.nil_append,\n  -- rw reverse,\n  -- simp [reverse],\n  -- Trace output of simplify.rewrite:\n  -- 1. [reverse.equations._eqn_2]: reverse [x] ==> reverse list.nil ++ [x]\n  -- 2. [reverse.equations._eqn_1]: reverse list.nil ==> list.nil\n  -- 3. [list.nil_append]: list.nil ++ [x] ==> [x]\n  -- 4. [list.cons_append]: [x] ++ xs ==> x :: (list.nil ++ xs)\n  -- 5. [list.nil_append]: list.nil ++ xs ==> xs\n  -- 6. [eq_self_iff_true]: x = x ==> true\n  -- 7. [eq_self_iff_true]: xs = xs ==> true\n  -- 8. [and_self]: true ∧ true ==> true\nend\n\nlemma reverse_reverse₂ {α : Type} :\n  ∀xs : list α, reverse (reverse xs) = xs\n| [] := rfl\n| (x :: xs) := by simp [reverse, reverse_append, reverse_reverse₂ xs]\n\n\n\nend induction_by_pattern_matching\nnamespace inductive_types\n\nnamespace hidden\ninductive nat : Type\n| zero : nat\n| succ : nat → nat\nend hidden\n-- <=>\nnamespace hidden2\nconstant nat : Type\nconstant nat.zero : nat\nconstant nat.succ : nat → nat\nend hidden2\n-- + some properties about nat.zero and nat.succ, which is why we use the \"inductive\" commmand\n\nset_option trace.debug.dsimplify true\n-- set_option trace.simplify false\nset_option trace.simplify.context false\nset_option trace.simplify.congruence false\nset_option trace.simplify.canonize false\nset_option trace.simplify.rewrite true\n\nlemma succ_neq_self (n : ℕ) :\n  nat.succ n ≠ n :=\nbegin\n  induction n with n ih,\n  {\n    -- [nat.nat_zero_eq_zero]: 0 ==> 0\n    -- [ne.def]: 1 ≠ 0 ==> ¬1 = 0\n    simp,\n  }, \n  {\n    rewrite ne.def,\n    simp only [ih, ne.def, not_false_iff],\n  },\n  -- [ne.def]: n_n.succ.succ ≠ n_n.succ ==> ¬n_n.succ.succ = n_n.succ\n-- 2. [simplify.rewrite] [n_ih]: n_n.succ = n_n ==> false\n-- [simplify] eq: not\n-- 1. [simplify.rewrite] [not_false_iff]: ¬false ==> true\nend\n\nend inductive_types", "meta": {"author": "mathprocessing", "repo": "lean_mathlib_examples", "sha": "743c6456c0a3219dd1722efdd31ee6f3a113818a", "save_path": "github-repos/lean/mathprocessing-lean_mathlib_examples", "path": "github-repos/lean/mathprocessing-lean_mathlib_examples/lean_mathlib_examples-743c6456c0a3219dd1722efdd31ee6f3a113818a/src/hitchhikers_guide.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.45793803871524585}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.normed_space.banach\nimport Mathlib.analysis.normed_space.finite_dimension\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Complemented subspaces of normed vector spaces\n\nA submodule `p` of a topological module `E` over `R` is called *complemented* if there exists\na continuous linear projection `f : E →ₗ[R] p`, `∀ x : p, f x = x`. We prove that for\na closed subspace of a normed space this condition is equivalent to existence of a closed\nsubspace `q` such that `p ⊓ q = ⊥`, `p ⊔ q = ⊤`. We also prove that a subspace of finite codimension\nis always a complemented subspace.\n\n## Tags\n\ncomplemented subspace, normed vector space\n-/\n\nnamespace continuous_linear_map\n\n\ntheorem ker_closed_complemented_of_finite_dimensional_range {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] [complete_space 𝕜] (f : continuous_linear_map 𝕜 E F) [finite_dimensional 𝕜 ↥(range f)] : submodule.closed_complemented (ker f) := sorry\n\n/-- If `f : E →L[R] F` and `g : E →L[R] G` are two surjective linear maps and\ntheir kernels are complement of each other, then `x ↦ (f x, g x)` defines\na linear equivalence `E ≃L[R] F × G`. -/\ndef equiv_prod_of_surjective_of_is_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] [complete_space E] [complete_space (F × G)] (f : continuous_linear_map 𝕜 E F) (g : continuous_linear_map 𝕜 E G) (hf : range f = ⊤) (hg : range g = ⊤) (hfg : is_compl (ker f) (ker g)) : continuous_linear_equiv 𝕜 E (F × G) :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous\n    (linear_map.equiv_prod_of_surjective_of_is_compl (↑f) (↑g) hf hg hfg) sorry\n\n@[simp] theorem coe_equiv_prod_of_surjective_of_is_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] [complete_space E] [complete_space (F × G)] {f : continuous_linear_map 𝕜 E F} {g : continuous_linear_map 𝕜 E G} (hf : range f = ⊤) (hg : range g = ⊤) (hfg : is_compl (ker f) (ker g)) : ↑(equiv_prod_of_surjective_of_is_compl f g hf hg hfg) = ↑(continuous_linear_map.prod f g) :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_to_linear_equiv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] [complete_space E] [complete_space (F × G)] {f : continuous_linear_map 𝕜 E F} {g : continuous_linear_map 𝕜 E G} (hf : range f = ⊤) (hg : range g = ⊤) (hfg : is_compl (ker f) (ker g)) : continuous_linear_equiv.to_linear_equiv (equiv_prod_of_surjective_of_is_compl f g hf hg hfg) =\n  linear_map.equiv_prod_of_surjective_of_is_compl (↑f) (↑g) hf hg hfg :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_apply {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G] [complete_space E] [complete_space (F × G)] {f : continuous_linear_map 𝕜 E F} {g : continuous_linear_map 𝕜 E G} (hf : range f = ⊤) (hg : range g = ⊤) (hfg : is_compl (ker f) (ker g)) (x : E) : coe_fn (equiv_prod_of_surjective_of_is_compl f g hf hg hfg) x = (coe_fn f x, coe_fn g x) :=\n  rfl\n\nend continuous_linear_map\n\n\nnamespace subspace\n\n\n/-- If `q` is a closed complement of a closed subspace `p`, then `p × q` is continuously\nisomorphic to `E`. -/\ndef prod_equiv_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] (p : subspace 𝕜 E) (q : subspace 𝕜 E) (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : continuous_linear_equiv 𝕜 (↥p × ↥q) E :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous (submodule.prod_equiv_of_is_compl p q h) sorry\n\n/-- Projection to a closed submodule along a closed complement. -/\ndef linear_proj_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] (p : subspace 𝕜 E) (q : subspace 𝕜 E) (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : continuous_linear_map 𝕜 E ↥p :=\n  continuous_linear_map.comp (continuous_linear_map.fst 𝕜 ↥p ↥q)\n    ↑(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq))\n\n@[simp] theorem coe_prod_equiv_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : ⇑(prod_equiv_of_closed_compl p q h hp hq) = ⇑(submodule.prod_equiv_of_is_compl p q h) :=\n  rfl\n\n@[simp] theorem coe_prod_equiv_of_closed_compl_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : ⇑(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq)) =\n  ⇑(linear_equiv.symm (submodule.prod_equiv_of_is_compl p q h)) :=\n  rfl\n\n@[simp] theorem coe_continuous_linear_proj_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : ↑(linear_proj_of_closed_compl p q h hp hq) = submodule.linear_proj_of_is_compl p q h :=\n  rfl\n\n@[simp] theorem coe_continuous_linear_proj_of_closed_compl' {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : ⇑(linear_proj_of_closed_compl p q h hp hq) = ⇑(submodule.linear_proj_of_is_compl p q h) :=\n  rfl\n\ntheorem closed_complemented_of_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} {q : subspace 𝕜 E} (h : is_compl p q) (hp : is_closed ↑p) (hq : is_closed ↑q) : submodule.closed_complemented p :=\n  Exists.intro (linear_proj_of_closed_compl p q h hp hq) (submodule.linear_proj_of_is_compl_apply_left h)\n\ntheorem closed_complemented_iff_has_closed_compl {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} : submodule.closed_complemented p ↔ is_closed ↑p ∧ ∃ (q : subspace 𝕜 E), ∃ (hq : is_closed ↑q), is_compl p q := sorry\n\ntheorem closed_complemented_of_quotient_finite_dimensional {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] [complete_space E] {p : subspace 𝕜 E} [complete_space 𝕜] [finite_dimensional 𝕜 (submodule.quotient p)] (hp : is_closed ↑p) : submodule.closed_complemented p := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/normed_space/complemented.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.45793803461078536}}
{"text": "import combinatorics.simple_graph.basic\nimport combinatorics.simple_graph.subgraph\nimport data.finset.basic\nimport data.finset.card\nimport data.fintype.basic\nimport data.fintype.card\nimport data.finset.powerset\nimport simple_graph_aux\nimport complete_graph_aux\nimport coercions_aux\nimport induced_subgraph\n\nuniverse u\nvariables {V : Type u} [fintype V] [decidable_eq V]\nvariables (G : simple_graph V) [decidable_rel G.adj]\nvariables {k : ℕ}\n\nvariable R : ↥(finset.powerset_len k (finset.univ : finset V))\n\nvariable red_edges : (finset ↥G.edge_finset)\n\nvariable red_edges_by_R : \nfinset ↥(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) ×\nfinset ↥((G.induced_subgraph R).edge_finset)\n\n-- trivial helper lemma\nlemma card_R : (R : finset V).card = k :=\nbegin\n  cases R with R R_in,\n  change R.card = k,\n  rw finset.mem_powerset_len at R_in,\n  rw R_in.right,\nend\n\ndef red_edges_by_R_coe :\n( finset ↥(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) ×\n  finset ↥((G.induced_subgraph R).edge_finset) ) →\n  (finset ↥G.edge_finset) := λ c, \n  ↑(⟨finset.map (function.embedding.subtype _) c.fst ∪\n    finset.map (function.embedding.subtype _) c.snd,\n    begin\n      rw finset.union_subset_iff,\n      split,\n      { rw finset.subset_iff,\n        intro x,\n        intro x_in,\n        have x_in' := finset.property_of_mem_map_subtype c.fst x_in,\n        rw finset.mem_sdiff at x_in',\n        exact x_in'.left,},\n      { rw finset.subset_iff,\n        intro x,\n        intro x_in,\n        have x_in' := finset.property_of_mem_map_subtype c.snd x_in,\n        apply finset.mem_of_subset,\n        exact (G.induced_subgraph R).edge_finset_subset,\n        exact x_in', },\n    end⟩ : {s // s ⊆ G.edge_finset})\n\ninstance red_edges_by_R_has_coe : has_coe\n  ( finset ↥(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) ×\n    finset ↥((G.induced_subgraph R).edge_finset))\n  (finset ↥G.edge_finset) \n:= ⟨red_edges_by_R_coe G R⟩\n\ntheorem red_edges_by_R_coe_inj :\nfunction.injective (red_edges_by_R_coe G R) :=\nbegin\n  unfold function.injective,\n  unfold red_edges_by_R_coe,\n  change (coe : {s // s ⊆ G.edge_finset} → finset ↥(G.edge_finset))\n    with subset_subtype.finset_subtype.coe,\n  intros c₁ c₂,\n  intro h_union,\n  rw function.injective.eq_iff subset_subtype.finset_subtype.coe_injective\n    at h_union,\n  rw subtype.mk_eq_mk at h_union,\n  rw prod.ext_iff,\n  split,\n  { rw finset.ext_iff,\n    intro e,\n    split,\n    { intro e_in₁,\n      have e_coe_in₁ := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in₁,\n      rw function.embedding.coe_subtype _ at e_coe_in₁,\n      have e_coe_in_union : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₁.fst ∪\n          finset.map (function.embedding.subtype _) c₁.snd,\n      { rw finset.mem_union,\n        left,\n        exact e_coe_in₁, },\n      rw h_union at e_coe_in_union,\n      have e_coe_in₂ : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₂.fst,\n      { rw finset.mem_union at e_coe_in_union,\n        cases e_coe_in_union with e_coe_in₂ e_coe_in_false,\n        { exact e_coe_in₂, },\n        { exfalso,\n          have e_in_R := \n            finset.property_of_mem_map_subtype _ e_coe_in_false,\n          have e_not_in_R := e.property,\n          rw finset.mem_sdiff at e_not_in_R,\n          exact e_not_in_R.right e_in_R, }, },\n      simp only [finset.mem_sdiff, simple_graph.mem_edge_finset,\n        simple_graph.complete_graph_eq_top, coe_coe, finset.mem_map,\n        function.embedding.coe_subtype, exists_prop, subtype.exists, \n        subtype.coe_mk, exists_and_distrib_right, exists_eq_right, \n        finset.mk_coe] at e_coe_in₂,\n      exact e_coe_in₂.right, },\n    { intro e_in₂,\n      have e_coe_in₂ := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in₂,\n      rw function.embedding.coe_subtype _ at e_coe_in₂,\n      have e_coe_in_union : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₂.fst ∪\n          finset.map (function.embedding.subtype _) c₂.snd,\n      { rw finset.mem_union,\n        left,\n        exact e_coe_in₂, },\n      rw ← h_union at e_coe_in_union,\n      have e_coe_in₁ : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₁.fst,\n      { rw finset.mem_union at e_coe_in_union,\n        cases e_coe_in_union with e_coe_in₁ e_coe_in_false,\n        { exact e_coe_in₁, },\n        { exfalso,\n          have e_in_R := \n            finset.property_of_mem_map_subtype _ e_coe_in_false,\n          have e_not_in_R := e.property,\n          rw finset.mem_sdiff at e_not_in_R,\n          exact e_not_in_R.right e_in_R,}, },\n      simp only [finset.mem_sdiff, simple_graph.mem_edge_finset,\n        simple_graph.complete_graph_eq_top, coe_coe, finset.mem_map,\n        function.embedding.coe_subtype, exists_prop, subtype.exists,\n        subtype.coe_mk, exists_and_distrib_right, exists_eq_right,\n        finset.mk_coe] at e_coe_in₁,\n      exact e_coe_in₁.right, }, },\n  { rw finset.ext_iff,\n    intro e,\n    split,\n    { intro e_in₁,\n      have e_coe_in₁ := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in₁, \n      rw function.embedding.coe_subtype at e_coe_in₁,\n      have e_coe_in_union : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₁.fst ∪\n          finset.map (function.embedding.subtype _) c₁.snd,\n      { rw finset.mem_union,\n        right,\n        exact e_coe_in₁, },\n      rw h_union at e_coe_in_union,\n      have e_coe_in₂ : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₂.snd,\n      { rw finset.mem_union at e_coe_in_union,\n        cases e_coe_in_union with e_coe_in_false e_coe_in₂,\n        { exfalso,\n          have e_not_in_R := \n            finset.property_of_mem_map_subtype _ e_coe_in_false,\n          rw finset.mem_sdiff at e_not_in_R,\n          have e_in_R := e.property,\n          exact e_not_in_R.right e_in_R, },\n        { exact e_coe_in₂, }, },\n      simp only [coe_coe, finset.mem_map, function.embedding.coe_subtype,\n        exists_prop, subtype.exists, subtype.coe_mk,\n        exists_and_distrib_right, exists_eq_right, finset.mk_coe] \n        at e_coe_in₂,\n      exact e_coe_in₂.right, },\n    { intro e_in₂,\n      have e_coe_in₂ := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in₂, \n      rw function.embedding.coe_subtype at e_coe_in₂,\n      have e_coe_in_union : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₂.fst ∪\n          finset.map (function.embedding.subtype _) c₂.snd,\n      { rw finset.mem_union,\n        right,\n        exact e_coe_in₂, },\n      rw ← h_union at e_coe_in_union,\n      have e_coe_in₁ : \n        ↑e ∈ finset.map (function.embedding.subtype _) c₁.snd,\n      { rw finset.mem_union at e_coe_in_union,\n        cases e_coe_in_union with e_coe_in_false e_coe_in₁,\n        { exfalso,\n          have e_not_in_R := \n            finset.property_of_mem_map_subtype _ e_coe_in_false,\n          rw finset.mem_sdiff at e_not_in_R,\n          have e_in_R := e.property,\n          exact e_not_in_R.right e_in_R, },\n        { exact e_coe_in₁, }, },\n      simp only [coe_coe, finset.mem_map, function.embedding.coe_subtype,\n        exists_prop, subtype.exists, subtype.coe_mk, \n        exists_and_distrib_right, exists_eq_right, finset.mk_coe] \n        at e_coe_in₁,\n      exact e_coe_in₁.right, }, },\nend\n\ndef A : Prop := \n∀ (e₁ : ↥((G.induced_subgraph R).edge_finset)) \n  (e₂ : ↥((G.induced_subgraph R).edge_finset)),\n( set.inclusion (G.induced_subgraph R).edge_finset_subset e₁ ∈ red_edges ∧\n  set.inclusion (G.induced_subgraph R).edge_finset_subset e₂ ∈ red_edges ) ∨\n( set.inclusion (G.induced_subgraph R).edge_finset_subset e₁ ∉ red_edges ∧ \n  set.inclusion (G.induced_subgraph R).edge_finset_subset e₂ ∉ red_edges )\n\ninstance A_decidable : decidable_pred (A G R) := \nbegin\n  unfold decidable_pred,\n  intro red_edges,\n  unfold A,\n  refine fintype.decidable_forall_fintype,\nend\n\ndef finset_univ_two_colouring : finset (finset ↥(G.edge_finset)) := \nfinset.univ\n\ndef two_colourings_sat_A_R : finset (finset ↥(G.edge_finset)) := \nfinset.filter (A G R) (finset_univ_two_colouring G)\n\ndef empty_univ_col_R : \nfinset (finset ↥(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) ×\n finset ↥((G.induced_subgraph R).edge_finset)) := \nfinset.product finset.univ {∅, finset.univ}\n\ntheorem all_red_colourings_sat_A_R : \ntwo_colourings_sat_A_R (complete_graph V) R = \nfinset.map \n  ⟨red_edges_by_R_coe (complete_graph V) R, red_edges_by_R_coe_inj _ _⟩\n  (empty_univ_col_R (complete_graph V) R) :=\nbegin\n  unfold two_colourings_sat_A_R,\n  unfold finset_univ_two_colouring,\n  unfold empty_univ_col_R,\n  unfold red_edges_by_R_coe,\n  change (coe : \n    {s // s ⊆ (complete_graph V).edge_finset} → \n      finset ↥((complete_graph V).edge_finset)) \n    with subset_subtype.finset_subtype.coe,\n  rw finset.ext_iff,\n  intro c,\n  simp only [finset.mem_filter, finset.mem_univ, true_and, finset.mem_map,\n    finset.mem_product, finset.mem_insert, finset.mem_singleton, \n    function.embedding.coe_fn_mk, exists_prop, prod.exists],\n  split,\n  { intro hA,\n    generalize h_cR : \n      simple_graph.induced_subgraph.edge_subtype_finset\n        (complete_graph V) R (finset.map (function.embedding.subtype _) c) \n      = cR,\n    generalize h_cRc : \n      simple_graph.induced_subgraph.edge_complement_subtype_finset\n        (complete_graph V) R (finset.map (function.embedding.subtype _) c)\n      = cRc,\n    use cRc,\n    use cR,\n    rw ← @finset.map_inj _ _ \n      (function.embedding.subtype (∈ (complete_graph V).edge_finset)) _ _,\n    rw subset_subtype.coe_type,\n    have h_union : \n      finset.map (function.embedding.subtype _) cRc ∪\n      finset.map (function.embedding.subtype _) cR =\n      finset.map (function.embedding.subtype _) c,\n    { rw ← h_cR,\n      rw ← h_cRc,\n      unfold simple_graph.induced_subgraph.edge_complement_subtype_finset,\n      unfold simple_graph.induced_subgraph.edge_subtype_finset,\n      rw finset.subtype_map,\n      rw finset.subtype_map,\n      simp_rw [finset.mem_sdiff],\n      rw finset.union_comm,\n      rw finset.filter_and,\n      rw finset.union_distrib_left,\n      rw finset.filter_union_filter_neg_eq \n        (∈ ((complete_graph V).induced_subgraph ↑R).edge_finset) \n          (finset.map (function.embedding.subtype _) c),\n      have h_eq_c : \n        finset.filter\n          (∈ (complete_graph V).edge_finset)\n          (finset.map (function.embedding.subtype _) c) = \n        (finset.map (function.embedding.subtype _) c),\n      { rw finset.filter_eq_self,\n        intro x,\n        intro x_in,\n        have := finset.property_of_mem_map_subtype _ x_in,\n        exact this, },\n      rw h_eq_c,\n      rw finset.union_comm,\n      exact finset.union_inter_cancel_left, },\n    cases finset.eq_empty_or_nonempty cR with cR_empty cR_nonempty,\n    { clear hA,\n      split,\n      { left,\n        exact cR_empty,},\n      { exact h_union, }, },\n    { split,\n      { clear h_union,\n        right,\n        unfold finset.nonempty at cR_nonempty,\n        cases cR_nonempty with e₁ e₁_in,\n        apply finset.ext,\n        intro e₂,\n        split,\n        { revert e₂,\n          exact cR.subset_univ, },\n        { intro e₂_in,\n          specialize hA e₁ e₂,\n          cases hA with h_red h_blue,\n          { rw ← h_cR,\n            unfold simple_graph.induced_subgraph.edge_subtype_finset,\n            simp only [simple_graph.mem_edge_finset,\n              simple_graph.complete_graph_eq_top, finset.mem_subtype,\n                finset.mem_map, function.embedding.coe_subtype,\n                exists_prop, subtype.exists, subtype.coe_mk,\n                exists_and_distrib_right, exists_eq_right],\n            have e₂_in_set : ↑e₂ ∈ (complete_graph V).edge_set,\n            { have e₂_in_finset := finset.mem_of_subset \n                ((complete_graph V).induced_subgraph R).edge_finset_subset\n                e₂.property,\n              unfold simple_graph.edge_finset at e₂_in_finset,\n              rw set.mem_to_finset at e₂_in_finset,\n              exact e₂_in_finset, },\n            use e₂_in_set,\n          exact h_red.right, },\n          { exfalso,\n            have e₁_not_in := h_blue.left,\n            rw ← h_cR at e₁_in,\n            unfold simple_graph.induced_subgraph.edge_subtype_finset \n              at e₁_in,\n            simp only [simple_graph.mem_edge_finset,\n              simple_graph.complete_graph_eq_top, finset.mem_subtype,\n              finset.mem_map, function.embedding.coe_subtype, exists_prop,\n              subtype.exists, subtype.coe_mk, exists_and_distrib_right,\n              exists_eq_right] at e₁_in,\n            cases e₁_in with _ e₁_in,\n            exact h_blue.left e₁_in, }, }, },\n        { exact h_union, }, }, },\n  { rintro ⟨cRc, cR, hcR, h_union⟩,\n    cases hcR with cR_empty cR_univ,\n    { intros e₁ e₂,\n      right,\n      rw ← h_union,\n      clear h_union,\n      rw cR_empty,\n      clear cR_empty,\n      simp only [finset.map_empty, finset.union_empty],\n      unfold subset_subtype.finset_subtype.coe,\n      split,\n      { by_contra,\n        simp only [finset.univ_eq_attach, finset.mem_map,\n          finset.mem_attach, function.embedding.coe_fn_mk,\n          exists_true_left] at h,\n        unfold set.inclusion at h,\n        rcases h with ⟨⟨a, a_in⟩, h_eq⟩,\n        rw subtype.mk_eq_mk at h_eq,\n        change a = e₁.val at h_eq,\n        rw h_eq at a_in,\n        have e_in := finset.property_of_mem_map_subtype cRc a_in,\n        rw finset.mem_sdiff at e_in,\n        exact e_in.right e₁.property, },\n      { by_contra,\n        simp only [finset.univ_eq_attach, finset.mem_map,\n          finset.mem_attach, function.embedding.coe_fn_mk,\n          exists_true_left] at h,\n        unfold set.inclusion at h,\n        rcases h with ⟨⟨a, a_in⟩, h_eq⟩,\n        rw subtype.mk_eq_mk at h_eq,\n        change a = e₂.val at h_eq,\n        rw h_eq at a_in,\n        have e_in := finset.property_of_mem_map_subtype cRc a_in,\n        rw finset.mem_sdiff at e_in,\n        exact e_in.right e₂.property, }, },\n    { intros e₁ e₂,\n      left,\n      rw ← h_union,\n      clear h_union,\n      rw cR_univ,\n      clear cR_univ,\n      unfold subset_subtype.finset_subtype.coe,\n      simp only [finset.univ_eq_attach, finset.mem_map, finset.mem_attach,\n        function.embedding.coe_fn_mk, exists_true_left],\n      split,\n      { use e₁,\n        { rw set.mem_def,\n          rw ← finset.mem_def,\n          rw finset.mem_union, \n          right,\n          change (function.embedding.subtype _) e₁ ∈ finset.map\n              (function.embedding.subtype _) finset.univ,\n          rw finset.mem_map' (function.embedding.subtype _),\n          exact finset.mem_univ e₁, },\n        refl, },\n      { use e₂,\n        { rw set.mem_def,\n          rw ← finset.mem_def,\n          rw finset.mem_union, \n          right,\n          change (function.embedding.subtype _) e₂ ∈ finset.map \n              (function.embedding.subtype _) finset.univ,\n          rw finset.mem_map' (function.embedding.subtype _),\n          exact finset.mem_univ e₂, },\n        refl, }, }, },\nend\n\ntheorem card_red_colourings_sat_A_R (hk : k ≥ 2) : \n(two_colourings_sat_A_R (complete_graph V) R).card = \n  2 ^ ((fintype.card V).choose 2 - k.choose 2 + 1) := \nbegin\n  rw all_red_colourings_sat_A_R,\n  unfold empty_univ_col_R,\n  rw finset.card_map,\n  rw finset.card_product,\n  rw finset.card_univ,\n  rw fintype.card_finset,\n  rw fintype.card_coe,\n  rw finset.card_sdiff \n    (((complete_graph V).induced_subgraph R).edge_finset_subset),\n  rw complete_graph.induced_subgraph.card_edge_finset,\n  change (↑R : set V) with (↑(↑R : finset V) : set V),\n  simp_rw finset.coe_sort_coe,\n  rw fintype.card_coe,\n  rw complete_graph.card_edge_finset,\n  rw finset.card_doubleton,\n  rw pow_succ',\n  rw card_R,\n  symmetry,\n  apply finset.nonempty.ne_empty,\n  rw finset.univ_nonempty_iff,\n  rw finset.nonempty_coe_sort,\n  unfold simple_graph.subgraph.edge_finset,\n  rw ← finset.coe_nonempty,\n  exact complete_graph.induced_subgraph_size.edge_finset_nonempty R hk,\nend\n\nvariable (k)\n\ndef finset_univ_prod_R_colouring : \nfinset (finset.powerset_len k (finset.univ : finset V) ×\n  finset ↥G.edge_finset) := finset.univ\n\ntheorem finset_univ_prod_R_colouring_eq_prod_univ : \nfinset_univ_prod_R_colouring G k = \n  finset.product finset.univ finset.univ :=\nbegin\n  unfold finset_univ_prod_R_colouring,\n  exact finset.univ_product_univ,\nend\n\ntheorem finset_univ_prod_R_colouring_eq_bUnion : \nfinset_univ_prod_R_colouring G k = finset.univ.bUnion \n  (λ R, finset.map ⟨prod.mk R, prod.mk.inj_left R⟩ finset.univ) :=\nbegin\n  simp_rw [finset.map_eq_image],\n  rw finset_univ_prod_R_colouring_eq_prod_univ,\n  exact finset.product_eq_bUnion finset.univ finset.univ,\nend\n\ndef finset_univ_prod_R_colouring_sat_A_R : \nfinset (finset.powerset_len k (finset.univ : finset V) ×\n  finset ↥G.edge_finset) :=\nfinset.filter (λ Rc, A G Rc.fst Rc.snd) (finset_univ_prod_R_colouring G k)\n\nlemma function.uncurry.comp_prod_mk_eq_self \n  {α : Type*} {β : Type*} {γ : Type*} (f : α → β → γ) (a : α) :\n(function.uncurry f) ∘ (prod.mk a) = f a := by unfold function.uncurry\n\ntheorem finset_univ_prod_R_colouring_sat_A_R_eq_bUnion_filter :\nfinset_univ_prod_R_colouring_sat_A_R G k = \n  finset.univ.bUnion (λ R, finset.map\n    ⟨prod.mk R, prod.mk.inj_left R⟩\n    (two_colourings_sat_A_R G R)) :=\nbegin\n  unfold finset_univ_prod_R_colouring_sat_A_R,\n  rw finset_univ_prod_R_colouring_eq_bUnion,\n  rw finset.filter_bUnion,\n  apply congr_arg,\n  apply funext,\n  intro R,\n  unfold two_colourings_sat_A_R,\n  rw finset.map_filter,\n  apply congr_arg,\n  rw function.embedding.coe_fn_mk,\n  change (λ Rc : \n      ↥(finset.powerset_len k finset.univ) × finset ↥(G.edge_finset),\n    A G Rc.fst Rc.snd) with function.uncurry (A G),\n  simp_rw [function.uncurry.comp_prod_mk_eq_self],\n  unfold finset_univ_two_colouring,\nend\n\ntheorem card_finset_univ_prod_R_colouring_sat_A_R {k} (hk : k ≥ 2) :\n(finset_univ_prod_R_colouring_sat_A_R (complete_graph V) k).card = \n  (fintype.card V).choose k * 2 ^ ((fintype.card V).choose 2 -\n    k.choose 2 + 1) :=\nbegin\n  rw finset_univ_prod_R_colouring_sat_A_R_eq_bUnion_filter,\n  rw finset.card_bUnion,\n  rw finset.sum_const_nat,\n  swap 3,\n  { exact 2 ^ ((fintype.card V).choose 2 - k.choose 2 + 1) },\n  { rw finset.card_univ,\n    rw fintype.card_coe,\n    rw finset.card_powerset_len,\n    rw finset.card_univ, },\n  { intros R R_in,\n    rw finset.card_map,\n    rw card_red_colourings_sat_A_R,\n    exact hk, },\n  intros R R_in R' R'_in R_ne_R',\n  rw finset.disjoint_iff_ne,\n  rintros ⟨R₁, c⟩ Rc_in ⟨R'₁, c'⟩ R'c'_in,\n  simp only [finset.mem_map, function.embedding.coe_fn_mk,\n    prod.mk.inj_iff, exists_prop, exists_eq_right_right] at Rc_in R'c'_in,\n  rw ← Rc_in.right,\n  rw ← R'c'_in.right,\n  rw ne.def,\n  rw prod.mk.inj_iff,\n  exact not_and_of_not_left _ R_ne_R',\nend\n\ndef finset_univ_colouring_sat_A : finset (finset ↥G.edge_finset) := \nfinset.image prod.snd (@finset_univ_prod_R_colouring_sat_A_R _ _ _ G _ k)\n\ntheorem finset_univ_prod_R_colouring_sat_A_R_ssubset_univ {k} \n( h : ((fintype.card V).choose k) * 2 ^ \n    ((fintype.card V).choose 2 - k.choose 2 + 1) <\n    2 ^ (fintype.card V).choose 2) (hk : k ≥ 2) : \nfinset_univ_colouring_sat_A (complete_graph V) k ⊂ \n  (finset_univ_two_colouring (complete_graph V)) :=\nbegin\n  unfold finset_univ_two_colouring,\n  rw finset.ssubset_iff_subset_ne,\n  split,\n  { exact finset.subset_univ _, },\n  { rw ← finset.card_lt_iff_ne_univ,\n    calc (finset_univ_colouring_sat_A (complete_graph V) k).card ≤\n      (finset_univ_prod_R_colouring_sat_A_R (complete_graph V) k).card :\n        finset.card_image_le\n      ... = (fintype.card V).choose k * 2 ^ \n            ((fintype.card V).choose 2 - k.choose 2 + 1) : \n        card_finset_univ_prod_R_colouring_sat_A_R hk\n      ... < 2 ^ (fintype.card V).choose 2 : h\n      ... = finset.univ.card : \n        begin \n          rw finset.card_univ, \n          rw fintype.card_finset, \n          rw fintype.card_coe, \n          rw complete_graph.card_edge_finset\n        end, },\nend\n\ntheorem ramsey_lower_bound {k} \n( h : ((fintype.card V).choose k) * 2 ^\n    ((fintype.card V).choose 2 - k.choose 2 + 1) < \n    2 ^ (fintype.card V).choose 2) (hk : k ≥ 2) :\n∃ c : finset ↥((complete_graph V).edge_finset),\n  ¬∃ R' : ↥(finset.powerset_len k (finset.univ : finset V)),\n    A (complete_graph V) R' c :=\nbegin\n  rcases \n    finset.exists_of_ssubset \n      (finset_univ_prod_R_colouring_sat_A_R_ssubset_univ h hk) \n    with ⟨c, c_in, c_not_in⟩,\n  use c,\n  convert_to ¬∃ R', \n    (R', c) ∈ (finset_univ_prod_R_colouring_sat_A_R (complete_graph V) k),\n  { unfold finset_univ_prod_R_colouring_sat_A_R,\n    simp_rw finset.mem_filter,\n    unfold finset_univ_prod_R_colouring,\n    simp_rw [eq_true_intro (finset.mem_univ _)],\n    simp_rw [true_and], },\n  unfold finset_univ_colouring_sat_A at c_not_in,\n  rw finset.mem_image at c_not_in,\n  rw not_exists at c_not_in,\n  rw not_exists,\n  intro R,\n  specialize c_not_in (R, c),\n  rw not_exists at c_not_in,\n  rw eq_self_iff_true at c_not_in,\n  rw not_true at c_not_in,\n  rw imp_false at c_not_in,\n  exact c_not_in,\nend", "meta": {"author": "1034461", "repo": "4th-Year-Project", "sha": "02026eba65e6cf9ec44785175eab9403564ea346", "save_path": "github-repos/lean/1034461-4th-Year-Project", "path": "github-repos/lean/1034461-4th-Year-Project/4th-Year-Project-02026eba65e6cf9ec44785175eab9403564ea346/src/ramsey_numbers.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4579367257191872}}
{"text": "section\n  variables (x y z : ℕ)\n  variables (h₁ : x = y) (h₂ : y = z)\n\n  include h₁ h₂\n  theorem foo : x = z :=\n  begin\n    rw [h₁, h₂]\n  end\n  omit h₁ h₂\n\n  theorem bar : x = z :=\n    eq.trans h₁ h₂\n\n  theorem baz : x = x := rfl\n\n  #check @foo\n  #check @bar\n  #check baz\nend\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch6/ex0202.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.45793671978692585}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n\nGodel numbering for partial recursive functions.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.computability.partrec\nimport Mathlib.PostPort\n\nuniverses l u_1 u_2 \n\nnamespace Mathlib\n\nnamespace nat.partrec\n\n\ntheorem rfind' {f : ℕ →. ℕ} (hf : partrec f) : partrec\n  (unpaired\n    fun (a m : ℕ) =>\n      roption.map (fun (_x : ℕ) => _x + m)\n        (rfind fun (n : ℕ) => (fun (m : ℕ) => to_bool (m = 0)) <$> f (mkpair a (n + m)))) := sorry\n\ninductive code \nwhere\n| zero : code\n| succ : code\n| left : code\n| right : code\n| pair : code → code → code\n| comp : code → code → code\n| prec : code → code → code\n| rfind' : code → code\n\nend nat.partrec\n\n\nnamespace nat.partrec.code\n\n\nprotected instance inhabited : Inhabited code :=\n  { default := zero }\n\nprotected def const : ℕ → code :=\n  sorry\n\ntheorem const_inj {n₁ : ℕ} {n₂ : ℕ} : code.const n₁ = code.const n₂ → n₁ = n₂ := sorry\n\nprotected def id : code :=\n  pair left right\n\ndef curry (c : code) (n : ℕ) : code :=\n  comp c (pair (code.const n) code.id)\n\ndef encode_code : code → ℕ :=\n  sorry\n\ndef of_nat_code : ℕ → code :=\n  sorry\n\nprotected instance denumerable : denumerable code :=\n  denumerable.mk' (equiv.mk encode_code of_nat_code sorry encode_of_nat_code)\n\ntheorem encode_code_eq : encodable.encode = encode_code :=\n  rfl\n\ntheorem of_nat_code_eq : denumerable.of_nat code = of_nat_code :=\n  rfl\n\ntheorem encode_lt_pair (cf : code) (cg : code) : encodable.encode cf < encodable.encode (pair cf cg) ∧ encodable.encode cg < encodable.encode (pair cf cg) := sorry\n\ntheorem encode_lt_comp (cf : code) (cg : code) : encodable.encode cf < encodable.encode (comp cf cg) ∧ encodable.encode cg < encodable.encode (comp cf cg) := sorry\n\ntheorem encode_lt_prec (cf : code) (cg : code) : encodable.encode cf < encodable.encode (prec cf cg) ∧ encodable.encode cg < encodable.encode (prec cf cg) := sorry\n\ntheorem encode_lt_rfind' (cf : code) : encodable.encode cf < encodable.encode (rfind' cf) := sorry\n\ntheorem pair_prim : primrec₂ pair := sorry\n\ntheorem comp_prim : primrec₂ comp := sorry\n\ntheorem prec_prim : primrec₂ prec := sorry\n\ntheorem rfind_prim : primrec rfind' := sorry\n\ntheorem rec_prim' {α : Type u_1} {σ : Type u_2} [primcodable α] [primcodable σ] {c : α → code} (hc : primrec c) {z : α → σ} (hz : primrec z) {s : α → σ} (hs : primrec s) {l : α → σ} (hl : primrec l) {r : α → σ} (hr : primrec r) {pr : α → code × code × σ × σ → σ} (hpr : primrec₂ pr) {co : α → code × code × σ × σ → σ} (hco : primrec₂ co) {pc : α → code × code × σ × σ → σ} (hpc : primrec₂ pc) {rf : α → code × σ → σ} (hrf : primrec₂ rf) : let PR : α → code → code → σ → σ → σ := fun (a : α) (cf cg : code) (hf hg : σ) => pr a (cf, cg, hf, hg);\nlet CO : α → code → code → σ → σ → σ := fun (a : α) (cf cg : code) (hf hg : σ) => co a (cf, cg, hf, hg);\nlet PC : α → code → code → σ → σ → σ := fun (a : α) (cf cg : code) (hf hg : σ) => pc a (cf, cg, hf, hg);\nlet RF : α → code → σ → σ := fun (a : α) (cf : code) (hf : σ) => rf a (cf, hf);\nlet F : α → code → σ := fun (a : α) (c : code) => code.rec_on c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a);\nprimrec fun (a : α) => F a (c a) := sorry\n\ntheorem rec_prim {α : Type u_1} {σ : Type u_2} [primcodable α] [primcodable σ] {c : α → code} (hc : primrec c) {z : α → σ} (hz : primrec z) {s : α → σ} (hs : primrec s) {l : α → σ} (hl : primrec l) {r : α → σ} (hr : primrec r) {pr : α → code → code → σ → σ → σ} (hpr : primrec\n  fun (a : α × code × code × σ × σ) =>\n    pr (prod.fst a) (prod.fst (prod.snd a)) (prod.fst (prod.snd (prod.snd a)))\n      (prod.fst (prod.snd (prod.snd (prod.snd a)))) (prod.snd (prod.snd (prod.snd (prod.snd a))))) {co : α → code → code → σ → σ → σ} (hco : primrec\n  fun (a : α × code × code × σ × σ) =>\n    co (prod.fst a) (prod.fst (prod.snd a)) (prod.fst (prod.snd (prod.snd a)))\n      (prod.fst (prod.snd (prod.snd (prod.snd a)))) (prod.snd (prod.snd (prod.snd (prod.snd a))))) {pc : α → code → code → σ → σ → σ} (hpc : primrec\n  fun (a : α × code × code × σ × σ) =>\n    pc (prod.fst a) (prod.fst (prod.snd a)) (prod.fst (prod.snd (prod.snd a)))\n      (prod.fst (prod.snd (prod.snd (prod.snd a)))) (prod.snd (prod.snd (prod.snd (prod.snd a))))) {rf : α → code → σ → σ} (hrf : primrec fun (a : α × code × σ) => rf (prod.fst a) (prod.fst (prod.snd a)) (prod.snd (prod.snd a))) : let F : α → code → σ := fun (a : α) (c : code) => code.rec_on c (z a) (s a) (l a) (r a) (pr a) (co a) (pc a) (rf a);\nprimrec fun (a : α) => F a (c a) := sorry\n\n/- TODO(Mario): less copy-paste from previous proof -/\n\ntheorem rec_computable {α : Type u_1} {σ : Type u_2} [primcodable α] [primcodable σ] {c : α → code} (hc : computable c) {z : α → σ} (hz : computable z) {s : α → σ} (hs : computable s) {l : α → σ} (hl : computable l) {r : α → σ} (hr : computable r) {pr : α → code × code × σ × σ → σ} (hpr : computable₂ pr) {co : α → code × code × σ × σ → σ} (hco : computable₂ co) {pc : α → code × code × σ × σ → σ} (hpc : computable₂ pc) {rf : α → code × σ → σ} (hrf : computable₂ rf) : let PR : α → code → code → σ → σ → σ := fun (a : α) (cf cg : code) (hf hg : σ) => pr a (cf, cg, hf, hg);\nlet CO : α → code → code → σ → σ → σ := fun (a : α) (cf cg : code) (hf hg : σ) => co a (cf, cg, hf, hg);\nlet PC : α → code → code → σ → σ → σ := fun (a : α) (cf cg : code) (hf hg : σ) => pc a (cf, cg, hf, hg);\nlet RF : α → code → σ → σ := fun (a : α) (cf : code) (hf : σ) => rf a (cf, hf);\nlet F : α → code → σ := fun (a : α) (c : code) => code.rec_on c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a);\ncomputable fun (a : α) => F a (c a) := sorry\n\ndef eval : code → ℕ →. ℕ :=\n  sorry\n\nprotected instance has_mem : has_mem (ℕ →. ℕ) code :=\n  has_mem.mk fun (f : ℕ →. ℕ) (c : code) => eval c = f\n\n@[simp] theorem eval_const (n : ℕ) (m : ℕ) : eval (code.const n) m = roption.some n := sorry\n\n@[simp] theorem eval_id (n : ℕ) : eval code.id n = roption.some n := sorry\n\n@[simp] theorem eval_curry (c : code) (n : ℕ) (x : ℕ) : eval (curry c n) x = eval c (mkpair n x) := sorry\n\ntheorem const_prim : primrec code.const := sorry\n\ntheorem curry_prim : primrec₂ curry :=\n  primrec₂.comp comp_prim primrec.fst\n    (primrec₂.comp pair_prim (primrec.comp const_prim primrec.snd) (primrec.const code.id))\n\ntheorem curry_inj {c₁ : code} {c₂ : code} {n₁ : ℕ} {n₂ : ℕ} (h : curry c₁ n₁ = curry c₂ n₂) : c₁ = c₂ ∧ n₁ = n₂ := sorry\n\ntheorem smn : ∃ (f : code → ℕ → code), computable₂ f ∧ ∀ (c : code) (n x : ℕ), eval (f c n) x = eval c (mkpair n x) :=\n  Exists.intro curry { left := primrec₂.to_comp curry_prim, right := eval_curry }\n\ntheorem exists_code {f : ℕ →. ℕ} : partrec f ↔ ∃ (c : code), eval c = f := sorry\n\ndef evaln (k : ℕ) : code → ℕ → Option ℕ :=\n  sorry\n\ntheorem evaln_bound {k : ℕ} {c : code} {n : ℕ} {x : ℕ} : x ∈ evaln k c n → n < k := sorry\n\ntheorem evaln_mono {k₁ : ℕ} {k₂ : ℕ} {c : code} {n : ℕ} {x : ℕ} : k₁ ≤ k₂ → x ∈ evaln k₁ c n → x ∈ evaln k₂ c n := sorry\n\ntheorem evaln_sound {k : ℕ} {c : code} {n : ℕ} {x : ℕ} : x ∈ evaln k c n → x ∈ eval c n := sorry\n\ntheorem evaln_complete {c : code} {n : ℕ} {x : ℕ} : x ∈ eval c n ↔ ∃ (k : ℕ), x ∈ evaln k c n := sorry\n\ntheorem evaln_prim : primrec fun (a : (ℕ × code) × ℕ) => evaln (prod.fst (prod.fst a)) (prod.snd (prod.fst a)) (prod.snd a) := sorry\n\ntheorem eval_eq_rfind_opt (c : code) (n : ℕ) : eval c n = rfind_opt fun (k : ℕ) => evaln k c n :=\n  roption.ext\n    fun (x : ℕ) => iff.trans evaln_complete (iff.symm (rfind_opt_mono fun (a m n_1 : ℕ) (hl : m ≤ n_1) => evaln_mono hl))\n\ntheorem eval_part : partrec₂ eval := sorry\n\ntheorem fixed_point {f : code → code} (hf : computable f) : ∃ (c : code), eval (f c) = eval c := sorry\n\ntheorem fixed_point₂ {f : code → ℕ →. ℕ} (hf : partrec₂ f) : ∃ (c : code), eval c = f c := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/computability/partrec_code.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.45793671978692585}}
{"text": "import main_induction_step\nimport for_mathlib.base_change\nimport for_mathlib.basis\nimport for_mathlib.duality\n\n.\n\nopen_locale tensor_product\nopen_locale classical\n\nvariables (K F : Type*) [field K] [field F]\n\nopen module\n\nabbreviation mul_base_change := F ⊗[ℤ] additive Kˣ\n\nvariables {K F}\n\ndef units.as (x : Kˣ) : mul_base_change K F :=\n1 ⊗ₜ additive.of_mul x\n\nnamespace units\n\n@[simp]\nlemma as_mul (u v : Kˣ) : ((u * v).as : mul_base_change K F) = u.as + v.as := \ntensor_product.tmul_add _ _ _\n\n@[simp]\nlemma as_one : ((1 : Kˣ).as : mul_base_change K F) = 0 := \ntensor_product.tmul_zero _ _\n\n@[simp]\nlemma as_inv (u : Kˣ) : (u⁻¹.as : mul_base_change K F) = - u.as := \ntensor_product.tmul_neg _ _\n\nlemma as_div (u v : Kˣ) : ((u / v).as : mul_base_change K F) = u.as - v.as := \ntensor_product.tmul_sub _ _ _\n\nend units\n\nnamespace submodule\n\ndef restrict (T : submodule F (mul_base_change K F)) : \n  subgroup Kˣ :=\n{ carrier := { u | u.as ∈ T },\n  mul_mem' := λ u v hu hv, begin\n    dsimp at hu hv ⊢,\n    rw units.as_mul,\n    apply T.add_mem hu hv,\n  end,\n  one_mem' := begin\n    dsimp, rw units.as_one, exact T.zero_mem,\n  end,\n  inv_mem' := begin\n    intros u hu,\n    dsimp at hu ⊢,\n    rw units.as_inv,\n    apply T.neg_mem hu,\n  end }\n\n--instance : topological_space (dual F (mul_base_change K F)) := \n--module.dual.pointwise_convergence_topology\n\nstructure acl (H : submodule F (dual F (mul_base_change K F))) : Prop := \n(closed : H.closed)\n(alternating : \n  ∀ (u v : Kˣ) (h : (u : K) + v = 1) (f g : dual F (mul_base_change K F))\n    (hf : f ∈ H) (hg : g ∈ H), f u.as * g v.as = f v.as * g u.as) \n(neg_one : ∀ (f : dual F (mul_base_change K F)) (hf : f ∈ H), f ((-1 : Kˣ).as) = 0)\n\nnoncomputable theory\n\nlemma neg_one_mem_of_acl (H : submodule F (dual F (mul_base_change K F))) (h : H.acl) :\n  (-1 : Kˣ).as ∈ H.dual_annihilator_comap :=\nbegin\n  rw mem_dual_annihilator_comap_iff,\n  intros f hf,\n  apply h.neg_one _ hf,\nend\n\nlemma dependent_of_acl (H : submodule F (dual F (mul_base_change K F))) (h : H.acl)\n  (u v : Kˣ) (huv : (u : K) + v = 1) : \n  ¬ linear_independent F \n    ![H.dual_annihilator_comap.mkq u.as, \n      H.dual_annihilator_comap.mkq v.as] :=\nbegin\n  --let T := H.dual_annihilator_comap\n  let e := ![(H.dual_annihilator_comap.mkq) u.as, \n    (H.dual_annihilator_comap.mkq) v.as],\n  let E := equiv_to_dual_mod_of_is_closed H h.1,\n  intro c,\n  let β := basis.sum_extend c,\n  let f : dual F _ := β.coord (sum.inl 0),\n  let g : dual F _ := β.coord (sum.inl 1),\n  let f' := E.symm f,\n  let g' := E.symm g,\n  have HH := h.2 u v huv f' g' f'.2 g'.2,\n  dsimp only [f',g', E] at HH,\n  simp only [equiv_to_dual_mod_of_is_closed_symm_apply_apply H h.1] at HH,\n  have he0 : e 0 = (H.dual_annihilator_comap.mkq u.as) := rfl, \n  have he1 : e 1 = (H.dual_annihilator_comap.mkq v.as) := rfl,\n  simp only [← he0, ← he1] at HH,\n  dsimp only [e,f,g,β] at HH,\n  simp only [\n      ← basis.sum_extend_extends _ c 0, \n      ← basis.sum_extend_extends _ c 1] at HH, \n  dsimp at HH,\n  simp only [basis.repr_self, finsupp.single_apply] at HH,\n  simp_rw [if_pos rfl] at HH,\n  rw [if_neg, if_neg] at HH,\n  { apply (one_ne_zero : (1 : F) ≠ 0),\n    simpa using HH },\n  all_goals { norm_num }\nend\n\nend submodule\n", "meta": {"author": "adamtopaz", "repo": "lean-acl-pairs", "sha": "6ac31d86ca2739b6c18d3f05b7007e720f66299f", "save_path": "github-repos/lean/adamtopaz-lean-acl-pairs", "path": "github-repos/lean/adamtopaz-lean-acl-pairs/lean-acl-pairs-6ac31d86ca2739b6c18d3f05b7007e720f66299f/src/cl.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186787341014, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4579025250114279}}
{"text": "import SciLean.Data.Quotient.GradedSetoid\n\nnamespace SciLean\n\ndef GradedQuotient (α : Type u) {Lvl : Type v} [BoundedLattice Lvl] [GradedSetoid α Lvl] (maxLvl : Lvl := ⊤) \n  := Quotient (instSetoidGradedSetoidRepr α maxLvl)\n\n\nnamespace GradedQuotient\n\n\n  variable {α : Type u} {Lvl : Type v} [BoundedLattice Lvl] [inst : GradedSetoid α Lvl] [∀ l l' : Lvl, Decidable (l ≤ l')]\n\n  notation \" ⟦ \" lvl \" | \" x \" ⟧ \" => ⟦GradedSetoid.reduceToLvl lvl x⟧\n\n  noncomputable\n  def repr (a : GradedQuotient α maxLvl) : α := (Quotient.repr a).1\n\n  @[simp high]\n  theorem repr_quotient (a : GradedQuotient α maxLvl) [GradedSetoid.Reduce α maxLvl]\n    : ⟦maxLvl| a.repr⟧ = a\n    := sorry_proof\n\n  def ungraded (a : GradedQuotient α maxLvl) := a.liftOn (λ a => ⟦a.1⟧) sorry_proof\n\n  @[simp high]\n  theorem repr_ungraded (a : GradedQuotient α maxLvl) \n    : ⟦a.repr⟧ = a.ungraded\n    := sorry_proof\n\n  noncomputable\n  def grepr (a : GradedQuotient α maxLvl) : GradedSetoid.Repr α maxLvl := Quotient.repr a\n\n  @[simp high]\n  theorem grepr_quotient (a : GradedQuotient α maxLvl)\n    : ⟦a.grepr⟧ = a\n    := sorry_proof\n\n  noncomputable\n  def lvl (a : GradedQuotient α maxLvl) : Lvl := (Quotient.repr a).2\n\n  def reduce (lvl : Lvl) [GradedSetoid.Reduce α (lvl ⊓ maxLvl)] (a : GradedQuotient α maxLvl) : GradedQuotient α maxLvl \n    := ⟦a.grepr.reduce lvl⟧ rewrite_by simp\n\n  /-- Reduction on quotient does nothing, it only changes the internal representation -/\n  theorem reduce_identity (a : GradedQuotient α maxLvl) (lvl : Lvl) [GradedSetoid.Reduce α (lvl ⊓ maxLvl)]\n    : a.reduce lvl = a := sorry_proof\n\n  def normalize [inst : GradedSetoid.Reduce α ⊥] (a : GradedQuotient α maxLvl) : GradedQuotient α maxLvl :=\n    have h :  ⊥ = (⊥ ⊓ maxLvl : Lvl) := sorry_proof\n    have : GradedSetoid.Reduce α (⊥ ⊓ maxLvl) := h ▸ inst\n    a.reduce ⊥ \n\n  def nrepr [inst : GradedSetoid.Reduce α ⊥] (a : GradedQuotient α maxLvl) : α := \n    a.liftOn (λ a => a.normalize.1) sorry_proof\n\n  @[simp]\n  theorem nrepr_quotient_mk [inst : GradedSetoid.Reduce α ⊥] (a : GradedQuotient α maxLvl)\n    : ⟦a.nrepr⟧ = a.ungraded\n  := sorry_proof\n\n  @[simp]\n  theorem nrepr_graded_quotient_mk [GradedSetoid.Reduce α ⊥] [GradedSetoid.Reduce α maxLvl] (a : GradedQuotient α maxLvl)\n    : ⟦maxLvl| a.nrepr⟧ = a\n  := sorry_proof\n\n  variable {β : Type w} [GradedSetoid β Lvl]\n\n  @[simp high]\n  theorem lift_graded_morphism   \n    {Lvl : Type u'} [BoundedLattice Lvl] {lvl : Lvl}\n    {α : Type u} [GradedSetoid α Lvl] [GradedSetoid.Reduce α lvl]\n    {β : Type v} [GradedSetoid β Lvl] [GradedSetoid.Reduce β lvl]\n    (f : α → β) [GradedSetoid.Morphism f] \n    (x : α)\n    : ⟦lvl| f x⟧ = Quotient.lift (λ (a : GradedSetoid.Repr α lvl) => ⟦GradedSetoid.Repr.mk (f a.1) a.2 sorry_proof sorry_proof⟧) sorry_proof ⟦lvl| x⟧\n    := sorry_proof\n\n  @[simp]\n  theorem lift_graded_morphism₂  \n    {Lvl : Type u'} {lvl : Lvl} [BoundedLattice Lvl] \n    {α : Type u} [GradedSetoid α Lvl] [GradedSetoid.Reduce α lvl]\n    {β : Type v} [GradedSetoid β Lvl] [GradedSetoid.Reduce β lvl]\n    {γ : Type v} [GradedSetoid γ Lvl] [GradedSetoid.Reduce γ lvl]\n    (f : α → β → γ) [GradedSetoid.Morphism₂ f] \n    (x : α) (y : β)\n    : ⟦lvl| f x y⟧ = Quotient.lift₂ (λ (x : GradedSetoid.Repr α lvl) (y : GradedSetoid.Repr β lvl) => ⟦GradedSetoid.Repr.mk (f x.1 y.1) x.2 sorry_proof x.4⟧) sorry_proof ⟦lvl| x⟧ ⟦lvl| y⟧\n    := sorry_proof\n  \nend GradedQuotient\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Data/Quotient/GradedQuotient.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186768138228, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4579025139952042}}
{"text": "/-\nCopyright (c) 2021 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou, Adam Topaz, Johan Commelin\n-/\n\nimport algebra.homology.additive\nimport algebraic_topology.Moore_complex\nimport data.fintype.card\n\n/-!\n\n# The alternating face map complex of a simplicial object in a preadditive category\n\nWe construct the alternating face map complex, as a\nfunctor `alternating_face_map_complex : simplicial_object C ⥤ chain_complex C ℕ`\nfor any preadditive category `C`. For any simplicial object `X` in `C`,\nthis is the homological complex `... → X_2 → X_1 → X_0`\nwhere the differentials are alternating sums of faces.\n\nWe also construct the natural transformation\n`inclusion_of_Moore_complex : normalized_Moore_complex A ⟶ alternating_face_map_complex A`\nwhen `A` is an abelian category.\n\n## References\n* https://stacks.math.columbia.edu/tag/0194\n* https://ncatlab.org/nlab/show/Moore+complex\n\n-/\n\nopen category_theory category_theory.limits category_theory.subobject\nopen category_theory.preadditive category_theory.category\nopen opposite\n\nopen_locale big_operators\nopen_locale simplicial\n\nnoncomputable theory\n\nnamespace algebraic_topology\n\nnamespace alternating_face_map_complex\n\n/-!\n## Construction of the alternating face map complex\n-/\n\nvariables {C : Type*} [category C] [preadditive C]\nvariables (X : simplicial_object C)\nvariables (Y : simplicial_object C)\n\n/-- The differential on the alternating face map complex is the alternate\nsum of the face maps -/\n@[simp]\ndef obj_d (n : ℕ) : X _[n+1] ⟶ X _[n] :=\n∑ (i : fin (n+2)), (-1 : ℤ)^(i : ℕ) • X.δ i\n\n/--\n## The chain complex relation `d ≫ d`\n-/\nlemma d_squared (n : ℕ) : obj_d X (n+1) ≫ obj_d X n = 0 :=\nbegin\n  /- we start by expanding d ≫ d as a double sum -/\n  dsimp,\n  rw comp_sum,\n  let d_l := λ (j : fin (n+3)), (-1 : ℤ)^(j : ℕ) • X.δ j,\n  let d_r := λ (i : fin (n+2)), (-1 : ℤ)^(i : ℕ) • X.δ i,\n  rw [show (λ i , (∑ j : fin (n+3), d_l j) ≫ d_r i) =\n    (λ i, ∑ j : fin (n+3), (d_l j ≫ d_r i)), by { ext i, rw sum_comp, }],\n  rw ← finset.sum_product',\n  /- then, we decompose the index set P into a subet S and its complement Sᶜ -/\n  let P := fin (n+2) × fin (n+3),\n  let S := finset.univ.filter (λ (ij : P), (ij.2 : ℕ) ≤ (ij.1 : ℕ)),\n  let term := λ (ij : P), d_l ij.2 ≫ d_r ij.1,\n  erw [show ∑ (ij : P), term ij =\n    (∑ ij in S, term ij) + (∑ ij in Sᶜ, term ij), by rw finset.sum_add_sum_compl],\n  rw [← eq_neg_iff_add_eq_zero, ← finset.sum_neg_distrib],\n  /- we are reduced to showing that two sums are equal, and this is obtained\n  by constructing a bijection φ : S -> Sᶜ, which maps (i,j) to (j,i+1),\n  and by comparing the terms -/\n  let φ : Π (ij : P), ij ∈ S → P := λ ij hij,\n    (fin.cast_lt ij.2\n      (lt_of_le_of_lt (finset.mem_filter.mp hij).right (fin.is_lt ij.1)), ij.1.succ),\n  apply finset.sum_bij φ,\n  { -- φ(S) is contained in Sᶜ\n    intros ij hij,\n    simp only [finset.mem_univ, finset.compl_filter, finset.mem_filter, true_and,\n      fin.coe_succ, fin.coe_cast_lt] at hij ⊢,\n    linarith, },\n  { /- identification of corresponding terms in both sums -/\n    rintro ⟨i, j⟩ hij,\n    simp only [term, d_l, d_r, φ, comp_zsmul, zsmul_comp, ← neg_smul, ← mul_smul,\n      pow_add, neg_mul, mul_one, fin.coe_cast_lt,\n      fin.coe_succ, pow_one, mul_neg, neg_neg],\n    let jj : fin (n+2) := (φ (i,j) hij).1,\n    have ineq : jj ≤ i, { rw ← fin.coe_fin_le, simpa using hij, },\n    rw [category_theory.simplicial_object.δ_comp_δ X ineq, fin.cast_succ_cast_lt, mul_comm] },\n  { -- φ : S → Sᶜ is injective\n    rintro ⟨i, j⟩ ⟨i', j'⟩ hij hij' h,\n    rw [prod.mk.inj_iff],\n    refine ⟨by simpa using congr_arg prod.snd h, _⟩,\n    have h1 := congr_arg fin.cast_succ (congr_arg prod.fst h),\n    simpa [fin.cast_succ_cast_lt] using h1 },\n  { -- φ : S → Sᶜ is surjective\n    rintro ⟨i', j'⟩ hij',\n    simp only [true_and, finset.mem_univ, finset.compl_filter, not_le,\n      finset.mem_filter] at hij',\n    refine ⟨(j'.pred _, fin.cast_succ i'), _, _⟩,\n    { intro H,\n      simpa only [H, nat.not_lt_zero, fin.coe_zero] using hij' },\n    { simpa only [true_and, finset.mem_univ, fin.coe_cast_succ, fin.coe_pred,\n        finset.mem_filter] using nat.le_pred_of_lt hij', },\n    { simp only [prod.mk.inj_iff, fin.succ_pred, fin.cast_lt_cast_succ],\n      split; refl }, },\nend\n\n/-!\n## Construction of the alternating face map complex functor\n-/\n\n/-- The alternating face map complex, on objects -/\ndef obj : chain_complex C ℕ := chain_complex.of (λ n, X _[n]) (obj_d X) (d_squared X)\n\nvariables {X} {Y}\n\n/-- The alternating face map complex, on morphisms -/\n@[simp]\ndef map (f : X ⟶ Y) : obj X ⟶ obj Y :=\nchain_complex.of_hom _ _ _ _ _ _\n  (λ n, f.app (op [n]))\n  (λ n,\n    begin\n      dsimp,\n      rw [comp_sum, sum_comp],\n      apply finset.sum_congr rfl (λ x h, _),\n      rw [comp_zsmul, zsmul_comp],\n      apply congr_arg,\n      erw f.naturality,\n      refl,\n    end)\n\nend alternating_face_map_complex\n\nvariables (C : Type*) [category C] [preadditive C]\n\n/-- The alternating face map complex, as a functor -/\n@[simps]\ndef alternating_face_map_complex : simplicial_object C ⥤ chain_complex C ℕ :=\n{ obj := alternating_face_map_complex.obj,\n  map := λ X Y f, alternating_face_map_complex.map f }\n\nvariables {C}\n\nlemma map_alternating_face_map_complex {D : Type*} [category D] [preadditive D]\n  (F : C ⥤ D) [F.additive] :\n  alternating_face_map_complex C ⋙ F.map_homological_complex _ =\n  (simplicial_object.whiskering C D).obj F ⋙ alternating_face_map_complex D :=\nbegin\n  apply category_theory.functor.ext,\n  { intros X Y f,\n    ext n,\n    simp only [functor.comp_map, alternating_face_map_complex.map,\n      alternating_face_map_complex_map, functor.map_homological_complex_map_f,\n      chain_complex.of_hom_f, simplicial_object.whiskering_obj_map_app,\n      homological_complex.comp_f, homological_complex.eq_to_hom_f,\n      eq_to_hom_refl, comp_id, id_comp], },\n  { intro X,\n    erw chain_complex.map_chain_complex_of,\n    congr,\n    ext n,\n    simp only [alternating_face_map_complex.obj_d, functor.map_sum],\n    congr,\n    ext,\n    apply functor.map_zsmul, },\nend\n\n/-!\n## Construction of the natural inclusion of the normalized Moore complex\n-/\n\nvariables {A : Type*} [category A] [abelian A]\n\n/-- The inclusion map of the Moore complex in the alternating face map complex -/\ndef inclusion_of_Moore_complex_map (X : simplicial_object A) :\n  (normalized_Moore_complex A).obj X ⟶ (alternating_face_map_complex A).obj X :=\nchain_complex.of_hom _ _ _ _ _ _\n  (λ n, (normalized_Moore_complex.obj_X X n).arrow)\n  (λ n,\n    begin\n      /- we have to show the compatibility of the differentials on the alternating\n         face map complex with those defined on the normalized Moore complex:\n         we first get rid of the terms of the alternating sum that are obviously\n         zero on the normalized_Moore_complex -/\n      simp only [alternating_face_map_complex.obj_d],\n      rw comp_sum,\n      let t := λ (j : fin (n+2)), (normalized_Moore_complex.obj_X X (n+1)).arrow ≫\n        ((-1 : ℤ)^(j : ℕ) • X.δ j),\n      have def_t : (∀ j : fin (n+2), t j = (normalized_Moore_complex.obj_X X (n+1)).arrow ≫\n        ((-1 : ℤ)^(j : ℕ) • X.δ j)) := by { intro j, refl, },\n      rw [fin.sum_univ_succ t],\n      have null : ∀ j : fin (n+1), t j.succ = 0,\n      { intro j,\n        rw [def_t, comp_zsmul, ← zsmul_zero ((-1 : ℤ)^(j.succ : ℕ))],\n        apply congr_arg,\n        rw normalized_Moore_complex.obj_X,\n        rw ← factor_thru_arrow _ _\n          (finset_inf_arrow_factors finset.univ _ j (by simp only [finset.mem_univ])),\n        slice_lhs 2 3 { erw kernel_subobject_arrow_comp (X.δ j.succ), },\n        simp only [comp_zero], },\n      rw [fintype.sum_eq_zero _ null],\n      simp only [add_zero],\n      /- finally, we study the remaining term which is induced by X.δ 0 -/\n      let eq := def_t 0,\n      rw [show (-1 : ℤ)^((0 : fin (n+2)) : ℕ) = 1, by ring] at eq,\n      rw one_smul at eq,\n      rw eq,\n      cases n; dsimp; simp,\n    end)\n\n@[simp]\n\n\nvariables (A)\n\n/-- The inclusion map of the Moore complex in the alternating face map complex,\nas a natural transformation -/\n@[simps]\ndef inclusion_of_Moore_complex :\n  (normalized_Moore_complex A) ⟶ (alternating_face_map_complex A) :=\n{ app := inclusion_of_Moore_complex_map, }\n\nend algebraic_topology\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/algebraic_topology/alternating_face_map_complex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933403143929, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.4577685843733252}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Scott Morrison\n-/\nimport category_theory.subobject.mono_over\nimport category_theory.skeletal\nimport category_theory.concrete_category.basic\nimport tactic.apply_fun\nimport tactic.elementwise\n\n/-!\n# Subobjects\n\nWe define `subobject X` as the quotient (by isomorphisms) of\n`mono_over X := {f : over X // mono f.hom}`.\n\nHere `mono_over X` is a thin category (a pair of objects has at most one morphism between them),\nso we can think of it as a preorder. However as it is not skeletal, it is not a partial order.\n\nThere is a coercion from `subobject X` back to the ambient category `C`\n(using choice to pick a representative), and for `P : subobject X`,\n`P.arrow : (P : C) ⟶ X` is the inclusion morphism.\n\nWe provide\n* `def pullback [has_pullbacks C] (f : X ⟶ Y) : subobject Y ⥤ subobject X`\n* `def map (f : X ⟶ Y) [mono f] : subobject X ⥤ subobject Y`\n* `def «exists» [has_images C] (f : X ⟶ Y) : subobject X ⥤ subobject Y`\nand prove their basic properties and relationships.\nThese are all easy consequences of the earlier development\nof the corresponding functors for `mono_over`.\n\nThe subobjects of `X` form a preorder making them into a category. We have `X ≤ Y` if and only if\n`X.arrow` factors through `Y.arrow`: see `of_le`/`of_le_mk`/`of_mk_le`/`of_mk_le_mk` and\n`le_of_comm`. Similarly, to show that two subobjects are equal, we can supply an isomorphism between\nthe underlying objects that commutes with the arrows (`eq_of_comm`).\n\nSee also\n\n* `category_theory.subobject.factor_thru` :\n  an API describing factorization of morphisms through subobjects.\n* `category_theory.subobject.lattice` :\n  the lattice structures on subobjects.\n\n## Notes\n\nThis development originally appeared in Bhavik Mehta's \"Topos theory for Lean\" repository,\nand was ported to mathlib by Scott Morrison.\n\n### Implementation note\n\nCurrently we describe `pullback`, `map`, etc., as functors.\nIt may be better to just say that they are monotone functions,\nand even avoid using categorical language entirely when describing `subobject X`.\n(It's worth keeping this in mind in future use; it should be a relatively easy change here\nif it looks preferable.)\n\n### Relation to pseudoelements\n\nThere is a separate development of pseudoelements in `category_theory.abelian.pseudoelements`,\nas a quotient (but not by isomorphism) of `over X`.\n\nWhen a morphism `f` has an image, the image represents the same pseudoelement.\nIn a category with images `pseudoelements X` could be constructed as a quotient of `mono_over X`.\nIn fact, in an abelian category (I'm not sure in what generality beyond that),\n`pseudoelements X` agrees with `subobject X`, but we haven't developed this in mathlib yet.\n\n-/\n\nuniverses v₁ v₂ u₁ u₂\n\nnoncomputable theory\nnamespace category_theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u₁} [category.{v₁} C] {X Y Z : C}\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-!\nWe now construct the subobject lattice for `X : C`,\nas the quotient by isomorphisms of `mono_over X`.\n\nSince `mono_over X` is a thin category, we use `thin_skeleton` to take the quotient.\n\nEssentially all the structure defined above on `mono_over X` descends to `subobject X`,\nwith morphisms becoming inequalities, and isomorphisms becoming equations.\n-/\n\n/--\nThe category of subobjects of `X : C`, defined as isomorphism classes of monomorphisms into `X`.\n-/\n@[derive [partial_order, category]]\ndef subobject (X : C) := thin_skeleton (mono_over X)\n\nnamespace subobject\n\n/-- Convenience constructor for a subobject. -/\nabbreviation mk {X A : C} (f : A ⟶ X) [mono f] : subobject X :=\n(to_thin_skeleton _).obj (mono_over.mk' f)\n\nsection\nlocal attribute [ext] category_theory.comma\n\nprotected lemma ind {X : C} (p : subobject X → Prop)\n  (h : ∀ ⦃A : C⦄ (f : A ⟶ X) [mono f], by exactI p (subobject.mk f)) (P : subobject X) : p P :=\nbegin\n  apply quotient.induction_on',\n  intro a,\n  convert h a.arrow,\n  ext; refl\nend\n\nprotected lemma ind₂ {X : C} (p : subobject X → subobject X → Prop)\n  (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [mono f] [mono g],\n    by exactI p (subobject.mk f) (subobject.mk g)) (P Q : subobject X) : p P Q :=\nbegin\n  apply quotient.induction_on₂',\n  intros a b,\n  convert h a.arrow b.arrow;\n  ext; refl\nend\n\nend\n\n/-- Declare a function on subobjects of `X` by specifying a function on monomorphisms with\n    codomain `X`. -/\nprotected def lift {α : Sort*} {X : C} (F : Π ⦃A : C⦄ (f : A ⟶ X) [mono f], α)\n  (h : ∀ ⦃A B : C⦄ (f : A ⟶ X) (g : B ⟶ X) [mono f] [mono g] (i : A ≅ B),\n    i.hom ≫ g = f → by exactI F f = F g) : subobject X → α :=\nλ P, quotient.lift_on' P (λ m, by exactI F m.arrow) $ λ m n ⟨i⟩,\n  h m.arrow n.arrow ((mono_over.forget X ⋙ over.forget X).map_iso i) (over.w i.hom)\n\n@[simp]\nprotected lemma lift_mk {α : Sort*} {X : C} (F : Π ⦃A : C⦄ (f : A ⟶ X) [mono f], α) {h A}\n  (f : A ⟶ X) [mono f] : subobject.lift F h (subobject.mk f) = F f :=\nrfl\n\n/-- The category of subobjects is equivalent to the `mono_over` category. It is more convenient to\nuse the former due to the partial order instance, but oftentimes it is easier to define structures\non the latter. -/\nnoncomputable def equiv_mono_over (X : C) : subobject X ≌ mono_over X :=\nthin_skeleton.equivalence _\n\n/--\nUse choice to pick a representative `mono_over X` for each `subobject X`.\n-/\nnoncomputable\ndef representative {X : C} : subobject X ⥤ mono_over X :=\n(equiv_mono_over X).functor\n\n/--\nStarting with `A : mono_over X`, we can take its equivalence class in `subobject X`\nthen pick an arbitrary representative using `representative.obj`.\nThis is isomorphic (in `mono_over X`) to the original `A`.\n-/\nnoncomputable\ndef representative_iso {X : C} (A : mono_over X) :\n  representative.obj ((to_thin_skeleton _).obj A) ≅ A :=\n(equiv_mono_over X).counit_iso.app A\n\n/--\nUse choice to pick a representative underlying object in `C` for any `subobject X`.\n\nPrefer to use the coercion `P : C` rather than explicitly writing `underlying.obj P`.\n-/\nnoncomputable\ndef underlying {X : C} : subobject X ⥤ C :=\nrepresentative ⋙ mono_over.forget _ ⋙ over.forget _\n\ninstance : has_coe (subobject X) C :=\n{ coe := λ Y, underlying.obj Y, }\n\n@[simp] lemma underlying_as_coe {X : C} (P : subobject X) : underlying.obj P = P := rfl\n\n/--\nIf we construct a `subobject Y` from an explicit `f : X ⟶ Y` with `[mono f]`,\nthen pick an arbitrary choice of underlying object `(subobject.mk f : C)` back in `C`,\nit is isomorphic (in `C`) to the original `X`.\n-/\nnoncomputable\ndef underlying_iso {X Y : C} (f : X ⟶ Y) [mono f] : (subobject.mk f : C) ≅ X :=\n(mono_over.forget _ ⋙ over.forget _).map_iso (representative_iso (mono_over.mk' f))\n\n/--\nThe morphism in `C` from the arbitrarily chosen underlying object to the ambient object.\n-/\nnoncomputable\ndef arrow {X : C} (Y : subobject X) : (Y : C) ⟶ X :=\n(representative.obj Y).obj.hom\n\ninstance arrow_mono {X : C} (Y : subobject X) : mono (Y.arrow) :=\n(representative.obj Y).property\n\n@[simp]\nlemma arrow_congr {A : C} (X Y : subobject A) (h : X = Y) :\n  eq_to_hom (congr_arg (λ X : subobject A, (X : C)) h) ≫ Y.arrow = X.arrow :=\nby { induction h, simp, }\n\n@[simp]\nlemma representative_coe (Y : subobject X) :\n  (representative.obj Y : C) = (Y : C) :=\nrfl\n\n@[simp]\nlemma representative_arrow (Y : subobject X) :\n  (representative.obj Y).arrow = Y.arrow :=\nrfl\n\n@[simp, reassoc]\nlemma underlying_arrow {X : C} {Y Z : subobject X} (f : Y ⟶ Z) :\n  underlying.map f ≫ arrow Z = arrow Y :=\nover.w (representative.map f)\n\n@[simp, reassoc, elementwise]\nlemma underlying_iso_arrow {X Y : C} (f : X ⟶ Y) [mono f] :\n  (underlying_iso f).inv ≫ (subobject.mk f).arrow = f :=\nover.w _\n\n@[simp, reassoc]\nlemma underlying_iso_hom_comp_eq_mk {X Y : C} (f : X ⟶ Y) [mono f] :\n  (underlying_iso f).hom ≫ f = (mk f).arrow :=\n(iso.eq_inv_comp _).1 (underlying_iso_arrow f).symm\n\n/-- Two morphisms into a subobject are equal exactly if\nthe morphisms into the ambient object are equal -/\n@[ext]\nlemma eq_of_comp_arrow_eq {X Y : C} {P : subobject Y}\n  {f g : X ⟶ P} (h : f ≫ P.arrow = g ≫ P.arrow) : f = g :=\n(cancel_mono P.arrow).mp h\n\nlemma mk_le_mk_of_comm {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [mono f₁] [mono f₂] (g : A₁ ⟶ A₂)\n  (w : g ≫ f₂ = f₁) : mk f₁ ≤ mk f₂ :=\n⟨mono_over.hom_mk _ w⟩\n\n@[simp] lemma mk_arrow (P : subobject X) : mk P.arrow = P :=\nquotient.induction_on' P $ λ Q,\nbegin\n  obtain ⟨e⟩ := @quotient.mk_out' _ (is_isomorphic_setoid _) Q,\n  refine quotient.sound' ⟨mono_over.iso_mk _ _ ≪≫ e⟩;\n  tidy\nend\n\nlemma le_of_comm {B : C} {X Y : subobject B} (f : (X : C) ⟶ (Y : C)) (w : f ≫ Y.arrow = X.arrow) :\n  X ≤ Y :=\nby convert mk_le_mk_of_comm _ w; simp\n\nlemma le_mk_of_comm {B A : C} {X : subobject B} {f : A ⟶ B} [mono f] (g : (X : C) ⟶ A)\n  (w : g ≫ f = X.arrow) : X ≤ mk f :=\nle_of_comm (g ≫ (underlying_iso f).inv) $ by simp [w]\n\nlemma mk_le_of_comm {B A : C} {X : subobject B} {f : A ⟶ B} [mono f] (g : A ⟶ (X : C))\n  (w : g ≫ X.arrow = f) : mk f ≤ X :=\nle_of_comm ((underlying_iso f).hom ≫ g) $ by simp [w]\n\n/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with\n    the arrows. -/\n@[ext] lemma eq_of_comm {B : C} {X Y : subobject B} (f : (X : C) ≅ (Y : C))\n  (w : f.hom ≫ Y.arrow = X.arrow) : X = Y :=\nle_antisymm (le_of_comm f.hom w) $ le_of_comm f.inv $ f.inv_comp_eq.2 w.symm\n\n/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with\n    the arrows. -/\n@[ext] lemma eq_mk_of_comm {B A : C} {X : subobject B} (f : A ⟶ B) [mono f] (i : (X : C) ≅ A)\n  (w : i.hom ≫ f = X.arrow) : X = mk f :=\neq_of_comm (i.trans (underlying_iso f).symm) $ by simp [w]\n\n/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with\n    the arrows. -/\n@[ext] lemma mk_eq_of_comm {B A : C} {X : subobject B} (f : A ⟶ B) [mono f] (i : A ≅ (X : C))\n  (w : i.hom ≫ X.arrow = f) : mk f = X :=\neq.symm $ eq_mk_of_comm _ i.symm $ by rw [iso.symm_hom, iso.inv_comp_eq, w]\n\n/-- To show that two subobjects are equal, it suffices to exhibit an isomorphism commuting with\n    the arrows. -/\n@[ext] lemma mk_eq_mk_of_comm {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [mono f] [mono g]\n  (i : A₁ ≅ A₂) (w : i.hom ≫ g = f) : mk f = mk g :=\neq_mk_of_comm _ ((underlying_iso f).trans i) $ by simp [w]\n\n/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/\n-- We make `X` and `Y` explicit arguments here so that when `of_le` appears in goal statements\n-- it is possible to see its source and target\n-- (`h` will just display as `_`, because it is in `Prop`).\ndef of_le {B : C} (X Y : subobject B) (h : X ≤ Y) : (X : C) ⟶ (Y : C) :=\nunderlying.map $ h.hom\n\n@[simp, reassoc] lemma of_le_arrow {B : C} {X Y : subobject B} (h : X ≤ Y) :\n  of_le X Y h ≫ Y.arrow = X.arrow :=\nunderlying_arrow _\n\ninstance {B : C} (X Y : subobject B) (h : X ≤ Y) : mono (of_le X Y h) :=\nbegin\n  fsplit,\n  intros Z f g w,\n  replace w := w =≫ Y.arrow,\n  ext,\n  simpa using w,\nend\n\nlemma of_le_mk_le_mk_of_comm\n  {B A₁ A₂ : C} {f₁ : A₁ ⟶ B} {f₂ : A₂ ⟶ B} [mono f₁] [mono f₂] (g : A₁ ⟶ A₂) (w : g ≫ f₂ = f₁) :\n  of_le _ _ (mk_le_mk_of_comm g w) = (underlying_iso _).hom ≫ g ≫ (underlying_iso _).inv :=\nby { ext, simp [w], }\n\n/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/\n@[derive mono]\ndef of_le_mk {B A : C} (X : subobject B) (f : A ⟶ B) [mono f] (h : X ≤ mk f) : (X : C) ⟶ A :=\nof_le X (mk f) h ≫ (underlying_iso f).hom\n\n@[simp] lemma of_le_mk_comp {B A : C} {X : subobject B} {f : A ⟶ B} [mono f] (h : X ≤ mk f) :\n  of_le_mk X f h ≫ f = X.arrow :=\nby simp [of_le_mk]\n\n/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/\n@[derive mono]\ndef of_mk_le {B A : C} (f : A ⟶ B) [mono f] (X : subobject B) (h : mk f ≤ X) : A ⟶ (X : C) :=\n(underlying_iso f).inv ≫ of_le (mk f) X h\n\n@[simp] lemma of_mk_le_arrow {B A : C} {f : A ⟶ B} [mono f] {X : subobject B} (h : mk f ≤ X) :\n  of_mk_le f X h ≫ X.arrow = f :=\nby simp [of_mk_le]\n\n/-- An inequality of subobjects is witnessed by some morphism between the corresponding objects. -/\n@[derive mono]\ndef of_mk_le_mk {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [mono f] [mono g] (h : mk f ≤ mk g) :\n  A₁ ⟶ A₂ :=\n(underlying_iso f).inv ≫ of_le (mk f) (mk g) h ≫ (underlying_iso g).hom\n\n@[simp] lemma of_mk_le_mk_comp {B A₁ A₂ : C} {f : A₁ ⟶ B} {g : A₂ ⟶ B} [mono f] [mono g]\n  (h : mk f ≤ mk g) : of_mk_le_mk f g h ≫ g = f :=\nby simp [of_mk_le_mk]\n\n@[simp, reassoc] lemma of_le_comp_of_le {B : C} (X Y Z : subobject B) (h₁ : X ≤ Y) (h₂ : Y ≤ Z) :\n  of_le X Y h₁ ≫ of_le Y Z h₂ = of_le X Z (h₁.trans h₂) :=\nby simp [of_le, ←functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_le_comp_of_le_mk {B A : C} (X Y : subobject B) (f : A ⟶ B) [mono f]\n  (h₁ : X ≤ Y) (h₂ : Y ≤ mk f) : of_le X Y h₁ ≫ of_le_mk Y f h₂ = of_le_mk X f (h₁.trans h₂) :=\nby simp [of_mk_le, of_le_mk, of_le, ←functor.map_comp_assoc underlying]\n\n@[simp, reassoc] lemma of_le_mk_comp_of_mk_le {B A : C} (X : subobject B) (f : A ⟶ B) [mono f]\n  (Y : subobject B) (h₁ : X ≤ mk f) (h₂ : mk f ≤ Y) :\n  of_le_mk X f h₁ ≫ of_mk_le f Y h₂ = of_le X Y (h₁.trans h₂) :=\nby simp [of_mk_le, of_le_mk, of_le, ←functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_le_mk_comp_of_mk_le_mk {B A₁ A₂ : C} (X : subobject B) (f : A₁ ⟶ B)\n  [mono f] (g : A₂ ⟶ B) [mono g] (h₁ : X ≤ mk f) (h₂ : mk f ≤ mk g) :\n  of_le_mk X f h₁ ≫ of_mk_le_mk f g h₂ = of_le_mk X g (h₁.trans h₂) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, ←functor.map_comp_assoc underlying]\n\n@[simp, reassoc] lemma of_mk_le_comp_of_le {B A₁ : C} (f : A₁ ⟶ B) [mono f] (X Y : subobject B)\n  (h₁ : mk f ≤ X) (h₂ : X ≤ Y) :\n  of_mk_le f X h₁ ≫ of_le X Y h₂ = of_mk_le f Y (h₁.trans h₂) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, ←functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_mk_le_comp_of_le_mk {B A₁ A₂ : C} (f : A₁ ⟶ B) [mono f] (X : subobject B)\n  (g : A₂ ⟶ B) [mono g] (h₁ : mk f ≤ X) (h₂ : X ≤ mk g) :\n  of_mk_le f X h₁ ≫ of_le_mk X g h₂ = of_mk_le_mk f g (h₁.trans h₂) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, ←functor.map_comp_assoc underlying]\n\n@[simp, reassoc] lemma of_mk_le_mk_comp_of_mk_le {B A₁ A₂ : C} (f : A₁ ⟶ B) [mono f] (g : A₂ ⟶ B)\n  [mono g] (X : subobject B) (h₁ : mk f ≤ mk g) (h₂ : mk g ≤ X) :\n  of_mk_le_mk f g h₁ ≫ of_mk_le g X h₂ = of_mk_le f X (h₁.trans h₂) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, ←functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_mk_le_mk_comp_of_mk_le_mk {B A₁ A₂ A₃ : C} (f : A₁ ⟶ B) [mono f]\n  (g : A₂ ⟶ B) [mono g] (h : A₃ ⟶ B) [mono h] (h₁ : mk f ≤ mk g) (h₂ : mk g ≤ mk h) :\n  of_mk_le_mk f g h₁ ≫ of_mk_le_mk g h h₂ = of_mk_le_mk f h (h₁.trans h₂) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, ←functor.map_comp_assoc underlying]\n\n@[simp] lemma of_le_refl {B : C} (X : subobject B) :\n  of_le X X le_rfl = 𝟙 _ :=\nby { apply (cancel_mono X.arrow).mp, simp }\n\n@[simp] lemma of_mk_le_mk_refl {B A₁ : C} (f : A₁ ⟶ B) [mono f] :\n  of_mk_le_mk f f le_rfl = 𝟙 _ :=\nby { apply (cancel_mono f).mp, simp }\n\n/-- An equality of subobjects gives an isomorphism of the corresponding objects.\n(One could use `underlying.map_iso (eq_to_iso h))` here, but this is more readable.) -/\n-- As with `of_le`, we have `X` and `Y` as explicit arguments for readability.\n@[simps]\ndef iso_of_eq {B : C} (X Y : subobject B) (h : X = Y) : (X : C) ≅ (Y : C) :=\n{ hom := of_le _ _ h.le,\n  inv := of_le _ _ h.ge, }\n\n/-- An equality of subobjects gives an isomorphism of the corresponding objects. -/\n@[simps]\ndef iso_of_eq_mk {B A : C} (X : subobject B) (f : A ⟶ B) [mono f] (h : X = mk f) : (X : C) ≅ A :=\n{ hom := of_le_mk X f h.le,\n  inv := of_mk_le f X h.ge }\n\n/-- An equality of subobjects gives an isomorphism of the corresponding objects. -/\n@[simps]\ndef iso_of_mk_eq {B A : C} (f : A ⟶ B) [mono f] (X : subobject B) (h : mk f = X) : A ≅ (X : C) :=\n{ hom := of_mk_le f X h.le,\n  inv := of_le_mk X f h.ge, }\n\n/-- An equality of subobjects gives an isomorphism of the corresponding objects. -/\n@[simps]\ndef iso_of_mk_eq_mk {B A₁ A₂ : C} (f : A₁ ⟶ B) (g : A₂ ⟶ B) [mono f] [mono g] (h : mk f = mk g) :\n  A₁ ≅ A₂ :=\n{ hom := of_mk_le_mk f g h.le,\n  inv := of_mk_le_mk g f h.ge, }\n\nend subobject\n\n\nopen category_theory.limits\n\nnamespace subobject\n\n/-- Any functor `mono_over X ⥤ mono_over Y` descends to a functor\n`subobject X ⥤ subobject Y`, because `mono_over Y` is thin. -/\ndef lower {Y : D} (F : mono_over X ⥤ mono_over Y) : subobject X ⥤ subobject Y :=\nthin_skeleton.map F\n\n/-- Isomorphic functors become equal when lowered to `subobject`.\n(It's not as evil as usual to talk about equality between functors\nbecause the categories are thin and skeletal.) -/\nlemma lower_iso (F₁ F₂ : mono_over X ⥤ mono_over Y) (h : F₁ ≅ F₂) :\n  lower F₁ = lower F₂ :=\nthin_skeleton.map_iso_eq h\n\n/-- A ternary version of `subobject.lower`. -/\ndef lower₂ (F : mono_over X ⥤ mono_over Y ⥤ mono_over Z) :\n  subobject X ⥤ subobject Y ⥤ subobject Z :=\nthin_skeleton.map₂ F\n\n@[simp]\n\n\n/-- An adjunction between `mono_over A` and `mono_over B` gives an adjunction\nbetween `subobject A` and `subobject B`. -/\ndef lower_adjunction {A : C} {B : D}\n  {L : mono_over A ⥤ mono_over B} {R : mono_over B ⥤ mono_over A} (h : L ⊣ R) :\n  lower L ⊣ lower R :=\nthin_skeleton.lower_adjunction _ _ h\n\n/-- An equivalence between `mono_over A` and `mono_over B` gives an equivalence\nbetween `subobject A` and `subobject B`. -/\n@[simps]\ndef lower_equivalence {A : C} {B : D} (e : mono_over A ≌ mono_over B) : subobject A ≌ subobject B :=\n{ functor := lower e.functor,\n  inverse := lower e.inverse,\n  unit_iso :=\n  begin\n    apply eq_to_iso,\n    convert thin_skeleton.map_iso_eq e.unit_iso,\n    { exact thin_skeleton.map_id_eq.symm },\n    { exact (thin_skeleton.map_comp_eq _ _).symm },\n  end,\n  counit_iso :=\n  begin\n    apply eq_to_iso,\n    convert thin_skeleton.map_iso_eq e.counit_iso,\n    { exact (thin_skeleton.map_comp_eq _ _).symm },\n    { exact thin_skeleton.map_id_eq.symm },\n  end }\n\nsection pullback\nvariables [has_pullbacks C]\n\n/-- When `C` has pullbacks, a morphism `f : X ⟶ Y` induces a functor `subobject Y ⥤ subobject X`,\nby pulling back a monomorphism along `f`. -/\ndef pullback (f : X ⟶ Y) : subobject Y ⥤ subobject X :=\nlower (mono_over.pullback f)\n\nlemma pullback_id (x : subobject X) : (pullback (𝟙 X)).obj x = x :=\nbegin\n  apply quotient.induction_on' x,\n  intro f,\n  apply quotient.sound,\n  exact ⟨mono_over.pullback_id.app f⟩,\nend\n\nlemma pullback_comp (f : X ⟶ Y) (g : Y ⟶ Z) (x : subobject Z) :\n  (pullback (f ≫ g)).obj x = (pullback f).obj ((pullback g).obj x) :=\nbegin\n  apply quotient.induction_on' x,\n  intro t,\n  apply quotient.sound,\n  refine ⟨(mono_over.pullback_comp _ _).app t⟩,\nend\n\ninstance (f : X ⟶ Y) : faithful (pullback f) := {}\n\nend pullback\n\nsection map\n\n/--\nWe can map subobjects of `X` to subobjects of `Y`\nby post-composition with a monomorphism `f : X ⟶ Y`.\n-/\ndef map (f : X ⟶ Y) [mono f] : subobject X ⥤ subobject Y :=\nlower (mono_over.map f)\n\nlemma map_id (x : subobject X) : (map (𝟙 X)).obj x = x :=\nbegin\n  apply quotient.induction_on' x,\n  intro f,\n  apply quotient.sound,\n  exact ⟨mono_over.map_id.app f⟩,\nend\n\nlemma map_comp (f : X ⟶ Y) (g : Y ⟶ Z) [mono f] [mono g] (x : subobject X) :\n  (map (f ≫ g)).obj x = (map g).obj ((map f).obj x) :=\nbegin\n  apply quotient.induction_on' x,\n  intro t,\n  apply quotient.sound,\n  refine ⟨(mono_over.map_comp _ _).app t⟩,\nend\n\n/-- Isomorphic objects have equivalent subobject lattices. -/\ndef map_iso {A B : C} (e : A ≅ B) : subobject A ≌ subobject B :=\nlower_equivalence (mono_over.map_iso e)\n\n/-- In fact, there's a type level bijection between the subobjects of isomorphic objects,\nwhich preserves the order. -/\n-- @[simps] here generates a lemma `map_iso_to_order_iso_to_equiv_symm_apply`\n-- whose left hand side is not in simp normal form.\ndef map_iso_to_order_iso (e : X ≅ Y) : subobject X ≃o subobject Y :=\n{ to_fun := (map e.hom).obj,\n  inv_fun := (map e.inv).obj,\n  left_inv := λ g, by simp_rw [← map_comp, e.hom_inv_id, map_id],\n  right_inv := λ g, by simp_rw [← map_comp, e.inv_hom_id, map_id],\n  map_rel_iff' := λ A B, begin\n    dsimp, fsplit,\n    { intro h,\n      apply_fun (map e.inv).obj at h,\n      simp_rw [← map_comp, e.hom_inv_id, map_id] at h,\n      exact h, },\n    { intro h,\n      apply_fun (map e.hom).obj at h,\n      exact h, },\n  end }\n\n@[simp] lemma map_iso_to_order_iso_apply (e : X ≅ Y) (P : subobject X) :\n  map_iso_to_order_iso e P = (map e.hom).obj P :=\nrfl\n\n@[simp] lemma map_iso_to_order_iso_symm_apply (e : X ≅ Y) (Q : subobject Y) :\n  (map_iso_to_order_iso e).symm Q = (map e.inv).obj Q :=\nrfl\n\n/-- `map f : subobject X ⥤ subobject Y` is\nthe left adjoint of `pullback f : subobject Y ⥤ subobject X`. -/\ndef map_pullback_adj [has_pullbacks C] (f : X ⟶ Y) [mono f] : map f ⊣ pullback f :=\nlower_adjunction (mono_over.map_pullback_adj f)\n\n@[simp]\nlemma pullback_map_self [has_pullbacks C] (f : X ⟶ Y) [mono f] (g : subobject X) :\n  (pullback f).obj ((map f).obj g) = g :=\nbegin\n  revert g,\n  apply quotient.ind,\n  intro g',\n  apply quotient.sound,\n  exact ⟨(mono_over.pullback_map_self f).app _⟩,\nend\n\nlemma map_pullback [has_pullbacks C]\n  {X Y Z W : C} {f : X ⟶ Y} {g : X ⟶ Z} {h : Y ⟶ W} {k : Z ⟶ W} [mono h] [mono g]\n  (comm : f ≫ h = g ≫ k) (t : is_limit (pullback_cone.mk f g comm)) (p : subobject Y) :\n  (map g).obj ((pullback f).obj p) = (pullback k).obj ((map h).obj p) :=\nbegin\n  revert p,\n  apply quotient.ind',\n  intro a,\n  apply quotient.sound,\n  apply thin_skeleton.equiv_of_both_ways,\n  { refine mono_over.hom_mk (pullback.lift pullback.fst _ _) (pullback.lift_snd _ _ _),\n    change _ ≫ a.arrow ≫ h = (pullback.snd ≫ g) ≫ _,\n    rw [assoc, ← comm, pullback.condition_assoc] },\n  { refine mono_over.hom_mk (pullback.lift pullback.fst\n                        (pullback_cone.is_limit.lift' t (pullback.fst ≫ a.arrow) pullback.snd _).1\n                        (pullback_cone.is_limit.lift' _ _ _ _).2.1.symm) _,\n    { rw [← pullback.condition, assoc], refl },\n    { dsimp, rw [pullback.lift_snd_assoc],\n      apply (pullback_cone.is_limit.lift' _ _ _ _).2.2 } }\nend\n\nend map\n\nsection «exists»\nvariables [has_images C]\n\n/--\nThe functor from subobjects of `X` to subobjects of `Y` given by\nsending the subobject `S` to its \"image\" under `f`, usually denoted $\\exists_f$.\nFor instance, when `C` is the category of types,\nviewing `subobject X` as `set X` this is just `set.image f`.\n\nThis functor is left adjoint to the `pullback f` functor (shown in `exists_pullback_adj`)\nprovided both are defined, and generalises the `map f` functor, again provided it is defined.\n-/\ndef «exists» (f : X ⟶ Y) : subobject X ⥤ subobject Y :=\nlower (mono_over.exists f)\n\n/--\nWhen `f : X ⟶ Y` is a monomorphism, `exists f` agrees with `map f`.\n-/\nlemma exists_iso_map (f : X ⟶ Y) [mono f] : «exists» f = map f :=\nlower_iso _ _ (mono_over.exists_iso_map f)\n\n/--\n`exists f : subobject X ⥤ subobject Y` is\nleft adjoint to `pullback f : subobject Y ⥤ subobject X`.\n-/\ndef exists_pullback_adj (f : X ⟶ Y) [has_pullbacks C] : «exists» f ⊣ pullback f :=\nlower_adjunction (mono_over.exists_pullback_adj f)\n\nend  «exists»\n\nend subobject\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/subobject/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.45776676671218464}}
{"text": "import QL.FOL.completeness.skolem QL.FOL.completeness.herbrand\n\nuniverses u\nopen_locale logic_symbol aclogic\n\nvariables {L : fol.language.{u}}\n\nnamespace pl\nvariables {T : Theory (fol.herbrand_basis L)}\n\nnamespace provable\n\nlemma to_fol {p : formula (fol.herbrand_basis L)} (h : equal_axioms L ⊢ p) : ⬝⊢ p.to_fol :=\nbegin\n  simp[axiomatic_classical_logic.empty_axiom],\n  apply rec'_on h,\n  { intros p q _ _ IHpq IHp, simp at IHpq, refine IHpq ⨀ IHp },\n  { intros p hp, rcases hp; simp },\n  { simp },\n  { simp },\n  { simp },\n  { simp }\nend\n\nend provable\n\nend pl\n\nnamespace fol\n\nnamespace formula\nvariables {m : ℕ}\n\nlemma to_snf_univ_closure (p : formula L m) :\n  ∃ n (p₀ : subformula (L + L.skolem) m n) (h : p₀.is_open), p.to_snf = ∀'*p₀ :=\npnf.univ_closure_to_formula p.to_pnf.skolemize (pnf.forall_pnf_skolemize _)\n\nend formula\n\nsection compactness\nopen subformula language\n\ndef Theory.to_pl (T : Theory L) : pl.Theory (fol.herbrand_basis (L + L.skolem)) :=\n⋃ (σ : sentence L) (hσ : σ ∈ T) {n} (p₀ : subformula (L + L.skolem) 0 n) (hp₀ : p₀.is_open)\n  (h : σ.to_snf = (∀'*p₀ : subformula _ _ _)),\n  set.range (λ x, sentence.to_pl (substs x p₀) (by simpa using hp₀))\n\nlemma Satisfiable_of_to_pl_Satisfiable (T : Theory L) (h : pl.Satisfiable (T.to_pl ∪ pl.equal_axioms (L + L.skolem))) : Satisfiable T :=\nbegin\n  rcases h with ⟨V, hV⟩,\n  have hVΓ : V ⊧ T.to_pl, from (logic.semantics.models_union.mp hV).1,\n  have hVeq : V ⊧ pl.equal_axioms _, from (logic.semantics.models_union.mp hV).2,\n  let S := Structure.Herbrand V hVeq,\n  have : ∀ {σ : sentence L} (hσ : σ ∈ T), S ⊧ σ.to_snf,\n  { intros σ hσ, rcases formula.to_snf_univ_closure σ with ⟨n, p₀, hp₀, h⟩,\n    have : ∀ x, S ⊧ substs x p₀,\n    { intros x,\n      have : V ⊧ sentence.to_pl (substs (Structure.Herbrand.qu_inv ∘ subterm.val S fin.nil fin.nil ∘ x) p₀) _,\n      from hVΓ (by simp[Theory.to_pl]; refine ⟨σ, hσ, n, p₀, h, hp₀, _, rfl⟩),\n      simpa[sentence_models_def, Structure.Herbrand.val_iff_subst p₀ hp₀] using this },  \n    have : S ⊧ ∀'*p₀, by simpa[Structure.Herbrand.models_forall_iff] using this,\n    simpa[h] using this },\n  refine ⟨S.restrict add_left, by intros σ hσ; exact skolem.restrict_models _ (this hσ)⟩\nend\n\ntheorem compactness {T : Theory L} : Satisfiable T ↔ (∀ u ⊆ T, u.finite → Satisfiable u) :=\n⟨by rintros ⟨S, hS⟩ u hu u_fin; refine ⟨S, logic.semantics.models_of_ss hu hS⟩,\nbegin\n  contrapose, intros h,\n  have : ¬pl.Satisfiable (T.to_pl ∪ pl.equal_axioms (L + L.skolem)),\n  from mt (Satisfiable_of_to_pl_Satisfiable T) h,\n  rcases pl.compactness'.mp this with ⟨u, u_ss, u_fin, hu⟩,\n  let g := u \\ pl.equal_axioms _,\n  have : g ⊆ T.to_pl, by simp[g, set.diff_subset_iff, set.union_comm, u_ss],\n  have hg_to_fol : pl.formula.to_fol '' g ⊆\n    ⋃ (σ ∈ T) {n} (p₀ : subformula (L + L.skolem) 0 n) (hp₀ : p₀.is_open) (h : to_snf σ = (∀'*p₀ : subformula _ _ _)),\n    set.range (λ x, substs x p₀),\n  by simpa[Theory.to_pl, set.image_Union, ←set.range_comp, (∘)] using set.image_subset pl.formula.to_fol this,    \n  have hg_to_fol_fin : (pl.formula.to_fol '' g).finite , from set.finite.image _ (set.finite.diff u_fin _),\n  have : ¬pl.Satisfiable (g ∪ pl.equal_axioms _),\n  { intros A, suffices : pl.Satisfiable u, by contradiction, refine logic.semantics.Satisfiable_of_ss (by simp) A },\n  have : ¬Satisfiable (pl.formula.to_fol '' g), from mt Structure.Satisfies_to_fol_iff.mp this,\n  rcases set.finite_subset_Union hg_to_fol_fin hg_to_fol with ⟨s, s_fin, hs⟩,\n  simp[-set.image_subset_iff] at hs ⊢,\n  refine ⟨s ∩ T, by simp, set.finite.inter_of_left s_fin T, _⟩,\n  assume A,\n  suffices : Satisfiable (pl.formula.to_fol '' g), by contradiction,\n  rcases skolem.Satisfiability.mpr A with ⟨S, hS⟩,\n  refine ⟨S, _⟩, intros p hp,\n  have : ∃ (σ ∈ s ∩ T) {n} (p₀ : subformula (L + L.skolem) 0 n),\n    p₀.is_open ∧ to_snf σ = (∀'*p₀ : subformula _ _ _) ∧ ∃ x, substs x p₀ = p,\n  by simpa[and_assoc] using hs hp,\n  rcases this with ⟨σ, hσ, n, p₀, hp₀, h, x, rfl⟩,\n  have : S ⊧ ∀'*p₀, { rw←h, refine hS (set.mem_image_of_mem _ hσ) },\n  simp[sentence_models_def] at this ⊢, exact this _  \nend⟩\n\nend compactness\n\nopen subformula logic logic.Theory\n     axiomatic_classical_logic' axiomatic_classical_logic\n     Structure\nvariables {L} {m n : ℕ} [inhabited (L.fn 0)]\n\nlemma provable_of_valid_aux (p : subformula L 0 n) (hp : p.is_open) (H : valid (∃'*p)) : ∅ ⊢ ∃'*p :=\nbegin\n  rcases (valid_iff_pl_consequence p hp).mp H with ⟨v, hv⟩,\n  have lmm₁ : ∅ ⊢ (v.map (λ t, substs t p)).disjunction ⟶ ∃'*p, from ldisj_imply_of (by simp),\n  have lmm₂ : ∅ ⊢ (v.map (λ t, substs t p)).disjunction,\n    by simpa[(∘)] using pl.provable.to_fol (pl.completeness.mpr hv),\n  exact lmm₁ ⨀ lmm₂\nend\n\nlemma provable_of_valid (σ : sentence L) (H : valid σ) : ∅ ⊢ σ :=\nbegin\n  rcases formula.to_snf_univ_closure (∼σ) with ⟨n, p, hp, h⟩,\n  \nend\n\n\nend fol\n", "meta": {"author": "iehality", "repo": "lean-logic", "sha": "201cef2500203f7de83deb7fa8287934e2e142b2", "save_path": "github-repos/lean/iehality-lean-logic", "path": "github-repos/lean/iehality-lean-logic/lean-logic-201cef2500203f7de83deb7fa8287934e2e142b2/src/QL/FOL/completeness/completeness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.4577667568085609}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Simon Hudon\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.testing.slim_check.testable\nimport Mathlib.testing.slim_check.functions\nimport Mathlib.data.list.sort\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n## Finding counterexamples automatically using `slim_check`\n\nA proposition can be tested by writing it out as:\n\n```lean\nexample (xs : list ℕ) (w : ∃ x ∈ xs, x < 3) : ∀ y ∈ xs, y < 5 := by slim_check\n-- ===================\n\n-- ===================\n-- Found problems!\n\n-- Found problems!\n\n-- xs := [0, 5]\n\n-- xs := [0, 5]\n-- x := 0\n\n-- x := 0\n-- y := 5\n\n-- y := 5\n-- -------------------\n\n-- -------------------\n\nexample (x : ℕ) (h : 2 ∣ x) : x < 100 := by slim_check\n-- ===================\n\n-- ===================\n-- Found problems!\n\n-- Found problems!\n\n-- x := 258\n\n-- x := 258\n-- -------------------\n\n-- -------------------\n\nexample (α : Type) (xs ys : list α) : xs ++ ys = ys ++ xs := by slim_check\n-- ===================\n\n-- ===================\n-- Found problems!\n\n-- Found problems!\n\n-- α := ℤ\n\n-- α := ℤ\n-- xs := [-4]\n\n-- xs := [-4]\n-- ys := [1]\n\n-- ys := [1]\n-- -------------------\n\n-- -------------------\n\nexample : ∀ x ∈ [1,2,3], x < 4 := by slim_check\n-- Success\n\n-- Success\n```\n\nIn the first example, `slim_check` is called on the following goal:\n\n```lean\nxs : list ℕ,\nh : ∃ (x : ℕ) (H : x ∈ xs), x < 3\n⊢ ∀ (y : ℕ), y ∈ xs → y < 5\n```\n\nThe local constants are reverted and an instance is found for\n`testable (∀ (xs : list ℕ), (∃ x ∈ xs, x < 3) → (∀ y ∈ xs, y < 5))`.\nThe `testable` instance is supported by instances of `sampleable (list ℕ)`,\n`decidable (x < 3)` and `decidable (y < 5)`. `slim_check` builds a\n`testable` instance step by step with:\n\n```\n- testable (∀ (xs : list ℕ), (∃ x ∈ xs, x < 3) → (∀ y ∈ xs, y < 5))\n                                     -: sampleable (list xs)\n- testable ((∃ x ∈ xs, x < 3) → (∀ y ∈ xs, y < 5))\n- testable (∀ x ∈ xs, x < 3 → (∀ y ∈ xs, y < 5))\n- testable (x < 3 → (∀ y ∈ xs, y < 5))\n                                     -: decidable (x < 3)\n- testable (∀ y ∈ xs, y < 5)\n                                     -: decidable (y < 5)\n```\n\n`sampleable (list ℕ)` lets us create random data of type `list ℕ` in a way that\nhelps find small counter-examples.  Next, the test of the proposition\nhinges on `x < 3` and `y < 5` to both be decidable. The\nimplication between the two could be tested as a whole but it would be\nless informative. Indeed, if we generate lists that only contain numbers\ngreater than `3`, the implication will always trivially hold but we should\nconclude that we haven't found meaningful examples. Instead, when `x < 3`\ndoes not hold, we reject the example (i.e.  we do not count it toward\nthe 100 required positive examples) and we start over. Therefore, when\n`slim_check` prints `Success`, it means that a hundred suitable lists\nwere found and successfully tested.\n\nIf no counter-examples are found, `slim_check` behaves like `admit`.\n\n`slim_check` can also be invoked using `#eval`:\n\n```lean\n#eval slim_check.testable.check (∀ (α : Type) (xs ys : list α), xs ++ ys = ys ++ xs)\n-- ===================\n\n-- ===================\n-- Found problems!\n\n-- Found problems!\n\n-- α := ℤ\n\n-- α := ℤ\n-- xs := [-4]\n\n-- xs := [-4]\n-- ys := [1]\n\n-- ys := [1]\n-- -------------------\n\n-- -------------------\n```\n\nFor more information on writing your own `sampleable` and `testable`\ninstances, see `testing.slim_check.testable`.\n-/\n\nnamespace tactic.interactive\n\n\n/-- Tree structure representing a `testable` instance. -/\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/slim_check_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.4577667529694814}}
{"text": "variable {α : Type*}\n\ndef is_prefix (l₁ : list α) (l₂ : list α) : Prop :=\n  ∃ t, l₁ ++ t = l₂\n\ninstance list_has_le : has_le (list α) := ⟨is_prefix⟩\n\ntheorem list.is_prefix_refl (l : list α) : l ≤ l :=\n  ⟨[], by simp⟩\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch6/ex0405.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4577667491304017}}
{"text": "import .dual \n\nnoncomputable theory \nopen_locale classical \n\nopen set \n\nnamespace matroid \n\nvariables {E E₀ E₁ E₂ : Type*} [finite E] [finite E₁] [finite E₂] \n{M₀ : matroid E₀} {M₁ : matroid E₁} {M₂ : matroid E₂}\n\nsection iso \n\n\n\n/-- Two matroids are isomorphic if there is a map between ground sets that preserves bases -/\ndef is_iso (M₁ : matroid E₁) (M₂ : matroid E₂) (e : E₁ ≃ E₂) := \n  ∀ B, M₁.base B ↔ M₂.base (e '' B)  \n\n/-- A bundled isomorphism between two matroids -/\nstructure iso (M₁ : matroid E₁) (M₂ : matroid E₂) := \n(to_fun : E₁ ≃ E₂)\n(on_base : ∀ B, M₁.base B ↔ M₂.base (to_fun '' B))\n\ninfix ` ≃i ` :75 :=  matroid.iso\n\ninstance : has_coe_to_fun (M₁ ≃i M₂) (λ _, E₁ → E₂) :=\n  ⟨λ e, e.to_fun⟩  \n\ndef iso.refl (M : matroid E) : M ≃i M := ⟨equiv.refl E, λ B, by simp⟩   \ndef iso.symm (e : M₁ ≃i M₂) : M₂ ≃i M₁ := ⟨e.to_fun.symm, λ B, by {rw e.on_base, simp, }⟩  \n\n/-- An equivalence between types induces a map from a matroid on one type to one on another -/\ndef congr_equiv (M₁ : matroid E₁) (e : E₁ ≃ E₂)  :\n  matroid E₂ :=\n{ base := λ B, M₁.base (e ⁻¹' B),\n  exists_base' := by \n    {obtain ⟨B₁,hB₁⟩ := M₁.exists_base, exact ⟨e '' B₁, by simpa using hB₁⟩} ,\n  base_exchange' := \n  begin\n    rintro B₁ B₂ hB₁ hB₂ x hx,\n    have hx' : e.symm x ∈ e ⁻¹' B₁ \\ e⁻¹' B₂, by simpa,\n    obtain ⟨y, hy, hBy⟩ := hB₁.exchange hB₂ hx',  \n    refine ⟨e y, by simpa, _⟩, \n    dsimp only, \n    simp_rw [←union_singleton, preimage_union, preimage_diff] at ⊢ hBy, \n    convert hBy;\n    simp [preimage_equiv_eq_image_symm],\n  end}\n\n@[simp] lemma congr_equiv_apply_base {e : E₁ ≃ E₂} {M₁ : matroid E₁} {B : set E₂} :\n  (M₁.congr_equiv e).base B ↔ M₁.base (e ⁻¹' B) := \niff.rfl \n\n@[simp] lemma congr_equiv_apply_indep {e : E₁ ≃ E₂} {M₁ : matroid E₁} {I : set E₂} :\n  (M₁.congr_equiv e).indep I ↔ M₁.indep (e ⁻¹' I) := \nbegin\n  simp_rw [indep, congr_equiv_apply_base], \n  split, \n  { rintro ⟨B₂, hB₂, hIB₂⟩, exact ⟨_, hB₂, preimage_mono hIB₂⟩},\n  rintro ⟨B₁, hB₁, hIB₁⟩, \n  refine ⟨e '' B₁, by {convert hB₁, simp}, _⟩,  \n  rwa [←equiv.subset_image, ←preimage_equiv_eq_image_symm], \nend \n\n@[simp] lemma congr_equiv_apply_symm_base {e : E₁ ≃ E₂} {M₂ : matroid E₂} {B : set E₁} :\n  (M₂.congr_equiv e.symm).base B ↔ M₂.base (e '' B) := \nby simp [←image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_symm_indep {e : E₁ ≃ E₂} {M₂ : matroid E₂} {I : set E₁} :\n  (M₂.congr_equiv e.symm).indep I ↔ M₂.indep (e '' I) := \nby simp [←image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_basis {e : E₁ ≃ E₂} {M₁ : matroid E₁} {I X : set E₂} :\n  (M₁.congr_equiv e).basis I X ↔ M₁.basis (e ⁻¹' I) (e ⁻¹' X) := \nbegin\n  simp only [basis, congr_equiv_apply_indep, equiv.preimage_subset, and.congr_right_iff], \n  refine λ hI hIX, ⟨λ h J hJ hIJ hJX, _,λ h J hJ hIJ hJX, _⟩, \n  { rw h (e '' J) (by simpa) _ (by simpa), \n    { simp, },\n    rw ←e.image_preimage I,\n    exact image_subset e hIJ}, \n  have h' := h (e ⁻¹' J) hJ (preimage_mono hIJ) (preimage_mono hJX), \n  rwa preimage_eq_preimage e.surjective at h',   \nend \n\n@[simp] lemma congr_equiv_apply_symm_basis {e : E₁ ≃ E₂} {M₂ : matroid E₂} {I X : set E₁} :\n  (M₂.congr_equiv e.symm).basis I X ↔ M₂.basis (e '' I) (e '' X) := \nby simp [←image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_r {e : E₁ ≃ E₂} {M₁ : matroid E₁} (X : set E₂) :\n  (M₁.congr_equiv e).r X = M₁.r (e ⁻¹' X) := \nbegin\n  obtain ⟨I, hI⟩ := (M₁.congr_equiv e).exists_basis X, \n  rw [←hI.r, hI.indep.r], \n  rw [congr_equiv_apply_basis] at hI,\n  rw [←hI.r, hI.indep.r, preimage_equiv_eq_image_symm, ncard_image_of_injective _ e.symm.injective], \nend\n\n@[simp] lemma congr_equiv_apply_symm_r {e : E₁ ≃ E₂} {M₂ : matroid E₂} (X : set E₁) :\n  (M₂.congr_equiv e.symm).r X = M₂.r (e '' X) := \nby simp [←image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_circuit {e : E₁ ≃ E₂} {M₁ : matroid E₁} {C : set E₂} :\n  (M₁.congr_equiv e).circuit C ↔ M₁.circuit (e ⁻¹' C) :=\nbegin\n  simp_rw [circuit_iff_dep_forall_diff_singleton_indep, congr_equiv_apply_indep, preimage_diff], \n  convert iff.rfl, \n  rw eq_iff_iff, \n  refine ⟨λ h x hxC, _,λ h x (hx : e x ∈ C), _⟩, \n  { convert h (e.symm x) (by simpa), \n    rw [←image_singleton, preimage_equiv_eq_image_symm]},\n  convert h _ hx, \n  rw [←image_singleton, preimage_image_eq _ e.injective], \nend \n\n@[simp] lemma congr_equiv_apply_symm_circuit {e : E₁ ≃ E₂} {M₂ : matroid E₂} {C : set E₁} :\n  (M₂.congr_equiv e.symm).circuit C = M₂.circuit (e '' C) := \nby simp [←image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_flat {e : E₁ ≃ E₂} {M₁ : matroid E₁} {F : set E₂} :\n  (M₁.congr_equiv e).flat F ↔ M₁.flat (e ⁻¹' F) :=\nbegin\n  simp_rw [flat_def, congr_equiv_apply_basis], \n  refine ⟨λ h I X hIF hFX, _,λ h I X hIF hFX, _⟩, \n  { rw [←image_subset_iff], \n    exact h (e '' I) (e '' X) (by simpa) (by simpa)},\n  exact (equiv.preimage_subset e X F).mp (h (⇑e ⁻¹' I) (⇑e ⁻¹' X) hIF hFX), \nend \n\n@[simp] lemma congr_equiv_apply_symm_flat {e : E₁ ≃ E₂} {M₂ : matroid E₂} {F : set E₁} :\n  (M₂.congr_equiv e.symm).flat F = M₂.flat (e '' F) := \nby simp [←image_equiv_eq_preimage_symm]\n\nend iso\n\n\n\nend matroid ", "meta": {"author": "apnelson1", "repo": "lean-matroids", "sha": "1880f5b4b9a99948368e35539672a9bf35cc09cc", "save_path": "github-repos/lean/apnelson1-lean-matroids", "path": "github-repos/lean/apnelson1-lean-matroids/lean-matroids-1880f5b4b9a99948368e35539672a9bf35cc09cc/src/matroid/equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.4577667491304017}}
{"text": "\nnamespace hidden\n    instance inhabited_sum (α : Type) (β : Type) [inhabited α] : inhabited (α ⊕ β) :=\n    ⟨@sum.inl α β (default α)⟩\n\n    instance inhabited_nonempty (α : Type) [inhabited α] : inhabited (list α) :=\n    ⟨list.cons (default α) list.nil⟩\n\n\n    def add_lists (α : Type) [has_add α] : list α → list α → list α\n    | [] [] := []\n    | l1 [] := l1\n    | [] l2 := l2\n    | (hd1::tl1) (hd2::tl2) := (hd1 + hd2)::(add_lists tl1 tl2)\n\n    instance list_has_add (α : Type) [has_add α] : has_add (list α) :=\n    ⟨add_lists α⟩\n\n    example : [3, 2] + [] = [3, 2] := rfl\n    example : [] + [3, 2] = [3, 2] := rfl\n    example : (@list.nil ℕ) + [] = [] := rfl\n    example : [3, 2] + [10, 20] = [13, 22] := rfl\n\nend hidden\n", "meta": {"author": "tomhoule", "repo": "theorem-proving-in-lean-exercises", "sha": "60ccc71b8a6df6924e7cc90aab713b804f78da9f", "save_path": "github-repos/lean/tomhoule-theorem-proving-in-lean-exercises", "path": "github-repos/lean/tomhoule-theorem-proving-in-lean-exercises/theorem-proving-in-lean-exercises-60ccc71b8a6df6924e7cc90aab713b804f78da9f/theorem-proving-in-lean/src/chap_9.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.457766739226778}}
{"text": "lemma imp_trans (P Q R : Prop) : (P → Q) → ((Q → R) → (P → R)) :=\nbegin\nintros hpq hqr p,\napply hqr,\napply hpq,\nexact p,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/4-proposition-world/l7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4577334583879441}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport algebra.category.Mon.basic\nimport category_theory.endomorphism\n\n/-!\n# Category instances for group, add_group, comm_group, and add_comm_group.\n\nWe introduce the bundled categories:\n* `Group`\n* `AddGroup`\n* `CommGroup`\n* `AddCommGroup`\nalong with the relevant forgetful functors between them, and to the bundled monoid categories.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- The category of groups and group morphisms. -/\n@[to_additive AddGroup]\ndef Group : Type (u+1) := bundled group\n\n/-- The category of additive groups and group morphisms -/\nadd_decl_doc AddGroup\n\nnamespace Group\n\n@[to_additive]\ninstance : bundled_hom.parent_projection group.to_monoid := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] Group\nattribute [to_additive] Group.large_category Group.concrete_category\n\n@[to_additive] instance : has_coe_to_sort Group Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `Group` from the underlying type and typeclass. -/\n@[to_additive] def of (X : Type u) [group X] : Group := bundled.of X\n\n/-- Construct a bundled `AddGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddGroup.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `Group`. -/\n@[to_additive] def of_hom {X Y : Type u} [group X] [group Y] (f : X →* Y) : of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddGroup`. -/\nadd_decl_doc AddGroup.of_hom\n\n@[to_additive]\ninstance (G : Group) : group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [group R] : (Group.of R : Type u) = R := rfl\n\n@[to_additive]\ninstance : has_one Group := ⟨Group.of punit⟩\n\n@[to_additive]\ninstance : inhabited Group := ⟨1⟩\n\n@[to_additive]\ninstance one.unique : unique (1 : Group) :=\n{ default := 1,\n  uniq := λ a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : Group) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[ext, to_additive]\n\n\n@[to_additive has_forget_to_AddMon]\ninstance has_forget_to_Mon : has_forget₂ Group Mon := bundled_hom.forget₂ _ _\n\nend Group\n\n/-- The category of commutative groups and group morphisms. -/\n@[to_additive AddCommGroup]\ndef CommGroup : Type (u+1) := bundled comm_group\n\n/-- The category of additive commutative groups and group morphisms. -/\nadd_decl_doc AddCommGroup\n\n/-- `Ab` is an abbreviation for `AddCommGroup`, for the sake of mathematicians' sanity. -/\nabbreviation Ab := AddCommGroup\n\nnamespace CommGroup\n\n@[to_additive]\ninstance : bundled_hom.parent_projection comm_group.to_group := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] CommGroup\nattribute [to_additive] CommGroup.large_category CommGroup.concrete_category\n\n@[to_additive] instance : has_coe_to_sort CommGroup Type* := bundled.has_coe_to_sort\n\n\n/-- Construct a bundled `CommGroup` from the underlying type and typeclass. -/\n@[to_additive] def of (G : Type u) [comm_group G] : CommGroup := bundled.of G\n\n/-- Construct a bundled `AddCommGroup` from the underlying type and typeclass. -/\nadd_decl_doc AddCommGroup.of\n\n/-- Typecheck a `monoid_hom` as a morphism in `CommGroup`. -/\n@[to_additive] def of_hom {X Y : Type u} [comm_group X] [comm_group Y] (f : X →* Y) :\n  of X ⟶ of Y := f\n\n/-- Typecheck a `add_monoid_hom` as a morphism in `AddCommGroup`. -/\nadd_decl_doc AddCommGroup.of_hom\n\n@[to_additive]\ninstance comm_group_instance (G : CommGroup) : comm_group G := G.str\n\n@[simp, to_additive] lemma coe_of (R : Type u) [comm_group R] : (CommGroup.of R : Type u) = R := rfl\n\n@[to_additive] instance : has_one CommGroup := ⟨CommGroup.of punit⟩\n\n@[to_additive] instance : inhabited CommGroup := ⟨1⟩\n\n@[to_additive]\ninstance one.unique : unique (1 : CommGroup) :=\n{ default := 1,\n  uniq := λ a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : CommGroup) (g : G) : (1 : G ⟶ H) g = 1 := rfl\n\n@[ext, to_additive]\nlemma ext (G H : CommGroup) (f₁ f₂ : G ⟶ H) (w : ∀ x, f₁ x = f₂ x) : f₁ = f₂ :=\nby { ext1, apply w }\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget₂ CommGroup Group := bundled_hom.forget₂ _ _\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget₂ CommGroup CommMon :=\ninduced_category.has_forget₂ (λ G : CommGroup, CommMon.of G)\n\nend CommGroup\n\n-- This example verifies an improvement possible in Lean 3.8.\n-- Before that, to have `monoid_hom.map_map` usable by `simp` here,\n-- we had to mark all the concrete category `has_coe_to_sort` instances reducible.\n-- Now, it just works.\n@[to_additive]\nexample {R S : CommGroup} (i : R ⟶ S) (r : R) (h : r = 1) : i r = 1 :=\nby simp [h]\n\nnamespace AddCommGroup\n\n/-- Any element of an abelian group gives a unique morphism from `ℤ` sending\n`1` to that element. -/\n-- Note that because `ℤ : Type 0`, this forces `G : AddCommGroup.{0}`,\n-- so we write this explicitly to be clear.\n-- TODO generalize this, requiring a `ulift_instances.lean` file\ndef as_hom {G : AddCommGroup.{0}} (g : G) : (AddCommGroup.of ℤ) ⟶ G :=\nzmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : ℤ) : (as_hom g) i = i • g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\nλ h k w, by convert congr_arg (λ k : (AddCommGroup.of ℤ) ⟶ G, (k : ℤ → G) (1 : ℤ)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of ℤ) ⟶ G) (w : f (1 : ℤ) = g (1 : ℤ)) : f = g :=\nadd_monoid_hom.ext_int w\n\n-- TODO: this argument should be generalised to the situation where\n-- the forgetful functor is representable.\nlemma injective_of_mono {G H : AddCommGroup.{0}} (f : G ⟶ H) [mono f] : function.injective f :=\nλ g₁ g₂ h,\nbegin\n  have t0 : as_hom g₁ ≫ f = as_hom g₂ ≫ f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g₁ = as_hom g₂ := (cancel_mono _).1 t0,\n  apply as_hom_injective t1,\nend\n\nend AddCommGroup\n\nvariables {X Y : Type u}\n\n/-- Build an isomorphism in the category `Group` from a `mul_equiv` between `group`s. -/\n@[to_additive add_equiv.to_AddGroup_iso, simps]\ndef mul_equiv.to_Group_iso [group X] [group Y] (e : X ≃* Y) : Group.of X ≅ Group.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddGroup` from an `add_equiv` between `add_group`s. -/\nadd_decl_doc add_equiv.to_AddGroup_iso\n\n/-- Build an isomorphism in the category `CommGroup` from a `mul_equiv` between `comm_group`s. -/\n@[to_additive add_equiv.to_AddCommGroup_iso, simps]\ndef mul_equiv.to_CommGroup_iso [comm_group X] [comm_group Y] (e : X ≃* Y) :\n  CommGroup.of X ≅ CommGroup.of Y :=\n{ hom := e.to_monoid_hom,\n  inv := e.symm.to_monoid_hom }\n\n/-- Build an isomorphism in the category `AddCommGroup` from a `add_equiv` between\n`add_comm_group`s. -/\nadd_decl_doc add_equiv.to_AddCommGroup_iso\n\nnamespace category_theory.iso\n\n/-- Build a `mul_equiv` from an isomorphism in the category `Group`. -/\n@[to_additive AddGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism in the category\n`AddGroup`.\", simps]\ndef Group_iso_to_mul_equiv {X Y : Group} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\n/-- Build a `mul_equiv` from an isomorphism in the category `CommGroup`. -/\n@[to_additive AddCommGroup_iso_to_add_equiv \"Build an `add_equiv` from an isomorphism\nin the category `AddCommGroup`.\", simps]\ndef CommGroup_iso_to_mul_equiv {X Y : CommGroup} (i : X ≅ Y) : X ≃* Y :=\ni.hom.to_mul_equiv i.inv i.hom_inv_id i.inv_hom_id\n\nend category_theory.iso\n\n/-- multiplicative equivalences between `group`s are the same as (isomorphic to) isomorphisms\nin `Group` -/\n@[to_additive add_equiv_iso_AddGroup_iso \"additive equivalences between `add_group`s are the same\nas (isomorphic to) isomorphisms in `AddGroup`\"]\ndef mul_equiv_iso_Group_iso {X Y : Type u} [group X] [group Y] :\n  (X ≃* Y) ≅ (Group.of X ≅ Group.of Y) :=\n{ hom := λ e, e.to_Group_iso,\n  inv := λ i, i.Group_iso_to_mul_equiv, }\n\n/-- multiplicative equivalences between `comm_group`s are the same as (isomorphic to) isomorphisms\nin `CommGroup` -/\n@[to_additive add_equiv_iso_AddCommGroup_iso \"additive equivalences between `add_comm_group`s are\nthe same as (isomorphic to) isomorphisms in `AddCommGroup`\"]\ndef mul_equiv_iso_CommGroup_iso {X Y : Type u} [comm_group X] [comm_group Y] :\n  (X ≃* Y) ≅ (CommGroup.of X ≅ CommGroup.of Y) :=\n{ hom := λ e, e.to_CommGroup_iso,\n  inv := λ i, i.CommGroup_iso_to_mul_equiv, }\n\nnamespace category_theory.Aut\n\n/-- The (bundled) group of automorphisms of a type is isomorphic to the (bundled) group\nof permutations. -/\ndef iso_perm {α : Type u} : Group.of (Aut α) ≅ Group.of (equiv.perm α) :=\n{ hom := ⟨λ g, g.to_equiv, (by tidy), (by tidy)⟩,\n  inv := ⟨λ g, g.to_iso, (by tidy), (by tidy)⟩ }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {α : Type u} : Aut α ≃* equiv.perm α :=\niso_perm.Group_iso_to_mul_equiv\n\nend category_theory.Aut\n\n@[to_additive]\ninstance Group.forget_reflects_isos : reflects_isomorphisms (forget Group.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_Group_iso).1⟩,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := λ X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X ≃* Y := { ..f, ..i.to_equiv },\n    exact ⟨(is_iso.of_iso e.to_CommGroup_iso).1⟩,\n  end }\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/category/Group/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.731058584489497, "lm_q1q2_score": 0.4577334547191744}}
{"text": "def tst (x : Nat) : Nat :=\n  let_mvar% ?m := x + 1;\n  ?m + ?m\n\n#print tst\n\nexample : tst x = (x + 1) + (x + 1) :=\n  rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/letMVar.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.45773345105040475}}
{"text": "import definitions rotations shrink forall_keys tactic.linarith tactic.induction\nset_option pp.generalized_field_notation false\n\nuniverse u\n\nnamespace del_root_lemmas \nopen btree rotation_lemmas shrink_lemmas forall_keys_lemmas\n\nvariables {α : Type u}\n\nlemma del_root_del_root_view (t : btree α) :\n  del_root_view t (del_root t) :=\nbegin\n  cases t,\n  case empty {\n    exact del_root_view.empty,\n  },\n  case node : l k a r {\n    dsimp [del_root],\n    cases h : shrink l,\n    case none {\n      dsimp [del_root._match_1],\n      apply del_root_view.nonempty_empty; assumption,\n    },\n    case some {\n      rcases val with ⟨x, a', sh⟩,\n      dsimp only [del_root._match_1],\n      by_cases h' : height r > height sh + 1,\n      { simp only [if_pos h'],\n        apply del_root_view.nonempty_nonempty₁; assumption,\n      },\n      { simp only [if_neg h'],\n        apply del_root_view.nonempty_nonempty₂; try { assumption, },\n        linarith,\n      },\n    },\n  },\nend\n\n/- Auxiliary del_root lemma for forall_delete -/\nlemma forall_del_root (t : btree α) (k : nat) (p : nat → nat → Prop) :\n  forall_keys p k t → forall_keys p k (del_root t) :=\nbegin\n  intro h₁,\n  cases t,\n  case empty {\n    simp [del_root],\n    exact h₁,\n  },\n  case node : l x v r {\n    cases' del_root_del_root_view (node l x v r),\n    case nonempty_empty {\n      unfold forall_keys at h₁ ⊢,\n      intros k' h₂,\n      apply h₁,\n      simp [bound],\n      tauto,\n    },\n    case nonempty_nonempty₁ {\n      apply forall_rotate_left,\n      rw ← forall_keys_char,\n      repeat { split },\n      { rw ← forall_keys_char at h₁, \n        cases_matching* (_ ∧ _),\n        apply forall_shrink_aux_1 (and.intro h₁_left h),\n      },\n      { rw ← forall_keys_char at h₁,\n        cases_matching* (_ ∧ _),\n        apply forall_shrink_aux_2 (and.intro h₁_left h),\n      },\n      { unfold forall_keys at h₁ ⊢, \n        intros k' h₂,\n        apply h₁,\n        simp [bound],\n        tauto,\n      },\n    },\n    case nonempty_nonempty₂ {\n      rw ← forall_keys_char,\n      repeat { split },\n      { rw ← forall_keys_char at h₁, \n        cases_matching* (_ ∧ _),\n        apply forall_shrink_aux_1 (and.intro h₁_left h),\n      },\n      { rw ← forall_keys_char at h₁, \n        cases_matching* (_ ∧ _),\n        apply forall_shrink_aux_2 (and.intro h₁_left h),\n      },\n      { unfold forall_keys at h₁ ⊢, \n        intros k' h₂,\n        apply h₁,\n        simp [bound],\n        tauto,\n      },\n    },\n  },\nend\n\n/- Deleting a root of a tree preserves the tree order -/\nlemma del_root_ordered (t : btree α) :\n  ordered t → ordered (del_root t) :=\nbegin\n  intro h₁,\n  cases t,\n  case empty {\n    simp [del_root, ordered],\n  },\n  case node : tl tk ta tr {\n    simp [ordered] at h₁,\n    cases_matching* (_ ∧ _),\n    cases' del_root_del_root_view (node tl tk ta tr),\n    case nonempty_empty { assumption, },\n    case nonempty_nonempty₁ { \n      apply rotate_left_ordered, \n      rw ordered,\n      repeat { split },\n      { apply shrink_ordered_aux_1 (and.intro h₁_left h),  },\n      { assumption, },\n      { apply shrink_ordered_aux_2 (and.intro h₁_left h), },\n      { apply forall_keys_trans _ (<) k, \n        { apply forall_shrink_aux_2 (and.intro h₁_right_right_left h), },\n        { apply trans, },\n        { assumption, },\n      },\n    },\n    case nonempty_nonempty₂ { \n      rw ordered, \n      repeat { split },\n      { apply shrink_ordered_aux_1 (and.intro h₁_left h), },\n      { assumption, },\n      { apply shrink_ordered_aux_2 (and.intro h₁_left h), },\n      { apply forall_keys_trans _ (<) k, \n        { apply forall_shrink_aux_2 (and.intro h₁_right_right_left h), },\n        { apply trans, },\n        { assumption, },\n      },\n    },\n  },\nend\n\nend del_root_lemmas", "meta": {"author": "reglayass", "repo": "lean-avl", "sha": "c7bffa75d7548e5ff8cdd7d69f5a58499f883df1", "save_path": "github-repos/lean/reglayass-lean-avl", "path": "github-repos/lean/reglayass-lean-avl/lean-avl-c7bffa75d7548e5ff8cdd7d69f5a58499f883df1/src/del_root.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.45773345105040475}}
{"text": "import thm95\nimport statement\n\n/-!\n# Liquid Tensor Experiment\n\nThis file is the entry point for this project.\nThe first goal of the Liquid Tensor Experiment\nis to formalize a theorem by Clausen and Scholze stated below,\nnamely a mix of Theorem 9.4 and Theorem 9.5 of\n[Analytic]: http://www.math.uni-bonn.de/people/scholze/Analytic.pdf\n\n**How to browse this project? See `README.md` in the root of the repository.**\n\nWe will now state the main theorem.\n\nFirst we need to fix a package of data corresponding to the Breen--Deligne resolution.\nIf you don't know the Breen--Deligne resolution, don't worry,\nwe'll explain more about how to find out more about it below.\nOnce we have fixed this data, we can state the theorem.\n-/\n\nuniverse variables u\n\nopen_locale nnreal -- enable the notation `ℝ≥0` for the nonnegative real numbers.\n\nopen category_theory ProFiltPseuNormGrpWithTinv polyhedral_lattice opposite\n\nvariables (r r' : ℝ≥0)\nvariables [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' < 1)]\nvariables (BD : breen_deligne.package) (κ : ℕ → ℝ≥0)\nvariables [BD.data.very_suitable r r' κ] [∀ (i : ℕ), fact (0 < κ i)]\n\ninclude r r' BD κ\n\n/-- A mix of Theorems 9.4 and 9.5 in [Analytic] -/\ntheorem first_target :\n  ∀ m : ℕ, ∃ (k K : ℝ≥0) (hk : fact (1 ≤ k)) (c₀ : ℝ≥0),\n  ∀ (S : Type) [fintype S] (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    ​((BD.data.system κ r V r').obj (op $ of r' (Lbar r' S))).is_weak_bounded_exact k K m c₀ :=\nbegin\n  intro m,\n  obtain ⟨k, K, hk, H⟩ := thm95'' BD r r' κ m,\n  obtain ⟨c₀, H⟩ := H ℤ,\n  use [k, K, hk, c₀],\n  introsI S hS V hV,\n  specialize H S V,\n  let i := (BD.data.system κ r V r').map_iso (HomZ_iso (of r' $ Lbar r' S)).op,\n  refine H.of_iso i.symm _,\n  intros c n,\n  rw ← system_of_complexes.apply_hom_eq_hom_apply,\n  apply SemiNormedGroup.iso_isometry_of_norm_noninc;\n  apply breen_deligne.data.complex.map_norm_noninc\nend\n\n/-!\n## On the statement\n\nMost of the theorem should be fairly readable.\nWe will now briefly explain some of the more peculiar syntax.\nThe proof reduces to `thm95''` (a variant of Theorem 9.5).\n\n* `[BD.suitable κ]` assumes that the nonnegative reals `κ i` satisfy some suitable conditions\n  with respect to the package of Breen--Deligne data `BD`.\n* `[fact (0 < r)]` records the \"fact\" `0 < r` as an assumption to whatever comes later.\n* `(S : Type) [fintype S]` is Lean's way of saying \"`S` is a finite set\".\n  See also the \"Brief note on type theory\" in `README.md`.\n* `[normed_with_aut r V]` adds the assumption that `V` is endowed with an automorphism `T`\n  that scales elements `v` of `V` by the positive scalar `r`: `∥T(v)∥ = r * ∥v∥`.\n* `Lbar_system` is the system of complexes of seminormed groups\n  occuring in Theorems 9.4/9.5 of [Analytic].\n* `is_bounded_exact` is the assertion that a system of complexes\n  of seminormed groups satisfies a suitable exactness criterion of being\n  `≤ k`-exact in degrees `≤ m` for `c ≥ c₀` (where `c` is an index to the system of complexes).\n-/\n\nexample : first_target_stmt r r' BD κ := first_target r r' BD κ\n\n/-- Theorem 9.4 in [Analytic] for weak bounded exactness -/\ntheorem thm94_weak :\n  ∀ m : ℕ, ∃ (k K : ℝ≥0) (hk : fact (1 ≤ k)) (c₀ : ℝ≥0),\n  ∀ (S : Profinite) (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    ​((BD.data.system κ r V r').obj (op $ of r' ((Lbar.functor.{0 0} r').obj S)))\n      .is_weak_bounded_exact k K m c₀ :=\nbegin\n  intro m,\n  obtain ⟨k, K, hk, H⟩ := thm95''.profinite BD r r' κ m,\n  obtain ⟨c₀, H⟩ := H ℤ,\n  use [k, K, hk, c₀],\n  introsI S V hV,\n  specialize H S V,\n  let i := (BD.data.system κ r V r').map_iso (HomZ_iso (of r' $ (Lbar.functor.{0 0} r').obj S)).op,\n  refine H.of_iso i.symm _,\n  intros c n,\n  rw ← system_of_complexes.apply_hom_eq_hom_apply,\n  apply SemiNormedGroup.iso_isometry_of_norm_noninc;\n  apply breen_deligne.data.complex.map_norm_noninc\nend\n\n/-- Theorem 9.4 in [Analytic] -/\ntheorem thm94 :\n  ∀ m : ℕ, ∃ (k K : ℝ≥0) (hk : fact (1 ≤ k)) (c₀ : ℝ≥0),\n  ∀ (S : Profinite) (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    ​((BD.data.system κ r V r').obj (op $ of r' ((Lbar.functor.{0 0} r').obj S)))\n      .is_bounded_exact k K m c₀ :=\nbegin\n  intro m,\n  obtain ⟨k, K, hk, c₀, H⟩ := thm94_weak r r' BD κ m,\n  resetI,\n  refine ⟨k ^ 2, K + 1, infer_instance, c₀, _⟩,\n  introsI,\n  refine system_of_complexes.is_weak_bounded_exact.strong_of_complete _ (H _ _) _ _ zero_lt_one,\n  apply breen_deligne.data.system_admissible,\nend\n\n/-- Theorem 9.4 in [Analytic] for weak bounded exactness -/\ntheorem thm94_weak' :\n  ∀ m : ℕ, ∃ (k K : ℝ≥0) (hk : fact (1 ≤ k)) (c₀ : ℝ≥0),\n  ∀ (S : Profinite) (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    ​((BD.data.system κ r V r').obj (op $ of r' ((Lbar.functor.{0 0} r').obj S)))\n      .is_weak_bounded_exact k K m c₀ :=\nbegin\n  intro m,\n  obtain ⟨k, K, hk, H⟩ := thm95''.profinite BD r r' κ m,\n  obtain ⟨c₀, H⟩ := H ℤ,\n  use [k, K, hk, c₀],\n  introsI S V hV,\n  specialize H S V,\n  let i := (BD.data.system κ r V r').map_iso (HomZ_iso (of r' $ (Lbar.functor.{0 0} r').obj S)).op,\n  refine H.of_iso i.symm _,\n  intros c n,\n  rw ← system_of_complexes.apply_hom_eq_hom_apply,\n  apply SemiNormedGroup.iso_isometry_of_norm_noninc;\n  apply breen_deligne.data.complex.map_norm_noninc\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/liquid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.45765615083809297}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module set_theory.lists\n! leanprover-community/mathlib commit 497d1e06409995dd8ec95301fa8d8f3480187f4c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.List.Basic\n\n/-!\n# A computable model of ZFA without infinity\n\nIn this file we define finite hereditary lists. This is useful for calculations in naive set theory.\n\nWe distinguish two kinds of ZFA lists:\n* Atoms. Directly correspond to an element of the original type.\n* Proper ZFA lists. Can be thought of (but aren't implemented) as a list of ZFA lists (not\n  necessarily proper).\n\nFor example, `Lists ℕ` contains stuff like `23`, `[]`, `[37]`, `[1, [[2], 3], 4]`.\n\n## Implementation note\n\nAs we want to be able to append both atoms and proper ZFA lists to proper ZFA lists, it's handy that\natoms and proper ZFA lists belong to the same type, even though atoms of `α` could be modelled as\n`α` directly. But we don't want to be able to append anything to atoms.\n\nThis calls for a two-steps definition of ZFA lists:\n* First, define ZFA prelists as atoms and proper ZFA prelists. Those proper ZFA prelists are defined\n  by inductive appending of (not necessarily proper) ZFA lists.\n* Second, define ZFA lists by rubbing out the distinction between atoms and proper lists.\n\n## Main declarations\n\n* `Lists' α false`: Atoms as ZFA prelists. Basically a copy of `α`.\n* `Lists' α true`: Proper ZFA prelists. Defined inductively from the empty ZFA prelist\n  (`Lists'.nil`) and from appending a ZFA prelist to a proper ZFA prelist (`Lists'.cons a l`).\n* `Lists α`: ZFA lists. Sum of the atoms and proper ZFA prelists.\n* `Finsets α`: ZFA sets. Defined as `Lists` quotiented by `Lists.Equiv`, the extensional\n  equivalence.\n-/\n\n\nvariable {α : Type _}\n\n/-- Prelists, helper type to define `Lists`. `Lists' α false` are the \"atoms\", a copy of `α`.\n`Lists' α true` are the \"proper\" ZFA prelists, inductively defined from the empty ZFA prelist and\nfrom appending a ZFA prelist to a proper ZFA prelist. It is made so that you can't append anything\nto an atom while having only one appending function for appending both atoms and proper ZFC prelists\nto a proper ZFA prelist. -/\ninductive Lists'.{u} (α : Type u) : Bool → Type u\n  | atom : α → Lists' α false\n  | nil : Lists' α true\n  | cons' {b} : Lists' α b → Lists' α true → Lists' α true\n  deriving DecidableEq\n#align lists' Lists'\n\n/-- Hereditarily finite list, aka ZFA list. A ZFA list is either an \"atom\" (`b = false`),\ncorresponding to an element of `α`, or a \"proper\" ZFA list, inductively defined from the empty ZFA\nlist and from appending a ZFA list to a proper ZFA list. -/\ndef Lists (α : Type _) :=\n  Σb, Lists' α b\n#align lists Lists\n\nnamespace Lists'\n\ninstance [Inhabited α] : ∀ b, Inhabited (Lists' α b)\n  | true => ⟨nil⟩\n  | false => ⟨atom default⟩\n\n/-- Appending a ZFA list to a proper ZFA prelist. -/\ndef cons : Lists α → Lists' α true → Lists' α true\n  | ⟨_, a⟩, l => cons' a l\n#align lists'.cons Lists'.cons\n\n/-- Converts a ZFA prelist to a `List` of ZFA lists. Atoms are sent to `[]`. -/\n@[simp]\ndef toList : ∀ {b}, Lists' α b → List (Lists α)\n  | _, atom _ => []\n  | _, nil => []\n  | _, cons' a l => ⟨_, a⟩ :: l.toList\n#align lists'.to_list Lists'.toList\n\n-- porting notes: removed @[simp]\n-- simp can prove this: by simp only [@Lists'.toList, @Sigma.eta]\ntheorem toList_cons (a : Lists α) (l) : toList (cons a l) = a :: l.toList := by simp\n#align lists'.to_list_cons Lists'.toList_cons\n\n/-- Converts a `List` of ZFA lists to a proper ZFA prelist. -/\n@[simp]\ndef ofList : List (Lists α) → Lists' α true\n  | [] => nil\n  | a :: l => cons a (ofList l)\n#align lists'.of_list Lists'.ofList\n\n@[simp]\ntheorem to_ofList (l : List (Lists α)) : toList (ofList l) = l := by induction l <;> simp [*]\n#align lists'.to_of_list Lists'.to_ofList\n\n@[simp]\ntheorem of_toList : ∀ l : Lists' α true, ofList (toList l) = l :=\n  suffices\n    ∀ (b) (h : true = b) (l : Lists' α b),\n      let l' : Lists' α true := by rw [h]; exact l\n      ofList (toList l') = l'\n    from this _ rfl\n  fun b h l => by\n    induction l with\n    | atom => cases h\n    -- Porting note: case nil was not covered.\n    | nil => simp\n    | cons' b a _ IH =>\n      intro l'\n      -- Porting note: Previous code was:\n      -- change l' with cons' a l\n      --\n      -- This can be removed.\n      simpa [cons] using IH rfl\n#align lists'.of_to_list Lists'.of_toList\n\nend Lists'\n\nmutual\n  inductive Lists.Equiv : Lists α → Lists α → Prop\n    | refl (l) : Lists.Equiv l l\n    | antisymm {l₁ l₂ : Lists' α true} :\n      Lists'.Subset l₁ l₂ → Lists'.Subset l₂ l₁ → Lists.Equiv ⟨_, l₁⟩ ⟨_, l₂⟩\n  inductive Lists'.Subset : Lists' α true → Lists' α true → Prop\n    | nil {l} : Lists'.Subset Lists'.nil l\n    | cons {a a' l l'} :\n      Lists.Equiv a a' →\n        a' ∈ Lists'.toList l' → Lists'.Subset l l' → Lists'.Subset (Lists'.cons a l) l'\nend\n#align lists.equiv Lists.Equiv\n#align lists'.subset Lists'.Subset\n\nlocal infixl:50 \" ~ \" => Lists.Equiv\n\n/-- Equivalence of ZFA lists. Defined inductively. -/\nadd_decl_doc Lists.Equiv\n\n/-- Subset relation for ZFA lists. Defined inductively. -/\nadd_decl_doc Lists'.Subset\n\nnamespace Lists'\n\ninstance : HasSubset (Lists' α true) :=\n  ⟨Lists'.Subset⟩\n\n/-- ZFA prelist membership. A ZFA list is in a ZFA prelist if some element of this ZFA prelist is\nequivalent as a ZFA list to this ZFA list. -/\ninstance {b} : Membership (Lists α) (Lists' α b) :=\n  ⟨fun a l => ∃ a' ∈ l.toList, a ~ a'⟩\n\ntheorem mem_def {b a} {l : Lists' α b} : a ∈ l ↔ ∃ a' ∈ l.toList, a ~ a' :=\n  Iff.rfl\n#align lists'.mem_def Lists'.mem_def\n\n@[simp]\ntheorem mem_cons {a y l} : a ∈ @cons α y l ↔ a ~ y ∨ a ∈ l := by\n  simp [mem_def, or_and_right, exists_or]\n#align lists'.mem_cons Lists'.mem_cons\n\ntheorem cons_subset {a} {l₁ l₂ : Lists' α true} : Lists'.cons a l₁ ⊆ l₂ ↔ a ∈ l₂ ∧ l₁ ⊆ l₂ := by\n  refine' ⟨fun h => _, fun ⟨⟨a', m, e⟩, s⟩ => Subset.cons e m s⟩\n  generalize h' : Lists'.cons a l₁ = l₁' at h\n  cases' h with l a' a'' l l' e m s;\n  · cases a\n    cases h'\n  cases a; cases a'; cases h'; exact ⟨⟨_, m, e⟩, s⟩\n#align lists'.cons_subset Lists'.cons_subset\n\ntheorem ofList_subset {l₁ l₂ : List (Lists α)} (h : l₁ ⊆ l₂) :\n    Lists'.ofList l₁ ⊆ Lists'.ofList l₂ := by\n  induction' l₁ with _ _ l₁_ih; · exact Subset.nil\n  refine' Subset.cons (Lists.Equiv.refl _) _ (l₁_ih (List.subset_of_cons_subset h))\n  simp at h; simp [h]\n#align lists'.of_list_subset Lists'.ofList_subset\n\n@[refl]\ntheorem Subset.refl {l : Lists' α true} : l ⊆ l := by\n  rw [← Lists'.of_toList l]; exact ofList_subset (List.Subset.refl _)\n#align lists'.subset.refl Lists'.Subset.refl\n\ntheorem subset_nil {l : Lists' α true} : l ⊆ Lists'.nil → l = Lists'.nil := by\n  rw [← of_toList l]\n  induction toList l <;> intro h\n  · rfl\n  · rcases cons_subset.1 h with ⟨⟨_, ⟨⟩, _⟩, _⟩\n#align lists'.subset_nil Lists'.subset_nil\n\n\n\ntheorem subset_def {l₁ l₂ : Lists' α true} : l₁ ⊆ l₂ ↔ ∀ a ∈ l₁.toList, a ∈ l₂ :=\n  ⟨fun H a => mem_of_subset' H, fun H =>\n    by\n    rw [← of_toList l₁]\n    revert H; induction' toList l₁ with h t t_ih <;> intro H\n    · exact Subset.nil\n    · simp only [ofList, List.find?, List.mem_cons, forall_eq_or_imp] at *\n      exact cons_subset.2 ⟨H.1, t_ih H.2⟩⟩\n#align lists'.subset_def Lists'.subset_def\n\nend Lists'\n\nnamespace Lists\n\n/-- Sends `a : α` to the corresponding atom in `Lists α`. -/\n@[match_pattern]\ndef atom (a : α) : Lists α :=\n  ⟨_, Lists'.atom a⟩\n#align lists.atom Lists.atom\n\n/-- Converts a proper ZFA prelist to a ZFA list. -/\n@[match_pattern]\ndef of' (l : Lists' α true) : Lists α :=\n  ⟨_, l⟩\n#align lists.of' Lists.of'\n\n/-- Converts a ZFA list to a `List` of ZFA lists. Atoms are sent to `[]`. -/\n@[simp]\ndef toList : Lists α → List (Lists α)\n  | ⟨_, l⟩ => l.toList\n#align lists.to_list Lists.toList\n\n/-- Predicate stating that a ZFA list is proper. -/\ndef IsList (l : Lists α) : Prop :=\n  l.1\n#align lists.is_list Lists.IsList\n\n/-- Converts a `List` of ZFA lists to a ZFA list. -/\ndef ofList (l : List (Lists α)) : Lists α :=\n  of' (Lists'.ofList l)\n#align lists.of_list Lists.ofList\n\ntheorem isList_toList (l : List (Lists α)) : IsList (ofList l) :=\n  Eq.refl _\n#align lists.is_list_to_list Lists.isList_toList\n\ntheorem to_ofList (l : List (Lists α)) : toList (ofList l) = l := by simp [ofList, of']\n#align lists.to_of_list Lists.to_ofList\n\ntheorem of_toList : ∀ {l : Lists α}, IsList l → ofList (toList l) = l\n  | ⟨true, l⟩, _ => by simp_all [ofList, of']\n#align lists.of_to_list Lists.of_toList\n\ninstance : Inhabited (Lists α) :=\n  ⟨of' Lists'.nil⟩\n\ninstance [DecidableEq α] : DecidableEq (Lists α) := by unfold Lists; infer_instance\n\n-- Porting note: 'Lists'._sizeOf_inst' does not have executable code.\n-- So noncomputable is added.\nnoncomputable instance [SizeOf α] : SizeOf (Lists α) := by unfold Lists; infer_instance\n\n-- Porting note: Made noncomputable because code generator does not support recursor\n-- Lists'.rec yet\n/-- A recursion principle for pairs of ZFA lists and proper ZFA prelists. -/\nnoncomputable def inductionMut (C : Lists α → Sort _) (D : Lists' α true → Sort _)\n    (C0 : ∀ a, C (atom a)) (C1 : ∀ l, D l → C (of' l))\n    (D0 : D Lists'.nil) (D1 : ∀ a l, C a → D l → D (Lists'.cons a l)) :\n    PProd (∀ l, C l) (∀ l, D l) := by\n  suffices\n    ∀ {b} (l : Lists' α b),\n      PProd (C ⟨_, l⟩)\n        (match b, l with\n        | true, l => D l\n        | false, _ => PUnit)\n    by exact ⟨fun ⟨b, l⟩ => (this _).1, fun l => (this l).2⟩\n  intros b l\n  induction' l with a b a l IH₁ IH\n  · exact ⟨C0 _, ⟨⟩⟩\n  · exact ⟨C1 _ D0, D0⟩\n  · have : D (Lists'.cons' a l) := D1 ⟨_, _⟩ _ IH₁.1 IH.2\n    exact ⟨C1 _ this, this⟩\n#align lists.induction_mut Lists.inductionMut\n\n/-- Membership of ZFA list. A ZFA list belongs to a proper ZFA list if it belongs to the latter as a\nproper ZFA prelist. An atom has no members. -/\ndef mem (a : Lists α) : Lists α → Prop\n  | ⟨false, _⟩ => False\n  | ⟨_, l⟩ => a ∈ l\n#align lists.mem Lists.mem\n\ninstance : Membership (Lists α) (Lists α) :=\n  ⟨mem⟩\n\ntheorem isList_of_mem {a : Lists α} : ∀ {l : Lists α}, a ∈ l → IsList l\n  | ⟨_, Lists'.nil⟩, _ => rfl\n  | ⟨_, Lists'.cons' _ _⟩, _ => rfl\n#align lists.is_list_of_mem Lists.isList_of_mem\n\ntheorem Equiv.antisymm_iff {l₁ l₂ : Lists' α true} : of' l₁ ~ of' l₂ ↔ l₁ ⊆ l₂ ∧ l₂ ⊆ l₁ := by\n  refine' ⟨fun h => _, fun ⟨h₁, h₂⟩ => Equiv.antisymm h₁ h₂⟩\n  cases' h with _ _ _ h₁ h₂\n  · simp [Lists'.Subset.refl]\n  . exact ⟨h₁, h₂⟩\n#align lists.equiv.antisymm_iff Lists.Equiv.antisymm_iff\n\nattribute [refl] Equiv.refl\n\ntheorem equiv_atom {a} {l : Lists α} : atom a ~ l ↔ atom a = l :=\n  ⟨fun h => by cases h; rfl, fun h => h ▸ Equiv.refl _⟩\n#align lists.equiv_atom Lists.equiv_atom\n\ntheorem Equiv.symm {l₁ l₂ : Lists α} (h : l₁ ~ l₂) : l₂ ~ l₁ := by\n  cases' h with _ _ _ h₁ h₂ <;> [rfl, exact Equiv.antisymm h₂ h₁]\n#align lists.equiv.symm Lists.Equiv.symm\n\ntheorem Equiv.trans : ∀ {l₁ l₂ l₃ : Lists α}, l₁ ~ l₂ → l₂ ~ l₃ → l₁ ~ l₃ := by\n  let trans := fun l₁ : Lists α => ∀ ⦃l₂ l₃⦄, l₁ ~ l₂ → l₂ ~ l₃ → l₁ ~ l₃\n  suffices PProd (∀ l₁, trans l₁) (∀ (l : Lists' α true), ∀ l' ∈ l.toList, trans l') by exact this.1\n  apply inductionMut\n  · intro a l₂ l₃ h₁ h₂\n    rwa [← equiv_atom.1 h₁] at h₂\n  · intro l₁ IH l₂ l₃ h₁ h₂\n    -- Porting note: Two 'have's are for saving the state.\n    have h₁' := h₁\n    have h₂' := h₂\n    cases' h₁ with _ _ l₂\n    · exact h₂\n    cases' h₂ with _ _ l₃\n    · exact h₁'\n    cases' Equiv.antisymm_iff.1 h₁' with hl₁ hr₁\n    cases' Equiv.antisymm_iff.1 h₂' with hl₂ hr₂\n    apply Equiv.antisymm_iff.2; constructor <;> apply Lists'.subset_def.2\n    · intro a₁ m₁\n      rcases Lists'.mem_of_subset' hl₁ m₁ with ⟨a₂, m₂, e₁₂⟩\n      rcases Lists'.mem_of_subset' hl₂ m₂ with ⟨a₃, m₃, e₂₃⟩\n      exact ⟨a₃, m₃, IH _ m₁ e₁₂ e₂₃⟩\n    · intro a₃ m₃\n      rcases Lists'.mem_of_subset' hr₂ m₃ with ⟨a₂, m₂, e₃₂⟩\n      rcases Lists'.mem_of_subset' hr₁ m₂ with ⟨a₁, m₁, e₂₁⟩\n      exact ⟨a₁, m₁, (IH _ m₁ e₂₁.symm e₃₂.symm).symm⟩\n  · rintro _ ⟨⟩\n  · intro a l IH₁ IH\n    -- Porting note: Previous code was:\n    -- simpa [IH₁] using IH\n    --\n    -- Assumption fails.\n    simp only [Lists'.toList, Sigma.eta, List.find?, List.mem_cons, forall_eq_or_imp]\n    constructor\n    . intros l₂ l₃ h₁ h₂\n      exact IH₁ h₁ h₂\n    . intros a h₁ l₂ l₃ h₂ h₃\n      exact IH _ h₁ h₂ h₃\n#align lists.equiv.trans Lists.Equiv.trans\n\ninstance : Setoid (Lists α) :=\n  ⟨(· ~ ·), Equiv.refl, @Equiv.symm _, @Equiv.trans _⟩\n\nsection Decidable\n\n-- porting note: Noncomputable because Lists.instSizeOfLists is\n/-- Auxillary function to prove termination of decidability checking -/\n@[simp]\nnoncomputable def Equiv.decidableMeas :\n    (PSum (Σ' _l₁ : Lists α, Lists α) <|\n        PSum (Σ' _l₁ : Lists' α true, Lists' α true) (Σ' _a : Lists α, Lists' α true)) →\n      ℕ\n  | PSum.inl ⟨l₁, l₂⟩ => SizeOf.sizeOf l₁ + SizeOf.sizeOf l₂\n  | PSum.inr <| PSum.inl ⟨l₁, l₂⟩ => SizeOf.sizeOf l₁ + SizeOf.sizeOf l₂\n  | PSum.inr <| PSum.inr ⟨l₁, l₂⟩ => SizeOf.sizeOf l₁ + SizeOf.sizeOf l₂\n#align lists.equiv.decidable_meas Lists.Equiv.decidableMeas\n\ntheorem sizeof_pos {b} (l : Lists' α b) : 0 < SizeOf.sizeOf l := by\n  cases l <;> simp only [Lists'.atom.sizeOf_spec, Lists'.nil.sizeOf_spec, Lists'.cons'.sizeOf_spec,\n    true_or, add_pos_iff]\n#align lists.sizeof_pos Lists.sizeof_pos\n\ntheorem lt_sizeof_cons' {b} (a : Lists' α b) (l) :\n    SizeOf.sizeOf (⟨b, a⟩ : Lists α) < SizeOf.sizeOf (Lists'.cons' a l) := by\n  simp only [Sigma.mk.sizeOf_spec, Lists'.cons'.sizeOf_spec, lt_add_iff_pos_right]\n  apply sizeof_pos\n#align lists.lt_sizeof_cons' Lists.lt_sizeof_cons'\n\nvariable [DecidableEq α]\n\nmutual\n  instance Equiv.decidable : ∀ l₁ l₂ : Lists α, Decidable (l₁ ~ l₂)\n    | ⟨false, l₁⟩, ⟨false, l₂⟩ =>\n      decidable_of_iff' (l₁ = l₂) <| by\n        cases l₁\n        apply equiv_atom.trans\n        simp [atom]\n        constructor <;> (rintro ⟨rfl⟩; rfl)\n    | ⟨false, l₁⟩, ⟨true, l₂⟩ => isFalse <| by rintro ⟨⟩\n    | ⟨true, l₁⟩, ⟨false, l₂⟩ => isFalse <| by rintro ⟨⟩\n    | ⟨true, l₁⟩, ⟨true, l₂⟩ => by\n      haveI : Decidable (l₁ ⊆ l₂) :=\n        have : SizeOf.sizeOf l₁ + SizeOf.sizeOf l₂ <\n            SizeOf.sizeOf (⟨true, l₁⟩ : Lists α) + SizeOf.sizeOf (⟨true, l₂⟩ : Lists α) :=\n          by decreasing_tactic\n        Subset.decidable l₁ l₂\n      haveI : Decidable (l₂ ⊆ l₁) :=\n        have : SizeOf.sizeOf l₂ + SizeOf.sizeOf l₁ <\n            SizeOf.sizeOf (⟨true, l₁⟩ : Lists α) + SizeOf.sizeOf (⟨true, l₂⟩ : Lists α) :=\n          by decreasing_tactic\n        Subset.decidable l₂ l₁\n      exact decidable_of_iff' _ Equiv.antisymm_iff\n  instance Subset.decidable  : ∀ l₁ l₂ : Lists' α true, Decidable (l₁ ⊆ l₂)\n    | Lists'.nil, l₂ => isTrue Lists'.Subset.nil\n    | @Lists'.cons' _ b a l₁, l₂ => by\n      haveI :=\n        have : sizeOf (⟨b, a⟩ : Lists α) < 1 + 1 + sizeOf a + sizeOf l₁ := by simp [sizeof_pos]\n        mem.decidable ⟨b, a⟩ l₂\n      haveI :=\n        have : SizeOf.sizeOf l₁ + SizeOf.sizeOf l₂ <\n            SizeOf.sizeOf (Lists'.cons' a l₁) + SizeOf.sizeOf l₂ :=\n          by decreasing_tactic\n        Subset.decidable l₁ l₂\n      exact decidable_of_iff' _ (@Lists'.cons_subset _ ⟨_, _⟩ _ _)\n  instance mem.decidable  : ∀ (a : Lists α) (l : Lists' α true), Decidable (a ∈ l)\n    | a, Lists'.nil => isFalse <| by rintro ⟨_, ⟨⟩, _⟩\n    | a, Lists'.cons' b l₂ => by\n      haveI :=\n        have : sizeOf (⟨_, b⟩ : Lists α) < 1 + 1 + sizeOf b + sizeOf l₂ := by simp [sizeof_pos]\n        Equiv.decidable a ⟨_, b⟩\n      haveI :=\n        have :\n          SizeOf.sizeOf a + SizeOf.sizeOf l₂ <\n            SizeOf.sizeOf a + SizeOf.sizeOf (Lists'.cons' b l₂) :=\n          by decreasing_tactic\n        mem.decidable a l₂\n      refine' decidable_of_iff' (a ~ ⟨_, b⟩ ∨ a ∈ l₂) _\n      rw [← Lists'.mem_cons]; rfl\nend termination_by' ⟨_, InvImage.wf Equiv.decidableMeas Nat.lt_wfRel.wf⟩\n#align lists.equiv.decidable Lists.Equiv.decidable\n#align lists.subset.decidable Lists.Subset.decidable\n#align lists.mem.decidable Lists.mem.decidable\n\nend Decidable\n\nend Lists\n\nnamespace Lists'\n\ntheorem mem_equiv_left {l : Lists' α true} : ∀ {a a'}, a ~ a' → (a ∈ l ↔ a' ∈ l) :=\n  suffices ∀ {a a'}, a ~ a' → a ∈ l → a' ∈ l from fun e => ⟨this e, this e.symm⟩\n  fun e₁ ⟨_, m₃, e₂⟩ => ⟨_, m₃, e₁.symm.trans e₂⟩\n#align lists'.mem_equiv_left Lists'.mem_equiv_left\n\ntheorem mem_of_subset {a} {l₁ l₂ : Lists' α true} (s : l₁ ⊆ l₂) : a ∈ l₁ → a ∈ l₂\n  | ⟨_, m, e⟩ => (mem_equiv_left e).2 (mem_of_subset' s m)\n#align lists'.mem_of_subset Lists'.mem_of_subset\n\ntheorem Subset.trans {l₁ l₂ l₃ : Lists' α true} (h₁ : l₁ ⊆ l₂) (h₂ : l₂ ⊆ l₃) : l₁ ⊆ l₃ :=\n  subset_def.2 fun _ m₁ => mem_of_subset h₂ <| mem_of_subset' h₁ m₁\n#align lists'.subset.trans Lists'.Subset.trans\n\nend Lists'\n\n/-- `Finsets` are defined via equivalence classes of `Lists` -/\ndef Finsets (α : Type _) :=\n  Quotient (@Lists.instSetoidLists α)\n#align finsets Finsets\n\nnamespace Finsets\n\ninstance : EmptyCollection (Finsets α) :=\n  ⟨⟦Lists.of' Lists'.nil⟧⟩\n\ninstance : Inhabited (Finsets α) :=\n  ⟨∅⟩\n\ninstance [DecidableEq α] : DecidableEq (Finsets α) := by\n  unfold Finsets\n  -- porting notes: infer_instance does not work for some reason\n  exact (Quotient.decidableEq (d := fun _ _ => Lists.Equiv.decidable _ _))\n\nend Finsets\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/SetTheory/Lists.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.4575963623450355}}
{"text": "/-\nCopyright (c) 2019 Jean Lo. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jean Lo\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.pointwise\nimport Mathlib.analysis.normed_space.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l \n\nnamespace Mathlib\n\n/-!\n# Seminorms and Local Convexity\n\nThis file introduces the following notions, defined for a vector space\nover a normed field:\n\n- the subset properties of being `absorbent` and `balanced`,\n\n- a `seminorm`, a function to the reals that is positive-semidefinite,\n  absolutely homogeneous, and subadditive.\n\nWe prove related properties.\n\n## TODO\n\nDefine and show equivalence of two notions of local convexity for a\ntopological vector space over ℝ or ℂ: that it has a local base of\nbalanced convex absorbent sets, and that it carries the initial\ntopology induced by a family of seminorms.\n\n## References\n* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]\n-/\n\n/-!\n### Subset Properties\n\nAbsorbent and balanced sets in a vector space over a\nnondiscrete normed field.\n-/\n\n/-- A set `A` absorbs another set `B` if `B` is contained in scaling\n`A` by elements of sufficiently large norms. -/\ndef absorbs (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (A : set E) (B : set E) :=\n  ∃ (r : ℝ), ∃ (H : r > 0), ∀ (a : 𝕜), r ≤ norm a → B ⊆ a • A\n\n/-- A set is absorbent if it absorbs every singleton. -/\ndef absorbent (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (A : set E) :=\n  ∀ (x : E), ∃ (r : ℝ), ∃ (H : r > 0), ∀ (a : 𝕜), r ≤ norm a → x ∈ a • A\n\n/-- A set `A` is balanced if `a • A` is contained in `A` whenever `a`\nhas norm no greater than one. -/\ndef balanced (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (A : set E) :=\n  ∀ (a : 𝕜), norm a ≤ 1 → a • A ⊆ A\n\n/-- A balanced set absorbs itself. -/\ntheorem balanced.absorbs_self {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] {A : set E} (hA : balanced 𝕜 A) : absorbs 𝕜 A A :=\n  sorry\n\n/-!\nProperties of balanced and absorbing sets in a topological vector space:\n-/\n\n/-- Every neighbourhood of the origin is absorbent. -/\ntheorem absorbent_nhds_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E]\n    [topological_vector_space 𝕜 E] (hA : A ∈ nhds 0) : absorbent 𝕜 A :=\n  sorry\n\n/-- The union of `{0}` with the interior of a balanced set\n    is balanced. -/\ntheorem balanced_zero_union_interior {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E]\n    [topological_vector_space 𝕜 E] (hA : balanced 𝕜 A) : balanced 𝕜 (singleton 0 ∪ interior A) :=\n  sorry\n\n/-- The interior of a balanced set is balanced if it contains the origin. -/\ntheorem balanced.interior {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E]\n    [topological_vector_space 𝕜 E] (hA : balanced 𝕜 A) (h : 0 ∈ interior A) :\n    balanced 𝕜 (interior A) :=\n  sorry\n\n/-- The closure of a balanced set is balanced. -/\ntheorem balanced.closure {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] {A : set E} [topological_space E]\n    [topological_vector_space 𝕜 E] (hA : balanced 𝕜 A) : balanced 𝕜 (closure A) :=\n  sorry\n\n/-!\n### Seminorms\n-/\n\n/-- A seminorm on a vector space over a normed field is a function to\nthe reals that is positive semidefinite, positive homogeneous, and\nsubadditive. -/\nstructure seminorm (𝕜 : Type u_1) (E : Type u_2) [normed_field 𝕜] [add_comm_group E]\n    [vector_space 𝕜 E]\n    where\n  to_fun : E → ℝ\n  smul' : ∀ (a : 𝕜) (x : E), to_fun (a • x) = norm a * to_fun x\n  triangle' : ∀ (x y : E), to_fun (x + y) ≤ to_fun x + to_fun y\n\nprotected instance seminorm.inhabited {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] : Inhabited (seminorm 𝕜 E) :=\n  { default := seminorm.mk (fun (_x : E) => 0) sorry sorry }\n\nprotected instance seminorm.has_coe_to_fun {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [add_comm_group E] [vector_space 𝕜 E] : has_coe_to_fun (seminorm 𝕜 E) :=\n  has_coe_to_fun.mk (fun (p : seminorm 𝕜 E) => E → ℝ) fun (p : seminorm 𝕜 E) => seminorm.to_fun p\n\nnamespace seminorm\n\n\nprotected theorem smul {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (p : seminorm 𝕜 E) (c : 𝕜) (x : E) :\n    coe_fn p (c • x) = norm c * coe_fn p x :=\n  smul' p c x\n\nprotected theorem triangle {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (y : E) :\n    coe_fn p (x + y) ≤ coe_fn p x + coe_fn p y :=\n  triangle' p x y\n\n@[simp] protected theorem zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) : coe_fn p 0 = 0 :=\n  sorry\n\n@[simp] protected theorem neg {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) : coe_fn p (-x) = coe_fn p x :=\n  sorry\n\ntheorem nonneg {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) : 0 ≤ coe_fn p x :=\n  sorry\n\ntheorem sub_rev {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (y : E) : coe_fn p (x - y) = coe_fn p (y - x) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn p (x - y) = coe_fn p (y - x))) (Eq.symm (neg_sub y x))))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (coe_fn p (-(y - x)) = coe_fn p (y - x))) (seminorm.neg p (y - x))))\n      (Eq.refl (coe_fn p (y - x))))\n\n/-- The ball of radius `r` at `x` with respect to seminorm `p`\n    is the set of elements `y` with `p (y - x) < `r`. -/\ndef ball {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (r : ℝ) : set E :=\n  set_of fun (y : E) => coe_fn p (y - x) < r\n\ntheorem mem_ball {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (p : seminorm 𝕜 E) (x : E) (y : E) (r : ℝ) :\n    y ∈ ball p x r ↔ coe_fn p (y - x) < r :=\n  iff.rfl\n\ntheorem mem_ball_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (p : seminorm 𝕜 E) (y : E) (r : ℝ) : y ∈ ball p 0 r ↔ coe_fn p y < r :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (y ∈ ball p 0 r ↔ coe_fn p y < r)) (propext (mem_ball p 0 y r))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn p (y - 0) < r ↔ coe_fn p y < r)) (sub_zero y)))\n      (iff.refl (coe_fn p y < r)))\n\ntheorem ball_zero_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [add_comm_group E]\n    [vector_space 𝕜 E] (p : seminorm 𝕜 E) (r : ℝ) :\n    ball p 0 r = set_of fun (y : E) => coe_fn p y < r :=\n  sorry\n\n/-- Seminorm-balls at the origin are balanced. -/\ntheorem balanced_ball_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [add_comm_group E] [vector_space 𝕜 E] (p : seminorm 𝕜 E) (r : ℝ) : balanced 𝕜 (ball p 0 r) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/seminorm_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.4575963623450355}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n\n! This file was ported from Lean 3 source module algebra.group.opposite\n! leanprover-community/mathlib commit 76de8ae01554c3b37d66544866659ff174e66e1f\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Group.InjSurj\nimport Mathbin.Algebra.Group.Commute\nimport Mathbin.Algebra.Hom.Equiv.Basic\nimport Mathbin.Algebra.Opposites\nimport Mathbin.Data.Int.Cast.Defs\n\n/-!\n# Group structures on the multiplicative and additive opposites\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nuniverse u v\n\nvariable (α : Type u)\n\nnamespace MulOpposite\n\n/-!\n### Additive structures on `αᵐᵒᵖ`\n-/\n\n\n@[to_additive]\ninstance [NatCast α] : NatCast αᵐᵒᵖ :=\n  ⟨fun n => op n⟩\n\n@[to_additive]\ninstance [IntCast α] : IntCast αᵐᵒᵖ :=\n  ⟨fun n => op n⟩\n\ninstance [AddSemigroup α] : AddSemigroup αᵐᵒᵖ :=\n  unop_injective.AddSemigroup _ fun x y => rfl\n\ninstance [AddLeftCancelSemigroup α] : AddLeftCancelSemigroup αᵐᵒᵖ :=\n  unop_injective.AddLeftCancelSemigroup _ fun x y => rfl\n\ninstance [AddRightCancelSemigroup α] : AddRightCancelSemigroup αᵐᵒᵖ :=\n  unop_injective.AddRightCancelSemigroup _ fun x y => rfl\n\ninstance [AddCommSemigroup α] : AddCommSemigroup αᵐᵒᵖ :=\n  unop_injective.AddCommSemigroup _ fun x y => rfl\n\ninstance [AddZeroClass α] : AddZeroClass αᵐᵒᵖ :=\n  unop_injective.AddZeroClass _ rfl fun x y => rfl\n\ninstance [AddMonoid α] : AddMonoid αᵐᵒᵖ :=\n  unop_injective.AddMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddCommMonoid α] : AddCommMonoid αᵐᵒᵖ :=\n  unop_injective.AddCommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddMonoidWithOne α] : AddMonoidWithOne αᵐᵒᵖ :=\n  { MulOpposite.addMonoid α, MulOpposite.hasOne α,\n    MulOpposite.hasNatCast\n      _ with\n    natCast_zero := show op ((0 : ℕ) : α) = 0 by rw [Nat.cast_zero, op_zero]\n    natCast_succ := show ∀ n, op ((n + 1 : ℕ) : α) = op (n : ℕ) + 1 by simp }\n\ninstance [AddCommMonoidWithOne α] : AddCommMonoidWithOne αᵐᵒᵖ :=\n  { MulOpposite.addMonoidWithOne α, MulOpposite.addCommMonoid α with }\n\ninstance [SubNegMonoid α] : SubNegMonoid αᵐᵒᵖ :=\n  unop_injective.SubNegMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddGroup α] : AddGroup αᵐᵒᵖ :=\n  unop_injective.AddGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    fun _ _ => rfl\n\ninstance [AddCommGroup α] : AddCommGroup αᵐᵒᵖ :=\n  unop_injective.AddCommGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddGroupWithOne α] : AddGroupWithOne αᵐᵒᵖ :=\n  { MulOpposite.addMonoidWithOne α,\n    MulOpposite.addGroup α with\n    intCast := fun n => op n\n    intCast_ofNat := fun n => show op ((n : ℤ) : α) = op n by rw [Int.cast_ofNat]\n    intCast_negSucc := fun n =>\n      show op _ = op (-unop (op ((n + 1 : ℕ) : α))) by erw [unop_op, Int.cast_negSucc] <;> rfl }\n\ninstance [AddCommGroupWithOne α] : AddCommGroupWithOne αᵐᵒᵖ :=\n  { MulOpposite.addGroupWithOne α, MulOpposite.addCommGroup α with }\n\n/-!\n### Multiplicative structures on `αᵐᵒᵖ`\n\nWe also generate additive structures on `αᵃᵒᵖ` using `to_additive`\n-/\n\n\n@[to_additive]\ninstance [Semigroup α] : Semigroup αᵐᵒᵖ :=\n  { MulOpposite.hasMul α with\n    mul_assoc := fun x y z => unop_injective <| Eq.symm <| mul_assoc (unop z) (unop y) (unop x) }\n\n@[to_additive]\ninstance [RightCancelSemigroup α] : LeftCancelSemigroup αᵐᵒᵖ :=\n  { MulOpposite.semigroup α with\n    mul_left_cancel := fun x y z H => unop_injective <| mul_right_cancel <| op_injective H }\n\n@[to_additive]\ninstance [LeftCancelSemigroup α] : RightCancelSemigroup αᵐᵒᵖ :=\n  { MulOpposite.semigroup α with\n    mul_right_cancel := fun x y z H => unop_injective <| mul_left_cancel <| op_injective H }\n\n@[to_additive]\ninstance [CommSemigroup α] : CommSemigroup αᵐᵒᵖ :=\n  { MulOpposite.semigroup α with\n    mul_comm := fun x y => unop_injective <| mul_comm (unop y) (unop x) }\n\n@[to_additive]\ninstance [MulOneClass α] : MulOneClass αᵐᵒᵖ :=\n  { MulOpposite.hasMul α,\n    MulOpposite.hasOne\n      α with\n    one_mul := fun x => unop_injective <| mul_one <| unop x\n    mul_one := fun x => unop_injective <| one_mul <| unop x }\n\n@[to_additive]\ninstance [Monoid α] : Monoid αᵐᵒᵖ :=\n  { MulOpposite.semigroup α,\n    MulOpposite.mulOneClass α with\n    npow := fun n x => op <| x.unop ^ n\n    npow_zero := fun x => unop_injective <| Monoid.npow_zero x.unop\n    npow_succ := fun n x => unop_injective <| pow_succ' x.unop n }\n\n@[to_additive]\ninstance [RightCancelMonoid α] : LeftCancelMonoid αᵐᵒᵖ :=\n  { MulOpposite.leftCancelSemigroup α, MulOpposite.monoid α with }\n\n@[to_additive]\ninstance [LeftCancelMonoid α] : RightCancelMonoid αᵐᵒᵖ :=\n  { MulOpposite.rightCancelSemigroup α, MulOpposite.monoid α with }\n\n@[to_additive]\ninstance [CancelMonoid α] : CancelMonoid αᵐᵒᵖ :=\n  { MulOpposite.rightCancelMonoid α, MulOpposite.leftCancelMonoid α with }\n\n@[to_additive]\ninstance [CommMonoid α] : CommMonoid αᵐᵒᵖ :=\n  { MulOpposite.monoid α, MulOpposite.commSemigroup α with }\n\n@[to_additive]\ninstance [CancelCommMonoid α] : CancelCommMonoid αᵐᵒᵖ :=\n  { MulOpposite.cancelMonoid α, MulOpposite.commMonoid α with }\n\n@[to_additive AddOpposite.subNegMonoid]\ninstance [DivInvMonoid α] : DivInvMonoid αᵐᵒᵖ :=\n  { MulOpposite.monoid α,\n    MulOpposite.hasInv α with\n    zpow := fun n x => op <| x.unop ^ n\n    zpow_zero' := fun x => unop_injective <| DivInvMonoid.zpow_zero' x.unop\n    zpow_succ' := fun n x =>\n      unop_injective <| by rw [unop_op, zpow_ofNat, zpow_ofNat, pow_succ', unop_mul, unop_op]\n    zpow_neg' := fun z x => unop_injective <| DivInvMonoid.zpow_neg' z x.unop }\n\n@[to_additive AddOpposite.subtractionMonoid]\ninstance [DivisionMonoid α] : DivisionMonoid αᵐᵒᵖ :=\n  { MulOpposite.divInvMonoid α,\n    MulOpposite.hasInvolutiveInv\n      α with\n    mul_inv_rev := fun a b => unop_injective <| mul_inv_rev _ _\n    inv_eq_of_mul := fun a b h => unop_injective <| inv_eq_of_mul_eq_one_left <| congr_arg unop h }\n\n@[to_additive AddOpposite.subtractionCommMonoid]\ninstance [DivisionCommMonoid α] : DivisionCommMonoid αᵐᵒᵖ :=\n  { MulOpposite.divisionMonoid α, MulOpposite.commSemigroup α with }\n\n@[to_additive]\ninstance [Group α] : Group αᵐᵒᵖ :=\n  { MulOpposite.divInvMonoid α with\n    mul_left_inv := fun x => unop_injective <| mul_inv_self <| unop x }\n\n@[to_additive]\ninstance [CommGroup α] : CommGroup αᵐᵒᵖ :=\n  { MulOpposite.group α, MulOpposite.commMonoid α with }\n\nvariable {α}\n\n#print MulOpposite.op_natCast /-\n@[simp, norm_cast, to_additive]\ntheorem op_natCast [NatCast α] (n : ℕ) : op (n : α) = n :=\n  rfl\n#align mul_opposite.op_nat_cast MulOpposite.op_natCast\n#align add_opposite.op_nat_cast AddOpposite.op_natCast\n-/\n\n#print MulOpposite.op_intCast /-\n@[simp, norm_cast, to_additive]\ntheorem op_intCast [IntCast α] (n : ℤ) : op (n : α) = n :=\n  rfl\n#align mul_opposite.op_int_cast MulOpposite.op_intCast\n#align add_opposite.op_int_cast AddOpposite.op_intCast\n-/\n\n#print MulOpposite.unop_natCast /-\n@[simp, norm_cast, to_additive]\ntheorem unop_natCast [NatCast α] (n : ℕ) : unop (n : αᵐᵒᵖ) = n :=\n  rfl\n#align mul_opposite.unop_nat_cast MulOpposite.unop_natCast\n#align add_opposite.unop_nat_cast AddOpposite.unop_natCast\n-/\n\n#print MulOpposite.unop_intCast /-\n@[simp, norm_cast, to_additive]\ntheorem unop_intCast [IntCast α] (n : ℤ) : unop (n : αᵐᵒᵖ) = n :=\n  rfl\n#align mul_opposite.unop_int_cast MulOpposite.unop_intCast\n#align add_opposite.unop_int_cast AddOpposite.unop_intCast\n-/\n\n/- warning: mul_opposite.unop_div -> MulOpposite.unop_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} α] (x : MulOpposite.{u1} α) (y : MulOpposite.{u1} α), Eq.{succ u1} α (MulOpposite.unop.{u1} α (HDiv.hDiv.{u1, u1, u1} (MulOpposite.{u1} α) (MulOpposite.{u1} α) (MulOpposite.{u1} α) (instHDiv.{u1} (MulOpposite.{u1} α) (DivInvMonoid.toHasDiv.{u1} (MulOpposite.{u1} α) (MulOpposite.divInvMonoid.{u1} α _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α _inst_1)))) (Inv.inv.{u1} α (DivInvMonoid.toHasInv.{u1} α _inst_1) (MulOpposite.unop.{u1} α y)) (MulOpposite.unop.{u1} α x))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} α] (x : MulOpposite.{u1} α) (y : MulOpposite.{u1} α), Eq.{succ u1} α (MulOpposite.unop.{u1} α (HDiv.hDiv.{u1, u1, u1} (MulOpposite.{u1} α) (MulOpposite.{u1} α) (MulOpposite.{u1} α) (instHDiv.{u1} (MulOpposite.{u1} α) (DivInvMonoid.toDiv.{u1} (MulOpposite.{u1} α) (MulOpposite.divInvMonoid.{u1} α _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α _inst_1)))) (Inv.inv.{u1} α (DivInvMonoid.toInv.{u1} α _inst_1) (MulOpposite.unop.{u1} α y)) (MulOpposite.unop.{u1} α x))\nCase conversion may be inaccurate. Consider using '#align mul_opposite.unop_div MulOpposite.unop_divₓ'. -/\n@[simp, to_additive]\ntheorem unop_div [DivInvMonoid α] (x y : αᵐᵒᵖ) : unop (x / y) = (unop y)⁻¹ * unop x :=\n  rfl\n#align mul_opposite.unop_div MulOpposite.unop_div\n#align add_opposite.unop_sub AddOpposite.unop_sub\n\n/- warning: mul_opposite.op_div -> MulOpposite.op_div is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} α] (x : α) (y : α), Eq.{succ u1} (MulOpposite.{u1} α) (MulOpposite.op.{u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α _inst_1)) x y)) (HMul.hMul.{u1, u1, u1} (MulOpposite.{u1} α) (MulOpposite.{u1} α) (MulOpposite.{u1} α) (instHMul.{u1} (MulOpposite.{u1} α) (MulOpposite.hasMul.{u1} α (MulOneClass.toHasMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α _inst_1))))) (Inv.inv.{u1} (MulOpposite.{u1} α) (MulOpposite.hasInv.{u1} α (DivInvMonoid.toHasInv.{u1} α _inst_1)) (MulOpposite.op.{u1} α y)) (MulOpposite.op.{u1} α x))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} α] (x : α) (y : α), Eq.{succ u1} (MulOpposite.{u1} α) (MulOpposite.op.{u1} α (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toDiv.{u1} α _inst_1)) x y)) (HMul.hMul.{u1, u1, u1} (MulOpposite.{u1} α) (MulOpposite.{u1} α) (MulOpposite.{u1} α) (instHMul.{u1} (MulOpposite.{u1} α) (MulOpposite.mul.{u1} α (MulOneClass.toMul.{u1} α (Monoid.toMulOneClass.{u1} α (DivInvMonoid.toMonoid.{u1} α _inst_1))))) (Inv.inv.{u1} (MulOpposite.{u1} α) (MulOpposite.inv.{u1} α (DivInvMonoid.toInv.{u1} α _inst_1)) (MulOpposite.op.{u1} α y)) (MulOpposite.op.{u1} α x))\nCase conversion may be inaccurate. Consider using '#align mul_opposite.op_div MulOpposite.op_divₓ'. -/\n@[simp, to_additive]\ntheorem op_div [DivInvMonoid α] (x y : α) : op (x / y) = (op y)⁻¹ * op x := by simp [div_eq_mul_inv]\n#align mul_opposite.op_div MulOpposite.op_div\n#align add_opposite.op_sub AddOpposite.op_sub\n\n#print MulOpposite.semiconjBy_op /-\n@[simp, to_additive]\ntheorem semiconjBy_op [Mul α] {a x y : α} : SemiconjBy (op a) (op y) (op x) ↔ SemiconjBy a x y := by\n  simp only [SemiconjBy, ← op_mul, op_inj, eq_comm]\n#align mul_opposite.semiconj_by_op MulOpposite.semiconjBy_op\n#align add_opposite.semiconj_by_op AddOpposite.semiconjBy_op\n-/\n\n#print MulOpposite.semiconjBy_unop /-\n@[simp, to_additive]\ntheorem semiconjBy_unop [Mul α] {a x y : αᵐᵒᵖ} :\n    SemiconjBy (unop a) (unop y) (unop x) ↔ SemiconjBy a x y := by\n  conv_rhs => rw [← op_unop a, ← op_unop x, ← op_unop y, semiconj_by_op]\n#align mul_opposite.semiconj_by_unop MulOpposite.semiconjBy_unop\n#align add_opposite.semiconj_by_unop AddOpposite.semiconjBy_unop\n-/\n\n#print SemiconjBy.op /-\n@[to_additive]\ntheorem SemiconjBy.op [Mul α] {a x y : α} (h : SemiconjBy a x y) :\n    SemiconjBy (op a) (op y) (op x) :=\n  semiconjBy_op.2 h\n#align semiconj_by.op SemiconjBy.op\n#align add_semiconj_by.op AddSemiconjBy.op\n-/\n\n#print SemiconjBy.unop /-\n@[to_additive]\ntheorem SemiconjBy.unop [Mul α] {a x y : αᵐᵒᵖ} (h : SemiconjBy a x y) :\n    SemiconjBy (unop a) (unop y) (unop x) :=\n  semiconjBy_unop.2 h\n#align semiconj_by.unop SemiconjBy.unop\n#align add_semiconj_by.unop AddSemiconjBy.unop\n-/\n\n#print Commute.op /-\n@[to_additive]\ntheorem Commute.op [Mul α] {x y : α} (h : Commute x y) : Commute (op x) (op y) :=\n  h.op\n#align commute.op Commute.op\n#align add_commute.op AddCommute.op\n-/\n\n#print MulOpposite.Commute.unop /-\n@[to_additive]\ntheorem Commute.unop [Mul α] {x y : αᵐᵒᵖ} (h : Commute x y) : Commute (unop x) (unop y) :=\n  h.unop\n#align mul_opposite.commute.unop MulOpposite.Commute.unop\n#align add_opposite.commute.unop AddOpposite.Commute.unop\n-/\n\n#print MulOpposite.commute_op /-\n@[simp, to_additive]\ntheorem commute_op [Mul α] {x y : α} : Commute (op x) (op y) ↔ Commute x y :=\n  semiconjBy_op\n#align mul_opposite.commute_op MulOpposite.commute_op\n#align add_opposite.commute_op AddOpposite.commute_op\n-/\n\n#print MulOpposite.commute_unop /-\n@[simp, to_additive]\ntheorem commute_unop [Mul α] {x y : αᵐᵒᵖ} : Commute (unop x) (unop y) ↔ Commute x y :=\n  semiconjBy_unop\n#align mul_opposite.commute_unop MulOpposite.commute_unop\n#align add_opposite.commute_unop AddOpposite.commute_unop\n-/\n\n#print MulOpposite.opAddEquiv /-\n/-- The function `mul_opposite.op` is an additive equivalence. -/\n@[simps (config :=\n      { fullyApplied := false\n        simpRhs := true })]\ndef opAddEquiv [Add α] : α ≃+ αᵐᵒᵖ :=\n  { opEquiv with map_add' := fun a b => rfl }\n#align mul_opposite.op_add_equiv MulOpposite.opAddEquiv\n-/\n\n#print MulOpposite.opAddEquiv_toEquiv /-\n@[simp]\ntheorem opAddEquiv_toEquiv [Add α] : (opAddEquiv : α ≃+ αᵐᵒᵖ).toEquiv = opEquiv :=\n  rfl\n#align mul_opposite.op_add_equiv_to_equiv MulOpposite.opAddEquiv_toEquiv\n-/\n\nend MulOpposite\n\n/-!\n### Multiplicative structures on `αᵃᵒᵖ`\n-/\n\n\nnamespace AddOpposite\n\ninstance [Semigroup α] : Semigroup αᵃᵒᵖ :=\n  unop_injective.Semigroup _ fun x y => rfl\n\ninstance [LeftCancelSemigroup α] : LeftCancelSemigroup αᵃᵒᵖ :=\n  unop_injective.LeftCancelSemigroup _ fun x y => rfl\n\ninstance [RightCancelSemigroup α] : RightCancelSemigroup αᵃᵒᵖ :=\n  unop_injective.RightCancelSemigroup _ fun x y => rfl\n\ninstance [CommSemigroup α] : CommSemigroup αᵃᵒᵖ :=\n  unop_injective.CommSemigroup _ fun x y => rfl\n\ninstance [MulOneClass α] : MulOneClass αᵃᵒᵖ :=\n  unop_injective.MulOneClass _ rfl fun x y => rfl\n\ninstance {β} [Pow α β] : Pow αᵃᵒᵖ β where pow a b := op (unop a ^ b)\n\n/- warning: add_opposite.op_pow -> AddOpposite.op_pow is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) {β : Type.{u2}} [_inst_1 : Pow.{u1, u2} α β] (a : α) (b : β), Eq.{succ u1} (AddOpposite.{u1} α) (AddOpposite.op.{u1} α (HPow.hPow.{u1, u2, u1} α β α (instHPow.{u1, u2} α β _inst_1) a b)) (HPow.hPow.{u1, u2, u1} (AddOpposite.{u1} α) β (AddOpposite.{u1} α) (instHPow.{u1, u2} (AddOpposite.{u1} α) β (AddOpposite.hasPow.{u1, u2} α β _inst_1)) (AddOpposite.op.{u1} α a) b)\nbut is expected to have type\n  forall (α : Type.{u2}) {β : Type.{u1}} [_inst_1 : Pow.{u2, u1} α β] (a : α) (b : β), Eq.{succ u2} (AddOpposite.{u2} α) (AddOpposite.op.{u2} α (HPow.hPow.{u2, u1, u2} α β α (instHPow.{u2, u1} α β _inst_1) a b)) (HPow.hPow.{u2, u1, u2} (AddOpposite.{u2} α) β (AddOpposite.{u2} α) (instHPow.{u2, u1} (AddOpposite.{u2} α) β (AddOpposite.pow.{u2, u1} α β _inst_1)) (AddOpposite.op.{u2} α a) b)\nCase conversion may be inaccurate. Consider using '#align add_opposite.op_pow AddOpposite.op_powₓ'. -/\n@[simp]\ntheorem op_pow {β} [Pow α β] (a : α) (b : β) : op (a ^ b) = op a ^ b :=\n  rfl\n#align add_opposite.op_pow AddOpposite.op_pow\n\n/- warning: add_opposite.unop_pow -> AddOpposite.unop_pow is a dubious translation:\nlean 3 declaration is\n  forall (α : Type.{u1}) {β : Type.{u2}} [_inst_1 : Pow.{u1, u2} α β] (a : AddOpposite.{u1} α) (b : β), Eq.{succ u1} α (AddOpposite.unop.{u1} α (HPow.hPow.{u1, u2, u1} (AddOpposite.{u1} α) β (AddOpposite.{u1} α) (instHPow.{u1, u2} (AddOpposite.{u1} α) β (AddOpposite.hasPow.{u1, u2} α β _inst_1)) a b)) (HPow.hPow.{u1, u2, u1} α β α (instHPow.{u1, u2} α β _inst_1) (AddOpposite.unop.{u1} α a) b)\nbut is expected to have type\n  forall (α : Type.{u2}) {β : Type.{u1}} [_inst_1 : Pow.{u2, u1} α β] (a : AddOpposite.{u2} α) (b : β), Eq.{succ u2} α (AddOpposite.unop.{u2} α (HPow.hPow.{u2, u1, u2} (AddOpposite.{u2} α) β (AddOpposite.{u2} α) (instHPow.{u2, u1} (AddOpposite.{u2} α) β (AddOpposite.pow.{u2, u1} α β _inst_1)) a b)) (HPow.hPow.{u2, u1, u2} α β α (instHPow.{u2, u1} α β _inst_1) (AddOpposite.unop.{u2} α a) b)\nCase conversion may be inaccurate. Consider using '#align add_opposite.unop_pow AddOpposite.unop_powₓ'. -/\n@[simp]\ntheorem unop_pow {β} [Pow α β] (a : αᵃᵒᵖ) (b : β) : unop (a ^ b) = unop a ^ b :=\n  rfl\n#align add_opposite.unop_pow AddOpposite.unop_pow\n\ninstance [Monoid α] : Monoid αᵃᵒᵖ :=\n  unop_injective.Monoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [CommMonoid α] : CommMonoid αᵃᵒᵖ :=\n  unop_injective.CommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [DivInvMonoid α] : DivInvMonoid αᵃᵒᵖ :=\n  unop_injective.DivInvMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [Group α] : Group αᵃᵒᵖ :=\n  unop_injective.Group _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    fun _ _ => rfl\n\ninstance [CommGroup α] : CommGroup αᵃᵒᵖ :=\n  unop_injective.CommGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    fun _ _ => rfl\n\n-- NOTE: `add_monoid_with_one α → add_monoid_with_one αᵃᵒᵖ` does not hold\ninstance [AddCommMonoidWithOne α] : AddCommMonoidWithOne αᵃᵒᵖ :=\n  { AddOpposite.addCommMonoid α, AddOpposite.hasOne,\n    AddOpposite.hasNatCast\n      _ with\n    natCast_zero := show op ((0 : ℕ) : α) = 0 by rw [Nat.cast_zero, op_zero]\n    natCast_succ := show ∀ n, op ((n + 1 : ℕ) : α) = op (n : ℕ) + 1 by simp [add_comm] }\n\ninstance [AddCommGroupWithOne α] : AddCommGroupWithOne αᵃᵒᵖ :=\n  { AddOpposite.addCommMonoidWithOne _, AddOpposite.addCommGroup α,\n    AddOpposite.hasIntCast\n      α with\n    intCast_ofNat := fun n => congr_arg op <| Int.cast_ofNat n\n    intCast_negSucc := fun _ => congr_arg op <| Int.cast_negSucc _ }\n\nvariable {α}\n\n#print AddOpposite.opMulEquiv /-\n/-- The function `add_opposite.op` is a multiplicative equivalence. -/\n@[simps (config :=\n      { fullyApplied := false\n        simpRhs := true })]\ndef opMulEquiv [Mul α] : α ≃* αᵃᵒᵖ :=\n  { opEquiv with map_mul' := fun a b => rfl }\n#align add_opposite.op_mul_equiv AddOpposite.opMulEquiv\n-/\n\n#print AddOpposite.opMulEquiv_toEquiv /-\n@[simp]\ntheorem opMulEquiv_toEquiv [Mul α] : (opMulEquiv : α ≃* αᵃᵒᵖ).toEquiv = opEquiv :=\n  rfl\n#align add_opposite.op_mul_equiv_to_equiv AddOpposite.opMulEquiv_toEquiv\n-/\n\nend AddOpposite\n\nopen MulOpposite\n\n/- warning: mul_equiv.inv' -> MulEquiv.inv' is a dubious translation:\nlean 3 declaration is\n  forall (G : Type.{u1}) [_inst_1 : DivisionMonoid.{u1} G], MulEquiv.{u1, u1} G (MulOpposite.{u1} G) (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (DivisionMonoid.toDivInvMonoid.{u1} G _inst_1)))) (MulOpposite.hasMul.{u1} G (MulOneClass.toHasMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (DivisionMonoid.toDivInvMonoid.{u1} G _inst_1)))))\nbut is expected to have type\n  forall (G : Type.{u1}) [_inst_1 : DivisionMonoid.{u1} G], MulEquiv.{u1, u1} G (MulOpposite.{u1} G) (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (DivisionMonoid.toDivInvMonoid.{u1} G _inst_1)))) (MulOpposite.mul.{u1} G (MulOneClass.toMul.{u1} G (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (DivisionMonoid.toDivInvMonoid.{u1} G _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align mul_equiv.inv' MulEquiv.inv'ₓ'. -/\n/-- Inversion on a group is a `mul_equiv` to the opposite group. When `G` is commutative, there is\n`mul_equiv.inv`. -/\n@[to_additive\n      \"Negation on an additive group is an `add_equiv` to the opposite group. When `G`\\nis commutative, there is `add_equiv.inv`.\",\n  simps (config :=\n      { fullyApplied := false\n        simpRhs := true })]\ndef MulEquiv.inv' (G : Type _) [DivisionMonoid G] : G ≃* Gᵐᵒᵖ :=\n  { (Equiv.inv G).trans opEquiv with map_mul' := fun x y => unop_injective <| mul_inv_rev x y }\n#align mul_equiv.inv' MulEquiv.inv'\n#align add_equiv.neg' AddEquiv.neg'\n\n#print MulHom.toOpposite /-\n/-- A semigroup homomorphism `f : M →ₙ* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism to `Nᵐᵒᵖ`. -/\n@[to_additive\n      \"An additive semigroup homomorphism `f : add_hom M N` such that `f x` additively\\ncommutes with `f y` for all `x, y` defines an additive semigroup homomorphism to `Sᵃᵒᵖ`.\",\n  simps (config := { fullyApplied := false })]\ndef MulHom.toOpposite {M N : Type _} [Mul M] [Mul N] (f : M →ₙ* N)\n    (hf : ∀ x y, Commute (f x) (f y)) : M →ₙ* Nᵐᵒᵖ\n    where\n  toFun := MulOpposite.op ∘ f\n  map_mul' x y := by simp [(hf x y).Eq]\n#align mul_hom.to_opposite MulHom.toOpposite\n#align add_hom.to_opposite AddHom.toOpposite\n-/\n\n#print MulHom.fromOpposite /-\n/-- A semigroup homomorphism `f : M →ₙ* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism from `Mᵐᵒᵖ`. -/\n@[to_additive\n      \"An additive semigroup homomorphism `f : add_hom M N` such that `f x` additively\\ncommutes with `f y` for all `x`, `y` defines an additive semigroup homomorphism from `Mᵃᵒᵖ`.\",\n  simps (config := { fullyApplied := false })]\ndef MulHom.fromOpposite {M N : Type _} [Mul M] [Mul N] (f : M →ₙ* N)\n    (hf : ∀ x y, Commute (f x) (f y)) : Mᵐᵒᵖ →ₙ* N\n    where\n  toFun := f ∘ MulOpposite.unop\n  map_mul' x y := (f.map_mul _ _).trans (hf _ _).Eq\n#align mul_hom.from_opposite MulHom.fromOpposite\n#align add_hom.from_opposite AddHom.fromOpposite\n-/\n\n/- warning: monoid_hom.to_opposite -> MonoidHom.toOpposite is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), (forall (x : M) (y : M), Commute.{u2} N (MulOneClass.toHasMul.{u2} N _inst_2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y)) -> (MonoidHom.{u1, u2} M (MulOpposite.{u2} N) _inst_1 (MulOpposite.mulOneClass.{u2} N _inst_2))\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), (forall (x : M) (y : M), Commute.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u1, u2} M N _inst_1 _inst_2))) f x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u1, u2} M N _inst_1 _inst_2))) f y)) -> (MonoidHom.{u1, u2} M (MulOpposite.{u2} N) _inst_1 (MulOpposite.mulOneClass.{u2} N _inst_2))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.to_opposite MonoidHom.toOppositeₓ'. -/\n/-- A monoid homomorphism `f : M →* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism to `Nᵐᵒᵖ`. -/\n@[to_additive\n      \"An additive monoid homomorphism `f : M →+ N` such that `f x` additively commutes\\nwith `f y` for all `x, y` defines an additive monoid homomorphism to `Sᵃᵒᵖ`.\",\n  simps (config := { fullyApplied := false })]\ndef MonoidHom.toOpposite {M N : Type _} [MulOneClass M] [MulOneClass N] (f : M →* N)\n    (hf : ∀ x y, Commute (f x) (f y)) : M →* Nᵐᵒᵖ\n    where\n  toFun := MulOpposite.op ∘ f\n  map_one' := congr_arg op f.map_one\n  map_mul' x y := by simp [(hf x y).Eq]\n#align monoid_hom.to_opposite MonoidHom.toOpposite\n#align add_monoid_hom.to_opposite AddMonoidHom.toOpposite\n\n/- warning: monoid_hom.from_opposite -> MonoidHom.fromOpposite is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), (forall (x : M) (y : M), Commute.{u2} N (MulOneClass.toHasMul.{u2} N _inst_2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f x) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) (fun (_x : MonoidHom.{u1, u2} M N _inst_1 _inst_2) => M -> N) (MonoidHom.hasCoeToFun.{u1, u2} M N _inst_1 _inst_2) f y)) -> (MonoidHom.{u1, u2} (MulOpposite.{u1} M) N (MulOpposite.mulOneClass.{u1} M _inst_1) _inst_2)\nbut is expected to have type\n  forall {M : Type.{u1}} {N : Type.{u2}} [_inst_1 : MulOneClass.{u1} M] [_inst_2 : MulOneClass.{u2} N] (f : MonoidHom.{u1, u2} M N _inst_1 _inst_2), (forall (x : M) (y : M), Commute.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) (MulOneClass.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) x) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u1, u2} M N _inst_1 _inst_2))) f x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N (MulOneClass.toMul.{u1} M _inst_1) (MulOneClass.toMul.{u2} N _inst_2) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) M N _inst_1 _inst_2 (MonoidHom.monoidHomClass.{u1, u2} M N _inst_1 _inst_2))) f y)) -> (MonoidHom.{u1, u2} (MulOpposite.{u1} M) N (MulOpposite.mulOneClass.{u1} M _inst_1) _inst_2)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.from_opposite MonoidHom.fromOppositeₓ'. -/\n/-- A monoid homomorphism `f : M →* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism from `Mᵐᵒᵖ`. -/\n@[to_additive\n      \"An additive monoid homomorphism `f : M →+ N` such that `f x` additively commutes\\nwith `f y` for all `x`, `y` defines an additive monoid homomorphism from `Mᵃᵒᵖ`.\",\n  simps (config := { fullyApplied := false })]\ndef MonoidHom.fromOpposite {M N : Type _} [MulOneClass M] [MulOneClass N] (f : M →* N)\n    (hf : ∀ x y, Commute (f x) (f y)) : Mᵐᵒᵖ →* N\n    where\n  toFun := f ∘ MulOpposite.unop\n  map_one' := f.map_one\n  map_mul' x y := (f.map_mul _ _).trans (hf _ _).Eq\n#align monoid_hom.from_opposite MonoidHom.fromOpposite\n#align add_monoid_hom.from_opposite AddMonoidHom.fromOpposite\n\n/- warning: units.op_equiv -> Units.opEquiv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M], MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M], MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1)))\nCase conversion may be inaccurate. Consider using '#align units.op_equiv Units.opEquivₓ'. -/\n/-- The units of the opposites are equivalent to the opposites of the units. -/\n@[to_additive\n      \"The additive units of the additive opposites are equivalent to the additive opposites\\nof the additive units.\"]\ndef Units.opEquiv {M} [Monoid M] : Mᵐᵒᵖˣ ≃* Mˣᵐᵒᵖ\n    where\n  toFun u := op ⟨unop u, unop ↑u⁻¹, op_injective u.4, op_injective u.3⟩\n  invFun := MulOpposite.rec' fun u => ⟨op ↑u, op ↑u⁻¹, unop_injective <| u.4, unop_injective u.3⟩\n  map_mul' x y := unop_injective <| Units.ext <| rfl\n  left_inv x := Units.ext <| by simp\n  right_inv x := unop_injective <| Units.ext <| rfl\n#align units.op_equiv Units.opEquiv\n#align add_units.op_equiv AddUnits.opEquiv\n\n/- warning: units.coe_unop_op_equiv -> Units.coe_unop_opEquiv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (u : Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)), Eq.{succ u1} M ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M _inst_1) M (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M _inst_1) M (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M _inst_1) M (coeBase.{succ u1, succ u1} (Units.{u1} M _inst_1) M (Units.hasCoe.{u1} M _inst_1)))) (MulOpposite.unop.{u1} (Units.{u1} M _inst_1) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1)))) (fun (_x : MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1)))) => (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) -> (MulOpposite.{u1} (Units.{u1} M _inst_1))) (MulEquiv.hasCoeToFun.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1)))) (Units.opEquiv.{u1} M _inst_1) u))) (MulOpposite.unop.{u1} M ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (coeBase.{succ u1, succ u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (Units.hasCoe.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))))) u))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (u : Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)), Eq.{succ u1} M (Units.val.{u1} M _inst_1 (MulOpposite.unop.{u1} (Units.{u1} M _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1)))) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (fun (_x : Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) => MulOpposite.{u1} (Units.{u1} M _inst_1)) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1)))) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1)))) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1)))) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))))))) (Units.opEquiv.{u1} M _inst_1) u))) (MulOpposite.unop.{u1} M (Units.val.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1) u))\nCase conversion may be inaccurate. Consider using '#align units.coe_unop_op_equiv Units.coe_unop_opEquivₓ'. -/\n@[simp, to_additive]\ntheorem Units.coe_unop_opEquiv {M} [Monoid M] (u : Mᵐᵒᵖˣ) :\n    ((Units.opEquiv u).unop : M) = unop (u : Mᵐᵒᵖ) :=\n  rfl\n#align units.coe_unop_op_equiv Units.coe_unop_opEquiv\n#align add_units.coe_unop_op_equiv AddUnits.coe_unop_opEquiv\n\n/- warning: units.coe_op_equiv_symm -> Units.coe_opEquiv_symm is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (u : MulOpposite.{u1} (Units.{u1} M _inst_1)), Eq.{succ u1} (MulOpposite.{u1} M) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (coeBase.{succ u1, succ u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} M) (Units.hasCoe.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))))) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1))) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)))) (fun (_x : MulEquiv.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1))) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)))) => (MulOpposite.{u1} (Units.{u1} M _inst_1)) -> (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulEquiv.hasCoeToFun.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1))) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)))) (MulEquiv.symm.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toHasMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.mulOneClass.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.hasMul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toHasMul.{u1} (Units.{u1} M _inst_1) (Units.mulOneClass.{u1} M _inst_1))) (Units.opEquiv.{u1} M _inst_1)) u)) (MulOpposite.op.{u1} M ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M _inst_1) M (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M _inst_1) M (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M _inst_1) M (coeBase.{succ u1, succ u1} (Units.{u1} M _inst_1) M (Units.hasCoe.{u1} M _inst_1)))) (MulOpposite.unop.{u1} (Units.{u1} M _inst_1) u)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (u : MulOpposite.{u1} (Units.{u1} M _inst_1)), Eq.{succ u1} (MulOpposite.{u1} M) (Units.val.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)))) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (fun (_x : MulOpposite.{u1} (Units.{u1} M _inst_1)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : MulOpposite.{u1} (Units.{u1} M _inst_1)) => Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)))) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)))) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)))) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (MulOpposite.{u1} (Units.{u1} M _inst_1)) (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))))))) (MulEquiv.symm.{u1, u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (MulOpposite.{u1} (Units.{u1} M _inst_1)) (MulOneClass.toMul.{u1} (Units.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1)) (Units.instMulOneClassUnits.{u1} (MulOpposite.{u1} M) (MulOpposite.monoid.{u1} M _inst_1))) (MulOpposite.mul.{u1} (Units.{u1} M _inst_1) (MulOneClass.toMul.{u1} (Units.{u1} M _inst_1) (Units.instMulOneClassUnits.{u1} M _inst_1))) (Units.opEquiv.{u1} M _inst_1)) u)) (MulOpposite.op.{u1} M (Units.val.{u1} M _inst_1 (MulOpposite.unop.{u1} (Units.{u1} M _inst_1) u)))\nCase conversion may be inaccurate. Consider using '#align units.coe_op_equiv_symm Units.coe_opEquiv_symmₓ'. -/\n@[simp, to_additive]\ntheorem Units.coe_opEquiv_symm {M} [Monoid M] (u : Mˣᵐᵒᵖ) :\n    (Units.opEquiv.symm u : Mᵐᵒᵖ) = op (u.unop : M) :=\n  rfl\n#align units.coe_op_equiv_symm Units.coe_opEquiv_symm\n#align add_units.coe_op_equiv_symm AddUnits.coe_opEquiv_symm\n\n#print MulHom.op /-\n/-- A semigroup homomorphism `M →ₙ* N` can equivalently be viewed as a semigroup homomorphism\n`Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[to_additive\n      \"An additive semigroup homomorphism `add_hom M N` can equivalently be viewed as an\\nadditive semigroup homomorphism `add_hom Mᵃᵒᵖ Nᵃᵒᵖ`. This is the action of the (fully faithful)\\n`ᵃᵒᵖ`-functor on morphisms.\",\n  simps]\ndef MulHom.op {M N} [Mul M] [Mul N] : (M →ₙ* N) ≃ (Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ)\n    where\n  toFun f :=\n    { toFun := op ∘ f ∘ unop\n      map_mul' := fun x y => unop_injective (f.map_mul y.unop x.unop) }\n  invFun f :=\n    { toFun := unop ∘ f ∘ op\n      map_mul' := fun x y => congr_arg unop (f.map_mul (op y) (op x)) }\n  left_inv f := by\n    ext\n    rfl\n  right_inv f := by\n    ext x\n    simp\n#align mul_hom.op MulHom.op\n#align add_hom.op AddHom.op\n-/\n\n#print MulHom.unop /-\n/-- The 'unopposite' of a semigroup homomorphism `Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ`. Inverse to `mul_hom.op`. -/\n@[simp,\n  to_additive\n      \"The 'unopposite' of an additive semigroup homomorphism `Mᵃᵒᵖ →ₙ+ Nᵃᵒᵖ`. Inverse\\nto `add_hom.op`.\"]\ndef MulHom.unop {M N} [Mul M] [Mul N] : (Mᵐᵒᵖ →ₙ* Nᵐᵒᵖ) ≃ (M →ₙ* N) :=\n  MulHom.op.symm\n#align mul_hom.unop MulHom.unop\n#align add_hom.unop AddHom.unop\n-/\n\n#print AddHom.mulOp /-\n/-- An additive semigroup homomorphism `add_hom M N` can equivalently be viewed as an additive\nhomomorphism `add_hom Mᵐᵒᵖ Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on\nmorphisms. -/\n@[simps]\ndef AddHom.mulOp {M N} [Add M] [Add N] : AddHom M N ≃ AddHom Mᵐᵒᵖ Nᵐᵒᵖ\n    where\n  toFun f :=\n    { toFun := op ∘ f ∘ unop\n      map_add' := fun x y => unop_injective (f.map_add x.unop y.unop) }\n  invFun f :=\n    { toFun := unop ∘ f ∘ op\n      map_add' := fun x y => congr_arg unop (f.map_add (op x) (op y)) }\n  left_inv f := by\n    ext\n    rfl\n  right_inv f := by\n    ext\n    simp\n#align add_hom.mul_op AddHom.mulOp\n-/\n\n#print AddHom.mulUnop /-\n/-- The 'unopposite' of an additive semigroup hom `αᵐᵒᵖ →+ βᵐᵒᵖ`. Inverse to\n`add_hom.mul_op`. -/\n@[simp]\ndef AddHom.mulUnop {α β} [Add α] [Add β] : AddHom αᵐᵒᵖ βᵐᵒᵖ ≃ AddHom α β :=\n  AddHom.mulOp.symm\n#align add_hom.mul_unop AddHom.mulUnop\n-/\n\n#print MonoidHom.op /-\n/-- A monoid homomorphism `M →* N` can equivalently be viewed as a monoid homomorphism\n`Mᵐᵒᵖ →* Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[to_additive\n      \"An additive monoid homomorphism `M →+ N` can equivalently be viewed as an\\nadditive monoid homomorphism `Mᵃᵒᵖ →+ Nᵃᵒᵖ`. This is the action of the (fully faithful)\\n`ᵃᵒᵖ`-functor on morphisms.\",\n  simps]\ndef MonoidHom.op {M N} [MulOneClass M] [MulOneClass N] : (M →* N) ≃ (Mᵐᵒᵖ →* Nᵐᵒᵖ)\n    where\n  toFun f :=\n    { toFun := op ∘ f ∘ unop\n      map_one' := congr_arg op f.map_one\n      map_mul' := fun x y => unop_injective (f.map_mul y.unop x.unop) }\n  invFun f :=\n    { toFun := unop ∘ f ∘ op\n      map_one' := congr_arg unop f.map_one\n      map_mul' := fun x y => congr_arg unop (f.map_mul (op y) (op x)) }\n  left_inv f := by\n    ext\n    rfl\n  right_inv f := by\n    ext x\n    simp\n#align monoid_hom.op MonoidHom.op\n#align add_monoid_hom.op AddMonoidHom.op\n-/\n\n#print MonoidHom.unop /-\n/-- The 'unopposite' of a monoid homomorphism `Mᵐᵒᵖ →* Nᵐᵒᵖ`. Inverse to `monoid_hom.op`. -/\n@[simp,\n  to_additive\n      \"The 'unopposite' of an additive monoid homomorphism `Mᵃᵒᵖ →+ Nᵃᵒᵖ`. Inverse to\\n`add_monoid_hom.op`.\"]\ndef MonoidHom.unop {M N} [MulOneClass M] [MulOneClass N] : (Mᵐᵒᵖ →* Nᵐᵒᵖ) ≃ (M →* N) :=\n  MonoidHom.op.symm\n#align monoid_hom.unop MonoidHom.unop\n#align add_monoid_hom.unop AddMonoidHom.unop\n-/\n\n#print AddMonoidHom.mulOp /-\n/-- An additive homomorphism `M →+ N` can equivalently be viewed as an additive homomorphism\n`Mᵐᵒᵖ →+ Nᵐᵒᵖ`. This is the action of the (fully faithful) `ᵐᵒᵖ`-functor on morphisms. -/\n@[simps]\ndef AddMonoidHom.mulOp {M N} [AddZeroClass M] [AddZeroClass N] : (M →+ N) ≃ (Mᵐᵒᵖ →+ Nᵐᵒᵖ)\n    where\n  toFun f :=\n    { toFun := op ∘ f ∘ unop\n      map_zero' := unop_injective f.map_zero\n      map_add' := fun x y => unop_injective (f.map_add x.unop y.unop) }\n  invFun f :=\n    { toFun := unop ∘ f ∘ op\n      map_zero' := congr_arg unop f.map_zero\n      map_add' := fun x y => congr_arg unop (f.map_add (op x) (op y)) }\n  left_inv f := by\n    ext\n    rfl\n  right_inv f := by\n    ext\n    simp\n#align add_monoid_hom.mul_op AddMonoidHom.mulOp\n-/\n\n#print AddMonoidHom.mulUnop /-\n/-- The 'unopposite' of an additive monoid hom `αᵐᵒᵖ →+ βᵐᵒᵖ`. Inverse to\n`add_monoid_hom.mul_op`. -/\n@[simp]\ndef AddMonoidHom.mulUnop {α β} [AddZeroClass α] [AddZeroClass β] : (αᵐᵒᵖ →+ βᵐᵒᵖ) ≃ (α →+ β) :=\n  AddMonoidHom.mulOp.symm\n#align add_monoid_hom.mul_unop AddMonoidHom.mulUnop\n-/\n\n#print AddEquiv.mulOp /-\n/-- A iso `α ≃+ β` can equivalently be viewed as an iso `αᵐᵒᵖ ≃+ βᵐᵒᵖ`. -/\n@[simps]\ndef AddEquiv.mulOp {α β} [Add α] [Add β] : α ≃+ β ≃ (αᵐᵒᵖ ≃+ βᵐᵒᵖ)\n    where\n  toFun f := opAddEquiv.symm.trans (f.trans opAddEquiv)\n  invFun f := opAddEquiv.trans (f.trans opAddEquiv.symm)\n  left_inv f := by\n    ext\n    rfl\n  right_inv f := by\n    ext\n    simp\n#align add_equiv.mul_op AddEquiv.mulOp\n-/\n\n#print AddEquiv.mulUnop /-\n/-- The 'unopposite' of an iso `αᵐᵒᵖ ≃+ βᵐᵒᵖ`. Inverse to `add_equiv.mul_op`. -/\n@[simp]\ndef AddEquiv.mulUnop {α β} [Add α] [Add β] : αᵐᵒᵖ ≃+ βᵐᵒᵖ ≃ (α ≃+ β) :=\n  AddEquiv.mulOp.symm\n#align add_equiv.mul_unop AddEquiv.mulUnop\n-/\n\n#print MulEquiv.op /-\n/-- A iso `α ≃* β` can equivalently be viewed as an iso `αᵐᵒᵖ ≃* βᵐᵒᵖ`. -/\n@[to_additive \"A iso `α ≃+ β` can equivalently be viewed as an iso `αᵃᵒᵖ ≃+ βᵃᵒᵖ`.\", simps]\ndef MulEquiv.op {α β} [Mul α] [Mul β] : α ≃* β ≃ (αᵐᵒᵖ ≃* βᵐᵒᵖ)\n    where\n  toFun f :=\n    { toFun := op ∘ f ∘ unop\n      invFun := op ∘ f.symm ∘ unop\n      left_inv := fun x => unop_injective (f.symm_apply_apply x.unop)\n      right_inv := fun x => unop_injective (f.apply_symm_apply x.unop)\n      map_mul' := fun x y => unop_injective (f.map_mul y.unop x.unop) }\n  invFun f :=\n    { toFun := unop ∘ f ∘ op\n      invFun := unop ∘ f.symm ∘ op\n      left_inv := fun x => by simp\n      right_inv := fun x => by simp\n      map_mul' := fun x y => congr_arg unop (f.map_mul (op y) (op x)) }\n  left_inv f := by\n    ext\n    rfl\n  right_inv f := by\n    ext\n    simp\n#align mul_equiv.op MulEquiv.op\n#align add_equiv.op AddEquiv.op\n-/\n\n#print MulEquiv.unop /-\n/-- The 'unopposite' of an iso `αᵐᵒᵖ ≃* βᵐᵒᵖ`. Inverse to `mul_equiv.op`. -/\n@[simp, to_additive \"The 'unopposite' of an iso `αᵃᵒᵖ ≃+ βᵃᵒᵖ`. Inverse to `add_equiv.op`.\"]\ndef MulEquiv.unop {α β} [Mul α] [Mul β] : αᵐᵒᵖ ≃* βᵐᵒᵖ ≃ (α ≃* β) :=\n  MulEquiv.op.symm\n#align mul_equiv.unop MulEquiv.unop\n#align add_equiv.unop AddEquiv.unop\n-/\n\nsection Ext\n\n/- warning: add_monoid_hom.mul_op_ext -> AddMonoidHom.mul_op_ext is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : AddZeroClass.{u1} α] [_inst_2 : AddZeroClass.{u2} β] (f : AddMonoidHom.{u1, u2} (MulOpposite.{u1} α) β (MulOpposite.addZeroClass.{u1} α _inst_1) _inst_2) (g : AddMonoidHom.{u1, u2} (MulOpposite.{u1} α) β (MulOpposite.addZeroClass.{u1} α _inst_1) _inst_2), (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} α β _inst_1 _inst_2) (AddMonoidHom.comp.{u1, u1, u2} α (MulOpposite.{u1} α) β _inst_1 (MulOpposite.addZeroClass.{u1} α _inst_1) _inst_2 f (AddEquiv.toAddMonoidHom.{u1, u1} α (MulOpposite.{u1} α) _inst_1 (MulOpposite.addZeroClass.{u1} α _inst_1) (MulOpposite.opAddEquiv.{u1} α (AddZeroClass.toHasAdd.{u1} α _inst_1)))) (AddMonoidHom.comp.{u1, u1, u2} α (MulOpposite.{u1} α) β _inst_1 (MulOpposite.addZeroClass.{u1} α _inst_1) _inst_2 g (AddEquiv.toAddMonoidHom.{u1, u1} α (MulOpposite.{u1} α) _inst_1 (MulOpposite.addZeroClass.{u1} α _inst_1) (MulOpposite.opAddEquiv.{u1} α (AddZeroClass.toHasAdd.{u1} α _inst_1))))) -> (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} (MulOpposite.{u1} α) β (MulOpposite.addZeroClass.{u1} α _inst_1) _inst_2) f g)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : AddZeroClass.{u2} α] [_inst_2 : AddZeroClass.{u1} β] (f : AddMonoidHom.{u2, u1} (MulOpposite.{u2} α) β (MulOpposite.addZeroClass.{u2} α _inst_1) _inst_2) (g : AddMonoidHom.{u2, u1} (MulOpposite.{u2} α) β (MulOpposite.addZeroClass.{u2} α _inst_1) _inst_2), (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} α β _inst_1 _inst_2) (AddMonoidHom.comp.{u2, u2, u1} α (MulOpposite.{u2} α) β _inst_1 (MulOpposite.addZeroClass.{u2} α _inst_1) _inst_2 f (AddEquiv.toAddMonoidHom.{u2, u2} α (MulOpposite.{u2} α) _inst_1 (MulOpposite.addZeroClass.{u2} α _inst_1) (MulOpposite.opAddEquiv.{u2} α (AddZeroClass.toAdd.{u2} α _inst_1)))) (AddMonoidHom.comp.{u2, u2, u1} α (MulOpposite.{u2} α) β _inst_1 (MulOpposite.addZeroClass.{u2} α _inst_1) _inst_2 g (AddEquiv.toAddMonoidHom.{u2, u2} α (MulOpposite.{u2} α) _inst_1 (MulOpposite.addZeroClass.{u2} α _inst_1) (MulOpposite.opAddEquiv.{u2} α (AddZeroClass.toAdd.{u2} α _inst_1))))) -> (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} (MulOpposite.{u2} α) β (MulOpposite.addZeroClass.{u2} α _inst_1) _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.mul_op_ext AddMonoidHom.mul_op_extₓ'. -/\n/-- This ext lemma change equalities on `αᵐᵒᵖ →+ β` to equalities on `α →+ β`.\nThis is useful because there are often ext lemmas for specific `α`s that will apply\nto an equality of `α →+ β` such as `finsupp.add_hom_ext'`. -/\n@[ext]\ntheorem AddMonoidHom.mul_op_ext {α β} [AddZeroClass α] [AddZeroClass β] (f g : αᵐᵒᵖ →+ β)\n    (h :\n      f.comp (opAddEquiv : α ≃+ αᵐᵒᵖ).toAddMonoidHom =\n        g.comp (opAddEquiv : α ≃+ αᵐᵒᵖ).toAddMonoidHom) :\n    f = g :=\n  AddMonoidHom.ext <| MulOpposite.rec' fun x => (AddMonoidHom.congr_fun h : _) x\n#align add_monoid_hom.mul_op_ext AddMonoidHom.mul_op_ext\n\nend Ext\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Group/Opposite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.6477982315512489, "lm_q1q2_score": 0.4572062848703305}}
{"text": "/-\nCopyright (c) 2022 Mathieu Chanavat. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mathieu Chanavat\n-/\nimport category_theory.limits.shapes.finite_limits\nimport category_theory.closed.cartesian\nimport category_theory.subobject.basic\n\nimport order.heyting.basic\n\n\n/-!\n# Subobject classifier for elementary topos\n\nUseful api to work wiht pullback inside a topos\n-/\n\nopen category_theory category_theory.category category_theory.limits \n\nuniverses v u\n\nnoncomputable theory\n\nvariables {C : Type u} [category.{v} C] [has_terminal.{v} C] \n\nvariables {U X Y : C}\n\nstructure classifying_pullback (truth : ⊤_ C ⟶ Y) (f : U ⟶ X) (χ : X ⟶ Y)  :=\n(comm : f ≫ χ = (terminal.from U) ≫ truth)\n(is_pb : is_limit (pullback_cone.mk _ _ comm))\n\nattribute [reassoc] classifying_pullback.comm\n\nabbreviation classifying {Ω U X : C} (truth : ⊤_ C ⟶ Ω) (f : U ⟶ X) (χ : X ⟶ Ω) := classifying_pullback truth f χ \n\nstructure is_subobject_classifier {Ω : C} (truth : ⊤_ C ⟶ Ω) :=\n(classifier_of : ∀ {U X} (f : U ⟶ X) [mono.{v} f], X ⟶ Ω)\n(classifies' : ∀ {U X} (f : U ⟶ X) [mono f], classifying truth f (classifier_of f))\n(uniquely' : ∀ {U X} (f : U ⟶ X) [mono f] (χ₁ : X ⟶ Ω), classifying truth f χ₁ → classifier_of f = χ₁)\n\nvariable (C)\n\n/--\nA category has a subobject classifier if there is a monomorphism `truth` which is a\nsubobject classifier.\n-/\nclass has_subobject_classifier :=\n(Ω : C)\n(truth : ⊤_ C ⟶ Ω)\n[truth_mono : mono.{v} truth]\n(is_subobj_classifier : is_subobject_classifier truth)\n\nvariables [has_subobject_classifier.{v} C]\n\n/-! Convenience interface to the `has_subobject_classifier` class. -/\nnamespace classifier\n\n/-- Convenience notation for the classifier target given the typeclass `has_subobject_classifier`. -/\ndef Ω : C := has_subobject_classifier.Ω.{v}\n/-- Convenience notation for the classifier given the typeclass `has_subobject_classifier`. -/\ndef truth : ⊤_ C ⟶ Ω C := has_subobject_classifier.truth\n/-- From the typeclass `has_subobject_classifier`, show that the classifier `truth` is a monomorphism. -/\ninstance truth_mono : mono (truth C) := has_subobject_classifier.truth_mono\n/-- The subobject classifier given by `has_subobject_classifier` is actually a classifier. -/\ndef subobj_classifier_is_subobj_classifier : is_subobject_classifier (truth C) := has_subobject_classifier.is_subobj_classifier\n\nvariable {C}\ndef classifier_of {U X : C} (f : U ⟶ X) [mono f] : X ⟶ Ω C :=\n(subobj_classifier_is_subobj_classifier C).classifier_of f\ndef classifies {U X : C} (f : U ⟶ X) [mono f] : classifying (truth C) f (classifier_of f) :=\n(subobj_classifier_is_subobj_classifier C).classifies' f\nlemma uniquely {U X : C} (f : U ⟶ X) [mono f] (χ₁ : X ⟶ Ω C) (hχ : classifying (truth C) f χ₁) : classifier_of f = χ₁ :=\n(subobj_classifier_is_subobj_classifier C).uniquely' f χ₁ hχ\n \nlemma classifier.comm {U X : C} (f : U ⟶ X) [mono f] : \n  f ≫ (classifier_of f) = terminal.from _ ≫ truth C :=\nclassifying_pullback.comm (classifies _)\n\nlemma classifier.is_pb {U X : C} (f : U ⟶ X) [mono f] :\n  is_limit (pullback_cone.mk _ _ (classifier.comm f)) := classifying_pullback.is_pb (classifies _)\n\nend classifier\n\n/- If we have σ : X → Ω then we have the following pullback, we call { σ } the canonical subobject\n  { σ } -> ⊤\n    |      |\n    X ---> Ω \n-/\n\nvariable {C}\nnotation `s{` σ `}s` := pullback σ (classifier.truth _)\n\n\n\nopen classifier\n\n\n/- true_X from McLane -/\nabbreviation lift_truth (X : C) : X ⟶ Ω C := terminal.from X ≫ truth C\n\nabbreviation canonical_incl {X : C} [has_pullbacks C] (σ : X ⟶ Ω C) : s{ σ }s ⟶ X := pullback.fst\n\ndef canonical_incl_of_mono {X Y : C} [has_pullbacks C] (m : X ⟶ Y) [mono m] : \n  s{ classifier_of m }s ⟶ Y :=\ncanonical_incl (classifier_of m)\n\nvariables [has_pullbacks C] (σ : X ⟶ Ω C)\n\ninstance canonical_incl_mono : mono (canonical_incl σ) := pullback.fst_of_mono\n\nlemma canonical_incl_comm : canonical_incl σ ≫ σ = terminal.from s{ σ }s ≫ truth C :=\nbegin\n  convert pullback.condition\nend\n\nabbreviation canonical_sub : subobject X := subobject.mk (canonical_incl σ)\n\ndef canonical_sub_iso_canonical : ↑(canonical_sub σ) ≅ s{ σ }s :=\nbegin\n  apply subobject.iso_of_eq_mk _ (canonical_incl σ), refl\nend\n\ndef canonical_iso_canonical_sub : s{ σ }s ≅ ↑(canonical_sub σ) := \n(canonical_sub_iso_canonical σ).symm\n\nlemma sub_eq_canonical_sub_of_classifier (S : subobject X) : \n  canonical_sub (classifier_of S.arrow) = S :=\nbegin\n  ext1,\n  exact is_limit.cone_point_unique_up_to_iso_hom_comp \n    (pullback_is_pullback _ _) (classifier.is_pb S.arrow) walking_cospan.left\nend\n\ndef pb_cone_of_canonical_sub_arrow : pullback_cone σ (truth C) :=\npullback_cone.mk (canonical_sub σ).arrow (terminal.from _) \n(by { rw [←subobject.underlying_iso_hom_comp_eq_mk, assoc, \n          canonical_incl_comm, ←assoc, terminal.comp_from] })\n\nlemma pb_cone_of_canonical_sub_arrow_X : \n  (pb_cone_of_canonical_sub_arrow σ).X = ↑(canonical_sub σ) := rfl\n\nlemma is_pullback_canonical_arrow :\n  is_limit (pb_cone_of_canonical_sub_arrow σ) :=\nbegin\n  apply is_limit.of_iso_limit (pullback_is_pullback σ (truth C)),\n  symmetry,\n  refine pullback_cone.ext (subobject.underlying_iso (canonical_incl σ)) _ \n    (is_terminal.hom_ext (terminal_is_terminal) _ _),\n  symmetry, rw [pullback_cone.mk_fst, subobject.underlying_iso_hom_comp_eq_mk], refl\nend\n\nlemma canonical_is_pullback : \n  is_limit (pullback_cone.mk (canonical_incl σ) (terminal.from _) (canonical_incl_comm σ)) :=\nbegin\n convert pullback_is_pullback _ _,\n  apply is_terminal.hom_ext terminal_is_terminal,\nend\n\nlemma canonical_incl_classifies : classifying (truth C) (canonical_incl σ) σ :=\n{ comm := canonical_incl_comm σ,\n  is_pb := canonical_is_pullback σ }\n \n@[simp] lemma classifier_of_canonical_incl_eq_self : classifier_of (canonical_incl σ) = σ :=\nuniquely _ _ (canonical_incl_classifies σ)\n\n\n\n/- The truth classifies the identity -/\nvariable (C)\n\nlemma terminal_from_self_is_id : terminal.from (⊤_ C) = 𝟙 (⊤_ C) := \nis_terminal.from_self terminal_is_terminal\n\nlemma truth_classifies_id : classifying (truth C) (𝟙 (⊤_ C)) (truth C) := \n{ comm := by rw (terminal_from_self_is_id ),\n  is_pb := \n  begin\n    conv in (terminal.from (⊤_ C)) {rw terminal_from_self_is_id },\n    exact pullback_cone.is_limit_mk_id_id (truth C)\n  end\n}\n\nlemma truth_classifies_id.comm : 𝟙 (⊤_ C) ≫ (truth C) = 𝟙 (⊤_ C) ≫ (truth C) := by simp\nlemma truth_classifies_id.is_pb : \n  is_limit (pullback_cone.mk (𝟙 (⊤_ C)) (𝟙 (⊤_ C)) (truth_classifies_id.comm C)) :=\nbegin \n  have h := (truth_classifies_id C).is_pb,\n  conv at h in (terminal.from (⊤_ C)) {rw terminal_from_self_is_id},\n  assumption\nend\n", "meta": {"author": "cchanavat", "repo": "lean-topos", "sha": "c8e22c35ed4dc4ea0d74a59c91785b8a4c8e48a4", "save_path": "github-repos/lean/cchanavat-lean-topos", "path": "github-repos/lean/cchanavat-lean-topos/lean-topos-c8e22c35ed4dc4ea0d74a59c91785b8a4c8e48a4/subobject_classifier.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.45720628170986166}}
{"text": "/-\nCopyright (c) 2020 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n\nBasic topological facts (limits and continuity) about `floor`,\n`ceil` and `fract` in a `floor_ring`.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.algebra.ordered\nimport Mathlib.algebra.floor\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\ntheorem tendsto_floor_at_top {α : Type u_1} [linear_ordered_ring α] [floor_ring α] : filter.tendsto floor filter.at_top filter.at_top := sorry\n\ntheorem tendsto_floor_at_bot {α : Type u_1} [linear_ordered_ring α] [floor_ring α] : filter.tendsto floor filter.at_bot filter.at_bot :=\n  monotone.tendsto_at_bot_at_bot (fun (a b : α) (hab : a ≤ b) => floor_mono hab)\n    fun (b : ℤ) => Exists.intro (↑b) (eq.mpr (id (Eq._oldrec (Eq.refl (floor ↑b ≤ b)) (floor_coe b))) (le_refl b))\n\ntheorem tendsto_ceil_at_top {α : Type u_1} [linear_ordered_ring α] [floor_ring α] : filter.tendsto ceil filter.at_top filter.at_top :=\n  filter.tendsto.comp filter.tendsto_neg_at_bot_at_top\n    (filter.tendsto.comp tendsto_floor_at_bot filter.tendsto_neg_at_top_at_bot)\n\ntheorem tendsto_ceil_at_bot {α : Type u_1} [linear_ordered_ring α] [floor_ring α] : filter.tendsto ceil filter.at_bot filter.at_bot :=\n  filter.tendsto.comp filter.tendsto_neg_at_top_at_bot\n    (filter.tendsto.comp tendsto_floor_at_top filter.tendsto_neg_at_bot_at_top)\n\ntheorem continuous_on_floor {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] (n : ℤ) : continuous_on (fun (x : α) => ↑(floor x)) (set.Ico (↑n) (↑n + 1)) :=\n  iff.mpr (continuous_on_congr (floor_eq_on_Ico' n)) continuous_on_const\n\ntheorem continuous_on_ceil {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] (n : ℤ) : continuous_on (fun (x : α) => ↑(ceil x)) (set.Ioc (↑n - 1) ↑n) :=\n  iff.mpr (continuous_on_congr (ceil_eq_on_Ioc' n)) continuous_on_const\n\ntheorem tendsto_floor_right' {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(floor x)) (nhds_within (↑n) (set.Ici ↑n)) (nhds ↑n) := sorry\n\ntheorem tendsto_ceil_left' {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(ceil x)) (nhds_within (↑n) (set.Iic ↑n)) (nhds ↑n) := sorry\n\ntheorem tendsto_floor_right {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(floor x)) (nhds_within (↑n) (set.Ici ↑n)) (nhds_within (↑n) (set.Ici ↑n)) := sorry\n\ntheorem tendsto_ceil_left {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(ceil x)) (nhds_within (↑n) (set.Iic ↑n)) (nhds_within (↑n) (set.Iic ↑n)) := sorry\n\ntheorem tendsto_floor_left {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(floor x)) (nhds_within (↑n) (set.Iio ↑n)) (nhds_within (↑n - 1) (set.Iic (↑n - 1))) := sorry\n\ntheorem tendsto_ceil_right {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(ceil x)) (nhds_within (↑n) (set.Ioi ↑n)) (nhds_within (↑n + 1) (set.Ici (↑n + 1))) := sorry\n\ntheorem tendsto_floor_left' {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(floor x)) (nhds_within (↑n) (set.Iio ↑n)) (nhds (↑n - 1)) := sorry\n\ntheorem tendsto_ceil_right' {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] (n : ℤ) : filter.tendsto (fun (x : α) => ↑(ceil x)) (nhds_within (↑n) (set.Ioi ↑n)) (nhds (↑n + 1)) := sorry\n\ntheorem continuous_on_fract {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [topological_add_group α] (n : ℤ) : continuous_on fract (set.Ico (↑n) (↑n + 1)) :=\n  continuous_on.sub continuous_on_id (continuous_on_floor n)\n\ntheorem tendsto_fract_left' {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] [topological_add_group α] (n : ℤ) : filter.tendsto fract (nhds_within (↑n) (set.Iio ↑n)) (nhds 1) := sorry\n\ntheorem tendsto_fract_left {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] [topological_add_group α] (n : ℤ) : filter.tendsto fract (nhds_within (↑n) (set.Iio ↑n)) (nhds_within 1 (set.Iio 1)) :=\n  tendsto_nhds_within_of_tendsto_nhds_of_eventually_within fract (tendsto_fract_left' n)\n    (filter.eventually_of_forall fract_lt_one)\n\ntheorem tendsto_fract_right' {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] [topological_add_group α] (n : ℤ) : filter.tendsto fract (nhds_within (↑n) (set.Ici ↑n)) (nhds 0) := sorry\n\ntheorem tendsto_fract_right {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] [order_closed_topology α] [topological_add_group α] (n : ℤ) : filter.tendsto fract (nhds_within (↑n) (set.Ici ↑n)) (nhds_within 0 (set.Ici 0)) :=\n  tendsto_nhds_within_of_tendsto_nhds_of_eventually_within fract (tendsto_fract_right' n)\n    (filter.eventually_of_forall fract_nonneg)\n\ntheorem continuous_on.comp_fract' {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] {β : Type u_2} {γ : Type u_3} [order_topology α] [topological_add_group α] [topological_space β] [topological_space γ] {f : β → α → γ} (h : continuous_on (function.uncurry f) (set.prod set.univ (set.Icc 0 1))) (hf : ∀ (s : β), f s 0 = f s 1) : continuous fun (st : β × α) => f (prod.fst st) (fract (prod.snd st)) := sorry\n\ntheorem continuous_on.comp_fract {α : Type u_1} [linear_ordered_ring α] [floor_ring α] [topological_space α] {β : Type u_2} [order_topology α] [topological_add_group α] [topological_space β] {f : α → β} (h : continuous_on f (set.Icc 0 1)) (hf : f 0 = f 1) : continuous (f ∘ fract) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/floor_ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679957, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.45715955719625273}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport topology.metric_space.closeds\nimport set_theory.cardinal\nimport topology.metric_space.gromov_hausdorff_realized\nimport topology.metric_space.completion\nimport topology.metric_space.kuratowski\n\n/-!\n# Gromov-Hausdorff distance\n\nThis file defines the Gromov-Hausdorff distance on the space of nonempty compact metric spaces\nup to isometry.\n\nWe introduce the space of all nonempty compact metric spaces, up to isometry,\ncalled `GH_space`, and endow it with a metric space structure. The distance,\nknown as the Gromov-Hausdorff distance, is defined as follows: given two\nnonempty compact spaces `X` and `Y`, their distance is the minimum Hausdorff distance\nbetween all possible isometric embeddings of `X` and `Y` in all metric spaces.\nTo define properly the Gromov-Hausdorff space, we consider the non-empty\ncompact subsets of `ℓ^∞(ℝ)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `ℓ^∞(ℝ)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `ℓ^∞(ℝ)`, through an\nembedding called the Kuratowski embedding.\nTo prove that we have a distance, we should show that if spaces can be coupled\nto be arbitrarily close, then they are isometric. More generally, the Gromov-Hausdorff\ndistance is realized, i.e., there is a coupling for which the Hausdorff distance\nis exactly the Gromov-Hausdorff distance. This follows from a compactness\nargument, essentially following from Arzela-Ascoli.\n\n## Main results\n\nWe prove the most important properties of the Gromov-Hausdorff space: it is a polish space,\ni.e., it is complete and second countable. We also prove the Gromov compactness criterion.\n\n-/\n\nnoncomputable theory\nopen_locale classical topological_space ennreal\n\nlocal notation `ℓ_infty_ℝ`:= lp (λ n : ℕ, ℝ) ∞\n\nuniverses u v w\n\nopen classical set function topological_space filter metric quotient\nopen bounded_continuous_function nat int Kuratowski_embedding\nopen sum (inl inr)\n\nlocal attribute [instance] metric_space_sum\n\n\nnamespace Gromov_Hausdorff\n\nsection GH_space\n/- In this section, we define the Gromov-Hausdorff space, denoted `GH_space` as the quotient\nof nonempty compact subsets of `ℓ^∞(ℝ)` by identifying isometric sets.\nUsing the Kuratwoski embedding, we get a canonical map `to_GH_space` mapping any nonempty\ncompact type to `GH_space`. -/\n\n/-- Equivalence relation identifying two nonempty compact sets which are isometric -/\nprivate definition isometry_rel :\n  nonempty_compacts ℓ_infty_ℝ → nonempty_compacts ℓ_infty_ℝ → Prop :=\n  λ x y, nonempty (x.val ≃ᵢ y.val)\n\n/-- This is indeed an equivalence relation -/\nprivate lemma is_equivalence_isometry_rel : equivalence isometry_rel :=\n⟨λ x, ⟨isometric.refl _⟩, λ x y ⟨e⟩, ⟨e.symm⟩, λ x y z ⟨e⟩ ⟨f⟩, ⟨e.trans f⟩⟩\n\n/-- setoid instance identifying two isometric nonempty compact subspaces of ℓ^∞(ℝ) -/\ninstance isometry_rel.setoid : setoid (nonempty_compacts ℓ_infty_ℝ) :=\nsetoid.mk isometry_rel is_equivalence_isometry_rel\n\n/-- The Gromov-Hausdorff space -/\ndefinition GH_space : Type := quotient (isometry_rel.setoid)\n\n/-- Map any nonempty compact type to `GH_space` -/\ndefinition to_GH_space (X : Type u) [metric_space X] [compact_space X] [nonempty X] : GH_space :=\n  ⟦nonempty_compacts.Kuratowski_embedding X⟧\n\ninstance : inhabited GH_space := ⟨quot.mk _ ⟨{0}, by simp⟩⟩\n\n/-- A metric space representative of any abstract point in `GH_space` -/\n@[nolint has_inhabited_instance]\ndefinition GH_space.rep (p : GH_space) : Type := (quot.out p).val\n\nlemma eq_to_GH_space_iff {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {p : nonempty_compacts ℓ_infty_ℝ} :\n  ⟦p⟧ = to_GH_space X ↔ ∃ Ψ : X → ℓ_infty_ℝ, isometry Ψ ∧ range Ψ = p.val :=\nbegin\n  simp only [to_GH_space, quotient.eq],\n  refine ⟨λ h, _, _⟩,\n  { rcases setoid.symm h with ⟨e⟩,\n    have f := (Kuratowski_embedding.isometry X).isometric_on_range.trans e,\n    use [λ x, f x, isometry_subtype_coe.comp f.isometry],\n    rw [range_comp, f.range_eq_univ, set.image_univ, subtype.range_coe] },\n  { rintros ⟨Ψ, ⟨isomΨ, rangeΨ⟩⟩,\n    have f := ((Kuratowski_embedding.isometry X).isometric_on_range.symm.trans\n               isomΨ.isometric_on_range).symm,\n    have E : (range Ψ ≃ᵢ (nonempty_compacts.Kuratowski_embedding X).val) =\n        (p.val ≃ᵢ range (Kuratowski_embedding X)),\n      by { dunfold nonempty_compacts.Kuratowski_embedding, rw [rangeΨ]; refl },\n    exact ⟨cast E f⟩ }\nend\n\nlemma eq_to_GH_space {p : nonempty_compacts ℓ_infty_ℝ} : ⟦p⟧ = to_GH_space p.val :=\neq_to_GH_space_iff.2 ⟨λ x, x, isometry_subtype_coe, subtype.range_coe⟩\n\nsection\nlocal attribute [reducible] GH_space.rep\n\ninstance rep_GH_space_metric_space {p : GH_space} : metric_space (p.rep) :=\nby apply_instance\n\ninstance rep_GH_space_compact_space {p : GH_space} : compact_space (p.rep) :=\nby apply_instance\n\ninstance rep_GH_space_nonempty {p : GH_space} : nonempty (p.rep) :=\nby apply_instance\nend\n\nlemma GH_space.to_GH_space_rep (p : GH_space) : to_GH_space (p.rep) = p :=\nbegin\n  change to_GH_space (quot.out p).val = p,\n  rw ← eq_to_GH_space,\n  exact quot.out_eq p\nend\n\n/-- Two nonempty compact spaces have the same image in `GH_space` if and only if they are\nisometric. -/\nlemma to_GH_space_eq_to_GH_space_iff_isometric {X : Type u} [metric_space X] [compact_space X]\n  [nonempty X] {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y] :\n  to_GH_space X = to_GH_space Y ↔ nonempty (X ≃ᵢ Y) :=\n⟨begin\n  simp only [to_GH_space, quotient.eq],\n  rintro ⟨e⟩,\n  have I : ((nonempty_compacts.Kuratowski_embedding X).val ≃ᵢ\n             (nonempty_compacts.Kuratowski_embedding Y).val)\n          = ((range (Kuratowski_embedding X)) ≃ᵢ (range (Kuratowski_embedding Y))),\n    by { dunfold nonempty_compacts.Kuratowski_embedding, refl },\n  have f := (Kuratowski_embedding.isometry X).isometric_on_range,\n  have g := (Kuratowski_embedding.isometry Y).isometric_on_range.symm,\n  exact ⟨f.trans $ (cast I e).trans g⟩\nend,\nbegin\n  rintro ⟨e⟩,\n  simp only [to_GH_space, quotient.eq],\n  have f := (Kuratowski_embedding.isometry X).isometric_on_range.symm,\n  have g := (Kuratowski_embedding.isometry Y).isometric_on_range,\n  have I : ((range (Kuratowski_embedding X)) ≃ᵢ (range (Kuratowski_embedding Y))) =\n    ((nonempty_compacts.Kuratowski_embedding X).val ≃ᵢ\n      (nonempty_compacts.Kuratowski_embedding Y).val),\n    by { dunfold nonempty_compacts.Kuratowski_embedding, refl },\n  exact ⟨cast I ((f.trans e).trans g)⟩\nend⟩\n\n/-- Distance on `GH_space`: the distance between two nonempty compact spaces is the infimum\nHausdorff distance between isometric copies of the two spaces in a metric space. For the definition,\nwe only consider embeddings in `ℓ^∞(ℝ)`, but we will prove below that it works for all spaces. -/\ninstance : has_dist (GH_space) :=\n{ dist := λ x y, Inf $\n    (λ p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ,\n      Hausdorff_dist p.1.val p.2.val) '' ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y}) }\n\n/-- The Gromov-Hausdorff distance between two nonempty compact metric spaces, equal by definition to\nthe distance of the equivalence classes of these spaces in the Gromov-Hausdorff space. -/\ndef GH_dist (X : Type u) (Y : Type v) [metric_space X] [nonempty X] [compact_space X]\n  [metric_space Y] [nonempty Y] [compact_space Y] : ℝ := dist (to_GH_space X) (to_GH_space Y)\n\nlemma dist_GH_dist (p q : GH_space) : dist p q = GH_dist (p.rep) (q.rep) :=\nby rw [GH_dist, p.to_GH_space_rep, q.to_GH_space_rep]\n\n/-- The Gromov-Hausdorff distance between two spaces is bounded by the Hausdorff distance\nof isometric copies of the spaces, in any metric space. -/\ntheorem GH_dist_le_Hausdorff_dist {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y]\n  {γ : Type w} [metric_space γ] {Φ : X → γ} {Ψ : Y → γ} (ha : isometry Φ) (hb : isometry Ψ) :\n  GH_dist X Y ≤ Hausdorff_dist (range Φ) (range Ψ) :=\nbegin\n  /- For the proof, we want to embed `γ` in `ℓ^∞(ℝ)`, to say that the Hausdorff distance is realized\n  in `ℓ^∞(ℝ)` and therefore bounded below by the Gromov-Hausdorff-distance. However, `γ` is not\n  separable in general. We restrict to the union of the images of `X` and `Y` in `γ`, which is\n  separable and therefore embeddable in `ℓ^∞(ℝ)`. -/\n  rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n  let s : set γ := (range Φ) ∪ (range Ψ),\n  let Φ' : X → subtype s := λ y, ⟨Φ y, mem_union_left _ (mem_range_self _)⟩,\n  let Ψ' : Y → subtype s := λ y, ⟨Ψ y, mem_union_right _ (mem_range_self _)⟩,\n  have IΦ' : isometry Φ' := λ x y, ha x y,\n  have IΨ' : isometry Ψ' := λ x y, hb x y,\n  have : is_compact s, from (is_compact_range ha.continuous).union (is_compact_range hb.continuous),\n  letI : metric_space (subtype s) := by apply_instance,\n  haveI : compact_space (subtype s) := ⟨is_compact_iff_is_compact_univ.1 ‹is_compact s›⟩,\n  haveI : nonempty (subtype s) := ⟨Φ' xX⟩,\n  have ΦΦ' : Φ = subtype.val ∘ Φ', by { funext, refl },\n  have ΨΨ' : Ψ = subtype.val ∘ Ψ', by { funext, refl },\n  have : Hausdorff_dist (range Φ) (range Ψ) = Hausdorff_dist (range Φ') (range Ψ'),\n  { rw [ΦΦ', ΨΨ', range_comp, range_comp],\n    exact Hausdorff_dist_image (isometry_subtype_coe) },\n  rw this,\n  -- Embed `s` in `ℓ^∞(ℝ)` through its Kuratowski embedding\n  let F := Kuratowski_embedding (subtype s),\n  have : Hausdorff_dist (F '' (range Φ')) (F '' (range Ψ')) =\n    Hausdorff_dist (range Φ') (range Ψ') := Hausdorff_dist_image (Kuratowski_embedding.isometry _),\n  rw ← this,\n  -- Let `A` and `B` be the images of `X` and `Y` under this embedding. They are in `ℓ^∞(ℝ)`, and\n  -- their Hausdorff distance is the same as in the original space.\n  let A : nonempty_compacts ℓ_infty_ℝ := ⟨F '' (range Φ'), ⟨(range_nonempty _).image _,\n      (is_compact_range IΦ'.continuous).image (Kuratowski_embedding.isometry _).continuous⟩⟩,\n  let B : nonempty_compacts ℓ_infty_ℝ := ⟨F '' (range Ψ'), ⟨(range_nonempty _).image _,\n      (is_compact_range IΨ'.continuous).image (Kuratowski_embedding.isometry _).continuous⟩⟩,\n  have AX : ⟦A⟧ = to_GH_space X,\n  { rw eq_to_GH_space_iff,\n    exact ⟨λ x, F (Φ' x), ⟨(Kuratowski_embedding.isometry _).comp IΦ', by rw range_comp⟩⟩ },\n  have BY : ⟦B⟧ = to_GH_space Y,\n  { rw eq_to_GH_space_iff,\n    exact ⟨λ x, F (Ψ' x), ⟨(Kuratowski_embedding.isometry _).comp IΨ', by rw range_comp⟩⟩ },\n  refine cInf_le ⟨0,\n    begin simp [lower_bounds], assume t _ _ _ _ ht, rw ← ht, exact Hausdorff_dist_nonneg end⟩ _,\n  apply (mem_image _ _ _).2,\n  existsi (⟨A, B⟩ : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n  simp [AX, BY]\nend\n\n/-- The optimal coupling constructed above realizes exactly the Gromov-Hausdorff distance,\nessentially by design. -/\nlemma Hausdorff_dist_optimal {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y] :\n  Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) = GH_dist X Y :=\nbegin\n  inhabit X, inhabit Y,\n  /- we only need to check the inequality `≤`, as the other one follows from the previous lemma.\n     As the Gromov-Hausdorff distance is an infimum, we need to check that the Hausdorff distance\n     in the optimal coupling is smaller than the Hausdorff distance of any coupling.\n     First, we check this for couplings which already have small Hausdorff distance: in this\n     case, the induced \"distance\" on `X ⊕ Y` belongs to the candidates family introduced in the\n     definition of the optimal coupling, and the conclusion follows from the optimality\n     of the optimal coupling within this family.\n  -/\n  have A : ∀ p q : nonempty_compacts (ℓ_infty_ℝ), ⟦p⟧ = to_GH_space X → ⟦q⟧ = to_GH_space Y →\n        Hausdorff_dist (p.val) (q.val) < diam (univ : set X) + 1 + diam (univ : set Y) →\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤\n        Hausdorff_dist (p.val) (q.val),\n  { assume p q hp hq bound,\n    rcases eq_to_GH_space_iff.1 hp with ⟨Φ, ⟨Φisom, Φrange⟩⟩,\n    rcases eq_to_GH_space_iff.1 hq with ⟨Ψ, ⟨Ψisom, Ψrange⟩⟩,\n    have I : diam (range Φ ∪ range Ψ) ≤ 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y),\n    { rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n      have : ∃ y ∈ range Ψ, dist (Φ xX) y < diam (univ : set X) + 1 + diam (univ : set Y),\n      { rw Ψrange,\n        have : Φ xX ∈ p.val := Φrange ▸ mem_range_self _,\n        exact exists_dist_lt_of_Hausdorff_dist_lt this bound\n          (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.2.1 q.2.1 p.2.2.bounded q.2.2.bounded) },\n      rcases this with ⟨y, hy, dy⟩,\n      rcases mem_range.1 hy with ⟨z, hzy⟩,\n      rw ← hzy at dy,\n      have DΦ : diam (range Φ) = diam (univ : set X) := Φisom.diam_range,\n      have DΨ : diam (range Ψ) = diam (univ : set Y) := Ψisom.diam_range,\n      calc\n        diam (range Φ ∪ range Ψ) ≤ diam (range Φ) + dist (Φ xX) (Ψ z) + diam (range Ψ) :\n          diam_union (mem_range_self _) (mem_range_self _)\n        ... ≤ diam (univ : set X) + (diam (univ : set X) + 1 + diam (univ : set Y)) +\n              diam (univ : set Y) :\n          by { rw [DΦ, DΨ], apply add_le_add (add_le_add le_rfl (le_of_lt dy)) le_rfl }\n        ... = 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y) : by ring },\n\n    let f : X ⊕ Y → ℓ_infty_ℝ := λ x, match x with | inl y := Φ y | inr z := Ψ z end,\n    let F : (X ⊕ Y) × (X ⊕ Y) → ℝ := λ p, dist (f p.1) (f p.2),\n    -- check that the induced \"distance\" is a candidate\n    have Fgood : F ∈ candidates X Y,\n    { simp only [candidates, forall_const, and_true, add_comm, eq_self_iff_true, dist_eq_zero,\n                 and_self, set.mem_set_of_eq],\n      repeat {split},\n      { exact λ x y, calc\n        F (inl x, inl y) = dist (Φ x) (Φ y) : rfl\n        ... = dist x y : Φisom.dist_eq x y },\n      { exact λ x y, calc\n        F (inr x, inr y) = dist (Ψ x) (Ψ y) : rfl\n        ... = dist x y : Ψisom.dist_eq x y },\n      { exact λ x y, dist_comm _ _ },\n      { exact λ x y z, dist_triangle _ _ _ },\n      { exact λ x y, calc\n        F (x, y) ≤ diam (range Φ ∪ range Ψ) :\n        begin\n          have A : ∀ z : X ⊕ Y, f z ∈ range Φ ∪ range Ψ,\n          { assume z,\n            cases z,\n            { apply mem_union_left, apply mem_range_self },\n            { apply mem_union_right, apply mem_range_self } },\n          refine dist_le_diam_of_mem _ (A _) (A _),\n          rw [Φrange, Ψrange],\n          exact (p.2.2.union q.2.2).bounded,\n        end\n        ... ≤ 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y) : I } },\n    let Fb := candidates_b_of_candidates F Fgood,\n    have : Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤ HD Fb :=\n      Hausdorff_dist_optimal_le_HD _ _ (candidates_b_of_candidates_mem F Fgood),\n    refine le_trans this (le_of_forall_le_of_dense (λ r hr, _)),\n    have I1 : ∀ x : X, (⨅ y, Fb (inl x, inr y)) ≤ r,\n    { assume x,\n      have : f (inl x) ∈ p.val, by { rw [← Φrange], apply mem_range_self },\n      rcases exists_dist_lt_of_Hausdorff_dist_lt this hr\n        (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.2.1 q.2.1 p.2.2.bounded q.2.2.bounded)\n        with ⟨z, zq, hz⟩,\n      have : z ∈ range Ψ, by rwa [← Ψrange] at zq,\n      rcases mem_range.1 this with ⟨y, hy⟩,\n      calc (⨅ y, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux1 0) y\n        ... = dist (Φ x) (Ψ y) : rfl\n        ... = dist (f (inl x)) z : by rw hy\n        ... ≤ r : le_of_lt hz },\n    have I2 : ∀ y : Y, (⨅ x, Fb (inl x, inr y)) ≤ r,\n    { assume y,\n      have : f (inr y) ∈ q.val, by { rw [← Ψrange], apply mem_range_self },\n      rcases exists_dist_lt_of_Hausdorff_dist_lt' this hr\n        (Hausdorff_edist_ne_top_of_nonempty_of_bounded p.2.1 q.2.1 p.2.2.bounded q.2.2.bounded)\n        with ⟨z, zq, hz⟩,\n      have : z ∈ range Φ, by rwa [← Φrange] at zq,\n      rcases mem_range.1 this with ⟨x, hx⟩,\n      calc (⨅ x, Fb (inl x, inr y)) ≤ Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux2 0) x\n        ... = dist (Φ x) (Ψ y) : rfl\n        ... = dist z (f (inr y)) : by rw hx\n        ... ≤ r : le_of_lt hz },\n    simp [HD, csupr_le I1, csupr_le I2] },\n  /- Get the same inequality for any coupling. If the coupling is quite good, the desired\n  inequality has been proved above. If it is bad, then the inequality is obvious. -/\n  have B : ∀ p q : nonempty_compacts (ℓ_infty_ℝ), ⟦p⟧ = to_GH_space X → ⟦q⟧ = to_GH_space Y →\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) ≤\n        Hausdorff_dist (p.val) (q.val),\n  { assume p q hp hq,\n    by_cases h : Hausdorff_dist (p.val) (q.val) < diam (univ : set X) + 1 + diam (univ : set Y),\n    { exact A p q hp hq h },\n    { calc Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y))\n               ≤ HD (candidates_b_dist X Y) :\n             Hausdorff_dist_optimal_le_HD _ _ (candidates_b_dist_mem_candidates_b)\n           ... ≤ diam (univ : set X) + 1 + diam (univ : set Y) : HD_candidates_b_dist_le\n           ... ≤ Hausdorff_dist (p.val) (q.val) : not_lt.1 h } },\n  refine le_antisymm _ _,\n  { apply le_cInf,\n    { refine (set.nonempty.prod _ _).image _; exact ⟨_, rfl⟩ },\n    { rintro b ⟨⟨p, q⟩, ⟨hp, hq⟩, rfl⟩,\n      exact B p q hp hq } },\n  { exact GH_dist_le_Hausdorff_dist (isometry_optimal_GH_injl X Y) (isometry_optimal_GH_injr X Y) }\nend\n\n/-- The Gromov-Hausdorff distance can also be realized by a coupling in `ℓ^∞(ℝ)`, by embedding\nthe optimal coupling through its Kuratowski embedding. -/\ntheorem GH_dist_eq_Hausdorff_dist (X : Type u) [metric_space X] [compact_space X] [nonempty X]\n  (Y : Type v) [metric_space Y] [compact_space Y] [nonempty Y] :\n  ∃ Φ : X → ℓ_infty_ℝ, ∃ Ψ : Y → ℓ_infty_ℝ, isometry Φ ∧ isometry Ψ ∧\n  GH_dist X Y = Hausdorff_dist (range Φ) (range Ψ) :=\nbegin\n  let F := Kuratowski_embedding (optimal_GH_coupling X Y),\n  let Φ := F ∘ optimal_GH_injl X Y,\n  let Ψ := F ∘ optimal_GH_injr X Y,\n  refine ⟨Φ, Ψ, _, _, _⟩,\n  { exact (Kuratowski_embedding.isometry _).comp (isometry_optimal_GH_injl X Y) },\n  { exact (Kuratowski_embedding.isometry _).comp (isometry_optimal_GH_injr X Y) },\n  { rw [← image_univ, ← image_univ, image_comp F, image_univ, image_comp F (optimal_GH_injr X Y),\n      image_univ, ← Hausdorff_dist_optimal],\n    exact (Hausdorff_dist_image (Kuratowski_embedding.isometry _)).symm },\nend\n\n/-- The Gromov-Hausdorff distance defines a genuine distance on the Gromov-Hausdorff space. -/\ninstance : metric_space GH_space :=\n{ dist_self := λ x, begin\n    rcases exists_rep x with ⟨y, hy⟩,\n    refine le_antisymm _ _,\n    { apply cInf_le,\n      { exact ⟨0, by { rintro b ⟨⟨u, v⟩, ⟨hu, hv⟩, rfl⟩, exact Hausdorff_dist_nonneg } ⟩},\n      { simp, existsi [y, y], simpa } },\n    { apply le_cInf,\n      { exact (nonempty.prod ⟨y, hy⟩ ⟨y, hy⟩).image _ },\n      { rintro b ⟨⟨u, v⟩, ⟨hu, hv⟩, rfl⟩, exact Hausdorff_dist_nonneg } },\n  end,\n  dist_comm := λ x y, begin\n    have A : (λ (p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n                 Hausdorff_dist ((p.fst).val) ((p.snd).val)) ''\n             ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y})\n           = ((λ (p : nonempty_compacts ℓ_infty_ℝ × nonempty_compacts ℓ_infty_ℝ),\n                 Hausdorff_dist ((p.fst).val) ((p.snd).val)) ∘ prod.swap) ''\n                 ({a | ⟦a⟧ = x} ×ˢ {b | ⟦b⟧ = y}) :=\n      by { congr, funext, simp, rw Hausdorff_dist_comm },\n    simp only [dist, A, image_comp, image_swap_prod],\n  end,\n  eq_of_dist_eq_zero := λ x y hxy, begin\n    /- To show that two spaces at zero distance are isometric, we argue that the distance\n    is realized by some coupling. In this coupling, the two spaces are at zero Hausdorff distance,\n    i.e., they coincide. Therefore, the original spaces are isometric. -/\n    rcases GH_dist_eq_Hausdorff_dist x.rep y.rep with ⟨Φ, Ψ, Φisom, Ψisom, DΦΨ⟩,\n    rw [← dist_GH_dist, hxy] at DΦΨ,\n    have : range Φ = range Ψ,\n    { have hΦ : is_compact (range Φ) := is_compact_range Φisom.continuous,\n      have hΨ : is_compact (range Ψ) := is_compact_range Ψisom.continuous,\n      apply (is_closed.Hausdorff_dist_zero_iff_eq _ _ _).1 (DΦΨ.symm),\n      { exact hΦ.is_closed },\n      { exact hΨ.is_closed },\n      { exact Hausdorff_edist_ne_top_of_nonempty_of_bounded (range_nonempty _)\n          (range_nonempty _) hΦ.bounded hΨ.bounded } },\n    have T : ((range Ψ) ≃ᵢ y.rep) = ((range Φ) ≃ᵢ y.rep), by rw this,\n    have eΨ := cast T Ψisom.isometric_on_range.symm,\n    have e := Φisom.isometric_on_range.trans eΨ,\n    rw [← x.to_GH_space_rep, ← y.to_GH_space_rep, to_GH_space_eq_to_GH_space_iff_isometric],\n    exact ⟨e⟩\n  end,\n  dist_triangle := λ x y z, begin\n    /- To show the triangular inequality between `X`, `Y` and `Z`, realize an optimal coupling\n    between `X` and `Y` in a space `γ1`, and an optimal coupling between `Y` and `Z` in a space\n    `γ2`. Then, glue these metric spaces along `Y`. We get a new space `γ` in which `X` and `Y` are\n    optimally coupled, as well as `Y` and `Z`. Apply the triangle inequality for the Hausdorff\n    distance in `γ` to conclude. -/\n    let X := x.rep,\n    let Y := y.rep,\n    let Z := z.rep,\n    let γ1 := optimal_GH_coupling X Y,\n    let γ2 := optimal_GH_coupling Y Z,\n    let Φ : Y → γ1 := optimal_GH_injr X Y,\n    have hΦ : isometry Φ := isometry_optimal_GH_injr X Y,\n    let Ψ : Y → γ2 := optimal_GH_injl Y Z,\n    have hΨ : isometry Ψ := isometry_optimal_GH_injl Y Z,\n    let γ := glue_space hΦ hΨ,\n    letI : metric_space γ := metric.metric_space_glue_space hΦ hΨ,\n    have Comm : (to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y) =\n      (to_glue_r hΦ hΨ) ∘ (optimal_GH_injl Y Z) := to_glue_commute hΦ hΨ,\n    calc dist x z = dist (to_GH_space X) (to_GH_space Z) :\n        by rw [x.to_GH_space_rep, z.to_GH_space_rep]\n      ... ≤ Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injl X Y)))\n                       (range ((to_glue_r hΦ hΨ) ∘ (optimal_GH_injr Y Z))) :\n        GH_dist_le_Hausdorff_dist\n          ((to_glue_l_isometry hΦ hΨ).comp (isometry_optimal_GH_injl X Y))\n          ((to_glue_r_isometry hΦ hΨ).comp (isometry_optimal_GH_injr Y Z))\n      ... ≤ Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injl X Y)))\n                           (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y)))\n          + Hausdorff_dist (range ((to_glue_l hΦ hΨ) ∘ (optimal_GH_injr X Y)))\n                           (range ((to_glue_r hΦ hΨ) ∘ (optimal_GH_injr Y Z))) :\n        begin\n          refine Hausdorff_dist_triangle (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n            (range_nonempty _) (range_nonempty _) _ _),\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry hΦ hΨ).comp\n              (isometry_optimal_GH_injl X Y)))).bounded },\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry hΦ hΨ).comp\n              (isometry_optimal_GH_injr X Y)))).bounded }\n        end\n      ... = Hausdorff_dist ((to_glue_l hΦ hΨ) '' (range (optimal_GH_injl X Y)))\n                           ((to_glue_l hΦ hΨ) '' (range (optimal_GH_injr X Y)))\n          + Hausdorff_dist ((to_glue_r hΦ hΨ) '' (range (optimal_GH_injl Y Z)))\n                           ((to_glue_r hΦ hΨ) '' (range (optimal_GH_injr Y Z))) :\n        by simp only [← range_comp, Comm, eq_self_iff_true, add_right_inj]\n      ... = Hausdorff_dist (range (optimal_GH_injl X Y))\n                           (range (optimal_GH_injr X Y))\n          + Hausdorff_dist (range (optimal_GH_injl Y Z))\n                           (range (optimal_GH_injr Y Z)) :\n        by rw [Hausdorff_dist_image (to_glue_l_isometry hΦ hΨ),\n               Hausdorff_dist_image (to_glue_r_isometry hΦ hΨ)]\n      ... = dist (to_GH_space X) (to_GH_space Y) + dist (to_GH_space Y) (to_GH_space Z) :\n        by rw [Hausdorff_dist_optimal, Hausdorff_dist_optimal, GH_dist, GH_dist]\n      ... = dist x y + dist y z:\n        by rw [x.to_GH_space_rep, y.to_GH_space_rep, z.to_GH_space_rep]\n  end }\n\nend GH_space --section\nend Gromov_Hausdorff\n\n/-- In particular, nonempty compacts of a metric space map to `GH_space`. We register this\nin the topological_space namespace to take advantage of the notation `p.to_GH_space`. -/\ndefinition topological_space.nonempty_compacts.to_GH_space {X : Type u} [metric_space X]\n  (p : nonempty_compacts X) : Gromov_Hausdorff.GH_space := Gromov_Hausdorff.to_GH_space p.val\n\nopen topological_space\n\nnamespace Gromov_Hausdorff\n\nsection nonempty_compacts\nvariables {X : Type u} [metric_space X]\n\ntheorem GH_dist_le_nonempty_compacts_dist (p q : nonempty_compacts X) :\n  dist p.to_GH_space q.to_GH_space ≤ dist p q :=\nbegin\n  have ha : isometry (coe : p.val → X) := isometry_subtype_coe,\n  have hb : isometry (coe : q.val → X) := isometry_subtype_coe,\n  have A : dist p q = Hausdorff_dist p.val q.val := rfl,\n  have I : p.val = range (coe : p.val → X), by simp,\n  have J : q.val = range (coe : q.val → X), by simp,\n  rw [I, J] at A,\n  rw A,\n  exact GH_dist_le_Hausdorff_dist ha hb\nend\n\nlemma to_GH_space_lipschitz :\n  lipschitz_with 1 (nonempty_compacts.to_GH_space : nonempty_compacts X → GH_space) :=\nlipschitz_with.mk_one GH_dist_le_nonempty_compacts_dist\n\nlemma to_GH_space_continuous :\n  continuous (nonempty_compacts.to_GH_space : nonempty_compacts X → GH_space) :=\nto_GH_space_lipschitz.continuous\n\nend nonempty_compacts\n\nsection\n/- In this section, we show that if two metric spaces are isometric up to `ε₂`, then their\nGromov-Hausdorff distance is bounded by `ε₂ / 2`. More generally, if there are subsets which are\n`ε₁`-dense and `ε₃`-dense in two spaces, and isometric up to `ε₂`, then the Gromov-Hausdorff\ndistance between the spaces is bounded by `ε₁ + ε₂/2 + ε₃`. For this, we construct a suitable\ncoupling between the two spaces, by gluing them (approximately) along the two matching subsets. -/\n\n\nvariables {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n          {Y : Type v} [metric_space Y] [compact_space Y] [nonempty Y]\n\n-- we want to ignore these instances in the following theorem\nlocal attribute [instance, priority 10] sum.topological_space sum.uniform_space\n/-- If there are subsets which are `ε₁`-dense and `ε₃`-dense in two spaces, and\nisometric up to `ε₂`, then the Gromov-Hausdorff distance between the spaces is bounded by\n`ε₁ + ε₂/2 + ε₃`. -/\ntheorem GH_dist_le_of_approx_subsets {s : set X} (Φ : s → Y) {ε₁ ε₂ ε₃ : ℝ}\n  (hs : ∀ x : X, ∃ y ∈ s, dist x y ≤ ε₁) (hs' : ∀ x : Y, ∃ y : s, dist x (Φ y) ≤ ε₃)\n  (H : ∀ x y : s, |dist x y - dist (Φ x) (Φ y)| ≤ ε₂) :\n  GH_dist X Y ≤ ε₁ + ε₂ / 2 + ε₃ :=\nbegin\n  refine le_of_forall_pos_le_add (λ δ δ0, _),\n  rcases exists_mem_of_nonempty X with ⟨xX, _⟩,\n  rcases hs xX with ⟨xs, hxs, Dxs⟩,\n  have sne : s.nonempty := ⟨xs, hxs⟩,\n  letI : nonempty s := sne.to_subtype,\n  have : 0 ≤ ε₂ := le_trans (abs_nonneg _) (H ⟨xs, hxs⟩ ⟨xs, hxs⟩),\n  have : ∀ p q : s, |dist p q - dist (Φ p) (Φ q)| ≤ 2 * (ε₂/2 + δ) := λ p q, calc\n    |dist p q - dist (Φ p) (Φ q)| ≤ ε₂ : H p q\n    ... ≤ 2 * (ε₂/2 + δ) : by linarith,\n  -- glue `X` and `Y` along the almost matching subsets\n  letI : metric_space (X ⊕ Y) :=\n    glue_metric_approx (λ x:s, (x:X)) (λ x, Φ x) (ε₂/2 + δ) (by linarith) this,\n  let Fl := @sum.inl X Y,\n  let Fr := @sum.inr X Y,\n  have Il : isometry Fl := isometry_emetric_iff_metric.2 (λ x y, rfl),\n  have Ir : isometry Fr := isometry_emetric_iff_metric.2 (λ x y, rfl),\n  /- The proof goes as follows : the `GH_dist` is bounded by the Hausdorff distance of the images\n  in the coupling, which is bounded (using the triangular inequality) by the sum of the Hausdorff\n  distances of `X` and `s` (in the coupling or, equivalently in the original space), of `s` and\n  `Φ s`, and of `Φ s` and `Y` (in the coupling or, equivalently, in the original space). The first\n  term is bounded by `ε₁`, by `ε₁`-density. The third one is bounded by `ε₃`. And the middle one is\n  bounded by `ε₂/2` as in the coupling the points `x` and `Φ x` are at distance `ε₂/2` by\n  construction of the coupling (in fact `ε₂/2 + δ` where `δ` is an arbitrarily small positive\n  constant where positivity is used to ensure that the coupling is really a metric space and not a\n  premetric space on `X ⊕ Y`). -/\n  have : GH_dist X Y ≤ Hausdorff_dist (range Fl) (range Fr) :=\n    GH_dist_le_Hausdorff_dist Il Ir,\n  have : Hausdorff_dist (range Fl) (range Fr) ≤ Hausdorff_dist (range Fl) (Fl '' s)\n                                              + Hausdorff_dist (Fl '' s) (range Fr),\n  { have B : bounded (range Fl) := (is_compact_range Il.continuous).bounded,\n    exact Hausdorff_dist_triangle (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n      (range_nonempty _) (sne.image _) B (B.mono (image_subset_range _ _))) },\n  have : Hausdorff_dist (Fl '' s) (range Fr) ≤ Hausdorff_dist (Fl '' s) (Fr '' (range Φ))\n                                             + Hausdorff_dist (Fr '' (range Φ)) (range Fr),\n  { have B : bounded (range Fr) := (is_compact_range Ir.continuous).bounded,\n    exact Hausdorff_dist_triangle' (Hausdorff_edist_ne_top_of_nonempty_of_bounded\n      ((range_nonempty _).image _) (range_nonempty _)\n      (bounded.mono (image_subset_range _ _) B) B) },\n  have : Hausdorff_dist (range Fl) (Fl '' s) ≤ ε₁,\n  { rw [← image_univ, Hausdorff_dist_image Il],\n    have : 0 ≤ ε₁ := le_trans dist_nonneg Dxs,\n    refine Hausdorff_dist_le_of_mem_dist this (λ x hx, hs x)\n      (λ x hx, ⟨x, mem_univ _, by simpa⟩) },\n  have : Hausdorff_dist (Fl '' s) (Fr '' (range Φ)) ≤ ε₂/2 + δ,\n  { refine Hausdorff_dist_le_of_mem_dist (by linarith) _ _,\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with ⟨x, ⟨x_in_s, xx'⟩⟩,\n      rw ← xx',\n      use [Fr (Φ ⟨x, x_in_s⟩), mem_image_of_mem Fr (mem_range_self _)],\n      exact le_of_eq (glue_dist_glued_points (λ x:s, (x:X)) Φ (ε₂/2 + δ) ⟨x, x_in_s⟩) },\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with ⟨y, ⟨y_in_s', yx'⟩⟩,\n      rcases mem_range.1 y_in_s' with ⟨x, xy⟩,\n      use [Fl x, mem_image_of_mem _ x.2],\n      rw [← yx', ← xy, dist_comm],\n      exact le_of_eq (glue_dist_glued_points (@subtype.val X s) Φ (ε₂/2 + δ) x) } },\n  have : Hausdorff_dist (Fr '' (range Φ)) (range Fr) ≤ ε₃,\n  { rw [← @image_univ _ _ Fr, Hausdorff_dist_image Ir],\n    rcases exists_mem_of_nonempty Y with ⟨xY, _⟩,\n    rcases hs' xY with ⟨xs', Dxs'⟩,\n    have : 0 ≤ ε₃ := le_trans dist_nonneg Dxs',\n    refine Hausdorff_dist_le_of_mem_dist this (λ x hx, ⟨x, mem_univ _, by simpa⟩) (λ x _, _),\n    rcases hs' x with ⟨y, Dy⟩,\n    exact ⟨Φ y, mem_range_self _, Dy⟩ },\n  linarith\nend\nend --section\n\n/-- The Gromov-Hausdorff space is second countable. -/\ninstance : second_countable_topology GH_space :=\nbegin\n  refine second_countable_of_countable_discretization (λ δ δpos, _),\n  let ε := (2/5) * δ,\n  have εpos : 0 < ε := mul_pos (by norm_num) δpos,\n  have : ∀ p:GH_space, ∃ s : set (p.rep), finite s ∧ (univ ⊆ (⋃x∈s, ball x ε)) :=\n    λ p, by simpa using finite_cover_balls_of_compact (@compact_univ p.rep _ _) εpos,\n  -- for each `p`, `s p` is a finite `ε`-dense subset of `p` (or rather the metric space\n  -- `p.rep` representing `p`)\n  choose s hs using this,\n  have : ∀ p:GH_space, ∀ t:set (p.rep), finite t → ∃ n:ℕ, ∃ e:equiv t (fin n), true,\n  { assume p t ht,\n    letI : fintype t := finite.fintype ht,\n    exact ⟨fintype.card t, fintype.equiv_fin t, trivial⟩ },\n  choose N e hne using this,\n  -- cardinality of the nice finite subset `s p` of `p.rep`, called `N p`\n  let N := λ p:GH_space, N p (s p) (hs p).1,\n  -- equiv from `s p`, a nice finite subset of `p.rep`, to `fin (N p)`, called `E p`\n  let E := λ p:GH_space, e p (s p) (hs p).1,\n  -- A function `F` associating to `p : GH_space` the data of all distances between points\n  -- in the `ε`-dense set `s p`.\n  let F : GH_space → Σn:ℕ, (fin n → fin n → ℤ) :=\n    λp, ⟨N p, λa b, ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋⟩,\n  refine ⟨Σ n, fin n → fin n → ℤ, by apply_instance, F, λp q hpq, _⟩,\n  /- As the target space of F is countable, it suffices to show that two points\n  `p` and `q` with `F p = F q` are at distance `≤ δ`.\n  For this, we construct a map `Φ` from `s p ⊆ p.rep` (representing `p`)\n  to `q.rep` (representing `q`) which is almost an isometry on `s p`, and\n  with image `s q`. For this, we compose the identification of `s p` with `fin (N p)`\n  and the inverse of the identification of `s q` with `fin (N q)`. Together with\n  the fact that `N p = N q`, this constructs `Ψ` between `s p` and `s q`, and then\n  composing with the canonical inclusion we get `Φ`. -/\n  have Npq : N p = N q := (sigma.mk.inj_iff.1 hpq).1,\n  let Ψ : s p → s q := λ x, (E q).symm (fin.cast Npq ((E p) x)),\n  let Φ : s p → q.rep := λ x, Ψ x,\n  -- Use the almost isometry `Φ` to show that `p.rep` and `q.rep`\n  -- are within controlled Gromov-Hausdorff distance.\n  have main : GH_dist p.rep q.rep ≤ ε + ε/2 + ε,\n  { refine GH_dist_le_of_approx_subsets Φ  _ _ _,\n    show ∀ x : p.rep, ∃ (y : p.rep) (H : y ∈ s p), dist x y ≤ ε,\n    { -- by construction, `s p` is `ε`-dense\n      assume x,\n      have : x ∈ ⋃y∈(s p), ball y ε := (hs p).2 (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      exact ⟨y, ys, le_of_lt hy⟩ },\n    show ∀ x : q.rep, ∃ (z : s p), dist x (Φ z) ≤ ε,\n    { -- by construction, `s q` is `ε`-dense, and it is the range of `Φ`\n      assume x,\n      have : x ∈ ⋃y∈(s q), ball y ε := (hs q).2 (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      let i : ℕ := E q ⟨y, ys⟩,\n      let hi := ((E q) ⟨y, ys⟩).is_lt,\n      have ihi_eq : (⟨i, hi⟩ : fin (N q)) = (E q) ⟨y, ys⟩, by rw [fin.ext_iff, fin.coe_mk],\n      have hiq : i < N q := hi,\n      have hip : i < N p, { rwa Npq.symm at hiq },\n      let z := (E p).symm ⟨i, hip⟩,\n      use z,\n      have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩,\n      have C2 : fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl,\n      have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩,\n        by { rw ihi_eq, exact (E q).symm_apply_apply ⟨y, ys⟩ },\n      have : Φ z = y :=\n        by { simp only [Φ, Ψ], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_of_lt hy },\n    show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `Φ x` in `fin (N p) = fin (N q)`\n      let i : ℕ := E p x,\n      have hip : i < N p := ((E p) x).2,\n      have hiq : i < N q, by rwa Npq at hip,\n      have i' : i = ((E q) (Ψ x)), by { simp [Ψ] },\n      -- introduce `j`, that codes both `y` and `Φ y` in `fin (N p) = fin (N q)`\n      let j : ℕ := E p y,\n      have hjp : j < N p := ((E p) y).2,\n      have hjq : j < N q, by rwa Npq at hjp,\n      have j' : j = ((E q) (Ψ y)).1, by { simp [Ψ] },\n      -- Express `dist x y` in terms of `F p`\n      have : (F p).2 ((E p) x) ((E p) y) = floor (ε⁻¹ * dist x y),\n        by simp only [F, (E p).symm_apply_apply],\n      have Ap : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = floor (ε⁻¹ * dist x y),\n        by { rw ← this, congr; apply (fin.ext_iff _ _).2; refl },\n      -- Express `dist (Φ x) (Φ y)` in terms of `F q`\n      have : (F q).2 ((E q) (Ψ x)) ((E q) (Ψ y)) = floor (ε⁻¹ * dist (Ψ x) (Ψ y)),\n        by simp only [F, (E q).symm_apply_apply],\n      have Aq : (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩ = floor (ε⁻¹ * dist (Ψ x) (Ψ y)),\n        by { rw ← this, congr; apply (fin.ext_iff _ _).2; [exact i', exact j'] },\n      -- use the equality between `F p` and `F q` to deduce that the distances have equal\n      -- integer parts\n      have : (F p).2 ⟨i, hip⟩ ⟨j, hjp⟩ = (F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩,\n      { -- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works\n        -- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`\n        -- then `subst`\n        revert hiq hjq,\n        change N q with (F q).1,\n        generalize_hyp : F q = f at hpq ⊢,\n        subst hpq,\n        intros,\n        refl },\n      rw [Ap, Aq] at this,\n      -- deduce that the distances coincide up to `ε`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| =\n          |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| : (abs_mul _ _).symm\n        ... = |(ε⁻¹ * dist x y) - (ε⁻¹ * dist (Ψ x) (Ψ y))| : by { congr, ring }\n        ... ≤ 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (Ψ x) (Ψ y)| = (ε * ε⁻¹) * |dist x y - dist (Ψ x) (Ψ y)| :\n          by rw [mul_inv_cancel (ne_of_gt εpos), one_mul]\n        ... = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]\n        ... ≤ ε * 1 : mul_le_mul_of_nonneg_left I (le_of_lt εpos)\n        ... = ε : mul_one _ } },\n  calc dist p q = GH_dist (p.rep) (q.rep) : dist_GH_dist p q\n    ... ≤ ε + ε/2 + ε : main\n    ... = δ : by { simp [ε], ring }\nend\n\n/-- Compactness criterion: a closed set of compact metric spaces is compact if the spaces have\na uniformly bounded diameter, and for all `ε` the number of balls of radius `ε` required\nto cover the spaces is uniformly bounded. This is an equivalence, but we only prove the\ninteresting direction that these conditions imply compactness. -/\nlemma totally_bounded {t : set GH_space} {C : ℝ} {u : ℕ → ℝ} {K : ℕ → ℕ}\n  (ulim : tendsto u at_top (𝓝 0))\n  (hdiam : ∀ p ∈ t, diam (univ : set (GH_space.rep p)) ≤ C)\n  (hcov : ∀ p ∈ t, ∀ n:ℕ, ∃ s : set (GH_space.rep p),\n    cardinal.mk s ≤ K n ∧ univ ⊆ ⋃x∈s, ball x (u n)) :\n  totally_bounded t :=\nbegin\n  /- Let `δ>0`, and `ε = δ/5`. For each `p`, we construct a finite subset `s p` of `p`, which\n  is `ε`-dense and has cardinality at most `K n`. Encoding the mutual distances of points in `s p`,\n  up to `ε`, we will get a map `F` associating to `p` finitely many data, and making it possible to\n  reconstruct `p` up to `ε`. This is enough to prove total boundedness. -/\n  refine metric.totally_bounded_of_finite_discretization (λ δ δpos, _),\n  let ε := (1/5) * δ,\n  have εpos : 0 < ε := mul_pos (by norm_num) δpos,\n  -- choose `n` for which `u n < ε`\n  rcases metric.tendsto_at_top.1 ulim ε εpos with ⟨n, hn⟩,\n  have u_le_ε : u n ≤ ε,\n  { have := hn n le_rfl,\n    simp only [real.dist_eq, add_zero, sub_eq_add_neg, neg_zero] at this,\n    exact le_of_lt (lt_of_le_of_lt (le_abs_self _) this) },\n  -- construct a finite subset `s p` of `p` which is `ε`-dense and has cardinal `≤ K n`\n  have : ∀ p:GH_space, ∃ s : set (p.rep), ∃ N ≤ K n, ∃ E : equiv s (fin N),\n    p ∈ t → univ ⊆ ⋃x∈s, ball x (u n),\n  { assume p,\n    by_cases hp : p ∉ t,\n    { have : nonempty (equiv (∅ : set (p.rep)) (fin 0)),\n      { rw ← fintype.card_eq, simp },\n      use [∅, 0, bot_le, choice (this)] },\n    { rcases hcov _ (set.not_not_mem.1 hp) n with ⟨s, ⟨scard, scover⟩⟩,\n      rcases cardinal.lt_omega.1 (lt_of_le_of_lt scard (cardinal.nat_lt_omega _)) with ⟨N, hN⟩,\n      rw [hN, cardinal.nat_cast_le] at scard,\n      have : cardinal.mk s = cardinal.mk (fin N), by rw [hN, cardinal.mk_fin],\n      cases quotient.exact this with E,\n      use [s, N, scard, E],\n      simp [hp, scover] } },\n  choose s N hN E hs using this,\n  -- Define a function `F` taking values in a finite type and associating to `p` enough data\n  -- to reconstruct it up to `ε`, namely the (discretized) distances between elements of `s p`.\n  let M := ⌊ε⁻¹ * max C 0⌋₊,\n  let F : GH_space → (Σk:fin ((K n).succ), (fin k → fin k → fin (M.succ))) :=\n    λ p, ⟨⟨N p, lt_of_le_of_lt (hN p) (nat.lt_succ_self _)⟩,\n         λ a b, ⟨min M ⌊ε⁻¹ * dist ((E p).symm a) ((E p).symm b)⌋₊,\n                ( min_le_left _ _).trans_lt (nat.lt_succ_self _) ⟩ ⟩,\n  refine ⟨_, _, (λ p, F p), _⟩, apply_instance,\n  -- It remains to show that if `F p = F q`, then `p` and `q` are `ε`-close\n  rintros ⟨p, pt⟩ ⟨q, qt⟩ hpq,\n  have Npq : N p = N q := (fin.ext_iff _ _).1 (sigma.mk.inj_iff.1 hpq).1,\n  let Ψ : s p → s q := λ x, (E q).symm (fin.cast Npq ((E p) x)),\n  let Φ : s p → q.rep := λ x, Ψ x,\n  have main : GH_dist (p.rep) (q.rep) ≤ ε + ε/2 + ε,\n  { -- to prove the main inequality, argue that `s p` is `ε`-dense in `p`, and `s q` is `ε`-dense\n    -- in `q`, and `s p` and `s q` are almost isometric. Then closeness follows\n    -- from `GH_dist_le_of_approx_subsets`\n    refine GH_dist_le_of_approx_subsets Φ  _ _ _,\n    show ∀ x : p.rep, ∃ (y : p.rep) (H : y ∈ s p), dist x y ≤ ε,\n    { -- by construction, `s p` is `ε`-dense\n      assume x,\n      have : x ∈ ⋃y∈(s p), ball y (u n) := (hs p pt) (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      exact ⟨y, ys, le_trans (le_of_lt hy) u_le_ε⟩ },\n    show ∀ x : q.rep, ∃ (z : s p), dist x (Φ z) ≤ ε,\n    { -- by construction, `s q` is `ε`-dense, and it is the range of `Φ`\n      assume x,\n      have : x ∈ ⋃y∈(s q), ball y (u n) := (hs q qt) (mem_univ _),\n      rcases mem_Union₂.1 this with ⟨y, ys, hy⟩,\n      let i : ℕ := E q ⟨y, ys⟩,\n      let hi := ((E q) ⟨y, ys⟩).2,\n      have ihi_eq : (⟨i, hi⟩ : fin (N q)) = (E q) ⟨y, ys⟩, by rw [fin.ext_iff, fin.coe_mk],\n      have hiq : i < N q := hi,\n      have hip : i < N p, { rwa Npq.symm at hiq },\n      let z := (E p).symm ⟨i, hip⟩,\n      use z,\n      have C1 : (E p) z = ⟨i, hip⟩ := (E p).apply_symm_apply ⟨i, hip⟩,\n      have C2 : fin.cast Npq ⟨i, hip⟩ = ⟨i, hi⟩ := rfl,\n      have C3 : (E q).symm ⟨i, hi⟩ = ⟨y, ys⟩,\n        by { rw ihi_eq, exact (E q).symm_apply_apply ⟨y, ys⟩ },\n      have : Φ z = y :=\n        by { simp only [Φ, Ψ], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_trans (le_of_lt hy) u_le_ε },\n    show ∀ x y : s p, |dist x y - dist (Φ x) (Φ y)| ≤ ε,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `Φ x` and `Φ y` (two points of `s q`) is encoded in `F q`, all this up to `ε`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (Φ x) (Φ y) = dist (Ψ x) (Ψ y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `Φ x` in `fin (N p) = fin (N q)`\n      let i : ℕ := E p x,\n      have hip : i < N p := ((E p) x).2,\n      have hiq : i < N q, by rwa Npq at hip,\n      have i' : i = ((E q) (Ψ x)), by { simp [Ψ] },\n      -- introduce `j`, that codes both `y` and `Φ y` in `fin (N p) = fin (N q)`\n      let j : ℕ := E p y,\n      have hjp : j < N p := ((E p) y).2,\n      have hjq : j < N q, by rwa Npq at hjp,\n      have j' : j = ((E q) (Ψ y)), by { simp [Ψ] },\n      -- Express `dist x y` in terms of `F p`\n      have Ap : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ⌊ε⁻¹ * dist x y⌋₊ := calc\n        ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F p).2 ((E p) x) ((E p) y)).1 :\n          by { congr; apply (fin.ext_iff _ _).2; refl }\n        ... = min M ⌊ε⁻¹ * dist x y⌋₊ :\n          by simp only [F, (E p).symm_apply_apply]\n        ... = ⌊ε⁻¹ * dist x y⌋₊ :\n        begin\n          refine min_eq_right (nat.floor_mono _),\n          refine mul_le_mul_of_nonneg_left (le_trans _ (le_max_left _ _)) ((inv_pos.2 εpos).le),\n          change dist (x : p.rep) y ≤ C,\n          refine le_trans (dist_le_diam_of_mem compact_univ.bounded (mem_univ _) (mem_univ _)) _,\n          exact hdiam p pt\n        end,\n      -- Express `dist (Φ x) (Φ y)` in terms of `F q`\n      have Aq : ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ := calc\n        ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1 = ((F q).2 ((E q) (Ψ x)) ((E q) (Ψ y))).1 :\n          by { congr; apply (fin.ext_iff _ _).2; [exact i', exact j'] }\n        ... = min M ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ :\n          by simp only [F, (E q).symm_apply_apply]\n        ... = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋₊ :\n        begin\n          refine min_eq_right (nat.floor_mono _),\n          refine mul_le_mul_of_nonneg_left (le_trans _ (le_max_left _ _)) ((inv_pos.2 εpos).le),\n          change dist (Ψ x : q.rep) (Ψ y) ≤ C,\n          refine le_trans (dist_le_diam_of_mem compact_univ.bounded (mem_univ _) (mem_univ _)) _,\n          exact hdiam q qt\n        end,\n      -- use the equality between `F p` and `F q` to deduce that the distances have equal\n      -- integer parts\n      have : ((F p).2 ⟨i, hip⟩ ⟨j, hjp⟩).1 = ((F q).2 ⟨i, hiq⟩ ⟨j, hjq⟩).1,\n      { -- we want to `subst hpq` where `hpq : F p = F q`, except that `subst` only works\n        -- with a constant, so replace `F q` (and everything that depends on it) by a constant `f`\n        -- then `subst`\n        revert hiq hjq,\n        change N q with (F q).1,\n        generalize_hyp : F q = f at hpq ⊢,\n        subst hpq,\n        intros,\n        refl },\n      have : ⌊ε⁻¹ * dist x y⌋ = ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋,\n      { rw [Ap, Aq] at this,\n        have D : 0 ≤ ⌊ε⁻¹ * dist x y⌋ :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg),\n        have D' : 0 ≤ ⌊ε⁻¹ * dist (Ψ x) (Ψ y)⌋ :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 εpos)) dist_nonneg),\n        rw [← int.to_nat_of_nonneg D, ← int.to_nat_of_nonneg D', int.floor_to_nat,int.floor_to_nat,\n          this] },\n      -- deduce that the distances coincide up to `ε`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)| =\n          |ε⁻¹ * (dist x y - dist (Ψ x) (Ψ y))| : (abs_mul _ _).symm\n        ... = |(ε⁻¹ * dist x y) - (ε⁻¹ * dist (Ψ x) (Ψ y))| : by { congr, ring }\n        ... ≤ 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (Ψ x) (Ψ y)| = (ε * ε⁻¹) * |dist x y - dist (Ψ x) (Ψ y)| :\n          by rw [mul_inv_cancel (ne_of_gt εpos), one_mul]\n        ... = ε * (|ε⁻¹| * |dist x y - dist (Ψ x) (Ψ y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 εpos)), mul_assoc]\n        ... ≤ ε * 1 : mul_le_mul_of_nonneg_left I (le_of_lt εpos)\n        ... = ε : mul_one _ } },\n  calc dist p q = GH_dist (p.rep) (q.rep) : dist_GH_dist p q\n    ... ≤ ε + ε/2 + ε : main\n    ... = δ/2 : by { simp [ε], ring }\n    ... < δ : half_lt_self δpos\nend\n\nsection complete\n\n/- We will show that a sequence `u n` of compact metric spaces satisfying\n`dist (u n) (u (n+1)) < 1/2^n` converges, which implies completeness of the Gromov-Hausdorff space.\nWe need to exhibit the limiting compact metric space. For this, start from\na sequence `X n` of representatives of `u n`, and glue in an optimal way `X n` to `X (n+1)`\nfor all `n`, in a common metric space. Formally, this is done as follows.\nStart from `Y 0 = X 0`. Then, glue `X 0` to `X 1` in an optimal way, yielding a space\n`Y 1` (with an embedding of `X 1`). Then, consider an optimal gluing of `X 1` and `X 2`, and\nglue it to `Y 1` along their common subspace `X 1`. This gives a new space `Y 2`, with an\nembedding of `X 2`. Go on, to obtain a sequence of spaces `Y n`. Let `Z0` be the inductive\nlimit of the `Y n`, and finally let `Z` be the completion of `Z0`.\nThe images `X2 n` of `X n` in `Z` are at Hausdorff distance `< 1/2^n` by construction, hence they\nform a Cauchy sequence for the Hausdorff distance. By completeness (of `Z`, and therefore of its\nset of nonempty compact subsets), they converge to a limit `L`. This is the nonempty\ncompact metric space we are looking for.  -/\n\nvariables (X : ℕ → Type) [∀ n, metric_space (X n)] [∀ n, compact_space (X n)] [∀ n, nonempty (X n)]\n\n/-- Auxiliary structure used to glue metric spaces below, recording an isometric embedding\nof a type `A` in another metric space. -/\nstructure aux_gluing_struct (A : Type) [metric_space A] : Type 1 :=\n(space  : Type)\n(metric : metric_space space)\n(embed  : A → space)\n(isom   : isometry embed)\n\ninstance (A : Type) [metric_space A] : inhabited (aux_gluing_struct A) :=\n⟨{ space := A,\n  metric := by apply_instance,\n  embed := id,\n  isom := λ x y, rfl }⟩\n\n/-- Auxiliary sequence of metric spaces, containing copies of `X 0`, ..., `X n`, where each\n`X i` is glued to `X (i+1)` in an optimal way. The space at step `n+1` is obtained from the space\nat step `n` by adding `X (n+1)`, glued in an optimal way to the `X n` already sitting there. -/\ndef aux_gluing (n : ℕ) : aux_gluing_struct (X n) := nat.rec_on n\n  { space  := X 0,\n    metric := by apply_instance,\n    embed  := id,\n    isom   := λ x y, rfl }\n(λ n Y, by letI : metric_space Y.space := Y.metric; exact\n  { space  := glue_space Y.isom (isometry_optimal_GH_injl (X n) (X (n+1))),\n    metric := by apply_instance,\n    embed  := (to_glue_r Y.isom (isometry_optimal_GH_injl (X n) (X (n+1))))\n              ∘ (optimal_GH_injr (X n) (X (n+1))),\n    isom   := (to_glue_r_isometry _ _).comp (isometry_optimal_GH_injr (X n) (X (n+1))) })\n\n/-- The Gromov-Hausdorff space is complete. -/\ninstance : complete_space GH_space :=\nbegin\n  have : ∀ (n : ℕ), 0 < ((1:ℝ) / 2) ^ n, by { apply pow_pos, norm_num },\n  -- start from a sequence of nonempty compact metric spaces within distance `1/2^n` of each other\n  refine metric.complete_of_convergent_controlled_sequences (λ n, (1/2)^n) this (λ u hu, _),\n  -- `X n` is a representative of `u n`\n  let X := λ n, (u n).rep,\n  -- glue them together successively in an optimal way, getting a sequence of metric spaces `Y n`\n  let Y := aux_gluing X,\n  letI : ∀ n, metric_space (Y n).space := λ n, (Y n).metric,\n  have E : ∀ n : ℕ,\n    glue_space (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)) = (Y n.succ).space :=\n    λ n, by { simp [Y, aux_gluing], refl },\n  let c := λ n, cast (E n),\n  have ic : ∀ n, isometry (c n) := λ n x y, rfl,\n  -- there is a canonical embedding of `Y n` in `Y (n+1)`, by construction\n  let f : Πn, (Y n).space → (Y n.succ).space :=\n    λ n, (c n) ∘ (to_glue_l (aux_gluing X n).isom (isometry_optimal_GH_injl (X n) (X n.succ))),\n  have I : ∀ n, isometry (f n),\n  { assume n,\n    apply isometry.comp,\n    { assume x y, refl },\n    { apply to_glue_l_isometry } },\n  -- consider the inductive limit `Z0` of the `Y n`, and then its completion `Z`\n  let Z0 := metric.inductive_limit I,\n  let Z := uniform_space.completion Z0,\n  let Φ := to_inductive_limit I,\n  let coeZ := (coe : Z0 → Z),\n  -- let `X2 n` be the image of `X n` in the space `Z`\n  let X2 := λ n, range (coeZ ∘ (Φ n) ∘ (Y n).embed),\n  have isom : ∀ n, isometry (coeZ ∘ (Φ n) ∘ (Y n).embed),\n  { assume n,\n    apply isometry.comp completion.coe_isometry _,\n    apply isometry.comp _ (Y n).isom,\n    apply to_inductive_limit_isometry },\n  -- The Hausdorff distance of `X2 n` and `X2 (n+1)` is by construction the distance between\n  -- `u n` and `u (n+1)`, therefore bounded by `1/2^n`\n  have D2 : ∀ n, Hausdorff_dist (X2 n) (X2 n.succ) < (1/2)^n,\n  { assume n,\n    have X2n : X2 n = range ((coeZ ∘ (Φ n.succ) ∘ (c n)\n      ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      ∘ (optimal_GH_injl (X n) (X n.succ))),\n    { change X2 n = range (coeZ ∘ (Φ n.succ) ∘ (c n)\n        ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)))\n        ∘ (optimal_GH_injl (X n) (X n.succ))),\n      simp only [X2, Φ],\n      rw [← to_inductive_limit_commute I],\n      simp only [f],\n      rw ← to_glue_commute },\n    rw range_comp at X2n,\n    have X2nsucc : X2 n.succ = range ((coeZ ∘ (Φ n.succ) ∘ (c n)\n      ∘ (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      ∘ (optimal_GH_injr (X n) (X n.succ))), by refl,\n    rw range_comp at X2nsucc,\n    rw [X2n, X2nsucc, Hausdorff_dist_image, Hausdorff_dist_optimal, ← dist_GH_dist],\n    { exact hu n n n.succ (le_refl n) (le_succ n) },\n    { apply isometry.comp completion.coe_isometry _,\n      apply isometry.comp _ ((ic n).comp (to_glue_r_isometry _ _)),\n      apply to_inductive_limit_isometry } },\n  -- consider `X2 n` as a member `X3 n` of the type of nonempty compact subsets of `Z`, which\n  -- is a metric space\n  let X3 : ℕ → nonempty_compacts Z := λ n, ⟨X2 n,\n    ⟨range_nonempty _, is_compact_range (isom n).continuous ⟩⟩,\n  -- `X3 n` is a Cauchy sequence by construction, as the successive distances are\n  -- bounded by `(1/2)^n`\n  have : cauchy_seq X3,\n  { refine cauchy_seq_of_le_geometric (1/2) 1 (by norm_num) (λ n, _),\n    rw one_mul,\n    exact le_of_lt (D2 n) },\n  -- therefore, it converges to a limit `L`\n  rcases cauchy_seq_tendsto_of_complete this with ⟨L, hL⟩,\n  -- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L`\n  have M : tendsto (λ n, (X3 n).to_GH_space) at_top (𝓝 L.to_GH_space) :=\n    tendsto.comp (to_GH_space_continuous.tendsto _) hL,\n  -- By construction, the image of `X3 n` in the Gromov-Hausdorff space is `u n`.\n  have : ∀ n, (X3 n).to_GH_space = u n,\n  { assume n,\n    rw [nonempty_compacts.to_GH_space, ← (u n).to_GH_space_rep,\n        to_GH_space_eq_to_GH_space_iff_isometric],\n    constructor,\n    convert (isom n).isometric_on_range.symm, },\n  -- Finally, we have proved the convergence of `u n`\n  exact ⟨L.to_GH_space, by simpa [this] using M⟩\nend\n\nend complete--section\n\nend Gromov_Hausdorff --namespace\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/topology/metric_space/gromov_hausdorff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4571595470264783}}
{"text": "import data.padics.padic_norm data.nat.binomial\n\nuniverses u v\n\ntheorem inv_pow' {α : Type u} [discrete_field α] {x : α} {n : ℕ} : (x⁻¹)^n = (x^n)⁻¹ :=\ndecidable.by_cases\n  (assume H : x = 0, or.cases_on (nat.eq_zero_or_pos n)\n    (λ hn, by rw [H, hn, pow_zero, pow_zero, inv_one])\n    (λ hn, by rw [H, zero_pow hn, inv_zero, zero_pow hn]))\n  (λ H, division_ring.inv_pow H n)\n\ntheorem pow_eq_zero {α : Type u} [domain α] {x : α} {n : ℕ} (H : x^n = 0) : x = 0 :=\nbegin\n  induction n with n ih,\n  { rw pow_zero at H,\n    rw [← mul_one x, H, mul_zero] },\n  exact or.cases_on (mul_eq_zero.1 H) id ih\nend\n\nclass char_p (α : Type u) [semiring α] (p : ℕ) : Prop :=\n(cast_eq_zero_iff : ∀ x:ℕ, (x:α) = 0 ↔ p ∣ x)\n\ntheorem char_p.cast_eq_zero (α : Type u) [semiring α] (p : ℕ) [char_p α p] : (p:α) = 0 :=\n(char_p.cast_eq_zero_iff α p p).2 (dvd_refl p)\n\ntheorem char_p.eq (α : Type u) [semiring α] {p q : ℕ} (c1 : char_p α p) (c2 : char_p α q) : p = q :=\nnat.dvd_antisymm\n  ((char_p.cast_eq_zero_iff α p q).1 (char_p.cast_eq_zero _ _))\n  ((char_p.cast_eq_zero_iff α q p).1 (char_p.cast_eq_zero _ _))\n\ninstance char_p.of_char_zero (α : Type u) [semiring α] [char_zero α] : char_p α 0 :=\n⟨λ x, by rw [zero_dvd_iff, ← nat.cast_zero, nat.cast_inj]⟩\n\ntheorem char_p.exists (α : Type u) [semiring α] : ∃ p, char_p α p :=\nby letI := classical.dec_eq α; exact\nclassical.by_cases\n  (assume H : ∀ p:ℕ, (p:α) = 0 → p = 0, ⟨0,\n    ⟨λ x, by rw [zero_dvd_iff]; exact ⟨H x, by rintro rfl; refl⟩⟩⟩)\n  (λ H, ⟨nat.find (classical.not_forall.1 H), ⟨λ x,\n    ⟨λ H1, nat.dvd_of_mod_eq_zero (by_contradiction $ λ H2,\n      nat.find_min (classical.not_forall.1 H)\n        (nat.mod_lt x $ nat.pos_of_ne_zero $ not_of_not_imp $\n          nat.find_spec (classical.not_forall.1 H))\n        (not_imp_of_and_not ⟨by rwa [← nat.mod_add_div x (nat.find (classical.not_forall.1 H)),\n          nat.cast_add, nat.cast_mul, of_not_not (not_not_of_not_imp $ nat.find_spec (classical.not_forall.1 H)),\n          zero_mul, add_zero] at H1, H2⟩)),\n    λ H1, by rw [← nat.mul_div_cancel' H1, nat.cast_mul,\n      of_not_not (not_not_of_not_imp $ nat.find_spec (classical.not_forall.1 H)), zero_mul]⟩⟩⟩)\n\ntheorem char_p.exists_unique (α : Type u) [semiring α] : ∃! p, char_p α p :=\nlet ⟨c, H⟩ := char_p.exists α in ⟨c, H, λ y H2, char_p.eq α H2 H⟩\n\nnoncomputable def ring_char (α : Type u) [semiring α] : ℕ :=\nclassical.some (char_p.exists_unique α)\n\ntheorem ring_char.spec (α : Type u) [semiring α] : ∀ x:ℕ, (x:α) = 0 ↔ ring_char α ∣ x :=\nby letI := (classical.some_spec (char_p.exists_unique α)).1;\nunfold ring_char; exact char_p.cast_eq_zero_iff α (ring_char α)\n\ntheorem ring_char.eq (α : Type u) [semiring α] {p : ℕ} (C : char_p α p) : p = ring_char α :=\n(classical.some_spec (char_p.exists_unique α)).2 p C\n\ntheorem add_pow_char (α : Type u) [comm_ring α] {p : ℕ} (hp : nat.prime p)\n  [char_p α p] (x y : α) : (x + y)^p = x^p + y^p :=\nbegin\n  rw [add_pow, finset.sum_range_succ, nat.sub_self, pow_zero, choose_self],\n  rw [nat.cast_one, mul_one, mul_one, add_left_inj],\n  transitivity,\n  { refine finset.sum_eq_single 0 _ _,\n    { intros b h1 h2,\n      have := nat.prime.dvd_choose (nat.pos_of_ne_zero h2) (finset.mem_range.1 h1) hp,\n      rw [← nat.div_mul_cancel this, nat.cast_mul, char_p.cast_eq_zero α p],\n      simp only [mul_zero] },\n    { intro H, exfalso, apply H, exact finset.mem_range.2 hp.pos } },\n  rw [pow_zero, nat.sub_zero, one_mul, choose_zero_right, nat.cast_one, mul_one]\nend\n\ntheorem nat.iterate₀ {α : Type u} {op : α → α} {x : α} (H : op x = x) {n : ℕ} :\n  op^[n] x = x :=\nby induction n; [simp only [nat.iterate_zero], simp only [nat.iterate_succ', H, *]]\n\ntheorem nat.iterate₁ {α : Type u} {β : Type v} {op : α → α} {op' : β → β} {op'' : α → β}\n  (H : ∀ x, op' (op'' x) = op'' (op x)) {n : ℕ} {x : α} :\n  op'^[n] (op'' x) = op'' (op^[n] x) :=\nby induction n; [simp only [nat.iterate_zero], simp only [nat.iterate_succ', H, *]]\n\ntheorem nat.iterate₂ {α : Type u} {op : α → α} {op' : α → α → α} (H : ∀ x y, op (op' x y) = op' (op x) (op y)) {n : ℕ} {x y : α} :\n  op^[n] (op' x y) = op' (op^[n] x) (op^[n] y) :=\nby induction n; [simp only [nat.iterate_zero], simp only [nat.iterate_succ', H, *]]\n\ntheorem nat.iterate_cancel {α : Type u} {op op' : α → α} (H : ∀ x, op (op' x) = x) {n : ℕ} {x : α} : op^[n] (op'^[n] x) = x :=\nby induction n; [refl, rwa [nat.iterate_succ, nat.iterate_succ', H]]\n\ntheorem nat.iterate_inj {α : Type u} {op : α → α} (Hinj : function.injective op) (n : ℕ) (x y : α)\n  (H : (op^[n] x) = (op^[n] y)) : x = y :=\nby induction n with n ih; simp only [nat.iterate_zero, nat.iterate_succ'] at H;\n[exact H, exact ih (Hinj H)]\n\ndef frobenius (α : Type u) [monoid α] (p : ℕ) (x : α) : α := x^p\n\ntheorem frobenius_def (α : Type u) [monoid α] (p : ℕ) (x : α) : frobenius α p x = x ^ p := rfl\n\ntheorem frobenius_mul (α : Type u) [comm_monoid α] (p : ℕ) (x y : α) :\n  frobenius α p (x * y) = frobenius α p x * frobenius α p y := mul_pow x y p\ntheorem frobenius_one (α : Type u) [monoid α] (p : ℕ) :\n  frobenius α p 1 = 1 := one_pow _\n\ntheorem is_monoid_hom.map_frobenius {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α → β) [is_monoid_hom f]\n  (p : ℕ) (x : α) : f (frobenius α p x) = frobenius β p (f x) :=\nby unfold frobenius; induction p; simp only [pow_zero, pow_succ,\n  is_monoid_hom.map_one f, is_monoid_hom.map_mul f, *]\n\ninstance {α : Type u} [comm_ring α] (p : ℕ) [hp : nat.prime p] [char_p α p] : is_ring_hom (frobenius α p) :=\n{ map_one := frobenius_one α p,\n  map_mul := frobenius_mul α p,\n  map_add := add_pow_char α hp }\n\nsection\nvariables (α : Type u) [comm_ring α] (p : ℕ) [hp : nat.prime p]\ntheorem frobenius_zero : frobenius α p 0 = 0 := zero_pow hp.pos\nvariables [char_p α p] (x y : α)\ninclude hp\ntheorem frobenius_add : frobenius α p (x + y) = frobenius α p x + frobenius α p y := is_ring_hom.map_add _\ntheorem frobenius_neg : frobenius α p (-x) = -frobenius α p x := is_ring_hom.map_neg _\ntheorem frobenius_sub : frobenius α p (x - y) = frobenius α p x - frobenius α p y := is_ring_hom.map_sub _\nend\n\ntheorem frobenius_inj (α : Type u) [integral_domain α] (p : ℕ) [nat.prime p] [char_p α p] (x y : α)\n  (H : frobenius α p x = frobenius α p y) : x = y :=\nby rw ← sub_eq_zero at H ⊢; rw ← frobenius_sub at H; exact pow_eq_zero H\n\ntheorem frobenius_nat_cast (α : Type u) [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] (x : ℕ) :\n  frobenius α p x = x :=\nby induction x; simp only [nat.cast_zero, nat.cast_succ, frobenius_zero, frobenius_one, frobenius_add, *]\n\nclass perfect_field (α : Type u) [field α] (p : ℕ) [char_p α p] : Type u :=\n(pth_root : α → α)\n(frobenius_pth_root : ∀ x, frobenius α p (pth_root x) = x)\n\ntheorem frobenius_pth_root (α : Type u) [field α] (p : ℕ) [char_p α p] [perfect_field α p] (x : α) :\n  frobenius α p (perfect_field.pth_root p x) = x :=\nperfect_field.frobenius_pth_root p x\n\ntheorem pth_root_frobenius (α : Type u) [field α] (p : ℕ) [nat.prime p] [char_p α p] [perfect_field α p] (x : α) :\n  perfect_field.pth_root p (frobenius α p x) = x :=\nfrobenius_inj α p _ _ (by rw frobenius_pth_root)\n\ninstance pth_root.is_ring_hom (α : Type u) [field α] (p : ℕ) [nat.prime p] [char_p α p] [perfect_field α p] :\n  is_ring_hom (@perfect_field.pth_root α _ p _ _) :=\n{ map_one := frobenius_inj α p _ _ (by rw [frobenius_pth_root, frobenius_one]),\n  map_mul := λ x y, frobenius_inj α p _ _ (by simp only [frobenius_pth_root, frobenius_mul]),\n  map_add := λ x y, frobenius_inj α p _ _ (by simp only [frobenius_pth_root, frobenius_add]) }\n\ntheorem is_ring_hom.pth_root {α : Type u} [field α] (p : ℕ) [nat.prime p] [char_p α p] [perfect_field α p]\n  {β : Type v} [field β] [char_p β p] [perfect_field β p] (f : α → β) [is_ring_hom f] {x : α} :\n  f (perfect_field.pth_root p x) = perfect_field.pth_root p (f x) :=\nfrobenius_inj β p _ _ (by rw [← is_monoid_hom.map_frobenius f, frobenius_pth_root, frobenius_pth_root])\n\ninductive perfect_closure.r (α : Type u) [monoid α] (p : ℕ) : (ℕ × α) → (ℕ × α) → Prop\n| intro : ∀ n x, perfect_closure.r (n, x) (n+1, frobenius α p x)\nrun_cmd tactic.mk_iff_of_inductive_prop `perfect_closure.r `perfect_closure.r_iff\n\ndef perfect_closure (α : Type u) [monoid α] (p : ℕ) : Type u :=\nquot (perfect_closure.r α p)\n\nnamespace perfect_closure\n\nvariables (α : Type u)\n\nprivate lemma mul_aux_left [comm_monoid α] (p : ℕ) (x1 x2 y : ℕ × α) (H : r α p x1 x2) :\n  quot.mk (r α p) (x1.1 + y.1, ((frobenius α p)^[y.1] x1.2) * ((frobenius α p)^[x1.1] y.2)) =\n  quot.mk (r α p) (x2.1 + y.1, ((frobenius α p)^[y.1] x2.2) * ((frobenius α p)^[x2.1] y.2)) :=\nmatch x1, x2, H with\n| _, _, r.intro _ n x := quot.sound $ by rw [← nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', ← frobenius_mul, nat.succ_add]; apply r.intro\nend\n\nprivate lemma mul_aux_right [comm_monoid α] (p : ℕ) (x y1 y2 : ℕ × α) (H : r α p y1 y2) :\n  quot.mk (r α p) (x.1 + y1.1, ((frobenius α p)^[y1.1] x.2) * ((frobenius α p)^[x.1] y1.2)) =\n  quot.mk (r α p) (x.1 + y2.1, ((frobenius α p)^[y2.1] x.2) * ((frobenius α p)^[x.1] y2.2)) :=\nmatch y1, y2, H with\n| _, _, r.intro _ n y := quot.sound $ by rw [← nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', ← frobenius_mul]; apply r.intro\nend\n\ninstance [comm_monoid α] (p : ℕ) : has_mul (perfect_closure α p) :=\n⟨quot.lift (λ x:ℕ×α, quot.lift (λ y:ℕ×α, quot.mk (r α p)\n    (x.1 + y.1, ((frobenius α p)^[y.1] x.2) * ((frobenius α p)^[x.1] y.2))) (mul_aux_right α p x))\n  (λ x1 x2 (H : r α p x1 x2), funext $ λ e, quot.induction_on e $ λ y,\nmul_aux_left α p x1 x2 y H)⟩\n\ninstance [comm_monoid α] (p : ℕ) : comm_monoid (perfect_closure α p) :=\n{ mul_assoc := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,\n    quot.induction_on g $ λ ⟨s, z⟩, congr_arg (quot.mk _) $\n    by simp only [add_assoc, mul_assoc, nat.iterate₂ (frobenius_mul _ _),\n      (nat.iterate_add _ _ _ _).symm, add_comm, add_left_comm],\n  one := quot.mk _ (0, 1),\n  one_mul := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $\n    by simp only [nat.iterate₀ (frobenius_one _ _), nat.iterate_zero, one_mul, zero_add]),\n  mul_one := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $\n    by simp only [nat.iterate₀ (frobenius_one _ _), nat.iterate_zero, mul_one, add_zero]),\n  mul_comm := λ e f, quot.induction_on e (λ ⟨m, x⟩, quot.induction_on f (λ ⟨n, y⟩,\n    congr_arg (quot.mk _) $ by simp only [add_comm, mul_comm])),\n  .. (infer_instance : has_mul (perfect_closure α p)) }\n\nprivate lemma add_aux_left [comm_ring α] (p : ℕ) (hp : nat.prime p) [char_p α p]\n  (x1 x2 y : ℕ × α) (H : r α p x1 x2) :\n  quot.mk (r α p) (x1.1 + y.1, ((frobenius α p)^[y.1] x1.2) + ((frobenius α p)^[x1.1] y.2)) =\n  quot.mk (r α p) (x2.1 + y.1, ((frobenius α p)^[y.1] x2.2) + ((frobenius α p)^[x2.1] y.2)) :=\nmatch x1, x2, H with\n| _, _, r.intro _ n x := quot.sound $ by rw [← nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', ← frobenius_add, nat.succ_add]; apply r.intro\nend\n\nprivate lemma add_aux_right [comm_ring α] (p : ℕ) (hp : nat.prime p) [char_p α p]\n  (x y1 y2 : ℕ × α) (H : r α p y1 y2) :\n  quot.mk (r α p) (x.1 + y1.1, ((frobenius α p)^[y1.1] x.2) + ((frobenius α p)^[x.1] y1.2)) =\n  quot.mk (r α p) (x.1 + y2.1, ((frobenius α p)^[y2.1] x.2) + ((frobenius α p)^[x.1] y2.2)) :=\nmatch y1, y2, H with\n| _, _, r.intro _ n y := quot.sound $ by rw [← nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', ← frobenius_add]; apply r.intro\nend\n\ninstance [comm_ring α] (p : ℕ) [hp : nat.prime p] [char_p α p] : has_add (perfect_closure α p) :=\n⟨quot.lift (λ x:ℕ×α, quot.lift (λ y:ℕ×α, quot.mk (r α p)\n    (x.1 + y.1, ((frobenius α p)^[y.1] x.2) + ((frobenius α p)^[x.1] y.2))) (add_aux_right α p hp x))\n  (λ x1 x2 (H : r α p x1 x2), funext $ λ e, quot.induction_on e $ λ y,\nadd_aux_left α p hp x1 x2 y H)⟩\n\ninstance [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] : has_neg (perfect_closure α p) :=\n⟨quot.lift (λ x:ℕ×α, quot.mk (r α p) (x.1, -x.2)) (λ x y (H : r α p x y), match x, y, H with\n| _, _, r.intro _ n x := quot.sound $ by rw ← frobenius_neg; apply r.intro\nend)⟩\n\ntheorem mk_zero [comm_ring α] (p : ℕ) [nat.prime p] (n : ℕ) : quot.mk (r α p) (n, 0) = quot.mk (r α p) (0, 0) :=\nby induction n with n ih; [refl, rw ← ih]; symmetry; apply quot.sound;\nhave := r.intro p n (0:α); rwa [frobenius_zero α p] at this\n\ntheorem r.sound [monoid α] (p m n : ℕ) (x y : α) (H : frobenius α p^[m] x = y) :\n  quot.mk (r α p) (n, x) = quot.mk (r α p) (m + n, y) :=\nby subst H; induction m with m ih; [simp only [zero_add, nat.iterate_zero],\n  rw [ih, nat.succ_add, nat.iterate_succ']]; apply quot.sound; apply r.intro\n\ninstance [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] : comm_ring (perfect_closure α p) :=\n{ add_assoc := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,\n    quot.induction_on g $ λ ⟨s, z⟩, congr_arg (quot.mk _) $\n    by simp only [add_assoc, nat.iterate₂ (frobenius_add α p),\n      (nat.iterate_add _ _ _ _).symm, add_comm, add_left_comm],\n  zero := quot.mk _ (0, 0),\n  zero_add := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $\n    by simp only [nat.iterate₀ (frobenius_zero α p), nat.iterate_zero, zero_add]),\n  add_zero := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $\n    by simp only [nat.iterate₀ (frobenius_zero α p), nat.iterate_zero, add_zero]),\n  add_left_neg := λ e, quot.induction_on e (λ ⟨n, x⟩, show quot.mk _ _ = _,\n    by simp only [nat.iterate₁ (frobenius_neg α p), add_left_neg, mk_zero]; refl),\n  add_comm := λ e f, quot.induction_on e (λ ⟨m, x⟩, quot.induction_on f (λ ⟨n, y⟩,\n    congr_arg (quot.mk _) $ by simp only [add_comm])),\n  left_distrib := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,\n    quot.induction_on g $ λ ⟨s, z⟩, show quot.mk _ _ = quot.mk _ _,\n    by simp only [add_assoc, add_comm, add_left_comm]; apply r.sound;\n    simp only [nat.iterate₂ (frobenius_mul α p), nat.iterate₂ (frobenius_add α p),\n      (nat.iterate_add _ _ _ _).symm, mul_add, add_comm, add_left_comm],\n  right_distrib := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,\n    quot.induction_on g $ λ ⟨s, z⟩, show quot.mk _ _ = quot.mk _ _,\n    by simp only [add_assoc, add_comm _ s, add_left_comm _ s]; apply r.sound;\n    simp only [nat.iterate₂ (frobenius_mul α p), nat.iterate₂ (frobenius_add α p),\n      (nat.iterate_add _ _ _ _).symm, add_mul, add_comm, add_left_comm],\n  .. (infer_instance : has_add (perfect_closure α p)),\n  .. (infer_instance : has_neg (perfect_closure α p)),\n  .. (infer_instance : comm_monoid (perfect_closure α p)) }\n\ninstance [discrete_field α] (p : ℕ) [nat.prime p] [char_p α p] : has_inv (perfect_closure α p) :=\n⟨quot.lift (λ x:ℕ×α, quot.mk (r α p) (x.1, x.2⁻¹)) (λ x y (H : r α p x y), match x, y, H with\n| _, _, r.intro _ n x := quot.sound $ by simp only [frobenius]; rw [← inv_pow']; apply r.intro\nend)⟩\n\ntheorem eq_iff' [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p]\n  (x y : ℕ × α) : quot.mk (r α p) x = quot.mk (r α p) y ↔\n    ∃ z, (frobenius α p^[y.1 + z] x.2) = (frobenius α p^[x.1 + z] y.2) :=\nbegin\n  split,\n  { intro H,\n    replace H := quot.exact _ H,\n    induction H,\n    case eqv_gen.rel : x y H\n    { cases H with n x, exact ⟨0, rfl⟩ },\n    case eqv_gen.refl : H\n    { exact ⟨0, rfl⟩ },\n    case eqv_gen.symm : x y H ih\n    { cases ih with w ih, exact ⟨w, ih.symm⟩ },\n    case eqv_gen.trans : x y z H1 H2 ih1 ih2\n    { cases ih1 with z1 ih1,\n      cases ih2 with z2 ih2,\n      existsi z2+(y.1+z1),\n      rw [← add_assoc, nat.iterate_add, ih1],\n      rw [← nat.iterate_add, add_comm, nat.iterate_add, ih2],\n      rw [← nat.iterate_add],\n      simp only [add_comm, add_left_comm] } },\n  intro H,\n  cases x with m x,\n  cases y with n y,\n  cases H with z H, dsimp only at H,\n  rw [r.sound α p (n+z) m x _ rfl, r.sound α p (m+z) n y _ rfl, H],\n  rw [add_assoc, add_comm, add_comm z]\nend\n\ntheorem eq_iff [integral_domain α] (p : ℕ) [nat.prime p] [char_p α p]\n  (x y : ℕ × α) : quot.mk (r α p) x = quot.mk (r α p) y ↔\n    (frobenius α p^[y.1] x.2) = (frobenius α p^[x.1] y.2) :=\n(eq_iff' α p x y).trans ⟨λ ⟨z, H⟩, nat.iterate_inj (frobenius_inj α p) z _ _ $\n  by simpa only [add_comm, nat.iterate_add] using H,\nλ H, ⟨0, H⟩⟩\n\ninstance [discrete_field α] (p : ℕ) [nat.prime p] [char_p α p] : discrete_field (perfect_closure α p) :=\n{ zero_ne_one := λ H, zero_ne_one ((eq_iff _ _ _ _).1 H),\n  mul_inv_cancel := λ e, quot.induction_on e $ λ ⟨m, x⟩ H,\n    have _ := mt (eq_iff _ _ _ _).2 H, (eq_iff _ _ _ _).2\n      (by simp only [nat.iterate₀ (frobenius_one _ _), nat.iterate₀ (frobenius_zero α p),\n        nat.iterate_zero, (nat.iterate₂ (frobenius_mul α p)).symm] at this ⊢;\n        rw [mul_inv_cancel this, nat.iterate₀ (frobenius_one _ _)]),\n  inv_mul_cancel := λ e, quot.induction_on e $ λ ⟨m, x⟩ H,\n    have _ := mt (eq_iff _ _ _ _).2 H, (eq_iff _ _ _ _).2\n      (by simp only [nat.iterate₀ (frobenius_one _ _), nat.iterate₀ (frobenius_zero α p),\n        nat.iterate_zero, (nat.iterate₂ (frobenius_mul α p)).symm] at this ⊢;\n        rw [inv_mul_cancel this, nat.iterate₀ (frobenius_one _ _)]),\n  has_decidable_eq := λ e f, quot.rec_on_subsingleton e $ λ ⟨m, x⟩,\n    quot.rec_on_subsingleton f $ λ ⟨n, y⟩,\n    decidable_of_iff' _ (eq_iff α p _ _),\n  inv_zero := congr_arg (quot.mk (r α p)) (by rw [inv_zero]),\n  .. (infer_instance : has_inv (perfect_closure α p)),\n  .. (infer_instance : comm_ring (perfect_closure α p)) }\n\ntheorem frobenius_mk [comm_monoid α] (p : ℕ) (x : ℕ × α) :\n  frobenius (perfect_closure α p) p (quot.mk (r α p) x) = quot.mk _ (x.1, x.2^p) :=\nbegin\n  unfold frobenius, cases x with n x, dsimp only,\n  suffices : ∀ p':ℕ, (quot.mk (r α p) (n, x) ^ p' : perfect_closure α p) = quot.mk (r α p) (n, x ^ p'),\n  { apply this },\n  intro p, induction p with p ih,\n  case nat.zero { apply r.sound, rw [nat.iterate₀ (frobenius_one _ _), pow_zero] },\n  case nat.succ {\n    rw [pow_succ, ih],\n    symmetry,\n    apply r.sound,\n    simp only [pow_succ, nat.iterate₂ (frobenius_mul _ _)]\n  }\nend\n\ndef frobenius_equiv [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] :\n  perfect_closure α p ≃ perfect_closure α p :=\n{ to_fun := frobenius (perfect_closure α p) p,\n  inv_fun := λ e, quot.lift_on e (λ x, quot.mk (r α p) (x.1 + 1, x.2)) (λ x y H,\n    match x, y, H with\n    | _, _, r.intro _ n x := quot.sound (r.intro _ _ _)\n    end),\n  left_inv := λ e, quot.induction_on e (λ ⟨m, x⟩, by rw frobenius_mk;\n    symmetry; apply quot.sound; apply r.intro),\n  right_inv := λ e, quot.induction_on e (λ ⟨m, x⟩, by rw frobenius_mk;\n    symmetry; apply quot.sound; apply r.intro) }\n\ntheorem frobenius_equiv_apply [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] {x : perfect_closure α p} :\n  frobenius_equiv α p x = frobenius _ p x :=\nrfl\n\ntheorem nat_cast [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] (n x : ℕ) :\n  (x : perfect_closure α p) = quot.mk (r α p) (n, x) :=\nbegin\n  induction n with n ih,\n  { induction x with x ih, {refl},\n    rw [nat.cast_succ, nat.cast_succ, ih], refl },\n  rw ih, apply quot.sound,\n  conv {congr, skip, skip, rw ← frobenius_nat_cast α p x},\n  apply r.intro\nend\n\ntheorem int_cast [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] (x : ℤ) :\n  (x : perfect_closure α p) = quot.mk (r α p) (0, x) :=\nby induction x; simp only [int.cast_of_nat, int.cast_neg_succ_of_nat, nat_cast α p 0]; refl\n\ntheorem nat_cast_eq_iff [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] (x y : ℕ) :\n  (x : perfect_closure α p) = y ↔ (x : α) = y :=\nbegin\n  split; intro H,\n  { rw [nat_cast α p 0, nat_cast α p 0, eq_iff'] at H,\n    cases H with z H,\n    simpa only [zero_add, nat.iterate₀ (frobenius_nat_cast α p _)] using H },\n  rw [nat_cast α p 0, nat_cast α p 0, H]\nend\n\ninstance [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] : char_p (perfect_closure α p) p :=\nbegin\n  constructor, intro x, rw ← char_p.cast_eq_zero_iff α,\n  rw [← nat.cast_zero, nat_cast_eq_iff, nat.cast_zero]\nend\n\ninstance [discrete_field α] (p : ℕ) [nat.prime p] [char_p α p] : perfect_field (perfect_closure α p) p :=\n{ pth_root := (frobenius_equiv α p).symm,\n  frobenius_pth_root := (frobenius_equiv α p).apply_inverse_apply }\n\ndef of [monoid α] (p : ℕ) (x : α) : perfect_closure α p :=\nquot.mk _ (0, x)\n\ninstance [comm_ring α] (p : ℕ) [nat.prime p] [char_p α p] : is_ring_hom (of α p) :=\n{ map_one := rfl,\n  map_mul := λ x y, rfl,\n  map_add := λ x y, rfl }\n\ntheorem eq_pth_root [discrete_field α] (p : ℕ) [nat.prime p] [char_p α p] (m : ℕ) (x : α) :\n  quot.mk (r α p) (m, x) = (perfect_field.pth_root p^[m] (of α p x) : perfect_closure α p) :=\nbegin\n  unfold of,\n  induction m with m ih, {refl},\n  rw [nat.iterate_succ', ← ih]; refl\nend\n\ndef UMP [discrete_field α] (p : ℕ) [nat.prime p] [char_p α p]\n  (β : Type v) [discrete_field β] [char_p β p] [perfect_field β p] :\n  { f : α → β // is_ring_hom f } ≃ { f : perfect_closure α p → β // is_ring_hom f } :=\n{ to_fun := λ f, ⟨λ e, quot.lift_on e (λ x, perfect_field.pth_root p^[x.1] (f.1 x.2))\n      (λ x y H, match x, y, H with | _, _, r.intro _ n x := by letI := f.2;\n        simp only [is_monoid_hom.map_frobenius f.1, nat.iterate_succ, pth_root_frobenius]\n      end),\n    show f.1 1 = 1, from f.2.1,\n    λ j k, quot.induction_on j $ λ ⟨m, x⟩, quot.induction_on k $ λ ⟨n, y⟩,\n      show (perfect_field.pth_root p^[_] _) = (perfect_field.pth_root p^[_] _) * (perfect_field.pth_root p^[_] _),\n      by letI := f.2; simp only [is_ring_hom.map_mul f.1, (nat.iterate₁ (λ x, (is_monoid_hom.map_frobenius f.1 p x).symm)).symm,\n          @nat.iterate₂ β _ (*) (λ x y, is_ring_hom.map_mul (perfect_field.pth_root p))];\n        rw [nat.iterate_add, nat.iterate_cancel (pth_root_frobenius β p),\n          add_comm, nat.iterate_add, nat.iterate_cancel (pth_root_frobenius β p)],\n    λ j k, quot.induction_on j $ λ ⟨m, x⟩, quot.induction_on k $ λ ⟨n, y⟩,\n      show (perfect_field.pth_root p^[_] _) = (perfect_field.pth_root p^[_] _) + (perfect_field.pth_root p^[_] _),\n      by letI := f.2; simp only [is_ring_hom.map_add f.1, (nat.iterate₁ (λ x, (is_monoid_hom.map_frobenius f.1 p x).symm)).symm,\n          @nat.iterate₂ β _ (+) (λ x y, is_ring_hom.map_add (perfect_field.pth_root p))];\n        rw [nat.iterate_add, nat.iterate_cancel (pth_root_frobenius β p),\n          add_comm m, nat.iterate_add, nat.iterate_cancel (pth_root_frobenius β p)]⟩,\n  inv_fun := λ f, ⟨f.1 ∘ of α p, @@is_ring_hom.comp _ _ _ _ _ _ f.2⟩,\n  left_inv := λ ⟨f, hf⟩, subtype.eq rfl,\n  right_inv := λ ⟨f, hf⟩, subtype.eq $ funext $ λ i, quot.induction_on i $ λ ⟨m, x⟩,\n    show perfect_field.pth_root p^[m] (f _) = f _,\n    by resetI; rw [eq_pth_root, @nat.iterate₁ _ _ _ _ f (λ x:perfect_closure α p, (is_ring_hom.pth_root p f).symm)] }\n\nend perfect_closure\n", "meta": {"author": "kckennylau", "repo": "Lean", "sha": "907d0a4d2bd8f23785abd6142ad53d308c54fdcb", "save_path": "github-repos/lean/kckennylau-Lean", "path": "github-repos/lean/kckennylau-Lean/Lean-907d0a4d2bd8f23785abd6142ad53d308c54fdcb/perfect_closure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.45715954461950875}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.group_power.default\nimport Mathlib.logic.function.iterate\nimport Mathlib.PostPort\n\nuniverses u_1 u_3 u_5 \n\nnamespace Mathlib\n\n/-!\n# Iterates of monoid and ring homomorphisms\n\nIterate of a monoid/ring homomorphism is a monoid/ring homomorphism but it has a wrong type, so Lean\ncan't apply lemmas like `monoid_hom.map_one` to `f^[n] 1`. Though it is possible to define\na monoid structure on the endomorphisms, quite often we do not want to convert from\n`M →* M` to (not yet defined) `monoid.End M` and from `f^[n]` to `f^n` just to apply a simple lemma.\n\nSo, we restate standard `*_hom.map_*` lemmas under names `*_hom.iterate_map_*`.\n\nWe also prove formulas for iterates of add/mul left/right.\n\n## Tags\n\nhomomorphism, iterate\n-/\n\nnamespace monoid_hom\n\n\n@[simp] theorem Mathlib.add_monoid_hom.iterate_map_zero {M : Type u_1} [add_monoid M] (f : M →+ M) (n : ℕ) : nat.iterate (⇑f) n 0 = 0 :=\n  function.iterate_fixed (add_monoid_hom.map_zero f) n\n\n@[simp] theorem iterate_map_mul {M : Type u_1} [monoid M] (f : M →* M) (n : ℕ) (x : M) (y : M) : nat.iterate (⇑f) n (x * y) = nat.iterate (⇑f) n x * nat.iterate (⇑f) n y :=\n  function.semiconj₂.iterate (map_mul f) n x y\n\n@[simp] theorem iterate_map_inv {G : Type u_3} [group G] (f : G →* G) (n : ℕ) (x : G) : nat.iterate (⇑f) n (x⁻¹) = (nat.iterate (⇑f) n x⁻¹) :=\n  function.commute.iterate_left (map_inv f) n x\n\ntheorem iterate_map_pow {M : Type u_1} [monoid M] (f : M →* M) (a : M) (n : ℕ) (m : ℕ) : nat.iterate (⇑f) n (a ^ m) = nat.iterate (⇑f) n a ^ m :=\n  function.commute.iterate_left (fun (x : M) => map_pow f x m) n a\n\ntheorem iterate_map_gpow {G : Type u_3} [group G] (f : G →* G) (a : G) (n : ℕ) (m : ℤ) : nat.iterate (⇑f) n (a ^ m) = nat.iterate (⇑f) n a ^ m :=\n  function.commute.iterate_left (fun (x : G) => map_gpow f x m) n a\n\nend monoid_hom\n\n\nnamespace add_monoid_hom\n\n\n@[simp] theorem iterate_map_sub {G : Type u_3} [add_group G] (f : G →+ G) (n : ℕ) (x : G) (y : G) : nat.iterate (⇑f) n (x - y) = nat.iterate (⇑f) n x - nat.iterate (⇑f) n y :=\n  function.semiconj₂.iterate (map_sub f) n x y\n\ntheorem iterate_map_smul {M : Type u_1} [add_monoid M] (f : M →+ M) (n : ℕ) (m : ℕ) (x : M) : nat.iterate (⇑f) n (m •ℕ x) = m •ℕ nat.iterate (⇑f) n x :=\n  monoid_hom.iterate_map_pow (coe_fn to_multiplicative f) x n m\n\ntheorem iterate_map_gsmul {G : Type u_3} [add_group G] (f : G →+ G) (n : ℕ) (m : ℤ) (x : G) : nat.iterate (⇑f) n (m •ℤ x) = m •ℤ nat.iterate (⇑f) n x :=\n  monoid_hom.iterate_map_gpow (coe_fn to_multiplicative f) x n m\n\nend add_monoid_hom\n\n\nnamespace ring_hom\n\n\ntheorem coe_pow {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) : ⇑(f ^ n) = nat.iterate (⇑f) n := sorry\n\ntheorem iterate_map_one {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) : nat.iterate (⇑f) n 1 = 1 :=\n  monoid_hom.iterate_map_one (to_monoid_hom f) n\n\ntheorem iterate_map_zero {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) : nat.iterate (⇑f) n 0 = 0 :=\n  add_monoid_hom.iterate_map_zero (to_add_monoid_hom f) n\n\ntheorem iterate_map_add {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) (x : R) (y : R) : nat.iterate (⇑f) n (x + y) = nat.iterate (⇑f) n x + nat.iterate (⇑f) n y :=\n  add_monoid_hom.iterate_map_add (to_add_monoid_hom f) n x y\n\ntheorem iterate_map_mul {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) (x : R) (y : R) : nat.iterate (⇑f) n (x * y) = nat.iterate (⇑f) n x * nat.iterate (⇑f) n y :=\n  monoid_hom.iterate_map_mul (to_monoid_hom f) n x y\n\ntheorem iterate_map_pow {R : Type u_5} [semiring R] (f : R →+* R) (a : R) (n : ℕ) (m : ℕ) : nat.iterate (⇑f) n (a ^ m) = nat.iterate (⇑f) n a ^ m :=\n  monoid_hom.iterate_map_pow (to_monoid_hom f) a n m\n\ntheorem iterate_map_smul {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) (m : ℕ) (x : R) : nat.iterate (⇑f) n (m •ℕ x) = m •ℕ nat.iterate (⇑f) n x :=\n  add_monoid_hom.iterate_map_smul (to_add_monoid_hom f) n m x\n\ntheorem iterate_map_sub {R : Type u_5} [ring R] (f : R →+* R) (n : ℕ) (x : R) (y : R) : nat.iterate (⇑f) n (x - y) = nat.iterate (⇑f) n x - nat.iterate (⇑f) n y :=\n  add_monoid_hom.iterate_map_sub (to_add_monoid_hom f) n x y\n\ntheorem iterate_map_neg {R : Type u_5} [ring R] (f : R →+* R) (n : ℕ) (x : R) : nat.iterate (⇑f) n (-x) = -nat.iterate (⇑f) n x :=\n  add_monoid_hom.iterate_map_neg (to_add_monoid_hom f) n x\n\ntheorem iterate_map_gsmul {R : Type u_5} [ring R] (f : R →+* R) (n : ℕ) (m : ℤ) (x : R) : nat.iterate (⇑f) n (m •ℤ x) = m •ℤ nat.iterate (⇑f) n x :=\n  add_monoid_hom.iterate_map_gsmul (to_add_monoid_hom f) n m x\n\nend ring_hom\n\n\n@[simp] theorem mul_left_iterate {M : Type u_1} [monoid M] (a : M) (n : ℕ) : nat.iterate (Mul.mul a) n = Mul.mul (a ^ n) := sorry\n\n@[simp] theorem add_left_iterate {M : Type u_1} [add_monoid M] (a : M) (n : ℕ) : nat.iterate (Add.add a) n = Add.add (n •ℕ a) :=\n  mul_left_iterate a n\n\n@[simp] theorem mul_right_iterate {M : Type u_1} [monoid M] (a : M) (n : ℕ) : nat.iterate (fun (x : M) => x * a) n = fun (x : M) => x * a ^ n := sorry\n\n@[simp] theorem add_right_iterate {M : Type u_1} [add_monoid M] (a : M) (n : ℕ) : nat.iterate (fun (x : M) => x + a) n = fun (x : M) => x + n •ℕ a :=\n  mul_right_iterate a n\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/iterate_hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217431943271999, "lm_q2_score": 0.63341024983754, "lm_q1q2_score": 0.4571595370373359}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n\n! This file was ported from Lean 3 source module topology.uniform_space.basic\n! leanprover-community/mathlib commit 195fcd60ff2bfe392543bceb0ec2adcdb472db4c\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Order.Filter.SmallSets\nimport Mathbin.Topology.SubsetProperties\nimport Mathbin.Topology.NhdsSet\n\n/-!\n# Uniform spaces\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nUniform spaces are a generalization of metric spaces and topological groups. Many concepts directly\ngeneralize to uniform spaces, e.g.\n\n* uniform continuity (in this file)\n* completeness (in `cauchy.lean`)\n* extension of uniform continuous functions to complete spaces (in `uniform_embedding.lean`)\n* totally bounded sets (in `cauchy.lean`)\n* totally bounded complete sets are compact (in `cauchy.lean`)\n\nA uniform structure on a type `X` is a filter `𝓤 X` on `X × X` satisfying some conditions\nwhich makes it reasonable to say that `∀ᶠ (p : X × X) in 𝓤 X, ...` means\n\"for all p.1 and p.2 in X close enough, ...\". Elements of this filter are called entourages\nof `X`. The two main examples are:\n\n* If `X` is a metric space, `V ∈ 𝓤 X ↔ ∃ ε > 0, { p | dist p.1 p.2 < ε } ⊆ V`\n* If `G` is an additive topological group, `V ∈ 𝓤 G ↔ ∃ U ∈ 𝓝 (0 : G), {p | p.2 - p.1 ∈ U} ⊆ V`\n\nThose examples are generalizations in two different directions of the elementary example where\n`X = ℝ` and `V ∈ 𝓤 ℝ ↔ ∃ ε > 0, { p | |p.2 - p.1| < ε } ⊆ V` which features both the topological\ngroup structure on `ℝ` and its metric space structure.\n\nEach uniform structure on `X` induces a topology on `X` characterized by\n\n> `nhds_eq_comap_uniformity : ∀ {x : X}, 𝓝 x = comap (prod.mk x) (𝓤 X)`\n\nwhere `prod.mk x : X → X × X := (λ y, (x, y))` is the partial evaluation of the product\nconstructor.\n\nThe dictionary with metric spaces includes:\n* an upper bound for `dist x y` translates into `(x, y) ∈ V` for some `V ∈ 𝓤 X`\n* a ball `ball x r` roughly corresponds to `uniform_space.ball x V := {y | (x, y) ∈ V}`\n  for some `V ∈ 𝓤 X`, but the later is more general (it includes in\n  particular both open and closed balls for suitable `V`).\n  In particular we have:\n  `is_open_iff_ball_subset {s : set X} : is_open s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 X, ball x V ⊆ s`\n\nThe triangle inequality is abstracted to a statement involving the composition of relations in `X`.\nFirst note that the triangle inequality in a metric space is equivalent to\n`∀ (x y z : X) (r r' : ℝ), dist x y ≤ r → dist y z ≤ r' → dist x z ≤ r + r'`.\nThen, for any `V` and `W` with type `set (X × X)`, the composition `V ○ W : set (X × X)` is\ndefined as `{ p : X × X | ∃ z, (p.1, z) ∈ V ∧ (z, p.2) ∈ W }`.\nIn the metric space case, if `V = { p | dist p.1 p.2 ≤ r }` and `W = { p | dist p.1 p.2 ≤ r' }`\nthen the triangle inequality, as reformulated above, says `V ○ W` is contained in\n`{p | dist p.1 p.2 ≤ r + r'}` which is the entourage associated to the radius `r + r'`.\nIn general we have `mem_ball_comp (h : y ∈ ball x V) (h' : z ∈ ball y W) : z ∈ ball x (V ○ W)`.\nNote that this discussion does not depend on any axiom imposed on the uniformity filter,\nit is simply captured by the definition of composition.\n\nThe uniform space axioms ask the filter `𝓤 X` to satisfy the following:\n* every `V ∈ 𝓤 X` contains the diagonal `id_rel = { p | p.1 = p.2 }`. This abstracts the fact\n  that `dist x x ≤ r` for every non-negative radius `r` in the metric space case and also that\n  `x - x` belongs to every neighborhood of zero in the topological group case.\n* `V ∈ 𝓤 X → prod.swap '' V ∈ 𝓤 X`. This is tightly related the fact that `dist x y = dist y x`\n  in a metric space, and to continuity of negation in the topological group case.\n* `∀ V ∈ 𝓤 X, ∃ W ∈ 𝓤 X, W ○ W ⊆ V`. In the metric space case, it corresponds\n  to cutting the radius of a ball in half and applying the triangle inequality.\n  In the topological group case, it comes from continuity of addition at `(0, 0)`.\n\nThese three axioms are stated more abstractly in the definition below, in terms of\noperations on filters, without directly manipulating entourages.\n\n## Main definitions\n\n* `uniform_space X` is a uniform space structure on a type `X`\n* `uniform_continuous f` is a predicate saying a function `f : α → β` between uniform spaces\n  is uniformly continuous : `∀ r ∈ 𝓤 β, ∀ᶠ (x : α × α) in 𝓤 α, (f x.1, f x.2) ∈ r`\n\nIn this file we also define a complete lattice structure on the type `uniform_space X`\nof uniform structures on `X`, as well as the pullback (`uniform_space.comap`) of uniform structures\ncoming from the pullback of filters.\nLike distance functions, uniform structures cannot be pushed forward in general.\n\n## Notations\n\nLocalized in `uniformity`, we have the notation `𝓤 X` for the uniformity on a uniform space `X`,\nand `○` for composition of relations, seen as terms with type `set (X × X)`.\n\n## Implementation notes\n\nThere is already a theory of relations in `data/rel.lean` where the main definition is\n`def rel (α β : Type*) := α → β → Prop`.\nThe relations used in the current file involve only one type, but this is not the reason why\nwe don't reuse `data/rel.lean`. We use `set (α × α)`\ninstead of `rel α α` because we really need sets to use the filter library, and elements\nof filters on `α × α` have type `set (α × α)`.\n\nThe structure `uniform_space X` bundles a uniform structure on `X`, a topology on `X` and\nan assumption saying those are compatible. This may not seem mathematically reasonable at first,\nbut is in fact an instance of the forgetful inheritance pattern. See Note [forgetful inheritance]\nbelow.\n\n## References\n\nThe formalization uses the books:\n\n* [N. Bourbaki, *General Topology*][bourbaki1966]\n* [I. M. James, *Topologies and Uniformities*][james1999]\n\nBut it makes a more systematic use of the filter library.\n-/\n\n\nopen Set Filter Classical\n\nopen Classical Topology Filter\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:334:40: warning: unsupported option eqn_compiler.zeta -/\nset_option eqn_compiler.zeta true\n\nuniverse u\n\n/-!\n### Relations, seen as `set (α × α)`\n-/\n\n\nvariable {α : Type _} {β : Type _} {γ : Type _} {δ : Type _} {ι : Sort _}\n\n#print idRel /-\n/-- The identity relation, or the graph of the identity function -/\ndef idRel {α : Type _} :=\n  { p : α × α | p.1 = p.2 }\n#align id_rel idRel\n-/\n\n#print mem_idRel /-\n@[simp]\ntheorem mem_idRel {a b : α} : (a, b) ∈ @idRel α ↔ a = b :=\n  Iff.rfl\n#align mem_id_rel mem_idRel\n-/\n\n#print idRel_subset /-\n@[simp]\ntheorem idRel_subset {s : Set (α × α)} : idRel ⊆ s ↔ ∀ a, (a, a) ∈ s := by\n  simp [subset_def] <;> exact forall_congr' fun a => by simp\n#align id_rel_subset idRel_subset\n-/\n\n#print compRel /-\n/-- The composition of relations -/\ndef compRel {α : Type u} (r₁ r₂ : Set (α × α)) :=\n  { p : α × α | ∃ z : α, (p.1, z) ∈ r₁ ∧ (z, p.2) ∈ r₂ }\n#align comp_rel compRel\n-/\n\n-- mathport name: uniformity.comp_rel\nscoped[uniformity] infixl:55 \" ○ \" => compRel\n\n#print mem_compRel /-\n@[simp]\ntheorem mem_compRel {r₁ r₂ : Set (α × α)} {x y : α} :\n    (x, y) ∈ r₁ ○ r₂ ↔ ∃ z, (x, z) ∈ r₁ ∧ (z, y) ∈ r₂ :=\n  Iff.rfl\n#align mem_comp_rel mem_compRel\n-/\n\n#print swap_idRel /-\n@[simp]\ntheorem swap_idRel : Prod.swap '' idRel = @idRel α :=\n  Set.ext fun ⟨a, b⟩ => by simp [image_swap_eq_preimage_swap] <;> exact eq_comm\n#align swap_id_rel swap_idRel\n-/\n\n/- warning: monotone.comp_rel -> Monotone.compRel is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u2} β] {f : β -> (Set.{u1} (Prod.{u1, u1} α α))} {g : β -> (Set.{u1} (Prod.{u1, u1} α α))}, (Monotone.{u2, u1} β (Set.{u1} (Prod.{u1, u1} α α)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} α α)))))))) f) -> (Monotone.{u2, u1} β (Set.{u1} (Prod.{u1, u1} α α)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} α α)))))))) g) -> (Monotone.{u2, u1} β (Set.{u1} (Prod.{u1, u1} α α)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} α α)))))))) (fun (x : β) => compRel.{u1} α (f x) (g x)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Preorder.{u2} β] {f : β -> (Set.{u1} (Prod.{u1, u1} α α))} {g : β -> (Set.{u1} (Prod.{u1, u1} α α))}, (Monotone.{u2, u1} β (Set.{u1} (Prod.{u1, u1} α α)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} α α)))))))) f) -> (Monotone.{u2, u1} β (Set.{u1} (Prod.{u1, u1} α α)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} α α)))))))) g) -> (Monotone.{u2, u1} β (Set.{u1} (Prod.{u1, u1} α α)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} α α)))))))) (fun (x : β) => compRel.{u1} α (f x) (g x)))\nCase conversion may be inaccurate. Consider using '#align monotone.comp_rel Monotone.compRelₓ'. -/\ntheorem Monotone.compRel [Preorder β] {f g : β → Set (α × α)} (hf : Monotone f) (hg : Monotone g) :\n    Monotone fun x => f x ○ g x := fun a b h p ⟨z, h₁, h₂⟩ => ⟨z, hf h h₁, hg h h₂⟩\n#align monotone.comp_rel Monotone.compRel\n\n#print compRel_mono /-\n@[mono]\ntheorem compRel_mono {f g h k : Set (α × α)} (h₁ : f ⊆ h) (h₂ : g ⊆ k) : f ○ g ⊆ h ○ k :=\n  fun ⟨x, y⟩ ⟨z, h, h'⟩ => ⟨z, h₁ h, h₂ h'⟩\n#align comp_rel_mono compRel_mono\n-/\n\n#print prod_mk_mem_compRel /-\ntheorem prod_mk_mem_compRel {a b c : α} {s t : Set (α × α)} (h₁ : (a, c) ∈ s) (h₂ : (c, b) ∈ t) :\n    (a, b) ∈ s ○ t :=\n  ⟨c, h₁, h₂⟩\n#align prod_mk_mem_comp_rel prod_mk_mem_compRel\n-/\n\n#print id_compRel /-\n@[simp]\ntheorem id_compRel {r : Set (α × α)} : idRel ○ r = r :=\n  Set.ext fun ⟨a, b⟩ => by simp\n#align id_comp_rel id_compRel\n-/\n\n#print compRel_assoc /-\ntheorem compRel_assoc {r s t : Set (α × α)} : r ○ s ○ t = r ○ (s ○ t) := by\n  ext p <;> cases p <;> simp only [mem_compRel] <;> tauto\n#align comp_rel_assoc compRel_assoc\n-/\n\n#print left_subset_compRel /-\ntheorem left_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ t) : s ⊆ s ○ t := fun ⟨x, y⟩ xy_in =>\n  ⟨y, xy_in, h <| rfl⟩\n#align left_subset_comp_rel left_subset_compRel\n-/\n\n#print right_subset_compRel /-\ntheorem right_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ s) : t ⊆ s ○ t := fun ⟨x, y⟩ xy_in =>\n  ⟨x, h <| rfl, xy_in⟩\n#align right_subset_comp_rel right_subset_compRel\n-/\n\n#print subset_comp_self /-\ntheorem subset_comp_self {s : Set (α × α)} (h : idRel ⊆ s) : s ⊆ s ○ s :=\n  left_subset_compRel h\n#align subset_comp_self subset_comp_self\n-/\n\n#print subset_iterate_compRel /-\ntheorem subset_iterate_compRel {s t : Set (α × α)} (h : idRel ⊆ s) (n : ℕ) :\n    t ⊆ ((· ○ ·) s^[n]) t := by\n  induction' n with n ihn generalizing t\n  exacts[subset.rfl, (right_subset_compRel h).trans ihn]\n#align subset_iterate_comp_rel subset_iterate_compRel\n-/\n\n#print SymmetricRel /-\n/-- The relation is invariant under swapping factors. -/\ndef SymmetricRel (V : Set (α × α)) : Prop :=\n  Prod.swap ⁻¹' V = V\n#align symmetric_rel SymmetricRel\n-/\n\n#print symmetrizeRel /-\n/-- The maximal symmetric relation contained in a given relation. -/\ndef symmetrizeRel (V : Set (α × α)) : Set (α × α) :=\n  V ∩ Prod.swap ⁻¹' V\n#align symmetrize_rel symmetrizeRel\n-/\n\n#print symmetric_symmetrizeRel /-\ntheorem symmetric_symmetrizeRel (V : Set (α × α)) : SymmetricRel (symmetrizeRel V) := by\n  simp [SymmetricRel, symmetrizeRel, preimage_inter, inter_comm, ← preimage_comp]\n#align symmetric_symmetrize_rel symmetric_symmetrizeRel\n-/\n\n#print symmetrizeRel_subset_self /-\ntheorem symmetrizeRel_subset_self (V : Set (α × α)) : symmetrizeRel V ⊆ V :=\n  sep_subset _ _\n#align symmetrize_rel_subset_self symmetrizeRel_subset_self\n-/\n\n#print symmetrize_mono /-\n@[mono]\ntheorem symmetrize_mono {V W : Set (α × α)} (h : V ⊆ W) : symmetrizeRel V ⊆ symmetrizeRel W :=\n  inter_subset_inter h <| preimage_mono h\n#align symmetrize_mono symmetrize_mono\n-/\n\n#print SymmetricRel.mk_mem_comm /-\ntheorem SymmetricRel.mk_mem_comm {V : Set (α × α)} (hV : SymmetricRel V) {x y : α} :\n    (x, y) ∈ V ↔ (y, x) ∈ V :=\n  Set.ext_iff.1 hV (y, x)\n#align symmetric_rel.mk_mem_comm SymmetricRel.mk_mem_comm\n-/\n\n#print SymmetricRel.eq /-\ntheorem SymmetricRel.eq {U : Set (α × α)} (hU : SymmetricRel U) : Prod.swap ⁻¹' U = U :=\n  hU\n#align symmetric_rel.eq SymmetricRel.eq\n-/\n\n/- warning: symmetric_rel.inter -> SymmetricRel.inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {U : Set.{u1} (Prod.{u1, u1} α α)} {V : Set.{u1} (Prod.{u1, u1} α α)}, (SymmetricRel.{u1} α U) -> (SymmetricRel.{u1} α V) -> (SymmetricRel.{u1} α (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasInter.{u1} (Prod.{u1, u1} α α)) U V))\nbut is expected to have type\n  forall {α : Type.{u1}} {U : Set.{u1} (Prod.{u1, u1} α α)} {V : Set.{u1} (Prod.{u1, u1} α α)}, (SymmetricRel.{u1} α U) -> (SymmetricRel.{u1} α V) -> (SymmetricRel.{u1} α (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instInterSet.{u1} (Prod.{u1, u1} α α)) U V))\nCase conversion may be inaccurate. Consider using '#align symmetric_rel.inter SymmetricRel.interₓ'. -/\ntheorem SymmetricRel.inter {U V : Set (α × α)} (hU : SymmetricRel U) (hV : SymmetricRel V) :\n    SymmetricRel (U ∩ V) := by rw [SymmetricRel, preimage_inter, hU.eq, hV.eq]\n#align symmetric_rel.inter SymmetricRel.inter\n\n#print UniformSpace.Core /-\n/-- This core description of a uniform space is outside of the type class hierarchy. It is useful\n  for constructions of uniform spaces, when the topology is derived from the uniform space. -/\nstructure UniformSpace.Core (α : Type u) where\n  uniformity : Filter (α × α)\n  refl : 𝓟 idRel ≤ uniformity\n  symm : Tendsto Prod.swap uniformity uniformity\n  comp : (uniformity.lift' fun s => s ○ s) ≤ uniformity\n#align uniform_space.core UniformSpace.Core\n-/\n\n/- warning: uniform_space.core.mk' -> UniformSpace.Core.mk' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (U : Filter.{u1} (Prod.{u1, u1} α α)), (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) r U) -> (forall (x : α), Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) r U) -> (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) (Set.preimage.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) r) U)) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) r U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t U) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t U) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) r)))) -> (UniformSpace.Core.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} (U : Filter.{u1} (Prod.{u1, u1} α α)), (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) r U) -> (forall (x : α), Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) r U) -> (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) (Set.preimage.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) r) U)) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) r U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t U) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) r)))) -> (UniformSpace.Core.{u1} α)\nCase conversion may be inaccurate. Consider using '#align uniform_space.core.mk' UniformSpace.Core.mk'ₓ'. -/\n/-- An alternative constructor for `uniform_space.core`. This version unfolds various\n`filter`-related definitions. -/\ndef UniformSpace.Core.mk' {α : Type u} (U : Filter (α × α)) (refl : ∀ r ∈ U, ∀ (x), (x, x) ∈ r)\n    (symm : ∀ r ∈ U, Prod.swap ⁻¹' r ∈ U) (comp : ∀ r ∈ U, ∃ t ∈ U, t ○ t ⊆ r) :\n    UniformSpace.Core α :=\n  ⟨U, fun r ru => idRel_subset.2 (refl _ ru), symm, fun r ru =>\n    let ⟨s, hs, hsr⟩ := comp _ ru\n    mem_of_superset (mem_lift' hs) hsr⟩\n#align uniform_space.core.mk' UniformSpace.Core.mk'\n\n/- warning: uniform_space.core.mk_of_basis -> UniformSpace.Core.mkOfBasis is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (B : FilterBasis.{u1} (Prod.{u1, u1} α α)), (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} α α)) r B) -> (forall (x : α), Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} α α)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} α α)) t B) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} α α)) t B) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) t (Set.preimage.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) r))))) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} α α)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} α α)) t B) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} α α)) t B) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) r)))) -> (UniformSpace.Core.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} (B : FilterBasis.{u1} (Prod.{u1, u1} α α)), (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} α α)) r B) -> (forall (x : α), Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} α α)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} α α)) t B) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) t (Set.preimage.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) r))))) -> (forall (r : Set.{u1} (Prod.{u1, u1} α α)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} α α)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (FilterBasis.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} α α)) t B) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) r)))) -> (UniformSpace.Core.{u1} α)\nCase conversion may be inaccurate. Consider using '#align uniform_space.core.mk_of_basis UniformSpace.Core.mkOfBasisₓ'. -/\n/-- Defining an `uniform_space.core` from a filter basis satisfying some uniformity-like axioms. -/\ndef UniformSpace.Core.mkOfBasis {α : Type u} (B : FilterBasis (α × α))\n    (refl : ∀ r ∈ B, ∀ (x), (x, x) ∈ r) (symm : ∀ r ∈ B, ∃ t ∈ B, t ⊆ Prod.swap ⁻¹' r)\n    (comp : ∀ r ∈ B, ∃ t ∈ B, t ○ t ⊆ r) : UniformSpace.Core α\n    where\n  uniformity := B.filterₓ\n  refl := B.HasBasis.ge_iff.mpr fun r ru => idRel_subset.2 <| refl _ ru\n  symm := (B.HasBasis.tendsto_iffₓ B.HasBasis).mpr symm\n  comp :=\n    (HasBasis.le_basis_iff (B.HasBasis.lift' (monotone_id.compRel monotone_id)) B.HasBasis).mpr comp\n#align uniform_space.core.mk_of_basis UniformSpace.Core.mkOfBasis\n\n#print UniformSpace.Core.toTopologicalSpace /-\n/-- A uniform space generates a topological space -/\ndef UniformSpace.Core.toTopologicalSpace {α : Type u} (u : UniformSpace.Core α) : TopologicalSpace α\n    where\n  IsOpen s := ∀ x ∈ s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ u.uniformity\n  isOpen_univ := by simp <;> intro <;> exact univ_mem\n  isOpen_inter := fun s t hs ht x ⟨xs, xt⟩ => by\n    filter_upwards [hs x xs, ht x xt] <;> simp (config := { contextual := true })\n  isOpen_unionₛ := fun s hs x ⟨t, ts, xt⟩ => by\n    filter_upwards [hs t ts x xt]with p ph h using⟨t, ts, ph h⟩\n#align uniform_space.core.to_topological_space UniformSpace.Core.toTopologicalSpace\n-/\n\n#print UniformSpace.core_eq /-\ntheorem UniformSpace.core_eq :\n    ∀ {u₁ u₂ : UniformSpace.Core α}, u₁.uniformity = u₂.uniformity → u₁ = u₂\n  | ⟨u₁, _, _, _⟩, ⟨u₂, _, _, _⟩, rfl => by congr\n#align uniform_space.core_eq UniformSpace.core_eq\n-/\n\n#print UniformSpace /-\n-- the topological structure is embedded in the uniform structure\n-- to avoid instance diamond issues. See Note [forgetful inheritance].\n/-- A uniform space is a generalization of the \"uniform\" topological aspects of a\n  metric space. It consists of a filter on `α × α` called the \"uniformity\", which\n  satisfies properties analogous to the reflexivity, symmetry, and triangle properties\n  of a metric.\n\n  A metric space has a natural uniformity, and a uniform space has a natural topology.\n  A topological group also has a natural uniformity, even when it is not metrizable. -/\nclass UniformSpace (α : Type u) extends TopologicalSpace α, UniformSpace.Core α where\n  isOpen_uniformity :\n    ∀ s, @IsOpen _ to_topological_space s ↔ ∀ x ∈ s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ uniformity\n#align uniform_space UniformSpace\n-/\n\n#print UniformSpace.mk' /-\n/-- Alternative constructor for `uniform_space α` when a topology is already given. -/\n@[match_pattern]\ndef UniformSpace.mk' {α} (t : TopologicalSpace α) (c : UniformSpace.Core α)\n    (is_open_uniformity :\n      ∀ s : Set α, IsOpen s ↔ ∀ x ∈ s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ c.uniformity) :\n    UniformSpace α :=\n  ⟨c, isOpen_uniformity⟩\n#align uniform_space.mk' UniformSpace.mk'\n-/\n\n#print UniformSpace.ofCore /-\n/-- Construct a `uniform_space` from a `uniform_space.core`. -/\ndef UniformSpace.ofCore {α : Type u} (u : UniformSpace.Core α) : UniformSpace α\n    where\n  toCore := u\n  toTopologicalSpace := u.toTopologicalSpace\n  isOpen_uniformity a := Iff.rfl\n#align uniform_space.of_core UniformSpace.ofCore\n-/\n\n#print UniformSpace.ofCoreEq /-\n/-- Construct a `uniform_space` from a `u : uniform_space.core` and a `topological_space` structure\nthat is equal to `u.to_topological_space`. -/\ndef UniformSpace.ofCoreEq {α : Type u} (u : UniformSpace.Core α) (t : TopologicalSpace α)\n    (h : t = u.toTopologicalSpace) : UniformSpace α\n    where\n  toCore := u\n  toTopologicalSpace := t\n  isOpen_uniformity a := h.symm ▸ Iff.rfl\n#align uniform_space.of_core_eq UniformSpace.ofCoreEq\n-/\n\n#print UniformSpace.toCore_toTopologicalSpace /-\ntheorem UniformSpace.toCore_toTopologicalSpace (u : UniformSpace α) :\n    u.toCore.toTopologicalSpace = u.toTopologicalSpace :=\n  topologicalSpace_eq <| funext fun s => by rw [UniformSpace.isOpen_uniformity, isOpen_mk]\n#align uniform_space.to_core_to_topological_space UniformSpace.toCore_toTopologicalSpace\n-/\n\n#print uniformity /-\n/-- The uniformity is a filter on α × α (inferred from an ambient uniform space\n  structure on α). -/\ndef uniformity (α : Type u) [UniformSpace α] : Filter (α × α) :=\n  (@UniformSpace.toCore α _).uniformity\n#align uniformity uniformity\n-/\n\n-- mathport name: uniformity_of\nscoped[Topology] notation \"𝓤[\" u \"]\" => @uniformity hole! u\n\n#print uniformSpace_eq /-\n@[ext]\ntheorem uniformSpace_eq : ∀ {u₁ u₂ : UniformSpace α}, 𝓤[u₁] = 𝓤[u₂] → u₁ = u₂\n  | UniformSpace.mk' t₁ u₁ o₁, UniformSpace.mk' t₂ u₂ o₂, h =>\n    by\n    have : u₁ = u₂ := UniformSpace.core_eq h\n    have : t₁ = t₂ := topologicalSpace_eq <| funext fun s => by rw [o₁, o₂] <;> simp [this]\n    simp [*]\n#align uniform_space_eq uniformSpace_eq\n-/\n\n#print UniformSpace.ofCoreEq_toCore /-\ntheorem UniformSpace.ofCoreEq_toCore (u : UniformSpace α) (t : TopologicalSpace α)\n    (h : t = u.toCore.toTopologicalSpace) : UniformSpace.ofCoreEq u.toCore t h = u :=\n  uniformSpace_eq rfl\n#align uniform_space.of_core_eq_to_core UniformSpace.ofCoreEq_toCore\n-/\n\n#print UniformSpace.replaceTopology /-\n/-- Replace topology in a `uniform_space` instance with a propositionally (but possibly not\ndefinitionally) equal one. -/\n@[reducible]\ndef UniformSpace.replaceTopology {α : Type _} [i : TopologicalSpace α] (u : UniformSpace α)\n    (h : i = u.toTopologicalSpace) : UniformSpace α :=\n  UniformSpace.ofCoreEq u.toCore i <| h.trans u.toCore_toTopologicalSpace.symm\n#align uniform_space.replace_topology UniformSpace.replaceTopology\n-/\n\n#print UniformSpace.replaceTopology_eq /-\ntheorem UniformSpace.replaceTopology_eq {α : Type _} [i : TopologicalSpace α] (u : UniformSpace α)\n    (h : i = u.toTopologicalSpace) : u.replaceTopology h = u :=\n  u.ofCoreEq_toCore _ _\n#align uniform_space.replace_topology_eq UniformSpace.replaceTopology_eq\n-/\n\n/- warning: uniform_space.of_fun -> UniformSpace.ofFun is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : OrderedAddCommMonoid.{u2} β] (d : α -> α -> β), (forall (x : α), Eq.{succ u2} β (d x x) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))))) -> (forall (x : α) (y : α), Eq.{succ u2} β (d x y) (d y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) (d x z) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) (d x y) (d y z))) -> (forall (ε : β), (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) ε (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))))) -> (Exists.{succ u2} β (fun (δ : β) => Exists.{0} (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) δ (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))))) (fun (H : GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) δ (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))))) => forall (x : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) x δ) -> (forall (y : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) y δ) -> (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) x y) ε)))))) -> (UniformSpace.{u1} α)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : OrderedAddCommMonoid.{u2} β] (d : α -> α -> β), (forall (x : α), Eq.{succ u2} β (d x x) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))) -> (forall (x : α) (y : α), Eq.{succ u2} β (d x y) (d y x)) -> (forall (x : α) (y : α) (z : α), LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) (d x z) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) (d x y) (d y z))) -> (forall (ε : β), (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) ε (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))) -> (Exists.{succ u2} β (fun (δ : β) => And (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) δ (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))) (forall (x : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) x δ) -> (forall (y : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) y δ) -> (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β _inst_1))) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) x y) ε)))))) -> (UniformSpace.{u1} α)\nCase conversion may be inaccurate. Consider using '#align uniform_space.of_fun UniformSpace.ofFunₓ'. -/\n/-- Define a `uniform_space` using a \"distance\" function. The function can be, e.g., the distance in\na (usual or extended) metric space or an absolute value on a ring. -/\ndef UniformSpace.ofFun {α β : Type _} [OrderedAddCommMonoid β] (d : α → α → β)\n    (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x)\n    (triangle : ∀ x y z, d x z ≤ d x y + d y z)\n    (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) : UniformSpace α :=\n  UniformSpace.ofCore\n    { uniformity := ⨅ r > 0, 𝓟 { x | d x.1 x.2 < r }\n      refl := le_infᵢ₂ fun r hr => principal_mono.2 <| idRel_subset.2 fun x => by simpa [refl]\n      symm :=\n        tendsto_infᵢ_infᵢ fun r =>\n          tendsto_infᵢ_infᵢ fun _ =>\n            tendsto_principal_principal.2 fun x hx => by rwa [mem_set_of, symm]\n      comp :=\n        le_infᵢ₂ fun r hr =>\n          let ⟨δ, h0, hδr⟩ := half r hr\n          le_principal_iff.2 <|\n            mem_of_superset\n              (mem_lift' <| mem_infᵢ_of_mem δ <| mem_infᵢ_of_mem h0 <| mem_principal_self _)\n              fun ⟨x, z⟩ ⟨y, h₁, h₂⟩ => (triangle _ _ _).trans_lt (hδr _ h₁ _ h₂) }\n#align uniform_space.of_fun UniformSpace.ofFun\n\n/- warning: uniform_space.has_basis_of_fun -> UniformSpace.hasBasis_ofFun is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedAddCommMonoid.{u2} β], (Exists.{succ u2} β (fun (x : β) => LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))))))) x)) -> (forall (d : α -> α -> β) (refl : forall (x : α), Eq.{succ u2} β (d x x) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1))))))))) (symm : forall (x : α) (y : α), Eq.{succ u2} β (d x y) (d y x)) (triangle : forall (x : α) (y : α) (z : α), LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (d x z) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))))) (d x y) (d y z))) (half : forall (ε : β), (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) ε (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1))))))))) -> (Exists.{succ u2} β (fun (δ : β) => Exists.{0} (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) δ (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1))))))))) (fun (H : GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) δ (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1))))))))) => forall (x : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) x δ) -> (forall (y : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) y δ) -> (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toHasAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))))) x y) ε)))))), Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α (UniformSpace.ofFun.{u1, u2} α β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1) d refl symm triangle half)) (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (OfNat.ofNat.{u2} β 0 (OfNat.mk.{u2} β 0 (Zero.zero.{u2} β (AddZeroClass.toHasZero.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (OrderedAddCommMonoid.toAddCommMonoid.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1))))))))) (fun (ε : β) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (d (Prod.fst.{u1, u1} α α x) (Prod.snd.{u1, u1} α α x)) ε)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedAddCommMonoid.{u2} β], (Exists.{succ u2} β (fun (x : β) => LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) x)) -> (forall (d : α -> α -> β) (refl : forall (x : α), Eq.{succ u2} β (d x x) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))) (symm : forall (x : α) (y : α), Eq.{succ u2} β (d x y) (d y x)) (triangle : forall (x : α) (y : α) (z : α), LE.le.{u2} β (Preorder.toLE.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (d x z) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) (d x y) (d y z))) (half : forall (ε : β), (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) ε (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))) -> (Exists.{succ u2} β (fun (δ : β) => And (GT.gt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) δ (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1)))))) (forall (x : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) x δ) -> (forall (y : β), (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) y δ) -> (LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (HAdd.hAdd.{u2, u2, u2} β β β (instHAdd.{u2} β (AddZeroClass.toAdd.{u2} β (AddMonoid.toAddZeroClass.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) x y) ε)))))), Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α (UniformSpace.ofFun.{u1, u2} α β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1) d refl symm triangle half)) (fun (x._@.Mathlib.Topology.UniformSpace.Basic._hyg.4156 : β) => LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (OfNat.ofNat.{u2} β 0 (Zero.toOfNat0.{u2} β (AddMonoid.toZero.{u2} β (AddCommMonoid.toAddMonoid.{u2} β (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} β _inst_1))))) x._@.Mathlib.Topology.UniformSpace.Basic._hyg.4156) (fun (ε : β) => setOf.{u1} (Prod.{u1, u1} α α) (fun (x : Prod.{u1, u1} α α) => LT.lt.{u2} β (Preorder.toLT.{u2} β (PartialOrder.toPreorder.{u2} β (OrderedAddCommMonoid.toPartialOrder.{u2} β (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} β _inst_1)))) (d (Prod.fst.{u1, u1} α α x) (Prod.snd.{u1, u1} α α x)) ε)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.has_basis_of_fun UniformSpace.hasBasis_ofFunₓ'. -/\ntheorem UniformSpace.hasBasis_ofFun {α β : Type _} [LinearOrderedAddCommMonoid β]\n    (h₀ : ∃ x : β, 0 < x) (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x)\n    (triangle : ∀ x y z, d x z ≤ d x y + d y z)\n    (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) :\n    𝓤[UniformSpace.ofFun d refl symm triangle half].HasBasis ((· < ·) (0 : β)) fun ε =>\n      { x | d x.1 x.2 < ε } :=\n  hasBasis_binfᵢ_principal'\n    (fun ε₁ h₁ ε₂ h₂ =>\n      ⟨min ε₁ ε₂, lt_min h₁ h₂, fun _x hx => lt_of_lt_of_le hx (min_le_left _ _), fun _x hx =>\n        lt_of_lt_of_le hx (min_le_right _ _)⟩)\n    h₀\n#align uniform_space.has_basis_of_fun UniformSpace.hasBasis_ofFun\n\nsection UniformSpace\n\nvariable [UniformSpace α]\n\n-- mathport name: uniformity\nscoped[uniformity] notation \"𝓤\" => uniformity\n\n#print isOpen_uniformity /-\ntheorem isOpen_uniformity {s : Set α} :\n    IsOpen s ↔ ∀ x ∈ s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α :=\n  UniformSpace.isOpen_uniformity s\n#align is_open_uniformity isOpen_uniformity\n-/\n\n/- warning: refl_le_uniformity -> refl_le_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (Filter.principal.{u1} (Prod.{u1, u1} α α) (idRel.{u1} α)) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (Filter.principal.{u1} (Prod.{u1, u1} α α) (idRel.{u1} α)) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align refl_le_uniformity refl_le_uniformityₓ'. -/\ntheorem refl_le_uniformity : 𝓟 idRel ≤ 𝓤 α :=\n  (@UniformSpace.toCore α _).refl\n#align refl_le_uniformity refl_le_uniformity\n\n#print uniformity.neBot /-\ninstance uniformity.neBot [Nonempty α] : NeBot (𝓤 α) :=\n  diagonal_nonempty.principal_neBot.mono refl_le_uniformity\n#align uniformity.ne_bot uniformity.neBot\n-/\n\n#print refl_mem_uniformity /-\ntheorem refl_mem_uniformity {x : α} {s : Set (α × α)} (h : s ∈ 𝓤 α) : (x, x) ∈ s :=\n  refl_le_uniformity h rfl\n#align refl_mem_uniformity refl_mem_uniformity\n-/\n\n#print mem_uniformity_of_eq /-\ntheorem mem_uniformity_of_eq {x y : α} {s : Set (α × α)} (h : s ∈ 𝓤 α) (hx : x = y) : (x, y) ∈ s :=\n  refl_le_uniformity h hx\n#align mem_uniformity_of_eq mem_uniformity_of_eq\n-/\n\n/- warning: symm_le_uniformity -> symm_le_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (Filter.map.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) (uniformity.{u1} α _inst_1)) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (Filter.map.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) (uniformity.{u1} α _inst_1)) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align symm_le_uniformity symm_le_uniformityₓ'. -/\ntheorem symm_le_uniformity : map (@Prod.swap α α) (𝓤 _) ≤ 𝓤 _ :=\n  (@UniformSpace.toCore α _).symm\n#align symm_le_uniformity symm_le_uniformity\n\n/- warning: comp_le_uniformity -> comp_le_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => compRel.{u1} α s s)) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => compRel.{u1} α s s)) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align comp_le_uniformity comp_le_uniformityₓ'. -/\ntheorem comp_le_uniformity : ((𝓤 α).lift' fun s : Set (α × α) => s ○ s) ≤ 𝓤 α :=\n  (@UniformSpace.toCore α _).comp\n#align comp_le_uniformity comp_le_uniformity\n\n#print tendsto_swap_uniformity /-\ntheorem tendsto_swap_uniformity : Tendsto (@Prod.swap α α) (𝓤 α) (𝓤 α) :=\n  symm_le_uniformity\n#align tendsto_swap_uniformity tendsto_swap_uniformity\n-/\n\n/- warning: comp_mem_uniformity_sets -> comp_mem_uniformity_sets is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s)))\nCase conversion may be inaccurate. Consider using '#align comp_mem_uniformity_sets comp_mem_uniformity_setsₓ'. -/\ntheorem comp_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, t ○ t ⊆ s :=\n  have : s ∈ (𝓤 α).lift' fun t : Set (α × α) => t ○ t := comp_le_uniformity hs\n  (mem_lift'_sets <| monotone_id.compRel monotone_id).mp this\n#align comp_mem_uniformity_sets comp_mem_uniformity_sets\n\n#print eventually_uniformity_iterate_comp_subset /-\n/-- If `s ∈ 𝓤 α`, then for any natural `n`, for a subset `t` of a sufficiently small set in `𝓤 α`,\nwe have `t ○ t ○ ... ○ t ⊆ s` (`n` compositions). -/\ntheorem eventually_uniformity_iterate_comp_subset {s : Set (α × α)} (hs : s ∈ 𝓤 α) (n : ℕ) :\n    ∀ᶠ t in (𝓤 α).smallSets, ((· ○ ·) t^[n]) t ⊆ s :=\n  by\n  suffices : ∀ᶠ t in (𝓤 α).smallSets, t ⊆ s ∧ ((· ○ ·) t^[n]) t ⊆ s\n  exact (eventually_and.1 this).2\n  induction' n with n ihn generalizing s; · simpa\n  rcases comp_mem_uniformity_sets hs with ⟨t, htU, hts⟩\n  refine' (ihn htU).mono fun U hU => _\n  rw [Function.iterate_succ_apply']\n  exact\n    ⟨hU.1.trans <| (subset_comp_self <| refl_le_uniformity htU).trans hts,\n      (compRel_mono hU.1 hU.2).trans hts⟩\n#align eventually_uniformity_iterate_comp_subset eventually_uniformity_iterate_comp_subset\n-/\n\n#print eventually_uniformity_comp_subset /-\n/-- If `s ∈ 𝓤 α`, then for any natural `n`, for a subset `t` of a sufficiently small set in `𝓤 α`,\nwe have `t ○ t ⊆ s`. -/\ntheorem eventually_uniformity_comp_subset {s : Set (α × α)} (hs : s ∈ 𝓤 α) :\n    ∀ᶠ t in (𝓤 α).smallSets, t ○ t ⊆ s :=\n  eventually_uniformity_iterate_comp_subset hs 1\n#align eventually_uniformity_comp_subset eventually_uniformity_comp_subset\n-/\n\n#print Filter.Tendsto.uniformity_trans /-\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is transitive. -/\ntheorem Filter.Tendsto.uniformity_trans {l : Filter β} {f₁ f₂ f₃ : β → α}\n    (h₁₂ : Tendsto (fun x => (f₁ x, f₂ x)) l (𝓤 α))\n    (h₂₃ : Tendsto (fun x => (f₂ x, f₃ x)) l (𝓤 α)) : Tendsto (fun x => (f₁ x, f₃ x)) l (𝓤 α) :=\n  by\n  refine' le_trans (le_lift'.2 fun s hs => mem_map.2 _) comp_le_uniformity\n  filter_upwards [h₁₂ hs, h₂₃ hs]with x hx₁₂ hx₂₃ using⟨_, hx₁₂, hx₂₃⟩\n#align filter.tendsto.uniformity_trans Filter.Tendsto.uniformity_trans\n-/\n\n#print Filter.Tendsto.uniformity_symm /-\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is symmetric -/\ntheorem Filter.Tendsto.uniformity_symm {l : Filter β} {f : β → α × α} (h : Tendsto f l (𝓤 α)) :\n    Tendsto (fun x => ((f x).2, (f x).1)) l (𝓤 α) :=\n  tendsto_swap_uniformity.comp h\n#align filter.tendsto.uniformity_symm Filter.Tendsto.uniformity_symm\n-/\n\n#print tendsto_diag_uniformity /-\n/-- Relation `λ f g, tendsto (λ x, (f x, g x)) l (𝓤 α)` is reflexive. -/\ntheorem tendsto_diag_uniformity (f : β → α) (l : Filter β) :\n    Tendsto (fun x => (f x, f x)) l (𝓤 α) := fun s hs =>\n  mem_map.2 <| univ_mem' fun x => refl_mem_uniformity hs\n#align tendsto_diag_uniformity tendsto_diag_uniformity\n-/\n\n#print tendsto_const_uniformity /-\ntheorem tendsto_const_uniformity {a : α} {f : Filter β} : Tendsto (fun _ => (a, a)) f (𝓤 α) :=\n  tendsto_diag_uniformity (fun _ => a) f\n#align tendsto_const_uniformity tendsto_const_uniformity\n-/\n\n/- warning: symm_of_uniformity -> symm_of_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => And (forall (a : α) (b : α), (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) t) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) t s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (And (forall (a : α) (b : α), (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) t) -> (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) t s))))\nCase conversion may be inaccurate. Consider using '#align symm_of_uniformity symm_of_uniformityₓ'. -/\ntheorem symm_of_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) :\n    ∃ t ∈ 𝓤 α, (∀ a b, (a, b) ∈ t → (b, a) ∈ t) ∧ t ⊆ s :=\n  have : preimage Prod.swap s ∈ 𝓤 α := symm_le_uniformity hs\n  ⟨s ∩ preimage Prod.swap s, inter_mem hs this, fun a b ⟨h₁, h₂⟩ => ⟨h₂, h₁⟩, inter_subset_left _ _⟩\n#align symm_of_uniformity symm_of_uniformity\n\n/- warning: comp_symm_of_uniformity -> comp_symm_of_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => And (forall {a : α} {b : α}, (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) t) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (And (forall {a : α} {b : α}, (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) t) -> (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s))))\nCase conversion may be inaccurate. Consider using '#align comp_symm_of_uniformity comp_symm_of_uniformityₓ'. -/\ntheorem comp_symm_of_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) :\n    ∃ t ∈ 𝓤 α, (∀ {a b}, (a, b) ∈ t → (b, a) ∈ t) ∧ t ○ t ⊆ s :=\n  let ⟨t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs\n  let ⟨t', ht', ht'₁, ht'₂⟩ := symm_of_uniformity ht₁\n  ⟨t', ht', ht'₁, Subset.trans (monotone_id.compRel monotone_id ht'₂) ht₂⟩\n#align comp_symm_of_uniformity comp_symm_of_uniformity\n\n/- warning: uniformity_le_symm -> uniformity_le_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (uniformity.{u1} α _inst_1) (Functor.map.{u1, u1} Filter.{u1} Filter.functor.{u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) (uniformity.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (uniformity.{u1} α _inst_1) (Functor.map.{u1, u1} Filter.{u1} Filter.instFunctorFilter.{u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) (uniformity.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align uniformity_le_symm uniformity_le_symmₓ'. -/\ntheorem uniformity_le_symm : 𝓤 α ≤ @Prod.swap α α <$> 𝓤 α := by\n  rw [map_swap_eq_comap_swap] <;> exact map_le_iff_le_comap.1 tendsto_swap_uniformity\n#align uniformity_le_symm uniformity_le_symm\n\n#print uniformity_eq_symm /-\ntheorem uniformity_eq_symm : 𝓤 α = @Prod.swap α α <$> 𝓤 α :=\n  le_antisymm uniformity_le_symm symm_le_uniformity\n#align uniformity_eq_symm uniformity_eq_symm\n-/\n\n#print comap_swap_uniformity /-\n@[simp]\ntheorem comap_swap_uniformity : comap (@Prod.swap α α) (𝓤 α) = 𝓤 α :=\n  (congr_arg _ uniformity_eq_symm).trans <| comap_map Prod.swap_injective\n#align comap_swap_uniformity comap_swap_uniformity\n-/\n\n#print symmetrize_mem_uniformity /-\ntheorem symmetrize_mem_uniformity {V : Set (α × α)} (h : V ∈ 𝓤 α) : symmetrizeRel V ∈ 𝓤 α :=\n  by\n  apply (𝓤 α).inter_sets h\n  rw [← image_swap_eq_preimage_swap, uniformity_eq_symm]\n  exact image_mem_map h\n#align symmetrize_mem_uniformity symmetrize_mem_uniformity\n-/\n\n#print UniformSpace.hasBasis_symmetric /-\n/-- Symmetric entourages form a basis of `𝓤 α` -/\ntheorem UniformSpace.hasBasis_symmetric :\n    (𝓤 α).HasBasis (fun s : Set (α × α) => s ∈ 𝓤 α ∧ SymmetricRel s) id :=\n  hasBasis_self.2 fun t t_in =>\n    ⟨symmetrizeRel t, symmetrize_mem_uniformity t_in, symmetric_symmetrizeRel t,\n      symmetrizeRel_subset_self t⟩\n#align uniform_space.has_basis_symmetric UniformSpace.hasBasis_symmetric\n-/\n\n/- warning: uniformity_lift_le_swap -> uniformity_lift_le_swap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {g : (Set.{u1} (Prod.{u1, u1} α α)) -> (Filter.{u2} β)} {f : Filter.{u2} β}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} α α)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.partialOrder.{u2} β)) g) -> (LE.le.{u2} (Filter.{u2} β) (Preorder.toLE.{u2} (Filter.{u2} β) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.partialOrder.{u2} β))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => g (Set.preimage.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) s))) f) -> (LE.le.{u2} (Filter.{u2} β) (Preorder.toLE.{u2} (Filter.{u2} β) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.partialOrder.{u2} β))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) g) f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {g : (Set.{u1} (Prod.{u1, u1} α α)) -> (Filter.{u2} β)} {f : Filter.{u2} β}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} α α)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.instPartialOrderFilter.{u2} β)) g) -> (LE.le.{u2} (Filter.{u2} β) (Preorder.toLE.{u2} (Filter.{u2} β) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.instPartialOrderFilter.{u2} β))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => g (Set.preimage.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (Prod.swap.{u1, u1} α α) s))) f) -> (LE.le.{u2} (Filter.{u2} β) (Preorder.toLE.{u2} (Filter.{u2} β) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.instPartialOrderFilter.{u2} β))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) g) f)\nCase conversion may be inaccurate. Consider using '#align uniformity_lift_le_swap uniformity_lift_le_swapₓ'. -/\ntheorem uniformity_lift_le_swap {g : Set (α × α) → Filter β} {f : Filter β} (hg : Monotone g)\n    (h : ((𝓤 α).lift fun s => g (preimage Prod.swap s)) ≤ f) : (𝓤 α).lift g ≤ f :=\n  calc\n    (𝓤 α).lift g ≤ (Filter.map (@Prod.swap α α) <| 𝓤 α).lift g :=\n      lift_mono uniformity_le_symm le_rfl\n    _ ≤ _ := by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap] <;> exact h\n    \n#align uniformity_lift_le_swap uniformity_lift_le_swap\n\n/- warning: uniformity_lift_le_comp -> uniformity_lift_le_comp is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {f : (Set.{u1} (Prod.{u1, u1} α α)) -> (Filter.{u2} β)}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} α α)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.partialOrder.{u2} β)) f) -> (LE.le.{u2} (Filter.{u2} β) (Preorder.toLE.{u2} (Filter.{u2} β) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.partialOrder.{u2} β))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => f (compRel.{u1} α s s))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {f : (Set.{u1} (Prod.{u1, u1} α α)) -> (Filter.{u2} β)}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} α α)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.instPartialOrderFilter.{u2} β)) f) -> (LE.le.{u2} (Filter.{u2} β) (Preorder.toLE.{u2} (Filter.{u2} β) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.instPartialOrderFilter.{u2} β))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => f (compRel.{u1} α s s))) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) f))\nCase conversion may be inaccurate. Consider using '#align uniformity_lift_le_comp uniformity_lift_le_compₓ'. -/\ntheorem uniformity_lift_le_comp {f : Set (α × α) → Filter β} (h : Monotone f) :\n    ((𝓤 α).lift fun s => f (s ○ s)) ≤ (𝓤 α).lift f :=\n  calc\n    ((𝓤 α).lift fun s => f (s ○ s)) = ((𝓤 α).lift' fun s : Set (α × α) => s ○ s).lift f :=\n      by\n      rw [lift_lift'_assoc]\n      exact monotone_id.comp_rel monotone_id\n      exact h\n    _ ≤ (𝓤 α).lift f := lift_mono comp_le_uniformity le_rfl\n    \n#align uniformity_lift_le_comp uniformity_lift_le_comp\n\n/- warning: comp_le_uniformity3 -> comp_le_uniformity3 is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => compRel.{u1} α s (compRel.{u1} α s s))) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => compRel.{u1} α s (compRel.{u1} α s s))) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align comp_le_uniformity3 comp_le_uniformity3ₓ'. -/\ntheorem comp_le_uniformity3 : ((𝓤 α).lift' fun s : Set (α × α) => s ○ (s ○ s)) ≤ 𝓤 α :=\n  calc\n    ((𝓤 α).lift' fun d => d ○ (d ○ d)) =\n        (𝓤 α).lift fun s => (𝓤 α).lift' fun t : Set (α × α) => s ○ (t ○ t) :=\n      by\n      rw [lift_lift'_same_eq_lift']\n      exact fun x => monotone_const.comp_rel <| monotone_id.comp_rel monotone_id\n      exact fun x => monotone_id.comp_rel monotone_const\n    _ ≤ (𝓤 α).lift fun s => (𝓤 α).lift' fun t : Set (α × α) => s ○ t :=\n      (lift_mono' fun s hs =>\n        @uniformity_lift_le_comp α _ _ (𝓟 ∘ (· ○ ·) s) <|\n          monotone_principal.comp (monotone_const.compRel monotone_id))\n    _ = (𝓤 α).lift' fun s : Set (α × α) => s ○ s :=\n      (lift_lift'_same_eq_lift' (fun s => monotone_const.compRel monotone_id) fun s =>\n        monotone_id.compRel monotone_const)\n    _ ≤ 𝓤 α := comp_le_uniformity\n    \n#align comp_le_uniformity3 comp_le_uniformity3\n\n/- warning: comp_symm_mem_uniformity_sets -> comp_symm_mem_uniformity_sets is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => And (SymmetricRel.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (And (SymmetricRel.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s))))\nCase conversion may be inaccurate. Consider using '#align comp_symm_mem_uniformity_sets comp_symm_mem_uniformity_setsₓ'. -/\n/-- See also `comp_open_symm_mem_uniformity_sets`. -/\ntheorem comp_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) :\n    ∃ t ∈ 𝓤 α, SymmetricRel t ∧ t ○ t ⊆ s :=\n  by\n  obtain ⟨w, w_in, w_sub⟩ : ∃ w ∈ 𝓤 α, w ○ w ⊆ s := comp_mem_uniformity_sets hs\n  use symmetrizeRel w, symmetrize_mem_uniformity w_in, symmetric_symmetrizeRel w\n  have : symmetrizeRel w ⊆ w := symmetrizeRel_subset_self w\n  calc\n    symmetrizeRel w ○ symmetrizeRel w ⊆ w ○ w := by mono\n    _ ⊆ s := w_sub\n    \n#align comp_symm_mem_uniformity_sets comp_symm_mem_uniformity_sets\n\n#print subset_comp_self_of_mem_uniformity /-\ntheorem subset_comp_self_of_mem_uniformity {s : Set (α × α)} (h : s ∈ 𝓤 α) : s ⊆ s ○ s :=\n  subset_comp_self (refl_le_uniformity h)\n#align subset_comp_self_of_mem_uniformity subset_comp_self_of_mem_uniformity\n-/\n\n/- warning: comp_comp_symm_mem_uniformity_sets -> comp_comp_symm_mem_uniformity_sets is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => And (SymmetricRel.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α (compRel.{u1} α t t) t) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (And (SymmetricRel.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α (compRel.{u1} α t t) t) s))))\nCase conversion may be inaccurate. Consider using '#align comp_comp_symm_mem_uniformity_sets comp_comp_symm_mem_uniformity_setsₓ'. -/\ntheorem comp_comp_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) :\n    ∃ t ∈ 𝓤 α, SymmetricRel t ∧ t ○ t ○ t ⊆ s :=\n  by\n  rcases comp_symm_mem_uniformity_sets hs with ⟨w, w_in, w_symm, w_sub⟩\n  rcases comp_symm_mem_uniformity_sets w_in with ⟨t, t_in, t_symm, t_sub⟩\n  use t, t_in, t_symm\n  have : t ⊆ t ○ t := subset_comp_self_of_mem_uniformity t_in\n  calc\n    t ○ t ○ t ⊆ w ○ t := by mono\n    _ ⊆ w ○ (t ○ t) := by mono\n    _ ⊆ w ○ w := by mono\n    _ ⊆ s := w_sub\n    \n#align comp_comp_symm_mem_uniformity_sets comp_comp_symm_mem_uniformity_sets\n\n/-!\n### Balls in uniform spaces\n-/\n\n\n#print UniformSpace.ball /-\n/-- The ball around `(x : β)` with respect to `(V : set (β × β))`. Intended to be\nused for `V ∈ 𝓤 β`, but this is not needed for the definition. Recovers the\nnotions of metric space ball when `V = {p | dist p.1 p.2 < r }`.  -/\ndef UniformSpace.ball (x : β) (V : Set (β × β)) : Set β :=\n  Prod.mk x ⁻¹' V\n#align uniform_space.ball UniformSpace.ball\n-/\n\nopen UniformSpace (ball)\n\n#print UniformSpace.mem_ball_self /-\ntheorem UniformSpace.mem_ball_self (x : α) {V : Set (α × α)} (hV : V ∈ 𝓤 α) : x ∈ ball x V :=\n  refl_mem_uniformity hV\n#align uniform_space.mem_ball_self UniformSpace.mem_ball_self\n-/\n\n#print mem_ball_comp /-\n/-- The triangle inequality for `uniform_space.ball` -/\ntheorem mem_ball_comp {V W : Set (β × β)} {x y z} (h : y ∈ ball x V) (h' : z ∈ ball y W) :\n    z ∈ ball x (V ○ W) :=\n  prod_mk_mem_compRel h h'\n#align mem_ball_comp mem_ball_comp\n-/\n\n#print ball_subset_of_comp_subset /-\ntheorem ball_subset_of_comp_subset {V W : Set (β × β)} {x y} (h : x ∈ ball y W) (h' : W ○ W ⊆ V) :\n    ball x W ⊆ ball y V := fun z z_in => h' (mem_ball_comp h z_in)\n#align ball_subset_of_comp_subset ball_subset_of_comp_subset\n-/\n\n#print ball_mono /-\ntheorem ball_mono {V W : Set (β × β)} (h : V ⊆ W) (x : β) : ball x V ⊆ ball x W :=\n  preimage_mono h\n#align ball_mono ball_mono\n-/\n\n/- warning: ball_inter -> ball_inter is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} (x : β) (V : Set.{u1} (Prod.{u1, u1} β β)) (W : Set.{u1} (Prod.{u1, u1} β β)), Eq.{succ u1} (Set.{u1} β) (UniformSpace.ball.{u1} β x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.hasInter.{u1} (Prod.{u1, u1} β β)) V W)) (Inter.inter.{u1} (Set.{u1} β) (Set.hasInter.{u1} β) (UniformSpace.ball.{u1} β x V) (UniformSpace.ball.{u1} β x W))\nbut is expected to have type\n  forall {β : Type.{u1}} (x : β) (V : Set.{u1} (Prod.{u1, u1} β β)) (W : Set.{u1} (Prod.{u1, u1} β β)), Eq.{succ u1} (Set.{u1} β) (UniformSpace.ball.{u1} β x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.instInterSet.{u1} (Prod.{u1, u1} β β)) V W)) (Inter.inter.{u1} (Set.{u1} β) (Set.instInterSet.{u1} β) (UniformSpace.ball.{u1} β x V) (UniformSpace.ball.{u1} β x W))\nCase conversion may be inaccurate. Consider using '#align ball_inter ball_interₓ'. -/\ntheorem ball_inter (x : β) (V W : Set (β × β)) : ball x (V ∩ W) = ball x V ∩ ball x W :=\n  preimage_inter\n#align ball_inter ball_inter\n\n/- warning: ball_inter_left -> ball_inter_left is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} (x : β) (V : Set.{u1} (Prod.{u1, u1} β β)) (W : Set.{u1} (Prod.{u1, u1} β β)), HasSubset.Subset.{u1} (Set.{u1} β) (Set.hasSubset.{u1} β) (UniformSpace.ball.{u1} β x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.hasInter.{u1} (Prod.{u1, u1} β β)) V W)) (UniformSpace.ball.{u1} β x V)\nbut is expected to have type\n  forall {β : Type.{u1}} (x : β) (V : Set.{u1} (Prod.{u1, u1} β β)) (W : Set.{u1} (Prod.{u1, u1} β β)), HasSubset.Subset.{u1} (Set.{u1} β) (Set.instHasSubsetSet.{u1} β) (UniformSpace.ball.{u1} β x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.instInterSet.{u1} (Prod.{u1, u1} β β)) V W)) (UniformSpace.ball.{u1} β x V)\nCase conversion may be inaccurate. Consider using '#align ball_inter_left ball_inter_leftₓ'. -/\ntheorem ball_inter_left (x : β) (V W : Set (β × β)) : ball x (V ∩ W) ⊆ ball x V :=\n  ball_mono (inter_subset_left V W) x\n#align ball_inter_left ball_inter_left\n\n/- warning: ball_inter_right -> ball_inter_right is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} (x : β) (V : Set.{u1} (Prod.{u1, u1} β β)) (W : Set.{u1} (Prod.{u1, u1} β β)), HasSubset.Subset.{u1} (Set.{u1} β) (Set.hasSubset.{u1} β) (UniformSpace.ball.{u1} β x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.hasInter.{u1} (Prod.{u1, u1} β β)) V W)) (UniformSpace.ball.{u1} β x W)\nbut is expected to have type\n  forall {β : Type.{u1}} (x : β) (V : Set.{u1} (Prod.{u1, u1} β β)) (W : Set.{u1} (Prod.{u1, u1} β β)), HasSubset.Subset.{u1} (Set.{u1} β) (Set.instHasSubsetSet.{u1} β) (UniformSpace.ball.{u1} β x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.instInterSet.{u1} (Prod.{u1, u1} β β)) V W)) (UniformSpace.ball.{u1} β x W)\nCase conversion may be inaccurate. Consider using '#align ball_inter_right ball_inter_rightₓ'. -/\ntheorem ball_inter_right (x : β) (V W : Set (β × β)) : ball x (V ∩ W) ⊆ ball x W :=\n  ball_mono (inter_subset_right V W) x\n#align ball_inter_right ball_inter_right\n\n#print mem_ball_symmetry /-\ntheorem mem_ball_symmetry {V : Set (β × β)} (hV : SymmetricRel V) {x y} :\n    x ∈ ball y V ↔ y ∈ ball x V :=\n  show (x, y) ∈ Prod.swap ⁻¹' V ↔ (x, y) ∈ V\n    by\n    unfold SymmetricRel at hV\n    rw [hV]\n#align mem_ball_symmetry mem_ball_symmetry\n-/\n\n#print ball_eq_of_symmetry /-\ntheorem ball_eq_of_symmetry {V : Set (β × β)} (hV : SymmetricRel V) {x} :\n    ball x V = { y | (y, x) ∈ V } := by\n  ext y\n  rw [mem_ball_symmetry hV]\n  exact Iff.rfl\n#align ball_eq_of_symmetry ball_eq_of_symmetry\n-/\n\n#print mem_comp_of_mem_ball /-\ntheorem mem_comp_of_mem_ball {V W : Set (β × β)} {x y z : β} (hV : SymmetricRel V)\n    (hx : x ∈ ball z V) (hy : y ∈ ball z W) : (x, y) ∈ V ○ W :=\n  by\n  rw [mem_ball_symmetry hV] at hx\n  exact ⟨z, hx, hy⟩\n#align mem_comp_of_mem_ball mem_comp_of_mem_ball\n-/\n\n/- warning: uniform_space.is_open_ball -> UniformSpace.isOpen_ball is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (x : α) {V : Set.{u1} (Prod.{u1, u1} α α)}, (IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.ball.{u1} α x V))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (x : α) {V : Set.{u1} (Prod.{u1, u1} α α)}, (IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.ball.{u1} α x V))\nCase conversion may be inaccurate. Consider using '#align uniform_space.is_open_ball UniformSpace.isOpen_ballₓ'. -/\ntheorem UniformSpace.isOpen_ball (x : α) {V : Set (α × α)} (hV : IsOpen V) : IsOpen (ball x V) :=\n  hV.Preimage <| continuous_const.prod_mk continuous_id\n#align uniform_space.is_open_ball UniformSpace.isOpen_ball\n\n/- warning: mem_comp_comp -> mem_comp_comp is a dubious translation:\nlean 3 declaration is\n  forall {β : Type.{u1}} {V : Set.{u1} (Prod.{u1, u1} β β)} {W : Set.{u1} (Prod.{u1, u1} β β)} {M : Set.{u1} (Prod.{u1, u1} β β)}, (SymmetricRel.{u1} β W) -> (forall {p : Prod.{u1, u1} β β}, Iff (Membership.Mem.{u1, u1} (Prod.{u1, u1} β β) (Set.{u1} (Prod.{u1, u1} β β)) (Set.hasMem.{u1} (Prod.{u1, u1} β β)) p (compRel.{u1} β (compRel.{u1} β V M) W)) (Set.Nonempty.{u1} (Prod.{u1, u1} β β) (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.hasInter.{u1} (Prod.{u1, u1} β β)) (Set.prod.{u1, u1} β β (UniformSpace.ball.{u1} β (Prod.fst.{u1, u1} β β p) V) (UniformSpace.ball.{u1} β (Prod.snd.{u1, u1} β β p) W)) M)))\nbut is expected to have type\n  forall {β : Type.{u1}} {V : Set.{u1} (Prod.{u1, u1} β β)} {W : Set.{u1} (Prod.{u1, u1} β β)} {M : Set.{u1} (Prod.{u1, u1} β β)}, (SymmetricRel.{u1} β W) -> (forall {p : Prod.{u1, u1} β β}, Iff (Membership.mem.{u1, u1} (Prod.{u1, u1} β β) (Set.{u1} (Prod.{u1, u1} β β)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} β β)) p (compRel.{u1} β (compRel.{u1} β V M) W)) (Set.Nonempty.{u1} (Prod.{u1, u1} β β) (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} β β)) (Set.instInterSet.{u1} (Prod.{u1, u1} β β)) (Set.prod.{u1, u1} β β (UniformSpace.ball.{u1} β (Prod.fst.{u1, u1} β β p) V) (UniformSpace.ball.{u1} β (Prod.snd.{u1, u1} β β p) W)) M)))\nCase conversion may be inaccurate. Consider using '#align mem_comp_comp mem_comp_compₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem mem_comp_comp {V W M : Set (β × β)} (hW' : SymmetricRel W) {p : β × β} :\n    p ∈ V ○ M ○ W ↔ (ball p.1 V ×ˢ ball p.2 W ∩ M).Nonempty :=\n  by\n  cases' p with x y\n  constructor\n  · rintro ⟨z, ⟨w, hpw, hwz⟩, hzy⟩\n    exact ⟨(w, z), ⟨hpw, by rwa [mem_ball_symmetry hW']⟩, hwz⟩\n  · rintro ⟨⟨w, z⟩, ⟨w_in, z_in⟩, hwz⟩\n    rwa [mem_ball_symmetry hW'] at z_in\n    use z, w <;> tauto\n#align mem_comp_comp mem_comp_comp\n\n/-!\n### Neighborhoods in uniform spaces\n-/\n\n\n#print mem_nhds_uniformity_iff_right /-\ntheorem mem_nhds_uniformity_iff_right {x : α} {s : Set α} :\n    s ∈ 𝓝 x ↔ { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α :=\n  by\n  refine' ⟨_, fun hs => _⟩\n  · simp only [mem_nhds_iff, isOpen_uniformity, and_imp, exists_imp]\n    intro t ts ht xt\n    filter_upwards [ht x xt]using fun y h eq => ts (h Eq)\n  · refine' mem_nhds_iff.mpr ⟨{ x | { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α }, _, _, hs⟩\n    · exact fun y hy => refl_mem_uniformity hy rfl\n    · refine' is_open_uniformity.mpr fun y hy => _\n      rcases comp_mem_uniformity_sets hy with ⟨t, ht, tr⟩\n      filter_upwards [ht]\n      rintro ⟨a, b⟩ hp' rfl\n      filter_upwards [ht]\n      rintro ⟨a', b'⟩ hp'' rfl\n      exact @tr (a, b') ⟨a', hp', hp''⟩ rfl\n#align mem_nhds_uniformity_iff_right mem_nhds_uniformity_iff_right\n-/\n\n#print mem_nhds_uniformity_iff_left /-\ntheorem mem_nhds_uniformity_iff_left {x : α} {s : Set α} :\n    s ∈ 𝓝 x ↔ { p : α × α | p.2 = x → p.1 ∈ s } ∈ 𝓤 α :=\n  by\n  rw [uniformity_eq_symm, mem_nhds_uniformity_iff_right]\n  rfl\n#align mem_nhds_uniformity_iff_left mem_nhds_uniformity_iff_left\n-/\n\n#print nhds_eq_comap_uniformity /-\ntheorem nhds_eq_comap_uniformity {x : α} : 𝓝 x = (𝓤 α).comap (Prod.mk x) :=\n  by\n  ext s\n  rw [mem_nhds_uniformity_iff_right, mem_comap_prod_mk]\n#align nhds_eq_comap_uniformity nhds_eq_comap_uniformity\n-/\n\n/- warning: is_open_iff_ball_subset -> isOpen_iff_ball_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s) (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (UniformSpace.ball.{u1} α x V) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (UniformSpace.ball.{u1} α x V) s))))\nCase conversion may be inaccurate. Consider using '#align is_open_iff_ball_subset isOpen_iff_ball_subsetₓ'. -/\n/-- See also `is_open_iff_open_ball_subset`. -/\ntheorem isOpen_iff_ball_subset {s : Set α} : IsOpen s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 α, ball x V ⊆ s :=\n  by\n  simp_rw [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity]\n  exact Iff.rfl\n#align is_open_iff_ball_subset isOpen_iff_ball_subset\n\n/- warning: nhds_basis_uniformity' -> nhds_basis_uniformity' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : ι -> Prop} {s : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p s) -> (forall {x : α}, Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x) p (fun (i : ι) => UniformSpace.ball.{u1} α x (s i)))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u2} α] {p : ι -> Prop} {s : ι -> (Set.{u2} (Prod.{u2, u2} α α))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} α α) ι (uniformity.{u2} α _inst_1) p s) -> (forall {x : α}, Filter.HasBasis.{u2, u1} α ι (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) x) p (fun (i : ι) => UniformSpace.ball.{u2} α x (s i)))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_uniformity' nhds_basis_uniformity'ₓ'. -/\ntheorem nhds_basis_uniformity' {p : ι → Prop} {s : ι → Set (α × α)} (h : (𝓤 α).HasBasis p s)\n    {x : α} : (𝓝 x).HasBasis p fun i => ball x (s i) :=\n  by\n  rw [nhds_eq_comap_uniformity]\n  exact h.comap (Prod.mk x)\n#align nhds_basis_uniformity' nhds_basis_uniformity'\n\n/- warning: nhds_basis_uniformity -> nhds_basis_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : ι -> Prop} {s : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p s) -> (forall {x : α}, Filter.HasBasis.{u1, u2} α ι (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x) p (fun (i : ι) => setOf.{u1} α (fun (y : α) => Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α y x) (s i))))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u2} α] {p : ι -> Prop} {s : ι -> (Set.{u2} (Prod.{u2, u2} α α))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} α α) ι (uniformity.{u2} α _inst_1) p s) -> (forall {x : α}, Filter.HasBasis.{u2, u1} α ι (nhds.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) x) p (fun (i : ι) => setOf.{u2} α (fun (y : α) => Membership.mem.{u2, u2} (Prod.{u2, u2} α α) (Set.{u2} (Prod.{u2, u2} α α)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} α α)) (Prod.mk.{u2, u2} α α y x) (s i))))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_uniformity nhds_basis_uniformityₓ'. -/\ntheorem nhds_basis_uniformity {p : ι → Prop} {s : ι → Set (α × α)} (h : (𝓤 α).HasBasis p s)\n    {x : α} : (𝓝 x).HasBasis p fun i => { y | (y, x) ∈ s i } :=\n  by\n  replace h := h.comap Prod.swap\n  rw [← map_swap_eq_comap_swap, ← uniformity_eq_symm] at h\n  exact nhds_basis_uniformity' h\n#align nhds_basis_uniformity nhds_basis_uniformity\n\n#print nhds_eq_comap_uniformity' /-\ntheorem nhds_eq_comap_uniformity' {x : α} : 𝓝 x = (𝓤 α).comap fun y => (y, x) :=\n  (nhds_basis_uniformity (𝓤 α).basis_sets).eq_of_same_basis <| (𝓤 α).basis_sets.comap _\n#align nhds_eq_comap_uniformity' nhds_eq_comap_uniformity'\n-/\n\n/- warning: uniform_space.mem_nhds_iff -> UniformSpace.mem_nhds_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {x : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (UniformSpace.ball.{u1} α x V) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {x : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (UniformSpace.ball.{u1} α x V) s)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_nhds_iff UniformSpace.mem_nhds_iffₓ'. -/\ntheorem UniformSpace.mem_nhds_iff {x : α} {s : Set α} : s ∈ 𝓝 x ↔ ∃ V ∈ 𝓤 α, ball x V ⊆ s :=\n  by\n  rw [nhds_eq_comap_uniformity, mem_comap]\n  exact Iff.rfl\n#align uniform_space.mem_nhds_iff UniformSpace.mem_nhds_iff\n\n#print UniformSpace.ball_mem_nhds /-\ntheorem UniformSpace.ball_mem_nhds (x : α) ⦃V : Set (α × α)⦄ (V_in : V ∈ 𝓤 α) : ball x V ∈ 𝓝 x :=\n  by\n  rw [UniformSpace.mem_nhds_iff]\n  exact ⟨V, V_in, subset.refl _⟩\n#align uniform_space.ball_mem_nhds UniformSpace.ball_mem_nhds\n-/\n\n/- warning: uniform_space.mem_nhds_iff_symm -> UniformSpace.mem_nhds_iff_symm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {x : α} {s : Set.{u1} α}, Iff (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) s (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) => And (SymmetricRel.{u1} α V) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (UniformSpace.ball.{u1} α x V) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {x : α} {s : Set.{u1} α}, Iff (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) s (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (And (SymmetricRel.{u1} α V) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (UniformSpace.ball.{u1} α x V) s))))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_nhds_iff_symm UniformSpace.mem_nhds_iff_symmₓ'. -/\ntheorem UniformSpace.mem_nhds_iff_symm {x : α} {s : Set α} :\n    s ∈ 𝓝 x ↔ ∃ V ∈ 𝓤 α, SymmetricRel V ∧ ball x V ⊆ s :=\n  by\n  rw [UniformSpace.mem_nhds_iff]\n  constructor\n  · rintro ⟨V, V_in, V_sub⟩\n    use symmetrizeRel V, symmetrize_mem_uniformity V_in, symmetric_symmetrizeRel V\n    exact subset.trans (ball_mono (symmetrizeRel_subset_self V) x) V_sub\n  · rintro ⟨V, V_in, V_symm, V_sub⟩\n    exact ⟨V, V_in, V_sub⟩\n#align uniform_space.mem_nhds_iff_symm UniformSpace.mem_nhds_iff_symm\n\n#print UniformSpace.hasBasis_nhds /-\ntheorem UniformSpace.hasBasis_nhds (x : α) :\n    HasBasis (𝓝 x) (fun s : Set (α × α) => s ∈ 𝓤 α ∧ SymmetricRel s) fun s => ball x s :=\n  ⟨fun t => by simp [UniformSpace.mem_nhds_iff_symm, and_assoc']⟩\n#align uniform_space.has_basis_nhds UniformSpace.hasBasis_nhds\n-/\n\nopen UniformSpace\n\n/- warning: uniform_space.mem_closure_iff_symm_ball -> UniformSpace.mem_closure_iff_symm_ball is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α} {x : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) -> (SymmetricRel.{u1} α V) -> (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) s (UniformSpace.ball.{u1} α x V))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α} {x : α}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) -> (SymmetricRel.{u1} α V) -> (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) s (UniformSpace.ball.{u1} α x V))))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_closure_iff_symm_ball UniformSpace.mem_closure_iff_symm_ballₓ'. -/\ntheorem UniformSpace.mem_closure_iff_symm_ball {s : Set α} {x} :\n    x ∈ closure s ↔ ∀ {V}, V ∈ 𝓤 α → SymmetricRel V → (s ∩ ball x V).Nonempty := by\n  simp [mem_closure_iff_nhds_basis (has_basis_nhds x), Set.Nonempty]\n#align uniform_space.mem_closure_iff_symm_ball UniformSpace.mem_closure_iff_symm_ball\n\n/- warning: uniform_space.mem_closure_iff_ball -> UniformSpace.mem_closure_iff_ball is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α} {x : α}, Iff (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) -> (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.hasInter.{u1} α) (UniformSpace.ball.{u1} α x V) s)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α} {x : α}, Iff (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) -> (Set.Nonempty.{u1} α (Inter.inter.{u1} (Set.{u1} α) (Set.instInterSet.{u1} α) (UniformSpace.ball.{u1} α x V) s)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_closure_iff_ball UniformSpace.mem_closure_iff_ballₓ'. -/\ntheorem UniformSpace.mem_closure_iff_ball {s : Set α} {x} :\n    x ∈ closure s ↔ ∀ {V}, V ∈ 𝓤 α → (ball x V ∩ s).Nonempty := by\n  simp [mem_closure_iff_nhds_basis' (nhds_basis_uniformity' (𝓤 α).basis_sets)]\n#align uniform_space.mem_closure_iff_ball UniformSpace.mem_closure_iff_ball\n\n/- warning: uniform_space.has_basis_nhds_prod -> UniformSpace.hasBasis_nhds_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (x : α) (y : α), Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (nhds.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α x y)) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) (SymmetricRel.{u1} α s)) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => Set.prod.{u1, u1} α α (UniformSpace.ball.{u1} α x s) (UniformSpace.ball.{u1} α y s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (x : α) (y : α), Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (nhds.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α x y)) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) (SymmetricRel.{u1} α s)) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => Set.prod.{u1, u1} α α (UniformSpace.ball.{u1} α x s) (UniformSpace.ball.{u1} α y s))\nCase conversion may be inaccurate. Consider using '#align uniform_space.has_basis_nhds_prod UniformSpace.hasBasis_nhds_prodₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem UniformSpace.hasBasis_nhds_prod (x y : α) :\n    HasBasis (𝓝 (x, y)) (fun s => s ∈ 𝓤 α ∧ SymmetricRel s) fun s => ball x s ×ˢ ball y s :=\n  by\n  rw [nhds_prod_eq]\n  apply (has_basis_nhds x).prod_same_index (has_basis_nhds y)\n  rintro U V ⟨U_in, U_symm⟩ ⟨V_in, V_symm⟩\n  exact\n    ⟨U ∩ V, ⟨(𝓤 α).inter_sets U_in V_in, U_symm.inter V_symm⟩, ball_inter_left x U V,\n      ball_inter_right y U V⟩\n#align uniform_space.has_basis_nhds_prod UniformSpace.hasBasis_nhds_prod\n\n#print nhds_eq_uniformity /-\ntheorem nhds_eq_uniformity {x : α} : 𝓝 x = (𝓤 α).lift' (ball x) :=\n  (nhds_basis_uniformity' (𝓤 α).basis_sets).eq_binfᵢ\n#align nhds_eq_uniformity nhds_eq_uniformity\n-/\n\n#print nhds_eq_uniformity' /-\ntheorem nhds_eq_uniformity' {x : α} : 𝓝 x = (𝓤 α).lift' fun s => { y | (y, x) ∈ s } :=\n  (nhds_basis_uniformity (𝓤 α).basis_sets).eq_binfᵢ\n#align nhds_eq_uniformity' nhds_eq_uniformity'\n-/\n\n#print mem_nhds_left /-\ntheorem mem_nhds_left (x : α) {s : Set (α × α)} (h : s ∈ 𝓤 α) : { y : α | (x, y) ∈ s } ∈ 𝓝 x :=\n  ball_mem_nhds x h\n#align mem_nhds_left mem_nhds_left\n-/\n\n#print mem_nhds_right /-\ntheorem mem_nhds_right (y : α) {s : Set (α × α)} (h : s ∈ 𝓤 α) : { x : α | (x, y) ∈ s } ∈ 𝓝 y :=\n  mem_nhds_left _ (symm_le_uniformity h)\n#align mem_nhds_right mem_nhds_right\n-/\n\n/- warning: exists_mem_nhds_ball_subset_of_mem_nhds -> exists_mem_nhds_ball_subset_of_mem_nhds is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {a : α} {U : Set.{u1} α}, (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) U (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) a)) -> (Exists.{succ u1} (Set.{u1} α) (fun (V : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) V (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) a)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (Filter.hasMem.{u1} α) V (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) a)) => Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => forall (a' : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a' V) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (UniformSpace.ball.{u1} α a' t) U))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {a : α} {U : Set.{u1} α}, (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) U (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) a)) -> (Exists.{succ u1} (Set.{u1} α) (fun (V : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Filter.{u1} α) (instMembershipSetFilter.{u1} α) V (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) a)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (forall (a' : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a' V) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (UniformSpace.ball.{u1} α a' t) U))))))\nCase conversion may be inaccurate. Consider using '#align exists_mem_nhds_ball_subset_of_mem_nhds exists_mem_nhds_ball_subset_of_mem_nhdsₓ'. -/\ntheorem exists_mem_nhds_ball_subset_of_mem_nhds {a : α} {U : Set α} (h : U ∈ 𝓝 a) :\n    ∃ V ∈ 𝓝 a, ∃ t ∈ 𝓤 α, ∀ a' ∈ V, UniformSpace.ball a' t ⊆ U :=\n  let ⟨t, ht, htU⟩ := comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 h)\n  ⟨_, mem_nhds_left a ht, t, ht, fun a₁ h₁ a₂ h₂ => @htU (a, a₂) ⟨a₁, h₁, h₂⟩ rfl⟩\n#align exists_mem_nhds_ball_subset_of_mem_nhds exists_mem_nhds_ball_subset_of_mem_nhds\n\n/- warning: is_compact.nhds_set_basis_uniformity -> IsCompact.nhdsSet_basis_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : ι -> Prop} {s : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p s) -> (forall {K : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) K) -> (Filter.HasBasis.{u1, u2} α ι (nhdsSet.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) K) p (fun (i : ι) => Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x K) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x K) => UniformSpace.ball.{u1} α x (s i))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u2} α] {p : ι -> Prop} {s : ι -> (Set.{u2} (Prod.{u2, u2} α α))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} α α) ι (uniformity.{u2} α _inst_1) p s) -> (forall {K : Set.{u2} α}, (IsCompact.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) K) -> (Filter.HasBasis.{u2, u1} α ι (nhdsSet.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) K) p (fun (i : ι) => Set.unionᵢ.{u2, succ u2} α α (fun (x : α) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x K) (fun (H : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x K) => UniformSpace.ball.{u2} α x (s i))))))\nCase conversion may be inaccurate. Consider using '#align is_compact.nhds_set_basis_uniformity IsCompact.nhdsSet_basis_uniformityₓ'. -/\ntheorem IsCompact.nhdsSet_basis_uniformity {p : ι → Prop} {s : ι → Set (α × α)}\n    (hU : (𝓤 α).HasBasis p s) {K : Set α} (hK : IsCompact K) :\n    (𝓝ˢ K).HasBasis p fun i => ⋃ x ∈ K, ball x (s i) :=\n  by\n  refine' ⟨fun U => _⟩\n  simp only [mem_nhdsSet_iff_forall, (nhds_basis_uniformity' hU).mem_iff, Union₂_subset_iff]\n  refine' ⟨fun H => _, fun ⟨i, hpi, hi⟩ x hx => ⟨i, hpi, hi x hx⟩⟩\n  replace H : ∀ x ∈ K, ∃ i : { i // p i }, ball x (s i ○ s i) ⊆ U\n  · intro x hx\n    rcases H x hx with ⟨i, hpi, hi⟩\n    rcases comp_mem_uniformity_sets (hU.mem_of_mem hpi) with ⟨t, ht_mem, ht⟩\n    rcases hU.mem_iff.1 ht_mem with ⟨j, hpj, hj⟩\n    exact ⟨⟨j, hpj⟩, subset.trans (ball_mono ((compRel_mono hj hj).trans ht) _) hi⟩\n  have : Nonempty { a // p a } := nonempty_subtype.2 hU.ex_mem\n  choose! I hI using H\n  rcases hK.elim_nhds_subcover (fun x => ball x <| s (I x)) fun x hx =>\n      ball_mem_nhds _ <| hU.mem_of_mem (I x).2 with\n    ⟨t, htK, ht⟩\n  obtain ⟨i, hpi, hi⟩ : ∃ (i : _)(hpi : p i), s i ⊆ ⋂ x ∈ t, s (I x)\n  exact hU.mem_iff.1 ((bInter_finset_mem t).2 fun x hx => hU.mem_of_mem (I x).2)\n  rw [subset_Inter₂_iff] at hi\n  refine' ⟨i, hpi, fun x hx => _⟩\n  rcases mem_Union₂.1 (ht hx) with ⟨z, hzt : z ∈ t, hzx : x ∈ ball z (s (I z))⟩\n  calc\n    ball x (s i) ⊆ ball z (s (I z) ○ s (I z)) := fun y hy => ⟨x, hzx, hi z hzt hy⟩\n    _ ⊆ U := hI z (htK z hzt)\n    \n#align is_compact.nhds_set_basis_uniformity IsCompact.nhdsSet_basis_uniformity\n\n/- warning: disjoint.exists_uniform_thickening -> Disjoint.exists_uniform_thickening is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {A : Set.{u1} α} {B : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) A) -> (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) B) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) A B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) => Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x A) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x A) => UniformSpace.ball.{u1} α x V))) (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x B) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x B) => UniformSpace.ball.{u1} α x V))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {A : Set.{u1} α} {B : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) A) -> (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) B) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) A B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x A) (fun (h._@.Mathlib.Topology.UniformSpace.Basic._hyg.10418 : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x A) => UniformSpace.ball.{u1} α x V))) (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x B) (fun (h._@.Mathlib.Topology.UniformSpace.Basic._hyg.10451 : Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x B) => UniformSpace.ball.{u1} α x V))))))\nCase conversion may be inaccurate. Consider using '#align disjoint.exists_uniform_thickening Disjoint.exists_uniform_thickeningₓ'. -/\ntheorem Disjoint.exists_uniform_thickening {A B : Set α} (hA : IsCompact A) (hB : IsClosed B)\n    (h : Disjoint A B) : ∃ V ∈ 𝓤 α, Disjoint (⋃ x ∈ A, ball x V) (⋃ x ∈ B, ball x V) :=\n  by\n  have : Bᶜ ∈ 𝓝ˢ A := hB.is_open_compl.mem_nhds_set.mpr h.le_compl_right\n  rw [(hA.nhds_set_basis_uniformity (Filter.basis_sets _)).mem_iff] at this\n  rcases this with ⟨U, hU, hUAB⟩\n  rcases comp_symm_mem_uniformity_sets hU with ⟨V, hV, hVsymm, hVU⟩\n  refine' ⟨V, hV, set.disjoint_left.mpr fun x => _⟩\n  simp only [mem_Union₂]\n  rintro ⟨a, ha, hxa⟩ ⟨b, hb, hxb⟩\n  rw [mem_ball_symmetry hVsymm] at hxa hxb\n  exact hUAB (mem_Union₂_of_mem ha <| hVU <| mem_comp_of_mem_ball hVsymm hxa hxb) hb\n#align disjoint.exists_uniform_thickening Disjoint.exists_uniform_thickening\n\n/- warning: disjoint.exists_uniform_thickening_of_basis -> Disjoint.exists_uniform_thickening_of_basis is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : ι -> Prop} {s : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p s) -> (forall {A : Set.{u1} α} {B : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) A) -> (IsClosed.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) B) -> (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) A B) -> (Exists.{u2} ι (fun (i : ι) => And (p i) (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x A) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x A) => UniformSpace.ball.{u1} α x (s i)))) (Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x B) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x B) => UniformSpace.ball.{u1} α x (s i))))))))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u2} α] {p : ι -> Prop} {s : ι -> (Set.{u2} (Prod.{u2, u2} α α))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} α α) ι (uniformity.{u2} α _inst_1) p s) -> (forall {A : Set.{u2} α} {B : Set.{u2} α}, (IsCompact.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) A) -> (IsClosed.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) B) -> (Disjoint.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} α) (Preorder.toLE.{u2} (Set.{u2} α) (PartialOrder.toPreorder.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) A B) -> (Exists.{u1} ι (fun (i : ι) => And (p i) (Disjoint.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} α) (Preorder.toLE.{u2} (Set.{u2} α) (PartialOrder.toPreorder.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (Set.unionᵢ.{u2, succ u2} α α (fun (x : α) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x A) (fun (H : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x A) => UniformSpace.ball.{u2} α x (s i)))) (Set.unionᵢ.{u2, succ u2} α α (fun (x : α) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x B) (fun (H : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x B) => UniformSpace.ball.{u2} α x (s i))))))))\nCase conversion may be inaccurate. Consider using '#align disjoint.exists_uniform_thickening_of_basis Disjoint.exists_uniform_thickening_of_basisₓ'. -/\ntheorem Disjoint.exists_uniform_thickening_of_basis {p : ι → Prop} {s : ι → Set (α × α)}\n    (hU : (𝓤 α).HasBasis p s) {A B : Set α} (hA : IsCompact A) (hB : IsClosed B)\n    (h : Disjoint A B) : ∃ i, p i ∧ Disjoint (⋃ x ∈ A, ball x (s i)) (⋃ x ∈ B, ball x (s i)) :=\n  by\n  rcases h.exists_uniform_thickening hA hB with ⟨V, hV, hVAB⟩\n  rcases hU.mem_iff.1 hV with ⟨i, hi, hiV⟩\n  exact\n    ⟨i, hi,\n      hVAB.mono (Union₂_mono fun a _ => ball_mono hiV a) (Union₂_mono fun b _ => ball_mono hiV b)⟩\n#align disjoint.exists_uniform_thickening_of_basis Disjoint.exists_uniform_thickening_of_basis\n\n#print tendsto_right_nhds_uniformity /-\ntheorem tendsto_right_nhds_uniformity {a : α} : Tendsto (fun a' => (a', a)) (𝓝 a) (𝓤 α) := fun s =>\n  mem_nhds_right a\n#align tendsto_right_nhds_uniformity tendsto_right_nhds_uniformity\n-/\n\n#print tendsto_left_nhds_uniformity /-\ntheorem tendsto_left_nhds_uniformity {a : α} : Tendsto (fun a' => (a, a')) (𝓝 a) (𝓤 α) := fun s =>\n  mem_nhds_left a\n#align tendsto_left_nhds_uniformity tendsto_left_nhds_uniformity\n-/\n\n/- warning: lift_nhds_left -> lift_nhds_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {x : α} {g : (Set.{u1} α) -> (Filter.{u2} β)}, (Monotone.{u1, u2} (Set.{u1} α) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.partialOrder.{u2} β)) g) -> (Eq.{succ u2} (Filter.{u2} β) (Filter.lift.{u1, u2} α β (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => g (UniformSpace.ball.{u1} α x s))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {x : α} {g : (Set.{u1} α) -> (Filter.{u2} β)}, (Monotone.{u1, u2} (Set.{u1} α) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.instPartialOrderFilter.{u2} β)) g) -> (Eq.{succ u2} (Filter.{u2} β) (Filter.lift.{u1, u2} α β (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => g (UniformSpace.ball.{u1} α x s))))\nCase conversion may be inaccurate. Consider using '#align lift_nhds_left lift_nhds_leftₓ'. -/\ntheorem lift_nhds_left {x : α} {g : Set α → Filter β} (hg : Monotone g) :\n    (𝓝 x).lift g = (𝓤 α).lift fun s : Set (α × α) => g (ball x s) :=\n  by\n  rw [nhds_eq_comap_uniformity, comap_lift_eq2 hg]\n  rfl\n#align lift_nhds_left lift_nhds_left\n\n/- warning: lift_nhds_right -> lift_nhds_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {x : α} {g : (Set.{u1} α) -> (Filter.{u2} β)}, (Monotone.{u1, u2} (Set.{u1} α) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.partialOrder.{u2} β)) g) -> (Eq.{succ u2} (Filter.{u2} β) (Filter.lift.{u1, u2} α β (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => g (setOf.{u1} α (fun (y : α) => Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α y x) s)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {x : α} {g : (Set.{u1} α) -> (Filter.{u2} β)}, (Monotone.{u1, u2} (Set.{u1} α) (Filter.{u2} β) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} β) (Filter.instPartialOrderFilter.{u2} β)) g) -> (Eq.{succ u2} (Filter.{u2} β) (Filter.lift.{u1, u2} α β (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => g (setOf.{u1} α (fun (y : α) => Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α y x) s)))))\nCase conversion may be inaccurate. Consider using '#align lift_nhds_right lift_nhds_rightₓ'. -/\ntheorem lift_nhds_right {x : α} {g : Set α → Filter β} (hg : Monotone g) :\n    (𝓝 x).lift g = (𝓤 α).lift fun s : Set (α × α) => g { y | (y, x) ∈ s } :=\n  by\n  rw [nhds_eq_comap_uniformity', comap_lift_eq2 hg]\n  rfl\n#align lift_nhds_right lift_nhds_right\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print nhds_nhds_eq_uniformity_uniformity_prod /-\ntheorem nhds_nhds_eq_uniformity_uniformity_prod {a b : α} :\n    𝓝 a ×ᶠ 𝓝 b =\n      (𝓤 α).lift fun s : Set (α × α) =>\n        (𝓤 α).lift' fun t : Set (α × α) => { y : α | (y, a) ∈ s } ×ˢ { y : α | (b, y) ∈ t } :=\n  by\n  rw [nhds_eq_uniformity', nhds_eq_uniformity, prod_lift'_lift']\n  exacts[rfl, monotone_preimage, monotone_preimage]\n#align nhds_nhds_eq_uniformity_uniformity_prod nhds_nhds_eq_uniformity_uniformity_prod\n-/\n\n/- warning: nhds_eq_uniformity_prod -> nhds_eq_uniformity_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {a : α} {b : α}, Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (nhds.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α a b)) (Filter.lift'.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => Set.prod.{u1, u1} α α (setOf.{u1} α (fun (y : α) => Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α y a) s)) (setOf.{u1} α (fun (y : α) => Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α b y) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {a : α} {b : α}, Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (nhds.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α a b)) (Filter.lift'.{u1, u1} (Prod.{u1, u1} α α) (Prod.{u1, u1} α α) (uniformity.{u1} α _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} α α)) => Set.prod.{u1, u1} α α (setOf.{u1} α (fun (y : α) => Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α y a) s)) (setOf.{u1} α (fun (y : α) => Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α b y) s))))\nCase conversion may be inaccurate. Consider using '#align nhds_eq_uniformity_prod nhds_eq_uniformity_prodₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem nhds_eq_uniformity_prod {a b : α} :\n    𝓝 (a, b) =\n      (𝓤 α).lift' fun s : Set (α × α) => { y : α | (y, a) ∈ s } ×ˢ { y : α | (b, y) ∈ s } :=\n  by\n  rw [nhds_prod_eq, nhds_nhds_eq_uniformity_uniformity_prod, lift_lift'_same_eq_lift']\n  · intro s\n    exact monotone_const.set_prod monotone_preimage\n  · intro t\n    exact monotone_preimage.set_prod monotone_const\n#align nhds_eq_uniformity_prod nhds_eq_uniformity_prod\n\n/- warning: nhdset_of_mem_uniformity -> nhdset_of_mem_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {d : Set.{u1} (Prod.{u1, u1} α α)} (s : Set.{u1} (Prod.{u1, u1} α α)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) d (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (And (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) s t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) t (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => Exists.{succ u1} α (fun (x : α) => Exists.{succ u1} α (fun (y : α) => And (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α (Prod.fst.{u1, u1} α α p) x) d) (And (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) s) (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α y (Prod.snd.{u1, u1} α α p)) d))))))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {d : Set.{u1} (Prod.{u1, u1} α α)} (s : Set.{u1} (Prod.{u1, u1} α α)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) d (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (And (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) s t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) t (setOf.{u1} (Prod.{u1, u1} α α) (fun (p : Prod.{u1, u1} α α) => Exists.{succ u1} α (fun (x : α) => Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α (Prod.fst.{u1, u1} α α p) x) d) (And (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) s) (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α y (Prod.snd.{u1, u1} α α p)) d))))))))))\nCase conversion may be inaccurate. Consider using '#align nhdset_of_mem_uniformity nhdset_of_mem_uniformityₓ'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » cl_d) -/\ntheorem nhdset_of_mem_uniformity {d : Set (α × α)} (s : Set (α × α)) (hd : d ∈ 𝓤 α) :\n    ∃ t : Set (α × α),\n      IsOpen t ∧ s ⊆ t ∧ t ⊆ { p | ∃ x y, (p.1, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.2) ∈ d } :=\n  let cl_d := { p : α × α | ∃ x y, (p.1, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.2) ∈ d }\n  have : ∀ p ∈ s, ∃ (t : _)(_ : t ⊆ cl_d), IsOpen t ∧ p ∈ t := fun ⟨x, y⟩ hp =>\n    mem_nhds_iff.mp <|\n      show cl_d ∈ 𝓝 (x, y) by\n        rw [nhds_eq_uniformity_prod, mem_lift'_sets]\n        exact ⟨d, hd, fun ⟨a, b⟩ ⟨ha, hb⟩ => ⟨x, y, ha, hp, hb⟩⟩\n        exact monotone_preimage.set_prod monotone_preimage\n  have :\n    ∃ t : ∀ (p : α × α) (h : p ∈ s), Set (α × α),\n      ∀ p, ∀ h : p ∈ s, t p h ⊆ cl_d ∧ IsOpen (t p h) ∧ p ∈ t p h :=\n    by simp [Classical.skolem] at this <;> simp <;> assumption\n  match this with\n  | ⟨t, ht⟩ =>\n    ⟨(⋃ p : α × α, ⋃ h : p ∈ s, t p h : Set (α × α)),\n      isOpen_unionᵢ fun p : α × α => isOpen_unionᵢ fun hp => (ht p hp).right.left, fun ⟨a, b⟩ hp =>\n      by simp <;> exact ⟨a, b, hp, (ht (a, b) hp).right.right⟩,\n      unionᵢ_subset fun p => unionᵢ_subset fun hp => (ht p hp).left⟩\n#align nhdset_of_mem_uniformity nhdset_of_mem_uniformity\n\n/- warning: nhds_le_uniformity -> nhds_le_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (x : α), LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (nhds.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α x x)) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (x : α), LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (nhds.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α x x)) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align nhds_le_uniformity nhds_le_uniformityₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem nhds_le_uniformity (x : α) : 𝓝 (x, x) ≤ 𝓤 α :=\n  by\n  intro V V_in\n  rcases comp_symm_mem_uniformity_sets V_in with ⟨w, w_in, w_symm, w_sub⟩\n  have : ball x w ×ˢ ball x w ∈ 𝓝 (x, x) :=\n    by\n    rw [nhds_prod_eq]\n    exact prod_mem_prod (ball_mem_nhds x w_in) (ball_mem_nhds x w_in)\n  apply mem_of_superset this\n  rintro ⟨u, v⟩ ⟨u_in, v_in⟩\n  exact w_sub (mem_comp_of_mem_ball w_symm u_in v_in)\n#align nhds_le_uniformity nhds_le_uniformity\n\n/- warning: supr_nhds_le_uniformity -> supᵢ_nhds_le_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (supᵢ.{u1, succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (ConditionallyCompleteLattice.toHasSup.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.completeLattice.{u1} (Prod.{u1, u1} α α)))) α (fun (x : α) => nhds.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α x x))) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (supᵢ.{u1, succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (ConditionallyCompleteLattice.toSupSet.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instCompleteLatticeFilter.{u1} (Prod.{u1, u1} α α)))) α (fun (x : α) => nhds.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Prod.mk.{u1, u1} α α x x))) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align supr_nhds_le_uniformity supᵢ_nhds_le_uniformityₓ'. -/\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem supᵢ_nhds_le_uniformity : (⨆ x : α, 𝓝 (x, x)) ≤ 𝓤 α :=\n  supᵢ_le nhds_le_uniformity\n#align supr_nhds_le_uniformity supᵢ_nhds_le_uniformity\n\n/- warning: nhds_set_diagonal_le_uniformity -> nhdsSet_diagonal_le_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.partialOrder.{u1} (Prod.{u1, u1} α α)))) (nhdsSet.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Set.diagonal.{u1} α)) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} α α)))) (nhdsSet.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (Set.diagonal.{u1} α)) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align nhds_set_diagonal_le_uniformity nhdsSet_diagonal_le_uniformityₓ'. -/\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem nhdsSet_diagonal_le_uniformity : 𝓝ˢ (diagonal α) ≤ 𝓤 α :=\n  (nhdsSet_diagonal α).trans_le supᵢ_nhds_le_uniformity\n#align nhds_set_diagonal_le_uniformity nhdsSet_diagonal_le_uniformity\n\n/-!\n### Closure and interior in uniform spaces\n-/\n\n\n/- warning: closure_eq_uniformity -> closure_eq_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (s : Set.{u1} (Prod.{u1, u1} α α)), Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (closure.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) s) (Set.interᵢ.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Set.interᵢ.{u1, 0} (Prod.{u1, u1} α α) (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} α α))) (Set.hasMem.{u1} (Set.{u1} (Prod.{u1, u1} α α))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (SymmetricRel.{u1} α V)))) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} α α))) (Set.hasMem.{u1} (Set.{u1} (Prod.{u1, u1} α α))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (SymmetricRel.{u1} α V)))) => compRel.{u1} α (compRel.{u1} α V s) V)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] (s : Set.{u1} (Prod.{u1, u1} α α)), Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (closure.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) s) (Set.interᵢ.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Set.interᵢ.{u1, 0} (Prod.{u1, u1} α α) (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} α α))) (Set.instMembershipSet.{u1} (Set.{u1} (Prod.{u1, u1} α α))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (SymmetricRel.{u1} α V)))) (fun (H : Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} α α))) (Set.instMembershipSet.{u1} (Set.{u1} (Prod.{u1, u1} α α))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (SymmetricRel.{u1} α V)))) => compRel.{u1} α (compRel.{u1} α V s) V)))\nCase conversion may be inaccurate. Consider using '#align closure_eq_uniformity closure_eq_uniformityₓ'. -/\ntheorem closure_eq_uniformity (s : Set <| α × α) :\n    closure s = ⋂ V ∈ { V | V ∈ 𝓤 α ∧ SymmetricRel V }, V ○ s ○ V :=\n  by\n  ext ⟨x, y⟩\n  simp (config :=\n    { contextual := true }) only [mem_closure_iff_nhds_basis (UniformSpace.hasBasis_nhds_prod x y),\n    mem_Inter, mem_set_of_eq, and_imp, mem_comp_comp, exists_prop, ← mem_inter_iff, inter_comm,\n    Set.Nonempty]\n#align closure_eq_uniformity closure_eq_uniformity\n\n/- warning: uniformity_has_basis_closed -> uniformity_hasBasis_closed is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (IsClosed.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (IsClosed.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_closed uniformity_hasBasis_closedₓ'. -/\ntheorem uniformity_hasBasis_closed :\n    HasBasis (𝓤 α) (fun V : Set (α × α) => V ∈ 𝓤 α ∧ IsClosed V) id :=\n  by\n  refine' Filter.hasBasis_self.2 fun t h => _\n  rcases comp_comp_symm_mem_uniformity_sets h with ⟨w, w_in, w_symm, r⟩\n  refine' ⟨closure w, mem_of_superset w_in subset_closure, isClosed_closure, _⟩\n  refine' subset.trans _ r\n  rw [closure_eq_uniformity]\n  apply Inter_subset_of_subset\n  apply Inter_subset\n  exact ⟨w_in, w_symm⟩\n#align uniformity_has_basis_closed uniformity_hasBasis_closed\n\n#print uniformity_eq_uniformity_closure /-\ntheorem uniformity_eq_uniformity_closure : 𝓤 α = (𝓤 α).lift' closure :=\n  Eq.symm <| uniformity_hasBasis_closed.lift'_closure_eq_self fun _ => And.right\n#align uniformity_eq_uniformity_closure uniformity_eq_uniformity_closure\n-/\n\n/- warning: filter.has_basis.uniformity_closure -> Filter.HasBasis.uniformity_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : ι -> Prop} {U : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p (fun (i : ι) => closure.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) (U i)))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u2} α] {p : ι -> Prop} {U : ι -> (Set.{u2} (Prod.{u2, u2} α α))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} α α) ι (uniformity.{u2} α _inst_1) p U) -> (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} α α) ι (uniformity.{u2} α _inst_1) p (fun (i : ι) => closure.{u2} (Prod.{u2, u2} α α) (instTopologicalSpaceProd.{u2, u2} α α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} α _inst_1)) (U i)))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniformity_closure Filter.HasBasis.uniformity_closureₓ'. -/\ntheorem Filter.HasBasis.uniformity_closure {p : ι → Prop} {U : ι → Set (α × α)}\n    (h : (𝓤 α).HasBasis p U) : (𝓤 α).HasBasis p fun i => closure (U i) :=\n  (@uniformity_eq_uniformity_closure α _).symm ▸ h.lift'_closure\n#align filter.has_basis.uniformity_closure Filter.HasBasis.uniformity_closure\n\n/- warning: uniformity_has_basis_closure -> uniformity_hasBasis_closure is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (closure.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (closure.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_closure uniformity_hasBasis_closureₓ'. -/\n/-- Closed entourages form a basis of the uniformity filter. -/\ntheorem uniformity_hasBasis_closure : HasBasis (𝓤 α) (fun V : Set (α × α) => V ∈ 𝓤 α) closure :=\n  (𝓤 α).basis_sets.uniformity_closure\n#align uniformity_has_basis_closure uniformity_hasBasis_closure\n\n/- warning: closure_eq_inter_uniformity -> closure_eq_inter_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {t : Set.{u1} (Prod.{u1, u1} α α)}, Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (closure.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (Set.interᵢ.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (fun (d : Set.{u1} (Prod.{u1, u1} α α)) => Set.interᵢ.{u1, 0} (Prod.{u1, u1} α α) (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) d (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) d (uniformity.{u1} α _inst_1)) => compRel.{u1} α d (compRel.{u1} α t d))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {t : Set.{u1} (Prod.{u1, u1} α α)}, Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (closure.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (Set.interᵢ.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (fun (d : Set.{u1} (Prod.{u1, u1} α α)) => Set.interᵢ.{u1, 0} (Prod.{u1, u1} α α) (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) d (uniformity.{u1} α _inst_1)) (fun (H : Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) d (uniformity.{u1} α _inst_1)) => compRel.{u1} α d (compRel.{u1} α t d))))\nCase conversion may be inaccurate. Consider using '#align closure_eq_inter_uniformity closure_eq_inter_uniformityₓ'. -/\ntheorem closure_eq_inter_uniformity {t : Set (α × α)} : closure t = ⋂ d ∈ 𝓤 α, d ○ (t ○ d) :=\n  calc\n    closure t = ⋂ (V) (hV : V ∈ 𝓤 α ∧ SymmetricRel V), V ○ t ○ V := closure_eq_uniformity t\n    _ = ⋂ V ∈ 𝓤 α, V ○ t ○ V :=\n      (Eq.symm <|\n        UniformSpace.hasBasis_symmetric.binterᵢ_mem fun V₁ V₂ hV =>\n          compRel_mono (compRel_mono hV Subset.rfl) hV)\n    _ = ⋂ V ∈ 𝓤 α, V ○ (t ○ V) := by simp only [compRel_assoc]\n    \n#align closure_eq_inter_uniformity closure_eq_inter_uniformity\n\n#print uniformity_eq_uniformity_interior /-\ntheorem uniformity_eq_uniformity_interior : 𝓤 α = (𝓤 α).lift' interior :=\n  le_antisymm\n    (le_infᵢ fun d =>\n      le_infᵢ fun hd =>\n        by\n        let ⟨s, hs, hs_comp⟩ :=\n          (mem_lift'_sets <| monotone_id.compRel <| monotone_id.compRel monotone_id).mp\n            (comp_le_uniformity3 hd)\n        let ⟨t, ht, hst, ht_comp⟩ := nhdset_of_mem_uniformity s hs\n        have : s ⊆ interior d :=\n          calc\n            s ⊆ t := hst\n            _ ⊆ interior d :=\n              ht.subset_interior_iff.mpr fun x (hx : x ∈ t) =>\n                let ⟨x, y, h₁, h₂, h₃⟩ := ht_comp hx\n                hs_comp ⟨x, h₁, y, h₂, h₃⟩\n            \n        have : interior d ∈ 𝓤 α := by filter_upwards [hs]using this\n        simp [this])\n    fun s hs => ((𝓤 α).lift' interior).sets_of_superset (mem_lift' hs) interior_subset\n#align uniformity_eq_uniformity_interior uniformity_eq_uniformity_interior\n-/\n\n/- warning: interior_mem_uniformity -> interior_mem_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) (interior.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) s) (uniformity.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) (interior.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) s) (uniformity.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align interior_mem_uniformity interior_mem_uniformityₓ'. -/\ntheorem interior_mem_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) : interior s ∈ 𝓤 α := by\n  rw [uniformity_eq_uniformity_interior] <;> exact mem_lift' hs\n#align interior_mem_uniformity interior_mem_uniformity\n\n/- warning: mem_uniformity_is_closed -> mem_uniformity_isClosed is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => And (IsClosed.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) t s))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (And (IsClosed.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) t s))))\nCase conversion may be inaccurate. Consider using '#align mem_uniformity_is_closed mem_uniformity_isClosedₓ'. -/\ntheorem mem_uniformity_isClosed {s : Set (α × α)} (h : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, IsClosed t ∧ t ⊆ s :=\n  let ⟨t, ⟨ht_mem, htc⟩, hts⟩ := uniformity_hasBasis_closed.mem_iff.1 h\n  ⟨t, ht_mem, htc, hts⟩\n#align mem_uniformity_is_closed mem_uniformity_isClosed\n\n/- warning: is_open_iff_open_ball_subset -> isOpen_iff_open_ball_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s) (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) => And (IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (UniformSpace.ball.{u1} α x V) s)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α}, Iff (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (UniformSpace.ball.{u1} α x V) s)))))\nCase conversion may be inaccurate. Consider using '#align is_open_iff_open_ball_subset isOpen_iff_open_ball_subsetₓ'. -/\ntheorem isOpen_iff_open_ball_subset {s : Set α} :\n    IsOpen s ↔ ∀ x ∈ s, ∃ V ∈ 𝓤 α, IsOpen V ∧ ball x V ⊆ s :=\n  by\n  rw [isOpen_iff_ball_subset]\n  constructor <;> intro h x hx\n  · obtain ⟨V, hV, hV'⟩ := h x hx\n    exact\n      ⟨interior V, interior_mem_uniformity hV, isOpen_interior,\n        (ball_mono interior_subset x).trans hV'⟩\n  · obtain ⟨V, hV, -, hV'⟩ := h x hx\n    exact ⟨V, hV, hV'⟩\n#align is_open_iff_open_ball_subset isOpen_iff_open_ball_subset\n\n#print Dense.bunionᵢ_uniformity_ball /-\n/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/\ntheorem Dense.bunionᵢ_uniformity_ball {s : Set α} {U : Set (α × α)} (hs : Dense s) (hU : U ∈ 𝓤 α) :\n    (⋃ x ∈ s, ball x U) = univ :=\n  by\n  refine' Union₂_eq_univ_iff.2 fun y => _\n  rcases hs.inter_nhds_nonempty (mem_nhds_right y hU) with ⟨x, hxs, hxy : (x, y) ∈ U⟩\n  exact ⟨x, hxs, hxy⟩\n#align dense.bUnion_uniformity_ball Dense.bunionᵢ_uniformity_ball\n-/\n\n/-!\n### Uniformity bases\n-/\n\n\n/- warning: uniformity_has_basis_open -> uniformity_hasBasis_open is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_open uniformity_hasBasis_openₓ'. -/\n/-- Open elements of `𝓤 α` form a basis of `𝓤 α`. -/\ntheorem uniformity_hasBasis_open : HasBasis (𝓤 α) (fun V : Set (α × α) => V ∈ 𝓤 α ∧ IsOpen V) id :=\n  hasBasis_self.2 fun s hs =>\n    ⟨interior s, interior_mem_uniformity hs, isOpen_interior, interior_subset⟩\n#align uniformity_has_basis_open uniformity_hasBasis_open\n\n/- warning: filter.has_basis.mem_uniformity_iff -> Filter.HasBasis.mem_uniformity_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : β -> Prop} {s : β -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) p s) -> (forall {t : Set.{u1} (Prod.{u1, u1} α α)}, Iff (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (Exists.{succ u2} β (fun (i : β) => Exists.{0} (p i) (fun (hi : p i) => forall (a : α) (b : α), (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) (s i)) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) t)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : β -> Prop} {s : β -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} α α) β (uniformity.{u1} α _inst_1) p s) -> (forall {t : Set.{u1} (Prod.{u1, u1} α α)}, Iff (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (Exists.{succ u2} β (fun (i : β) => And (p i) (forall (a : α) (b : α), (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) (s i)) -> (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) t)))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.mem_uniformity_iff Filter.HasBasis.mem_uniformity_iffₓ'. -/\ntheorem Filter.HasBasis.mem_uniformity_iff {p : β → Prop} {s : β → Set (α × α)}\n    (h : (𝓤 α).HasBasis p s) {t : Set (α × α)} :\n    t ∈ 𝓤 α ↔ ∃ (i : _)(hi : p i), ∀ a b, (a, b) ∈ s i → (a, b) ∈ t :=\n  h.mem_iff.trans <| by simp only [Prod.forall, subset_def]\n#align filter.has_basis.mem_uniformity_iff Filter.HasBasis.mem_uniformity_iff\n\n/- warning: uniformity_has_basis_open_symmetric -> uniformity_hasBasis_open_symmetric is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) (SymmetricRel.{u1} α V))) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) (SymmetricRel.{u1} α V))) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_open_symmetric uniformity_hasBasis_open_symmetricₓ'. -/\n/-- Open elements `s : set (α × α)` of `𝓤 α` such that `(x, y) ∈ s ↔ (y, x) ∈ s` form a basis\nof `𝓤 α`. -/\ntheorem uniformity_hasBasis_open_symmetric :\n    HasBasis (𝓤 α) (fun V : Set (α × α) => V ∈ 𝓤 α ∧ IsOpen V ∧ SymmetricRel V) id :=\n  by\n  simp only [← and_assoc']\n  refine' uniformity_has_basis_open.restrict fun s hs => ⟨symmetrizeRel s, _⟩\n  exact\n    ⟨⟨symmetrize_mem_uniformity hs.1, IsOpen.inter hs.2 (hs.2.Preimage continuous_swap)⟩,\n      symmetric_symmetrizeRel s, symmetrizeRel_subset_self s⟩\n#align uniformity_has_basis_open_symmetric uniformity_hasBasis_open_symmetric\n\n/- warning: comp_open_symm_mem_uniformity_sets -> comp_open_symm_mem_uniformity_sets is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) => And (IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (And (SymmetricRel.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasSubset.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) s (uniformity.{u1} α _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (t : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) t (uniformity.{u1} α _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) t) (And (SymmetricRel.{u1} α t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} α α)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} α α)) (compRel.{u1} α t t) s)))))\nCase conversion may be inaccurate. Consider using '#align comp_open_symm_mem_uniformity_sets comp_open_symm_mem_uniformity_setsₓ'. -/\ntheorem comp_open_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) :\n    ∃ t ∈ 𝓤 α, IsOpen t ∧ SymmetricRel t ∧ t ○ t ⊆ s :=\n  by\n  obtain ⟨t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs\n  obtain ⟨u, ⟨hu₁, hu₂, hu₃⟩, hu₄ : u ⊆ t⟩ := uniformity_has_basis_open_symmetric.mem_iff.mp ht₁\n  exact ⟨u, hu₁, hu₂, hu₃, (compRel_mono hu₄ hu₄).trans ht₂⟩\n#align comp_open_symm_mem_uniformity_sets comp_open_symm_mem_uniformity_sets\n\nsection\n\nvariable (α)\n\n#print UniformSpace.has_seq_basis /-\ntheorem UniformSpace.has_seq_basis [IsCountablyGenerated <| 𝓤 α] :\n    ∃ V : ℕ → Set (α × α), HasAntitoneBasis (𝓤 α) V ∧ ∀ n, SymmetricRel (V n) :=\n  let ⟨U, hsym, hbasis⟩ := UniformSpace.hasBasis_symmetric.exists_antitone_subbasis\n  ⟨U, hbasis, fun n => (hsym n).2⟩\n#align uniform_space.has_seq_basis UniformSpace.has_seq_basis\n-/\n\nend\n\n/- warning: filter.has_basis.bInter_bUnion_ball -> Filter.HasBasis.binterᵢ_bunionᵢ_ball is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} [_inst_1 : UniformSpace.{u1} α] {p : ι -> Prop} {U : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p U) -> (forall (s : Set.{u1} α), Eq.{succ u1} (Set.{u1} α) (Set.interᵢ.{u1, u2} α ι (fun (i : ι) => Set.interᵢ.{u1, 0} α (p i) (fun (hi : p i) => Set.unionᵢ.{u1, succ u1} α α (fun (x : α) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) (fun (H : Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) => UniformSpace.ball.{u1} α x (U i)))))) (closure.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u2} α] {p : ι -> Prop} {U : ι -> (Set.{u2} (Prod.{u2, u2} α α))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} α α) ι (uniformity.{u2} α _inst_1) p U) -> (forall (s : Set.{u2} α), Eq.{succ u2} (Set.{u2} α) (Set.interᵢ.{u2, u1} α ι (fun (i : ι) => Set.interᵢ.{u2, 0} α (p i) (fun (hi : p i) => Set.unionᵢ.{u2, succ u2} α α (fun (x : α) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x s) (fun (H : Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x s) => UniformSpace.ball.{u2} α x (U i)))))) (closure.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) s))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.bInter_bUnion_ball Filter.HasBasis.binterᵢ_bunionᵢ_ballₓ'. -/\ntheorem Filter.HasBasis.binterᵢ_bunionᵢ_ball {p : ι → Prop} {U : ι → Set (α × α)}\n    (h : HasBasis (𝓤 α) p U) (s : Set α) : (⋂ (i) (hi : p i), ⋃ x ∈ s, ball x (U i)) = closure s :=\n  by\n  ext x\n  simp [mem_closure_iff_nhds_basis (nhds_basis_uniformity h), ball]\n#align filter.has_basis.bInter_bUnion_ball Filter.HasBasis.binterᵢ_bunionᵢ_ball\n\n/-! ### Uniform continuity -/\n\n\n#print UniformContinuous /-\n/-- A function `f : α → β` is *uniformly continuous* if `(f x, f y)` tends to the diagonal\nas `(x, y)` tends to the diagonal. In other words, if `x` is sufficiently close to `y`, then\n`f x` is close to `f y` no matter where `x` and `y` are located in `α`. -/\ndef UniformContinuous [UniformSpace β] (f : α → β) :=\n  Tendsto (fun x : α × α => (f x.1, f x.2)) (𝓤 α) (𝓤 β)\n#align uniform_continuous UniformContinuous\n-/\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print UniformContinuousOn /-\n/-- A function `f : α → β` is *uniformly continuous* on `s : set α` if `(f x, f y)` tends to\nthe diagonal as `(x, y)` tends to the diagonal while remaining in `s ×ˢ s`.\nIn other words, if `x` is sufficiently close to `y`, then `f x` is close to\n`f y` no matter where `x` and `y` are located in `s`.-/\ndef UniformContinuousOn [UniformSpace β] (f : α → β) (s : Set α) : Prop :=\n  Tendsto (fun x : α × α => (f x.1, f x.2)) (𝓤 α ⊓ principal (s ×ˢ s)) (𝓤 β)\n#align uniform_continuous_on UniformContinuousOn\n-/\n\n#print uniformContinuous_def /-\ntheorem uniformContinuous_def [UniformSpace β] {f : α → β} :\n    UniformContinuous f ↔ ∀ r ∈ 𝓤 β, { x : α × α | (f x.1, f x.2) ∈ r } ∈ 𝓤 α :=\n  Iff.rfl\n#align uniform_continuous_def uniformContinuous_def\n-/\n\n#print uniformContinuous_iff_eventually /-\ntheorem uniformContinuous_iff_eventually [UniformSpace β] {f : α → β} :\n    UniformContinuous f ↔ ∀ r ∈ 𝓤 β, ∀ᶠ x : α × α in 𝓤 α, (f x.1, f x.2) ∈ r :=\n  Iff.rfl\n#align uniform_continuous_iff_eventually uniformContinuous_iff_eventually\n-/\n\n#print uniformContinuousOn_univ /-\ntheorem uniformContinuousOn_univ [UniformSpace β] {f : α → β} :\n    UniformContinuousOn f univ ↔ UniformContinuous f := by\n  rw [UniformContinuousOn, UniformContinuous, univ_prod_univ, principal_univ, inf_top_eq]\n#align uniform_continuous_on_univ uniformContinuousOn_univ\n-/\n\n#print uniformContinuous_of_const /-\ntheorem uniformContinuous_of_const [UniformSpace β] {c : α → β} (h : ∀ a b, c a = c b) :\n    UniformContinuous c :=\n  have : (fun x : α × α => (c x.fst, c x.snd)) ⁻¹' idRel = univ :=\n    eq_univ_iff_forall.2 fun ⟨a, b⟩ => h a b\n  le_trans (map_le_iff_le_comap.2 <| by simp [comap_principal, this, univ_mem]) refl_le_uniformity\n#align uniform_continuous_of_const uniformContinuous_of_const\n-/\n\n#print uniformContinuous_id /-\ntheorem uniformContinuous_id : UniformContinuous (@id α) := by\n  simp [UniformContinuous] <;> exact tendsto_id\n#align uniform_continuous_id uniformContinuous_id\n-/\n\n#print uniformContinuous_const /-\ntheorem uniformContinuous_const [UniformSpace β] {b : β} : UniformContinuous fun a : α => b :=\n  uniformContinuous_of_const fun _ _ => rfl\n#align uniform_continuous_const uniformContinuous_const\n-/\n\n#print UniformContinuous.comp /-\ntheorem UniformContinuous.comp [UniformSpace β] [UniformSpace γ] {g : β → γ} {f : α → β}\n    (hg : UniformContinuous g) (hf : UniformContinuous f) : UniformContinuous (g ∘ f) :=\n  hg.comp hf\n#align uniform_continuous.comp UniformContinuous.comp\n-/\n\n/- warning: filter.has_basis.uniform_continuous_iff -> Filter.HasBasis.uniformContinuous_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {ι : Sort.{u3}} [_inst_1 : UniformSpace.{u1} α] {ι' : Sort.{u4}} [_inst_2 : UniformSpace.{u2} β] {p : ι -> Prop} {s : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u3} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p s) -> (forall {q : ι' -> Prop} {t : ι' -> (Set.{u2} (Prod.{u2, u2} β β))}, (Filter.HasBasis.{u2, u4} (Prod.{u2, u2} β β) ι' (uniformity.{u2} β _inst_2) q t) -> (forall {f : α -> β}, Iff (UniformContinuous.{u1, u2} α β _inst_1 _inst_2 f) (forall (i : ι'), (q i) -> (Exists.{u3} ι (fun (j : ι) => Exists.{0} (p j) (fun (hj : p j) => forall (x : α) (y : α), (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) (s j)) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} β β) (Set.{u2} (Prod.{u2, u2} β β)) (Set.hasMem.{u2} (Prod.{u2, u2} β β)) (Prod.mk.{u2, u2} β β (f x) (f y)) (t i))))))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u4}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u3} α] {ι' : Sort.{u2}} [_inst_2 : UniformSpace.{u4} β] {p : ι -> Prop} {s : ι -> (Set.{u3} (Prod.{u3, u3} α α))}, (Filter.HasBasis.{u3, u1} (Prod.{u3, u3} α α) ι (uniformity.{u3} α _inst_1) p s) -> (forall {q : ι' -> Prop} {t : ι' -> (Set.{u4} (Prod.{u4, u4} β β))}, (Filter.HasBasis.{u4, u2} (Prod.{u4, u4} β β) ι' (uniformity.{u4} β _inst_2) q t) -> (forall {f : α -> β}, Iff (UniformContinuous.{u3, u4} α β _inst_1 _inst_2 f) (forall (i : ι'), (q i) -> (Exists.{u1} ι (fun (j : ι) => And (p j) (forall (x : α) (y : α), (Membership.mem.{u3, u3} (Prod.{u3, u3} α α) (Set.{u3} (Prod.{u3, u3} α α)) (Set.instMembershipSet.{u3} (Prod.{u3, u3} α α)) (Prod.mk.{u3, u3} α α x y) (s j)) -> (Membership.mem.{u4, u4} (Prod.{u4, u4} β β) (Set.{u4} (Prod.{u4, u4} β β)) (Set.instMembershipSet.{u4} (Prod.{u4, u4} β β)) (Prod.mk.{u4, u4} β β (f x) (f y)) (t i))))))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniform_continuous_iff Filter.HasBasis.uniformContinuous_iffₓ'. -/\ntheorem Filter.HasBasis.uniformContinuous_iff {ι'} [UniformSpace β] {p : ι → Prop}\n    {s : ι → Set (α × α)} (ha : (𝓤 α).HasBasis p s) {q : ι' → Prop} {t : ι' → Set (β × β)}\n    (hb : (𝓤 β).HasBasis q t) {f : α → β} :\n    UniformContinuous f ↔\n      ∀ (i) (hi : q i), ∃ (j : _)(hj : p j), ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ t i :=\n  (ha.tendsto_iffₓ hb).trans <| by simp only [Prod.forall]\n#align filter.has_basis.uniform_continuous_iff Filter.HasBasis.uniformContinuous_iff\n\n/- warning: filter.has_basis.uniform_continuous_on_iff -> Filter.HasBasis.uniformContinuousOn_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {ι : Sort.{u3}} [_inst_1 : UniformSpace.{u1} α] {ι' : Sort.{u4}} [_inst_2 : UniformSpace.{u2} β] {p : ι -> Prop} {s : ι -> (Set.{u1} (Prod.{u1, u1} α α))}, (Filter.HasBasis.{u1, u3} (Prod.{u1, u1} α α) ι (uniformity.{u1} α _inst_1) p s) -> (forall {q : ι' -> Prop} {t : ι' -> (Set.{u2} (Prod.{u2, u2} β β))}, (Filter.HasBasis.{u2, u4} (Prod.{u2, u2} β β) ι' (uniformity.{u2} β _inst_2) q t) -> (forall {f : α -> β} {S : Set.{u1} α}, Iff (UniformContinuousOn.{u1, u2} α β _inst_1 _inst_2 f S) (forall (i : ι'), (q i) -> (Exists.{u3} ι (fun (j : ι) => Exists.{0} (p j) (fun (hj : p j) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x S) -> (forall (y : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y S) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) (s j)) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} β β) (Set.{u2} (Prod.{u2, u2} β β)) (Set.hasMem.{u2} (Prod.{u2, u2} β β)) (Prod.mk.{u2, u2} β β (f x) (f y)) (t i)))))))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u4}} {ι : Sort.{u1}} [_inst_1 : UniformSpace.{u3} α] {ι' : Sort.{u2}} [_inst_2 : UniformSpace.{u4} β] {p : ι -> Prop} {s : ι -> (Set.{u3} (Prod.{u3, u3} α α))}, (Filter.HasBasis.{u3, u1} (Prod.{u3, u3} α α) ι (uniformity.{u3} α _inst_1) p s) -> (forall {q : ι' -> Prop} {t : ι' -> (Set.{u4} (Prod.{u4, u4} β β))}, (Filter.HasBasis.{u4, u2} (Prod.{u4, u4} β β) ι' (uniformity.{u4} β _inst_2) q t) -> (forall {f : α -> β} {S : Set.{u3} α}, Iff (UniformContinuousOn.{u3, u4} α β _inst_1 _inst_2 f S) (forall (i : ι'), (q i) -> (Exists.{u1} ι (fun (j : ι) => And (p j) (forall (x : α), (Membership.mem.{u3, u3} α (Set.{u3} α) (Set.instMembershipSet.{u3} α) x S) -> (forall (y : α), (Membership.mem.{u3, u3} α (Set.{u3} α) (Set.instMembershipSet.{u3} α) y S) -> (Membership.mem.{u3, u3} (Prod.{u3, u3} α α) (Set.{u3} (Prod.{u3, u3} α α)) (Set.instMembershipSet.{u3} (Prod.{u3, u3} α α)) (Prod.mk.{u3, u3} α α x y) (s j)) -> (Membership.mem.{u4, u4} (Prod.{u4, u4} β β) (Set.{u4} (Prod.{u4, u4} β β)) (Set.instMembershipSet.{u4} (Prod.{u4, u4} β β)) (Prod.mk.{u4, u4} β β (f x) (f y)) (t i)))))))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniform_continuous_on_iff Filter.HasBasis.uniformContinuousOn_iffₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x y «expr ∈ » S) -/\ntheorem Filter.HasBasis.uniformContinuousOn_iff {ι'} [UniformSpace β] {p : ι → Prop}\n    {s : ι → Set (α × α)} (ha : (𝓤 α).HasBasis p s) {q : ι' → Prop} {t : ι' → Set (β × β)}\n    (hb : (𝓤 β).HasBasis q t) {f : α → β} {S : Set α} :\n    UniformContinuousOn f S ↔\n      ∀ (i) (hi : q i),\n        ∃ (j : _)(hj : p j), ∀ (x) (_ : x ∈ S) (y) (_ : y ∈ S), (x, y) ∈ s j → (f x, f y) ∈ t i :=\n  ((ha.inf_principal (S ×ˢ S)).tendsto_iffₓ hb).trans <| by\n    simp_rw [Prod.forall, Set.inter_comm (s _), ball_mem_comm, mem_inter_iff, mem_prod, and_imp]\n#align filter.has_basis.uniform_continuous_on_iff Filter.HasBasis.uniformContinuousOn_iff\n\nend UniformSpace\n\nopen uniformity\n\nsection Constructions\n\ninstance : PartialOrder (UniformSpace α)\n    where\n  le t s := t.uniformity ≤ s.uniformity\n  le_antisymm t s h₁ h₂ := uniformSpace_eq <| le_antisymm h₁ h₂\n  le_refl t := le_rfl\n  le_trans a b c h₁ h₂ := le_trans h₁ h₂\n\ninstance : InfSet (UniformSpace α) :=\n  ⟨fun s =>\n    UniformSpace.ofCore\n      { uniformity := ⨅ u ∈ s, 𝓤[u]\n        refl := le_infᵢ fun u => le_infᵢ fun hu => u.refl\n        symm :=\n          le_infᵢ fun u =>\n            le_infᵢ fun hu => le_trans (map_mono <| infᵢ_le_of_le _ <| infᵢ_le _ hu) u.symm\n        comp :=\n          le_infᵢ fun u =>\n            le_infᵢ fun hu =>\n              le_trans (lift'_mono (infᵢ_le_of_le _ <| infᵢ_le _ hu) <| le_rfl) u.comp }⟩\n\n/- warning: Inf_le -> infₛ_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} α] {s : Set.{u1} α} {a : α}, (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) a s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α _inst_1))) (InfSet.infₛ.{u1} α (CompleteSemilatticeInf.toHasInf.{u1} α _inst_1) s) a)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} α] {s : Set.{u1} α} {a : α}, (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) a s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α _inst_1))) (InfSet.infₛ.{u1} α (CompleteSemilatticeInf.toInfSet.{u1} α _inst_1) s) a)\nCase conversion may be inaccurate. Consider using '#align Inf_le infₛ_leₓ'. -/\nprivate theorem infₛ_le {tt : Set (UniformSpace α)} {t : UniformSpace α} (h : t ∈ tt) :\n    infₛ tt ≤ t :=\n  show (⨅ u ∈ tt, 𝓤[u]) ≤ 𝓤[t] from infᵢ₂_le t h\n#align Inf_le infₛ_le\n\n/- warning: le_Inf -> le_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} α] {s : Set.{u1} α} {a : α}, (forall (b : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) b s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α _inst_1))) a b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α _inst_1))) a (InfSet.infₛ.{u1} α (CompleteSemilatticeInf.toHasInf.{u1} α _inst_1) s))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} α] {s : Set.{u1} α} {a : α}, (forall (b : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) b s) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α _inst_1))) a b)) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α _inst_1))) a (InfSet.infₛ.{u1} α (CompleteSemilatticeInf.toInfSet.{u1} α _inst_1) s))\nCase conversion may be inaccurate. Consider using '#align le_Inf le_infₛₓ'. -/\nprivate theorem le_infₛ {tt : Set (UniformSpace α)} {t : UniformSpace α} (h : ∀ t' ∈ tt, t ≤ t') :\n    t ≤ infₛ tt :=\n  show 𝓤[t] ≤ ⨅ u ∈ tt, 𝓤[u] from le_infᵢ₂ h\n#align le_Inf le_infₛ\n\ninstance : Top (UniformSpace α) :=\n  ⟨UniformSpace.ofCore\n      { uniformity := ⊤\n        refl := le_top\n        symm := le_top\n        comp := le_top }⟩\n\ninstance : Bot (UniformSpace α) :=\n  ⟨{  toTopologicalSpace := ⊥\n      uniformity := 𝓟 idRel\n      refl := le_rfl\n      symm := by simp [tendsto]\n      comp := lift'_le (mem_principal_self _) <| principal_mono.2 id_compRel.Subset\n      isOpen_uniformity := fun s => by\n        simp (config := { contextual := true }) [isOpen_fold, subset_def, idRel] }⟩\n\ninstance : Inf (UniformSpace α) :=\n  ⟨fun u₁ u₂ =>\n    @UniformSpace.replaceTopology _ (u₁.toTopologicalSpace ⊓ u₂.toTopologicalSpace)\n        (UniformSpace.ofCore\n          { uniformity := u₁.uniformity ⊓ u₂.uniformity\n            refl := le_inf u₁.refl u₂.refl\n            symm := u₁.symm.inf u₂.symm\n            comp := (lift'_inf_le _ _ _).trans <| inf_le_inf u₁.comp u₂.comp }) <|\n      eq_of_nhds_eq_nhds fun a => by\n        simpa only [nhds_inf, nhds_eq_comap_uniformity] using comap_inf.symm⟩\n\ninstance : CompleteLattice (UniformSpace α) :=\n  {\n    UniformSpace.partialOrder with\n    sup := fun a b => infₛ { x | a ≤ x ∧ b ≤ x }\n    le_sup_left := fun a b => le_infₛ fun _ ⟨h, _⟩ => h\n    le_sup_right := fun a b => le_infₛ fun _ ⟨_, h⟩ => h\n    sup_le := fun a b c h₁ h₂ => infₛ_le ⟨h₁, h₂⟩\n    inf := (· ⊓ ·)\n    le_inf := fun a b c h₁ h₂ => show a.uniformity ≤ _ from le_inf h₁ h₂\n    inf_le_left := fun a b => show _ ≤ a.uniformity from inf_le_left\n    inf_le_right := fun a b => show _ ≤ b.uniformity from inf_le_right\n    top := ⊤\n    le_top := fun a => show a.uniformity ≤ ⊤ from le_top\n    bot := ⊥\n    bot_le := fun u => u.refl\n    supₛ := fun tt => infₛ { t | ∀ t' ∈ tt, t' ≤ t }\n    le_sup := fun s u h => le_infₛ fun u' h' => h' u h\n    sup_le := fun s u h => infₛ_le h\n    infₛ := infₛ\n    le_inf := fun s a hs => le_infₛ hs\n    inf_le := fun s a ha => infₛ_le ha }\n\n/- warning: infi_uniformity -> infᵢ_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} {u : ι -> (UniformSpace.{u1} α)}, Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} α α)) (uniformity.{u1} α (infᵢ.{u1, u2} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) ι u)) (infᵢ.{u1, u2} (Filter.{u1} (Prod.{u1, u1} α α)) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.completeLattice.{u1} (Prod.{u1, u1} α α)))) ι (fun (i : ι) => uniformity.{u1} α (u i)))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} {u : ι -> (UniformSpace.{u2} α)}, Eq.{succ u2} (Filter.{u2} (Prod.{u2, u2} α α)) (uniformity.{u2} α (infᵢ.{u2, u1} (UniformSpace.{u2} α) (instInfSetUniformSpace.{u2} α) ι u)) (infᵢ.{u2, u1} (Filter.{u2} (Prod.{u2, u2} α α)) (ConditionallyCompleteLattice.toInfSet.{u2} (Filter.{u2} (Prod.{u2, u2} α α)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Filter.{u2} (Prod.{u2, u2} α α)) (Filter.instCompleteLatticeFilter.{u2} (Prod.{u2, u2} α α)))) ι (fun (i : ι) => uniformity.{u2} α (u i)))\nCase conversion may be inaccurate. Consider using '#align infi_uniformity infᵢ_uniformityₓ'. -/\ntheorem infᵢ_uniformity {ι : Sort _} {u : ι → UniformSpace α} : 𝓤[infᵢ u] = ⨅ i, 𝓤[u i] :=\n  infᵢ_range\n#align infi_uniformity infᵢ_uniformity\n\n#print inf_uniformity /-\ntheorem inf_uniformity {u v : UniformSpace α} : 𝓤[u ⊓ v] = 𝓤[u] ⊓ 𝓤[v] :=\n  rfl\n#align inf_uniformity inf_uniformity\n-/\n\n#print inhabitedUniformSpace /-\ninstance inhabitedUniformSpace : Inhabited (UniformSpace α) :=\n  ⟨⊥⟩\n#align inhabited_uniform_space inhabitedUniformSpace\n-/\n\n#print inhabitedUniformSpaceCore /-\ninstance inhabitedUniformSpaceCore : Inhabited (UniformSpace.Core α) :=\n  ⟨@UniformSpace.toCore _ default⟩\n#align inhabited_uniform_space_core inhabitedUniformSpaceCore\n-/\n\n#print UniformSpace.comap /-\n/-- Given `f : α → β` and a uniformity `u` on `β`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `α × α → β × β`. -/\ndef UniformSpace.comap (f : α → β) (u : UniformSpace β) : UniformSpace α\n    where\n  uniformity := 𝓤[u].comap fun p : α × α => (f p.1, f p.2)\n  toTopologicalSpace := u.toTopologicalSpace.induced f\n  refl := le_trans (by simp <;> exact fun ⟨a, b⟩ (h : a = b) => h ▸ rfl) (comap_mono u.refl)\n  symm := by\n    simp [tendsto_comap_iff, Prod.swap, (· ∘ ·)] <;>\n      exact tendsto_swap_uniformity.comp tendsto_comap\n  comp :=\n    le_trans\n      (by\n        rw [comap_lift'_eq, comap_lift'_eq2]\n        exact lift'_mono' fun s hs ⟨a₁, a₂⟩ ⟨x, h₁, h₂⟩ => ⟨f x, h₁, h₂⟩\n        exact monotone_id.comp_rel monotone_id)\n      (comap_mono u.comp)\n  isOpen_uniformity s := by\n    simp only [isOpen_fold, isOpen_induced, isOpen_iff_mem_nhds, nhds_induced,\n      nhds_eq_comap_uniformity, comap_comap, ← mem_comap_prod_mk, ← uniformity]\n#align uniform_space.comap UniformSpace.comap\n-/\n\n#print uniformity_comap /-\ntheorem uniformity_comap [UniformSpace β] (f : α → β) :\n    𝓤[UniformSpace.comap f ‹_›] = comap (Prod.map f f) (𝓤 β) :=\n  rfl\n#align uniformity_comap uniformity_comap\n-/\n\n#print uniformSpace_comap_id /-\n@[simp]\ntheorem uniformSpace_comap_id {α : Type _} : UniformSpace.comap (id : α → α) = id :=\n  by\n  ext : 2\n  rw [uniformity_comap, Prod.map_id, comap_id]\n#align uniform_space_comap_id uniformSpace_comap_id\n-/\n\n/- warning: uniform_space.comap_comap -> UniformSpace.comap_comap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [uγ : UniformSpace.{u3} γ] {f : α -> β} {g : β -> γ}, Eq.{succ u1} (UniformSpace.{u1} α) (UniformSpace.comap.{u1, u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ g f) uγ) (UniformSpace.comap.{u1, u2} α β f (UniformSpace.comap.{u2, u3} β γ g uγ))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} {uγ : UniformSpace.{u1} γ} {f : α -> β} {g : β -> γ}, Eq.{succ u3} (UniformSpace.{u3} α) (UniformSpace.comap.{u3, u1} α γ (Function.comp.{succ u3, succ u2, succ u1} α β γ g f) uγ) (UniformSpace.comap.{u3, u2} α β f (UniformSpace.comap.{u2, u1} β γ g uγ))\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_comap UniformSpace.comap_comapₓ'. -/\ntheorem UniformSpace.comap_comap {α β γ} [uγ : UniformSpace γ] {f : α → β} {g : β → γ} :\n    UniformSpace.comap (g ∘ f) uγ = UniformSpace.comap f (UniformSpace.comap g uγ) :=\n  by\n  ext1\n  simp only [uniformity_comap, comap_comap, Prod.map_comp_map]\n#align uniform_space.comap_comap UniformSpace.comap_comap\n\n/- warning: uniform_space.comap_inf -> UniformSpace.comap_inf is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {γ : Type.{u2}} {u₁ : UniformSpace.{u2} γ} {u₂ : UniformSpace.{u2} γ} {f : α -> γ}, Eq.{succ u1} (UniformSpace.{u1} α) (UniformSpace.comap.{u1, u2} α γ f (Inf.inf.{u2} (UniformSpace.{u2} γ) (UniformSpace.hasInf.{u2} γ) u₁ u₂)) (Inf.inf.{u1} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) (UniformSpace.comap.{u1, u2} α γ f u₁) (UniformSpace.comap.{u1, u2} α γ f u₂))\nbut is expected to have type\n  forall {α : Type.{u2}} {γ : Type.{u1}} {u₁ : UniformSpace.{u1} γ} {u₂ : UniformSpace.{u1} γ} {f : α -> γ}, Eq.{succ u2} (UniformSpace.{u2} α) (UniformSpace.comap.{u2, u1} α γ f (Inf.inf.{u1} (UniformSpace.{u1} γ) (instInfUniformSpace.{u1} γ) u₁ u₂)) (Inf.inf.{u2} (UniformSpace.{u2} α) (instInfUniformSpace.{u2} α) (UniformSpace.comap.{u2, u1} α γ f u₁) (UniformSpace.comap.{u2, u1} α γ f u₂))\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_inf UniformSpace.comap_infₓ'. -/\ntheorem UniformSpace.comap_inf {α γ} {u₁ u₂ : UniformSpace γ} {f : α → γ} :\n    (u₁ ⊓ u₂).comap f = u₁.comap f ⊓ u₂.comap f :=\n  uniformSpace_eq comap_inf\n#align uniform_space.comap_inf UniformSpace.comap_inf\n\n/- warning: uniform_space.comap_infi -> UniformSpace.comap_infᵢ is a dubious translation:\nlean 3 declaration is\n  forall {ι : Sort.{u1}} {α : Type.{u2}} {γ : Type.{u3}} {u : ι -> (UniformSpace.{u3} γ)} {f : α -> γ}, Eq.{succ u2} (UniformSpace.{u2} α) (UniformSpace.comap.{u2, u3} α γ f (infᵢ.{u3, u1} (UniformSpace.{u3} γ) (UniformSpace.hasInf.{u3} γ) ι (fun (i : ι) => u i))) (infᵢ.{u2, u1} (UniformSpace.{u2} α) (UniformSpace.hasInf.{u2} α) ι (fun (i : ι) => UniformSpace.comap.{u2, u3} α γ f (u i)))\nbut is expected to have type\n  forall {ι : Sort.{u3}} {α : Type.{u2}} {γ : Type.{u1}} {u : ι -> (UniformSpace.{u1} γ)} {f : α -> γ}, Eq.{succ u2} (UniformSpace.{u2} α) (UniformSpace.comap.{u2, u1} α γ f (infᵢ.{u1, u3} (UniformSpace.{u1} γ) (instInfSetUniformSpace.{u1} γ) ι (fun (i : ι) => u i))) (infᵢ.{u2, u3} (UniformSpace.{u2} α) (instInfSetUniformSpace.{u2} α) ι (fun (i : ι) => UniformSpace.comap.{u2, u1} α γ f (u i)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_infi UniformSpace.comap_infᵢₓ'. -/\ntheorem UniformSpace.comap_infᵢ {ι α γ} {u : ι → UniformSpace γ} {f : α → γ} :\n    (⨅ i, u i).comap f = ⨅ i, (u i).comap f :=\n  by\n  ext : 1\n  simp [uniformity_comap, infᵢ_uniformity]\n#align uniform_space.comap_infi UniformSpace.comap_infᵢ\n\n/- warning: uniform_space.comap_mono -> UniformSpace.comap_mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {γ : Type.{u2}} {f : α -> γ}, Monotone.{u2, u1} (UniformSpace.{u2} γ) (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u2} (UniformSpace.{u2} γ) (UniformSpace.partialOrder.{u2} γ)) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (UniformSpace.partialOrder.{u1} α)) (fun (u : UniformSpace.{u2} γ) => UniformSpace.comap.{u1, u2} α γ f u)\nbut is expected to have type\n  forall {α : Type.{u2}} {γ : Type.{u1}} {f : α -> γ}, Monotone.{u1, u2} (UniformSpace.{u1} γ) (UniformSpace.{u2} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} γ) (instPartialOrderUniformSpace.{u1} γ)) (PartialOrder.toPreorder.{u2} (UniformSpace.{u2} α) (instPartialOrderUniformSpace.{u2} α)) (fun (u : UniformSpace.{u1} γ) => UniformSpace.comap.{u2, u1} α γ f u)\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_mono UniformSpace.comap_monoₓ'. -/\ntheorem UniformSpace.comap_mono {α γ} {f : α → γ} : Monotone fun u : UniformSpace γ => u.comap f :=\n  by\n  intro u₁ u₂ hu\n  change 𝓤 _ ≤ 𝓤 _\n  rw [uniformity_comap]\n  exact comap_mono hu\n#align uniform_space.comap_mono UniformSpace.comap_mono\n\n/- warning: uniform_continuous_iff -> uniformContinuous_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {uα : UniformSpace.{u1} α} {uβ : UniformSpace.{u2} β} {f : α -> β}, Iff (UniformContinuous.{u1, u2} α β uα uβ f) (LE.le.{u1} (UniformSpace.{u1} α) (Preorder.toLE.{u1} (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (UniformSpace.partialOrder.{u1} α))) uα (UniformSpace.comap.{u1, u2} α β f uβ))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {uα : UniformSpace.{u2} α} {uβ : UniformSpace.{u1} β} {f : α -> β}, Iff (UniformContinuous.{u2, u1} α β uα uβ f) (LE.le.{u2} (UniformSpace.{u2} α) (Preorder.toLE.{u2} (UniformSpace.{u2} α) (PartialOrder.toPreorder.{u2} (UniformSpace.{u2} α) (instPartialOrderUniformSpace.{u2} α))) uα (UniformSpace.comap.{u2, u1} α β f uβ))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_iff uniformContinuous_iffₓ'. -/\ntheorem uniformContinuous_iff {α β} {uα : UniformSpace α} {uβ : UniformSpace β} {f : α → β} :\n    UniformContinuous f ↔ uα ≤ uβ.comap f :=\n  Filter.map_le_iff_le_comap\n#align uniform_continuous_iff uniformContinuous_iff\n\n/- warning: le_iff_uniform_continuous_id -> le_iff_uniformContinuous_id is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {u : UniformSpace.{u1} α} {v : UniformSpace.{u1} α}, Iff (LE.le.{u1} (UniformSpace.{u1} α) (Preorder.toLE.{u1} (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (UniformSpace.partialOrder.{u1} α))) u v) (UniformContinuous.{u1, u1} α α u v (id.{succ u1} α))\nbut is expected to have type\n  forall {α : Type.{u1}} {u : UniformSpace.{u1} α} {v : UniformSpace.{u1} α}, Iff (LE.le.{u1} (UniformSpace.{u1} α) (Preorder.toLE.{u1} (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (instPartialOrderUniformSpace.{u1} α))) u v) (UniformContinuous.{u1, u1} α α u v (id.{succ u1} α))\nCase conversion may be inaccurate. Consider using '#align le_iff_uniform_continuous_id le_iff_uniformContinuous_idₓ'. -/\ntheorem le_iff_uniformContinuous_id {u v : UniformSpace α} :\n    u ≤ v ↔ @UniformContinuous _ _ u v id := by\n  rw [uniformContinuous_iff, uniformSpace_comap_id, id]\n#align le_iff_uniform_continuous_id le_iff_uniformContinuous_id\n\n#print uniformContinuous_comap /-\ntheorem uniformContinuous_comap {f : α → β} [u : UniformSpace β] :\n    @UniformContinuous α β (UniformSpace.comap f u) u f :=\n  tendsto_comap\n#align uniform_continuous_comap uniformContinuous_comap\n-/\n\n#print toTopologicalSpace_comap /-\ntheorem toTopologicalSpace_comap {f : α → β} {u : UniformSpace β} :\n    @UniformSpace.toTopologicalSpace _ (UniformSpace.comap f u) =\n      TopologicalSpace.induced f (@UniformSpace.toTopologicalSpace β u) :=\n  rfl\n#align to_topological_space_comap toTopologicalSpace_comap\n-/\n\n#print uniformContinuous_comap' /-\ntheorem uniformContinuous_comap' {f : γ → β} {g : α → γ} [v : UniformSpace β] [u : UniformSpace α]\n    (h : UniformContinuous (f ∘ g)) : @UniformContinuous α γ u (UniformSpace.comap f v) g :=\n  tendsto_comap_iff.2 h\n#align uniform_continuous_comap' uniformContinuous_comap'\n-/\n\n/- warning: to_nhds_mono -> to_nhds_mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {u₁ : UniformSpace.{u1} α} {u₂ : UniformSpace.{u1} α}, (LE.le.{u1} (UniformSpace.{u1} α) (Preorder.toLE.{u1} (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (UniformSpace.partialOrder.{u1} α))) u₁ u₂) -> (forall (a : α), LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.partialOrder.{u1} α))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α u₁) a) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α u₂) a))\nbut is expected to have type\n  forall {α : Type.{u1}} {u₁ : UniformSpace.{u1} α} {u₂ : UniformSpace.{u1} α}, (LE.le.{u1} (UniformSpace.{u1} α) (Preorder.toLE.{u1} (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (instPartialOrderUniformSpace.{u1} α))) u₁ u₂) -> (forall (a : α), LE.le.{u1} (Filter.{u1} α) (Preorder.toLE.{u1} (Filter.{u1} α) (PartialOrder.toPreorder.{u1} (Filter.{u1} α) (Filter.instPartialOrderFilter.{u1} α))) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α u₁) a) (nhds.{u1} α (UniformSpace.toTopologicalSpace.{u1} α u₂) a))\nCase conversion may be inaccurate. Consider using '#align to_nhds_mono to_nhds_monoₓ'. -/\ntheorem to_nhds_mono {u₁ u₂ : UniformSpace α} (h : u₁ ≤ u₂) (a : α) :\n    @nhds _ (@UniformSpace.toTopologicalSpace _ u₁) a ≤\n      @nhds _ (@UniformSpace.toTopologicalSpace _ u₂) a :=\n  by rw [@nhds_eq_uniformity α u₁ a, @nhds_eq_uniformity α u₂ a] <;> exact lift'_mono h le_rfl\n#align to_nhds_mono to_nhds_mono\n\n/- warning: to_topological_space_mono -> toTopologicalSpace_mono is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {u₁ : UniformSpace.{u1} α} {u₂ : UniformSpace.{u1} α}, (LE.le.{u1} (UniformSpace.{u1} α) (Preorder.toLE.{u1} (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (UniformSpace.partialOrder.{u1} α))) u₁ u₂) -> (LE.le.{u1} (TopologicalSpace.{u1} α) (Preorder.toLE.{u1} (TopologicalSpace.{u1} α) (PartialOrder.toPreorder.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.partialOrder.{u1} α))) (UniformSpace.toTopologicalSpace.{u1} α u₁) (UniformSpace.toTopologicalSpace.{u1} α u₂))\nbut is expected to have type\n  forall {α : Type.{u1}} {u₁ : UniformSpace.{u1} α} {u₂ : UniformSpace.{u1} α}, (LE.le.{u1} (UniformSpace.{u1} α) (Preorder.toLE.{u1} (UniformSpace.{u1} α) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} α) (instPartialOrderUniformSpace.{u1} α))) u₁ u₂) -> (LE.le.{u1} (TopologicalSpace.{u1} α) (Preorder.toLE.{u1} (TopologicalSpace.{u1} α) (PartialOrder.toPreorder.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.instPartialOrderTopologicalSpace.{u1} α))) (UniformSpace.toTopologicalSpace.{u1} α u₁) (UniformSpace.toTopologicalSpace.{u1} α u₂))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_mono toTopologicalSpace_monoₓ'. -/\ntheorem toTopologicalSpace_mono {u₁ u₂ : UniformSpace α} (h : u₁ ≤ u₂) :\n    @UniformSpace.toTopologicalSpace _ u₁ ≤ @UniformSpace.toTopologicalSpace _ u₂ :=\n  le_of_nhds_le_nhds <| to_nhds_mono h\n#align to_topological_space_mono toTopologicalSpace_mono\n\n#print UniformContinuous.continuous /-\ntheorem UniformContinuous.continuous [UniformSpace α] [UniformSpace β] {f : α → β}\n    (hf : UniformContinuous f) : Continuous f :=\n  continuous_iff_le_induced.mpr <| toTopologicalSpace_mono <| uniformContinuous_iff.1 hf\n#align uniform_continuous.continuous UniformContinuous.continuous\n-/\n\n/- warning: to_topological_space_bot -> toTopologicalSpace_bot is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} α) (UniformSpace.toTopologicalSpace.{u1} α (Bot.bot.{u1} (UniformSpace.{u1} α) (UniformSpace.hasBot.{u1} α))) (Bot.bot.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toHasBot.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.completeLattice.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} α) (UniformSpace.toTopologicalSpace.{u1} α (Bot.bot.{u1} (UniformSpace.{u1} α) (instBotUniformSpace.{u1} α))) (Bot.bot.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toBot.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_bot toTopologicalSpace_botₓ'. -/\ntheorem toTopologicalSpace_bot : @UniformSpace.toTopologicalSpace α ⊥ = ⊥ :=\n  rfl\n#align to_topological_space_bot toTopologicalSpace_bot\n\n/- warning: to_topological_space_top -> toTopologicalSpace_top is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} α) (UniformSpace.toTopologicalSpace.{u1} α (Top.top.{u1} (UniformSpace.{u1} α) (UniformSpace.hasTop.{u1} α))) (Top.top.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toHasTop.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.completeLattice.{u1} α)))\nbut is expected to have type\n  forall {α : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} α) (UniformSpace.toTopologicalSpace.{u1} α (Top.top.{u1} (UniformSpace.{u1} α) (instTopUniformSpace.{u1} α))) (Top.top.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toTop.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} α)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_top toTopologicalSpace_topₓ'. -/\ntheorem toTopologicalSpace_top : @UniformSpace.toTopologicalSpace α ⊤ = ⊤ :=\n  top_unique fun s hs =>\n    s.eq_empty_or_nonempty.elim (fun this : s = ∅ => this.symm ▸ @isOpen_empty _ ⊤) fun ⟨x, hx⟩ =>\n      have : s = univ := top_unique fun y hy => hs x hx (x, y) rfl\n      this.symm ▸ @isOpen_univ _ ⊤\n#align to_topological_space_top toTopologicalSpace_top\n\n/- warning: to_topological_space_infi -> toTopologicalSpace_infᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Sort.{u2}} {u : ι -> (UniformSpace.{u1} α)}, Eq.{succ u1} (TopologicalSpace.{u1} α) (UniformSpace.toTopologicalSpace.{u1} α (infᵢ.{u1, u2} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) ι u)) (infᵢ.{u1, u2} (TopologicalSpace.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.completeLattice.{u1} α))) ι (fun (i : ι) => UniformSpace.toTopologicalSpace.{u1} α (u i)))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Sort.{u1}} {u : ι -> (UniformSpace.{u2} α)}, Eq.{succ u2} (TopologicalSpace.{u2} α) (UniformSpace.toTopologicalSpace.{u2} α (infᵢ.{u2, u1} (UniformSpace.{u2} α) (instInfSetUniformSpace.{u2} α) ι u)) (infᵢ.{u2, u1} (TopologicalSpace.{u2} α) (ConditionallyCompleteLattice.toInfSet.{u2} (TopologicalSpace.{u2} α) (CompleteLattice.toConditionallyCompleteLattice.{u2} (TopologicalSpace.{u2} α) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u2} α))) ι (fun (i : ι) => UniformSpace.toTopologicalSpace.{u2} α (u i)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_infi toTopologicalSpace_infᵢₓ'. -/\ntheorem toTopologicalSpace_infᵢ {ι : Sort _} {u : ι → UniformSpace α} :\n    (infᵢ u).toTopologicalSpace = ⨅ i, (u i).toTopologicalSpace :=\n  by\n  refine' eq_of_nhds_eq_nhds fun a => _\n  simp only [nhds_infᵢ, nhds_eq_uniformity, infᵢ_uniformity]\n  exact lift'_infi_of_map_univ (ball_inter _) preimage_univ\n#align to_topological_space_infi toTopologicalSpace_infᵢ\n\n/- warning: to_topological_space_Inf -> toTopologicalSpace_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {s : Set.{u1} (UniformSpace.{u1} α)}, Eq.{succ u1} (TopologicalSpace.{u1} α) (UniformSpace.toTopologicalSpace.{u1} α (InfSet.infₛ.{u1} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) s)) (infᵢ.{u1, succ u1} (TopologicalSpace.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.completeLattice.{u1} α))) (UniformSpace.{u1} α) (fun (i : UniformSpace.{u1} α) => infᵢ.{u1, 0} (TopologicalSpace.{u1} α) (ConditionallyCompleteLattice.toHasInf.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.completeLattice.{u1} α))) (Membership.Mem.{u1, u1} (UniformSpace.{u1} α) (Set.{u1} (UniformSpace.{u1} α)) (Set.hasMem.{u1} (UniformSpace.{u1} α)) i s) (fun (H : Membership.Mem.{u1, u1} (UniformSpace.{u1} α) (Set.{u1} (UniformSpace.{u1} α)) (Set.hasMem.{u1} (UniformSpace.{u1} α)) i s) => UniformSpace.toTopologicalSpace.{u1} α i)))\nbut is expected to have type\n  forall {α : Type.{u1}} {s : Set.{u1} (UniformSpace.{u1} α)}, Eq.{succ u1} (TopologicalSpace.{u1} α) (UniformSpace.toTopologicalSpace.{u1} α (InfSet.infₛ.{u1} (UniformSpace.{u1} α) (instInfSetUniformSpace.{u1} α) s)) (infᵢ.{u1, succ u1} (TopologicalSpace.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} α))) (UniformSpace.{u1} α) (fun (i : UniformSpace.{u1} α) => infᵢ.{u1, 0} (TopologicalSpace.{u1} α) (ConditionallyCompleteLattice.toInfSet.{u1} (TopologicalSpace.{u1} α) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} α) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} α))) (Membership.mem.{u1, u1} (UniformSpace.{u1} α) (Set.{u1} (UniformSpace.{u1} α)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} α)) i s) (fun (H : Membership.mem.{u1, u1} (UniformSpace.{u1} α) (Set.{u1} (UniformSpace.{u1} α)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} α)) i s) => UniformSpace.toTopologicalSpace.{u1} α i)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_Inf toTopologicalSpace_infₛₓ'. -/\ntheorem toTopologicalSpace_infₛ {s : Set (UniformSpace α)} :\n    (infₛ s).toTopologicalSpace = ⨅ i ∈ s, @UniformSpace.toTopologicalSpace α i :=\n  by\n  rw [infₛ_eq_infᵢ]\n  simp only [← toTopologicalSpace_infᵢ]\n#align to_topological_space_Inf toTopologicalSpace_infₛ\n\n#print toTopologicalSpace_inf /-\ntheorem toTopologicalSpace_inf {u v : UniformSpace α} :\n    (u ⊓ v).toTopologicalSpace = u.toTopologicalSpace ⊓ v.toTopologicalSpace :=\n  rfl\n#align to_topological_space_inf toTopologicalSpace_inf\n-/\n\n#print ULift.uniformSpace /-\n/-- Uniform space structure on `ulift α`. -/\ninstance ULift.uniformSpace [UniformSpace α] : UniformSpace (ULift α) :=\n  UniformSpace.comap ULift.down ‹_›\n#align ulift.uniform_space ULift.uniformSpace\n-/\n\nsection UniformContinuousInfi\n\n#print UniformContinuous.inf_rng /-\ntheorem UniformContinuous.inf_rng {f : α → β} {u₁ : UniformSpace α} {u₂ u₃ : UniformSpace β}\n    (h₁ : @UniformContinuous u₁ u₂ f) (h₂ : @UniformContinuous u₁ u₃ f) :\n    @UniformContinuous u₁ (u₂ ⊓ u₃) f :=\n  tendsto_inf.mpr ⟨h₁, h₂⟩\n#align uniform_continuous_inf_rng UniformContinuous.inf_rng\n-/\n\n#print UniformContinuous.inf_dom_left /-\ntheorem UniformContinuous.inf_dom_left {f : α → β} {u₁ u₂ : UniformSpace α} {u₃ : UniformSpace β}\n    (hf : @UniformContinuous u₁ u₃ f) : @UniformContinuous (u₁ ⊓ u₂) u₃ f :=\n  tendsto_inf_left hf\n#align uniform_continuous_inf_dom_left UniformContinuous.inf_dom_left\n-/\n\n#print UniformContinuous.inf_dom_right /-\ntheorem UniformContinuous.inf_dom_right {f : α → β} {u₁ u₂ : UniformSpace α} {u₃ : UniformSpace β}\n    (hf : @UniformContinuous u₂ u₃ f) : @UniformContinuous (u₁ ⊓ u₂) u₃ f :=\n  tendsto_inf_right hf\n#align uniform_continuous_inf_dom_right UniformContinuous.inf_dom_right\n-/\n\n/- warning: uniform_continuous_Inf_dom -> uniformContinuous_infₛ_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β} {u₁ : Set.{u1} (UniformSpace.{u1} α)} {u₂ : UniformSpace.{u2} β} {u : UniformSpace.{u1} α}, (Membership.Mem.{u1, u1} (UniformSpace.{u1} α) (Set.{u1} (UniformSpace.{u1} α)) (Set.hasMem.{u1} (UniformSpace.{u1} α)) u u₁) -> (UniformContinuous.{u1, u2} α β u u₂ f) -> (UniformContinuous.{u1, u2} α β (InfSet.infₛ.{u1} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) u₁) u₂ f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β} {u₁ : Set.{u1} (UniformSpace.{u1} α)} {u₂ : UniformSpace.{u2} β} {u : UniformSpace.{u1} α}, (Membership.mem.{u1, u1} (UniformSpace.{u1} α) (Set.{u1} (UniformSpace.{u1} α)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} α)) u u₁) -> (UniformContinuous.{u1, u2} α β u u₂ f) -> (UniformContinuous.{u1, u2} α β (InfSet.infₛ.{u1} (UniformSpace.{u1} α) (instInfSetUniformSpace.{u1} α) u₁) u₂ f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_Inf_dom uniformContinuous_infₛ_domₓ'. -/\ntheorem uniformContinuous_infₛ_dom {f : α → β} {u₁ : Set (UniformSpace α)} {u₂ : UniformSpace β}\n    {u : UniformSpace α} (h₁ : u ∈ u₁) (hf : @UniformContinuous u u₂ f) :\n    @UniformContinuous (infₛ u₁) u₂ f :=\n  by\n  rw [UniformContinuous, infₛ_eq_infᵢ', infᵢ_uniformity]\n  exact tendsto_infi' ⟨u, h₁⟩ hf\n#align uniform_continuous_Inf_dom uniformContinuous_infₛ_dom\n\n/- warning: uniform_continuous_Inf_rng -> uniformContinuous_infₛ_rng is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β} {u₁ : UniformSpace.{u1} α} {u₂ : Set.{u2} (UniformSpace.{u2} β)}, (forall (u : UniformSpace.{u2} β), (Membership.Mem.{u2, u2} (UniformSpace.{u2} β) (Set.{u2} (UniformSpace.{u2} β)) (Set.hasMem.{u2} (UniformSpace.{u2} β)) u u₂) -> (UniformContinuous.{u1, u2} α β u₁ u f)) -> (UniformContinuous.{u1, u2} α β u₁ (InfSet.infₛ.{u2} (UniformSpace.{u2} β) (UniformSpace.hasInf.{u2} β) u₂) f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β} {u₁ : UniformSpace.{u1} α} {u₂ : Set.{u2} (UniformSpace.{u2} β)}, (forall (u : UniformSpace.{u2} β), (Membership.mem.{u2, u2} (UniformSpace.{u2} β) (Set.{u2} (UniformSpace.{u2} β)) (Set.instMembershipSet.{u2} (UniformSpace.{u2} β)) u u₂) -> (UniformContinuous.{u1, u2} α β u₁ u f)) -> (UniformContinuous.{u1, u2} α β u₁ (InfSet.infₛ.{u2} (UniformSpace.{u2} β) (instInfSetUniformSpace.{u2} β) u₂) f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_Inf_rng uniformContinuous_infₛ_rngₓ'. -/\ntheorem uniformContinuous_infₛ_rng {f : α → β} {u₁ : UniformSpace α} {u₂ : Set (UniformSpace β)}\n    (h : ∀ u ∈ u₂, @UniformContinuous u₁ u f) : @UniformContinuous u₁ (infₛ u₂) f :=\n  by\n  rw [UniformContinuous, infₛ_eq_infᵢ', infᵢ_uniformity]\n  exact tendsto_infi.mpr fun ⟨u, hu⟩ => h u hu\n#align uniform_continuous_Inf_rng uniformContinuous_infₛ_rng\n\n/- warning: uniform_continuous_infi_dom -> uniformContinuous_infᵢ_dom is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {ι : Sort.{u3}} {f : α -> β} {u₁ : ι -> (UniformSpace.{u1} α)} {u₂ : UniformSpace.{u2} β} {i : ι}, (UniformContinuous.{u1, u2} α β (u₁ i) u₂ f) -> (UniformContinuous.{u1, u2} α β (infᵢ.{u1, u3} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) ι u₁) u₂ f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {ι : Sort.{u1}} {f : α -> β} {u₁ : ι -> (UniformSpace.{u2} α)} {u₂ : UniformSpace.{u3} β} {i : ι}, (UniformContinuous.{u2, u3} α β (u₁ i) u₂ f) -> (UniformContinuous.{u2, u3} α β (infᵢ.{u2, u1} (UniformSpace.{u2} α) (instInfSetUniformSpace.{u2} α) ι u₁) u₂ f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_infi_dom uniformContinuous_infᵢ_domₓ'. -/\ntheorem uniformContinuous_infᵢ_dom {f : α → β} {u₁ : ι → UniformSpace α} {u₂ : UniformSpace β}\n    {i : ι} (hf : @UniformContinuous (u₁ i) u₂ f) : @UniformContinuous (infᵢ u₁) u₂ f :=\n  by\n  rw [UniformContinuous, infᵢ_uniformity]\n  exact tendsto_infi' i hf\n#align uniform_continuous_infi_dom uniformContinuous_infᵢ_dom\n\n/- warning: uniform_continuous_infi_rng -> uniformContinuous_infᵢ_rng is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {ι : Sort.{u3}} {f : α -> β} {u₁ : UniformSpace.{u1} α} {u₂ : ι -> (UniformSpace.{u2} β)}, (forall (i : ι), UniformContinuous.{u1, u2} α β u₁ (u₂ i) f) -> (UniformContinuous.{u1, u2} α β u₁ (infᵢ.{u2, u3} (UniformSpace.{u2} β) (UniformSpace.hasInf.{u2} β) ι u₂) f)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {ι : Sort.{u1}} {f : α -> β} {u₁ : UniformSpace.{u2} α} {u₂ : ι -> (UniformSpace.{u3} β)}, (forall (i : ι), UniformContinuous.{u2, u3} α β u₁ (u₂ i) f) -> (UniformContinuous.{u2, u3} α β u₁ (infᵢ.{u3, u1} (UniformSpace.{u3} β) (instInfSetUniformSpace.{u3} β) ι u₂) f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_infi_rng uniformContinuous_infᵢ_rngₓ'. -/\ntheorem uniformContinuous_infᵢ_rng {f : α → β} {u₁ : UniformSpace α} {u₂ : ι → UniformSpace β}\n    (h : ∀ i, @UniformContinuous u₁ (u₂ i) f) : @UniformContinuous u₁ (infᵢ u₂) f := by\n  rwa [UniformContinuous, infᵢ_uniformity, tendsto_infi]\n#align uniform_continuous_infi_rng uniformContinuous_infᵢ_rng\n\nend UniformContinuousInfi\n\n#print discreteTopology_of_discrete_uniformity /-\n/-- A uniform space with the discrete uniformity has the discrete topology. -/\ntheorem discreteTopology_of_discrete_uniformity [hα : UniformSpace α] (h : uniformity α = 𝓟 idRel) :\n    DiscreteTopology α :=\n  ⟨(uniformSpace_eq h.symm : ⊥ = hα) ▸ rfl⟩\n#align discrete_topology_of_discrete_uniformity discreteTopology_of_discrete_uniformity\n-/\n\ninstance : UniformSpace Empty :=\n  ⊥\n\ninstance : UniformSpace PUnit :=\n  ⊥\n\ninstance : UniformSpace Bool :=\n  ⊥\n\ninstance : UniformSpace ℕ :=\n  ⊥\n\ninstance : UniformSpace ℤ :=\n  ⊥\n\nsection\n\nvariable [UniformSpace α]\n\nopen Additive Multiplicative\n\ninstance : UniformSpace (Additive α) :=\n  ‹UniformSpace α›\n\ninstance : UniformSpace (Multiplicative α) :=\n  ‹UniformSpace α›\n\n#print uniformContinuous_ofMul /-\ntheorem uniformContinuous_ofMul : UniformContinuous (ofMul : α → Additive α) :=\n  uniformContinuous_id\n#align uniform_continuous_of_mul uniformContinuous_ofMul\n-/\n\n#print uniformContinuous_toMul /-\ntheorem uniformContinuous_toMul : UniformContinuous (toMul : Additive α → α) :=\n  uniformContinuous_id\n#align uniform_continuous_to_mul uniformContinuous_toMul\n-/\n\n#print uniformContinuous_ofAdd /-\ntheorem uniformContinuous_ofAdd : UniformContinuous (ofAdd : α → Multiplicative α) :=\n  uniformContinuous_id\n#align uniform_continuous_of_add uniformContinuous_ofAdd\n-/\n\n#print uniformContinuous_toAdd /-\ntheorem uniformContinuous_toAdd : UniformContinuous (toAdd : Multiplicative α → α) :=\n  uniformContinuous_id\n#align uniform_continuous_to_add uniformContinuous_toAdd\n-/\n\n#print uniformity_additive /-\ntheorem uniformity_additive : 𝓤 (Additive α) = (𝓤 α).map (Prod.map ofMul ofMul) :=\n  by\n  convert map_id.symm\n  exact Prod.map_id\n#align uniformity_additive uniformity_additive\n-/\n\n#print uniformity_multiplicative /-\ntheorem uniformity_multiplicative : 𝓤 (Multiplicative α) = (𝓤 α).map (Prod.map ofAdd ofAdd) :=\n  by\n  convert map_id.symm\n  exact Prod.map_id\n#align uniformity_multiplicative uniformity_multiplicative\n-/\n\nend\n\ninstance {p : α → Prop} [t : UniformSpace α] : UniformSpace (Subtype p) :=\n  UniformSpace.comap Subtype.val t\n\n#print uniformity_subtype /-\ntheorem uniformity_subtype {p : α → Prop} [t : UniformSpace α] :\n    𝓤 (Subtype p) = comap (fun q : Subtype p × Subtype p => (q.1.1, q.2.1)) (𝓤 α) :=\n  rfl\n#align uniformity_subtype uniformity_subtype\n-/\n\n#print uniformity_setCoe /-\ntheorem uniformity_setCoe {s : Set α} [t : UniformSpace α] :\n    𝓤 s = comap (Prod.map (coe : s → α) (coe : s → α)) (𝓤 α) :=\n  rfl\n#align uniformity_set_coe uniformity_setCoe\n-/\n\n#print uniformContinuous_subtype_val /-\ntheorem uniformContinuous_subtype_val {p : α → Prop} [UniformSpace α] :\n    UniformContinuous (Subtype.val : { a : α // p a } → α) :=\n  uniformContinuous_comap\n#align uniform_continuous_subtype_val uniformContinuous_subtype_val\n-/\n\n/- warning: uniform_continuous_subtype_coe clashes with uniform_continuous_subtype_val -> uniformContinuous_subtype_val\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_subtype_coe uniformContinuous_subtype_valₓ'. -/\n#print uniformContinuous_subtype_val /-\ntheorem uniformContinuous_subtype_val {p : α → Prop} [UniformSpace α] :\n    UniformContinuous (coe : { a : α // p a } → α) :=\n  uniformContinuous_subtype_val\n#align uniform_continuous_subtype_coe uniformContinuous_subtype_val\n-/\n\n#print UniformContinuous.subtype_mk /-\ntheorem UniformContinuous.subtype_mk {p : α → Prop} [UniformSpace α] [UniformSpace β] {f : β → α}\n    (hf : UniformContinuous f) (h : ∀ x, p (f x)) :\n    UniformContinuous (fun x => ⟨f x, h x⟩ : β → Subtype p) :=\n  uniformContinuous_comap' hf\n#align uniform_continuous.subtype_mk UniformContinuous.subtype_mk\n-/\n\n#print uniformContinuousOn_iff_restrict /-\ntheorem uniformContinuousOn_iff_restrict [UniformSpace α] [UniformSpace β] {f : α → β} {s : Set α} :\n    UniformContinuousOn f s ↔ UniformContinuous (s.restrict f) :=\n  by\n  unfold UniformContinuousOn Set.restrict UniformContinuous tendsto\n  conv_rhs =>\n    rw [show (fun x : s × s => (f x.1, f x.2)) = Prod.map f f ∘ Prod.map coe coe from rfl,\n      uniformity_setCoe, ← map_map, map_comap, range_prod_map, Subtype.range_coe]\n  rfl\n#align uniform_continuous_on_iff_restrict uniformContinuousOn_iff_restrict\n-/\n\n#print tendsto_of_uniformContinuous_subtype /-\ntheorem tendsto_of_uniformContinuous_subtype [UniformSpace α] [UniformSpace β] {f : α → β}\n    {s : Set α} {a : α} (hf : UniformContinuous fun x : s => f x.val) (ha : s ∈ 𝓝 a) :\n    Tendsto f (𝓝 a) (𝓝 (f a)) := by\n  rw [(@map_nhds_subtype_coe_eq_nhds α _ s a (mem_of_mem_nhds ha) ha).symm] <;>\n    exact tendsto_map' (continuous_iff_continuous_at.mp hf.continuous _)\n#align tendsto_of_uniform_continuous_subtype tendsto_of_uniformContinuous_subtype\n-/\n\n#print UniformContinuousOn.continuousOn /-\ntheorem UniformContinuousOn.continuousOn [UniformSpace α] [UniformSpace β] {f : α → β} {s : Set α}\n    (h : UniformContinuousOn f s) : ContinuousOn f s :=\n  by\n  rw [uniformContinuousOn_iff_restrict] at h\n  rw [continuousOn_iff_continuous_restrict]\n  exact h.continuous\n#align uniform_continuous_on.continuous_on UniformContinuousOn.continuousOn\n-/\n\n@[to_additive]\ninstance [UniformSpace α] : UniformSpace αᵐᵒᵖ :=\n  UniformSpace.comap MulOpposite.unop ‹_›\n\n#print uniformity_mulOpposite /-\n@[to_additive]\ntheorem uniformity_mulOpposite [UniformSpace α] :\n    𝓤 αᵐᵒᵖ = comap (fun q : αᵐᵒᵖ × αᵐᵒᵖ => (q.1.unop, q.2.unop)) (𝓤 α) :=\n  rfl\n#align uniformity_mul_opposite uniformity_mulOpposite\n#align uniformity_add_opposite uniformity_addOpposite\n-/\n\n#print comap_uniformity_mulOpposite /-\n@[simp, to_additive]\ntheorem comap_uniformity_mulOpposite [UniformSpace α] :\n    comap (fun p : α × α => (MulOpposite.op p.1, MulOpposite.op p.2)) (𝓤 αᵐᵒᵖ) = 𝓤 α := by\n  simpa [uniformity_mulOpposite, comap_comap, (· ∘ ·)] using comap_id\n#align comap_uniformity_mul_opposite comap_uniformity_mulOpposite\n#align comap_uniformity_add_opposite comap_uniformity_addOpposite\n-/\n\nnamespace MulOpposite\n\n#print MulOpposite.uniformContinuous_unop /-\n@[to_additive]\ntheorem uniformContinuous_unop [UniformSpace α] : UniformContinuous (unop : αᵐᵒᵖ → α) :=\n  uniformContinuous_comap\n#align mul_opposite.uniform_continuous_unop MulOpposite.uniformContinuous_unop\n#align add_opposite.uniform_continuous_unop AddOpposite.uniformContinuous_unop\n-/\n\n#print MulOpposite.uniformContinuous_op /-\n@[to_additive]\ntheorem uniformContinuous_op [UniformSpace α] : UniformContinuous (op : α → αᵐᵒᵖ) :=\n  uniformContinuous_comap' uniformContinuous_id\n#align mul_opposite.uniform_continuous_op MulOpposite.uniformContinuous_op\n#align add_opposite.uniform_continuous_op AddOpposite.uniformContinuous_op\n-/\n\nend MulOpposite\n\nsection Prod\n\n/- a similar product space is possible on the function space (uniformity of pointwise convergence),\n  but we want to have the uniformity of uniform convergence on function spaces -/\ninstance [u₁ : UniformSpace α] [u₂ : UniformSpace β] : UniformSpace (α × β) :=\n  u₁.comap Prod.fst ⊓ u₂.comap Prod.snd\n\n-- check the above produces no diamond\nexample [u₁ : UniformSpace α] [u₂ : UniformSpace β] :\n    (Prod.topologicalSpace : TopologicalSpace (α × β)) = UniformSpace.toTopologicalSpace :=\n  rfl\n\n/- warning: uniformity_prod -> uniformity_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (uniformity.{max u1 u2} (Prod.{u1, u2} α β) (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2)) (Inf.inf.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (Filter.hasInf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (Filter.comap.{max u1 u2, u1} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u1, u1} α α) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{u1} α _inst_1)) (Filter.comap.{max u1 u2, u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u2, u2} β β) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{u2} β _inst_2)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (uniformity.{max u2 u1} (Prod.{u1, u2} α β) (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2)) (Inf.inf.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (Filter.instInfFilter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (Filter.comap.{max u1 u2, u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u1, u1} α α) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{u1} α _inst_1)) (Filter.comap.{max u1 u2, u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u2, u2} β β) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{u2} β _inst_2)))\nCase conversion may be inaccurate. Consider using '#align uniformity_prod uniformity_prodₓ'. -/\ntheorem uniformity_prod [UniformSpace α] [UniformSpace β] :\n    𝓤 (α × β) =\n      ((𝓤 α).comap fun p : (α × β) × α × β => (p.1.1, p.2.1)) ⊓\n        (𝓤 β).comap fun p : (α × β) × α × β => (p.1.2, p.2.2) :=\n  rfl\n#align uniformity_prod uniformity_prod\n\n/- warning: uniformity_prod_eq_comap_prod -> uniformity_prod_eq_comap_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (uniformity.{max u1 u2} (Prod.{u1, u2} α β) (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2)) (Filter.comap.{max u1 u2, max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β)) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) (Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) (uniformity.{u1} α _inst_1) (uniformity.{u2} β _inst_2)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (uniformity.{max u2 u1} (Prod.{u1, u2} α β) (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2)) (Filter.comap.{max u1 u2, max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β)) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) (Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) (uniformity.{u1} α _inst_1) (uniformity.{u2} β _inst_2)))\nCase conversion may be inaccurate. Consider using '#align uniformity_prod_eq_comap_prod uniformity_prod_eq_comap_prodₓ'. -/\ntheorem uniformity_prod_eq_comap_prod [UniformSpace α] [UniformSpace β] :\n    𝓤 (α × β) = comap (fun p : (α × β) × α × β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (𝓤 α ×ᶠ 𝓤 β) :=\n  by rw [uniformity_prod, Filter.prod, comap_inf, comap_comap, comap_comap]\n#align uniformity_prod_eq_comap_prod uniformity_prod_eq_comap_prod\n\n/- warning: uniformity_prod_eq_prod -> uniformity_prod_eq_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (uniformity.{max u1 u2} (Prod.{u1, u2} α β) (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2)) (Filter.map.{max u1 u2, max u1 u2} (Prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β)) (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (fun (p : Prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β)) => Prod.mk.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) (Prod.mk.{u1, u2} α β (Prod.fst.{u1, u1} α α (Prod.fst.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p)) (Prod.fst.{u2, u2} β β (Prod.snd.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p))) (Prod.mk.{u1, u2} α β (Prod.snd.{u1, u1} α α (Prod.fst.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p)) (Prod.snd.{u2, u2} β β (Prod.snd.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) (uniformity.{u1} α _inst_1) (uniformity.{u2} β _inst_2)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (uniformity.{max u2 u1} (Prod.{u1, u2} α β) (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2)) (Filter.map.{max u1 u2, max u2 u1} (Prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β)) (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (fun (p : Prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β)) => Prod.mk.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) (Prod.mk.{u1, u2} α β (Prod.fst.{u1, u1} α α (Prod.fst.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p)) (Prod.fst.{u2, u2} β β (Prod.snd.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p))) (Prod.mk.{u1, u2} α β (Prod.snd.{u1, u1} α α (Prod.fst.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p)) (Prod.snd.{u2, u2} β β (Prod.snd.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} α α) (Prod.{u2, u2} β β) (uniformity.{u1} α _inst_1) (uniformity.{u2} β _inst_2)))\nCase conversion may be inaccurate. Consider using '#align uniformity_prod_eq_prod uniformity_prod_eq_prodₓ'. -/\ntheorem uniformity_prod_eq_prod [UniformSpace α] [UniformSpace β] :\n    𝓤 (α × β) = map (fun p : (α × α) × β × β => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (𝓤 α ×ᶠ 𝓤 β) := by\n  rw [map_swap4_eq_comap, uniformity_prod_eq_comap_prod]\n#align uniformity_prod_eq_prod uniformity_prod_eq_prod\n\n/- warning: mem_uniformity_of_uniform_continuous_invariant -> mem_uniformity_of_uniformContinuous_invariant is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {s : Set.{u2} (Prod.{u2, u2} β β)} {f : α -> α -> β}, (UniformContinuous.{u1, u2} (Prod.{u1, u1} α α) β (Prod.uniformSpace.{u1, u1} α α _inst_1 _inst_1) _inst_2 (fun (p : Prod.{u1, u1} α α) => f (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))) -> (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} β β)) (Filter.{u2} (Prod.{u2, u2} β β)) (Filter.hasMem.{u2} (Prod.{u2, u2} β β)) s (uniformity.{u2} β _inst_2)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (u : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) u (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) u (uniformity.{u1} α _inst_1)) => forall (a : α) (b : α) (c : α), (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) u) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} β β) (Set.{u2} (Prod.{u2, u2} β β)) (Set.hasMem.{u2} (Prod.{u2, u2} β β)) (Prod.mk.{u2, u2} β β (f a c) (f b c)) s))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {s : Set.{u2} (Prod.{u2, u2} β β)} {f : α -> α -> β}, (UniformContinuous.{u1, u2} (Prod.{u1, u1} α α) β (instUniformSpaceProd.{u1, u1} α α _inst_1 _inst_1) _inst_2 (fun (p : Prod.{u1, u1} α α) => f (Prod.fst.{u1, u1} α α p) (Prod.snd.{u1, u1} α α p))) -> (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} β β)) (Filter.{u2} (Prod.{u2, u2} β β)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} β β)) s (uniformity.{u2} β _inst_2)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (u : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) u (uniformity.{u1} α _inst_1)) (forall (a : α) (b : α) (c : α), (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α a b) u) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} β β) (Set.{u2} (Prod.{u2, u2} β β)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} β β)) (Prod.mk.{u2, u2} β β (f a c) (f b c)) s))))\nCase conversion may be inaccurate. Consider using '#align mem_uniformity_of_uniform_continuous_invariant mem_uniformity_of_uniformContinuous_invariantₓ'. -/\ntheorem mem_uniformity_of_uniformContinuous_invariant [UniformSpace α] [UniformSpace β]\n    {s : Set (β × β)} {f : α → α → β} (hf : UniformContinuous fun p : α × α => f p.1 p.2)\n    (hs : s ∈ 𝓤 β) : ∃ u ∈ 𝓤 α, ∀ a b c, (a, b) ∈ u → (f a c, f b c) ∈ s :=\n  by\n  rw [UniformContinuous, uniformity_prod_eq_prod, tendsto_map'_iff, (· ∘ ·)] at hf\n  rcases mem_prod_iff.1 (mem_map.1 <| hf hs) with ⟨u, hu, v, hv, huvt⟩\n  exact ⟨u, hu, fun a b c hab => @huvt ((_, _), (_, _)) ⟨hab, refl_mem_uniformity hv⟩⟩\n#align mem_uniformity_of_uniform_continuous_invariant mem_uniformity_of_uniformContinuous_invariant\n\n/- warning: mem_uniform_prod -> mem_uniform_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [t₁ : UniformSpace.{u1} α] [t₂ : UniformSpace.{u2} β] {a : Set.{u1} (Prod.{u1, u1} α α)} {b : Set.{u2} (Prod.{u2, u2} β β)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) a (uniformity.{u1} α t₁)) -> (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} β β)) (Filter.{u2} (Prod.{u2, u2} β β)) (Filter.hasMem.{u2} (Prod.{u2, u2} β β)) b (uniformity.{u2} β t₂)) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (setOf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => And (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) a) (Membership.Mem.{u2, u2} (Prod.{u2, u2} β β) (Set.{u2} (Prod.{u2, u2} β β)) (Set.hasMem.{u2} (Prod.{u2, u2} β β)) (Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) b))) (uniformity.{max u1 u2} (Prod.{u1, u2} α β) (Prod.uniformSpace.{u1, u2} α β t₁ t₂)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [t₁ : UniformSpace.{u1} α] [t₂ : UniformSpace.{u2} β] {a : Set.{u1} (Prod.{u1, u1} α α)} {b : Set.{u2} (Prod.{u2, u2} β β)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) a (uniformity.{u1} α t₁)) -> (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} β β)) (Filter.{u2} (Prod.{u2, u2} β β)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} β β)) b (uniformity.{u2} β t₂)) -> (Membership.mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β))) (setOf.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => And (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) a) (Membership.mem.{u2, u2} (Prod.{u2, u2} β β) (Set.{u2} (Prod.{u2, u2} β β)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} β β)) (Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) b))) (uniformity.{max u2 u1} (Prod.{u1, u2} α β) (instUniformSpaceProd.{u1, u2} α β t₁ t₂)))\nCase conversion may be inaccurate. Consider using '#align mem_uniform_prod mem_uniform_prodₓ'. -/\ntheorem mem_uniform_prod [t₁ : UniformSpace α] [t₂ : UniformSpace β] {a : Set (α × α)}\n    {b : Set (β × β)} (ha : a ∈ 𝓤 α) (hb : b ∈ 𝓤 β) :\n    { p : (α × β) × α × β | (p.1.1, p.2.1) ∈ a ∧ (p.1.2, p.2.2) ∈ b } ∈ 𝓤 (α × β) := by\n  rw [uniformity_prod] <;> exact inter_mem_inf (preimage_mem_comap ha) (preimage_mem_comap hb)\n#align mem_uniform_prod mem_uniform_prod\n\n/- warning: tendsto_prod_uniformity_fst -> tendsto_prod_uniformity_fst is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Filter.Tendsto.{max u1 u2, u1} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u1, u1} α α) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{max u1 u2} (Prod.{u1, u2} α β) (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2)) (uniformity.{u1} α _inst_1)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Filter.Tendsto.{max u1 u2, u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u1, u1} α α) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u1, u1} α α (Prod.fst.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.fst.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{max u2 u1} (Prod.{u1, u2} α β) (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2)) (uniformity.{u1} α _inst_1)\nCase conversion may be inaccurate. Consider using '#align tendsto_prod_uniformity_fst tendsto_prod_uniformity_fstₓ'. -/\ntheorem tendsto_prod_uniformity_fst [UniformSpace α] [UniformSpace β] :\n    Tendsto (fun p : (α × β) × α × β => (p.1.1, p.2.1)) (𝓤 (α × β)) (𝓤 α) :=\n  le_trans (map_mono inf_le_left) map_comap_le\n#align tendsto_prod_uniformity_fst tendsto_prod_uniformity_fst\n\n/- warning: tendsto_prod_uniformity_snd -> tendsto_prod_uniformity_snd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Filter.Tendsto.{max u1 u2, u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u2, u2} β β) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{max u1 u2} (Prod.{u1, u2} α β) (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2)) (uniformity.{u2} β _inst_2)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Filter.Tendsto.{max u1 u2, u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) (Prod.{u2, u2} β β) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β)) => Prod.mk.{u2, u2} β β (Prod.snd.{u1, u2} α β (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p)) (Prod.snd.{u1, u2} α β (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} α β) (Prod.{u1, u2} α β) p))) (uniformity.{max u2 u1} (Prod.{u1, u2} α β) (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2)) (uniformity.{u2} β _inst_2)\nCase conversion may be inaccurate. Consider using '#align tendsto_prod_uniformity_snd tendsto_prod_uniformity_sndₓ'. -/\ntheorem tendsto_prod_uniformity_snd [UniformSpace α] [UniformSpace β] :\n    Tendsto (fun p : (α × β) × α × β => (p.1.2, p.2.2)) (𝓤 (α × β)) (𝓤 β) :=\n  le_trans (map_mono inf_le_right) map_comap_le\n#align tendsto_prod_uniformity_snd tendsto_prod_uniformity_snd\n\n/- warning: uniform_continuous_fst -> uniformContinuous_fst is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], UniformContinuous.{max u1 u2, u1} (Prod.{u1, u2} α β) α (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) _inst_1 (fun (p : Prod.{u1, u2} α β) => Prod.fst.{u1, u2} α β p)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], UniformContinuous.{max u1 u2, u1} (Prod.{u1, u2} α β) α (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) _inst_1 (fun (p : Prod.{u1, u2} α β) => Prod.fst.{u1, u2} α β p)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_fst uniformContinuous_fstₓ'. -/\ntheorem uniformContinuous_fst [UniformSpace α] [UniformSpace β] :\n    UniformContinuous fun p : α × β => p.1 :=\n  tendsto_prod_uniformity_fst\n#align uniform_continuous_fst uniformContinuous_fst\n\n/- warning: uniform_continuous_snd -> uniformContinuous_snd is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], UniformContinuous.{max u1 u2, u2} (Prod.{u1, u2} α β) β (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) _inst_2 (fun (p : Prod.{u1, u2} α β) => Prod.snd.{u1, u2} α β p)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], UniformContinuous.{max u1 u2, u2} (Prod.{u1, u2} α β) β (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) _inst_2 (fun (p : Prod.{u1, u2} α β) => Prod.snd.{u1, u2} α β p)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_snd uniformContinuous_sndₓ'. -/\ntheorem uniformContinuous_snd [UniformSpace α] [UniformSpace β] :\n    UniformContinuous fun p : α × β => p.2 :=\n  tendsto_prod_uniformity_snd\n#align uniform_continuous_snd uniformContinuous_snd\n\nvariable [UniformSpace α] [UniformSpace β] [UniformSpace γ]\n\n/- warning: uniform_continuous.prod_mk -> UniformContinuous.prod_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f₁ : α -> β} {f₂ : α -> γ}, (UniformContinuous.{u1, u2} α β _inst_1 _inst_2 f₁) -> (UniformContinuous.{u1, u3} α γ _inst_1 _inst_3 f₂) -> (UniformContinuous.{u1, max u2 u3} α (Prod.{u2, u3} β γ) _inst_1 (Prod.uniformSpace.{u2, u3} β γ _inst_2 _inst_3) (fun (a : α) => Prod.mk.{u2, u3} β γ (f₁ a) (f₂ a)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f₁ : α -> β} {f₂ : α -> γ}, (UniformContinuous.{u1, u2} α β _inst_1 _inst_2 f₁) -> (UniformContinuous.{u1, u3} α γ _inst_1 _inst_3 f₂) -> (UniformContinuous.{u1, max u3 u2} α (Prod.{u2, u3} β γ) _inst_1 (instUniformSpaceProd.{u2, u3} β γ _inst_2 _inst_3) (fun (a : α) => Prod.mk.{u2, u3} β γ (f₁ a) (f₂ a)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_mk UniformContinuous.prod_mkₓ'. -/\ntheorem UniformContinuous.prod_mk {f₁ : α → β} {f₂ : α → γ} (h₁ : UniformContinuous f₁)\n    (h₂ : UniformContinuous f₂) : UniformContinuous fun a => (f₁ a, f₂ a) := by\n  rw [UniformContinuous, uniformity_prod] <;>\n    exact tendsto_inf.2 ⟨tendsto_comap_iff.2 h₁, tendsto_comap_iff.2 h₂⟩\n#align uniform_continuous.prod_mk UniformContinuous.prod_mk\n\n/- warning: uniform_continuous.prod_mk_left -> UniformContinuous.prod_mk_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f : (Prod.{u1, u2} α β) -> γ}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) _inst_3 f) -> (forall (b : β), UniformContinuous.{u1, u3} α γ _inst_1 _inst_3 (fun (a : α) => f (Prod.mk.{u1, u2} α β a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f : (Prod.{u1, u2} α β) -> γ}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) _inst_3 f) -> (forall (b : β), UniformContinuous.{u1, u3} α γ _inst_1 _inst_3 (fun (a : α) => f (Prod.mk.{u1, u2} α β a b)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_mk_left UniformContinuous.prod_mk_leftₓ'. -/\ntheorem UniformContinuous.prod_mk_left {f : α × β → γ} (h : UniformContinuous f) (b) :\n    UniformContinuous fun a => f (a, b) :=\n  h.comp (uniformContinuous_id.prod_mk uniformContinuous_const)\n#align uniform_continuous.prod_mk_left UniformContinuous.prod_mk_left\n\n/- warning: uniform_continuous.prod_mk_right -> UniformContinuous.prod_mk_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f : (Prod.{u1, u2} α β) -> γ}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) _inst_3 f) -> (forall (a : α), UniformContinuous.{u2, u3} β γ _inst_2 _inst_3 (fun (b : β) => f (Prod.mk.{u1, u2} α β a b)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f : (Prod.{u1, u2} α β) -> γ}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) _inst_3 f) -> (forall (a : α), UniformContinuous.{u2, u3} β γ _inst_2 _inst_3 (fun (b : β) => f (Prod.mk.{u1, u2} α β a b)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_mk_right UniformContinuous.prod_mk_rightₓ'. -/\ntheorem UniformContinuous.prod_mk_right {f : α × β → γ} (h : UniformContinuous f) (a) :\n    UniformContinuous fun b => f (a, b) :=\n  h.comp (uniformContinuous_const.prod_mk uniformContinuous_id)\n#align uniform_continuous.prod_mk_right UniformContinuous.prod_mk_right\n\n/- warning: uniform_continuous.prod_map -> UniformContinuous.prod_map is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] [_inst_4 : UniformSpace.{u4} δ] {f : α -> γ} {g : β -> δ}, (UniformContinuous.{u1, u3} α γ _inst_1 _inst_3 f) -> (UniformContinuous.{u2, u4} β δ _inst_2 _inst_4 g) -> (UniformContinuous.{max u1 u2, max u3 u4} (Prod.{u1, u2} α β) (Prod.{u3, u4} γ δ) (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) (Prod.uniformSpace.{u3, u4} γ δ _inst_3 _inst_4) (Prod.map.{u1, u3, u2, u4} α γ β δ f g))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] [_inst_4 : UniformSpace.{u4} δ] {f : α -> γ} {g : β -> δ}, (UniformContinuous.{u1, u3} α γ _inst_1 _inst_3 f) -> (UniformContinuous.{u2, u4} β δ _inst_2 _inst_4 g) -> (UniformContinuous.{max u2 u1, max u4 u3} (Prod.{u1, u2} α β) (Prod.{u3, u4} γ δ) (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) (instUniformSpaceProd.{u3, u4} γ δ _inst_3 _inst_4) (Prod.map.{u1, u3, u2, u4} α γ β δ f g))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_map UniformContinuous.prod_mapₓ'. -/\ntheorem UniformContinuous.prod_map [UniformSpace δ] {f : α → γ} {g : β → δ}\n    (hf : UniformContinuous f) (hg : UniformContinuous g) : UniformContinuous (Prod.map f g) :=\n  (hf.comp uniformContinuous_fst).prod_mk (hg.comp uniformContinuous_snd)\n#align uniform_continuous.prod_map UniformContinuous.prod_map\n\n/- warning: to_topological_space_prod -> toTopologicalSpace_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [u : UniformSpace.{u1} α] [v : UniformSpace.{u2} β], Eq.{succ (max u1 u2)} (TopologicalSpace.{max u1 u2} (Prod.{u1, u2} α β)) (UniformSpace.toTopologicalSpace.{max u1 u2} (Prod.{u1, u2} α β) (Prod.uniformSpace.{u1, u2} α β u v)) (Prod.topologicalSpace.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α u) (UniformSpace.toTopologicalSpace.{u2} β v))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [u : UniformSpace.{u2} α] [v : UniformSpace.{u1} β], Eq.{max (succ u2) (succ u1)} (TopologicalSpace.{max u1 u2} (Prod.{u2, u1} α β)) (UniformSpace.toTopologicalSpace.{max u1 u2} (Prod.{u2, u1} α β) (instUniformSpaceProd.{u2, u1} α β u v)) (instTopologicalSpaceProd.{u2, u1} α β (UniformSpace.toTopologicalSpace.{u2} α u) (UniformSpace.toTopologicalSpace.{u1} β v))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_prod toTopologicalSpace_prodₓ'. -/\ntheorem toTopologicalSpace_prod {α} {β} [u : UniformSpace α] [v : UniformSpace β] :\n    @UniformSpace.toTopologicalSpace (α × β) Prod.uniformSpace =\n      @Prod.topologicalSpace α β u.toTopologicalSpace v.toTopologicalSpace :=\n  rfl\n#align to_topological_space_prod toTopologicalSpace_prod\n\n/- warning: uniform_continuous_inf_dom_left₂ -> uniformContinuous_inf_dom_left₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> β -> γ} {ua1 : UniformSpace.{u1} α} {ua2 : UniformSpace.{u1} α} {ub1 : UniformSpace.{u2} β} {ub2 : UniformSpace.{u2} β} {uc1 : UniformSpace.{u3} γ}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β ua1 ub1) uc1 (fun (p : Prod.{u1, u2} α β) => f (Prod.fst.{u1, u2} α β p) (Prod.snd.{u1, u2} α β p))) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β (Inf.inf.{u1} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} β) (UniformSpace.hasInf.{u2} β) ub1 ub2)) uc1 (fun (p : Prod.{u1, u2} α β) => f (Prod.fst.{u1, u2} α β p) (Prod.snd.{u1, u2} α β p)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} {f : α -> β -> γ} {ua1 : UniformSpace.{u3} α} {ua2 : UniformSpace.{u3} α} {ub1 : UniformSpace.{u2} β} {ub2 : UniformSpace.{u2} β} {uc1 : UniformSpace.{u1} γ}, (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} α β) γ (instUniformSpaceProd.{u3, u2} α β ua1 ub1) uc1 (fun (p : Prod.{u3, u2} α β) => f (Prod.fst.{u3, u2} α β p) (Prod.snd.{u3, u2} α β p))) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} α β) γ (instUniformSpaceProd.{u3, u2} α β (Inf.inf.{u3} (UniformSpace.{u3} α) (instInfUniformSpace.{u3} α) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} β) (instInfUniformSpace.{u2} β) ub1 ub2)) uc1 (fun (p : Prod.{u3, u2} α β) => f (Prod.fst.{u3, u2} α β p) (Prod.snd.{u3, u2} α β p)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_inf_dom_left₂ uniformContinuous_inf_dom_left₂ₓ'. -/\n/-- A version of `uniform_continuous_inf_dom_left` for binary functions -/\ntheorem uniformContinuous_inf_dom_left₂ {α β γ} {f : α → β → γ} {ua1 ua2 : UniformSpace α}\n    {ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ}\n    (h : by haveI := ua1 <;> haveI := ub1 <;> exact UniformContinuous fun p : α × β => f p.1 p.2) :\n    by\n    haveI := ua1 ⊓ ua2 <;> haveI := ub1 ⊓ ub2 <;>\n      exact UniformContinuous fun p : α × β => f p.1 p.2 :=\n  by\n  -- proof essentially copied from ``continuous_inf_dom_left₂`\n  have ha := @UniformContinuous.inf_dom_left _ _ id ua1 ua2 ua1 (@uniformContinuous_id _ (id _))\n  have hb := @UniformContinuous.inf_dom_left _ _ id ub1 ub2 ub1 (@uniformContinuous_id _ (id _))\n  have h_unif_cont_id :=\n    @UniformContinuous.prod_map _ _ _ _ (ua1 ⊓ ua2) (ub1 ⊓ ub2) ua1 ub1 _ _ ha hb\n  exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id\n#align uniform_continuous_inf_dom_left₂ uniformContinuous_inf_dom_left₂\n\n/- warning: uniform_continuous_inf_dom_right₂ -> uniformContinuous_inf_dom_right₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> β -> γ} {ua1 : UniformSpace.{u1} α} {ua2 : UniformSpace.{u1} α} {ub1 : UniformSpace.{u2} β} {ub2 : UniformSpace.{u2} β} {uc1 : UniformSpace.{u3} γ}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β ua2 ub2) uc1 (fun (p : Prod.{u1, u2} α β) => f (Prod.fst.{u1, u2} α β p) (Prod.snd.{u1, u2} α β p))) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β (Inf.inf.{u1} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} β) (UniformSpace.hasInf.{u2} β) ub1 ub2)) uc1 (fun (p : Prod.{u1, u2} α β) => f (Prod.fst.{u1, u2} α β p) (Prod.snd.{u1, u2} α β p)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} {f : α -> β -> γ} {ua1 : UniformSpace.{u3} α} {ua2 : UniformSpace.{u3} α} {ub1 : UniformSpace.{u2} β} {ub2 : UniformSpace.{u2} β} {uc1 : UniformSpace.{u1} γ}, (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} α β) γ (instUniformSpaceProd.{u3, u2} α β ua2 ub2) uc1 (fun (p : Prod.{u3, u2} α β) => f (Prod.fst.{u3, u2} α β p) (Prod.snd.{u3, u2} α β p))) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} α β) γ (instUniformSpaceProd.{u3, u2} α β (Inf.inf.{u3} (UniformSpace.{u3} α) (instInfUniformSpace.{u3} α) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} β) (instInfUniformSpace.{u2} β) ub1 ub2)) uc1 (fun (p : Prod.{u3, u2} α β) => f (Prod.fst.{u3, u2} α β p) (Prod.snd.{u3, u2} α β p)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_inf_dom_right₂ uniformContinuous_inf_dom_right₂ₓ'. -/\n/-- A version of `uniform_continuous_inf_dom_right` for binary functions -/\ntheorem uniformContinuous_inf_dom_right₂ {α β γ} {f : α → β → γ} {ua1 ua2 : UniformSpace α}\n    {ub1 ub2 : UniformSpace β} {uc1 : UniformSpace γ}\n    (h : by haveI := ua2 <;> haveI := ub2 <;> exact UniformContinuous fun p : α × β => f p.1 p.2) :\n    by\n    haveI := ua1 ⊓ ua2 <;> haveI := ub1 ⊓ ub2 <;>\n      exact UniformContinuous fun p : α × β => f p.1 p.2 :=\n  by\n  -- proof essentially copied from ``continuous_inf_dom_right₂`\n  have ha := @UniformContinuous.inf_dom_right _ _ id ua1 ua2 ua2 (@uniformContinuous_id _ (id _))\n  have hb := @UniformContinuous.inf_dom_right _ _ id ub1 ub2 ub2 (@uniformContinuous_id _ (id _))\n  have h_unif_cont_id :=\n    @UniformContinuous.prod_map _ _ _ _ (ua1 ⊓ ua2) (ub1 ⊓ ub2) ua2 ub2 _ _ ha hb\n  exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id\n#align uniform_continuous_inf_dom_right₂ uniformContinuous_inf_dom_right₂\n\n/- warning: uniform_continuous_Inf_dom₂ -> uniformContinuous_infₛ_dom₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> β -> γ} {uas : Set.{u1} (UniformSpace.{u1} α)} {ubs : Set.{u2} (UniformSpace.{u2} β)} {ua : UniformSpace.{u1} α} {ub : UniformSpace.{u2} β} {uc : UniformSpace.{u3} γ}, (Membership.Mem.{u1, u1} (UniformSpace.{u1} α) (Set.{u1} (UniformSpace.{u1} α)) (Set.hasMem.{u1} (UniformSpace.{u1} α)) ua uas) -> (Membership.Mem.{u2, u2} (UniformSpace.{u2} β) (Set.{u2} (UniformSpace.{u2} β)) (Set.hasMem.{u2} (UniformSpace.{u2} β)) ub ubs) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β ua ub) uc (fun (p : Prod.{u1, u2} α β) => f (Prod.fst.{u1, u2} α β p) (Prod.snd.{u1, u2} α β p))) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β (InfSet.infₛ.{u1} (UniformSpace.{u1} α) (UniformSpace.hasInf.{u1} α) uas) (InfSet.infₛ.{u2} (UniformSpace.{u2} β) (UniformSpace.hasInf.{u2} β) ubs)) uc (fun (p : Prod.{u1, u2} α β) => f (Prod.fst.{u1, u2} α β p) (Prod.snd.{u1, u2} α β p)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} {f : α -> β -> γ} {uas : Set.{u3} (UniformSpace.{u3} α)} {ubs : Set.{u2} (UniformSpace.{u2} β)} {ua : UniformSpace.{u3} α} {ub : UniformSpace.{u2} β} {uc : UniformSpace.{u1} γ}, (Membership.mem.{u3, u3} (UniformSpace.{u3} α) (Set.{u3} (UniformSpace.{u3} α)) (Set.instMembershipSet.{u3} (UniformSpace.{u3} α)) ua uas) -> (Membership.mem.{u2, u2} (UniformSpace.{u2} β) (Set.{u2} (UniformSpace.{u2} β)) (Set.instMembershipSet.{u2} (UniformSpace.{u2} β)) ub ubs) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} α β) γ (instUniformSpaceProd.{u3, u2} α β ua ub) uc (fun (p : Prod.{u3, u2} α β) => f (Prod.fst.{u3, u2} α β p) (Prod.snd.{u3, u2} α β p))) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} α β) γ (instUniformSpaceProd.{u3, u2} α β (InfSet.infₛ.{u3} (UniformSpace.{u3} α) (instInfSetUniformSpace.{u3} α) uas) (InfSet.infₛ.{u2} (UniformSpace.{u2} β) (instInfSetUniformSpace.{u2} β) ubs)) uc (fun (p : Prod.{u3, u2} α β) => f (Prod.fst.{u3, u2} α β p) (Prod.snd.{u3, u2} α β p)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_Inf_dom₂ uniformContinuous_infₛ_dom₂ₓ'. -/\n/-- A version of `uniform_continuous_Inf_dom` for binary functions -/\ntheorem uniformContinuous_infₛ_dom₂ {α β γ} {f : α → β → γ} {uas : Set (UniformSpace α)}\n    {ubs : Set (UniformSpace β)} {ua : UniformSpace α} {ub : UniformSpace β} {uc : UniformSpace γ}\n    (ha : ua ∈ uas) (hb : ub ∈ ubs) (hf : UniformContinuous fun p : α × β => f p.1 p.2) : by\n    haveI := Inf uas <;> haveI := Inf ubs <;>\n      exact @UniformContinuous _ _ _ uc fun p : α × β => f p.1 p.2 :=\n  by\n  -- proof essentially copied from ``continuous_Inf_dom`\n  let t : UniformSpace (α × β) := Prod.uniformSpace\n  have ha := uniformContinuous_infₛ_dom ha uniformContinuous_id\n  have hb := uniformContinuous_infₛ_dom hb uniformContinuous_id\n  have h_unif_cont_id := @UniformContinuous.prod_map _ _ _ _ (Inf uas) (Inf ubs) ua ub _ _ ha hb\n  exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ hf h_unif_cont_id\n#align uniform_continuous_Inf_dom₂ uniformContinuous_infₛ_dom₂\n\nend Prod\n\nsection\n\nopen UniformSpace Function\n\nvariable {δ' : Type _} [UniformSpace α] [UniformSpace β] [UniformSpace γ] [UniformSpace δ]\n  [UniformSpace δ']\n\n-- mathport name: «expr ∘₂ »\nlocal notation f \" ∘₂ \" g => Function.bicompr f g\n\n#print UniformContinuous₂ /-\n/-- Uniform continuity for functions of two variables. -/\ndef UniformContinuous₂ (f : α → β → γ) :=\n  UniformContinuous (uncurry f)\n#align uniform_continuous₂ UniformContinuous₂\n-/\n\n/- warning: uniform_continuous₂_def -> uniformContinuous₂_def is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] (f : α -> β -> γ), Iff (UniformContinuous₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f) (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} α β γ f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] (f : α -> β -> γ), Iff (UniformContinuous₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f) (UniformContinuous.{max u2 u1, u3} (Prod.{u1, u2} α β) γ (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} α β γ f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous₂_def uniformContinuous₂_defₓ'. -/\ntheorem uniformContinuous₂_def (f : α → β → γ) :\n    UniformContinuous₂ f ↔ UniformContinuous (uncurry f) :=\n  Iff.rfl\n#align uniform_continuous₂_def uniformContinuous₂_def\n\n/- warning: uniform_continuous₂.uniform_continuous -> UniformContinuous₂.uniformContinuous is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f : α -> β -> γ}, (UniformContinuous₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} α β γ f))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] {f : α -> β -> γ}, (UniformContinuous₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{max u2 u1, u3} (Prod.{u1, u2} α β) γ (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} α β γ f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous₂.uniform_continuous UniformContinuous₂.uniformContinuousₓ'. -/\ntheorem UniformContinuous₂.uniformContinuous {f : α → β → γ} (h : UniformContinuous₂ f) :\n    UniformContinuous (uncurry f) :=\n  h\n#align uniform_continuous₂.uniform_continuous UniformContinuous₂.uniformContinuous\n\n/- warning: uniform_continuous₂_curry -> uniformContinuous₂_curry is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] (f : (Prod.{u1, u2} α β) -> γ), Iff (UniformContinuous₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 (Function.curry.{u1, u2, u3} α β γ f)) (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (Prod.uniformSpace.{u1, u2} α β _inst_1 _inst_2) _inst_3 f)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] (f : (Prod.{u1, u2} α β) -> γ), Iff (UniformContinuous₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 (Function.curry.{u1, u2, u3} α β γ f)) (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (instUniformSpaceProd.{u1, u2} α β _inst_1 _inst_2) _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous₂_curry uniformContinuous₂_curryₓ'. -/\ntheorem uniformContinuous₂_curry (f : α × β → γ) :\n    UniformContinuous₂ (Function.curry f) ↔ UniformContinuous f := by\n  rw [UniformContinuous₂, uncurry_curry]\n#align uniform_continuous₂_curry uniformContinuous₂_curry\n\n#print UniformContinuous₂.comp /-\ntheorem UniformContinuous₂.comp {f : α → β → γ} {g : γ → δ} (hg : UniformContinuous g)\n    (hf : UniformContinuous₂ f) : UniformContinuous₂ (g ∘₂ f) :=\n  hg.comp hf\n#align uniform_continuous₂.comp UniformContinuous₂.comp\n-/\n\n/- warning: uniform_continuous₂.bicompl -> UniformContinuous₂.bicompl is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {δ' : Type.{u5}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] [_inst_3 : UniformSpace.{u3} γ] [_inst_4 : UniformSpace.{u4} δ] [_inst_5 : UniformSpace.{u5} δ'] {f : α -> β -> γ} {ga : δ -> α} {gb : δ' -> β}, (UniformContinuous₂.{u1, u2, u3} α β γ _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{u4, u1} δ α _inst_4 _inst_1 ga) -> (UniformContinuous.{u5, u2} δ' β _inst_5 _inst_2 gb) -> (UniformContinuous₂.{u4, u5, u3} δ δ' γ _inst_4 _inst_5 _inst_3 (Function.bicompl.{u4, u5, u1, u2, u3} δ δ' α β γ f ga gb))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} {δ' : Type.{u1}} [_inst_1 : UniformSpace.{u2} α] [_inst_2 : UniformSpace.{u3} β] [_inst_3 : UniformSpace.{u4} γ] [_inst_4 : UniformSpace.{u5} δ] [_inst_5 : UniformSpace.{u1} δ'] {f : α -> β -> γ} {ga : δ -> α} {gb : δ' -> β}, (UniformContinuous₂.{u2, u3, u4} α β γ _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{u5, u2} δ α _inst_4 _inst_1 ga) -> (UniformContinuous.{u1, u3} δ' β _inst_5 _inst_2 gb) -> (UniformContinuous₂.{u5, u1, u4} δ δ' γ _inst_4 _inst_5 _inst_3 (Function.bicompl.{u5, u1, u2, u3, u4} δ δ' α β γ f ga gb))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous₂.bicompl UniformContinuous₂.bicomplₓ'. -/\ntheorem UniformContinuous₂.bicompl {f : α → β → γ} {ga : δ → α} {gb : δ' → β}\n    (hf : UniformContinuous₂ f) (hga : UniformContinuous ga) (hgb : UniformContinuous gb) :\n    UniformContinuous₂ (bicompl f ga gb) :=\n  hf.UniformContinuous.comp (hga.Prod_map hgb)\n#align uniform_continuous₂.bicompl UniformContinuous₂.bicompl\n\nend\n\n#print toTopologicalSpace_subtype /-\ntheorem toTopologicalSpace_subtype [u : UniformSpace α] {p : α → Prop} :\n    @UniformSpace.toTopologicalSpace (Subtype p) Subtype.uniformSpace =\n      @Subtype.topologicalSpace α p u.toTopologicalSpace :=\n  rfl\n#align to_topological_space_subtype toTopologicalSpace_subtype\n-/\n\nsection Sum\n\nvariable [UniformSpace α] [UniformSpace β]\n\nopen Sum\n\n#print UniformSpace.Core.sum /-\n/-- Uniformity on a disjoint union. Entourages of the diagonal in the union are obtained\nby taking independently an entourage of the diagonal in the first part, and an entourage of\nthe diagonal in the second part. -/\ndef UniformSpace.Core.sum : UniformSpace.Core (Sum α β) :=\n  UniformSpace.Core.mk'\n    (map (fun p : α × α => (inl p.1, inl p.2)) (𝓤 α) ⊔\n      map (fun p : β × β => (inr p.1, inr p.2)) (𝓤 β))\n    (fun r ⟨H₁, H₂⟩ x => by\n      cases x <;> [apply refl_mem_uniformity H₁, apply refl_mem_uniformity H₂])\n    (fun r ⟨H₁, H₂⟩ => ⟨symm_le_uniformity H₁, symm_le_uniformity H₂⟩) fun r ⟨Hrα, Hrβ⟩ =>\n    by\n    rcases comp_mem_uniformity_sets Hrα with ⟨tα, htα, Htα⟩\n    rcases comp_mem_uniformity_sets Hrβ with ⟨tβ, htβ, Htβ⟩\n    refine'\n      ⟨_,\n        ⟨mem_map_iff_exists_image.2 ⟨tα, htα, subset_union_left _ _⟩,\n          mem_map_iff_exists_image.2 ⟨tβ, htβ, subset_union_right _ _⟩⟩,\n        _⟩\n    rintro ⟨_, _⟩ ⟨z, ⟨⟨a, b⟩, hab, ⟨⟩⟩ | ⟨⟨a, b⟩, hab, ⟨⟩⟩, ⟨⟨_, c⟩, hbc, ⟨⟩⟩ | ⟨⟨_, c⟩, hbc, ⟨⟩⟩⟩\n    · have A : (a, c) ∈ tα ○ tα := ⟨b, hab, hbc⟩\n      exact Htα A\n    · have A : (a, c) ∈ tβ ○ tβ := ⟨b, hab, hbc⟩\n      exact Htβ A\n#align uniform_space.core.sum UniformSpace.Core.sum\n-/\n\n/- warning: union_mem_uniformity_sum -> union_mem_uniformity_sum is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {a : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) a (uniformity.{u1} α _inst_1)) -> (forall {b : Set.{u2} (Prod.{u2, u2} β β)}, (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} β β)) (Filter.{u2} (Prod.{u2, u2} β β)) (Filter.hasMem.{u2} (Prod.{u2, u2} β β)) b (uniformity.{u2} β _inst_2)) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Union.union.{max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Set.hasUnion.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Set.image.{u1, max u1 u2} (Prod.{u1, u1} α α) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u1, u1} α α) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inl.{u1, u2} α β (Prod.fst.{u1, u1} α α p)) (Sum.inl.{u1, u2} α β (Prod.snd.{u1, u1} α α p))) a) (Set.image.{u2, max u1 u2} (Prod.{u2, u2} β β) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u2, u2} β β) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inr.{u1, u2} α β (Prod.fst.{u2, u2} β β p)) (Sum.inr.{u1, u2} α β (Prod.snd.{u2, u2} β β p))) b)) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} α β) (UniformSpace.Core.sum.{u1, u2} α β _inst_1 _inst_2))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {a : Set.{u1} (Prod.{u1, u1} α α)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) a (uniformity.{u1} α _inst_1)) -> (forall {b : Set.{u2} (Prod.{u2, u2} β β)}, (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} β β)) (Filter.{u2} (Prod.{u2, u2} β β)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} β β)) b (uniformity.{u2} β _inst_2)) -> (Membership.mem.{max u2 u1, max u1 u2} (Set.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Union.union.{max u2 u1} (Set.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Set.instUnionSet.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Set.image.{u1, max u2 u1} (Prod.{u1, u1} α α) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u1, u1} α α) => Prod.mk.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inl.{u1, u2} α β (Prod.fst.{u1, u1} α α p)) (Sum.inl.{u1, u2} α β (Prod.snd.{u1, u1} α α p))) a) (Set.image.{u2, max u1 u2} (Prod.{u2, u2} β β) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u2, u2} β β) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inr.{u1, u2} α β (Prod.fst.{u2, u2} β β p)) (Sum.inr.{u1, u2} α β (Prod.snd.{u2, u2} β β p))) b)) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} α β) (UniformSpace.Core.sum.{u1, u2} α β _inst_1 _inst_2))))\nCase conversion may be inaccurate. Consider using '#align union_mem_uniformity_sum union_mem_uniformity_sumₓ'. -/\n/-- The union of an entourage of the diagonal in each set of a disjoint union is again an entourage\nof the diagonal. -/\ntheorem union_mem_uniformity_sum {a : Set (α × α)} (ha : a ∈ 𝓤 α) {b : Set (β × β)} (hb : b ∈ 𝓤 β) :\n    (fun p : α × α => (inl p.1, inl p.2)) '' a ∪ (fun p : β × β => (inr p.1, inr p.2)) '' b ∈\n      (@UniformSpace.Core.sum α β _ _).uniformity :=\n  ⟨mem_map_iff_exists_image.2 ⟨_, ha, subset_union_left _ _⟩,\n    mem_map_iff_exists_image.2 ⟨_, hb, subset_union_right _ _⟩⟩\n#align union_mem_uniformity_sum union_mem_uniformity_sum\n\n/- warning: uniformity_sum_of_open_aux -> uniformity_sum_of_open_aux is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {s : Set.{max u1 u2} (Sum.{u1, u2} α β)}, (IsOpen.{max u1 u2} (Sum.{u1, u2} α β) (Sum.topologicalSpace.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_2)) s) -> (forall {x : Sum.{u1, u2} α β}, (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u1 u2} (Sum.{u1, u2} α β)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} α β)) x s) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (setOf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) x) -> (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u1 u2} (Sum.{u1, u2} α β)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} α β)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} α β) (UniformSpace.Core.sum.{u1, u2} α β _inst_1 _inst_2))))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {s : Set.{max u2 u1} (Sum.{u1, u2} α β)}, (IsOpen.{max u1 u2} (Sum.{u1, u2} α β) (instTopologicalSpaceSum.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_2)) s) -> (forall {x : Sum.{u1, u2} α β}, (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u2 u1} (Sum.{u1, u2} α β)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} α β)) x s) -> (Membership.mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (setOf.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) x) -> (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u2 u1} (Sum.{u1, u2} α β)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} α β)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} α β) (UniformSpace.Core.sum.{u1, u2} α β _inst_1 _inst_2))))\nCase conversion may be inaccurate. Consider using '#align uniformity_sum_of_open_aux uniformity_sum_of_open_auxₓ'. -/\n/- To prove that the topology defined by the uniform structure on the disjoint union coincides with\nthe disjoint union topology, we need two lemmas saying that open sets can be characterized by\nthe uniform structure -/\ntheorem uniformity_sum_of_open_aux {s : Set (Sum α β)} (hs : IsOpen s) {x : Sum α β} (xs : x ∈ s) :\n    { p : Sum α β × Sum α β | p.1 = x → p.2 ∈ s } ∈ (@UniformSpace.Core.sum α β _ _).uniformity :=\n  by\n  cases x\n  · refine'\n        mem_of_superset\n          (union_mem_uniformity_sum (mem_nhds_uniformity_iff_right.1 (IsOpen.mem_nhds hs.1 xs))\n            univ_mem)\n          (union_subset _ _) <;>\n      rintro _ ⟨⟨_, b⟩, h, ⟨⟩⟩ ⟨⟩\n    exact h rfl\n  · refine'\n        mem_of_superset\n          (union_mem_uniformity_sum univ_mem\n            (mem_nhds_uniformity_iff_right.1 (IsOpen.mem_nhds hs.2 xs)))\n          (union_subset _ _) <;>\n      rintro _ ⟨⟨a, _⟩, h, ⟨⟩⟩ ⟨⟩\n    exact h rfl\n#align uniformity_sum_of_open_aux uniformity_sum_of_open_aux\n\n/- warning: open_of_uniformity_sum_aux -> open_of_uniformity_sum_aux is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {s : Set.{max u1 u2} (Sum.{u1, u2} α β)}, (forall (x : Sum.{u1, u2} α β), (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u1 u2} (Sum.{u1, u2} α β)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} α β)) x s) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (setOf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) x) -> (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u1 u2} (Sum.{u1, u2} α β)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} α β)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} α β) (UniformSpace.Core.sum.{u1, u2} α β _inst_1 _inst_2)))) -> (IsOpen.{max u1 u2} (Sum.{u1, u2} α β) (Sum.topologicalSpace.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_2)) s)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β] {s : Set.{max u2 u1} (Sum.{u1, u2} α β)}, (forall (x : Sum.{u1, u2} α β), (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u2 u1} (Sum.{u1, u2} α β)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} α β)) x s) -> (Membership.mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (setOf.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) x) -> (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Set.{max u2 u1} (Sum.{u1, u2} α β)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} α β)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} α β) (UniformSpace.Core.sum.{u1, u2} α β _inst_1 _inst_2)))) -> (IsOpen.{max u1 u2} (Sum.{u1, u2} α β) (instTopologicalSpaceSum.{u1, u2} α β (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u2} β _inst_2)) s)\nCase conversion may be inaccurate. Consider using '#align open_of_uniformity_sum_aux open_of_uniformity_sum_auxₓ'. -/\ntheorem open_of_uniformity_sum_aux {s : Set (Sum α β)}\n    (hs :\n      ∀ x ∈ s,\n        { p : Sum α β × Sum α β | p.1 = x → p.2 ∈ s } ∈\n          (@UniformSpace.Core.sum α β _ _).uniformity) :\n    IsOpen s := by\n  constructor\n  · refine' (@isOpen_iff_mem_nhds α _ _).2 fun a ha => mem_nhds_uniformity_iff_right.2 _\n    rcases mem_map_iff_exists_image.1 (hs _ ha).1 with ⟨t, ht, st⟩\n    refine' mem_of_superset ht _\n    rintro p pt rfl\n    exact st ⟨_, pt, rfl⟩ rfl\n  · refine' (@isOpen_iff_mem_nhds β _ _).2 fun b hb => mem_nhds_uniformity_iff_right.2 _\n    rcases mem_map_iff_exists_image.1 (hs _ hb).2 with ⟨t, ht, st⟩\n    refine' mem_of_superset ht _\n    rintro p pt rfl\n    exact st ⟨_, pt, rfl⟩ rfl\n#align open_of_uniformity_sum_aux open_of_uniformity_sum_aux\n\n#print Sum.uniformSpace /-\n-- We can now define the uniform structure on the disjoint union\ninstance Sum.uniformSpace : UniformSpace (Sum α β)\n    where\n  toCore := UniformSpace.Core.sum\n  isOpen_uniformity s := ⟨uniformity_sum_of_open_aux, open_of_uniformity_sum_aux⟩\n#align sum.uniform_space Sum.uniformSpace\n-/\n\n/- warning: sum.uniformity -> Sum.uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (uniformity.{max u1 u2} (Sum.{u1, u2} α β) (Sum.uniformSpace.{u1, u2} α β _inst_1 _inst_2)) (Sup.sup.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (SemilatticeSup.toHasSup.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Lattice.toSemilatticeSup.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (ConditionallyCompleteLattice.toLattice.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (CompleteLattice.toConditionallyCompleteLattice.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.completeLattice.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))))))) (Filter.map.{u1, max u1 u2} (Prod.{u1, u1} α α) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u1, u1} α α) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inl.{u1, u2} α β (Prod.fst.{u1, u1} α α p)) (Sum.inl.{u1, u2} α β (Prod.snd.{u1, u1} α α p))) (uniformity.{u1} α _inst_1)) (Filter.map.{u2, max u1 u2} (Prod.{u2, u2} β β) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u2, u2} β β) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inr.{u1, u2} α β (Prod.fst.{u2, u2} β β p)) (Sum.inr.{u1, u2} α β (Prod.snd.{u2, u2} β β p))) (uniformity.{u2} β _inst_2)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : UniformSpace.{u2} β], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (uniformity.{max u2 u1} (Sum.{u1, u2} α β) (Sum.uniformSpace.{u1, u2} α β _inst_1 _inst_2)) (Sup.sup.{max u2 u1} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (SemilatticeSup.toSup.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Lattice.toSemilatticeSup.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (ConditionallyCompleteLattice.toLattice.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (CompleteLattice.toConditionallyCompleteLattice.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))) (Filter.instCompleteLatticeFilter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β))))))) (Filter.map.{u1, max u2 u1} (Prod.{u1, u1} α α) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u1, u1} α α) => Prod.mk.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inl.{u1, u2} α β (Prod.fst.{u1, u1} α α p)) (Sum.inl.{u1, u2} α β (Prod.snd.{u1, u1} α α p))) (uniformity.{u1} α _inst_1)) (Filter.map.{u2, max u1 u2} (Prod.{u2, u2} β β) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β)) (fun (p : Prod.{u2, u2} β β) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} α β) (Sum.{u1, u2} α β) (Sum.inr.{u1, u2} α β (Prod.fst.{u2, u2} β β p)) (Sum.inr.{u1, u2} α β (Prod.snd.{u2, u2} β β p))) (uniformity.{u2} β _inst_2)))\nCase conversion may be inaccurate. Consider using '#align sum.uniformity Sum.uniformityₓ'. -/\ntheorem Sum.uniformity :\n    𝓤 (Sum α β) =\n      map (fun p : α × α => (inl p.1, inl p.2)) (𝓤 α) ⊔\n        map (fun p : β × β => (inr p.1, inr p.2)) (𝓤 β) :=\n  rfl\n#align sum.uniformity Sum.uniformity\n\nend Sum\n\nend Constructions\n\n/- warning: lebesgue_number_lemma -> lebesgue_number_lemma is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α} {ι : Sort.{u2}} {c : ι -> (Set.{u1} α)}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s) -> (forall (i : ι), IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (c i)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionᵢ.{u1, u2} α ι (fun (i : ι) => c i))) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (n : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) n (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) n (uniformity.{u1} α _inst_1)) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{u2} ι (fun (i : ι) => HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (setOf.{u1} α (fun (y : α) => Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) n)) (c i))))))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : UniformSpace.{u2} α] {s : Set.{u2} α} {ι : Sort.{u1}} {c : ι -> (Set.{u2} α)}, (IsCompact.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) s) -> (forall (i : ι), IsOpen.{u2} α (UniformSpace.toTopologicalSpace.{u2} α _inst_1) (c i)) -> (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) s (Set.unionᵢ.{u2, u1} α ι (fun (i : ι) => c i))) -> (Exists.{succ u2} (Set.{u2} (Prod.{u2, u2} α α)) (fun (n : Set.{u2} (Prod.{u2, u2} α α)) => And (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} α α)) (Filter.{u2} (Prod.{u2, u2} α α)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} α α)) n (uniformity.{u2} α _inst_1)) (forall (x : α), (Membership.mem.{u2, u2} α (Set.{u2} α) (Set.instMembershipSet.{u2} α) x s) -> (Exists.{u1} ι (fun (i : ι) => HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (setOf.{u2} α (fun (y : α) => Membership.mem.{u2, u2} (Prod.{u2, u2} α α) (Set.{u2} (Prod.{u2, u2} α α)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} α α)) (Prod.mk.{u2, u2} α α x y) n)) (c i))))))\nCase conversion may be inaccurate. Consider using '#align lebesgue_number_lemma lebesgue_number_lemmaₓ'. -/\n/-- Let `c : ι → set α` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `c i`. -/\ntheorem lebesgue_number_lemma {α : Type u} [UniformSpace α] {s : Set α} {ι} {c : ι → Set α}\n    (hs : IsCompact s) (hc₁ : ∀ i, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i, c i) :\n    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, { y | (x, y) ∈ n } ⊆ c i :=\n  by\n  let u n := { x | ∃ i, ∃ m ∈ 𝓤 α, { y | (x, y) ∈ m ○ n } ⊆ c i }\n  have hu₁ : ∀ n ∈ 𝓤 α, IsOpen (u n) :=\n    by\n    refine' fun n hn => isOpen_uniformity.2 _\n    rintro x ⟨i, m, hm, h⟩\n    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩\n    apply (𝓤 α).sets_of_superset hm'\n    rintro ⟨x, y⟩ hp rfl\n    refine' ⟨i, m', hm', fun z hz => h (monotone_id.comp_rel monotone_const mm' _)⟩\n    dsimp [-mem_compRel] at hz⊢\n    rw [compRel_assoc]\n    exact ⟨y, hp, hz⟩\n  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n := by\n    intro x hx\n    rcases mem_Union.1 (hc₂ hx) with ⟨i, h⟩\n    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩\n    exact mem_bUnion hm' ⟨i, _, hm', fun y hy => mm' hy rfl⟩\n  rcases hs.elim_finite_subcover_image hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩\n  refine' ⟨_, (bInter_mem b_fin).2 bu, fun x hx => _⟩\n  rcases mem_Union₂.1 (b_cover hx) with ⟨n, bn, i, m, hm, h⟩\n  refine' ⟨i, fun y hy => h _⟩\n  exact prod_mk_mem_compRel (refl_mem_uniformity hm) (bInter_subset_of_mem bn hy)\n#align lebesgue_number_lemma lebesgue_number_lemma\n\n/- warning: lebesgue_number_lemma_sUnion -> lebesgue_number_lemma_unionₛ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α} {c : Set.{u1} (Set.{u1} α)}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s) -> (forall (t : Set.{u1} α), (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t c) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) t)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) s (Set.unionₛ.{u1} α c)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (n : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) n (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) n (uniformity.{u1} α _inst_1)) => forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t c) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.hasMem.{u1} (Set.{u1} α)) t c) => forall (y : α), (Membership.Mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.hasMem.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) n) -> (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) y t)))))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {s : Set.{u1} α} {c : Set.{u1} (Set.{u1} α)}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) s) -> (forall (t : Set.{u1} α), (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) t c) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) t)) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) s (Set.unionₛ.{u1} α c)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (n : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) n (uniformity.{u1} α _inst_1)) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x s) -> (Exists.{succ u1} (Set.{u1} α) (fun (t : Set.{u1} α) => And (Membership.mem.{u1, u1} (Set.{u1} α) (Set.{u1} (Set.{u1} α)) (Set.instMembershipSet.{u1} (Set.{u1} α)) t c) (forall (y : α), (Membership.mem.{u1, u1} (Prod.{u1, u1} α α) (Set.{u1} (Prod.{u1, u1} α α)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} α α)) (Prod.mk.{u1, u1} α α x y) n) -> (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) y t)))))))\nCase conversion may be inaccurate. Consider using '#align lebesgue_number_lemma_sUnion lebesgue_number_lemma_unionₛₓ'. -/\n/-- Let `c : set (set α)` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x ∈ s` its `n`-neighborhood is contained in some `t ∈ c`. -/\ntheorem lebesgue_number_lemma_unionₛ {α : Type u} [UniformSpace α] {s : Set α} {c : Set (Set α)}\n    (hs : IsCompact s) (hc₁ : ∀ t ∈ c, IsOpen t) (hc₂ : s ⊆ ⋃₀ c) :\n    ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ y, (x, y) ∈ n → y ∈ t := by\n  rw [sUnion_eq_Union] at hc₂ <;> simpa using lebesgue_number_lemma hs (by simpa) hc₂\n#align lebesgue_number_lemma_sUnion lebesgue_number_lemma_unionₛ\n\n/- warning: lebesgue_number_of_compact_open -> lebesgue_number_of_compact_open is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {K : Set.{u1} α} {U : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) K) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) U) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) K U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (Filter.hasMem.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) => And (IsOpen.{u1} (Prod.{u1, u1} α α) (Prod.topologicalSpace.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) (forall (x : α), (Membership.Mem.{u1, u1} α (Set.{u1} α) (Set.hasMem.{u1} α) x K) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (UniformSpace.ball.{u1} α x V) U)))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : UniformSpace.{u1} α] {K : Set.{u1} α} {U : Set.{u1} α}, (IsCompact.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) K) -> (IsOpen.{u1} α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) U) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) K U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} α α)) (fun (V : Set.{u1} (Prod.{u1, u1} α α)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} α α)) (Filter.{u1} (Prod.{u1, u1} α α)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} α α)) V (uniformity.{u1} α _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} α α) (instTopologicalSpaceProd.{u1, u1} α α (UniformSpace.toTopologicalSpace.{u1} α _inst_1) (UniformSpace.toTopologicalSpace.{u1} α _inst_1)) V) (forall (x : α), (Membership.mem.{u1, u1} α (Set.{u1} α) (Set.instMembershipSet.{u1} α) x K) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (UniformSpace.ball.{u1} α x V) U)))))\nCase conversion may be inaccurate. Consider using '#align lebesgue_number_of_compact_open lebesgue_number_of_compact_openₓ'. -/\n/-- A useful consequence of the Lebesgue number lemma: given any compact set `K` contained in an\nopen set `U`, we can find an (open) entourage `V` such that the ball of size `V` about any point of\n`K` is contained in `U`. -/\ntheorem lebesgue_number_of_compact_open [UniformSpace α] {K U : Set α} (hK : IsCompact K)\n    (hU : IsOpen U) (hKU : K ⊆ U) : ∃ V ∈ 𝓤 α, IsOpen V ∧ ∀ x ∈ K, UniformSpace.ball x V ⊆ U :=\n  by\n  let W : K → Set (α × α) := fun k =>\n    Classical.choose <| is_open_iff_open_ball_subset.mp hU k.1 <| hKU k.2\n  have hW : ∀ k, W k ∈ 𝓤 α ∧ IsOpen (W k) ∧ UniformSpace.ball k.1 (W k) ⊆ U :=\n    by\n    intro k\n    obtain ⟨h₁, h₂, h₃⟩ := Classical.choose_spec (is_open_iff_open_ball_subset.mp hU k.1 (hKU k.2))\n    exact ⟨h₁, h₂, h₃⟩\n  let c : K → Set α := fun k => UniformSpace.ball k.1 (W k)\n  have hc₁ : ∀ k, IsOpen (c k) := fun k => UniformSpace.isOpen_ball k.1 (hW k).2.1\n  have hc₂ : K ⊆ ⋃ i, c i := by\n    intro k hk\n    simp only [mem_Union, SetCoe.exists]\n    exact ⟨k, hk, UniformSpace.mem_ball_self k (hW ⟨k, hk⟩).1⟩\n  have hc₃ : ∀ k, c k ⊆ U := fun k => (hW k).2.2\n  obtain ⟨V, hV, hV'⟩ := lebesgue_number_lemma hK hc₁ hc₂\n  refine' ⟨interior V, interior_mem_uniformity hV, isOpen_interior, _⟩\n  intro k hk\n  obtain ⟨k', hk'⟩ := hV' k hk\n  exact ((ball_mono interior_subset k).trans hk').trans (hc₃ k')\n#align lebesgue_number_of_compact_open lebesgue_number_of_compact_open\n\n/-!\n### Expressing continuity properties in uniform spaces\n\nWe reformulate the various continuity properties of functions taking values in a uniform space\nin terms of the uniformity in the target. Since the same lemmas (essentially with the same names)\nalso exist for metric spaces and emetric spaces (reformulating things in terms of the distance or\nthe edistance in the target), we put them in a namespace `uniform` here.\n\nIn the metric and emetric space setting, there are also similar lemmas where one assumes that\nboth the source and the target are metric spaces, reformulating things in terms of the distance\non both sides. These lemmas are generally written without primes, and the versions where only\nthe target is a metric space is primed. We follow the same convention here, thus giving lemmas\nwith primes.\n-/\n\n\nnamespace Uniform\n\nvariable [UniformSpace α]\n\n#print Uniform.tendsto_nhds_right /-\ntheorem tendsto_nhds_right {f : Filter β} {u : β → α} {a : α} :\n    Tendsto u f (𝓝 a) ↔ Tendsto (fun x => (a, u x)) f (𝓤 α) := by\n  rw [nhds_eq_comap_uniformity, tendsto_comap_iff]\n#align uniform.tendsto_nhds_right Uniform.tendsto_nhds_right\n-/\n\n#print Uniform.tendsto_nhds_left /-\ntheorem tendsto_nhds_left {f : Filter β} {u : β → α} {a : α} :\n    Tendsto u f (𝓝 a) ↔ Tendsto (fun x => (u x, a)) f (𝓤 α) := by\n  rw [nhds_eq_comap_uniformity', tendsto_comap_iff]\n#align uniform.tendsto_nhds_left Uniform.tendsto_nhds_left\n-/\n\n#print Uniform.continuousAt_iff'_right /-\ntheorem continuousAt_iff'_right [TopologicalSpace β] {f : β → α} {b : β} :\n    ContinuousAt f b ↔ Tendsto (fun x => (f b, f x)) (𝓝 b) (𝓤 α) := by\n  rw [ContinuousAt, tendsto_nhds_right]\n#align uniform.continuous_at_iff'_right Uniform.continuousAt_iff'_right\n-/\n\n#print Uniform.continuousAt_iff'_left /-\ntheorem continuousAt_iff'_left [TopologicalSpace β] {f : β → α} {b : β} :\n    ContinuousAt f b ↔ Tendsto (fun x => (f x, f b)) (𝓝 b) (𝓤 α) := by\n  rw [ContinuousAt, tendsto_nhds_left]\n#align uniform.continuous_at_iff'_left Uniform.continuousAt_iff'_left\n-/\n\n/- warning: uniform.continuous_at_iff_prod -> Uniform.continuousAt_iff_prod is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {b : β}, Iff (ContinuousAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α _inst_1) f b) (Filter.Tendsto.{u2, u1} (Prod.{u2, u2} β β) (Prod.{u1, u1} α α) (fun (x : Prod.{u2, u2} β β) => Prod.mk.{u1, u1} α α (f (Prod.fst.{u2, u2} β β x)) (f (Prod.snd.{u2, u2} β β x))) (nhds.{u2} (Prod.{u2, u2} β β) (Prod.topologicalSpace.{u2, u2} β β _inst_2 _inst_2) (Prod.mk.{u2, u2} β β b b)) (uniformity.{u1} α _inst_1))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u1} α] [_inst_2 : TopologicalSpace.{u2} β] {f : β -> α} {b : β}, Iff (ContinuousAt.{u2, u1} β α _inst_2 (UniformSpace.toTopologicalSpace.{u1} α _inst_1) f b) (Filter.Tendsto.{u2, u1} (Prod.{u2, u2} β β) (Prod.{u1, u1} α α) (fun (x : Prod.{u2, u2} β β) => Prod.mk.{u1, u1} α α (f (Prod.fst.{u2, u2} β β x)) (f (Prod.snd.{u2, u2} β β x))) (nhds.{u2} (Prod.{u2, u2} β β) (instTopologicalSpaceProd.{u2, u2} β β _inst_2 _inst_2) (Prod.mk.{u2, u2} β β b b)) (uniformity.{u1} α _inst_1))\nCase conversion may be inaccurate. Consider using '#align uniform.continuous_at_iff_prod Uniform.continuousAt_iff_prodₓ'. -/\ntheorem continuousAt_iff_prod [TopologicalSpace β] {f : β → α} {b : β} :\n    ContinuousAt f b ↔ Tendsto (fun x : β × β => (f x.1, f x.2)) (𝓝 (b, b)) (𝓤 α) :=\n  ⟨fun H => le_trans (H.prod_map' H) (nhds_le_uniformity _), fun H =>\n    continuousAt_iff'_left.2 <| H.comp <| tendsto_id.prod_mk_nhds tendsto_const_nhds⟩\n#align uniform.continuous_at_iff_prod Uniform.continuousAt_iff_prod\n\n#print Uniform.continuousWithinAt_iff'_right /-\ntheorem continuousWithinAt_iff'_right [TopologicalSpace β] {f : β → α} {b : β} {s : Set β} :\n    ContinuousWithinAt f s b ↔ Tendsto (fun x => (f b, f x)) (𝓝[s] b) (𝓤 α) := by\n  rw [ContinuousWithinAt, tendsto_nhds_right]\n#align uniform.continuous_within_at_iff'_right Uniform.continuousWithinAt_iff'_right\n-/\n\n#print Uniform.continuousWithinAt_iff'_left /-\ntheorem continuousWithinAt_iff'_left [TopologicalSpace β] {f : β → α} {b : β} {s : Set β} :\n    ContinuousWithinAt f s b ↔ Tendsto (fun x => (f x, f b)) (𝓝[s] b) (𝓤 α) := by\n  rw [ContinuousWithinAt, tendsto_nhds_left]\n#align uniform.continuous_within_at_iff'_left Uniform.continuousWithinAt_iff'_left\n-/\n\n#print Uniform.continuousOn_iff'_right /-\ntheorem continuousOn_iff'_right [TopologicalSpace β] {f : β → α} {s : Set β} :\n    ContinuousOn f s ↔ ∀ b ∈ s, Tendsto (fun x => (f b, f x)) (𝓝[s] b) (𝓤 α) := by\n  simp [ContinuousOn, continuous_within_at_iff'_right]\n#align uniform.continuous_on_iff'_right Uniform.continuousOn_iff'_right\n-/\n\n#print Uniform.continuousOn_iff'_left /-\ntheorem continuousOn_iff'_left [TopologicalSpace β] {f : β → α} {s : Set β} :\n    ContinuousOn f s ↔ ∀ b ∈ s, Tendsto (fun x => (f x, f b)) (𝓝[s] b) (𝓤 α) := by\n  simp [ContinuousOn, continuous_within_at_iff'_left]\n#align uniform.continuous_on_iff'_left Uniform.continuousOn_iff'_left\n-/\n\n#print Uniform.continuous_iff'_right /-\ntheorem continuous_iff'_right [TopologicalSpace β] {f : β → α} :\n    Continuous f ↔ ∀ b, Tendsto (fun x => (f b, f x)) (𝓝 b) (𝓤 α) :=\n  continuous_iff_continuousAt.trans <| forall_congr' fun b => tendsto_nhds_right\n#align uniform.continuous_iff'_right Uniform.continuous_iff'_right\n-/\n\n#print Uniform.continuous_iff'_left /-\ntheorem continuous_iff'_left [TopologicalSpace β] {f : β → α} :\n    Continuous f ↔ ∀ b, Tendsto (fun x => (f x, f b)) (𝓝 b) (𝓤 α) :=\n  continuous_iff_continuousAt.trans <| forall_congr' fun b => tendsto_nhds_left\n#align uniform.continuous_iff'_left Uniform.continuous_iff'_left\n-/\n\nend Uniform\n\n/- warning: filter.tendsto.congr_uniformity -> Filter.Tendsto.congr_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u2} β] {f : α -> β} {g : α -> β} {l : Filter.{u1} α} {b : β}, (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_1) b)) -> (Filter.Tendsto.{u1, u2} α (Prod.{u2, u2} β β) (fun (x : α) => Prod.mk.{u2, u2} β β (f x) (g x)) l (uniformity.{u2} β _inst_1)) -> (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_1) b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : UniformSpace.{u1} β] {f : α -> β} {g : α -> β} {l : Filter.{u2} α} {b : β}, (Filter.Tendsto.{u2, u1} α β f l (nhds.{u1} β (UniformSpace.toTopologicalSpace.{u1} β _inst_1) b)) -> (Filter.Tendsto.{u2, u1} α (Prod.{u1, u1} β β) (fun (x : α) => Prod.mk.{u1, u1} β β (f x) (g x)) l (uniformity.{u1} β _inst_1)) -> (Filter.Tendsto.{u2, u1} α β g l (nhds.{u1} β (UniformSpace.toTopologicalSpace.{u1} β _inst_1) b))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.congr_uniformity Filter.Tendsto.congr_uniformityₓ'. -/\ntheorem Filter.Tendsto.congr_uniformity {α β} [UniformSpace β] {f g : α → β} {l : Filter α} {b : β}\n    (hf : Tendsto f l (𝓝 b)) (hg : Tendsto (fun x => (f x, g x)) l (𝓤 β)) : Tendsto g l (𝓝 b) :=\n  Uniform.tendsto_nhds_right.2 <| (Uniform.tendsto_nhds_right.1 hf).uniformity_trans hg\n#align filter.tendsto.congr_uniformity Filter.Tendsto.congr_uniformity\n\n/- warning: uniform.tendsto_congr -> Uniform.tendsto_congr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : UniformSpace.{u2} β] {f : α -> β} {g : α -> β} {l : Filter.{u1} α} {b : β}, (Filter.Tendsto.{u1, u2} α (Prod.{u2, u2} β β) (fun (x : α) => Prod.mk.{u2, u2} β β (f x) (g x)) l (uniformity.{u2} β _inst_1)) -> (Iff (Filter.Tendsto.{u1, u2} α β f l (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_1) b)) (Filter.Tendsto.{u1, u2} α β g l (nhds.{u2} β (UniformSpace.toTopologicalSpace.{u2} β _inst_1) b)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : UniformSpace.{u1} β] {f : α -> β} {g : α -> β} {l : Filter.{u2} α} {b : β}, (Filter.Tendsto.{u2, u1} α (Prod.{u1, u1} β β) (fun (x : α) => Prod.mk.{u1, u1} β β (f x) (g x)) l (uniformity.{u1} β _inst_1)) -> (Iff (Filter.Tendsto.{u2, u1} α β f l (nhds.{u1} β (UniformSpace.toTopologicalSpace.{u1} β _inst_1) b)) (Filter.Tendsto.{u2, u1} α β g l (nhds.{u1} β (UniformSpace.toTopologicalSpace.{u1} β _inst_1) b)))\nCase conversion may be inaccurate. Consider using '#align uniform.tendsto_congr Uniform.tendsto_congrₓ'. -/\ntheorem Uniform.tendsto_congr {α β} [UniformSpace β] {f g : α → β} {l : Filter α} {b : β}\n    (hfg : Tendsto (fun x => (f x, g x)) l (𝓤 β)) : Tendsto f l (𝓝 b) ↔ Tendsto g l (𝓝 b) :=\n  ⟨fun h => h.congr_uniformity hfg, fun h => h.congr_uniformity hfg.uniformity_symm⟩\n#align uniform.tendsto_congr Uniform.tendsto_congr\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Topology/UniformSpace/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45711361670559664}}
{"text": "theorem ex {i j : Fin n} (h : i = j) : i.val = j.val :=\n  h ▸ rfl\n\nattribute [-app_unexpander] unexpandEqNDRec\n\n#print ex\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/keyAttrErase.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.743167997235783, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45711360970792775}}
{"text": "/-\nCopyright (c) 2016 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport data.option.defs\nimport logic.nonempty\nimport tactic.cache\n\n/-!\n# Miscellaneous function constructions and lemmas\n-/\n\nuniverses u v w\n\nnamespace function\n\nsection\nvariables {α β γ : Sort*} {f : α → β}\n\n/-- Evaluate a function at an argument. Useful if you want to talk about the partially applied\n  `function.eval x : (Π x, β x) → β x`. -/\n@[reducible] def eval {β : α → Sort*} (x : α) (f : Π x, β x) : β x := f x\n\n@[simp] lemma eval_apply {β : α → Sort*} (x : α) (f : Π x, β x) : eval x f = f x := rfl\n\nlemma comp_apply {α : Sort u} {β : Sort v} {φ : Sort w} (f : β → φ) (g : α → β) (a : α) :\n  (f ∘ g) a = f (g a) := rfl\n\nlemma const_def {y : β} : (λ x : α, y) = const α y := rfl\n\n@[simp] lemma const_apply {y : β} {x : α} : const α y x = y := rfl\n\n@[simp] lemma const_comp {f : α → β} {c : γ} : const β c ∘ f = const α c := rfl\n\n@[simp] lemma comp_const {f : β → γ} {b : β} : f ∘ const α b = const α (f b) := rfl\n\nlemma id_def : @id α = λ x, x := rfl\n\nlemma hfunext {α α': Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : Πa, β a} {f' : Πa, β' a}\n  (hα : α = α') (h : ∀a a', a == a' → f a == f' a') : f == f' :=\nbegin\n  subst hα,\n  have : ∀a, f a == f' a,\n  { intro a, exact h a a (heq.refl a) },\n  have : β = β',\n  { funext a, exact type_eq_of_heq (this a) },\n  subst this,\n  apply heq_of_eq,\n  funext a,\n  exact eq_of_heq (this a)\nend\n\nlemma funext_iff {β : α → Sort*} {f₁ f₂ : Π (x : α), β x} : f₁ = f₂ ↔ (∀a, f₁ a = f₂ a) :=\niff.intro (assume h a, h ▸ rfl) funext\n\nprotected lemma bijective.injective {f : α → β} (hf : bijective f) : injective f := hf.1\nprotected lemma bijective.surjective {f : α → β} (hf : bijective f) : surjective f := hf.2\n\ntheorem injective.eq_iff (I : injective f) {a b : α} :\n  f a = f b ↔ a = b :=\n⟨@I _ _, congr_arg f⟩\n\ntheorem injective.eq_iff' (I : injective f) {a b : α} {c : β} (h : f b = c) :\n  f a = c ↔ a = b :=\nh ▸ I.eq_iff\n\nlemma injective.ne (hf : injective f) {a₁ a₂ : α} : a₁ ≠ a₂ → f a₁ ≠ f a₂ :=\nmt (assume h, hf h)\n\nlemma injective.ne_iff (hf : injective f) {x y : α} : f x ≠ f y ↔ x ≠ y :=\n⟨mt $ congr_arg f, hf.ne⟩\n\nlemma injective.ne_iff' (hf : injective f) {x y : α} {z : β} (h : f y = z) :\n  f x ≠ z ↔ x ≠ y :=\nh ▸ hf.ne_iff\n\n/-- If the co-domain `β` of an injective function `f : α → β` has decidable equality, then\nthe domain `α` also has decidable equality. -/\ndef injective.decidable_eq [decidable_eq β] (I : injective f) : decidable_eq α :=\nλ a b, decidable_of_iff _ I.eq_iff\n\nlemma injective.of_comp {g : γ → α} (I : injective (f ∘ g)) : injective g :=\nλ x y h, I $ show f (g x) = f (g y), from congr_arg f h\n\nlemma injective.of_comp_iff {f : α → β} (hf : injective f) (g : γ → α) :\n  injective (f ∘ g) ↔ injective g :=\n⟨injective.of_comp, hf.comp⟩\n\nlemma injective.of_comp_iff' (f : α → β) {g : γ → α} (hg : bijective g) :\n  injective (f ∘ g) ↔ injective f :=\n⟨ λ h x y, let ⟨x', hx⟩ := hg.surjective x, ⟨y', hy⟩ := hg.surjective y in\n    hx ▸ hy ▸ λ hf, h hf ▸ rfl,\n  λ h, h.comp hg.injective⟩\n\n/-- Composition by an injective function on the left is itself injective. -/\nlemma injective.comp_left {g : β → γ} (hg : function.injective g) :\n  function.injective ((∘) g : (α → β) → (α → γ)) :=\nλ f₁ f₂ hgf, funext $ λ i, hg $ (congr_fun hgf i : _)\n\nlemma injective_of_subsingleton [subsingleton α] (f : α → β) :\n  injective f :=\nλ a b ab, subsingleton.elim _ _\n\nlemma injective.dite (p : α → Prop) [decidable_pred p]\n  {f : {a : α // p a} → β} {f' : {a : α // ¬ p a} → β}\n  (hf : injective f) (hf' : injective f')\n  (im_disj : ∀ {x x' : α} {hx : p x} {hx' : ¬ p x'}, f ⟨x, hx⟩ ≠ f' ⟨x', hx'⟩) :\n  function.injective (λ x, if h : p x then f ⟨x, h⟩ else f' ⟨x, h⟩) :=\nλ x₁ x₂ h, begin\n  dsimp only at h,\n  by_cases h₁ : p x₁; by_cases h₂ : p x₂,\n  { rw [dif_pos h₁, dif_pos h₂] at h, injection (hf h), },\n  { rw [dif_pos h₁, dif_neg h₂] at h, exact (im_disj h).elim, },\n  { rw [dif_neg h₁, dif_pos h₂] at h, exact (im_disj h.symm).elim, },\n  { rw [dif_neg h₁, dif_neg h₂] at h, injection (hf' h), },\nend\n\nlemma surjective.of_comp {g : γ → α} (S : surjective (f ∘ g)) : surjective f :=\nλ y, let ⟨x, h⟩ := S y in ⟨g x, h⟩\n\nlemma surjective.of_comp_iff (f : α → β) {g : γ → α} (hg : surjective g) :\n  surjective (f ∘ g) ↔ surjective f :=\n⟨surjective.of_comp, λ h, h.comp hg⟩\n\nlemma surjective.of_comp_iff' (hf : bijective f) (g : γ → α) :\n  surjective (f ∘ g) ↔ surjective g :=\n⟨λ h x, let ⟨x', hx'⟩ := h (f x) in ⟨x', hf.injective hx'⟩, hf.surjective.comp⟩\n\ninstance decidable_eq_pfun (p : Prop) [decidable p] (α : p → Type*)\n  [Π hp, decidable_eq (α hp)] : decidable_eq (Π hp, α hp)\n| f g := decidable_of_iff (∀ hp, f hp = g hp) funext_iff.symm\n\nprotected theorem surjective.forall (hf : surjective f) {p : β → Prop} :\n  (∀ y, p y) ↔ ∀ x, p (f x) :=\n⟨λ h x, h (f x), λ h y, let ⟨x, hx⟩ := hf y in hx ▸ h x⟩\n\nprotected theorem surjective.forall₂ (hf : surjective f) {p : β → β → Prop} :\n  (∀ y₁ y₂, p y₁ y₂) ↔ ∀ x₁ x₂, p (f x₁) (f x₂) :=\nhf.forall.trans $ forall_congr $ λ x, hf.forall\n\nprotected theorem surjective.forall₃ (hf : surjective f) {p : β → β → β → Prop} :\n  (∀ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∀ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\nhf.forall.trans $ forall_congr $ λ x, hf.forall₂\n\nprotected theorem surjective.exists (hf : surjective f) {p : β → Prop} :\n  (∃ y, p y) ↔ ∃ x, p (f x) :=\n⟨λ ⟨y, hy⟩, let ⟨x, hx⟩ := hf y in ⟨x, hx.symm ▸ hy⟩, λ ⟨x, hx⟩, ⟨f x, hx⟩⟩\n\nprotected theorem surjective.exists₂ (hf : surjective f) {p : β → β → Prop} :\n  (∃ y₁ y₂, p y₁ y₂) ↔ ∃ x₁ x₂, p (f x₁) (f x₂) :=\nhf.exists.trans $ exists_congr $ λ x, hf.exists\n\nprotected theorem surjective.exists₃ (hf : surjective f) {p : β → β → β → Prop} :\n  (∃ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∃ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=\nhf.exists.trans $ exists_congr $ λ x, hf.exists₂\n\nlemma surjective.injective_comp_right (hf : surjective f) :\n  injective (λ g : β → γ, g ∘ f) :=\nλ g₁ g₂ h, funext $ hf.forall.2 $ congr_fun h\n\nprotected lemma surjective.right_cancellable (hf : surjective f) {g₁ g₂ : β → γ} :\n  g₁ ∘ f = g₂ ∘ f ↔ g₁ = g₂ :=\nhf.injective_comp_right.eq_iff\n\nlemma surjective_of_right_cancellable_Prop (h : ∀ g₁ g₂ : β → Prop, g₁ ∘ f = g₂ ∘ f → g₁ = g₂) :\n  surjective f :=\nbegin\n  specialize h (λ _, true) (λ y, ∃ x, f x = y) (funext $ λ x, _),\n  { simp only [(∘), exists_apply_eq_apply] },\n  { intro y,\n    have : true = ∃ x, f x = y, from congr_fun h y,\n    rw ← this, exact trivial }\nend\n\nlemma bijective_iff_exists_unique (f : α → β) : bijective f ↔\n  ∀ b : β, ∃! (a : α), f a = b :=\n⟨ λ hf b, let ⟨a, ha⟩ := hf.surjective b in ⟨a, ha, λ a' ha', hf.injective (ha'.trans ha.symm)⟩,\n  λ he, ⟨\n    λ a a' h, unique_of_exists_unique (he (f a')) h rfl,\n    λ b, exists_of_exists_unique (he b) ⟩⟩\n\n/-- Shorthand for using projection notation with `function.bijective_iff_exists_unique`. -/\nprotected lemma bijective.exists_unique {f : α → β} (hf : bijective f) (b : β) :\n  ∃! (a : α), f a = b :=\n(bijective_iff_exists_unique f).mp hf b\n\nlemma bijective.exists_unique_iff {f : α → β} (hf : bijective f) {p : β → Prop} :\n  (∃! y, p y) ↔ ∃! x, p (f x) :=\n⟨λ ⟨y, hpy, hy⟩, let ⟨x, hx⟩ := hf.surjective y in ⟨x, by rwa hx,\n  λ z (hz : p (f z)), hf.injective $ hx.symm ▸ hy _ hz⟩,\n  λ ⟨x, hpx, hx⟩, ⟨f x, hpx, λ y hy,\n    let ⟨z, hz⟩ := hf.surjective y in hz ▸ congr_arg f $ hx _ $ by rwa hz⟩⟩\n\nlemma bijective.of_comp_iff (f : α → β) {g : γ → α} (hg : bijective g) :\n  bijective (f ∘ g) ↔ bijective f :=\nand_congr (injective.of_comp_iff' _ hg) (surjective.of_comp_iff _ hg.surjective)\n\nlemma bijective.of_comp_iff' {f : α → β} (hf : bijective f) (g : γ → α) :\n  function.bijective (f ∘ g) ↔ function.bijective g :=\nand_congr (injective.of_comp_iff hf.injective _) (surjective.of_comp_iff' hf _)\n\n/-- **Cantor's diagonal argument** implies that there are no surjective functions from `α`\nto `set α`. -/\ntheorem cantor_surjective {α} (f : α → set α) : ¬ function.surjective f | h :=\nlet ⟨D, e⟩ := h (λ a, ¬ f a a) in\n(iff_not_self (f D D)).1 $ iff_of_eq (congr_fun e D)\n\n/-- **Cantor's diagonal argument** implies that there are no injective functions from `set α`\nto `α`. -/\ntheorem cantor_injective {α : Type*} (f : (set α) → α) :\n  ¬ function.injective f | i :=\ncantor_surjective (λ a b, ∀ U, a = f U → U b) $\nright_inverse.surjective (λ U, funext $ λ a, propext ⟨λ h, h U rfl, λ h' U' e, i e ▸ h'⟩)\n\n/-- `g` is a partial inverse to `f` (an injective but not necessarily\n  surjective function) if `g y = some x` implies `f x = y`, and `g y = none`\n  implies that `y` is not in the range of `f`. -/\ndef is_partial_inv {α β} (f : α → β) (g : β → option α) : Prop :=\n∀ x y, g y = some x ↔ f x = y\n\ntheorem is_partial_inv_left {α β} {f : α → β} {g} (H : is_partial_inv f g) (x) : g (f x) = some x :=\n(H _ _).2 rfl\n\ntheorem injective_of_partial_inv {α β} {f : α → β} {g} (H : is_partial_inv f g) : injective f :=\nλ a b h, option.some.inj $ ((H _ _).2 h).symm.trans ((H _ _).2 rfl)\n\ntheorem injective_of_partial_inv_right {α β} {f : α → β} {g} (H : is_partial_inv f g)\n (x y b) (h₁ : b ∈ g x) (h₂ : b ∈ g y) : x = y :=\n((H _ _).1 h₁).symm.trans ((H _ _).1 h₂)\n\ntheorem left_inverse.comp_eq_id {f : α → β} {g : β → α} (h : left_inverse f g) : f ∘ g = id :=\nfunext h\n\ntheorem left_inverse_iff_comp {f : α → β} {g : β → α} : left_inverse f g ↔ f ∘ g = id :=\n⟨left_inverse.comp_eq_id, congr_fun⟩\n\ntheorem right_inverse.comp_eq_id {f : α → β} {g : β → α} (h : right_inverse f g) : g ∘ f = id :=\nfunext h\n\ntheorem right_inverse_iff_comp {f : α → β} {g : β → α} : right_inverse f g ↔ g ∘ f = id :=\n⟨right_inverse.comp_eq_id, congr_fun⟩\n\ntheorem left_inverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β}\n  (hf : left_inverse f g) (hh : left_inverse h i) : left_inverse (h ∘ f) (g ∘ i) :=\nassume a, show h (f (g (i a))) = a, by rw [hf (i a), hh a]\n\ntheorem right_inverse.comp {f : α → β} {g : β → α} {h : β → γ} {i : γ → β}\n  (hf : right_inverse f g) (hh : right_inverse h i) : right_inverse (h ∘ f) (g ∘ i) :=\nleft_inverse.comp hh hf\n\ntheorem left_inverse.right_inverse {f : α → β} {g : β → α} (h : left_inverse g f) :\n  right_inverse f g := h\n\ntheorem right_inverse.left_inverse {f : α → β} {g : β → α} (h : right_inverse g f) :\n  left_inverse f g := h\n\ntheorem left_inverse.surjective {f : α → β} {g : β → α} (h : left_inverse f g) :\n  surjective f :=\nh.right_inverse.surjective\n\ntheorem right_inverse.injective {f : α → β} {g : β → α} (h : right_inverse f g) :\n  injective f :=\nh.left_inverse.injective\n\ntheorem left_inverse.right_inverse_of_injective {f : α → β} {g : β → α} (h : left_inverse f g)\n  (hf : injective f) :\n  right_inverse f g :=\nλ x, hf $ h (f x)\n\ntheorem left_inverse.right_inverse_of_surjective {f : α → β} {g : β → α} (h : left_inverse f g)\n  (hg : surjective g) :\n  right_inverse f g :=\nλ x, let ⟨y, hy⟩ := hg x in hy ▸ congr_arg g (h y)\n\ntheorem left_inverse.eq_right_inverse {f : α → β} {g₁ g₂ : β → α} (h₁ : left_inverse g₁ f)\n  (h₂ : right_inverse g₂ f) :\n  g₁ = g₂ :=\ncalc g₁ = g₁ ∘ f ∘ g₂ : by rw [h₂.comp_eq_id, comp.right_id]\n    ... = g₂          : by rw [← comp.assoc, h₁.comp_eq_id, comp.left_id]\n\nlocal attribute [instance, priority 10] classical.prop_decidable\n\n/-- We can use choice to construct explicitly a partial inverse for\n  a given injective function `f`. -/\nnoncomputable def partial_inv {α β} (f : α → β) (b : β) : option α :=\nif h : ∃ a, f a = b then some (classical.some h) else none\n\ntheorem partial_inv_of_injective {α β} {f : α → β} (I : injective f) :\n  is_partial_inv f (partial_inv f) | a b :=\n⟨λ h, if h' : ∃ a, f a = b then begin\n    rw [partial_inv, dif_pos h'] at h,\n    injection h with h, subst h,\n    apply classical.some_spec h'\n  end else by rw [partial_inv, dif_neg h'] at h; contradiction,\n λ e, e ▸ have h : ∃ a', f a' = f a, from ⟨_, rfl⟩,\n   (dif_pos h).trans (congr_arg _ (I $ classical.some_spec h))⟩\n\ntheorem partial_inv_left {α β} {f : α → β} (I : injective f) : ∀ x, partial_inv f (f x) = some x :=\nis_partial_inv_left (partial_inv_of_injective I)\n\nend\n\nsection inv_fun\n\nvariables {α β : Sort*} [nonempty α] {f : α → β} {a : α} {b : β}\nlocal attribute [instance, priority 10] classical.prop_decidable\n\n/-- The inverse of a function (which is a left inverse if `f` is injective\n  and a right inverse if `f` is surjective). -/\nnoncomputable def inv_fun (f : α → β) : β → α :=\nλ y, if h : ∃ x, f x = y then h.some else classical.arbitrary α\n\ntheorem inv_fun_eq (h : ∃ a, f a = b) : f (inv_fun f b) = b :=\nby simp only [inv_fun, dif_pos h, h.some_spec]\n\nlemma inv_fun_neg (h : ¬ ∃ a, f a = b) : inv_fun f b = classical.choice ‹_› :=\ndif_neg h\n\ntheorem inv_fun_eq_of_injective_of_right_inverse {g : β → α}\n  (hf : injective f) (hg : right_inverse g f) : inv_fun f = g :=\nfunext $ assume b,\nhf begin rw [hg b], exact inv_fun_eq ⟨g b, hg b⟩ end\n\nlemma right_inverse_inv_fun (hf : surjective f) : right_inverse (inv_fun f) f :=\nassume b, inv_fun_eq $ hf b\n\nlemma left_inverse_inv_fun (hf : injective f) : left_inverse (inv_fun f) f :=\nλ b, hf $ inv_fun_eq ⟨b, rfl⟩\n\nlemma inv_fun_surjective (hf : injective f) : surjective (inv_fun f) :=\n(left_inverse_inv_fun hf).surjective\n\nlemma inv_fun_comp (hf : injective f) : inv_fun f ∘ f = id := funext $ left_inverse_inv_fun hf\n\nlemma injective.has_left_inverse (hf : injective f) : has_left_inverse f :=\n⟨inv_fun f, left_inverse_inv_fun hf⟩\n\nlemma injective_iff_has_left_inverse : injective f ↔ has_left_inverse f :=\n⟨injective.has_left_inverse, has_left_inverse.injective⟩\n\nend inv_fun\n\nsection surj_inv\nvariables {α : Sort u} {β : Sort v} {γ : Sort w} {f : α → β}\n\n/-- The inverse of a surjective function. (Unlike `inv_fun`, this does not require\n  `α` to be inhabited.) -/\nnoncomputable def surj_inv {f : α → β} (h : surjective f) (b : β) : α := classical.some (h b)\n\nlemma surj_inv_eq (h : surjective f) (b) : f (surj_inv h b) = b := classical.some_spec (h b)\n\nlemma right_inverse_surj_inv (hf : surjective f) : right_inverse (surj_inv hf) f :=\nsurj_inv_eq hf\n\nlemma left_inverse_surj_inv (hf : bijective f) : left_inverse (surj_inv hf.2) f :=\nright_inverse_of_injective_of_left_inverse hf.1 (right_inverse_surj_inv hf.2)\n\nlemma surjective.has_right_inverse (hf : surjective f) : has_right_inverse f :=\n⟨_, right_inverse_surj_inv hf⟩\n\nlemma surjective_iff_has_right_inverse : surjective f ↔ has_right_inverse f :=\n⟨surjective.has_right_inverse, has_right_inverse.surjective⟩\n\nlemma bijective_iff_has_inverse : bijective f ↔ ∃ g, left_inverse g f ∧ right_inverse g f :=\n⟨λ hf, ⟨_, left_inverse_surj_inv hf, right_inverse_surj_inv hf.2⟩,\n λ ⟨g, gl, gr⟩, ⟨gl.injective,  gr.surjective⟩⟩\n\nlemma injective_surj_inv (h : surjective f) : injective (surj_inv h) :=\n(right_inverse_surj_inv h).injective\n\nlemma surjective_to_subsingleton [na : nonempty α] [subsingleton β] (f : α → β) :\n  surjective f :=\nλ y, let ⟨a⟩ := na in ⟨a, subsingleton.elim _ _⟩\n\n/-- Composition by an surjective function on the left is itself surjective. -/\nlemma surjective.comp_left {g : β → γ} (hg : surjective g) :\n  surjective ((∘) g : (α → β) → (α → γ)) :=\nλ f, ⟨surj_inv hg ∘ f, funext $ λ x, right_inverse_surj_inv _ _⟩\n\n/-- Composition by an bijective function on the left is itself bijective. -/\nlemma bijective.comp_left {g : β → γ} (hg : bijective g) :\n  bijective ((∘) g : (α → β) → (α → γ)) :=\n⟨hg.injective.comp_left, hg.surjective.comp_left⟩\n\nend surj_inv\n\nsection update\nvariables {α : Sort u} {β : α → Sort v} {α' : Sort w} [decidable_eq α] [decidable_eq α']\n\n/-- Replacing the value of a function at a given point by a given value. -/\ndef update (f : Πa, β a) (a' : α) (v : β a') (a : α) : β a :=\nif h : a = a' then eq.rec v h.symm else f a\n\n/-- On non-dependent functions, `function.update` can be expressed as an `ite` -/\nlemma update_apply {β : Sort*} (f : α → β) (a' : α) (b : β) (a : α) :\n  update f a' b a = if a = a' then b else f a :=\nbegin\n  dunfold update,\n  congr,\n  funext,\n  rw eq_rec_constant,\nend\n\n@[simp] lemma update_same (a : α) (v : β a) (f : Πa, β a) : update f a v a = v :=\ndif_pos rfl\n\nlemma surjective_eval {α : Sort u} {β : α → Sort v} [h : Π a, nonempty (β a)] (a : α) :\n  surjective (eval a : (Π a, β a) → β a) :=\nλ b, ⟨@update _ _ (classical.dec_eq α) (λ a, (h a).some) a b,\n  @update_same _ _ (classical.dec_eq α) _ _ _⟩\n\nlemma update_injective (f : Πa, β a) (a' : α) : injective (update f a') :=\nλ v v' h, have _ := congr_fun h a', by rwa [update_same, update_same] at this\n\n@[simp] lemma update_noteq {a a' : α} (h : a ≠ a') (v : β a') (f : Πa, β a) :\n  update f a' v a = f a :=\ndif_neg h\n\nlemma forall_update_iff (f : Π a, β a) {a : α} {b : β a} (p : Π a, β a → Prop) :\n  (∀ x, p x (update f a b x)) ↔ p a b ∧ ∀ x ≠ a, p x (f x) :=\nby { rw [← and_forall_ne a, update_same], simp { contextual := tt } }\n\nlemma exists_update_iff (f : Π a, β a) {a : α} {b : β a} (p : Π a, β a → Prop) :\n  (∃ x, p x (update f a b x)) ↔ p a b ∨ ∃ x ≠ a, p x (f x) :=\nby { rw [← not_forall_not, forall_update_iff f (λ a b, ¬p a b)], simp [not_and_distrib] }\n\nlemma update_eq_iff {a : α} {b : β a} {f g : Π a, β a} :\n  update f a b = g ↔ b = g a ∧ ∀ x ≠ a, f x = g x :=\nfunext_iff.trans $ forall_update_iff _ (λ x y, y = g x)\n\nlemma eq_update_iff {a : α} {b : β a} {f g : Π a, β a} :\n  g = update f a b ↔ g a = b ∧ ∀ x ≠ a, g x = f x :=\nfunext_iff.trans $ forall_update_iff _ (λ x y, g x = y)\n\n@[simp] lemma update_eq_self (a : α) (f : Πa, β a) : update f a (f a) = f :=\nupdate_eq_iff.2 ⟨rfl, λ _ _, rfl⟩\n\nlemma update_comp_eq_of_forall_ne' {α'} (g : Π a, β a) {f : α' → α} {i : α} (a : β i)\n  (h : ∀ x, f x ≠ i) :\n  (λ j, (update g i a) (f j)) = (λ j, g (f j)) :=\nfunext $ λ x, update_noteq (h _) _ _\n\n/-- Non-dependent version of `function.update_comp_eq_of_forall_ne'` -/\nlemma update_comp_eq_of_forall_ne {α β : Sort*} (g : α' → β) {f : α → α'} {i : α'} (a : β)\n  (h : ∀ x, f x ≠ i) :\n  (update g i a) ∘ f = g ∘ f :=\nupdate_comp_eq_of_forall_ne' g a h\n\nlemma update_comp_eq_of_injective' (g : Π a, β a) {f : α' → α} (hf : function.injective f)\n  (i : α') (a : β (f i)) :\n  (λ j, update g (f i) a (f j)) = update (λ i, g (f i)) i a :=\neq_update_iff.2 ⟨update_same _ _ _, λ j hj, update_noteq (hf.ne hj) _ _⟩\n\n/-- Non-dependent version of `function.update_comp_eq_of_injective'` -/\nlemma update_comp_eq_of_injective {β : Sort*} (g : α' → β) {f : α → α'}\n  (hf : function.injective f) (i : α) (a : β) :\n  (function.update g (f i) a) ∘ f = function.update (g ∘ f) i a :=\nupdate_comp_eq_of_injective' g hf i a\n\nlemma apply_update {ι : Sort*} [decidable_eq ι] {α β : ι → Sort*}\n  (f : Π i, α i → β i) (g : Π i, α i) (i : ι) (v : α i) (j : ι) :\n  f j (update g i v j) = update (λ k, f k (g k)) i (f i v) j :=\nbegin\n  by_cases h : j = i,\n  { subst j, simp },\n  { simp [h] }\nend\n\nlemma apply_update₂ {ι : Sort*} [decidable_eq ι] {α β γ : ι → Sort*}\n  (f : Π i, α i → β i → γ i) (g : Π i, α i) (h : Π i, β i) (i : ι) (v : α i) (w : β i) (j : ι) :\n  f j (update g i v j) (update h i w j) = update (λ k, f k (g k) (h k)) i (f i v w) j :=\nbegin\n  by_cases h : j = i,\n  { subst j, simp },\n  { simp [h] }\nend\n\nlemma comp_update {α' : Sort*} {β : Sort*} (f : α' → β) (g : α → α') (i : α) (v : α') :\n  f ∘ (update g i v) = update (f ∘ g) i (f v) :=\nfunext $ apply_update _ _ _ _\n\ntheorem update_comm {α} [decidable_eq α] {β : α → Sort*}\n  {a b : α} (h : a ≠ b) (v : β a) (w : β b) (f : Πa, β a) :\n  update (update f a v) b w = update (update f b w) a v :=\nbegin\n  funext c, simp only [update],\n  by_cases h₁ : c = b; by_cases h₂ : c = a; try {simp [h₁, h₂]},\n  cases h (h₂.symm.trans h₁),\nend\n\n@[simp] theorem update_idem {α} [decidable_eq α] {β : α → Sort*}\n  {a : α} (v w : β a) (f : Πa, β a) : update (update f a v) a w = update f a w :=\nby {funext b, by_cases b = a; simp [update, h]}\n\nend update\n\nsection extend\n\nnoncomputable theory\nlocal attribute [instance, priority 10] classical.prop_decidable\n\nvariables {α β γ : Sort*} {f : α → β}\n\n/-- `extend f g e'` extends a function `g : α → γ`\nalong a function `f : α → β` to a function `β → γ`,\nby using the values of `g` on the range of `f`\nand the values of an auxiliary function `e' : β → γ` elsewhere.\n\nMostly useful when `f` is injective. -/\ndef extend (f : α → β) (g : α → γ) (e' : β → γ) : β → γ :=\nλ b, if h : ∃ a, f a = b then g (classical.some h) else e' b\n\nlemma extend_def (f : α → β) (g : α → γ) (e' : β → γ) (b : β) [decidable (∃ a, f a = b)] :\n  extend f g e' b = if h : ∃ a, f a = b then g (classical.some h) else e' b :=\nby { unfold extend, congr }\n\n@[simp] lemma extend_apply (hf : injective f) (g : α → γ) (e' : β → γ) (a : α) :\n  extend f g e' (f a) = g a :=\nbegin\n  simp only [extend_def, dif_pos, exists_apply_eq_apply],\n  exact congr_arg g (hf $ classical.some_spec (exists_apply_eq_apply f a))\nend\n\n@[simp] lemma extend_apply' (g : α → γ) (e' : β → γ) (b : β) (hb : ¬∃ a, f a = b) :\n  extend f g e' b = e' b :=\nby simp [function.extend_def, hb]\n\nlemma apply_extend {δ} (hf : injective f) (F : γ → δ) (g : α → γ) (e' : β → γ) (b : β) :\n  F (extend f g e' b) = extend f (F ∘ g) (F ∘ e') b :=\nbegin\n  by_cases hb : ∃ a, f a = b,\n  { cases hb with a ha, subst b,\n    rw [extend_apply hf, extend_apply hf] },\n  { rw [extend_apply' _ _ _ hb, extend_apply' _ _ _ hb] }\nend\n\nlemma extend_injective (hf : injective f) (e' : β → γ) :\n  injective (λ g, extend f g e') :=\nbegin\n  intros g₁ g₂ hg,\n  refine funext (λ x, _),\n  have H := congr_fun hg (f x),\n  simp only [hf, extend_apply] at H,\n  exact H\nend\n\n@[simp] lemma extend_comp (hf : injective f) (g : α → γ) (e' : β → γ) :\n  extend f g e' ∘ f = g :=\nfunext $ λ a, extend_apply hf g e' a\n\nlemma injective.surjective_comp_right' (hf : injective f) (g₀ : β → γ) :\n  surjective (λ g : β → γ, g ∘ f) :=\nλ g, ⟨extend f g g₀, extend_comp hf _ _⟩\n\nlemma injective.surjective_comp_right [nonempty γ] (hf : injective f) :\n  surjective (λ g : β → γ, g ∘ f) :=\nhf.surjective_comp_right' (λ _, classical.choice ‹_›)\n\nlemma bijective.comp_right (hf : bijective f) :\n  bijective (λ g : β → γ, g ∘ f) :=\n⟨hf.surjective.injective_comp_right,\n  λ g, ⟨g ∘ surj_inv hf.surjective,\n    by simp only [comp.assoc g _ f, (left_inverse_surj_inv hf).comp_eq_id, comp.right_id]⟩⟩\n\nend extend\n\nlemma uncurry_def {α β γ} (f : α → β → γ) : uncurry f = (λp, f p.1 p.2) :=\nrfl\n\n@[simp] lemma uncurry_apply_pair {α β γ} (f : α → β → γ) (x : α) (y : β) :\n  uncurry f (x, y) = f x y :=\nrfl\n\n@[simp] lemma curry_apply {α β γ} (f : α × β → γ) (x : α) (y : β) :\n  curry f x y = f (x, y) :=\nrfl\n\nsection bicomp\nvariables {α β γ δ ε : Type*}\n\n/-- Compose a binary function `f` with a pair of unary functions `g` and `h`.\nIf both arguments of `f` have the same type and `g = h`, then `bicompl f g g = f on g`. -/\ndef bicompl (f : γ → δ → ε) (g : α → γ) (h : β → δ) (a b) :=\nf (g a) (h b)\n\n/-- Compose an unary function `f` with a binary function `g`. -/\ndef bicompr (f : γ → δ) (g : α → β → γ) (a b) :=\nf (g a b)\n\n-- Suggested local notation:\nlocal notation f `∘₂` g := bicompr f g\n\nlemma uncurry_bicompr (f : α → β → γ) (g : γ → δ) :\n  uncurry (g ∘₂ f) = (g ∘ uncurry f) := rfl\n\n\n\nend bicomp\n\nsection uncurry\n\nvariables {α β γ δ : Type*}\n\n/-- Records a way to turn an element of `α` into a function from `β` to `γ`. The most generic use\nis to recursively uncurry. For instance `f : α → β → γ → δ` will be turned into\n`↿f : α × β × γ → δ`. One can also add instances for bundled maps. -/\nclass has_uncurry (α : Type*) (β : out_param Type*) (γ : out_param Type*) := (uncurry : α → (β → γ))\n\n/-- Uncurrying operator. The most generic use is to recursively uncurry. For instance\n`f : α → β → γ → δ` will be turned into `↿f : α × β × γ → δ`. One can also add instances\nfor bundled maps.-/\nadd_decl_doc has_uncurry.uncurry\n\nnotation `↿`:max x:max := has_uncurry.uncurry x\n\ninstance has_uncurry_base : has_uncurry (α → β) α β := ⟨id⟩\n\ninstance has_uncurry_induction [has_uncurry β γ δ] : has_uncurry (α → β) (α × γ) δ :=\n⟨λ f p, ↿(f p.1) p.2⟩\n\nend uncurry\n\n/-- A function is involutive, if `f ∘ f = id`. -/\ndef involutive {α} (f : α → α) : Prop := ∀ x, f (f x) = x\n\nlemma involutive_iff_iter_2_eq_id {α} {f : α → α} : involutive f ↔ (f^[2] = id) :=\nfunext_iff.symm\n\nnamespace involutive\nvariables {α : Sort u} {f : α → α} (h : involutive f)\ninclude h\n\n@[simp]\nlemma comp_self : f ∘ f = id := funext h\n\nprotected lemma left_inverse : left_inverse f f := h\nprotected lemma right_inverse : right_inverse f f := h\n\nprotected lemma injective : injective f := h.left_inverse.injective\nprotected lemma surjective : surjective f := λ x, ⟨f x, h x⟩\nprotected lemma bijective : bijective f := ⟨h.injective, h.surjective⟩\n\n/-- Involuting an `ite` of an involuted value `x : α` negates the `Prop` condition in the `ite`. -/\nprotected lemma ite_not (P : Prop) [decidable P] (x : α) :\n  f (ite P x (f x)) = ite (¬ P) x (f x) :=\nby rw [apply_ite f, h, ite_not]\n\n/-- An involution commutes across an equality. Compare to `function.injective.eq_iff`. -/\nprotected lemma eq_iff {x y : α} : f x = y ↔ x = f y :=\nh.injective.eq_iff' (h y)\n\nend involutive\n\n/-- The property of a binary function `f : α → β → γ` being injective.\nMathematically this should be thought of as the corresponding function `α × β → γ` being injective.\n-/\n@[reducible] def injective2 {α β γ} (f : α → β → γ) : Prop :=\n∀ ⦃a₁ a₂ b₁ b₂⦄, f a₁ b₁ = f a₂ b₂ → a₁ = a₂ ∧ b₁ = b₂\n\nnamespace injective2\nvariables {α β γ : Type*} (f : α → β → γ)\n\nprotected lemma left (hf : injective2 f) ⦃a₁ a₂ b₁ b₂⦄ (h : f a₁ b₁ = f a₂ b₂) : a₁ = a₂ :=\n(hf h).1\n\nprotected lemma right (hf : injective2 f) ⦃a₁ a₂ b₁ b₂⦄ (h : f a₁ b₁ = f a₂ b₂) : b₁ = b₂ :=\n(hf h).2\n\nlemma eq_iff (hf : injective2 f) ⦃a₁ a₂ b₁ b₂⦄ : f a₁ b₁ = f a₂ b₂ ↔ a₁ = a₂ ∧ b₁ = b₂ :=\n⟨λ h, hf h, λ⟨h1, h2⟩, congr_arg2 f h1 h2⟩\n\nend injective2\n\nsection sometimes\nlocal attribute [instance, priority 10] classical.prop_decidable\n\n/-- `sometimes f` evaluates to some value of `f`, if it exists. This function is especially\ninteresting in the case where `α` is a proposition, in which case `f` is necessarily a\nconstant function, so that `sometimes f = f a` for all `a`. -/\nnoncomputable def sometimes {α β} [nonempty β] (f : α → β) : β :=\nif h : nonempty α then f (classical.choice h) else classical.choice ‹_›\n\ntheorem sometimes_eq {p : Prop} {α} [nonempty α] (f : p → α) (a : p) : sometimes f = f a :=\ndif_pos ⟨a⟩\n\ntheorem sometimes_spec {p : Prop} {α} [nonempty α]\n  (P : α → Prop) (f : p → α) (a : p) (h : P (f a)) : P (sometimes f) :=\nby rwa sometimes_eq\n\nend sometimes\n\nend function\n\n/-- `s.piecewise f g` is the function equal to `f` on the set `s`, and to `g` on its complement. -/\ndef set.piecewise {α : Type u} {β : α → Sort v} (s : set α) (f g : Πi, β i)\n  [∀j, decidable (j ∈ s)] :\n  Πi, β i :=\nλi, if i ∈ s then f i else g i\n\n/-! ### Bijectivity of `eq.rec`, `eq.mp`, `eq.mpr`, and `cast` -/\n\nlemma eq_rec_on_bijective {α : Sort*} {C : α → Sort*} :\n  ∀ {a a' : α} (h : a = a'), function.bijective (@eq.rec_on _ _ C _ h)\n| _ _ rfl := ⟨λ x y, id, λ x, ⟨x, rfl⟩⟩\n\nlemma eq_mp_bijective {α β : Sort*} (h : α = β) : function.bijective (eq.mp h) :=\neq_rec_on_bijective h\n\nlemma eq_mpr_bijective {α β : Sort*} (h : α = β) : function.bijective (eq.mpr h) :=\neq_rec_on_bijective h.symm\n\nlemma cast_bijective {α β : Sort*} (h : α = β) : function.bijective (cast h) :=\neq_rec_on_bijective h\n\n/-! Note these lemmas apply to `Type*` not `Sort*`, as the latter interferes with `simp`, and\nis trivial anyway.-/\n\n@[simp]\nlemma eq_rec_inj {α : Sort*} {a a' : α} (h : a = a') {C : α → Type*} (x y : C a) :\n  (eq.rec x h : C a') = eq.rec y h ↔ x = y :=\n(eq_rec_on_bijective h).injective.eq_iff\n\n@[simp]\nlemma cast_inj {α β : Type*} (h : α = β) {x y : α} : cast h x = cast h y ↔ x = y :=\n(cast_bijective h).injective.eq_iff\n\n/-- A set of functions \"separates points\"\nif for each pair of distinct points there is a function taking different values on them. -/\ndef set.separates_points {α β : Type*} (A : set (α → β)) : Prop :=\n∀ ⦃x y : α⦄, x ≠ y → ∃ f ∈ A, (f x : β) ≠ f y\n\nlemma is_symm_op.flip_eq {α β} (op) [is_symm_op α β op] : flip op = op :=\nfunext $ λ a, funext $ λ b, (is_symm_op.symm_op a b).symm\n\nlemma inv_image.equivalence {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β)\n  (h : equivalence r) : equivalence (inv_image r f) :=\n⟨λ _, h.1 _, λ _ _ x, h.2.1 x, inv_image.trans r f h.2.2⟩\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/logic/function/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5964331462646255, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.45704292850834094}}
{"text": "import .basic\nimport .model\nimport .proof\n\nnamespace universal\nvariables {τ : Type} {σ : Type*} {sig : signature τ σ} {ι : Type} {ax : ι → identity sig}\n\nnamespace proof\nvariables {ι' : Type} {ax' : ι' → identity sig} (ht : Π (i : ι), proof ax' (ax i).lhs (ax i).rhs)\n\ndefinition transfer {dom} : Π {cod} {t₁ t₂ : term sig dom cod} (p : proof ax t₁ t₂), proof ax' t₁ t₂\n| _ _ _ (proof.ax i sub) := proof.subst sub (ht i) \n| _ _ _ (proof.proj _) := proof.proj _\n| _ _ _ (proof.func f ps) := proof.func f (λ i, transfer (ps i))\n| _ _ _ (proof.eucl p₁ p₂) := proof.eucl (transfer p₁) (transfer p₂)\n\ndefinition transfer_of_map (f : ι → ι') (hf : ∀ i, ax' (f i) = ax i) (i : ι) : proof ax' (ax i).lhs (ax i).rhs :=\neq.rec_on (hf i) $ proof.ax_id (f i)\n\nend proof\n\ndefinition proof.occurs {dom} : Π {cod} {t₁ t₂ : term sig dom cod}, proof ax t₁ t₂ → ι → Prop\n| _ _ _ (proof.ax i _) j := i = j\n| _ _ _ (proof.proj _) _ := false\n| _ _ _ (proof.func _ ps) j := ∃ i, proof.occurs (ps i) j\n| _ _ _ (proof.eucl p₁ p₂) j := proof.occurs p₁ j ∨ proof.occurs p₂ j\n\ndefinition proof.use {dom} : Π {cod} {t₁ t₂ : term sig dom cod}, proof ax t₁ t₂ → list ι\n| _ _ _ (proof.ax i _) := [i]\n| _ _ _ (proof.proj _) := []\n| _ _ _ (proof.func _ ps) := list.join $ index.dtup.to_list (λ i, proof.use (ps i))\n| _ _ _ (proof.eucl p₁ p₂) := proof.use p₁ ++ proof.use p₂\n\ntheorem proof.mem_use_of_occurs {dom} : Π {cod} {t₁ t₂ : term sig dom cod} {p : proof ax t₁ t₂} {i : ι}, proof.occurs p i → i ∈ proof.use p\n| _ _ _ (proof.ax i _) j h := eq.rec_on h (or.inl rfl)\n| _ _ _ (proof.proj _) _ h := absurd h not_false\n| _ _ _ (proof.func _ ps) j h :=\n  exists.elim h $ λ i hi,\n  let i' : index (index.dtup.to_list (λ i, proof.use (ps i))) := index.map _ (index.dtup.enum_index _ i) in\n  have hi' : j ∈ i'.val, by { rw [index.val_map, index.dtup.enum_index_val], exact proof.mem_use_of_occurs hi },\n  list.mem_join j i' hi'\n| _ _ _ (proof.eucl p₁ p₂) j h :=  or.elim h (λ h, list.mem_append_left _ (proof.mem_use_of_occurs h)) (λ h, list.mem_append_right _ (proof.mem_use_of_occurs h))\n\ndefinition proof.of_use {dom} : Π {cod} {t₁ t₂ : term sig dom cod} (p : proof ax t₁ t₂), proof (λ (i : index p.use), ax i.val) t₁ t₂\n| _ t₁ t₂ p@(proof.ax i sub) := proof.subst sub $ proof.ax_id (index.head i [])\n| _ _ _ (proof.proj _) := proof.proj _\n| _ _ _ p@(@proof.func _ _ _ _ _ _ f lhs rhs ps) :=\n  let m : Π (i : sig.index f) (j : index (ps i).use), index p.use :=\n  λ i j, index.join_map _ (index.dtup.to_list_index _ i) $ eq.rec_on (index.dtup.to_list_index_val (λ i, (ps i).use) i).symm j in\n  let ps : Π (i : sig.index f), proof (λ (i : index p.use), ax i.val) (lhs i) (rhs i) :=\n  λ i, proof.transfer (proof.transfer_of_map (m i) (by {intro, simp})) (proof.of_use (ps i)) in\n  proof.func f ps\n| _ t₁ t₂ p@(@proof.eucl _ _ _ _ _ _ _ t _ _ p₁ p₂) :=\n  let p₁ : proof (λ (i : index p.use), ax i.val) t t₁ :=\n  proof.transfer (proof.transfer_of_map (index.append_left _ _) (by {intro, rw [index.append_left_val]})) (proof.of_use p₁) in\n  let p₂ : proof (λ (i : index p.use), ax i.val) t t₂ :=\n  proof.transfer (proof.transfer_of_map (index.append_right _ _) (by {intro, rw [index.append_right_val]})) (proof.of_use p₂) in\n  proof.eucl p₁ p₂\n\ntheorem compactness (e : identity sig) : models ax e → ∃ (as : list ι), models (λ (i : index as), ax i.val) e :=\nbegin\nintros hm,\ncases completeness ax e hm with hp,\nexistsi hp.use,\napply soundness,\nconstructor,\nexact proof.of_use hp,\nend\n\nend universal\n", "meta": {"author": "fgdorais", "repo": "lean-universal", "sha": "9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1", "save_path": "github-repos/lean/fgdorais-lean-universal", "path": "github-repos/lean/fgdorais-lean-universal/lean-universal-9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1/src/universal/compactness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4570429285083409}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : ¬ is_rat α) : ∀ y ∈ Icc 0 1, ∃ x ∈ Icc 0 1, ∃ N : ℤ, |y - (N : ℝ) * x| < 1 :=\nbegin\n  -- Let $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n  assume (y : ℝ) (h1 : y ∈ Icc 0 1),\n  have h2 : ∀ (i j : ℤ), i ≠ j → (i : ℝ) * α - (i : ℝ) ≠ (j : ℝ) * α - (j : ℝ), from by auto [hα, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop :=  λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l →  (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n  from by auto [abs_sub_lt_iff] using [linarith],\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : ε > 0),\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that $\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n  cases h2 ε h7 with N1 h8,\n\n  --As $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that $\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n  cases h3 ε h7 with N2 h9,\n  \n  --Let $N = \\max \\set {N_1, N_2}$.\n  let N := max N1 N2,\n  use N,\n\n  --Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n  have h10 : ∀ n > N, n > N1 ∧ n > N2 := by auto [lt_of_le_of_lt, le_max_left, le_max_right],\n  \n  --$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n  --$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n  --$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n  --So $\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n  have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n  from by auto [h8, h10, h5, h9],\n\n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n  from by auto [h11] using [linarith],\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  ∀ (n : ℕ), n > N → |x n - l| < ε, \n  from by auto [h5, h15], \n\nend\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\alpha$ be an irrational number. Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$. If this were not true, then\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$.\n\nTo show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. Then by selecting $x \\in S$ such that $\\{x\\}<\\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \\cdot\\{x\\} \\leq y<(N+1) \\cdot\\{x\\}$, we get: $|y-\\{N x\\}|<\\epsilon$.\n\nQED\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto_with_comments-Natural-Language-Proof-Translation/lean_proof_auto_with_comments-4_few_shot_temperature_0_max_tokens_2000_n_1/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4569749095234384}}
{"text": "/-\nCopyright (c) 2021 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.Tactic.Basic\nimport Std.Tactic.Simpa\nimport Mathlib.Data.Array.Basic\n\nstructure UFModel (n) where\n  parent : Fin n → Fin n\n  rank : Nat → Nat\n  rank_lt : ∀ i, (parent i).1 ≠ i → rank i < rank (parent i)\n\nnamespace UFModel\n\ndef empty : UFModel 0 where\n  parent i := i.elim0\n  rank _ := 0\n  rank_lt i := i.elim0\n\ndef push {n} (m : UFModel n) (k) (le : n ≤ k) : UFModel k where\n  parent i :=\n    if h : i < n then\n      let ⟨a, h'⟩ := m.parent ⟨i, h⟩\n      ⟨a, lt_of_lt_of_le h' le⟩\n    else i\n  rank i := if i < n then m.rank i else 0\n  rank_lt i := by\n    simp; split <;> rename_i h\n    · simp [(m.parent ⟨i, h⟩).2, h]; exact m.rank_lt _\n    · intro.\n\ndef setParent {n} (m : UFModel n) (x y : Fin n) (h : m.rank x < m.rank y) : UFModel n where\n  parent i := if x.1 = i then y else m.parent i\n  rank := m.rank\n  rank_lt i := by\n    simp; split <;> rename_i h'\n    · rw [← h']; exact fun _ ↦ h\n    · exact m.rank_lt i\n\ndef setParentBump {n} (m : UFModel n) (x y : Fin n)\n    (H : m.rank x ≤ m.rank y) (hroot : (m.parent y).1 = y) : UFModel n where\n  parent i := if x.1 = i then y else m.parent i\n  rank i := if y.1 = i ∧ m.rank x = m.rank y then m.rank y + 1 else m.rank i\n  rank_lt i := by\n    simp; split <;>\n      (rename_i h₁; simp [h₁]; split <;> rename_i h₂ <;>\n        (intro h; simp [h] at h₂ <;> simp [h₁, h₂, h]))\n    · simp [← h₁]; split <;> rename_i h₃\n      · rw [h₃]; apply Nat.lt_succ_self\n      · exact lt_of_le_of_ne H h₃\n    · have := Fin.eq_of_val_eq h₂.1; subst this\n      simp [hroot] at h\n    · have := m.rank_lt i h\n      split <;> rename_i h₃\n      · rw [h₃.1]; exact Nat.lt_succ_of_lt this\n      · exact this\n\nend UFModel\n\nstructure UFNode (α : Type _) where\n  parent : Nat\n  value : α\n  rank : Nat\n\ninductive UFModel.Agrees (arr : Array α) (f : α → β) : ∀ {n}, (Fin n → β) → Prop\n| mk : Agrees arr f fun i ↦ f (arr.get i)\n\nnamespace UFModel.Agrees\n\ntheorem mk' {arr : Array α} {f : α → β} {n} {g : Fin n → β}\n  (e : n = arr.size)\n  (H : ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = g ⟨i, h₂⟩) :\n  Agrees arr f g := by\n    cases e\n    have : (fun i ↦ f (arr.get i)) = g := by funext ⟨i, h⟩; apply H\n    cases this; constructor\n\n\n\ntheorem get_eq {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m) :\n  ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = m ⟨i, h₂⟩ := by\n  cases H; exact fun i h _ ↦ rfl\n\ntheorem get_eq' {arr : Array α} {m : Fin arr.size → β} (H : Agrees arr f m)\n  (i) : f (arr.get i) = m i := H.get_eq ..\n\ntheorem empty {f : α → β} {g : Fin 0 → β} : Agrees #[] f g := mk' rfl λ.\n\ntheorem push {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m)\n  (k) (hk : k = n + 1) (x) (m' : Fin k → β)\n  (hm₁ : ∀ (i : Fin k) (h : i < n), m' i = m ⟨i, h⟩)\n  (hm₂ : ∀ (h : n < k), f x = m' ⟨n, h⟩) : Agrees (arr.push x) f m' := by\n  cases H\n  have : k = (arr.push x).size := by simp [hk]\n  refine mk' this fun i h₁ h₂ ↦ ?_\n  simp [Array.get_push]; split <;> (rename_i h; simp at hm₁ ⊢)\n  · rw [← hm₁ ⟨i, h₂⟩]; assumption\n  · cases show i = arr.size by apply le_antisymm <;> simp_all [Nat.lt_succ]\n    rw [hm₂]\n\ntheorem set {arr : Array α} {n} {m : Fin n → β} (H : Agrees arr f m)\n  {i : Fin arr.size} {x} {m' : Fin n → β}\n  (hm₁ : ∀ (j : Fin n), j.1 ≠ i → m' j = m j)\n  (hm₂ : ∀ (h : i < n), f x = m' ⟨i, h⟩) : Agrees (arr.set i x) f m' := by\n  cases H\n  refine mk' (by simp) fun j hj₁ hj₂ ↦ ?_\n  suffices f (Array.set arr i x)[j] = m' ⟨j, hj₂⟩ by simp_all [Array.get_set]\n  by_cases h : i = j\n  · subst h; rw [Array.get_set_eq, ← hm₂]\n  · rw [arr.get_set_ne _ _ _ h, hm₁ ⟨j, _⟩ (Ne.symm h)]; rfl\n\nend UFModel.Agrees\n\ndef UFModel.Models (arr : Array (UFNode α)) {n} (m : UFModel n) :=\n  UFModel.Agrees arr (·.parent) (fun i ↦ m.parent i) ∧\n  UFModel.Agrees arr (·.rank) (fun i : Fin n ↦ m.rank i)\n\nnamespace UFModel.Models\n\ntheorem size_eq {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr) :\n  n = arr.size := H.1.size_eq\n\ntheorem parent_eq {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr)\n  (i : Nat) (h₁ : i < arr.size) (h₂) : arr[i].parent = m.parent ⟨i, h₂⟩ := H.1.get_eq ..\n\ntheorem parent_eq' {arr : Array (UFNode α)} {m : UFModel arr.size} (H : m.Models arr)\n  (i : Fin arr.size) : (arr[i.1]).parent = m.parent i := H.parent_eq ..\n\ntheorem rank_eq {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr) (i : Nat)\n    (h : i < arr.size) : arr[i].rank = m.rank i :=\n  H.2.get_eq _ _ (by rw [H.size_eq]; exact h)\n\ntheorem empty : UFModel.empty.Models (α := α) #[] := ⟨Agrees.empty, Agrees.empty⟩\n\ntheorem push {arr : Array (UFNode α)} {n} {m : UFModel n} (H : m.Models arr)\n  (k) (hk : k = n + 1) (x) :\n  (m.push k (hk ▸ Nat.le_add_right ..)).Models (arr.push ⟨n, x, 0⟩) := by\n  apply H.imp <;>\n  · intro H\n    refine H.push _ hk _ _ (fun i h ↦ ?_) (fun h ↦ ?_) <;>\n    simp [UFModel.push, h, lt_irrefl]\n\ntheorem setParent {arr : Array (UFNode α)} {n} {m : UFModel n} (hm : m.Models arr)\n  (i j H hi x) (hp : x.parent = j.1) (hrk : x.rank = arr[i].rank) :\n  (m.setParent i j H).Models (arr.set ⟨i.1, hi⟩ x) :=\n  ⟨hm.1.set\n      (fun k (h : (k:ℕ) ≠ i) ↦ by simp [UFModel.setParent, h.symm])\n      (fun h ↦ by simp [UFModel.setParent, hp]),\n    hm.2.set (fun _ _ ↦ rfl) (fun _ ↦ hrk.trans $ hm.2.get_eq ..)⟩\n\nend UFModel.Models\n\nstructure UnionFind (α) where\n  arr : Array (UFNode α)\n  model : ∃ (n : _) (m : UFModel n), m.Models arr\n\nnamespace UnionFind\n\ndef size (self : UnionFind α) := self.arr.size\n\ntheorem model' (self : UnionFind α) : ∃ (m : UFModel self.arr.size), m.Models self.arr := by\n  let ⟨n, m, hm⟩ := self.model; cases hm.size_eq; exact ⟨m, hm⟩\n\ndef empty : UnionFind α where\n  arr := #[]\n  model := ⟨_, _, UFModel.Models.empty⟩\n\ndef mkEmpty (c : Nat) : UnionFind α where\n  arr := Array.mkEmpty c\n  model := ⟨_, _, UFModel.Models.empty⟩\n\ndef rank (self : UnionFind α) (i : Nat) : Nat :=\n  if h : i < self.size then (self.arr.get ⟨i, h⟩).rank else 0\n\ndef rankMaxAux (self : UnionFind α) : ∀ (i : Nat),\n  {k : Nat // ∀ j < i, ∀ h, (self.arr.get ⟨j, h⟩).rank ≤ k}\n| 0 => ⟨0, λ.⟩\n| i+1 => by\n  let ⟨k, H⟩ := rankMaxAux self i\n  refine ⟨max k (if h : _ then (self.arr.get ⟨i, h⟩).rank else 0), fun j hj h ↦ ?_⟩\n  match j, lt_or_eq_of_le (Nat.le_of_lt_succ hj) with\n  | j, Or.inl hj => exact le_trans (H _ hj h) (le_max_left _ _)\n  | _, Or.inr rfl => simp [h, le_max_right]\n\ndef rankMax (self : UnionFind α) := (rankMaxAux self self.size).1 + 1\n\ntheorem lt_rankMax' (self : UnionFind α) (i : Fin self.size) :\n  (self.arr.get i).rank < self.rankMax :=\n  Nat.lt_succ.2 $ (rankMaxAux self self.size).2 _ i.2 _\n\ntheorem lt_rankMax (self : UnionFind α) (i : Nat) : self.rank i < self.rankMax := by\n  simp [rank]; split; {apply lt_rankMax'}; apply Nat.succ_pos\n\ntheorem rank_eq (self : UnionFind α) {n} {m : UFModel n} (H : m.Models self.arr)\n    {i} (h : i < self.size) : self.rank i = m.rank i := by\n  simp [rank, h, H.rank_eq]\n\ntheorem rank_lt (self : UnionFind α) {i : Nat} (h) : self.arr[i].parent ≠ i →\n  self.rank i < self.rank self.arr[i].parent := by\n  let ⟨m, hm⟩ := self.model'\n  simpa [hm.parent_eq, hm.rank_eq, rank, size, h, (m.parent ⟨i, h⟩).2] using m.rank_lt ⟨i, h⟩\n\ntheorem parent_lt (self : UnionFind α) (i : Nat) (h) : self.arr[i].parent < self.size := by\n  let ⟨m, hm⟩ := self.model'\n  simp [hm.parent_eq, size, (m.parent ⟨i, h⟩).2, h]\n\ndef push (self : UnionFind α) (x : α) : UnionFind α where\n  arr := self.arr.push ⟨self.arr.size, x, 0⟩\n  model := let ⟨_, hm⟩ := self.model'; ⟨_, _, hm.push _ rfl _⟩\n\ndef findAux (self : UnionFind α) (x : Fin self.size) :\n  (s : Array (UFNode α)) ×' (root : Fin s.size) ×'\n    ∃ n, ∃ (m : UFModel n) (m' : UFModel n),\n      m.Models self.arr ∧ m'.Models s ∧ m'.rank = m.rank ∧\n      (∃ hr, (m'.parent ⟨root, hr⟩).1 = root) ∧\n      m.rank x ≤ m.rank root := by\n  let y := self.arr[x].parent\n  refine if h : y = x then ⟨self.arr, x, ?a'⟩ else\n    have := Nat.sub_lt_sub_left (self.lt_rankMax x) (self.rank_lt _ h)\n    let ⟨arr₁, root, H⟩ := self.findAux ⟨y, self.parent_lt _ x.2⟩\n    have hx := ?hx\n    let arr₂ := arr₁.set ⟨x, hx⟩ {arr₁.get ⟨x, hx⟩ with parent := root}\n    ⟨arr₂, ⟨root, by simp [root.2]⟩, ?b'⟩\n  -- start proof\n  case a' => -- FIXME: hygiene bug causes `case a` to fail\n    let ⟨m, hm⟩ := self.model'\n    exact ⟨_, m, m, hm, hm, rfl, ⟨x.2, by rwa [← hm.parent_eq]⟩, le_refl _⟩\n  all_goals let ⟨n, m, m', hm, hm', e, ⟨_, hr⟩, le⟩ := H\n  case hx => exact hm'.size_eq ▸ hm.size_eq.symm ▸ x.2\n  case b' =>\n    let x' : Fin n := ⟨x, hm.size_eq ▸ x.2⟩\n    let root : Fin n := ⟨root, hm'.size_eq.symm ▸ root.2⟩\n    have hy : (UFModel.parent m x').1 = y := by rw [← hm.parent_eq x x.2 x'.2]; rfl\n    have := m.rank_lt x'; rw [hy] at this\n    have := lt_of_lt_of_le (this h) le\n    refine ⟨n, m, _, hm,\n      hm'.setParent x' root (by rw [e]; exact this) hx _ rfl rfl, e,\n      ⟨root.2, ?_⟩, le_of_lt this⟩\n    have : x.1 ≠ root := mt (congrArg _) (ne_of_lt this); dsimp only at this\n    simp [UFModel.setParent, this, hr]\ntermination_by _ α self x => self.rankMax - self.rank x\n\ndef find (self : UnionFind α) (x : Fin self.size) :\n  (s : UnionFind α) × (root : Fin s.size) ×'\n    s.size = self.size ∧ (s.arr.get root).parent = root :=\n  let ⟨s, root, H⟩ := self.findAux x\n  have : _ ∧ s.size = self.size ∧ s[root.1].parent = root :=\n    let ⟨n, _, m', hm, hm', _, ⟨_, hr⟩, _⟩ := H\n    ⟨⟨n, m', hm'⟩, hm'.size_eq.symm.trans hm.size_eq, by rwa [hm'.parent_eq]⟩\n  ⟨⟨s, this.1⟩, root, this.2⟩\n\ndef link (self : UnionFind α) (x y : Fin self.size)\n  (yroot : (self.arr.get y).parent = y) : UnionFind α := by\n  refine if ne : x.1 = y then self else\n    let nx := self.arr[x]\n    let ny := self.arr[y]\n    if h : ny.rank < nx.rank then\n      ⟨self.arr.set y {ny with parent := x}, ?a⟩\n    else\n      let arr₁ := self.arr.set x {nx with parent := y}\n      let arr₂ := if nx.rank = ny.rank then\n        arr₁.set ⟨y, by simp; exact y.2⟩ {ny with rank := ny.rank + 1}\n      else arr₁\n      ⟨arr₂, ?b⟩\n  -- start proof\n  case a =>\n    let ⟨m, hm⟩ := self.model'\n    exact ⟨_, _, hm.setParent y x (by simpa [hm.rank_eq] using h) _ _ rfl rfl⟩\n  case b =>\n    let ⟨m, hm⟩ := self.model'; let n := self.size\n    refine ⟨_, m.setParentBump x y (by simpa [hm.rank_eq] using h)\n      (by simpa [← hm.parent_eq'] using yroot), ?_⟩\n    let parent (i : Fin n) := (if x.1 = i then y else m.parent i).1\n    have : UFModel.Agrees arr₁ (·.parent) parent :=\n      hm.1.set (fun i h ↦ by simp; rw [if_neg h.symm]) (fun h ↦ by simp)\n    have H1 : UFModel.Agrees arr₂ (·.parent) parent := by\n      simp; split\n      · exact this.set (fun i h ↦ by simp [h.symm]) (fun h ↦ by simp [ne, hm.parent_eq'])\n      · exact this\n    have : UFModel.Agrees arr₁ (·.rank) (fun i : Fin n ↦ m.rank i) :=\n      hm.2.set (fun i _ ↦ by simp) (fun _ ↦ by simp [hm.rank_eq])\n    let rank (i : Fin n) := if y.1 = i ∧ m.rank x = m.rank y then m.rank y + 1 else m.rank i\n    have H2 : UFModel.Agrees arr₂ (·.rank) rank := by\n      simp; split <;> (rename_i xy; simp [hm.rank_eq] at xy; simp [xy])\n      · exact this.set (fun i h ↦ by rw [if_neg h.symm]) (fun h ↦ by simp [hm.rank_eq])\n      · exact this\n    exact ⟨H1, H2⟩\n\ndef union (self : UnionFind α) (x y : Fin self.size) : UnionFind α :=\n  let ⟨self₁, rx, e, _⟩ := self.find x\n  let ⟨self₂, ry, e, hry⟩ := self₁.find ⟨y, by rw [e]; exact y.2⟩\n  self₂.link ⟨rx, by rw [e]; exact rx.2⟩ ry hry\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/UnionFind.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4569703443250696}}
{"text": "/-\nCopyright (c) 2021 David Wärn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David Wärn, Scott Morrison\n\n! This file was ported from Lean 3 source module combinatorics.quiver.basic\n! leanprover-community/mathlib commit 56adee5b5eef9e734d82272918300fca4f3e7cef\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Opposite\n\n/-!\n# Quivers\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis module defines quivers. A quiver on a type `V` of vertices assigns to every\npair `a b : V` of vertices a type `a ⟶ b` of arrows from `a` to `b`. This\nis a very permissive notion of directed graph.\n\n## Implementation notes\n\nCurrently `quiver` is defined with `arrow : V → V → Sort v`.\nThis is different from the category theory setup,\nwhere we insist that morphisms live in some `Type`.\nThere's some balance here: it's nice to allow `Prop` to ensure there are no multiple arrows,\nbut it is also results in error-prone universe signatures when constraints require a `Type`.\n-/\n\n\nopen Opposite\n\n-- We use the same universe order as in category theory.\n-- See note [category_theory universes]\nuniverse v v₁ v₂ u u₁ u₂\n\n#print Quiver /-\n/-- A quiver `G` on a type `V` of vertices assigns to every pair `a b : V` of vertices\na type `a ⟶ b` of arrows from `a` to `b`.\n\nFor graphs with no repeated edges, one can use `quiver.{0} V`, which ensures\n`a ⟶ b : Prop`. For multigraphs, one can use `quiver.{v+1} V`, which ensures\n`a ⟶ b : Type v`.\n\nBecause `category` will later extend this class, we call the field `hom`.\nExcept when constructing instances, you should rarely see this, and use the `⟶` notation instead.\n-/\nclass Quiver (V : Type u) where\n  Hom : V → V → Sort v\n#align quiver Quiver\n-/\n\n-- mathport name: «expr ⟶ »\ninfixr:10 \" ⟶ \" => Quiver.Hom\n\n/- warning: prefunctor -> Prefunctor is a dubious translation:\nlean 3 declaration is\n  forall (V : Type.{u3}) [_inst_1 : Quiver.{u1, u3} V] (W : Type.{u4}) [_inst_2 : Quiver.{u2, u4} W], Sort.{max (imax (succ u3) (succ u3) u1 u2) (succ u3) (succ u4)}\nbut is expected to have type\n  forall (V : Type.{u3}) [_inst_1 : Quiver.{u1, u3} V] (W : Type.{u4}) [_inst_2 : Quiver.{u2, u4} W], Sort.{max (max (max (succ u3) (succ u4)) u1) u2}\nCase conversion may be inaccurate. Consider using '#align prefunctor Prefunctorₓ'. -/\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`obj] [] -/\n-- type as \\h\n/-- A morphism of quivers. As we will later have categorical functors extend this structure,\nwe call it a `prefunctor`.\n-/\nstructure Prefunctor (V : Type u₁) [Quiver.{v₁} V] (W : Type u₂) [Quiver.{v₂} W] where\n  obj : V → W\n  map : ∀ {X Y : V}, (X ⟶ Y) → (obj X ⟶ obj Y)\n#align prefunctor Prefunctor\n\nnamespace Prefunctor\n\n#print Prefunctor.ext /-\n@[ext]\ntheorem ext {V : Type u} [Quiver.{v₁} V] {W : Type u₂} [Quiver.{v₂} W] {F G : Prefunctor V W}\n    (h_obj : ∀ X, F.obj X = G.obj X)\n    (h_map :\n      ∀ (X Y : V) (f : X ⟶ Y),\n        F.map f = Eq.recOn (h_obj Y).symm (Eq.recOn (h_obj X).symm (G.map f))) :\n    F = G := by\n  cases' F with F_obj _\n  cases' G with G_obj _\n  obtain rfl : F_obj = G_obj := by\n    ext X\n    apply h_obj\n  congr\n  funext X Y f\n  simpa using h_map X Y f\n#align prefunctor.ext Prefunctor.ext\n-/\n\n#print Prefunctor.id /-\n/-- The identity morphism between quivers.\n-/\n@[simps]\ndef id (V : Type _) [Quiver V] : Prefunctor V V\n    where\n  obj := id\n  map X Y f := f\n#align prefunctor.id Prefunctor.id\n-/\n\ninstance (V : Type _) [Quiver V] : Inhabited (Prefunctor V V) :=\n  ⟨id V⟩\n\n#print Prefunctor.comp /-\n/-- Composition of morphisms between quivers.\n-/\n@[simps]\ndef comp {U : Type _} [Quiver U] {V : Type _} [Quiver V] {W : Type _} [Quiver W]\n    (F : Prefunctor U V) (G : Prefunctor V W) : Prefunctor U W\n    where\n  obj X := G.obj (F.obj X)\n  map X Y f := G.map (F.map f)\n#align prefunctor.comp Prefunctor.comp\n-/\n\n/- warning: prefunctor.comp_id -> Prefunctor.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{u2, u1} U] {V : Type.{u3}} [_inst_2 : Quiver.{u4, u3} V] (F : Prefunctor.{u2, u4, u1, u3} U _inst_1 V _inst_2), Eq.{max (imax (succ u1) (succ u1) u2 u4) (succ u1) (succ u3)} (Prefunctor.{u2, u4, u1, u3} U _inst_1 V _inst_2) (Prefunctor.comp.{u1, u2, u3, u4, u3, u4} U _inst_1 V _inst_2 V _inst_2 F (Prefunctor.id.{u3, u4} V _inst_2)) F\nbut is expected to have type\n  forall {U : Type.{u4}} {_inst_1 : Type.{u3}} [V : Quiver.{u2, u4} U] [_inst_2 : Quiver.{u1, u3} _inst_1] (F : Prefunctor.{u2, u1, u4, u3} U V _inst_1 _inst_2), Eq.{max (max (max (succ u4) (succ u3)) u2) u1} (Prefunctor.{u2, u1, u4, u3} U V _inst_1 _inst_2) (Prefunctor.comp.{u4, u2, u3, u1, u3, u1} U V _inst_1 _inst_2 _inst_1 _inst_2 F (Prefunctor.id.{u3, u1} _inst_1 _inst_2)) F\nCase conversion may be inaccurate. Consider using '#align prefunctor.comp_id Prefunctor.comp_idₓ'. -/\n@[simp]\ntheorem comp_id {U : Type _} [Quiver U] {V : Type _} [Quiver V] (F : Prefunctor U V) :\n    F.comp (id _) = F := by\n  cases F\n  rfl\n#align prefunctor.comp_id Prefunctor.comp_id\n\n/- warning: prefunctor.id_comp -> Prefunctor.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u1}} [_inst_1 : Quiver.{u2, u1} U] {V : Type.{u3}} [_inst_2 : Quiver.{u4, u3} V] (F : Prefunctor.{u2, u4, u1, u3} U _inst_1 V _inst_2), Eq.{max (imax (succ u1) (succ u1) u2 u4) (succ u1) (succ u3)} (Prefunctor.{u2, u4, u1, u3} U _inst_1 V _inst_2) (Prefunctor.comp.{u1, u2, u1, u2, u3, u4} U _inst_1 U _inst_1 V _inst_2 (Prefunctor.id.{u1, u2} U _inst_1) F) F\nbut is expected to have type\n  forall {U : Type.{u4}} {_inst_1 : Type.{u3}} [V : Quiver.{u2, u4} U] [_inst_2 : Quiver.{u1, u3} _inst_1] (F : Prefunctor.{u2, u1, u4, u3} U V _inst_1 _inst_2), Eq.{max (max (max (succ u4) (succ u3)) u2) u1} (Prefunctor.{u2, u1, u4, u3} U V _inst_1 _inst_2) (Prefunctor.comp.{u4, u2, u4, u2, u3, u1} U V U V _inst_1 _inst_2 (Prefunctor.id.{u4, u2} U V) F) F\nCase conversion may be inaccurate. Consider using '#align prefunctor.id_comp Prefunctor.id_compₓ'. -/\n@[simp]\ntheorem id_comp {U : Type _} [Quiver U] {V : Type _} [Quiver V] (F : Prefunctor U V) :\n    (id _).comp F = F := by\n  cases F\n  rfl\n#align prefunctor.id_comp Prefunctor.id_comp\n\n/- warning: prefunctor.comp_assoc -> Prefunctor.comp_assoc is a dubious translation:\nlean 3 declaration is\n  forall {U : Type.{u1}} {V : Type.{u2}} {W : Type.{u3}} {Z : Type.{u4}} [_inst_1 : Quiver.{u5, u1} U] [_inst_2 : Quiver.{u6, u2} V] [_inst_3 : Quiver.{u7, u3} W] [_inst_4 : Quiver.{u8, u4} Z] (F : Prefunctor.{u5, u6, u1, u2} U _inst_1 V _inst_2) (G : Prefunctor.{u6, u7, u2, u3} V _inst_2 W _inst_3) (H : Prefunctor.{u7, u8, u3, u4} W _inst_3 Z _inst_4), Eq.{max (imax (succ u1) (succ u1) u5 u8) (succ u1) (succ u4)} (Prefunctor.{u5, u8, u1, u4} U _inst_1 Z _inst_4) (Prefunctor.comp.{u1, u5, u3, u7, u4, u8} U _inst_1 W _inst_3 Z _inst_4 (Prefunctor.comp.{u1, u5, u2, u6, u3, u7} U _inst_1 V _inst_2 W _inst_3 F G) H) (Prefunctor.comp.{u1, u5, u2, u6, u4, u8} U _inst_1 V _inst_2 Z _inst_4 F (Prefunctor.comp.{u2, u6, u3, u7, u4, u8} V _inst_2 W _inst_3 Z _inst_4 G H))\nbut is expected to have type\n  forall {U : Type.{u8}} {V : Type.{u7}} {W : Type.{u6}} {Z : Type.{u5}} [_inst_1 : Quiver.{u4, u8} U] [_inst_2 : Quiver.{u3, u7} V] [_inst_3 : Quiver.{u2, u6} W] [_inst_4 : Quiver.{u1, u5} Z] (F : Prefunctor.{u4, u3, u8, u7} U _inst_1 V _inst_2) (G : Prefunctor.{u3, u2, u7, u6} V _inst_2 W _inst_3) (H : Prefunctor.{u2, u1, u6, u5} W _inst_3 Z _inst_4), Eq.{max (max (max (succ u8) (succ u5)) u4) u1} (Prefunctor.{u4, u1, u8, u5} U _inst_1 Z _inst_4) (Prefunctor.comp.{u8, u4, u6, u2, u5, u1} U _inst_1 W _inst_3 Z _inst_4 (Prefunctor.comp.{u8, u4, u7, u3, u6, u2} U _inst_1 V _inst_2 W _inst_3 F G) H) (Prefunctor.comp.{u8, u4, u7, u3, u5, u1} U _inst_1 V _inst_2 Z _inst_4 F (Prefunctor.comp.{u7, u3, u6, u2, u5, u1} V _inst_2 W _inst_3 Z _inst_4 G H))\nCase conversion may be inaccurate. Consider using '#align prefunctor.comp_assoc Prefunctor.comp_assocₓ'. -/\n@[simp]\ntheorem comp_assoc {U V W Z : Type _} [Quiver U] [Quiver V] [Quiver W] [Quiver Z]\n    (F : Prefunctor U V) (G : Prefunctor V W) (H : Prefunctor W Z) :\n    (F.comp G).comp H = F.comp (G.comp H) :=\n  rfl\n#align prefunctor.comp_assoc Prefunctor.comp_assoc\n\n-- mathport name: «expr ⥤q »\ninfixl:50 \" ⥤q \" => Prefunctor\n\n-- mathport name: «expr ⋙q »\ninfixl:60 \" ⋙q \" => Prefunctor.comp\n\n-- mathport name: «expr𝟭q»\nnotation \"𝟭q\" => id\n\nend Prefunctor\n\nnamespace Quiver\n\n#print Quiver.opposite /-\n/-- `Vᵒᵖ` reverses the direction of all arrows of `V`. -/\ninstance opposite {V} [Quiver V] : Quiver Vᵒᵖ :=\n  ⟨fun a b => unop b ⟶ unop a⟩\n#align quiver.opposite Quiver.opposite\n-/\n\n#print Quiver.Hom.op /-\n/-- The opposite of an arrow in `V`.\n-/\ndef Hom.op {V} [Quiver V] {X Y : V} (f : X ⟶ Y) : op Y ⟶ op X :=\n  f\n#align quiver.hom.op Quiver.Hom.op\n-/\n\n#print Quiver.Hom.unop /-\n/-- Given an arrow in `Vᵒᵖ`, we can take the \"unopposite\" back in `V`.\n-/\ndef Hom.unop {V} [Quiver V] {X Y : Vᵒᵖ} (f : X ⟶ Y) : unop Y ⟶ unop X :=\n  f\n#align quiver.hom.unop Quiver.Hom.unop\n-/\n\n#print Quiver.Empty /-\n/-- A type synonym for a quiver with no arrows. -/\n@[nolint has_nonempty_instance]\ndef Empty (V) : Type u :=\n  V\n#align quiver.empty Quiver.Empty\n-/\n\n#print Quiver.emptyQuiver /-\ninstance emptyQuiver (V : Type u) : Quiver.{u} (Empty V) :=\n  ⟨fun a b => PEmpty⟩\n#align quiver.empty_quiver Quiver.emptyQuiver\n-/\n\n#print Quiver.empty_arrow /-\n@[simp]\ntheorem empty_arrow {V : Type u} (a b : Empty V) : (a ⟶ b) = PEmpty :=\n  rfl\n#align quiver.empty_arrow Quiver.empty_arrow\n-/\n\n#print Quiver.IsThin /-\n/-- A quiver is thin if it has no parallel arrows. -/\n@[reducible]\ndef IsThin (V : Type u) [Quiver V] :=\n  ∀ a b : V, Subsingleton (a ⟶ b)\n#align quiver.is_thin Quiver.IsThin\n-/\n\nend Quiver\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Combinatorics/Quiver/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.45695956364043316}}
{"text": "import data.set.lattice\nimport data.set.function\nimport tactic\n\nopen set\nopen function\n\n/- TEXT:\n.. _the_schroeder_bernstein_theorem:\n\nThe Schröder-Bernstein Theorem\n------------------------------\n\nWe close this chapter with an elementary but nontrivial theorem of set theory.\nLet :math:`\\alpha` and :math:`\\beta` be sets.\n(In our formalization, they will actually be types.)\nSuppose :math:`f : \\alpha → \\beta` and :math:`g : \\beta → \\alpha`\nare both injective.\nIntuitively, this means that :math:`\\alpha` is no bigger than :math:`\\beta` and vice-versa.\nIf :math:`\\alpha` and :math:`\\beta` are finite, this implies that\nthey have the same cardinality, which is equivalent to saying that there\nis a bijection between them.\nIn the nineteenth century, Cantor stated that same result holds even in the\ncase where :math:`\\alpha` and :math:`\\beta` are infinite.\nThis was eventually established by Dedekind, Schröder, and Bernstein\nindependently.\n\nOur formalization will introduce some new methods that we will explain\nin greater detail in chapters to come.\nDon't worry if they go by too quickly here.\nOur goal is to show you that you already have the skills to contribute\nto the formal proof of a real mathematical result.\n\nTo understand the idea behind the proof, consider the image of the map\n:math:`g` in :math:`\\alpha`.\nOn that image, the inverse of :math:`g` is defined and is a bijection\nwith :math:`\\beta`.\n\n.. image:: /figures/schroeder_bernstein1.*\n   :height: 150 px\n   :alt: the Schröder Bernstein theorem\n   :align: center\n\nThe problem is that the bijection does not include the shaded region\nin the diagram, which is nonempty if :math:`g` is not surjective.\nAlternatively, we can use :math:`f` to map all of\n:math:`\\alpha` to :math:`\\beta`,\nbut in that case the problem is that if :math:`f` is not surjective,\nit will miss some elements of :math:`\\beta`.\n\n.. image:: /figures/schroeder_bernstein2.*\n   :height: 150 px\n   :alt: the Schröder Bernstein theorem\n   :align: center\n\nBut now consider the composition :math:`g \\circ f` from :math:`\\alpha` to\nitself. Because the composition is injective, it forms a bijection between\n:math:`\\alpha` and its image, yielding a scaled-down copy of :math:`\\alpha`\ninside itself.\n\n.. image:: /figures/schroeder_bernstein3.*\n   :height: 150 px\n   :alt: the Schröder Bernstein theorem\n   :align: center\n\nThis composition maps the inner shaded ring to yet another such\nset, which we can think of as an even smaller concentric shaded ring,\nand so on.\nThis yields a\nconcentric sequence of shaded rings, each of which is in\nbijective correspondence with the next.\nIf we map each ring to the next and leave the unshaded\nparts of :math:`\\alpha` alone,\nwe have a bijection of :math:`\\alpha` with the image of :math:`g`.\nComposing with :math:`g^{-1}`, this yields the desired\nbijection between :math:`\\alpha` and :math:`\\beta`.\n\nWe can describe this bijection more simply.\nLet :math:`A` be the union of the sequence of shaded regions, and\ndefine :math:`h : \\alpha \\to \\beta` as follows:\n\n.. math::\n\n  h(x) = \\begin{cases}\n    f(x) & \\text{if $x \\in A$} \\\\\n    g^{-1}(x) & \\text{otherwise.}\n  \\end{cases}\n\nIn other words, we use :math:`f` on the shaded parts,\nand we use the inverse of :math:`g` everywhere else.\nThe resulting map :math:`h` is injective\nbecause each component is injective\nand the images of the two components are disjoint.\nTo see that it is surjective,\nsuppose we are given a :math:`y` in :math:`\\beta`, and\nconsider :math:`g(y)`.\nIf :math:`g(y)` is in one of the shaded regions,\nit cannot be in the first ring, so we have :math:`g(y) = g(f(x))`\nfor some :math:`x` is in the previous ring.\nBy the injectivity of :math:`g`, we have :math:`h(x) = f(x) = y`.\nIf :math:`g(y)` is not in the shaded region,\nthen by the definition of :math:`h`, we have :math:`h(g(y))= y`.\nEither way, :math:`y` is in the image of :math:`h`.\n\nThis argument should sound plausible, but the details are delicate.\nFormalizing the proof will not only improve our confidence in the\nresult, but also help us understand it better.\nBecause the proof uses classical logic, we tell Lean that our definitions\nwill generally not be computable.\nBOTH: -/\n-- QUOTE:\nnoncomputable theory\nopen_locale classical\n\nvariables {α β : Type*} [nonempty β]\n-- QUOTE.\n\n/- TEXT:\nThe annotation ``[nonempty β]`` specifies that ``β`` is nonempty.\nWe use it because the mathlib primitive that we will use to\nconstruct :math:`g^{-1}` requires it.\nThe case of the theorem where :math:`\\beta` is empty is trivial,\nand even though it would not be hard to generalize the formalization to cover\nthat case as well, we will not bother.\nSpecifically, we need the hypothesis ``[nonempty β]`` for the operation\n``inv_fun`` that is defined in mathlib.\nGiven ``x : α``, ``inv_fun g x`` chooses a preimage of ``x``\nin ``β`` if there is one,\nand returns an arbitrary element of ``β`` otherwise.\nThe function ``inv_fun g`` is always a left inverse if ``g`` is injective\nand a right inverse if ``g`` is surjective.\n\n-- LITERALINCLUDE: inv_fun g\n\nWe define the set corresponding to the union of the shaded regions as follows.\n\nBOTH: -/\nsection\n-- QUOTE:\nvariables (f : α → β) (g : β → α)\n\ndef sb_aux : ℕ → set α\n| 0       := univ \\ (g '' univ)\n| (n + 1) := g '' (f '' sb_aux n)\n\ndef sb_set := ⋃ n, sb_aux f g n\n-- QUOTE.\n\n/- TEXT:\nThe definition ``sb_aux`` is an example of a *recursive definition*,\nwhich we will explain in the next chapter.\nIt defines a sequence of sets\n\n.. math::\n\n  S_0 &= \\alpha ∖ g(\\beta) \\\\\n  S_{n+1} &= g(f(S_n)).\n\nThe definition ``sb_set`` corresponds to the set\n:math:`A = \\bigcup_{n \\in \\mathbb{N}} S_n` in our proof sketch.\nThe function :math:`h` described above is now defined as follows:\nBOTH: -/\n-- QUOTE:\ndef sb_fun (x : α) : β := if x ∈ sb_set f g then f x else inv_fun g x\n-- QUOTE.\n\n/- TEXT:\nWe will need the fact that our definition of :math:`g^{-1}` is a\nright inverse on the complement of :math:`A`,\nwhich is to say, on the non-shaded regions of :math:`\\alpha`.\nThis is so because the outermost ring, :math:`S_0`, is equal to\n:math:`\\alpha \\setminus g(\\beta)`, so the complement of :math:`A` is\ncontained in :math:`g(\\beta)`.\nAs a result, for every :math:`x` in the complement of :math:`A`,\nthere is a :math:`y` such that :math:`g(y) = x`.\n(By the injectivity of :math:`g`, this :math:`y` is unique,\nbut next theorem says only that ``inv_fun g x`` returns some ``y``\nsuch that ``g y = x``.)\n\nStep through the proof below, make sure you understand what is going on,\nand fill in the remaining parts.\nYou will need to use ``inv_fun_eq`` at the end.\nNotice that rewriting with ``sb_aux`` here replaces ``sb_aux f g 0``\nwith the right-hand side of the corresponding defining equation.\nBOTH: -/\n-- QUOTE:\ntheorem sb_right_inv {x : α} (hx : x ∉ sb_set f g) :\n    g (inv_fun g x) = x :=\nbegin\n  have : x ∈ g '' univ,\n  { contrapose! hx,\n    rw [sb_set, mem_Union],\n    use [0],\n    rw [sb_aux, mem_diff],\n/- EXAMPLES:\n    sorry },\nSOLUTIONS: -/\n    exact ⟨mem_univ _, hx⟩ },\n-- BOTH:\n  have : ∃ y, g y = x,\n/- EXAMPLES:\n  { sorry },\n  sorry\nSOLUTIONS: -/\n  { simp at this, assumption },\n  exact inv_fun_eq this\n-- BOTH:\nend\n-- QUOTE.\n\n/- TEXT:\nWe now turn to the proof that :math:`h` is injective.\nInformally, the proof goes as follows.\nFirst, suppose :math:`h(x_1) = h(x_2)`.\nIf :math:`x_1` is in :math:`A`, then :math:`h(x_1) = f(x_1)`,\nand we can show that :math:`x_2` is in :math:`A` as follows.\nIf it isn't, then we have :math:`h(x_2) = g^{-1}(x_2)`.\nFrom :math:`f(x_1) = h(x_1) = h(x_2)` we have :math:`g(f(x_1)) = x_2`.\nFrom the definition of :math:`A`, since :math:`x_1` is in :math:`A`,\n:math:`x_2` is in :math:`A` as well, a contradiction.\nHence, if :math:`x_1` is in :math:`A`, so is :math:`x_2`,\nin which case we have :math:`f(x_1) = h(x_1) = h(x_2) = f(x_2)`.\nThe injectivity of :math:`f` then implies :math:`x_1 = x_2`.\nThe symmetric argument shows that if :math:`x_2` is in :math:`A`,\nthen so is :math:`x_1`, which again implies :math:`x_1 = x_2`.\n\nThe only remaining possibility is that neither :math:`x_1` nor :math:`x_2`\nis in :math:`A`. In that case, we have\n:math:`g^{-1}(x_1) = h(x_1) = h(x_2) = g^{-1}(x_2)`.\nApplying :math:`g` to both sides yields :math:`x_1 = x_2`.\n\nOnce again, we encourage you to step through the following proof\nto see how the argument plays out in Lean.\nSee if you can finish off the proof using ``sb_right_inv``.\nBOTH: -/\n-- QUOTE:\ntheorem sb_injective (hf: injective f) (hg : injective g) :\n  injective (sb_fun f g) :=\nbegin\n  set A := sb_set f g with A_def,\n  set h := sb_fun f g with h_def,\n  intros x₁ x₂,\n  assume hxeq : h x₁ = h x₂,\n  show x₁ = x₂,\n  simp only [h_def, sb_fun, ←A_def] at hxeq,\n  by_cases xA : x₁ ∈ A ∨ x₂ ∈ A,\n  { wlog : x₁ ∈ A := xA using [x₁ x₂, x₂ x₁],\n    have x₂A : x₂ ∈ A,\n    { apply not_imp_self.mp,\n      assume x₂nA : x₂ ∉ A,\n      rw [if_pos xA, if_neg x₂nA] at hxeq,\n      rw [A_def, sb_set, mem_Union] at xA,\n      have x₂eq : x₂ = g (f x₁),\n/- EXAMPLES:\n      { sorry },\nSOLUTIONS: -/\n      { rw [hxeq, sb_right_inv f g x₂nA] },\n-- BOTH:\n      rcases xA with ⟨n, hn⟩,\n      rw [A_def, sb_set, mem_Union],\n      use n + 1,\n      simp [sb_aux],\n      exact ⟨x₁, hn, x₂eq.symm⟩ },\n/- EXAMPLES:\n    sorry },\nSOLUTIONS: -/\n    rw [if_pos xA, if_pos x₂A] at hxeq,\n    exact hf hxeq },\n-- BOTH:\n  push_neg at xA,\n/- EXAMPLES:\n  sorry\nSOLUTIONS: -/\n  rw [if_neg xA.1, if_neg xA.2] at hxeq,\n  rw [←sb_right_inv f g xA.1, hxeq, sb_right_inv f g xA.2]\n-- BOTH:\nend\n-- QUOTE.\n\n/- TEXT:\nThe proof introduces some new tactics.\nTo start with, notice the ``set`` tactic, which introduces abbreviations\n``A`` and ``h`` for ``sb_set f g`` and ``sb_fun f g`` respectively.\nWe name the corresponding defining equations ``A_def`` and ``h_def``.\nThe abbreviations are definitional, which is to say, Lean will sometimes\nunfold them automatically when needed.\nBut not always; for example, when using ``rw``, we generally need to\nuse ``A_def`` and ``h_def`` explicitly.\nSo the definitions bring a tradeoff: they can make expressions shorter\nand more readable, but they sometimes require us to do more work.\n\nA more interesting tactic is the ``wlog`` tactic, which encapsulates\nthe symmetry argument in the informal proof above.\nWe will not dwell on it now, but notice that it does exactly what we want.\nIf you hover over the tactic you can take a look at its documentation.\n\nThe argument for surjectivity is even easier.\nGiven :math:`y` in :math:`\\beta`,\nwe consider two cases, depending on whether :math:`g(y)` is in :math:`A`.\nIf it is, it can't be in :math:`S_0`, the outermost ring,\nbecause by definition that is disjoint from the image of :math:`g`.\nThus it is an element of :math:`S_{n+1}` for some :math:`n`.\nThis means that it is of the form :math:`g(f(x))` for some\n:math:`x` in :math:`S_n`.\nBy the injectivity of :math:`g`, we have :math:`f(x) = y`.\nIn the case where :math:`g(y)` is in the complement of :math:`A`,\nwe immediately have :math:`h(g(y))= y`, and we are done.\n\nOnce again, we encourage you to step through the proof and fill in\nthe missing parts.\nThe tactic ``cases n with n`` splits on the cases ``g y ∈ sb_aux f g 0``\nand ``g y ∈ sb_aux f g n.succ``.\nIn both cases, calling the simplifier with ``simp [sb_aux]``\napplies the corresponding defining equation of ``sb_aux``.\nBOTH: -/\n-- QUOTE:\ntheorem sb_surjective (hf: injective f) (hg : injective g) :\n  surjective (sb_fun f g) :=\nbegin\n  set A := sb_set f g with A_def,\n  set h := sb_fun f g with h_def,\n  intro y,\n  by_cases gyA : g y ∈ A,\n  { rw [A_def, sb_set, mem_Union] at gyA,\n    rcases gyA with ⟨n, hn⟩,\n    cases n with n,\n    { simp [sb_aux] at hn,\n      contradiction },\n    simp [sb_aux] at hn,\n    rcases hn with ⟨x, xmem, hx⟩,\n    use x,\n    have : x ∈ A,\n    { rw [A_def, sb_set, mem_Union],\n      exact ⟨n, xmem⟩ },\n    simp only [h_def, sb_fun, if_pos this],\n    exact hg hx },\n/- EXAMPLES:\n  sorry\nSOLUTIONS: -/\n  use g y,\n  simp only [h_def, sb_fun, if_neg gyA],\n  apply left_inverse_inv_fun hg\n-- BOTH:\nend\n-- QUOTE.\n\nend\n\n/- TEXT:\nWe can now put it all together. The final statement is short and sweet,\nand the proof uses the fact that ``bijective h`` unfolds to\n``injective h ∧ surjective h``.\nEXAMPLES: -/\n-- QUOTE:\ntheorem schroeder_bernstein {f : α → β} {g : β → α}\n    (hf: injective f) (hg : injective g) :\n  ∃ h : α → β, bijective h :=\n⟨sb_fun f g, sb_injective f g hf hg, sb_surjective f g hf hg⟩\n-- QUOTE.\n\n/- Auxliary information -/\n\nsection\n\nvariables  (g : β → α) (x : α)\n\n-- TAG: inv_fun g\n#check (inv_fun g : α → β)\n\n#check (left_inverse_inv_fun : injective g → left_inverse (inv_fun g) g)\n#check (left_inverse_inv_fun : injective g → ∀ y, inv_fun g (g y) = y)\n\n#check (inv_fun_eq : (∃ y, g y = x) → g (inv_fun g x) = x)\n-- TAG: end\nend\n", "meta": {"author": "avigad", "repo": "mathematics_in_lean_source", "sha": "4eeb8c43762522c1acaa7f799599609d6a48f59e", "save_path": "github-repos/lean/avigad-mathematics_in_lean_source", "path": "github-repos/lean/avigad-mathematics_in_lean_source/mathematics_in_lean_source-4eeb8c43762522c1acaa7f799599609d6a48f59e/lean_source/04_Sets_and_Functions/source_03_The_Schroeder_Bernstein_Theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.45695956364043316}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.normed_space.multilinear\nimport Mathlib.ring_theory.power_series.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 \n\nnamespace Mathlib\n\n/-!\n# Formal multilinear series\n\nIn this file we define `formal_multilinear_series 𝕜 E F` to be a family of `n`-multilinear maps for\nall `n`, designed to model the sequence of derivatives of a function. In other files we use this\nnotion to define `C^n` functions (called `times_cont_diff` in `mathlib`) and analytic functions.\n\n## Notations\n\nWe use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with\nvalues in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.\n\n## Tags\n\nmultilinear, formal series\n-/\n\n/-- A formal multilinear series over a field `𝕜`, from `E` to `F`, is given by a family of\nmultilinear maps from `E^n` to `F` for all `n`. -/\ndef formal_multilinear_series (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] (E : Type u_2)\n    [normed_group E] [normed_space 𝕜 E] (F : Type u_3) [normed_group F] [normed_space 𝕜 F] :=\n  (n : ℕ) → continuous_multilinear_map 𝕜 (fun (i : fin n) => E) F\n\nprotected instance formal_multilinear_series.inhabited {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F]\n    [normed_space 𝕜 F] : Inhabited (formal_multilinear_series 𝕜 E F) :=\n  { default := 0 }\n\n/- `derive` is not able to find the module structure, probably because Lean is confused by the\ndependent types. We register it explicitly. -/\n\nprotected instance formal_multilinear_series.module {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F]\n    [normed_space 𝕜 F] : module 𝕜 (formal_multilinear_series 𝕜 E F) :=\n  let _inst : (n : ℕ) → module 𝕜 (continuous_multilinear_map 𝕜 (fun (i : fin n) => E) F) :=\n    fun (n : ℕ) => continuous_multilinear_map.semimodule;\n  pi.semimodule ℕ (fun (n : ℕ) => continuous_multilinear_map 𝕜 (fun (i : fin n) => E) F) 𝕜\n\nnamespace formal_multilinear_series\n\n\n/-- Forgetting the zeroth term in a formal multilinear series, and interpreting the following terms\nas multilinear maps into `E →L[𝕜] F`. If `p` corresponds to the Taylor series of a function, then\n`p.shift` is the Taylor series of the derivative of the function. -/\ndef shift {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E]\n    [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    (p : formal_multilinear_series 𝕜 E F) :\n    formal_multilinear_series 𝕜 E (continuous_linear_map 𝕜 E F) :=\n  fun (n : ℕ) => continuous_multilinear_map.curry_right (p (Nat.succ n))\n\n/-- Adding a zeroth term to a formal multilinear series taking values in `E →L[𝕜] F`. This\ncorresponds to starting from a Taylor series for the derivative of a function, and building a Taylor\nseries for the function itself. -/\ndef unshift {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E]\n    [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    (q : formal_multilinear_series 𝕜 E (continuous_linear_map 𝕜 E F)) (z : F) :\n    formal_multilinear_series 𝕜 E F :=\n  sorry\n\n/-- Killing the zeroth coefficient in a formal multilinear series -/\ndef remove_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E]\n    [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    (p : formal_multilinear_series 𝕜 E F) : formal_multilinear_series 𝕜 E F :=\n  sorry\n\n@[simp] theorem remove_zero_coeff_zero {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    (p : formal_multilinear_series 𝕜 E F) : remove_zero p 0 = 0 :=\n  rfl\n\n@[simp] theorem remove_zero_coeff_succ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    (p : formal_multilinear_series 𝕜 E F) (n : ℕ) : remove_zero p (n + 1) = p (n + 1) :=\n  rfl\n\ntheorem remove_zero_of_pos {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    (p : formal_multilinear_series 𝕜 E F) {n : ℕ} (h : 0 < n) : remove_zero p n = p n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (remove_zero p n = p n)) (Eq.symm (nat.succ_pred_eq_of_pos h))))\n    (Eq.refl (remove_zero p (Nat.succ (Nat.pred n))))\n\n/-- Convenience congruence lemma stating in a dependent setting that, if the arguments to a formal\nmultilinear series are equal, then the values are also equal. -/\ntheorem congr {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E]\n    [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    (p : formal_multilinear_series 𝕜 E F) {m : ℕ} {n : ℕ} {v : fin m → E} {w : fin n → E}\n    (h1 : m = n)\n    (h2 :\n      ∀ (i : ℕ) (him : i < m) (hin : i < n),\n        v { val := i, property := him } = w { val := i, property := hin }) :\n    coe_fn (p m) v = coe_fn (p n) w :=\n  sorry\n\n/-- Composing each term `pₙ` in a formal multilinear series with `(u, ..., u)` where `u` is a fixed\ncontinuous linear map, gives a new formal multilinear series `p.comp_continuous_linear_map u`. -/\ndef comp_continuous_linear_map {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    {G : Type u_4} [normed_group G] [normed_space 𝕜 G] (p : formal_multilinear_series 𝕜 F G)\n    (u : continuous_linear_map 𝕜 E F) : formal_multilinear_series 𝕜 E G :=\n  fun (n : ℕ) => continuous_multilinear_map.comp_continuous_linear_map (p n) fun (i : fin n) => u\n\n@[simp] theorem comp_continuous_linear_map_apply {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜]\n    {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F]\n    [normed_space 𝕜 F] {G : Type u_4} [normed_group G] [normed_space 𝕜 G]\n    (p : formal_multilinear_series 𝕜 F G) (u : continuous_linear_map 𝕜 E F) (n : ℕ)\n    (v : fin n → E) : coe_fn (comp_continuous_linear_map p u n) v = coe_fn (p n) (⇑u ∘ v) :=\n  rfl\n\n/-- Reinterpret a formal `𝕜'`-multilinear series as a formal `𝕜`-multilinear series, where `𝕜'` is a\nnormed algebra over `𝕜`. -/\n@[simp] protected def restrict_scalars (𝕜 : Type u_1) [nondiscrete_normed_field 𝕜] {E : Type u_2}\n    [normed_group E] [normed_space 𝕜 E] {F : Type u_3} [normed_group F] [normed_space 𝕜 F]\n    {𝕜' : Type u_5} [nondiscrete_normed_field 𝕜'] [normed_algebra 𝕜 𝕜'] [normed_space 𝕜' E]\n    [is_scalar_tower 𝕜 𝕜' E] [normed_space 𝕜' F] [is_scalar_tower 𝕜 𝕜' F]\n    (p : formal_multilinear_series 𝕜' E F) : formal_multilinear_series 𝕜 E F :=\n  fun (n : ℕ) => continuous_multilinear_map.restrict_scalars 𝕜 (p n)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/calculus/formal_multilinear_series_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6224593452091672, "lm_q1q2_score": 0.4569595600195516}}
{"text": "/-\nCopyright (c) 2019 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.endomorphism\nimport Mathlib.category_theory.category.Cat\nimport Mathlib.algebra.category.Mon.basic\nimport Mathlib.PostPort\n\nuniverses u v w u_1 \n\nnamespace Mathlib\n\n/-!\n# Single-object category\n\nSingle object category with a given monoid of endomorphisms.  It is defined to facilitate transfering\nsome definitions and lemmas (e.g., conjugacy etc.) from category theory to monoids and groups.\n\n## Main definitions\n\nGiven a type `α` with a monoid structure, `single_obj α` is `unit` type with `category` structure\nsuch that `End (single_obj α).star` is the monoid `α`.  This can be extended to a functor `Mon ⥤\nCat`.\n\nIf `α` is a group, then `single_obj α` is a groupoid.\n\nAn element `x : α` can be reinterpreted as an element of `End (single_obj.star α)` using\n`single_obj.to_End`.\n\n## Implementation notes\n\n- `category_struct.comp` on `End (single_obj.star α)` is `flip (*)`, not `(*)`. This way\n  multiplication on `End` agrees with the multiplication on `α`.\n\n- By default, Lean puts instances into `category_theory` namespace instead of\n  `category_theory.single_obj`, so we give all names explicitly.\n-/\n\nnamespace category_theory\n\n\n/-- Type tag on `unit` used to define single-object categories and groupoids. -/\ndef single_obj (α : Type u) :=\n  Unit\n\nnamespace single_obj\n\n\n/-- One and `flip (*)` become `id` and `comp` for morphisms of the single object category. -/\nprotected instance category_struct (α : Type u) [HasOne α] [Mul α] : category_struct (single_obj α) :=\n  category_struct.mk (fun (_x : single_obj α) => 1)\n    fun (_x _x_1 _x_2 : single_obj α) (x : _x ⟶ _x_1) (y : _x_1 ⟶ _x_2) => y * x\n\n/-- Monoid laws become category laws for the single object category. -/\nprotected instance category (α : Type u) [monoid α] : category (single_obj α) :=\n  category.mk\n\n/--\nGroupoid structure on `single_obj α`.\n\nSee https://stacks.math.columbia.edu/tag/0019.\n-/\nprotected instance groupoid (α : Type u) [group α] : groupoid (single_obj α) :=\n  groupoid.mk fun (_x _x_1 : single_obj α) (x : _x ⟶ _x_1) => x⁻¹\n\n/-- The single object in `single_obj α`. -/\nprotected def star (α : Type u) : single_obj α :=\n  Unit.unit\n\n/-- The endomorphisms monoid of the only object in `single_obj α` is equivalent to the original\n     monoid α. -/\ndef to_End (α : Type u) [monoid α] : α ≃* End (single_obj.star α) :=\n  mul_equiv.mk (equiv.to_fun (equiv.refl α)) (equiv.inv_fun (equiv.refl α)) sorry sorry sorry\n\ntheorem to_End_def (α : Type u) [monoid α] (x : α) : coe_fn (to_End α) x = x :=\n  rfl\n\n/-- There is a 1-1 correspondence between monoid homomorphisms `α → β` and functors between the\n    corresponding single-object categories. It means that `single_obj` is a fully faithful\n    functor.\n\nSee https://stacks.math.columbia.edu/tag/001F --\nalthough we do not characterize when the functor is full or faithful.\n-/\ndef map_hom (α : Type u) (β : Type v) [monoid α] [monoid β] : (α →* β) ≃ single_obj α ⥤ single_obj β :=\n  equiv.mk (fun (f : α →* β) => functor.mk id fun (_x _x : single_obj α) => ⇑f)\n    (fun (f : single_obj α ⥤ single_obj β) => monoid_hom.mk (functor.map f) sorry sorry) sorry sorry\n\ntheorem map_hom_id (α : Type u) [monoid α] : coe_fn (map_hom α α) (monoid_hom.id α) = 𝟭 :=\n  rfl\n\ntheorem map_hom_comp {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β) {γ : Type w} [monoid γ] (g : β →* γ) : coe_fn (map_hom α γ) (monoid_hom.comp g f) = coe_fn (map_hom α β) f ⋙ coe_fn (map_hom β γ) g :=\n  rfl\n\nend single_obj\n\n\nend category_theory\n\n\nnamespace monoid_hom\n\n\n/-- Reinterpret a monoid homomorphism `f : α → β` as a functor `(single_obj α) ⥤ (single_obj β)`.\nSee also `category_theory.single_obj.map_hom` for an equivalence between these types. -/\ndef to_functor {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β) : category_theory.single_obj α ⥤ category_theory.single_obj β :=\n  coe_fn (category_theory.single_obj.map_hom α β) f\n\n@[simp] theorem id_to_functor (α : Type u) [monoid α] : to_functor (id α) = 𝟭 :=\n  rfl\n\n@[simp] theorem comp_to_functor {α : Type u} {β : Type v} [monoid α] [monoid β] (f : α →* β) {γ : Type w} [monoid γ] (g : β →* γ) : to_functor (comp g f) = to_functor f ⋙ to_functor g :=\n  rfl\n\nend monoid_hom\n\n\nnamespace units\n\n\n/--\nThe units in a monoid are (multiplicatively) equivalent to\nthe automorphisms of `star` when we think of the monoid as a single-object category. -/\ndef to_Aut (α : Type u) [monoid α] : units α ≃* category_theory.Aut (category_theory.single_obj.star α) :=\n  mul_equiv.trans (map_equiv (category_theory.single_obj.to_End α))\n    (category_theory.Aut.units_End_equiv_Aut (category_theory.single_obj.star α))\n\n@[simp] theorem to_Aut_hom (α : Type u) [monoid α] (x : units α) : category_theory.iso.hom (coe_fn (to_Aut α) x) = coe_fn (category_theory.single_obj.to_End α) ↑x :=\n  rfl\n\n@[simp] theorem to_Aut_inv (α : Type u) [monoid α] (x : units α) : category_theory.iso.inv (coe_fn (to_Aut α) x) = coe_fn (category_theory.single_obj.to_End α) ↑(x⁻¹) :=\n  rfl\n\nend units\n\n\nnamespace Mon\n\n\n/-- The fully faithful functor from `Mon` to `Cat`. -/\ndef to_Cat : Mon ⥤ category_theory.Cat :=\n  category_theory.functor.mk (fun (x : Mon) => category_theory.Cat.of (category_theory.single_obj ↥x))\n    fun (x y : Mon) (f : x ⟶ y) => coe_fn (category_theory.single_obj.map_hom ↥x ↥y) f\n\nprotected instance to_Cat_full : category_theory.full to_Cat :=\n  category_theory.full.mk fun (x y : Mon) => equiv.inv_fun (category_theory.single_obj.map_hom ↥x ↥y)\n\nprotected instance to_Cat_faithful : category_theory.faithful to_Cat :=\n  category_theory.faithful.mk\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/single_obj.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4569595497365099}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl\n\nContinuous linear functions -- functions between normed vector spaces which are bounded and linear.\n-/\nimport algebra.field\nimport tactic.norm_num\nimport analysis.normed_space.basic\nimport analysis.asymptotics\n\n@[simp] lemma mul_inv_eq' {α} [discrete_field α] (a b : α) : (a * b)⁻¹ = b⁻¹ * a⁻¹ :=\nclassical.by_cases (assume : a = 0, by simp [this]) $ assume ha,\nclassical.by_cases (assume : b = 0, by simp [this]) $ assume hb,\nmul_inv_eq hb ha\n\nnoncomputable theory\nlocal attribute [instance] classical.prop_decidable\n\nlocal notation f ` →_{`:50 a `} `:0 b := filter.tendsto f (nhds a) (nhds b)\n\nopen filter (tendsto)\nopen metric\n\nvariables {k : Type*} [normed_field k]\nvariables {E : Type*} [normed_space k E]\nvariables {F : Type*} [normed_space k F]\nvariables {G : Type*} [normed_space k G]\n\nstructure is_bounded_linear_map (k : Type*)\n  [normed_field k] {E : Type*} [normed_space k E] {F : Type*} [normed_space k F] (L : E → F)\n  extends is_linear_map k L : Prop :=\n(bound : ∃ M, M > 0 ∧ ∀ x : E, ∥ L x ∥ ≤ M * ∥ x ∥)\n\ninclude k\n\nlemma is_linear_map.with_bound\n  {L : E → F} (hf : is_linear_map k L) (M : ℝ) (h : ∀ x : E, ∥ L x ∥ ≤ M * ∥ x ∥) :\n  is_bounded_linear_map k L :=\n⟨ hf, classical.by_cases\n  (assume : M ≤ 0, ⟨1, zero_lt_one, assume x,\n    le_trans (h x) $ mul_le_mul_of_nonneg_right (le_trans this zero_le_one) (norm_nonneg x)⟩)\n  (assume : ¬ M ≤ 0, ⟨M, lt_of_not_ge this, h⟩)⟩\n\nnamespace is_bounded_linear_map\n\ndef to_linear_map (f : E → F) (h : is_bounded_linear_map k f) : E →ₗ[k] F :=\n(is_linear_map.mk' _ h.to_is_linear_map)\n\nlemma zero : is_bounded_linear_map k (λ (x:E), (0:F)) :=\n(0 : E →ₗ F).is_linear.with_bound 0 $ by simp [le_refl]\n\nlemma id : is_bounded_linear_map k (λ (x:E), x) :=\nlinear_map.id.is_linear.with_bound 1 $ by simp [le_refl]\n\nset_option class.instance_max_depth 43\nlemma smul {f : E → F} (c : k) : is_bounded_linear_map k f → is_bounded_linear_map k (λ e, c • f e)\n| ⟨hf, ⟨M, hM, h⟩⟩ := (c • hf.mk' f).is_linear.with_bound (∥c∥ * M) $ assume x,\n  calc ∥c • f x∥ = ∥c∥ * ∥f x∥ : norm_smul c (f x)\n    ... ≤ ∥c∥ * (M * ∥x∥) : mul_le_mul_of_nonneg_left (h x) (norm_nonneg c)\n    ... = (∥c∥ * M) * ∥x∥ : (mul_assoc _ _ _).symm\n\nlemma neg {f : E → F} (hf : is_bounded_linear_map k f) : is_bounded_linear_map k (λ e, -f e) :=\nbegin\n  rw show (λ e, -f e) = (λ e, (-1 : k) • f e), { funext, simp },\n  exact smul (-1) hf\nend\n\nlemma add {f : E → F} {g : E → F} :\n  is_bounded_linear_map k f → is_bounded_linear_map k g → is_bounded_linear_map k (λ e, f e + g e)\n| ⟨hlf, Mf, hMf, hf⟩  ⟨hlg, Mg, hMg, hg⟩ := (hlf.mk' _ + hlg.mk' _).is_linear.with_bound (Mf + Mg) $ assume x,\n  calc ∥f x + g x∥ ≤ ∥f x∥ + ∥g x∥ : norm_triangle _ _\n    ... ≤ Mf * ∥x∥ + Mg * ∥x∥ : add_le_add (hf x) (hg x)\n    ... ≤ (Mf + Mg) * ∥x∥ : by rw add_mul\n\nlemma sub {f : E → F} {g : E → F} (hf : is_bounded_linear_map k f) (hg : is_bounded_linear_map k g) :\n  is_bounded_linear_map k (λ e, f e - g e) := add hf (neg hg)\n\nlemma comp {f : E → F} {g : F → G} :\n  is_bounded_linear_map k g → is_bounded_linear_map k f → is_bounded_linear_map k (g ∘ f)\n| ⟨hlg, Mg, hMg, hg⟩ ⟨hlf, Mf, hMf, hf⟩ := ((hlg.mk' _).comp (hlf.mk' _)).is_linear.with_bound (Mg * Mf) $ assume x,\n  calc ∥g (f x)∥ ≤ Mg * ∥f x∥ : hg _\n    ... ≤ Mg * (Mf * ∥x∥) : mul_le_mul_of_nonneg_left (hf _) (le_of_lt hMg)\n    ... = Mg * Mf * ∥x∥ : (mul_assoc _ _ _).symm\n\nlemma tendsto {L : E → F} (x : E) : is_bounded_linear_map k L → L →_{x} (L x)\n| ⟨hL, M, hM, h_ineq⟩ := tendsto_iff_norm_tendsto_zero.2 $\n  squeeze_zero (assume e, norm_nonneg _)\n    (assume e, calc ∥L e - L x∥ = ∥hL.mk' L (e - x)∥ : by rw (hL.mk' _).map_sub e x; refl\n      ... ≤ M*∥e-x∥ : h_ineq (e-x))\n    (suffices (λ (e : E), M * ∥e - x∥) →_{x} (M * 0), by simpa,\n      tendsto_mul tendsto_const_nhds (lim_norm _))\n\nlemma continuous {L : E → F} (hL : is_bounded_linear_map k L) : continuous L :=\ncontinuous_iff_continuous_at.2 $ assume x, hL.tendsto x\n\nlemma lim_zero_bounded_linear_map {L : E → F} (H : is_bounded_linear_map k L) : (L →_{0} 0) :=\n(H.1.mk' _).map_zero ▸ continuous_iff_continuous_at.1 H.continuous 0\n\nsection\nopen asymptotics filter\n\ntheorem is_O_id {L : E → F} (h : is_bounded_linear_map k L) (l : filter E) :\n  is_O L (λ x, x) l :=\nlet ⟨M, Mpos, hM⟩ := h.bound in\n⟨M, Mpos, mem_sets_of_superset univ_mem_sets (λ x _, hM x)⟩\n\ntheorem is_O_comp {L : F → G} (h : is_bounded_linear_map k L)\n  {f : E → F} (l : filter E) : is_O (λ x', L (f x')) f l :=\n((h.is_O_id ⊤).comp _).mono (map_le_iff_le_comap.mp lattice.le_top)\n\ntheorem is_O_sub {L : E → F} (h : is_bounded_linear_map k L) (l : filter E) (x : E) :\n  is_O (λ x', L (x' - x)) (λ x', x' - x) l :=\nis_O_comp h l\n\nend\n\nend is_bounded_linear_map\n\nset_option class.instance_max_depth 34\n\n-- Next lemma is stated for real normed space but it would work as soon as the base field is an extension of ℝ\nlemma bounded_continuous_linear_map\n  {E : Type*} [normed_space ℝ E] {F : Type*} [normed_space ℝ F] {L : E → F}\n  (lin : is_linear_map ℝ L) (cont : continuous L) : is_bounded_linear_map ℝ L :=\nlet ⟨δ, δ_pos, hδ⟩ := exists_delta_of_continuous cont zero_lt_one 0 in\nhave HL0 : L 0 = 0, from (lin.mk' _).map_zero,\nhave H : ∀{a}, ∥a∥ ≤ δ → ∥L a∥ < 1, by simpa only [HL0, dist_zero_right] using hδ,\nlin.with_bound (δ⁻¹) $ assume x,\nclassical.by_cases (assume : x = 0, by simp only [this, HL0, norm_zero, mul_zero]) $\nassume h : x ≠ 0,\nlet p := ∥x∥ * δ⁻¹, q := p⁻¹ in\nhave p_inv : p⁻¹ = δ*∥x∥⁻¹, by simp,\n\nhave norm_x_pos : ∥x∥ > 0 := (norm_pos_iff x).2 h,\nhave norm_x : ∥x∥ ≠ 0 := mt (norm_eq_zero x).1 h,\n\nhave p_pos : p > 0 := mul_pos norm_x_pos (inv_pos δ_pos),\nhave p0 : _ := ne_of_gt p_pos,\nhave q_pos : q > 0 := inv_pos p_pos,\nhave q0 : _ := ne_of_gt q_pos,\n\nhave ∥p⁻¹ • x∥ = δ := calc\n  ∥p⁻¹ • x∥ = abs p⁻¹ * ∥x∥ : by rw norm_smul; refl\n  ... = p⁻¹ * ∥x∥ : by rw [abs_of_nonneg $ le_of_lt q_pos]\n  ... = δ : by simp [mul_assoc, inv_mul_cancel norm_x],\n\ncalc ∥L x∥ = (p * q) * ∥L x∥ : begin dsimp [q], rw [mul_inv_cancel p0, one_mul] end\n  ... = p * ∥L (q • x)∥ : by simp [lin.smul, norm_smul, real.norm_eq_abs, abs_of_pos q_pos, mul_assoc]\n  ... ≤ p * 1 : mul_le_mul_of_nonneg_left (le_of_lt $ H $ le_of_eq $ this) (le_of_lt p_pos)\n  ... = δ⁻¹ * ∥x∥ : by rw [mul_one, mul_comm]\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/analysis/normed_space/bounded_linear_maps.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.4569595497365099}}
{"text": "import Cat.Fam.Functor\n\n\n\n/-! # Additional definitions for functors -/\n\nnamespace Cat\n\n\n\n/-! ## Functors and iso arrows/objects  -/\nsection iso_proper\n  variable\n    {ℂ₁ ℂ₂ : Fam.Cat}\n    (F : Fam.Cat.Func ℂ₁ ℂ₂)\n\n  theorem Fam.Cat.Func.proper_inv\n    {α β : ℂ₁.Obj}\n    {f₁ : α ↠ β}\n    {f₂ : β ↠ α}\n    (h : f₁ ⊚ f₂ ≈ ℂ₁.id)\n  : (F.fMap f₁) ⊚ (F.fMap f₂) ≈ F.id :=\n    let f₁' :=\n      F.fMap f₁\n    let f₂' :=\n      F.fMap f₂\n    let h₁ : f₁' ⊚ f₂' ≈ F.fMap (f₁ ⊚ f₂) :=\n      F.comp_law f₁ f₂\n      |> Setoid.symm\n    let h₂ : f₁' ⊚ f₂' ≈ F.fMap ℂ₁.id :=\n      F.fmap_proper h\n      |> Setoid.trans h₁\n    let h₃ : f₁' ⊚ f₂' ≈ ℂ₂.id :=\n      F.id_law' β\n      |> Setoid.trans h₂\n    h₃\n\n  /-- Functors preserve the *iso* property over arrows. -/\n  instance instIsoFuncIso\n    {F : Fam.Cat.Func ℂ₁ ℂ₂}\n    {α β : ℂ₁.Obj}\n    (f : α ↠ β)\n    [instIso : Fam.Cat.Iso f]\n  : Fam.Cat.Iso (F.fmap f) :=\n    let fInv' :=\n      F.fmap instIso.inv\n    Fam.Cat.Iso.mk\n      fInv'\n      (F.proper_inv instIso.law_left)\n      (F.proper_inv instIso.law_right)\n  \n\n  /-- Functors preserve the *iso* property over objects. -/\n  instance instIsoObjFuncIsoObj\n    {α β : ℂ₁.Obj}\n    (h_iso : α ≅ β)\n  : F α ≅ F β where\n    iso :=\n      F.fmap h_iso.iso\n    instIso :=\n      instIsoFuncIso h_iso.iso\n\nend iso_proper\n\n\n\n/-! ## Faithful / full functors -/\nsection\n  variable\n    {ℂ₁ ℂ₂ : Fam.Cat}\n    (F : Fam.Cat.Func ℂ₁ ℂ₂)\n\n  /-- Proof that a functor is *faithful*, *i.e.* `F f ≈ F g → f ≈ g`. -/\n  class Fam.Cat.Func.Faithful\n    {ℂ₁ ℂ₂ : Cat}\n    (F : Func ℂ₁ ℂ₂)\n  where\n    /-- Faithfulness law. -/\n    law' :\n      ∀ {α β : ℂ₁.Obj} (f g : α ↠ β),\n        F.fmap f ≈ F.fmap g → f ≈ g\n\n  /-- Same as `Faithful.law'` but `f` and `g` are implicit. -/\n  @[simp]\n  abbrev Fam.Cat.Func.Faithful.law\n    [inst : Faithful F]\n    {α β : ℂ₁.Obj}\n    {f g : α ↠ β}\n  : F.fmap f ≈ F.fmap g → f ≈ g :=\n    inst.law' f g\n\n  /-- Faithfulness is closed under functor composition. -/\n  instance instFaithfulFuncComp\n    (F₂₃ : Fam.Cat.Func ℂ₂ ℂ₃)\n    [inst₂₃ : Fam.Cat.Func.Faithful F₂₃]\n    (F₁₂ : Fam.Cat.Func ℂ₁ ℂ₂)\n    [inst₁₂ : Fam.Cat.Func.Faithful F₁₂]\n  : Fam.Cat.Func.Faithful (F₂₃ ⊙ F₁₂) where\n    law' {α β} (f g) h :=\n      by\n        apply inst₁₂.law\n        apply inst₂₃.law\n        exact h\n\n\n\n  /-- Proof that a functor is *full*, *i.e.* any `h : F α ↠ F β` has a preimage by `F.fmap`. -/\n  class Fam.Cat.Func.Full\n    {ℂ₁ ℂ₂ : Cat}\n    (F : Func ℂ₁ ℂ₂)\n  where\n    /-- Yields the preimage of `h` by `F.fmap`. -/\n    preimage\n      {α β : ℂ₁.Obj}\n      (h : F α ↠ F β)\n    : α ↠ β\n    /-- Proof that `h` and the image of its preimage are equivalent. -/\n    law'\n      {α β : ℂ₁.Obj}\n      (h : F α ↠ F β)\n    : h ≈ F.fmap (preimage h)\n\n  /-- Same as `Full.law'` but `h` is implicit. -/\n  @[simp]\n  abbrev Fam.Cat.Func.Full.law\n    [inst : Full F]\n    {α β : ℂ₁.Obj}\n    {h : F α ↠ F β}\n  : h ≈ F.fmap (inst.preimage h) :=\n    inst.law' h\n\n  /-- Fullness is closed under functor composition. -/\n  instance instFullFuncComp\n    (F₂₃ : Fam.Cat.Func ℂ₂ ℂ₃)\n    [inst₂₃ : Fam.Cat.Func.Full F₂₃]\n    (F₁₂ : Fam.Cat.Func ℂ₁ ℂ₂)\n    [inst₁₂ : Fam.Cat.Func.Full F₁₂]\n  : Fam.Cat.Func.Full (F₂₃ ⊙ F₁₂) where\n    preimage h :=\n      inst₂₃.preimage h\n      |> inst₁₂.preimage\n    law' g₃ :=\n      let g₂ :=\n        inst₂₃.preimage g₃\n      let g₁ :=\n        inst₁₂.preimage g₂\n      let h : g₃ ≈ F₂₃.fmap g₂ :=\n        inst₂₃.law\n      let h' : g₂ ≈ F₁₂.fmap g₁ :=\n        inst₁₂.law\n      let h : g₃ ≈ F₂₃.fmap (F₁₂.fmap g₁) :=\n        F₂₃.fmap_proper h'\n        |> Setoid.trans h\n      h\n\nend\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/cat/Cat/Fam/FunctorDefs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.45695954459498894}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.preadditive.basic\nimport algebra.module.linear_map\nimport algebra.invertible\nimport algebra.algebra.basic\n\n/-!\n# Linear categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nAn `R`-linear category is a category in which `X ⟶ Y` is an `R`-module in such a way that\ncomposition of morphisms is `R`-linear in both variables.\n\nNote that sometimes in the literature a \"linear category\" is further required to be abelian.\n\n## Implementation\n\nCorresponding to the fact that we need to have an `add_comm_group X` structure in place\nto talk about a `module R X` structure,\nwe need `preadditive C` as a prerequisite typeclass for `linear R C`.\nThis makes for longer signatures than would be ideal.\n\n## Future work\n\nIt would be nice to have a usable framework of enriched categories in which this just became\na category enriched in `Module R`.\n\n-/\n\nuniverses w v u\n\nopen category_theory.limits\nopen linear_map\n\nnamespace category_theory\n\n/-- A category is called `R`-linear if `P ⟶ Q` is an `R`-module such that composition is\n    `R`-linear in both variables. -/\nclass linear (R : Type w) [semiring R] (C : Type u) [category.{v} C] [preadditive C] :=\n(hom_module : Π X Y : C, module R (X ⟶ Y) . tactic.apply_instance)\n(smul_comp' : ∀ (X Y Z : C) (r : R) (f : X ⟶ Y) (g : Y ⟶ Z),\n  (r • f) ≫ g = r • (f ≫ g) . obviously)\n(comp_smul' : ∀ (X Y Z : C) (f : X ⟶ Y) (r : R) (g : Y ⟶ Z),\n  f ≫ (r • g) = r • (f ≫ g) . obviously)\n\nattribute [instance] linear.hom_module\nrestate_axiom linear.smul_comp'\nrestate_axiom linear.comp_smul'\nattribute [simp,reassoc] linear.smul_comp\nattribute [reassoc, simp] linear.comp_smul -- (the linter doesn't like `simp` on the `_assoc` lemma)\n\nend category_theory\n\nopen category_theory\n\nnamespace category_theory.linear\n\nvariables {C : Type u} [category.{v} C] [preadditive C]\n\ninstance preadditive_nat_linear : linear ℕ C :=\n{ smul_comp' := λ X Y Z r f g, (preadditive.right_comp X g).map_nsmul f r,\n  comp_smul' := λ X Y Z f r g, (preadditive.left_comp Z f).map_nsmul g r, }\n\ninstance preadditive_int_linear : linear ℤ C :=\n{ smul_comp' := λ X Y Z r f g, (preadditive.right_comp X g).map_zsmul f r,\n  comp_smul' := λ X Y Z f r g, (preadditive.left_comp Z f).map_zsmul g r, }\n\nsection End\n\nvariables {R : Type w}\n\ninstance [semiring R] [linear R C] (X : C) : module R (End X) :=\nby { dsimp [End], apply_instance, }\n\ninstance [comm_semiring R] [linear R C] (X : C) : algebra R (End X) :=\nalgebra.of_module (λ r f g, comp_smul _ _ _ _ _ _) (λ r f g, smul_comp _ _ _ _ _ _)\n\nend End\n\nsection\nvariables {R : Type w} [semiring R] [linear R C]\n\nsection induced_category\nuniverses u'\nvariables {C} {D : Type u'} (F : D → C)\n\ninstance induced_category : linear.{w v} R (induced_category C F) :=\n{ hom_module := λ X Y, @linear.hom_module R _ C _ _ _ (F X) (F Y),\n  smul_comp' := λ P Q R f f' g, smul_comp' _ _ _ _ _ _,\n  comp_smul' := λ P Q R f g g', comp_smul' _ _ _ _ _ _, }\n\nend induced_category\n\ninstance full_subcategory (Z : C → Prop) : linear.{w v} R (full_subcategory Z) :=\n{ hom_module := λ X Y, @linear.hom_module R _ C _ _ _ X.obj Y.obj,\n  smul_comp' := λ P Q R f f' g, smul_comp' _ _ _ _ _ _,\n  comp_smul' := λ P Q R f g g', comp_smul' _ _ _ _ _ _, }\n\nvariables (R)\n\n/-- Composition by a fixed left argument as an `R`-linear map. -/\n@[simps]\ndef left_comp {X Y : C} (Z : C) (f : X ⟶ Y) : (Y ⟶ Z) →ₗ[R] (X ⟶ Z) :=\n{ to_fun := λ g, f ≫ g,\n  map_add' := by simp,\n  map_smul' := by simp, }\n\n/-- Composition by a fixed right argument as an `R`-linear map. -/\n@[simps]\ndef right_comp (X : C) {Y Z : C} (g : Y ⟶ Z) : (X ⟶ Y) →ₗ[R] (X ⟶ Z) :=\n{ to_fun := λ f, f ≫ g,\n  map_add' := by simp,\n  map_smul' := by simp, }\n\ninstance {X Y : C} (f : X ⟶ Y) [epi f] (r : R) [invertible r] : epi (r • f) :=\n⟨λ R g g' H, begin\n  rw [smul_comp, smul_comp, ←comp_smul, ←comp_smul, cancel_epi] at H,\n  simpa [smul_smul] using congr_arg (λ f, ⅟r • f) H,\nend⟩\n\ninstance {X Y : C} (f : X ⟶ Y) [mono f] (r : R) [invertible r] : mono (r • f) :=\n⟨λ R g g' H, begin\n  rw [comp_smul, comp_smul, ←smul_comp, ←smul_comp, cancel_mono] at H,\n  simpa [smul_smul] using congr_arg (λ f, ⅟r • f) H,\nend⟩\n\n/-- Given isomorphic objects `X ≅ Y, W ≅ Z` in a `k`-linear category, we have a `k`-linear\nisomorphism between `Hom(X, W)` and `Hom(Y, Z).` -/\ndef hom_congr (k : Type*) {C : Type*} [category C] [semiring k]\n  [preadditive C] [linear k C] {X Y W Z : C} (f₁ : X ≅ Y) (f₂ : W ≅ Z) :\n  (X ⟶ W) ≃ₗ[k] (Y ⟶ Z) :=\n{ inv_fun := (left_comp k W f₁.hom).comp (right_comp k Y f₂.symm.hom),\n  left_inv := λ x, by simp only [iso.symm_hom, linear_map.to_fun_eq_coe, linear_map.coe_comp,\n    function.comp_app, left_comp_apply, right_comp_apply, category.assoc, iso.hom_inv_id,\n    category.comp_id, iso.hom_inv_id_assoc],\n  right_inv := λ x, by simp only [iso.symm_hom, linear_map.coe_comp, function.comp_app,\n    right_comp_apply, left_comp_apply, linear_map.to_fun_eq_coe, iso.inv_hom_id_assoc,\n    category.assoc, iso.inv_hom_id, category.comp_id],\n  ..(right_comp k Y f₂.hom).comp (left_comp k W f₁.symm.hom) }\n\nlemma hom_congr_apply (k : Type*) {C : Type*} [category C] [semiring k]\n  [preadditive C] [linear k C] {X Y W Z : C} (f₁ : X ≅ Y) (f₂ : W ≅ Z) (f : X ⟶ W) :\n  hom_congr k f₁ f₂ f = (f₁.inv ≫ f) ≫ f₂.hom := rfl\n\nlemma hom_congr_symm_apply (k : Type*) {C : Type*} [category C] [semiring k]\n  [preadditive C] [linear k C] {X Y W Z : C} (f₁ : X ≅ Y) (f₂ : W ≅ Z) (f : Y ⟶ Z) :\n  (hom_congr k f₁ f₂).symm f = f₁.hom ≫ f ≫ f₂.inv := rfl\n\nend\n\nsection\nvariables {S : Type w} [comm_semiring S] [linear S C]\n\n/-- Composition as a bilinear map. -/\n@[simps]\ndef comp (X Y Z : C) : (X ⟶ Y) →ₗ[S] ((Y ⟶ Z) →ₗ[S] (X ⟶ Z)) :=\n{ to_fun := λ f, left_comp S Z f,\n  map_add' := by { intros, ext, simp, },\n  map_smul' := by { intros, ext, simp, }, }\n\nend\n\nend category_theory.linear\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/linear/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.4569595373532259}}
{"text": "variables p q : Prop\nvariables (hp : p) (hq : q)\n\nexample : p ∧ q := (|hp, hq|)\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch3/ex0306.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.709019146082187, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4567679348856718}}
{"text": "/-\nCopyright (c) 2021 Yakov Pechersky. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yakov Pechersky, Chris Hughes\n\n! This file was ported from Lean 3 source module data.list.duplicate\n! leanprover-community/mathlib commit f694c7dead66f5d4c80f446c796a5aad14707f0e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.List.Nodup\n\n/-!\n# List duplicates\n\n## Main definitions\n\n* `List.Duplicate x l : Prop` is an inductive property that holds when `x` is a duplicate in `l`\n\n## Implementation details\n\nIn this file, `x ∈+ l` notation is shorthand for `List.Duplicate x l`.\n\n-/\n\n\nvariable {α : Type _}\n\nnamespace List\n\n/-- Property that an element `x : α` of `l : list α` can be found in the list more than once. -/\ninductive Duplicate (x : α) : List α → Prop\n  | cons_mem {l : List α} : x ∈ l → Duplicate x (x :: l)\n  | cons_duplicate {y : α} {l : List α} : Duplicate x l → Duplicate x (y :: l)\n#align list.duplicate List.Duplicate\n\n-- mathport name: «expr ∈+ »\nlocal infixl:50 \" ∈+ \" => List.Duplicate\n\nvariable {l : List α} {x : α}\n\ntheorem Mem.duplicate_cons_self (h : x ∈ l) : x ∈+ x :: l :=\n  Duplicate.cons_mem h\n#align list.mem.duplicate_cons_self List.Mem.duplicate_cons_self\n\ntheorem Duplicate.duplicate_cons (h : x ∈+ l) (y : α) : x ∈+ y :: l :=\n  Duplicate.cons_duplicate h\n#align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons\n\ntheorem Duplicate.mem (h : x ∈+ l) : x ∈ l := by\n  induction' h with l' _ y l' _ hm\n  · exact mem_cons_self _ _\n  · exact mem_cons_of_mem _ hm\n#align list.duplicate.mem List.Duplicate.mem\n\ntheorem Duplicate.mem_cons_self (h : x ∈+ x :: l) : x ∈ l := by\n  cases' h with _ h _ _ h\n  · exact h\n  · exact h.mem\n#align list.duplicate.mem_cons_self List.Duplicate.mem_cons_self\n\n@[simp]\ntheorem duplicate_cons_self_iff : x ∈+ x :: l ↔ x ∈ l :=\n  ⟨Duplicate.mem_cons_self, Mem.duplicate_cons_self⟩\n#align list.duplicate_cons_self_iff List.duplicate_cons_self_iff\n\ntheorem Duplicate.ne_nil (h : x ∈+ l) : l ≠ [] := fun H => (mem_nil_iff x).mp (H ▸ h.mem)\n#align list.duplicate.ne_nil List.Duplicate.ne_nil\n\n@[simp]\ntheorem not_duplicate_nil (x : α) : ¬x ∈+ [] := fun H => H.ne_nil rfl\n#align list.not_duplicate_nil List.not_duplicate_nil\n\ntheorem Duplicate.ne_singleton (h : x ∈+ l) (y : α) : l ≠ [y] := by\n  induction' h with l' h z l' h _\n  · simp [ne_nil_of_mem h]\n  · simp [ne_nil_of_mem h.mem]\n#align list.duplicate.ne_singleton List.Duplicate.ne_singleton\n\n@[simp]\n\n\ntheorem Duplicate.elim_nil (h : x ∈+ []) : False :=\n  not_duplicate_nil x h\n#align list.duplicate.elim_nil List.Duplicate.elim_nil\n\ntheorem Duplicate.elim_singleton {y : α} (h : x ∈+ [y]) : False :=\n  not_duplicate_singleton x y h\n#align list.duplicate.elim_singleton List.Duplicate.elim_singleton\n\ntheorem duplicate_cons_iff {y : α} : x ∈+ y :: l ↔ y = x ∧ x ∈ l ∨ x ∈+ l := by\n  refine' ⟨fun h => _, fun h => _⟩\n  · cases' h with _ hm _ _ hm\n    · exact Or.inl ⟨rfl, hm⟩\n    · exact Or.inr hm\n  · rcases h with (⟨rfl | h⟩ | h)\n    · simpa\n    · exact h.cons_duplicate\n#align list.duplicate_cons_iff List.duplicate_cons_iff\n\ntheorem Duplicate.of_duplicate_cons {y : α} (h : x ∈+ y :: l) (hx : x ≠ y) : x ∈+ l := by\n  simpa [duplicate_cons_iff, hx.symm] using h\n#align list.duplicate.of_duplicate_cons List.Duplicate.of_duplicate_cons\n\ntheorem duplicate_cons_iff_of_ne {y : α} (hne : x ≠ y) : x ∈+ y :: l ↔ x ∈+ l := by\n  simp [duplicate_cons_iff, hne.symm]\n#align list.duplicate_cons_iff_of_ne List.duplicate_cons_iff_of_ne\n\ntheorem Duplicate.mono_sublist {l' : List α} (hx : x ∈+ l) (h : l <+ l') : x ∈+ l' := by\n  induction' h with l₁ l₂ y _ IH l₁ l₂ y h IH\n  · exact hx\n  · exact (IH hx).duplicate_cons _\n  · rw [duplicate_cons_iff] at hx⊢\n    rcases hx with (⟨rfl, hx⟩ | hx)\n    · simp [h.subset hx]\n    · simp [IH hx]\n#align list.duplicate.mono_sublist List.Duplicate.mono_sublist\n\n/-- The contrapositive of `List.nodup_iff_sublist`. -/\ntheorem duplicate_iff_sublist : x ∈+ l ↔ [x, x] <+ l := by\n  induction' l with y l IH\n  · simp\n  · by_cases hx : x = y\n    · simp [hx, cons_sublist_cons_iff, singleton_sublist]\n    · rw [duplicate_cons_iff_of_ne hx, IH]\n      refine' ⟨sublist_cons_of_sublist y, fun h => _⟩\n      cases h\n      · assumption\n      · contradiction\n#align list.duplicate_iff_sublist List.duplicate_iff_sublist\n\ntheorem nodup_iff_forall_not_duplicate : Nodup l ↔ ∀ x : α, ¬x ∈+ l := by\n  simp_rw [nodup_iff_sublist, duplicate_iff_sublist]\n#align list.nodup_iff_forall_not_duplicate List.nodup_iff_forall_not_duplicate\n\ntheorem exists_duplicate_iff_not_nodup : (∃ x : α, x ∈+ l) ↔ ¬Nodup l := by\n  simp [nodup_iff_forall_not_duplicate]\n#align list.exists_duplicate_iff_not_nodup List.exists_duplicate_iff_not_nodup\n\ntheorem Duplicate.not_nodup (h : x ∈+ l) : ¬Nodup l := fun H =>\n  nodup_iff_forall_not_duplicate.mp H _ h\n#align list.duplicate.not_nodup List.Duplicate.not_nodup\n\ntheorem duplicate_iff_two_le_count [DecidableEq α] : x ∈+ l ↔ 2 ≤ count x l := by\n  simp [duplicate_iff_sublist, le_count_iff_replicate_sublist]\n#align list.duplicate_iff_two_le_count List.duplicate_iff_two_le_count\n\ninstance decidableDuplicate [DecidableEq α] (x : α) : ∀ l : List α, Decidable (x ∈+ l)\n  | [] => isFalse (not_duplicate_nil x)\n  | y :: l =>\n    match decidableDuplicate x l with\n    | isTrue h => isTrue (h.duplicate_cons y)\n    | isFalse h =>\n      if hx : y = x ∧ x ∈ l then isTrue (hx.left.symm ▸ List.Mem.duplicate_cons_self hx.right)\n      else isFalse (by simpa [duplicate_cons_iff, h] using hx)\n#align list.decidable_duplicate List.decidableDuplicate\n\nend List\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/List/Duplicate.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.4567679309246236}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser, Kevin Buzzard, Jujian Zhang\n\n! This file was ported from Lean 3 source module ring_theory.graded_algebra.basic\n! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.DirectSum.Algebra\nimport Mathbin.Algebra.DirectSum.Decomposition\nimport Mathbin.Algebra.DirectSum.Internal\nimport Mathbin.Algebra.DirectSum.Ring\n\n/-!\n# Internally-graded rings and algebras\n\nThis file defines the typeclass `graded_algebra 𝒜`, for working with an algebra `A` that is\ninternally graded by a collection of submodules `𝒜 : ι → submodule R A`.\nSee the docstring of that typeclass for more information.\n\n## Main definitions\n\n* `graded_ring 𝒜`: the typeclass, which is a combination of `set_like.graded_monoid`, and\n  `direct_sum.decomposition 𝒜`.\n* `graded_algebra 𝒜`: A convenience alias for `graded_ring` when `𝒜` is a family of submodules.\n* `direct_sum.decompose_ring_equiv 𝒜 : A ≃ₐ[R] ⨁ i, 𝒜 i`, a more bundled version of\n  `direct_sum.decompose 𝒜`.\n* `direct_sum.decompose_alg_equiv 𝒜 : A ≃ₐ[R] ⨁ i, 𝒜 i`, a more bundled version of\n  `direct_sum.decompose 𝒜`.\n* `graded_algebra.proj 𝒜 i` is the linear map from `A` to its degree `i : ι` component, such that\n  `proj 𝒜 i x = decompose 𝒜 x i`.\n\n## Implementation notes\n\nFor now, we do not have internally-graded semirings and internally-graded rings; these can be\nrepresented with `𝒜 : ι → submodule ℕ A` and `𝒜 : ι → submodule ℤ A` respectively, since all\n`semiring`s are ℕ-algebras via `algebra_nat`, and all `ring`s are `ℤ`-algebras via `algebra_int`.\n\n## Tags\n\ngraded algebra, graded ring, graded semiring, decomposition\n-/\n\n\nopen DirectSum BigOperators\n\nvariable {ι R A σ : Type _}\n\nsection GradedRing\n\nvariable [DecidableEq ι] [AddMonoid ι] [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SetLike σ A] [AddSubmonoidClass σ A] (𝒜 : ι → σ)\n\ninclude A\n\nopen DirectSum\n\n/-- An internally-graded `R`-algebra `A` is one that can be decomposed into a collection\nof `submodule R A`s indexed by `ι` such that the canonical map `A → ⨁ i, 𝒜 i` is bijective and\nrespects multiplication, i.e. the product of an element of degree `i` and an element of degree `j`\nis an element of degree `i + j`.\n\nNote that the fact that `A` is internally-graded, `graded_algebra 𝒜`, implies an externally-graded\nalgebra structure `direct_sum.galgebra R (λ i, ↥(𝒜 i))`, which in turn makes available an\n`algebra R (⨁ i, 𝒜 i)` instance.\n-/\nclass GradedRing (𝒜 : ι → σ) extends SetLike.GradedMonoid 𝒜, DirectSum.Decomposition 𝒜\n#align graded_ring GradedRing\n\nvariable [GradedRing 𝒜]\n\nnamespace DirectSum\n\n/-- If `A` is graded by `ι` with degree `i` component `𝒜 i`, then it is isomorphic as\na ring to a direct sum of components. -/\ndef decomposeRingEquiv : A ≃+* ⨁ i, 𝒜 i :=\n  RingEquiv.symm\n    {\n      (decomposeAddEquiv 𝒜).symm with\n      map_mul' := (coeRingHom 𝒜).map_mul\n      map_add' := (coeRingHom 𝒜).map_add }\n#align direct_sum.decompose_ring_equiv DirectSum.decomposeRingEquiv\n\n@[simp]\ntheorem decompose_one : decompose 𝒜 (1 : A) = 1 :=\n  map_one (decomposeRingEquiv 𝒜)\n#align direct_sum.decompose_one DirectSum.decompose_one\n\n@[simp]\ntheorem decompose_symm_one : (decompose 𝒜).symm 1 = (1 : A) :=\n  map_one (decomposeRingEquiv 𝒜).symm\n#align direct_sum.decompose_symm_one DirectSum.decompose_symm_one\n\n@[simp]\ntheorem decompose_mul (x y : A) : decompose 𝒜 (x * y) = decompose 𝒜 x * decompose 𝒜 y :=\n  map_mul (decomposeRingEquiv 𝒜) x y\n#align direct_sum.decompose_mul DirectSum.decompose_mul\n\n@[simp]\ntheorem decompose_symm_mul (x y : ⨁ i, 𝒜 i) :\n    (decompose 𝒜).symm (x * y) = (decompose 𝒜).symm x * (decompose 𝒜).symm y :=\n  map_mul (decomposeRingEquiv 𝒜).symm x y\n#align direct_sum.decompose_symm_mul DirectSum.decompose_symm_mul\n\nend DirectSum\n\n/-- The projection maps of a graded ring -/\ndef GradedRing.proj (i : ι) : A →+ A :=\n  (AddSubmonoidClass.Subtype (𝒜 i)).comp <|\n    (Dfinsupp.evalAddMonoidHom i).comp <|\n      RingHom.toAddMonoidHom <| RingEquiv.toRingHom <| DirectSum.decomposeRingEquiv 𝒜\n#align graded_ring.proj GradedRing.proj\n\n@[simp]\ntheorem GradedRing.proj_apply (i : ι) (r : A) :\n    GradedRing.proj 𝒜 i r = (decompose 𝒜 r : ⨁ i, 𝒜 i) i :=\n  rfl\n#align graded_ring.proj_apply GradedRing.proj_apply\n\ntheorem GradedRing.proj_recompose (a : ⨁ i, 𝒜 i) (i : ι) :\n    GradedRing.proj 𝒜 i ((decompose 𝒜).symm a) = (decompose 𝒜).symm (DirectSum.of _ i (a i)) := by\n  rw [GradedRing.proj_apply, decompose_symm_of, Equiv.apply_symm_apply]\n#align graded_ring.proj_recompose GradedRing.proj_recompose\n\ntheorem GradedRing.mem_support_iff [∀ (i) (x : 𝒜 i), Decidable (x ≠ 0)] (r : A) (i : ι) :\n    i ∈ (decompose 𝒜 r).support ↔ GradedRing.proj 𝒜 i r ≠ 0 :=\n  Dfinsupp.mem_support_iff.trans ZeroMemClass.coe_eq_zero.Not.symm\n#align graded_ring.mem_support_iff GradedRing.mem_support_iff\n\nend GradedRing\n\nsection AddCancelMonoid\n\nopen DirectSum\n\nvariable [DecidableEq ι] [Semiring A] [SetLike σ A] [AddSubmonoidClass σ A] (𝒜 : ι → σ)\n\nvariable {i j : ι}\n\nnamespace DirectSum\n\ntheorem coe_decompose_mul_add_of_left_mem [AddLeftCancelMonoid ι] [GradedRing 𝒜] {a b : A}\n    (a_mem : a ∈ 𝒜 i) : (decompose 𝒜 (a * b) (i + j) : A) = a * decompose 𝒜 b j :=\n  by\n  lift a to 𝒜 i using a_mem\n  rw [decompose_mul, decompose_coe, coe_of_mul_apply_add]\n#align direct_sum.coe_decompose_mul_add_of_left_mem DirectSum.coe_decompose_mul_add_of_left_mem\n\ntheorem coe_decompose_mul_add_of_right_mem [AddRightCancelMonoid ι] [GradedRing 𝒜] {a b : A}\n    (b_mem : b ∈ 𝒜 j) : (decompose 𝒜 (a * b) (i + j) : A) = decompose 𝒜 a i * b :=\n  by\n  lift b to 𝒜 j using b_mem\n  rw [decompose_mul, decompose_coe, coe_mul_of_apply_add]\n#align direct_sum.coe_decompose_mul_add_of_right_mem DirectSum.coe_decompose_mul_add_of_right_mem\n\ntheorem decompose_mul_add_left [AddLeftCancelMonoid ι] [GradedRing 𝒜] (a : 𝒜 i) {b : A} :\n    decompose 𝒜 (↑a * b) (i + j) =\n      @GradedMonoid.GMul.mul ι (fun i => 𝒜 i) _ _ _ _ a (decompose 𝒜 b j) :=\n  Subtype.ext <| coe_decompose_mul_add_of_left_mem 𝒜 a.2\n#align direct_sum.decompose_mul_add_left DirectSum.decompose_mul_add_left\n\ntheorem decompose_mul_add_right [AddRightCancelMonoid ι] [GradedRing 𝒜] {a : A} (b : 𝒜 j) :\n    decompose 𝒜 (a * ↑b) (i + j) =\n      @GradedMonoid.GMul.mul ι (fun i => 𝒜 i) _ _ _ _ (decompose 𝒜 a i) b :=\n  Subtype.ext <| coe_decompose_mul_add_of_right_mem 𝒜 b.2\n#align direct_sum.decompose_mul_add_right DirectSum.decompose_mul_add_right\n\nend DirectSum\n\nend AddCancelMonoid\n\nsection GradedAlgebra\n\nvariable [DecidableEq ι] [AddMonoid ι] [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable (𝒜 : ι → Submodule R A)\n\n/-- A special case of `graded_ring` with `σ = submodule R A`. This is useful both because it\ncan avoid typeclass search, and because it provides a more concise name. -/\n@[reducible]\ndef GradedAlgebra :=\n  GradedRing 𝒜\n#align graded_algebra GradedAlgebra\n\n/-- A helper to construct a `graded_algebra` when the `set_like.graded_monoid` structure is already\navailable. This makes the `left_inv` condition easier to prove, and phrases the `right_inv`\ncondition in a way that allows custom `@[ext]` lemmas to apply.\n\nSee note [reducible non-instances]. -/\n@[reducible]\ndef GradedAlgebra.ofAlgHom [SetLike.GradedMonoid 𝒜] (decompose : A →ₐ[R] ⨁ i, 𝒜 i)\n    (right_inv : (DirectSum.coeAlgHom 𝒜).comp decompose = AlgHom.id R A)\n    (left_inv : ∀ (i) (x : 𝒜 i), decompose (x : A) = DirectSum.of (fun i => ↥(𝒜 i)) i x) :\n    GradedAlgebra 𝒜 where\n  decompose' := decompose\n  left_inv := AlgHom.congr_fun right_inv\n  right_inv := by\n    suffices : decompose.comp (DirectSum.coeAlgHom 𝒜) = AlgHom.id _ _\n    exact AlgHom.congr_fun this\n    ext (i x) : 2\n    exact (decompose.congr_arg <| DirectSum.coeAlgHom_of _ _ _).trans (left_inv i x)\n#align graded_algebra.of_alg_hom GradedAlgebra.ofAlgHom\n\nvariable [GradedAlgebra 𝒜]\n\nnamespace DirectSum\n\n/-- If `A` is graded by `ι` with degree `i` component `𝒜 i`, then it is isomorphic as\nan algebra to a direct sum of components. -/\n@[simps]\ndef decomposeAlgEquiv : A ≃ₐ[R] ⨁ i, 𝒜 i :=\n  AlgEquiv.symm\n    { (decomposeAddEquiv 𝒜).symm with\n      map_mul' := (coeAlgHom 𝒜).map_mul\n      map_add' := (coeAlgHom 𝒜).map_add\n      commutes' := (coeAlgHom 𝒜).commutes }\n#align direct_sum.decompose_alg_equiv DirectSum.decomposeAlgEquiv\n\nend DirectSum\n\nopen DirectSum\n\n/-- The projection maps of graded algebra-/\ndef GradedAlgebra.proj (𝒜 : ι → Submodule R A) [GradedAlgebra 𝒜] (i : ι) : A →ₗ[R] A :=\n  (𝒜 i).Subtype.comp <| (Dfinsupp.lapply i).comp <| (decomposeAlgEquiv 𝒜).toAlgHom.toLinearMap\n#align graded_algebra.proj GradedAlgebra.proj\n\n@[simp]\ntheorem GradedAlgebra.proj_apply (i : ι) (r : A) :\n    GradedAlgebra.proj 𝒜 i r = (decompose 𝒜 r : ⨁ i, 𝒜 i) i :=\n  rfl\n#align graded_algebra.proj_apply GradedAlgebra.proj_apply\n\ntheorem GradedAlgebra.proj_recompose (a : ⨁ i, 𝒜 i) (i : ι) :\n    GradedAlgebra.proj 𝒜 i ((decompose 𝒜).symm a) = (decompose 𝒜).symm (of _ i (a i)) := by\n  rw [GradedAlgebra.proj_apply, decompose_symm_of, Equiv.apply_symm_apply]\n#align graded_algebra.proj_recompose GradedAlgebra.proj_recompose\n\ntheorem GradedAlgebra.mem_support_iff [DecidableEq A] (r : A) (i : ι) :\n    i ∈ (decompose 𝒜 r).support ↔ GradedAlgebra.proj 𝒜 i r ≠ 0 :=\n  Dfinsupp.mem_support_iff.trans Submodule.coe_eq_zero.Not.symm\n#align graded_algebra.mem_support_iff GradedAlgebra.mem_support_iff\n\nend GradedAlgebra\n\nsection CanonicalOrder\n\nopen SetLike.GradedMonoid DirectSum\n\nvariable [Semiring A] [DecidableEq ι]\n\nvariable [CanonicallyOrderedAddMonoid ι]\n\nvariable [SetLike σ A] [AddSubmonoidClass σ A] (𝒜 : ι → σ) [GradedRing 𝒜]\n\n/-- If `A` is graded by a canonically ordered add monoid, then the projection map `x ↦ x₀` is a ring\nhomomorphism.\n-/\n@[simps]\ndef GradedRing.projZeroRingHom : A →+* A\n    where\n  toFun a := decompose 𝒜 a 0\n  map_one' := decompose_of_mem_same 𝒜 one_mem\n  map_zero' := by\n    rw [decompose_zero]\n    rfl\n  map_add' _ _ := by\n    rw [decompose_add]\n    rfl\n  map_mul' := by\n    refine' DirectSum.Decomposition.inductionOn 𝒜 (fun x => _) _ _\n    · simp only [MulZeroClass.zero_mul, decompose_zero, zero_apply, ZeroMemClass.coe_zero]\n    · rintro i ⟨c, hc⟩\n      refine' DirectSum.Decomposition.inductionOn 𝒜 _ _ _\n      · simp only [MulZeroClass.mul_zero, decompose_zero, zero_apply, ZeroMemClass.coe_zero]\n      · rintro j ⟨c', hc'⟩\n        · simp only [Subtype.coe_mk]\n          by_cases h : i + j = 0\n          ·\n            rw [decompose_of_mem_same 𝒜 (show c * c' ∈ 𝒜 0 from h ▸ mul_mem hc hc'),\n              decompose_of_mem_same 𝒜 (show c ∈ 𝒜 0 from (add_eq_zero_iff.mp h).1 ▸ hc),\n              decompose_of_mem_same 𝒜 (show c' ∈ 𝒜 0 from (add_eq_zero_iff.mp h).2 ▸ hc')]\n          · rw [decompose_of_mem_ne 𝒜 (mul_mem hc hc') h]\n            cases' show i ≠ 0 ∨ j ≠ 0 by rwa [add_eq_zero_iff, not_and_or] at h with h' h'\n            · simp only [decompose_of_mem_ne 𝒜 hc h', MulZeroClass.zero_mul]\n            · simp only [decompose_of_mem_ne 𝒜 hc' h', MulZeroClass.mul_zero]\n      · intro _ _ hd he\n        simp only [mul_add, decompose_add, add_apply, AddMemClass.coe_add, hd, he]\n    · rintro _ _ ha hb _\n      simp only [add_mul, decompose_add, add_apply, AddMemClass.coe_add, ha, hb]\n#align graded_ring.proj_zero_ring_hom GradedRing.projZeroRingHom\n\nvariable {a b : A} {n i : ι}\n\nnamespace DirectSum\n\ntheorem coe_decompose_mul_of_left_mem_of_not_le (a_mem : a ∈ 𝒜 i) (h : ¬i ≤ n) :\n    (decompose 𝒜 (a * b) n : A) = 0 :=\n  by\n  lift a to 𝒜 i using a_mem\n  rwa [decompose_mul, decompose_coe, coe_of_mul_apply_of_not_le]\n#align direct_sum.coe_decompose_mul_of_left_mem_of_not_le DirectSum.coe_decompose_mul_of_left_mem_of_not_le\n\ntheorem coe_decompose_mul_of_right_mem_of_not_le (b_mem : b ∈ 𝒜 i) (h : ¬i ≤ n) :\n    (decompose 𝒜 (a * b) n : A) = 0 :=\n  by\n  lift b to 𝒜 i using b_mem\n  rwa [decompose_mul, decompose_coe, coe_mul_of_apply_of_not_le]\n#align direct_sum.coe_decompose_mul_of_right_mem_of_not_le DirectSum.coe_decompose_mul_of_right_mem_of_not_le\n\nvariable [Sub ι] [OrderedSub ι] [ContravariantClass ι ι (· + ·) (· ≤ ·)]\n\ntheorem coe_decompose_mul_of_left_mem_of_le (a_mem : a ∈ 𝒜 i) (h : i ≤ n) :\n    (decompose 𝒜 (a * b) n : A) = a * decompose 𝒜 b (n - i) :=\n  by\n  lift a to 𝒜 i using a_mem\n  rwa [decompose_mul, decompose_coe, coe_of_mul_apply_of_le]\n#align direct_sum.coe_decompose_mul_of_left_mem_of_le DirectSum.coe_decompose_mul_of_left_mem_of_le\n\ntheorem coe_decompose_mul_of_right_mem_of_le (b_mem : b ∈ 𝒜 i) (h : i ≤ n) :\n    (decompose 𝒜 (a * b) n : A) = decompose 𝒜 a (n - i) * b :=\n  by\n  lift b to 𝒜 i using b_mem\n  rwa [decompose_mul, decompose_coe, coe_mul_of_apply_of_le]\n#align direct_sum.coe_decompose_mul_of_right_mem_of_le DirectSum.coe_decompose_mul_of_right_mem_of_le\n\ntheorem coe_decompose_mul_of_left_mem (n) [Decidable (i ≤ n)] (a_mem : a ∈ 𝒜 i) :\n    (decompose 𝒜 (a * b) n : A) = if i ≤ n then a * decompose 𝒜 b (n - i) else 0 :=\n  by\n  lift a to 𝒜 i using a_mem\n  rwa [decompose_mul, decompose_coe, coe_of_mul_apply]\n#align direct_sum.coe_decompose_mul_of_left_mem DirectSum.coe_decompose_mul_of_left_mem\n\ntheorem coe_decompose_mul_of_right_mem (n) [Decidable (i ≤ n)] (b_mem : b ∈ 𝒜 i) :\n    (decompose 𝒜 (a * b) n : A) = if i ≤ n then decompose 𝒜 a (n - i) * b else 0 :=\n  by\n  lift b to 𝒜 i using b_mem\n  rwa [decompose_mul, decompose_coe, coe_mul_of_apply]\n#align direct_sum.coe_decompose_mul_of_right_mem DirectSum.coe_decompose_mul_of_right_mem\n\nend DirectSum\n\nend CanonicalOrder\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/GradedAlgebra/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.4567679172774293}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebraic_geometry.presheafed_space.has_colimits\nimport topology.sheaves.functors\n\n/-!\n# Sheafed spaces\n\nIntroduces the category of topological spaces equipped with a sheaf (taking values in an\narbitrary target category `C`.)\n\nWe further describe how to apply functors and natural transformations to the values of the\npresheaves.\n-/\n\nuniverses v u\n\nopen category_theory\nopen Top\nopen topological_space\nopen opposite\nopen category_theory.limits\nopen category_theory.category category_theory.functor\n\nvariables (C : Type u) [category.{v} C] [limits.has_products C]\n\nlocal attribute [tidy] tactic.op_induction'\n\nnamespace algebraic_geometry\n\n/-- A `SheafedSpace C` is a topological space equipped with a sheaf of `C`s. -/\nstructure SheafedSpace extends PresheafedSpace C :=\n(is_sheaf : presheaf.is_sheaf)\n\nvariables {C}\n\nnamespace SheafedSpace\n\ninstance coe_carrier : has_coe (SheafedSpace C) Top :=\n{ coe := λ X, X.carrier }\n\n/-- Extract the `sheaf C (X : Top)` from a `SheafedSpace C`. -/\ndef sheaf (X : SheafedSpace C) : sheaf C (X : Top.{v}) := ⟨X.presheaf, X.is_sheaf⟩\n\n@[simp] lemma as_coe (X : SheafedSpace C) : X.carrier = (X : Top.{v}) := rfl\n@[simp] lemma mk_coe (carrier) (presheaf) (h) :\n  (({ carrier := carrier, presheaf := presheaf, is_sheaf := h } : SheafedSpace.{v} C) :\n  Top.{v}) = carrier :=\nrfl\n\ninstance (X : SheafedSpace.{v} C) : topological_space X := X.carrier.str\n\n/-- The trivial `punit` valued sheaf on any topological space. -/\ndef punit (X : Top) : SheafedSpace (discrete punit) :=\n{ is_sheaf := presheaf.is_sheaf_punit _,\n  ..@PresheafedSpace.const (discrete punit) _ X punit.star }\n\ninstance : inhabited (SheafedSpace (discrete _root_.punit)) := ⟨punit (Top.of pempty)⟩\n\ninstance : category (SheafedSpace C) :=\nshow category (induced_category (PresheafedSpace C) SheafedSpace.to_PresheafedSpace),\nby apply_instance\n\n/-- Forgetting the sheaf condition is a functor from `SheafedSpace C` to `PresheafedSpace C`. -/\n@[derive [full, faithful]]\ndef forget_to_PresheafedSpace : (SheafedSpace C) ⥤ (PresheafedSpace C) :=\ninduced_functor _\n\nvariables {C}\n\nsection\nlocal attribute [simp] id comp\n\n@[simp] lemma id_base (X : SheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).base = (𝟙 (X : Top.{v})) := rfl\n\nlemma id_c (X : SheafedSpace C) :\n  ((𝟙 X) : X ⟶ X).c = eq_to_hom (presheaf.pushforward.id_eq X.presheaf).symm := rfl\n\n@[simp] lemma id_c_app (X : SheafedSpace C) (U) :\n  ((𝟙 X) : X ⟶ X).c.app U = eq_to_hom (by { induction U using opposite.rec, cases U, refl }) :=\nby { induction U using opposite.rec, cases U, simp only [id_c], dsimp, simp, }\n\n@[simp] lemma comp_base {X Y Z : SheafedSpace C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g).base = f.base ≫ g.base := rfl\n\n@[simp] lemma comp_c_app {X Y Z : SheafedSpace C} (α : X ⟶ Y) (β : Y ⟶ Z) (U) :\n  (α ≫ β).c.app U = (β.c).app U ≫ (α.c).app (op ((opens.map (β.base)).obj (unop U)))\n:= rfl\n\nvariables (C)\n\n/-- The forgetful functor from `SheafedSpace` to `Top`. -/\ndef forget : SheafedSpace C ⥤ Top :=\n{ obj := λ X, (X : Top.{v}),\n  map := λ X Y f, f.base }\n\nend\n\nopen Top.presheaf\n\n/--\nThe restriction of a sheafed space along an open embedding into the space.\n-/\ndef restrict {U : Top} (X : SheafedSpace C)\n  {f : U ⟶ (X : Top.{v})} (h : open_embedding f) : SheafedSpace C :=\n{ is_sheaf := λ ι 𝒰, ⟨is_limit.of_iso_limit\n    ((is_limit.postcompose_inv_equiv _ _).inv_fun (X.is_sheaf _).some)\n    (sheaf_condition_equalizer_products.fork.iso_of_open_embedding h 𝒰).symm⟩,\n  ..X.to_PresheafedSpace.restrict h }\n\n/--\nThe restriction of a sheafed space `X` to the top subspace is isomorphic to `X` itself.\n-/\ndef restrict_top_iso (X : SheafedSpace C) :\n  X.restrict (opens.open_embedding ⊤) ≅ X :=\n@preimage_iso _ _ _ _ forget_to_PresheafedSpace _ _\n  (X.restrict (opens.open_embedding ⊤)) _\n  X.to_PresheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef Γ : (SheafedSpace C)ᵒᵖ ⥤ C :=\nforget_to_PresheafedSpace.op ⋙ PresheafedSpace.Γ\n\nlemma Γ_def : (Γ : _ ⥤ C) = forget_to_PresheafedSpace.op ⋙ PresheafedSpace.Γ := rfl\n\n@[simp] \n\nlemma Γ_obj_op (X : SheafedSpace C) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl\n\n@[simp] lemma Γ_map {X Y : (SheafedSpace C)ᵒᵖ} (f : X ⟶ Y) :\n  Γ.map f = f.unop.c.app (op ⊤) := rfl\n\nlemma Γ_map_op {X Y : SheafedSpace C} (f : X ⟶ Y) :\n  Γ.map f.op = f.c.app (op ⊤) := rfl\n\nnoncomputable\ninstance [has_limits C] : creates_colimits (forget_to_PresheafedSpace : SheafedSpace C ⥤ _) :=\n⟨λ J hJ, by exactI ⟨λ K, creates_colimit_of_fully_faithful_of_iso\n  ⟨(PresheafedSpace.colimit_cocone (K ⋙ forget_to_PresheafedSpace)).X,\n    limit_is_sheaf _ (λ j, sheaf.pushforward_sheaf_of_sheaf _ (K.obj (unop j)).2)⟩\n  (colimit.iso_colimit_cocone ⟨_, PresheafedSpace.colimit_cocone_is_colimit _⟩).symm⟩⟩\n\ninstance [has_limits C] : has_colimits (SheafedSpace C) :=\nhas_colimits_of_has_colimits_creates_colimits forget_to_PresheafedSpace\n\nend SheafedSpace\n\nend algebraic_geometry\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebraic_geometry/sheafed_space.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6791787121629466, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.4566333820540642}}
{"text": "import Cat.Setoid.Setoid\n\n\n\n/-! # Morphisms between setoids, seen as setoids over functions\n-/\n\nnamespace Cat\n\n\n\n/-- Notion of morphism over `Setoid` (`⇒`, `\\r=`). -/\nstructure Morph.{ua, ub}\n  (α : Setoid.{ua})\n  (β : Setoid.{ub})\n: Type (max ua ub) where\n\n  /-- Maps values from `α`'s carrier to values of `β`'s carrier. -/\n  map : |α| → |β|\n\n  /-- `map` is proper for setoid equivalence (`≈`). -/\n  proper {a₁ a₂ : |α|} :\n    a₁ ≈ a₂ → map a₁ ≈ map a₂\n\ninfixr:3 \" ⇒ \" =>\n  Morph\n\n\n\nsection Morph\n\n  universe u_α u_β\n\n  variable\n    {α : Setoid.{u_α}}\n    {β : Setoid.{u_β}}\n\n  /-- Domain accessor. -/\n  def Morph.dom\n    (_ : α ⇒ β)\n  : Setoid.{u_α} :=\n    α\n  /-- Codomain accessor. -/\n  def Morph.cod\n    (_ : α ⇒ β)\n  : Setoid.{u_β} :=\n    β\n\n  /-- Applies the underlying function. -/\n  def Morph.app\n    (self : α ⇒ β)\n  : |α| → |β| :=\n    (self.map ·)\n\n\n  /-! ## Equivalence relation on morphisms -/\n  section equiv\n\n    /-- Equivalence relation (extensional equality, `≈`, `\\~~`). -/\n    abbrev Morph.equiv\n      {α β : Setoid}\n      (f g : α ⇒ β)\n    : Prop :=\n      ∀ (a : |α|), f.map a ≈ g.map a\n\n    /-- Give access to `≈` (`\\~~`) equivalence notation. -/\n    instance instHasEquivMorph\n    : HasEquiv (α ⇒ β) where\n      Equiv :=\n        Morph.equiv\n\n    /-- `Morph.equiv` is reflexive. -/\n    def Morph.equiv.refl\n      (m : α ⇒ β)\n    : m ≈ m :=\n      (m.map · |> β.refl)\n\n    /-- `Morph.equiv` is symmetric. -/\n    def Morph.equiv.symm\n      {f g : α ⇒ β}\n      (h : equiv f g)\n    : g ≈ f :=\n      (h · |> β.symm)\n\n    /-- `Morph.equiv` is transitive. -/\n    def Morph.equiv.trans\n      {f g h : α ⇒ β}\n      (eqFG : equiv f g)\n      (eqGH : equiv g h)\n    : f ≈ h :=\n      fun a =>\n        β.trans (eqFG a) (eqGH a)\n\n    /-- `Morph.equiv` is an equivalence relation. -/\n    def Morph.equiv.iseqv\n    : @Equivalence (α ⇒ β) Morph.equiv :=\n      ⟨refl, symm, trans⟩\n\n\n\n    def Morph.equiv.rewrite\n      {f g h : α ⇒ β}\n      (self : f ≈ g)\n      (subgoal : f ≈ h)\n    : g ≈ h :=\n      self.symm.trans subgoal\n\n\n\n    instance instTransMorphTrans\n      {α β : Setoid}\n    : let I := @instHasEquivMorph α β\n      Trans I.Equiv I.Equiv I.Equiv\n    where\n      trans :=\n        Morph.equiv.trans\n\n  end equiv\n\n\n\n  /-- Composition of two morphisms, `Morph` version (`∘M`). -/\n  def Morph.compose\n    (f : β ⇒ γ)\n    (g : α ⇒ β)\n  : α ⇒ γ where\n    map :=\n      f.map ∘ g.map\n    proper :=\n      f.proper ∘ g.proper\n\n  infix:100 \" ∘M \" =>\n    Morph.compose\n\n  /-- Morphism composition (`∘M`) is associative. -/\n  theorem Morph.compose.assoc\n    (f : γ ⇒ δ)\n    (g : β ⇒ γ)\n    (h : α ⇒ β)\n  : f ∘M (g ∘M h) ≈ (f ∘M g) ∘M h :=\n    fun a =>\n      by simp [compose, δ.refl]\n\n  /-- Morphism composition (`∘M`) abides by congruence laws. -/\n  def Morph.compose.congr\n  : Congr (β ⇒ γ) (α ⇒ β) (α ⇒ γ) Morph.compose where\n    left g :=\n      fun h_f a =>\n        g.map a |> h_f\n    right f :=\n      fun h_g a =>\n        h_g a |> f.proper\n\n\n\n\n  /-- Composition of two morphisms, function version (`∘m`). -/\n  def Morph.kompose\n    (f : β ⇒ γ)\n    (g : α ⇒ β)\n  : |α| → |γ| :=\n    (f.compose g).map\n\n  infix:100 \" ∘m \" =>\n    Morph.kompose\n\n\n\n  /-- Identity morphism over an implicit erased setoid `α`. -/\n  protected def Morph.id\n    {α : Setoid}\n  : α ⇒ α where\n    map := id\n    proper := id\n\n  /-- Identity morphism over an explicit erased setoid `α`. -/\n  protected abbrev Morph.id'\n    (α : Setoid)\n  : α ⇒ α :=\n    @Morph.id α\n\n  /-- `Morph.id` is a left-identity for `∘M`. -/\n  theorem Morph.id_compose\n    (f : α ⇒ β)\n  : Morph.id ∘M f ≈ f :=\n    fun _a =>\n      β.refl _\n\n  /-- `Morph.id` is a right-identity for `∘M`. -/\n  theorem Morph.compose_id\n    (f : α ⇒ β)\n  : f ∘M Morph.id ≈ f :=\n    fun _a =>\n      β.refl _\n\n\n\n  /-! ## `Morph` as a `Setoid` -/\n  section MorSet\n\n    /-- `Zetoid` instance so that we can build the actual `Setoid`. -/\n    instance instZetoidMorph\n    : Zetoid (α ⇒ β) where\n      r :=\n        Morph.equiv\n      iseqv :=\n        Morph.equiv.iseqv\n\n    /-- Builds the `Setoid` for `α ⇒ β`, written `α ⇛ β` (`\\r==`).\n\n    Note that you should not need to write `|α ⇛ β|` since the carrier of `α ⇛ β` is simply `α ⇒ β`.\n    It is however sometimes more readable to write `|α ⇛ β ⇛ γ|` for `α ⇒ β ⇛ γ`.\n    -/\n    def Morph.mkSetoid\n      (α : Setoid.{u_a})\n      (β : Setoid.{u_b})\n    : Setoid where\n      Carrier :=\n        α ⇒ β\n      instZetoid :=\n        instZetoidMorph\n\n    infixr:4 \" ⇛ \" =>\n      Morph.mkSetoid\n\n  end MorSet\n\n\n\n  /-! ## More helpers, mostly for defining a first notion of category -/\n\n  /-- Same as `app` but the codomain is a morphism. -/\n  def Morph.app2\n    {γ : Setoid.{u_γ}}\n    (self : α ⇒ β ⇛ γ)\n    -- (self : |α ⇛ β ⇛ γ|) -- alternatively, same as the above\n    (a : |α|)\n  : |β| → |γ| :=\n    self.map a\n    |>.map\n\n  /-- Takes a composition operation over morphisms and returns the underlying binary function. -/\n  @[simp]\n  def Morph.komposeExt\n    {Obj : Sort u_o}\n    {Hom : Obj → Obj → Setoid}\n    (compose :\n      (α β γ : Obj) → |Hom β γ ⇛ Hom α β ⇛ Hom α γ|)\n    {α β γ : outParam Obj}\n  : |Hom β γ| → |Hom α β| → |Hom α γ| :=\n    compose α β γ\n    |>.app2\n\n  macro \"⟦ \" f:term \" ⟧\" : term =>\n    `(Morph.komposeExt $f)\n\nend Morph\n\n\n\n/-! ## Some useful instances -/\n\n/-- Allows using a `Morph` directly as its underlying function. -/\ninstance instCoeFunMorph\n: CoeFun (α ⇒ β) (𝕂 $ |α| → |β|) where\n  coe m :=\n    m.map\n/-- Allows using a `Morph` setoid directly as its underlying function. -/\ninstance instCoeFunMorphSetoid\n: CoeFun (|α ⇛ β|) (𝕂 $ |α| → |β|) where\n  coe m :=\n    m.map\n", "meta": {"author": "AdrienChampion", "repo": "experimentalean4", "sha": "5071a8b007029f61b2e996d9ac89d90999603fcc", "save_path": "github-repos/lean/AdrienChampion-experimentalean4", "path": "github-repos/lean/AdrienChampion-experimentalean4/experimentalean4-5071a8b007029f61b2e996d9ac89d90999603fcc/cat/Cat/Setoid/Morph.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.4566333688629691}}
{"text": "/-!\n# Parametric Higher-Order Abstract Syntax\n\nIn contrast to first-order encodings, higher-order encodings avoid explicit modeling of variable identity.\nInstead, the binding constructs of an object language (the language being\nformalized) can be represented using the binding constructs of the meta language (the language in which the formalization is done).\nThe best known higher-order encoding is called higher-order abstract syntax (HOAS),\nand we can start by attempting to apply it directly in Lean.\n\nRemark: this example is based on an example in the book [Certified Programming with Dependent Types](http://adam.chlipala.net/cpdt/) by Adam Chlipala.\n-/\n\n/-!\nHere is the definition of the simple type system for our programming language, a simply typed\nlambda calculus with natural numbers as the base type.\n-/\ninductive Ty where\n  | nat\n  | fn : Ty → Ty → Ty\n\n/-!\nWe can write a function to translate `Ty` values to a Lean type\n— remember that types are first class, so can be calculated just like any other value.\nWe mark `Ty.denote` as `[reducible]` to make sure the typeclass resolution procedure can\nunfold/reduce it. For example, suppose Lean is trying to synthesize a value for the instance\n`Add (Ty.denote Ty.nat)`. Since `Ty.denote` is marked as `[reducible]`,\nthe typeclass resolution procedure can reduce `Ty.denote Ty.nat` to `Nat`, and use\nthe builtin instance for `Add Nat` as the solution.\n\nRecall that the term `a.denote` is sugar for `denote a` where `denote` is the function being defined.\nWe call it the \"dot notation\".\n-/\n@[reducible] def Ty.denote : Ty → Type\n  | nat    => Nat\n  | fn a b => a.denote → b.denote\n\n/-!\nWith HOAS, each object language binding construct is represented with a function of\nthe meta language. Here is what we get if we apply that idea within an inductive definition\nof term syntax. However a naive encondig in Lean fails to meet the strict positivity restrictions\nimposed by the Lean kernel. An alternate higher-order encoding is parametric HOAS, as introduced by Washburn\nand Weirich for Haskell and tweaked by Adam Chlipala for use in Coq. The key idea is to parameterize the\ndeclaration by a type family `rep` standing for a \"representation of variables.\"\n-/\ninductive Term' (rep : Ty → Type) : Ty → Type\n  | var   : rep ty → Term' rep ty\n  | const : Nat → Term' rep .nat\n  | plus  : Term' rep .nat → Term' rep .nat → Term' rep .nat\n  | lam   : (rep dom → Term' rep ran) → Term' rep (.fn dom ran)\n  | app   : Term' rep (.fn dom ran) → Term' rep dom → Term' rep ran\n  | let   : Term' rep ty₁ → (rep ty₁ → Term' rep ty₂) → Term' rep ty₂\n\n/-!\nLean accepts this definition because our embedded functions now merely take variables as\narguments, instead of arbitrary terms. One might wonder whether there is an easy loophole\nto exploit here, instantiating the parameter `rep` as term itself. However, to do that, we\nwould need to choose a variable representation for this nested mention of term, and so on\nthrough an infinite descent into term arguments.\n\nWe write the final type of a closed term using polymorphic quantification over all possible\nchoices of `rep` type family\n-/\n\nopen Ty (nat fn)\n\nnamespace FirstTry\n\ndef Term (ty : Ty) := (rep : Ty → Type) → Term' rep ty\n\n/-!\nIn the next two example, note how each is written as a function over a `rep` choice,\nsuch that the specific choice has no impact on the structure of the term.\n-/\ndef add : Term (fn nat (fn nat nat)) := fun _rep =>\n  .lam fun x => .lam fun y => .plus (.var x) (.var y)\n\ndef three_the_hard_way : Term nat := fun rep =>\n  .app (.app (add rep) (.const 1)) (.const 2)\n\nend FirstTry\n\n/-!\nThe argument `rep` does not even appear in the function body for `add`. How can that be?\nBy giving our terms expressive types, we allow Lean to infer many arguments for us. In fact,\nwe do not even need to name the `rep` argument! By using Lean implicit arguments and lambdas,\nwe can completely hide `rep` in these examples.\n-/\n\ndef Term (ty : Ty) := {rep : Ty → Type} → Term' rep ty\n\ndef add : Term (fn nat (fn nat nat)) :=\n  .lam fun x => .lam fun y => .plus (.var x) (.var y)\n\ndef three_the_hard_way : Term nat :=\n  .app (.app add (.const 1)) (.const 2)\n\n/-!\nIt may not be at all obvious that the PHOAS representation admits the crucial computable\noperations. The key to effective deconstruction of PHOAS terms is one principle: treat\nthe `rep` parameter as an unconstrained choice of which data should be annotated on each\nvariable. We will begin with a simple example, that of counting how many variable nodes\nappear in a PHOAS term. This operation requires no data annotated on variables, so we\nsimply annotate variables with `Unit` values. Note that, when we go under binders in the\ncases for `lam` and `let`, we must provide the data value to annotate on the new variable we\npass beneath. For our current choice of `Unit` data, we always pass `()`.\n-/\n\ndef countVars : Term' (fun _ => Unit) ty → Nat\n  | .var _    => 1\n  | .const _  => 0\n  | .plus a b => countVars a + countVars b\n  | .app f a  => countVars f + countVars a\n  | .lam b    => countVars (b ())\n  | .let a b  => countVars a + countVars (b ())\n\n/-! We can now easily prove that `add` has two variables by using reflexivity -/\n\nexample : countVars add = 2 :=\n  rfl\n\n/-!\nHere is another example, translating PHOAS terms into strings giving a first-order rendering.\nTo implement this translation, the key insight is to tag variables with strings, giving their names.\nThe function takes as an additional input `i` which is used to create variable names for binders.\nWe also use the string interpolation available in Lean. For example, `s!\"x_{i}\"` is expanded to\n`\"x_\" ++ toString i`.\n-/\ndef pretty (e : Term' (fun _ => String) ty) (i : Nat := 1) : String :=\n  match e with\n  | .var s     => s\n  | .const n   => toString n\n  | .app f a   => s!\"({pretty f i} {pretty a i})\"\n  | .plus a b  => s!\"({pretty a i} + {pretty b i})\"\n  | .lam f     =>\n    let x := s!\"x_{i}\"\n    s!\"(fun {x} => {pretty (f x) (i+1)})\"\n  | .let a b  =>\n    let x := s!\"x_{i}\"\n    s!\"(let {x} := {pretty a i}; => {pretty (b x) (i+1)}\"\n\n#eval pretty three_the_hard_way\n\n/-!\nIt is not necessary to convert to a different representation to support many common\noperations on terms. For instance, we can implement substitution of terms for variables.\nThe key insight here is to tag variables with terms, so that, on encountering a variable, we\ncan simply replace it by the term in its tag. We will call this function initially on a term\nwith exactly one free variable, tagged with the appropriate substitute. During recursion,\nnew variables are added, but they are only tagged with their own term equivalents. Note\nthat this function squash is parameterized over a specific `rep` choice.\n-/\ndef squash : Term' (Term' rep) ty → Term' rep ty\n | .var e    => e\n | .const n  => .const n\n | .plus a b => .plus (squash a) (squash b)\n | .lam f    => .lam fun x => squash (f (.var x))\n | .app f a  => .app (squash f) (squash a)\n | .let a b  => .let (squash a) fun x => squash (b (.var x))\n\n/-!\nTo define the final substitution function over terms with single free variables, we define\n`Term1`, an analogue to Term that we defined before for closed terms.\n-/\ndef Term1 (ty1 ty2 : Ty) := {rep : Ty → Type} → rep ty1 → Term' rep ty2\n\n/-!\nSubstitution is defined by (1) instantiating a `Term1` to tag variables with terms and (2)\napplying the result to a specific term to be substituted. Note how the parameter `rep` of\n`squash` is instantiated: the body of `subst` is itself a polymorphic quantification over `rep`,\nstanding for a variable tag choice in the output term; and we use that input to compute a\ntag choice for the input term.\n-/\n\ndef subst (e : Term1 ty1 ty2) (e' : Term ty1) : Term ty2 :=\n  squash (e e')\n\n/-!\nWe can view `Term1` as a term with hole. In the following example,\n`(fun x => plus (var x) (const 5))` can be viewed as the term `plus _ (const 5)` where\nthe hole `_` is instantiated by `subst` with `three_the_hard_way`\n-/\n\n#eval pretty <| subst (fun x => .plus (.var x) (.const 5)) three_the_hard_way\n\n/-!\nOne further development, which may seem surprising at first,\nis that we can also implement a usual term denotation function,\nwhen we tag variables with their denotations.\n\nThe attribute `[simp]` instructs Lean to always try to unfold `denote` applications when one applies\nthe `simp` tactic. We also say this is a hint for the Lean term simplifier.\n-/\n@[simp] def denote : Term' Ty.denote ty → ty.denote\n  | .var x    => x\n  | .const n  => n\n  | .plus a b => denote a + denote b\n  | .app f a  => denote f (denote a)\n  | .lam f    => fun x => denote (f x)\n  | .let a b  => denote (b (denote a))\n\nexample : denote three_the_hard_way = 3 :=\n  rfl\n\n/-!\nTo summarize, the PHOAS representation has all the expressive power of more\nstandard encodings (e.g., using de Bruijn indices), and a variety of translations are actually much more pleasant to\nimplement than usual, thanks to the novel ability to tag variables with data.\n-/\n\n/-!\nWe now define the constant folding optimization that traverses a term if replaces subterms such as\n`plus (const m) (const n)` with `const (n+m)`.\n-/\n@[simp] def constFold : Term' rep ty → Term' rep ty\n  | .var x    => .var x\n  | .const n  => .const n\n  | .app f a  => .app (constFold f) (constFold a)\n  | .lam f    => .lam fun x => constFold (f x)\n  | .let a b  => .let (constFold a) fun x => constFold (b x)\n  | .plus a b =>\n    match constFold a, constFold b with\n    | .const n, .const m => .const (n+m)\n    | a',       b'       => .plus a' b'\n\n/-!\nThe correctness of the `constFold` is proved using induction, case-analysis, and the term simplifier.\nWe prove all cases but the one for `plus` using `simp [*]`. This tactic instructs the term simplifier to\nuse hypotheses such as `a = b` as rewriting/simplications rules.\nWe use the `split` to break the nested `match` expression in the `plus` case into two cases.\nThe local variables `iha` and `ihb` are the induction hypotheses for `a` and `b`.\nThe modifier `←` in a term simplifier argument instructs the term simplier to use the equation as a rewriting rule in\nthe \"reverse direction. That is, given `h : a = b`, `← h` instructs the term simplifier to rewrite `b` subterms to `a`.\n-/\ntheorem constFold_sound (e : Term' Ty.denote ty) : denote (constFold e) = denote e := by\n  induction e with simp [*]\n  | plus a b iha ihb =>\n    split\n    next he₁ he₂ => simp [← iha, ← ihb, he₁, he₂]\n    next => simp [iha, ihb]\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/doc/examples/phoas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.679178699175393, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.4566333644038181}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro, Patrick Massot\n\nTheory of uniform spaces.\n\nUniform spaces are a generalization of metric spaces and topological groups. Many concepts directly\ngeneralize to uniform spaces, e.g.\n\n* completeness\n* extension of uniform continuous functions to complete spaces\n* uniform contiunuity & embedding\n* totally bounded\n* totally bounded ∧ complete → compact\n\nThe central concept of uniform spaces is its uniformity: a filter relating two elements of the\nspace. This filter is reflexive, symmetric and transitive. So a set (i.e. a relation) in this filter\nrepresents a 'distance': it is reflexive, symmetric and the uniformity contains a set for which the\n`triangular` rule holds.\n\nThe formalization is mostly based on the books:\n  N. Bourbaki: General Topology\n  I. M. James: Topologies and Uniformities\nA major difference is that this formalization is heavily based on the filter library.\n-/\nimport order.filter order.filter.lift data.quot topology.constructions\n\nopen set lattice filter classical\nlocal attribute [instance, priority 0] prop_decidable\n\nset_option eqn_compiler.zeta true\n\nuniverses u\nsection\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} {ι : Sort*}\n\n/-- The identity relation, or the graph of the identity function -/\ndef id_rel {α : Type*} := {p : α × α | p.1 = p.2}\n\n@[simp] theorem mem_id_rel {a b : α} : (a, b) ∈ @id_rel α ↔ a = b := iff.rfl\n\n@[simp] theorem id_rel_subset {s : set (α × α)} : id_rel ⊆ s ↔ ∀ a, (a, a) ∈ s :=\nby simp [subset_def]; exact forall_congr (λ a, by simp)\n\n/-- The composition of relations -/\ndef comp_rel {α : Type u} (r₁ r₂ : set (α×α)) := {p : α × α | ∃z:α, (p.1, z) ∈ r₁ ∧ (z, p.2) ∈ r₂}\n\n@[simp] theorem mem_comp_rel {r₁ r₂ : set (α×α)}\n  {x y : α} : (x, y) ∈ comp_rel r₁ r₂ ↔ ∃ z, (x, z) ∈ r₁ ∧ (z, y) ∈ r₂ := iff.rfl\n\n@[simp] theorem swap_id_rel : prod.swap '' id_rel = @id_rel α :=\nset.ext $ assume ⟨a, b⟩, by simp [image_swap_eq_preimage_swap]; exact eq_comm\n\ntheorem monotone_comp_rel [preorder β] {f g : β → set (α×α)}\n  (hf : monotone f) (hg : monotone g) : monotone (λx, comp_rel (f x) (g x)) :=\nassume a b h p ⟨z, h₁, h₂⟩, ⟨z, hf h h₁, hg h h₂⟩\n\nlemma prod_mk_mem_comp_rel {a b c : α} {s t : set (α×α)} (h₁ : (a, c) ∈ s) (h₂ : (c, b) ∈ t) :\n  (a, b) ∈ comp_rel s t :=\n⟨c, h₁, h₂⟩\n\n@[simp] lemma id_comp_rel {r : set (α×α)} : comp_rel id_rel r = r :=\nset.ext $ assume ⟨a, b⟩, by simp\n\nlemma comp_rel_assoc {r s t : set (α×α)} :\n  comp_rel (comp_rel r s) t = comp_rel r (comp_rel s t) :=\nby ext p; cases p; simp only [mem_comp_rel]; tauto\n\n/-- This core description of a uniform space is outside of the type class hierarchy. It is useful\n  for constructions of uniform spaces, when the topology is derived from the uniform space. -/\nstructure uniform_space.core (α : Type u) :=\n(uniformity : filter (α × α))\n(refl       : principal id_rel ≤ uniformity)\n(symm       : tendsto prod.swap uniformity uniformity)\n(comp       : uniformity.lift' (λs, comp_rel s s) ≤ uniformity)\n\ndef uniform_space.core.mk' {α : Type u} (U : filter (α × α))\n  (refl : ∀ (r ∈ U) x, (x, x) ∈ r)\n  (symm : ∀ r ∈ U, {p | prod.swap p ∈ r} ∈ U)\n  (comp : ∀ r ∈ U, ∃ t ∈ U, comp_rel t t ⊆ r) : uniform_space.core α :=\n⟨U, λ r ru, id_rel_subset.2 (refl _ ru), symm,\n  begin\n    intros r ru,\n    rw [mem_lift'_sets],\n    exact comp _ ru,\n    apply monotone_comp_rel; exact monotone_id,\n  end⟩\n\n/-- A uniform space generates a topological space -/\ndef uniform_space.core.to_topological_space {α : Type u} (u : uniform_space.core α) :\n  topological_space α :=\n{ is_open        := λs, ∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ u.uniformity,\n  is_open_univ   := by simp; intro; exact univ_mem_sets,\n  is_open_inter  :=\n    assume s t hs ht x ⟨xs, xt⟩, by filter_upwards [hs x xs, ht x xt]; simp {contextual := tt},\n  is_open_sUnion :=\n    assume s hs x ⟨t, ts, xt⟩, by filter_upwards [hs t ts x xt] assume p ph h, ⟨t, ts, ph h⟩ }\n\nlemma uniform_space.core_eq : ∀{u₁ u₂ : uniform_space.core α}, u₁.uniformity = u₂.uniformity → u₁ = u₂\n| ⟨u₁, _, _, _⟩  ⟨u₂, _, _, _⟩ h := have u₁ = u₂, from h, by simp [*]\n\n/-- A uniform space is a generalization of the \"uniform\" topological aspects of a\n  metric space. It consists of a filter on `α × α` called the \"uniformity\", which\n  satisfies properties analogous to the reflexivity, symmetry, and triangle properties\n  of a metric.\n\n  A metric space has a natural uniformity, and a uniform space has a natural topology.\n  A topological group also has a natural uniformity, even when it is not metrizable. -/\nclass uniform_space (α : Type u) extends topological_space α, uniform_space.core α :=\n(is_open_uniformity : ∀s, is_open s ↔ (∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ uniformity))\n\n@[pattern] def uniform_space.mk' {α} (t : topological_space α)\n  (c : uniform_space.core α)\n  (is_open_uniformity : ∀s:set α, t.is_open s ↔\n    (∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ c.uniformity)) :\n  uniform_space α := ⟨c, is_open_uniformity⟩\n\ndef uniform_space.of_core {α : Type u} (u : uniform_space.core α) : uniform_space α :=\n{ to_core := u,\n  to_topological_space := u.to_topological_space,\n  is_open_uniformity := assume a, iff.refl _ }\n\ndef uniform_space.of_core_eq {α : Type u} (u : uniform_space.core α) (t : topological_space α)\n  (h : t = u.to_topological_space) : uniform_space α :=\n{ to_core := u,\n  to_topological_space := t,\n  is_open_uniformity := assume a, h.symm ▸ iff.refl _ }\n\nlemma uniform_space.to_core_to_topological_space (u : uniform_space α) :\n  u.to_core.to_topological_space = u.to_topological_space :=\ntopological_space_eq $ funext $ assume s,\n  by rw [uniform_space.core.to_topological_space, uniform_space.is_open_uniformity]\n\n@[extensionality]\nlemma uniform_space_eq : ∀{u₁ u₂ : uniform_space α}, u₁.uniformity = u₂.uniformity → u₁ = u₂\n| (uniform_space.mk' t₁ u₁ o₁)  (uniform_space.mk' t₂ u₂ o₂) h :=\n  have u₁ = u₂, from uniform_space.core_eq h,\n  have t₁ = t₂, from topological_space_eq $ funext $ assume s, by rw [o₁, o₂]; simp [this],\n  by simp [*]\n\nlemma uniform_space.of_core_eq_to_core\n  (u : uniform_space α) (t : topological_space α) (h : t = u.to_core.to_topological_space) :\n  uniform_space.of_core_eq u.to_core t h = u :=\nuniform_space_eq rfl\n\nsection uniform_space\nvariables [uniform_space α]\n\n/-- The uniformity is a filter on α × α (inferred from an ambient uniform space\n  structure on α). -/\ndef uniformity (α : Type u) [uniform_space α] : filter (α × α) :=\n  (@uniform_space.to_core α _).uniformity\n\nlocal notation `𝓤` := uniformity\n\nlemma is_open_uniformity {s : set α} :\n  is_open s ↔ (∀x∈s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α) :=\nuniform_space.is_open_uniformity s\n\nlemma refl_le_uniformity : principal id_rel ≤ 𝓤 α :=\n(@uniform_space.to_core α _).refl\n\nlemma refl_mem_uniformity {x : α} {s : set (α × α)} (h : s ∈ 𝓤 α) :\n  (x, x) ∈ s :=\nrefl_le_uniformity h rfl\n\nlemma symm_le_uniformity : map (@prod.swap α α) (𝓤 _) ≤ (𝓤 _) :=\n(@uniform_space.to_core α _).symm\n\nlemma comp_le_uniformity : (𝓤 α).lift' (λs:set (α×α), comp_rel s s) ≤ 𝓤 α :=\n(@uniform_space.to_core α _).comp\n\nlemma tendsto_swap_uniformity : tendsto (@prod.swap α α) (𝓤 α) (𝓤 α) :=\nsymm_le_uniformity\n\nlemma tendsto_const_uniformity {a : α} {f : filter β} : tendsto (λ _, (a, a)) f (𝓤 α) :=\nassume s hs,\nshow {x | (a, a) ∈ s} ∈ f,\n  from univ_mem_sets' $ assume b, refl_mem_uniformity hs\n\nlemma comp_mem_uniformity_sets {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, comp_rel t t ⊆ s :=\nhave s ∈ (𝓤 α).lift' (λt:set (α×α), comp_rel t t),\n  from comp_le_uniformity hs,\n(mem_lift'_sets $ monotone_comp_rel monotone_id monotone_id).mp this\n\nlemma symm_of_uniformity {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, (∀a b, (a, b) ∈ t → (b, a) ∈ t) ∧ t ⊆ s :=\nhave preimage prod.swap s ∈ 𝓤 α, from symm_le_uniformity hs,\n⟨s ∩ preimage prod.swap s, inter_mem_sets hs this, assume a b ⟨h₁, h₂⟩, ⟨h₂, h₁⟩, inter_subset_left _ _⟩\n\nlemma comp_symm_of_uniformity {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  ∃ t ∈ 𝓤 α, (∀{a b}, (a, b) ∈ t → (b, a) ∈ t) ∧ comp_rel t t ⊆ s :=\nlet ⟨t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs in\nlet ⟨t', ht', ht'₁, ht'₂⟩ := symm_of_uniformity ht₁ in\n⟨t', ht', ht'₁, subset.trans (monotone_comp_rel monotone_id monotone_id ht'₂) ht₂⟩\n\nlemma uniformity_le_symm : 𝓤 α ≤ (@prod.swap α α) <$> 𝓤 α :=\nby rw [map_swap_eq_comap_swap];\nfrom map_le_iff_le_comap.1 tendsto_swap_uniformity\n\nlemma uniformity_eq_symm : 𝓤 α = (@prod.swap α α) <$> 𝓤 α :=\nle_antisymm uniformity_le_symm symm_le_uniformity\n\ntheorem uniformity_lift_le_swap {g : set (α×α) → filter β} {f : filter β} (hg : monotone g)\n  (h : (𝓤 α).lift (λs, g (preimage prod.swap s)) ≤ f) : (𝓤 α).lift g ≤ f :=\ncalc (𝓤 α).lift g ≤ (filter.map (@prod.swap α α) $ 𝓤 α).lift g :\n    lift_mono uniformity_le_symm (le_refl _)\n  ... ≤ _ :\n    by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h\n\nlemma uniformity_lift_le_comp {f : set (α×α) → filter β} (h : monotone f):\n  (𝓤 α).lift (λs, f (comp_rel s s)) ≤ (𝓤 α).lift f :=\ncalc (𝓤 α).lift (λs, f (comp_rel s s)) =\n    ((𝓤 α).lift' (λs:set (α×α), comp_rel s s)).lift f :\n  begin\n    rw [lift_lift'_assoc],\n    exact monotone_comp_rel monotone_id monotone_id,\n    exact h\n  end\n  ... ≤ (𝓤 α).lift f : lift_mono comp_le_uniformity (le_refl _)\n\nlemma comp_le_uniformity3 :\n  (𝓤 α).lift' (λs:set (α×α), comp_rel s (comp_rel s s)) ≤ (𝓤 α) :=\ncalc (𝓤 α).lift' (λd, comp_rel d (comp_rel d d)) =\n  (𝓤 α).lift (λs, (𝓤 α).lift' (λt:set(α×α), comp_rel s (comp_rel t t))) :\n  begin\n    rw [lift_lift'_same_eq_lift'],\n    exact (assume x, monotone_comp_rel monotone_const $ monotone_comp_rel monotone_id monotone_id),\n    exact (assume x, monotone_comp_rel monotone_id monotone_const),\n  end\n  ... ≤ (𝓤 α).lift (λs, (𝓤 α).lift' (λt:set(α×α), comp_rel s t)) :\n    lift_mono' $ assume s hs, @uniformity_lift_le_comp α _ _ (principal ∘ comp_rel s) $\n      monotone_comp (monotone_comp_rel monotone_const monotone_id) monotone_principal\n  ... = (𝓤 α).lift' (λs:set(α×α), comp_rel s s) :\n    lift_lift'_same_eq_lift'\n      (assume s, monotone_comp_rel monotone_const monotone_id)\n      (assume s, monotone_comp_rel monotone_id monotone_const)\n  ... ≤ (𝓤 α) : comp_le_uniformity\n\nlemma mem_nhds_uniformity_iff {x : α} {s : set α} :\n  s ∈ nhds x ↔ {p : α × α | p.1 = x → p.2 ∈ s} ∈ 𝓤 α :=\n⟨ begin\n    simp only [mem_nhds_sets_iff, is_open_uniformity, and_imp, exists_imp_distrib],\n    exact assume t ts ht xt, by filter_upwards [ht x xt] assume ⟨x', y⟩ h eq, ts $ h eq\n  end,\n\n  assume hs,\n  mem_nhds_sets_iff.mpr ⟨{x | {p : α × α | p.1 = x → p.2 ∈ s} ∈ 𝓤 α},\n    assume x' hx', refl_mem_uniformity hx' rfl,\n    is_open_uniformity.mpr $ assume x' hx',\n      let ⟨t, ht, tr⟩ := comp_mem_uniformity_sets hx' in\n      by filter_upwards [ht] assume ⟨a, b⟩ hp' (hax' : a = x'),\n      by filter_upwards [ht] assume ⟨a, b'⟩ hp'' (hab : a = b),\n      have hp : (x', b) ∈ t, from hax' ▸ hp',\n      have (b, b') ∈ t, from hab ▸ hp'',\n      have (x', b') ∈ comp_rel t t, from ⟨b, hp, this⟩,\n      show b' ∈ s,\n        from tr this rfl,\n    hs⟩⟩\n\nlemma nhds_eq_comap_uniformity {x : α} : nhds x = (𝓤 α).comap (prod.mk x) :=\nby ext s; rw [mem_nhds_uniformity_iff, mem_comap_sets]; from iff.intro\n  (assume hs, ⟨_, hs, assume x hx, hx rfl⟩)\n  (assume ⟨t, h, ht⟩, (𝓤 α).sets_of_superset h $\n    assume ⟨p₁, p₂⟩ hp (h : p₁ = x), ht $ by simp [h.symm, hp])\n\nlemma nhds_eq_uniformity {x : α} : nhds x = (𝓤 α).lift' (λs:set (α×α), {y | (x, y) ∈ s}) :=\nbegin\n  ext s,\n  rw [mem_lift'_sets], tactic.swap, apply monotone_preimage,\n  simp [mem_nhds_uniformity_iff],\n  exact ⟨assume h, ⟨_, h, assume y h, h rfl⟩,\n    assume ⟨t, h₁, h₂⟩,\n    (𝓤 α).sets_of_superset h₁ $\n    assume ⟨x', y⟩ hp (eq : x' = x), h₂ $\n    show (x, y) ∈ t, from eq ▸ hp⟩\nend\n\nlemma mem_nhds_left (x : α) {s : set (α×α)} (h : s ∈ 𝓤 α) :\n  {y : α | (x, y) ∈ s} ∈ nhds x :=\nhave nhds x ≤ principal {y : α | (x, y) ∈ s},\n  by rw [nhds_eq_uniformity]; exact infi_le_of_le s (infi_le _ h),\nby simp at this; assumption\n\nlemma mem_nhds_right (y : α) {s : set (α×α)} (h : s ∈ 𝓤 α) :\n  {x : α | (x, y) ∈ s} ∈ nhds y :=\nmem_nhds_left _ (symm_le_uniformity h)\n\nlemma tendsto_right_nhds_uniformity {a : α} : tendsto (λa', (a', a)) (nhds a) (𝓤 α) :=\nassume s, mem_nhds_right a\n\nlemma tendsto_left_nhds_uniformity {a : α} : tendsto (λa', (a, a')) (nhds a) (𝓤 α) :=\nassume s, mem_nhds_left a\n\nlemma lift_nhds_left {x : α} {g : set α → filter β} (hg : monotone g) :\n  (nhds x).lift g = (𝓤 α).lift (λs:set (α×α), g {y | (x, y) ∈ s}) :=\neq.trans\n  begin\n    rw [nhds_eq_uniformity],\n    exact (filter.lift_assoc $ monotone_comp monotone_preimage $ monotone_comp monotone_preimage monotone_principal)\n  end\n  (congr_arg _ $ funext $ assume s, filter.lift_principal hg)\n\nlemma lift_nhds_right {x : α} {g : set α → filter β} (hg : monotone g) :\n  (nhds x).lift g = (𝓤 α).lift (λs:set (α×α), g {y | (y, x) ∈ s}) :=\ncalc (nhds x).lift g = (𝓤 α).lift (λs:set (α×α), g {y | (x, y) ∈ s}) : lift_nhds_left hg\n  ... = ((@prod.swap α α) <$> (𝓤 α)).lift (λs:set (α×α), g {y | (x, y) ∈ s}) : by rw [←uniformity_eq_symm]\n  ... = (𝓤 α).lift (λs:set (α×α), g {y | (x, y) ∈ image prod.swap s}) :\n    map_lift_eq2 $ monotone_comp monotone_preimage hg\n  ... = _ : by simp [image_swap_eq_preimage_swap]\n\nlemma nhds_nhds_eq_uniformity_uniformity_prod {a b : α} :\n  filter.prod (nhds a) (nhds b) =\n  (𝓤 α).lift (λs:set (α×α), (𝓤 α).lift' (λt:set (α×α),\n    set.prod {y : α | (y, a) ∈ s} {y : α | (b, y) ∈ t})) :=\nbegin\n  rw [prod_def],\n  show (nhds a).lift (λs:set α, (nhds b).lift (λt:set α, principal (set.prod s t))) = _,\n  rw [lift_nhds_right],\n  apply congr_arg, funext s,\n  rw [lift_nhds_left],\n  refl,\n  exact monotone_comp (monotone_prod monotone_const monotone_id) monotone_principal,\n  exact (monotone_lift' monotone_const $ monotone_lam $\n    assume x, monotone_prod monotone_id monotone_const)\nend\n\nlemma nhds_eq_uniformity_prod {a b : α} :\n  nhds (a, b) =\n  (𝓤 α).lift' (λs:set (α×α), set.prod {y : α | (y, a) ∈ s} {y : α | (b, y) ∈ s}) :=\nbegin\n  rw [nhds_prod_eq, nhds_nhds_eq_uniformity_uniformity_prod, lift_lift'_same_eq_lift'],\n  { intro s, exact monotone_prod monotone_const monotone_preimage },\n  { intro t, exact monotone_prod monotone_preimage monotone_const }\nend\n\nlemma nhdset_of_mem_uniformity {d : set (α×α)} (s : set (α×α)) (hd : d ∈ 𝓤 α) :\n  ∃(t : set (α×α)), is_open t ∧ s ⊆ t ∧ t ⊆ {p | ∃x y, (p.1, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.2) ∈ d} :=\nlet cl_d := {p:α×α | ∃x y, (p.1, x) ∈ d ∧ (x, y) ∈ s ∧ (y, p.2) ∈ d} in\nhave ∀p ∈ s, ∃t ⊆ cl_d, is_open t ∧ p ∈ t, from\n  assume ⟨x, y⟩ hp, mem_nhds_sets_iff.mp $\n  show cl_d ∈ nhds (x, y),\n  begin\n    rw [nhds_eq_uniformity_prod, mem_lift'_sets],\n    exact ⟨d, hd, assume ⟨a, b⟩ ⟨ha, hb⟩, ⟨x, y, ha, hp, hb⟩⟩,\n    exact monotone_prod monotone_preimage monotone_preimage\n  end,\nhave ∃t:(Π(p:α×α) (h:p ∈ s), set (α×α)),\n    ∀p, ∀h:p ∈ s, t p h ⊆ cl_d ∧ is_open (t p h) ∧ p ∈ t p h,\n  by simp [classical.skolem] at this; simp; assumption,\nmatch this with\n| ⟨t, ht⟩ :=\n  ⟨(⋃ p:α×α, ⋃ h : p ∈ s, t p h : set (α×α)),\n    is_open_Union $ assume (p:α×α), is_open_Union $ assume hp, (ht p hp).right.left,\n    assume ⟨a, b⟩ hp, begin simp; exact ⟨a, b, hp, (ht (a,b) hp).right.right⟩ end,\n    Union_subset $ assume p, Union_subset $ assume hp, (ht p hp).left⟩\nend\n\nlemma closure_eq_inter_uniformity {t : set (α×α)} :\n  closure t = (⋂ d ∈ 𝓤 α, comp_rel d (comp_rel t d)) :=\nset.ext $ assume ⟨a, b⟩,\ncalc (a, b) ∈ closure t ↔ (nhds (a, b) ⊓ principal t ≠ ⊥) : by simp [closure_eq_nhds]\n  ... ↔ (((@prod.swap α α) <$> 𝓤 α).lift'\n      (λ (s : set (α × α)), set.prod {x : α | (x, a) ∈ s} {y : α | (b, y) ∈ s}) ⊓ principal t ≠ ⊥) :\n    by rw [←uniformity_eq_symm, nhds_eq_uniformity_prod]\n  ... ↔ ((map (@prod.swap α α) (𝓤 α)).lift'\n      (λ (s : set (α × α)), set.prod {x : α | (x, a) ∈ s} {y : α | (b, y) ∈ s}) ⊓ principal t ≠ ⊥) :\n    by refl\n  ... ↔ ((𝓤 α).lift'\n      (λ (s : set (α × α)), set.prod {y : α | (a, y) ∈ s} {x : α | (x, b) ∈ s}) ⊓ principal t ≠ ⊥) :\n  begin\n    rw [map_lift'_eq2],\n    simp [image_swap_eq_preimage_swap, function.comp],\n    exact monotone_prod monotone_preimage monotone_preimage\n  end\n  ... ↔ (∀s ∈ 𝓤 α, ∃x, x ∈ set.prod {y : α | (a, y) ∈ s} {x : α | (x, b) ∈ s} ∩ t) :\n  begin\n    rw [lift'_inf_principal_eq, lift'_neq_bot_iff],\n    apply forall_congr, intro s, rw [ne_empty_iff_exists_mem],\n    exact monotone_inter (monotone_prod monotone_preimage monotone_preimage) monotone_const\n  end\n  ... ↔ (∀ s ∈ 𝓤 α, (a, b) ∈ comp_rel s (comp_rel t s)) :\n    forall_congr $ assume s, forall_congr $ assume hs,\n    ⟨assume ⟨⟨x, y⟩, ⟨⟨hx, hy⟩, hxyt⟩⟩, ⟨x, hx, y, hxyt, hy⟩,\n      assume ⟨x, hx, y, hxyt, hy⟩, ⟨⟨x, y⟩, ⟨⟨hx, hy⟩, hxyt⟩⟩⟩\n  ... ↔ _ : by simp\n\nlemma uniformity_eq_uniformity_closure : 𝓤 α = (𝓤 α).lift' closure :=\nle_antisymm\n  (le_infi $ assume s, le_infi $ assume hs, by simp; filter_upwards [hs] subset_closure)\n  (calc (𝓤 α).lift' closure ≤ (𝓤 α).lift' (λd, comp_rel d (comp_rel d d)) :\n      lift'_mono' (by intros s hs; rw [closure_eq_inter_uniformity]; exact bInter_subset_of_mem hs)\n    ... ≤ (𝓤 α) : comp_le_uniformity3)\n\nlemma uniformity_eq_uniformity_interior : 𝓤 α = (𝓤 α).lift' interior :=\nle_antisymm\n  (le_infi $ assume d, le_infi $ assume hd,\n    let ⟨s, hs, hs_comp⟩ := (mem_lift'_sets $\n      monotone_comp_rel monotone_id $ monotone_comp_rel monotone_id monotone_id).mp (comp_le_uniformity3 hd) in\n    let ⟨t, ht, hst, ht_comp⟩ := nhdset_of_mem_uniformity s hs in\n    have s ⊆ interior d, from\n      calc s ⊆ t : hst\n       ... ⊆ interior d : (subset_interior_iff_subset_of_open ht).mpr $\n        assume x, assume : x ∈ t, let ⟨x, y, h₁, h₂, h₃⟩ := ht_comp this in hs_comp ⟨x, h₁, y, h₂, h₃⟩,\n    have interior d ∈ 𝓤 α, by filter_upwards [hs] this,\n    by simp [this])\n  (assume s hs, ((𝓤 α).lift' interior).sets_of_superset (mem_lift' hs) interior_subset)\n\nlemma interior_mem_uniformity {s : set (α × α)} (hs : s ∈ 𝓤 α) :\n  interior s ∈ 𝓤 α :=\nby rw [uniformity_eq_uniformity_interior]; exact mem_lift' hs\n\nlemma mem_uniformity_is_closed [uniform_space α] {s : set (α×α)} (h : s ∈ 𝓤 α) :\n  ∃t ∈ 𝓤 α, is_closed t ∧ t ⊆ s :=\nhave s ∈ (𝓤 α).lift' closure, by rwa [uniformity_eq_uniformity_closure] at h,\nhave ∃ t ∈ 𝓤 α, closure t ⊆ s,\n  by rwa [mem_lift'_sets] at this; apply closure_mono,\nlet ⟨t, ht, hst⟩ := this in\n⟨closure t, (𝓤 α).sets_of_superset ht subset_closure, is_closed_closure, hst⟩\n\n/- uniform continuity -/\n\ndef uniform_continuous [uniform_space β] (f : α → β) :=\ntendsto (λx:α×α, (f x.1, f x.2)) (𝓤 α) (𝓤 β)\n\ntheorem uniform_continuous_def [uniform_space β] {f : α → β} :\n  uniform_continuous f ↔ ∀ r ∈ 𝓤 β,\n    {x : α × α | (f x.1, f x.2) ∈ r} ∈ 𝓤 α :=\niff.rfl\n\nlemma uniform_continuous_of_const [uniform_space β] {c : α → β} (h : ∀a b, c a = c b) :\n  uniform_continuous c :=\nhave (λ (x : α × α), (c (x.fst), c (x.snd))) ⁻¹' id_rel = univ, from\n  eq_univ_iff_forall.2 $ assume ⟨a, b⟩, h a b,\nle_trans (map_le_iff_le_comap.2 $ by simp [comap_principal, this, univ_mem_sets]) refl_le_uniformity\n\nlemma uniform_continuous_id : uniform_continuous (@id α) :=\nby simp [uniform_continuous]; exact tendsto_id\n\nlemma uniform_continuous_const [uniform_space β] {b : β} : uniform_continuous (λa:α, b) :=\n@tendsto_const_uniformity _ _ _ b (𝓤 α)\n\nlemma uniform_continuous.comp [uniform_space β] [uniform_space γ] {f : α → β} {g : β → γ}\n  (hf : uniform_continuous f) (hg : uniform_continuous g) : uniform_continuous (g ∘ f) :=\nhf.comp hg\n\nlemma uniform_continuous.continuous [uniform_space β] {f : α → β}\n  (hf : uniform_continuous f) : continuous f :=\ncontinuous_iff_continuous_at.mpr $ assume a,\ncalc map f (nhds a) ≤\n    (map (λp:α×α, (f p.1, f p.2)) (𝓤 α)).lift' (λs:set (β×β), {y | (f a, y) ∈ s}) :\n  begin\n    rw [nhds_eq_uniformity, map_lift'_eq, map_lift'_eq2],\n    exact (lift'_mono' $ assume s hs b ⟨a', (ha' : (_, a') ∈ s), a'_eq⟩,\n      ⟨(a, a'), ha', show (f a, f a') = (f a, b), from a'_eq ▸ rfl⟩),\n    exact monotone_preimage,\n    exact monotone_preimage\n  end\n  ... ≤ nhds (f a) :\n    by rw [nhds_eq_uniformity]; exact lift'_mono hf (le_refl _)\nend uniform_space\nend\n\nlocal notation `𝓤` := uniformity\n\nsection constructions\nvariables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} {ι : Sort*}\n\ninstance : partial_order (uniform_space α) :=\n{ le          := λt s, s.uniformity ≤ t.uniformity,\n  le_antisymm := assume t s h₁ h₂, uniform_space_eq $ le_antisymm h₂ h₁,\n  le_refl     := assume t, le_refl _,\n  le_trans    := assume a b c h₁ h₂, @le_trans _ _ c.uniformity b.uniformity a.uniformity h₂ h₁ }\n\ninstance : has_Sup (uniform_space α) :=\n⟨assume s, uniform_space.of_core {\n  uniformity := (⨅u∈s, @uniformity α u),\n  refl       := le_infi $ assume u, le_infi $ assume hu, u.refl,\n  symm       := le_infi $ assume u, le_infi $ assume hu,\n    le_trans (map_mono $ infi_le_of_le _ $ infi_le _ hu) u.symm,\n  comp       := le_infi $ assume u, le_infi $ assume hu,\n    le_trans (lift'_mono (infi_le_of_le _ $ infi_le _ hu) $ le_refl _) u.comp }⟩\n\nprivate lemma le_Sup {tt : set (uniform_space α)} {t : uniform_space α} (h : t ∈ tt) :\n  t ≤ Sup tt :=\nshow (⨅u∈tt, @uniformity α u) ≤ t.uniformity,\n  from infi_le_of_le t $ infi_le _ h\n\nprivate lemma Sup_le {tt : set (uniform_space α)} {t : uniform_space α} (h : ∀t'∈tt, t' ≤ t) :\n  Sup tt ≤ t :=\nshow t.uniformity ≤ (⨅u∈tt, @uniformity α u),\n  from le_infi $ assume t', le_infi $ assume ht', h t' ht'\n\ninstance : has_bot (uniform_space α) :=\n⟨uniform_space.of_core { uniformity := ⊤, refl := le_top, symm := le_top, comp := le_top }⟩\n\ninstance : has_top (uniform_space α) :=\n⟨{ to_topological_space := ⊤,\n  uniformity  := principal id_rel,\n  refl        := le_refl _,\n  symm        := by simp [tendsto]; apply subset.refl,\n  comp        :=\n  begin\n    rw [lift'_principal], {simp},\n    exact monotone_comp_rel monotone_id monotone_id\n  end,\n  is_open_uniformity :=\n    assume s, by simp [is_open_fold, subset_def, id_rel] {contextual := tt } } ⟩\n\ninstance : complete_lattice (uniform_space α) :=\n{ sup           := λa b, Sup {a, b},\n  le_sup_left   := assume a b, le_Sup $ by simp,\n  le_sup_right  := assume a b, le_Sup $ by simp,\n  sup_le        := assume a b c h₁ h₂, Sup_le $ assume t',\n    begin simp, intro h, cases h with h h, repeat { subst h; assumption } end,\n  inf           := λa b, Sup {x | x ≤ a ∧ x ≤ b},\n  le_inf        := assume a b c h₁ h₂, le_Sup ⟨h₁, h₂⟩,\n  inf_le_left   := assume a b, Sup_le $ assume x ⟨ha, hb⟩, ha,\n  inf_le_right  := assume a b, Sup_le $ assume x ⟨ha, hb⟩, hb,\n  top           := ⊤,\n  le_top        := assume u, u.refl,\n  bot           := ⊥,\n  bot_le        := assume a, show a.uniformity ≤ ⊤, from le_top,\n  Sup           := Sup,\n  le_Sup        := assume s u, le_Sup,\n  Sup_le        := assume s u, Sup_le,\n  Inf           := λtt, Sup {t | ∀t'∈tt, t ≤ t'},\n  le_Inf        := assume s a hs, le_Sup hs,\n  Inf_le        := assume s a ha, Sup_le $ assume u hs, hs _ ha,\n  ..uniform_space.partial_order }\n\nlemma supr_uniformity {ι : Sort*} {u : ι → uniform_space α} :\n  (supr u).uniformity = (⨅i, (u i).uniformity) :=\nshow (⨅a (h : ∃i:ι, u i = a), a.uniformity) = _, from\nle_antisymm\n  (le_infi $ assume i, infi_le_of_le (u i) $ infi_le _ ⟨i, rfl⟩)\n  (le_infi $ assume a, le_infi $ assume ⟨i, (ha : u i = a)⟩, ha ▸ infi_le _ _)\n\nlemma sup_uniformity {u v : uniform_space α} :\n  (u ⊔ v).uniformity = u.uniformity ⊓ v.uniformity :=\nhave (u ⊔ v) = (⨆i (h : i = u ∨ i = v), i), by simp [supr_or, supr_sup_eq],\ncalc (u ⊔ v).uniformity = ((⨆i (h : i = u ∨ i = v), i) : uniform_space α).uniformity : by rw [this]\n  ... = _ : by simp [supr_uniformity, infi_or, infi_inf_eq]\n\ninstance inhabited_uniform_space : inhabited (uniform_space α) := ⟨⊤⟩\n\n/-- Given `f : α → β` and a uniformity `u` on `β`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `α × α → β × β`. -/\ndef uniform_space.comap (f : α → β) (u : uniform_space β) : uniform_space α :=\n{ uniformity := u.uniformity.comap (λp:α×α, (f p.1, f p.2)),\n  to_topological_space := u.to_topological_space.induced f,\n  refl := le_trans (by simp; exact assume ⟨a, b⟩ (h : a = b), h ▸ rfl) (comap_mono u.refl),\n  symm := by simp [tendsto_comap_iff, prod.swap, (∘)]; exact tendsto_comap.comp tendsto_swap_uniformity,\n  comp := le_trans\n    begin\n      rw [comap_lift'_eq, comap_lift'_eq2],\n      exact (lift'_mono' $ assume s hs ⟨a₁, a₂⟩ ⟨x, h₁, h₂⟩, ⟨f x, h₁, h₂⟩),\n      repeat { exact monotone_comp_rel monotone_id monotone_id }\n    end\n    (comap_mono u.comp),\n  is_open_uniformity := λ s, begin\n    change (@is_open α (u.to_topological_space.induced f) s ↔ _),\n    simp [is_open_iff_nhds, nhds_induced_eq_comap, mem_nhds_uniformity_iff, filter.comap, and_comm],\n    refine ball_congr (λ x hx, ⟨_, _⟩),\n    { rintro ⟨t, hts, ht⟩, refine ⟨_, ht, _⟩,\n      rintro ⟨x₁, x₂⟩ h rfl, exact hts (h rfl) },\n    { rintro ⟨t, ht, hts⟩,\n      exact ⟨{y | (f x, y) ∈ t}, λ y hy, @hts (x, y) hy rfl,\n        mem_nhds_uniformity_iff.1 $ mem_nhds_left _ ht⟩ }\n  end }\n\nlemma uniform_space_comap_id {α : Type*} : uniform_space.comap (id : α → α) = id :=\nby ext u ; dsimp [uniform_space.comap] ; rw [prod.id_prod, filter.comap_id]\n\nlemma uniform_space.comap_comap_comp {α β γ} [uγ : uniform_space γ] {f : α → β} {g : β → γ} :\n  uniform_space.comap (g ∘ f) uγ = uniform_space.comap f (uniform_space.comap g uγ) :=\nby ext ; dsimp [uniform_space.comap] ; rw filter.comap_comap_comp\n\nlemma uniform_continuous_iff {α β} [uα : uniform_space α] [uβ : uniform_space β] (f : α → β) :\n  uniform_continuous f ↔ uβ.comap f ≤ uα :=\nfilter.map_le_iff_le_comap\n\nlemma uniform_continuous_comap {f : α → β} [u : uniform_space β] :\n  @uniform_continuous α β (uniform_space.comap f u) u f :=\ntendsto_comap\n\ntheorem to_topological_space_comap {f : α → β} {u : uniform_space β} :\n  @uniform_space.to_topological_space _ (uniform_space.comap f u) =\n  topological_space.induced f (@uniform_space.to_topological_space β u) :=\neq_of_nhds_eq_nhds $ assume a,\nbegin\n  simp [nhds_induced_eq_comap, nhds_eq_uniformity, nhds_eq_uniformity],\n  change comap f ((𝓤 β).lift' (preimage (λb, (f a, b)))) =\n      (u.uniformity.comap (λp:α×α, (f p.1, f p.2))).lift' (preimage (λa', (a, a'))),\n  rw [comap_lift'_eq monotone_preimage, comap_lift'_eq2 monotone_preimage],\n  exact rfl\nend\n\nlemma uniform_continuous_comap' {f : γ → β} {g : α → γ} [v : uniform_space β] [u : uniform_space α]\n  (h : uniform_continuous (f ∘ g)) : @uniform_continuous α γ u (uniform_space.comap f v) g :=\ntendsto_comap_iff.2 h\n\nlemma to_topological_space_mono {u₁ u₂ : uniform_space α} (h : u₁ ≤ u₂) :\n  @uniform_space.to_topological_space _ u₁ ≤ @uniform_space.to_topological_space _ u₂ :=\nle_of_nhds_le_nhds $ assume a,\n  by rw [@nhds_eq_uniformity α u₁ a, @nhds_eq_uniformity α u₂ a]; exact (lift'_mono h $ le_refl _)\n\nlemma to_topological_space_top : @uniform_space.to_topological_space α ⊤ = ⊤ := rfl\n\nlemma to_topological_space_bot : @uniform_space.to_topological_space α ⊥ = ⊥ :=\nbot_unique $ assume s hs, classical.by_cases\n  (assume : s = ∅, this.symm ▸ @is_open_empty _ ⊥)\n  (assume : s ≠ ∅,\n    let ⟨x, hx⟩ := exists_mem_of_ne_empty this in\n    have s = univ, from top_unique $ assume y hy, hs x hx (x, y) rfl,\n    this.symm ▸ @is_open_univ _ ⊥)\n\nlemma to_topological_space_supr {ι : Sort*} {u : ι → uniform_space α} :\n  @uniform_space.to_topological_space α (supr u) = (⨆i, @uniform_space.to_topological_space α (u i)) :=\nclassical.by_cases\n  (assume h : nonempty ι,\n    eq_of_nhds_eq_nhds $ assume a,\n    begin\n      rw [nhds_supr, nhds_eq_uniformity],\n      change _ = (supr u).uniformity.lift' (preimage $ prod.mk a),\n      begin\n        rw [supr_uniformity, lift'_infi],\n        exact (congr_arg _ $ funext $ assume i, @nhds_eq_uniformity α (u i) a),\n        exact h,\n        exact assume a b, rfl\n      end\n    end)\n  (assume : ¬ nonempty ι,\n    le_antisymm\n      (have supr u = ⊥, from bot_unique $ supr_le $ assume i, (this ⟨i⟩).elim,\n        have @uniform_space.to_topological_space _ (supr u) = ⊥,\n          from this.symm ▸ to_topological_space_bot,\n        this.symm ▸ bot_le)\n      (supr_le $ assume i, to_topological_space_mono $ le_supr _ _))\n\nlemma to_topological_space_Sup {s : set (uniform_space α)} :\n  @uniform_space.to_topological_space α (Sup s) = (⨆i∈s, @uniform_space.to_topological_space α i) :=\nbegin\n  rw [Sup_eq_supr, to_topological_space_supr],\n  apply congr rfl,\n  funext x,\n  exact to_topological_space_supr\nend\n\nlemma to_topological_space_sup {u v : uniform_space α} :\n  @uniform_space.to_topological_space α (u ⊔ v) =\n    @uniform_space.to_topological_space α u ⊔ @uniform_space.to_topological_space α v :=\nord_continuous_sup $ assume s, to_topological_space_Sup\n\ninstance : uniform_space empty := ⊤\ninstance : uniform_space unit := ⊤\ninstance : uniform_space bool := ⊤\ninstance : uniform_space ℕ := ⊤\ninstance : uniform_space ℤ := ⊤\n\ninstance {p : α → Prop} [t : uniform_space α] : uniform_space (subtype p) :=\nuniform_space.comap subtype.val t\n\nlemma uniformity_subtype {p : α → Prop} [t : uniform_space α] :\n  𝓤 (subtype p) = comap (λq:subtype p × subtype p, (q.1.1, q.2.1)) (𝓤 α) :=\nrfl\n\nlemma uniform_continuous_subtype_val {p : α → Prop} [uniform_space α] :\n  uniform_continuous (subtype.val : {a : α // p a} → α) :=\nuniform_continuous_comap\n\nlemma uniform_continuous_subtype_mk {p : α → Prop} [uniform_space α] [uniform_space β]\n  {f : β → α} (hf : uniform_continuous f) (h : ∀x, p (f x)) :\n  uniform_continuous (λx, ⟨f x, h x⟩ : β → subtype p) :=\nuniform_continuous_comap' hf\n\nlemma tendsto_of_uniform_continuous_subtype\n  [uniform_space α] [uniform_space β] {f : α → β} {s : set α} {a : α}\n  (hf : uniform_continuous (λx:s, f x.val)) (ha : s ∈ nhds a) :\n  tendsto f (nhds a) (nhds (f a)) :=\nby rw [(@map_nhds_subtype_val_eq α _ s a (mem_of_nhds ha) ha).symm]; exact\ntendsto_map' (continuous_iff_continuous_at.mp hf.continuous _)\n\n\nsection prod\n\n/- a similar product space is possible on the function space (uniformity of pointwise convergence),\n  but we want to have the uniformity of uniform convergence on function spaces -/\ninstance [u₁ : uniform_space α] [u₂ : uniform_space β] : uniform_space (α × β) :=\nuniform_space.of_core_eq\n  (u₁.comap prod.fst ⊔ u₂.comap prod.snd).to_core\n  prod.topological_space\n  (calc prod.topological_space = (u₁.comap prod.fst ⊔ u₂.comap prod.snd).to_topological_space :\n      by rw [to_topological_space_sup, to_topological_space_comap, to_topological_space_comap]; refl\n    ... = _ : by rw [uniform_space.to_core_to_topological_space])\n\ntheorem uniformity_prod [uniform_space α] [uniform_space β] : @uniformity (α × β) _ =\n  (𝓤 α).comap (λp:(α × β) × α × β, (p.1.1, p.2.1)) ⊓\n  (𝓤 β).comap (λp:(α × β) × α × β, (p.1.2, p.2.2)) :=\nsup_uniformity\n\nlemma uniformity_prod_eq_prod [uniform_space α] [uniform_space β] :\n  𝓤 (α×β) =\n    map (λp:(α×α)×(β×β), ((p.1.1, p.2.1), (p.1.2, p.2.2))) (filter.prod (𝓤 α) (𝓤 β)) :=\nhave map (λp:(α×α)×(β×β), ((p.1.1, p.2.1), (p.1.2, p.2.2))) =\n  comap (λp:(α×β)×(α×β), ((p.1.1, p.2.1), (p.1.2, p.2.2))),\n  from funext $ assume f, map_eq_comap_of_inverse\n    (funext $ assume ⟨⟨_, _⟩, ⟨_, _⟩⟩, rfl) (funext $ assume ⟨⟨_, _⟩, ⟨_, _⟩⟩, rfl),\nby rw [this, uniformity_prod, filter.prod, comap_inf, comap_comap_comp, comap_comap_comp]\n\nlemma mem_map_sets_iff' {α : Type*} {β : Type*} {f : filter α} {m : α → β} {t : set β} :\n  t ∈ (map m f).sets ↔ (∃s∈f, m '' s ⊆ t) :=\nmem_map_sets_iff\n\nlemma mem_uniformity_of_uniform_continuous_invarant [uniform_space α] {s:set (α×α)} {f : α → α → α}\n  (hf : uniform_continuous (λp:α×α, f p.1 p.2)) (hs : s ∈ 𝓤 α) :\n  ∃u∈𝓤 α, ∀a b c, (a, b) ∈ u → (f a c, f b c) ∈ s :=\nbegin\n  rw [uniform_continuous, uniformity_prod_eq_prod, tendsto_map'_iff, (∘)] at hf,\n  rcases mem_map_sets_iff'.1 (hf hs) with ⟨t, ht, hts⟩, clear hf,\n  rcases mem_prod_iff.1 ht with ⟨u, hu, v, hv, huvt⟩, clear ht,\n  refine ⟨u, hu, assume a b c hab, hts $ (mem_image _ _ _).2 ⟨⟨⟨a, b⟩, ⟨c, c⟩⟩, huvt ⟨_, _⟩, _⟩⟩,\n  exact hab,\n  exact refl_mem_uniformity hv,\n  refl\nend\n\nlemma mem_uniform_prod [t₁ : uniform_space α] [t₂ : uniform_space β] {a : set (α × α)} {b : set (β × β)}\n  (ha : a ∈ 𝓤 α) (hb : b ∈ 𝓤 β) :\n  {p:(α×β)×(α×β) | (p.1.1, p.2.1) ∈ a ∧ (p.1.2, p.2.2) ∈ b } ∈ (@uniformity (α × β) _) :=\nby rw [uniformity_prod]; exact inter_mem_inf_sets (preimage_mem_comap ha) (preimage_mem_comap hb)\n\nlemma tendsto_prod_uniformity_fst [uniform_space α] [uniform_space β] :\n  tendsto (λp:(α×β)×(α×β), (p.1.1, p.2.1)) (𝓤 (α × β)) (𝓤 α) :=\nle_trans (map_mono (@le_sup_left (uniform_space (α×β)) _ _ _)) map_comap_le\n\nlemma tendsto_prod_uniformity_snd [uniform_space α] [uniform_space β] :\n  tendsto (λp:(α×β)×(α×β), (p.1.2, p.2.2)) (𝓤 (α × β)) (𝓤 β) :=\nle_trans (map_mono (@le_sup_right (uniform_space (α×β)) _ _ _)) map_comap_le\n\nlemma uniform_continuous_fst [uniform_space α] [uniform_space β] : uniform_continuous (λp:α×β, p.1) :=\ntendsto_prod_uniformity_fst\n\nlemma uniform_continuous_snd [uniform_space α] [uniform_space β] : uniform_continuous (λp:α×β, p.2) :=\ntendsto_prod_uniformity_snd\n\nvariables [uniform_space α] [uniform_space β] [uniform_space γ]\nlemma uniform_continuous.prod_mk\n  {f₁ : α → β} {f₂ : α → γ} (h₁ : uniform_continuous f₁) (h₂ : uniform_continuous f₂) :\n  uniform_continuous (λa, (f₁ a, f₂ a)) :=\nby rw [uniform_continuous, uniformity_prod]; exact\ntendsto_inf.2 ⟨tendsto_comap_iff.2 h₁, tendsto_comap_iff.2 h₂⟩\n\nlemma uniform_continuous.prod_mk_left {f : α × β → γ} (h : uniform_continuous f) (b) :\n  uniform_continuous (λ a, f (a,b)) :=\n(uniform_continuous_id.prod_mk uniform_continuous_const).comp h\n\nlemma uniform_continuous.prod_mk_right {f : α × β → γ} (h : uniform_continuous f) (a) :\n  uniform_continuous (λ b, f (a,b)) :=\n(uniform_continuous_const.prod_mk  uniform_continuous_id).comp h\n\nlemma to_topological_space_prod [u : uniform_space α] [v : uniform_space β] :\n  @uniform_space.to_topological_space (α × β) prod.uniform_space =\n    @prod.topological_space α β u.to_topological_space v.to_topological_space := rfl\n\nend prod\n\nlemma to_topological_space_subtype [u : uniform_space α] {p : α → Prop} :\n  @uniform_space.to_topological_space (subtype p) subtype.uniform_space =\n    @subtype.topological_space α p u.to_topological_space := rfl\n\nsection sum\nvariables [uniform_space α] [uniform_space β]\nopen sum\n\n/-- Uniformity on a disjoint union. Entourages of the diagonal in the union are obtained\nby taking independently an entourage of the diagonal in the first part, and an entourage of\nthe diagonal in the second part. -/\ndef uniform_space.core.sum : uniform_space.core (α ⊕ β) :=\nuniform_space.core.mk'\n  (map (λ p : α × α, (inl p.1, inl p.2)) (𝓤 α) ⊔ map (λ p : β × β, (inr p.1, inr p.2)) (𝓤 β))\n  (λ r ⟨H₁, H₂⟩ x, by cases x; [apply refl_mem_uniformity H₁, apply refl_mem_uniformity H₂])\n  (λ r ⟨H₁, H₂⟩, ⟨symm_le_uniformity H₁, symm_le_uniformity H₂⟩)\n  (λ r ⟨Hrα, Hrβ⟩, begin\n    rcases comp_mem_uniformity_sets Hrα with ⟨tα, htα, Htα⟩,\n    rcases comp_mem_uniformity_sets Hrβ with ⟨tβ, htβ, Htβ⟩,\n    refine ⟨_,\n      ⟨mem_map_sets_iff.2 ⟨tα, htα, subset_union_left _ _⟩,\n       mem_map_sets_iff.2 ⟨tβ, htβ, subset_union_right _ _⟩⟩, _⟩,\n    rintros ⟨_, _⟩ ⟨z, ⟨⟨a, b⟩, hab, ⟨⟩⟩ | ⟨⟨a, b⟩, hab, ⟨⟩⟩,\n                       ⟨⟨_, c⟩, hbc, ⟨⟩⟩ | ⟨⟨_, c⟩, hbc, ⟨⟩⟩⟩,\n    { have A : (a, c) ∈ comp_rel tα tα := ⟨b, hab, hbc⟩,\n      exact Htα A },\n    { have A : (a, c) ∈ comp_rel tβ tβ := ⟨b, hab, hbc⟩,\n      exact Htβ A }\n  end)\n\n/-- The union of an entourage of the diagonal in each set of a disjoint union is again an entourage of the diagonal. -/\nlemma union_mem_uniformity_sum\n  {a : set (α × α)} (ha : a ∈ 𝓤 α) {b : set (β × β)} (hb : b ∈ 𝓤 β) :\n  ((λ p : (α × α), (inl p.1, inl p.2)) '' a ∪ (λ p : (β × β), (inr p.1, inr p.2)) '' b) ∈ (@uniform_space.core.sum α β _ _).uniformity :=\n⟨mem_map_sets_iff.2 ⟨_, ha, subset_union_left _ _⟩, mem_map_sets_iff.2 ⟨_, hb, subset_union_right _ _⟩⟩\n\n/- To prove that the topology defined by the uniform structure on the disjoint union coincides with\nthe disjoint union topology, we need two lemmas saying that open sets can be characterized by\nthe uniform structure -/\nlemma uniformity_sum_of_open_aux {s : set (α ⊕ β)} (hs : is_open s) {x : α ⊕ β} (xs : x ∈ s) :\n  { p : ((α ⊕ β) × (α ⊕ β)) | p.1 = x → p.2 ∈ s } ∈ (@uniform_space.core.sum α β _ _).uniformity :=\nbegin\n  cases x,\n  { refine mem_sets_of_superset\n      (union_mem_uniformity_sum (mem_nhds_uniformity_iff.1 (mem_nhds_sets hs.1 xs)) univ_mem_sets)\n      (union_subset _ _);\n    rintro _ ⟨⟨_, b⟩, h, ⟨⟩⟩ ⟨⟩,\n    exact h rfl },\n  { refine mem_sets_of_superset\n      (union_mem_uniformity_sum univ_mem_sets (mem_nhds_uniformity_iff.1 (mem_nhds_sets hs.2 xs)))\n      (union_subset _ _);\n    rintro _ ⟨⟨a, _⟩, h, ⟨⟩⟩ ⟨⟩,\n    exact h rfl },\nend\n\nlemma open_of_uniformity_sum_aux {s : set (α ⊕ β)}\n  (hs : ∀x ∈ s, { p : ((α ⊕ β) × (α ⊕ β)) | p.1 = x → p.2 ∈ s } ∈ (@uniform_space.core.sum α β _ _).uniformity) :\n  is_open s :=\nbegin\n  split,\n  { refine (@is_open_iff_mem_nhds α _ _).2 (λ a ha, mem_nhds_uniformity_iff.2 _),\n    rcases mem_map_sets_iff.1 (hs _ ha).1 with ⟨t, ht, st⟩,\n    refine mem_sets_of_superset ht _,\n    rintro p pt rfl, exact st ⟨_, pt, rfl⟩ rfl },\n  { refine (@is_open_iff_mem_nhds β _ _).2 (λ b hb, mem_nhds_uniformity_iff.2 _),\n    rcases mem_map_sets_iff.1 (hs _ hb).2 with ⟨t, ht, st⟩,\n    refine mem_sets_of_superset ht _,\n    rintro p pt rfl, exact st ⟨_, pt, rfl⟩ rfl }\nend\n\n/- We can now define the uniform structure on the disjoint union -/\ninstance sum.uniform_space [u₁ : uniform_space α] [u₂ : uniform_space β] : uniform_space (α ⊕ β) :=\n{ to_core := uniform_space.core.sum,\n  is_open_uniformity := λ s, ⟨uniformity_sum_of_open_aux, open_of_uniformity_sum_aux⟩ }\n\nlemma sum.uniformity [uniform_space α] [uniform_space β] :\n  𝓤 (α ⊕ β) =\n    map (λ p : α × α, (inl p.1, inl p.2)) (𝓤 α) ⊔\n    map (λ p : β × β, (inr p.1, inr p.2)) (𝓤 β) := rfl\n\nend sum\n\nend constructions\n\nlemma lebesgue_number_lemma {α : Type u} [uniform_space α] {s : set α} {ι} {c : ι → set α}\n  (hs : compact s) (hc₁ : ∀ i, is_open (c i)) (hc₂ : s ⊆ ⋃ i, c i) :\n  ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ i, {y | (x, y) ∈ n} ⊆ c i :=\nbegin\n  let u := λ n, {x | ∃ i (m ∈ 𝓤 α), {y | (x, y) ∈ comp_rel m n} ⊆ c i},\n  have hu₁ : ∀ n ∈ 𝓤 α, is_open (u n),\n  { refine λ n hn, is_open_uniformity.2 _,\n    rintro x ⟨i, m, hm, h⟩,\n    rcases comp_mem_uniformity_sets hm with ⟨m', hm', mm'⟩,\n    apply (𝓤 α).sets_of_superset hm',\n    rintros ⟨x, y⟩ hp rfl,\n    refine ⟨i, m', hm', λ z hz, h (monotone_comp_rel monotone_id monotone_const mm' _)⟩,\n    dsimp at hz ⊢, rw comp_rel_assoc,\n    exact ⟨y, hp, hz⟩ },\n  have hu₂ : s ⊆ ⋃ n ∈ 𝓤 α, u n,\n  { intros x hx,\n    rcases mem_Union.1 (hc₂ hx) with ⟨i, h⟩,\n    rcases comp_mem_uniformity_sets (is_open_uniformity.1 (hc₁ i) x h) with ⟨m', hm', mm'⟩,\n    exact mem_bUnion hm' ⟨i, _, hm', λ y hy, mm' hy rfl⟩ },\n  rcases compact_elim_finite_subcover_image hs hu₁ hu₂ with ⟨b, bu, b_fin, b_cover⟩,\n  refine ⟨_, Inter_mem_sets b_fin bu, λ x hx, _⟩,\n  rcases mem_bUnion_iff.1 (b_cover hx) with ⟨n, bn, i, m, hm, h⟩,\n  refine ⟨i, λ y hy, h _⟩,\n  exact prod_mk_mem_comp_rel (refl_mem_uniformity hm) (bInter_subset_of_mem bn hy)\nend\n\nlemma lebesgue_number_lemma_sUnion {α : Type u} [uniform_space α] {s : set α} {c : set (set α)}\n  (hs : compact s) (hc₁ : ∀ t ∈ c, is_open t) (hc₂ : s ⊆ ⋃₀ c) :\n  ∃ n ∈ 𝓤 α, ∀ x ∈ s, ∃ t ∈ c, ∀ y, (x, y) ∈ n → y ∈ t :=\nby rw sUnion_eq_Union at hc₂;\n   simpa using lebesgue_number_lemma hs (by simpa) hc₂\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/topology/uniform_space/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.4565601015152037}}
{"text": "import linear_algebra.matrix.pos_def\n\nnamespace finset\nvariables {M ι : Type*} [ordered_cancel_comm_monoid M] {f g : ι → M} {s t : finset ι}\nopen_locale big_operators\n\n--TODO: move\n@[to_additive sum_pos'] lemma one_lt_prod' (Hle : ∀ i ∈ s, 1 ≤ f i) (Hlt : ∃ i ∈ s, 1 < f i) :\n  1 < (∏ i in s, f i) :=\nlt_of_le_of_lt (by rw prod_const_one) $ prod_lt_prod' Hle Hlt\n\nend finset\n\nnamespace matrix\nvariables {𝕜 : Type*} [is_R_or_C 𝕜] {m n : Type*} [fintype m] [fintype n]\nopen_locale matrix\n\n/-- A matrix `M : matrix n n 𝕜` is positive semidefinite if it is hermitian\n   and `xᴴMx` is nonnegative for all `x`. -/\ndef pos_semidef (M : matrix n n 𝕜) :=\nM.is_hermitian ∧ ∀ x : n → 𝕜, 0 ≤ is_R_or_C.re (dot_product (star x) (M.mul_vec x))\n\nlemma pos_def.pos_semidef {M : matrix n n 𝕜} (hM : M.pos_def) : M.pos_semidef :=\nbegin\n  refine ⟨hM.1, _⟩,\n  intros x,\n  by_cases hx : x = 0,\n  { simp only [hx, zero_dot_product, star_zero, is_R_or_C.zero_re'] },\n  { exact le_of_lt (hM.2 x hx) }\nend\n\nlemma pos_semidef.is_hermitian {M : matrix n n 𝕜} (hM : M.pos_semidef) : M.is_hermitian := hM.1\n\nlemma pos_semidef.transpose {M : matrix n n 𝕜} (hM : M.pos_semidef) : Mᵀ.pos_semidef :=\nbegin\n  refine ⟨is_hermitian.transpose hM.1, λ x, _⟩,\n  convert hM.2 (star x) using 2,\n  rw [mul_vec_transpose, matrix.dot_product_mul_vec, star_star, dot_product_comm]\nend\n\nlemma pos_semidef_diagonal [decidable_eq n] {f : n → ℝ} (hf : ∀ i, 0 ≤ f i) :\n  (diagonal f).pos_semidef :=\nbegin\n  refine ⟨is_hermitian_diagonal _, _⟩,\n  intro x,\n  simp only [star, id.def, is_R_or_C.re_to_real],\n  apply finset.sum_nonneg',\n  intro i,\n  rw [mul_vec_diagonal f x i, mul_comm, mul_assoc],\n  exact mul_nonneg (hf i) (mul_self_nonneg (x i))\nend\n\nlemma pos_def_diagonal [decidable_eq n] {f : n → ℝ} (hf : ∀ i, 0 < f i) :\n  (diagonal f).pos_def :=\nbegin\n  refine ⟨is_hermitian_diagonal _, _⟩,\n  intros x hx,\n  simp only [star, id.def, is_R_or_C.re_to_real],\n  apply finset.sum_pos',\n  { intros i _,\n    rw [mul_vec_diagonal f x i, mul_comm, mul_assoc],\n    exact mul_nonneg (le_of_lt (hf i)) (mul_self_nonneg (x i)) },\n  { contrapose! hx,\n    ext i,\n    have := hx i (finset.mem_univ _),\n    rw [mul_vec_diagonal f x i, mul_comm, mul_assoc] at this,\n    have := nonpos_of_mul_nonpos_right this (hf i),\n    rw mul_self_eq_zero.1 (le_antisymm this (mul_self_nonneg (x i))),\n    refl }\nend\n\n-- instance : nontrivial 𝕜 := by apply_instance--infinite.nontrivial 𝕜\ninstance : is_domain 𝕜 := by apply_instance\n\n\n-- Replace? seems to have fewer assumptions than `eq_zero_of_mul_vec_eq_zero`\nlemma eq_zero_of_mul_vec_eq_zero' {R : Type*} [comm_ring R] [decidable_eq n]\n  {M : matrix n n R} (hM : is_unit M.det) (x : n → R) (h : M.mul_vec x = 0) : x = 0 :=\ncalc\n  x = (M⁻¹ ⬝ M).mul_vec x : by rw [nonsing_inv_mul M hM, one_mul_vec]\n  ... = 0 : by rw [← mul_vec_mul_vec, h, mul_vec_zero]\n\nlemma pos_def.det_ne_zero [decidable_eq n] {M : matrix n n 𝕜} (hM : M.pos_def) : M.det ≠ 0 :=\nbegin\n  rw ← matrix.nondegenerate_iff_det_ne_zero,\n  intros v hv,\n  have hv' := hv (star v),\n  rw [← star_eq_zero],\n  by_contra h,\n  have := hM.2 (star v) h,\n  rw [star_star, hv'] at this,\n  simpa using this,\nend\n\nlemma is_hermitian.nonsingular_inv [decidable_eq n] {M : matrix n n 𝕜}\n  (hM : M.is_hermitian) (hMdet : is_unit M.det):\n  M⁻¹.is_hermitian :=\nbegin\n  refine (matrix.inv_eq_right_inv _).symm,\n  rw [conj_transpose_nonsing_inv, hM.eq, mul_nonsing_inv _ hMdet]\nend\n\nlemma pos_def.nonsingular_inv [decidable_eq n] {M : matrix n n 𝕜} (hM : M.pos_def) :\n  M⁻¹.pos_def :=\nbegin\n  refine ⟨is_hermitian.nonsingular_inv hM.1 (is_unit_iff_ne_zero.2 hM.det_ne_zero), _⟩,\n  intros x hx,\n  have hMMinv := (mul_nonsing_inv _ (is_unit_iff_ne_zero.2 hM.det_ne_zero)),\n  have hMinvdet : M⁻¹.det ≠ 0 := det_ne_zero_of_left_inverse hMMinv,\n  have := hM.2 (M⁻¹.mul_vec x) (λ h, hx (eq_zero_of_mul_vec_eq_zero hMinvdet h)),\n  rw [mul_vec_mul_vec, hMMinv, one_mul_vec, star_dot_product] at this,\n  rw [← is_R_or_C.conj_re],\n  exact this\nend\n\n-- TODO: move\nlemma is_hermitian.conj_transpose_mul_mul (M N : matrix n n 𝕜) (hM : M.is_hermitian) :\n  (Nᴴ ⬝ M ⬝ N).is_hermitian :=\nby simp [is_hermitian, hM.eq, matrix.mul_assoc]\n\nlemma pos_def.conj_transpose_mul_mul [decidable_eq n]\n    (M N : matrix n n 𝕜) (hM : M.pos_def) (hN : N.det ≠ 0):\n  (Nᴴ ⬝ M ⬝ N).pos_def :=\nbegin\n  refine ⟨hM.1.conj_transpose_mul_mul M N, _⟩,\n  intros x hx,\n  convert hM.2 (N.mul_vec x) (λ h, hx (eq_zero_of_mul_vec_eq_zero hN h)) using 2,\n  rw [matrix.mul_assoc, mul_vec_mul_vec, ←mul_vec_mul_vec, dot_product_mul_vec, star_mul_vec]\nend\n\nlemma pos_semidef.conj_transpose_mul_mul (M N : matrix n n 𝕜) (hM : M.pos_semidef) :\n  (Nᴴ ⬝ M ⬝ N).pos_semidef :=\nbegin\n  refine ⟨hM.1.conj_transpose_mul_mul M N, _⟩,\n  intro x,\n  convert hM.2 (N.mul_vec x) using 2,\n  rw [matrix.mul_assoc, mul_vec_mul_vec, ←mul_vec_mul_vec, dot_product_mul_vec, star_mul_vec]\nend\n\nlemma pos_semidef.mul_mul_of_is_hermitian {M N : matrix n n 𝕜}\n    (hM : M.pos_semidef) (hN : N.is_hermitian) :\n  (N ⬝ M ⬝ N).pos_semidef :=\nby { convert hM.conj_transpose_mul_mul M N, exact hN.symm }\n\nlemma pos_semidef.submatrix {M : matrix n n 𝕜} (hM : M.pos_semidef) (e : m ≃ n):\n  (M.submatrix e e).pos_semidef :=\nbegin\n  refine ⟨hM.1.submatrix e, λ x, _⟩,\n  have : (M.submatrix ⇑e ⇑e).mul_vec x = M.mul_vec (λ (i : n), x (e.symm i)) ∘ e,\n  { ext i,\n    dsimp only [(∘), mul_vec, dot_product],\n    rw finset.sum_bij' (λ i _, e i) _ _ (λ i _, e.symm i);\n    simp only [eq_self_iff_true, implies_true_iff, equiv.symm_apply_apply, finset.mem_univ,\n      submatrix_apply, equiv.apply_symm_apply] },\n  rw this,\n  convert hM.2 (λ i, x (e.symm i)) using 3,\n  unfold dot_product,\n  rw [finset.sum_bij' (λ i _, e i) _ _ (λ i _, e.symm i)];\n  simp only [eq_self_iff_true, implies_true_iff, equiv.symm_apply_apply, finset.mem_univ,\n    submatrix_apply, equiv.apply_symm_apply, pi.star_apply],\nend\n\n@[simp] lemma pos_semidef_submatrix_equiv {M : matrix n n 𝕜} (e : m ≃ n) :\n  (M.submatrix e e).pos_semidef ↔ M.pos_semidef :=\n⟨λ h, by simpa using h.submatrix e.symm, λ h, h.submatrix _⟩\n\nlemma pos_semidef.add {M N: matrix n n 𝕜} (hM : M.pos_semidef) (hN : N.pos_semidef) :\n  (M + N).pos_semidef :=\nbegin\n  refine ⟨hM.1.add hN.1, λ x, _⟩,\n  simp only [add_mul_vec, dot_product_add, map_add],\n  apply add_nonneg (hM.2 x) (hN.2 x)\nend\n\nnamespace pos_def\n\nvariables {M : matrix n n ℝ} (hM : M.pos_def)\ninclude hM\n\n--TODO: use in `det_pos`\nlemma eigenvalues_pos [decidable_eq n] (i : n) : 0 < hM.1.eigenvalues i :=\nbegin\n  rw hM.is_hermitian.eigenvalues_eq,\n  apply hM.2 _ (λ h, _),\n  have h_det : (hM.is_hermitian.eigenvector_matrix)ᵀ.det = 0,\n    from matrix.det_eq_zero_of_row_eq_zero i (λ j, congr_fun h j),\n  simpa only [h_det, not_is_unit_zero] using\n    is_unit_det_of_invertible hM.is_hermitian.eigenvector_matrixᵀ,\nend\n\nnoncomputable instance [decidable_eq n] : invertible M :=\ninvertible_of_is_unit_det M (is_unit_iff_ne_zero.2 hM.det_ne_zero)\n\nlemma is_unit_det [decidable_eq n]\n  {M : matrix n n ℝ} (hM : M.pos_def) : is_unit M.det :=\nis_unit_iff_ne_zero.2 hM.det_ne_zero\n\nend pos_def\n\nlemma is_unit_det_of_pos_def_inv [decidable_eq n]\n  {M : matrix n n ℝ} (h : M⁻¹.pos_def) :\n  is_unit M.det :=\nbegin\n  apply is_unit_iff_ne_zero.2,\n  have := h.is_unit_det,\n  rw [det_nonsing_inv, is_unit_ring_inverse] at this,\n  apply is_unit.ne_zero this,\nend\n\nlemma posdef_inv_iff_posdef [decidable_eq n]\n  (M : matrix n n ℝ) : M⁻¹.pos_def ↔ M.pos_def :=\nbegin\n  refine ⟨λ hM, _, λ hM, hM.nonsingular_inv⟩,\n  rw ← matrix.nonsing_inv_nonsing_inv M (is_unit_det_of_pos_def_inv hM),\n  apply hM.nonsingular_inv\nend\n\nnamespace pos_semidef\n\nvariables {M : matrix n n ℝ} (hM : M.pos_semidef)\ninclude hM\n\nlemma eigenvalues_nonneg [decidable_eq n] (i : n) : 0 ≤ hM.1.eigenvalues i :=\nby {rw hM.is_hermitian.eigenvalues_eq, apply hM.2}\n\nlemma det_nonneg [decidable_eq n] : 0 ≤ det M :=\nbegin\n  rw [hM.1.det_eq_prod_eigenvalues],\n  apply finset.prod_nonneg (λ i hi, _),\n  apply eigenvalues_nonneg,\nend\n\nend pos_semidef\n\nend matrix\n", "meta": {"author": "verified-optimization", "repo": "optlib", "sha": "b5d69678be5a4be8284ed15d376d6d973c64ea72", "save_path": "github-repos/lean/verified-optimization-optlib", "path": "github-repos/lean/verified-optimization-optlib/optlib-b5d69678be5a4be8284ed15d376d6d973c64ea72/src/missing/linear_algebra/matrix/pos_def.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.45656009719612706}}
{"text": "example (u w x y z : ℕ) (h₁ : x = y + z) (h₂ : w = u + x) :\n  w = z + y + u :=\n  by simp [add_comm, *]\n-- lean 3.6 removes simp attributes from add_comm\n-- i.e., now it is required to provide that lemma to solve this example.\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch5/ex0710.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6688802537704064, "lm_q1q2_score": 0.45656009269072934}}
{"text": "import LeanExt\n\nnamespace Day2\n\ninductive RPS where | rock | paper | scissors\nderiving Inhabited, BEq\n\ndef RPS.next : RPS → RPS\n  | rock => paper\n  | paper => scissors\n  | scissors => rock\n\ndef RPS.prev : RPS → RPS := next ∘ next\n\ntheorem RPS.next_eq (rps:RPS) : rps = rps.next.next.next := by\n  cases rps <;> simp [next]\n\ntheorem RPS.next_eq_prev (rps:RPS) : rps.next = rps.prev.prev := by\n  cases rps <;> simp [prev, next]\n\ndef RPS.points : RPS → Nat\n  | rock => 1\n  | paper => 2\n  | scissors => 3\n\ninductive Result where | lose | draw | win\nderiving Inhabited\n\nopen RPS in\ndef Result.of (l r:RPS) : Result :=\n  if l == r then draw\n  else if l.next == r then win\n  else lose\n\nopen RPS in open Result in\ndef Result.to (l:RPS) : Result → RPS\n  | lose => l.prev\n  | draw => l\n  | win => l.next\n\ndef Result.points : Result → Nat\n  | lose => 0\n  | draw => 3\n  | win => 6\n\nnamespace Parse\n  def rps! : String → RPS\n    | \"A\" | \"X\" => RPS.rock\n    | \"B\" | \"Y\" => RPS.paper\n    | \"C\" | \"Z\" => RPS.scissors\n    | _ => panic! \"invalid input [they]\"\n\n  def result! : String → Result\n    | \"X\" => Result.lose\n    | \"Y\" => Result.draw\n    | \"Z\" => Result.win\n    | _ => panic! \"invalid input [they]\"\n\n  def input! [Inhabited α] [Inhabited β] (fLeft:String → α) (fRight:String → β) (ls:List String) : List (α × β) :=\n    ls\n    |>.map (fun l => l.split (' ' == ·))\n    |>.map (fun ls =>\n      match ls with\n      | [sLeft, sRight] => (fLeft sLeft, fRight sRight)\n      | _ => panic! \"invalid input\"\n    )\n\n  def input1! (ls:List String) := input! rps! rps! ls\n\n  def input2! (ls:List String) := input! rps! result! ls\nend Parse\n\ndef score (mrs:List (RPS × Result)) :Nat :=\n  mrs\n  |>.map (fun (me, result) => me.points + result.points)\n  |>.sum\n\ndef part1 (ls:List String) :=\n  ls\n  |> Parse.input1!\n  |>.map (fun (they, me) =>\n      let result := Result.of they me\n      (me, result)\n  )\n  |> score\n\ndef part2 (ls:List String) :=\n  ls\n  |> Parse.input2!\n  |>.map (fun (they, result) =>\n    let me := result.to they\n    (me, result)\n  )\n  |> score\n\ndef testInput :=\n  [ \"A Y\"\n  , \"B X\"\n  , \"C Z\"\n  ]\n#eval 15 <== part1 testInput\n#eval 12 <== part2 testInput\n\nend Day2", "meta": {"author": "JanWosnitza", "repo": "advent-of-code-2022", "sha": "05caceb26df7b17c5d52772d36cfe58e82d92ef6", "save_path": "github-repos/lean/JanWosnitza-advent-of-code-2022", "path": "github-repos/lean/JanWosnitza-advent-of-code-2022/advent-of-code-2022-05caceb26df7b17c5d52772d36cfe58e82d92ef6/src/Days/Day2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737344123242, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.4565600926907293}}
{"text": "import tactic.induction\nimport data.stream.init\nimport .A_lists\n\nset_option pp.generalized_field_notation false\n\n/-\n# 3. Streams\nWe'll prove CPS equivalences for a variety of non-CPS and CPS functions over CPS\nstreams (i.e., streams that are themselves implemented as a CPS type).\n\nWe require that all stream functions be *maximally lazy*; that is, that they\nperform no computation until it is necessary to produce a requested value.\n-/\n\n/- ## 3.1. The `stream_cps` Type\nDue to the nature of streams (and Lean's current lack of support for coinductive\ntypes over non-Prop universes), we can do something a little different here:\nrather than re-write our *functions* to be in CPS, we can rewrite our *type* to\nbe a CPS type. In this section, the functions are actually in direct style;\nwe'll deal with the CPS-on-CPS case in §3.2. For the meantime, we're interested\nin proving that a CPS *representation* of our data is equivalent to a non-CPS\nrepresentation. Even this was deceptively tricky to get right!\n-/\n\n-- ### 3.1.1. Basic Stream Operations\n-- We begin by defining a type of CPS streams and a few basic operations\n-- thereupon\ndef stream_cps (α : Type _) {β : Type _} := ℕ → (α → β) → β\n\ndef stream_cps.expose {α β : Type _} (s : stream_cps α) (k : α → β) : β := s 0 k\n\ndef stream_cps.const {α β : Type _} (x : α) : stream_cps α :=\n  (λ (n : ℕ) (k' : α → β), k' x)\n\ndef stream_cps.cons {α β : Type _} (x : α) (s : stream_cps α) : stream_cps α :=\n  (λ (n : ℕ) (k' : α → β),\n    match n with\n    | 0 := k' x\n    | nat.succ n := s n k'\n    end)\n\ndef stream_cps.drop {α β : Type _} (n : ℕ) (s : stream_cps α) : stream_cps α :=\n  λ (n' : ℕ) (k' : α → β), s (n' + n) k'\n\n-- ### 3.1.2. Basic Stream Equivalences\n-- We define a notion of equivalence between a CPS stream and a regular stream\n-- (since we don't have formal coinduction in Lean)\ndef stream_equiv {α β : Type _} (s_cps : stream_cps α) (s : stream α) :=\n  ∀(n : ℕ) (k : α → β), k (s n) = s_cps n k\n\n-- Now, we use that equivalence to prove various equivalences between the\n-- primitive CPS and non-CPS functions:\nlemma const_cps_equiv_const {β : Type _} :\n  @stream_equiv ℕ β (stream_cps.const 2) (stream.const 2) :=\nλ _ _, rfl\n\nlemma cons_cps_equiv_cons {α β : Type _} :\n  ∀ (s_cps : @stream_cps α β) (s : stream α) (x : α),\n  stream_equiv s_cps s ↔\n    stream_equiv (stream_cps.cons x s_cps) (stream.cons x s) :=\nbegin\n  intros s_cps s x,\n  apply iff.intro,\n  {\n    intros h_equiv n k,\n    rw [stream_cps.cons, stream.cons],\n    dsimp only,\n    cases' n,\n    { refl, },\n    {\n      rw [stream_cps.cons._match_1, stream.cons._match_1],\n      exact h_equiv n k,\n    }\n  },\n  {\n    intros h_equiv n k,\n    rw [stream_cps.cons, stream.cons] at h_equiv,\n    have h_e_inst := h_equiv (nat.succ n) k,\n    dsimp only at h_e_inst,\n    rw [stream.cons._match_1, stream_cps.cons._match_1] at h_e_inst,\n    exact h_e_inst,\n  }\nend\n\nlemma drop_cps_equiv_drop {α β : Type _} :\n  ∀ (s_cps : @stream_cps α β) (s : stream α) (n : ℕ),\n    stream_equiv s_cps s →\n      stream_equiv (stream_cps.drop n s_cps) (stream.drop n s) :=\nbegin\n  intros s_cps s n,\n  {\n    intros h_equiv n' k',\n    rw [stream_cps.drop, stream.drop],\n    dsimp only,\n    exact h_equiv (n' + n) k',\n  }\nend\n\n-- Note that the `drop` lemma, unlike `cons_cps_equiv_cons`, isn't biconditional\n-- We provide the following counterexample (let \"C<...>\" denote a CPS stream and\n-- ≡ the CPS/non-CPS stream equivalence relation):\n-- C<4, 3, 3, ...> ≢ <2, 3, 3, ...> even though\n-- (drop_cps 1 C<4, 3, 3, ...>) ≡ <3, 3, ...> = (drop 1 <2, 3, 3, ...>)\nlemma drop_equiv_not_bicond :\n  ¬(∀ (α β : Type _) (s_cps : @stream_cps α β) (s : stream α) (n : ℕ),\n    stream_equiv (stream_cps.drop n s_cps) (stream.drop n s)\n      → stream_equiv s_cps s) :=\nbegin\n  intro h,\n  let s_cps := @stream_cps.cons (ulift ℕ) (ulift ℕ)\n                                (ulift.up 4) (stream_cps.const (ulift.up 3)),\n  let s := stream.cons (ulift.up 2) (stream.const (ulift.up 3)),\n\n  have h_drop_equiv :\n    stream_equiv (stream_cps.drop 1 s_cps) (stream.drop 1 s) := λ_ _, rfl,\n\n  have h_not_equiv : ¬(stream_equiv s_cps s) :=\n  begin\n    intro h_s_cps_equiv_s,\n    dsimp only [s, s_cps] at h_s_cps_equiv_s,  -- expands s and s_cps defns\n    -- for the continuation, instead of just `id`, we have to do some universe\n    -- trickery since we can't assume that `u₁ = u₂`\n    have h_equiv_at_0 := h_s_cps_equiv_s 0 (ulift.up ∘ ulift.down),\n    rw [stream.const, stream.cons, stream_cps.const, stream_cps.cons]\n      at h_equiv_at_0,\n    dsimp only at h_equiv_at_0,\n    rw [stream.cons._match_1, stream_cps.cons._match_1, function.comp] at h_equiv_at_0,\n    dsimp only at h_equiv_at_0,\n    -- Because where's the fun in using the simplifier?\n    exact (@ulift.no_confusion ℕ false {down := 2} {down := 4} h_equiv_at_0)\n            (λh2eq4, (@nat.no_confusion false 2 4 h2eq4)\n              (λh', (@nat.no_confusion false 1 3 h')\n                (λh'', nat.no_confusion h'')))\n  end,\n  have h_for_contra := h (ulift ℕ) (ulift ℕ) s_cps s,\n  exact absurd (h_for_contra 1 h_drop_equiv) h_not_equiv,\nend\n\n-- ## 3.2. CPS Functions on CPS Streams\n-- Shortly, we will be composing functions, which, of course, we want to be\n-- doing in CPS. Therefore, we now turn our attention to handling CPS functions\n-- which abstract over a data structure which is itself a CPS function.\n\n-- ### 3.2.1. A(nother) Notion of Equivalence\n-- We'll first need a way of saying that a CPS function over CPS streams is\n-- equivalent to a non-CPS function over non-CPS streams. A naïve way of doing\n-- this would be to simply pass `id` as the continuation and use `stream_equiv`,\n-- but this isn't nearly general enough if we want to reuse lemmas in the future\n-- (as we will do shortly). Therefore, we resort to this rather messy, but very\n-- useful, notion of \"double-CPS stream function\" equivalence.\ndef stream_cps_fn_equiv {α β γ : Sort _}\n                        (f_res : stream α)\n                        (f_res_cps : (@stream_cps α β → γ) → γ) :=\n∀ (k : @stream_cps α β → γ)\n    (k' : stream α → γ)\n    (hks : ∀(s : stream_cps α) (s' : stream α),\n        stream_equiv s s' → k s = k' s'),\n      (f_res_cps k) = k' f_res\n\n-- ### 3.2.2. `map`\n-- A simple, maximally-lazy stream map\n-- Because we'll be using this in the next section, it is implemented as a full\n-- CPS function, which makes for a tricky lemma statement\ndef stream_cps.map {α β γ δ : Type _} (f : α → (β → γ) → γ)\n                                    (s : stream_cps α)\n                                    (k : stream_cps β → δ) : δ :=\nk (λ(n : ℕ) (k' : β → γ), s n (λel, f el k'))\n\nlemma map_cps_equiv_map {α β γ δ : Type _} (f : α → β) :\n  ∀(s : stream α) (s_cps : @stream_cps α γ) (hequiv : stream_equiv s_cps s),\n    stream_cps_fn_equiv (stream.map f s)\n                        (@stream_cps.map α β γ δ (λ(x : α) (k'' : β → γ),\n                                                    k'' (f x)) s_cps) :=\nbegin\n  intros s s_cps hequiv k k' hks,\n  rw stream_cps.map,\n  rw hks,\n  intros n_se k_se,\n  rw stream.map,\n  dsimp only,\n  rw stream.nth,\n  -- rw conveniently decides to do β-reduction for us...for once\n  rw ←hequiv n_se (λ (el : α), k_se (f el)),\nend\n\n-- ## 3.2.3. The Corecursor Term (and Friends)\n-- Since Lean doesn't support corecursion natively, we don't get a corecursor\n-- term for free; instead, we must declare it ourselves. To do so, we'll need to\n-- implement two helper functions: a CPS version of the natural number recursor\n-- (so that `corec` can be fully-CPS) and an iterator function that will \"seed\"\n-- our stream with input values to the generator function, over which we will\n-- then `map` the generator. This approach mirrors that taken by the mathlib\n-- implementation of direct-style streams\n\n-- We first implement a new natural-number rec_on that's in CPS\n-- (I'm drawing the line at \"type-level CPS\" -- we'll leave the `motive`\n-- as-is...)\ndef nat.rec_on_cps : Π {α : Sort _} {motive : ℕ → Sort _} (n : ℕ),\n  motive 0 →\n  (Π (n : ℕ), motive n → (motive n.succ → α) → α) →\n  (motive n → α) → α\n| α motive 0 val0 fn_succ k := k val0\n| α motive (nat.succ n) val0 fn_succ k :=\n    nat.rec_on_cps n val0 fn_succ (λv_prev, fn_succ n v_prev k)\n\n/-\nThis iterator function turned out to be pretty involved. To see what's going on,\nhere are implementations using the regular nat recursor (or an analogue) in SML\n(which I find a bit easier to parse in this instance) and Lean.\n\nSML:\n```\ntype ('a, 'b) stream_cps = int -> ('a -> 'b) -> 'b\n\nfun stream_cps_iterate (f : 'a -> ('a -> 'b) -> 'b)\n                       (a : 'a)\n                       (outer_k : ('a, 'b) stream_cps -> 'c) = outer_k\n(fn (n : int) => fn (k : 'a -> 'b) => let\n  val rec res = (fn 0 => (fn (k' : 'a -> 'b) => k' a)\n                  | n' => (fn (k' : 'a -> 'b) =>\n                            res (n - 1) (fn (prev : 'a) => f prev k')))\nin\n  res n k\nend)\n```\n\nLean:\n```\ndef stream_cps.iterate {α β γ : Type _} (f : α → (α → β) → β)\n                                        (a : α)\n                                        (outer_k : @stream_cps α β → γ) : γ :=\nouter_k (λ(n : ℕ) (k : α → β),\n@nat.rec_on (λ_, (α → β) → β)\n            n\n            (λ (k' : α → β), k' a)\n            (λ (_ : ℕ) (r : (α → β) → β) (k' : α → β),\n              r (λ(prev : α), f prev k'))\n            k)\n```\n\nFor wrapping your head around the full-CPS version, it's helpful to consider\nthat `motive n = ((α → β) → β)`, so `fn_succ` has type `(((α → β) → β) → γ) → γ`\n-/\ndef stream_cps.iterate {α β γ : Type _} (f : α → (α → β) → β)\n                                        (a : α)\n                                        (outer_k : @stream_cps α β → γ) : γ :=\nouter_k (λ(n : ℕ) (k : α → β),\n  @nat.rec_on_cps _ (λ_, (α → β) → β)\n              n\n              (λ (k' : α → β), k' a)\n              (λ (_ : ℕ) (r : (α → β) → β) (k' : ((α → β) → β) → β),\n                k' (λ(inner_k : α → β), r (λ(prev : α), f prev inner_k)))\n              (λnth_el_accessor, nth_el_accessor k)\n                 -- the motive type takes a continuation; we ultimately need to\n                 -- produce a β, so we use k to pass the value from the nat\n                 -- recursion to the stream caller\n)\n\n-- This is the analogue of the corecursor term `stream.corec`. As mentioned,\n-- this implementation mirrors the library's dual-argument approach, which\n-- makes the proofs to come (a little) less painful\ndef stream_cps.corec {α β γ δ : Type _} (f : α → (β → γ) → γ)\n                                      (g : α → (α → γ) → γ) :\n                                      α → (stream_cps β → δ) → δ :=\nλ (a : α) (k : stream_cps β → δ),\n  k (λ(n : ℕ) (k : β → γ),\n    stream_cps.iterate g a (λs_seeds,\n      stream_cps.map f s_seeds (λs, s n k)))\n\n-- We now prove that all of these functions behave equivalently to their non-CPS\n-- non-CPS-stream analogues\nlemma nat_rec_on_cps_equiv_nat_rec_on {α β : Sort _} :\n  ∀ {mot : ℕ → Sort _}\n    (n : ℕ)\n    (el0 : mot 0)\n    (f_succ : Π(n' : ℕ), mot n' → mot (nat.succ n'))\n    (k : mot n → α),\n  k (@nat.rec_on mot n el0 f_succ)\n    = nat.rec_on_cps n el0 (λn' x k', k' (f_succ n' x)) k\n:=\nbegin\n  intros mot n el0 f_succ k,\n  induction' n,\n  { refl, },\n  {\n    rw nat.rec_on_cps,\n    dsimp only,  -- unfold nat.rec_on definition\n    rw ←(ih el0 (λ (n' : ℕ) (x : mot n'), f_succ n' x)\n                (λ (v_prev : mot n), k (f_succ n v_prev))),\n  }\nend\n\nlemma iterate_cps_equiv_iterate {α β γ : Type _} :\n  ∀ (f : α → α)\n    (a : α),\n    stream_cps_fn_equiv (stream.iterate f a)\n                        (@stream_cps.iterate α β γ (λ(x : α) (k'' : α → β),\n                                                      k'' (f x)) a) :=\nbegin\n  intros f a k k' hks,\n  rw stream_cps.iterate,\n  rw hks,\n  intros n k,\n  dsimp only,\n  rw ←(@nat_rec_on_cps_equiv_nat_rec_on β α),\n  rw stream.iterate,\n  dsimp only,\n  -- It feels like this induction shouldn't be necessary since\n  -- n_r_o_c_e_n_r_o handles the induction for us.\n  induction' n,\n  { refl },\n  { rw ←(ih f a k k' hks) },\nend\n\nlemma corec_cps_equiv_corec {α β γ δ : Type _} :\n  ∀ (f : α → β) (g : α → α) (a : α),\n    stream_cps_fn_equiv (stream.corec f g a)\n                        (@stream_cps.corec α β γ δ (λx k, k (f x))\n                                                   (λx k, k (g x)) a) :=\nbegin\n  intros f g a k k' hks,\n  rw stream_cps.corec,\n  dsimp only,\n  rw hks,\n  intros n_se k_se,\n  rw stream.corec,\n  dsimp only,\n  let k_cand := λ (s : stream α), k_se ((stream.map f s) n_se),\n  rw (iterate_cps_equiv_iterate g a _ k_cand),  -- _ = the CPS continuation\n  {\n    -- Proving that k_cand is an appropriate analogue of the CPS continuation\n    intros s_candpf s'_candpf hequiv_candpf,\n    dsimp only [k_cand],\n    resetI,\n    apply (map_cps_equiv_map f s'_candpf s_candpf _ _ -- _ = CPS continuation\n            (λ(s : stream β), k_se (s n_se))),\n    {\n      -- Proving that the candidate continuation matches the CPS one for map\n      intros s_map s'_map hequiv_map,\n      dsimp only,\n      apply eq.symm (hequiv_map n_se k_se),\n    },\n    exact hequiv_candpf,\n  }\nend\n\n-- ### 3.2.4. The Big Finale: `cycle`\n-- Using our fancy new iterator and corecursor, we implement `cycle` analogously\n-- to the built-in library (but in CPS, of course!) and then prove its\n-- equivalence to the library implementation over regular streams\ndef stream_cps.cycle_f {α β : Type _} : α × list α × α × list α → (α → β) → β\n| (v, _, _, _) k := k v\n\ndef stream_cps.cycle_g {α β : Type _} :\n  α × list α × α × list α → (α × list α × α × list α → β) → β\n| (v₁, [], v₀, l₀) k := k (v₀, l₀, v₀, l₀)\n| (v₁, list.cons v₂ l₂, v₀, l₀) k := k (v₂, l₂, v₀, l₀)\n\ndef stream_cps.cycle {α β γ : Type _} :\n  Π (l : list α), l ≠ [] → (@stream_cps α γ → β) → β\n| []              h := absurd rfl h\n| (list.cons a l) h := stream_cps.corec stream_cps.cycle_f\n                                        stream_cps.cycle_g\n                                        (a, l, a, l)\n\n-- Just to \"prove\" it all works:\n#eval @nat.rec_on (λ_, list ℕ)\n                  20\n                  []\n                  (λn r, stream_cps.cycle [1, 9, 5, 1, 88]\n                                          (by apply list.no_confusion)\n                                          (λs, s n (λel, r ++ [el])))\n\n\n-- And now to **prove** it all works...\n-- I finally have to break my \"no-axioms\" rule...to take advantage of the other\n-- lemmas, we have to use `funext` to substitute lambdas. This proof is doable\n-- without `funext`, of course, but it would end up duplicating a lot of the\n-- previous lemmas (which we wouldn't be able to apply)\nlemma cycle_cps_equiv_cycle {α β γ : Type _} :\n  ∀ (l : list α) (hl : l ≠ []) (k : @stream_cps α β → γ) (k' : stream α → γ)\n    (hks : ∀(s : stream_cps α) (s' : stream α),\n        stream_equiv s s' → k s = k' s'),\n    stream_cps.cycle l hl k = k' (stream.cycle l hl) :=\nbegin\n  intros l hl k k' hks,\n  cases' l,\n  { apply absurd rfl hl, },\n  {\n    rw stream_cps.cycle,\n    have hf : ∀{α β : Type _},\n      (λ (x : α × list α × α × list α) (k : α → β), k (stream.cycle_f x))\n      = stream_cps.cycle_f := \n    begin\n      intros α β,\n      apply funext,\n      intro x,\n      apply funext,\n      intro k,\n      -- To make rw work, we have to expand out the tuple fully\n      cases' x,\n      cases' snd,\n      cases' snd,\n      rw [stream_cps.cycle_f, stream.cycle_f],\n    end,\n    have hg: ∀{α β : Type _}, (λ (x : α × list α × α × list α)\n                                 (k : α × list α × α × list α → β),\n                                   k (stream.cycle_g x)) = stream_cps.cycle_g := \n    begin\n      intros α β,\n      apply funext,\n      intro x,\n      apply funext,\n      intro k,\n      cases' x,\n      cases' snd,\n      cases' snd,\n      cases' fst_1,\n      { refl, },\n      { rw [stream_cps.cycle_g, stream.cycle_g], },\n    end,\n    rw [←hf, ←hg],\n    rw (corec_cps_equiv_corec stream.cycle_f stream.cycle_g (hd, l, hd, l) k k'\n          hks),\n    rw stream.cycle,\n  }\nend\n\n/-\n## 3.3. CPS Functions on Non-CPS Streams\nFor completeness, we can also consider a more traditional case: our functions\nare in CPS, and we leave our streams in direct style.\n\nUnfortunately, this turned out to be relatively uninteresting -- since streams\naren't inductively defined, the CPS functions essentially amount to applying a\ncontinuation to a re-implementation of a library function. Just to illustrate\nthis point, I've included `boring_map_cps` below, but the reader can imagine\nanalogous cases for most other stream functions:\n-/\n\ndef boring_map_cps {α β γ : Type _} (f : α → β)\n                                    (s : stream α)\n                                    (k : stream β → γ) :=\n  k (λn, f (s n))\n\nlemma boring_map_cps_equiv_map {α β γ : Type _} :\n  ∀ (f : α → β) (s : stream α) (k : stream β → γ),\n  k (stream.map f s) = boring_map_cps f s k := λ_ _ _, rfl\n", "meta": {"author": "jrr6", "repo": "fpv_final_project", "sha": "5a391008aee3a14fe83d628fb5805f1bec45e8ac", "save_path": "github-repos/lean/jrr6-fpv_final_project", "path": "github-repos/lean/jrr6-fpv_final_project/fpv_final_project-5a391008aee3a14fe83d628fb5805f1bec45e8ac/src/C_streams.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.6688802537704063, "lm_q1q2_score": 0.45656008405257575}}
{"text": "import ring_theory.tensor_product\nimport algebra.algebra.bilinear\n\nopen_locale tensor_product \n\nuniverses ur uc\n\nnoncomputable theory\n\nsection missing_tensor_stuff\n\nvariables \n{R : Type*} [comm_semiring R]\n{A : Type*} [ring A] [algebra R A]\n{M₁ : Type*} [add_comm_monoid M₁] [module R M₁] \n{N₁ : Type*} [add_comm_monoid N₁] [module R N₁] \n{M₂ : Type*} [add_comm_monoid M₂] [module R M₂] \n{N₂ : Type*} [add_comm_monoid N₂] [module R N₂] \n{M₃ : Type*} [add_comm_monoid M₃] [module R M₃] \n{N₃ : Type*} [add_comm_monoid N₃] [module R N₃]\n\nnamespace tensor_product\n\nlemma map_assoc (f₁ : M₁ →ₗ[R] N₁) (f₂ : M₂ →ₗ[R] N₂) (f₃ : M₃ →ₗ[R] N₃) : \n  (↑(tensor_product.assoc R N₁ N₂ N₃)) ∘ₗ (tensor_product.map (tensor_product.map f₁ f₂) f₃)\n  = (tensor_product.map (f₁ : M₁ →ₗ[R] N₁) (tensor_product.map f₂ f₃)) ∘ₗ \n  ↑(tensor_product.assoc R M₁ M₂ M₃) := \nbegin\n  apply tensor_product.ext',\n  intros xy z,\n  apply tensor_product.induction_on xy,\n  { simp only [zero_tmul, map_zero] },\n  { intros x y,\n    simp only [linear_map.coe_comp, linear_equiv.coe_coe, function.comp_app, map_tmul,\n       assoc_tmul] },\n  { simp only [tensor_product.add_tmul, linear_map.coe_comp, linear_equiv.coe_coe, \n      function.comp_app, map_tmul, map_add],\n    intros x y hx hy,\n    rw [← hx,← hy] },\nend\n\nlemma lid_comm_ltensor (f₁ : M₁ →ₗ[R] N₁) : ↑(tensor_product.lid R N₁) ∘ₗ \n  (tensor_product.map (linear_map.id : R →ₗ[R] R) f₁) =  f₁ ∘ₗ ↑(tensor_product.lid R M₁) :=\nby apply tensor_product.ext'; simp [linear_map.comp_apply]\n\nlemma rid_comm_rtensor (f₁ : M₁ →ₗ[R] N₁) : ↑(tensor_product.rid R N₁) ∘ₗ \n  (tensor_product.map f₁ (linear_map.id : R →ₗ[R] R)) =  f₁ ∘ₗ ↑(tensor_product.rid R M₁) :=\nby apply tensor_product.ext'; simp [linear_map.comp_apply]\n\nend tensor_product\n\nnamespace algebra\n\n/-\n  translating algebra defns to statements about linear maps between\n  vector spaces.\n-/\n\nlemma lmul'_assoc : (lmul' R : A ⊗ A →ₗ[R] A) ∘ₗ (_root_.tensor_product.map (lmul' R) \n  (linear_map.id : A →ₗ[R] A)) = (lmul' R : A ⊗ A →ₗ[R] A) ∘ₗ\n  (_root_.tensor_product.map linear_map.id (lmul' R)) ∘ₗ ↑(_root_.tensor_product.assoc R A A A) :=\nbegin\n  apply tensor_product.ext',\n  intros xy z,\n  apply tensor_product.induction_on xy,\n  { simp only [tensor_product.zero_tmul, map_zero] },\n  { intros x y,\n    simp only[ mul_assoc, linear_map.coe_comp, function.comp_app,_root_.tensor_product.map_tmul, \n      lmul'_apply, linear_map.id_coe, id.def, linear_equiv.coe_coe, \n      _root_.tensor_product.assoc_tmul, eq_self_iff_true] },\n  { simp only [tensor_product.add_tmul, linear_map.coe_comp, function.comp_app, \n      tensor_product.map_tmul, linear_map.id_coe, id.def, lmul'_apply, linear_equiv.coe_coe, map_add],\n    intros x y hx hy,\n    rw [←hx, ←hy] }\nend\n\nlemma algebra_map_id_left : (lmul' R : A ⊗ A →ₗ[R] A) ∘ₗ \n  (_root_.tensor_product.map (algebra.linear_map R A) linear_map.id) = \n  ↑(_root_.tensor_product.lid R A) := \nby apply tensor_product.ext'; simp[algebra.smul_def]\n\nlemma algebra_map_id_right : (lmul' R : A ⊗ A →ₗ[R] A) ∘ₗ \n  (_root_.tensor_product.map linear_map.id (algebra.linear_map R A) ) = \n  ↑(_root_.tensor_product.rid R A) := \nby apply tensor_product.ext'; simp[← algebra.commutes, algebra.smul_def]\n\nend algebra\n\nend missing_tensor_stuff\n\nclass coalgebra (R : Type ur) [comm_semiring R] (C : Type uc) [add_comm_monoid C] [module R C] :=\n(counit : C →ₗ[R] R)\n(comul  : C →ₗ[R] (C ⊗[R] C))\n(counit_left : ↑(tensor_product.lid R C) ∘ₗ (tensor_product.map counit linear_map.id) ∘ₗ comul = \n  (linear_map.id : C →ₗ[R] C))\n(counit_right : ↑(tensor_product.rid R C) ∘ₗ (tensor_product.map linear_map.id counit) ∘ₗ comul =\n  (linear_map.id : C →ₗ[R] C))\n(coassoc : ↑(tensor_product.assoc R C C C) ∘ₗ (tensor_product.map comul linear_map.id) ∘ₗ comul = \n    (tensor_product.map linear_map.id  comul) ∘ₗ comul)\n\nnamespace coalgebra \n\nvariables \n(R : Type*) [comm_semiring R]\n(C : Type*) [add_comm_monoid C] [module R C] [coalgebra R C]\n(A : Type*) [ring A] [algebra R A]\n\n@[derive [add_comm_group, module R]]\ndef conv_alg := C →ₗ[R] A \n\nvariables {R} {C} {A}\n\nlemma coassoc' : (tensor_product.map comul linear_map.id) ∘ₗ (comul : C →ₗ[R] C ⊗ C) = \n  ↑(tensor_product.assoc R C C C).symm ∘ₗ (tensor_product.map linear_map.id comul) \n  ∘ₗ (comul : C →ₗ[R] C ⊗ C) :=\nbegin\n  rw [←linear_equiv.to_linear_map_eq_coe ,linear_equiv.eq_to_linear_map_symm_comp],\n  exact coassoc,\nend\n\ndef grouplike_elm (c : C) : Prop := comul c = c ⊗ₜ[R] c\n\nnamespace conv_alg\n\ninstance : has_mul (conv_alg R C A) :=\n ⟨λ f g, (algebra.lmul' R) ∘ₗ (tensor_product.map f g) ∘ₗ comul⟩\n\n@[simp] \nlemma mul_def (f g : conv_alg R C A) : \n  f * g = (algebra.lmul' R) ∘ₗ (tensor_product.map f g) ∘ₗ comul := rfl \n\ninstance : has_one (conv_alg R C A) := ⟨(algebra.linear_map R A) ∘ₗ counit⟩\n\n@[simp]\nlemma one_def : (1 : conv_alg R C A) = (algebra.linear_map R A) ∘ₗ counit := rfl\n\ninstance : add_monoid_hom_class (conv_alg R C A) C A := linear_map.add_monoid_hom_class\n\nlemma left_distrib (f g h : conv_alg R C A) : f * (g + h) = f * g + f * h := \nby simp [mul_def,tensor_product.map_add_right, linear_map.add_comp, linear_map.comp_add]\n\nlemma right_distrib (f g h : conv_alg R C A) : (f + g) * h = f * h + g * h := \nby simp [mul_def,tensor_product.map_add_left, linear_map.add_comp, linear_map.comp_add]\n\nlemma one_mul (f : conv_alg R C A) : 1 * f = f := \nbegin\n  simp only [one_def, mul_def],\n  conv_lhs \n    begin \n      rw [← linear_map.id_comp f,tensor_product.map_comp, ← linear_map.comp_id f,\n        ← linear_map.id_comp counit,tensor_product.map_comp],\n    end,\n  have hassoc : (algebra.lmul' R).comp \n      (((tensor_product.map (algebra.linear_map R A) linear_map.id).comp \n      ((tensor_product.map linear_map.id f).comp (tensor_product.map counit linear_map.id))).comp \n      (comul : C →ₗ[R] C ⊗ C)) = ((algebra.lmul' R : A ⊗ A →ₗ[R] A) ∘ₗ \n      (tensor_product.map (algebra.linear_map R A) linear_map.id)) ∘ₗ \n      (tensor_product.map linear_map.id f) ∘ₗ \n      ((tensor_product.map counit linear_map.id) ∘ₗ (comul : C →ₗ[R] C ⊗ C)),\n    { simp only [linear_map.comp_assoc] },\n  rw [hassoc, algebra.algebra_map_id_left, ←linear_map.comp_assoc,tensor_product.lid_comm_ltensor,\n    linear_map.comp_assoc,counit_left],\n  simp\nend\n\nlemma mul_one (f : conv_alg R C A) : f * 1 = f :=\nbegin\n  simp only [one_def, mul_def],\n  conv_lhs \n    begin \n      rw [← linear_map.id_comp f,tensor_product.map_comp, ← linear_map.comp_id f,\n        ← linear_map.id_comp counit,tensor_product.map_comp],\n    end,\n  have hassoc : (algebra.lmul' R).comp \n      (((tensor_product.map linear_map.id (algebra.linear_map R A) ).comp \n      ((tensor_product.map f linear_map.id).comp (tensor_product.map linear_map.id counit))).comp \n      (comul : C →ₗ[R] C ⊗ C)) = ((algebra.lmul' R : A ⊗ A →ₗ[R] A) ∘ₗ \n      (tensor_product.map  linear_map.id (algebra.linear_map R A) )) ∘ₗ \n      (tensor_product.map f linear_map.id) ∘ₗ \n      ((tensor_product.map linear_map.id counit) ∘ₗ (comul : C →ₗ[R] C ⊗ C)),\n    { simp only [linear_map.comp_assoc] },\n  rw [hassoc, algebra.algebra_map_id_right, ←linear_map.comp_assoc,tensor_product.rid_comm_rtensor,\n    linear_map.comp_assoc,counit_right],\n  simp\nend\n\nlemma mul_assoc (f g h : conv_alg R C A) : f * g * h = f * (g * h) :=\nbegin\n  simp only [mul_def],\n  conv_rhs \n    begin\n      congr, skip,\n      rw [← linear_map.comp_id f, ← linear_map.comp_assoc,tensor_product.map_comp, \n        linear_map.comp_assoc, ← coassoc, ← linear_map.id_comp f, tensor_product.map_comp,\n        linear_map.comp_assoc],\n      congr, skip,\n      rw [← linear_map.comp_assoc,← tensor_product.map_assoc],\n    end,\n  conv_rhs\n    begin\n      simp only [← linear_map.comp_assoc],\n      congr, congr, congr,\n      rw  [linear_map.comp_assoc, ← algebra.lmul'_assoc],\n    end,\n  simp[← tensor_product.map_comp, linear_map.comp_assoc],\nend\n\ninstance : ring (conv_alg R C A) := {\n  mul_assoc := mul_assoc,\n  left_distrib := left_distrib,\n  right_distrib := right_distrib,\n  one_mul := one_mul,\n  mul_one := mul_one,\n  .. conv_alg.has_one,\n  .. conv_alg.has_mul,\n  .. (infer_instance : add_comm_group (conv_alg R C A))\n}\n\ninstance : algebra R (conv_alg R C A) :=\nbegin\n  apply algebra.of_module,\n  { simp only [tensor_product.map_smul_left, linear_map.comp_smul, linear_map.smul_comp, mul_def,\n     eq_self_iff_true, forall_const] },\n  { simp only [tensor_product.map_smul_right, linear_map.comp_smul, linear_map.smul_comp, mul_def,\n    eq_self_iff_true, forall_const] }\nend\n\nend conv_alg\n\nend coalgebra\n\nstructure coalg_hom (R : Type*) [comm_semiring R] (C₁ : Type*) [add_comm_monoid C₁] [module R C₁] \n  [coalgebra R C₁] (C₂ : Type*) [add_comm_monoid C₂] [module R C₂] [coalgebra R C₂] :=\n(to_map : C₁ →ₗ[R] C₂)\n(map_counit' : (coalgebra.counit ∘ₗ to_map : C₁ → R) = coalgebra.counit) \n(map_comul' : coalgebra.comul ∘ₗ to_map  = (tensor_product.map to_map to_map) ∘ₗ coalgebra.comul)\n\ninfixr ` →ᶜ `:25 := coalg_hom _\nnotation A ` →ᶜ[`:25 R `] ` B := coalg_hom R A B\n\nnamespace coalg_hom\n\nend coalg_hom\n\nclass bialgebra (R : Type*) [comm_semiring R] (B : Type*) [ring B] [algebra R B] extends \n  coalgebra R B :=\n(counit_one : counit 1 = 1)\n(counit_mul : ∀ x y : B, counit (x * y) = (counit x) * (counit y))\n(comul_one : comul 1 = 1)\n(comul_mul : ∀ x y : B,  comul (x * y) = (comul x) * (comul y))\n\nclass hopf_algebra (R : Type*) [comm_semiring R](H : Type*) [ring H] [algebra R H] extends\n  bialgebra R H :=\n(id_unit : is_unit (linear_map.id : coalgebra.conv_alg R H H))\n\nnamespace hopf_algebra\n\n\nend hopf_algebra", "meta": {"author": "CameronTorrance", "repo": "thomas_paper", "sha": "5135ba70092496a8144773cd1c37310f10543cd6", "save_path": "github-repos/lean/CameronTorrance-thomas_paper", "path": "github-repos/lean/CameronTorrance-thomas_paper/thomas_paper-5135ba70092496a8144773cd1c37310f10543cd6/src/stuff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.45653366068752443}}
{"text": "import data.list.basic\n\n/- Prelude -/\n\nattribute [simp] nat.succ_le_succ nat.zero_le\nattribute [reducible] id\n\n\nlemma {u v} if_distrib {c : Prop} {h : decidable c} {α : Sort u} {t e : α}\n  {β : Sort v} (f : α → β) : f (ite c t e) = ite c (f t) (f e) :=\nmatch h with\n| (is_true  hc)  := rfl\n| (is_false hnc) := rfl\nend\n\nlemma nat.succ_lt_succ_iff (n m : ℕ) : n.succ < m.succ ↔ n < m :=\n⟨nat.lt_of_succ_lt_succ, nat.succ_lt_succ⟩\n\ntheorem nat.sub_lt_sub_right : Π {n m k : ℕ} (h₁ : n < m) (h₂ : k ≤ n), n - k < m - k\n| n     m     0     h₁ h₂ := h₁\n| (n+1) (m+1) (k+1) h₁ h₂ := by simp; apply nat.sub_lt_sub_right (nat.lt_of_succ_lt_succ h₁) (nat.le_of_succ_le_succ h₂)\n\ntheorem nat.le_sub_one_of_lt {a b : ℕ} (h : a < b) : a ≤ b - 1 :=\nbegin\n  cases b,\n  { simp [nat.not_lt_zero] at h; contradiction },\n  { simp [nat.le_of_succ_le_succ h] }\nend\n\nnamespace list\nuniverse u\nvariables {α β : Type u}\n@[simp]\nlemma nth_map (xs : list α) (f : α → β) (i : ℕ) : (xs.map f).nth i = f <$> xs.nth i :=\nbegin\n  induction xs generalizing i,\n  { refl },\n  { cases i, { refl },\n    apply ih_1 }\nend\n\n@[simp]\nlemma nth_drop (xs : list α) (i k : ℕ) : (xs.drop k).nth i = xs.nth (i + k) :=\nbegin\n  induction xs generalizing k i,\n  { cases k; refl },\n  { cases k, { refl },\n    simp [nat.add_succ],\n    apply ih_1 }\nend\n\nlemma nth_take (xs : list α) (i k : ℕ) : (xs.take k).nth i = if i < k then xs.nth i else none :=\nbegin\n  induction xs generalizing k i,\n  { simp [list.nth] },\n  { cases k, { refl },\n    cases i, { refl },\n    simp [list.take, ih_1, nat.succ_lt_succ_iff],\n    apply if_congr; refl }\nend\n\nlemma nth_append (xs ys : list α) (i : ℕ) : (xs ++ ys).nth i =\n  if i < length xs then xs.nth i else ys.nth (i - length xs) :=\nbegin\n  induction xs generalizing i,\n  case list.nil { refl },\n  case list.cons x xs { cases i with i,\n    { refl },\n    { simp [ih_1, nat.one_add, nat.succ_lt_succ_iff],\n      apply if_congr; refl }\n  }\nend\nend list\n\nnamespace system_f_sub\n\n/- Recursive types in F<: -/\n\ninductive type\n| var (idx : ℕ)\n| top\n| «fun» (domain body : type)\n| abs (bound body : type)\n| mu (rec : type)\n\nopen type\n\ninfixr ` →ₛ `:55 := type.fun\nnotation `∀0<: ` t `, ` s := abs t s\n\n/- Parallel substitution -/\n\ndef rename := ℕ → ℕ\ndef rename.up (ξ : rename) : rename\n| 0     := 0\n| (k+1) := ξ k + 1\n\n@[simp]\ndef type.rename : rename → type → type\n| ξ (var x)    := var (ξ x)\n| ξ top        := top\n| ξ (a →ₛ b)   := a.rename ξ →ₛ b.rename ξ\n| ξ (∀0<:a, b) := ∀0<:a.rename ξ, b.rename ξ.up\n| ξ (mu a)     := mu (a.rename ξ.up)\n\ndef subst := ℕ → type\ndef subst.up (σ : subst) : subst\n| 0     := var 0\n| (k+1) := (σ k).rename (+1)\n\n@[simp]\ndef type.subst : subst → type → type\n| σ (var x)    := σ x\n| σ top        := top\n| σ (a →ₛ b)   := a.subst σ →ₛ b.subst σ\n| σ (∀0<:a, b) := ∀0<:a.subst σ, b.subst σ.up\n| σ (mu a)     := mu (a.subst σ.up)\n\ndef subst.comp (σ' σ : subst) : subst := type.subst σ' ∘ σ\n\ninfix ` ∘ₛ `:90 := subst.comp\n\ndef lift_idx (k : ℕ) (d := 0) : rename :=\nλ i, if i ≥ d then i + k else i\n\ndef type.lift (a : type) (k : ℕ) (d := 0) : type :=\na.rename (lift_idx k d)\n\ndef instantiate_idx (r : type) (d := 0) : subst :=\nλ i, if d < i then var (i-1) else if i = d then r.lift d else var i\n\ndef type.instantiate (a b : type) (d := 0) : type :=\na.subst (instantiate_idx b d)\n\ndef type.expand (a : type) : type :=\na.instantiate (mu a)\n\ndef type.free_range : type → ℕ\n| (var d)     := d + 1\n| top         := 0\n| (a →ₛ b)    := max a.free_range b.free_range\n| (∀0<: a, b) := max a.free_range (b.free_range - 1)\n| (mu a)      := a.free_range - 1\n\ndef type.closed (t : type) := t.free_range = 0\n\n/- The subtyping relation -/\n\n@[reducible] def env := list type\n\ndef env.lift : env → ℕ → opt_param ℕ 0 → env\n| [] k d := []\n| (a::e) k d := a.lift k (d + e.length) :: env.lift e k d\n\ninductive sub : env → type → type → Prop\n  notation e ` ⊢ `:40 a ` <: `:40 b:40 := sub e a b\n| var_refl (e x) : e ⊢ var x <: var x\n| env {e x a b} : list.nth e x = some a → e ⊢ a.lift (x+1) <: b → e ⊢ var x <: b\n| top (e a) : e ⊢ a <: top\n| «fun» {e a a' b b'} : e ⊢ a' <: a → e ⊢ b <: b' → e ⊢ a →ₛ b <: a' →ₛ b'\n| abs {e a a' b b'} : e ⊢ a' <: a → a'::e ⊢ b <: b' → e ⊢ ∀0<:a, b <: ∀0<:a', b'\n-- violates the positivity restriction\n--| mu {e a a'} : (∀ b b', e ⊢ b <: b' → e ⊢ type.instantiate a b <: type.instantiate a' b') → e ⊢ mu a <: mu a'\n| mu_refl (e a) : e ⊢ mu a <: mu a\n| expₗ {e a a'} : e ⊢ type.expand a <: a' → e ⊢ mu a <: a'\n| expᵣ {e a a'} : e ⊢ a <: type.expand a' → e ⊢ a <: mu a'\n\nnotation e ` ⊢ `:40 a:41 ` <: `:40 b:40 := sub e a b\nnotation a ` <: `:40 b:40 := sub [] a b\n\nlemma sub.refl : Π e a, e ⊢ a <: a\n| e (var x)    := sub.var_refl e x\n| e top        := sub.top e top\n| e (a →ₛ b)   := sub.fun (sub.refl e a) (sub.refl e b)\n| e (∀0<:a, b) := sub.abs (sub.refl e a) (sub.refl _ b)\n| e (mu a)     := sub.mu_refl e a\n\n/- A macro for translating Lean types into F<: types -/\n\nsection\nopen lean\nopen lean.parser\nopen interactive\nopen interactive.types\n\nopen expr (app pi const lam)\n\nreserve notation `⟦ₛ`:1000\ndef mu_helper := 0\nnotation `μ ` binder `, ` a:scoped := mu_helper a\ndef ctx_helper := 0\nnotation `bctx ` binder <: a:50 `⊢` b:scoped := ctx_helper a b\n\nprivate meta def parse_type : ℕ → ℕ → pexpr → parser pexpr\n| d d' (expr.var n) := let n := n - d' in pure ``(var %%(reflect n))\n| d d' (const n ls) := pure $ const n ls\n| d d' (app (const ``mu_helper _) (lam _ _ _ a)) := do a ← parse_type (d+1) d' a, pure ``(mu %%a)\n| d d' (expr.local_const n m bi t) := pure $ ``(type.lift  %%(expr.local_const n m bi t) %%(reflect d))\n-- ``(∀ x <: %%a, %%b)\n| d d' (pi _ _ _ (pi _ _ (app (app (app (const `system_f_sub.sub []) _) (expr.var 0)) a) b)) :=\ndo a ← parse_type (d+1) (d'+1) a, b ← parse_type (d+1) (d'+1) b, pure ``(∀0<:%%a, %%b)\n| d d' (expr.pi _ _ dom b) :=\nif (@unchecked_cast _ expr b).has_var_idx 0 then\n     do b ← parse_type (d+1) d' b, pure ``(∀0<:top, %%b)\n   else\n     do dom ← parse_type d d' dom, b ← parse_type d (d'+1) b, pure ``(%%dom →ₛ %%b)\n| d d' e := match e.get_structure_instance_info with\n  | some info :=\n    do fields ← (info.field_names.zip info.field_values).mmap (λ ⟨n, v⟩,\n      do v ← parse_type d d' v,\n         pure ``(⟨%%(const (`system_f_sub.labels ++ n) [] : pexpr), %%v⟩)),\n    pure (app (const `system_f_sub.record []) (fields.foldr (λ e f, ``(%%e::%%f)) ``([])))\n  | _ := tactic.fail format!\"unsupported sub-expression {e.to_raw_fmt}\"\n  end\n\nprivate meta def parse_ctx : list pexpr → pexpr → parser pexpr\n| ctx (app (app (const ``ctx_helper _) a) (lam _ _ _ b)) :=\ndo a ← parse_type ctx.length 0 a,\n   let ctx := a::ctx,\n   parse_ctx ctx b\n| ctx (app (app (app (const ``sub _) _) a) b) :=\ndo a ← parse_type ctx.length 0 a,\n   b ← parse_type ctx.length 0 b,\n   pure ``(sub %%(ctx.foldl (λ ctx a, ``(%%a :: %%ctx)) ``([])) %%a %%b)\n| _ e := parse_type 0 0 e\n\nprivate meta def erase_all_annotations : expr → expr :=\nλ e, expr.replace e (λ e _, match e.is_annotation with\n| some (_, e') := some (erase_all_annotations e')\n| _ := none\nend)\n\n@[user_notation]\nmeta def interpret_notation (_ : parse $ tk \"⟦ₛ\") (e : parse $ parser.pexpr <* tk \"⟧\") : parser pexpr :=\nlet e := erase_all_annotations (unchecked_cast e) in\nparse_ctx [] (unchecked_cast e)\nend\n\n/- Basic types -/\n\n-- def Bool := ∀0<:top, var 0 →ₛ var 0 →ₛ var 0\ndef Bool := ⟦ₛ ∀ a, a → a → a ⟧\ndef True := ⟦ₛ ∀ a, a → top → a ⟧\ndef False := ⟦ₛ ∀ a, top → a → a ⟧\ndef None := ⟦ₛ ∀ a, top → top → a ⟧\n\nexample : None <: True := by repeat {constructor}\nexample : None <: False := by repeat {constructor}\nexample : True <: Bool := by repeat {constructor}\nexample : False <: Bool := by repeat {constructor}\n\ndef prod (a b : type) := ⟦ₛ ∀ r, (a → b → r) → r ⟧\ninfix ` ×ₛ `:45 := prod\n\ndef tuple : list type → type\n| []      := top\n| (a::as) := a ×ₛ tuple as\n\nstructure field :=\n(idx : ℕ)\n(type : type)\n\ndef record_list (fields : list field) : list type :=\nlet max_idx := (fields.map field.idx).foldr max 0 in\n(list.range (max_idx+1)).map (λ i, (field.type <$> fields.find (λ f, f.idx = i)).get_or_else top)\n\ndef record (fields : list field) : type :=\ntuple (record_list fields ++ [top])\n\n/- Finally, some proofs -/\n\nlemma rename_up_id : rename.up id = id :=\nbegin\n  apply funext, intro i,\n  cases i; simp [rename.up]\nend\n\nlemma rename_up_comp_rename_up (ξ ξ' : rename) : ξ'.up ∘ ξ.up = rename.up (ξ' ∘ ξ) :=\nbegin\n  apply funext, intro i,\n  cases i; simp [function.comp, rename.up]\nend\n\n@[simp]\nlemma rename_rename (a : type) (ξ ξ') : (a.rename ξ).rename ξ' = a.rename (ξ' ∘ ξ) :=\nby induction a generalizing ξ ξ'; simp [*,rename_up_comp_rename_up]\n\nlemma subst_up_comp_rename_up (ξ : rename) (σ : subst) : σ.up ∘ ξ.up = subst.up (σ ∘ ξ) :=\nbegin\n  apply funext, intro i,\n  cases i; simp [function.comp, rename.up, subst.up]\nend\n\n@[simp]\nlemma rename_subst (a : type) (ξ σ) : (a.rename ξ).subst σ = a.subst (σ ∘ ξ) :=\nby induction a generalizing ξ σ; simp [*,subst_up_comp_rename_up]\n\nlemma rename_up_comp_subst_up (ξ : rename) (σ : subst) : type.rename ξ.up ∘ σ.up = subst.up (type.rename ξ ∘ σ) :=\nbegin\n  apply funext, intro i,\n  cases i with i; simp [function.comp, rename.up, subst.up]\nend\n\n@[simp]\nlemma subst_rename (a : type) (ξ σ) : (a.subst σ).rename ξ = a.subst (type.rename ξ ∘ σ) :=\nby induction a generalizing ξ σ; simp [*,rename_up_comp_subst_up]\n\nlemma subst_up_comp_subst_up (σ σ' : subst) : σ'.up ∘ₛ σ.up = (σ' ∘ₛ σ).up :=\nbegin\n  apply funext, intro i,\n  cases i with i; simp [subst.comp, function.comp, subst.up]\nend\n\n@[simp]\nlemma subst_subst (a : type) (σ σ') : (a.subst σ).subst σ' = a.subst (σ' ∘ₛ σ) :=\nbegin\n  induction a generalizing σ σ'; simp [*,subst_up_comp_subst_up],\n  case var { simp [subst.comp, function.comp] }\nend\n\nlemma lift_lift {k k' d d'} (a : type) : d ≤ d' → d' ≤ k + d → (a.lift k d).lift k' d' = a.lift (k + k') d :=\nbegin\n  intros, simp [type.lift,rename_rename,function.comp],\n  congr, apply funext, intro i,\n  by_cases i ≥ d,\n  { simp [ge, h, type.lift, lift_idx, le_trans ‹d' ≤ k + d› (add_le_add_left h _)] },\n  { have : ¬d' ≤ i, from λ hcontr, h (le_trans ‹d ≤ d'› hcontr),\n    simp [ge, h, type.lift, lift_idx, this] }\nend\n\n@[simp]\nlemma lift_lift' (k k') (a : type) : (a.lift k).lift k' = a.lift (k + k') :=\nlift_lift _ dec_trivial dec_trivial\n\nlemma lift_lift2 (k k' d d') (a : type) : k + d ≤ d' → (a.lift k d).lift k' d' = (a.lift k' (d' - k)).lift k d :=\nbegin\n  intros, simp [type.lift,rename_rename,function.comp],\n  congr, apply funext, intro i,\n  have : k ≤ d', from le_trans (nat.le_add_right _ _) ‹k + d ≤ d'›,\n  by_cases i ≥ d,\n  { by_cases d' ≤ k + i with h',\n    { have : d' - k ≤ k + i - k, from nat.sub_le_sub_right h' k,\n      simp [nat.add_sub_cancel_left] at this,\n      simp [ge, h, type.lift, lift_idx, h', this, le_add_of_nonneg_of_le (nat.zero_le _) h] },\n    { have : ¬ d' - k ≤ i, begin\n        assume hcontr, apply h',\n        have : d' - k + k ≤ i + k, from nat.add_le_add_right hcontr k,\n        simp [nat.sub_add_cancel ‹k ≤ d'›] at this,\n        simp [this],\n      end,\n      simp [ge, h, type.lift, lift_idx, h', this] }\n  },\n  { simp [ge, lift_idx, h],\n    have : ¬d' - k ≤ i, begin\n      have : k + i < k + d, from add_lt_add_left (lt_of_not_ge h) _,\n      have : i + k < k + d, by simp [this],\n      have : d' > i + k, from lt_of_lt_of_le this ‹k + d ≤ d'›,\n      have : d' - k > i + k - k, from nat.sub_lt_sub_right this (nat.le_add_left _ _),\n      simp only [nat.add_sub_cancel] at this,\n      exact not_le_of_gt this,\n    end,\n    have : d ≤ d', from le_trans (nat.le_add_left _ _) ‹k + d ≤ d'›,\n    have : ¬d' ≤ i, from not_le_of_gt (lt_of_lt_of_le (lt_of_not_ge h) this),\n    simp [*, h, type.lift, this] }\nend\n\nlemma nat.succ_le_iff_lt (n m : ℕ) : n.succ ≤ m ↔ n < m := ⟨nat.succ_le_of_lt, nat.lt_of_succ_le⟩\n\n@[simp]\nlemma expand_lift (k d) (a : type) : (a.lift k (d+1)).expand = a.expand.lift k d :=\nbegin\n  intros, simp [type.expand,type.instantiate,type.lift,instantiate_idx,rename_rename,function.comp],\n  congr, apply funext, intro i,\n  simp [nat.not_lt_zero,ge,lift_idx,nat.succ_le_iff_lt],\n  by_cases d < i,\n  { have : 0 < i, from lt_of_le_of_lt (nat.zero_le _) ‹d < i›,\n    have : 0 < k + i, from lt_of_lt_of_le this (nat.le_add_left _ _),\n    simp [*, le_of_lt h, nat.add_sub_assoc, nat.succ_le_iff_lt, nat.le_sub_one_of_lt] },\n  { simp [*],\n    cases i with i,\n    { simp [rename_up_comp_rename_up, nat.not_lt_zero],\n      congr, apply funext, intro j,\n      cases j, --by_cases d ≤ j,\n      { simp [rename.up,*] },\n      { simp [rename.up,*, function.comp, if_distrib nat.succ, nat.add_one, nat.add_succ,\n          nat.lt_succ_iff_le, rename_up_id],\n        apply if_congr; simp }\n    },\n    { have : ¬ d ≤ i, from h ∘ nat.lt_succ_of_le,\n      simp [nat.zero_lt_succ,*] }\n  }\nend\n\n@[simp]\nlemma env.length_lift (e : env) (k d) : (e.lift k d).length = e.length :=\nby induction e; simp [env.lift, *]\n\n@[simp]\nlemma option_has_map_map_none {α β : Type} (f : α → β) : f <$> none = none := rfl\n\n@[simp]\nlemma option_has_map_map_some {α β : Type} (f : α → β) (x : α) : f <$> some x = f x := rfl\n\n@[simp]\nlemma env.nth_lift {e : env} (k d i) : (e.lift k d).nth i = (λ a : type, a.lift k (d + (e.length - 1 - i))) <$> e.nth i :=\nbegin\n  induction e generalizing i,\n  { simp [env.lift] },\n  { simp [list.nth],\n    cases i with i,\n    { simp [env.lift, list.nth, nat.add_sub_cancel_left], refl },\n    { simp [env.lift, ih_1, nat.add_sub_cancel_left, nat.sub_sub] }\n  }\nend\n\n@[simp]\nlemma lift_zero (a : type) : a.lift 0 = a :=\nby induction a; simp [*, type.lift, lift_idx, rename_up_id] at *\n\n@[simp]\nlemma up_lift_idx (k d) : (lift_idx k d).up = lift_idx k (d+1) :=\nbegin\n  apply funext, intro i,\n  simp [lift_idx],\n  cases i,\n  { have : d + 1 > 0, from nat.zero_lt_succ _,\n    simp [rename.up, ge, not_le_of_gt this] },\n  { simp [rename.up, ge, nat.succ_le_succ_iff],\n    rw if_distrib (has_add.add 1),\n    simp [nat.add_one],\n    apply if_congr; refl }\nend\n\n@[simp]\nlemma up_instantiate_idx (a d) : (instantiate_idx a d).up = instantiate_idx a (d+1) :=\nbegin\n  apply funext, intro i,\n  simp [instantiate_idx],\n  cases i with i,\n  { have : d + 1 > 0, from nat.zero_lt_succ _,\n    simp [subst.up, not_lt_of_ge (nat.zero_le _), ne_of_lt this] },\n  { simp [subst.up, ge, nat.succ_lt_succ_iff, nat.add_one],\n    by_cases d < i,\n    { have : 0 < i, from lt_of_le_of_lt (nat.zero_le _) h,\n      simp [*, (nat.succ_sub this).symm] },\n    { simp *,\n      by_cases i = d,\n      { simp [*,type.lift,lift_idx,function.comp,nat.zero_le,ge,nat.add_succ] },\n      { have : i.succ ≠ d.succ, from h ∘ nat.succ.inj,\n        simp [*] }\n    }\n  }\nend\n\nsection\nvariables (k d : ℕ)\n@[simp] def type.lift_idx (x : ℕ) : (var x).lift k d = var (lift_idx k d x) := rfl\n@[simp] def type.lift_top : top.lift k d = top := rfl\n@[simp] def type.lift_app (a b) : (a →ₛ b).lift k d = a.lift k d →ₛ b.lift k d := rfl\n@[simp] def type.lift_abs (a b) : (∀0<:a, b).lift k d = ∀0<:a.lift k d, b.lift k (d+1) := by simp [type.lift]\n@[simp] def type.lift_mu (a) : (mu a).lift k d = mu (a.lift k (d+1)) := by simp [type.lift]\n\nvariables (r : type)\n@[simp] def type.instantiate_var (x : ℕ) : (var x).instantiate r d = if d < x then var (x-1) else if x = d then r.lift d else var x := rfl\n@[simp] def type.instantiate_top : top.instantiate r d = top := rfl\n@[simp] def type.instantiate_app (a b) : (a →ₛ b).instantiate r d = a.instantiate r d →ₛ b.instantiate r d := rfl\n@[simp] def type.instantiate_abs (a b) : (∀0<: a, b).instantiate r d = ∀0<:a.instantiate r d, b.instantiate r (d+1) := by simp [type.instantiate]\n@[simp] def type.instantiate_mu (a) : (mu a).instantiate r d = mu (a.instantiate r (d+1)) := by simp [type.instantiate]\nend\n\nlemma sub_insert {e₁ e₂ : env} {a b c} : e₁ ++ e₂ ⊢ a <: b → e₁.lift 1 ++ c::e₂ ⊢ a.lift 1 e₁.length <: b.lift 1 e₁.length :=\nbegin\n  generalize he' : e₁ ++ e₂ = e',\n  intro h, induction h generalizing c e₁,\n  all_goals { simp [lift_idx, -add_comm], try {constructor; done} },\n  case sub.env e' x a b h₁ h₂ ih {\n    subst e',\n    by_cases x ≥ e₁.length,\n    { simp [if_pos h], apply sub.env,\n      { have : ¬ (x + 1 < e₁.length), from\n          λ hcontr, not_lt_of_ge h (nat.lt_of_succ_lt hcontr),\n        simp [list.nth_append, this, nat.sub_add_comm h, -add_comm, list.nth],\n        simp [list.nth_append, if_neg (not_lt_of_ge h)] at h₁,\n        apply h₁ },\n      { have ih := ih rfl,\n        rw lift_lift _ (nat.zero_le _) (nat.le_succ_of_le h) at ih,\n        apply ih }\n    },\n    { simp [if_neg h], apply sub.env,\n      { simp [list.nth_append, lt_of_not_ge h] at ⊢ h₁,\n        -- HACK\n        show _ = some (a.lift 1 (e₁.length - 1 - x)),\n        simp [h₁], refl },\n      { have ih := ih rfl,\n        rw lift_lift2 at ih,\n        { rw [nat.sub_sub, nat.one_add], apply ih },\n        { apply nat.succ_le_of_lt (lt_of_not_ge h) }\n      }\n    }\n  },\n  case sub.abs {\n    have ih_2 := @ih_2 c (a'::e₁),\n    apply sub.abs; simp [*, env.lift] at *\n  },\n  case sub.fun {\n    apply sub.fun (ih_1 he') (ih_2 he')\n  },\n  case sub.expₗ {\n    apply sub.expₗ,\n    simp only [expand_lift],\n    apply ih_1 he'\n  },\n  case sub.expᵣ {\n    apply sub.expᵣ,\n    simp only [expand_lift],\n    apply ih_1 he'\n  }\nend\n\nlemma prod.sub {e : env} {a a' b b'} :\n  e ⊢ a <: a' →\n  e ⊢ b <: b' →\n  e ⊢ a ×ₛ b <: a' ×ₛ b' :=\nbegin\n  intros,\n  repeat {any_goals {constructor}},\n  apply @sub_insert []; assumption,\n  apply @sub_insert []; assumption\nend\n\nlemma {u} list.elem_zip_cons_of_elem_zip {α β : Type u} {a : α} {b : β} {p as bs} : p ∈ list.zip as bs → p ∈ list.zip (a::as) (b::bs) :=\nor.inr\n\nlemma list.sub {e : env} {as as'} : list.length as = list.length as' → (∀ p ∈ as.zip as', e ⊢ prod.fst p <: p.2) → e ⊢ tuple as <: tuple as' :=\nbegin\n  intros hlen helem, induction as generalizing as',\n  { cases as', {constructor}, {contradiction} },\n  { cases as', {contradiction},\n    simp [tuple],\n    apply prod.sub,\n    { apply helem (a, a_2), simp [list.zip, list.zip_with] },\n    { simp [list.length] at hlen, apply ih_1 (eq_of_add_eq_add_left hlen),\n      intros p hp, apply helem p (list.elem_zip_cons_of_elem_zip hp), }\n  }\nend\n\n@[simp]\nlemma lift_tuple (as k d) : (tuple as).lift k d = tuple (as.map (λ a, a.lift k d)) :=\nbegin\n  induction as generalizing d,\n  { refl },\n  { simp [tuple, prod, lift_idx, lift_lift2, *, ge, not_le_of_gt (nat.zero_lt_succ _)] }\nend\n\n@[simp]\nlemma instantiate_idx_lift_idx (i b d) : instantiate_idx b (d + 1) (lift_idx 1 0 i) = type.rename (lift_idx 1) (instantiate_idx b d i) :=\nbegin\n  simp [instantiate_idx, lift_idx, ge, nat.zero_le, nat.add_one, nat.succ_lt_succ_iff],\n  by_cases d < i,\n  { have : 0 < i, from lt_of_le_of_lt (nat.zero_le _) ‹d < i›,\n    simp [*, has_sub.sub, nat.sub, nat.succ_pred_eq_of_pos this] },\n  { simp [*],\n    by_cases i = d,\n    { simp [*, type.lift, lift_idx, function.comp, ge, nat.zero_le, nat.add_succ] },\n    { simp [*, show i.succ ≠ d.succ, from h ∘ nat.succ.inj] }\n  }\nend\n\n@[simp]\nlemma instantiate_tuple (as b d) : (tuple as).instantiate b d = tuple (as.map (λ a, a.instantiate b d)) :=\nbegin\n  generalize h : as.length = l,\n  induction l generalizing as b d,\n  { simp [list.eq_nil_of_length_eq_zero h], refl },\n  { cases as,\n    { contradiction },\n    { rw list.length at h, injection h with h,\n      simp [tuple, prod, nat.not_lt_zero],\n      rw ih_1 _ b (d+1),\n      { have : 0 ≠ d + 1, by intro hcontr; injection hcontr,\n        simp [*, type.instantiate, type.lift, function.comp, list.length_map] },\n      { simp [*, list.length_map] }\n    }\n  }\nend\n\nlemma instantiate_record (b fs) : (record fs).instantiate b = record (fs.map (λ ⟨i, a⟩, ⟨i, a.instantiate b⟩)) :=\nbegin\n  simp [record, record_list],\n  congr,\n  { apply funext, intro i,\n    induction fs,\n    { refl },\n    { simp [list.find], cases a,\n      simp,\n      by_cases idx = i,\n      { simp [function.comp, h, option.get_or_else, has_map.map, option.map, option.bind] },\n      { simp [function.comp, h], apply ih_1 },\n    }\n  },\n  { apply funext, intro a, cases a with idx ty,\n    simp }\nend\n\nlemma record.sub {e} {fs fs' : list field} :\n  (record_list fs).length ≥ (record_list fs').length →\n  (∀ p : _ × _, p ∈ (record_list fs).zip (record_list fs') → e ⊢ p.1 <: p.2) →\n  e ⊢ record fs <: record fs' :=\nbegin\n  simp [record],\n  generalize : record_list fs = rfs,\n  induction record_list fs' generalizing rfs,\n  all_goals { intros hlen helem },\n  case list.nil {\n    cases rfs,\n    { apply sub.refl },\n    { simp [tuple], apply prod.sub; apply sub.top }\n  },\n  case list.cons {\n    cases rfs,\n    { cases hlen },\n    { simp [tuple], apply prod.sub,\n      { apply helem, simp [list.zip, list.zip_with] },\n      { apply ih_1,\n        { simp at hlen, apply le_of_add_le_add_left hlen },\n        { intros a b hab, apply helem a b (list.elem_zip_cons_of_elem_zip hab) }\n      }\n    }\n  }\nend\n\nlemma lift_free_range {t : type} (k m) : t.free_range ≤ m → t.lift k m = t :=\nbegin\n  induction t generalizing m,\n  all_goals { simp [type.free_range] },\n  { intro h,  simp [lift_idx, ge, not_le_of_gt (nat.lt_of_succ_le h)] },\n  { intro h,\n    have := ih_1 m (le_trans (le_max_left _ _) h),\n    rw [this],\n    have := ih_2 m (le_trans (le_max_right _ _) h),\n    rw [this] },\n  { intro h,\n    have := ih_1 m (le_trans (le_max_left _ _) h),\n    rw [this],\n    have : body.lift k (m+1) = body, {\n      apply ih_2 (m+1),\n      have : body.free_range - 1 ≤ m, from le_trans (le_max_right _ _) h,\n      show body.free_range ≤ m + 1, from nat.le_succ_of_pred_le this,\n    },\n    rw [this] },\n  { intro h,\n    have := ih_1 (m+1) (nat.le_succ_of_pred_le h),\n    rw [this] }\nend\n\nlemma lift_closed {t : type} (k) : t.closed → (t.lift k) = t :=\nbegin\n  intro h, apply lift_free_range,\n  simp [type.closed] at h, simp [h]\nend\n\nlemma left_le_of_max_le {a b c : ℕ} : max a b ≤ c → a ≤ c :=\nbegin\n  intro h,\n  by_cases a ≤ b with ab,\n  { simp [max, ab] at h, apply le_trans ab h },\n  { simp [max, ab] at h, apply h }\nend\n\nlemma right_le_of_max_le {a b c : ℕ} : max a b ≤ c → b ≤ c :=\nbegin\n  intro h,\n  by_cases a ≤ b with ab,\n  { simp [max, ab] at h, apply h },\n  { simp [max, ab] at h, apply le_trans (le_of_not_le ab) h }\nend\n\nlemma instantiate_free_range {t t' : type} {d} : t.free_range ≤ d → t.instantiate t' d = t :=\nbegin\n  induction t generalizing d,\n  all_goals { simp [type.free_range] },\n  { intro h,\n    have : idx < d, from nat.lt_of_succ_le h,\n    simp [lift_idx, instantiate_idx, ne_of_lt this, not_lt_of_gt this] },\n  { intro h, rw[ih_1 (le_trans (left_le_of_max_le h) (le_refl _)),\n                ih_2 (le_trans (right_le_of_max_le h) (le_refl _))] },\n  { intro h, rw[ih_1 (le_trans (left_le_of_max_le h) (le_refl _)),\n                ih_2 (le_trans (nat.le_succ_of_pred_le (right_le_of_max_le h)) (le_refl _))] },\n  { intro h, rw[ih_1 (le_trans (nat.le_succ_of_pred_le h) (le_refl _))] },\nend\n\n@[simp]\nlemma instantiate_closed {t t' : type} : t.closed → t.instantiate t' = t :=\nbegin\n  intro h, apply instantiate_free_range,\n  simp [type.closed] at h, simp [h]\nend\n\n/- A tactic for reducing record relations to field-wise relations -/\n\nsection\nprivate meta def go :=\n`[simp [record_list, list.range, list.range_core, list.find,\n        option.get_or_else, list.zip, list.zip_with, max_eq_left, max_eq_right]\n       at h {fail_if_unchanged:=ff},\n  do {\n    h ← tactic.get_local `h >>= tactic.infer_type,\n    match h with\n    | `(_ ∨ _) := `[\n        cases h with h h,\n        tactic.swap,\n        go]\n    | _ := tactic.skip\n    end\n  }]\n\nmeta def record.fieldwise_eq : tactic unit :=\n`[apply record.sub,\n  { exact dec_trivial },\n  intros p h,\n  cases p with a b,\n  go,\n  all_goals { simp [h] }]\n\nrun_cmd add_interactive [``record.fieldwise_eq]\nend\n\nsection\n\nattribute [reducible] lift_t coe_to_lift coe_t coe_option\n\n@[simp] def labels.a := 0\n@[simp] def labels.b := 1\n@[simp] def labels.c := 2\n\ndef foo := ⟦ₛ { a := Bool, b := top } ⟧\ndef bar := ⟦ₛ { a := Bool, b := Bool, c := Bool } ⟧\n\nexample : bar <: foo :=\nrecord.sub dec_trivial (λ ⟨a, b⟩ h, begin\n  conv at h {\n    change (a, b) = (Bool, Bool) ∨ _,\n    simp,\n  },\n  cases h with h h; simp [h],\n  { apply sub.refl },\n  { apply sub.top },\nend)\n\ndef A := ⟦ₛ { a := Bool } ⟧\ndef B := ⟦ₛ ∀ α <: A, μ β, { a := Bool, b := Bool → α → β } ⟧\ndef C := ⟦ₛ ∀ α <: A, { a := Bool, b := Bool → α → A } ⟧\n\n@[simp] lemma A.is_closed : A.closed :=\nshow A.free_range = 0, from rfl\n\nexample : B <: C :=\nbegin\n  suffices : ⟦ₛ bctx α <: A ⊢\n    (μ β, { a := Bool, b := Bool → α → β }) <:\n          { a := Bool, b := Bool → α → A } ⟧,\n    from sub.abs (sub.refl _ _) this,\n  suffices : ⟦ₛ bctx α <: A ⊢\n    { a := Bool, b := Bool → α → μ β, { a := Bool, b := Bool → α → β } } <:\n    { a := Bool, b := Bool → α → A } ⟧,\n    from sub.expₗ this,\n  record.fieldwise_eq,\n  show ⟦ₛ bctx α <: A ⊢\n    (Bool → α → μ β, { a := Bool, b := Bool → α → β }) <:\n    (Bool → α → A) ⟧,\n  { suffices : ⟦ₛ bctx α <: A ⊢ (μ β, { a := Bool, b := Bool → α → β }) <: A ⟧,\n      by simp at this; simp [sub.fun, sub.refl, this],\n    suffices : ⟦ₛ bctx α <: A ⊢ { a := Bool, b := Bool → α → (μ β, { a := Bool, b := Bool → α → β }) } <: A ⟧,\n      from sub.expₗ this,\n    simp [lift_closed],\n    record.fieldwise_eq,\n    show [A] ⊢ Bool <: Bool, from sub.refl _ _\n  },\n  show [A] ⊢ Bool <: Bool, from sub.refl _ _\nend\nend\n\nend system_f_sub\n\n/- Unused experiments -/\n\nsection\nopen lean\nopen lean.parser\nopen interactive\nopen interactive.types\nopen tactic\n\n@[user_command]\nmeta def extend_inductive_cmd (dmi : decl_meta_info) (_ : parse $ tk \"extend_inductive\") : parser unit :=\ndo base ← ident,\n   base ← resolve_constant base,\n   env ← get_env,\n   guard (env.is_inductive base) <|> fail \"expected inductive type\",\n   tk \"with\",\n   decl ← inductive_decl.parse dmi,\n   [idecl] ← pure decl.decls | fail \"mutual inductives not supported\",\n   let new := idecl.sig.app_fn.local_uniq_name,\n   let ls : list name := [], -- TODO\n   let p := env.inductive_num_params base,\n   ty ← declaration.type <$> env.get base,\n   is ← (env.constructors_of base).mmap (λ ctor,\n     do ty ← declaration.type <$> env.get ctor,\n     let ty := ty.replace (λ e _, match e with\n     | expr.const n ls := if n = base then some (expr.const new ls) else none\n     | _ := none\n     end) in\n     pure (new ++ ctor.components.ilast, ty)),\n   let is := is ++ idecl.intros.map (λ e, (e.local_uniq_name, e.local_type)),\n   set_env $ env.add_namespace new,\n   add_inductive new ls p ty is\n\nmeta def dunfold_productive (cfg : delta_config := {}) : conv unit :=\nlet unfold (u : unit) (e : expr) : tactic (unit × expr × bool) := do\n  (expr.const f_name _) ← return e.get_app_fn,\n  es ← get_eqn_lemmas_for ff f_name,\n  guard $ es.length > 1,\n  sl ← es.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n  new_e ← sl.drewrite e,\n  return (u, new_e, tt)\nin do e ← target,\n      (c, new_e) ← dsimplify_core () (λ c e, failed) unfold e {max_steps := cfg.max_steps, canonize_instances := cfg.visit_instances},\n      change new_e\n\nmeta def delta_target (cs : list name) (cfg : delta_config := {}) : tactic unit :=\ndo t ← target, delta cs t cfg >>= unsafe_change\n\nrun_cmd add_interactive [`dunfold_productive] `conv.interactive\nend\n", "meta": {"author": "Kha", "repo": "system_f_sub", "sha": "66b726d47b279de535e6ec9bdc57dd2445ebf750", "save_path": "github-repos/lean/Kha-system_f_sub", "path": "github-repos/lean/Kha-system_f_sub/system_f_sub-66b726d47b279de535e6ec9bdc57dd2445ebf750/system_f_sub.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6297746143530797, "lm_q1q2_score": 0.45650489863527016}}
{"text": "/-\nCopyright (c) 2020 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz, Bhavik Mehta\n-/\n\nimport category_theory.adjunction.reflective\nimport topology.category.Top\nimport topology.stone_cech\nimport category_theory.monad.limits\nimport topology.urysohns_lemma\n\n/-!\n# The category of Compact Hausdorff Spaces\n\nWe construct the category of compact Hausdorff spaces.\nThe type of compact Hausdorff spaces is denoted `CompHaus`, and it is endowed with a category\ninstance making it a full subcategory of `Top`.\nThe fully faithful functor `CompHaus ⥤ Top` is denoted `CompHaus_to_Top`.\n\n**Note:** The file `topology/category/Compactum.lean` provides the equivalence between `Compactum`,\nwhich is defined as the category of algebras for the ultrafilter monad, and `CompHaus`.\n`Compactum_to_CompHaus` is the functor from `Compactum` to `CompHaus` which is proven to be an\nequivalence of categories in `Compactum_to_CompHaus.is_equivalence`.\nSee `topology/category/Compactum.lean` for a more detailed discussion where these definitions are\nintroduced.\n\n-/\n\nuniverses v u\n\nopen category_theory\n\n/-- The type of Compact Hausdorff topological spaces. -/\nstructure CompHaus :=\n(to_Top : Top)\n[is_compact : compact_space to_Top]\n[is_hausdorff : t2_space to_Top]\n\nnamespace CompHaus\n\ninstance : inhabited CompHaus := ⟨{to_Top := { α := pempty }}⟩\n\ninstance : has_coe_to_sort CompHaus Type* := ⟨λ X, X.to_Top⟩\ninstance {X : CompHaus} : compact_space X := X.is_compact\ninstance {X : CompHaus} : t2_space X := X.is_hausdorff\n\ninstance category : category CompHaus := induced_category.category to_Top\n\ninstance concrete_category : concrete_category CompHaus :=\ninduced_category.concrete_category _\n\n@[simp]\nlemma coe_to_Top {X : CompHaus} : (X.to_Top : Type*) = X :=\nrfl\n\nvariables (X : Type*) [topological_space X] [compact_space X] [t2_space X]\n\n/-- A constructor for objects of the category `CompHaus`,\ntaking a type, and bundling the compact Hausdorff topology\nfound by typeclass inference. -/\ndef of : CompHaus :=\n{ to_Top := Top.of X,\n  is_compact := ‹_›,\n  is_hausdorff := ‹_› }\n\n@[simp] lemma coe_of : (CompHaus.of X : Type _) = X := rfl\n\n/-- Any continuous function on compact Hausdorff spaces is a closed map. -/\nlemma is_closed_map {X Y : CompHaus.{u}} (f : X ⟶ Y) : is_closed_map f :=\nλ C hC, (hC.is_compact.image f.continuous).is_closed\n\n/-- Any continuous bijection of compact Hausdorff spaces is an isomorphism. -/\nlemma is_iso_of_bijective {X Y : CompHaus.{u}} (f : X ⟶ Y) (bij : function.bijective f) :\n  is_iso f :=\nbegin\n  let E := equiv.of_bijective _ bij,\n  have hE : continuous E.symm,\n  { rw continuous_iff_is_closed,\n    intros S hS,\n    rw ← E.image_eq_preimage,\n    exact is_closed_map f S hS },\n  refine ⟨⟨⟨E.symm, hE⟩, _, _⟩⟩,\n  { ext x,\n    apply E.symm_apply_apply },\n  { ext x,\n    apply E.apply_symm_apply }\nend\n\n/-- Any continuous bijection of compact Hausdorff spaces induces an isomorphism. -/\nnoncomputable\ndef iso_of_bijective {X Y : CompHaus.{u}} (f : X ⟶ Y) (bij : function.bijective f) : X ≅ Y :=\nby letI := is_iso_of_bijective _ bij; exact as_iso f\n\nend CompHaus\n\n/-- The fully faithful embedding of `CompHaus` in `Top`. -/\n@[simps {rhs_md := semireducible}, derive [full, faithful]]\ndef CompHaus_to_Top : CompHaus.{u} ⥤ Top.{u} := induced_functor _\n\ninstance CompHaus.forget_reflects_isomorphisms : reflects_isomorphisms (forget CompHaus.{u}) :=\n⟨by introsI A B f hf; exact CompHaus.is_iso_of_bijective _ ((is_iso_iff_bijective f).mp hf)⟩\n\n/--\n(Implementation) The object part of the compactification functor from topological spaces to\ncompact Hausdorff spaces.\n-/\n@[simps]\ndef StoneCech_obj (X : Top) : CompHaus := CompHaus.of (stone_cech X)\n\n/--\n(Implementation) The bijection of homsets to establish the reflective adjunction of compact\nHausdorff spaces in topological spaces.\n-/\nnoncomputable def stone_cech_equivalence (X : Top.{u}) (Y : CompHaus.{u}) :\n  (StoneCech_obj X ⟶ Y) ≃ (X ⟶ CompHaus_to_Top.obj Y) :=\n{ to_fun := λ f,\n  { to_fun := f ∘ stone_cech_unit,\n    continuous_to_fun := f.2.comp (@continuous_stone_cech_unit X _) },\n  inv_fun := λ f,\n  { to_fun := stone_cech_extend f.2,\n    continuous_to_fun := continuous_stone_cech_extend f.2 },\n  left_inv :=\n  begin\n    rintro ⟨f : stone_cech X ⟶ Y, hf : continuous f⟩,\n    ext (x : stone_cech X),\n    refine congr_fun _ x,\n    apply continuous.ext_on dense_range_stone_cech_unit (continuous_stone_cech_extend _) hf,\n    rintro _ ⟨y, rfl⟩,\n    apply congr_fun (stone_cech_extend_extends (hf.comp _)) y,\n  end,\n  right_inv :=\n  begin\n    rintro ⟨f : (X : Type*) ⟶ Y, hf : continuous f⟩,\n    ext,\n    exact congr_fun (stone_cech_extend_extends hf) _,\n  end }\n\n/--\nThe Stone-Cech compactification functor from topological spaces to compact Hausdorff spaces,\nleft adjoint to the inclusion functor.\n-/\nnoncomputable def Top_to_CompHaus : Top.{u} ⥤ CompHaus.{u} :=\nadjunction.left_adjoint_of_equiv stone_cech_equivalence.{u} (λ _ _ _ _ _, rfl)\n\nlemma Top_to_CompHaus_obj (X : Top) : ↥(Top_to_CompHaus.obj X) = stone_cech X :=\nrfl\n\n/--\nThe category of compact Hausdorff spaces is reflective in the category of topological spaces.\n-/\nnoncomputable instance CompHaus_to_Top.reflective : reflective CompHaus_to_Top :=\n{ to_is_right_adjoint := ⟨Top_to_CompHaus, adjunction.adjunction_of_equiv_left _ _⟩ }\n\nnoncomputable instance CompHaus_to_Top.creates_limits : creates_limits CompHaus_to_Top :=\nmonadic_creates_limits _\n\ninstance CompHaus.has_limits : limits.has_limits CompHaus :=\nhas_limits_of_has_limits_creates_limits CompHaus_to_Top\n\ninstance CompHaus.has_colimits : limits.has_colimits CompHaus :=\nhas_colimits_of_reflective CompHaus_to_Top\n\nnamespace CompHaus\n\n/-- An explicit limit cone for a functor `F : J ⥤ CompHaus`, defined in terms of\n`Top.limit_cone`. -/\ndef limit_cone {J : Type v} [small_category J] (F : J ⥤ CompHaus.{max v u}) :\n  limits.cone F :=\n{ X :=\n  { to_Top := (Top.limit_cone (F ⋙ CompHaus_to_Top)).X,\n    is_compact := begin\n      show compact_space ↥{u : Π j, (F.obj j) | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j},\n      rw ← is_compact_iff_compact_space,\n      apply is_closed.is_compact,\n      have : {u : Π j, F.obj j | ∀ {i j : J} (f : i ⟶ j), F.map f (u i) = u j} =\n        ⋂ (i j : J) (f : i ⟶ j), {u | F.map f (u i) = u j},\n      { ext1, simp only [set.mem_Inter, set.mem_set_of_eq], },\n      rw this,\n      apply is_closed_Inter, intros i,\n      apply is_closed_Inter, intros j,\n      apply is_closed_Inter, intros f,\n      apply is_closed_eq,\n      { exact (continuous_map.continuous (F.map f)).comp (continuous_apply i), },\n      { exact continuous_apply j, }\n    end,\n    is_hausdorff :=\n      show t2_space ↥{u : Π j, (F.obj j) | ∀ {i j : J} (f : i ⟶ j), (F.map f) (u i) = u j},\n      from infer_instance },\n  π :=\n  { app := λ j, (Top.limit_cone (F ⋙ CompHaus_to_Top)).π.app j,\n    naturality' := by { intros _ _ _, ext ⟨x, hx⟩,\n      simp only [comp_apply, functor.const.obj_map, id_apply], exact (hx f).symm, } } }\n\n/-- The limit cone `CompHaus.limit_cone F` is indeed a limit cone. -/\ndef limit_cone_is_limit {J : Type v} [small_category J] (F : J ⥤ CompHaus.{max v u}) :\n  limits.is_limit (limit_cone F) :=\n{ lift := λ S,\n    (Top.limit_cone_is_limit (F ⋙ CompHaus_to_Top)).lift (CompHaus_to_Top.map_cone S),\n  uniq' := λ S m h, (Top.limit_cone_is_limit _).uniq (CompHaus_to_Top.map_cone S) _ h }\n\nlemma epi_iff_surjective {X Y : CompHaus.{u}} (f : X ⟶ Y) : epi f ↔ function.surjective f :=\nbegin\n  split,\n  { contrapose!,\n    rintros ⟨y, hy⟩ hf,\n    let C := set.range f,\n    have hC : is_closed C := (is_compact_range f.continuous).is_closed,\n    let D := {y},\n    have hD : is_closed D := is_closed_singleton,\n    have hCD : disjoint C D,\n    { rw set.disjoint_singleton_right, rintro ⟨y', hy'⟩, exact hy y' hy' },\n    haveI : normal_space ↥(Y.to_Top) := normal_of_compact_t2,\n    obtain ⟨φ, hφ0, hφ1, hφ01⟩ := exists_continuous_zero_one_of_closed hC hD hCD,\n    haveI : compact_space (ulift.{u} $ set.Icc (0:ℝ) 1) := homeomorph.ulift.symm.compact_space,\n    haveI : t2_space (ulift.{u} $ set.Icc (0:ℝ) 1) := homeomorph.ulift.symm.t2_space,\n    let Z := of (ulift.{u} $ set.Icc (0:ℝ) 1),\n    let g : Y ⟶ Z := ⟨λ y', ⟨⟨φ y', hφ01 y'⟩⟩,\n      continuous_ulift_up.comp (continuous_subtype_mk (λ y', hφ01 y') φ.continuous)⟩,\n    let h : Y ⟶ Z := ⟨λ _, ⟨⟨0, set.left_mem_Icc.mpr zero_le_one⟩⟩, continuous_const⟩,\n    have H : h = g,\n    { rw ← cancel_epi f,\n      ext x, dsimp,\n      simp only [comp_apply, continuous_map.coe_mk, subtype.coe_mk, hφ0 (set.mem_range_self x),\n        pi.zero_apply], },\n    apply_fun (λ e, (e y).down) at H,\n    dsimp at H,\n    simp only [subtype.mk_eq_mk, hφ1 (set.mem_singleton y), pi.one_apply] at H,\n    exact zero_ne_one H, },\n  { rw ← category_theory.epi_iff_surjective,\n    apply faithful_reflects_epi (forget CompHaus) },\nend\n\nlemma mono_iff_injective {X Y : CompHaus.{u}} (f : X ⟶ Y) : mono f ↔ function.injective f :=\nbegin\n  split,\n  { introsI hf x₁ x₂ h,\n    let g₁ : of punit ⟶ X := ⟨λ _, x₁, continuous_of_discrete_topology⟩,\n    let g₂ : of punit ⟶ X := ⟨λ _, x₂, continuous_of_discrete_topology⟩,\n    have : g₁ ≫ f = g₂ ≫ f, by { ext, exact h },\n    rw cancel_mono at this,\n    apply_fun (λ e, e punit.star) at this,\n    exact this },\n  { rw ← category_theory.mono_iff_injective,\n    apply faithful_reflects_mono (forget CompHaus) }\nend\n\nend CompHaus\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/topology/category/CompHaus/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.45650489604773475}}
{"text": "-- Copyright © 2019 François G. Dorais. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n\nimport .basic\nimport .magma\n\nnamespace algebra\n\nsignature unital (α : Type*) :=\n(op : α → α → α)\n(id : α)\n\nnamespace unital_sig\nvariables {α : Type*} (s : unital_sig α)\n\n@[signature_instance]\ndefinition to_magma : magma_sig α :=\n{ op := s.op\n}\n\nend unital_sig\n\nvariables {α : Type*} (s : unital_sig α)\nlocal infix ∙ := s.op\nlocal notation `e` := s.id\n\n@[theory]\nclass unital : Prop := intro ::\n(left_identity : identity.op_left_identity s.op s.id)\n(right_identity : identity.op_right_identity s.op s.id)\n\nnamespace unital\nvariable [i : unital s]\ninclude i\n\ninstance to_magma : magma s.to_magma := magma.infer _\n\nend unital\n\n@[theory]\nclass cancel_unital : Prop := intro ::\n(left_cancellative : identity.op_left_cancellative s.op)\n(right_cancellative : identity.op_right_cancellative s.op)\n(left_identity : identity.op_left_identity s.op s.id)\n(right_identity : identity.op_right_identity s.op s.id)\n\nnamespace cancel_unital\nvariable [i : cancel_unital s]\ninclude i\n\ninstance to_cancel_magma : cancel_magma s.to_magma := cancel_magma.infer _\n\nend cancel_unital\n\n@[theory]\nclass comm_unital : Prop := intro ::\n(commutative : identity.op_commutative s.op)\n(right_identity : identity.op_right_identity s.op s.id)\n\nnamespace comm_unital\nvariable [i : comm_unital s]\ninclude i\n\n@[identity_instance]\ntheorem left_identity : identity.op_left_identity s.op s.id :=\nλ x, show e ∙ x = x, from calc _\n= x ∙ e : by rw op_commutative s.op ...\n= x : by rw op_right_identity s.op\n\ninstance to_unital : unital s := unital.infer _\n\ninstance to_comm_magma : comm_magma s.to_magma := comm_magma.infer _\n\nend comm_unital\n\n@[theory]\nclass cancel_comm_unital : Prop := intro ::\n(commutative : identity.op_commutative s.op)\n(right_identity : identity.op_right_identity s.op s.id)\n(right_cancellative : identity.op_right_cancellative s.op)\n\nnamespace cancel_comm_unital\nvariables [i : cancel_comm_unital s]\ninclude i\n\ninstance to_comm_unital : comm_unital s := comm_unital.infer _\n\ninstance to_cancel_comm_magma : cancel_comm_magma s.to_magma := cancel_comm_magma.infer _\n\ninstance to_cancel_unital : cancel_unital s := cancel_unital.infer _\n\nend cancel_comm_unital\n\nend algebra\n", "meta": {"author": "fgdorais", "repo": "lean-universal", "sha": "9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1", "save_path": "github-repos/lean/fgdorais-lean-universal", "path": "github-repos/lean/fgdorais-lean-universal/lean-universal-9259b0f7fb3aa83a9e0a7a3eaa44c262e42cc9b1/src/algebra/theories/unital.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4565048935983886}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Bhavik Mehta\n-/\nimport category_theory.structured_arrow\nimport category_theory.punit\nimport category_theory.functor.reflects_isomorphisms\nimport category_theory.epi_mono\n\n/-!\n# Over and under categories\n\nOver (and under) categories are special cases of comma categories.\n* If `L` is the identity functor and `R` is a constant functor, then `comma L R` is the \"slice\" or\n  \"over\" category over the object `R` maps to.\n* Conversely, if `L` is a constant functor and `R` is the identity functor, then `comma L R` is the\n  \"coslice\" or \"under\" category under the object `L` maps to.\n\n## Tags\n\ncomma, slice, coslice, over, under\n-/\n\nnamespace category_theory\n\nuniverses v₁ v₂ u₁ u₂ -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u₁} [category.{v₁} T]\n\n/--\nThe over category has as objects arrows in `T` with codomain `X` and as morphisms commutative\ntriangles.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\n@[derive category]\ndef over (X : T) := costructured_arrow (𝟭 T) X\n\n-- Satisfying the inhabited linter\ninstance over.inhabited [inhabited T] : inhabited (over (default : T)) :=\n{ default :=\n  { left := default,\n    hom := 𝟙 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U ⟶ V}\n  (h : f.left = g.left) : f = g :=\nby tidy\n\n@[simp] lemma over_right (U : over X) : U.right = punit.star := by tidy\n\n@[simp] lemma id_left (U : over X) : comma_morphism.left (𝟙 U) = 𝟙 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).left = f.left ≫ g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A ⟶ B) : f.left ≫ B.hom = A.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/\n@[simps]\ndef mk {X Y : T} (f : Y ⟶ X) : over X :=\ncostructured_arrow.mk f\n\n/-- We can set up a coercion from arrows with codomain `X` to `over X`. This most likely should not\n    be a global instance, but it is sometimes useful. -/\ndef coe_from_hom {X Y : T} : has_coe (Y ⟶ X) (over X) :=\n{ coe := mk }\n\nsection\nlocal attribute [instance] coe_from_hom\n\n@[simp] lemma coe_hom {X Y : T} (f : Y ⟶ X) : (f : over X).hom = f := rfl\nend\n\n/-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative\n    triangle. -/\n@[simps]\ndef hom_mk {U V : over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom . obviously) :\n  U ⟶ V :=\ncostructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\n@[simps]\ndef iso_mk {f g : over X} (hl : f.left ≅ g.left) (hw : hl.hom ≫ g.hom = f.hom . obviously) :\n  f ≅ g :=\ncostructured_arrow.iso_mk hl hw\n\nsection\nvariable (X)\n/--\nThe forgetful functor mapping an arrow to its domain.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef forget : over X ⥤ T := comma.fst _ _\n\nend\n\n@[simp] lemma forget_obj {U : over X} : (forget X).obj U = U.left := rfl\n@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : (forget X).map f = f.left := rfl\n\n/-- The natural cocone over the forgetful functor `over X ⥤ T` with cocone point `X`. -/\n@[simps] def forget_cocone (X : T) : limits.cocone (forget X) :=\n{ X := X, ι := { app := comma.hom } }\n\n/--\nA morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef map {Y : T} (f : X ⟶ Y) : over X ⥤ over Y := comma.map_right _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : over X} {g : U ⟶ V}\n@[simp] lemma map_obj_left : ((map f).obj U).left = U.left := rfl\n@[simp] lemma map_obj_hom  : ((map f).obj U).hom  = U.hom ≫ f := rfl\n@[simp] lemma map_map_left : ((map f).map g).left = g.left := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map f ⋙ map g :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := λ Y Z f t, by exactI\n  ⟨⟨over.hom_mk (inv ((forget X).map f))\n      ((as_iso ((forget X).map f)).inv_comp_eq.2 (over.w f).symm),\n    by tidy⟩⟩ }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\n/--\nIf `k.left` is an epimorphism, then `k` is an epimorphism. In other words, `over.forget X` reflects\nepimorphisms.\nThe converse does not hold without additional assumptions on the underlying category.\n-/\n-- TODO: Show the converse holds if `T` has binary products or pushouts.\nlemma epi_of_epi_left {f g : over X} (k : f ⟶ g) [hk : epi k.left] : epi k :=\nfaithful_reflects_epi (forget X) hk\n\n/--\nIf `k.left` is a monomorphism, then `k` is a monomorphism. In other words, `over.forget X` reflects\nmonomorphisms.\nThe converse of `category_theory.over.mono_left_of_mono`.\n\nThis lemma is not an instance, to avoid loops in type class inference.\n-/\nlemma mono_of_mono_left {f g : over X} (k : f ⟶ g) [hk : mono k.left] : mono k :=\nfaithful_reflects_mono (forget X) hk\n\n/--\nIf `k` is a monomorphism, then `k.left` is a monomorphism. In other words, `over.forget X` preserves\nmonomorphisms.\nThe converse of `category_theory.over.mono_of_mono_left`.\n-/\ninstance mono_left_of_mono {f g : over X} (k : f ⟶ g) [mono k] : mono k.left :=\nbegin\n  refine ⟨λ (Y : T) l m a, _⟩,\n  let l' : mk (m ≫ f.hom) ⟶ f := hom_mk l (by { dsimp, rw [←over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw ← cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y ⟶ X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f ⥤ over f.left :=\n{ obj := λ α, over.mk α.hom.left,\n  map := λ α β κ, over.hom_mk κ.left.left (by { rw auto_param_eq, rw ← over.w κ, refl }) }\n\n/-- Given f : Y ⟶ X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left ⥤ over f :=\n{ obj := λ g, mk (hom_mk g.hom : mk (g.hom ≫ f.hom) ⟶ f),\n  map := λ g h α, hom_mk (hom_mk α.left (w_assoc α f.hom)) (over_morphism.ext (w α)) }\n\n/-- Given f : Y ⟶ X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f ≌ over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (λ g, over.iso_mk (iso.refl _) (by tidy))\n    (λ X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f ⋙ forget f.left = forget f ⋙ forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f ⋙ forget f ⋙ forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `over X ⥤ over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T ⥤ D) : over X ⥤ over (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { left := F.map f.left,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend over\n\n/-- The under category has as objects arrows with domain `X` and as morphisms commutative\n    triangles. -/\n@[derive category]\ndef under (X : T) := structured_arrow X (𝟭 T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default : T)) :=\n{ default :=\n  { right := default,\n    hom := 𝟙 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U ⟶ V}\n  (h : f.right = g.right) : f = g :=\nby tidy\n\n@[simp] lemma under_left (U : under X) : U.left = punit.star := by tidy\n\n@[simp] lemma id_right (U : under X) : comma_morphism.right (𝟙 U) = 𝟙 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a ⟶ b) (g : b ⟶ c) :\n  (f ≫ g).right = f.right ≫ g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A ⟶ B) : A.hom ≫ f.right = B.hom :=\nby have := f.w; tidy\n\n/-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/\n@[simps]\ndef mk {X Y : T} (f : X ⟶ Y) : under X :=\nstructured_arrow.mk f\n\n/-- To give a morphism in the under category, it suffices to give a morphism fitting in a\n    commutative triangle. -/\n@[simps]\ndef hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom . obviously) :\n  U ⟶ V :=\nstructured_arrow.hom_mk f w\n\n/--\nConstruct an isomorphism in the over category given isomorphisms of the objects whose forward\ndirection gives a commutative triangle.\n-/\ndef iso_mk {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) : f ≅ g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).hom.right = hr.hom := rfl\n\n@[simp]\nlemma iso_mk_inv_right {f g : under X} (hr : f.right ≅ g.right) (hw : f.hom ≫ hr.hom = g.hom) :\n  (iso_mk hr hw).inv.right = hr.inv := rfl\n\nsection\nvariables (X)\n/-- The forgetful functor mapping an arrow to its domain. -/\ndef forget : under X ⥤ T := comma.snd _ _\n\nend\n\n@[simp] lemma forget_obj {U : under X} : (forget X).obj U = U.right := rfl\n@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : (forget X).map f = f.right := rfl\n\n/-- The natural cone over the forgetful functor `under X ⥤ T` with cone point `X`. -/\n@[simps] def forget_cone (X : T) : limits.cone (forget X) :=\n{ X := X, π := { app := comma.hom } }\n\n/-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/\ndef map {Y : T} (f : X ⟶ Y) : under Y ⥤ under X := comma.map_left _ $ discrete.nat_trans (λ _, f)\n\nsection\nvariables {Y : T} {f : X ⟶ Y} {U V : under Y} {g : U ⟶ V}\n@[simp] lemma map_obj_right : ((map f).obj U).right = U.right := rfl\n@[simp] lemma map_obj_hom   : ((map f).obj U).hom   = f ≫ U.hom := rfl\n@[simp] lemma map_map_right : ((map f).map g).right = g.right := rfl\n\n/-- Mapping by the identity morphism is just the identity functor. -/\ndef map_id : map (𝟙 Y) ≅ 𝟭 _ :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f ≫ g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=\nnat_iso.of_components (λ X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := λ Y Z f t, by exactI\n  ⟨⟨under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm),\n    by tidy⟩⟩ }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\nsection\nvariables {D : Type u₂} [category.{v₂} D]\n\n/-- A functor `F : T ⥤ D` induces a functor `under X ⥤ under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T ⥤ D) : under X ⥤ under (F.obj X) :=\n{ obj := λ Y, mk $ F.map Y.hom,\n  map := λ Y₁ Y₂ f,\n  { right := F.map f.right,\n    w' := by tidy; erw [← F.map_comp, w] } }\n\nend\n\nend under\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/over.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4565048935983886}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard,\nAmelia Livingston, Yury Kudryashov\n-/\n\nimport group_theory.submonoid.basic\nimport data.equiv.mul_add\nimport algebra.group.prod\nimport algebra.group.inj_surj\nimport group_theory.group_action.defs\n\n/-!\n# Operations on `submonoid`s\n\nIn this file we define various operations on `submonoid`s and `monoid_hom`s.\n\n## Main definitions\n\n### Conversion between multiplicative and additive definitions\n\n* `submonoid.to_add_submonoid`, `submonoid.to_add_submonoid'`, `add_submonoid.to_submonoid`,\n  `add_submonoid.to_submonoid'`: convert between multiplicative and additive submonoids of `M`,\n  `multiplicative M`, and `additive M`. These are stated as `order_iso`s.\n\n### (Commutative) monoid structure on a submonoid\n\n* `submonoid.to_monoid`, `submonoid.to_comm_monoid`: a submonoid inherits a (commutative) monoid\n  structure.\n\n### Group actions by submonoids\n\n* `submonoid.mul_action`, `submonoid.distrib_mul_action`: a submonoid inherits (distributive)\n  multiplicative actions.\n\n### Operations on submonoids\n\n* `submonoid.comap`: preimage of a submonoid under a monoid homomorphism as a submonoid of the\n  domain;\n* `submonoid.map`: image of a submonoid under a monoid homomorphism as a submonoid of the codomain;\n* `submonoid.prod`: product of two submonoids `s : submonoid M` and `t : submonoid N` as a submonoid\n  of `M × N`;\n\n### Monoid homomorphisms between submonoid\n\n* `submonoid.subtype`: embedding of a submonoid into the ambient monoid.\n* `submonoid.inclusion`: given two submonoids `S`, `T` such that `S ≤ T`, `S.inclusion T` is the\n  inclusion of `S` into `T` as a monoid homomorphism;\n* `mul_equiv.submonoid_congr`: converts a proof of `S = T` into a monoid isomorphism between `S`\n  and `T`.\n* `submonoid.prod_equiv`: monoid isomorphism between `s.prod t` and `s × t`;\n\n### Operations on `monoid_hom`s\n\n* `monoid_hom.mrange`: range of a monoid homomorphism as a submonoid of the codomain;\n* `monoid_hom.mker`: kernel of a monoid homomorphism as a submonoid of the domain;\n* `monoid_hom.mrestrict`: restrict a monoid homomorphism to a submonoid;\n* `monoid_hom.cod_mrestrict`: restrict the codomain of a monoid homomorphism to a submonoid;\n* `monoid_hom.mrange_restrict`: restrict a monoid homomorphism to its range;\n\n## Tags\n\nsubmonoid, range, product, map, comap\n-/\n\nvariables {M N P : Type*} [mul_one_class M] [mul_one_class N] [mul_one_class P] (S : submonoid M)\n\n/-!\n### Conversion to/from `additive`/`multiplicative`\n-/\n\nsection\n\n/-- Submonoids of monoid `M` are isomorphic to additive submonoids of `additive M`. -/\n@[simps]\ndef submonoid.to_add_submonoid : submonoid M ≃o add_submonoid (additive M) :=\n{ to_fun := λ S,\n  { carrier := additive.to_mul ⁻¹' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  inv_fun := λ S,\n  { carrier := additive.of_mul ⁻¹' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  left_inv := λ x, by cases x; refl,\n  right_inv := λ x, by cases x; refl,\n  map_rel_iff' := λ a b, iff.rfl, }\n\n/-- Additive submonoids of an additive monoid `additive M` are isomorphic to submonoids of `M`. -/\nabbreviation add_submonoid.to_submonoid' : add_submonoid (additive M) ≃o submonoid M :=\nsubmonoid.to_add_submonoid.symm\n\nlemma submonoid.to_add_submonoid_closure (S : set M) :\n  (submonoid.closure S).to_add_submonoid = add_submonoid.closure (additive.to_mul ⁻¹' S) :=\nle_antisymm\n  (submonoid.to_add_submonoid.le_symm_apply.1 $\n    submonoid.closure_le.2 add_submonoid.subset_closure)\n  (add_submonoid.closure_le.2 submonoid.subset_closure)\n\nlemma add_submonoid.to_submonoid'_closure (S : set (additive M)) :\n  (add_submonoid.closure S).to_submonoid' = submonoid.closure (multiplicative.of_add ⁻¹' S) :=\nle_antisymm\n  (add_submonoid.to_submonoid'.le_symm_apply.1 $\n    add_submonoid.closure_le.2 submonoid.subset_closure)\n  (submonoid.closure_le.2 add_submonoid.subset_closure)\n\nend\n\nsection\n\nvariables {A : Type*} [add_zero_class A]\n\n/-- Additive submonoids of an additive monoid `A` are isomorphic to\nmultiplicative submonoids of `multiplicative A`. -/\n@[simps]\ndef add_submonoid.to_submonoid : add_submonoid A ≃o submonoid (multiplicative A) :=\n{ to_fun := λ S,\n  { carrier := multiplicative.to_add ⁻¹' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  inv_fun := λ S,\n  { carrier := multiplicative.of_add ⁻¹' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  left_inv := λ x, by cases x; refl,\n  right_inv := λ x, by cases x; refl,\n  map_rel_iff' := λ a b, iff.rfl, }\n\n/-- Submonoids of a monoid `multiplicative A` are isomorphic to additive submonoids of `A`. -/\nabbreviation submonoid.to_add_submonoid' : submonoid (multiplicative A) ≃o add_submonoid A :=\nadd_submonoid.to_submonoid.symm\n\nlemma add_submonoid.to_submonoid_closure (S : set A) :\n  (add_submonoid.closure S).to_submonoid = submonoid.closure (multiplicative.to_add ⁻¹' S) :=\nle_antisymm\n  (add_submonoid.to_submonoid.to_galois_connection.l_le $\n    add_submonoid.closure_le.2 submonoid.subset_closure)\n  (submonoid.closure_le.2 add_submonoid.subset_closure)\n\nlemma submonoid.to_add_submonoid'_closure (S : set (multiplicative A)) :\n  (submonoid.closure S).to_add_submonoid' = add_submonoid.closure (additive.of_mul ⁻¹' S) :=\nle_antisymm\n  (submonoid.to_add_submonoid'.to_galois_connection.l_le $\n    submonoid.closure_le.2 add_submonoid.subset_closure)\n  (add_submonoid.closure_le.2 submonoid.subset_closure)\n\nend\n\nnamespace submonoid\n\nopen set\n\n/-!\n### `comap` and `map`\n-/\n\n/-- The preimage of a submonoid along a monoid homomorphism is a submonoid. -/\n@[to_additive \"The preimage of an `add_submonoid` along an `add_monoid` homomorphism is an\n`add_submonoid`.\"]\ndef comap (f : M →* N) (S : submonoid N) : submonoid M :=\n{ carrier := (f ⁻¹' S),\n  one_mem' := show f 1 ∈ S, by rw f.map_one; exact S.one_mem,\n  mul_mem' := λ a b ha hb,\n    show f (a * b) ∈ S, by rw f.map_mul; exact S.mul_mem ha hb }\n\n@[simp, to_additive]\nlemma coe_comap (S : submonoid N) (f : M →* N) : (S.comap f : set M) = f ⁻¹' S := rfl\n\n@[simp, to_additive]\nlemma mem_comap {S : submonoid N} {f : M →* N} {x : M} : x ∈ S.comap f ↔ f x ∈ S := iff.rfl\n\n@[to_additive]\nlemma comap_comap (S : submonoid P) (g : N →* P) (f : M →* N) :\n  (S.comap g).comap f = S.comap (g.comp f) :=\nrfl\n\n@[simp, to_additive]\nlemma comap_id (S : submonoid P) : S.comap (monoid_hom.id _) = S :=\next (by simp)\n\n/-- The image of a submonoid along a monoid homomorphism is a submonoid. -/\n@[to_additive \"The image of an `add_submonoid` along an `add_monoid` homomorphism is\nan `add_submonoid`.\"]\ndef map (f : M →* N) (S : submonoid M) : submonoid N :=\n{ carrier := (f '' S),\n  one_mem' := ⟨1, S.one_mem, f.map_one⟩,\n  mul_mem' := begin rintros _ _ ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩, exact ⟨x * y, S.mul_mem hx hy,\n    by rw f.map_mul; refl⟩ end }\n\n@[simp, to_additive]\nlemma coe_map (f : M →* N) (S : submonoid M) :\n  (S.map f : set N) = f '' S := rfl\n\n@[simp, to_additive]\nlemma mem_map {f : M →* N} {S : submonoid M} {y : N} :\n  y ∈ S.map f ↔ ∃ x ∈ S, f x = y :=\nmem_image_iff_bex\n\n@[to_additive]\nlemma mem_map_of_mem (f : M →* N) {S : submonoid M} {x : M} (hx : x ∈ S) : f x ∈ S.map f :=\nmem_image_of_mem f hx\n\n@[to_additive]\nlemma apply_coe_mem_map (f : M →* N) (S : submonoid M) (x : S) : f x ∈ S.map f :=\nmem_map_of_mem f x.prop\n\n@[to_additive]\nlemma map_map (g : N →* P) (f : M →* N) : (S.map f).map g = S.map (g.comp f) :=\nset_like.coe_injective $ image_image _ _ _\n\n@[to_additive]\nlemma mem_map_iff_mem {f : M →* N} (hf : function.injective f) {S : submonoid M} {x : M} :\n  f x ∈ S.map f ↔ x ∈ S :=\nhf.mem_set_image\n\n@[to_additive]\nlemma map_le_iff_le_comap {f : M →* N} {S : submonoid M} {T : submonoid N} :\n  S.map f ≤ T ↔ S ≤ T.comap f :=\nimage_subset_iff\n\n@[to_additive]\nlemma gc_map_comap (f : M →* N) : galois_connection (map f) (comap f) :=\nλ S T, map_le_iff_le_comap\n\n@[to_additive]\nlemma map_le_of_le_comap {T : submonoid N} {f : M →* N} : S ≤ T.comap f → S.map f ≤ T :=\n(gc_map_comap f).l_le\n\n@[to_additive]\nlemma le_comap_of_map_le {T : submonoid N} {f : M →* N} : S.map f ≤ T → S ≤ T.comap f :=\n(gc_map_comap f).le_u\n\n@[to_additive]\nlemma le_comap_map {f : M →* N} : S ≤ (S.map f).comap f :=\n(gc_map_comap f).le_u_l _\n\n@[to_additive]\nlemma map_comap_le {S : submonoid N} {f : M →* N} : (S.comap f).map f ≤ S :=\n(gc_map_comap f).l_u_le _\n\n@[to_additive]\nlemma monotone_map {f : M →* N} : monotone (map f) :=\n(gc_map_comap f).monotone_l\n\n@[to_additive]\nlemma monotone_comap {f : M →* N} : monotone (comap f) :=\n(gc_map_comap f).monotone_u\n\n@[simp, to_additive]\nlemma map_comap_map {f : M →* N} : ((S.map f).comap f).map f = S.map f :=\n(gc_map_comap f).l_u_l_eq_l _\n\n@[simp, to_additive]\nlemma comap_map_comap {S : submonoid N} {f : M →* N} : ((S.comap f).map f).comap f = S.comap f :=\n(gc_map_comap f).u_l_u_eq_u _\n\n@[to_additive]\nlemma map_sup (S T : submonoid M) (f : M →* N) : (S ⊔ T).map f = S.map f ⊔ T.map f :=\n(gc_map_comap f).l_sup\n\n@[to_additive]\nlemma map_supr {ι : Sort*} (f : M →* N) (s : ι → submonoid M) :\n  (supr s).map f = ⨆ i, (s i).map f :=\n(gc_map_comap f).l_supr\n\n@[to_additive]\nlemma comap_inf (S T : submonoid N) (f : M →* N) : (S ⊓ T).comap f = S.comap f ⊓ T.comap f :=\n(gc_map_comap f).u_inf\n\n@[to_additive]\nlemma comap_infi {ι : Sort*} (f : M →* N) (s : ι → submonoid N) :\n  (infi s).comap f = ⨅ i, (s i).comap f :=\n(gc_map_comap f).u_infi\n\n@[simp, to_additive] lemma map_bot (f : M →* N) : (⊥ : submonoid M).map f = ⊥ :=\n(gc_map_comap f).l_bot\n\n@[simp, to_additive] \n\n@[simp, to_additive] lemma map_id (S : submonoid M) : S.map (monoid_hom.id M) = S :=\next (λ x, ⟨λ ⟨_, h, rfl⟩, h, λ h, ⟨_, h, rfl⟩⟩)\n\nsection galois_coinsertion\n\nvariables {ι : Type*} {f : M →* N} (hf : function.injective f)\n\ninclude hf\n\n/-- `map f` and `comap f` form a `galois_coinsertion` when `f` is injective. -/\n@[to_additive /-\" `map f` and `comap f` form a `galois_coinsertion` when `f` is injective. \"-/]\ndef gci_map_comap : galois_coinsertion (map f) (comap f) :=\n(gc_map_comap f).to_galois_coinsertion\n  (λ S x, by simp [mem_comap, mem_map, hf.eq_iff])\n\n@[to_additive]\nlemma comap_map_eq_of_injective (S : submonoid M) : (S.map f).comap f = S :=\n(gci_map_comap hf).u_l_eq _\n\n@[to_additive]\nlemma comap_surjective_of_injective : function.surjective (comap f) :=\n(gci_map_comap hf).u_surjective\n\n@[to_additive]\nlemma map_injective_of_injective : function.injective (map f) :=\n(gci_map_comap hf).l_injective\n\n@[to_additive]\nlemma comap_inf_map_of_injective (S T : submonoid M) : (S.map f ⊓ T.map f).comap f = S ⊓ T :=\n(gci_map_comap hf).u_inf_l _ _\n\n@[to_additive]\nlemma comap_infi_map_of_injective (S : ι → submonoid M) : (⨅ i, (S i).map f).comap f = infi S :=\n(gci_map_comap hf).u_infi_l _\n\n@[to_additive]\nlemma comap_sup_map_of_injective (S T : submonoid M) : (S.map f ⊔ T.map f).comap f = S ⊔ T :=\n(gci_map_comap hf).u_sup_l _ _\n\n@[to_additive]\nlemma comap_supr_map_of_injective (S : ι → submonoid M) : (⨆ i, (S i).map f).comap f = supr S :=\n(gci_map_comap hf).u_supr_l _\n\n@[to_additive]\nlemma map_le_map_iff_of_injective {S T : submonoid M} : S.map f ≤ T.map f ↔ S ≤ T :=\n(gci_map_comap hf).l_le_l_iff\n\n@[to_additive]\nlemma map_strict_mono_of_injective : strict_mono (map f) :=\n(gci_map_comap hf).strict_mono_l\n\nend galois_coinsertion\n\nsection galois_insertion\n\nvariables {ι : Type*} {f : M →* N} (hf : function.surjective f)\n\ninclude hf\n\n/-- `map f` and `comap f` form a `galois_insertion` when `f` is surjective. -/\n@[to_additive /-\" `map f` and `comap f` form a `galois_insertion` when `f` is surjective. \"-/]\ndef gi_map_comap : galois_insertion (map f) (comap f) :=\n(gc_map_comap f).to_galois_insertion\n  (λ S x h, let ⟨y, hy⟩ := hf x in mem_map.2 ⟨y, by simp [hy, h]⟩)\n\n@[to_additive]\nlemma map_comap_eq_of_surjective (S : submonoid N) : (S.comap f).map f = S :=\n(gi_map_comap hf).l_u_eq _\n\n@[to_additive]\nlemma map_surjective_of_surjective : function.surjective (map f) :=\n(gi_map_comap hf).l_surjective\n\n@[to_additive]\nlemma comap_injective_of_surjective : function.injective (comap f) :=\n(gi_map_comap hf).u_injective\n\n@[to_additive]\nlemma map_inf_comap_of_surjective (S T : submonoid N) : (S.comap f ⊓ T.comap f).map f = S ⊓ T :=\n(gi_map_comap hf).l_inf_u _ _\n\n@[to_additive]\nlemma map_infi_comap_of_surjective (S : ι → submonoid N) : (⨅ i, (S i).comap f).map f = infi S :=\n(gi_map_comap hf).l_infi_u _\n\n@[to_additive]\nlemma map_sup_comap_of_surjective (S T : submonoid N) : (S.comap f ⊔ T.comap f).map f = S ⊔ T :=\n(gi_map_comap hf).l_sup_u _ _\n\n@[to_additive]\nlemma map_supr_comap_of_surjective (S : ι → submonoid N) : (⨆ i, (S i).comap f).map f = supr S :=\n(gi_map_comap hf).l_supr_u _\n\n@[to_additive]\nlemma comap_le_comap_iff_of_surjective {S T : submonoid N} : S.comap f ≤ T.comap f ↔ S ≤ T :=\n(gi_map_comap hf).u_le_u_iff\n\n@[to_additive]\nlemma comap_strict_mono_of_surjective : strict_mono (comap f) :=\n(gi_map_comap hf).strict_mono_u\n\nend galois_insertion\n\n/-- A submonoid of a monoid inherits a multiplication. -/\n@[to_additive \"An `add_submonoid` of an `add_monoid` inherits an addition.\"]\ninstance has_mul : has_mul S := ⟨λ a b, ⟨a.1 * b.1, S.mul_mem a.2 b.2⟩⟩\n\n/-- A submonoid of a monoid inherits a 1. -/\n@[to_additive \"An `add_submonoid` of an `add_monoid` inherits a zero.\"]\ninstance has_one : has_one S := ⟨⟨_, S.one_mem⟩⟩\n\n@[simp, norm_cast, to_additive] lemma coe_mul (x y : S) : (↑(x * y) : M) = ↑x * ↑y := rfl\n@[simp, norm_cast, to_additive] lemma coe_one : ((1 : S) : M) = 1 := rfl\n\n@[simp, to_additive] lemma mk_mul_mk (x y : M) (hx : x ∈ S) (hy : y ∈ S) :\n  (⟨x, hx⟩ : S) * ⟨y, hy⟩ = ⟨x * y, S.mul_mem hx hy⟩ := rfl\n\n@[to_additive] lemma mul_def (x y : S) : x * y = ⟨x * y, S.mul_mem x.2 y.2⟩ := rfl\n@[to_additive] lemma one_def : (1 : S) = ⟨1, S.one_mem⟩ := rfl\n\n/-- A submonoid of a unital magma inherits a unital magma structure. -/\n@[to_additive \"An `add_submonoid` of an unital additive magma inherits an unital additive magma\nstructure.\"]\ninstance to_mul_one_class {M : Type*} [mul_one_class M] (S : submonoid M) : mul_one_class S :=\nsubtype.coe_injective.mul_one_class coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a monoid inherits a monoid structure. -/\n@[to_additive \"An `add_submonoid` of an `add_monoid` inherits an `add_monoid`\nstructure.\"]\ninstance to_monoid {M : Type*} [monoid M] (S : submonoid M) : monoid S :=\nsubtype.coe_injective.monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a `comm_monoid` is a `comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of an `add_comm_monoid` is\nan `add_comm_monoid`.\"]\ninstance to_comm_monoid {M} [comm_monoid M] (S : submonoid M) : comm_monoid S :=\nsubtype.coe_injective.comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of an `ordered_comm_monoid` is an `ordered_comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of an `ordered_add_comm_monoid` is\nan `ordered_add_comm_monoid`.\"]\ninstance to_ordered_comm_monoid {M} [ordered_comm_monoid M] (S : submonoid M) :\n  ordered_comm_monoid S :=\nsubtype.coe_injective.ordered_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a `linear_ordered_comm_monoid` is a `linear_ordered_comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of a `linear_ordered_add_comm_monoid` is\na `linear_ordered_add_comm_monoid`.\"]\ninstance to_linear_ordered_comm_monoid {M} [linear_ordered_comm_monoid M] (S : submonoid M) :\n  linear_ordered_comm_monoid S :=\nsubtype.coe_injective.linear_ordered_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of an `ordered_cancel_comm_monoid` is an `ordered_cancel_comm_monoid`. -/\n@[to_additive \"An `add_submonoid` of an `ordered_cancel_add_comm_monoid` is\nan `ordered_cancel_add_comm_monoid`.\"]\ninstance to_ordered_cancel_comm_monoid {M} [ordered_cancel_comm_monoid M] (S : submonoid M) :\n  ordered_cancel_comm_monoid S :=\nsubtype.coe_injective.ordered_cancel_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- A submonoid of a `linear_ordered_cancel_comm_monoid` is a `linear_ordered_cancel_comm_monoid`.\n-/\n@[to_additive \"An `add_submonoid` of a `linear_ordered_cancel_add_comm_monoid` is\na `linear_ordered_cancel_add_comm_monoid`.\"]\ninstance to_linear_ordered_cancel_comm_monoid {M} [linear_ordered_cancel_comm_monoid M]\n  (S : submonoid M) : linear_ordered_cancel_comm_monoid S :=\nsubtype.coe_injective.linear_ordered_cancel_comm_monoid coe rfl (λ _ _, rfl)\n\n/-- The natural monoid hom from a submonoid of monoid `M` to `M`. -/\n@[to_additive \"The natural monoid hom from an `add_submonoid` of `add_monoid` `M` to `M`.\"]\ndef subtype : S →* M := ⟨coe, rfl, λ _ _, rfl⟩\n\n@[simp, to_additive] theorem coe_subtype : ⇑S.subtype = coe := rfl\n\n/-- A submonoid is isomorphic to its image under an injective function -/\n@[to_additive \"An additive submonoid is isomorphic to its image under an injective function\"]\nnoncomputable def equiv_map_of_injective\n  (f : M →* N) (hf : function.injective f) : S ≃* S.map f :=\n{ map_mul' := λ _ _, subtype.ext (f.map_mul _ _), ..equiv.set.image f S hf }\n\n@[simp, to_additive] lemma coe_equiv_map_of_injective_apply\n  (f : M →* N) (hf : function.injective f) (x : S) :\n  (equiv_map_of_injective S f hf x : N) = f x := rfl\n\n/-- An induction principle on elements of the type `submonoid.closure s`.\nIf `p` holds for `1` and all elements of `s`, and is preserved under multiplication, then `p`\nholds for all elements of the closure of `s`.\n\nThe difference with `submonoid.closure_induction` is that this acts on the subtype.\n-/\n@[elab_as_eliminator, to_additive \"An induction principle on elements of the type\n`add_submonoid.closure s`.  If `p` holds for `0` and all elements of `s`, and is preserved under\naddition, then `p` holds for all elements of the closure of `s`.\n\nThe difference with `add_submonoid.closure_induction` is that this acts on the subtype.\"]\nlemma closure_induction' (s : set M) {p : closure s → Prop}\n  (Hs : ∀ x (h : x ∈ s), p ⟨x, subset_closure h⟩)\n  (H1 : p 1)\n  (Hmul : ∀ x y, p x → p y → p (x * y))\n  (x : closure s) :\n  p x :=\nsubtype.rec_on x $ λ x hx, begin\n  refine exists.elim _ (λ (hx : x ∈ closure s) (hc : p ⟨x, hx⟩), hc),\n  exact closure_induction hx\n    (λ x hx, ⟨subset_closure hx, Hs x hx⟩)\n    ⟨one_mem _, H1⟩\n    (λ x y hx hy, exists.elim hx $ λ hx' hx, exists.elim hy $ λ hy' hy,\n      ⟨mul_mem _ hx' hy', Hmul _ _ hx hy⟩),\nend\n\n@[simp, to_additive]\nlemma closure_closure_coe_preimage {s : set M} : closure ((coe : closure s → M) ⁻¹' s) = ⊤ :=\nbegin\n  refine eq_top_iff.2 (λ x hx, closure_induction' (λ x, _) _ _ (λ g₁ g₂ hg₁ hg₂, _) x),\n  { intros g hg,\n    exact subset_closure hg },\n  { exact submonoid.one_mem _ },\n  { exact submonoid.mul_mem _ hg₁ hg₂ },\nend\n\n/-- Given `submonoid`s `s`, `t` of monoids `M`, `N` respectively, `s × t` as a submonoid\nof `M × N`. -/\n@[to_additive prod \"Given `add_submonoid`s `s`, `t` of `add_monoid`s `A`, `B` respectively, `s × t`\nas an `add_submonoid` of `A × B`.\"]\ndef prod (s : submonoid M) (t : submonoid N) : submonoid (M × N) :=\n{ carrier := (s : set M).prod t,\n  one_mem' := ⟨s.one_mem, t.one_mem⟩,\n  mul_mem' := λ p q hp hq, ⟨s.mul_mem hp.1 hq.1, t.mul_mem hp.2 hq.2⟩ }\n\n@[to_additive coe_prod]\nlemma coe_prod (s : submonoid M) (t : submonoid N) :\n (s.prod t : set (M × N)) = (s : set M).prod (t : set N) :=\nrfl\n\n@[to_additive mem_prod]\nlemma mem_prod {s : submonoid M} {t : submonoid N} {p : M × N} :\n  p ∈ s.prod t ↔ p.1 ∈ s ∧ p.2 ∈ t := iff.rfl\n\n@[to_additive prod_mono]\nlemma prod_mono {s₁ s₂ : submonoid M} {t₁ t₂ : submonoid N} (hs : s₁ ≤ s₂) (ht : t₁ ≤ t₂) :\n  s₁.prod t₁ ≤ s₂.prod t₂ :=\nset.prod_mono hs ht\n\n@[to_additive prod_top]\nlemma prod_top (s : submonoid M) :\n  s.prod (⊤ : submonoid N) = s.comap (monoid_hom.fst M N) :=\next $ λ x, by simp [mem_prod, monoid_hom.coe_fst]\n\n@[to_additive top_prod]\nlemma top_prod (s : submonoid N) :\n  (⊤ : submonoid M).prod s = s.comap (monoid_hom.snd M N) :=\next $ λ x, by simp [mem_prod, monoid_hom.coe_snd]\n\n@[simp, to_additive top_prod_top]\nlemma top_prod_top : (⊤ : submonoid M).prod (⊤ : submonoid N) = ⊤ :=\n(top_prod _).trans $ comap_top _\n\n@[to_additive] lemma bot_prod_bot : (⊥ : submonoid M).prod (⊥ : submonoid N) = ⊥ :=\nset_like.coe_injective $ by simp [coe_prod, prod.one_eq_mk]\n\n/-- The product of submonoids is isomorphic to their product as monoids. -/\n@[to_additive prod_equiv \"The product of additive submonoids is isomorphic to their product\nas additive monoids\"]\ndef prod_equiv (s : submonoid M) (t : submonoid N) : s.prod t ≃* s × t :=\n{ map_mul' := λ x y, rfl, .. equiv.set.prod ↑s ↑t }\n\nopen monoid_hom\n\n@[to_additive]\nlemma map_inl (s : submonoid M) : s.map (inl M N) = s.prod ⊥ :=\next $ λ p, ⟨λ ⟨x, hx, hp⟩, hp ▸ ⟨hx, set.mem_singleton 1⟩,\n  λ ⟨hps, hp1⟩, ⟨p.1, hps, prod.ext rfl $ (set.eq_of_mem_singleton hp1).symm⟩⟩\n\n@[to_additive]\nlemma map_inr (s : submonoid N) : s.map (inr M N) = prod ⊥ s :=\next $ λ p, ⟨λ ⟨x, hx, hp⟩, hp ▸ ⟨set.mem_singleton 1, hx⟩,\n  λ ⟨hp1, hps⟩, ⟨p.2, hps, prod.ext (set.eq_of_mem_singleton hp1).symm rfl⟩⟩\n\n@[simp, to_additive prod_bot_sup_bot_prod]\nlemma prod_bot_sup_bot_prod (s : submonoid M) (t : submonoid N) :\n  (s.prod ⊥) ⊔ (prod ⊥ t) = s.prod t :=\nle_antisymm (sup_le (prod_mono (le_refl s) bot_le) (prod_mono bot_le (le_refl t))) $\nassume p hp, prod.fst_mul_snd p ▸ mul_mem _\n  ((le_sup_left : s.prod ⊥ ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨hp.1, set.mem_singleton 1⟩)\n  ((le_sup_right : prod ⊥ t ≤ s.prod ⊥ ⊔ prod ⊥ t) ⟨set.mem_singleton 1, hp.2⟩)\n\n@[to_additive]\nlemma mem_map_equiv {f : M ≃* N} {K : submonoid M} {x : N} :\n  x ∈ K.map f.to_monoid_hom ↔ f.symm x ∈ K :=\n@set.mem_image_equiv _ _ ↑K f.to_equiv x\n\n@[to_additive]\nlemma map_equiv_eq_comap_symm (f : M ≃* N) (K : submonoid M) :\n  K.map f.to_monoid_hom = K.comap f.symm.to_monoid_hom :=\nset_like.coe_injective (f.to_equiv.image_eq_preimage K)\n\n@[to_additive]\nlemma comap_equiv_eq_map_symm (f : N ≃* M) (K : submonoid M) :\n  K.comap f.to_monoid_hom = K.map f.symm.to_monoid_hom :=\n(map_equiv_eq_comap_symm f.symm K).symm\n\nend submonoid\n\nnamespace monoid_hom\n\nopen submonoid\n\n/-- For many categories (monoids, modules, rings, ...) the set-theoretic image of a morphism `f` is\na subobject of the codomain. When this is the case, it is useful to define the range of a morphism\nin such a way that the underlying carrier set of the range subobject is definitionally\n`set.range f`. In particular this means that the types `↥(set.range f)` and `↥f.range` are\ninterchangeable without proof obligations.\n\nA convenient candidate definition for range which is mathematically correct is `map ⊤ f`, just as\n`set.range` could have been defined as `f '' set.univ`. However, this lacks the desired definitional\nconvenience, in that it both does not match `set.range`, and that it introduces a redudant `x ∈ ⊤`\nterm which clutters proofs. In such a case one may resort to the `copy`\npattern. A `copy` function converts the definitional problem for the carrier set of a subobject\ninto a one-off propositional proof obligation which one discharges while writing the definition of\nthe definitionally convenient range (the parameter `hs` in the example below).\n\nA good example is the case of a morphism of monoids. A convenient definition for\n`monoid_hom.mrange` would be `(⊤ : submonoid M).map f`. However since this lacks the required\ndefinitional convenience, we first define `submonoid.copy` as follows:\n```lean\nprotected def copy (S : submonoid M) (s : set M) (hs : s = S) : submonoid M :=\n{ carrier  := s,\n  one_mem' := hs.symm ▸ S.one_mem',\n  mul_mem' := hs.symm ▸ S.mul_mem' }\n```\nand then finally define:\n```lean\ndef mrange (f : M →* N) : submonoid N :=\n((⊤ : submonoid M).map f).copy (set.range f) set.image_univ.symm\n```\n-/\nlibrary_note \"range copy pattern\"\n\n/-- The range of a monoid homomorphism is a submonoid. See Note [range copy pattern]. -/\n@[to_additive \"The range of an `add_monoid_hom` is an `add_submonoid`.\"]\ndef mrange (f : M →* N) : submonoid N :=\n((⊤ : submonoid M).map f).copy (set.range f) set.image_univ.symm\n\n@[simp, to_additive]\nlemma coe_mrange (f : M →* N) :\n  (f.mrange : set N) = set.range f :=\nrfl\n\n@[simp, to_additive] lemma mem_mrange {f : M →* N} {y : N} :\n  y ∈ f.mrange ↔ ∃ x, f x = y :=\niff.rfl\n\n@[to_additive] lemma mrange_eq_map (f : M →* N) : f.mrange = (⊤ : submonoid M).map f :=\ncopy_eq _\n\n@[to_additive]\nlemma map_mrange (g : N →* P) (f : M →* N) : f.mrange.map g = (g.comp f).mrange :=\nby simpa only [mrange_eq_map] using (⊤ : submonoid M).map_map g f\n\n@[to_additive]\nlemma mrange_top_iff_surjective {N} [mul_one_class N] {f : M →* N} :\n  f.mrange = (⊤ : submonoid N) ↔ function.surjective f :=\nset_like.ext'_iff.trans $ iff.trans (by rw [coe_mrange, coe_top]) set.range_iff_surjective\n\n/-- The range of a surjective monoid hom is the whole of the codomain. -/\n@[to_additive \"The range of a surjective `add_monoid` hom is the whole of the codomain.\"]\nlemma mrange_top_of_surjective {N} [mul_one_class N] (f : M →* N) (hf : function.surjective f) :\n  f.mrange = (⊤ : submonoid N) :=\nmrange_top_iff_surjective.2 hf\n\n@[to_additive]\nlemma mclosure_preimage_le (f : M →* N) (s : set N) :\n  closure (f ⁻¹' s) ≤ (closure s).comap f :=\nclosure_le.2 $ λ x hx, set_like.mem_coe.2 $ mem_comap.2 $ subset_closure hx\n\n/-- The image under a monoid hom of the submonoid generated by a set equals the submonoid generated\n    by the image of the set. -/\n@[to_additive \"The image under an `add_monoid` hom of the `add_submonoid` generated by a set equals\nthe `add_submonoid` generated by the image of the set.\"]\nlemma map_mclosure (f : M →* N) (s : set M) :\n  (closure s).map f = closure (f '' s) :=\nle_antisymm\n  (map_le_iff_le_comap.2 $ le_trans (closure_mono $ set.subset_preimage_image _ _)\n    (mclosure_preimage_le _ _))\n  (closure_le.2 $ set.image_subset _ subset_closure)\n\n/-- Restriction of a monoid hom to a submonoid of the domain. -/\n@[to_additive \"Restriction of an add_monoid hom to an `add_submonoid` of the domain.\"]\ndef mrestrict {N : Type*} [mul_one_class N] (f : M →* N) (S : submonoid M) : S →* N :=\nf.comp S.subtype\n\n@[simp, to_additive]\nlemma mrestrict_apply {N : Type*} [mul_one_class N] (f : M →* N) (x : S) : f.mrestrict S x = f x :=\nrfl\n\n/-- Restriction of a monoid hom to a submonoid of the codomain. -/\n@[to_additive \"Restriction of an `add_monoid` hom to an `add_submonoid` of the codomain.\", simps]\ndef cod_mrestrict (f : M →* N) (S : submonoid N) (h : ∀ x, f x ∈ S) : M →* S :=\n{ to_fun := λ n, ⟨f n, h n⟩,\n  map_one' := subtype.eq f.map_one,\n  map_mul' := λ x y, subtype.eq (f.map_mul x y) }\n\n/-- Restriction of a monoid hom to its range interpreted as a submonoid. -/\n@[to_additive \"Restriction of an `add_monoid` hom to its range interpreted as a submonoid.\"]\ndef mrange_restrict {N} [mul_one_class N] (f : M →* N) : M →* f.mrange :=\nf.cod_mrestrict f.mrange $ λ x, ⟨x, rfl⟩\n\n@[simp, to_additive]\nlemma coe_mrange_restrict {N} [mul_one_class N] (f : M →* N) (x : M) :\n  (f.mrange_restrict x : N) = f x :=\nrfl\n\n/-- The multiplicative kernel of a monoid homomorphism is the submonoid of elements `x : G` such\nthat `f x = 1` -/\n@[to_additive \"The additive kernel of an `add_monoid` homomorphism is the `add_submonoid` of\nelements such that `f x = 0`\"]\ndef mker (f : M →* N) : submonoid M := (⊥ : submonoid N).comap f\n\n@[to_additive]\nlemma mem_mker (f : M →* N) {x : M} : x ∈ f.mker ↔ f x = 1 := iff.rfl\n\n@[to_additive]\nlemma coe_mker (f : M →* N) : (f.mker : set M) = (f : M → N) ⁻¹' {1} := rfl\n\n@[to_additive]\ninstance decidable_mem_mker [decidable_eq N] (f : M →* N) :\n  decidable_pred (∈ f.mker) :=\nλ x, decidable_of_iff (f x = 1) f.mem_mker\n\n@[to_additive]\nlemma comap_mker (g : N →* P) (f : M →* N) : g.mker.comap f = (g.comp f).mker := rfl\n\n@[simp, to_additive] lemma comap_bot' (f : M →* N) :\n  (⊥ : submonoid N).comap f = f.mker := rfl\n\n@[to_additive] lemma range_restrict_mker (f : M →* N) : mker (mrange_restrict f) = mker f :=\nbegin\n  ext,\n  change (⟨f x, _⟩ : mrange f) = ⟨1, _⟩ ↔ f x = 1,\n  simp only [],\nend\n\n@[simp, to_additive]\nlemma mker_one : (1 : M →* N).mker = ⊤ :=\nby { ext, simp [mem_mker] }\n\n@[to_additive]\nlemma prod_map_comap_prod' {M' : Type*} {N' : Type*} [mul_one_class M'] [mul_one_class N']\n  (f : M →* N) (g : M' →* N') (S : submonoid N) (S' : submonoid N') :\n  (S.prod S').comap (prod_map f g) = (S.comap f).prod (S'.comap g) :=\nset_like.coe_injective $ set.preimage_prod_map_prod f g _ _\n\n@[to_additive]\nlemma mker_prod_map {M' : Type*} {N' : Type*} [mul_one_class M'] [mul_one_class N'] (f : M →* N)\n  (g : M' →* N') : (prod_map f g).mker = f.mker.prod g.mker :=\nby rw [←comap_bot', ←comap_bot', ←comap_bot', ←prod_map_comap_prod', bot_prod_bot]\n\nend monoid_hom\n\nnamespace submonoid\nopen monoid_hom\n\n@[to_additive]\nlemma mrange_inl : (inl M N).mrange = prod ⊤ ⊥ :=\nby simpa only [mrange_eq_map] using map_inl ⊤\n\n@[to_additive]\nlemma mrange_inr : (inr M N).mrange = prod ⊥ ⊤ :=\nby simpa only [mrange_eq_map] using map_inr ⊤\n\n@[to_additive]\nlemma mrange_inl' : (inl M N).mrange = comap (snd M N) ⊥ := mrange_inl.trans (top_prod _)\n\n@[to_additive]\nlemma mrange_inr' : (inr M N).mrange = comap (fst M N) ⊥ := mrange_inr.trans (prod_top _)\n\n@[simp, to_additive]\nlemma mrange_fst : (fst M N).mrange = ⊤ :=\n(fst M N).mrange_top_of_surjective $ @prod.fst_surjective _ _ ⟨1⟩\n\n@[simp, to_additive]\nlemma mrange_snd : (snd M N).mrange = ⊤ :=\n(snd M N).mrange_top_of_surjective $ @prod.snd_surjective _ _ ⟨1⟩\n@[simp, to_additive]\n\nlemma mrange_inl_sup_mrange_inr : (inl M N).mrange ⊔ (inr M N).mrange = ⊤ :=\nby simp only [mrange_inl, mrange_inr, prod_bot_sup_bot_prod, top_prod_top]\n\n/-- The monoid hom associated to an inclusion of submonoids. -/\n@[to_additive \"The `add_monoid` hom associated to an inclusion of submonoids.\"]\ndef inclusion {S T : submonoid M} (h : S ≤ T) : S →* T :=\nS.subtype.cod_mrestrict _ (λ x, h x.2)\n\n@[simp, to_additive]\nlemma range_subtype (s : submonoid M) : s.subtype.mrange = s :=\nset_like.coe_injective $ (coe_mrange _).trans $ subtype.range_coe\n\n@[to_additive] lemma eq_top_iff' : S = ⊤ ↔ ∀ x : M, x ∈ S :=\neq_top_iff.trans ⟨λ h m, h $ mem_top m, λ h m _, h m⟩\n\n@[to_additive] lemma eq_bot_iff_forall : S = ⊥ ↔ ∀ x ∈ S, x = (1 : M) :=\nset_like.ext_iff.trans $ by simp [iff_def, S.one_mem] { contextual := tt }\n\n@[to_additive] lemma nontrivial_iff_exists_ne_one (S : submonoid M) :\n  nontrivial S ↔ ∃ x ∈ S, x ≠ (1:M) :=\ncalc nontrivial S ↔ ∃ x : S, x ≠ 1                                   : nontrivial_iff_exists_ne 1\n              ... ↔ ∃ x (hx : x ∈ S), (⟨x, hx⟩ : S) ≠ ⟨1, S.one_mem⟩ : subtype.exists\n              ... ↔ ∃ x ∈ S, x ≠ (1 : M)                             : by simp only [ne.def]\n\n/-- A submonoid is either the trivial submonoid or nontrivial. -/\n@[to_additive] lemma bot_or_nontrivial (S : submonoid M) : S = ⊥ ∨ nontrivial S :=\nby simp only [eq_bot_iff_forall, nontrivial_iff_exists_ne_one, ← not_forall, classical.em]\n\n/-- A submonoid is either the trivial submonoid or contains a nonzero element. -/\n@[to_additive] lemma bot_or_exists_ne_one (S : submonoid M) : S = ⊥ ∨ ∃ x ∈ S, x ≠ (1:M) :=\nS.bot_or_nontrivial.imp_right S.nontrivial_iff_exists_ne_one.mp\n\nend submonoid\n\nnamespace mul_equiv\n\nvariables {S} {T : submonoid M}\n\n/-- Makes the identity isomorphism from a proof that two submonoids of a multiplicative\n    monoid are equal. -/\n@[to_additive \"Makes the identity additive isomorphism from a proof two\nsubmonoids of an additive monoid are equal.\"]\ndef submonoid_congr (h : S = T) : S ≃* T :=\n{ map_mul' :=  λ _ _, rfl, ..equiv.set_congr $ congr_arg _ h }\n\n-- this name is primed so that the version to `f.range` instead of `f.mrange` can be unprimed.\n/-- A monoid homomorphism `f : M →* N` with a left-inverse `g : N → M` defines a multiplicative\nequivalence between `M` and `f.mrange`.\n\nThis is a bidirectional version of `monoid_hom.mrange_restrict`. -/\n@[to_additive /-\"\nAn additive monoid homomorphism `f : M →+ N` with a left-inverse `g : N → M` defines an additive\nequivalence between `M` and `f.mrange`.\n\nThis is a bidirectional version of `add_monoid_hom.mrange_restrict`. \"-/, simps {simp_rhs := tt}]\ndef of_left_inverse' (f : M →* N) {g : N → M} (h : function.left_inverse g f) : M ≃* f.mrange :=\n{ to_fun := f.mrange_restrict,\n  inv_fun := g ∘ f.mrange.subtype,\n  left_inv := h,\n  right_inv := λ x, subtype.ext $\n    let ⟨x', hx'⟩ := monoid_hom.mem_mrange.mp x.prop in\n    show f (g x) = x, by rw [←hx', h x'],\n  .. f.mrange_restrict }\n\n/-- A `mul_equiv` `φ` between two monoids `M` and `N` induces a `mul_equiv` between\na submonoid `S ≤ M` and the submonoid `φ(S) ≤ N`. -/\n@[to_additive \"An `add_equiv` `φ` between two additive monoids `M` and `N` induces an `add_equiv`\nbetween a submonoid `S ≤ M` and the submonoid `φ(S) ≤ N`. \", simps]\ndef submonoid_equiv_map (e : M ≃* N) (S : submonoid M) : S ≃* S.map e.to_monoid_hom :=\n{ to_fun := λ x, ⟨e x, _⟩,\n  inv_fun := λ x, ⟨e.symm x, _⟩, -- we restate this for `simps` to avoid `⇑e.symm.to_equiv x`\n  map_mul' := λ _ _, subtype.ext (e.map_mul _ _), ..equiv.image e.to_equiv S }\n\nend mul_equiv\n\nsection actions\n/-! ### Actions by `submonoid`s\n\nThese instances tranfer the action by an element `m : M` of a monoid `M` written as `m • a` onto the\naction by an element `s : S` of a submonoid `S : submonoid M` such that `s • a = (s : M) • a`.\n\nThese instances work particularly well in conjunction with `monoid.to_mul_action`, enabling\n`s • m` as an alias for `↑s * m`.\n-/\n\nnamespace submonoid\n\nvariables {M' : Type*} {α β : Type*} [monoid M']\n\n/-- The action by a submonoid is the action by the underlying monoid. -/\n@[to_additive /-\"The additive action by an add_submonoid is the action by the underlying\nadd_monoid. \"-/]\ninstance [mul_action M' α] (S : submonoid M') : mul_action S α :=\nmul_action.comp_hom _ S.subtype\n\n@[to_additive]\nlemma smul_def [mul_action M' α] {S : submonoid M'} (g : S) (m : α) : g • m = (g : M') • m := rfl\n\n/-- The action by a submonoid is the action by the underlying monoid. -/\ninstance [add_monoid α] [distrib_mul_action M' α] (S : submonoid M') : distrib_mul_action S α :=\ndistrib_mul_action.comp_hom _ S.subtype\n\n/-- The action by a submonoid is the action by the underlying monoid. -/\ninstance [monoid α] [mul_distrib_mul_action M' α] (S : submonoid M') : mul_distrib_mul_action S α :=\nmul_distrib_mul_action.comp_hom _ S.subtype\n\n@[to_additive]\ninstance smul_comm_class_left\n  [mul_action M' β] [has_scalar α β] [smul_comm_class M' α β] (S : submonoid M') :\n  smul_comm_class S α β :=\n⟨λ a, (smul_comm (a : M') : _)⟩\n\n@[to_additive]\ninstance smul_comm_class_right\n  [has_scalar α β] [mul_action M' β] [smul_comm_class α M' β] (S : submonoid M') :\n  smul_comm_class α S β :=\n⟨λ a s, (smul_comm a (s : M') : _)⟩\n\n/-- Note that this provides `is_scalar_tower S M' M'` which is needed by `smul_mul_assoc`. -/\ninstance\n  [has_scalar α β] [mul_action M' α] [mul_action M' β] [is_scalar_tower M' α β] (S : submonoid M') :\n  is_scalar_tower S α β :=\n⟨λ a, (smul_assoc (a : M') : _)⟩\n\nexample {S : submonoid M'} : is_scalar_tower S M' M' := by apply_instance\n\ninstance [mul_action M' α] [has_faithful_scalar M' α] (S : submonoid M') :\n  has_faithful_scalar S α :=\n{ eq_of_smul_eq_smul := λ x y h, subtype.ext (eq_of_smul_eq_smul h) }\n\nend submonoid\n\nend actions\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/group_theory/submonoid/operations.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6297745935070806, "lm_q2_score": 0.7248702821204019, "lm_q1q2_score": 0.456504887267739}}
{"text": "import .basic .simplify_eq  .init_last .map_accum_lemmas .repeat_lemmas .rotate .tail_lemmas .zero_length_lemmas\n\nuniverse variables u\n\nnamespace vector\n\nvariable {α : Type u}\n\nsection ind\n\nopen nat\n\nparameter {α' : Type u}\n\nvariables {P : ∀ {n : ℕ}, vector α' n → Prop}\nvariables {n : ℕ} (v : vector α' n)\nvariables h₀ : P nil\nvariables hn : ∀ {n : ℕ} (x : α') (v : vector α' n), P v → P (x :: v)\n\ninclude hn\n\nlemma induction : ∀ {n : ℕ} (v : vector α' n), P v\n | 0 ⟨[],P⟩ := h₀\n | (succ n) ⟨x :: xs, P⟩ :=\n begin\n   apply hn x ⟨xs,_⟩ (induction ⟨xs, _⟩),\n   have P' : succ (list.length xs) = succ n, { apply P },\n   injection P',\n end\n\nlemma induction_on : P v := induction h₀ @hn v\n\nend ind\n\nend vector\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/vector/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4565023051795535}}
{"text": "import data.zmod.basic order.basic\n\ndef int32 := zmod (2^32)\n\nnamespace int32\n\nlocal attribute [instance]\ndef int32_pos : fact (0 < 2 ^ 32) := nat.pow_pos dec_trivial _\n\ninstance : has_coe int32 ℤ :=\n⟨λ i, if i.val < 2^31 then i.val else i.val - 2^32⟩\n\ninstance : comm_ring int32 := by unfold int32; apply_instance\n\ninstance : decidable_eq int32 :=\nλ x y, decidable_of_iff _ (zmod.val_injective _).eq_iff\n\ntheorem coe_inj {i j : int32} : (i : ℤ) = j ↔ i = j :=\n⟨λ h : (ite (i.val < 2 ^ 31) i.val (i.val - 2 ^ 32) : ℤ) =\n       ite (j.val < 2 ^ 31) j.val (j.val - 2 ^ 32), begin\n  rw ← (_ : ((2 ^ 32 : ℕ) : ℤ) = 2 ^ 32) at h,\n  swap, {apply int.coe_nat_pow},\n  split_ifs at h with h₁ h₂,\n  { exact zmod.val_injective _ (int.coe_nat_inj h) },\n  { have := int.coe_nat_nonneg i.val,\n    rw [h, sub_nonneg, int.coe_nat_le] at this,\n    cases not_lt_of_le this j.val_lt },\n  { have := int.coe_nat_nonneg j.val,\n    rw [← h, sub_nonneg, int.coe_nat_le] at this,\n    cases not_lt_of_le this i.val_lt },\n  { rw sub_left_inj at h,\n    exact zmod.val_injective _ (int.coe_nat_inj h) }\nend, congr_arg _⟩\n\ninstance : decidable_linear_order int32 :=\n{ decidable_le := λ x y, int.decidable_le _ _,\n  decidable_eq := int32.decidable_eq,\n  ..linear_order.lift (coe : int32 → ℤ) (λ _ _, coe_inj.1) }\n\ntheorem coe_le {i j : int32} : (i : ℤ) ≤ j ↔ i ≤ j := iff.rfl\n\ntheorem coe_lt {i j : int32} : (i : ℤ) < j ↔ i < j :=\nby rw [← not_le, coe_le, not_le]\n\ntheorem coe_zero : ((0 : int32) : ℤ) = 0 :=\nby unfold_coes; exact if_pos (nat.pow_pos dec_trivial _)\n\ndef of_int (n : ℤ) : option int32 :=\nif -2^31 ≤ n ∧ n < 2^31 then some n else none\n\ndef div (m n : int32) : option int32 :=\nif n = 0 then none else of_int (m / n)\n\ndef mod (m n : int32) : option int32 :=\nif n = 0 then none else of_int (m % n)\n\ndef shl (m n : int32) : option int32 :=\nif 0 ≤ n ∧ n < 32 then of_int (int.shiftl m n) else none\n\ndef shr (m n : int32) : option int32 :=\nif 0 ≤ n ∧ n < 32 then of_int (int.shiftr m n) else none\n\ndef bitwise_and (m n : int32) : int32 := int.land m n\ndef bitwise_xor (m n : int32) : int32 := int.lxor m n\ndef bitwise_or (m n : int32) : int32 := int.lor m n\ndef bitwise_not (n : int32) : int32 := int.lnot n\n\nend int32\n", "meta": {"author": "digama0", "repo": "vc0", "sha": "b8b192c8c139e0b5a25a7284b93ed53cdf7fd7a5", "save_path": "github-repos/lean/digama0-vc0", "path": "github-repos/lean/digama0-vc0/vc0-b8b192c8c139e0b5a25a7284b93ed53cdf7fd7a5/src/util/int32.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085808877581, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4565023051795535}}
{"text": "/-\nCopyright (c) 2014 Parikshit Khanna. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro\n-/\nimport Lean\nimport Mathlib.Init.Data.List.Instances\nimport Mathlib.Init.Data.Nat.Basic\n\n/-!\n## Definitions on Lists\n\nThis file contains various definitions on `List`. It does not contain\nproofs about these definitions, those are contained in other files in `Mathlib.Data.List`.\n-/\n\nnamespace List\n\n/-- Split a list at an index.\n```\nsplitAt 2 [a, b, c] = ([a, b], [c])\n``` -/\ndef splitAt : ℕ → List α → List α × List α\n| n+1, x :: xs => let (l, r) := splitAt n xs; (x :: l, r)\n| _, xs => ([], xs)\n\n/-- Split a list at an index. Ensures the left list always has the specified length\nby right padding with the provided default element.\n```\nsplitAtD 2 [a, b, c] x = ([a, b], [c])\nsplitAtD 4 [a, b, c] x = ([a, b, c, x], [])\n``` -/\ndef splitAtD : ℕ → List α → α → List α × List α\n| 0, xs, a => ([], xs)\n| n+1, [], a => let (l, r) := splitAtD n [] a; (a :: l, r)\n| n+1, x :: xs, a => let (l, r) := splitAtD n xs a; (x :: l, r)\n\n/-- An auxiliary function for `splitOnP`. -/\ndef splitOnPAux {α : Type u} (P : α → Prop) [DecidablePred P] : List α → (List α → List α) → List (List α)\n| [], f => [f []]\n| h :: t, f => if P h then f [] :: splitOnPAux P t id else splitOnPAux P t fun l => f (h :: l)\n\n/-- Split a list at every element satisfying a predicate. -/\ndef splitOnP {α : Type u} (P : α → Prop) [DecidablePred P] (l : List α) : List (List α) :=\n  splitOnPAux P l id\n\n/-- Split a list at every occurrence of an element.\n```\n[1,1,2,3,2,4,4].split_on 2 = [[1,1],[3],[4,4]]\n``` -/\ndef splitOn {α : Type u} [DecidableEq α] (a : α) (as : List α) : List (List α) :=\n  as.splitOnP (· = a)\n\n/-- Apply a function to the nth tail of `l`. Returns the input without\n  using `f` if the index is larger than the length of the List.\n```\nmodifyNthTail f 2 [a, b, c] = [a, b] ++ f [c]\n``` -/\n@[simp]\ndef modifyNthTail (f : List α → List α) : ℕ → List α → List α\n| 0, l => f l\n| n+1, [] => []\n| n+1, a :: l => a :: modifyNthTail f n l\n\n/-- Apply `f` to the head of the list, if it exists. -/\n@[simp]\ndef modifyHead (f : α → α) : List α → List α\n| [] => []\n| a :: l => f a :: l\n\n/-- Apply `f` to the nth element of the list, if it exists. -/\ndef modifyNth (f : α → α) : ℕ → List α → List α :=\n  modifyNthTail (modifyHead f)\n\n/-- Apply `f` to the last element of `l`, if it exists. -/\n@[simp]\ndef modifyLast (f : α → α) : List α → List α\n| [] => []\n| [x] => [f x]\n| x :: xs => x :: modifyLast f xs\n\n/-- `insertNth n a l` inserts `a` into the list `l` after the first `n` elements of `l`\n```\ninsertNth 2 1 [1, 2, 3, 4] = [1, 2, 1, 3, 4]\n``` -/\ndef insertNth (n : ℕ) (a : α) : List α → List α :=\n  modifyNthTail (cons a) n\n\n/-- Take `n` elements from a list `l`. If `l` has less than `n` elements, append `n - length l`\nelements `x`. -/\ndef takeD : ∀ n : ℕ, List α → α → List α\n| 0, l, _ => []\n| n+1, l, x => l.headD x :: takeD n l.tail x\n\n/-- Fold a function `f` over the list from the left, returning the list\n  of partial results.\n```\nscanl (+) 0 [1, 2, 3] = [0, 1, 3, 6]\n``` -/\ndef scanl (f : α → β → α) : α → List β → List α\n| a, [] => [a]\n| a, b :: l => a :: scanl f (f a b) l\n\n/-- Auxiliary definition used to define `scanr`. If `scanrAux f b l = (b', l')`\nthen `scanr f b l = b' :: l'` -/\ndef scanrAux (f : α → β → β) (b : β) : List α → β × List β\n| [] => (b, [])\n| a :: l =>\n  let (b', l') := scanrAux f b l\n  (f a b', b' :: l')\n\n/-- Fold a function `f` over the list from the right, returning the list of partial results.\n```\nscanr (+) 0 [1, 2, 3] = [6, 5, 3, 0]\n``` -/\ndef scanr (f : α → β → β) (b : β) (l : List α) : List β :=\n  let (b', l') := scanrAux f b l\n  b' :: l'\n\n/-- Given a function `f : α → β ⊕ γ`, `partitionMap f l` maps the list by `f`\n  whilst partitioning the result it into a pair of lists, `list β × list γ`,\n  partitioning the `sum.inl _` into the left list, and the `sum.inr _` into the right List.\n  `partitionMap (id : ℕ ⊕ ℕ → ℕ ⊕ ℕ) [inl 0, inr 1, inl 2] = ([0,2], [1])`    -/\ndef partitionMap (f : α → β ⊕ γ) : List α → List β × List γ\n| [] => ([], [])\n| x :: xs =>\n  match f x with\n  | Sum.inr r => Prod.map id (cons r) $ partitionMap f xs\n  | Sum.inl l => Prod.map (cons l) id $ partitionMap f xs\n\n/-- `find p l` is the first element of `l` satisfying `p`, or `none` if no such\n  element exists. -/\ndef find (p : α → Prop) [DecidablePred p] : List α → Option α\n| [] => none\n| a :: l => if p a then some a else find p l\n\n/-- Auxiliary definition for `foldlIdx`. -/\ndef foldlIdxAux (f : ℕ → α → β → α) : ℕ → α → List β → α\n| _, a, [] => a\n| i, a, b :: l => foldlIdxAux f (i+1) (f i a b) l\n\n/-- Fold a list from left to right as with `foldl`, but the combining function\nalso receives each element's index. -/\ndef foldlIdx (f : ℕ → α → β → α) (a : α) (l : List β) : α :=\n  foldlIdxAux f 0 a l\n\n/-- Auxiliary definition for `foldrIdx`. -/\ndef foldrIdxAux (f : ℕ → α → β → β) : ℕ → β → List α → β\n| _, b, [] => b\n| i, b, a :: l => f i a (foldrIdxAux f (i+1) b l)\n\n/-- Fold a list from right to left as with `foldr`, but the combining function\nalso receives each element's index. -/\ndef foldrIdx (f : ℕ → α → β → β) (b : β) (l : List α) : β :=\n  foldrIdxAux f 0 b l\n\n/-- `findIdxs p l` is the list of indexes of elements of `l` that satisfy `p`. -/\ndef findIdxs (p : α → Prop) [DecidablePred p] (l : List α) : List Nat :=\n  foldrIdx (fun i a is => if p a then i :: is else is) [] l\n\n/-- Returns the elements of `l` that satisfy `p` together with their indexes in\n`l`. The returned list is ordered by index. -/\ndef indexesValues (p : α → Prop) [DecidablePred p] (l : List α) : List (ℕ × α) :=\n  foldrIdx (fun i a l => if p a then (i, a) :: l else l) [] l\n\n/-- `indexesOf a l` is the list of all indexes of `a` in `l`. For example:\n\n    indexesOf a [a, b, a, a] = [0, 2, 3] -/\ndef indexesOf [DecidableEq α] (a : α) : List α → List Nat :=\n  findIdxs (Eq a)\n\n/-- `lookmap` is a combination of `lookup` and `filterMap`.\n  `lookmap f l` will apply `f : α → option α` to each element of the list,\n  replacing `a → b` at the first value `a` in the list such that `f a = some b`. -/\ndef lookmap (f : α → Option α) : List α → List α\n| [] => []\n| a :: l =>\n  match f a with\n  | some b => b :: l\n  | none => a :: lookmap f l\n\n/-- `countp p l` is the number of elements of `l` that satisfy `p`. -/\ndef countp (p : α → Prop) [DecidablePred p] : List α → Nat\n| [] => 0\n| x :: xs => if p x then countp p xs + 1 else countp p xs\n\n/-- `count a l` is the number of occurrences of `a` in `l`. -/\ndef count [DecidableEq α] (a : α) : List α → Nat :=\n  countp (Eq a)\n\n/-- `isPrefix l₁ l₂`, or `l₁ <+: l₂`, means that `l₁` is a prefix of `l₂`,\n  that is, `l₂` has the form `l₁ ++ t` for some `t`. -/\ndef isPrefix (l₁ : List α) (l₂ : List α) : Prop :=\n  ∃ t, l₁ ++ t = l₂\n\n/-- `isSuffix l₁ l₂`, or `l₁ <:+ l₂`, means that `l₁` is a suffix of `l₂`,\n  that is, `l₂` has the form `t ++ l₁` for some `t`. -/\ndef isSuffix (l₁ : List α) (l₂ : List α) : Prop :=\n  ∃ t, t ++ l₁ = l₂\n\n/-- `isInfix l₁ l₂`, or `l₁ <:+: l₂`, means that `l₁` is a contiguous\n  substring of `l₂`, that is, `l₂` has the form `s ++ l₁ ++ t` for some `s, t`. -/\ndef isInfix (l₁ : List α) (l₂ : List α) : Prop :=\n  ∃ s t, s ++ l₁ ++ t = l₂\n\ninfixl:50 \" <+: \" => isPrefix\n\ninfixl:50 \" <:+ \" => isSuffix\n\ninfixl:50 \" <:+: \" => isInfix\n\n/-- `inits l` is the list of initial segments of `l`.\n```\ninits [1, 2, 3] = [[], [1], [1, 2], [1, 2, 3]]\n``` -/\n@[simp] def inits : List α → List (List α)\n| [] => [[]]\n| a :: l => [] :: map (fun t => a :: t) (inits l)\n\n/-- `tails l` is the list of terminal segments of `l`.\n```\ntails [1, 2, 3] = [[1, 2, 3], [2, 3], [3], []]\n``` -/\n@[simp] def tails : List α → List (List α)\n| [] => [[]]\n| a :: l => (a :: l) :: tails l\n\ndef sublists'Aux : List α → (List α → List β) → List (List β) → List (List β)\n| [], f, r => f [] :: r\n| a :: l, f, r => sublists'Aux l f (sublists'Aux l (f ∘ cons a) r)\n\n/-- `sublists' l` is the list of all (non-contiguous) sublists of `l`.\n  It differs from `sublists` only in the order of appearance of the sublists;\n  `sublists'` uses the first element of the list as the MSB,\n  `sublists` uses the first element of the list as the LSB.\n```\nsublists' [1, 2, 3] = [[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]]\n``` -/\ndef sublists' (l : List α) : List (List α) :=\n  sublists'Aux l id []\n\ndef sublistsAux : List α → (List α → List β → List β) → List β\n| [], f => []\n| a :: l, f => f [a] (sublistsAux l fun ys r => f ys (f (a :: ys) r))\n\n/-- `sublists l` is the list of all (non-contiguous) sublists of `l`; cf. `sublists'`\n  for a different ordering.\n```\nsublists [1, 2, 3] = [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]\n``` -/\ndef sublists (l : List α) : List (List α) :=\n  [] :: sublistsAux l cons\n\ndef sublistsAux₁ : List α → (List α → List β) → List β\n| [], f => []\n| a :: l, f => f [a] ++ sublistsAux₁ l fun ys => f ys ++ f (a :: ys)\n\nsection Forall₂\n\nvariable {r : α → β → Prop} {p : γ → δ → Prop}\n\n/-- `Forall₂ R l₁ l₂` means that `l₁` and `l₂` have the same length,\n  and whenever `a` is the nth element of `l₁`, and `b` is the nth element of `l₂`,\n  then `R a b` is satisfied. -/\ninductive Forall₂ (R : α → β → Prop) : List α → List β → Prop\n  | nil : Forall₂ R [] []\n  | cons {a b l₁ l₂} : R a b → Forall₂ R l₁ l₂ → Forall₂ R (a :: l₁) (b :: l₂)\n\nattribute [simp] Forall₂.nil\n\nend Forall₂\n\n/-- Auxiliary definition used to define `transpose`.\n  `transposeAux l L` takes each element of `l` and appends it to the start of\n  each element of `L`.\n  `transposeAux [a, b, c] [l₁, l₂, l₃] = [a::l₁, b::l₂, c::l₃]` -/\ndef transposeAux : List α → List (List α) → List (List α)\n| [], ls => ls\n| a :: i, [] => [a] :: transposeAux i []\n| a :: i, l :: ls => (a :: l) :: transposeAux i ls\n\n/-- transpose of a list of lists, treated as a matrix.\n```\ntranspose [[1, 2], [3, 4], [5, 6]] = [[1, 3, 5], [2, 4, 6]]\n``` -/\ndef transpose : List (List α) → List (List α)\n| [] => []\n| l :: ls => transposeAux l (transpose ls)\n\n/-- List of all sections through a list of lists. A section\n  of `[L₁, L₂, ..., Lₙ]` is a list whose first element comes from\n  `L₁`, whose second element comes from `L₂`, and so on. -/\ndef sections : List (List α) → List (List α)\n| [] => [[]]\n| l :: L => (sections L).bind fun s => l.map fun a => a :: s\n\n/-- `erasep p l` removes the first element of `l` satisfying the predicate `p`. -/\ndef erasep (p : α → Prop) [DecidablePred p] : List α → List α\n| [] => []\n| a :: l => if p a then l else a :: erasep p l\n\n/-- `extractp p l` returns a pair of an element `a` of `l` satisfying the predicate\n  `p`, and `l`, with `a` removed. If there is no such element `a` it returns `(none, l)`. -/\ndef extractp (p : α → Prop) [DecidablePred p] : List α → Option α × List α\n| [] => (none, [])\n| a :: l =>\n  if p a then (some a, l) else\n    let (a', l') := extractp p l\n    (a', a :: l')\n\n/-- `revzip l` returns a list of pairs of the elements of `l` paired\n  with the elements of `l` in reverse order.\n```\nrevzip [1,2,3,4,5] = [(1, 5), (2, 4), (3, 3), (4, 2), (5, 1)]\n``` -/\ndef revzip (l : List α) : List (α × α) :=\n  zip l l.reverse\n\n/-- `product l₁ l₂` is the list of pairs `(a, b)` where `a ∈ l₁` and `b ∈ l₂`.\n```\nproduct [1, 2] [5, 6] = [(1, 5), (1, 6), (2, 5), (2, 6)]\n``` -/\ndef product (l₁ : List α) (l₂ : List β) : List (α × β) :=\n  l₁.bind $ fun a => l₂.map $ Prod.mk a\n\n/-- `sigma l₁ l₂` is the list of dependent pairs `(a, b)` where `a ∈ l₁` and `b ∈ l₂ a`.\n```\nsigma [1, 2] (λ_, [(5 : ℕ), 6]) = [(1, 5), (1, 6), (2, 5), (2, 6)]\n``` -/\nprotected def sigma {σ : α → Type _} (l₁ : List α) (l₂ : ∀ a, List (σ a)) : List (Σ a, σ a) :=\n  l₁.bind $ fun a => (l₂ a).map $ Sigma.mk a\n\n/-- Auxliary definition used to define `ofFn`.\n  `ofFnAux f m h l` returns the first `m` elements of `ofFn f`\n  appended to `l` -/\ndef ofFnAux {n} (f : Fin n → α) : ∀ m, m ≤ n → List α → List α\n| 0, h, l => l\n| m+1, h, l => ofFnAux f m (Nat.le_of_lt h) (f ⟨m, h⟩ :: l)\n\n/-- `ofFn f` with `f : fin n → α` returns the list whose ith element is `f i`\n```\nofFn f = [f 0, f 1, ... , f(n - 1)]\n``` -/\ndef ofFn {n} (f : Fin n → α) : List α :=\n  ofFnAux f n (Nat.le_refl _) []\n\n/-- `ofFnNthVal f i` returns `some (f i)` if `i < n` and `none` otherwise. -/\ndef ofFnNthVal {n} (f : Fin n → α) (i : ℕ) : Option α :=\n  if h : i < n then some (f ⟨i, h⟩) else none\n\n/-- `disjoint l₁ l₂` means that `l₁` and `l₂` have no elements in common. -/\ndef disjoint (l₁ l₂ : List α) : Prop :=\n  ∀ ⦃a⦄, a ∈ l₁ → a ∈ l₂ → False\n\nsection Pairwise\n\nvariable (R : α → α → Prop)\n\n-- ././Mathport/Syntax/Translate/Basic.lean:452:2: warning: expanding binder collection (a' «expr ∈ » l)\n/-- `Pairwise R l` means that all the elements with earlier indexes are\n  `R`-related to all the elements with later indexes.\n     Pairwise R [1, 2, 3] ↔ R 1 2 ∧ R 1 3 ∧ R 2 3\n  For example if `R = (≠)` then it asserts `l` has no duplicates,\n  and if `R = (<)` then it asserts that `l` is (strictly) sorted. -/\ninductive Pairwise : List α → Prop\n  | nil : Pairwise []\n  | cons : ∀ {a : α} {l : List α}, (∀ a' ∈ l, R a a') → Pairwise l → Pairwise (a :: l)\n\nend Pairwise\n\n-- ././Mathport/Syntax/Translate/Basic.lean:452:2: warning: expanding binder collection (y «expr ∈ » IH)\n/-- `pwFilter R l` is a maximal sublist of `l` which is `Pairwise R`.\n  `pwFilter (≠)` is the erase duplicates function (cf. `eraseDup`), and `pwFilter (<)` finds\n  a maximal increasing subsequence in `l`. For example,\n     pwFilter (<) [0, 1, 5, 2, 6, 3, 4] = [0, 1, 2, 3, 4] -/\ndef pwFilter (R : α → α → Prop) [DecidableRel R] : List α → List α\n| [] => []\n| x :: xs =>\n  let IH := pwFilter R xs\n  if ∀ y ∈ IH, R x y then x :: IH else IH\n\nsection Chain\n\nvariable (R : α → α → Prop)\n\n/-- `Chain R a l` means that `R` holds between adjacent elements of `a::l`.\n```\nChain R a [b, c, d] ↔ R a b ∧ R b c ∧ R c d\n``` -/\ninductive Chain : α → List α → Prop\n  | nil {a : α} : Chain a []\n  | cons : ∀ {a b : α} {l : List α}, R a b → Chain b l → Chain a (b :: l)\n\n/-- `Chain' R l` means that `R` holds between adjacent elements of `l`.\n```\nChain' R [a, b, c, d] ↔ R a b ∧ R b c ∧ R c d\n``` -/\ndef Chain' : List α → Prop\n| [] => True\n| a :: l => Chain R a l\n\nend Chain\n\n/-- `Nodup l` means that `l` has no duplicates, that is, any element appears at most\n  once in the List. It is defined as `Pairwise (≠)`. -/\ndef Nodup : List α → Prop :=\n  Pairwise (· ≠ ·)\n\n/-- `eraseDup l` removes duplicates from `l` (taking only the first occurrence).\n  Defined as `pwFilter (≠)`.\n\n    eraseDup [1, 0, 2, 2, 1] = [0, 2, 1] -/\ndef eraseDup [DecidableEq α] : List α → List α :=\n  pwFilter (· ≠ ·)\n\n/-- `range' s n` is the list of numbers `[s, s+1, ..., s+n-1]`.\n  It is intended mainly for proving properties of `range` and `iota`. -/\n@[simp]\ndef range' : ℕ → ℕ → List ℕ\n| s, 0 => []\n| s, n+1 => s :: range' (s+1) n\n\n/-- Drop `none`s from a list, and replace each remaining `some a` with `a`. -/\ndef reduceOption {α} : List (Option α) → List α :=\n  List.filterMap id\n\n/-- `ilast' x xs` returns the last element of `xs` if `xs` is non-empty;\nit returns `x` otherwise -/\n@[simp]\ndef ilast' {α} : α → List α → α\n| a, [] => a\n| a, b :: l => ilast' b l\n\n/-- `last' xs` returns the last element of `xs` if `xs` is non-empty;\nit returns `none` otherwise -/\n@[simp]\ndef last' {α} : List α → Option α\n| [] => none\n| [a] => some a\n| b :: l => last' l\n\n/-- `rotate l n` rotates the elements of `l` to the left by `n`\n```\nrotate [0, 1, 2, 3, 4, 5] 2 = [2, 3, 4, 5, 0, 1]\n``` -/\ndef rotate (l : List α) (n : ℕ) : List α :=\n  let (l₁, l₂) := List.splitAt (n % l.length) l\n  l₂ ++ l₁\n\n/-- rotate' is the same as `rotate`, but slower. Used for proofs about `rotate`-/\ndef rotate' : List α → ℕ → List α\n| [], n => []\n| l, 0 => l\n| a :: l, n+1 => rotate' (l ++ [a]) n\n\ndef mmap {m : Type u → Type v} [Monad m] {α β} (f : α → m β) : List α → m (List β)\n| [] => pure []\n| h :: t => return (← f h) :: (← mmap f t)\n\ndef mmap' {m : Type → Type v} [Monad m] {α β} (f : α → m β) : List α → m Unit\n| [] => pure ()\n| h :: t => f h *> t.mmap' f\n\n/-- Filters and maps elements of a list -/\ndef mmapFilter {m : Type → Type v} [Monad m] {α β} (f : α → m (Option β)) : List α → m (List β)\n| [] => pure []\n| h :: t => do\n  let b ← f h\n  let t' ← t.mmapFilter f\n  pure $ match b with\n  | none => t'\n  | some x => x :: t'\n\n/--\n`mmapUpperTriangle f l` calls `f` on all elements in the upper triangular part of `l × l`.\nThat is, for each `e ∈ l`, it will run `f e e` and then `f e e'`\nfor each `e'` that appears after `e` in `l`.\n```\nmmapUpperTriangle f [1, 2, 3] =\n  return [← f 1 1, ← f 1 2, ← f 1 3, ← f 2 2, ← f 2 3, ← f 3 3]\n``` -/\ndef mmapUpperTriangle {m} [Monad m] {α β : Type u} (f : α → α → m β) : List α → m (List β)\n| [] => pure []\n| h :: t => return (← f h h) :: (← t.mmap (f h)) ++ (← t.mmapUpperTriangle f)\n\n/--\n`mmap'Diag f l` calls `f` on all elements in the upper triangular part of `l × l`.\nThat is, for each `e ∈ l`, it will run `f e e` and then `f e e'`\nfor each `e'` that appears after `e` in `l`.\n```\nmmap'Diag f [1, 2, 3] = do f 1 1; f 1 2; f 1 3; f 2 2; f 2 3; f 3 3\n``` -/\ndef mmap'Diag {m} [Monad m] {α} (f : α → α → m Unit) : List α → m Unit\n| [] => return ()\n| h :: t => do f h h; t.mmap' (f h); t.mmap'Diag f\n\nprotected def traverse {F : Type u → Type v} [Applicative F] {α β} (f : α → F β) : List α → F (List β)\n| [] => pure []\n| x :: xs => cons <$> f x <*> List.traverse f xs\n\n/-- `getRest l l₁` returns `some l₂` if `l = l₁ ++ l₂`.\n  If `l₁` is not a prefix of `l`, returns `none` -/\ndef getRest [DecidableEq α] : List α → List α → Option (List α)\n| l, [] => some l\n| [], _ => none\n| x :: l, y :: l₁ => if x = y then getRest l l₁ else none\n\n/--\n`List.slice n m xs` removes a slice of length `m` at index `n` in list `xs`.\n-/\ndef slice {α} : ℕ → ℕ → List α → List α\n| 0, n, xs => xs.drop n\n| n+1, m, [] => []\n| n+1, m, x :: xs => x :: slice n m xs\n\n/--\nLeft-biased version of `List.map₂`. `map₂Left' f as bs` applies `f` to each\npair of elements `aᵢ ∈ as` and `bᵢ ∈ bs`. If `bs` is shorter than `as`, `f` is\napplied to `none` for the remaining `aᵢ`. Returns the results of the `f`\napplications and the remaining `bs`.\n```\nmap₂Left' prod.mk [1, 2] ['a'] = ([(1, some 'a'), (2, none)], [])\nmap₂Left' prod.mk [1] ['a', 'b'] = ([(1, some 'a')], ['b'])\n```\n-/\n@[simp]\ndef map₂Left' (f : α → Option β → γ) : List α → List β → List γ × List β\n| [], bs => ([], bs)\n| a :: as, [] => ((a :: as).map fun a => f a none, [])\n| a :: as, b :: bs => let r := map₂Left' f as bs; (f a (some b) :: r.1, r.2)\n\n/--\nRight-biased version of `List.map₂`. `map₂Right' f as bs` applies `f` to each\npair of elements `aᵢ ∈ as` and `bᵢ ∈ bs`. If `as` is shorter than `bs`, `f` is\napplied to `none` for the remaining `bᵢ`. Returns the results of the `f`\napplications and the remaining `as`.\n```\nmap₂Right' prod.mk [1] ['a', 'b'] = ([(some 1, 'a'), (none, 'b')], [])\nmap₂Right' prod.mk [1, 2] ['a'] = ([(some 1, 'a')], [2])\n```\n-/\ndef map₂Right' (f : Option α → β → γ) (as : List α) (bs : List β) : List γ × List α :=\n  map₂Left' (flip f) bs as\n\n/--\nLeft-biased version of `List.zip`. `zipLeft' as bs` returns the list of\npairs `(aᵢ, bᵢ)` for `aᵢ ∈ as` and `bᵢ ∈ bs`. If `bs` is shorter than `as`, the\nremaining `aᵢ` are paired with `none`. Also returns the remaining `bs`.\n```\nzipLeft' [1, 2] ['a'] = ([(1, some 'a'), (2, none)], [])\nzipLeft' [1] ['a', 'b'] = ([(1, some 'a')], ['b'])\nzipLeft' = map₂Left' prod.mk\n```\n-/\ndef zipLeft' : List α → List β → List (α × Option β) × List β :=\n  map₂Left' Prod.mk\n\n/--\nRight-biased version of `List.zip`. `zipRight' as bs` returns the list of\npairs `(aᵢ, bᵢ)` for `aᵢ ∈ as` and `bᵢ ∈ bs`. If `as` is shorter than `bs`, the\nremaining `bᵢ` are paired with `none`. Also returns the remaining `as`.\n```\nzipRight' [1] ['a', 'b'] = ([(some 1, 'a'), (none, 'b')], [])\nzipRight' [1, 2] ['a'] = ([(some 1, 'a')], [2])\nzipRight' = map₂Right' prod.mk\n```\n-/\ndef zipRight' : List α → List β → List (Option α × β) × List α :=\n  map₂Right' Prod.mk\n\n/--\nLeft-biased version of `List.map₂`. `map₂Left f as bs` applies `f` to each pair\n`aᵢ ∈ as` and `bᵢ ‌∈ bs`. If `bs` is shorter than `as`, `f` is applied to `none`\nfor the remaining `aᵢ`.\n```\nmap₂Left prod.mk [1, 2] ['a'] = [(1, some 'a'), (2, none)]\nmap₂Left prod.mk [1] ['a', 'b'] = [(1, some 'a')]\nmap₂Left f as bs = (map₂Left' f as bs).fst\n```\n-/\n@[simp]\ndef map₂Left (f : α → Option β → γ) : List α → List β → List γ\n| [], _ => []\n| a :: as, [] => (a :: as).map fun a => f a none\n| a :: as, b :: bs => f a (some b) :: map₂Left f as bs\n\n/--\nRight-biased version of `List.map₂`. `map₂Right f as bs` applies `f` to each\npair `aᵢ ∈ as` and `bᵢ ‌∈ bs`. If `as` is shorter than `bs`, `f` is applied to\n`none` for the remaining `bᵢ`.\n```\nmap₂Right prod.mk [1, 2] ['a'] = [(some 1, 'a')]\nmap₂Right prod.mk [1] ['a', 'b'] = [(some 1, 'a'), (none, 'b')]\nmap₂Right f as bs = (map₂Right' f as bs).fst\n```\n-/\ndef map₂Right (f : Option α → β → γ) (as : List α) (bs : List β) : List γ :=\n  map₂Left (flip f) bs as\n\n/--\nLeft-biased version of `List.zip`. `zipLeft as bs` returns the list of pairs\n`(aᵢ, bᵢ)` for `aᵢ ∈ as` and `bᵢ ∈ bs`. If `bs` is shorter than `as`, the\nremaining `aᵢ` are paired with `none`.\n```\nzipLeft [1, 2] ['a'] = [(1, some 'a'), (2, none)]\nzipLeft [1] ['a', 'b'] = [(1, some 'a')]\nzipLeft = map₂Left prod.mk\n```\n-/\ndef zipLeft : List α → List β → List (α × Option β) :=\n  map₂Left Prod.mk\n\n/--\nRight-biased version of `List.zip`. `zipRight as bs` returns the list of pairs\n`(aᵢ, bᵢ)` for `aᵢ ∈ as` and `bᵢ ∈ bs`. If `as` is shorter than `bs`, the\nremaining `bᵢ` are paired with `none`.\n```\nzipRight [1, 2] ['a'] = [(some 1, 'a')]\nzipRight [1] ['a', 'b'] = [(some 1, 'a'), (none, 'b')]\nzipRight = map₂Right prod.mk\n```\n-/\ndef zipRight : List α → List β → List (Option α × β) :=\n  map₂Right Prod.mk\n\n/--\nIf all elements of `xs` are `some xᵢ`, `allSome xs` returns the `xᵢ`. Otherwise\nit returns `none`.\n```\nallSome [some 1, some 2] = some [1, 2]\nallSome [some 1, none  ] = none\n```\n-/\ndef allSome : List (Option α) → Option (List α)\n| [] => some []\n| some a :: as => cons a <$> allSome as\n| none :: as => none\n\n/--\n`fillNones xs ys` replaces the `none`s in `xs` with elements of `ys`. If there\nare not enough `ys` to replace all the `none`s, the remaining `none`s are\ndropped from `xs`.\n```\nfillNones [none, some 1, none, none] [2, 3] = [2, 1, 3]\n```\n-/\ndef fillNones {α} : List (Option α) → List α → List α\n| [], _ => []\n| some a :: as, as' => a :: fillNones as as'\n| none :: as, [] => as.reduceOption\n| none :: as, a :: as' => a :: fillNones as as'\n\n/--\n`takeList as ns` extracts successive sublists from `as`. For `ns = n₁ ... nₘ`,\nit first takes the `n₁` initial elements from `as`, then the next `n₂` ones,\netc. It returns the sublists of `as` -- one for each `nᵢ` -- and the remaining\nelements of `as`. If `as` does not have at least as many elements as the sum of\nthe `nᵢ`, the corresponding sublists will have less than `nᵢ` elements.\n```\ntakeList ['a', 'b', 'c', 'd', 'e'] [2, 1, 1] = ([['a', 'b'], ['c'], ['d']], ['e'])\ntakeList ['a', 'b'] [3, 1] = ([['a', 'b'], []], [])\n```\n-/\ndef takeList {α} : List α → List ℕ → List (List α) × List α\n| xs, [] => ([], xs)\n| xs, n :: ns =>\n  let ⟨xs₁, xs₂⟩ := xs.splitAt n\n  let ⟨xss, rest⟩ := takeList xs₂ ns\n  (xs₁ :: xss, rest)\n\n/-- Auxliary definition used to define `toChunks`.\n  `toChunksAux n xs i` returns `(xs.take i, (xs.drop i).toChunks (n+1))`,\n  that is, the first `i` elements of `xs`, and the remaining elements chunked into\n  sublists of length `n+1`. -/\ndef toChunksAux {α} (n : ℕ) : List α → ℕ → List α × List (List α)\n| [], i => ([], [])\n| x :: xs, 0 =>\n  let (l, L) := toChunksAux n xs n\n  ([], (x :: l) :: L)\n| x :: xs, i+1 =>\n  let (l, L) := toChunksAux n xs i\n  (x :: l, L)\n\n/--\n`xs.toChunks n` splits the list into sublists of size at most `n`,\nsuch that `(xs.toChunks n).join = xs`.\n```\n[1, 2, 3, 4, 5, 6, 7, 8].toChunks 10 = [[1, 2, 3, 4, 5, 6, 7, 8]]\n[1, 2, 3, 4, 5, 6, 7, 8].toChunks 3 = [[1, 2, 3], [4, 5, 6], [7, 8]]\n[1, 2, 3, 4, 5, 6, 7, 8].toChunks 2 = [[1, 2], [3, 4], [5, 6], [7, 8]]\n[1, 2, 3, 4, 5, 6, 7, 8].toChunks 0 = [[1, 2, 3, 4, 5, 6, 7, 8]]\n```\n-/\ndef toChunks {α} : ℕ → List α → List (List α)\n| _, [] => []\n| 0, xs => [xs]\n| n+1, x :: xs =>\n  let (l, L) := toChunksAux n xs n\n  (x :: l) :: L\n\n/-!\nWe add some n-ary versions of `List.zipWith` for functions with more than two arguments.\nThese can also be written in terms of `List.zip` or `List.zipWith`.\nFor example, `zipWith₃ f xs ys zs` could also be written as\n`zipWith id (zipWith f xs ys) zs`\nor as\n`(zip xs $ zip ys zs).map $ λ ⟨x, y, z⟩, f x y z`.\n-/\n\n\n/-- Ternary version of `List.zipWith`. -/\ndef zipWith₃ (f : α → β → γ → δ) : List α → List β → List γ → List δ\n| x :: xs, y :: ys, z :: zs => f x y z :: zipWith₃ f xs ys zs\n| _, _, _ => []\n\n/-- Quaternary version of `List.zipWith`. -/\ndef zipWith₄ (f : α → β → γ → δ → ε) : List α → List β → List γ → List δ → List ε\n| x :: xs, y :: ys, z :: zs, u :: us => f x y z u :: zipWith₄ f xs ys zs us\n| _, _, _, _ => []\n\n/-- Quinary version of `List.zipWith`. -/\ndef zipWith₅ (f : α → β → γ → δ → ε → ζ) : List α → List β → List γ → List δ → List ε → List ζ\n| x :: xs, y :: ys, z :: zs, u :: us, v :: vs => f x y z u v :: zipWith₅ f xs ys zs us vs\n| _, _, _, _, _ => []\n\n/-- An auxiliary function for `List.mapWithPrefixSuffix`. -/\ndef mapWithPrefixSuffixAux {α β} (f : List α → α → List α → β) : List α → List α → List β\n| prev, [] => []\n| prev, h :: t => f prev h t :: mapWithPrefixSuffixAux f (prev.concat h) t\n\n/--\n`List.mapWithPrefixSuffix f l` maps `f` across a list `l`.\nFor each `a ∈ l` with `l = pref ++ [a] ++ suff`, `a` is mapped to `f pref a suff`.\nExample: if `f : list ℕ → ℕ → list ℕ → β`,\n`List.mapWithPrefixSuffix f [1, 2, 3]` will produce the list\n`[f [] 1 [2, 3], f [1] 2 [3], f [1, 2] 3 []]`.\n-/\ndef mapWithPrefixSuffix {α β} (f : List α → α → List α → β) (l : List α) : List β :=\n  mapWithPrefixSuffixAux f [] l\n\n/--\n`List.mapWithComplement f l` is a variant of `List.mapWithPrefixSuffix`\nthat maps `f` across a list `l`.\nFor each `a ∈ l` with `l = pref ++ [a] ++ suff`, `a` is mapped to `f a (pref ++ suff)`,\ni.e., the list input to `f` is `l` with `a` removed.\nExample: if `f : ℕ → list ℕ → β`, `List.mapWithComplement f [1, 2, 3]` will produce the list\n`[f 1 [2, 3], f 2 [1, 3], f 3 [1, 2]]`.\n-/\ndef mapWithComplement {α β} (f : α → List α → β) : List α → List β :=\n  mapWithPrefixSuffix fun pref a suff => f a (pref ++ suff)\n\nend List\n", "meta": {"author": "JOSHCLUNE", "repo": "Keller_reduction", "sha": "dc392b3da352fc1ffcfbecb1d4717d05f5faed4a", "save_path": "github-repos/lean/JOSHCLUNE-Keller_reduction", "path": "github-repos/lean/JOSHCLUNE-Keller_reduction/Keller_reduction-dc392b3da352fc1ffcfbecb1d4717d05f5faed4a/Lean4_Clique/Mathlib/Mathlib/Data/List/Defs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.785308580887758, "lm_q1q2_score": 0.4565023051795534}}
{"text": "/-\nCopyright (c) 2018 Sean Leather. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sean Leather, Mario Carneiro\n\n! This file was ported from Lean 3 source module data.list.alist\n! leanprover-community/mathlib commit f808feb6c18afddb25e66a71d317643cf7fb5fbb\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.List.Sigma\n\n/-!\n# Association Lists\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines association lists. An association list is a list where every element consists of\na key and a value, and no two entries have the same key. The type of the value is allowed to be\ndependent on the type of the key.\n\nThis type dependence is implemented using `sigma`: The elements of the list are of type `sigma β`,\nfor some type index `β`.\n\n## Main definitions\n\nAssociation lists are represented by the `alist` structure. This file defines this structure and\nprovides ways to access, modify, and combine `alist`s.\n\n* `alist.keys` returns a list of keys of the alist.\n* `alist.has_mem` returns membership in the set of keys.\n* `alist.erase` removes a certain key.\n* `alist.insert` adds a key-value mapping to the list.\n* `alist.union` combines two association lists.\n\n## References\n\n* <https://en.wikipedia.org/wiki/Association_list>\n\n-/\n\n\nuniverse u v w\n\nopen List\n\nvariable {α : Type u} {β : α → Type v}\n\n#print AList /-\n/-- `alist β` is a key-value map stored as a `list` (i.e. a linked list).\n  It is a wrapper around certain `list` functions with the added constraint\n  that the list have unique keys. -/\nstructure AList (β : α → Type v) : Type max u v where\n  entries : List (Sigma β)\n  NodupKeys : entries.NodupKeys\n#align alist AList\n-/\n\n#print List.toAList /-\n/-- Given `l : list (sigma β)`, create a term of type `alist β` by removing\nentries with duplicate keys. -/\ndef List.toAList [DecidableEq α] {β : α → Type v} (l : List (Sigma β)) : AList β\n    where\n  entries := _\n  NodupKeys := nodupKeys_dedupKeys l\n#align list.to_alist List.toAList\n-/\n\nnamespace AList\n\n#print AList.ext /-\n@[ext]\ntheorem ext : ∀ {s t : AList β}, s.entries = t.entries → s = t\n  | ⟨l₁, h₁⟩, ⟨l₂, h₂⟩, H => by congr\n#align alist.ext AList.ext\n-/\n\n#print AList.ext_iff /-\ntheorem ext_iff {s t : AList β} : s = t ↔ s.entries = t.entries :=\n  ⟨congr_arg _, ext⟩\n#align alist.ext_iff AList.ext_iff\n-/\n\ninstance [DecidableEq α] [∀ a, DecidableEq (β a)] : DecidableEq (AList β) := fun xs ys => by\n  rw [ext_iff] <;> infer_instance\n\n/-! ### keys -/\n\n\n#print AList.keys /-\n/-- The list of keys of an association list. -/\ndef keys (s : AList β) : List α :=\n  s.entries.keys\n#align alist.keys AList.keys\n-/\n\n#print AList.keys_nodup /-\ntheorem keys_nodup (s : AList β) : s.keys.Nodup :=\n  s.NodupKeys\n#align alist.keys_nodup AList.keys_nodup\n-/\n\n/-! ### mem -/\n\n\n/-- The predicate `a ∈ s` means that `s` has a value associated to the key `a`. -/\ninstance : Membership α (AList β) :=\n  ⟨fun a s => a ∈ s.keys⟩\n\n#print AList.mem_keys /-\ntheorem mem_keys {a : α} {s : AList β} : a ∈ s ↔ a ∈ s.keys :=\n  Iff.rfl\n#align alist.mem_keys AList.mem_keys\n-/\n\n#print AList.mem_of_perm /-\ntheorem mem_of_perm {a : α} {s₁ s₂ : AList β} (p : s₁.entries ~ s₂.entries) : a ∈ s₁ ↔ a ∈ s₂ :=\n  (p.map Sigma.fst).mem_iff\n#align alist.mem_of_perm AList.mem_of_perm\n-/\n\n/-! ### empty -/\n\n\n/-- The empty association list. -/\ninstance : EmptyCollection (AList β) :=\n  ⟨⟨[], nodupKeys_nil⟩⟩\n\ninstance : Inhabited (AList β) :=\n  ⟨∅⟩\n\n#print AList.not_mem_empty /-\n@[simp]\ntheorem not_mem_empty (a : α) : a ∉ (∅ : AList β) :=\n  not_mem_nil a\n#align alist.not_mem_empty AList.not_mem_empty\n-/\n\n#print AList.empty_entries /-\n@[simp]\ntheorem empty_entries : (∅ : AList β).entries = [] :=\n  rfl\n#align alist.empty_entries AList.empty_entries\n-/\n\n#print AList.keys_empty /-\n@[simp]\ntheorem keys_empty : (∅ : AList β).keys = [] :=\n  rfl\n#align alist.keys_empty AList.keys_empty\n-/\n\n/-! ### singleton -/\n\n\n#print AList.singleton /-\n/-- The singleton association list. -/\ndef singleton (a : α) (b : β a) : AList β :=\n  ⟨[⟨a, b⟩], nodupKeys_singleton _⟩\n#align alist.singleton AList.singleton\n-/\n\n#print AList.singleton_entries /-\n@[simp]\ntheorem singleton_entries (a : α) (b : β a) : (singleton a b).entries = [Sigma.mk a b] :=\n  rfl\n#align alist.singleton_entries AList.singleton_entries\n-/\n\n#print AList.keys_singleton /-\n@[simp]\ntheorem keys_singleton (a : α) (b : β a) : (singleton a b).keys = [a] :=\n  rfl\n#align alist.keys_singleton AList.keys_singleton\n-/\n\n/-! ### lookup -/\n\n\nsection\n\nvariable [DecidableEq α]\n\n#print AList.lookup /-\n/-- Look up the value associated to a key in an association list. -/\ndef lookup (a : α) (s : AList β) : Option (β a) :=\n  s.entries.dlookup a\n#align alist.lookup AList.lookup\n-/\n\n#print AList.lookup_empty /-\n@[simp]\ntheorem lookup_empty (a) : lookup a (∅ : AList β) = none :=\n  rfl\n#align alist.lookup_empty AList.lookup_empty\n-/\n\n#print AList.lookup_isSome /-\ntheorem lookup_isSome {a : α} {s : AList β} : (s.dlookup a).isSome ↔ a ∈ s :=\n  dlookup_isSome\n#align alist.lookup_is_some AList.lookup_isSome\n-/\n\n#print AList.lookup_eq_none /-\ntheorem lookup_eq_none {a : α} {s : AList β} : lookup a s = none ↔ a ∉ s :=\n  dlookup_eq_none\n#align alist.lookup_eq_none AList.lookup_eq_none\n-/\n\n#print AList.mem_lookup_iff /-\ntheorem mem_lookup_iff {a : α} {b : β a} {s : AList β} :\n    b ∈ lookup a s ↔ Sigma.mk a b ∈ s.entries :=\n  mem_dlookup_iff s.NodupKeys\n#align alist.mem_lookup_iff AList.mem_lookup_iff\n-/\n\n#print AList.perm_lookup /-\ntheorem perm_lookup {a : α} {s₁ s₂ : AList β} (p : s₁.entries ~ s₂.entries) :\n    s₁.dlookup a = s₂.dlookup a :=\n  perm_dlookup _ s₁.NodupKeys s₂.NodupKeys p\n#align alist.perm_lookup AList.perm_lookup\n-/\n\ninstance (a : α) (s : AList β) : Decidable (a ∈ s) :=\n  decidable_of_iff _ lookup_isSome\n\n/-! ### replace -/\n\n\n#print AList.replace /-\n/-- Replace a key with a given value in an association list.\n  If the key is not present it does nothing. -/\ndef replace (a : α) (b : β a) (s : AList β) : AList β :=\n  ⟨kreplace a b s.entries, (kreplace_nodupKeys a b).2 s.NodupKeys⟩\n#align alist.replace AList.replace\n-/\n\n#print AList.keys_replace /-\n@[simp]\ntheorem keys_replace (a : α) (b : β a) (s : AList β) : (replace a b s).keys = s.keys :=\n  keys_kreplace _ _ _\n#align alist.keys_replace AList.keys_replace\n-/\n\n#print AList.mem_replace /-\n@[simp]\ntheorem mem_replace {a a' : α} {b : β a} {s : AList β} : a' ∈ replace a b s ↔ a' ∈ s := by\n  rw [mem_keys, keys_replace, ← mem_keys]\n#align alist.mem_replace AList.mem_replace\n-/\n\n#print AList.perm_replace /-\ntheorem perm_replace {a : α} {b : β a} {s₁ s₂ : AList β} :\n    s₁.entries ~ s₂.entries → (replace a b s₁).entries ~ (replace a b s₂).entries :=\n  Perm.kreplace s₁.NodupKeys\n#align alist.perm_replace AList.perm_replace\n-/\n\nend\n\n#print AList.foldl /-\n/-- Fold a function over the key-value pairs in the map. -/\ndef foldl {δ : Type w} (f : δ → ∀ a, β a → δ) (d : δ) (m : AList β) : δ :=\n  m.entries.foldl (fun r a => f r a.1 a.2) d\n#align alist.foldl AList.foldl\n-/\n\n/-! ### erase -/\n\n\nsection\n\nvariable [DecidableEq α]\n\n#print AList.erase /-\n/-- Erase a key from the map. If the key is not present, do nothing. -/\ndef erase (a : α) (s : AList β) : AList β :=\n  ⟨s.entries.kerase a, s.NodupKeys.kerase a⟩\n#align alist.erase AList.erase\n-/\n\n/- warning: alist.keys_erase -> AList.keys_erase is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] (a : α) (s : AList.{u1, u2} α β), Eq.{succ u1} (List.{u1} α) (AList.keys.{u1, u2} α β (AList.erase.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a s)) (List.eraseₓ.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (AList.keys.{u1, u2} α β s) a)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] (a : α) (s : AList.{u1, u2} α β), Eq.{succ u1} (List.{u1} α) (AList.keys.{u1, u2} α β (AList.erase.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a s)) (List.erase.{u1} α (instBEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (AList.keys.{u1, u2} α β s) a)\nCase conversion may be inaccurate. Consider using '#align alist.keys_erase AList.keys_eraseₓ'. -/\n@[simp]\ntheorem keys_erase (a : α) (s : AList β) : (erase a s).keys = s.keys.eraseₓ a :=\n  keys_kerase\n#align alist.keys_erase AList.keys_erase\n\n#print AList.mem_erase /-\n@[simp]\ntheorem mem_erase {a a' : α} {s : AList β} : a' ∈ erase a s ↔ a' ≠ a ∧ a' ∈ s := by\n  rw [mem_keys, keys_erase, s.keys_nodup.mem_erase_iff, ← mem_keys]\n#align alist.mem_erase AList.mem_erase\n-/\n\n#print AList.perm_erase /-\ntheorem perm_erase {a : α} {s₁ s₂ : AList β} :\n    s₁.entries ~ s₂.entries → (erase a s₁).entries ~ (erase a s₂).entries :=\n  Perm.kerase s₁.NodupKeys\n#align alist.perm_erase AList.perm_erase\n-/\n\n#print AList.lookup_erase /-\n@[simp]\ntheorem lookup_erase (a) (s : AList β) : lookup a (erase a s) = none :=\n  dlookup_kerase a s.NodupKeys\n#align alist.lookup_erase AList.lookup_erase\n-/\n\n#print AList.lookup_erase_ne /-\n@[simp]\ntheorem lookup_erase_ne {a a'} {s : AList β} (h : a ≠ a') : lookup a (erase a' s) = lookup a s :=\n  dlookup_kerase_ne h\n#align alist.lookup_erase_ne AList.lookup_erase_ne\n-/\n\n#print AList.erase_erase /-\ntheorem erase_erase (a a' : α) (s : AList β) : (s.eraseₓ a).eraseₓ a' = (s.eraseₓ a').eraseₓ a :=\n  ext <| kerase_kerase\n#align alist.erase_erase AList.erase_erase\n-/\n\n/-! ### insert -/\n\n\n#print AList.insert /-\n/-- Insert a key-value pair into an association list and erase any existing pair\n  with the same key. -/\ndef insert (a : α) (b : β a) (s : AList β) : AList β :=\n  ⟨kinsert a b s.entries, kinsert_nodupKeys a b s.NodupKeys⟩\n#align alist.insert AList.insert\n-/\n\n#print AList.insert_entries /-\n@[simp]\ntheorem insert_entries {a} {b : β a} {s : AList β} :\n    (insert a b s).entries = Sigma.mk a b :: kerase a s.entries :=\n  rfl\n#align alist.insert_entries AList.insert_entries\n-/\n\n#print AList.insert_entries_of_neg /-\ntheorem insert_entries_of_neg {a} {b : β a} {s : AList β} (h : a ∉ s) :\n    (insert a b s).entries = ⟨a, b⟩ :: s.entries := by rw [insert_entries, kerase_of_not_mem_keys h]\n#align alist.insert_entries_of_neg AList.insert_entries_of_neg\n-/\n\n#print AList.insert_of_neg /-\n-- Todo: rename to `insert_of_not_mem`.\ntheorem insert_of_neg {a} {b : β a} {s : AList β} (h : a ∉ s) :\n    insert a b s = ⟨⟨a, b⟩ :: s.entries, nodupKeys_cons.2 ⟨h, s.2⟩⟩ :=\n  ext <| insert_entries_of_neg h\n#align alist.insert_of_neg AList.insert_of_neg\n-/\n\n#print AList.insert_empty /-\n@[simp]\ntheorem insert_empty (a) (b : β a) : insert a b ∅ = singleton a b :=\n  rfl\n#align alist.insert_empty AList.insert_empty\n-/\n\n#print AList.mem_insert /-\n@[simp]\ntheorem mem_insert {a a'} {b' : β a'} (s : AList β) : a ∈ insert a' b' s ↔ a = a' ∨ a ∈ s :=\n  mem_keys_kinsert\n#align alist.mem_insert AList.mem_insert\n-/\n\n/- warning: alist.keys_insert -> AList.keys_insert is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] {a : α} {b : β a} (s : AList.{u1, u2} α β), Eq.{succ u1} (List.{u1} α) (AList.keys.{u1, u2} α (fun {a : α} => β a) (AList.insert.{u1, u2} α (fun {a : α} => β a) (fun (a : α) (b : α) => _inst_1 a b) a b s)) (List.cons.{u1} α a (List.eraseₓ.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (AList.keys.{u1, u2} α β s) a))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] {a : α} {b : β a} (s : AList.{u1, u2} α β), Eq.{succ u1} (List.{u1} α) (AList.keys.{u1, u2} α β (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a b s)) (List.cons.{u1} α a (List.erase.{u1} α (instBEq.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) (AList.keys.{u1, u2} α β s) a))\nCase conversion may be inaccurate. Consider using '#align alist.keys_insert AList.keys_insertₓ'. -/\n@[simp]\ntheorem keys_insert {a} {b : β a} (s : AList β) : (insert a b s).keys = a :: s.keys.eraseₓ a := by\n  simp [insert, keys, keys_kerase]\n#align alist.keys_insert AList.keys_insert\n\n#print AList.perm_insert /-\ntheorem perm_insert {a} {b : β a} {s₁ s₂ : AList β} (p : s₁.entries ~ s₂.entries) :\n    (insert a b s₁).entries ~ (insert a b s₂).entries := by\n  simp only [insert_entries] <;> exact p.kinsert s₁.nodupkeys\n#align alist.perm_insert AList.perm_insert\n-/\n\n#print AList.lookup_insert /-\n@[simp]\ntheorem lookup_insert {a} {b : β a} (s : AList β) : lookup a (insert a b s) = some b := by\n  simp only [lookup, insert, lookup_kinsert]\n#align alist.lookup_insert AList.lookup_insert\n-/\n\n#print AList.lookup_insert_ne /-\n@[simp]\ntheorem lookup_insert_ne {a a'} {b' : β a'} {s : AList β} (h : a ≠ a') :\n    lookup a (insert a' b' s) = lookup a s :=\n  dlookup_kinsert_ne h\n#align alist.lookup_insert_ne AList.lookup_insert_ne\n-/\n\n#print AList.lookup_to_alist /-\n@[simp]\ntheorem lookup_to_alist {a} (s : List (Sigma β)) : lookup a s.toAList = s.dlookup a := by\n  rw [List.toAList, lookup, lookup_dedupkeys]\n#align alist.lookup_to_alist AList.lookup_to_alist\n-/\n\n#print AList.insert_insert /-\n@[simp]\ntheorem insert_insert {a} {b b' : β a} (s : AList β) : (s.insert a b).insert a b' = s.insert a b' :=\n  by\n  ext : 1 <;> simp only [AList.insert_entries, List.kerase_cons_eq] <;> constructorm*_ ∧ _ <;> rfl\n#align alist.insert_insert AList.insert_insert\n-/\n\n#print AList.insert_insert_of_ne /-\ntheorem insert_insert_of_ne {a a'} {b : β a} {b' : β a'} (s : AList β) (h : a ≠ a') :\n    ((s.insert a b).insert a' b').entries ~ ((s.insert a' b').insert a b).entries := by\n  simp only [insert_entries] <;> rw [kerase_cons_ne, kerase_cons_ne, kerase_comm] <;>\n    [apply perm.swap, exact h, exact h.symm]\n#align alist.insert_insert_of_ne AList.insert_insert_of_ne\n-/\n\n#print AList.insert_singleton_eq /-\n@[simp]\ntheorem insert_singleton_eq {a : α} {b b' : β a} : insert a b (singleton a b') = singleton a b :=\n  ext <| by\n    simp only [AList.insert_entries, List.kerase_cons_eq, and_self_iff, AList.singleton_entries,\n      heq_iff_eq, eq_self_iff_true]\n#align alist.insert_singleton_eq AList.insert_singleton_eq\n-/\n\n#print AList.entries_toAList /-\n@[simp]\ntheorem entries_toAList (xs : List (Sigma β)) : (List.toAList xs).entries = dedupKeys xs :=\n  rfl\n#align alist.entries_to_alist AList.entries_toAList\n-/\n\n#print AList.toAList_cons /-\ntheorem toAList_cons (a : α) (b : β a) (xs : List (Sigma β)) :\n    List.toAList (⟨a, b⟩ :: xs) = insert a b xs.toAList :=\n  rfl\n#align alist.to_alist_cons AList.toAList_cons\n-/\n\n#print AList.mk_cons_eq_insert /-\ntheorem mk_cons_eq_insert (c : Sigma β) (l : List (Sigma β)) (h : (c :: l).NodupKeys) :\n    (⟨c :: l, h⟩ : AList β) = insert c.1 c.2 ⟨l, nodupKeys_of_nodupKeys_cons h⟩ := by\n  simpa [insert] using (kerase_of_not_mem_keys <| not_mem_keys_of_nodupkeys_cons h).symm\n#align alist.mk_cons_eq_insert AList.mk_cons_eq_insert\n-/\n\n#print AList.insertRec /-\n/-- Recursion on an `alist`, using `insert`. Use as `induction l using alist.insert_rec`. -/\n@[elab_as_elim]\ndef insertRec {C : AList β → Sort _} (H0 : C ∅)\n    (IH : ∀ (a : α) (b : β a) (l : AList β) (h : a ∉ l), C l → C (l.insert a b)) :\n    ∀ l : AList β, C l\n  | ⟨[], _⟩ => H0\n  | ⟨c :: l, h⟩ => by\n    rw [mk_cons_eq_insert]\n    refine' IH _ _ _ _ (insert_rec _)\n    exact not_mem_keys_of_nodupkeys_cons h\n#align alist.insert_rec AList.insertRec\n-/\n\n-- Test that the `induction` tactic works on `insert_rec`.\nexample (l : AList β) : True := by induction l using AList.insertRec <;> trivial\n\n/- warning: alist.insert_rec_empty -> AList.insertRec_empty is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] {C : (AList.{u1, u2} α β) -> Sort.{u3}} (H0 : C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α β) (AList.hasEmptyc.{u1, u2} α β))) (IH : forall (a : α) (b : β a) (l : AList.{u1, u2} α β), (Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α β) (AList.hasMem.{u1, u2} α β) a l)) -> (C l) -> (C (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a b l))), Eq.{u3} (C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α β) (AList.hasEmptyc.{u1, u2} α β))) (AList.insertRec.{u1, u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α β) (AList.hasEmptyc.{u1, u2} α β))) H0\nbut is expected to have type\n  forall {α : Type.{u2}} {β : α -> Type.{u3}} [_inst_1 : DecidableEq.{succ u2} α] {C : (AList.{u2, u3} α β) -> Sort.{u1}} (H0 : C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} α β) (AList.instEmptyCollectionAList.{u2, u3} α β))) (IH : forall (a : α) (b : β a) (l : AList.{u2, u3} α β), (Not (Membership.mem.{u2, max u2 u3} α (AList.{u2, u3} α β) (AList.instMembershipAList.{u2, u3} α β) a l)) -> (C l) -> (C (AList.insert.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) a b l))), Eq.{u1} (C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} α β) (AList.instEmptyCollectionAList.{u2, u3} α β))) (AList.insertRec.{u2, u3, u1} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} α β) (AList.instEmptyCollectionAList.{u2, u3} α β))) H0\nCase conversion may be inaccurate. Consider using '#align alist.insert_rec_empty AList.insertRec_emptyₓ'. -/\n@[simp]\ntheorem insertRec_empty {C : AList β → Sort _} (H0 : C ∅)\n    (IH : ∀ (a : α) (b : β a) (l : AList β) (h : a ∉ l), C l → C (l.insert a b)) :\n    @insertRec α β _ C H0 IH ∅ = H0 :=\n  by\n  change @insert_rec α β _ C H0 IH ⟨[], _⟩ = H0\n  rw [insert_rec]\n#align alist.insert_rec_empty AList.insertRec_empty\n\n/- warning: alist.insert_rec_insert -> AList.insertRec_insert is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] {C : (AList.{u1, u2} α β) -> Sort.{u3}} (H0 : C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α β) (AList.hasEmptyc.{u1, u2} α β))) (IH : forall (a : α) (b : β a) (l : AList.{u1, u2} α β), (Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α β) (AList.hasMem.{u1, u2} α β) a l)) -> (C l) -> (C (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a b l))) {c : Sigma.{u1, u2} α β} {l : AList.{u1, u2} α β} (h : Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α β) (AList.hasMem.{u1, u2} α β) (Sigma.fst.{u1, u2} α β c) l)), Eq.{u3} (C (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (Sigma.fst.{u1, u2} α β c) (Sigma.snd.{u1, u2} α β c) l)) (AList.insertRec.{u1, u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) (Sigma.fst.{u1, u2} α β c) (Sigma.snd.{u1, u2} α β c) l)) (IH (Sigma.fst.{u1, u2} α β c) (Sigma.snd.{u1, u2} α β c) l h (AList.insertRec.{u1, u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH l))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : α -> Type.{u3}} [_inst_1 : DecidableEq.{succ u2} α] {C : (AList.{u2, u3} α β) -> Sort.{u1}} (H0 : C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} α β) (AList.instEmptyCollectionAList.{u2, u3} α β))) (IH : forall (a : α) (b : β a) (l : AList.{u2, u3} α β), (Not (Membership.mem.{u2, max u2 u3} α (AList.{u2, u3} α β) (AList.instMembershipAList.{u2, u3} α β) a l)) -> (C l) -> (C (AList.insert.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) a b l))) {c : Sigma.{u2, u3} α β} {l : AList.{u2, u3} α β} (h : Not (Membership.mem.{u2, max u2 u3} α (AList.{u2, u3} α β) (AList.instMembershipAList.{u2, u3} α β) (Sigma.fst.{u2, u3} α β c) l)), Eq.{u1} (C (AList.insert.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) (Sigma.fst.{u2, u3} α β c) (Sigma.snd.{u2, u3} α β c) l)) (AList.insertRec.{u2, u3, u1} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH (AList.insert.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) (Sigma.fst.{u2, u3} α β c) (Sigma.snd.{u2, u3} α β c) l)) (IH (Sigma.fst.{u2, u3} α β c) (Sigma.snd.{u2, u3} α β c) l h (AList.insertRec.{u2, u3, u1} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH l))\nCase conversion may be inaccurate. Consider using '#align alist.insert_rec_insert AList.insertRec_insertₓ'. -/\ntheorem insertRec_insert {C : AList β → Sort _} (H0 : C ∅)\n    (IH : ∀ (a : α) (b : β a) (l : AList β) (h : a ∉ l), C l → C (l.insert a b)) {c : Sigma β}\n    {l : AList β} (h : c.1 ∉ l) :\n    @insertRec α β _ C H0 IH (l.insert c.1 c.2) = IH c.1 c.2 l h (@insertRec α β _ C H0 IH l) :=\n  by\n  cases' l with l hl\n  suffices\n    HEq (@insert_rec α β _ C H0 IH ⟨c :: l, nodupkeys_cons.2 ⟨h, hl⟩⟩)\n      (IH c.1 c.2 ⟨l, hl⟩ h (@insert_rec α β _ C H0 IH ⟨l, hl⟩))\n    by\n    cases c\n    apply eq_of_hEq\n    convert this <;> rw [insert_of_neg h]\n  rw [insert_rec]\n  apply cast_hEq\n#align alist.insert_rec_insert AList.insertRec_insert\n\n/- warning: alist.recursion_insert_mk -> AList.insertRec_insert_mk is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : α -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} α] {C : (AList.{u1, u2} α β) -> Sort.{u3}} (H0 : C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α β) (AList.hasEmptyc.{u1, u2} α β))) (IH : forall (a : α) (b : β a) (l : AList.{u1, u2} α β), (Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α β) (AList.hasMem.{u1, u2} α β) a l)) -> (C l) -> (C (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a b l))) {a : α} (b : β a) {l : AList.{u1, u2} α β} (h : Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α β) (AList.hasMem.{u1, u2} α β) a l)), Eq.{u3} (C (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a b l)) (AList.insertRec.{u1, u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH (AList.insert.{u1, u2} α β (fun (a : α) (b : α) => _inst_1 a b) a b l)) (IH a b l h (AList.insertRec.{u1, u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH l))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : α -> Type.{u3}} [_inst_1 : DecidableEq.{succ u2} α] {C : (AList.{u2, u3} α β) -> Sort.{u1}} (H0 : C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} α β) (AList.instEmptyCollectionAList.{u2, u3} α β))) (IH : forall (a : α) (b : β a) (l : AList.{u2, u3} α β), (Not (Membership.mem.{u2, max u2 u3} α (AList.{u2, u3} α β) (AList.instMembershipAList.{u2, u3} α β) a l)) -> (C l) -> (C (AList.insert.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) a b l))) {a : α} (b : β a) {l : AList.{u2, u3} α β} (h : Not (Membership.mem.{u2, max u2 u3} α (AList.{u2, u3} α β) (AList.instMembershipAList.{u2, u3} α β) a l)), Eq.{u1} (C (AList.insert.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) a b l)) (AList.insertRec.{u2, u3, u1} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH (AList.insert.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) a b l)) (IH a b l h (AList.insertRec.{u2, u3, u1} α β (fun (a : α) (b : α) => _inst_1 a b) C H0 IH l))\nCase conversion may be inaccurate. Consider using '#align alist.recursion_insert_mk AList.insertRec_insert_mkₓ'. -/\ntheorem insertRec_insert_mk {C : AList β → Sort _} (H0 : C ∅)\n    (IH : ∀ (a : α) (b : β a) (l : AList β) (h : a ∉ l), C l → C (l.insert a b)) {a : α} (b : β a)\n    {l : AList β} (h : a ∉ l) :\n    @insertRec α β _ C H0 IH (l.insert a b) = IH a b l h (@insertRec α β _ C H0 IH l) :=\n  @insertRec_insert α β _ C H0 IH ⟨a, b⟩ l h\n#align alist.recursion_insert_mk AList.insertRec_insert_mk\n\n/-! ### extract -/\n\n\n#print AList.extract /-\n/-- Erase a key from the map, and return the corresponding value, if found. -/\ndef extract (a : α) (s : AList β) : Option (β a) × AList β :=\n  have : (kextract a s.entries).2.NodupKeys := by\n    rw [kextract_eq_lookup_kerase] <;> exact s.nodupkeys.kerase _\n  match kextract a s.entries, this with\n  | (b, l), h => (b, ⟨l, h⟩)\n#align alist.extract AList.extract\n-/\n\n#print AList.extract_eq_lookup_erase /-\n@[simp]\ntheorem extract_eq_lookup_erase (a : α) (s : AList β) : extract a s = (lookup a s, erase a s) := by\n  simp [extract] <;> constructor <;> rfl\n#align alist.extract_eq_lookup_erase AList.extract_eq_lookup_erase\n-/\n\n/-! ### union -/\n\n\n#print AList.union /-\n/-- `s₁ ∪ s₂` is the key-based union of two association lists. It is\nleft-biased: if there exists an `a ∈ s₁`, `lookup a (s₁ ∪ s₂) = lookup a s₁`.\n-/\ndef union (s₁ s₂ : AList β) : AList β :=\n  ⟨s₁.entries.kunion s₂.entries, s₁.NodupKeys.kunion s₂.NodupKeys⟩\n#align alist.union AList.union\n-/\n\ninstance : Union (AList β) :=\n  ⟨union⟩\n\n#print AList.union_entries /-\n@[simp]\ntheorem union_entries {s₁ s₂ : AList β} : (s₁ ∪ s₂).entries = kunion s₁.entries s₂.entries :=\n  rfl\n#align alist.union_entries AList.union_entries\n-/\n\n#print AList.empty_union /-\n@[simp]\ntheorem empty_union {s : AList β} : (∅ : AList β) ∪ s = s :=\n  ext rfl\n#align alist.empty_union AList.empty_union\n-/\n\n#print AList.union_empty /-\n@[simp]\ntheorem union_empty {s : AList β} : s ∪ (∅ : AList β) = s :=\n  ext <| by simp\n#align alist.union_empty AList.union_empty\n-/\n\n#print AList.mem_union /-\n@[simp]\ntheorem mem_union {a} {s₁ s₂ : AList β} : a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂ :=\n  mem_keys_kunion\n#align alist.mem_union AList.mem_union\n-/\n\n#print AList.perm_union /-\ntheorem perm_union {s₁ s₂ s₃ s₄ : AList β} (p₁₂ : s₁.entries ~ s₂.entries)\n    (p₃₄ : s₃.entries ~ s₄.entries) : (s₁ ∪ s₃).entries ~ (s₂ ∪ s₄).entries := by\n  simp [p₁₂.kunion s₃.nodupkeys p₃₄]\n#align alist.perm_union AList.perm_union\n-/\n\n#print AList.union_erase /-\ntheorem union_erase (a : α) (s₁ s₂ : AList β) : erase a (s₁ ∪ s₂) = erase a s₁ ∪ erase a s₂ :=\n  ext kunion_kerase.symm\n#align alist.union_erase AList.union_erase\n-/\n\n#print AList.lookup_union_left /-\n@[simp]\ntheorem lookup_union_left {a} {s₁ s₂ : AList β} : a ∈ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₁ :=\n  dlookup_kunion_left\n#align alist.lookup_union_left AList.lookup_union_left\n-/\n\n#print AList.lookup_union_right /-\n@[simp]\ntheorem lookup_union_right {a} {s₁ s₂ : AList β} : a ∉ s₁ → lookup a (s₁ ∪ s₂) = lookup a s₂ :=\n  dlookup_kunion_right\n#align alist.lookup_union_right AList.lookup_union_right\n-/\n\n#print AList.mem_lookup_union /-\n@[simp]\ntheorem mem_lookup_union {a} {b : β a} {s₁ s₂ : AList β} :\n    b ∈ lookup a (s₁ ∪ s₂) ↔ b ∈ lookup a s₁ ∨ a ∉ s₁ ∧ b ∈ lookup a s₂ :=\n  mem_dlookup_kunion\n#align alist.mem_lookup_union AList.mem_lookup_union\n-/\n\n#print AList.mem_lookup_union_middle /-\ntheorem mem_lookup_union_middle {a} {b : β a} {s₁ s₂ s₃ : AList β} :\n    b ∈ lookup a (s₁ ∪ s₃) → a ∉ s₂ → b ∈ lookup a (s₁ ∪ s₂ ∪ s₃) :=\n  mem_dlookup_kunion_middle\n#align alist.mem_lookup_union_middle AList.mem_lookup_union_middle\n-/\n\n#print AList.insert_union /-\ntheorem insert_union {a} {b : β a} {s₁ s₂ : AList β} : insert a b (s₁ ∪ s₂) = insert a b s₁ ∪ s₂ :=\n  by ext <;> simp\n#align alist.insert_union AList.insert_union\n-/\n\n#print AList.union_assoc /-\ntheorem union_assoc {s₁ s₂ s₃ : AList β} : (s₁ ∪ s₂ ∪ s₃).entries ~ (s₁ ∪ (s₂ ∪ s₃)).entries :=\n  lookup_ext (AList.nodupKeys _) (AList.nodupKeys _)\n    (by simp [Decidable.not_or_iff_and_not, or_assoc', and_or_left, and_assoc'])\n#align alist.union_assoc AList.union_assoc\n-/\n\nend\n\n/-! ### disjoint -/\n\n\n#print AList.Disjoint /-\n/-- Two associative lists are disjoint if they have no common keys. -/\ndef Disjoint (s₁ s₂ : AList β) : Prop :=\n  ∀ k ∈ s₁.keys, ¬k ∈ s₂.keys\n#align alist.disjoint AList.Disjoint\n-/\n\nvariable [DecidableEq α]\n\n#print AList.union_comm_of_disjoint /-\ntheorem union_comm_of_disjoint {s₁ s₂ : AList β} (h : Disjoint s₁ s₂) :\n    (s₁ ∪ s₂).entries ~ (s₂ ∪ s₁).entries :=\n  lookup_ext (AList.nodupKeys _) (AList.nodupKeys _)\n    (by\n      intros ; simp\n      constructor <;> intro h'\n      cases h'\n      · right\n        refine' ⟨_, h'⟩\n        apply h\n        rw [keys, ← List.dlookup_isSome, h']\n        exact rfl\n      · left\n        rw [h'.2]\n      cases h'\n      · right\n        refine' ⟨_, h'⟩\n        intro h''\n        apply h _ h''\n        rw [keys, ← List.dlookup_isSome, h']\n        exact rfl\n      · left\n        rw [h'.2])\n#align alist.union_comm_of_disjoint AList.union_comm_of_disjoint\n-/\n\nend AList\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/List/Alist.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.7853085708384736, "lm_q1q2_score": 0.45650229933787334}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.norm_num\nimport Mathlib.data.int.range\nimport Mathlib.PostPort\n\nuniverses u_1 l \n\nnamespace Mathlib\n\n/-!\n# `ring`\n\nEvaluate expressions in the language of commutative (semi)rings.\nBased on <http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf> .\n-/\n\nnamespace tactic\n\n\nnamespace ring\n\n\n/-- The normal form that `ring` uses is mediated by the function `horner a x n b := a * x ^ n + b`.\nThe reason we use a definition rather than the (more readable) expression on the right is because\nthis expression contains a number of typeclass arguments in different positions, while `horner`\ncontains only one `comm_semiring` instance at the top level. See also `horner_expr` for a\ndescription of normal form. -/\ndef horner {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) : α := a * x ^ n + b\n\n/-- This cache contains data required by the `ring` tactic during execution. -/\n/-- The monad that `ring` works in. This is a reader monad containing a mutable cache (using `ref`\nfor mutability), as well as the list of atoms-up-to-defeq encountered thus far, used for atom\nsorting. -/\n/-- Get the `ring` data from the monad. -/\n/-- Get an already encountered atom by its index. -/\n/-- Get the index corresponding to an atomic expression, if it has already been encountered, or\nput it in the list of atoms and return the new index, otherwise. -/\n/-- Lift a tactic into the `ring_m` monad. -/\n/-- Run a `ring_m` tactic in the tactic monad. This version of `ring_m.run` uses an external\natoms ref, so that subexpressions can be named across multiple `ring_m` calls. -/\n/-- Run a `ring_m` tactic in the tactic monad. -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This version\nis abstract over the instance cache in question (either the ring `α`, or `ℕ` for exponents). -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to the ring `α`. -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to `ℕ`, which is used for computations in the exponent. -/\n/-- Apply a theorem that expects a `comm_semiring` instance. This is a special case of\n`ic_lift mk_app`, but it comes up often because `horner` and all its theorems have this assumption;\nit also does not require the tactic monad which improves access speed a bit. -/\n/-- Every expression in the language of commutative semirings can be viewed as a sum of monomials,\nwhere each monomial is a product of powers of atoms. We fix a global order on atoms (up to\ndefinitional equality), and then separate the terms according to their smallest atom. So the top\nlevel expression is `a * x^n + b` where `x` is the smallest atom and `n > 0` is a numeral, and\n`n` is maximal (so `a` contains at least one monomial not containing an `x`), and `b` contains no\nmonomials with an `x` (hence all atoms in `b` are larger than `x`).\n\nIf there is no `x` satisfying these constraints, then the expression must be a numeral. Even though\nwe are working over rings, we allow rational constants when these can be interpreted in the ring,\nso we can solve problems like `x / 3 = 1 / 3 * x` even though these are not technically in the\nlanguage of rings.\n\nThese constraints ensure that there is a unique normal form for each ring expression, and so the\nalgorithm is simply to calculate the normal form of each side and compare for equality.\n\nTo allow us to efficiently pattern match on normal forms, we maintain this inductive type that\nholds a normalized expression together with its structure. All the `expr`s in this type could be\nremoved without loss of information, and conversely the `horner_expr` structure and the `ℕ` and\n`ℚ` values can be recovered from the top level `expr`, but we keep both in order to keep proof\n producing normalization functions efficient. -/\n/-- Get the expression corresponding to a `horner_expr`. This can be calculated recursively from\nthe structure, but we cache the exprs in all subterms so that this function can be computed in\nconstant time. -/\n/-- Is this expr the constant `0`? -/\n/-- Construct a `xadd` node, generating the cached expr using the input cache. -/\n/-- Pretty printer for `horner_expr`. -/\n/-- Pretty printer for `horner_expr`. -/\n/-- Reflexivity conversion for a `horner_expr`. -/\ntheorem zero_horner {α : Type u_1} [comm_semiring α] (x : α) (n : ℕ) (b : α) : horner 0 x n b = b :=\n  sorry\n\ntheorem horner_horner {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (n₂ : ℕ) (b : α)\n    (n' : ℕ) (h : n₁ + n₂ = n') : horner (horner a₁ x n₁ 0) x n₂ b = horner a₁ x n' b :=\n  sorry\n\n/-- Evaluate `horner a n x b` where `a` and `b` are already in normal form. -/\ntheorem const_add_horner {α : Type u_1} [comm_semiring α] (k : α) (a : α) (x : α) (n : ℕ) (b : α)\n    (b' : α) (h : k + b = b') : k + horner a x n b = horner a x n b' :=\n  sorry\n\ntheorem horner_add_const {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) (k : α)\n    (b' : α) (h : b + k = b') : horner a x n b + k = horner a x n b' :=\n  sorry\n\ntheorem horner_add_horner_lt {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α)\n    (a₂ : α) (n₂ : ℕ) (b₂ : α) (k : ℕ) (a' : α) (b' : α) (h₁ : n₁ + k = n₂)\n    (h₂ : a₁ + horner a₂ x k 0 = a') (h₃ : b₁ + b₂ = b') :\n    horner a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₁ b' :=\n  sorry\n\ntheorem horner_add_horner_gt {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α)\n    (a₂ : α) (n₂ : ℕ) (b₂ : α) (k : ℕ) (a' : α) (b' : α) (h₁ : n₂ + k = n₁)\n    (h₂ : horner a₁ x k 0 + a₂ = a') (h₃ : b₁ + b₂ = b') :\n    horner a₁ x n₁ b₁ + horner a₂ x n₂ b₂ = horner a' x n₂ b' :=\n  sorry\n\ntheorem horner_add_horner_eq {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n : ℕ) (b₁ : α)\n    (a₂ : α) (b₂ : α) (a' : α) (b' : α) (t : α) (h₁ : a₁ + a₂ = a') (h₂ : b₁ + b₂ = b')\n    (h₃ : horner a' x n b' = t) : horner a₁ x n b₁ + horner a₂ x n b₂ = t :=\n  sorry\n\n/-- Evaluate `a + b` where `a` and `b` are already in normal form. -/\ntheorem horner_neg {α : Type u_1} [comm_ring α] (a : α) (x : α) (n : ℕ) (b : α) (a' : α) (b' : α)\n    (h₁ : -a = a') (h₂ : -b = b') : -horner a x n b = horner a' x n b' :=\n  sorry\n\n/-- Evaluate `-a` where `a` is already in normal form. -/\ntheorem horner_const_mul {α : Type u_1} [comm_semiring α] (c : α) (a : α) (x : α) (n : ℕ) (b : α)\n    (a' : α) (b' : α) (h₁ : c * a = a') (h₂ : c * b = b') : c * horner a x n b = horner a' x n b' :=\n  sorry\n\ntheorem horner_mul_const {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) (c : α)\n    (a' : α) (b' : α) (h₁ : a * c = a') (h₂ : b * c = b') : horner a x n b * c = horner a' x n b' :=\n  sorry\n\n/-- Evaluate `k * a` where `k` is a rational numeral and `a` is in normal form. -/\ntheorem horner_mul_horner_zero {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α)\n    (a₂ : α) (n₂ : ℕ) (aa : α) (t : α) (h₁ : horner a₁ x n₁ b₁ * a₂ = aa)\n    (h₂ : horner aa x n₂ 0 = t) : horner a₁ x n₁ b₁ * horner a₂ x n₂ 0 = t :=\n  sorry\n\ntheorem horner_mul_horner {α : Type u_1} [comm_semiring α] (a₁ : α) (x : α) (n₁ : ℕ) (b₁ : α)\n    (a₂ : α) (n₂ : ℕ) (b₂ : α) (aa : α) (haa : α) (ab : α) (bb : α) (t : α)\n    (h₁ : horner a₁ x n₁ b₁ * a₂ = aa) (h₂ : horner aa x n₂ 0 = haa) (h₃ : a₁ * b₂ = ab)\n    (h₄ : b₁ * b₂ = bb) (H : haa + horner ab x n₁ bb = t) :\n    horner a₁ x n₁ b₁ * horner a₂ x n₂ b₂ = t :=\n  sorry\n\n/-- Evaluate `a * b` where `a` and `b` are in normal form. -/\ntheorem horner_pow {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (m : ℕ) (n' : ℕ)\n    (a' : α) (h₁ : n * m = n') (h₂ : a ^ m = a') : horner a x n 0 ^ m = horner a' x n' 0 :=\n  sorry\n\ntheorem pow_succ {α : Type u_1} [comm_semiring α] (a : α) (n : ℕ) (b : α) (c : α) (h₁ : a ^ n = b)\n    (h₂ : b * a = c) : a ^ (n + 1) = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = c)) (Eq.symm h₂)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = b * a)) (Eq.symm h₁)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = a ^ n * a)) (pow_succ' a n)))\n        (Eq.refl (a ^ n * a))))\n\n/-- Evaluate `a ^ n` where `a` is in normal form and `n` is a natural numeral. -/\ntheorem horner_atom {α : Type u_1} [comm_semiring α] (x : α) : x = horner 1 x 1 0 := sorry\n\n/-- Evaluate `a` where `a` is an atom. -/\ntheorem subst_into_pow {α : Type u_1} [monoid α] (l : α) (r : ℕ) (tl : α) (tr : ℕ) (t : α)\n    (prl : l = tl) (prr : r = tr) (prt : tl ^ tr = t) : l ^ r = t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (l ^ r = t)) prl))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (tl ^ r = t)) prr))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (tl ^ tr = t)) prt)) (Eq.refl t)))\n\ntheorem unfold_sub {α : Type u_1} [add_group α] (a : α) (b : α) (c : α) (h : a + -b = c) :\n    a - b = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a - b = c)) (sub_eq_add_neg a b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a + -b = c)) h)) (Eq.refl c))\n\ntheorem unfold_div {α : Type u_1} [division_ring α] (a : α) (b : α) (c : α) (h : a * (b⁻¹) = c) :\n    a / b = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a / b = c)) (div_eq_mul_inv a b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a * (b⁻¹) = c)) h)) (Eq.refl c))\n\n/-- Evaluate a ring expression `e` recursively to normal form, together with a proof of\nequality. -/\n/-- Evaluate a ring expression `e` recursively to normal form, together with a proof of\nequality. -/\ntheorem horner_def' {α : Type u_1} [comm_semiring α] (a : α) (x : α) (n : ℕ) (b : α) :\n    horner a x n b = x ^ n * a + b :=\n  sorry\n\ntheorem mul_assoc_rev {α : Type u_1} [semigroup α] (a : α) (b : α) (c : α) :\n    a * (b * c) = a * b * c :=\n  sorry\n\ntheorem pow_add_rev {α : Type u_1} [monoid α] (a : α) (m : ℕ) (n : ℕ) :\n    a ^ m * a ^ n = a ^ (m + n) :=\n  sorry\n\ntheorem pow_add_rev_right {α : Type u_1} [monoid α] (a : α) (b : α) (m : ℕ) (n : ℕ) :\n    b * a ^ m * a ^ n = b * a ^ (m + n) :=\n  sorry\n\ntheorem add_neg_eq_sub {α : Type u_1} [add_group α] (a : α) (b : α) : a + -b = a - b :=\n  Eq.symm (sub_eq_add_neg a b)\n\n/-- If `ring` fails to close the goal, it falls back on normalizing the expression to a \"pretty\"\nform so that you can see why it failed. This setting adjusts the resulting form:\n\n  * `raw` is the form that `ring` actually uses internally, with iterated applications of `horner`.\n    Not very readable but useful if you don't want any postprocessing.\n    This results in terms like `horner (horner (horner 3 y 1 0) x 2 1) x 1 (horner 1 y 1 0)`.\n  * `horner` maintains the Horner form structure, but it unfolds the `horner` definition itself,\n    and tries to otherwise minimize parentheses.\n    This results in terms like `(3 * x ^ 2 * y + 1) * x + y`.\n  * `SOP` means sum of products form, expanding everything to monomials.\n    This results in terms like `3 * x ^ 3 * y + x + y`. -/\ninductive normalize_mode where\n| raw : normalize_mode\n| SOP : normalize_mode\n| horner : normalize_mode\n\nprotected instance normalize_mode.inhabited : Inhabited normalize_mode :=\n  { default := normalize_mode.horner }\n\n/-- A `ring`-based normalization simplifier that rewrites ring expressions into the specified mode.\n\n  * `raw` is the form that `ring` actually uses internally, with iterated applications of `horner`.\n    Not very readable but useful if you don't want any postprocessing.\n    This results in terms like `horner (horner (horner 3 y 1 0) x 2 1) x 1 (horner 1 y 1 0)`.\n  * `horner` maintains the Horner form structure, but it unfolds the `horner` definition itself,\n    and tries to otherwise minimize parentheses.\n    This results in terms like `(3 * x ^ 2 * y + 1) * x + y`.\n  * `SOP` means sum of products form, expanding everything to monomials.\n    This results in terms like `3 * x ^ 3 * y + x + y`. -/\nend ring\n\n\nnamespace interactive\n\n\n/-- Tactic for solving equations in the language of *commutative* (semi)rings.\n  This version of `ring` fails if the target is not an equality\n  that is provable by the axioms of commutative (semi)rings. -/\n/-- Parser for `ring`'s `mode` argument, which can only be the \"keywords\" `raw`, `horner` or `SOP`.\n(Because these are not actually keywords we use a name parser and postprocess the result.) -/\n/-- Tactic for solving equations in the language of *commutative* (semi)rings.\nAttempts to prove the goal outright if there is no `at`\nspecifier and the target is an equality, but if this\nfails it falls back to rewriting all ring expressions\ninto a normal form. When writing a normal form,\n`ring SOP` will use sum-of-products form instead of horner form.\n`ring!` will use a more aggressive reducibility setting to identify atoms.\n\nBased on [Proving Equalities in a Commutative Ring Done Right\nin Coq](http://www.cs.ru.nl/~freek/courses/tt-2014/read/10.1.1.61.3041.pdf) by Benjamin Grégoire\nand Assia Mahboubi.\n-/\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/tactic/ring_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744850834648, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.45647390490194234}}
{"text": "import linear_algebra.basic\n\nuniverses u v w x\n\nvariables {R : Type u} [ring R]\nvariables {M₁ : Type v} [add_comm_group M₁] [module R M₁]\nvariables {M₂ : Type w} [add_comm_group M₂] [module R M₂]\nvariables {M₃ : Type x} [add_comm_group M₃] [module R M₃]\n\nopen linear_map\nopen submodule\n\nlemma linear_map.ker_le_range_iff {f : M₁ →ₗ[R] M₂} {g : M₂ →ₗ[R] M₃} :\n  g.ker ≤ f.range ↔ f.range.mkq.comp g.ker.subtype = 0 :=\nby rw [←range_le_ker_iff, ker_mkq, range_subtype]\n\n/-⟨λ h, ker_eq_top.1 $ eq_top_iff'.2 $ λ x, mem_ker.2 $ by simpa using mem_range.1 (h x.2),\n λ h,\n begin\n  rw ←range_le_ker_iff at h,\n  rw ker_mkq at h,\n  rw range_subtype at h,\n  exact h,\n end-\n  /-x hx,\n begin\n  rw ←submodule.ker_mkq f.range,\n  apply mem_ker.2,\n  rw ←zero_apply x,\n  rw ←h,\n  --rw ←submodule.subtype_apply _ ⟨x, hx⟩,\n  exact mem_ker.2 (@linear_map.congr _ _ _ _ _ _ _ _\n    (comp (mkq (range f)) (submodule.subtype (ker g))) 0 ⟨x, hx⟩ h),-/\n end⟩-/\n", "meta": {"author": "TwoFX", "repo": "lean-homological-algebra", "sha": "e3a8e4ecaf49bec6c7b38b34c0b8f9749e941aa8", "save_path": "github-repos/lean/TwoFX-lean-homological-algebra", "path": "github-repos/lean/TwoFX-lean-homological-algebra/lean-homological-algebra-e3a8e4ecaf49bec6c7b38b34c0b8f9749e941aa8/src/modules/to_mathlib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936435, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.45647389993851517}}
{"text": "-- Title: Generation in Optimality Theory with Lexical Insertion is Undecidable\n--\n-- Author: Cerek Hillen\n--\n-- Description:\n--   Here we show that PCP is reducible to OT. In particular, we show that when\n--   there exists a solution to PCP, there exists a solution to OT, and when\n--   there does not exist a solution to PCP, there does not exist a solution to\n--   OT.\n--\n--   Because PCP is known to be Turing Complete, this reduction proves that OT\n--   is also Turing Complete.\n\nimport data.vector\n\nuniverses u v\n\n--------------------------------------------------------------------------------\n--                                   PCP                                      --\n--------------------------------------------------------------------------------\n\n-- Defining PCP\nstructure pcp\n  {n : ℕ}\n  (Γ : Type)\n  (tops : vector (list Γ) n)\n  (bottoms : vector (list Γ) n) : Type\n\nnamespace pcp\n  open vector\n\n  -- Defining the composition of a vector of symbols by a sequence. Used to\n  -- define the existence of a solution for PCP.\n  def compose\n    {Γ : Type}\n    {n : ℕ} :\n      Π (symbols : vector (list Γ) n), list (fin n) → list Γ\n        | symbols list.nil        := list.nil\n        | symbols (list.cons i l) :=\n          list.append\n            (nth symbols i)\n            (compose symbols l)\n\n  -- The property of an instance of PCP having a solution. In plain English,\n  -- an instance of PCP has a solution iff there exists a sequence of indicies\n  -- such that the composition of the indexed tops and bottoms are equal.\n  def has_solution\n    {n : ℕ}\n    {Γ : Type}\n    {tops : vector (list Γ) n}\n    {bottoms : vector (list Γ) n} :\n      pcp Γ tops bottoms → Prop\n      | _ := ∃ (seq : list (fin n)), compose tops seq = compose bottoms seq\nend pcp\n\n--------------------------------------------------------------------------------\n--                             Optimality Theory                              --\n--------------------------------------------------------------------------------\n\nnamespace ot\n  open vector\n\n  -- We define a score to be a vector of natural numbers of length n. Each value\n  -- score_i corresponds to the number of violations that occurred in the ith\n  -- constraint.\n  def score (n : ℕ) := vector ℕ n\n\n  -- We define an ordering on scores such that s₁ ≤ s₂ iff they are equal up to\n  -- some index i, wherein s₁[i] ≤ s₂[i].\n  --\n  -- TODO: This definition isn't going to work, because you can prove it by\n  --       using an index larger than n for i.\n  def score_lte {n : ℕ} (s1 : score n) (s2 : score n) : Prop :=\n    ∃ (i : ℕ), Π (ltin : i < n),\n      (nth s1 (fin.mk i ltin)) ≤\n      (nth s2 (fin.mk i ltin)) ∧\n        ∀ (j : ℕ), Π (ltji : j < i),\n          (nth s1 ⟨j, lt.trans ltji ltin⟩) =\n          (nth s2 ⟨j, lt.trans ltji ltin⟩)\n\n\n  -- TODO: Define the rest of OT\nend ot\n\n--------------------------------------------------------------------------------\n--                                  Proof                                     --\n--------------------------------------------------------------------------------\n\n-- Step 1. Reduce from an arbitrary case of PCP to a case of PCP where there\n--         exist only two characters.\n\n-- Definition of a binary language\ninductive bin\n  | a : bin\n  | b : bin\n\ndef alphabet_width : Type → ℕ := sorry\n\ndef map_to_binary\n  {n : ℕ}\n  {Γ : Type}\n\n  {tops : vector (list Γ) n}\n  {bottoms : vector (list Γ) n}\n\n  {new_tops : vector (list bin) (n * alphabet_width Γ)}\n  {new_bottoms : vector (list bin) (n * alphabet_width Γ)}:\n    pcp Γ tops bottoms → pcp bin new_tops new_bottoms :=\n      sorry\n\n-- TODO: Debug it\n-- theorem binary_equivalence {n : ℕ}\n--                            {Γ : Type}\n--                            {tops bottoms : vector (list Γ) n}\n--                            (problem : pcp Γ tops bottoms) :\n--   problem.has_solution ↔ (map_to_binary problem).has_solution :=\n--   begin\n--     split,\n--     sorry,\n--   end\n\n-- Step 2. Provide our mapping from an arbitrary instance of PCP to an arbitrary\n--         instance of OT.\n\n-- TODO\n\n-- Step 3. Show that PCP has a solution if and only if our mapped version of OT\n--         has a solution.\n\n-- TODO\n\n\n--------------------------------------------------------------------------------\n--                             Misc / Testing                                 --\n--------------------------------------------------------------------------------\n\n-- Proving that a simple instance of PCP has a solution.\nnamespace hidden_has_solution\n  inductive Γ\n    | a : Γ\n    | b : Γ\n\n  open Γ\n\n  def top_l := [[b], [a]]\n  def bot_l := [[], [b, a]]\n\n  def tops : vector (list Γ) 2 := ⟨top_l, by refl⟩\n  def bottoms : vector (list Γ) 2 := ⟨bot_l, by refl⟩\n\n  theorem simple_pcp (problem : pcp Γ tops bottoms) : problem.has_solution :=\n  begin\n    existsi [[\n      (0 : fin 2),\n      (1 : fin 2)\n    ]],\n    refl,\n  end\n\n  #print simple_pcp\nend hidden_has_solution\n\nnamespace hidden_score\n  open ot\n  open vector\n\n  def x : score 5 := ⟨[0, 0, 1, 3, 5], by refl⟩\n  def y : score 5 := ⟨[0, 0, 2, 1, 7], by refl⟩\n\n  example : (score_lte x y) :=\n  begin\n    existsi 2,\n    intro ltin,\n\n    rw x,\n    rw y,\n\n    split,\n\n    {\n      repeat {rw nth},\n      repeat {rw list.nth_le},\n\n      exact\n        nat.less_than_or_equal.step\n        (nat.less_than_or_equal.refl 1),\n    },\n\n    {\n      intros j ltji,\n\n      repeat {rw nth},\n\n      cases j,\n      any_goals { cases j },\n      any_goals {\n        repeat {rw list.nth_le},\n      },\n\n      have h : j < 0,\n      from nat.le_of_succ_le_succ (nat.le_of_succ_le_succ ltji),\n\n      exfalso,\n      exact (nat.not_lt_zero j) h,\n    },\n  end\nend hidden_score\n\n-- NOTE: This example shows that our definition of ordering for score vectors is\n--       broken. We can show that x ≤ y, even though in fact x > y. I should\n--       change the defn above to be a conjunct, rather than an implication.\n--       I.e. (i < n) ∧ ..., not (Π (ltin : i < n), ...\nnamespace hidden_break_score\n  open ot\n  open vector\n\n  def x : score 5 := ⟨[0, 0, 2, 3, 5], by refl⟩\n  def y : score 5 := ⟨[0, 0, 1, 1, 7], by refl⟩\n\n  example : (score_lte x y) :=\n    begin\n      existsi 5,\n      assume h,\n\n      have h' : 0 < 0,\n      sorry,\n\n      exfalso,\n      exact (nat.not_lt_zero 0) h',\n    end\n\n\n\n\nend hidden_break_score\n", "meta": {"author": "crockeo", "repo": "math-exercises", "sha": "cf9150ef9e025f1b7929ba070a783e7a71f24f31", "save_path": "github-repos/lean/crockeo-math-exercises", "path": "github-repos/lean/crockeo-math-exercises/math-exercises-cf9150ef9e025f1b7929ba070a783e7a71f24f31/paper/proof.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581097540519, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4564518772803786}}
{"text": "import algebra.camera.exclusive\nimport algebra.camera.option\n\nuniverses u\n\n@[ext] structure auth (α : Type u) :=\n(excl : option (exclusive α))\n(frag : α)\n\nnamespace auth\n\nnotation `● `:75 a:75 := auth.mk (some (exclusive.mk a)) 1\nnotation `◯ `:75 a:75 := auth.mk none a\n\ninstance {α : Type u} [ofe α] : ofe (auth α) := {\n  eq_at := λ n a b, a.excl =[n] b.excl ∧ a.frag =[n] b.frag,\n  eq_at_reflexive := by intros n a; split; refl,\n  eq_at_symmetric := λ n a b h, ⟨eq_at_symmetric n h.1, eq_at_symmetric n h.2⟩,\n  eq_at_transitive := begin\n    rintros n a b c ⟨hab₁, hab₂⟩ ⟨hbc₁, hbc₂⟩,\n    split; transitivity; assumption,\n  end,\n  eq_at_mono' := λ m n hmn a b h, ⟨eq_at_mono hmn h.1, eq_at_mono hmn h.2⟩,\n  eq_at_limit' := begin\n    intros x y h,\n    ext1; rw eq_at_limit; intros n,\n    exact (h n).1, exact (h n).2,\n  end,\n}\n\nlemma excl_eq_at {α : Type u} [unital_camera α] {n : ℕ} {a b : α} :\n  ● a =[n] ● b → a =[n] b :=\nλ h, exclusive.mk_eq_at (option.eq_at_of_some_eq_at h.1)\n\n@[simp] lemma excl_eq_at_iff {α : Type u} [unital_camera α] {n : ℕ} {a b : α} :\n  ● a =[n] ● b ↔ a =[n] b :=\n⟨excl_eq_at, λ h, ⟨option.some_eq_at_iff.mpr (exclusive.mk_eq_at_iff.mpr h), eq_at_refl n 1⟩⟩\n\nlemma frag_eq_at {α : Type u} [ofe α] {n : ℕ} {a b : α} :\n  ◯ a =[n] ◯ b → a =[n] b :=\nλ h, h.2\n\n@[simp] lemma frag_eq_at_iff {α : Type u} [ofe α] {n : ℕ} {a b : α} :\n  ◯ a =[n] ◯ b ↔ a =[n] b :=\n⟨λ h, h.2, λ h, ⟨eq_at_refl n _, h⟩⟩\n\ninstance {α : Type u} [comm_semigroup α] : comm_semigroup (auth α) := {\n  mul := λ a b, ⟨a.excl * b.excl, a.frag * b.frag⟩,\n  mul_assoc := by intros; ext1; simp only [mul_assoc],\n  mul_comm := begin\n    intros, ext1,\n    change a.excl * b.excl = b.excl * a.excl, rw mul_comm,\n    change a.frag * b.frag = b.frag * a.frag, rw mul_comm,\n  end,\n}\n\n@[simp] lemma mul_excl {α : Type u} [comm_semigroup α] (a b : auth α) :\n  (a * b).excl = a.excl * b.excl := rfl\n\n@[simp] lemma mul_frag {α : Type u} [comm_semigroup α] (a b : auth α) :\n  (a * b).frag = a.frag * b.frag := rfl\n\n@[simp] lemma mul_mk {α : Type u} [comm_semigroup α]\n  (ax bx : option (exclusive α)) (af bf : α) :\n  (⟨ax, af⟩ : auth α) * ⟨bx, bf⟩ = ⟨ax * bx, af * bf⟩ := rfl\n\ninductive validn {α : Type u} [camera α] (n : ℕ) : auth α → Prop\n| none {b : α} : ✓[n] b → validn (◯ b)\n| mk {a b : α} : b ≼[n] a → ✓[n] a → validn ⟨some (exclusive.mk a), b⟩\n\nprivate lemma validn_nonexpansive {α : Type u} [camera α] {n : ℕ} {xa ya : option (exclusive α)}\n  {xf yf : α} : (⟨xa, xf⟩ : auth α) =[n] ⟨ya, yf⟩ → validn n ⟨xa, xf⟩ → validn n ⟨ya, yf⟩ :=\nbegin\n  intros h h',\n  obtain (⟨_, h₁⟩ | ⟨z, _, ⟨c, hc⟩, h₃⟩) := h',\n  { cases h.1,\n    refine validn.none _,\n    refine camera.validn_of_eq_at (frag_eq_at h) _,\n    assumption, },\n  { obtain ⟨h₁, h₂⟩ := h,\n    simp only [option.exists_eq_iff_some_eq, exclusive.exists_eq_iff_mk_eq] at h₁,\n    obtain ⟨_, rfl, ⟨b', rfl, h₁⟩⟩ := h₁,\n    refine validn.mk ⟨c, _⟩ _,\n    simp only at h₂,\n    refine eq_at_trans z _ h₁,\n    refine eq_at_trans (xf * c) _ hc,\n    exact camera.mul_eq_at_left (eq_at_symm h₂),\n    exact camera.validn_of_eq_at h₁ h₃, },\nend\n\nprivate lemma excl_validn {α : Type u} [camera α] {n : ℕ} {a : auth α} : validn n a → ✓[n] a.excl :=\nbegin\n  rintro (h | h) a (h | h),\n  intro h', cases h',\nend\n\nprivate lemma frag_validn {α : Type u} [camera α] {n : ℕ} {a : auth α} : validn n a → ✓[n] a.frag :=\nbegin\n  rintro (h | h),\n  assumption,\n  exact camera.validn_incln ‹_› ‹_›,\nend\n\ndef extend {α : Type u} [unital_camera α] {n : ℕ} {a b₁ b₂ : auth α}\n  (h₁ : validn n a) (h₂ : a =[n] b₁ * b₂) : auth α × auth α :=\n⟨⟨(camera.extend (excl_validn h₁) h₂.1).1, (camera.extend (frag_validn h₁) h₂.2).1⟩,\n  ⟨(camera.extend (excl_validn h₁) h₂.1).2, (camera.extend (frag_validn h₁) h₂.2).2⟩⟩\n\ninstance {α : Type u} [unital_camera α] : camera (auth α) := {\n  validn := ⟨λ a, ⟨λ n, validn n a, begin\n    intros m n hmn h,\n    cases h,\n    exact validn.none (camera.validn_mono hmn ‹_›),\n    exact validn.mk (incln_mono hmn ‹_›) (camera.validn_mono hmn ‹_›),\n  end⟩, begin\n    rintros n ⟨xa, xf⟩ ⟨ya, yf⟩ h m hmn,\n    exact ⟨validn_nonexpansive (eq_at_mono hmn h),\n      validn_nonexpansive (eq_at_mono hmn (eq_at_symm h))⟩,\n  end⟩,\n  core := ⟨λ a, some (◯ |a.frag|), begin\n    intros n a b h,\n    simp only [option.exists_eq_iff_some_eq, exists_eq_left', frag_eq_at_iff],\n    exact abs_is_nonexpansive h.2,\n  end⟩,\n  extend := @extend _ _,\n  mul_is_nonexpansive := λ n a b h, ⟨camera.mul_eq_at h.1.1 h.2.1, camera.mul_eq_at h.1.2 h.2.2⟩,\n  core_mul_self := begin\n    intros a ca h,\n    cases h,\n    ext1,\n    simp only [mul_excl, none_mul],\n    simp only [mul_frag, unital_camera.abs_mul_self],\n  end,\n  core_core := begin\n    intros a ca h,\n    cases h,\n    simp only [nonexpansive_fun.coe_fn_mk, eq_self_iff_true, true_and, unital_camera.abs_abs],\n  end,\n  core_mono_some := λ a b ca hca h, by simp only [nonexpansive_fun.coe_fn_mk, exists_eq'],\n  core_mono := begin\n    rintros a b ca hca ⟨c, rfl⟩,\n    simp only [nonexpansive_fun.coe_fn_mk, mul_frag] at hca ⊢,\n    obtain ⟨d, hd⟩ := unital_camera.abs_mono a.frag (a.frag * c.frag) ⟨c.frag, rfl⟩,\n    refine ⟨some (◯ d), _⟩,\n    simp only [some_mul_some],\n    ext1, refl,\n    simp only [nonexpansive_fun.coe_fn_mk, some_mul_some, mul_frag],\n    exact hd,\n  end,\n  validn_mul := begin\n    rintros ⟨ax, af⟩ ⟨bx, bf⟩ n h,\n    simp only [nonexpansive_fun.coe_fn_mk, sprop.coe_fn_mk, mul_mk] at h ⊢,\n    cases ax,\n    { cases bx,\n      { obtain (⟨_, h⟩ | _) := h,\n        exact validn.none (camera.validn_mul_left h), },\n      { obtain (_ | ⟨c, _, ⟨d, hd⟩, hc⟩) := h,\n        refine validn.none _,\n        exact camera.validn_mul_left (camera.validn_mul_left\n          (camera.validn_of_eq_at (eq_at_symm hd) hc)), }, },\n    { cases bx,\n      { obtain (_ | ⟨c, _, ⟨d, hd⟩, hc⟩) := h,\n        refine validn.mk ⟨bf * d, _⟩ hc,\n        convert hd using 1,\n        rw ← mul_assoc,\n        refl, },\n      { cases h, }, },\n  end,\n  extend_mul_eq := begin\n    intros n a b₁ b₂ h₁ b₂,\n    ext1,\n    exact camera.extend_mul_eq _ _,\n    exact camera.extend_mul_eq _ _,\n  end,\n  extend_eq_at_left := begin\n    intros n a b₁ b₂ h₁ b₂,\n    split,\n    exact camera.extend_eq_at_left _ _,\n    exact camera.extend_eq_at_left _ _,\n  end,\n  extend_eq_at_right := begin\n    intros n a b₁ b₂ h₁ b₂,\n    split,\n    exact camera.extend_eq_at_right _ _,\n    exact camera.extend_eq_at_right _ _,\n  end,\n  ..auth.ofe,\n  ..auth.comm_semigroup,\n}\n\nend auth\n", "meta": {"author": "zeramorphic", "repo": "separation-logic", "sha": "51c131501cc541b3aae072957942e8ef744c4ebf", "save_path": "github-repos/lean/zeramorphic-separation-logic", "path": "github-repos/lean/zeramorphic-separation-logic/separation-logic-51c131501cc541b3aae072957942e8ef744c4ebf/src/algebra/camera/auth.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.45645187172091983}}
{"text": "import tactic\n\nopen tactic\n\n/-!\n\nThis file contains three tactic-programming exercises of increasing difficulty.\n\nThey were (hastily) written to follow the metaprogramming tutorial at\nLean for the Curious Mathematician 2020.\n\nIf you're looking for more (better) exercises, we strongly recommend the\nexercises by Blanchette et al\nfor the course Logical Verification at the Vrije Universiteit Amsterdam,\nand the corresponding chapter of the course notes:\n\nhttps://github.com/blanchette/logical_verification_2020/blob/master/lean/love07_metaprogramming_exercise_sheet.lean\nhttps://github.com/blanchette/logical_verification_2020/raw/master/hitchhikers_guide.pdf\n\n-/\n\n-- Preheating...\n\n-- First example from Video 5.\n\n#check list.mfirst (λx, trace `(5))\n\n-- This one already works (serendipity!)\nmeta def assump' : tactic unit :=\ndo\n  ctxt ← local_context,\n  list.mfirst (λx, exact x) ctxt\n\n-- Shorter version (blind guess)\nmeta def assump : tactic unit := local_context >>= list.mfirst (λx, exact x)\n\nexample (A B C : Prop) (ha : A) (hb : B) (hc : C) : C :=\nby assump\n\nexample (n: ℕ)(hx: n+0=5): n=5 := by assump\n\n/-!\n\n## Exercise 1\n\nWrite a `contradiction` tactic.\nThe tactic should look through the hypotheses in the local context\ntrying to find two that contradict each other,\ni.e. proving `P` and `¬ P` for some proposition `P`.\nIt should use this contradiction to close the goal.\n\nBonus: handle `P → false` as well as `¬ P`.\n\nThis exercise is to practice manipulating the hypotheses and goal.\n\nNote: this exists as `tactic.interactive.contradiction`.\n\n-/\n\n-- First try: only proves falsity, but also performs modus ponens!\nmeta def tactic.interactive.contr' : tactic unit :=\ndo\nctx ← local_context,\nlist.mfirst\n  (λ e, list.mfirst (λx, \n  -- Shorter than the next 3 lines: `to_expr ``(%%x %%e) >>= exact`\n  do\n  apli ← to_expr ``(%%x %%e),\n  exact apli\n ) ctx) ctx,\ndone\n\n-- Even shorter\n-- meta def tactic.interactive.contr' : tactic unit :=\n-- local_context >>= \n-- λ ctx, list.mfirst\n-- (λ e, list.mfirst (λx, to_expr ``(%%x %%e) >>= exact ) ctx) ctx\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hnq : ¬ Q) : false :=\nby contr'\n\n\nexample (P Q R : Prop) (hnq : ¬ Q) (hp : P) (hq : Q) (hr : ¬ R) : 0 = 1 :=\nby contr'\n\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hnq : Q → false) : false :=\nby contr'\n\n-- Unexpected!\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hqr : Q → R) : R :=\nby contr'\n\nmeta def tactic.interactive.contr : tactic unit :=\ndo\ntgt ← target,\nctx ← local_context,\nlist.mfirst\n  (λ e, list.mfirst (λx, to_expr ``(absurd %%x %%e) >>= exact)\n   ctx) ctx,\ndone\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hnq : ¬ Q) : false :=\nby contr\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hnq : ¬ Q) : false :=\nby contr\n\nexample (P Q R : Prop) (hnq : ¬ Q) (hp : P) (hq : Q) (hr : ¬ R) : 0 = 1 :=\nby exact false.rec.{0} (0 = 1) (hnq hq)\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : ¬ R) (hnq : Q → false) : false :=\nby contr\n\n\n/-!\n\n## Exercise 2\n\nWrite a tactic that proves a given `nat`-valued declaration is nonnegative.\nThe tactic should take the name of a declaration whose return type is `ℕ`\n(presumably with some arguments), e.g. `nat.add : ℕ → ℕ → ℕ`\nor `list.length : Π α : Type, list α → ℕ`.\nIt should add a new declaration to the environment which proves all applications\nof this function are nonnegative,\ne.g. `nat.add_nonneg : ∀ m n : ℕ, 0 ≤ nat.add m n`.\n\nBonus: create reasonable names for these declarations, and/or take an optional argument\nfor the new name.\n\nThis tactic is not useful by itself, but it's a good way to practice\nquerying and modifying an environment and working under binders.\nIt is not a tactic to be used during a proof, but rather as a command.\n\n\nHints:\n* For looking at declarations in the environment, you will need the `declaration` type,\n  as well as the tactics `get_decl` and `add_decl`.\n* You will have to manipulate an expression under binders.\n  The tactics `mk_local_pis` and `pis`, or their lambda equivalents, will be helpful here.\n* `mk_mapp` is a variant of `mk_app` that lets you provide implicit arguments.\n-/\n\n\nmeta def add_nonneg_proof (n : name) : tactic unit :=\nsorry\n\n-- these test cases should succeed when you're done\n\n-- run_cmd add_nonneg_proof `nat.add\n-- run_cmd add_nonneg_proof `list.length\n\n-- #check nat.add_nonneg\n-- #check list.length_nonneg\n\n\n/-!\n\n## Exercise 3 (challenge!)\n\nThe mathlib tactic `cancel_denoms` is intended to get rid of division by numerals\nin expressions where this makes sense. For example,\n\n-/\n\nexample (q : ℚ) (h : q / 3 > 0) : q > 0 :=\nbegin\n  cancel_denoms at h, exact h\nend\n\n/-!\n\nBut it is not complete. In particular, it doesn't like nested division\nor other operators in denominators. These all fail:\n\n-/\n\nexample (q : ℚ) (h : q / (3 / 4) > 0) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\nexample (p q : ℚ) (h : q / 2 / 3 < q) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\nexample (p q : ℚ) (h : q / 2 < 3 / (4*q)) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\n-- this one succeeds but doesn't do what it should\nexample (p q : ℚ) (h : q / (2*3) < q) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\n/-!\n\nLook at the code in `src/tactic/cancel_denoms.lean` and try to fix it.\nSee if you can solve any or all of these failing test cases.\n\nIf you succeed, a pull request to mathlib is strongly encouraged!\n\n-/\n", "meta": {"author": "sterraf", "repo": "mylearninglean", "sha": "a8911234b2a4e15a48ec2c0f05d744e58f798ca7", "save_path": "github-repos/lean/sterraf-mylearninglean", "path": "github-repos/lean/sterraf-mylearninglean/mylearninglean-a8911234b2a4e15a48ec2c0f05d744e58f798ca7/src/lftcm2020_exercises_sources/monday/metaprogramming.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.5736783928749126, "lm_q2_score": 0.7956581073313275, "lm_q1q2_score": 0.4564518642917307}}
{"text": "inductive Vec (α : Type u) : Nat → Type u\n  | nil : Vec α 0\n  | cons : α → Vec α n → Vec α (n+1)\n\ndef f1 (xs : Vec α n) : Nat :=\n  Vec.casesOn xs 0 fun _ _ => 1\n\ndef f2 (xs : Vec α n) : Nat :=\n  xs.casesOn 0 -- Error insufficient number of arguments\n\ndef f3 (x : Nat) : Nat → (Nat → Nat) → Nat :=\n  x.casesOn\n\ndef f4 (xs : List Nat) : xs ≠ [] → xs.length > 0 :=\n  xs.casesOn (by intros; contradiction) (by intros; simp_arith)\n\ndef f5 (xs : List Nat) (h : xs ≠ []) : xs.length > 0 :=\n  xs.casesOn (by intros; contradiction) (by intros; simp_arith) h\n\ndef f6 (x : Nat) :=\n  2 * x.casesOn 0 id\n\nexample : f6 (x+1) = 2*x := rfl\n\ndef f7 (xs : Vec α n) : Nat :=\n  xs.casesOn (a := 10) 0 -- Error unused named args\n\ndef f8 (xs : List Nat) : xs ≠ [] → xs.length > 0 :=\n  @List.casesOn _ (fun xs => xs ≠ [] → xs.length > 0) xs (by dsimp; intros; contradiction) (by dsimp; intros; simp_arith)\n\ndef f5' (xs : List Nat) (h : xs ≠ []) : xs.length > 0 :=\n  xs.casesOn (fun h => absurd rfl h) (fun _ _ _ => Nat.zero_lt_succ ..) h\n\nexample (h₁ : a = b) (h₂ : b = c) : a = c :=\n  Eq.rec h₂ h₁.symm\n\n@[elab_as_elim] theorem subst {p : (b : α) → a = b → Prop} (h₁ : a = b) (h₂ : p a rfl) : p b h₁ := by\n  cases h₁\n  assumption\n\nexample (h₁ : a = b) (h₂ : b = c) : a = c :=\n  subst h₁.symm h₂\n\ntheorem not_or_not : (¬p ∨ ¬q) → ¬(p ∧ q) := λ h ⟨hp, hq⟩ =>\n  h.rec (λ h1 => h1 hp) (λ h2 => h2 hq)\n\nstructure Point where\n  x : Nat\n\ntheorem PointExt_lean4 (p : Point) : forall (q : Point) (h1 : Point.x p = Point.x q), p = q :=\n  Point.recOn p <|\n   fun z1 q => Point.recOn q $\n   fun z2 (hA : Point.x (Point.mk z1) = Point.x (Point.mk z2)) => congrArg Point.mk hA\n\ninductive pos_num : Type\n  | one  : pos_num\n  | bit1 : pos_num → pos_num\n  | bit0 : pos_num → pos_num\n\ninductive num : Type\n  | zero  : num\n  | pos   : pos_num → num\n\ninductive znum : Type\n  | zero : znum\n  | pos  : pos_num → znum\n  | neg  : pos_num → znum\n\ndef pos_num.pred' : pos_num → num\n  | one    => .zero\n  | bit0 n => num.pos (num.casesOn (pred' n) one bit1)\n  | bit1 n => num.pos (bit0 n)\n\nprotected def znum.bit1 : znum → znum\n  | zero    => pos .one\n  | pos n => pos (pos_num.bit1 n)\n  | neg n => neg (num.casesOn (pos_num.pred' n) .one pos_num.bit1)\n\nexample (h : False) : a = c :=\n  h.rec\n\nexample (h : False) : a = c :=\n  h.elim\n\nnoncomputable def f : Nat → Nat :=\n  Nat.rec 0 (fun x _ => x)\n\nexample : ∀ x, x ≥ 0 :=\n  Nat.rec (Nat.le_refl 0) (fun _ ih => Nat.le_succ_of_le ih)\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/elabAsElim.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.4564380058570717}}
{"text": "constant n : Nat\n@[simp] axiom prio_1000 : n = 1000\n@[simp 10] axiom prio_10 : n = 10\n-- simp should prefer the prio_1000 lemma with the higher priority\nexample : n = 1000 := by simp\n", "meta": {"author": "Kha", "repo": "lean4-nightly", "sha": "b4c92de57090e6c47b29d3575df53d86fce52752", "save_path": "github-repos/lean/Kha-lean4-nightly", "path": "github-repos/lean/Kha-lean4-nightly/lean4-nightly-b4c92de57090e6c47b29d3575df53d86fce52752/tests/lean/run/simpPrio.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929104825006, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4563747521936487}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.tensor_product\nimport Mathlib.linear_algebra.direct_sum_module\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 \n\nnamespace Mathlib\n\nnamespace tensor_product\n\n\n/-- The linear equivalence `(⨁ i₁, M₁ i₁) ⊗ (⨁ i₂, M₂ i₂) ≃ (⨁ i₁, ⨁ i₂, M₁ i₁ ⊗ M₂ i₂)`, i.e.\n\"tensor product distributes over direct sum\". -/\ndef direct_sum (R : Type u_1) [comm_ring R] (ι₁ : Type u_2) (ι₂ : Type u_3) [DecidableEq ι₁]\n    [DecidableEq ι₂] (M₁ : ι₁ → Type u_4) (M₂ : ι₂ → Type u_5) [(i₁ : ι₁) → add_comm_group (M₁ i₁)]\n    [(i₂ : ι₂) → add_comm_group (M₂ i₂)] [(i₁ : ι₁) → module R (M₁ i₁)]\n    [(i₂ : ι₂) → module R (M₂ i₂)] :\n    linear_equiv R\n        (tensor_product R (direct_sum ι₁ fun (i₁ : ι₁) => M₁ i₁)\n          (direct_sum ι₂ fun (i₂ : ι₂) => M₂ i₂))\n        (direct_sum (ι₁ × ι₂)\n          fun (i : ι₁ × ι₂) => tensor_product R (M₁ (prod.fst i)) (M₂ (prod.snd i))) :=\n  linear_equiv.of_linear\n    (lift\n      (direct_sum.to_module R ι₁\n        (linear_map R (direct_sum ι₂ fun (i₂ : ι₂) => M₂ i₂)\n          (direct_sum (ι₁ × ι₂)\n            fun (i : ι₁ × ι₂) => tensor_product R (M₁ (prod.fst i)) (M₂ (prod.snd i))))\n        fun (i₁ : ι₁) =>\n          linear_map.flip\n            (direct_sum.to_module R ι₂\n              (linear_map R (M₁ i₁)\n                (direct_sum (ι₁ × ι₂)\n                  fun (i : ι₁ × ι₂) => tensor_product R (M₁ (prod.fst i)) (M₂ (prod.snd i))))\n              fun (i₂ : ι₂) =>\n                linear_map.flip\n                  (curry\n                    (direct_sum.lof R (ι₁ × ι₂)\n                      (fun (i : ι₁ × ι₂) => tensor_product R (M₁ (prod.fst i)) (M₂ (prod.snd i)))\n                      (i₁, i₂))))))\n    (direct_sum.to_module R (ι₁ × ι₂)\n      (tensor_product R (direct_sum ι₁ fun (i₁ : ι₁) => M₁ i₁)\n        (direct_sum ι₂ fun (i₂ : ι₂) => M₂ i₂))\n      fun (i : ι₁ × ι₂) =>\n        map (direct_sum.lof R ι₁ M₁ (prod.fst i)) (direct_sum.lof R ι₂ M₂ (prod.snd i)))\n    sorry sorry\n\n@[simp] theorem direct_sum_lof_tmul_lof (R : Type u_1) [comm_ring R] (ι₁ : Type u_2) (ι₂ : Type u_3)\n    [DecidableEq ι₁] [DecidableEq ι₂] (M₁ : ι₁ → Type u_4) (M₂ : ι₂ → Type u_5)\n    [(i₁ : ι₁) → add_comm_group (M₁ i₁)] [(i₂ : ι₂) → add_comm_group (M₂ i₂)]\n    [(i₁ : ι₁) → module R (M₁ i₁)] [(i₂ : ι₂) → module R (M₂ i₂)] (i₁ : ι₁) (m₁ : M₁ i₁) (i₂ : ι₂)\n    (m₂ : M₂ i₂) :\n    coe_fn (direct_sum R ι₁ ι₂ M₁ M₂)\n          (tmul R (coe_fn (direct_sum.lof R ι₁ M₁ i₁) m₁) (coe_fn (direct_sum.lof R ι₂ M₂ i₂) m₂)) =\n        coe_fn\n          (direct_sum.lof R (ι₁ × ι₂)\n            (fun (i : ι₁ × ι₂) => tensor_product R (M₁ (prod.fst i)) (M₂ (prod.snd i))) (i₁, i₂))\n          (tmul R m₁ m₂) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/direct_sum/tensor_product_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929104825006, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4563747521936487}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury G. Kudryashov\n-/\nimport linear_algebra.affine_space.affine_map\nimport algebra.invertible\n\n/-!\n# Affine equivalences\n\nIn this file we define `affine_equiv k P₁ P₂` (notation: `P₁ ≃ᵃ[k] P₂`) to be the type of affine\nequivalences between `P₁` and `P₂, i.e., equivalences such that both forward and inverse maps are\naffine maps.\n\nWe define the following equivalences:\n\n* `affine_equiv.refl k P`: the identity map as an `affine_equiv`;\n\n* `e.symm`: the inverse map of an `affine_equiv` as an `affine_equiv`;\n\n* `e.trans e'`: composition of two `affine_equiv`s; note that the order follows `mathlib`'s\n  `category_theory` convention (apply `e`, then `e'`), not the convention used in function\n  composition and compositions of bundled morphisms.\n\n## Tags\n\naffine space, affine equivalence\n-/\n\nopen function set\nopen_locale affine\n\n/-- An affine equivalence is an equivalence between affine spaces such that both forward\nand inverse maps are affine.\n\nWe define it using an `equiv` for the map and a `linear_equiv` for the linear part in order\nto allow affine equivalences with good definitional equalities. -/\n@[nolint has_inhabited_instance]\nstructure affine_equiv (k P₁ P₂ : Type*) {V₁ V₂ : Type*} [ring k]\n  [add_comm_group V₁] [module k V₁] [add_torsor V₁ P₁]\n  [add_comm_group V₂] [module k V₂] [add_torsor V₂ P₂] extends P₁ ≃ P₂ :=\n(linear : V₁ ≃ₗ[k] V₂)\n(map_vadd' : ∀ (p : P₁) (v : V₁), to_equiv (v +ᵥ p) = linear v +ᵥ to_equiv p)\n\nnotation P₁ ` ≃ᵃ[`:25 k:25 `] `:0 P₂:0 := affine_equiv k P₁ P₂\n\nvariables {k V₁ V₂ V₃ V₄ P₁ P₂ P₃ P₄ : Type*} [ring k]\n  [add_comm_group V₁] [module k V₁] [add_torsor V₁ P₁]\n  [add_comm_group V₂] [module k V₂] [add_torsor V₂ P₂]\n  [add_comm_group V₃] [module k V₃] [add_torsor V₃ P₃]\n  [add_comm_group V₄] [module k V₄] [add_torsor V₄ P₄]\n\nnamespace affine_equiv\n\ninclude V₁ V₂\n\ninstance : has_coe_to_fun (P₁ ≃ᵃ[k] P₂) (λ _, P₁ → P₂) := ⟨λ e, e.to_fun⟩\n\ninstance : has_coe (P₁ ≃ᵃ[k] P₂) (P₁ ≃ P₂) := ⟨affine_equiv.to_equiv⟩\n\nvariables (k P₁)\n\nomit V₂\n\n/-- Identity map as an `affine_equiv`. -/\n@[refl] def refl : P₁ ≃ᵃ[k] P₁ :=\n{ to_equiv := equiv.refl P₁,\n  linear := linear_equiv.refl k V₁,\n  map_vadd' := λ _ _, rfl }\n\n@[simp] lemma coe_refl : ⇑(refl k P₁) = id := rfl\n\nlemma refl_apply (x : P₁) : refl k P₁ x = x := rfl\n\n@[simp] lemma to_equiv_refl : (refl k P₁).to_equiv = equiv.refl P₁ := rfl\n\n@[simp] lemma linear_refl : (refl k P₁).linear = linear_equiv.refl k V₁ := rfl\n\nvariables {k P₁}\n\ninclude V₂\n\n@[simp] lemma map_vadd (e : P₁ ≃ᵃ[k] P₂) (p : P₁) (v : V₁) : e (v +ᵥ p) = e.linear v +ᵥ e p :=\ne.map_vadd' p v\n\n@[simp] lemma coe_to_equiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.to_equiv = e := rfl\n\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef to_affine_map (e : P₁ ≃ᵃ[k] P₂) : P₁ →ᵃ[k] P₂ := { to_fun := e, .. e }\n\ninstance : has_coe (P₁ ≃ᵃ[k] P₂) (P₁ →ᵃ[k] P₂) := ⟨to_affine_map⟩\n\n@[simp] lemma coe_to_affine_map (e : P₁ ≃ᵃ[k] P₂) :\n  (e.to_affine_map : P₁ → P₂) = (e : P₁ → P₂) :=\nrfl\n\n@[simp] lemma to_affine_map_mk (f : P₁ ≃ P₂) (f' : V₁ ≃ₗ[k] V₂) (h) :\n  to_affine_map (mk f f' h) = ⟨f, f', h⟩ :=\nrfl\n\n@[norm_cast, simp] lemma coe_coe (e : P₁ ≃ᵃ[k] P₂) : ((e : P₁ →ᵃ[k] P₂) : P₁ → P₂) = e := rfl\n\n@[simp] lemma linear_to_affine_map (e : P₁ ≃ᵃ[k] P₂) : e.to_affine_map.linear = e.linear := rfl\n\nlemma to_affine_map_injective : injective (to_affine_map : (P₁ ≃ᵃ[k] P₂) → (P₁ →ᵃ[k] P₂)) :=\nbegin\n  rintros ⟨e, el, h⟩ ⟨e', el', h'⟩ H,\n  simp only [to_affine_map_mk, equiv.coe_inj, linear_equiv.to_linear_map_inj] at H,\n  congr,\n  exacts [H.1, H.2]\nend\n\n@[simp] lemma to_affine_map_inj {e e' : P₁ ≃ᵃ[k] P₂} :\n  e.to_affine_map = e'.to_affine_map ↔ e = e' :=\nto_affine_map_injective.eq_iff\n\n@[ext] lemma ext {e e' : P₁ ≃ᵃ[k] P₂} (h : ∀ x, e x = e' x) : e = e' :=\nto_affine_map_injective $ affine_map.ext h\n\nlemma coe_fn_injective : @injective (P₁ ≃ᵃ[k] P₂) (P₁ → P₂) coe_fn :=\nλ e e' H, ext $ congr_fun H\n\n@[simp, norm_cast] lemma coe_fn_inj {e e' : P₁ ≃ᵃ[k] P₂} : (e : P₁ → P₂) = e' ↔ e = e' :=\ncoe_fn_injective.eq_iff\n\nlemma to_equiv_injective : injective (to_equiv : (P₁ ≃ᵃ[k] P₂) → (P₁ ≃ P₂)) :=\nλ e e' H, ext $ equiv.ext_iff.1 H\n\n@[simp] lemma to_equiv_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.to_equiv = e'.to_equiv ↔ e = e' :=\nto_equiv_injective.eq_iff\n\n@[simp] lemma coe_mk (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (h) :\n  ((⟨e, e', h⟩ : P₁ ≃ᵃ[k] P₂) : P₁ → P₂) = e :=\nrfl\n\n/-- Construct an affine equivalence by verifying the relation between the map and its linear part at\none base point. Namely, this function takes a map `e : P₁ → P₂`, a linear equivalence\n`e' : V₁ ≃ₗ[k] V₂`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/\ndef mk' (e : P₁ → P₂) (e' : V₁ ≃ₗ[k] V₂) (p : P₁) (h : ∀ p' : P₁, e p' = e' (p' -ᵥ p) +ᵥ e p) :\n  P₁ ≃ᵃ[k] P₂ :=\n{ to_fun := e,\n  inv_fun := λ q' : P₂, e'.symm (q' -ᵥ e p) +ᵥ p,\n  left_inv := λ p', by simp [h p'],\n  right_inv := λ q', by simp [h (e'.symm (q' -ᵥ e p) +ᵥ p)],\n  linear := e',\n  map_vadd' := λ p' v, by { simp [h p', h (v +ᵥ p'), vadd_vsub_assoc, vadd_vadd] } }\n\n@[simp] lemma coe_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : ⇑(mk' e e' p h) = e := rfl\n@[simp] lemma linear_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) :\n  (mk' e e' p h).linear = e' := rfl\n\n/-- Inverse of an affine equivalence as an affine equivalence. -/\n@[symm] def symm (e : P₁ ≃ᵃ[k] P₂) : P₂ ≃ᵃ[k] P₁ :=\n{ to_equiv := e.to_equiv.symm,\n  linear := e.linear.symm,\n  map_vadd' := λ v p, e.to_equiv.symm.apply_eq_iff_eq_symm_apply.2 $\n    by simpa using (e.to_equiv.apply_symm_apply v).symm }\n\n@[simp] lemma symm_to_equiv (e : P₁ ≃ᵃ[k] P₂) : e.to_equiv.symm = e.symm.to_equiv := rfl\n\n@[simp] lemma symm_linear (e : P₁ ≃ᵃ[k] P₂) : e.linear.symm = e.symm.linear := rfl\n\nprotected lemma bijective (e : P₁ ≃ᵃ[k] P₂) : bijective e := e.to_equiv.bijective\nprotected lemma surjective (e : P₁ ≃ᵃ[k] P₂) : surjective e := e.to_equiv.surjective\nprotected lemma injective (e : P₁ ≃ᵃ[k] P₂) : injective e := e.to_equiv.injective\n\n@[simp] lemma range_eq (e : P₁ ≃ᵃ[k] P₂) : range e = univ := e.surjective.range_eq\n\n@[simp] lemma apply_symm_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₂) : e (e.symm p) = p :=\ne.to_equiv.apply_symm_apply p\n\n@[simp] lemma symm_apply_apply (e : P₁ ≃ᵃ[k] P₂) (p : P₁) : e.symm (e p) = p :=\ne.to_equiv.symm_apply_apply p\n\nlemma apply_eq_iff_eq_symm_apply (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂} : e p₁ = p₂ ↔ p₁ = e.symm p₂ :=\ne.to_equiv.apply_eq_iff_eq_symm_apply\n\n@[simp] lemma apply_eq_iff_eq (e : P₁ ≃ᵃ[k] P₂) {p₁ p₂ : P₁} : e p₁ = e p₂ ↔ p₁ = p₂ :=\ne.to_equiv.apply_eq_iff_eq\n\nomit V₂\n\n@[simp] lemma symm_refl : (refl k P₁).symm = refl k P₁ := rfl\n\ninclude V₂ V₃\n\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\n@[trans] def trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : P₁ ≃ᵃ[k] P₃ :=\n{ to_equiv := e.to_equiv.trans e'.to_equiv,\n  linear := e.linear.trans e'.linear,\n  map_vadd' := λ p v, by simp only [linear_equiv.trans_apply, coe_to_equiv, (∘),\n    equiv.coe_trans, map_vadd] }\n\n@[simp] lemma coe_trans (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) : ⇑(e.trans e') = e' ∘ e := rfl\n\nlemma trans_apply (e : P₁ ≃ᵃ[k] P₂) (e' : P₂ ≃ᵃ[k] P₃) (p : P₁) : e.trans e' p = e' (e p) := rfl\n\ninclude V₄\n\nlemma trans_assoc (e₁ : P₁ ≃ᵃ[k] P₂) (e₂ : P₂ ≃ᵃ[k] P₃) (e₃ : P₃ ≃ᵃ[k] P₄) :\n  (e₁.trans e₂).trans e₃ = e₁.trans (e₂.trans e₃) :=\next $ λ _, rfl\n\nomit V₃ V₄\n\n@[simp] lemma trans_refl (e : P₁ ≃ᵃ[k] P₂) : e.trans (refl k P₂) = e :=\next $ λ _, rfl\n\n@[simp] lemma refl_trans (e : P₁ ≃ᵃ[k] P₂) : (refl k P₁).trans e = e :=\next $ λ _, rfl\n\n@[simp] lemma self_trans_symm (e : P₁ ≃ᵃ[k] P₂) : e.trans e.symm = refl k P₁ :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : P₁ ≃ᵃ[k] P₂) : e.symm.trans e = refl k P₂ :=\next e.apply_symm_apply\n\n@[simp] lemma apply_line_map (e : P₁ ≃ᵃ[k] P₂) (a b : P₁) (c : k) :\n  e (affine_map.line_map a b c) = affine_map.line_map (e a) (e b) c :=\ne.to_affine_map.apply_line_map a b c\n\nomit V₂\n\ninstance : group (P₁ ≃ᵃ[k] P₁) :=\n{ one := refl k P₁,\n  mul := λ e e', e'.trans e,\n  inv := symm,\n  mul_assoc := λ e₁ e₂ e₃, trans_assoc _ _ _,\n  one_mul := trans_refl,\n  mul_one := refl_trans,\n  mul_left_inv := self_trans_symm }\n\nlemma one_def : (1 : P₁ ≃ᵃ[k] P₁) = refl k P₁ := rfl\n\n@[simp] lemma coe_one : ⇑(1 : P₁ ≃ᵃ[k] P₁) = id := rfl\n\nlemma mul_def (e e' : P₁ ≃ᵃ[k] P₁) : e * e' = e'.trans e := rfl\n\n@[simp] lemma coe_mul (e e' : P₁ ≃ᵃ[k] P₁) : ⇑(e * e') = e ∘ e' := rfl\n\nlemma inv_def (e : P₁ ≃ᵃ[k] P₁) : e⁻¹ = e.symm := rfl\n\nvariable (k)\n\n/-- The map `v ↦ v +ᵥ b` as an affine equivalence between a module `V` and an affine space `P` with\ntangent space `V`. -/\ndef vadd_const (b : P₁) : V₁ ≃ᵃ[k] P₁ :=\n{ to_equiv := equiv.vadd_const b,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := λ p v, add_vadd _ _ _ }\n\n@[simp] lemma linear_vadd_const (b : P₁) : (vadd_const k b).linear = linear_equiv.refl k V₁ := rfl\n\n@[simp] lemma vadd_const_apply (b : P₁) (v : V₁) : vadd_const k b v = v +ᵥ b := rfl\n\n@[simp] lemma vadd_const_symm_apply (b p : P₁) : (vadd_const k b).symm p = p -ᵥ b := rfl\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef const_vsub (p : P₁) : P₁ ≃ᵃ[k] V₁ :=\n{ to_equiv := equiv.const_vsub p,\n  linear := linear_equiv.neg k,\n  map_vadd' := λ p' v, by simp [vsub_vadd_eq_vsub_sub, neg_add_eq_sub] }\n\n@[simp] lemma coe_const_vsub (p : P₁) : ⇑(const_vsub k p) = (-ᵥ) p := rfl\n\n@[simp] lemma coe_const_vsub_symm (p : P₁) : ⇑(const_vsub k p).symm = λ v, -v +ᵥ p := rfl\n\nvariable (P₁)\n\n/-- The map `p ↦ v +ᵥ p` as an affine automorphism of an affine space. -/\ndef const_vadd (v : V₁) : P₁ ≃ᵃ[k] P₁ :=\n{ to_equiv := equiv.const_vadd P₁ v,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := λ p w, vadd_comm _ _ _ }\n\n@[simp] lemma linear_const_vadd (v : V₁) : (const_vadd k P₁ v).linear = linear_equiv.refl _ _ := rfl\n\n@[simp] lemma const_vadd_apply (v : V₁) (p : P₁) : const_vadd k P₁ v p = v +ᵥ p := rfl\n\n@[simp] lemma const_vadd_symm_apply (v : V₁) (p : P₁) : (const_vadd k P₁ v).symm p = -v +ᵥ p := rfl\n\nsection homothety\n\nomit V₁\n\nvariables {R V P : Type*} [comm_ring R] [add_comm_group V] [module R V] [affine_space V P]\ninclude V\n\n/-- Fixing a point in affine space, homothety about this point gives a group homomorphism from (the\ncentre of) the units of the scalars into the group of affine equivalences. -/\ndef homothety_units_mul_hom (p : P) : units R →* P ≃ᵃ[R] P :=\n{ to_fun   := λ t,\n  { to_fun    := affine_map.homothety p (t : R),\n    inv_fun   := affine_map.homothety p (↑t⁻¹ : R),\n    left_inv  := λ p, by simp [← affine_map.comp_apply, ← affine_map.homothety_mul],\n    right_inv := λ p, by simp [← affine_map.comp_apply, ← affine_map.homothety_mul],\n    linear    :=\n    { inv_fun   := linear_map.lsmul R V (↑t⁻¹ : R),\n      left_inv  := λ v, by simp [smul_smul],\n      right_inv := λ v, by simp [smul_smul],\n      .. linear_map.lsmul R V t, },\n    map_vadd' := λ p v, by simp only [vadd_vsub_assoc, smul_add, add_vadd, affine_map.coe_line_map,\n      affine_map.homothety_eq_line_map, equiv.coe_fn_mk, linear_equiv.coe_mk,\n      linear_map.lsmul_apply, linear_map.to_fun_eq_coe], },\n  map_one' := by { ext, simp, },\n  map_mul' := λ t₁ t₂, by { ext, simp [← affine_map.comp_apply, ← affine_map.homothety_mul], }, }\n\n@[simp] lemma coe_homothety_units_mul_hom_apply (p : P) (t : units R) :\n  (homothety_units_mul_hom p t : P → P) = affine_map.homothety p (t : R) :=\nrfl\n\n@[simp] lemma coe_homothety_units_mul_hom_apply_symm (p : P) (t : units R) :\n  ((homothety_units_mul_hom p t).symm : P → P) = affine_map.homothety p (↑t⁻¹ : R) :=\nrfl\n\n@[simp] lemma coe_homothety_units_mul_hom_eq_homothety_hom_coe (p : P) :\n  (coe : (P ≃ᵃ[R] P) → P →ᵃ[R] P) ∘ homothety_units_mul_hom p =\n  (affine_map.homothety_hom p) ∘ (coe : units R → R) :=\nby { ext, simp, }\n\nend homothety\n\nvariable {P₁}\nopen function\n\n/-- Point reflection in `x` as a permutation. -/\ndef point_reflection (x : P₁) : P₁ ≃ᵃ[k] P₁ := (const_vsub k x).trans (vadd_const k x)\n\nlemma point_reflection_apply (x y : P₁) : point_reflection k x y = x -ᵥ y +ᵥ x := rfl\n\n@[simp] lemma point_reflection_symm (x : P₁) : (point_reflection k x).symm = point_reflection k x :=\nto_equiv_injective $ equiv.point_reflection_symm x\n\n@[simp] lemma to_equiv_point_reflection (x : P₁) :\n  (point_reflection k x).to_equiv = equiv.point_reflection x :=\nrfl\n\n@[simp] lemma point_reflection_self (x : P₁) : point_reflection k x x = x := vsub_vadd _ _\n\nlemma point_reflection_involutive (x : P₁) : involutive (point_reflection k x : P₁ → P₁) :=\nequiv.point_reflection_involutive x\n\n/-- `x` is the only fixed point of `point_reflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\nlemma point_reflection_fixed_iff_of_injective_bit0 {x y : P₁} (h : injective (bit0 : V₁ → V₁)) :\n  point_reflection k x y = y ↔ y = x :=\nequiv.point_reflection_fixed_iff_of_injective_bit0 h\n\nlemma injective_point_reflection_left_of_injective_bit0 (h : injective (bit0 : V₁ → V₁)) (y : P₁) :\n  injective (λ x : P₁, point_reflection k x y) :=\nequiv.injective_point_reflection_left_of_injective_bit0 h y\n\nlemma injective_point_reflection_left_of_module [invertible (2:k)]:\n  ∀ y, injective (λ x : P₁, point_reflection k x y) :=\ninjective_point_reflection_left_of_injective_bit0 k $ λ x y h,\n  by rwa [bit0, bit0, ← two_smul k x, ← two_smul k y,\n    (is_unit_of_invertible (2:k)).smul_left_cancel] at h\n\nlemma point_reflection_fixed_iff_of_module [invertible (2:k)] {x y : P₁} :\n  point_reflection k x y = y ↔ y = x :=\n((injective_point_reflection_left_of_module k y).eq_iff' (point_reflection_self k y)).trans eq_comm\n\nend affine_equiv\n\nnamespace linear_equiv\n\n/-- Interpret a linear equivalence between modules as an affine equivalence. -/\ndef to_affine_equiv (e : V₁ ≃ₗ[k] V₂) : V₁ ≃ᵃ[k] V₂ :=\n{ to_equiv := e.to_equiv,\n  linear := e,\n  map_vadd' := λ p v, e.map_add v p }\n\n@[simp] lemma coe_to_affine_equiv (e : V₁ ≃ₗ[k] V₂) : ⇑e.to_affine_equiv = e := rfl\n\nend linear_equiv\n\nnamespace affine_map\n\nopen affine_equiv\n\ninclude V₁\n\nlemma line_map_vadd (v v' : V₁) (p : P₁) (c : k) :\n  line_map v v' c +ᵥ p = line_map (v +ᵥ p) (v' +ᵥ p) c :=\n(vadd_const k p).apply_line_map v v' c\n\nlemma line_map_vsub (p₁ p₂ p₃ : P₁) (c : k) :\n  line_map p₁ p₂ c -ᵥ p₃ = line_map (p₁ -ᵥ p₃) (p₂ -ᵥ p₃) c :=\n(vadd_const k p₃).symm.apply_line_map p₁ p₂ c\n\nlemma vsub_line_map (p₁ p₂ p₃ : P₁) (c : k) :\n  p₁ -ᵥ line_map p₂ p₃ c = line_map (p₁ -ᵥ p₂) (p₁ -ᵥ p₃) c :=\n(const_vsub k p₁).apply_line_map p₂ p₃ c\n\nlemma vadd_line_map (v : V₁) (p₁ p₂ : P₁) (c : k) :\n  v +ᵥ line_map p₁ p₂ c = line_map (v +ᵥ p₁) (v +ᵥ p₂) c :=\n(const_vadd k P₁ v).apply_line_map p₁ p₂ c\n\nvariables {R' : Type*} [comm_ring R'] [module R' V₁]\n\nlemma homothety_neg_one_apply (c p : P₁) :\n  homothety c (-1:R') p = point_reflection R' c p :=\nby simp [homothety_apply, point_reflection_apply]\n\nend affine_map\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/linear_algebra/affine_space/affine_equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4562814839678506}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.list.basic\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\nnamespace list\n\n\n/- pairwise relation (generalized no duplicate) -/\n\ntheorem pairwise_iff {α : Type u} (R : α → α → Prop) :\n    ∀ (ᾰ : List α),\n        pairwise R ᾰ ↔\n          ᾰ = [] ∨\n            Exists\n              fun {a : α} =>\n                Exists\n                  fun {l : List α} => (∀ (a' : α), a' ∈ l → R a a') ∧ pairwise R l ∧ ᾰ = a :: l :=\n  sorry\n\ntheorem rel_of_pairwise_cons {α : Type u} {R : α → α → Prop} {a : α} {l : List α}\n    (p : pairwise R (a :: l)) {a' : α} : a' ∈ l → R a a' :=\n  and.left (iff.mp pairwise_cons p)\n\ntheorem pairwise_of_pairwise_cons {α : Type u} {R : α → α → Prop} {a : α} {l : List α}\n    (p : pairwise R (a :: l)) : pairwise R l :=\n  and.right (iff.mp pairwise_cons p)\n\ntheorem pairwise.tail {α : Type u} {R : α → α → Prop} {l : List α} (p : pairwise R l) :\n    pairwise R (tail l) :=\n  sorry\n\ntheorem pairwise.imp_of_mem {α : Type u} {R : α → α → Prop} {S : α → α → Prop} {l : List α}\n    (H : ∀ {a b : α}, a ∈ l → b ∈ l → R a b → S a b) (p : pairwise R l) : pairwise S l :=\n  sorry\n\ntheorem pairwise.imp {α : Type u} {R : α → α → Prop} {S : α → α → Prop}\n    (H : ∀ (a b : α), R a b → S a b) {l : List α} : pairwise R l → pairwise S l :=\n  pairwise.imp_of_mem fun (a b : α) (_x : a ∈ l) (_x : b ∈ l) => H a b\n\ntheorem pairwise.and {α : Type u} {R : α → α → Prop} {S : α → α → Prop} {l : List α} :\n    pairwise (fun (a b : α) => R a b ∧ S a b) l ↔ pairwise R l ∧ pairwise S l :=\n  sorry\n\ntheorem pairwise.imp₂ {α : Type u} {R : α → α → Prop} {S : α → α → Prop} {T : α → α → Prop}\n    (H : ∀ (a b : α), R a b → S a b → T a b) {l : List α} (hR : pairwise R l) (hS : pairwise S l) :\n    pairwise T l :=\n  pairwise.imp (fun (a b : α) => And._oldrec (H a b))\n    (iff.mpr pairwise.and { left := hR, right := hS })\n\ntheorem pairwise.iff_of_mem {α : Type u} {R : α → α → Prop} {S : α → α → Prop} {l : List α}\n    (H : ∀ {a b : α}, a ∈ l → b ∈ l → (R a b ↔ S a b)) : pairwise R l ↔ pairwise S l :=\n  { mp := pairwise.imp_of_mem fun (a b : α) (m : a ∈ l) (m' : b ∈ l) => iff.mp (H m m'),\n    mpr := pairwise.imp_of_mem fun (a b : α) (m : a ∈ l) (m' : b ∈ l) => iff.mpr (H m m') }\n\ntheorem pairwise.iff {α : Type u} {R : α → α → Prop} {S : α → α → Prop}\n    (H : ∀ (a b : α), R a b ↔ S a b) {l : List α} : pairwise R l ↔ pairwise S l :=\n  pairwise.iff_of_mem fun (a b : α) (_x : a ∈ l) (_x : b ∈ l) => H a b\n\ntheorem pairwise_of_forall {α : Type u} {R : α → α → Prop} {l : List α} (H : ∀ (x y : α), R x y) :\n    pairwise R l :=\n  sorry\n\ntheorem pairwise.and_mem {α : Type u} {R : α → α → Prop} {l : List α} :\n    pairwise R l ↔ pairwise (fun (x y : α) => x ∈ l ∧ y ∈ l ∧ R x y) l :=\n  sorry\n\ntheorem pairwise.imp_mem {α : Type u} {R : α → α → Prop} {l : List α} :\n    pairwise R l ↔ pairwise (fun (x y : α) => x ∈ l → y ∈ l → R x y) l :=\n  sorry\n\ntheorem pairwise_of_sublist {α : Type u} {R : α → α → Prop} {l₁ : List α} {l₂ : List α} :\n    l₁ <+ l₂ → pairwise R l₂ → pairwise R l₁ :=\n  sorry\n\ntheorem forall_of_forall_of_pairwise {α : Type u} {R : α → α → Prop} (H : symmetric R) {l : List α}\n    (H₁ : ∀ (x : α), x ∈ l → R x x) (H₂ : pairwise R l) (x : α) :\n    x ∈ l → ∀ (y : α), y ∈ l → R x y :=\n  sorry\n\ntheorem forall_of_pairwise {α : Type u} {R : α → α → Prop} (H : symmetric R) {l : List α}\n    (hl : pairwise R l) (a : α) : a ∈ l → ∀ (b : α), b ∈ l → a ≠ b → R a b :=\n  forall_of_forall_of_pairwise\n    (fun (a b : α) (h : a ≠ b → R a b) (hne : b ≠ a) => H (h (ne.symm hne)))\n    (fun (_x : α) (_x_1 : _x ∈ l) (h : _x ≠ _x) => false.elim (h rfl))\n    (pairwise.imp (fun (_x _x_1 : α) (h : R _x _x_1) (_x : _x ≠ _x_1) => h) hl)\n\ntheorem pairwise_singleton {α : Type u} (R : α → α → Prop) (a : α) : pairwise R [a] := sorry\n\ntheorem pairwise_pair {α : Type u} {R : α → α → Prop} {a : α} {b : α} : pairwise R [a, b] ↔ R a b :=\n  sorry\n\ntheorem pairwise_append {α : Type u} {R : α → α → Prop} {l₁ : List α} {l₂ : List α} :\n    pairwise R (l₁ ++ l₂) ↔\n        pairwise R l₁ ∧ pairwise R l₂ ∧ ∀ (x : α), x ∈ l₁ → ∀ (y : α), y ∈ l₂ → R x y :=\n  sorry\n\ntheorem pairwise_append_comm {α : Type u} {R : α → α → Prop} (s : symmetric R) {l₁ : List α}\n    {l₂ : List α} : pairwise R (l₁ ++ l₂) ↔ pairwise R (l₂ ++ l₁) :=\n  sorry\n\ntheorem pairwise_middle {α : Type u} {R : α → α → Prop} (s : symmetric R) {a : α} {l₁ : List α}\n    {l₂ : List α} : pairwise R (l₁ ++ a :: l₂) ↔ pairwise R (a :: (l₁ ++ l₂)) :=\n  sorry\n\ntheorem pairwise_map {α : Type u} {β : Type v} {R : α → α → Prop} (f : β → α) {l : List β} :\n    pairwise R (map f l) ↔ pairwise (fun (a b : β) => R (f a) (f b)) l :=\n  sorry\n\ntheorem pairwise_of_pairwise_map {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    (f : α → β) (H : ∀ (a b : α), S (f a) (f b) → R a b) {l : List α} (p : pairwise S (map f l)) :\n    pairwise R l :=\n  pairwise.imp H (iff.mp (pairwise_map f) p)\n\ntheorem pairwise_map_of_pairwise {α : Type u} {β : Type v} {R : α → α → Prop} {S : β → β → Prop}\n    (f : α → β) (H : ∀ (a b : α), R a b → S (f a) (f b)) {l : List α} (p : pairwise R l) :\n    pairwise S (map f l) :=\n  iff.mpr (pairwise_map f) (pairwise.imp H p)\n\ntheorem pairwise_filter_map {α : Type u} {β : Type v} {R : α → α → Prop} (f : β → Option α)\n    {l : List β} :\n    pairwise R (filter_map f l) ↔\n        pairwise (fun (a a' : β) => ∀ (b : α), b ∈ f a → ∀ (b' : α), b' ∈ f a' → R b b') l :=\n  sorry\n\ntheorem pairwise_filter_map_of_pairwise {α : Type u} {β : Type v} {R : α → α → Prop}\n    {S : β → β → Prop} (f : α → Option β)\n    (H : ∀ (a a' : α), R a a' → ∀ (b : β), b ∈ f a → ∀ (b' : β), b' ∈ f a' → S b b') {l : List α}\n    (p : pairwise R l) : pairwise S (filter_map f l) :=\n  iff.mpr (pairwise_filter_map f) (pairwise.imp H p)\n\ntheorem pairwise_filter {α : Type u} {R : α → α → Prop} (p : α → Prop) [decidable_pred p]\n    {l : List α} : pairwise R (filter p l) ↔ pairwise (fun (x y : α) => p x → p y → R x y) l :=\n  sorry\n\ntheorem pairwise_filter_of_pairwise {α : Type u} {R : α → α → Prop} (p : α → Prop)\n    [decidable_pred p] {l : List α} : pairwise R l → pairwise R (filter p l) :=\n  pairwise_of_sublist (filter_sublist l)\n\ntheorem pairwise_pmap {α : Type u} {β : Type v} {R : α → α → Prop} {p : β → Prop}\n    {f : (b : β) → p b → α} {l : List β} (h : ∀ (x : β), x ∈ l → p x) :\n    pairwise R (pmap f l h) ↔\n        pairwise (fun (b₁ b₂ : β) => ∀ (h₁ : p b₁) (h₂ : p b₂), R (f b₁ h₁) (f b₂ h₂)) l :=\n  sorry\n\ntheorem pairwise.pmap {α : Type u} {β : Type v} {R : α → α → Prop} {l : List α} (hl : pairwise R l)\n    {p : α → Prop} {f : (a : α) → p a → β} (h : ∀ (x : α), x ∈ l → p x) {S : β → β → Prop}\n    (hS : ∀ {x : α} (hx : p x) {y : α} (hy : p y), R x y → S (f x hx) (f y hy)) :\n    pairwise S (pmap f l h) :=\n  iff.mpr (pairwise_pmap h)\n    (pairwise.imp_of_mem\n      (fun (a b : α) (ᾰ : a ∈ l) (ᾰ_1 : b ∈ l) (ᾰ_2 : R a b) (h₁ : p a) (h₂ : p b) => hS h₁ h₂ ᾰ_2)\n      hl)\n\ntheorem pairwise_join {α : Type u} {R : α → α → Prop} {L : List (List α)} :\n    pairwise R (join L) ↔\n        (∀ (l : List α), l ∈ L → pairwise R l) ∧\n          pairwise (fun (l₁ l₂ : List α) => ∀ (x : α), x ∈ l₁ → ∀ (y : α), y ∈ l₂ → R x y) L :=\n  sorry\n\n@[simp] theorem pairwise_reverse {α : Type u} {R : α → α → Prop} {l : List α} :\n    pairwise R (reverse l) ↔ pairwise (fun (x y : α) => R y x) l :=\n  sorry\n\ntheorem pairwise_iff_nth_le {α : Type u} {R : α → α → Prop} {l : List α} :\n    pairwise R l ↔\n        ∀ (i j : ℕ) (h₁ : j < length l) (h₂ : i < j),\n          R (nth_le l i (lt_trans h₂ h₁)) (nth_le l j h₁) :=\n  sorry\n\ntheorem pairwise_sublists' {α : Type u} {R : α → α → Prop} {l : List α} :\n    pairwise R l → pairwise (lex (function.swap R)) (sublists' l) :=\n  sorry\n\ntheorem pairwise_sublists {α : Type u} {R : α → α → Prop} {l : List α} (H : pairwise R l) :\n    pairwise (fun (l₁ l₂ : List α) => lex R (reverse l₁) (reverse l₂)) (sublists l) :=\n  sorry\n\n/- pairwise reduct -/\n\n@[simp] theorem pw_filter_nil {α : Type u} {R : α → α → Prop} [DecidableRel R] :\n    pw_filter R [] = [] :=\n  rfl\n\n@[simp] theorem pw_filter_cons_of_pos {α : Type u} {R : α → α → Prop} [DecidableRel R] {a : α}\n    {l : List α} (h : ∀ (b : α), b ∈ pw_filter R l → R a b) :\n    pw_filter R (a :: l) = a :: pw_filter R l :=\n  if_pos h\n\n@[simp] theorem pw_filter_cons_of_neg {α : Type u} {R : α → α → Prop} [DecidableRel R] {a : α}\n    {l : List α} (h : ¬∀ (b : α), b ∈ pw_filter R l → R a b) :\n    pw_filter R (a :: l) = pw_filter R l :=\n  if_neg h\n\ntheorem pw_filter_map {α : Type u} {β : Type v} {R : α → α → Prop} [DecidableRel R] (f : β → α)\n    (l : List β) : pw_filter R (map f l) = map f (pw_filter (fun (x y : β) => R (f x) (f y)) l) :=\n  sorry\n\ntheorem pw_filter_sublist {α : Type u} {R : α → α → Prop} [DecidableRel R] (l : List α) :\n    pw_filter R l <+ l :=\n  sorry\n\ntheorem pw_filter_subset {α : Type u} {R : α → α → Prop} [DecidableRel R] (l : List α) :\n    pw_filter R l ⊆ l :=\n  sublist.subset (pw_filter_sublist l)\n\ntheorem pairwise_pw_filter {α : Type u} {R : α → α → Prop} [DecidableRel R] (l : List α) :\n    pairwise R (pw_filter R l) :=\n  sorry\n\ntheorem pw_filter_eq_self {α : Type u} {R : α → α → Prop} [DecidableRel R] {l : List α} :\n    pw_filter R l = l ↔ pairwise R l :=\n  sorry\n\n@[simp] theorem pw_filter_idempotent {α : Type u} {R : α → α → Prop} [DecidableRel R] {l : List α} :\n    pw_filter R (pw_filter R l) = pw_filter R l :=\n  iff.mpr pw_filter_eq_self (pairwise_pw_filter l)\n\ntheorem forall_mem_pw_filter {α : Type u} {R : α → α → Prop} [DecidableRel R]\n    (neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z) (a : α) (l : List α) :\n    (∀ (b : α), b ∈ pw_filter R l → R a b) ↔ ∀ (b : α), b ∈ l → R a b :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/list/pairwise_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.45628147419440546}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Scott Morrison\n\n! This file was ported from Lean 3 source module category_theory.filtered\n! leanprover-community/mathlib commit ee05e9ce1322178f0c12004eb93c00d2c8c00ed2\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.FinCategory\nimport Mathbin.CategoryTheory.Limits.Cones\nimport Mathbin.CategoryTheory.Adjunction.Basic\nimport Mathbin.CategoryTheory.Category.Preorder\nimport Mathbin.CategoryTheory.Category.Ulift\n\n/-!\n# Filtered categories\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nA category is filtered if every finite diagram admits a cocone.\nWe give a simple characterisation of this condition as\n1. for every pair of objects there exists another object \"to the right\",\n2. for every pair of parallel morphisms there exists a morphism to the right so the compositions\n   are equal, and\n3. there exists some object.\n\nFiltered colimits are often better behaved than arbitrary colimits.\nSee `category_theory/limits/types` for some details.\n\nFiltered categories are nice because colimits indexed by filtered categories tend to be\neasier to describe than general colimits (and more often preserved by functors).\n\nIn this file we show that any functor from a finite category to a filtered category admits a cocone:\n* `cocone_nonempty [fin_category J] [is_filtered C] (F : J ⥤ C) : nonempty (cocone F)`\nMore generally,\nfor any finite collection of objects and morphisms between them in a filtered category\n(even if not closed under composition) there exists some object `Z` receiving maps from all of them,\nso that all the triangles (one edge from the finite set, two from morphisms to `Z`) commute.\nThis formulation is often more useful in practice and is available via `sup_exists`,\nwhich takes a finset of objects, and an indexed family (indexed by source and target)\nof finsets of morphisms.\n\nFurthermore, we give special support for two diagram categories: The `bowtie` and the `tulip`.\nThis is because these shapes show up in the proofs that forgetful functors of algebraic categories\n(e.g. `Mon`, `CommRing`, ...) preserve filtered colimits.\n\nAll of the above API, except for the `bowtie` and the `tulip`, is also provided for cofiltered\ncategories.\n\n## See also\nIn `category_theory.limits.filtered_colimit_commutes_finite_limit` we show that filtered colimits\ncommute with finite limits.\n\n-/\n\n\nopen Function\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverse w v v₁ u u₁ u₂\n\nnamespace CategoryTheory\n\nvariable (C : Type u) [Category.{v} C]\n\n#print CategoryTheory.IsFilteredOrEmpty /-\n/-- A category `is_filtered_or_empty` if\n1. for every pair of objects there exists another object \"to the right\", and\n2. for every pair of parallel morphisms there exists a morphism to the right so the compositions\n   are equal.\n-/\nclass IsFilteredOrEmpty : Prop where\n  cocone_objs : ∀ X Y : C, ∃ (Z : _)(f : X ⟶ Z)(g : Y ⟶ Z), True\n  cocone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (Z : _)(h : Y ⟶ Z), f ≫ h = g ≫ h\n#align category_theory.is_filtered_or_empty CategoryTheory.IsFilteredOrEmpty\n-/\n\n#print CategoryTheory.IsFiltered /-\n/-- A category `is_filtered` if\n1. for every pair of objects there exists another object \"to the right\",\n2. for every pair of parallel morphisms there exists a morphism to the right so the compositions\n   are equal, and\n3. there exists some object.\n\nSee <https://stacks.math.columbia.edu/tag/002V>. (They also define a diagram being filtered.)\n-/\nclass IsFiltered extends IsFilteredOrEmpty C : Prop where\n  [Nonempty : Nonempty C]\n#align category_theory.is_filtered CategoryTheory.IsFiltered\n-/\n\n#print CategoryTheory.isFilteredOrEmpty_of_semilatticeSup /-\ninstance (priority := 100) isFilteredOrEmpty_of_semilatticeSup (α : Type u) [SemilatticeSup α] :\n    IsFilteredOrEmpty α\n    where\n  cocone_objs X Y := ⟨X ⊔ Y, homOfLE le_sup_left, homOfLE le_sup_right, trivial⟩\n  cocone_maps X Y f g := ⟨Y, 𝟙 _, by ext⟩\n#align category_theory.is_filtered_or_empty_of_semilattice_sup CategoryTheory.isFilteredOrEmpty_of_semilatticeSup\n-/\n\n#print CategoryTheory.isFiltered_of_semilatticeSup_nonempty /-\ninstance (priority := 100) isFiltered_of_semilatticeSup_nonempty (α : Type u) [SemilatticeSup α]\n    [Nonempty α] : IsFiltered α where\n#align category_theory.is_filtered_of_semilattice_sup_nonempty CategoryTheory.isFiltered_of_semilatticeSup_nonempty\n-/\n\n#print CategoryTheory.isFilteredOrEmpty_of_directed_le /-\ninstance (priority := 100) isFilteredOrEmpty_of_directed_le (α : Type u) [Preorder α]\n    [IsDirected α (· ≤ ·)] : IsFilteredOrEmpty α\n    where\n  cocone_objs X Y :=\n    let ⟨Z, h1, h2⟩ := exists_ge_ge X Y\n    ⟨Z, homOfLE h1, homOfLE h2, trivial⟩\n  cocone_maps X Y f g := ⟨Y, 𝟙 _, by simp⟩\n#align category_theory.is_filtered_or_empty_of_directed_le CategoryTheory.isFilteredOrEmpty_of_directed_le\n-/\n\n#print CategoryTheory.isFiltered_of_directed_le_nonempty /-\ninstance (priority := 100) isFiltered_of_directed_le_nonempty (α : Type u) [Preorder α]\n    [IsDirected α (· ≤ ·)] [Nonempty α] : IsFiltered α where\n#align category_theory.is_filtered_of_directed_le_nonempty CategoryTheory.isFiltered_of_directed_le_nonempty\n-/\n\n-- Sanity checks\nexample (α : Type u) [SemilatticeSup α] [OrderBot α] : IsFiltered α := by infer_instance\n\nexample (α : Type u) [SemilatticeSup α] [OrderTop α] : IsFiltered α := by infer_instance\n\ninstance : IsFiltered (Discrete PUnit)\n    where\n  cocone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by decide⟩⟩, ⟨⟨by decide⟩⟩, trivial⟩\n  cocone_maps X Y f g := ⟨⟨PUnit.unit⟩, ⟨⟨by decide⟩⟩, by decide⟩\n  Nonempty := ⟨⟨PUnit.unit⟩⟩\n\nnamespace IsFiltered\n\nsection AllowEmpty\n\nvariable {C} [IsFilteredOrEmpty C]\n\ntheorem cocone_objs : ∀ X Y : C, ∃ (Z : _)(f : X ⟶ Z)(g : Y ⟶ Z), True :=\n  IsFilteredOrEmpty.cocone_objs\n#align category_theory.is_filtered.cocone_objs CategoryTheory.IsFiltered.cocone_objs\n\ntheorem cocone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (Z : _)(h : Y ⟶ Z), f ≫ h = g ≫ h :=\n  IsFilteredOrEmpty.cocone_maps\n#align category_theory.is_filtered.cocone_maps CategoryTheory.IsFiltered.cocone_maps\n\n#print CategoryTheory.IsFiltered.max /-\n/-- `max j j'` is an arbitrary choice of object to the right of both `j` and `j'`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def max (j j' : C) : C :=\n  (cocone_objs j j').some\n#align category_theory.is_filtered.max CategoryTheory.IsFiltered.max\n-/\n\n#print CategoryTheory.IsFiltered.leftToMax /-\n/-- `left_to_max j j'` is an arbitrary choice of morphism from `j` to `max j j'`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def leftToMax (j j' : C) : j ⟶ max j j' :=\n  (cocone_objs j j').choose_spec.some\n#align category_theory.is_filtered.left_to_max CategoryTheory.IsFiltered.leftToMax\n-/\n\n#print CategoryTheory.IsFiltered.rightToMax /-\n/-- `right_to_max j j'` is an arbitrary choice of morphism from `j'` to `max j j'`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def rightToMax (j j' : C) : j' ⟶ max j j' :=\n  (cocone_objs j j').choose_spec.choose_spec.some\n#align category_theory.is_filtered.right_to_max CategoryTheory.IsFiltered.rightToMax\n-/\n\n#print CategoryTheory.IsFiltered.coeq /-\n/-- `coeq f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of object\nwhich admits a morphism `coeq_hom f f' : j' ⟶ coeq f f'` such that\n`coeq_condition : f ≫ coeq_hom f f' = f' ≫ coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq {j j' : C} (f f' : j ⟶ j') : C :=\n  (cocone_maps f f').some\n#align category_theory.is_filtered.coeq CategoryTheory.IsFiltered.coeq\n-/\n\n#print CategoryTheory.IsFiltered.coeqHom /-\n/-- `coeq_hom f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of morphism\n`coeq_hom f f' : j' ⟶ coeq f f'` such that\n`coeq_condition : f ≫ coeq_hom f f' = f' ≫ coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeqHom {j j' : C} (f f' : j ⟶ j') : j' ⟶ coeq f f' :=\n  (cocone_maps f f').choose_spec.some\n#align category_theory.is_filtered.coeq_hom CategoryTheory.IsFiltered.coeqHom\n-/\n\n#print CategoryTheory.IsFiltered.coeq_condition /-\n/-- `coeq_condition f f'`, for morphisms `f f' : j ⟶ j'`, is the proof that\n`f ≫ coeq_hom f f' = f' ≫ coeq_hom f f'`.\n-/\n@[simp, reassoc.1]\ntheorem coeq_condition {j j' : C} (f f' : j ⟶ j') : f ≫ coeqHom f f' = f' ≫ coeqHom f f' :=\n  (cocone_maps f f').choose_spec.choose_spec\n#align category_theory.is_filtered.coeq_condition CategoryTheory.IsFiltered.coeq_condition\n-/\n\nend AllowEmpty\n\nsection Nonempty\n\nopen CategoryTheory.Limits\n\nvariable {C} [IsFiltered C]\n\n#print CategoryTheory.IsFiltered.sup_objs_exists /-\n/-- Any finite collection of objects in a filtered category has an object \"to the right\".\n-/\ntheorem sup_objs_exists (O : Finset C) : ∃ S : C, ∀ {X}, X ∈ O → Nonempty (X ⟶ S) := by\n  classical\n    apply Finset.induction_on O\n    · exact ⟨is_filtered.nonempty.some, by rintro - ⟨⟩⟩\n    · rintro X O' nm ⟨S', w'⟩\n      use max X S'\n      rintro Y mY\n      obtain rfl | h := eq_or_ne Y X\n      · exact ⟨left_to_max _ _⟩\n      · exact ⟨(w' (Finset.mem_of_mem_insert_of_ne mY h)).some ≫ right_to_max _ _⟩\n#align category_theory.is_filtered.sup_objs_exists CategoryTheory.IsFiltered.sup_objs_exists\n-/\n\nvariable (O : Finset C) (H : Finset (Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y))\n\n#print CategoryTheory.IsFiltered.sup_exists /-\n/-- Given any `finset` of objects `{X, ...}` and\nindexed collection of `finset`s of morphisms `{f, ...}` in `C`,\nthere exists an object `S`, with a morphism `T X : X ⟶ S` from each `X`,\nsuch that the triangles commute: `f ≫ T Y = T X`, for `f : X ⟶ Y` in the `finset`.\n-/\ntheorem sup_exists :\n    ∃ (S : C)(T : ∀ {X : C}, X ∈ O → (X ⟶ S)),\n      ∀ {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y},\n        (⟨X, Y, mX, mY, f⟩ : Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y) ∈ H → f ≫ T mY = T mX :=\n  by\n  classical\n    apply Finset.induction_on H\n    · obtain ⟨S, f⟩ := sup_objs_exists O\n      refine' ⟨S, fun X mX => (f mX).some, _⟩\n      rintro - - - - - ⟨⟩\n    · rintro ⟨X, Y, mX, mY, f⟩ H' nmf ⟨S', T', w'⟩\n      refine' ⟨coeq (f ≫ T' mY) (T' mX), fun Z mZ => T' mZ ≫ coeq_hom (f ≫ T' mY) (T' mX), _⟩\n      intro X' Y' mX' mY' f' mf'\n      rw [← category.assoc]\n      by_cases h : X = X' ∧ Y = Y'\n      · rcases h with ⟨rfl, rfl⟩\n        by_cases hf : f = f'\n        · subst hf\n          apply coeq_condition\n        · rw [@w' _ _ mX mY f' (by simpa [hf ∘ Eq.symm] using mf')]\n      · rw [@w' _ _ mX' mY' f' _]\n        apply Finset.mem_of_mem_insert_of_ne mf'\n        contrapose! h\n        obtain ⟨rfl, h⟩ := h\n        rw [heq_iff_eq, PSigma.mk.inj_iff] at h\n        exact ⟨rfl, h.1.symm⟩\n#align category_theory.is_filtered.sup_exists CategoryTheory.IsFiltered.sup_exists\n-/\n\n#print CategoryTheory.IsFiltered.sup /-\n/-- An arbitrary choice of object \"to the right\"\nof a finite collection of objects `O` and morphisms `H`,\nmaking all the triangles commute.\n-/\nnoncomputable def sup : C :=\n  (sup_exists O H).some\n#align category_theory.is_filtered.sup CategoryTheory.IsFiltered.sup\n-/\n\n#print CategoryTheory.IsFiltered.toSup /-\n/-- The morphisms to `sup O H`.\n-/\nnoncomputable def toSup {X : C} (m : X ∈ O) : X ⟶ sup O H :=\n  (sup_exists O H).choose_spec.some m\n#align category_theory.is_filtered.to_sup CategoryTheory.IsFiltered.toSup\n-/\n\n#print CategoryTheory.IsFiltered.toSup_commutes /-\n/-- The triangles of consisting of a morphism in `H` and the maps to `sup O H` commute.\n-/\ntheorem toSup_commutes {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y}\n    (mf : (⟨X, Y, mX, mY, f⟩ : Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y) ∈ H) :\n    f ≫ toSup O H mY = toSup O H mX :=\n  (sup_exists O H).choose_spec.choose_spec mX mY mf\n#align category_theory.is_filtered.to_sup_commutes CategoryTheory.IsFiltered.toSup_commutes\n-/\n\nvariable {J : Type v} [SmallCategory J] [FinCategory J]\n\n#print CategoryTheory.IsFiltered.cocone_nonempty /-\n/-- If we have `is_filtered C`, then for any functor `F : J ⥤ C` with `fin_category J`,\nthere exists a cocone over `F`.\n-/\ntheorem cocone_nonempty (F : J ⥤ C) : Nonempty (Cocone F) := by\n  classical\n    let O := finset.univ.image F.obj\n    let H : Finset (Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y) :=\n      finset.univ.bUnion fun X : J =>\n        finset.univ.bUnion fun Y : J =>\n          finset.univ.image fun f : X ⟶ Y => ⟨F.obj X, F.obj Y, by simp, by simp, F.map f⟩\n    obtain ⟨Z, f, w⟩ := sup_exists O H\n    refine' ⟨⟨Z, ⟨fun X => f (by simp), _⟩⟩⟩\n    intro j j' g\n    dsimp\n    simp only [category.comp_id]\n    apply w\n    simp only [Finset.mem_univ, Finset.mem_bunionᵢ, exists_and_left, exists_prop_of_true,\n      Finset.mem_image]\n    exact ⟨j, rfl, j', g, by simp⟩\n#align category_theory.is_filtered.cocone_nonempty CategoryTheory.IsFiltered.cocone_nonempty\n-/\n\n#print CategoryTheory.IsFiltered.cocone /-\n/-- An arbitrary choice of cocone over `F : J ⥤ C`, for `fin_category J` and `is_filtered C`.\n-/\nnoncomputable def cocone (F : J ⥤ C) : Cocone F :=\n  (cocone_nonempty F).some\n#align category_theory.is_filtered.cocone CategoryTheory.IsFiltered.cocone\n-/\n\nvariable {D : Type u₁} [Category.{v₁} D]\n\n#print CategoryTheory.IsFiltered.of_right_adjoint /-\n/-- If `C` is filtered, and we have a functor `R : C ⥤ D` with a left adjoint, then `D` is filtered.\n-/\ntheorem of_right_adjoint {L : D ⥤ C} {R : C ⥤ D} (h : L ⊣ R) : IsFiltered D :=\n  { cocone_objs := fun X Y =>\n      ⟨_, h.homEquiv _ _ (leftToMax _ _), h.homEquiv _ _ (rightToMax _ _), ⟨⟩⟩\n    cocone_maps := fun X Y f g =>\n      ⟨_, h.homEquiv _ _ (coeqHom _ _), by\n        rw [← h.hom_equiv_naturality_left, ← h.hom_equiv_naturality_left, coeq_condition]⟩\n    Nonempty := IsFiltered.nonempty.map R.obj }\n#align category_theory.is_filtered.of_right_adjoint CategoryTheory.IsFiltered.of_right_adjoint\n-/\n\n#print CategoryTheory.IsFiltered.of_isRightAdjoint /-\n/-- If `C` is filtered, and we have a right adjoint functor `R : C ⥤ D`, then `D` is filtered. -/\ntheorem of_isRightAdjoint (R : C ⥤ D) [IsRightAdjoint R] : IsFiltered D :=\n  of_right_adjoint (Adjunction.ofRightAdjoint R)\n#align category_theory.is_filtered.of_is_right_adjoint CategoryTheory.IsFiltered.of_isRightAdjoint\n-/\n\n/- warning: category_theory.is_filtered.of_equivalence -> CategoryTheory.IsFiltered.of_equivalence is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.IsFiltered.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_5 : CategoryTheory.Category.{u2, u4} D], (CategoryTheory.Equivalence.{u1, u2, u3, u4} C _inst_1 D _inst_5) -> (CategoryTheory.IsFiltered.{u2, u4} D _inst_5)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.IsFiltered.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_5 : CategoryTheory.Category.{u2, u4} D], (CategoryTheory.Equivalence.{u1, u2, u3, u4} C D _inst_1 _inst_5) -> (CategoryTheory.IsFiltered.{u2, u4} D _inst_5)\nCase conversion may be inaccurate. Consider using '#align category_theory.is_filtered.of_equivalence CategoryTheory.IsFiltered.of_equivalenceₓ'. -/\n/-- Being filtered is preserved by equivalence of categories. -/\ntheorem of_equivalence (h : C ≌ D) : IsFiltered D :=\n  of_right_adjoint h.symm.toAdjunction\n#align category_theory.is_filtered.of_equivalence CategoryTheory.IsFiltered.of_equivalence\n\nend Nonempty\n\nsection SpecialShapes\n\nvariable {C} [IsFilteredOrEmpty C]\n\n#print CategoryTheory.IsFiltered.max₃ /-\n/-- `max₃ j₁ j₂ j₃` is an arbitrary choice of object to the right of `j₁`, `j₂` and `j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def max₃ (j₁ j₂ j₃ : C) : C :=\n  max (max j₁ j₂) j₃\n#align category_theory.is_filtered.max₃ CategoryTheory.IsFiltered.max₃\n-/\n\n#print CategoryTheory.IsFiltered.firstToMax₃ /-\n/-- `first_to_max₃ j₁ j₂ j₃` is an arbitrary choice of morphism from `j₁` to `max₃ j₁ j₂ j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def firstToMax₃ (j₁ j₂ j₃ : C) : j₁ ⟶ max₃ j₁ j₂ j₃ :=\n  leftToMax j₁ j₂ ≫ leftToMax (max j₁ j₂) j₃\n#align category_theory.is_filtered.first_to_max₃ CategoryTheory.IsFiltered.firstToMax₃\n-/\n\n#print CategoryTheory.IsFiltered.secondToMax₃ /-\n/-- `second_to_max₃ j₁ j₂ j₃` is an arbitrary choice of morphism from `j₂` to `max₃ j₁ j₂ j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def secondToMax₃ (j₁ j₂ j₃ : C) : j₂ ⟶ max₃ j₁ j₂ j₃ :=\n  rightToMax j₁ j₂ ≫ leftToMax (max j₁ j₂) j₃\n#align category_theory.is_filtered.second_to_max₃ CategoryTheory.IsFiltered.secondToMax₃\n-/\n\n#print CategoryTheory.IsFiltered.thirdToMax₃ /-\n/-- `third_to_max₃ j₁ j₂ j₃` is an arbitrary choice of morphism from `j₃` to `max₃ j₁ j₂ j₃`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def thirdToMax₃ (j₁ j₂ j₃ : C) : j₃ ⟶ max₃ j₁ j₂ j₃ :=\n  rightToMax (max j₁ j₂) j₃\n#align category_theory.is_filtered.third_to_max₃ CategoryTheory.IsFiltered.thirdToMax₃\n-/\n\n#print CategoryTheory.IsFiltered.coeq₃ /-\n/-- `coeq₃ f g h`, for morphisms `f g h : j₁ ⟶ j₂`, is an arbitrary choice of object\nwhich admits a morphism `coeq₃_hom f g h : j₂ ⟶ coeq₃ f g h` such that\n`coeq₃_condition₁`, `coeq₃_condition₂` and `coeq₃_condition₃` are satisfied.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq₃ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : C :=\n  coeq (coeqHom f g ≫ leftToMax (coeq f g) (coeq g h))\n    (coeqHom g h ≫ rightToMax (coeq f g) (coeq g h))\n#align category_theory.is_filtered.coeq₃ CategoryTheory.IsFiltered.coeq₃\n-/\n\n#print CategoryTheory.IsFiltered.coeq₃Hom /-\n/-- `coeq₃_hom f g h`, for morphisms `f g h : j₁ ⟶ j₂`, is an arbitrary choice of morphism\n`j₂ ⟶ coeq₃ f g h` such that `coeq₃_condition₁`, `coeq₃_condition₂` and `coeq₃_condition₃`\nare satisfied. Its existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq₃Hom {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : j₂ ⟶ coeq₃ f g h :=\n  coeqHom f g ≫\n    leftToMax (coeq f g) (coeq g h) ≫\n      coeqHom (coeqHom f g ≫ leftToMax (coeq f g) (coeq g h))\n        (coeqHom g h ≫ rightToMax (coeq f g) (coeq g h))\n#align category_theory.is_filtered.coeq₃_hom CategoryTheory.IsFiltered.coeq₃Hom\n-/\n\n#print CategoryTheory.IsFiltered.coeq₃_condition₁ /-\ntheorem coeq₃_condition₁ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : f ≫ coeq₃Hom f g h = g ≫ coeq₃Hom f g h :=\n  by rw [coeq₃_hom, reassoc_of (coeq_condition f g)]\n#align category_theory.is_filtered.coeq₃_condition₁ CategoryTheory.IsFiltered.coeq₃_condition₁\n-/\n\n#print CategoryTheory.IsFiltered.coeq₃_condition₂ /-\ntheorem coeq₃_condition₂ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : g ≫ coeq₃Hom f g h = h ≫ coeq₃Hom f g h :=\n  by\n  dsimp [coeq₃_hom]\n  slice_lhs 2 4 => rw [← category.assoc, coeq_condition _ _]\n  slice_rhs 2 4 => rw [← category.assoc, coeq_condition _ _]\n  slice_lhs 1 3 => rw [← category.assoc, coeq_condition _ _]\n  simp only [category.assoc]\n#align category_theory.is_filtered.coeq₃_condition₂ CategoryTheory.IsFiltered.coeq₃_condition₂\n-/\n\n#print CategoryTheory.IsFiltered.coeq₃_condition₃ /-\ntheorem coeq₃_condition₃ {j₁ j₂ : C} (f g h : j₁ ⟶ j₂) : f ≫ coeq₃Hom f g h = h ≫ coeq₃Hom f g h :=\n  Eq.trans (coeq₃_condition₁ f g h) (coeq₃_condition₂ f g h)\n#align category_theory.is_filtered.coeq₃_condition₃ CategoryTheory.IsFiltered.coeq₃_condition₃\n-/\n\n#print CategoryTheory.IsFiltered.span /-\n/-- For every span `j ⟵ i ⟶ j'`, there\n   exists a cocone `j ⟶ k ⟵ j'` such that the square commutes. -/\ntheorem span {i j j' : C} (f : i ⟶ j) (f' : i ⟶ j') :\n    ∃ (k : C)(g : j ⟶ k)(g' : j' ⟶ k), f ≫ g = f' ≫ g' :=\n  let ⟨K, G, G', _⟩ := cocone_objs j j'\n  let ⟨k, e, he⟩ := cocone_maps (f ≫ G) (f' ≫ G')\n  ⟨k, G ≫ e, G' ≫ e, by simpa only [← category.assoc] ⟩\n#align category_theory.is_filtered.span CategoryTheory.IsFiltered.span\n-/\n\n#print CategoryTheory.IsFiltered.bowtie /-\n/-- Given a \"bowtie\" of morphisms\n```\n j₁   j₂\n |\\  /|\n | \\/ |\n | /\\ |\n |/  \\∣\n vv  vv\n k₁  k₂\n```\nin a filtered category, we can construct an object `s` and two morphisms from `k₁` and `k₂` to `s`,\nmaking the resulting squares commute.\n-/\ntheorem bowtie {j₁ j₂ k₁ k₂ : C} (f₁ : j₁ ⟶ k₁) (g₁ : j₁ ⟶ k₂) (f₂ : j₂ ⟶ k₁) (g₂ : j₂ ⟶ k₂) :\n    ∃ (s : C)(α : k₁ ⟶ s)(β : k₂ ⟶ s), f₁ ≫ α = g₁ ≫ β ∧ f₂ ≫ α = g₂ ≫ β :=\n  by\n  obtain ⟨t, k₁t, k₂t, ht⟩ := span f₁ g₁\n  obtain ⟨s, ts, hs⟩ := cocone_maps (f₂ ≫ k₁t) (g₂ ≫ k₂t)\n  simp_rw [category.assoc] at hs\n  exact ⟨s, k₁t ≫ ts, k₂t ≫ ts, by rw [reassoc_of ht], hs⟩\n#align category_theory.is_filtered.bowtie CategoryTheory.IsFiltered.bowtie\n-/\n\n#print CategoryTheory.IsFiltered.tulip /-\n/-- Given a \"tulip\" of morphisms\n```\n j₁    j₂    j₃\n |\\   / \\   / |\n | \\ /   \\ /  |\n |  vv    vv  |\n \\  k₁    k₂ /\n  \\         /\n   \\       /\n    \\     /\n     \\   /\n      v v\n       l\n```\nin a filtered category, we can construct an object `s` and three morphisms from `k₁`, `k₂` and `l`\nto `s`, making the resulting squares commute.\n-/\ntheorem tulip {j₁ j₂ j₃ k₁ k₂ l : C} (f₁ : j₁ ⟶ k₁) (f₂ : j₂ ⟶ k₁) (f₃ : j₂ ⟶ k₂) (f₄ : j₃ ⟶ k₂)\n    (g₁ : j₁ ⟶ l) (g₂ : j₃ ⟶ l) :\n    ∃ (s : C)(α : k₁ ⟶ s)(β : l ⟶ s)(γ : k₂ ⟶ s),\n      f₁ ≫ α = g₁ ≫ β ∧ f₂ ≫ α = f₃ ≫ γ ∧ f₄ ≫ γ = g₂ ≫ β :=\n  by\n  obtain ⟨l', k₁l, k₂l, hl⟩ := span f₂ f₃\n  obtain ⟨s, ls, l's, hs₁, hs₂⟩ := bowtie g₁ (f₁ ≫ k₁l) g₂ (f₄ ≫ k₂l)\n  refine' ⟨s, k₁l ≫ l's, ls, k₂l ≫ l's, _, by rw [reassoc_of hl], _⟩ <;>\n    simp only [hs₁, hs₂, category.assoc]\n#align category_theory.is_filtered.tulip CategoryTheory.IsFiltered.tulip\n-/\n\nend SpecialShapes\n\nend IsFiltered\n\n#print CategoryTheory.IsCofilteredOrEmpty /-\n/-- A category `is_cofiltered_or_empty` if\n1. for every pair of objects there exists another object \"to the left\", and\n2. for every pair of parallel morphisms there exists a morphism to the left so the compositions\n   are equal.\n-/\nclass IsCofilteredOrEmpty : Prop where\n  cone_objs : ∀ X Y : C, ∃ (W : _)(f : W ⟶ X)(g : W ⟶ Y), True\n  cone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (W : _)(h : W ⟶ X), h ≫ f = h ≫ g\n#align category_theory.is_cofiltered_or_empty CategoryTheory.IsCofilteredOrEmpty\n-/\n\n#print CategoryTheory.IsCofiltered /-\n/-- A category `is_cofiltered` if\n1. for every pair of objects there exists another object \"to the left\",\n2. for every pair of parallel morphisms there exists a morphism to the left so the compositions\n   are equal, and\n3. there exists some object.\n\nSee <https://stacks.math.columbia.edu/tag/04AZ>.\n-/\nclass IsCofiltered extends IsCofilteredOrEmpty C : Prop where\n  [Nonempty : Nonempty C]\n#align category_theory.is_cofiltered CategoryTheory.IsCofiltered\n-/\n\n#print CategoryTheory.isCofilteredOrEmpty_of_semilatticeInf /-\ninstance (priority := 100) isCofilteredOrEmpty_of_semilatticeInf (α : Type u) [SemilatticeInf α] :\n    IsCofilteredOrEmpty α\n    where\n  cone_objs X Y := ⟨X ⊓ Y, homOfLE inf_le_left, homOfLE inf_le_right, trivial⟩\n  cone_maps X Y f g := ⟨X, 𝟙 _, by ext⟩\n#align category_theory.is_cofiltered_or_empty_of_semilattice_inf CategoryTheory.isCofilteredOrEmpty_of_semilatticeInf\n-/\n\n#print CategoryTheory.isCofiltered_of_semilatticeInf_nonempty /-\ninstance (priority := 100) isCofiltered_of_semilatticeInf_nonempty (α : Type u) [SemilatticeInf α]\n    [Nonempty α] : IsCofiltered α where\n#align category_theory.is_cofiltered_of_semilattice_inf_nonempty CategoryTheory.isCofiltered_of_semilatticeInf_nonempty\n-/\n\n#print CategoryTheory.isCofilteredOrEmpty_of_directed_ge /-\ninstance (priority := 100) isCofilteredOrEmpty_of_directed_ge (α : Type u) [Preorder α]\n    [IsDirected α (· ≥ ·)] : IsCofilteredOrEmpty α\n    where\n  cone_objs X Y :=\n    let ⟨Z, hX, hY⟩ := exists_le_le X Y\n    ⟨Z, homOfLE hX, homOfLE hY, trivial⟩\n  cone_maps X Y f g := ⟨X, 𝟙 _, by simp⟩\n#align category_theory.is_cofiltered_or_empty_of_directed_ge CategoryTheory.isCofilteredOrEmpty_of_directed_ge\n-/\n\n#print CategoryTheory.isCofiltered_of_directed_ge_nonempty /-\ninstance (priority := 100) isCofiltered_of_directed_ge_nonempty (α : Type u) [Preorder α]\n    [IsDirected α (· ≥ ·)] [Nonempty α] : IsCofiltered α where\n#align category_theory.is_cofiltered_of_directed_ge_nonempty CategoryTheory.isCofiltered_of_directed_ge_nonempty\n-/\n\n-- Sanity checks\nexample (α : Type u) [SemilatticeInf α] [OrderBot α] : IsCofiltered α := by infer_instance\n\nexample (α : Type u) [SemilatticeInf α] [OrderTop α] : IsCofiltered α := by infer_instance\n\ninstance : IsCofiltered (Discrete PUnit)\n    where\n  cone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by decide⟩⟩, ⟨⟨by decide⟩⟩, trivial⟩\n  cone_maps X Y f g := ⟨⟨PUnit.unit⟩, ⟨⟨by decide⟩⟩, by decide⟩\n  Nonempty := ⟨⟨PUnit.unit⟩⟩\n\nnamespace IsCofiltered\n\nsection AllowEmpty\n\nvariable {C} [IsCofilteredOrEmpty C]\n\ntheorem cone_objs : ∀ X Y : C, ∃ (W : _)(f : W ⟶ X)(g : W ⟶ Y), True :=\n  IsCofilteredOrEmpty.cone_objs\n#align category_theory.is_cofiltered.cone_objs CategoryTheory.IsCofiltered.cone_objs\n\ntheorem cone_maps : ∀ ⦃X Y : C⦄ (f g : X ⟶ Y), ∃ (W : _)(h : W ⟶ X), h ≫ f = h ≫ g :=\n  IsCofilteredOrEmpty.cone_maps\n#align category_theory.is_cofiltered.cone_maps CategoryTheory.IsCofiltered.cone_maps\n\n#print CategoryTheory.IsCofiltered.min /-\n/-- `min j j'` is an arbitrary choice of object to the left of both `j` and `j'`,\nwhose existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def min (j j' : C) : C :=\n  (cone_objs j j').some\n#align category_theory.is_cofiltered.min CategoryTheory.IsCofiltered.min\n-/\n\n#print CategoryTheory.IsCofiltered.minToLeft /-\n/-- `min_to_left j j'` is an arbitrary choice of morphism from `min j j'` to `j`,\nwhose existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def minToLeft (j j' : C) : min j j' ⟶ j :=\n  (cone_objs j j').choose_spec.some\n#align category_theory.is_cofiltered.min_to_left CategoryTheory.IsCofiltered.minToLeft\n-/\n\n#print CategoryTheory.IsCofiltered.minToRight /-\n/-- `min_to_right j j'` is an arbitrary choice of morphism from `min j j'` to `j'`,\nwhose existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def minToRight (j j' : C) : min j j' ⟶ j' :=\n  (cone_objs j j').choose_spec.choose_spec.some\n#align category_theory.is_cofiltered.min_to_right CategoryTheory.IsCofiltered.minToRight\n-/\n\n#print CategoryTheory.IsCofiltered.eq /-\n/-- `eq f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of object\nwhich admits a morphism `eq_hom f f' : eq f f' ⟶ j` such that\n`eq_condition : eq_hom f f' ≫ f = eq_hom f f' ≫ f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eq {j j' : C} (f f' : j ⟶ j') : C :=\n  (cone_maps f f').some\n#align category_theory.is_cofiltered.eq CategoryTheory.IsCofiltered.eq\n-/\n\n#print CategoryTheory.IsCofiltered.eqHom /-\n/-- `eq_hom f f'`, for morphisms `f f' : j ⟶ j'`, is an arbitrary choice of morphism\n`eq_hom f f' : eq f f' ⟶ j` such that\n`eq_condition : eq_hom f f' ≫ f = eq_hom f f' ≫ f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eqHom {j j' : C} (f f' : j ⟶ j') : eq f f' ⟶ j :=\n  (cone_maps f f').choose_spec.some\n#align category_theory.is_cofiltered.eq_hom CategoryTheory.IsCofiltered.eqHom\n-/\n\n#print CategoryTheory.IsCofiltered.eq_condition /-\n/-- `eq_condition f f'`, for morphisms `f f' : j ⟶ j'`, is the proof that\n`eq_hom f f' ≫ f = eq_hom f f' ≫ f'`.\n-/\n@[simp, reassoc.1]\ntheorem eq_condition {j j' : C} (f f' : j ⟶ j') : eqHom f f' ≫ f = eqHom f f' ≫ f' :=\n  (cone_maps f f').choose_spec.choose_spec\n#align category_theory.is_cofiltered.eq_condition CategoryTheory.IsCofiltered.eq_condition\n-/\n\n#print CategoryTheory.IsCofiltered.cospan /-\n/-- For every cospan `j ⟶ i ⟵ j'`,\n there exists a cone `j ⟵ k ⟶ j'` such that the square commutes. -/\ntheorem cospan {i j j' : C} (f : j ⟶ i) (f' : j' ⟶ i) :\n    ∃ (k : C)(g : k ⟶ j)(g' : k ⟶ j'), g ≫ f = g' ≫ f' :=\n  let ⟨K, G, G', _⟩ := cone_objs j j'\n  let ⟨k, e, he⟩ := cone_maps (G ≫ f) (G' ≫ f')\n  ⟨k, e ≫ G, e ≫ G', by simpa only [category.assoc] using he⟩\n#align category_theory.is_cofiltered.cospan CategoryTheory.IsCofiltered.cospan\n-/\n\n/- warning: category_theory.functor.ranges_directed -> CategoryTheory.Functor.ranges_directed is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u1, u2} C] [_inst_2 : CategoryTheory.IsCofilteredOrEmpty.{u1, u2} C _inst_1] (F : CategoryTheory.Functor.{u1, u3, u2, succ u3} C _inst_1 Type.{u3} CategoryTheory.types.{u3}) (j : C), Directed.{u3, max 1 (succ u2) (succ u1)} (Set.{u3} (CategoryTheory.Functor.obj.{u1, u3, u2, succ u3} C _inst_1 Type.{u3} CategoryTheory.types.{u3} F j)) (PSigma.{succ u2, succ u1} C (fun (i : C) => Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) i j)) (Superset.{u3} (Set.{u3} (CategoryTheory.Functor.obj.{u1, u3, u2, succ u3} C _inst_1 Type.{u3} CategoryTheory.types.{u3} F j)) (Set.hasSubset.{u3} (CategoryTheory.Functor.obj.{u1, u3, u2, succ u3} C _inst_1 Type.{u3} CategoryTheory.types.{u3} F j))) (fun (f : PSigma.{succ u2, succ u1} C (fun (i : C) => Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) i j)) => Set.range.{u3, succ u3} (CategoryTheory.Functor.obj.{u1, u3, u2, succ u3} C _inst_1 Type.{u3} CategoryTheory.types.{u3} F j) (CategoryTheory.Functor.obj.{u1, u3, u2, succ u3} C _inst_1 Type.{u3} CategoryTheory.types.{u3} F (PSigma.fst.{succ u2, succ u1} C (fun (i : C) => Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) i j) f)) (CategoryTheory.Functor.map.{u1, u3, u2, succ u3} C _inst_1 Type.{u3} CategoryTheory.types.{u3} F (PSigma.fst.{succ u2, succ u1} C (fun (i : C) => Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) i j) f) j (PSigma.snd.{succ u2, succ u1} C (fun (i : C) => Quiver.Hom.{succ u1, u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_1)) i j) f)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u2, u3} C] [_inst_2 : CategoryTheory.IsCofilteredOrEmpty.{u2, u3} C _inst_1] (F : CategoryTheory.Functor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1}) (j : C), Directed.{u1, max (succ u3) (succ u2)} (Set.{u1} (Prefunctor.obj.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) j)) (PSigma.{succ u3, succ u2} C (fun (i : C) => Quiver.Hom.{succ u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) i j)) (fun (x._@.Mathlib.CategoryTheory.Filtered._hyg.4398 : Set.{u1} (Prefunctor.obj.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) j)) (x._@.Mathlib.CategoryTheory.Filtered._hyg.4400 : Set.{u1} (Prefunctor.obj.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) j)) => Superset.{u1} (Set.{u1} (Prefunctor.obj.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) j)) (Set.instHasSubsetSet.{u1} (Prefunctor.obj.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) j)) x._@.Mathlib.CategoryTheory.Filtered._hyg.4398 x._@.Mathlib.CategoryTheory.Filtered._hyg.4400) (fun (f : PSigma.{succ u3, succ u2} C (fun (i : C) => Quiver.Hom.{succ u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) i j)) => Set.range.{u1, succ u1} (Prefunctor.obj.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) j) (Prefunctor.obj.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) (PSigma.fst.{succ u3, succ u2} C (fun (i : C) => Quiver.Hom.{succ u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) i j) f)) (Prefunctor.map.{succ u2, succ u1, u3, succ u1} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) Type.{u1} (CategoryTheory.CategoryStruct.toQuiver.{u1, succ u1} Type.{u1} (CategoryTheory.Category.toCategoryStruct.{u1, succ u1} Type.{u1} CategoryTheory.types.{u1})) (CategoryTheory.Functor.toPrefunctor.{u2, u1, u3, succ u1} C _inst_1 Type.{u1} CategoryTheory.types.{u1} F) (PSigma.fst.{succ u3, succ u2} C (fun (i : C) => Quiver.Hom.{succ u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) i j) f) j (PSigma.snd.{succ u3, succ u2} C (fun (i : C) => Quiver.Hom.{succ u2, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u3} C (CategoryTheory.Category.toCategoryStruct.{u2, u3} C _inst_1)) i j) f)))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.ranges_directed CategoryTheory.Functor.ranges_directedₓ'. -/\ntheorem CategoryTheory.Functor.ranges_directed (F : C ⥤ Type _) (j : C) :\n    Directed (· ⊇ ·) fun f : Σ'i, i ⟶ j => Set.range (F.map f.2) := fun ⟨i, ij⟩ ⟨k, kj⟩ =>\n  by\n  let ⟨l, li, lk, e⟩ := cospan ij kj\n  refine' ⟨⟨l, lk ≫ kj⟩, e ▸ _, _⟩ <;> simp_rw [F.map_comp] <;> apply Set.range_comp_subset_range\n#align category_theory.functor.ranges_directed CategoryTheory.Functor.ranges_directed\n\nend AllowEmpty\n\nsection Nonempty\n\nopen CategoryTheory.Limits\n\nvariable {C} [IsCofiltered C]\n\n#print CategoryTheory.IsCofiltered.inf_objs_exists /-\n/-- Any finite collection of objects in a cofiltered category has an object \"to the left\".\n-/\ntheorem inf_objs_exists (O : Finset C) : ∃ S : C, ∀ {X}, X ∈ O → Nonempty (S ⟶ X) := by\n  classical\n    apply Finset.induction_on O\n    · exact ⟨is_cofiltered.nonempty.some, by rintro - ⟨⟩⟩\n    · rintro X O' nm ⟨S', w'⟩\n      use min X S'\n      rintro Y mY\n      obtain rfl | h := eq_or_ne Y X\n      · exact ⟨min_to_left _ _⟩\n      · exact ⟨min_to_right _ _ ≫ (w' (Finset.mem_of_mem_insert_of_ne mY h)).some⟩\n#align category_theory.is_cofiltered.inf_objs_exists CategoryTheory.IsCofiltered.inf_objs_exists\n-/\n\nvariable (O : Finset C) (H : Finset (Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y))\n\n#print CategoryTheory.IsCofiltered.inf_exists /-\n/-- Given any `finset` of objects `{X, ...}` and\nindexed collection of `finset`s of morphisms `{f, ...}` in `C`,\nthere exists an object `S`, with a morphism `T X : S ⟶ X` from each `X`,\nsuch that the triangles commute: `T X ≫ f = T Y`, for `f : X ⟶ Y` in the `finset`.\n-/\ntheorem inf_exists :\n    ∃ (S : C)(T : ∀ {X : C}, X ∈ O → (S ⟶ X)),\n      ∀ {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y},\n        (⟨X, Y, mX, mY, f⟩ : Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y) ∈ H → T mX ≫ f = T mY :=\n  by\n  classical\n    apply Finset.induction_on H\n    · obtain ⟨S, f⟩ := inf_objs_exists O\n      refine' ⟨S, fun X mX => (f mX).some, _⟩\n      rintro - - - - - ⟨⟩\n    · rintro ⟨X, Y, mX, mY, f⟩ H' nmf ⟨S', T', w'⟩\n      refine' ⟨Eq (T' mX ≫ f) (T' mY), fun Z mZ => eq_hom (T' mX ≫ f) (T' mY) ≫ T' mZ, _⟩\n      intro X' Y' mX' mY' f' mf'\n      rw [category.assoc]\n      by_cases h : X = X' ∧ Y = Y'\n      · rcases h with ⟨rfl, rfl⟩\n        by_cases hf : f = f'\n        · subst hf\n          apply eq_condition\n        · rw [@w' _ _ mX mY f' (by simpa [hf ∘ Eq.symm] using mf')]\n      · rw [@w' _ _ mX' mY' f' _]\n        apply Finset.mem_of_mem_insert_of_ne mf'\n        contrapose! h\n        obtain ⟨rfl, h⟩ := h\n        rw [heq_iff_eq, PSigma.mk.inj_iff] at h\n        exact ⟨rfl, h.1.symm⟩\n#align category_theory.is_cofiltered.inf_exists CategoryTheory.IsCofiltered.inf_exists\n-/\n\n#print CategoryTheory.IsCofiltered.inf /-\n/-- An arbitrary choice of object \"to the left\"\nof a finite collection of objects `O` and morphisms `H`,\nmaking all the triangles commute.\n-/\nnoncomputable def inf : C :=\n  (inf_exists O H).some\n#align category_theory.is_cofiltered.inf CategoryTheory.IsCofiltered.inf\n-/\n\n#print CategoryTheory.IsCofiltered.infTo /-\n/-- The morphisms from `inf O H`.\n-/\nnoncomputable def infTo {X : C} (m : X ∈ O) : inf O H ⟶ X :=\n  (inf_exists O H).choose_spec.some m\n#align category_theory.is_cofiltered.inf_to CategoryTheory.IsCofiltered.infTo\n-/\n\n#print CategoryTheory.IsCofiltered.infTo_commutes /-\n/-- The triangles consisting of a morphism in `H` and the maps from `inf O H` commute.\n-/\ntheorem infTo_commutes {X Y : C} (mX : X ∈ O) (mY : Y ∈ O) {f : X ⟶ Y}\n    (mf : (⟨X, Y, mX, mY, f⟩ : Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y) ∈ H) :\n    infTo O H mX ≫ f = infTo O H mY :=\n  (inf_exists O H).choose_spec.choose_spec mX mY mf\n#align category_theory.is_cofiltered.inf_to_commutes CategoryTheory.IsCofiltered.infTo_commutes\n-/\n\nvariable {J : Type w} [SmallCategory J] [FinCategory J]\n\n#print CategoryTheory.IsCofiltered.cone_nonempty /-\n/-- If we have `is_cofiltered C`, then for any functor `F : J ⥤ C` with `fin_category J`,\nthere exists a cone over `F`.\n-/\ntheorem cone_nonempty (F : J ⥤ C) : Nonempty (Cone F) := by\n  classical\n    let O := finset.univ.image F.obj\n    let H : Finset (Σ'(X Y : C)(mX : X ∈ O)(mY : Y ∈ O), X ⟶ Y) :=\n      finset.univ.bUnion fun X : J =>\n        finset.univ.bUnion fun Y : J =>\n          finset.univ.image fun f : X ⟶ Y => ⟨F.obj X, F.obj Y, by simp, by simp, F.map f⟩\n    obtain ⟨Z, f, w⟩ := inf_exists O H\n    refine' ⟨⟨Z, ⟨fun X => f (by simp), _⟩⟩⟩\n    intro j j' g\n    dsimp\n    simp only [category.id_comp]\n    symm\n    apply w\n    simp only [Finset.mem_univ, Finset.mem_bunionᵢ, exists_and_left, exists_prop_of_true,\n      Finset.mem_image]\n    exact ⟨j, rfl, j', g, by simp⟩\n#align category_theory.is_cofiltered.cone_nonempty CategoryTheory.IsCofiltered.cone_nonempty\n-/\n\n#print CategoryTheory.IsCofiltered.cone /-\n/-- An arbitrary choice of cone over `F : J ⥤ C`, for `fin_category J` and `is_cofiltered C`.\n-/\nnoncomputable def cone (F : J ⥤ C) : Cone F :=\n  (cone_nonempty F).some\n#align category_theory.is_cofiltered.cone CategoryTheory.IsCofiltered.cone\n-/\n\nvariable {D : Type u₁} [Category.{v₁} D]\n\n#print CategoryTheory.IsCofiltered.of_left_adjoint /-\n/-- If `C` is cofiltered, and we have a functor `L : C ⥤ D` with a right adjoint,\nthen `D` is cofiltered.\n-/\ntheorem of_left_adjoint {L : C ⥤ D} {R : D ⥤ C} (h : L ⊣ R) : IsCofiltered D :=\n  { cone_objs := fun X Y =>\n      ⟨L.obj (min (R.obj X) (R.obj Y)), (h.homEquiv _ X).symm (minToLeft _ _),\n        (h.homEquiv _ Y).symm (minToRight _ _), ⟨⟩⟩\n    cone_maps := fun X Y f g =>\n      ⟨L.obj (eq (R.map f) (R.map g)), (h.homEquiv _ _).symm (eqHom _ _), by\n        rw [← h.hom_equiv_naturality_right_symm, ← h.hom_equiv_naturality_right_symm, eq_condition]⟩\n    Nonempty := IsCofiltered.nonempty.map L.obj }\n#align category_theory.is_cofiltered.of_left_adjoint CategoryTheory.IsCofiltered.of_left_adjoint\n-/\n\n#print CategoryTheory.IsCofiltered.of_isLeftAdjoint /-\n/-- If `C` is cofiltered, and we have a left adjoint functor `L : C ⥤ D`, then `D` is cofiltered. -/\ntheorem of_isLeftAdjoint (L : C ⥤ D) [IsLeftAdjoint L] : IsCofiltered D :=\n  of_left_adjoint (Adjunction.ofLeftAdjoint L)\n#align category_theory.is_cofiltered.of_is_left_adjoint CategoryTheory.IsCofiltered.of_isLeftAdjoint\n-/\n\n/- warning: category_theory.is_cofiltered.of_equivalence -> CategoryTheory.IsCofiltered.of_equivalence is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.IsCofiltered.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_5 : CategoryTheory.Category.{u2, u4} D], (CategoryTheory.Equivalence.{u1, u2, u3, u4} C _inst_1 D _inst_5) -> (CategoryTheory.IsCofiltered.{u2, u4} D _inst_5)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] [_inst_2 : CategoryTheory.IsCofiltered.{u1, u3} C _inst_1] {D : Type.{u4}} [_inst_5 : CategoryTheory.Category.{u2, u4} D], (CategoryTheory.Equivalence.{u1, u2, u3, u4} C D _inst_1 _inst_5) -> (CategoryTheory.IsCofiltered.{u2, u4} D _inst_5)\nCase conversion may be inaccurate. Consider using '#align category_theory.is_cofiltered.of_equivalence CategoryTheory.IsCofiltered.of_equivalenceₓ'. -/\n/-- Being cofiltered is preserved by equivalence of categories. -/\ntheorem of_equivalence (h : C ≌ D) : IsCofiltered D :=\n  of_left_adjoint h.toAdjunction\n#align category_theory.is_cofiltered.of_equivalence CategoryTheory.IsCofiltered.of_equivalence\n\nend Nonempty\n\nend IsCofiltered\n\nsection Opposite\n\nopen Opposite\n\n#print CategoryTheory.isCofiltered_op_of_isFiltered /-\ninstance isCofiltered_op_of_isFiltered [IsFiltered C] : IsCofiltered Cᵒᵖ\n    where\n  cone_objs X Y :=\n    ⟨op (IsFiltered.max X.unop Y.unop), (IsFiltered.leftToMax _ _).op,\n      (IsFiltered.rightToMax _ _).op, trivial⟩\n  cone_maps X Y f g :=\n    ⟨op (IsFiltered.coeq f.unop g.unop), (IsFiltered.coeqHom _ _).op,\n      by\n      rw [show f = f.unop.op by simp, show g = g.unop.op by simp, ← op_comp, ← op_comp]\n      congr 1\n      exact is_filtered.coeq_condition f.unop g.unop⟩\n  Nonempty := ⟨op IsFiltered.nonempty.some⟩\n#align category_theory.is_cofiltered_op_of_is_filtered CategoryTheory.isCofiltered_op_of_isFiltered\n-/\n\n#print CategoryTheory.isFiltered_op_of_isCofiltered /-\ninstance isFiltered_op_of_isCofiltered [IsCofiltered C] : IsFiltered Cᵒᵖ\n    where\n  cocone_objs X Y :=\n    ⟨op (IsCofiltered.min X.unop Y.unop), (IsCofiltered.minToLeft X.unop Y.unop).op,\n      (IsCofiltered.minToRight X.unop Y.unop).op, trivial⟩\n  cocone_maps X Y f g :=\n    ⟨op (IsCofiltered.eq f.unop g.unop), (IsCofiltered.eqHom f.unop g.unop).op,\n      by\n      rw [show f = f.unop.op by simp, show g = g.unop.op by simp, ← op_comp, ← op_comp]\n      congr 1\n      exact is_cofiltered.eq_condition f.unop g.unop⟩\n  Nonempty := ⟨op IsCofiltered.nonempty.some⟩\n#align category_theory.is_filtered_op_of_is_cofiltered CategoryTheory.isFiltered_op_of_isCofiltered\n-/\n\nend Opposite\n\nsection ULift\n\ninstance [IsFiltered C] : IsFiltered (ULift.{u₂} C) :=\n  IsFiltered.of_equivalence ULift.equivalence\n\ninstance [IsCofiltered C] : IsCofiltered (ULift.{u₂} C) :=\n  IsCofiltered.of_equivalence ULift.equivalence\n\ninstance [IsFiltered C] : IsFiltered (ULiftHom C) :=\n  IsFiltered.of_equivalence ULiftHom.equiv\n\ninstance [IsCofiltered C] : IsCofiltered (ULiftHom C) :=\n  IsCofiltered.of_equivalence ULiftHom.equiv\n\ninstance [IsFiltered C] : IsFiltered (AsSmall C) :=\n  IsFiltered.of_equivalence AsSmall.equiv\n\ninstance [IsCofiltered C] : IsCofiltered (AsSmall C) :=\n  IsCofiltered.of_equivalence AsSmall.equiv\n\nend ULift\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Filtered.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.45628147419440546}}
{"text": "import M4R.Algebra.Ring.Semiring\n\nnamespace M4R\n\n  namespace NCRing\n    open Group NCSemiring\n\n    protected instance Product (α₁ : Type _) (α₂ : Type _) [NCRing α₁] [NCRing α₂] : NCRing (α₁ × α₂) where\n      toNeg := (Group.Product α₁ α₂).toNeg\n      add_neg := (Group.Product α₁ α₂).add_neg\n\n    protected instance multi_product {ι : Type _} (fι : ι → Type _) [∀ i, NCRing (fι i)] : NCRing (MultiProd fι) where\n      toNeg   := (Group.multi_product fι).toNeg\n      add_neg := (Group.multi_product fι).add_neg\n\n    theorem neg_mul [NCRing α] (a b : α) : -a * b = -(a * b) := by\n      rw [←add_right_cancel _ _ (a * b), neg_add, ←mul_distrib_right, neg_add, zero_mul]\n    theorem mul_neg [NCRing α] (a b : α) : a * -b = -(a * b) := by\n      rw [←add_right_cancel _ _ (a * b), neg_add, ←mul_distrib_left, neg_add, mul_zero]\n    theorem mul_neg_swap [NCRing α] (a b : α) : a * -b = -a * b := by\n      rw [mul_neg, neg_mul]\n\n    theorem neg_one_mul [NCRing α] (a : α) : -1 * a = -a := by\n      rw [neg_mul, one_mul]\n    theorem neg_one_mul_add [NCRing α] (a b : α) : -1 * (a + b) = -a + -b := by\n      rw [mul_distrib_left, neg_one_mul, neg_one_mul]\n    theorem neg_one_mul_add' [NCRing α] (a b : α) : -1 * (a + b) = -b + -a := by\n      rw [neg_one_mul, neg_add_distrib]\n\n    theorem sub_mul_distrib_left [NCRing α] (a b c : α) : a * (b - c) = a * b - a * c := by\n      rw [sub_def, mul_distrib_left, mul_neg]; rfl\n    theorem sub_mul_distrib_right [NCRing α] (a b c : α) : (a - b) * c = a * c - b * c := by\n      rw [sub_def, mul_distrib_right, neg_mul]; rfl\n\n    protected class constructor_ncr (α : Type _) extends Group.constructor_g α, One α, Mul α where\n      mul_one           : ∀ a : α, a * 1 = a\n      one_mul           : ∀ a : α, 1 * a = a\n      mul_assoc         : ∀ a b c : α, (a * b) * c = a * (b * c)\n      mul_distrib_left  : ∀ a b c : α, a * (b + c) = a * b + a * c\n      mul_distrib_right : ∀ a b c : α, (a + b) * c = a * c + b * c\n\n    protected def construct {α : Type _} (c : NCRing.constructor_ncr α) : NCRing α where\n      toNCSemiring := NCSemiring.construct\n        {\n          toconstructor_cm  := {\n            add_zero  := c.add_zero\n            add_assoc := c.add_assoc\n            add_comm  := fun a b => (Group.construct c.toconstructor_g).neg_inj (by\n              rw [(Group.construct c.toconstructor_g).neg_add_distrib]\n              have : ∀ a : α, -a = -1 * a := fun a => by\n                rw [←(Group.construct c.toconstructor_g).add_right_cancel _ _ a,\n                  (Group.construct c.toconstructor_g).neg_add]\n                conv => rhs rhs rw [←c.one_mul a]\n                rw [←c.mul_distrib_right, (Group.construct c.toconstructor_g).neg_add,\n                  ←(Group.construct c.toconstructor_g).add_right_cancel _ _ (0 * a),\n                  ←c.mul_distrib_right, c.add_zero, (Group.construct c.toconstructor_g).zero_add]\n              rw [this (b + a), c.mul_distrib_left, ←this, ←this])\n          }\n          mul_one           := c.mul_one\n          one_mul           := c.one_mul\n          mul_assoc         := c.mul_assoc\n          mul_distrib_left  := c.mul_distrib_left\n          mul_distrib_right := c.mul_distrib_right\n          mul_zero          := fun a => by\n            rw [←(Group.construct c.toconstructor_g).add_right_cancel _ _ (a * 0),\n              ←c.mul_distrib_left]\n            conv => rhs rw [(Group.construct c.toconstructor_g).zero_add]\n            rw [c.add_zero]\n          zero_mul          := fun a => by\n            rw [←(Group.construct c.toconstructor_g).add_right_cancel _ _ (0 * a),\n              ←c.mul_distrib_right]\n            conv => rhs rw [(Group.construct c.toconstructor_g).zero_add]\n            rw [c.add_zero]\n        }\n      toNeg := (Group.construct c.toconstructor_g).toNeg\n      add_neg := (Group.construct c.toconstructor_g).add_neg\n\n    protected def to_constructor (α : Type _) [NCRing α] : NCRing.constructor_ncr α where\n      toconstructor_g   := Group.to_constructor α\n      mul_one           := NCSemiring.mul_one\n      one_mul           := NCSemiring.one_mul\n      mul_assoc         := NCSemiring.mul_assoc\n      mul_distrib_left  := NCSemiring.mul_distrib_left\n      mul_distrib_right := NCSemiring.mul_distrib_right\n\n  end NCRing\n\n  namespace Ring\n    open NCSemiring\n\n    protected instance Product (α₁ : Type _) (α₂ : Type _) [Ring α₁] [Ring α₂] : Ring (α₁ × α₂) where\n      toNCRing := NCRing.Product α₁ α₂\n      mul_comm := (Semiring.Product α₁ α₂).mul_comm\n\n    protected instance multi_product {ι : Type _} (fι : ι → Type _) [∀ i, Ring (fι i)] : Ring (MultiProd fι) where\n      mul_comm := (Semiring.multi_product fι).mul_comm\n\n    def is_NonTrivial (α : Type _) [Ring α] : Prop := (1 : α) ≠ 0\n    def is_NonTrivial.toNonTrivialRing [Ring α] (h : is_NonTrivial α) : NonTrivialRing α where\n      toNonTrivial.one_neq_zero := h\n\n    protected class constructor_r (α : Type _) extends AbelianGroup.constructor_ab α, One α, Mul α where\n      mul_one           : ∀ a : α, a * 1 = a\n      mul_assoc         : ∀ a b c : α, (a * b) * c = a * (b * c)\n      mul_distrib_left  : ∀ a b c : α, a * (b + c) = a * b + a * c\n      mul_comm          : ∀ a b : α, a * b = b * a\n\n    protected def construct {α : Type _} (c : Ring.constructor_r α) : Ring α where\n      toNCRing := NCRing.construct\n        {\n          mul_one           := c.mul_one\n          one_mul           := fun a => by rw [c.mul_comm]; exact c.mul_one a\n          mul_assoc         := c.mul_assoc\n          mul_distrib_left  := c.mul_distrib_left\n          mul_distrib_right := fun a b _ => by rw [c.mul_comm, c.mul_comm a, c.mul_comm b]; exact c.mul_distrib_left _ _ _\n        }\n      mul_comm := c.mul_comm\n\n    protected def to_constructor (α : Type _) [Ring α] : Ring.constructor_r α where\n      toconstructor_ab  := AbelianGroup.to_constructor α\n      mul_one           := NCSemiring.mul_one\n      mul_assoc         := NCSemiring.mul_assoc\n      mul_distrib_left  := NCSemiring.mul_distrib_left\n      mul_comm          := Semiring.mul_comm\n\n  end Ring\n\n  theorem NonTrivialRing.to_is_NonTrivial [NonTrivialRing α] : Ring.is_NonTrivial α := NonTrivial.one_neq_zero\n\n  instance IntRing : NonTrivialRing Int where\n    toRing := Ring.construct\n      {\n        toconstructor_ab  := IntGroup.to_constructor\n        mul_one           := Int.mul_one\n        mul_assoc         := Int.mul_assoc\n        mul_distrib_left  := Int.mul_distrib_left\n        mul_comm          := Int.mul_comm\n      }\n    toNonTrivial := IntNonTrivial\n\nend M4R\n", "meta": {"author": "Hop311", "repo": "M4R", "sha": "ebd1b04af344f9737d290bf8b48b3cde35e9787b", "save_path": "github-repos/lean/Hop311-M4R", "path": "github-repos/lean/Hop311-M4R/M4R-ebd1b04af344f9737d290bf8b48b3cde35e9787b/M4R/Algebra/Ring/Ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4562764657809088}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.continuous_on\nimport Mathlib.group_theory.submonoid.basic\nimport Mathlib.algebra.group.prod\nimport Mathlib.algebra.pointwise\nimport Mathlib.PostPort\n\nuniverses u_5 l u_3 u_1 u_4 u_2 \n\nnamespace Mathlib\n\n/-!\n# Theory of topological monoids\n\nIn this file we define mixin classes `has_continuous_mul` and `has_continuous_add`. While in many\napplications the underlying type is a monoid (multiplicative or additive), we do not require this in\nthe definitions.\n-/\n\n/-- Basic hypothesis to talk about a topological additive monoid or a topological additive\nsemigroup. A topological additive monoid over `α`, for example, is obtained by requiring both the\ninstances `add_monoid α` and `has_continuous_add α`. -/\nclass has_continuous_add (M : Type u_5) [topological_space M] [Add M] \nwhere\n  continuous_add : continuous fun (p : M × M) => prod.fst p + prod.snd p\n\n/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.\nA topological monoid over `α`, for example, is obtained by requiring both the instances `monoid α`\nand `has_continuous_mul α`. -/\nclass has_continuous_mul (M : Type u_5) [topological_space M] [Mul M] \nwhere\n  continuous_mul : continuous fun (p : M × M) => prod.fst p * prod.snd p\n\ntheorem continuous_add {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] : continuous fun (p : M × M) => prod.fst p + prod.snd p :=\n  has_continuous_add.continuous_add\n\ntheorem continuous.mul {α : Type u_1} {M : Type u_3} [topological_space M] [Mul M] [has_continuous_mul M] [topological_space α] {f : α → M} {g : α → M} (hf : continuous f) (hg : continuous g) : continuous fun (x : α) => f x * g x :=\n  continuous.comp continuous_mul (continuous.prod_mk hf hg)\n\n-- should `to_additive` be doing this?\n\ntheorem continuous_add_left {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] (a : M) : continuous fun (b : M) => a + b :=\n  continuous.add continuous_const continuous_id\n\ntheorem continuous_add_right {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] (a : M) : continuous fun (b : M) => b + a :=\n  continuous.add continuous_id continuous_const\n\ntheorem continuous_on.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] [topological_space α] {f : α → M} {g : α → M} {s : set α} (hf : continuous_on f s) (hg : continuous_on g s) : continuous_on (fun (x : α) => f x + g x) s :=\n  continuous.comp_continuous_on continuous_add (continuous_on.prod hf hg)\n\ntheorem tendsto_add {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] {a : M} {b : M} : filter.tendsto (fun (p : M × M) => prod.fst p + prod.snd p) (nhds (a, b)) (nhds (a + b)) :=\n  iff.mp continuous_iff_continuous_at has_continuous_add.continuous_add (a, b)\n\ntheorem filter.tendsto.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] {f : α → M} {g : α → M} {x : filter α} {a : M} {b : M} (hf : filter.tendsto f x (nhds a)) (hg : filter.tendsto g x (nhds b)) : filter.tendsto (fun (x : α) => f x + g x) x (nhds (a + b)) :=\n  filter.tendsto.comp tendsto_add (filter.tendsto.prod_mk_nhds hf hg)\n\ntheorem tendsto.const_mul {α : Type u_1} {M : Type u_3} [topological_space M] [Mul M] [has_continuous_mul M] (b : M) {c : M} {f : α → M} {l : filter α} (h : filter.tendsto (fun (k : α) => f k) l (nhds c)) : filter.tendsto (fun (k : α) => b * f k) l (nhds (b * c)) :=\n  filter.tendsto.mul tendsto_const_nhds h\n\ntheorem tendsto.add_const {α : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] (b : M) {c : M} {f : α → M} {l : filter α} (h : filter.tendsto (fun (k : α) => f k) l (nhds c)) : filter.tendsto (fun (k : α) => f k + b) l (nhds (c + b)) :=\n  filter.tendsto.add h tendsto_const_nhds\n\ntheorem continuous_at.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] [topological_space α] {f : α → M} {g : α → M} {x : α} (hf : continuous_at f x) (hg : continuous_at g x) : continuous_at (fun (x : α) => f x + g x) x :=\n  filter.tendsto.add hf hg\n\ntheorem continuous_within_at.add {α : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] [topological_space α] {f : α → M} {g : α → M} {s : set α} {x : α} (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) : continuous_within_at (fun (x : α) => f x + g x) s x :=\n  filter.tendsto.add hf hg\n\nprotected instance prod.has_continuous_mul {M : Type u_3} {N : Type u_4} [topological_space M] [Mul M] [has_continuous_mul M] [topological_space N] [Mul N] [has_continuous_mul N] : has_continuous_mul (M × N) :=\n  has_continuous_mul.mk\n    (continuous.prod_mk\n      (continuous.mul (continuous.comp continuous_fst continuous_fst) (continuous.comp continuous_fst continuous_snd))\n      (continuous.mul (continuous.comp continuous_snd continuous_fst) (continuous.comp continuous_snd continuous_snd)))\n\nprotected instance has_continuous_mul_of_discrete_topology {N : Type u_4} [topological_space N] [Mul N] [discrete_topology N] : has_continuous_mul N :=\n  has_continuous_mul.mk continuous_of_discrete_topology\n\ntheorem has_continuous_mul.of_nhds_one {M : Type (max u_1 u_2)} [monoid M] [topological_space M] (hmul : filter.tendsto (function.uncurry Mul.mul) (filter.prod (nhds 1) (nhds 1)) (nhds 1)) (hleft : ∀ (x₀ : M), nhds x₀ = filter.map (fun (x : M) => x₀ * x) (nhds 1)) (hright : ∀ (x₀ : M), nhds x₀ = filter.map (fun (x : M) => x * x₀) (nhds 1)) : has_continuous_mul M := sorry\n\ntheorem has_continuous_mul_of_comm_of_nhds_one (M : Type (max u_1 u_2)) [comm_monoid M] [topological_space M] (hmul : filter.tendsto (function.uncurry Mul.mul) (filter.prod (nhds 1) (nhds 1)) (nhds 1)) (hleft : ∀ (x₀ : M), nhds x₀ = filter.map (fun (x : M) => x₀ * x) (nhds 1)) : has_continuous_mul M := sorry\n\ntheorem add_submonoid.top_closure_add_self_subset {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] (s : add_submonoid M) : closure ↑s + closure ↑s ⊆ closure ↑s := sorry\n\ntheorem submonoid.top_closure_mul_self_eq {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] (s : submonoid M) : closure ↑s * closure ↑s = closure ↑s := sorry\n\n/-- The (topological-space) closure of a submonoid of a space `M` with `has_continuous_mul` is\nitself a submonoid. -/\ndef add_submonoid.topological_closure {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] (s : add_submonoid M) : add_submonoid M :=\n  add_submonoid.mk (closure ↑s) sorry sorry\n\ntheorem submonoid.submonoid_topological_closure {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] (s : submonoid M) : s ≤ submonoid.topological_closure s :=\n  subset_closure\n\ntheorem submonoid.is_closed_topological_closure {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] (s : submonoid M) : is_closed ↑(submonoid.topological_closure s) := sorry\n\ntheorem submonoid.topological_closure_minimal {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] (s : submonoid M) {t : submonoid M} (h : s ≤ t) (ht : is_closed ↑t) : submonoid.topological_closure s ≤ t :=\n  closure_minimal h ht\n\ntheorem exists_open_nhds_zero_half {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] {s : set M} (hs : s ∈ nhds 0) : ∃ (V : set M), is_open V ∧ 0 ∈ V ∧ ∀ (v : M), v ∈ V → ∀ (w : M), w ∈ V → v + w ∈ s := sorry\n\ntheorem exists_nhds_zero_half {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] {s : set M} (hs : s ∈ nhds 0) : ∃ (V : set M), ∃ (H : V ∈ nhds 0), ∀ (v : M), v ∈ V → ∀ (w : M), w ∈ V → v + w ∈ s := sorry\n\ntheorem exists_nhds_one_split4 {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] {u : set M} (hu : u ∈ nhds 1) : ∃ (V : set M), ∃ (H : V ∈ nhds 1), ∀ {v w s t : M}, v ∈ V → w ∈ V → s ∈ V → t ∈ V → v * w * s * t ∈ u := sorry\n\n/-- Given a neighborhood `U` of `1` there is an open neighborhood `V` of `1`\nsuch that `VV ⊆ U`. -/\ntheorem exists_open_nhds_one_mul_subset {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] {U : set M} (hU : U ∈ nhds 1) : ∃ (V : set M), is_open V ∧ 1 ∈ V ∧ V * V ⊆ U := sorry\n\ntheorem tendsto_list_sum {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] {f : β → α → M} {x : filter α} {a : β → M} (l : List β) : (∀ (c : β), c ∈ l → filter.tendsto (f c) x (nhds (a c))) →\n  filter.tendsto (fun (b : α) => list.sum (list.map (fun (c : β) => f c b) l)) x (nhds (list.sum (list.map a l))) := sorry\n\ntheorem continuous_list_sum {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] [topological_space α] {f : β → α → M} (l : List β) (h : ∀ (c : β), c ∈ l → continuous (f c)) : continuous fun (a : α) => list.sum (list.map (fun (c : β) => f c a) l) :=\n  iff.mpr continuous_iff_continuous_at\n    fun (x : α) => tendsto_list_sum l fun (c : β) (hc : c ∈ l) => iff.mp continuous_iff_continuous_at (h c hc) x\n\n-- @[to_additive continuous_smul]\n\ntheorem continuous_pow {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] (n : ℕ) : continuous fun (a : M) => a ^ n := sorry\n\ntheorem continuous.pow {α : Type u_1} {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] {f : α → M} [topological_space α] (h : continuous f) (n : ℕ) : continuous fun (b : α) => f b ^ n :=\n  continuous.comp (continuous_pow n) h\n\ntheorem submonoid.mem_nhds_one {M : Type u_3} [topological_space M] [comm_monoid M] (S : submonoid M) (oS : is_open ↑S) : ↑S ∈ nhds 1 :=\n  mem_nhds_sets oS (submonoid.one_mem S)\n\ntheorem tendsto_multiset_prod {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M] [comm_monoid M] [has_continuous_mul M] {f : β → α → M} {x : filter α} {a : β → M} (s : multiset β) : (∀ (c : β), c ∈ s → filter.tendsto (f c) x (nhds (a c))) →\n  filter.tendsto (fun (b : α) => multiset.prod (multiset.map (fun (c : β) => f c b) s)) x\n    (nhds (multiset.prod (multiset.map a s))) := sorry\n\ntheorem tendsto_finset_sum {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M] [add_comm_monoid M] [has_continuous_add M] {f : β → α → M} {x : filter α} {a : β → M} (s : finset β) : (∀ (c : β), c ∈ s → filter.tendsto (f c) x (nhds (a c))) →\n  filter.tendsto (fun (b : α) => finset.sum s fun (c : β) => f c b) x (nhds (finset.sum s fun (c : β) => a c)) :=\n  tendsto_multiset_sum (finset.val s)\n\ntheorem continuous_multiset_prod {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M] [comm_monoid M] [has_continuous_mul M] [topological_space α] {f : β → α → M} (s : multiset β) : (∀ (c : β), c ∈ s → continuous (f c)) → continuous fun (a : α) => multiset.prod (multiset.map (fun (c : β) => f c a) s) := sorry\n\ntheorem continuous_finset_prod {α : Type u_1} {β : Type u_2} {M : Type u_3} [topological_space M] [comm_monoid M] [has_continuous_mul M] [topological_space α] {f : β → α → M} (s : finset β) : (∀ (c : β), c ∈ s → continuous (f c)) → continuous fun (a : α) => finset.prod s fun (c : β) => f c a :=\n  continuous_multiset_prod (finset.val s)\n\n-- should `to_additive` be doing this?\n\nprotected instance additive.has_continuous_add {M : Type u_1} [h : topological_space M] [Mul M] [has_continuous_mul M] : has_continuous_add (additive M) :=\n  has_continuous_add.mk continuous_mul\n\nprotected instance multiplicative.has_continuous_mul {M : Type u_1} [h : topological_space M] [Add M] [has_continuous_add M] : has_continuous_mul (multiplicative M) :=\n  has_continuous_mul.mk continuous_add\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/monoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.6619228625116081, "lm_q1q2_score": 0.4562671470079521}}
{"text": "/- THE CUBE CATEGORY -/\n\nuniverses v u\n\ninductive cmonad (α : Type u)   | ll {}  : cmonad\n                                | rr {}  : cmonad\n                                | dim {} : α → cmonad\nopen cmonad\n\ndef bool_to_cmonad {α : Type u} : bool → cmonad α\n| ff := ll\n| tt := rr\n\ninstance inst_bool_to_cmonad (α : Type u) : has_coe bool (cmonad α) :=\n⟨ bool_to_cmonad ⟩\n\n@[inline] def cmor (α β) := α → cmonad β\n\n@[inline] def cbind {α : Type u} {β : Type v} (x) (f : cmor α β) : cmonad β :=\nmatch x with\n| ll    := ll\n| rr    := rr\n| dim x := f x\nend\n\ndef cmap {α : Type u} {β : Type v} (f : α → β) (x : cmonad α) : cmonad β :=\nmatch x with\n| ll    := ll\n| rr    := rr\n| dim x := dim (f x)\nend\n\ninstance inst_cmonad : monad cmonad :=\n{ monad . pure := @dim, bind := @cbind }\n\ntheorem cbind_bool {α β : Type u} (b : bool) (f : cmor α β) : (↑b >>= f) = ↑b :=\nby cases b; reflexivity; reflexivity; reflexivity\n\ntheorem cbind_dim {α β : Type u} (a : α) (f : cmor α β) : (dim a >>= f) = f a :=\nrfl\n\ntheorem cbind_assoc {α β γ : Type u} (a : cmonad α) (f : cmor α β) (g : cmor β γ) :\n  ((a >>= f) >>= g) = (a >>= (λ x, f x >>= g)) :=\nbegin\n cases a with i, reflexivity, reflexivity,\n rw [cbind_dim, cbind_dim], \nend\n\n/- The identity cube map is just return is just dim -/\n\n/- Composition of cube maps -/\ndef ccomp {α β γ} (g : cmor β γ) (f : cmor α β) : cmor α γ :=\nλ x, do y <- f x,\n        g y\n\ninfixl ` ∘c `:90 := ccomp\n\n/- The monad laws for cmonad -/\ntheorem cid_left {α β} (f : cmor α β) (x : α) : (dim ∘c f) x = f x :=\nbegin\n  simp[ccomp],\n  exact  match (f x) with\n         | ll    := rfl\n         | rr    := rfl\n         | dim a := rfl\n         end\nend\n\ntheorem cid_right {α β} (f : cmor α β) (x : α) : (f ∘c dim) x = f x :=\nbegin\n  simp[ccomp],\n  exact rfl\nend\n\ntheorem ccomp_assoc {α β γ δ} (f : cmor α β) (g : cmor β γ) (h : cmor γ δ) (x) :\n    ((h ∘c g) ∘c f) x = (h ∘c (g ∘c f)) x :=\nbegin\n  simp[ccomp],\n  exact match (f x) with\n        | ll    := rfl\n        | rr    := rfl\n        | dim x := rfl\n        end\nend\n\n/- TODO Instantiate cmonad as internal category -/\n\ndef is_strict {α β} (f : cmor α β) : Prop := ∀ a, ∃ x, f a = dim x\n", "meta": {"author": "javra", "repo": "cubes", "sha": "734bdf71b9086b0ba9ef7dba3ede0c71f10872cc", "save_path": "github-repos/lean/javra-cubes", "path": "github-repos/lean/javra-cubes/cubes-734bdf71b9086b0ba9ef7dba3ede0c71f10872cc/cubes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4561759230083187}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monoidal.functor\nimport Mathlib.category_theory.functorial\nimport Mathlib.PostPort\n\nuniverses v₁ v₂ u₁ u₂ l \n\nnamespace Mathlib\n\n/-!\n# Unbundled lax monoidal functors\n\n## Design considerations\nThe essential problem I've encountered that requires unbundled functors is\nhaving an existing (non-monoidal) functor `F : C ⥤ D` between monoidal categories,\nand wanting to assert that it has an extension to a lax monoidal functor.\n\nThe two options seem to be\n1. Construct a separate `F' : lax_monoidal_functor C D`,\n   and assert `F'.to_functor ≅ F`.\n2. Introduce unbundled functors and unbundled lax monoidal functors,\n   and construct `lax_monoidal F.obj`, then construct `F' := lax_monoidal_functor.of F.obj`.\n\nBoth have costs, but as for option 2. the cost is in library design,\nwhile in option 1. the cost is users having to carry around additional isomorphisms forever,\nI wanted to introduce unbundled functors.\n\nTODO:\nlater, we may want to do this for strong monoidal functors as well,\nbut the immediate application, for enriched categories, only requires this notion.\n-/\n\nnamespace category_theory\n\n\n/-- An unbundled description of lax monoidal functors. -/\n-- Perhaps in the future we'll redefine `lax_monoidal_functor` in terms of this,\n\n-- but that isn't the immediate plan.\n\n-- unit morphism\n\nclass lax_monoidal {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂} [category D]\n    [monoidal_category D] (F : C → D) [functorial F]\n    where\n  ε : 𝟙_ ⟶ F 𝟙_\n  μ : (X Y : C) → F X ⊗ F Y ⟶ F (X ⊗ Y)\n  μ_natural' :\n    autoParam\n      (∀ {X Y X' Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y'),\n        (map F f ⊗ map F g) ≫ μ Y Y' = μ X X' ≫ map F (f ⊗ g))\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  associativity' :\n    autoParam\n      (∀ (X Y Z : C),\n        (μ X Y ⊗ 𝟙) ≫ μ (X ⊗ Y) Z ≫ map F (iso.hom α_) = iso.hom α_ ≫ (𝟙 ⊗ μ Y Z) ≫ μ X (Y ⊗ Z))\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  left_unitality' :\n    autoParam (∀ (X : C), iso.hom λ_ = (ε ⊗ 𝟙) ≫ μ 𝟙_ X ≫ map F (iso.hom λ_))\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n  right_unitality' :\n    autoParam (∀ (X : C), iso.hom ρ_ = (𝟙 ⊗ ε) ≫ μ X 𝟙_ ≫ map F (iso.hom ρ_))\n      (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.obviously\")\n        (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"obviously\") [])\n\n-- tensorator\n\n-- associativity of the tensorator\n\n-- unitality\n\n@[simp] theorem lax_monoidal.μ_natural {C : Type u₁} [category C] [monoidal_category C]\n    {D : Type u₂} [category D] [monoidal_category D] {F : C → D} [functorial F] [c : lax_monoidal F]\n    {X : C} {Y : C} {X' : C} {Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') :\n    (map F f ⊗ map F g) ≫ lax_monoidal.μ F Y Y' = lax_monoidal.μ F X X' ≫ map F (f ⊗ g) :=\n  sorry\n\ntheorem lax_monoidal.left_unitality {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂}\n    [category D] [monoidal_category D] {F : C → D} [functorial F] [c : lax_monoidal F] (X : C) :\n    iso.hom λ_ = (lax_monoidal.ε F ⊗ 𝟙) ≫ lax_monoidal.μ F 𝟙_ X ≫ map F (iso.hom λ_) :=\n  sorry\n\n-- The unitality axioms cannot be used as simp lemmas because they require\n\ntheorem lax_monoidal.right_unitality {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂}\n    [category D] [monoidal_category D] {F : C → D} [functorial F] [c : lax_monoidal F] (X : C) :\n    iso.hom ρ_ = (𝟙 ⊗ lax_monoidal.ε F) ≫ lax_monoidal.μ F X 𝟙_ ≫ map F (iso.hom ρ_) :=\n  sorry\n\n-- higher-order matching to figure out the `F` and `X` from `F X`.\n\n@[simp] theorem lax_monoidal.associativity {C : Type u₁} [category C] [monoidal_category C]\n    {D : Type u₂} [category D] [monoidal_category D] {F : C → D} [functorial F] [c : lax_monoidal F]\n    (X : C) (Y : C) (Z : C) :\n    (lax_monoidal.μ F X Y ⊗ 𝟙) ≫ lax_monoidal.μ F (X ⊗ Y) Z ≫ map F (iso.hom α_) =\n        iso.hom α_ ≫ (𝟙 ⊗ lax_monoidal.μ F Y Z) ≫ lax_monoidal.μ F X (Y ⊗ Z) :=\n  sorry\n\nnamespace lax_monoidal_functor\n\n\n/--\nConstruct a bundled `lax_monoidal_functor` from the object level function\nand `functorial` and `lax_monoidal` typeclasses.\n-/\n@[simp] theorem of_μ {C : Type u₁} [category C] [monoidal_category C] {D : Type u₂} [category D]\n    [monoidal_category D] (F : C → D) [I₁ : functorial F] [I₂ : lax_monoidal F] (X : C) (Y : C) :\n    μ (of F) X Y = lax_monoidal.μ F X Y :=\n  Eq.refl (μ (of F) X Y)\n\nend lax_monoidal_functor\n\n\nprotected instance lax_monoidal_functor.obj.lax_monoidal {C : Type u₁} [category C]\n    [monoidal_category C] {D : Type u₂} [category D] [monoidal_category D]\n    (F : lax_monoidal_functor C D) :\n    lax_monoidal (functor.obj (lax_monoidal_functor.to_functor F)) :=\n  lax_monoidal.mk (lax_monoidal_functor.ε F) (lax_monoidal_functor.μ F)\n\nprotected instance lax_monoidal_id {C : Type u₁} [category C] [monoidal_category C] :\n    lax_monoidal id :=\n  lax_monoidal.mk 𝟙 fun (X Y : C) => 𝟙\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monoidal/functorial_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45614373580808737}}
{"text": "/-\nCopyright (c) 2021 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport measure_theory.covering.differentiation\nimport measure_theory.covering.vitali_family\nimport measure_theory.integral.lebesgue\nimport measure_theory.measure.regular\nimport set_theory.ordinal.arithmetic\nimport topology.metric_space.basic\n\n/-!\n# Besicovitch covering theorems\n\nThe topological Besicovitch covering theorem ensures that, in a nice metric space, there exists a\nnumber `N` such that, from any family of balls with bounded radii, one can extract `N` families,\neach made of disjoint balls, covering together all the centers of the initial family.\n\nBy \"nice metric space\", we mean a technical property stated as follows: there exists no satellite\nconfiguration of `N + 1` points (with a given parameter `τ > 1`). Such a configuration is a family\nof `N + 1` balls, where the first `N` balls all intersect the last one, but none of them contains\nthe center of another one and their radii are controlled. This property is for instance\nsatisfied by finite-dimensional real vector spaces.\n\nIn this file, we prove the topological Besicovitch covering theorem,\nin `besicovitch.exist_disjoint_covering_families`.\n\nThe measurable Besicovitch theorem ensures that, in the same class of metric spaces, if at every\npoint one considers a class of balls of arbitrarily small radii, called admissible balls, then\none can cover almost all the space by a family of disjoint admissible balls.\nIt is deduced from the topological Besicovitch theorem, and proved\nin `besicovitch.exists_disjoint_closed_ball_covering_ae`.\n\nThis implies that balls of small radius form a Vitali family in such spaces. Therefore, theorems\non differentiation of measures hold as a consequence of general results. We restate them in this\ncontext to make them more easily usable.\n\n## Main definitions and results\n\n* `satellite_config α N τ` is the type of all satellite configurations of `N + 1` points\n  in the metric space `α`, with parameter `τ`.\n* `has_besicovitch_covering` is a class recording that there exist `N` and `τ > 1` such that\n  there is no satellite configuration of `N + 1` points with parameter `τ`.\n* `exist_disjoint_covering_families` is the topological Besicovitch covering theorem: from any\n  family of balls one can extract finitely many disjoint subfamilies covering the same set.\n* `exists_disjoint_closed_ball_covering` is the measurable Besicovitch covering theorem: from any\n  family of balls with arbitrarily small radii at every point, one can extract countably many\n  disjoint balls covering almost all the space. While the value of `N` is relevant for the precise\n  statement of the topological Besicovitch theorem, it becomes irrelevant for the measurable one.\n  Therefore, this statement is expressed using the `Prop`-valued\n  typeclass `has_besicovitch_covering`.\n\nWe also restate the following specialized versions of general theorems on differentiation of\nmeasures:\n* `besicovitch.ae_tendsto_rn_deriv` ensures that `ρ (closed_ball x r) / μ (closed_ball x r)` tends\n  almost surely to the Radon-Nikodym derivative of `ρ` with respect to `μ` at `x`.\n* `besicovitch.ae_tendsto_measure_inter_div` states that almost every point in an arbitrary set `s`\n  is a Lebesgue density point, i.e., `μ (s ∩ closed_ball x r) / μ (closed_ball x r)` tends to `1` as\n  `r` tends to `0`. A stronger version for measurable sets is given in\n  `besicovitch.ae_tendsto_measure_inter_div_of_measurable_set`.\n\n## Implementation\n\n#### Sketch of proof of the topological Besicovitch theorem:\n\nWe choose balls in a greedy way. First choose a ball with maximal radius (or rather, since there\nis no guarantee the maximal radius is realized, a ball with radius within a factor `τ` of the\nsupremum). Then, remove all balls whose center is covered by the first ball, and choose among the\nremaining ones a ball with radius close to maximum. Go on forever until there is no available\ncenter (this is a transfinite induction in general).\n\nThen define inductively a coloring of the balls. A ball will be of color `i` if it intersects\nalready chosen balls of color `0`, ..., `i - 1`, but none of color `i`. In this way, balls of the\nsame color form a disjoint family, and the space is covered by the families of the different colors.\n\nThe nontrivial part is to show that at most `N` colors are used. If one needs `N + 1` colors,\nconsider the first time this happens. Then the corresponding ball intersects `N` balls of the\ndifferent colors. Moreover, the inductive construction ensures that the radii of all the balls are\ncontrolled: they form a satellite configuration with `N + 1` balls (essentially by definition of\nsatellite configurations). Since we assume that there are no such configurations, this is a\ncontradiction.\n\n#### Sketch of proof of the measurable Besicovitch theorem:\n\nFrom the topological Besicovitch theorem, one can find a disjoint countable family of balls\ncovering a proportion `> 1 / (N + 1)` of the space. Taking a large enough finite subset of these\nballs, one gets the same property for finitely many balls. Their union is closed. Therefore, any\npoint in the complement has around it an admissible ball not intersecting these finitely many balls.\nApplying again the topological Besicovitch theorem, one extracts from these a disjoint countable\nsubfamily covering a proportion `> 1 / (N + 1)` of the remaining points, and then even a disjoint\nfinite subfamily. Then one goes on again and again, covering at each step a positive proportion of\nthe remaining points, while remaining disjoint from the already chosen balls. The union of all these\nballs is the desired almost everywhere covering.\n-/\n\nnoncomputable theory\n\nuniverse u\n\nopen metric set filter fin measure_theory topological_space\nopen_locale topology classical big_operators ennreal measure_theory nnreal\n\n\n/-!\n### Satellite configurations\n-/\n\n/-- A satellite configuration is a configuration of `N+1` points that shows up in the inductive\nconstruction for the Besicovitch covering theorem. It depends on some parameter `τ ≥ 1`.\n\nThis is a family of balls (indexed by `i : fin N.succ`, with center `c i` and radius `r i`) such\nthat the last ball intersects all the other balls (condition `inter`),\nand given any two balls there is an order between them, ensuring that the first ball does not\ncontain the center of the other one, and the radius of the second ball can not be larger than\nthe radius of the first ball (up to a factor `τ`). This order corresponds to the order of choice\nin the inductive construction: otherwise, the second ball would have been chosen before.\nThis is the condition `h`.\n\nFinally, the last ball is chosen after all the other ones, meaning that `h` can be strengthened\nby keeping only one side of the alternative in `hlast`.\n-/\nstructure besicovitch.satellite_config (α : Type*) [metric_space α] (N : ℕ) (τ : ℝ) :=\n(c : fin N.succ → α)\n(r : fin N.succ → ℝ)\n(rpos : ∀ i, 0 < r i)\n(h : ∀ i j, i ≠ j → (r i ≤ dist (c i) (c j) ∧ r j ≤ τ * r i) ∨\n                    (r j ≤ dist (c j) (c i) ∧ r i ≤ τ * r j))\n(hlast : ∀ i < last N, r i ≤ dist (c i) (c (last N)) ∧ r (last N) ≤ τ * r i)\n(inter : ∀ i < last N, dist (c i) (c (last N)) ≤ r i + r (last N))\n\n/-- A metric space has the Besicovitch covering property if there exist `N` and `τ > 1` such that\nthere are no satellite configuration of parameter `τ` with `N+1` points. This is the condition that\nguarantees that the measurable Besicovitch covering theorem holds. It is satified by\nfinite-dimensional real vector spaces. -/\nclass has_besicovitch_covering (α : Type*) [metric_space α] : Prop :=\n(no_satellite_config [] : ∃ (N : ℕ) (τ : ℝ), 1 < τ ∧ is_empty (besicovitch.satellite_config α N τ))\n\n/-- There is always a satellite configuration with a single point. -/\ninstance {α : Type*} {τ : ℝ} [inhabited α] [metric_space α] :\n  inhabited (besicovitch.satellite_config α 0 τ) :=\n⟨{ c := default,\n  r := λ i, 1,\n  rpos := λ i, zero_lt_one,\n  h := λ i j hij, (hij (subsingleton.elim i j)).elim,\n  hlast := λ i hi, by { rw subsingleton.elim i (last 0) at hi, exact (lt_irrefl _ hi).elim },\n  inter := λ i hi, by { rw subsingleton.elim i (last 0) at hi, exact (lt_irrefl _ hi).elim } }⟩\n\nnamespace besicovitch\n\nnamespace satellite_config\nvariables {α : Type*} [metric_space α] {N : ℕ} {τ : ℝ} (a : satellite_config α N τ)\n\nlemma inter' (i : fin N.succ) : dist (a.c i) (a.c (last N)) ≤ a.r i + a.r (last N) :=\nbegin\n  rcases lt_or_le i (last N) with H|H,\n  { exact a.inter i H },\n  { have I : i = last N := top_le_iff.1 H,\n    have := (a.rpos (last N)).le,\n    simp only [I, add_nonneg this this, dist_self] }\nend\n\nlemma hlast' (i : fin N.succ) (h : 1 ≤ τ) : a.r (last N) ≤ τ * a.r i :=\nbegin\n  rcases lt_or_le i (last N) with H|H,\n  { exact (a.hlast i H).2 },\n  { have : i = last N := top_le_iff.1 H,\n    rw this,\n    exact le_mul_of_one_le_left (a.rpos _).le h }\nend\n\nend satellite_config\n\n/-! ### Extracting disjoint subfamilies from a ball covering -/\n\n/-- A ball package is a family of balls in a metric space with positive bounded radii. -/\nstructure ball_package (β : Type*) (α : Type*) :=\n(c : β → α)\n(r : β → ℝ)\n(rpos : ∀ b, 0 < r b)\n(r_bound : ℝ)\n(r_le : ∀ b, r b ≤ r_bound)\n\n/-- The ball package made of unit balls. -/\ndef unit_ball_package (α : Type*) : ball_package α α :=\n{ c := id,\n  r := λ _, 1,\n  rpos := λ _, zero_lt_one,\n  r_bound := 1,\n  r_le := λ _, le_rfl }\n\ninstance (α : Type*) : inhabited (ball_package α α) :=\n⟨unit_ball_package α⟩\n\n/-- A Besicovitch tau-package is a family of balls in a metric space with positive bounded radii,\ntogether with enough data to proceed with the Besicovitch greedy algorithm. We register this in\na single structure to make sure that all our constructions in this algorithm only depend on\none variable. -/\nstructure tau_package (β : Type*) (α : Type*) extends ball_package β α :=\n(τ : ℝ)\n(one_lt_tau : 1 < τ)\n\ninstance (α : Type*) : inhabited (tau_package α α) :=\n⟨{ τ := 2,\n  one_lt_tau := one_lt_two,\n  .. unit_ball_package α }⟩\n\nvariables {α : Type*} [metric_space α] {β : Type u}\n\nnamespace tau_package\n\nvariables [nonempty β] (p : tau_package β α)\ninclude p\n\n/-- Choose inductively large balls with centers that are not contained in the union of already\nchosen balls. This is a transfinite induction. -/\nnoncomputable def index : ordinal.{u} → β\n| i :=\n    -- `Z` is the set of points that are covered by already constructed balls\n    let Z := ⋃ (j : {j // j < i}), ball (p.c (index j)) (p.r (index j)),\n    -- `R` is the supremum of the radii of balls with centers not in `Z`\n    R := supr (λ b : {b : β // p.c b ∉ Z}, p.r b) in\n    -- return an index `b` for which the center `c b` is not in `Z`, and the radius is at\n    -- least `R / τ`, if such an index exists (and garbage otherwise).\n    classical.epsilon (λ b : β, p.c b ∉ Z ∧ R ≤ p.τ * p.r b)\nusing_well_founded {dec_tac := `[exact j.2]}\n\n/-- The set of points that are covered by the union of balls selected at steps `< i`. -/\ndef Union_up_to (i : ordinal.{u}) : set α :=\n⋃ (j : {j // j < i}), ball (p.c (p.index j)) (p.r (p.index j))\n\nlemma monotone_Union_up_to : monotone p.Union_up_to :=\nbegin\n  assume i j hij,\n  simp only [Union_up_to],\n  exact Union_mono' (λ r, ⟨⟨r, r.2.trans_le hij⟩, subset.rfl⟩),\nend\n\n/-- Supremum of the radii of balls whose centers are not yet covered at step `i`. -/\ndef R (i : ordinal.{u}) : ℝ :=\nsupr (λ b : {b : β // p.c b ∉ p.Union_up_to i}, p.r b)\n\n/-- Group the balls into disjoint families, by assigning to a ball the smallest color for which\nit does not intersect any already chosen ball of this color. -/\nnoncomputable def color : ordinal.{u} → ℕ\n| i := let A : set ℕ := ⋃ (j : {j // j < i})\n          (hj : (closed_ball (p.c (p.index j)) (p.r (p.index j))\n            ∩ closed_ball (p.c (p.index i)) (p.r (p.index i))).nonempty), {color j} in\n       Inf (univ \\ A)\nusing_well_founded {dec_tac := `[exact j.2]}\n\n/-- `p.last_step` is the first ordinal where the construction stops making sense, i.e., `f` returns\ngarbage since there is no point left to be chosen. We will only use ordinals before this step. -/\ndef last_step : ordinal.{u} :=\nInf {i | ¬ ∃ (b : β), p.c b ∉ p.Union_up_to i ∧ p.R i ≤ p.τ * p.r b}\n\nlemma last_step_nonempty :\n  {i | ¬ ∃ (b : β), p.c b ∉ p.Union_up_to i ∧ p.R i ≤ p.τ * p.r b}.nonempty :=\nbegin\n  by_contra,\n  suffices H : function.injective p.index, from not_injective_of_ordinal p.index H,\n  assume x y hxy,\n  wlog x_le_y : x ≤ y generalizing x y,\n  { exact (this hxy.symm (le_of_not_le x_le_y)).symm },\n  rcases eq_or_lt_of_le x_le_y with rfl|H, { refl },\n  simp only [nonempty_def, not_exists, exists_prop, not_and, not_lt, not_le, mem_set_of_eq,\n    not_forall] at h,\n  specialize h y,\n  have A : p.c (p.index y) ∉ p.Union_up_to y,\n  { have : p.index y = classical.epsilon (λ b : β, p.c b ∉ p.Union_up_to y ∧ p.R y ≤ p.τ * p.r b),\n      by { rw [tau_package.index], refl },\n    rw this,\n    exact (classical.epsilon_spec h).1 },\n  simp only [Union_up_to, not_exists, exists_prop, mem_Union, mem_closed_ball, not_and, not_le,\n              subtype.exists, subtype.coe_mk] at A,\n  specialize A x H,\n  simp [hxy] at A,\n  exact (lt_irrefl _ ((p.rpos (p.index y)).trans_le A)).elim\nend\n\n/-- Every point is covered by chosen balls, before `p.last_step`. -/\nlemma mem_Union_up_to_last_step (x : β) : p.c x ∈ p.Union_up_to p.last_step :=\nbegin\n  have A : ∀ (z : β), p.c z ∈ p.Union_up_to p.last_step ∨ p.τ * p.r z < p.R p.last_step,\n  { have : p.last_step ∈ {i | ¬ ∃ (b : β), p.c b ∉ p.Union_up_to i ∧ p.R i ≤ p.τ * p.r b} :=\n      Inf_mem p.last_step_nonempty,\n    simpa only [not_exists, mem_set_of_eq, not_and_distrib, not_le, not_not_mem] },\n  by_contra,\n  rcases A x with H|H, { exact h H },\n  have Rpos : 0 < p.R p.last_step,\n  { apply lt_trans (mul_pos (_root_.zero_lt_one.trans p.one_lt_tau) (p.rpos _)) H },\n  have B : p.τ⁻¹ * p.R p.last_step < p.R p.last_step,\n  { conv_rhs { rw ← one_mul (p.R p.last_step) },\n    exact mul_lt_mul (inv_lt_one p.one_lt_tau) le_rfl Rpos zero_le_one },\n  obtain ⟨y, hy1, hy2⟩ : ∃ (y : β),\n    p.c y ∉ p.Union_up_to p.last_step ∧ (p.τ)⁻¹ * p.R p.last_step < p.r y,\n  { simpa only [exists_prop, mem_range, exists_exists_and_eq_and, subtype.exists, subtype.coe_mk]\n      using exists_lt_of_lt_cSup _ B,\n    rw [← image_univ, nonempty_image_iff],\n    exact ⟨⟨_, h⟩, mem_univ _⟩ },\n  rcases A y with Hy|Hy,\n  { exact hy1 Hy },\n  { rw ← div_eq_inv_mul at hy2,\n    have := (div_le_iff' (_root_.zero_lt_one.trans p.one_lt_tau)).1 hy2.le,\n    exact lt_irrefl _ (Hy.trans_le this) }\nend\n\n/-- If there are no configurations of satellites with `N+1` points, one never uses more than `N`\ndistinct families in the Besicovitch inductive construction. -/\nlemma color_lt {i : ordinal.{u}} (hi : i < p.last_step)\n  {N : ℕ} (hN : is_empty (satellite_config α N p.τ)) :\n  p.color i < N :=\nbegin\n  /- By contradiction, consider the first ordinal `i` for which one would have `p.color i = N`.\n  Choose for each `k < N` a ball with color `k` that intersects the ball at color `i`\n  (there is such a ball, otherwise one would have used the color `k` and not `N`).\n  Then this family of `N+1` balls forms a satellite configuration, which is forbidden by\n  the assumption `hN`. -/\n  induction i using ordinal.induction with i IH,\n  let A : set ℕ := ⋃ (j : {j // j < i})\n         (hj : (closed_ball (p.c (p.index j)) (p.r (p.index j))\n            ∩ closed_ball (p.c (p.index i)) (p.r (p.index i))).nonempty), {p.color j},\n  have color_i : p.color i = Inf (univ \\ A), by rw [color],\n  rw color_i,\n  have N_mem : N ∈ univ \\ A,\n  { simp only [not_exists, true_and, exists_prop, mem_Union, mem_singleton_iff, mem_closed_ball,\n      not_and, mem_univ, mem_diff, subtype.exists, subtype.coe_mk],\n    assume j ji hj,\n    exact (IH j ji (ji.trans hi)).ne' },\n  suffices : Inf (univ \\ A) ≠ N,\n  { rcases (cInf_le (order_bot.bdd_below (univ \\ A)) N_mem).lt_or_eq with H|H,\n    { exact H },\n    { exact (this H).elim } },\n  assume Inf_eq_N,\n  have : ∀ k, k < N → ∃ j, j < i\n    ∧ (closed_ball (p.c (p.index j)) (p.r (p.index j))\n        ∩ closed_ball (p.c (p.index i)) (p.r (p.index i))).nonempty\n    ∧ k = p.color j,\n  { assume k hk,\n    rw ← Inf_eq_N at hk,\n    have : k ∈ A,\n      by simpa only [true_and, mem_univ, not_not, mem_diff] using nat.not_mem_of_lt_Inf hk,\n    simp at this,\n    simpa only [exists_prop, mem_Union, mem_singleton_iff, mem_closed_ball, subtype.exists,\n      subtype.coe_mk] },\n  choose! g hg using this,\n  -- Choose for each `k < N` an ordinal `G k < i`  giving a ball of color `k` intersecting\n  -- the last ball.\n  let G : ℕ → ordinal := λ n, if n = N then i else g n,\n  have color_G : ∀ n, n ≤ N → p.color (G n) = n,\n  { assume n hn,\n    unfreezingI { rcases hn.eq_or_lt with rfl|H },\n    { simp only [G], simp only [color_i, Inf_eq_N, if_true, eq_self_iff_true] },\n    { simp only [G], simp only [H.ne, (hg n H).right.right.symm, if_false] } },\n  have G_lt_last : ∀ n, n ≤ N → G n < p.last_step,\n  { assume n hn,\n    unfreezingI { rcases hn.eq_or_lt with rfl|H },\n    { simp only [G], simp only [hi, if_true, eq_self_iff_true], },\n    { simp only [G], simp only [H.ne, (hg n H).left.trans hi, if_false] } },\n  have fGn : ∀ n, n ≤ N →\n    p.c (p.index (G n)) ∉ p.Union_up_to (G n) ∧ p.R (G n) ≤ p.τ * p.r (p.index (G n)),\n  { assume n hn,\n    have: p.index (G n) = classical.epsilon\n      (λ t, p.c t ∉ p.Union_up_to (G n) ∧ p.R (G n) ≤ p.τ * p.r t), by { rw index, refl },\n    rw this,\n    have : ∃ t, p.c t ∉ p.Union_up_to (G n) ∧ p.R (G n) ≤ p.τ * p.r t,\n      by simpa only [not_exists, exists_prop, not_and, not_lt, not_le, mem_set_of_eq,\n        not_forall] using not_mem_of_lt_cInf (G_lt_last n hn) (order_bot.bdd_below _),\n    exact classical.epsilon_spec this },\n  -- the balls with indices `G k` satisfy the characteristic property of satellite configurations.\n  have Gab : ∀ (a b : fin (nat.succ N)), G a < G b →\n    p.r (p.index (G a)) ≤ dist (p.c (p.index (G a))) (p.c (p.index (G b)))\n      ∧ p.r (p.index (G b)) ≤ p.τ * p.r (p.index (G a)),\n  { assume a b G_lt,\n    have ha : (a : ℕ) ≤ N := nat.lt_succ_iff.1 a.2,\n    have hb : (b : ℕ) ≤ N := nat.lt_succ_iff.1 b.2,\n    split,\n    { have := (fGn b hb).1,\n      simp only [Union_up_to, not_exists, exists_prop, mem_Union, mem_closed_ball, not_and,\n        not_le, subtype.exists, subtype.coe_mk] at this,\n      simpa only [dist_comm, mem_ball, not_lt] using this (G a) G_lt },\n    { apply le_trans _ (fGn a ha).2,\n      have B : p.c (p.index (G b)) ∉ p.Union_up_to (G a),\n      { assume H, exact (fGn b hb).1 (p.monotone_Union_up_to G_lt.le H) },\n      let b' : {t // p.c t ∉ p.Union_up_to (G a)} := ⟨p.index (G b), B⟩,\n      apply @le_csupr _ _ _ (λ t : {t // p.c t ∉ p.Union_up_to (G a)}, p.r t) _ b',\n      refine ⟨p.r_bound, λ t ht, _⟩,\n      simp only [exists_prop, mem_range, subtype.exists, subtype.coe_mk] at ht,\n      rcases ht with ⟨u, hu⟩,\n      rw ← hu.2,\n      exact p.r_le _ } },\n  -- therefore, one may use them to construct a satellite configuration with `N+1` points\n  let sc : satellite_config α N p.τ :=\n  { c := λ k, p.c (p.index (G k)),\n    r := λ k, p.r (p.index (G k)),\n    rpos := λ k, p.rpos (p.index (G k)),\n    h := begin\n      assume a b a_ne_b,\n      wlog G_le : G a ≤ G b generalizing a b,\n      { exact (this b a a_ne_b.symm (le_of_not_le G_le)).symm },\n      have G_lt : G a < G b,\n      { rcases G_le.lt_or_eq with H|H, { exact H },\n        have A : (a : ℕ) ≠ b := fin.coe_injective.ne a_ne_b,\n        rw [← color_G a (nat.lt_succ_iff.1 a.2), ← color_G b (nat.lt_succ_iff.1 b.2), H] at A,\n        exact (A rfl).elim },\n      exact or.inl (Gab a b G_lt),\n    end,\n    hlast := begin\n      assume a ha,\n      have I : (a : ℕ) < N := ha,\n      have : G a < G (fin.last N), by { dsimp [G], simp [I.ne, (hg a I).1] },\n      exact Gab _ _ this,\n    end,\n    inter := begin\n      assume a ha,\n      have I : (a : ℕ) < N := ha,\n      have J : G (fin.last N) = i, by { dsimp [G], simp only [if_true, eq_self_iff_true], },\n      have K : G a = g a, { dsimp [G], simp [I.ne, (hg a I).1] },\n      convert dist_le_add_of_nonempty_closed_ball_inter_closed_ball (hg _ I).2.1,\n    end },\n  -- this is a contradiction\n  exact (hN.false : _) sc\nend\n\nend tau_package\n\nopen tau_package\n\n/-- The topological Besicovitch covering theorem: there exist finitely many families of disjoint\nballs covering all the centers in a package. More specifically, one can use `N` families if there\nare no satellite configurations with `N+1` points. -/\ntheorem exist_disjoint_covering_families {N : ℕ} {τ : ℝ}\n  (hτ : 1 < τ) (hN : is_empty (satellite_config α N τ)) (q : ball_package β α) :\n  ∃ s : fin N → set β,\n    (∀ (i : fin N), (s i).pairwise_disjoint (λ j, closed_ball (q.c j) (q.r j))) ∧\n      (range q.c ⊆ ⋃ (i : fin N), ⋃ (j ∈ s i), ball (q.c j) (q.r j)) :=\nbegin\n  -- first exclude the trivial case where `β` is empty (we need non-emptiness for the transfinite\n  -- induction, to be able to choose garbage when there is no point left).\n  casesI is_empty_or_nonempty β,\n  { refine ⟨λ i, ∅, λ i, pairwise_disjoint_empty, _⟩,\n    rw [← image_univ, eq_empty_of_is_empty (univ : set β)],\n    simp },\n  -- Now, assume `β` is nonempty.\n  let p : tau_package β α := { τ := τ, one_lt_tau := hτ, .. q },\n  -- we use for `s i` the balls of color `i`.\n  let s := λ (i : fin N),\n    ⋃ (k : ordinal.{u}) (hk : k < p.last_step) (h'k : p.color k = i), ({p.index k} : set β),\n  refine ⟨s, λ i, _, _⟩,\n  { -- show that balls of the same color are disjoint\n    assume x hx y hy x_ne_y,\n    obtain ⟨jx, jx_lt, jxi, rfl⟩ :\n      ∃ (jx : ordinal), jx < p.last_step ∧ p.color jx = i ∧ x = p.index jx,\n        by simpa only [exists_prop, mem_Union, mem_singleton_iff] using hx,\n    obtain ⟨jy, jy_lt, jyi, rfl⟩ :\n      ∃ (jy : ordinal), jy < p.last_step ∧ p.color jy = i ∧ y = p.index jy,\n        by simpa only [exists_prop, mem_Union, mem_singleton_iff] using hy,\n    wlog jxy : jx ≤ jy generalizing jx jy,\n    { exact (this jy jy_lt jyi hy jx jx_lt jxi hx x_ne_y.symm (le_of_not_le jxy)).symm },\n    replace jxy : jx < jy,\n      by { rcases lt_or_eq_of_le jxy with H|rfl, { exact H }, { exact (x_ne_y rfl).elim } },\n    let A : set ℕ := ⋃ (j : {j // j < jy})\n         (hj : (closed_ball (p.c (p.index j)) (p.r (p.index j))\n            ∩ closed_ball (p.c (p.index jy)) (p.r (p.index jy))).nonempty), {p.color j},\n    have color_j : p.color jy = Inf (univ \\ A), by rw [tau_package.color],\n    have : p.color jy ∈ univ \\ A,\n    { rw color_j,\n      apply Inf_mem,\n      refine ⟨N, _⟩,\n      simp only [not_exists, true_and, exists_prop, mem_Union, mem_singleton_iff, not_and, mem_univ,\n        mem_diff, subtype.exists, subtype.coe_mk],\n      assume k hk H,\n      exact (p.color_lt (hk.trans jy_lt) hN).ne' },\n    simp only [not_exists, true_and, exists_prop, mem_Union, mem_singleton_iff, not_and, mem_univ,\n      mem_diff, subtype.exists, subtype.coe_mk] at this,\n    specialize this jx jxy,\n    contrapose! this,\n    simpa only [jxi, jyi, and_true, eq_self_iff_true, ← not_disjoint_iff_nonempty_inter] },\n  { -- show that the balls of color at most `N` cover every center.\n    refine range_subset_iff.2 (λ b, _),\n    obtain ⟨a, ha⟩ :\n      ∃ (a : ordinal), a < p.last_step ∧ dist (p.c b) (p.c (p.index a)) < p.r (p.index a),\n      by simpa only [Union_up_to, exists_prop, mem_Union, mem_ball, subtype.exists, subtype.coe_mk]\n        using p.mem_Union_up_to_last_step b,\n    simp only [exists_prop, mem_Union, mem_ball, mem_singleton_iff, bUnion_and', exists_eq_left,\n      Union_exists, exists_and_distrib_left],\n    exact ⟨⟨p.color a, p.color_lt ha.1 hN⟩, a, rfl, ha⟩ }\nend\n\n/-!\n### The measurable Besicovitch covering theorem\n-/\n\nopen_locale nnreal\nvariables [second_countable_topology α] [measurable_space α] [opens_measurable_space α]\n\n/-- Consider, for each `x` in a set `s`, a radius `r x ∈ (0, 1]`. Then one can find finitely\nmany disjoint balls of the form `closed_ball x (r x)` covering a proportion `1/(N+1)` of `s`, if\nthere are no satellite configurations with `N+1` points.\n-/\nlemma exist_finset_disjoint_balls_large_measure\n  (μ : measure α) [is_finite_measure μ] {N : ℕ} {τ : ℝ}\n  (hτ : 1 < τ) (hN : is_empty (satellite_config α N τ)) (s : set α)\n  (r : α → ℝ) (rpos : ∀ x ∈ s, 0 < r x) (rle : ∀ x ∈ s, r x ≤ 1) :\n  ∃ (t : finset α), (↑t ⊆ s) ∧ μ (s \\ (⋃ (x ∈ t), closed_ball x (r x))) ≤ N/(N+1) * μ s\n    ∧ (t : set α).pairwise_disjoint (λ x, closed_ball x (r x)) :=\nbegin\n  -- exclude the trivial case where `μ s = 0`.\n  rcases le_or_lt (μ s) 0 with hμs|hμs,\n  { have : μ s = 0 := le_bot_iff.1 hμs,\n    refine ⟨∅, by simp only [finset.coe_empty, empty_subset], _, _⟩,\n    { simp only [this, diff_empty, Union_false, Union_empty, nonpos_iff_eq_zero, mul_zero] },\n    { simp only [finset.coe_empty, pairwise_disjoint_empty], } },\n  casesI is_empty_or_nonempty α,\n  { simp only [eq_empty_of_is_empty s, measure_empty] at hμs,\n    exact (lt_irrefl _ hμs).elim },\n  have Npos : N ≠ 0,\n  { unfreezingI { rintros rfl },\n    inhabit α,\n    exact (not_is_empty_of_nonempty _) hN },\n  -- introduce a measurable superset `o` with the same measure, for measure computations\n  obtain ⟨o, so, omeas, μo⟩ : ∃ (o : set α), s ⊆ o ∧ measurable_set o ∧ μ o = μ s :=\n    exists_measurable_superset μ s,\n  /- We will apply the topological Besicovitch theorem, giving `N` disjoint subfamilies of balls\n  covering `s`. Among these, one of them covers a proportion at least `1/N` of `s`. A large\n  enough finite subfamily will then cover a proportion at least `1/(N+1)`. -/\n  let a : ball_package s α :=\n  { c := λ x, x,\n    r := λ x, r x,\n    rpos := λ x, rpos x x.2,\n    r_bound := 1,\n    r_le := λ x, rle x x.2 },\n  rcases exist_disjoint_covering_families hτ hN a with ⟨u, hu, hu'⟩,\n  have u_count : ∀ i, (u i).countable,\n  { assume i,\n    refine (hu i).countable_of_nonempty_interior (λ j hj, _),\n    have : (ball (j : α) (r j)).nonempty := nonempty_ball.2 (a.rpos _),\n    exact this.mono ball_subset_interior_closed_ball },\n  let v : fin N → set α := λ i, ⋃ (x : s) (hx : x ∈ u i), closed_ball x (r x),\n  have : ∀ i, measurable_set (v i) :=\n    λ i, measurable_set.bUnion (u_count i) (λ b hb, measurable_set_closed_ball),\n  have A : s = ⋃ (i : fin N), s ∩ v i,\n  { refine subset.antisymm _ (Union_subset (λ i, inter_subset_left _ _)),\n    assume x hx,\n    obtain ⟨i, y, hxy, h'⟩ : ∃ (i : fin N) (i_1 : ↥s) (i : i_1 ∈ u i), x ∈ ball ↑i_1 (r ↑i_1),\n    { have : x ∈ range a.c, by simpa only [subtype.range_coe_subtype, set_of_mem_eq],\n      simpa only [mem_Union] using hu' this },\n    refine mem_Union.2 ⟨i, ⟨hx, _⟩⟩,\n    simp only [v, exists_prop, mem_Union, set_coe.exists, exists_and_distrib_right, subtype.coe_mk],\n    exact ⟨y, ⟨y.2, by simpa only [subtype.coe_eta]⟩, ball_subset_closed_ball h'⟩ },\n  have S : ∑ (i : fin N), μ s / N ≤ ∑ i, μ (s ∩ v i) := calc\n    ∑ (i : fin N), μ s / N = μ s : begin\n      simp only [finset.card_fin, finset.sum_const, nsmul_eq_mul],\n      rw ennreal.mul_div_cancel',\n      { simp only [Npos, ne.def, nat.cast_eq_zero, not_false_iff] },\n      { exact (ennreal.nat_ne_top _) }\n    end\n    ... ≤ ∑ i, μ (s ∩ v i) : by { conv_lhs { rw A }, apply measure_Union_fintype_le },\n  -- choose an index `i` of a subfamily covering at least a proportion `1/N` of `s`.\n  obtain ⟨i, -, hi⟩ : ∃ (i : fin N) (hi : i ∈ finset.univ), μ s / N ≤ μ (s ∩ v i),\n  { apply ennreal.exists_le_of_sum_le _ S,\n    exact ⟨⟨0, bot_lt_iff_ne_bot.2 Npos⟩, finset.mem_univ _⟩ },\n  replace hi : μ s / (N + 1) < μ (s ∩ v i),\n  { apply lt_of_lt_of_le _ hi,\n    apply (ennreal.mul_lt_mul_left hμs.ne' (measure_lt_top μ s).ne).2,\n    rw ennreal.inv_lt_inv,\n    conv_lhs {rw ← add_zero (N : ℝ≥0∞) },\n    exact ennreal.add_lt_add_left (ennreal.nat_ne_top N) zero_lt_one },\n  have B : μ (o ∩ v i) = ∑' (x : u i), μ (o ∩ closed_ball x (r x)),\n  { have : o ∩ v i = ⋃ (x : s) (hx : x ∈ u i), o ∩ closed_ball x (r x), by simp only [inter_Union],\n    rw [this, measure_bUnion (u_count i)],\n    { refl },\n    { exact (hu i).mono (λ k, inter_subset_right _ _) },\n    { exact λ b hb, omeas.inter measurable_set_closed_ball } },\n  -- A large enough finite subfamily of `u i` will also cover a proportion `> 1/(N+1)` of `s`.\n  -- Since `s` might not be measurable, we express this in terms of the measurable superset `o`.\n  obtain ⟨w, hw⟩ : ∃ (w : finset (u i)),\n    μ s / (N + 1) < ∑ (x : u i) in w, μ (o ∩ closed_ball (x : α) (r (x : α))),\n  { have C : has_sum (λ (x : u i), μ (o ∩ closed_ball x (r x))) (μ (o ∩ v i)),\n      by { rw B, exact ennreal.summable.has_sum },\n    have : μ s / (N+1) < μ (o ∩ v i) :=\n      hi.trans_le (measure_mono (inter_subset_inter_left _ so)),\n    exact ((tendsto_order.1 C).1 _ this).exists },\n  -- Bring back the finset `w i` of `↑(u i)` to a finset of `α`, and check that it works by design.\n  refine ⟨finset.image (λ (x : u i), x) w, _, _, _⟩,\n  -- show that the finset is included in `s`.\n  { simp only [image_subset_iff, coe_coe, finset.coe_image],\n    assume y hy,\n    simp only [subtype.coe_prop, mem_preimage] },\n  -- show that it covers a large enough proportion of `s`. For measure computations, we do not\n  -- use `s` (which might not be measurable), but its measurable superset `o`. Since their measures\n  -- are the same, this does not spoil the estimates\n  { suffices H : μ (o \\ ⋃ x ∈ w, closed_ball ↑x (r ↑x)) ≤ N/(N+1) * μ s,\n      { rw [finset.set_bUnion_finset_image],\n        exact le_trans (measure_mono (diff_subset_diff so (subset.refl _))) H },\n    rw [← diff_inter_self_eq_diff,\n      measure_diff_le_iff_le_add _ (inter_subset_right _ _) ((measure_lt_top μ _).ne)], swap,\n    { apply measurable_set.inter _ omeas,\n      haveI : encodable (u i) := (u_count i).to_encodable,\n      exact measurable_set.Union\n        (λ b, measurable_set.Union (λ hb, measurable_set_closed_ball)) },\n    calc\n    μ o = 1/(N+1) * μ s + N/(N+1) * μ s :\n      by { rw [μo, ← add_mul, ennreal.div_add_div_same, add_comm, ennreal.div_self, one_mul]; simp }\n    ... ≤ μ ((⋃ (x ∈ w), closed_ball ↑x (r ↑x)) ∩ o) + N/(N+1) * μ s : begin\n      refine add_le_add _ le_rfl,\n      rw [div_eq_mul_inv, one_mul, mul_comm, ← div_eq_mul_inv],\n      apply hw.le.trans (le_of_eq _),\n      rw [← finset.set_bUnion_coe, inter_comm _ o, inter_Union₂, finset.set_bUnion_coe,\n          measure_bUnion_finset],\n      { have : (w : set (u i)).pairwise_disjoint (λ (b : u i), closed_ball (b : α) (r (b : α))),\n          by { assume k hk l hl hkl, exact hu i k.2 l.2 (subtype.coe_injective.ne hkl) },\n        exact this.mono (λ k, inter_subset_right _ _) },\n      { assume b hb,\n        apply omeas.inter measurable_set_closed_ball }\n    end },\n  -- show that the balls are disjoint\n  { assume k hk l hl hkl,\n    obtain ⟨k', k'w, rfl⟩ : ∃ (k' : u i), k' ∈ w ∧ ↑↑k' = k,\n      by simpa only [mem_image, finset.mem_coe, coe_coe, finset.coe_image] using hk,\n    obtain ⟨l', l'w, rfl⟩ : ∃ (l' : u i), l' ∈ w ∧ ↑↑l' = l,\n      by simpa only [mem_image, finset.mem_coe, coe_coe, finset.coe_image] using hl,\n    have k'nel' : (k' : s) ≠ l',\n      by { assume h, rw h at hkl, exact hkl rfl },\n    exact hu i k'.2 l'.2 k'nel' }\nend\n\nvariable [has_besicovitch_covering α]\n\n/-- The measurable Besicovitch covering theorem. Assume that, for any `x` in a set `s`,\none is given a set of admissible closed balls centered at `x`, with arbitrarily small radii.\nThen there exists a disjoint covering of almost all `s` by admissible closed balls centered at some\npoints of `s`.\nThis version requires that the underlying measure is finite, and that the space has the Besicovitch\ncovering property (which is satisfied for instance by normed real vector spaces). It expresses the\nconclusion in a slightly awkward form (with a subset of `α × ℝ`) coming from the proof technique.\nFor a version assuming that the measure is sigma-finite,\nsee `exists_disjoint_closed_ball_covering_ae_aux`.\nFor a version giving the conclusion in a nicer form, see `exists_disjoint_closed_ball_covering_ae`.\n-/\ntheorem exists_disjoint_closed_ball_covering_ae_of_finite_measure_aux\n  (μ : measure α) [is_finite_measure μ]\n  (f : α → set ℝ) (s : set α) (hf : ∀ x ∈ s, ∀ δ > 0, (f x ∩ Ioo 0 δ).nonempty) :\n  ∃ (t : set (α × ℝ)), t.countable\n    ∧ (∀ (p : α × ℝ), p ∈ t → p.1 ∈ s) ∧ (∀ (p : α × ℝ), p ∈ t → p.2 ∈ f p.1)\n    ∧ μ (s \\ (⋃ (p : α × ℝ) (hp : p ∈ t), closed_ball p.1 p.2)) = 0\n    ∧ t.pairwise_disjoint (λ p, closed_ball p.1 p.2) :=\nbegin\n  rcases has_besicovitch_covering.no_satellite_config α with ⟨N, τ, hτ, hN⟩,\n  /- Introduce a property `P` on finsets saying that we have a nice disjoint covering of a\n    subset of `s` by admissible balls. -/\n  let P : finset (α × ℝ) → Prop := λ t,\n    (t : set (α × ℝ)).pairwise_disjoint (λ p, closed_ball p.1 p.2) ∧\n    (∀ (p : α × ℝ), p ∈ t → p.1 ∈ s) ∧ (∀ (p : α × ℝ), p ∈ t → p.2 ∈ f p.1),\n  /- Given a finite good covering of a subset `s`, one can find a larger finite good covering,\n  covering additionally a proportion at least `1/(N+1)` of leftover points. This follows from\n  `exist_finset_disjoint_balls_large_measure` applied to balls not intersecting the initial\n  covering. -/\n  have : ∀ (t : finset (α × ℝ)), P t → ∃ (u : finset (α × ℝ)), t ⊆ u ∧ P u ∧\n    μ (s \\ (⋃ (p : α × ℝ) (hp : p ∈ u), closed_ball p.1 p.2)) ≤\n      N/(N+1) * μ (s \\ (⋃ (p : α × ℝ) (hp : p ∈ t), closed_ball p.1 p.2)),\n  { assume t ht,\n    set B := ⋃ (p : α × ℝ) (hp : p ∈ t), closed_ball p.1 p.2 with hB,\n    have B_closed : is_closed B :=\n      is_closed_bUnion (finset.finite_to_set _) (λ i hi, is_closed_ball),\n    set s' := s \\ B with hs',\n    have : ∀ x ∈ s', ∃ r ∈ f x ∩ Ioo 0 1, disjoint B (closed_ball x r),\n    { assume x hx,\n      have xs : x ∈ s := ((mem_diff x).1 hx).1,\n      rcases eq_empty_or_nonempty B with hB|hB,\n      { have : (0 : ℝ) < 1 := zero_lt_one,\n        rcases hf x xs 1 zero_lt_one with ⟨r, hr, h'r⟩,\n        exact ⟨r, ⟨hr, h'r⟩, by simp only [hB, empty_disjoint]⟩ },\n      { let R := inf_dist x B,\n        have : 0 < min R 1 :=\n          lt_min ((B_closed.not_mem_iff_inf_dist_pos hB).1 ((mem_diff x).1 hx).2) zero_lt_one,\n        rcases hf x xs _ this with ⟨r, hr, h'r⟩,\n        refine ⟨r, ⟨hr, ⟨h'r.1, h'r.2.trans_le (min_le_right _ _)⟩⟩, _⟩,\n        rw disjoint.comm,\n        exact disjoint_closed_ball_of_lt_inf_dist (h'r.2.trans_le (min_le_left _ _)) } },\n    choose! r hr using this,\n    obtain ⟨v, vs', hμv, hv⟩ : ∃ (v : finset α), ↑v ⊆ s'\n      ∧ μ (s' \\ ⋃ (x ∈ v), closed_ball x (r x)) ≤ N/(N+1) * μ s'\n      ∧ (v : set α).pairwise_disjoint (λ (x : α), closed_ball x (r x)),\n    { have rI : ∀ x ∈ s', r x ∈ Ioo (0 : ℝ) 1 := λ x hx, (hr x hx).1.2,\n      exact exist_finset_disjoint_balls_large_measure μ hτ hN s' r (λ x hx, (rI x hx).1)\n        (λ x hx, (rI x hx).2.le) },\n    refine ⟨t ∪ (finset.image (λ x, (x, r x)) v), finset.subset_union_left _ _, ⟨_, _, _⟩, _⟩,\n    { simp only [finset.coe_union, pairwise_disjoint_union, ht.1, true_and, finset.coe_image],\n      split,\n      { assume p hp q hq hpq,\n        rcases (mem_image _ _ _).1 hp with ⟨p', p'v, rfl⟩,\n        rcases (mem_image _ _ _).1 hq with ⟨q', q'v, rfl⟩,\n        refine hv p'v q'v (λ hp'q', _),\n        rw [hp'q'] at hpq,\n        exact hpq rfl },\n      { assume p hp q hq hpq,\n        rcases (mem_image _ _ _).1 hq with ⟨q', q'v, rfl⟩,\n        apply disjoint_of_subset_left _ (hr q' (vs' q'v)).2,\n        rw [hB, ← finset.set_bUnion_coe],\n        exact subset_bUnion_of_mem hp } },\n    { assume p hp,\n      rcases finset.mem_union.1 hp with h'p|h'p,\n      { exact ht.2.1 p h'p },\n      { rcases finset.mem_image.1 h'p with ⟨p', p'v, rfl⟩,\n        exact ((mem_diff _).1 (vs' (finset.mem_coe.2 p'v))).1 } },\n    { assume p hp,\n      rcases finset.mem_union.1 hp with h'p|h'p,\n      { exact ht.2.2 p h'p },\n      { rcases finset.mem_image.1 h'p with ⟨p', p'v, rfl⟩,\n        exact (hr p' (vs' p'v)).1.1 } },\n    { convert hμv using 2,\n      rw [finset.set_bUnion_union, ← diff_diff, finset.set_bUnion_finset_image] } },\n  /- Define `F` associating to a finite good covering the above enlarged good covering, covering\n  a proportion `1/(N+1)` of leftover points. Iterating `F`, one will get larger and larger good\n  coverings, missing in the end only a measure-zero set. -/\n  choose! F hF using this,\n  let u := λ n, F^[n] ∅,\n  have u_succ : ∀ (n : ℕ), u n.succ = F (u n) :=\n    λ n, by simp only [u, function.comp_app, function.iterate_succ'],\n  have Pu : ∀ n, P (u n),\n  { assume n,\n    induction n with n IH,\n    { simp only [u, P, prod.forall, id.def, function.iterate_zero],\n      simp only [finset.not_mem_empty, is_empty.forall_iff, finset.coe_empty, forall_2_true_iff,\n        and_self, pairwise_disjoint_empty] },\n    { rw u_succ,\n      exact (hF (u n) IH).2.1 } },\n  refine ⟨⋃ n, u n, countable_Union (λ n, (u n).countable_to_set), _, _, _, _⟩,\n  { assume p hp,\n    rcases mem_Union.1 hp with ⟨n, hn⟩,\n    exact (Pu n).2.1 p (finset.mem_coe.1 hn) },\n  { assume p hp,\n    rcases mem_Union.1 hp with ⟨n, hn⟩,\n    exact (Pu n).2.2 p (finset.mem_coe.1 hn) },\n  { have A : ∀ n, μ (s \\ ⋃ (p : α × ℝ) (hp : p ∈ ⋃ (n : ℕ), (u n : set (α × ℝ))),\n                     closed_ball p.fst p.snd)\n                ≤ μ (s \\ ⋃ (p : α × ℝ) (hp : p ∈ u n), closed_ball p.fst p.snd),\n    { assume n,\n      apply measure_mono,\n      apply diff_subset_diff (subset.refl _),\n      exact bUnion_subset_bUnion_left (subset_Union (λ i, (u i : set (α × ℝ))) n) },\n    have B : ∀ n, μ (s \\ ⋃ (p : α × ℝ) (hp : p ∈ u n), closed_ball p.fst p.snd)\n      ≤ (N/(N+1))^n * μ s,\n    { assume n,\n      induction n with n IH,\n      { simp only [le_refl, diff_empty, one_mul, Union_false, Union_empty, pow_zero] },\n      calc\n        μ (s \\ ⋃ (p : α × ℝ) (hp : p ∈ u n.succ), closed_ball p.fst p.snd)\n            ≤ (N/(N+1)) * μ (s \\ ⋃ (p : α × ℝ) (hp : p ∈ u n), closed_ball p.fst p.snd) :\n              by { rw u_succ, exact (hF (u n) (Pu n)).2.2 }\n        ... ≤ (N/(N+1))^n.succ * μ s :\n          by { rw [pow_succ, mul_assoc], exact mul_le_mul_left' IH _ } },\n    have C : tendsto (λ (n : ℕ), ((N : ℝ≥0∞)/(N+1))^n * μ s) at_top (𝓝 (0 * μ s)),\n    { apply ennreal.tendsto.mul_const _ (or.inr (measure_lt_top μ s).ne),\n      apply ennreal.tendsto_pow_at_top_nhds_0_of_lt_1,\n      rw [ennreal.div_lt_iff, one_mul],\n      { conv_lhs {rw ← add_zero (N : ℝ≥0∞) },\n        exact ennreal.add_lt_add_left (ennreal.nat_ne_top N) zero_lt_one },\n      { simp only [true_or, add_eq_zero_iff, ne.def, not_false_iff, one_ne_zero, and_false] },\n      { simp only [ennreal.nat_ne_top, ne.def, not_false_iff, or_true] } },\n    rw zero_mul at C,\n    apply le_bot_iff.1,\n    exact le_of_tendsto_of_tendsto' tendsto_const_nhds C (λ n, (A n).trans (B n)) },\n  { refine (pairwise_disjoint_Union _).2 (λ n, (Pu n).1),\n    apply (monotone_nat_of_le_succ (λ n, _)).directed_le,\n    rw u_succ,\n    exact (hF (u n) (Pu n)).1 }\nend\n\n/-- The measurable Besicovitch covering theorem. Assume that, for any `x` in a set `s`,\none is given a set of admissible closed balls centered at `x`, with arbitrarily small radii.\nThen there exists a disjoint covering of almost all `s` by admissible closed balls centered at some\npoints of `s`.\nThis version requires that the underlying measure is sigma-finite, and that the space has the\nBesicovitch covering property (which is satisfied for instance by normed real vector spaces).\nIt expresses the conclusion in a slightly awkward form (with a subset of `α × ℝ`) coming from the\nproof technique.\nFor a version giving the conclusion in a nicer form, see `exists_disjoint_closed_ball_covering_ae`.\n-/\ntheorem exists_disjoint_closed_ball_covering_ae_aux (μ : measure α) [sigma_finite μ]\n  (f : α → set ℝ) (s : set α) (hf : ∀ x ∈ s, ∀ δ > 0, (f x ∩ Ioo 0 δ).nonempty) :\n  ∃ (t : set (α × ℝ)), t.countable\n    ∧ (∀ (p : α × ℝ), p ∈ t → p.1 ∈ s) ∧ (∀ (p : α × ℝ), p ∈ t → p.2 ∈ f p.1)\n    ∧ μ (s \\ (⋃ (p : α × ℝ) (hp : p ∈ t), closed_ball p.1 p.2)) = 0\n    ∧ t.pairwise_disjoint (λ p, closed_ball p.1 p.2) :=\nbegin\n  /- This is deduced from the finite measure case, by using a finite measure with respect to which\n  the initial sigma-finite measure is absolutely continuous. -/\n  unfreezingI { rcases exists_absolutely_continuous_is_finite_measure μ with ⟨ν, hν, hμν⟩ },\n  rcases exists_disjoint_closed_ball_covering_ae_of_finite_measure_aux ν f s hf\n    with ⟨t, t_count, ts, tr, tν, tdisj⟩,\n  exact ⟨t, t_count, ts, tr, hμν tν, tdisj⟩,\nend\n\n/-- The measurable Besicovitch covering theorem. Assume that, for any `x` in a set `s`,\none is given a set of admissible closed balls centered at `x`, with arbitrarily small radii.\nThen there exists a disjoint covering of almost all `s` by admissible closed balls centered at some\npoints of `s`. We can even require that the radius at `x` is bounded by a given function `R x`.\n(Take `R = 1` if you don't need this additional feature).\nThis version requires that the underlying measure is sigma-finite, and that the space has the\nBesicovitch covering property (which is satisfied for instance by normed real vector spaces).\n-/\ntheorem exists_disjoint_closed_ball_covering_ae (μ : measure α) [sigma_finite μ]\n  (f : α → set ℝ) (s : set α) (hf : ∀ x ∈ s, ∀ δ > 0, (f x ∩ Ioo 0 δ).nonempty)\n  (R : α → ℝ) (hR : ∀ x ∈ s, 0 < R x):\n  ∃ (t : set α) (r : α → ℝ), t.countable ∧ t ⊆ s ∧ (∀ x ∈ t, r x ∈ f x ∩ Ioo 0 (R x))\n    ∧ μ (s \\ (⋃ (x ∈ t), closed_ball x (r x))) = 0\n    ∧ t.pairwise_disjoint (λ x, closed_ball x (r x)) :=\nbegin\n  let g := λ x, f x ∩ Ioo 0 (R x),\n  have hg : ∀ x ∈ s, ∀ δ > 0, (g x ∩ Ioo 0 δ).nonempty,\n  { assume x hx δ δpos,\n    rcases hf x hx (min δ (R x)) (lt_min δpos (hR x hx)) with ⟨r, hr⟩,\n    exact ⟨r, ⟨⟨hr.1, hr.2.1, hr.2.2.trans_le (min_le_right _ _)⟩,\n      ⟨hr.2.1, hr.2.2.trans_le (min_le_left _ _)⟩⟩⟩ },\n  rcases exists_disjoint_closed_ball_covering_ae_aux μ g s hg\n    with ⟨v, v_count, vs, vg, μv, v_disj⟩,\n  let t := prod.fst '' v,\n  have : ∀ x ∈ t, ∃ (r : ℝ), (x, r) ∈ v,\n  { assume x hx,\n    rcases (mem_image _ _ _).1 hx with ⟨⟨p, q⟩, hp, rfl⟩,\n    exact ⟨q, hp⟩ },\n  choose! r hr using this,\n  have im_t : (λ x, (x, r x)) '' t = v,\n  { have I : ∀ (p : α × ℝ), p ∈ v → 0 ≤ p.2 :=\n      λ p hp, (vg p hp).2.1.le,\n    apply subset.antisymm,\n    { simp only [image_subset_iff],\n      rintros ⟨x, p⟩ hxp,\n      simp only [mem_preimage],\n      exact hr _ (mem_image_of_mem _ hxp) },\n    { rintros ⟨x, p⟩ hxp,\n      have hxrx : (x, r x) ∈ v := hr _ (mem_image_of_mem _ hxp),\n      have : p = r x,\n      { by_contra,\n        have A : (x, p) ≠ (x, r x),\n          by simpa only [true_and, prod.mk.inj_iff, eq_self_iff_true, ne.def] using h,\n        have H := v_disj hxp hxrx A,\n        contrapose H,\n        rw not_disjoint_iff_nonempty_inter,\n        refine ⟨x, by simp [I _ hxp, I _ hxrx]⟩ },\n      rw this,\n      apply mem_image_of_mem,\n      exact mem_image_of_mem _ hxp } },\n  refine ⟨t, r, v_count.image _, _, _, _, _⟩,\n  { assume x hx,\n    rcases (mem_image _ _ _).1 hx with ⟨⟨p, q⟩, hp, rfl⟩,\n    exact vs _ hp },\n  { assume x hx,\n    rcases (mem_image _ _ _).1 hx with ⟨⟨p, q⟩, hp, rfl⟩,\n    exact vg _ (hr _ hx) },\n  { have : (⋃ (x : α) (H : x ∈ t), closed_ball x (r x)) =\n      (⋃ (p : α × ℝ) (H : p ∈ (λ x, (x, r x)) '' t), closed_ball p.1 p.2),\n        by conv_rhs { rw bUnion_image },\n    rw [this, im_t],\n    exact μv },\n  { have A : inj_on (λ x : α, (x, r x)) t,\n      by simp only [inj_on, prod.mk.inj_iff, implies_true_iff, eq_self_iff_true] {contextual := tt},\n    rwa [← im_t, A.pairwise_disjoint_image] at v_disj }\nend\n\n/-- In a space with the Besicovitch property, any set `s` can be covered with balls whose measures\nadd up to at most `μ s + ε`, for any positive `ε`. This works even if one restricts the set of\nallowed radii around a point `x` to a set `f x` which accumulates at `0`. -/\ntheorem exists_closed_ball_covering_tsum_measure_le\n  (μ : measure α) [sigma_finite μ] [measure.outer_regular μ]\n  {ε : ℝ≥0∞} (hε : ε ≠ 0) (f : α → set ℝ) (s : set α)\n  (hf : ∀ x ∈ s, ∀ δ > 0, (f x ∩ Ioo 0 δ).nonempty) :\n  ∃ (t : set α) (r : α → ℝ), t.countable ∧ t ⊆ s ∧ (∀ x ∈ t, r x ∈ f x)\n    ∧ s ⊆ (⋃ (x ∈ t), closed_ball x (r x))\n    ∧ ∑' (x : t), μ (closed_ball x (r x)) ≤ μ s + ε  :=\nbegin\n  /- For the proof, first cover almost all `s` with disjoint balls thanks to the usual Besicovitch\n  theorem. Taking the balls included in a well-chosen open neighborhood `u` of `s`, one may\n  ensure that their measures add at most to `μ s + ε / 2`. Let `s'` be the remaining set, of measure\n  `0`. Applying the other version of Besicovitch, one may cover it with at most `N` disjoint\n  subfamilies. Making sure that they are all included in a neighborhood `v` of `s'` of measure at\n  most `ε / (2 N)`, the sum of their measures is at most `ε / 2`, completing the proof. -/\n  obtain ⟨u, su, u_open, μu⟩ : ∃ U ⊇ s, is_open U ∧ μ U ≤ μ s + ε / 2 :=\n    set.exists_is_open_le_add _ _ (by simpa only [or_false, ne.def, ennreal.div_zero_iff,\n      ennreal.one_ne_top, ennreal.bit0_eq_top_iff] using hε),\n  have : ∀ x ∈ s, ∃ R > 0, ball x R ⊆ u :=\n    λ x hx, metric.mem_nhds_iff.1 (u_open.mem_nhds (su hx)),\n  choose! R hR using this,\n  obtain ⟨t0, r0, t0_count, t0s, hr0, μt0, t0_disj⟩ :\n    ∃ (t0 : set α) (r0 : α → ℝ), t0.countable ∧ t0 ⊆ s ∧ (∀ x ∈ t0, r0 x ∈ f x ∩ Ioo 0 (R x))\n      ∧ μ (s \\ (⋃ (x ∈ t0), closed_ball x (r0 x))) = 0\n      ∧ t0.pairwise_disjoint (λ x, closed_ball x (r0 x)) :=\n        exists_disjoint_closed_ball_covering_ae μ f s hf R (λ x hx, (hR x hx).1),\n  -- we have constructed an almost everywhere covering of `s` by disjoint balls. Let `s'` be the\n  -- remaining set.\n  let s' := s \\ (⋃ (x ∈ t0), closed_ball x (r0 x)),\n  have s's : s' ⊆ s := diff_subset _ _,\n  obtain ⟨N, τ, hτ, H⟩ : ∃ N τ, 1 < τ ∧ is_empty (besicovitch.satellite_config α N τ) :=\n    has_besicovitch_covering.no_satellite_config α,\n  obtain ⟨v, s'v, v_open, μv⟩ : ∃ v ⊇ s', is_open v ∧ μ v ≤ μ s' + (ε / 2) / N :=\n    set.exists_is_open_le_add _ _\n      (by simp only [hε, ennreal.nat_ne_top, with_top.mul_eq_top_iff, ne.def, ennreal.div_zero_iff,\n        ennreal.one_ne_top, not_false_iff, and_false, false_and, or_self, ennreal.bit0_eq_top_iff]),\n  have : ∀ x ∈ s', ∃ r1 ∈ (f x ∩ Ioo (0 : ℝ) 1), closed_ball x r1 ⊆ v,\n  { assume x hx,\n    rcases metric.mem_nhds_iff.1 (v_open.mem_nhds (s'v hx)) with ⟨r, rpos, hr⟩,\n    rcases hf x (s's hx) (min r 1) (lt_min rpos zero_lt_one) with ⟨R', hR'⟩,\n    exact ⟨R', ⟨hR'.1, hR'.2.1, hR'.2.2.trans_le (min_le_right _ _)⟩,\n      subset.trans (closed_ball_subset_ball (hR'.2.2.trans_le (min_le_left _ _))) hr⟩, },\n  choose! r1 hr1 using this,\n  let q : ball_package s' α :=\n  { c := λ x, x,\n    r := λ x, r1 x,\n    rpos := λ x, (hr1 x.1 x.2).1.2.1,\n    r_bound := 1,\n    r_le := λ x, (hr1 x.1 x.2).1.2.2.le },\n  -- by Besicovitch, we cover `s'` with at most `N` families of disjoint balls, all included in\n  -- a suitable neighborhood `v` of `s'`.\n  obtain ⟨S, S_disj, hS⟩ : ∃ S : fin N → set s',\n    (∀ (i : fin N), (S i).pairwise_disjoint (λ j, closed_ball (q.c j) (q.r j))) ∧\n      (range q.c ⊆ ⋃ (i : fin N), ⋃ (j ∈ S i), ball (q.c j) (q.r j)) :=\n    exist_disjoint_covering_families hτ H q,\n  have S_count : ∀ i, (S i).countable,\n  { assume i,\n    apply (S_disj i).countable_of_nonempty_interior (λ j hj, _),\n    have : (ball (j : α) (r1 j)).nonempty := nonempty_ball.2 (q.rpos _),\n    exact this.mono ball_subset_interior_closed_ball },\n  let r := λ x, if x ∈ s' then r1 x else r0 x,\n  have r_t0 : ∀ x ∈ t0, r x = r0 x,\n  { assume x hx,\n    have : ¬ (x ∈ s'),\n    { simp only [not_exists, exists_prop, mem_Union, mem_closed_ball, not_and, not_lt,\n                  not_le, mem_diff, not_forall],\n      assume h'x,\n      refine ⟨x, hx, _⟩,\n      rw dist_self,\n      exact (hr0 x hx).2.1.le },\n    simp only [r, if_neg this] },\n  -- the desired covering set is given by the union of the families constructed in the first and\n  -- second steps.\n  refine ⟨t0 ∪ (⋃ (i : fin N), (coe : s' → α) '' (S i)), r, _, _, _, _, _⟩,\n  -- it remains to check that they have the desired properties\n  { exact t0_count.union (countable_Union (λ i, (S_count i).image _)) },\n  { simp only [t0s, true_and, union_subset_iff, image_subset_iff, Union_subset_iff],\n    assume i x hx,\n    exact s's x.2 },\n  { assume x hx,\n    cases hx,\n    { rw r_t0 x hx,\n      exact (hr0 _ hx).1 },\n    { have h'x : x ∈ s',\n      { simp only [mem_Union, mem_image] at hx,\n        rcases hx with ⟨i, y, ySi, rfl⟩,\n        exact y.2 },\n      simp only [r, if_pos h'x, (hr1 x h'x).1.1] } },\n  { assume x hx,\n    by_cases h'x : x ∈ s',\n    { obtain ⟨i, y, ySi, xy⟩ : ∃ (i : fin N) (y : ↥s') (ySi : y ∈ S i), x ∈ ball (y : α) (r1 y),\n      { have A : x ∈ range q.c, by simpa only [not_exists, exists_prop, mem_Union, mem_closed_ball,\n          not_and, not_le, mem_set_of_eq, subtype.range_coe_subtype, mem_diff] using h'x,\n        simpa only [mem_Union, mem_image] using hS A },\n      refine mem_Union₂.2 ⟨y, or.inr _, _⟩,\n      { simp only [mem_Union, mem_image],\n        exact ⟨i, y, ySi, rfl⟩ },\n      { have : (y : α) ∈ s' := y.2,\n        simp only [r, if_pos this],\n        exact ball_subset_closed_ball xy } },\n    { obtain ⟨y, yt0, hxy⟩ : ∃ (y : α), y ∈ t0 ∧ x ∈ closed_ball y (r0 y),\n        by simpa [hx, -mem_closed_ball] using h'x,\n      refine mem_Union₂.2 ⟨y, or.inl yt0, _⟩,\n      rwa r_t0 _ yt0 } },\n  -- the only nontrivial property is the measure control, which we check now\n  { -- the sets in the first step have measure at most `μ s + ε / 2`\n    have A : ∑' (x : t0), μ (closed_ball x (r x)) ≤ μ s + ε / 2 := calc\n      ∑' (x : t0), μ (closed_ball x (r x))\n      = ∑' (x : t0), μ (closed_ball x (r0 x)) :\n        by { congr' 1, ext x, rw r_t0 x x.2 }\n      ... = μ (⋃ (x : t0), closed_ball x (r0 x)) :\n        begin\n          haveI : encodable t0 := t0_count.to_encodable,\n          rw measure_Union,\n          { exact (pairwise_subtype_iff_pairwise_set _ _).2 t0_disj },\n          { exact λ i, measurable_set_closed_ball }\n        end\n      ... ≤ μ u :\n        begin\n          apply measure_mono,\n          simp only [set_coe.forall, subtype.coe_mk, Union_subset_iff],\n          assume x hx,\n          apply subset.trans (closed_ball_subset_ball (hr0 x hx).2.2) (hR x (t0s hx)).2,\n        end\n      ... ≤ μ s + ε / 2 : μu,\n    -- each subfamily in the second step has measure at most `ε / (2 N)`.\n    have B : ∀ (i : fin N),\n      ∑' (x : (coe : s' → α) '' (S i)), μ (closed_ball x (r x)) ≤ (ε / 2) / N := λ i, calc\n      ∑' (x : (coe : s' → α) '' (S i)), μ (closed_ball x (r x)) =\n            ∑' (x : S i), μ (closed_ball x (r x)) :\n        begin\n          have : inj_on (coe : s' → α) (S i) := subtype.coe_injective.inj_on _,\n          let F : S i ≃ (coe : s' → α) '' (S i) := this.bij_on_image.equiv _,\n          exact (F.tsum_eq (λ x, μ (closed_ball x (r x)))).symm,\n        end\n      ... = ∑' (x : S i), μ (closed_ball x (r1 x)) :\n        by { congr' 1, ext x, have : (x : α) ∈ s' := x.1.2, simp only [r, if_pos this] }\n      ... = μ (⋃ (x : S i), closed_ball x (r1 x)) :\n        begin\n          haveI : encodable (S i) := (S_count i).to_encodable,\n          rw measure_Union,\n          { exact (pairwise_subtype_iff_pairwise_set _ _).2 (S_disj i) },\n          { exact λ i, measurable_set_closed_ball }\n        end\n      ... ≤ μ v :\n        begin\n          apply measure_mono,\n          simp only [set_coe.forall, subtype.coe_mk, Union_subset_iff],\n          assume x xs' xSi,\n          exact (hr1 x xs').2,\n        end\n      ... ≤ (ε / 2) / N : by { have : μ s' = 0 := μt0, rwa [this, zero_add] at μv },\n    -- add up all these to prove the desired estimate\n    calc ∑' (x : (t0 ∪ ⋃ (i : fin N), (coe : s' → α) '' S i)), μ (closed_ball x (r x))\n        ≤ ∑' (x : t0), μ (closed_ball x (r x))\n          + ∑' (x : ⋃ (i : fin N), (coe : s' → α) '' S i), μ (closed_ball x (r x)) :\n            ennreal.tsum_union_le (λ x, μ (closed_ball x (r x))) _ _\n    ... ≤ ∑' (x : t0), μ (closed_ball x (r x))\n          + ∑ (i : fin N), ∑' (x : (coe : s' → α) '' S i), μ (closed_ball x (r x)) :\n            add_le_add le_rfl (ennreal.tsum_Union_le (λ x, μ (closed_ball x (r x))) _)\n    ... ≤ (μ s + ε / 2) + ∑ (i : fin N), (ε / 2) / N :\n      begin\n        refine add_le_add A _,\n        refine finset.sum_le_sum _,\n        assume i hi,\n        exact B i\n      end\n    ... ≤ (μ s + ε / 2) + ε / 2 :\n      begin\n        refine add_le_add le_rfl _,\n        simp only [finset.card_fin, finset.sum_const, nsmul_eq_mul, ennreal.mul_div_le],\n      end\n    ... = μ s + ε : by rw [add_assoc, ennreal.add_halves] }\nend\n\n/-! ### Consequences on differentiation of measures -/\n\n/-- In a space with the Besicovitch covering property, the set of closed balls with positive radius\nforms a Vitali family. This is essentially a restatement of the measurable Besicovitch theorem. -/\nprotected def vitali_family (μ : measure α) [sigma_finite μ] :\n  vitali_family μ :=\n{ sets_at := λ x, (λ (r : ℝ), closed_ball x r) '' (Ioi (0 : ℝ)),\n  measurable_set' := begin\n    assume x y hy,\n    obtain ⟨r, rpos, rfl⟩ : ∃ (r : ℝ), 0 < r ∧ closed_ball x r = y,\n      by simpa only [mem_image, mem_Ioi] using hy,\n    exact is_closed_ball.measurable_set\n  end,\n  nonempty_interior := begin\n    assume x y hy,\n    obtain ⟨r, rpos, rfl⟩ : ∃ (r : ℝ), 0 < r ∧ closed_ball x r = y,\n      by simpa only [mem_image, mem_Ioi] using hy,\n    simp only [nonempty.mono ball_subset_interior_closed_ball, rpos, nonempty_ball],\n  end,\n  nontrivial := λ x ε εpos, ⟨closed_ball x ε, mem_image_of_mem _ εpos, subset.refl _⟩,\n  covering := begin\n    assume s f fsubset ffine,\n    let g : α → set ℝ := λ x, {r | 0 < r ∧ closed_ball x r ∈ f x},\n    have A : ∀ x ∈ s, ∀ δ > 0, (g x ∩ Ioo 0 δ).nonempty,\n    { assume x xs δ δpos,\n      obtain ⟨t, tf, ht⟩ : ∃ (t : set α) (H : t ∈ f x), t ⊆ closed_ball x (δ/2) :=\n        ffine x xs (δ/2) (half_pos δpos),\n      obtain ⟨r, rpos, rfl⟩ : ∃ (r : ℝ), 0 < r ∧ closed_ball x r = t,\n        by simpa using fsubset x xs tf,\n      rcases le_total r (δ/2) with H|H,\n      { exact ⟨r, ⟨rpos, tf⟩, ⟨rpos, H.trans_lt (half_lt_self δpos)⟩⟩ },\n      { have : closed_ball x r = closed_ball x (δ/2) :=\n          subset.antisymm ht (closed_ball_subset_closed_ball H),\n        rw this at tf,\n        refine ⟨δ/2, ⟨half_pos δpos, tf⟩, ⟨half_pos δpos, half_lt_self δpos⟩⟩ } },\n    obtain ⟨t, r, t_count, ts, tg, μt, tdisj⟩ : ∃ (t : set α) (r : α → ℝ), t.countable\n      ∧ t ⊆ s ∧ (∀ x ∈ t, r x ∈ g x ∩ Ioo 0 1)\n      ∧ μ (s \\ (⋃ (x ∈ t), closed_ball x (r x))) = 0\n      ∧ t.pairwise_disjoint (λ x, closed_ball x (r x)) :=\n        exists_disjoint_closed_ball_covering_ae μ g s A (λ _, 1) (λ _ _, zero_lt_one),\n    let F : α → α × set α := λ x, (x, closed_ball x (r x)),\n    refine ⟨F '' t, _, _, _, _⟩,\n    { rintros - ⟨x, hx, rfl⟩, exact ts hx },\n    { rintros p ⟨x, hx, rfl⟩ q ⟨y, hy, rfl⟩ hxy,\n      exact tdisj hx hy (ne_of_apply_ne F hxy) },\n    { rintros - ⟨x, hx, rfl⟩, exact (tg x hx).1.2 },\n    { rwa bUnion_image }\n  end }\n\n/-- The main feature of the Besicovitch Vitali family is that its filter at a point `x` corresponds\nto convergence along closed balls. We record one of the two implications here, which will enable us\nto deduce specific statements on differentiation of measures in this context from the general\nversions. -/\nlemma tendsto_filter_at (μ : measure α) [sigma_finite μ] (x : α) :\n  tendsto (λ r, closed_ball x r) (𝓝[>] 0) ((besicovitch.vitali_family μ).filter_at x) :=\nbegin\n  assume s hs,\n  simp only [mem_map],\n  obtain ⟨ε, εpos, hε⟩ : ∃ (ε : ℝ) (H : ε > 0), ∀ (a : set α),\n    a ∈ (besicovitch.vitali_family μ).sets_at x → a ⊆ closed_ball x ε → a ∈ s :=\n      (vitali_family.mem_filter_at_iff _).1 hs,\n  have : Ioc (0 : ℝ) ε ∈ 𝓝[>] (0 : ℝ) := Ioc_mem_nhds_within_Ioi ⟨le_rfl, εpos⟩,\n  filter_upwards [this] with _ hr,\n  apply hε,\n  { exact mem_image_of_mem _ hr.1 },\n  { exact closed_ball_subset_closed_ball hr.2 }\nend\n\nvariables [metric_space β] [measurable_space β] [borel_space β] [second_countable_topology β]\n  [has_besicovitch_covering β]\n\n/-- In a space with the Besicovitch covering property, the ratio of the measure of balls converges\nalmost surely to to the Radon-Nikodym derivative. -/\nlemma ae_tendsto_rn_deriv\n  (ρ μ : measure β) [is_locally_finite_measure μ] [is_locally_finite_measure ρ] :\n  ∀ᵐ x ∂μ, tendsto (λ r, ρ (closed_ball x r) / μ (closed_ball x r))\n    (𝓝[>] 0) (𝓝 (ρ.rn_deriv μ x)) :=\nbegin\n  filter_upwards [vitali_family.ae_tendsto_rn_deriv (besicovitch.vitali_family μ) ρ] with x hx,\n  exact hx.comp (tendsto_filter_at μ x)\nend\n\n/-- Given a measurable set `s`, then `μ (s ∩ closed_ball x r) / μ (closed_ball x r)` converges when\n`r` tends to `0`, for almost every `x`. The limit is `1` for `x ∈ s` and `0` for `x ∉ s`.\nThis shows that almost every point of `s` is a Lebesgue density point for `s`.\nA version for non-measurable sets holds, but it only gives the first conclusion,\nsee `ae_tendsto_measure_inter_div`. -/\nlemma ae_tendsto_measure_inter_div_of_measurable_set\n  (μ : measure β) [is_locally_finite_measure μ] {s : set β} (hs : measurable_set s) :\n  ∀ᵐ x ∂μ, tendsto (λ r, μ (s ∩ closed_ball x r) / μ (closed_ball x r))\n    (𝓝[>] 0) (𝓝 (s.indicator 1 x)) :=\nbegin\n  filter_upwards [vitali_family.ae_tendsto_measure_inter_div_of_measurable_set\n    (besicovitch.vitali_family μ) hs],\n  assume x hx,\n  exact hx.comp (tendsto_filter_at μ x)\nend\n\n/-- Given an arbitrary set `s`, then `μ (s ∩ closed_ball x r) / μ (closed_ball x r)` converges\nto `1` when `r` tends to `0`, for almost every `x` in `s`.\nThis shows that almost every point of `s` is a Lebesgue density point for `s`.\nA stronger version holds for measurable sets, see `ae_tendsto_measure_inter_div_of_measurable_set`.\n\nSee also `is_doubling_measure.ae_tendsto_measure_inter_div`. -/\nlemma ae_tendsto_measure_inter_div (μ : measure β) [is_locally_finite_measure μ] (s : set β) :\n  ∀ᵐ x ∂(μ.restrict s), tendsto (λ r, μ (s ∩ (closed_ball x r)) / μ (closed_ball x r))\n    (𝓝[>] 0) (𝓝 1) :=\nby filter_upwards [vitali_family.ae_tendsto_measure_inter_div (besicovitch.vitali_family μ)]\n    with x hx using hx.comp (tendsto_filter_at μ x)\n\nend besicovitch\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/measure_theory/covering/besicovitch.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649232, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4561437358080873}}
{"text": "import Runtime.Utilities.Extensions\n\n/-- An event type is a type which has an identifier and an associated time stamp. -/\nclass EventType (α : Type _) where\n  Id : Type\n  id : α → Id\n  time : α → Time\n  [decEqId : DecidableEq Id]\n\nattribute [instance] EventType.decEqId\n\n-- TODO: Use `List.Sorted` once it arrives in Mathlib.\ninductive Queue.Sorted [inst : EventType ε] : List ε → Prop\n  | nil : Sorted []\n  | singleton : Sorted [e]\n  | cons : (inst.time fst ≤ inst.time snd) → Sorted (snd :: tl) → Sorted (hd :: snd :: tl)\n\n/--\nA queue is a sorted list of events where each event has a time stamp greater or equal to a given\nlower `bound`.\n-/\nstructure Queue (ε : Type) [inst : EventType ε] (bound : Time) where\n  events : Array ε\n  sorted : Queue.Sorted events.data\n  bounded : ∀ {event}, (events[0]? = some event) → bound ≤ inst.time event\n  -- TODO: Add the property:\n  -- ∀ {event₁ event₂}, (event₁ ∈ events) → (event₂ ∈ events) → (time event₁ > bound) →\n  --                    (time event₁ ≠ time event₂) ∨ (id event₁ ≠ id event₂)\n\nnamespace Queue\nopen EventType\n\nvariable [EventType ε]\n\n@[reducible]\ninstance : Membership ε (Queue ε bound) where\n  mem e q := e ∈ q.events.data\n\n-- TODO: What's the story for theorems about `Array`s in Lean 4?\ntheorem all_events_bounded {queue : Queue ε bound} :\n  ∀ {event}, event ∈ queue.events.data → bound ≤ time event := by\n  sorry\n\n/-- A queue is empty if its underlying list of events is empty. -/\ndef isEmpty (q : Queue ε bound) : Bool := q.events.isEmpty\n\n/-- The size of a queue is the number of its events. -/\ndef size (q : Queue ε bound) : Nat := q.events.size\n\ninstance : GetElem (Queue ε bound) Nat { e : ε // bound ≤ time e } (fun q i => i < q.size) where\n  getElem queue i _ := {\n    val := queue.events[i]\n    property := sorry\n  }\n\n@[simp]\ntheorem getElem?_some_events_getElem?_some {queue : Queue ε bound} {i : Nat} :\n  (queue[i]? = some event) → (queue.events[i]? = event.val) := by\n  intro h\n  sorry\n\n@[simp]\ntheorem getElem?_none_events_getElem?_none {queue : Queue ε bound} {i : Nat} :\n  (queue[i]? = none) → (queue.events[i]? = none) := by\n  intro h\n  sorry\n\n/-- Creates an empty queue. -/\ndef nil : Queue ε bound where\n  events := #[]\n  sorted := .nil\n  bounded := by simp\n\nnotation \"°[]\" => Queue.nil\n\ninstance : Inhabited (Queue ε bound) where\n  default := °[]\n\n/-- Creates a queue with a single event. -/\ndef singleton (event : ε) (h : bound ≤ time event) : Queue ε bound where\n  events := #[event]\n  sorted := .singleton\n  bounded := by intros; simp_all\n\nnotation \"°[\" e \"]' \" h => Queue.singleton e h\n\n/--\nCreates a queue from an array of events by sorting its elements. The time bound fulfilled trivially\nby choosing it to be 0.\n-/\ndef sorting (events : Array ε) : Queue ε 0 where\n  events := events.insertionSort (time · ≤ time ·)\n  sorted := sorry\n  bounded := by intros; simp\n\n/--\nThe \"next time\" of a queue is the time of its next event (if it exists).\n\n*Note:* The next event is considered to be the one at index 0.\n-/\ndef nextTime (queue : Queue ε bound) : Option (Time.From bound) :=\n  match queue[0]? with\n  | none => none\n  | some nextEvent => some {\n      val := time nextEvent.val\n      property := by have := nextEvent.property; simp_all [EventType.time]\n    }\n\ntheorem nextTime_some {queue : Queue ε bound} :\n  (queue.nextTime = some next) →\n  (∃ event, queue[0]? = some event ∧ (time event.val) ≥ next.val) := by\n  intro h\n  unfold nextTime at h\n  split at h <;> simp at h\n  case _ event h' =>\n    exists event\n    apply And.intro h'\n    simp [←h]\n\ntheorem nextTime_isSome_iff_not_isEmpty {queue : Queue ε bound} :\n  queue.nextTime.isSome ↔ ¬queue.isEmpty := by\n  rw [Queue.isEmpty, ←Array.getElem?_zero_isSome_iff_not_isEmpty]\n  simp [nextTime]\n  constructor <;> split <;> simp_all [Option.isSome]\n  · simp [Queue.getElem?_some_events_getElem?_some ‹_›]\n\n/--\nSplits a queue into a list of \"next events\" and \"remaining events\".\n* \"Next events\" are those which have a time stamp matching the `nextTime` and are the first among\n  all events with the same id.\n* \"Remaining events\" are those which have a time stamp greater than the `nextTime` or have an event\n  in with the same id earlier in the queue.\n\nFor example, let's assume each event has the form `(time, id, value)`. Then the queue:\n```\n(10, a, 0) (10, a, 1) (10, b, 2) (11, a, 3)\n```\n... would be split into:\n* next events `(10, a, 0) (10, b, 2)`, and\n* remaining events `(10, a, 1) (11, a, 3)`.\n-/\ndef split\n  (queue : Queue ε bound) (anchor : Time) (h : ∀ next, queue.nextTime = some next → anchor ≤ next) :\n  Array ε × Queue ε anchor :=\n  let ⟨candidates, later⟩ := queue.events.split (time · = anchor)\n  let ⟨next, postponed⟩ := candidates.unique (EventType.id ·)\n  {\n    fst := next\n    snd := {\n      events := postponed ++ later\n      sorted := sorry\n      bounded := sorry\n    }\n  }\n\n-- *Note*: For adherence to the LF scheduling semantics, this operation overrides events of equal id\n--         and time, except those whose time is `bound`.\n--\n-- *Note:* It is important that this merge is stable. That is, it should be the same as would be\n-- produced by a stable sorting algorithm on input `queue₁ ++ queue₂`.\n-- TODO: Implement all of this properly once something like `Array.merge` arrives in Std.\ndef merge [inst : EventType ε] (queue₁ queue₂ : Queue ε bound) : Queue ε bound :=\n  if queue₁.isEmpty      then queue₂\n  else if queue₂.isEmpty then queue₁\n  else\n  -- Note, using `split` is inefficient as it traverses the entire array.\n  let ⟨immediate₁, future₁⟩ := queue₁.events.split (time · = bound)\n  let ⟨immediate₂, future₂⟩ := queue₂.events.split (time · = bound)\n  {\n    events := (mergeImmediate immediate₁ immediate₂) ++ (mergeFuture future₁ future₂)\n    sorted := sorry\n    bounded := sorry\n  }\nwhere\n  mergeImmediate (is₁ is₂ : Array ε) : Array ε :=\n    (is₁ ++ is₂).insertionSort (time · ≤ time ·)\n  mergeFuture (fs₁ fs₂ : Array ε) : Array ε :=\n    let fs₁' := fs₁.filter fun event₁ =>\n      ¬ fs₂.any fun event₂ =>\n        (inst.time event₁ = inst.time event₂) ∧\n        (inst.id event₁ = inst.id event₂)\n    (fs₁' ++ fs₂).insertionSort (time · ≤ time ·)\n\ntheorem merge_mem₂ {queue₁ queue₂ : Queue ε bound} :\n  (event ∈ queue₂) → (event ∈ queue₁.merge queue₂) := by\n  intro h\n  simp [merge]\n  split <;> try split\n  case inl => exact h\n  case inr.inl he =>\n    rw [isEmpty, Array.isEmpty_iff_data_eq_nil] at he\n    simp [Membership.mem, he] at h\n    contradiction\n  case inr.inr =>\n    by_cases time event = bound\n    case inl ht =>\n      -- `event` is in `immediate₂` and thus retained as part of `mergeImmediate`\n      sorry\n    case inr ht =>\n      -- `event` is in `future₂` and thus retained as part of `mergeFuture`\n      sorry\n\n/--\nMaps a queue of event type `ε` to a queue of event type `δ`. To ensure that the resulting queue is\nstill sorted and bounded, the map must preserve time stamps.\n-/\ndef map [EventType δ] (queue : Queue ε bound) (f : ε → δ) (h : ∀ e : ε, time e = time (f e)) :\n  Queue δ bound where\n  events := queue.events.map f\n  sorted := sorry\n  bounded := sorry\n\nnamespace Queue\n", "meta": {"author": "lf-lang", "repo": "reactor-lean", "sha": "d2eb5458446af838be34ebb6f69549b2f6d9c04d", "save_path": "github-repos/lean/lf-lang-reactor-lean", "path": "github-repos/lean/lf-lang-reactor-lean/reactor-lean-d2eb5458446af838be34ebb6f69549b2f6d9c04d/Runtime/Utilities/Queue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7371581510799253, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45613904046305076}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.structured_arrow\nimport category_theory.groupoid\nimport category_theory.punit\n\n/-!\n# The category of elements\n\nThis file defines the category of elements, also known as (a special case of) the Grothendieck\nconstruction.\n\nGiven a functor `F : C ⥤ Type`, an object of `F.elements` is a pair `(X : C, x : F.obj X)`.\nA morphism `(X, x) ⟶ (Y, y)` is a morphism `f : X ⟶ Y` in `C`, so `F.map f` takes `x` to `y`.\n\n## Implementation notes\n\nThis construction is equivalent to a special case of a comma construction, so this is mostly just a\nmore convenient API. We prove the equivalence in\n`category_theory.category_of_elements.structured_arrow_equivalence`.\n\n## References\n* [Emily Riehl, *Category Theory in Context*, Section 2.4][riehl2017]\n* <https://en.wikipedia.org/wiki/Category_of_elements>\n* <https://ncatlab.org/nlab/show/category+of+elements>\n\n## Tags\ncategory of elements, Grothendieck construction, comma category\n-/\n\nnamespace category_theory\n\nuniverses w v u\nvariables {C : Type u} [category.{v} C]\n\n/--\nThe type of objects for the category of elements of a functor `F : C ⥤ Type`\nis a pair `(X : C, x : F.obj X)`.\n-/\n@[nolint has_inhabited_instance]\ndef functor.elements (F : C ⥤ Type w) := (Σ c : C, F.obj c)\n\n/-- The category structure on `F.elements`, for `F : C ⥤ Type`.\n    A morphism `(X, x) ⟶ (Y, y)` is a morphism `f : X ⟶ Y` in `C`, so `F.map f` takes `x` to `y`.\n -/\ninstance category_of_elements (F : C ⥤ Type w) : category.{v} F.elements :=\n{ hom := λ p q, { f : p.1 ⟶ q.1 // (F.map f) p.2 = q.2 },\n  id := λ p, ⟨𝟙 p.1, by obviously⟩,\n  comp := λ p q r f g, ⟨f.val ≫ g.val, by obviously⟩ }\n\nnamespace category_of_elements\n\n@[ext]\nlemma ext (F : C ⥤ Type w) {x y : F.elements} (f g : x ⟶ y) (w : f.val = g.val) : f = g :=\nsubtype.ext_val w\n\n@[simp] lemma comp_val {F : C ⥤ Type w} {p q r : F.elements} {f : p ⟶ q} {g : q ⟶ r} :\n  (f ≫ g).val = f.val ≫ g.val := rfl\n\n@[simp] lemma id_val {F : C ⥤ Type w} {p : F.elements} : (𝟙 p : p ⟶ p).val = 𝟙 p.1 := rfl\n\nend category_of_elements\n\nnoncomputable\ninstance groupoid_of_elements {G : Type u} [groupoid.{v} G] (F : G ⥤ Type w) :\n  groupoid F.elements :=\n{ inv := λ p q f, ⟨inv f.val,\n      calc F.map (inv f.val) q.2 = F.map (inv f.val) (F.map f.val p.2) : by rw f.2\n                             ... = (F.map f.val ≫ F.map (inv f.val)) p.2 : by simp\n                             ... = p.2 : by {rw ←functor.map_comp, simp}⟩, }\n\nnamespace category_of_elements\nvariable (F : C ⥤ Type w)\n\n/-- The functor out of the category of elements which forgets the element. -/\n@[simps]\ndef π : F.elements ⥤ C :=\n{ obj := λ X, X.1,\n  map := λ X Y f, f.val }\n\n/--\nA natural transformation between functors induces a functor between the categories of elements.\n-/\n@[simps]\ndef map {F₁ F₂ : C ⥤ Type w} (α : F₁ ⟶ F₂) : F₁.elements ⥤ F₂.elements :=\n{ obj := λ t, ⟨t.1, α.app t.1 t.2⟩,\n  map := λ t₁ t₂ k, ⟨k.1, by simpa [←k.2] using (functor_to_types.naturality _ _ α k.1 t₁.2).symm⟩ }\n\n@[simp] lemma map_π {F₁ F₂ : C ⥤ Type w} (α : F₁ ⟶ F₂) : map α ⋙ π F₂ = π F₁ := rfl\n\n/-- The forward direction of the equivalence `F.elements ≅ (*, F)`. -/\ndef to_structured_arrow : F.elements ⥤ structured_arrow punit F :=\n{ obj := λ X, structured_arrow.mk (λ _, X.2),\n  map := λ X Y f, structured_arrow.hom_mk f.val (by tidy) }\n\n@[simp] lemma to_structured_arrow_obj (X) :\n  (to_structured_arrow F).obj X = { left := punit.star, right := X.1, hom := λ _, X.2 } := rfl\n@[simp] lemma to_comma_map_right {X Y} (f : X ⟶ Y) :\n  ((to_structured_arrow F).map f).right = f.val := rfl\n\n/-- The reverse direction of the equivalence `F.elements ≅ (*, F)`. -/\ndef from_structured_arrow : structured_arrow punit F ⥤ F.elements :=\n{ obj := λ X, ⟨X.right, X.hom (punit.star)⟩,\n  map := λ X Y f, ⟨f.right, congr_fun f.w'.symm punit.star⟩ }\n\n@[simp] lemma from_structured_arrow_obj (X) :\n  (from_structured_arrow F).obj X = ⟨X.right, X.hom (punit.star)⟩ := rfl\n@[simp] lemma from_structured_arrow_map {X Y} (f : X ⟶ Y) :\n  (from_structured_arrow F).map f = ⟨f.right, congr_fun f.w'.symm punit.star⟩ := rfl\n\n/-- The equivalence between the category of elements `F.elements`\n    and the comma category `(*, F)`. -/\n@[simps]\ndef structured_arrow_equivalence : F.elements ≌ structured_arrow punit F :=\nequivalence.mk (to_structured_arrow F) (from_structured_arrow F)\n  (nat_iso.of_components (λ X, eq_to_iso (by tidy)) (by tidy))\n  (nat_iso.of_components\n    (λ X, { hom := { right := 𝟙 _ }, inv := { right := 𝟙 _ } })\n    (by tidy))\n\nend category_of_elements\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/elements.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.4560476070318939}}
{"text": "import category_theory.category\nimport o_minimal.structure\nimport o_minimal.coordinates\n\nuniverse u\n\nnamespace o_minimal\n\nopen set\n\n-- Carrier for the (o-minimal) structure.\nvariables {R : Type u}\n\n-- A structure on `R`.\nvariables (S : struc R)\n\n/--\nA type with coordinates valued in R is *definable* with respect to a given structure S on R\nif the corresponding subset of Rⁿ is definable according to S.\n-/\nclass is_definable (X : Type*) [has_coordinates R X] : Prop :=\n(is_definable [] : S.definable (coordinate_image R X))\n\ninstance is_definable.self : is_definable S R :=\nbegin\n  constructor,\n  convert S.definable_univ 1,\n  ext,\n  simp [coordinate_image],\n  use (x 0),\n  ext i,\n  have : i = 0 := by cc,\n  subst i\nend\n\n-- TODO: Generalize to [is_definable S X] : is_definable S (finvec n X)\ninstance is_definable.rn {n : ℕ} : is_definable S (finvec n R) :=\nbegin\n  constructor,\n  convert S.definable_univ n,\n  ext,\n  simp [coordinate_image]\nend\n\nvariables {X : Type*} [has_coordinates R X] [is_definable S X]\nvariables {Y : Type*} [has_coordinates R Y] [is_definable S Y]\nvariables {Z : Type*} [has_coordinates R Z] [is_definable S Z]\nvariables {W : Type*} [has_coordinates R W] [is_definable S W]\n\ninstance is_definable.prod : is_definable S (X × Y) :=\nbegin\n  constructor,\n  rw coordinate_image_prod,\n  exact S.definable_external_prod (is_definable.is_definable S X) (is_definable.is_definable S Y)\nend\n\n-- TODO: instances matching the rest of has_coordinates\n\nsection definable_set\n/-\nWe first discuss what it means for \na subset `s : set X` to be definable\nwhen `X` is a definable type. -/\n\ndef def_set (s : set X) : Prop := S.definable (coords R '' s)\n\nvariables {S}\n\n/-- The subtype of a definable type determined by a definable set is definable.\nUnfortunately, this can't be a global instance because of the hypothesis `hs`. -/\ndef is_definable.subtype {s : set X} (hs : def_set S s) : is_definable S s :=\n{ is_definable := begin\n    unfold def_set at hs,\n    convert hs,\n    ext x,\n    simp [coordinate_image]\n  end }\n\nvariables (X)\n\nlemma def_set_empty : def_set S (∅ : set X) :=\nbegin\n  convert S.definable_empty _,\n  simp [def_set]\nend\n\nlemma def_set_univ : def_set S (set.univ : set X) :=\nby simpa [def_set] using is_definable.is_definable S X\n\nvariable {X}\n\nlemma def_set.inter {s t : set X} (hs : def_set S s) (ht : def_set S t) :\n  def_set S (s ∩ t) :=\nbegin\n  convert S.definable_inter hs ht,\n  simp [def_set, image_inter (injective_coords X)]\nend\n\nlemma def_set.union {s t : set X} (hs : def_set S s) (ht : def_set S t) :\n  def_set S (s ∪ t) :=\nbegin\n  convert S.definable_union hs ht,\n  simp [def_set, image_union]\nend\n\nlemma def_set.diff {s t : set X} (hs : def_set S s) (ht : def_set S t) :\n  def_set S (s \\ t) :=\nbegin\n  convert S.definable_diff hs ht,\n  simp [def_set, image_diff (injective_coords X)],\nend\n\nlemma def_set.compl {s : set X} (hs : def_set S s) : def_set S (sᶜ) :=\nby { rw compl_eq_univ_diff, exact (def_set_univ _).diff hs }\n\nlemma def_set.compl' {s : set X} (hs : def_set S sᶜ) : def_set S s :=\nby { rw ←compl_compl s, exact hs.compl }\n\nlemma def_set.iff {s t : set X} (hs : def_set S s) (ht : def_set S t) :\n  def_set S {x : X | x ∈ s ↔ x ∈ t} :=\nbegin\n  simp only [iff_iff_and_or_not_and_not],\n  exact (hs.inter ht).union (hs.compl.inter ht.compl)\nend\n\nlemma def_set_Inter {ι : Type*} [fintype ι] {t : ι → set X}\n  (ht : ∀ i, def_set S (t i)) : def_set S (⋂ i, t i) :=\nsuffices ∀ {s : set ι}, set.finite s → def_set S (⋂ i ∈ s, t i),\nby { convert this finite_univ, simp },\nλ s hs, finite.induction_on hs\n  (by { convert def_set_univ _, simp, apply_instance }) -- why is apply_instance needed here?\n  (λ i s _ _ IH, by { convert (ht i).inter IH, simp })\n\nlemma def_set_Union {ι : Type*} [fintype ι] {t : ι → set X}\n  (ht : ∀ i, def_set S (t i)) : def_set S (⋃ i, t i) :=\nbegin\n  apply def_set.compl',\n  rw compl_Union,\n  exact def_set_Inter (λ i, (ht i).compl)\nend\n\nlemma def_set.or {s t : X → Prop} (hs : def_set S {x : X | s x}) (ht : def_set S {x : X | t x}) :\n  def_set S {x | s x ∨ t x} :=\nhs.union ht\n\nlemma def_set.and {s t : X → Prop} (hs : def_set S {x : X | s x}) (ht : def_set S {x : X | t x}) :\n  def_set S {x | s x ∧ t x} :=\nhs.inter ht\n\nlemma def_set.not {s : X → Prop} (hs : def_set S {x : X | s x}) :\n  def_set S {x | ¬ s x} :=\nhs.compl\n\nlemma def_set.imp {s t : X → Prop} (hs : def_set S {x : X | s x}) (ht : def_set S {x : X | t x}) :\n  def_set S {x | s x → t x} :=\nbegin\n  simp [imp_iff_not_or], -- classical!\n  exact hs.not.or ht\nend\n\nlemma def_set.forall_fintype {ι : Type*} [fintype ι] {t : ι → set X}\n  (ht : ∀ i, def_set S (t i)) : def_set S {x | ∀ i, x ∈ t i} :=\nbegin\n  convert def_set_Inter ht using 1,\n  ext x,\n  simp\nend\n\nlemma def_set.exists_fintype {ι : Type*} [fintype ι] {t : ι → set X}\n  (ht : ∀ i, def_set S (t i)) : def_set S {x | ∃ i, x ∈ t i} :=\nbegin\n  convert def_set_Union ht using 1,\n  ext x,\n  simp\nend\n\nlemma def_set.proj {s : set (X × Y)} (hs : def_set S s) : def_set S (prod.fst '' s) :=\nbegin\n  unfold def_set,\n  convert S.definable_proj hs using 1,\n  ext z,\n  rw [image_image, image_image],\n  simp only [has_coordinates.prod_coords, finvec.left_append]\nend\n\n-- Is it better to use `{p : Y × X | s p.2 p.1}`?\n-- After all, Lean prefers to form `Z × Y × X = Z × (Y × X)`\nlemma def_set.exists {s : X → Y → Prop} (hs : def_set S {p : X × Y | s p.1 p.2}) :\n  def_set S {x | ∃ y, s x y} :=\nbegin\n  convert def_set.proj hs,\n  ext, simp\nend\n\nlemma def_set.forall {s : X → Y → Prop} (hs : def_set S {p : X × Y | s p.1 p.2}) :\n  def_set S {x | ∀ y, s x y} :=\nbegin\n  -- classical!!\n  have : ∀ (s : X → Y → Prop) (hs : def_set S {p : X × Y | s p.1 p.2}),\n    def_set S {x | ∀ y, ¬ s x y},\n  { intros t ht, simpa using ht.exists.not },\n  simpa using this (λ x y, ¬ s x y) hs.not,\nend\n\nlemma def_set.reindex {f : X → Y} (hf : is_reindexing R f)\n  {s : set Y} (hs : def_set S s) : def_set S (f ⁻¹' s) :=\nbegin\n  cases hf with fσ hf,\n  unfold def_set,\n  -- The preimage f ⁻¹' s, as a subset of the Rⁿ in which X lives,\n  -- is the intersection of X with the preimage of s under the reindexing.\n  convert S.definable_inter (is_definable.is_definable S X) (S.definable_reindex fσ hs),\n  ext z,\n  suffices : (∃ (x : X), f x ∈ s ∧ coords R x = z) ↔\n    z ∈ range (coords R) ∧ ∃ (y : Y), y ∈ s ∧ coords R y = z ∘ fσ,\n  { simpa },\n  -- TODO: funext'd version of `is_reindexing.hf`\n  replace hf : ∀ (x : X), coords R x ∘ fσ = coords R (f x) := λ x, funext (λ i, (hf x i)),\n  split,\n  { rintro ⟨x, hfx, rfl⟩,\n    refine ⟨mem_range_self _, f x, hfx, (hf x).symm⟩ },\n  { rintro ⟨⟨x, rfl⟩, y, hy, H⟩,\n    rw hf x at H,\n    replace hf := injective_coords _ H,\n    subst y,\n    exact ⟨x, hy, rfl⟩ }\nend\n\nlemma def_set_diag : def_set S {p : X × X | p.1 = p.2} :=\nbegin\n  unfold def_set,\n  -- The image of the diagonal of X in Rⁿ × Rⁿ\n  -- is the diagonal of Rⁿ intersected with X × X.\n  convert S.definable_inter\n    (S.definable_external_prod (is_definable.is_definable S X) (is_definable.is_definable S X))\n    S.definable_diag_rn,\n  ext z,\n  rw [mem_inter_iff, finvec.mem_prod_iff],\n  change _ ↔ _ ∧ finvec.left z = finvec.right z,\n  split,\n  { rintro ⟨⟨x, y⟩, h, rfl⟩,\n    change x = y at h,\n    simp [coordinate_image, h] },\n  { rintro ⟨⟨hz₁, _⟩, hz₂⟩,\n    rcases hz₁ with ⟨x, hx⟩,\n    refine ⟨⟨x, x⟩, rfl, _⟩,\n    convert finvec.left_append_right _,\n    refine finvec.append.inj_iff.mpr _,\n    simp [hx, hz₂] }\nend\n\nlemma def_set.prod_univ {s : set X} (hs : def_set S s) :\n  def_set S {p : X × Y | p.1 ∈ s} :=\ndef_set.reindex is_reindexing.fst hs\n\nlemma def_set.univ_prod {t : set Y} (ht : def_set S t) :\n  def_set S {p : X × Y | p.2 ∈ t} :=\ndef_set.reindex is_reindexing.snd ht\n\nlemma def_set.prod {s : set X} (hs : def_set S s) {t : set Y} (ht : def_set S t) :\n  def_set S (s.prod t) :=\nhs.prod_univ.inter ht.univ_prod\n\nend definable_set\n\nsection definable_fun\n-- Now we introduce definable functions between definable types.\n-- They are the functions whose graphs are definable sets.\n\n/-- A function f : X → Y is definable if its graph is a definable set. -/\ndef def_fun (f : X → Y) : Prop := def_set S {p : X × Y | f p.1 = p.2}\n\nvariables {S}\n\nlemma def_fun.id : def_fun S (id : X → X) :=\ndef_set_diag\n\nlemma def_fun.comp {g : Y → Z} (hg : def_fun S g) {f : X → Y} (hf : def_fun S f) :\n  def_fun S (g ∘ f) :=\nbegin\n  suffices : def_set S {p : X × Z | ∃ y, f p.1 = y ∧ g y = p.2},\n  { unfold def_fun,\n    convert this,\n    ext ⟨x, z⟩,\n    simp },\n  apply def_set.exists,\n  apply def_set.and,\n  { have : is_reindexing R (λ p : (X × Z) × Y, (p.1.1, p.2)),\n    { apply_rules [is_reindexing.prod, is_reindexing.fst, is_reindexing.snd, is_reindexing.comp] },\n    exact def_set.reindex this hf },\n  { have : is_reindexing R (λ p : (X × Z) × Y, (p.2, p.1.2)),\n    { apply_rules [is_reindexing.prod, is_reindexing.fst, is_reindexing.snd, is_reindexing.comp] },\n    exact def_set.reindex this hg }\nend\n\nlemma is_reindexing.def_fun {f : X → Y} (hf : is_reindexing R f) :\n  def_fun S f :=\nbegin\n  cases hf with fσ hf,\n  unfold def_fun,\n  unfold def_set,\n  convert S.definable_inter\n    (S.definable_prod_rn (is_definable.is_definable S X))\n    (S.definable_reindex_aux fσ (def_set_univ Y)),\n  ext z,\n  split,\n  { rintro ⟨⟨x, y⟩, h, rfl⟩,\n    change f x = y at h, subst y,\n    show _ ∧ _ ∧ _,\n    simp only [mem_range_self, and_true, image_univ, has_coordinates.prod_coords, finvec.left_append, finvec.right_append, finvec.append_mem_prod_univ_iff],\n    refine ⟨⟨x, _⟩, _⟩,\n    { simp },\n    { ext i,\n      apply hf, }, },\n  { rintro ⟨⟨x, hx⟩, ⟨hz, ⟨y, ⟨⟩, hy⟩⟩⟩,\n    simp only [mem_image, mem_set_of_eq],\n    use [(x,y)],\n    split,\n    { apply @injective_coords R,\n      ext i,\n      show coords R (f x) i = coords R y i,\n      rw ← hf,\n      rw [← hx, ← hy] at hz,\n      exact congr_fun hz i },\n    { simp [hx, hy] } }\nend\n\nlemma def_fun.preimage {f : X → Y} (hf : def_fun S f) {s : set Y} (hs : def_set S s) :\n  def_set S (f ⁻¹' s) :=\nbegin\n  -- f ⁻¹' s = {x | ∃ (p : X × Y), p.1 = x ∧ p ∈ Γ(f)}\n  convert def_set.proj (hf.inter ((def_set_univ _).prod hs)) using 1,\n  ext, simp\nend\n\nlemma def_fun.coords : def_fun S (λ x : X, coords R x) :=\nis_reindexing.def_fun is_reindexing.coords\n\nlemma def_fun.coord (i : fin (has_coordinates.ambdim R X)) : def_fun S (λ x : X, coords R x i) :=\nis_reindexing.def_fun (is_reindexing.coord i)\n\nlemma def_fun.coord_rn {n : ℕ} (i : fin n) : def_fun S (λ x : finvec n R, x i) :=\ndef_fun.coord i\n\nlemma def_fun.fst : def_fun S (prod.fst : X × Y → X) :=\nis_reindexing.def_fun is_reindexing.fst\n\nlemma def_fun.snd : def_fun S (prod.snd : X × Y → Y) :=\nis_reindexing.def_fun is_reindexing.snd\n\nlemma def_fun.prod' {f : X → Y} {g : X → Z} (hf : def_fun S f) (hg : def_fun S g) :\n  def_fun S (λ x, (f x, g x)) :=\nbegin\n  unfold def_fun,\n  let p1 : X × (Y × Z) → X × Y := λ p, (p.1, p.2.1),\n  have hp1 : def_fun S p1,\n  { apply is_reindexing.def_fun,\n    apply is_reindexing.fst.prod (is_reindexing.fst.comp is_reindexing.snd) },\n  let p2 : X × (Y × Z) → X × Z := λ p, (p.1, p.2.2),\n  have hp2 : def_fun S p2,\n  { apply is_reindexing.def_fun,\n    apply is_reindexing.fst.prod (is_reindexing.snd.comp is_reindexing.snd) },\n  convert (hp1.preimage hf).inter (hp2.preimage hg),\n  ext ⟨x,y,z⟩,\n  show (f x, g x) = (y,z) ↔ _,\n  simp only [mem_inter_eq, prod.mk.inj_iff, mem_set_of_eq, preimage_set_of_eq],\nend\n\nlemma def_fun.prod {f : X → Z} {g : Y → W} (hf : def_fun S f) (hg : def_fun S g) :\n  def_fun S (prod.map f g) :=\n(hf.comp def_fun.fst).prod' (hg.comp def_fun.snd)\n\nlemma def_fun_subtype_val {s : set X} {hs : def_set S s} :\n  by haveI := is_definable.subtype hs; exact\n  def_fun S (subtype.val : s → X) :=\nby haveI := is_definable.subtype hs; exact\nis_reindexing.subtype.val.def_fun\n\nlemma def_fun.finvec.left {n m : ℕ} : def_fun S (λ x : finvec (n+m) R, x.left) :=\nis_reindexing.finvec.left.def_fun\n\nlemma def_fun.finvec.right {n m : ℕ} : def_fun S (λ x : finvec (n+m) R, x.right) :=\nis_reindexing.finvec.right.def_fun\n\nlemma def_fun.finvec.init {n : ℕ} : def_fun S (λ x : finvec (n+1) R, x.init) :=\nis_reindexing.finvec.init.def_fun\n\nlemma def_fun.finvec.snoc' {n : ℕ} : def_fun S (λ p : finvec n R × R, p.1.snoc p.2) :=\nis_reindexing.finvec.snoc.def_fun\n\nlemma def_fun.finvec.snoc {n : ℕ} {f : X → finvec n R} (hf : def_fun S f) {g : X → R} (hg : def_fun S g) :\n  def_fun S (λ x, (f x).snoc (g x)) :=\ndef_fun.finvec.snoc'.comp (hf.prod' hg)\n\nlemma def_set_eq {f g : X → Y} (hf : def_fun S f) (hg : def_fun S g) :\n  def_set S {x | f x = g x} :=\n(hf.prod' hg).preimage def_set_diag\n\nlemma def_fun.cancel {g : Y → Z} (dg : def_fun S g) (hg : function.injective g)\n  {f : X → Y} (h : def_fun S (g ∘ f)) : def_fun S f :=\nbegin\n  unfold def_fun,\n  suffices : def_set S {p : X × Y | (g ∘ f) p.fst = g p.snd},\n  { convert ←this,\n    ext,\n    apply hg.eq_iff },\n  apply def_set_eq,\n  { exact h.comp def_fun.fst },\n  { exact dg.comp def_fun.snd }\nend\n\nlemma def_fun_subtype_mk {s : set X} {hs : def_set S s}\n  {f : Y → X} (df : def_fun S f) (h : ∀ y, f y ∈ s) :\n  by haveI := is_definable.subtype hs; exact\n  def_fun S (λ y, (⟨f y, h y⟩ : s)) :=\nby haveI := is_definable.subtype hs; exact\ndef_fun.cancel def_fun_subtype_val subtype.val_injective df\n\nlemma def_fun_subtype_iff {s : set X} {ds : def_set S s} {f : Y → s} :\n  by haveI := is_definable.subtype ds; exact\n  def_fun S f ↔ def_fun S (subtype.val ∘ f) :=\nby haveI := is_definable.subtype ds; exact\n⟨λ h, def_fun_subtype_val.comp h, λ h, def_fun_subtype_val.cancel subtype.val_injective h⟩\n\nlemma def_fun.image {f : X → Y} (hf : def_fun S f) {s : set X} (hs : def_set S s) :\n  def_set S (f '' s) :=\nshow def_set S {y | ∃ x, x ∈ s ∧ f x = y}, from\ndef_set.exists $\n  (def_fun.preimage def_fun.snd hs).and\n  (def_set_eq (hf.comp def_fun.snd) (def_fun.fst))\n\nlemma def_fun.range {f : X → Y} (hf : def_fun S f) : def_set S (range f) :=\nby { rw ←image_univ, exact hf.image (def_set_univ _) }\n\nend definable_fun\n\nsection definable_val\n-- Finally, a \"value\" (element) of X is definable\n-- if the corresponding singleton set is definable.\n--\n-- This notion is mostly used for bootstrapping\n-- because in the o-minimal project we're only interested in\n-- structures S on R in which every r ∈ R is definable,\n-- which forces every value of every definable type to be definable.\n\n/-- A value `x : X` is definable if `{x}` is definable. -/\ndef def_val (x : X) : Prop := def_set S ({x} : set X)\n\nvariables (S)\n\n/-- A structure `S` on `R` has *definable constants*\nif every `r : R` is definable. -/\nclass definable_constants : Prop :=\n(definable_val : ∀ (r : R), def_val S r)\n\nvariables {S}\n\n-- These primed lemmas take `def_val` arguments\n-- and have unprimed variants which use a `definable_constants S` assumption.\n\nlemma def_set_eq_const' {f : X → Y} (hf : def_fun S f) {y : Y} (hy : def_val S y) :\n  def_set S {x | f x = y} :=\nshow def_set S (f ⁻¹' {y}), from\nhf.preimage hy\n\nlemma def_set_const_eq' {f : X → Y} (hf : def_fun S f) {y : Y} (hy : def_val S y) :\n  def_set S {x | y = f x} :=\nby { convert def_set_eq_const' hf hy, simp_rw [eq_comm] }\n\nlemma def_fun_const' {y : Y} (hy : def_val S y) : def_fun S (λ (x : X), y) :=\ndef_set_const_eq' def_fun.snd hy\n\nlemma def_val_const [definable_constants S] {x : X} : def_val S x :=\nbegin\n  unfold def_val,\n  have : {x} = ⋂ i, {x' : X | coords R x' i = coords R x i},\n  { ext x',\n    rw [mem_singleton_iff, mem_Inter],\n    exact (@injective_coords R X _).eq_iff.symm.trans function.funext_iff },\n  rw this,\n  apply def_set_Inter,\n  intro i,\n  exact def_set_eq_const' (def_fun.coord i) (definable_constants.definable_val _)\nend\n\nlemma def_set_eq_const [definable_constants S] {f : X → Y} (hf : def_fun S f) (y : Y) :\n  def_set S {x | f x = y} :=\ndef_set_eq_const' hf def_val_const\n\nlemma def_set_const_eq [definable_constants S] {f : X → Y} (hf : def_fun S f) (y : Y) :\n  def_set S {x | y = f x} :=\ndef_set_const_eq' hf def_val_const\n\nlemma def_fun_const [definable_constants S] {y : Y} : def_fun S (λ (x : X), y) :=\ndef_fun_const' def_val_const\n\n-- TODO: more lemmas as needed.\n\nend definable_val\n\nend o_minimal\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/src/o_minimal/definable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417487156366, "lm_q2_score": 0.6926419831347362, "lm_q1q2_score": 0.4560475940345751}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro, Johannes Hölzl, Sander Dahmen\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.basis\nimport Mathlib.set_theory.cardinal_ordinal\nimport Mathlib.PostPort\n\nuniverses u v w w' m v' u_1 u₁ u₁' v'' \n\nnamespace Mathlib\n\n/-!\n# Dimension of modules and vector spaces\n\n## Main definitions\n\n* The dimension of a vector space is defined as `vector_space.dim : cardinal`.\n\n## Main statements\n\n* `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same\n  cardinality.\n* `dim_quotient_add_dim`: if V₁ is a submodule of V, then dim (V/V₁) + dim V₁ = dim V.\n* `dim_range_add_dim_ker`: the rank-nullity theorem.\n\n## Implementation notes\n\nMany theorems in this file are not universe-generic when they relate dimensions\nin different universes. They should be as general as they can be without\ninserting `lift`s. The types `V`, `V'`, ... all live in different universes,\nand `V₁`, `V₂`, ... all live in the same universe.\n-/\n\n/-- the dimension of a vector space, defined as a term of type `cardinal` -/\ndef vector_space.dim (K : Type u) (V : Type v) [field K] [add_comm_group V] [vector_space K V] :\n    cardinal :=\n  cardinal.min sorry\n    fun (b : Subtype fun (b : set V) => is_basis K fun (i : ↥b) => ↑i) =>\n      cardinal.mk ↥(subtype.val b)\n\ntheorem is_basis.le_span {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : ι → V} {J : set V} (hv : is_basis K v) (hJ : submodule.span K J = ⊤) :\n    cardinal.mk ↥(set.range v) ≤ cardinal.mk ↥J :=\n  sorry\n\n/-- dimension theorem -/\ntheorem mk_eq_mk_of_basis {K : Type u} {V : Type v} {ι : Type w} {ι' : Type w'} [field K]\n    [add_comm_group V] [vector_space K V] {v : ι → V} {v' : ι' → V} (hv : is_basis K v)\n    (hv' : is_basis K v') : cardinal.lift (cardinal.mk ι) = cardinal.lift (cardinal.mk ι') :=\n  sorry\n\ntheorem mk_eq_mk_of_basis' {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {ι' : Type w} {v : ι → V} {v' : ι' → V} (hv : is_basis K v)\n    (hv' : is_basis K v') : cardinal.mk ι = cardinal.mk ι' :=\n  iff.mp cardinal.lift_inj (mk_eq_mk_of_basis hv hv')\n\ntheorem is_basis.mk_eq_dim'' {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] {ι : Type v} {v : ι → V} (h : is_basis K v) :\n    cardinal.mk ι = vector_space.dim K V :=\n  sorry\n\ntheorem is_basis.mk_range_eq_dim {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : ι → V} (h : is_basis K v) :\n    cardinal.mk ↥(set.range v) = vector_space.dim K V :=\n  is_basis.mk_eq_dim'' (is_basis.range h)\n\ntheorem is_basis.mk_eq_dim {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : ι → V} (h : is_basis K v) :\n    cardinal.lift (cardinal.mk ι) = cardinal.lift (vector_space.dim K V) :=\n  sorry\n\ntheorem is_basis.mk_eq_dim' {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : ι → V} (h : is_basis K v) :\n    cardinal.lift (cardinal.mk ι) = cardinal.lift (vector_space.dim K V) :=\n  eq.mpr (id (propext cardinal.lift_max))\n    (eq.mp (Eq.refl (cardinal.lift (cardinal.mk ι) = cardinal.lift (vector_space.dim K V)))\n      (is_basis.mk_eq_dim h))\n\ntheorem dim_le {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] {n : ℕ}\n    (H : ∀ (s : finset V), (linear_independent K fun (i : ↥↑s) => ↑i) → finset.card s ≤ n) :\n    vector_space.dim K V ≤ ↑n :=\n  sorry\n\n/-- Two linearly equivalent vector spaces have the same dimension, a version with different\nuniverses. -/\ntheorem linear_equiv.lift_dim_eq {K : Type u} {V : Type v} {V' : Type v'} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V']\n    (f : linear_equiv K V V') :\n    cardinal.lift (vector_space.dim K V) = cardinal.lift (vector_space.dim K V') :=\n  sorry\n\n/-- Two linearly equivalent vector spaces have the same dimension. -/\ntheorem linear_equiv.dim_eq {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_equiv K V V₁) :\n    vector_space.dim K V = vector_space.dim K V₁ :=\n  iff.mp cardinal.lift_inj (linear_equiv.lift_dim_eq f)\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ntheorem nonempty_linear_equiv_of_lift_dim_eq {K : Type u} {V : Type v} {V' : Type v'} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V']\n    (cond : cardinal.lift (vector_space.dim K V) = cardinal.lift (vector_space.dim K V')) :\n    Nonempty (linear_equiv K V V') :=\n  sorry\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ntheorem nonempty_linear_equiv_of_dim_eq {K : Type u} {V : Type v} {V₁ : Type v} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V₁] [vector_space K V₁]\n    (cond : vector_space.dim K V = vector_space.dim K V₁) : Nonempty (linear_equiv K V V₁) :=\n  nonempty_linear_equiv_of_lift_dim_eq (congr_arg cardinal.lift cond)\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ndef linear_equiv.of_lift_dim_eq {K : Type u} (V : Type v) (V' : Type v') [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V']\n    (cond : cardinal.lift (vector_space.dim K V) = cardinal.lift (vector_space.dim K V')) :\n    linear_equiv K V V' :=\n  Classical.choice (nonempty_linear_equiv_of_lift_dim_eq cond)\n\n/-- Two vector spaces are isomorphic if they have the same dimension. -/\ndef linear_equiv.of_dim_eq {K : Type u} (V : Type v) (V₁ : Type v) [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁]\n    (cond : vector_space.dim K V = vector_space.dim K V₁) : linear_equiv K V V₁ :=\n  Classical.choice (nonempty_linear_equiv_of_dim_eq cond)\n\n/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/\ntheorem linear_equiv.nonempty_equiv_iff_lift_dim_eq {K : Type u} {V : Type v} {V' : Type v'}\n    [field K] [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V'] :\n    Nonempty (linear_equiv K V V') ↔\n        cardinal.lift (vector_space.dim K V) = cardinal.lift (vector_space.dim K V') :=\n  sorry\n\n/-- Two vector spaces are isomorphic if and only if they have the same dimension. -/\ntheorem linear_equiv.nonempty_equiv_iff_dim_eq {K : Type u} {V : Type v} {V₁ : Type v} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V₁] [vector_space K V₁] :\n    Nonempty (linear_equiv K V V₁) ↔ vector_space.dim K V = vector_space.dim K V₁ :=\n  sorry\n\n@[simp] theorem dim_bot {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] :\n    vector_space.dim K ↥⊥ = 0 :=\n  sorry\n\n@[simp] theorem dim_top {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] :\n    vector_space.dim K ↥⊤ = vector_space.dim K V :=\n  linear_equiv.dim_eq (linear_equiv.of_top ⊤ rfl)\n\ntheorem dim_of_field (K : Type u_1) [field K] : vector_space.dim K K = 1 := sorry\n\ntheorem dim_span {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : ι → V} (hv : linear_independent K v) :\n    vector_space.dim K ↥(submodule.span K (set.range v)) = cardinal.mk ↥(set.range v) :=\n  sorry\n\ntheorem dim_span_set {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    {s : set V} (hs : linear_independent K fun (x : ↥s) => ↑x) :\n    vector_space.dim K ↥(submodule.span K s) = cardinal.mk ↥s :=\n  sorry\n\ntheorem cardinal_lift_le_dim_of_linear_independent {K : Type u} {V : Type v} [field K]\n    [add_comm_group V] [vector_space K V] {ι : Type w} {v : ι → V} (hv : linear_independent K v) :\n    cardinal.lift (cardinal.mk ι) ≤ cardinal.lift (vector_space.dim K V) :=\n  sorry\n\ntheorem cardinal_le_dim_of_linear_independent {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] {ι : Type v} {v : ι → V} (hv : linear_independent K v) :\n    cardinal.mk ι ≤ vector_space.dim K V :=\n  eq.mpr (id (Eq.refl (cardinal.mk ι ≤ vector_space.dim K V)))\n    (eq.mp (propext cardinal.lift_le) (cardinal_lift_le_dim_of_linear_independent hv))\n\ntheorem cardinal_le_dim_of_linear_independent' {K : Type u} {V : Type v} [field K]\n    [add_comm_group V] [vector_space K V] {s : set V}\n    (hs : linear_independent K fun (x : ↥s) => ↑x) : cardinal.mk ↥s ≤ vector_space.dim K V :=\n  sorry\n\ntheorem dim_span_le {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    (s : set V) : vector_space.dim K ↥(submodule.span K s) ≤ cardinal.mk ↥s :=\n  sorry\n\ntheorem dim_span_of_finset {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    (s : finset V) : vector_space.dim K ↥(submodule.span K ↑s) < cardinal.omega :=\n  sorry\n\ntheorem dim_prod {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] :\n    vector_space.dim K (V × V₁) = vector_space.dim K V + vector_space.dim K V₁ :=\n  sorry\n\ntheorem dim_quotient_add_dim {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (p : submodule K V) :\n    vector_space.dim K (submodule.quotient p) + vector_space.dim K ↥p = vector_space.dim K V :=\n  sorry\n\ntheorem dim_quotient_le {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    (p : submodule K V) : vector_space.dim K (submodule.quotient p) ≤ vector_space.dim K V :=\n  sorry\n\n/-- rank-nullity theorem -/\ntheorem dim_range_add_dim_ker {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁) :\n    vector_space.dim K ↥(linear_map.range f) + vector_space.dim K ↥(linear_map.ker f) =\n        vector_space.dim K V :=\n  sorry\n\ntheorem dim_range_le {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁) :\n    vector_space.dim K ↥(linear_map.range f) ≤ vector_space.dim K V :=\n  sorry\n\ntheorem dim_map_le {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁)\n    (p : submodule K V) : vector_space.dim K ↥(submodule.map f p) ≤ vector_space.dim K ↥p :=\n  sorry\n\ntheorem dim_range_of_surjective {K : Type u} {V : Type v} {V' : Type v'} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V']\n    (f : linear_map K V V') (h : function.surjective ⇑f) :\n    vector_space.dim K ↥(linear_map.range f) = vector_space.dim K V' :=\n  sorry\n\ntheorem dim_eq_of_surjective {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁)\n    (h : function.surjective ⇑f) :\n    vector_space.dim K V = vector_space.dim K V₁ + vector_space.dim K ↥(linear_map.ker f) :=\n  sorry\n\ntheorem dim_le_of_surjective {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁)\n    (h : function.surjective ⇑f) : vector_space.dim K V₁ ≤ vector_space.dim K V :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (vector_space.dim K V₁ ≤ vector_space.dim K V))\n        (dim_eq_of_surjective f h)))\n    (self_le_add_right (vector_space.dim K V₁) (vector_space.dim K ↥(linear_map.ker f)))\n\ntheorem dim_eq_of_injective {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁)\n    (h : function.injective ⇑f) : vector_space.dim K V = vector_space.dim K ↥(linear_map.range f) :=\n  sorry\n\ntheorem dim_submodule_le {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    (s : submodule K V) : vector_space.dim K ↥s ≤ vector_space.dim K V :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (vector_space.dim K ↥s ≤ vector_space.dim K V))\n        (Eq.symm (dim_quotient_add_dim s))))\n    (self_le_add_left (vector_space.dim K ↥s) (vector_space.dim K (submodule.quotient s)))\n\ntheorem dim_le_of_injective {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁)\n    (h : function.injective ⇑f) : vector_space.dim K V ≤ vector_space.dim K V₁ :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (vector_space.dim K V ≤ vector_space.dim K V₁))\n        (dim_eq_of_injective f h)))\n    (dim_submodule_le (linear_map.range f))\n\ntheorem dim_le_of_submodule {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (s : submodule K V) (t : submodule K V) (h : s ≤ t) :\n    vector_space.dim K ↥s ≤ vector_space.dim K ↥t :=\n  sorry\n\ntheorem linear_independent_le_dim {K : Type u} {V : Type v} {ι : Type w} [field K]\n    [add_comm_group V] [vector_space K V] {v : ι → V} (hv : linear_independent K v) :\n    cardinal.lift (cardinal.mk ι) ≤ cardinal.lift (vector_space.dim K V) :=\n  sorry\n\ntheorem linear_independent_le_dim' {K : Type u} {V : Type v} {ι : Type w} [field K]\n    [add_comm_group V] [vector_space K V] {v : ι → V} (hs : linear_independent K v) :\n    cardinal.lift (cardinal.mk ι) ≤ cardinal.lift (vector_space.dim K V) :=\n  cardinal.mk_range_eq_lift (linear_independent.injective hs) ▸\n    dim_span hs ▸ iff.mpr cardinal.lift_le (dim_submodule_le (submodule.span K (set.range v)))\n\n/-- This is mostly an auxiliary lemma for `dim_sup_add_dim_inf_eq`. -/\ntheorem dim_add_dim_split {K : Type u} {V : Type v} {V₁ : Type v} {V₂ : Type v} {V₃ : Type v}\n    [field K] [add_comm_group V] [vector_space K V] [add_comm_group V₁] [vector_space K V₁]\n    [add_comm_group V₂] [vector_space K V₂] [add_comm_group V₃] [vector_space K V₃]\n    (db : linear_map K V₂ V) (eb : linear_map K V₃ V) (cd : linear_map K V₁ V₂)\n    (ce : linear_map K V₁ V₃) (hde : ⊤ ≤ linear_map.range db ⊔ linear_map.range eb)\n    (hgd : linear_map.ker cd = ⊥) (eq : linear_map.comp db cd = linear_map.comp eb ce)\n    (eq₂ :\n      ∀ (d : V₂) (e : V₃),\n        coe_fn db d = coe_fn eb e → ∃ (c : V₁), coe_fn cd c = d ∧ coe_fn ce c = e) :\n    vector_space.dim K V + vector_space.dim K V₁ = vector_space.dim K V₂ + vector_space.dim K V₃ :=\n  sorry\n\ntheorem dim_sup_add_dim_inf_eq {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (s : submodule K V) (t : submodule K V) :\n    vector_space.dim K ↥(s ⊔ t) + vector_space.dim K ↥(s ⊓ t) =\n        vector_space.dim K ↥s + vector_space.dim K ↥t :=\n  sorry\n\ntheorem dim_add_le_dim_add_dim {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (s : submodule K V) (t : submodule K V) :\n    vector_space.dim K ↥(s ⊔ t) ≤ vector_space.dim K ↥s + vector_space.dim K ↥t :=\n  sorry\n\ntheorem dim_pi {K : Type u} {η : Type u₁'} {φ : η → Type u_1} [field K] [fintype η]\n    [(i : η) → add_comm_group (φ i)] [(i : η) → vector_space K (φ i)] :\n    vector_space.dim K ((i : η) → φ i) = cardinal.sum fun (i : η) => vector_space.dim K (φ i) :=\n  sorry\n\ntheorem dim_fun {K : Type u} [field K] {V : Type u} {η : Type u} [fintype η] [add_comm_group V]\n    [vector_space K V] : vector_space.dim K (η → V) = ↑(fintype.card η) * vector_space.dim K V :=\n  sorry\n\ntheorem dim_fun_eq_lift_mul {K : Type u} {V : Type v} {η : Type u₁'} [field K] [add_comm_group V]\n    [vector_space K V] [fintype η] :\n    vector_space.dim K (η → V) = ↑(fintype.card η) * cardinal.lift (vector_space.dim K V) :=\n  sorry\n\ntheorem dim_fun' {K : Type u} {η : Type u₁'} [field K] [fintype η] :\n    vector_space.dim K (η → K) = ↑(fintype.card η) :=\n  sorry\n\ntheorem dim_fin_fun {K : Type u} [field K] (n : ℕ) : vector_space.dim K (fin n → K) = ↑n := sorry\n\ntheorem exists_mem_ne_zero_of_ne_bot {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] {s : submodule K V} (h : s ≠ ⊥) : ∃ (b : V), b ∈ s ∧ b ≠ 0 :=\n  sorry\n\ntheorem exists_mem_ne_zero_of_dim_pos {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] {s : submodule K V} (h : 0 < vector_space.dim K ↥s) :\n    ∃ (b : V), b ∈ s ∧ b ≠ 0 :=\n  sorry\n\ntheorem exists_is_basis_fintype {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (h : vector_space.dim K V < cardinal.omega) :\n    ∃ (s : set V), is_basis K subtype.val ∧ Nonempty (fintype ↥s) :=\n  sorry\n\n/-- `rank f` is the rank of a `linear_map f`, defined as the dimension of `f.range`. -/\ndef rank {K : Type u} {V : Type v} {V' : Type v'} [field K] [add_comm_group V] [vector_space K V]\n    [add_comm_group V'] [vector_space K V'] (f : linear_map K V V') : cardinal :=\n  vector_space.dim K ↥(linear_map.range f)\n\ntheorem rank_le_domain {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁) :\n    rank f ≤ vector_space.dim K V :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (rank f ≤ vector_space.dim K V)) (Eq.symm (dim_range_add_dim_ker f))))\n    (self_le_add_right (rank f) (vector_space.dim K ↥(linear_map.ker f)))\n\ntheorem rank_le_range {K : Type u} {V : Type v} {V₁ : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V₁] [vector_space K V₁] (f : linear_map K V V₁) :\n    rank f ≤ vector_space.dim K V₁ :=\n  dim_submodule_le (linear_map.range f)\n\ntheorem rank_add_le {K : Type u} {V : Type v} {V' : Type v'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V'] [vector_space K V'] (f : linear_map K V V')\n    (g : linear_map K V V') : rank (f + g) ≤ rank f + rank g :=\n  sorry\n\n@[simp] theorem rank_zero {K : Type u} {V : Type v} {V' : Type v'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V'] [vector_space K V'] : rank 0 = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (rank 0 = 0)) (rank.equations._eqn_1 0)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (vector_space.dim K ↥(linear_map.range 0) = 0)) linear_map.range_zero))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (vector_space.dim K ↥⊥ = 0)) dim_bot)) (Eq.refl 0)))\n\ntheorem rank_finset_sum_le {K : Type u} {V : Type v} {V' : Type v'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V'] [vector_space K V'] {η : Type u_1} (s : finset η)\n    (f : η → linear_map K V V') :\n    rank (finset.sum s fun (d : η) => f d) ≤ finset.sum s fun (d : η) => rank (f d) :=\n  finset.sum_hom_rel (le_of_eq rank_zero)\n    fun (i : η) (g : linear_map K V V') (c : cardinal) (h : rank g ≤ c) =>\n      le_trans (rank_add_le (f i) g) (add_le_add_left h (rank (f i)))\n\ntheorem rank_comp_le1 {K : Type u} {V : Type v} {V' : Type v'} {V'' : Type v''} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V']\n    [add_comm_group V''] [vector_space K V''] (g : linear_map K V V') (f : linear_map K V' V'') :\n    rank (linear_map.comp f g) ≤ rank f :=\n  sorry\n\ntheorem rank_comp_le2 {K : Type u} {V : Type v} {V' : Type v'} {V'₁ : Type v'} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V'] [vector_space K V']\n    [add_comm_group V'₁] [vector_space K V'₁] (g : linear_map K V V') (f : linear_map K V' V'₁) :\n    rank (linear_map.comp f g) ≤ rank g :=\n  sorry\n\ntheorem dim_zero_iff_forall_zero {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] : vector_space.dim K V = 0 ↔ ∀ (x : V), x = 0 :=\n  sorry\n\ntheorem dim_pos_iff_exists_ne_zero {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] : 0 < vector_space.dim K V ↔ ∃ (x : V), x ≠ 0 :=\n  sorry\n\ntheorem dim_pos_iff_nontrivial {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] : 0 < vector_space.dim K V ↔ nontrivial V :=\n  sorry\n\ntheorem dim_pos {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    [h : nontrivial V] : 0 < vector_space.dim K V :=\n  iff.mpr dim_pos_iff_nontrivial h\n\n/-- A vector space has dimension at most `1` if and only if there is a\nsingle vector of which all vectors are multiples. -/\ntheorem dim_le_one_iff {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] :\n    vector_space.dim K V ≤ 1 ↔ ∃ (v₀ : V), ∀ (v : V), ∃ (r : K), r • v₀ = v :=\n  sorry\n\n/-- A submodule has dimension at most `1` if and only if there is a\nsingle vector in the submodule such that the submodule is contained in\nits span. -/\ntheorem dim_submodule_le_one_iff {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (s : submodule K V) :\n    vector_space.dim K ↥s ≤ 1 ↔ ∃ (v₀ : V), ∃ (H : v₀ ∈ s), s ≤ submodule.span K (singleton v₀) :=\n  sorry\n\n/-- A submodule has dimension at most `1` if and only if there is a\nsingle vector, not necessarily in the submodule, such that the\nsubmodule is contained in its span. -/\ntheorem dim_submodule_le_one_iff' {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (s : submodule K V) :\n    vector_space.dim K ↥s ≤ 1 ↔ ∃ (v₀ : V), s ≤ submodule.span K (singleton v₀) :=\n  sorry\n\n/-- Version of linear_equiv.dim_eq without universe constraints. -/\ntheorem linear_equiv.dim_eq_lift {K : Type u} {V : Type v} {E : Type v'} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group E] [vector_space K E]\n    (f : linear_equiv K V E) :\n    cardinal.lift (vector_space.dim K V) = cardinal.lift (vector_space.dim K E) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/dimension_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.45591718566604256}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.geometry.manifold.algebra.smooth_functions\nimport Mathlib.linear_algebra.finite_dimensional\nimport Mathlib.analysis.normed_space.inner_product\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# Constructing examples of manifolds over ℝ\n\nWe introduce the necessary bits to be able to define manifolds modelled over `ℝ^n`, boundaryless\nor with boundary or with corners. As a concrete example, we construct explicitly the manifold with\nboundary structure on the real interval `[x, y]`.\n\nMore specifically, we introduce\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)` for the model space used\n  to define `n`-dimensional real manifolds with boundary\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n)` for the model space used\n  to define `n`-dimensional real manifolds with corners\n\n## Notations\n\nIn the locale `manifold`, we introduce the notations\n* `𝓡 n` for the identity model with corners on `euclidean_space ℝ (fin n)`\n* `𝓡∂ n` for `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space ℝ (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M → N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (𝓡 m) (𝓡∂ n) f` (as to why the\nmodel with corners can not be implicit, see the discussion in `smooth_manifold_with_corners.lean`).\n\n## Implementation notes\n\nThe manifold structure on the interval `[x, y] = Icc x y` requires the assumption `x < y` as a\ntypeclass. We provide it as `[fact (x < y)]`.\n-/\n\n/--\nThe half-space in `ℝ^n`, used to model manifolds with boundary. We only define it when\n`1 ≤ n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : ℕ) [HasZero (fin n)] :=\n  Subtype fun (x : euclidean_space ℝ (fin n)) => 0 ≤ x 0\n\n/--\nThe quadrant in `ℝ^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : ℕ) :=\n  Subtype fun (x : euclidean_space ℝ (fin n)) => ∀ (i : fin n), 0 ≤ x i\n\n/- Register class instances for euclidean half-space and quadrant, that can not be noticed\nwithout the following reducibility attribute (which is only set in this section). -/\n\nprotected instance euclidean_half_space.topological_space {n : ℕ} [HasZero (fin n)] : topological_space (euclidean_half_space n) :=\n  subtype.topological_space\n\nprotected instance euclidean_quadrant.topological_space {n : ℕ} : topological_space (euclidean_quadrant n) :=\n  subtype.topological_space\n\nprotected instance euclidean_half_space.inhabited {n : ℕ} [HasZero (fin n)] : Inhabited (euclidean_half_space n) :=\n  { default := { val := 0, property := sorry } }\n\nprotected instance euclidean_quadrant.inhabited {n : ℕ} : Inhabited (euclidean_quadrant n) :=\n  { default := { val := 0, property := sorry } }\n\ntheorem range_half_space (n : ℕ) [HasZero (fin n)] : (set.range fun (x : euclidean_half_space n) => subtype.val x) = set_of fun (x : euclidean_space ℝ (fin n)) => 0 ≤ x 0 := sorry\n\ntheorem range_quadrant (n : ℕ) : (set.range fun (x : euclidean_quadrant n) => subtype.val x) =\n  set_of fun (x : euclidean_space ℝ (fin n)) => ∀ (i : fin n), 0 ≤ x i := sorry\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_half_space n)`, used as a\nmodel for manifolds with boundary. In the locale `manifold`, use the shortcut `𝓡∂ n`.\n-/\ndef model_with_corners_euclidean_half_space (n : ℕ) [HasZero (fin n)] : model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n) :=\n  model_with_corners.mk\n    (local_equiv.mk (fun (x : euclidean_half_space n) => subtype.val x)\n      (fun (x : euclidean_space ℝ (fin n)) =>\n        { val := fun (i : fin n) => dite (i = 0) (fun (h : i = 0) => max (x i) 0) fun (h : ¬i = 0) => x i,\n          property := sorry })\n      set.univ (set.range fun (x : euclidean_half_space n) => subtype.val x) sorry sorry sorry sorry)\n    sorry sorry\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : ℕ) : model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n) :=\n  model_with_corners.mk\n    (local_equiv.mk (fun (x : euclidean_quadrant n) => subtype.val x)\n      (fun (x : euclidean_space ℝ (fin n)) => { val := fun (i : fin n) => max (x i) 0, property := sorry }) set.univ\n      (set.range fun (x : euclidean_quadrant n) => subtype.val x) sorry sorry sorry sorry)\n    sorry sorry\n\n/--\nThe left chart for the topological space `[x, y]`, defined on `[x,y)` and sending `x` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_left_chart (x : ℝ) (y : ℝ) [fact (x < y)] : local_homeomorph (↥(set.Icc x y)) (euclidean_half_space 1) :=\n  local_homeomorph.mk\n    (local_equiv.mk (fun (z : ↥(set.Icc x y)) => { val := fun (i : fin 1) => subtype.val z - x, property := sorry })\n      (fun (z : euclidean_half_space 1) => { val := min (subtype.val z 0 + x) y, property := sorry })\n      (set_of fun (z : ↥(set.Icc x y)) => subtype.val z < y)\n      (set_of fun (z : euclidean_half_space 1) => subtype.val z 0 < y - x) sorry sorry sorry sorry)\n    sorry sorry sorry sorry\n\n/--\nThe right chart for the topological space `[x, y]`, defined on `(x,y]` and sending `y` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_right_chart (x : ℝ) (y : ℝ) [fact (x < y)] : local_homeomorph (↥(set.Icc x y)) (euclidean_half_space 1) :=\n  local_homeomorph.mk\n    (local_equiv.mk (fun (z : ↥(set.Icc x y)) => { val := fun (i : fin 1) => y - subtype.val z, property := sorry })\n      (fun (z : euclidean_half_space 1) => { val := max (y - subtype.val z 0) x, property := sorry })\n      (set_of fun (z : ↥(set.Icc x y)) => x < subtype.val z)\n      (set_of fun (z : euclidean_half_space 1) => subtype.val z 0 < y - x) sorry sorry sorry sorry)\n    sorry sorry sorry sorry\n\n/--\nCharted space structure on `[x, y]`, using only two charts taking values in `euclidean_half_space 1`.\n-/\nprotected instance Icc_manifold (x : ℝ) (y : ℝ) [fact (x < y)] : charted_space (euclidean_half_space 1) ↥(set.Icc x y) :=\n  charted_space.mk (insert (Icc_left_chart x y) (singleton (Icc_right_chart x y)))\n    (fun (z : ↥(set.Icc x y)) => ite (subtype.val z < y) (Icc_left_chart x y) (Icc_right_chart x y)) sorry sorry\n\n/--\nThe manifold structure on `[x, y]` is smooth.\n-/\nprotected instance Icc_smooth_manifold (x : ℝ) (y : ℝ) [fact (x < y)] : smooth_manifold_with_corners (model_with_corners_euclidean_half_space 1) ↥(set.Icc x y) := sorry\n\n/-! Register the manifold structure on `Icc 0 1`, and also its zero and one. -/\n\ntheorem fact_zero_lt_one : fact (0 < 1) :=\n  zero_lt_one\n\nprotected instance set.Icc.charted_space : charted_space (euclidean_half_space 1) ↥(set.Icc 0 1) :=\n  Mathlib.Icc_manifold 0 1\n\nprotected instance set.Icc.smooth_manifold_with_corners : smooth_manifold_with_corners (model_with_corners_euclidean_half_space 1) ↥(set.Icc 0 1) :=\n  Mathlib.Icc_smooth_manifold 0 1\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/geometry/manifold/instances/real.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.4558081754702719}}
{"text": "\nimport Playlean4.Basic\nimport Playlean4.Group.Basic\nimport Playlean4.Group.Subgroup\nimport Playlean4.Group.Action\n\nset_option quotPrecheck.allowSectionVars true\n\nnamespace Group.Action.Remarkable\n\nnamespace OnSet\n\nvariable {G : Type} (law : G → G → G) [grp : Group G law]\n\nlocal infixl:70 \" * \" => id' law\n@[appUnexpander id'] def unexpandGMul : Lean.PrettyPrinter.Unexpander\n  | `(id' Magma.law G $x $y) => `($x * $y)\n  | _ => throw ()\nlocal notation \"one\" => grp.one' -- HACK\nlocal notation g\"⁻¹\" => grp.inv g\n\ndef leftTranslationOnSet : G → Set G → Set G := (liftToSet (onSelf law))\ndef rightTranslationOnSet : G → Set G → Set G := (@liftToSet G _ (onSelf (lawᵒᵖ)))\ndef conjugationOnSet : G → Set G → Set G := (liftToSet (conjugation law))\n\nlocal infix:70 \" •ₗ \" => leftTranslationOnSet law\nlocal notation:70 lhs:70 \" •ᵣ \" rhs:70 => rightTranslationOnSet law rhs lhs\nlocal infix:70 \" ••  \" => conjugationOnSet law\n\ninstance leftActionOnSet : Action G law (leftTranslationOnSet law) := actionOnSet _ _\n\ntheorem rightTranslationIdentity (P : Set G) : P •ᵣ one = P :=\n((@actionOnSet G (lawᵒᵖ) _ _ (onSelf (lawᵒᵖ)) _).identity P)\n\ntheorem rightTranslationCompat (g g' : G) (P : Set G) : (P •ᵣ (g * g')) = (P •ᵣ g) •ᵣ g' :=\n(@actionOnSet G (lawᵒᵖ) _ _ (onSelf (lawᵒᵖ)) _).compat g' g P\n\ntheorem translationCompat (g g' : G) (P : Set G) : (g •ₗ P) •ᵣ g' = g •ₗ (P •ᵣ g') :=\nby\n  simp only [leftTranslationOnSet, rightTranslationOnSet, liftToSet, Set.imgComp]\n  apply Set.imgCongrFun\n  funext x\n  suffices g * x * g' = g * (x * g') by exact this\n  simp\n\ntheorem conjugationCompat (g : G) (P : Set G) : g •• P = (g •ₗ P) •ᵣ g⁻¹ :=\nby\n  simp only [leftTranslationOnSet, rightTranslationOnSet, conjugationOnSet, liftToSet, Set.imgComp]\n  apply Set.imgCongrFun\n  rfl\n\ndef mulOnSet : Set G → Set G → Set G := λ P Q =>\n  λ h => ∃ g, g ∈ P ∧ ∃ g', g' ∈ Q ∧ h = g * g'\n\nlocal infixl:70 \" ** \" => mulOnSet law\n\ndef mulOnSetCompat₁ (P Q : Set G) (g : G) : P ** (g •ₗ Q) = (P •ᵣ g) ** Q :=\nby\n  funext x\n  apply propext\n  have p₁ : (P ** (g •ₗ Q)) x ↔ ∃ p, p ∈ P ∧ ∃ q, q ∈ Q ∧ x = p * (g * q)\n  by\n    apply Iff.intro\n    exact λ h => match h with\n      | ⟨ p, pIn, res, ⟨ q, qIn, resEq ⟩, xEq ⟩ =>\n        ⟨ p, pIn, q, qIn, xEq ▸ resEq ▸ rfl ⟩\n    exact λ h => match h with\n      | ⟨ p, pIn, q, qIn, h ⟩ =>\n        ⟨ p, pIn, g * q, ⟨ q, qIn, rfl ⟩, h ⟩\n  have p₂ : (∃ p, p ∈ P ∧ ∃ q, q ∈ Q ∧ x = p * g * q) ↔ ((P •ᵣ g) ** Q) x\n  by\n    apply Iff.intro\n    exact λ h => match h with\n      | ⟨ p, pIn, q, qIn, h ⟩ =>\n        ⟨ p * g, ⟨ p, pIn, rfl ⟩, q, qIn, h ⟩\n    exact λ h => match h with\n      | ⟨ res, ⟨ p, pIn, resEq ⟩, q, qIn, xEq ⟩ =>\n        ⟨ p, pIn, q, qIn, xEq ▸ resEq ▸ rfl ⟩\n  have p₃ : (∃ p, p ∈ P ∧ ∃ q, q ∈ Q ∧ x = p * (g * q)) ↔\n    ∃ p, p ∈ P ∧ ∃ q, q ∈ Q ∧ x = p * g * q\n  by simp\n  exact p₁.trans <| p₃.trans p₂\n\nend OnSet\n\nend Group.Action.Remarkable\n", "meta": {"author": "thejohncrafter", "repo": "playlean4", "sha": "81df180a71b8d84d0f45bc98db367aad203cf5df", "save_path": "github-repos/lean/thejohncrafter-playlean4", "path": "github-repos/lean/thejohncrafter-playlean4/playlean4-81df180a71b8d84d0f45bc98db367aad203cf5df/Playlean4/Group/OnSet.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4558081691965784}}
{"text": "/-\nCopyright (c) 2021 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\nimport algebraic_geometry.presheafed_space.has_colimits\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.preserves.shapes.pullbacks\nimport topology.sheaves.functors\nimport algebraic_geometry.Scheme\n\n/-!\n# Open immersions of structured spaces\n\nWe say that a morphism of presheafed spaces `f : X ⟶ Y` is an open immersions if\nthe underlying map of spaces is an open embedding `f : X ⟶ U ⊆ Y`,\nand the sheaf map `Y(V) ⟶ f _* X(V)` is an iso for each `V ⊆ U`.\n\nAbbreviations are also provided for `SheafedSpace`, `LocallyRingedSpace` and `Scheme`.\n\n## Main definitions\n\n* `algebraic_geometry.PresheafedSpace.is_open_immersion`: the `Prop`-valued typeclass asserting\n  that a PresheafedSpace hom `f` is an open_immersion.\n* `algebraic_geometry.is_open_immersion`: the `Prop`-valued typeclass asserting\n  that a Scheme morphism `f` is an open_immersion.\n* `algebraic_geometry.PresheafedSpace.is_open_immersion.iso_restrict`: The source of an\n  open immersion is isomorphic to the restriction of the target onto the image.\n\n## Main results\n\n* `algebraic_geometry.PresheafedSpace.is_open_immersion.comp`: The composition of two open\n  immersions is an open immersion.\n* `algebraic_geometry.PresheafedSpace.is_open_immersion.of_iso`: An iso is an open immersion.\n* `algebraic_geometry.PresheafedSpace.is_open_immersion.to_iso`:\n  A surjective open immersion is an isomorphism.\n* `algebraic_geometry.PresheafedSpace.is_open_immersion.stalk_iso`: An open immersion induces\n  an isomorphism on stalks.\n\n-/\n\nopen topological_space category_theory opposite\nopen category_theory.limits\nnamespace algebraic_geometry\n\nuniverses v u\n\nvariables {C : Type u} [category.{v} C]\n\n/--\nAn open immersion of PresheafedSpaces is an open embedding `f : X ⟶ U ⊆ Y` of the underlying\nspaces, such that the sheaf map `Y(V) ⟶ f _* X(V)` is an iso for each `V ⊆ U`.\n-/\nclass PresheafedSpace.is_open_immersion {X Y : PresheafedSpace C} (f : X ⟶ Y) : Prop :=\n(base_open : open_embedding f.base)\n(c_iso : ∀ U : opens X, is_iso (f.c.app (op (base_open.is_open_map.functor.obj U))))\n\n/--\nA morphism of SheafedSpaces is an open immersion if it is an open immersion as a morphism\nof PresheafedSpaces\n-/\nabbreviation SheafedSpace.is_open_immersion\n  [has_products C] {X Y : SheafedSpace C} (f : X ⟶ Y) : Prop :=\nPresheafedSpace.is_open_immersion f\n\n/--\nA morphism of LocallyRingedSpaces is an open immersion if it is an open immersion as a morphism\nof SheafedSpaces\n-/\nabbreviation LocallyRingedSpace.is_open_immersion {X Y : LocallyRingedSpace} (f : X ⟶ Y) : Prop :=\nSheafedSpace.is_open_immersion f.1\n\n/--\nA morphism of Schemes is an open immersion if it is an open immersion as a morphism\nof LocallyRingedSpaces\n-/\nabbreviation is_open_immersion {X Y : Scheme} (f : X ⟶ Y) : Prop :=\nLocallyRingedSpace.is_open_immersion f\n\nnamespace PresheafedSpace.is_open_immersion\n\nopen PresheafedSpace\n\nlocal notation `is_open_immersion` := PresheafedSpace.is_open_immersion\n\nattribute [instance] is_open_immersion.c_iso\n\nsection\n\nvariables {X Y : PresheafedSpace C} {f : X ⟶ Y} (H : is_open_immersion f)\n\n/-- The functor `opens X ⥤ opens Y` associated with an open immersion `f : X ⟶ Y`. -/\nabbreviation open_functor := H.base_open.is_open_map.functor\n\n/-\nWe want to keep `eq_to_hom`s in the form of `F.map (eq_to_hom _)` so that the lemmas about\nnaturality can be applied.\n-/\nlocal attribute [-simp] eq_to_hom_map eq_to_iso_map\n\n/-- An open immersion `f : X ⟶ Y` induces an isomorphism `X ≅ Y|_{f(X)}`. -/\n@[simps] noncomputable\ndef iso_restrict : X ≅ Y.restrict H.base_open :=\nPresheafedSpace.iso_of_components (iso.refl _)\nbegin\n  symmetry,\n  fapply nat_iso.of_components,\n  intro U,\n  refine as_iso (f.c.app (op (H.open_functor.obj (unop U)))) ≪≫ X.presheaf.map_iso (eq_to_iso _),\n  { induction U using opposite.rec,\n    cases U,\n    dsimp only [is_open_map.functor, functor.op, opens.map],\n    congr' 2,\n    erw set.preimage_image_eq _ H.base_open.inj,\n    refl },\n  { intros U V i,\n    simp only [category_theory.eq_to_iso.hom, Top.presheaf.pushforward_obj_map, category.assoc,\n      functor.op_map, iso.trans_hom, as_iso_hom, functor.map_iso_hom, ←X.presheaf.map_comp],\n    erw [f.c.naturality_assoc, ←X.presheaf.map_comp],\n    congr }\nend\n\n@[simp] lemma iso_restrict_hom_of_restrict : H.iso_restrict.hom ≫ Y.of_restrict _ = f :=\nbegin\n  ext,\n  { simp only [comp_c_app, iso_restrict_hom_c_app, nat_trans.comp_app,\n      eq_to_hom_refl, of_restrict_c_app, category.assoc, whisker_right_id'],\n    erw [category.comp_id, f.c.naturality_assoc, ←X.presheaf.map_comp],\n    transitivity f.c.app x ≫ X.presheaf.map (𝟙 _),\n    { congr },\n    { erw [X.presheaf.map_id, category.comp_id] } },\n  { simp }\nend\n\n@[simp] lemma iso_restrict_inv_of_restrict : H.iso_restrict.inv ≫ f = Y.of_restrict _ :=\nby { rw iso.inv_comp_eq, simp }\n\ninstance mono [H : is_open_immersion f] : mono f :=\nby { rw ← H.iso_restrict_hom_of_restrict, apply mono_comp }\n\n/-- The composition of two open immersions is an open immersion. -/\ninstance comp {Z : PresheafedSpace C} (f : X ⟶ Y) [hf : is_open_immersion f] (g : Y ⟶ Z)\n  [hg : is_open_immersion g] :\n  is_open_immersion (f ≫ g) :=\n{ base_open := hg.base_open.comp hf.base_open,\n  c_iso := λ U,\n  begin\n    generalize_proofs h,\n    dsimp only [algebraic_geometry.PresheafedSpace.comp_c_app, unop_op, functor.op, comp_base,\n      Top.presheaf.pushforward_obj_obj, opens.map_comp_obj],\n    apply_with is_iso.comp_is_iso { instances := ff },\n    swap,\n    { have : (opens.map g.base).obj (h.functor.obj U) = hf.open_functor.obj U,\n      { dsimp only [opens.map, is_open_map.functor, PresheafedSpace.comp_base],\n        congr' 1,\n        rw [coe_comp, ←set.image_image, set.preimage_image_eq _ hg.base_open.inj] },\n      rw this,\n      apply_instance },\n    { have : h.functor.obj U = hg.open_functor.obj (hf.open_functor.obj U),\n      { dsimp only [is_open_map.functor],\n        congr' 1,\n        rw [comp_base, coe_comp, ←set.image_image],\n        congr },\n      rw this,\n      apply_instance }\n  end }\n\n/-- For an open immersion `f : X ⟶ Y` and an open set `U ⊆ X`, we have the map `X(U) ⟶ Y(U)`. -/\nnoncomputable\ndef inv_app (U : opens X) : X.presheaf.obj (op U) ⟶ Y.presheaf.obj (op (H.open_functor.obj U)) :=\nX.presheaf.map (eq_to_hom (by simp [opens.map, set.preimage_image_eq _ H.base_open.inj])) ≫\n  inv (f.c.app (op (H.open_functor.obj U)))\n\n@[simp, reassoc] lemma inv_naturality {U V : (opens X)ᵒᵖ} (i : U ⟶ V) :\n  X.presheaf.map i ≫ H.inv_app (unop V) = H.inv_app (unop U) ≫\n    Y.presheaf.map (H.open_functor.op.map i) :=\nbegin\n  simp only [inv_app, ←category.assoc],\n  rw [is_iso.comp_inv_eq],\n  simp only [category.assoc, f.c.naturality, is_iso.inv_hom_id_assoc, ← X.presheaf.map_comp],\n  erw ← X.presheaf.map_comp,\n  congr\nend\n\ninstance (U : opens X) : is_iso (H.inv_app U) := by { delta inv_app, apply_instance }\n\nlemma inv_inv_app (U : opens X) :\n  inv (H.inv_app U) = f.c.app (op (H.open_functor.obj U)) ≫\n    X.presheaf.map (eq_to_hom (by simp [opens.map, set.preimage_image_eq _ H.base_open.inj])) :=\nbegin\n  rw ← cancel_epi (H.inv_app U),\n  rw is_iso.hom_inv_id,\n  delta inv_app,\n  simp [← functor.map_comp]\nend\n\n@[simp, reassoc] lemma inv_app_app (U : opens X) :\n  H.inv_app U ≫ f.c.app (op (H.open_functor.obj U)) =\n    X.presheaf.map (eq_to_hom (by simp [opens.map, set.preimage_image_eq _ H.base_open.inj])) :=\nby rw [inv_app, category.assoc, is_iso.inv_hom_id, category.comp_id]\n\n@[simp, reassoc] lemma app_inv_app (U : opens Y) :\n  f.c.app (op U) ≫ H.inv_app ((opens.map f.base).obj U) =\n  Y.presheaf.map ((hom_of_le (by exact set.image_preimage_subset f.base U)).op :\n    op U ⟶ op (H.open_functor.obj ((opens.map f.base).obj U))) :=\nby { erw ← category.assoc, rw [is_iso.comp_inv_eq, f.c.naturality], congr }\n\n/-- A variant of `app_inv_app` that gives an `eq_to_hom` instead of `hom_of_le`. -/\n@[reassoc] lemma app_inv_app' (U : opens Y) (hU : (U : set Y) ⊆ set.range f.base) :\n  f.c.app (op U) ≫ H.inv_app ((opens.map f.base).obj U) =\n  Y.presheaf.map (eq_to_hom (by\n    { apply has_le.le.antisymm,\n      { exact set.image_preimage_subset f.base U.1 },\n      { change U ⊆ _,\n        refine has_le.le.trans_eq _ (@set.image_preimage_eq_inter_range _ _ f.base U.1).symm,\n        exact set.subset_inter_iff.mpr ⟨λ _ h, h, hU⟩ } })).op :=\nby { erw ← category.assoc, rw [is_iso.comp_inv_eq, f.c.naturality], congr }\n\n/-- An isomorphism is an open immersion. -/\ninstance of_iso {X Y : PresheafedSpace C} (H : X ≅ Y) : is_open_immersion H.hom :=\n{ base_open := (Top.homeo_of_iso ((forget C).map_iso H)).open_embedding,\n  c_iso := λ _, infer_instance }\n\n@[priority 100]\ninstance of_is_iso {X Y : PresheafedSpace C} (f : X ⟶ Y) [is_iso f] : is_open_immersion f :=\nalgebraic_geometry.PresheafedSpace.is_open_immersion.of_iso (as_iso f)\n\ninstance of_restrict {X : Top} (Y : PresheafedSpace C) {f : X ⟶ Y.carrier}\n  (hf : open_embedding f) : is_open_immersion (Y.of_restrict hf) :=\n{ base_open := hf,\n  c_iso := λ U,\n  begin\n    dsimp,\n    have : (opens.map f).obj (hf.is_open_map.functor.obj U) = U,\n    { cases U,\n      dsimp only [opens.map, is_open_map.functor],\n      congr' 1,\n      rw set.preimage_image_eq _ hf.inj,\n      refl },\n    convert (show is_iso (Y.presheaf.map (𝟙 _)), from infer_instance),\n    { apply subsingleton.helim,\n      rw this },\n    { rw Y.presheaf.map_id,\n      apply_instance }\n  end }\n\n/-- An open immersion is an iso if the underlying continuous map is epi. -/\nlemma to_iso (f : X ⟶ Y) [h : is_open_immersion f] [h' : epi f.base] : is_iso f :=\nbegin\n  apply_with is_iso_of_components { instances := ff },\n  { let : X ≃ₜ Y := (homeomorph.of_embedding _ h.base_open.to_embedding).trans\n    { to_fun := subtype.val, inv_fun := λ x, ⟨x,\n      by { rw set.range_iff_surjective.mpr ((Top.epi_iff_surjective _).mp h'), trivial }⟩,\n      left_inv := λ ⟨_,_⟩, rfl, right_inv := λ _, rfl },\n    convert is_iso.of_iso (Top.iso_of_homeo this),\n    { ext, refl } },\n  { apply_with nat_iso.is_iso_of_is_iso_app { instances := ff },\n    intro U,\n    have : U = op (h.open_functor.obj ((opens.map f.base).obj (unop U))),\n    { induction U using opposite.rec,\n      cases U,\n      dsimp only [functor.op, opens.map],\n      congr,\n      exact (set.image_preimage_eq _ ((Top.epi_iff_surjective _).mp h')).symm },\n    convert @@is_open_immersion.c_iso _ h ((opens.map f.base).obj (unop U)) }\nend\n\ninstance stalk_iso [has_colimits C] [H : is_open_immersion f] (x : X) : is_iso (stalk_map f x) :=\nbegin\n  rw ← H.iso_restrict_hom_of_restrict,\n  rw PresheafedSpace.stalk_map.comp,\n  apply_instance\nend\n\nend\n\nend PresheafedSpace.is_open_immersion\n\nend algebraic_geometry\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebraic_geometry/open_immersion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.727975460709318, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4558030363790168}}
{"text": "import tactic.generalize_proofs\n\nexample (x : ℕ) (h : x < 2) : classical.some ⟨x, h⟩ < 2 :=\nbegin\n  generalize_proofs a,\n  guard_hyp a : ∃ x, x < 2,\n  guard_target classical.some a < 2,\n  exact classical.some_spec a,\nend\n\nexample (a : ∃ x, x < 2) : classical.some a < 2 :=\nbegin\n  generalize_proofs,\n  guard_target classical.some a < 2,\n  exact classical.some_spec a,\nend\n\nexample (x : ℕ) (h : x < 2) (a : ∃ x, x < 2) : classical.some a < 2 :=\nbegin\n  generalize_proofs,\n  guard_target classical.some a < 2,\n  exact classical.some_spec a,\nend\n\nexample (x : ℕ) (h : x < 2) (H : classical.some ⟨x, h⟩ < 2) : classical.some ⟨x, h⟩ < 2 :=\nbegin\n  generalize_proofs a at H ⊢,\n  guard_hyp a : ∃ x, x < 2,\n  guard_hyp H : classical.some a < 2,\n  guard_target classical.some a < 2,\n  exact H,\nend\n\nlocal attribute [instance] classical.prop_decidable\n\nexample (H : ∀ x, x = 1) : (if h : ∃ (k : ℕ), k = 1 then classical.some h else 0) = 1 :=\nbegin\n  rw [dif_pos], tactic.swap, { exact ⟨1, rfl⟩ },\n  generalize_proofs h,\n  guard_target classical.some h = 1,\n  apply H\nend\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/generalize_proofs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.45580302898865993}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Scott Morrison\n-/\n\nimport tactic.interactive\nimport tactic.finish\nimport tactic.ext\nimport tactic.lift\nimport tactic.apply\nimport tactic.reassoc_axiom\nimport tactic.tfae\nimport tactic.elide\nimport tactic.ring_exp\nimport tactic.clear\nimport tactic.simp_rw\n\nexample (m n p q : nat) (h : m + n = p) : true :=\nbegin\n  have : m + n = q,\n  { generalize_hyp h' : m + n = x at h,\n    guard_hyp h' : m + n = x,\n    guard_hyp h : x = p,\n    guard_target m + n = q,\n    admit },\n  have : m + n = q,\n  { generalize_hyp h' : m + n = x at h ⊢,\n    guard_hyp h' : m + n = x,\n    guard_hyp h : x = p,\n    guard_target x = q,\n    admit },\n  trivial\nend\n\nexample (α : Sort*) (L₁ L₂ L₃ : list α)\n  (H : L₁ ++ L₂ = L₃) : true :=\nbegin\n  have : L₁ ++ L₂ = L₂,\n  { generalize_hyp h : L₁ ++ L₂ = L at H,\n    induction L with hd tl ih,\n    case list.nil\n    { tactic.cleanup,\n      change list.nil = L₃ at H,\n      admit },\n    case list.cons\n    { change list.cons hd tl = L₃ at H,\n      admit } },\n  trivial\nend\n\nexample (x y : ℕ) (p q : Prop) (h : x = y) (h' : p ↔ q) : true :=\nbegin\n  symmetry' at h,\n  guard_hyp' h : y = x,\n  guard_hyp' h' : p ↔ q,\n  symmetry' at *,\n  guard_hyp' h : x = y,\n  guard_hyp' h' : q ↔ p,\n  trivial\nend\n\nsection h_generalize\n\nvariables {α β γ φ ψ : Type} (f : α → α → α → φ → γ)\n          (x y : α) (a b : β) (z : φ)\n          (h₀ : β = α) (h₁ : β = α) (h₂ : φ = β)\n          (hx : x == a) (hy : y == b) (hz : z == a)\ninclude f x y z a b hx hy hz\n\nexample : f x y x z = f (eq.rec_on h₀ a) (cast h₀ b) (eq.mpr h₁.symm a) (eq.mpr h₂ a) :=\nbegin\n  guard_hyp_nums 16,\n  h_generalize hp : a == p with hh,\n  guard_hyp_nums 19,\n  guard_hyp' hh : β = α,\n  guard_target f x y x z = f p (cast h₀ b) p (eq.mpr h₂ a),\n  h_generalize hq : _ == q,\n  guard_hyp_nums 21,\n  guard_target f x y x z = f p q p (eq.mpr h₂ a),\n  h_generalize _ : _ == r,\n  guard_hyp_nums 23,\n  guard_target f x y x z = f p q p r,\n  casesm* [_ == _, _ = _], refl\nend\n\nend h_generalize\n\nsection h_generalize\n\nvariables {α β γ φ ψ : Type} (f : list α → list α → γ)\n          (x : list α) (a : list β) (z : φ)\n          (h₀ : β = α) (h₁ : list β = list α)\n          (hx : x == a)\ninclude f x z a hx h₀ h₁\n\nexample : true :=\nbegin\n  have : f x x = f (eq.rec_on h₀ a) (cast h₁ a),\n  { guard_hyp_nums 11,\n    h_generalize : a == p with _,\n    guard_hyp_nums 13,\n    guard_hyp' h : β = α,\n    guard_target f x x = f p (cast h₁ a),\n    h_generalize! : a == q ,\n    guard_hyp_nums 13,\n    guard_target ∀ q, f x x = f p q,\n    casesm* [_ == _, _ = _],\n    success_if_fail { refl },\n    admit },\n  trivial\nend\n\nend h_generalize\n\nsection tfae\n\nexample (p q r s : Prop)\n  (h₀ : p ↔ q)\n  (h₁ : q ↔ r)\n  (h₂ : r ↔ s) :\n  p ↔ s :=\nbegin\n  scc,\nend\n\nexample (p' p q r r' s s' : Prop)\n  (h₀ : p' → p)\n  (h₀ : p → q)\n  (h₁ : q → r)\n  (h₁ : r' → r)\n  (h₂ : r ↔ s)\n  (h₂ : s → p)\n  (h₂ : s → s') :\n  p ↔ s :=\nbegin\n  scc,\nend\n\nexample (p' p q r r' s s' : Prop)\n  (h₀ : p' → p)\n  (h₀ : p → q)\n  (h₁ : q → r)\n  (h₁ : r' → r)\n  (h₂ : r ↔ s)\n  (h₂ : s → p)\n  (h₂ : s → s') :\n  p ↔ s :=\nbegin\n  scc',\n  assumption\nend\n\nexample : tfae [true, ∀ n : ℕ, 0 ≤ n * n, true, true] := begin\n  tfae_have : 3 → 1, { intro h, constructor },\n  tfae_have : 2 → 3, { intro h, constructor },\n  tfae_have : 2 ← 1, { intros h n, apply nat.zero_le },\n  tfae_have : 4 ↔ 2, { tauto },\n  tfae_finish,\nend\n\nexample : tfae [] := begin\n  tfae_finish,\nend\n\nvariables P Q R : Prop\n\nexample (pq : P → Q) (qr : Q → R) (rp : R → P) : tfae [P, Q, R] :=\nbegin\n  tfae_finish\nend\n\nexample (pq : P ↔ Q) (qr : Q ↔ R) : tfae [P, Q, R] :=\nbegin\n  tfae_finish -- the success or failure of this tactic is nondeterministic!\nend\n\nexample (p : unit → Prop) : tfae [p (), p ()] :=\nbegin\n  tfae_have : 1 ↔ 2, from iff.rfl,\n  tfae_finish\nend\n\nend tfae\n\nsection clear_aux_decl\n\nexample (n m : ℕ) (h₁ : n = m) (h₂ : ∃ a : ℕ, a = n ∧ a = m) : 2 * m = 2 * n :=\nlet ⟨a, ha⟩ := h₂ in\nbegin\n  clear_aux_decl, -- subst will fail without this line\n  subst h₁\nend\n\nexample (x y : ℕ) (h₁ : ∃ n : ℕ, n * 1 = 2) (h₂ : 1 + 1 = 2 → x * 1 = y) : x = y :=\nlet ⟨n, hn⟩ := h₁ in\nbegin\n  clear_aux_decl, -- finish produces an error without this line\n  finish\nend\n\nend clear_aux_decl\n\nsection swap\n\nexample {α₁ α₂ α₃ : Type} : true :=\nby {have : α₁, have : α₂, have : α₃, swap, swap,\n    rotate, rotate, rotate, rotate 2, rotate 2, triv, recover}\n\nend swap\n\nprivate meta def get_exception_message (t : lean.parser unit) : lean.parser string\n| s := match t s with\n       | result.success a s' := result.success \"No exception\" s\n       | result.exception none pos s' := result.success \"Exception no msg\" s\n       | result.exception (some msg) pos s' := result.success (msg ()).to_string s\n       end\n\n@[user_command] meta def test_parser1_fail_cmd\n(_ : interactive.parse (lean.parser.tk \"test_parser1\")) : lean.parser unit :=\ndo\n  let msg := \"oh, no!\",\n  let t : lean.parser unit := tactic.fail msg,\n  s ← get_exception_message t,\n  if s = msg then tactic.skip\n  else interaction_monad.fail \"Message was corrupted while being passed through `lean.parser.of_tactic`\"\n.\n\n-- Due to `lean.parser.of_tactic'` priority, the following *should not* fail with\n-- a VM check error, and instead catch the error gracefully and just\n-- run and succeed silently.\ntest_parser1\n\nsection category_theory\nopen category_theory\nvariables {C : Type} [category.{1} C]\n\nexample (X Y Z W : C) (x : X ⟶ Y) (y : Y ⟶ Z) (z z' : Z ⟶ W) (w : X ⟶ Z)\n  (h : x ≫ y = w)\n  (h' : y ≫ z = y ≫ z') :\n  x ≫ y ≫ z = w ≫ z' :=\nbegin\n  rw [h',reassoc_of h],\nend\n\nend category_theory\n\nsection is_eta_expansion\n/- test the is_eta_expansion tactic -/\nopen function tactic\nstructure my_equiv (α : Sort*) (β : Sort*) :=\n(to_fun    : α → β)\n(inv_fun   : β → α)\n(left_inv  : left_inverse inv_fun to_fun)\n(right_inv : right_inverse inv_fun to_fun)\n\ninfix ` my≃ `:25 := my_equiv\n\nprotected def my_rfl {α} : α my≃ α :=\n⟨id, λ x, x, λ x, rfl, λ x, rfl⟩\n\ndef eta_expansion_test : ℕ × ℕ := ((1,0).1,(1,0).2)\nrun_cmd do e ← get_env, x ← e.get `eta_expansion_test,\n  let v := (x.value.get_app_args).drop 2,\n  let nms := [`prod.fst, `prod.snd],\n  guard $ expr.is_eta_expansion_test (nms.zip v) = some `((1, 0))\n\ndef eta_expansion_test2 : ℕ my≃ ℕ :=\n⟨my_rfl.to_fun, my_rfl.inv_fun, λ x, rfl, λ x, rfl⟩\n\nrun_cmd do e ← get_env, x ← e.get `eta_expansion_test2,\n  let v := (x.value.get_app_args).drop 2,\n  projs ← e.structure_fields_full `my_equiv,\n  b ← expr.is_eta_expansion_aux x.value (projs.zip v),\n  guard $ b = some `(@my_rfl ℕ)\n\nrun_cmd do e ← get_env, x1 ← e.get `eta_expansion_test, x2 ← e.get `eta_expansion_test2,\n  b1 ← expr.is_eta_expansion x1.value,\n  b2 ← expr.is_eta_expansion x2.value,\n  guard $ b1 = some `((1, 0)) ∧ b2 = some `(@my_rfl ℕ)\n\nstructure my_str (n : ℕ) := (x y : ℕ)\n\ndef dummy : my_str 3 := ⟨1, 1⟩\ndef wrong_param : my_str 2 := ⟨dummy.1, dummy.2⟩\ndef right_param : my_str 3 := ⟨dummy.1, dummy.2⟩\n\nrun_cmd do e ← get_env,\n  x ← e.get `wrong_param, o ← x.value.is_eta_expansion,\n  guard o.is_none,\n  x ← e.get `right_param, o ← x.value.is_eta_expansion,\n  guard $ o = some `(dummy)\n\n\nend is_eta_expansion\n\nsection elide\n\nvariables {x y z w : ℕ}\nvariables (h  : x + y + z ≤ w)\n          (h' : x ≤ y + z + w)\ninclude h h'\n\nexample : x + y + z ≤ w :=\nbegin\n  elide 0 at h,\n  elide 2 at h',\n  guard_hyp h : @hidden _ (x + y + z ≤ w),\n  guard_hyp h' : x ≤ @has_add.add (@hidden Type nat) (@hidden (has_add nat) nat.has_add)\n                                   (@hidden ℕ (y + z)) (@hidden ℕ w),\n  unelide at h,\n  unelide at h',\n  guard_hyp h' : x ≤ y + z + w,\n  exact h, -- there was a universe problem in `elide`. `exact h` lets the kernel check\n           -- the consistency of the universes\nend\n\nend elide\n\nsection struct_eq\n\n@[ext]\nstructure foo (α : Type*) :=\n(x y : ℕ)\n(z : {z // z < x})\n(k : α)\n(h : x < y)\n\nexample {α : Type*} : Π (x y : foo α), x.x = y.x → x.y = y.y → x.z == y.z → x.k = y.k → x = y :=\nfoo.ext\n\nexample {α : Type*} : Π (x y : foo α), x = y ↔ x.x = y.x ∧ x.y = y.y ∧ x.z == y.z ∧ x.k = y.k :=\nfoo.ext_iff\n\nexample {α} (x y : foo α) (h : x = y) : y = x :=\nbegin\n  ext,\n  { guard_target' y.x = x.x, rw h },\n  { guard_target' y.y = x.y, rw h },\n  { guard_target' y.z == x.z, rw h },\n  { guard_target' y.k = x.k, rw h },\nend\n\nend struct_eq\n\nsection ring_exp\n  example (a b : ℤ) (n : ℕ) : (a + b)^(n + 2) = (a^2 + 2 * a * b + b^2) * (a + b)^n := by ring_exp\nend ring_exp\n\nsection clear'\n\nexample (a : ℕ) (b : fin a) : unit :=\nbegin\n  success_if_fail { clear a b }, -- fails since `b` depends on `a`\n  success_if_fail { clear' a },  -- fails since `b` depends on `a`\n  clear' a b,\n  guard_hyp_nums 0,\n  exact ()\nend\n\nexample (a : ℕ) : fin a → unit :=\nbegin\n  success_if_fail { clear' a },          -- fails since the target depends on `a`\n  success_if_fail { clear_dependent a }, -- ditto\n  exact λ _, ()\nend\n\nexample (a : unit) : unit :=\nbegin\n  -- Check we fail with an error (but don't segfault) if hypotheses are repeated.\n  success_if_fail { clear' a a },\n  success_if_fail { clear_dependent a a },\n  exact ()\nend\n\nexample (a a a : unit) : unit :=\nbegin\n  -- If there are multiple hypotheses with the same name,\n  -- `clear'`/`clear_dependent` currently clears only the last.\n  clear' a,\n  clear_dependent a,\n  guard_hyp_nums 1,\n  exact ()\nend\n\nend clear'\n\nsection clear_dependent\n\nexample (a : ℕ) (b : fin a) : unit :=\nbegin\n  success_if_fail { clear' a }, -- fails since `b` depends on `a`\n  clear_dependent a,\n  guard_hyp_nums 0,\n  exact ()\nend\n\nend clear_dependent\n\nsection simp_rw\n  example {α β : Type} {f : α → β} {t : set β} :\n    (∀ s, f '' s ⊆ t) = ∀ s : set α, ∀ x ∈ s, x ∈ f ⁻¹' t :=\n  by simp_rw [set.image_subset_iff, set.subset_def]\nend simp_rw\n\nsection local_definitions\n/- Some tactics about local definitions.\n  Testing revert_deps, revert_after, generalize', clear_value. -/\nopen tactic\nexample {A : ℕ → Type} {n : ℕ} : let k := n + 3, l := k + n, f : A k → A k := id in\n  ∀(x : A k) (y : A (n + k)) (z : A n) (h : k = n + n), unit :=\nbegin\n  intros, guard_target unit,\n  do { e ← get_local `k, e1 ← tactic.local_def_value e, e2 ← to_expr ```(n + 3), guard $ e1 = e2 },\n  do { e ← get_local `n, success_if_fail_with_msg (tactic.local_def_value e)\n    \"Variable n is not a local definition.\" },\n  do { success_if_fail_with_msg (tactic.local_def_value `(1 + 2))\n    \"No such hypothesis 1 + 2.\" },\n  revert_deps k, tactic.intron 5, guard_target unit,\n  revert_after n, tactic.intron 7, guard_target unit,\n  do {\n    e ← get_local `k,\n    tactic.revert_reverse_dependencies_of_hyp e,\n    l ← local_context,\n    guard $ e ∈ l,\n    intros },\n  exact unit.star\nend\n\nexample {A : ℕ → Type} {n : ℕ} : let k := n + 3, l := k + n, f : A k → A (n+3) := id in\n  ∀(x : A k) (y : A (n + k)) (z : A n) (h : k = n + n), unit :=\nbegin\n  intros,\n  success_if_fail_with_msg {generalize : n + k = x}\n    \"generalize tactic failed, failed to find expression in the target\",\n  generalize' : n + k = x,\n  generalize' h : n + k = y,\n  exact unit.star\nend\n\nexample {A : ℕ → Type} {n : ℕ} : let k := n + 3, l := k + n, f : A k → A (n+3) := id in\n  ∀(x : A k) (y : A (n + k)) (z : A n) (h : k = n + n), unit :=\nbegin\n  intros,\n  tactic.to_expr ```(n + n) >>= λ e, tactic.generalize' e `xxx,\n  success_if_fail_with_msg {clear_value n}\n    \"Cannot clear the body of n. It is not a local definition.\",\n  success_if_fail_with_msg {clear_value k}\n    \"Cannot clear the body of k. The resulting goal is not type correct.\",\n  clear_value k f,\n  get_local `k, -- test that `k` is not renamed.\n  exact unit.star\nend\n\nexample {A : ℕ → Type} {n : ℕ} : let k := n + 3, l := k + n, f : A k → A k := id in\n  ∀(x : A k) (y : A (n + k)) (z : A n) (h : k = n + n), unit :=\nbegin\n  intros,\n  clear_value k f,\n  exact unit.star\nend\n\n/-- test `clear_value` and the preservation of naming -/\nexample : ∀ x y : ℤ, let z := x + y in x = z - y → x = y - z → true :=\nbegin\n  introv h h,\n  guard_hyp x : ℤ,\n  guard_hyp y : ℤ,\n  guard_hyp z : ℤ := x + y,\n  guard_hyp h : x = y - z,\n  suffices : true, -- test the type of the second assumption named `h`\n  { clear h,\n    guard_hyp h : x = z - y,\n    assumption },\n  do { to_expr ```(z) >>= is_local_def },\n  clear_value z,\n  guard_hyp z : ℤ,\n  success_if_fail { do { to_expr ```(z) >>= is_local_def } },\n  guard_hyp h : x = y - z,\n  suffices : true,\n  { clear h,\n    guard_hyp h : x = z - y,\n    assumption },\n  trivial\nend\n\n/- Test whether generalize' always uses the exact name stated by the user, even if that name already\n  exists. -/\nexample (n : Type) (k : ℕ) : k = 5 → unit :=\nbegin\n  generalize' : 5 = n,\n  guard_target (k = n → unit),\n  intro, constructor\nend\n\n/- Test that `generalize'` works correctly with argument `h`, when the expression occurs in the\n  target -/\nexample (n : Type) (k : ℕ) : k = 5 → unit :=\nbegin\n  generalize' h : 5 = n,\n  guard_target (k = n → unit),\n  intro, constructor\nend\n\nend local_definitions\n\nsection set_attribute\n\nopen tactic\n\n@[user_attribute] meta def my_user_attribute : user_attribute unit bool :=\n{ name := `my_attr,\n  descr := \"\",\n  parser := return ff }\n\nrun_cmd do nm ← get_user_attribute_name `library_note, guard $ nm = `library_note_attr\nrun_cmd do nm ← get_user_attribute_name `higher_order, guard $ nm = `tactic.higher_order_attr\nrun_cmd do success_if_fail $ get_user_attribute_name `zxy.xzy\n\nrun_cmd set_attribute `norm `prod.map tt\nrun_cmd set_attribute `my_attr `prod.map\nrun_cmd set_attribute `to_additive `has_mul\nrun_cmd success_if_fail $ set_attribute `higher_order `prod.map tt\nrun_cmd success_if_fail $ set_attribute `norm `xyz.zxy\nrun_cmd success_if_fail $ set_attribute `zxy.xyz `prod.map\n\nend set_attribute\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/tactics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.7279754430043072, "lm_q1q2_score": 0.4558030252934815}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Mario Carneiro, Reid Barton\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.category.Top.opens\nimport Mathlib.PostPort\n\nuniverses v u \n\nnamespace Mathlib\n\n/-!\n# Presheaves on a topological space\n\nWe define `presheaf C X` simply as `(opens X)ᵒᵖ ⥤ C`,\nand inherit the category structure with natural transformations as morphisms.\n\nWe define\n* `pushforward_obj {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : X.presheaf C) : Y.presheaf C`\nwith notation `f _* ℱ`\nand for `ℱ : X.presheaf C` provide the natural isomorphisms\n* `pushforward.id : (𝟙 X) _* ℱ ≅ ℱ``\n* `pushforward.comp : (f ≫ g) _* ℱ ≅ g _* (f _* ℱ)`\nalong with their `@[simp]` lemmas.\n-/\n\nnamespace Top\n\n\ndef presheaf (C : Type u) [category_theory.category C] (X : Top) := topological_space.opens ↥Xᵒᵖ ⥤ C\n\nnamespace presheaf\n\n\n/-- Pushforward a presheaf on `X` along a continuous map `f : X ⟶ Y`, obtaining a presheaf on `Y`. -/\ndef pushforward_obj {C : Type u} [category_theory.category C] {X : Top} {Y : Top} (f : X ⟶ Y)\n    (ℱ : presheaf C X) : presheaf C Y :=\n  category_theory.functor.op (topological_space.opens.map f) ⋙ ℱ\n\ninfixl:80 \" _* \" => Mathlib.Top.presheaf.pushforward_obj\n\n@[simp] theorem pushforward_obj_obj {C : Type u} [category_theory.category C] {X : Top} {Y : Top}\n    (f : X ⟶ Y) (ℱ : presheaf C X) (U : topological_space.opens ↥Yᵒᵖ) :\n    category_theory.functor.obj (f _* ℱ) U =\n        category_theory.functor.obj ℱ\n          (category_theory.functor.obj (category_theory.functor.op (topological_space.opens.map f))\n            U) :=\n  rfl\n\n@[simp] theorem pushforward_obj_map {C : Type u} [category_theory.category C] {X : Top} {Y : Top}\n    (f : X ⟶ Y) (ℱ : presheaf C X) {U : topological_space.opens ↥Yᵒᵖ}\n    {V : topological_space.opens ↥Yᵒᵖ} (i : U ⟶ V) :\n    category_theory.functor.map (f _* ℱ) i =\n        category_theory.functor.map ℱ\n          (category_theory.functor.map (category_theory.functor.op (topological_space.opens.map f))\n            i) :=\n  rfl\n\ndef pushforward_eq {C : Type u} [category_theory.category C] {X : Top} {Y : Top} {f : X ⟶ Y}\n    {g : X ⟶ Y} (h : f = g) (ℱ : presheaf C X) : f _* ℱ ≅ g _* ℱ :=\n  category_theory.iso_whisker_right\n    (category_theory.nat_iso.op (category_theory.iso.symm (topological_space.opens.map_iso f g h)))\n    ℱ\n\n@[simp] theorem pushforward_eq_hom_app {C : Type u} [category_theory.category C] {X : Top} {Y : Top}\n    {f : X ⟶ Y} {g : X ⟶ Y} (h : f = g) (ℱ : presheaf C X) (U : topological_space.opens ↥Yᵒᵖ) :\n    category_theory.nat_trans.app (category_theory.iso.hom (pushforward_eq h ℱ)) U =\n        category_theory.functor.map ℱ\n          (id\n            (category_theory.has_hom.hom.op\n              (category_theory.eq_to_hom\n                (eq.mpr\n                  (id\n                    (Eq._oldrec\n                      (Eq.refl\n                        (category_theory.functor.obj (topological_space.opens.map g)\n                            (opposite.unop U) =\n                          category_theory.functor.obj (topological_space.opens.map f)\n                            (opposite.unop U)))\n                      h))\n                  (Eq.refl\n                    (category_theory.functor.obj (topological_space.opens.map g)\n                      (opposite.unop U))))))) :=\n  rfl\n\n@[simp] theorem pushforward_eq_rfl {C : Type u} [category_theory.category C] {X : Top} {Y : Top}\n    (f : X ⟶ Y) (ℱ : presheaf C X) (U : topological_space.opens ↥Y) :\n    category_theory.nat_trans.app (category_theory.iso.hom (pushforward_eq rfl ℱ)) (opposite.op U) =\n        𝟙 :=\n  sorry\n\ntheorem pushforward_eq_eq {C : Type u} [category_theory.category C] {X : Top} {Y : Top} {f : X ⟶ Y}\n    {g : X ⟶ Y} (h₁ : f = g) (h₂ : f = g) (ℱ : presheaf C X) :\n    pushforward_eq h₁ ℱ = pushforward_eq h₂ ℱ :=\n  rfl\n\nnamespace pushforward\n\n\ndef id {C : Type u} [category_theory.category C] {X : Top} (ℱ : presheaf C X) : 𝟙 _* ℱ ≅ ℱ :=\n  category_theory.iso_whisker_right\n      (category_theory.nat_iso.op (category_theory.iso.symm (topological_space.opens.map_id X)))\n      ℱ ≪≫\n    category_theory.functor.left_unitor ℱ\n\n@[simp] theorem id_hom_app' {C : Type u} [category_theory.category C] {X : Top} (ℱ : presheaf C X)\n    (U : set ↥X) (p : is_open U) :\n    category_theory.nat_trans.app (category_theory.iso.hom (id ℱ))\n          (opposite.op { val := U, property := p }) =\n        category_theory.functor.map ℱ 𝟙 :=\n  sorry\n\n@[simp] theorem id_hom_app {C : Type u} [category_theory.category C] {X : Top} (ℱ : presheaf C X)\n    (U : topological_space.opens ↥Xᵒᵖ) :\n    category_theory.nat_trans.app (category_theory.iso.hom (id ℱ)) U =\n        category_theory.functor.map ℱ\n          (category_theory.eq_to_hom (topological_space.opens.op_map_id_obj U)) :=\n  sorry\n\n@[simp] theorem id_inv_app' {C : Type u} [category_theory.category C] {X : Top} (ℱ : presheaf C X)\n    (U : set ↥X) (p : is_open U) :\n    category_theory.nat_trans.app (category_theory.iso.inv (id ℱ))\n          (opposite.op { val := U, property := p }) =\n        category_theory.functor.map ℱ 𝟙 :=\n  sorry\n\ndef comp {C : Type u} [category_theory.category C] {X : Top} (ℱ : presheaf C X) {Y : Top} {Z : Top}\n    (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g) _* ℱ ≅ g _* (f _* ℱ) :=\n  category_theory.iso_whisker_right\n    (category_theory.nat_iso.op (category_theory.iso.symm (topological_space.opens.map_comp f g))) ℱ\n\n@[simp] theorem comp_hom_app {C : Type u} [category_theory.category C] {X : Top} (ℱ : presheaf C X)\n    {Y : Top} {Z : Top} (f : X ⟶ Y) (g : Y ⟶ Z) (U : topological_space.opens ↥Zᵒᵖ) :\n    category_theory.nat_trans.app (category_theory.iso.hom (comp ℱ f g)) U = 𝟙 :=\n  sorry\n\n@[simp] theorem comp_inv_app {C : Type u} [category_theory.category C] {X : Top} (ℱ : presheaf C X)\n    {Y : Top} {Z : Top} (f : X ⟶ Y) (g : Y ⟶ Z) (U : topological_space.opens ↥Zᵒᵖ) :\n    category_theory.nat_trans.app (category_theory.iso.inv (comp ℱ f g)) U = 𝟙 :=\n  sorry\n\nend pushforward\n\n\n/--\nA morphism of presheaves gives rise to a morphisms of the pushforwards of those presheaves.\n-/\ndef pushforward_map {C : Type u} [category_theory.category C] {X : Top} {Y : Top} (f : X ⟶ Y)\n    {ℱ : presheaf C X} {𝒢 : presheaf C X} (α : ℱ ⟶ 𝒢) : f _* ℱ ⟶ f _* 𝒢 :=\n  category_theory.nat_trans.mk\n    fun (U : topological_space.opens ↥Yᵒᵖ) =>\n      category_theory.nat_trans.app α\n        (category_theory.functor.obj (category_theory.functor.op (topological_space.opens.map f)) U)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/sheaves/presheaf_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6261241702517976, "lm_q1q2_score": 0.455803023909935}}
{"text": "--- Will clean up these imports\nimport tactic\nimport analysis.calculus.iterated_deriv\nimport topology.continuous_function.polynomial\nimport topology.separation\nimport topology.path_connected\nimport analysis.complex.basic\nimport analysis.calculus.tangent_cone\nimport analysis.normed_space.units\nimport analysis.asymptotics.asymptotic_equivalent\nimport analysis.analytic.basic\nimport geometry.manifold.algebra.smooth_functions\nimport linear_algebra.finite_dimensional\nimport analysis.normed_space.inner_product\nimport topology.metric_space.basic\nimport topology.continuous_on\nimport analysis.calculus.formal_multilinear_series\n\nopen set complex classical filter asymptotics continuous_linear_map set metric is_open differentiable\nopen_locale topological_space classical nnreal asymptotics filter ennreal unit_interval\n\nnoncomputable theory\n\n--- Some assumptions\n\ntheorem holomorph_analytic (f : ℂ → ℂ) (z : ℂ) : differentiable_at ℂ f z ↔ analytic_at ℂ f z :=\nsorry\n\ntheorem smooth_within_at_iff_holomorph_within_at (f : ℂ → ℂ) {s : set ℂ} (h : is_open s) : ∀ (z : ℂ), (differentiable_within_at ℂ f s z ↔ times_cont_diff_within_at ℂ ⊤ f s z):=\nsorry\n\ntheorem smooth_at_iff_holomorph_at (f : ℂ → ℂ) : ∀ (z : ℂ), (differentiable_at ℂ f z ↔ times_cont_diff_at ℂ ⊤ f z) :=\nsorry\n\ntheorem smooth_on_iff_holomorph_on (f : ℂ → ℂ) {s : set ℂ} (h : is_open s) : differentiable_on ℂ f s ↔ times_cont_diff_on ℂ ⊤ f s := \nsorry\n\nsection accuml_pts\n\n--- Need this?\n--- def isolated_pt (X : Type*) [topological_space X] (U : set X) (z : X) : Prop :=\n--- ∃ (V : set X), is_open V ∧ U ∩ (V \\ {z}) = ∅\n\ndef accumulation_pt (X : Type*) [topological_space X] (U : set X) (z : X) : Prop :=\n∀ (V : set X), V ∈ (𝓝 z) → ∃ (v : X), v ∈ U ∩ V ∧ ¬ v = z\n\nlemma accumulation_pt_open_inter {X : Type*} [topological_space X] \n  {U : set X} {U' : set X} {z : X}\n  (hU' : is_open U') (HU' : z ∈ U') (hz : accumulation_pt X U z) :\n  accumulation_pt X (U ∩ U') z := \nλ V hV, (set.inter_assoc U U' V).symm ▸ \n  (hz (U' ∩ V) $ _root_.mem_nhds_iff.mpr $ \n    let ⟨t, ht, ht₁, ht₂⟩ := _root_.mem_nhds_iff.mp hV in \n    ⟨U' ∩ t, ⟨set.inter_subset_inter_right U' ht, ⟨is_open.inter hU' ht₁, ⟨HU', ht₂⟩⟩⟩⟩)\n--\nlemma accumulation_pt_mem_closure {X : Type*} [topological_space X] \n  {U : set X} {z : X} (hz : accumulation_pt X U z) :\n  z ∈ closure U :=\nbegin\n  rw _root_.mem_closure_iff,\n  intros o ho hxo,\n  rcases hz o (is_open.mem_nhds ho hxo) with ⟨v, hv₁, hv₂⟩,\n  use v,\n  rw set.inter_comm at hv₁,\n  exact hv₁,\nend\n\nend accuml_pts\n\nsection crowded_space\n\nclass crowded_space (X : Type*) [t : topological_space X] :=\n(is_crowded : ∀ (x : X), ¬ t.is_open {x})\n\nlemma crowded_space.def (X : Type*) [t : topological_space X] [cr : crowded_space X] : \n∀ (x : X), ¬ t.is_open {x} := cr.is_crowded\n\nlemma mem_frontier (X : Type*) [t : topological_space X] {U : set X} {z : X} : \n  z ∈ frontier U → ∀ (V : set X), V ∈ 𝓝 z → (V ∩ U ≠ ∅ ∧ V \\ U ≠ ∅) :=\nbegin\n  intros hz,\n  rw frontier at hz,\n  have h : ∀ (o : set X), is_open o → z ∈ o → (o ∩ U).nonempty := \n    _root_.mem_closure_iff.mp (mem_of_mem_diff hz),\n  have h' : ¬ (∃ (o : set X) (H : o ⊆ U), is_open o ∧ z ∈ o),\n  { let p := not_mem_of_mem_diff hz, rw [mem_interior] at p, exact p, },\n  simp at h',\n  intros V hV,\n  rcases _root_.mem_nhds_iff.mp hV with ⟨V', hV'₁, hV'₂, hV'₃⟩,\n  split,\n  { exact set.nonempty.ne_empty (set.nonempty.mono (set.inter_subset_inter_left _ hV'₁) $ h V' hV'₂ hV'₃), },\n  { by_contra w,\n    simp at w,\n    rw [diff_eq_empty] at w,\n    show false, from (h' V' (set.subset.trans hV'₁ w) hV'₂) hV'₃, },\nend\n\nlemma t1_space_connected_with_two_points_is_crowded (X : Type*) \n  [t : topological_space X] [c : connected_space X] [h : t1_space X]\n  (hX : ∀ (x : X), ∃ (y : X), ¬ y = x) (x : X) : ¬ t.is_open {x} :=\nbegin\n  by_contra w,\n  rcases hX x with ⟨y, hy⟩,\n  have minor₁ : is_open {x}ᶜ := is_open_compl_singleton,\n  have : set.nonempty {x}ᶜ,\n  { use y, rw [← ne.def, ← mem_compl_singleton_iff] at hy, exact hy, },\n  exact (ne_empty_iff_nonempty.mpr $ nonempty_inter w (is_open_compl_singleton) \n    (union_compl_self {x}) (set.singleton_nonempty x) this) (set.inter_compl_self {x}),\nend\n\nlemma accumulation_pt_of_mem_open_nondiscrete \n  (X : Type*) [t : topological_space X] [cr : crowded_space X]\n  {U : set X} (hU : is_open U) {z : X} (hz : z ∈ U) :\n  accumulation_pt X U z := \nbegin\n  let ht := crowded_space.def X,\n  intros V hV,\n  rw is_open_iff_forall_mem_open at hU,\n  rcases _root_.mem_nhds_iff.mp hV with ⟨V', hV'₁, hV'₂, hV'₃⟩,\n  rcases hU z hz with ⟨U', hU'₁, hU'₂, hU'₃⟩,\n  have : ¬ (U' ∩ V') = {z} := by_contra (λ h, ht z $ (not_not.mp h) ▸ is_open.inter hU'₂ hV'₂),\n  rw set.ext_iff at this,\n  simp at this,\n  rcases this with ⟨v, hV⟩,\n  use v,\n  rw iff_iff_implies_and_implies at hV,\n  cases not_and_distrib.mp hV,\n  { simp at h,\n    exact ⟨⟨hU'₁ h.1, hV'₁ h.2.1⟩, h.2.2⟩, },\n  { simp at h,\n    exfalso,\n    exact h.2 (h.1.symm ▸ hU'₃) (h.1.symm ▸ hV'₃), },\nend\n\nlemma accumulation_pt_of_open_mem_frontier \n  {X : Type*} [t : topological_space X] [cr : crowded_space X] {U : set X}\n  (hU : is_open U) {z : X} (hz : z ∈ frontier U) :\n  accumulation_pt X U z := \nif h : z ∈ U then accumulation_pt_of_mem_open_nondiscrete X hU h \n  else begin\n    rw accumulation_pt,\n    intros V hV, \n    let p := (mem_frontier X hz V hV).1,\n    rcases set.nonempty_def.mp (set.ne_empty_iff_nonempty.mp p) with ⟨v, hv⟩,\n    use v,\n    have : ¬ v = z := begin\n      by_contra w,\n      rw ← w at h,\n      exact h hv.2,\n    end,\n    rw set.inter_comm at hv,\n    exact ⟨hv, this⟩,\n  end\n\ninstance complex_plane_crowded_space : crowded_space ℂ :=\n{ is_crowded := begin\n    have : ∀ (x : ℂ), ∃ y, ¬ y = x :=\n    begin\n      intros x,\n      by_cases (x = 0),\n      { rw h,\n        exact ⟨1, one_ne_zero⟩, },\n      { exact ⟨0, λ h', h h'.symm⟩, },\n    end,\n    exact t1_space_connected_with_two_points_is_crowded ℂ this,\n  end }\n\nend crowded_space\n\nsection accuml_pts_homeomorph\n\nlemma mem_image_closure_mem_closure\n  {X : Type*} [topological_space X] {U : set X} {x : X} (hx : x ∈ closure U)\n  {Y : Type*} [topological_space Y] {e : local_homeomorph X Y} (he : x ∈ e.to_local_equiv.source) :\n  e x ∈ closure (e '' U) :=\nbegin\n  rw _root_.mem_closure_iff at hx ⊢,\n  intros o ho hxo,\n  have : e.is_image (e⁻¹' o) o :=\n  begin\n    intros y hy,\n    split,\n    { intros h, exact h, },\n    { intros h, exact set.mem_preimage.mp h },\n  end,\n  let o' := e.to_local_equiv.source ∩ e⁻¹' o,\n  have subkey : x ∈ o' := ⟨he, hxo⟩,\n  have key : is_open o' := \n    (local_homeomorph.is_image.is_open_iff this).mpr (is_open.inter e.open_target ho),\n  rcases hx o' key subkey with ⟨z, hz₁, hz₂⟩,\n  rcases hz₁ with ⟨hz₁₁, hz₁₂⟩,\n  use e z,\n  exact ⟨hz₁₂, set.mem_image_of_mem e hz₂⟩,\nend\n\nlemma mem_closure_inter\n  {X : Type*} [topological_space X] {U : set X} {x : X} (hx : x ∈ closure U)\n  {U' : set X} (hU' : is_open U') (h : x ∈ U') :\n  x ∈ closure (U ∩ U') :=\nbegin\n  rw _root_.mem_closure_iff at hx ⊢,\n  intros o ho hxo,\n  specialize hx (o ∩ U') (is_open.inter ho hU') ⟨hxo, h⟩,\n  rw set.inter_assoc at hx,\n  nth_rewrite 1 set.inter_comm at hx,\n  exact hx,\nend\n\nlemma accumulation_pt_local_homeomorph \n  {X : Type*} [topological_space X] {U : set X} {x : X} (hx : accumulation_pt X U x)\n  {Y : Type*} [topological_space Y] {e : local_homeomorph X Y} (he : x ∈ e.to_local_equiv.source) :\n  accumulation_pt Y (e '' U) (e x) :=\nbegin\n  rw accumulation_pt at hx ⊢,\n  intros V hV,\n  rcases _root_.mem_nhds_iff.mp hV with ⟨V', hV'₁, hV'₂, hV'₃⟩,\n  specialize hx (e.to_local_equiv.source ∩ e⁻¹' (V' ∩ e.to_local_equiv.target)),\n  have : (e.to_local_equiv.source ∩ e⁻¹' (V' ∩ e.to_local_equiv.target)) ∈ 𝓝 x :=\n  begin\n    have minor : is_open (V' ∩ e.to_local_equiv.target) := is_open.inter hV'₂ e.open_target,\n    have key : x ∈ (e⁻¹' (V' ∩ e.to_local_equiv.target)) := set.mem_preimage.mpr ⟨hV'₃, local_equiv.map_source _ he⟩,\n    refine is_open.mem_nhds _ ⟨he, key⟩,\n    apply local_homeomorph.preimage_open_of_open,\n    exact is_open.inter hV'₂ e.open_target,\n  end,\n  rcases hx this with ⟨a, ha₁, ha₂⟩,\n  rcases ha₁ with ⟨haa, hab⟩,\n  let p := set.mem_image_of_mem e hab,\n  use e a,\n  split,\n  { split, exact set.mem_image_of_mem e haa,\n    nth_rewrite 1 set.inter_comm at p,\n    rw [← local_homeomorph.coe_coe, \n        ← local_equiv.symm_image_target_inter_eq e.to_local_equiv V'] at p,\n    have : set.left_inv_on ⇑(e.to_local_equiv) \n          ⇑(e.to_local_equiv.symm) e.to_local_equiv.target := \n    begin\n      nth_rewrite 0 ← local_equiv.symm_symm e.to_local_equiv,\n      rw [←local_homeomorph.symm_source, local_homeomorph.symm_to_local_equiv],\n      exact local_equiv.left_inv_on e.to_local_equiv.symm,\n    end,\n    rw set.left_inv_on.image_image' this (set.inter_subset_left e.to_local_equiv.target V') at p,\n    exact hV'₁ p.2, },\n  rw set.mem_image at p,\n  rcases p with ⟨b, hb⟩,\n  rcases hb with ⟨left, right⟩,\n  rcases left with ⟨hb₁, hb₂⟩,\n  { intros w,\n    have key : a = b := by rwa [eq_comm, ←local_homeomorph.coe_coe e, \n          set.inj_on.eq_iff (local_equiv.inj_on e.to_local_equiv) hab.1 hb₁] at right,\n    rw ← right at w,\n    rw [eq_comm, ←local_homeomorph.coe_coe e, \n        set.inj_on.eq_iff (local_equiv.inj_on e.to_local_equiv) he hb₁] at w,\n    rw ← key at w,\n    exact ha₂ (eq_comm.mp w), },\nend\n\nend accuml_pts_homeomorph\n\nsection complex_theorems\n\ntheorem identity_theorem\n  {f : ℂ → ℂ} {g : ℂ → ℂ}\n  {U : set ℂ} (hU₁ : is_open U) (hU₂ : is_connected U)\n  (hf : differentiable_on ℂ f U) (hg : differentiable_on ℂ g U)\n  {s₀ : ℂ} {S : set ℂ} (hS : S ⊆ U) (hS' : set.eq_on f g S)\n  (hs₀ : s₀ ∈ S) (hs₀' : accumulation_pt ℂ S s₀):\n  set.eq_on f g U :=\nsorry\n\ntheorem eq_of_eq_on_open\n  {f : ℂ → ℂ} {g : ℂ → ℂ}\n  {U : set ℂ} (hU₁ : is_open U) (hU₂ : is_connected U)\n  (hf : differentiable_on ℂ f U) (hg : differentiable_on ℂ g U)\n  {V : set ℂ} (hV₁ : is_open V) (hV₂ : V.nonempty) (hV₃ : set.eq_on f g V) (hV₄ : V ⊆ U) :\n  set.eq_on f g U := \nlet ⟨v, hv⟩ := hV₂ in \n  identity_theorem hU₁ hU₂ hf hg hV₄ hV₃ hv $ accumulation_pt_of_mem_open_nondiscrete ℂ hV₁ hv\n\ntheorem open_mapping_complex\n  {f : ℂ → ℂ}\n  {U : set ℂ} (hU₁ : is_open U) (hU₂ : is_connected U)\n  (hf₁ : differentiable_on ℂ f U)\n  (hf₂ : ∃ (x y : ℂ), x ∈ U ∧ y ∈ U ∧ ¬ f x = f y) :\n  ∀ (U' : set ℂ), U' ⊆ U → is_open U' → is_open (f '' U'):=\nsorry\n\nend complex_theorems\n\n/-\n  Trash codes. A bad attempt to prove the identity theorem only assuming some\n  standard results\n-/\n\n/-\nlemma nonvanishing_has_local_expansion\n(ε : ℝ) {hε : ε > 0}\n(f : ℂ → ℂ)\n(w : ℂ)\n{hf₁ : ∃ (z : ℂ), z ∈ ball w ε ∧ ¬f z = 0}\n{hf₂ : ∀ (z : ℂ), z ∈ ball w ε  → analytic_at ℂ f z} {hf₂ : f w = 0}:\n∃ (k : ℕ) (r : ℝ) (g : ℂ → ℂ),\nk > 0 ∧ r ≤ ε ∧ 0 < r ∧\n∀ (x : ℂ), x ∈ ball w r → f = (λ x, ((x - w) ^ k) * g x)\n∧ ¬ g x = 0 ∧ analytic_at ℂ g x:=\nsorry\n\n-- I cannot prove the following theorem neatly. I tried to prove it with some disguting inductions,\n-- but Lean's treatments of derivatives are not quite nice in this case. Maybe using g's expansion\n-- would be easier. But again, that requires at least one induction.\nlemma nonvanishing_iter_deriv_of_nonvanishing\n(f : ℂ → ℂ)\n(w : ℂ)\n{hf : analytic_at ℂ f w}:\n(∃ (k : ℕ),\n¬ iterated_deriv k f w = 0)\n↔ (∃ (ε : ℝ), 0 < ε ∧ (∀ (z : ℂ), z ∈ ball w ε → analytic_at ℂ f z) \n∧ (∃ (z : ℂ), z ∈ ball w ε ∧ ¬f z = 0)) := \nsorry\n\nlemma nonvanishing_disk_of_continuous\n(f : ℂ → ℂ)\n(z : ℂ) {hf₁ : continuous_at f z} {hf₂ : ¬ f z = 0}:\n∃ (ε : ℝ),\n0 < ε ∧ ∀ (x : ℂ), x ∈ ball z ε → ¬ f x = 0 :=\nbegin\n  have := hf₁,\n  rw continuous_at_iff at this,\n    let ε' := ∥f z∥ / 2,\n    rw [← ne.def, ← norm_pos_iff] at hf₂,\n    have hε' : 0 < ∥f z∥ / 2 := by linarith,\n    rcases this ε' hε' with ⟨δ, hδ, h⟩,\n    use min ε' δ,\n    split,\n    simp,\n    exact ⟨hε', hδ⟩,\n    {\n      intros x hx,\n      rw [mem_ball', dist_comm] at hx,\n      have lt_δ : dist x z < δ := lt_of_lt_of_le hx (min_le_right _ _),\n      specialize h lt_δ,\n      rw [dist_eq_norm, norm_sub_rev] at h,\n      have key : 0 < ∥f x∥ :=\n        calc ∥f x∥ = ∥f z - (f z - f x)∥ : by simp\n        ... ≥ ∥f z∥ - ∥f z - f x∥ : norm_sub_norm_le _ _\n        ... ≥ ∥f z∥ - ε' : begin simp, apply le_of_lt, exact h, end\n        ... ≥ ∥f z∥ - ∥f z∥ / 2 : begin simp, apply le_of_eq, rw ← norm_eq_abs, end\n        ... = ∥f z∥ / 2 : by linarith\n        ... > 0 : hε',\n      rw [norm_pos_iff] at key,\n      exact key,\n    },\nend\n\nlemma is_open_nonvanishing_of_continuous\n(f : ℂ → ℂ)\n(U : set ℂ) {hU : is_open U}\n{hf : ∀ (z : ℂ), z ∈ U → continuous_at f z} : \nis_open {z : ℂ | z ∈ U ∧ ¬ f z = 0} :=\nbegin\n  rw metric.is_open_iff at *,\n  dsimp,\n  intros z hz,\n  rcases hz with ⟨hz₁, hz₂⟩,\n  specialize hU z hz₁,\n  specialize hf z hz₁,\n  rcases hU with ⟨δ, hδ₁, hδ₂⟩,\n  rcases nonvanishing_disk_of_continuous f z with ⟨ε, hε₁, hε₂⟩,\n  assumption',\n  use min δ ε,\n  split,\n  simp at hδ₁,\n  exact lt_min hδ₁ hε₁,\n  rw subset_def,\n  dsimp,\n  intros x hx,\n  have key₁ : x ∈ U := hδ₂ ((ball_subset_ball $ min_le_left δ ε) hx),\n  have key₂ : ¬ f x = 0 := hε₂ x ((ball_subset_ball $ min_le_right δ ε) hx),\n  exact ⟨key₁, key₂⟩,\nend\n\nlemma isolated_zeros_of_nonvanishing\n(ε : ℝ) {hε : ε > 0}\n(f : ℂ → ℂ)\n(w : ℂ)\n{hf₁ : ∃ (z : ℂ), z ∈ ball w ε ∧ ¬f z = 0} \n{hf₂ : ∀ (z : ℂ), z ∈ ball w ε  → analytic_at ℂ f z}:\n∃ (r : ℝ),\nr ≤ ε ∧ 0 < r ∧\n∀ (x : ℂ), x ∈ ball w r → ¬ x - w = 0 → ¬ f x = 0:=\nbegin\n  by_cases (f w = 0),\n  -- the case where f w = 0; use f's local expansion around w\n  {\n    rcases nonvanishing_has_local_expansion ε f w with ⟨k, r, g, H⟩,\n    rcases H with ⟨H₁, H₂, H₃, H₄⟩,\n    use r,\n    split,\n    exact H₂,\n    {\n      split,\n      exact H₃,\n      {\n        intros x hx₁ hx₂,\n        by_contra h',\n        specialize H₄ x hx₁,\n        rcases H₄ with ⟨h₂₁, h₂₂, h₂₃⟩,\n        rw h₂₁ at h',\n        have key : (x - w) ^ k = 0 ∨ g x = 0 := eq_zero_or_eq_zero_of_mul_eq_zero h',\n        cases key with key₁ key₂,\n        {\n          rw [← complex.cpow_nat_cast, complex.cpow_eq_zero_iff] at key₁,\n          exact hx₂ key₁.1,\n        },\n        {\n          exact h₂₂ key₂,\n        },\n      },\n    },\n    assumption',\n  },\n  -- the case where f w ≠ 0; use the continuity of f at w\n  {\n    specialize hf₂ w (mem_ball_self hε),\n    rcases nonvanishing_disk_of_continuous f w with ⟨r, hr⟩,\n    assumption',\n    use min r ε,\n    split,\n    exact min_le_right _ _,\n    split,\n    {\n      simp,\n      exact ⟨hr.1, hε⟩,\n    },\n    {\n      intros x hx₁ hx₂,\n      rw [mem_ball'] at hx₁,\n      have key : dist w x < r := lt_of_lt_of_le hx₁ (min_le_left _ _),\n      rw [← mem_ball'] at key,\n      exact hr.2 x key,\n    },\n    exact analytic_at.continuous_at hf₂,\n  },\nend\n\ndef is_accumulation_point (U : set ℂ) (z : ℂ) : Prop :=\n∀ (V : set ℂ), V ∈ (𝓝 z) → ∃ (v : ℂ), v ∈ U ∩ V ∧ ¬ v - z = 0\n\nlemma vanishing_disk_of_accumulation_point\n(U : set ℂ) {hU : is_open U}\n(f : ℂ → ℂ) {hf : ∀ (z : ℂ), z ∈ U → analytic_at ℂ f z}\n(s₀ : ℂ) \n{hs₀ : is_accumulation_point {s : ℂ | f s = 0 ∧ s ∈ U} s₀} \n{hs₀' : s₀ ∈ {s : ℂ | f s = 0 ∧ s ∈ U}}:\n∃ (ε : ℝ), 0 < ε ∧ ball s₀ ε ⊆ U ∧\n∀ (z : ℂ), z ∈ ball s₀ ε → f z = 0 :=\nbegin\n  by_contra w,\n  simp only [not_exists, not_and] at w,\n  dsimp at hs₀',\n  rw metric.is_open_iff at hU,\n  specialize hU s₀ hs₀'.2,\n  rcases hU with ⟨ε, hε₁, hε₂⟩,\n  specialize w ε hε₁ hε₂,\n  simp only [not_forall] at w,\n  rcases w with ⟨z, hz₁, hz₂⟩,\n  have hf₁ : ∃ (z : ℂ), z ∈ ball s₀ ε ∧ ¬f z = 0 := ⟨z, ⟨hz₁, hz₂⟩⟩,\n  have hf₂ : ∀ (x : ℂ), x ∈ ball s₀ ε → analytic_at ℂ f x := λ x hx, hf x $ hε₂ hx,\n  rcases isolated_zeros_of_nonvanishing ε f s₀ with ⟨r, hr₁, hr₂, hr₃⟩,\n  assumption',\n  have : ∃ (v : ℂ), v ∈ {s : ℂ | f s = 0 ∧ s ∈ U} ∩ (ball s₀ r) ∧ ¬ v - s₀ = 0 := \n    hs₀ (ball s₀ r) (ball_mem_nhds s₀ hr₂),\n  rcases this with ⟨v, hv₁, hv₂⟩,\n  dsimp at hv₁,\n  show false, from (hr₃ v hv₁.2 hv₂) hv₁.1.1,\nend\n\ntheorem vanishing_if_zeros_accumulate\n(U : set ℂ) {hU₁ : is_open U} {hU₂ : is_connected U}\n(f : ℂ → ℂ) {hf : ∀ (z : ℂ), z ∈ U → analytic_at ℂ f z}\n(s₀ : ℂ)\n{hs₀ : is_accumulation_point {s : ℂ | f s = 0 ∧ s ∈ U} s₀} \n{hs₀' : s₀ ∈ {s : ℂ | f s = 0 ∧ s ∈ U}}:\n∀ (z : ℂ), z ∈ U → f z = 0:=\nbegin\n  let U₁ : set ℂ := {z : ℂ | z ∈ U ∧ ∃ (r : ℝ), 0 < r ∧ ball z r ⊆ U ∧ ∀ (x : ℂ), x ∈ ball z r → f x = 0},\n  let U₂ : set ℂ := {z : ℂ | z ∈ U ∧ ∃ (k : ℕ), ¬ iterated_deriv k f z = 0},\n  have h₁ : U₁ ∪ U₂ = U :=\n  begin\n    ext,\n    split,\n    {\n      intro h,\n      dsimp at h,\n      cases h with H₁ H₂,\n      exact H₁.1,\n      exact H₂.1,\n    },\n    {\n      intro H,\n      by_cases (x ∈ U₂),\n      exact (mem_union_right U₁) h,\n      {\n        by_cases h' : f x = 0,\n        {\n          have key : is_accumulation_point {s : ℂ | f s = 0 ∧ s ∈ U} x ∧ x ∈ {s : ℂ | f s = 0 ∧ s ∈ U}:=\n          begin\n            by_contradiction w,\n            rw not_and_distrib at w,\n            cases w with w₁ w₂,\n            {\n              -- sorry,\n              unfold is_accumulation_point at w₁,\n              simp at w₁,\n              rcases w₁ with ⟨U', hU₁', hU₂'⟩,\n              rw metric.mem_nhds_iff at hU₁',\n              rcases hU₁' with ⟨r, hr₁, hr₂⟩,\n              let U'' : set ℂ := ball x r ∩ U,\n              have key₁ : is_open U'' := is_open.inter metric.is_open_ball hU₁,\n              rw metric.is_open_iff at key₁,\n              specialize key₁ x (mem_inter (mem_ball_self hr₁) H),\n              rcases key₁ with ⟨ε, hε₁, hε₂⟩,\n              let x' : ℂ := x + ε / 2,\n              have key₂ : x' ∈ ball x ε := \n              begin \n                simp,\n                have : 0 ≤ ε / 2 := by linarith,\n                exact calc dist x' x = ∥(x + ε / 2) - x∥ : by rw dist_eq_norm\n                  ... = complex.abs ↑(ε / 2) : by simp\n                  ... = ε / 2 : by rw complex.abs_of_nonneg this\n                  ... < ε : by linarith,\n              end,\n              have key₃ : ¬ f x' = 0 :=\n              begin\n                by_contra w',\n                have : x' ∈ U'' := hε₂ key₂,\n                simp only [mem_inter_eq] at this,\n                specialize hU₂' x' w' this.2 (hr₂ this.1),\n                have key : ¬ x' - x = 0 := begin\n                  simp,\n                  exact ne_of_gt hε₁,\n                end,\n                show false, from key hU₂',\n              end,\n              have : ∃ (ε : ℝ), ε > 0 ∧ (∀ (z : ℂ), z ∈ ball x ε → analytic_at ℂ f z) ∧ ∃ (z : ℂ), z ∈ ball x ε ∧ ¬f z = 0 :=\n              begin\n                use ε,\n                split,\n                exact hε₁,\n                split,\n                intros z hz, \n                exact hf z (mem_of_mem_inter_right (hε₂ hz)),\n                exact ⟨x', ⟨key₂, key₃⟩⟩,\n              end,\n              have key₄ : x ∈ U₂ :=\n              begin\n                dsimp,\n                split,\n                exact H,\n                rcases iff.elim_right (nonvanishing_iter_deriv_of_nonvanishing f x) this with ⟨k, hk⟩,\n                use k,\n                exact hf x H,\n              end, \n              show false, from h key₄,\n            },\n            {\n              simp at w₂,\n              show false, from (w₂ h') H,\n            },\n          end,\n          rcases vanishing_disk_of_accumulation_point U f x with ⟨ε, hε₁, hε₂, hε₃⟩,\n          assumption',\n          have : x ∈ U₁ :=\n          begin\n            dsimp [U₁],\n            split,\n            exact H,\n            {\n              use ε,\n              exact ⟨hε₁, ⟨hε₂, hε₃⟩⟩,\n            },\n          end,\n          exact (mem_union_left U₂) this,\n          exact key.1,\n          exact key.2,\n        },\n        {\n          have key₁ : ∃ (k : ℕ), ¬ iterated_deriv k f x = 0 := by use 0,\n          have key₂ : x ∈ U₂ := begin\n            simp,\n            exact ⟨H, key₁⟩,\n          end,\n          exfalso,\n          exact h key₂,\n        },\n      },\n    },  \n  end,\n  have h₂ : U₁ ∩ U₂ = ∅ :=\n  begin\n    by_contra,\n    rw [← ne.def, ne_empty_iff_nonempty, nonempty_def] at h,\n    rcases h with ⟨x, hx⟩,\n    dsimp at hx,\n    rcases iff.elim_left (nonvanishing_iter_deriv_of_nonvanishing f x) hx.2.2 with ⟨ε, hε₁, hε₂, hε₃⟩,\n    rcases isolated_zeros_of_nonvanishing ε f x with ⟨r, hr₁, hr₂, hr₃⟩,\n    assumption',\n    swap,\n    exact hf x hx.1.1,\n    rcases hx.1.2 with ⟨r', hr₁', hr₂', hr₃'⟩,\n    let r'' : ℝ := min r r',\n    have minor₁ : 0 < r'' := \n    begin\n      rw lt_min_iff,\n      exact ⟨hr₂, gt.lt hr₁'⟩,\n    end,\n    have minor₂ : ∃ (x' : ℂ), x' ∈ ball x r'' ∧ ¬ x' - x = 0 := \n    begin\n      let x' : ℂ := x + r'' / 2,\n      use x',\n      split,\n      simp only [metric.mem_ball],\n      have : 0 ≤ r'' / 2 := by linarith,\n      exact calc dist x' x = ∥(x + r'' / 2) - x∥ : by rw dist_eq_norm\n        ... = complex.abs ↑(r'' / 2) : by simp\n        ... = r'' / 2 : by rw complex.abs_of_nonneg this\n        ... < r'' : by linarith,\n      simp,\n      exact ne_of_gt minor₁,\n    end,\n    rcases minor₂ with ⟨x', hx₁', hx₂'⟩,\n    have key₁ : f x' = 0 := hr₃' x' ((ball_subset_ball (min_le_right r r')) hx₁'),\n    have key₂ : ¬ f x' = 0 := hr₃ x' ((ball_subset_ball (min_le_left r r')) hx₁') hx₂',\n    show false, from key₂ key₁,\n  end,\n  have h₃ : is_open U₁ :=\n  begin\n    rw metric.is_open_iff,\n    intros x hx,\n    dsimp at hx,\n    rcases hx with ⟨hx₁, ε, hε₁, hε₂, hε₃⟩,\n    use ε,\n    split,\n    exact hε₁,\n    intros z hz,\n    dsimp,\n    split,\n    exact hε₂ hz,\n    have : ∃ (r : ℝ), (0 < r ∧ ball z r ⊆ U) ∧ ball z r ⊆ ball x ε :=\n    begin\n      have key : is_open (ball x ε) := is_open_ball,\n      rw metric.is_open_iff at key,\n      specialize key z hz,\n      rcases key with ⟨r, hr₁, hr₂⟩,\n      use r,\n      split,\n      exact ⟨hr₁, subset.trans hr₂ hε₂⟩,\n      exact hr₂,\n    end,\n    rcases this with ⟨r, hr₁, hr₂⟩,\n    use r,\n    split,\n    exact hr₁.1,\n    split,\n    exact hr₁.2,\n    intros x' hx',\n    exact hε₃ x' (hr₂ hx'),\n  end,\n  have h₄ : is_open U₂ :=\n  begin\n    sorry,   \n  end,\n  have h₅ : U₁.nonempty :=\n  begin\n    rw nonempty_def,\n    use s₀,\n    dsimp,\n    simp at hs₀',\n    split,\n    exact hs₀'.2,\n    rcases vanishing_disk_of_accumulation_point U f s₀ with ⟨ε, hε₁, hε₂, hε₃⟩,\n    assumption',\n    use ε,\n    exact ⟨hε₁, ⟨hε₂, hε₃⟩⟩,\n  end,\n  have hfinal : U₁ = U :=\n  begin\n    have : is_preconnected U := is_connected.is_preconnected hU₂,\n    rw is_preconnected_iff_subset_of_disjoint at this,\n    specialize this U₁ U₂ h₃ h₄ (eq.subset (eq.symm h₁)),\n    have minor : U ∩ (U₁ ∩ U₂) = ∅ := \n    begin\n      rw h₂,\n      simp,\n    end,\n    specialize this minor,\n    cases this,\n    {\n      have minor' : U₁ ⊆ U :=\n      begin\n        let h := set.subset_union_left U₁ U₂,\n        rw h₁ at h,\n        exact h,\n      end,\n      exact has_subset.subset.antisymm minor' this,\n    },\n    {\n      have minor₁ : U₁ ⊆ U :=\n      begin\n        let h := set.subset_union_left U₁ U₂,\n        rw h₁ at h,\n        exact h,\n      end,\n      have minor₂ : U₂ ⊆ U :=\n      begin\n        let h := set.subset_union_right U₁ U₂,\n        rw h₁ at h,\n        exact h,\n      end,\n      have minor₃ : U₂ = U := has_subset.subset.antisymm minor₂ this,\n      have key : U₁ = ∅ :=\n      begin\n        rw [inter_comm, ← set.subset_empty_iff, ← set.diff_eq_self] at h₂,\n        rw ← h₂,\n        by_contra w,\n        rw [← ne.def, set.ne_empty_iff_nonempty, set.nonempty_diff, minor₃] at w,\n        show false, from w minor₁,\n      end,\n      rw [← set.not_nonempty_iff_eq_empty] at key,\n      exfalso,\n      exact key h₅,\n    },\n  end,\n  intros z hz,\n  have : z ∈ U₁ := (eq.subset (eq.symm hfinal)) hz,\n  dsimp at this,\n  rcases this.2 with ⟨r, hr₁, hr₂, hr₃⟩,\n  specialize hr₃ z (mem_ball_self hr₁),\n  exact hr₃,\nend\n\ntheorem eq_if_eq_points_accumulate\n(U : set ℂ) {hU₁ : is_open U} {hU₂ : is_connected U}\n(f : ℂ → ℂ) {hf : ∀ (z : ℂ), z ∈ U → analytic_at ℂ f z}\n(g : ℂ → ℂ) {hg : ∀ (z : ℂ), z ∈ U → analytic_at ℂ g z}\n(s₀ : ℂ)\n{hs₀ : is_accumulation_point {s : ℂ | f s = g s ∧ s ∈ U} s₀} \n{hs₀' : s₀ ∈ {s : ℂ | f s = g s ∧ s ∈ U}} :\n∀ (z : ℂ), z ∈ U → f z = g z :=\nbegin\n  let h : ℂ → ℂ := f - g,\n  have minor : ∀ (z : ℂ), z ∈ U → analytic_at ℂ h z := λ z hz, analytic_at.sub (hf z hz) $ hg z hz,\n  have key : {s : ℂ | f s = g s ∧ s ∈ U} = {s : ℂ | h s = 0 ∧ s ∈ U} :=\n  begin\n    ext,\n    split,\n    { \n      intros hx, \n      dsimp at hx, \n      simp, split,\n      exact calc h x = (f - g) x : by refl\n        ... = f x - g x : by simp\n        ... = f x - f x : by rw ← hx.1\n        ... = 0 : by ring,\n      exact hx.2,\n    },\n    {\n      intros hx, \n      dsimp at hx, \n      simp, split,\n      exact calc f x = f x - g x + g x : by simp\n        ... = (f - g) x + g x : by simp\n        ... = h x + g x : by refl\n        ... = 0 + g x : by rw hx.1\n        ... = g x : by ring,\n      exact hx.2,\n    },\n  end,\n  rw key at hs₀ hs₀',\n  intros z hz,\n  have : h z = 0 := vanishing_if_zeros_accumulate U h s₀ z hz,\n  assumption',\n  exact calc f z = f z - g z + g z : by simp\n        ... = (f - g) z + g z : by simp\n        ... = h z + g z : by refl\n        ... = 0 + g z : by rw this\n        ... = g z : by ring,\nend\n-/\n", "meta": {"author": "justadzr", "repo": "lean-2021", "sha": "dfc6b30de2f27bdba5fbc51183e2b84e73a920d1", "save_path": "github-repos/lean/justadzr-lean-2021", "path": "github-repos/lean/justadzr-lean-2021/lean-2021-dfc6b30de2f27bdba5fbc51183e2b84e73a920d1/src/complex_analysis_prep.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.4557794563324928}}
{"text": "/-\nCopyright (c) 2014 Floris van Doorn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Floris van Doorn\n\nTheorems about functions with multiple arguments\n-/\nimport .init\n\nuniverses u v w\nhott_theory\n\nnamespace hott\n\nvariables {A : Type _} {U : Type _} {V : Type _} {W : Type _}\n          {X : Type _} {Y : Type _} {Z : Type _}\n          {B : A → Type _} {C : Πa, B a → Type _} {D : Πa b, C a b → Type _}\n          {E : Πa b c, D a b c → Type _} {F : Πa b c d, E a b c d → Type _}\n          {G : Πa b c d e, F a b c d e → Type _} {H : Πa b c d e f, G a b c d e f → Type _}\nvariables {a a' : A} {u u' : U} {v v' : V} {w w' : W} {x x' x'' : X} {y y' : Y} {z z' : Z}\n          {b : B a} {b' : B a'}\n          {c : C a b} {c' : C a' b'}\n          {d : D a b c} {d' : D a' b' c'}\n          {e : E a b c d} {e' : E a' b' c' d'}\n         {ff : F a b c d e} {f' : F a' b' c' d' e'}\n          {g : G a b c d e ff} {g' : G a' b' c' d' e' f'}\n          {h : H a b c d e ff g} {h' : H a' b' c' d' e' f' g'}\n\nnamespace eq\n  /-\n    Naming convention:\n      The theorem which states how to construct an path between two function applications is\n        api₀i₁...iₙ.\n      Here i₀, ... iₙ are digits, n is the arity of the function(s),\n        and iⱼ specifies the dimension of the path between the jᵗʰ argument\n        (i₀ specifies the dimension of the path between the functions).\n      A value iⱼ ≡ 0 means that the jᵗʰ arguments are definitionaly equal\n      The functions are non-dependent, except when the theorem name contains trailing zeroes\n        (where the function is dependent only in the arguments where it doesn't result in any\n         transports in the theorem statement).\n      For the fully-dependent versions (except that the conclusion doesn't contain a transport)\n      we write\n        apdi₀i₁...iₙ.\n\n      For versions where only some arguments depend on some other arguments,\n      or for versions with transport in the conclusion (like apdt), we don't have a\n      consistent naming scheme (yet).\n\n      We don't prove each theorem systematically, but prove only the ones which we actually need.\n  -/\n\n  @[hott, reducible] def homotopy2 (f g : Πa b, C a b)         : Type _ :=\n  Πa b, f a b = g a b\n  @[hott, reducible] def homotopy3 (f g : Πa b c, D a b c)     : Type _ :=\n  Πa b c, f a b c = g a b c\n  @[hott, reducible] def homotopy4 (f g : Πa b c d, E a b c d) : Type _ :=\n  Πa b c d, f a b c d = g a b c d\n\n  infix ` ~2 `:50 := homotopy2\n  infix ` ~3 `:50 := homotopy3\n  infix ` ~4 `:50 := homotopy4\n\n  @[refl] def homotopy2.refl (f : Π a b, C a b) : f ~2 f := by intros _ _; refl\n  @[refl] def homotopy3.refl (f : Π a b c, D a b c) : f ~3 f := by intros _ _ _; refl\n  @[refl] def homotopy4.refl (f : Π a b c d, E a b c d) : f ~4 f := by intros _ _ _ _; refl\n\n  @[hott] def ap0111 (f : U → V → W → X) (Hu : u = u') (Hv : v = v') (Hw : w = w')\n      : f u v w = f u' v' w' :=\n  by induction Hu; hsimp *\n\n  @[hott] def ap01111 (f : U → V → W → X → Y)\n    (Hu : u = u') (Hv : v = v') (Hw : w = w') (Hx : x = x')\n      : f u v w x = f u' v' w' x' :=\n  by induction Hu; hsimp *\n\n  @[hott] def ap011111 (f : U → V → W → X → Y → Z)\n    (Hu : u = u') (Hv : v = v') (Hw : w = w') (Hx : x = x') (Hy : y = y')\n      : f u v w x y = f u' v' w' x' y' :=\n  by induction Hu; hsimp *\n\n  @[hott] def ap0111111 (f : U → V → W → X → Y → Z → A)\n    (Hu : u = u') (Hv : v = v') (Hw : w = w') (Hx : x = x') (Hy : y = y') (Hz : z = z')\n      : f u v w x y z = f u' v' w' x' y' z' :=\n  by induction Hu; hsimp *\n\n  @[hott, elab_simple] def ap010 (f : X → Πa, B a) (Hx : x = x') : f x ~ f x' :=\n  λ b, ap (λa, f a b) Hx\n\n  @[hott] def ap0100 (f : X → Πa b, C a b) (Hx : x = x') : f x ~2 f x' :=\n  by intros; induction Hx; reflexivity\n\n  @[hott] def ap01000 (f : X → Πa b c, D a b c) (Hx : x = x') : f x ~3 f x' :=\n  by intros; induction Hx; reflexivity\n\n  @[hott] def apdt011 (f : Πa, B a → Z) (Ha : a = a') (Hb : transport B Ha b = b')\n      : f a b = f a' b' :=\n  by induction Ha; induction Hb; reflexivity\n\n  @[hott] def apdt0111 (f : Πa b, C a b → Z) (Ha : a = a') (Hb : transport B Ha b = b')\n    (Hc : cast (apdt011 C Ha Hb) c = c')\n      : f a b c = f a' b' c' :=\n  by induction Ha; induction Hb; induction Hc; reflexivity\n\n  @[hott] def apd011' {R : X → Y → Type _} {r : R x y} {r' : R x' y'} (f : Πx y, R x y → Z)\n    (p : x = x') (q : y = y') (s : transport11 R p q r = r') : f x y r = f x' y' r' :=\n  by induction p; induction q; induction s; refl\n\n  @[hott] def apdt01111 (f : Πa b c, D a b c → Z) (Ha : a = a') (Hb : transport B Ha b = b')\n    (Hc : cast (apdt011 C Ha Hb) c = c') (Hd : cast (apdt0111 D Ha Hb Hc) d = d')\n      : f a b c d = f a' b' c' d' :=\n  by induction Ha; induction Hb; induction Hc; induction Hd; reflexivity\n\n  @[hott] def apdt011111 (f : Πa b c d, E a b c d → Z) (Ha : a = a') (Hb : transport B Ha b = b')\n    (Hc : cast (apdt011 C Ha Hb) c = c') (Hd : cast (apdt0111 D Ha Hb Hc) d = d')\n    (He : cast (apdt01111 E Ha Hb Hc Hd) e = e')\n    : f a b c d e = f a' b' c' d' e' :=\n  by induction Ha; induction Hb; induction Hc; induction Hd; induction He; reflexivity\n\n  @[hott] def apdt0111111 (f : Πa b c d e, F a b c d e → Z) (Ha : a = a') (Hb : transport B Ha b = b')\n    (Hc : cast (apdt011 C Ha Hb) c = c') (Hd : cast (apdt0111 D Ha Hb Hc) d = d')\n    (He : cast (apdt01111 E Ha Hb Hc Hd) e = e') (Hf : cast (apdt011111 F Ha Hb Hc Hd He) ff = f')\n    : f a b c d e ff = f a' b' c' d' e' f' :=\n  begin induction Ha, induction Hb, induction Hc, induction Hd, induction He, induction Hf, reflexivity end\n\n  -- @[hott] def apd0111111 (f : Πa b c d e ff, G a b c d e ff → Z) (Ha : a = a') (Hb : transport B Ha b = b')\n  --   (Hc : cast (apd011 C Ha Hb) c = c') (Hd : cast (apd0111 D Ha Hb Hc) d = d')\n  --   (He : cast (apd01111 E Ha Hb Hc Hd) e = e') (Hf : cast (apd011111 F Ha Hb Hc Hd He) ff = f')\n  --   (Hg : cast (apd0111111 G Ha Hb Hc Hd He Hf) g = g')\n  --   : f a b c d e ff g = f a' b' c' d' e' f' g' :=\n  -- by induction Ha; induction Hb; induction Hc; induction Hd; induction He; induction Hf; induction Hg; reflexivity\n\n  -- @[hott] def apd01111111 (f : Πa b c d e ff g, G a b c d e ff g → Z) (Ha : a = a') (Hb : transport B Ha b = b')\n  --   (Hc : cast (apd011 C Ha Hb) c = c') (Hd : cast (apd0111 D Ha Hb Hc) d = d')\n  --   (He : cast (apd01111 E Ha Hb Hc Hd) e = e') (Hf : cast (apd011111 F Ha Hb Hc Hd He) ff = f')\n  --   (Hg : cast (apd0111111 G Ha Hb Hc Hd He Hf) g = g') (Hh : cast (apd01111111 H Ha Hb Hc Hd He Hf Hg) h = h')\n  --   : f a b c d e ff g h = f a' b' c' d' e' f' g' h' :=\n  -- by induction Ha; induction Hb; induction Hc; induction Hd; induction He; induction Hf; induction Hg; induction Hh; reflexivity\n\n  @[hott] def apd100 {f g : Πa b, C a b} (p : f = g) : f ~2 g :=\n  λa b, apd10 (apd10 p a) b\n\n  @[hott] def apd1000 {f g : Πa b c, D a b c} (p : f = g) : f ~3 g :=\n  λa b c, apd100 (apd10 p a) b c\n\n  /- some properties of these variants of ap -/\n\n  -- we only prove what we currently need\n\n  @[hott] def ap010_con (f : X → Πa, B a) (p : x = x') (q : x' = x'') :\n    ap010 f (p ⬝ q) a = ap010 f p a ⬝ ap010 f q a :=\n  eq.rec_on q (eq.rec_on p idp)\n\n  @[hott] def ap010_ap (f : X → Πa, B a) (g : Y → X) (p : y = y') :\n    ap010 f (ap g p) a = (ap010 (f ∘ g) p) a :=\n  eq.rec_on p idp\n\n  @[hott] def ap_eq_ap010 {A B C : Type _} (f : A → B → C) {a a' : A} (p : a = a') (b : B) :\n    ap (λa, f a b) p = ap010 f p b :=\n  idp\n\n  @[hott] def ap011_idp {A B C : Type _} (f : A → B → C) {a a' : A} (p : a = a') (b : B) :\n    ap011 f p idp = ap010 f p b :=\n  by reflexivity\n\n  @[hott] def ap011_flip {A B C : Type _} (f : A → B → C) {a a' : A} {b b' : B} (p : a = a') (q : b = b') :\n    ap011 f p q = (ap011 (λb a, f a b) q) p :=\n  by induction q; induction p; reflexivity\n\n  /- the following theorems are function extentionality for functions with multiple arguments -/\n\n  @[hott] def eq_of_homotopy2 {f g : Πa b, C a b} (H : f ~2 g) : f = g :=\n  eq_of_homotopy (λa, eq_of_homotopy (H a))\n\n  @[hott] def eq_of_homotopy3 {f g : Πa b c, D a b c} (H : f ~3 g) : f = g :=\n  eq_of_homotopy (λa, eq_of_homotopy2 (H a))\n\n  @[hott] def eq_of_homotopy2_id (f : Πa b, C a b)\n    : eq_of_homotopy2 (λa b, idpath (f a b)) = idpath f :=\n  begin\n    transitivity eq_of_homotopy (λ a, idpath (f a)),\n      {apply (ap eq_of_homotopy), apply eq_of_homotopy, intro, apply eq_of_homotopy_idp},\n      apply eq_of_homotopy_idp\n  end\n\n  @[hott] def eq_of_homotopy3_id (f : Πa b c, D a b c)\n    : eq_of_homotopy3 (λa b c, idpath (f a b c)) = idpath f :=\n  begin\n    transitivity _,\n      {apply (ap eq_of_homotopy), apply eq_of_homotopy, intro, apply eq_of_homotopy2_id},\n      apply eq_of_homotopy_idp\n  end\n\n  @[hott] def eq_of_homotopy2_inv {f g : Πa b, C a b} (H : f ~2 g)\n    : eq_of_homotopy2 (λa b, (H a b).inverse) = (eq_of_homotopy2 H)⁻¹ :=\n  begin\n    transitivity,\n    {dsimp [eq_of_homotopy2], apply ap, apply eq_of_homotopy, intro, apply eq_of_homotopy_inv},\n    {apply eq_of_homotopy_inv}\n  end\n\n  @[hott] def eq_of_homotopy3_inv {f g : Πa b c, D a b c} (H : f ~3 g)\n    : eq_of_homotopy3 (λa b c, (H a b c).inverse) = (eq_of_homotopy3 H)⁻¹ :=\n  begin\n    transitivity,\n    {dsimp [eq_of_homotopy3], apply ap, apply eq_of_homotopy, intro, apply eq_of_homotopy2_inv},\n    {apply eq_of_homotopy_inv}\n  end\n\n  @[hott] def eq_of_homotopy2_con {f g h : Πa b, C a b} (H1 : f ~2 g) (H2 : g ~2 h)\n    : eq_of_homotopy2 (λa b, H1 a b ⬝ H2 a b) = eq_of_homotopy2 H1 ⬝ eq_of_homotopy2 H2 :=\n  begin\n    transitivity,\n    {dsimp [eq_of_homotopy2], apply ap, apply eq_of_homotopy, intro, apply eq_of_homotopy_con},\n    {apply eq_of_homotopy_con}\n  end\n\n  @[hott] def eq_of_homotopy3_con {f g h : Πa b c, D a b c} (H1 : f ~3 g) (H2 : g ~3 h)\n    : eq_of_homotopy3 (λa b c, H1 a b c ⬝ H2 a b c) = eq_of_homotopy3 H1 ⬝ eq_of_homotopy3 H2 :=\n  begin\n    transitivity,\n    {dsimp [eq_of_homotopy3], apply ap, apply eq_of_homotopy, intro, apply eq_of_homotopy2_con},\n    {apply eq_of_homotopy_con}\n  end\n\nend eq\n\nopen hott.eq hott.equiv hott.is_equiv\nnamespace funext\n  @[hott, instance] def is_equiv_apd100 (f g : Πa b, C a b)\n    : is_equiv (@apd100 A B C f g) :=\n  adjointify _\n             eq_of_homotopy2\n             begin\n               intro H, dsimp [apd100, eq_of_homotopy2],\n               apply eq_of_homotopy, intro a,\n               apply concat, apply (ap (λx : Π a, f a = g a, apd10 (x a))), apply (right_inv apd10),\n               apply (right_inv apd10)\n             end\n             begin\n               intro p, induction p, apply eq_of_homotopy2_id\n             end\n\n  @[hott, instance] def is_equiv_apd1000 (f g : Πa b c, D a b c)\n    : is_equiv (@apd1000 A B C D f g) :=\n  adjointify _\n             eq_of_homotopy3\n             begin\n               intro H, dsimp,\n               apply eq_of_homotopy, intro a,\n               transitivity apd100 (eq_of_homotopy2 (H a)),\n                 {apply ap (λ x : Π a, f a = g a, apd100 (x a)),\n                  apply right_inv apd10},\n                 apply right_inv apd100\n             end\n             begin\n               intro p, induction p, apply eq_of_homotopy3_id\n             end\nend funext\n\nnamespace eq\n  open funext\n  local attribute [instance] funext.is_equiv_apd100\n  @[hott] protected def homotopy2.rec_on {f g : Πa b, C a b} {P : (f ~2 g) → Type _}\n    (p : f ~2 g) (H : Π(q : f = g), P (apd100 q)) : P p :=\n  right_inv apd100 p ▸ H (eq_of_homotopy2 p)\n\n  @[hott] protected def homotopy3.rec_on {f g : Πa b c, D a b c} {P : (f ~3 g) → Type _}\n    (p : f ~3 g) (H : Π(q : f = g), P (apd1000 q)) : P p :=\n  right_inv apd1000 p ▸ H (eq_of_homotopy3 p)\n\n  @[hott] def eq_equiv_homotopy2 (f g : Πa b, C a b) : (f = g) ≃ (f ~2 g) :=\n  equiv.mk apd100 (by apply_instance)\n\n  @[hott] def eq_equiv_homotopy3 (f g : Πa b c, D a b c) : (f = g) ≃ (f ~3 g) :=\n  equiv.mk apd1000 (by apply_instance)\n\n  @[hott] def apd10_ap (f : X → Πa, B a) (p : x = x')\n    : apd10 (ap f p) = ap010 f p :=\n  eq.rec_on p idp\n\n  @[hott] def eq_of_homotopy_ap010 (f : X → Πa, B a) (p : x = x')\n    : eq_of_homotopy (ap010 f p) = ap f p :=\n  inv_eq_of_eq (apd10_ap _ _)⁻¹\n\n  @[hott] def ap_eq_ap_of_homotopy {f : X → Πa, B a} {p q : x = x'} (H : ap010 f p ~ ap010 f q)\n    : ap f p = ap f q :=\n  calc\n    ap f p = eq_of_homotopy (ap010 f p) : by symmetry; apply eq_of_homotopy_ap010\n       ... = eq_of_homotopy (ap010 f q) : by apply ap; apply eq_of_homotopy H\n       ... = ap f q                     : by apply eq_of_homotopy_ap010\n\nend eq\n\nend hott\n", "meta": {"author": "gebner", "repo": "hott3", "sha": "7ead7a8a2503049eacd45cbff6587802bae2add2", "save_path": "github-repos/lean/gebner-hott3", "path": "github-repos/lean/gebner-hott3/hott3-7ead7a8a2503049eacd45cbff6587802bae2add2/src/hott/arity.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4557794469571656}}
{"text": "/-\nCopyright (c) 2022 Aaron Anderson. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Aaron Anderson\n-/\nimport model_theory.substructures\n\n/-!\n# Finitely Generated First-Order Structures\nThis file defines what it means for a first-order (sub)structure to be finitely or countably\ngenerated, similarly to other finitely-generated objects in the algebra library.\n\n## Main Definitions\n* `first_order.language.substructure.fg` indicates that a substructure is finitely generated.\n* `first_order.language.Structure.fg` indicates that a structure is finitely generated.\n* `first_order.language.substructure.cg` indicates that a substructure is countably generated.\n* `first_order.language.Structure.cg` indicates that a structure is countably generated.\n\n\n## TODO\nDevelop a more unified definition of finite generation using the theory of closure operators, or use\nthis definition of finite generation to define the others.\n\n-/\n\nopen_locale first_order\nopen set\n\nnamespace first_order\nnamespace language\nopen Structure\n\nvariables {L : language} {M : Type*} [L.Structure M]\n\nnamespace substructure\n\n/-- A substructure of `M` is finitely generated if it is the closure of a finite subset of `M`. -/\ndef fg (N : L.substructure M) : Prop := ∃ S : finset M, closure L ↑S = N\n\ntheorem fg_def {N : L.substructure M} :\n  N.fg ↔ ∃ S : set M, S.finite ∧ closure L S = N :=\n⟨λ ⟨t, h⟩, ⟨_, finset.finite_to_set t, h⟩, begin\n  rintro ⟨t', h, rfl⟩,\n  rcases finite.exists_finset_coe h with ⟨t, rfl⟩,\n  exact ⟨t, rfl⟩\nend⟩\n\nlemma fg_iff_exists_fin_generating_family {N : L.substructure M} :\n  N.fg ↔ ∃ (n : ℕ) (s : fin n → M), closure L (range s) = N :=\nbegin\n  rw fg_def,\n  split,\n  { rintros ⟨S, Sfin, hS⟩,\n    obtain ⟨n, f, rfl⟩ := Sfin.fin_embedding,\n    exact ⟨n, f, hS⟩, },\n  { rintros ⟨n, s, hs⟩,\n    refine ⟨range s, finite_range s, hs⟩ },\nend\n\ntheorem fg_bot : (⊥ : L.substructure M).fg :=\n⟨∅, by rw [finset.coe_empty, closure_empty]⟩\n\ntheorem fg_closure {s : set M} (hs : s.finite) : fg (closure L s) :=\n⟨hs.to_finset, by rw [hs.coe_to_finset]⟩\n\ntheorem fg_closure_singleton (x : M) : fg (closure L ({x} : set M)) :=\nfg_closure (finite_singleton x)\n\ntheorem fg.sup {N₁ N₂ : L.substructure M}\n  (hN₁ : N₁.fg) (hN₂ : N₂.fg) : (N₁ ⊔ N₂).fg :=\nlet ⟨t₁, ht₁⟩ := fg_def.1 hN₁, ⟨t₂, ht₂⟩ := fg_def.1 hN₂ in\nfg_def.2 ⟨t₁ ∪ t₂, ht₁.1.union ht₂.1, by rw [closure_union, ht₁.2, ht₂.2]⟩\n\ntheorem fg.map {N : Type*} [L.Structure N] (f : M →[L] N) {s : L.substructure M} (hs : s.fg) :\n  (s.map f).fg :=\nlet ⟨t, ht⟩ := fg_def.1 hs in fg_def.2 ⟨f '' t, ht.1.image _, by rw [closure_image, ht.2]⟩\n\ntheorem fg.of_map_embedding {N : Type*} [L.Structure N] (f : M ↪[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).fg) : s.fg :=\nbegin\n  rcases hs with ⟨t, h⟩,\n  rw fg_def,\n  refine ⟨f ⁻¹' t, t.finite_to_set.preimage (f.injective.inj_on _), _⟩,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [← h, map_closure, embedding.coe_to_hom, image_preimage_eq_of_subset],\n  intros x hx,\n  have h' := subset_closure hx,\n  rw h at h',\n  exact hom.map_le_range h'\nend\n\n/-- A substructure of `M` is countably generated if it is the closure of a countable subset of `M`.\n-/\ndef cg (N : L.substructure M) : Prop := ∃ S : set M, S.countable ∧ closure L S = N\n\n\n\ntheorem fg.cg {N : L.substructure M} (h : N.fg) : N.cg :=\nbegin\n  obtain ⟨s, hf, rfl⟩ := fg_def.1 h,\n  refine ⟨s, hf.countable, rfl⟩,\nend\n\nlemma cg_iff_empty_or_exists_nat_generating_family {N : L.substructure M} :\n  N.cg ↔ (↑N = (∅ : set M)) ∨ ∃ (s : ℕ → M), closure L (range s) = N :=\nbegin\n  rw cg_def,\n  split,\n  { rintros ⟨S, Scount, hS⟩,\n    cases eq_empty_or_nonempty ↑N with h h,\n    { exact or.intro_left _ h },\n    obtain ⟨f, h'⟩ := (Scount.union (set.countable_singleton h.some)).exists_eq_range\n      (singleton_nonempty h.some).inr,\n    refine or.intro_right _ ⟨f, _⟩,\n    rw [← h', closure_union, hS, sup_eq_left, closure_le],\n    exact singleton_subset_iff.2 h.some_mem },\n  { intro h,\n    cases h with h h,\n    { refine ⟨∅, countable_empty, closure_eq_of_le (empty_subset _) _⟩,\n      rw [← set_like.coe_subset_coe, h],\n      exact empty_subset _ },\n    { obtain ⟨f, rfl⟩ := h,\n      exact ⟨range f, countable_range _, rfl⟩ } },\nend\n\ntheorem cg_bot : (⊥ : L.substructure M).cg := fg_bot.cg\n\ntheorem cg_closure {s : set M} (hs : s.countable) : cg (closure L s) :=\n⟨s, hs, rfl⟩\n\ntheorem cg_closure_singleton (x : M) : cg (closure L ({x} : set M)) := (fg_closure_singleton x).cg\n\ntheorem cg.sup {N₁ N₂ : L.substructure M}\n  (hN₁ : N₁.cg) (hN₂ : N₂.cg) : (N₁ ⊔ N₂).cg :=\nlet ⟨t₁, ht₁⟩ := cg_def.1 hN₁, ⟨t₂, ht₂⟩ := cg_def.1 hN₂ in\ncg_def.2 ⟨t₁ ∪ t₂, ht₁.1.union ht₂.1, by rw [closure_union, ht₁.2, ht₂.2]⟩\n\ntheorem cg.map {N : Type*} [L.Structure N] (f : M →[L] N) {s : L.substructure M} (hs : s.cg) :\n  (s.map f).cg :=\nlet ⟨t, ht⟩ := cg_def.1 hs in cg_def.2 ⟨f '' t, ht.1.image _, by rw [closure_image, ht.2]⟩\n\ntheorem cg.of_map_embedding {N : Type*} [L.Structure N] (f : M ↪[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).cg) : s.cg :=\nbegin\n  rcases hs with ⟨t, h1, h2⟩,\n  rw cg_def,\n  refine ⟨f ⁻¹' t, h1.preimage f.injective, _⟩,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [← h2, map_closure, embedding.coe_to_hom, image_preimage_eq_of_subset],\n  intros x hx,\n  have h' := subset_closure hx,\n  rw h2 at h',\n  exact hom.map_le_range h'\nend\n\ntheorem cg_iff_countable [countable (Σl, L.functions l)] {s : L.substructure M} :\n  s.cg ↔ countable s :=\nbegin\n  refine ⟨_, λ h, ⟨s, h.to_set, s.closure_eq⟩⟩,\n  rintro ⟨s, h, rfl⟩,\n  exact h.substructure_closure L\nend\n\nend substructure\n\nopen substructure\n\nnamespace Structure\n\nvariables (L) (M)\n\n/-- A structure is finitely generated if it is the closure of a finite subset. -/\nclass fg : Prop := (out : (⊤ : L.substructure M).fg)\n\n/-- A structure is countably generated if it is the closure of a countable subset. -/\nclass cg : Prop := (out : (⊤ : L.substructure M).cg)\n\nvariables {L M}\n\nlemma fg_def : fg L M ↔ (⊤ : L.substructure M).fg := ⟨λ h, h.1, λ h, ⟨h⟩⟩\n\n/-- An equivalent expression of `Structure.fg` in terms of `set.finite` instead of `finset`. -/\nlemma fg_iff : fg L M ↔ ∃ S : set M, S.finite ∧ closure L S = (⊤ : L.substructure M) :=\nby rw [fg_def, substructure.fg_def]\n\nlemma fg.range {N : Type*} [L.Structure N] (h : fg L M) (f : M →[L] N) :\n  f.range.fg :=\nbegin\n  rw [hom.range_eq_map],\n  exact (fg_def.1 h).map f,\nend\n\nlemma fg.map_of_surjective {N : Type*} [L.Structure N] (h : fg L M) (f : M →[L] N)\n  (hs : function.surjective f) :\n  fg L N :=\nbegin\n  rw ← hom.range_eq_top at hs,\n  rw [fg_def, ← hs],\n  exact h.range f,\nend\n\n\n\n/-- An equivalent expression of `Structure.cg`. -/\nlemma cg_iff : cg L M ↔ ∃ S : set M, S.countable ∧ closure L S = (⊤ : L.substructure M) :=\nby rw [cg_def, substructure.cg_def]\n\nlemma cg.range {N : Type*} [L.Structure N] (h : cg L M) (f : M →[L] N) :\n  f.range.cg :=\nbegin\n  rw [hom.range_eq_map],\n  exact (cg_def.1 h).map f,\nend\n\nlemma cg.map_of_surjective {N : Type*} [L.Structure N] (h : cg L M) (f : M →[L] N)\n  (hs : function.surjective f) :\n  cg L N :=\nbegin\n  rw ← hom.range_eq_top at hs,\n  rw [cg_def, ← hs],\n  exact h.range f,\nend\n\nlemma cg_iff_countable [countable (Σl, L.functions l)] : cg L M ↔ countable M :=\nby rw [cg_def, cg_iff_countable, top_equiv.to_equiv.countable_iff]\n\nlemma fg.cg (h : fg L M) : cg L M :=\ncg_def.2 (fg_def.1 h).cg\n\n@[priority 100] instance cg_of_fg [h : fg L M] : cg L M := h.cg\n\nend Structure\n\nlemma equiv.fg_iff {N : Type*} [L.Structure N] (f : M ≃[L] N) :\n  Structure.fg L M ↔ Structure.fg L N :=\n⟨λ h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  λ h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective⟩\n\nlemma substructure.fg_iff_Structure_fg (S : L.substructure M) :\n  S.fg ↔ Structure.fg L S :=\nbegin\n  rw Structure.fg_def,\n  refine ⟨λ h, fg.of_map_embedding S.subtype _, λ h, _⟩,\n  { rw [← hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [← hom.range_eq_map, range_subtype] at h,\n    exact h }\nend\n\nlemma equiv.cg_iff {N : Type*} [L.Structure N] (f : M ≃[L] N) :\n  Structure.cg L M ↔ Structure.cg L N :=\n⟨λ h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  λ h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective⟩\n\nlemma substructure.cg_iff_Structure_cg (S : L.substructure M) :\n  S.cg ↔ Structure.cg L S :=\nbegin\n  rw Structure.cg_def,\n  refine ⟨λ h, cg.of_map_embedding S.subtype _, λ h, _⟩,\n  { rw [← hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [← hom.range_eq_map, range_subtype] at h,\n    exact h }\nend\n\nend language\nend first_order\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/model_theory/finitely_generated.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334527, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4557794386973959}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes Hölzl (CMU)\n-/\n\nnamespace name\n\ndef last_string : name → string\n| anonymous        := \"[anonymous]\"\n| (mk_string s _)  := s\n| (mk_numeral _ n) := last_string n\n\nend name\n\nnamespace expr\nopen expr\n\nmeta def replace_with (e : expr) (s : expr) (s' : expr) : expr :=\ne.replace $ λc d, if c = s then some (s'.lift_vars 0 d) else none\n\nmeta def local_binder_info : expr → binder_info\n| (local_const x n bi t) := bi\n| e                      := binder_info.default\n\nmeta def to_implicit_binder : expr → expr\n| (local_const n₁ n₂ _ d) := local_const n₁ n₂ binder_info.implicit d\n| (lam n _ d b) := lam n binder_info.implicit d b\n| (pi n _ d b) := pi n binder_info.implicit d b\n| e  := e\n\nmeta def get_app_fn_args_aux : list expr → expr → expr × list expr\n| r (app f a) := get_app_fn_args_aux (a::r) f\n| r e         := (e, r)\n\nmeta def get_app_fn_args : expr → expr × list expr :=\nget_app_fn_args_aux []\n\nend expr\n\nnamespace tactic\nopen level expr tactic\n\nmeta def mk_local_pisn : expr → nat → tactic (list expr × expr)\n| (pi n bi d b) (c + 1) := do\n  p ← mk_local' n bi d,\n  (ps, r) ← mk_local_pisn (b.instantiate_var p) c,\n  return ((p :: ps), r)\n| e 0 := return ([], e)\n| _ _ := failed\n\nmeta def drop_pis : list expr → expr → tactic expr\n| (list.cons v vs) (pi n bi d b) := do\n  t ← infer_type v,\n  guard (t =ₐ d),\n  drop_pis vs (b.instantiate_var v)\n| [] e := return e\n| _  _ := failed\n\nmeta def mk_theorem (n : name) (ls : list name) (t : expr) (e : expr) : declaration :=\ndeclaration.thm n ls t (task.pure e)\n\nmeta def add_theorem_by (n : name) (ls : list name) (type : expr) (tac : tactic unit) : tactic expr := do\n  ((), body) ← solve_aux type tac,\n  body ← instantiate_mvars body,\n  add_decl $ mk_theorem n ls type body,\n  return $ const n $ ls.map param\n\nmeta def mk_exists_lst (args : list expr) (inner : expr) : tactic expr :=\nargs.mfoldr (λarg i:expr, do\n    t ← infer_type arg,\n    sort l ← infer_type t,\n    return $ if arg.occurs i ∨ l ≠ level.zero\n      then (const `Exists [l] : expr) t (i.lambdas [arg])\n      else (const `and [] : expr) t i)\n  inner\n\nmeta def mk_op_lst (op : expr) (empty : expr) : list expr → expr\n| []        := empty\n| [e]       := e\n| (e :: es) := op e $ mk_op_lst es\n\nmeta def mk_and_lst : list expr → expr := mk_op_lst `(and) `(true)\n\nmeta def mk_or_lst : list expr → expr := mk_op_lst `(or) `(false)\n\nmeta def elim_gen_prod : nat → expr → list expr → tactic (list expr × expr)\n| 0       e hs := return (hs, e)\n| (n + 1) e hs := do\n  [(_, [h, h'], _)] ← induction e [],\n  elim_gen_prod n h' (hs ++ [h])\n\nprivate meta def elim_gen_sum_aux : nat → expr → list expr → tactic (list expr × expr)\n| 0       e hs := return (hs, e)\n| (n + 1) e hs := do\n  [(_, [h], _), (_, [h'], _)] ← induction e [],\n  swap,\n  elim_gen_sum_aux n h' (h::hs)\n\nmeta def elim_gen_sum (n : nat) (e : expr) : tactic (list expr) := do\n  (hs, h') ← elim_gen_sum_aux n e [],\n  gs ← get_goals,\n  set_goals $ (gs.take (n+1)).reverse ++ gs.drop (n+1),\n  return $ hs.reverse ++ [h']\n\nend tactic\n\nsection\nuniverse u\n\n@[user_attribute]\nmeta def monotonicity : user_attribute := { name := `monotonicity, descr := \"Monotonicity rules for predicates\" }\n\nlemma monotonicity.pi {α : Sort u} {p q : α → Prop} (h : ∀a, implies (p a) (q a)) :\n  implies (Πa, p a) (Πa, q a) :=\nassume h' a, h a (h' a)\n\nlemma monotonicity.imp {p p' q q' : Prop} (h₁ : implies p' q') (h₂ : implies q p) :\n  implies (p → p') (q → q') :=\nassume h, h₁ ∘ h ∘ h₂\n\n@[monotonicity]\nlemma monotonicity.const (p : Prop) : implies p p := id\n\n@[monotonicity]\nlemma monotonicity.true (p : Prop) : implies p true := assume _, trivial\n\n@[monotonicity]\nlemma monotonicity.false (p : Prop) : implies false p := false.elim\n\n@[monotonicity]\nlemma monotonicity.exists {α : Sort u} {p q : α → Prop} (h : ∀a, implies (p a) (q a)) :\n  implies (∃a, p a) (∃a, q a) :=\nexists_imp_exists h\n\n@[monotonicity]\nlemma monotonicity.and {p p' q q' : Prop} (hp : implies p p') (hq : implies q q') :\n  implies (p ∧ q) (p' ∧ q') :=\nand.imp hp hq\n\n@[monotonicity]\nlemma monotonicity.or {p p' q q' : Prop} (hp : implies p p') (hq : implies q q') :\n  implies (p ∨ q) (p' ∨ q') :=\nor.imp hp hq\n\n@[monotonicity]\nlemma monotonicity.not {p q : Prop} (h : implies p q) :\n  implies (¬ q) (¬ p) :=\nmt h\n\nend\n\nnamespace tactic\nopen expr tactic\n\n/- TODO: use backchaining -/\nprivate meta def mono_aux (ns : list name) (hs : list expr) : tactic unit := do\n  intros,\n  (do\n    `(implies %%p %%q) ← target,\n    (do is_def_eq p q, eapplyc `monotone.const) <|>\n    (do\n      (expr.pi pn pbi pd pb) ← whnf p,\n      (expr.pi qn qbi qd qb) ← whnf q,\n      sort u ← infer_type pd,\n      (do is_def_eq pd qd,\n        let p' := expr.lam pn pbi pd pb,\n        let q' := expr.lam qn qbi qd qb,\n        eapply ((const `monotonicity.pi [u] : expr) pd p' q'),\n        skip) <|>\n      (do guard $ u = level.zero ∧ is_arrow p ∧ is_arrow q,\n        let p' := pb.lower_vars 0 1,\n        let q' := qb.lower_vars 0 1,\n        eapply ((const `monotonicity.imp []: expr) pd p' qd q'),\n        skip))) <|>\n  first (hs.map $ λh, apply_core h {md := transparency.none, new_goals := new_goals.non_dep_only} >> skip) <|>\n  first (ns.map $ λn, do c ← mk_const n, apply_core c {md := transparency.none, new_goals := new_goals.non_dep_only}, skip),\n  all_goals mono_aux\n\nmeta def mono (e : expr) (hs : list expr) : tactic unit := do\n  t ← target,\n  t' ← infer_type e,\n  ns ← attribute.get_instances `monotonicity,\n  ((), p) ← solve_aux `(implies %%t' %%t) (mono_aux ns hs),\n  exact (p e)\n\nend tactic\n\n/-\nThe coinductive predicate `pred`:\n\n  coinductive {u} pred (A) : a → Prop\n  | r : ∀A b, pred A p\n\nwhere\n  `u` is a list of universe parameters\n  `A` is a list of global parameters\n  `pred` is a list predicates to be defined\n  `a` are the indices for each `pred`\n  `r` is a list of introduction rules for each `pred`\n  `b` is a list of parameters for each rule in `r` and `pred`\n  `p` is are the instances of `a` using `A` and `b`\n\n`pred` is compiled to the following defintions:\n\n  inductive {u} pred.functional (A) ([pred'] : a → Prop) : a → Prop\n  | r : ∀a [f], b[pred/pred'] → pred.functional a [f] p\n\n  lemma {u} pred.functional.mono (A) ([pred₁] [pred₂] : a → Prop) [(h : ∀b, pred₁ b → pred₂ b)] :\n    ∀p, pred.functional A pred₁ p → pred.functional A pred₂ p\n\n  def {u} pred_i (A) (a) : Prop :=\n  ∃[pred'], (Λi, ∀a, pred_i a → pred_i.functional A [pred] a) ∧ pred'_i a\n\n  lemma {u} pred_i.corec_functional (A) [Λi, C_i : a_i → Prop] [Λi, h : ∀a, C_i a → pred_i.functional A C_i a] :\n    ∀a, C_i a → pred_i A a\n\n  lemma {u} pred_i.destruct (A) (a) : pred A a → pred.functional A [pred A] a\n\n  lemma {u} pred_i.construct (A) : ∀a, pred_i.functional A [pred A] a → pred_i A a\n\n  lemma {u} pred_i.cases_on (A) (C : a → Prop) {a} (h : pred_i a) [Λi, ∀a, b → C p] → C a\n\n  lemma {u} pred_i.corec_on (A) [(C : a → Prop)] (a) (h : C_i a)\n    [Λi, h_i : ∀a, C_i a → [V j ∃b, a = p]] : pred_i A a\n\n  lemma {u} pred.r (A) (b) : pred_i A p\n-/\n\nnamespace tactic\nopen level expr tactic\n\nnamespace add_coinductive_predicate\n\n/- private -/ meta structure coind_rule : Type :=\n(orig_nm  : name)\n(func_nm  : name)\n(type     : expr)\n(loc_type : expr)\n(args     : list expr)\n(loc_args : list expr)\n(concl    : expr)\n(insts    : list expr)\n\n/- private -/ meta structure coind_pred : Type :=\n(u_names  : list name)\n(params   : list expr)\n(pd_name  : name)\n(type     : expr)\n(intros   : list coind_rule)\n(locals   : list expr)\n(f₁ f₂    : expr)\n(u_f      : level)\n\nnamespace coind_pred\n\nmeta def u_params (pd : coind_pred) : list level :=\npd.u_names.map param\n\nmeta def f₁_l (pd : coind_pred) : expr :=\npd.f₁.app_of_list pd.locals\n\nmeta def f₂_l (pd : coind_pred) : expr :=\npd.f₂.app_of_list pd.locals\n\nmeta def pred (pd : coind_pred) : expr :=\nconst pd.pd_name pd.u_params\n\nmeta def func (pd : coind_pred) : expr :=\nconst (pd.pd_name ++ \"functional\") pd.u_params\n\nmeta def func_g (pd : coind_pred) : expr :=\npd.func.app_of_list $ pd.params\n\nmeta def pred_g (pd : coind_pred) : expr :=\npd.pred.app_of_list $ pd.params\n\nmeta def impl_locals (pd : coind_pred) : list expr :=\npd.locals.map to_implicit_binder\n\nmeta def impl_params (pd : coind_pred) : list expr :=\npd.params.map to_implicit_binder\n\nmeta def le (pd : coind_pred) (f₁ f₂ : expr) : expr :=\n(imp (f₁.app_of_list pd.locals) (f₂.app_of_list pd.locals)).pis pd.impl_locals\n\nmeta def corec_functional (pd : coind_pred) : expr :=\nconst (pd.pd_name ++ \"corec_functional\") pd.u_params\n\nmeta def mono (pd : coind_pred) : expr :=\nconst (pd.func.const_name ++ \"mono\") pd.u_params\n\nmeta def rec' (pd : coind_pred) : tactic expr :=\ndo let c := pd.func.const_name ++ \"rec\",\n   env  ← get_env,\n   decl ← env.get c,\n   let num := decl.univ_params.length,\n   return (const c $ if num = pd.u_params.length then pd.u_params else level.zero :: pd.u_params)\n  -- ^^ `rec`'s universes are not always `u_params`, e.g. eq, wf, false\n\nmeta def construct (pd : coind_pred) : expr :=\nconst (pd.pd_name ++ \"construct\") pd.u_params\n\nmeta def destruct (pd : coind_pred) : expr :=\nconst (pd.pd_name ++ \"destruct\") pd.u_params\n\nmeta def add_theorem (pd : coind_pred) (n : name) (type : expr) (tac : tactic unit) : tactic expr :=\nadd_theorem_by n pd.u_names type tac\n\nend coind_pred\n\nend add_coinductive_predicate\n\nopen add_coinductive_predicate\n\n/- compact_relation bs as_ps: Product a relation of the form:\n  R := λ as, ∃ bs, Λ_i a_i = p_i[bs]\nThis relation is user visible, so we compact it by removing each `b_j` where a `p_i = b_j`, and\nhence `a_i = b_j`. We need to take care when there are `p_i` and `p_j` with `p_i = p_j = b_k`. -/\nprivate meta def compact_relation :\n  list expr → list (expr × expr) → list expr × list (expr × expr)\n| [] ps      := ([], ps)\n| (list.cons b bs) ps :=\n  match ps.span (λap:expr × expr, ¬ ap.2 =ₐ b) with\n    | (_, [])           := let (bs, ps) := compact_relation bs ps in (b::bs, ps)\n    | (ps₁, list.cons (a, _) ps₂) := let i := a.instantiate_local b.local_uniq_name in\n      compact_relation (bs.map i) ((ps₁ ++ ps₂).map (λ⟨a, p⟩, (a, i p)))\n  end\n\nmeta def add_coinductive_predicate\n  (u_names : list name) (params : list expr) (preds : list $ expr × list expr) : command := do\n  let params_names := params.map local_pp_name,\n  let u_params := u_names.map param,\n\n  pre_info ← preds.mmap (λ⟨c, is⟩, do\n    (ls, t) ← mk_local_pis c.local_type,\n    (is_def_eq t `(Prop) <|>\n      fail (format! \"Type of {c.local_pp_name} is not Prop. Currently only \" ++\n                    \"coinductive predicates are supported.\")),\n    let n := if preds.length = 1 then \"\" else \"_\" ++ c.local_pp_name.last_string,\n    f₁ ← mk_local_def (mk_simple_name $ \"C\" ++ n) c.local_type,\n    f₂ ← mk_local_def (mk_simple_name $ \"C₂\" ++ n) c.local_type,\n    return (ls, (f₁, f₂))),\n\n  let fs := pre_info.map prod.snd,\n  let fs₁ := fs.map prod.fst,\n  let fs₂ := fs.map prod.snd,\n\n  pds ← (preds.zip pre_info).mmap (λ⟨⟨c, is⟩, ls, f₁, f₂⟩, do\n    sort u_f ← infer_type f₁ >>= infer_type,\n    let pred_g := λc:expr, (const c.local_uniq_name u_params : expr).app_of_list params,\n    intros ← is.mmap (λi, do\n      (args, t') ← mk_local_pis i.local_type,\n      (name.mk_string sub p) ← return i.local_uniq_name,\n      let loc_args := args.map $ λe, (fs₁.zip preds).foldl (λ(e:expr) ⟨f, c, _⟩,\n        e.replace_with (pred_g c) f) e,\n      let t' := t'.replace_with (pred_g c) f₂,\n      return { tactic.add_coinductive_predicate.coind_rule .\n        orig_nm  := i.local_uniq_name,\n        func_nm  := (p ++ \"functional\") ++ sub,\n        type     := i.local_type,\n        loc_type := t'.pis loc_args,\n        concl    := t',\n        loc_args := loc_args,\n        args     := args,\n        insts    := t'.get_app_args }),\n    return { tactic.add_coinductive_predicate.coind_pred .\n      pd_name := c.local_uniq_name, type := c.local_type, f₁ := f₁, f₂ := f₂, u_f := u_f,\n      intros := intros, locals := ls, params := params, u_names := u_names }),\n\n  /- Introduce all functionals -/\n  pds.mmap' (λpd:coind_pred, do\n    let func_f₁ := pd.func_g.app_of_list $ fs₁,\n    let func_f₂ := pd.func_g.app_of_list $ fs₂,\n\n    /- Define functional for `pd` as inductive predicate -/\n    func_intros ← pd.intros.mmap (λr:coind_rule, do\n      let t := instantiate_local pd.f₂.local_uniq_name (pd.func_g.app_of_list fs₁) r.loc_type,\n      return (r.func_nm, r.orig_nm, t.pis $ params ++ fs₁)),\n    add_inductive pd.func.const_name u_names\n      (params.length + preds.length) (pd.type.pis $ params ++ fs₁) (func_intros.map $ λ⟨t, _, r⟩, (t, r)),\n\n    /- Prove monotonicity rule -/\n    mono_params ← pds.mmap (λpd, do\n      h ← mk_local_def `h $ pd.le pd.f₁ pd.f₂,\n      return [pd.f₁, pd.f₂, h]),\n    pd.add_theorem (pd.func.const_name ++ \"mono\")\n      ((pd.le func_f₁ func_f₂).pis $ params ++ mono_params.join)\n      (do\n      ps ← intro_lst $ params.map expr.local_pp_name,\n      fs ← pds.mmap (λpd, do\n        [f₁, f₂, h] ← intro_lst [pd.f₁.local_pp_name, pd.f₂.local_pp_name, `h],\n        -- the type of h' reduces to h\n        let h' := local_const h.local_uniq_name h.local_pp_name h.local_binder_info $\n          (((const `implies [] : expr)\n            (f₁.app_of_list pd.locals) (f₂.app_of_list pd.locals)).pis pd.locals).instantiate_locals $\n          (ps.zip params).map $ λ⟨lv, p⟩, (p.local_uniq_name, lv),\n        return (f₂, h')),\n      m ← pd.rec',\n      eapply $ m.app_of_list ps, -- somehow `induction` / `cases` doesn't work?\n      func_intros.mmap' (λ⟨n, pp_n, t⟩, solve1 $ do\n        bs ← intros,\n        ms ← apply_core ((const n u_params).app_of_list $ ps ++ fs.map prod.fst) {new_goals := new_goals.all},\n        params ← (ms.zip bs).enum.mfilter (λ⟨n, m, d⟩, bnot <$> is_assigned m.2),\n        params.mmap' (λ⟨n, m, d⟩, mono d (fs.map prod.snd) <|>\n          fail format! \"failed to prove montonoicity of {n+1}. parameter of intro-rule {pp_n}\")))),\n\n  pds.mmap' (λpd, do\n    let func_f := λpd:coind_pred, pd.func_g.app_of_list $ pds.map coind_pred.f₁,\n\n    /- define final predicate -/\n    pred_body ← mk_exists_lst (pds.map coind_pred.f₁) $\n      mk_and_lst $ (pds.map $ λpd, pd.le pd.f₁ (func_f pd)) ++ [pd.f₁.app_of_list pd.locals],\n    add_decl $ mk_definition pd.pd_name u_names (pd.type.pis $ params) $\n      pred_body.lambdas $ params ++ pd.locals,\n\n    /- prove `corec_functional` rule -/\n    hs ← pds.mmap $ λpd:coind_pred, mk_local_def `hc $ pd.le pd.f₁ (func_f pd),\n    pd.add_theorem (pd.pred.const_name ++ \"corec_functional\")\n      ((pd.le pd.f₁ pd.pred_g).pis $ params ++ fs₁ ++ hs)\n      (do\n      intro_lst $ params.map local_pp_name,\n      fs ← intro_lst $ fs₁.map local_pp_name,\n      hs ← intro_lst $ hs.map local_pp_name,\n      ls ← intro_lst $ pd.locals.map local_pp_name,\n      h ← intro `h,\n      whnf_target,\n      fs.mmap' existsi,\n      hs.mmap' (λf, econstructor >> exact f),\n      exact h)),\n\n  let func_f := λpd : coind_pred, pd.func_g.app_of_list $ pds.map coind_pred.pred_g,\n\n  /- prove `destruct` rules -/\n  pds.enum.mmap' (λ⟨n, pd⟩, do\n    let destruct := pd.le pd.pred_g (func_f pd),\n    pd.add_theorem (pd.pred.const_name ++ \"destruct\") (destruct.pis params) (do\n      ps ← intro_lst $ params.map local_pp_name,\n      ls ← intro_lst $ pd.locals.map local_pp_name,\n      h ← intro `h,\n      (fs, h) ← elim_gen_prod pds.length h [],\n      (hs, h) ← elim_gen_prod pds.length h [],\n      eapply $ pd.mono.app_of_list ps,\n      pds.mmap' (λpd:coind_pred, focus1 $ do\n        eapply $ pd.corec_functional,\n        focus $ hs.map exact),\n      some h' ← return $ hs.nth n,\n      eapply h',\n      exact h)),\n\n  /- prove `construct` rules -/\n  pds.mmap' (λpd,\n    pd.add_theorem (pd.pred.const_name ++ \"construct\")\n      ((pd.le (func_f pd) pd.pred_g).pis params) (do\n      ps ← intro_lst $ params.map local_pp_name,\n      let func_pred_g := λpd:coind_pred,\n        pd.func.app_of_list $ ps ++ pds.map (λpd:coind_pred, pd.pred.app_of_list ps),\n      eapply $ pd.corec_functional.app_of_list $ ps ++ pds.map func_pred_g,\n      pds.mmap' (λpd:coind_pred, solve1 $ do\n        eapply $ pd.mono.app_of_list ps,\n        pds.mmap' (λpd, solve1 $ eapply (pd.destruct.app_of_list ps) >> skip)))),\n\n  /- prove `cases_on` rules -/\n  pds.mmap' (λpd, do\n    let C := pd.f₁.to_implicit_binder,\n    h ← mk_local_def `h $ pd.pred_g.app_of_list pd.locals,\n    rules ← pd.intros.mmap (λr:coind_rule, do\n      mk_local_def (mk_simple_name r.orig_nm.last_string) $ (C.app_of_list r.insts).pis r.args),\n    cases_on ← pd.add_theorem (pd.pred.const_name ++ \"cases_on\")\n      ((C.app_of_list pd.locals).pis $ params ++ [C] ++ pd.impl_locals ++ [h] ++ rules)\n      (do\n        ps ← intro_lst $ params.map local_pp_name,\n        C  ← intro `C,\n        ls ← intro_lst $ pd.locals.map local_pp_name,\n        h  ← intro `h,\n        rules  ← intro_lst $ rules.map local_pp_name,\n        func_rec ← pd.rec',\n        eapply $ func_rec.app_of_list $ ps ++ pds.map (λpd, pd.pred.app_of_list ps) ++ [C] ++ rules,\n        eapply $ pd.destruct,\n        exact h),\n    set_basic_attribute `elab_as_eliminator cases_on.const_name),\n\n  /- prove `corec_on` rules -/\n  pds.mmap' (λpd, do\n    rules ← pds.mmap (λpd, do\n      intros ← pd.intros.mmap (λr, do\n        let (bs, eqs) := compact_relation r.loc_args $ pd.locals.zip r.insts,\n        eqs ← eqs.mmap (λ⟨l, i⟩, do\n          sort u ← infer_type l.local_type,\n          return $ (const `eq [u] : expr) l.local_type i l),\n        match bs, eqs with\n        | [], [] := return ((0, 0), mk_true)\n        | _, []  := prod.mk (bs.length, 0) <$> mk_exists_lst bs.init bs.ilast.local_type\n        | _, _   := prod.mk (bs.length, eqs.length) <$> mk_exists_lst bs (mk_and_lst eqs)\n        end),\n      let shape  := intros.map prod.fst,\n      let intros := intros.map prod.snd,\n      prod.mk shape <$>\n        mk_local_def (mk_simple_name $ \"h_\" ++ pd.pd_name.last_string)\n          (((pd.f₁.app_of_list pd.locals).imp (mk_or_lst intros)).pis pd.locals)),\n    let shape := rules.map prod.fst,\n    let rules := rules.map prod.snd,\n    h ← mk_local_def `h $ pd.f₁.app_of_list pd.locals,\n    pd.add_theorem (pd.pred.const_name ++ \"corec_on\")\n      ((pd.pred_g.app_of_list $ pd.locals).pis $ params ++ fs₁ ++ pd.impl_locals ++ [h] ++ rules)\n      (do\n        ps ← intro_lst $ params.map local_pp_name,\n        fs ← intro_lst $ fs₁.map local_pp_name,\n        ls ← intro_lst $ pd.locals.map local_pp_name,\n        h  ← intro `h,\n        rules  ← intro_lst $ rules.map local_pp_name,\n        eapply $ pd.corec_functional.app_of_list $ ps ++ fs,\n        (pds.zip $ rules.zip shape).mmap (λ⟨pd, hr, s⟩, solve1 $ do\n          ls ← intro_lst $ pd.locals.map local_pp_name,\n          h' ← intro `h,\n          h' ← note `h' none $ hr.app_of_list ls h',\n          match s.length with\n          | 0     := induction h' >> skip -- h' : false\n          | (n+1) := do\n            hs ← elim_gen_sum n h',\n            (hs.zip $ pd.intros.zip s).mmap' (λ⟨h, r, n_bs, n_eqs⟩, solve1 $ do\n              (as, h) ← elim_gen_prod (n_bs - (if n_eqs = 0 then 1 else 0)) h [],\n              if n_eqs > 0 then do\n                (eqs, eq') ← elim_gen_prod (n_eqs - 1) h [],\n                (eqs ++ [eq']).mmap' subst\n              else skip,\n              eapply ((const r.func_nm u_params).app_of_list $ ps ++ fs),\n              iterate assumption)\n          end),\n        exact h)),\n\n  /- prove constructors -/\n  pds.mmap' (λpd, pd.intros.mmap' (λr,\n    pd.add_theorem r.orig_nm (r.type.pis params) $ do\n      ps ← intro_lst $ params.map local_pp_name,\n      bs ← intros,\n      eapply $ pd.construct,\n      exact $ (const r.func_nm u_params).app_of_list $ ps ++ pds.map (λpd, pd.pred.app_of_list ps) ++ bs)),\n\n  pds.mmap' (λpd:coind_pred, set_basic_attribute `irreducible pd.pd_name),\n\n  try triv -- we setup a trivial goal for the tactic framework\n\nopen lean.parser\nopen interactive\n\n@[user_command]\nmeta def coinductive_predicate (meta_info : decl_meta_info) (_ : parse $ tk \"coinductive\") : lean.parser unit := do\n  decl ← inductive_decl.parse meta_info,\n  add_coinductive_predicate decl.u_names decl.params $ decl.decls.map $ λ d, (d.sig, d.intros),\n  decl.decls.mmap' $ λ d, do {\n    get_env >>= λ env, set_env $ env.add_namespace d.name,\n    meta_info.attrs.apply d.name,\n    d.attrs.apply d.name,\n    some doc_string ← pure meta_info.doc_string | skip,\n    add_doc_string d.name doc_string\n  }\n\n/-- Prepares coinduction proofs. This tactic constructs the coinduction invariant from\nthe quantifiers in the current goal.\n\nCurrent version: do not support mutual inductive rules (i.e. only a since C -/\nmeta def coinduction (rule : expr) : tactic unit := focus1 $\ndo\n  ctxts' ← intros,\n  ctxts ← ctxts'.mmap (λv,\n    local_const v.local_uniq_name v.local_pp_name v.local_binder_info <$> infer_type v),\n  mvars ← apply_core rule {approx := ff, new_goals := new_goals.all},\n  -- analyse relation\n  g ← list.head <$> get_goals,\n  (list.cons _ m_is) ← return $ mvars.drop_while (λv, v.2 ≠ g),\n  tgt ← target,\n  (is, ty) ← mk_local_pis tgt,\n\n  -- construct coinduction predicate\n  (bs, eqs) ← compact_relation ctxts <$>\n    ((is.zip m_is).mmap (λ⟨i, m⟩, prod.mk i <$> instantiate_mvars m.2)),\n\n  solve1 (do\n    eqs ← mk_and_lst <$> eqs.mmap (λ⟨i, m⟩, mk_app `eq [m, i] >>= instantiate_mvars),\n    rel ← mk_exists_lst bs eqs,\n    exact (rel.lambdas is)),\n\n  -- prove predicate\n  solve1 (do\n    target >>= instantiate_mvars >>= change, -- TODO: bug in existsi & constructor when mvars in hyptohesis\n    bs.mmap existsi,\n    iterate (econstructor >> skip)),\n\n  -- clean up remaining coinduction steps\n  all_goals (do\n    ctxts'.reverse.mmap clear,\n    target >>= instantiate_mvars >>= change, -- TODO: bug in subst when mvars in hyptohesis\n    is ← intro_lst $ is.map expr.local_pp_name,\n    h ← intro1,\n    (_, h) ← elim_gen_prod (bs.length - (if eqs.length = 0 then 1 else 0)) h [],\n    (match eqs with\n    | [] := clear h\n    | (e::eqs) := do\n      (hs, h) ← elim_gen_prod eqs.length h [],\n      (h::(hs.reverse)).mmap' subst\n    end))\n\nnamespace interactive\nopen interactive interactive.types expr lean.parser\nlocal postfix `?`:9001 := optional\nlocal postfix *:9001 := many\n\nmeta def coinduction (corec_name : parse ident)\n  (revert : parse $ (tk \"generalizing\" *> ident*)?) : tactic unit := do\n  rule ← mk_const corec_name,\n  locals ← mmap tactic.get_local $ revert.get_or_else [],\n  revert_lst locals,\n  tactic.coinduction rule,\n  skip\n\nend interactive\n\nend tactic\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/meta/coinductive_predicates.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.4557794304376258}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.has_limits\nimport category_theory.thin\n\n/-!\n# Wide pullbacks\n\nWe define the category `wide_pullback_shape`, (resp. `wide_pushout_shape`) which is the category\nobtained from a discrete category of type `J` by adjoining a terminal (resp. initial) element.\nLimits of this shape are wide pullbacks (pushouts).\nThe convenience method `wide_cospan` (`wide_span`) constructs a functor from this category, hitting\nthe given morphisms.\n\nWe use `wide_pullback_shape` to define ordinary pullbacks (pushouts) by using `J := walking_pair`,\nwhich allows easy proofs of some related lemmas.\nFurthermore, wide pullbacks are used to show the existence of limits in the slice category.\nNamely, if `C` has wide pullbacks then `C/B` has limits for any object `B` in `C`.\n\nTypeclasses `has_wide_pullbacks` and `has_finite_wide_pullbacks` assert the existence of wide\npullbacks and finite wide pullbacks.\n-/\n\nuniverses v u\n\nopen category_theory category_theory.limits\n\nnamespace category_theory.limits\n\nvariable (J : Type v)\n\n/-- A wide pullback shape for any type `J` can be written simply as `option J`. -/\n@[derive inhabited]\ndef wide_pullback_shape := option J\n\n/-- A wide pushout shape for any type `J` can be written simply as `option J`. -/\n@[derive inhabited]\ndef wide_pushout_shape := option J\n\nnamespace wide_pullback_shape\n\nvariable {J}\n\n/-- The type of arrows for the shape indexing a wide pullback. -/\n@[derive decidable_eq]\ninductive hom : wide_pullback_shape J → wide_pullback_shape J → Type v\n| id : Π X, hom X X\n| term : Π (j : J), hom (some j) none\n\nattribute [nolint unused_arguments] hom.decidable_eq\n\ninstance struct : category_struct (wide_pullback_shape J) :=\n{ hom := hom,\n  id := λ j, hom.id j,\n  comp := λ j₁ j₂ j₃ f g,\n  begin\n    cases f,\n      exact g,\n    cases g,\n    apply hom.term _\n  end }\n\ninstance hom.inhabited : inhabited (hom none none) := ⟨hom.id (none : wide_pullback_shape J)⟩\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance subsingleton_hom (j j' : wide_pullback_shape J) : subsingleton (j ⟶ j') :=\n⟨by tidy⟩\n\ninstance category : small_category (wide_pullback_shape J) := thin_category\n\n@[simp] lemma hom_id (X : wide_pullback_shape J) : hom.id X = 𝟙 X := rfl\n\nvariables {C : Type u} [category.{v} C]\n\n/--\nConstruct a functor out of the wide pullback shape given a J-indexed collection of arrows to a\nfixed object.\n-/\n@[simps]\ndef wide_cospan (B : C) (objs : J → C) (arrows : Π (j : J), objs j ⟶ B) :\n  wide_pullback_shape J ⥤ C :=\n{ obj := λ j, option.cases_on j B objs,\n  map := λ X Y f,\n  begin\n    cases f with _ j,\n    { apply (𝟙 _) },\n    { exact arrows j }\n  end }\n\n/-- Every diagram is naturally isomorphic (actually, equal) to a `wide_cospan` -/\ndef diagram_iso_wide_cospan (F : wide_pullback_shape J ⥤ C) :\n  F ≅ wide_cospan (F.obj none) (λ j, F.obj (some j)) (λ j, F.map (hom.term j)) :=\nnat_iso.of_components (λ j, eq_to_iso $ by tidy) $ by tidy\n\n/-- Construct a cone over a wide cospan. -/\n@[simps]\ndef mk_cone {F : wide_pullback_shape J ⥤ C} {X : C}\n  (f : X ⟶ F.obj none) (π : Π j, X ⟶ F.obj (some j))\n  (w : ∀ j, π j ≫ F.map (hom.term j) = f) : cone F :=\n{ X := X,\n  π :=\n  { app := λ j, match j with\n    | none := f\n    | (some j) := π j\n    end,\n    naturality' := λ j j' f, by { cases j; cases j'; cases f; unfold_aux; dsimp; simp [w], }, } }\n\nend wide_pullback_shape\n\nnamespace wide_pushout_shape\n\nvariable {J}\n\n/-- The type of arrows for the shape indexing a wide psuhout. -/\n@[derive decidable_eq]\ninductive hom : wide_pushout_shape J → wide_pushout_shape J → Type v\n| id : Π X, hom X X\n| init : Π (j : J), hom none (some j)\n\nattribute [nolint unused_arguments] hom.decidable_eq\n\ninstance struct : category_struct (wide_pushout_shape J) :=\n{ hom := hom,\n  id := λ j, hom.id j,\n  comp := λ j₁ j₂ j₃ f g,\n  begin\n    cases f,\n      exact g,\n    cases g,\n    apply hom.init _\n  end }\n\ninstance hom.inhabited : inhabited (hom none none) := ⟨hom.id (none : wide_pushout_shape J)⟩\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance subsingleton_hom (j j' : wide_pushout_shape J) : subsingleton (j ⟶ j') :=\n⟨by tidy⟩\n\ninstance category : small_category (wide_pushout_shape J) := thin_category\n\n@[simp] lemma hom_id (X : wide_pushout_shape J) : hom.id X = 𝟙 X := rfl\n\nvariables {C : Type u} [category.{v} C]\n\n/--\nConstruct a functor out of the wide pushout shape given a J-indexed collection of arrows from a\nfixed object.\n-/\n@[simps]\ndef wide_span (B : C) (objs : J → C) (arrows : Π (j : J), B ⟶ objs j) : wide_pushout_shape J ⥤ C :=\n{ obj := λ j, option.cases_on j B objs,\n  map := λ X Y f,\n  begin\n    cases f with _ j,\n    { apply (𝟙 _) },\n    { exact arrows j }\n  end }\n\n/-- Every diagram is naturally isomorphic (actually, equal) to a `wide_span` -/\ndef diagram_iso_wide_span (F : wide_pushout_shape J ⥤ C) :\n  F ≅ wide_span (F.obj none) (λ j, F.obj (some j)) (λ j, F.map (hom.init j)) :=\nnat_iso.of_components (λ j, eq_to_iso $ by tidy) $ by tidy\n\n/-- Construct a cocone over a wide span. -/\n@[simps]\ndef mk_cocone {F : wide_pushout_shape J ⥤ C} {X : C}\n  (f : F.obj none ⟶ X) (ι : Π j, F.obj (some j) ⟶ X)\n  (w : ∀ j, F.map (hom.init j) ≫ ι j = f) : cocone F :=\n{ X := X,\n  ι :=\n  { app := λ j, match j with\n    | none := f\n    | (some j) := ι j\n    end,\n    naturality' := λ j j' f, by { cases j; cases j'; cases f; unfold_aux; dsimp; simp [w], }, } }\n\nend wide_pushout_shape\n\nvariables (C : Type u) [category.{v} C]\n\n/-- `has_wide_pullbacks` represents a choice of wide pullback for every collection of morphisms -/\nabbreviation has_wide_pullbacks : Prop :=\nΠ (J : Type v), has_limits_of_shape (wide_pullback_shape J) C\n\n/-- `has_wide_pushouts` represents a choice of wide pushout for every collection of morphisms -/\nabbreviation has_wide_pushouts : Prop :=\nΠ (J : Type v), has_colimits_of_shape (wide_pushout_shape J) C\n\nend category_theory.limits\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/shapes/wide_pullbacks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.7154240079185318, "lm_q1q2_score": 0.455747134014612}}
{"text": "/-\nCopyright (c) 2021 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.shapes.pullbacks\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.preserves.shapes.pullbacks\n\n/-!\n# Relating monomorphisms and epimorphisms to limits and colimits\n\nIf `F` preserves (resp. reflects) pullbacks, then it preserves (resp. reflects) monomorphisms.\n\nWe also provide the dual version for epimorphisms.\n\n-/\n\nuniverses v₁ v₂ u₁ u₂\n\nnamespace category_theory\nopen category limits\n\nvariables {C : Type u₁} {D : Type u₂} [category.{v₁} C] [category.{v₂} D]\nvariables (F : C ⥤ D)\n\n/-- If `F` preserves pullbacks, then it preserves monomorphisms. -/\ninstance preserves_mono {X Y : C} (f : X ⟶ Y) [preserves_limit (cospan f f) F] [mono f] :\n  mono (F.map f) :=\nbegin\n  have := is_limit_pullback_cone_map_of_is_limit F _ (pullback_cone.is_limit_mk_id_id f),\n  simp_rw [F.map_id] at this,\n  apply pullback_cone.mono_of_is_limit_mk_id_id _ this,\nend\n\n/-- If `F` reflects pullbacks, then it reflects monomorphisms. -/\nlemma reflects_mono {X Y : C} (f : X ⟶ Y) [reflects_limit (cospan f f) F] [mono (F.map f)] :\n  mono f :=\nbegin\n  have := pullback_cone.is_limit_mk_id_id (F.map f),\n  simp_rw [←F.map_id] at this,\n  apply pullback_cone.mono_of_is_limit_mk_id_id _ (is_limit_of_is_limit_pullback_cone_map F _ this),\nend\n\n/-- If `F` preserves pushouts, then it preserves epimorphisms. -/\ninstance preserves_epi {X Y : C} (f : X ⟶ Y) [preserves_colimit (span f f) F] [epi f] :\n  epi (F.map f) :=\nbegin\n  have := is_colimit_pushout_cocone_map_of_is_colimit F _ (pushout_cocone.is_colimit_mk_id_id f),\n  simp_rw [F.map_id] at this,\n  apply pushout_cocone.epi_of_is_colimit_mk_id_id _ this,\nend\n\n/-- If `F` reflects pushouts, then it reflects epimorphisms. -/\nlemma reflects_epi {X Y : C} (f : X ⟶ Y) [reflects_colimit (span f f) F] [epi (F.map f)] :\n  epi f :=\nbegin\n  have := pushout_cocone.is_colimit_mk_id_id (F.map f),\n  simp_rw [← F.map_id] at this,\n  apply pushout_cocone.epi_of_is_colimit_mk_id_id _\n    (is_colimit_of_is_colimit_pushout_cocone_map F _ this)\nend\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/limits/constructions/epi_mono.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834732, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.4557471262842058}}
{"text": "import tactic tactic.induction data.string.basic\n\nnamespace exlean\nnamespace parser\n\n/-\nThis is a translation into Lean of the `parsing` module described in the first edition of\n\"Programming in Haskell\", by Graham Hutton, Chapter 8:\nhttp://www.cs.nott.ac.uk/~pszgmh/Parsing.lhs\n-/\n\ninductive Parser (α : Type)\n  | P : (string → option (α × string)) → Parser\n\nopen Parser\n\nvariables {α β : Type}\n\ndef parse : Parser α → string → option (α × string)\n  | (P p) inp := p inp\n\ndef item : Parser char :=\n  P (λ inp, match inp.to_list with\n              | [] := none\n              | (x::xs) := some (x, ⟨xs⟩)\n            end )\n\ninstance : monad Parser :=\n{ pure := λ α v, P (λ inp, some (v, inp)),\n  bind := λ α β p f, P (λ inp,  match (parse p inp) with\n                                  | none := none\n                                  | some (v, out) := parse (f v) out\n                                end ) }\n\n-- `return` is a synonym for `pure`.\nexample : α → Parser α := return\n\n-- `>>=` is notation for `bind`.\nexample (f : α → Parser β) (p : Parser α) : Parser β := p >>= f\n\n/-\nSome parsers:\n-/\nexample : parse (return 1) \"abc\" = some (1, \"abc\") := rfl\n\nexample : parse item \"\" = none := rfl\n\nexample : parse item \"abc\" = some ('a', \"bc\") := rfl\n\ndef failure' : Parser α := P (λ _, none)\n\ndef return_first_and_third : Parser (char × char) :=\n  do  x ← item,\n      item,\n      y ← item,\n      return (x, y)\n\nexample : parse return_first_and_third \"ribena\" = some ( ('r', 'b'), \"ena\") := rfl\n\n/-\nAlternatives and failure.\n-/\ninstance : alternative Parser :=\n{ failure := λ α, P (λ _, none),\n  orelse := λ α p q, P (λ inp,  match parse p inp with\n                                  | none := parse q inp\n                                  | some (v, out) := some (v, out)\n                                end) }\n\n-- We need to specifiy the type of `failure` in the example below. I've chosen `Parser unit`\n-- for no special reason other than the fact that `failure` should convey no information.\nexample : parse (failure : Parser unit) \"abc\" = none := rfl\n\nexample : parse (item <|> return 'd') \"abc\" = some ('a', \"bc\") := rfl\n\nexample : parse (item <|> return 'd') \"\" = some ('d', \"\") := rfl\n\nexample : parse (failure : Parser unit) \"abc\" = none := rfl\n\nexample : parse ((failure <|> failure) : Parser unit) \"abc\" = none := rfl\n\n/-\nGiven a parser `p`, the proposition `consumes p` means that for every input string `inp`, either\n`p` fails on `inp` (i.e. that `parse p inp = none`) or that the output string is shorter than\nthe input string.\n-/\ndef consumes (p : Parser α) : Prop := ∀ (inp : string), (parse p inp = none ∨ \n  ∃ v out, (parse p inp) = some (v, out) ∧ out.length < inp.length)\n\ndef consumes' : Parser α → Prop\n| (P p) := ∀ (inp : string), p inp = none ∨ ∃ v out, p inp = some (v, out) ∧ out.length < inp.length\n\nlemma item_consumes' : consumes' item :=\nbegin\n  intro inp, dsimp [item],\n  cases h : inp.to_list with x xs,\n  { left, refl, },\n  { right, existsi x, existsi xs.as_string, split,\n    { refl, },\n    { rw [←inp.as_string_inv_to_list, h], simp, }, }\nend\n\nlemma item_consumes : consumes item :=\nbegin\n  intro inp, dsimp [item, parse],\n  cases h : inp.to_list with x xs,\n  { left, refl, },\n  { right, existsi x, existsi xs.as_string, split,\n    { refl, },\n    { rw [←inp.as_string_inv_to_list, h], simp, }, }\nend\n\n/-\nDerived primatives\n-/\ndef sat (p : char → bool) : Parser char :=\n  do  x ← item,\n      if p x then return x else failure\n\ndef digit : Parser char := sat (λ c, to_bool c.is_digit)\n\ndef lower : Parser char := sat (λ c, to_bool c.is_lower)\n\ndef upper : Parser char := sat (λ c, to_bool c.is_upper)\n\ndef letter : Parser char := sat (λ c, to_bool c.is_alpha)\n\ndef alphanum : Parser char := sat (λ c, to_bool c.is_alphanum)\n\ndef is_space : Parser char := sat (λ c, to_bool c.is_whitespace)\n\ndef charp (x : char) : Parser char := sat (λ c, c = x)\n\nexample : parse digit \"123\" = some ('1', \"23\") := rfl\n\nexample : parse digit \"abc\" = none := rfl\n\nexample : parse (charp 'a') \"abc\" = some ('a', \"bc\") := rfl\n\nexample : parse (charp 'a') \"123\" = none := rfl\n\ndef list_char_parser : list char → Parser string\n  | [] := return \"\"\n  | (x::xs) := do charp x,\n                  list_char_parser xs,\n                  return ⟨x :: xs⟩\n\ndef stringp (s : string) : Parser string := list_char_parser (s.to_list)\n\nexample : parse (stringp \"abc\") \"abcdef\" = some (\"abc\", \"def\") := rfl\n\nexample : parse (stringp \"abc\") \"ab1234\" = none := rfl\n\n/-\nRepetition\n-/\n\ndef once (p : Parser α) : Parser (list α) :=\n  P (λ inp, match parse p inp with\n              | none := none\n              | some (v, out) := some ([v], out)\n            end )\n\ndef one_or_zero (p : Parser α) : Parser (list α) :=\n  P (λ inp, match parse p inp with\n              | none := some ([], inp)\n              | some (v, out) := some ([v], out)\n            end )\n\nexample : parse (one_or_zero digit) \"a123\" = some ([], \"a123\") := rfl\n\nexample : parse (one_or_zero digit) \"123\" = some (['1'], \"23\") := rfl\n\n/-\n`n_or_less p n` succeeds if `n` or fewer applications of `p` succeed. Else it fails.\n-/\ndef n_or_less (p : Parser α) : ℕ → Parser (list α)\n  | 0 := return []\n  | (n+1) := do x <- p,\n                xs ← n_or_less n,\n                return (x :: xs)   \n\nexample : parse (n_or_less lower 600000) \"gihanIIHAN\" = none := rfl                 \n\nexample : parse (n_or_less lower 4) \"gihanIIHAN\" = some (['g', 'i', 'h', 'a'], \"nIIHAN\") := rfl     \n\n/-\n`many p` does `p` repeatedly until failure. It always succeeds.\nIt's a `meta def` as it uses unbounded recursion.\nThe Lean parser module gets around this by using a natural number to store the position in the string.\n\nNote: Graham Hutton used mutual recursion to define `many` and `many1`. I didn't choose this\napproach as Lean 3 has limited support for mutual recursion.\n-/\nmeta def many (p : Parser α) : Parser (list α) :=\n  (do x ← p, xs ← many, return (x :: xs)) <|> return []\n\n#eval parse (many digit) \"754asdf\"\n\n#eval parse (many digit) \"abc\" -- succeeds and returns the empty list.\n\n/-\n`many1 p` is like `many` except that it will fail if `p` doesn't succeed at least once.\n-/\nmeta def many1 (p : Parser α) : Parser (list α) :=\n  (do x ← p, xs ← many p, return (x :: xs)) <|> failure\n\n/-\n`many_many b` acts as `many` if `b = tt` and as `many1` if `b = ff`.\n-/\n\n/- inductive less_than_or_equal (a : ℕ) : ℕ → Prop\n| refl : less_than_or_equal a\n| step : Π {b}, less_than_or_equal b → less_than_or_equal (succ b) -/\n\n/- inductive opt_rel : option (α × string) → option (α × string) → Prop\n| none_lt_some  -/\n\ndef opt_rel : option (α × string) → option (α × string) → Prop\n  | none (some (_,_)) := true\n  | (some (v1, inp1)) (some (v2, inp2)) := inp1.length < inp2.length\n  | _ _ := false\n\nlemma not_none_lt_none : @opt_rel α none none = false := rfl\n\nlemma not_some_lt_none (v : α) (inp : string) : @opt_rel α (some (v, inp)) none = false := rfl\n\nlemma some_lt_some {v1 v2 : α} {inp1 inp2 : string} (h : opt_rel (some (v1,inp1)) (some (v2,inp2))) : \n  inp1.length < inp2.length := h\n\nlemma not_lt_none (r : option (α × string)) : ¬ (opt_rel r none) :=\nbegin\n  intro h,\n  rcases r with _ | ⟨v, inp⟩,\n  { cases h, },\n  { rw not_some_lt_none v inp at h, exact h, },\nend\n      \nlemma nat.lt_wf' : well_founded nat.lt := well_founded.intro $\nbegin\n  intro a,\n  induction a with n ih,\n  { refine acc.intro 0 _,\n    intros n h,\n    exfalso,\n    apply nat.not_lt_zero n, exact h, },\n    /-\n    case nat.succ\n    α : Type,\n    n : ℕ,\n    ih : ∀ (inp : string) (v : α), inp.length = n → acc opt_rel (some (v, inp)),\n    inp : string,\n    v : α,\n    hl : inp.length = n.succ\n    ⊢ acc opt_rel (some (v, inp))\n    -/\n  { refine acc.intro (n+1) _,\n    intros m h,\n    cases (nat.eq_or_lt_of_le (nat.le_of_succ_le_succ h)) with e h₂,\n    { rw e, exact ih, },\n    { exact acc.inv ih h₂, }, }\nend\n\nlemma acc_opt_rel_none : acc (@opt_rel α) none :=\nbegin\n  refine acc.intro none _,\n  intros n h,\n  exfalso,\n  exact not_lt_none n h \nend\n\nlemma string_succ {s : string} {n : ℕ} (h : s.length = n.succ) : ∃ x xs, s = (x :: xs).as_string :=\nbegin\n  let sl := s.to_list,\n  have h₁ : sl.length = n.succ,\n  { rw s.length_to_list, exact h, },\n  rcases (s.to_list).exists_of_length_succ h₁ with ⟨x, xs, h₂⟩,\n  use [x, xs],  \n  rw [←h₂, s.as_string_inv_to_list],\nend\n\nlemma acc_opt_rel_some (n : ℕ) : ∀ (inp : string) (v : α),\n  inp.length < n → acc opt_rel (some (v, inp)) :=\nbegin\n  induction n with n ih,\n  { intros inp v hl, \n    refine acc.intro (some (v, inp)) _,\n    intros x h,\n    rcases x with _ | ⟨v', inp'⟩,\n    { exact acc_opt_rel_none, },\n    { have h₂ := some_lt_some h, exfalso, refine nat.not_lt_zero _ hl, }, },    \n  { intros inp v hl, \n    refine acc.intro (some (v, inp)) _,\n    intros m h,\n    rcases m with _ | ⟨v', inp'⟩,\n    { exact acc_opt_rel_none, },\n    { cases (nat.eq_or_lt_of_le (nat.le_of_succ_le_succ hl)) with e h₂,\n      sorry,\n      sorry,\n     },\n   },\nend\n\n/- lemma acc_opt_rel_some (n : ℕ) : ∀ (inp : string) (v : α),\n  inp.length = n → acc opt_rel (some (v, inp)) :=\nbegin\n  induction n with n ih,\n  { intros inp v hl, \n    refine acc.intro (some (v, inp)) _,\n    intros x h,\n    rcases x with _ | ⟨v', inp'⟩,\n    { exact acc_opt_rel_none, },\n    { have h₂ := some_lt_some h, rw hl at h₂, exfalso, refine nat.not_lt_zero _ h₂, }, },    \n  { intros inp v hl, \n    refine acc.intro (some (v, inp)) _,\n    intros m h,\n    rcases m with _ | ⟨v', inp'⟩,\n    { exact acc_opt_rel_none, },\n    { rcases string_succ hl with ⟨x, xs, h₂⟩,\n      have h₃ : (x :: xs).as_string.length = n.succ, { rw [←h₂, hl], },\n      have h₄ : xs.as_string.length = n,\n      { simp only [nat.succ_eq_add_one, list.length_as_string, add_left_inj, list.length] at h₃ ⊢,\n        exact h₃, },\n      have h₅ : inp'.length < inp.length := some_lt_some h,\n      rw h₂ at h₅, simp only [list.length_as_string, list.length] at h₅,\n      cases (nat.eq_or_lt_of_le (nat.le_of_succ_le_succ h₅)) with e h₆,\n      { apply ih, rw [e, ←h₄], simp,  },\n      sorry,\n     },\n   },\nend -/\n\n\nexample : well_founded (@opt_rel α) := well_founded.intro $\nbegin\n  rintro (_ | ⟨v, inp⟩),\n  { exact acc_opt_rel_none, },\n  { \n    sorry,\n   },\nend\n\n\nexample : well_founded (@opt_rel α) := well_founded.intro $\nbegin\n  rintro (_ | ⟨v, inp⟩),\n  { exact acc_opt_rel_none, },\n  { rw ←inp.as_string_inv_to_list,\n    induction' p : inp.to_list with x xs ih,\n    { refine acc.intro (some (v, [].as_string)) _,\n      intros x h, -- maybe use rintro?\n      rcases x with _ | ⟨v', inp'⟩,\n      { exact acc_opt_rel_none, },\n      { cases h, }, },\n    { refine acc.intro (some (v, (x :: xs).as_string)) _,\n      intros m h,\n      rcases m with _ | ⟨v', inp'⟩,\n      { exact acc_opt_rel_none, },\n      { /- have h₂ : inp'.length < (x :: xs).as_string.length := some_lt_some h,\n        simp only [list.length_as_string, list.length] at h₂, -/\n        cases (nat.eq_or_lt_of_le (nat.le_of_succ_le_succ h)) with e h₂,\n        { specialize ih v' inp', sorry, },\n        { sorry, }\n       }\n\n      }\n  \n   },\nend\n\nexample : @well_founded (ℕ) (nat.lt) :=\nwell_founded.intro (λ x, acc.intro x (λ y h, (acc.intro y (λ z p, sorry))))\n\nexample : @well_founded (option (α × string)) (@opt_rel α) :=\nwell_founded.intro (λ x, acc.intro x (λ y h, sorry))\n\nmeta def many_many1 : bool → Π (p : Parser α) (h : consumes' p), Parser (list α)\n| tt (P p) := λ h, P (λ inp, parse (many_many1 ff (P p) h <|> return []) inp)\n| ff (P p) := λ h, P (λ inp, parse  (do v ← (P p),\n                                        vs ← many_many1 tt (P p) h,\n                                        return (v :: vs)) inp)\n                                        \n#eval parse (many1 digit) \"754asdf\"\n\n#eval parse (many1 digit) \"abc\" -- fails\n\nmeta def identc : Parser (list char) :=\n  do  x ← lower,\n      xs ← many alphanum,\n      return (x :: xs)\n\nmeta def ident : Parser string := do xs ← identc, return ⟨xs⟩\n\n#eval parse ident \"abc343[]!!\" -- returns \"abc343\"\n\n#eval parse ident \"121abc343[]!!\" -- fails\n\n/-\n`char_to_nat c` converts the character `c` to a corresponding `ℕ`.\nAs Lean functions are total, we choose to convert `c` to `0` if `c` is not a digit.\n-/\ndef char_to_nat : char → ℕ\n  | '0' := 0\n  | '1' := 1\n  | '2' := 2\n  | '3' := 3\n  | '4' := 4\n  | '5' := 5\n  | '6' := 6\n  | '7' := 7\n  | '8' := 8\n  | '9' := 9\n  | _ := 0\n\n-- Converts a list of digits (in 'big-endian' order) into a natural number.\ndef list_nat_to_nat : list ℕ → ℕ\n  | [] := 0\n  | (x :: xs) := x + 10 * list_nat_to_nat xs\n\nexample : list_nat_to_nat [1,9,4] = 491 := rfl\n\ndef list_char_to_nat (xs : list char) : ℕ :=\n  list_nat_to_nat (list.map char_to_nat (list.reverse xs))\n\nexample : list_char_to_nat ['1','2','3'] = 123 := rfl\n\n-- Recall non-digit chars are converted to `0`:\nexample : list_char_to_nat ['1','p', '3'] = 103 := rfl\n\nmeta def natp : Parser ℕ :=\n  do  xs ← many1 digit,\n      return (list_char_to_nat xs)\n\n#eval parse natp \"4563bob\" -- gets `4563` as a natural number\n\nmeta def intp : Parser ℤ :=\n  (do  charp '-',\n      n ← natp,\n      return (-n))\n  <|> do n ← natp, return n\n\n#eval parse intp \"132bob\"\n\n#eval parse intp \"-123bob\"\n\nmeta def space : Parser unit := do many is_space, return ()\n\n#eval parse space \" ▸  ¬ fish\" -- consumes the whitespace, returning `star`.\n\nmeta def token (p : Parser α) : Parser α :=\n  do  space,\n      v ← p,\n      space,\n      return v\n\n#eval parse (token natp) \"    123\" -- returns the natural number `123`\n\nmeta def identifier : Parser string := token ident\n\n#eval parse identifier \"   gill   sdfd\"\n\nmeta def natural : Parser ℕ := token natp\n\n#eval parse natural \"   1232\"\n\nmeta def symbol (xs : string) : Parser string := token (stringp xs)\n\n#eval parse (symbol \"hema\") \"   hema\"\n\nmeta def test_parser1 : Parser (list ℕ) := \n  do  symbol \"[\",\n      n ← natural,\n      ns ← many (do symbol \",\", natural),\n      symbol \"]\",\n      return (n :: ns)\n\n#eval parse test_parser1 \"  [1,2,  3 ] rubbish\" -- returns `[1, 2, 3] : list ℕ`.\n\nend parser\nend exlean", "meta": {"author": "gihanmarasingha", "repo": "exleanblog", "sha": "aa6dc06cb64376dc87ba680815b9d14a904ad2ff", "save_path": "github-repos/lean/gihanmarasingha-exleanblog", "path": "github-repos/lean/gihanmarasingha-exleanblog/exleanblog-aa6dc06cb64376dc87ba680815b9d14a904ad2ff/src/2021/06/parsing2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307944803831, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.4557471202894793}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\n\nimport algebra.char_p.basic\nimport algebra.geom_sum\nimport data.mv_polynomial.comm_ring\nimport data.mv_polynomial.equiv\nimport ring_theory.polynomial.content\nimport ring_theory.unique_factorization_domain\n\n/-!\n# Ring-theoretic supplement of data.polynomial.\n\n## Main results\n* `mv_polynomial.is_domain`:\n  If a ring is an integral domain, then so is its polynomial ring over finitely many variables.\n* `polynomial.is_noetherian_ring`:\n  Hilbert basis theorem, that if a ring is noetherian then so is its polynomial ring.\n* `polynomial.wf_dvd_monoid`:\n  If an integral domain is a `wf_dvd_monoid`, then so is its polynomial ring.\n* `polynomial.unique_factorization_monoid`, `mv_polynomial.unique_factorization_monoid`:\n  If an integral domain is a `unique_factorization_monoid`, then so is its polynomial ring (of any\n  number of variables).\n-/\n\nnoncomputable theory\nopen_locale classical big_operators polynomial\nopen finset\n\nuniverses u v w\nvariables {R : Type u} {S : Type*}\n\nnamespace polynomial\n\nsection semiring\nvariables [semiring R]\n\ninstance (p : ℕ) [h : char_p R p] : char_p R[X] p :=\nlet ⟨h⟩ := h in ⟨λ n, by rw [← map_nat_cast C, ← C_0, C_inj, h]⟩\n\nvariables (R)\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R R[X] :=\n⨅ k : ℕ, ⨅ h : ↑k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : ℕ) : submodule R R[X] :=\n⨅ k : ℕ, ⨅ h : k ≥ n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot ℕ} {f : R[X]} :\n  f ∈ degree_le R n ↔ degree f ≤ n :=\nby simp only [degree_le, submodule.mem_infi, degree_le_iff_coeff_zero, linear_map.mem_ker]; refl\n\n@[mono] theorem degree_le_mono {m n : with_bot ℕ} (H : m ≤ n) :\n  degree_le R m ≤ degree_le R n :=\nλ f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : ℕ} :\n  degree_le R n = submodule.span R ↑((finset.range (n+1)).image (λ n, (X : R[X])^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [← polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_le_coe.1 (finset.sup_le_iff.1 hp k hk),\n    rw [← C_mul_X_pow_eq_monomial, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_le.2,\n  exact (degree_X_pow_le _).trans\n    (with_bot.coe_le_coe.2 $ nat.le_of_lt_succ $ finset.mem_range.1 hk)\nend\n\ntheorem mem_degree_lt {n : ℕ} {f : R[X]} :\n  f ∈ degree_lt R n ↔ degree f < n :=\nby { simp_rw [degree_lt, submodule.mem_infi, linear_map.mem_ker, degree, finset.max_eq_sup_coe,\n    finset.sup_lt_iff (with_bot.bot_lt_coe n), mem_support_iff,\n    with_bot.coe_lt_coe, lt_iff_not_le, ne, not_imp_not], refl }\n\n@[mono] theorem degree_lt_mono {m n : ℕ} (H : m ≤ n) :\n  degree_lt R m ≤ degree_lt R n :=\nλ f hf, mem_degree_lt.2 (lt_of_lt_of_le (mem_degree_lt.1 hf) $ with_bot.coe_le_coe.2 H)\n\ntheorem degree_lt_eq_span_X_pow {n : ℕ} :\n  degree_lt R n = submodule.span R ↑((finset.range n).image (λ n, X^n) : finset R[X]) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [← polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (λ k hk, _),\n    show monomial _ _ ∈ _,\n    have := with_bot.coe_lt_coe.1 ((finset.sup_lt_iff $ with_bot.bot_lt_coe n).1 hp k hk),\n    rw [← C_mul_X_pow_eq_monomial, C_mul'],\n    refine submodule.smul_mem _ _ (submodule.subset_span $ finset.mem_coe.2 $\n      finset.mem_image.2 ⟨_, finset.mem_range.2 this, rfl⟩) },\n  rw [submodule.span_le, finset.coe_image, set.image_subset_iff],\n  intros k hk, apply mem_degree_lt.2,\n  exact lt_of_le_of_lt (degree_X_pow_le _) (with_bot.coe_lt_coe.2 $ finset.mem_range.1 hk)\nend\n\n/-- The first `n` coefficients on `degree_lt n` form a linear equivalence with `fin n → R`. -/\ndef degree_lt_equiv (R) [semiring R] (n : ℕ) : degree_lt R n ≃ₗ[R] (fin n → R) :=\n{ to_fun := λ p n, (↑p : R[X]).coeff n,\n  inv_fun := λ f, ⟨∑ i : fin n, monomial i (f i),\n    (degree_lt R n).sum_mem (λ i _, mem_degree_lt.mpr (lt_of_le_of_lt\n      (degree_monomial_le i (f i)) (with_bot.coe_lt_coe.mpr i.is_lt)))⟩,\n  map_add' := λ p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := λ x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro ⟨p, hp⟩, ext1,\n    simp only [submodule.coe_mk],\n    by_cases hp0 : p = 0,\n    { subst hp0, simp only [coeff_zero, linear_map.map_zero, finset.sum_const_zero] },\n    rw [mem_degree_lt, degree_eq_nat_degree hp0, with_bot.coe_lt_coe] at hp,\n    conv_rhs { rw [p.as_sum_range' n hp, ← fin.sum_univ_eq_sum_range] },\n  end,\n  right_inv :=\n  begin\n    intro f, ext i,\n    simp only [finset_sum_coeff, submodule.coe_mk],\n    rw [finset.sum_eq_single i, coeff_monomial, if_pos rfl],\n    { rintro j - hji, rw [coeff_monomial, if_neg], rwa [← fin.ext_iff] },\n    { intro h, exact (h (finset.mem_univ _)).elim }\n  end }\n\n@[simp] theorem degree_lt_equiv_eq_zero_iff_eq_zero {n : ℕ} {p : R[X]} (hp : p ∈ degree_lt R n) :\n  degree_lt_equiv _ _ ⟨p, hp⟩ = 0 ↔ p = 0 :=\nby rw [linear_equiv.map_eq_zero_iff, submodule.mk_eq_zero]\n\ntheorem eval_eq_sum_degree_lt_equiv {n : ℕ} {p : R[X]} (hp : p ∈ degree_lt R n) (x : R) :\n  p.eval x = ∑ i, degree_lt_equiv _ _ ⟨p, hp⟩ i * (x ^ (i : ℕ)) :=\nbegin\n  simp_rw [eval_eq_sum],\n  exact (sum_fin _ (by simp_rw [zero_mul, forall_const]) (mem_degree_lt.mp hp)).symm\nend\n\n/-- The finset of nonzero coefficients of a polynomial. -/\ndef frange (p : R[X]) : finset R :=\nfinset.image (λ n, p.coeff n) p.support\n\nlemma frange_zero : frange (0 : R[X]) = ∅ :=\nrfl\n\nlemma mem_frange_iff {p : R[X]} {c : R} :\n  c ∈ p.frange ↔ ∃ n ∈ p.support, c = p.coeff n :=\nby simp [frange, eq_comm]\n\nlemma frange_one : frange (1 : R[X]) ⊆ {1} :=\nbegin\n  simp [frange, finset.image_subset_iff],\n  simp only [← C_1, coeff_C],\n  assume n hn,\n  simp only [exists_prop, ite_eq_right_iff, not_forall] at hn,\n  simp [hn],\nend\n\nlemma coeff_mem_frange (p : R[X]) (n : ℕ) (h : p.coeff n ≠ 0) :\n  p.coeff n ∈ p.frange :=\nbegin\n  simp only [frange, exists_prop, mem_support_iff, finset.mem_image, ne.def],\n  exact ⟨n, h, rfl⟩,\nend\n\nlemma geom_sum_X_comp_X_add_one_eq_sum (n : ℕ) :\n  (∑ i in range n, (X : R[X]) ^ i).comp (X + 1) =\n  (finset.range n).sum (λ (i : ℕ), (n.choose (i + 1) : R[X]) * X ^ i) :=\nbegin\n  ext i,\n  transitivity (n.choose (i + 1) : R), swap,\n  { simp only [finset_sum_coeff, ← C_eq_nat_cast, coeff_C_mul_X_pow],\n    rw [finset.sum_eq_single i, if_pos rfl],\n    { simp only [@eq_comm _ i, if_false, eq_self_iff_true, implies_true_iff] {contextual := tt}, },\n    { simp only [nat.lt_add_one_iff, nat.choose_eq_zero_of_lt, nat.cast_zero, finset.mem_range,\n        not_lt, eq_self_iff_true, if_true, implies_true_iff] {contextual := tt}, } },\n  induction n with n ih generalizing i,\n  { simp only [geom_sum_zero, zero_comp, coeff_zero, nat.choose_zero_succ, nat.cast_zero], },\n  simp only [geom_sum_succ', ih, add_comp, X_pow_comp, coeff_add, nat.choose_succ_succ,\n    nat.cast_add, coeff_X_add_one_pow],\nend\n\nlemma monic.geom_sum {P : R[X]}\n  (hP : P.monic) (hdeg : 0 < P.nat_degree) {n : ℕ} (hn : n ≠ 0) : (∑ i in range n, P ^ i).monic :=\nbegin\n  nontriviality R,\n  cases n, { exact (hn rfl).elim },\n  rw [geom_sum_succ'],\n  refine (hP.pow _).add_of_left _,\n  refine lt_of_le_of_lt (degree_sum_le _ _) _,\n  rw [finset.sup_lt_iff],\n  { simp only [finset.mem_range, degree_eq_nat_degree (hP.pow _).ne_zero,\n      with_bot.coe_lt_coe, hP.nat_degree_pow],\n    intro k, exact nsmul_lt_nsmul hdeg },\n  { rw [bot_lt_iff_ne_bot, ne.def, degree_eq_bot],\n    exact (hP.pow _).ne_zero }\nend\n\n\n\nlemma monic_geom_sum_X {n : ℕ} (hn : n ≠ 0) :\n  (∑ i in range n, (X : R[X]) ^ i).monic :=\nbegin\n  nontriviality R,\n  apply monic_X.geom_sum _ hn,\n  simpa only [nat_degree_X] using zero_lt_one\nend\n\nend semiring\n\nsection ring\nvariables [ring R]\n\n/-- Given a polynomial, return the polynomial whose coefficients are in\nthe ring closure of the original coefficients. -/\ndef restriction (p : R[X]) : polynomial (subring.closure (↑p.frange : set R)) :=\n∑ i in p.support, monomial i (⟨p.coeff i,\n  if H : p.coeff i = 0 then H.symm ▸ (subring.closure _).zero_mem\n  else subring.subset_closure (p.coeff_mem_frange _ H)⟩ : (subring.closure (↑p.frange : set R)))\n\n@[simp] theorem coeff_restriction {p : R[X]} {n : ℕ} :\n  ↑(coeff (restriction p) n) = coeff p n :=\nbegin\n  simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ne.def, ite_not],\n  split_ifs,\n  { rw h, refl },\n  { refl }\nend\n\n@[simp] theorem coeff_restriction' {p : R[X]} {n : ℕ} :\n  (coeff (restriction p) n).1 = coeff p n :=\ncoeff_restriction\n\n@[simp] lemma support_restriction (p : R[X]) :\n  support (restriction p) = support p :=\nbegin\n  ext i,\n  simp only [mem_support_iff, not_iff_not, ne.def],\n  conv_rhs { rw [← coeff_restriction] },\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem map_restriction {R : Type u} [comm_ring R]\n  (p : R[X]) : p.restriction.map (algebra_map _ _) = p :=\next $ λ n, by rw [coeff_map, algebra.algebra_map_of_subring_apply, coeff_restriction]\n\n@[simp] theorem degree_restriction {p : R[X]} : (restriction p).degree = p.degree :=\nby simp [degree]\n\n@[simp] theorem nat_degree_restriction {p : R[X]} :\n  (restriction p).nat_degree = p.nat_degree :=\nby simp [nat_degree]\n\n@[simp] theorem monic_restriction {p : R[X]} : monic (restriction p) ↔ monic p :=\nbegin\n  simp only [monic, leading_coeff, nat_degree_restriction],\n  rw [←@coeff_restriction _ _ p],\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem restriction_zero : restriction (0 : R[X]) = 0 :=\nby simp only [restriction, finset.sum_empty, support_zero]\n\n@[simp] theorem restriction_one : restriction (1 : R[X]) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables [semiring S] {f : R →+* S} {x : S}\n\ntheorem eval₂_restriction {p : R[X]} :\n  eval₂ f x p =\n  eval₂ (f.comp (subring.subtype (subring.closure (p.frange : set R)))) x p.restriction :=\nbegin\n  simp only [eval₂_eq_sum, sum, support_restriction, ←@coeff_restriction _ _ p],\n  refl,\nend\n\nsection to_subring\n\nvariables (p : R[X]) (T : subring R)\n\n/-- Given a polynomial `p` and a subring `T` that contains the coefficients of `p`,\nreturn the corresponding polynomial whose coefficients are in `T`. -/\ndef to_subring (hp : (↑p.frange : set R) ⊆ T) : T[X] :=\n∑ i in p.support, monomial i (⟨p.coeff i,\n  if H : p.coeff i = 0 then H.symm ▸ T.zero_mem\n  else hp (p.coeff_mem_frange _ H)⟩ : T)\n\nvariables (hp : (↑p.frange : set R) ⊆ T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : ℕ} : ↑(coeff (to_subring p T hp) n) = coeff p n :=\nbegin\n  simp only [to_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ne.def, ite_not],\n  split_ifs,\n  { rw h, refl },\n  { refl }\nend\n\n@[simp] theorem coeff_to_subring' {n : ℕ} : (coeff (to_subring p T hp) n).1 = coeff p n :=\ncoeff_to_subring _ _ hp\n\n@[simp] lemma support_to_subring :\n  support (to_subring p T hp) = support p :=\nbegin\n  ext i,\n  simp only [mem_support_iff, not_iff_not, ne.def],\n  conv_rhs { rw [← coeff_to_subring p T hp] },\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\n@[simp] theorem degree_to_subring : (to_subring p T hp).degree = p.degree :=\nby simp [degree]\n\n@[simp] theorem nat_degree_to_subring : (to_subring p T hp).nat_degree = p.nat_degree :=\nby simp [nat_degree]\n\n@[simp] theorem monic_to_subring : monic (to_subring p T hp) ↔ monic p :=\nbegin\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, ← coeff_to_subring p T hp],\n  exact ⟨λ H, by { rw H, refl }, λ H, subtype.coe_injective H⟩\nend\n\nomit hp\n\n@[simp] theorem to_subring_zero : to_subring (0 : R[X]) T (by simp [frange_zero]) = 0 :=\nby { ext i, simp }\n\n@[simp] theorem to_subring_one : to_subring (1 : R[X]) T\n  (set.subset.trans frange_one $finset.singleton_subset_set_iff.2 T.one_mem) = 1 :=\next $ λ i, subtype.eq $ by rw [coeff_to_subring', coeff_one, coeff_one]; split_ifs; refl\n\n@[simp] theorem map_to_subring : (p.to_subring T hp).map (subring.subtype T) = p :=\nby { ext n, simp [coeff_map] }\n\nend to_subring\n\nvariables (T : subring R)\n\n/-- Given a polynomial whose coefficients are in some subring, return\nthe corresponding polynomial whose coefficients are in the ambient ring. -/\ndef of_subring (p : T[X]) : R[X] :=\n∑ i in p.support, monomial i (p.coeff i : R)\n\nlemma coeff_of_subring (p : T[X]) (n : ℕ) :\n  coeff (of_subring T p) n = (coeff p n : T) :=\nbegin\n  simp only [of_subring, coeff_monomial, finset_sum_coeff, mem_support_iff, finset.sum_ite_eq',\n    ite_eq_right_iff, ne.def, ite_not, not_not, ite_eq_left_iff],\n  assume h,\n  rw h,\n  refl\nend\n\n@[simp] theorem frange_of_subring {p : T[X]} :\n  (↑(p.of_subring T).frange : set R) ⊆ T :=\nbegin\n  assume i hi,\n  simp only [frange, set.mem_image, mem_support_iff, ne.def, finset.mem_coe, finset.coe_image]\n    at hi,\n  rcases hi with ⟨n, hn, h'n⟩,\n  rw [← h'n, coeff_of_subring],\n  exact subtype.mem (coeff p n : T)\nend\n\nend ring\n\nsection comm_ring\nvariables [comm_ring R]\n\nsection mod_by_monic\n\nvariables {q : R[X]}\n\nlemma mem_ker_mod_by_monic (hq : q.monic) {p : R[X]} :\n  p ∈ (mod_by_monic_hom q).ker ↔ q ∣ p :=\nlinear_map.mem_ker.trans (dvd_iff_mod_by_monic_eq_zero hq)\n\n@[simp] lemma ker_mod_by_monic_hom (hq : q.monic) :\n  (polynomial.mod_by_monic_hom q).ker = (ideal.span {q}).restrict_scalars R :=\nsubmodule.ext (λ f, (mem_ker_mod_by_monic hq).trans ideal.mem_span_singleton.symm)\n\nend mod_by_monic\n\nend comm_ring\n\nend polynomial\n\nnamespace ideal\nopen polynomial\n\nsection semiring\nvariables [semiring R]\n\n/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/\ndef of_polynomial (I : ideal R[X]) : submodule R R[X] :=\n{ carrier := I.carrier,\n  zero_mem' := I.zero_mem,\n  add_mem' := λ _ _, I.add_mem,\n  smul_mem' := λ c x H, by { rw [← C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal R[X]}\ntheorem mem_of_polynomial (x) : x ∈ I.of_polynomial ↔ x ∈ I := iff.rfl\nvariables (I)\n\n/-- Given an ideal `I` of `R[X]`, make the `R`-submodule of `I`\nconsisting of polynomials of degree ≤ `n`. -/\ndef degree_le (n : with_bot ℕ) : submodule R R[X] :=\ndegree_le R n ⊓ I.of_polynomial\n\n/-- Given an ideal `I` of `R[X]`, make the ideal in `R` of\nleading coefficients of polynomials in `I` with degree ≤ `n`. -/\ndef leading_coeff_nth (n : ℕ) : ideal R :=\n(I.degree_le n).map $ lcoeff R n\n\n/-- Given an ideal `I` in `R[X]`, make the ideal in `R` of the\nleading coefficients in `I`. -/\ndef leading_coeff : ideal R :=\n⨆ n : ℕ, I.leading_coeff_nth n\n\nend semiring\n\nsection comm_semiring\nvariables [comm_semiring R] [semiring S]\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself -/\nlemma polynomial_mem_ideal_of_coeff_mem_ideal (I : ideal R[X]) (p : R[X])\n  (hp : ∀ (n : ℕ), (p.coeff n) ∈ I.comap (C : R →+* R[X])) : p ∈ I :=\nsum_C_mul_X_pow_eq p ▸ submodule.sum_mem I (λ n hn, I.mul_mem_right _ (hp n))\n\n/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : R[X]} :\n  f ∈ (ideal.map (C : R →+* R[X]) I : ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw ← sum_monomial_eq f,\n    refine (I.map C : ideal R[X]).sum_mem (λ n hn, _),\n    simp [← C_mul_X_pow_eq_monomial],\n    rw mul_comm,\n    exact (I.map C : ideal R[X]).mul_mem_left _ (mem_map_of_mem _ (hf n)) }\nend\n\nlemma _root_.polynomial.ker_map_ring_hom (f : R →+* S) :\n  (polynomial.map_ring_hom f).ker = f.ker.map (C : R →+* R[X]) :=\nbegin\n  ext,\n  rw [mem_map_C_iff, ring_hom.mem_ker, polynomial.ext_iff],\n  simp_rw [coe_map_ring_hom, coeff_map, coeff_zero, ring_hom.mem_ker],\nend\n\nvariable (I : ideal R[X])\n\ntheorem mem_leading_coeff_nth (n : ℕ) (x) :\n  x ∈ I.leading_coeff_nth n ↔ ∃ p ∈ I, degree p ≤ n ∧ p.leading_coeff = x :=\nbegin\n  simp only [leading_coeff_nth, degree_le, submodule.mem_map, lcoeff_apply, submodule.mem_inf,\n    mem_degree_le],\n  split,\n  { rintro ⟨p, ⟨hpdeg, hpI⟩, rfl⟩,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine ⟨0, I.zero_mem, bot_le, _⟩,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine ⟨p, hpI, le_of_eq hpdeg, _⟩,\n      rw [polynomial.leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro ⟨p, hpI, hpdeg, rfl⟩,\n    have : nat_degree p + (n - nat_degree p) = n,\n    { exact add_tsub_cancel_of_le (nat_degree_le_of_degree_le hpdeg) },\n    refine ⟨p * X ^ (n - nat_degree p), ⟨_, I.mul_mem_right _ hpI⟩, _⟩,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [← with_bot.coe_add, this],\n      exact le_rfl },\n    { rw [polynomial.leading_coeff, ← coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x ∈ I.leading_coeff_nth 0 ↔ C x ∈ I :=\n(mem_leading_coeff_nth _ _ _).trans\n⟨λ ⟨p, hpI, hpdeg, hpx⟩, by rwa [← hpx, polynomial.leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  ← eq_C_of_degree_le_zero hpdeg],\nλ hx, ⟨C x, hx, degree_C_le, leading_coeff_C x⟩⟩\n\ntheorem leading_coeff_nth_mono {m n : ℕ} (H : m ≤ n) :\n  I.leading_coeff_nth m ≤ I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr ⊢,\n  rcases hr with ⟨p, hpI, hpdeg, rfl⟩,\n  refine ⟨p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow⟩,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [← with_bot.coe_add, add_tsub_cancel_of_le H],\n  exact le_rfl\nend\n\ntheorem mem_leading_coeff (x) :\n  x ∈ I.leading_coeff ↔ ∃ p ∈ I, polynomial.leading_coeff p = x :=\nbegin\n  rw [leading_coeff, submodule.mem_supr_of_directed],\n  simp only [mem_leading_coeff_nth],\n  { split, { rintro ⟨i, p, hpI, hpdeg, rfl⟩, exact ⟨p, hpI, rfl⟩ },\n    rintro ⟨p, hpI, rfl⟩, exact ⟨nat_degree p, p, hpI, degree_le_nat_degree, rfl⟩ },\n  intros i j, exact ⟨i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)⟩\nend\n\n/--\nIf `I` is an ideal, and `pᵢ` is a finite family of polynomials each satisfying\n`∀ k, (pᵢ)ₖ ∈ Iⁿⁱ⁻ᵏ` for some `nᵢ`, then `p = ∏ pᵢ` also satisfies `∀ k, pₖ ∈ Iⁿ⁻ᵏ` with `n = ∑ nᵢ`.\n-/\nlemma _root_.polynomial.coeff_prod_mem_ideal_pow_tsub {ι : Type*} (s : finset ι) (f : ι → R[X])\n  (I : ideal R) (n : ι → ℕ) (h : ∀ (i ∈ s) k, (f i).coeff k ∈ I ^ (n i - k)) (k : ℕ) :\n  (s.prod f).coeff k ∈ I ^ (s.sum n - k) :=\nbegin\n  classical,\n  induction s using finset.induction with a s ha hs generalizing k,\n  { rw [sum_empty, prod_empty, coeff_one, zero_tsub, pow_zero, ideal.one_eq_top],\n    exact submodule.mem_top },\n  { rw [sum_insert ha, prod_insert ha, coeff_mul],\n    apply sum_mem,\n    rintro ⟨i, j⟩ e,\n    obtain rfl : i + j = k := nat.mem_antidiagonal.mp e,\n    apply ideal.pow_le_pow add_tsub_add_le_tsub_add_tsub,\n    rw pow_add,\n    exact ideal.mul_mem_mul (h _ (finset.mem_insert.mpr $ or.inl rfl) _)\n      (hs (λ i hi k, h _ (finset.mem_insert.mpr $ or.inr hi) _) j) }\nend\n\nend comm_semiring\n\nsection ring\nvariables [ring R]\n\n/-- `R[X]` is never a field for any ring `R`. -/\nlemma polynomial_not_is_field : ¬ is_field R[X] :=\nbegin\n  nontriviality R,\n  intro hR,\n  obtain ⟨p, hp⟩ := hR.mul_inv_cancel X_ne_zero,\n  have hp0 : p ≠ 0,\n  { rintro rfl,\n    rw [mul_zero] at hp,\n    exact zero_ne_one hp },\n  have := degree_lt_degree_mul_X hp0,\n  rw [←X_mul, congr_arg degree hp, degree_one, nat.with_bot.lt_zero_iff, degree_eq_bot] at this,\n  exact hp0 this,\nend\n\n/-- The only constant in a maximal ideal over a field is `0`. -/\nlemma eq_zero_of_constant_mem_of_maximal (hR : is_field R)\n  (I : ideal R[X]) [hI : I.is_maximal] (x : R) (hx : C x ∈ I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (λ hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain ⟨y, hy⟩ := hR.mul_inv_cancel hx0,\n  convert I.mul_mem_left (C y) hx,\n  rw [← C.map_mul, hR.mul_comm y x, hy, ring_hom.map_one],\nend\n\nend ring\n\nsection comm_ring\nvariables [comm_ring R]\n\n/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/\nlemma is_prime_map_C_iff_is_prime (P : ideal R) :\n  is_prime (map (C : R →+* R[X]) P : ideal R[X]) ↔ is_prime P :=\nbegin\n  -- Porting note: the following proof avoids quotient rings\n  -- It can be golfed substantially by using something like\n  -- `(quotient.is_domain_iff_prime (map C P : ideal R[X]))`\n  split,\n  { intro H,\n    have := @comap_is_prime R R[X] (R →+* R[X]) _ _ _ C (map C P) H,\n    convert this using 1,\n    ext x,\n    simp only [mem_comap, mem_map_C_iff],\n    split,\n    { rintro h (-|n),\n      { simpa only [coeff_C_zero] using h },\n      { simp only [coeff_C_ne_zero (nat.succ_ne_zero _), submodule.zero_mem] } },\n    { intro h, simpa only [coeff_C_zero] using h 0 } },\n  { intro h,\n    constructor,\n    { rw [ne.def, eq_top_iff_one, mem_map_C_iff, not_forall],\n      use 0,\n      rw [coeff_one_zero, ← eq_top_iff_one], exact h.1 },\n    { intros f g, simp only [mem_map_C_iff], contrapose!,\n      rintro ⟨hf, hg⟩,\n      classical,\n      let m := nat.find hf,\n      let n := nat.find hg,\n      refine ⟨m + n, _⟩,\n      rw [coeff_mul, ← finset.insert_erase ((@finset.nat.mem_antidiagonal _ (m,n)).mpr rfl),\n        finset.sum_insert (finset.not_mem_erase _ _), (P.add_mem_iff_left _).not],\n      { apply mt h.2, rw [not_or_distrib], exact ⟨nat.find_spec hf, nat.find_spec hg⟩ },\n      apply P.sum_mem,\n      rintro ⟨i, j⟩ hij,\n      rw [finset.mem_erase, finset.nat.mem_antidiagonal] at hij,\n      simp only [ne.def, prod.mk.inj_iff, not_and_distrib] at hij,\n      obtain (hi|hj) : i < m ∨ j < n,\n      { rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq],\n        rintro (hmi|rfl),\n        { rw [← not_le], intro hnj, exact (add_lt_add_of_lt_of_le hmi hnj).ne hij.2.symm, },\n        { simpa only [eq_self_iff_true, not_true, false_or, add_right_inj, not_and_self]\n            using hij, } },\n      { rw [mul_comm], apply P.mul_mem_left, exact not_not.1 (nat.find_min hf hi) },\n      { apply P.mul_mem_left, exact not_not.1 (nat.find_min hg hj) } } }\nend\n\n/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/\nlemma is_prime_map_C_of_is_prime {P : ideal R} (H : is_prime P) :\n  is_prime (map (C : R →+* R[X]) P : ideal R[X]) :=\n(is_prime_map_C_iff_is_prime P).mpr H\n\ntheorem is_fg_degree_le [is_noetherian_ring R] (I : ideal R[X]) (n : ℕ) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  ⟨_, degree_le_eq_span_X_pow.symm⟩) _\n\nend comm_ring\n\nend ideal\n\nvariables {σ : Type v} {M : Type w}\nvariables [comm_ring R] [comm_ring S] [add_comm_group M] [module R M]\n\nsection prime\nvariables (σ) {r : R}\n\nnamespace polynomial\nlemma prime_C_iff : prime (C r) ↔ prime r :=\n⟨ comap_prime C (eval_ring_hom (0 : R)) (λ r, eval_C),\n  λ hr, by { have := hr.1,\n    rw ← ideal.span_singleton_prime at hr ⊢,\n    { convert ideal.is_prime_map_C_of_is_prime hr using 1,\n      rw [ideal.map_span, set.image_singleton] },\n    exacts [λ h, this (C_eq_zero.1 h), this] } ⟩\nend polynomial\n\nnamespace mv_polynomial\n\nprivate lemma prime_C_iff_of_fintype [fintype σ] : prime (C r : mv_polynomial σ R) ↔ prime r :=\nbegin\n  rw (rename_equiv R (fintype.equiv_fin σ)).to_mul_equiv.prime_iff,\n  convert_to prime (C r) ↔ _, { congr, apply rename_C },\n  { symmetry, induction fintype.card σ with d hd,\n    { exact (is_empty_alg_equiv R (fin 0)).to_mul_equiv.symm.prime_iff },\n    { rw [hd, ← polynomial.prime_C_iff],\n      convert (fin_succ_equiv R d).to_mul_equiv.symm.prime_iff,\n      rw ← fin_succ_equiv_comp_C_eq_C, refl } },\nend\n\nlemma prime_C_iff : prime (C r : mv_polynomial σ R) ↔ prime r :=\n⟨ comap_prime C constant_coeff (constant_coeff_C _),\n  λ hr, ⟨ λ h, hr.1 $ by { rw [← C_inj, h], simp },\n    λ h, hr.2.1 $ by { rw ← constant_coeff_C _ r, exact h.map _ },\n    λ a b hd, begin\n      obtain ⟨s,a',b',rfl,rfl⟩ := exists_finset_rename₂ a b,\n      rw ← algebra_map_eq at hd, have : algebra_map R _ r ∣ a' * b',\n      { convert (kill_compl subtype.coe_injective).to_ring_hom.map_dvd hd, simpa, simp },\n      rw ← rename_C (coe : s → σ), let f := (rename (coe : s → σ)).to_ring_hom,\n      exact (((prime_C_iff_of_fintype s).2 hr).2.2 a' b' this).imp f.map_dvd f.map_dvd,\n    end ⟩ ⟩\n\nvariable {σ}\nlemma prime_rename_iff (s : set σ) {p : mv_polynomial s R} :\n  prime (rename (coe : s → σ) p) ↔ prime p :=\nbegin\n  classical, symmetry, let eqv := (sum_alg_equiv R _ _).symm.trans\n    (rename_equiv R $ (equiv.sum_comm ↥sᶜ s).trans $ equiv.set.sum_compl s),\n  rw [← prime_C_iff ↥sᶜ, eqv.to_mul_equiv.prime_iff], convert iff.rfl,\n  suffices : (rename coe).to_ring_hom = eqv.to_alg_hom.to_ring_hom.comp C,\n  { apply ring_hom.congr_fun this },\n  { apply ring_hom_ext,\n    { intro, dsimp [eqv], erw [iter_to_sum_C_C, rename_C, rename_C] },\n    { intro, dsimp [eqv], erw [iter_to_sum_C_X, rename_X, rename_X], refl } },\nend\n\nend mv_polynomial\n\nend prime\n\nnamespace polynomial\n\n@[priority 100]\ninstance {R : Type*} [comm_ring R] [is_domain R] [wf_dvd_monoid R] :\n  wf_dvd_monoid R[X] :=\n{ well_founded_dvd_not_unit := begin\n    classical,\n    refine rel_hom_class.well_founded (⟨λ (p : R[X]),\n        ((if p = 0 then ⊤ else ↑p.degree : with_top (with_bot ℕ)), p.leading_coeff), _⟩ :\n        dvd_not_unit →r prod.lex (<) dvd_not_unit)\n      (prod.lex_wf (with_top.well_founded_lt $ with_bot.well_founded_lt nat.lt_wf)\n        ‹wf_dvd_monoid R›.well_founded_dvd_not_unit),\n    rintros a b ⟨ane0, ⟨c, ⟨not_unit_c, rfl⟩⟩⟩,\n    rw [polynomial.degree_mul, if_neg ane0],\n    split_ifs with hac,\n    { rw [hac, polynomial.leading_coeff_zero],\n      apply prod.lex.left,\n      exact lt_of_le_of_ne le_top with_top.coe_ne_top },\n    have cne0 : c ≠ 0 := right_ne_zero_of_mul hac,\n    simp only [cne0, ane0, polynomial.leading_coeff_mul],\n    by_cases hdeg : c.degree = 0,\n    { simp only [hdeg, add_zero],\n      refine prod.lex.right _ ⟨_, ⟨c.leading_coeff, (λ unit_c, not_unit_c _), rfl⟩⟩,\n      { rwa [ne, polynomial.leading_coeff_eq_zero] },\n      rw [polynomial.is_unit_iff, polynomial.eq_C_of_degree_eq_zero hdeg],\n      use [c.leading_coeff, unit_c],\n      rw [polynomial.leading_coeff, polynomial.nat_degree_eq_of_degree_eq_some hdeg] },\n    { apply prod.lex.left,\n      rw polynomial.degree_eq_nat_degree cne0 at *,\n      rw [with_top.coe_lt_coe, polynomial.degree_eq_nat_degree ane0,\n          ← with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (λ h, hdeg (h.symm ▸ with_bot.coe_zero))) },\n  end }\n\nend polynomial\n\n/-- Hilbert basis theorem: a polynomial ring over a noetherian ring is a noetherian ring. -/\nprotected theorem polynomial.is_noetherian_ring [is_noetherian_ring R] :\n  is_noetherian_ring R[X] :=\nis_noetherian_ring_iff.2 ⟨assume I : ideal R[X],\nlet M := well_founded.min (is_noetherian_iff_well_founded.1 (by apply_instance))\n  (set.range I.leading_coeff_nth) ⟨_, ⟨0, rfl⟩⟩ in\nhave hm : M ∈ set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet ⟨N, HN⟩ := hm, ⟨s, hs⟩ := I.is_fg_degree_le N in\nhave hm2 : ∀ k, I.leading_coeff_nth k ≤ M := λ k, or.cases_on (le_or_lt k N)\n  (λ h, HN ▸ I.leading_coeff_nth_mono h)\n  (λ h x hx, classical.by_contradiction $ λ hxm,\n    have ¬M < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact ⟨k, rfl⟩,\n    this ⟨HN ▸ I.leading_coeff_nth_mono (le_of_lt h), λ H, hxm (H hx)⟩),\nhave hs2 : ∀ {x}, x ∈ I.degree_le N → x ∈ ideal.span (↑s : set R[X]),\nfrom hs ▸ λ x hx, submodule.span_induction hx (λ _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (λ _ _, ideal.add_mem _) (λ c f hf, f.C_mul' c ▸ ideal.mul_mem_left _ _ hf),\n⟨s, le_antisymm\n  (ideal.span_le.2 $ λ x hx, have x ∈ I.degree_le N, from hs ▸ submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span R[X] ↑s = ideal.span ↑s, by refl,\n  rw this,\n  intros p hp, generalize hn : p.nat_degree = k,\n  induction k using nat.strong_induction_on with k ih generalizing p,\n  cases le_or_lt k N,\n  { subst k, refine hs2 ⟨polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp⟩ },\n  { have hp0 : p ≠ 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) ≠ 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [← h, mul_zero], refl },\n    haveI : nontrivial R := ⟨⟨0, 1, this⟩⟩,\n    have : p.leading_coeff ∈ I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        ⟨_, hp, hn ▸ polynomial.degree_le_nat_degree, rfl⟩) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with ⟨q, hq, hdq, hlqp⟩,\n    have hq0 : q ≠ 0,\n    { intro H, rw [← polynomial.leading_coeff_eq_zero] at H,\n      rw [hlqp, polynomial.leading_coeff_eq_zero] at H, exact hp0 H },\n    have h1 : p.degree = (q * polynomial.X ^ (k - q.nat_degree)).degree,\n    { rw [polynomial.degree_mul', polynomial.degree_X_pow],\n      rw [polynomial.degree_eq_nat_degree hp0, polynomial.degree_eq_nat_degree hq0],\n      rw [← with_bot.coe_add, add_tsub_cancel_of_le, hn],\n      { refine le_trans (polynomial.nat_degree_le_of_degree_le hdq) (le_of_lt h) },\n      rw [polynomial.leading_coeff_X_pow, mul_one],\n      exact mt polynomial.leading_coeff_eq_zero.1 hq0 },\n    have h2 : p.leading_coeff = (q * polynomial.X ^ (k - q.nat_degree)).leading_coeff,\n    { rw [← hlqp, polynomial.leading_coeff_mul_X_pow] },\n    have := polynomial.degree_sub_lt h1 hp0 h2,\n    rw [polynomial.degree_eq_nat_degree hp0] at this,\n    rw ← sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span ↑s).add_mem _ ((ideal.span ↑s).mul_mem_right _ _),\n    { by_cases hpq : p - q * polynomial.X ^ (k - q.nat_degree) = 0,\n      { rw hpq, exact ideal.zero_mem _ },\n      refine ih _ _ (I.sub_mem hp (I.mul_mem_right _ hq)) rfl,\n      rwa [polynomial.degree_eq_nat_degree hpq, with_bot.coe_lt_coe, hn] at this },\n    exact hs2 ⟨polynomial.mem_degree_le.2 hdq, hq⟩ }\nend⟩⟩\n\nattribute [instance] polynomial.is_noetherian_ring\n\nnamespace polynomial\n\ntheorem exists_irreducible_of_degree_pos\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : R[X]} (hf : 0 < f.degree) : ∃ g, irreducible g ∧ g ∣ f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (λ huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (λ hf0, not_lt_of_lt hf $ hf0.symm ▸ (@degree_zero R _).symm ▸ with_bot.bot_lt_coe _)\n\ntheorem exists_irreducible_of_nat_degree_pos\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : R[X]} (hf : 0 < f.nat_degree) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_degree_pos $ by { contrapose! hf, exact nat_degree_le_of_degree_le hf }\n\ntheorem exists_irreducible_of_nat_degree_ne_zero\n  {R : Type u} [comm_ring R] [is_domain R] [wf_dvd_monoid R]\n  {f : R[X]} (hf : f.nat_degree ≠ 0) : ∃ g, irreducible g ∧ g ∣ f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_aeval\n  (f : M →ₗ[R] M) (v : M) :\n  linear_independent R (λ n : ℕ, (f ^ n) v)\n    ↔ ∀ (p : R[X]), aeval f p v = 0 → p = 0 :=\nbegin\n  rw linear_independent_iff,\n  simp only [finsupp.total_apply, aeval_endomorphism, forall_iff_forall_finsupp, sum, support,\n    coeff, of_finsupp_eq_zero],\n  exact iff.rfl,\nend\n\nlemma disjoint_ker_aeval_of_coprime\n  (f : M →ₗ[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  disjoint (aeval f p).ker (aeval f q).ker :=\nbegin\n  rw disjoint_iff_inf_le,\n  intros v hv,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  simpa [linear_map.mem_ker.1 (submodule.mem_inf.1 hv).1,\n         linear_map.mem_ker.1 (submodule.mem_inf.1 hv).2]\n    using congr_arg (λ p : R[X], aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M →ₗ[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).range ⊔ (aeval f q).range = ⊤ :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 ⟨aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 ⟨aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]⟩,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (λ p : R[X], aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M →ₗ[R] M} {p q : R[X]} :\n  (aeval f p).ker ⊔ (aeval f q).ker ≤ (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with ⟨x, hx, y, hy, hxy⟩,\n  have h_eval_x : aeval f (p * q) x = 0,\n  { rw [mul_comm, aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hx, linear_map.map_zero] },\n  have h_eval_y : aeval f (p * q) y = 0,\n  { rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hy, linear_map.map_zero] },\n  rw [linear_map.mem_ker, ←hxy, linear_map.map_add, h_eval_x, h_eval_y, add_zero],\nend\n\nlemma sup_ker_aeval_eq_ker_aeval_mul_of_coprime\n  (f : M →ₗ[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).ker ⊔ (aeval f q).ker = (aeval f (p * q)).ker :=\nbegin\n  apply le_antisymm sup_ker_aeval_le_ker_aeval_mul,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with ⟨p', q', hpq'⟩,\n  have h_eval₂_qpp' := calc\n    aeval f (q * (p * p')) v = aeval f (p' * (p * q)) v :\n      by rw [mul_comm, mul_assoc, mul_comm, mul_assoc, mul_comm q p]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  have h_eval₂_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [←mul_assoc, mul_comm]\n    ... = 0 :\n      by rw [aeval_mul, linear_map.mul_apply, linear_map.mem_ker.1 hv, linear_map.map_zero],\n  rw aeval_mul at h_eval₂_qpp' h_eval₂_pqq',\n  refine ⟨aeval f (q * q') v, linear_map.mem_ker.1 h_eval₂_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval₂_qpp', _⟩,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa only [map_add, map_mul, aeval_one] using congr_arg (λ p : R[X], aeval f p v) hpq'\nend\n\nend polynomial\n\nnamespace mv_polynomial\n\nlemma is_noetherian_ring_fin_0 [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial (fin 0) R) :=\nis_noetherian_ring_of_ring_equiv R\n  ((mv_polynomial.is_empty_ring_equiv R pempty).symm.trans\n   (rename_equiv R fin_zero_equiv'.symm).to_ring_equiv)\n\ntheorem is_noetherian_ring_fin [is_noetherian_ring R] :\n  ∀ {n : ℕ}, is_noetherian_ring (mv_polynomial (fin n) R)\n| 0 := is_noetherian_ring_fin_0\n| (n+1) :=\n  @is_noetherian_ring_of_ring_equiv (polynomial (mv_polynomial (fin n) R)) _ _ _\n    (mv_polynomial.fin_succ_equiv _ n).to_ring_equiv.symm\n    (@polynomial.is_noetherian_ring (mv_polynomial (fin n) R) _ (is_noetherian_ring_fin))\n\n/-- The multivariate polynomial ring in finitely many variables over a noetherian ring\nis itself a noetherian ring. -/\ninstance is_noetherian_ring [finite σ] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial σ R) :=\nby casesI nonempty_fintype σ; exact\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card σ)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin σ).symm).to_ring_equiv is_noetherian_ring_fin\n\n/-- Auxiliary lemma:\nMultivariate polynomials over an integral domain\nwith variables indexed by `fin n` form an integral domain.\nThis fact is proven inductively,\nand then used to prove the general case without any finiteness hypotheses.\nSee `mv_polynomial.no_zero_divisors` for the general case. -/\nlemma no_zero_divisors_fin (R : Type u) [comm_semiring R] [no_zero_divisors R] :\n  ∀ (n : ℕ), no_zero_divisors (mv_polynomial (fin n) R)\n| 0 := (mv_polynomial.is_empty_alg_equiv R _).injective.no_zero_divisors _ (map_zero _) (map_mul _)\n| (n+1) := begin\n    haveI := no_zero_divisors_fin n,\n    exact (mv_polynomial.fin_succ_equiv R n).injective.no_zero_divisors _ (map_zero _) (map_mul _)\n  end\n\n/-- Auxiliary definition:\nMultivariate polynomials in finitely many variables over an integral domain form an integral domain.\nThis fact is proven by transport of structure from the `mv_polynomial.no_zero_divisors_fin`,\nand then used to prove the general case without finiteness hypotheses.\nSee `mv_polynomial.no_zero_divisors` for the general case. -/\nlemma no_zero_divisors_of_finite (R : Type u) (σ : Type v) [comm_semiring R] [finite σ]\n  [no_zero_divisors R] : no_zero_divisors (mv_polynomial σ R) :=\nbegin\n  casesI nonempty_fintype σ,\n  haveI := no_zero_divisors_fin R (fintype.card σ),\n  exact (rename_equiv R (fintype.equiv_fin σ)).injective.no_zero_divisors _ (map_zero _) (map_mul _)\nend\n\ninstance {R : Type u} [comm_semiring R] [no_zero_divisors R] {σ : Type v} :\n  no_zero_divisors (mv_polynomial σ R) :=\n⟨λ p q h, begin\n  obtain ⟨s, p, rfl⟩ := exists_finset_rename p,\n  obtain ⟨t, q, rfl⟩ := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x ∈ s} → {x // x ∈ s ∪ t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x ∈ t} → {x // x ∈ s ∪ t}) q = 0,\n  { apply rename_injective _ subtype.val_injective, simpa using h },\n  letI := mv_polynomial.no_zero_divisors_of_finite R {x // x ∈ (s ∪ t)},\n  rw mul_eq_zero at this,\n  cases this; [left, right],\n  all_goals { simpa using congr_arg (rename subtype.val) this }\nend⟩\n\n/-- The multivariate polynomial ring over an integral domain is an integral domain. -/\ninstance {R : Type u} {σ : Type v} [comm_ring R] [is_domain R] : is_domain (mv_polynomial σ R) :=\nbegin\n  apply no_zero_divisors.to_is_domain _,\n  exact add_monoid_algebra.nontrivial,\n  exact mv_polynomial.no_zero_divisors\nend\n\nlemma map_mv_polynomial_eq_eval₂ {S : Type*} [comm_ring S] [finite σ]\n  (ϕ : mv_polynomial σ R →+* S) (p : mv_polynomial σ R) :\n  ϕ p = mv_polynomial.eval₂ (ϕ.comp mv_polynomial.C) (λ s, ϕ (mv_polynomial.X s)) p :=\nbegin\n  casesI nonempty_fintype σ,\n  refine trans (congr_arg ϕ (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval₂_eq', ϕ.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, ϕ.map_pow, ϕ.map_prod, ϕ.comp_apply, ϕ.map_mul, finsupp.prod_pow],\nend\n\n/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself,\nmultivariate version. -/\nlemma mem_ideal_of_coeff_mem_ideal (I : ideal (mv_polynomial σ R)) (p : mv_polynomial σ R)\n  (hcoe : ∀ (m : σ →₀ ℕ), p.coeff m ∈ I.comap (C : R →+* mv_polynomial σ R)) : p ∈ I :=\nbegin\n  rw as_sum p,\n  suffices : ∀ m ∈ p.support, monomial m (mv_polynomial.coeff m p) ∈ I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [← mul_one (coeff m p), ← C_mul_monomial],\n  suffices : C (coeff m p) ∈ I,\n  { exact I.mul_mem_right (monomial m 1) this },\n  simpa [ideal.mem_comap] using hcoe m\nend\n\n/-- The push-forward of an ideal `I` of `R` to `mv_polynomial σ R` via inclusion\n is exactly the set of polynomials whose coefficients are in `I` -/\ntheorem mem_map_C_iff {I : ideal R} {f : mv_polynomial σ R} :\n  f ∈ (ideal.map (C : R →+* mv_polynomial σ R) I :\n  ideal (mv_polynomial σ R)) ↔ ∀ (m : σ →₀ ℕ), f.coeff m ∈ I :=\nbegin\n  split,\n  { intros hf,\n    apply submodule.span_induction hf,\n    { intros f hf n,\n      cases (set.mem_image _ _ _).mp hf with x hx,\n      rw [← hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n    { exact λ f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine λ f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (λ c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : ∀ m ∈ f.support, monomial m (coeff m f) ∈\n      (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [← mul_one (coeff m f), ← C_mul_monomial],\n    suffices : C (coeff m f) ∈ (ideal.map C I : ideal (mv_polynomial σ R)),\n    { exact ideal.mul_mem_right _ _ this },\n    apply ideal.mem_map_of_mem _,\n    exact hf m }\nend\n\nlemma ker_map (f : R →+* S) :\n  (map f : mv_polynomial σ R →+* mv_polynomial σ S).ker = f.ker.map (C : R →+* mv_polynomial σ R) :=\nbegin\n  ext,\n  rw [mv_polynomial.mem_map_C_iff, ring_hom.mem_ker, mv_polynomial.ext_iff],\n  simp_rw [coeff_map, coeff_zero, ring_hom.mem_ker],\nend\n\nend mv_polynomial\n\nsection unique_factorization_domain\nvariables {D : Type u} [comm_ring D] [is_domain D] [unique_factorization_monoid D] (σ)\nopen unique_factorization_monoid\n\nnamespace polynomial\n\n@[priority 100]\ninstance unique_factorization_monoid : unique_factorization_monoid D[X] :=\nbegin\n  haveI := arbitrary (normalization_monoid D),\n  haveI := to_normalized_gcd_monoid D,\n  exact ufm_of_gcd_of_wf_dvd_monoid\nend\n\nend polynomial\n\nnamespace mv_polynomial\n\nprivate lemma unique_factorization_monoid_of_fintype [fintype σ] :\n  unique_factorization_monoid (mv_polynomial σ D) :=\n(rename_equiv D (fintype.equiv_fin σ)).to_mul_equiv.symm.unique_factorization_monoid $\nbegin\n  induction fintype.card σ with d hd,\n  { apply (is_empty_alg_equiv D (fin 0)).to_mul_equiv.symm.unique_factorization_monoid,\n    apply_instance },\n  { apply (fin_succ_equiv D d).to_mul_equiv.symm.unique_factorization_monoid,\n    exactI polynomial.unique_factorization_monoid },\nend\n\n@[priority 100]\ninstance : unique_factorization_monoid (mv_polynomial σ D) :=\nbegin\n  rw iff_exists_prime_factors,\n  intros a ha, obtain ⟨s,a',rfl⟩ := exists_finset_rename a,\n  obtain ⟨w,h,u,hw⟩ := iff_exists_prime_factors.1\n    (unique_factorization_monoid_of_fintype s) a' (λ h, ha $ by simp [h]),\n  exact ⟨ w.map (rename coe),\n    λ b hb, let ⟨b',hb',he⟩ := multiset.mem_map.1 hb in he ▸ (prime_rename_iff ↑s).2 (h b' hb'),\n    units.map (@rename s σ D _ coe).to_ring_hom.to_monoid_hom u,\n    by erw [multiset.prod_hom, ← map_mul, hw] ⟩,\nend\n\nend mv_polynomial\nend unique_factorization_domain\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/ring_theory/polynomial/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6370307944803831, "lm_q1q2_score": 0.45574711642427623}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.limits.has_limits\nimport category_theory.discrete_category\n\n/-!\n# Categorical (co)products\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines (co)products as special cases of (co)limits.\n\nA product is the categorical generalization of the object `Π i, f i` where `f : ι → C`. It is a\nlimit cone over the diagram formed by `f`, implemented by converting `f` into a functor\n`discrete ι ⥤ C`.\n\nA coproduct is the dual concept.\n\n## Main definitions\n\n* a `fan` is a cone over a discrete category\n* `fan.mk` constructs a fan from an indexed collection of maps\n* a `pi` is a `limit (discrete.functor f)`\n\nEach of these has a dual.\n\n## Implementation notes\nAs with the other special shapes in the limits library, all the definitions here are given as\n`abbreviation`s of the general statements for limits, so all the `simp` lemmas and theorems about\ngeneral limits can be used.\n-/\n\nnoncomputable theory\n\nuniverses w v v₂ u u₂\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables {β : Type w}\nvariables {C : Type u} [category.{v} C]\n\n-- We don't need an analogue of `pair` (for binary products), `parallel_pair` (for equalizers),\n-- or `(co)span`, since we already have `discrete.functor`.\n\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- A fan over `f : β → C` consists of a collection of maps from an object `P` to every `f b`. -/\nabbreviation fan (f : β → C) := cone (discrete.functor f)\n/-- A cofan over `f : β → C` consists of a collection of maps from every `f b` to an object `P`. -/\nabbreviation cofan (f : β → C) := cocone (discrete.functor f)\n\n/-- A fan over `f : β → C` consists of a collection of maps from an object `P` to every `f b`. -/\n@[simps]\ndef fan.mk {f : β → C} (P : C) (p : Π b, P ⟶ f b) : fan f :=\n{ X := P,\n  π := { app := λ X, p X.as } }\n\n/-- A cofan over `f : β → C` consists of a collection of maps from every `f b` to an object `P`. -/\n@[simps]\ndef cofan.mk {f : β → C} (P : C) (p : Π b, f b ⟶ P) : cofan f :=\n{ X := P,\n  ι := { app := λ X, p X.as } }\n\n-- FIXME dualize as needed below (and rename?)\n\n/-- Get the `j`th map in the fan -/\ndef fan.proj  {f : β → C} (p : fan f) (j : β) : p.X ⟶ f j := p.π.app (discrete.mk j)\n@[simp] lemma fan_mk_proj {f : β → C} (P : C) (p : Π b, P ⟶ f b) (j : β) :\n  (fan.mk P p).proj j = p j := rfl\n\n/-- An abbreviation for `has_limit (discrete.functor f)`. -/\nabbreviation has_product (f : β → C) := has_limit (discrete.functor f)\n\n/-- An abbreviation for `has_colimit (discrete.functor f)`. -/\nabbreviation has_coproduct (f : β → C) := has_colimit (discrete.functor f)\n\n/-- Make a fan `f` into a limit fan by providing `lift`, `fac`, and `uniq` --\n  just a convenience lemma to avoid having to go through `discrete` -/\n@[simps] def mk_fan_limit {f : β → C} (t : fan f)\n  (lift : Π s : fan f, s.X ⟶ t.X)\n  (fac : ∀ (s : fan f) (j : β), lift s ≫ (t.proj j) = s.proj j)\n  (uniq : ∀ (s : fan f) (m : s.X ⟶ t.X) (w : ∀ j : β, m ≫ t.proj j = s.proj j), m = lift s) :\n  is_limit t :=\n{ lift := lift,\n  fac' := λ s j, by convert fac s j.as; simp,\n  uniq' := λ s m w, uniq s m (λ j, w (discrete.mk j)), }\n\n\nsection\nvariables (C)\n\n/-- An abbreviation for `has_limits_of_shape (discrete f)`. -/\nabbreviation has_products_of_shape (β : Type v) := has_limits_of_shape.{v} (discrete β)\n/-- An abbreviation for `has_colimits_of_shape (discrete f)`. -/\nabbreviation has_coproducts_of_shape (β : Type v) := has_colimits_of_shape.{v} (discrete β)\nend\n\n/-- `pi_obj f` computes the product of a family of elements `f`.\n(It is defined as an abbreviation for `limit (discrete.functor f)`,\nso for most facts about `pi_obj f`, you will just use general facts about limits.) -/\nabbreviation pi_obj (f : β → C) [has_product f] := limit (discrete.functor f)\n/-- `sigma_obj f` computes the coproduct of a family of elements `f`.\n(It is defined as an abbreviation for `colimit (discrete.functor f)`,\nso for most facts about `sigma_obj f`, you will just use general facts about colimits.) -/\nabbreviation sigma_obj (f : β → C) [has_coproduct f] := colimit (discrete.functor f)\n\nnotation `∏ ` f:20 := pi_obj f\nnotation `∐ ` f:20 := sigma_obj f\n\n/-- The `b`-th projection from the pi object over `f` has the form `∏ f ⟶ f b`. -/\nabbreviation pi.π (f : β → C) [has_product f] (b : β) : ∏ f ⟶ f b :=\nlimit.π (discrete.functor f) (discrete.mk b)\n/-- The `b`-th inclusion into the sigma object over `f` has the form `f b ⟶ ∐ f`. -/\nabbreviation sigma.ι (f : β → C) [has_coproduct f] (b : β) : f b ⟶ ∐ f :=\ncolimit.ι (discrete.functor f) (discrete.mk b)\n\n/-- The fan constructed of the projections from the product is limiting. -/\ndef product_is_product (f : β → C) [has_product f] :\n  is_limit (fan.mk _ (pi.π f)) :=\nis_limit.of_iso_limit (limit.is_limit (discrete.functor f)) (cones.ext (iso.refl _) (by tidy))\n\n/-- The cofan constructed of the inclusions from the coproduct is colimiting. -/\ndef coproduct_is_coproduct (f : β → C) [has_coproduct f] :\n  is_colimit (cofan.mk _ (sigma.ι f)) :=\nis_colimit.of_iso_colimit (colimit.is_colimit (discrete.functor f)) (cocones.ext (iso.refl _)\n  (by tidy))\n\n/-- A collection of morphisms `P ⟶ f b` induces a morphism `P ⟶ ∏ f`. -/\nabbreviation pi.lift {f : β → C} [has_product f] {P : C} (p : Π b, P ⟶ f b) : P ⟶ ∏ f :=\nlimit.lift _ (fan.mk P p)\n/-- A collection of morphisms `f b ⟶ P` induces a morphism `∐ f ⟶ P`. -/\nabbreviation sigma.desc {f : β → C} [has_coproduct f] {P : C} (p : Π b, f b ⟶ P) : ∐ f ⟶ P :=\ncolimit.desc _ (cofan.mk P p)\n\n/--\nConstruct a morphism between categorical products (indexed by the same type)\nfrom a family of morphisms between the factors.\n-/\nabbreviation pi.map {f g : β → C} [has_product f] [has_product g]\n  (p : Π b, f b ⟶ g b) : ∏ f ⟶ ∏ g :=\nlim_map (discrete.nat_trans (λ X, p X.as))\n\ninstance pi.map_mono {f g : β → C} [has_product f] [has_product g]\n  (p : Π b, f b ⟶ g b) [Π i, mono (p i)] : mono $ pi.map p :=\n@@limits.lim_map_mono _ _ _ _ _ (by { dsimp, apply_instance })\n\n/--\nConstruct an isomorphism between categorical products (indexed by the same type)\nfrom a family of isomorphisms between the factors.\n-/\nabbreviation pi.map_iso {f g : β → C} [has_products_of_shape β C]\n  (p : Π b, f b ≅ g b) : ∏ f ≅ ∏ g :=\nlim.map_iso (discrete.nat_iso (λ X, p X.as))\n/--\nConstruct a morphism between categorical coproducts (indexed by the same type)\nfrom a family of morphisms between the factors.\n-/\nabbreviation sigma.map {f g : β → C} [has_coproduct f] [has_coproduct g]\n  (p : Π b, f b ⟶ g b) : ∐ f ⟶ ∐ g :=\ncolim_map (discrete.nat_trans (λ X, p X.as))\n\ninstance sigma.map_epi {f g : β → C} [has_coproduct f] [has_coproduct g]\n  (p : Π b, f b ⟶ g b) [Π i, epi (p i)] : epi $ sigma.map p :=\n@@limits.colim_map_epi _ _ _ _ _ (by { dsimp, apply_instance })\n\n/--\nConstruct an isomorphism between categorical coproducts (indexed by the same type)\nfrom a family of isomorphisms between the factors.\n-/\nabbreviation sigma.map_iso {f g : β → C} [has_coproducts_of_shape β C]\n  (p : Π b, f b ≅ g b) : ∐ f ≅ ∐ g :=\ncolim.map_iso (discrete.nat_iso (λ X, p X.as))\n\nsection comparison\n\nvariables {D : Type u₂} [category.{v₂} D] (G : C ⥤ D)\nvariables (f : β → C)\n\n/-- The comparison morphism for the product of `f`. This is an iso iff `G` preserves the product\nof `f`, see `preserves_product.of_iso_comparison`. -/\ndef pi_comparison [has_product f] [has_product (λ b, G.obj (f b))] :\n  G.obj (∏ f) ⟶ ∏ (λ b, G.obj (f b)) :=\npi.lift (λ b, G.map (pi.π f b))\n\n@[simp, reassoc]\nlemma pi_comparison_comp_π [has_product f] [has_product (λ b, G.obj (f b))] (b : β) :\n  pi_comparison G f ≫ pi.π _ b = G.map (pi.π f b) :=\nlimit.lift_π _ (discrete.mk b)\n\n@[simp, reassoc]\nlemma map_lift_pi_comparison [has_product f] [has_product (λ b, G.obj (f b))]\n  (P : C) (g : Π j, P ⟶ f j) :\n  G.map (pi.lift g) ≫ pi_comparison G f = pi.lift (λ j, G.map (g j)) :=\nby { ext, discrete_cases, simp [← G.map_comp] }\n\n/-- The comparison morphism for the coproduct of `f`. This is an iso iff `G` preserves the coproduct\nof `f`, see `preserves_coproduct.of_iso_comparison`. -/\ndef sigma_comparison [has_coproduct f] [has_coproduct (λ b, G.obj (f b))] :\n  ∐ (λ b, G.obj (f b)) ⟶ G.obj (∐ f) :=\nsigma.desc (λ b, G.map (sigma.ι f b))\n\n@[simp, reassoc]\nlemma ι_comp_sigma_comparison [has_coproduct f] [has_coproduct (λ b, G.obj (f b))] (b : β) :\n  sigma.ι _ b ≫ sigma_comparison G f = G.map (sigma.ι f b) :=\ncolimit.ι_desc _ (discrete.mk b)\n\n@[simp, reassoc]\nlemma sigma_comparison_map_desc [has_coproduct f] [has_coproduct (λ b, G.obj (f b))]\n  (P : C) (g : Π j, f j ⟶ P) :\n  sigma_comparison G f ≫ G.map (sigma.desc g) = sigma.desc (λ j, G.map (g j)) :=\nby { ext, discrete_cases, simp [← G.map_comp] }\n\nend comparison\n\nvariables (C)\n\n/-- An abbreviation for `Π J, has_limits_of_shape (discrete J) C` -/\nabbreviation has_products := Π (J : Type w), has_limits_of_shape (discrete J) C\n/-- An abbreviation for `Π J, has_colimits_of_shape (discrete J) C` -/\nabbreviation has_coproducts := Π (J : Type w), has_colimits_of_shape (discrete J) C\n\nvariable {C}\n\nlemma has_smallest_products_of_has_products [has_products.{w} C] : has_products.{0} C :=\nλ J, has_limits_of_shape_of_equivalence\n  (discrete.equivalence equiv.ulift : discrete (ulift.{w} J) ≌ _)\n\nlemma has_smallest_coproducts_of_has_coproducts [has_coproducts.{w} C] : has_coproducts.{0} C :=\nλ J, has_colimits_of_shape_of_equivalence\n  (discrete.equivalence equiv.ulift : discrete (ulift.{w} J) ≌ _)\n\nlemma has_products_of_limit_fans (lf : ∀ {J : Type w} (f : J → C), fan f)\n  (lf_is_limit : ∀ {J : Type w} (f : J → C), is_limit (lf f)) : has_products.{w} C :=\nλ (J : Type w), { has_limit := λ F, has_limit.mk\n  ⟨(cones.postcompose discrete.nat_iso_functor.inv).obj (lf (λ j, F.obj ⟨j⟩)),\n    (is_limit.postcompose_inv_equiv _ _).symm (lf_is_limit _)⟩ }\n\n/-!\n(Co)products over a type with a unique term.\n-/\nsection unique\nvariables {C} [unique β] (f : β → C)\n\n/-- The limit cone for the product over an index type with exactly one term. -/\n@[simps]\ndef limit_cone_of_unique : limit_cone (discrete.functor f) :=\n{ cone :=\n  { X := f default,\n    π := { app := λ j, eq_to_hom (by { dsimp, congr, }), }, },\n  is_limit :=\n  { lift := λ s, s.π.app default,\n    fac' := λ s j, begin\n      have w := (s.π.naturality (eq_to_hom (unique.default_eq _))).symm,\n      dsimp at w,\n      simpa [eq_to_hom_map] using w,\n    end,\n    uniq' := λ s m w, begin\n      specialize w default,\n      dsimp at w,\n      simpa using w,\n    end, }, }\n\n@[priority 100] instance has_product_unique : has_product f :=\nhas_limit.mk (limit_cone_of_unique f)\n\n/-- A product over a index type with exactly one term is just the object over that term. -/\n@[simps]\ndef product_unique_iso : ∏ f ≅ f default :=\nis_limit.cone_point_unique_up_to_iso (limit.is_limit _) (limit_cone_of_unique f).is_limit\n\n/-- The colimit cocone for the coproduct over an index type with exactly one term. -/\n@[simps]\ndef colimit_cocone_of_unique : colimit_cocone (discrete.functor f) :=\n{ cocone :=\n  { X := f default,\n    ι := { app := λ j, eq_to_hom (by { discrete_cases, dsimp, congr, }), }, },\n  is_colimit :=\n  { desc := λ s, s.ι.app default,\n    fac' := λ s j, begin\n      have w := (s.ι.naturality (eq_to_hom (unique.eq_default _))),\n      dsimp at w,\n      simpa [eq_to_hom_map] using w,\n    end,\n    uniq' := λ s m w, begin\n      specialize w default,\n      dsimp at w,\n      simpa using w,\n    end, }, }\n\n@[priority 100] instance has_coproduct_unique : has_coproduct f :=\nhas_colimit.mk (colimit_cocone_of_unique f)\n\n/-- A coproduct over a index type with exactly one term is just the object over that term. -/\n@[simps]\ndef coproduct_unique_iso : ∐ f ≅ f default :=\nis_colimit.cocone_point_unique_up_to_iso (colimit.is_colimit _)\n  (colimit_cocone_of_unique f).is_colimit\n\nend unique\n\nsection reindex\nvariables {C} {γ : Type v} (ε : β ≃ γ) (f : γ → C)\n\nsection\nvariables [has_product f] [has_product (f ∘ ε)]\n\n/-- Reindex a categorical product via an equivalence of the index types. -/\ndef pi.reindex : pi_obj (f ∘ ε) ≅ pi_obj f :=\nhas_limit.iso_of_equivalence (discrete.equivalence ε) (discrete.nat_iso (λ i, iso.refl _))\n\n@[simp, reassoc]\nlemma pi.reindex_hom_π (b : β) : (pi.reindex ε f).hom ≫ pi.π f (ε b) = pi.π (f ∘ ε) b :=\nbegin\n  dsimp [pi.reindex],\n  simp only [has_limit.iso_of_equivalence_hom_π, discrete.nat_iso_inv_app,\n    equivalence.equivalence_mk'_counit, discrete.equivalence_counit_iso, discrete.nat_iso_hom_app,\n    eq_to_iso.hom, eq_to_hom_map],\n  dsimp,\n  simpa [eq_to_hom_map] using\n    limit.w (discrete.functor (f ∘ ε)) (discrete.eq_to_hom' (ε.symm_apply_apply b)),\nend\n\n@[simp, reassoc]\nlemma pi.reindex_inv_π (b : β) : (pi.reindex ε f).inv ≫ pi.π (f ∘ ε) b = pi.π f (ε b) :=\nby simp [iso.inv_comp_eq]\n\nend\n\nsection\nvariables [has_coproduct f] [has_coproduct (f ∘ ε)]\n\n/-- Reindex a categorical coproduct via an equivalence of the index types. -/\ndef sigma.reindex : sigma_obj (f ∘ ε) ≅ sigma_obj f :=\nhas_colimit.iso_of_equivalence (discrete.equivalence ε) (discrete.nat_iso (λ i, iso.refl _))\n\n@[simp, reassoc]\nlemma sigma.ι_reindex_hom (b : β) : sigma.ι (f ∘ ε) b ≫ (sigma.reindex ε f).hom = sigma.ι f (ε b) :=\nbegin\n  dsimp [sigma.reindex],\n  simp only [has_colimit.iso_of_equivalence_hom_π, equivalence.equivalence_mk'_unit,\n    discrete.equivalence_unit_iso, discrete.nat_iso_hom_app, eq_to_iso.hom, eq_to_hom_map,\n    discrete.nat_iso_inv_app],\n  dsimp,\n  simp [eq_to_hom_map,\n    ←colimit.w (discrete.functor f) (discrete.eq_to_hom' (ε.apply_symm_apply (ε b)))],\nend\n\n@[simp, reassoc]\nlemma sigma.ι_reindex_inv (b : β) : sigma.ι f (ε b) ≫ (sigma.reindex ε f).inv = sigma.ι (f ∘ ε) b :=\nby simp [iso.comp_inv_eq]\n\nend\n\nend reindex\n\nend category_theory.limits\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/shapes/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.4557471065643466}}
{"text": "/-\nCopyright (c) 2022 Jun Yoshida. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n-/\n\nimport Dijkstra.Tactic.Basic\n\nimport Dijkstra.Control.Monad.Hom\nimport Dijkstra.Control.Monad.Rel\nimport Dijkstra.Control.Monad.Dijkstra\nimport Dijkstra.Control.Monad.Spec\n\nuniverse u v v₁ v₂ w w₁ w₂\n\n\n/-!\n\n# Reification of Dijkstra monads\n\nGiven a Dijkstra monad `M : (α : Type u) → W α → Type v` over a monad `W : Type u → Type w`, one sometimes wants to take the value of type `M α w` into computation of a monad `m : Type u → Type v`.\nFor example, suppose that `M := Graph r` is the Dijkstra monad associated with the monadic relation `r : MonadRel m W` on `m` with a specification monad `W`.\nIn this case, a relation between a computation `x : m α` and a \"specification\" `w : W α` can be represented by `X : M α w`.\nSometimes, the specification `X` assures that the computation result of `x` actually lies in the subtype `{a : α // p a}` rather than `α` for some predicate `p : α → Prop`.\nIn other words, `X` enables to pass the result of `x` to the next computation of the form `(a : α) → p a → m β`.\nIn particular, if the next computation is `pure`, one obtains a value of type `m (Subtype p)`, which we would call the ***reification*** of `X`.\n\nThe goal of this module is to develop a formal framework for the above.\n\n-/\n\n\n/-!\n\n## The transformer `SubtypeT`\n\nWe first investigate the type `m (Subtype p)` of the reifications.\nNotice that it is a type construction from a monad `m : Type u → Type v`, a type `α : Type u`, and a prediate `p : α → Prop`.\nSince `p` is also considered as a value of the predicate monad `Pred`, \nFrom this viewpoint, we introduce the following:\n\n```lean\nSubtypeT m (α : Type u) (p : Pred α) ≡ m (Subtype p)\n```\n\nIt turns out that `SubtypeT m` forms a Dijkstra monad over `Pred` provided `m` is a monad.\nHence, we may think of `SubtypeT` as a transformer of a monad into a Dijkstra monad.\n\nFor each monad `m`, the Dijkstra monad `SubtypeT m` comes equipped with the following two fundamental operations:\n\n```lean\ndef pureMk {α: Type u} {p : Pred α} : (a : α) → (h : p a) → SubtypeT m α p :=\n  λ a h => return (Subtype.mk a h)\n\ndef weaken {α :Type u} {p q : Pred α} : MonadRel.rel p q → SubtypeT m α p → SubtypeT m α q :=\n  λ hpq x => x >>= λ a => return ⟨a.val, hpq a.val a.property⟩\n```\n\n-/\n\ndef SubtypeT (m : Type u → Type v) (α : Type u) (p : Pred α) : Type v := m (Subtype p)\n\nnamespace SubtypeT\n\nvariable {m : Type u → Type v} [Monad m]\n\ninstance instDijkstraMonadSubtypeT : DijkstraMonad Pred (SubtypeT m) where\n  dpure a := pure ⟨a,rfl⟩\n  dbind x f := x >>= λ a => f a.val >>= λ b => return ⟨b, ⟨a, a.property, b.property⟩⟩\n\ndef pureMk {α : Type u} {p : Pred α} (a : α) (h : p a) : SubtypeT m α p :=\n  pure ⟨a,h⟩\n\ndef weaken {α : Type u} {p q : Pred α} (hpq : mrel p q) (x : SubtypeT m α p) : SubtypeT m α q :=\n  x >>= λ a => return ⟨a.val, hpq a a.property⟩\n\ntheorem deq_of_iff [LawfulMonad m] {α : Type u} {p q : Pred α} (hpq : ∀ a, p a ↔ q a) : ∀ (x : SubtypeT m α p), DEq (SubtypeT m α) x (x.weaken λ a => (hpq a).mp) := by\n  have : p = q := funext (λ a => propext (hpq a))\n  cases this\n  intro x; apply DEq.deq_of_eq\n  conv =>\n    rhs; dsimp [weaken]; congr\n    . skip\n    . ext a; change pure a\n  rw [bind_pure]\n\ninstance instDijkstraMonadLawfulSubtypeT [LawfulMonad m] : DijkstraMonad.Lawful Pred (SubtypeT m) where\n  dbind_dpure := by\n    intro α p x\n    dsimp [dbind, dpure]\n    conv =>\n      lhs; rhs; ext a; rw [pure_bind]; dsimp [pure]\n    have : ∀ a, (p >>= pure) a ↔ p a := by\n      rw [bind_pure (m:=Pred)]; intros; exact Iff.rfl\n    apply DEq.trans (deq_of_iff (m:=m) (q:=p) this _)\n    apply DEq.deq_of_eq\n    conv =>\n      lhs; dsimp [weaken]; rw [bind_assoc]\n      rhs; ext x; rw [pure_bind]\n    rw [bind_pure (m:=m)]\n  dpure_dbind := by\n    intro α β wf a f\n    dsimp [dbind, dpure]\n    conv => lhs; rw [pure_bind]; dsimp\n    have : ∀ a₁, (pure a >>= wf) a₁ ↔ wf a a₁ := by\n      rw [pure_bind (m:=Pred)]; intros; exact Iff.rfl\n    apply DEq.trans (deq_of_iff (m:=m) this _)\n    apply DEq.deq_of_eq\n    conv =>\n      lhs; dsimp [weaken]; rw [bind_assoc]\n      rhs; ext x; rw [pure_bind]; change pure x\n    rw [bind_pure]\n  dbind_assoc := by\n    intro α β γ wa wf wg x f g\n    have : ∀ c, (wa >>= wf >>= wg) c ↔ (wa >>= λ a => wf a >>= wg) c := by\n      rw [bind_assoc (m:=Pred)]; intros; exact Iff.rfl\n    apply DEq.trans (deq_of_iff this _)\n    apply DEq.deq_of_eq\n    dsimp [weaken, dbind]\n    conv =>\n      lhs; rw [bind_assoc, bind_assoc]\n      rhs; ext x; rw [bind_assoc]\n      rhs; ext y; rw [pure_bind, bind_assoc]\n      rhs; ext z; rw [pure_bind]\n    apply bind_congr\n    intro a\n    conv =>\n      rhs; rw [bind_assoc]\n      rhs; ext b; rw [bind_assoc]\n      rhs; ext x; rw [pure_bind]\n\nend SubtypeT\n\n\n/-!\n\n## Dijkstra lift\n\nAs seen in the previous section, the type `m (Subtype p)` of the result of the reification form a Dijkstra monad over the specification `Pred`.\nThis implies that the reification is a transformation of Dijkstra monads with possibly different underlying monads.\nThis is why we introduce the notion of ***Dijkstra lift***, which is an analogue of `MonadLift`.\n\n-/\n\n/-- Dijkstra lift structure. Notice that the ingredients include `MonadRel W Z` instead of `MonadHom W Z`. -/\nclass DijkstraLift {W : Type u → Type v₁} [Monad W] {Z : Type u → Type v₂} [Monad Z] (r : MonadRel W Z) (M : (α : Type u) → W α → Type w₁) [DijkstraMonad W M] (N : (α : Type u) → Z α → Type w₂) [DijkstraMonad Z N] where\n  dLift {α : Type u} {w : W α} {z : Z α} : r.rel w z → M α w → N α z\n\n/-- Axioms for Dijkstra lifts -/\nclass DijkstraLift.Lawful {W : Type u → Type v₁} [Monad W] {Z : Type u → Type v₂} [Monad Z] (r : MonadRel W Z) (M : (α : Type u) → W α → Type w₁) [DijkstraMonad W M] (N : (α : Type u) → Z α → Type w₂) [DijkstraMonad Z N] [DijkstraLift r M N] where\n  -- Compatibility with `DijkstraMonad.dpure`\n  dLift_dpure {α : Type u} (a : α) : dLift (r.pure a) (dpure (M:=M) a) = dpure (M:=N) a\n  -- Compatibility with `DijkstraMonad.dbind`\n  dLift_dbind {α β : Type u} {wa : W α} {wf : α → W β} {za : Z α} {zf : α → Z β} {ha : r.rel wa za} {hf : ∀ a, r.rel (wf a) (zf a)} (x : M α wa) (f : (a : α) → M β (wf a)) : dLift (r.bind ha hf) (dbind (M:=M) x f) = dbind (M:=N) (dLift ha x) λ a => dLift (hf a) (f a)\n\nexport DijkstraLift.Lawful (dLift_dpure dLift_dbind)\n\n/-- As an example, for every monad `m`, `SubtypeT m` has a canonical lift to itself along the implication relation `Pred.rel p q ≡ ∀ a, p a → q a`. -/\ninstance instDijkstraLiftSubtypeTweaken (m : Type u → Type v) [Monad m] : DijkstraLift Pred.rel (SubtypeT m) (SubtypeT  m) where\n  dLift h x := SubtypeT.weaken h x\n\ninstance instDijkstraLiftLawfulSubtypeTweaken (m : Type u → Type v) [Monad m] [LawfulMonad m] : DijkstraLift.Lawful Pred.rel (SubtypeT m) (SubtypeT m) where\n  dLift_dpure a := by\n    dsimp [DijkstraLift.dLift, SubtypeT.weaken, dpure]\n    rw [pure_bind]\n  dLift_dbind x f := by\n    dsimp [DijkstraLift.dLift, SubtypeT.weaken, dbind]\n    rw [bind_assoc, bind_assoc]\n    apply bind_congr; intro a\n    rw [bind_assoc, pure_bind, bind_assoc]\n    apply bind_congr; intro b\n    rw [pure_bind, pure_bind]\n\n\n/-!\n\n## Reification\n\nWe now define the notion of reification.\nLet `M : (α : Type u) → W α → Type v` be a Dijkstra monad over a (specification) monad `W` equipped with a specification monadic relation `r : SpecMonadRel W Pred`.\nThen, a monad `m : Tye u → Type w` is called a ***reification of `M`*** with respect to `r` if there is a Dijkstra lift `reify : r w p → M α w → SubtypeT m p` which satisfies the follogin conditions.\n\n```lean\nreify_weaken {α : Type u} {p q : Pred α} (hpq : ∀ a, p a → q a): ∀ {wp : WPPure α} {x : M α wp} {h : wp p}, (reify p x h).weaken hpq = reify q x (wp.monotonic h)\n```\n-/\n\n/-- Reification of a Dijkstra monad  -/\nclass Reification {W : Type u → Type w} [Monad W] [SpecMonad W] (r : SpecMonadRel W Pred) (M : (α : Type u) → W α → Type v) [DijkstraMonad W M] (m : Type u → Type v₁) [Monad m] extends DijkstraLift r.toMonadRel M (SubtypeT m)\n\ndef reify {W : Type u → Type w} [Monad W] [SpecMonad W] {r : SpecMonadRel W Pred} {M : (α : Type u) → W α → Type v} [DijkstraMonad W M] {m : Type u → Type v₁} [Monad m] [self : Reification r M m] {α : Type u} {w : W α} (p : Pred α) : r.rel w p → M α w → SubtypeT m α p :=\n  self.dLift\n\n/-- The axioms for reification -/\nclass Reification.Lawful {W : Type u → Type w} [Monad W] [SpecMonad W] (r : SpecMonadRel W Pred) (M : (α : Type u) → W α → Type v) [DijkstraMonad W M] (m : Type u → Type v₁) [Monad m] [Reification r M m] extends DijkstraLift.Lawful r.toMonadRel M (SubtypeT m) where\n  --- `reify` and `weaken`\n  reify_weaken {α : Type u} {wa : W α} {p q : Pred α} (hpq : mrel p q) : ∀ {x : M α wa} {h : r.rel wa p}, (reify (M:=M) (m:=m) p h x).weaken hpq = reify (M:=M) (m:=m) q (r.trans_right h hpq) x\n\nexport Reification.Lawful (reify_weaken)\n\nsection Reification\n\nvariable {W : Type u → Type w} [Monad W] [SpecMonad W] {r : SpecMonadRel W Pred} {M : (α :Type u) → W α → Type v} [DijkstraMonad W M] {m :Type u → Type v₁} [Monad m] [Reification r M m] [DijkstraLift.Lawful r.toMonadRel M (SubtypeT m)] [self : Reification.Lawful r M m]\n\n@[simp]\ntheorem reify_dpure {α : Type u} (a : α) : reify (M:=M) (pure a) (r.pure a) (dpure a) = dpure (M:=SubtypeT m) a :=\n  dLift_dpure a\n\n@[simp]\ntheorem reify_dbind {α β : Type u} {wa : W α} {wf : α → W β} {pa : Pred α} {pf : α → Pred β} {ha : r.rel wa pa} {hf : ∀ a, r.rel (wf a) (pf a)} (x : M α wa) (f : (a : α) → M β (wf a)) : reify (M:=M) (pa >>= pf) (r.bind ha hf) (dbind x f) = dbind (M:=SubtypeT m) (reify (M:=M) pa ha x) (λ a => reify (M:=M) (pf a) (hf a) (f a)) :=\n  dLift_dbind x f\n\nend Reification\n\n\n", "meta": {"author": "Junology", "repo": "dijkstra", "sha": "19ff3ddd7ff112c69848fa9c643f773008cdd5ff", "save_path": "github-repos/lean/Junology-dijkstra", "path": "github-repos/lean/Junology-dijkstra/dijkstra-19ff3ddd7ff112c69848fa9c643f773008cdd5ff/Dijkstra/Control/Monad/Reify.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4554627864253298}}
{"text": "/-\nCopyright (c) 2020 Anatole Dedecker. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anatole Dedecker\n-/\nimport analysis.calculus.mean_value\n\n/-!\n# L'Hôpital's rule for 0/0 indeterminate forms\n\nIn this file, we prove several forms of \"L'Hopital's rule\" for computing 0/0\nindeterminate forms. The proof of `has_deriv_at.lhopital_zero_right_on_Ioo`\nis based on the one given in the corresponding\n[Wikibooks](https://en.wikibooks.org/wiki/Calculus/L%27H%C3%B4pital%27s_Rule)\nchapter, and all other statements are derived from this one by composing by\ncarefully chosen functions.\n\nNote that the filter `f'/g'` tends to isn't required to be one of `𝓝 a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `ℝ`.\n\nEach statement is available in a `has_deriv_at` form and a `deriv` form, which\nis denoted by each statement being in either the `has_deriv_at` or the `deriv`\nnamespace.\n\n## Tags\n\nL'Hôpital's rule, L'Hopital's rule\n-/\n\nopen filter set\nopen_locale filter topological_space pointwise\n\nvariables {a b : ℝ} (hab : a < b) {l : filter ℝ} {f f' g g' : ℝ → ℝ}\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' ≠ 0`) have\nto be satisfied on an explicitly-provided interval.\n-/\n\nnamespace has_deriv_at\n\ninclude hab\n\ntheorem lhopital_zero_right_on_Ioo\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[Ioi a] a) (𝓝 0)) (hga : tendsto g (𝓝[Ioi a] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[Ioi a] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[Ioi a] a) l :=\nbegin\n  have sub : ∀ x ∈ Ioo a b, Ioo a x ⊆ Ioo a b := λ x hx, Ioo_subset_Ioo (le_refl a) (le_of_lt hx.2),\n  have hg : ∀ x ∈ (Ioo a b), g x ≠ 0,\n  { intros x hx h,\n    have : tendsto g (𝓝[Iio x] x) (𝓝 0),\n    { rw [← h, ← nhds_within_Ioo_eq_nhds_within_Iio hx.1],\n      exact ((hgg' x hx).continuous_at.continuous_within_at.mono $ sub x hx).tendsto },\n    obtain ⟨y, hyx, hy⟩ : ∃ c ∈ Ioo a x, g' c = 0,\n      from exists_has_deriv_at_eq_zero' hx.1 hga this (λ y hy, hgg' y $ sub x hx hy),\n    exact hg' y (sub x hx hyx) hy },\n  have : ∀ x ∈ Ioo a b, ∃ c ∈ Ioo a x, (f x) * (g' c) = (g x) * (f' c),\n  { intros x hx,\n    rw [← sub_zero (f x), ← sub_zero (g x)],\n    exact exists_ratio_has_deriv_at_eq_ratio_slope' g g' hx.1 f f'\n      (λ y hy, hgg' y $ sub x hx hy) (λ y hy, hff' y $ sub x hx hy) hga hfa\n      (tendsto_nhds_within_of_tendsto_nhds (hgg' x hx).continuous_at.tendsto)\n      (tendsto_nhds_within_of_tendsto_nhds (hff' x hx).continuous_at.tendsto) },\n  choose! c hc using this,\n  have : ∀ x ∈ Ioo a b, ((λ x', (f' x') / (g' x')) ∘ c) x = f x / g x,\n  { intros x hx,\n    rcases hc x hx with ⟨h₁, h₂⟩,\n    field_simp [hg x hx, hg' (c x) ((sub x hx) h₁)],\n    simp only [h₂],\n    rwa mul_comm },\n  have cmp : ∀ x ∈ Ioo a b, a < c x ∧ c x < x,\n    from λ x hx, (hc x hx).1,\n  rw ← nhds_within_Ioo_eq_nhds_within_Ioi hab,\n  apply tendsto_nhds_within_congr this,\n  simp only,\n  apply hdiv.comp,\n  refine tendsto_nhds_within_of_tendsto_nhds_of_eventually_within _\n    (tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds\n      (tendsto_nhds_within_of_tendsto_nhds tendsto_id) _ _) _,\n  all_goals\n  { apply eventually_nhds_with_of_forall,\n    intros x hx,\n    have := cmp x hx,\n    try {simp},\n    linarith [this] }\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (nhds_within a (Ioi a)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within a (Ioi a)) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [← hfa, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcf a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\n  { rw [← hga, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcg a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\nend\n\ntheorem lhopital_zero_left_on_Ioo\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (𝓝 0)) (hgb : tendsto g (nhds_within b (Iio b)) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  -- Here, we essentially compose by `has_neg.neg`. The following is mostly technical details.\n  have hdnf : ∀ x ∈ -Ioo a b, has_deriv_at (f ∘ has_neg.neg) (f' (-x) * (-1)) x,\n    from λ x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : ∀ x ∈ -Ioo a b, has_deriv_at (g ∘ has_neg.neg) (g' (-x) * (-1)) x,\n    from λ x hx, comp x (hgg' (-x) hx) (has_deriv_at_neg x),\n  rw preimage_neg_Ioo at hdnf,\n  rw preimage_neg_Ioo at hdng,\n  have := lhopital_zero_right_on_Ioo (neg_lt_neg hab) hdnf hdng\n    (by { intros x hx h,\n          apply hg' _ (by {rw ← preimage_neg_Ioo at hx, exact hx}),\n          rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h })\n    (hfb.comp tendsto_neg_nhds_within_Ioi_neg)\n    (hgb.comp tendsto_neg_nhds_within_Ioi_neg)\n    (by { simp only [neg_div_neg_eq, mul_one, mul_neg_eq_neg_mul_symm],\n          exact (tendsto_congr $ λ x, rfl).mp (hdiv.comp tendsto_neg_nhds_within_Ioi_neg) }),\n  have := this.comp tendsto_neg_nhds_within_Iio,\n  unfold function.comp at this,\n  simpa only [neg_neg]\nend\n\ntheorem lhopital_zero_left_on_Ioc\n  (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)\n  (hcf : continuous_on f (Ioc a b)) (hcg : continuous_on g (Ioc a b))\n  (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)\n  (hfb : f b = 0) (hgb : g b = 0)\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  refine lhopital_zero_left_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [← hfb, ← nhds_within_Ioo_eq_nhds_within_Iio hab],\n    exact ((hcf b $ right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto },\n  { rw [← hgb, ← nhds_within_Ioo_eq_nhds_within_Iio hab],\n    exact ((hcg b $ right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto },\nend\n\nomit hab\n\ntheorem lhopital_zero_at_top_on_Ioi\n  (hff' : ∀ x ∈ Ioi a, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Ioi a, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Ioi a, g' x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  obtain ⟨ a', haa', ha'⟩ : ∃ a', a < a' ∧ 0 < a' :=\n    ⟨1 + max a 0, ⟨lt_of_le_of_lt (le_max_left a 0) (lt_one_add _),\n                   lt_of_le_of_lt (le_max_right a 0) (lt_one_add _)⟩⟩,\n  have fact1 : ∀ (x:ℝ), x ∈ Ioo 0 a'⁻¹ → x ≠ 0 := λ _ hx, (ne_of_lt hx.1).symm,\n  have fact2 : ∀ x ∈ Ioo 0 a'⁻¹, a < x⁻¹,\n    from λ _ hx, lt_trans haa' ((lt_inv ha' hx.1).mpr hx.2),\n  have hdnf : ∀ x ∈ Ioo 0 a'⁻¹, has_deriv_at (f ∘ has_inv.inv) (f' (x⁻¹) * (-(x^2)⁻¹)) x,\n    from λ x hx, comp x (hff' (x⁻¹) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have hdng : ∀ x ∈ Ioo 0 a'⁻¹, has_deriv_at (g ∘ has_inv.inv) (g' (x⁻¹) * (-(x^2)⁻¹)) x,\n    from λ x hx, comp x (hgg' (x⁻¹) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have := lhopital_zero_right_on_Ioo (inv_pos.mpr ha') hdnf hdng\n    (by { intros x hx,\n          refine mul_ne_zero _ (neg_ne_zero.mpr $ inv_ne_zero $ pow_ne_zero _ $ fact1 x hx),\n          exact hg' _ (fact2 x hx) })\n    (hftop.comp tendsto_inv_zero_at_top)\n    (hgtop.comp tendsto_inv_zero_at_top)\n    (by { refine (tendsto_congr' _).mp (hdiv.comp tendsto_inv_zero_at_top),\n          rw eventually_eq_iff_exists_mem,\n          use [Ioi 0, self_mem_nhds_within],\n          intros x hx,\n          unfold function.comp,\n          erw mul_div_mul_right,\n          refine neg_ne_zero.mpr (inv_ne_zero $ pow_ne_zero _ $ ne_of_gt hx) }),\n  have := this.comp tendsto_inv_at_top_zero',\n  unfold function.comp at this,\n  simpa only [inv_inv₀],\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hff' : ∀ x ∈ Iio a, has_deriv_at f (f' x) x) (hgg' : ∀ x ∈ Iio a, has_deriv_at g (g' x) x)\n  (hg' : ∀ x ∈ Iio a, g' x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  -- Here, we essentially compose by `has_neg.neg`. The following is mostly technical details.\n  have hdnf : ∀ x ∈ -Iio a, has_deriv_at (f ∘ has_neg.neg) (f' (-x) * (-1)) x,\n    from λ x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : ∀ x ∈ -Iio a, has_deriv_at (g ∘ has_neg.neg) (g' (-x) * (-1)) x,\n    from λ x hx, comp x (hgg' (-x) hx) (has_deriv_at_neg x),\n  rw preimage_neg_Iio at hdnf,\n  rw preimage_neg_Iio at hdng,\n  have := lhopital_zero_at_top_on_Ioi hdnf hdng\n    (by { intros x hx h,\n          apply hg' _ (by {rw ← preimage_neg_Iio at hx, exact hx}),\n          rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h })\n    (hfbot.comp tendsto_neg_at_top_at_bot)\n    (hgbot.comp tendsto_neg_at_top_at_bot)\n    (by { simp only [mul_one, mul_neg_eq_neg_mul_symm, neg_div_neg_eq],\n          exact (tendsto_congr $ λ x, rfl).mp (hdiv.comp tendsto_neg_at_top_at_bot) }),\n  have := this.comp tendsto_neg_at_bot_at_top,\n  unfold function.comp at this,\n  simpa only [neg_neg],\nend\n\nend has_deriv_at\n\nnamespace deriv\n\ninclude hab\n\ntheorem lhopital_zero_right_on_Ioo\n  (hdf : differentiable_on ℝ f (Ioo a b)) (hg' : ∀ x ∈ Ioo a b, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[Ioi a] a) (𝓝 0)) (hga : tendsto g (𝓝[Ioi a] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[Ioi a] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[Ioi a] a) l :=\nbegin\n  have hdf : ∀ x ∈ Ioo a b, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : ∀ x ∈ Ioo a b, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_right_on_Ioo hab (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfa hga hdiv\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hdf : differentiable_on ℝ f (Ioo a b))\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : ∀ x ∈ (Ioo a b), (deriv g) x ≠ 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (nhds_within a (Ioi a)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within a (Ioi a)) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hdf hg' _ _ hdiv,\n  { rw [← hfa, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcf a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\n  { rw [← hga, ← nhds_within_Ioo_eq_nhds_within_Ioi hab],\n    exact ((hcg a $ left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto },\nend\n\ntheorem lhopital_zero_left_on_Ioo\n  (hdf : differentiable_on ℝ f (Ioo a b))\n  (hg' : ∀ x ∈ (Ioo a b), (deriv g) x ≠ 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (𝓝 0)) (hgb : tendsto g (nhds_within b (Iio b)) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (nhds_within b (Iio b)) l) :\n  tendsto (λ x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  have hdf : ∀ x ∈ Ioo a b, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : ∀ x ∈ Ioo a b, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_left_on_Ioo hab (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfb hgb hdiv\nend\n\nomit hab\n\ntheorem lhopital_zero_at_top_on_Ioi\n  (hdf : differentiable_on ℝ f (Ioi a))\n  (hg' : ∀ x ∈ (Ioi a), (deriv g) x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  have hdf : ∀ x ∈ Ioi a, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Ioi_mem_nhds hx),\n  have hdg : ∀ x ∈ Ioi a, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_top_on_Ioi (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hftop hgtop hdiv,\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hdf : differentiable_on ℝ f (Iio a))\n  (hg' : ∀ x ∈ (Iio a), (deriv g) x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdf : ∀ x ∈ Iio a, differentiable_at ℝ f x,\n    from λ x hx, (hdf x hx).differentiable_at (Iio_mem_nhds hx),\n  have hdg : ∀ x ∈ Iio a, differentiable_at ℝ g x,\n    from λ x hx, classical.by_contradiction (λ h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_bot_on_Iio (λ x hx, (hdf x hx).has_deriv_at)\n    (λ x hx, (hdg x hx).has_deriv_at) hg' hfbot hgbot hdiv,\nend\n\nend deriv\n\n/-!\n## Generic versions\n\nThe following statements no longer any explicit interval, as they only require\nconditions holding eventually.\n-/\n\nnamespace has_deriv_at\n\n/-- L'Hôpital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right\n  (hff' : ∀ᶠ x in 𝓝[Ioi a] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[Ioi a] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[Ioi a] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[Ioi a] a) (𝓝 0)) (hga : tendsto g (𝓝[Ioi a] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[Ioi a] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[Ioi a] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ 𝓝[Ioi a] a := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_nhds_within_Ioi_iff_exists_Ioo_subset at hs,\n  rcases hs with ⟨u, hau, hu⟩,\n  refine lhopital_zero_right_on_Ioo hau _ _ _ hfa hga hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hu hx).1.1 <|> exact (hu hx).1.2 <|> exact (hu hx).2\nend\n\n/-- L'Hôpital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left\n  (hff' : ∀ᶠ x in 𝓝[Iio a] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[Iio a] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[Iio a] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[Iio a] a) (𝓝 0)) (hga : tendsto g (𝓝[Iio a] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[Iio a] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[Iio a] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ 𝓝[Iio a] a := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_nhds_within_Iio_iff_exists_Ioo_subset at hs,\n  rcases hs with ⟨l, hal, hl⟩,\n  refine lhopital_zero_left_on_Ioo hal _ _ _ hfa hga hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl hx).1.1 <|> exact (hl hx).1.2 <|> exact (hl hx).2\nend\n\n/-- L'Hôpital's rule for approaching a real, `has_deriv_at` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds'\n  (hff' : ∀ᶠ x in 𝓝[univ \\ {a}] a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝[univ \\ {a}] a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝[univ \\ {a}] a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝[univ \\ {a}] a) (𝓝 0)) (hga : tendsto g (𝓝[univ \\ {a}] a) (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) (𝓝[univ \\ {a}] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a ∪ Ioi a,\n  { ext, rw [mem_diff_singleton, eq_true_intro $ mem_univ x, true_and, ne_iff_lt_or_gt], refl },\n  simp only [this, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact ⟨lhopital_zero_nhds_left hff'.1 hgg'.1 hg'.1 hfa.1 hga.1 hdiv.1,\n          lhopital_zero_nhds_right hff'.2 hgg'.2 hg'.2 hfa.2 hga.2 hdiv.2⟩\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds\n  (hff' : ∀ᶠ x in 𝓝 a, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in 𝓝 a, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in 𝓝 a, g' x ≠ 0)\n  (hfa : tendsto f (𝓝 a) (𝓝 0)) (hga : tendsto g (𝓝 a) (𝓝 0))\n  (hdiv : tendsto (λ x, f' x / g' x) (𝓝 a) l) :\n  tendsto (λ x, f x / g x) (𝓝[univ \\ {a}] a) l :=\nbegin\n  apply @lhopital_zero_nhds' _ _ _ f' _ g';\n  apply eventually_nhds_within_of_eventually_nhds <|> apply tendsto_nhds_within_of_tendsto_nhds;\n  assumption\nend\n\n/-- L'Hôpital's rule for approaching +∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top\n  (hff' : ∀ᶠ x in at_top, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in at_top, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in at_top, g' x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ at_top := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_at_top_sets at hs,\n  rcases hs with ⟨l, hl⟩,\n  have hl' : Ioi l ⊆ s := λ x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_top_on_Ioi _ _ (λ x hx, hg' x $ (hl' hx).2) hftop hgtop hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl' hx).1.1 <|> exact (hl' hx).1.2\nend\n\n/-- L'Hôpital's rule for approaching -∞, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot\n  (hff' : ∀ᶠ x in at_bot, has_deriv_at f (f' x) x)\n  (hgg' : ∀ᶠ x in at_bot, has_deriv_at g (g' x) x)\n  (hg' : ∀ᶠ x in at_bot, g' x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, (f' x) / (g' x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with ⟨s₁, hs₁, hff'⟩,\n  rcases hgg' with ⟨s₂, hs₂, hgg'⟩,\n  rcases hg' with ⟨s₃, hs₃, hg'⟩,\n  let s := s₁ ∩ s₂ ∩ s₃,\n  have hs : s ∈ at_bot := inter_mem (inter_mem hs₁ hs₂) hs₃,\n  rw mem_at_bot_sets at hs,\n  rcases hs with ⟨l, hl⟩,\n  have hl' : Iio l ⊆ s := λ x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_bot_on_Iio _ _ (λ x hx, hg' x $ (hl' hx).2) hfbot hgbot hdiv;\n  intros x hx;\n  apply_assumption;\n  exact (hl' hx).1.1 <|> exact (hl' hx).1.2\nend\n\nend has_deriv_at\n\nnamespace deriv\n\n/-- **L'Hôpital's rule** for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right\n  (hdf : ∀ᶠ x in 𝓝[Ioi a] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[Ioi a] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[Ioi a] a) (𝓝 0)) (hga : tendsto g (𝓝[Ioi a] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[Ioi a] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[Ioi a] a) l :=\nbegin\n  have hdg : ∀ᶠ x in 𝓝[Ioi a] a, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in 𝓝[Ioi a] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in 𝓝[Ioi a] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_nhds_right hdf' hdg' hg' hfa hga hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left\n  (hdf : ∀ᶠ x in 𝓝[Iio a] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[Iio a] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[Iio a] a) (𝓝 0)) (hga : tendsto g (𝓝[Iio a] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[Iio a] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[Iio a] a) l :=\nbegin\n  have hdg : ∀ᶠ x in 𝓝[Iio a] a, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in 𝓝[Iio a] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in 𝓝[Iio a] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_nhds_left hdf' hdg' hg' hfa hga hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `deriv` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds'\n  (hdf : ∀ᶠ x in 𝓝[univ \\ {a}] a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝[univ \\ {a}] a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝[univ \\ {a}] a) (𝓝 0)) (hga : tendsto g (𝓝[univ \\ {a}] a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝[univ \\ {a}] a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a ∪ Ioi a,\n  { ext, rw [mem_diff_singleton, eq_true_intro $ mem_univ x, true_and, ne_iff_lt_or_gt], refl },\n  simp only [this, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact ⟨lhopital_zero_nhds_left hdf.1 hg'.1 hfa.1 hga.1 hdiv.1,\n          lhopital_zero_nhds_right hdf.2 hg'.2 hfa.2 hga.2 hdiv.2⟩,\nend\n\n/-- **L'Hôpital's rule** for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds\n  (hdf : ∀ᶠ x in 𝓝 a, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ x in 𝓝 a, deriv g x ≠ 0)\n  (hfa : tendsto f (𝓝 a) (𝓝 0)) (hga : tendsto g (𝓝 a) (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) (𝓝 a) l) :\n  tendsto (λ x, (f x) / (g x)) (𝓝[univ \\ {a}] a) l :=\nbegin\n  apply lhopital_zero_nhds';\n  apply eventually_nhds_within_of_eventually_nhds <|> apply tendsto_nhds_within_of_tendsto_nhds;\n  assumption\nend\n\n/-- **L'Hôpital's rule** for approaching +∞, `deriv` version -/\ntheorem lhopital_zero_at_top\n  (hdf : ∀ᶠ (x : ℝ) in at_top, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ (x : ℝ) in at_top, deriv g x ≠ 0)\n  (hftop : tendsto f at_top (𝓝 0)) (hgtop : tendsto g at_top (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (λ x, (f x) / (g x)) at_top l :=\nbegin\n  have hdg : ∀ᶠ x in at_top, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in at_top, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in at_top, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_at_top hdf' hdg' hg' hftop hgtop hdiv\nend\n\n/-- **L'Hôpital's rule** for approaching -∞, `deriv` version -/\ntheorem lhopital_zero_at_bot\n  (hdf : ∀ᶠ (x : ℝ) in at_bot, differentiable_at ℝ f x)\n  (hg' : ∀ᶠ (x : ℝ) in at_bot, deriv g x ≠ 0)\n  (hfbot : tendsto f at_bot (𝓝 0)) (hgbot : tendsto g at_bot (𝓝 0))\n  (hdiv : tendsto (λ x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (λ x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdg : ∀ᶠ x in at_bot, differentiable_at ℝ g x,\n    from hg'.mp (eventually_of_forall $\n      λ _ hg', classical.by_contradiction (λ h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : ∀ᶠ x in at_bot, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  have hdg' : ∀ᶠ x in at_bot, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ λ _, differentiable_at.has_deriv_at),\n  exact has_deriv_at.lhopital_zero_at_bot hdf' hdg' hg' hfbot hgbot hdiv\nend\n\nend deriv\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/calculus/lhopital.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4554627769604173}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Bhavik Mehta\n-/\nimport analysis.specific_limits\nimport combinatorics.simplicial_complex.basic\nimport set_theory.fincard\n\nopen affine set\n\nvariables {m : ℕ} {E : Type*} [normed_group E] [normed_space ℝ E]\n  {S₁ S₂ : simplicial_complex E}\n\n/--\nS₁ ≤ S₂ (S₁ is a subdivision of S₂) iff their underlying space is the same and each face of S₁ is\ncontained in some face of S₂\n-/\ninstance : has_le (simplicial_complex E) := ⟨λ S₁ S₂, S₁.space = S₂.space ∧\n  ∀ {X₁ : finset  E}, X₁ ∈ S₁.faces → ∃ X₂ ∈ S₂.faces,\n  convex_hull (X₁ : set E) ⊆ convex_hull (X₂ : set E)⟩\n\nlemma subdivision_iff_combi_interiors_subset_combi_interiors :\n  S₁ ≤ S₂ ↔ S₂.space ⊆ S₁.space ∧\n  ∀ {X₁}, X₁ ∈ S₁.faces → ∃ {X₂}, X₂ ∈ S₂.faces ∧ combi_interior X₁ ⊆ combi_interior X₂ :=\nbegin\n  split,\n  { rintro ⟨hspace, hS⟩,\n    use ge_of_eq hspace,\n    rintro X hX,\n    obtain ⟨Y, hY, hXY⟩ := hS hX,\n    obtain ⟨Z, hZY, hXZ⟩ := simplex_combi_interiors_split_interiors (S₂.indep hY) hXY,\n    exact ⟨Z, S₂.down_closed hY hZY, hXZ⟩ },\n  { rintro ⟨hspace, hS⟩,\n    split,\n    { apply subset.antisymm _ hspace,\n      rintro x hx,\n      obtain ⟨X₁, hX₁, hx⟩ := mem_space_iff.1 hx,\n      obtain ⟨X₂, hX₂, hX₁X₂⟩ := hS hX₁,\n      rw mem_space_iff,\n      refine ⟨X₂, hX₂, _⟩,\n      apply convex_hull_subset_convex_hull_of_combi_interior_subset_combi_interior _ _ hX₁X₂ hx,\n      { apply S₁.indep hX₁ },\n      { apply S₂.indep hX₂ } },\n    { rintro X₁ hX₁,\n      obtain ⟨X₂, hX₂, hX₁X₂⟩ := hS hX₁,\n      refine ⟨_, hX₂, convex_hull_subset_convex_hull_of_combi_interior_subset_combi_interior _ _ _⟩,\n      { apply S₁.indep hX₁ },\n      { apply S₂.indep hX₂ },\n      { apply hX₁X₂ }}}\nend\n\nlemma subdivision_iff_partition :\n  S₁ ≤ S₂ ↔ (S₁.faces.nonempty → S₂.faces.nonempty) ∧ S₁.space ⊆ S₂.space ∧ ∀ {X₂}, X₂ ∈ S₂.faces →\n  ∃ {F}, F ⊆ S₁.faces ∧ combi_interior X₂ = ⋃ (X₁ ∈ F), combi_interior X₁ :=\nbegin\n  split,\n  { rintro ⟨hspace, hsubdiv⟩,\n    split,\n    { rintro ⟨X₁, hX₁⟩,\n      obtain ⟨X₂, hX₂, hX₁X₂⟩ := hsubdiv hX₁,\n      exact ⟨X₂, hX₂⟩ },\n    use le_of_eq hspace,\n    rintro X hX,\n    use [{Y | Y ∈ S₁.faces ∧ combi_interior Y ⊆ combi_interior X}, (λ Y hY, hY.1)],\n    ext x,\n    split,\n    { rintro hxX,\n      have hxspace := mem_space_iff.2 ⟨X, hX, hxX.1⟩,\n      rw [←hspace, combi_interiors_cover, mem_bUnion_iff] at hxspace,\n      obtain ⟨Y, hY, hxY⟩ := hxspace,\n      apply mem_bUnion _ hxY,\n      use hY,\n      rintro y hyY,\n      obtain ⟨Z, hZ, hYZ⟩ := hsubdiv hY,\n      obtain ⟨W, hWZ, hYW⟩ := simplex_combi_interiors_split_interiors (S₂.indep hZ) hYZ,\n      rw disjoint_interiors hX (S₂.down_closed hZ hWZ) hxX (hYW hxY),\n      exact hYW hyY },\n    { rw mem_bUnion_iff,\n      rintro ⟨Y, ⟨hY, hYX⟩, hxY⟩,\n      exact hYX hxY }},\n  { rintro ⟨hempty, hspace, hpartition⟩,\n    have hspace : S₁.space = S₂.space,\n    { apply subset.antisymm hspace,\n      rintro x hx,\n      rw [combi_interiors_cover, mem_bUnion_iff] at ⊢ hx,\n      obtain ⟨X, hX, hxX⟩ := hx,\n      obtain ⟨F, hF, hXint⟩ := hpartition hX,\n      rw [hXint, mem_bUnion_iff] at hxX,\n      obtain ⟨Y, hY, hxY⟩ := hxX,\n      exact ⟨Y, hF hY, hxY⟩ },\n    use hspace,\n    rintro X hX,\n    cases finset.eq_empty_or_nonempty X with hXempty hXnonempty,\n    { obtain ⟨Y, hY⟩ := hempty ⟨X, hX⟩,\n      use [Y, hY],\n      rw hXempty,\n      simp },\n    obtain ⟨x, hx⟩ := nonempty_combi_interior_of_nonempty (S₁.indep hX) hXnonempty,\n    have hxspace := mem_space_iff.2 ⟨X, hX, hx.1⟩,\n    rw [hspace, combi_interiors_cover, mem_bUnion_iff] at hxspace,\n    obtain ⟨Y, hY, hxY⟩ := hxspace,\n    use [Y, hY],\n    rw ←closure_combi_interior_eq_convex_hull (S₁.indep hX),\n    apply closure_minimal _ is_closed_convex_hull,\n    rintro x' hx',\n    have hxspace := mem_space_iff.2 ⟨X, hX, hx'.1⟩,\n    rw [hspace, combi_interiors_cover, mem_bUnion_iff] at hxspace,\n    obtain ⟨Y', hY', hxY'⟩ := hxspace,\n    suffices hYY' : Y = Y',\n    { rw hYY',\n      exact hxY'.1 },\n    obtain ⟨F, hF, hinterior⟩ := hpartition hY,\n    obtain ⟨F', hF', hinterior'⟩ := hpartition hY',\n    apply disjoint_interiors hY hY' (_ : x ∈ _) _,\n    { rw [hinterior, mem_bUnion_iff] at ⊢ hxY,\n      obtain ⟨Z, hZ, hxZ⟩ := hxY,\n      use [Z, hZ, hxZ] },\n    { rw [hinterior', mem_bUnion_iff] at ⊢ hxY',\n      obtain ⟨Z, hZ, hxZ⟩ := hxY',\n      use [Z, hZ],\n      rw ←disjoint_interiors hX (hF' hZ) hx' hxZ,\n      exact hx }}\nend\n\ninstance : partial_order (simplicial_complex E) :=\n{ le := λ S₁ S₂, S₁ ≤ S₂,\n  le_refl := (λ S, ⟨rfl, (λ X hX, ⟨X, hX, subset.refl _⟩)⟩),\n  le_trans := begin\n    rintro S₁ S₂ S₃ h₁₂ h₂₃,\n    use eq.trans h₁₂.1 h₂₃.1,\n    rintro X₁ hX₁,\n    obtain ⟨X₂, hX₂, hX₁₂⟩ := h₁₂.2 hX₁,\n    obtain ⟨X₃, hX₃, hX₂₃⟩ := h₂₃.2 hX₂,\n    exact ⟨X₃, hX₃, subset.trans hX₁₂ hX₂₃⟩,\n  end,\n  le_antisymm := begin\n    suffices aux_lemma : ∀ {S₁ S₂ : simplicial_complex E}, S₁ ≤ S₂ → S₂ ≤ S₁ → ∀ {X},\n      X ∈ S₁.faces → X ∈ S₂.faces,\n    { rintro S₁ S₂ h₁ h₂,\n      ext X,\n      exact ⟨λ hX, aux_lemma h₁ h₂ hX, λ hX, aux_lemma h₂ h₁ hX⟩ },\n    rintro S₁ S₂ h₁ h₂ X hX,\n    rw subdivision_iff_partition at h₂ h₁,\n    cases finset.eq_empty_or_nonempty X with hXempty hXnonempty,\n    { rw hXempty,\n      exact empty_mem_faces_of_nonempty (h₁.1 ⟨X, hX⟩) },\n    obtain ⟨x, hxX⟩ := nonempty_combi_interior_of_nonempty (S₁.indep hX) hXnonempty,\n    obtain ⟨F, hF, hFX⟩ := h₂.2.2 hX,\n    have hxX' := hxX,\n    rw [hFX, mem_bUnion_iff] at hxX',\n    obtain ⟨Y, hY, hxY⟩ := hxX',\n    obtain ⟨F', hF', hF'Y⟩ := h₁.2.2 (hF hY),\n    rw [hF'Y, mem_bUnion_iff] at hxY,\n    obtain ⟨Z, hZ, hxZ⟩ := hxY,\n    have := disjoint_interiors hX (hF' hZ) hxX hxZ,\n    subst this,\n    suffices h : X = Y,\n    { rw h,\n      exact hF hY },\n    apply combi_interior.inj (S₁.indep hX) (S₂.indep (hF hY)) (subset.antisymm _ _),\n    { rw hF'Y,\n      exact subset_bUnion_of_mem hZ },\n    { rw hFX,\n      exact subset_bUnion_of_mem hY }\n  end }\n\n/-def simplicial_complex.mesh_size (S : simplicial_complex E) : ℝ := sorry --max diameter of simplices\n\ndef barycentrisation : list (fin m → ℝ) → fin m → ℝ :=\n  λ L,\n\ndef simplicial_complex.barycentric_subdivision (S : simplicial_complex E) : simplicial_complex E :=\n{ faces := {X | ∃ {L : list (fin m → ℝ)}, list.to_finset L ∈ S.faces ∧ X = },\n  indep := _,\n  down_closed := _,\n  disjoint := _ }-/\n", "meta": {"author": "mmasdeu", "repo": "brouwerfixedpoint", "sha": "548270f79ecf12d7e20a256806ccb9fcf57b87e2", "save_path": "github-repos/lean/mmasdeu-brouwerfixedpoint", "path": "github-repos/lean/mmasdeu-brouwerfixedpoint/brouwerfixedpoint-548270f79ecf12d7e20a256806ccb9fcf57b87e2/src/combinatorics/simplicial_complex/subdivision.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660542, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.4554627728781425}}
{"text": "/- -----------------------------------------------------------------------\nCategories.\n----------------------------------------------------------------------- -/\n\nimport .s1_categories\n\nnamespace qp\n\nopen stdaux\n\nuniverse variables ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓobj ℓhom ℓobj₁ ℓhom₁ ℓobj₂ ℓhom₂ ℓobj₃ ℓhom₃ ℓobj₄ ℓhom₄ ℓobj₅ ℓhom₅\n\n/-! #brief A functor between categories.\n-/\nstructure Fun (C : Cat.{ℓobj₁ ℓhom₁}) (D : Cat.{ℓobj₂ ℓhom₂})\n    : Type (max ℓobj₁ ℓhom₁ ℓobj₂ ℓhom₂)\n:= (obj : C^.obj → D^.obj)\n   (hom : ∀ {x y : C^.obj}, C^.hom x y → D^.hom (obj x) (obj y))\n   (hom_id : ∀ {x : C^.obj}, hom ⟨⟨x⟩⟩ = ⟨⟨obj x⟩⟩)\n   (hom_circ : ∀ {x y z : C^.obj}\n                 {g : C^.hom y z} {f : C^.hom x y}\n               , hom (g ∘∘ f) = hom g ∘∘ hom f)\n\nattribute [simp] Fun.hom_id\n\n-- A functor between categories.\n-- \\rightrightarrows\nnotation C `⇉` D := Fun C D\n\n/-! #brief Helper for proving two functors are equal.\n-/\ntheorem Fun.eq {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    : ∀ {F G : Fun C D}\n        (ωobj : ∀ (x : C^.obj), F^.obj x = G^.obj x)\n        (ωhom : ∀ (ω : ∀ (x : C^.obj), F^.obj x = G^.obj x)\n                  {x y : C^.obj} (f : C^.hom x y)\n                , F^.hom f == G^.hom f)\n      , F = G\n| (Fun.mk Fobj Fhom Fhom_id Fhom_circ)\n  (Fun.mk Gobj Ghom Ghom_id Ghom_circ)\n  ωobj ωhom\n:= begin\n     assert ωobj' : Fobj = Gobj, { exact funext ωobj },\n     subst ωobj',\n     assert ωhom' : @Fhom = @Ghom,\n     { apply funext, intro x,\n       apply funext, intro y,\n       apply funext, intro f,\n       apply eq_of_heq,\n       apply ωhom ωobj\n     },\n     subst ωhom'\n   end\n\n/-! #brief Helper for proving two functors are heterogeneously equal.\n-/\ntheorem Fun.heq\n    : ∀ {C₁ : Cat.{ℓobj₁ ℓhom₁}} {D₁ : Cat.{ℓobj₂ ℓhom₂}} {F₁ : Fun C₁ D₁}\n        {C₂ : Cat.{ℓobj₁ ℓhom₁}} {D₂ : Cat.{ℓobj₂ ℓhom₂}} {F₂ : Fun C₂ D₂}\n        (ωC : C₁ = C₂) (ωD : D₁ = D₂)\n        (ωobj : ∀ (x₁ : C₁^.obj) (x₂ : C₂^.obj)\n                , x₁ == x₂ → F₁^.obj x₁ == F₂^.obj x₂)\n        (ωhom : ∀ (x₁ y₁ : C₁^.obj) (x₂ y₂ : C₂^.obj)\n                  (f₁ : C₁^.hom x₁ y₁) (f₂ : C₂^.hom x₂ y₂)\n                , f₁ == f₂ → (F₁^.hom f₁) == (F₂^.hom f₂))\n      , F₁ == F₂\n| C D F₁ .(C) .(D) F₂ (eq.refl .(C)) (eq.refl .(D)) ωobj ωhom\n:= begin\n     apply heq_of_eq,\n     apply Fun.eq,\n     { intro x,\n       apply eq_of_heq,\n       apply ωobj,\n       apply heq.refl\n     },\n     { intros ωobj x y f,\n       apply ωhom,\n       apply heq.refl\n     }\n   end\n\n/-! #brief Congruence on objects.\n-/\ntheorem Fun.congr_obj {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    : ∀ {x y : C^.obj}\n        (ω : x = y)\n      , F^.obj x = F^.obj y\n| x .(x) (eq.refl .(x)) := rfl\n\n/-! #brief Congruence on homs.\n-/\ntheorem Fun.congr_hom {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    : ∀ {x y : C^.obj} {f₁ f₂ : C^.hom x y}\n        (ω : f₁ = f₂)\n      , F^.hom f₁ = F^.hom f₂\n| x y f .(f) (eq.refl .(f)) := rfl\n\n/-! #brief Action of a functor on a cast_hom.\n-/\ntheorem Fun.cast_hom {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    : ∀ {x y : C^.obj}\n        {ω : x = y}\n      , F^.hom (cast_hom ω) = cast_hom begin rw ω end\n| x .(x) (eq.refl .(x)) := F^.hom_id\n\n\n\n/- -----------------------------------------------------------------------\nFunctors are morphisms of categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief The identity functor.\n-/\ndefinition Fun.id (C : Cat.{ℓobj ℓhom}) : Fun C C\n:= { obj := λ x, x\n   , hom := λ x y f, f\n   , hom_id := λ x, rfl\n   , hom_circ := λ x y z g f, rfl\n   }\n\n@[simp] theorem Fun.id.simp_obj {C : Cat.{ℓobj ℓhom}}\n    (c : C^.obj)\n    : (Fun.id C)^.obj c = c\n:= rfl\n\n@[simp] theorem Fun.id.simp_hom {C : Cat.{ℓobj ℓhom}}\n    {c₁ c₂ : C^.obj} (f : C^.hom c₁ c₂)\n    : (Fun.id C)^.hom f = f\n:= rfl\n\n/-! #brief Composition of functors.\n-/\ndefinition Fun.comp {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (G : Fun C D) (F : Fun B C)\n    : Fun B D\n:= { obj := λ x, G^.obj (F^.obj x)\n   , hom := λ x y f, G^.hom (F^.hom f)\n   , hom_id := λ x, begin dsimp, simp end\n   , hom_circ := λ x y z g f, begin dsimp, simp [Fun.hom_circ] end\n   }\n\n-- Composition of functors.\n-- \\Box\\Box\ninfixl ` □□ ` : 150 := Fun.comp\n\n@[simp] theorem Fun.comp.simp_obj {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (G : Fun C D) (F : Fun B C) (x : B^.obj)\n    : (Fun.comp G F)^.obj x = G^.obj (F^.obj x)\n:= rfl\n\n@[simp] theorem Fun.comp.simp_hom {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (G : Fun C D) (F : Fun B C) {x₁ x₂ : B^.obj} (f : B^.hom x₁ x₂)\n    : (Fun.comp G F)^.hom f = G^.hom (F^.hom f)\n:= rfl\n\n/-! #brief Composition of functors is associative.\n-/\ntheorem Fun.comp_assoc {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}} {E : Cat.{ℓobj₄ ℓhom₄}}\n    {H : Fun D E} {G : Fun C D} {F : Fun B C}\n    : Fun.comp H (Fun.comp G F) = Fun.comp (Fun.comp H G) F\n:= begin\n     apply Fun.eq,\n     { intro b, repeat {rw [Fun.comp.simp_obj]} },\n     { intros ωobj x y f, repeat {rw [Fun.comp.simp_hom]}, apply heq.refl }\n   end\n\n/-! #brief The identity functor is a left-identity for composition.\n-/\n@[simp] theorem Fun.comp_id_left {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    : Fun.comp (Fun.id D) F = F\n:= begin\n     apply Fun.eq,\n     { intro x, rw [Fun.comp.simp_obj, Fun.id.simp_obj] },\n     { intros ωobj x y f, rw [Fun.comp.simp_hom, Fun.id.simp_hom], apply heq.refl }\n   end\n\n/-! #brief The identity functor is a right-identity for composition.\n-/\n@[simp] theorem Fun.comp_id_right {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    : Fun.comp F (Fun.id C) = F\n:= begin\n     apply Fun.eq,\n     { intro x, rw [Fun.comp.simp_obj, Fun.id.simp_obj] },\n     { intros ωobj x y f, rw [Fun.comp.simp_hom, Fun.id.simp_hom], apply heq.refl }\n   end\n\n/-! #brief Iterated composition of endofunctors.\n-/\ndefinition Fun.iter_comp {C : Cat.{ℓobj₁ ℓhom₁}}\n    (F : Fun C C)\n    : ℕ → Fun C C\n| 0 := Fun.id C\n| (nat.succ n) := Fun.comp F (Fun.iter_comp n)\n\n/-! #brief Fun.iter_comp absorbs on the left.\n-/\ndefinition Fun.iter_comp_fold_left {C : Cat.{ℓobj₁ ℓhom₁}}\n    {F : Fun C C}\n    {n : ℕ}\n    : Fun.comp F (Fun.iter_comp F n)\n       = Fun.iter_comp F (nat.succ n)\n:= rfl\n\n/-! #brief Fun.iter_comp absorbs on the right.\n-/\ndefinition Fun.iter_comp_fold_right {C : Cat.{ℓobj₁ ℓhom₁}}\n    {F : Fun C C}\n    : ∀ {n : ℕ}\n      , Fun.comp (Fun.iter_comp F n) F\n         = Fun.iter_comp F (nat.succ n)\n| 0 := rfl\n| (nat.succ n)\n:= begin\n     dsimp [Fun.iter_comp],\n     rw -Fun.comp_assoc,\n     rw Fun.iter_comp_fold_right,\n     trivial\n   end\n\n/-! #brief Iterated composition of endofunctors.\n-/\ndefinition Fun.iter_comp' {C : Cat.{ℓobj₁ ℓhom₁}}\n    (F : Fun C C)\n    : ℕ → Fun C C\n| 0 := Fun.id C\n| (nat.succ n) := Fun.comp (Fun.iter_comp' n) F\n\n/-! @brief Fun.iter_comp and Fun.iter_comp' are equal.\n-/\ntheorem Fun.iter_comp_assoc {C : Cat.{ℓobj₁ ℓhom₁}}\n    {F : Fun C C}\n    : ∀ {n : ℕ}\n      , Fun.iter_comp F n = Fun.iter_comp' F n\n| 0 := rfl\n| (nat.succ n)\n:= begin\n     dsimp [Fun.iter_comp, Fun.iter_comp'],\n     rw [-Fun.iter_comp_assoc, Fun.iter_comp_fold_left, Fun.iter_comp_fold_right]\n   end\n\n/-! #brief Fun.iter_comp absorbs on the left.\n-/\ndefinition Fun.iter_comp'_fold_left {C : Cat.{ℓobj₁ ℓhom₁}}\n    {F : Fun C C}\n    {n : ℕ}\n    : Fun.comp F (Fun.iter_comp' F n)\n       = Fun.iter_comp' F (nat.succ n)\n:= begin\n     repeat { rw -Fun.iter_comp_assoc },\n     exact Fun.iter_comp_fold_left\n   end\n\n/-! #brief Fun.iter_comp absorbs on the right.\n-/\ndefinition Fun.iter_comp'_fold_right {C : Cat.{ℓobj₁ ℓhom₁}}\n    {F : Fun C C}\n    {n : ℕ}\n    : Fun.comp (Fun.iter_comp' F n) F\n       = Fun.iter_comp' F (nat.succ n)\n:= begin\n     repeat { rw -Fun.iter_comp_assoc },\n     exact Fun.iter_comp_fold_right\n   end\n\n\n\n/- -----------------------------------------------------------------------\nConstant functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief A constant functor.\n-/\ndefinition ConstFun (C : Cat.{ℓobj₁ ℓhom₁}) {D : Cat.{ℓobj₂ ℓhom₂}}\n    (d : D^.obj)\n    : Fun C D\n:= { obj := λ c, d\n   , hom := λ c₁ c₂ f, D^.id d\n   , hom_id := λ c, rfl\n   , hom_circ := λ c₁ c₂ c₃ g f, eq.symm D^.circ_id_right\n   }\n\n\n\n/- -----------------------------------------------------------------------\nThe initial and final functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief The final functor.\n-/\ndefinition FinalFun (C : Cat.{ℓobj₂ ℓhom₂})\n    : Fun C UnitCat.{ℓobj₁ ℓhom₁}\n:= { obj := λ c, punit.star\n   , hom := λ c₁ c₂ f, punit.star\n   , hom_id := λ c, rfl\n   , hom_circ := λ c₁ c₂ c₃ g f, rfl\n   }\n\n/-! #brief The final functor is unique.\n-/\ntheorem FinalFun.uniq {C : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C UnitCat.{ℓobj₁ ℓhom₁}}\n    : F = FinalFun.{ℓobj₁ ℓhom₁} C\n:= Fun.eq\n    (λ c, begin cases F^.obj c, trivial end)\n    (λ ω c₁ c₂ f, begin cases F^.hom f, trivial end)\n\n/-! #brief The initial functor.\n-/\ndefinition InitFun (C : Cat.{ℓobj₂ ℓhom₂})\n    : Fun EmptyCat.{ℓobj₁ ℓhom₁} C\n:= { obj := λ e, by cases e\n   , hom := λ e₁ e₂ f, by cases f\n   , hom_id := λ e, by cases e\n   , hom_circ := λ e₁ e₂ e₃ g f, by cases f\n   }\n\n/-! #brief The initial functor is unique.\n-/\ntheorem InitFun.uniq {C : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun EmptyCat.{ℓobj₁ ℓhom₁} C}\n    : F = InitFun.{ℓobj₁ ℓhom₁} C\n:= Fun.eq\n    (λ c, by cases c)\n    (λ ω c₁ c₂ f, by cases f)\n\n\n\n/- -----------------------------------------------------------------------\nFunctors and isomorphisms.\n----------------------------------------------------------------------- -/\n\n/-! #brief Functors preserve isomorphisms.\n-/\ntheorem Fun.preserves_Iso {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    {c₁ c₂ : C^.obj}\n    {f₁₂ : C^.hom c₁ c₂} {f₂₁ : C^.hom c₂ c₁}\n    (iso : Iso f₁₂ f₂₁)\n    : Iso (F^.hom f₁₂) (F^.hom f₂₁)\n:= { id₁ := by calc F^.hom f₂₁ ∘∘ F^.hom f₁₂\n                        = F^.hom (f₂₁ ∘∘ f₁₂) : by rw F^.hom_circ\n                    ... = F^.hom (C^.id c₁)   : by rw iso^.id₁\n                    ... = ⟨⟨F^.obj c₁⟩⟩       : by rw F^.hom_id\n   , id₂ := by calc F^.hom f₁₂ ∘∘ F^.hom f₂₁\n                        = F^.hom (f₁₂ ∘∘ f₂₁) : by rw F^.hom_circ\n                    ... = F^.hom (C^.id c₂)   : by rw iso^.id₂\n                    ... = ⟨⟨F^.obj c₂⟩⟩       : by rw F^.hom_id\n   }\n\n\n\n/- -----------------------------------------------------------------------\nThe category of categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief A category of categories.\n-/\ndefinition CatOfCats\n    : Cat.{((max ℓobj ℓhom) + 1) ((max ℓobj ℓhom) + 1)}\n:= { obj := Cat.{ℓobj ℓhom}\n   , hom := Fun\n   , id := Fun.id\n   , circ := @Fun.comp\n   , circ_assoc := @Fun.comp_assoc\n   , circ_id_left := @Fun.comp_id_left\n   , circ_id_right := @Fun.comp_id_right\n   }\n\n/-! #brief The Lean object functor.\n-/\ndefinition CatOfCats.ObjFun\n    : Fun CatOfCats.{ℓobj ℓhom} LeanCat.{ℓobj}\n:= { obj := λ C, C^.obj\n   , hom := λ C₁ C₂ F, F^.obj\n   , hom_id := λ C, rfl\n   , hom_circ := λ C₁ C₂ C₃ g f, rfl\n   }\n\n/-! #brief A general hom in a category.\n-/\nstructure Cat.GeneralHom (C : Cat.{ℓobj₁ ℓhom₁})\n    : Type (max ℓobj₁ ℓhom₁)\n:= (dom : C^.obj)\n   (codom : C^.obj)\n   (hom : C^.hom dom codom)\n\n/-! #brief The Lean hom functor.\n-/\ndefinition CatOfCats.HomFun\n    : Fun CatOfCats.{ℓobj ℓhom} LeanCat.{max ℓobj ℓhom}\n:= { obj := Cat.GeneralHom\n   , hom\n      := λ C₁ C₂ F h\n         , { dom := F^.obj h^.dom\n           , codom := F^.obj h^.codom\n           , hom := F^.hom h^.hom\n           }\n   , hom_id := λ C, begin apply funext, intro x, cases x, trivial end\n   , hom_circ := λ C₁ C₂ C₃ g f, begin apply funext, intro x, cases x, trivial end\n   }\n\n\n\n/- -----------------------------------------------------------------------\nThe Lean universe-level functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief Lift the universe level to the max.\n-/\ninductive Lean.LevelMax (A : Type.{ℓ₁}) : Type (max ℓ₁ ℓ₂)\n| lift : A → Lean.LevelMax\n\ndefinition Lean.LevelMax.unlift {A : Type.{ℓ₁}}\n    : Lean.LevelMax.{ℓ₁ ℓ₂} A → A\n| (Lean.LevelMax.lift a) := a\n\n-- /-! #brief Lean.LevelMax.lift is injective.\n-- -/\n-- theorem Lean.LevelMax.lift.inj {A : Type.{ℓ₁}}\n--     : ∀ {a₁ a₂ : A}\n--         (ω : Lean.LevelMax.lift.{ℓ₁ ℓ₂} a₁ = Lean.LevelMax.lift.{ℓ₁ ℓ₂} a₂)\n--       , a₁ = a₂\n-- | a .(a) (eq.refl .(Lean.LevelMax.lift.{ℓ₁ ℓ₂} a)) := rfl\n\n/-! #brief Apply a function to a Lean.Level1.\n-/\ndefinition Lean.LevelMax.map {A : Type.{ℓ₁}} {B : Type.{ℓ₂}}\n    (f : A → B)\n    : Lean.LevelMax.{ℓ₁ ℓ₃} A → Lean.LevelMax.{ℓ₂ ℓ₄} B\n| (Lean.LevelMax.lift a) := Lean.LevelMax.lift (f a)\n\n/-! #brief Increasing the universe level to the max.\n-/\ndefinition LeanCat.LevelMax\n    : Fun LeanCat.{ℓ₁} LeanCat.{max ℓ₁ ℓ₂}\n:= { obj := Lean.LevelMax\n   , hom := @Lean.LevelMax.map\n   , hom_id := λ X, begin apply funext, intro x, cases x, trivial end\n   , hom_circ := λ X Y Z g f, begin apply funext, intro x, cases x, trivial end\n   }\n\n/-! #brief Lift the universe level of a type by 1.\n-/\n@[reducible] definition Lean.Level1 (A : Type.{ℓ₁}) : Type (ℓ₁ + 1)\n:= Lean.LevelMax.{ℓ₁ (ℓ₁ + 1)} A\n\n/-! #brief Apply a function to a Lean.Level1.\n-/\ndefinition Lean.Level1.map {A : Type.{ℓ₁}} {B : Type.{ℓ₂}}\n    (f : A → B)\n    : Lean.Level1 A → Lean.Level1 B\n:= Lean.LevelMax.map f\n\n/-! #brief Increasing the universe level by 1.\n-/\ndefinition LeanCat.Level1\n    : Fun LeanCat.{ℓ₁} LeanCat.{ℓ₁ + 1}\n:= LeanCat.LevelMax.{ℓ₁ (ℓ₁ + 1)}\n\n/- -----------------------------------------------------------------------\nBijections of categories and conjugate functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief A bijection of categories.\n-/\nstructure Cat.Bij {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    (G : Fun D C)\n    : Prop\n:= (id₁ : Fun.comp G F = Fun.id C)\n   (id₂ : Fun.comp F G = Fun.id D)\n\n/-! #brief Bijections of categories can be 'flipped' to the other direction.\n-/\ntheorem Cat.Bij.flip {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {G : Fun D C}\n    (bij : Cat.Bij F G)\n    : Cat.Bij G F\n:= { id₁ := bij^.id₂\n   , id₂ := bij^.id₁\n   }\n\n/-! #brief Bijections have unique inverses.\n-/\ntheorem Cat.Bij.inv_uniq₂ {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {G₁ G₂ : Fun D C}\n    (bij₁ : Cat.Bij F G₁)\n    (bij₂ : Cat.Bij F G₂)\n    : G₁ = G₂\n:= by calc G₁  = G₁ □□ Fun.id D : by rw Fun.comp_id_right\n           ... = G₁ □□ (F □□ G₂) : by rw bij₂^.id₂\n           ... = G₁ □□ F □□ G₂   : by rw Fun.comp_assoc\n           ... = Fun.id C □□ G₂ : by rw bij₁^.id₁\n           ... = G₂             : by rw Fun.comp_id_left\n\n/-! #brief Bijections have unique inverses.\n-/\ntheorem Cat.Bij.inv_uniq₁ {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F₁ F₂ : Fun C D}\n    {G : Fun D C}\n    (bij₁ : Cat.Bij F₁ G)\n    (bij₂ : Cat.Bij F₂ G)\n    : F₁ = F₂\n:= Cat.Bij.inv_uniq₂ (Cat.Bij.flip bij₁) (Cat.Bij.flip bij₂)\n\n/-! #brief The identity functor is a bijection of categories.\n-/\ntheorem Fun.id.Bij (C : Cat.{ℓobj ℓhom})\n    : Cat.Bij (Fun.id C) (Fun.id C)\n:= { id₁ := Fun.comp_id_left\n   , id₂ := Fun.comp_id_left\n   }\n\n/-! #brief The composition of two bijections is again a bijection.\n-/\ntheorem Fun.comp.bij\n    {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    {F₂ : Fun C D} {G₂ : Fun D C} (bij₂ : Cat.Bij F₂ G₂)\n    {F₁ : Fun B C} {G₁ : Fun C B} (bij₁ : Cat.Bij F₁ G₁)\n    : Cat.Bij (Fun.comp F₂ F₁) (Fun.comp G₁ G₂)\n:= { id₁\n      := by calc\n          G₁ □□ G₂ □□ (F₂ □□ F₁)\n              = G₁ □□ (G₂ □□ F₂) □□ F₁  : by repeat { rw Fun.comp_assoc }\n          ... = G₁ □□ Fun.id C □□ F₁    : by rw bij₂^.id₁\n          ... = G₁ □□ F₁                : by rw Fun.comp_id_right\n          ... = Fun.id B                : by rw bij₁^.id₁\n   , id₂\n      := by calc\n          F₂ □□ F₁ □□ (G₁ □□ G₂)\n              = F₂ □□ (F₁ □□ G₁) □□ G₂  : by repeat { rw Fun.comp_assoc }\n          ... = F₂ □□ (Fun.id C) □□ G₂  : by rw bij₁^.id₂\n          ... = F₂ □□ G₂                : by rw Fun.comp_id_right\n          ... = Fun.id D                : by rw bij₂^.id₂\n   }\n\n/-! #brief The casting functor.\n-/\ndefinition CastFun\n    : ∀ {C₁ C₂ : Cat.{ℓobj ℓhom}}\n        (ω : C₁ = C₂)\n       , Fun C₁ C₂\n| C .(C) (eq.refl .(C)) := Fun.id C\n\n/-! #brief The casting functor is trivial on eq.refl.\n-/\ntheorem CastFun.refl\n    : ∀ {C : Cat.{ℓobj ℓhom}}\n         (ω : C = C)\n      , CastFun ω = Fun.id C\n| C (eq.refl .(C)) := rfl\n\n/-! #brief The casting functor is compatible with transitivity.\n-/\ntheorem CastFun.trans\n    : ∀ {C₁ C₂ C₃ : Cat.{ℓobj ℓhom}}\n        (ω₂₃ : C₂ = C₃)\n        (ω₁₂ : C₁ = C₂)\n      , CastFun ω₂₃ □□ CastFun ω₁₂ = CastFun (eq.trans ω₁₂ ω₂₃)\n| C .(C) .(C) (eq.refl .(C)) (eq.refl .(C)) := Fun.comp_id_right\n\n/-! #brief The casting functor is a bijection of categories.\n-/\ntheorem CastFun.Bij\n    : ∀ {C₁ C₂ : Cat.{ℓobj ℓhom}}\n         (ω₁₂ : C₁ = C₂)\n         (ω₂₁ : C₂ = C₁)\n      , Cat.Bij (CastFun ω₁₂) (CastFun ω₂₁)\n| C .(C) (eq.refl .(C)) (eq.refl .(C)) := Fun.id.Bij C\n\n/-! #brief A pair of conjugate functors.\n-/\nstructure Fun.Conj {C₁ C₂ : Cat.{ℓobj₁ ℓhom₁}} {D₁ D₂ : Cat.{ℓobj₂ ℓhom₂}}\n    (FC₁₂ : Fun C₁ C₂) (FC₂₁ : Fun C₂ C₁)\n    (FD₁₂ : Fun D₁ D₂) (FD₂₁ : Fun D₂ D₁)\n    (F₁ : Fun C₁ D₁) (F₂ : Fun C₂ D₂)\n    : Prop\n:= (dom_bij : Cat.Bij FC₁₂ FC₂₁)\n   (codom_bij : Cat.Bij FD₁₂ FD₂₁)\n   (id₂ : F₂ = Fun.comp (Fun.comp FD₁₂ F₁) FC₂₁)\n\ntheorem Fun.Conj.outside {C₁ C₂ : Cat.{ℓobj₁ ℓhom₁}} {D₁ D₂ : Cat.{ℓobj₂ ℓhom₂}}\n    {FC₁₂ : Fun C₁ C₂} {FC₂₁ : Fun C₂ C₁}\n    {FD₁₂ : Fun D₁ D₂} {FD₂₁ : Fun D₂ D₁}\n    {F₁ : Fun C₁ D₁} {F₂ : Fun C₂ D₂}\n    (conj : Fun.Conj FC₁₂ FC₂₁ FD₁₂ FD₂₁ F₁ F₂)\n    : Fun.comp FD₂₁ F₂ = Fun.comp F₁ FC₂₁\n:= by calc FD₂₁ □□ F₂\n               = FD₂₁ □□ (FD₁₂ □□ F₁ □□ FC₂₁) : by rw conj^.id₂\n           ... = (FD₂₁ □□ FD₁₂) □□ F₁ □□ FC₂₁ : by repeat {rw Fun.comp_assoc}\n           ... = Fun.id D₁ □□ F₁ □□ FC₂₁     : by rw conj^.codom_bij^.id₁\n           ... = F₁ □□ FC₂₁                   : by rw Fun.comp_id_left\n\ntheorem Fun.Conj.inside {C₁ C₂ : Cat.{ℓobj₁ ℓhom₁}} {D₁ D₂ : Cat.{ℓobj₂ ℓhom₂}}\n    {FC₁₂ : Fun C₁ C₂} {FC₂₁ : Fun C₂ C₁}\n    {FD₁₂ : Fun D₁ D₂} {FD₂₁ : Fun D₂ D₁}\n    {F₁ : Fun C₁ D₁} {F₂ : Fun C₂ D₂}\n    (conj : Fun.Conj FC₁₂ FC₂₁ FD₁₂ FD₂₁ F₁ F₂)\n    : Fun.comp F₂ FC₁₂ = Fun.comp FD₁₂ F₁\n:= by calc F₂ □□ FC₁₂\n               = (FD₁₂ □□ F₁ □□ FC₂₁) □□ FC₁₂ : by rw conj^.id₂\n           ... = FD₁₂ □□ F₁ □□ (FC₂₁ □□ FC₁₂) : by repeat {rw Fun.comp_assoc}\n           ... = FD₁₂ □□ F₁ □□ Fun.id C₁     : by rw conj^.dom_bij^.id₁\n           ... = FD₁₂ □□ F₁                  : by rw Fun.comp_id_right\n\ntheorem Fun.Conj.id₁ {C₁ C₂ : Cat.{ℓobj₁ ℓhom₁}} {D₁ D₂ : Cat.{ℓobj₂ ℓhom₂}}\n    {FC₁₂ : Fun C₁ C₂} {FC₂₁ : Fun C₂ C₁}\n    {FD₁₂ : Fun D₁ D₂} {FD₂₁ : Fun D₂ D₁}\n    {F₁ : Fun C₁ D₁} {F₂ : Fun C₂ D₂}\n    (conj : Fun.Conj FC₁₂ FC₂₁ FD₁₂ FD₂₁ F₁ F₂)\n    : Fun.comp (Fun.comp FD₂₁ F₂) FC₁₂ = F₁\n:= by calc FD₂₁ □□ F₂ □□ FC₁₂\n               = FD₂₁ □□ (FD₁₂ □□ F₁ □□ FC₂₁) □□ FC₁₂   : by rw conj^.id₂\n           ... = (FD₂₁ □□ FD₁₂) □□ F₁ □□ (FC₂₁ □□ FC₁₂) : by repeat {rw Fun.comp_assoc}\n           ... = Fun.id D₁ □□ F₁ □□ Fun.id C₁           : by rw [conj^.dom_bij^.id₁, conj^.codom_bij^.id₁]\n           ... = F₁                                     : by rw [Fun.comp_id_left, Fun.comp_id_right]\n\n/-! #brief Conjugate functors can be 'flipped' to the other direction.\n-/\ntheorem Fun.conj {C₁ C₂ : Cat.{ℓobj₁ ℓhom₁}} {D₁ D₂ : Cat.{ℓobj₂ ℓhom₂}}\n    {FC₁₂ : Fun C₁ C₂} {FC₂₁ : Fun C₂ C₁}\n    {FD₁₂ : Fun D₁ D₂} {FD₂₁ : Fun D₂ D₁}\n    {F₁ : Fun C₁ D₁} {F₂ : Fun C₂ D₂}\n    (conj : Fun.Conj FC₁₂ FC₂₁ FD₁₂ FD₂₁ F₁ F₂)\n    : Fun.Conj FC₂₁ FC₁₂ FD₂₁ FD₁₂ F₂ F₁\n:= { dom_bij := Cat.Bij.flip conj^.dom_bij\n   , codom_bij := Cat.Bij.flip conj^.codom_bij\n   , id₂ := eq.symm conj^.id₁\n   }\n\n\n\n/- -----------------------------------------------------------------------\nOver-categories over final objects.\n----------------------------------------------------------------------- -/\n\n/-! #brief The over-category over a final is iso to the original category.\n-/\ndefinition OverFinal.to (C : Cat.{ℓobj ℓhom})\n    [C_HasFinal : HasFinal C]\n    : Fun C (OverCat C (final C))\n:= { obj := λ c, { obj := c, hom := final_hom c }\n   , hom := λ c₁ c₂ f, { hom := f, triangle := eq.symm (final_hom.uniq C) }\n   , hom_id := λ c, OverHom.eq rfl\n   , hom_circ := λ c₁ c₂ c₃ g f, OverHom.eq rfl\n   }\n\n/-! #brief The over-category over a final is iso to the original category.\n-/\ndefinition OverFinal.from (C : Cat.{ℓobj ℓhom})\n    [C_HasFinal : HasFinal C]\n    : Fun (OverCat C (final C)) C\n:= { obj := λ c, c^.obj\n   , hom := λ c₁ c₂ f, f^.hom\n   , hom_id := λ c, rfl\n   , hom_circ := λ c₁ c₂ c₃ g f, rfl\n   }\n\n/-! #brief The over-category over a final is iso to the original category.\n-/\ndefinition OverFinal.Bij (C : Cat.{ℓobj ℓhom})\n    [C_HasFinal : HasFinal C]\n    : Cat.Bij (OverFinal.to C) (OverFinal.from C)\n:= { id₁ := rfl\n   , id₂ := Fun.eq\n             (λ c, OverObj.eq rfl (heq_of_eq (eq.symm (final_hom.uniq C))))\n             (λ ω x y f, OverHom.heq (ω _) (ω _) (heq.refl _))\n   }\n\n\n/- -----------------------------------------------------------------------\nForgetful functors between the algebraic categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief The forgetful functor from CatOfMonoids to CatOfSemigroups.\n-/\ndefinition FrgtMonoidSemigroupFun\n    : Fun CatOfMonoids.{ℓ₁} CatOfSemigroups.{ℓ₁}\n:= { obj := λ A\n            , { fst := A^.fst\n              , snd := @monoid.to_semigroup A^.fst A^.snd\n              }\n   , hom := λ A B f\n            , { val := f^.val\n              , property := monoid.hom.to_hom f^.property\n              }\n   , hom_id := λ A, subtype.eq rfl\n   , hom_circ := λ A B C g f, subtype.eq rfl\n   }\n\n/-! #brief The forgetful functor from CatOfGroups to CatOfMonoids.\n-/\ndefinition FrgtGroupMonoidFun\n    : Fun CatOfGroups.{ℓ₁} CatOfMonoids.{ℓ₁}\n:= { obj := λ A\n            , { fst := A^.fst\n              , snd := @group.to_monoid A^.fst A^.snd\n              }\n   , hom := λ A B f\n            , { val := f^.val\n              , property := @group.hom.to_monoid_hom _ A^.snd _ B^.snd _ f^.property\n              }\n   , hom_id := λ A, subtype.eq rfl\n   , hom_circ := λ A B C g f, subtype.eq rfl\n   }\n\n\n\n/- -----------------------------------------------------------------------\nFunctors between categories induced by monoids and groups.\n----------------------------------------------------------------------- -/\n\n/-! #brief Every monoid homomorphism induces a functor.\n-/\ndefinition MonoidFun\n    {A : Type ℓ₁} [A_monoid : monoid A]\n    {B : Type ℓ₁} [B_monoid : monoid B]\n    {f : A → B}\n    (f_hom : monoid.hom f)\n    : Fun (MonoidCat A) (MonoidCat B)\n:= { obj := λ u, punit.star\n   , hom := λ u₁ u₂ a, f a\n   , hom_id := λ u, f_hom^.id\n   , hom_circ := λ u₁ u₂ u₃ a₂ a₁, f_hom^.dist a₂ a₁\n   }\n\n/-! #brief Every group homomorphism induces a functor.\n-/\ndefinition GroupFun\n    {A : Type ℓ₁} [A_group : group A]\n    {B : Type ℓ₁} [B_group : group B]\n    {f : A → B}\n    (f_hom : group.hom f)\n    : Fun (GroupCat A) (GroupCat B)\n:= MonoidFun (group.hom.to_monoid_hom f_hom)\n\n\n\n/- -----------------------------------------------------------------------\nFunctors between preorder categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief Every monotone function induces a functor.\n-/\ndefinition PreorderFun\n    {A : Type ℓ₁} {r : A → A → Prop}\n    {r_refl : reflexive r} {r_trans : transitive r}\n    {B : Type ℓ₂} {s : B → B → Prop}\n    {s_refl : reflexive s} {s_trans : transitive s}\n    (f : A → B)\n    (f_monotone : monotone r s f)\n    : Fun (PreorderCat r r_refl r_trans) (PreorderCat s s_refl s_trans)\n:= { obj := f\n   , hom := f_monotone\n   , hom_id := λ a, proof_irrel _ _\n   , hom_circ := λ a₁ a₂ a₃ g f, proof_irrel _ _\n   }\n\n@[simp] definition PreorderFun.simp_obj\n    {A : Type ℓ₁} {r : A → A → Prop}\n    {r_refl : reflexive r} {r_trans : transitive r}\n    {B : Type ℓ₂} {s : B → B → Prop}\n    {s_refl : reflexive s} {s_trans : transitive s}\n    (f : A → B)\n    (f_monotone : monotone r s f)\n    (a : A)\n    : (@PreorderFun A r r_refl r_trans B s s_refl s_trans f f_monotone)^.obj a = f a\n:= rfl\n\n@[simp] definition PreorderFun.simp_hom\n    {A : Type ℓ₁} {r : A → A → Prop}\n    {r_refl : reflexive r} {r_trans : transitive r}\n    {B : Type ℓ₂} {s : B → B → Prop}\n    {s_refl : reflexive s} {s_trans : transitive s}\n    (f : A → B)\n    (f_monotone : monotone r s f)\n    {a₁ a₂ : A} (ω : r a₁ a₂)\n    : (@PreorderFun A r r_refl r_trans B s s_refl s_trans f f_monotone)^.hom ω = f_monotone a₁ a₂ ω\n:= rfl\n\n/-! #brief Every function induces a functor between object categories.\n-/\ndefinition ObjFun {A : Type ℓ₁} {B : Type ℓ₂} (f : A → B)\n    : Fun (ObjCat A) (ObjCat B)\n:= PreorderFun f (λ a₁ a₂, congr_arg f)\n\n@[simp] definition ObjFun.simp_obj {A : Type ℓ₁} {B : Type ℓ₂} (f : A → B)\n    (a : A)\n    : (ObjFun f)^.obj a = f a\n:= rfl\n\n@[simp] definition ObjFun.simp_hom {A : Type ℓ₁} {B : Type ℓ₂} (f : A → B)\n    {a₁ a₂ : A} (ω : a₁ = a₂)\n    : (ObjFun f)^.hom ω = congr_arg f ω\n:= rfl\n\n\n\n/- -----------------------------------------------------------------------\nFunctors out of product categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief Left-projection out of a product category.\n-/\ndefinition ProdCat.π₁ (C : Cat.{ℓobj₁ ℓhom₁}) (D : Cat.{ℓobj₂ ℓhom₂})\n    : Fun (ProdCat C D) C\n:= { obj := λ x, x^.fst\n   , hom := λ x y f, f^.fst\n   , hom_id := λ x, rfl\n   , hom_circ := λ x y z g f, rfl\n   }\n\n/-! #brief Right-projection out of a product category.\n-/\ndefinition ProdCat.π₂ (C : Cat.{ℓobj₁ ℓhom₁}) (D : Cat.{ℓobj₂ ℓhom₂})\n    : Fun (ProdCat C D) D\n:= { obj := λ x, x^.snd\n   , hom := λ x y f, f^.snd\n   , hom_id := λ x, rfl\n   , hom_circ := λ x y z g f, rfl\n   }\n\n/-! #brief Pairs of functors induce functors into the product category.\n-/\ndefinition ProdCat.into {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (l : Fun B C)\n    (r : Fun B D)\n    : Fun B (ProdCat C D)\n:= { obj := λ b, { fst := l^.obj b, snd := r^.obj b }\n   , hom := λ b₁ b₂ f, { fst := l^.hom f, snd := r^.hom f }\n   , hom_id := λ b, begin rw [l^.hom_id, r^.hom_id], trivial end\n   , hom_circ := λ b₁ b₂ b₃ g f, begin rw [l^.hom_circ, r^.hom_circ], trivial end\n   }\n\n/-! #brief Factoring through Product.into.\n-/\ntheorem ProdCat.π₁_into {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    {l : Fun B C}\n    {r : Fun B D}\n    : Fun.comp (ProdCat.π₁ C D) (ProdCat.into l r) = l\n:= begin\n     apply Fun.eq,\n     { intro b, trivial },\n     { intros ωobj b₁ b₂ f, trivial },\n   end\n\n/-! #brief Factoring through Product.into.\n-/\ntheorem ProdCat.π₂_into {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    {l : Fun B C}\n    {r : Fun B D}\n    : Fun.comp (ProdCat.π₂ C D) (ProdCat.into l r) = r\n:= begin\n     apply Fun.eq,\n     { intro b, trivial },\n     { intros ωobj b₁ b₂ f, trivial },\n   end\n\n/-! #brief ProdCat.into on the projections is trivial.\n-/\ntheorem ProdCat.into_π {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    : ProdCat.into (ProdCat.π₁ C D) (ProdCat.π₂ C D) = Fun.id (ProdCat C D)\n:= begin\n     apply Fun.eq,\n     { intro cd, cases cd with c d, trivial },\n     { intros ωobj cd₁ cd₂ f, cases f with f₁ f₂, trivial }\n   end\n\n/-! #brief Composition of ProdCat.into.\n-/\ntheorem ProdCat.into.comp\n    {A : Cat.{ℓobj₁ ℓhom₁}}\n    {B : Cat.{ℓobj₂ ℓhom₂}}\n    {C : Cat.{ℓobj₃ ℓhom₃}}\n    {D : Cat.{ℓobj₄ ℓhom₄}}\n    {E : Cat.{ℓobj₅ ℓhom₅}}\n    {l₁ : Fun A B} {r₁ : Fun A C}\n    {l₂ : Fun (ProdCat B C) D} {r₂ : Fun (ProdCat B C) E}\n    : Fun.comp (ProdCat.into l₂ r₂) (ProdCat.into l₁ r₁)\n       = ProdCat.into (Fun.comp l₂ (ProdCat.into l₁ r₁))\n                      (Fun.comp r₂ (ProdCat.into l₁ r₁))\n:= begin\n     apply Fun.eq,\n     { intro a, trivial },\n     { intros ωobj a₁ a₂ f, trivial },\n   end\n\n/-! #brief Flipping the order of a product.\n-/\ndefinition ProdCat.flip (C : Cat.{ℓobj₁ ℓhom₁}) (D : Cat.{ℓobj₂ ℓhom₂})\n    : Fun (ProdCat C D) (ProdCat D C)\n:= ProdCat.into (ProdCat.π₂ C D) (ProdCat.π₁ C D)\n\n/-! #brief Flipping the order of a product is a bijection of categories.\n-/\ntheorem ProdCat.flip.Bij (C : Cat.{ℓobj₁ ℓhom₁}) (D : Cat.{ℓobj₂ ℓhom₂})\n    : Cat.Bij (ProdCat.flip C D) (ProdCat.flip D C)\n:= { id₁ := begin\n              unfold ProdCat.flip,\n              rw [ProdCat.into.comp, ProdCat.π₂_into, ProdCat.π₁_into, ProdCat.into_π]\n            end\n   , id₂ := begin\n              unfold ProdCat.flip,\n              rw [ProdCat.into.comp, ProdCat.π₂_into, ProdCat.π₁_into, ProdCat.into_π]\n            end\n   }\n\n\n\n/- -----------------------------------------------------------------------\nFunctors and opposite categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief Casting into OpCat OpCat.\n-/\ndefinition OpCat_OpCat.inFun (C : Cat.{ℓobj ℓhom})\n    : Fun C (OpCat (OpCat C))\n:= CastFun (eq.symm (OpCat_OpCat C))\n\n/-! #brief Casting out of OpCat OpCat.\n-/\ndefinition OpCat_OpCat.outFun (C : Cat.{ℓobj ℓhom})\n    : Fun (OpCat (OpCat C)) C\n:= CastFun (OpCat_OpCat C)\n\n/-! #brief OpCat_OpCat.inFun and OpCat_OpCat.outFun form a bijection.\n-/\ndefinition OpCat_OpCat.Bij (C : Cat.{ℓobj ℓhom})\n    : Cat.Bij (OpCat_OpCat.inFun C) (OpCat_OpCat.outFun C)\n:= CastFun.Bij _ _\n\n/-! #brief The opposite functor.\n-/\ndefinition OpFun {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Fun (OpCat C) (OpCat D)\n:= { obj := λ c, F^.obj c\n   , hom := λ c₁ c₂ f, F^.hom f\n   , hom_id := λ c, F^.hom_id\n   , hom_circ := λ c₁ c₂ c₃ g f, F^.hom_circ\n   }\n\n@[simp] theorem OpFun.simp_obj {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    (x : (OpCat C)^.obj)\n    : (OpFun F)^.obj x = F^.obj x\n:= rfl\n\n@[simp] theorem OpFun.simp_hom {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    {x₁ x₂ : (OpCat C)^.obj} (f : (OpCat C)^.hom x₁ x₂)\n    : (OpFun F)^.hom f = F^.hom f\n:= rfl\n\n/-! #brief The opposite functor preserves identity functors.\n-/\ntheorem OpFun.id {C : Cat.{ℓobj ℓhom}}\n    : OpFun (Fun.id C) = Fun.id (OpCat C)\n:= begin\n     apply Fun.eq,\n     { intro c, trivial },\n     { intros ωobj c₁ c₂ f, trivial }\n   end\n\n/-! #brief The opposite functor distributes over composition.\n-/\ntheorem OpFun.comp {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    {G : Fun C D}\n    {F : Fun B C}\n    : OpFun (Fun.comp G F) = Fun.comp (OpFun G) (OpFun F)\n:= begin\n     apply Fun.eq,\n     { intro c, trivial },\n     { intros ωobj c₁ c₂ f, trivial }\n   end\n\n/-! #brief OpFun preserves bijections.\n-/\ntheorem OpFun.Bij {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D} {G : Fun D C}\n    (bij : Cat.Bij F G)\n    : Cat.Bij (OpFun F) (OpFun G)\n:= { id₁ := by calc OpFun G □□ OpFun F\n                        = OpFun (G □□ F)   : by rw OpFun.comp\n                    ... = OpFun (Fun.id C) : by rw bij^.id₁\n                    ... = Fun.id (OpCat C) : by rw OpFun.id\n   , id₂ := by calc OpFun F □□ OpFun G\n                        = OpFun (F □□ G)   : by rw OpFun.comp\n                    ... = OpFun (Fun.id D) : by rw bij^.id₂\n                    ... = Fun.id (OpCat D) : by rw OpFun.id\n   }\n\n/-! #brief OpFun sends OpCat_OpCat.inFun to OpCat_OpCat.outFun.\n-/\ntheorem OpFun.inFun {C : Cat.{ℓobj ℓhom}}\n    : OpFun (OpCat_OpCat.inFun C) = OpCat_OpCat.outFun (OpCat C)\n:= begin cases C, exact OpFun.id end\n\n/-! #brief OpFun sends OpCat_OpCat.outFun to OpCat_OpCat.inFun.\n-/\ntheorem OpFun.outFun {C : Cat.{ℓobj ℓhom}}\n    : OpFun (OpCat_OpCat.outFun C) = OpCat_OpCat.inFun (OpCat C)\n:= begin cases C, exact OpFun.id end\n\n/-! #brief OpFun is nearly an involution.\n-/\ndefinition OpFun_OpFun.Conj {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Fun.Conj _ _ _ _  F (OpFun (OpFun F))\n:= { dom_bij := (OpCat_OpCat.Bij C)\n   , codom_bij := (OpCat_OpCat.Bij D)\n   , id₂ := begin\n              apply Fun.eq,\n              { intro c, cases C, cases D, trivial },\n              { intros ωobj c₁ c₂ f, cases C, cases D, trivial }\n            end\n   }\n\n\n\n/- -----------------------------------------------------------------------\nPreservation of initial and final.\n----------------------------------------------------------------------- -/\n\n/-! #brief A functor which preserves final objects.\n-/\nclass PresFinal {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Type (max ℓobj₁ ℓhom₁ ℓobj₂ ℓhom₂)\n:= (hom : ∀ [C_HasFinal : HasFinal C]\n            (d : D^.obj)\n          , D^.hom d (F^.obj (final C)))\n   (pres : ∀ [C_HasFinal : HasFinal C]\n           , IsFinal D (F^.obj (final C)) hom)\n\n/-! #brief Functors which preserve final objects yield instances of HasFinal.\n-/\ninstance PresFinal.HasFinal {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    [C_HasFinal : HasFinal C]\n    (F : Fun C D) [F_PresFinal : PresFinal F]\n    : HasFinal D\n:= { obj := F^.obj (final C)\n   , hom := PresFinal.hom F\n   , final := PresFinal.pres F\n   }\n\n/-! #brief A functor which preserves initial objects.\n-/\n@[class] definition PresInit {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Type (max ℓobj₁ ℓhom₁ ℓobj₂ ℓhom₂)\n:= PresFinal (OpFun F)\n-- := (hom : ∀ [C_HasInit : HasInit C]\n--             (d : D^.obj)\n--           , D^.hom (F^.obj (init C)) d)\n--    (pres : ∀ [C_HasInit : HasInit C]\n--            , IsInit D (F^.obj (init C)) hom)\n\n/-! #brief Functors which preserve initial objects yield instances of HasInit.\n-/\ninstance PresInit.HasInit {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    [C_HasInit : HasInit C]\n    (F : Fun C D) [F_PresInit : PresInit F]\n    : HasInit D\n:= @PresFinal.HasFinal (OpCat C) (OpCat D) C_HasInit (OpFun F) F_PresInit\n\n\n\n/- -----------------------------------------------------------------------\nFunctors and over and under categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief Functor from OverCat.\n-/\ndefinition OverFun.out (C : Cat.{ℓobj₁ ℓhom₁}) (c : C^.obj)\n    : Fun (OverCat C c) C\n:= { obj := λ x, x^.obj\n   , hom := λ x y f, f^.hom\n   , hom_id := λ x, rfl\n   , hom_circ := λ x y z g f, rfl\n   }\n\n/-! #brief Functors induce functors of over categories.\n-/\ndefinition OverFun {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (X : C^.obj)\n    (F : Fun C D)\n    : Fun (OverCat C X) (OverCat D (F^.obj X))\n:= { obj := λ A, OverObj.mk (F^.obj A^.dom) (F^.hom A^.down)\n   , hom := λ A B f, OverHom.mk (F^.hom f^.hom) (by rw [f^.triangle, F^.hom_circ])\n   , hom_id := λ A, OverHom.eq F^.hom_id\n   , hom_circ := λ a b c g f, OverHom.eq F^.hom_circ\n   }\n\n/-! #brief Heterogeneous equality for OverFun.\n-/\ntheorem OverFun.heq {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {X : C^.obj}\n    : ∀ {F₁ F₂ : Fun C D}\n         (ω : F₁ = F₂)\n      , OverFun X F₁ == OverFun X F₂\n| F .(F) (eq.refl .(F)) := heq.refl _\n\n/-! #brief OverFun preserves identity functors.\n-/\ntheorem OverFun.id {C : Cat.{ℓobj₁ ℓhom₁}} (X : C^.obj)\n    : OverFun X (Fun.id C) = Fun.id (OverCat C X)\n:= begin\n     apply Fun.eq,\n     { intro a, apply OverObj.eq,\n       { trivial },\n       { trivial }\n     },\n     { intros ωobj a b f,\n       apply OverHom.heq (ωobj _) (ωobj _),\n       { trivial }\n     }\n   end\n\n/-! #brief OverFun distributes over composition of functors.\n-/\ntheorem OverFun.comp {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    {X : B^.obj} {G : Fun C D} {F : Fun B C}\n    : OverFun X (Fun.comp G F) = Fun.comp (OverFun (F^.obj X) G) (OverFun X F)\n:= begin\n     apply Fun.eq,\n     { intro a, trivial },\n     { intros ωobj a b f, trivial }\n   end\n\n/-! #brief Functors induce functors of under categories.\n-/\ndefinition UnderFun {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (X : C^.obj)\n    (F : Fun C D)\n    : Fun (UnderCat C X) (UnderCat D (F^.obj X))\n:= OpFun (@OverFun (OpCat C) (OpCat D) X (OpFun F))\n\n/-! #brief UnderFun sends identity functors to identity functors.\n-/\ntheorem UnderFun.id {C : Cat.{ℓobj₁ ℓhom₁}} (X : C^.obj)\n    : UnderFun X (Fun.id C) = Fun.id (UnderCat C X)\n:= by calc OpFun (@OverFun C⁻¹ C⁻¹ X (OpFun (Fun.id C)))\n               = OpFun (@OverFun C⁻¹ C⁻¹ X (Fun.id C⁻¹)) : congr_arg OpFun (eq_of_heq (OverFun.heq OpFun.id))\n           ... = OpFun (Fun.id (OverCat C⁻¹ X))          : congr_arg OpFun (OverFun.id X)\n           ... = Fun.id (C\\\\X)                           : OpFun.id\n\n/-! #brief UnderFun distributes over composition of functors.\n-/\ntheorem UnderFun.comp {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (X : B^.obj) (G : Fun C D) (F : Fun B C)\n    : UnderFun X (Fun.comp G F) = Fun.comp (UnderFun (F^.obj X) G) (UnderFun X F)\n:= by calc OpFun (@OverFun B⁻¹ D⁻¹ X (OpFun (G □□ F)))\n               = OpFun (@OverFun B⁻¹ D⁻¹ X (OpFun G □□ OpFun F))                                       : congr_arg OpFun (eq_of_heq (OverFun.heq OpFun.comp))\n           ... = OpFun (@OverFun C⁻¹ D⁻¹ ((OpFun F)^.obj X) (OpFun G) □□ @OverFun B⁻¹ C⁻¹ X (OpFun F)) : congr_arg OpFun (@OverFun.comp B⁻¹ C⁻¹ D⁻¹ X (OpFun G) (OpFun F))\n           ... = OpFun (@OverFun C⁻¹ D⁻¹ (F^.obj X) (OpFun G)) □□ OpFun (@OverFun B⁻¹ C⁻¹ X (OpFun F)) : OpFun.comp\n\n/-! #brief Under and over categories are dual concepts.\n-/\ndefinition Under_dual_Over (C : Cat.{ℓobj ℓhom}) (X : C^.obj)\n    : UnderCat C X = OpCat (OverCat (OpCat C) X)\n:= rfl\n\n/-! #brief Over and under categories are dual concepts.\n-/\ndefinition Over_dual_Under (C : Cat.{ℓobj ℓhom}) (X : C^.obj)\n    : OverCat C X = OpCat (UnderCat (OpCat C) X)\n:= begin cases C, trivial end\n\n\n\n/- -----------------------------------------------------------------------\nCone and co-cone categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief An object in a cone category.\n-/\nstructure Cone {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Type (max ℓobj₁ ℓobj₂ ℓhom₂)\n:= (obj : D^.obj)\n   (hom : ∀ (c : C^.obj), D^.hom obj (F^.obj c))\n   (comm : ∀ {c₁ c₂ : C^.obj} (f : C^.hom c₁ c₂)\n           , hom c₂ = F^.hom f ∘∘ hom c₁)\n\n/-! #brief Composition of a cone with a hom.\n-/\ndefinition Cone.circ {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D} (cone : Cone F)\n    {d' : D^.obj} (h : D^.hom d' cone^.obj)\n    : Cone F\n:= { obj := d'\n   , hom := λ c, D^.circ (cone^.hom c) h\n   , comm := λ c₁ c₂ f\n             , begin\n                 rw D^.circ_assoc,\n                 apply Cat.circ.congr_left,\n                 apply cone^.comm\n               end\n   }\n\n/-! #brief A hom in a cone category.\n-/\nstructure ConeHom {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    (X Y : Cone F)\n    : Type ℓhom₂\n:= (mediate : D^.hom X^.obj Y^.obj)\n   (factor : ∀ (c : C^.obj), X^.hom c = Y^.hom c ∘∘ mediate)\n\n/-! #brief Equality of homs in a cone category.\n-/\ntheorem ConeHom.eq {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {X Y : Cone F}\n    : ∀ {f₁ f₂ : ConeHom F X Y}\n      , f₁^.mediate = f₂^.mediate\n      → f₁ = f₂\n| (ConeHom.mk f ω₁) (ConeHom.mk .(f) ω₂) (eq.refl .(f)) := rfl\n\n/-! #brief An identity hom in a cone category.\n-/\ndefinition ConeHom.id {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    (X : Cone F)\n    : ConeHom F X X\n:= { mediate := D^.id X^.obj\n   , factor := λ c, eq.symm D^.circ_id_right\n   }\n\n@[simp] theorem ConeHom.id.simp_mediate {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {X : Cone F}\n    : (ConeHom.id X)^.mediate = D^.id X^.obj\n:= rfl\n\n/-! #brief Composition of two homs in a cone category.\n-/\ndefinition ConeHom.comp {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {X Y Z : Cone F}\n    (g : ConeHom F Y Z) (f : ConeHom F X Y)\n    : ConeHom F X Z\n:= { mediate := D^.circ g^.mediate f^.mediate\n   , factor := λ c, by rw [D^.circ_assoc, -g^.factor, -f^.factor]\n   }\n\n@[simp] theorem ConeHom.comp.simp_mediate {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {X Y Z : Cone F}\n    {g : ConeHom F Y Z} {f : ConeHom F X Y}\n    : (ConeHom.comp g f)^.mediate = D^.circ g^.mediate f^.mediate\n:= rfl\n\n/-! #brief Composition of cone homs is associative.\n-/\ntheorem ConeHom.comp_assoc {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {X Y Z W : Cone F}\n    (h : ConeHom F Z W) (g : ConeHom F Y Z) (f : ConeHom F X Y)\n    : ConeHom.comp h (ConeHom.comp g f) = ConeHom.comp (ConeHom.comp h g) f\n:= ConeHom.eq D^.circ_assoc\n\n/-! #brief Left-identity for cone hom composition.\n-/\ntheorem ConeHom.comp_id_left {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {A B : Cone F} {f : ConeHom F A B}\n    : ConeHom.comp (ConeHom.id B) f = f\n:= ConeHom.eq D^.circ_id_left\n\n/-! #brief Right-identity for cone hom composition.\n-/\ntheorem ConeHom.comp_id_right {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {A B : Cone F} {f : ConeHom F A B}\n    : ConeHom.comp f (ConeHom.id A) = f\n:= ConeHom.eq D^.circ_id_right\n\n/-! #brief A cone category.\n-/\ndefinition ConeCat {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Cat.{(max ℓobj₁ ℓobj₂ ℓhom₂) (ℓhom₂ + 1)}\n:= { obj := Cone F\n   , hom := ConeHom F\n   , id := ConeHom.id\n   , circ := @ConeHom.comp C D F\n   , circ_assoc := @ConeHom.comp_assoc C D F\n   , circ_id_left := @ConeHom.comp_id_left C D F\n   , circ_id_right := @ConeHom.comp_id_right C D F\n   }\n\n/-! #brief Equal functors give equal cone categories.\n-/\ndefinition ConeCat.CastFun {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F₁ F₂ : Fun C D}\n    (ω : F₁ = F₂)\n    : Fun (ConeCat F₁) (ConeCat F₂)\n:= CastFun (congr_arg ConeCat ω)\n\n/-! #brief A co-cone category.\n-/\ndefinition CoConeCat {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Cat.{(max ℓobj₁ ℓobj₂ ℓhom₂) (ℓhom₂ + 1)}\n:= ConeCat (OpFun F)\n\n/-! #brief Equal functors give equal co-cone categories.\n-/\ndefinition CoConeCat.CastFun {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F₁ F₂ : Fun C D}\n    (ω : F₁ = F₂)\n    : Fun (CoConeCat F₁) (CoConeCat F₂)\n:= CastFun (congr_arg CoConeCat ω)\n\n/-! #brief An object in a co-cone category.\n-/\ndefinition CoCone {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : Type (max ℓobj₁ ℓobj₂ ℓhom₂)\n:= (CoConeCat F)^.obj\n\n/-! #brief Composition of a co-cone with a hom.\n-/\ndefinition CoCone.circ {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D} (ccone : CoCone F)\n    {d' : D^.obj} (h : D^.hom ccone^.obj d')\n    : CoCone F\n:= Cone.circ ccone h\n\n/-! #brief Construct an object in a co-cone category.\n-/\ndefinition CoCone.mk {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    (d : D^.obj)\n    (to : ∀ (c : C^.obj), D^.hom (F^.obj c) d)\n    (ω : ∀ {c₁ c₂ : C^.obj} (f : C^.hom c₁ c₂)\n         , to c₁ = to c₂ ∘∘ F^.hom f)\n    : CoCone F\n:= { obj := d\n   , hom := to\n   , comm := λ c₁ c₂, ω\n   }\n\n/-! #brief A hom in a co-cone category.\n-/\ndefinition CoConeHom {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    (A B : CoCone F)\n    : Type ℓhom₂\n:= (CoConeCat F)^.hom A B\n\n/-! #brief Construct a hom in a co-cone category.\n-/\ndefinition CoConeHom.mk {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    {F : Fun C D}\n    {A B : CoCone F}\n    (f : D^.hom B^.obj A^.obj)\n    (ω : ∀ (c : C^.obj), A^.hom c = f ∘∘ B^.hom c)\n    : CoConeHom F A B\n:= { mediate := f\n   , factor := ω\n   }\n\n/-! #brief Co-cones and cones are dual concepts.\n-/\ntheorem CoCone_dual_Cone {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : CoConeCat F = ConeCat (OpFun F)\n:= rfl\n\n/-! #brief Cones and co-cones are dual concepts.\n-/\ntheorem Cone_dual_CoCone {C : Cat.{ℓobj₁ ℓhom₁}} {D : Cat.{ℓobj₂ ℓhom₂}}\n    (F : Fun C D)\n    : (ConeCat F) = (CoConeCat (OpFun F))\n:= begin\n     cases C, cases D, cases F,\n     exact rfl,\n   end\n\n\n\n/- -----------------------------------------------------------------------\nFunctors and cone and co-cone categories.\n----------------------------------------------------------------------- -/\n\n/-! #brief Functors induce functors on cone categories by composition on the left.\n-/\ndefinition LeftConeFun {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (G : Fun C D)\n    (F : Fun B C)\n    : Fun (ConeCat F) (ConeCat (G □□ F))\n:= { obj := λ c, { obj := G^.obj c^.obj\n                 , hom := λ a, G^.hom (c^.hom a)\n                 , comm := λ a₁ a₂ f\n                           , begin\n                               rw [c^.comm f, G^.hom_circ],\n                               trivial\n                             end\n                 }\n   , hom := λ c₁ c₂ h, { mediate := G^.hom h^.mediate\n                      , factor := λ b, begin dsimp, rw [h^.factor, G^.hom_circ] end\n                      }\n   , hom_id := λ c, ConeHom.eq G^.hom_id\n   , hom_circ := λ c₁ c₂ c₃ g f, ConeHom.eq G^.hom_circ\n   }\n\n/-! #brief Functors induce functors on cone categories by composition on the right.\n-/\ndefinition RightConeFun {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (G : Fun C D)\n    (F : Fun B C)\n    : Fun (ConeCat G) (ConeCat (G □□ F))\n:= { obj := λ c, { obj := c^.obj\n                 , hom := λ a, (c^.hom (F^.obj a))\n                 , comm := λ a₁ a₂ f, c^.comm (F^.hom f)\n                 }\n   , hom := λ c₁ c₂ h, { mediate := h^.mediate\n                      , factor := λ b, h^.factor (F^.obj b)\n                      }\n   , hom_id := λ c, rfl\n   , hom_circ := λ c₁ c₂ c₃ g f, rfl\n   }\n\n/-! #brief Functors induce functors on cone categories by composition.\n-/\ndefinition ConeFun\n    {A : Cat.{ℓobj₁ ℓhom₁}} {B : Cat.{ℓobj₂ ℓhom₂}} {C : Cat.{ℓobj₃ ℓhom₃}} {D : Cat.{ℓobj₄ ℓhom₄}}\n    (H : Fun C D)\n    (G : Fun B C)\n    (F : Fun A B)\n    : Fun (ConeCat G) (ConeCat (H □□ G □□ F))\n:= Fun.comp (RightConeFun (Fun.comp H G) F) (LeftConeFun H G)\n\n/-! #brief Functors induce functors on co-cone categories by composition on the left.\n-/\ndefinition LeftCoConeFun {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (H : Fun C D)\n    (F : Fun B C)\n    : Fun (CoConeCat F) (CoConeCat (H □□ F))\n:= LeftConeFun (OpFun H) (OpFun F)\n\n/-! #brief Functors induce functors on co-cone categories by composition on the left.\n-/\ndefinition RightCoConeFun {B : Cat.{ℓobj₁ ℓhom₁}} {C : Cat.{ℓobj₂ ℓhom₂}} {D : Cat.{ℓobj₃ ℓhom₃}}\n    (F : Fun C D)\n    (H : Fun B C)\n    : Fun (CoConeCat F) (CoConeCat (F □□ H))\n:= RightConeFun (OpFun F) (OpFun H)\n\n/-! #brief Functors induce functors on co-cone categories by composition.\n-/\ndefinition CoConeFun\n    {A : Cat.{ℓobj₁ ℓhom₁}} {B : Cat.{ℓobj₂ ℓhom₂}} {C : Cat.{ℓobj₃ ℓhom₃}} {D : Cat.{ℓobj₄ ℓhom₄}}\n    (H : Fun C D)\n    (G : Fun B C)\n    (F : Fun A B)\n    : Fun (CoConeCat G) (CoConeCat (H □□ G □□ F))\n:= ConeFun (OpFun H) (OpFun G) (OpFun F)\n\nend qp\n", "meta": {"author": "intoverflow", "repo": "qvr", "sha": "0cfcd33fe4bf8d93851a00cec5bfd21e77105d74", "save_path": "github-repos/lean/intoverflow-qvr", "path": "github-repos/lean/intoverflow-qvr/qvr-0cfcd33fe4bf8d93851a00cec5bfd21e77105d74/qp/p1_categories/c1_basic/s2_functors.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.4554627593309554}}
{"text": "import MLIR.Semantics.Fitree\n\ntheorem Fitree.map_const:\n    (Functor.mapConst: R₁ → Fitree E R₂ → Fitree E R₁)\n    = Functor.map ∘ Function.const R₂ :=\n  rfl\n\ntheorem Fitree.id_map (t: Fitree E R):\n    id <$> t = t := by\n  simp [Functor.map]\n  induction t with\n  | Ret _ => rfl\n  | Vis _ _ ih => simp [bind, ih]\n\ntheorem Fitree.comp_map (f: R₁ → R₂) (g: R₂ → R₃) (t: Fitree E R₁):\n    (g ∘ f) <$> t = g <$> f <$> t := by\n  simp [Functor.map]\n  induction t with\n  | Ret _ => rfl\n  | Vis _ _ ih => simp [bind, ih]\n\ninstance {E}: LawfulFunctor (Fitree E) where\n  map_const  := Fitree.map_const\n  id_map     := Fitree.id_map\n  comp_map   := Fitree.comp_map\n\ntheorem Fitree.seqLeft_eq (t₁: Fitree E R₁) (t₂: Fitree E R₂):\n    t₁ <* t₂ = Function.const R₂ <$> t₁ <*> t₂ := by\n  simp [SeqLeft.seqLeft, Seq.seq]\n  induction t₁ with\n  | Ret _ => rfl\n  | Vis _ _ ih => simp [bind]; funext _; simp [ih]; sorry -- rfl\n\ntheorem Fitree.seqRight_eq (t₁: Fitree E R₁) (t₂: Fitree E R₂):\n    t₁ *> t₂ = Function.const R₁ id <$> t₁ <*> t₂ := by\n  simp [SeqRight.seqRight, Seq.seq]\n  induction t₁ with\n  | Ret _ =>\n    simp [Function.const, Function.comp, bind]\n  | Vis _ _ ih =>\n    simp [bind]; funext _; simp [ih]; sorry\n\ntheorem Fitree.pure_seq (f: R₁ → R₂) (t: Fitree E R₁):\n    pure f <*> t = f <$> t :=\n  rfl\n\ntheorem Fitree.map_pure (f: R₁ → R₂) (r: R₁):\n    f <$> (pure r) = pure (f := Fitree E) (f r) :=\n  rfl\n\ntheorem Fitree.seq_pure (f: Fitree E (R₁ → R₂)) (r: R₁):\n    f <*> pure r = (fun h => h r) <$> f :=\n  rfl\n\ntheorem Fitree.seq_assoc (t₁: Fitree E R₁)\n    (t₂: Fitree E (R₁ → R₂)) (t₃: Fitree E (R₂ → R₃)):\n    t₃ <*> (t₂ <*> t₁) = ((@Function.comp R₁ R₂ R₃) <$> t₃) <*> t₂ <*> t₁ := by\n  sorry\n\ninstance {E}: LawfulApplicative (Fitree E) where\n  seqLeft_eq   := Fitree.seqLeft_eq\n  seqRight_eq  := Fitree.seqRight_eq\n  pure_seq     := Fitree.pure_seq\n  map_pure     := Fitree.map_pure\n  seq_pure     := Fitree.seq_pure\n  seq_assoc    := Fitree.seq_assoc\n\n\ntheorem Fitree.bind_pure_comp (f: R₁ → R₂) (t: Fitree E R₁):\n    bind t (fun r => pure (f r)) = f <$> t :=\n  rfl\n\ntheorem Fitree.bind_map (f: Fitree E (R₁ → R₂)) (t: Fitree E R₁):\n    bind f (. <$> t) = f <*> t :=\n  rfl\n\ntheorem Fitree.pure_bind (r: R₁) (k: R₁ → Fitree E R₂):\n    bind (pure r) k = k r :=\n  rfl\n\ntheorem Fitree.bind_assoc (t: Fitree E R₁)\n    (k₁: R₁ → Fitree E R₂) (k₂: R₂ → Fitree E R₃):\n    bind (bind t k₁) k₂ = bind t (fun x => bind (k₁ x) k₂) := by\n  induction t with\n  | Ret _ => rfl\n  | Vis _ _ ih => simp [bind]; \n\ninstance {E}: LawfulMonad (Fitree E) where\n  bind_pure_comp  := Fitree.bind_pure_comp\n  bind_map        := Fitree.bind_map\n  pure_bind       := Fitree.pure_bind\n  bind_assoc      := Fitree.bind_assoc\n", "meta": {"author": "opencompl", "repo": "lean-mlir", "sha": "85fd61e38dec57e4d67d7af4d49a1ccc67828c1b", "save_path": "github-repos/lean/opencompl-lean-mlir", "path": "github-repos/lean/opencompl-lean-mlir/lean-mlir-85fd61e38dec57e4d67d7af4d49a1ccc67828c1b/MLIR/Semantics/FitreeLaws.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.45536702321864403}}
{"text": "import category_theory.equivalence\n\nopen category_theory\n\nvariables {C : Type*} [category C]\nvariables {D : Type*} [category D]\n\nlemma equiv_reflects_mono {X Y : C} (f : X ⟶ Y) (e : C ≌ D)\n  (hef : mono (e.functor.map f)) : mono f :=\nbegin\n  -- My first instinct is always to call `tidy`, to see how far it gets:\n  tidy,\n\n  -- It seems it unfolded the definition of `mono` in the goal for us,\n  -- and introduced some new hypotheses. That seems pretty reasonable for this problem!\n\n  -- If you like, you can ask `tidy` what it did by calling `tidy?`.\n  -- Often some human intervention is required to clean up the output,\n  -- but on this occasion it's pretty good.\n  sorry\nend\n", "meta": {"author": "leanprover-community", "repo": "lftcm2020", "sha": "cc683e2b074b61909310746d6acc1fb3d42d6ee2", "save_path": "github-repos/lean/leanprover-community-lftcm2020", "path": "github-repos/lean/leanprover-community-lftcm2020/lftcm2020-cc683e2b074b61909310746d6acc1fb3d42d6ee2/src/hints/category_theory/exercise3/hint1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.45536702321864403}}
{"text": "import str init.data.set data.set\nnamespace operators\nopen str \n-- Type to know if some actions are available or if there is a deadlock\nuniverse u\ninductive completed (α : Type _)\n\t| deadlock {} : completed\n\t| some   {} : α → completed\n\n-- Operator used to complete a STR by adding implicit transitions\n-- this operator is applicable only if the execution cannot deadlock\ndef add_implicit_transitions\n    (C A : Type)\n    (str : STR C A)\n    (h   : ∀ c, ∃ a ∈ str.actions c, str.execute c a ≠ ∅)\n    [∀ c, decidable (str.actions c = ∅)]\n: STR C (completed A) := \n{ \n    initial := str.initial,\n    actions := λ c, if str.actions c = ∅ then \n            (singleton completed.deadlock) \n        else \n            { oa | ∀ a ∈ str.actions c, oa = completed.some a }, \n    execute := λ c oa, match oa with\n        | completed.deadlock  := singleton c\n        | completed.some a := str.execute c a\n    end\n} \n\n-- deadlock = exists a configuration without fanout\n-- three potential sources of deadlock\n-- + actions, if from a source there is no action fireable\n-- + execute, ∀ a ∈ str.actions c, str.execute c a = ∅ , all action from c lead to empty sets when executed\n\ndef no_deadlock \n  (C A : Type)\n  (str : STR C A)\n: Prop := \n  ∀ c, \n    (str.actions c).nonempty\n  ∧ ∃ a ∈ str.actions c, (str.execute c a).nonempty\n\ndef has_deadlock \n  (C A : Type)\n  (str : STR C A)\n: Prop := \n  ∃ c, \n    str.actions c = ∅ \n  ∨ ∀ a ∈ str.actions c, str.execute c a = ∅\n\ndef deadlock_configuration \n  {C A : Type}\n  (str : STR C A)\n  (c : C)\n: Prop :=\n  str.actions c = ∅ \n  ∨ ∀ a ∈ str.actions c, str.execute c a = ∅\n\n\n\n@[simp]\ndef add_implicit_steps\n  (C A : Type)\n  (str : STR C A)\n  [∀ c, decidable (str.actions c = ∅)]\n  [∀ c, decidable (∀ a ∈ str.actions c, str.execute c a = ∅)]\n: STR C (completed A) :=\n{\n  initial := str.initial,\n  actions := λ c, \n              if  str.actions c = ∅ \n                ∨ ∀ a ∈ str.actions c, str.execute c a = ∅ \n              then \n                  singleton completed.deadlock\n              else\n                  { oa | ∀ a ∈ str.actions c, oa = (completed.some a)},\n  execute := λ c oa, match oa with\n        | completed.deadlock  := singleton c\n        | completed.some a := str.execute c a\n        end \n}\n\ndef actions_empty\n  (C A : Type) (str : STR C A) (c : C) := \nstr.actions c = ∅\ndef all_executions_block (C A : Type) (str : STR C A) (c : C) :=\n(∀ a ∈ str.actions c, str.execute c a = ∅)\n\ndef add_implicit_steps'\n  (C A : Type)\n  (str : STR C A)\n  -- [∀ c, decidable (str.actions c = ∅)]\n  -- [∀ c, decidable (∀ a ∈ str.actions c, str.execute c a = ∅)]\n: STR C (completed A) :=\n{\n  initial := str.initial,\n  actions := λ c, { a | (str.actions c = ∅ ∨ (∀ a ∈ str.actions c, str.execute c a = ∅) → a = completed.deadlock) \n                        ∨ ∀ oa ∈ str.actions c, a = (completed.some oa)}, \n  execute := λ c oa, match oa with\n        | completed.deadlock  := singleton c\n        | completed.some a := str.execute c a\n        end \n}\n\n\ntheorem add_imp_rem_deadlock \n  (C: Type)\n  (A: Type)\n  [hA : inhabited A]\n  (str : STR C A)\n  (deadlock : ¬ no_deadlock C A str)\n  [∀ c, decidable (str.actions c = ∅)]\n  [∀ c, decidable (∀ (a : A), a ∈ str.actions c → str.execute c a = ∅)]\n  [∀ c, decidable (deadlock_configuration str c)]\n: \n  no_deadlock C (completed A) (add_implicit_steps C A str)\n:= \nbegin\n  simp * at *, intro, simp at *, split_ifs, \n    finish *, \n    split, sorry,\n\n    revert h, simp at *, \n    refine classical.skolem.mpr _, refine ex_of_psig _, refine ⟨_, _⟩, \n  intro, exact completed.deadlock,\n    \n  refine imp_and_distrib.mpr _, split, \n  revert deadlock, unfold no_deadlock,\n\n  simp * at *, intros, revert ᾰ_1, refine not_imp.mpr _, split, \n  revert ᾰ, refine imp_or_distrib.mpr _, refine or.inl _, safe *,\n   sorry,\n  -- -- hint, \n  -- refine not_imp.mpr _, norm_num, revert ᾰ, exact set.not_nonempty_iff_eq_empty.mp, simp [not_nonempty_iff_eq_empty], \n  \n  sorry, sorry\nend\n\nend operators", "meta": {"author": "teodorov", "repo": "gamine", "sha": "91fe07321c1b457b1c925de6cdc1588ee34d0a6b", "save_path": "github-repos/lean/teodorov-gamine", "path": "github-repos/lean/teodorov-gamine/gamine-91fe07321c1b457b1c925de6cdc1588ee34d0a6b/src/stuttering.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837527911057, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.45536701679912267}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.list.dedup\n! leanprover-community/mathlib commit f694c7dead66f5d4c80f446c796a5aad14707f0e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathlib.Data.List.Nodup\n\n/-!\n# Erasure of duplicates in a list\n\nThis file proves basic results about `List.dedup` (definition in `Data.List.Defs`).\n`dedup l` returns `l` without its duplicates. It keeps the earliest (that is, rightmost)\noccurrence of each.\n\n## Tags\n\nduplicate, multiplicity, nodup, `nub`\n-/\n\n\nuniverse u\n\nnamespace List\n\nvariable {α : Type u} [DecidableEq α]\n\n@[simp]\ntheorem dedup_nil : dedup [] = ([] : List α) :=\n  rfl\n#align list.dedup_nil List.dedup_nil\n\ntheorem dedup_cons_of_mem' {a : α} {l : List α} (h : a ∈ dedup l) : dedup (a :: l) = dedup l :=\n  pwFilter_cons_of_neg <| by simpa only [forall_mem_ne, not_not] using h\n#align list.dedup_cons_of_mem' List.dedup_cons_of_mem'\n\ntheorem dedup_cons_of_not_mem' {a : α} {l : List α} (h : a ∉ dedup l) :\n    dedup (a :: l) = a :: dedup l :=\n  pwFilter_cons_of_pos <| by simpa only [forall_mem_ne] using h\n#align list.dedup_cons_of_not_mem' List.dedup_cons_of_not_mem'\n\n@[simp]\ntheorem mem_dedup {a : α} {l : List α} : a ∈ dedup l ↔ a ∈ l := by\n  have := not_congr (@forall_mem_pwFilter α (· ≠ ·) _ ?_ a l)\n  simpa only [dedup, forall_mem_ne, not_not] using this\n  intros x y z xz\n  exact not_and_or.1 <| mt (fun h ↦ h.1.trans h.2) xz\n\n#align list.mem_dedup List.mem_dedup\n\n@[simp]\ntheorem dedup_cons_of_mem {a : α} {l : List α} (h : a ∈ l) : dedup (a :: l) = dedup l :=\n  dedup_cons_of_mem' <| mem_dedup.2 h\n#align list.dedup_cons_of_mem List.dedup_cons_of_mem\n\n@[simp]\ntheorem dedup_cons_of_not_mem {a : α} {l : List α} (h : a ∉ l) : dedup (a :: l) = a :: dedup l :=\n  dedup_cons_of_not_mem' <| mt mem_dedup.1 h\n#align list.dedup_cons_of_not_mem List.dedup_cons_of_not_mem\n\ntheorem dedup_sublist : ∀ l : List α, dedup l <+ l :=\n  pwFilter_sublist\n#align list.dedup_sublist List.dedup_sublist\n\ntheorem dedup_subset : ∀ l : List α, dedup l ⊆ l :=\n  pwFilter_subset\n#align list.dedup_subset List.dedup_subset\n\ntheorem subset_dedup (l : List α) : l ⊆ dedup l := fun _ => mem_dedup.2\n#align list.subset_dedup List.subset_dedup\n\ntheorem nodup_dedup : ∀ l : List α, Nodup (dedup l) :=\n  pairwise_pwFilter\n#align list.nodup_dedup List.nodup_dedup\n\ntheorem dedup_eq_self {l : List α} : dedup l = l ↔ Nodup l :=\n  pwFilter_eq_self\n#align list.dedup_eq_self List.dedup_eq_self\n\nprotected theorem Nodup.dedup {l : List α} (h : l.Nodup) : l.dedup = l :=\n  List.dedup_eq_self.2 h\n#align list.nodup.dedup List.Nodup.dedup\n\n@[simp]\ntheorem dedup_idempotent {l : List α} : dedup (dedup l) = dedup l :=\n  pwFilter_idempotent\n#align list.dedup_idempotent List.dedup_idempotent\n\ntheorem dedup_append (l₁ l₂ : List α) : dedup (l₁ ++ l₂) = l₁ ∪ dedup l₂ := by\n  induction' l₁ with a l₁ IH; · rfl\n  simp only [instUnionList, cons_union] at *\n  rw [← IH, cons_append]\n  by_cases h : a ∈ dedup (l₁ ++ l₂)\n  · rw [dedup_cons_of_mem' h, insert_of_mem h]\n  · rw [dedup_cons_of_not_mem' h, insert_of_not_mem h]\n#align list.dedup_append List.dedup_append\n\ntheorem replicate_dedup {x : α} : ∀ {k}, k ≠ 0 → (replicate k x).dedup = [x]\n  | 0, h => (h rfl).elim\n  | 1, _ => rfl\n  | n + 2, _ => by\n    rw [replicate_succ, dedup_cons_of_mem (mem_replicate.2 ⟨n.succ_ne_zero, rfl⟩),\n      replicate_dedup n.succ_ne_zero]\n#align list.replicate_dedup List.replicate_dedup\n\ntheorem count_dedup (l : List α) (a : α) : l.dedup.count a = if a ∈ l then 1 else 0 := by\n  simp_rw [count_eq_of_nodup <| nodup_dedup l, mem_dedup]\n#align list.count_dedup List.count_dedup\n\n/-- Summing the count of `x` over a list filtered by some `p` is just `countp` applied to `p` -/\ntheorem sum_map_count_dedup_filter_eq_countp (p : α → Bool) (l : List α) :\n    ((l.dedup.filter p).map fun x => l.count x).sum = l.countp p := by\n  induction' l with a as h\n  · simp\n  · simp_rw [List.countp_cons, List.count_cons', List.sum_map_add]\n    congr 1\n    · refine' _root_.trans _ h\n      by_cases ha : a ∈ as\n      · simp [dedup_cons_of_mem ha]\n      · simp only [dedup_cons_of_not_mem ha, List.filter]\n        match p a with\n        | true => simp only [List.map_cons, List.sum_cons, List.count_eq_zero.2 ha, zero_add]\n        | false => simp only\n    · by_cases hp : p a\n      · refine' _root_.trans (sum_map_eq_nsmul_single a _ fun _ h _ => by simp [h]) _\n        simp [hp, count_dedup]\n      · refine' _root_.trans (List.sum_eq_zero fun n hn => _) (by simp [hp])\n        obtain ⟨a', ha'⟩ := List.mem_map.1 hn\n        split_ifs at ha' with ha\n        · simp only [ha, mem_filter, mem_dedup, find?, mem_cons, true_or, hp,\n            and_false, false_and] at ha'\n        · exact ha'.2.symm\n#align list.sum_map_count_dedup_filter_eq_countp List.sum_map_count_dedup_filter_eq_countp\n\ntheorem sum_map_count_dedup_eq_length (l : List α) :\n    (l.dedup.map fun x => l.count x).sum = l.length := by\n  simpa using sum_map_count_dedup_filter_eq_countp (fun _ => True) l\n#align list.sum_map_count_dedup_eq_length List.sum_map_count_dedup_eq_length\n\nend List\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/List/Dedup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878696277513, "lm_q2_score": 0.7401743735019595, "lm_q1q2_score": 0.4552722785503757}}
{"text": "import lambda_calculus.notation\nimport lambda_calculus.utlc.basic\nimport lambda_calculus.utlc.identities\nimport lambda_calculus.utlc.reduction\nimport logic.relation\n\nnamespace lambda_calculus\nnamespace utlc\nnamespace η\n\nlocal notation a `[` b `:=` c  `]` : 70 := has_substitution.substitution a b c\n\nvariables {f g f' g' x y z: utlc}\n\n@[simp]\ndef head_step : utlc → utlc → Prop := λ f g, f = Λ (g ↑¹ 0)·↓0\n\ninstance : has_η_reduction utlc := ⟨ reduction_step_of head_step ⟩\n\n@[simp] theorem down_step {n: ℕ}: ¬ ↓n →η g :=\nbegin\n  simp [has_η_reduction.step, reduction_step],\nend\n\ntheorem lambda_step_lambda : f →η g → (Λ f) →η (Λ g) :=\nbegin\n  intro p,\n  simp [has_η_reduction.step, reduction_step],\n  exact or.inr p\nend\n\ntheorem lambda_step_head (f: utlc): Λ (f ↑¹ 0)·↓0 →η f :=\nby simp [has_η_reduction.step, reduction_step]\n\ntheorem lambda_step_head': f = (g ↑¹ 0)·↓0 → Λ f →η g :=\nby { intro p, rw[p], exact lambda_step_head _ }\n\ntheorem lambda_step_iff: Λ f →η g ↔ (∃ x, g = x ∧ f = (x ↑¹ 0)·↓0) ∨ (∃ x, g = Λ x ∧ f →η x) :=\nby simp [has_η_reduction.step, reduction_step]\n\ntheorem lambda_step_cases : Λ f →η g → (∃ x, g = Λ x ∧ f →η x ∨ g = x ∧ f = (x ↑¹ 0)·↓0) :=\nbegin\n  simp [has_η_reduction.step, reduction_step],\n  intro p,\n  cases p,\n  use g,\n  exact or.inr ⟨rfl, p⟩,\n  cases g,\n  all_goals { simp [has_η_reduction.step, reduction_step] at * },\n  any_goals { contradiction },\n  use g,\n  exact or.inl ⟨rfl, p⟩,  \nend\n\ntheorem lambda_step_cases': Λ f →η g → (∃ x, g = Λ x ∧ f →η x) ∨ ∃ x, g = x ∧ f = (x ↑¹ 0)·↓0 :=\nbegin\n  intro p,\n  cases lambda_step_cases p,\n  cases h,\n  left,\n  use w,\n  assumption,\n  right,\n  use w,\n  assumption,\nend\n\ntheorem dot_step_dot_left : f →η f' → (f·g) →η (f'·g) :=\nbegin\n  intro p,\n  simp [has_η_reduction.step, reduction_step],\n  exact or.inl p,\nend\n\ntheorem dot_step_dot_right : g →η g' → (f·g) →η (f·g') :=\nbegin\n  intro p,\n  simp [has_η_reduction.step, reduction_step],\n  exact or.inr p,\nend\n\ntheorem dot_step_iff: (f·f') →η g ↔ ∃ x x', g = x·x' ∧ (x' = f' ∧ f →η x ∨ x = f ∧ f' →η x') :=\nbegin\n  cases g,\n  all_goals { simp [has_η_reduction.step, and_assoc] },\nend\n\ntheorem dot_step_iff': (f·f') →η g ↔ (∃ x x', x' = f' ∧ g = x·x' ∧ f →η x) ∨ (∃ x x', x = f ∧ g = x·x' ∧ f' →η x') :=\nbegin\n  cases g,\n  all_goals { simp [has_η_reduction.step, and_assoc] },\nend\n\ntheorem dot_step_cases: (f·f') →η g → ∃ x x', g = x·x' ∧ (x' = f' ∧ f →η x ∨ x = f ∧ f' →η x') :=\nbegin\n  cases g,\n  all_goals { simp [has_η_reduction.step, and_assoc] },\nend\n\ntheorem dot_step_cases': (f·f') →η g → (∃ x x', x' = f' ∧ g = x·x' ∧ f →η x) ∨ (∃ x x', x = f ∧ g = x·x' ∧ f' →η x') :=\nbegin\n  cases g,\n  all_goals { simp [has_η_reduction.step, and_assoc] },\nend\n\ntheorem reduction_step_shift (n: ℕ): f ↑¹ n →η g ↑¹ n → f →η g :=\nbegin\n  induction f generalizing g n,\n  { simp[down_shift] },\n  { simp,\n    intro p,\n    cases lambda_step_cases p with x p,\n    cases p with p p,\n    { cases p with hgx hfx,\n      have h: (g ↑¹ n).uses n = x.uses (n + 1),\n      { simp [hgx, uses] },\n      have h: ∃ y, x = y ↑¹ (n+1),\n      { apply shift_of_uses_zero,\n        rw [← h],\n        simp [shift_uses] },\n      cases h with y hy,\n      rw [hy,\n          ← show (Λ y) ↑¹ n = Λ y ↑¹ (n+1), by simp,\n          shift_inj_iff] at hgx,\n      rw [hgx],\n      apply lambda_step_lambda,\n      apply f_ih,\n      rw [← hy],\n      apply hfx },\n    { cases p with hgx hfx,\n      -- rw [← hgx, ← shift_comm] at hfx,\n      apply lambda_step_head',\n      rw [← shift_inj_iff (n + 1), hfx],\n      simp [down_shift],\n      rw [← shift_comm_zero, hgx] } },\n  { simp,\n    intro p,\n    cases g;\n    try { simp[has_η_reduction.step, reduction_step, dot_step_iff, down_shift] at p,\n      contradiction },\n    rcases dot_step_cases p with ⟨x, y, hgxy, p⟩,\n    simp at hgxy,\n    simp,\n    cases p with p p,\n    cases p with hfy hfx,\n    simp [hfy] at hgxy,\n    rw [hgxy.right],\n    rw [← hgxy.left] at hfx,\n    exact dot_step_dot_left (f_ih_f _ hfx),\n    cases p with hfx hfy,\n    simp [hfx] at hgxy,\n    rw [hgxy.left],\n    rw [← hgxy.right] at hfy,\n    exact dot_step_dot_right (f_ih_g _ hfy)\n     }\nend\n\ntheorem reduction_step_uses: f →η g → ∀ n, f.uses n = g.uses n :=\nbegin\n  induction f generalizing g,\n  { all_goals { simp } },\n  { intros p n,\n    cases lambda_step_cases p with x p,\n    cases p with p p,\n    { simp [uses, p.left], exact f_ih p.right _},\n    { simp [uses, p, show 0 ≠ n + 1, by linarith] } },\n  {\n    intros p m,\n    rcases dot_step_cases p with ⟨x, y, hg, p⟩,\n    cases p with p p,\n    { simp [p.left, hg, uses],\n      apply f_ih_f p.right },\n    { simp [p.left, hg, uses],\n      apply f_ih_g p.right } }\nend\n\ntheorem reduction_step_size: f →η g → f.size = g.size + 3 :=\nbegin\n  induction f generalizing g;\n  simp,\n  simp [lambda_step_iff],\n  intro p,\n  cases p,\n  { rw [p], simp },\n  { rcases p with ⟨x, hgx, hfx⟩,\n    simp [f_ih hfx, hgx] },\n  { intro p,\n    rcases dot_step_cases p with ⟨x, y, hgxy, p⟩,\n    cases p with p p;\n    rcases p with ⟨heq, hstep⟩,\n    simp [f_ih_f hstep, hgxy, ← heq],\n    ring,\n    simp [f_ih_g hstep, hgxy, ← heq],\n    ring,\n  }\nend\n\ntheorem reduction_step_size_mono: f →η g → g.size < f.size :=\nby intro p; simp [reduction_step_size p]\n\n@[simp] theorem down_reduction_iff {n: ℕ}: ↓n ↠η g ↔ g = ↓n :=\nbegin\n  split;\n  intro p,\n  cases relation.refl_trans_gen.cases_head p,\n  { apply h.symm },\n  { simp at h, contradiction },\n  rw [p],\nend\n\ntheorem lambda_reduction_lambda: f ↠η f' → Λ f ↠η Λ f' :=\nbegin\n  intro p,\n  induction p,\n  { refl },\n  apply relation.refl_trans_gen.tail,\n  assumption,\n  apply lambda_step_lambda,\n  assumption,\nend\n\ntheorem dot_reduction_dot_left: f ↠η f' → f·g ↠η f'·g :=\nbegin\n  intro p,\n  induction p,\n  { refl },\n  apply relation.refl_trans_gen.tail,\n  assumption,\n  apply dot_step_dot_left,\n  assumption,\nend\n\ntheorem dot_reduction_dot_right: g ↠η g' → f·g ↠η f·g' :=\nbegin\n  intro p,\n  induction p,\n  { refl },\n  apply relation.refl_trans_gen.tail,\n  assumption,\n  apply dot_step_dot_right,\n  assumption,\nend\n\ntheorem dot_reduction_dot: f ↠η f' → g ↠η g' → f·g ↠η f'·g' :=\nbegin\n  intros p q,\n  apply trans,\n  apply dot_reduction_dot_left,\n  assumption,\n  apply dot_reduction_dot_right,\n  assumption,\nend\n\ntheorem dot_exists_reduction (h: f ↠η g): ∀ {m n}, f = m·n → ∃ x y, g = x·y ∧ m ↠η x ∧ n ↠η y :=\nbegin\n  induction h using relation.refl_trans_gen.head_induction_on with f f' hf hfg ih,\n  { intros m n p,\n    refine ⟨ m, n, p, by refl, by refl⟩ },\n  { intros m n p,\n    rw [p] at hf,\n    rcases dot_step_cases hf with ⟨a, b, hab, h⟩,\n    rcases ih hab with ⟨i, j, ih⟩,\n    refine ⟨i, j, ih.left, trans _ ih.right.left, trans _ ih.right.right⟩;\n    cases h;\n    try { simp[h] };\n    cases h;\n    try { apply relation.refl_trans_gen.single, assumption } }\nend\n\ntheorem dot_reduction_cases (h: f·f' ↠η g): ∃ x y, g = x·y ∧ f ↠η x ∧ f' ↠η y := dot_exists_reduction h rfl\n\ntheorem dot_reduction_dot_iff: f·g ↠η f'·g' ↔ f ↠η f' ∧ g ↠η g' :=\nbegin\n  split,\n  { intro p,\n    have h := dot_exists_reduction p rfl,\n    simp [and.assoc] at h,\n    assumption },\n  intro p,\n  apply dot_reduction_dot p.left p.right,\nend\n\ntheorem shift_head_step_shift {n: ℕ}: head_step (f ↑¹ n) (g ↑¹ n) ↔ head_step f g :=\nbegin\n  cases f;\n  cases g;\n  try { simp };\n  cases f;\n  try { simp[down_shift] };\n  cases f_f;\n  cases f_g;\n  simp [down_shift];\n  split_ifs;\n  simp;\n  try { simp [← @shift_comm 1 (n + 1) _ (by linarith)] };\n  try { simp [← @shift_comm 0 n _ (by linarith)] };\n  repeat { intro };\n  try { linarith };\n  split;\n  intro;\n  try { linarith },\n  rw [← @shift_inj_iff _ (n + 1 + 1), shift_comm],\n  assumption,\n  linarith,\n  rw [← shift_comm, shift_inj_iff],\n  assumption,\n  linarith,\nend\n\ntheorem head_step_substitution: head_step f f' → ∀ n g, f[n:=g] ↠η f'[n:=g]  :=\nbegin\n  simp only [head_step],\n  intros p n g,\n  simp [p],\n  apply relation.refl_trans_gen.single,\n  apply lambda_step_head',\n  simp,\n  apply substitution_shift_ge,\n  apply nat.zero_le _,\nend\n\ndef head_reduced : utlc → bool\n| (↓ _):= true\n| (Λ f) := match f with\n  | (↓ _) := true\n  | (Λ _) := true\n  | (f·g) := f.uses 0 > 0 ∨ g ≠ ↓0\n  end\n| (_·_) := true\n\ndef reduced := reduced_of head_reduced\n\ntheorem head_reduced_iff_not_head_step: head_reduced f ↔ ∀ g, ¬ head_step f g :=\nbegin\n  cases f;\n  try { cases f };\n  simp[head_reduced],\n  split,\n  { intros p g q,\n    cases p,\n    exfalso,\n    apply (ne_of_lt p).symm,\n    rw [q],\n    apply shift_uses_self,\n    assumption },\n  intros p,\n  obtain h|h|h := nat.lt_trichotomy (f_f.uses 0) 0,\n  { simp at h, contradiction },\n  { cases shift_of_uses_zero h with g h,\n    right,\n    apply p g h },\n  { left, apply h },\nend\n\ntheorem reduced_iff_not_reduction (f: utlc): reduced f ↔ ∀ g, ¬ f →η g :=\n  reduced_iff_not_reduction_step @head_reduced_iff_not_head_step _\n\n\n@[simp] theorem down_reduced (n: ℕ): reduced ↓n := by simp [reduced, head_reduced, down_reduced]\n\ntheorem lambda_reduced (f: utlc): reduced (Λ f) ↔ head_reduced (Λ f) ∧ reduced f :=\nby simp [reduced, head_reduced, lambda_reduced]\n\n@[simp] theorem dot_reduced (f g: utlc): reduced (f·g) ↔ reduced f ∧ reduced g := by simp [reduced, head_reduced, dot_reduced]\n\n-- inductive hypothesis useful when dealing with η reductions\n-- splits (Λ f·↓0) up to handle the (Λ f)·g ⇔ f[0:=g] case\n-- theorem η_induction_on (p: utlc → Prop): Π (f: utlc)\n--   (down: Π n, p ↓n)\n--   (dot_lambda: Π x (hx: p x) (h: x.uses 0 = 0), p (Λ x·↓0))\n--   (lambda: Π x (hx: p x) (h: head_reduced x), p (Λ x))\n--   (dot : Π x y (hx: p x) (hy: p y), p (x·y)),\n--   (p f)\n-- | (↓n) := λ hn hx hdx hlx, hn n\n-- | (Λ x) := λ hn hx hdx hlx, hx x (β_induction_on x hn hx hdx hlx)\n\nend η\nend utlc\nend lambda_calculus", "meta": {"author": "calcu16", "repo": "lean_complexity", "sha": "0dcb73bde8d1d4237f782f4790166365ac3209fe", "save_path": "github-repos/lean/calcu16-lean_complexity", "path": "github-repos/lean/calcu16-lean_complexity/lean_complexity-0dcb73bde8d1d4237f782f4790166365ac3209fe/src/lambda_calculus/utlc/eta/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743735019594, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4552722681052682}}
{"text": "/-\nCopyright (c) 2018 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad\n\nThe initial algebra of a multivariate qpf is again a qpf.\n-/\nimport ..mvpfunctor.M .basic\nuniverse u\n\nnamespace mvqpf\nopen typevec\nopen mvfunctor (liftp liftr)\n\nvariables {n : ℕ} {F : typevec.{u} (n+1) → Type u} [mvfunctor F] [q : mvqpf F]\ninclude q\n\ndef corecF {α : typevec n} {β : Type*} (g : β → F (α.append1 β)) : β → q.P.M α :=\nq.P.M_corec (λ x, repr (g x))\n\ntheorem corecF_eq {α : typevec n} {β : Type*} (g : β → F (α.append1 β)) (x : β) :\n  q.P.M_dest (corecF g x) = append_fun id (corecF g) <$$> repr (g x) :=\nby rw [corecF, q.P.M_dest_corec]\n\ndef is_precongr {α : typevec n} (r : q.P.M α → q.P.M α → Prop) : Prop :=\n  ∀ ⦃x y⦄, r x y →\n    abs (append_fun id (quot.mk r) <$$> q.P.M_dest x) =\n      abs (append_fun id (quot.mk r) <$$> q.P.M_dest y)\n\ndef Mcongr {α : typevec n} : q.P.M α → q.P.M α → Prop :=\nλ x y, ∃ r, is_precongr r ∧ r x y\n\ndef cofix (F : typevec (n + 1) → Type u) [mvfunctor F] [q : mvqpf F] (α : typevec n):=\nquot (@Mcongr _ F _ q α)\n\ndef cofix.map {α β : typevec n} (g : α ⟹ β) : cofix F α → cofix F β :=\nquot.lift (λ x : q.P.M α, quot.mk Mcongr (g <$$> x))\n  begin\n    rintros a₁ a₂ ⟨r, pr, ra₁a₂⟩, apply quot.sound,\n    let r' := λ b₁ b₂, ∃ a₁ a₂ : q.P.M α, r a₁ a₂ ∧ b₁ = g <$$> a₁ ∧ b₂ = g <$$> a₂,\n    use r', split,\n    { show is_precongr r',\n      rintros b₁ b₂ ⟨a₁, a₂, ra₁a₂, b₁eq, b₂eq⟩,\n      let u : quot r → quot r' := quot.lift (λ x : q.P.M α, quot.mk r' (g <$$> x))\n        (by { intros a₁ a₂ ra₁a₂, apply quot.sound, exact ⟨a₁, a₂, ra₁a₂, rfl, rfl⟩ }),\n      have hu : (quot.mk r' ∘ λ x : q.P.M α, g <$$> x) = u ∘ quot.mk r,\n        { ext x, refl },\n      rw [b₁eq, b₂eq, q.P.M_dest_map, q.P.M_dest_map, ←q.P.comp_map, ←q.P.comp_map],\n      rw [←append_fun_comp, id_comp, hu, hu, ←comp_id g, append_fun_comp],\n      rw [q.P.comp_map, q.P.comp_map, abs_map, pr ra₁a₂, ←abs_map] },\n    show r' (g <$$> a₁) (g <$$> a₂), from ⟨a₁, a₂, ra₁a₂, rfl, rfl⟩\n  end\n\ninstance cofix.mvfunctor : mvfunctor (cofix F) :=\n{ map := @cofix.map _ _ _ _}\n\ndef cofix.corec {α : typevec n} {β : Type u} (g : β → F (α.append1 β)) : β → cofix F α :=\nλ x, quot.mk  _ (corecF g x)\n\ndef cofix.dest {α : typevec n} : cofix F α → F (α.append1 (cofix F α)) :=\nquot.lift\n  (λ x, append_fun id (quot.mk Mcongr) <$$> (abs (q.P.M_dest x)))\n  begin\n    rintros x y ⟨r, pr, rxy⟩, dsimp,\n    have : ∀ x y, r x y → Mcongr x y,\n    { intros x y h, exact ⟨r, pr, h⟩ },\n    rw [←quot.factor_mk_eq _ _ this], dsimp,\n    conv { to_lhs,\n      rw [append_fun_comp_id, comp_map, ←abs_map, pr rxy, abs_map, ←comp_map,\n        ←append_fun_comp_id] }\n  end\n\ntheorem cofix.dest_corec {α : typevec n} {β : Type u} (g : β → F (α.append1 β)) (x : β) :\n  cofix.dest (cofix.corec g x) = append_fun id (cofix.corec g) <$$> g x :=\nbegin\n  conv { to_lhs, rw [cofix.dest, cofix.corec] }, dsimp,\n  rw [corecF_eq, abs_map, abs_repr, ←comp_map, ←append_fun_comp], reflexivity\nend\n\ndef cofix.mk {α : typevec n} : F (α.append1 $ cofix F α) → cofix F α :=\ncofix.corec (λ x, append_fun id (λ i : cofix F α, cofix.dest.{u} i) <$$> x)\n\nprivate theorem cofix.bisim_aux {α : typevec n}\n    (r : cofix F α → cofix F α → Prop)\n    (h' : ∀ x, r x x)\n    (h : ∀ x y, r x y →\n      append_fun id (quot.mk r) <$$> cofix.dest x = append_fun id (quot.mk r) <$$> cofix.dest y) :\n  ∀ x y, r x y → x = y :=\nbegin\n  intro x, apply quot.induction_on x, clear x,\n  intros x y, apply quot.induction_on y, clear y,\n  intros y rxy,\n  apply quot.sound,\n  let r' := λ x y, r (quot.mk _ x) (quot.mk _ y),\n  have : is_precongr r',\n  { intros a b r'ab,\n      have  h₀ :\n          append_fun id (quot.mk r ∘ quot.mk Mcongr) <$$> abs (q.P.M_dest a) =\n          append_fun id (quot.mk r ∘ quot.mk Mcongr) <$$> abs (q.P.M_dest b) :=\n        by rw [append_fun_comp_id, comp_map, comp_map]; exact h _ _ r'ab,\n    have h₁ : ∀ u v : q.P.M α, Mcongr u v → quot.mk r' u = quot.mk r' v,\n    { intros u v cuv, apply quot.sound, dsimp [r'], rw quot.sound cuv, apply h' },\n    let f : quot r → quot r' := quot.lift (quot.lift (quot.mk r') h₁)\n      begin\n        intro c, apply quot.induction_on c, clear c,\n        intros c d, apply quot.induction_on d, clear d,\n        intros d rcd, apply quot.sound, apply rcd\n      end,\n    have : f ∘ quot.mk r ∘ quot.mk Mcongr = quot.mk r' := rfl,\n    rw [←this, append_fun_comp_id, q.P.comp_map, q.P.comp_map, abs_map, abs_map, abs_map,\n         abs_map, h₀] },\n  refine ⟨r', this, rxy⟩\nend\n\ntheorem cofix.bisim_rel {α : typevec n}\n    (r : cofix F α → cofix F α → Prop)\n    (h : ∀ x y, r x y →\n      append_fun id (quot.mk r) <$$> cofix.dest x = append_fun id (quot.mk r) <$$> cofix.dest y) :\n  ∀ x y, r x y → x = y :=\nlet r' x y := x = y ∨ r x y in\nbegin\n  intros x y rxy,\n  apply cofix.bisim_aux r',\n  { intro x, left, reflexivity },\n  { intros x y r'xy,\n    cases r'xy, { rw r'xy },\n    have : ∀ x y, r x y → r' x y := λ x y h, or.inr h,\n    rw ←quot.factor_mk_eq _ _ this, dsimp,\n    rw [append_fun_comp_id, append_fun_comp_id],\n    rw [@comp_map _ _ _ q _ _ _ (append_fun id (quot.mk r)),\n        @comp_map _ _ _ q _ _ _ (append_fun id (quot.mk r))],\n    rw h _ _ r'xy },\n  right, exact rxy\nend\n\ntheorem cofix.bisim {α : typevec n}\n    (r : cofix F α → cofix F α → Prop)\n    (h : ∀ x y, r x y → liftr (rel_last α r) (cofix.dest x) (cofix.dest y)) :\n  ∀ x y, r x y → x = y :=\nbegin\n  apply cofix.bisim_rel,\n  intros x y rxy,\n  rcases (liftr_iff (rel_last α r) _ _).mp (h x y rxy) with ⟨a, f₀, f₁, dxeq, dyeq, h'⟩,\n  rw [dxeq, dyeq, ←abs_map, ←abs_map, mvpfunctor.map_eq, mvpfunctor.map_eq],\n  rw [←split_drop_fun_last_fun f₀, ←split_drop_fun_last_fun f₁],\n  rw [append_fun_comp_split_fun, append_fun_comp_split_fun],\n  rw [id_comp, id_comp],\n  congr' 2, ext i j, cases i with _ i; dsimp,\n  { change f₀ _ j = f₁ _ j, apply h' _ j },\n  apply quot.sound,\n  apply h' _ j\nend\n\ntheorem cofix.bisim' {α : typevec n} {β : Type*} (Q : β → Prop) (u v : β → cofix F α)\n    (h : ∀ x, Q x → ∃ a f' f₀ f₁,\n      cofix.dest (u x) = abs ⟨a, q.P.append_contents f' f₀⟩ ∧\n      cofix.dest (v x) = abs ⟨a, q.P.append_contents f' f₁⟩ ∧\n      ∀ i, ∃ x', Q x' ∧ f₀ i = u x' ∧ f₁ i = v x') :\n  ∀ x, Q x → u x = v x :=\nλ x Qx,\nlet R := λ w z : cofix F α, ∃ x', Q x' ∧ w = u x' ∧ z = v x' in\ncofix.bisim R\n  (λ x y ⟨x', Qx', xeq, yeq⟩,\n    begin\n      rcases h x' Qx' with ⟨a, f', f₀, f₁, ux'eq, vx'eq, h'⟩,\n      rw liftr_iff,\n      refine ⟨a, q.P.append_contents f' f₀, q.P.append_contents f' f₁,\n        xeq.symm ▸ ux'eq, yeq.symm ▸ vx'eq, _⟩,\n      intro i, cases i,\n      { intro j, apply eq.refl },\n      apply h',\n    end)\n  _ _ ⟨x, Qx, rfl, rfl⟩\n\nlemma cofix.mk_dest {α : typevec n} (x : cofix F α) : cofix.mk (cofix.dest x) = x :=\nbegin\n  apply cofix.bisim_rel (λ x y : cofix F α, x = cofix.mk (cofix.dest y)) _ _ _ rfl, dsimp,\n  intros x y h, rw h,\n  conv { to_lhs, congr, skip, rw [cofix.mk], rw cofix.dest_corec},\n  rw [←comp_map, ←append_fun_comp, id_comp],\n  rw [←comp_map, ←append_fun_comp, id_comp, ←cofix.mk],\n  congr' 2,\n  ext u, apply quot.sound, refl\nend\n\nlemma cofix.dest_mk {α : typevec n} (x : F (α.append1 $ cofix F α)) : cofix.dest (cofix.mk x) = x :=\nbegin\n  have : cofix.mk ∘ cofix.dest = @_root_.id (cofix F α) := funext cofix.mk_dest,\n  rw [cofix.mk, cofix.dest_corec, ←comp_map, ←cofix.mk, ← append_fun_comp, this, id_comp, append_fun_id_id, id_map]\nend\n\nnoncomputable instance mvqpf_cofix : mvqpf (cofix F) :=\n{ P         := q.P.Mp,\n  abs       := λ α, quot.mk Mcongr,\n  repr'     := λ α, quot.out,\n  abs_repr' := λ α, quot.out_eq,\n  abs_map   := λ α β g x, rfl\n}\n\nend mvqpf\n", "meta": {"author": "avigad", "repo": "qpf", "sha": "debe2eacb8cf46b21aba2eaf3f2e20940da0263b", "save_path": "github-repos/lean/avigad-qpf", "path": "github-repos/lean/avigad-qpf/qpf-debe2eacb8cf46b21aba2eaf3f2e20940da0263b/src/mvqpf/cofix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.45519271040258225}}
{"text": "import SciLean.Core.Functions\nimport SciLean.Tactic.RemoveLambdaLet\n\nopen Function\n\nopen SciLean\n\nvariable {α β γ : Type}\nvariable {X Y Z : Type} [Hilbert X] [Hilbert Y] [Hilbert Z] \n\nexample (f : Y → Z) (g : X → Y) (z : Z) [HasAdjoint f] [HasAdjoint g] : (f ∘ g)† z = g† (f† z) := by simp; done\nexample (f g : X → Y) [HasAdjoint f] [HasAdjoint g] (y : Y) : (λ x => f x + g x)† y = f† y + g† y := by simp; done\n\nexample (y : Y) (r : ℝ) \n  : (λ x => ⟪x,y⟫)† r = r*y := by simp; done\nexample (y : X) (r : ℝ) \n  : (λ x => ⟪x,y⟫ + ⟪y,x⟫)† r = r * y + r * y := by simp; done\nexample (r : ℝ) (x' : X) \n  : (λ x : X => r*((λ x'' => ⟪x', x''⟫) x))† = λ s => (r * s) * x' := by simp; done\n\nexample {n : Nat} (a : Fin n) [Nonempty (Fin n)] \n  : (λ (f : Fin n → ℝ) i => f (i - a))† = (λ (f : Fin n → ℝ) x => f (x + a)) := \n  by funext f i; simp[sum_into_lambda]; done\nexample {ι} [Enumtype ι] \n  : (λ x : ι → X => sum x)† = (λ (x : X) (i : ι) => x) := by simp done\nexample {n} (c : Fin n)  [Nonempty (Fin n)] \n  : (λ (g : Fin n → ℝ) => (λ i => g (i+c)))† = (fun f x => f (x - c)) := by simp[Function.comp,sum_into_lambda]; done\n\nexample {ι} [Enumtype ι] (f : ι → X → Y) [∀ i, HasAdjoint (f i)] \n  : (λ x i => f i x)† = (λ y => ∑ i, (f i)† (y i)) := by funext y; simp done\nexample {ι} [Enumtype ι] [Nonempty ι] (f : ι → X → Y) [∀ i, HasAdjoint (f i)] \n  : (λ (g : ι → X) i => f i (g i))† = (λ h i => (1:ℝ) * ((f i)† (h i))) := by funext h i; simp[sum_into_lambda]; done\n\nexample (y : ℝ) : (λ x : ℝ => x * y)† 1 = ⟪1,y⟫ := by simp done\nexample (y : ℝ) : (λ x : ℝ => y * x)† 1 = y := by simp done\n\n-- set_option trace.Meta.Tactic.simp.discharge true in\nexample (a b : ℝ) (x : X)\n  : (λ dx : X => (a * ⟪x, dx⟫) * b)† 1 = (a * ⟪1,b⟫) * x := \nby simp; unfold hold; simp done\n\nexample {ι} [Enumtype ι] [Nonempty ι] (i : ι) (c : ℝ)\n  : (fun (x : ι → ℝ) => x i * c)† 1 = (fun j => kron i j * ⟪1,c⟫)\n  := by simp; unfold hold; simp done\n\nexample -- [NonZero n]\n  : (λ (x : Fin n → ℝ) => sum λ i => x i)† 1 = (λ i => (1 : ℝ)) := by simp done\n\nexample {n} (f : Fin n → ℝ) (c : Fin n) [Nonempty (Fin n)] \n  : (λ (g : Fin n → ℝ) => sum (λ i => (f i) * (g (i+c))))† (1 : ℝ) = (fun i => f (i - c)) := by funext i; simp[sum_into_lambda]; done\n\n-- set_option trace.Meta.Tactic.simp.discharge true in\n-- set_option trace.Meta.Tactic.simp.rewrite true in\n-- example {n} (f : Fin n → ℝ) [Nonempty (Fin n)] \n--   : (fun df : Fin n → ℝ => ∑ i, df i * f i + f i * df i)† 1 = λ i => ⟪1,f i⟫ + f i := by funext i; simp; unfold hold; simp; simp only [sum_into_lambda]; done\n\n-- example {n} (f : Fin n → ℝ) (i : Fin n) [Nonempty (Fin n)]\n--   : (λ (x : Fin n → ℝ) => x i * f i)† = λ (y : ℝ) j => kron i j * ⟪y, f i⟫\n--   := by funext x j; simp; unfold hold; simp done\n\n\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (Prod.fst : X × Y → X)† = λ x : X => (x, 0) := by simp\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (Prod.snd : X × Y → Y)† = λ y : Y => (0, y) := by simp\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (λ ((x,y) : X × Y) => x)† = λ x : X => (x, (0:Y)) := by simp\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (λ ((x,y) : X × Y) => y)† = λ y : Y => ((0:X), y) := by simp\n\n\nset_option trace.Meta.Tactic.simp.discharge true in\nexample : (λ (x : Fin n → ℝ) => Function.comp (HMul.hMul 2) x)† = 0 := by rw[Function.comp.arg_g.adj_simp]; simp[comp]; admit\n\n@[simp (low-2) ↓]\ntheorem asdf {ι : Type} [Enumtype ι] (f : Y → Z) [HasAdjoint f] \n  : (λ (g : ι → Y) i => f (g i))† = λ (g' : ι → Z) i => f† (g' i)  := sorry\n\nexample : (λ (x : Fin n → ℝ) => ∑ i, x i)† = 0 := by simp; admit\nexample : (λ (x : Fin n → ℝ) => ∑ i, 1 * x i)† = 0 := by simp; admit\n\nexample : HasAdjoint (λ x : ℝ => 2 * x) := by infer_instance\n\nset_option synthInstance.maxSize 2000 in\nset_option synthInstance.maxHeartbeats 200000 in\nset_option pp.funBinderTypes true in\nset_option trace.Meta.Tactic.simp.rewrite true in\nset_option trace.Meta.Tactic.simp.discharge true in\n-- set_option trace.Meta.Tactic.simp.unify true in\nexample : (λ (x : Fin n → ℝ) i => 2 * x i)† = 0 := \nby\n  simp -- [-SciLean.swap.arg_y.adj_simp] \n  simp; admit\n\n\nexample : (λ (x : Fin n → ℝ) i => 2 * x i)† = 0 := by simp; admit\n\nexample : (λ (x : Fin n → ℝ) => ∑ i, 2 * x i)† = 0 := by simp; admit\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/test/basic_adjoint_tests.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147275, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.4551927104025821}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport data.list.chain\nimport category_theory.is_connected\nimport category_theory.sigma.basic\nimport category_theory.full_subcategory\n\n/-!\n# Connected components of a category\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nDefines a type `connected_components J` indexing the connected components of a category, and the\nfull subcategories giving each connected component: `component j : Type u₁`.\nWe show that each `component j` is in fact connected.\n\nWe show every category can be expressed as a disjoint union of its connected components, in\nparticular `decomposed J` is the category (definitionally) given by the sigma-type of the connected\ncomponents of `J`, and it is shown that this is equivalent to `J`.\n-/\n\nuniverses v₁ v₂ v₃ u₁ u₂\n\nnoncomputable theory\n\nopen category_theory.category\n\nnamespace category_theory\n\nattribute [instance, priority 100] is_connected.is_nonempty\n\nvariables {J : Type u₁} [category.{v₁} J]\nvariables {C : Type u₂} [category.{u₁} C]\n\n/-- This type indexes the connected components of the category `J`. -/\ndef connected_components (J : Type u₁) [category.{v₁} J] : Type u₁ := quotient (zigzag.setoid J)\n\ninstance [inhabited J] : inhabited (connected_components J) := ⟨quotient.mk' default⟩\n\n/-- Given an index for a connected component, produce the actual component as a full subcategory. -/\n@[derive category]\ndef component (j : connected_components J) : Type u₁ := full_subcategory (λ k, quotient.mk' k = j)\n\n/-- The inclusion functor from a connected component to the whole category. -/\n@[derive [full, faithful], simps {rhs_md := semireducible}]\ndef component.ι (j) : component j ⥤ J :=\nfull_subcategory_inclusion _\n\n/-- Each connected component of the category is nonempty. -/\ninstance (j : connected_components J) : nonempty (component j) :=\nbegin\n  apply quotient.induction_on' j,\n  intro k,\n  refine ⟨⟨k, rfl⟩⟩,\nend\n\ninstance (j : connected_components J) : inhabited (component j) := classical.inhabited_of_nonempty'\n\n/-- Each connected component of the category is connected. -/\ninstance (j : connected_components J) : is_connected (component j) :=\nbegin\n  -- Show it's connected by constructing a zigzag (in `component j`) between any two objects\n  apply is_connected_of_zigzag,\n  rintro ⟨j₁, hj₁⟩ ⟨j₂, rfl⟩,\n  -- We know that the underlying objects j₁ j₂ have some zigzag between them in `J`\n  have h₁₂ : zigzag j₁ j₂ := quotient.exact' hj₁,\n  -- Get an explicit zigzag as a list\n  rcases list.exists_chain_of_relation_refl_trans_gen h₁₂ with ⟨l, hl₁, hl₂⟩,\n  -- Everything which has a zigzag to j₂ can be lifted to the same component as `j₂`.\n  let f : Π x, zigzag x j₂ → component (quotient.mk' j₂) := λ x h, ⟨x, quotient.sound' h⟩,\n  -- Everything in our chosen zigzag from `j₁` to `j₂` has a zigzag to `j₂`.\n  have hf : ∀ (a : J), a ∈ l → zigzag a j₂,\n  { intros i hi,\n    apply list.chain.induction (λ t, zigzag t j₂) _ hl₁ hl₂ _ _ _ (or.inr hi),\n    { intros j k,\n      apply relation.refl_trans_gen.head },\n    { apply relation.refl_trans_gen.refl } },\n  -- Now lift the zigzag from `j₁` to `j₂` in `J` to the same thing in `component j`.\n  refine ⟨l.pmap f hf, _, _⟩,\n  { refine @@list.chain_pmap_of_chain _ _ _ f (λ x y _ _ h, _) hl₁ h₁₂ _,\n    exact zag_of_zag_obj (component.ι _) h },\n  { erw list.last_pmap _ f (j₁ :: l) (by simpa [h₁₂] using hf) (list.cons_ne_nil _ _),\n    exact full_subcategory.ext _ _ hl₂ },\nend\n\n/--\nThe disjoint union of `J`s connected components, written explicitly as a sigma-type with the\ncategory structure.\nThis category is equivalent to `J`.\n-/\nabbreviation decomposed (J : Type u₁) [category.{v₁} J] :=\nΣ (j : connected_components J), component j\n\n/--\nThe inclusion of each component into the decomposed category. This is just `sigma.incl` but having\nthis abbreviation helps guide typeclass search to get the right category instance on `decomposed J`.\n-/\n-- This name may cause clashes further down the road, and so might need to be changed.\nabbreviation inclusion (j : connected_components J) : component j ⥤ decomposed J :=\nsigma.incl _\n\n/-- The forward direction of the equivalence between the decomposed category and the original. -/\n@[simps {rhs_md := semireducible}]\ndef decomposed_to (J : Type u₁) [category.{v₁} J] : decomposed J ⥤ J :=\nsigma.desc component.ι\n\n@[simp]\nlemma inclusion_comp_decomposed_to (j : connected_components J) :\n  inclusion j ⋙ decomposed_to J = component.ι j :=\nrfl\n\ninstance : full (decomposed_to J) :=\n{ preimage :=\n  begin\n    rintro ⟨j', X, hX⟩ ⟨k', Y, hY⟩ f,\n    dsimp at f,\n    have : j' = k',\n      rw [← hX, ← hY, quotient.eq'],\n      exact relation.refl_trans_gen.single (or.inl ⟨f⟩),\n    subst this,\n    refine sigma.sigma_hom.mk f,\n  end,\n  witness' :=\n  begin\n    rintro ⟨j', X, hX⟩ ⟨_, Y, rfl⟩ f,\n    have : quotient.mk' Y = j',\n    { rw [← hX, quotient.eq'],\n      exact relation.refl_trans_gen.single (or.inr ⟨f⟩) },\n    subst this,\n    refl,\n  end }\n\ninstance : faithful (decomposed_to J) :=\n{ map_injective' :=\n  begin\n    rintro ⟨_, j, rfl⟩ ⟨_, k, hY⟩ ⟨f⟩ ⟨g⟩ e,\n    change f = g at e,\n    subst e,\n  end }\n\ninstance : ess_surj (decomposed_to J) :=\n{ mem_ess_image := λ j, ⟨⟨_, j, rfl⟩, ⟨iso.refl _⟩⟩ }\n\ninstance : is_equivalence (decomposed_to J) :=\nequivalence.of_fully_faithfully_ess_surj _\n\n/-- This gives that any category is equivalent to a disjoint union of connected categories. -/\n@[simps functor {rhs_md := semireducible}]\ndef decomposed_equiv : decomposed J ≌ J :=\n(decomposed_to J).as_equivalence\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/connected_components.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872019117029, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.45519270359491665}}
{"text": "import kassel.lemma.right_pivotal_category\n\nopen category_theory\nopen category_theory.monoidal_category\n\nnamespace kassel\nopen right_pivotal_category\n\nnamespace FinVect\n\nvariables {K: Type*} [field K]\n\nnoncomputable instance finite_dimensional.decidable_eq (V) [add_comm_group V] [module K V] [finite_dimensional K V]:\n  decidable_eq (basis.of_vector_space_index K V) :=\n  equiv.decidable_eq (fintype.equiv_fin (basis.of_vector_space_index K V))\n\nlemma dual_mul {V} [add_comm_monoid V] [module K V] (f: module.dual K V) (x: V) (t: K):\n  f x * t = f (t • x) :=\nby rw [map_smul, smul_eq_mul, mul_comm]\n\nlemma right_adjoint_mate_eq_dual_linear_map {X Y: FinVect K} (f: X.obj →ₗ[K] Y.obj):\n  left_unitor.hom K (module.dual K X.obj) ∘ₗ\n  tensor_product.map (evaluation.hom K Y.obj) linear_map.id ∘ₗ\n  associator.inv K _ _ _ ∘ₗ\n  tensor_product.map linear_map.id (tensor_product.map f linear_map.id) ∘ₗ\n  tensor_product.map linear_map.id (coevaluation.hom K X.obj) ∘ₗ\n  right_unitor.inv K (module.dual K Y.obj) =\n  f.dual_map :=\nbegin\n  ext g x,\n  have b := basis.of_vector_space K X.obj,\n  simp [\n    map_sum, tensor_product.tmul_sum, tensor_product.map_tmul,\n    coevaluation_apply_one' b, linear_map.id_apply\n  ],\n  simp_rw [dual_mul, ←map_sum], congr,\n  simp_rw [←map_smul, ←map_sum], congr,\n  rw basis.sum_repr,\nend\n\nlemma right_adjoint_mate_eq_dual {X Y: FinVect K} (f: X ⟶ Y):\n  fᘁ = f.dual_map :=\nby apply right_adjoint_mate_eq_dual_linear_map\n\nlemma tensor_iso_dual_tensor_dual_apply {X Y: FinVect K} (f: module.dual K X.obj) (g: module.dual K Y.obj):\n  ((δ_ X Y).inv: _ →ₗ[K] _) (g ⊗ₜ[K] f) = ↑(tensor_product.lid K K) ∘ₗ tensor_product.map f g :=\nbegin\n  sorry,\nend\n\nlemma module.eval_equiv_to_linear_map' (V) [add_comm_group V] [module K V] [finite_dimensional K V]:\n  ⇑(module.eval_equiv K V) = module.dual.eval K V :=\nby rw [←module.eval_equiv_to_linear_map, linear_equiv.coe_to_linear_map]\n\nnoncomputable def right_pivotor (X: FinVect K): X ≅ Xᘁᘁ := {\n  hom := right_pivotor.hom K X.obj,\n  inv := right_pivotor.inv K X.obj,\n  hom_inv_id' := by ext; simp [←module.eval_equiv_to_linear_map],\n  inv_hom_id' := by ext; simp [←module.eval_equiv_to_linear_map]\n}\n\nlemma right_pivotor_naturality (X Y: FinVect K) (f: X ⟶ Y):\n  f ≫ (right_pivotor Y).hom = (right_pivotor X).hom ≫ fᘁᘁ :=\nbegin\n  unfold_projs at *, dsimp [right_pivotor],\n  ext x g, simp [right_adjoint_mate_eq_dual, module.eval_equiv_to_linear_map'],\nend\n\nlemma right_pivotor_tensor_naturality (X Y: FinVect K):\n  (right_pivotor (X ⊗ Y)).hom = ((right_pivotor X).hom ⊗ (right_pivotor Y).hom) ≫ (δ_ _ _).inv ≫ ((δ_ _ _).hom)ᘁ :=\nbegin\n  ext x y f, unfold_projs, dsimp [right_pivotor],\n  simp_rw module.eval_equiv_to_linear_map',\n  simp [module.dual.eval_apply, tensor_iso_dual_tensor_dual_apply, right_adjoint_mate_eq_dual],\n\nend\n\nnoncomputable instance right_pivotal_category: right_pivotal_category (FinVect K) := {\n  right_pivotor := right_pivotor,\n  right_pivotor_naturality' := right_pivotor_naturality,\n  right_pivotor_tensor_naturality' := right_pivotor_tensor_naturality\n}\n\nend FinVect\nend kassel\n", "meta": {"author": "youjo-tape", "repo": "lean-univ", "sha": "f8a9e82134c930715fc39f44ba0e5a98184673a7", "save_path": "github-repos/lean/youjo-tape-lean-univ", "path": "github-repos/lean/youjo-tape-lean-univ/lean-univ-f8a9e82134c930715fc39f44ba0e5a98184673a7/src/kassel/lemma/FinVect_right_pivotal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4551663054644473}}
{"text": "import data.nat.basic data.complex.basic data.rea l.cau_seq .exponential.series\nlocal attribute [instance, priority 0] classical.prop_decidable\nnoncomputable theory\nopen nat is_absolute_value\n\n\n\nlemma series_series_diag {α : Type*} [add_comm_monoid α] (f : ℕ → ℕ → α) (n : ℕ) : series (λ i, \nseries (λ k, f k (i - k)) i) n = series (λ i, series (λ k, f i k) (n - i)) n := begin\n  have : ∀ m : ℕ, m ≤ n → series (λ (i : ℕ), series (λ k, f k (i - k)) (min m i)) n =\n      series (λ i, series (λ k, f i k) (n - i)) m,\n    assume m mn, induction m with m' hi,\n    simp[series_succ,series_zero,mul_add,max_eq_left (zero_le n)],\n    simp only [series_succ _ m'],rw ←hi (le_of_succ_le mn),clear hi,\n    induction n with n' hi,\n    simp[series_succ],exact absurd mn dec_trivial,cases n' with n₂,\n    simp [series_succ],rw [min_eq_left mn,series_succ,min_eq_left (le_of_succ_le mn)],\n    rw eq_zero_of_le_zero (le_of_succ_le_succ mn),simp,\n    cases lt_or_eq_of_le mn,\n    simp [series_succ _ (succ n₂),min_eq_left mn,hi (le_of_lt_succ h)],rw [←add_assoc,←add_assoc],\n    suffices : series (f (succ m')) (n₂ - m') + series (λ (k : ℕ), f k (succ (succ n₂) - k)) (succ m')\n    = series (f (succ m')) (succ n₂ - m') +\n        series (λ (k : ℕ), f k (succ (succ n₂) - k)) (min m' (succ (succ n₂))),\n      rw this,rw[min_eq_left (le_of_succ_le mn),series_succ,succ_sub_succ,succ_sub (le_of_succ_le_succ (le_of_lt_succ h)),series_succ],\n      rw [add_comm (series (λ (k : ℕ), f k (succ (succ n₂) - k)) m'),add_assoc],      \n    rw ←h,simp[nat.sub_self],clear hi mn h,simp[series_succ,nat.sub_self],\n    suffices : series (λ (i : ℕ), series (λ (k : ℕ), f k (i - k)) (min (succ m') i)) m' = series (λ (i : ℕ), series (λ (k : ℕ), f k (i - k)) (min m' i)) m',\n      rw [this,min_eq_left (le_succ _)],clear n₂,\n    have h₁ : ∀ i ≤ m', (λ (i : ℕ), series (λ (k : ℕ), f k (i - k)) (min (succ m') i)) i = (λ (i : ℕ), series (λ (k : ℕ), f k (i - k)) (min m' i)) i,\n      assume i im,simp, rw [min_eq_right im,min_eq_right (le_succ_of_le im)],\n    rw series_congr h₁,\n  specialize this n (le_refl _),\n  rw ←this,refine series_congr _,assume i ni,rw min_eq_right ni,\nend\n\nlemma series_merten {α β : Type*} [discrete_linear_ordered_field α] [ring β] {a b : ℕ → β}\n{abv : β → α} [is_absolute_value abv] : is_cau_seq abs (series (λ n, abv (a n))) → is_cau_seq abv (series b) → \n∀ ε : α, 0 < ε → ∃ i : ℕ, ∀ j ≥ i, abv (series a j * series b j - series (λ n, \nseries (λ m, a m * b (n - m)) n) j) < ε := begin\n  assume ha hb ε ε0,\n  cases seq_bounded_above_of_cau hb with Q hQ,\n  cases seq_bounded_above_of_cau ha with P hP,\n  have P0 : 0 < P,exact lt_of_le_of_lt (abs_nonneg _) (hP 0),\n  have Pε0 := div_pos ε0 (mul_pos (show (2 : α) > 0, from by norm_num) P0),\n  cases cau_seq.cauchy₂ ⟨_, hb⟩ Pε0 with N hN,simp at hN,\n  have Qε0 := div_pos ε0 (mul_pos (show (4 : α) > 0, from by norm_num) (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))),\n  cases cau_seq.cauchy₂ ⟨_, ha⟩ Qε0 with M hM,simp at hM,\n  existsi 2 * (max N M + 1),\n  assume K hK,have := diag_swap1 (λ m n, a m * b n) K,simp at this,rw this,clear this,\n  have : (λ (i : ℕ), series (λ (k : ℕ), a i * b k) (K - i)) = (λ (i : ℕ), a i * series (λ (k : ℕ), b k) (K - i)),\n    {apply funext,assume i,rw series_mul_left},\n  rw this,clear this,simp,\n  have : series (λ (i : ℕ), a i * series b (K - i)) K = series (λ (i : ℕ), a i * (series b (K - i) - series b K))\n  K + series (λ i, a i * series b K) K,\n    {rw ←series_add,simp[(mul_add _ _ _).symm]},\n  rw this, clear this,\n  rw series_mul_series,simp,\n  rw abv_neg abv,\n  refine lt_of_le_of_lt (abv_series_le_series_abv _) _,\n  simp [abv_mul abv],\n  suffices : series (λ (i : ℕ), abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 1) + \n  (series (λ (i : ℕ), abv (a i) * abv (series b (K - i) + -series b K)) K -series (λ (i : ℕ), \n  abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 1)) < ε / (2 * P) * P + ε / (4 * Q) * (2 * Q),\n  { simp [(div_div_eq_div_mul _ _ _).symm] at this,\n    rwa[div_mul_cancel _ (ne_of_lt P0).symm,(by norm_num : (4 : α) = 2 * 2),←div_div_eq_div_mul,mul_comm (2 : α),←mul_assoc,\n    div_mul_cancel _ (ne_of_lt (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))).symm,div_mul_cancel,add_halves] at this,\n    norm_num},\n  refine add_lt_add _ _,\n  {have : series (λ (i : ℕ), abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 1) ≤ series\n  (λ (i : ℕ), abv (a i) * (ε / (2 * P))) (max N M + 1),\n    {refine series_le_series _,assume m mJ,refine mul_le_mul_of_nonneg_left _ _,\n      {refine le_of_lt (hN (K - m) K _ _),{\n      refine nat.le_sub_left_of_add_le (le_trans _ hK),\n      rw[succ_mul,one_mul],\n      exact add_le_add mJ (le_trans (le_max_left _ _) (le_of_lt (lt_add_one _)))},\n      {refine le_trans _ hK,rw ←one_mul N,\n      refine mul_le_mul (by norm_num) (by rw one_mul;exact le_trans (le_max_left _ _) \n      (le_of_lt (lt_add_one _))) (zero_le _) (zero_le _)}},\n      exact abv_nonneg abv _},\n  refine lt_of_le_of_lt this _,\n  rw [series_mul_right,mul_comm],\n  specialize hP (max N M + 1),rwa abs_of_nonneg at hP,\n  refine (mul_lt_mul_left Pε0).mpr hP,\n  refine series_nonneg _,assume x h,exact abv_nonneg abv _},\n  {have hNMK : max N M + 1 < K,\n    {refine lt_of_lt_of_le _ hK,\n    rw [succ_mul,one_mul,←add_zero (max N M + 1)],\n    refine add_lt_add_of_le_of_lt (le_refl _) _,rw add_zero,\n    refine add_pos_of_nonneg_of_pos (zero_le _) (by norm_num)},\n  rw series_sub_series _ hNMK,\n  have : nat.sum (λ (i : ℕ), abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 2) K \n  ≤ nat.sum (λ (i : ℕ), abv (a i) * (2 * Q)) (max N M + 2) K,\n    {unfold nat.sum,refine series_le_series _,\n    assume m hm,\n    refine mul_le_mul_of_nonneg_left _ _,\n    {refine le_trans (abv_add abv _ _) _,\n    rw ←(by ring : Q + Q = 2 * Q),\n    refine add_le_add (le_of_lt (hQ _)) _,\n    rw abv_neg abv, exact le_of_lt (hQ _)},\n    exact abv_nonneg abv _},\n  refine lt_of_le_of_lt this _,\n  rw [←series_sub_series _ hNMK,series_mul_right,series_mul_right,←sub_mul],\n  refine (mul_lt_mul_right (mul_pos (by norm_num) (lt_of_le_of_lt (abv_nonneg abv _) (hQ 0)))).mpr _,\n  refine lt_of_le_of_lt (le_abs_self _) _,\n  refine hM _ _ _ (le_trans (le_max_right _ _) (le_of_lt (lt_add_one _))),\n  refine le_trans _ hK,\n  rw [succ_mul,one_mul,←add_zero M],\n  exact add_le_add (le_trans (le_max_right _ _) (le_of_lt (lt_add_one _))) (zero_le _)},\nend\n#print series_merten", "meta": {"author": "ChrisHughes24", "repo": "leanstuff", "sha": "9efa85f72efaccd1d540385952a6acc18fce8687", "save_path": "github-repos/lean/ChrisHughes24-leanstuff", "path": "github-repos/lean/ChrisHughes24-leanstuff/leanstuff-9efa85f72efaccd1d540385952a6acc18fce8687/mertens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.4551650537301614}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen,\n  Frédéric Dupuis, Heather Macbeth\n-/\nimport algebra.module.linear_map\n\n/-!\n# (Semi)linear equivalences\n\nIn this file we define\n\n* `linear_equiv σ M M₂`, `M ≃ₛₗ[σ] M₂`: an invertible semilinear map. Here, `σ` is a `ring_hom`\n  from `R` to `R₂` and an `e : M ≃ₛₗ[σ] M₂` satisfies `e (c • x) = (σ c) • (e x)`. The plain\n  linear version, with `σ` being `ring_hom.id R`, is denoted by `M ≃ₗ[R] M₂`, and the\n  star-linear version (with `σ` begin `star_ring_aut`) is denoted by `M ≃ₗ⋆[R] M₂`.\n\n## Implementation notes\n\nTo ensure that composition works smoothly for semilinear equivalences, we use the typeclasses\n`ring_hom_comp_triple`, `ring_hom_inv_pair` and `ring_hom_surjective` from\n`algebra/ring/comp_typeclasses`.\n\nThe group structure on automorphisms, `linear_equiv.automorphism_group`, is provided elsewhere.\n\n## TODO\n\n* Parts of this file have not yet been generalized to semilinear maps\n\n## Tags\n\nlinear equiv, linear equivalences, linear isomorphism, linear isomorphic\n-/\n\nopen function\nopen_locale big_operators\n\nuniverses u u' v w x y z\nvariables {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*}\nvariables {k : Type*} {S : Type*} {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*}\nvariables {N₁ : Type*} {N₂ : Type*} {N₃ : Type*} {N₄ : Type*} {ι : Type*}\n\nsection\nset_option old_structure_cmd true\n\n/-- A linear equivalence is an invertible linear map. -/\n@[nolint has_inhabited_instance]\nstructure linear_equiv {R : Type*} {S : Type*} [semiring R] [semiring S] (σ : R →+* S)\n  {σ' : S →+* R} [ring_hom_inv_pair σ σ'] [ring_hom_inv_pair σ' σ]\n  (M : Type*) (M₂ : Type*)\n  [add_comm_monoid M] [add_comm_monoid M₂] [module R M] [module S M₂]\n  extends linear_map σ M M₂, M ≃+ M₂\nend\n\nattribute [nolint doc_blame] linear_equiv.to_linear_map\nattribute [nolint doc_blame] linear_equiv.to_add_equiv\n\nnotation M ` ≃ₛₗ[`:50 σ `] ` M₂ := linear_equiv σ M M₂\nnotation M ` ≃ₗ[`:50 R `] ` M₂ := linear_equiv (ring_hom.id R) M M₂\nnotation M ` ≃ₗ⋆[`:50 R `] ` M₂ := linear_equiv (@star_ring_aut R _ _ : R →+* R) M M₂\n\nnamespace linear_equiv\n\nsection add_comm_monoid\n\nvariables {M₄ : Type*}\nvariables [semiring R] [semiring S]\n\nsection\nvariables [add_comm_monoid M] [add_comm_monoid M₁] [add_comm_monoid M₂]\nvariables [module R M] [module S M₂] {σ : R →+* S} {σ' : S →+* R}\nvariables [ring_hom_inv_pair σ σ'] [ring_hom_inv_pair σ' σ]\n\ninclude R\n\ninclude σ'\ninstance : has_coe (M ≃ₛₗ[σ] M₂) (M →ₛₗ[σ] M₂) := ⟨to_linear_map⟩\n-- see Note [function coercion]\ninstance : has_coe_to_fun (M ≃ₛₗ[σ] M₂) (λ _, M → M₂) := ⟨to_fun⟩\n\n@[simp] lemma coe_mk {to_fun inv_fun map_add map_smul left_inv right_inv } :\n  ⇑(⟨to_fun, map_add, map_smul, inv_fun, left_inv, right_inv⟩ : M ≃ₛₗ[σ] M₂) = to_fun :=\nrfl\n\n-- This exists for compatibility, previously `≃ₗ[R]` extended `≃` instead of `≃+`.\n@[nolint doc_blame]\ndef to_equiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂ := λ f, f.to_add_equiv.to_equiv\n\nlemma to_equiv_injective : function.injective (to_equiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂) :=\nλ ⟨_, _, _, _, _, _⟩ ⟨_, _, _, _, _, _⟩ h, linear_equiv.mk.inj_eq.mpr (equiv.mk.inj h)\n\n@[simp] lemma to_equiv_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} : e₁.to_equiv = e₂.to_equiv ↔ e₁ = e₂ :=\nto_equiv_injective.eq_iff\n\nlemma to_linear_map_injective :\n  injective (coe : (M ≃ₛₗ[σ] M₂) → (M →ₛₗ[σ] M₂)) :=\nλ e₁ e₂ H, to_equiv_injective $ equiv.ext $ linear_map.congr_fun H\n\n@[simp, norm_cast] lemma to_linear_map_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} :\n  (e₁ : M →ₛₗ[σ] M₂) = e₂ ↔ e₁ = e₂ :=\nto_linear_map_injective.eq_iff\n\nlemma coe_injective :\n  @injective (M ≃ₛₗ[σ] M₂) (M → M₂) coe_fn :=\nlinear_map.coe_injective.comp to_linear_map_injective\n\nend\n\nsection\nvariables [semiring R₁] [semiring R₂] [semiring R₃]\nvariables [add_comm_monoid M] [add_comm_monoid M₁] [add_comm_monoid M₂]\nvariables [add_comm_monoid M₃] [add_comm_monoid M₄]\nvariables [add_comm_monoid N₁] [add_comm_monoid N₂]\nvariables {module_M : module R M} {module_S_M₂ : module S M₂} {σ : R →+* S} {σ' : S →+* R}\nvariables {re₁ : ring_hom_inv_pair σ σ'} {re₂ : ring_hom_inv_pair σ' σ}\nvariables (e e' : M ≃ₛₗ[σ] M₂)\n\nlemma to_linear_map_eq_coe : e.to_linear_map = (e : M →ₛₗ[σ] M₂) := rfl\n\n@[simp, norm_cast] theorem coe_coe : ⇑(e : M →ₛₗ[σ] M₂) = e := rfl\n\n@[simp] lemma coe_to_equiv : ⇑e.to_equiv = e := rfl\n\n@[simp] lemma coe_to_linear_map : ⇑e.to_linear_map = e := rfl\n\n@[simp] lemma to_fun_eq_coe : e.to_fun = e := rfl\n\nsection\nvariables {e e'}\n@[ext] lemma ext (h : ∀ x, e x = e' x) : e = e' :=\ncoe_injective $ funext h\n\nprotected lemma congr_arg : Π {x x' : M}, x = x' → e x = e x'\n| _ _ rfl := rfl\n\nprotected lemma congr_fun (h : e = e') (x : M) : e x = e' x := h ▸ rfl\n\nlemma ext_iff : e = e' ↔ ∀ x, e x = e' x :=\n⟨λ h x, h ▸ rfl, ext⟩\n\nend\n\nsection\nvariables (M R)\n\n/-- The identity map is a linear equivalence. -/\n@[refl]\ndef refl [module R M] : M ≃ₗ[R] M := { .. linear_map.id, .. equiv.refl M }\n\nend\n\n@[simp] lemma refl_apply [module R M] (x : M) : refl R M x = x := rfl\n\ninclude module_M module_S_M₂ re₁ re₂\n/-- Linear equivalences are symmetric. -/\n@[symm]\ndef symm (e : M ≃ₛₗ[σ] M₂) : M₂ ≃ₛₗ[σ'] M :=\n{ to_fun := e.to_linear_map.inverse e.inv_fun e.left_inv e.right_inv,\n  inv_fun := e.to_equiv.symm.inv_fun,\n  map_smul' := λ r x, by simp,\n  .. e.to_linear_map.inverse e.inv_fun e.left_inv e.right_inv,\n  .. e.to_equiv.symm }\nomit module_M module_S_M₂ re₁ re₂\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply {R : Type*} {S : Type*} [semiring R] [semiring S] {σ : R →+* S}\n  {σ' : S →+* R} [ring_hom_inv_pair σ σ'] [ring_hom_inv_pair σ' σ]\n  {M : Type*} {M₂ : Type*} [add_comm_monoid M] [add_comm_monoid M₂] [module R M] [module S M₂]\n  (e : M ≃ₛₗ[σ] M₂) : M₂ → M := e.symm\n\ninitialize_simps_projections linear_equiv (to_fun → apply, inv_fun → symm_apply)\n\ninclude σ'\n@[simp] lemma inv_fun_eq_symm : e.inv_fun = e.symm := rfl\nomit σ'\n\nvariables {module_M₁ : module R₁ M₁} {module_M₂ : module R₂ M₂} {module_M₃ : module R₃ M₃}\nvariables {module_N₁ : module R₁ N₁} {module_N₂ : module R₁ N₂}\nvariables {σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R₁ →+* R₃}\nvariables {σ₂₁ : R₂ →+* R₁} {σ₃₂ : R₃ →+* R₂} {σ₃₁ : R₃ →+* R₁}\nvariables [ring_hom_comp_triple σ₁₂ σ₂₃ σ₁₃]\nvariables [ring_hom_comp_triple σ₃₂ σ₂₁ σ₃₁]\nvariables {re₁₂ : ring_hom_inv_pair σ₁₂ σ₂₁} {re₂₃ : ring_hom_inv_pair σ₂₃ σ₃₂}\nvariables [ring_hom_inv_pair σ₁₃ σ₃₁] {re₂₁ : ring_hom_inv_pair σ₂₁ σ₁₂}\nvariables {re₃₂ : ring_hom_inv_pair σ₃₂ σ₂₃} [ring_hom_inv_pair σ₃₁ σ₁₃]\nvariables (e₁₂ : M₁ ≃ₛₗ[σ₁₂] M₂) (e₂₃ : M₂ ≃ₛₗ[σ₂₃] M₃)\n\ninclude σ₃₁\n/-- Linear equivalences are transitive. -/\n-- Note: The linter thinks the `ring_hom_comp_triple` argument is doubled -- it is not.\n@[trans, nolint unused_arguments]\ndef trans : M₁ ≃ₛₗ[σ₁₃] M₃ :=\n{ .. e₂₃.to_linear_map.comp e₁₂.to_linear_map,\n  .. e₁₂.to_equiv.trans e₂₃.to_equiv }\nomit σ₃₁\n\ninfixl ` ≪≫ₗ `:80 := @linear_equiv.trans _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n  (ring_hom.id _) (ring_hom.id _) (ring_hom.id _)\n  (ring_hom.id _) (ring_hom.id _) (ring_hom.id _)\n  ring_hom_comp_triple.ids ring_hom_comp_triple.ids\n  ring_hom_inv_pair.ids ring_hom_inv_pair.ids ring_hom_inv_pair.ids\n  ring_hom_inv_pair.ids ring_hom_inv_pair.ids ring_hom_inv_pair.ids\n\nvariables {e₁₂} {e₂₃}\n\n@[simp] lemma coe_to_add_equiv : ⇑(e.to_add_equiv) = e := rfl\n\n/-- The two paths coercion can take to an `add_monoid_hom` are equivalent -/\nlemma to_add_monoid_hom_commutes :\n  e.to_linear_map.to_add_monoid_hom = e.to_add_equiv.to_add_monoid_hom :=\nrfl\n\ninclude σ₃₁\n@[simp] theorem trans_apply (c : M₁) :\n  (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃) c = e₂₃ (e₁₂ c) := rfl\nomit σ₃₁\n\ninclude σ'\n@[simp] theorem apply_symm_apply (c : M₂) : e (e.symm c) = c := e.right_inv c\n@[simp] theorem symm_apply_apply (b : M) : e.symm (e b) = b := e.left_inv b\nomit σ'\n\ninclude σ₃₁ σ₂₁ σ₃₂\n@[simp] lemma symm_trans_apply\n  (c : M₃) : (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃).symm c = e₁₂.symm (e₂₃.symm c) := rfl\nomit σ₃₁ σ₂₁ σ₃₂\n\n@[simp] lemma trans_refl : e.trans (refl S M₂) = e := to_equiv_injective e.to_equiv.trans_refl\n@[simp] lemma refl_trans : (refl R M).trans e = e := to_equiv_injective e.to_equiv.refl_trans\n\ninclude σ'\nlemma symm_apply_eq {x y} : e.symm x = y ↔ x = e y := e.to_equiv.symm_apply_eq\n\nlemma eq_symm_apply {x y} : y = e.symm x ↔ e y = x := e.to_equiv.eq_symm_apply\nomit σ'\n\n@[simp] lemma refl_symm [module R M] : (refl R M).symm = linear_equiv.refl R M := rfl\n\n@[simp] lemma self_trans_symm [module R M] [module R M₂] (f : M ≃ₗ[R] M₂) :\n  f.trans f.symm = linear_equiv.refl R M :=\nby { ext x, simp }\n\n@[simp] lemma symm_trans_self [module R M] [module R M₂] (f : M ≃ₗ[R] M₂) :\n  f.symm.trans f = linear_equiv.refl R M₂ :=\nby { ext x, simp }\n\n@[simp, norm_cast] lemma refl_to_linear_map [module R M] :\n  (linear_equiv.refl R M : M →ₗ[R] M) = linear_map.id :=\nrfl\n\n@[simp, norm_cast]\nlemma comp_coe [module R M] [module R M₂] [module R M₃] (f :  M ≃ₗ[R] M₂)\n  (f' :  M₂ ≃ₗ[R] M₃) : (f' : M₂ →ₗ[R] M₃).comp (f : M →ₗ[R] M₂) = (f.trans f' : M ≃ₗ[R] M₃) :=\nrfl\n\n@[simp] lemma mk_coe (h₁ h₂ f h₃ h₄) :\n  (linear_equiv.mk e h₁ h₂ f h₃ h₄ : M ≃ₛₗ[σ] M₂) = e := ext $ λ _, rfl\n\n@[simp] theorem map_add (a b : M) : e (a + b) = e a + e b := e.map_add' a b\n@[simp] theorem map_zero : e 0 = 0 := e.to_linear_map.map_zero\n@[simp] theorem map_smulₛₗ (c : R) (x : M) : e (c • x) = (σ c) • e x := e.map_smul' c x\n\ninclude module_N₁ module_N₂\ntheorem map_smul (e : N₁ ≃ₗ[R₁] N₂) (c : R₁) (x : N₁) :\n  e (c • x) = c • e x := map_smulₛₗ _ _ _\nomit module_N₁ module_N₂\n\n@[simp] lemma map_sum {s : finset ι} (u : ι → M) : e (∑ i in s, u i) = ∑ i in s, e (u i) :=\ne.to_linear_map.map_sum\n\n@[simp] theorem map_eq_zero_iff {x : M} : e x = 0 ↔ x = 0 :=\ne.to_add_equiv.map_eq_zero_iff\ntheorem map_ne_zero_iff {x : M} : e x ≠ 0 ↔ x ≠ 0 :=\ne.to_add_equiv.map_ne_zero_iff\n\ninclude module_M module_S_M₂ re₁ re₂\n@[simp] theorem symm_symm (e : M ≃ₛₗ[σ] M₂): e.symm.symm = e :=\nby { cases e, refl }\nomit module_M module_S_M₂ re₁ re₂\n\nlemma symm_bijective [module R M] [module S M₂] [ring_hom_inv_pair σ' σ]\n  [ring_hom_inv_pair σ σ'] : function.bijective (symm : (M ≃ₛₗ[σ] M₂) → (M₂ ≃ₛₗ[σ'] M)) :=\nequiv.bijective ⟨(symm : (M ≃ₛₗ[σ] M₂) →\n  (M₂ ≃ₛₗ[σ'] M)), (symm : (M₂ ≃ₛₗ[σ'] M) → (M ≃ₛₗ[σ] M₂)), symm_symm, symm_symm⟩\n\n@[simp] lemma mk_coe' (f h₁ h₂ h₃ h₄) : (linear_equiv.mk f h₁ h₂ ⇑e h₃ h₄ :\n  M₂ ≃ₛₗ[σ'] M) = e.symm :=\nsymm_bijective.injective $ ext $ λ x, rfl\n\ninclude σ'\n@[simp] theorem symm_mk (f h₁ h₂ h₃ h₄) :\n  (⟨e, h₁, h₂, f, h₃, h₄⟩ : M ≃ₛₗ[σ] M₂).symm =\n  { to_fun := f, inv_fun := e,\n    ..(⟨e, h₁, h₂, f, h₃, h₄⟩ : M ≃ₛₗ[σ] M₂).symm } := rfl\nomit σ'\n\n@[simp] lemma coe_symm_mk [module R M] [module R M₂]\n  {to_fun inv_fun map_add map_smul left_inv right_inv} :\n  ⇑((⟨to_fun, map_add, map_smul, inv_fun, left_inv, right_inv⟩ : M ≃ₗ[R] M₂).symm) = inv_fun :=\nrfl\n\nprotected lemma bijective : function.bijective e := e.to_equiv.bijective\nprotected lemma injective : function.injective e := e.to_equiv.injective\nprotected lemma surjective : function.surjective e := e.to_equiv.surjective\n\ninclude σ'\nprotected lemma image_eq_preimage (s : set M) : e '' s = e.symm ⁻¹' s :=\ne.to_equiv.image_eq_preimage s\nomit σ'\n\nend\n\n/-- Interpret a `ring_equiv` `f` as an `f`-semilinear equiv. -/\n@[simps]\ndef _root_.ring_equiv.to_semilinear_equiv (f : R ≃+* S) :\n  by haveI := ring_hom_inv_pair.of_ring_equiv f;\n     haveI := ring_hom_inv_pair.symm (↑f : R →+* S) (f.symm : S →+* R);\n     exact (R ≃ₛₗ[(↑f : R →+* S)] S) :=\nby exact\n{ to_fun := f,\n  map_smul' := f.map_mul,\n  .. f}\n\nvariables [semiring R₁] [semiring R₂] [semiring R₃]\nvariables [add_comm_monoid M] [add_comm_monoid M₁] [add_comm_monoid M₂]\n\n/-- An involutive linear map is a linear equivalence. -/\ndef of_involutive {σ σ' : R →+* R} [ring_hom_inv_pair σ σ'] [ring_hom_inv_pair σ' σ]\n  {module_M : module R M} (f : M →ₛₗ[σ] M) (hf : involutive f) :\n  M ≃ₛₗ[σ] M :=\n{ .. f, .. hf.to_equiv f }\n\n@[simp] lemma coe_of_involutive {σ σ' : R →+* R} [ring_hom_inv_pair σ σ']\n  [ring_hom_inv_pair σ' σ] {module_M : module R M} (f : M →ₛₗ[σ] M) (hf : involutive f) :\n  ⇑(of_involutive f hf) = f :=\nrfl\n\nsection restrict_scalars\n\nvariables (R) [module R M] [module R M₂] [module S M] [module S M₂]\n  [linear_map.compatible_smul M M₂ R S]\n\n/-- If `M` and `M₂` are both `R`-semimodules and `S`-semimodules and `R`-semimodule structures\nare defined by an action of `R` on `S` (formally, we have two scalar towers), then any `S`-linear\nequivalence from `M` to `M₂` is also an `R`-linear equivalence.\n\nSee also `linear_map.restrict_scalars`. -/\n@[simps]\ndef restrict_scalars (f : M ≃ₗ[S] M₂) : M ≃ₗ[R] M₂ :=\n{ to_fun := f,\n  inv_fun := f.symm,\n  left_inv := f.left_inv,\n  right_inv := f.right_inv,\n  .. f.to_linear_map.restrict_scalars R }\n\nlemma restrict_scalars_injective :\n  function.injective (restrict_scalars R : (M ≃ₗ[S] M₂) → (M ≃ₗ[R] M₂)) :=\nλ f g h, ext (linear_equiv.congr_fun h : _)\n\n@[simp]\nlemma restrict_scalars_inj (f g : M ≃ₗ[S] M₂) :\n  f.restrict_scalars R = g.restrict_scalars R ↔ f = g :=\n(restrict_scalars_injective R).eq_iff\n\nend restrict_scalars\n\nsection automorphisms\nvariables [module R M]\n\ninstance automorphism_group : group (M ≃ₗ[R] M) :=\n{ mul := λ f g, g.trans f,\n  one := linear_equiv.refl R M,\n  inv := λ f, f.symm,\n  mul_assoc := λ f g h, rfl,\n  mul_one := λ f, ext $ λ x, rfl,\n  one_mul := λ f, ext $ λ x, rfl,\n  mul_left_inv := λ f, ext $ f.left_inv }\n\n/-- Restriction from `R`-linear automorphisms of `M` to `R`-linear endomorphisms of `M`,\npromoted to a monoid hom. -/\n@[simps]\ndef automorphism_group.to_linear_map_monoid_hom : (M ≃ₗ[R] M) →* (M →ₗ[R] M) :=\n{ to_fun := coe,\n  map_one' := rfl,\n  map_mul' := λ _ _, rfl }\n\n/-- The tautological action by `M ≃ₗ[R] M` on `M`.\n\nThis generalizes `function.End.apply_mul_action`. -/\ninstance apply_distrib_mul_action : distrib_mul_action (M ≃ₗ[R] M) M :=\n{ smul := ($),\n  smul_zero := linear_equiv.map_zero,\n  smul_add := linear_equiv.map_add,\n  one_smul := λ _, rfl,\n  mul_smul := λ _ _ _, rfl }\n\n@[simp] protected lemma smul_def (f : M ≃ₗ[R] M) (a : M) :\n  f • a = f a := rfl\n\n/-- `linear_equiv.apply_distrib_mul_action` is faithful. -/\ninstance apply_has_faithful_scalar : has_faithful_scalar (M ≃ₗ[R] M) M :=\n⟨λ _ _, linear_equiv.ext⟩\n\ninstance apply_smul_comm_class : smul_comm_class R (M ≃ₗ[R] M) M :=\n{ smul_comm := λ r e m, (e.map_smul r m).symm }\n\ninstance apply_smul_comm_class' : smul_comm_class (M ≃ₗ[R] M) R M :=\n{ smul_comm := linear_equiv.map_smul }\n\nend automorphisms\n\nend add_comm_monoid\n\nend linear_equiv\n\nnamespace module\n\n/-- `g : R ≃+* S` is `R`-linear when the module structure on `S` is `module.comp_hom S g` . -/\n@[simps]\ndef comp_hom.to_linear_equiv {R S : Type*} [semiring R] [semiring S] (g : R ≃+* S) :\n  (by haveI := comp_hom S (↑g : R →+* S); exact (R ≃ₗ[R] S)) :=\nby exact\n{ to_fun := (g : R → S),\n  inv_fun := (g.symm : S → R),\n  map_smul' := g.map_mul,\n  ..g }\n\nend module\n\nnamespace distrib_mul_action\n\nvariables (R M) [semiring R] [add_comm_monoid M] [module R M]\nvariables [group S] [distrib_mul_action S M] [smul_comm_class S R M]\n\n/-- Each element of the group defines a linear equivalence.\n\nThis is a stronger version of `distrib_mul_action.to_add_equiv`. -/\n@[simps]\ndef to_linear_equiv (s : S) : M ≃ₗ[R] M :=\n{ ..to_add_equiv M s,\n  ..to_linear_map R M s }\n\n/-- Each element of the group defines a module automorphism.\n\nThis is a stronger version of `distrib_mul_action.to_add_aut`. -/\n@[simps]\ndef to_module_aut : S →* M ≃ₗ[R] M :=\n{ to_fun := to_linear_equiv R M,\n  map_one' := linear_equiv.ext $ one_smul _,\n  map_mul' := λ a b, linear_equiv.ext $ mul_smul _ _ }\n\nend distrib_mul_action\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/data/equiv/module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.45516505373016136}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury G. Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.convex.basic\nimport Mathlib.measure_theory.set_integral\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Jensen's inequality for integrals\n\nIn this file we prove four theorems:\n\n* `convex.smul_integral_mem`: if `μ` is a non-zero finite measure on `α`, `s` is a convex closed set\n  in `E`, and `f` is an integrable function sending `μ`-a.e. points to `s`, then the average value\n  of `f` belongs to `s`: `(μ univ).to_real⁻¹ • ∫ x, f x ∂μ ∈ s`. See also `convex.center_mass_mem`\n  for a finite sum version of this lemma.\n\n* `convex.integral_mem`: if `μ` is a probability measure on `α`, `s` is a convex closed set in `E`,\n  and `f` is an integrable function sending `μ`-a.e. points to `s`, then the expected value of `f`\n  belongs to `s`: `∫ x, f x ∂μ ∈ s`. See also `convex.sum_mem` for a finite sum version of this\n  lemma.\n\n* `convex_on.map_smul_integral_le`: Jensen's inequality: if a function `g : E → ℝ` is convex and\n  continuous on a convex closed set `s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is\n  a function sending `μ`-a.e. points to `s`, then the value of `g` at the average value of `f` is\n  less than or equal to the average value of `g ∘ f` provided that both `f` and `g ∘ f` are\n  integrable. See also `convex.map_center_mass_le` for a finite sum version of this lemma.\n\n* `convex_on.map_integral_le`: Jensen's inequality: if a function `g : E → ℝ` is convex and\n  continuous on a convex closed set `s`, `μ` is a probability measure on `α`, and `f : α → E` is a\n  function sending `μ`-a.e. points to `s`, then the value of `g` at the expected value of `f` is\n  less than or equal to the expected value of `g ∘ f` provided that both `f` and `g ∘ f` are\n  integrable. See also `convex.map_sum_le` for a finite sum version of this lemma.\n\n## Tags\n\nconvex, integral, center mass, Jensen's inequality\n-/\n\n/-- If `μ` is a non-zero finite measure on `α`, `s` is a convex closed set in `E`, and `f` is an\nintegrable function sending `μ`-a.e. points to `s`, then the average value of `f` belongs to `s`:\n`(μ univ).to_real⁻¹ • ∫ x, f x ∂μ ∈ s`. See also `convex.center_mass_mem` for a finite sum version\nof this lemma. -/\ntheorem convex.smul_integral_mem {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure_theory.measure α} [normed_group E] [normed_space ℝ E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.finite_measure μ] {s : set E} (hs : convex s) (hsc : is_closed s) (hμ : μ ≠ 0) {f : α → E} (hfs : filter.eventually (fun (x : α) => f x ∈ s) (measure_theory.measure.ae μ)) (hfi : measure_theory.integrable f) : (ennreal.to_real (coe_fn μ set.univ)⁻¹ • measure_theory.integral μ fun (x : α) => f x) ∈ s := sorry\n\n/-- If `μ` is a probability measure on `α`, `s` is a convex closed set in `E`, and `f` is an\nintegrable function sending `μ`-a.e. points to `s`, then the expected value of `f` belongs to `s`:\n`∫ x, f x ∂μ ∈ s`. See also `convex.sum_mem` for a finite sum version of this lemma. -/\ntheorem convex.integral_mem {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure_theory.measure α} [normed_group E] [normed_space ℝ E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.probability_measure μ] {s : set E} (hs : convex s) (hsc : is_closed s) {f : α → E} (hf : filter.eventually (fun (x : α) => f x ∈ s) (measure_theory.measure.ae μ)) (hfi : measure_theory.integrable f) : (measure_theory.integral μ fun (x : α) => f x) ∈ s := sorry\n\n/-- Jensen's inequality: if a function `g : E → ℝ` is convex and continuous on a convex closed set\n`s`, `μ` is a finite non-zero measure on `α`, and `f : α → E` is a function sending `μ`-a.e. points\nto `s`, then the value of `g` at the average value of `f` is less than or equal to the average value\nof `g ∘ f` provided that both `f` and `g ∘ f` are integrable. See also `convex.map_center_mass_le`\nfor a finite sum version of this lemma. -/\ntheorem convex_on.map_smul_integral_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure_theory.measure α} [normed_group E] [normed_space ℝ E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.finite_measure μ] {s : set E} {g : E → ℝ} (hg : convex_on s g) (hgc : continuous_on g s) (hsc : is_closed s) (hμ : μ ≠ 0) {f : α → E} (hfs : filter.eventually (fun (x : α) => f x ∈ s) (measure_theory.measure.ae μ)) (hfi : measure_theory.integrable f) (hgi : measure_theory.integrable (g ∘ f)) : g (ennreal.to_real (coe_fn μ set.univ)⁻¹ • measure_theory.integral μ fun (x : α) => f x) ≤\n  ennreal.to_real (coe_fn μ set.univ)⁻¹ • measure_theory.integral μ fun (x : α) => g (f x) := sorry\n\n/-- Jensen's inequality: if a function `g : E → ℝ` is convex and continuous on a convex closed set\n`s`, `μ` is a probability measure on `α`, and `f : α → E` is a function sending `μ`-a.e. points to\n`s`, then the value of `g` at the expected value of `f` is less than or equal to the expected value\nof `g ∘ f` provided that both `f` and `g ∘ f` are integrable. See also `convex.map_sum_le` for a\nfinite sum version of this lemma. -/\ntheorem convex_on.map_integral_le {α : Type u_1} {E : Type u_2} [measurable_space α] {μ : measure_theory.measure α} [normed_group E] [normed_space ℝ E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.probability_measure μ] {s : set E} {g : E → ℝ} (hg : convex_on s g) (hgc : continuous_on g s) (hsc : is_closed s) {f : α → E} (hfs : filter.eventually (fun (x : α) => f x ∈ s) (measure_theory.measure.ae μ)) (hfi : measure_theory.integrable f) (hgi : measure_theory.integrable (g ∘ f)) : g (measure_theory.integral μ fun (x : α) => f x) ≤ measure_theory.integral μ fun (x : α) => g (f x) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/convex/integral.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943805178138, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.4551650460956408}}
{"text": "/-\nCopyright (c) 2021 Jakob von Raumer. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jakob von Raumer\n-/\n\nimport category_theory.monoidal.category\n\n\n/-!\n# Rigid (autonomous) monoidal categories\n\nThis file defines rigid (autonomous) monoidal categories and the necessary theory about\nexact pairings and duals.\n\n## Main definitions\n\n* `exact_pairing` of two objects of a monoidal category\n* Type classes `has_left_dual` and `has_right_dual` that capture that a pairing exists\n* The `right_adjoint_mate f` as a morphism `fᘁ : Yᘁ ⟶ Xᘁ` for a morphism `f : X ⟶ Y`\n* The classes of `right_rigid_category`, `left_rigid_category` and `rigid_category`\n\n## Main statements\n\n* `comp_right_adjoint_mate`: The adjoint mates of the composition is the composition of\n  adjoint mates.\n\n## Notations\n\n* `η_` and `ε_` denote the coevaluation and evaluation morphism of an exact pairing.\n* `Xᘁ` and `ᘁX` denote the right and left dual of an object, as well as the adjoint\n  mate of a morphism.\n\n## Future work\n\n* Show that `X ⊗ Y` and `Yᘁ ⊗ Xᘁ` form an exact pairing.\n* Show that the left adjoint mate of the right adjoint mate of a morphism is the morphism itself.\n* Simplify constructions in the case where a symmetry or braiding is present.\n\n## References\n\n* <https://ncatlab.org/nlab/show/rigid+monoidal+category>\n\n## Tags\n\nrigid category, monoidal category\n\n-/\nopen category_theory\n\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u₁} [category.{v₁} C] [monoidal_category C]\n\n/-- An exact pairing is a pair of objects `X Y : C` which admit\n  a coevaluation and evaluation morphism which fulfill two triangle equalities. -/\nclass exact_pairing (X Y : C) :=\n(coevaluation [] : 𝟙_ C ⟶ X ⊗ Y)\n(evaluation [] : Y ⊗ X ⟶ 𝟙_ C)\n(coevaluation_evaluation' [] :\n  (𝟙 Y ⊗ coevaluation) ≫ (α_ _ _ _).inv ≫ (evaluation ⊗ 𝟙 Y)\n  = (ρ_ Y).hom ≫ (λ_ Y).inv . obviously)\n(evaluation_coevaluation' [] :\n  (coevaluation ⊗ 𝟙 X) ≫ (α_ _ _ _).hom ≫ (𝟙 X ⊗ evaluation)\n  = (λ_ X).hom ≫ (ρ_ X).inv . obviously)\n\nopen exact_pairing\n\nnotation `η_` := exact_pairing.coevaluation\nnotation `ε_` := exact_pairing.evaluation\n\nrestate_axiom coevaluation_evaluation'\nattribute [reassoc, simp] exact_pairing.coevaluation_evaluation\nrestate_axiom evaluation_coevaluation'\nattribute [reassoc, simp] exact_pairing.evaluation_coevaluation\n\ninstance exact_pairing_unit : exact_pairing (𝟙_ C) (𝟙_ C) :=\n{ coevaluation := (ρ_ _).inv,\n  evaluation := (ρ_ _).hom,\n  coevaluation_evaluation' := by\n  { rw[monoidal_category.triangle_assoc_comp_right,\n      monoidal_category.unitors_inv_equal,\n      monoidal_category.unitors_equal], simp },\n  evaluation_coevaluation' := by\n  { rw[monoidal_category.triangle_assoc_comp_right_inv_assoc,\n      monoidal_category.unitors_inv_equal,\n      monoidal_category.unitors_equal], simp } }\n\n/-- A class of objects which have a right dual. -/\nclass has_right_dual (X : C) :=\n  (right_dual : C)\n  [exact : exact_pairing X right_dual]\n\n/-- A class of objects with have a left dual. -/\nclass has_left_dual (Y : C) :=\n  (left_dual : C)\n  [exact : exact_pairing left_dual Y]\n\nattribute [instance] has_right_dual.exact\nattribute [instance] has_left_dual.exact\n\nopen exact_pairing has_right_dual has_left_dual monoidal_category\n\nprefix `ᘁ`:1025 := left_dual\npostfix `ᘁ`:1025 := right_dual\n\ninstance has_right_dual_unit : has_right_dual (𝟙_ C) :=\n{ right_dual := 𝟙_ C }\n\ninstance has_left_dual_unit : has_left_dual (𝟙_ C) :=\n{ left_dual := 𝟙_ C }\n\ninstance has_right_dual_left_dual {X : C} [has_left_dual X] : has_right_dual (ᘁX) :=\n{ right_dual := X }\n\ninstance has_left_dual_right_dual {X : C} [has_right_dual X] : has_left_dual Xᘁ :=\n{ left_dual := X }\n\n@[simp]\nlemma left_dual_right_dual {X : C} [has_right_dual X] : ᘁ(Xᘁ) = X := rfl\n\n@[simp]\nlemma right_dual_left_dual {X : C} [has_left_dual X] : (ᘁX)ᘁ = X := rfl\n\n/-- The right adjoint mate `fᘁ : Xᘁ ⟶ Yᘁ` of a morphism `f : X ⟶ Y`. -/\ndef right_adjoint_mate {X Y : C} [has_right_dual X] [has_right_dual Y] (f : X ⟶ Y) : Yᘁ ⟶ Xᘁ :=\n(ρ_ _).inv ≫ (𝟙 _ ⊗ η_ _ _) ≫ (𝟙 _ ⊗ (f ⊗ 𝟙 _))\n ≫ (α_ _ _ _).inv ≫ ((ε_ _ _) ⊗ 𝟙 _) ≫ (λ_ _).hom\n\n/-- The left adjoint mate `ᘁf : ᘁY ⟶ ᘁX` of a morphism `f : X ⟶ Y`. -/\ndef left_adjoint_mate {X Y : C} [has_left_dual X] [has_left_dual Y] (f : X ⟶ Y) : ᘁY ⟶ ᘁX :=\n(λ_ _).inv ≫ (η_ (ᘁX) X ⊗ 𝟙 _) ≫ ((𝟙 _ ⊗ f) ⊗ 𝟙 _)\n ≫ (α_ _ _ _).hom ≫ (𝟙 _ ⊗ ε_ _ _) ≫ (ρ_ _).hom\n\nnotation f `ᘁ` := right_adjoint_mate f\nnotation `ᘁ` f := left_adjoint_mate f\n\n@[simp]\nlemma right_adjoint_mate_id {X : C} [has_right_dual X] : (𝟙 X)ᘁ = 𝟙 (Xᘁ) :=\nby simp only [right_adjoint_mate, monoidal_category.tensor_id, category.id_comp,\n  coevaluation_evaluation_assoc, category.comp_id, iso.inv_hom_id]\n\n@[simp]\nlemma left_adjoint_mate_id {X : C} [has_left_dual X] : ᘁ(𝟙 X) = 𝟙 (ᘁX) :=\nby simp only [left_adjoint_mate, monoidal_category.tensor_id, category.id_comp,\n  evaluation_coevaluation_assoc, category.comp_id, iso.inv_hom_id]\n\nlemma right_adjoint_mate_comp {X Y Z : C} [has_right_dual X]\n  [has_right_dual Y] {f : X ⟶ Y} {g : Xᘁ ⟶ Z} :\n  fᘁ ≫ g\n  = (ρ_ Yᘁ).inv ≫ (𝟙 _ ⊗ η_ X Xᘁ) ≫ (𝟙 _ ⊗ f ⊗ g)\n    ≫ (α_ Yᘁ Y Z).inv ≫ (ε_ Y Yᘁ ⊗ 𝟙 _) ≫ (λ_ Z).hom :=\nbegin\n  dunfold right_adjoint_mate,\n  rw [category.assoc, category.assoc, associator_inv_naturality_assoc,\n    associator_inv_naturality_assoc, ←tensor_id_comp_id_tensor g, category.assoc, category.assoc,\n    category.assoc, category.assoc, id_tensor_comp_tensor_id_assoc, ←left_unitor_naturality,\n    tensor_id_comp_id_tensor_assoc],\nend\n\nlemma left_adjoint_mate_comp {X Y Z : C} [has_left_dual X] [has_left_dual Y]\n  {f : X ⟶ Y} {g : ᘁX ⟶ Z} :\n  ᘁf ≫ g\n  = (λ_ _).inv ≫ (η_ (ᘁX) X ⊗ 𝟙 _) ≫ ((g ⊗ f) ⊗ 𝟙 _)\n    ≫ (α_ _ _ _).hom ≫ (𝟙 _ ⊗ ε_ _ _) ≫ (ρ_ _).hom :=\nbegin\n  dunfold left_adjoint_mate,\n  rw [category.assoc, category.assoc, associator_naturality_assoc, associator_naturality_assoc,\n  ←id_tensor_comp_tensor_id _ g, category.assoc, category.assoc, category.assoc, category.assoc,\n  tensor_id_comp_id_tensor_assoc, ←right_unitor_naturality, id_tensor_comp_tensor_id_assoc],\nend\n\n/-- The composition of right adjoint mates is the adjoint mate of the composition. -/\n@[reassoc]\nlemma comp_right_adjoint_mate {X Y Z : C}\n  [has_right_dual X] [has_right_dual Y] [has_right_dual Z] {f : X ⟶ Y} {g : Y ⟶ Z} :\n  (f ≫ g)ᘁ = gᘁ ≫ fᘁ :=\nbegin\n  rw right_adjoint_mate_comp,\n  simp only [right_adjoint_mate, comp_tensor_id, iso.cancel_iso_inv_left, id_tensor_comp,\n    category.assoc],\n  symmetry, iterate 5 { transitivity, rw [←category.id_comp g, tensor_comp] },\n  rw ←category.assoc,\n  symmetry, iterate 2 { transitivity, rw ←category.assoc }, apply eq_whisker,\n  repeat { rw ←id_tensor_comp }, congr' 1,\n  rw [←id_tensor_comp_tensor_id (λ_ Xᘁ).hom g, id_tensor_right_unitor_inv, category.assoc,\n    category.assoc, right_unitor_inv_naturality_assoc, ←associator_naturality_assoc, tensor_id,\n    tensor_id_comp_id_tensor_assoc, ←associator_naturality_assoc],\n  slice_rhs 2 3 { rw [←tensor_comp, tensor_id, category.comp_id,\n    ←category.id_comp (η_ Y Yᘁ), tensor_comp] },\n  rw [←id_tensor_comp_tensor_id _ (η_ Y Yᘁ), ←tensor_id],\n  repeat { rw category.assoc },\n  rw [pentagon_hom_inv_assoc, ←associator_naturality_assoc, associator_inv_naturality_assoc],\n  slice_rhs 5 7 { rw [←comp_tensor_id, ←comp_tensor_id, evaluation_coevaluation, comp_tensor_id] },\n  rw associator_inv_naturality_assoc,\n  slice_rhs 4 5 { rw [←tensor_comp, left_unitor_naturality, tensor_comp] },\n  repeat { rw category.assoc },\n  rw [triangle_assoc_comp_right_inv_assoc, ←left_unitor_tensor_assoc,\n    left_unitor_naturality_assoc, unitors_equal, ←category.assoc, ←category.assoc], simp\nend\n\n/-- The composition of left adjoint mates is the adjoint mate of the composition. -/\n@[reassoc]\nlemma comp_left_adjoint_mate {X Y Z : C}\n  [has_left_dual X] [has_left_dual Y] [has_left_dual Z] {f : X ⟶ Y} {g : Y ⟶ Z} :\n  ᘁ(f ≫ g) = ᘁg ≫ ᘁf :=\nbegin\n  rw left_adjoint_mate_comp,\n  simp only [left_adjoint_mate, id_tensor_comp, iso.cancel_iso_inv_left,\n    comp_tensor_id, category.assoc],\n  symmetry, iterate 5 { transitivity, rw [←category.id_comp g, tensor_comp] },\n  rw ← category.assoc,\n  symmetry, iterate 2 { transitivity, rw ←category.assoc }, apply eq_whisker,\n  repeat { rw ←comp_tensor_id }, congr' 1,\n  rw [←tensor_id_comp_id_tensor g (ρ_ (ᘁX)).hom, left_unitor_inv_tensor_id, category.assoc,\n    category.assoc, left_unitor_inv_naturality_assoc, ←associator_inv_naturality_assoc, tensor_id,\n    id_tensor_comp_tensor_id_assoc, ←associator_inv_naturality_assoc],\n  slice_rhs 2 3 { rw [←tensor_comp, tensor_id, category.comp_id,\n    ←category.id_comp (η_ (ᘁY) Y), tensor_comp] },\n  rw [←tensor_id_comp_id_tensor (η_ (ᘁY) Y), ←tensor_id],\n  repeat { rw category.assoc },\n  rw [pentagon_inv_hom_assoc, ←associator_inv_naturality_assoc, associator_naturality_assoc],\n  slice_rhs 5 7 { rw [←id_tensor_comp, ←id_tensor_comp, coevaluation_evaluation, id_tensor_comp ]},\n  rw associator_naturality_assoc,\n  slice_rhs 4 5 { rw [←tensor_comp, right_unitor_naturality, tensor_comp] },\n  repeat { rw category.assoc },\n  rw [triangle_assoc_comp_left_inv_assoc, ←right_unitor_tensor_assoc,\n    right_unitor_naturality_assoc, ←unitors_equal, ←category.assoc, ←category.assoc], simp\nend\n\n/-- Right duals are isomorphic. -/\ndef right_dual_iso {X Y₁ Y₂ : C} (_ : exact_pairing X Y₁) (_ : exact_pairing X Y₂) :\n  Y₁ ≅ Y₂ :=\n{ hom := @right_adjoint_mate C _ _ X X ⟨Y₂⟩ ⟨Y₁⟩ (𝟙 X),\n  inv := @right_adjoint_mate C _ _ X X ⟨Y₁⟩ ⟨Y₂⟩ (𝟙 X),\n  hom_inv_id' := by rw [←comp_right_adjoint_mate, category.comp_id, right_adjoint_mate_id],\n  inv_hom_id' := by rw [←comp_right_adjoint_mate, category.comp_id, right_adjoint_mate_id] }\n\n/-- Left duals are isomorphic. -/\ndef left_dual_iso {X₁ X₂ Y : C} (p₁ : exact_pairing X₁ Y) (p₂ : exact_pairing X₂ Y) :\n  X₁ ≅ X₂ :=\n{ hom := @left_adjoint_mate C _ _ Y Y ⟨X₂⟩ ⟨X₁⟩ (𝟙 Y),\n  inv := @left_adjoint_mate C _ _ Y Y ⟨X₁⟩ ⟨X₂⟩ (𝟙 Y),\n  hom_inv_id' := by rw [←comp_left_adjoint_mate, category.comp_id, left_adjoint_mate_id],\n  inv_hom_id' := by rw [←comp_left_adjoint_mate, category.comp_id, left_adjoint_mate_id] }\n\n@[simp]\nlemma right_dual_iso_id {X Y : C} (p : exact_pairing X Y) :\n  right_dual_iso p p = iso.refl Y :=\nby { ext, simp only [right_dual_iso, iso.refl_hom, right_adjoint_mate_id] }\n\n@[simp]\nlemma left_dual_iso_id {X Y : C} (p : exact_pairing X Y) :\n  left_dual_iso p p = iso.refl X :=\nby { ext, simp only [left_dual_iso, iso.refl_hom, left_adjoint_mate_id] }\n\n/-- A right rigid monoidal category is one in which every object has a right dual. -/\nclass right_rigid_category (C : Type u) [category.{v} C] [monoidal_category.{v} C] :=\n  [right_dual : Π (X : C), has_right_dual X]\n\n/-- A left rigid monoidal category is one in which every object has a right dual. -/\nclass left_rigid_category (C : Type u) [category.{v} C] [monoidal_category.{v} C] :=\n  [left_dual : Π (X : C), has_left_dual X]\n\nattribute [instance, priority 100] right_rigid_category.right_dual\nattribute [instance, priority 100] left_rigid_category.left_dual\n\n/-- A rigid monoidal category is a monoidal category which is left rigid and right rigid. -/\nclass rigid_category (C : Type u) [category.{v} C] [monoidal_category.{v} C]\n  extends right_rigid_category C, left_rigid_category C\n\nend category_theory\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/category_theory/monoidal/rigid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514777, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4550977273075589}}
{"text": "/-\nCopyright (c) 2017 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Tim Baumann, Stephen Morgan, Scott Morrison\n-/\nimport tactic.reassoc_axiom\nimport category_theory.category.basic\n\n/-!\n# Functors\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nDefines a functor between categories, extending a `prefunctor` between quivers.\n\nIntroduces notation `C ⥤ D` for the type of all functors from `C` to `D`.\n(Unfortunately the `⇒` arrow (`\\functor`) is taken by core,\nbut in mathlib4 we should switch to this.)\n-/\n\nnamespace category_theory\n\n-- declare the `v`'s first; see `category_theory.category` for an explanation\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\n\nsection\n\nset_option old_structure_cmd true\n\n/--\n`functor C D` represents a functor between categories `C` and `D`.\n\nTo apply a functor `F` to an object use `F.obj X`, and to a morphism use `F.map f`.\n\nThe axiom `map_id` expresses preservation of identities, and\n`map_comp` expresses functoriality.\n\nSee <https://stacks.math.columbia.edu/tag/001B>.\n-/\nstructure functor (C : Type u₁) [category.{v₁} C] (D : Type u₂) [category.{v₂} D]\n  extends prefunctor C D : Type (max v₁ v₂ u₁ u₂) :=\n(map_id'   : ∀ (X : C), map (𝟙 X) = 𝟙 (obj X) . obviously)\n(map_comp' : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), map (f ≫ g) = (map f) ≫ (map g) . obviously)\n\n/-- The prefunctor between the underlying quivers. -/\nadd_decl_doc functor.to_prefunctor\n\nend\n\n-- A functor is basically a function, so give ⥤ a similar precedence to → (25).\n-- For example, `C × D ⥤ E` should parse as `(C × D) ⥤ E` not `C × (D ⥤ E)`.\ninfixr ` ⥤ `:26 := functor       -- type as \\func --\n\nrestate_axiom functor.map_id'\nattribute [simp] functor.map_id\nrestate_axiom functor.map_comp'\nattribute [reassoc, simp] functor.map_comp\n\nnamespace functor\n\nsection\nvariables (C : Type u₁) [category.{v₁} C]\n\n/-- `𝟭 C` is the identity functor on a category `C`. -/\n-- We don't use `@[simps]` here because we want `C` implicit for the simp lemmas.\nprotected def id : C ⥤ C :=\n{ obj := λ X, X,\n  map := λ _ _ f, f }\n\nnotation `𝟭` := functor.id -- Type this as `\\sb1`\n\ninstance : inhabited (C ⥤ C) := ⟨functor.id C⟩\n\nvariable {C}\n\n@[simp] lemma id_obj (X : C) : (𝟭 C).obj X = X := rfl\n@[simp] lemma id_map {X Y : C} (f : X ⟶ Y) : (𝟭 C).map f = f := rfl\n\nend\n\nsection\nvariables {C : Type u₁} [category.{v₁} C]\n          {D : Type u₂} [category.{v₂} D]\n          {E : Type u₃} [category.{v₃} E]\n\n/--\n`F ⋙ G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\n@[simps obj] def comp (F : C ⥤ D) (G : D ⥤ E) : C ⥤ E :=\n{ obj := λ X, G.obj (F.obj X),\n  map := λ _ _ f, G.map (F.map f) }\n\ninfixr ` ⋙ `:80 := comp\n\n@[simp] lemma comp_map (F : C ⥤ D) (G : D ⥤ E) {X Y : C} (f : X ⟶ Y) :\n  (F ⋙ G).map f = G.map (F.map f) := rfl\n\n-- These are not simp lemmas because rewriting along equalities between functors\n-- is not necessarily a good idea.\n-- Natural isomorphisms are also provided in `whiskering.lean`.\nprotected lemma comp_id (F : C ⥤ D) : F ⋙ (𝟭 D) = F := by cases F; refl\nprotected lemma id_comp (F : C ⥤ D) : (𝟭 C) ⋙ F = F := by cases F; refl\n\n@[simp] lemma map_dite (F : C ⥤ D) {X Y : C} {P : Prop} [decidable P]\n  (f : P → (X ⟶ Y)) (g : ¬P → (X ⟶ Y)) :\n  F.map (if h : P then f h else g h) = if h : P then F.map (f h) else F.map (g h) :=\nby { split_ifs; refl, }\n\n@[simp] lemma to_prefunctor_obj (F : C ⥤ D) (X : C) :\n  F.to_prefunctor.obj X = F.obj X := rfl\n\n@[simp] lemma to_prefunctor_map (F : C ⥤ D)\n  {X Y : C} (f : X ⟶ Y) : F.to_prefunctor.map f = F.map f := rfl\n\n@[simp] lemma to_prefunctor_comp (F : C ⥤ D) (G : D ⥤ E) :\n  F.to_prefunctor.comp G.to_prefunctor = (F ⋙ G).to_prefunctor := rfl\n\n\nend\n\nend functor\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/functor/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.4550977240153096}}
{"text": "/-\nCopyright (c) 2021 Paula Neeley. All rights reserved.\nAuthor: Paula Neeley\nFollowing the textbook \"Dynamic Epistemic Logic\" by \nHans van Ditmarsch, Wiebe van der Hoek, and Barteld Kooi\n-/\n\nimport del.semantics.consistencyDEL del.syntax.soundnessDEL\nimport data.list.basic\nlocal attribute [instance] classical.prop_decidable\n\nvariables {agents : Type}\nopen prfS5\nopen S5lemma\n\n\n---------------------- Canonical Model Construction ----------------------\n\n\nnamespace canonical\n\ndef canonical [hax : sem_cons (∅ : ctx agents) equiv_class] : frame agents := \n{ \n  states := {xΓ : ctx agents // max_ax_consist xΓ},\n  h := begin have h1 := max_ax_exists hax, choose Γ h1 using h1, exact ⟨⟨Γ, h1⟩⟩ end,\n  rel := λ a, λ xΓ yΔ, ∀ φ : form agents, K a φ ∈ xΓ.val → φ ∈ yΔ.val\n}\n\n\ndef val_canonical [hax : sem_cons (∅ : ctx agents) equiv_class] : \n  nat → canonical.states → Prop := λ n, λ xΓ : canonical.states, (form.var n) ∈ (xΓ.val : ctx agents)\n\n\nlemma existence (hax : sem_cons (∅ : ctx agents) equiv_class) (xΓ : canonical.states) :\n  ∀ a, ∀ φ : form agents, (¬ K a (¬φ)) ∈ xΓ.val ↔ ∃ yΔ : canonical.states, φ ∈ yΔ.val ∧ canonical.rel a xΓ yΔ :=\nbegin\nintros a φ, split,\nintro h1,\nlet Γbox : ctx agents := {ψ : form agents | K a ψ ∈ xΓ.val},\nhave h1 : ax_consist (Γbox ∪ {φ}), \n{by_contradiction h2, simp at h2,\nhave h3 := five Γbox φ h2,\ncases h3 with L h3, cases h3 with h3 h4,\nhave h5 := cut fin_conj_boxn (mp kdist (nec h4)),\nhave h6 := exercise1,\nhave h7 : ∀ ψ ∈ (list.map (form.box a) L), ψ ∈ xΓ.1, \nintros ψ h8, simp at *, cases h8 with a h8,\ncases h8 with h8l h8r,\nsubst h8r, exact h3 a h8l,\nspecialize h6 xΓ.2 h7 h5,\nhave h8 := (six xΓ.1 (max_imp_ax xΓ.2)).mp xΓ.2 (K a (¬φ)),\ncases h8 with h8l h8r, simp at *, \nexact absurd h1 (h8r h6),\n},\nhave h2 := lindenbaum (Γbox ∪ {φ}) h1,\ncases h2 with Δ h2, cases h2 with h2 h3,\nlet xΔ : canonical.states := ⟨Δ, h2⟩,\nexistsi (xΔ : canonical.states),\nhave h5 := set.union_subset_iff.mp h3,\ncases h5, split, simp at h5_right, exact h5_right,\nhave h3 : ∀ φ : form agents, K a φ ∈ xΓ.val → φ ∈ xΔ.val,\nintros ψ h4, apply h5_left, exact h4,\nexact h3,\nsimp at *,\nintros yΔ h1 h2,\nby_contradiction h4,\nhave h5 := (max_notiff xΓ.1 xΓ.2 (C a φ)).mp h4,\nhave h6 := (max_dn xΓ.1 xΓ.2 (K a ¬φ)).mpr h5,\nexact absurd h1 ((max_notiff yΔ.1 yΔ.2 φ).mpr ((h2 (¬φ)) h6))\nend\n\n\nlemma truth (hax : sem_cons (∅ : ctx agents) equiv_class) (xΓ : canonical.states) : \n  ∀ φ : form agents, forces canonical val_canonical xΓ φ ↔ (φ ∈ xΓ.val) :=\nbegin\nintro φ, induction φ with n φ ψ ih_φ ih_ψ \nφ ψ ih_φ ih_ψ φ ih_φ generalizing xΓ,\nsplit, intro h1, exact false.elim h1,\nintro h1, rw forces, \nhave h2 := xΓ.2,\ncases h2,\nspecialize h2_left [⊥],\nsimp at *, \nexact absurd not_contra (h2_left h1),\nrepeat {rw forces, rw val_canonical},\nsplit, intro h1, cases h1 with h1 h2,\nexact max_conj_1 xΓ.2 (and.intro ((ih_φ xΓ).mp h1) ((ih_ψ xΓ).mp h2)), \nintro h1, split,\napply (ih_φ xΓ).mpr, exact max_conj_2 xΓ.2 h1,\napply (ih_ψ xΓ).mpr, exact max_conj_3 xΓ.2 h1,\nsplit, \nintro h1,\napply max_imp_1 xΓ.2,\nintro h2,\nexact (ih_ψ xΓ).mp (h1 ((ih_φ xΓ).mpr h2)),\nintros h1 h2,\napply (ih_ψ xΓ).mpr, \nexact max_imp_2 xΓ.2 h1 ((ih_φ xΓ).mp h2),\nrename φ a, rename ih_φ φ,\nsplit, \nintros h1, by_contradiction h2,\nhave h4 := (existence hax xΓ a (¬φ)).mp,\nhave h5 := max_boxdn xΓ.1 xΓ.2 φ a ((max_notiff xΓ.1 xΓ.2 (K a φ)).mp h2),\ncases h4 h5 with xΔ h4, cases h4 with h4 h6,\nhave h7 := max_notiff xΔ.1 xΔ.2 φ,\ncases h7 with h7l h7r,\nexact absurd ((φ_ih xΔ).mp (h1 xΔ h6)) (h7r h4),\nintros h1 xΔ h2,\napply (φ_ih xΔ).mpr, exact (h2 φ h1),\nend\n\n\nlemma comphelper (φ : form agents) (hax : sem_cons (∅ : ctx agents) equiv_class) : \n  ¬ prfS5 ∅ φ → ax_consist ({¬φ} : ctx agents) :=\nbegin\nintros h1 L h2,\nrw fin_ax_consist, induction L,\nby_contradiction h3,\nexact absurd (mp dne h3) (nprfalse hax), \nhave h4 : (∀ ψ ∈ L_hd::L_tl, ψ = ¬φ) → prfS5 ∅ (¬fin_conj (L_hd::L_tl)) → prfS5 ∅ φ, \nfrom fin_conj_repeat hax,\nsimp at *, \ncases h2 with h2 h3,\nintro h6, apply h1, apply h4 h2, \nexact h3,\nexact h6\nend \n\n\ntheorem forcesAX (hax : sem_cons (∅ : ctx agents) equiv_class) : \n  forces_ctx canonical val_canonical (∅ : ctx agents) :=\nbegin\nintros φ xΓ h1,\nhave h2 := mp prfS5.pl1 (ax h1),\nhave h3 : ∀ ψ ∈ list.nil, ψ ∈ xΓ.val, \n{intros ψ h3, have h5 := list.ne_nil_of_length_pos (list.length_pos_of_mem h3),\nsimp at *, exact false.elim h5},\nhave h4 := exercise1 xΓ.2 h3 h2,\nexact (truth hax xΓ φ).mpr h4\nend\n\n\nlemma euclid_dual {a : agents} {φ : form agents} : \n  prfS5 ∅ ((C a (¬φ) ⊃ K a (C a (¬φ))) ⊃ (C a (K a φ) ⊃ K a φ)) :=\nbegin\nhave h1 := contrapos.mpr negintro,\nhave h2 := cut h1 (mp pl6 dual_equiv1),\nhave h3 : prfS5 ∅ ((¬K a (C a ¬φ)) ↔ (¬¬C a (¬(C a ¬φ)))),\n  from (mp (mp pl4 (contrapos.mpr (mp pl6 dual_equiv1))) \n  (contrapos.mpr (mp pl5 dual_equiv1))),\nhave h4 := cut dni (cut (mp pl6 h3) h2),\nhave h5 := (contrapos.mpr (mp kdist (nec (contrapos.mpr (mp pl5 dual_equiv1))))),\nexact (mp pl1 (cut h5 h4))\nend\n\n\nlemma S5_equiv (hax : sem_cons (∅ : ctx agents) equiv_class) : \n  canonical ∈ (equiv_class : set (frame agents)) :=\nbegin\nrw equiv_ref_euclid,\nsplit,\nintros a x φ h1,\nhave h2 : ∀ a, (∀ ψ ∈ [(K a φ)], ψ ∈ x.1) → prfS5 ∅ (fin_conj [(K a φ)] ⊃ φ) → φ ∈ x.1, \n  from λ a, exercise1 x.2,\nhave h3 : prfS5 ∅ (fin_conj [(K a φ)] ⊃ φ), \n{exact cut (mp pl5 phi_and_true) prfS5.truth},\nspecialize h2 a, simp at *,\nexact h2 h1 h3,\nintros a x y z h1 h2 φ h3,\napply h2 φ,\nhave h4 := mp euclid_dual negintro,\nhave h5 : ∀ a, (∀ ψ ∈ [(C a (K a φ))], ψ ∈ x.1) → \n  prfS5 ∅ (fin_conj [(C a (K a φ))] ⊃ K a φ) → K a φ ∈ x.1,\n  from λ a, exercise1 x.2, \nsimp at *,\napply h5,\nby_contradiction h6,\nhave h7 := max_notiff x.1 x.2 (¬K a (¬K a φ)),\nhave h8 := max_dn x.1 x.2 (K a (¬K a φ)),\nhave h9 := (max_notiff y.1 y.2 (K a φ)).mpr (h1 (¬K a φ) (h8.mpr (h7.mp h6))),\nexact absurd h3 h9,\nexact (cut (mp pl5 phi_and_true) h4)\nend\n\n\ntheorem completeness (hax : sem_cons (∅ : ctx agents) equiv_class) (φ : form agents) : \n  global_sem_csq ∅ equiv_class φ → prfS5 ∅ φ :=\nbegin\nrw ←not_imp_not, intro h1,\nhave h2 := comphelper φ hax h1,\nhave h3 := lindenbaum {¬φ} h2,\nsimp at *,\ncases h3 with Γ' h3, cases h3 with h3 h4, \nrw global_sem_csq, \npush_neg,\nlet f := canonical, \nuse f,\nlet v := val_canonical, \nsplit,\nexact S5_equiv hax, \nuse v,\nlet xΓ' : f.states := ⟨Γ', h3⟩,\nsplit, \nexact forcesAX hax,\nuse xΓ',\nhave h5 : forces f v xΓ' (¬φ) ↔ ((¬φ) ∈ xΓ'.val), \n  from truth hax xΓ' ¬φ,\ncases h5 with h5 h6,\nhave h7 : ¬forces f v xΓ' φ ↔ forces f v xΓ' ¬φ, \n  from not_forces_imp f v xΓ' φ,\ncases h7 with h7 h8, apply h8, apply h6, exact h4\nend\n\n\nend canonical", "meta": {"author": "paulaneeley", "repo": "modal", "sha": "ee5d149d4ecb337005b850bddf4453e56a5daf04", "save_path": "github-repos/lean/paulaneeley-modal", "path": "github-repos/lean/paulaneeley-modal/modal-ee5d149d4ecb337005b850bddf4453e56a5daf04/src/del/semantics/completenessDEL.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4550977192384078}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Markus Himmel\n-/\nimport category_theory.epi_mono\nimport category_theory.limits.has_limits\n\n/-!\n# Equalizers and coequalizers\n\nThis file defines (co)equalizers as special cases of (co)limits.\n\nAn equalizer is the categorical generalization of the subobject {a ∈ A | f(a) = g(a)} known\nfrom abelian groups or modules. It is a limit cone over the diagram formed by `f` and `g`.\n\nA coequalizer is the dual concept.\n\n## Main definitions\n\n* `walking_parallel_pair` is the indexing category used for (co)equalizer_diagrams\n* `parallel_pair` is a functor from `walking_parallel_pair` to our category `C`.\n* a `fork` is a cone over a parallel pair.\n  * there is really only one interesting morphism in a fork: the arrow from the vertex of the fork\n    to the domain of f and g. It is called `fork.ι`.\n* an `equalizer` is now just a `limit (parallel_pair f g)`\n\nEach of these has a dual.\n\n## Main statements\n\n* `equalizer.ι_mono` states that every equalizer map is a monomorphism\n* `is_iso_limit_cone_parallel_pair_of_self` states that the identity on the domain of `f` is an\n  equalizer of `f` and `f`.\n\n## Implementation notes\nAs with the other special shapes in the limits library, all the definitions here are given as\n`abbreviation`s of the general statements for limits, so all the `simp` lemmas and theorems about\ngeneral limits can be used.\n\n## References\n\n* [F. Borceux, *Handbook of Categorical Algebra 1*][borceux-vol1]\n-/\n\nnoncomputable theory\n\nopen category_theory\n\nnamespace category_theory.limits\n\nlocal attribute [tidy] tactic.case_bash\n\nuniverses v u u₂\n\n/-- The type of objects for the diagram indexing a (co)equalizer. -/\n@[derive decidable_eq, derive inhabited] inductive walking_parallel_pair : Type v\n| zero | one\n\nopen walking_parallel_pair\n\n/-- The type family of morphisms for the diagram indexing a (co)equalizer. -/\n@[derive decidable_eq] inductive walking_parallel_pair_hom :\n  walking_parallel_pair → walking_parallel_pair → Type v\n| left : walking_parallel_pair_hom zero one\n| right : walking_parallel_pair_hom zero one\n| id : Π X : walking_parallel_pair.{v}, walking_parallel_pair_hom X X\n\n/-- Satisfying the inhabited linter -/\ninstance : inhabited (walking_parallel_pair_hom zero one) :=\n{ default := walking_parallel_pair_hom.left }\n\nopen walking_parallel_pair_hom\n\n/-- Composition of morphisms in the indexing diagram for (co)equalizers. -/\ndef walking_parallel_pair_hom.comp :\n  Π (X Y Z : walking_parallel_pair)\n    (f : walking_parallel_pair_hom X Y) (g : walking_parallel_pair_hom Y Z),\n    walking_parallel_pair_hom X Z\n  | _ _ _ (id _) h := h\n  | _ _ _ left   (id one) := left\n  | _ _ _ right  (id one) := right\n.\n\ninstance walking_parallel_pair_hom_category : small_category walking_parallel_pair :=\n{ hom  := walking_parallel_pair_hom,\n  id   := walking_parallel_pair_hom.id,\n  comp := walking_parallel_pair_hom.comp }\n\n@[simp]\nlemma walking_parallel_pair_hom_id (X : walking_parallel_pair) :\n  walking_parallel_pair_hom.id X = 𝟙 X :=\nrfl\n\nvariables {C : Type u} [category.{v} C]\nvariables {X Y : C}\n\n/-- `parallel_pair f g` is the diagram in `C` consisting of the two morphisms `f` and `g` with\n    common domain and codomain. -/\ndef parallel_pair (f g : X ⟶ Y) : walking_parallel_pair.{v} ⥤ C :=\n{ obj := λ x, match x with\n  | zero := X\n  | one := Y\n  end,\n  map := λ x y h, match x, y, h with\n  | _, _, (id _) := 𝟙 _\n  | _, _, left := f\n  | _, _, right := g\n  end,\n  -- `tidy` can cope with this, but it's too slow:\n  map_comp' := begin rintros (⟨⟩|⟨⟩) (⟨⟩|⟨⟩) (⟨⟩|⟨⟩) ⟨⟩⟨⟩; { unfold_aux, simp; refl }, end, }.\n\n@[simp] lemma parallel_pair_obj_zero (f g : X ⟶ Y) : (parallel_pair f g).obj zero = X := rfl\n@[simp] lemma parallel_pair_obj_one (f g : X ⟶ Y) : (parallel_pair f g).obj one = Y := rfl\n\n@[simp] lemma parallel_pair_map_left (f g : X ⟶ Y) : (parallel_pair f g).map left = f := rfl\n@[simp] lemma parallel_pair_map_right (f g : X ⟶ Y) : (parallel_pair f g).map right = g := rfl\n\n@[simp] lemma parallel_pair_functor_obj\n  {F : walking_parallel_pair ⥤ C} (j : walking_parallel_pair) :\n  (parallel_pair (F.map left) (F.map right)).obj j = F.obj j :=\nbegin\n  cases j; refl\nend\n\n/-- Every functor indexing a (co)equalizer is naturally isomorphic (actually, equal) to a\n    `parallel_pair` -/\n@[simps]\ndef diagram_iso_parallel_pair (F : walking_parallel_pair ⥤ C) :\n  F ≅ parallel_pair (F.map left) (F.map right) :=\nnat_iso.of_components (λ j, eq_to_iso $ by cases j; tidy) $ by tidy\n\n/-- A fork on `f` and `g` is just a `cone (parallel_pair f g)`. -/\nabbreviation fork (f g : X ⟶ Y) := cone (parallel_pair f g)\n\n/-- A cofork on `f` and `g` is just a `cocone (parallel_pair f g)`. -/\nabbreviation cofork (f g : X ⟶ Y) := cocone (parallel_pair f g)\n\nvariables {f g : X ⟶ Y}\n\n/-- A fork `t` on the parallel pair `f g : X ⟶ Y` consists of two morphisms `t.π.app zero : t.X ⟶ X`\n    and `t.π.app one : t.X ⟶ Y`. Of these, only the first one is interesting, and we give it the\n    shorter name `fork.ι t`. -/\nabbreviation fork.ι (t : fork f g) := t.π.app zero\n\n/-- A cofork `t` on the parallel_pair `f g : X ⟶ Y` consists of two morphisms\n    `t.ι.app zero : X ⟶ t.X` and `t.ι.app one : Y ⟶ t.X`. Of these, only the second one is\n    interesting, and we give it the shorter name `cofork.π t`. -/\nabbreviation cofork.π (t : cofork f g) := t.ι.app one\n\n@[simp] lemma fork.ι_eq_app_zero (t : fork f g) : t.ι = t.π.app zero := rfl\n@[simp] lemma cofork.π_eq_app_one (t : cofork f g) : t.π = t.ι.app one := rfl\n\n@[simp, reassoc] lemma fork.app_zero_left (s : fork f g) :\n  s.π.app zero ≫ f = s.π.app one :=\nby rw [←s.w left, parallel_pair_map_left]\n\n@[simp, reassoc] lemma fork.app_zero_right (s : fork f g) :\n  s.π.app zero ≫ g = s.π.app one :=\nby rw [←s.w right, parallel_pair_map_right]\n\n@[simp, reassoc] lemma cofork.left_app_one (s : cofork f g) :\n  f ≫ s.ι.app one = s.ι.app zero :=\nby rw [←s.w left, parallel_pair_map_left]\n\n@[simp, reassoc] lemma cofork.right_app_one (s : cofork f g) :\n  g ≫ s.ι.app one = s.ι.app zero :=\nby rw [←s.w right, parallel_pair_map_right]\n\n/-- A fork on `f g : X ⟶ Y` is determined by the morphism `ι : P ⟶ X` satisfying `ι ≫ f = ι ≫ g`.\n-/\n@[simps]\ndef fork.of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) : fork f g :=\n{ X := P,\n  π :=\n  { app := λ X, begin cases X, exact ι, exact ι ≫ f, end,\n    naturality' := λ X Y f,\n    begin\n      cases X; cases Y; cases f; dsimp; simp,\n      { dsimp, simp, }, -- See note [dsimp, simp].\n      { exact w },\n      { dsimp, simp, },\n    end } }\n\n/-- A cofork on `f g : X ⟶ Y` is determined by the morphism `π : Y ⟶ P` satisfying\n    `f ≫ π = g ≫ π`. -/\n@[simps]\ndef cofork.of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) : cofork f g :=\n{ X := P,\n  ι :=\n  { app := λ X, walking_parallel_pair.cases_on X (f ≫ π) π,\n    naturality' := λ i j f, by { cases f; dsimp; simp [w] } } } -- See note [dsimp, simp]\n\nlemma fork.ι_of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) :\n  (fork.of_ι ι w).ι = ι := rfl\nlemma cofork.π_of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) :\n  (cofork.of_π π w).π = π := rfl\n\n@[reassoc]\nlemma fork.condition (t : fork f g) : t.ι ≫ f = t.ι ≫ g :=\nby rw [t.app_zero_left, t.app_zero_right]\n@[reassoc]\nlemma cofork.condition (t : cofork f g) : f ≫ t.π = g ≫ t.π :=\nby rw [t.left_app_one, t.right_app_one]\n\n/-- To check whether two maps are equalized by both maps of a fork, it suffices to check it for the\n    first map -/\nlemma fork.equalizer_ext (s : fork f g) {W : C} {k l : W ⟶ s.X}\n  (h : k ≫ fork.ι s = l ≫ fork.ι s) : ∀ (j : walking_parallel_pair),\n    k ≫ s.π.app j = l ≫ s.π.app j\n| zero := h\n| one := by rw [←fork.app_zero_left, reassoc_of h]\n\n/-- To check whether two maps are coequalized by both maps of a cofork, it suffices to check it for\n    the second map -/\n\n\nlemma fork.is_limit.hom_ext {s : fork f g} (hs : is_limit s) {W : C} {k l : W ⟶ s.X}\n  (h : k ≫ fork.ι s = l ≫ fork.ι s) : k = l :=\nhs.hom_ext $ fork.equalizer_ext _ h\n\nlemma cofork.is_colimit.hom_ext {s : cofork f g} (hs : is_colimit s) {W : C} {k l : s.X ⟶ W}\n  (h : cofork.π s ≫ k = cofork.π s ≫ l) : k = l :=\nhs.hom_ext $ cofork.coequalizer_ext _ h\n\n/-- If `s` is a limit fork over `f` and `g`, then a morphism `k : W ⟶ X` satisfying\n    `k ≫ f = k ≫ g` induces a morphism `l : W ⟶ s.X` such that `l ≫ fork.ι s = k`. -/\ndef fork.is_limit.lift' {s : fork f g} (hs : is_limit s) {W : C} (k : W ⟶ X) (h : k ≫ f = k ≫ g) :\n  {l : W ⟶ s.X // l ≫ fork.ι s = k} :=\n⟨hs.lift $ fork.of_ι _ h, hs.fac _ _⟩\n\n/-- If `s` is a colimit cofork over `f` and `g`, then a morphism `k : Y ⟶ W` satisfying\n    `f ≫ k = g ≫ k` induces a morphism `l : s.X ⟶ W` such that `cofork.π s ≫ l = k`. -/\ndef cofork.is_colimit.desc' {s : cofork f g} (hs : is_colimit s) {W : C} (k : Y ⟶ W)\n  (h : f ≫ k = g ≫ k) : {l : s.X ⟶ W // cofork.π s ≫ l = k} :=\n⟨hs.desc $ cofork.of_π _ h, hs.fac _ _⟩\n\n/-- This is a slightly more convenient method to verify that a fork is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content -/\ndef fork.is_limit.mk (t : fork f g)\n  (lift : Π (s : fork f g), s.X ⟶ t.X)\n  (fac : ∀ (s : fork f g), lift s ≫ fork.ι t = fork.ι s)\n  (uniq : ∀ (s : fork f g) (m : s.X ⟶ t.X)\n    (w : ∀ j : walking_parallel_pair, m ≫ t.π.app j = s.π.app j), m = lift s) :\n  is_limit t :=\n{ lift := lift,\n  fac' := λ s j, walking_parallel_pair.cases_on j (fac s) $\n    by erw [←s.w left, ←t.w left, ←category.assoc, fac]; refl,\n  uniq' := uniq }\n\n/-- This is another convenient method to verify that a fork is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef fork.is_limit.mk' {X Y : C} {f g : X ⟶ Y} (t : fork f g)\n  (create : Π (s : fork f g), {l // l ≫ t.ι = s.ι ∧ ∀ {m}, m ≫ t.ι = s.ι → m = l}) :\nis_limit t :=\nfork.is_limit.mk t\n  (λ s, (create s).1)\n  (λ s, (create s).2.1)\n  (λ s m w, (create s).2.2 (w zero))\n\n/-- This is a slightly more convenient method to verify that a cofork is a colimit cocone. It\n    only asks for a proof of facts that carry any mathematical content -/\ndef cofork.is_colimit.mk (t : cofork f g)\n  (desc : Π (s : cofork f g), t.X ⟶ s.X)\n  (fac : ∀ (s : cofork f g), cofork.π t ≫ desc s = cofork.π s)\n  (uniq : ∀ (s : cofork f g) (m : t.X ⟶ s.X)\n    (w : ∀ j : walking_parallel_pair, t.ι.app j ≫ m = s.ι.app j), m = desc s) :\n  is_colimit t :=\n{ desc := desc,\n  fac' := λ s j, walking_parallel_pair.cases_on j\n    (by erw [←s.w left, ←t.w left, category.assoc, fac]; refl) (fac s),\n  uniq' := uniq }\n\n/-- This is another convenient method to verify that a fork is a limit cone. It\n    only asks for a proof of facts that carry any mathematical content, and allows access to the\n    same `s` for all parts. -/\ndef cofork.is_colimit.mk' {X Y : C} {f g : X ⟶ Y} (t : cofork f g)\n  (create : Π (s : cofork f g), {l : t.X ⟶ s.X // t.π ≫ l = s.π ∧ ∀ {m}, t.π ≫ m = s.π → m = l}) :\nis_colimit t :=\ncofork.is_colimit.mk t\n  (λ s, (create s).1)\n  (λ s, (create s).2.1)\n  (λ s m w, (create s).2.2 (w one))\n\n/--\nGiven a limit cone for the pair `f g : X ⟶ Y`, for any `Z`, morphisms from `Z` to its point are in\nbijection with morphisms `h : Z ⟶ X` such that `h ≫ f = h ≫ g`.\nFurther, this bijection is natural in `Z`: see `fork.is_limit.hom_iso_natural`.\nThis is a special case of `is_limit.hom_iso'`, often useful to construct adjunctions.\n-/\n@[simps]\ndef fork.is_limit.hom_iso {X Y : C} {f g : X ⟶ Y} {t : fork f g} (ht : is_limit t) (Z : C) :\n  (Z ⟶ t.X) ≃ {h : Z ⟶ X // h ≫ f = h ≫ g} :=\n{ to_fun := λ k, ⟨k ≫ t.ι, by simp⟩,\n  inv_fun := λ h, (fork.is_limit.lift' ht _ h.prop).1,\n  left_inv := λ k, fork.is_limit.hom_ext ht (fork.is_limit.lift' _ _ _).prop,\n  right_inv := λ h, subtype.ext (fork.is_limit.lift' ht _ _).prop }\n\n/-- The bijection of `fork.is_limit.hom_iso` is natural in `Z`. -/\nlemma fork.is_limit.hom_iso_natural {X Y : C} {f g : X ⟶ Y} {t : fork f g} (ht : is_limit t)\n  {Z Z' : C} (q : Z' ⟶ Z) (k : Z ⟶ t.X) :\n  (fork.is_limit.hom_iso ht _ (q ≫ k) : Z' ⟶ X) = q ≫ (fork.is_limit.hom_iso ht _ k : Z ⟶ X) :=\ncategory.assoc _ _ _\n\n/--\nGiven a colimit cocone for the pair `f g : X ⟶ Y`, for any `Z`, morphisms from the cocone point\nto `Z` are in bijection with morphisms `h : Y ⟶ Z` such that `f ≫ h = g ≫ h`.\nFurther, this bijection is natural in `Z`: see `cofork.is_colimit.hom_iso_natural`.\nThis is a special case of `is_colimit.hom_iso'`, often useful to construct adjunctions.\n-/\n@[simps]\ndef cofork.is_colimit.hom_iso {X Y : C} {f g : X ⟶ Y} {t : cofork f g} (ht : is_colimit t) (Z : C) :\n  (t.X ⟶ Z) ≃ {h : Y ⟶ Z // f ≫ h = g ≫ h} :=\n{ to_fun := λ k, ⟨t.π ≫ k, by simp⟩,\n  inv_fun := λ h, (cofork.is_colimit.desc' ht _ h.prop).1,\n  left_inv := λ k, cofork.is_colimit.hom_ext ht (cofork.is_colimit.desc' _ _ _).prop,\n  right_inv := λ h, subtype.ext (cofork.is_colimit.desc' ht _ _).prop }\n\n/-- The bijection of `cofork.is_colimit.hom_iso` is natural in `Z`. -/\nlemma cofork.is_colimit.hom_iso_natural {X Y : C} {f g : X ⟶ Y} {t : cofork f g} {Z Z' : C}\n  (q : Z ⟶ Z') (ht : is_colimit t) (k : t.X ⟶ Z) :\n    (cofork.is_colimit.hom_iso ht _ (k ≫ q) : Y ⟶ Z') =\n    (cofork.is_colimit.hom_iso ht _ k : Y ⟶ Z) ≫ q :=\n(category.assoc _ _ _).symm\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    equalizers. Given `F : walking_parallel_pair ⥤ C`, which is really the same as\n    `parallel_pair (F.map left) (F.map right)`, and a fork on `F.map left` and `F.map right`,\n    we get a cone on `F`.\n\n    If you're thinking about using this, have a look at `has_equalizers_of_has_limit_parallel_pair`,\n    which you may find to be an easier way of achieving your goal. -/\ndef cone.of_fork\n  {F : walking_parallel_pair ⥤ C} (t : fork (F.map left) (F.map right)) : cone F :=\n{ X := t.X,\n  π :=\n  { app := λ X, t.π.app X ≫ eq_to_hom (by tidy),\n    naturality' := λ j j' g, by { cases j; cases j'; cases g; dsimp; simp } } }\n\n/-- This is a helper construction that can be useful when verifying that a category has all\n    coequalizers. Given `F : walking_parallel_pair ⥤ C`, which is really the same as\n    `parallel_pair (F.map left) (F.map right)`, and a cofork on `F.map left` and `F.map right`,\n    we get a cocone on `F`.\n\n    If you're thinking about using this, have a look at\n    `has_coequalizers_of_has_colimit_parallel_pair`, which you may find to be an easier way of\n    achieving your goal. -/\ndef cocone.of_cofork\n  {F : walking_parallel_pair ⥤ C} (t : cofork (F.map left) (F.map right)) : cocone F :=\n{ X := t.X,\n  ι :=\n  { app := λ X, eq_to_hom (by tidy) ≫ t.ι.app X,\n    naturality' := λ j j' g, by { cases j; cases j'; cases g; dsimp; simp } } }\n\n@[simp] lemma cone.of_fork_π\n  {F : walking_parallel_pair ⥤ C} (t : fork (F.map left) (F.map right)) (j) :\n  (cone.of_fork t).π.app j = t.π.app j ≫ eq_to_hom (by tidy) := rfl\n\n@[simp] lemma cocone.of_cofork_ι\n  {F : walking_parallel_pair ⥤ C} (t : cofork (F.map left) (F.map right)) (j) :\n  (cocone.of_cofork t).ι.app j = eq_to_hom (by tidy) ≫ t.ι.app j := rfl\n\n/-- Given `F : walking_parallel_pair ⥤ C`, which is really the same as\n    `parallel_pair (F.map left) (F.map right)` and a cone on `F`, we get a fork on\n    `F.map left` and `F.map right`. -/\ndef fork.of_cone\n  {F : walking_parallel_pair ⥤ C} (t : cone F) : fork (F.map left) (F.map right) :=\n{ X := t.X,\n  π := { app := λ X, t.π.app X ≫ eq_to_hom (by tidy) } }\n\n/-- Given `F : walking_parallel_pair ⥤ C`, which is really the same as\n    `parallel_pair (F.map left) (F.map right)` and a cocone on `F`, we get a cofork on\n    `F.map left` and `F.map right`. -/\ndef cofork.of_cocone\n  {F : walking_parallel_pair ⥤ C} (t : cocone F) : cofork (F.map left) (F.map right) :=\n{ X := t.X,\n  ι := { app := λ X, eq_to_hom (by tidy) ≫ t.ι.app X } }\n\n@[simp] lemma fork.of_cone_π {F : walking_parallel_pair ⥤ C} (t : cone F) (j) :\n  (fork.of_cone t).π.app j = t.π.app j ≫ eq_to_hom (by tidy) := rfl\n@[simp] lemma cofork.of_cocone_ι {F : walking_parallel_pair ⥤ C} (t : cocone F) (j) :\n  (cofork.of_cocone t).ι.app j = eq_to_hom (by tidy) ≫ t.ι.app j := rfl\n\n/--\nHelper function for constructing morphisms between equalizer forks.\n-/\n@[simps]\ndef fork.mk_hom {s t : fork f g} (k : s.X ⟶ t.X) (w : k ≫ t.ι = s.ι) : s ⟶ t :=\n{ hom := k,\n  w' :=\n  begin\n    rintro ⟨_|_⟩,\n    { exact w },\n    { simpa using w =≫ f },\n  end }\n\n/--\nTo construct an isomorphism between forks,\nit suffices to give an isomorphism between the cone points\nand check that it commutes with the `ι` morphisms.\n-/\n@[simps]\ndef fork.ext {s t : fork f g} (i : s.X ≅ t.X) (w : i.hom ≫ t.ι = s.ι) : s ≅ t :=\n{ hom := fork.mk_hom i.hom w,\n  inv := fork.mk_hom i.inv (by rw [← w, iso.inv_hom_id_assoc]) }\n\n/--\nHelper function for constructing morphisms between coequalizer coforks.\n-/\n@[simps]\ndef cofork.mk_hom {s t : cofork f g} (k : s.X ⟶ t.X) (w : s.π ≫ k = t.π) : s ⟶ t :=\n{ hom := k,\n  w' :=\n  begin\n    rintro ⟨_|_⟩,\n    simpa using f ≫= w,\n    exact w,\n  end }\n\n/--\nTo construct an isomorphism between coforks,\nit suffices to give an isomorphism between the cocone points\nand check that it commutes with the `π` morphisms.\n-/\ndef cofork.ext {s t : cofork f g} (i : s.X ≅ t.X) (w : s.π ≫ i.hom = t.π) : s ≅ t :=\n{ hom := cofork.mk_hom i.hom w,\n  inv := cofork.mk_hom i.inv (by rw [iso.comp_inv_eq, w]) }\n\nvariables (f g)\n\nsection\n/--\n`has_equalizer f g` represents a particular choice of limiting cone\nfor the parallel pair of morphisms `f` and `g`.\n-/\nabbreviation has_equalizer := has_limit (parallel_pair f g)\n\nvariables [has_equalizer f g]\n\n/-- If an equalizer of `f` and `g` exists, we can access an arbitrary choice of such by\n    saying `equalizer f g`. -/\nabbreviation equalizer : C := limit (parallel_pair f g)\n\n/-- If an equalizer of `f` and `g` exists, we can access the inclusion\n    `equalizer f g ⟶ X` by saying `equalizer.ι f g`. -/\nabbreviation equalizer.ι : equalizer f g ⟶ X :=\nlimit.π (parallel_pair f g) zero\n\n/--\nAn equalizer cone for a parallel pair `f` and `g`.\n-/\nabbreviation equalizer.fork : fork f g := limit.cone (parallel_pair f g)\n\n@[simp] lemma equalizer.fork_ι :\n  (equalizer.fork f g).ι = equalizer.ι f g := rfl\n\n@[simp] lemma equalizer.fork_π_app_zero :\n  (equalizer.fork f g).π.app zero = equalizer.ι f g := rfl\n\n@[reassoc] lemma equalizer.condition : equalizer.ι f g ≫ f = equalizer.ι f g ≫ g :=\nfork.condition $ limit.cone $ parallel_pair f g\n\n/-- The equalizer built from `equalizer.ι f g` is limiting. -/\ndef equalizer_is_equalizer : is_limit (fork.of_ι (equalizer.ι f g) (equalizer.condition f g)) :=\nis_limit.of_iso_limit (limit.is_limit _) (fork.ext (iso.refl _) (by tidy))\n\nvariables {f g}\n\n/-- A morphism `k : W ⟶ X` satisfying `k ≫ f = k ≫ g` factors through the equalizer of `f` and `g`\n    via `equalizer.lift : W ⟶ equalizer f g`. -/\nabbreviation equalizer.lift {W : C} (k : W ⟶ X) (h : k ≫ f = k ≫ g) : W ⟶ equalizer f g :=\nlimit.lift (parallel_pair f g) (fork.of_ι k h)\n\n@[simp, reassoc]\nlemma equalizer.lift_ι {W : C} (k : W ⟶ X) (h : k ≫ f = k ≫ g) :\n  equalizer.lift k h ≫ equalizer.ι f g = k :=\nlimit.lift_π _ _\n\n/-- A morphism `k : W ⟶ X` satisfying `k ≫ f = k ≫ g` induces a morphism `l : W ⟶ equalizer f g`\n    satisfying `l ≫ equalizer.ι f g = k`. -/\ndef equalizer.lift' {W : C} (k : W ⟶ X) (h : k ≫ f = k ≫ g) :\n  {l : W ⟶ equalizer f g // l ≫ equalizer.ι f g = k} :=\n⟨equalizer.lift k h, equalizer.lift_ι _ _⟩\n\n/-- Two maps into an equalizer are equal if they are are equal when composed with the equalizer\n    map. -/\n@[ext] lemma equalizer.hom_ext {W : C} {k l : W ⟶ equalizer f g}\n  (h : k ≫ equalizer.ι f g = l ≫ equalizer.ι f g) : k = l :=\nfork.is_limit.hom_ext (limit.is_limit _) h\n\n/-- An equalizer morphism is a monomorphism -/\ninstance equalizer.ι_mono : mono (equalizer.ι f g) :=\n{ right_cancellation := λ Z h k w, equalizer.hom_ext w }\n\nend\n\nsection\nvariables {f g}\n/-- The equalizer morphism in any limit cone is a monomorphism. -/\nlemma mono_of_is_limit_parallel_pair {c : cone (parallel_pair f g)} (i : is_limit c) :\n  mono (fork.ι c) :=\n{ right_cancellation := λ Z h k w, fork.is_limit.hom_ext i w }\n\nend\n\nsection\nvariables {f g}\n\n/-- The identity determines a cone on the equalizer diagram of `f` and `g` if `f = g`. -/\ndef id_fork (h : f = g) : fork f g :=\nfork.of_ι (𝟙 X) $ h ▸ rfl\n\n/-- The identity on `X` is an equalizer of `(f, g)`, if `f = g`. -/\ndef is_limit_id_fork (h : f = g) : is_limit (id_fork h) :=\nfork.is_limit.mk _\n  (λ s, fork.ι s)\n  (λ s, category.comp_id _)\n  (λ s m h, by { convert h zero, exact (category.comp_id _).symm })\n\n/-- Every equalizer of `(f, g)`, where `f = g`, is an isomorphism. -/\nlemma is_iso_limit_cone_parallel_pair_of_eq (h₀ : f = g) {c : cone (parallel_pair f g)}\n  (h : is_limit c) : is_iso (c.π.app zero) :=\nis_iso.of_iso $ is_limit.cone_point_unique_up_to_iso h $ is_limit_id_fork h₀\n\n/-- The equalizer of `(f, g)`, where `f = g`, is an isomorphism. -/\nlemma equalizer.ι_of_eq [has_equalizer f g] (h : f = g) : is_iso (equalizer.ι f g) :=\nis_iso_limit_cone_parallel_pair_of_eq h $ limit.is_limit _\n\n/-- Every equalizer of `(f, f)` is an isomorphism. -/\nlemma is_iso_limit_cone_parallel_pair_of_self {c : cone (parallel_pair f f)} (h : is_limit c) :\n  is_iso (c.π.app zero) :=\nis_iso_limit_cone_parallel_pair_of_eq rfl h\n\n/-- An equalizer that is an epimorphism is an isomorphism. -/\nlemma is_iso_limit_cone_parallel_pair_of_epi {c : cone (parallel_pair f g)}\n  (h : is_limit c) [epi (c.π.app zero)] : is_iso (c.π.app zero) :=\nis_iso_limit_cone_parallel_pair_of_eq ((cancel_epi _).1 (fork.condition c)) h\n\nend\n\ninstance has_equalizer_of_self : has_equalizer f f :=\nhas_limit.mk\n{ cone := id_fork rfl,\n  is_limit := is_limit_id_fork rfl }\n\n/-- The equalizer inclusion for `(f, f)` is an isomorphism. -/\ninstance equalizer.ι_of_self : is_iso (equalizer.ι f f) :=\nequalizer.ι_of_eq rfl\n\n/-- The equalizer of a morphism with itself is isomorphic to the source. -/\ndef equalizer.iso_source_of_self : equalizer f f ≅ X :=\nas_iso (equalizer.ι f f)\n\n@[simp] lemma equalizer.iso_source_of_self_hom :\n  (equalizer.iso_source_of_self f).hom = equalizer.ι f f :=\nrfl\n\n@[simp] lemma equalizer.iso_source_of_self_inv :\n  (equalizer.iso_source_of_self f).inv = equalizer.lift (𝟙 X) (by simp) :=\nby { ext, simp [equalizer.iso_source_of_self], }\n\nsection\n/--\n`has_coequalizer f g` represents a particular choice of colimiting cocone\nfor the parallel pair of morphisms `f` and `g`.\n-/\nabbreviation has_coequalizer := has_colimit (parallel_pair f g)\n\nvariables [has_coequalizer f g]\n\n/-- If a coequalizer of `f` and `g` exists, we can access an arbitrary choice of such by\n    saying `coequalizer f g`. -/\nabbreviation coequalizer : C := colimit (parallel_pair f g)\n\n/--  If a coequalizer of `f` and `g` exists, we can access the corresponding projection by\n    saying `coequalizer.π f g`. -/\nabbreviation coequalizer.π : Y ⟶ coequalizer f g :=\ncolimit.ι (parallel_pair f g) one\n\n/--\nAn arbitrary choice of coequalizer cocone for a parallel pair `f` and `g`.\n-/\nabbreviation coequalizer.cofork : cofork f g := colimit.cocone (parallel_pair f g)\n\n@[simp] lemma coequalizer.cofork_π :\n  (coequalizer.cofork f g).π = coequalizer.π f g := rfl\n\n@[simp] lemma coequalizer.cofork_ι_app_one :\n  (coequalizer.cofork f g).ι.app one = coequalizer.π f g := rfl\n\n@[reassoc] lemma coequalizer.condition : f ≫ coequalizer.π f g = g ≫ coequalizer.π f g :=\ncofork.condition $ colimit.cocone $ parallel_pair f g\n\n/-- The cofork built from `coequalizer.π f g` is colimiting. -/\ndef coequalizer_is_coequalizer :\n  is_colimit (cofork.of_π (coequalizer.π f g) (coequalizer.condition f g)) :=\nis_colimit.of_iso_colimit (colimit.is_colimit _) (cofork.ext (iso.refl _) (by tidy))\n\nvariables {f g}\n\n/-- Any morphism `k : Y ⟶ W` satisfying `f ≫ k = g ≫ k` factors through the coequalizer of `f`\n    and `g` via `coequalizer.desc : coequalizer f g ⟶ W`. -/\nabbreviation coequalizer.desc {W : C} (k : Y ⟶ W) (h : f ≫ k = g ≫ k) : coequalizer f g ⟶ W :=\ncolimit.desc (parallel_pair f g) (cofork.of_π k h)\n\n@[simp, reassoc]\nlemma coequalizer.π_desc {W : C} (k : Y ⟶ W) (h : f ≫ k = g ≫ k) :\n  coequalizer.π f g ≫ coequalizer.desc k h = k :=\ncolimit.ι_desc _ _\n\n/-- Any morphism `k : Y ⟶ W` satisfying `f ≫ k = g ≫ k` induces a morphism\n    `l : coequalizer f g ⟶ W` satisfying `coequalizer.π ≫ g = l`. -/\ndef coequalizer.desc' {W : C} (k : Y ⟶ W) (h : f ≫ k = g ≫ k) :\n  {l : coequalizer f g ⟶ W // coequalizer.π f g ≫ l = k} :=\n⟨coequalizer.desc k h, coequalizer.π_desc _ _⟩\n\n/-- Two maps from a coequalizer are equal if they are equal when composed with the coequalizer\n    map -/\n@[ext] lemma coequalizer.hom_ext {W : C} {k l : coequalizer f g ⟶ W}\n  (h : coequalizer.π f g ≫ k = coequalizer.π f g ≫ l) : k = l :=\ncofork.is_colimit.hom_ext (colimit.is_colimit _) h\n\n/-- A coequalizer morphism is an epimorphism -/\ninstance coequalizer.π_epi : epi (coequalizer.π f g) :=\n{ left_cancellation := λ Z h k w, coequalizer.hom_ext w }\n\nend\n\nsection\nvariables {f g}\n\n/-- The coequalizer morphism in any colimit cocone is an epimorphism. -/\nlemma epi_of_is_colimit_parallel_pair {c : cocone (parallel_pair f g)} (i : is_colimit c) :\n  epi (c.ι.app one) :=\n{ left_cancellation := λ Z h k w, cofork.is_colimit.hom_ext i w }\n\nend\n\nsection\nvariables {f g}\n\n/-- The identity determines a cocone on the coequalizer diagram of `f` and `g`, if `f = g`. -/\ndef id_cofork (h : f = g) : cofork f g :=\ncofork.of_π (𝟙 Y) $ h ▸ rfl\n\n/-- The identity on `Y` is a coequalizer of `(f, g)`, where `f = g`.  -/\ndef is_colimit_id_cofork (h : f = g) : is_colimit (id_cofork h) :=\ncofork.is_colimit.mk _\n  (λ s, cofork.π s)\n  (λ s, category.id_comp _)\n  (λ s m h, by { convert h one, exact (category.id_comp _).symm })\n\n/-- Every coequalizer of `(f, g)`, where `f = g`, is an isomorphism. -/\nlemma is_iso_colimit_cocone_parallel_pair_of_eq (h₀ : f = g) {c : cocone (parallel_pair f g)}\n  (h : is_colimit c) : is_iso (c.ι.app one) :=\nis_iso.of_iso $ is_colimit.cocone_point_unique_up_to_iso (is_colimit_id_cofork h₀) h\n\n/-- The coequalizer of `(f, g)`, where `f = g`, is an isomorphism. -/\nlemma coequalizer.π_of_eq [has_coequalizer f g] (h : f = g) :\n  is_iso (coequalizer.π f g) :=\nis_iso_colimit_cocone_parallel_pair_of_eq h $ colimit.is_colimit _\n\n/-- Every coequalizer of `(f, f)` is an isomorphism. -/\nlemma is_iso_colimit_cocone_parallel_pair_of_self {c : cocone (parallel_pair f f)}\n  (h : is_colimit c) : is_iso (c.ι.app one) :=\nis_iso_colimit_cocone_parallel_pair_of_eq rfl h\n\n/-- A coequalizer that is a monomorphism is an isomorphism. -/\nlemma is_iso_limit_cocone_parallel_pair_of_epi {c : cocone (parallel_pair f g)}\n  (h : is_colimit c) [mono (c.ι.app one)] : is_iso (c.ι.app one) :=\nis_iso_colimit_cocone_parallel_pair_of_eq ((cancel_mono _).1 (cofork.condition c)) h\n\nend\n\ninstance has_coequalizer_of_self : has_coequalizer f f :=\nhas_colimit.mk\n{ cocone := id_cofork rfl,\n  is_colimit := is_colimit_id_cofork rfl }\n\n/-- The coequalizer projection for `(f, f)` is an isomorphism. -/\ninstance coequalizer.π_of_self : is_iso (coequalizer.π f f) :=\ncoequalizer.π_of_eq rfl\n\n/-- The coequalizer of a morphism with itself is isomorphic to the target. -/\ndef coequalizer.iso_target_of_self : coequalizer f f ≅ Y :=\n(as_iso (coequalizer.π f f)).symm\n\n@[simp] lemma coequalizer.iso_target_of_self_hom :\n  (coequalizer.iso_target_of_self f).hom = coequalizer.desc (𝟙 Y) (by simp) :=\nby { ext, simp [coequalizer.iso_target_of_self], }\n\n@[simp] lemma coequalizer.iso_target_of_self_inv :\n  (coequalizer.iso_target_of_self f).inv = coequalizer.π f f :=\nrfl\n\nsection comparison\n\nvariables {D : Type u₂} [category.{v} D] (G : C ⥤ D)\n\n/--\nThe comparison morphism for the equalizer of `f,g`.\nThis is an isomorphism iff `G` preserves the equalizer of `f,g`; see\n`category_theory/limits/preserves/shapes/equalizers.lean`\n-/\ndef equalizer_comparison [has_equalizer f g] [has_equalizer (G.map f) (G.map g)] :\n  G.obj (equalizer f g) ⟶ equalizer (G.map f) (G.map g) :=\nequalizer.lift (G.map (equalizer.ι _ _)) (by simp only [←G.map_comp, equalizer.condition])\n\n@[simp, reassoc]\nlemma equalizer_comparison_comp_π [has_equalizer f g] [has_equalizer (G.map f) (G.map g)] :\n  equalizer_comparison f g G ≫ equalizer.ι (G.map f) (G.map g) = G.map (equalizer.ι f g) :=\nequalizer.lift_ι _ _\n\n@[simp, reassoc]\nlemma map_lift_equalizer_comparison [has_equalizer f g] [has_equalizer (G.map f) (G.map g)]\n  {Z : C} {h : Z ⟶ X} (w : h ≫ f = h ≫ g) :\n    G.map (equalizer.lift h w) ≫ equalizer_comparison f g G =\n      equalizer.lift (G.map h) (by simp only [←G.map_comp, w]) :=\nby { ext, simp [← G.map_comp] }\n\n/-- The comparison morphism for the coequalizer of `f,g`. -/\ndef coequalizer_comparison [has_coequalizer f g] [has_coequalizer (G.map f) (G.map g)] :\n  coequalizer (G.map f) (G.map g) ⟶ G.obj (coequalizer f g) :=\ncoequalizer.desc (G.map (coequalizer.π _ _)) (by simp only [←G.map_comp, coequalizer.condition])\n\n@[simp, reassoc]\nlemma ι_comp_coequalizer_comparison [has_coequalizer f g] [has_coequalizer (G.map f) (G.map g)] :\n  coequalizer.π _ _ ≫ coequalizer_comparison f g G = G.map (coequalizer.π _ _) :=\ncoequalizer.π_desc _ _\n\n@[simp, reassoc]\nlemma coequalizer_comparison_map_desc [has_coequalizer f g] [has_coequalizer (G.map f) (G.map g)]\n  {Z : C} {h : Y ⟶ Z} (w : f ≫ h = g ≫ h) :\n  coequalizer_comparison f g G ≫ G.map (coequalizer.desc h w) =\n    coequalizer.desc (G.map h) (by simp only [←G.map_comp, w]) :=\nby { ext, simp [← G.map_comp] }\n\nend comparison\n\nvariables (C)\n\n/-- `has_equalizers` represents a choice of equalizer for every pair of morphisms -/\nabbreviation has_equalizers := has_limits_of_shape walking_parallel_pair C\n\n/-- `has_coequalizers` represents a choice of coequalizer for every pair of morphisms -/\nabbreviation has_coequalizers := has_colimits_of_shape walking_parallel_pair C\n\n/-- If `C` has all limits of diagrams `parallel_pair f g`, then it has all equalizers -/\nlemma has_equalizers_of_has_limit_parallel_pair\n  [Π {X Y : C} {f g : X ⟶ Y}, has_limit (parallel_pair f g)] : has_equalizers C :=\n{ has_limit := λ F, has_limit_of_iso (diagram_iso_parallel_pair F).symm }\n\n/-- If `C` has all colimits of diagrams `parallel_pair f g`, then it has all coequalizers -/\nlemma has_coequalizers_of_has_colimit_parallel_pair\n  [Π {X Y : C} {f g : X ⟶ Y}, has_colimit (parallel_pair f g)] : has_coequalizers C :=\n{ has_colimit := λ F, has_colimit_of_iso (diagram_iso_parallel_pair F) }\n\n\nsection\n-- In this section we show that a split mono `f` equalizes `(retraction f ≫ f)` and `(𝟙 Y)`.\nvariables {C} [split_mono f]\n\n/--\nA split mono `f` equalizes `(retraction f ≫ f)` and `(𝟙 Y)`.\nHere we build the cone, and show in `split_mono_equalizes` that it is a limit cone.\n-/\n@[simps {rhs_md := semireducible}]\ndef cone_of_split_mono : cone (parallel_pair (𝟙 Y) (retraction f ≫ f)) :=\nfork.of_ι f (by simp)\n\n\n/--\nA split mono `f` equalizes `(retraction f ≫ f)` and `(𝟙 Y)`.\n-/\ndef split_mono_equalizes {X Y : C} (f : X ⟶ Y) [split_mono f] : is_limit (cone_of_split_mono f) :=\nfork.is_limit.mk' _ $ λ s,\n⟨s.ι ≫ retraction f,\n by { dsimp, rw [category.assoc, ←s.condition], apply category.comp_id },\n λ m hm, by simp [←hm]⟩\n\nend\n\nsection\n-- In this section we show that a split epi `f` coequalizes `(f ≫ section_ f)` and `(𝟙 X)`.\nvariables {C} [split_epi f]\n\n/--\nA split epi `f` coequalizes `(f ≫ section_ f)` and `(𝟙 X)`.\nHere we build the cocone, and show in `split_epi_coequalizes` that it is a colimit cocone.\n-/\n@[simps {rhs_md := semireducible}]\ndef cocone_of_split_epi : cocone (parallel_pair (𝟙 X) (f ≫ section_ f)) :=\ncofork.of_π f (by simp)\n\n/--\nA split epi `f` coequalizes `(f ≫ section_ f)` and `(𝟙 X)`.\n-/\ndef split_epi_coequalizes {X Y : C} (f : X ⟶ Y) [split_epi f] :\n  is_colimit (cocone_of_split_epi f) :=\ncofork.is_colimit.mk' _ $ λ s,\n⟨section_ f ≫ s.π,\n by { dsimp, rw [← category.assoc, ← s.condition, category.id_comp] },\n λ m hm, by simp [← hm]⟩\n\nend\n\nend category_theory.limits\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/shapes/equalizers.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.4550977192384078}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.lie.nilpotent\nimport algebra.lie.tensor_product\nimport algebra.lie.character\nimport algebra.lie.cartan_subalgebra\nimport linear_algebra.eigenspace\nimport ring_theory.tensor_product\n\n/-!\n# Weights and roots of Lie modules and Lie algebras\n\nJust as a key tool when studying the behaviour of a linear operator is to decompose the space on\nwhich it acts into a sum of (generalised) eigenspaces, a key tool when studying a representation `M`\nof Lie algebra `L` is to decompose `M` into a sum of simultaneous eigenspaces of `x` as `x` ranges\nover `L`. These simultaneous generalised eigenspaces are known as the weight spaces of `M`.\n\nWhen `L` is nilpotent, it follows from the binomial theorem that weight spaces are Lie submodules.\nEven when `L` is not nilpotent, it may be useful to study its representations by restricting them\nto a nilpotent subalgebra (e.g., a Cartan subalgebra). In the particular case when we view `L` as a\nmodule over itself via the adjoint action, the weight spaces of `L` restricted to a nilpotent\nsubalgebra are known as root spaces.\n\nBasic definitions and properties of the above ideas are provided in this file.\n\n## Main definitions\n\n  * `lie_module.weight_space`\n  * `lie_module.is_weight`\n  * `lie_algebra.root_space`\n  * `lie_algebra.is_root`\n  * `lie_algebra.root_space_weight_space_product`\n  * `lie_algebra.root_space_product`\n\n## References\n\n* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 7--9*](bourbaki1975b)\n\n## Tags\n\nlie character, eigenvalue, eigenspace, weight, weight vector, root, root vector\n-/\n\nuniverses u v w w₁ w₂ w₃\n\nvariables {R : Type u} {L : Type v} [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables (H : lie_subalgebra R L) [lie_algebra.is_nilpotent R H]\nvariables (M : Type w) [add_comm_group M] [module R M] [lie_ring_module L M] [lie_module R L M]\n\nnamespace lie_module\n\nopen lie_algebra\nopen tensor_product\nopen tensor_product.lie_module\n\nopen_locale big_operators\nopen_locale tensor_product\n\n/-- Given a Lie module `M` over a Lie algebra `L`, the pre-weight space of `M` with respect to a\nmap `χ : L → R` is the simultaneous generalized eigenspace of the action of all `x : L` on `M`,\nwith eigenvalues `χ x`.\n\nSee also `lie_module.weight_space`. -/\ndef pre_weight_space (χ : L → R) : submodule R M :=\n⨅ (x : L), (to_endomorphism R L M x).maximal_generalized_eigenspace (χ x)\n\nlemma mem_pre_weight_space (χ : L → R) (m : M) :\n  m ∈ pre_weight_space M χ ↔ ∀ x, ∃ (k : ℕ), ((to_endomorphism R L M x - (χ x) • 1)^k) m = 0 :=\nby simp [pre_weight_space, -linear_map.pow_apply]\n\nvariables (L)\n\n/-- See also `bourbaki1975b` Chapter VII §1.1, Proposition 2 (ii). -/\nprotected lemma weight_vector_multiplication (M₁ : Type w₁) (M₂ : Type w₂) (M₃ : Type w₃)\n  [add_comm_group M₁] [module R M₁] [lie_ring_module L M₁] [lie_module R L M₁]\n  [add_comm_group M₂] [module R M₂] [lie_ring_module L M₂] [lie_module R L M₂]\n  [add_comm_group M₃] [module R M₃] [lie_ring_module L M₃] [lie_module R L M₃]\n (g : M₁ ⊗[R] M₂ →ₗ⁅R,L⁆ M₃) (χ₁ χ₂ : L → R) :\n  ((g : M₁ ⊗[R] M₂ →ₗ[R] M₃).comp\n  (map_incl (pre_weight_space M₁ χ₁) (pre_weight_space M₂ χ₂))).range ≤\n    pre_weight_space M₃ (χ₁ + χ₂) :=\nbegin\n  /- Unpack the statement of the goal. -/\n  intros m₃,\n  simp only [lie_module_hom.coe_to_linear_map, pi.add_apply, function.comp_app,\n    mem_pre_weight_space, linear_map.coe_comp, tensor_product.map_incl, exists_imp_distrib,\n    linear_map.mem_range],\n  rintros t rfl x,\n\n  /- Set up some notation. -/\n  let F : module.End R M₃ := (to_endomorphism R L M₃ x) - (χ₁ x + χ₂ x) • 1,\n  change ∃ k, (F^k) (g _) = 0,\n\n  /- The goal is linear in `t` so use induction to reduce to the case that `t` is a pure tensor. -/\n  apply t.induction_on,\n  { use 0, simp only [linear_map.map_zero, lie_module_hom.map_zero], },\n  swap,\n  { rintros t₁ t₂ ⟨k₁, hk₁⟩ ⟨k₂, hk₂⟩, use max k₁ k₂,\n    simp only [lie_module_hom.map_add, linear_map.map_add,\n      linear_map.pow_map_zero_of_le (le_max_left k₁ k₂) hk₁,\n      linear_map.pow_map_zero_of_le (le_max_right k₁ k₂) hk₂, add_zero], },\n\n  /- Now the main argument: pure tensors. -/\n  rintros ⟨m₁, hm₁⟩ ⟨m₂, hm₂⟩,\n  change ∃ k, (F^k) ((g : M₁ ⊗[R] M₂ →ₗ[R] M₃) (m₁ ⊗ₜ m₂)) = 0,\n\n  /- Eliminate `g` from the picture. -/\n  let f₁ : module.End R (M₁ ⊗[R] M₂) := (to_endomorphism R L M₁ x - (χ₁ x) • 1).rtensor M₂,\n  let f₂ : module.End R (M₁ ⊗[R] M₂) := (to_endomorphism R L M₂ x - (χ₂ x) • 1).ltensor M₁,\n  have h_comm_square : F ∘ₗ ↑g = (g : M₁ ⊗[R] M₂ →ₗ[R] M₃).comp (f₁ + f₂),\n  { ext m₁ m₂, simp only [← g.map_lie x (m₁ ⊗ₜ m₂), add_smul, sub_tmul, tmul_sub, smul_tmul,\n      lie_tmul_right, tmul_smul, to_endomorphism_apply_apply, lie_module_hom.map_smul,\n      linear_map.one_apply, lie_module_hom.coe_to_linear_map, linear_map.smul_apply,\n      function.comp_app, linear_map.coe_comp, linear_map.rtensor_tmul, lie_module_hom.map_add,\n      linear_map.add_apply, lie_module_hom.map_sub, linear_map.sub_apply, linear_map.ltensor_tmul,\n      algebra_tensor_module.curry_apply, curry_apply, linear_map.to_fun_eq_coe,\n      linear_map.coe_restrict_scalars_eq_coe], abel, },\n  suffices : ∃ k, ((f₁ + f₂)^k) (m₁ ⊗ₜ m₂) = 0,\n  { obtain ⟨k, hk⟩ := this, use k,\n    rw [← linear_map.comp_apply, linear_map.commute_pow_left_of_commute h_comm_square,\n      linear_map.comp_apply, hk, linear_map.map_zero], },\n\n  /- Unpack the information we have about `m₁`, `m₂`. -/\n  simp only [mem_pre_weight_space] at hm₁ hm₂,\n  obtain ⟨k₁, hk₁⟩ := hm₁ x,\n  obtain ⟨k₂, hk₂⟩ := hm₂ x,\n  have hf₁ : (f₁^k₁) (m₁ ⊗ₜ m₂) = 0,\n  { simp only [hk₁, zero_tmul, linear_map.rtensor_tmul, linear_map.rtensor_pow], },\n  have hf₂ : (f₂^k₂) (m₁ ⊗ₜ m₂) = 0,\n  { simp only [hk₂, tmul_zero, linear_map.ltensor_tmul, linear_map.ltensor_pow], },\n\n  /- It's now just an application of the binomial theorem. -/\n  use k₁ + k₂ - 1,\n  have hf_comm : commute f₁ f₂,\n  { ext m₁ m₂, simp only [linear_map.mul_apply, linear_map.rtensor_tmul, linear_map.ltensor_tmul,\n      algebra_tensor_module.curry_apply, linear_map.to_fun_eq_coe, linear_map.ltensor_tmul,\n      curry_apply, linear_map.coe_restrict_scalars_eq_coe], },\n  rw hf_comm.add_pow',\n  simp only [tensor_product.map_incl, submodule.subtype_apply, finset.sum_apply,\n    submodule.coe_mk, linear_map.coe_fn_sum, tensor_product.map_tmul, linear_map.smul_apply],\n\n  /- The required sum is zero because each individual term is zero. -/\n  apply finset.sum_eq_zero,\n  rintros ⟨i, j⟩ hij,\n\n  /- Eliminate the binomial coefficients from the picture. -/\n  suffices : (f₁^i * f₂^j) (m₁ ⊗ₜ m₂) = 0, { rw this, apply smul_zero, },\n\n  /- Finish off with appropriate case analysis. -/\n  cases nat.le_or_le_of_add_eq_add_pred (finset.nat.mem_antidiagonal.mp hij) with hi hj,\n  { rw [(hf_comm.pow_pow i j).eq, linear_map.mul_apply, linear_map.pow_map_zero_of_le hi hf₁,\n    linear_map.map_zero], },\n  { rw [linear_map.mul_apply, linear_map.pow_map_zero_of_le hj hf₂, linear_map.map_zero], },\nend\n\nvariables {L M}\n\nlemma lie_mem_pre_weight_space_of_mem_pre_weight_space {χ₁ χ₂ : L → R} {x : L} {m : M}\n  (hx : x ∈ pre_weight_space L χ₁) (hm : m ∈ pre_weight_space M χ₂) :\n  ⁅x, m⁆ ∈ pre_weight_space M (χ₁ + χ₂) :=\nbegin\n  apply lie_module.weight_vector_multiplication L L M M (to_module_hom R L M) χ₁ χ₂,\n  simp only [lie_module_hom.coe_to_linear_map, function.comp_app, linear_map.coe_comp,\n    tensor_product.map_incl, linear_map.mem_range],\n  use [⟨x, hx⟩ ⊗ₜ ⟨m, hm⟩],\n  simp only [submodule.subtype_apply, to_module_hom_apply, tensor_product.map_tmul],\n  refl,\nend\n\nvariables (M)\n\n/-- If a Lie algebra is nilpotent, then pre-weight spaces are Lie submodules. -/\ndef weight_space [lie_algebra.is_nilpotent R L] (χ : L → R) : lie_submodule R L M :=\n{ lie_mem := λ x m hm,\n  begin\n    rw ← zero_add χ,\n    refine lie_mem_pre_weight_space_of_mem_pre_weight_space _ hm,\n    suffices : pre_weight_space L (0 : L → R) = ⊤, { simp only [this, submodule.mem_top], },\n    exact lie_algebra.infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L,\n  end,\n  .. pre_weight_space M χ }\n\nlemma mem_weight_space [lie_algebra.is_nilpotent R L] (χ : L → R) (m : M) :\n  m ∈ weight_space M χ ↔ m ∈ pre_weight_space M χ :=\niff.rfl\n\n/-- See also the more useful form `lie_module.zero_weight_space_eq_top_of_nilpotent`. -/\n@[simp] lemma zero_weight_space_eq_top_of_nilpotent'\n  [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] :\n  weight_space M (0 : L → R) = ⊤ :=\nbegin\n  rw [← lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule],\n  exact infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L M,\nend\n\nlemma coe_weight_space_of_top [lie_algebra.is_nilpotent R L] (χ : L → R) :\n  (weight_space M (χ ∘ (⊤ : lie_subalgebra R L).incl) : submodule R M) = weight_space M χ :=\nbegin\n  ext m,\n  simp only [weight_space, lie_submodule.coe_to_submodule_mk, lie_subalgebra.coe_bracket_of_module,\n    function.comp_app, mem_pre_weight_space],\n  split; intros h x,\n  { obtain ⟨k, hk⟩ := h ⟨x, set.mem_univ x⟩, use k, exact hk, },\n  { obtain ⟨k, hk⟩ := h x, use k, exact hk, },\nend\n\n@[simp] lemma zero_weight_space_eq_top_of_nilpotent\n  [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] :\n  weight_space M (0 : (⊤ : lie_subalgebra R L) → R) = ⊤ :=\nbegin\n  /- We use `coe_weight_space_of_top` as a trick to circumvent the fact that we don't (yet) know\n    `is_nilpotent R (⊤ : lie_subalgebra R L) M` is equivalent to `is_nilpotent R L M`. -/\n  have h₀ : (0 : L → R) ∘ (⊤ : lie_subalgebra R L).incl = 0, { ext, refl, },\n  rw [← lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule, ← h₀,\n    coe_weight_space_of_top, ← infi_max_gen_zero_eigenspace_eq_top_of_nilpotent R L M],\n  refl,\nend\n\n/-- Given a Lie module `M` of a Lie algebra `L`, a weight of `M` with respect to a nilpotent\nsubalgebra `H ⊆ L` is a Lie character whose corresponding weight space is non-empty. -/\ndef is_weight (χ : lie_character R H) : Prop := weight_space M χ ≠ ⊥\n\n/-- For a non-trivial nilpotent Lie module over a nilpotent Lie algebra, the zero character is a\nweight with respect to the `⊤` Lie subalgebra. -/\nlemma is_weight_zero_of_nilpotent\n   [nontrivial M] [lie_algebra.is_nilpotent R L] [is_nilpotent R L M] :\n   is_weight (⊤ : lie_subalgebra R L) M 0 :=\nby { rw [is_weight, lie_hom.coe_zero, zero_weight_space_eq_top_of_nilpotent], exact top_ne_bot, }\n\nend lie_module\n\nnamespace lie_algebra\n\nopen_locale tensor_product\nopen tensor_product.lie_module\nopen lie_module\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L`, the root space of a map `χ : H → R` is the weight\nspace of `L` regarded as a module of `H` via the adjoint action. -/\nabbreviation root_space (χ : H → R) : lie_submodule R H L := weight_space L χ\n\n@[simp] \n\n/-- A root of a Lie algebra `L` with respect to a nilpotent subalgebra `H ⊆ L` is a weight of `L`,\nregarded as a module of `H` via the adjoint action. -/\nabbreviation is_root := is_weight H L\n\n@[simp] lemma root_space_comap_eq_weight_space (χ : H → R) :\n  (root_space H χ).comap H.incl' = weight_space H χ :=\nbegin\n  ext x,\n  let f : H → module.End R L := λ y, to_endomorphism R H L y - (χ y) • 1,\n  let g : H → module.End R H := λ y, to_endomorphism R H H y - (χ y) • 1,\n  suffices : (∀ (y : H), ∃ (k : ℕ), ((f y)^k).comp (H.incl : H →ₗ[R] L) x = 0) ↔\n              ∀ (y : H), ∃ (k : ℕ), (H.incl : H →ₗ[R] L).comp ((g y)^k) x = 0,\n  { simp only [lie_hom.coe_to_linear_map, lie_subalgebra.coe_incl, function.comp_app,\n      linear_map.coe_comp, submodule.coe_eq_zero] at this,\n    simp only [mem_weight_space, mem_pre_weight_space,\n      lie_subalgebra.coe_incl', lie_submodule.mem_comap, this], },\n  have hfg : ∀ (y : H), (f y).comp (H.incl : H →ₗ[R] L) = (H.incl : H →ₗ[R] L).comp (g y),\n  { rintros ⟨y, hy⟩, ext ⟨z, hz⟩,\n    simp only [submodule.coe_sub, to_endomorphism_apply_apply, lie_hom.coe_to_linear_map,\n      linear_map.one_apply, lie_subalgebra.coe_incl, lie_subalgebra.coe_bracket_of_module,\n      lie_subalgebra.coe_bracket, linear_map.smul_apply, function.comp_app,\n      submodule.coe_smul_of_tower, linear_map.coe_comp, linear_map.sub_apply], },\n  simp_rw [linear_map.commute_pow_left_of_commute (hfg _)],\nend\n\nvariables {H M}\n\nlemma lie_mem_weight_space_of_mem_weight_space {χ₁ χ₂ : H → R} {x : L} {m : M}\n  (hx : x ∈ root_space H χ₁) (hm : m ∈ weight_space M χ₂) : ⁅x, m⁆ ∈ weight_space M (χ₁ + χ₂) :=\nbegin\n  apply lie_module.weight_vector_multiplication\n    H L M M ((to_module_hom R L M).restrict_lie H) χ₁ χ₂,\n  simp only [lie_module_hom.coe_to_linear_map, function.comp_app, linear_map.coe_comp,\n    tensor_product.map_incl, linear_map.mem_range],\n  use [⟨x, hx⟩ ⊗ₜ ⟨m, hm⟩],\n  simp only [submodule.subtype_apply, to_module_hom_apply, submodule.coe_mk,\n    lie_module_hom.coe_restrict_lie, tensor_product.map_tmul],\nend\n\nvariables (R L H M)\n\n/--\nAuxiliary definition for `root_space_weight_space_product`,\nwhich is close to the deterministic timeout limit.\n-/\ndef root_space_weight_space_product_aux {χ₁ χ₂ χ₃ : H → R} (hχ : χ₁ + χ₂ = χ₃) :\n  (root_space H χ₁) →ₗ[R] (weight_space M χ₂) →ₗ[R] (weight_space M χ₃) :=\n{ to_fun    := λ x,\n  { to_fun    :=\n      λ m, ⟨⁅(x : L), (m : M)⁆,\n            hχ ▸ (lie_mem_weight_space_of_mem_weight_space x.property m.property) ⟩,\n    map_add'  := λ m n, by { simp only [lie_submodule.coe_add, lie_add], refl, },\n    map_smul' := λ t m, by { conv_lhs { congr, rw [lie_submodule.coe_smul, lie_smul], }, refl, }, },\n  map_add'  := λ x y, by ext m; rw [linear_map.add_apply, linear_map.coe_mk, linear_map.coe_mk,\n    linear_map.coe_mk, subtype.coe_mk, lie_submodule.coe_add, lie_submodule.coe_add, add_lie,\n    subtype.coe_mk, subtype.coe_mk],\n  map_smul' := λ t x,\n  begin\n    simp only [ring_hom.id_apply],\n    ext m,\n    rw [linear_map.smul_apply, linear_map.coe_mk, linear_map.coe_mk,\n      subtype.coe_mk, lie_submodule.coe_smul, smul_lie, lie_submodule.coe_smul, subtype.coe_mk],\n  end, }\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L` together with `χ₁ χ₂ : H → R`, there is a natural\n`R`-bilinear product of root vectors and weight vectors, compatible with the actions of `H`. -/\ndef root_space_weight_space_product (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) :\n  (root_space H χ₁) ⊗[R] (weight_space M χ₂) →ₗ⁅R,H⁆ weight_space M χ₃ :=\nlift_lie R H (root_space H χ₁) (weight_space M χ₂) (weight_space M χ₃)\n{ to_linear_map := root_space_weight_space_product_aux R L H M hχ,\n  map_lie' := λ x y, by ext m; rw [root_space_weight_space_product_aux,\n    lie_hom.lie_apply, lie_submodule.coe_sub, linear_map.coe_mk,\n    linear_map.coe_mk, subtype.coe_mk, subtype.coe_mk, lie_submodule.coe_bracket,\n    lie_submodule.coe_bracket, subtype.coe_mk, lie_subalgebra.coe_bracket_of_module,\n    lie_subalgebra.coe_bracket_of_module, lie_submodule.coe_bracket,\n    lie_subalgebra.coe_bracket_of_module, lie_lie], }\n\n@[simp] lemma coe_root_space_weight_space_product_tmul\n  (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) (x : root_space H χ₁) (m : weight_space M χ₂) :\n  (root_space_weight_space_product R L H M χ₁ χ₂ χ₃ hχ (x ⊗ₜ m) : M) = ⁅(x : L), (m : M)⁆ :=\nby simp only [root_space_weight_space_product, root_space_weight_space_product_aux,\n  lift_apply, lie_module_hom.coe_to_linear_map,\n  coe_lift_lie_eq_lift_coe, submodule.coe_mk, linear_map.coe_mk, lie_module_hom.coe_mk]\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L` together with `χ₁ χ₂ : H → R`, there is a natural\n`R`-bilinear product of root vectors, compatible with the actions of `H`. -/\ndef root_space_product (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) :\n  (root_space H χ₁) ⊗[R] (root_space H χ₂) →ₗ⁅R,H⁆ root_space H χ₃ :=\nroot_space_weight_space_product R L H L χ₁ χ₂ χ₃ hχ\n\n@[simp] lemma root_space_product_def :\n  root_space_product R L H = root_space_weight_space_product R L H L :=\nrfl\n\nlemma root_space_product_tmul\n  (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) (x : root_space H χ₁) (y : root_space H χ₂) :\n  (root_space_product R L H χ₁ χ₂ χ₃ hχ (x ⊗ₜ y) : L) = ⁅(x : L), (y : L)⁆ :=\nby simp only [root_space_product_def, coe_root_space_weight_space_product_tmul]\n\n/-- Given a nilpotent Lie subalgebra `H ⊆ L`, the root space of the zero map `0 : H → R` is a Lie\nsubalgebra of `L`. -/\ndef zero_root_subalgebra : lie_subalgebra R L :=\n{ lie_mem' := λ x y hx hy, by\n  { let xy : (root_space H 0) ⊗[R] (root_space H 0) := ⟨x, hx⟩ ⊗ₜ ⟨y, hy⟩,\n    suffices : (root_space_product R L H 0 0 0 (add_zero 0) xy : L) ∈ root_space H 0,\n    { rwa [root_space_product_tmul, subtype.coe_mk, subtype.coe_mk] at this, },\n    exact (root_space_product R L H 0 0 0 (add_zero 0) xy).property, },\n  .. (root_space H 0 : submodule R L) }\n\n@[simp] lemma coe_zero_root_subalgebra :\n  (zero_root_subalgebra R L H : submodule R L) = root_space H 0 :=\nrfl\n\nlemma mem_zero_root_subalgebra (x : L) :\n  x ∈ zero_root_subalgebra R L H ↔ ∀ (y : H), ∃ (k : ℕ), ((to_endomorphism R H L y)^k) x = 0 :=\nby simp only [zero_root_subalgebra, mem_weight_space, mem_pre_weight_space, pi.zero_apply, sub_zero,\n  set_like.mem_coe, zero_smul, lie_submodule.mem_coe_submodule, submodule.mem_carrier,\n  lie_subalgebra.mem_mk_iff]\n\nlemma to_lie_submodule_le_root_space_zero : H.to_lie_submodule ≤ root_space H 0 :=\nbegin\n  intros x hx,\n  simp only [lie_subalgebra.mem_to_lie_submodule] at hx,\n  simp only [mem_weight_space, mem_pre_weight_space, pi.zero_apply, sub_zero, zero_smul],\n  intros y,\n  unfreezingI { obtain ⟨k, hk⟩ := (infer_instance : is_nilpotent R H) },\n  use k,\n  let f : module.End R H := to_endomorphism R H H y,\n  let g : module.End R L := to_endomorphism R H L y,\n  have hfg : g.comp (H : submodule R L).subtype = (H : submodule R L).subtype.comp f,\n  { ext z, simp only [to_endomorphism_apply_apply, submodule.subtype_apply,\n      lie_subalgebra.coe_bracket_of_module, lie_subalgebra.coe_bracket, function.comp_app,\n      linear_map.coe_comp], },\n  change (g^k).comp (H : submodule R L).subtype ⟨x, hx⟩ = 0,\n  rw linear_map.commute_pow_left_of_commute hfg k,\n  have h := iterate_to_endomorphism_mem_lower_central_series R H H y ⟨x, hx⟩ k,\n  rw [hk, lie_submodule.mem_bot] at h,\n  simp only [submodule.subtype_apply, function.comp_app, linear_map.pow_apply, linear_map.coe_comp,\n    submodule.coe_eq_zero],\n  exact h,\nend\n\nlemma le_zero_root_subalgebra : H ≤ zero_root_subalgebra R L H :=\nbegin\n  rw [← lie_subalgebra.coe_submodule_le_coe_submodule, ← H.coe_to_lie_submodule,\n    coe_zero_root_subalgebra, lie_submodule.coe_submodule_le_coe_submodule],\n  exact to_lie_submodule_le_root_space_zero R L H,\nend\n\n@[simp] lemma zero_root_subalgebra_normalizer_eq_self :\n  (zero_root_subalgebra R L H).normalizer = zero_root_subalgebra R L H :=\nbegin\n  refine le_antisymm _ (lie_subalgebra.le_normalizer _),\n  intros x hx,\n  rw lie_subalgebra.mem_normalizer_iff at hx,\n  rw mem_zero_root_subalgebra,\n  rintros ⟨y, hy⟩,\n  specialize hx y (le_zero_root_subalgebra R L H hy),\n  rw mem_zero_root_subalgebra at hx,\n  obtain ⟨k, hk⟩ := hx ⟨y, hy⟩,\n  rw [← lie_skew, linear_map.map_neg, neg_eq_zero] at hk,\n  use k + 1,\n  rw [linear_map.iterate_succ, linear_map.coe_comp, function.comp_app, to_endomorphism_apply_apply,\n    lie_subalgebra.coe_bracket_of_module, submodule.coe_mk, hk],\nend\n\n/-- In finite dimensions over a field (and possibly more generally) Engel's theorem shows that\nthe converse of this is also true, i.e.,\n`zero_root_subalgebra R L H = H ↔ lie_subalgebra.is_cartan_subalgebra H`. -/\nlemma zero_root_subalgebra_is_cartan_of_eq (h : zero_root_subalgebra R L H = H) :\n  lie_subalgebra.is_cartan_subalgebra H :=\n{ nilpotent        := infer_instance,\n  self_normalizing := by { rw ← h, exact zero_root_subalgebra_normalizer_eq_self R L H, } }\n\nend lie_algebra\n\nnamespace lie_module\n\nopen lie_algebra\n\nvariables {R L H}\n\n/-- A priori, weight spaces are Lie submodules over the Lie subalgebra `H` used to define them.\nHowever they are naturally Lie submodules over the (in general larger) Lie subalgebra\n`zero_root_subalgebra R L H`. Even though it is often the case that\n`zero_root_subalgebra R L H = H`, it is likely to be useful to have the flexibility not to have\nto invoke this equality (as well as to work more generally). -/\ndef weight_space' (χ : H → R) : lie_submodule R (zero_root_subalgebra R L H) M :=\n{ lie_mem := λ x m hm, by\n  { have hx : (x : L) ∈ root_space H 0,\n    { rw [← lie_submodule.mem_coe_submodule, ← coe_zero_root_subalgebra], exact x.property, },\n    rw ← zero_add χ,\n    exact lie_mem_weight_space_of_mem_weight_space hx hm, },\n  .. (weight_space M χ : submodule R M) }\n\n@[simp] lemma coe_weight_space' (χ : H → R) :\n  (weight_space' M χ : submodule R M) = weight_space M χ :=\nrfl\n\nend lie_module\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/lie/weights.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529716, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.4550977056500286}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n\n! This file was ported from Lean 3 source module algebra.group_with_zero.units.basic\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GroupWithZero.Basic\nimport Mathbin.Algebra.Group.Units\nimport Mathbin.Tactic.Nontriviality\nimport Mathbin.Tactic.AssertExists\n\n/-!\n# Lemmas about units in a `monoid_with_zero` or a `group_with_zero`.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe also define `ring.inverse`, a globally defined function on any ring\n(in fact any `monoid_with_zero`), which inverts units and sends non-units to zero.\n-/\n\n\nvariable {α M₀ G₀ M₀' G₀' F F' : Type _}\n\nvariable [MonoidWithZero M₀]\n\nnamespace Units\n\n/- warning: units.ne_zero -> Units.ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] [_inst_2 : Nontrivial.{u1} M₀] (u : Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)), Ne.{succ u1} M₀ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (coeBase.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (Units.hasCoe.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1))))) u) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] [_inst_2 : Nontrivial.{u1} M₀] (u : Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)), Ne.{succ u1} M₀ (Units.val.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) u) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))\nCase conversion may be inaccurate. Consider using '#align units.ne_zero Units.ne_zeroₓ'. -/\n/-- An element of the unit group of a nonzero monoid with zero represented as an element\n    of the monoid is nonzero. -/\n@[simp]\ntheorem ne_zero [Nontrivial M₀] (u : M₀ˣ) : (u : M₀) ≠ 0 :=\n  left_ne_zero_of_mul_eq_one u.mul_inv\n#align units.ne_zero Units.ne_zero\n\n/- warning: units.mul_left_eq_zero -> Units.mul_left_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (u : Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) {a : M₀}, Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (coeBase.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (Units.hasCoe.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1))))) u)) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))) (Eq.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (u : Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) {a : M₀}, Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) a (Units.val.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) u)) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))) (Eq.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1))))\nCase conversion may be inaccurate. Consider using '#align units.mul_left_eq_zero Units.mul_left_eq_zeroₓ'. -/\n-- We can't use `mul_eq_zero` + `units.ne_zero` in the next two lemmas because we don't assume\n-- `nonzero M₀`.\n@[simp]\ntheorem mul_left_eq_zero (u : M₀ˣ) {a : M₀} : a * u = 0 ↔ a = 0 :=\n  ⟨fun h => by simpa using mul_eq_zero_of_left h ↑u⁻¹, fun h => mul_eq_zero_of_left h u⟩\n#align units.mul_left_eq_zero Units.mul_left_eq_zero\n\n/- warning: units.mul_right_eq_zero -> Units.mul_right_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (u : Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) {a : M₀}, Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (coeBase.{succ u1, succ u1} (Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) M₀ (Units.hasCoe.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1))))) u) a) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))) (Eq.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (u : Units.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)) {a : M₀}, Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Units.val.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) u) a) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))) (Eq.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1))))\nCase conversion may be inaccurate. Consider using '#align units.mul_right_eq_zero Units.mul_right_eq_zeroₓ'. -/\n@[simp]\ntheorem mul_right_eq_zero (u : M₀ˣ) {a : M₀} : ↑u * a = 0 ↔ a = 0 :=\n  ⟨fun h => by simpa using mul_eq_zero_of_right (↑u⁻¹) h, mul_eq_zero_of_right u⟩\n#align units.mul_right_eq_zero Units.mul_right_eq_zero\n\nend Units\n\nnamespace IsUnit\n\n/- warning: is_unit.ne_zero -> IsUnit.ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] [_inst_2 : Nontrivial.{u1} M₀] {a : M₀}, (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) a) -> (Ne.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] [_inst_2 : Nontrivial.{u1} M₀] {a : M₀}, (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) a) -> (Ne.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1))))\nCase conversion may be inaccurate. Consider using '#align is_unit.ne_zero IsUnit.ne_zeroₓ'. -/\ntheorem ne_zero [Nontrivial M₀] {a : M₀} (ha : IsUnit a) : a ≠ 0 :=\n  let ⟨u, hu⟩ := ha\n  hu ▸ u.NeZero\n#align is_unit.ne_zero IsUnit.ne_zero\n\n/- warning: is_unit.mul_right_eq_zero -> IsUnit.mul_right_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] {a : M₀} {b : M₀}, (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) a) -> (Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) a b) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))) (Eq.{succ u1} M₀ b (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] {a : M₀} {b : M₀}, (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) a) -> (Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) a b) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))) (Eq.{succ u1} M₀ b (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align is_unit.mul_right_eq_zero IsUnit.mul_right_eq_zeroₓ'. -/\ntheorem mul_right_eq_zero {a b : M₀} (ha : IsUnit a) : a * b = 0 ↔ b = 0 :=\n  let ⟨u, hu⟩ := ha\n  hu ▸ u.mul_right_eq_zero\n#align is_unit.mul_right_eq_zero IsUnit.mul_right_eq_zero\n\n/- warning: is_unit.mul_left_eq_zero -> IsUnit.mul_left_eq_zero is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] {a : M₀} {b : M₀}, (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) b) -> (Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) a b) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))) (Eq.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] {a : M₀} {b : M₀}, (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) b) -> (Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) a b) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))) (Eq.{succ u1} M₀ a (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align is_unit.mul_left_eq_zero IsUnit.mul_left_eq_zeroₓ'. -/\ntheorem mul_left_eq_zero {a b : M₀} (hb : IsUnit b) : a * b = 0 ↔ a = 0 :=\n  let ⟨u, hu⟩ := hb\n  hu ▸ u.mul_left_eq_zero\n#align is_unit.mul_left_eq_zero IsUnit.mul_left_eq_zero\n\nend IsUnit\n\n/- warning: is_unit_zero_iff -> isUnit_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀], Iff (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))) (Eq.{succ u1} M₀ (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))) (OfNat.ofNat.{u1} M₀ 1 (OfNat.mk.{u1} M₀ 1 (One.one.{u1} M₀ (MulOneClass.toHasOne.{u1} M₀ (MulZeroOneClass.toMulOneClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀], Iff (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))) (Eq.{succ u1} M₀ (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1))) (OfNat.ofNat.{u1} M₀ 1 (One.toOfNat1.{u1} M₀ (Monoid.toOne.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align is_unit_zero_iff isUnit_zero_iffₓ'. -/\n@[simp]\ntheorem isUnit_zero_iff : IsUnit (0 : M₀) ↔ (0 : M₀) = 1 :=\n  ⟨fun ⟨⟨_, a, (a0 : 0 * a = 1), _⟩, rfl⟩ => by rwa [MulZeroClass.zero_mul] at a0, fun h =>\n    @isUnit_of_subsingleton _ _ (subsingleton_of_zero_eq_one h) 0⟩\n#align is_unit_zero_iff isUnit_zero_iff\n\n/- warning: not_is_unit_zero -> not_isUnit_zero is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] [_inst_2 : Nontrivial.{u1} M₀], Not (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] [_inst_2 : Nontrivial.{u1} M₀], Not (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1))))\nCase conversion may be inaccurate. Consider using '#align not_is_unit_zero not_isUnit_zeroₓ'. -/\n@[simp]\ntheorem not_isUnit_zero [Nontrivial M₀] : ¬IsUnit (0 : M₀) :=\n  mt isUnit_zero_iff.1 zero_ne_one\n#align not_is_unit_zero not_isUnit_zero\n\nnamespace Ring\n\nopen Classical\n\n#print Ring.inverse /-\n/-- Introduce a function `inverse` on a monoid with zero `M₀`, which sends `x` to `x⁻¹` if `x` is\ninvertible and to `0` otherwise.  This definition is somewhat ad hoc, but one needs a fully (rather\nthan partially) defined inverse function for some purposes, including for calculus.\n\nNote that while this is in the `ring` namespace for brevity, it requires the weaker assumption\n`monoid_with_zero M₀` instead of `ring M₀`. -/\nnoncomputable def inverse : M₀ → M₀ := fun x => if h : IsUnit x then ((h.Unit⁻¹ : M₀ˣ) : M₀) else 0\n#align ring.inverse Ring.inverse\n-/\n\n#print Ring.inverse_unit /-\n/-- By definition, if `x` is invertible then `inverse x = x⁻¹`. -/\n@[simp]\ntheorem inverse_unit (u : M₀ˣ) : inverse (u : M₀) = (u⁻¹ : M₀ˣ) :=\n  by\n  simp only [Units.isUnit, inverse, dif_pos]\n  exact Units.inv_unique rfl\n#align ring.inverse_unit Ring.inverse_unit\n-/\n\n/- warning: ring.inverse_non_unit -> Ring.inverse_non_unit is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀), (Not (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x)) -> (Eq.{succ u1} M₀ (Ring.inverse.{u1} M₀ _inst_1 x) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀), (Not (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x)) -> (Eq.{succ u1} M₀ (Ring.inverse.{u1} M₀ _inst_1 x) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1))))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_non_unit Ring.inverse_non_unitₓ'. -/\n/-- By definition, if `x` is not invertible then `inverse x = 0`. -/\n@[simp]\ntheorem inverse_non_unit (x : M₀) (h : ¬IsUnit x) : inverse x = 0 :=\n  dif_neg h\n#align ring.inverse_non_unit Ring.inverse_non_unit\n\n/- warning: ring.mul_inverse_cancel -> Ring.mul_inverse_cancel is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x (Ring.inverse.{u1} M₀ _inst_1 x)) (OfNat.ofNat.{u1} M₀ 1 (OfNat.mk.{u1} M₀ 1 (One.one.{u1} M₀ (MulOneClass.toHasOne.{u1} M₀ (MulZeroOneClass.toMulOneClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x (Ring.inverse.{u1} M₀ _inst_1 x)) (OfNat.ofNat.{u1} M₀ 1 (One.toOfNat1.{u1} M₀ (Monoid.toOne.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align ring.mul_inverse_cancel Ring.mul_inverse_cancelₓ'. -/\ntheorem mul_inverse_cancel (x : M₀) (h : IsUnit x) : x * inverse x = 1 :=\n  by\n  rcases h with ⟨u, rfl⟩\n  rw [inverse_unit, Units.mul_inv]\n#align ring.mul_inverse_cancel Ring.mul_inverse_cancel\n\n/- warning: ring.inverse_mul_cancel -> Ring.inverse_mul_cancel is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) x) (OfNat.ofNat.{u1} M₀ 1 (OfNat.mk.{u1} M₀ 1 (One.one.{u1} M₀ (MulOneClass.toHasOne.{u1} M₀ (MulZeroOneClass.toMulOneClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))))))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) x) (OfNat.ofNat.{u1} M₀ 1 (One.toOfNat1.{u1} M₀ (Monoid.toOne.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_mul_cancel Ring.inverse_mul_cancelₓ'. -/\ntheorem inverse_mul_cancel (x : M₀) (h : IsUnit x) : inverse x * x = 1 :=\n  by\n  rcases h with ⟨u, rfl⟩\n  rw [inverse_unit, Units.inv_mul]\n#align ring.inverse_mul_cancel Ring.inverse_mul_cancel\n\n/- warning: ring.mul_inverse_cancel_right -> Ring.mul_inverse_cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) y x) (Ring.inverse.{u1} M₀ _inst_1 x)) y)\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) y x) (Ring.inverse.{u1} M₀ _inst_1 x)) y)\nCase conversion may be inaccurate. Consider using '#align ring.mul_inverse_cancel_right Ring.mul_inverse_cancel_rightₓ'. -/\ntheorem mul_inverse_cancel_right (x y : M₀) (h : IsUnit x) : y * x * inverse x = y := by\n  rw [mul_assoc, mul_inverse_cancel x h, mul_one]\n#align ring.mul_inverse_cancel_right Ring.mul_inverse_cancel_right\n\n/- warning: ring.inverse_mul_cancel_right -> Ring.inverse_mul_cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) y (Ring.inverse.{u1} M₀ _inst_1 x)) x) y)\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) y (Ring.inverse.{u1} M₀ _inst_1 x)) x) y)\nCase conversion may be inaccurate. Consider using '#align ring.inverse_mul_cancel_right Ring.inverse_mul_cancel_rightₓ'. -/\ntheorem inverse_mul_cancel_right (x y : M₀) (h : IsUnit x) : y * inverse x * x = y := by\n  rw [mul_assoc, inverse_mul_cancel x h, mul_one]\n#align ring.inverse_mul_cancel_right Ring.inverse_mul_cancel_right\n\n/- warning: ring.mul_inverse_cancel_left -> Ring.mul_inverse_cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) y)) y)\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) y)) y)\nCase conversion may be inaccurate. Consider using '#align ring.mul_inverse_cancel_left Ring.mul_inverse_cancel_leftₓ'. -/\ntheorem mul_inverse_cancel_left (x y : M₀) (h : IsUnit x) : x * (inverse x * y) = y := by\n  rw [← mul_assoc, mul_inverse_cancel x h, one_mul]\n#align ring.mul_inverse_cancel_left Ring.mul_inverse_cancel_left\n\n/- warning: ring.inverse_mul_cancel_left -> Ring.inverse_mul_cancel_left is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x y)) y)\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x y)) y)\nCase conversion may be inaccurate. Consider using '#align ring.inverse_mul_cancel_left Ring.inverse_mul_cancel_leftₓ'. -/\ntheorem inverse_mul_cancel_left (x y : M₀) (h : IsUnit x) : inverse x * (x * y) = y := by\n  rw [← mul_assoc, inverse_mul_cancel x h, one_mul]\n#align ring.inverse_mul_cancel_left Ring.inverse_mul_cancel_left\n\n/- warning: ring.inverse_mul_eq_iff_eq_mul -> Ring.inverse_mul_eq_iff_eq_mul is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀) (z : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) y) z) (Eq.{succ u1} M₀ y (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x z)))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀) (z : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) x) -> (Iff (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) (Ring.inverse.{u1} M₀ _inst_1 x) y) z) (Eq.{succ u1} M₀ y (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x z)))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_mul_eq_iff_eq_mul Ring.inverse_mul_eq_iff_eq_mulₓ'. -/\ntheorem inverse_mul_eq_iff_eq_mul (x y z : M₀) (h : IsUnit x) : inverse x * y = z ↔ y = x * z :=\n  ⟨fun h1 => by rw [← h1, mul_inverse_cancel_left _ _ h], fun h1 => by\n    rw [h1, inverse_mul_cancel_left _ _ h]⟩\n#align ring.inverse_mul_eq_iff_eq_mul Ring.inverse_mul_eq_iff_eq_mul\n\n/- warning: ring.eq_mul_inverse_iff_mul_eq -> Ring.eq_mul_inverse_iff_mul_eq is a dubious translation:\nlean 3 declaration is\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀) (z : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) z) -> (Iff (Eq.{succ u1} M₀ x (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) y (Ring.inverse.{u1} M₀ _inst_1 z))) (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toHasMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x z) y))\nbut is expected to have type\n  forall {M₀ : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M₀] (x : M₀) (y : M₀) (z : M₀), (IsUnit.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1) z) -> (Iff (Eq.{succ u1} M₀ x (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) y (Ring.inverse.{u1} M₀ _inst_1 z))) (Eq.{succ u1} M₀ (HMul.hMul.{u1, u1, u1} M₀ M₀ M₀ (instHMul.{u1} M₀ (MulZeroClass.toMul.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1)))) x z) y))\nCase conversion may be inaccurate. Consider using '#align ring.eq_mul_inverse_iff_mul_eq Ring.eq_mul_inverse_iff_mul_eqₓ'. -/\ntheorem eq_mul_inverse_iff_mul_eq (x y z : M₀) (h : IsUnit z) : x = y * inverse z ↔ x * z = y :=\n  ⟨fun h1 => by rw [h1, inverse_mul_cancel_right _ _ h], fun h1 => by\n    rw [← h1, mul_inverse_cancel_right _ _ h]⟩\n#align ring.eq_mul_inverse_iff_mul_eq Ring.eq_mul_inverse_iff_mul_eq\n\nvariable (M₀)\n\n/- warning: ring.inverse_one -> Ring.inverse_one is a dubious translation:\nlean 3 declaration is\n  forall (M₀ : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M₀], Eq.{succ u1} M₀ (Ring.inverse.{u1} M₀ _inst_1 (OfNat.ofNat.{u1} M₀ 1 (OfNat.mk.{u1} M₀ 1 (One.one.{u1} M₀ (MulOneClass.toHasOne.{u1} M₀ (MulZeroOneClass.toMulOneClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))) (OfNat.ofNat.{u1} M₀ 1 (OfNat.mk.{u1} M₀ 1 (One.one.{u1} M₀ (MulOneClass.toHasOne.{u1} M₀ (MulZeroOneClass.toMulOneClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))\nbut is expected to have type\n  forall (M₀ : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M₀], Eq.{succ u1} M₀ (Ring.inverse.{u1} M₀ _inst_1 (OfNat.ofNat.{u1} M₀ 1 (One.toOfNat1.{u1} M₀ (Monoid.toOne.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1))))) (OfNat.ofNat.{u1} M₀ 1 (One.toOfNat1.{u1} M₀ (Monoid.toOne.{u1} M₀ (MonoidWithZero.toMonoid.{u1} M₀ _inst_1))))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_one Ring.inverse_oneₓ'. -/\n@[simp]\ntheorem inverse_one : inverse (1 : M₀) = 1 :=\n  inverse_unit 1\n#align ring.inverse_one Ring.inverse_one\n\n/- warning: ring.inverse_zero -> Ring.inverse_zero is a dubious translation:\nlean 3 declaration is\n  forall (M₀ : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M₀], Eq.{succ u1} M₀ (Ring.inverse.{u1} M₀ _inst_1 (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))) (OfNat.ofNat.{u1} M₀ 0 (OfNat.mk.{u1} M₀ 0 (Zero.zero.{u1} M₀ (MulZeroClass.toHasZero.{u1} M₀ (MulZeroOneClass.toMulZeroClass.{u1} M₀ (MonoidWithZero.toMulZeroOneClass.{u1} M₀ _inst_1))))))\nbut is expected to have type\n  forall (M₀ : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M₀], Eq.{succ u1} M₀ (Ring.inverse.{u1} M₀ _inst_1 (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))) (OfNat.ofNat.{u1} M₀ 0 (Zero.toOfNat0.{u1} M₀ (MonoidWithZero.toZero.{u1} M₀ _inst_1)))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_zero Ring.inverse_zeroₓ'. -/\n@[simp]\ntheorem inverse_zero : inverse (0 : M₀) = 0 :=\n  by\n  nontriviality\n  exact inverse_non_unit _ not_isUnit_zero\n#align ring.inverse_zero Ring.inverse_zero\n\nvariable {M₀}\n\nend Ring\n\n#print IsUnit.ring_inverse /-\ntheorem IsUnit.ring_inverse {a : M₀} : IsUnit a → IsUnit (Ring.inverse a)\n  | ⟨u, hu⟩ => hu ▸ ⟨u⁻¹, (Ring.inverse_unit u).symm⟩\n#align is_unit.ring_inverse IsUnit.ring_inverse\n-/\n\n#print isUnit_ring_inverse /-\n@[simp]\ntheorem isUnit_ring_inverse {a : M₀} : IsUnit (Ring.inverse a) ↔ IsUnit a :=\n  ⟨fun h => by\n    cases subsingleton_or_nontrivial M₀\n    · convert h\n    · contrapose h\n      rw [Ring.inverse_non_unit _ h]\n      exact not_isUnit_zero, IsUnit.ring_inverse⟩\n#align is_unit_ring_inverse isUnit_ring_inverse\n-/\n\nnamespace Units\n\nvariable [GroupWithZero G₀]\n\nvariable {a b : G₀}\n\n/- warning: units.mk0 -> Units.mk0 is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (a : G₀), (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) -> (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (a : G₀), (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) -> (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))\nCase conversion may be inaccurate. Consider using '#align units.mk0 Units.mk0ₓ'. -/\n/-- Embed a non-zero element of a `group_with_zero` into the unit group.\n  By combining this function with the operations on units,\n  or the `/ₚ` operation, it is possible to write a division\n  as a partial function with three arguments. -/\ndef mk0 (a : G₀) (ha : a ≠ 0) : G₀ˣ :=\n  ⟨a, a⁻¹, mul_inv_cancel ha, inv_mul_cancel ha⟩\n#align units.mk0 Units.mk0\n\n/- warning: units.mk0_one -> Units.mk0_one is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (h : optParam.{0} (Ne.{succ u1} G₀ (OfNat.ofNat.{u1} G₀ 1 (OfNat.mk.{u1} G₀ 1 (One.one.{u1} G₀ (MulOneClass.toHasOne.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (one_ne_zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))) (MulOneClass.toHasOne.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))) (NeZero.one.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) (GroupWithZero.to_nontrivial.{u1} G₀ _inst_2)))), Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 (OfNat.ofNat.{u1} G₀ 1 (OfNat.mk.{u1} G₀ 1 (One.one.{u1} G₀ (MulOneClass.toHasOne.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) h) (OfNat.ofNat.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) 1 (OfNat.mk.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) 1 (One.one.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (MulOneClass.toHasOne.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mulOneClass.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (h : optParam.{0} (Ne.{succ u1} G₀ (OfNat.ofNat.{u1} G₀ 1 (One.toOfNat1.{u1} G₀ (InvOneClass.toOne.{u1} G₀ (DivInvOneMonoid.toInvOneClass.{u1} G₀ (DivisionMonoid.toDivInvOneMonoid.{u1} G₀ (GroupWithZero.toDivisionMonoid.{u1} G₀ _inst_2)))))) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (one_ne_zero.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) (InvOneClass.toOne.{u1} G₀ (DivInvOneMonoid.toInvOneClass.{u1} G₀ (DivisionMonoid.toDivInvOneMonoid.{u1} G₀ (GroupWithZero.toDivisionMonoid.{u1} G₀ _inst_2)))) (NeZero.one.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) (GroupWithZero.toNontrivial.{u1} G₀ _inst_2)))), Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 (OfNat.ofNat.{u1} G₀ 1 (One.toOfNat1.{u1} G₀ (InvOneClass.toOne.{u1} G₀ (DivInvOneMonoid.toInvOneClass.{u1} G₀ (DivisionMonoid.toDivInvOneMonoid.{u1} G₀ (GroupWithZero.toDivisionMonoid.{u1} G₀ _inst_2)))))) h) (OfNat.ofNat.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) 1 (One.toOfNat1.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (InvOneClass.toOne.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Group.toDivisionMonoid.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.instGroupUnits.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align units.mk0_one Units.mk0_oneₓ'. -/\n@[simp]\ntheorem mk0_one (h := one_ne_zero) : mk0 (1 : G₀) h = 1 :=\n  by\n  ext\n  rfl\n#align units.mk0_one Units.mk0_one\n\n/- warning: units.coe_mk0 -> Units.val_mk0 is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} (h : Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))), Eq.{succ u1} G₀ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) (Units.mk0.{u1} G₀ _inst_2 a h)) a\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} (h : Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))), Eq.{succ u1} G₀ (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) (Units.mk0.{u1} G₀ _inst_2 a h)) a\nCase conversion may be inaccurate. Consider using '#align units.coe_mk0 Units.val_mk0ₓ'. -/\n@[simp]\ntheorem val_mk0 {a : G₀} (h : a ≠ 0) : (mk0 a h : G₀) = a :=\n  rfl\n#align units.coe_mk0 Units.val_mk0\n\n/- warning: units.mk0_coe -> Units.mk0_val is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (h : Ne.{succ u1} G₀ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))), Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u) h) u\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (h : Ne.{succ u1} G₀ (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))), Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u) h) u\nCase conversion may be inaccurate. Consider using '#align units.mk0_coe Units.mk0_valₓ'. -/\n@[simp]\ntheorem mk0_val (u : G₀ˣ) (h : (u : G₀) ≠ 0) : mk0 (u : G₀) h = u :=\n  Units.ext rfl\n#align units.mk0_coe Units.mk0_val\n\n/- warning: units.mul_inv' -> Units.mul_inv' is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))), Eq.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u) (Inv.inv.{u1} G₀ (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_2)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u))) (OfNat.ofNat.{u1} G₀ 1 (OfNat.mk.{u1} G₀ 1 (One.one.{u1} G₀ (MulOneClass.toHasOne.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))), Eq.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u) (Inv.inv.{u1} G₀ (GroupWithZero.toInv.{u1} G₀ _inst_2) (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u))) (OfNat.ofNat.{u1} G₀ 1 (One.toOfNat1.{u1} G₀ (InvOneClass.toOne.{u1} G₀ (DivInvOneMonoid.toInvOneClass.{u1} G₀ (DivisionMonoid.toDivInvOneMonoid.{u1} G₀ (GroupWithZero.toDivisionMonoid.{u1} G₀ _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align units.mul_inv' Units.mul_inv'ₓ'. -/\n@[simp]\ntheorem mul_inv' (u : G₀ˣ) : (u : G₀) * u⁻¹ = 1 :=\n  mul_inv_cancel u.NeZero\n#align units.mul_inv' Units.mul_inv'\n\n/- warning: units.inv_mul' -> Units.inv_mul' is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))), Eq.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Inv.inv.{u1} G₀ (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_2)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u)) (OfNat.ofNat.{u1} G₀ 1 (OfNat.mk.{u1} G₀ 1 (One.one.{u1} G₀ (MulOneClass.toHasOne.{u1} G₀ (MulZeroOneClass.toMulOneClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))), Eq.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Inv.inv.{u1} G₀ (GroupWithZero.toInv.{u1} G₀ _inst_2) (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u)) (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u)) (OfNat.ofNat.{u1} G₀ 1 (One.toOfNat1.{u1} G₀ (InvOneClass.toOne.{u1} G₀ (DivInvOneMonoid.toInvOneClass.{u1} G₀ (DivisionMonoid.toDivInvOneMonoid.{u1} G₀ (GroupWithZero.toDivisionMonoid.{u1} G₀ _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align units.inv_mul' Units.inv_mul'ₓ'. -/\n@[simp]\ntheorem inv_mul' (u : G₀ˣ) : (u⁻¹ : G₀) * u = 1 :=\n  inv_mul_cancel u.NeZero\n#align units.inv_mul' Units.inv_mul'\n\n/- warning: units.mk0_inj -> Units.mk0_inj is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀} (ha : Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (hb : Ne.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))), Iff (Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 a ha) (Units.mk0.{u1} G₀ _inst_2 b hb)) (Eq.{succ u1} G₀ a b)\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀} (ha : Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (hb : Ne.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))), Iff (Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 a ha) (Units.mk0.{u1} G₀ _inst_2 b hb)) (Eq.{succ u1} G₀ a b)\nCase conversion may be inaccurate. Consider using '#align units.mk0_inj Units.mk0_injₓ'. -/\n@[simp]\ntheorem mk0_inj {a b : G₀} (ha : a ≠ 0) (hb : b ≠ 0) : Units.mk0 a ha = Units.mk0 b hb ↔ a = b :=\n  ⟨fun h => by injection h, fun h => Units.ext h⟩\n#align units.mk0_inj Units.mk0_inj\n\n/- warning: units.exists0 -> Units.exists0 is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {p : (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) -> Prop}, Iff (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (g : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => p g)) (Exists.{succ u1} G₀ (fun (g : G₀) => Exists.{0} (Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (fun (hg : Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) => p (Units.mk0.{u1} G₀ _inst_2 g hg))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {p : (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) -> Prop}, Iff (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (g : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => p g)) (Exists.{succ u1} G₀ (fun (g : G₀) => Exists.{0} (Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (fun (hg : Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) => p (Units.mk0.{u1} G₀ _inst_2 g hg))))\nCase conversion may be inaccurate. Consider using '#align units.exists0 Units.exists0ₓ'. -/\n/-- In a group with zero, an existential over a unit can be rewritten in terms of `units.mk0`. -/\ntheorem exists0 {p : G₀ˣ → Prop} : (∃ g : G₀ˣ, p g) ↔ ∃ (g : G₀)(hg : g ≠ 0), p (Units.mk0 g hg) :=\n  ⟨fun ⟨g, pg⟩ => ⟨g, g.NeZero, (g.mk0_val g.NeZero).symm ▸ pg⟩, fun ⟨g, hg, pg⟩ =>\n    ⟨Units.mk0 g hg, pg⟩⟩\n#align units.exists0 Units.exists0\n\n/- warning: units.exists0' -> Units.exists0' is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {p : forall (g : G₀), (Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) -> Prop}, Iff (Exists.{succ u1} G₀ (fun (g : G₀) => Exists.{0} (Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (fun (hg : Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) => p g hg))) (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (g : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) g) (Units.ne_zero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2) (GroupWithZero.to_nontrivial.{u1} G₀ _inst_2) g)))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {p : forall (g : G₀), (Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) -> Prop}, Iff (Exists.{succ u1} G₀ (fun (g : G₀) => Exists.{0} (Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (fun (hg : Ne.{succ u1} G₀ g (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) => p g hg))) (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (g : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => p (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) g) (Units.ne_zero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2) (GroupWithZero.toNontrivial.{u1} G₀ _inst_2) g)))\nCase conversion may be inaccurate. Consider using '#align units.exists0' Units.exists0'ₓ'. -/\n/-- An alternative version of `units.exists0`. This one is useful if Lean cannot\nfigure out `p` when using `units.exists0` from right to left. -/\ntheorem exists0' {p : ∀ g : G₀, g ≠ 0 → Prop} :\n    (∃ (g : G₀)(hg : g ≠ 0), p g hg) ↔ ∃ g : G₀ˣ, p g g.NeZero :=\n  Iff.trans (by simp_rw [coe_mk0]) exists0.symm\n#align units.exists0' Units.exists0'\n\n/- warning: units.exists_iff_ne_zero -> Units.exists_iff_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {x : G₀}, Iff (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => Eq.{succ u1} G₀ ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u) x)) (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {x : G₀}, Iff (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => Eq.{succ u1} G₀ (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u) x)) (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align units.exists_iff_ne_zero Units.exists_iff_ne_zeroₓ'. -/\n@[simp]\ntheorem exists_iff_ne_zero {x : G₀} : (∃ u : G₀ˣ, ↑u = x) ↔ x ≠ 0 := by simp [exists0]\n#align units.exists_iff_ne_zero Units.exists_iff_ne_zero\n\n/- warning: group_with_zero.eq_zero_or_unit -> GroupWithZero.eq_zero_or_unit is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (a : G₀), Or (Eq.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => Eq.{succ u1} G₀ a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (coeBase.{succ u1, succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) G₀ (Units.hasCoe.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))) u)))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (a : G₀), Or (Eq.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Exists.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (fun (u : Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) => Eq.{succ u1} G₀ a (Units.val.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) u)))\nCase conversion may be inaccurate. Consider using '#align group_with_zero.eq_zero_or_unit GroupWithZero.eq_zero_or_unitₓ'. -/\ntheorem GroupWithZero.eq_zero_or_unit (a : G₀) : a = 0 ∨ ∃ u : G₀ˣ, a = u :=\n  by\n  by_cases h : a = 0\n  · left\n    exact h\n  · right\n    simpa only [eq_comm] using units.exists_iff_ne_zero.mpr h\n#align group_with_zero.eq_zero_or_unit GroupWithZero.eq_zero_or_unit\n\nend Units\n\nsection GroupWithZero\n\nvariable [GroupWithZero G₀] {a b c : G₀}\n\n/- warning: is_unit.mk0 -> IsUnit.mk0 is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (x : G₀), (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) -> (IsUnit.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) x)\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (x : G₀), (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) -> (IsUnit.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) x)\nCase conversion may be inaccurate. Consider using '#align is_unit.mk0 IsUnit.mk0ₓ'. -/\ntheorem IsUnit.mk0 (x : G₀) (hx : x ≠ 0) : IsUnit x :=\n  (Units.mk0 x hx).IsUnit\n#align is_unit.mk0 IsUnit.mk0\n\n/- warning: is_unit_iff_ne_zero -> isUnit_iff_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀}, Iff (IsUnit.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) a) (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀}, Iff (IsUnit.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) a) (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align is_unit_iff_ne_zero isUnit_iff_ne_zeroₓ'. -/\ntheorem isUnit_iff_ne_zero : IsUnit a ↔ a ≠ 0 :=\n  Units.exists_iff_ne_zero\n#align is_unit_iff_ne_zero isUnit_iff_ne_zero\n\n/- warning: ne.is_unit -> Ne.isUnit is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) -> (IsUnit.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) a)\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) -> (IsUnit.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align ne.is_unit Ne.isUnitₓ'. -/\nalias isUnit_iff_ne_zero ↔ _ Ne.isUnit\n#align ne.is_unit Ne.isUnit\n\nattribute [protected] Ne.isUnit\n\n/- warning: group_with_zero.no_zero_divisors -> GroupWithZero.noZeroDivisors is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀], NoZeroDivisors.{u1} G₀ (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))) (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀], NoZeroDivisors.{u1} G₀ (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))) (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))\nCase conversion may be inaccurate. Consider using '#align group_with_zero.no_zero_divisors GroupWithZero.noZeroDivisorsₓ'. -/\n-- see Note [lower instance priority]\ninstance (priority := 10) GroupWithZero.noZeroDivisors : NoZeroDivisors G₀ :=\n  { (‹_› : GroupWithZero G₀) with\n    eq_zero_or_eq_zero_of_mul_eq_zero := fun a b h =>\n      by\n      contrapose! h\n      exact (Units.mk0 a h.1 * Units.mk0 b h.2).NeZero }\n#align group_with_zero.no_zero_divisors GroupWithZero.noZeroDivisors\n\n#print GroupWithZero.cancelMonoidWithZero /-\n-- see Note [lower instance priority]\ninstance (priority := 10) GroupWithZero.cancelMonoidWithZero : CancelMonoidWithZero G₀ :=\n  {\n    (‹_› :\n      GroupWithZero\n        G₀) with\n    mul_left_cancel_of_ne_zero := fun x y z hx h => by\n      rw [← inv_mul_cancel_left₀ hx y, h, inv_mul_cancel_left₀ hx z]\n    mul_right_cancel_of_ne_zero := fun x y z hy h => by\n      rw [← mul_inv_cancel_right₀ hy x, h, mul_inv_cancel_right₀ hy z] }\n#align group_with_zero.cancel_monoid_with_zero GroupWithZero.cancelMonoidWithZero\n-/\n\n/- warning: units.mk0_mul -> Units.mk0_mul is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (x : G₀) (y : G₀) (hxy : Ne.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))), Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) hxy) (HMul.hMul.{u1, u1, u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (instHMul.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (MulOneClass.toHasMul.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mulOneClass.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Units.mk0.{u1} G₀ _inst_2 x (And.left (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Iff.mp (Ne.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (And (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))))) (mul_ne_zero_iff.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G₀ _inst_2) x y) hxy))) (Units.mk0.{u1} G₀ _inst_2 y (And.right (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Iff.mp (Ne.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toHasMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (And (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))))) (mul_ne_zero_iff.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G₀ _inst_2) x y) hxy))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (x : G₀) (y : G₀) (hxy : Ne.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))), Eq.{succ u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.mk0.{u1} G₀ _inst_2 (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) hxy) (HMul.hMul.{u1, u1, u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (instHMul.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (MulOneClass.toMul.{u1} (Units.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (Units.instMulOneClassUnits.{u1} G₀ (MonoidWithZero.toMonoid.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Units.mk0.{u1} G₀ _inst_2 x (And.left (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (Iff.mp (Ne.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (And (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (mul_ne_zero_iff.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G₀ _inst_2) x y) hxy))) (Units.mk0.{u1} G₀ _inst_2 y (And.right (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (Iff.mp (Ne.{succ u1} G₀ (HMul.hMul.{u1, u1, u1} G₀ G₀ G₀ (instHMul.{u1} G₀ (MulZeroClass.toMul.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) x y) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (And (Ne.{succ u1} G₀ x (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))) (Ne.{succ u1} G₀ y (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MulZeroClass.toZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (mul_ne_zero_iff.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G₀ _inst_2) x y) hxy))))\nCase conversion may be inaccurate. Consider using '#align units.mk0_mul Units.mk0_mulₓ'. -/\n-- Can't be put next to the other `mk0` lemmas because it depends on the\n-- `no_zero_divisors` instance, which depends on `mk0`.\n@[simp]\ntheorem Units.mk0_mul (x y : G₀) (hxy) :\n    Units.mk0 (x * y) hxy =\n      Units.mk0 x (mul_ne_zero_iff.mp hxy).1 * Units.mk0 y (mul_ne_zero_iff.mp hxy).2 :=\n  by\n  ext\n  rfl\n#align units.mk0_mul Units.mk0_mul\n\n/- warning: div_ne_zero -> div_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) -> (Ne.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) -> (Ne.{succ u1} G₀ (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toHasDiv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_2))) a b) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀}, (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) -> (Ne.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) -> (Ne.{succ u1} G₀ (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (GroupWithZero.toDiv.{u1} G₀ _inst_2)) a b) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align div_ne_zero div_ne_zeroₓ'. -/\ntheorem div_ne_zero (ha : a ≠ 0) (hb : b ≠ 0) : a / b ≠ 0 :=\n  by\n  rw [div_eq_mul_inv]\n  exact mul_ne_zero ha (inv_ne_zero hb)\n#align div_ne_zero div_ne_zero\n\n/- warning: div_eq_zero_iff -> div_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀}, Iff (Eq.{succ u1} G₀ (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toHasDiv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_2))) a b) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Or (Eq.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Eq.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀}, Iff (Eq.{succ u1} G₀ (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (GroupWithZero.toDiv.{u1} G₀ _inst_2)) a b) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Or (Eq.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Eq.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align div_eq_zero_iff div_eq_zero_iffₓ'. -/\n@[simp]\ntheorem div_eq_zero_iff : a / b = 0 ↔ a = 0 ∨ b = 0 := by simp [div_eq_mul_inv]\n#align div_eq_zero_iff div_eq_zero_iff\n\n/- warning: div_ne_zero_iff -> div_ne_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀}, Iff (Ne.{succ u1} G₀ (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (DivInvMonoid.toHasDiv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_2))) a b) (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (And (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))) (Ne.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (OfNat.mk.{u1} G₀ 0 (Zero.zero.{u1} G₀ (MulZeroClass.toHasZero.{u1} G₀ (MulZeroOneClass.toMulZeroClass.{u1} G₀ (MonoidWithZero.toMulZeroOneClass.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)))))))))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] {a : G₀} {b : G₀}, Iff (Ne.{succ u1} G₀ (HDiv.hDiv.{u1, u1, u1} G₀ G₀ G₀ (instHDiv.{u1} G₀ (GroupWithZero.toDiv.{u1} G₀ _inst_2)) a b) (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (And (Ne.{succ u1} G₀ a (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))) (Ne.{succ u1} G₀ b (OfNat.ofNat.{u1} G₀ 0 (Zero.toOfNat0.{u1} G₀ (MonoidWithZero.toZero.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align div_ne_zero_iff div_ne_zero_iffₓ'. -/\ntheorem div_ne_zero_iff : a / b ≠ 0 ↔ a ≠ 0 ∧ b ≠ 0 :=\n  div_eq_zero_iff.Not.trans not_or\n#align div_ne_zero_iff div_ne_zero_iff\n\n/- warning: ring.inverse_eq_inv -> Ring.inverse_eq_inv is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (a : G₀), Eq.{succ u1} G₀ (Ring.inverse.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2) a) (Inv.inv.{u1} G₀ (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_2)) a)\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀] (a : G₀), Eq.{succ u1} G₀ (Ring.inverse.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2) a) (Inv.inv.{u1} G₀ (GroupWithZero.toInv.{u1} G₀ _inst_2) a)\nCase conversion may be inaccurate. Consider using '#align ring.inverse_eq_inv Ring.inverse_eq_invₓ'. -/\ntheorem Ring.inverse_eq_inv (a : G₀) : Ring.inverse a = a⁻¹ :=\n  by\n  obtain rfl | ha := eq_or_ne a 0\n  · simp\n  · exact Ring.inverse_unit (Units.mk0 a ha)\n#align ring.inverse_eq_inv Ring.inverse_eq_inv\n\n/- warning: ring.inverse_eq_inv' -> Ring.inverse_eq_inv' is a dubious translation:\nlean 3 declaration is\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀], Eq.{succ u1} (G₀ -> G₀) (Ring.inverse.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) (Inv.inv.{u1} G₀ (DivInvMonoid.toHasInv.{u1} G₀ (GroupWithZero.toDivInvMonoid.{u1} G₀ _inst_2)))\nbut is expected to have type\n  forall {G₀ : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G₀], Eq.{succ u1} (G₀ -> G₀) (Ring.inverse.{u1} G₀ (GroupWithZero.toMonoidWithZero.{u1} G₀ _inst_2)) (Inv.inv.{u1} G₀ (GroupWithZero.toInv.{u1} G₀ _inst_2))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_eq_inv' Ring.inverse_eq_inv'ₓ'. -/\n@[simp]\ntheorem Ring.inverse_eq_inv' : (Ring.inverse : G₀ → G₀) = Inv.inv :=\n  funext Ring.inverse_eq_inv\n#align ring.inverse_eq_inv' Ring.inverse_eq_inv'\n\nend GroupWithZero\n\nsection CommGroupWithZero\n\n-- comm\nvariable [CommGroupWithZero G₀] {a b c d : G₀}\n\n#print CommGroupWithZero.cancelCommMonoidWithZero /-\n-- see Note [lower instance priority]\ninstance (priority := 10) CommGroupWithZero.cancelCommMonoidWithZero :\n    CancelCommMonoidWithZero G₀ :=\n  { GroupWithZero.cancelMonoidWithZero, CommGroupWithZero.toCommMonoidWithZero G₀ with }\n#align comm_group_with_zero.cancel_comm_monoid_with_zero CommGroupWithZero.cancelCommMonoidWithZero\n-/\n\n#print CommGroupWithZero.toDivisionCommMonoid /-\n-- See note [lower instance priority]\ninstance (priority := 100) CommGroupWithZero.toDivisionCommMonoid : DivisionCommMonoid G₀ :=\n  { ‹CommGroupWithZero G₀›, GroupWithZero.toDivisionMonoid with }\n#align comm_group_with_zero.to_division_comm_monoid CommGroupWithZero.toDivisionCommMonoid\n-/\n\nend CommGroupWithZero\n\nsection NoncomputableDefs\n\nopen Classical\n\nvariable {M : Type _} [Nontrivial M]\n\n/- warning: group_with_zero_of_is_unit_or_eq_zero -> groupWithZeroOfIsUnitOrEqZero is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_2 : Nontrivial.{u1} M] [hM : MonoidWithZero.{u1} M], (forall (a : M), Or (IsUnit.{u1} M (MonoidWithZero.toMonoid.{u1} M hM) a) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M hM)))))))) -> (GroupWithZero.{u1} M)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_2 : Nontrivial.{u1} M] [hM : MonoidWithZero.{u1} M], (forall (a : M), Or (IsUnit.{u1} M (MonoidWithZero.toMonoid.{u1} M hM) a) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (MonoidWithZero.toZero.{u1} M hM))))) -> (GroupWithZero.{u1} M)\nCase conversion may be inaccurate. Consider using '#align group_with_zero_of_is_unit_or_eq_zero groupWithZeroOfIsUnitOrEqZeroₓ'. -/\n/-- Constructs a `group_with_zero` structure on a `monoid_with_zero`\n  consisting only of units and 0. -/\nnoncomputable def groupWithZeroOfIsUnitOrEqZero [hM : MonoidWithZero M]\n    (h : ∀ a : M, IsUnit a ∨ a = 0) : GroupWithZero M :=\n  { hM with\n    inv := fun a => if h0 : a = 0 then 0 else ↑((h a).resolve_right h0).Unit⁻¹\n    inv_zero := dif_pos rfl\n    mul_inv_cancel := fun a h0 =>\n      by\n      change (a * if h0 : a = 0 then 0 else ↑((h a).resolve_right h0).Unit⁻¹) = 1\n      rw [dif_neg h0, Units.mul_inv_eq_iff_eq_mul, one_mul, IsUnit.unit_spec]\n    exists_pair_ne := Nontrivial.exists_pair_ne }\n#align group_with_zero_of_is_unit_or_eq_zero groupWithZeroOfIsUnitOrEqZero\n\n/- warning: comm_group_with_zero_of_is_unit_or_eq_zero -> commGroupWithZeroOfIsUnitOrEqZero is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_2 : Nontrivial.{u1} M] [hM : CommMonoidWithZero.{u1} M], (forall (a : M), Or (IsUnit.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M hM)) a) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (OfNat.mk.{u1} M 0 (Zero.zero.{u1} M (MulZeroClass.toHasZero.{u1} M (MulZeroOneClass.toMulZeroClass.{u1} M (MonoidWithZero.toMulZeroOneClass.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M hM))))))))) -> (CommGroupWithZero.{u1} M)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_2 : Nontrivial.{u1} M] [hM : CommMonoidWithZero.{u1} M], (forall (a : M), Or (IsUnit.{u1} M (MonoidWithZero.toMonoid.{u1} M (CommMonoidWithZero.toMonoidWithZero.{u1} M hM)) a) (Eq.{succ u1} M a (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M (CommMonoidWithZero.toZero.{u1} M hM))))) -> (CommGroupWithZero.{u1} M)\nCase conversion may be inaccurate. Consider using '#align comm_group_with_zero_of_is_unit_or_eq_zero commGroupWithZeroOfIsUnitOrEqZeroₓ'. -/\n/-- Constructs a `comm_group_with_zero` structure on a `comm_monoid_with_zero`\n  consisting only of units and 0. -/\nnoncomputable def commGroupWithZeroOfIsUnitOrEqZero [hM : CommMonoidWithZero M]\n    (h : ∀ a : M, IsUnit a ∨ a = 0) : CommGroupWithZero M :=\n  { groupWithZeroOfIsUnitOrEqZero h, hM with }\n#align comm_group_with_zero_of_is_unit_or_eq_zero commGroupWithZeroOfIsUnitOrEqZero\n\nend NoncomputableDefs\n\n-- Guard against import creep\nassert_not_exists Multiplicative\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/GroupWithZero/Units/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.45509770161545293}}
{"text": "/-\nCopyright (c) 2020 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Adam Topaz.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.free_algebra\nimport Mathlib.algebra.ring_quot\nimport Mathlib.algebra.triv_sq_zero_ext\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Tensor Algebras\n\nGiven a commutative semiring `R`, and an `R`-module `M`, we construct the tensor algebra of `M`.\nThis is the free `R`-algebra generated (`R`-linearly) by the module `M`.\n\n## Notation\n\n1. `tensor_algebra R M` is the tensor algebra itself. It is endowed with an R-algebra structure.\n2. `tensor_algebra.ι R` is the canonical R-linear map `M → tensor_algebra R M`.\n3. Given a linear map `f : M → A` to an R-algebra `A`, `lift R f` is the lift of `f` to an\n  `R`-algebra morphism `tensor_algebra R M → A`.\n\n## Theorems\n\n1. `ι_comp_lift` states that the composition `(lift R f) ∘ (ι R)` is identical to `f`.\n2. `lift_unique` states that whenever an R-algebra morphism `g : tensor_algebra R M → A` is\n  given whose composition with `ι R` is `f`, then one has `g = lift R f`.\n3. `hom_ext` is a variant of `lift_unique` in the form of an extensionality theorem.\n4. `lift_comp_ι` is a combination of `ι_comp_lift` and `lift_unique`. It states that the lift\n  of the composition of an algebra morphism with `ι` is the algebra morphism itself.\n\n## Implementation details\n\nAs noted above, the tensor algebra of `M` is constructed as the free `R`-algebra generated by `M`,\nmodulo the additional relations making the inclusion of `M` into an `R`-linear map.\n-/\n\nnamespace tensor_algebra\n\n\n/--\nAn inductively defined relation on `pre R M` used to force the initial algebra structure on\nthe associated quotient.\n-/\n-- force `ι` to be linear\n\ninductive rel (R : Type u_1) [comm_semiring R] (M : Type u_2) [add_comm_monoid M] [semimodule R M] :\n    free_algebra R M → free_algebra R M → Prop\n    where\n| add : ∀ {a b : M}, rel R M (free_algebra.ι R (a + b)) (free_algebra.ι R a + free_algebra.ι R b)\n| smul :\n    ∀ {r : R} {a : M},\n      rel R M (free_algebra.ι R (r • a))\n        (coe_fn (algebra_map R (free_algebra R M)) r * free_algebra.ι R a)\n\nend tensor_algebra\n\n\n/--\nThe tensor algebra of the module `M` over the commutative semiring `R`.\n-/\ndef tensor_algebra (R : Type u_1) [comm_semiring R] (M : Type u_2) [add_comm_monoid M]\n    [semimodule R M] :=\n  ring_quot sorry\n\nnamespace tensor_algebra\n\n\nprotected instance ring (M : Type u_2) [add_comm_monoid M] {S : Type u_1} [comm_ring S]\n    [semimodule S M] : ring (tensor_algebra S M) :=\n  ring_quot.ring (rel S M)\n\n/--\nThe canonical linear map `M →ₗ[R] tensor_algebra R M`.\n-/\ndef ι (R : Type u_1) [comm_semiring R] {M : Type u_2} [add_comm_monoid M] [semimodule R M] :\n    linear_map R M (tensor_algebra R M) :=\n  linear_map.mk (fun (m : M) => coe_fn (ring_quot.mk_alg_hom R (rel R M)) (free_algebra.ι R m))\n    sorry sorry\n\ntheorem ring_quot_mk_alg_hom_free_algebra_ι_eq_ι (R : Type u_1) [comm_semiring R] {M : Type u_2}\n    [add_comm_monoid M] [semimodule R M] (m : M) :\n    coe_fn (ring_quot.mk_alg_hom R (rel R M)) (free_algebra.ι R m) = coe_fn (ι R) m :=\n  rfl\n\n/--\nGiven a linear map `f : M → A` where `A` is an `R`-algebra, `lift R f` is the unique lift\nof `f` to a morphism of `R`-algebras `tensor_algebra R M → A`.\n-/\ndef lift (R : Type u_1) [comm_semiring R] {M : Type u_2} [add_comm_monoid M] [semimodule R M]\n    {A : Type u_3} [semiring A] [algebra R A] :\n    linear_map R M A ≃ alg_hom R (tensor_algebra R M) A :=\n  equiv.mk\n    (⇑(ring_quot.lift_alg_hom R) ∘\n      fun (f : linear_map R M A) => { val := coe_fn (free_algebra.lift R) ⇑f, property := sorry })\n    (fun (F : alg_hom R (tensor_algebra R M) A) => linear_map.comp (alg_hom.to_linear_map F) (ι R))\n    sorry sorry\n\n@[simp] theorem ι_comp_lift {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] {A : Type u_3} [semiring A] [algebra R A] (f : linear_map R M A) :\n    linear_map.comp (alg_hom.to_linear_map (coe_fn (lift R) f)) (ι R) = f :=\n  equiv.symm_apply_apply (lift R) f\n\n@[simp] theorem lift_ι_apply {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] {A : Type u_3} [semiring A] [algebra R A] (f : linear_map R M A) (x : M) :\n    coe_fn (coe_fn (lift R) f) (coe_fn (ι R) x) = coe_fn f x :=\n  id (Eq.refl (coe_fn f x))\n\n@[simp] theorem lift_unique {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] {A : Type u_3} [semiring A] [algebra R A] (f : linear_map R M A)\n    (g : alg_hom R (tensor_algebra R M) A) :\n    linear_map.comp (alg_hom.to_linear_map g) (ι R) = f ↔ g = coe_fn (lift R) f :=\n  equiv.symm_apply_eq (lift R)\n\n-- Marking `tensor_algebra` irreducible makes `ring` instances inaccessible on quotients.\n\n-- https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/algebra.2Esemiring_to_ring.20breaks.20semimodule.20typeclass.20lookup/near/212580241\n\n-- For now, we avoid this by not marking it irreducible.\n\n@[simp] theorem lift_comp_ι {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] {A : Type u_3} [semiring A] [algebra R A]\n    (g : alg_hom R (tensor_algebra R M) A) :\n    coe_fn (lift R) (linear_map.comp (alg_hom.to_linear_map g) (ι R)) = g :=\n  sorry\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem hom_ext {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M] [semimodule R M]\n    {A : Type u_3} [semiring A] [algebra R A] {f : alg_hom R (tensor_algebra R M) A}\n    {g : alg_hom R (tensor_algebra R M) A}\n    (w :\n      linear_map.comp (alg_hom.to_linear_map f) (ι R) =\n        linear_map.comp (alg_hom.to_linear_map g) (ι R)) :\n    f = g :=\n  sorry\n\n/-- The left-inverse of `algebra_map`. -/\ndef algebra_map_inv {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] : alg_hom R (tensor_algebra R M) R :=\n  coe_fn (lift R) 0\n\ntheorem algebra_map_left_inverse {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] :\n    function.left_inverse ⇑algebra_map_inv ⇑(algebra_map R (tensor_algebra R M)) :=\n  sorry\n\n/-- The left-inverse of `ι`.\n\nAs an implementation detail, we implement this using `triv_sq_zero_ext` which has a suitable\nalgebra structure. -/\ndef ι_inv {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M] [semimodule R M] :\n    linear_map R (tensor_algebra R M) M :=\n  linear_map.comp (triv_sq_zero_ext.snd_hom R M)\n    (alg_hom.to_linear_map (coe_fn (lift R) (triv_sq_zero_ext.inr_hom R M)))\n\ntheorem ι_left_inverse {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] : function.left_inverse ⇑ι_inv ⇑(ι R) :=\n  sorry\n\nend tensor_algebra\n\n\nnamespace free_algebra\n\n\n/-- The canonical image of the `free_algebra` in the `tensor_algebra`, which maps\n`free_algebra.ι R x` to `tensor_algebra.ι R x`. -/\ndef to_tensor {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M] [semimodule R M] :\n    alg_hom R (free_algebra R M) (tensor_algebra R M) :=\n  coe_fn (lift R) ⇑(tensor_algebra.ι R)\n\n@[simp] theorem to_tensor_ι {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] (m : M) : coe_fn to_tensor (ι R m) = coe_fn (tensor_algebra.ι R) m :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/tensor_algebra_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489891, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.45505424121800236}}
{"text": "lemma le_zero (a : mynat) (h : a ≤ 0) : a = 0 :=\nbegin\ncases h with d hd,\nsymmetry at hd,\nexact add_right_eq_zero hd,\nend\n", "meta": {"author": "abdelq", "repo": "natural-number-game", "sha": "bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2", "save_path": "github-repos/lean/abdelq-natural-number-game", "path": "github-repos/lean/abdelq-natural-number-game/natural-number-game-bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2/world10/level07.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.731058578630005, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4550542339234113}}
{"text": "lemma le_zero (a : mynat) (h : a ≤ 0) : a = 0 :=\nbegin\ncases h with b hb,\nsymmetry at hb,\nexact add_right_eq_zero hb,\nend\n", "meta": {"author": "chanha-park", "repo": "naturalNumberGame", "sha": "4e0d7100ce4575e1add92feefa38b1250431b879", "save_path": "github-repos/lean/chanha-park-naturalNumberGame", "path": "github-repos/lean/chanha-park-naturalNumberGame/naturalNumberGame-4e0d7100ce4575e1add92feefa38b1250431b879/Inequality/7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.45505422662882}}
{"text": "import SciLean.Data.DataArray.PlainDataType\nimport SciLean.Data.ArrayType\n\nnamespace SciLean\n\n-- TODO: Quotient it out by trailing bits\nstructure DataArray (α : Type) [pd : PlainDataType α] where\n  byteData : ByteArray\n  size : Nat \n  h_size : pd.bytes size ≤ byteData.size\n\nvariable {α : Type} [pd : PlainDataType α]\nvariable {ι} [Enumtype ι]\n\ndef DataArray.get (arr : DataArray α) (i : Fin arr.size) : α := -- pd.get a.data i sorry_proof\n  match pd.btype with\n  | .inl bitType => \n    let perByte := 8/bitType.bits\n    let inByte  := (i.1 % perByte.toNat).toUInt8\n    let ofByte  : Fin arr.byteData.size := ⟨i.1 / perByte.toNat, sorry_proof⟩\n    let ones : UInt8 := 255\n    let mask    := (ones - (ones <<< bitType.bits))   -- 00000111 \n    -- masking is note necessary if `fromBytes` correctly ignores unused bits\n    let byte    := mask &&& (arr.byteData[ofByte] >>> (inByte*bitType.bits))\n    bitType.fromByte byte\n  | .inr byteType => \n    byteType.fromByteArray arr.byteData (byteType.bytes * i.1) sorry_proof\n\ndef DataArray.set (arr : DataArray α) (i : Fin arr.size) (val : α) : DataArray α := -- ⟨pd.set a.byteData i sorry_proof val, a.size, sorry_proof⟩\n  match pd.btype with\n  | .inl bitType => \n    let perByte := 8/bitType.bits\n    let inByte  := (i.1 % perByte.toNat).toUInt8\n    let ofByte  := ⟨i.1 / perByte.toNat, sorry_proof⟩\n    let ones : UInt8 := 255\n    let mask    := ones - ((ones - (ones <<< bitType.bits)) <<< (inByte*bitType.bits))  --- 11000111 for bitType.bits = 3 and inByte = 1\n    let byte    := arr.byteData[ofByte]\n    let newByte := (mask &&& byte) + (bitType.toByte val <<< (inByte*bitType.bits))\n    ⟨arr.byteData.set ofByte newByte, arr.size, sorry_proof⟩\n  | .inr byteType => \n    ⟨byteType.toByteArray arr.byteData (byteType.bytes * i.1) sorry_proof val, arr.size, sorry_proof⟩\n\n\n/-- Capacity of an array. The return type is `Squash Nat` as the capacity is is just an implementation detail and should not affect semantics of the program. -/\ndef DataArray.capacity (arr : DataArray α) : Squash Nat := Quot.mk _ (pd.capacity (arr.byteData.size))\n/-- Makes sure that `arr` fits at least `n` elements of `α` -/\ndef DataArray.reserve  (arr : DataArray α) (n : Nat) : DataArray α := \n  if (pd.capacity (arr.byteData.size)) ≤ n then\n    arr\n  else Id.run do\n    let newBytes := pd.bytes n\n    let mut arr' : DataArray α := ⟨ByteArray.mkEmpty newBytes, arr.size, sorry_proof⟩\n    -- copy over the old data\n    for i in [0:arr.size] do\n      arr' := ⟨arr'.byteData.push 0, arr.size, sorry_proof⟩\n      arr' := arr'.set ⟨i,sorry_proof⟩ (arr.get ⟨i,sorry_proof⟩)\n    arr'\n\n\ndef DataArray.drop (arr : DataArray α) (k : Nat) : DataArray α := ⟨arr.byteData, arr.size - k, sorry_proof⟩\n\ndef DataArray.push (arr : DataArray α) (k : Nat := 1) (val : α) : DataArray α := Id.run do\n  let oldSize := arr.size\n  let newSize := arr.size + k\n  let mut arr' := arr.reserve newSize\n  arr' := ⟨arr'.byteData, newSize, sorry_proof⟩\n  for i in [oldSize:newSize] do\n    arr' := arr'.set ⟨i,sorry_proof⟩ val\n  arr'\n\n/-- Extensionality of DataArray\n\nCurrently this is inconsistent, we need to turn DataArray into quotient!\n-/\ntheorem DataArray.ext (d d' : DataArray α) : (h : d.size = d'.size) → (∀ i, d.get i = d'.get (h ▸ i)) → d = d' := sorry_proof\n\ndef DataArray.intro (f : ι → α) : DataArray α := Id.run do\n  let bytes := (pd.bytes (numOf ι))\n  let mut d : ByteArray := ByteArray.mkEmpty bytes\n  for _ in [0:bytes] do\n    d := d.push 0\n  let mut d' : DataArray α := ⟨d, (numOf ι), sorry_proof⟩\n  for (i,li) in Enumtype.fullRange ι do\n    d' := d'.set ⟨li,sorry_proof⟩ (f i)\n  d'\n\nstructure DataArrayN (α : Type) [pd : PlainDataType α] (n : Nat) where\n  data : DataArray α\n  h_size : n = data.size\n\ninstance (n) : GetElem (DataArrayN α n) (Fin n) α (λ _ _ => True) where\n  getElem xs i _ := xs.1.get (xs.2 ▸ i)\n\ninstance : GetElem (DataArrayN α (numOf ι)) ι α (λ _ _ => True) where\n  getElem xs i _ := xs.1.get (xs.2 ▸ toFin i)\n\ninstance : SetElem (DataArrayN α n) (Fin n) α where\n  setElem xs i xi := ⟨xs.1.set (xs.2 ▸ i) xi, sorry_proof⟩\n\ninstance : SetElem (DataArrayN α (numOf ι)) ι α where\n  setElem xs i xi := ⟨xs.1.set (xs.2 ▸ toFin i) xi, sorry_proof⟩\n\ninstance : IntroElem (DataArrayN α n) (Fin n) α where\n  introElem f := ⟨DataArray.intro f, sorry_proof⟩\n\ninstance : IntroElem (DataArrayN α (numOf ι)) ι α where\n  introElem f := ⟨DataArray.intro f, sorry_proof⟩\n\ninstance : PushElem (DataArrayN α) α where\n  pushElem k val xs := ⟨xs.1.push k val, sorry_proof⟩\n\ninstance : DropElem (DataArrayN α) α where\n  dropElem k xs := ⟨xs.1.drop k, sorry_proof⟩\n\ninstance : ReserveElem (DataArrayN α) α where\n  reserveElem k xs := ⟨xs.1.reserve k, sorry_proof⟩\n\ninstance : ArrayType (DataArrayN α n) (Fin n) α  where\n  ext := sorry_proof\n  getElem_setElem_eq := sorry_proof\n  getElem_setElem_neq := sorry_proof\n  getElem_introElem := sorry_proof\n\ninstance : LinearArrayType (DataArrayN α) α  where\n  toArrayType := by infer_instance\n  pushElem_getElem := sorry_proof\n  dropElem_getElem := sorry_proof\n  reserveElem_id := sorry_proof\n\ninstance : ArrayType (DataArrayN α (numOf ι)) ι α  where\n  ext := sorry_proof\n  getElem_setElem_eq := sorry_proof\n  getElem_setElem_neq := sorry_proof\n  getElem_introElem := sorry_proof\n\n@[infer_tc_goals_rl]\ninstance {Cont ι α : Type} [Enumtype ι] [Inhabited α] [pd : PlainDataType α] [ArrayType Cont ι α] : PlainDataType Cont where\n  btype := match pd.btype with\n    | .inl αBitType => \n      -- TODO: Fixme !!!!\n      .inr {\n        bytes := 2\n        h_size := sorry_proof\n\n        fromByteArray := λ b i h => \n          introElem (λ j => default)\n        toByteArray   := λ b i h c => b\n        toByteArray_size := sorry_proof\n        fromByteArray_toByteArray := sorry_proof\n        fromByteArray_toByteArray_other := sorry_proof\n      }\n    | .inr αByteType => \n      .inr {\n        bytes := (numOf ι) * αByteType.bytes\n        h_size := sorry_proof\n\n        fromByteArray := λ b i h => \n          introElem (λ j => \n            let idx := (i + (toFin j).1*αByteType.bytes)\n            αByteType.fromByteArray b idx sorry_proof)\n        toByteArray   := λ b i h c => Id.run do\n          let mut b := b\n          for (j,lj) in Enumtype.fullRange ι do\n            let idx := (i + lj.1*αByteType.bytes)\n            b := αByteType.toByteArray b idx sorry_proof c[j]\n          b\n\n        toByteArray_size := sorry_proof\n        fromByteArray_toByteArray := sorry_proof\n        fromByteArray_toByteArray_other := sorry_proof\n      }\n\n\n  -- bytes : Nat\n  -- h_size : 1 < bytes  -- for one byte types use BitInfo\n  -- fromByteArray (b : ByteArray) (i : Nat) (h : i+bytes ≤ b.size) : α\n  -- toByteArray   (b : ByteArray) (i : Nat) (h : i+bytes ≤ b.size) (a : α) : ByteArray\n\n  -- -- `toByteArray` does not modify ByteArray size\n  -- toByteArray_size : ∀ b i h a, (toByteArray b i h a).size = b.size\n  -- -- we can recover `a` from bytes\n  -- fromByteArray_toByteArray : ∀ a b i h h', fromByteArray (toByteArray b i h a) i h' = a\n  -- -- `toByteArray` does not affect other bytes\n  -- fromByteArray_toByteArray_other : ∀ a b i j h, (j < i) ∨ (i+size) ≤ j → (toByteArray b i h a).get! j = b.get! j\n\n\n\n\n-- ShortOptDataArray is prefered for PowType\n-- @[defaultInstance]\n-- instance : PowType (DataArrayN α (numOf ι)) ι α := PowType.mk \n\n-- ShortOptDataArray is prefered for PowType\n-- @[defaultInstance]\n-- instance : LinearPowType (DataArrayN α) α := LinearPowType.mk\n\n\n\n-- #check ℝ^(Fin 3)\n\n-- #eval ((λ [i] => i.1.toReal ) : ℝ^(Fin 100)) |>.map Math.sqrt\n\n-- #eval ((λ [i] => i) : (Fin 3 × Fin 5)^(Fin 3 × Fin 5))\n-- #eval ((λ [i] => i) : (Fin 3 × Fin 5)^(Fin 3 × Fin 5)).data\n-- #eval ((λ [i] => i) : (Fin 3 × Fin 5)^(Fin 3 × Fin 5)).data.byteData\n\n-- #eval (1,2,3,4)\n\n-- #eval ((λ [i] => i) : (Fin 3 × Fin 2 × Fin 2)^(Fin 3 × Fin 2 × Fin 2))\n-- #eval ((λ [i] => i) : (Fin 3 × Fin 2 × Fin 2)^(Fin 3 × Fin 2 × Fin 2)).data\n-- #eval ((λ [i] => i) : (Fin 3 × Fin 2 × Fin 2)^(Fin 3 × Fin 2 × Fin 2)).data.byteData\n\n-- #eval ((λ [i] => (i.1.toFloat, i.1.toFloat.sqrt)) : (Float × Float)^(Fin 17))\n\n-- variable (x : ℝ^{n,m})\n\n-- #check x\n-- #check λ (i,j) => x[i,j]\n-- #check ∑ i, x[i]\n\n-- #check Id.run do\n--   let mut a : ℝ^{10} := λ [i] => i.1\n--   for (i,_) in Enumtype.fullRange a.Index do\n--     a[i] *= 1000\n--     a[i] += Math.sqrt i.1 + a[i]\n--   a\n\n-- #eval Id.run do\n--   let mut a : (ℝ×ℝ)^{3,3} := λ [i,j] => (i.1,j.1)\n--   for (i,li) in Enumtype.fullRange a.Index do\n--     a[li] := (Math.sqrt a[li].1, Math.exp a[li].2)\n--   a\n\n-- #eval Id.run do\n--   let mut a : ℝ^(Fin 3 × Fin 3) := 0\n--   for ((i,j),li) in Enumtype.fullRange a.Index do\n--     a[li] := if i = j then 1 else 0\n--   a\n", "meta": {"author": "lecopivo", "repo": "SciLean", "sha": "e4fe5962c862f9854a6c88a4082eb01bc1147086", "save_path": "github-repos/lean/lecopivo-SciLean", "path": "github-repos/lean/lecopivo-SciLean/SciLean-e4fe5962c862f9854a6c88a4082eb01bc1147086/SciLean/Data/DataArray/DataArray.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.45505422662882}}
{"text": "/-\nCopyright (c) 2022 Jun Yoshida. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n-/\n\nimport Dijkstra.Init\nimport Dijkstra.Control.Lawful\nimport Dijkstra.Control.Monad.Rel\n\n\n/-!\n\n# Dijkstra monads\n\nA ***Dijkstra monad*** is a dependent analogue of a monad which is parametrized by a specific monad, called the *underlying monad*, so that the operations `pure` and `bind` are defined along with those on the underlying monad.\nMore precisely, given monad `W : Type u → Type v`, a type-family `M : (α : Type u) → W α → Type v` is a Dijkstra monad if it is equipped with the following two operations:\n\n```lean\ndpure {α : Type u} (a : α) :  M (pure a)\ndbind {α β : Type u} {wa : W α} {wf : α → W β} : M α wa → ((a : α) → M β (wf a)) → M β (wa >>= wf)\n```\n\nIn addition, these operations are supposed to satisfy dependent analogues of the ordinary monad relations.\nThere is, however, a problem to write down such conditions.\nFor example, one would expect that the left unitality of `dbind` can be written to be of the type `dbind (dpure a) f = f a`, thouth it is not type-correct.\nIndeed, for `a : α`, `wb : W β`, and `f : α → M β wb`, we have\n\n```lean\n#check dbind (dpure a) f -- M β (pure a >>= λ _ => wb)\n#check f a               -- M β wb\n```\n\nand it turns out that the dependent parameters are not definitionally equal (even if one has `[LawfulMonad W]`).\nThis is why we need `DEq` a dependent analogue of `Eq` for type families; see [Init.lean](Dijkstra/Init.lean).\n\n-/\n\nuniverse u v w\n\n/-- The main structures of Dijkstra monads. -/\nclass DijkstraMonad (W : Type u → Type v) [Monad W] (M : (α : Type u) → W α → Type w) where\n  dpure {α : Type u} (a : α) : M α (return a)\n  dbind {α β : Type u} {wa : W α} {wf : α → W β} : M α wa → ((a : α) → M β (wf a)) → M β (wa >>= wf)\n\nexport DijkstraMonad (dpure dbind)\n\n/-- The dependent monad laws for Dijkstra monads. -/\nclass DijkstraMonad.Lawful (W : Type u → Type v) [Monad W] (M : (α : Type u) → W α → Type w) [DijkstraMonad W M] where\n  --- right unitality\n  dbind_dpure {α : Type u} {wa : W α} {x : M α wa} : DEq (M α) (dbind x dpure) x\n  --- left unitality\n  dpure_dbind {α β : Type u} {wf : α → W β} (a : α) (f : (a : α) → M β (wf a)) : DEq (M β) (dbind (dpure a) f) (f a)\n  --- associativity\n  dbind_assoc {α β γ : Type u} {wa : W α} {wf : α → W β} {wg : β → W γ} (x : M α wa) (f : (a : α) → M β (wf a)) (g : (b : β) → M γ (wg b)) : DEq (M γ) (dbind (dbind x f) g) (dbind x (λ a => dbind (f a) g))\n\nnamespace DijkstraMonad\n\n\n/-!\n\n## Basic lemmas\n\n-/\n\ntheorem dbind_congr {W : Type u → Type v} [Monad W] {M : (α : Type u) → W α → Type w} [DijkstraMonad W M] {α β : Type u} : ∀ {wa₁ wa₂ : W α} {wf₁ wf₂ : α → W β} {x₁ : M α wa₁} {x₂ : M α wa₂} {f₁ : (a : α) → M β (wf₁ a)} {f₂ : (a : α) → M β (wf₂ a)}, DEq (M α) x₁ x₂ → (∀ a, DEq (M β) (f₁ a) (f₂ a)) → DEq (M β) (dbind x₁ f₁) (dbind x₂ f₂)\n| _, _, wf₁, wf₂, _, _, f₁, f₂, DEq.refl _, hf => by\n  have : wf₁ = wf₂ := by\n    funext a\n    exact (hf a).eq_param\n  cases this\n  have : f₁ = f₂ := by\n    funext a\n    exact (hf a).eq_of_deq\n  cases this\n  exact DEq.refl _\n\ntheorem dbind_congrRight {W : Type u → Type v} [Monad W] {M : (α : Type u) → W α → Type w} [DijkstraMonad W M] {α β : Type u} : ∀ {wa : W α} {wf₁ wf₂ : α → W β} {x : M α wa} {f₁ : (a : α) → M β (wf₁ a)} {f₂ : (a : α) → M β (wf₂ a)}, (∀ a, DEq (M β) (f₁ a) (f₂ a)) → DEq (M β) (dbind x f₁) (dbind x f₂) :=\n  dbind_congr (DEq.refl _) \n\ntheorem dbind_congrLeft {W : Type u → Type v} [Monad W] {M : (α : Type u) → W α → Type w} [DijkstraMonad W M] {α β : Type u} : ∀ {wa₁ wa₂ : W α} {wf : α → W β} {x₁ : M α wa₁} {x₂ : M α wa₂} {f : (a : α) → M β (wf a)}, DEq (M α) x₁ x₂ → DEq (M β) (dbind x₁ f) (dbind x₂ f) :=\n  λ h => dbind_congr h (λ _ => DEq.refl _)\n\n\n/-!\n\n## Change of underlying monads\n\nAs is the case for parametrized type families, one can translate Dijkstra monads into other along monad homomorphisms on underlying monads.\nIn particular, given a monad homomorphism `F : MonadHom W₁ W₂`, we define the \"push-forward\" `DijkstraMonad W₁ M → DijkstraMonad W₂ (Push F M)` and the \"pull-back\" `DijkstraMonad W₂ M → DijkstraMonad W₁ (Pull F M)`.\n\n-/\n\nsection underlying\n\nuniverse v₁ v₂\n\nvariable {W₁ : Type u → Type v₁} [Monad W₁] {W₂ : Type u → Type v₂} [Monad W₂]\n\n/-- Pushforward of Dijkstra monads along a monad homomorphism. -/\nstructure Push (F : MonadHom W₁ W₂) (M : (α : Type u) → W₁ α → Type w) (α : Type u) (wa₂ : W₂ α) : Type (max v₁ w) where\n  base : W₁ α\n  body : M α base\n  underly : F.app base = wa₂\n\nnamespace Push\n\nvariable {F : MonadHom W₁ W₂} {M : (α : Type u) → W₁ α → Type w}\n\nprotected\ntheorem eq {α : Type u} {wa₂ : W₂ α} : ∀ {x y : Push F M α wa₂}, x.base = y.base → DEq (M α) x.body y.body → x = y\n| mk _ _ _, mk _ _ _, rfl, DEq.refl _ => rfl\n\nprotected\ntheorem deq {α : Type u} {wa₂ wa₂': W₂ α} : ∀ {x : Push F M α wa₂} {y : Push F M α wa₂'}, x.base = y.base → DEq (M α) x.body y.body → DEq (Push F M α) x y\n| mk base _ hx, mk _ _ hy, rfl, DEq.refl _ => by\n  cases (Eq.trans hy.symm hx)\n  exact DEq.refl _\n\ninstance instDijkstraMonadPush [DijkstraMonad W₁ M] : DijkstraMonad W₂ (Push F M) where\n  dpure a := {\n    base := pure a\n    body := dpure a\n    underly := F.app_pure a\n  }\n  dbind x f := {\n    base := x.base >>= (λ a => (f a).base)\n    body := dbind x.body (λ a => (f a).body)\n    underly := by\n      rw [F.app_bind, x.underly]\n      apply bind_congr\n      intro a; dsimp\n      exact (f a).underly\n  }\n\ninstance instDijkstraMonadLawfulPush [LawfulMonad W₁] [DijkstraMonad W₁ M] [DijkstraMonad.Lawful W₁ M] : DijkstraMonad.Lawful W₂ (Push F M) where\n  dbind_dpure := by\n    intro α wa₂ x\n    cases x with | mk x_base x_body hx =>\n    apply Push.deq <;> dsimp [dbind, dpure]\n    . rw [bind_pure]; \n    . exact DijkstraMonad.Lawful.dbind_dpure (M:=M)\n  dpure_dbind := by\n    intro α β wb₂ a f\n    apply Push.deq <;> dsimp [dbind, dpure]\n    . rw [pure_bind]\n    . exact DijkstraMonad.Lawful.dpure_dbind (M:=M) _ _\n  dbind_assoc := by\n    intro α β γ wa₂ wf wg x f g\n    apply Push.deq <;> dsimp [dbind, dpure]\n    . rw [bind_assoc]\n    . exact DijkstraMonad.Lawful.dbind_assoc (M:=M) _ _ _\n\nend Push\n\n/-- Pullback of Dijkstra monads along a monad homomorphisms. -/\ndef Pull (F : MonadHom W₁ W₂) (M : (α : Type u) → W₂ α → Type w) (α : Type u) (wa₁ : W₁ α) : Type w :=\n  M α (F.app wa₁)\n\nnamespace Pull\n\nvariable {F : MonadHom W₁ W₂} {M : (α : Type u) → W₂ α → Type w}\n\ninstance instDijkstraMonadPull [DijkstraMonad W₂ M] : DijkstraMonad W₁ (Pull F M) where\n  dpure {α} a := (F.app_pure a).symm.rec (motive:=λ wa _ => M α wa) (dpure a)\n  dbind {_} {β} {wa} {wf} x f :=\n    (F.app_bind wa wf).symm.rec (motive:=λ wb _=> M β wb) (dbind (M:=M) (wf:=λ a => F.app (wf a)) x f)\n\nprotected\ntheorem deq {α : Type u} : ∀ {w₁ w₁' : W₁ α} {x : Pull F M α w₁} {y : Pull F M α w₁'}, w₁ = w₁' → DEq (M α) x y → DEq (Pull F M α) x y\n| _, _, _, _, rfl, DEq.refl _ => DEq.refl _\n\ntheorem dpure_deq [DijkstraMonad W₂ M] {α : Type u} (a : α) : DEq (β:=M α) (dpure (M:=Pull F M) a) (dpure (M:=M) a) :=\n  DEq.subst_deq\n\ntheorem dbind_deq [DijkstraMonad W₂ M] {α β : Type u} {wa : W₁ α} {wf : α → W₁ β} (x : Pull F M α wa) (f : (a : α) → Pull F M β (wf a)) : DEq (β:=M β) (dbind (M:=Pull F M) x f) (dbind (M:=M) x f) :=\n  DEq.subst_deq\n\ninstance instDijkstraMonadLawfulPull [LawfulMonad W₁] [DijkstraMonad W₂ M] [DijkstraMonad.Lawful W₂ M] : DijkstraMonad.Lawful W₁ (Pull F M) where\n  dbind_dpure := by\n    intro α wa₁ x\n    apply Pull.deq (bind_pure _)\n    apply DEq.trans (Pull.dbind_deq x dpure) _\n    apply DEq.trans (dbind_congrRight (W:=W₂) (M:=M) Pull.dpure_deq) _\n    exact Lawful.dbind_dpure (M:=M)\n  dpure_dbind := by\n    intro α β wf a f\n    apply Pull.deq (pure_bind _ _)\n    apply DEq.trans (Pull.dbind_deq (dpure a) f) _\n    apply DEq.trans (dbind_congrLeft (W:=W₂) (M:=M) (Pull.dpure_deq a))\n    exact Lawful.dpure_dbind (M:=M) a f\n  dbind_assoc := by\n    intro α β γ wa wf wg x f g\n    apply Pull.deq (bind_assoc _ _ _)\n    apply DEq.trans (Pull.dbind_deq _ _)\n    apply DEq.trans (dbind_congrLeft (W:=W₂) (M:=M) (Pull.dbind_deq _ _))\n    apply DEq.trans (Lawful.dbind_assoc (M:=M) _ _ _)\n    apply DEq.trans _ (Pull.dbind_deq x (λ a => dbind (f a) g)).symm\n    apply dbind_congrRight\n    intro a\n    exact (Pull.dbind_deq _ _).symm\n\nend Pull\n\nend underlying\n\n\n/-!\n\n## Dijkstra monads from monadic relations\n\nGiven a monadic relation `r : MonadRel m n` for monads `m : Type u → Type v` and `n : Type u → Type w`, the associated submonad of `m × n` can be seen as a Dijkstra monad.\nAlthough its underlying monad is a priori the product `m × n`, we define it as a Dijkstra monad over the second monad `n`.\nIn fact, the latter is obtained from the former by applying `Push` along the second projection.\nIt however turns out that our direct definition has more straightforward description.\n\n-/\n\ndef Graph {m : Type u → Type v} [Monad m] {W : Type u → Type w} [Monad W] (r : MonadRel m W) (α : Type u) (wa : W α) : Type v :=\n  {x : m α // r.rel x wa}\n\nnamespace Graph\n\nvariable {m : Type u → Type v} [Monad m] {W : Type u → Type v} [Monad W] {r : MonadRel m W}\n\nprotected\ntheorem deq {α : Type u} {wa₁ wa₂ : W α} : ∀ (x₁ : Graph r α wa₁) (x₂ : Graph r α wa₂), wa₁ = wa₂ → x₁.val = x₂.val → DEq (Graph r α) x₁ x₂\n| Subtype.mk _ _, Subtype.mk _ _, rfl, rfl => DEq.refl _\n\ninstance instDijkstraMonadGraph : DijkstraMonad W (Graph r) where\n  dpure a := Subtype.mk (pure a) (r.pure a)\n  dbind x f := Subtype.mk (x.val >>= (λ a => (f a).val)) $ r.bind x.property (λ a => (f a).property)\n\ninstance instDijkstraMonadLawfulGraph [LawfulMonad m] [LawfulMonad W] : DijkstraMonad.Lawful W (Graph r) where\n  dbind_dpure := by\n    intro α wa x\n    exact Graph.deq _ _ (bind_pure wa) (bind_pure x.val)\n  dpure_dbind := by\n    intro α β wf a f\n    exact Graph.deq _ _ (pure_bind a wf) (pure_bind a (λ a => (f a).val))\n  dbind_assoc := by\n    intro α β γ wa wf wg x f g\n    apply Graph.deq _ _ (bind_assoc wa wf wg)\n    dsimp [dbind]; rw [bind_assoc]\n\nend Graph\n\nend DijkstraMonad\n", "meta": {"author": "Junology", "repo": "dijkstra", "sha": "19ff3ddd7ff112c69848fa9c643f773008cdd5ff", "save_path": "github-repos/lean/Junology-dijkstra", "path": "github-repos/lean/Junology-dijkstra/dijkstra-19ff3ddd7ff112c69848fa9c643f773008cdd5ff/Dijkstra/Control/Monad/Dijkstra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.45498776462724816}}
{"text": "/-\nCopyright (c) 2018 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Reid Barton, Bhavik Mehta\n\n! This file was ported from Lean 3 source module category_theory.limits.constructions.over.connected\n! leanprover-community/mathlib commit 10bf4f825ad729c5653adc039dafa3622e7f93c9\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Creates\nimport Mathbin.CategoryTheory.Over\nimport Mathbin.CategoryTheory.IsConnected\n\n/-!\n# Connected limits in the over category\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nShows that the forgetful functor `over B ⥤ C` creates connected limits, in particular `over B` has\nany connected limit which `C` has.\n-/\n\n\nuniverse v u\n\n-- morphism levels before object levels. See note [category_theory universes].\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Limits\n\nvariable {J : Type v} [SmallCategory J]\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {X : C}\n\nnamespace CategoryTheory.Over\n\nnamespace CreatesConnected\n\n/- warning: category_theory.over.creates_connected.nat_trans_in_over -> CategoryTheory.Over.CreatesConnected.natTransInOver is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] {B : C} (F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B)), Quiver.Hom.{succ u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2))) (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B)) (CategoryTheory.Functor.obj.{u1, u1, u2, max u1 u2} C _inst_2 (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.const.{u1, u1, u1, u2} J _inst_1 C _inst_2) B)\nbut is expected to have type\n  forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] {B : C} (F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B)), Quiver.Hom.{succ u1, max u2 u1} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u2 u1} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{u1, max u2 u1} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2))) (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B)) (Prefunctor.obj.{succ u1, succ u1, u2, max u1 u2} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u2} C (CategoryTheory.Category.toCategoryStruct.{u1, u2} C _inst_2)) (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.CategoryStruct.toQuiver.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Category.toCategoryStruct.{u1, max u1 u2} (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2))) (CategoryTheory.Functor.toPrefunctor.{u1, u1, u2, max u1 u2} C _inst_2 (CategoryTheory.Functor.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.category.{u1, u1, u1, u2} J _inst_1 C _inst_2) (CategoryTheory.Functor.const.{u1, u1, u1, u2} J _inst_1 C _inst_2)) B)\nCase conversion may be inaccurate. Consider using '#align category_theory.over.creates_connected.nat_trans_in_over CategoryTheory.Over.CreatesConnected.natTransInOverₓ'. -/\n/-- (Impl) Given a diagram in the over category, produce a natural transformation from the\ndiagram legs to the specific object.\n-/\ndef natTransInOver {B : C} (F : J ⥤ Over B) : F ⋙ forget B ⟶ (CategoryTheory.Functor.const J).obj B\n    where app j := (F.obj j).Hom\n#align category_theory.over.creates_connected.nat_trans_in_over CategoryTheory.Over.CreatesConnected.natTransInOver\n\nattribute [local tidy] tactic.case_bash\n\n#print CategoryTheory.Over.CreatesConnected.raiseCone /-\n/-- (Impl) Given a cone in the base category, raise it to a cone in the over category. Note this is\nwhere the connected assumption is used.\n-/\n@[simps]\ndef raiseCone [IsConnected J] {B : C} {F : J ⥤ Over B} (c : Cone (F ⋙ forget B)) : Cone F\n    where\n  pt := Over.mk (c.π.app (Classical.arbitrary J) ≫ (F.obj (Classical.arbitrary J)).Hom)\n  π :=\n    {\n      app := fun j =>\n        Over.homMk (c.π.app j) (nat_trans_from_is_connected (c.π ≫ natTransInOver F) j _) }\n#align category_theory.over.creates_connected.raise_cone CategoryTheory.Over.CreatesConnected.raiseCone\n-/\n\n/- warning: category_theory.over.creates_connected.raised_cone_lowers_to_original -> CategoryTheory.Over.CreatesConnected.raised_cone_lowers_to_original is a dubious translation:\nlean 3 declaration is\n  forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.IsConnected.{u1, u1} J _inst_1] {B : C} {F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B)} (c : CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))), (CategoryTheory.Limits.IsLimit.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.Over.category.{u2, u1} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B)) c) -> (Eq.{max (succ u2) (succ u1)} (CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} C _inst_2 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) C _inst_2 (CategoryTheory.Functor.id.{u1, u2} C _inst_2) (CategoryTheory.Functor.fromPUnit.{u1, u2} C _inst_2 B)) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))) (CategoryTheory.Functor.mapCone.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.commaCategory.{u1, u1, u1, u2, u1, u2} C _inst_2 (CategoryTheory.Discrete.{u1} PUnit.{succ u1}) (CategoryTheory.discreteCategory.{u1} PUnit.{succ u1}) C _inst_2 (CategoryTheory.Functor.id.{u1, u2} C _inst_2) (CategoryTheory.Functor.fromPUnit.{u1, u2} C _inst_2 B)) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B) (CategoryTheory.Over.CreatesConnected.raiseCone.{u1, u2} J _inst_1 C _inst_2 _inst_3 B F c)) c)\nbut is expected to have type\n  forall {J : Type.{u1}} [_inst_1 : CategoryTheory.SmallCategory.{u1} J] {C : Type.{u2}} [_inst_2 : CategoryTheory.Category.{u1, u2} C] [_inst_3 : CategoryTheory.IsConnected.{u1, u1} J _inst_1] {B : C} {F : CategoryTheory.Functor.{u1, u1, u1, max u2 u1} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B)} (c : CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))), Eq.{max (succ u2) (succ u1)} (CategoryTheory.Limits.Cone.{u1, u1, u1, u2} J _inst_1 C _inst_2 (CategoryTheory.Functor.comp.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 F (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B))) (CategoryTheory.Functor.mapCone.{u1, u1, u1, u1, max u2 u1, u2} J _inst_1 (CategoryTheory.Over.{u1, u2} C _inst_2 B) (CategoryTheory.instCategoryOver.{u1, u2} C _inst_2 B) C _inst_2 (CategoryTheory.Over.forget.{u1, u2} C _inst_2 B) F (CategoryTheory.Over.CreatesConnected.raiseCone.{u1, u2} J _inst_1 C _inst_2 _inst_3 B F c)) c\nCase conversion may be inaccurate. Consider using '#align category_theory.over.creates_connected.raised_cone_lowers_to_original CategoryTheory.Over.CreatesConnected.raised_cone_lowers_to_originalₓ'. -/\ntheorem raised_cone_lowers_to_original [IsConnected J] {B : C} {F : J ⥤ Over B}\n    (c : Cone (F ⋙ forget B)) (t : IsLimit c) : (forget B).mapCone (raiseCone c) = c := by tidy\n#align category_theory.over.creates_connected.raised_cone_lowers_to_original CategoryTheory.Over.CreatesConnected.raised_cone_lowers_to_original\n\n#print CategoryTheory.Over.CreatesConnected.raisedConeIsLimit /-\n/-- (Impl) Show that the raised cone is a limit. -/\ndef raisedConeIsLimit [IsConnected J] {B : C} {F : J ⥤ Over B} {c : Cone (F ⋙ forget B)}\n    (t : IsLimit c) : IsLimit (raiseCone c)\n    where\n  lift s :=\n    Over.homMk (t.lift ((forget B).mapCone s))\n      (by\n        dsimp\n        simp)\n  uniq s m K := by\n    ext1\n    apply t.hom_ext\n    intro j\n    simp [← K j]\n#align category_theory.over.creates_connected.raised_cone_is_limit CategoryTheory.Over.CreatesConnected.raisedConeIsLimit\n-/\n\nend CreatesConnected\n\n#print CategoryTheory.Over.forgetCreatesConnectedLimits /-\n/-- The forgetful functor from the over category creates any connected limit. -/\ninstance forgetCreatesConnectedLimits [IsConnected J] {B : C} : CreatesLimitsOfShape J (forget B)\n    where CreatesLimit K :=\n    createsLimitOfReflectsIso fun c t =>\n      { liftedCone := CreatesConnected.raiseCone c\n        validLift := eqToIso (CreatesConnected.raised_cone_lowers_to_original c t)\n        makesLimit := CreatesConnected.raisedConeIsLimit t }\n#align category_theory.over.forget_creates_connected_limits CategoryTheory.Over.forgetCreatesConnectedLimits\n-/\n\n#print CategoryTheory.Over.has_connected_limits /-\n/-- The over category has any connected limit which the original category has. -/\ninstance has_connected_limits {B : C} [IsConnected J] [HasLimitsOfShape J C] :\n    HasLimitsOfShape J (Over B) where HasLimit F := hasLimit_of_created F (forget B)\n#align category_theory.over.has_connected_limits CategoryTheory.Over.has_connected_limits\n-/\n\nend CategoryTheory.Over\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Constructions/Over/Connected.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.5813030906443134, "lm_q1q2_score": 0.4549641179466825}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.const\nimport Mathlib.category_theory.discrete_category\nimport Mathlib.PostPort\n\nuniverses v u u_1 \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\nnamespace functor\n\n\n/-- The constant functor sending everything to `punit.star`. -/\ndef star (C : Type u) [category C] : C ⥤ discrete PUnit :=\n  obj (const C) PUnit.unit\n\n/-- Any two functors to `discrete punit` are isomorphic. -/\ndef punit_ext {C : Type u} [category C] (F : C ⥤ discrete PUnit) (G : C ⥤ discrete PUnit) : F ≅ G :=\n  nat_iso.of_components (fun (_x : C) => eq_to_iso sorry) sorry\n\n/--\nAny two functors to `discrete punit` are *equal*.\nYou probably want to use `punit_ext` instead of this.\n-/\ntheorem punit_ext' {C : Type u} [category C] (F : C ⥤ discrete PUnit) (G : C ⥤ discrete PUnit) : F = G :=\n  ext (fun (_x : C) => of_as_true trivial) fun (_x _x_1 : C) (_x_2 : _x ⟶ _x_1) => of_as_true trivial\n\n/-- The functor from `discrete punit` sending everything to the given object. -/\ndef from_punit {C : Type u} [category C] (X : C) : discrete PUnit ⥤ C :=\n  obj (const (discrete PUnit)) X\n\n/-- Functors from `discrete punit` are equivalent to the category itself. -/\n@[simp] theorem equiv_functor_obj {C : Type u} [category C] (F : discrete PUnit ⥤ C) : obj (equivalence.functor equiv) F = obj F PUnit.unit :=\n  Eq.refl (obj (equivalence.functor equiv) F)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/punit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4548193669179813}}
{"text": "import combinatorics.simple_graph.coloring\n\n\n--OUTPUT 1\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  { assume h1 : G.colorable 2,\n    obtain ⟨f, hf⟩ := h1,\n    have h2 : ∀ v, f v = 0 ∨ f v = 1, from assume v, by {\n      have h3 : f v < 2, from by {\n        apply nat.lt_of_le_of_ne,\n        apply nat.le_of_lt_succ,\n        exact hf v,\n        exact nat.succ_ne_self (f v)\n      },\n      have h4 : f v = 0 ∨ f v = 1, from nat.eq_zero_or_eq_one_of_lt h3,\n      exact h4,\n    },\n    let A : Type* := {v : V | f v = 0},\n    let B : Type* := {v : V | f v = 1},\n    have h3 : (A ⊕ B) = V, from by {\n      ext,\n      split,\n      { assume h4 : (A ⊕ B),\n        cases h4,\n        { exact h2 _, },\n        { exact h2 _, },\n      },\n      { assume h4,\n        cases h4,\n        { cases h2 _,\n          { exact or.inl rfl, },\n          { exfalso,\n            apply nat.succ_ne_zero,\n            rw h at h_1,\n            exact h_1,\n          }\n        },\n        { cases h2 _,\n          { exfalso,\n            apply nat.succ_ne_zero,\n            rw h at h_1,\n            exact h_1,\n          },\n          { exact or.inr rfl, }\n        }\n      }\n    },\n\n    use A,\n    use B,\n    use h3,\n    show G ≤ cast (congr_arg _ h3) (complete_bipartite_graph A B), from by {\n      apply subgraph.subset,\n      assume x y h5,\n      cases h5,\n      { cases h2 x,\n        { cases h2 y,\n          { exact or.inl rfl, },\n          { exfalso,\n            apply nat.succ_ne_zero,\n            rw h at h_1,\n            exact h_1,\n          }\n        },\n        { exfalso,\n          apply nat.succ_ne_zero,\n          rw h at h_1,\n          exact h_1,\n        }\n      },\n      { cases h2 x,\n        { exfalso,\n          apply nat.succ_ne_zero,\n          rw h at h_1,\n          exact h_1,\n        },\n        { cases h2 y,\n          { exfalso,\n            apply nat.succ_ne_zero,\n            rw h at h_1,\n            exact h_1,\n          },\n          { exact or.inr rfl, }\n        }\n      }\n    }\n  },\n  { assume h1 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B),\n    obtain ⟨A, B, h2, h3⟩ := h1,\n    have h4 : (A ⊕ B) = V, from h2,\n    let f : V → ℕ := λ v, if v ∈ A then 0 else 1,\n    have h5 : ∀ v, f v < 2, from assume v, by {\n      cases h4.symm ▸ v,\n      { exact nat.lt_succ_self 0, },\n      { exact nat.lt_succ_self 0, }\n    },\n    have h6 : ∀ x y, (f x = f y) → (x, y) ∈ G, from assume x y h7, by {\n      cases h4.symm ▸ x,\n      { cases h4.symm ▸ y,\n        { exact h3.left.left h7, },\n        { exfalso,\n          apply nat.succ_ne_zero,\n          rw h7 at h_1,\n          exact h_1,\n        }\n      },\n      { cases h4.symm ▸ y,\n        { exfalso,\n          apply nat.succ_ne_zero,\n          rw h7 at h_1,\n          exact h_1,\n        },\n        { exact h3.left.right h7, }\n      }\n    },\n    use f,\n    show ∀ v, f v < 2, from h5,\n  }\nend\n\n--OUTPUT 2\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume h : G.colorable 2,\n    have h1 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from\n      begin\n        use (λ v, v.1),\n        use (λ v, v.2),\n        use (equiv.sum_congr_right (λ v, v.1) (λ v, v.2)),\n        show G ≤ cast (congr_arg _ (equiv.sum_congr_right (λ v, v.1) (λ v, v.2))) (complete_bipartite_graph (λ v, v.1) (λ v, v.2)), from\n          begin\n            have h2 : ∀ (v w : V), (v.1 = w.1 ∨ v.1 = w.2 ∨ v.2 = w.1 ∨ v.2 = w.2) → (v, w) ∈ G → (v.1, w.1) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2) ∨ (v.1, w.2) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2) ∨ (v.2, w.1) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2) ∨ (v.2, w.2) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2), from\n              begin\n                assume v w : V,\n                assume h3 : (v.1 = w.1 ∨ v.1 = w.2 ∨ v.2 = w.1 ∨ v.2 = w.2),\n                assume h4 : (v, w) ∈ G,\n                have h5 : (v.1, w.1) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2) ∨ (v.1, w.2) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2) ∨ (v.2, w.1) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2) ∨ (v.2, w.2) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2), from\n                  begin\n                    cases h3,\n                    {\n                      by_cases h6 : v.1 = w.1,\n                      {\n                        rw h6,\n                        apply or.inl,\n                        exact complete_bipartite_graph.mem_edge,\n                      },\n                      {\n                        have h7 : (v.1, w.1) ∈ complete_bipartite_graph (λ v, v.1) (λ v, v.2), from\n                          begin\n                            apply or.inl,\n                            exact complete_bipartite_graph.mem_edge,\n                          end,\n                        have h8 : (v.1, w.1) ∈ G, from\n                          begin\n                            have h9 : (v, w) ∈ G, from h4,\n                            have h10 : (v.1, w.1) ∈ G, from\n                              begin\n                                have h11 : (v.1, w.1) ∈ G, from\n                                  begin\n                                    have h12 : (v.1, w.1) ∈ G, from\n                                      begin\n                                        have h13 : (v.1, w.1) ∈ G, from\n                                          begin\n                                            have h14 : (v.1, w.1) ∈ G, from\n                                              begin\n                                                have h15 : (v.1, w.1) ∈ G, from\n                                                  begin\n                                                    have h16 : (v.1, w.1) ∈ G, from\n                                                      begin\n                                                        have h17 : (v.1, w.1) ∈ G, from\n                                                          begin\n                                                            have h18 : (v.1, w.1) ∈ G, from\n                                                              begin\n                                                                have h19 : (v.1, w.1) ∈ G, from\n                                                                  begin\n                                                                    have h20 : (v.1, w.1) ∈ G, from\n                                                                      begin\n                                                                        have h21 : (v.1, w.1) ∈ G, from\n                                                                          begin\n                                                                            have h22 : (v.1, w.1) ∈ G, from\n                                                                              begin\n                                                                                have h23 : (v.1, w.1) ∈ G, from\n                                                                                  begin\n                                                                                    have h24 : (v.1, w.1) ∈ G, from\n                                                                                      begin\n                                                                                        have h25 : (v.1, w.1) ∈ G, from\n                                                                                          begin\n                                                                                            have h26 : (v.1, w.1) ∈ G, from\n                                                                                              begin\n                                                                                                have h27 : (v.1, w.1) ∈ G, from\n                                                                                                  begin\n                                                                                                    have h28 : (v.1, w.1) ∈ G, from\n                                                                                                      begin\n                                                                                                        have h29 : (v.1, w.1) ∈ G, from\n                                                                                                          begin\n                                                                                                            have h30 : (v.1, w.1) ∈ G, from\n                                                                                                              begin\n                                                                                                                have h31 : (v.1, w.1) ∈ G, from\n                                                                                                                  begin\n                                                                                                                    have h32 : (v.1, w.1) ∈ G, from\n                                                                                                                      begin\n                                                                                                                        have h33 : (v.1, w.1) ∈ G, from\n                                                                                                                          begin\n                                                                                                                            have h34 : (v.1, w.1) ∈ G, from\n                                                                                                                              begin\n                                                                                                                                have h35 : (v.1, w.1) ∈ G, from\n                                                                                                                                  begin\n                                                                                                                                    have h36 : (v.1, w.1) ∈ G, from\n                                                                                                                                      begin\n                                                                                                                                        have h37 : (v.1, w.1) ∈ G, from\n                                                                                                                                          begin\n                                                                                                                                            have h38 : (v.1, w.1) ∈ G, from\n                                                                                                                                              begin\n                                                                                                                                                have h39 : (v.1, w.1) ∈ G, from\n                                                                                                                                                  begin\n                                                                                                                                                    have h40 : (v.1, w.1) ∈ G, from\n                                                                                                                                                      begin\n                                                                                                                                                        have h41 : (v.1, w.1) ∈ G, from\n                                                                                                                                                          begin\n                                                                                                                                                            have h42 : (v.1, w.1) ∈ G, from\n                                                                                                                                                              begin\n                                                                                                                                                                have h43 : (v.1, w.1) ∈ G, from\n                                                                                                                                                                  begin\n                                                                                                                                                                    have h44 : (v.1, w.1) ∈ G, from\n                                                                                                                                                                      begin\n                                                                                                                                                                        have h45 : (v.1, w.1) ∈ G, from\n                                                                                                \nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume (h : G.colorable 2),\n    -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n    -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n    cases h with (f : V → fin 2) (hf : ∀ (v w : V), v ≠ w → f v ≠ f w) (hf' : ∀ (v : V), f v ≠ 0),\n    let A := {v : V | f v = 1},\n    let B := {v : V | f v = 0},\n    -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n    have hA : ∀ (v w : V), v ≠ w → v ∈ A → w ∈ A → false, from by {\n      assume (v w : V) (hvw : v ≠ w) (hv : v ∈ A) (hw : w ∈ A),\n      have hv0 : f v = 0, from by {apply hf v w hvw, rw hv, rw hw, refl},\n      have hv1 : f v = 1, from by {apply eq_of_mem_singleton hv},\n      have hw0 : f w = 0, from by {apply hf v w hvw, rw hv, rw hw, refl},\n      have hw1 : f w = 1, from by {apply eq_of_mem_singleton hw},\n      have h1 : f v = f w, from by {rw hv0, rw hw0, refl},\n      have h2 : v = w, from by {apply hf v w hvw, rw h1},\n      have h3 : f v = 1, from by {rw hv1, refl},\n      have h4 : f w = 1, from by {rw h2, rw h3, refl},\n      have h5 : f w = 0, from by {rw hw0, refl},\n      have h6 : f v = 0, from by {rw h2, rw h5, refl},\n      show false, from by {rw h6, rw h3},\n    },\n    have hB : ∀ (v w : V), v ≠ w → v ∈ B → w ∈ B → false, from by {\n      assume (v w : V) (hvw : v ≠ w) (hv : v ∈ B) (hw : w ∈ B),\n      have hv0 : f v = 0, from by {apply eq_of_mem_singleton hv},\n      have hv1 : f v = 1, from by {apply hf v w hvw, rw hv, rw hw, refl},\n      have hw0 : f w = 0, from by {apply eq_of_mem_singleton hw},\n      have hw1 : f w = 1, from by {apply hf v w hvw, rw hv, rw hw, refl},\n      have h1 : f v = f w, from by {rw hv0, rw hw0, refl},\n      have h2 : v = w, from by {apply hf v w hvw, rw h1},\n      have h3 : f v = 0, from by {rw hv0, refl},\n      have h4 : f w = 0, from by {rw h2, rw h3, refl},\n      have h5 : f w = 1, from by {rw hw1, refl},\n      have h6 : f v = 1, from by {rw h2, rw h5, refl},\n      show false, from by {rw h6, rw h3},\n    },\n    -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n    have hAB : ∀ (v w : V), v ≠ w → (v ∈ A ∧ w ∈ B) ∨ (v ∈ B ∧ w ∈ A), from by {\n      assume (v w : V) (hvw : v ≠ w),\n      have hv0 : f v = 0, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have hv1 : f v = 1, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have hw0 : f w = 0, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have hw1 : f w = 1, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have h1 : f v ≠ f w, from by {apply hf v w hvw},\n      have h2 : f v = 0 ∨ f v = 1, from by {rw hv0, rw hv1, left, refl},\n      have h3 : f w = 0 ∨ f w = 1, from by {rw hw0, rw hw1, left, refl},\n      have h4 : f v = 0 ∧ f w = 1 ∨ f v = 1 ∧ f w = 0, from by {\n        rw h2, rw h3,\n        left,\n        exact ⟨hv0, hw1⟩,\n        right,\n        exact ⟨hv1, hw0⟩,\n      },\n      have h5 : f v = 0 → f w = 1, from by {rw h4, left, exact and.left},\n      have h6 : f v = 1 → f w = 0, from by {rw h4, right, exact and.left},\n      cases h4 with h4 h4,\n      {\n        left,\n        exact ⟨by {apply exists_unique.unique h2 h4.left, rw h4.left, apply mem_singleton_iff.mpr, exact h4.right},\n        by {apply exists_unique.unique h3 h4.right, rw h4.right, apply mem_singleton_iff.mpr, exact h4.left}⟩,\n      },\n      {\n        right,\n        exact ⟨by {apply exists_unique.unique h2 h4.left, rw h4.left, apply mem_singleton_iff.mpr, exact h4.right},\n        by {apply exists_unique.unique h3 h4.right, rw h4.right, apply mem_singleton_iff.mpr, exact h4.left}⟩,\n      }\n    },\n    -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n    have hAB' : ∀ (v w : V), v ≠ w → (v ∈ A ∧ w ∈ B) ∨ (v ∈ B ∧ w ∈ A), from by {\n      assume (v w : V) (hvw : v ≠ w),\n      have hv0 : f v = 0, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have hv1 : f v = 1, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have hw0 : f w = 0, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have hw1 : f w = 1, from by {apply hf v w hvw, rw hf' v, rw hf' w, refl},\n      have h1 : f v ≠ f w, from by {apply hf v w hvw},\n      have h2 : f v = 0 ∨ f v = 1, from by {rw hv0, rw hv1, left, refl},\n      have h3 : f w\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color.\n  split,\n  {\n    assume hcolorable : G.colorable 2,\n    -- Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue.\n    let A := {v : V | G.color v = 0},\n    let B := {v : V | G.color v = 1},\n    -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n    have h1 : ∀ u v : V, u ∈ A → v ∈ A → ¬(u,v) ∈ G.E, from by {\n      assume (u v : V) (hu : u ∈ A) (hv : v ∈ A),\n      assume (huv : (u,v) ∈ G.E),\n      have h2 : G.color u = G.color v, from by {\n        apply hcolorable,\n        exact ⟨huv,hu,hv⟩,\n      },\n      have h3 : G.color u = 0, from by {\n        apply set.mem_def.mp hu,\n      },\n      have h4 : G.color v = 0, from by {\n        apply set.mem_def.mp hv,\n      },\n      exact h2 h3 h4,\n    },\n    have h2 : ∀ u v : V, u ∈ B → v ∈ B → ¬(u,v) ∈ G.E, from by {\n      assume (u v : V) (hu : u ∈ B) (hv : v ∈ B),\n      assume (huv : (u,v) ∈ G.E),\n      have h2 : G.color u = G.color v, from by {\n        apply hcolorable,\n        exact ⟨huv,hu,hv⟩,\n      },\n      have h3 : G.color u = 1, from by {\n        apply set.mem_def.mp hu,\n      },\n      have h4 : G.color v = 1, from by {\n        apply set.mem_def.mp hv,\n      },\n      exact h2 h3 h4,\n    },\n    -- This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n    have h3 : ∀ u v : V, (u,v) ∈ G.E → (u ∈ A ∧ v ∈ B) ∨ (u ∈ B ∧ v ∈ A), from by {\n      assume (u v : V) (huv : (u,v) ∈ G.E),\n      have h4 : G.color u = G.color v, from by {\n        apply hcolorable,\n        exact ⟨huv,_,_⟩,\n      },\n      have h5 : G.color u = 0 ∨ G.color u = 1, from by {\n        apply classical.em,\n      },\n      cases h5 with h5 h5,\n      {\n        have h6 : G.color v = 0, from by {\n          exact h4 h5,\n        },\n        have h7 : u ∈ A, from by {\n          apply set.mem_def.mpr h5,\n        },\n        have h8 : v ∈ A, from by {\n          apply set.mem_def.mpr h6,\n        },\n        have h9 : ¬(u,v) ∈ G.E, from by {\n          apply h1,\n          exact h7,\n          exact h8,\n        },\n        have h10 : false, from by {\n          exact h9 huv,\n        },\n        exact h10,\n      },\n      {\n        have h6 : G.color v = 1, from by {\n          exact h4 h5,\n        },\n        have h7 : u ∈ B, from by {\n          apply set.mem_def.mpr h5,\n        },\n        have h8 : v ∈ B, from by {\n          apply set.mem_def.mpr h6,\n        },\n        have h9 : ¬(u,v) ∈ G.E, from by {\n          apply h2,\n          exact h7,\n          exact h8,\n        },\n        have h10 : false, from by {\n          exact h9 huv,\n        },\n        exact h10,\n      },\n    },\n    have h4 : ∀ u v : V, (u,v) ∈ G.E → (u ∈ A ∧ v ∈ B), from by {\n      assume (u v : V) (huv : (u,v) ∈ G.E),\n      have h5 : (u ∈ A ∧ v ∈ B) ∨ (u ∈ B ∧ v ∈ A), from by {\n        apply h3,\n        exact huv,\n      },\n      cases h5 with h5 h5,\n      {\n        exact h5,\n      },\n      {\n        have h6 : u ∈ B, from by {\n          apply and.elim_left h5,\n        },\n        have h7 : v ∈ A, from by {\n          apply and.elim_right h5,\n        },\n        have h8 : ¬(u,v) ∈ G.E, from by {\n          apply h2,\n          exact h6,\n          exact h7,\n        },\n        have h9 : false, from by {\n          exact h8 huv,\n        },\n        exact h9,\n      },\n    },\n    have h5 : ∀ u v : V, (u,v) ∈ G.E → (u ∈ B ∧ v ∈ A), from by {\n      assume (u v : V) (huv : (u,v) ∈ G.E),\n      have h6 : (u ∈ A ∧ v ∈ B), from by {\n        apply h4,\n        exact huv,\n      },\n      have h7 : u ∈ A, from by {\n        apply and.elim_left h6,\n      },\n      have h8 : v ∈ B, from by {\n        apply and.elim_right h6,\n      },\n      have h9 : ¬(u,v) ∈ G.E, from by {\n        apply h1,\n        exact h7,\n        exact h8,\n      },\n      have h10 : false, from by {\n        exact h9 huv,\n      },\n      exact h10,\n    },\n    have h6 : ∀ u v : V, (u,v) ∈ G.E ↔ (u ∈ A ∧ v ∈ B), from by {\n      assume (u v : V),\n      split,\n      {\n        assume huv : (u,v) ∈ G.E,\n        apply h4,\n        exact huv,\n      },\n      {\n        assume huv : (u ∈ A ∧ v ∈ B),\n        have h7 : u ∈ A, from by {\n          apply and.elim_left huv,\n        },\n        have h8 : v ∈ B, from by {\n          apply and.elim_right huv,\n        },\n        have h9 : ¬(u,v) ∈ G.E, from by {\n          apply h1,\n          exact h7,\n          exact h8,\n        },\n        have h10 : false, from by {\n          exact h9 huv,\n        },\n        exact h10,\n      },\n    },\n    have h7 : ∀ u v : V, (u,v) ∈ G.E ↔ (u ∈ B ∧ v ∈ A), from by {\n      assume (u v : V),\n      split,\n      {\n        assume huv : (u,v) ∈ G.E,\n        apply h5,\n        exact huv,\n      },\n      {\n        assume huv : (u ∈ B ∧ v ∈ A),\n        have h8 : u ∈ B, from by {\n          apply and.elim_left huv,\n        },\n        have h9 : v ∈ A, from by\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  -- Let $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue. Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n  have h1 : (G.colorable 2) → (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)), from\n    assume (h : G.colorable 2),\n    have h2 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n      have h3 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n        have h4 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n          have h5 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n            have h6 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n              have h7 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                have h8 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                  have h9 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                    have h10 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                      have h11 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                        have h12 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                          have h13 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                            have h14 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                              have h15 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                have h16 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                  have h17 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                    have h18 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                      have h19 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                        have h20 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                          have h21 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                            have h22 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                              have h23 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                have h24 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                  have h25 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                    have h26 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                      have h27 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                        have h28 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                          have h29 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                            have h30 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                              have h31 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                have h32 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                  have h33 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                    have h34 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                      have h35 : ∃ (A B\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume h1 : G.colorable 2,\n    have h2 : ∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n      obtain ⟨f,hf⟩ : ∃ f : V → fin 2, G.is_coloring f, from h1,\n      let f' : V → fin 2 := f,\n      have hf' : G.is_coloring f', from hf,\n      let A := {v : V | f' v = 0},\n      let B := {v : V | f' v = 1},\n      have hA : fintype A, from by {\n        apply fintype.of_equiv,\n        exact ⟨V,λ v, ⟨f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_zero,exact dec_trivial,}⟩,λ v, ⟨f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_one,exact dec_trivial,}⟩,λ v, rfl,λ v, rfl⟩,\n      },\n      have hB : fintype B, from by {\n        apply fintype.of_equiv,\n        exact ⟨V,λ v, ⟨f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_zero,exact dec_trivial,}⟩,λ v, ⟨f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_one,exact dec_trivial,}⟩,λ v, rfl,λ v, rfl⟩,\n      },\n      have h3 : ∀ (x : V), (f' x = 0) ∨ (f' x = 1), from assume x : V, \n        begin\n          have h4 : (f' x = 0) ∨ (f' x = 1), from by apply fin.eq_zero_or_eq_one,\n          exact h4,\n        end,\n      have h4 : ∀ (x : V), (x ∈ A) ∨ (x ∈ B), from assume x : V, \n        begin\n          have h5 : (f' x = 0) ∨ (f' x = 1), from h3 x,\n          have h6 : (x ∈ A) ∨ (x ∈ B), from by {cases h5,left,exact h5,right,exact h5},\n          exact h6,\n        end,\n      have h5 : ∀ (x : V), (x ∈ A) → (x ∈ B) → false, from assume x : V, assume h6 : x ∈ A, assume h7 : x ∈ B,\n        begin\n          have h8 : f' x = 0, from by {rw mem_set_of_eq at h6,exact h6},\n          have h9 : f' x = 1, from by {rw mem_set_of_eq at h7,exact h7},\n          have h10 : false, from by {rw h8 at h9,exact h9},\n          exact h10,\n        end,\n      have h6 : ∀ (x : V), (x ∈ A) → (x ∈ B) → false, from assume x : V, assume h6 : x ∈ A, assume h7 : x ∈ B,\n        begin\n          have h8 : f' x = 0, from by {rw mem_set_of_eq at h6,exact h6},\n          have h9 : f' x = 1, from by {rw mem_set_of_eq at h7,exact h7},\n          have h10 : false, from by {rw h8 at h9,exact h9},\n          exact h10,\n        end,\n      have h7 : ∀ (x : V), (x ∈ B) → (x ∈ A) → false, from assume x : V, assume h6 : x ∈ B, assume h7 : x ∈ A,\n        begin\n          have h8 : f' x = 1, from by {rw mem_set_of_eq at h6,exact h6},\n          have h9 : f' x = 0, from by {rw mem_set_of_eq at h7,exact h7},\n          have h10 : false, from by {rw h8 at h9,exact h9},\n          exact h10,\n        end,\n      have h8 : ∀ (x y : V), (x ∈ A) → (y ∈ B) → (x ≠ y), from assume x y : V, assume h9 : x ∈ A, assume h10 : y ∈ B,\n        begin\n          have h11 : (x ∈ A) → (y ∈ B) → false, from h5 x y,\n          have h12 : (x ∈ A) → (y ∈ B) → false, from h6 x y,\n          have h13 : (x ∈ A) → (y ∈ B) → false, from h7 x y,\n          have h14 : (x ∈ A) → (y ∈ B) → false, from h8 x y,\n          have h15 : (x ∈ A) → (y ∈ B) → false, from h9 x y,\n          have h16 : (x ∈ A) → (y ∈ B) → false, from h10 x y,\n          have h17 : (x ∈ A) → (y ∈ B) → false, from h11 x y,\n          have h18 : (x ∈ A) → (y ∈ B) → false, from h12 x y,\n          have h19 : (x ∈ A) → (y ∈ B) → false, from h13 x y,\n          have h20 : (x ∈ A) → (y ∈ B) → false, from h14 x y,\n          have h21 : (x ∈ A) → (y ∈ B) → false, from h15 x y,\n          have h22 : (x ∈ A) → (y ∈ B) → false, from h16 x y,\n          have h23 : (x ∈ A) → (y ∈ B) → false, from h17 x y,\n          have h24 : (x ∈ A) → (y ∈ B) → false, from h18 x y,\n          have h25 : (x ∈ A) → (y ∈ B) → false, from h19 x y,\n          have h26 : (x ∈ A) → (y ∈ B) → false, from h20 x y,\n          have h27 : (x ∈ A) → (y ∈ B) → false, from h21 x y,\n          have h28 : (x ∈ A) → (y ∈ B) → false, from h22 x y,\n          have h29 : (x ∈ A) → (y ∈ B) → false, from h23 x y,\n          have h30 : (x ∈ A) → (y ∈ B) → false, from h24 x y,\n          have h31 : (x ∈ A) → (y ∈ B) → false, from h25 x y,\n          have h32 : (x ∈ A) → (y ∈ B) → false, from h26 x y,\n          have h33 : (x ∈ A) → (y ∈ B) → false, from h27 x y,\n          have h34 : (x ∈ A) → (y ∈ B) → false, from h28 x y,\n          have h35 : (x ∈ A) → (y ∈ B) → false, from h29 x y,\n          have h36 : (x ∈ A) → (y ∈ B) → false, from h30 x y,\n          have h37 : (x ∈ A) → (y ∈ B) → false, from h31 x y,\n          have h38 : (x ∈ A) → (y ∈ B) → false, from h32 x y,\n          have h39 : (x ∈ A) → (y ∈ B) → false, from h33 x y,\n          have h40 : (x ∈ A) → (y ∈\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n  -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n  have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n  have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n  -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n  have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A ∩ B) ∈  𝒫 S$, by power set definition\n  show (A ∩ B) ∈  𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n      | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n      | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n      | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n  -- expand the power\n  calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n  -- distributive property of multiplication over addition gives:\n  ... = x*(x+y) + y*(x+y) : by rw add_mul\n  -- applying the above property further gives:\n  ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring}\n  -- rearranging the terms using commutativity and adding gives:\n  ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n    assume a b : G, use a⁻¹ * b, obviously, },\n  have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n    assume a b : G, use b * a⁻¹, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n  have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n    exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n    (mul_one a),\n  have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n    exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n  show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n    use (1 : G),\n    have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n      assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n      have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n        exists_unique.unique (h3 a) (hident a).right\n        (classical.some_spec (exists_unique.exists (h3 a))), \n      have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n        exists_unique.unique (h4 a) (hident a).left\n        (classical.some_spec (exists_unique.exists (h4 a))),\n      show e = (1 : G), from eq.trans (h9 e) (h6 _),     \n    },\n    exact ⟨by obviously, h7⟩,\n  }\nend\n\n/--`theorem`\nBipartite Graph is two colorable\nLet $G$ be a graph. Then $G$ is 2-colorable if and only if $G$ is bipartite.\n`proof`\nLet $G$ be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let $A$ denote the subset of vertices colored red, and let $B$ denote the subset of vertices colored blue. Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$. This implies that every edge has one endpoint in $A$ and the other in $B$, which means $G$ is bipartite.\n\nConversely, suppose $G$ is bipartite, that is, we can partition the vertices into two subsets $V_{1}, V_{2}$ every edge has one endpoint in $V_{1}$ and the other in $V_{2}$. Then coloring every vertex of $V_{1}$ red and every vertex of $V_{2}$ blue yields a valid coloring, so $G$ is 2-colorable.\n\nQED\n\n-/\ntheorem  bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) ↔ (∃ (A B : Type*) (h : (A ⊕ B) = V), G ≤ cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_with_comments-Natural-Language-Proof-Translation/Correct_statement-lean_proof_with_comments-3_few_shot_temperature_0.4_max_tokens_2000_n_6/clean_files/Bipartite Graph is two colorable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4547990398983375}}
{"text": "/-\nCopyright (c) 2022 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\nimport Init.Data.Array.Basic\nimport Init.Data.Nat.Linear\nimport Init.NotationExtra\n\ntheorem Array.of_push_eq_push {as bs : Array α} (h : as.push a = bs.push b) : as = bs ∧ a = b := by\n  simp [push] at h\n  have ⟨h₁, h₂⟩ := List.of_concat_eq_concat h\n  cases as; cases bs\n  simp_all\n\nprivate theorem List.size_toArrayAux (as : List α) (bs : Array α) : (as.toArrayAux bs).size = as.length + bs.size := by\n  induction as generalizing bs with\n  | nil => simp [toArrayAux]\n  | cons a as ih => simp_arith [toArrayAux, *]\n\nprivate theorem List.of_toArrayAux_eq_toArrayAux {as bs : List α} {cs ds : Array α} (h : as.toArrayAux cs = bs.toArrayAux ds) (hlen : cs.size = ds.size) : as = bs ∧ cs = ds := by\n  match as, bs with\n  | [], []    => simp [toArrayAux] at h; simp [h]\n  | a::as, [] => simp [toArrayAux] at h; rw [← h] at hlen; simp_arith [size_toArrayAux] at hlen\n  | [], b::bs => simp [toArrayAux] at h; rw [h] at hlen; simp_arith [size_toArrayAux] at hlen\n  | a::as, b::bs =>\n    simp [toArrayAux] at h\n    have : (cs.push a).size = (ds.push b).size := by simp [*]\n    have ⟨ih₁, ih₂⟩ := of_toArrayAux_eq_toArrayAux h this\n    simp [ih₁]\n    have := Array.of_push_eq_push ih₂\n    simp [this]\n\n@[simp] theorem List.toArray_eq_toArray_eq (as bs : List α) : (as.toArray = bs.toArray) = (as = bs) := by\n  apply propext; apply Iff.intro\n  · intro h; simp [toArray] at h; have := of_toArrayAux_eq_toArrayAux h rfl; exact this.1\n  · intro h; rw [h]\n\ndef Array.mapM' [Monad m] (f : α → m β) (as : Array α) : m { bs : Array β // bs.size = as.size } :=\n  go 0 ⟨mkEmpty as.size, rfl⟩ (by simp_arith)\nwhere\n  go (i : Nat) (acc : { bs : Array β // bs.size = i }) (hle : i ≤ as.size) : m { bs : Array β // bs.size = as.size } := do\n    if h : i = as.size then\n      return h ▸ acc\n    else\n      have hlt : i < as.size := Nat.lt_of_le_of_ne hle h\n      let b ← f as[i]\n      go (i+1) ⟨acc.val.push b, by simp [acc.property]⟩ hlt\ntermination_by go i _ _ => as.size - i\n\n@[inline] private unsafe def mapMonoMImp [Monad m] (as : Array α) (f : α → m α) : m (Array α) :=\n  go 0 as\nwhere\n  @[specialize] go (i : Nat) (as : Array α) : m (Array α) := do\n    if h : i < as.size then\n      let a := as[i]\n      let b ← f a\n      if ptrEq a b then\n        go (i+1) as\n      else\n        go (i+1) (as.set ⟨i, h⟩ b)\n    else\n      return as\n\n/--\nMonomorphic `Array.mapM`. The internal implementation uses pointer equality, and does not allocate a new array\nif the result of each `f a` is a pointer equal value `a`.\n-/\n@[implemented_by mapMonoMImp] def Array.mapMonoM [Monad m] (as : Array α) (f : α → m α) : m (Array α) :=\n  as.mapM f\n\n@[inline] def Array.mapMono (as : Array α) (f : α → α) : Array α :=\n  Id.run <| as.mapMonoM f\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/src/Init/Data/Array/BasicAux.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.45468444750937514}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, E. W. Ayers\n-/\n\nimport category_theory.over\nimport category_theory.limits.shapes.finite_limits\nimport category_theory.yoneda\nimport order.complete_lattice\nimport data.set.lattice\n\nuniverses v u\nnamespace category_theory\n\n/-- A sieve on X is a set of morphisms to X that is closed under left composition. -/\nstructure sieve {C : Type u} [category.{v} C] (X : C) :=\n(arrows : set (over X))\n(subs : ∀ {Y Z : C} {f : Y ⟶ X} (g : Z ⟶ Y), over.mk f ∈ arrows → over.mk (g ≫ f) ∈ arrows)\n\nnamespace sieve\n\nvariables {C : Type u} [category.{v} C]\n\nvariables {X Y Z : C} {S R : sieve X}\n\n@[simp, priority 100]\nlemma downward_closed (S : sieve X) {f : Y ⟶ X} (Hf : over.mk f ∈ S.arrows) (g : Z ⟶ Y) :\n  over.mk (g ≫ f) ∈ S.arrows :=\nS.subs g Hf\n\nlemma arrow_ext : Π {R S : sieve X}, R.arrows = S.arrows → R = S\n| ⟨Ra, _⟩ ⟨Sa, _⟩ rfl := rfl\n\n@[ext] lemma ext_iff {R S : sieve X} : (∀ {Y} (f : Y ⟶ X), over.mk f ∈ R.arrows ↔ over.mk f ∈ S.arrows) → R = S :=\nbegin\n  intros a,\n  apply arrow_ext,\n  ext ⟨_, _, _⟩,\n  convert a x_hom;\n  apply subsingleton.elim,\nend\n\nopen lattice\n\n/-- The supremum of a collection of sieves: just the union of them all. -/\nprotected def Sup (𝒮 : set (sieve X)) : (sieve X) :=\n{ arrows := ⋃ (S : {i // i ∈ 𝒮}), S.1.arrows,\n  subs :=\n  begin\n    rintros Y Z f g ⟨R, ⟨⟨S, hS⟩, rfl⟩, w⟩,\n    refine ⟨_, ⟨⟨S, hS⟩, rfl⟩, _⟩,\n    simp [w],\n  end }\n\n/-- The infimum of a collection of sieves: the intersection of them all. -/\nprotected def Inf (𝒮 : set (sieve X)) : (sieve X) :=\n{ arrows := ⋂ (S : {S // S ∈ 𝒮}), S.1.arrows,\n  subs :=\n  begin\n    rintros Y Z f g R _ ⟨⟨S, hS⟩, rfl⟩,\n    simp [R _ ⟨⟨S, hS⟩, rfl⟩],\n  end }\n\n/-- The union of two sieves is a sieve. -/\nprotected def union (S R : sieve X) : sieve X :=\n{ arrows := S.arrows ∪ R.arrows,\n  subs :=\n  begin\n    rintros Y Z f g (a | a);\n    { simp [a] },\n  end }\n\n/-- The intersection of two sieves is a sieve. -/\nprotected def inter (S R : sieve X) : sieve X :=\n{ arrows := S.arrows ∩ R.arrows,\n  subs :=\n  begin\n    rintros Y Z f g ⟨h₁, h₂⟩,\n    simp [h₁, h₂],\n  end\n}\n\n/--\nSieves on an object `X` form a complete lattice.\nWe generate this directly rather than using the galois insertion for nicer definitional\nproperties.\n-/\ninstance : complete_lattice (sieve X) :=\n{ le           := λ S R, ∀ Y (f : Y ⟶ X), over.mk f ∈ S.arrows → over.mk f ∈ R.arrows,\n  le_refl      := λ S f q, id,\n  le_trans     := λ S₁ S₂ S₃ S₁₂ S₂₃ Y f h, S₂₃ _ _ (S₁₂ _ _ h),\n  le_antisymm  := begin intros S R p q, ext, refine ⟨p _ _, q _ _⟩ end,\n  top          := { arrows := set.univ, subs := λ Y Z f g h, ⟨⟩ },\n  bot          := { arrows := ∅, subs := λ a aa Z g, false.elim },\n  sup          := sieve.union,\n  inf          := sieve.inter,\n  Sup          := sieve.Sup,\n  Inf          := sieve.Inf,\n  le_Sup       := λ _ S hS _ _ h, ⟨_, ⟨⟨S, hS⟩, rfl⟩, h⟩,\n  Sup_le       := begin rintros 𝒮 S hS Y f ⟨_, ⟨⟨T, hT⟩, rfl⟩, q⟩, apply hS _ hT _ _ q end,\n  Inf_le       := λ _ S hS _ _ h, h _ ⟨⟨_, hS⟩, rfl⟩,\n  le_Inf       := begin rintros 𝒮 S hS Y f h q ⟨⟨T, hT⟩, rfl⟩, apply hS _ hT _ _ h end,\n  le_sup_left  := λ _ _ _ _, or.inl,\n  le_sup_right := λ _ _ _ _, or.inr,\n  sup_le       := begin rintros _ _ _ a b _ _ (q | q), apply a _ _ q, apply b _ _ q end,\n  inf_le_left  := λ _ _ _ _, and.left,\n  inf_le_right := λ _ _ _ _, and.right,\n  le_inf       := begin intros _ _ _ p q _ _ z, exact ⟨p _ _ z, q _ _ z⟩,  end,\n  le_top       := λ _ _ _ _, trivial,\n  bot_le       := by { rintros _ _ _ ⟨⟩ } }\n\n@[simp]\nlemma mem_inter {R S : sieve X} {Y} (f : Y ⟶ X) :\n  over.mk f ∈ (R ⊓ S).arrows ↔ over.mk f ∈ R.arrows ∧ over.mk f ∈ S.arrows :=\niff.rfl\n\n@[simp]\nlemma mem_union {R S : sieve X} {Y} (f : Y ⟶ X) :\n  over.mk f ∈ (R ⊔ S).arrows ↔ over.mk f ∈ R.arrows ∨ over.mk f ∈ S.arrows :=\niff.rfl\n\n@[simp]\nlemma mem_top (f : Y ⟶ X) : over.mk f ∈ (⊤ : sieve X).arrows := trivial\n\ninstance : preorder      (sieve X) := by apply_instance\ninstance : partial_order (sieve X) := by apply_instance\n\ninductive generate_sets (𝒢 : set (over X)) : over X → Prop\n| basic : Π {f : over X}, f ∈ 𝒢 → generate_sets f\n| subs  : Π {Y Z} {f : Y ⟶ X} (g : Z ⟶ Y), generate_sets (over.mk f) → generate_sets (over.mk (g ≫ f))\n\n/-- Generate the smallest sieve containing the given set of arrows. -/\ndef generate (𝒢 : set (over X)) : sieve X :=\n{ arrows := generate_sets 𝒢,\n  subs   := λ Y Z f g t, generate_sets.subs _ t }\n\nopen order lattice\n\nlemma sets_iff_generate {𝒢 : set (over X)} : generate 𝒢 ≤ S ↔ 𝒢 ⊆ S.arrows :=\niff.intro\n  (λ H g hg,\n    begin\n      have : over.mk g.hom = g,\n        cases g, dsimp [over.mk],\n        congr' 1, apply subsingleton.elim,\n      rw ← this at *,\n      apply H,\n      apply generate_sets.basic hg,\n    end )\n  (λ ss Y f hf, begin induction hf with hf_f hf_a hf_Y hf_Z hf_f hf_g hf_a hf_ih, apply ss hf_a, apply downward_closed, apply hf_ih end)\n\n/-- Show that there is a galois insertion (generate, .arrows). -/\ndef gi_generate :\n  @galois_insertion (set (over X)) (sieve X) (by apply_instance) _ generate sieve.arrows :=\n  { gc        := λ s f, sets_iff_generate,\n    choice    := λ 𝒢 f, generate 𝒢,\n    choice_eq := λ 𝒢 h, rfl,\n    le_l_u    := λ _ _ _, generate_sets.basic }\n\n/-- Given a morphism `h : Y ⟶ X`, send a sieve S on X to a sieve on Y\n    as the inverse image of S with `_ ≫ h`.\n    That is, `sieve.pullback S h := (≫ h) '⁻¹ S`. -/\ndef pullback (S : sieve X) (h : Y ⟶ X) : sieve Y :=\n{ arrows := {sl | over.mk (sl.hom ≫ h) ∈ S.arrows },\n  subs := λ f hf Z g k, by { dsimp at k, simp [k] } }\n\n@[simp] lemma mem_pullback (h : Y ⟶ X) {f : Z ⟶ Y} :\n  over.mk f ∈ (pullback S h).arrows ↔ over.mk (f ≫ h) ∈ S.arrows := iff.rfl\n\n/--\nPush a sieve `R` on `Y` forward along an arrow `f : Y ⟶ X`: `gf : Z ⟶ X`\nis in the sieve if `gf` factors through some `g : Z ⟶ Y` which is in `R`.\n-/\ndef comp (R : sieve Y) (f : Y ⟶ X) : sieve X :=\n{ arrows := λ gf, ∃ (g : gf.left ⟶ Y), over.mk g ∈ R.arrows ∧ g ≫ f = gf.hom,\n  subs :=\n  begin\n    rintros Z₁ Z₂ g h ⟨j, k, z⟩,\n    refine ⟨h ≫ j, _, _⟩,\n    simp [k],\n    simp [z],\n  end }\n\n-- def comps (R : Π (f : over X), sieve f.left) (S : sieve X) : sieve X :=\n--   ⨆ (f ∈ S.arrows), comp (R f) f.hom\n\n/-- Pullback is monotonic -/\nlemma pullback_le_map {S R : sieve X} (Hss : S ≤ R) (f : Y ⟶ X) : pullback S f ≤ pullback R f :=\nbegin rintros Z H, apply Hss end\n\nlemma pullback_top {f : Y ⟶ X} : pullback ⊤ f = ⊤ :=\ntop_unique (λ _ g, id)\n\nlemma pullback_comp {f : Y ⟶ X} {g : Z ⟶ Y} (S : sieve X) : S.pullback (g ≫ f) = (S.pullback f).pullback g :=\nbegin\n  ext W h,\n  simp,\nend\nlemma pullback_inter {f : Y ⟶ X} (S R : sieve X) : (S ⊓ R).pullback f = S.pullback f ⊓ R.pullback f :=\nbegin\n  ext Z g,\n  simp,\nend\n\nlemma le_pullback_comp {R : sieve Y} {f : Y ⟶ X} :\n  R ≤ pullback (comp R f) f :=\nbegin rintros Z g b, refine ⟨_, _, rfl⟩, simpa end\n\n/-- If the identity arrow is in a sieve, the sieve is maximal. -/\nlemma id_mem_iff_eq_top : over.mk (𝟙 X) ∈ S.arrows ↔ S = ⊤ :=\n⟨begin\n  intro h,\n  rw eq_top_iff,\n  rintros Y f ⟨⟩,\n  suffices : over.mk (f ≫ (𝟙 _)) ∈ S.arrows,\n    simpa using this,\n  apply downward_closed _ h,\nend,\nby { rintro rfl, trivial } ⟩\n\nlemma pullback_eq_top_iff_mem (f : Y ⟶ X) : over.mk f ∈ S.arrows ↔ S.pullback f = ⊤ :=\nby rw [← id_mem_iff_eq_top, mem_pullback, category.id_comp]\n-- lemma comp_le_comps\n--   (R : Π (f : over X), sieve f.1)\n--   (S : sieve X)\n--   (f : over X)\n--   (H : f ∈ S.arrows) :\n--   comp (R f) f.hom ≤ comps R S  :=\n-- calc comp (R f) f.hom ≤  ⨆ (_ : f ∈ S.arrows), comp (R f) f.hom : le_supr _ H\n--                   ... ≤  comps R S                       : le_supr _ f\n\n-- lemma comps_le\n--   (R : Π (f : over X), sieve f.left)\n--   (S : sieve X) :\n--   comps R S ≤ S :=\n-- begin\n--   apply supr_le _,\n--   rintros f,\n--   apply supr_le _,\n--   rintros H Y g,\n\n--   rintros ⟨a,b,e⟩,\n\n--   -- suffices : over.mk (g.hom) ∈ S.arrows, simp at this, apply this,\n--   -- rw ← e,\n--   -- apply downward_closed,\n--   -- apply H,\n-- end\n\n/-- A sieve induces a presheaf. -/\n@[simps]\ndef as_functor (S : sieve X) : Cᵒᵖ ⥤ Type v :=\n{ obj := λ Y, {g : Y.unop ⟶ X // over.mk g ∈ S.arrows},\n  map := λ Y Z f g, ⟨f.unop ≫ g.1, downward_closed _ g.2 _⟩ }\n\n@[simps]\ndef le_as_functor {S T : sieve X} (h : S ≤ T) : S.as_functor ⟶ T.as_functor :=\n{ app := λ Y f, ⟨f.1, h _ _ f.2⟩ }.\n\n/-- The natural inclusion from the functor induced by a sieve to the yoneda embedding. -/\n@[simps]\ndef functor_inclusion (S : sieve X) : S.as_functor ⟶ yoneda.obj X :=\n{ app := λ Y f, f.1 }.\n\nlemma le_as_functor_comm {S T : sieve X} (h : S ≤ T) :\n  le_as_functor h ≫ functor_inclusion _ = functor_inclusion _ :=\nbegin\n  ext c t,\n  refl,\nend\n\n/-- The presheaf induced by a sieve is a subobject of the yoneda embedding. -/\ninstance functor_inclusion_is_mono : mono (functor_inclusion S) :=\n⟨λ Z f g h, begin\n  ext Y y,\n  have : (f ≫ functor_inclusion S).app Y y = (g ≫ functor_inclusion S).app Y y,\n    rw h,\n  exact this\nend⟩\n\nend sieve\nend category_theory\n", "meta": {"author": "b-mehta", "repo": "topos", "sha": "c9032b11789e36038bc841a1e2b486972421b983", "save_path": "github-repos/lean/b-mehta-topos", "path": "github-repos/lean/b-mehta-topos/topos-c9032b11789e36038bc841a1e2b486972421b983/src/sieve.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251201477016, "lm_q2_score": 0.7057850216484837, "lm_q1q2_score": 0.4546844403699426}}
{"text": "/-\nCopyright (c) 2019 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Jeremy Avigad\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.list\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l \n\nnamespace Mathlib\n\n/-!\n# W types\n\nGiven `α : Type` and `β : α → Type`, the W type determined by this data, `W_type β`, is the\ninductively defined type of trees where the nodes are labeled by elements of `α` and the children of\na node labeled `a` are indexed by elements of `β a`.\n\nThis file is currently a stub, awaiting a full development of the theory. Currently, the main result\nis that if `α` is an encodable fintype and `β a` is encodable for every `a : α`, then `W_type β` is\nencodable. This can be used to show the encodability of other inductive types, such as those that\nare commonly used to formalize syntax, e.g. terms and expressions in a given language. The strategy\nis illustrated in the example found in the file `prop_encodable` in the `archive/examples` folder of\nmathlib.\n\n## Implementation details\n\nWhile the name `W_type` is somewhat verbose, it is preferable to putting a single character\nidentifier `W` in the root namespace.\n-/\n\n/--\nGiven `β : α → Type*`, `W_type β` is the type of finitely branching trees where nodes are labeled by\nelements of `α` and the children of a node labeled `a` are indexed by elements of `β a`.\n-/\ninductive W_type {α : Type u_1} (β : α → Type u_2) \nwhere\n| mk : (a : α) → (β a → W_type β) → W_type β\n\nprotected instance W_type.inhabited : Inhabited (W_type fun (_x : Unit) => empty) :=\n  { default := W_type.mk Unit.unit empty.elim }\n\nnamespace W_type\n\n\n/-- The depth of a finitely branching tree. -/\ndef depth {α : Type u_1} {β : α → Type u_2} [(a : α) → fintype (β a)] : W_type β → ℕ :=\n  sorry\n\ntheorem depth_pos {α : Type u_1} {β : α → Type u_2} [(a : α) → fintype (β a)] (t : W_type β) : 0 < depth t :=\n  W_type.cases_on t\n    fun (t_a : α) (t_f : β t_a → W_type β) => nat.succ_pos (finset.sup finset.univ fun (n : β t_a) => depth (t_f n))\n\ntheorem depth_lt_depth_mk {α : Type u_1} {β : α → Type u_2} [(a : α) → fintype (β a)] (a : α) (f : β a → W_type β) (i : β a) : depth (f i) < depth (mk a f) :=\n  nat.lt_succ_of_le (finset.le_sup (finset.mem_univ i))\n\nend W_type\n\n\n/-\nShow that W types are encodable when `α` is an encodable fintype and for every `a : α`, `β a` is\nencodable.\n\nWe define an auxiliary type `W_type' β n` of trees of depth at most `n`, and then we show by\ninduction on `n` that these are all encodable. These auxiliary constructions are not interesting in\nand of themselves, so we mark them as `private`.\n-/\n\nnamespace encodable\n\n\n/-- `W_type` is encodable when `α` is an encodable fintype and for every `a : α`, `β a` is\nencodable. -/\nprotected instance W_type.encodable {α : Type u_1} {β : α → Type u_2} [(a : α) → fintype (β a)] [(a : α) → encodable (β a)] [encodable α] : encodable (W_type β) :=\n  let f : W_type β → sigma fun (n : ℕ) => W_type' β n :=\n    fun (t : W_type β) => sigma.mk (W_type.depth t) { val := t, property := sorry };\n  let finv : (sigma fun (n : ℕ) => W_type' β n) → W_type β :=\n    fun (p : sigma fun (n : ℕ) => W_type' β n) => subtype.val (sigma.snd p);\n  of_left_inverse f finv sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/W.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.45468442674117443}}
{"text": "example (p q : Prop) : p ∧ q → q ∧ p :=\nbegin\n  intro h,\n  cases h with hp hq,\n  constructor, exact hq, exact hp\nend\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch5/ex0302.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.4546844267411743}}
{"text": "/-\nCopyright (c) 2021 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser, Frédéric Dupuis\n\n! This file was ported from Lean 3 source module algebra.star.module\n! leanprover-community/mathlib commit 30413fc89f202a090a54d78e540963ed3de0056e\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Star.SelfAdjoint\nimport Mathbin.Algebra.Module.Equiv\nimport Mathbin.LinearAlgebra.Prod\n\n/-!\n# The star operation, bundled as a star-linear equiv\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define `star_linear_equiv`, which is the star operation bundled as a star-linear map.\nIt is defined on a star algebra `A` over the base ring `R`.\n\nThis file also provides some lemmas that need `algebra.module.basic` imported to prove.\n\n## TODO\n\n- Define `star_linear_equiv` for noncommutative `R`. We only the commutative case for now since,\n  in the noncommutative case, the ring hom needs to reverse the order of multiplication. This\n  requires a ring hom of type `R →+* Rᵐᵒᵖ`, which is very undesirable in the commutative case.\n  One way out would be to define a new typeclass `is_op R S` and have an instance `is_op R R`\n  for commutative `R`.\n- Also note that such a definition involving `Rᵐᵒᵖ` or `is_op R S` would require adding\n  the appropriate `ring_hom_inv_pair` instances to be able to define the semilinear\n  equivalence.\n-/\n\n\nsection SmulLemmas\n\nvariable {R M : Type _}\n\n/- warning: star_nat_cast_smul -> star_nat_cast_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M _inst_1 _inst_2] [_inst_4 : StarAddMonoid.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)] (n : Nat) (x : M), Eq.{succ u2} M (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2) _inst_4)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Module.toMulActionWithZero.{u1, u2} R M _inst_1 _inst_2 _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))))) n) x)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Module.toMulActionWithZero.{u1, u2} R M _inst_1 _inst_2 _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))))) n) (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2) _inst_4)) x))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Semiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : Module.{u2, u1} R M _inst_1 _inst_2] [_inst_4 : StarAddMonoid.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)] (n : Nat) (x : M), Eq.{succ u1} M (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2) _inst_4)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R _inst_1) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (Module.toMulActionWithZero.{u2, u1} R M _inst_1 _inst_2 _inst_3))))) (Nat.cast.{u2} R (Semiring.toNatCast.{u2} R _inst_1) n) x)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R _inst_1) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (Module.toMulActionWithZero.{u2, u1} R M _inst_1 _inst_2 _inst_3))))) (Nat.cast.{u2} R (Semiring.toNatCast.{u2} R _inst_1) n) (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2) _inst_4)) x))\nCase conversion may be inaccurate. Consider using '#align star_nat_cast_smul star_nat_cast_smulₓ'. -/\n@[simp]\ntheorem star_nat_cast_smul [Semiring R] [AddCommMonoid M] [Module R M] [StarAddMonoid M] (n : ℕ)\n    (x : M) : star ((n : R) • x) = (n : R) • star x :=\n  map_nat_cast_smul (starAddEquiv : M ≃+ M) R R n x\n#align star_nat_cast_smul star_nat_cast_smul\n\n/- warning: star_int_cast_smul -> star_int_cast_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : Ring.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_4 : StarAddMonoid.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2)))] (n : Int) (x : M), Eq.{succ u2} M (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2))) _inst_4)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))) n) x)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R _inst_1) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R _inst_1)))))) n) (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2))) _inst_4)) x))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : Ring.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_4 : StarAddMonoid.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2)))] (n : Int) (x : M), Eq.{succ u1} M (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2))) _inst_4)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))))) (Int.cast.{u2} R (Ring.toIntCast.{u2} R _inst_1) n) x)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (Ring.toSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (Ring.toSemiring.{u2} R _inst_1)) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} R M (Ring.toSemiring.{u2} R _inst_1) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))))) (Int.cast.{u2} R (Ring.toIntCast.{u2} R _inst_1) n) (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2))) _inst_4)) x))\nCase conversion may be inaccurate. Consider using '#align star_int_cast_smul star_int_cast_smulₓ'. -/\n@[simp]\ntheorem star_int_cast_smul [Ring R] [AddCommGroup M] [Module R M] [StarAddMonoid M] (n : ℤ)\n    (x : M) : star ((n : R) • x) = (n : R) • star x :=\n  map_int_cast_smul (starAddEquiv : M ≃+ M) R R n x\n#align star_int_cast_smul star_int_cast_smul\n\n/- warning: star_inv_nat_cast_smul -> star_inv_nat_cast_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : DivisionSemiring.{u1} R] [_inst_2 : AddCommMonoid.{u2} M] [_inst_3 : Module.{u1, u2} R M (DivisionSemiring.toSemiring.{u1} R _inst_1) _inst_2] [_inst_4 : StarAddMonoid.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)] (n : Nat) (x : M), Eq.{succ u2} M (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2) _inst_4)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (DivisionSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (DivisionSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Module.toMulActionWithZero.{u1, u2} R M (DivisionSemiring.toSemiring.{u1} R _inst_1) _inst_2 _inst_3)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (GroupWithZero.toDivInvMonoid.{u1} R (DivisionSemiring.toGroupWithZero.{u1} R _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R _inst_1)))))))) n)) x)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (DivisionSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (DivisionSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Module.toMulActionWithZero.{u1, u2} R M (DivisionSemiring.toSemiring.{u1} R _inst_1) _inst_2 _inst_3)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (GroupWithZero.toDivInvMonoid.{u1} R (DivisionSemiring.toGroupWithZero.{u1} R _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat R (HasLiftT.mk.{1, succ u1} Nat R (CoeTCₓ.coe.{1, succ u1} Nat R (Nat.castCoe.{u1} R (AddMonoidWithOne.toNatCast.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R (DivisionSemiring.toSemiring.{u1} R _inst_1)))))))) n)) (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2) _inst_4)) x))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : DivisionSemiring.{u2} R] [_inst_2 : AddCommMonoid.{u1} M] [_inst_3 : Module.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R _inst_1) _inst_2] [_inst_4 : StarAddMonoid.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)] (n : Nat) (x : M), Eq.{succ u1} M (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2) _inst_4)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (Module.toMulActionWithZero.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R _inst_1) _inst_2 _inst_3))))) (Inv.inv.{u2} R (DivisionSemiring.toInv.{u2} R _inst_1) (Nat.cast.{u2} R (Semiring.toNatCast.{u2} R (DivisionSemiring.toSemiring.{u2} R _inst_1)) n)) x)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R _inst_1))) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2)) (Module.toMulActionWithZero.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R _inst_1) _inst_2 _inst_3))))) (Inv.inv.{u2} R (DivisionSemiring.toInv.{u2} R _inst_1) (Nat.cast.{u2} R (Semiring.toNatCast.{u2} R (DivisionSemiring.toSemiring.{u2} R _inst_1)) n)) (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (AddCommMonoid.toAddMonoid.{u1} M _inst_2) _inst_4)) x))\nCase conversion may be inaccurate. Consider using '#align star_inv_nat_cast_smul star_inv_nat_cast_smulₓ'. -/\n@[simp]\ntheorem star_inv_nat_cast_smul [DivisionSemiring R] [AddCommMonoid M] [Module R M] [StarAddMonoid M]\n    (n : ℕ) (x : M) : star ((n⁻¹ : R) • x) = (n⁻¹ : R) • star x :=\n  map_inv_nat_cast_smul (starAddEquiv : M ≃+ M) R R n x\n#align star_inv_nat_cast_smul star_inv_nat_cast_smul\n\n/- warning: star_inv_int_cast_smul -> star_inv_int_cast_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : DivisionRing.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_4 : StarAddMonoid.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2)))] (n : Int) (x : M), Eq.{succ u2} M (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2))) _inst_4)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))))) n)) x)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))) (Inv.inv.{u1} R (DivInvMonoid.toHasInv.{u1} R (DivisionRing.toDivInvMonoid.{u1} R _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int R (HasLiftT.mk.{1, succ u1} Int R (CoeTCₓ.coe.{1, succ u1} Int R (Int.castCoe.{u1} R (AddGroupWithOne.toHasIntCast.{u1} R (AddCommGroupWithOne.toAddGroupWithOne.{u1} R (Ring.toAddCommGroupWithOne.{u1} R (DivisionRing.toRing.{u1} R _inst_1))))))) n)) (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2))) _inst_4)) x))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : DivisionRing.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_4 : StarAddMonoid.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2)))] (n : Int) (x : M), Eq.{succ u1} M (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2))) _inst_4)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))))) (Inv.inv.{u2} R (DivisionRing.toInv.{u2} R _inst_1) (Int.cast.{u2} R (Ring.toIntCast.{u2} R (DivisionRing.toRing.{u2} R _inst_1)) n)) x)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))))) (Inv.inv.{u2} R (DivisionRing.toInv.{u2} R _inst_1) (Int.cast.{u2} R (Ring.toIntCast.{u2} R (DivisionRing.toRing.{u2} R _inst_1)) n)) (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2))) _inst_4)) x))\nCase conversion may be inaccurate. Consider using '#align star_inv_int_cast_smul star_inv_int_cast_smulₓ'. -/\n@[simp]\ntheorem star_inv_int_cast_smul [DivisionRing R] [AddCommGroup M] [Module R M] [StarAddMonoid M]\n    (n : ℤ) (x : M) : star ((n⁻¹ : R) • x) = (n⁻¹ : R) • star x :=\n  map_inv_int_cast_smul (starAddEquiv : M ≃+ M) R R n x\n#align star_inv_int_cast_smul star_inv_int_cast_smul\n\n/- warning: star_rat_cast_smul -> star_rat_cast_smul is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {M : Type.{u2}} [_inst_1 : DivisionRing.{u1} R] [_inst_2 : AddCommGroup.{u2} M] [_inst_3 : Module.{u1, u2} R M (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)] [_inst_4 : StarAddMonoid.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2)))] (n : Rat) (x : M), Eq.{succ u2} M (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2))) _inst_4)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat R (HasLiftT.mk.{1, succ u1} Rat R (CoeTCₓ.coe.{1, succ u1} Rat R (Rat.castCoe.{u1} R (DivisionRing.toHasRatCast.{u1} R _inst_1)))) n) x)) (SMul.smul.{u1, u2} R M (SMulZeroClass.toHasSmul.{u1, u2} R M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R M (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)))))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R M (Semiring.toMonoidWithZero.{u1} R (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1))) (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M (AddCommGroup.toAddCommMonoid.{u2} M _inst_2)))) (Module.toMulActionWithZero.{u1, u2} R M (Ring.toSemiring.{u1} R (DivisionRing.toRing.{u1} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u2} M _inst_2) _inst_3)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat R (HasLiftT.mk.{1, succ u1} Rat R (CoeTCₓ.coe.{1, succ u1} Rat R (Rat.castCoe.{u1} R (DivisionRing.toHasRatCast.{u1} R _inst_1)))) n) (Star.star.{u2} M (InvolutiveStar.toHasStar.{u2} M (StarAddMonoid.toHasInvolutiveStar.{u2} M (SubNegMonoid.toAddMonoid.{u2} M (AddGroup.toSubNegMonoid.{u2} M (AddCommGroup.toAddGroup.{u2} M _inst_2))) _inst_4)) x))\nbut is expected to have type\n  forall {R : Type.{u2}} {M : Type.{u1}} [_inst_1 : DivisionRing.{u2} R] [_inst_2 : AddCommGroup.{u1} M] [_inst_3 : Module.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2)] [_inst_4 : StarAddMonoid.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2)))] (n : Rat) (x : M), Eq.{succ u1} M (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2))) _inst_4)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))))) (Rat.cast.{u2} R (DivisionRing.toRatCast.{u2} R _inst_1) n) x)) (HSMul.hSMul.{u2, u1, u1} R M M (instHSMul.{u2, u1} R M (SMulZeroClass.toSMul.{u2, u1} R M (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (SMulWithZero.toSMulZeroClass.{u2, u1} R M (MonoidWithZero.toZero.{u2} R (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (MulActionWithZero.toSMulWithZero.{u2, u1} R M (Semiring.toMonoidWithZero.{u2} R (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1))) (NegZeroClass.toZero.{u1} M (SubNegZeroMonoid.toNegZeroClass.{u1} M (SubtractionMonoid.toSubNegZeroMonoid.{u1} M (SubtractionCommMonoid.toSubtractionMonoid.{u1} M (AddCommGroup.toDivisionAddCommMonoid.{u1} M _inst_2))))) (Module.toMulActionWithZero.{u2, u1} R M (DivisionSemiring.toSemiring.{u2} R (DivisionRing.toDivisionSemiring.{u2} R _inst_1)) (AddCommGroup.toAddCommMonoid.{u1} M _inst_2) _inst_3))))) (Rat.cast.{u2} R (DivisionRing.toRatCast.{u2} R _inst_1) n) (Star.star.{u1} M (InvolutiveStar.toStar.{u1} M (StarAddMonoid.toInvolutiveStar.{u1} M (SubNegMonoid.toAddMonoid.{u1} M (AddGroup.toSubNegMonoid.{u1} M (AddCommGroup.toAddGroup.{u1} M _inst_2))) _inst_4)) x))\nCase conversion may be inaccurate. Consider using '#align star_rat_cast_smul star_rat_cast_smulₓ'. -/\n@[simp]\ntheorem star_rat_cast_smul [DivisionRing R] [AddCommGroup M] [Module R M] [StarAddMonoid M] (n : ℚ)\n    (x : M) : star ((n : R) • x) = (n : R) • star x :=\n  map_rat_cast_smul (starAddEquiv : M ≃+ M) _ _ _ x\n#align star_rat_cast_smul star_rat_cast_smul\n\n#print star_rat_smul /-\n@[simp]\ntheorem star_rat_smul {R : Type _} [AddCommGroup R] [StarAddMonoid R] [Module ℚ R] (x : R) (n : ℚ) :\n    star (n • x) = n • star x :=\n  map_rat_smul (starAddEquiv : R ≃+ R) _ _\n#align star_rat_smul star_rat_smul\n-/\n\nend SmulLemmas\n\n#print starLinearEquiv /-\n/-- If `A` is a module over a commutative `R` with compatible actions,\nthen `star` is a semilinear equivalence. -/\n@[simps]\ndef starLinearEquiv (R : Type _) {A : Type _} [CommRing R] [StarRing R] [Semiring A] [StarRing A]\n    [Module R A] [StarModule R A] : A ≃ₗ⋆[R] A :=\n  { starAddEquiv with\n    toFun := star\n    map_smul' := star_smul }\n#align star_linear_equiv starLinearEquiv\n-/\n\nvariable (R : Type _) (A : Type _) [Semiring R] [StarSemigroup R] [TrivialStar R] [AddCommGroup A]\n  [Module R A] [StarAddMonoid A] [StarModule R A]\n\n#print selfAdjoint.submodule /-\n/-- The self-adjoint elements of a star module, as a submodule. -/\ndef selfAdjoint.submodule : Submodule R A :=\n  { selfAdjoint A with smul_mem' := fun r x => (IsSelfAdjoint.all _).smul }\n#align self_adjoint.submodule selfAdjoint.submodule\n-/\n\n#print skewAdjoint.submodule /-\n/-- The skew-adjoint elements of a star module, as a submodule. -/\ndef skewAdjoint.submodule : Submodule R A :=\n  { skewAdjoint A with smul_mem' := skewAdjoint.smul_mem }\n#align skew_adjoint.submodule skewAdjoint.submodule\n-/\n\nvariable {A} [Invertible (2 : R)]\n\n/- warning: self_adjoint_part -> selfAdjointPart is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {A : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toHasStar.{u2} A (StarAddMonoid.toHasInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))))))], LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_5 (selfAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)\nbut is expected to have type\n  forall (R : Type.{u1}) {A : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toStar.{u2} A (StarAddMonoid.toInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toSMul.{u1, u2} R A (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (SMulWithZero.toSMulZeroClass.{u1, u2} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toOne.{u1} R _inst_1) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (Semiring.toNatCast.{u1} R _inst_1) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))], LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_5 (selfAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSelfAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)\nCase conversion may be inaccurate. Consider using '#align self_adjoint_part selfAdjointPartₓ'. -/\n/-- The self-adjoint part of an element of a star module, as a linear map. -/\n@[simps]\ndef selfAdjointPart : A →ₗ[R] selfAdjoint A\n    where\n  toFun x :=\n    ⟨(⅟ 2 : R) • (x + star x), by\n      simp only [selfAdjoint.mem_iff, star_smul, add_comm, StarAddMonoid.star_add, star_inv',\n        star_bit0, star_one, star_star, star_invOf (2 : R), star_trivial]⟩\n  map_add' x y := by\n    ext\n    simp [add_add_add_comm]\n  map_smul' r x := by\n    ext\n    simp [← mul_smul, show ⅟ 2 * r = r * ⅟ 2 from Commute.invOf_left (Commute.one_left r).bit0_left]\n#align self_adjoint_part selfAdjointPart\n\n/- warning: skew_adjoint_part -> skewAdjointPart is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {A : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toHasStar.{u2} A (StarAddMonoid.toHasInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))))))], LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_5 (skewAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)\nbut is expected to have type\n  forall (R : Type.{u1}) {A : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toStar.{u2} A (StarAddMonoid.toInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toSMul.{u1, u2} R A (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (SMulWithZero.toSMulZeroClass.{u1, u2} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toOne.{u1} R _inst_1) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (Semiring.toNatCast.{u1} R _inst_1) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))], LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6))) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_5 (skewAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSkewAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)\nCase conversion may be inaccurate. Consider using '#align skew_adjoint_part skewAdjointPartₓ'. -/\n/-- The skew-adjoint part of an element of a star module, as a linear map. -/\n@[simps]\ndef skewAdjointPart : A →ₗ[R] skewAdjoint A\n    where\n  toFun x :=\n    ⟨(⅟ 2 : R) • (x - star x), by\n      simp only [skewAdjoint.mem_iff, star_smul, star_sub, star_star, star_trivial, ← smul_neg,\n        neg_sub]⟩\n  map_add' x y := by\n    ext\n    simp only [sub_add, ← smul_add, sub_sub_eq_add_sub, star_add, AddSubgroup.coe_mk,\n      AddSubgroup.coe_add]\n  map_smul' r x := by\n    ext\n    simp [← mul_smul, ← smul_sub,\n      show r * ⅟ 2 = ⅟ 2 * r from Commute.invOf_right (Commute.one_right r).bit0_right]\n#align skew_adjoint_part skewAdjointPart\n\n/- warning: star_module.self_adjoint_part_add_skew_adjoint_part -> StarModule.selfAdjointPart_add_skewAdjointPart is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) {A : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toHasStar.{u2} A (StarAddMonoid.toHasInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))))))] (x : A), Eq.{succ u2} A (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toHasAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))))) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) A (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) A (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) A (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) A (coeSubtype.{succ u2} A (fun (x : A) => Membership.Mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.hasMem.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)))))) (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_5 (selfAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_5 (selfAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)) => A -> (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) _inst_1 _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_5 (selfAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (selfAdjointPart.{u1, u2} R A _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8) x)) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) A (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) A (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) A (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) A (coeSubtype.{succ u2} A (fun (x : A) => Membership.Mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.hasMem.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6)))))) (coeFn.{succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_5 (skewAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)) (fun (_x : LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_5 (skewAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)) => A -> (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6))) (LinearMap.hasCoeToFun.{u1, u1, u2, u2} R R A (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) _inst_1 _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_5 (skewAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (skewAdjointPart.{u1, u2} R A _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8) x))) x\nbut is expected to have type\n  forall (R : Type.{u1}) {A : Type.{u2}} [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toStar.{u2} A (StarAddMonoid.toInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toSMul.{u1, u2} R A (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (SMulWithZero.toSMulZeroClass.{u1, u2} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toOne.{u1} R _inst_1) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (Semiring.toNatCast.{u1} R _inst_1) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))] (x : A), Eq.{succ u2} A (HAdd.hAdd.{u2, u2, u2} A A A (instHAdd.{u2} A (AddZeroClass.toAdd.{u2} A (AddMonoid.toAddZeroClass.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))))) (Subtype.val.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Set.{u2} A) (Set.instMembershipSet.{u2} A) x (SetLike.coe.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (FunLike.coe.{succ u2, succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_5 (selfAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSelfAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R A (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_1 _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) _inst_5 (selfAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSelfAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (selfAdjointPart.{u1, u2} R A _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8) x)) (Subtype.val.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (Set.{u2} A) (Set.instMembershipSet.{u2} A) x (SetLike.coe.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (skewAdjoint.{u2} A _inst_4 _inst_6))) (FunLike.coe.{succ u2, succ u2, succ u2} (LinearMap.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) A (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6))) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_5 (skewAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSkewAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : A) => Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6))) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u2} R R A (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_1 _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_5 (skewAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSkewAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (skewAdjointPart.{u1, u2} R A _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8) x))) x\nCase conversion may be inaccurate. Consider using '#align star_module.self_adjoint_part_add_skew_adjoint_part StarModule.selfAdjointPart_add_skewAdjointPartₓ'. -/\ntheorem StarModule.selfAdjointPart_add_skewAdjointPart (x : A) :\n    (selfAdjointPart R x : A) + skewAdjointPart R x = x := by\n  simp only [smul_sub, selfAdjointPart_apply_coe, smul_add, skewAdjointPart_apply_coe,\n    add_add_sub_cancel, inv_of_two_smul_add_inv_of_two_smul]\n#align star_module.self_adjoint_part_add_skew_adjoint_part StarModule.selfAdjointPart_add_skewAdjointPart\n\nvariable (A)\n\n/- warning: star_module.decompose_prod_adjoint -> StarModule.decomposeProdAdjoint is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) (A : Type.{u2}) [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toHasStar.{u2} A (StarAddMonoid.toHasInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (Distrib.toHasMul.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (OfNat.ofNat.{u1} R 2 (OfNat.mk.{u1} R 2 (bit0.{u1} R (Distrib.toHasAdd.{u1} R (NonUnitalNonAssocSemiring.toDistrib.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)))) (One.one.{u1} R (AddMonoidWithOne.toOne.{u1} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} R (NonAssocSemiring.toAddCommMonoidWithOne.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))))))))], LinearEquiv.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) A (Prod.{u2, u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6))) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (Prod.addCommMonoid.{u2, u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (skewAdjoint.{u2} A _inst_4 _inst_6)))) _inst_5 (Prod.module.{u1, u2, u2} R (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) _inst_1 (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.setLike.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) (skewAdjoint.{u2} A _inst_4 _inst_6)) (AddSubgroup.toAddCommGroup.{u2} A _inst_4 (skewAdjoint.{u2} A _inst_4 _inst_6))) (selfAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7) (skewAdjoint.module.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarSemigroup.toHasInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7))\nbut is expected to have type\n  forall (R : Type.{u1}) (A : Type.{u2}) [_inst_1 : Semiring.{u1} R] [_inst_2 : StarSemigroup.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1)))] [_inst_3 : TrivialStar.{u1} R (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2))] [_inst_4 : AddCommGroup.{u2} A] [_inst_5 : Module.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4)] [_inst_6 : StarAddMonoid.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)))] [_inst_7 : StarModule.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) (InvolutiveStar.toStar.{u2} A (StarAddMonoid.toInvolutiveStar.{u2} A (SubNegMonoid.toAddMonoid.{u2} A (AddGroup.toSubNegMonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) _inst_6)) (SMulZeroClass.toSMul.{u1, u2} R A (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (SMulWithZero.toSMulZeroClass.{u1, u2} R A (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R _inst_1) (NegZeroClass.toZero.{u2} A (SubNegZeroMonoid.toNegZeroClass.{u2} A (SubtractionMonoid.toSubNegZeroMonoid.{u2} A (SubtractionCommMonoid.toSubtractionMonoid.{u2} A (AddCommGroup.toDivisionAddCommMonoid.{u2} A _inst_4))))) (Module.toMulActionWithZero.{u1, u2} R A _inst_1 (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) _inst_5))))] [_inst_8 : Invertible.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (Semiring.toOne.{u1} R _inst_1) (OfNat.ofNat.{u1} R 2 (instOfNat.{u1} R 2 (Semiring.toNatCast.{u1} R _inst_1) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))], LinearEquiv.{u1, u1, u2, u2} R R _inst_1 _inst_1 (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (RingHomInvPair.ids.{u1} R _inst_1) (RingHomInvPair.ids.{u1} R _inst_1) A (Prod.{u2, u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6)))) (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (Prod.instAddCommMonoidSum.{u2, u2} (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6))) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (skewAdjoint.{u2} A _inst_4 _inst_6)))) _inst_5 (Prod.module.{u1, u2, u2} R (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (Subtype.{succ u2} A (fun (x : A) => Membership.mem.{u2, u2} A (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) (SetLike.instMembership.{u2, u2} (AddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4)) A (AddSubgroup.instSetLikeAddSubgroup.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4))) x (skewAdjoint.{u2} A _inst_4 _inst_6))) _inst_1 (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (selfAdjoint.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) _inst_6))) (AddSubmonoid.toAddCommMonoid.{u2} A (AddCommGroup.toAddCommMonoid.{u2} A _inst_4) (AddSubgroup.toAddSubmonoid.{u2} A (AddCommGroup.toAddGroup.{u2} A _inst_4) (skewAdjoint.{u2} A _inst_4 _inst_6))) (selfAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSelfAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7) (skewAdjoint.instModuleSubtypeMemAddSubgroupToAddGroupInstMembershipInstSetLikeAddSubgroupSkewAdjointToAddCommMonoidToAddCommMonoidToAddSubmonoid.{u1, u2} R A (InvolutiveStar.toStar.{u1} R (StarSemigroup.toInvolutiveStar.{u1} R (SemigroupWithZero.toSemigroup.{u1} R (NonUnitalSemiring.toSemigroupWithZero.{u1} R (Semiring.toNonUnitalSemiring.{u1} R _inst_1))) _inst_2)) _inst_3 _inst_4 _inst_6 _inst_1 _inst_5 _inst_7))\nCase conversion may be inaccurate. Consider using '#align star_module.decompose_prod_adjoint StarModule.decomposeProdAdjointₓ'. -/\n/-- The decomposition of elements of a star module into their self- and skew-adjoint parts,\nas a linear equivalence. -/\n@[simps]\ndef StarModule.decomposeProdAdjoint : A ≃ₗ[R] selfAdjoint A × skewAdjoint A :=\n  LinearEquiv.ofLinear ((selfAdjointPart R).Prod (skewAdjointPart R))\n    ((selfAdjoint.submodule R A).Subtype.coprod (skewAdjoint.submodule R A).Subtype)\n    (by ext <;> simp) (LinearMap.ext <| StarModule.selfAdjointPart_add_skewAdjointPart R)\n#align star_module.decompose_prod_adjoint StarModule.decomposeProdAdjoint\n\n/- warning: algebra_map_star_comm -> algebraMap_star_comm is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} [_inst_9 : CommSemiring.{u1} R] [_inst_10 : StarRing.{u1} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u1} R (CommSemiring.toNonUnitalCommSemiring.{u1} R _inst_9))] [_inst_11 : Semiring.{u2} A] [_inst_12 : StarSemigroup.{u2} A (SemigroupWithZero.toSemigroup.{u2} A (NonUnitalSemiring.toSemigroupWithZero.{u2} A (Semiring.toNonUnitalSemiring.{u2} A _inst_11)))] [_inst_13 : Algebra.{u1, u2} R A _inst_9 _inst_11] [_inst_14 : StarModule.{u1, u2} R A (InvolutiveStar.toHasStar.{u1} R (StarAddMonoid.toHasInvolutiveStar.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonUnitalSemiring.toNonUnitalNonAssocSemiring.{u1} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u1} R (CommSemiring.toNonUnitalCommSemiring.{u1} R _inst_9))))) (StarRing.toStarAddMonoid.{u1} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u1} R (CommSemiring.toNonUnitalCommSemiring.{u1} R _inst_9)) _inst_10))) (InvolutiveStar.toHasStar.{u2} A (StarSemigroup.toHasInvolutiveStar.{u2} A (SemigroupWithZero.toSemigroup.{u2} A (NonUnitalSemiring.toSemigroupWithZero.{u2} A (Semiring.toNonUnitalSemiring.{u2} A _inst_11))) _inst_12)) (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_11)))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_11)))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_11)))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_9) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_11))) (Algebra.toModule.{u1, u2} R A _inst_9 _inst_11 _inst_13)))))] (r : R), Eq.{succ u2} A (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9)) (Semiring.toNonAssocSemiring.{u2} A _inst_11)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9)) (Semiring.toNonAssocSemiring.{u2} A _inst_11)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9)) (Semiring.toNonAssocSemiring.{u2} A _inst_11)) (algebraMap.{u1, u2} R A _inst_9 _inst_11 _inst_13) (Star.star.{u1} R (InvolutiveStar.toHasStar.{u1} R (StarAddMonoid.toHasInvolutiveStar.{u1} R (AddCommMonoid.toAddMonoid.{u1} R (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonUnitalSemiring.toNonUnitalNonAssocSemiring.{u1} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u1} R (CommSemiring.toNonUnitalCommSemiring.{u1} R _inst_9))))) (StarRing.toStarAddMonoid.{u1} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u1} R (CommSemiring.toNonUnitalCommSemiring.{u1} R _inst_9)) _inst_10))) r)) (Star.star.{u2} A (InvolutiveStar.toHasStar.{u2} A (StarSemigroup.toHasInvolutiveStar.{u2} A (SemigroupWithZero.toSemigroup.{u2} A (NonUnitalSemiring.toSemigroupWithZero.{u2} A (Semiring.toNonUnitalSemiring.{u2} A _inst_11))) _inst_12)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9)) (Semiring.toNonAssocSemiring.{u2} A _inst_11)) (fun (_x : RingHom.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9)) (Semiring.toNonAssocSemiring.{u2} A _inst_11)) => R -> A) (RingHom.hasCoeToFun.{u1, u2} R A (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_9)) (Semiring.toNonAssocSemiring.{u2} A _inst_11)) (algebraMap.{u1, u2} R A _inst_9 _inst_11 _inst_13) r))\nbut is expected to have type\n  forall {R : Type.{u2}} {A : Type.{u1}} [_inst_9 : CommSemiring.{u2} R] [_inst_10 : StarRing.{u2} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u2} R (CommSemiring.toNonUnitalCommSemiring.{u2} R _inst_9))] [_inst_11 : Semiring.{u1} A] [_inst_12 : StarSemigroup.{u1} A (SemigroupWithZero.toSemigroup.{u1} A (NonUnitalSemiring.toSemigroupWithZero.{u1} A (Semiring.toNonUnitalSemiring.{u1} A _inst_11)))] [_inst_13 : Algebra.{u2, u1} R A _inst_9 _inst_11] [_inst_14 : StarModule.{u2, u1} R A (InvolutiveStar.toStar.{u2} R (StarAddMonoid.toInvolutiveStar.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9))))) (StarRing.toStarAddMonoid.{u2} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u2} R (CommSemiring.toNonUnitalCommSemiring.{u2} R _inst_9)) _inst_10))) (InvolutiveStar.toStar.{u1} A (StarSemigroup.toInvolutiveStar.{u1} A (SemigroupWithZero.toSemigroup.{u1} A (NonUnitalSemiring.toSemigroupWithZero.{u1} A (Semiring.toNonUnitalSemiring.{u1} A _inst_11))) _inst_12)) (Algebra.toSMul.{u2, u1} R A _inst_9 _inst_11 _inst_13)] (r : R), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) (Star.star.{u2} R (InvolutiveStar.toStar.{u2} R (StarAddMonoid.toInvolutiveStar.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9))))) (StarRing.toStarAddMonoid.{u2} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u2} R (CommSemiring.toNonUnitalCommSemiring.{u2} R _inst_9)) _inst_10))) r)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R A (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)))) (NonUnitalNonAssocSemiring.toMul.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A _inst_11))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A _inst_11)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11) (RingHom.instRingHomClassRingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11))))) (algebraMap.{u2, u1} R A _inst_9 _inst_11 _inst_13) (Star.star.{u2} R (InvolutiveStar.toStar.{u2} R (StarAddMonoid.toInvolutiveStar.{u2} R (AddMonoidWithOne.toAddMonoid.{u2} R (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} R (NonAssocSemiring.toAddCommMonoidWithOne.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9))))) (StarRing.toStarAddMonoid.{u2} R (NonUnitalCommSemiring.toNonUnitalSemiring.{u2} R (CommSemiring.toNonUnitalCommSemiring.{u2} R _inst_9)) _inst_10))) r)) (Star.star.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) (InvolutiveStar.toStar.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) (StarSemigroup.toInvolutiveStar.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) (SemigroupWithZero.toSemigroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) (NonUnitalSemiring.toSemigroupWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) (Semiring.toNonUnitalSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) r) _inst_11))) _inst_12)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => A) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R A (NonUnitalNonAssocSemiring.toMul.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)))) (NonUnitalNonAssocSemiring.toMul.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A _inst_11))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A _inst_11)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11)) R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11) (RingHom.instRingHomClassRingHom.{u2, u1} R A (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_9)) (Semiring.toNonAssocSemiring.{u1} A _inst_11))))) (algebraMap.{u2, u1} R A _inst_9 _inst_11 _inst_13) r))\nCase conversion may be inaccurate. Consider using '#align algebra_map_star_comm algebraMap_star_commₓ'. -/\n@[simp]\ntheorem algebraMap_star_comm {R A : Type _} [CommSemiring R] [StarRing R] [Semiring A]\n    [StarSemigroup A] [Algebra R A] [StarModule R A] (r : R) :\n    algebraMap R A (star r) = star (algebraMap R A r) := by\n  simp only [Algebra.algebraMap_eq_smul_one, star_smul, star_one]\n#align algebra_map_star_comm algebraMap_star_comm\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Star/Module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599563, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.45468441709921087}}
{"text": "import order.basic ..nat ..logic .neg_elim \n  .reify .rev .sub_elim .dnf ..expr_of_unsat\n\nopen tactic\n\nnamespace nat\n\nrun_cmd mk_simp_attr `sugar_nat \nattribute [sugar_nat] \n  not_le not_lt\n  lt_iff_add_one_le\n  succ_eq_add_one\n  or_false false_or\n  and_true true_and\n  ge gt mul_add add_mul \n  mul_comm classical.iff_iff\n  classical.imp_iff_not_or\n\nmeta def desugar := `[try {simp only with sugar_nat}]\n\nlemma uniclo_of_unsat_neg_elim_not (m) (p : form) :\n  (neg_elim (¬* p)).unsat → uniclo p (λ _, 0) m :=  \nbegin\n  intro h1, apply uniclo_of_valid,\n  apply valid_of_unsat_not, intro h2, apply h1,\n  apply form.sat_of_implies_of_sat implies_neg_elim h2,\nend\n\nmeta def preterm.expr_of_sub_free : preterm → tactic expr \n| (& m)    := return `(trivial)\n| (m ** n) := return `(trivial)\n| (t +* s) := \n  do x ← preterm.expr_of_sub_free t,\n     y ← preterm.expr_of_sub_free s,\n     return `(@and.intro (preterm.sub_free %%`(t)) \n       (preterm.sub_free %%`(s)) %%x %%y) \n| (_ -* _) := failed\n\nmeta def expr_of_neg_free : form → tactic expr \n| (t =* s) := return `(trivial)\n| (t ≤* s) := return `(trivial)\n| (p ∨* q) := \n  do x ← expr_of_neg_free p,\n     y ← expr_of_neg_free q,\n     return `(@and.intro (form.neg_free %%`(p)) \n       (form.neg_free %%`(q)) %%x %%y) \n| (p ∧* q) := \n  do x ← expr_of_neg_free p,\n     y ← expr_of_neg_free q,\n     return `(@and.intro (form.neg_free %%`(p)) \n       (form.neg_free %%`(q)) %%x %%y) \n| _        := failed\n\nmeta def expr_of_sub_free : form → tactic expr \n| (t =* s) := \n  do x ← preterm.expr_of_sub_free t,\n     y ← preterm.expr_of_sub_free s,\n     return `(@and.intro (preterm.sub_free %%`(t)) \n       (preterm.sub_free %%`(s)) %%x %%y) \n| (t ≤* s) := \n  do x ← preterm.expr_of_sub_free t,\n     y ← preterm.expr_of_sub_free s,\n     return `(@and.intro (preterm.sub_free %%`(t)) \n       (preterm.sub_free %%`(s)) %%x %%y) \n| (¬*p) := expr_of_sub_free p\n| (p ∨* q) := \n  do x ← expr_of_sub_free p,\n     y ← expr_of_sub_free q,\n     return `(@and.intro (form.sub_free %%`(p)) \n       (form.sub_free %%`(q)) %%x %%y) \n| (p ∧* q) := \n  do x ← expr_of_sub_free p,\n     y ← expr_of_sub_free q,\n     return `(@and.intro (form.sub_free %%`(p)) \n       (form.sub_free %%`(q)) %%x %%y) \n\n/- Given a p : form, return the expr of a term t : p.unsat,\n   where p is subtraction- and negation-free. -/\nmeta def expr_of_unsat_sf (p : form) : tactic expr :=  \ndo x ← expr_of_neg_free p,\n   y ← expr_of_sub_free p,\n   z ← expr_of_unsats (dnf p),\n   return `(unsat_of_unsat_dnf %%`(p) %%x %%y %%z)\n\n/- Given a p : form, return the expr of a term t : p.unsat,\n   where p is negation-free. -/\nmeta def expr_of_unsat_nf : form → tactic expr | p := \nmatch p.sub_terms with \n| none         := expr_of_unsat_sf p\n| (some (t,s)) := \n  do x ← expr_of_unsat_nf (sub_elim t s p), \n     return `(unsat_of_unsat_sub_elim %%`(t) %%`(s) %%`(p) %%x)\nend\n\n/- Given a (m : nat) and (p : form), \n   return the expr of (t : uniclo m p) -/\nmeta def expr_of_uniclo (m : nat) (p : form) : tactic expr := \ndo x ← expr_of_unsat_nf (neg_elim (¬*p)), \n   to_expr ``(uniclo_of_unsat_neg_elim_not %%`(m) %%`(p) %%x)\n\nmeta def expr_of_lna : tactic expr :=\ndo (p,m) ← target >>= to_form 0,\n   expr_of_uniclo m p \n\nmeta def omega : tactic unit :=\nrev >> desugar >> expr_of_lna >>= apply >> skip\n\nend nat\n\n", "meta": {"author": "skbaek", "repo": "omega", "sha": "715e384ed14e8eb177a326700066e7c98269e078", "save_path": "github-repos/lean/skbaek-omega", "path": "github-repos/lean/skbaek-omega/omega-715e384ed14e8eb177a326700066e7c98269e078/nat/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738057795403, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4546112610552135}}
{"text": "example : ∀(x : Nat){h : x = x}, Nat := by\n  intro x\n  match x with\n  | 0 => _\n  | n + 1 => _\n\nexample (x : Nat) : ∀{h : x = x}, Nat := by\n  match x with\n  | 0 => _\n  | n + 1 => _\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/995.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737775116229, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4546112450550483}}
{"text": "section\n  variables (x y z : ℕ)\n  variables (h₁ : x = y) (h₂ : y = z)\n\n  section\n    variables {x y z}\n    include h₁ h₂\n    theorem foo : x = z :=\n    begin\n      rw [h₁, h₂]\n    end\n  end\n\n  theorem bar : x = z :=\n    eq.trans h₁ h₂\n\n  variable {x}\n  theorem baz : x = x := rfl\n\n  #check @foo\n  #check @bar\n  #check baz\nend\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch6/ex0204.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45453024653125573}}
{"text": "\nimport data.finmap\n\nrun_cmd mk_simp_attr `separation_logic\n\nopen finmap\n\nnamespace memory\n\nvariables value : Type\n\n@[reducible]\ndef ptr := ℕ\n\n@[reducible]\ndef heap := finmap (λ _ : ptr, value)\n\nvariables {value}\n\ndef add (x y : option (heap value)) : option (heap value) :=\ndo x ← x,\n   y ← y,\n   if disjoint x y then pure $ x ∪ y else none\n\ninfixr ` ⊗ `:55 := add\n\ninstance {α : Type*} {β : α → Type*} : has_subset (finmap β) :=\n⟨ λ x y, ∀ a, a ∈ x → a ∈ y ⟩\n\nlemma disjoint_mono' {ha hb ha' hb' : heap value} (H₀ : ha' ⊆ ha) (H₁ : hb' ⊆ hb) :\n  disjoint ha hb → disjoint ha' hb' :=\nλ H₂ x H₃ H₄,  H₂ x (H₀ _ H₃) (H₁ _ H₄)\n\nlemma union_eq_add_of_disjoint {h h' : heap value} (H₀ : disjoint h h') :\n  some (h ∪ h') = some h ⊗ some h' :=\nby simp [add,if_pos H₀]; refl\n\nlemma add_assoc (h₀ h₁ h₂ : option (heap value)) : (h₀ ⊗ h₁) ⊗ h₂ = h₀ ⊗ (h₁ ⊗ h₂) :=\nbegin\n  simp only [add] with monad_norm; congr; ext : 1; congr; ext : 1,\n  split_ifs,\n  { simp, congr, ext : 1,\n    split_ifs; simp [disjoint_union_left] at h_1,\n    { simp, rw [if_pos,finmap.union_assoc],\n      simp [disjoint_union_right],\n      exact ⟨h,h_1.1⟩ },\n    { exfalso, apply h_2 h_1.2 },\n    simp, split_ifs,\n    { exfalso, rw disjoint_union_right at h_3,\n      apply h_1 h_3.2 h_2, },\n    { refl },\n    simp },\n  simp, cases h₂,\n  { refl },\n  change none = pure h₂ >>= _, simp,\n  split_ifs,\n  { simp, split_ifs,\n    exfalso, rw disjoint_union_right at h_2, apply h h_2.1,\n    refl },\n  refl\nend\n\nlemma add_comm (h₀ h₁ : option (heap value)) : h₀ ⊗ h₁ = h₁ ⊗ h₀ :=\nbegin\n  cases h₀; cases h₁; try { refl },\n  simp only [add, @disjoint.symm_iff _ _ h₀, option.some_bind]; split_ifs,\n  ext : 1, simp only [ext_iff,pure], rw finmap.union_comm_of_disjoint,\n  symmetry, assumption, refl\nend\n\ninstance : is_associative _ (@add value) := ⟨ add_assoc ⟩\ninstance : is_commutative _ (@add value) := ⟨ add_comm ⟩\n\n@[simp]\nlemma empty_add (h : option (heap value)) :\n  some ∅ ⊗ h = h :=\nby cases h; [ simp [add], { rw [← union_eq_add_of_disjoint,empty_union]; apply disjoint_empty }]\n\n@[simp]\nlemma add_empty (h : option (heap value)) :\n  h ⊗ some ∅ = h :=\nby cases h; [ simp [add], { rw [← union_eq_add_of_disjoint,union_empty]; apply empty_disjoint }]\n\nlemma add_eq_some (x y : option (heap value)) (z : heap value) : some z = x ⊗ y → ∃ x', some x' = x :=\nby intro h; cases x; [ { simp [add] at h, cases h }, exact ⟨_,rfl⟩ ]\n\nlemma add_eq_some' (x y : option (heap value)) (z : heap value) : some z = x ⊗ y → ∃ y', some y' = y :=\nassume h, add_eq_some y x z (@add_comm _ x y ▸ h)\n\nlemma disjoint_iff {h h' : heap value} : disjoint h h' ↔ ∃ h'', some h'' = some h ⊗ some h' :=\nby by_cases disjoint h h'; simp only [add, *, option.some_bind, exists_false, if_false, if_true, true_iff]; exact ⟨_,rfl⟩\n\nlemma disjoint_of_add {h h' : heap value} (h'' : heap value) : some h'' = some h ⊗ some h' → disjoint h h' :=\nλ HH, disjoint_iff.mpr ⟨_, HH⟩\n\nlemma eq_union_of_eq_add {h h' h'' : heap value} : some h'' = some h ⊗ some h' → h'' = h ∪ h' :=\nλ HH, option.some.inj (eq.trans HH (union_eq_add_of_disjoint (disjoint_of_add _ HH)).symm)\n\nend memory\n", "meta": {"author": "cipher1024", "repo": "lean-pl", "sha": "829680605ac17e91038d793c0188e9614353ca25", "save_path": "github-repos/lean/cipher1024-lean-pl", "path": "github-repos/lean/cipher1024-lean-pl/lean-pl-829680605ac17e91038d793c0188e9614353ca25/src/heap/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45453024653125573}}
{"text": "import analysis.calculus.times_cont_diff\nimport analysis.calculus.fderiv_symmetric\nimport analysis.calculus.conformal\nimport similarity\nimport data.matrix.notation\n\nnoncomputable theory\n\nopen conformal_at submodule set continuous_linear_map\nopen_locale classical real_inner_product_space filter topological_space\n\nlemma quick1 {E : Type*} [inner_product_space ℝ E] (u : E) : ![u] = fin.snoc 0 u :=\nbegin\n  ext y,\n  simp only [fin.snoc],\n  rw dif_neg (not_lt.mpr $ zero_le y.val),\n  simp\nend\n\nlemma diff1 {E F G : Type*} [normed_group E] [normed_group F] [normed_group G]\n  [normed_space ℝ E] [normed_space ℝ F]\n  [normed_space ℝ G] {x v : E} {u : G} {f : E → F} (hf : differentiable_at ℝ f x) :\n  (fderiv ℝ (λ y, (f y, u)) x v).2 = 0 :=\nbegin\n  have A : (fderiv ℝ (λ y, (f y, u)) x v).2 = \n    (continuous_linear_map.snd ℝ F G).comp (fderiv ℝ (λ y, (f y, u)) x) v := by simp,\n  rw A,\n  rw ← (continuous_linear_map.snd ℝ F G).fderiv,\n  rw [← fderiv.comp, coe_snd'],\n  have B : prod.snd ∘ (λ y, (f y, u)) = λ y, u := by ext1; simp,\n  rw [B, fderiv_const_apply, zero_apply],\n  { exact continuous_linear_map.differentiable_at _ },\n  { refine differentiable_at.prod hf _,\n    exact differentiable_at_const _ }\nend  \n\nvariables {E F : Type*} [inner_product_space ℝ E] [inner_product_space ℝ F] {f : E → F}\n  {s : set E} (hs : is_open s)\n\nlemma A {f' : E →L[ℝ] F} (h : is_conformal_map f') {u v : E} :\n  ⟪u, v⟫ = 0 ↔ ⟪f' u, f' v⟫ = 0 :=\nbegin\n  rcases (is_conformal_map_iff _).mp h with ⟨c, p, q⟩,\n  split,\n  { intros huv,\n    convert q u v,\n    rw [huv, mul_zero] },\n  { intros huv,\n    rw q u v at huv,\n    exact eq_zero_of_ne_zero_of_mul_left_eq_zero (ne_of_gt p) huv } \nend\n\nlemma A' {x : E} {f' : E → (E →L[ℝ] F)} {u v : E} (huv : ⟪u, v⟫ = 0) \n  (h : ∀ᶠ x' in 𝓝 x, is_conformal_map $ f' x') :\n  (λ x, ⟪f' x u, f' x v⟫) =ᶠ[𝓝 x] λ x, (0 : ℝ) :=\nbegin\n  apply (filter.eventually_of_forall $ λ x, huv).mp,\n  simp only [congr_arg],\n  rcases filter.eventually_iff_exists_mem.mp h with ⟨s, hs, hys⟩,\n  exact filter.eventually_iff_exists_mem.mpr ⟨s, hs, λ y hy p, (A $ hys y hy).mp p⟩\nend\n\ninclude hs\n\nlemma eval_fderiv1 {u v x : E} (hx : x ∈ s) {p : E → formal_multilinear_series ℝ E F}\n  (hf : has_ftaylor_series_up_to_on 2 f p s) : \n  fderiv ℝ (λ y, p y 1 ![u]) x v = p x 2 ![u, v] :=\nbegin\n  have : (λ y, p y 1 ![u]) = (λ (q : (E →L[ℝ] F) × E), q.1 q.2) ∘ \n    (λ y, (continuous_multilinear_curry_fin1 ℝ _ _ (p y 1), u)),\n  { ext1,\n    simp only [function.comp_app, continuous_multilinear_curry_fin1_apply],\n    rw quick1 },\n  rw [this, fderiv.comp, is_bounded_bilinear_map_apply.fderiv],\n  simp only [coe_comp', function.comp_app, is_bounded_bilinear_map_deriv_coe],\n  rw @diff1 _ _ _ _ _ _ _ _ _ (λ y, continuous_multilinear_curry_fin1 ℝ _ _ (p y 1)),\nend\n\n-- lemma eval_fderiv3 {u x : E} (hx : x ∈ s)\n--   {n₀ : ℕ} (hf : times_cont_diff_at ℝ n₀ f x) {n : ℕ} (hn : n < n₀) {m : fin (n + 1) → E} :\n--   fderiv ℝ (λ y, iterated_fderiv) x u = p x (n + 2) (fin.snoc m u)\n\nlemma diff_aux {f' : E → (E →L[ℝ] F)} {x u : E} \n  (hf : ∀ᶠ (y : E) in 𝓝 x, has_fderiv_at f (f' y) y) (hf' : differentiable_at ℝ f' x) :\n  fderiv ℝ (λ y, f' y u) x = fderiv ℝ f' x u :=\nbegin\n  have : (λ y, f' y u) = λ y, ((apply ℝ F u) ∘ f') y :=\n    by simp only [function.comp_app, apply_apply],\n  simp only [this, congr_arg],\n  rw fderiv.comp _ (continuous_linear_map.differentiable_at _) hf',\n  ext1 v,\n  simp only [continuous_linear_map.fderiv, coe_comp', function.comp_app, apply_apply],\n  exact second_derivative_symmetric_of_eventually hf hf'.has_fderiv_at _ _\nend\n\nvariables {p : E → formal_multilinear_series ℝ E F}\n\nlemma D' (u v w : E) {x : E} (hx : x ∈ s) (hf : has_ftaylor_series_up_to_on 2 f p s) :\n  fderiv ℝ (λ y, ⟪fderiv ℝ f y u, fderiv ℝ f y v⟫) x w = \n  ⟪p x 2 ![u, w], fderiv ℝ f x v⟫ + \n  ⟪fderiv ℝ f x u, iterated_fderiv ℝ 2 f x ![v, w]⟫ :=\nbegin\n  rw fderiv_inner_apply,\n  have : ∀ᶠ (y : E) in 𝓝 x, has_fderiv_at f (fderiv ℝ f y) y :=\n  begin\n    refine filter.eventually_iff_exists_mem.mpr ⟨s, hs.mem_nhds hx, λ y hy, _⟩,\n    convert ((hf.differentiable_on $ with_top.coe_le_coe.mpr one_le_two) \n      y hy).has_fderiv_within_at.has_fderiv_at (hs.mem_nhds hy),\n    rw fderiv_within_of_open hs hy\n  end,\n  rw diff_aux,\nend\n\nlemma D {u v w : E} {x : E} (hx : x ∈ s) (hf : has_ftaylor_series_up_to_on 2 f p s)\n  (huv : ⟪u, v⟫ = 0) (hwu : ⟪w, u⟫ = 0) (hvw : ⟪v, w⟫ = 0) :\n  ⟪p x 2 ![u, v], p x 1 ![w]⟫ = 0 :=\nbegin\n  have m₁ := D' u v w hx hf,\n  have m₂ := D' v w u hx hf,\n  have m₃ := D' w u v hx hf,\n  rw add_comm at m₁ m₃,\n  nth_rewrite 0 real_inner_comm at m₃ m₁,\n  nth_rewrite 1 real_inner_comm at m₁,\nend", "meta": {"author": "justadzr", "repo": "lean-2021", "sha": "dfc6b30de2f27bdba5fbc51183e2b84e73a920d1", "save_path": "github-repos/lean/justadzr-lean-2021", "path": "github-repos/lean/justadzr-lean-2021/lean-2021-dfc6b30de2f27bdba5fbc51183e2b84e73a920d1/src/liouville_new.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45453024653125573}}
{"text": "import Smt.Reconstruction.Defs\nimport Smt.Reconstruction.Term\n\nopen Types\nopen proof\nopen term\nopen sort\nopen Nat\n\nnamespace Rules\n\ntheorem refl : ∀ {t : term} {Γ : Environment} {Δ : SEnvironment},\n  wellTyped t → validWith Γ Δ (eq t t)\n  | t, Γ, Δ, wTt =>\n    match r: interpTerm t with\n    | some ⟨ atom 0 , _ ⟩               => by simp; rewrite [r]; exact rfl\n    | some ⟨ atom 1 , _ ⟩               => by simp; rewrite [r]; exact rfl\n    | some ⟨ atom (succ (succ _)) , _ ⟩ => by simp; rewrite [r]; simp; exact rfl\n    | some ⟨ sort.undef, _ ⟩            => by simp; rewrite [r]; exact rfl\n    | some ⟨ sort.array _ _, _ ⟩        => by simp; rewrite [r]; simp; exact rfl\n    | some ⟨ sort.bv _, _ ⟩             => by simp; rewrite [r]; simp; exact rfl\n    | some ⟨ sort.arrow _ _, _ ⟩        => by simp; rewrite [r]; simp; exact rfl\n    | some ⟨ sort.dep, _ ⟩              => by simp; rewrite [r]; exact rfl\n    | none                              => by simp at wTt; rewrite [r] at wTt; exact False.elim wTt\n\n\nend Rules\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Smt/Reconstruction/Certified/EufRules.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4545302465312556}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module tactic.ring2\n! leanprover-community/mathlib commit 3d7987cda72abc473c7cdbbb075170e9ac620042\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Tactic.Ring\nimport Mathbin.Data.Num.Lemmas\nimport Mathbin.Data.Tree\n\n/-!\n# ring2\n\nAn experimental variant on the `ring` tactic that uses computational\nreflection instead of proof generation. Useful for kernel benchmarking.\n-/\n\n\nnamespace Tree\n\n/-- `(reflect' t u α)` quasiquotes a tree `(t: tree expr)` of quoted\nvalues of type `α` at level `u` into an `expr` which reifies to a `tree α`\ncontaining the reifications of the `expr`s from the original `t`. -/\nprotected unsafe def reflect' (u : level) (α : expr) : Tree expr → expr\n  | Tree.nil => (expr.const `` Tree.nil [u] : expr) α\n  | Tree.node a t₁ t₂ => (expr.const `` Tree.node [u] : expr) α a t₁.reflect' t₂.reflect'\n#align tree.reflect' tree.reflect'\n\n/-- Returns an element indexed by `n`, or zero if `n` isn't a valid index.\nSee `tree.get`. -/\nprotected def getOrZero {α} [Zero α] (t : Tree α) (n : PosNum) : α :=\n  t.getD n 0\n#align tree.get_or_zero Tree.getOrZero\n\nend Tree\n\nnamespace Tactic.Ring2\n\n/-- A reflected/meta representation of an expression in a commutative\nsemiring. This representation is a direct translation of such\nexpressions - see `horner_expr` for a normal form. -/\ninductive CsringExpr/- (atom n) is an opaque element of the csring. For example,\na local variable in the context. n indexes into a storage\nof such atoms - a `tree α`. -/\n\n  | atom : PosNum → csring_expr/- (const n) is technically the csring's one, added n times.\nOr the zero if n is 0. -/\n\n  | const : Num → csring_expr\n  | add : csring_expr → csring_expr → csring_expr\n  | mul : csring_expr → csring_expr → csring_expr\n  | pow : csring_expr → Num → csring_expr\n  deriving has_reflect\n#align tactic.ring2.csring_expr Tactic.Ring2.CsringExpr\n\nnamespace CsringExpr\n\ninstance : Inhabited CsringExpr :=\n  ⟨const 0⟩\n\n/-- Evaluates a reflected `csring_expr` into an element of the\noriginal `comm_semiring` type `α`, retrieving opaque elements\n(atoms) from the tree `t`. -/\ndef eval {α} [CommSemiring α] (t : Tree α) : CsringExpr → α\n  | atom n => t.getOrZero n\n  | const n => n\n  | add x y => eval x + eval y\n  | mul x y => eval x * eval y\n  | pow x n => eval x ^ (n : ℕ)\n#align tactic.ring2.csring_expr.eval Tactic.Ring2.CsringExpr.eval\n\nend CsringExpr\n\n/-- An efficient representation of expressions in a commutative\nsemiring using the sparse Horner normal form. This type admits\nnon-optimal instantiations (e.g. `P` can be represented as `P+0+0`),\nso to get good performance out of it, care must be taken to maintain\nan optimal, *canonical* form. -/\ninductive HornerExpr/- (const n) is a constant n in the csring, similarly to the same\nconstructor in `csring_expr`. This one, however, can be negative. -/\n\n  | const : ZNum → horner_expr/- (horner a x n b) is a*xⁿ + b, where x is the x-th atom\nin the atom tree. -/\n\n  | horner : horner_expr → PosNum → Num → horner_expr → horner_expr\n  deriving DecidableEq\n#align tactic.ring2.horner_expr Tactic.Ring2.HornerExpr\n\nnamespace HornerExpr\n\n/-- True iff the `horner_expr` argument is a valid `csring_expr`.\nFor that to be the case, all its constants must be non-negative. -/\ndef IsCs : HornerExpr → Prop\n  | const n => ∃ m : Num, n = m.toZNum\n  | horner a x n b => is_cs a ∧ is_cs b\n#align tactic.ring2.horner_expr.is_cs Tactic.Ring2.HornerExpr.IsCs\n\ninstance : Zero HornerExpr :=\n  ⟨const 0⟩\n\ninstance : One HornerExpr :=\n  ⟨const 1⟩\n\ninstance : Inhabited HornerExpr :=\n  ⟨0⟩\n\n/-- Represent a `csring_expr.atom` in Horner form. -/\ndef atom (n : PosNum) : HornerExpr :=\n  horner 1 n 1 0\n#align tactic.ring2.horner_expr.atom Tactic.Ring2.HornerExpr.atom\n\ndef toString : HornerExpr → String\n  | const n => repr n\n  | horner a x n b => \"(\" ++ toString a ++ \") * x\" ++ repr x ++ \"^\" ++ repr n ++ \" + \" ++ toString b\n#align tactic.ring2.horner_expr.to_string Tactic.Ring2.HornerExpr.toString\n\ninstance : ToString HornerExpr :=\n  ⟨toString⟩\n\n/-- Alternative constructor for (horner a x n b) which maintains canonical\nform by simplifying special cases of `a`. -/\ndef horner' (a : HornerExpr) (x : PosNum) (n : Num) (b : HornerExpr) : HornerExpr :=\n  match a with\n  | const q => if q = 0 then b else horner a x n b\n  | horner a₁ x₁ n₁ b₁ => if x₁ = x ∧ b₁ = 0 then horner a₁ x (n₁ + n) b else horner a x n b\n#align tactic.ring2.horner_expr.horner' Tactic.Ring2.HornerExpr.horner'\n\ndef addConst (k : ZNum) (e : HornerExpr) : HornerExpr :=\n  if k = 0 then e\n  else by\n    induction' e with n a x n b A B\n    · exact const (k + n)\n    · exact horner a x n B\n#align tactic.ring2.horner_expr.add_const Tactic.Ring2.HornerExpr.addConst\n\ndef addAux (a₁ : HornerExpr) (A₁ : HornerExpr → HornerExpr) (x₁ : PosNum) :\n    HornerExpr → Num → HornerExpr → (HornerExpr → HornerExpr) → HornerExpr\n  | const n₂, n₁, b₁, B₁ => addConst n₂ (horner a₁ x₁ n₁ b₁)\n  | horner a₂ x₂ n₂ b₂, n₁, b₁, B₁ =>\n    let e₂ := horner a₂ x₂ n₂ b₂\n    match PosNum.cmp x₁ x₂ with\n    | Ordering.lt => horner a₁ x₁ n₁ (B₁ e₂)\n    | Ordering.gt => horner a₂ x₂ n₂ (add_aux b₂ n₁ b₁ B₁)\n    | Ordering.eq =>\n      match Num.sub' n₁ n₂ with\n      | ZNum.zero => horner' (A₁ a₂) x₁ n₁ (B₁ b₂)\n      | ZNum.pos k => horner (add_aux a₂ k 0 id) x₁ n₂ (B₁ b₂)\n      | ZNum.neg k => horner (A₁ (horner a₂ x₁ k 0)) x₁ n₁ (B₁ b₂)\n#align tactic.ring2.horner_expr.add_aux Tactic.Ring2.HornerExpr.addAux\n\ndef add : HornerExpr → HornerExpr → HornerExpr\n  | const n₁, e₂ => addConst n₁ e₂\n  | horner a₁ x₁ n₁ b₁, e₂ => addAux a₁ (add a₁) x₁ e₂ n₁ b₁ (add b₁)\n#align tactic.ring2.horner_expr.add Tactic.Ring2.HornerExpr.add\n\n/-begin\n  induction e₁ with n₁ a₁ x₁ n₁ b₁ A₁ B₁ generalizing e₂,\n  { exact add_const n₁ e₂ },\n  exact match e₂ with e₂ := begin\n    induction e₂ with n₂ a₂ x₂ n₂ b₂ A₂ B₂ generalizing n₁ b₁;\n    let e₁ := horner a₁ x₁ n₁ b₁,\n    { exact add_const n₂ e₁ },\n    let e₂ := horner a₂ x₂ n₂ b₂,\n    exact match pos_num.cmp x₁ x₂ with\n    | ordering.lt := horner a₁ x₁ n₁ (B₁ e₂)\n    | ordering.gt := horner a₂ x₂ n₂ (B₂ n₁ b₁)\n    | ordering.eq :=\n      match num.sub' n₁ n₂ with\n      | znum.zero := horner' (A₁ a₂) x₁ n₁ (B₁ b₂)\n      | (znum.pos k) := horner (A₂ k 0) x₁ n₂ (B₁ b₂)\n      | (znum.neg k) := horner (A₁ (horner a₂ x₁ k 0)) x₁ n₁ (B₁ b₂)\n      end\n    end\n  end end\nend-/\ndef neg (e : HornerExpr) : HornerExpr :=\n  by\n  induction' e with n a x n b A B\n  · exact const (-n)\n  · exact horner A x n B\n#align tactic.ring2.horner_expr.neg Tactic.Ring2.HornerExpr.neg\n\ndef mulConst (k : ZNum) (e : HornerExpr) : HornerExpr :=\n  if k = 0 then 0\n  else\n    if k = 1 then e\n    else by\n      induction' e with n a x n b A B\n      · exact const (n * k)\n      · exact horner A x n B\n#align tactic.ring2.horner_expr.mul_const Tactic.Ring2.HornerExpr.mulConst\n\ndef mulAux (a₁ x₁ n₁ b₁) (A₁ B₁ : HornerExpr → HornerExpr) : HornerExpr → HornerExpr\n  | const n₂ => mulConst n₂ (horner a₁ x₁ n₁ b₁)\n  | e₂@(horner a₂ x₂ n₂ b₂) =>\n    match PosNum.cmp x₁ x₂ with\n    | Ordering.lt => horner (A₁ e₂) x₁ n₁ (B₁ e₂)\n    | Ordering.gt => horner (mul_aux a₂) x₂ n₂ (mul_aux b₂)\n    | Ordering.eq =>\n      let haa := horner' (mul_aux a₂) x₁ n₂ 0\n      if b₂ = 0 then haa else haa.add (horner (A₁ b₂) x₁ n₁ (B₁ b₂))\n#align tactic.ring2.horner_expr.mul_aux Tactic.Ring2.HornerExpr.mulAux\n\ndef mul : HornerExpr → HornerExpr → HornerExpr\n  | const n₁ => mulConst n₁\n  | horner a₁ x₁ n₁ b₁ => mulAux a₁ x₁ n₁ b₁ (mul a₁) (mul b₁)\n#align tactic.ring2.horner_expr.mul Tactic.Ring2.HornerExpr.mul\n\n/-begin\n  induction e₁ with n₁ a₁ x₁ n₁ b₁ A₁ B₁ generalizing e₂,\n  { exact mul_const n₁ e₂ },\n  induction e₂ with n₂ a₂ x₂ n₂ b₂ A₂ B₂;\n  let e₁ := horner a₁ x₁ n₁ b₁,\n  { exact mul_const n₂ e₁ },\n  let e₂ := horner a₂ x₂ n₂ b₂,\n  cases pos_num.cmp x₁ x₂,\n  { exact horner (A₁ e₂) x₁ n₁ (B₁ e₂) },\n  { let haa := horner' A₂ x₁ n₂ 0,\n    exact if b₂ = 0 then haa else\n      haa.add (horner (A₁ b₂) x₁ n₁ (B₁ b₂)) },\n  { exact horner A₂ x₂ n₂ B₂ }\nend-/\ninstance : Add HornerExpr :=\n  ⟨add⟩\n\ninstance : Neg HornerExpr :=\n  ⟨neg⟩\n\ninstance : Mul HornerExpr :=\n  ⟨mul⟩\n\ndef pow (e : HornerExpr) : Num → HornerExpr\n  | 0 => 1\n  | Num.pos p => by\n    induction' p with p ep p ep\n    · exact e\n    · exact (ep.mul ep).mul e\n    · exact ep.mul ep\n#align tactic.ring2.horner_expr.pow Tactic.Ring2.HornerExpr.pow\n\ndef inv (e : HornerExpr) : HornerExpr :=\n  0\n#align tactic.ring2.horner_expr.inv Tactic.Ring2.HornerExpr.inv\n\n/-- Brings expressions into Horner normal form. -/\ndef ofCsexpr : CsringExpr → HornerExpr\n  | csring_expr.atom n => atom n\n  | csring_expr.const n => const n.toZNum\n  | csring_expr.add x y => (of_csexpr x).add (of_csexpr y)\n  | csring_expr.mul x y => (of_csexpr x).mul (of_csexpr y)\n  | csring_expr.pow x n => (of_csexpr x).pow n\n#align tactic.ring2.horner_expr.of_csexpr Tactic.Ring2.HornerExpr.ofCsexpr\n\n/-- Evaluates a reflected `horner_expr` - see `csring_expr.eval`. -/\ndef cseval {α} [CommSemiring α] (t : Tree α) : HornerExpr → α\n  | const n => n.abs\n  | horner a x n b => Tactic.Ring.horner (cseval a) (t.getOrZero x) n (cseval b)\n#align tactic.ring2.horner_expr.cseval Tactic.Ring2.HornerExpr.cseval\n\ntheorem cseval_atom {α} [CommSemiring α] (t : Tree α) (n : PosNum) :\n    (atom n).IsCs ∧ cseval t (atom n) = t.getOrZero n :=\n  ⟨⟨⟨1, rfl⟩, ⟨0, rfl⟩⟩, (Tactic.Ring.horner_atom _).symm⟩\n#align tactic.ring2.horner_expr.cseval_atom Tactic.Ring2.HornerExpr.cseval_atom\n\ntheorem cseval_addConst {α} [CommSemiring α] (t : Tree α) (k : Num) {e : HornerExpr} (cs : e.IsCs) :\n    (addConst k.toZNum e).IsCs ∧ cseval t (addConst k.toZNum e) = k + cseval t e :=\n  by\n  simp [add_const]\n  cases k <;> simp! [*]\n  simp [show ZNum.pos k ≠ 0 by decide]\n  induction' e with n a x n b A B <;> simp [*]\n  · rcases cs with ⟨n, rfl⟩\n    refine' ⟨⟨n + Num.pos k, by simp [add_comm] <;> rfl⟩, _⟩\n    cases n <;> simp!\n  · rcases B cs.2 with ⟨csb, h⟩\n    simp! [*, cs.1]\n    rw [← Tactic.Ring.horner_add_const, add_comm]\n    rw [add_comm]\n#align tactic.ring2.horner_expr.cseval_add_const Tactic.Ring2.HornerExpr.cseval_addConst\n\ntheorem cseval_horner' {α} [CommSemiring α] (t : Tree α) (a x n b) (h₁ : IsCs a) (h₂ : IsCs b) :\n    (horner' a x n b).IsCs ∧\n      cseval t (horner' a x n b) = Tactic.Ring.horner (cseval t a) (t.getOrZero x) n (cseval t b) :=\n  by\n  cases' a with n₁ a₁ x₁ n₁ b₁ <;> simp [horner'] <;> split_ifs\n  · simp! [*, Tactic.Ring.horner]\n  · exact ⟨⟨h₁, h₂⟩, rfl⟩\n  · refine' ⟨⟨h₁.1, h₂⟩, Eq.symm _⟩\n    simp! [*]\n    apply Tactic.Ring.horner_horner\n    simp\n  · exact ⟨⟨h₁, h₂⟩, rfl⟩\n#align tactic.ring2.horner_expr.cseval_horner' Tactic.Ring2.HornerExpr.cseval_horner'\n\ntheorem cseval_add {α} [CommSemiring α] (t : Tree α) {e₁ e₂ : HornerExpr} (cs₁ : e₁.IsCs)\n    (cs₂ : e₂.IsCs) : (add e₁ e₂).IsCs ∧ cseval t (add e₁ e₂) = cseval t e₁ + cseval t e₂ :=\n  by\n  induction' e₁ with n₁ a₁ x₁ n₁ b₁ A₁ B₁ generalizing e₂ <;> simp!\n  · rcases cs₁ with ⟨n₁, rfl⟩\n    simpa using cseval_add_const t n₁ cs₂\n  induction' e₂ with n₂ a₂ x₂ n₂ b₂ A₂ B₂ generalizing n₁ b₁\n  · rcases cs₂ with ⟨n₂, rfl⟩\n    simp! [cseval_add_const t n₂ cs₁, add_comm]\n  cases' cs₁ with csa₁ csb₁; cases' id cs₂ with csa₂ csb₂\n  simp! ; have C := PosNum.cmp_to_nat x₁ x₂\n  cases PosNum.cmp x₁ x₂ <;> simp!\n  · rcases B₁ csb₁ cs₂ with ⟨csh, h⟩\n    refine' ⟨⟨csa₁, csh⟩, Eq.symm _⟩\n    apply Tactic.Ring.horner_add_const\n    exact h.symm\n  · cases C\n    have B0 :\n      is_cs 0 →\n        ∀ {e₂ : horner_expr},\n          is_cs e₂ → is_cs (add 0 e₂) ∧ cseval t (add 0 e₂) = cseval t 0 + cseval t e₂ :=\n      fun _ e₂ c => ⟨c, (zero_add _).symm⟩\n    cases' e : Num.sub' n₁ n₂ with k k <;> simp!\n    · have : n₁ = n₂ := by\n        have := congr_arg (coe : ZNum → ℤ) e\n        simp at this\n        have := sub_eq_zero.1 this\n        rw [← Num.to_nat_to_int, ← Num.to_nat_to_int] at this\n        exact Num.to_nat_inj.1 (Int.ofNat.inj this)\n      subst n₂\n      rcases cseval_horner' _ _ _ _ _ _ _ with ⟨csh, h⟩\n      · refine' ⟨csh, h.trans (Eq.symm _)⟩\n        simp [*]\n        apply Tactic.Ring.horner_add_horner_eq <;> try rfl\n      all_goals simp! [*]\n    · simp [B₁ csb₁ csb₂, add_comm]\n      rcases A₂ csa₂ _ _ B0 ⟨csa₁, 0, rfl⟩ with ⟨csh, h⟩\n      refine' ⟨csh, Eq.symm _⟩\n      rw [show id = add 0 from rfl, h]\n      apply Tactic.Ring.horner_add_horner_gt\n      · change (_ + k : ℕ) = _\n        rw [← Int.coe_nat_inj', Int.ofNat_add, eq_comm, ← sub_eq_iff_eq_add']\n        simpa using congr_arg (coe : ZNum → ℤ) e\n      · rfl\n      · apply add_comm\n    · have : (horner a₂ x₁ (Num.pos k) 0).IsCs := ⟨csa₂, 0, rfl⟩\n      simp [B₁ csb₁ csb₂, A₁ csa₁ this]\n      symm\n      apply Tactic.Ring.horner_add_horner_lt\n      · change (_ + k : ℕ) = _\n        rw [← Int.coe_nat_inj', Int.ofNat_add, eq_comm, ← sub_eq_iff_eq_add', ← neg_inj, neg_sub]\n        simpa using congr_arg (coe : ZNum → ℤ) e\n      all_goals rfl\n  · rcases B₂ csb₂ _ _ B₁ ⟨csa₁, csb₁⟩ with ⟨csh, h⟩\n    refine' ⟨⟨csa₂, csh⟩, Eq.symm _⟩\n    apply Tactic.Ring.const_add_horner\n    simp [h]\n#align tactic.ring2.horner_expr.cseval_add Tactic.Ring2.HornerExpr.cseval_add\n\ntheorem cseval_mulConst {α} [CommSemiring α] (t : Tree α) (k : Num) {e : HornerExpr} (cs : e.IsCs) :\n    (mulConst k.toZNum e).IsCs ∧ cseval t (mulConst k.toZNum e) = cseval t e * k :=\n  by\n  simp [mul_const]\n  split_ifs with h h\n  · cases (Num.toZNum_inj.1 h : k = 0)\n    exact ⟨⟨0, rfl⟩, (MulZeroClass.mul_zero _).symm⟩\n  · cases (Num.toZNum_inj.1 h : k = 1)\n    exact ⟨cs, (mul_one _).symm⟩\n  induction' e with n a x n b A B <;> simp [*]\n  · rcases cs with ⟨n, rfl⟩\n    suffices\n    refine' ⟨⟨n * k, this⟩, _⟩\n    swap\n    · cases n <;> cases k <;> rfl\n    rw [show _ from this]\n    simp!\n  · cases cs\n    simp! [*]\n    symm\n    apply Tactic.Ring.horner_mul_const <;> rfl\n#align tactic.ring2.horner_expr.cseval_mul_const Tactic.Ring2.HornerExpr.cseval_mulConst\n\ntheorem cseval_mul {α} [CommSemiring α] (t : Tree α) {e₁ e₂ : HornerExpr} (cs₁ : e₁.IsCs)\n    (cs₂ : e₂.IsCs) : (mul e₁ e₂).IsCs ∧ cseval t (mul e₁ e₂) = cseval t e₁ * cseval t e₂ :=\n  by\n  induction' e₁ with n₁ a₁ x₁ n₁ b₁ A₁ B₁ generalizing e₂ <;> simp!\n  · rcases cs₁ with ⟨n₁, rfl⟩\n    simpa [mul_comm] using cseval_mul_const t n₁ cs₂\n  induction' e₂ with n₂ a₂ x₂ n₂ b₂ A₂ B₂\n  · rcases cs₂ with ⟨n₂, rfl⟩\n    simpa! using cseval_mul_const t n₂ cs₁\n  cases' cs₁ with csa₁ csb₁; cases' id cs₂ with csa₂ csb₂\n  simp! ; have C := PosNum.cmp_to_nat x₁ x₂\n  cases' A₂ csa₂ with csA₂ hA₂\n  cases PosNum.cmp x₁ x₂ <;> simp!\n  · simp [A₁ csa₁ cs₂, B₁ csb₁ cs₂]\n    symm\n    apply Tactic.Ring.horner_mul_const <;> rfl\n  · cases' cseval_horner' t _ x₁ n₂ 0 csA₂ ⟨0, rfl⟩ with csh₁ h₁\n    cases C\n    split_ifs\n    · subst b₂\n      refine' ⟨csh₁, h₁.trans (Eq.symm _)⟩\n      apply Tactic.Ring.horner_mul_horner_zero <;> try rfl\n      simp! [hA₂]\n    · cases' A₁ csa₁ csb₂ with csA₁ hA₁\n      cases' cseval_add t csh₁ _ with csh₂ h₂\n      · refine' ⟨csh₂, h₂.trans (Eq.symm _)⟩\n        apply Tactic.Ring.horner_mul_horner <;> try rfl\n        simp! [*]\n      exact ⟨csA₁, (B₁ csb₁ csb₂).1⟩\n  · simp [A₂ csa₂, B₂ csb₂]\n    rw [mul_comm, eq_comm]\n    apply Tactic.Ring.horner_const_mul\n    · apply mul_comm\n    · rfl\n#align tactic.ring2.horner_expr.cseval_mul Tactic.Ring2.HornerExpr.cseval_mul\n\ntheorem cseval_pow {α} [CommSemiring α] (t : Tree α) {x : HornerExpr} (cs : x.IsCs) :\n    ∀ n : Num, (pow x n).IsCs ∧ cseval t (pow x n) = cseval t x ^ (n : ℕ)\n  | 0 => ⟨⟨1, rfl⟩, (pow_zero _).symm⟩\n  | Num.pos p => by\n    simp [pow]; induction' p with p ep p ep\n    · simp [*]\n    · simp [pow_bit1]\n      cases' cseval_mul t ep.1 ep.1 with cs₀ h₀\n      cases' cseval_mul t cs₀ cs with cs₁ h₁\n      simp [*]\n    · simp [pow_bit0]\n      cases' cseval_mul t ep.1 ep.1 with cs₀ h₀\n      simp [*]\n#align tactic.ring2.horner_expr.cseval_pow Tactic.Ring2.HornerExpr.cseval_pow\n\n/-- For any given tree `t` of atoms and any reflected expression `r`,\nthe Horner form of `r` is a valid csring expression, and under `t`,\nthe Horner form evaluates to the same thing as `r`. -/\ntheorem cseval_ofCsexpr {α} [CommSemiring α] (t : Tree α) :\n    ∀ r : CsringExpr, (ofCsexpr r).IsCs ∧ cseval t (ofCsexpr r) = r.eval t\n  | csring_expr.atom n => cseval_atom _ _\n  | csring_expr.const n => ⟨⟨n, rfl⟩, by cases n <;> rfl⟩\n  | csring_expr.add x y =>\n    let ⟨cs₁, h₁⟩ := cseval_of_csexpr x\n    let ⟨cs₂, h₂⟩ := cseval_of_csexpr y\n    let ⟨cs, h⟩ := cseval_add t cs₁ cs₂\n    ⟨cs, by simp! [h, *]⟩\n  | csring_expr.mul x y =>\n    let ⟨cs₁, h₁⟩ := cseval_of_csexpr x\n    let ⟨cs₂, h₂⟩ := cseval_of_csexpr y\n    let ⟨cs, h⟩ := cseval_mul t cs₁ cs₂\n    ⟨cs, by simp! [h, *]⟩\n  | csring_expr.pow x n =>\n    let ⟨cs, h⟩ := cseval_of_csexpr x\n    let ⟨cs, h⟩ := cseval_pow t cs n\n    ⟨cs, by simp! [h, *]⟩\n#align tactic.ring2.horner_expr.cseval_of_csexpr Tactic.Ring2.HornerExpr.cseval_ofCsexpr\n\nend HornerExpr\n\n/-- The main proof-by-reflection theorem. Given reflected csring expressions\n`r₁` and `r₂` plus a storage `t` of atoms, if both expressions go to the\nsame Horner normal form, then the original non-reflected expressions are\nequal. `H` follows from kernel reduction and is therefore `rfl`. -/\ntheorem correctness {α} [CommSemiring α] (t : Tree α) (r₁ r₂ : CsringExpr)\n    (H : HornerExpr.ofCsexpr r₁ = HornerExpr.ofCsexpr r₂) : r₁.eval t = r₂.eval t := by\n  repeat' rw [← (horner_expr.cseval_of_csexpr t _).2] <;> rw [H]\n#align tactic.ring2.correctness Tactic.Ring2.correctness\n\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/--\n      Reflects a csring expression into a `csring_expr`, together\n      with a dlist of atoms, i.e. opaque variables over which the\n      expression is a polynomial. -/\n    unsafe\n  def\n    reflect_expr\n    : expr → CsringExpr × Dlist expr\n    |\n        q( $ ( e₁ ) + $ ( e₂ ) )\n        =>\n        let\n          ( r₁ , l₁ ) := reflect_expr e₁\n          let ( r₂ , l₂ ) := reflect_expr e₂ ( r₁ . add r₂ , l₁ ++ l₂ )\n      |\n        q( $ ( e₁ ) * $ ( e₂ ) )\n        =>\n        let\n          ( r₁ , l₁ ) := reflect_expr e₁\n          let ( r₂ , l₂ ) := reflect_expr e₂ ( r₁ . mul r₂ , l₁ ++ l₂ )\n      |\n        e @ q( $ ( e₁ ) ^ $ ( e₂ ) )\n        =>\n        match\n          reflect_expr e₁ , expr.to_nat e₂\n          with\n          | ( r₁ , l₁ ) , some n₂ => ( r₁ . pow ( Num.ofNat' n₂ ) , l₁ )\n            | ( r₁ , l₁ ) , none => ( CsringExpr.atom 1 , Dlist.singleton e )\n      |\n        e\n        =>\n        match\n          expr.to_nat e\n          with\n          | some n => ( CsringExpr.const ( Num.ofNat' n ) , Dlist.empty )\n            | none => ( CsringExpr.atom 1 , Dlist.singleton e )\n#align tactic.ring2.reflect_expr tactic.ring2.reflect_expr\n\n/-- In the output of `reflect_expr`, `atom`s are initialized with incorrect indices.\nThe indices cannot be computed until the whole tree is built, so another pass over\nthe expressions is needed - this is what `replace` does. The computation (expressed\nin the state monad) fixes up `atom`s to match their positions in the atom tree.\nThe initial state is a list of all atom occurrences in the goal, left-to-right. -/\nunsafe def csring_expr.replace (t : Tree expr) : CsringExpr → StateT (List expr) Option CsringExpr\n  | csring_expr.atom _ => do\n    let e ← get\n    let p ← monadLift (t.indexOfₓ (· < ·) e.headI)\n    put e\n    pure (csring_expr.atom p)\n  | csring_expr.const n => pure (CsringExpr.const n)\n  | csring_expr.add x y => CsringExpr.add <$> x.replace <*> y.replace\n  | csring_expr.mul x y => CsringExpr.mul <$> x.replace <*> y.replace\n  | csring_expr.pow x n => (fun x => CsringExpr.pow x n) <$> x.replace\n#align tactic.ring2.csring_expr.replace tactic.ring2.csring_expr.replace\n\n--| (csring_expr.neg x)   := csring_expr.neg <$> x.replace\n--| (csring_expr.inv x)   := csring_expr.inv <$> x.replace\nend Tactic.Ring2\n\nnamespace Tactic\n\nnamespace Interactive\n\nopen Interactive Interactive.Types Lean.Parser\n\nopen Tactic.Ring2\n\n-- mathport name: parser.optional\nlocal postfix:1024 \"?\" => optional\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:330:4: warning: unsupported (TODO): `[tacs] -/\n-- failed to format: unknown constant 'term.pseudo.antiquot'\n/--\n      `ring2` solves equations in the language of rings.\n      \n      It supports only the commutative semiring operations, i.e. it does not normalize subtraction or\n      division.\n      \n        This variant on the `ring` tactic uses kernel computation instead\n        of proof generation. In general, you should use `ring` instead of `ring2`. -/\n    unsafe\n  def\n    ring2\n    : tactic Unit\n    :=\n      do\n        sorry\n          let\n            q( $ ( e₁ ) = $ ( e₂ ) )\n              ←\n              target\n              | fail \"ring2 tactic failed: the goal is not an equality\"\n          let α ← infer_type e₁\n          let expr.sort ( level.succ u ) ← infer_type α\n          let ( r₁ , l₁ ) := reflect_expr e₁\n          let ( r₂ , l₂ ) := reflect_expr e₂\n          let L := ( l₁ ++ l₂ ) . toList\n          let s := Tree.ofRBNode ( rbtreeOf L ) . 1\n          let ( r₁ , L ) ← ( StateT.run ( r₁ . replace s ) L : Option _ )\n          let ( r₂ , _ ) ← ( StateT.run ( r₂ . replace s ) L : Option _ )\n          let se : expr := s . reflect' u α\n          let er₁ : expr := reflect r₁\n          let er₂ : expr := reflect r₂\n          let cs ← mk_app ` ` CommSemiring [ α ] >>= mk_instance\n          let\n            e\n              ←\n              to_expr ` `( correctness $ ( se ) $ ( er₁ ) $ ( er₂ ) rfl )\n                <|>\n                fail\n                  (\n                    \"ring2 tactic failed, cannot show equality:\\n\"\n                          ++\n                          toString ( HornerExpr.ofCsexpr r₁ )\n                        ++\n                        \"\\n  =?=\\n\"\n                      ++\n                      toString ( HornerExpr.ofCsexpr r₂ )\n                    )\n          tactic.exact e\n#align tactic.interactive.ring2 tactic.interactive.ring2\n\nadd_tactic_doc\n  { Name := \"ring2\"\n    category := DocCategory.tactic\n    declNames := [`tactic.interactive.ring2]\n    tags := [\"arithmetic\", \"simplification\", \"decision procedure\"] }\n\nend Interactive\n\nend Tactic\n\nnamespace Conv.Interactive\n\nopen Conv\n\nunsafe def ring2 : conv Unit :=\n  discharge_eq_lhs tactic.interactive.ring2\n#align conv.interactive.ring2 conv.interactive.ring2\n\nend Conv.Interactive\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Tactic/Ring2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434873426302, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45453024035001366}}
{"text": "import data.equiv.basic\n\nnamespace random1\n\nvariables {α : Type} [partial_order α] [decidable_eq α] (M : α) (M_is_lb : ∀ a, M ≤ a)\n\nopen classical\nlocal attribute [instance] prop_decidable\n\ntheorem double_not (p : Prop) : ¬¬p ↔ p :=\n  begin\n  constructor,\n  intro h,\n  by_cases a : p, exact a, exfalso, exact h a,\n  intro h, intro not_p, exact not_p h,\n  end\n\ninclude M_is_lb\nlemma not_gt_equiv_eq : iff (¬ ∃ M', M' > M ∧ ∀ a, M' ≤ a) (¬¬∀ M', (∀ a, M' ≤ a) → M' = M) :=\n  begin\n  have : ∀ M', (M' > M ∧ ∀ a, M' ≤ a) ↔ ¬ ((∀ a, M' ≤ a) → M' = M),\n  {\n    intro M',\n    constructor,\n    {\n      intro h,\n      intro h',\n      apply ne_of_gt h.1,\n      exact h' h.2,\n    }, {\n      intro h,\n      by_cases meq : M' = M,\n      {\n        exfalso, apply h, intro, exact meq,\n      }, {\n        have : M' > M, exact lt_of_le_of_ne (M_is_lb M') (ne.symm meq),\n        constructor, exact this,\n        by_cases allfor : ∀ (a : α), M' ≤ a, exact allfor, cc,\n      }\n    }\n  },\n  simp only [this],\n  transitivity,\n  constructor,\n  exact forall_not_of_not_exists,\n  intro allfor, intro exist,\n  apply exists.elim exist,\n  intro M', intro h,\n  apply allfor M',\n  exact h,\n  constructor,\n  intro h, intro not_h, apply not_h,\n  intro M', exact (double_not _).1 (h M'),\n  intro h, intro M', intro not_concl,\n  apply h, intro concl,\n  exact not_concl (concl M'),\n  end\n\nend random1\n\n#print equiv\n\nuniverse u\n\ndef eqv (t d : Type u) : Prop := nonempty (t ≃ d)\ninstance Type.setoid : setoid (Type u) :=\n  { r := eqv\n  , iseqv := begin\n    constructor,\n    intro t,\n    apply nonempty.intro,\n    refl,\n    constructor,\n    intros t d,\n    intro e,\n    apply nonempty.elim e, intro e',\n    apply nonempty.intro,\n    exact equiv.symm e',\n    intros t d b,\n    intros e o,\n    apply nonempty.elim e, intro e',\n    apply nonempty.elim o, intro o',\n    apply nonempty.intro,\n    exact equiv.trans e' o',\n    end\n  }\n\ndef up2iso : Type (u+1) := quotient Type.setoid\ndef up2iso.mk : Type u → up2iso.{u} := @quotient.mk _ Type.setoid\n\nset_option pp.universes true\n\nlemma bool_eq_unit_sum_unit\n  : up2iso.mk bool = up2iso.mk (punit.{1} ⊕ punit.{1})\n  := quotient.sound $ nonempty.intro equiv.bool_equiv_unit_sum_unit\n", "meta": {"author": "MonoidMusician", "repo": "lean-math-stuff", "sha": "56e6ae80b4a634f23a90989a7156ce053a012acf", "save_path": "github-repos/lean/MonoidMusician-lean-math-stuff", "path": "github-repos/lean/MonoidMusician-lean-math-stuff/lean-math-stuff-56e6ae80b4a634f23a90989a7156ce053a012acf/src/random.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.45435952359458337}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.analysis.calculus.mean_value\nimport Mathlib.tactic.monotonicity.default\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Extending differentiability to the boundary\n\nWe investigate how differentiable functions inside a set extend to differentiable functions\non the boundary. For this, it suffices that the function and its derivative admit limits there.\nA general version of this statement is given in `has_fderiv_at_boundary_of_tendsto_fderiv`.\n\nOne-dimensional versions, in which one wants to obtain differentiability at the left endpoint or\nthe right endpoint of an interval, are given in\n`has_deriv_at_interval_left_endpoint_of_tendsto_deriv` and\n`has_deriv_at_interval_right_endpoint_of_tendsto_deriv`. These versions are formulated in terms\nof the one-dimensional derivative `deriv ℝ f`.\n-/\n\n/-- If a function `f` is differentiable in a convex open set and continuous on its closure, and its\nderivative converges to a limit `f'` at a point on the boundary, then `f` is differentiable there\nwith derivative `f'`. -/\ntheorem has_fderiv_at_boundary_of_tendsto_fderiv {E : Type u_1} [normed_group E] [normed_space ℝ E]\n    {F : Type u_2} [normed_group F] [normed_space ℝ F] {f : E → F} {s : set E} {x : E}\n    {f' : continuous_linear_map ℝ E F} (f_diff : differentiable_on ℝ f s) (s_conv : convex s)\n    (s_open : is_open s) (f_cont : ∀ (y : E), y ∈ closure s → continuous_within_at f s y)\n    (h : filter.tendsto (fun (y : E) => fderiv ℝ f y) (nhds_within x s) (nhds f')) :\n    has_fderiv_within_at f f' (closure s) x :=\n  sorry\n\n/-- If a function is differentiable on the right of a point `a : ℝ`, continuous at `a`, and\nits derivative also converges at `a`, then `f` is differentiable on the right at `a`. -/\ntheorem has_deriv_at_interval_left_endpoint_of_tendsto_deriv {E : Type u_1} [normed_group E]\n    [normed_space ℝ E] {s : set ℝ} {e : E} {a : ℝ} {f : ℝ → E} (f_diff : differentiable_on ℝ f s)\n    (f_lim : continuous_within_at f s a) (hs : s ∈ nhds_within a (set.Ioi a))\n    (f_lim' : filter.tendsto (fun (x : ℝ) => deriv f x) (nhds_within a (set.Ioi a)) (nhds e)) :\n    has_deriv_within_at f e (set.Ici a) a :=\n  sorry\n\n/-- If a function is differentiable on the left of a point `a : ℝ`, continuous at `a`, and\nits derivative also converges at `a`, then `f` is differentiable on the left at `a`. -/\ntheorem has_deriv_at_interval_right_endpoint_of_tendsto_deriv {E : Type u_1} [normed_group E]\n    [normed_space ℝ E] {s : set ℝ} {e : E} {a : ℝ} {f : ℝ → E} (f_diff : differentiable_on ℝ f s)\n    (f_lim : continuous_within_at f s a) (hs : s ∈ nhds_within a (set.Iio a))\n    (f_lim' : filter.tendsto (fun (x : ℝ) => deriv f x) (nhds_within a (set.Iio a)) (nhds e)) :\n    has_deriv_within_at f e (set.Iic a) a :=\n  sorry\n\n/-- If a real function `f` has a derivative `g` everywhere but at a point, and `f` and `g` are\ncontinuous at this point, then `g` is also the derivative of `f` at this point. -/\ntheorem has_deriv_at_of_has_deriv_at_of_ne {E : Type u_1} [normed_group E] [normed_space ℝ E]\n    {f : ℝ → E} {g : ℝ → E} {x : ℝ} (f_diff : ∀ (y : ℝ), y ≠ x → has_deriv_at f (g y) y)\n    (hf : continuous_at f x) (hg : continuous_at g x) : has_deriv_at f (g x) x :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/analysis/calculus/extend_deriv_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.4543379712288547}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin\n-/\nimport data.fintype.order\nimport order.category.LinearOrder\n\n/-!\n# Nonempty finite linear orders\n\nThis defines `NonemptyFinLinOrd`, the category of nonempty finite linear orders with monotone maps.\nThis is the index category for simplicial objects.\n-/\n\nuniverses u v\n\nopen category_theory\n\n/-- A typeclass for nonempty finite linear orders. -/\nclass nonempty_fin_lin_ord (α : Type*) extends fintype α, linear_order α :=\n(nonempty : nonempty α . tactic.apply_instance)\n\nattribute [instance] nonempty_fin_lin_ord.nonempty\n\n@[priority 100]\ninstance nonempty_fin_lin_ord.to_bounded_order (α : Type*) [nonempty_fin_lin_ord α] :\n  bounded_order α :=\nfintype.to_bounded_order α\n\ninstance punit.nonempty_fin_lin_ord : nonempty_fin_lin_ord punit :=\n{ .. punit.linear_ordered_cancel_add_comm_monoid,\n  .. punit.fintype }\n\ninstance fin.nonempty_fin_lin_ord (n : ℕ) : nonempty_fin_lin_ord (fin (n+1)) :=\n{ .. fin.fintype _,\n  .. fin.linear_order }\n\ninstance ulift.nonempty_fin_lin_ord (α : Type u) [nonempty_fin_lin_ord α] :\n  nonempty_fin_lin_ord (ulift.{v} α) :=\n{ nonempty := ⟨ulift.up ⊥⟩,\n  .. linear_order.lift equiv.ulift (equiv.injective _),\n  .. ulift.fintype _ }\n\ninstance (α : Type*) [nonempty_fin_lin_ord α] : nonempty_fin_lin_ord (order_dual α) :=\n{ ..order_dual.fintype α }\n\n/-- The category of nonempty finite linear orders. -/\ndef NonemptyFinLinOrd := bundled nonempty_fin_lin_ord\n\nnamespace NonemptyFinLinOrd\n\ninstance : bundled_hom.parent_projection @nonempty_fin_lin_ord.to_linear_order := ⟨⟩\n\nattribute [derive [large_category, concrete_category]] NonemptyFinLinOrd\n\ninstance : has_coe_to_sort NonemptyFinLinOrd Type* := bundled.has_coe_to_sort\n\n/-- Construct a bundled `NonemptyFinLinOrd` from the underlying type and typeclass. -/\ndef of (α : Type*) [nonempty_fin_lin_ord α] : NonemptyFinLinOrd := bundled.of α\n\ninstance : inhabited NonemptyFinLinOrd := ⟨of punit⟩\n\ninstance (α : NonemptyFinLinOrd) : nonempty_fin_lin_ord α := α.str\n\ninstance has_forget_to_LinearOrder : has_forget₂ NonemptyFinLinOrd LinearOrder :=\nbundled_hom.forget₂ _ _\n\n/-- Constructs an equivalence between nonempty finite linear orders from an order isomorphism\nbetween them. -/\n@[simps] def iso.mk {α β : NonemptyFinLinOrd.{u}} (e : α ≃o β) : α ≅ β :=\n{ hom := e,\n  inv := e.symm,\n  hom_inv_id' := by { ext, exact e.symm_apply_apply x },\n  inv_hom_id' := by { ext, exact e.apply_symm_apply x } }\n\n/-- `order_dual` as a functor. -/\n@[simps] def to_dual : NonemptyFinLinOrd ⥤ NonemptyFinLinOrd :=\n{ obj := λ X, of (order_dual X), map := λ X Y, order_hom.dual }\n\n/-- The equivalence between `FinPartialOrder` and itself induced by `order_dual` both ways. -/\n@[simps functor inverse] def dual_equiv : NonemptyFinLinOrd ≌ NonemptyFinLinOrd :=\nequivalence.mk to_dual to_dual\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n  (nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)\n\nend NonemptyFinLinOrd\n\nlemma NonemptyFinLinOrd_dual_equiv_comp_forget_to_LinearOrder :\n  NonemptyFinLinOrd.dual_equiv.functor ⋙ forget₂ NonemptyFinLinOrd LinearOrder\n  = forget₂ NonemptyFinLinOrd LinearOrder ⋙ LinearOrder.dual_equiv.functor := rfl\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/order/category/NonemptyFinLinOrd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482762, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.45433795796512993}}
{"text": "/-\nCopyright (c) 2017 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad\n\nThese tactics do straightforward things: they call the simplifier, split conjunctive assumptions,\neliminate existential quantifiers on the left, and look for contradictions. They rely on ematching\nand congruence closure to try to finish off a goal at the end.\n\nThe procedures *do* split on disjunctions and recreate the smt state for each terminal call, so\nthey are only meant to be used on small, straightforward problems.\n\nWe provide the following tactics:\n\n  finish  -- solves the goal or fails\n  clarify -- makes as much progress as possible while not leaving more than one goal\n  safe    -- splits freely, finishes off whatever subgoals it can, and leaves the rest\n\nAll accept an optional list of simplifier rules, typically definitions that should be expanded.\n(The equations and identities should not refer to the local context.)\n\nThe variants ifinish, iclarify, and isafe restrict to intuitionistic logic. They do not work\nwell with the current heuristic instantiation method used by ematch, so they should be revisited\nwhen the API changes.\n-/\nimport logic.basic\n\ndeclare_trace auto.done\ndeclare_trace auto.finish\n\n-- TODO(Jeremy): move these\n\n\nnamespace tactic\n\n/- call (assert n t) with a fresh name n. -/\nmeta def assert_fresh (t : expr) : tactic expr :=\ndo n ← get_unused_name `h none,\n   assert n t\n\n/- call (assertv n t v) with a fresh name n. -/\nmeta def assertv_fresh (t : expr) (v : expr) : tactic expr :=\ndo h ← get_unused_name `h none,\n   assertv h t v\n\nnamespace interactive\n\nmeta def revert_all := tactic.revert_all\n\nend interactive\n\nend tactic\n\nopen tactic expr\n\nnamespace auto\n\n/- Utilities -/\n\nmeta def whnf_reducible (e : expr) : tactic expr := whnf e reducible\n\n-- stolen from interactive.lean\nmeta def add_simps : simp_lemmas → list name → tactic simp_lemmas\n| s []      := return s\n| s (n::ns) := do s' ← s.add_simp n, add_simps s' ns\n\n/-\n  Configuration information for the auto tactics.\n-/\n\nstructure auto_config : Type :=\n(use_simp := tt)           -- call the simplifier\n(classical := tt)          -- use classical logic\n(max_ematch_rounds := 20)  -- for the \"done\" tactic\n\n/-\n  Preprocess goal.\n\n  We want to move everything to the left of the sequent arrow. For intuitionistic logic,\n  we replace the goal p with ∀ f, (p → f) → f and introduce.\n-/\n\ntheorem by_contradiction_trick (p : Prop) (h : ∀ f : Prop, (p → f) → f) : p :=\nh p id\n\nmeta def preprocess_goal (cfg : auto_config) : tactic unit :=\ndo repeat (intro1 >> skip),\n   tgt ← target >>= whnf_reducible,\n   if (¬ (is_false tgt)) then\n     if cfg.classical then\n       (mk_mapp ``classical.by_contradiction [some tgt]) >>= apply >> intro1 >> skip\n     else\n       (mk_mapp ``decidable.by_contradiction [some tgt, none] >>= apply >> intro1 >> skip) <|>\n       applyc ``by_contradiction_trick >> intro1 >> intro1 >> skip\n   else\n     skip\n\n/-\n  Normalize hypotheses. Bring conjunctions to the outside (for splitting),\n  bring universal quantifiers to the outside (for ematching). The classical normalizer\n  eliminates a → b in favor of ¬ a ∨ b.\n\n  For efficiency, we push negations inwards from the top down. (For example, consider\n  simplifying ¬ ¬ (p ∨ q).)\n-/\n\nsection\n\nuniverse u\nvariable  {α : Type u}\nvariables (p q : Prop)\nvariable  (s : α → Prop)\n\nlocal attribute [instance] classical.prop_decidable\ntheorem not_not_eq : (¬ ¬ p) = p := propext not_not\ntheorem not_and_eq : (¬ (p ∧ q)) = (¬ p ∨ ¬ q) := propext not_and_distrib\ntheorem not_or_eq : (¬ (p ∨ q)) = (¬ p ∧ ¬ q) := propext not_or_distrib\ntheorem not_forall_eq : (¬ ∀ x, s x) = (∃ x, ¬ s x) := propext not_forall\ntheorem not_exists_eq : (¬ ∃ x, s x) = (∀ x, ¬ s x) := propext not_exists\ntheorem not_implies_eq : (¬ (p → q)) = (p ∧ ¬ q) := propext not_imp\n\ntheorem classical.implies_iff_not_or : (p → q) ↔ (¬ p ∨ q) := imp_iff_not_or\n\nend\n\ndef common_normalize_lemma_names : list name :=\n[``bex_def, ``forall_and_distrib, ``exists_imp_distrib, ``or.assoc, ``or.comm, ``or.left_comm,\n  ``and.assoc, ``and.comm, ``and.left_comm]\n\ndef classical_normalize_lemma_names : list name :=\ncommon_normalize_lemma_names ++ [``classical.implies_iff_not_or]\n\n-- optionally returns an equivalent expression and proof of equivalence\nprivate meta def transform_negation_step (cfg : auto_config) (e : expr) :\n  tactic (option (expr × expr)) :=\ndo e ← whnf_reducible e,\n   match e with\n   | `(¬ %%ne) :=\n      (do ne ← whnf_reducible ne,\n      match ne with\n      | `(¬ %%a)      := do pr ← mk_app ``not_not_eq [a],\n                            return (some (a, pr))\n      | `(%%a ∧ %%b)  := do pr ← mk_app ``not_and_eq [a, b],\n                            return (some (`(¬ %%a ∨ ¬ %%b), pr))\n      | `(%%a ∨ %%b)  := do pr ← mk_app ``not_or_eq [a, b],\n                            return (some (`(¬ %%a ∧ ¬ %%b), pr))\n      | `(Exists %%p) := do pr ← mk_app ``not_exists_eq [p],\n                            `(%%_ = %%e') ← infer_type pr,\n                            return (some (e', pr))\n      | (pi n bi d p) := if ¬ cfg.classical then return none\n                         else if p.has_var then do\n                            pr ← mk_app ``not_forall_eq [lam n bi d (expr.abstract_local p n)],\n                            `(%%_ = %%e') ← infer_type pr,\n                            return (some (e', pr))\n                         else do\n                            pr ← mk_app ``not_implies_eq [d, p],\n                            `(%%_ = %%e') ← infer_type pr,\n                            return (some (e', pr))\n      | _             := return none\n      end)\n    | _        := return none\n  end\n\n-- given an expr 'e', returns a new expression and a proof of equality\nprivate meta def transform_negation (cfg : auto_config) : expr → tactic (option (expr × expr)) :=\nλ e, do\n  opr ← transform_negation_step cfg e,\n  match opr with\n  | (some (e', pr)) := do\n    opr' ← transform_negation e',\n    match opr' with\n    | none              := return (some (e', pr))\n    | (some (e'', pr')) := do pr'' ← mk_eq_trans pr pr',\n                              return (some (e'', pr''))\n    end\n  | none            := return none\n  end\n\nmeta def normalize_negations (cfg : auto_config) (h : expr) : tactic unit :=\ndo t ← infer_type h,\n   (_, e, pr) ← simplify_top_down ()\n                   (λ _, λ e, do\n                       oepr ← transform_negation cfg e,\n                       match oepr with\n                       | (some (e', pr)) := return ((), e', pr)\n                       | none            := do pr ← mk_eq_refl e, return ((), e, pr)\n                       end)\n                   t,\n   replace_hyp h e pr,\n   skip\n\nmeta def normalize_hyp (cfg : auto_config) (simps : simp_lemmas) (h : expr) : tactic unit :=\n(do h ← simp_hyp simps [] h, try (normalize_negations cfg h)) <|>\ntry (normalize_negations cfg h)\n\nmeta def normalize_hyps (cfg : auto_config) : tactic unit :=\ndo simps ← if cfg.classical then\n             add_simps simp_lemmas.mk classical_normalize_lemma_names\n           else\n             add_simps simp_lemmas.mk common_normalize_lemma_names,\n   local_context >>= monad.mapm' (normalize_hyp cfg simps)\n\n/-\n  Eliminate existential quantifiers.\n-/\n\n-- eliminate an existential quantifier if there is one\nmeta def eelim : tactic unit :=\ndo ctx ← local_context,\n   first $ ctx.map $ λ h,\n     do t ← infer_type h >>= whnf_reducible,\n        guard (is_app_of t ``Exists),\n        tgt ← target,\n        to_expr ``(@exists.elim _ _ %%tgt %%h) >>= apply,\n        intros,\n        clear h\n\n-- eliminate all existential quantifiers, fails if there aren't any\nmeta def eelims : tactic unit := eelim >> repeat eelim\n\n/-\n  Substitute if there is a hypothesis x = t or t = x.\n-/\n\n-- carries out a subst if there is one, fails otherwise\nmeta def do_subst : tactic unit :=\ndo ctx ← local_context,\n   first $ ctx.map $ λ h,\n     do t ← infer_type h >>= whnf_reducible,\n        match t with\n        | `(%%a = %%b) := subst h\n        | _            := failed\n        end\n\nmeta def do_substs : tactic unit := do_subst >> repeat do_subst\n\n/-\n  Split all conjunctions.\n-/\n\n-- Assumes pr is a proof of t. Adds the consequences of t to the context\n-- and returns tt if anything nontrivial has been added.\nmeta def add_conjuncts : expr → expr → tactic bool :=\nλ pr t,\nlet assert_consequences := λ e t, mcond (add_conjuncts e t) skip (assertv_fresh t e >> skip) in\ndo t' ← whnf_reducible t,\n   match t' with\n   | `(%%a ∧ %%b) :=\n     do e₁ ← mk_app ``and.left [pr],\n        assert_consequences e₁ a,\n        e₂ ← mk_app ``and.right [pr],\n        assert_consequences e₂ b,\n        return tt\n  | `(true) :=\n     do return tt\n  | _ := return ff\nend\n\n-- return tt if any progress is made\nmeta def split_hyp (h : expr) : tactic bool :=\ndo t ← infer_type h,\n   mcond (add_conjuncts h t) (clear h >> return tt) (return ff)\n\n-- return tt if any progress is made\nmeta def split_hyps_aux : list expr → tactic bool\n| []        := return ff\n| (h :: hs) := do b₁ ← split_hyp h,\n                  b₂ ← split_hyps_aux hs,\n                  return (b₁ || b₂)\n\n-- fail if no progress is made\nmeta def split_hyps : tactic unit := local_context >>= split_hyps_aux >>= guardb\n\n/-\n  Eagerly apply all the preprocessing rules.\n-/\n\nmeta def preprocess_hyps (cfg : auto_config) : tactic unit :=\ndo repeat (intro1 >> skip),\n   preprocess_goal cfg,\n   normalize_hyps cfg,\n   repeat (do_substs <|> split_hyps <|> eelim /-<|> self_simplify_hyps-/)\n\n/-\n  The terminal tactic, used to try to finish off goals:\n  - Call the contradiction tactic.\n  - Open an SMT state, and use ematching and congruence closure, with all the universal\n    statements in the context.\n\n  TODO(Jeremy): allow users to specify attribute for ematching lemmas?\n-/\n\nmeta def mk_hinst_lemmas : list expr → smt_tactic hinst_lemmas\n| []        := -- return hinst_lemmas.mk\n               do get_hinst_lemmas_for_attr `ematch\n| (h :: hs) := do his ← mk_hinst_lemmas hs,\n                  t ← infer_type h,\n                  match t with\n                  | (pi _ _ _ _) :=\n                    do t' ← infer_type t,\n                       if t' = `(Prop) then\n                          (do new_lemma ← hinst_lemma.mk h,\n                             return (hinst_lemmas.add his new_lemma)) <|> return his\n                       else return his\n                  | _ := return his\n                  end\n\nmeta def done (cfg : auto_config := {}) : tactic unit :=\ndo when_tracing `auto.done (trace \"entering done\" >> trace_state),\n   contradiction <|>\n   (solve1 $\n     (do revert_all,\n         using_smt\n         (do smt_tactic.intros,\n             ctx ← local_context,\n             hs ← mk_hinst_lemmas ctx,\n             smt_tactic.iterate_at_most cfg.max_ematch_rounds\n               (smt_tactic.ematch_using hs >> smt_tactic.try smt_tactic.close))))\n\n/-\n  Tactics that perform case splits.\n-/\n\ninductive case_option\n| force        -- fail unless all goals are solved\n| at_most_one  -- leave at most one goal\n| accept       -- leave as many goals as necessary\n\nprivate meta def case_cont (s : case_option) (cont : case_option → tactic unit) : tactic unit :=\ndo match s with\n   | case_option.force := cont case_option.force >> cont case_option.force\n   | case_option.at_most_one :=\n       -- if the first one succeeds, commit to it, and try the second\n       (mcond (cont case_option.force >> return tt) (cont case_option.at_most_one) skip) <|>\n       -- otherwise, try the second\n       (swap >> cont case_option.force >> cont case_option.at_most_one)\n   | case_option.accept := focus [cont case_option.accept, cont case_option.accept]\n   end\n\n-- three possible outcomes:\n--   finds something to case, the continuations succeed ==> returns tt\n--   finds something to case, the continutations fail ==> fails\n--   doesn't find anything to case ==> returns ff\nmeta def case_hyp (h : expr) (s : case_option) (cont : case_option → tactic unit) : tactic bool :=\ndo t ← infer_type h,\n   match t with\n   | `(%%a ∨ %%b) := cases h >> case_cont s cont >> return tt\n   | _            := return ff\n   end\n\nmeta def case_some_hyp_aux (s : case_option) (cont : case_option → tactic unit) :\n  list expr → tactic bool\n| []      := return ff\n| (h::hs) := mcond (case_hyp h s cont) (return tt) (case_some_hyp_aux hs)\n\nmeta def case_some_hyp (s : case_option) (cont : case_option → tactic unit) : tactic bool :=\nlocal_context >>= case_some_hyp_aux s cont\n\n/-\n  The main tactics.\n-/\n\nmeta def safe_core (s : simp_lemmas × list name) (cfg : auto_config) : case_option → tactic unit :=\nλ co, focus1 $\ndo when_tracing `auto.finish (trace \"entering safe_core\" >> trace_state),\n   if cfg.use_simp then do\n     when_tracing `auto.finish (trace \"simplifying hypotheses\"),\n     simp_all s.1 s.2 { fail_if_unchanged := ff },\n     when_tracing `auto.finish (trace \"result:\" >> trace_state)\n   else skip,\n   tactic.done <|>\n   do when_tracing `auto.finish (trace \"preprocessing hypotheses\"),\n      preprocess_hyps cfg,\n      when_tracing `auto.finish (trace \"result:\" >> trace_state),\n      done cfg <|>\n        (mcond (case_some_hyp co safe_core)\n          skip\n          (match co with\n            | case_option.force       := done cfg\n            | case_option.at_most_one := try (done cfg)\n            | case_option.accept      := try (done cfg)\n            end))\n\nmeta def clarify (s : simp_lemmas × list name) (cfg : auto_config := {}) : tactic unit :=\n  safe_core s cfg case_option.at_most_one\nmeta def safe (s : simp_lemmas × list name) (cfg : auto_config := {}) : tactic unit :=\n  safe_core s cfg case_option.accept\nmeta def finish (s : simp_lemmas × list name) (cfg : auto_config := {}) : tactic unit :=\n  safe_core s cfg case_option.force\n\nmeta def iclarify (s : simp_lemmas × list name) (cfg : auto_config := {}) : tactic unit :=\n  clarify s {classical := ff, ..cfg}\nmeta def isafe (s : simp_lemmas × list name) (cfg : auto_config := {}) : tactic unit :=\n  safe s {classical := ff, ..cfg}\nmeta def ifinish (s : simp_lemmas × list name) (cfg : auto_config := {}) : tactic unit :=\n  finish s {classical := ff, ..cfg}\n\nend auto\n\n/- interactive versions -/\n\nopen auto\n\nnamespace tactic\nnamespace interactive\n\nopen lean lean.parser interactive interactive.types\n\nlocal postfix `?`:9001 := optional\nlocal postfix *:9001 := many\n\nmeta def clarify (hs : parse simp_arg_list) (cfg : auto_config := {}) : tactic unit :=\ndo s ← mk_simp_set ff [] hs,\n   auto.clarify s cfg\n\nmeta def safe (hs : parse simp_arg_list) (cfg : auto_config := {}) : tactic unit :=\ndo s ← mk_simp_set ff [] hs,\n   auto.safe s cfg\n\nmeta def finish (hs : parse simp_arg_list) (cfg : auto_config := {}) : tactic unit :=\ndo s ← mk_simp_set ff [] hs,\n   auto.finish s cfg\n\nmeta def iclarify (hs : parse simp_arg_list) (cfg : auto_config := {}) : tactic unit :=\ndo s ← mk_simp_set ff [] hs,\n   auto.iclarify s cfg\n\nmeta def isafe (hs : parse simp_arg_list) (cfg : auto_config := {}) : tactic unit :=\ndo s ← mk_simp_set ff [] hs,\n   auto.isafe s cfg\n\nmeta def ifinish (hs : parse simp_arg_list) (cfg : auto_config := {}) : tactic unit :=\ndo s ← mk_simp_set ff [] hs,\n   auto.ifinish s cfg\n\nend interactive\nend tactic\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/tactic/finish.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316860482763, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.454337953574877}}
{"text": "/-\nCopyright (c) 2018 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot, Johannes Hölzl\n\nCompletion of topological groups:\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.uniform_space.completion\nimport Mathlib.topology.algebra.uniform_group\nimport Mathlib.PostPort\n\nuniverses u u_1 v \n\nnamespace Mathlib\n\nprotected instance uniform_space.completion.has_zero {α : Type u} [uniform_space α] [HasZero α] : HasZero (uniform_space.completion α) :=\n  { zero := ↑0 }\n\nprotected instance uniform_space.completion.has_neg {α : Type u} [uniform_space α] [Neg α] : Neg (uniform_space.completion α) :=\n  { neg := uniform_space.completion.map fun (a : α) => -a }\n\nprotected instance uniform_space.completion.has_add {α : Type u} [uniform_space α] [Add α] : Add (uniform_space.completion α) :=\n  { add := uniform_space.completion.map₂ Add.add }\n\nprotected instance uniform_space.completion.has_sub {α : Type u} [uniform_space α] [Sub α] : Sub (uniform_space.completion α) :=\n  { sub := uniform_space.completion.map₂ Sub.sub }\n\n-- TODO: switch sides once #1103 is fixed\n\ntheorem uniform_space.completion.coe_zero {α : Type u} [uniform_space α] [HasZero α] : ↑0 = 0 :=\n  rfl\n\nnamespace uniform_space.completion\n\n\ntheorem coe_neg {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] (a : α) : ↑(-a) = -↑a :=\n  Eq.symm (map_coe uniform_continuous_neg a)\n\ntheorem coe_sub {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] (a : α) (b : α) : ↑(a - b) = ↑a - ↑b :=\n  Eq.symm (map₂_coe_coe a b Sub.sub uniform_continuous_sub)\n\ntheorem coe_add {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] (a : α) (b : α) : ↑(a + b) = ↑a + ↑b :=\n  Eq.symm (map₂_coe_coe a b Add.add uniform_continuous_add)\n\nprotected instance sub_neg_monoid {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : sub_neg_monoid (completion α) :=\n  sub_neg_monoid.mk Add.add sorry 0 sorry sorry Neg.neg Sub.sub\n\nprotected instance add_group {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : add_group (completion α) :=\n  add_group.mk sub_neg_monoid.add sorry sub_neg_monoid.zero sorry sorry sub_neg_monoid.neg sub_neg_monoid.sub sorry\n\nprotected instance uniform_add_group {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : uniform_add_group (completion α) :=\n  uniform_add_group.mk (uniform_continuous_map₂ Sub.sub)\n\nprotected instance is_add_group_hom_coe {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] : is_add_group_hom coe :=\n  is_add_group_hom.mk\n\ntheorem is_add_group_hom_extension {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] {β : Type v} [uniform_space β] [add_group β] [uniform_add_group β] [complete_space β] [separated_space β] {f : α → β} [is_add_group_hom f] (hf : continuous f) : is_add_group_hom (completion.extension f) :=\n  (fun (hf : uniform_continuous f) => is_add_group_hom.mk) (uniform_continuous_of_continuous hf)\n\ntheorem is_add_group_hom_map {α : Type u_1} [uniform_space α] [add_group α] [uniform_add_group α] {β : Type v} [uniform_space β] [add_group β] [uniform_add_group β] {f : α → β} [is_add_group_hom f] (hf : continuous f) : is_add_group_hom (completion.map f) :=\n  is_add_group_hom_extension (continuous.comp (continuous_coe β) hf)\n\nprotected instance add_comm_group {α : Type u} [uniform_space α] [add_comm_group α] [uniform_add_group α] : add_comm_group (completion α) :=\n  add_comm_group.mk add_group.add sorry add_group.zero sorry sorry add_group.neg add_group.sub sorry sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/algebra/group_completion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4542588064740874}}
{"text": "import topology.algebra.infinite_sum\nimport analysis.normed_space.basic\nimport topology.instances.ennreal\nimport analysis.specific_limits.normed\n\n/- These are lemmas that are used in the proof of either auxilliary facts for Theorem 6.9 or\nfor Theorem 6.9 directly. -/\n\nopen function metric finset nnreal normed_field\nopen_locale nnreal classical big_operators topological_space\n\nnamespace aux_thm69\n\nsection group_add_neg\nvariables {G : Type*} [group G]\n\n/--  If `G` is a group and `g ∈ G` is an element, then `equiv.group_mul g` is the self-equivalence\nof `G` defined by `h ↦ g * h`. -/\n@[to_additive \"If `G` is an additive group and `g ∈ G` is an element, then `equiv.add_group_add g`\nis the self-equivalence of `G` defined by `h ↦ g + h`.\"]\ndef equiv.group_mul (g : G) : G ≃ G :=\n  ⟨λ x, g * x, λ x, g⁻¹ * x, by { intro, simp }, by { intro, simp }⟩\n\n@[simp, to_additive]\nlemma equiv.group_mul_apply {g h : G} : equiv.group_mul g h = g * h := rfl\n\n@[simp, to_additive]\nlemma equiv.group_mul_symm_apply {g h : G} : (equiv.group_mul g).symm h = g⁻¹ * h := rfl\n\nvariables [has_le G] [covariant_class G G ((*)) (≤)]\n\n@[to_additive]\nlemma aux_ineq_mul {d e x : G} (hx : d ≤ x) : e ≤ e * d⁻¹ * x :=\ncalc  e ≤ e * (d⁻¹ * x) : le_mul_of_one_le_right' (le_inv_mul_iff_le.mpr hx)\n    ... = e * d⁻¹ * x   : (mul_assoc _ _ _).symm\n\n/--  If `G` is a group and `d e : G`. then `mul_inv_fun d e` is the function mapping\n`{x // d ≤ x}` to `{x // e ≤ x}` defined by `x ↦ e * d⁻¹ * x`. -/\n@[to_additive \"If `G` is an additive group and `d e : G`. then `add_neg_fun d e` is the function\nmapping `{x // d ≤ x}` to `{x // e ≤ x}` defined by `x ↦ e + (- d) + x`.\"]\ndef mul_inv_fun (d e : G) : {x // d ≤ x} → {x // e ≤ x} :=\nλ ⟨x, hx⟩, ⟨_, aux_ineq_mul hx⟩\n\n@[to_additive]\nlemma mul_inv_fun_def (d e : G) (z : {x // d ≤ x}) :\n  mul_inv_fun d e z = ⟨_, aux_ineq_mul z.2⟩ :=\nby { cases z, simp [mul_inv_fun] }\n\n@[simp, to_additive]\nlemma mul_inv_fun_comp (d e f : G) : mul_inv_fun e f ∘ mul_inv_fun d e = mul_inv_fun d f :=\nby { funext, simp [mul_inv_fun_def, mul_assoc] }\n\n@[simp, to_additive]\nlemma mul_inv_fun_comp_id (d e : G) : mul_inv_fun e d ∘ mul_inv_fun d e = id :=\nby { funext, simp [mul_inv_fun_def] }\n\n@[simp, to_additive]\nlemma mul_inv_fun_comp_id_apply (d e : G) (z : {x // d ≤ x}) :\n  mul_inv_fun e d (mul_inv_fun d e z) = z :=\nby simp [mul_inv_fun_def, mul_assoc]\n\n/--  The function `mul_inv_fun d e` bundled as an equivalence `{x // d ≤ x} ≃ {x // e ≤ x}`. -/\n@[to_additive \"The function `add_neg_fun d e` bundled as an equivalence\n`{x // d ≤ x} ≃ {x // e ≤ x}`.\"]\ndef equiv.mul_inv (d e : G) : {x // d ≤ x} ≃ {x // e ≤ x} :=\n{ to_fun    := mul_inv_fun d e,\n  inv_fun   := mul_inv_fun e d,\n  left_inv  := λ z, by simp,\n  right_inv := λ z, by simp }\n\n@[simp, to_additive]\nlemma equiv.mul_inv_eval (d e : G) (x : {x // d ≤ x}) :\n  equiv.mul_inv d e x = ⟨e * d⁻¹ * x, aux_ineq_mul x.2⟩ :=\nby { cases x with x hx, simpa }\n\n@[simp, to_additive]\nlemma equiv.mul_inv_rev (d e : G) :\n  (equiv.mul_inv d e).symm = equiv.mul_inv e d := rfl\n\nend group_add_neg\n\n/--  The subtype of nonnegative integers is equivalent to the natural numbers. -/\ndef int_subtype_nonneg_equiv : {x : ℤ // 0 ≤ x} ≃ ℕ :=\n{ to_fun := begin\n    rintro ⟨x | y, hx⟩,\n    { exact x },\n    { exact ((int.neg_succ_not_nonneg _).mp hx).elim }\n  end,\n  inv_fun := λ x, ⟨x, int.coe_zero_le x⟩,\n  left_inv := begin\n    rintro ⟨x | y, hx⟩,\n    { simp only [int.of_nat_eq_coe, subtype.coe_mk] },\n    { exact ((int.neg_succ_not_nonneg _).mp hx).elim }\n  end,\n  right_inv := λ x, rfl }\n\n@[simp]\nlemma int_subtype_nonneg_equiv_eval {z : {x : ℤ // 0 ≤ x}} :\n  int_subtype_nonneg_equiv z = int.to_nat z :=\nbegin\n  rcases z with ⟨x | y, hz⟩,\n  { refl },\n  { exact ((int.neg_succ_not_nonneg _).mp hz).elim }\nend\n\n@[simp]\nlemma int.to_nat_subtype_nonneg {z : {x : ℤ // 0 ≤ x}} :\n  ((z : ℤ).to_nat : ℤ) = z :=\nbegin\n  cases z with x hz,\n  simp [int.to_nat_of_nonneg hz],\nend\n\n@[simp]\nlemma int_subtype_nonneg_equiv_symm_eval {n : ℕ} : (int_subtype_nonneg_equiv.symm n : ℤ) = n := rfl\n\n/--  The subtype of nonnegative integers is equivalent to the natural number. -/\ndef int.nonneg_equiv_nat (d : ℤ) : {x : ℤ // d ≤ x} ≃ ℕ :=\n(equiv.add_neg d 0).trans int_subtype_nonneg_equiv\n\n/--  The subtype of nonnegative integers is equivalent to the natural number. -/\ndef nat.le_equiv_nat (d : ℕ) : {x // d ≤ x} ≃ ℕ :=\n{ to_fun    := λ x, x.1 - d,\n  inv_fun   := λ x, ⟨x + d, le_add_self⟩,\n  left_inv  := by { rintro ⟨x, hx⟩, simp only [nat.sub_add_cancel hx] },\n  right_inv := λ x, by simp }\n\n/--  The \"identity\" is an equivalence between the complement of the set of non-negative integers\nand the negative integers. -/\ndef compl_le : ↥(set_of ((≤) (0 : ℤ)))ᶜ ≃ {z : ℤ // z < 0} :=\n{ to_fun    := by { rintro ⟨a, ha⟩, exact ⟨a, by simpa using ha⟩ },\n  inv_fun   := by { rintro ⟨a, ha⟩, exact ⟨a, by simpa using ha⟩ },\n  left_inv  := by { rintro ⟨a, ha⟩, simp },\n  right_inv := by { rintro ⟨a, ha⟩, simp } }\n\n@[simp]\nlemma compl_le_symm_eval {x : {z : ℤ // z < 0}} :\n  (compl_le.symm x : ℤ) = x :=\nby { cases x with x hx, refl }\n\nsection group\nvariables (α : Type*)\n\nsection one_lt\nvariables [group α] [has_lt α] [covariant_class α α (*) (<)]\n\n/--  Taking inverses establishes an isomorphism between the elements of a group that are\nstrictly smaller than `1` with the elements that are strictly larger than `1`. -/\n@[to_additive \"Taking opposites establishes an isomorphism between the elements of an additive\ngroup that are strictly smaller than `0` with the elements that are strictly larger than `0`.\"]\ndef equiv.lt_one_gt_one : {z : α | z < 1} ≃ {z : α | 1 < z} :=\n{ to_fun    := by { rintro ⟨z, hz⟩, exact ⟨z⁻¹, by simpa⟩ },\n  inv_fun   := by { rintro ⟨z, hz⟩, exact ⟨z⁻¹, by simpa⟩ },\n  left_inv  := by { rintro ⟨z, hz⟩, simp },\n  right_inv := by { rintro ⟨z, hz⟩, simp } }\n\nvariable {α}\n@[simp, to_additive]\nlemma equiv.lt_one_gt_one_eval {x : {z : α | z < 1}} :\n  ((equiv.lt_one_gt_one α) x : α) = x⁻¹ :=\nby { cases x with x hx, refl }\n\n@[simp, to_additive]\nlemma equiv.lt_one_gt_one_symm_eval {x : {z : α | 1 < z}} :\n  ((equiv.lt_one_gt_one α).symm x : α) = x⁻¹ :=\nby { cases x with x hx, refl }\n\nend one_lt\n\nsection one_le\nvariables [group α] [has_le α] [covariant_class α α (*) (≤)]\n\n/--  Taking inverses establishes an isomorphism between the elements of a group that are\nat most `1` with the elements that are at least `1`. -/\n@[to_additive \"Taking opposites establishes an isomorphism between the elements of an additive\ngroup that are strictly at most `0` with the elements that are at least `0`.\"]\ndef equiv.le_one_ge_one : {z : α | z ≤ 1} ≃ {z : α | 1 ≤ z} :=\n{ to_fun    := by { rintro ⟨z, hz⟩, exact ⟨z⁻¹, by simpa⟩ },\n  inv_fun   := by { rintro ⟨z, hz⟩, exact ⟨z⁻¹, by simpa⟩ },\n  left_inv  := by { rintro ⟨z, hz⟩, simp },\n  right_inv := by { rintro ⟨z, hz⟩, simp } }\n\n\nvariable {α}\n\n@[simp, to_additive]\nlemma equiv.le_one_ge_one_eval {x : {z : α | z ≤ 1}} :\n  ((equiv.le_one_ge_one α) x : α) = x⁻¹ :=\nby { cases x with x hx, refl }\n\n@[simp, to_additive]\nlemma equiv.le_one_ge_one_symm_eval {x : {z : α | 1 ≤ z}} :\n  ((equiv.le_one_ge_one α).symm x : α) = x⁻¹ :=\nby { cases x with x hx, refl }\n\nend one_le\n\nend group\n\n/--  An equivalence between the complement of the non-negative integers and the natural numbers. -/\ndef oppo : ({z : ℤ | 0 ≤ z}ᶜ : set ℤ) ≃ ℕ :=\ncompl_le.trans $ (equiv.neg_gt_zero ℤ).trans $ (equiv.add_neg 1 0).trans int_subtype_nonneg_equiv\n\n@[simp]\nlemma oppo_symm_eval {n : ℕ} : (oppo.symm n : ℤ) = - n - 1 :=\nby simp [oppo]\n\nsection topological_space\nvariables {α : Type*} [topological_space α]\n\nsection add_comm_monoid\nvariables [add_comm_monoid α] {f : ℤ → α}\n\nlemma my_summable_shift (f : ℤ → α) (N : ℤ) :\n  summable (λ x : ℕ, f (x + N)) ↔ summable (λ x : {x // N ≤ x}, f x) :=\nbegin\n  convert (int_subtype_nonneg_equiv.symm.trans (equiv.add_neg 0 N)).summable_iff,\n  ext,\n  simp [add_comm],\nend\n\nend add_comm_monoid\n\nend topological_space\n\nsection uniform\nvariables {α : Type*} [uniform_space α] [add_comm_group α] [uniform_add_group α] [complete_space α]\nvariable {f : ℤ → α}\n\nlemma int_summable_iff :\n  summable f ↔ summable (λ n : ℕ, f n) ∧ summable (λ n : ℕ, f (- n - 1)) :=\nbegin\n  refine (@summable_subtype_and_compl α _ _ _ _ _ _ {z : ℤ | 0 ≤ z}).symm.trans _,\n  rw [← equiv.summable_iff int_subtype_nonneg_equiv, ← equiv.summable_iff oppo.symm],\n  refine ⟨_, _⟩;\n  rintro ⟨h1, h2⟩;\n  refine ⟨_, _⟩;\n  refine summable.congr ‹_› (λ b, _);\n  simp only [oppo_symm_eval, int_subtype_nonneg_equiv_eval, function.comp_app];\n  { apply congr_arg, simp [b.2] }\nend\n\nend uniform\n\nlemma _root_.summable.smaller_radius {f : ℕ → ℝ} {ρ σ : ℝ≥0}\n  (hf : summable (λ n, f n * ρ ^ n)) (σρ : σ ≤ ρ) (f0 : ∀ n, 0 ≤ f n) :\n  summable (λ n, f n * σ ^ n) :=\nbegin\n  refine summable_of_nonneg_of_le (λ b, mul_nonneg (f0 _) (pow_nonneg zero_le_coe _)) _ hf,\n  exact λ b, mul_le_mul rfl.le\n    (pow_le_pow_of_le_left zero_le_coe σρ b) (pow_nonneg zero_le_coe b) (f0 b)\nend\n\n/--  A technical equivalence, useful in the proof of `prod_nat_summable_1`. -/\ndef equiv_nat_diag : {x : ℕ × ℕ // x.2 ≤ x.1} ≃ ℕ × ℕ :=\n{ to_fun    := λ x, (x.1.1 - x.1.2, x.1.2 ),\n  inv_fun   := λ x, ⟨(x.1 + x.2, x.2), by simp⟩,\n  left_inv  := by { rintros ⟨x, hx⟩, simp only [nat.sub_add_cancel hx, prod.mk.eta] },\n  right_inv := by { rintros ⟨x, y⟩, simp only [add_tsub_cancel_right] } }\n\nlemma _root_.summable.prod_nat {f : ℤ → ℝ} {g : ℕ → ℝ} (hf : summable f) (f0 : ∀ n, 0 ≤ f n)\n  (hg : summable g) (g0 : ∀ n, 0 ≤ g n) :\n  summable (λ lj: ℕ × ℕ, f (lj.fst + lj.snd) * g lj.snd) :=\nbegin\n  apply (equiv.summable_iff equiv_nat_diag).mp,\n  suffices : summable (λ (lj : {x : ℕ × ℕ // x.2 ≤ x.1}), f lj.1.fst * g lj.1.snd),\n  { convert this,\n    ext ⟨⟨x, y⟩, hx⟩,\n    suffices : f (↑(x - y) + ↑y) * g y = f ↑x * g y, by simpa [equiv_nat_diag],\n    rw_mod_cast nat.sub_add_cancel hx },\n  apply summable.subtype (_ : summable (λ (lj : ℕ × ℕ), f lj.fst * g lj.snd)),\n  convert summable_mul_of_summable_norm (_ : summable (λ i : ℕ, ∥f i∥)) _,\n  { conv { congr, funext, rw [real.norm_of_nonneg (f0 _)] },\n    apply ((int_summable_iff).mp hf).1 },\n  { conv { congr, funext, rw [real.norm_of_nonneg (g0 _)] },\n    exact hg }\nend\n\nlemma prod_nat_summable_aux {f : ℤ → ℝ} {s r : ℝ≥0}\n  (s1 : s < 1) (hf : summable (λ n : ℤ, ∥ f n ∥ * r ^ n)) :\n  summable (λ lj: ℕ × ℕ, ∥(f (lj.fst + 1 + lj.snd)) * r ^ (lj.fst + 1 + lj.snd)∥ * s^ lj.snd) :=\nbegin\n  apply summable_of_summable_norm,\n  simp_rw [norm_mul, norm_norm],\n  convert (_ : summable (λ n, ∥f (n + 1)∥ * r ^ (n + 1))).prod_nat _ (by simpa) (pow_nonneg s.2),\n  { simpa only [norm_pow, norm_eq, val_eq_coe, add_right_comm _ (1 : ℤ), add_right_comm _ 1 _] },\n  { let add_one : ℤ ≃ ℤ := ⟨λ x, x - 1, λ x, x + 1, λ x, by simp, λ x, by simp⟩,\n    apply add_one.summable_iff.mp,\n    convert hf,\n    ext,\n    simp },\n  { exact λ n, mul_nonneg (norm_nonneg _) (zpow_nonneg r.2 _) },\nend\n\nend aux_thm69\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/laurent_measures/int_nat_shifts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6187804337438501, "lm_q2_score": 0.734119521083126, "lm_q1q2_score": 0.45425879567564414}}
{"text": "import Smt\n\ntheorem modus_ponens (p q : Bool) : p → (p → q) → q := by\n  smt\n  simp_all\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Test/Bool/ModusPonens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.4542230885996121}}
{"text": "lemma contrapositive (P Q : Prop) : (P → Q) → (¬ Q → ¬ P) :=\nbegin\nrepeat {rw not_iff_imp_false},\nintros a b c,\nexact b(a(c)),\nend\n", "meta": {"author": "chanha-park", "repo": "naturalNumberGame", "sha": "4e0d7100ce4575e1add92feefa38b1250431b879", "save_path": "github-repos/lean/chanha-park-naturalNumberGame", "path": "github-repos/lean/chanha-park-naturalNumberGame/naturalNumberGame-4e0d7100ce4575e1add92feefa38b1250431b879/Proposition/8.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.454223088599612}}
{"text": "import category_theory.category\nimport category_theory.colimits\nimport category_theory.colimit_lemmas\nimport category_theory.types\n\nimport .homeomorphism\nimport .subspace\n\nopen set\n\nopen category_theory\nlocal notation f ` ∘ `:80 g:80 := g ≫ f\n\nuniverse u\n\nnamespace homotopy_theory.topological_spaces\n\nnamespace Set\nlocal notation `Set` := Type u\n\ndef mk_ob (α : Set) : Set := α\n\ndef incl' {α : Set} (A B : set α) (h : A ⊆ B) : mk_ob A ⟶ mk_ob B :=\nλ p, ⟨p.val, h p.property⟩\n\nsection inter_union\nvariables {X : Set} {A₀ A₁ : set X}\n\nlocal notation `A₀₁` := A₀ ∩ A₁\nlocal notation `A` := (A₀ ∪ A₁ : set X)\n\nlocal notation `i₀` := incl' A₀₁ A₀ (set.inter_subset_left A₀ A₁)\nlocal notation `i₁` := incl' A₀₁ A₁ (set.inter_subset_right A₀ A₁)\nlocal notation `j₀` := incl' A₀ A (set.subset_union_left A₀ A₁)\nlocal notation `j₁` := incl' A₁ A (set.subset_union_right A₀ A₁)\n\nsection glue\nvariables ⦃β : Set⦄ (h₀ : mk_ob A₀ ⟶ β) (h₁ : mk_ob A₁ ⟶ β)\nvariable (e : h₀ ∘ i₀ = h₁ ∘ i₁)\ninclude e\n\nlocal attribute [instance] classical.prop_decidable\n\nnoncomputable def glue : mk_ob A ⟶ β :=\nλ a, if h : a.val ∈ A₀ then h₀ ⟨a.val, h⟩ else h₁ ⟨a.val, a.property.resolve_left h⟩\n\nlemma glue_commutes₀ : glue h₀ h₁ e ∘ j₀ = h₀ :=\nby funext a; have := a.property; simp [glue, incl', this]\n\nlemma glue_commutes₁ : glue h₀ h₁ e ∘ j₁ = h₁ :=\nbegin\n  funext a, change (if h : _ then _ else _) = h₁ a, cases a with v p,\n  split_ifs, { exact congr_fun e ⟨v, h, p⟩ }, { refl }\nend\n\nend glue\n\nlemma uniqueness ⦃β : Set⦄ (k k' : mk_ob A ⟶ β)\n  (e₀ : k ∘ j₀ = k' ∘ j₀) (e₁ : k ∘ j₁ = k' ∘ j₁) : k = k' :=\nbegin\n  funext a, rcases a with ⟨v, p₀|p₁⟩,\n  { exact @@congr_fun _ _ _ e₀ ⟨v, p₀⟩ },\n  { exact @@congr_fun _ _ _ e₁ ⟨v, p₁⟩ }\nend\n\nvariables (A₀ A₁)\ninclude A₀ A₁\nnoncomputable def Is_pushout_inter_union : Is_pushout i₀ i₁ j₀ j₁ :=\nIs_pushout.mk' rfl glue glue_commutes₀ glue_commutes₁ uniqueness\n\nend inter_union\n\nend «Set»\n\n\nnamespace Top\nlocal notation `Top` := Top.{u}\n\nsection inter_union\nvariables {X : Top} {A₀ A₁ : set X} (ha₀ : is_closed A₀) (ha₁ : is_closed A₁)\n-- Other assumptions are possible, e.g., A₀, A₁ both open.\n\nlocal notation `A₀₁` := A₀ ∩ A₁\nlocal notation `A` := (A₀ ∪ A₁ : set X)\n\nlocal notation `i₀` := incl' A₀₁ A₀ (set.inter_subset_left A₀ A₁)\nlocal notation `i₁` := incl' A₀₁ A₁ (set.inter_subset_right A₀ A₁)\nlocal notation `j₀` := incl' A₀ A (set.subset_union_left A₀ A₁)\nlocal notation `j₁` := incl' A₁ A (set.subset_union_right A₀ A₁)\nlocal notation `i'₀` := Set.incl' A₀₁ A₀ (set.inter_subset_left A₀ A₁)\nlocal notation `i'₁` := Set.incl' A₀₁ A₁ (set.inter_subset_right A₀ A₁)\nlocal notation `j'₀` := Set.incl' A₀ A (set.subset_union_left A₀ A₁)\nlocal notation `j'₁` := Set.incl' A₁ A (set.subset_union_right A₀ A₁)\n\nlocal notation [parsing_only] a ` ~~ ` b := Bij_on _ a b\n\ninstance Set.mk_ob.topological_space (α : Type*) [t : topological_space α] :\n  topological_space (Set.mk_ob α) := t\n\nlemma continuous_iff {Z : Top} (k : A → Z) :\n  continuous k ↔ continuous (k ∘ j'₀) ∧ continuous (k ∘ j'₁) :=\niff.intro (assume h, ⟨by continuity!, by continuity!⟩)\n  (assume ⟨h₀, h₁⟩,\n    let c : bool → set A := λ i, bool.rec_on i {a | a.val ∈ A₀} {a | a.val ∈ A₁} in\n    have h_lf : locally_finite c :=\n      locally_finite_of_finite ⟨fintype.of_equiv _ (equiv.set.univ bool).symm⟩,\n    have h_is_closed : ∀ i, is_closed (c i) :=\n      assume i, bool.rec_on i\n        (continuous_iff_is_closed.mp continuous_subtype_val _ ha₀)\n        (continuous_iff_is_closed.mp continuous_subtype_val _ ha₁),\n    have h_cover : ∀ a, ∃ i, a ∈ c i :=\n      assume a, a.property.elim (λ h, ⟨ff, h⟩) (λ h, ⟨tt, h⟩),\n    have f_cont : ∀ i, continuous (λ (x : subtype (c i)), k x.val) :=\n      assume i, bool.rec_on i\n        (have continuous (function.comp (k ∘ j'₀) (λ (x : subtype (c ff)), ⟨x.val.val, x.property⟩)),\n          by continuity, begin convert this, funext x, rcases x with ⟨⟨_, _⟩, _⟩, refl end)\n        (have continuous (function.comp (k ∘ j'₁) (λ (x : subtype (c tt)), ⟨x.val.val, x.property⟩)),\n          by continuity, begin convert this, funext x, rcases x with ⟨⟨_, _⟩, _⟩, refl end),\n    continuous_subtype_is_closed_cover c h_lf h_is_closed h_cover f_cont)\n\nvariables (A₀ A₁)\ninclude A₀ A₁\nnoncomputable def Is_pushout_inter_union : Is_pushout i₀ i₁ j₀ j₁ :=\nIs_pushout.mk $ λ Z, calc\n  univ ~~ {k : {k : A → Z // continuous k} | true}\n       : Bij_on.of_equiv (Top.hom_equiv_subtype (Top.mk_ob A) Z)\n   ... ~~ {k : {k : A → Z // continuous (k ∘ j'₀) ∧ continuous (k ∘ j'₁)} | true}\n       : Bij_on.congr_subtype (ext (continuous_iff ha₀ ha₁))\n   ... ~~ {p : {p : (A₀ → Z) × (A₁ → Z) // continuous p.1 ∧ continuous p.2} | p.val.1 ∘ i'₀ = p.val.2 ∘ i'₁}\n       : ((Set.Is_pushout_inter_union A₀ A₁).universal Z).restrict_to_subtype (λ p, continuous p.1 ∧ continuous p.2)\n   ... ~~ {p : {f₀ : Top.mk_ob A₀ → Z // continuous f₀} ×\n               {f₁ : Top.mk_ob A₁ → Z // continuous f₁} |\n           (Top.hom_equiv_subtype _ _).symm p.1 ∘ i₀ = (Top.hom_equiv_subtype _ _).symm p.2 ∘ i₁}\n       : by { convert Bij_on.restrict_equiv equiv.subtype_prod_subtype_equiv_subtype.symm _,\n              ext, simp only [Top.hom_eq2], refl }\n   ... ~~ {p : (Top.mk_ob A₀ ⟶ Z) × (Top.mk_ob A₁ ⟶ Z) | p.1 ∘ i₀ = p.2 ∘ i₁}\n       : by {\n           convert Bij_on.restrict_equiv\n             ((Top.hom_equiv_subtype (Top.mk_ob A₀) Z).prod_congr\n              (Top.hom_equiv_subtype (Top.mk_ob A₁) Z)).symm\n             _,\n           ext ⟨_, _⟩, refl }\n\nlocal notation `k₀` := incl A₀\nlocal notation `k₁` := incl A₁\nvariables (h : A₀ ∪ A₁ = univ)\n\ninclude h\ndef union_is_X : homeomorphism (Top.mk_ob A) X :=\n{ hom := incl _,\n  inv := Top.mk_hom (λ x, ⟨x, by rw h; exact trivial⟩) (by continuity),\n  hom_inv_id' := by ext p; cases p; refl,\n  inv_hom_id' := by ext p; refl }\n\nnoncomputable def Is_pushout_inter_of_cover : Is_pushout i₀ i₁ k₀ k₁ :=\nIs_pushout_of_isomorphic'\n  (Is_pushout_inter_union A₀ A₁ ha₀ ha₁) (union_is_X A₀ A₁ h)\n\nend inter_union\n\nend «Top»\n\nend homotopy_theory.topological_spaces\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/homotopy_theory/topological_spaces/inter_union.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6406358548398982, "lm_q1q2_score": 0.45422307887025726}}
{"text": "/- This defines an hmac primitive.\n -/\nimport galois.word\nimport galois.tactic.nat\nimport galois.bitvec.join\nimport galois.crypto.sha2\n\nnamespace crypto\n\ndefinition hmac {olen : ℕ} -- ^ Output length\n                (blen : ℕ) -- ^ Block length\n                (hash : list byte → vector byte olen)\n                (key : list byte)\n                (msg : list byte)\n                : vector byte olen :=\n  let klen := list.length key in\n  let padded_key :=\n        if blen ≥ klen then\n          key ++ list.repeat 0 (blen - klen)\n        else\n          key ++ list.repeat 0 (blen - olen) in\n  let ki := list.map (bitvec.xor 54) padded_key in\n  let ko := list.map (bitvec.xor 92) padded_key in\n  hash (ko ++ (hash (ki ++ msg))^.to_list)\n\nend crypto\n\nnamespace hmac\n\n/- hash_algorithm -/\n\ninductive hash_algorithm\n  | sha1      : hash_algorithm\n  | sha2_256  : hash_algorithm\n  | ripemd160 : hash_algorithm\n  | sha2_224  : hash_algorithm\n  | sha2_384  : hash_algorithm\n  | sha2_512  : hash_algorithm\n  | sha3_224  : hash_algorithm\n  | sha3_256  : hash_algorithm\n  | sha3_384  : hash_algorithm\n  | sha3_512  : hash_algorithm\n  | sm3       : hash_algorithm\n\nnamespace hash_algorithm\n\nprotected def to_string : hash_algorithm → string\n| sha1 := \"sha1\"\n| sha2_256 := \"sha2_256\"\n| ripemd160 := \"ripemd160\"\n| sha2_224 := \"sha2_224\"\n| sha2_384 := \"sha2_384\"\n| sha2_512 := \"sha2_512\"\n| sha3_224 := \"sha3_224\"\n| sha3_256 := \"sha3_256\"\n| sha3_384 := \"sha3_384\"\n| sha3_512 := \"sha3_512\"\n| sm3      := \"sm3\"\n\ninstance : has_to_string hash_algorithm := ⟨ hash_algorithm.to_string ⟩\n\n/- hash length in bytes -/\ndefinition hash_length : hash_algorithm → ℕ\n  | sha1      := 20\n  | sha2_256  := 32\n  | ripemd160 := 20\n  | sha2_224  := 28\n  | sha2_384  := 48\n  | sha2_512  := 64\n  | sha3_224  := 28\n  | sha3_256  := 32\n  | sha3_384  := 48\n  | sha3_512  := 64\n  | sm3       := 32\n\nlemma max_hash_length (algo : hash_algorithm) : algo.hash_length ≤ 64 :=\nbegin\n  cases algo,\n  all_goals { dunfold hash_length },\n  all_goals { galois.tactic.nat.nat_lit_le },\nend\n\n/- block length in bytes -/\ndefinition block_length (algo : hash_algorithm) : ℕ :=\n  match algo with\n  | sha1      :=  64\n  | sha2_256  :=  64\n  | ripemd160 :=  64\n  | sha2_224  :=  64\n  | sha2_384  := 128\n  | sha2_512  := 128\n  | sha3_224  := 144\n  | sha3_256  := 136\n  | sha3_384  := 104\n  | sha3_512  :=  72\n  | sm3       :=  64\n  end\n\ndefinition encode (algo : hash_algorithm) : byte :=\n  match algo with\n  | sha1      := 0x0\n  | sha2_256  := 0x1\n  | ripemd160 := 0x2\n  | sha2_224  := 0x3\n  | sha2_384  := 0x4\n  | sha2_512  := 0x5\n  | sha3_224  := 0x7\n  | sha3_256  := 0x8\n  | sha3_384  := 0x9\n  | sha3_512  := 0xA\n  | sm3       := 0xB\n  end\n\ndefinition decode (w : byte) : option hash_algorithm :=\n  if w = 0x0 then\n    some sha1\n  else if w = 0x1 then\n    some sha2_256\n  else if w = 0x2 then\n    some ripemd160\n  else if w = 0x3 then\n    some sha2_224\n  else if w = 0x4 then\n    some sha2_384\n  else if w = 0x5 then\n    some sha2_512\n  else if w = 0x7 then\n    some sha3_224\n  else if w = 0x8 then\n    some sha3_256\n  else if w = 0x9 then\n    some sha3_384\n  else if w = 0xA then\n    some sha3_512\n  else if w = 0xB then\n    some sm3\n  else\n    none\n\n@[simp]\nlemma decode_encode (a : hash_algorithm) : decode (encode a) = some a :=\nbegin\n  cases a,\n  simp [encode, decode],\n  all_goals {\n    simp [encode, decode],\n    smt_tactic.execute smt_tactic.solve_goals\n  }\nend\n\ninstance : decidable_eq hash_algorithm := by tactic.mk_dec_eq_instance\n\n------------------------------------------------------------------------\n-- hash\n\n-- | Helper function to speed up length proofs below\ndef to_byte_list (m : ℕ) (v : bitvec (8 * m)) : list byte := cast rfl (@bitvec.split_vector 8 m v)\n\nprotected\nlemma length_to_byte_list (m : ℕ) (v : bitvec (8 * m)) : (to_byte_list m v).length = m :=\nvector.length_split_vector _ _\n\ndef nat_224_decompose : bitvec 224 → list byte := @to_byte_list 28\ndef nat_256_decompose : bitvec 256 → list byte := @to_byte_list 32\ndef nat_384_decompose : bitvec 384 → list byte := @to_byte_list 48\ndef nat_512_decompose : bitvec 512 → list byte := @to_byte_list 64\n\ndefinition hash : hash_algorithm → list byte → list byte\n| sha2_256  data := nat_256_decompose (crypto.sha256 data)\n| sha2_224  data := nat_224_decompose (crypto.sha224 data)\n| sha2_384  data := nat_384_decompose (crypto.sha384 data)\n| sha2_512  data := nat_512_decompose (crypto.sha512 data)\n| algo data := list.repeat 0 (algo.hash_length)\n\ntheorem length_hash_is_hash_length\n: ∀ (algo : hash_algorithm) (data : list byte),\n    (algo.hash data).length = algo.hash_length\n| sha1      data := list.length_repeat _ _\n| sha2_256  data := hash_algorithm.length_to_byte_list _ _\n| ripemd160 data := list.length_repeat _ _\n| sha2_224  data := hash_algorithm.length_to_byte_list _ _\n| sha2_384  data := hash_algorithm.length_to_byte_list _ _\n| sha2_512  data := hash_algorithm.length_to_byte_list _ _\n| sha3_224  data := list.length_repeat _ _\n| sha3_256  data := list.length_repeat _ _\n| sha3_384  data := list.length_repeat _ _\n| sha3_512  data := list.length_repeat _ _\n| sm3       data := list.length_repeat _ _\n\n-- Hash the data using the given algorithm.\ndefinition hashv (algo : hash_algorithm) (data : list byte) : vector byte algo.hash_length :=\n  ⟨ hash algo data, length_hash_is_hash_length algo data ⟩\n\nend hash_algorithm\n\nend hmac\n\n\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/crypto/hmac.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4542230788702572}}
{"text": "import Runtime.Network.Graph.Path.Subpaths\n\nnamespace Network.Graph.Path\n\ndef Succ (path₁ path₂ : Path graph start) :=\n  path₁.prefix? = path₂\n\ninfix:35 \" ≻ \" => Succ\n\ntheorem Succ.isCons : (path₁ ≻ path₂) → path₁.isCons :=\n  fun h => prefix?_isSome_iff_isCons.mp (Option.isSome_iff_exists.mpr ⟨_, h⟩)\n\ntheorem Succ.isCons' : (cons c₁ (cons c₂ path₁) ≻ path₂) → path₂.isCons := by\n  intro h\n  have ⟨subpath, hp⟩ := prefix?_isSome_iff_isCons.mpr (@isCons_of_cons _ _ c₂ path₁) |> Option.isSome_iff_exists.mp\n  simp [Succ, prefix?, hp] at h\n  simp [isCons_def]\n  exists c₁, subpath\n  injection h with h\n  exact h.symm\n\ntheorem Succ.iff_cons_Succ {path₁ path₂} : \n  (path₁ ≻ path₂) ↔ (cons child path₁) ≻ (cons child path₂) :=\n  prefix?_iff_cons_prefix?\n\ntheorem Succ.nil : (cons child nil) ≻ nil := rfl\n\ninstance : Decidable (path₁ ≻ path₂) := \n  if h : path₁.prefix? = path₂ then isTrue h else isFalse h\n\ntheorem Succ.cons (path₁) : ∃ path₂, (cons child path₁) ≻ path₂ := by\n  cases h : (Path.cons child path₁).prefix?\n  case none =>\n    have h : ¬(Path.cons child path₁).prefix?.isSome := by simp_all [Option.isSome_iff_exists]\n    have := mt prefix?_isSome_iff_isCons.mpr h\n    contradiction\n  case some pre => exists pre\n\nend Network.Graph.Path", "meta": {"author": "lf-lang", "repo": "reactor-lean", "sha": "d2eb5458446af838be34ebb6f69549b2f6d9c04d", "save_path": "github-repos/lean/lf-lang-reactor-lean", "path": "github-repos/lean/lf-lang-reactor-lean/reactor-lean-d2eb5458446af838be34ebb6f69549b2f6d9c04d/Runtime/Network/Graph/Path/Succ.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.45422307701886133}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport algebra.homology.image_to_kernel_map\n\n/-!\n# Exact sequences\n\nIn a category with zero morphisms, images, and equalizers we say that `f : A ⟶ B` and `g : B ⟶ C`\nare exact if `f ≫ g = 0` and the natural map `image f ⟶ kernel g` is an epimorphism.\n\nThis definition is equivalent to the homology at `B` vanishing (at least for preadditive\ncategories). At this level of generality, this is not necessarily equivalent to other reasonable\ndefinitions of exactness, for example that the inclusion map `image.ι f` is a kernel of `g` or that\nthe map `image f ⟶ kernel g` is an isomorphism. By adding more assumptions on our category, we get\nthese equivalences and more. Currently, there is one particular set of assumptions mathlib knows\nabout: abelian categories. Consequently, many interesting results about exact sequences are found in\n`category_theory/abelian/exact.lean`.\n\n# Main results\n* Suppose that cokernels exist and that `f` and `g` are exact. If `s` is any kernel fork over `g`\n  and `t` is any cokernel cofork over `f`, then `fork.ι s ≫ cofork.π t = 0`.\n* Precomposing the first morphism with an epimorphism retains exactness. Postcomposing the second\n  morphism with a monomorphism retains exactness.\n* If `f` and `g` are exact and `i` is an isomorphism, then `f ≫ i.hom` and `i.inv ≫ g` are also\n  exact.\n\n# Future work\n* Short exact sequences, split exact sequences, the splitting lemma (maybe only for abelian\n  categories?)\n* Two adjacent maps in a chain complex are exact iff the homology vanishes\n\n-/\n\nuniverses v u\n\nopen category_theory\nopen category_theory.limits\n\nvariables {V : Type u} [category.{v} V] [has_zero_morphisms V]\nvariables [has_equalizers V] [has_images V]\n\nnamespace category_theory\n\n/-- Two morphisms `f : A ⟶ B`, `g : B ⟶ C` are called exact if `f ≫ g = 0` and the natural map\n    `image f ⟶ kernel g` is an epimorphism. -/\nclass exact {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Prop :=\n(w : f ≫ g = 0)\n(epi : epi (image_to_kernel_map f g w))\n\nattribute [instance] exact.epi\nattribute [simp, reassoc] exact.w\n\nsection\nvariables {A B C D : V} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\n\nlemma exact_comp_hom_inv_comp [exact f g] (i : B ≅ D) : exact (f ≫ i.hom) (i.inv ≫ g) :=\nbegin\n  refine ⟨by simp, _⟩,\n  rw image_to_kernel_map_comp_hom_inv_comp,\n  haveI : epi (image_to_kernel_map f g exact.w ≫ (kernel_is_iso_comp i.inv g).inv) := epi_comp _ _,\n  exact epi_comp _ _\nend\n\nlemma exact_comp_hom_inv_comp_iff (i : B ≅ D) : exact (f ≫ i.hom) (i.inv ≫ g) ↔ exact f g :=\nbegin\n  refine ⟨_, by { introI, exact exact_comp_hom_inv_comp i }⟩,\n  introI,\n  have : exact ((f ≫ i.hom) ≫ i.inv) (i.hom ≫ i.inv ≫ g) := exact_comp_hom_inv_comp i.symm,\n  simpa using this\nend\n\nlemma exact_epi_comp [exact g h] [epi f] : exact (f ≫ g) h :=\nbegin\n  refine ⟨by simp, _⟩,\n  rw image_to_kernel_map_comp_left,\n  suffices : epi (image.pre_comp f g),\n  { exactI epi_comp _ _ },\n  apply epi_of_epi_fac (limits.image.factor_thru_image_pre_comp _ _),\n  exact epi_comp _ _\nend\n\nlemma exact_comp_mono [exact f g] [mono h] : exact f (g ≫ h) :=\nbegin\n  refine ⟨by simp, _⟩,\n  letI : is_iso (kernel.lift (g ≫ h) (kernel.ι g) (by simp)) :=\n    ⟨⟨kernel.lift g (kernel.ι (g ≫ h)) (by simp [←cancel_mono h]), by tidy⟩⟩,\n  rw image_to_kernel_map_comp_right f g h exact.w,\n  exact epi_comp _ _\nend\n\nlemma exact_kernel : exact (kernel.ι f) f :=\nbegin\n  refine ⟨kernel.condition _, _⟩,\n  letI : is_iso (image_to_kernel_map (kernel.ι f) f (kernel.condition f)) :=\n    ⟨⟨factor_thru_image (kernel.ι f),\n      ⟨by simp [←cancel_mono (image.ι (kernel.ι f))], by tidy⟩⟩⟩,\n  apply_instance\nend\n\nsection\nvariables (A)\n\nlemma kernel_ι_eq_zero_of_exact_zero_left [exact (0 : A ⟶ B) g] : kernel.ι g = 0 :=\nbegin\n  rw [←cancel_epi (image_to_kernel_map (0 : A ⟶ B) g exact.w),\n    ←cancel_epi (factor_thru_image (0 : A ⟶ B))],\n  simp\nend\n\nlemma exact_zero_left_of_mono [has_zero_object V] [mono g] : exact (0 : A ⟶ B) g :=\n⟨by simp, image_to_kernel_map_epi_of_zero_of_mono _⟩\n\nend\n\nend\n\nsection has_cokernels\nvariables [has_cokernels V] {A B C : V} (f : A ⟶ B) (g : B ⟶ C)\n\n@[simp, reassoc] lemma kernel_comp_cokernel [exact f g] : kernel.ι g ≫ cokernel.π f = 0 :=\nzero_of_epi_comp (image_to_kernel_map f g exact.w) $ zero_of_epi_comp (factor_thru_image f) $\n  by simp\n\nlemma comp_eq_zero_of_exact [exact f g] {X Y : V} {ι : X ⟶ B} (hι : ι ≫ g = 0) {π : B ⟶ Y}\n  (hπ : f ≫ π = 0) : ι ≫ π = 0 :=\nby rw [←kernel.lift_ι _ _ hι, ←cokernel.π_desc _ _ hπ, category.assoc, kernel_comp_cokernel_assoc,\n  zero_comp, comp_zero]\n\n@[simp, reassoc] lemma fork_ι_comp_cofork_π [exact f g] (s : kernel_fork g)\n  (t : cokernel_cofork f) : fork.ι s ≫ cofork.π t = 0 :=\ncomp_eq_zero_of_exact f g (kernel_fork.condition s) (cokernel_cofork.condition t)\n\nend has_cokernels\n\nsection\nlocal attribute [instance] has_zero_object.has_zero\n\nlemma exact_of_zero [has_zero_object V] {A C : V} (f : A ⟶ 0) (g : 0 ⟶ C) : exact f g :=\nbegin\n  obtain rfl : f = 0 := by ext,\n  obtain rfl : g = 0 := by ext,\n  fsplit,\n  { simp, },\n  { exact image_to_kernel_map_epi_of_zero_of_mono 0, },\nend\n\nend\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/algebra/homology/exact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4541917740655559}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Scott Morrison, Jakob von Raumer\n-/\nimport category_theory.monoidal.braided\nimport category_theory.closed.monoidal\nimport algebra.category.Module.basic\nimport linear_algebra.tensor_product\nimport category_theory.linear.yoneda\nimport category_theory.monoidal.linear\n\n/-!\n# The symmetric monoidal category structure on R-modules\n\nMostly this uses existing machinery in `linear_algebra.tensor_product`.\nWe just need to provide a few small missing pieces to build the\n`monoidal_category` instance and then the `symmetric_category` instance.\n\nNote the universe level of the modules must be at least the universe level of the ring,\nso that we have a monoidal unit.\nFor now, we simplify by insisting both universe levels are the same.\n\nWe then construct the monoidal closed structure on `Module R`.\n\nIf you're happy using the bundled `Module R`, it may be possible to mostly\nuse this as an interface and not need to interact much with the implementation details.\n-/\n\nuniverses u\n\nopen category_theory\n\nnamespace Module\n\nvariables {R : Type u} [comm_ring R]\n\nnamespace monoidal_category\n-- The definitions inside this namespace are essentially private.\n-- After we build the `monoidal_category (Module R)` instance,\n-- you should use that API.\n\nopen_locale tensor_product\nlocal attribute [ext] tensor_product.ext\n\n/-- (implementation) tensor product of R-modules -/\ndef tensor_obj (M N : Module R) : Module R := Module.of R (M ⊗[R] N)\n/-- (implementation) tensor product of morphisms R-modules -/\ndef tensor_hom {M N M' N' : Module R} (f : M ⟶ N) (g : M' ⟶ N') :\n  tensor_obj M M' ⟶ tensor_obj N N' :=\ntensor_product.map f g\n\nlemma tensor_id (M N : Module R) : tensor_hom (𝟙 M) (𝟙 N) = 𝟙 (Module.of R (↥M ⊗ ↥N)) :=\nby tidy\n\nlemma tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : Module R}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :\n    tensor_hom (f₁ ≫ g₁) (f₂ ≫ g₂) = tensor_hom f₁ f₂ ≫ tensor_hom g₁ g₂ :=\nby tidy\n\n/-- (implementation) the associator for R-modules -/\ndef associator (M N K : Module R) : tensor_obj (tensor_obj M N) K ≅ tensor_obj M (tensor_obj N K) :=\nlinear_equiv.to_Module_iso (tensor_product.assoc R M N K)\n\nsection\n\n/-! The `associator_naturality` and `pentagon` lemmas below are very slow to elaborate.\n\nWe give them some help by expressing the lemmas first non-categorically, then using\n`convert _aux using 1` to have the elaborator work as little as possible. -/\n\nopen tensor_product (assoc map)\n\nprivate lemma associator_naturality_aux\n  {X₁ X₂ X₃ : Type*}\n  [add_comm_monoid X₁] [add_comm_monoid X₂] [add_comm_monoid X₃]\n  [module R X₁] [module R X₂] [module R X₃]\n  {Y₁ Y₂ Y₃ : Type*}\n  [add_comm_monoid Y₁] [add_comm_monoid Y₂] [add_comm_monoid Y₃]\n  [module R Y₁] [module R Y₂] [module R Y₃]\n  (f₁ : X₁ →ₗ[R] Y₁) (f₂ : X₂ →ₗ[R] Y₂) (f₃ : X₃ →ₗ[R] Y₃) :\n  (↑(assoc R Y₁ Y₂ Y₃) ∘ₗ (map (map f₁ f₂) f₃)) = ((map f₁ (map f₂ f₃)) ∘ₗ ↑(assoc R X₁ X₂ X₃)) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl\nend\n\nvariables (R)\n\nprivate lemma pentagon_aux\n  (W X Y Z : Type*)\n  [add_comm_monoid W] [add_comm_monoid X] [add_comm_monoid Y] [add_comm_monoid Z]\n  [module R W] [module R X] [module R Y] [module R Z] :\n  ((map (1 : W →ₗ[R] W) (assoc R X Y Z).to_linear_map).comp (assoc R W (X ⊗[R] Y) Z).to_linear_map)\n    .comp (map ↑(assoc R W X Y) (1 : Z →ₗ[R] Z)) =\n  (assoc R W X (Y ⊗[R] Z)).to_linear_map.comp (assoc R (W ⊗[R] X) Y Z).to_linear_map :=\nbegin\n  apply tensor_product.ext_fourfold,\n  intros w x y z,\n  refl\nend\n\nend\n\nlemma associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : Module R}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :\n    tensor_hom (tensor_hom f₁ f₂) f₃ ≫ (associator Y₁ Y₂ Y₃).hom =\n    (associator X₁ X₂ X₃).hom ≫ tensor_hom f₁ (tensor_hom f₂ f₃) :=\nby convert associator_naturality_aux f₁ f₂ f₃ using 1\n\nlemma pentagon (W X Y Z : Module R) :\n  tensor_hom (associator W X Y).hom (𝟙 Z) ≫ (associator W (tensor_obj X Y) Z).hom\n  ≫ tensor_hom (𝟙 W) (associator X Y Z).hom =\n    (associator (tensor_obj W X) Y Z).hom ≫ (associator W X (tensor_obj Y Z)).hom :=\nby convert pentagon_aux R W X Y Z using 1\n\n/-- (implementation) the left unitor for R-modules -/\ndef left_unitor (M : Module.{u} R) : Module.of R (R ⊗[R] M) ≅ M :=\n(linear_equiv.to_Module_iso (tensor_product.lid R M) : of R (R ⊗ M) ≅ of R M).trans (of_self_iso M)\n\n\n\n/-- (implementation) the right unitor for R-modules -/\ndef right_unitor (M : Module.{u} R) : Module.of R (M ⊗[R] R) ≅ M :=\n(linear_equiv.to_Module_iso (tensor_product.rid R M) : of R (M ⊗ R) ≅ of R M).trans (of_self_iso M)\n\nlemma right_unitor_naturality {M N : Module R} (f : M ⟶ N) :\n  tensor_hom f (𝟙 (Module.of R R)) ≫ (right_unitor N).hom = (right_unitor M).hom ≫ f :=\nbegin\n  ext x y, simp,\n  erw [tensor_product.rid_tmul, tensor_product.rid_tmul],\n  rw linear_map.map_smul,\n  refl,\nend\n\nlemma triangle (M N : Module.{u} R) :\n  (associator M (Module.of R R) N).hom ≫ tensor_hom (𝟙 M) (left_unitor N).hom =\n    tensor_hom (right_unitor M).hom (𝟙 N) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  change R at y,\n  dsimp [tensor_hom, associator],\n  erw [tensor_product.lid_tmul, tensor_product.rid_tmul],\n  exact (tensor_product.smul_tmul _ _ _).symm\nend\n\nend monoidal_category\n\nopen monoidal_category\n\ninstance monoidal_category : monoidal_category (Module.{u} R) :=\n{ -- data\n  tensor_obj   := tensor_obj,\n  tensor_hom   := @tensor_hom _ _,\n  tensor_unit  := Module.of R R,\n  associator   := associator,\n  left_unitor  := left_unitor,\n  right_unitor := right_unitor,\n  -- properties\n  tensor_id'               := λ M N, tensor_id M N,\n  tensor_comp'             := λ M N K M' N' K' f g h, tensor_comp f g h,\n  associator_naturality'   := λ M N K M' N' K' f g h, associator_naturality f g h,\n  left_unitor_naturality'  := λ M N f, left_unitor_naturality f,\n  right_unitor_naturality' := λ M N f, right_unitor_naturality f,\n  pentagon'                := λ M N K L, pentagon M N K L,\n  triangle'                := λ M N, triangle M N, }\n\n/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/\ninstance : comm_ring ((𝟙_ (Module.{u} R) : Module.{u} R) : Type u) :=\n(by apply_instance : comm_ring R)\n\nnamespace monoidal_category\n\n@[simp]\nlemma hom_apply {K L M N : Module.{u} R} (f : K ⟶ L) (g : M ⟶ N) (k : K) (m : M) :\n  (f ⊗ g) (k ⊗ₜ m) = f k ⊗ₜ g m := rfl\n\n@[simp]\nlemma left_unitor_hom_apply {M : Module.{u} R} (r : R) (m : M) :\n  ((λ_ M).hom : 𝟙_ (Module R) ⊗ M ⟶ M) (r ⊗ₜ[R] m) = r • m :=\ntensor_product.lid_tmul m r\n\n@[simp]\nlemma left_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((λ_ M).inv : M ⟶ 𝟙_ (Module.{u} R) ⊗ M) m = 1 ⊗ₜ[R] m :=\ntensor_product.lid_symm_apply m\n\n@[simp]\nlemma right_unitor_hom_apply {M : Module.{u} R} (m : M) (r : R) :\n  ((ρ_ M).hom : M ⊗ 𝟙_ (Module R) ⟶ M) (m ⊗ₜ r) = r • m :=\ntensor_product.rid_tmul m r\n\n@[simp]\nlemma right_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((ρ_ M).inv : M ⟶ M ⊗ 𝟙_ (Module.{u} R)) m = m ⊗ₜ[R] 1 :=\ntensor_product.rid_symm_apply m\n\n@[simp]\nlemma associator_hom_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((α_ M N K).hom : (M ⊗ N) ⊗ K ⟶ M ⊗ (N ⊗ K)) ((m ⊗ₜ n) ⊗ₜ k) = (m ⊗ₜ (n ⊗ₜ k)) := rfl\n\n@[simp]\nlemma associator_inv_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((α_ M N K).inv : M ⊗ (N ⊗ K) ⟶ (M ⊗ N) ⊗ K) (m ⊗ₜ (n ⊗ₜ k)) = ((m ⊗ₜ n) ⊗ₜ k) := rfl\n\nend monoidal_category\n\n/-- (implementation) the braiding for R-modules -/\ndef braiding (M N : Module R) : tensor_obj M N ≅ tensor_obj N M :=\nlinear_equiv.to_Module_iso (tensor_product.comm R M N)\n\n@[simp] lemma braiding_naturality {X₁ X₂ Y₁ Y₂ : Module.{u} R} (f : X₁ ⟶ Y₁) (g : X₂ ⟶ Y₂) :\n  (f ⊗ g) ≫ (Y₁.braiding Y₂).hom =\n    (X₁.braiding X₂).hom ≫ (g ⊗ f) :=\nbegin\n  apply tensor_product.ext',\n  intros x y,\n  refl\nend\n\n@[simp] lemma hexagon_forward (X Y Z : Module.{u} R) :\n  (α_ X Y Z).hom ≫ (braiding X _).hom ≫ (α_ Y Z X).hom =\n  ((braiding X Y).hom ⊗ 𝟙 Z) ≫ (α_ Y X Z).hom ≫ (𝟙 Y ⊗ (braiding X Z).hom) :=\nbegin\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl,\nend\n\n@[simp] lemma hexagon_reverse (X Y Z : Module.{u} R) :\n  (α_ X Y Z).inv ≫ (braiding _ Z).hom ≫ (α_ Z X Y).inv =\n  (𝟙 X ⊗ (Y.braiding Z).hom) ≫ (α_ X Z Y).inv ≫ ((X.braiding Z).hom ⊗ 𝟙 Y) :=\nbegin\n  apply (cancel_epi (α_ X Y Z).hom).1,\n  apply tensor_product.ext_threefold,\n  intros x y z,\n  refl,\nend\n\nlocal attribute [ext] tensor_product.ext\n\n/-- The symmetric monoidal structure on `Module R`. -/\ninstance symmetric_category : symmetric_category (Module.{u} R) :=\n{ braiding := braiding,\n  braiding_naturality' := λ X₁ X₂ Y₁ Y₂ f g, braiding_naturality f g,\n  hexagon_forward' := hexagon_forward,\n  hexagon_reverse' := hexagon_reverse, }\n\nnamespace monoidal_category\n\n@[simp] lemma braiding_hom_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((β_ M N).hom : M ⊗ N ⟶ N ⊗ M) (m ⊗ₜ n) = n ⊗ₜ m := rfl\n\n@[simp] lemma braiding_inv_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((β_ M N).inv : N ⊗ M ⟶ M ⊗ N) (n ⊗ₜ m) = m ⊗ₜ n := rfl\n\nend monoidal_category\n\nopen opposite\n\ninstance : monoidal_preadditive (Module.{u} R) :=\n{ tensor_zero' := by { intros, ext, simp, },\n  zero_tensor' := by { intros, ext, simp, },\n  tensor_add' := by { intros, ext, simp [tensor_product.tmul_add], },\n  add_tensor' := by { intros, ext, simp [tensor_product.add_tmul], }, }\n\ninstance : monoidal_linear R (Module.{u} R) :=\n{ tensor_smul' := by { intros, ext, simp, },\n  smul_tensor' := by { intros, ext, simp [tensor_product.smul_tmul], }, }\n\n/--\nAuxiliary definition for the `monoidal_closed` instance on `Module R`.\n(This is only a separate definition in order to speed up typechecking. )\n-/\n@[simps]\ndef monoidal_closed_hom_equiv (M N P : Module.{u} R) :\n  ((monoidal_category.tensor_left M).obj N ⟶ P) ≃\n    (N ⟶ ((linear_coyoneda R (Module R)).obj (op M)).obj P) :=\n{ to_fun := λ f, linear_map.compr₂ (tensor_product.mk R N M) ((β_ N M).hom ≫ f),\n  inv_fun := λ f, (β_ M N).hom ≫ tensor_product.lift f,\n  left_inv := λ f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr₂_apply,\n      function.comp_app, coe_comp, monoidal_category.braiding_hom_apply],\n  end,\n  right_inv := λ f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr₂_apply,\n      symmetric_category.symmetry_assoc],\n  end, }\n\ninstance : monoidal_closed (Module.{u} R) :=\n{ closed' := λ M,\n  { is_adj :=\n    { right := (linear_coyoneda R (Module.{u} R)).obj (op M),\n      adj := adjunction.mk_of_hom_equiv\n      { hom_equiv := λ N P, monoidal_closed_hom_equiv M N P, } } } }\n\n-- I can't seem to express the function coercion here without writing `@coe_fn`.\n@[simp]\nlemma monoidal_closed_curry {M N P : Module.{u} R} (f : M ⊗ N ⟶ P) (x : M) (y : N) :\n  @coe_fn _ _ linear_map.has_coe_to_fun ((monoidal_closed.curry f : N →ₗ[R] (M →ₗ[R] P)) y) x =\n    f (x ⊗ₜ[R] y) :=\nrfl\n\n@[simp]\nlemma monoidal_closed_uncurry {M N P : Module.{u} R}\n  (f : N ⟶ (M ⟶[Module.{u} R] P)) (x : M) (y : N) :\n  monoidal_closed.uncurry f (x ⊗ₜ[R] y) = (@coe_fn _ _ linear_map.has_coe_to_fun (f y)) x :=\nby { simp only [monoidal_closed.uncurry, ihom.adjunction, is_left_adjoint.adj], simp, }\n\nend Module\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/algebra/category/Module/monoidal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.6654105454764746, "lm_q1q2_score": 0.45419175234987447}}
{"text": "import tactic\n\nopen function\n\ntheorem challenge4 (X Y Z : Type) (f : X → Y) (g : Y → Z) : surjective (g ∘ f) → surjective g :=\nbegin\n  sorry\nend\n", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/Maths_Challenges/src/challenges/challenge4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4541566480141732}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\n! This file was ported from Lean 3 source module data.set.pairwise.lattice\n! leanprover-community/mathlib commit c227d107bbada5d0d9d20287e3282c0a7f1651a0\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Set.Lattice\nimport Mathbin.Data.Set.Pairwise.Basic\n\n/-!\n# Relations holding pairwise\n\nIn this file we prove many facts about `pairwise` and the set lattice.\n-/\n\n\nopen Set Function\n\nvariable {α β γ ι ι' : Type _} {r p q : α → α → Prop}\n\nsection Pairwise\n\nvariable {f g : ι → α} {s t u : Set α} {a b : α}\n\nnamespace Set\n\n/- warning: set.pairwise_Union -> Set.pairwise_unionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {r : α -> α -> Prop} {f : ι -> (Set.{u1} α)}, (Directed.{u1, succ u2} (Set.{u1} α) ι (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α)) f) -> (Iff (Set.Pairwise.{u1} α (Set.unionᵢ.{u1, succ u2} α ι (fun (n : ι) => f n)) r) (forall (n : ι), Set.Pairwise.{u1} α (f n) r))\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Type.{u1}} {r : α -> α -> Prop} {f : ι -> (Set.{u2} α)}, (Directed.{u2, succ u1} (Set.{u2} α) ι (fun (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.120 : Set.{u2} α) (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.122 : Set.{u2} α) => HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.120 x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.122) f) -> (Iff (Set.Pairwise.{u2} α (Set.unionᵢ.{u2, succ u1} α ι (fun (n : ι) => f n)) r) (forall (n : ι), Set.Pairwise.{u2} α (f n) r))\nCase conversion may be inaccurate. Consider using '#align set.pairwise_Union Set.pairwise_unionᵢₓ'. -/\ntheorem pairwise_unionᵢ {f : ι → Set α} (h : Directed (· ⊆ ·) f) :\n    (⋃ n, f n).Pairwise r ↔ ∀ n, (f n).Pairwise r :=\n  by\n  constructor\n  · intro H n\n    exact Pairwise.mono (subset_Union _ _) H\n  · intro H i hi j hj hij\n    rcases mem_Union.1 hi with ⟨m, hm⟩\n    rcases mem_Union.1 hj with ⟨n, hn⟩\n    rcases h m n with ⟨p, mp, np⟩\n    exact H p (mp hm) (np hn) hij\n#align set.pairwise_Union Set.pairwise_unionᵢ\n\n#print Set.pairwise_unionₛ /-\ntheorem pairwise_unionₛ {r : α → α → Prop} {s : Set (Set α)} (h : DirectedOn (· ⊆ ·) s) :\n    (⋃₀ s).Pairwise r ↔ ∀ a ∈ s, Set.Pairwise a r :=\n  by\n  rw [sUnion_eq_Union, pairwise_Union h.directed_coe, SetCoe.forall]\n  rfl\n#align set.pairwise_sUnion Set.pairwise_unionₛ\n-/\n\nend Set\n\nend Pairwise\n\nnamespace Set\n\nsection PartialOrderBot\n\nvariable [PartialOrder α] [OrderBot α] {s t : Set ι} {f g : ι → α}\n\n/- warning: set.pairwise_disjoint_Union -> Set.pairwiseDisjoint_unionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {ι' : Type.{u3}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : OrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1))] {f : ι -> α} {g : ι' -> (Set.{u2} ι)}, (Directed.{u2, succ u3} (Set.{u2} ι) ι' (HasSubset.Subset.{u2} (Set.{u2} ι) (Set.hasSubset.{u2} ι)) g) -> (Iff (Set.PairwiseDisjoint.{u1, u2} α ι _inst_1 _inst_2 (Set.unionᵢ.{u2, succ u3} ι ι' (fun (n : ι') => g n)) f) (forall {{n : ι'}}, Set.PairwiseDisjoint.{u1, u2} α ι _inst_1 _inst_2 (g n) f))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Type.{u3}} {ι' : Type.{u2}} [_inst_1 : PartialOrder.{u1} α] [_inst_2 : OrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α _inst_1))] {f : ι -> α} {g : ι' -> (Set.{u3} ι)}, (Directed.{u3, succ u2} (Set.{u3} ι) ι' (fun (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.443 : Set.{u3} ι) (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.445 : Set.{u3} ι) => HasSubset.Subset.{u3} (Set.{u3} ι) (Set.instHasSubsetSet.{u3} ι) x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.443 x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.445) g) -> (Iff (Set.PairwiseDisjoint.{u1, u3} α ι _inst_1 _inst_2 (Set.unionᵢ.{u3, succ u2} ι ι' (fun (n : ι') => g n)) f) (forall {{n : ι'}}, Set.PairwiseDisjoint.{u1, u3} α ι _inst_1 _inst_2 (g n) f))\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint_Union Set.pairwiseDisjoint_unionᵢₓ'. -/\ntheorem pairwiseDisjoint_unionᵢ {g : ι' → Set ι} (h : Directed (· ⊆ ·) g) :\n    (⋃ n, g n).PairwiseDisjoint f ↔ ∀ ⦃n⦄, (g n).PairwiseDisjoint f :=\n  pairwise_unionᵢ h\n#align set.pairwise_disjoint_Union Set.pairwiseDisjoint_unionᵢ\n\n#print Set.pairwiseDisjoint_unionₛ /-\ntheorem pairwiseDisjoint_unionₛ {s : Set (Set ι)} (h : DirectedOn (· ⊆ ·) s) :\n    (⋃₀ s).PairwiseDisjoint f ↔ ∀ ⦃a⦄, a ∈ s → Set.PairwiseDisjoint a f :=\n  pairwise_unionₛ h\n#align set.pairwise_disjoint_sUnion Set.pairwiseDisjoint_unionₛ\n-/\n\nend PartialOrderBot\n\nsection CompleteLattice\n\nvariable [CompleteLattice α]\n\n/- warning: set.pairwise_disjoint.bUnion -> Set.PairwiseDisjoint.bunionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {ι' : Type.{u3}} [_inst_1 : CompleteLattice.{u1} α] {s : Set.{u3} ι'} {g : ι' -> (Set.{u2} ι)} {f : ι -> α}, (Set.PairwiseDisjoint.{u1, u3} α ι' (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)) (BoundedOrder.toOrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} α _inst_1)) s (fun (i' : ι') => supᵢ.{u1, succ u2} α (CompleteSemilatticeSup.toHasSup.{u1} α (CompleteLattice.toCompleteSemilatticeSup.{u1} α _inst_1)) ι (fun (i : ι) => supᵢ.{u1, 0} α (CompleteSemilatticeSup.toHasSup.{u1} α (CompleteLattice.toCompleteSemilatticeSup.{u1} α _inst_1)) (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i (g i')) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i (g i')) => f i)))) -> (forall (i : ι'), (Membership.Mem.{u3, u3} ι' (Set.{u3} ι') (Set.hasMem.{u3} ι') i s) -> (Set.PairwiseDisjoint.{u1, u2} α ι (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)) (BoundedOrder.toOrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} α _inst_1)) (g i) f)) -> (Set.PairwiseDisjoint.{u1, u2} α ι (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)) (BoundedOrder.toOrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} α _inst_1)) (Set.unionᵢ.{u2, succ u3} ι ι' (fun (i : ι') => Set.unionᵢ.{u2, 0} ι (Membership.Mem.{u3, u3} ι' (Set.{u3} ι') (Set.hasMem.{u3} ι') i s) (fun (H : Membership.Mem.{u3, u3} ι' (Set.{u3} ι') (Set.hasMem.{u3} ι') i s) => g i))) f)\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Type.{u2}} {ι' : Type.{u3}} [_inst_1 : CompleteLattice.{u1} α] {s : Set.{u3} ι'} {g : ι' -> (Set.{u2} ι)} {f : ι -> α}, (Set.PairwiseDisjoint.{u1, u3} α ι' (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)) (BoundedOrder.toOrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} α _inst_1)) s (fun (i' : ι') => supᵢ.{u1, succ u2} α (CompleteLattice.toSupSet.{u1} α _inst_1) ι (fun (i : ι) => supᵢ.{u1, 0} α (CompleteLattice.toSupSet.{u1} α _inst_1) (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i (g i')) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i (g i')) => f i)))) -> (forall (i : ι'), (Membership.mem.{u3, u3} ι' (Set.{u3} ι') (Set.instMembershipSet.{u3} ι') i s) -> (Set.PairwiseDisjoint.{u1, u2} α ι (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)) (BoundedOrder.toOrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} α _inst_1)) (g i) f)) -> (Set.PairwiseDisjoint.{u1, u2} α ι (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)) (BoundedOrder.toOrderBot.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (CompleteSemilatticeInf.toPartialOrder.{u1} α (CompleteLattice.toCompleteSemilatticeInf.{u1} α _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} α _inst_1)) (Set.unionᵢ.{u2, succ u3} ι ι' (fun (i : ι') => Set.unionᵢ.{u2, 0} ι (Membership.mem.{u3, u3} ι' (Set.{u3} ι') (Set.instMembershipSet.{u3} ι') i s) (fun (H : Membership.mem.{u3, u3} ι' (Set.{u3} ι') (Set.instMembershipSet.{u3} ι') i s) => g i))) f)\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint.bUnion Set.PairwiseDisjoint.bunionᵢₓ'. -/\n/-- Bind operation for `set.pairwise_disjoint`. If you want to only consider finsets of indices, you\ncan use `set.pairwise_disjoint.bUnion_finset`. -/\ntheorem PairwiseDisjoint.bunionᵢ {s : Set ι'} {g : ι' → Set ι} {f : ι → α}\n    (hs : s.PairwiseDisjoint fun i' : ι' => ⨆ i ∈ g i', f i)\n    (hg : ∀ i ∈ s, (g i).PairwiseDisjoint f) : (⋃ i ∈ s, g i).PairwiseDisjoint f :=\n  by\n  rintro a ha b hb hab\n  simp_rw [Set.mem_unionᵢ] at ha hb\n  obtain ⟨c, hc, ha⟩ := ha\n  obtain ⟨d, hd, hb⟩ := hb\n  obtain hcd | hcd := eq_or_ne (g c) (g d)\n  · exact hg d hd (hcd.subst ha) hb hab\n  · exact (hs hc hd <| ne_of_apply_ne _ hcd).mono (le_supᵢ₂ a ha) (le_supᵢ₂ b hb)\n#align set.pairwise_disjoint.bUnion Set.PairwiseDisjoint.bunionᵢ\n\nend CompleteLattice\n\n/- warning: set.bUnion_diff_bUnion_eq -> Set.bunionᵢ_diff_bunionᵢ_eq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {s : Set.{u2} ι} {t : Set.{u2} ι} {f : ι -> (Set.{u1} α)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} α) ι (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Union.union.{u2} (Set.{u2} ι) (Set.hasUnion.{u2} ι) s t) f) -> (Eq.{succ u1} (Set.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) => f i))) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i t) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i t) => f i)))) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i (SDiff.sdiff.{u2} (Set.{u2} ι) (BooleanAlgebra.toHasSdiff.{u2} (Set.{u2} ι) (Set.booleanAlgebra.{u2} ι)) s t)) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i (SDiff.sdiff.{u2} (Set.{u2} ι) (BooleanAlgebra.toHasSdiff.{u2} (Set.{u2} ι) (Set.booleanAlgebra.{u2} ι)) s t)) => f i))))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Type.{u2}} {s : Set.{u2} ι} {t : Set.{u2} ι} {f : ι -> (Set.{u1} α)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} α) ι (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (Union.union.{u2} (Set.{u2} ι) (Set.instUnionSet.{u2} ι) s t) f) -> (Eq.{succ u1} (Set.{u1} α) (SDiff.sdiff.{u1} (Set.{u1} α) (Set.instSDiffSet.{u1} α) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) => f i))) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i t) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i t) => f i)))) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i (SDiff.sdiff.{u2} (Set.{u2} ι) (Set.instSDiffSet.{u2} ι) s t)) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i (SDiff.sdiff.{u2} (Set.{u2} ι) (Set.instSDiffSet.{u2} ι) s t)) => f i))))\nCase conversion may be inaccurate. Consider using '#align set.bUnion_diff_bUnion_eq Set.bunionᵢ_diff_bunionᵢ_eqₓ'. -/\ntheorem bunionᵢ_diff_bunionᵢ_eq {s t : Set ι} {f : ι → Set α} (h : (s ∪ t).PairwiseDisjoint f) :\n    ((⋃ i ∈ s, f i) \\ ⋃ i ∈ t, f i) = ⋃ i ∈ s \\ t, f i :=\n  by\n  refine'\n    (bUnion_diff_bUnion_subset f s t).antisymm\n      (Union₂_subset fun i hi a ha => (mem_diff _).2 ⟨mem_bUnion hi.1 ha, _⟩)\n  rw [mem_Union₂]; rintro ⟨j, hj, haj⟩\n  exact (h (Or.inl hi.1) (Or.inr hj) (ne_of_mem_of_not_mem hj hi.2).symm).le_bot ⟨ha, haj⟩\n#align set.bUnion_diff_bUnion_eq Set.bunionᵢ_diff_bunionᵢ_eq\n\n/- warning: set.bUnion_eq_sigma_of_disjoint -> Set.bunionᵢEqSigmaOfDisjoint is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {s : Set.{u2} ι} {f : ι -> (Set.{u1} α)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} α) ι (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) s f) -> (Equiv.{succ u1, max (succ u2) (succ u1)} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) => f i)))) (Sigma.{u2, u1} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} ι) Type.{u2} (Set.hasCoeToSort.{u2} ι) s) (fun (i : coeSort.{succ u2, succ (succ u2)} (Set.{u2} ι) Type.{u2} (Set.hasCoeToSort.{u2} ι) s) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (f ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Set.{u2} ι) Type.{u2} (Set.hasCoeToSort.{u2} ι) s) ι (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} ι) Type.{u2} (Set.hasCoeToSort.{u2} ι) s) ι (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} ι) Type.{u2} (Set.hasCoeToSort.{u2} ι) s) ι (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} ι) Type.{u2} (Set.hasCoeToSort.{u2} ι) s) ι (coeSubtype.{succ u2} ι (fun (x : ι) => Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) x s))))) i)))))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Type.{u2}} {s : Set.{u2} ι} {f : ι -> (Set.{u1} α)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} α) ι (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) s f) -> (Equiv.{succ u1, max (succ u1) (succ u2)} (Set.Elem.{u1} α (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) => f i)))) (Sigma.{u2, u1} (Set.Elem.{u2} ι s) (fun (i : Set.Elem.{u2} ι s) => Set.Elem.{u1} α (f (Subtype.val.{succ u2} ι (fun (x : ι) => Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) x s) i)))))\nCase conversion may be inaccurate. Consider using '#align set.bUnion_eq_sigma_of_disjoint Set.bunionᵢEqSigmaOfDisjointₓ'. -/\n/-- Equivalence between a disjoint bounded union and a dependent sum. -/\nnoncomputable def bunionᵢEqSigmaOfDisjoint {s : Set ι} {f : ι → Set α} (h : s.PairwiseDisjoint f) :\n    (⋃ i ∈ s, f i) ≃ Σi : s, f i :=\n  (Equiv.setCongr (bunionᵢ_eq_unionᵢ _ _)).trans <|\n    unionEqSigmaOfDisjoint fun ⟨i, hi⟩ ⟨j, hj⟩ ne => h hi hj fun eq => Ne <| Subtype.eq Eq\n#align set.bUnion_eq_sigma_of_disjoint Set.bunionᵢEqSigmaOfDisjoint\n\nend Set\n\nsection\n\nvariable {f : ι → Set α} {s t : Set ι}\n\n/- warning: set.pairwise_disjoint.subset_of_bUnion_subset_bUnion -> Set.PairwiseDisjoint.subset_of_bunionᵢ_subset_bunionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {f : ι -> (Set.{u1} α)} {s : Set.{u2} ι} {t : Set.{u2} ι}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} α) ι (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α))) (Union.union.{u2} (Set.{u2} ι) (Set.hasUnion.{u2} ι) s t) f) -> (forall (i : ι), (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) -> (Set.Nonempty.{u1} α (f i))) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) => f i))) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i t) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i t) => f i)))) -> (HasSubset.Subset.{u2} (Set.{u2} ι) (Set.hasSubset.{u2} ι) s t)\nbut is expected to have type\n  forall {α : Type.{u2}} {ι : Type.{u1}} {f : ι -> (Set.{u2} α)} {s : Set.{u1} ι} {t : Set.{u1} ι}, (Set.PairwiseDisjoint.{u2, u1} (Set.{u2} α) ι (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} α) (Preorder.toLE.{u2} (Set.{u2} α) (PartialOrder.toPreorder.{u2} (Set.{u2} α) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} α) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} α) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} α) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} α) (Set.instCompleteBooleanAlgebraSet.{u2} α)))))) (Union.union.{u1} (Set.{u1} ι) (Set.instUnionSet.{u1} ι) s t) f) -> (forall (i : ι), (Membership.mem.{u1, u1} ι (Set.{u1} ι) (Set.instMembershipSet.{u1} ι) i s) -> (Set.Nonempty.{u2} α (f i))) -> (HasSubset.Subset.{u2} (Set.{u2} α) (Set.instHasSubsetSet.{u2} α) (Set.unionᵢ.{u2, succ u1} α ι (fun (i : ι) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u1, u1} ι (Set.{u1} ι) (Set.instMembershipSet.{u1} ι) i s) (fun (H : Membership.mem.{u1, u1} ι (Set.{u1} ι) (Set.instMembershipSet.{u1} ι) i s) => f i))) (Set.unionᵢ.{u2, succ u1} α ι (fun (i : ι) => Set.unionᵢ.{u2, 0} α (Membership.mem.{u1, u1} ι (Set.{u1} ι) (Set.instMembershipSet.{u1} ι) i t) (fun (H : Membership.mem.{u1, u1} ι (Set.{u1} ι) (Set.instMembershipSet.{u1} ι) i t) => f i)))) -> (HasSubset.Subset.{u1} (Set.{u1} ι) (Set.instHasSubsetSet.{u1} ι) s t)\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint.subset_of_bUnion_subset_bUnion Set.PairwiseDisjoint.subset_of_bunionᵢ_subset_bunionᵢₓ'. -/\ntheorem Set.PairwiseDisjoint.subset_of_bunionᵢ_subset_bunionᵢ (h₀ : (s ∪ t).PairwiseDisjoint f)\n    (h₁ : ∀ i ∈ s, (f i).Nonempty) (h : (⋃ i ∈ s, f i) ⊆ ⋃ i ∈ t, f i) : s ⊆ t :=\n  by\n  rintro i hi\n  obtain ⟨a, hai⟩ := h₁ i hi\n  obtain ⟨j, hj, haj⟩ := mem_Union₂.1 (h <| mem_Union₂_of_mem hi hai)\n  rwa [h₀.eq (subset_union_left _ _ hi) (subset_union_right _ _ hj)\n      (not_disjoint_iff.2 ⟨a, hai, haj⟩)]\n#align set.pairwise_disjoint.subset_of_bUnion_subset_bUnion Set.PairwiseDisjoint.subset_of_bunionᵢ_subset_bunionᵢ\n\n/- warning: pairwise.subset_of_bUnion_subset_bUnion -> Pairwise.subset_of_bunionᵢ_subset_bunionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {f : ι -> (Set.{u1} α)} {s : Set.{u2} ι} {t : Set.{u2} ι}, (Pairwise.{u2} ι (Function.onFun.{succ u2, succ u1, 1} ι (Set.{u1} α) Prop (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)))) f)) -> (forall (i : ι), (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) -> (Set.Nonempty.{u1} α (f i))) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) => f i))) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i t) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i t) => f i)))) -> (HasSubset.Subset.{u2} (Set.{u2} ι) (Set.hasSubset.{u2} ι) s t)\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Type.{u2}} {f : ι -> (Set.{u1} α)} {s : Set.{u2} ι} {t : Set.{u2} ι}, (Pairwise.{u2} ι (Function.onFun.{succ u2, succ u1, 1} ι (Set.{u1} α) Prop (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α))))))) f)) -> (forall (i : ι), (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) -> (Set.Nonempty.{u1} α (f i))) -> (HasSubset.Subset.{u1} (Set.{u1} α) (Set.instHasSubsetSet.{u1} α) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) => f i))) (Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i t) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i t) => f i)))) -> (HasSubset.Subset.{u2} (Set.{u2} ι) (Set.instHasSubsetSet.{u2} ι) s t)\nCase conversion may be inaccurate. Consider using '#align pairwise.subset_of_bUnion_subset_bUnion Pairwise.subset_of_bunionᵢ_subset_bunionᵢₓ'. -/\ntheorem Pairwise.subset_of_bunionᵢ_subset_bunionᵢ (h₀ : Pairwise (Disjoint on f))\n    (h₁ : ∀ i ∈ s, (f i).Nonempty) (h : (⋃ i ∈ s, f i) ⊆ ⋃ i ∈ t, f i) : s ⊆ t :=\n  Set.PairwiseDisjoint.subset_of_bunionᵢ_subset_bunionᵢ (h₀.set_pairwise _) h₁ h\n#align pairwise.subset_of_bUnion_subset_bUnion Pairwise.subset_of_bunionᵢ_subset_bunionᵢ\n\n/- warning: pairwise.bUnion_injective -> Pairwise.bunionᵢ_injective is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {ι : Type.{u2}} {f : ι -> (Set.{u1} α)}, (Pairwise.{u2} ι (Function.onFun.{succ u2, succ u1, 1} ι (Set.{u1} α) Prop (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.completeBooleanAlgebra.{u1} α)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} α) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)))) f)) -> (forall (i : ι), Set.Nonempty.{u1} α (f i)) -> (Function.Injective.{succ u2, succ u1} (Set.{u2} ι) (Set.{u1} α) (fun (s : Set.{u2} ι) => Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) (fun (H : Membership.Mem.{u2, u2} ι (Set.{u2} ι) (Set.hasMem.{u2} ι) i s) => f i))))\nbut is expected to have type\n  forall {α : Type.{u1}} {ι : Type.{u2}} {f : ι -> (Set.{u1} α)}, (Pairwise.{u2} ι (Function.onFun.{succ u2, succ u1, 1} ι (Set.{u1} α) Prop (Disjoint.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} α) (Preorder.toLE.{u1} (Set.{u1} α) (PartialOrder.toPreorder.{u1} (Set.{u1} α) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} α) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} α) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} α) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} α) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} α) (Set.instCompleteBooleanAlgebraSet.{u1} α))))))) f)) -> (forall (i : ι), Set.Nonempty.{u1} α (f i)) -> (Function.Injective.{succ u2, succ u1} (Set.{u2} ι) (Set.{u1} α) (fun (s : Set.{u2} ι) => Set.unionᵢ.{u1, succ u2} α ι (fun (i : ι) => Set.unionᵢ.{u1, 0} α (Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) (fun (H : Membership.mem.{u2, u2} ι (Set.{u2} ι) (Set.instMembershipSet.{u2} ι) i s) => f i))))\nCase conversion may be inaccurate. Consider using '#align pairwise.bUnion_injective Pairwise.bunionᵢ_injectiveₓ'. -/\ntheorem Pairwise.bunionᵢ_injective (h₀ : Pairwise (Disjoint on f)) (h₁ : ∀ i, (f i).Nonempty) :\n    Injective fun s : Set ι => ⋃ i ∈ s, f i := fun s t h =>\n  ((h₀.subset_of_bunionᵢ_subset_bunionᵢ fun _ _ => h₁ _) <| h.Subset).antisymm <|\n    (h₀.subset_of_bunionᵢ_subset_bunionᵢ fun _ _ => h₁ _) <| h.Superset\n#align pairwise.bUnion_injective Pairwise.bunionᵢ_injective\n\nend\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Set/Pairwise/Lattice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081926, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.45404563594675906}}
{"text": "import Lean4Axiomatic.Rational.Negation\n\n/-! # Rational numbers: reciprocation and division -/\n\nnamespace Lean4Axiomatic.Rational\n\nopen Logic (AP)\n\n/-- Operations pertaining to rational number reciprocation. -/\nclass Reciprocation.Ops\n    {ℕ ℤ : outParam Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\n    (ℚ : Type) [Core (ℤ := ℤ) ℚ]\n    :=\n  /-- Reciprocation of rational numbers. -/\n  reciprocal (p : ℚ) [AP (p ≄ 0)] : ℚ\n\nexport Reciprocation.Ops (reciprocal)\n\n/-- Enables the use of the `·⁻¹` operator for reciprocation. -/\npostfix:120 \"⁻¹\" => reciprocal\n\n/-- Properties of rational number reciprocation. -/\nclass Reciprocation.Props\n    {ℕ ℤ : outParam Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\n    (ℚ : Type) [Core (ℤ := ℤ) ℚ] [Addition ℚ] [Multiplication ℚ] [Ops ℚ]\n    :=\n  /-- Reciprocation respects equivalence over its operand. -/\n  recip_subst {p₁ p₂ : ℚ} [AP (p₁ ≄ 0)] [AP (p₂ ≄ 0)] : p₁ ≃ p₂ → p₁⁻¹ ≃ p₂⁻¹\n\n  /-- The reciprocal of a value is its left multiplicative inverse. -/\n  mul_inverseL {p : ℚ} [AP (p ≄ 0)] : p⁻¹ * p ≃ 1\n\n  /-- The reciprocal of a value is its right multiplicative inverse. -/\n  mul_inverseR {p : ℚ} [AP (p ≄ 0)] : p * p⁻¹ ≃ 1\n\nexport Reciprocation.Props (mul_inverseL mul_inverseR recip_subst)\n\n/-- All rational number reciprocation axioms. -/\nclass Reciprocation\n    {ℕ ℤ : outParam Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\n    (ℚ : Type) [Core (ℤ := ℤ) ℚ] [Addition ℚ] [Multiplication ℚ]\n    :=\n  toOps : Reciprocation.Ops ℚ\n  toProps : Reciprocation.Props ℚ\n\nattribute [instance] Reciprocation.toOps\nattribute [instance] Reciprocation.toProps\n\n/-- Operations pertaining to rational number division. -/\nclass Division.Ops\n    {ℕ ℤ : outParam Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\n    (ℚ : Type) [Core (ℤ := ℤ) ℚ]\n    :=\n  /-- Division of rational numbers. -/\n  div (p q : ℚ) [AP (q ≄ 0)] : ℚ\n\nexport Division.Ops (div)\n\n/--\nEnables the use of the `· / ·` operator for division.\n\nWe define the operator syntax directly here, instead of using the `Div` class\nfrom the standard library. This is because our `div` operation has an extra\nargument, an instance expressing that the divisor must be nonzero. The `Div`\nclass only provides a simple binary operation for its `div`.\n-/\ninfixl:70 \" / \" => div\n\n/--\nAn inductive predicate expressing that a rational number can be represented as\na ratio of integers.\n\nA value of `AsRatio p`, for some rational number `p`, is an existence proof\nthat there are two integers `a` and `b` whose ratio `a / b` is equivalent to\n`p`.\n-/\ninductive AsRatio\n    {ℕ ℤ : Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\n    {ℚ : Type} [Core (ℤ := ℤ) ℚ] [Division.Ops ℚ] (p : ℚ)\n    : Prop\n    :=\n  /-- Construct a value of `AsRatio p`. -/\n| intro\n    (a b : ℤ)\n    (b_nonzero : Integer.Nonzero b)\n    (eqv_ratio : p ≃ a / b)\n\n/-- Properties of rational number division. -/\nclass Division.Props\n    {ℕ ℤ : outParam Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\n    (ℚ : Type)\n      [Core (ℤ := ℤ) ℚ] [Addition ℚ] [Multiplication ℚ] [Reciprocation ℚ]\n      [Ops ℚ]\n    :=\n  /--\n  Division is equivalent to multiplication by the reciprocal of the second\n  argument.\n  -/\n  div_mul_recip {p q : ℚ} [AP (q ≄ 0)] : p / q ≃ p * q⁻¹\n\n  /--\n  Every rational number can be expressed as a ratio of integers.\n\n  Given any two integers, we can easily make a rational number; convert both of\n  them to rationals using `from_integer`, then divide them. This axiom tells us\n  that we can also do the reverse: given any rational, there are two integers\n  that produce it when put into a ratio.\n\n  It's a useful axiom because it provides a way to \"deconstruct\" a rational\n  number into simpler pieces, which may be easier to work with. Although it's\n  preferable to work with rational numbers directly, and use this only when\n  necessary.\n  -/\n  as_ratio (p : ℚ) : AsRatio p\n\nexport Division.Props (as_ratio div_mul_recip)\n\n/-- All rational number division axioms. -/\nclass Division\n    {ℕ ℤ : outParam Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\n    (ℚ : Type)\n      [Core (ℤ := ℤ) ℚ] [Addition ℚ] [Multiplication ℚ] [Reciprocation ℚ]\n    :=\n  toOps : Division.Ops ℚ\n  toProps : Division.Props ℚ\n\nattribute [instance] Division.toOps\nattribute [instance] Division.toProps\n\n/-! ## Derived properties -/\n\nvariable {ℕ ℤ : Type} [Natural ℕ] [Integer (ℕ := ℕ) ℤ]\nvariable {ℚ : Type}\n  [Core (ℤ := ℤ) ℚ] [Addition ℚ] [Multiplication ℚ]\n  [Negation ℚ] [Reciprocation ℚ] [Division ℚ]\n\n/--\nSquare roots of unity are their own reciprocals.\n\n**Property intuition**: Taking the reciprocal of a number doesn't change its\nsign, and the only fraction that would be unchanged when flipping it is `1/1`,\ni.e. the rational number `1`. Thus `1` and `-1` should be the only numbers to\nsatisfy this property.\n\n**Proof intuition**: The defining proprty of square roots of unity,\n`s * s ≃ 1`, is cruical for this proof because it introduces two factors of\n`s`. One of them gets canceled by the reciprocal, leaving the other as the\nresult.\n-/\ntheorem recip_sqrt1 {s : ℚ} [Sqrt1 s] : s⁻¹ ≃ s := calc\n  s⁻¹           ≃ _ := eqv_symm mul_identL\n  1 * s⁻¹       ≃ _ := mul_substL (eqv_symm ‹Sqrt1 s›.elim)\n  (s * s) * s⁻¹ ≃ _ := mul_assoc\n  s * (s * s⁻¹) ≃ _ := mul_substR mul_inverseR\n  s * 1         ≃ _ := mul_identR\n  s             ≃ _ := eqv_refl\n\n/--\nDivision respects equivalence over its left operand.\n\n**Property intuition**: Necessary for division to be a valid function on\nrational numbers.\n\n**Proof intuition**: The left operand of division is also the left operand of\nthe underlying multiplication, which is already known to obey the substitution\nproperty.\n-/\ntheorem div_substL {p₁ p₂ q : ℚ} [AP (q ≄ 0)] : p₁ ≃ p₂ → p₁ / q ≃ p₂ / q := by\n  intro (_ : p₁ ≃ p₂)\n  show p₁ / q ≃ p₂ / q\n  calc\n    p₁ / q   ≃ _ := div_mul_recip\n    p₁ * q⁻¹ ≃ _ := mul_substL ‹p₁ ≃ p₂›\n    p₂ * q⁻¹ ≃ _ := eqv_symm div_mul_recip\n    p₂ / q   ≃ _ := eqv_refl\n\n/--\nDivision respects equivalence over its right operand.\n\n**Property intuition**: Necessary for division to be a valid function on\nrational numbers.\n\n**Proof intuition**: Division's right operand's reciprocal is the underlying\nmultiplication's right operand. Multiplication and reciprocation are already\nknown to obey the substitution property.\n-/\ntheorem div_substR\n    {p₁ p₂ q : ℚ} [AP (p₁ ≄ 0)] [AP (p₂ ≄ 0)] : p₁ ≃ p₂ → q / p₁ ≃ q / p₂\n    := by\n  intro (_ : p₁ ≃ p₂)\n  show q / p₁ ≃ q / p₂\n  calc\n    q / p₁   ≃ _ := div_mul_recip\n    q * p₁⁻¹ ≃ _ := mul_substR (recip_subst ‹p₁ ≃ p₂›)\n    q * p₂⁻¹ ≃ _ := eqv_symm div_mul_recip\n    q / p₂   ≃ _ := eqv_refl\n\nend Lean4Axiomatic.Rational\n", "meta": {"author": "cruhland", "repo": "lean4-axiomatic", "sha": "6384bd38b8ba104530247d25456858775fe3c442", "save_path": "github-repos/lean/cruhland-lean4-axiomatic", "path": "github-repos/lean/cruhland-lean4-axiomatic/lean4-axiomatic-6384bd38b8ba104530247d25456858775fe3c442/Lean4Axiomatic/Rational/Reciprocation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702880639791, "lm_q2_score": 0.6261241842048093, "lm_q1q2_score": 0.45385881776836406}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.limits.colimit_limit\nimport category_theory.limits.preserves.functor_category\nimport category_theory.limits.preserves.finite\nimport category_theory.limits.shapes.finite_limits\nimport category_theory.limits.preserves.filtered\nimport category_theory.concrete_category.basic\n\n/-!\n# Filtered colimits commute with finite limits.\n\nWe show that for a functor `F : J × K ⥤ Type v`, when `J` is finite and `K` is filtered,\nthe universal morphism `colimit_limit_to_limit_colimit F` comparing the\ncolimit (over `K`) of the limits (over `J`) with the limit of the colimits is an isomorphism.\n\n(In fact, to prove that it is injective only requires that `J` has finitely many objects.)\n\n## References\n* Borceux, Handbook of categorical algebra 1, Theorem 2.13.4\n* [Stacks: Filtered colimits](https://stacks.math.columbia.edu/tag/002W)\n-/\n\nuniverses v u\n\nopen category_theory\nopen category_theory.category\nopen category_theory.limits.types\nopen category_theory.limits.types.filtered_colimit\n\nnamespace category_theory.limits\n\nvariables {J K : Type v} [small_category J] [small_category K]\nvariables (F : J × K ⥤ Type v)\n\nopen category_theory.prod\n\nvariables [is_filtered K]\n\nsection\n/-!\nInjectivity doesn't need that we have finitely many morphisms in `J`,\nonly that there are finitely many objects.\n-/\nvariables [fintype J]\n\n/--\nThis follows this proof from\n* Borceux, Handbook of categorical algebra 1, Theorem 2.13.4\n-/\nlemma colimit_limit_to_limit_colimit_injective :\n  function.injective (colimit_limit_to_limit_colimit F) :=\nbegin\n  classical,\n\n  -- Suppose we have two terms `x y` in the colimit (over `K`) of the limits (over `J`),\n  -- and that these have the same image under `colimit_limit_to_limit_colimit F`.\n  intros x y h,\n  -- These elements of the colimit have representatives somewhere:\n  obtain ⟨kx, x, rfl⟩ := jointly_surjective'.{v v} x,\n  obtain ⟨ky, y, rfl⟩ := jointly_surjective'.{v v} y,\n  dsimp at x y,\n\n  -- Since the images of `x` and `y` are equal in a limit, they are equal componentwise\n  -- (indexed by `j : J`),\n  replace h := λ j, congr_arg (limit.π ((curry.obj F) ⋙ colim) j) h,\n  -- and they are equations in a filtered colimit,\n  -- so for each `j` we have some place `k j` to the right of both `kx` and `ky`\n  simp [colimit_eq_iff.{v v}] at h,\n  let k := λ j, (h j).some,\n  let f : Π j, kx ⟶ k j := λ j, (h j).some_spec.some,\n  let g : Π j, ky ⟶ k j := λ j, (h j).some_spec.some_spec.some,\n  -- where the images of the components of the representatives become equal:\n  have w : Π j,\n    F.map ((𝟙 j, f j) : (j, kx) ⟶ (j, k j)) (limit.π ((curry.obj (swap K J ⋙ F)).obj kx) j x) =\n    F.map ((𝟙 j, g j) : (j, ky) ⟶ (j, k j)) (limit.π ((curry.obj (swap K J ⋙ F)).obj ky) j y) :=\n    λ j, (h j).some_spec.some_spec.some_spec,\n\n  -- We now use that `K` is filtered, picking some point to the right of all these\n  -- morphisms `f j` and `g j`.\n  let O : finset K := (finset.univ).image k ∪ {kx, ky},\n  have kxO : kx ∈ O := finset.mem_union.mpr (or.inr (by simp)),\n  have kyO : ky ∈ O := finset.mem_union.mpr (or.inr (by simp)),\n  have kjO : ∀ j, k j ∈ O := λ j, finset.mem_union.mpr (or.inl (by simp)),\n\n  let H : finset (Σ' (X Y : K) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y) :=\n    (finset.univ).image (λ j : J, ⟨kx, k j, kxO,\n      finset.mem_union.mpr (or.inl (by simp)),\n      f j⟩) ∪\n    (finset.univ).image (λ j : J, ⟨ky, k j, kyO,\n      finset.mem_union.mpr (or.inl (by simp)),\n      g j⟩),\n  obtain ⟨S, T, W⟩ := is_filtered.sup_exists O H,\n\n  have fH :\n    ∀ j, (⟨kx, k j, kxO, kjO j, f j⟩ : (Σ' (X Y : K) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y)) ∈ H :=\n    λ j, (finset.mem_union.mpr (or.inl\n    begin\n      simp only [true_and, finset.mem_univ, eq_self_iff_true, exists_prop_of_true,\n        finset.mem_image, heq_iff_eq],\n      refine ⟨j, rfl, _⟩,\n      simp only [heq_iff_eq],\n      exact ⟨rfl, rfl, rfl⟩,\n    end)),\n  have gH :\n    ∀ j, (⟨ky, k j, kyO, kjO j, g j⟩ : (Σ' (X Y : K) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y)) ∈ H :=\n    λ j, (finset.mem_union.mpr (or.inr\n    begin\n      simp only [true_and, finset.mem_univ, eq_self_iff_true, exists_prop_of_true,\n        finset.mem_image, heq_iff_eq],\n      refine ⟨j, rfl, _⟩,\n      simp only [heq_iff_eq],\n      exact ⟨rfl, rfl, rfl⟩,\n    end)),\n\n  -- Our goal is now an equation between equivalence classes of representatives of a colimit,\n  -- and so it suffices to show those representative become equal somewhere, in particular at `S`.\n  apply colimit_sound'.{v v} (T kxO) (T kyO),\n\n  -- We can check if two elements of a limit (in `Type`) are equal by comparing them componentwise.\n  ext,\n\n  -- Now it's just a calculation using `W` and `w`.\n  simp only [functor.comp_map, limit.map_π_apply, curry.obj_map_app, swap_map],\n  rw ←W _ _ (fH j),\n  rw ←W _ _ (gH j),\n  simp [w],\nend\n\nend\n\nvariables [fin_category J]\n\n/--\nThis follows this proof from\n* Borceux, Handbook of categorical algebra 1, Theorem 2.13.4\nalthough with different names.\n-/\nlemma colimit_limit_to_limit_colimit_surjective :\n  function.surjective (colimit_limit_to_limit_colimit F) :=\nbegin\n  classical,\n  -- We begin with some element `x` in the limit (over J) over the colimits (over K),\n  intro x,\n  -- This consists of some coherent family of elements in the various colimits,\n  -- and so our first task is to pick representatives of these elements.\n  have z := λ j, jointly_surjective'.{v v} (limit.π (curry.obj F ⋙ limits.colim) j x),\n  -- `k : J ⟶ K` records where the representative of the element in the `j`-th element of `x` lives\n  let k : J → K := λ j, (z j).some,\n  -- `y j : F.obj (j, k j)` is the representative\n  let y : Π j, F.obj (j, k j) := λ j, (z j).some_spec.some,\n  -- and we record that these representatives, when mapped back into the relevant colimits,\n  -- are actually the components of `x`.\n  have e : ∀ j,\n    colimit.ι ((curry.obj F).obj j) (k j) (y j) =\n    limit.π (curry.obj F ⋙ limits.colim) j x := λ j, (z j).some_spec.some_spec,\n  clear_value k y, -- A little tidying up of things we no longer need.\n  clear z,\n\n  -- As a first step, we use that `K` is filtered to pick some point `k' : K` above all the `k j`\n  let k' : K := is_filtered.sup (finset.univ.image k) ∅,\n  -- and name the morphisms as `g j : k j ⟶ k'`.\n  have g : Π j, k j ⟶ k' := λ j, is_filtered.to_sup (finset.univ.image k) ∅ (by simp),\n  clear_value k',\n\n  -- Recalling that the components of `x`, which are indexed by `j : J`, are \"coherent\",\n  -- in other words preserved by morphisms in the `J` direction,\n  -- we see that for any morphism `f : j ⟶ j'` in `J`,\n  -- the images of `y j` and `y j'`, when mapped to `F.obj (j', k')` respectively by\n  -- `(f, g j)` and `(𝟙 j', g j')`, both represent the same element in the colimit.\n  have w : ∀ {j j' : J} (f : j ⟶ j'),\n    colimit.ι ((curry.obj F).obj j') k' (F.map ((𝟙 j', g j') : (j', k j') ⟶ (j', k')) (y j')) =\n    colimit.ι ((curry.obj F).obj j') k' (F.map ((f, g j) : (j, k j) ⟶ (j', k')) (y j)),\n  { intros j j' f,\n    have t : (f, g j) = (((f, 𝟙 (k j)) : (j, k j) ⟶ (j', k j)) ≫ (𝟙 j', g j) : (j, k j) ⟶ (j', k')),\n    { simp only [id_comp, comp_id, prod_comp], },\n    erw [colimit.w_apply', t, functor_to_types.map_comp_apply, colimit.w_apply', e,\n      ←limit.w_apply' f, ←e],\n    simp, },\n\n  -- Because `K` is filtered, we can restate this as saying that\n  -- for each such `f`, there is some place to the right of `k'`\n  -- where these images of `y j` and `y j'` become equal.\n  simp_rw colimit_eq_iff.{v v} at w,\n\n  -- We take a moment to restate `w` more conveniently.\n  let kf : Π {j j'} (f : j ⟶ j'), K := λ _ _ f, (w f).some,\n  let gf : Π {j j'} (f : j ⟶ j'), k' ⟶ kf f := λ _ _ f, (w f).some_spec.some,\n  let hf : Π {j j'} (f : j ⟶ j'), k' ⟶ kf f := λ _ _ f, (w f).some_spec.some_spec.some,\n  have wf : Π {j j'} (f : j ⟶ j'),\n    F.map ((𝟙 j', g j' ≫ gf f) : (j', k j') ⟶ (j', kf f)) (y j') =\n    F.map ((f, g j ≫ hf f) : (j, k j) ⟶ (j', kf f)) (y j) := λ j j' f,\n  begin\n    have q :\n      ((curry.obj F).obj j').map (gf f) (F.map _ (y j')) =\n      ((curry.obj F).obj j').map (hf f) (F.map _ (y j)) :=\n      (w f).some_spec.some_spec.some_spec,\n    dsimp at q,\n    simp_rw ←functor_to_types.map_comp_apply at q,\n    convert q; simp only [comp_id],\n  end,\n  clear_value kf gf hf, -- and clean up some things that are no longer needed.\n  clear w,\n\n  -- We're now ready to use the fact that `K` is filtered a second time,\n  -- picking some place to the right of all of\n  -- the morphisms `gf f : k' ⟶ kh f` and `hf f : k' ⟶ kf f`.\n  -- At this point we're relying on there being only finitely morphisms in `J`.\n  let O := finset.univ.bUnion (λ j, finset.univ.bUnion (λ j', finset.univ.image (@kf j j'))) ∪ {k'},\n  have kfO : ∀ {j j'} (f : j ⟶ j'), kf f ∈ O := λ j j' f, finset.mem_union.mpr (or.inl (\n  begin\n    rw [finset.mem_bUnion],\n    refine ⟨j, finset.mem_univ j, _⟩,\n    rw [finset.mem_bUnion],\n    refine ⟨j', finset.mem_univ j', _⟩,\n    rw [finset.mem_image],\n    refine ⟨f, finset.mem_univ _, _⟩,\n    refl,\n  end)),\n  have k'O : k' ∈ O := finset.mem_union.mpr (or.inr (finset.mem_singleton.mpr rfl)),\n  let H : finset (Σ' (X Y : K) (mX : X ∈ O) (mY : Y ∈ O), X ⟶ Y) :=\n    finset.univ.bUnion (λ j : J, finset.univ.bUnion (λ j' : J, finset.univ.bUnion (λ f : j ⟶ j',\n      {⟨k', kf f, k'O, kfO f, gf f⟩, ⟨k', kf f, k'O, kfO f, hf f⟩}))),\n\n  obtain ⟨k'', i', s'⟩ := is_filtered.sup_exists O H,\n  -- We then restate this slightly more conveniently, as a family of morphism `i f : kf f ⟶ k''`,\n  -- satisfying `gf f ≫ i f = hf f' ≫ i f'`.\n  let i : Π {j j'} (f : j ⟶ j'), kf f ⟶ k'' := λ j j' f, i' (kfO f),\n  have s : ∀ {j₁ j₂ j₃ j₄} (f : j₁ ⟶ j₂) (f' : j₃ ⟶ j₄), gf f ≫ i f = hf f' ≫ i f' :=\n  begin\n    intros,\n    rw [s', s'],\n    swap 2,\n    exact k'O,\n    swap 2,\n    { rw [finset.mem_bUnion],\n      refine ⟨j₁, finset.mem_univ _, _⟩,\n      rw [finset.mem_bUnion],\n      refine ⟨j₂, finset.mem_univ _, _⟩,\n      rw [finset.mem_bUnion],\n      refine ⟨f, finset.mem_univ _, _⟩,\n      simp only [true_or, eq_self_iff_true, and_self, finset.mem_insert, heq_iff_eq], },\n    { rw [finset.mem_bUnion],\n      refine ⟨j₃, finset.mem_univ _, _⟩,\n      rw [finset.mem_bUnion],\n      refine ⟨j₄, finset.mem_univ _, _⟩,\n      rw [finset.mem_bUnion],\n      refine ⟨f', finset.mem_univ _, _⟩,\n      simp only [eq_self_iff_true, or_true, and_self, finset.mem_insert, finset.mem_singleton,\n        heq_iff_eq], }\n  end,\n  clear_value i,\n  clear s' i' H kfO k'O O,\n\n  -- We're finally ready to construct the pre-image, and verify it really maps to `x`.\n  fsplit,\n\n  { -- We construct the pre-image (which, recall is meant to be a point\n    -- in the colimit (over `K`) of the limits (over `J`)) via a representative at `k''`.\n    apply colimit.ι (curry.obj (swap K J ⋙ F) ⋙ limits.lim) k'' _,\n    dsimp,\n    -- This representative is meant to be an element of a limit,\n    -- so we need to construct a family of elements in `F.obj (j, k'')` for varying `j`,\n    -- then show that are coherent with respect to morphisms in the `j` direction.\n    apply limit.mk.{v v}, swap,\n    { -- We construct the elements as the images of the `y j`.\n      exact λ j, F.map (⟨𝟙 j, g j ≫ gf (𝟙 j) ≫ i (𝟙 j)⟩ : (j, k j) ⟶ (j, k'')) (y j), },\n    { -- After which it's just a calculation, using `s` and `wf`, to see they are coherent.\n      dsimp,\n      intros j j' f,\n      simp only [←functor_to_types.map_comp_apply, prod_comp, id_comp, comp_id],\n      calc F.map ((f, g j ≫ gf (𝟙 j) ≫ i (𝟙 j)) : (j, k j) ⟶ (j', k'')) (y j)\n          = F.map ((f, g j ≫ hf f ≫ i f) : (j, k j) ⟶ (j', k'')) (y j)\n                : by rw s (𝟙 j) f\n      ... = F.map ((𝟙 j', i f) : (j', kf f) ⟶ (j', k''))\n              (F.map ((f, g j ≫ hf f) : (j, k j) ⟶ (j', kf f)) (y j))\n                : by rw [←functor_to_types.map_comp_apply, prod_comp, comp_id, assoc]\n      ... = F.map ((𝟙 j', i f) : (j', kf f) ⟶ (j', k''))\n              (F.map ((𝟙 j', g j' ≫ gf f) : (j', k j') ⟶ (j', kf f)) (y j'))\n                : by rw ←wf f\n      ... = F.map ((𝟙 j', g j' ≫ gf f ≫ i f) : (j', k j') ⟶ (j', k'')) (y j')\n                : by rw [←functor_to_types.map_comp_apply, prod_comp, id_comp, assoc]\n      ... = F.map ((𝟙 j', g j' ≫ gf (𝟙 j') ≫ i (𝟙 j')) : (j', k j') ⟶ (j', k'')) (y j')\n                : by rw [s f (𝟙 j'), ←s (𝟙 j') (𝟙 j')], }, },\n\n  -- Finally we check that this maps to `x`.\n  { -- We can do this componentwise:\n    apply limit_ext',\n    intro j,\n\n    -- and as each component is an equation in a colimit, we can verify it by\n    -- pointing out the morphism which carries one representative to the other:\n    simp only [←e, colimit_eq_iff.{v v}, curry.obj_obj_map, limit.π_mk',\n      bifunctor.map_id_comp, id.def, types_comp_apply,\n      limits.ι_colimit_limit_to_limit_colimit_π_apply],\n    refine ⟨k'', 𝟙 k'', g j ≫ gf (𝟙 j) ≫ i (𝟙 j), _⟩,\n    simp only [bifunctor.map_id_comp, types_comp_apply, bifunctor.map_id, types_id_apply], },\nend\n\ninstance colimit_limit_to_limit_colimit_is_iso :\n  is_iso (colimit_limit_to_limit_colimit F) :=\n(is_iso_iff_bijective _).mpr\n  ⟨colimit_limit_to_limit_colimit_injective F, colimit_limit_to_limit_colimit_surjective F⟩\n\ninstance colimit_limit_to_limit_colimit_cone_iso (F : J ⥤ K ⥤ Type v) :\n  is_iso (colimit_limit_to_limit_colimit_cone F) :=\nbegin\n  haveI : is_iso (colimit_limit_to_limit_colimit_cone F).hom,\n  { dsimp only [colimit_limit_to_limit_colimit_cone], apply_instance },\n  apply cones.cone_iso_of_hom_iso,\nend\n\nnoncomputable\ninstance filtered_colim_preserves_finite_limits_of_types :\n  preserves_finite_limits (colim : (K ⥤ Type v) ⥤ _) := ⟨λ J _ _, by exactI ⟨λ F, ⟨λ c hc,\nbegin\n  apply is_limit.of_iso_limit (limit.is_limit _),\n  symmetry,\n  transitivity (colim.map_cone (limit.cone F)),\n  exact functor.map_iso _ (hc.unique_up_to_iso (limit.is_limit F)),\n  exact as_iso (colimit_limit_to_limit_colimit_cone F),\nend ⟩⟩⟩\n\nvariables {C : Type u} [category.{v} C] [concrete_category.{v} C]\nsection\nvariables [has_limits_of_shape J C] [has_colimits_of_shape K C]\nvariables [reflects_limits_of_shape J (forget C)] [preserves_colimits_of_shape K (forget C)]\nvariables [preserves_limits_of_shape J (forget C)]\n\nnoncomputable\ninstance filtered_colim_preserves_finite_limits :\n  preserves_limits_of_shape J (colim : (K ⥤ C) ⥤ _) :=\nbegin\n  haveI : preserves_limits_of_shape J ((colim : (K ⥤ C) ⥤ _) ⋙ forget C) :=\n    preserves_limits_of_shape_of_nat_iso (preserves_colimit_nat_iso _).symm,\n  exactI preserves_limits_of_shape_of_reflects_of_preserves _ (forget C)\nend\nend\n\nlocal attribute [instance] reflects_limits_of_shape_of_reflects_isomorphisms\n\nnoncomputable\ninstance [preserves_finite_limits (forget C)] [preserves_filtered_colimits (forget C)]\n  [has_finite_limits C] [has_colimits_of_shape K C] [reflects_isomorphisms (forget C)] :\n    preserves_finite_limits (colim : (K ⥤ C) ⥤ _) :=\n⟨λ _ _ _, by exactI category_theory.limits.filtered_colim_preserves_finite_limits⟩\n\nsection\n\nvariables [has_limits_of_shape J C] [has_colimits_of_shape K C]\nvariables [reflects_limits_of_shape J (forget C)] [preserves_colimits_of_shape K (forget C)]\nvariables [preserves_limits_of_shape J (forget C)]\n\n/-- A curried version of the fact that filtered colimits commute with finite limits. -/\nnoncomputable def colimit_limit_iso (F : J ⥤ K ⥤ C) :\n  colimit (limit F) ≅ limit (colimit F.flip) :=\n(is_limit_of_preserves colim (limit.is_limit _)).cone_point_unique_up_to_iso (limit.is_limit _) ≪≫\n  (has_limit.iso_of_nat_iso (colimit_flip_iso_comp_colim _).symm)\n\n@[simp, reassoc]\nlemma ι_colimit_limit_iso_limit_π (F : J ⥤ K ⥤ C) (a) (b) :\n  colimit.ι (limit F) a ≫ (colimit_limit_iso F).hom ≫ limit.π (colimit F.flip) b =\n  (limit.π F b).app a ≫ (colimit.ι F.flip a).app b :=\nbegin\n  dsimp [colimit_limit_iso],\n  simp only [functor.map_cone_π_app, iso.symm_hom,\n    limits.limit.cone_point_unique_up_to_iso_hom_comp_assoc, limits.limit.cone_π,\n    limits.colimit.ι_map_assoc, limits.colimit_flip_iso_comp_colim_inv_app, assoc,\n    limits.has_limit.iso_of_nat_iso_hom_π],\n  congr' 1,\n  simp only [← category.assoc, iso.comp_inv_eq,\n    limits.colimit_obj_iso_colimit_comp_evaluation_ι_app_hom,\n    limits.has_colimit.iso_of_nat_iso_ι_hom, nat_iso.of_components.hom_app],\n  dsimp,\n  simp,\nend\n\nend\n\nend category_theory.limits\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/filtered_colimit_commutes_finite_limit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.45385088132700263}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Jeremy Avigad, Simon Hudon\n-/\nimport data.rel\n\n/-- `roption α` is the type of \"partial values\" of type `α`. It\n  is similar to `option α` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure {u} roption (α : Type u) : Type u :=\n(dom : Prop)\n(get : dom → α)\n\nnamespace roption\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\n/-- Convert an `roption α` with a decidable domain to an option -/\ndef to_option (o : roption α) [decidable o.dom] : option α :=\nif h : dom o then some (o.get h) else none\n\n/-- `roption` extensionality -/\ntheorem ext' : ∀ {o p : roption α}\n  (H1 : o.dom ↔ p.dom)\n  (H2 : ∀h₁ h₂, o.get h₁ = p.get h₂), o = p\n| ⟨od, o⟩ ⟨pd, p⟩ H1 H2 := have t : od = pd, from propext H1,\n  by cases t; rw [show o = p, from funext $ λp, H2 p p]\n\n/-- `roption` eta expansion -/\n@[simp] theorem eta : Π (o : roption α), (⟨o.dom, λ h, o.get h⟩ : roption α) = o\n| ⟨h, f⟩ := rfl\n\n/-- `a ∈ o` means that `o` is defined and equal to `a` -/\nprotected def mem (a : α) (o : roption α) : Prop := ∃ h, o.get h = a\n\ninstance : has_mem α (roption α) := ⟨roption.mem⟩\n\ntheorem mem_eq (a : α) (o : roption α) : (a ∈ o) = (∃ h, o.get h = a) :=\nrfl\n\ntheorem dom_iff_mem : ∀ {o : roption α}, o.dom ↔ ∃y, y ∈ o\n| ⟨p, f⟩ := ⟨λh, ⟨f h, h, rfl⟩, λ⟨_, h, rfl⟩, h⟩\n\ntheorem get_mem {o : roption α} (h) : get o h ∈ o := ⟨_, rfl⟩\n\n/-- `roption` extensionality -/\n@[ext]\ntheorem ext {o p : roption α} (H : ∀ a, a ∈ o ↔ a ∈ p) : o = p :=\next' ⟨λ h, ((H _).1 ⟨h, rfl⟩).fst,\n     λ h, ((H _).2 ⟨h, rfl⟩).fst⟩ $\nλ a b, ((H _).2 ⟨_, rfl⟩).snd\n\n/-- The `none` value in `roption` has a `false` domain and an empty function. -/\ndef none : roption α := ⟨false, false.rec _⟩\n\ninstance : inhabited (roption α) := ⟨none⟩\n\n@[simp] theorem not_mem_none (a : α) : a ∉ @none α := λ h, h.fst\n\n/-- The `some a` value in `roption` has a `true` domain and the\n  function returns `a`. -/\ndef some (a : α) : roption α := ⟨true, λ_, a⟩\n\ntheorem mem_unique : ∀ {a b : α} {o : roption α}, a ∈ o → b ∈ o → a = b\n| _ _ ⟨p, f⟩ ⟨h₁, rfl⟩ ⟨h₂, rfl⟩ := rfl\n\ntheorem mem.left_unique : relator.left_unique ((∈) : α → roption α → Prop) :=\n⟨λ a o b, mem_unique⟩\n\ntheorem get_eq_of_mem {o : roption α} {a} (h : a ∈ o) (h') : get o h' = a :=\nmem_unique ⟨_, rfl⟩ h\n\n@[simp] theorem get_some {a : α} (ha : (some a).dom) : get (some a) ha = a := rfl\n\ntheorem mem_some (a : α) : a ∈ some a := ⟨trivial, rfl⟩\n\n@[simp] theorem mem_some_iff {a b} : b ∈ (some a : roption α) ↔ b = a :=\n⟨λ⟨h, e⟩, e.symm, λ e, ⟨trivial, e.symm⟩⟩\n\ntheorem eq_some_iff {a : α} {o : roption α} : o = some a ↔ a ∈ o :=\n⟨λ e, e.symm ▸ mem_some _,\n λ ⟨h, e⟩, e ▸ ext' (iff_true_intro h) (λ _ _, rfl)⟩\n\ntheorem eq_none_iff {o : roption α} : o = none ↔ ∀ a, a ∉ o :=\n⟨λ e, e.symm ▸ not_mem_none,\n λ h, ext (by simpa [not_mem_none])⟩\n\ntheorem eq_none_iff' {o : roption α} : o = none ↔ ¬ o.dom :=\n⟨λ e, e.symm ▸ id, λ h, eq_none_iff.2 (λ a h', h h'.fst)⟩\n\nlemma some_ne_none (x : α) : some x ≠ none :=\nby { intro h, change none.dom, rw [← h], trivial }\n\nlemma ne_none_iff {o : roption α} : o ≠ none ↔ ∃x, o = some x :=\nbegin\n  split,\n  { rw [ne, eq_none_iff], intro h, push_neg at h, cases h with x hx, use x, rwa [eq_some_iff] },\n  { rintro ⟨x, rfl⟩, apply some_ne_none }\nend\n\nlemma eq_none_or_eq_some (o : roption α) : o = none ∨ ∃ x, o = some x :=\nbegin\n  classical,\n  by_cases h : o.dom,\n  { rw dom_iff_mem at h, right,\n    apply exists_imp_exists _ h,\n    simp [eq_some_iff] },\n  { rw eq_none_iff', exact or.inl h },\nend\n\n@[simp] lemma some_inj {a b : α} : roption.some a = some b ↔ a = b :=\nfunction.injective.eq_iff (λ a b h, congr_fun (eq_of_heq (roption.mk.inj h).2) trivial)\n\n@[simp] lemma some_get {a : roption α} (ha : a.dom) :\n  roption.some (roption.get a ha) = a :=\neq.symm (eq_some_iff.2 ⟨ha, rfl⟩)\n\nlemma get_eq_iff_eq_some {a : roption α} {ha : a.dom} {b : α} :\n  a.get ha = b ↔ a = some b :=\n⟨λ h, by simp [h.symm], λ h, by simp [h]⟩\n\nlemma get_eq_get_of_eq (a : roption α) (ha : a.dom) {b : roption α} (h : a = b) :\n  a.get ha = b.get (h ▸ ha) :=\nby { congr, exact h }\n\ninstance none_decidable : decidable (@none α).dom := decidable.false\ninstance some_decidable (a : α) : decidable (some a).dom := decidable.true\n\ndef get_or_else (a : roption α) [decidable a.dom] (d : α) :=\nif ha : a.dom then a.get ha else d\n\n@[simp] lemma get_or_else_none (d : α) : get_or_else none d = d :=\ndif_neg id\n\n@[simp] lemma get_or_else_some (a : α) (d : α) : get_or_else (some a) d = a :=\ndif_pos trivial\n\n@[simp] theorem mem_to_option {o : roption α} [decidable o.dom] {a : α} :\n  a ∈ to_option o ↔ a ∈ o :=\nbegin\n  unfold to_option,\n  by_cases h : o.dom; simp [h],\n  { exact ⟨λ h, ⟨_, h⟩, λ ⟨_, h⟩, h⟩ },\n  { exact mt Exists.fst h }\nend\n\n/-- Convert an `option α` into an `roption α` -/\ndef of_option : option α → roption α\n| option.none     := none\n| (option.some a) := some a\n\n@[simp] theorem mem_of_option {a : α} : ∀ {o : option α}, a ∈ of_option o ↔ a ∈ o\n| option.none     := ⟨λ h, h.fst.elim, λ h, option.no_confusion h⟩\n| (option.some b) := ⟨λ h, congr_arg option.some h.snd,\n  λ h, ⟨trivial, option.some.inj h⟩⟩\n\n@[simp] theorem of_option_dom {α} : ∀ (o : option α), (of_option o).dom ↔ o.is_some\n| option.none     := by simp [of_option, none]\n| (option.some a) := by simp [of_option]\n\ntheorem of_option_eq_get {α} (o : option α) : of_option o = ⟨_, @option.get _ o⟩ :=\nroption.ext' (of_option_dom o) $ λ h₁ h₂, by cases o; [cases h₁, refl]\n\ninstance : has_coe (option α) (roption α) := ⟨of_option⟩\n\n@[simp] theorem mem_coe {a : α} {o : option α} :\n  a ∈ (o : roption α) ↔ a ∈ o := mem_of_option\n\n@[simp] theorem coe_none : (@option.none α : roption α) = none := rfl\n@[simp] theorem coe_some (a : α) : (option.some a : roption α) = some a := rfl\n\n@[elab_as_eliminator] protected lemma induction_on {P : roption α → Prop}\n  (a : roption α) (hnone : P none) (hsome : ∀ a : α, P (some a)) : P a :=\n(classical.em a.dom).elim\n  (λ h, roption.some_get h ▸ hsome _)\n  (λ h, (eq_none_iff'.2 h).symm ▸ hnone)\n\ninstance of_option_decidable : ∀ o : option α, decidable (of_option o).dom\n| option.none     := roption.none_decidable\n| (option.some a) := roption.some_decidable a\n\n@[simp] theorem to_of_option (o : option α) : to_option (of_option o) = o :=\nby cases o; refl\n\n@[simp] theorem of_to_option (o : roption α) [decidable o.dom] : of_option (to_option o) = o :=\next $ λ a, mem_of_option.trans mem_to_option\n\nnoncomputable def equiv_option : roption α ≃ option α :=\nby haveI := classical.dec; exact\n⟨λ o, to_option o, of_option, λ o, of_to_option o,\n λ o, eq.trans (by dsimp; congr) (to_of_option o)⟩\n\ninstance : order_bot (roption α) :=\n{ le := λ x y, ∀ i, i ∈ x → i ∈ y,\n  le_refl := λ x y, id,\n  le_trans := λ x y z f g i, g _ ∘ f _,\n  le_antisymm := λ x y f g, roption.ext $ λ z, ⟨f _, g _⟩,\n  bot := none,\n  bot_le := by { introv x, rintro ⟨⟨_⟩,_⟩, } }\n\ninstance : preorder (roption α) :=\nby apply_instance\n\nlemma le_total_of_le_of_le {x y : roption α} (z : roption α) (hx : x ≤ z) (hy : y ≤ z) :\n  x ≤ y ∨ y ≤ x :=\nbegin\n  rcases roption.eq_none_or_eq_some x with h | ⟨b, h₀⟩,\n  { rw h, left, apply order_bot.bot_le _ },\n  right, intros b' h₁,\n  rw roption.eq_some_iff at h₀,\n  replace hx := hx _ h₀, replace hy := hy _ h₁,\n  replace hx := roption.mem_unique hx hy, subst hx,\n  exact h₀\nend\n\n/-- `assert p f` is a bind-like operation which appends an additional condition\n  `p` to the domain and uses `f` to produce the value. -/\ndef assert (p : Prop) (f : p → roption α) : roption α :=\n⟨∃h : p, (f h).dom, λha, (f ha.fst).get ha.snd⟩\n\n/-- The bind operation has value `g (f.get)`, and is defined when all the\n  parts are defined. -/\nprotected def bind (f : roption α) (g : α → roption β) : roption β :=\nassert (dom f) (λb, g (f.get b))\n\n/-- The map operation for `roption` just maps the value and maintains the same domain. -/\ndef map (f : α → β) (o : roption α) : roption β :=\n⟨o.dom, f ∘ o.get⟩\n\ntheorem mem_map (f : α → β) {o : roption α} :\n  ∀ {a}, a ∈ o → f a ∈ map f o\n| _ ⟨h, rfl⟩ := ⟨_, rfl⟩\n\n@[simp] theorem mem_map_iff (f : α → β) {o : roption α} {b} :\n  b ∈ map f o ↔ ∃ a ∈ o, f a = b :=\n⟨match b with _, ⟨h, rfl⟩ := ⟨_, ⟨_, rfl⟩, rfl⟩ end,\n λ ⟨a, h₁, h₂⟩, h₂ ▸ mem_map f h₁⟩\n\n@[simp] theorem map_none (f : α → β) :\n  map f none = none := eq_none_iff.2 $ λ a, by simp\n\n@[simp] theorem map_some (f : α → β) (a : α) : map f (some a) = some (f a) :=\neq_some_iff.2 $ mem_map f $ mem_some _\n\ntheorem mem_assert {p : Prop} {f : p → roption α}\n  : ∀ {a} (h : p), a ∈ f h → a ∈ assert p f\n| _ x ⟨h, rfl⟩ := ⟨⟨x, h⟩, rfl⟩\n\n@[simp] theorem mem_assert_iff {p : Prop} {f : p → roption α} {a} :\n  a ∈ assert p f ↔ ∃ h : p, a ∈ f h :=\n⟨match a with _, ⟨h, rfl⟩ := ⟨_, ⟨_, rfl⟩⟩ end,\n λ ⟨a, h⟩, mem_assert _ h⟩\n\nlemma assert_pos {p : Prop} {f : p → roption α} (h : p) :\n  assert p f = f h :=\nbegin\n  dsimp [assert],\n  cases h' : f h,\n  simp only [h', h, true_and, iff_self, exists_prop_of_true, eq_iff_iff],\n  apply function.hfunext,\n  { simp only [h,h',exists_prop_of_true] },\n  { cc }\nend\n\nlemma assert_neg {p : Prop} {f : p → roption α} (h : ¬ p) :\n  assert p f = none :=\nbegin\n  dsimp [assert,none], congr,\n  { simp only [h, not_false_iff, exists_prop_of_false] },\n  { apply function.hfunext,\n    { simp only [h, not_false_iff, exists_prop_of_false] },\n    cc },\nend\n\ntheorem mem_bind {f : roption α} {g : α → roption β} :\n  ∀ {a b}, a ∈ f → b ∈ g a → b ∈ f.bind g\n| _ _ ⟨h, rfl⟩ ⟨h₂, rfl⟩ := ⟨⟨h, h₂⟩, rfl⟩\n\n@[simp] theorem mem_bind_iff {f : roption α} {g : α → roption β} {b} :\n  b ∈ f.bind g ↔ ∃ a ∈ f, b ∈ g a :=\n⟨match b with _, ⟨⟨h₁, h₂⟩, rfl⟩ := ⟨_, ⟨_, rfl⟩, ⟨_, rfl⟩⟩ end,\n λ ⟨a, h₁, h₂⟩, mem_bind h₁ h₂⟩\n\n@[simp] theorem bind_none (f : α → roption β) :\n  none.bind f = none := eq_none_iff.2 $ λ a, by simp\n\n@[simp] theorem bind_some (a : α) (f : α → roption β) :\n  (some a).bind f = f a := ext $ by simp\n\ntheorem bind_some_eq_map (f : α → β) (x : roption α) :\n  x.bind (some ∘ f) = map f x :=\next $ by simp [eq_comm]\n\ntheorem bind_assoc {γ} (f : roption α) (g : α → roption β) (k : β → roption γ) :\n  (f.bind g).bind k = f.bind (λ x, (g x).bind k) :=\next $ λ a, by simp; exact\n ⟨λ ⟨_, ⟨_, h₁, h₂⟩, h₃⟩, ⟨_, h₁, _, h₂, h₃⟩,\n  λ ⟨_, h₁, _, h₂, h₃⟩, ⟨_, ⟨_, h₁, h₂⟩, h₃⟩⟩\n\n@[simp] theorem bind_map {γ} (f : α → β) (x) (g : β → roption γ) :\n  (map f x).bind g = x.bind (λ y, g (f y)) :=\nby rw [← bind_some_eq_map, bind_assoc]; simp\n\n@[simp] theorem map_bind {γ} (f : α → roption β) (x : roption α) (g : β → γ) :\n  map g (x.bind f) = x.bind (λ y, map g (f y)) :=\nby rw [← bind_some_eq_map, bind_assoc]; simp [bind_some_eq_map]\n\ntheorem map_map (g : β → γ) (f : α → β) (o : roption α) :\n  map g (map f o) = map (g ∘ f) o :=\nby rw [← bind_some_eq_map, bind_map, bind_some_eq_map]\n\ninstance : monad roption :=\n{ pure := @some,\n  map := @map,\n  bind := @roption.bind }\n\ninstance : is_lawful_monad roption :=\n{ bind_pure_comp_eq_map := @bind_some_eq_map,\n  id_map := λ β f, by cases f; refl,\n  pure_bind := @bind_some,\n  bind_assoc := @bind_assoc }\n\ntheorem map_id' {f : α → α} (H : ∀ (x : α), f x = x) (o) : map f o = o :=\nby rw [show f = id, from funext H]; exact id_map o\n\n@[simp] theorem bind_some_right (x : roption α) : x.bind some = x :=\nby rw [bind_some_eq_map]; simp [map_id']\n\n@[simp] theorem pure_eq_some (a : α) : pure a = some a := rfl\n@[simp] theorem ret_eq_some (a : α) : return a = some a := rfl\n\n@[simp] theorem map_eq_map {α β} (f : α → β) (o : roption α) :\n  f <$> o = map f o := rfl\n\n@[simp] theorem bind_eq_bind {α β} (f : roption α) (g : α → roption β) :\n  f >>= g = f.bind g := rfl\n\nlemma bind_le {α} (x : roption α) (f : α → roption β) (y : roption β) :\n  x >>= f ≤ y ↔ (∀ a, a ∈ x → f a ≤ y) :=\nbegin\n  split; intro h,\n  { intros a h' b, replace h := h b,\n    simp only [and_imp, exists_prop, bind_eq_bind, mem_bind_iff, exists_imp_distrib] at h,\n    apply h _ h' },\n  { intros b h',\n    simp only [exists_prop, bind_eq_bind, mem_bind_iff] at h',\n    rcases h' with ⟨a,h₀,h₁⟩, apply h _ h₀ _ h₁ },\nend\n\ninstance : monad_fail roption :=\n{ fail := λ_ _, none, ..roption.monad }\n\n/- `restrict p o h` replaces the domain of `o` with `p`, and is well defined when\n  `p` implies `o` is defined. -/\ndef restrict (p : Prop) : ∀ (o : roption α), (p → o.dom) → roption α\n| ⟨d, f⟩ H := ⟨p, λh, f (H h)⟩\n\n@[simp]\ntheorem mem_restrict (p : Prop) (o : roption α) (h : p → o.dom) (a : α) :\n  a ∈ restrict p o h ↔ p ∧ a ∈ o :=\nbegin\n  cases o, dsimp [restrict, mem_eq], split,\n  { rintro ⟨h₀, h₁⟩, exact ⟨h₀, ⟨_, h₁⟩⟩ },\n  rintro ⟨h₀, h₁, h₂⟩, exact ⟨h₀, h₂⟩\nend\n\n/-- `unwrap o` gets the value at `o`, ignoring the condition.\n  (This function is unsound.) -/\nmeta def unwrap (o : roption α) : α := o.get undefined\n\ntheorem assert_defined {p : Prop} {f : p → roption α} :\n  ∀ (h : p), (f h).dom → (assert p f).dom := exists.intro\n\ntheorem bind_defined {f : roption α} {g : α → roption β} :\n  ∀ (h : f.dom), (g (f.get h)).dom → (f.bind g).dom := assert_defined\n\n@[simp] theorem bind_dom {f : roption α} {g : α → roption β} :\n  (f.bind g).dom ↔ ∃ h : f.dom, (g (f.get h)).dom := iff.rfl\n\nend roption\n\n/-- `pfun α β`, or `α →. β`, is the type of partial functions from\n  `α` to `β`. It is defined as `α → roption β`. -/\ndef pfun (α : Type*) (β : Type*) := α → roption β\n\ninfixr ` →. `:25 := pfun\n\nnamespace pfun\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\ninstance : inhabited (α →. β) := ⟨λ a, roption.none⟩\n\n/-- The domain of a partial function -/\ndef dom (f : α →. β) : set α := {a | (f a).dom}\n\ntheorem mem_dom (f : α →. β) (x : α) : x ∈ dom f ↔ ∃ y, y ∈ f x :=\nby simp [dom, roption.dom_iff_mem]\n\ntheorem dom_eq (f : α →. β) : dom f = {x | ∃ y, y ∈ f x} :=\nset.ext (mem_dom f)\n\n/-- Evaluate a partial function -/\ndef fn (f : α →. β) (x) (h : dom f x) : β := (f x).get h\n\n/-- Evaluate a partial function to return an `option` -/\ndef eval_opt (f : α →. β) [D : decidable_pred (dom f)] (x : α) : option β :=\n@roption.to_option _ _ (D x)\n\n/-- Partial function extensionality -/\ntheorem ext' {f g : α →. β}\n  (H1 : ∀ a, a ∈ dom f ↔ a ∈ dom g)\n  (H2 : ∀ a p q, f.fn a p = g.fn a q) : f = g :=\nfunext $ λ a, roption.ext' (H1 a) (H2 a)\n\ntheorem ext {f g : α →. β} (H : ∀ a b, b ∈ f a ↔ b ∈ g a) : f = g :=\nfunext $ λ a, roption.ext (H a)\n\n/-- Turn a partial function into a function out of a subtype -/\ndef as_subtype (f : α →. β) (s : f.dom) : β := f.fn s s.2\n\n/-- The set of partial functions `α →. β` is equivalent to\nthe set of pairs `(p : α → Prop, f : subtype p → β)`. -/\ndef equiv_subtype : (α →. β) ≃ (Σ p : α → Prop, subtype p → β) :=\n⟨λ f, ⟨λ a, (f a).dom, as_subtype f⟩,\n λ f x, ⟨f.1 x, λ h, f.2 ⟨x, h⟩⟩,\n λ f, funext $ λ a, roption.eta _,\n λ ⟨p, f⟩, by dsimp; congr; funext a; cases a; refl⟩\n\ntheorem as_subtype_eq_of_mem {f : α →. β} {x : α} {y : β} (fxy : y ∈ f x) (domx : x ∈ f.dom) :\n  f.as_subtype ⟨x, domx⟩ = y :=\nroption.mem_unique (roption.get_mem _) fxy\n\n/-- Turn a total function into a partial function -/\nprotected def lift (f : α → β) : α →. β := λ a, roption.some (f a)\n\ninstance : has_coe (α → β) (α →. β) := ⟨pfun.lift⟩\n\n@[simp] theorem lift_eq_coe (f : α → β) : pfun.lift f = f := rfl\n\n@[simp] theorem coe_val (f : α → β) (a : α) :\n  (f : α →. β) a = roption.some (f a) := rfl\n\n/-- The graph of a partial function is the set of pairs\n  `(x, f x)` where `x` is in the domain of `f`. -/\ndef graph (f : α →. β) : set (α × β) := {p | p.2 ∈ f p.1}\n\ndef graph' (f : α →. β) : rel α β := λ x y, y ∈ f x\n\n/-- The range of a partial function is the set of values\n  `f x` where `x` is in the domain of `f`. -/\ndef ran (f : α →. β) : set β := {b | ∃a, b ∈ f a}\n\n/-- Restrict a partial function to a smaller domain. -/\ndef restrict (f : α →. β) {p : set α} (H : p ⊆ f.dom) : α →. β :=\nλ x, roption.restrict (x ∈ p) (f x) (@H x)\n\n@[simp]\ntheorem mem_restrict {f : α →. β} {s : set α} (h : s ⊆ f.dom) (a : α) (b : β) :\n  b ∈ restrict f h a ↔ a ∈ s ∧ b ∈ f a :=\nby simp [restrict]\n\ndef res (f : α → β) (s : set α) : α →. β :=\nrestrict (pfun.lift f) (set.subset_univ s)\n\ntheorem mem_res (f : α → β) (s : set α) (a : α) (b : β) :\n  b ∈ res f s a ↔ (a ∈ s ∧ f a = b) :=\nby simp [res, @eq_comm _ b]\n\ntheorem res_univ (f : α → β) : pfun.res f set.univ = f :=\nrfl\n\ntheorem dom_iff_graph (f : α →. β) (x : α) : x ∈ f.dom ↔ ∃y, (x, y) ∈ f.graph :=\nroption.dom_iff_mem\n\ntheorem lift_graph {f : α → β} {a b} : (a, b) ∈ (f : α →. β).graph ↔ f a = b :=\nshow (∃ (h : true), f a = b) ↔ f a = b, by simp\n\n/-- The monad `pure` function, the total constant `x` function -/\nprotected def pure (x : β) : α →. β := λ_, roption.some x\n\n/-- The monad `bind` function, pointwise `roption.bind` -/\ndef bind (f : α →. β) (g : β → α →. γ) : α →. γ :=\nλa, roption.bind (f a) (λb, g b a)\n\n/-- The monad `map` function, pointwise `roption.map` -/\ndef map (f : β → γ) (g : α →. β) : α →. γ :=\nλa, roption.map f (g a)\n\ninstance : monad (pfun α) :=\n{ pure := @pfun.pure _,\n  bind := @pfun.bind _,\n  map := @pfun.map _ }\n\ninstance : is_lawful_monad (pfun α) :=\n{ bind_pure_comp_eq_map := λ β γ f x, funext $ λ a, roption.bind_some_eq_map _ _,\n  id_map := λ β f, by funext a; dsimp [functor.map, pfun.map]; cases f a; refl,\n  pure_bind := λ β γ x f, funext $ λ a, roption.bind_some.{u_1 u_2} _ (f x),\n  bind_assoc := λ β γ δ f g k,\n    funext $ λ a, roption.bind_assoc (f a) (λ b, g b a) (λ b, k b a) }\n\ntheorem pure_defined (p : set α) (x : β) : p ⊆ (@pfun.pure α _ x).dom := set.subset_univ p\n\ntheorem bind_defined {α β γ} (p : set α) {f : α →. β} {g : β → α →. γ}\n  (H1 : p ⊆ f.dom) (H2 : ∀x, p ⊆ (g x).dom) : p ⊆ (f >>= g).dom :=\nλa ha, (⟨H1 ha, H2 _ ha⟩ : (f >>= g).dom a)\n\ndef fix (f : α →. β ⊕ α) : α →. β := λ a,\nroption.assert (acc (λ x y, sum.inr x ∈ f y) a) $ λ h,\n@well_founded.fix_F _ (λ x y, sum.inr x ∈ f y) _\n  (λ a IH, roption.assert (f a).dom $ λ hf,\n    by cases e : (f a).get hf with b a';\n      [exact roption.some b, exact IH _ ⟨hf, e⟩])\n  a h\n\ntheorem dom_of_mem_fix {f : α →. β ⊕ α} {a : α} {b : β}\n  (h : b ∈ fix f a) : (f a).dom :=\nlet ⟨h₁, h₂⟩ := roption.mem_assert_iff.1 h in\nby rw well_founded.fix_F_eq at h₂; exact h₂.fst.fst\n\ntheorem mem_fix_iff {f : α →. β ⊕ α} {a : α} {b : β} :\n  b ∈ fix f a ↔ sum.inl b ∈ f a ∨ ∃ a', sum.inr a' ∈ f a ∧ b ∈ fix f a' :=\n⟨λ h, let ⟨h₁, h₂⟩ := roption.mem_assert_iff.1 h in\n  begin\n    rw well_founded.fix_F_eq at h₂,\n    simp at h₂,\n    cases h₂ with h₂ h₃,\n    cases e : (f a).get h₂ with b' a'; simp [e] at h₃,\n    { subst b', refine or.inl ⟨h₂, e⟩ },\n    { exact or.inr ⟨a', ⟨_, e⟩, roption.mem_assert _ h₃⟩ }\n  end,\nλ h, begin\n  simp [fix],\n  rcases h with ⟨h₁, h₂⟩ | ⟨a', h, h₃⟩,\n  { refine ⟨⟨_, λ y h', _⟩, _⟩,\n    { injection roption.mem_unique ⟨h₁, h₂⟩ h' },\n    { rw well_founded.fix_F_eq, simp [h₁, h₂] } },\n  { simp [fix] at h₃, cases h₃ with h₃ h₄,\n    refine ⟨⟨_, λ y h', _⟩, _⟩,\n    { injection roption.mem_unique h h' with e,\n      exact e ▸ h₃ },\n    { cases h with h₁ h₂,\n      rw well_founded.fix_F_eq, simp [h₁, h₂, h₄] } }\nend⟩\n\n@[elab_as_eliminator] def fix_induction\n  {f : α →. β ⊕ α} {b : β} {C : α → Sort*} {a : α} (h : b ∈ fix f a)\n  (H : ∀ a, b ∈ fix f a →\n    (∀ a', b ∈ fix f a' → sum.inr a' ∈ f a → C a') → C a) : C a :=\nbegin\n  replace h := roption.mem_assert_iff.1 h,\n  have := h.snd, revert this,\n  induction h.fst with a ha IH, intro h₂,\n  refine H a (roption.mem_assert_iff.2 ⟨⟨_, ha⟩, h₂⟩)\n    (λ a' ha' fa', _),\n  have := (roption.mem_assert_iff.1 ha').snd,\n  exact IH _ fa' ⟨ha _ fa', this⟩ this\nend\n\nend pfun\n\nnamespace pfun\n\nvariables {α : Type*} {β : Type*} (f : α →. β)\n\ndef image (s : set α) : set β := rel.image f.graph' s\n\nlemma image_def (s : set α) : image f s = {y | ∃ x ∈ s, y ∈ f x} := rfl\n\nlemma mem_image (y : β) (s : set α) : y ∈ image f s ↔ ∃ x ∈ s, y ∈ f x :=\niff.rfl\n\nlemma image_mono {s t : set α} (h : s ⊆ t) : f.image s ⊆ f.image t :=\nrel.image_mono _ h\n\nlemma image_inter (s t : set α) : f.image (s ∩ t) ⊆ f.image s ∩ f.image t :=\nrel.image_inter _ s t\n\nlemma image_union (s t : set α) : f.image (s ∪ t) = f.image s ∪ f.image t :=\nrel.image_union _ s t\n\ndef preimage (s : set β) : set α := rel.preimage (λ x y, y ∈ f x) s\n\nlemma preimage_def (s : set β) : preimage f s = {x | ∃ y ∈ s, y ∈ f x} := rfl\n\nlemma mem_preimage (s : set β) (x : α) : x ∈ preimage f s ↔ ∃ y ∈ s, y ∈ f x :=\niff.rfl\n\nlemma preimage_subset_dom (s : set β) : f.preimage s ⊆ f.dom :=\nassume x ⟨y, ys, fxy⟩, roption.dom_iff_mem.mpr ⟨y, fxy⟩\n\nlemma preimage_mono {s t : set β} (h : s ⊆ t) : f.preimage s ⊆ f.preimage t :=\nrel.preimage_mono _ h\n\nlemma preimage_inter (s t : set β) : f.preimage (s ∩ t) ⊆ f.preimage s ∩ f.preimage t :=\nrel.preimage_inter _ s t\n\nlemma preimage_union (s t : set β) : f.preimage (s ∪ t) = f.preimage s ∪ f.preimage t :=\nrel.preimage_union _ s t\n\nlemma preimage_univ : f.preimage set.univ = f.dom :=\nby ext; simp [mem_preimage, mem_dom]\n\ndef core (s : set β) : set α := rel.core f.graph' s\n\nlemma core_def (s : set β) : core f s = {x | ∀ y, y ∈ f x → y ∈ s} := rfl\n\nlemma mem_core (x : α) (s : set β) : x ∈ core f s ↔ (∀ y, y ∈ f x → y ∈ s) :=\niff.rfl\n\nlemma compl_dom_subset_core (s : set β) : f.domᶜ ⊆ f.core s :=\nassume x hx y fxy,\nabsurd ((mem_dom f x).mpr ⟨y, fxy⟩) hx\n\nlemma core_mono {s t : set β} (h : s ⊆ t) : f.core s ⊆ f.core t :=\nrel.core_mono _ h\n\nlemma core_inter (s t : set β) : f.core (s ∩ t) = f.core s ∩ f.core t :=\nrel.core_inter _ s t\n\nlemma mem_core_res (f : α → β) (s : set α) (t : set β) (x : α) :\n  x ∈ core (res f s) t ↔ (x ∈ s → f x ∈ t) :=\nby simp [mem_core, mem_res]\n\nsection\nopen_locale classical\n\nlemma core_res (f : α → β) (s : set α) (t : set β) : core (res f s) t = sᶜ ∪ f ⁻¹' t :=\nby { ext, rw mem_core_res, by_cases h : x ∈ s; simp [h] }\n\nend\n\nlemma core_restrict (f : α → β) (s : set β) : core (f : α →. β) s = set.preimage f s :=\nby ext x; simp [core_def]\n\nlemma preimage_subset_core (f : α →. β) (s : set β) : f.preimage s ⊆ f.core s :=\nassume x ⟨y, ys, fxy⟩ y' fxy',\nhave y = y', from roption.mem_unique fxy fxy',\nthis ▸ ys\n\nlemma preimage_eq (f : α →. β) (s : set β) : f.preimage s = f.core s ∩ f.dom :=\nset.eq_of_subset_of_subset\n  (set.subset_inter (preimage_subset_core f s) (preimage_subset_dom f s))\n  (assume x ⟨xcore, xdom⟩,\n    let y := (f x).get xdom in\n    have ys : y ∈ s, from xcore _ (roption.get_mem _),\n    show x ∈ preimage f s, from  ⟨(f x).get xdom, ys, roption.get_mem _⟩)\n\nlemma core_eq (f : α →. β) (s : set β) : f.core s = f.preimage s ∪ f.domᶜ :=\nby rw [preimage_eq, set.union_distrib_right, set.union_comm (dom f), set.compl_union_self,\n        set.inter_univ, set.union_eq_self_of_subset_right (compl_dom_subset_core f s)]\n\nlemma preimage_as_subtype (f : α →. β) (s : set β) :\n  f.as_subtype ⁻¹' s = subtype.val ⁻¹' pfun.preimage f s :=\nbegin\n  ext x,\n  simp only [set.mem_preimage, set.mem_set_of_eq, pfun.as_subtype, pfun.mem_preimage],\n  show pfun.fn f (x.val) _ ∈ s ↔ ∃ y ∈ s, y ∈ f (x.val),\n  exact iff.intro\n    (assume h, ⟨_, h, roption.get_mem _⟩)\n    (assume ⟨y, ys, fxy⟩,\n      have f.fn x.val x.property ∈ f x.val := roption.get_mem _,\n      roption.mem_unique fxy this ▸ ys)\nend\n\nend pfun\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/data/pfun.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.658417500561683, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4538508771246094}}
{"text": "/-\nCopyright (c) 2018 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Yury Kudryashov\n-/\nimport algebra.algebra.basic\n\n/-!\n# Homomorphisms of `R`-algebras\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines bundled homomorphisms of `R`-algebras.\n\n## Main definitions\n\n* `alg_hom R A B`: the type of `R`-algebra morphisms from `A` to `B`.\n* `algebra.of_id R A : R →ₐ[R] A`: the canonical map from `R` to `A`, as an `alg_hom`.\n\n## Notations\n\n* `A →ₐ[R] B` : `R`-algebra homomorphism from `A` to `B`.\n-/\n\nopen_locale big_operators\n\nuniverses u v w u₁ v₁\n\nset_option old_structure_cmd true\n/-- Defining the homomorphism in the category R-Alg. -/\n@[nolint has_nonempty_instance]\nstructure alg_hom (R : Type u) (A : Type v) (B : Type w)\n  [comm_semiring R] [semiring A] [semiring B] [algebra R A] [algebra R B] extends ring_hom A B :=\n(commutes' : ∀ r : R, to_fun (algebra_map R A r) = algebra_map R B r)\n\nrun_cmd tactic.add_doc_string `alg_hom.to_ring_hom \"Reinterpret an `alg_hom` as a `ring_hom`\"\n\ninfixr ` →ₐ `:25 := alg_hom _\nnotation A ` →ₐ[`:25 R `] ` B := alg_hom R A B\n\n/-- `alg_hom_class F R A B` asserts `F` is a type of bundled algebra homomorphisms\nfrom `A` to `B`.  -/\nclass alg_hom_class (F : Type*) (R : out_param Type*) (A : out_param Type*) (B : out_param Type*)\n  [comm_semiring R] [semiring A] [semiring B] [algebra R A] [algebra R B]\n  extends ring_hom_class F A B :=\n(commutes : ∀ (f : F) (r : R), f (algebra_map R A r) = algebra_map R B r)\n\n-- `R` becomes a metavariable but that's fine because it's an `out_param`\nattribute [nolint dangerous_instance] alg_hom_class.to_ring_hom_class\n\nattribute [simp] alg_hom_class.commutes\n\nnamespace alg_hom_class\n\nvariables {R : Type*} {A : Type*} {B : Type*} [comm_semiring R] [semiring A] [semiring B]\n  [algebra R A] [algebra R B]\n\n@[priority 100] -- see Note [lower instance priority]\ninstance {F : Type*} [alg_hom_class F R A B] : linear_map_class F R A B :=\n{ map_smulₛₗ := λ f r x, by simp only [algebra.smul_def, map_mul, commutes, ring_hom.id_apply],\n  ..‹alg_hom_class F R A B› }\n\ninstance {F : Type*} [alg_hom_class F R A B] : has_coe_t F (A →ₐ[R] B) :=\n{ coe := λ f,\n  { to_fun := f,\n    commutes' := alg_hom_class.commutes f,\n    .. (f : A →+* B) } }\n\nend alg_hom_class\n\nnamespace alg_hom\n\nvariables {R : Type u} {A : Type v} {B : Type w} {C : Type u₁} {D : Type v₁}\n\nsection semiring\n\nvariables [comm_semiring R] [semiring A] [semiring B] [semiring C] [semiring D]\nvariables [algebra R A] [algebra R B] [algebra R C] [algebra R D]\n\ninstance : has_coe_to_fun (A →ₐ[R] B) (λ _, A → B) := ⟨alg_hom.to_fun⟩\n\ninitialize_simps_projections alg_hom (to_fun → apply)\n\n@[simp, protected] lemma coe_coe {F : Type*} [alg_hom_class F R A B] (f : F) :\n  ⇑(f : A →ₐ[R] B) = f := rfl\n\n@[simp] lemma to_fun_eq_coe (f : A →ₐ[R] B) : f.to_fun = f := rfl\n\ninstance : alg_hom_class (A →ₐ[R] B) R A B :=\n{ coe := to_fun,\n  coe_injective' := λ f g h, by { cases f, cases g, congr' },\n  map_add := map_add',\n  map_zero := map_zero',\n  map_mul := map_mul',\n  map_one := map_one',\n  commutes := λ f, f.commutes' }\n\ninstance coe_ring_hom : has_coe (A →ₐ[R] B) (A →+* B) := ⟨alg_hom.to_ring_hom⟩\n\ninstance coe_monoid_hom : has_coe (A →ₐ[R] B) (A →* B) := ⟨λ f, ↑(f : A →+* B)⟩\n\ninstance coe_add_monoid_hom : has_coe (A →ₐ[R] B) (A →+ B) := ⟨λ f, ↑(f : A →+* B)⟩\n\n@[simp, norm_cast] lemma coe_mk {f : A → B} (h₁ h₂ h₃ h₄ h₅) :\n  ⇑(⟨f, h₁, h₂, h₃, h₄, h₅⟩ : A →ₐ[R] B) = f := rfl\n\n-- make the coercion the simp-normal form\n@[simp] lemma to_ring_hom_eq_coe (f : A →ₐ[R] B) : f.to_ring_hom = f := rfl\n\n@[simp, norm_cast] lemma coe_to_ring_hom (f : A →ₐ[R] B) : ⇑(f : A →+* B) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_monoid_hom (f : A →ₐ[R] B) : ⇑(f : A →* B) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_add_monoid_hom (f : A →ₐ[R] B) : ⇑(f : A →+ B) = f := rfl\n\nvariables (φ : A →ₐ[R] B)\n\ntheorem coe_fn_injective : @function.injective (A →ₐ[R] B) (A → B) coe_fn := fun_like.coe_injective\n\ntheorem coe_fn_inj {φ₁ φ₂ : A →ₐ[R] B} : (φ₁ : A → B) = φ₂ ↔ φ₁ = φ₂ := fun_like.coe_fn_eq\n\ntheorem coe_ring_hom_injective : function.injective (coe : (A →ₐ[R] B) → (A →+* B)) :=\nλ φ₁ φ₂ H, coe_fn_injective $ show ((φ₁ : (A →+* B)) : A → B) = ((φ₂ : (A →+* B)) : A → B),\n  from congr_arg _ H\n\ntheorem coe_monoid_hom_injective : function.injective (coe : (A →ₐ[R] B)  → (A →* B)) :=\nring_hom.coe_monoid_hom_injective.comp coe_ring_hom_injective\n\ntheorem coe_add_monoid_hom_injective : function.injective (coe : (A →ₐ[R] B)  → (A →+ B)) :=\nring_hom.coe_add_monoid_hom_injective.comp coe_ring_hom_injective\n\nprotected lemma congr_fun {φ₁ φ₂ : A →ₐ[R] B} (H : φ₁ = φ₂) (x : A) : φ₁ x = φ₂ x :=\nfun_like.congr_fun H x\nprotected lemma congr_arg (φ : A →ₐ[R] B) {x y : A} (h : x = y) : φ x = φ y :=\nfun_like.congr_arg φ h\n\n@[ext]\ntheorem ext {φ₁ φ₂ : A →ₐ[R] B} (H : ∀ x, φ₁ x = φ₂ x) : φ₁ = φ₂ := fun_like.ext _ _ H\n\ntheorem ext_iff {φ₁ φ₂ : A →ₐ[R] B} : φ₁ = φ₂ ↔ ∀ x, φ₁ x = φ₂ x := fun_like.ext_iff\n\n@[simp] theorem mk_coe {f : A →ₐ[R] B} (h₁ h₂ h₃ h₄ h₅) :\n  (⟨f, h₁, h₂, h₃, h₄, h₅⟩ : A →ₐ[R] B) = f := ext $ λ _, rfl\n\n@[simp]\ntheorem commutes (r : R) : φ (algebra_map R A r) = algebra_map R B r := φ.commutes' r\n\ntheorem comp_algebra_map : (φ : A →+* B).comp (algebra_map R A) = algebra_map R B :=\nring_hom.ext $ φ.commutes\n\nprotected lemma map_add (r s : A) : φ (r + s) = φ r + φ s := map_add _ _ _\nprotected lemma map_zero : φ 0 = 0 := map_zero _\nprotected lemma map_mul (x y) : φ (x * y) = φ x * φ y := map_mul _ _ _\nprotected lemma map_one : φ 1 = 1 := map_one _\nprotected lemma map_pow (x : A) (n : ℕ) : φ (x ^ n) = (φ x) ^ n := map_pow _ _ _\n\n@[simp] protected lemma map_smul (r : R) (x : A) : φ (r • x) = r • φ x := map_smul _ _ _\n\nprotected lemma map_sum {ι : Type*} (f : ι → A) (s : finset ι) :\n  φ (∑ x in s, f x) = ∑ x in s, φ (f x) := map_sum _ _ _\n\nprotected lemma map_finsupp_sum {α : Type*} [has_zero α] {ι : Type*} (f : ι →₀ α) (g : ι → α → A) :\n  φ (f.sum g) = f.sum (λ i a, φ (g i a)) := map_finsupp_sum _ _ _\n\nprotected lemma map_bit0 (x) : φ (bit0 x) = bit0 (φ x) := map_bit0 _ _\nprotected lemma map_bit1 (x) : φ (bit1 x) = bit1 (φ x) := map_bit1 _ _\n\n/-- If a `ring_hom` is `R`-linear, then it is an `alg_hom`. -/\ndef mk' (f : A →+* B) (h : ∀ (c : R) x, f (c • x) = c • f x) : A →ₐ[R] B :=\n{ to_fun := f,\n  commutes' := λ c, by simp only [algebra.algebra_map_eq_smul_one, h, f.map_one],\n  .. f }\n\n@[simp] \n\nsection\n\nvariables (R A)\n/-- Identity map as an `alg_hom`. -/\nprotected def id : A →ₐ[R] A :=\n{ commutes' := λ _, rfl,\n  ..ring_hom.id A }\n\n@[simp] lemma coe_id : ⇑(alg_hom.id R A) = id := rfl\n\n@[simp] lemma id_to_ring_hom : (alg_hom.id R A : A →+* A) = ring_hom.id _ := rfl\n\nend\n\nlemma id_apply (p : A) : alg_hom.id R A p = p := rfl\n\n/-- Composition of algebra homeomorphisms. -/\ndef comp (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) : A →ₐ[R] C :=\n{ commutes' := λ r : R, by rw [← φ₁.commutes, ← φ₂.commutes]; refl,\n  .. φ₁.to_ring_hom.comp ↑φ₂ }\n\n@[simp] lemma coe_comp (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) : ⇑(φ₁.comp φ₂) = φ₁ ∘ φ₂ := rfl\n\nlemma comp_apply (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) (p : A) : φ₁.comp φ₂ p = φ₁ (φ₂ p) := rfl\n\nlemma comp_to_ring_hom (φ₁ : B →ₐ[R] C) (φ₂ : A →ₐ[R] B) :\n  (φ₁.comp φ₂ : A →+* C) = (φ₁ : B →+* C).comp ↑φ₂ := rfl\n\n@[simp] theorem comp_id : φ.comp (alg_hom.id R A) = φ :=\next $ λ x, rfl\n\n@[simp] theorem id_comp : (alg_hom.id R B).comp φ = φ :=\next $ λ x, rfl\n\ntheorem comp_assoc (φ₁ : C →ₐ[R] D) (φ₂ : B →ₐ[R] C) (φ₃ : A →ₐ[R] B) :\n  (φ₁.comp φ₂).comp φ₃ = φ₁.comp (φ₂.comp φ₃) :=\next $ λ x, rfl\n\n/-- R-Alg ⥤ R-Mod -/\ndef to_linear_map : A →ₗ[R] B :=\n{ to_fun := φ,\n  map_add' := map_add _,\n  map_smul' := map_smul _ }\n\n@[simp] lemma to_linear_map_apply (p : A) : φ.to_linear_map p = φ p := rfl\n\ntheorem to_linear_map_injective : function.injective (to_linear_map : _ → (A →ₗ[R] B)) :=\nλ φ₁ φ₂ h, ext $ linear_map.congr_fun h\n\n@[simp] lemma comp_to_linear_map (f : A →ₐ[R] B) (g : B →ₐ[R] C) :\n  (g.comp f).to_linear_map = g.to_linear_map.comp f.to_linear_map := rfl\n\n@[simp] lemma to_linear_map_id : to_linear_map (alg_hom.id R A) = linear_map.id :=\nlinear_map.ext $ λ _, rfl\n\n/-- Promote a `linear_map` to an `alg_hom` by supplying proofs about the behavior on `1` and `*`. -/\n@[simps]\ndef of_linear_map (f : A →ₗ[R] B) (map_one : f 1 = 1) (map_mul : ∀ x y, f (x * y) = f x * f y) :\n  A →ₐ[R] B :=\n{ to_fun := f,\n  map_one' := map_one,\n  map_mul' := map_mul,\n  commutes' := λ c, by simp only [algebra.algebra_map_eq_smul_one, f.map_smul, map_one],\n  .. f.to_add_monoid_hom }\n\n@[simp] lemma of_linear_map_to_linear_map (map_one) (map_mul) :\n  of_linear_map φ.to_linear_map map_one map_mul = φ :=\nby { ext, refl }\n\n@[simp] lemma to_linear_map_of_linear_map (f : A →ₗ[R] B) (map_one) (map_mul) :\n  to_linear_map (of_linear_map f map_one map_mul) = f :=\nby { ext, refl }\n\n@[simp] lemma of_linear_map_id (map_one) (map_mul) :\n  of_linear_map linear_map.id map_one map_mul = alg_hom.id R A :=\next $ λ _, rfl\n\nlemma map_smul_of_tower {R'} [has_smul R' A] [has_smul R' B]\n  [linear_map.compatible_smul A B R' R] (r : R') (x : A) : φ (r • x) = r • φ x :=\nφ.to_linear_map.map_smul_of_tower r x\n\nlemma map_list_prod (s : list A) :\n  φ s.prod = (s.map φ).prod :=\nφ.to_ring_hom.map_list_prod s\n\n@[simps mul one {attrs := []}] instance End : monoid (A →ₐ[R] A) :=\n{ mul := comp,\n  mul_assoc := λ ϕ ψ χ, rfl,\n  one := alg_hom.id R A,\n  one_mul := λ ϕ, ext $ λ x, rfl,\n  mul_one := λ ϕ, ext $ λ x, rfl }\n\n@[simp] lemma one_apply (x : A) : (1 : A →ₐ[R] A) x = x := rfl\n\n@[simp] lemma mul_apply (φ ψ : A →ₐ[R] A) (x : A) : (φ * ψ) x = φ (ψ x) := rfl\n\nlemma algebra_map_eq_apply (f : A →ₐ[R] B) {y : R} {x : A} (h : algebra_map R A y = x) :\n  algebra_map R B y = f x :=\nh ▸ (f.commutes _).symm\n\nend semiring\n\nsection comm_semiring\n\nvariables [comm_semiring R] [comm_semiring A] [comm_semiring B]\nvariables [algebra R A] [algebra R B] (φ : A →ₐ[R] B)\n\nprotected lemma map_multiset_prod (s : multiset A) :\n  φ s.prod = (s.map φ).prod := map_multiset_prod _ _\n\nprotected lemma map_prod {ι : Type*} (f : ι → A) (s : finset ι) :\n  φ (∏ x in s, f x) = ∏ x in s, φ (f x) := map_prod _ _ _\n\nprotected lemma map_finsupp_prod {α : Type*} [has_zero α] {ι : Type*} (f : ι →₀ α) (g : ι → α → A) :\n  φ (f.prod g) = f.prod (λ i a, φ (g i a)) := map_finsupp_prod _ _ _\n\nend comm_semiring\n\nsection ring\n\nvariables [comm_semiring R] [ring A] [ring B]\nvariables [algebra R A] [algebra R B] (φ : A →ₐ[R] B)\n\nprotected lemma map_neg (x) : φ (-x) = -φ x := map_neg _ _\nprotected lemma map_sub (x y) : φ (x - y) = φ x - φ y := map_sub _ _ _\n\nend ring\n\nend alg_hom\n\n\nnamespace ring_hom\nvariables {R S : Type*}\n\n/-- Reinterpret a `ring_hom` as an `ℕ`-algebra homomorphism. -/\ndef to_nat_alg_hom [semiring R] [semiring S] (f : R →+* S) :\n  R →ₐ[ℕ] S :=\n{ to_fun := f, commutes' := λ n, by simp, .. f }\n\n/-- Reinterpret a `ring_hom` as a `ℤ`-algebra homomorphism. -/\ndef to_int_alg_hom [ring R] [ring S] [algebra ℤ R] [algebra ℤ S] (f : R →+* S) :\n  R →ₐ[ℤ] S :=\n{ commutes' := λ n, by simp, .. f }\n\n/-- Reinterpret a `ring_hom` as a `ℚ`-algebra homomorphism. This actually yields an equivalence,\nsee `ring_hom.equiv_rat_alg_hom`. -/\ndef to_rat_alg_hom [ring R] [ring S] [algebra ℚ R] [algebra ℚ S] (f : R →+* S) :\n  R →ₐ[ℚ] S :=\n{ commutes' := f.map_rat_algebra_map, .. f }\n\n@[simp]\nlemma to_rat_alg_hom_to_ring_hom [ring R] [ring S] [algebra ℚ R] [algebra ℚ S]\n  (f : R →+* S) : ↑f.to_rat_alg_hom = f :=\nring_hom.ext $ λ x, rfl\n\nend ring_hom\n\nsection\nvariables {R S : Type*}\n\n@[simp]\nlemma alg_hom.to_ring_hom_to_rat_alg_hom [ring R] [ring S] [algebra ℚ R] [algebra ℚ S]\n  (f : R →ₐ[ℚ] S) : (f : R →+* S).to_rat_alg_hom = f :=\nalg_hom.ext $ λ x, rfl\n\n/-- The equivalence between `ring_hom` and `ℚ`-algebra homomorphisms. -/\n@[simps]\ndef ring_hom.equiv_rat_alg_hom [ring R] [ring S] [algebra ℚ R] [algebra ℚ S] :\n  (R →+* S) ≃ (R →ₐ[ℚ] S) :=\n{ to_fun := ring_hom.to_rat_alg_hom,\n  inv_fun := alg_hom.to_ring_hom,\n  left_inv := ring_hom.to_rat_alg_hom_to_ring_hom,\n  right_inv := alg_hom.to_ring_hom_to_rat_alg_hom, }\n\nend\n\nnamespace algebra\nvariables (R : Type u) (A : Type v)\nvariables [comm_semiring R] [semiring A] [algebra R A]\n\n/-- `algebra_map` as an `alg_hom`. -/\ndef of_id : R →ₐ[R] A :=\n{ commutes' := λ _, rfl, .. algebra_map R A }\nvariables {R}\n\ntheorem of_id_apply (r) : of_id R A r = algebra_map R A r := rfl\n\nend algebra\n\nnamespace mul_semiring_action\nvariables {M G : Type*} (R A : Type*) [comm_semiring R] [semiring A] [algebra R A]\nvariables [monoid M] [mul_semiring_action M A] [smul_comm_class M R A]\n\n/-- Each element of the monoid defines a algebra homomorphism.\n\nThis is a stronger version of `mul_semiring_action.to_ring_hom` and\n`distrib_mul_action.to_linear_map`. -/\n@[simps]\ndef to_alg_hom (m : M) : A →ₐ[R] A :=\n{ to_fun := λ a, m • a,\n  commutes' := smul_algebra_map _,\n  ..mul_semiring_action.to_ring_hom _ _ m }\n\ntheorem to_alg_hom_injective [has_faithful_smul M A] :\n  function.injective (mul_semiring_action.to_alg_hom R A : M → A →ₐ[R] A) :=\nλ m₁ m₂ h, eq_of_smul_eq_smul $ λ r, alg_hom.ext_iff.1 h r\n\nend mul_semiring_action\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/algebra/hom.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.6370308082623216, "lm_q1q2_score": 0.4537138517784103}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.shapes.equalizers\nimport category_theory.limits.shapes.reflexive\nimport category_theory.adjunction\nimport category_theory.monad.adjunction\nimport category_theory.monad.coequalizer\n\n/-!\n# Adjoint lifting\n\nThis file gives two constructions for building left adjoints: the adjoint triangle theorem and the\nadjoint lifting theorem.\nThe adjoint triangle theorem says that given a functor `U : B ⥤ C` with a left adjoint `F` such\nthat `ε_X : FUX ⟶ X` is a regular epi. Then for any category `A` with coequalizers of reflexive\npairs, a functor `R : A ⥤ B` has a left adjoint if (and only if) the composite `R ⋙ U` does.\nNote that the condition on `U` regarding `ε_X` is automatically satisfied in the case when `U` is\na monadic functor, giving the corollary: `monadic_adjoint_triangle_lift`, i.e. if `U` is monadic,\n`A` has reflexive coequalizers then `R : A ⥤ B` has a left adjoint provided `R ⋙ U` does.\n\nThe adjoint lifting theorem says that given a commutative square of functors (up to isomorphism):\n\n      Q\n    A → B\n  U ↓   ↓ V\n    C → D\n      R\n\nwhere `U` and `V` are monadic and `A` has reflexive coequalizers, then if `R` has a left adjoint\nthen `Q` has a left adjoint.\n\n## Implementation\n\nIt is more convenient to prove this theorem by assuming we are given the explicit adjunction rather\nthan just a functor known to be a right adjoint. In docstrings, we write `(η, ε)` for the unit\nand counit of the adjunction `adj₁ : F ⊣ U` and `(ι, δ)` for the unit and counit of the adjunction\n`adj₂ : F' ⊣ R ⋙ U`.\n\n## TODO\n\nDualise to lift right adjoints through comonads (by reversing 1-cells) and dualise to lift right\nadjoints through monads (by reversing 2-cells), and the combination.\n\n## References\n* https://ncatlab.org/nlab/show/adjoint+triangle+theorem\n* https://ncatlab.org/nlab/show/adjoint+lifting+theorem\n* Adjoint Lifting Theorems for Categories of Algebras (PT Johnstone, 1975)\n* A unified approach to the lifting of adjoints (AJ Power, 1988)\n-/\n\nnamespace category_theory\n\nopen category limits\n\nuniverses v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄\n\nvariables {A : Type u₁} {B : Type u₂} {C : Type u₃}\nvariables [category.{v₁} A] [category.{v₂} B] [category.{v₃} C]\n\n-- Hide implementation details in this namespace\nnamespace lift_adjoint\n\nvariables {U : B ⥤ C} {F : C ⥤ B} (R : A ⥤ B) (F' : C ⥤ A)\nvariables (adj₁ : F ⊣ U) (adj₂ : F' ⊣ R ⋙ U)\n\n/--\nTo show that `ε_X` is a coequalizer for `(FUε_X, ε_FUX)`, it suffices to assume it's always a\ncoequalizer of something (i.e. a regular epi).\n-/\ndef counit_coequalises [∀ (X : B), regular_epi (adj₁.counit.app X)] (X : B) :\n  is_colimit (cofork.of_π (adj₁.counit.app X) (adj₁.counit_naturality _)) :=\ncofork.is_colimit.mk' _ $ λ s,\nbegin\n  refine ⟨(regular_epi.desc' (adj₁.counit.app X) s.π _).1, _, _⟩,\n  { rw ← cancel_epi (adj₁.counit.app (regular_epi.W (adj₁.counit.app X))),\n    rw ← adj₁.counit_naturality_assoc,\n    dsimp only [functor.comp_obj],\n    rw [← s.condition, ← F.map_comp_assoc, ← U.map_comp, regular_epi.w, U.map_comp,\n        F.map_comp_assoc, s.condition, ← adj₁.counit_naturality_assoc] },\n  { apply (regular_epi.desc' (adj₁.counit.app X) s.π _).2 },\n  { intros m hm,\n    rw ← cancel_epi (adj₁.counit.app X),\n    apply hm.trans (regular_epi.desc' (adj₁.counit.app X) s.π _).2.symm }\nend\n\ninclude adj₁ adj₂\n\n/--\n(Implementation)\nTo construct the left adjoint, we use the coequalizer of `F' U ε_Y` with the composite\n\n`F' U F U X ⟶ F' U F U R F U' X ⟶ F' U R F' U X ⟶ F' U X`\n\nwhere the first morphism is `F' U F ι_UX`, the second is `F' U ε_RF'UX`, and the third is `δ_F'UX`.\nWe will show that this coequalizer exists and that it forms the object map for a left adjoint to\n`R`.\n-/\ndef other_map (X) : F'.obj (U.obj (F.obj (U.obj X))) ⟶ F'.obj (U.obj X) :=\nF'.map (U.map (F.map (adj₂.unit.app _) ≫ adj₁.counit.app _)) ≫ adj₂.counit.app _\n\n/--\n`(F'Uε_X, other_map X)` is a reflexive pair: in particular if `A` has reflexive coequalizers then\nit has a coequalizer.\n-/\ninstance (X : B) :\n  is_reflexive_pair (F'.map (U.map (adj₁.counit.app X))) (other_map _ _ adj₁ adj₂ X) :=\nis_reflexive_pair.mk'\n  (F'.map (adj₁.unit.app (U.obj X)))\n  (by {rw [← F'.map_comp, adj₁.right_triangle_components], apply F'.map_id })\n  begin\n    dsimp [other_map],\n    rw [← F'.map_comp_assoc, U.map_comp, adj₁.unit_naturality_assoc, adj₁.right_triangle_components,\n        comp_id, adj₂.left_triangle_components]\n  end\n\nvariables [has_reflexive_coequalizers A]\n\n/--\nConstruct the object part of the desired left adjoint as the coequalizer of `F'Uε_Y` with\n`other_map`.\n-/\nnoncomputable def construct_left_adjoint_obj (Y : B) : A :=\ncoequalizer (F'.map (U.map (adj₁.counit.app Y))) (other_map _ _ adj₁ adj₂ Y)\n\n/-- The homset equivalence which helps show that `R` is a right adjoint. -/\n@[simps {rhs_md := semireducible}]\nnoncomputable\ndef construct_left_adjoint_equiv [∀ (X : B), regular_epi (adj₁.counit.app X)] (Y : A) (X : B) :\n  (construct_left_adjoint_obj _ _ adj₁ adj₂ X ⟶ Y) ≃ (X ⟶ R.obj Y) :=\ncalc (construct_left_adjoint_obj _ _ adj₁ adj₂ X ⟶ Y)\n        ≃ {f : F'.obj (U.obj X) ⟶ Y //\n              F'.map (U.map (adj₁.counit.app X)) ≫ f = other_map _ _ adj₁ adj₂ _ ≫ f} :\n                cofork.is_colimit.hom_iso (colimit.is_colimit _) _\n  ... ≃ {g : U.obj X ⟶ U.obj (R.obj Y) //\n          U.map (F.map g ≫ adj₁.counit.app _) = U.map (adj₁.counit.app _) ≫ g} :\n            begin\n              apply (adj₂.hom_equiv _ _).subtype_equiv _,\n              intro f,\n              rw [← (adj₂.hom_equiv _ _).injective.eq_iff, eq_comm, adj₂.hom_equiv_naturality_left,\n                  other_map, assoc, adj₂.hom_equiv_naturality_left, ← adj₂.counit_naturality,\n                  adj₂.hom_equiv_naturality_left, adj₂.hom_equiv_unit,\n                  adj₂.right_triangle_components, comp_id, functor.comp_map, ← U.map_comp, assoc,\n                  ← adj₁.counit_naturality, adj₂.hom_equiv_unit, adj₂.hom_equiv_unit, F.map_comp,\n                  assoc],\n              refl,\n            end\n  ... ≃ {z : F.obj (U.obj X) ⟶ R.obj Y // _} :\n            begin\n              apply (adj₁.hom_equiv _ _).symm.subtype_equiv,\n              intro g,\n              rw [← (adj₁.hom_equiv _ _).symm.injective.eq_iff, adj₁.hom_equiv_counit,\n                  adj₁.hom_equiv_counit, adj₁.hom_equiv_counit, F.map_comp, assoc, U.map_comp,\n                  F.map_comp, assoc, adj₁.counit_naturality, adj₁.counit_naturality_assoc],\n              apply eq_comm,\n            end\n  ... ≃ (X ⟶ R.obj Y) : (cofork.is_colimit.hom_iso (counit_coequalises adj₁ X) _).symm\n\n/-- Construct the left adjoint to `R`, with object map `construct_left_adjoint_obj`. -/\nnoncomputable def construct_left_adjoint [∀ (X : B), regular_epi (adj₁.counit.app X)] : B ⥤ A :=\nbegin\n  refine adjunction.left_adjoint_of_equiv (λ X Y, construct_left_adjoint_equiv R _ adj₁ adj₂ Y X) _,\n  intros X Y Y' g h,\n  rw [construct_left_adjoint_equiv_apply, construct_left_adjoint_equiv_apply, function.comp_app,\n      function.comp_app, equiv.trans_apply, equiv.trans_apply, equiv.trans_apply, equiv.trans_apply,\n      equiv.symm_apply_eq, subtype.ext_iff, cofork.is_colimit.hom_iso_natural,\n      equiv.apply_symm_apply, equiv.subtype_equiv_apply, equiv.subtype_equiv_apply,\n      equiv.subtype_equiv_apply, equiv.subtype_equiv_apply, subtype.coe_mk, subtype.coe_mk,\n      subtype.coe_mk, subtype.coe_mk, ← adj₁.hom_equiv_naturality_right_symm,\n      cofork.is_colimit.hom_iso_natural, adj₂.hom_equiv_naturality_right, functor.comp_map],\nend\n\nend lift_adjoint\n\n/--\nThe adjoint triangle theorem: Suppose `U : B ⥤ C` has a left adjoint `F` such that each counit\n`ε_X : FUX ⟶ X` is a regular epimorphism. Then if a category `A` has coequalizers of reflexive\npairs, then a functor `R : A ⥤ B` has a left adjoint if the composite `R ⋙ U` does.\n\nNote the converse is true (with weaker assumptions), by `adjunction.comp`.\nSee https://ncatlab.org/nlab/show/adjoint+triangle+theorem\n-/\nnoncomputable def adjoint_triangle_lift {U : B ⥤ C} {F : C ⥤ B} (R : A ⥤ B) (adj₁ : F ⊣ U)\n  [Π (X : B), regular_epi (adj₁.counit.app X)]\n  [has_reflexive_coequalizers A]\n  [is_right_adjoint (R ⋙ U)] : is_right_adjoint R :=\n{ left := lift_adjoint.construct_left_adjoint R _ adj₁ (adjunction.of_right_adjoint _),\n  adj := adjunction.adjunction_of_equiv_left _ _ }\n\n/--\nIf `R ⋙ U` has a left adjoint, the domain of `R` has reflexive coequalizers and `U` is a monadic\nfunctor, then `R` has a left adjoint.\nThis is a special case of `adjoint_triangle_lift` which is often more useful in practice.\n-/\nnoncomputable def monadic_adjoint_triangle_lift (U : B ⥤ C) [monadic_right_adjoint U] {R : A ⥤ B}\n  [has_reflexive_coequalizers A]\n  [is_right_adjoint (R ⋙ U)] :\n  is_right_adjoint R :=\nbegin\n  let R' : A ⥤ _ := R ⋙ monad.comparison (adjunction.of_right_adjoint U),\n  suffices : is_right_adjoint R',\n  { let : is_right_adjoint (R' ⋙ (monad.comparison (adjunction.of_right_adjoint U)).inv),\n    { resetI,\n      apply_instance },\n    { let : R' ⋙ (monad.comparison (adjunction.of_right_adjoint U)).inv ≅ R :=\n        (iso_whisker_left R (monad.comparison _).as_equivalence.unit_iso.symm : _) ≪≫\n          R.right_unitor,\n      exactI adjunction.right_adjoint_of_nat_iso this } },\n  let : is_right_adjoint (R' ⋙ monad.forget (adjunction.of_right_adjoint U).to_monad) :=\n    adjunction.right_adjoint_of_nat_iso\n      (iso_whisker_left R (monad.comparison_forget (adjunction.of_right_adjoint U)).symm : _),\n  letI : Π X, regular_epi ((monad.adj (adjunction.of_right_adjoint U).to_monad).counit.app X),\n  { intro X,\n    dsimp only [monad.adj_counit, functor.comp_map, monad.forget_obj, functor.id_obj,\n                functor.comp_obj, monad.free_obj_A],\n    simp only [functor.map_id, id_comp],\n    exact ⟨_, _, _, _, monad.beck_algebra_coequalizer X⟩ },\n  exact adjoint_triangle_lift R' (monad.adj _),\nend\n\nvariables {D : Type u₄}\nvariables [category.{v₄} D]\n\n/--\nSuppose we have a commutative square of functors\n\n      Q\n    A → B\n  U ↓   ↓ V\n    C → D\n      R\n\nwhere `U` has a left adjoint, `A` has reflexive coequalizers and `V` has a left adjoint such that\neach component of the counit is a regular epi.\nThen `Q` has a left adjoint if `R` has a left adjoint.\n\nSee https://ncatlab.org/nlab/show/adjoint+lifting+theorem\n-/\nnoncomputable def adjoint_square_lift (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (R : C ⥤ D)\n  (comm : U ⋙ R ≅ Q ⋙ V)\n  [is_right_adjoint U] [is_right_adjoint V] [is_right_adjoint R]\n  [∀ X, regular_epi ((adjunction.of_right_adjoint V).counit.app X)]\n  [has_reflexive_coequalizers A] :\n  is_right_adjoint Q :=\nbegin\n  let := adjunction.right_adjoint_of_nat_iso comm,\n  exactI adjoint_triangle_lift Q (adjunction.of_right_adjoint V),\nend\n\n/--\nSuppose we have a commutative square of functors\n\n      Q\n    A → B\n  U ↓   ↓ V\n    C → D\n      R\n\nwhere `U` has a left adjoint, `A` has reflexive coequalizers and `V` is monadic.\nThen `Q` has a left adjoint if `R` has a left adjoint.\n\nSee https://ncatlab.org/nlab/show/adjoint+lifting+theorem\n-/\nnoncomputable def monadic_adjoint_square_lift (Q : A ⥤ B) (V : B ⥤ D) (U : A ⥤ C) (R : C ⥤ D)\n  (comm : U ⋙ R ≅ Q ⋙ V)\n  [is_right_adjoint U] [monadic_right_adjoint V] [is_right_adjoint R]\n  [has_reflexive_coequalizers A] :\n  is_right_adjoint Q :=\nbegin\n  let := adjunction.right_adjoint_of_nat_iso comm,\n  exactI monadic_adjoint_triangle_lift V,\nend\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/adjunction/lifting.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6370308013713525, "lm_q1q2_score": 0.45371383908820506}}
{"text": "/-\nCopyright (c) 2022 Jun Yoshida. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n-/\n\nimport Std.Data.List.Lemmas\n\nimport Algdata.Init.Fin\nimport Algdata.Init.LawfulLT\n\nnamespace List\n\nuniverse u\nvariable {α : Type u}\n\ntheorem get_congr {x y : List α} {i : Fin x.length} {j : Fin y.length} : x = y → i.val = j.val → get x i = get y j\n| rfl, h => by rw [Fin.eq_of_val_eq h]\n\ntheorem get_congrList {x y : List α} {i : Fin x.length} : (h : x = y) → get x i = get y ⟨i.val, h▸i.isLt⟩\n| rfl => rfl\n\ntheorem get_proof_irrev (x : List α) (i : Fin x.length) (h : i.val < x.length) : x.get i = x.get ⟨i.val, h⟩ :=\n  get_congr rfl rfl\n\ntheorem get_head (a : α) (as : List α) : ∀ {i : Fin (a::as).length}, i.val = 0 → (a::as).get i = a\n| Fin.mk i hi, h => by cases h; rfl\n\ntheorem get_tail (a : α) (as : List α) : ∀ {i : Fin (a::as).length} (hpos : i.val > 0), (a::as).get i = as.get (i.pred hpos)\n| Fin.mk 0 _, hpos => (Nat.not_lt_zero _ hpos).elim\n| Fin.mk (k+1) hk, hpos => by\n  rw [get, Fin.pred]\n  apply get_congr rfl _\n  simp\n\ntheorem get_set_on : ∀ (x : List α) (i : Nat) (v : α) (j : Fin (x.set i v).length), i = j.val → get (x.set i v) j = v\n| [], _, _, Fin.mk _ hk, _ => (Nat.not_lt_zero _ hk).elim\n| (a::as), 0, v, Fin.mk 0 _, _ => rfl\n| (a::as), 0, v, Fin.mk (k+1) hk, h => (Nat.succ_ne_zero _ h.symm).elim\n| (a::as), (i+1), v, Fin.mk 0 _, h => (Nat.succ_ne_zero _ h).elim\n| (a::as), (i+1), v, Fin.mk (k+1) hk, h => by\n  have hset : set (a::as) i.succ v = a::(as.set i v) := rfl\n  rw [get_congr hset rfl, get]\n  rw [get_set_on as]\n  exact Nat.succ.inj h\n\ntheorem get_set_off : ∀ (x : List α) (i : Nat) (v : α) (j : Fin (x.set i v).length), i ≠ j.val → get (x.set i v) j = get x ⟨j.val, x.length_set i v ▸ j.isLt⟩\n| [], _, _, Fin.mk _ hk, _ => (Nat.not_lt_zero _ hk).elim\n| (a::as), 0, v, Fin.mk 0 _, h => (h rfl).elim\n| (a::as), 0, v, Fin.mk (k+1) hk, _ => by\n  have : set (a::as) 0 v = v::as := rfl\n  rw [get_congr this rfl, get, get]\n| (a::as), (i+1), v, Fin.mk 0 _, _ => by\n  have : set (a::as) (i+1) v = a :: set as i v := rfl\n  rw [get_congr this rfl, get, get]\n| (a::as), (i+1), v, Fin.mk (k+1) hk, h => by\n  have : set (a::as) (i+1) v = a :: set as i v := rfl\n  rw [get_congr this rfl, get, get]\n  rw [get_set_off as i v ⟨k,_⟩ (h ∘ congrArg Nat.succ)]\n\ntheorem foldl_comm {α β : Type _} {f : α → β → α} {g : α → α} : (∀ a b, f (g a) b = g (f a b)) → ∀ {init : α} {bs : List β}, bs.foldl f (g init) = g (bs.foldl f init) := by\n  intro hfg init bs\n  revert init; induction bs\n  case nil => exact λ {_} => rfl\n  case cons b bs h_ind =>\n    intro init\n    dsimp [foldl]\n    rw [hfg init b, h_ind (init:=f init b)]\n\ntheorem comp_map {α β γ : Type _} (f : α → β) (g : β → γ) : ∀ (as : List α), as.map (g ∘ f) = (as.map f).map g\n| [] => rfl\n| (a::as) => by unfold map; rw [comp_map f g as]; rfl\n\ntheorem comp_filterMap {α β γ : Type _} (f : α → β) (g : β → Option γ) : ∀ (as : List α), as.filterMap (g ∘ f) = (as.map f).filterMap g\n| [] => rfl\n| (a::as) => by\n  unfold map; unfold filterMap\n  rw [comp_filterMap f g as]\n  rfl\n\ntheorem zipWith_nil_first {β γ : Type _} (f : α → β → γ) : ∀ (x : List β), List.zipWith f [] x = []\n| [] => rfl\n| (_::_) => rfl\n\ntheorem zipWith_nil_second {β γ : Type _} (f : α → β → γ) : ∀ (x : List α), List.zipWith f x [] = []\n| [] => rfl\n| (_::_) => rfl\n\ntheorem reverseAux_append_left {α : Type _} {as₁ as₂ bs : List α} : reverseAux (as₁ ++ as₂) bs = as₂.reverse ++ reverseAux as₁ bs := by\n  revert bs; induction as₁ <;> intro bs\n  case nil => rw [reverseAux_eq_append]; rfl\n  case cons a₁ as₁ h_ind =>\n    rw [cons_append]\n    unfold reverseAux\n    rw [h_ind]\n\ntheorem bind_congr {α β : Type _} : ∀ {as₁ as₂ : List α} {f₁ f₂ : α → List β}, as₁ = as₂ → (∀ a, f₁ a = f₂ a) → as₁.bind f₁ = as₂.bind f₂\n| as, _, _, _, rfl, h =>\n  congrArg (as.bind) (funext h)\n\ntheorem bind_map_binary_eq_map_bind_map {α β γ : Type _} (f : α → β → γ) (as : List α) (bs : List β) : as.bind (fun a => bs.map (f a)) = (as.map f).bind bs.map := by\n  induction as with\n  | nil => rfl\n  | cons a as hi =>\n    rw [cons_bind, map, cons_bind]\n    rw [hi]\n\n\n--- Lexicographical lift of relations\nprotected\ninductive lex {α : Type _} (r : α → α → Prop) : List α → List α → Prop\n| nil : (a : α) → (as : List α) → List.lex r [] (a::as)\n| head {a b : α} {as bs : List α} : r a b → List.lex r (a::as) (b::bs)\n| tail {a : α} {as bs : List α} : List.lex r as bs → List.lex r (a::as) (a::bs)\n\nnamespace lex\n\nvariable {α : Type _} {r : α → α → Prop}\n\nprotected\ntheorem trans [Trans r r r] : {as bs cs : List α} → List.lex r as bs → List.lex r bs cs → List.lex r as cs\n| [], (_::_), (_::_), List.lex.nil _ _, List.lex.head _ => List.lex.nil _ _\n| [], (_::_), (_::_), List.lex.nil _ _, List.lex.tail _ => List.lex.nil _ _\n| (_::_), (_::_), (_::_), List.lex.head hab, List.lex.head hbc => List.lex.head (trans hab hbc)\n| (_::_), (_::_), (_::_), List.lex.head hab, List.lex.tail _ => List.lex.head hab\n| (_::_), (_::_), (_::_), List.lex.tail _, List.lex.head hbc => List.lex.head hbc\n| (_::_), (_::_), (_::_), List.lex.tail hab, List.lex.tail hbc => List.lex.tail (List.lex.trans hab hbc)\n\nprotected\ntheorem irrefl [Irreflective r] : ∀ (as : List α), ¬ List.lex r as as\n| (_::_), List.lex.head h => absurd h (Irreflective.irrefl _)\n| (_::_), List.lex.tail h => List.lex.irrefl _ h\n\nprotected\ntheorem asymm [Asymmetry r] : ∀ (as bs : List α), List.lex r as bs → ¬ List.lex r bs as\n| (_::_), (_::_), List.lex.head hab, List.lex.head hba =>\n  Asymmetry.asymm _ _ hab hba\n| (_::_), (_::_), List.lex.head hab, List.lex.tail _ =>\n  Asymmetry.asymm _ _ hab hab\n| (_::_), (_::_), List.lex.tail _, List.lex.head hba =>\n  Asymmetry.asymm _ _ hba hba\n| (_::_), (_::_), List.lex.tail hab, List.lex.tail hba =>\n  List.lex.asymm _ _ hab hba\n\nprotected\ntheorem trichot [Trichotomous r] : ∀ (as bs : List α), as = bs ∨ List.lex r as bs ∨ List.lex r bs as\n| [], [] => Or.inl rfl\n| [], (_::_) => Or.inr $ Or.inl $ List.lex.nil _ _\n| (_::_), [] => Or.inr $ Or.inr $ List.lex.nil _ _\n| (a::as), (b::bs) =>\n  trichotCasesOn r a b\n    (λ a h_ind =>\n      Or.map (congrArg (List.cons a)) (Or.map List.lex.tail List.lex.tail) h_ind\n    )\n    (λ _ _ h _ => Or.inr $ Or.inl $ List.lex.head h)\n    (λ _ _ h _ => Or.inr $ Or.inr $ List.lex.head h)\n    (List.lex.trichot as bs)\n\ninstance instTransListLex [Trans r r r] : Trans (List.lex r) (List.lex r) (List.lex r) where\n  trans := List.lex.trans\n\ninstance instIrreflectiveListLex [Irreflective r] : Irreflective (List.lex r) where\n  irrefl := List.lex.irrefl\n\ninstance instAsymmetryListLex [Asymmetry r] : Asymmetry (List.lex r) where\n  asymm := List.lex.asymm\n\ninstance instTrichotomousListLex [Trichotomous r] : Trichotomous (List.lex r) where\n  trichot := List.lex.trichot\n\ninstance instDecidableRelListLex [DecidableEq α] [DecidableRel r] : DecidableRel (List.lex r)\n| [], [] => isFalse $ λ hcontra => by cases hcontra\n| (a::as), [] => isFalse $ λ hcontra => by cases hcontra\n| [], (b::bs) => isTrue $ List.lex.nil _ _\n| (a::as), (b::bs) =>\n  if hab : r a b then\n    isTrue $ List.lex.head hab\n  else if heq : a = b then\n    match instDecidableRelListLex as bs with\n    | isTrue htail => isTrue $ heq ▸ List.lex.tail htail\n    | isFalse htail => isFalse $ by\n      cases heq; intro hcontra; cases hcontra <;> contradiction\n  else\n    isFalse $ λ hcontra => by\n      cases hcontra <;> contradiction\n\nend lex\n\nend List\n", "meta": {"author": "Junology", "repo": "algdata", "sha": "ef0e552747c3f1004705755a3afc7ccedec92bf6", "save_path": "github-repos/lean/Junology-algdata", "path": "github-repos/lean/Junology-algdata/algdata-ef0e552747c3f1004705755a3afc7ccedec92bf6/Algdata/Data/List/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6370307806984445, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.4537138282554122}}
{"text": "import .logging\n\nuniverse u\n\n/- Checks if applying a tactic will succeed without actually applying it -/\nmeta def tactic.will_succeed {α : Type u} (t : tactic α) : tactic bool :=\n  λ ts,\n    let b :=\n      match t ts with\n      | (result.success _ _) := tt\n      | (result.exception _ _ _) := ff\n      end\n    in result.success b ts\n\n/-\nAdd arguments to `add_args_type` so it unifies with `fixed_type`\nReturns `some n` if unifiable after putting in `n` arguments\nReturns `none` if fails to unify\n-/\nmeta def unify_with_args : expr → expr → tactic (option ℕ) := λ fixed_type add_args_type, do\n  can_unify ← tactic.will_succeed $ tactic.unify fixed_type add_args_type,\n  if can_unify then\n    return (some 0)\n  else\n    match add_args_type with\n    | (expr.pi arg_name _ arg_type body) := do\n        arg_mvar ← tactic.mk_meta_var arg_type,\n        let substituted_expr := body.instantiate_var arg_mvar,\n        recur_result ← unify_with_args fixed_type substituted_expr,\n        return $ match recur_result with\n        | some n := some (n + 1)\n        | none := none\n        end\n    | _ := return none\n    end\n\n@[hole_command]\nmeta def any_value_that_fits : hole_command :=\n{ name   := \"Anything\",\n  descr  := \"Insert any value that, when inserted, typechecks\",\n  action := λ _, do\n    tar ← tactic.target,\n    env ← tactic.get_env,\n    ans ← env.fold (return []) $ λ decl accum, (do\n      accum_result ← accum,\n      unify_with_args_result ← unify_with_args tar decl.type,\n      return $\n        match unify_with_args_result with\n        | some n := (\"(\" ++ decl.to_name.to_string ++ string.join (list.repeat \" {! !}\" n) ++ \")\", \"\") :: accum_result\n        | none := accum_result\n        end\n    ),\n    log $ string.intercalate \"\\n\" $ ans.map to_string,\n    return ans\n}\n\n-- Applying hole command inserts `(unsigned_sz)`, which is a ℕ\nexample := 1 + {! !}\n\ninductive MyType : ℕ → ℕ → Type\n| constr : ∀ x y : ℕ, MyType x y\n\n-- Applying hole command should insert `(MyType.constr {! !} {! !})`\n-- Doesn't work yet\nexample : MyType 1 2 := {! !}\n\n-- Doesn't work yet\nexample (x y z : ℕ) : ((x + y) + z = x + (y + z)) := {! !}\n\n-- Doesn't work yet\nexample (α : Type u) (x : α) : α := {! !}", "meta": {"author": "theemathas", "repo": "loogle", "sha": "68439fea92b16464b9080d3e44ad319970770efd", "save_path": "github-repos/lean/theemathas-loogle", "path": "github-repos/lean/theemathas-loogle/loogle-68439fea92b16464b9080d3e44ad319970770efd/main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.45371382436429464}}
{"text": "/-\nCopyright (c) 2021 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies, Scott Morrison\n\n! This file was ported from Lean 3 source module data.finset.functor\n! leanprover-community/mathlib commit f16e7a22e11fc09c71f25446ac1db23a24e8a0bd\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.Lattice\nimport Mathbin.Data.Finset.NAry\nimport Mathbin.Data.Multiset.Functor\n\n/-!\n# Functoriality of `finset`\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines the functor structure of `finset`.\n\n## TODO\n\nCurrently, all instances are classical because the functor classes want to run over all types. If\ninstead we could state that a functor is lawful/applicative/traversable... between two given types,\nthen we could provide the instances for types with decidable equality.\n-/\n\n\nuniverse u\n\nopen Function\n\nnamespace Finset\n\n/-! ### Functor -/\n\n\nsection Functor\n\nvariable {α β : Type u} [∀ P, Decidable P]\n\n/-- Because `finset.image` requires a `decidable_eq` instance for the target type, we can only\nconstruct `functor finset` when working classically. -/\ninstance : Functor Finset where map α β f s := s.image f\n\ninstance : LawfulFunctor Finset where\n  id_map α s := image_id\n  comp_map α β γ f g s := image_image.symm\n\n#print Finset.fmap_def /-\n@[simp]\ntheorem fmap_def {s : Finset α} (f : α → β) : f <$> s = s.image f :=\n  rfl\n#align finset.fmap_def Finset.fmap_def\n-/\n\nend Functor\n\n/-! ### Pure -/\n\n\ninstance : Pure Finset :=\n  ⟨fun α x => {x}⟩\n\n#print Finset.pure_def /-\n@[simp]\ntheorem pure_def {α} : (pure : α → Finset α) = singleton :=\n  rfl\n#align finset.pure_def Finset.pure_def\n-/\n\n/-! ### Applicative functor -/\n\n\nsection Applicative\n\nvariable {α β : Type u} [∀ P, Decidable P]\n\ninstance : Applicative Finset :=\n  { Finset.functor,\n    Finset.hasPure with\n    seq := fun α β t s => t.sup fun f => s.image f\n    seqLeft := fun α β s t => if t = ∅ then ∅ else s\n    seqRight := fun α β s t => if s = ∅ then ∅ else t }\n\n#print Finset.seq_def /-\n@[simp]\ntheorem seq_def (s : Finset α) (t : Finset (α → β)) : t <*> s = t.sup fun f => s.image f :=\n  rfl\n#align finset.seq_def Finset.seq_def\n-/\n\n#print Finset.seqLeft_def /-\n@[simp]\ntheorem seqLeft_def (s : Finset α) (t : Finset β) : s <* t = if t = ∅ then ∅ else s :=\n  rfl\n#align finset.seq_left_def Finset.seqLeft_def\n-/\n\n#print Finset.seqRight_def /-\n@[simp]\ntheorem seqRight_def (s : Finset α) (t : Finset β) : s *> t = if s = ∅ then ∅ else t :=\n  rfl\n#align finset.seq_right_def Finset.seqRight_def\n-/\n\n#print Finset.image₂_def /-\n/-- `finset.image₂` in terms of monadic operations. Note that this can't be taken as the definition\nbecause of the lack of universe polymorphism. -/\ntheorem image₂_def {α β γ : Type _} (f : α → β → γ) (s : Finset α) (t : Finset β) :\n    image₂ f s t = f <$> s <*> t := by\n  ext\n  simp [mem_sup]\n#align finset.image₂_def Finset.image₂_def\n-/\n\ninstance : LawfulApplicative Finset :=\n  {\n    Finset.lawfulFunctor with\n    seqLeft_eq := fun α β s t => by\n      rw [seq_def, fmap_def, seq_left_def]\n      obtain rfl | ht := t.eq_empty_or_nonempty\n      · simp_rw [if_pos rfl, image_empty]\n        exact (sup_bot _).symm\n      · ext a\n        rw [if_neg ht.ne_empty, mem_sup]\n        refine' ⟨fun ha => ⟨const β a, mem_image_of_mem _ ha, mem_image_const_self.2 ht⟩, _⟩\n        rintro ⟨f, hf, ha⟩\n        rw [mem_image] at hf ha\n        obtain ⟨b, hb, rfl⟩ := hf\n        obtain ⟨_, _, rfl⟩ := ha\n        exact hb\n    seqRight_eq := fun α β s t =>\n      by\n      rw [seq_def, fmap_def, seq_right_def]\n      obtain rfl | hs := s.eq_empty_or_nonempty\n      · rw [if_pos rfl, image_empty, sup_empty, bot_eq_empty]\n      · ext a\n        rw [if_neg hs.ne_empty, mem_sup]\n        refine' ⟨fun ha => ⟨id, mem_image_const_self.2 hs, by rwa [image_id]⟩, _⟩\n        rintro ⟨f, hf, ha⟩\n        rw [mem_image] at hf ha\n        obtain ⟨b, hb, rfl⟩ := ha\n        obtain ⟨_, _, rfl⟩ := hf\n        exact hb\n    pure_seq := fun α β f s => sup_singleton\n    map_pure := fun α β f a => image_singleton _ _\n    seq_pure := fun α β s a => sup_singleton'' _ _\n    seq_assoc := fun α β γ s t u => by\n      ext a\n      simp_rw [seq_def, fmap_def]\n      simp only [exists_prop, mem_sup, mem_image]\n      constructor\n      · rintro ⟨g, hg, b, ⟨f, hf, a, ha, rfl⟩, rfl⟩\n        exact ⟨g ∘ f, ⟨comp g, ⟨g, hg, rfl⟩, f, hf, rfl⟩, a, ha, rfl⟩\n      · rintro ⟨c, ⟨_, ⟨g, hg, rfl⟩, f, hf, rfl⟩, a, ha, rfl⟩\n        exact ⟨g, hg, f a, ⟨f, hf, a, ha, rfl⟩, rfl⟩ }\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ninstance : CommApplicative Finset :=\n  { Finset.lawfulApplicative with\n    commutative_prod := fun α β s t =>\n      by\n      simp_rw [seq_def, fmap_def, sup_image, sup_eq_bUnion]\n      change (s.bUnion fun a => t.image fun b => (a, b)) = t.bUnion fun b => s.image fun a => (a, b)\n      trans s ×ˢ t <;> [rw [product_eq_bUnion], rw [product_eq_bUnion_right]] <;> congr <;> ext <;>\n        simp_rw [mem_image] }\n\nend Applicative\n\n/-! ### Monad -/\n\n\nsection Monad\n\nvariable [∀ P, Decidable P]\n\ninstance : Monad Finset :=\n  { Finset.applicative with bind := fun α β => @sup _ _ _ _ }\n\n/- warning: finset.bind_def -> Finset.bind_def is a dubious translation:\nlean 3 declaration is\n  forall [_inst_1 : forall (P : Prop), Decidable P] {α : Type.{u1}} {β : Type.{u1}}, Eq.{succ u1} ((Finset.{u1} β) -> (β -> (Finset.{u1} α)) -> (Finset.{u1} α)) (Bind.bind.{u1, u1} Finset.{u1} (Monad.toHasBind.{u1, u1} Finset.{u1} (Finset.monad.{u1} (fun (P : Prop) => _inst_1 P))) β α) (Finset.sup.{u1, u1} (Finset.{u1} α) β (Lattice.toSemilatticeSup.{u1} (Finset.{u1} α) (Finset.lattice.{u1} α (fun (a : α) (b : α) => _inst_1 (Eq.{succ u1} α a b)))) (Finset.orderBot.{u1} α))\nbut is expected to have type\n  forall [_inst_1 : forall (P : Prop), Decidable P] {α : Type.{u1}} {β : Type.{u1}}, Eq.{succ u1} ((Finset.{u1} β) -> (β -> (Finset.{u1} α)) -> (Finset.{u1} α)) (fun (x._@.Mathlib.Data.Finset.Functor._hyg.1288 : Finset.{u1} β) (x._@.Mathlib.Data.Finset.Functor._hyg.1290 : β -> (Finset.{u1} α)) => Bind.bind.{u1, u1} Finset.{u1} (Monad.toBind.{u1, u1} Finset.{u1} (Finset.instMonadFinset.{u1} (fun (P : Prop) => _inst_1 P))) β α x._@.Mathlib.Data.Finset.Functor._hyg.1288 x._@.Mathlib.Data.Finset.Functor._hyg.1290) (Finset.sup.{u1, u1} (Finset.{u1} α) β (Lattice.toSemilatticeSup.{u1} (Finset.{u1} α) (Finset.instLatticeFinset.{u1} α (fun (a : α) (b : α) => _inst_1 (Eq.{succ u1} α a b)))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α))\nCase conversion may be inaccurate. Consider using '#align finset.bind_def Finset.bind_defₓ'. -/\n@[simp]\ntheorem bind_def {α β} : (· >>= ·) = @sup (Finset α) β _ _ :=\n  rfl\n#align finset.bind_def Finset.bind_def\n\ninstance : LawfulMonad Finset :=\n  {\n    Finset.lawfulApplicative with\n    bind_pure_comp_eq_map := fun α β f s => sup_singleton'' _ _\n    bind_map_eq_seq := fun α β t s => rfl\n    pure_bind := fun α β t s => sup_singleton\n    bind_assoc := fun α β γ s f g => by\n      convert sup_bUnion _ _\n      exact sup_eq_bUnion _ _ }\n\nend Monad\n\n/-! ### Alternative functor -/\n\n\nsection Alternative\n\nvariable [∀ P, Decidable P]\n\ninstance : Alternative Finset :=\n  { Finset.applicative with\n    orelse := fun α => (· ∪ ·)\n    failure := fun α => ∅ }\n\nend Alternative\n\n/-! ### Traversable functor -/\n\n\nsection Traversable\n\nvariable {α β γ : Type u} {F G : Type u → Type u} [Applicative F] [Applicative G]\n  [CommApplicative F] [CommApplicative G]\n\n#print Finset.traverse /-\n/-- Traverse function for `finset`. -/\ndef traverse [DecidableEq β] (f : α → F β) (s : Finset α) : F (Finset β) :=\n  Multiset.toFinset <$> Multiset.traverse f s.1\n#align finset.traverse Finset.traverse\n-/\n\n/- warning: finset.id_traverse -> Finset.id_traverse is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_5 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (id.{succ (succ u1)} Type.{u1} (Finset.{u1} α)) (Finset.traverse.{u1} α α (id.{succ (succ u1)} Type.{u1}) (Monad.toApplicative.{u1, u1} (id.{succ (succ u1)} Type.{u1}) id.monad.{u1}) id.commApplicative.{u1} (fun (a : α) (b : α) => _inst_5 a b) (id.mk.{succ u1} α) s) s\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_5 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Eq.{succ u1} (Id.{u1} (Finset.{u1} α)) (Finset.traverse.{u1} α α Id.{u1} (Monad.toApplicative.{u1, u1} Id.{u1} Id.instMonadId.{u1}) instCommApplicativeIdToApplicativeInstMonadId.{u1} (fun (a : α) (b : α) => _inst_5 a b) (Pure.pure.{u1, u1} Id.{u1} (Applicative.toPure.{u1, u1} Id.{u1} (Monad.toApplicative.{u1, u1} Id.{u1} Id.instMonadId.{u1})) α) s) s\nCase conversion may be inaccurate. Consider using '#align finset.id_traverse Finset.id_traverseₓ'. -/\n@[simp]\ntheorem id_traverse [DecidableEq α] (s : Finset α) : traverse id.mk s = s :=\n  by\n  rw [traverse, Multiset.id_traverse]\n  exact s.val_to_finset\n#align finset.id_traverse Finset.id_traverse\n\nopen Classical\n\n#print Finset.map_comp_coe /-\n@[simp]\ntheorem map_comp_coe (h : α → β) :\n    Functor.map h ∘ Multiset.toFinset = Multiset.toFinset ∘ Functor.map h :=\n  funext fun s => image_toFinset\n#align finset.map_comp_coe Finset.map_comp_coe\n-/\n\n#print Finset.map_traverse /-\ntheorem map_traverse (g : α → G β) (h : β → γ) (s : Finset α) :\n    Functor.map h <$> traverse g s = traverse (Functor.map h ∘ g) s :=\n  by\n  unfold traverse\n  simp only [map_comp_coe, functor_norm]\n  rw [LawfulFunctor.comp_map, Multiset.map_traverse]\n#align finset.map_traverse Finset.map_traverse\n-/\n\nend Traversable\n\nend Finset\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finset/Functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.45371382149002976}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Johan Commelin\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.functor\nimport Mathlib.data.mv_polynomial.equiv\nimport Mathlib.data.mv_polynomial.comm_ring\nimport Mathlib.ring_theory.free_ring\nimport Mathlib.PostPort\n\nuniverses u v u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Free commutative rings\n\nThe theory of the free commutative ring generated by a type `α`.\nIt is isomorphic to the polynomial ring over ℤ with variables\nin `α`\n\n## Main definitions\n\n* `free_comm_ring α`     : the free commutative ring on a type α\n* `lift_hom (f : α → R)` : the ring hom `free_comm_ring α →+* R` induced by functoriality from `f`.\n* `map (f : α → β)`      : the ring hom `free_comm_ring α →*+ free_comm_ring β` induced by\n                           functoriality from f.\n\n## Main results\n\n`free_comm_ring` has functorial properties (it is an adjoint to the forgetful functor).\nIn this file we have:\n\n* `of : α → free_comm_ring α`\n* `lift_hom (f : α → R) : free_comm_ring α →+* R`\n* `map (f : α → β) : free_comm_ring α →+* free_comm_ring β`\n\n* `free_comm_ring_equiv_mv_polynomial_int : free_comm_ring α ≃+* mv_polynomial α ℤ` :\n    `free_comm_ring α` is isomorphic to a polynomial ring.\n\n\n\n## Implementation notes\n\n`free_comm_ring α` is implemented not using `mv_polynomial` but\ndirectly as the free abelian group on `multiset α`, the type\nof monomials in this free commutative ring.\n\n## Tags\n\nfree commutative ring, free ring\n-/\n\n/-- `free_comm_ring α` is the free commutative ring on the type `α`. -/\ndef free_comm_ring (α : Type u) :=\n  free_abelian_group (multiplicative (multiset α))\n\nnamespace free_comm_ring\n\n\n/-- The structure of a commutative ring on `free_comm_ring α`. -/\nprotected instance comm_ring (α : Type u) : comm_ring (free_comm_ring α) :=\n  free_abelian_group.comm_ring (multiplicative (multiset α))\n\nprotected instance inhabited (α : Type u) : Inhabited (free_comm_ring α) :=\n  { default := 0 }\n\n/-- The canonical map from `α` to the free commutative ring on `α`. -/\ndef of {α : Type u} (x : α) : free_comm_ring α :=\n  free_abelian_group.of ↑[x]\n\ntheorem of_injective {α : Type u} : function.injective of :=\n  function.injective.comp free_abelian_group.of_injective\n    fun (x y : α) => iff.mp (iff.trans multiset.coe_eq_coe list.singleton_perm_singleton)\n\nprotected theorem induction_on {α : Type u} {C : free_comm_ring α → Prop} (z : free_comm_ring α) (hn1 : C (-1)) (hb : ∀ (b : α), C (of b)) (ha : ∀ (x y : free_comm_ring α), C x → C y → C (x + y)) (hm : ∀ (x y : free_comm_ring α), C x → C y → C (x * y)) : C z := sorry\n\n/-- Lift a map `α → R` to a additive group homomorphism `free_comm_ring α → R`.\nFor a version producing a bundled homomorphism, see `lift_hom`. -/\ndef lift {α : Type u} {R : Type v} [comm_ring R] (f : α → R) : free_comm_ring α →+* R :=\n  ring_hom.mk\n    (add_monoid_hom.to_fun\n      (free_abelian_group.lift\n        fun (s : multiplicative (multiset α)) => multiset.prod (multiset.map f (coe_fn multiplicative.to_add s))))\n    sorry sorry sorry sorry\n\n@[simp] theorem lift_of {α : Type u} {R : Type v} [comm_ring R] (f : α → R) (x : α) : coe_fn (lift f) (of x) = f x := sorry\n\n@[simp] theorem lift_comp_of {α : Type u} {R : Type v} [comm_ring R] (f : free_comm_ring α →+* R) : lift (⇑f ∘ of) = f := sorry\n\n/-- A map `f : α → β` produces a ring homomorphism `free_comm_ring α →+* free_comm_ring β`. -/\ndef map {α : Type u} {β : Type v} (f : α → β) : free_comm_ring α →+* free_comm_ring β :=\n  lift (of ∘ f)\n\n@[simp] theorem map_of {α : Type u} {β : Type v} (f : α → β) (x : α) : coe_fn (map f) (of x) = of (f x) :=\n  lift_of (of ∘ f) x\n\n/-- `is_supported x s` means that all monomials showing up in `x` have variables in `s`. -/\ndef is_supported {α : Type u} (x : free_comm_ring α) (s : set α) :=\n  x ∈ ring.closure (of '' s)\n\ntheorem is_supported_upwards {α : Type u} {x : free_comm_ring α} {s : set α} {t : set α} (hs : is_supported x s) (hst : s ⊆ t) : is_supported x t :=\n  ring.closure_mono (set.monotone_image hst) hs\n\ntheorem is_supported_add {α : Type u} {x : free_comm_ring α} {y : free_comm_ring α} {s : set α} (hxs : is_supported x s) (hys : is_supported y s) : is_supported (x + y) s :=\n  is_add_submonoid.add_mem hxs hys\n\ntheorem is_supported_neg {α : Type u} {x : free_comm_ring α} {s : set α} (hxs : is_supported x s) : is_supported (-x) s :=\n  is_add_subgroup.neg_mem hxs\n\ntheorem is_supported_sub {α : Type u} {x : free_comm_ring α} {y : free_comm_ring α} {s : set α} (hxs : is_supported x s) (hys : is_supported y s) : is_supported (x - y) s :=\n  is_add_subgroup.sub_mem hxs hys\n\ntheorem is_supported_mul {α : Type u} {x : free_comm_ring α} {y : free_comm_ring α} {s : set α} (hxs : is_supported x s) (hys : is_supported y s) : is_supported (x * y) s :=\n  is_submonoid.mul_mem hxs hys\n\ntheorem is_supported_zero {α : Type u} {s : set α} : is_supported 0 s :=\n  is_add_submonoid.zero_mem\n\ntheorem is_supported_one {α : Type u} {s : set α} : is_supported 1 s :=\n  is_submonoid.one_mem\n\ntheorem is_supported_int {α : Type u} {i : ℤ} {s : set α} : is_supported (↑i) s := sorry\n\n/-- The restriction map from `free_comm_ring α` to `free_comm_ring s` where `s : set α`, defined\n  by sending all variables not in `s` to zero. -/\ndef restriction {α : Type u} (s : set α) [decidable_pred s] : free_comm_ring α →+* free_comm_ring ↥s :=\n  lift fun (p : α) => dite (p ∈ s) (fun (H : p ∈ s) => of { val := p, property := H }) fun (H : ¬p ∈ s) => 0\n\n@[simp] theorem restriction_of {α : Type u} (s : set α) [decidable_pred s] (p : α) : coe_fn (restriction s) (of p) = dite (p ∈ s) (fun (H : p ∈ s) => of { val := p, property := H }) fun (H : ¬p ∈ s) => 0 :=\n  lift_of (fun (p : α) => dite (p ∈ s) (fun (H : p ∈ s) => of { val := p, property := H }) fun (H : ¬p ∈ s) => 0) p\n\ntheorem is_supported_of {α : Type u} {p : α} {s : set α} : is_supported (of p) s ↔ p ∈ s := sorry\n\ntheorem map_subtype_val_restriction {α : Type u} {x : free_comm_ring α} (s : set α) [decidable_pred s] (hxs : is_supported x s) : coe_fn (map subtype.val) (coe_fn (restriction s) x) = x := sorry\n\ntheorem exists_finite_support {α : Type u} (x : free_comm_ring α) : ∃ (s : set α), set.finite s ∧ is_supported x s := sorry\n\ntheorem exists_finset_support {α : Type u} (x : free_comm_ring α) : ∃ (s : finset α), is_supported x ↑s := sorry\n\nend free_comm_ring\n\n\nnamespace free_ring\n\n\n/-- The canonical ring homomorphism from the free ring generated by `α` to the free commutative ring\n    generated by `α`. -/\ndef to_free_comm_ring {α : Type u_1} : free_ring α →+* free_comm_ring α :=\n  lift free_comm_ring.of\n\nprotected instance free_comm_ring.has_coe (α : Type u) : has_coe (free_ring α) (free_comm_ring α) :=\n  has_coe.mk ⇑to_free_comm_ring\n\nprotected instance coe.is_ring_hom (α : Type u) : is_ring_hom coe :=\n  ring_hom.is_ring_hom to_free_comm_ring\n\n@[simp] protected theorem coe_zero (α : Type u) : ↑0 = 0 :=\n  rfl\n\n@[simp] protected theorem coe_one (α : Type u) : ↑1 = 1 :=\n  rfl\n\n@[simp] protected theorem coe_of {α : Type u} (a : α) : ↑(of a) = free_comm_ring.of a :=\n  lift_of free_comm_ring.of a\n\n@[simp] protected theorem coe_neg {α : Type u} (x : free_ring α) : ↑(-x) = -↑x :=\n  ring_hom.map_neg (lift free_comm_ring.of) x\n\n@[simp] protected theorem coe_add {α : Type u} (x : free_ring α) (y : free_ring α) : ↑(x + y) = ↑x + ↑y :=\n  ring_hom.map_add (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_sub {α : Type u} (x : free_ring α) (y : free_ring α) : ↑(x - y) = ↑x - ↑y :=\n  ring_hom.map_sub (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_mul {α : Type u} (x : free_ring α) (y : free_ring α) : ↑(x * y) = ↑x * ↑y :=\n  ring_hom.map_mul (lift free_comm_ring.of) x y\n\nprotected theorem coe_surjective (α : Type u) : function.surjective coe := sorry\n\ntheorem coe_eq (α : Type u) : coe = Functor.map fun (l : List α) => ↑l := sorry\n\n-- FIXME This was in `deprecated.ring`, but only used here.\n\n-- It would be good to inline it into the next construction.\n\n/-- Interpret an equivalence `f : R ≃ S` as a ring equivalence `R ≃+* S`. -/\ndef of' {R : Type u_1} {S : Type u_2} [ring R] [ring S] (e : R ≃ S) [is_ring_hom ⇑e] : R ≃+* S :=\n  ring_equiv.mk (equiv.to_fun e) (equiv.inv_fun e) (equiv.left_inv e) (equiv.right_inv e) sorry sorry\n\n/-- If α has size at most 1 then the natural map from the free ring on `α` to the\n    free commutative ring on `α` is an isomorphism of rings. -/\ndef subsingleton_equiv_free_comm_ring (α : Type u) [subsingleton α] : free_ring α ≃+* free_comm_ring α :=\n  of' (functor.map_equiv free_abelian_group (multiset.subsingleton_equiv α))\n\nprotected instance comm_ring (α : Type u) [subsingleton α] : comm_ring (free_ring α) :=\n  comm_ring.mk ring.add sorry ring.zero sorry sorry ring.neg ring.sub sorry sorry ring.mul sorry ring.one sorry sorry\n    sorry sorry sorry\n\nend free_ring\n\n\n/-- The free commutative ring on `α` is isomorphic to the polynomial ring over ℤ with\n    variables in `α` -/\ndef free_comm_ring_equiv_mv_polynomial_int (α : Type u) : free_comm_ring α ≃+* mv_polynomial α ℤ :=\n  ring_equiv.mk (⇑(free_comm_ring.lift fun (a : α) => mv_polynomial.X a))\n    (mv_polynomial.eval₂ (int.cast_ring_hom (free_comm_ring α)) free_comm_ring.of) sorry sorry sorry sorry\n\n/-- The free commutative ring on the empty type is isomorphic to `ℤ`. -/\ndef free_comm_ring_pempty_equiv_int : free_comm_ring pempty ≃+* ℤ :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int pempty) (mv_polynomial.pempty_ring_equiv ℤ)\n\n/-- The free commutative ring on a type with one term is isomorphic to `ℤ[X]`. -/\ndef free_comm_ring_punit_equiv_polynomial_int : free_comm_ring PUnit ≃+* polynomial ℤ :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int PUnit) (mv_polynomial.punit_ring_equiv ℤ)\n\n/-- The free ring on the empty type is isomorphic to `ℤ`. -/\ndef free_ring_pempty_equiv_int : free_ring pempty ≃+* ℤ :=\n  ring_equiv.trans (free_ring.subsingleton_equiv_free_comm_ring pempty) free_comm_ring_pempty_equiv_int\n\n/-- The free ring on a type with one term is isomorphic to `ℤ[X]`. -/\ndef free_ring_punit_equiv_polynomial_int : free_ring PUnit ≃+* polynomial ℤ :=\n  ring_equiv.trans (free_ring.subsingleton_equiv_free_comm_ring PUnit) free_comm_ring_punit_equiv_polynomial_int\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/free_comm_ring.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.45367726198455594}}
{"text": "-- import category_theory.limits.terminal\n-- import category_theory.tactics.obviously\n\n-- open category_theory\n\n-- universes u v\n\n-- namespace category_theory.limits\n\n-- variables {C : Type u} [𝒞 : category.{u v} C]\n-- include 𝒞\n\n-- structure is_zero (t : C) :=\n-- (lift : ∀ (s : C), s ⟶ t)\n-- (uniq_lift' : ∀ (s : C) (m : s ⟶ t), m = lift s . obviously)\n-- (desc : ∀ (s : C), t ⟶ s)\n-- (uniq_desc' : ∀ (s : C) (m : t ⟶ s), m = desc s . obviously)\n\n-- namespace is_zero\n-- def to_is_initial  {t : C} (Z : is_zero.{u v} t) : is_initial.{u v} t  := { desc := Z.desc, uniq' := Z.uniq_desc' }\n-- def to_is_terminal {t : C} (Z : is_zero.{u v} t) : is_terminal.{u v} t := { lift := Z.lift, uniq' := Z.uniq_lift' }\n-- end is_zero\n\n\n-- restate_axiom is_zero.uniq_lift'\n-- restate_axiom is_zero.uniq_desc'\n-- attribute [search,elim] is_zero.uniq_lift is_zero.uniq_desc\n\n-- @[extensionality] lemma is_zero.ext {X : C} (P Q : is_zero.{u v} X) : P = Q :=\n-- begin tactic.unfreeze_local_instances, cases P, cases Q, congr, obviously, end\n\n-- instance hom_to_zero_subsingleton (X Z : C) (B : is_zero.{u v} Z) : subsingleton (X ⟶ Z) :=\n-- limits.hom_to_terminal_subsingleton X Z B.to_is_terminal\n-- instance hom_from_zero_subsingleton (Z X : C) (B : is_zero.{u v} Z) : subsingleton (Z ⟶ X) :=\n-- limits.hom_from_initial_subsingleton Z X B.to_is_initial\n\n-- variable (C)\n\n-- class has_zero_object :=\n-- (zero : C)\n-- (is_zero : is_zero.{u v} zero)\n\n-- end category_theory.limits\n\n-- namespace category_theory.limits\n\n-- def zero_object := has_zero_object.zero.{u v}\n\n-- variables {C : Type u} [𝒞 : category.{u v} C]\n-- include 𝒞\n\n-- variables [has_zero_object.{u v} C]\n\n-- def zero_is_zero : is_zero.{u v} (zero_object.{u v} C) := has_zero_object.is_zero C\n\n-- instance has_initial_object_of_has_zero : has_initial_object.{u v} C :=\n-- { initial := zero_object.{u v} C,\n--   is_initial := zero_is_zero.to_is_initial }\n\n-- instance has_terminal_object_of_has_zero: has_terminal_object.{u v} C :=\n-- { terminal := zero_object.{u v} C,\n--   is_terminal := zero_is_zero.to_is_terminal }\n\n-- def zero_morphism (X Y : C) : X ⟶ Y := (zero_is_zero.lift.{u v} X) ≫ (zero_is_zero.desc.{u v} Y)\n\n-- instance hom_has_zero (X Y : C) : _root_.has_zero (X ⟶ Y) := { zero := zero_morphism X Y }\n\n-- @[extensionality] lemma ext.out (Y : C) (f g : zero_object.{u v} C ⟶ Y) : f = g :=\n-- begin\n--   rw (initial.universal_property).uniq _ f,\n--   rw (initial.universal_property).uniq _ g,\n-- end\n-- @[extensionality] lemma ext.in  (Y : C) (f g : Y ⟶ zero_object.{u v} C) : f = g :=\n-- begin\n--   rw (terminal.universal_property).uniq _ f,\n--   rw (terminal.universal_property).uniq _ g,\n-- end\n\n-- @[simp] lemma zero_morphism_left  {X Y Z : C} (f : Y ⟶ Z) : (zero_morphism X Y) ≫ f = zero_morphism X Z :=\n-- begin\n--   unfold zero_morphism,\n--   rw category.assoc,\n--   congr,\n--   tidy,\n-- end\n-- @[simp] lemma zero_morphism_right {X Y Z : C} (f : X ⟶ Y) : f ≫ (zero_morphism Y Z) = zero_morphism X Z :=\n-- begin\n--   unfold zero_morphism,\n--   rw ← category.assoc,\n--   congr,\n--   tidy,\n-- end\n\n-- end category_theory.limits\n\n", "meta": {"author": "semorrison", "repo": "lean-category-theory", "sha": "a27b4ae5eac978e9188d2e867c3d11d9a5b87a9e", "save_path": "github-repos/lean/semorrison-lean-category-theory", "path": "github-repos/lean/semorrison-lean-category-theory/lean-category-theory-a27b4ae5eac978e9188d2e867c3d11d9a5b87a9e/src/category_theory/universal/zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4536772555122449}}
{"text": "import tactic\n\nvariable {α : Type*}\nvariables (s t u : set α)\n\n-- BEGIN\nexample : s \\ t \\ u ⊆ s \\ (t ∪ u) :=\nbegin\n  intros x xstu,\n  have xs : x ∈ s := xstu.1.1,\n  have xnt : x ∉ t := xstu.1.2,\n  have xnu : x ∉ u := xstu.2,\n  split,\n  { exact xs }, dsimp,\n  intro xtu, -- x ∈ t ∨ x ∈ u\n  cases xtu with xt xu,\n  { show false, from xnt xt },\n  show false, from xnu xu\nend\n\n/- Alternatively -/\nexample : s \\ t \\ u ⊆ s \\ (t ∪ u) :=\nbegin\n  rintros x ⟨⟨xs, xnt⟩, xnu⟩,\n  use xs,\n  rintros (xt | xu); contradiction,\nend\n-- END", "meta": {"author": "xhkittyyan", "repo": "Lean-Seminars-Series-Fall-2022", "sha": "6951cdf2cb4e001666d2a56170601325f69d52b5", "save_path": "github-repos/lean/xhkittyyan-Lean-Seminars-Series-Fall-2022", "path": "github-repos/lean/xhkittyyan-Lean-Seminars-Series-Fall-2022/Lean-Seminars-Series-Fall-2022-6951cdf2cb4e001666d2a56170601325f69d52b5/src/5_split/5.1_conjunc/ex6_split_set_diff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419958239132, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.45360758751297386}}
{"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Fabian Glöckle\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.finite_dimensional\nimport Mathlib.tactic.apply_fun\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u v w l \n\nnamespace Mathlib\n\n/-!\n# Dual vector spaces\n\nThe dual space of an R-module M is the R-module of linear maps `M → R`.\n\n## Main definitions\n\n* `dual R M` defines the dual space of M over R.\n* Given a basis for a K-vector space `V`, `is_basis.to_dual` produces a map from `V` to `dual K V`.\n* Given families of vectors `e` and `ε`, `dual_pair e ε` states that these families have the\n  characteristic properties of a basis and a dual.\n\n## Main results\n\n* `to_dual_equiv` : the dual space is linearly equivalent to the primal space.\n* `dual_pair.is_basis` and `dual_pair.eq_dual`: if `e` and `ε` form a dual pair, `e` is a basis and\n  `ε` is its dual basis.\n\n## Notation\n\nWe sometimes use `V'` as local notation for `dual K V`.\n\n-/\n\nnamespace module\n\n\n/-- The dual space of an R-module M is the R-module of linear maps `M → R`. -/\ndef dual (R : Type u_1) (M : Type u_2) [comm_ring R] [add_comm_group M] [module R M] :=\n  linear_map R M R\n\nnamespace dual\n\n\nprotected instance inhabited (R : Type u_1) (M : Type u_2) [comm_ring R] [add_comm_group M]\n    [module R M] : Inhabited (dual R M) :=\n  id linear_map.inhabited\n\nprotected instance has_coe_to_fun (R : Type u_1) (M : Type u_2) [comm_ring R] [add_comm_group M]\n    [module R M] : has_coe_to_fun (dual R M) :=\n  has_coe_to_fun.mk (fun (x : dual R M) => M → R) linear_map.to_fun\n\n/-- Maps a module M to the dual of the dual of M. See `vector_space.erange_coe` and\n`vector_space.eval_equiv`. -/\ndef eval (R : Type u_1) (M : Type u_2) [comm_ring R] [add_comm_group M] [module R M] :\n    linear_map R M (dual R (dual R M)) :=\n  linear_map.flip linear_map.id\n\n@[simp] theorem eval_apply (R : Type u_1) (M : Type u_2) [comm_ring R] [add_comm_group M]\n    [module R M] (v : M) (a : dual R M) : coe_fn (coe_fn (eval R M) v) a = coe_fn a v :=\n  sorry\n\n/-- The transposition of linear maps, as a linear map from `M →ₗ[R] M'` to\n`dual R M' →ₗ[R] dual R M`. -/\ndef transpose {R : Type u_1} {M : Type u_2} [comm_ring R] [add_comm_group M] [module R M]\n    {M' : Type u_3} [add_comm_group M'] [module R M'] :\n    linear_map R (linear_map R M M') (linear_map R (dual R M') (dual R M)) :=\n  linear_map.flip (linear_map.llcomp R M M' R)\n\ntheorem transpose_apply {R : Type u_1} {M : Type u_2} [comm_ring R] [add_comm_group M] [module R M]\n    {M' : Type u_3} [add_comm_group M'] [module R M'] (u : linear_map R M M') (l : dual R M') :\n    coe_fn (coe_fn transpose u) l = linear_map.comp l u :=\n  rfl\n\ntheorem transpose_comp {R : Type u_1} {M : Type u_2} [comm_ring R] [add_comm_group M] [module R M]\n    {M' : Type u_3} [add_comm_group M'] [module R M'] {M'' : Type u_4} [add_comm_group M'']\n    [module R M''] (u : linear_map R M' M'') (v : linear_map R M M') :\n    coe_fn transpose (linear_map.comp u v) =\n        linear_map.comp (coe_fn transpose v) (coe_fn transpose u) :=\n  rfl\n\nend dual\n\n\nend module\n\n\nnamespace is_basis\n\n\n/-- The linear map from a vector space equipped with basis to its dual vector space,\ntaking basis elements to corresponding dual basis elements. -/\ndef to_dual {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V] [vector_space K V]\n    [de : DecidableEq ι] (B : ι → V) (h : is_basis K B) : linear_map K V (module.dual K V) :=\n  constr h fun (v : ι) => constr h fun (w : ι) => ite (w = v) 1 0\n\ntheorem to_dual_apply {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) (i : ι) (j : ι) :\n    coe_fn (coe_fn (to_dual B h) (B i)) (B j) = ite (i = j) 1 0 :=\n  sorry\n\n@[simp] theorem to_dual_total_left {K : Type u} {V : Type v} {ι : Type w} [field K]\n    [add_comm_group V] [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B)\n    (f : ι →₀ K) (i : ι) :\n    coe_fn (coe_fn (to_dual B h) (coe_fn (finsupp.total ι V K B) f)) (B i) = coe_fn f i :=\n  sorry\n\n@[simp] theorem to_dual_total_right {K : Type u} {V : Type v} {ι : Type w} [field K]\n    [add_comm_group V] [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B)\n    (f : ι →₀ K) (i : ι) :\n    coe_fn (coe_fn (to_dual B h) (B i)) (coe_fn (finsupp.total ι V K B) f) = coe_fn f i :=\n  sorry\n\ntheorem to_dual_apply_left {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) (v : V) (i : ι) :\n    coe_fn (coe_fn (to_dual B h) v) (B i) = coe_fn (coe_fn (repr h) v) i :=\n  sorry\n\ntheorem to_dual_apply_right {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) (i : ι) (v : V) :\n    coe_fn (coe_fn (to_dual B h) (B i)) v = coe_fn (coe_fn (repr h) v) i :=\n  sorry\n\n/-- `h.to_dual_flip v` is the linear map sending `w` to `h.to_dual w v`. -/\ndef to_dual_flip {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] (B : ι → V) (h : is_basis K B) (v : V) :\n    linear_map K V K :=\n  coe_fn (linear_map.flip (to_dual B h)) v\n\n-- TODO: unify this with `finsupp.lapply`.\n\n/-- Evaluation of finitely supported functions at a fixed point `i`, as a `K`-linear map. -/\ndef eval_finsupp_at {K : Type u} {ι : Type w} [field K] (i : ι) : linear_map K (ι →₀ K) K :=\n  linear_map.mk (fun (f : ι →₀ K) => coe_fn f i) sorry sorry\n\n/-- `h.coord_fun i` sends vectors to their `i`'th coordinate with respect to the basis `h`. -/\ndef coord_fun {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V] [vector_space K V]\n    {B : ι → V} (h : is_basis K B) (i : ι) : linear_map K V K :=\n  linear_map.comp (eval_finsupp_at i) (repr h)\n\ntheorem coord_fun_eq_repr {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {B : ι → V} (h : is_basis K B) (v : V) (i : ι) :\n    coe_fn (coord_fun h i) v = coe_fn (coe_fn (repr h) v) i :=\n  rfl\n\n-- TODO: this lemma should be called something like `to_dual_flip_apply`\n\ntheorem to_dual_swap_eq_to_dual {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) (v : V) (w : V) :\n    coe_fn (to_dual_flip B h v) w = coe_fn (coe_fn (to_dual B h) w) v :=\n  rfl\n\ntheorem to_dual_eq_repr {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) (v : V) (i : ι) :\n    coe_fn (coe_fn (to_dual B h) v) (B i) = coe_fn (coe_fn (repr h) v) i :=\n  to_dual_apply_left h v i\n\ntheorem to_dual_eq_equiv_fun {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fintype ι] (v : V)\n    (i : ι) : coe_fn (coe_fn (to_dual B h) v) (B i) = coe_fn (equiv_fun h) v i :=\n  sorry\n\ntheorem to_dual_inj {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) (v : V)\n    (a : coe_fn (to_dual B h) v = 0) : v = 0 :=\n  sorry\n\ntheorem to_dual_ker {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) :\n    linear_map.ker (to_dual B h) = ⊥ :=\n  iff.mpr linear_map.ker_eq_bot' (to_dual_inj h)\n\ntheorem to_dual_range {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fin : fintype ι] :\n    linear_map.range (to_dual B h) = ⊤ :=\n  sorry\n\n/-- Maps a basis for `V` to a basis for the dual space. -/\ndef dual_basis {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) : ι → module.dual K V :=\n  fun (i : ι) => coe_fn (to_dual B h) (B i)\n\ntheorem dual_lin_independent {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) :\n    linear_independent K (dual_basis h) :=\n  linear_independent.map' (and.left h) (to_dual B h) (to_dual_ker h)\n\n@[simp] theorem dual_basis_apply_self {K : Type u} {V : Type v} {ι : Type w} [field K]\n    [add_comm_group V] [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B)\n    (i : ι) (j : ι) : coe_fn (dual_basis h i) (B j) = ite (i = j) 1 0 :=\n  to_dual_apply h i j\n\n/-- A vector space is linearly equivalent to its dual space. -/\ndef to_dual_equiv {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] (B : ι → V) (h : is_basis K B) [fintype ι] :\n    linear_equiv K V (module.dual K V) :=\n  linear_equiv.of_bijective (to_dual B h) sorry sorry\n\ntheorem dual_basis_is_basis {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fintype ι] :\n    is_basis K (dual_basis h) :=\n  linear_equiv.is_basis h (to_dual_equiv B h)\n\n@[simp] theorem total_dual_basis {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fintype ι] (f : ι →₀ K)\n    (i : ι) :\n    coe_fn (coe_fn (finsupp.total ι (module.dual K V) K (dual_basis h)) f) (B i) = coe_fn f i :=\n  sorry\n\ntheorem dual_basis_repr {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fintype ι]\n    (l : module.dual K V) (i : ι) :\n    coe_fn (coe_fn (repr (dual_basis_is_basis h)) l) i = coe_fn l (B i) :=\n  sorry\n\ntheorem dual_basis_equiv_fun {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fintype ι]\n    (l : module.dual K V) (i : ι) :\n    coe_fn (equiv_fun (dual_basis_is_basis h)) l i = coe_fn l (B i) :=\n  sorry\n\ntheorem dual_basis_apply {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fintype ι] (i : ι)\n    (v : V) : coe_fn (dual_basis h i) v = coe_fn (equiv_fun h) v i :=\n  to_dual_apply_right h i v\n\n@[simp] theorem to_dual_to_dual {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq ι] {B : ι → V} (h : is_basis K B) [fintype ι] :\n    linear_map.comp (to_dual (dual_basis h) (dual_basis_is_basis h)) (to_dual B h) =\n        module.dual.eval K V :=\n  sorry\n\ntheorem dual_dim_eq {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {B : ι → V} (h : is_basis K B) [fintype ι] :\n    cardinal.lift (vector_space.dim K V) = vector_space.dim K (module.dual K V) :=\n  sorry\n\nend is_basis\n\n\nnamespace vector_space\n\n\ntheorem eval_ker {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] :\n    linear_map.ker (module.dual.eval K V) = ⊥ :=\n  sorry\n\ntheorem dual_dim_eq {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    [finite_dimensional K V] : cardinal.lift (dim K V) = dim K (module.dual K V) :=\n  sorry\n\ntheorem erange_coe {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    [finite_dimensional K V] : linear_map.range (module.dual.eval K V) = ⊤ :=\n  sorry\n\n/-- A vector space is linearly equivalent to the dual of its dual space. -/\ndef eval_equiv {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V]\n    [finite_dimensional K V] : linear_equiv K V (module.dual K (module.dual K V)) :=\n  linear_equiv.of_bijective (module.dual.eval K V) eval_ker erange_coe\n\nend vector_space\n\n\n/-- `e` and `ε` have characteristic properties of a basis and its dual -/\nstructure dual_pair {K : Type u} {V : Type v} {ι : Type w} [DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] (e : ι → V) (ε : ι → module.dual K V)\n    where\n  eval : ∀ (i j : ι), coe_fn (ε i) (e j) = ite (i = j) 1 0\n  total : ∀ {v : V}, (∀ (i : ι), coe_fn (ε i) v = 0) → v = 0\n  finite : (v : V) → fintype ↥(set_of fun (i : ι) => coe_fn (ε i) v ≠ 0)\n\nnamespace dual_pair\n\n\n/-- The coefficients of `v` on the basis `e` -/\ndef coeffs {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K] [add_comm_group V]\n    [vector_space K V] {e : ι → V} {ε : ι → module.dual K V} (h : dual_pair e ε) (v : V) : ι →₀ K :=\n  finsupp.mk (set.to_finset (set_of fun (i : ι) => coe_fn (ε i) v ≠ 0))\n    (fun (i : ι) => coe_fn (ε i) v) sorry\n\n@[simp] theorem coeffs_apply {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] {e : ι → V} {ε : ι → module.dual K V} (h : dual_pair e ε)\n    (v : V) (i : ι) : coe_fn (coeffs h v) i = coe_fn (ε i) v :=\n  rfl\n\n/-- linear combinations of elements of `e`.\nThis is a convenient abbreviation for `finsupp.total _ V K e l` -/\ndef lc {K : Type u} {V : Type v} {ι : Type w} [field K] [add_comm_group V] [vector_space K V]\n    (e : ι → V) (l : ι →₀ K) : V :=\n  finsupp.sum l fun (i : ι) (a : K) => a • e i\n\ntheorem dual_lc {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] {e : ι → V} {ε : ι → module.dual K V} (h : dual_pair e ε)\n    (l : ι →₀ K) (i : ι) : coe_fn (ε i) (lc e l) = coe_fn l i :=\n  sorry\n\n@[simp] theorem coeffs_lc {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] {e : ι → V} {ε : ι → module.dual K V} (h : dual_pair e ε)\n    (l : ι →₀ K) : coeffs h (lc e l) = l :=\n  sorry\n\n/-- For any v : V n, \\sum_{p ∈ Q n} (ε p v) • e p = v -/\ntheorem decomposition {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] {e : ι → V} {ε : ι → module.dual K V} (h : dual_pair e ε)\n    (v : V) : lc e (coeffs h v) = v :=\n  sorry\n\ntheorem mem_of_mem_span {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] {e : ι → V} {ε : ι → module.dual K V} (h : dual_pair e ε)\n    {H : set ι} {x : V} (hmem : x ∈ submodule.span K (e '' H)) (i : ι) :\n    coe_fn (ε i) x ≠ 0 → i ∈ H :=\n  sorry\n\ntheorem is_basis {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] {e : ι → V} {ε : ι → module.dual K V}\n    (h : dual_pair e ε) : is_basis K e :=\n  sorry\n\ntheorem eq_dual {K : Type u} {V : Type v} {ι : Type w} [dι : DecidableEq ι] [field K]\n    [add_comm_group V] [vector_space K V] {e : ι → V} {ε : ι → module.dual K V}\n    (h : dual_pair e ε) : ε = is_basis.dual_basis (is_basis h) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/dual_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419704455588, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.45360758488880154}}
{"text": "import tactic\nimport for_mathlib -- gives us new theorem `alg_hom.eq_of_id`\n\n/-!\n\n# Formally unramified morphisms\n\nA ring morphism `A →+* B` between commutative rings `A` and `B` is *formally unramified*\nif for every surjective square-zero extension of A-algebras `R' →+* R`\n(meaning that the kernel I satisties I² = 0)\nthe natural map Hom_A(B,R') → Hom_A(B,R) is injective.\n\n-/\n\n-- Let A and B be commutative rings\nvariables {A B : Type} [comm_ring A] [comm_ring B]\n\n--set_option pp.notation false\n\n/-- A ring homomorphism `f : A → B` is *formally unramified* if for every surjective square zero\nmorphism `φ : R → R'` of A-algebras, the natural map Hom_A(B,R') → Hom_A(B, R) is\nan injection. -/\ndef is_formally_unramified {A B : Type} [comm_ring A] [comm_ring B] (f : A →+* B) : Prop :=\n-- First let's make B into an A-algebra in the obvious way via f\nlet h : algebra A B := f.to_algebra in\n-- The condition is: For all A-algebras R and R'\n∀ {{R R' : Type}} [comm_ring R] [comm_ring R'], by exactI\n∀ [algebra A R] [algebra A R'], by exactI\n-- and for all A-algebra morphisms φ : R' → R with square zero\n∀ {φ : R' →ₐ[A] R} (hφ1 : ∀ r : R, ∃ r' : R', φ r' = r) \n  (hφ2 : ∀ x y : R', φ x = 0 → φ y = 0 → x * y = 0),\n-- composing with φ is an injection Hom_A(B,R') → Hom_A(B, R)\nfunction.injective (φ.comp : (B →ₐ[A] R') → (B →ₐ[A] R))\n\nlemma is_formally_unramified_id : is_formally_unramified (ring_hom.id A: A →+* A) :=\nbegin\n  intros R R',\n  intro _,\n  intro _,\n  intros _ _,\n  intro φ,\n  intro hφ,\n  intro hφ',\n  unfold function.injective,\n  intros a₁ a₂,\n  resetI,\n  intro h,\n  rw a₁.eq_of_id,\n  rw a₂.eq_of_id,\n  -- the last two lines can be replaced by\n  -- apply subsingleton.elim,\n  -- then lean does more work (see zulip chat)\nend\n\n\nvariables {C : Type} [comm_ring C]\n\nlemma is_formally_unramified.comp {φ : A →+* B} (hφ : is_formally_unramified φ)\n  {ψ : B →+* C} (hψ : is_formally_unramified ψ) : is_formally_unramified (ψ.comp φ) :=\nbegin\n intros R R' _ _ _ _ f,\n intros hf1 hf2,\n  unfold function.injective,\n  intros a₁ a₂ hyp, \n  letI : algebra A B := φ.to_algebra,\n  letI : algebra A C := (ψ.comp φ).to_algebra,\n  let ψ' : B →ₐ[A] C :=\n  { commutes' := λ r, rfl, -- definitional abuse!\n    ..ψ },\nhave h_5: f.comp (a₁.comp ψ') =  f.comp (a₂.comp ψ'),\n  begin \n  rw ← alg_hom.comp_assoc,\n  rw ← alg_hom.comp_assoc,\n  rw hyp, \n  end,\n have h_6: a₁.comp ψ' =  a₂.comp ψ', -- as phi is formally unramified\n  begin\n  apply hφ hf1 hf2,\n  apply h_5\n  end,\n let σ := a₁.comp ψ',\n let ρ := f.comp (a₁.comp ψ'),\n letI : algebra B R' := σ.to_ring_hom.to_algebra,\n letI : algebra B R := ρ.to_ring_hom.to_algebra,\n let f' : R' →ₐ[B] R :=\n  { commutes' := λ r, rfl,\n    ..f },\n-- now I want to tell lean that a₁ and a₂ are in fact B algbera maps using h_6.\nletI : algebra B C := ψ.to_algebra,\nlet a₁' : C →ₐ[B] R' :=\n{ commutes' :=  λ r, rfl,\n   ..a₁ },\nlet a₂' : C →ₐ[B] R' :=\n{ commutes' := begin intro r, change (a₂.comp ψ') r = _, rw ← h_6, refl,\nend, ..a₂ },\nhave h_7 : f'.comp a₁' = f'.comp a₂',\n  begin\n  ext r,\n  rw alg_hom.ext_iff at hyp,\n  specialize hyp r,\n  exact hyp,\n  end,\nhave hf1' : ∀ (r : R), ∃ (r' : R'), f' r' = r,\n  exact hf1,\nhave hf2' : ∀ (x y : R'), f' x = 0 → f' y = 0 → x * y = 0,\n  exact hf2,\nhave h_8 : a₁' = a₂', \n  begin \n  specialize hψ hf1' hf2',\n  apply hψ h_7,\n  end,\next r,\nrw alg_hom.ext_iff at h_8,\nspecialize h_8 r,\nexact h_8,\nend\n\n", "meta": {"author": "kbuzzard", "repo": "etale_experiments", "sha": "7d1f2f6f772f03ad553971103696ebc0654068f4", "save_path": "github-repos/lean/kbuzzard-etale_experiments", "path": "github-repos/lean/kbuzzard-etale_experiments/etale_experiments-7d1f2f6f772f03ad553971103696ebc0654068f4/src/formally_unramified.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.45360757920289874}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n\n! This file was ported from Lean 3 source module data.finset.n_ary\n! leanprover-community/mathlib commit 517cc149e0b515d2893baa376226ed10feb319c7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Finset.Prod\nimport Mathbin.Data.Set.Finite\n\n/-!\n# N-ary images of finsets\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines `finset.image₂`, the binary image of finsets. This is the finset version of\n`set.image2`. This is mostly useful to define pointwise operations.\n\n## Notes\n\nThis file is very similar to `data.set.n_ary`, `order.filter.n_ary` and `data.option.n_ary`. Please\nkeep them in sync.\n\nWe do not define `finset.image₃` as its only purpose would be to prove properties of `finset.image₂`\nand `set.image2` already fulfills this task.\n-/\n\n\nopen Function Set\n\nvariable {α α' β β' γ γ' δ δ' ε ε' ζ ζ' ν : Type _}\n\nnamespace Finset\n\nvariable [DecidableEq α'] [DecidableEq β'] [DecidableEq γ] [DecidableEq γ'] [DecidableEq δ]\n  [DecidableEq δ'] [DecidableEq ε] [DecidableEq ε'] {f f' : α → β → γ} {g g' : α → β → γ → δ}\n  {s s' : Finset α} {t t' : Finset β} {u u' : Finset γ} {a a' : α} {b b' : β} {c : γ}\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.image₂ /-\n/-- The image of a binary function `f : α → β → γ` as a function `finset α → finset β → finset γ`.\nMathematically this should be thought of as the image of the corresponding function `α × β → γ`. -/\ndef image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) : Finset γ :=\n  (s ×ˢ t).image <| uncurry f\n#align finset.image₂ Finset.image₂\n-/\n\n/- warning: finset.mem_image₂ -> Finset.mem_image₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {c : γ}, Iff (Membership.Mem.{u3, u3} γ (Finset.{u3} γ) (Finset.hasMem.{u3} γ) c (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Exists.{succ u1} α (fun (a : α) => Exists.{succ u2} β (fun (b : β) => And (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) (And (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) b t) (Eq.{succ u3} γ (f a b) c)))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β} {c : γ}, Iff (Membership.mem.{u3, u3} γ (Finset.{u3} γ) (Finset.instMembershipFinset.{u3} γ) c (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Exists.{succ u2} α (fun (a : α) => Exists.{succ u1} β (fun (b : β) => And (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) a s) (And (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) b t) (Eq.{succ u3} γ (f a b) c)))))\nCase conversion may be inaccurate. Consider using '#align finset.mem_image₂ Finset.mem_image₂ₓ'. -/\n@[simp]\ntheorem mem_image₂ : c ∈ image₂ f s t ↔ ∃ a b, a ∈ s ∧ b ∈ t ∧ f a b = c := by\n  simp [image₂, and_assoc']\n#align finset.mem_image₂ Finset.mem_image₂\n\n/- warning: finset.coe_image₂ -> Finset.coe_image₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] (f : α -> β -> γ) (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ u3} (Set.{u3} γ) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Finset.{u3} γ) (Set.{u3} γ) (HasLiftT.mk.{succ u3, succ u3} (Finset.{u3} γ) (Set.{u3} γ) (CoeTCₓ.coe.{succ u3, succ u3} (Finset.{u3} γ) (Set.{u3} γ) (Finset.Set.hasCoeT.{u3} γ))) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Set.image2.{u1, u2, u3} α β γ f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) s) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} β) (Set.{u2} β) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (Finset.Set.hasCoeT.{u2} β))) t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] (f : α -> β -> γ) (s : Finset.{u3} α) (t : Finset.{u2} β), Eq.{succ u1} (Set.{u1} γ) (Finset.toSet.{u1} γ (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Set.image2.{u3, u2, u1} α β γ f (Finset.toSet.{u3} α s) (Finset.toSet.{u2} β t))\nCase conversion may be inaccurate. Consider using '#align finset.coe_image₂ Finset.coe_image₂ₓ'. -/\n@[simp, norm_cast]\ntheorem coe_image₂ (f : α → β → γ) (s : Finset α) (t : Finset β) :\n    (image₂ f s t : Set γ) = Set.image2 f s t :=\n  Set.ext fun _ => mem_image₂\n#align finset.coe_image₂ Finset.coe_image₂\n\n/- warning: finset.card_image₂_le -> Finset.card_image₂_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] (f : α -> β -> γ) (s : Finset.{u1} α) (t : Finset.{u2} β), LE.le.{0} Nat Nat.hasLe (Finset.card.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} α s) (Finset.card.{u2} β t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] (f : α -> β -> γ) (s : Finset.{u3} α) (t : Finset.{u2} β), LE.le.{0} Nat instLENat (Finset.card.{u1} γ (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u3} α s) (Finset.card.{u2} β t))\nCase conversion may be inaccurate. Consider using '#align finset.card_image₂_le Finset.card_image₂_leₓ'. -/\ntheorem card_image₂_le (f : α → β → γ) (s : Finset α) (t : Finset β) :\n    (image₂ f s t).card ≤ s.card * t.card :=\n  card_image_le.trans_eq <| card_product _ _\n#align finset.card_image₂_le Finset.card_image₂_le\n\n/- warning: finset.card_image₂_iff -> Finset.card_image₂_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, Iff (Eq.{1} Nat (Finset.card.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} α s) (Finset.card.{u2} β t))) (Set.InjOn.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (fun (x : Prod.{u1, u2} α β) => f (Prod.fst.{u1, u2} α β x) (Prod.snd.{u1, u2} α β x)) (Set.prod.{u1, u2} α β ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) s) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} β) (Set.{u2} β) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (Finset.Set.hasCoeT.{u2} β))) t)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β}, Iff (Eq.{1} Nat (Finset.card.{u3} γ (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u2} α s) (Finset.card.{u1} β t))) (Set.InjOn.{max u2 u1, u3} (Prod.{u2, u1} α β) γ (fun (x : Prod.{u2, u1} α β) => f (Prod.fst.{u2, u1} α β x) (Prod.snd.{u2, u1} α β x)) (Set.prod.{u2, u1} α β (Finset.toSet.{u2} α s) (Finset.toSet.{u1} β t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_image₂_iff Finset.card_image₂_iffₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem card_image₂_iff :\n    (image₂ f s t).card = s.card * t.card ↔ (s ×ˢ t : Set (α × β)).InjOn fun x => f x.1 x.2 :=\n  by\n  rw [← card_product, ← coe_product]\n  exact card_image_iff\n#align finset.card_image₂_iff Finset.card_image₂_iff\n\n/- warning: finset.card_image₂ -> Finset.card_image₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ}, (Function.Injective2.{succ u1, succ u2, succ u3} α β γ f) -> (forall (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{1} Nat (Finset.card.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} α s) (Finset.card.{u2} β t)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ}, (Function.Injective2.{succ u3, succ u2, succ u1} α β γ f) -> (forall (s : Finset.{u3} α) (t : Finset.{u2} β), Eq.{1} Nat (Finset.card.{u1} γ (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u3} α s) (Finset.card.{u2} β t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_image₂ Finset.card_image₂ₓ'. -/\ntheorem card_image₂ (hf : Injective2 f) (s : Finset α) (t : Finset β) :\n    (image₂ f s t).card = s.card * t.card :=\n  (card_image_of_injective _ hf.uncurry).trans <| card_product _ _\n#align finset.card_image₂ Finset.card_image₂\n\n/- warning: finset.mem_image₂_of_mem -> Finset.mem_image₂_of_mem is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {a : α} {b : β}, (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) b t) -> (Membership.Mem.{u3, u3} γ (Finset.{u3} γ) (Finset.hasMem.{u3} γ) (f a b) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β} {a : α} {b : β}, (Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a s) -> (Membership.mem.{u2, u2} β (Finset.{u2} β) (Finset.instMembershipFinset.{u2} β) b t) -> (Membership.mem.{u1, u1} γ (Finset.{u1} γ) (Finset.instMembershipFinset.{u1} γ) (f a b) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.mem_image₂_of_mem Finset.mem_image₂_of_memₓ'. -/\ntheorem mem_image₂_of_mem (ha : a ∈ s) (hb : b ∈ t) : f a b ∈ image₂ f s t :=\n  mem_image₂.2 ⟨a, b, ha, hb, rfl⟩\n#align finset.mem_image₂_of_mem Finset.mem_image₂_of_mem\n\n/- warning: finset.mem_image₂_iff -> Finset.mem_image₂_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {a : α} {b : β}, (Function.Injective2.{succ u1, succ u2, succ u3} α β γ f) -> (Iff (Membership.Mem.{u3, u3} γ (Finset.{u3} γ) (Finset.hasMem.{u3} γ) (f a b) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (And (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) b t)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β} {a : α} {b : β}, (Function.Injective2.{succ u3, succ u2, succ u1} α β γ f) -> (Iff (Membership.mem.{u1, u1} γ (Finset.{u1} γ) (Finset.instMembershipFinset.{u1} γ) (f a b) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (And (Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a s) (Membership.mem.{u2, u2} β (Finset.{u2} β) (Finset.instMembershipFinset.{u2} β) b t)))\nCase conversion may be inaccurate. Consider using '#align finset.mem_image₂_iff Finset.mem_image₂_iffₓ'. -/\ntheorem mem_image₂_iff (hf : Injective2 f) : f a b ∈ image₂ f s t ↔ a ∈ s ∧ b ∈ t := by\n  rw [← mem_coe, coe_image₂, mem_image2_iff hf, mem_coe, mem_coe]\n#align finset.mem_image₂_iff Finset.mem_image₂_iff\n\n/- warning: finset.image₂_subset -> Finset.image₂_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β}, (HasSubset.Subset.{u1} (Finset.{u1} α) (Finset.hasSubset.{u1} α) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} β) (Finset.hasSubset.{u2} β) t t') -> (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t'))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {s' : Finset.{u3} α} {t : Finset.{u2} β} {t' : Finset.{u2} β}, (HasSubset.Subset.{u3} (Finset.{u3} α) (Finset.instHasSubsetFinset.{u3} α) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} β) (Finset.instHasSubsetFinset.{u2} β) t t') -> (HasSubset.Subset.{u1} (Finset.{u1} γ) (Finset.instHasSubsetFinset.{u1} γ) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t'))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_subset Finset.image₂_subsetₓ'. -/\ntheorem image₂_subset (hs : s ⊆ s') (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s' t' :=\n  by\n  rw [← coe_subset, coe_image₂, coe_image₂]\n  exact image2_subset hs ht\n#align finset.image₂_subset Finset.image₂_subset\n\n/- warning: finset.image₂_subset_left -> Finset.image₂_subset_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β}, (HasSubset.Subset.{u2} (Finset.{u2} β) (Finset.hasSubset.{u2} β) t t') -> (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t'))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {t' : Finset.{u3} β}, (HasSubset.Subset.{u3} (Finset.{u3} β) (Finset.instHasSubsetFinset.{u3} β) t t') -> (HasSubset.Subset.{u2} (Finset.{u2} γ) (Finset.instHasSubsetFinset.{u2} γ) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t'))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_subset_left Finset.image₂_subset_leftₓ'. -/\ntheorem image₂_subset_left (ht : t ⊆ t') : image₂ f s t ⊆ image₂ f s t' :=\n  image₂_subset Subset.rfl ht\n#align finset.image₂_subset_left Finset.image₂_subset_left\n\n/- warning: finset.image₂_subset_right -> Finset.image₂_subset_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β}, (HasSubset.Subset.{u1} (Finset.{u1} α) (Finset.hasSubset.{u1} α) s s') -> (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {s' : Finset.{u3} α} {t : Finset.{u1} β}, (HasSubset.Subset.{u3} (Finset.{u3} α) (Finset.instHasSubsetFinset.{u3} α) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} γ) (Finset.instHasSubsetFinset.{u2} γ) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_subset_right Finset.image₂_subset_rightₓ'. -/\ntheorem image₂_subset_right (hs : s ⊆ s') : image₂ f s t ⊆ image₂ f s' t :=\n  image₂_subset hs Subset.rfl\n#align finset.image₂_subset_right Finset.image₂_subset_right\n\n/- warning: finset.image_subset_image₂_left -> Finset.image_subset_image₂_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {b : β}, (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) b t) -> (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image.{u1, u3} α γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (a : α) => f a b) s) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {b : β}, (Membership.mem.{u3, u3} β (Finset.{u3} β) (Finset.instMembershipFinset.{u3} β) b t) -> (HasSubset.Subset.{u2} (Finset.{u2} γ) (Finset.instHasSubsetFinset.{u2} γ) (Finset.image.{u1, u2} α γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (a : α) => f a b) s) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image_subset_image₂_left Finset.image_subset_image₂_leftₓ'. -/\ntheorem image_subset_image₂_left (hb : b ∈ t) : (s.image fun a => f a b) ⊆ image₂ f s t :=\n  image_subset_iff.2 fun a ha => mem_image₂_of_mem ha hb\n#align finset.image_subset_image₂_left Finset.image_subset_image₂_left\n\n/- warning: finset.image_subset_image₂_right -> Finset.image_subset_image₂_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {a : α}, (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image.{u2, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (f a) t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u1} β} {a : α}, (Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a s) -> (HasSubset.Subset.{u2} (Finset.{u2} γ) (Finset.instHasSubsetFinset.{u2} γ) (Finset.image.{u1, u2} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (f a) t) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image_subset_image₂_right Finset.image_subset_image₂_rightₓ'. -/\ntheorem image_subset_image₂_right (ha : a ∈ s) : t.image (f a) ⊆ image₂ f s t :=\n  image_subset_iff.2 fun b => mem_image₂_of_mem ha\n#align finset.image_subset_image₂_right Finset.image_subset_image₂_right\n\n/- warning: finset.forall_image₂_iff -> Finset.forall_image₂_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {p : γ -> Prop}, Iff (forall (z : γ), (Membership.Mem.{u3, u3} γ (Finset.{u3} γ) (Finset.hasMem.{u3} γ) z (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) -> (p z)) (forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (forall (y : β), (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) y t) -> (p (f x y))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β} {p : γ -> Prop}, Iff (forall (z : γ), (Membership.mem.{u3, u3} γ (Finset.{u3} γ) (Finset.instMembershipFinset.{u3} γ) z (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) -> (p z)) (forall (x : α), (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) x s) -> (forall (y : β), (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) y t) -> (p (f x y))))\nCase conversion may be inaccurate. Consider using '#align finset.forall_image₂_iff Finset.forall_image₂_iffₓ'. -/\ntheorem forall_image₂_iff {p : γ → Prop} :\n    (∀ z ∈ image₂ f s t, p z) ↔ ∀ x ∈ s, ∀ y ∈ t, p (f x y) := by\n  simp_rw [← mem_coe, coe_image₂, forall_image2_iff]\n#align finset.forall_image₂_iff Finset.forall_image₂_iff\n\n/- warning: finset.image₂_subset_iff -> Finset.image₂_subset_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {u : Finset.{u3} γ}, Iff (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) u) (forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (forall (y : β), (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) y t) -> (Membership.Mem.{u3, u3} γ (Finset.{u3} γ) (Finset.hasMem.{u3} γ) (f x y) u)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β} {u : Finset.{u3} γ}, Iff (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.instHasSubsetFinset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) u) (forall (x : α), (Membership.mem.{u2, u2} α (Finset.{u2} α) (Finset.instMembershipFinset.{u2} α) x s) -> (forall (y : β), (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) y t) -> (Membership.mem.{u3, u3} γ (Finset.{u3} γ) (Finset.instMembershipFinset.{u3} γ) (f x y) u)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_subset_iff Finset.image₂_subset_iffₓ'. -/\n@[simp]\ntheorem image₂_subset_iff : image₂ f s t ⊆ u ↔ ∀ x ∈ s, ∀ y ∈ t, f x y ∈ u :=\n  forall_image₂_iff\n#align finset.image₂_subset_iff Finset.image₂_subset_iff\n\n/- warning: finset.image₂_nonempty_iff -> Finset.image₂_nonempty_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, Iff (Finset.Nonempty.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (And (Finset.Nonempty.{u1} α s) (Finset.Nonempty.{u2} β t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β}, Iff (Finset.Nonempty.{u3} γ (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (And (Finset.Nonempty.{u2} α s) (Finset.Nonempty.{u1} β t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_nonempty_iff Finset.image₂_nonempty_iffₓ'. -/\n@[simp]\ntheorem image₂_nonempty_iff : (image₂ f s t).Nonempty ↔ s.Nonempty ∧ t.Nonempty :=\n  by\n  rw [← coe_nonempty, coe_image₂]\n  exact image2_nonempty_iff\n#align finset.image₂_nonempty_iff Finset.image₂_nonempty_iff\n\n/- warning: finset.nonempty.image₂ -> Finset.Nonempty.image₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, (Finset.Nonempty.{u1} α s) -> (Finset.Nonempty.{u2} β t) -> (Finset.Nonempty.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β}, (Finset.Nonempty.{u3} α s) -> (Finset.Nonempty.{u2} β t) -> (Finset.Nonempty.{u1} γ (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.image₂ Finset.Nonempty.image₂ₓ'. -/\ntheorem Nonempty.image₂ (hs : s.Nonempty) (ht : t.Nonempty) : (image₂ f s t).Nonempty :=\n  image₂_nonempty_iff.2 ⟨hs, ht⟩\n#align finset.nonempty.image₂ Finset.Nonempty.image₂\n\n/- warning: finset.nonempty.of_image₂_left -> Finset.Nonempty.of_image₂_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, (Finset.Nonempty.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u1} α s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β}, (Finset.Nonempty.{u3} γ (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u2} α s)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.of_image₂_left Finset.Nonempty.of_image₂_leftₓ'. -/\ntheorem Nonempty.of_image₂_left (h : (image₂ f s t).Nonempty) : s.Nonempty :=\n  (image₂_nonempty_iff.1 h).1\n#align finset.nonempty.of_image₂_left Finset.Nonempty.of_image₂_left\n\n/- warning: finset.nonempty.of_image₂_right -> Finset.Nonempty.of_image₂_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, (Finset.Nonempty.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u2} β t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β}, (Finset.Nonempty.{u3} γ (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u1} β t)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.of_image₂_right Finset.Nonempty.of_image₂_rightₓ'. -/\ntheorem Nonempty.of_image₂_right (h : (image₂ f s t).Nonempty) : t.Nonempty :=\n  (image₂_nonempty_iff.1 h).2\n#align finset.nonempty.of_image₂_right Finset.Nonempty.of_image₂_right\n\n/- warning: finset.image₂_empty_left -> Finset.image₂_empty_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {t : Finset.{u2} β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (EmptyCollection.emptyCollection.{u1} (Finset.{u1} α) (Finset.hasEmptyc.{u1} α)) t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} γ) (Finset.hasEmptyc.{u3} γ))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {t : Finset.{u1} β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (EmptyCollection.emptyCollection.{u2} (Finset.{u2} α) (Finset.instEmptyCollectionFinset.{u2} α)) t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} γ) (Finset.instEmptyCollectionFinset.{u3} γ))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_empty_left Finset.image₂_empty_leftₓ'. -/\n@[simp]\ntheorem image₂_empty_left : image₂ f ∅ t = ∅ :=\n  coe_injective <| by simp\n#align finset.image₂_empty_left Finset.image₂_empty_left\n\n/- warning: finset.image₂_empty_right -> Finset.image₂_empty_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} β) (Finset.hasEmptyc.{u2} β))) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} γ) (Finset.hasEmptyc.{u3} γ))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} β) (Finset.instEmptyCollectionFinset.{u1} β))) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} γ) (Finset.instEmptyCollectionFinset.{u3} γ))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_empty_right Finset.image₂_empty_rightₓ'. -/\n@[simp]\ntheorem image₂_empty_right : image₂ f s ∅ = ∅ :=\n  coe_injective <| by simp\n#align finset.image₂_empty_right Finset.image₂_empty_right\n\n/- warning: finset.image₂_eq_empty_iff -> Finset.image₂_eq_empty_iff is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, Iff (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} γ) (Finset.hasEmptyc.{u3} γ))) (Or (Eq.{succ u1} (Finset.{u1} α) s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} α) (Finset.hasEmptyc.{u1} α))) (Eq.{succ u2} (Finset.{u2} β) t (EmptyCollection.emptyCollection.{u2} (Finset.{u2} β) (Finset.hasEmptyc.{u2} β))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β}, Iff (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} γ) (Finset.instEmptyCollectionFinset.{u3} γ))) (Or (Eq.{succ u2} (Finset.{u2} α) s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} α) (Finset.instEmptyCollectionFinset.{u2} α))) (Eq.{succ u1} (Finset.{u1} β) t (EmptyCollection.emptyCollection.{u1} (Finset.{u1} β) (Finset.instEmptyCollectionFinset.{u1} β))))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_eq_empty_iff Finset.image₂_eq_empty_iffₓ'. -/\n@[simp]\ntheorem image₂_eq_empty_iff : image₂ f s t = ∅ ↔ s = ∅ ∨ t = ∅ := by\n  simp_rw [← not_nonempty_iff_eq_empty, image₂_nonempty_iff, not_and_or]\n#align finset.image₂_eq_empty_iff Finset.image₂_eq_empty_iff\n\n/- warning: finset.image₂_singleton_left -> Finset.image₂_singleton_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {t : Finset.{u2} β} {a : α}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) t) (Finset.image.{u2, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (b : β) => f a b) t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {t : Finset.{u1} β} {a : α}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u2, u2} α (Finset.{u2} α) (Finset.instSingletonFinset.{u2} α) a) t) (Finset.image.{u1, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (b : β) => f a b) t)\nCase conversion may be inaccurate. Consider using '#align finset.image₂_singleton_left Finset.image₂_singleton_leftₓ'. -/\n@[simp]\ntheorem image₂_singleton_left : image₂ f {a} t = t.image fun b => f a b :=\n  ext fun x => by simp\n#align finset.image₂_singleton_left Finset.image₂_singleton_left\n\n/- warning: finset.image₂_singleton_right -> Finset.image₂_singleton_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {b : β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b)) (Finset.image.{u1, u3} α γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (a : α) => f a b) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {b : β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b)) (Finset.image.{u2, u3} α γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (a : α) => f a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.image₂_singleton_right Finset.image₂_singleton_rightₓ'. -/\n@[simp]\ntheorem image₂_singleton_right : image₂ f s {b} = s.image fun a => f a b :=\n  ext fun x => by simp\n#align finset.image₂_singleton_right Finset.image₂_singleton_right\n\n/- warning: finset.image₂_singleton_left' -> Finset.image₂_singleton_left' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {t : Finset.{u2} β} {a : α}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) t) (Finset.image.{u2, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (f a) t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {t : Finset.{u1} β} {a : α}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u2, u2} α (Finset.{u2} α) (Finset.instSingletonFinset.{u2} α) a) t) (Finset.image.{u1, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (f a) t)\nCase conversion may be inaccurate. Consider using '#align finset.image₂_singleton_left' Finset.image₂_singleton_left'ₓ'. -/\ntheorem image₂_singleton_left' : image₂ f {a} t = t.image (f a) :=\n  image₂_singleton_left\n#align finset.image₂_singleton_left' Finset.image₂_singleton_left'\n\n/- warning: finset.image₂_singleton -> Finset.image₂_singleton is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {a : α} {b : β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b)) (Singleton.singleton.{u3, u3} γ (Finset.{u3} γ) (Finset.hasSingleton.{u3} γ) (f a b))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {a : α} {b : β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u2, u2} α (Finset.{u2} α) (Finset.instSingletonFinset.{u2} α) a) (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b)) (Singleton.singleton.{u3, u3} γ (Finset.{u3} γ) (Finset.instSingletonFinset.{u3} γ) (f a b))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_singleton Finset.image₂_singletonₓ'. -/\ntheorem image₂_singleton : image₂ f {a} {b} = {f a b} := by simp\n#align finset.image₂_singleton Finset.image₂_singleton\n\n/- warning: finset.image₂_union_left -> Finset.image₂_union_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u1} α], Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s s') t) (Union.union.{u3} (Finset.{u3} γ) (Finset.hasUnion.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {s' : Finset.{u3} α} {t : Finset.{u1} β} [_inst_9 : DecidableEq.{succ u3} α], Eq.{succ u2} (Finset.{u2} γ) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Union.union.{u3} (Finset.{u3} α) (Finset.instUnionFinset.{u3} α (fun (a : α) (b : α) => _inst_9 a b)) s s') t) (Union.union.{u2} (Finset.{u2} γ) (Finset.instUnionFinset.{u2} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_union_left Finset.image₂_union_leftₓ'. -/\ntheorem image₂_union_left [DecidableEq α] : image₂ f (s ∪ s') t = image₂ f s t ∪ image₂ f s' t :=\n  coe_injective <| by\n    push_cast\n    exact image2_union_left\n#align finset.image₂_union_left Finset.image₂_union_left\n\n/- warning: finset.image₂_union_right -> Finset.image₂_union_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u2} β], Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Union.union.{u2} (Finset.{u2} β) (Finset.hasUnion.{u2} β (fun (a : β) (b : β) => _inst_9 a b)) t t')) (Union.union.{u3} (Finset.{u3} γ) (Finset.hasUnion.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t'))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {t' : Finset.{u3} β} [_inst_9 : DecidableEq.{succ u3} β], Eq.{succ u2} (Finset.{u2} γ) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Union.union.{u3} (Finset.{u3} β) (Finset.instUnionFinset.{u3} β (fun (a : β) (b : β) => _inst_9 a b)) t t')) (Union.union.{u2} (Finset.{u2} γ) (Finset.instUnionFinset.{u2} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t'))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_union_right Finset.image₂_union_rightₓ'. -/\ntheorem image₂_union_right [DecidableEq β] : image₂ f s (t ∪ t') = image₂ f s t ∪ image₂ f s t' :=\n  coe_injective <| by\n    push_cast\n    exact image2_union_right\n#align finset.image₂_union_right Finset.image₂_union_right\n\n/- warning: finset.image₂_inter_left -> Finset.image₂_inter_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u1} α], (Function.Injective2.{succ u1, succ u2, succ u3} α β γ f) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s s') t) (Inter.inter.{u3} (Finset.{u3} γ) (Finset.hasInter.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {s' : Finset.{u3} α} {t : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u3} α], (Function.Injective2.{succ u3, succ u2, succ u1} α β γ f) -> (Eq.{succ u1} (Finset.{u1} γ) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Inter.inter.{u3} (Finset.{u3} α) (Finset.instInterFinset.{u3} α (fun (a : α) (b : α) => _inst_9 a b)) s s') t) (Inter.inter.{u1} (Finset.{u1} γ) (Finset.instInterFinset.{u1} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_inter_left Finset.image₂_inter_leftₓ'. -/\ntheorem image₂_inter_left [DecidableEq α] (hf : Injective2 f) :\n    image₂ f (s ∩ s') t = image₂ f s t ∩ image₂ f s' t :=\n  coe_injective <| by\n    push_cast\n    exact image2_inter_left hf\n#align finset.image₂_inter_left Finset.image₂_inter_left\n\n/- warning: finset.image₂_inter_right -> Finset.image₂_inter_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u2} β], (Function.Injective2.{succ u1, succ u2, succ u3} α β γ f) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Inter.inter.{u2} (Finset.{u2} β) (Finset.hasInter.{u2} β (fun (a : β) (b : β) => _inst_9 a b)) t t')) (Inter.inter.{u3} (Finset.{u3} γ) (Finset.hasInter.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t')))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u3} β} {t' : Finset.{u3} β} [_inst_9 : DecidableEq.{succ u3} β], (Function.Injective2.{succ u2, succ u3, succ u1} α β γ f) -> (Eq.{succ u1} (Finset.{u1} γ) (Finset.image₂.{u2, u3, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Inter.inter.{u3} (Finset.{u3} β) (Finset.instInterFinset.{u3} β (fun (a : β) (b : β) => _inst_9 a b)) t t')) (Inter.inter.{u1} (Finset.{u1} γ) (Finset.instInterFinset.{u1} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u2, u3, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u2, u3, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t')))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_inter_right Finset.image₂_inter_rightₓ'. -/\ntheorem image₂_inter_right [DecidableEq β] (hf : Injective2 f) :\n    image₂ f s (t ∩ t') = image₂ f s t ∩ image₂ f s t' :=\n  coe_injective <| by\n    push_cast\n    exact image2_inter_right hf\n#align finset.image₂_inter_right Finset.image₂_inter_right\n\n/- warning: finset.image₂_inter_subset_left -> Finset.image₂_inter_subset_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {s' : Finset.{u1} α} {t : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u1} α], HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s s') t) (Inter.inter.{u3} (Finset.{u3} γ) (Finset.hasInter.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u3} α} {s' : Finset.{u3} α} {t : Finset.{u1} β} [_inst_9 : DecidableEq.{succ u3} α], HasSubset.Subset.{u2} (Finset.{u2} γ) (Finset.instHasSubsetFinset.{u2} γ) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Inter.inter.{u3} (Finset.{u3} α) (Finset.instInterFinset.{u3} α (fun (a : α) (b : α) => _inst_9 a b)) s s') t) (Inter.inter.{u2} (Finset.{u2} γ) (Finset.instInterFinset.{u2} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_inter_subset_left Finset.image₂_inter_subset_leftₓ'. -/\ntheorem image₂_inter_subset_left [DecidableEq α] :\n    image₂ f (s ∩ s') t ⊆ image₂ f s t ∩ image₂ f s' t :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_inter_subset_left\n#align finset.image₂_inter_subset_left Finset.image₂_inter_subset_left\n\n/- warning: finset.image₂_inter_subset_right -> Finset.image₂_inter_subset_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {t' : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u2} β], HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Inter.inter.{u2} (Finset.{u2} β) (Finset.hasInter.{u2} β (fun (a : β) (b : β) => _inst_9 a b)) t t')) (Inter.inter.{u3} (Finset.{u3} γ) (Finset.hasInter.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t'))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {t' : Finset.{u3} β} [_inst_9 : DecidableEq.{succ u3} β], HasSubset.Subset.{u2} (Finset.{u2} γ) (Finset.instHasSubsetFinset.{u2} γ) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Inter.inter.{u3} (Finset.{u3} β) (Finset.instInterFinset.{u3} β (fun (a : β) (b : β) => _inst_9 a b)) t t')) (Inter.inter.{u2} (Finset.{u2} γ) (Finset.instInterFinset.{u2} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t'))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_inter_subset_right Finset.image₂_inter_subset_rightₓ'. -/\ntheorem image₂_inter_subset_right [DecidableEq β] :\n    image₂ f s (t ∩ t') ⊆ image₂ f s t ∩ image₂ f s t' :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_inter_subset_right\n#align finset.image₂_inter_subset_right Finset.image₂_inter_subset_right\n\n/- warning: finset.image₂_congr -> Finset.image₂_congr is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {f' : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (forall (b : β), (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) b t) -> (Eq.{succ u3} γ (f a b) (f' a b)))) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f' s t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {f' : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β}, (forall (a : α), (Membership.mem.{u3, u3} α (Finset.{u3} α) (Finset.instMembershipFinset.{u3} α) a s) -> (forall (b : β), (Membership.mem.{u2, u2} β (Finset.{u2} β) (Finset.instMembershipFinset.{u2} β) b t) -> (Eq.{succ u1} γ (f a b) (f' a b)))) -> (Eq.{succ u1} (Finset.{u1} γ) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f' s t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_congr Finset.image₂_congrₓ'. -/\ntheorem image₂_congr (h : ∀ a ∈ s, ∀ b ∈ t, f a b = f' a b) : image₂ f s t = image₂ f' s t :=\n  coe_injective <| by\n    push_cast\n    exact image2_congr h\n#align finset.image₂_congr Finset.image₂_congr\n\n/- warning: finset.image₂_congr' -> Finset.image₂_congr' is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {f' : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, (forall (a : α) (b : β), Eq.{succ u3} γ (f a b) (f' a b)) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f' s t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {f' : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β}, (forall (a : α) (b : β), Eq.{succ u3} γ (f a b) (f' a b)) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f' s t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_congr' Finset.image₂_congr'ₓ'. -/\n/-- A common special case of `image₂_congr` -/\ntheorem image₂_congr' (h : ∀ a b, f a b = f' a b) : image₂ f s t = image₂ f' s t :=\n  image₂_congr fun a _ b _ => h a b\n#align finset.image₂_congr' Finset.image₂_congr'\n\n/- warning: finset.subset_image₂ -> Finset.subset_image₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {u : Finset.{u3} γ} {s : Set.{u1} α} {t : Set.{u2} β}, (HasSubset.Subset.{u3} (Set.{u3} γ) (Set.hasSubset.{u3} γ) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Finset.{u3} γ) (Set.{u3} γ) (HasLiftT.mk.{succ u3, succ u3} (Finset.{u3} γ) (Set.{u3} γ) (CoeTCₓ.coe.{succ u3, succ u3} (Finset.{u3} γ) (Set.{u3} γ) (Finset.Set.hasCoeT.{u3} γ))) u) (Set.image2.{u1, u2, u3} α β γ f s t)) -> (Exists.{succ u1} (Finset.{u1} α) (fun (s' : Finset.{u1} α) => Exists.{succ u2} (Finset.{u2} β) (fun (t' : Finset.{u2} β) => And (HasSubset.Subset.{u1} (Set.{u1} α) (Set.hasSubset.{u1} α) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} α) (Set.{u1} α) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (CoeTCₓ.coe.{succ u1, succ u1} (Finset.{u1} α) (Set.{u1} α) (Finset.Set.hasCoeT.{u1} α))) s') s) (And (HasSubset.Subset.{u2} (Set.{u2} β) (Set.hasSubset.{u2} β) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} β) (Set.{u2} β) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (Finset.Set.hasCoeT.{u2} β))) t') t) (HasSubset.Subset.{u3} (Finset.{u3} γ) (Finset.hasSubset.{u3} γ) u (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t'))))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} {u : Finset.{u1} γ} {s : Set.{u3} α} {t : Set.{u2} β}, (HasSubset.Subset.{u1} (Set.{u1} γ) (Set.instHasSubsetSet.{u1} γ) (Finset.toSet.{u1} γ u) (Set.image2.{u3, u2, u1} α β γ f s t)) -> (Exists.{succ u3} (Finset.{u3} α) (fun (s' : Finset.{u3} α) => Exists.{succ u2} (Finset.{u2} β) (fun (t' : Finset.{u2} β) => And (HasSubset.Subset.{u3} (Set.{u3} α) (Set.instHasSubsetSet.{u3} α) (Finset.toSet.{u3} α s') s) (And (HasSubset.Subset.{u2} (Set.{u2} β) (Set.instHasSubsetSet.{u2} β) (Finset.toSet.{u2} β t') t) (HasSubset.Subset.{u1} (Finset.{u1} γ) (Finset.instHasSubsetFinset.{u1} γ) u (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s' t'))))))\nCase conversion may be inaccurate. Consider using '#align finset.subset_image₂ Finset.subset_image₂ₓ'. -/\ntheorem subset_image₂ {s : Set α} {t : Set β} (hu : ↑u ⊆ image2 f s t) :\n    ∃ (s' : Finset α)(t' : Finset β), ↑s' ⊆ s ∧ ↑t' ⊆ t ∧ u ⊆ image₂ f s' t' :=\n  by\n  apply Finset.induction_on' u\n  · exact ⟨∅, ∅, Set.empty_subset _, Set.empty_subset _, empty_subset _⟩\n  rintro a u ha _ _ ⟨s', t', hs, hs', h⟩\n  obtain ⟨x, y, hx, hy, ha⟩ := hu ha\n  haveI := Classical.decEq α\n  haveI := Classical.decEq β\n  refine' ⟨insert x s', insert y t', _⟩\n  simp_rw [coe_insert, Set.insert_subset]\n  exact\n    ⟨⟨hx, hs⟩, ⟨hy, hs'⟩,\n      insert_subset.2\n        ⟨mem_image₂.2 ⟨x, y, mem_insert_self _ _, mem_insert_self _ _, ha⟩,\n          h.trans <| image₂_subset (subset_insert _ _) <| subset_insert _ _⟩⟩\n#align finset.subset_image₂ Finset.subset_image₂\n\nvariable (s t)\n\n/- warning: finset.card_image₂_singleton_left -> Finset.card_image₂_singleton_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} (t : Finset.{u2} β) {a : α}, (Function.Injective.{succ u2, succ u3} β γ (f a)) -> (Eq.{1} Nat (Finset.card.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) t)) (Finset.card.{u2} β t))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} (t : Finset.{u3} β) {a : α}, (Function.Injective.{succ u3, succ u2} β γ (f a)) -> (Eq.{1} Nat (Finset.card.{u2} γ (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.instSingletonFinset.{u1} α) a) t)) (Finset.card.{u3} β t))\nCase conversion may be inaccurate. Consider using '#align finset.card_image₂_singleton_left Finset.card_image₂_singleton_leftₓ'. -/\ntheorem card_image₂_singleton_left (hf : Injective (f a)) : (image₂ f {a} t).card = t.card := by\n  rw [image₂_singleton_left, card_image_of_injective _ hf]\n#align finset.card_image₂_singleton_left Finset.card_image₂_singleton_left\n\n/- warning: finset.card_image₂_singleton_right -> Finset.card_image₂_singleton_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} (s : Finset.{u1} α) {b : β}, (Function.Injective.{succ u1, succ u3} α γ (fun (a : α) => f a b)) -> (Eq.{1} Nat (Finset.card.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b))) (Finset.card.{u1} α s))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} (s : Finset.{u3} α) {b : β}, (Function.Injective.{succ u3, succ u2} α γ (fun (a : α) => f a b)) -> (Eq.{1} Nat (Finset.card.{u2} γ (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b))) (Finset.card.{u3} α s))\nCase conversion may be inaccurate. Consider using '#align finset.card_image₂_singleton_right Finset.card_image₂_singleton_rightₓ'. -/\ntheorem card_image₂_singleton_right (hf : Injective fun a => f a b) :\n    (image₂ f s {b}).card = s.card := by rw [image₂_singleton_right, card_image_of_injective _ hf]\n#align finset.card_image₂_singleton_right Finset.card_image₂_singleton_right\n\n/- warning: finset.image₂_singleton_inter -> Finset.image₂_singleton_inter is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {a : α} [_inst_9 : DecidableEq.{succ u2} β] (t₁ : Finset.{u2} β) (t₂ : Finset.{u2} β), (Function.Injective.{succ u2, succ u3} β γ (f a)) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) (Inter.inter.{u2} (Finset.{u2} β) (Finset.hasInter.{u2} β (fun (a : β) (b : β) => _inst_9 a b)) t₁ t₂)) (Inter.inter.{u3} (Finset.{u3} γ) (Finset.hasInter.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) t₁) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.hasSingleton.{u1} α) a) t₂)))\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u3}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {a : α} [_inst_9 : DecidableEq.{succ u3} β] (t₁ : Finset.{u3} β) (t₂ : Finset.{u3} β), (Function.Injective.{succ u3, succ u2} β γ (f a)) -> (Eq.{succ u2} (Finset.{u2} γ) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.instSingletonFinset.{u1} α) a) (Inter.inter.{u3} (Finset.{u3} β) (Finset.instInterFinset.{u3} β (fun (a : β) (b : β) => _inst_9 a b)) t₁ t₂)) (Inter.inter.{u2} (Finset.{u2} γ) (Finset.instInterFinset.{u2} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.instSingletonFinset.{u1} α) a) t₁) (Finset.image₂.{u1, u3, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Singleton.singleton.{u1, u1} α (Finset.{u1} α) (Finset.instSingletonFinset.{u1} α) a) t₂)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_singleton_inter Finset.image₂_singleton_interₓ'. -/\ntheorem image₂_singleton_inter [DecidableEq β] (t₁ t₂ : Finset β) (hf : Injective (f a)) :\n    image₂ f {a} (t₁ ∩ t₂) = image₂ f {a} t₁ ∩ image₂ f {a} t₂ := by\n  simp_rw [image₂_singleton_left, image_inter _ _ hf]\n#align finset.image₂_singleton_inter Finset.image₂_singleton_inter\n\n/- warning: finset.image₂_inter_singleton -> Finset.image₂_inter_singleton is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {b : β} [_inst_9 : DecidableEq.{succ u1} α] (s₁ : Finset.{u1} α) (s₂ : Finset.{u1} α), (Function.Injective.{succ u1, succ u3} α γ (fun (a : α) => f a b)) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s₁ s₂) (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b)) (Inter.inter.{u3} (Finset.{u3} γ) (Finset.hasInter.{u3} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s₁ (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s₂ (Singleton.singleton.{u2, u2} β (Finset.{u2} β) (Finset.hasSingleton.{u2} β) b))))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} γ] {f : α -> β -> γ} {b : β} [_inst_9 : DecidableEq.{succ u3} α] (s₁ : Finset.{u3} α) (s₂ : Finset.{u3} α), (Function.Injective.{succ u3, succ u2} α γ (fun (a : α) => f a b)) -> (Eq.{succ u2} (Finset.{u2} γ) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Inter.inter.{u3} (Finset.{u3} α) (Finset.instInterFinset.{u3} α (fun (a : α) (b : α) => _inst_9 a b)) s₁ s₂) (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b)) (Inter.inter.{u2} (Finset.{u2} γ) (Finset.instInterFinset.{u2} γ (fun (a : γ) (b : γ) => _inst_3 a b)) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s₁ (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b)) (Finset.image₂.{u3, u1, u2} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s₂ (Singleton.singleton.{u1, u1} β (Finset.{u1} β) (Finset.instSingletonFinset.{u1} β) b))))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_inter_singleton Finset.image₂_inter_singletonₓ'. -/\ntheorem image₂_inter_singleton [DecidableEq α] (s₁ s₂ : Finset α) (hf : Injective fun a => f a b) :\n    image₂ f (s₁ ∩ s₂) {b} = image₂ f s₁ {b} ∩ image₂ f s₂ {b} := by\n  simp_rw [image₂_singleton_right, image_inter _ _ hf]\n#align finset.image₂_inter_singleton Finset.image₂_inter_singleton\n\n/- warning: finset.card_le_card_image₂_left -> Finset.card_le_card_image₂_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} (t : Finset.{u2} β) {s : Finset.{u1} α}, (Finset.Nonempty.{u1} α s) -> (forall (a : α), Function.Injective.{succ u2, succ u3} β γ (f a)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u2} β t) (Finset.card.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} (t : Finset.{u2} β) {s : Finset.{u3} α}, (Finset.Nonempty.{u3} α s) -> (forall (a : α), Function.Injective.{succ u2, succ u1} β γ (f a)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} β t) (Finset.card.{u1} γ (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_image₂_left Finset.card_le_card_image₂_leftₓ'. -/\ntheorem card_le_card_image₂_left {s : Finset α} (hs : s.Nonempty) (hf : ∀ a, Injective (f a)) :\n    t.card ≤ (image₂ f s t).card := by\n  obtain ⟨a, ha⟩ := hs\n  rw [← card_image₂_singleton_left _ (hf a)]\n  exact card_le_of_subset (image₂_subset_right <| singleton_subset_iff.2 ha)\n#align finset.card_le_card_image₂_left Finset.card_le_card_image₂_left\n\n/- warning: finset.card_le_card_image₂_right -> Finset.card_le_card_image₂_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} (s : Finset.{u1} α) {t : Finset.{u2} β}, (Finset.Nonempty.{u2} β t) -> (forall (b : β), Function.Injective.{succ u1, succ u3} α γ (fun (a : α) => f a b)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α s) (Finset.card.{u3} γ (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] {f : α -> β -> γ} (s : Finset.{u2} α) {t : Finset.{u3} β}, (Finset.Nonempty.{u3} β t) -> (forall (b : β), Function.Injective.{succ u2, succ u1} α γ (fun (a : α) => f a b)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α s) (Finset.card.{u1} γ (Finset.image₂.{u2, u3, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_image₂_right Finset.card_le_card_image₂_rightₓ'. -/\ntheorem card_le_card_image₂_right {t : Finset β} (ht : t.Nonempty)\n    (hf : ∀ b, Injective fun a => f a b) : s.card ≤ (image₂ f s t).card :=\n  by\n  obtain ⟨b, hb⟩ := ht\n  rw [← card_image₂_singleton_right _ (hf b)]\n  exact card_le_of_subset (image₂_subset_left <| singleton_subset_iff.2 hb)\n#align finset.card_le_card_image₂_right Finset.card_le_card_image₂_right\n\nvariable {s t}\n\n/- warning: finset.bUnion_image_left -> Finset.bunionᵢ_image_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.bunionᵢ.{u1, u3} α γ (fun (a : γ) (b : γ) => _inst_3 a b) s (fun (a : α) => Finset.image.{u2, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (f a) t)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β}, Eq.{succ u3} (Finset.{u3} γ) (Finset.bunionᵢ.{u2, u3} α γ (fun (a : γ) (b : γ) => _inst_3 a b) s (fun (a : α) => Finset.image.{u1, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) (f a) t)) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)\nCase conversion may be inaccurate. Consider using '#align finset.bUnion_image_left Finset.bunionᵢ_image_leftₓ'. -/\ntheorem bunionᵢ_image_left : (s.bunionᵢ fun a => t.image <| f a) = image₂ f s t :=\n  coe_injective <| by\n    push_cast\n    exact Set.unionᵢ_image_left _\n#align finset.bUnion_image_left Finset.bunionᵢ_image_left\n\n#print Finset.bunionᵢ_image_right /-\ntheorem bunionᵢ_image_right : (t.bunionᵢ fun b => s.image fun a => f a b) = image₂ f s t :=\n  coe_injective <| by\n    push_cast\n    exact Set.unionᵢ_image_right _\n#align finset.bUnion_image_right Finset.bunionᵢ_image_right\n-/\n\n/-!\n### Algebraic replacement rules\n\nA collection of lemmas to transfer associativity, commutativity, distributivity, ... of operations\nto the associativity, commutativity, distributivity, ... of `finset.image₂` of those operations.\n\nThe proof pattern is `image₂_lemma operation_lemma`. For example, `image₂_comm mul_comm` proves that\n`image₂ (*) f g = image₂ (*) g f` in a `comm_semigroup`.\n-/\n\n\n/- warning: finset.image_image₂ -> Finset.image_image₂ is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_3 : DecidableEq.{succ u3} γ] [_inst_5 : DecidableEq.{succ u4} δ] {s : Finset.{u1} α} {t : Finset.{u2} β} (f : α -> β -> γ) (g : γ -> δ), Eq.{succ u4} (Finset.{u4} δ) (Finset.image.{u3, u4} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u1, u2, u4} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) (fun (a : α) (b : β) => g (f a b)) s t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_3 : DecidableEq.{succ u3} γ] [_inst_5 : DecidableEq.{succ u4} δ] {s : Finset.{u2} α} {t : Finset.{u1} β} (f : α -> β -> γ) (g : γ -> δ), Eq.{succ u4} (Finset.{u4} δ) (Finset.image.{u3, u4} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u2, u1, u4} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) (fun (a : α) (b : β) => g (f a b)) s t)\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂ Finset.image_image₂ₓ'. -/\ntheorem image_image₂ (f : α → β → γ) (g : γ → δ) :\n    (image₂ f s t).image g = image₂ (fun a b => g (f a b)) s t :=\n  coe_injective <| by\n    push_cast\n    exact image_image2 _ _\n#align finset.image_image₂ Finset.image_image₂\n\n#print Finset.image₂_image_left /-\ntheorem image₂_image_left (f : γ → β → δ) (g : α → γ) :\n    image₂ f (s.image g) t = image₂ (fun a b => f (g a) b) s t :=\n  coe_injective <| by\n    push_cast\n    exact image2_image_left _ _\n#align finset.image₂_image_left Finset.image₂_image_left\n-/\n\n/- warning: finset.image₂_image_right -> Finset.image₂_image_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} [_inst_3 : DecidableEq.{succ u3} γ] [_inst_5 : DecidableEq.{succ u4} δ] {s : Finset.{u1} α} {t : Finset.{u2} β} (f : α -> γ -> δ) (g : β -> γ), Eq.{succ u4} (Finset.{u4} δ) (Finset.image₂.{u1, u3, u4} α γ δ (fun (a : δ) (b : δ) => _inst_5 a b) f s (Finset.image.{u2, u3} β γ (fun (a : γ) (b : γ) => _inst_3 a b) g t)) (Finset.image₂.{u1, u2, u4} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) (fun (a : α) (b : β) => f a (g b)) s t)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} {δ : Type.{u4}} [_inst_3 : DecidableEq.{succ u2} γ] [_inst_5 : DecidableEq.{succ u4} δ] {s : Finset.{u3} α} {t : Finset.{u1} β} (f : α -> γ -> δ) (g : β -> γ), Eq.{succ u4} (Finset.{u4} δ) (Finset.image₂.{u3, u2, u4} α γ δ (fun (a : δ) (b : δ) => _inst_5 a b) f s (Finset.image.{u1, u2} β γ (fun (a : γ) (b : γ) => _inst_3 a b) g t)) (Finset.image₂.{u3, u1, u4} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) (fun (a : α) (b : β) => f a (g b)) s t)\nCase conversion may be inaccurate. Consider using '#align finset.image₂_image_right Finset.image₂_image_rightₓ'. -/\ntheorem image₂_image_right (f : α → γ → δ) (g : β → γ) :\n    image₂ f s (t.image g) = image₂ (fun a b => f a (g b)) s t :=\n  coe_injective <| by\n    push_cast\n    exact image2_image_right _ _\n#align finset.image₂_image_right Finset.image₂_image_right\n\n/- warning: finset.image₂_swap -> Finset.image₂_swap is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] (f : α -> β -> γ) (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u2, u1, u3} β α γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (a : β) (b : α) => f b a) t s)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] (f : α -> β -> γ) (s : Finset.{u3} α) (t : Finset.{u2} β), Eq.{succ u1} (Finset.{u1} γ) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u2, u3, u1} β α γ (fun (a : γ) (b : γ) => _inst_3 a b) (fun (a : β) (b : α) => f b a) t s)\nCase conversion may be inaccurate. Consider using '#align finset.image₂_swap Finset.image₂_swapₓ'. -/\ntheorem image₂_swap (f : α → β → γ) (s : Finset α) (t : Finset β) :\n    image₂ f s t = image₂ (fun a b => f b a) t s :=\n  coe_injective <| by\n    push_cast\n    exact image2_swap _ _ _\n#align finset.image₂_swap Finset.image₂_swap\n\n/- warning: finset.image₂_mk_eq_product -> Finset.image₂_mk_eq_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_9 : DecidableEq.{succ u1} α] [_inst_10 : DecidableEq.{succ u2} β] (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} α β)) (Finset.image₂.{u1, u2, max u1 u2} α β (Prod.{u1, u2} α β) (fun (a : Prod.{u1, u2} α β) (b : Prod.{u1, u2} α β) => Prod.decidableEq.{u1, u2} α β (fun (a : α) (b : α) => _inst_9 a b) (fun (a : β) (b : β) => _inst_10 a b) a b) (Prod.mk.{u1, u2} α β) s t) (Finset.product.{u1, u2} α β s t)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_9 : DecidableEq.{succ u2} α] [_inst_10 : DecidableEq.{succ u1} β] (s : Finset.{u2} α) (t : Finset.{u1} β), Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} α β)) (Finset.image₂.{u2, u1, max u1 u2} α β (Prod.{u2, u1} α β) (fun (a : Prod.{u2, u1} α β) (b : Prod.{u2, u1} α β) => instDecidableEqProd.{u2, u1} α β (fun (a : α) (b : α) => _inst_9 a b) (fun (a : β) (b : β) => _inst_10 a b) a b) (Prod.mk.{u2, u1} α β) s t) (Finset.product.{u2, u1} α β s t)\nCase conversion may be inaccurate. Consider using '#align finset.image₂_mk_eq_product Finset.image₂_mk_eq_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem image₂_mk_eq_product [DecidableEq α] [DecidableEq β] (s : Finset α) (t : Finset β) :\n    image₂ Prod.mk s t = s ×ˢ t := by ext <;> simp [Prod.ext_iff]\n#align finset.image₂_mk_eq_product Finset.image₂_mk_eq_product\n\n/- warning: finset.image₂_curry -> Finset.image₂_curry is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] (f : (Prod.{u1, u2} α β) -> γ) (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) (Function.curry.{u1, u2, u3} α β γ f) s t) (Finset.image.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Finset.product.{u1, u2} α β s t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] (f : (Prod.{u3, u2} α β) -> γ) (s : Finset.{u3} α) (t : Finset.{u2} β), Eq.{succ u1} (Finset.{u1} γ) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) (Function.curry.{u3, u2, u1} α β γ f) s t) (Finset.image.{max u3 u2, u1} (Prod.{u3, u2} α β) γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Finset.product.{u3, u2} α β s t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_curry Finset.image₂_curryₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem image₂_curry (f : α × β → γ) (s : Finset α) (t : Finset β) :\n    image₂ (curry f) s t = (s ×ˢ t).image f := by\n  classical rw [← image₂_mk_eq_product, image_image₂, curry]\n#align finset.image₂_curry Finset.image₂_curry\n\n/- warning: finset.image_uncurry_product -> Finset.image_uncurry_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] (f : α -> β -> γ) (s : Finset.{u1} α) (t : Finset.{u2} β), Eq.{succ u3} (Finset.{u3} γ) (Finset.image.{max u1 u2, u3} (Prod.{u1, u2} α β) γ (fun (a : γ) (b : γ) => _inst_3 a b) (Function.uncurry.{u1, u2, u3} α β γ f) (Finset.product.{u1, u2} α β s t)) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} γ] (f : α -> β -> γ) (s : Finset.{u3} α) (t : Finset.{u2} β), Eq.{succ u1} (Finset.{u1} γ) (Finset.image.{max u2 u3, u1} (Prod.{u3, u2} α β) γ (fun (a : γ) (b : γ) => _inst_3 a b) (Function.uncurry.{u3, u2, u1} α β γ f) (Finset.product.{u3, u2} α β s t)) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)\nCase conversion may be inaccurate. Consider using '#align finset.image_uncurry_product Finset.image_uncurry_productₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem image_uncurry_product (f : α → β → γ) (s : Finset α) (t : Finset β) :\n    (s ×ˢ t).image (uncurry f) = image₂ f s t := by rw [← image₂_curry, curry_uncurry]\n#align finset.image_uncurry_product Finset.image_uncurry_product\n\n/- warning: finset.image₂_left -> Finset.image₂_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β} [_inst_9 : DecidableEq.{succ u1} α], (Finset.Nonempty.{u2} β t) -> (Eq.{succ u1} (Finset.{u1} α) (Finset.image₂.{u1, u2, u1} α β α (fun (a : α) (b : α) => _inst_9 a b) (fun (x : α) (y : β) => x) s t) s)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} {t : Finset.{u1} β} [_inst_9 : DecidableEq.{succ u2} α], (Finset.Nonempty.{u1} β t) -> (Eq.{succ u2} (Finset.{u2} α) (Finset.image₂.{u2, u1, u2} α β α (fun (a : α) (b : α) => _inst_9 a b) (fun (x : α) (y : β) => x) s t) s)\nCase conversion may be inaccurate. Consider using '#align finset.image₂_left Finset.image₂_leftₓ'. -/\n@[simp]\ntheorem image₂_left [DecidableEq α] (h : t.Nonempty) : image₂ (fun x y => x) s t = s :=\n  coe_injective <| by\n    push_cast\n    exact image2_left h\n#align finset.image₂_left Finset.image₂_left\n\n#print Finset.image₂_right /-\n@[simp]\ntheorem image₂_right [DecidableEq β] (h : s.Nonempty) : image₂ (fun x y => y) s t = t :=\n  coe_injective <| by\n    push_cast\n    exact image2_right h\n#align finset.image₂_right Finset.image₂_right\n-/\n\n/- warning: finset.image₂_assoc -> Finset.image₂_assoc is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {δ : Type.{u3}} {ε : Type.{u4}} {ε' : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} δ] [_inst_7 : DecidableEq.{succ u4} ε] [_inst_8 : DecidableEq.{succ u5} ε'] {s : Finset.{u1} α} {t : Finset.{u2} β} {γ : Type.{u6}} {u : Finset.{u6} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f' : α -> ε' -> ε} {g' : β -> γ -> ε'}, (forall (a : α) (b : β) (c : γ), Eq.{succ u4} ε (f (g a b) c) (f' a (g' b c))) -> (Eq.{succ u4} (Finset.{u4} ε) (Finset.image₂.{u3, u6, u4} δ γ ε (fun (a : ε) (b : ε) => _inst_7 a b) f (Finset.image₂.{u1, u2, u3} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) g s t) u) (Finset.image₂.{u1, u5, u4} α ε' ε (fun (a : ε) (b : ε) => _inst_7 a b) f' s (Finset.image₂.{u2, u6, u5} β γ ε' (fun (a : ε') (b : ε') => _inst_8 a b) g' t u)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {δ : Type.{u4}} {ε : Type.{u5}} {ε' : Type.{u1}} [_inst_5 : DecidableEq.{succ u4} δ] [_inst_7 : DecidableEq.{succ u5} ε] [_inst_8 : DecidableEq.{succ u1} ε'] {s : Finset.{u3} α} {t : Finset.{u2} β} {γ : Type.{u6}} {u : Finset.{u6} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f' : α -> ε' -> ε} {g' : β -> γ -> ε'}, (forall (a : α) (b : β) (c : γ), Eq.{succ u5} ε (f (g a b) c) (f' a (g' b c))) -> (Eq.{succ u5} (Finset.{u5} ε) (Finset.image₂.{u4, u6, u5} δ γ ε (fun (a : ε) (b : ε) => _inst_7 a b) f (Finset.image₂.{u3, u2, u4} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) g s t) u) (Finset.image₂.{u3, u1, u5} α ε' ε (fun (a : ε) (b : ε) => _inst_7 a b) f' s (Finset.image₂.{u2, u6, u1} β γ ε' (fun (a : ε') (b : ε') => _inst_8 a b) g' t u)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_assoc Finset.image₂_assocₓ'. -/\ntheorem image₂_assoc {γ : Type _} {u : Finset γ} {f : δ → γ → ε} {g : α → β → δ} {f' : α → ε' → ε}\n    {g' : β → γ → ε'} (h_assoc : ∀ a b c, f (g a b) c = f' a (g' b c)) :\n    image₂ f (image₂ g s t) u = image₂ f' s (image₂ g' t u) :=\n  coe_injective <| by\n    push_cast\n    exact image2_assoc h_assoc\n#align finset.image₂_assoc Finset.image₂_assoc\n\n/- warning: finset.image₂_comm -> Finset.image₂_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {g : β -> α -> γ}, (forall (a : α) (b : β), Eq.{succ u3} γ (f a b) (g b a)) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u2, u1, u3} β α γ (fun (a : γ) (b : γ) => _inst_3 a b) g t s))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} {γ : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} γ] {f : α -> β -> γ} {s : Finset.{u2} α} {t : Finset.{u1} β} {g : β -> α -> γ}, (forall (a : α) (b : β), Eq.{succ u3} γ (f a b) (g b a)) -> (Eq.{succ u3} (Finset.{u3} γ) (Finset.image₂.{u2, u1, u3} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t) (Finset.image₂.{u1, u2, u3} β α γ (fun (a : γ) (b : γ) => _inst_3 a b) g t s))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_comm Finset.image₂_commₓ'. -/\ntheorem image₂_comm {g : β → α → γ} (h_comm : ∀ a b, f a b = g b a) : image₂ f s t = image₂ g t s :=\n  (image₂_swap _ _ _).trans <| by simp_rw [h_comm]\n#align finset.image₂_comm Finset.image₂_comm\n\n/- warning: finset.image₂_left_comm -> Finset.image₂_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {δ : Type.{u3}} {δ' : Type.{u4}} {ε : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} δ] [_inst_6 : DecidableEq.{succ u4} δ'] [_inst_7 : DecidableEq.{succ u5} ε] {s : Finset.{u1} α} {t : Finset.{u2} β} {γ : Type.{u6}} {u : Finset.{u6} γ} {f : α -> δ -> ε} {g : β -> γ -> δ} {f' : α -> γ -> δ'} {g' : β -> δ' -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u5} ε (f a (g b c)) (g' b (f' a c))) -> (Eq.{succ u5} (Finset.{u5} ε) (Finset.image₂.{u1, u3, u5} α δ ε (fun (a : ε) (b : ε) => _inst_7 a b) f s (Finset.image₂.{u2, u6, u3} β γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g t u)) (Finset.image₂.{u2, u4, u5} β δ' ε (fun (a : ε) (b : ε) => _inst_7 a b) g' t (Finset.image₂.{u1, u6, u4} α γ δ' (fun (a : δ') (b : δ') => _inst_6 a b) f' s u)))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u2}} {δ : Type.{u3}} {δ' : Type.{u1}} {ε : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} δ] [_inst_6 : DecidableEq.{succ u1} δ'] [_inst_7 : DecidableEq.{succ u5} ε] {s : Finset.{u4} α} {t : Finset.{u2} β} {γ : Type.{u6}} {u : Finset.{u6} γ} {f : α -> δ -> ε} {g : β -> γ -> δ} {f' : α -> γ -> δ'} {g' : β -> δ' -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u5} ε (f a (g b c)) (g' b (f' a c))) -> (Eq.{succ u5} (Finset.{u5} ε) (Finset.image₂.{u4, u3, u5} α δ ε (fun (a : ε) (b : ε) => _inst_7 a b) f s (Finset.image₂.{u2, u6, u3} β γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g t u)) (Finset.image₂.{u2, u1, u5} β δ' ε (fun (a : ε) (b : ε) => _inst_7 a b) g' t (Finset.image₂.{u4, u6, u1} α γ δ' (fun (a : δ') (b : δ') => _inst_6 a b) f' s u)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_left_comm Finset.image₂_left_commₓ'. -/\ntheorem image₂_left_comm {γ : Type _} {u : Finset γ} {f : α → δ → ε} {g : β → γ → δ}\n    {f' : α → γ → δ'} {g' : β → δ' → ε} (h_left_comm : ∀ a b c, f a (g b c) = g' b (f' a c)) :\n    image₂ f s (image₂ g t u) = image₂ g' t (image₂ f' s u) :=\n  coe_injective <| by\n    push_cast\n    exact image2_left_comm h_left_comm\n#align finset.image₂_left_comm Finset.image₂_left_comm\n\n/- warning: finset.image₂_right_comm -> Finset.image₂_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {δ : Type.{u3}} {δ' : Type.{u4}} {ε : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} δ] [_inst_6 : DecidableEq.{succ u4} δ'] [_inst_7 : DecidableEq.{succ u5} ε] {s : Finset.{u1} α} {t : Finset.{u2} β} {γ : Type.{u6}} {u : Finset.{u6} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f' : α -> γ -> δ'} {g' : δ' -> β -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u5} ε (f (g a b) c) (g' (f' a c) b)) -> (Eq.{succ u5} (Finset.{u5} ε) (Finset.image₂.{u3, u6, u5} δ γ ε (fun (a : ε) (b : ε) => _inst_7 a b) f (Finset.image₂.{u1, u2, u3} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) g s t) u) (Finset.image₂.{u4, u2, u5} δ' β ε (fun (a : ε) (b : ε) => _inst_7 a b) g' (Finset.image₂.{u1, u6, u4} α γ δ' (fun (a : δ') (b : δ') => _inst_6 a b) f' s u) t))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {δ : Type.{u4}} {δ' : Type.{u1}} {ε : Type.{u5}} [_inst_5 : DecidableEq.{succ u4} δ] [_inst_6 : DecidableEq.{succ u1} δ'] [_inst_7 : DecidableEq.{succ u5} ε] {s : Finset.{u3} α} {t : Finset.{u2} β} {γ : Type.{u6}} {u : Finset.{u6} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f' : α -> γ -> δ'} {g' : δ' -> β -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u5} ε (f (g a b) c) (g' (f' a c) b)) -> (Eq.{succ u5} (Finset.{u5} ε) (Finset.image₂.{u4, u6, u5} δ γ ε (fun (a : ε) (b : ε) => _inst_7 a b) f (Finset.image₂.{u3, u2, u4} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) g s t) u) (Finset.image₂.{u1, u2, u5} δ' β ε (fun (a : ε) (b : ε) => _inst_7 a b) g' (Finset.image₂.{u3, u6, u1} α γ δ' (fun (a : δ') (b : δ') => _inst_6 a b) f' s u) t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_right_comm Finset.image₂_right_commₓ'. -/\ntheorem image₂_right_comm {γ : Type _} {u : Finset γ} {f : δ → γ → ε} {g : α → β → δ}\n    {f' : α → γ → δ'} {g' : δ' → β → ε} (h_right_comm : ∀ a b c, f (g a b) c = g' (f' a c) b) :\n    image₂ f (image₂ g s t) u = image₂ g' (image₂ f' s u) t :=\n  coe_injective <| by\n    push_cast\n    exact image2_right_comm h_right_comm\n#align finset.image₂_right_comm Finset.image₂_right_comm\n\n/- warning: finset.image₂_image₂_image₂_comm -> Finset.image₂_image₂_image₂_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {ε : Type.{u3}} {ε' : Type.{u4}} {ζ : Type.{u5}} {ζ' : Type.{u6}} {ν : Type.{u7}} [_inst_7 : DecidableEq.{succ u3} ε] [_inst_8 : DecidableEq.{succ u4} ε'] {s : Finset.{u1} α} {t : Finset.{u2} β} {γ : Type.{u8}} {δ : Type.{u9}} {u : Finset.{u8} γ} {v : Finset.{u9} δ} [_inst_9 : DecidableEq.{succ u5} ζ] [_inst_10 : DecidableEq.{succ u6} ζ'] [_inst_11 : DecidableEq.{succ u7} ν] {f : ε -> ζ -> ν} {g : α -> β -> ε} {h : γ -> δ -> ζ} {f' : ε' -> ζ' -> ν} {g' : α -> γ -> ε'} {h' : β -> δ -> ζ'}, (forall (a : α) (b : β) (c : γ) (d : δ), Eq.{succ u7} ν (f (g a b) (h c d)) (f' (g' a c) (h' b d))) -> (Eq.{succ u7} (Finset.{u7} ν) (Finset.image₂.{u3, u5, u7} ε ζ ν (fun (a : ν) (b : ν) => _inst_11 a b) f (Finset.image₂.{u1, u2, u3} α β ε (fun (a : ε) (b : ε) => _inst_7 a b) g s t) (Finset.image₂.{u8, u9, u5} γ δ ζ (fun (a : ζ) (b : ζ) => _inst_9 a b) h u v)) (Finset.image₂.{u4, u6, u7} ε' ζ' ν (fun (a : ν) (b : ν) => _inst_11 a b) f' (Finset.image₂.{u1, u8, u4} α γ ε' (fun (a : ε') (b : ε') => _inst_8 a b) g' s u) (Finset.image₂.{u2, u9, u6} β δ ζ' (fun (a : ζ') (b : ζ') => _inst_10 a b) h' t v)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {ε : Type.{u4}} {ε' : Type.{u1}} {ζ : Type.{u7}} {ζ' : Type.{u6}} {ν : Type.{u5}} [_inst_7 : DecidableEq.{succ u4} ε] [_inst_8 : DecidableEq.{succ u1} ε'] {s : Finset.{u3} α} {t : Finset.{u2} β} {γ : Type.{u9}} {δ : Type.{u8}} {u : Finset.{u9} γ} {v : Finset.{u8} δ} [_inst_9 : DecidableEq.{succ u7} ζ] [_inst_10 : DecidableEq.{succ u6} ζ'] [_inst_11 : DecidableEq.{succ u5} ν] {f : ε -> ζ -> ν} {g : α -> β -> ε} {h : γ -> δ -> ζ} {f' : ε' -> ζ' -> ν} {g' : α -> γ -> ε'} {h' : β -> δ -> ζ'}, (forall (a : α) (b : β) (c : γ) (d : δ), Eq.{succ u5} ν (f (g a b) (h c d)) (f' (g' a c) (h' b d))) -> (Eq.{succ u5} (Finset.{u5} ν) (Finset.image₂.{u4, u7, u5} ε ζ ν (fun (a : ν) (b : ν) => _inst_11 a b) f (Finset.image₂.{u3, u2, u4} α β ε (fun (a : ε) (b : ε) => _inst_7 a b) g s t) (Finset.image₂.{u9, u8, u7} γ δ ζ (fun (a : ζ) (b : ζ) => _inst_9 a b) h u v)) (Finset.image₂.{u1, u6, u5} ε' ζ' ν (fun (a : ν) (b : ν) => _inst_11 a b) f' (Finset.image₂.{u3, u9, u1} α γ ε' (fun (a : ε') (b : ε') => _inst_8 a b) g' s u) (Finset.image₂.{u2, u8, u6} β δ ζ' (fun (a : ζ') (b : ζ') => _inst_10 a b) h' t v)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_image₂_image₂_comm Finset.image₂_image₂_image₂_commₓ'. -/\ntheorem image₂_image₂_image₂_comm {γ δ : Type _} {u : Finset γ} {v : Finset δ} [DecidableEq ζ]\n    [DecidableEq ζ'] [DecidableEq ν] {f : ε → ζ → ν} {g : α → β → ε} {h : γ → δ → ζ}\n    {f' : ε' → ζ' → ν} {g' : α → γ → ε'} {h' : β → δ → ζ'}\n    (h_comm : ∀ a b c d, f (g a b) (h c d) = f' (g' a c) (h' b d)) :\n    image₂ f (image₂ g s t) (image₂ h u v) = image₂ f' (image₂ g' s u) (image₂ h' t v) :=\n  coe_injective <| by\n    push_cast\n    exact image2_image2_image2_comm h_comm\n#align finset.image₂_image₂_image₂_comm Finset.image₂_image₂_image₂_comm\n\n/- warning: finset.image_image₂_distrib -> Finset.image_image₂_distrib is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {β' : Type.{u4}} {γ : Type.{u5}} {δ : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_2 : DecidableEq.{succ u4} β'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u6} δ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {g : γ -> δ} {f' : α' -> β' -> δ} {g₁ : α -> α'} {g₂ : β -> β'}, (forall (a : α) (b : β), Eq.{succ u6} δ (g (f a b)) (f' (g₁ a) (g₂ b))) -> (Eq.{succ u6} (Finset.{u6} δ) (Finset.image.{u5, u6} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u1, u3, u5} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u2, u4, u6} α' β' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u1, u2} α α' (fun (a : α') (b : α') => _inst_1 a b) g₁ s) (Finset.image.{u3, u4} β β' (fun (a : β') (b : β') => _inst_2 a b) g₂ t)))\nbut is expected to have type\n  forall {α : Type.{u4}} {α' : Type.{u2}} {β : Type.{u3}} {β' : Type.{u1}} {γ : Type.{u5}} {δ : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_2 : DecidableEq.{succ u1} β'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u6} δ] {f : α -> β -> γ} {s : Finset.{u4} α} {t : Finset.{u3} β} {g : γ -> δ} {f' : α' -> β' -> δ} {g₁ : α -> α'} {g₂ : β -> β'}, (forall (a : α) (b : β), Eq.{succ u6} δ (g (f a b)) (f' (g₁ a) (g₂ b))) -> (Eq.{succ u6} (Finset.{u6} δ) (Finset.image.{u5, u6} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u4, u3, u5} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u2, u1, u6} α' β' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u4, u2} α α' (fun (a : α') (b : α') => _inst_1 a b) g₁ s) (Finset.image.{u3, u1} β β' (fun (a : β') (b : β') => _inst_2 a b) g₂ t)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_distrib Finset.image_image₂_distribₓ'. -/\ntheorem image_image₂_distrib {g : γ → δ} {f' : α' → β' → δ} {g₁ : α → α'} {g₂ : β → β'}\n    (h_distrib : ∀ a b, g (f a b) = f' (g₁ a) (g₂ b)) :\n    (image₂ f s t).image g = image₂ f' (s.image g₁) (t.image g₂) :=\n  coe_injective <| by\n    push_cast\n    exact image_image2_distrib h_distrib\n#align finset.image_image₂_distrib Finset.image_image₂_distrib\n\n/- warning: finset.image_image₂_distrib_left -> Finset.image_image₂_distrib_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {g : γ -> δ} {f' : α' -> β -> δ} {g' : α -> α'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' (g' a) b)) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u1, u3, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u2, u3, u5} α' β δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u1, u2} α α' (fun (a : α') (b : α') => _inst_1 a b) g' s) t))\nbut is expected to have type\n  forall {α : Type.{u3}} {α' : Type.{u1}} {β : Type.{u2}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_1 : DecidableEq.{succ u1} α'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β} {g : γ -> δ} {f' : α' -> β -> δ} {g' : α -> α'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' (g' a) b)) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u3, u2, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u1, u2, u5} α' β δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u3, u1} α α' (fun (a : α') (b : α') => _inst_1 a b) g' s) t))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_distrib_left Finset.image_image₂_distrib_leftₓ'. -/\n/-- Symmetric statement to `finset.image₂_image_left_comm`. -/\ntheorem image_image₂_distrib_left {g : γ → δ} {f' : α' → β → δ} {g' : α → α'}\n    (h_distrib : ∀ a b, g (f a b) = f' (g' a) b) :\n    (image₂ f s t).image g = image₂ f' (s.image g') t :=\n  coe_injective <| by\n    push_cast\n    exact image_image2_distrib_left h_distrib\n#align finset.image_image₂_distrib_left Finset.image_image₂_distrib_left\n\n/- warning: finset.image_image₂_distrib_right -> Finset.image_image₂_distrib_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} β'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {g : γ -> δ} {f' : α -> β' -> δ} {g' : β -> β'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' a (g' b))) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u1, u2, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u1, u3, u5} α β' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' s (Finset.image.{u2, u3} β β' (fun (a : β') (b : β') => _inst_2 a b) g' t)))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {β' : Type.{u1}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_2 : DecidableEq.{succ u1} β'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β} {g : γ -> δ} {f' : α -> β' -> δ} {g' : β -> β'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' a (g' b))) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u3, u2, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u3, u1, u5} α β' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' s (Finset.image.{u2, u1} β β' (fun (a : β') (b : β') => _inst_2 a b) g' t)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_distrib_right Finset.image_image₂_distrib_rightₓ'. -/\n/-- Symmetric statement to `finset.image_image₂_right_comm`. -/\ntheorem image_image₂_distrib_right {g : γ → δ} {f' : α → β' → δ} {g' : β → β'}\n    (h_distrib : ∀ a b, g (f a b) = f' a (g' b)) :\n    (image₂ f s t).image g = image₂ f' s (t.image g') :=\n  coe_injective <| by\n    push_cast\n    exact image_image2_distrib_right h_distrib\n#align finset.image_image₂_distrib_right Finset.image_image₂_distrib_right\n\n/- warning: finset.image₂_image_left_comm -> Finset.image₂_image_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {s : Finset.{u1} α} {t : Finset.{u3} β} {f : α' -> β -> γ} {g : α -> α'} {f' : α -> β -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f (g a) b) (g' (f' a b))) -> (Eq.{succ u4} (Finset.{u4} γ) (Finset.image₂.{u2, u3, u4} α' β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Finset.image.{u1, u2} α α' (fun (a : α') (b : α') => _inst_1 a b) g s) t) (Finset.image.{u5, u4} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u1, u3, u5} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) f' s t)))\nbut is expected to have type\n  forall {α : Type.{u2}} {α' : Type.{u4}} {β : Type.{u3}} {γ : Type.{u5}} {δ : Type.{u1}} [_inst_1 : DecidableEq.{succ u4} α'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u1} δ] {s : Finset.{u2} α} {t : Finset.{u3} β} {f : α' -> β -> γ} {g : α -> α'} {f' : α -> β -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u5} γ (f (g a) b) (g' (f' a b))) -> (Eq.{succ u5} (Finset.{u5} γ) (Finset.image₂.{u4, u3, u5} α' β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Finset.image.{u2, u4} α α' (fun (a : α') (b : α') => _inst_1 a b) g s) t) (Finset.image.{u1, u5} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u2, u3, u1} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) f' s t)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_image_left_comm Finset.image₂_image_left_commₓ'. -/\n/-- Symmetric statement to `finset.image_image₂_distrib_left`. -/\ntheorem image₂_image_left_comm {f : α' → β → γ} {g : α → α'} {f' : α → β → δ} {g' : δ → γ}\n    (h_left_comm : ∀ a b, f (g a) b = g' (f' a b)) :\n    image₂ f (s.image g) t = (image₂ f' s t).image g' :=\n  (image_image₂_distrib_left fun a b => (h_left_comm a b).symm).symm\n#align finset.image₂_image_left_comm Finset.image₂_image_left_comm\n\n/- warning: finset.image_image₂_right_comm -> Finset.image_image₂_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} β'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {s : Finset.{u1} α} {t : Finset.{u2} β} {f : α -> β' -> γ} {g : β -> β'} {f' : α -> β -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f a (g b)) (g' (f' a b))) -> (Eq.{succ u4} (Finset.{u4} γ) (Finset.image₂.{u1, u3, u4} α β' γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Finset.image.{u2, u3} β β' (fun (a : β') (b : β') => _inst_2 a b) g t)) (Finset.image.{u5, u4} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u1, u2, u5} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) f' s t)))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u5}} {δ : Type.{u1}} [_inst_2 : DecidableEq.{succ u3} β'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u1} δ] {s : Finset.{u4} α} {t : Finset.{u2} β} {f : α -> β' -> γ} {g : β -> β'} {f' : α -> β -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u5} γ (f a (g b)) (g' (f' a b))) -> (Eq.{succ u5} (Finset.{u5} γ) (Finset.image₂.{u4, u3, u5} α β' γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Finset.image.{u2, u3} β β' (fun (a : β') (b : β') => _inst_2 a b) g t)) (Finset.image.{u1, u5} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u4, u2, u1} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) f' s t)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_right_comm Finset.image_image₂_right_commₓ'. -/\n/-- Symmetric statement to `finset.image_image₂_distrib_right`. -/\ntheorem image_image₂_right_comm {f : α → β' → γ} {g : β → β'} {f' : α → β → δ} {g' : δ → γ}\n    (h_right_comm : ∀ a b, f a (g b) = g' (f' a b)) :\n    image₂ f s (t.image g) = (image₂ f' s t).image g' :=\n  (image_image₂_distrib_right fun a b => (h_right_comm a b).symm).symm\n#align finset.image_image₂_right_comm Finset.image_image₂_right_comm\n\n/- warning: finset.image₂_distrib_subset_left -> Finset.image₂_distrib_subset_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ' : Type.{u4}} {δ : Type.{u5}} {ε : Type.{u6}} [_inst_2 : DecidableEq.{succ u3} β'] [_inst_4 : DecidableEq.{succ u4} γ'] [_inst_5 : DecidableEq.{succ u5} δ] [_inst_7 : DecidableEq.{succ u6} ε] {s : Finset.{u1} α} {t : Finset.{u2} β} {γ : Type.{u7}} {u : Finset.{u7} γ} {f : α -> δ -> ε} {g : β -> γ -> δ} {f₁ : α -> β -> β'} {f₂ : α -> γ -> γ'} {g' : β' -> γ' -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u6} ε (f a (g b c)) (g' (f₁ a b) (f₂ a c))) -> (HasSubset.Subset.{u6} (Finset.{u6} ε) (Finset.hasSubset.{u6} ε) (Finset.image₂.{u1, u5, u6} α δ ε (fun (a : ε) (b : ε) => _inst_7 a b) f s (Finset.image₂.{u2, u7, u5} β γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g t u)) (Finset.image₂.{u3, u4, u6} β' γ' ε (fun (a : ε) (b : ε) => _inst_7 a b) g' (Finset.image₂.{u1, u2, u3} α β β' (fun (a : β') (b : β') => _inst_2 a b) f₁ s t) (Finset.image₂.{u1, u7, u4} α γ γ' (fun (a : γ') (b : γ') => _inst_4 a b) f₂ s u)))\nbut is expected to have type\n  forall {α : Type.{u5}} {β : Type.{u3}} {β' : Type.{u2}} {γ' : Type.{u1}} {δ : Type.{u4}} {ε : Type.{u6}} [_inst_2 : DecidableEq.{succ u2} β'] [_inst_4 : DecidableEq.{succ u1} γ'] [_inst_5 : DecidableEq.{succ u4} δ] [_inst_7 : DecidableEq.{succ u6} ε] {s : Finset.{u5} α} {t : Finset.{u3} β} {γ : Type.{u7}} {u : Finset.{u7} γ} {f : α -> δ -> ε} {g : β -> γ -> δ} {f₁ : α -> β -> β'} {f₂ : α -> γ -> γ'} {g' : β' -> γ' -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u6} ε (f a (g b c)) (g' (f₁ a b) (f₂ a c))) -> (HasSubset.Subset.{u6} (Finset.{u6} ε) (Finset.instHasSubsetFinset.{u6} ε) (Finset.image₂.{u5, u4, u6} α δ ε (fun (a : ε) (b : ε) => _inst_7 a b) f s (Finset.image₂.{u3, u7, u4} β γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g t u)) (Finset.image₂.{u2, u1, u6} β' γ' ε (fun (a : ε) (b : ε) => _inst_7 a b) g' (Finset.image₂.{u5, u3, u2} α β β' (fun (a : β') (b : β') => _inst_2 a b) f₁ s t) (Finset.image₂.{u5, u7, u1} α γ γ' (fun (a : γ') (b : γ') => _inst_4 a b) f₂ s u)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_distrib_subset_left Finset.image₂_distrib_subset_leftₓ'. -/\n/-- The other direction does not hold because of the `s`-`s` cross terms on the RHS. -/\ntheorem image₂_distrib_subset_left {γ : Type _} {u : Finset γ} {f : α → δ → ε} {g : β → γ → δ}\n    {f₁ : α → β → β'} {f₂ : α → γ → γ'} {g' : β' → γ' → ε}\n    (h_distrib : ∀ a b c, f a (g b c) = g' (f₁ a b) (f₂ a c)) :\n    image₂ f s (image₂ g t u) ⊆ image₂ g' (image₂ f₁ s t) (image₂ f₂ s u) :=\n  coe_subset.1 <| by\n    push_cast\n    exact Set.image2_distrib_subset_left h_distrib\n#align finset.image₂_distrib_subset_left Finset.image₂_distrib_subset_left\n\n/- warning: finset.image₂_distrib_subset_right -> Finset.image₂_distrib_subset_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {β' : Type.{u4}} {δ : Type.{u5}} {ε : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_2 : DecidableEq.{succ u4} β'] [_inst_5 : DecidableEq.{succ u5} δ] [_inst_7 : DecidableEq.{succ u6} ε] {s : Finset.{u1} α} {t : Finset.{u3} β} {γ : Type.{u7}} {u : Finset.{u7} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f₁ : α -> γ -> α'} {f₂ : β -> γ -> β'} {g' : α' -> β' -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u6} ε (f (g a b) c) (g' (f₁ a c) (f₂ b c))) -> (HasSubset.Subset.{u6} (Finset.{u6} ε) (Finset.hasSubset.{u6} ε) (Finset.image₂.{u5, u7, u6} δ γ ε (fun (a : ε) (b : ε) => _inst_7 a b) f (Finset.image₂.{u1, u3, u5} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) g s t) u) (Finset.image₂.{u2, u4, u6} α' β' ε (fun (a : ε) (b : ε) => _inst_7 a b) g' (Finset.image₂.{u1, u7, u2} α γ α' (fun (a : α') (b : α') => _inst_1 a b) f₁ s u) (Finset.image₂.{u3, u7, u4} β γ β' (fun (a : β') (b : β') => _inst_2 a b) f₂ t u)))\nbut is expected to have type\n  forall {α : Type.{u4}} {α' : Type.{u2}} {β : Type.{u3}} {β' : Type.{u1}} {δ : Type.{u5}} {ε : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_2 : DecidableEq.{succ u1} β'] [_inst_5 : DecidableEq.{succ u5} δ] [_inst_7 : DecidableEq.{succ u6} ε] {s : Finset.{u4} α} {t : Finset.{u3} β} {γ : Type.{u7}} {u : Finset.{u7} γ} {f : δ -> γ -> ε} {g : α -> β -> δ} {f₁ : α -> γ -> α'} {f₂ : β -> γ -> β'} {g' : α' -> β' -> ε}, (forall (a : α) (b : β) (c : γ), Eq.{succ u6} ε (f (g a b) c) (g' (f₁ a c) (f₂ b c))) -> (HasSubset.Subset.{u6} (Finset.{u6} ε) (Finset.instHasSubsetFinset.{u6} ε) (Finset.image₂.{u5, u7, u6} δ γ ε (fun (a : ε) (b : ε) => _inst_7 a b) f (Finset.image₂.{u4, u3, u5} α β δ (fun (a : δ) (b : δ) => _inst_5 a b) g s t) u) (Finset.image₂.{u2, u1, u6} α' β' ε (fun (a : ε) (b : ε) => _inst_7 a b) g' (Finset.image₂.{u4, u7, u2} α γ α' (fun (a : α') (b : α') => _inst_1 a b) f₁ s u) (Finset.image₂.{u3, u7, u1} β γ β' (fun (a : β') (b : β') => _inst_2 a b) f₂ t u)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_distrib_subset_right Finset.image₂_distrib_subset_rightₓ'. -/\n/-- The other direction does not hold because of the `u`-`u` cross terms on the RHS. -/\ntheorem image₂_distrib_subset_right {γ : Type _} {u : Finset γ} {f : δ → γ → ε} {g : α → β → δ}\n    {f₁ : α → γ → α'} {f₂ : β → γ → β'} {g' : α' → β' → ε}\n    (h_distrib : ∀ a b c, f (g a b) c = g' (f₁ a c) (f₂ b c)) :\n    image₂ f (image₂ g s t) u ⊆ image₂ g' (image₂ f₁ s u) (image₂ f₂ t u) :=\n  coe_subset.1 <| by\n    push_cast\n    exact Set.image2_distrib_subset_right h_distrib\n#align finset.image₂_distrib_subset_right Finset.image₂_distrib_subset_right\n\n/- warning: finset.image_image₂_antidistrib -> Finset.image_image₂_antidistrib is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {β' : Type.{u4}} {γ : Type.{u5}} {δ : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_2 : DecidableEq.{succ u4} β'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u6} δ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {g : γ -> δ} {f' : β' -> α' -> δ} {g₁ : β -> β'} {g₂ : α -> α'}, (forall (a : α) (b : β), Eq.{succ u6} δ (g (f a b)) (f' (g₁ b) (g₂ a))) -> (Eq.{succ u6} (Finset.{u6} δ) (Finset.image.{u5, u6} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u1, u3, u5} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u4, u2, u6} β' α' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u3, u4} β β' (fun (a : β') (b : β') => _inst_2 a b) g₁ t) (Finset.image.{u1, u2} α α' (fun (a : α') (b : α') => _inst_1 a b) g₂ s)))\nbut is expected to have type\n  forall {α : Type.{u4}} {α' : Type.{u1}} {β : Type.{u3}} {β' : Type.{u2}} {γ : Type.{u5}} {δ : Type.{u6}} [_inst_1 : DecidableEq.{succ u1} α'] [_inst_2 : DecidableEq.{succ u2} β'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u6} δ] {f : α -> β -> γ} {s : Finset.{u4} α} {t : Finset.{u3} β} {g : γ -> δ} {f' : β' -> α' -> δ} {g₁ : β -> β'} {g₂ : α -> α'}, (forall (a : α) (b : β), Eq.{succ u6} δ (g (f a b)) (f' (g₁ b) (g₂ a))) -> (Eq.{succ u6} (Finset.{u6} δ) (Finset.image.{u5, u6} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u4, u3, u5} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u2, u1, u6} β' α' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u3, u2} β β' (fun (a : β') (b : β') => _inst_2 a b) g₁ t) (Finset.image.{u4, u1} α α' (fun (a : α') (b : α') => _inst_1 a b) g₂ s)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_antidistrib Finset.image_image₂_antidistribₓ'. -/\ntheorem image_image₂_antidistrib {g : γ → δ} {f' : β' → α' → δ} {g₁ : β → β'} {g₂ : α → α'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' (g₁ b) (g₂ a)) :\n    (image₂ f s t).image g = image₂ f' (t.image g₁) (s.image g₂) :=\n  by\n  rw [image₂_swap f]\n  exact image_image₂_distrib fun _ _ => h_antidistrib _ _\n#align finset.image_image₂_antidistrib Finset.image_image₂_antidistrib\n\n/- warning: finset.image_image₂_antidistrib_left -> Finset.image_image₂_antidistrib_left is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} β'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u2} β} {g : γ -> δ} {f' : β' -> α -> δ} {g' : β -> β'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' (g' b) a)) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u1, u2, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u3, u1, u5} β' α δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u2, u3} β β' (fun (a : β') (b : β') => _inst_2 a b) g' t) s))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {β' : Type.{u1}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_2 : DecidableEq.{succ u1} β'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β} {g : γ -> δ} {f' : β' -> α -> δ} {g' : β -> β'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' (g' b) a)) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u3, u2, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u1, u3, u5} β' α δ (fun (a : δ) (b : δ) => _inst_5 a b) f' (Finset.image.{u2, u1} β β' (fun (a : β') (b : β') => _inst_2 a b) g' t) s))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_antidistrib_left Finset.image_image₂_antidistrib_leftₓ'. -/\n/-- Symmetric statement to `finset.image₂_image_left_anticomm`. -/\ntheorem image_image₂_antidistrib_left {g : γ → δ} {f' : β' → α → δ} {g' : β → β'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' (g' b) a) :\n    (image₂ f s t).image g = image₂ f' (t.image g') s :=\n  coe_injective <| by\n    push_cast\n    exact image_image2_antidistrib_left h_antidistrib\n#align finset.image_image₂_antidistrib_left Finset.image_image₂_antidistrib_left\n\n/- warning: finset.image_image₂_antidistrib_right -> Finset.image_image₂_antidistrib_right is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u1} α} {t : Finset.{u3} β} {g : γ -> δ} {f' : β -> α' -> δ} {g' : α -> α'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' b (g' a))) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u1, u3, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u3, u2, u5} β α' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' t (Finset.image.{u1, u2} α α' (fun (a : α') (b : α') => _inst_1 a b) g' s)))\nbut is expected to have type\n  forall {α : Type.{u3}} {α' : Type.{u1}} {β : Type.{u2}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_1 : DecidableEq.{succ u1} α'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {f : α -> β -> γ} {s : Finset.{u3} α} {t : Finset.{u2} β} {g : γ -> δ} {f' : β -> α' -> δ} {g' : α -> α'}, (forall (a : α) (b : β), Eq.{succ u5} δ (g (f a b)) (f' b (g' a))) -> (Eq.{succ u5} (Finset.{u5} δ) (Finset.image.{u4, u5} γ δ (fun (a : δ) (b : δ) => _inst_5 a b) g (Finset.image₂.{u3, u2, u4} α β γ (fun (a : γ) (b : γ) => _inst_3 a b) f s t)) (Finset.image₂.{u2, u1, u5} β α' δ (fun (a : δ) (b : δ) => _inst_5 a b) f' t (Finset.image.{u3, u1} α α' (fun (a : α') (b : α') => _inst_1 a b) g' s)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_antidistrib_right Finset.image_image₂_antidistrib_rightₓ'. -/\n/-- Symmetric statement to `finset.image_image₂_right_anticomm`. -/\ntheorem image_image₂_antidistrib_right {g : γ → δ} {f' : β → α' → δ} {g' : α → α'}\n    (h_antidistrib : ∀ a b, g (f a b) = f' b (g' a)) :\n    (image₂ f s t).image g = image₂ f' t (s.image g') :=\n  coe_injective <| by\n    push_cast\n    exact image_image2_antidistrib_right h_antidistrib\n#align finset.image_image₂_antidistrib_right Finset.image_image₂_antidistrib_right\n\n/- warning: finset.image₂_image_left_anticomm -> Finset.image₂_image_left_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {α' : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} α'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {s : Finset.{u1} α} {t : Finset.{u3} β} {f : α' -> β -> γ} {g : α -> α'} {f' : β -> α -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f (g a) b) (g' (f' b a))) -> (Eq.{succ u4} (Finset.{u4} γ) (Finset.image₂.{u2, u3, u4} α' β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Finset.image.{u1, u2} α α' (fun (a : α') (b : α') => _inst_1 a b) g s) t) (Finset.image.{u5, u4} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u3, u1, u5} β α δ (fun (a : δ) (b : δ) => _inst_5 a b) f' t s)))\nbut is expected to have type\n  forall {α : Type.{u2}} {α' : Type.{u4}} {β : Type.{u3}} {γ : Type.{u5}} {δ : Type.{u1}} [_inst_1 : DecidableEq.{succ u4} α'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u1} δ] {s : Finset.{u2} α} {t : Finset.{u3} β} {f : α' -> β -> γ} {g : α -> α'} {f' : β -> α -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u5} γ (f (g a) b) (g' (f' b a))) -> (Eq.{succ u5} (Finset.{u5} γ) (Finset.image₂.{u4, u3, u5} α' β γ (fun (a : γ) (b : γ) => _inst_3 a b) f (Finset.image.{u2, u4} α α' (fun (a : α') (b : α') => _inst_1 a b) g s) t) (Finset.image.{u1, u5} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u3, u2, u1} β α δ (fun (a : δ) (b : δ) => _inst_5 a b) f' t s)))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_image_left_anticomm Finset.image₂_image_left_anticommₓ'. -/\n/-- Symmetric statement to `finset.image_image₂_antidistrib_left`. -/\ntheorem image₂_image_left_anticomm {f : α' → β → γ} {g : α → α'} {f' : β → α → δ} {g' : δ → γ}\n    (h_left_anticomm : ∀ a b, f (g a) b = g' (f' b a)) :\n    image₂ f (s.image g) t = (image₂ f' t s).image g' :=\n  (image_image₂_antidistrib_left fun a b => (h_left_anticomm b a).symm).symm\n#align finset.image₂_image_left_anticomm Finset.image₂_image_left_anticomm\n\n/- warning: finset.image_image₂_right_anticomm -> Finset.image_image₂_right_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} β'] [_inst_3 : DecidableEq.{succ u4} γ] [_inst_5 : DecidableEq.{succ u5} δ] {s : Finset.{u1} α} {t : Finset.{u2} β} {f : α -> β' -> γ} {g : β -> β'} {f' : β -> α -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u4} γ (f a (g b)) (g' (f' b a))) -> (Eq.{succ u4} (Finset.{u4} γ) (Finset.image₂.{u1, u3, u4} α β' γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Finset.image.{u2, u3} β β' (fun (a : β') (b : β') => _inst_2 a b) g t)) (Finset.image.{u5, u4} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u2, u1, u5} β α δ (fun (a : δ) (b : δ) => _inst_5 a b) f' t s)))\nbut is expected to have type\n  forall {α : Type.{u4}} {β : Type.{u2}} {β' : Type.{u3}} {γ : Type.{u5}} {δ : Type.{u1}} [_inst_2 : DecidableEq.{succ u3} β'] [_inst_3 : DecidableEq.{succ u5} γ] [_inst_5 : DecidableEq.{succ u1} δ] {s : Finset.{u4} α} {t : Finset.{u2} β} {f : α -> β' -> γ} {g : β -> β'} {f' : β -> α -> δ} {g' : δ -> γ}, (forall (a : α) (b : β), Eq.{succ u5} γ (f a (g b)) (g' (f' b a))) -> (Eq.{succ u5} (Finset.{u5} γ) (Finset.image₂.{u4, u3, u5} α β' γ (fun (a : γ) (b : γ) => _inst_3 a b) f s (Finset.image.{u2, u3} β β' (fun (a : β') (b : β') => _inst_2 a b) g t)) (Finset.image.{u1, u5} δ γ (fun (a : γ) (b : γ) => _inst_3 a b) g' (Finset.image₂.{u2, u4, u1} β α δ (fun (a : δ) (b : δ) => _inst_5 a b) f' t s)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image₂_right_anticomm Finset.image_image₂_right_anticommₓ'. -/\n/-- Symmetric statement to `finset.image_image₂_antidistrib_right`. -/\ntheorem image_image₂_right_anticomm {f : α → β' → γ} {g : β → β'} {f' : β → α → δ} {g' : δ → γ}\n    (h_right_anticomm : ∀ a b, f a (g b) = g' (f' b a)) :\n    image₂ f s (t.image g) = (image₂ f' t s).image g' :=\n  (image_image₂_antidistrib_right fun a b => (h_right_anticomm b a).symm).symm\n#align finset.image_image₂_right_anticomm Finset.image_image₂_right_anticomm\n\n#print Finset.image₂_left_identity /-\n/-- If `a` is a left identity for `f : α → β → β`, then `{a}` is a left identity for\n`finset.image₂ f`. -/\ntheorem image₂_left_identity {f : α → γ → γ} {a : α} (h : ∀ b, f a b = b) (t : Finset γ) :\n    image₂ f {a} t = t :=\n  coe_injective <| by rw [coe_image₂, coe_singleton, Set.image2_left_identity h]\n#align finset.image₂_left_identity Finset.image₂_left_identity\n-/\n\n#print Finset.image₂_right_identity /-\n/-- If `b` is a right identity for `f : α → β → α`, then `{b}` is a right identity for\n`finset.image₂ f`. -/\ntheorem image₂_right_identity {f : γ → β → γ} {b : β} (h : ∀ a, f a b = a) (s : Finset γ) :\n    image₂ f s {b} = s := by rw [image₂_singleton_right, funext h, image_id']\n#align finset.image₂_right_identity Finset.image₂_right_identity\n-/\n\nvariable [DecidableEq α] [DecidableEq β]\n\n/- warning: finset.image₂_inter_union_subset -> Finset.image₂_inter_union_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_9 : DecidableEq.{succ u1} α] [_inst_10 : DecidableEq.{succ u2} β] {f : α -> α -> β} {s : Finset.{u1} α} {t : Finset.{u1} α}, (forall (a : α) (b : α), Eq.{succ u2} β (f a b) (f b a)) -> (HasSubset.Subset.{u2} (Finset.{u2} β) (Finset.hasSubset.{u2} β) (Finset.image₂.{u1, u1, u2} α α β (fun (a : β) (b : β) => _inst_10 a b) f (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s t) (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s t)) (Finset.image₂.{u1, u1, u2} α α β (fun (a : β) (b : β) => _inst_10 a b) f s t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_9 : DecidableEq.{succ u2} α] [_inst_10 : DecidableEq.{succ u1} β] {f : α -> α -> β} {s : Finset.{u2} α} {t : Finset.{u2} α}, (forall (a : α) (b : α), Eq.{succ u1} β (f a b) (f b a)) -> (HasSubset.Subset.{u1} (Finset.{u1} β) (Finset.instHasSubsetFinset.{u1} β) (Finset.image₂.{u2, u2, u1} α α β (fun (a : β) (b : β) => _inst_10 a b) f (Inter.inter.{u2} (Finset.{u2} α) (Finset.instInterFinset.{u2} α (fun (a : α) (b : α) => _inst_9 a b)) s t) (Union.union.{u2} (Finset.{u2} α) (Finset.instUnionFinset.{u2} α (fun (a : α) (b : α) => _inst_9 a b)) s t)) (Finset.image₂.{u2, u2, u1} α α β (fun (a : β) (b : β) => _inst_10 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_inter_union_subset Finset.image₂_inter_union_subsetₓ'. -/\ntheorem image₂_inter_union_subset {f : α → α → β} {s t : Finset α} (hf : ∀ a b, f a b = f b a) :\n    image₂ f (s ∩ t) (s ∪ t) ⊆ image₂ f s t :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_inter_union_subset hf\n#align finset.image₂_inter_union_subset Finset.image₂_inter_union_subset\n\n/- warning: finset.image₂_union_inter_subset -> Finset.image₂_union_inter_subset is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_9 : DecidableEq.{succ u1} α] [_inst_10 : DecidableEq.{succ u2} β] {f : α -> α -> β} {s : Finset.{u1} α} {t : Finset.{u1} α}, (forall (a : α) (b : α), Eq.{succ u2} β (f a b) (f b a)) -> (HasSubset.Subset.{u2} (Finset.{u2} β) (Finset.hasSubset.{u2} β) (Finset.image₂.{u1, u1, u2} α α β (fun (a : β) (b : β) => _inst_10 a b) f (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s t) (Inter.inter.{u1} (Finset.{u1} α) (Finset.hasInter.{u1} α (fun (a : α) (b : α) => _inst_9 a b)) s t)) (Finset.image₂.{u1, u1, u2} α α β (fun (a : β) (b : β) => _inst_10 a b) f s t))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_9 : DecidableEq.{succ u2} α] [_inst_10 : DecidableEq.{succ u1} β] {f : α -> α -> β} {s : Finset.{u2} α} {t : Finset.{u2} α}, (forall (a : α) (b : α), Eq.{succ u1} β (f a b) (f b a)) -> (HasSubset.Subset.{u1} (Finset.{u1} β) (Finset.instHasSubsetFinset.{u1} β) (Finset.image₂.{u2, u2, u1} α α β (fun (a : β) (b : β) => _inst_10 a b) f (Union.union.{u2} (Finset.{u2} α) (Finset.instUnionFinset.{u2} α (fun (a : α) (b : α) => _inst_9 a b)) s t) (Inter.inter.{u2} (Finset.{u2} α) (Finset.instInterFinset.{u2} α (fun (a : α) (b : α) => _inst_9 a b)) s t)) (Finset.image₂.{u2, u2, u1} α α β (fun (a : β) (b : β) => _inst_10 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image₂_union_inter_subset Finset.image₂_union_inter_subsetₓ'. -/\ntheorem image₂_union_inter_subset {f : α → α → β} {s t : Finset α} (hf : ∀ a b, f a b = f b a) :\n    image₂ f (s ∪ t) (s ∩ t) ⊆ image₂ f s t :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_union_inter_subset hf\n#align finset.image₂_union_inter_subset Finset.image₂_union_inter_subset\n\nend Finset\n\nnamespace Set\n\nvariable [DecidableEq γ] {s : Set α} {t : Set β}\n\n/- warning: set.to_finset_image2 -> Set.toFinset_image2 is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} γ] (f : α -> β -> γ) (s : Set.{u1} α) (t : Set.{u2} β) [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_3 : Fintype.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) t)] [_inst_4 : Fintype.{u3} (coeSort.{succ u3, succ (succ u3)} (Set.{u3} γ) Type.{u3} (Set.hasCoeToSort.{u3} γ) (Set.image2.{u1, u2, u3} α β γ f s t))], Eq.{succ u3} (Finset.{u3} γ) (Set.toFinset.{u3} γ (Set.image2.{u1, u2, u3} α β γ f s t) _inst_4) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_1 a b) f (Set.toFinset.{u1} α s _inst_2) (Set.toFinset.{u2} β t _inst_3))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} γ] (f : α -> β -> γ) (s : Set.{u3} α) (t : Set.{u2} β) [_inst_2 : Fintype.{u3} (Set.Elem.{u3} α s)] [_inst_3 : Fintype.{u2} (Set.Elem.{u2} β t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} γ (Set.image2.{u3, u2, u1} α β γ f s t))], Eq.{succ u1} (Finset.{u1} γ) (Set.toFinset.{u1} γ (Set.image2.{u3, u2, u1} α β γ f s t) _inst_4) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_1 a b) f (Set.toFinset.{u3} α s _inst_2) (Set.toFinset.{u2} β t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_image2 Set.toFinset_image2ₓ'. -/\n@[simp]\ntheorem toFinset_image2 (f : α → β → γ) (s : Set α) (t : Set β) [Fintype s] [Fintype t]\n    [Fintype (image2 f s t)] : (image2 f s t).toFinset = Finset.image₂ f s.toFinset t.toFinset :=\n  Finset.coe_injective <| by simp\n#align set.to_finset_image2 Set.toFinset_image2\n\n/- warning: set.finite.to_finset_image2 -> Set.Finite.toFinset_image2 is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} γ] {s : Set.{u1} α} {t : Set.{u2} β} (f : α -> β -> γ) (hs : Set.Finite.{u1} α s) (ht : Set.Finite.{u2} β t) (hf : optParam.{0} (Set.Finite.{u3} γ (Set.image2.{u1, u2, u3} α β γ f s t)) (Set.Finite.image2.{u1, u2, u3} α β γ s t f hs ht)), Eq.{succ u3} (Finset.{u3} γ) (Set.Finite.toFinset.{u3} γ (Set.image2.{u1, u2, u3} α β γ f s t) hf) (Finset.image₂.{u1, u2, u3} α β γ (fun (a : γ) (b : γ) => _inst_1 a b) f (Set.Finite.toFinset.{u1} α s hs) (Set.Finite.toFinset.{u2} β t ht))\nbut is expected to have type\n  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} γ] {s : Set.{u3} α} {t : Set.{u2} β} (f : α -> β -> γ) (hs : Set.Finite.{u3} α s) (ht : Set.Finite.{u2} β t) (hf : optParam.{0} (Set.Finite.{u1} γ (Set.image2.{u3, u2, u1} α β γ f s t)) (Set.Finite.image2.{u3, u2, u1} α β γ f s t hs ht)), Eq.{succ u1} (Finset.{u1} γ) (Set.Finite.toFinset.{u1} γ (Set.image2.{u3, u2, u1} α β γ f s t) hf) (Finset.image₂.{u3, u2, u1} α β γ (fun (a : γ) (b : γ) => _inst_1 a b) f (Set.Finite.toFinset.{u3} α s hs) (Set.Finite.toFinset.{u2} β t ht))\nCase conversion may be inaccurate. Consider using '#align set.finite.to_finset_image2 Set.Finite.toFinset_image2ₓ'. -/\ntheorem Finite.toFinset_image2 (f : α → β → γ) (hs : s.Finite) (ht : t.Finite)\n    (hf := hs.image2 f ht) : hf.toFinset = Finset.image₂ f hs.toFinset ht.toFinset :=\n  Finset.coe_injective <| by simp\n#align set.finite.to_finset_image2 Set.Finite.toFinset_image2\n\nend Set\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Finset/NAry.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.45360757920289874}}
{"text": "/-\nCopyright (c) 2019 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.basic\nimport Mathlib.control.applicative\nimport Mathlib.control.traversable.basic\nimport Mathlib.PostPort\n\nuniverses u l v u_1 \n\nnamespace Mathlib\n\n/-!\n# Free constructions\n\n## Main definitions\n\n* `free_magma α`: free magma (structure with binary operation without any axioms) over alphabet `α`,\n  defined inductively, with traversable instance and decidable equality.\n* `magma.free_semigroup α`: free semigroup over magma `α`.\n* `free_semigroup α`: free semigroup over alphabet `α`, defined as a synonym for `α × list α`\n  (i.e. nonempty lists), with traversable instance and decidable equality.\n* `free_semigroup_free_magma α`: isomorphism between `magma.free_semigroup (free_magma α)` and\n  `free_semigroup α`.\n-/\n\n/-- Free magma over a given alphabet. -/\ninductive free_magma (α : Type u) where\n| of : α → free_magma α\n| mul : free_magma α → free_magma α → free_magma α\n\n/-- Free nonabelian additive magma over a given alphabet. -/\ninductive free_add_magma (α : Type u) where\n| of : α → free_add_magma α\n| add : free_add_magma α → free_add_magma α → free_add_magma α\n\nnamespace free_magma\n\n\nprotected instance Mathlib.free_add_magma.inhabited {α : Type u} [Inhabited α] :\n    Inhabited (free_add_magma α) :=\n  { default := free_add_magma.of Inhabited.default }\n\nprotected instance Mathlib.free_add_magma.has_add {α : Type u} : Add (free_add_magma α) :=\n  { add := free_add_magma.add }\n\n@[simp] theorem Mathlib.free_add_magma.add_eq {α : Type u} (x : free_add_magma α)\n    (y : free_add_magma α) : free_add_magma.add x y = x + y :=\n  rfl\n\n/-- Recursor for `free_magma` using `x * y` instead of `free_magma.mul x y`. -/\ndef Mathlib.free_add_magma.rec_on' {α : Type u} {C : free_add_magma α → Sort l}\n    (x : free_add_magma α) (ih1 : (x : α) → C (free_add_magma.of x))\n    (ih2 : (x y : free_add_magma α) → C x → C y → C (x + y)) : C x :=\n  free_add_magma.rec_on x ih1 ih2\n\nend free_magma\n\n\n/-- Lifts a function `α → β` to a magma homomorphism `free_magma α → β` given a magma `β`. -/\ndef free_magma.lift {α : Type u} {β : Type v} [Mul β] (f : α → β) : free_magma α → β := sorry\n\n/-- Lifts a function `α → β` to an additive magma homomorphism `free_add_magma α → β` given\nan additive magma `β`. -/\ndef free_add_magma.lift {α : Type u} {β : Type v} [Add β] (f : α → β) : free_add_magma α → β :=\n  sorry\n\nnamespace free_magma\n\n\n@[simp] theorem Mathlib.free_add_magma.lift_of {α : Type u} {β : Type v} [Add β] (f : α → β)\n    (x : α) : free_add_magma.lift f (free_add_magma.of x) = f x :=\n  rfl\n\n@[simp] theorem lift_mul {α : Type u} {β : Type v} [Mul β] (f : α → β) (x : free_magma α)\n    (y : free_magma α) : lift f (x * y) = lift f x * lift f y :=\n  rfl\n\ntheorem lift_unique {α : Type u} {β : Type v} [Mul β] (f : free_magma α → β)\n    (hf : ∀ (x y : free_magma α), f (x * y) = f x * f y) : f = lift (f ∘ of) :=\n  sorry\n\nend free_magma\n\n\n/-- The unique magma homomorphism `free_magma α → free_magma β` that sends\neach `of x` to `of (f x)`. -/\ndef free_magma.map {α : Type u} {β : Type v} (f : α → β) : free_magma α → free_magma β := sorry\n\n/-- The unique additive magma homomorphism `free_add_magma α → free_add_magma β` that sends\neach `of x` to `of (f x)`. -/\ndef free_add_magma.map {α : Type u} {β : Type v} (f : α → β) :\n    free_add_magma α → free_add_magma β :=\n  sorry\n\nnamespace free_magma\n\n\n@[simp] theorem Mathlib.free_add_magma.map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :\n    free_add_magma.map f (free_add_magma.of x) = free_add_magma.of (f x) :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.map_add {α : Type u} {β : Type v} (f : α → β)\n    (x : free_add_magma α) (y : free_add_magma α) :\n    free_add_magma.map f (x + y) = free_add_magma.map f x + free_add_magma.map f y :=\n  rfl\n\nprotected instance Mathlib.free_add_magma.monad : Monad free_add_magma := sorry\n\n/-- Recursor on `free_magma` using `pure` instead of `of`. -/\nprotected def Mathlib.free_add_magma.rec_on'' {α : Type u} {C : free_add_magma α → Sort l}\n    (x : free_add_magma α) (ih1 : (x : α) → C (pure x))\n    (ih2 : (x y : free_add_magma α) → C x → C y → C (x + y)) : C x :=\n  free_add_magma.rec_on' x ih1 ih2\n\n@[simp] theorem Mathlib.free_add_magma.map_pure {α : Type u} {β : Type u} (f : α → β) (x : α) :\n    f <$> pure x = pure (f x) :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.map_add' {α : Type u} {β : Type u} (f : α → β)\n    (x : free_add_magma α) (y : free_add_magma α) : f <$> (x + y) = f <$> x + f <$> y :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.pure_bind {α : Type u} {β : Type u}\n    (f : α → free_add_magma β) (x : α) : pure x >>= f = f x :=\n  rfl\n\n@[simp] theorem mul_bind {α : Type u} {β : Type u} (f : α → free_magma β) (x : free_magma α)\n    (y : free_magma α) : x * y >>= f = (x >>= f) * (y >>= f) :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.pure_seq {α : Type u} {β : Type u} {f : α → β}\n    {x : free_add_magma α} : pure f <*> x = f <$> x :=\n  rfl\n\n@[simp] theorem mul_seq {α : Type u} {β : Type u} {f : free_magma (α → β)} {g : free_magma (α → β)}\n    {x : free_magma α} : f * g <*> x = (f <*> x) * (g <*> x) :=\n  rfl\n\nprotected instance Mathlib.free_add_magma.is_lawful_monad : is_lawful_monad free_add_magma := sorry\n\nend free_magma\n\n\n/-- `free_magma` is traversable. -/\nprotected def free_magma.traverse {m : Type u → Type u} [Applicative m] {α : Type u} {β : Type u}\n    (F : α → m β) : free_magma α → m (free_magma β) :=\n  sorry\n\n/-- `free_add_magma` is traversable. -/\nprotected def free_add_magma.traverse {m : Type u → Type u} [Applicative m] {α : Type u}\n    {β : Type u} (F : α → m β) : free_add_magma α → m (free_add_magma β) :=\n  sorry\n\nnamespace free_magma\n\n\nprotected instance Mathlib.free_add_magma.traversable : traversable free_add_magma :=\n  traversable.mk free_add_magma.traverse\n\n@[simp] theorem Mathlib.free_add_magma.traverse_pure {α : Type u} {β : Type u} {m : Type u → Type u}\n    [Applicative m] (F : α → m β) (x : α) : traverse F (pure x) = pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.traverse_pure' {α : Type u} {β : Type u}\n    {m : Type u → Type u} [Applicative m] (F : α → m β) :\n    traverse F ∘ pure = fun (x : α) => pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.traverse_add {α : Type u} {β : Type u} {m : Type u → Type u}\n    [Applicative m] (F : α → m β) (x : free_add_magma α) (y : free_add_magma α) :\n    traverse F (x + y) = Add.add <$> traverse F x <*> traverse F y :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.traverse_add' {α : Type u} {β : Type u} {m : Type u → Type u}\n    [Applicative m] (F : α → m β) :\n    function.comp (traverse F) ∘ Add.add =\n        fun (x y : free_add_magma α) => Add.add <$> traverse F x <*> traverse F y :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.traverse_eq {α : Type u} {β : Type u} {m : Type u → Type u}\n    [Applicative m] (F : α → m β) (x : free_add_magma α) :\n    free_add_magma.traverse F x = traverse F x :=\n  rfl\n\n@[simp] theorem mul_map_seq {α : Type u} (x : free_magma α) (y : free_magma α) :\n    Mul.mul <$> x <*> y = x * y :=\n  rfl\n\nprotected instance Mathlib.free_add_magma.is_lawful_traversable :\n    is_lawful_traversable free_add_magma :=\n  is_lawful_traversable.mk sorry sorry sorry sorry\n\nend free_magma\n\n\n/-- Representation of an element of a free magma. -/\nprotected def free_magma.repr {α : Type u} [has_repr α] : free_magma α → string := sorry\n\n/-- Representation of an element of a free additive magma. -/\nprotected def free_add_magma.repr {α : Type u} [has_repr α] : free_add_magma α → string := sorry\n\nprotected instance free_add_magma.has_repr {α : Type u} [has_repr α] :\n    has_repr (free_add_magma α) :=\n  has_repr.mk free_add_magma.repr\n\n/-- Length of an element of a free magma. -/\ndef free_magma.length {α : Type u} : free_magma α → ℕ := sorry\n\n/-- Length of an element of a free additive magma. -/\ndef free_add_magma.length {α : Type u} : free_add_magma α → ℕ := sorry\n\n/-- Associativity relations for a magma. -/\ninductive magma.free_semigroup.r (α : Type u) [Mul α] : α → α → Prop where\n| intro : ∀ (x y z : α), magma.free_semigroup.r α (x * y * z) (x * (y * z))\n| left : ∀ (w x y z : α), magma.free_semigroup.r α (w * (x * y * z)) (w * (x * (y * z)))\n\n/-- Associativity relations for an additive magma. -/\ninductive add_magma.free_add_semigroup.r (α : Type u) [Add α] : α → α → Prop where\n| intro : ∀ (x y z : α), add_magma.free_add_semigroup.r α (x + y + z) (x + (y + z))\n| left : ∀ (w x y z : α), add_magma.free_add_semigroup.r α (w + (x + y + z)) (w + (x + (y + z)))\n\nnamespace magma\n\n\n/-- Free semigroup over a magma. -/\ndef free_semigroup (α : Type u) [Mul α] := Quot sorry\n\nnamespace free_semigroup\n\n\n/-- Embedding from magma to its free semigroup. -/\ndef Mathlib.add_magma.free_add_semigroup.of {α : Type u} [Add α] :\n    α → add_magma.free_add_semigroup α :=\n  Quot.mk (add_magma.free_add_semigroup.r α)\n\nprotected instance Mathlib.add_magma.free_add_semigroup.inhabited {α : Type u} [Add α]\n    [Inhabited α] : Inhabited (add_magma.free_add_semigroup α) :=\n  { default := add_magma.free_add_semigroup.of Inhabited.default }\n\nprotected theorem Mathlib.add_magma.free_add_semigroup.induction_on {α : Type u} [Add α]\n    {C : add_magma.free_add_semigroup α → Prop} (x : add_magma.free_add_semigroup α)\n    (ih : ∀ (x : α), C (add_magma.free_add_semigroup.of x)) : C x :=\n  quot.induction_on x ih\n\ntheorem of_mul_assoc {α : Type u} [Mul α] (x : α) (y : α) (z : α) :\n    of (x * y * z) = of (x * (y * z)) :=\n  quot.sound (r.intro x y z)\n\ntheorem of_mul_assoc_left {α : Type u} [Mul α] (w : α) (x : α) (y : α) (z : α) :\n    of (w * (x * y * z)) = of (w * (x * (y * z))) :=\n  quot.sound (r.left w x y z)\n\ntheorem of_mul_assoc_right {α : Type u} [Mul α] (w : α) (x : α) (y : α) (z : α) :\n    of (w * x * y * z) = of (w * (x * y) * z) :=\n  sorry\n\nprotected instance semigroup {α : Type u} [Mul α] : semigroup (free_semigroup α) :=\n  semigroup.mk\n    (fun (x y : free_semigroup α) =>\n      quot.lift_on x (fun (p : α) => quot.lift_on y (fun (q : α) => Quot.mk (r α) (p * q)) sorry)\n        sorry)\n    sorry\n\ntheorem Mathlib.add_magma.free_add_semigroup.of_add {α : Type u} [Add α] (x : α) (y : α) :\n    add_magma.free_add_semigroup.of (x + y) =\n        add_magma.free_add_semigroup.of x + add_magma.free_add_semigroup.of y :=\n  rfl\n\n/-- Lifts a magma homomorphism `α → β` to a semigroup homomorphism `magma.free_semigroup α → β`\ngiven a semigroup `β`. -/\ndef lift {α : Type u} [Mul α] {β : Type v} [semigroup β] (f : α → β)\n    (hf : ∀ (x y : α), f (x * y) = f x * f y) : free_semigroup α → β :=\n  Quot.lift f sorry\n\n@[simp] theorem lift_of {α : Type u} [Mul α] {β : Type v} [semigroup β] (f : α → β)\n    {hf : ∀ (x y : α), f (x * y) = f x * f y} (x : α) : lift f hf (of x) = f x :=\n  rfl\n\n@[simp] theorem lift_mul {α : Type u} [Mul α] {β : Type v} [semigroup β] (f : α → β)\n    {hf : ∀ (x y : α), f (x * y) = f x * f y} (x : free_semigroup α) (y : free_semigroup α) :\n    lift f hf (x * y) = lift f hf x * lift f hf y :=\n  quot.induction_on x fun (p : α) => quot.induction_on y fun (q : α) => hf p q\n\ntheorem Mathlib.add_magma.free_add_semigroup.lift_unique {α : Type u} [Add α] {β : Type v}\n    [add_semigroup β] (f : add_magma.free_add_semigroup α → β)\n    (hf : ∀ (x y : add_magma.free_add_semigroup α), f (x + y) = f x + f y) :\n    f =\n        add_magma.free_add_semigroup.lift (f ∘ add_magma.free_add_semigroup.of)\n          fun (p q : α) =>\n            hf (add_magma.free_add_semigroup.of p) (add_magma.free_add_semigroup.of q) :=\n  funext fun (x : add_magma.free_add_semigroup α) => quot.induction_on x fun (p : α) => rfl\n\n/-- From a magma homomorphism `α → β` to a semigroup homomorphism\n`magma.free_semigroup α → magma.free_semigroup β`. -/\ndef Mathlib.add_magma.free_add_semigroup.map {α : Type u} [Add α] {β : Type v} [Add β] (f : α → β)\n    (hf : ∀ (x y : α), f (x + y) = f x + f y) :\n    add_magma.free_add_semigroup α → add_magma.free_add_semigroup β :=\n  add_magma.free_add_semigroup.lift (add_magma.free_add_semigroup.of ∘ f) sorry\n\n@[simp] theorem Mathlib.add_magma.free_add_semigroup.map_of {α : Type u} [Add α] {β : Type v}\n    [Add β] (f : α → β) {hf : ∀ (x y : α), f (x + y) = f x + f y} (x : α) :\n    add_magma.free_add_semigroup.map f hf (add_magma.free_add_semigroup.of x) =\n        add_magma.free_add_semigroup.of (f x) :=\n  rfl\n\n@[simp] theorem map_mul {α : Type u} [Mul α] {β : Type v} [Mul β] (f : α → β)\n    {hf : ∀ (x y : α), f (x * y) = f x * f y} (x : free_semigroup α) (y : free_semigroup α) :\n    map f hf (x * y) = map f hf x * map f hf y :=\n  lift_mul (of ∘ f) x y\n\nend free_semigroup\n\n\nend magma\n\n\n/-- Free semigroup over a given alphabet.\n(Note: In this definition, the free semigroup does not contain the empty word.) -/\ndef free_semigroup (α : Type u) := α × List α\n\nnamespace free_semigroup\n\n\nprotected instance semigroup {α : Type u} : semigroup (free_semigroup α) :=\n  semigroup.mk\n    (fun (L1 L2 : free_semigroup α) => (prod.fst L1, prod.snd L1 ++ prod.fst L2 :: prod.snd L2))\n    sorry\n\n/-- The embedding `α → free_semigroup α`. -/\ndef Mathlib.free_add_semigroup.of {α : Type u} (x : α) : free_add_semigroup α := (x, [])\n\nprotected instance Mathlib.free_add_semigroup.inhabited {α : Type u} [Inhabited α] :\n    Inhabited (free_add_semigroup α) :=\n  { default := free_add_semigroup.of Inhabited.default }\n\n/-- Recursor for free semigroup using `of` and `*`. -/\nprotected def Mathlib.free_add_semigroup.rec_on {α : Type u} {C : free_add_semigroup α → Sort l}\n    (x : free_add_semigroup α) (ih1 : (x : α) → C (free_add_semigroup.of x))\n    (ih2 :\n      (x : α) →\n        (y : free_add_semigroup α) →\n          C (free_add_semigroup.of x) → C y → C (free_add_semigroup.of x + y)) :\n    C x :=\n  prod.rec_on x\n    fun (f : α) (s : List α) =>\n      list.rec_on s ih1\n        (fun (hd : α) (tl : List α) (ih : (_a : α) → C (_a, tl)) (f : α) =>\n          ih2 f (hd, tl) (ih1 f) (ih hd))\n        f\n\nend free_semigroup\n\n\n/-- Auxiliary function for `free_semigroup.lift`. -/\ndef free_semigroup.lift' {α : Type u} {β : Type v} [semigroup β] (f : α → β) : α → List α → β :=\n  sorry\n\n/-- Auxiliary function for `free_semigroup.lift`. -/\ndef free_add_semigroup.lift' {α : Type u} {β : Type v} [add_semigroup β] (f : α → β) :\n    α → List α → β :=\n  sorry\n\nnamespace free_semigroup\n\n\n/-- Lifts a function `α → β` to a semigroup homomorphism `free_semigroup α → β` given\na semigroup `β`. -/\ndef lift {α : Type u} {β : Type v} [semigroup β] (f : α → β) (x : free_semigroup α) : β :=\n  lift' f (prod.fst x) (prod.snd x)\n\n@[simp] theorem lift_of {α : Type u} {β : Type v} [semigroup β] (f : α → β) (x : α) :\n    lift f (of x) = f x :=\n  rfl\n\ntheorem lift_of_mul {α : Type u} {β : Type v} [semigroup β] (f : α → β) (x : α)\n    (y : free_semigroup α) : lift f (of x * y) = f x * lift f y :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.lift_add {α : Type u} {β : Type v} [add_semigroup β]\n    (f : α → β) (x : free_add_semigroup α) (y : free_add_semigroup α) :\n    free_add_semigroup.lift f (x + y) = free_add_semigroup.lift f x + free_add_semigroup.lift f y :=\n  sorry\n\ntheorem Mathlib.free_add_semigroup.lift_unique {α : Type u} {β : Type v} [add_semigroup β]\n    (f : free_add_semigroup α → β) (hf : ∀ (x y : free_add_semigroup α), f (x + y) = f x + f y) :\n    f = free_add_semigroup.lift (f ∘ free_add_semigroup.of) :=\n  sorry\n\n/-- The unique semigroup homomorphism that sends `of x` to `of (f x)`. -/\ndef Mathlib.free_add_semigroup.map {α : Type u} {β : Type v} (f : α → β) :\n    free_add_semigroup α → free_add_semigroup β :=\n  free_add_semigroup.lift (free_add_semigroup.of ∘ f)\n\n@[simp] theorem Mathlib.free_add_semigroup.map_of {α : Type u} {β : Type v} (f : α → β) (x : α) :\n    free_add_semigroup.map f (free_add_semigroup.of x) = free_add_semigroup.of (f x) :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.map_add {α : Type u} {β : Type v} (f : α → β)\n    (x : free_add_semigroup α) (y : free_add_semigroup α) :\n    free_add_semigroup.map f (x + y) = free_add_semigroup.map f x + free_add_semigroup.map f y :=\n  free_add_semigroup.lift_add (free_add_semigroup.of ∘ f) x y\n\nprotected instance Mathlib.free_add_semigroup.monad : Monad free_add_semigroup := sorry\n\n/-- Recursor that uses `pure` instead of `of`. -/\ndef rec_on' {α : Type u} {C : free_semigroup α → Sort l} (x : free_semigroup α)\n    (ih1 : (x : α) → C (pure x))\n    (ih2 : (x : α) → (y : free_semigroup α) → C (pure x) → C y → C (pure x * y)) : C x :=\n  free_semigroup.rec_on x ih1 ih2\n\n@[simp] theorem map_pure {α : Type u} {β : Type u} (f : α → β) (x : α) :\n    f <$> pure x = pure (f x) :=\n  rfl\n\n@[simp] theorem map_mul' {α : Type u} {β : Type u} (f : α → β) (x : free_semigroup α)\n    (y : free_semigroup α) : f <$> (x * y) = f <$> x * f <$> y :=\n  map_mul f x y\n\n@[simp] theorem pure_bind {α : Type u} {β : Type u} (f : α → free_semigroup β) (x : α) :\n    pure x >>= f = f x :=\n  rfl\n\n@[simp] theorem mul_bind {α : Type u} {β : Type u} (f : α → free_semigroup β) (x : free_semigroup α)\n    (y : free_semigroup α) : x * y >>= f = (x >>= f) * (y >>= f) :=\n  lift_mul f x y\n\n@[simp] theorem Mathlib.free_add_semigroup.pure_seq {α : Type u} {β : Type u} {f : α → β}\n    {x : free_add_semigroup α} : pure f <*> x = f <$> x :=\n  rfl\n\n@[simp] theorem mul_seq {α : Type u} {β : Type u} {f : free_semigroup (α → β)}\n    {g : free_semigroup (α → β)} {x : free_semigroup α} : f * g <*> x = (f <*> x) * (g <*> x) :=\n  mul_bind\n    (fun (_x : α → β) =>\n      (fun (α β : Type u) (f : α → β) (x : free_semigroup α) => lift (of ∘ f) x) α β _x x)\n    f g\n\nprotected instance Mathlib.free_add_semigroup.is_lawful_monad :\n    is_lawful_monad free_add_semigroup :=\n  sorry\n\n/-- `free_semigroup` is traversable. -/\nprotected def Mathlib.free_add_semigroup.traverse {m : Type u → Type u} [Applicative m] {α : Type u}\n    {β : Type u} (F : α → m β) (x : free_add_semigroup α) : m (free_add_semigroup β) :=\n  free_add_semigroup.rec_on' x (fun (x : α) => pure <$> F x)\n    fun (x : α) (y : free_add_semigroup α) (ihx ihy : m (free_add_semigroup β)) =>\n      Add.add <$> ihx <*> ihy\n\nprotected instance Mathlib.free_add_semigroup.traversable : traversable free_add_semigroup :=\n  traversable.mk free_add_semigroup.traverse\n\n@[simp] theorem traverse_pure {α : Type u} {β : Type u} {m : Type u → Type u} [Applicative m]\n    (F : α → m β) (x : α) : traverse F (pure x) = pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.traverse_pure' {α : Type u} {β : Type u}\n    {m : Type u → Type u} [Applicative m] (F : α → m β) :\n    traverse F ∘ pure = fun (x : α) => pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.traverse_add {α : Type u} {β : Type u}\n    {m : Type u → Type u} [Applicative m] (F : α → m β) [is_lawful_applicative m]\n    (x : free_add_semigroup α) (y : free_add_semigroup α) :\n    traverse F (x + y) = Add.add <$> traverse F x <*> traverse F y :=\n  sorry\n\n@[simp] theorem Mathlib.free_add_semigroup.traverse_add' {α : Type u} {β : Type u}\n    {m : Type u → Type u} [Applicative m] (F : α → m β) [is_lawful_applicative m] :\n    function.comp (traverse F) ∘ Add.add =\n        fun (x y : free_add_semigroup α) => Add.add <$> traverse F x <*> traverse F y :=\n  funext\n    fun (x : free_add_semigroup α) =>\n      funext fun (y : free_add_semigroup α) => free_add_semigroup.traverse_add F x y\n\n@[simp] theorem Mathlib.free_add_semigroup.traverse_eq {α : Type u} {β : Type u}\n    {m : Type u → Type u} [Applicative m] (F : α → m β) (x : free_add_semigroup α) :\n    free_add_semigroup.traverse F x = traverse F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.add_map_seq {α : Type u} (x : free_add_semigroup α)\n    (y : free_add_semigroup α) : Add.add <$> x <*> y = x + y :=\n  rfl\n\nprotected instance Mathlib.free_add_semigroup.is_lawful_traversable :\n    is_lawful_traversable free_add_semigroup :=\n  is_lawful_traversable.mk sorry sorry sorry sorry\n\nprotected instance Mathlib.free_add_semigroup.decidable_eq {α : Type u} [DecidableEq α] :\n    DecidableEq (free_add_semigroup α) :=\n  prod.decidable_eq\n\nend free_semigroup\n\n\n/-- Isomorphism between `magma.free_semigroup (free_magma α)` and `free_semigroup α`. -/\ndef free_add_semigroup_free_add_magma (α : Type u) :\n    add_magma.free_add_semigroup (free_add_magma α) ≃ free_add_semigroup α :=\n  equiv.mk (add_magma.free_add_semigroup.lift (free_add_magma.lift free_add_semigroup.of) sorry)\n    (free_add_semigroup.lift (add_magma.free_add_semigroup.of ∘ free_add_magma.of)) sorry sorry\n\n@[simp] theorem free_semigroup_free_magma_mul {α : Type u} (x : magma.free_semigroup (free_magma α))\n    (y : magma.free_semigroup (free_magma α)) :\n    coe_fn (free_semigroup_free_magma α) (x * y) =\n        coe_fn (free_semigroup_free_magma α) x * coe_fn (free_semigroup_free_magma α) y :=\n  magma.free_semigroup.lift_mul (free_magma.lift free_semigroup.of) x y\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/free_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.4536075755581497}}
{"text": "/-\nCopyright (c) 2019 Amelia Livingston. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Amelia Livingston\n-/\nimport group_theory.submonoid.operations\nimport data.equiv.mul_add\nimport data.setoid.basic\nimport algebra.group.prod\n\n/-!\n# Congruence relations\n\nThis file defines congruence relations: equivalence relations that preserve a binary operation,\nwhich in this case is multiplication or addition. The principal definition is a `structure`\nextending a `setoid` (an equivalence relation), and the inductive definition of the smallest\ncongruence relation containing a binary relation is also given (see `con_gen`).\n\nThe file also proves basic properties of the quotient of a type by a congruence relation, and the\ncomplete lattice of congruence relations on a type. We then establish an order-preserving bijection\nbetween the set of congruence relations containing a congruence relation `c` and the set of\ncongruence relations on the quotient by `c`.\n\nThe second half of the file concerns congruence relations on monoids, in which case the\nquotient by the congruence relation is also a monoid. There are results about the universal\nproperty of quotients of monoids, and the isomorphism theorems for monoids.\n\n## Implementation notes\n\nThe inductive definition of a congruence relation could be a nested inductive type, defined using\nthe equivalence closure of a binary relation `eqv_gen`, but the recursor generated does not work.\nA nested inductive definition could conceivably shorten proofs, because they would allow invocation\nof the corresponding lemmas about `eqv_gen`.\n\nThe lemmas `refl`, `symm` and `trans` are not tagged with `@[refl]`, `@[symm]`, and `@[trans]`\nrespectively as these tags do not work on a structure coerced to a binary relation.\n\nThere is a coercion from elements of a type to the element's equivalence class under a\ncongruence relation.\n\nA congruence relation on a monoid `M` can be thought of as a submonoid of `M × M` for which\nmembership is an equivalence relation, but whilst this fact is established in the file, it is not\nused, since this perspective adds more layers of definitional unfolding.\n\n## Tags\n\ncongruence, congruence relation, quotient, quotient by congruence relation, monoid,\nquotient monoid, isomorphism theorems\n-/\n\nvariables (M : Type*) {N : Type*} {P : Type*}\n\nopen function setoid\n\n/-- A congruence relation on a type with an addition is an equivalence relation which\n    preserves addition. -/\nstructure add_con [has_add M] extends setoid M :=\n(add' : ∀ {w x y z}, r w x → r y z → r (w + y) (x + z))\n\n/-- A congruence relation on a type with a multiplication is an equivalence relation which\n    preserves multiplication. -/\n@[to_additive add_con] structure con [has_mul M] extends setoid M :=\n(mul' : ∀ {w x y z}, r w x → r y z → r (w * y) (x * z))\n\n/-- The equivalence relation underlying an additive congruence relation. -/\nadd_decl_doc add_con.to_setoid\n\n/-- The equivalence relation underlying a multiplicative congruence relation. -/\nadd_decl_doc con.to_setoid\n\nvariables {M}\n\n/-- The inductively defined smallest additive congruence relation containing a given binary\n    relation. -/\ninductive add_con_gen.rel [has_add M] (r : M → M → Prop) : M → M → Prop\n| of : Π x y, r x y → add_con_gen.rel x y\n| refl : Π x, add_con_gen.rel x x\n| symm : Π x y, add_con_gen.rel x y → add_con_gen.rel y x\n| trans : Π x y z, add_con_gen.rel x y → add_con_gen.rel y z → add_con_gen.rel x z\n| add : Π w x y z, add_con_gen.rel w x → add_con_gen.rel y z → add_con_gen.rel (w + y) (x + z)\n\n/-- The inductively defined smallest multiplicative congruence relation containing a given binary\n    relation. -/\n@[to_additive add_con_gen.rel]\ninductive con_gen.rel [has_mul M] (r : M → M → Prop) : M → M → Prop\n| of : Π x y, r x y → con_gen.rel x y\n| refl : Π x, con_gen.rel x x\n| symm : Π x y, con_gen.rel x y → con_gen.rel y x\n| trans : Π x y z, con_gen.rel x y → con_gen.rel y z → con_gen.rel x z\n| mul : Π w x y z, con_gen.rel w x → con_gen.rel y z → con_gen.rel (w * y) (x * z)\n\n/-- The inductively defined smallest multiplicative congruence relation containing a given binary\n    relation. -/\n@[to_additive add_con_gen \"The inductively defined smallest additive congruence relation containing\na given binary relation.\"]\ndef con_gen [has_mul M] (r : M → M → Prop) : con M :=\n⟨⟨con_gen.rel r, ⟨con_gen.rel.refl, con_gen.rel.symm, con_gen.rel.trans⟩⟩, con_gen.rel.mul⟩\n\nnamespace con\n\nsection\nvariables [has_mul M] [has_mul N] [has_mul P] (c : con M)\n\n@[to_additive]\ninstance : inhabited (con M) :=\n⟨con_gen empty_relation⟩\n\n/-- A coercion from a congruence relation to its underlying binary relation. -/\n@[to_additive \"A coercion from an additive congruence relation to its underlying binary relation.\"]\ninstance : has_coe_to_fun (con M) (λ _, M → M → Prop) := ⟨λ c, λ x y, @setoid.r _ c.to_setoid x y⟩\n\n@[simp, to_additive] lemma rel_eq_coe (c : con M) : c.r = c := rfl\n\n/-- Congruence relations are reflexive. -/\n@[to_additive \"Additive congruence relations are reflexive.\"]\nprotected lemma refl (x) : c x x := c.to_setoid.refl' x\n\n/-- Congruence relations are symmetric. -/\n@[to_additive \"Additive congruence relations are symmetric.\"]\nprotected lemma symm : ∀ {x y}, c x y → c y x := λ _ _ h, c.to_setoid.symm' h\n\n/-- Congruence relations are transitive. -/\n@[to_additive \"Additive congruence relations are transitive.\"]\nprotected lemma trans : ∀ {x y z}, c x y → c y z → c x z :=\nλ _ _ _ h, c.to_setoid.trans' h\n\n/-- Multiplicative congruence relations preserve multiplication. -/\n@[to_additive \"Additive congruence relations preserve addition.\"]\nprotected lemma mul : ∀ {w x y z}, c w x → c y z → c (w * y) (x * z) :=\nλ _ _ _ _ h1 h2, c.mul' h1 h2\n\n@[simp, to_additive] lemma rel_mk {s : setoid M} {h a b} :\n  con.mk s h a b ↔ r a b :=\niff.rfl\n\n/-- Given a type `M` with a multiplication, a congruence relation `c` on `M`, and elements of `M`\n    `x, y`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`. -/\n@[to_additive \"Given a type `M` with an addition, `x, y ∈ M`, and an additive congruence relation\n`c` on `M`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`.\"]\ninstance : has_mem (M × M) (con M) := ⟨λ x c, c x.1 x.2⟩\n\nvariables {c}\n\n/-- The map sending a congruence relation to its underlying binary relation is injective. -/\n@[to_additive \"The map sending an additive congruence relation to its underlying binary relation\nis injective.\"]\nlemma ext' {c d : con M} (H : c.r = d.r) : c = d :=\nby { rcases c with ⟨⟨⟩⟩, rcases d with ⟨⟨⟩⟩, cases H, congr, }\n\n/-- Extensionality rule for congruence relations. -/\n@[ext, to_additive \"Extensionality rule for additive congruence relations.\"]\nlemma ext {c d : con M} (H : ∀ x y, c x y ↔ d x y) : c = d :=\next' $ by ext; apply H\n\n/-- The map sending a congruence relation to its underlying equivalence relation is injective. -/\n@[to_additive \"The map sending an additive congruence relation to its underlying equivalence\nrelation is injective.\"]\nlemma to_setoid_inj {c d : con M} (H : c.to_setoid = d.to_setoid) : c = d :=\next $ ext_iff.1 H\n\n/-- Iff version of extensionality rule for congruence relations. -/\n@[to_additive \"Iff version of extensionality rule for additive congruence relations.\"]\nlemma ext_iff {c d : con M} : (∀ x y, c x y ↔ d x y) ↔ c = d :=\n⟨ext, λ h _ _, h ▸ iff.rfl⟩\n\n/-- Two congruence relations are equal iff their underlying binary relations are equal. -/\n@[to_additive \"Two additive congruence relations are equal iff their underlying binary relations\nare equal.\"]\nlemma ext'_iff {c d : con M} : c.r = d.r ↔ c = d :=\n⟨ext', λ h, h ▸ rfl⟩\n\n/-- The kernel of a multiplication-preserving function as a congruence relation. -/\n@[to_additive \"The kernel of an addition-preserving function as an additive congruence relation.\"]\ndef mul_ker (f : M → P) (h : ∀ x y, f (x * y) = f x * f y) : con M :=\n{ to_setoid := setoid.ker f,\n  mul' := λ _ _ _ _ h1 h2, by { dsimp [setoid.ker, on_fun] at *, rw [h, h1, h2, h], } }\n\n/-- Given types with multiplications `M, N`, the product of two congruence relations `c` on `M` and\n    `d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁` is related to `y₁`\n    by `c` and `x₂` is related to `y₂` by `d`. -/\n@[to_additive prod \"Given types with additions `M, N`, the product of two congruence relations\n`c` on `M` and `d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁`\nis related to `y₁` by `c` and `x₂` is related to `y₂` by `d`.\"]\nprotected def prod (c : con M) (d : con N) : con (M × N) :=\n{ mul' := λ _ _ _ _ h1 h2, ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩, ..c.to_setoid.prod d.to_setoid }\n\n/-- The product of an indexed collection of congruence relations. -/\n@[to_additive \"The product of an indexed collection of additive congruence relations.\"]\ndef pi {ι : Type*} {f : ι → Type*} [Π i, has_mul (f i)]\n  (C : Π i, con (f i)) : con (Π i, f i) :=\n{ mul' := λ _ _ _ _ h1 h2 i, (C i).mul (h1 i) (h2 i), ..@pi_setoid _ _ $ λ i, (C i).to_setoid }\n\nvariables (c)\n\n-- Quotients\n\n/-- Defining the quotient by a congruence relation of a type with a multiplication. -/\n@[to_additive \"Defining the quotient by an additive congruence relation of a type with\nan addition.\"]\nprotected def quotient := quotient $ c.to_setoid\n\n/-- Coercion from a type with a multiplication to its quotient by a congruence relation.\n\nSee Note [use has_coe_t]. -/\n@[to_additive \"Coercion from a type with an addition to its quotient by an additive congruence\nrelation\", priority 0]\ninstance : has_coe_t M c.quotient := ⟨@quotient.mk _ c.to_setoid⟩\n\n/-- The quotient by a decidable congruence relation has decidable equality. -/\n@[to_additive \"The quotient by a decidable additive congruence relation has decidable equality.\",\n  priority 500] -- Lower the priority since it unifies with any quotient type.\ninstance [d : ∀ a b, decidable (c a b)] : decidable_eq c.quotient :=\n@quotient.decidable_eq M c.to_setoid d\n\n@[simp, to_additive] lemma quot_mk_eq_coe {M : Type*} [has_mul M] (c : con M) (x : M) :\n  quot.mk c x = (x : c.quotient) :=\nrfl\n\n/-- The function on the quotient by a congruence relation `c` induced by a function that is\n    constant on `c`'s equivalence classes. -/\n@[elab_as_eliminator, to_additive \"The function on the quotient by a congruence relation `c`\ninduced by a function that is constant on `c`'s equivalence classes.\"]\nprotected def lift_on {β} {c : con M} (q : c.quotient) (f : M → β)\n  (h : ∀ a b, c a b → f a = f b) : β := quotient.lift_on' q f h\n\n/-- The binary function on the quotient by a congruence relation `c` induced by a binary function\n    that is constant on `c`'s equivalence classes. -/\n@[elab_as_eliminator, to_additive \"The binary function on the quotient by a congruence relation `c`\ninduced by a binary function that is constant on `c`'s equivalence classes.\"]\nprotected def lift_on₂ {β} {c : con M} (q r : c.quotient) (f : M → M → β)\n  (h : ∀ a₁ a₂ b₁ b₂, c a₁ b₁ → c a₂ b₂ → f a₁ a₂ = f b₁ b₂) : β := quotient.lift_on₂' q r f h\n\n/-- A version of `quotient.hrec_on₂'` for quotients by `con`. -/\n@[to_additive \"A version of `quotient.hrec_on₂'` for quotients by `add_con`.\"]\nprotected def hrec_on₂ {cM : con M} {cN : con N} {φ : cM.quotient → cN.quotient → Sort*}\n  (a : cM.quotient) (b : cN.quotient)\n  (f : Π (x : M) (y : N), φ x y) (h : ∀ x y x' y', cM x x' → cN y y' → f x y == f x' y') :\n  φ a b :=\nquotient.hrec_on₂' a b f h\n\n@[simp, to_additive] lemma hrec_on₂_coe {cM : con M} {cN : con N}\n  {φ : cM.quotient → cN.quotient → Sort*} (a : M) (b : N)\n  (f : Π (x : M) (y : N), φ x y) (h : ∀ x y x' y', cM x x' → cN y y' → f x y == f x' y') :\n  con.hrec_on₂ ↑a ↑b f h = f a b :=\nrfl\n\nvariables {c}\n\n/-- The inductive principle used to prove propositions about the elements of a quotient by a\n    congruence relation. -/\n@[elab_as_eliminator, to_additive \"The inductive principle used to prove propositions about\nthe elements of a quotient by an additive congruence relation.\"]\nprotected lemma induction_on {C : c.quotient → Prop} (q : c.quotient) (H : ∀ x : M, C x) : C q :=\nquotient.induction_on' q H\n\n/-- A version of `con.induction_on` for predicates which take two arguments. -/\n@[elab_as_eliminator, to_additive \"A version of `add_con.induction_on` for predicates which take\ntwo arguments.\"]\nprotected lemma induction_on₂ {d : con N} {C : c.quotient → d.quotient → Prop}\n  (p : c.quotient) (q : d.quotient) (H : ∀ (x : M) (y : N), C x y) : C p q :=\nquotient.induction_on₂' p q H\n\nvariables (c)\n\n/-- Two elements are related by a congruence relation `c` iff they are represented by the same\n    element of the quotient by `c`. -/\n@[simp, to_additive \"Two elements are related by an additive congruence relation `c` iff they\nare represented by the same element of the quotient by `c`.\"]\nprotected lemma eq {a b : M} : (a : c.quotient) = b ↔ c a b :=\nquotient.eq'\n\n/-- The multiplication induced on the quotient by a congruence relation on a type with a\n    multiplication. -/\n@[to_additive \"The addition induced on the quotient by an additive congruence relation on a type\nwith an addition.\"]\ninstance has_mul : has_mul c.quotient :=\n⟨λ x y, quotient.lift_on₂' x y (λ w z, ((w * z : M) : c.quotient))\n     $ λ _ _ _ _ h1 h2, c.eq.2 $ c.mul h1 h2⟩\n\n/-- The kernel of the quotient map induced by a congruence relation `c` equals `c`. -/\n@[simp, to_additive \"The kernel of the quotient map induced by an additive congruence relation\n`c` equals `c`.\"]\nlemma mul_ker_mk_eq : mul_ker (coe : M → c.quotient) (λ x y, rfl) = c :=\next $ λ x y, quotient.eq'\n\nvariables {c}\n\n/-- The coercion to the quotient of a congruence relation commutes with multiplication (by\n    definition). -/\n@[simp, to_additive \"The coercion to the quotient of an additive congruence relation commutes with\naddition (by definition).\"]\nlemma coe_mul (x y : M) : (↑(x * y) : c.quotient) = ↑x * ↑y := rfl\n\n/-- Definition of the function on the quotient by a congruence relation `c` induced by a function\n    that is constant on `c`'s equivalence classes. -/\n@[simp, to_additive \"Definition of the function on the quotient by an additive congruence\nrelation `c` induced by a function that is constant on `c`'s equivalence classes.\"]\nprotected lemma lift_on_coe {β} (c : con M) (f : M → β)\n  (h : ∀ a b, c a b → f a = f b) (x : M) :\n  con.lift_on (x : c.quotient) f h = f x := rfl\n\n/-- Makes an isomorphism of quotients by two congruence relations, given that the relations are\n    equal. -/\n@[to_additive \"Makes an additive isomorphism of quotients by two additive congruence relations,\ngiven that the relations are equal.\"]\nprotected def congr {c d : con M} (h : c = d) :  c.quotient ≃* d.quotient :=\n{ map_mul' := λ x y, by rcases x; rcases y; refl,\n  ..quotient.congr (equiv.refl M) $ by apply ext_iff.2 h }\n\n-- The complete lattice of congruence relations on a type\n\n/-- For congruence relations `c, d` on a type `M` with a multiplication, `c ≤ d` iff `∀ x y ∈ M`,\n    `x` is related to `y` by `d` if `x` is related to `y` by `c`. -/\n@[to_additive \"For additive congruence relations `c, d` on a type `M` with an addition, `c ≤ d` iff\n`∀ x y ∈ M`, `x` is related to `y` by `d` if `x` is related to `y` by `c`.\"]\ninstance : has_le (con M) := ⟨λ c d, ∀ ⦃x y⦄, c x y → d x y⟩\n\n/-- Definition of `≤` for congruence relations. -/\n@[to_additive \"Definition of `≤` for additive congruence relations.\"]\ntheorem le_def {c d : con M} : c ≤ d ↔ ∀ {x y}, c x y → d x y := iff.rfl\n\n/-- The infimum of a set of congruence relations on a given type with a multiplication. -/\n@[to_additive \"The infimum of a set of additive congruence relations on a given type with\nan addition.\"]\ninstance : has_Inf (con M) :=\n⟨λ S, ⟨⟨λ x y, ∀ c : con M, c ∈ S → c x y,\n⟨λ x c hc, c.refl x, λ _ _ h c hc, c.symm $ h c hc,\n λ _ _ _ h1 h2 c hc, c.trans (h1 c hc) $ h2 c hc⟩⟩,\n λ _ _ _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc⟩⟩\n\n/-- The infimum of a set of congruence relations is the same as the infimum of the set's image\n    under the map to the underlying equivalence relation. -/\n@[to_additive \"The infimum of a set of additive congruence relations is the same as the infimum of\nthe set's image under the map to the underlying equivalence relation.\"]\nlemma Inf_to_setoid (S : set (con M)) : (Inf S).to_setoid = Inf (to_setoid '' S) :=\nsetoid.ext' $ λ x y, ⟨λ h r ⟨c, hS, hr⟩, by rw ←hr; exact h c hS,\n  λ h c hS, h c.to_setoid ⟨c, hS, rfl⟩⟩\n\n/-- The infimum of a set of congruence relations is the same as the infimum of the set's image\n    under the map to the underlying binary relation. -/\n@[to_additive \"The infimum of a set of additive congruence relations is the same as the infimum\nof the set's image under the map to the underlying binary relation.\"]\nlemma Inf_def (S : set (con M)) : ⇑(Inf S) = Inf (@set.image (con M) (M → M → Prop) coe_fn S) :=\nby { ext, simp only [Inf_image, infi_apply, infi_Prop_eq], refl }\n\n@[to_additive]\ninstance : partial_order (con M) :=\n{ le := (≤),\n  lt := λ c d, c ≤ d ∧ ¬d ≤ c,\n  le_refl := λ c _ _, id,\n  le_trans := λ c1 c2 c3 h1 h2 x y h, h2 $ h1 h,\n  lt_iff_le_not_le := λ _ _, iff.rfl,\n  le_antisymm := λ c d hc hd, ext $ λ x y, ⟨λ h, hc h, λ h, hd h⟩ }\n\n/-- The complete lattice of congruence relations on a given type with a multiplication. -/\n@[to_additive \"The complete lattice of additive congruence relations on a given type with\nan addition.\"]\ninstance : complete_lattice (con M) :=\n{ inf := λ c d, ⟨(c.to_setoid ⊓ d.to_setoid), λ _ _ _ _ h1 h2, ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩⟩,\n  inf_le_left := λ _ _ _ _ h, h.1,\n  inf_le_right := λ _ _ _ _ h, h.2,\n  le_inf := λ _ _ _ hb hc _ _ h, ⟨hb h, hc h⟩,\n  top := { mul' := by tauto, ..setoid.complete_lattice.top},\n  le_top := λ _ _ _ h, trivial,\n  bot := { mul' := λ _ _ _ _ h1 h2, h1 ▸ h2 ▸ rfl, ..setoid.complete_lattice.bot},\n  bot_le := λ c x y h, h ▸ c.refl x,\n  .. complete_lattice_of_Inf (con M) $ assume s,\n    ⟨λ r hr x y h, (h : ∀ r ∈ s, (r : con M) x y) r hr, λ r hr x y h r' hr', hr hr' h⟩ }\n\n/-- The infimum of two congruence relations equals the infimum of the underlying binary\n    operations. -/\n@[to_additive \"The infimum of two additive congruence relations equals the infimum of the\nunderlying binary operations.\"]\nlemma inf_def {c d : con M} : (c ⊓ d).r = c.r ⊓ d.r := rfl\n\n/-- Definition of the infimum of two congruence relations. -/\n@[to_additive \"Definition of the infimum of two additive congruence relations.\"]\ntheorem inf_iff_and {c d : con M} {x y} : (c ⊓ d) x y ↔ c x y ∧ d x y := iff.rfl\n\n/-- The inductively defined smallest congruence relation containing a binary relation `r` equals\n    the infimum of the set of congruence relations containing `r`. -/\n@[to_additive add_con_gen_eq \"The inductively defined smallest additive congruence relation\ncontaining a binary relation `r` equals the infimum of the set of additive congruence relations\ncontaining `r`.\"]\ntheorem con_gen_eq (r : M → M → Prop) :\n  con_gen r = Inf {s : con M | ∀ x y, r x y → s x y} :=\nle_antisymm\n  (λ x y H, con_gen.rel.rec_on H (λ _ _ h _ hs, hs _ _ h) (con.refl _) (λ _ _ _, con.symm _)\n    (λ _ _ _ _ _, con.trans _)\n    $ λ w x y z _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc)\n  (Inf_le (λ _ _, con_gen.rel.of _ _))\n\n/-- The smallest congruence relation containing a binary relation `r` is contained in any\n    congruence relation containing `r`. -/\n@[to_additive add_con_gen_le \"The smallest additive congruence relation containing a binary\nrelation `r` is contained in any additive congruence relation containing `r`.\"]\ntheorem con_gen_le {r : M → M → Prop} {c : con M} (h : ∀ x y, r x y → @setoid.r _ c.to_setoid x y) :\n  con_gen r ≤ c :=\nby rw con_gen_eq; exact Inf_le h\n\n/-- Given binary relations `r, s` with `r` contained in `s`, the smallest congruence relation\n    containing `s` contains the smallest congruence relation containing `r`. -/\n@[to_additive add_con_gen_mono \"Given binary relations `r, s` with `r` contained in `s`, the\nsmallest additive congruence relation containing `s` contains the smallest additive congruence\nrelation containing `r`.\"]\ntheorem con_gen_mono {r s : M → M → Prop} (h : ∀ x y, r x y → s x y) :\n  con_gen r ≤ con_gen s :=\ncon_gen_le $ λ x y hr, con_gen.rel.of _ _ $ h x y hr\n\n/-- Congruence relations equal the smallest congruence relation in which they are contained. -/\n@[simp, to_additive add_con_gen_of_add_con \"Additive congruence relations equal the smallest\nadditive congruence relation in which they are contained.\"]\nlemma con_gen_of_con (c : con M) : con_gen c = c :=\nle_antisymm (by rw con_gen_eq; exact Inf_le (λ _ _, id)) con_gen.rel.of\n\n/-- The map sending a binary relation to the smallest congruence relation in which it is\n    contained is idempotent. -/\n@[simp, to_additive add_con_gen_idem \"The map sending a binary relation to the smallest additive\ncongruence relation in which it is contained is idempotent.\"]\nlemma con_gen_idem (r : M → M → Prop) :\n  con_gen (con_gen r) = con_gen r :=\ncon_gen_of_con _\n\n/-- The supremum of congruence relations `c, d` equals the smallest congruence relation containing\n    the binary relation '`x` is related to `y` by `c` or `d`'. -/\n@[to_additive sup_eq_add_con_gen \"The supremum of additive congruence relations `c, d` equals the\nsmallest additive congruence relation containing the binary relation '`x` is related to `y`\nby `c` or `d`'.\"]\nlemma sup_eq_con_gen (c d : con M) :\n  c ⊔ d = con_gen (λ x y, c x y ∨ d x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  simp only [le_def, or_imp_distrib, ← forall_and_distrib]\nend\n\n/-- The supremum of two congruence relations equals the smallest congruence relation containing\n    the supremum of the underlying binary operations. -/\n@[to_additive \"The supremum of two additive congruence relations equals the smallest additive\ncongruence relation containing the supremum of the underlying binary operations.\"]\nlemma sup_def {c d : con M} : c ⊔ d = con_gen (c.r ⊔ d.r) :=\nby rw sup_eq_con_gen; refl\n\n/-- The supremum of a set of congruence relations `S` equals the smallest congruence relation\n    containing the binary relation 'there exists `c ∈ S` such that `x` is related to `y` by\n    `c`'. -/\n@[to_additive Sup_eq_add_con_gen \"The supremum of a set of additive congruence relations `S` equals\nthe smallest additive congruence relation containing the binary relation 'there exists `c ∈ S`\nsuch that `x` is related to `y` by `c`'.\"]\nlemma Sup_eq_con_gen (S : set (con M)) :\n  Sup S = con_gen (λ x y, ∃ c : con M, c ∈ S ∧ c x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  ext,\n  exact ⟨λ h _ _ ⟨r, hr⟩, h hr.1 hr.2,\n         λ h r hS _ _ hr, h _ _ ⟨r, hS, hr⟩⟩,\nend\n\n/-- The supremum of a set of congruence relations is the same as the smallest congruence relation\n    containing the supremum of the set's image under the map to the underlying binary relation. -/\n@[to_additive \"The supremum of a set of additive congruence relations is the same as the smallest\nadditive congruence relation containing the supremum of the set's image under the map to the\nunderlying binary relation.\"]\nlemma Sup_def {S : set (con M)} :\n  Sup S = con_gen (Sup (@set.image (con M) (M → M → Prop) coe_fn S)) :=\nbegin\n  rw [Sup_eq_con_gen, Sup_image],\n  congr' with x y,\n  simp only [Sup_image, supr_apply, supr_Prop_eq, exists_prop, rel_eq_coe]\nend\n\nvariables (M)\n\n/-- There is a Galois insertion of congruence relations on a type with a multiplication `M` into\n    binary relations on `M`. -/\n@[to_additive \"There is a Galois insertion of additive congruence relations on a type with\nan addition `M` into binary relations on `M`.\"]\nprotected noncomputable def gi :\n  @galois_insertion (M → M → Prop) (con M) _ _ con_gen coe_fn :=\n{ choice := λ r h, con_gen r,\n  gc := λ r c, ⟨λ H _ _ h, H $ con_gen.rel.of _ _ h, λ H, con_gen_of_con c ▸ con_gen_mono H⟩,\n  le_l_u := λ x, (con_gen_of_con x).symm ▸ le_refl x,\n  choice_eq := λ _ _, rfl }\n\nvariables {M} (c)\n\n\n/-- Given a function `f`, the smallest congruence relation containing the binary relation on `f`'s\n    image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)`\n    by a congruence relation `c`.' -/\n@[to_additive \"Given a function `f`, the smallest additive congruence relation containing the\nbinary relation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the\nelements of `f⁻¹(y)` by an additive congruence relation `c`.'\"]\ndef map_gen (f : M → N) : con N :=\ncon_gen $ λ x y, ∃ a b, f a = x ∧ f b = y ∧ c a b\n\n/-- Given a surjective multiplicative-preserving function `f` whose kernel is contained in a\n    congruence relation `c`, the congruence relation on `f`'s codomain defined by '`x ≈ y` iff the\n    elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.' -/\n@[to_additive \"Given a surjective addition-preserving function `f` whose kernel is contained in\nan additive congruence relation `c`, the additive congruence relation on `f`'s codomain defined\nby '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.'\"]\ndef map_of_surjective (f : M → N) (H : ∀ x y, f (x * y) = f x * f y) (h : mul_ker f H ≤ c)\n  (hf : surjective f) : con N :=\n{ mul' := λ w x y z ⟨a, b, hw, hx, h1⟩ ⟨p, q, hy, hz, h2⟩,\n    ⟨a * p, b * q, by rw [H, hw, hy], by rw [H, hx, hz], c.mul h1 h2⟩,\n  ..c.to_setoid.map_of_surjective f h hf }\n\n/-- A specialization of 'the smallest congruence relation containing a congruence relation `c`\n    equals `c`'. -/\n@[to_additive \"A specialization of 'the smallest additive congruence relation containing\nan additive congruence relation `c` equals `c`'.\"]\nlemma map_of_surjective_eq_map_gen {c : con M} {f : M → N} (H : ∀ x y, f (x * y) = f x * f y)\n  (h : mul_ker f H ≤ c) (hf : surjective f) :\n  c.map_gen f = c.map_of_surjective f H h hf :=\nby rw ←con_gen_of_con (c.map_of_surjective f H h hf); refl\n\n/-- Given types with multiplications `M, N` and a congruence relation `c` on `N`, a\n    multiplication-preserving map `f : M → N` induces a congruence relation on `f`'s domain\n    defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' -/\n@[to_additive \"Given types with additions `M, N` and an additive congruence relation `c` on `N`,\nan addition-preserving map `f : M → N` induces an additive congruence relation on `f`'s domain\ndefined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' \"]\ndef comap (f : M → N) (H : ∀ x y, f (x * y) = f x * f y) (c : con N) : con M :=\n{ mul' := λ w x y z h1 h2, show c (f (w * y)) (f (x * z)), by rw [H, H]; exact c.mul h1 h2,\n  ..c.to_setoid.comap f }\n\n@[simp, to_additive] lemma comap_rel {f : M → N} (H : ∀ x y, f (x * y) = f x * f y)\n  {c : con N} {x y : M} :\n  comap f H c x y ↔ c (f x) (f y) :=\niff.rfl\n\nsection\nopen _root_.quotient\n\n/-- Given a congruence relation `c` on a type `M` with a multiplication, the order-preserving\n    bijection between the set of congruence relations containing `c` and the congruence relations\n    on the quotient of `M` by `c`. -/\n@[to_additive \"Given an additive congruence relation `c` on a type `M` with an addition,\nthe order-preserving bijection between the set of additive congruence relations containing `c` and\nthe additive congruence relations on the quotient of `M` by `c`.\"]\ndef correspondence : {d // c ≤ d} ≃o (con c.quotient) :=\n{ to_fun := λ d, d.1.map_of_surjective coe _\n    (by rw mul_ker_mk_eq; exact d.2) $ @exists_rep _ c.to_setoid,\n  inv_fun := λ d, ⟨comap (coe : M → c.quotient) (λ x y, rfl) d, λ _ _ h,\n    show d _ _, by rw c.eq.2 h; exact d.refl _ ⟩,\n  left_inv := λ d, subtype.ext_iff_val.2 $ ext $ λ _ _,\n    ⟨λ h, let ⟨a, b, hx, hy, H⟩ := h in\n      d.1.trans (d.1.symm $ d.2 $ c.eq.1 hx) $ d.1.trans H $ d.2 $ c.eq.1 hy,\n     λ h, ⟨_, _, rfl, rfl, h⟩⟩,\n  right_inv := λ d, let Hm : mul_ker (coe : M → c.quotient) (λ x y, rfl) ≤\n        comap (coe : M → c.quotient) (λ x y, rfl) d :=\n      λ x y h, show d _ _, by rw mul_ker_mk_eq at h; exact c.eq.2 h ▸ d.refl _ in\n    ext $ λ x y, ⟨λ h, let ⟨a, b, hx, hy, H⟩ := h in hx ▸ hy ▸ H,\n      con.induction_on₂ x y $ λ w z h, ⟨w, z, rfl, rfl, h⟩⟩,\n  map_rel_iff' := λ s t, ⟨λ h _ _ hs, let ⟨a, b, hx, hy, ht⟩ := h ⟨_, _, rfl, rfl, hs⟩ in\n      t.1.trans (t.1.symm $ t.2 $ eq_rel.1 hx) $ t.1.trans ht $ t.2 $ eq_rel.1 hy,\n      λ h _ _ hs, let ⟨a, b, hx, hy, Hs⟩ := hs in ⟨a, b, hx, hy, h Hs⟩⟩ }\n\nend\n\nend\n\nsection mul_one_class\n\nvariables {M} [mul_one_class M] [mul_one_class N] [mul_one_class P] (c : con M)\n\n/-- The quotient of a monoid by a congruence relation is a monoid. -/\n@[to_additive \"The quotient of an `add_monoid` by an additive congruence relation is\nan `add_monoid`.\"]\ninstance mul_one_class : mul_one_class c.quotient :=\n{ one := ((1 : M) : c.quotient),\n  mul := (*),\n  mul_one := λ x, quotient.induction_on' x $ λ _, congr_arg coe $ mul_one _,\n  one_mul := λ x, quotient.induction_on' x $ λ _, congr_arg coe $ one_mul _ }\n\nvariables {c}\n\n/-- The 1 of the quotient of a monoid by a congruence relation is the equivalence class of the\n    monoid's 1. -/\n@[simp, to_additive \"The 0 of the quotient of an `add_monoid` by an additive congruence relation\nis the equivalence class of the `add_monoid`'s 0.\"]\nlemma coe_one : ((1 : M) : c.quotient) = 1 := rfl\n\nvariables (M c)\n\n/-- The submonoid of `M × M` defined by a congruence relation on a monoid `M`. -/\n@[to_additive \"The `add_submonoid` of `M × M` defined by an additive congruence\nrelation on an `add_monoid` `M`.\"]\nprotected def submonoid : submonoid (M × M) :=\n{ carrier := { x | c x.1 x.2 },\n  one_mem' := c.iseqv.1 1,\n  mul_mem' := λ _ _, c.mul }\n\nvariables {M c}\n\n/-- The congruence relation on a monoid `M` from a submonoid of `M × M` for which membership\n    is an equivalence relation. -/\n@[to_additive \"The additive congruence relation on an `add_monoid` `M` from\nan `add_submonoid` of `M × M` for which membership is an equivalence relation.\"]\ndef of_submonoid (N : submonoid (M × M)) (H : equivalence (λ x y, (x, y) ∈ N)) : con M :=\n{ r := λ x y, (x, y) ∈ N,\n  iseqv := H,\n  mul' := λ _ _ _ _, N.mul_mem }\n\n/-- Coercion from a congruence relation `c` on a monoid `M` to the submonoid of `M × M` whose\n    elements are `(x, y)` such that `x` is related to `y` by `c`. -/\n@[to_additive \"Coercion from a congruence relation `c` on an `add_monoid` `M`\nto the `add_submonoid` of `M × M` whose elements are `(x, y)` such that `x`\nis related to `y` by `c`.\"]\ninstance to_submonoid : has_coe (con M) (submonoid (M × M)) := ⟨λ c, c.submonoid M⟩\n\n@[to_additive] lemma mem_coe {c : con M} {x y} :\n  (x, y) ∈ (↑c : submonoid (M × M)) ↔ (x, y) ∈ c := iff.rfl\n\n@[to_additive]\ntheorem to_submonoid_inj (c d : con M) (H : (c : submonoid (M × M)) = d) : c = d :=\next $ λ x y, show (x, y) ∈ (c : submonoid (M × M)) ↔ (x, y) ∈ ↑d, by rw H\n\n@[to_additive]\nlemma le_iff {c d : con M} : c ≤ d ↔ (c : submonoid (M × M)) ≤ d :=\n⟨λ h x H, h H, λ h x y hc, h $ show (x, y) ∈ c, from hc⟩\n\n/-- The kernel of a monoid homomorphism as a congruence relation. -/\n@[to_additive \"The kernel of an `add_monoid` homomorphism as an additive congruence relation.\"]\ndef ker (f : M →* P) : con M := mul_ker f f.3\n\n/-- The definition of the congruence relation defined by a monoid homomorphism's kernel. -/\n@[simp, to_additive \"The definition of the additive congruence relation defined by an `add_monoid`\nhomomorphism's kernel.\"]\nlemma ker_rel (f : M →* P) {x y} : ker f x y ↔ f x = f y := iff.rfl\n\n/-- There exists an element of the quotient of a monoid by a congruence relation (namely 1). -/\n@[to_additive \"There exists an element of the quotient of an `add_monoid` by a congruence relation\n(namely 0).\"]\ninstance quotient.inhabited : inhabited c.quotient := ⟨((1 : M) : c.quotient)⟩\n\nvariables (c)\n\n/-- The natural homomorphism from a monoid to its quotient by a congruence relation. -/\n@[to_additive \"The natural homomorphism from an `add_monoid` to its quotient by an additive\ncongruence relation.\"]\ndef mk' : M →* c.quotient := ⟨coe, rfl, λ _ _, rfl⟩\n\nvariables (x y : M)\n\n/-- The kernel of the natural homomorphism from a monoid to its quotient by a congruence\n    relation `c` equals `c`. -/\n@[simp, to_additive \"The kernel of the natural homomorphism from an `add_monoid` to its quotient by\nan additive congruence relation `c` equals `c`.\"]\nlemma mk'_ker : ker c.mk' = c := ext $ λ _ _, c.eq\n\nvariables {c}\n\n/-- The natural homomorphism from a monoid to its quotient by a congruence relation is\n    surjective. -/\n@[to_additive \"The natural homomorphism from an `add_monoid` to its quotient by a congruence\nrelation is surjective.\"]\nlemma mk'_surjective : surjective c.mk' :=\nquotient.surjective_quotient_mk'\n\n@[simp, to_additive] lemma coe_mk' : (c.mk' : M → c.quotient) = coe := rfl\n\n/-- The elements related to `x ∈ M`, `M` a monoid, by the kernel of a monoid homomorphism are\n    those in the preimage of `f(x)` under `f`. -/\n@[to_additive \"The elements related to `x ∈ M`, `M` an `add_monoid`, by the kernel of\nan `add_monoid` homomorphism are those in the preimage of `f(x)` under `f`. \"]\nlemma ker_apply_eq_preimage {f : M →* P} (x) : (ker f) x = f ⁻¹' {f x} :=\nset.ext $ λ x,\n  ⟨λ h, set.mem_preimage.2 $ set.mem_singleton_iff.2 h.symm,\n   λ h, (set.mem_singleton_iff.1 $ set.mem_preimage.1 h).symm⟩\n\n/-- Given a monoid homomorphism `f : N → M` and a congruence relation `c` on `M`, the congruence\n    relation induced on `N` by `f` equals the kernel of `c`'s quotient homomorphism composed with\n    `f`. -/\n@[to_additive \"Given an `add_monoid` homomorphism `f : N → M` and an additive congruence relation\n`c` on `M`, the additive congruence relation induced on `N` by `f` equals the kernel of `c`'s\nquotient homomorphism composed with `f`.\"]\nlemma comap_eq {f : N →* M} : comap f f.map_mul c = ker (c.mk'.comp f) :=\next $ λ x y, show c _ _ ↔ c.mk' _ = c.mk' _, by rw ←c.eq; refl\n\nvariables (c) (f : M →* P)\n\n/-- The homomorphism on the quotient of a monoid by a congruence relation `c` induced by a\n    homomorphism constant on `c`'s equivalence classes. -/\n@[to_additive \"The homomorphism on the quotient of an `add_monoid` by an additive congruence\nrelation `c` induced by a homomorphism constant on `c`'s equivalence classes.\"]\ndef lift (H : c ≤ ker f) : c.quotient →* P :=\n{ to_fun := λ x, con.lift_on x f $ λ _ _ h, H h,\n  map_one' := by rw ←f.map_one; refl,\n  map_mul' := λ x y, con.induction_on₂ x y $ λ m n, f.map_mul m n ▸ rfl }\n\nvariables {c f}\n\n/-- The diagram describing the universal property for quotients of monoids commutes. -/\n@[to_additive \"The diagram describing the universal property for quotients of `add_monoid`s\ncommutes.\"]\nlemma lift_mk' (H : c ≤ ker f) (x) :\n  c.lift f H (c.mk' x) = f x := rfl\n\n/-- The diagram describing the universal property for quotients of monoids commutes. -/\n@[simp, to_additive \"The diagram describing the universal property for quotients of `add_monoid`s\ncommutes.\"]\nlemma lift_coe (H : c ≤ ker f) (x : M) :\n  c.lift f H x = f x := rfl\n\n/-- The diagram describing the universal property for quotients of monoids commutes. -/\n@[simp, to_additive \"The diagram describing the universal property for quotients of `add_monoid`s\ncommutes.\"]\ntheorem lift_comp_mk' (H : c ≤ ker f) :\n  (c.lift f H).comp c.mk' = f := by ext; refl\n\n/-- Given a homomorphism `f` from the quotient of a monoid by a congruence relation, `f` equals the\n    homomorphism on the quotient induced by `f` composed with the natural map from the monoid to\n    the quotient. -/\n@[simp, to_additive \"Given a homomorphism `f` from the quotient of an `add_monoid` by an additive\ncongruence relation, `f` equals the homomorphism on the quotient induced by `f` composed with the\nnatural map from the `add_monoid` to the quotient.\"]\nlemma lift_apply_mk' (f : c.quotient →* P) :\n  c.lift (f.comp c.mk') (λ x y h, show f ↑x = f ↑y, by rw c.eq.2 h) = f :=\nby ext; rcases x; refl\n\n/-- Homomorphisms on the quotient of a monoid by a congruence relation are equal if they\n    are equal on elements that are coercions from the monoid. -/\n@[to_additive \"Homomorphisms on the quotient of an `add_monoid` by an additive congruence relation\nare equal if they are equal on elements that are coercions from the `add_monoid`.\"]\nlemma lift_funext (f g : c.quotient →* P) (h : ∀ a : M, f a = g a) : f = g :=\nbegin\n  rw [←lift_apply_mk' f, ←lift_apply_mk' g],\n  congr' 1,\n  exact monoid_hom.ext_iff.2 h,\nend\n\n/-- The uniqueness part of the universal property for quotients of monoids. -/\n@[to_additive \"The uniqueness part of the universal property for quotients of `add_monoid`s.\"]\ntheorem lift_unique (H : c ≤ ker f) (g : c.quotient →* P)\n  (Hg : g.comp c.mk' = f) : g = c.lift f H :=\nlift_funext g (c.lift f H) $ λ x, by { subst f, refl }\n\n/-- Given a congruence relation `c` on a monoid and a homomorphism `f` constant on `c`'s\n    equivalence classes, `f` has the same image as the homomorphism that `f` induces on the\n    quotient. -/\n@[to_additive \"Given an additive congruence relation `c` on an `add_monoid` and a homomorphism `f`\nconstant on `c`'s equivalence classes, `f` has the same image as the homomorphism that `f` induces\non the quotient.\"]\ntheorem lift_range (H : c ≤ ker f) : (c.lift f H).mrange = f.mrange :=\nsubmonoid.ext $ λ x, ⟨by rintros ⟨⟨y⟩, hy⟩; exact ⟨y, hy⟩, λ ⟨y, hy⟩, ⟨↑y, hy⟩⟩\n\n/-- Surjective monoid homomorphisms constant on a congruence relation `c`'s equivalence classes\n    induce a surjective homomorphism on `c`'s quotient. -/\n@[to_additive \"Surjective `add_monoid` homomorphisms constant on an additive congruence\nrelation `c`'s equivalence classes induce a surjective homomorphism on `c`'s quotient.\"]\nlemma lift_surjective_of_surjective (h : c ≤ ker f) (hf : surjective f) :\n  surjective (c.lift f h) :=\nλ y, exists.elim (hf y) $ λ w hw, ⟨w, (lift_mk' h w).symm ▸ hw⟩\n\nvariables (c f)\n\n/-- Given a monoid homomorphism `f` from `M` to `P`, the kernel of `f` is the unique congruence\n    relation on `M` whose induced map from the quotient of `M` to `P` is injective. -/\n@[to_additive \"Given an `add_monoid` homomorphism `f` from `M` to `P`, the kernel of `f`\nis the unique additive congruence relation on `M` whose induced map from the quotient of `M`\nto `P` is injective.\"]\nlemma ker_eq_lift_of_injective (H : c ≤ ker f) (h : injective (c.lift f H)) :\n  ker f = c :=\nto_setoid_inj $ ker_eq_lift_of_injective f H h\n\nvariables {c}\n\n/-- The homomorphism induced on the quotient of a monoid by the kernel of a monoid homomorphism. -/\n@[to_additive \"The homomorphism induced on the quotient of an `add_monoid` by the kernel\nof an `add_monoid` homomorphism.\"]\ndef ker_lift : (ker f).quotient →* P :=\n(ker f).lift f $ λ _ _, id\n\nvariables {f}\n\n/-- The diagram described by the universal property for quotients of monoids, when the congruence\n    relation is the kernel of the homomorphism, commutes. -/\n@[simp, to_additive \"The diagram described by the universal property for quotients\nof `add_monoid`s, when the additive congruence relation is the kernel of the homomorphism,\ncommutes.\"]\nlemma ker_lift_mk (x : M) :  ker_lift f x = f x := rfl\n\n/-- Given a monoid homomorphism `f`, the induced homomorphism on the quotient by `f`'s kernel has\n    the same image as `f`. -/\n@[simp, to_additive \"Given an `add_monoid` homomorphism `f`, the induced homomorphism\non the quotient by `f`'s kernel has the same image as `f`.\"]\nlemma ker_lift_range_eq : (ker_lift f).mrange = f.mrange :=\nlift_range $ λ _ _, id\n\n/-- A monoid homomorphism `f` induces an injective homomorphism on the quotient by `f`'s kernel. -/\n@[to_additive \"An `add_monoid` homomorphism `f` induces an injective homomorphism on the quotient\nby `f`'s kernel.\"]\nlemma ker_lift_injective (f : M →* P) : injective (ker_lift f) :=\nλ x y, quotient.induction_on₂' x y $ λ _ _, (ker f).eq.2\n\n/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, `d`'s quotient\n    map induces a homomorphism from the quotient by `c` to the quotient by `d`. -/\n@[to_additive \"Given additive congruence relations `c, d` on an `add_monoid` such that `d`\ncontains `c`, `d`'s quotient map induces a homomorphism from the quotient by `c` to the quotient\nby `d`.\"]\ndef map (c d : con M) (h : c ≤ d) : c.quotient →* d.quotient :=\nc.lift d.mk' $ λ x y hc, show (ker d.mk') x y, from\n  (mk'_ker d).symm ▸ h hc\n\n/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, the definition of\n    the homomorphism from the quotient by `c` to the quotient by `d` induced by `d`'s quotient\n    map. -/\n@[to_additive \"Given additive congruence relations `c, d` on an `add_monoid` such that `d`\ncontains `c`, the definition of the homomorphism from the quotient by `c` to the quotient by `d`\ninduced by `d`'s quotient map.\"]\nlemma map_apply {c d : con M} (h : c ≤ d) (x) :\n  c.map d h x = c.lift d.mk' (λ x y hc, d.eq.2 $ h hc) x := rfl\n\nvariables (c)\n\n/-- The first isomorphism theorem for monoids. -/\n@[to_additive \"The first isomorphism theorem for `add_monoid`s.\"]\nnoncomputable def quotient_ker_equiv_range (f : M →* P) : (ker f).quotient ≃* f.mrange :=\n{ map_mul' := monoid_hom.map_mul _,\n  ..equiv.of_bijective\n      ((@mul_equiv.to_monoid_hom (ker_lift f).mrange _ _ _\n        $ mul_equiv.submonoid_congr ker_lift_range_eq).comp (ker_lift f).mrange_restrict) $\n      (equiv.bijective _).comp\n        ⟨λ x y h, ker_lift_injective f $ by rcases x; rcases y; injections,\n         λ ⟨w, z, hz⟩, ⟨z, by rcases hz; rcases _x; refl⟩⟩ }\n\n/-- The first isomorphism theorem for monoids in the case of a homomorphism with right inverse. -/\n@[to_additive \"The first isomorphism theorem for `add_monoid`s in the case of a homomorphism\nwith right inverse.\", simps]\ndef quotient_ker_equiv_of_right_inverse (f : M →* P) (g : P → M)\n  (hf : function.right_inverse g f) :\n  (ker f).quotient ≃* P :=\n{ to_fun := ker_lift f,\n  inv_fun := coe ∘ g,\n  left_inv := λ x, ker_lift_injective _ (by rw [function.comp_app, ker_lift_mk, hf]),\n  right_inv := hf,\n  .. ker_lift f }\n\n/-- The first isomorphism theorem for monoids in the case of a surjective homomorphism.\n\nFor a `computable` version, see `con.quotient_ker_equiv_of_right_inverse`.\n-/\n@[to_additive \"The first isomorphism theorem for `add_monoid`s in the case of a surjective\nhomomorphism.\n\nFor a `computable` version, see `add_con.quotient_ker_equiv_of_right_inverse`.\n\"]\nnoncomputable def quotient_ker_equiv_of_surjective (f : M →* P) (hf : surjective f) :\n  (ker f).quotient ≃* P :=\nquotient_ker_equiv_of_right_inverse _ _ hf.has_right_inverse.some_spec\n\n/-- The second isomorphism theorem for monoids. -/\n@[to_additive \"The second isomorphism theorem for `add_monoid`s.\"]\nnoncomputable def comap_quotient_equiv (f : N →* M) :\n  (comap f f.map_mul c).quotient ≃* (c.mk'.comp f).mrange :=\n(con.congr comap_eq).trans $ quotient_ker_equiv_range $ c.mk'.comp f\n\n/-- The third isomorphism theorem for monoids. -/\n@[to_additive \"The third isomorphism theorem for `add_monoid`s.\"]\ndef quotient_quotient_equiv_quotient (c d : con M) (h : c ≤ d) :\n  (ker (c.map d h)).quotient ≃* d.quotient :=\n{ map_mul' := λ x y, con.induction_on₂ x y $ λ w z, con.induction_on₂ w z $ λ a b,\n    show _ = d.mk' a * d.mk' b, by rw ←d.mk'.map_mul; refl,\n  ..quotient_quotient_equiv_quotient c.to_setoid d.to_setoid h }\n\nend mul_one_class\n\nsection monoids\n\n/-- The quotient of a monoid by a congruence relation is a monoid. -/\n@[to_additive \"The quotient of an `add_monoid` by an additive congruence relation is\nan `add_monoid`.\"]\ninstance monoid {M : Type*} [monoid M] (c : con M): monoid c.quotient :=\n{ one := ((1 : M) : c.quotient),\n  mul := (*),\n  mul_assoc := λ x y z, quotient.induction_on₃' x y z\n               $ λ _ _ _, congr_arg coe $ mul_assoc _ _ _,\n  .. c.mul_one_class }\n\n/-- The quotient of a `comm_monoid` by a congruence relation is a `comm_monoid`. -/\n@[to_additive \"The quotient of an `add_comm_monoid` by an additive congruence\nrelation is an `add_comm_monoid`.\"]\ninstance comm_monoid {M : Type*} [comm_monoid M] (c : con M) :\n  comm_monoid c.quotient :=\n{ mul_comm := λ x y, con.induction_on₂ x y $ λ w z, by rw [←coe_mul, ←coe_mul, mul_comm],\n  ..c.monoid}\n\nend monoids\n\nsection groups\n\nvariables {M} [group M] [group N] [group P] (c : con M)\n\n/-- Multiplicative congruence relations preserve inversion. -/\n@[to_additive \"Additive congruence relations preserve negation.\"]\nprotected lemma inv : ∀ {w x}, c w x → c w⁻¹ x⁻¹ :=\nλ x y h, by simpa using c.symm (c.mul (c.mul (c.refl x⁻¹) h) (c.refl y⁻¹))\n\n/-- The inversion induced on the quotient by a congruence relation on a type with a\n    inversion. -/\n@[to_additive \"The negation induced on the quotient by an additive congruence relation on a type\nwith an negation.\"]\ninstance has_inv : has_inv c.quotient :=\n⟨λ x, quotient.lift_on' x (λ w, ((w⁻¹ : M) : c.quotient))\n     $ λ x y h, c.eq.2 $ c.inv h⟩\n\n/-- The quotient of a group by a congruence relation is a group. -/\n@[to_additive \"The quotient of an `add_group` by an additive congruence relation is\nan `add_group`.\"]\ninstance group : group c.quotient :=\n{ inv := λ x, x⁻¹,\n  mul_left_inv := λ x, show x⁻¹ * x = 1,\n    from quotient.induction_on' x $ λ _, congr_arg coe $ mul_left_inv _,\n  .. con.monoid c}\n\nend groups\n\nsection units\n\nvariables {α : Type*} [monoid M] {c : con M}\n\n/-- In order to define a function `units (con.quotient c) → α` on the units of `con.quotient c`,\nwhere `c : con M` is a multiplicative congruence on a monoid, it suffices to define a function `f`\nthat takes elements `x y : M` with proofs of `c (x * y) 1` and `c (y * x) 1`, and returns an element\nof `α` provided that `f x y _ _ = f x' y' _ _` whenever `c x x'` and `c y y'`. -/\n@[to_additive lift_on_add_units] def lift_on_units (u : units c.quotient)\n  (f : Π (x y : M), c (x * y) 1 → c (y * x) 1 → α)\n  (Hf : ∀ x y hxy hyx x' y' hxy' hyx', c x x' → c y y' → f x y hxy hyx = f x' y' hxy' hyx') :\n  α :=\nbegin\n  refine @con.hrec_on₂ M M _ _ c c (λ x y, x * y = 1 → y * x = 1 → α)\n    (u : c.quotient) (↑u⁻¹ : c.quotient)\n    (λ (x y : M) (hxy : (x * y : c.quotient) = 1) (hyx : (y * x : c.quotient) = 1),\n    f x y (c.eq.1 hxy) (c.eq.1 hyx)) (λ x y x' y' hx hy, _) u.3 u.4,\n  ext1, { rw [c.eq.2 hx, c.eq.2 hy] },\n  rintro Hxy Hxy' -,\n  ext1, { rw [c.eq.2 hx, c.eq.2 hy] },\n  rintro Hyx Hyx' -,\n  exact heq_of_eq (Hf _ _ _ _ _ _ _ _ hx hy)\nend\n\n/-- In order to define a function `units (con.quotient c) → α` on the units of `con.quotient c`,\nwhere `c : con M` is a multiplicative congruence on a monoid, it suffices to define a function `f`\nthat takes elements `x y : M` with proofs of `c (x * y) 1` and `c (y * x) 1`, and returns an element\nof `α` provided that `f x y _ _ = f x' y' _ _` whenever `c x x'` and `c y y'`. -/\nadd_decl_doc add_con.lift_on_add_units\n\n@[simp, to_additive]\nlemma lift_on_units_mk (f : Π (x y : M), c (x * y) 1 → c (y * x) 1 → α)\n  (Hf : ∀ x y hxy hyx x' y' hxy' hyx', c x x' → c y y' → f x y hxy hyx = f x' y' hxy' hyx')\n  (x y : M) (hxy hyx) :\n  lift_on_units ⟨(x : c.quotient), y, hxy, hyx⟩ f Hf = f x y (c.eq.1 hxy) (c.eq.1 hyx) :=\nrfl\n\n@[elab_as_eliminator, to_additive induction_on_add_units]\nlemma induction_on_units {p : units c.quotient → Prop} (u : units c.quotient)\n  (H : ∀ (x y : M) (hxy : c (x * y) 1) (hyx : c (y * x) 1), p ⟨x, y, c.eq.2 hxy, c.eq.2 hyx⟩) :\n  p u :=\nbegin\n  rcases u with ⟨⟨x⟩, ⟨y⟩, h₁, h₂⟩,\n  exact H x y (c.eq.1 h₁) (c.eq.1 h₂)\nend\n\nend units\n\nend con\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/group_theory/congruence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947155710234, "lm_q2_score": 0.6926419767901475, "lm_q1q2_score": 0.453607570382535}}
{"text": "import breen_deligne.eg\nimport thm95.constants\nimport polyhedral_lattice.int\nimport system_of_complexes.shift_sub_id\n\nopen breen_deligne thm95.universal_constants\nopen_locale nnreal\n\nnamespace Lbar\n\nvariables (r r' : ℝ≥0)\nvariables [fact (0 < r')] [fact (r < 1)]\nvariables (i : ℕ)\n\n-- move me\nlemma κ_pos : ∀ m, 0 < eg.κ r r' m\n| 0 := zero_lt_one\n| (m+1) := begin\n  dsimp only [eg.κ, data.κ],\n  refine mul_pos _ _,\n  { refine nnreal.inv_pos.mpr (lt_max_of_lt_left zero_lt_one), },\n  { refine mul_pos (pow_pos (fact.out _) _) (κ_pos _), }\nend\n\nvariables [fact (0 < r)] [fact (r < r')] [fact (r' < 1)]\n\nnoncomputable!\ndef ι' : ℕ → ℝ≥0\n| 0 := max\n        (c₀ r r' eg (λ (n : ℕ), eg.κ r r' n) (eg.κ' r r') (i + 1) ⟨ℤ⟩)\n        (c₀ r r' eg (λ (n : ℕ), eg.κ r r' n) (eg.κ' r r') (i + 1 + 1) ⟨ℤ⟩)\n| (j+1) := max\n        (max (j+1) (ι' j))\n        (max\n          (max\n            (k (eg.κ' r r') i ^ 2 * ι' j)\n            (k (eg.κ' r r') (i+1) ^ 2 * ι' j))\n            ((k (eg.κ' r r') (i+1+1) ^ 2 * ι' j)))\n\nlemma hι' : monotone (ι' r r' i) :=\nbegin\n  apply monotone_nat_of_le_succ,\n  rintro (_|j); refine le_trans (le_max_right _ _) (le_max_left _ _),\nend\n\nlemma Hι1 : ∀ j,\n  c₀ r r' eg (λ (n : ℕ), eg.κ r r' n) (eg.κ' r r') (i + 1) ⟨ℤ⟩ ≤ ι' r r' i j\n| 0 := le_max_left _ _\n| (j+1) := (Hι1 j).trans $ by { apply hι', apply nat.le_succ }\n\nlemma Hι1' : ∀ j,\n  c₀ r r' eg (λ (n : ℕ), eg.κ r r' n) (eg.κ' r r') (i + 1 + 1) ⟨ℤ⟩ ≤ ι' r r' i j\n| 0 := le_max_right _ _\n| (j+1) := (Hι1' j).trans $ by { apply hι', apply nat.le_succ }\n\nlemma Hι2a : ∀ j,\n  k (eg.κ' r r') i ^ 2 * ι' r r' i j ≤ ι' r r' i (j + 1) :=\nby rintro (_|j); simp only [ι', le_max_iff, le_rfl, true_or, or_true]\n\nlemma Hι2b : ∀ j,\n  k (eg.κ' r r') (i + 1) ^ 2 * ι' r r' i j ≤ ι' r r' i (j + 1) :=\nby rintro (_|j); simp only [ι', le_max_iff, le_rfl, true_or, or_true]\n\nlemma Hι2c : ∀ j,\n  k (eg.κ' r r') (i + 1 + 1) ^ 2 * ι' r r' i j ≤ ι' r r' i (j + 1) :=\nby rintro (_|j); simp only [ι', le_max_iff, le_rfl, true_or, or_true]\n\nnoncomputable\ndef ι : ulift.{1} ℕ → ℝ≥0 := ι' r r' i ∘ ulift.down\n\nlemma hι : monotone (ι r r' i) :=\nλ j₁ j₂ h, by { delta ι, apply hι', exact h }\n\nlemma hι'_self_le : ∀ j:ℕ, (j:ℝ≥0) ≤ ι' r r' i j\n| 0 := by { norm_cast, exact zero_le' }\n| (j+1) := by simp only [ι', le_max_iff, nat.cast_add, nat.cast_one, le_refl, true_or]\n\nlemma sufficiently_increasing_eg (s : ℝ≥0) (m : ℕ) :\n  ∃ n : ℕ, s ≤ ι' r r' i n * eg.κ r r' m :=\nbegin\n  let κ := eg.κ r r' m,\n  let n := ⌈s * κ⁻¹⌉₊,\n  let ι := ι' r r' i n,\n  refine ⟨n, _⟩,\n  calc s = s * κ⁻¹ * κ : _\n     ... ≤ ι * κ : mul_le_mul' _ le_rfl,\n  { rw inv_mul_cancel_right₀, apply ne_of_gt, apply κ_pos, },\n  { refine (nat.le_ceil _).trans (hι'_self_le _ _ _ _) }\nend\n\nlemma sufficiently_increasing_eg' (s : ℝ≥0) (m : ℕ) :\n  ∃ n : ℕ, s ≤ r' * (ι' r r' i n * eg.κ r r' m) :=\nbegin\n  obtain ⟨n,hn⟩ := sufficiently_increasing_eg r r' i (s / r') m,\n  use n,\n  replace hn := mul_le_mul (le_refl r') hn (zero_le (s / r')) (zero_le _),\n  refine le_trans (le_of_eq _) hn,\n  have : r' ≠ 0, { symmetry, exact ne_of_lt (fact.out (0 < r')) },\n  rw mul_comm,\n  exact (div_eq_iff this).mp rfl\nend\n\ndef sufficiently_increasing\n  (κ : ℝ≥0 → ℕ → ℝ≥0) (ι : ulift ℕ → ℝ≥0) : Prop :=\n∀ (r : ℝ≥0) (m : ℕ), ∃ n : ℕ, r ≤ κ (ι ⟨n⟩) m\n\nend Lbar\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/Lbar/iota.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.785308580887758, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.45351206570332736}}
{"text": "import data.sum\nimport data.set\n\nopen sum\n\nlemma preimage_inl_image_inl {α β : Type*} (u : set α) :\n  @inl α β ⁻¹' (@inl α β '' u) = u :=\nset.preimage_image_eq u (λ _ _, inl.inj_iff.mp)\n\nlemma preimage_inl_image_inr {α β : Type*} (u : set β) :\n  @inl α β ⁻¹' (@inr α β '' u) = ∅ :=\nset.eq_empty_iff_forall_not_mem.mpr (assume b ⟨a, _, h⟩, inr_ne_inl h)\n\nlemma preimage_inr_image_inl {α β : Type*} (u : set α) :\n  @inr α β ⁻¹' (@inl α β '' u) = ∅ :=\nset.eq_empty_iff_forall_not_mem.mpr (assume a ⟨b, _, h⟩, inl_ne_inr h)\n\nlemma preimage_inr_image_inr {α β : Type*} (u : set β) :\n  @inr α β ⁻¹' (@inr α β '' u) = u :=\nset.preimage_image_eq u (λ _ _, inr.inj_iff.mp)\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/for_mathlib/data_sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.453510174257344}}
{"text": "import .basic\n\nnamespace premodel\n\n-- `optree` defines an (initial) premodel\ninstance tree_premodel (th : theory) (α : Type*) : premodel th (optree th.op α) :=\n  {\n    act := @optree.opnode th.op α\n  }\n\nend premodel\n\n\nnamespace morphism\n\n-- maps into premodels give rise to morphisms out of trees\ndefinition treelift (th : theory) {α β: Type*} [premodel th β] (f : α → β) : morphism th (optree th.op α) β :=\n  subtype.mk (optree.elim (@premodel.act th β _) f) $\n    by intros n μ ts; unfold premodel.act; rw [optree.elim_opnode]\n\n-- Computation rule for treelift; treelift preserves the original map\ntheorem treelift_comp {th : theory} {α β: Type*} [premodel th β] (f : α → β) : ∀ {a : α}, (treelift th f).val (optree.varleaf a) = f a :=\n  begin\n    intros,\n    dsimp [treelift],\n    exact optree.elim_varleaf\n  end\n\n-- The embedding into a treemodel is \"epimorphic\"\nmutual theorem tree_unique, tree_unique_aux {th : theory} {α β : Type*} [premodel th β] {f g : morphism th (optree th.op α) β} (h : ∀ a, f.val (optree.varleaf a) = g.val (optree.varleaf a))\nwith tree_unique : ∀ {t : optree th.op α}, f.val t = g.val t\n| (optree.varleaf a) := h a\n| (optree.opnode k vect.nil) :=\n  begin\n    have : (optree.opnode k vect.nil) = (@premodel.act th (optree th.op α) _ 0 k) vect.nil,\n      by unfold premodel.act; refl,\n    rw [this],\n    rw [f.property,g.property],\n    unfold vect.map\n  end\n| (optree.opnode k (vect.cons t ts)) :=\n  begin\n    have : ∀ t, (optree.opnode k t) = (@premodel.act th (optree th.op α) _ _ k) t,\n      from λ_, rfl,\n    rw [this],\n    rw [f.property,g.property],\n    unfold vect.map,\n    rw [tree_unique, tree_unique_aux]\n  end\nwith tree_unique_aux : ∀ {n : ℕ} {ts : vect (optree th.op α) n}, vect.map f.val ts = vect.map g.val ts\n| _ vect.nil := by unfold vect.map; refl\n| _ (vect.cons t ts) :=\n  begin\n    unfold vect.map,\n    rw [tree_unique, tree_unique_aux],\n    try {split; refl}\n  end\n\nend morphism\n", "meta": {"author": "Junology", "repo": "groth-lean", "sha": "5aa1ba624cd0f5145f63fa86130f99b85bbbcac2", "save_path": "github-repos/lean/Junology-groth-lean", "path": "github-repos/lean/Junology-groth-lean/groth-lean-5aa1ba624cd0f5145f63fa86130f99b85bbbcac2/src/algebra/theory/tree.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45341703342744066}}
{"text": "import classes.context_free.basics.lifting\n\n\nvariables {T : Type}\n\nprivate def union_grammar (g₁ g₂ : CF_grammar T) : CF_grammar T :=\nCF_grammar.mk (option (g₁.nt ⊕ g₂.nt)) none (\n  (none, [symbol.nonterminal (some (sum.inl (g₁.initial)))]) ::\n  (none, [symbol.nonterminal (some (sum.inr (g₂.initial)))]) ::\n  ((list.map rule_of_rule₁ g₁.rules) ++ (list.map rule_of_rule₂ g₂.rules))\n)\n\n\nvariables {g₁ g₂ : CF_grammar T}\n\nsection lifted_grammars\n\nprivate def oN₁_of_N : (union_grammar g₁ g₂).nt → (option g₁.nt)\n| none := none\n| (some (sum.inl nonte)) := some nonte\n| (some (sum.inr _)) := none\n\nprivate def oN₂_of_N : (union_grammar g₁ g₂).nt → (option g₂.nt)\n| none := none\n| (some (sum.inl _)) := none\n| (some (sum.inr nonte)) := some nonte\n\n\nprivate def g₁g : @lifted_grammar T :=\nlifted_grammar.mk g₁ (union_grammar g₁ g₂) (some ∘ sum.inl) (by {\n  intros x y h,\n  apply sum.inl_injective,\n  apply option.some_injective,\n  exact h,\n}) (by {\n  intros r h,\n  apply list.mem_cons_of_mem,\n  apply list.mem_cons_of_mem,\n  apply list.mem_append_left,\n  rw list.mem_map,\n  use r,\n  split,\n  {\n    exact h,\n  },\n  unfold rule_of_rule₁,\n  unfold lift_rule,\n  norm_num,\n  unfold lift_string,\n  unfold lsTN_of_lsTN₁,\n  five_steps,\n}) oN₁_of_N (by {\n  intros x y ass,\n  cases x,\n  {\n    right,\n    refl,\n  },\n  cases x, swap,\n  {\n    right,\n    refl,\n  },\n  cases y,\n  {\n    rw ass,\n    right,\n    refl,\n  },\n  cases y, swap,\n  {\n    tauto,\n  },\n  left,\n  simp only [oN₁_of_N] at ass,\n  apply congr_arg,\n  apply congr_arg,\n  exact ass,\n}) (by {\n  intro r,\n  rintro ⟨r_in, r_ntype⟩,\n  cases r_in,\n  {\n    exfalso,\n    rw r_in at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n₀ imposs,\n    exact option.no_confusion imposs,\n  },\n  cases r_in,\n  {\n    exfalso,\n    rw r_in at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n₀ imposs,\n    exact option.no_confusion imposs,\n  },\n  change r ∈ (list.map rule_of_rule₁ g₁.rules ++ list.map rule_of_rule₂ g₂.rules) at r_in,\n  rw list.mem_append at r_in,\n  cases r_in,\n  {\n    rw list.mem_map at r_in,\n    rcases r_in with ⟨r₁, r₁_in, r₁_convert_r⟩,\n    use r₁,\n    split,\n    {\n      exact r₁_in,\n    },\n    rw ←r₁_convert_r,\n    simp only [\n      lift_rule, rule_of_rule₁, lift_string, lsTN_of_lsTN₁,\n      prod.mk.inj_iff, eq_self_iff_true, true_and\n    ],\n    five_steps,\n  },\n  {\n    exfalso,\n    rw list.mem_map at r_in,\n    rcases r_in with ⟨r₂, r₂_in, r₂_convert_r⟩,\n    rw ←r₂_convert_r at r_ntype,\n    unfold rule_of_rule₂ at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n₁ contr,\n    rw option.some_inj at contr,\n    exact sum.no_confusion contr,\n  },\n}) (by { intro, refl })\n\nprivate def g₂g : @lifted_grammar T :=\nlifted_grammar.mk g₂ (union_grammar g₁ g₂) (some ∘ sum.inr) (by {\n  intros x y h,\n  apply sum.inr_injective,\n  apply option.some_injective,\n  exact h,\n}) (by {\n  intros r h,\n  apply list.mem_cons_of_mem,\n  apply list.mem_cons_of_mem,\n  apply list.mem_append_right,\n  rw list.mem_map,\n  use r,\n  split,\n  {\n    exact h,\n  },\n  unfold rule_of_rule₂,\n  unfold lift_rule,\n  norm_num,\n  unfold lift_string,\n  unfold lsTN_of_lsTN₂,\n  five_steps,\n}) oN₂_of_N (by {\n  intros x y ass,\n  cases x,\n  {\n    right,\n    refl,\n  },\n  cases x,\n  {\n    right,\n    refl,\n  },\n  cases y,\n  {\n    right,\n    rw ass,\n    refl,\n  },\n  cases y,\n  {\n    tauto,\n  },\n  left,\n  simp only [oN₂_of_N] at ass,\n  apply congr_arg,\n  apply congr_arg,\n  exact ass,\n}) (by {\n  intro r,\n  rintro ⟨r_in, r_ntype⟩,\n  cases list.eq_or_mem_of_mem_cons r_in with r_eq r_in_,\n  {\n    exfalso,\n    rw r_eq at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n₀ imposs,\n    exact option.no_confusion imposs,\n  },\n  cases list.eq_or_mem_of_mem_cons r_in_ with r_eq_ r_in__,\n  {\n    exfalso,\n    rw r_eq_ at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n₀ imposs,\n    exact option.no_confusion imposs,\n  },\n  clear r_in r_in_,\n  rename r_in__ r_in,\n  rw list.mem_append at r_in,\n  cases r_in,\n  {\n    exfalso,\n    rw list.mem_map at r_in,\n    rcases r_in with ⟨r₁, r₁_in, r₁_convert_r⟩,\n    rw ←r₁_convert_r at r_ntype,\n    unfold rule_of_rule₁ at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n₂ contr,\n    rw option.some_inj at contr,\n    exact sum.no_confusion contr,\n  },\n  {\n    rw list.mem_map at r_in,\n    rcases r_in with ⟨r₂, r₂_in, r₂_convert_r⟩,\n    use r₂,\n    split,\n    {\n      exact r₂_in,\n    },\n    rw ←r₂_convert_r,\n    simp only [\n      lift_rule, rule_of_rule₂, lift_string, lsTN_of_lsTN₂,\n      prod.mk.inj_iff, eq_self_iff_true, true_and\n    ],\n    five_steps,\n  },\n}) (by { intro, refl })\n\nend lifted_grammars\n\n\nsection lemmata_subset\n\nprivate lemma deri₁_more (w : list (symbol T g₁.nt)) :\n  CF_derives g₁ [symbol.nonterminal g₁.initial] w →\n    CF_derives\n      (union_grammar g₁ g₂)\n      (lsTN_of_lsTN₁ [symbol.nonterminal g₁.initial])\n      (lsTN_of_lsTN₁ w) :=\nbegin\n  intro ass,\n  let gg₁ := @g₁g T g₁ g₂,\n  change CF_derives gg₁.g (lsTN_of_lsTN₁ [symbol.nonterminal g₁.initial]) (lsTN_of_lsTN₁ w),\n  have techni : lsTN_of_lsTN₁ = lift_string gg₁.lift_nt,\n  {\n    unfold lsTN_of_lsTN₁,\n    unfold lift_string,\n    ext1 w,\n    five_steps,\n  },\n  rw techni,\n  exact lift_deri ass,\nend\n\nprivate lemma deri₂_more (w : list (symbol T g₂.nt)) :\n  CF_derives g₂ [symbol.nonterminal g₂.initial] w →\n    CF_derives\n      (union_grammar g₁ g₂)\n      (lsTN_of_lsTN₂ [symbol.nonterminal g₂.initial])\n      (lsTN_of_lsTN₂ w) :=\nbegin\n  intro ass,\n  let gg₂ := @g₂g T g₁ g₂,\n  change CF_derives gg₂.g (lsTN_of_lsTN₂ [symbol.nonterminal g₂.initial]) (lsTN_of_lsTN₂ w),\n  have techni : lsTN_of_lsTN₂ = lift_string gg₂.lift_nt,\n  {\n    unfold lsTN_of_lsTN₂,\n    unfold lift_string,\n    ext1 w,\n    five_steps,\n  },\n  rw techni,\n  exact lift_deri ass,\nend\n\nprivate lemma in_union_of_in_first (w : list T) :\n  w ∈ CF_language g₁  →  w ∈ CF_language (union_grammar g₁ g₂)  :=\nbegin\n  intro assum,\n\n  have deri_start :\n    CF_derives\n      (union_grammar g₁ g₂)\n      [symbol.nonterminal none]\n      [symbol.nonterminal (some (sum.inl g₁.initial))],\n  {\n    apply CF_deri_of_tran,\n    use (none, [symbol.nonterminal (some (sum.inl (g₁.initial)))]),\n    split,\n    {\n      change (none, [symbol.nonterminal (some (sum.inl g₁.initial))]) ∈ (\n        (none, [symbol.nonterminal (some (sum.inl (g₁.initial)))]) ::\n        (none, [symbol.nonterminal (some (sum.inr (g₂.initial)))]) ::\n        ((list.map rule_of_rule₁ g₁.rules) ++ (list.map rule_of_rule₂ g₂.rules))\n      ),\n      apply list.mem_cons_self,\n    },\n    use [[], []],\n    simp,\n  },\n\n  have deri_rest :\n    CF_derives\n      (union_grammar g₁ g₂)\n      [symbol.nonterminal (some (sum.inl g₁.initial))]\n      (list.map symbol.terminal w),\n  {\n    have beginning :\n      [symbol.nonterminal (some (sum.inl g₁.initial))] =\n      lsTN_of_lsTN₁ [symbol.nonterminal g₁.initial],\n    {\n      unfold lsTN_of_lsTN₁,\n      change\n        [symbol.nonterminal (some (sum.inl g₁.initial))] =\n        [sTN_of_sTN₁ (symbol.nonterminal g₁.initial)],\n      unfold sTN_of_sTN₁,\n    },\n    have ending :\n      (list.map symbol.terminal w) =\n      lsTN_of_lsTN₁ (list.map symbol.terminal w),\n    {\n      ext1,\n      unfold lsTN_of_lsTN₁,\n      rw [list.nth_map, list.map_map, list.nth_map],\n      apply congr_arg,\n      refl,\n    },\n    rw beginning,\n    rw ending,\n    exact deri₁_more (list.map symbol.terminal w) assum,\n  },\n\n  unfold CF_language,\n  rw set.mem_set_of_eq,\n  unfold CF_generates,\n  unfold CF_generates_str,\n  unfold CF_derives,\n  apply CF_deri_of_deri_deri deri_start,\n  exact deri_rest,\nend\n\nprivate lemma in_union_of_in_second (w : list T) :\n  w ∈ CF_language g₂  →  w ∈ CF_language (union_grammar g₁ g₂)  :=\nbegin\n  intro assum,\n\n  have deri_start :\n    CF_derives\n      (union_grammar g₁ g₂)\n      [symbol.nonterminal none]\n      [symbol.nonterminal (some (sum.inr g₂.initial))],\n  {\n    apply CF_deri_of_tran,\n    use (none, [symbol.nonterminal (some (sum.inr (g₂.initial)))]),\n    split,\n    {\n      change (none, [symbol.nonterminal (some (sum.inr g₂.initial))]) ∈ (\n        (none, [symbol.nonterminal (some (sum.inl (g₁.initial)))]) ::\n        (none, [symbol.nonterminal (some (sum.inr (g₂.initial)))]) ::\n        ((list.map rule_of_rule₁ g₁.rules) ++ (list.map rule_of_rule₂ g₂.rules))\n      ),\n      apply list.mem_cons_of_mem,\n      apply list.mem_cons_self,\n    },\n    use [[], []],\n    simp,\n  },\n\n  have deri_rest :\n    CF_derives\n      (union_grammar g₁ g₂)\n      [symbol.nonterminal (some (sum.inr g₂.initial))]\n      (list.map symbol.terminal w),\n  {\n    have beginning :\n      [symbol.nonterminal (some (sum.inr g₂.initial))] =\n      lsTN_of_lsTN₂ [symbol.nonterminal g₂.initial],\n    {\n      unfold lsTN_of_lsTN₂,\n      change\n        [symbol.nonterminal (some (sum.inr g₂.initial))] =\n        [sTN_of_sTN₂ (symbol.nonterminal g₂.initial)],\n      unfold sTN_of_sTN₂,\n    },\n    have ending :\n      (list.map symbol.terminal w) =\n      lsTN_of_lsTN₂ (list.map symbol.terminal w),\n    {\n      ext1,\n      unfold lsTN_of_lsTN₂,\n      rw [list.nth_map, list.map_map, list.nth_map],\n      apply congr_arg,\n      refl,\n    },\n    rw beginning,\n    rw ending,\n    exact deri₂_more (list.map symbol.terminal w) assum,\n  },\n\n  unfold CF_language,\n  rw set.mem_set_of_eq,\n  unfold CF_generates,\n  unfold CF_generates_str,\n  unfold CF_derives,\n  apply CF_deri_of_deri_deri deri_start,\n  exact deri_rest,\nend\n\nend lemmata_subset\n\n\nsection lemmata_supset\n\nmeta def good_singleton : tactic unit := `[\n  unfold good_string,\n  intros a in_singleton,\n  rw list.mem_singleton at in_singleton,\n  rw in_singleton,\n  unfold good_letter\n]\n\nprivate lemma in_language_left_case_of_union {w : list T}\n    (hypo : CF_derives (union_grammar g₁ g₂)\n      [symbol.nonterminal (some (sum.inl g₁.initial))]\n      (list.map symbol.terminal w)) :\n  w ∈ CF_language g₁ :=\nbegin\n  unfold CF_language,\n  rw set.mem_set_of_eq,\n  unfold CF_generates,\n  unfold CF_generates_str,\n\n  let gg₁ := @g₁g T g₁ g₂,\n\n  have bar :\n    [symbol.nonterminal g₁.initial] =\n    (sink_string gg₁.sink_nt [symbol.nonterminal (some (sum.inl g₁.initial))]),\n  {\n    unfold sink_string,\n    refl,\n  },\n  rw bar,\n\n  have baz : list.map symbol.terminal w = sink_string gg₁.sink_nt (list.map symbol.terminal w),\n  {\n    unfold sink_string,\n    rw list.filter_map_map,\n    change list.map symbol.terminal w = list.filter_map (λ x, (sink_symbol gg₁.sink_nt ∘ symbol.terminal) x) w,\n    convert_to list.map symbol.terminal w = list.filter_map (λ x, option.some (symbol.terminal x)) w,\n    change list.map symbol.terminal w = list.filter_map (option.some ∘ symbol.terminal) w,\n    clear hypo,\n    induction w with d l,\n    {\n      refl,\n    },\n    rw list.map,\n    convert_to\n      symbol.terminal d :: list.map symbol.terminal l =\n      symbol.terminal d :: list.filter_map (some ∘ symbol.terminal) l,\n    norm_num,\n    exact w_ih,\n  },\n  rw baz,\n\n  exact (sink_deri gg₁ [symbol.nonterminal (some (sum.inl g₁.initial))] (list.map symbol.terminal w) hypo (by {\n    good_singleton,\n    use g₁.initial,\n    refl,\n  })).left,\nend\n\nprivate lemma in_language_right_case_of_union {w : list T}\n    (hypo : CF_derives (union_grammar g₁ g₂)\n      [symbol.nonterminal (some (sum.inr g₂.initial))]\n      (list.map symbol.terminal w)) :\n  w ∈ CF_language g₂ :=\nbegin\n  unfold CF_language,\n  rw set.mem_set_of_eq,\n  unfold CF_generates,\n  unfold CF_generates_str,\n\n  let gg₂ := @g₂g T g₁ g₂,\n\n  have bar :\n    [symbol.nonterminal g₂.initial] =\n    (sink_string gg₂.sink_nt [symbol.nonterminal (some (sum.inr g₂.initial))]),\n  {\n    unfold sink_string,\n    refl,\n  },\n  rw bar,\n\n  have baz : list.map symbol.terminal w = sink_string gg₂.sink_nt (list.map symbol.terminal w),\n  {\n    unfold sink_string,\n    rw list.filter_map_map,\n    change list.map symbol.terminal w = list.filter_map (λ x, (sink_symbol gg₂.sink_nt ∘ symbol.terminal) x) w,\n    convert_to list.map symbol.terminal w = list.filter_map (λ x, option.some (symbol.terminal x)) w,\n    change list.map symbol.terminal w = list.filter_map (option.some ∘ symbol.terminal) w,\n    clear hypo,\n    induction w with d l,\n    {\n      refl,\n    },\n    rw list.map,\n    convert_to\n      symbol.terminal d :: list.map symbol.terminal l =\n      symbol.terminal d :: list.filter_map (some ∘ symbol.terminal) l,\n    norm_num,\n    exact w_ih,\n  },\n  rw baz,\n\n  exact (sink_deri gg₂ [symbol.nonterminal (some (sum.inr g₂.initial))] (list.map symbol.terminal w) hypo (by {\n    good_singleton,\n    use g₂.initial,\n    refl,\n  })).left,\nend\n\nprivate lemma both_empty\n    (u v: list (symbol T (union_grammar g₁ g₂).nt))\n    (a : (symbol T (union_grammar g₁ g₂).nt))\n    (bef: [symbol.nonterminal (union_grammar g₁ g₂).initial] = u ++ [a] ++ v) :\n  u = []  ∧  v = [] :=\nbegin\n  have len := congr_arg list.length bef,\n  rw [list.length_singleton, list.length_append, list.length_append, list.length_singleton] at len,\n  split,\n  {\n    by_contradiction,\n    rw ←list.length_eq_zero at h,\n    exact nat.not_succ_le_self 1 (by calc\n      1 = (u.length + 1) + v.length : len\n    ... = u.length + (1 + v.length) : add_assoc (list.length u) 1 (list.length v)\n    ... ≥ 1 + (1 + v.length)        : add_le_add (nat.one_le_iff_ne_zero.mpr h) (le_of_eq rfl)\n    ... = (1 + 1) + v.length        : eq.symm (add_assoc 1 1 (list.length v))\n    ... ≥ 1 + 1 + 0                 : le_self_add\n    ... = 2                         : rfl),\n  },\n  {\n    by_contradiction,\n    rw ←list.length_eq_zero at h,\n    exact nat.not_succ_le_self 1 (by calc\n      1 = (u.length + 1) + v.length : len\n    ... ≥ (u.length + 1) + 1        : add_le_add (le_of_eq rfl) (nat.one_le_iff_ne_zero.mpr h)\n    ... = u.length + (1 + 1)        : add_assoc (list.length u) 1 1\n    ... ≥ 0 + (1 + 1)               : le_add_self\n    ... = (0 + 1) + 1               : eq.symm (add_assoc 0 1 1)\n    ... = 2                         : rfl),\n  },\nend\n\nprivate lemma in_language_impossible_case_of_union\n    (w : list T)\n    (r : (union_grammar g₁ g₂).nt × list (symbol T (union_grammar g₁ g₂).nt))\n    (u v: list (symbol T (union_grammar g₁ g₂).nt))\n    (hu : u = []) (hv : v = [])\n    (bef: [symbol.nonterminal (union_grammar g₁ g₂).initial] = u ++ [symbol.nonterminal r.fst] ++ v)\n    (sbi : r ∈ (list.map rule_of_rule₁ g₁.rules ++ list.map rule_of_rule₂ g₂.rules)) :\n  w ∈ CF_language g₁ ∨ w ∈ CF_language g₂ :=\nbegin\n  exfalso,\n  rw [hu, hv] at bef,\n  rw [list.nil_append, list.append_nil] at bef,\n  change [symbol.nonterminal none] = [symbol.nonterminal r.fst] at bef,\n  have rule_root : r.fst = none,\n  {\n    have almost := list.head_eq_of_cons_eq bef,\n    exact symbol.nonterminal.inj almost.symm,\n  },\n  rw list.mem_append at sbi,\n  cases sbi,\n  {\n    rw list.mem_map at sbi,\n    rcases sbi with ⟨r₁, -, imposs⟩,\n    unfold rule_of_rule₁ at imposs,\n    rw ←imposs at rule_root,\n    unfold prod.fst at rule_root,\n    exact option.no_confusion rule_root,\n  },\n  {\n    rw list.mem_map at sbi,\n    rcases sbi with ⟨r₂, -, imposs⟩,\n    unfold rule_of_rule₂ at imposs,\n    rw ←imposs at rule_root,\n    unfold prod.fst at rule_root,\n    exact option.no_confusion rule_root,\n  },\nend\n\nprivate lemma in_language_of_in_union (w : list T) :\n  w ∈ CF_language (union_grammar g₁ g₂)   →   w ∈ CF_language g₁  ∨  w ∈ CF_language g₂   :=\nbegin\n  intro ass,\n\n  cases CF_tran_or_id_of_deri ass with impossible h,\n  {\n    exfalso,\n    have zeroth := congr_arg (λ p, list.nth p 0) impossible,\n    unfold list.nth at zeroth,\n    rw list.nth_map at zeroth,\n    cases (w.nth 0),\n    {\n      rw option.map_none' at zeroth,\n      exact option.no_confusion zeroth,\n    },\n    {\n      rw option.map_some' at zeroth,\n      exact symbol.no_confusion (option.some.inj zeroth),\n    },\n  },\n  rcases h with ⟨S₁, deri_head, deri_tail⟩,\n  rcases deri_head with ⟨rule, ruleok, u, v, h_bef, h_aft⟩,\n\n  rw h_aft at deri_tail,\n  cases both_empty u v (symbol.nonterminal rule.fst) h_bef with u_nil v_nil,\n\n  cases ruleok with g₁S r_rest,\n  {\n    left,\n    rw g₁S at *,\n    rw u_nil at deri_tail,\n    rw v_nil at deri_tail,\n    rw list.nil_append at deri_tail,\n    exact in_language_left_case_of_union deri_tail,\n  },\n  cases r_rest with g₂S r_imposs,\n  {\n    right,\n    rw g₂S at *,\n    rw u_nil at deri_tail,\n    rw v_nil at deri_tail,\n    rw list.nil_append at deri_tail,\n    exact in_language_right_case_of_union deri_tail,\n  },\n  exact in_language_impossible_case_of_union w rule u v u_nil v_nil h_bef r_imposs,\nend\n\nend lemmata_supset\n\n\n/-- The class of context-free languages is closed under union. -/\ntheorem CF_of_CF_u_CF {T : Type} (L₁ : language T) (L₂ : language T) :\n  is_CF L₁  ∧  is_CF L₂   →   is_CF (L₁ + L₂)   :=\nbegin\n  rintro ⟨⟨g₁, eq_L₁⟩, ⟨g₂, eq_L₂⟩⟩,\n\n  use union_grammar g₁ g₂,\n\n  apply set.eq_of_subset_of_subset,\n  {\n    -- prove `L₁ + L₂ ⊇ `\n    intros w hyp,\n    rw language.mem_add,\n    rw ←eq_L₁,\n    rw ←eq_L₂,\n    exact in_language_of_in_union w hyp,\n  },\n  {\n    -- prove `L₁ + L₂ ⊆ `\n    intros w hyp,\n    cases hyp with case₁ case₂,\n    {\n      rw ←eq_L₁ at case₁,\n      exact in_union_of_in_first w case₁,\n    },\n    {\n      rw ←eq_L₂ at case₂,\n      exact in_union_of_in_second w case₂,\n    },\n  },\nend\n", "meta": {"author": "madvorak", "repo": "grammars", "sha": "5ab26130eb76d5f7cde0f6c2f9c6f3107ff8d34f", "save_path": "github-repos/lean/madvorak-grammars", "path": "github-repos/lean/madvorak-grammars/grammars-5ab26130eb76d5f7cde0f6c2f9c6f3107ff8d34f/src/classes/context_free/closure_properties/union.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45341703342744066}}
{"text": "\nimport pq_to_group\n\nimport tactic\n\nuniverses u v\n\nsection counit_ker_abelian\n\nvariables {G : Type u} [group G]\n\n\nlemma of_inv_group : ∀ x : G, of (x⁻¹) = (of x)⁻¹ :=\nbegin\n  intro x,\n  repeat {rw ←gpow_neg_one},\n  rw of_pow_eq_pow_of,\nend\n\ntheorem inner_aut_eq : ∀ x y : pq_group G, x ▷ y = (of (counit x)) ▷ y :=\nbegin\n  intros x,\n  induction x,\n  {\n    rw quot_mk_helper,\n    induction x,\n    {\n      intro y,\n      rw ←unit_def,\n      apply congr_arg (λ a, a ▷ y),\n      rw monoid_hom.map_one,\n      rw of_1_eq_unit,\n    },\n    {\n      intro y,\n      rw ←of_def,\n      rw counit_of,\n    },\n    {\n      intro y,\n\n      rw counit_mul,\n      rw ←mul_def,\n      \n      rw mul_rhd,\n      rw x_ih_b,\n      rw x_ih_a,\n\n      rw ←mul_rhd,\n      \n\n      induction y,\n      {\n        rw quot_mk_helper at *,\n        induction y,\n        {\n          rw ←unit_def,\n          repeat {rw power_quandle.rhd_one},\n        },\n        {\n          repeat {rw ←of_def at *},\n          rw rhd_def_group,\n          rw rhd_def_group,\n          have halg_rw_1 : ∀ a b c : pq_group G, a*b*c*(a*b)⁻¹ = a*(b*c*b⁻¹)*a⁻¹,\n          {\n            intros a b c,\n            group,\n          },\n          rw halg_rw_1,\n          repeat {rw rhd_eq_conj},\n          rw mul_rhd,\n        },\n        {\n          rw ←mul_def,\n          rw rhd_mul,\n          rw rhd_mul,\n          rw y_ih_a,\n          rw y_ih_b,\n        },\n        {\n          rw ←inv_def,\n          rw rhd_inv,\n          rw y_ih,\n          rw rhd_inv,\n        },\n      },\n      {refl,},\n      \n    },\n    {\n      /-\n      intro y,\n      rw ←inv_def,\n      have hx := x_ih (⟦x_a⟧⁻¹▷⟦x_a⟧⁻¹▷y),\n      rw ←mul_rhd_eq_rhd at hx,\n      simp only [mul_right_inv] at hx,\n      rw one_rhd at hx,\n      rw hx,\n      -/\n      intro y,\n      rw ←inv_def,\n      have hx := x_ih (⟦x_a⟧⁻¹▷y),\n      rw ←mul_rhd at hx,\n      simp only [mul_right_inv] at hx,\n      rw power_quandle.one_rhd at hx,\n      --rw hx,\n      rw monoid_hom.map_inv,\n      rw of_inv_group,\n      rw hx,\n      rw ←mul_rhd ((of _) ⁻¹),\n      simp only [mul_left_inv],\n      rw ←hx,\n      rw power_quandle.one_rhd,\n    }\n  },\n  {intro y, refl,},\nend \n\n\ntheorem counit_ker_center : ∀ a : ((counit : pq_group G →* G).ker), ∀ b : pq_group G, ↑a * b = b * a := \nbegin\n  intros a b,\n  cases a with a ha,\n  simp only [subtype.coe_mk],\n  rw center_reformulate,\n  rw ←rhd_def_group,\n  rw inner_aut_eq,\n  have ha1 : counit a = 1 := ha,\n  rw ha1,\n  rw of_1_eq_unit,\n  rw power_quandle.one_rhd,\nend\n\ntheorem counit_ker_sub_center : ((counit : pq_group G →* G).ker) ≤ subgroup.center (pq_group G) :=\nbegin\n  intros x hx,\n  intro y,\n  apply eq.symm,\n  apply counit_ker_center ⟨x, hx⟩ y,\nend\n\ntheorem counit_ker_abelian : ∀ a b : ((counit : pq_group G →* G).ker), a * b = b * a :=\nbegin\n  intros a b,\n  cases b with b hb,\n  ext1,\n  simp only [subgroup.coe_mul, subtype.coe_mk],\n  apply counit_ker_center,\nend\n\nlemma counit_ker_rhd : ∀ a b : ((counit : pq_group G →* G).ker), a ▷ b = b :=\nbegin \n  intros a b,\n  rw rhd_def_group,\n  rw counit_ker_abelian,\n  group,\nend\n\nlemma counit_ker_abelian_counit (a b : pq_group G) (ha : counit a = 1) : a * b = b * a :=\nbegin\n  suffices : ↑(⟨a, ha⟩ : (counit : pq_group G →* G).ker) * b = b * a,\n  simp only [subtype.coe_mk] at this,\n  exact this,\n  rw counit_ker_center,\n  refl,\nend\n\nlemma counit_ker_counit (a : ((counit : pq_group G →* G).ker)) : counit (↑a : pq_group G) = 1 :=\nbegin\n  cases a with a ha,\n  simp only [subtype.coe_mk],\n  exact ha,\nend\n\nlemma counit_ker_rhd_left_counit (a b : pq_group G) (ha : counit a = 1) : a ▷ b = b :=\nbegin\n  rw rhd_def_group,\n  rw counit_ker_abelian_counit a,\n  simp only [mul_inv_cancel_right],\n  exact ha,\nend\n\nlemma counit_ker_rhd_right_counit (a b : pq_group G) (ha : counit a = 1) : b ▷ a = a :=\nbegin\n  rw rhd_def_group,\n  rw mul_assoc,\n  rw counit_ker_abelian_counit a,\n  simp only [mul_inv_cancel_left],\n  exact ha,\nend\n\n/-\ninstance counit_ker_comm : comm_group ((counit : pq_group G →* G).ker) := {\n  mul_comm := begin\n    exact counit_ker_abelian,\n  end ,\n  ..\n}\n-/\n\nend counit_ker_abelian\n\n\nsection phi_ker\n\nvariables {G : Type u} [group G]\n\n/-\n@[ext]\nstructure deg (G : Type u) [group G] := (g : G)\n\ninstance degen_pq_G : power_quandle (deg G) := { \n  triangle_left := λ x y, x,\n  triangle_right := λ x y, y,\n  right_dist := begin intros a b c, refl, end,\n  left_dist := begin intros a b c, refl, end,\n  right_inv := begin intros a b, refl, end,\n  left_inv := begin intros a b, refl, end,\n  self_idem_right := begin intro a, refl, end,\n  self_idem_left := begin intro a, refl, end,\n  pow := λ x n, ⟨x.g ^ n⟩,\n  pow_1 := begin intro a, cases a, ext, simp only [gpow_one], end,\n  pow_comp := begin intros a n m, cases a, ext, simp only, exact power_quandle.pow_comp a n m, end,\n  q_pow0 := begin intros a b, refl, end,\n  q_pown_right := begin intros a b n, refl, end,\n  q_powneg_left := begin intros a b, refl, end,\n  q_powadd := begin intros a b n m, refl, end }\n\nlemma deg_rhd_def : ∀ a b : (deg G), a ▷ b = b :=\nbegin\n  intros a b,\n  refl,\nend\n\nlemma deg_pow_def : ∀ a : (deg G), ∀ n : ℤ, a ^ n = ⟨a.g ^ n⟩ :=\nbegin\n  intros a n,\n  refl,\nend\n-/\nnotation `kerc` G := (counit : pq_group G →* G).ker\n\n\ndef φ' : G × G → kerc G := λ ⟨x, y⟩, ⟨of x * of y * (of (x*y))⁻¹, begin \n  refine counit.mem_ker.mpr _,\n  repeat {rw monoid_hom.map_mul},\n  rw monoid_hom.map_inv,\n  repeat {rw counit_of},\n  group,\nend⟩ \n\n\ntheorem φ'_is_cocycle : ∀ g h k : G, φ'(g, h) * φ'(g * h, k) = φ'(g, h * k) * φ'(h ,k) :=\nbegin\n  intros g h k,\n  rw counit_ker_abelian (φ' (g, h * k))  (φ' (h, k)),\n  unfold φ',\n  ext1,\n  simp only [subgroup.coe_mul, subgroup.coe_mk],\n  have alg_rw : of h * of k * (of (h * k))⁻¹ * (of g * of (h * k) * (of (g * (h * k)))⁻¹) = (of h * (of k * ((of (h * k))⁻¹ * of g * ((of (h * k))⁻¹)⁻¹) * (of k)⁻¹) * (of h)⁻¹ * of h * of k) * (of (g * (h * k)))⁻¹,\n  {\n    group,\n  },\n  rw alg_rw,\n  clear alg_rw,\n  rw ←rhd_def_group,\n  rw ←rhd_def_group,\n  rw ←rhd_def_group,\n  rw ←mul_assoc g h k,\n  group,\n  rw ←of_pow_eq_pow_of,\n  repeat {rw rhd_of_eq_of_rhd},\n  repeat {rw rhd_def_group},\n  group,\nend\n \n\nend phi_ker\n\n\nsection center_LR_morph\n\nvariables {G : Type u} [group G]\n\n\n\ndef center_LR_morph_fun : subgroup.center (pq_group G) → subgroup.center (G) :=\nbegin\n  intro x,\n  cases x with x hx,\n  fconstructor,\n  exact counit x,\n  intro y,\n  specialize hx (of y),\n  have hx1 := congr_arg counit hx,\n  repeat {rw monoid_hom.map_mul at hx1},\n  repeat {rw counit_of at hx1},\n  exact hx1,\nend\n\n\ndef center_LR_morph : subgroup.center (pq_group G) →* subgroup.center (G) := ⟨center_LR_morph_fun, begin\n  have one_rw : (1 : subgroup.center (pq_group G)) = ⟨1, _⟩ := rfl,\n  rw one_rw,\n  unfold center_LR_morph_fun,\n  ext1,\n  simp only [subgroup.coe_one, subtype.coe_mk, monoid_hom.map_one],\nend, begin \n  intros x y,\n  cases x with x hx,\n  cases y with y hy,\n  have prod_rw : (⟨x, hx⟩ * ⟨y, hy⟩ : subgroup.center (pq_group G)) = ⟨x * y, _⟩ := rfl,\n  rw prod_rw,\n  unfold center_LR_morph_fun,\n  ext1,\n  simp only [monoid_hom.map_mul, subgroup.coe_mul, subtype.coe_mk],\nend⟩\n\n\nnoncomputable theorem counit_ker_iso_center_LR_morph_ker : (counit : pq_group G →* G).ker ≃* (center_LR_morph : subgroup.center (pq_group G) →* subgroup.center (G) ).ker := \nbegin\n  fapply mul_equiv.of_bijective,\n  fconstructor,\n  {\n    intro x,\n    cases x with x hx,\n    fconstructor,\n    fconstructor,\n    exact x,\n\n    apply counit_ker_sub_center,\n    exact hx,\n    ext1,\n    exact hx,\n  },\n  {\n    refl,\n  },\n  {\n    intros x y,\n    cases x with x hx,\n    cases y with y hy,\n    ext1,\n    ext1,\n    have prod_rw : (⟨x, hx⟩ * ⟨y, hy⟩ : ((counit : pq_group G →* G).ker)) = ⟨x * y, _⟩ := rfl,\n    rw prod_rw,\n    simp only [subgroup.coe_mul, subtype.coe_mk],\n  },\n  {\n    split,\n    {\n      simp only [monoid_hom.coe_mk],\n      intros x y,\n      cases x with x hx,\n      cases y with y hy,\n      simp only [imp_self, subtype.mk_eq_mk],\n    },\n    {\n      simp only [monoid_hom.coe_mk],\n      intro x,\n      cases x with x hx,\n      cases x with x hx1,\n      fconstructor,\n      fconstructor,\n      exact x,\n      {\n        have hx2 : center_LR_morph ⟨x, _⟩ = 1 := hx,\n        injections_and_clear,\n        exact h_1,\n      },\n      refl,\n    },\n  }\nend\n\nend center_LR_morph\n", "meta": {"author": "torstein-vik", "repo": "power-quandle-lean", "sha": "452437602c4be2e6c5ad5f5224b068baabfdf9e1", "save_path": "github-repos/lean/torstein-vik-power-quandle-lean", "path": "github-repos/lean/torstein-vik-power-quandle-lean/power-quandle-lean-452437602c4be2e6c5ad5f5224b068baabfdf9e1/src/counit_ker_abelian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45341703342744066}}
{"text": "import Mathlib.Data.Nat.Basic\nimport Mathlib.Init.Algebra.Order\nimport Mathlib.Init.Data.Nat.Basic\nimport Mathlib.Init.Data.Nat.Lemmas\nimport Mathlib.Init.Data.Int.Basic\nimport Mathlib.Data.String.Defs\nimport Mathlib.Data.String.Lemmas\nimport Mathlib.Data.Equiv.Basic\nimport Timelib.Util\nimport Timelib.Date.ScalarDate\nimport Timelib.Date.Convert\nimport Timelib.NanoPrecision.Duration.SignedDuration\nimport Timelib.NanoPrecision.Duration.UnsignedDuration\nimport Timelib.NanoPrecision.ClockTime.NaiveClockTime\nimport Lean.Data.Json\n\n/--\nIf nonnegative, the number of nanoseconds since the epoch (midnight of 0001/Jan/01)\nIf negative, the number of nanoseconds until the epoch (midnight of 0001/Jan/01)\n-/\nstructure NaiveDateTime where\n  nanos : Int\nderiving DecidableEq, Ord, Hashable, Repr, Lean.ToJson, Lean.FromJson\n\ninstance : Inhabited NaiveDateTime where\n  default := ⟨0⟩\n\n/-\nUsing `Int.fdiv`, because we have a positive denominator, and we want to round \ndown if `dt.nanos` is negative, up if it's nonnegative.\n-/\ndef NaiveDateTime.toScalarDate (dt : NaiveDateTime) : ScalarDate := ⟨(dt.nanos.fdiv oneDayNanos) + 1⟩\n\ndef NaiveDateTime.dayOfWeek (dt : NaiveDateTime) : Int := dt.toScalarDate.dayOfWeek\n\n/--\nThe `DateTime` as of midnight (00:00:00 uninterpreted) on the ymd. \nWe subtract one to account for the fact that `Date` is one day ahead of the zero-based `NaiveDateTime`.\n-/\ndef NaiveDateTime.fromYmd \n  (y : Year)\n  (m : Month)\n  (d : Nat)\n  (hd : 1 <= d ∧ d <= m.numDays y := by decide) : NaiveDateTime := \n    ⟨oneDayNanos * ((Ymd.mk y m d hd.left hd.right).toScalarDate.day - 1)⟩ \n\ndef NaiveDateTime.fromYmdsn \n  (y : Year) \n  (m : Month) \n  (d : Nat) \n  (s : Nat)\n  (n : Nat)\n  (hd : 1 <= d ∧ d <= m.numDays y := by decide) : NaiveDateTime := \n    ⟨(NaiveDateTime.fromYmd y m d hd).nanos + (oneSecondNanos * s) + n⟩ \n\ninstance : Equiv Int NaiveDateTime where\n  toFun := NaiveDateTime.mk\n  invFun := NaiveDateTime.nanos\n  left_inv := by simp [Function.LeftInverse]\n  right_inv := by simp [Function.LeftInverse, Function.RightInverse]\n\ntheorem NaiveDateTime.eq_of_val_eq : ∀ {d1 d2 : NaiveDateTime} (h : d1.nanos = d2.nanos), d1 = d2\n| ⟨_⟩, _, rfl => rfl\n\ntheorem NaiveDateTime.val_ne_of_ne : ∀ {d1 d2 : NaiveDateTime} (h : d1 ≠ d2), d1.nanos ≠ d2.nanos\n| ⟨x⟩, ⟨y⟩, h => by intro hh; apply h; exact congrArg NaiveDateTime.mk hh\n\ninstance : LT NaiveDateTime where\n  lt := InvImage Int.lt NaiveDateTime.nanos\n\ninstance : LE NaiveDateTime where\n  le := InvImage Int.le NaiveDateTime.nanos\n  \n@[simp] theorem NaiveDateTime.le_def (d₁ d₂ : NaiveDateTime) : (d₁ <= d₂) = (d₁.nanos <= d₂.nanos) := rfl\n@[simp] theorem NaiveDateTime.lt_def (d₁ d₂ : NaiveDateTime) : (d₁ < d₂) = (d₁.nanos < d₂.nanos) := rfl\n\ninstance instDecidableLENaiveDateTime (d₁ d₂ : NaiveDateTime) : Decidable (d₁ <= d₂) := inferInstanceAs (Decidable <| d₁.nanos <= d₂.nanos)\ninstance instDecidableLTNaiveDateTime (d₁ d₂ : NaiveDateTime) : Decidable (d₁ < d₂) := inferInstanceAs (Decidable <| d₁.nanos < d₂.nanos)\n\ninstance : LinearOrder NaiveDateTime where\n  le_refl (a) := le_refl a.nanos\n  le_trans (a b c) := Int.le_trans\n  lt_iff_le_not_le (a b) := Int.lt_iff_le_not_le\n  le_antisymm (a b h1 h2) := by\n    apply NaiveDateTime.eq_of_val_eq\n    exact le_antisymm h1 h2\n  le_total := by simp [NaiveDateTime.le_def, le_total]\n  decidable_le := inferInstance\n\ndef NaiveDateTime.seconds (d : NaiveDateTime) : Int := d.nanos / oneSecondNanos\n\ndef NaiveDateTime.fromNanos : Int → NaiveDateTime := NaiveDateTime.mk\n\ndef NaiveDateTime.toYmd (d : NaiveDateTime) : Ymd := d.toScalarDate.toYmd\n\ndef NaiveDateTime.year (d : NaiveDateTime) : Year := d.toScalarDate.year\n\ninstance : ToString NaiveDateTime where\n  toString dt :=\n    let ⟨y, m, d, _, _⟩ := dt.toYmd\n    let t : String := ToString.toString <| NaiveClockTime.mk (Fin.ofInt'' (dt.nanos % (↑oneDayNanos)))\n    s!\"{y}/{m.toNat}/{d}; {t}\"\n\n@[reducible]\ndef NaiveDateTime.dateEq : NaiveDateTime → NaiveDateTime → Prop\n| n₁, n₂ => n₁.toScalarDate = n₂.toScalarDate\n\ndef NaiveDateTime.dateEq.Equivalence : Equivalence NaiveDateTime.dateEq := {\n  refl := fun _ => rfl\n  symm := fun h => h.symm\n  trans := fun h h' => Eq.trans h h'\n}\n\ninstance instNaiveDateTimeSetoid : Setoid NaiveDateTime := \n  ⟨NaiveDateTime.dateEq, NaiveDateTime.dateEq.Equivalence⟩\n\ninstance (d₁ d₂ : NaiveDateTime) : Decidable <| d₁.dateEq d₂ := inferInstance\n\ninstance {n : Nat} : OfNat NaiveDateTime n where\n  ofNat := ⟨n⟩\n\ninstance : HAdd NaiveDateTime SignedDuration NaiveDateTime where\n  hAdd da du := ⟨da.nanos + du.val⟩\n\ninstance : HAdd SignedDuration NaiveDateTime NaiveDateTime where\n  hAdd du da := da + du\n\ntheorem NaiveDateTime.hAdd_signed_def (d : NaiveDateTime) (dur : SignedDuration) : d + dur = ⟨d.nanos + dur.val⟩ := rfl\ntheorem NaiveDateTime.hAdd_signed_def_rev (d : NaiveDateTime) (dur : SignedDuration) : dur + d = ⟨d.nanos + dur.val⟩ := rfl\n\ninstance : HSub NaiveDateTime SignedDuration NaiveDateTime where\n  hSub t dur := t + -dur\n\ntheorem NaiveDateTime.hSub_signed_def (d : NaiveDateTime) (dur : SignedDuration) : d - dur = d + -dur := rfl\n\ntheorem NaiveDateTime.hAdd_signed_sub_cancel (t : NaiveDateTime) (d : SignedDuration) : t + d - d = t := by\n  apply NaiveDateTime.eq_of_val_eq\n  simp [NaiveDateTime.hSub_signed_def, NaiveDateTime.hAdd_signed_def]\n  apply Int.add_neg_cancel_right\n\ntheorem NaiveDateTime.hAdd_signed_sub_add_cancel (t : NaiveDateTime) (d : SignedDuration) : t - d + d = t := by\n  simp [NaiveDateTime.hSub_signed_def, NaiveDateTime.hAdd_signed_def]\n  exact NaiveDateTime.eq_of_val_eq (Int.sub_add_cancel t.nanos d.val)\n\ntheorem NaiveDateTime.hAdd_signed_comm (t : NaiveDateTime) (d : SignedDuration) : t + d = d + t := by\n  simp [NaiveDateTime.hAdd_signed_def, NaiveDateTime.hAdd_signed_def_rev]\n\ninstance : HAdd NaiveDateTime UnsignedDuration NaiveDateTime where\n  hAdd da du := ⟨da.nanos + du.val⟩\n\ninstance : HAdd UnsignedDuration NaiveDateTime NaiveDateTime where\n  hAdd du da := da + du\n\ntheorem NaiveDateTime.hAdd_unsigned_def (d : NaiveDateTime) (dur : UnsignedDuration) : d + dur = ⟨d.nanos + dur.val⟩ := rfl\n\ninstance : HSub NaiveDateTime UnsignedDuration NaiveDateTime where\n  hSub da du := ⟨da.nanos - du.val⟩\n\ntheorem NaiveDateTime.hSub_unsigned_def (d : NaiveDateTime) (dur : UnsignedDuration) : d - dur = ⟨d.nanos - dur.val⟩ := rfl\n\ntheorem NaiveDateTime.hAdd_unsigned_sub_cancel (t : NaiveDateTime) (d : UnsignedDuration) : t + d - d = t := NaiveDateTime.hAdd_signed_sub_cancel t d\n\ntheorem NaiveDateTime.hAdd_unsigned_sub_add_cancel (t : NaiveDateTime) (d : UnsignedDuration) : t - d + d = t := NaiveDateTime.hAdd_signed_sub_add_cancel t d\n\ntheorem NaiveDateTime.hAdd_unsigned_comm (t : NaiveDateTime) (d : UnsignedDuration) : t + d = d + t := NaiveDateTime.hAdd_signed_comm t d\n\n/--\nSet the clock time of the current day to `tgt`.\n-/\n@[reducible]\ndef NaiveDateTime.setClockTime (t : NaiveDateTime) (clockTime : NaiveClockTime) : NaiveDateTime :=\n  let days := (t.nanos.fdiv oneDayNanos) * oneDayNanos\n  ⟨days + clockTime.nanos.val⟩\n\n", "meta": {"author": "ammkrn", "repo": "timelib", "sha": "185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15", "save_path": "github-repos/lean/ammkrn-timelib", "path": "github-repos/lean/ammkrn-timelib/timelib-185e8ea7c8b4274f2cb7ecba4c2e785c6e97cf15/Timelib/NanoPrecision/DateTime/NaiveDateTime.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7371581626286833, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45341703342744055}}
{"text": "import morphisms.closed_immersion\nimport for_mathlib.field\nimport topology.local_at_target\n\nopen opposite category_theory category_theory.limits topological_space\n\nnoncomputable theory\n\nnamespace algebraic_geometry\n\nsection fiber\n\nuniverse u\n\nvariables {X Y : Scheme.{u}}\n\nabbreviation Scheme.stalk_residue (X : Scheme) (x : X.carrier) :\n  X.stalk x ⟶ X.residue_field x :=\nlocal_ring.residue _ \n\nlemma is_iso_to_stalk_residue {R : Type*} [field R] (x) : \n  is_iso (structure_sheaf.to_stalk R x ≫ (Scheme.Spec.obj $ op $ CommRing.of R).stalk_residue _) :=\nbegin\n  apply_with (is_iso_of_reflects_iso _ (forget $ CommRing)) { instances := ff },\n  rw is_iso_iff_bijective,\n  refine ⟨ring_hom.injective _, _⟩,\n  intro y,\n  obtain ⟨y' : (Spec.structure_sheaf R).presheaf.stalk x, rfl⟩ := ideal.quotient.mk_surjective y,\n  obtain ⟨y : R, s, rfl⟩ := is_localization.mk'_surjective x.as_ideal.prime_compl y',\n  have : (s : R) ≠ 0 := λ e, s.prop (e.symm ▸ x.as_ideal.zero_mem),\n  refine ⟨(y/s : _), _⟩,\n  change ideal.quotient.mk _ _ = _,\n  congr' 1,\n  apply is_localization.eq_mk'_iff_mul_eq.mpr,\n  refine ((map_mul _ _ _).symm.trans _),\n  rw div_mul_cancel _ this,\n  refl\nend\n.\ninstance (X : Scheme) (x) : epi (X.stalk_residue x) :=\nbegin\n  refine (forget _).epi_of_epi_map _,\n  rw epi_iff_surjective,\n  exact ideal.quotient.mk_surjective\nend\n\n@[simp, reassoc]\nlemma Scheme.stalk_residue_eq (X : Scheme) {x y : X.carrier} (e : x = y) : \n  X.stalk_residue y ≫ X.residue_field_of_eq e =\n    X.presheaf.stalk_specializes (specializes_of_eq e) ≫ X.stalk_residue x := rfl\n\n@[simp, reassoc]\nlemma Scheme.stalk_residue_map {X Y : Scheme} (f : X ⟶ Y) {x : X.carrier} : \n  Y.stalk_residue _ ≫ f.map_residue_field x = PresheafedSpace.stalk_map f.1 x ≫ X.stalk_residue x :=\nrfl\n\nlemma is_affine.hom_ext {X Y : Scheme} [is_affine Y] (f g : X ⟶ Y) (e : Scheme.Γ.map f.op = Scheme.Γ.map g.op) :\n  f = g :=\nbegin\n  rw [← cancel_mono (Γ_Spec.adjunction.unit.app Y), ← Γ_Spec.adjunction.unit_naturality f, ← Γ_Spec.adjunction.unit_naturality g,\n    functor.right_op_map, functor.right_op_map, e],\nend\n\nlemma is_affine_open.from_Spec_of_affine {R : CommRing} {U : opens (Scheme.Spec.obj $ op R).carrier} (h : is_affine_open U) :\n  h.from_Spec = Scheme.Spec.map (eq_to_hom (by unfreezingI { cases R, refl }) ≫ structure_sheaf.to_open R U).op :=\nbegin\n  apply is_affine.hom_ext,\n  delta is_affine_open.from_Spec Scheme.iso_Spec,\n  haveI : is_affine _ := h,\n  have := @adjunction.left_triangle_components _ _ _ _ _ _ Γ_Spec.adjunction ((Scheme.Spec.obj (op R)).restrict U.open_embedding),\n  rw [functor.right_op_map, ← quiver.hom.unop_inj.eq_iff, unop_comp, quiver.hom.unop_op] at this,\n  have := is_iso.eq_inv_of_inv_hom_id this,\n  apply quiver.hom.op_inj,\n  simp only [quiver.hom.op_unop, functor.map_inv, op_inv, as_iso_inv, op_comp, category.assoc, functor.map_comp, unop_comp, ← this],\n  erw Γ_Spec.adjunction.counit_naturality_assoc,\n  rw [← is_iso.comp_inv_eq, ← cancel_mono (Γ_Spec.adjunction.counit.app $ op $ CommRing.of R)],\n  conv_rhs { erw (Γ_Spec.adjunction.counit_naturality (structure_sheaf.to_open R U).op) },\n  simp_rw [category.assoc],\n  congr' 1,\n  unfreezingI { cases R },\n  slice_lhs 3 3 { simp only [eq_to_hom_op, eq_to_hom_map Scheme.Spec, eq_to_hom_map Scheme.Γ, inv_eq_to_hom] },\n  apply quiver.hom.unop_inj,\n  simp only [algebraic_geometry.Γ_Spec.LocallyRingedSpace_adjunction_counit, nat_trans.op_app, quiver.hom.unop_op,\n    unop_inv, Scheme.Spec_map_2, Scheme.Γ_map, Spec_Γ_identity_inv_app, category.assoc,\n    Γ_Spec.adjunction_counit_app, unop_comp, eq_to_hom_refl, to_Spec_Γ, is_iso.inv_id],\n  dsimp,\n  rw [category.id_comp, reassoc_of structure_sheaf.to_open_res, structure_sheaf.to_open_res]\nend\n\n@[elementwise, reassoc]\nlemma Scheme.from_Spec_residue_field_map_residue_field {X : Scheme} (x) (s)  : \n  X.residue_field_of_eq (Scheme.from_Spec_residue_field_base _ _)  ≫ \n    (X.from_Spec_residue_field x).map_residue_field s = structure_sheaf.to_stalk _ s ≫\n    (Scheme.Spec.obj _).stalk_residue _ :=\nbegin\n  apply quiver.hom.op_inj,\n  apply Scheme.Spec.map_injective,\n  rw [pullback.triplet.eq_from_Spec_residue_field_aux, Scheme.from_Spec_residue_field, op_comp, functor.map_comp],\n  congr' 1,\n  rw [← (top_is_affine_open _).from_Spec_stalk_eq],\n  rotate, { trivial }, { apply_instance },\n  delta is_affine_open.from_Spec_stalk structure_sheaf.to_stalk,\n  rw [op_comp, functor.map_comp, is_affine_open.from_Spec_of_affine],\n  refl\nend\n\n@[instance]\nlemma is_iso_from_Spec_residue_field_map_residue {X : Scheme} (x) (s) :\n  is_iso ((X.from_Spec_residue_field x).map_residue_field s) :=\nbegin\n  apply_with (is_iso_of_reflects_iso _ (forget $ CommRing)) { instances := ff },\n  rw is_iso_iff_bijective,\n  refine ⟨ring_hom.injective _, _⟩,\n  intro y,\n  obtain ⟨y' : (Spec.structure_sheaf _).presheaf.stalk s, rfl⟩ := ideal.quotient.mk_surjective y,\n  obtain ⟨y, rfl⟩ : ∃ y : X.residue_field x, structure_sheaf.to_stalk _ s y = y',\n  { obtain ⟨y : X.residue_field x, t, rfl⟩ := is_localization.mk'_surjective s.as_ideal.prime_compl y',\n    refine ⟨y/t.1, _⟩,\n    apply is_localization.eq_mk'_iff_mul_eq.mpr,\n    refine (map_mul _ _ _).symm.trans _,\n    rw [subtype.val_eq_coe, div_mul_cancel],\n    exacts [rfl, λ e, t.prop (e.symm ▸ s.as_ideal.zero_mem)] },\n  refine ⟨X.residue_field_of_eq (Scheme.from_Spec_residue_field_base _ _) y, _⟩,\n  refine (Scheme.from_Spec_residue_field_map_residue_field_apply x s y).trans _,\n  refl\nend\n\ninstance {X : Scheme} {x y} (e : x = y) : is_iso (X.residue_field_of_eq e) :=\n⟨⟨X.residue_field_of_eq e.symm, by simp, by simp⟩⟩\n\ndef Scheme.hom.fiber (f : X ⟶ Y) (y : Y.carrier) : Scheme :=\npullback f (Y.from_Spec_residue_field y)\n\n@[derive is_preimmersion]\ndef Scheme.hom.fiber_ι (f : X ⟶ Y) (y : Y.carrier) : f.fiber y ⟶ X :=\npullback.fst\n\ndef Scheme.hom.fiber_to_residue_field (f : X ⟶ Y) (y : Y.carrier) :\n  f.fiber y ⟶ Scheme.Spec.obj (op $ Y.residue_field y) :=\npullback.snd\n\ndef Scheme.hom.fiber_residue_field_tensor_iso (f : X ⟶ Y) (y : Y.carrier)\n  (T : pullback.triplet f (Y.from_Spec_residue_field y)) : \n  T.residue_field_tensor ≅ X.residue_field T.x :=\n(as_iso pushout.inl).symm\n\ninstance (f : X ⟶ Y) (y : Y.carrier)\n  (T : pullback.triplet f (Y.from_Spec_residue_field y)) : \n  field T.residue_field_tensor :=\n(f.fiber_residue_field_tensor_iso y T).CommRing_iso_to_ring_equiv.symm.is_field.to_field\n\ndef Scheme.hom.fiber_carrier (f : X ⟶ Y) (y : Y.carrier) :\n  (f.fiber y).carrier ≃ₜ { x : X.carrier // f.1.base x = y } :=\nbegin\n  refine (homeomorph.of_embedding _ (is_preimmersion.base_embedding $ f.fiber_ι y)).trans\n    (homeomorph.set_congr _),\n  ext x,\n  rw [Scheme.hom.fiber_ι, pullback.range_fst, Scheme.range_from_Spec_residue_field],\n  exact set.mem_singleton_iff\nend \n\n@[simp]\nlemma Scheme.hom.fiber_carrier_apply (f : X ⟶ Y) (y : Y.carrier) (x) :\n  (f.fiber_carrier y x : X.carrier) = (f.fiber_ι y).1.base x := rfl\n\nlemma Scheme.hom.fiber_ι_coe (f : X ⟶ Y) (y : Y.carrier) :\n  ⇑(f.fiber_ι y).1.base = (coe ∘ (f.fiber_carrier y) : _ → X.carrier) :=\nfunext $ λ x, (f.fiber_carrier_apply y x).symm\n\nlemma Scheme.hom.range_fiber_ι (f : X ⟶ Y) (y : Y.carrier) :\n  set.range (f.fiber_ι y).1.base = f.1.base ⁻¹' {y} :=\nbegin\n  rw [Scheme.hom.fiber_ι_coe, set.range_comp, set.range_iff_surjective.mpr\n    (f.fiber_carrier y).surjective, set.image_univ, subtype.range_coe],\n  ext, rw [set.mem_preimage, set.mem_singleton_iff], refl,\nend\n\ndef Scheme.hom.Spec_residue_field_to_fiber (f : X ⟶ Y) (x : X.carrier) : \n  Scheme.Spec.obj (op $ X.residue_field x) ⟶ f.fiber (f.1.base x) :=\npullback.lift _ _ (f.map_residue_field_from_Spec_residue_field x).symm\n\n@[simp, reassoc]\nlemma Scheme.hom.Spec_residue_field_to_fiber_ι (f : X ⟶ Y) (x : X.carrier) : \n  f.Spec_residue_field_to_fiber x ≫ f.fiber_ι _ = X.from_Spec_residue_field x :=\npullback.lift_fst _ _ _\n\n@[simp, reassoc]\nlemma Scheme.hom.Spec_residue_field_to_fiber_to_residue_field (f : X ⟶ Y) (x : X.carrier) : \n  f.Spec_residue_field_to_fiber x ≫ f.fiber_to_residue_field _ =\n    Scheme.Spec.map (f.map_residue_field x).op :=\npullback.lift_snd _ _ _\n\ninstance (f : X ⟶ Y) (x : X.carrier) : is_preimmersion (f.Spec_residue_field_to_fiber x) :=\nbegin\n  haveI H : is_preimmersion (X.from_Spec_residue_field x) := infer_instance,\n  rw ← f.Spec_residue_field_to_fiber_ι at H,\n  exact @@is_preimmersion.of_comp _ _ H\nend\n\nend fiber\n\nend algebraic_geometry\n", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/algebraic_geometry/fiber.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4534122835983339}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.nat.factorial\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# Binomial coefficients\n\nThis file contains a definition of binomial coefficients and simple lemmas (i.e. those not\nrequiring more imports).\n\n## Main definition and results\n\n- `nat.choose`: binomial coefficients, defined inductively\n- `nat.choose_eq_factorial_div_factorial`: a proof that `choose n k = n! / (k! * (n - k)!)`\n- `nat.choose_symm`: symmetry of binomial coefficients\n- `nat.choose_le_succ_of_lt_half_left`: `choose n k` is increasing for small values of `k`\n- `nat.choose_le_middle`: `choose n r` is maximised when `r` is `n/2`\n\n-/\n\nnamespace nat\n\n\n/-- `choose n k` is the number of `k`-element subsets in an `n`-element set. Also known as binomial\ncoefficients. -/\ndef choose : ℕ → ℕ → ℕ :=\n  sorry\n\n@[simp] theorem choose_zero_right (n : ℕ) : choose n 0 = 1 :=\n  nat.cases_on n (Eq.refl (choose 0 0)) fun (n : ℕ) => Eq.refl (choose (Nat.succ n) 0)\n\n@[simp] theorem choose_zero_succ (k : ℕ) : choose 0 (Nat.succ k) = 0 :=\n  rfl\n\ntheorem choose_succ_succ (n : ℕ) (k : ℕ) : choose (Nat.succ n) (Nat.succ k) = choose n k + choose n (Nat.succ k) :=\n  rfl\n\ntheorem choose_eq_zero_of_lt {n : ℕ} {k : ℕ} : n < k → choose n k = 0 := sorry\n\n@[simp] theorem choose_self (n : ℕ) : choose n n = 1 := sorry\n\n@[simp] theorem choose_succ_self (n : ℕ) : choose n (Nat.succ n) = 0 :=\n  choose_eq_zero_of_lt (lt_succ_self n)\n\n@[simp] theorem choose_one_right (n : ℕ) : choose n 1 = n := sorry\n\n/- The `n+1`-st triangle number is `n` more than the `n`-th triangle number -/\n\ntheorem triangle_succ (n : ℕ) : (n + 1) * (n + 1 - 1) / bit0 1 = n * (n - 1) / bit0 1 + n := sorry\n\n/-- `choose n 2` is the `n`-th triangle number. -/\ntheorem choose_two_right (n : ℕ) : choose n (bit0 1) = n * (n - 1) / bit0 1 := sorry\n\ntheorem choose_pos {n : ℕ} {k : ℕ} : k ≤ n → 0 < choose n k := sorry\n\ntheorem succ_mul_choose_eq (n : ℕ) (k : ℕ) : Nat.succ n * choose n k = choose (Nat.succ n) (Nat.succ k) * Nat.succ k := sorry\n\ntheorem choose_mul_factorial_mul_factorial {n : ℕ} {k : ℕ} : k ≤ n → choose n k * factorial k * factorial (n - k) = factorial n := sorry\n\ntheorem choose_eq_factorial_div_factorial {n : ℕ} {k : ℕ} (hk : k ≤ n) : choose n k = factorial n / (factorial k * factorial (n - k)) := sorry\n\ntheorem factorial_mul_factorial_dvd_factorial {n : ℕ} {k : ℕ} (hk : k ≤ n) : factorial k * factorial (n - k) ∣ factorial n := sorry\n\n@[simp] theorem choose_symm {n : ℕ} {k : ℕ} (hk : k ≤ n) : choose n (n - k) = choose n k := sorry\n\ntheorem choose_symm_of_eq_add {n : ℕ} {a : ℕ} {b : ℕ} (h : n = a + b) : choose n a = choose n b := sorry\n\ntheorem choose_symm_add {a : ℕ} {b : ℕ} : choose (a + b) a = choose (a + b) b :=\n  choose_symm_of_eq_add rfl\n\ntheorem choose_symm_half (m : ℕ) : choose (bit0 1 * m + 1) (m + 1) = choose (bit0 1 * m + 1) m := sorry\n\ntheorem choose_succ_right_eq (n : ℕ) (k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := sorry\n\n@[simp] theorem choose_succ_self_right (n : ℕ) : choose (n + 1) n = n + 1 := sorry\n\ntheorem choose_mul_succ_eq (n : ℕ) (k : ℕ) : choose n k * (n + 1) = choose (n + 1) k * (n + 1 - k) := sorry\n\n/-! ### Inequalities -/\n\n/-- Show that `nat.choose` is increasing for small values of the right argument. -/\ntheorem choose_le_succ_of_lt_half_left {r : ℕ} {n : ℕ} (h : r < n / bit0 1) : choose n r ≤ choose n (r + 1) := sorry\n\n/-- Show that for small values of the right argument, the middle value is largest. -/\n/-- `choose n r` is maximised when `r` is `n/2`. -/\ntheorem choose_le_middle (r : ℕ) (n : ℕ) : choose n r ≤ choose n (n / bit0 1) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/nat/choose/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7461390043208003, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.45340119250153516}}
{"text": "/-\nCopyright (c) 2021 OpenAI. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f\n-/\nimport mathzoo.imports.miniF2F\n\nopen_locale nat rat real big_operators topological_space\n\ntheorem algebra_2rootsintpoly_am10tap11eqasqpam110\n  (a : ℂ) :\n  (a - 10) * (a + 11) = a^2 + a - 110 :=\nbegin\n  ring,\nend", "meta": {"author": "leanprover-community", "repo": "mathzoo", "sha": "87e9b492daeb929838706942aaa2437621b34a0e", "save_path": "github-repos/lean/leanprover-community-mathzoo", "path": "github-repos/lean/leanprover-community-mathzoo/mathzoo-87e9b492daeb929838706942aaa2437621b34a0e/src/mathzoo/misc/miniF2F/algebra/2rootsintpoly_am10tap11eqasqpam110.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744584140004, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.45332089009658033}}
{"text": "/-\nCopyright (c) 2014 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\n! This file was ported from Lean 3 source module data.nat.cast.prod\n! leanprover-community/mathlib commit 448144f7ae193a8990cb7473c9e9a01990f64ac7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Data.Nat.Cast.Basic\nimport Mathbin.Algebra.Group.Prod\n\n/-!\n# The product of two `add_monoid_with_one`s.\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\n\nvariable {α β : Type _}\n\nnamespace Prod\n\nvariable [AddMonoidWithOne α] [AddMonoidWithOne β]\n\ninstance : AddMonoidWithOne (α × β) :=\n  { Prod.addMonoid, Prod.hasOne with\n    natCast := fun n => (n, n)\n    natCast_zero := congr_arg₂ Prod.mk Nat.cast_zero Nat.cast_zero\n    natCast_succ := fun n => congr_arg₂ Prod.mk (Nat.cast_succ _) (Nat.cast_succ _) }\n\n/- warning: prod.fst_nat_cast -> Prod.fst_natCast is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : AddMonoidWithOne.{u1} α] [_inst_2 : AddMonoidWithOne.{u2} β] (n : Nat), Eq.{succ u1} α (Prod.fst.{u1, u2} α β ((fun (a : Type) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{1, max (succ u1) (succ u2)} a b] => self.0) Nat (Prod.{u1, u2} α β) (HasLiftT.mk.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} α β) (CoeTCₓ.coe.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} α β) (Nat.castCoe.{max u1 u2} (Prod.{u1, u2} α β) (AddMonoidWithOne.toNatCast.{max u1 u2} (Prod.{u1, u2} α β) (Prod.addMonoidWithOne.{u1, u2} α β _inst_1 _inst_2))))) n)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α _inst_1)))) n)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : AddMonoidWithOne.{u2} α] [_inst_2 : AddMonoidWithOne.{u1} β] (n : Nat), Eq.{succ u2} α (Prod.fst.{u2, u1} α β (Nat.cast.{max u2 u1} (Prod.{u2, u1} α β) (AddMonoidWithOne.toNatCast.{max u2 u1} (Prod.{u2, u1} α β) (Prod.instAddMonoidWithOneProd.{u2, u1} α β _inst_1 _inst_2)) n)) (Nat.cast.{u2} α (AddMonoidWithOne.toNatCast.{u2} α _inst_1) n)\nCase conversion may be inaccurate. Consider using '#align prod.fst_nat_cast Prod.fst_natCastₓ'. -/\n@[simp]\ntheorem fst_natCast (n : ℕ) : (n : α × β).fst = n := by induction n <;> simp [*]\n#align prod.fst_nat_cast Prod.fst_natCast\n\n/- warning: prod.snd_nat_cast -> Prod.snd_natCast is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : AddMonoidWithOne.{u1} α] [_inst_2 : AddMonoidWithOne.{u2} β] (n : Nat), Eq.{succ u2} β (Prod.snd.{u1, u2} α β ((fun (a : Type) (b : Sort.{max (succ u1) (succ u2)}) [self : HasLiftT.{1, max (succ u1) (succ u2)} a b] => self.0) Nat (Prod.{u1, u2} α β) (HasLiftT.mk.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} α β) (CoeTCₓ.coe.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} α β) (Nat.castCoe.{max u1 u2} (Prod.{u1, u2} α β) (AddMonoidWithOne.toNatCast.{max u1 u2} (Prod.{u1, u2} α β) (Prod.addMonoidWithOne.{u1, u2} α β _inst_1 _inst_2))))) n)) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat β (HasLiftT.mk.{1, succ u2} Nat β (CoeTCₓ.coe.{1, succ u2} Nat β (Nat.castCoe.{u2} β (AddMonoidWithOne.toNatCast.{u2} β _inst_2)))) n)\nbut is expected to have type\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : AddMonoidWithOne.{u1} α] [_inst_2 : AddMonoidWithOne.{u2} β] (n : Nat), Eq.{succ u2} β (Prod.snd.{u1, u2} α β (Nat.cast.{max u1 u2} (Prod.{u1, u2} α β) (AddMonoidWithOne.toNatCast.{max u1 u2} (Prod.{u1, u2} α β) (Prod.instAddMonoidWithOneProd.{u1, u2} α β _inst_1 _inst_2)) n)) (Nat.cast.{u2} β (AddMonoidWithOne.toNatCast.{u2} β _inst_2) n)\nCase conversion may be inaccurate. Consider using '#align prod.snd_nat_cast Prod.snd_natCastₓ'. -/\n@[simp]\ntheorem snd_natCast (n : ℕ) : (n : α × β).snd = n := by induction n <;> simp [*]\n#align prod.snd_nat_cast Prod.snd_natCast\n\nend Prod\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Nat/Cast/Prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4533158582507994}}
{"text": "/-\nCopyright (c) 2020 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Robert Y. Lewis\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.matrix.notation\nimport Mathlib.field_theory.mv_polynomial\nimport Mathlib.field_theory.finite.polynomial\nimport Mathlib.number_theory.basic\nimport Mathlib.ring_theory.witt_vector.witt_polynomial\nimport Mathlib.PostPort\n\nuniverses u_2 u_1 \n\nnamespace Mathlib\n\n/-!\n# Witt structure polynomials\n\nIn this file we prove the main theorem that makes the whole theory of Witt vectors work.\nBriefly, consider a polynomial `Φ : mv_polynomial idx ℤ` over the integers,\nwith polynomials variables indexed by an arbitrary type `idx`.\n\nThen there exists a unique family of polynomials `φ : ℕ → mv_polynomial (idx × ℕ) Φ`\nsuch that for all `n : ℕ` we have (`witt_structure_int_exists_unique`)\n```\nbind₁ φ (witt_polynomial p ℤ n) = bind₁ (λ i, (rename (prod.mk i) (witt_polynomial p ℤ n))) Φ\n```\nIn other words: evaluating the `n`-th Witt polynomial on the family `φ`\nis the same as evaluating `Φ` on the (appropriately renamed) `n`-th Witt polynomials.\n\nN.b.: As far as we know, these polynomials do not have a name in the literature,\nso we have decided to call them the “Witt structure polynomials”. See `witt_structure_int`.\n\n## Special cases\n\nWith the main result of this file in place, we apply it to certain special polynomials.\nFor example, by taking `Φ = X tt + X ff` resp. `Φ = X tt * X ff`\nwe obtain families of polynomials `witt_add` resp. `witt_mul`\n(with type `ℕ → mv_polynomial (bool × ℕ) ℤ`) that will be used in later files to define the\naddition and multiplication on the ring of Witt vectors.\n\n## Outline of the proof\n\nThe proof of `witt_structure_int_exists_unique` is rather technical, and takes up most of this file.\n\nWe start by proving the analogous version for polynomials with rational coefficients,\ninstead of integer coefficients.\nIn this case, the solution is rather easy,\nsince the Witt polynomials form a faithful change of coordinates\nin the polynomial ring `mv_polynomial ℕ ℚ`.\nWe therefore obtain a family of polynomials `witt_structure_rat Φ`\nfor every `Φ : mv_polynomial idx ℚ`.\n\nIf `Φ` has integer coefficients, then the polynomials `witt_structure_rat Φ n` do so as well.\nProving this claim is the essential core of this file, and culminates in\n`map_witt_structure_int`, which proves that upon mapping the coefficients\nof `witt_structure_int Φ n` from the integers to the rationals,\none obtains `witt_structure_rat Φ n`.\nUltimately, the proof of `map_witt_structure_int` relies on\n```\ndvd_sub_pow_of_dvd_sub {R : Type*} [comm_ring R] {p : ℕ} {a b : R} :\n    (p : R) ∣ a - b → ∀ (k : ℕ), (p : R) ^ (k + 1) ∣ a ^ p ^ k - b ^ p ^ k\n```\n\n## Main results\n\n* `witt_structure_rat Φ`: the family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℚ`\n  associated with `Φ : mv_polynomial idx ℚ` and satisfying the property explained above.\n* `witt_structure_rat_prop`: the proof that `witt_structure_rat` indeed satisfies the property.\n* `witt_structure_int Φ`: the family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℤ`\n  associated with `Φ : mv_polynomial idx ℤ` and satisfying the property explained above.\n* `map_witt_structure_int`: the proof that the integral polynomials `with_structure_int Φ`\n  are equal to `witt_structure_rat Φ` when mapped to polynomials with rational coefficients.\n* `witt_structure_int_prop`: the proof that `witt_structure_int` indeed satisfies the property.\n* Five families of polynomials that will be used to define the ring structure\n  on the ring of Witt vectors:\n  - `witt_vector.witt_zero`\n  - `witt_vector.witt_one`\n  - `witt_vector.witt_add`\n  - `witt_vector.witt_mul`\n  - `witt_vector.witt_neg`\n  (We also define `witt_vector.witt_sub`, and later we will prove that it describes subtraction,\n  which is defined as `λ a b, a + -b`. See `witt_vector.sub_coeff` for this proof.)\n\n-/\n\n-- This lemma reduces a bundled morphism to a \"mere\" function,\n\n-- and consequently the simplifier cannot use a lot of powerful simp-lemmas.\n\n-- We disable this locally, and probably it should be disabled globally in mathlib.\n\n/-- `witt_structure_rat Φ` is a family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℚ`\nthat are uniquely characterised by the property that\n```\nbind₁ (witt_structure_rat p Φ) (witt_polynomial p ℚ n) =\nbind₁ (λ i, (rename (prod.mk i) (witt_polynomial p ℚ n))) Φ\n```\nIn other words: evaluating the `n`-th Witt polynomial on the family `witt_structure_rat Φ`\nis the same as evaluating `Φ` on the (appropriately renamed) `n`-th Witt polynomials.\n\nSee `witt_structure_rat_prop` for this property,\nand `witt_structure_rat_exists_unique` for the fact that `witt_structure_rat`\ngives the unique family of polynomials with this property.\n\nThese polynomials turn out to have integral coefficients,\nbut it requires some effort to show this.\nSee `witt_structure_int` for the version with integral coefficients,\nand `map_witt_structure_int` for the fact that it is equal to `witt_structure_rat`\nwhen mapped to polynomials over the rationals. -/\ndef witt_structure_rat (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℚ) (n : ℕ) : mv_polynomial (idx × ℕ) ℚ :=\n  coe_fn\n    (mv_polynomial.bind₁\n      fun (k : ℕ) =>\n        coe_fn (mv_polynomial.bind₁ fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p ℚ k)) Φ)\n    (X_in_terms_of_W p ℚ n)\n\ntheorem witt_structure_rat_prop (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℚ) (n : ℕ) : coe_fn (mv_polynomial.bind₁ (witt_structure_rat p Φ)) (witt_polynomial p ℚ n) =\n  coe_fn (mv_polynomial.bind₁ fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p ℚ n)) Φ := sorry\n\ntheorem witt_structure_rat_exists_unique (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℚ) : exists_unique\n  fun (φ : ℕ → mv_polynomial (idx × ℕ) ℚ) =>\n    ∀ (n : ℕ),\n      coe_fn (mv_polynomial.bind₁ φ) (witt_polynomial p ℚ n) =\n        coe_fn (mv_polynomial.bind₁ fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p ℚ n))\n          Φ := sorry\n\ntheorem witt_structure_rat_rec_aux (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℚ) (n : ℕ) : witt_structure_rat p Φ n * coe_fn mv_polynomial.C (↑p ^ n) =\n  coe_fn\n      (mv_polynomial.bind₁ fun (b : idx) => coe_fn (mv_polynomial.rename fun (i : ℕ) => (b, i)) (witt_polynomial p ℚ n))\n      Φ -\n    finset.sum (finset.range n) fun (i : ℕ) => coe_fn mv_polynomial.C (↑p ^ i) * witt_structure_rat p Φ i ^ p ^ (n - i) := sorry\n\n/-- Write `witt_structure_rat p φ n` in terms of `witt_structure_rat p φ i` for `i < n`. -/\ntheorem witt_structure_rat_rec (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℚ) (n : ℕ) : witt_structure_rat p Φ n =\n  coe_fn mv_polynomial.C (1 / ↑p ^ n) *\n    (coe_fn\n        (mv_polynomial.bind₁\n          fun (b : idx) => coe_fn (mv_polynomial.rename fun (i : ℕ) => (b, i)) (witt_polynomial p ℚ n))\n        Φ -\n      finset.sum (finset.range n)\n        fun (i : ℕ) => coe_fn mv_polynomial.C (↑p ^ i) * witt_structure_rat p Φ i ^ p ^ (n - i)) := sorry\n\n/-- `witt_structure_int Φ` is a family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℚ`\nthat are uniquely characterised by the property that\n```\nbind₁ (witt_structure_int p Φ) (witt_polynomial p ℚ n) =\nbind₁ (λ i, (rename (prod.mk i) (witt_polynomial p ℚ n))) Φ\n```\nIn other words: evaluating the `n`-th Witt polynomial on the family `witt_structure_int Φ`\nis the same as evaluating `Φ` on the (appropriately renamed) `n`-th Witt polynomials.\n\nSee `witt_structure_int_prop` for this property,\nand `witt_structure_int_exists_unique` for the fact that `witt_structure_int`\ngives the unique family of polynomials with this property. -/\ndef witt_structure_int (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (n : ℕ) : mv_polynomial (idx × ℕ) ℤ :=\n  finsupp.map_range rat.num sorry (witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) Φ) n)\n\ntheorem bind₁_rename_expand_witt_polynomial {p : ℕ} {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (n : ℕ) (IH : ∀ (m : ℕ),\n  m < n + 1 →\n    coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) (witt_structure_int p Φ m) =\n      witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) Φ) m) : coe_fn\n    (mv_polynomial.bind₁\n      fun (b : idx) =>\n        coe_fn (mv_polynomial.rename fun (i : ℕ) => (b, i)) (coe_fn (mv_polynomial.expand p) (witt_polynomial p ℤ n)))\n    Φ =\n  coe_fn (mv_polynomial.bind₁ fun (i : ℕ) => coe_fn (mv_polynomial.expand p) (witt_structure_int p Φ i))\n    (witt_polynomial p ℤ n) := sorry\n\ntheorem C_p_pow_dvd_bind₁_rename_witt_polynomial_sub_sum {p : ℕ} {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (n : ℕ) (IH : ∀ (m : ℕ),\n  m < n →\n    coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) (witt_structure_int p Φ m) =\n      witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) Φ) m) : coe_fn mv_polynomial.C ↑(p ^ n) ∣\n  coe_fn\n      (mv_polynomial.bind₁ fun (b : idx) => coe_fn (mv_polynomial.rename fun (i : ℕ) => (b, i)) (witt_polynomial p ℤ n))\n      Φ -\n    finset.sum (finset.range n) fun (i : ℕ) => coe_fn mv_polynomial.C (↑p ^ i) * witt_structure_int p Φ i ^ p ^ (n - i) := sorry\n\n@[simp] theorem map_witt_structure_int (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (n : ℕ) : coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) (witt_structure_int p Φ n) =\n  witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom ℚ)) Φ) n := sorry\n\ntheorem witt_structure_int_prop (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (n : ℕ) : coe_fn (mv_polynomial.bind₁ (witt_structure_int p Φ)) (witt_polynomial p ℤ n) =\n  coe_fn (mv_polynomial.bind₁ fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p ℤ n)) Φ := sorry\n\ntheorem eq_witt_structure_int (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (φ : ℕ → mv_polynomial (idx × ℕ) ℤ) (h : ∀ (n : ℕ),\n  coe_fn (mv_polynomial.bind₁ φ) (witt_polynomial p ℤ n) =\n    coe_fn (mv_polynomial.bind₁ fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p ℤ n)) Φ) : φ = witt_structure_int p Φ := sorry\n\ntheorem witt_structure_int_exists_unique (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) : exists_unique\n  fun (φ : ℕ → mv_polynomial (idx × ℕ) ℤ) =>\n    ∀ (n : ℕ),\n      coe_fn (mv_polynomial.bind₁ φ) (witt_polynomial p ℤ n) =\n        coe_fn (mv_polynomial.bind₁ fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p ℤ n))\n          Φ :=\n  Exists.intro (witt_structure_int p Φ) { left := witt_structure_int_prop p Φ, right := eq_witt_structure_int p Φ }\n\ntheorem witt_structure_prop (p : ℕ) {R : Type u_1} {idx : Type u_2} [comm_ring R] [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (n : ℕ) : coe_fn (mv_polynomial.aeval fun (i : ℕ) => coe_fn (mv_polynomial.map (int.cast_ring_hom R)) (witt_structure_int p Φ i))\n    (witt_polynomial p ℤ n) =\n  coe_fn (mv_polynomial.aeval fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p R n)) Φ := sorry\n\ntheorem witt_structure_int_rename (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] {σ : Type u_1} (Φ : mv_polynomial idx ℤ) (f : idx → σ) (n : ℕ) : witt_structure_int p (coe_fn (mv_polynomial.rename f) Φ) n =\n  coe_fn (mv_polynomial.rename (prod.map f id)) (witt_structure_int p Φ n) := sorry\n\n@[simp] theorem constant_coeff_witt_structure_rat_zero (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℚ) : coe_fn mv_polynomial.constant_coeff (witt_structure_rat p Φ 0) = coe_fn mv_polynomial.constant_coeff Φ := sorry\n\ntheorem constant_coeff_witt_structure_rat (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℚ) (h : coe_fn mv_polynomial.constant_coeff Φ = 0) (n : ℕ) : coe_fn mv_polynomial.constant_coeff (witt_structure_rat p Φ n) = 0 := sorry\n\n@[simp] theorem constant_coeff_witt_structure_int_zero (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) : coe_fn mv_polynomial.constant_coeff (witt_structure_int p Φ 0) = coe_fn mv_polynomial.constant_coeff Φ := sorry\n\ntheorem constant_coeff_witt_structure_int (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] (Φ : mv_polynomial idx ℤ) (h : coe_fn mv_polynomial.constant_coeff Φ = 0) (n : ℕ) : coe_fn mv_polynomial.constant_coeff (witt_structure_int p Φ n) = 0 := sorry\n\n-- we could relax the fintype on `idx`, but then we need to cast from finset to set.\n\n-- for our applications `idx` is always finite.\n\ntheorem witt_structure_rat_vars (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] [fintype idx] (Φ : mv_polynomial idx ℚ) (n : ℕ) : mv_polynomial.vars (witt_structure_rat p Φ n) ⊆ finset.product finset.univ (finset.range (n + 1)) := sorry\n\n-- we could relax the fintype on `idx`, but then we need to cast from finset to set.\n\n-- for our applications `idx` is always finite.\n\ntheorem witt_structure_int_vars (p : ℕ) {idx : Type u_2} [hp : fact (nat.prime p)] [fintype idx] (Φ : mv_polynomial idx ℤ) (n : ℕ) : mv_polynomial.vars (witt_structure_int p Φ n) ⊆ finset.product finset.univ (finset.range (n + 1)) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/ring_theory/witt_vector/structure_polynomial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4533158500356755}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.num.basic\nimport Mathlib.data.bitvec.core\nimport Mathlib.PostPort\n\nuniverses l u_1 \n\nnamespace Mathlib\n\n/-!\n# Bitwise operations using binary representation of integers\n\n## Definitions\n\n* bitwise operations for `pos_num` and `num`,\n* `snum`, a type that represents integers as a bit string with a sign bit at the end,\n* arithmetic operations for `snum`.\n-/\n\nnamespace pos_num\n\n\ndef lor : pos_num → pos_num → pos_num := sorry\n\ndef land : pos_num → pos_num → num := sorry\n\ndef ldiff : pos_num → pos_num → num := sorry\n\ndef lxor : pos_num → pos_num → num := sorry\n\ndef test_bit : pos_num → ℕ → Bool := sorry\n\ndef one_bits : pos_num → ℕ → List ℕ := sorry\n\ndef shiftl (p : pos_num) : ℕ → pos_num := sorry\n\ndef shiftr : pos_num → ℕ → num := sorry\n\nend pos_num\n\n\nnamespace num\n\n\ndef lor : num → num → num := sorry\n\ndef land : num → num → num := sorry\n\ndef ldiff : num → num → num := sorry\n\ndef lxor : num → num → num := sorry\n\ndef shiftl : num → ℕ → num := sorry\n\ndef shiftr : num → ℕ → num := sorry\n\ndef test_bit : num → ℕ → Bool := sorry\n\ndef one_bits : num → List ℕ := sorry\n\nend num\n\n\n/-- This is a nonzero (and \"non minus one\") version of `snum`.\n    See the documentation of `snum` for more details. -/\ninductive nzsnum where\n| msb : Bool → nzsnum\n| bit : Bool → nzsnum → nzsnum\n\n/-- Alternative representation of integers using a sign bit at the end.\n  The convention on sign here is to have the argument to `msb` denote\n  the sign of the MSB itself, with all higher bits set to the negation\n  of this sign. The result is interpreted in two's complement.\n\n     13  = ..0001101(base 2) = nz (bit1 (bit0 (bit1 (msb tt))))\n     -13 = ..1110011(base 2) = nz (bit1 (bit1 (bit0 (msb ff))))\n\n  As with `num`, a special case must be added for zero, which has no msb,\n  but by two's complement symmetry there is a second special case for -1.\n  Here the `bool` field indicates the sign of the number.\n\n     0  = ..0000000(base 2) = zero ff\n     -1 = ..1111111(base 2) = zero tt -/\ninductive snum where\n| zero : Bool → snum\n| nz : nzsnum → snum\n\nprotected instance snum.has_coe : has_coe nzsnum snum := has_coe.mk snum.nz\n\nprotected instance snum.has_zero : HasZero snum := { zero := snum.zero false }\n\nprotected instance nzsnum.has_one : HasOne nzsnum := { one := nzsnum.msb tt }\n\nprotected instance snum.has_one : HasOne snum := { one := snum.nz 1 }\n\nprotected instance nzsnum.inhabited : Inhabited nzsnum := { default := 1 }\n\nprotected instance snum.inhabited : Inhabited snum := { default := 0 }\n\ninfixr:67 \" :: \" => Mathlib.nzsnum.bit\n\n/-!\nThe `snum` representation uses a bit string, essentially a list of 0 (`ff`) and 1 (`tt`) bits,\nand the negation of the MSB is sign-extended to all higher bits.\n-/\n\nnamespace nzsnum\n\n\ndef sign : nzsnum → Bool := sorry\n\ndef not : nzsnum → nzsnum := sorry\n\nprefix:40 \"~\" => Mathlib.nzsnum.not\n\ndef bit0 : nzsnum → nzsnum := bit false\n\ndef bit1 : nzsnum → nzsnum := bit tt\n\ndef head : nzsnum → Bool := sorry\n\ndef tail : nzsnum → snum := sorry\n\nend nzsnum\n\n\nnamespace snum\n\n\ndef sign : snum → Bool := sorry\n\ndef not : snum → snum := sorry\n\nprefix:40 \"~\" => Mathlib.snum.not\n\ndef bit : Bool → snum → snum := sorry\n\ninfixr:67 \" :: \" => Mathlib.snum.bit\n\ndef bit0 : snum → snum := bit false\n\ndef bit1 : snum → snum := bit tt\n\ntheorem bit_zero (b : Bool) : b :: zero b = zero b :=\n  bool.cases_on b (Eq.refl (false :: zero false)) (Eq.refl (tt :: zero tt))\n\ntheorem bit_one (b : Bool) : b :: zero (!b) = ↑(nzsnum.msb b) :=\n  bool.cases_on b (Eq.refl (false :: zero (!false))) (Eq.refl (tt :: zero (!tt)))\n\nend snum\n\n\nnamespace nzsnum\n\n\ndef drec' {C : snum → Sort u_1} (z : (b : Bool) → C (snum.zero b))\n    (s : (b : Bool) → (p : snum) → C p → C (b :: p)) (p : nzsnum) : C ↑p :=\n  sorry\n\nend nzsnum\n\n\nnamespace snum\n\n\ndef head : snum → Bool := sorry\n\ndef tail : snum → snum := sorry\n\ndef drec' {C : snum → Sort u_1} (z : (b : Bool) → C (zero b))\n    (s : (b : Bool) → (p : snum) → C p → C (b :: p)) (p : snum) : C p :=\n  sorry\n\ndef rec' {α : Sort u_1} (z : Bool → α) (s : Bool → snum → α → α) : snum → α := drec' z s\n\ndef test_bit : ℕ → snum → Bool := sorry\n\ndef succ : snum → snum :=\n  rec' (fun (b : Bool) => cond b 0 1)\n    fun (b : Bool) (p succp : snum) => cond b (false :: succp) (tt :: p)\n\ndef pred : snum → snum :=\n  rec' (fun (b : Bool) => cond b (~1) (~0))\n    fun (b : Bool) (p predp : snum) => cond b (false :: p) (tt :: predp)\n\nprotected def neg (n : snum) : snum := succ (~n)\n\nprotected instance has_neg : Neg snum := { neg := snum.neg }\n\ndef czadd : Bool → Bool → snum → snum := sorry\n\nend snum\n\n\nnamespace snum\n\n\n/-- `a.bits n` is the vector of the `n` first bits of `a` (starting from the LSB). -/\ndef bits : snum → (n : ℕ) → vector Bool n := sorry\n\ndef cadd : snum → snum → Bool → snum :=\n  rec' (fun (a : Bool) (p : snum) (c : Bool) => czadd c a p)\n    fun (a : Bool) (p : snum) (IH : snum → Bool → snum) =>\n      rec' (fun (b c : Bool) => czadd c b (a :: p))\n        fun (b : Bool) (q : snum) (_x : Bool → snum) (c : Bool) =>\n          bitvec.xor3 a b c :: IH q (bitvec.carry a b c)\n\n/-- Add two `snum`s. -/\nprotected def add (a : snum) (b : snum) : snum := cadd a b false\n\nprotected instance has_add : Add snum := { add := snum.add }\n\n/-- Substract two `snum`s. -/\nprotected def sub (a : snum) (b : snum) : snum := a + -b\n\nprotected instance has_sub : Sub snum := { sub := snum.sub }\n\n/-- Multiply two `snum`s. -/\nprotected def mul (a : snum) : snum → snum :=\n  rec' (fun (b : Bool) => cond b (-a) 0)\n    fun (b : Bool) (q IH : snum) => cond b (bit0 IH + a) (bit0 IH)\n\nprotected instance has_mul : Mul snum := { mul := snum.mul }\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/num/bitwise_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.4533158500356755}}
{"text": "\nimport Playlean4.Group.Basic\nimport Playlean4.Group.Subgroup\nimport Playlean4.Group.LRClasses\nimport Playlean4.Group.OnSet\n\nnamespace Group\n\nnamespace Subgroup\n\nvariable {G : Type} (law : G → G → G) [grp : Group G law]\n\nlocal infixl:70 \" * \" => id' law\n@[appUnexpander id'] def normal.UnexpandGMul : Lean.PrettyPrinter.Unexpander\n  | `(id' law $x $y) => `($x * $y)\n  | _ => throw ()\nlocal notation \"one\" => grp.one' -- HACK\nlocal notation g\"⁻¹\" => grp.inv g\n\nsection\n\nvariable (H : Set G) [sg : Subgroup G law H]\n\nlocal infixl:70 \" * \" => id' (subgroupLaw law H)\n@[appUnexpander id'] def normal.unexpandHMul : Lean.PrettyPrinter.Unexpander\n  | `(id' (subgroupLaw law H) $x $y) => `($x * $y)\n  | _ => throw ()\n\nclass Normal where\n  stable : ∀ (g : G), ∀ {h}, h ∈ H → (g * h * g⁻¹) ∈ H\n\nend\n\nend Subgroup\n\n-- Start with the simple things : the kernel is always normal\nnamespace Morphism\n\nvariable {G : Type} {lawG : G → G → G} [grpG : Group G lawG]\nvariable {H : Type} {lawH : H → H → H} [grpH : Group H lawH]\nvariable (φ : Morphism G lawG H lawH)\n\nlocal infixl:70 \" * \" => id' lawG\nlocal notation g\"⁻¹\" => grpG.inv g\nlocal infix:70 \" * \" => id' lawH\nlocal notation g\"⁻¹\" => grpH.inv g\n\ndef kernel : Set G := λ g => φ g = grpH.one'\n\ndef kernelIsSubgroup : Subgroup G lawG (kernel φ) := Subgroup.ofInhabitedMulInvStable lawG\n  (⟨ grpG.one', φ.respectOne ⟩)\n  (λ {h} hIn h' h'In => by simp [kernel, Set.mem]; rw [hIn, h'In]; simp )\n\ninstance kernelIsNormal : Subgroup.Normal lawG (φ.kernel) where\n  stable := λ g k kIn => by\n    suffices p : φ (g * (k : G) * g⁻¹) = grpH.one'\n    by exact p\n    have p : φ k = grpH.one' := kIn\n    simp [φ.respectMul, p]\n\nend Morphism\n\nnamespace Subgroup\n\nvariable {G : Type} {law : G → G → G} [grp : Group G law]\n\nlocal infixl:70 \" * \" => id' law\n@[appUnexpander id'] def normal.UnexpandGMul' : Lean.PrettyPrinter.Unexpander\n  | `(id' law $x $y) => `($x * $y)\n  | _ => throw ()\nlocal notation \"one\" => grp.one' -- HACK\nlocal notation g\"⁻¹\" => grp.inv g\n\n-- Now prove the converse : a normal subgroup is the kernel of some function\nnamespace Normal\n\nvariable (H : Set G) [sg : Subgroup G law H]\n\nlocal infixl:70 \" * \" => id' (subgroupLaw law H)\n@[appUnexpander id'] def normal.unexpandHMul : Lean.PrettyPrinter.Unexpander\n  | `(id' Magma.law H $x $y) => `($x * $y)\n  | _ => throw ()\n\ntheorem normalIff.lemma₁ :\n  (∀ (g : G), ∀ {h}, h ∈ H → g * h * g⁻¹ ∈ H) ↔\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h = h' * g) :=\nby\n  apply Iff.intro\n  focus\n    intro p g h hIn\n    suffices p : ∃ h', h' ∈ H ∧ g * h * g⁻¹ = h'\n    from match p with\n      | ⟨ h', ⟨ h'In, p ⟩ ⟩ => ⟨ h', ⟨ h'In, by simp [p.symm] ⟩ ⟩\n    exact ⟨ g * h * g⁻¹, ⟨ p g hIn, rfl ⟩ ⟩\n  focus\n    intro p g h hIn\n    match p g hIn with\n    | ⟨ h', ⟨ h'In, p ⟩ ⟩ =>\n      rw [show g * h * g⁻¹ = h' by simp [p]]\n      simp [h'In]\n\ntheorem normalIff.lemma₂ :\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h = h' * g) →\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h' = h * g) :=\nby\n  intro h g h₀ h₀In\n  match h (g⁻¹) (sg.invMem h₀In) with\n  | ⟨ h', ⟨ h'In, p ⟩ ⟩ =>\n    have ∀ k k' : G, k = k' → k⁻¹ = k'⁻¹ by intro _ _ h; rw [h]\n    have p' := this _ _ p\n    simp at p'\n    exact ⟨ h'⁻¹, ⟨ sg.invMem h'In, p'.symm ⟩ ⟩\n\ntheorem normalIff.lemma₃ :\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h = h' * g) →\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h' = h * g) →\n  ∀ (P : G → Prop), P ∈ leftClasses law H → P ∈ rightClasses law H :=\nby\n  intro h₀ h₁ p h'\n  match h' with\n  | ⟨ g, h' ⟩ =>\n    apply Exists.intro g\n    rw [h']\n    simp [Action.Remarkable.onSelf]\n    exact funext <| λ x => propext ⟨ (λ h'' => match h'' with\n      | ⟨ k, ⟨ kIn, h'' ⟩ ⟩ => match h₀ g kIn with\n        | ⟨ k', ⟨ k'In, h''' ⟩ ⟩ => ⟨ k', ⟨ k'In,\n          by rw [h'']; simp [id'] at h'''; simp [id']; rw [h''']; rfl ⟩ ⟩),\n      (λ h'' => match h'' with\n      | ⟨ k, ⟨ kIn, h'' ⟩ ⟩ => match h₁ g kIn with\n        | ⟨ k', ⟨ k'In, h''' ⟩ ⟩ => ⟨ k', ⟨ k'In,\n          by rw [h'']; simp [id'] at h'''; simp [id']; rw [h''']; rfl ⟩ ⟩) ⟩\n\ntheorem normalIff.lemma₄ :\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h = h' * g) →\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h' = h * g) →\n  ∀ (P : G → Prop), P ∈ rightClasses law H → P ∈ leftClasses law H :=\nby\n  rw [← leftClassesOnOp, ← rightClassesOnOp]\n  exact λ h₁ h₂ p h => @normalIff.lemma₃ _ (lawᵒᵖ) _ H\n    (λ g h hIn => match h₂ g hIn with\n      | ⟨ k, ⟨ kIn, h₂ ⟩ ⟩ => ⟨ k, ⟨ kIn, h₂.symm ⟩ ⟩)\n    (λ g h hIn => match h₁ g hIn with\n      | ⟨ k, ⟨ kIn, h₁ ⟩ ⟩ => ⟨ k, ⟨ kIn, h₁.symm ⟩ ⟩)\n    p h\n\ntheorem normalIff.lemma₅ :\n  (∀ (P : Set G), P ∈ rightClasses law H ↔ P ∈ leftClasses law H) →\n  (∀ (g : G), ∀ {h}, h ∈ H → ∃ h', h' ∈ H ∧ g * h = h' * g) :=\nby\n  intro h g h₀ h₀In\n  have p := ((leftClassOf law H g).property)\n  rw [← h] at p\n  have p₁ := leftClassMemIff law H ((leftClassOf law H g).2)\n    (memOfLeftClassOf law H g) (g * h₀)\n  have p₂ := rightClassMemIff law H p\n    (memOfLeftClassOf law H g) (g * h₀)\n  exact (p₁.trans p₂).1 ⟨ h₀, ⟨ h₀In, rfl ⟩ ⟩\n\nsection\n\nvariable [normal : Normal law H]\n\nopen Action.Remarkable.OnSet\n\nlocal infix:70 \" •ₗ \" => leftTranslationOnSet law\nlocal notation:70 lhs:70 \" •ᵣ \" rhs:70 => rightTranslationOnSet law rhs lhs\nlocal infix:70 \" ••  \" => conjugationOnSet law\nlocal infixl:70 \" ** \" => mulOnSet law\n\ntheorem conjH (g : G) : g •• H = H :=\nby\n  funext h\n  apply propext\n  suffices (∃ h', h' ∈ H ∧ h = g * h' * g⁻¹) ↔ h ∈ H by exact this\n  exact ⟨ λ p => match p with\n    | ⟨ h', ⟨ h'In, p ⟩ ⟩ => p ▸ normal.stable g h'In,\n    λ p => ⟨ (g⁻¹ * h * (g⁻¹⁻¹)), ⟨ normal.stable (g⁻¹) p, by simp ⟩ ⟩ ⟩\n\ntheorem moveLeft (g : G) : H •ᵣ g = g •ₗ H :=\nby\n  rw [show H •ᵣ g = (g •• H) •ᵣ g by rw [conjH]]\n  rw [conjugationCompat, ← rightTranslationCompat, invCancelLeft, rightTranslationIdentity]\n\ntheorem neutralRight (g : G) : (g •ₗ H) ** H = g •ₗ H :=\nby\n  funext x\n  apply propext\n  apply Iff.intro\n  exact λ h => match h with\n  | ⟨ res, ⟨ h₁, h₁In, resEq ⟩, h₂, h₂In, h₂Eq ⟩ =>\n    ⟨ h₁ * h₂, sg.mulMem h₁In h₂In, by\n      rw [h₂Eq, resEq]\n      suffices g * h₁ * h₂ = g * (h₁ * h₂) by exact this\n      simp ⟩\n  exact λ h => match h with\n    | ⟨ h, hIn, xEq ⟩ =>\n      ⟨ g * h, ⟨ h, hIn, rfl ⟩, one, oneMem, by\n        rw [xEq]\n        suffices g * h = g * h * one by exact this\n        simp ⟩\n\n/-! \"pseudo morphism\" because there is no notion of magma morphisms (yet !) -/\ntheorem pseudoMorphism (g : G) (g' : G) : (g •ₗ H) ** (g' •ₗ H) = (g * g') •ₗ H :=\nby\n  have p : g •ₗ (g' •ₗ H) = (g * g') •ₗ H\n  from ((leftActionOnSet law).compat g g' H).symm\n  rw [mulOnSetCompat₁, translationCompat, moveLeft, p, neutralRight]\n\ntheorem leftClassesStable {P Q : Set G}\n  (PIn : P ∈ leftClasses law H) (QIn : Q ∈ leftClasses law H) : P ** Q ∈ leftClasses law H :=\nby\n  rw [leftClassIff] at PIn\n  rw [leftClassIff] at QIn\n  rw [leftClassIff]\n  match PIn, QIn with\n  | ⟨ g, PIs ⟩, ⟨ g', QIs ⟩ =>\n    rw [PIs, QIs]\n    rw [pseudoMorphism]\n    exact ⟨ g * g', rfl ⟩\n\ndef quotientLaw : leftClasses law H → leftClasses law H → leftClasses law H :=\n  λ P Q => ⟨ P ** Q, leftClassesStable H P.2 Q.2 ⟩\n\ninstance quotientGroup : Group (leftClasses law H) (quotientLaw H) where\n  one' := subgroupAsLeftClass law H\n  assoc := λ P₁ P₂ P₃ => by\n    apply Subtype.eq\n    simp [id', quotientLaw]\n    match (leftClassIff law _ _).2 P₁.2,\n      (leftClassIff law _ _).2 P₂.2,\n      (leftClassIff law _ _).2 P₃.2 with\n    | ⟨ g₁, (P₁Is : P₁ = g₁ •ₗ H) ⟩,\n      ⟨ g₂, (P₂Is : P₂ = g₂ •ₗ H) ⟩,\n      ⟨ g₃, (P₃Is : P₃ = g₃ •ₗ H) ⟩ =>\n      rw [P₁Is, P₂Is, P₃Is]\n      simp [pseudoMorphism]\n  oneNeutralRight := λ P => by\n    apply Subtype.eq\n    simp only [id', quotientLaw]\n    exact match (leftClassIff law _ _).2 P.2 with\n    | ⟨ g, PIs ⟩ => PIs ▸ neutralRight _ _\n  invertible := λ P => by\n    simp only [id', quotientLaw]\n    match (leftClassIff law _ _).2 P.2 with\n    | ⟨ g, (PIs : P = g •ₗ H)⟩ =>\n      apply Exists.intro (leftClassOf law H (g⁻¹))\n      apply Subtype.eq\n      suffices P.1 ** (g⁻¹ •ₗ H) = H by exact this\n      rw [PIs]\n      simp only [pseudoMorphism, invCancelRight]\n      exact (leftActionOnSet law).identity H\n\ndef canonicalSurjection : Morphism G law (leftClasses law H) (quotientLaw H) where\n  f := λ g => ⟨ g •ₗ H, by\n    rw [leftClassIff]\n    exact ⟨ g, rfl ⟩ ⟩\n  respectMul' := λ g g' => Subtype.eq <| (pseudoMorphism H _ _).symm\n\nend\n\nend Normal\n\nend Subgroup\n\nend Group\n", "meta": {"author": "thejohncrafter", "repo": "playlean4", "sha": "81df180a71b8d84d0f45bc98db367aad203cf5df", "save_path": "github-repos/lean/thejohncrafter-playlean4", "path": "github-repos/lean/thejohncrafter-playlean4/playlean4-81df180a71b8d84d0f45bc98db367aad203cf5df/Playlean4/Group/Normal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583376458153, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.45331584883050213}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.discrete_category\n\n/-!\n# The empty category\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nDefines a category structure on `pempty`, and the unique functor `pempty ⥤ C` for any category `C`.\n-/\n\nuniverses w v u -- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nnamespace functor\n\nvariables (C : Type u) [category.{v} C]\n\n/-- Equivalence between two empty categories. -/\ndef empty_equivalence : discrete.{w} pempty ≌ discrete.{v} pempty :=\nequivalence.mk\n{ obj := pempty.elim ∘ discrete.as, map := λ x, x.as.elim }\n{ obj := pempty.elim ∘ discrete.as, map := λ x, x.as.elim }\n(by tidy) (by tidy)\n\n/-- The canonical functor out of the empty category. -/\ndef empty : discrete.{w} pempty ⥤ C := discrete.functor pempty.elim\n\nvariable {C}\n/-- Any two functors out of the empty category are isomorphic. -/\ndef empty_ext (F G : discrete.{w} pempty ⥤ C) : F ≅ G :=\ndiscrete.nat_iso (λ x, x.as.elim)\n\n/--\nAny functor out of the empty category is isomorphic to the canonical functor from the empty\ncategory.\n-/\ndef unique_from_empty (F : discrete.{w} pempty ⥤ C) : F ≅ empty C :=\nempty_ext _ _\n\n/--\nAny two functors out of the empty category are *equal*. You probably want to use\n`empty_ext` instead of this.\n-/\nlemma empty_ext' (F G : discrete.{w} pempty ⥤ C) : F = G :=\nfunctor.ext (λ x, x.as.elim) (λ x _ _, x.as.elim)\n\nend functor\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/pempty.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4533158406153783}}
{"text": "/-\nCopyright (c) 2021 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport algebra.big_operators.basic\nimport algebra.big_operators.pi\nimport category_theory.limits.shapes.biproducts\nimport category_theory.preadditive\nimport category_theory.preadditive.additive_functor\nimport data.matrix.dmatrix\nimport data.matrix.basic\nimport category_theory.Fintype\nimport category_theory.preadditive.single_obj\nimport algebra.opposites\n\n/-!\n# Matrices over a category.\n\nWhen `C` is a preadditive category, `Mat_ C` is the preadditive category\nwhose objects are finite tuples of objects in `C`, and\nwhose morphisms are matrices of morphisms from `C`.\n\nThere is a functor `Mat_.embedding : C ⥤ Mat_ C` sending morphisms to one-by-one matrices.\n\n`Mat_ C` has finite biproducts.\n\n## The additive envelope\n\nWe show that this construction is the \"additive envelope\" of `C`,\nin the sense that any additive functor `F : C ⥤ D` to a category `D` with biproducts\nlifts to a functor `Mat_.lift F : Mat_ C ⥤ D`,\nMoreover, this functor is unique (up to natural isomorphisms) amongst functors `L : Mat_ C ⥤ D`\nsuch that `embedding C ⋙ L ≅ F`.\n(As we don't have 2-category theory, we can't explicitly state that `Mat_ C` is\nthe initial object in the 2-category of categories under `C` which have biproducts.)\n\nAs a consequence, when `C` already has finite biproducts we have `Mat_ C ≌ C`.\n\n## Future work\n\nWe should provide a more convenient `Mat R`, when `R` is a ring,\nas a category with objects `n : FinType`,\nand whose morphisms are matrices with components in `R`.\n\nIdeally this would conveniently interact with both `Mat_` and `matrix`.\n\n-/\n\nopen category_theory category_theory.preadditive\nopen_locale big_operators classical\nnoncomputable theory\n\nnamespace category_theory\n\nuniverses w v₁ v₂ u₁ u₂\nvariables (C : Type u₁) [category.{v₁} C] [preadditive C]\n\n/--\nAn object in `Mat_ C` is a finite tuple of objects in `C`.\n-/\nstructure Mat_ : Type (max (v₁+1) u₁) :=\n(ι : Type v₁)\n[F : fintype ι]\n(X : ι → C)\n\nattribute [instance] Mat_.F\n\nnamespace Mat_\n\nvariables {C}\n\n/-- A morphism in `Mat_ C` is a dependently typed matrix of morphisms. -/\n@[nolint has_inhabited_instance]\ndef hom (M N : Mat_ C) : Type v₁ := dmatrix M.ι N.ι (λ i j, M.X i ⟶ N.X j)\n\nnamespace hom\n\n/-- The identity matrix consists of identity morphisms on the diagonal, and zeros elsewhere. -/\ndef id (M : Mat_ C) : hom M M := λ i j, if h : i = j then eq_to_hom (congr_arg M.X h) else 0\n\n/-- Composition of matrices using matrix multiplication. -/\ndef comp {M N K : Mat_ C} (f : hom M N) (g : hom N K) : hom M K :=\nλ i k, ∑ j : N.ι, f i j ≫ g j k\n\nend hom\n\nsection\nlocal attribute [simp] hom.id hom.comp\n\ninstance : category.{v₁} (Mat_ C) :=\n{ hom := hom,\n  id := hom.id,\n  comp := λ M N K f g, f.comp g,\n  id_comp' := λ M N f, by simp [dite_comp],\n  comp_id' := λ M N f, by simp [comp_dite],\n  assoc' := λ M N K L f g h, begin\n    ext i k,\n    simp_rw [hom.comp, sum_comp, comp_sum, category.assoc],\n    rw finset.sum_comm,\n  end, }.\n\nlemma id_def (M : Mat_ C) :\n  (𝟙 M : hom M M) = λ i j, if h : i = j then eq_to_hom (congr_arg M.X h) else 0 :=\nrfl\n\nlemma id_apply (M : Mat_ C) (i j : M.ι) :\n  (𝟙 M : hom M M) i j = if h : i = j then eq_to_hom (congr_arg M.X h) else 0 :=\nrfl\n\n@[simp] lemma id_apply_self (M : Mat_ C) (i : M.ι) :\n  (𝟙 M : hom M M) i i = 𝟙 _ :=\nby simp [id_apply]\n\n@[simp] lemma id_apply_of_ne (M : Mat_ C) (i j : M.ι) (h : i ≠ j) :\n  (𝟙 M : hom M M) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat_ C} (f : M ⟶ N) (g : N ⟶ K) :\n  (f ≫ g) = λ i k, ∑ j : N.ι, f i j ≫ g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat_ C} (f : M ⟶ N) (g : N ⟶ K) (i k) :\n  (f ≫ g) i k = ∑ j : N.ι, f i j ≫ g j k := rfl\n\ninstance (M N : Mat_ C) : inhabited (M ⟶ N) := ⟨λ i j, (0 : M.X i ⟶ N.X j)⟩\n\nend\n\ninstance : preadditive (Mat_ C) :=\n{ hom_group := λ M N, by { change add_comm_group (dmatrix M.ι N.ι _), apply_instance, },\n  add_comp' := λ M N K f f' g, by { ext, simp [finset.sum_add_distrib], },\n  comp_add' := λ M N K f g g', by { ext, simp [finset.sum_add_distrib], }, }\n\n@[simp] lemma add_apply {M N : Mat_ C} (f g : M ⟶ N) (i j) : (f + g) i j = f i j + g i j := rfl\n\nopen category_theory.limits\n\n/--\nWe now prove that `Mat_ C` has finite biproducts.\n\nBe warned, however, that `Mat_ C` is not necessarily Krull-Schmidt,\nand so the internal indexing of a biproduct may have nothing to do with the external indexing,\neven though the construction we give uses a sigma type.\nSee however `iso_biproduct_embedding`.\n-/\ninstance has_finite_biproducts : has_finite_biproducts (Mat_ C) :=\n{ has_biproducts_of_shape := λ J 𝒟, by exactI\n  { has_biproduct := λ f,\n    has_biproduct_of_total\n    { X := ⟨Σ j : J, (f j).ι, λ p, (f p.1).X p.2⟩,\n      π := λ j x y,\n      begin\n        dsimp at x ⊢,\n        refine if h : x.1 = j then _ else 0,\n        refine if h' : (@eq.rec J x.1 (λ j, (f j).ι) x.2 _ h) = y then _ else 0,\n        apply eq_to_hom,\n        substs h h', -- Notice we were careful not to use `subst` until we had a goal in `Prop`.\n      end,\n      ι := λ j x y,\n      begin\n        dsimp at y ⊢,\n        refine if h : y.1 = j then _ else 0,\n        refine if h' : (@eq.rec J y.1 (λ j, (f j).ι) y.2 _ h) = x then _ else 0,\n        apply eq_to_hom,\n        substs h h',\n      end,\n      ι_π := λ j j',\n      begin\n        ext x y,\n        dsimp,\n        simp_rw [dite_comp, comp_dite],\n        simp only [if_t_t, dite_eq_ite, dif_ctx_congr, limits.comp_zero, limits.zero_comp,\n          eq_to_hom_trans, finset.sum_congr],\n        erw finset.sum_sigma,\n        dsimp,\n        simp only [if_congr, if_true, dif_ctx_congr, finset.sum_dite_irrel, finset.mem_univ,\n          finset.sum_const_zero, finset.sum_congr, finset.sum_dite_eq'],\n        split_ifs with h h',\n        { substs h h',\n          simp only [category_theory.eq_to_hom_refl, category_theory.Mat_.id_apply_self], },\n        { subst h,\n          simp only [id_apply_of_ne _ _ _ h', category_theory.eq_to_hom_refl], },\n        { refl, },\n      end, }\n    begin\n      dsimp,\n      funext i₁,\n      dsimp at i₁ ⊢,\n      rcases i₁ with ⟨j₁, i₁⟩,\n      -- I'm not sure why we can't just `simp` by `finset.sum_apply`: something doesn't quite match\n      convert finset.sum_apply _ _ _ using 1,\n      { refl, },\n      { apply heq_of_eq,\n        symmetry,\n        funext i₂,\n        rcases i₂ with ⟨j₂, i₂⟩,\n        simp only [comp_apply, dite_comp, comp_dite,\n          if_t_t, dite_eq_ite, if_congr, if_true, dif_ctx_congr,\n          finset.sum_dite_irrel, finset.sum_dite_eq, finset.mem_univ, finset.sum_const_zero,\n          finset.sum_congr, finset.sum_dite_eq, finset.sum_apply,\n          limits.comp_zero, limits.zero_comp, eq_to_hom_trans, Mat_.id_apply],\n        by_cases h : j₁ = j₂,\n        { subst h, simp, },\n        { simp [h], }, },\n    end }}.\n\nend Mat_\n\nnamespace functor\nvariables {C} {D : Type*} [category.{v₁} D] [preadditive D]\n\nlocal attribute [simp] Mat_.id_apply eq_to_hom_map\n\n/--\nA functor induces a functor of matrix categories.\n-/\n@[simps]\ndef map_Mat_ (F : C ⥤ D) [functor.additive F] : Mat_ C ⥤ Mat_ D :=\n{ obj := λ M, ⟨M.ι, λ i, F.obj (M.X i)⟩,\n  map := λ M N f i j, F.map (f i j),\n  map_comp' := λ M N K f g, by { ext i k, simp,}, }\n\n/--\nThe identity functor induces the identity functor on matrix categories.\n-/\n@[simps]\ndef map_Mat_id : (𝟭 C).map_Mat_ ≅ 𝟭 (Mat_ C) :=\nnat_iso.of_components (λ M, eq_to_iso (by { cases M, refl, }))\n(λ M N f, begin\n  ext i j,\n  cases M, cases N,\n  simp [comp_dite, dite_comp],\nend)\n\n/--\nComposite functors induce composite functors on matrix categories.\n-/\n@[simps]\ndef map_Mat_comp {E : Type*} [category.{v₁} E] [preadditive E]\n  (F : C ⥤ D) [functor.additive F] (G : D ⥤ E) [functor.additive G] :\n  (F ⋙ G).map_Mat_ ≅ F.map_Mat_ ⋙ G.map_Mat_ :=\nnat_iso.of_components (λ M, eq_to_iso (by { cases M, refl, }))\n(λ M N f, begin\n  ext i j,\n  cases M, cases N,\n  simp [comp_dite, dite_comp],\nend)\n\nend functor\n\nnamespace Mat_\n\nvariables (C)\n\n/-- The embedding of `C` into `Mat_ C` as one-by-one matrices.\n(We index the summands by `punit`.) -/\n@[simps]\ndef embedding : C ⥤ Mat_ C :=\n{ obj := λ X, ⟨punit, λ _, X⟩,\n  map := λ X Y f, λ _ _, f,\n  map_id' := λ X, by { ext ⟨⟩ ⟨⟩, simp, },\n  map_comp' := λ X Y Z f g, by { ext ⟨⟩ ⟨⟩, simp, }, }\n\nnamespace embedding\n\ninstance : faithful (embedding C) :=\n{ map_injective' := λ X Y f g h, congr_fun (congr_fun h punit.star) punit.star, }\n\ninstance : full (embedding C) :=\n{ preimage := λ X Y f, f punit.star punit.star, }\n\ninstance : functor.additive (embedding C) := {}\n\nend embedding\n\ninstance [inhabited C] : inhabited (Mat_ C) := ⟨(embedding C).obj default⟩\n\nopen category_theory.limits\n\nvariables {C}\n\n/--\nEvery object in `Mat_ C` is isomorphic to the biproduct of its summands.\n-/\n@[simps]\ndef iso_biproduct_embedding (M : Mat_ C) : M ≅ ⨁ (λ i, (embedding C).obj (M.X i)) :=\n{ hom := biproduct.lift (λ i j k, if h : j = i then eq_to_hom (congr_arg M.X h) else 0),\n  inv := biproduct.desc (λ i j k, if h : i = k then eq_to_hom (congr_arg M.X h) else 0),\n  hom_inv_id' :=\n  begin\n    simp only [biproduct.lift_desc],\n    funext i,\n    dsimp,\n    convert finset.sum_apply _ _ _,\n    { dsimp, refl, },\n    { apply heq_of_eq,\n      symmetry,\n      funext j,\n      simp only [finset.sum_apply],\n      dsimp,\n      simp [dite_comp, comp_dite, Mat_.id_apply], }\n  end,\n  inv_hom_id' :=\n  begin\n    apply biproduct.hom_ext,\n    intro i,\n    apply biproduct.hom_ext',\n    intro j,\n    simp only [category.id_comp, category.assoc,\n      biproduct.lift_π, biproduct.ι_desc_assoc, biproduct.ι_π],\n    ext ⟨⟩ ⟨⟩,\n    simp [dite_comp, comp_dite],\n    split_ifs,\n    { subst h, simp, },\n    { simp [h], },\n  end, }.\n\nvariables {D : Type u₁} [category.{v₁} D] [preadditive D]\n\n/-- Every `M` is a direct sum of objects from `C`, and `F` preserves biproducts. -/\n@[simps]\ndef additive_obj_iso_biproduct (F : Mat_ C ⥤ D) [functor.additive F] (M : Mat_ C) :\n  F.obj M ≅ ⨁ (λ i, F.obj ((embedding C).obj (M.X i))) :=\n(F.map_iso (iso_biproduct_embedding M)) ≪≫ (F.map_biproduct _)\n\nvariables [has_finite_biproducts D]\n\n@[reassoc] lemma additive_obj_iso_biproduct_naturality (F : Mat_ C ⥤ D) [functor.additive F]\n  {M N : Mat_ C} (f : M ⟶ N) :\n  F.map f ≫ (additive_obj_iso_biproduct F N).hom =\n    (additive_obj_iso_biproduct F M).hom ≫\n      biproduct.matrix (λ i j, F.map ((embedding C).map (f i j))) :=\nbegin\n  -- This is disappointingly tedious.\n  ext,\n  simp only [additive_obj_iso_biproduct_hom, category.assoc, biproduct.lift_π, functor.map_bicone_π,\n    biproduct.bicone_π, biproduct.lift_matrix],\n  dsimp [embedding],\n  simp only [←F.map_comp, biproduct.lift_π, biproduct.matrix_π, category.assoc],\n  simp only [←F.map_comp, ←F.map_sum, biproduct.lift_desc, biproduct.lift_π_assoc, comp_sum],\n  simp only [comp_def, comp_dite, comp_zero, finset.sum_dite_eq', finset.mem_univ, if_true],\n  dsimp,\n  simp only [finset.sum_singleton, dite_comp, zero_comp],\n  congr,\n  symmetry,\n  convert finset.sum_fn _ _, -- It's hard to use this as a simp lemma!\n  simp only [finset.sum_fn, finset.sum_dite_eq],\n  ext,\n  simp,\nend\n\n@[reassoc] lemma additive_obj_iso_biproduct_naturality' (F : Mat_ C ⥤ D) [functor.additive F]\n  {M N : Mat_ C} (f : M ⟶ N) :\n  (additive_obj_iso_biproduct F M).inv ≫ F.map f =\n    biproduct.matrix (λ i j, F.map ((embedding C).map (f i j)) : _) ≫\n      (additive_obj_iso_biproduct F N).inv :=\nby rw [iso.inv_comp_eq, ←category.assoc, iso.eq_comp_inv, additive_obj_iso_biproduct_naturality]\n\n/-- Any additive functor `C ⥤ D` to a category `D` with finite biproducts extends to\na functor `Mat_ C ⥤ D`. -/\n@[simps]\ndef lift (F : C ⥤ D) [functor.additive F] : Mat_ C ⥤ D :=\n{ obj := λ X, ⨁ (λ i, F.obj (X.X i)),\n  map := λ X Y f, biproduct.matrix (λ i j, F.map (f i j)),\n  map_id' := λ X, begin\n    ext i j,\n    by_cases h : i = j,\n    { subst h, simp, },\n    { simp [h, Mat_.id_apply], },\n  end,\n  map_comp' := λ X Y Z f g, by { ext i j, simp, }, }.\n\ninstance lift_additive (F : C ⥤ D) [functor.additive F] : functor.additive (lift F) := {}\n\n/-- An additive functor `C ⥤ D` factors through its lift to `Mat_ C ⥤ D`. -/\n@[simps]\ndef embedding_lift_iso (F : C ⥤ D) [functor.additive F] : embedding C ⋙ lift F ≅ F :=\nnat_iso.of_components (λ X,\n  { hom := biproduct.desc (λ P, 𝟙 (F.obj X)),\n    inv := biproduct.lift (λ P, 𝟙 (F.obj X)), })\n(λ X Y f, begin\n  dsimp,\n  ext,\n  simp only [category.id_comp, biproduct.ι_desc_assoc],\n  erw biproduct.ι_matrix_assoc, -- Not sure why this doesn't fire via `simp`.\n  simp,\nend).\n\n/--\n`Mat_.lift F` is the unique additive functor `L : Mat_ C ⥤ D` such that `F ≅ embedding C ⋙ L`.\n-/\ndef lift_unique (F : C ⥤ D) [functor.additive F] (L : Mat_ C ⥤ D) [functor.additive L]\n  (α : embedding C ⋙ L ≅ F) :\n  L ≅ lift F :=\nnat_iso.of_components\n  (λ M, (additive_obj_iso_biproduct L M) ≪≫\n    (biproduct.map_iso (λ i, α.app (M.X i))) ≪≫\n    (biproduct.map_iso (λ i, (embedding_lift_iso F).symm.app (M.X i))) ≪≫\n    (additive_obj_iso_biproduct (lift F) M).symm)\n(λ M N f, begin\n  dsimp only [iso.trans_hom, iso.symm_hom, biproduct.map_iso_hom],\n  simp only [additive_obj_iso_biproduct_naturality_assoc],\n  simp only [biproduct.matrix_map_assoc, category.assoc],\n  simp only [additive_obj_iso_biproduct_naturality'],\n  simp only [biproduct.map_matrix_assoc, category.assoc],\n  congr,\n  ext j k ⟨⟩,\n  dsimp, simp,\n  exact α.hom.naturality (f j k),\nend).\n\n-- TODO is there some uniqueness statement for the natural isomorphism in `lift_unique`?\n\n/-- Two additive functors `Mat_ C ⥤ D` are naturally isomorphic if\ntheir precompositions with `embedding C` are naturally isomorphic as functors `C ⥤ D`. -/\n@[ext]\ndef ext {F G : Mat_ C ⥤ D} [functor.additive F] [functor.additive G]\n  (α : embedding C ⋙ F ≅ embedding C ⋙ G) : F ≅ G :=\n(lift_unique (embedding C ⋙ G) _ α) ≪≫ (lift_unique _ _ (iso.refl _)).symm\n\n/--\nNatural isomorphism needed in the construction of `equivalence_self_of_has_finite_biproducts`.\n-/\ndef equivalence_self_of_has_finite_biproducts_aux [has_finite_biproducts C] :\n  embedding C ⋙ 𝟭 (Mat_ C) ≅ embedding C ⋙ lift (𝟭 C) ⋙ embedding C :=\nfunctor.right_unitor _ ≪≫\n  (functor.left_unitor _).symm ≪≫\n  (iso_whisker_right (embedding_lift_iso _).symm _) ≪≫\n  functor.associator _ _ _\n\n/--\nA preadditive category that already has finite biproducts is equivalent to its additive envelope.\n\nNote that we only prove this for a large category;\notherwise there are universe issues that I haven't attempted to sort out.\n-/\ndef equivalence_self_of_has_finite_biproducts\n  (C : Type (u₁+1)) [large_category C] [preadditive C] [has_finite_biproducts C] :\n  Mat_ C ≌ C :=\nequivalence.mk -- I suspect this is already an adjoint equivalence, but it seems painful to verify.\n  (lift (𝟭 C))\n  (embedding C)\n  (ext equivalence_self_of_has_finite_biproducts_aux)\n  (embedding_lift_iso (𝟭 C))\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_functor\n  {C : Type (u₁+1)} [large_category C] [preadditive C] [has_finite_biproducts C] :\n  (equivalence_self_of_has_finite_biproducts C).functor = lift (𝟭 C) :=\nrfl\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_inverse\n  {C : Type (u₁+1)} [large_category C] [preadditive C] [has_finite_biproducts C] :\n  (equivalence_self_of_has_finite_biproducts C).inverse = embedding C :=\nrfl\n\nend Mat_\n\nuniverse u\n\n/-- A type synonym for `Fintype`, which we will equip with a category structure\nwhere the morphisms are matrices with components in `R`. -/\n@[nolint unused_arguments, derive inhabited]\ndef Mat (R : Type u) := Fintype.{u}\n\ninstance (R : Type u) : has_coe_to_sort (Mat R) (Type u) := bundled.has_coe_to_sort\n\nopen_locale classical matrix\n\ninstance (R : Type u) [semiring R] : category (Mat R) :=\n{ hom := λ X Y, matrix X Y R,\n  id := λ X, 1,\n  comp := λ X Y Z f g, f ⬝ g,\n  assoc' := by { intros, simp [matrix.mul_assoc], }, }\n\nnamespace Mat\n\nsection\nvariables (R : Type u) [semiring R]\n\nlemma id_def (M : Mat R) :\n  𝟙 M = λ i j, if h : i = j then 1 else 0 :=\nrfl\n\nlemma id_apply (M : Mat R) (i j : M) :\n  (𝟙 M : matrix M M R) i j = if h : i = j then 1 else 0 :=\nrfl\n\n@[simp] lemma id_apply_self (M : Mat R) (i : M) :\n  (𝟙 M : matrix M M R) i i = 1 :=\nby simp [id_apply]\n\n@[simp] lemma id_apply_of_ne (M : Mat R) (i j : M) (h : i ≠ j) :\n  (𝟙 M : matrix M M R) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat R} (f : M ⟶ N) (g : N ⟶ K) :\n  (f ≫ g) = λ i k, ∑ j : N, f i j * g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat R} (f : M ⟶ N) (g : N ⟶ K) (i k) :\n  (f ≫ g) i k = ∑ j : N, f i j * g j k := rfl\n\ninstance (M N : Mat R) : inhabited (M ⟶ N) := ⟨λ (i : M) (j : N), (0 : R)⟩\n\nend\n\nvariables (R : Type u) [ring R]\n\nopen opposite\n\n/-- Auxiliary definition for `category_theory.Mat.equivalence_single_obj`. -/\n@[simps]\ndef equivalence_single_obj_inverse : Mat_ (single_obj Rᵐᵒᵖ) ⥤ Mat R :=\n{ obj := λ X, Fintype.of X.ι,\n  map := λ X Y f i j, mul_opposite.unop (f i j),\n  map_id' := λ X, by { ext i j, simp [id_def, Mat_.id_def], split_ifs; refl, }, }\n\ninstance : faithful (equivalence_single_obj_inverse R) :=\n{ map_injective' := λ X Y f g w, begin\n    ext i j,\n    apply_fun mul_opposite.unop using mul_opposite.unop_injective,\n    exact (congr_fun (congr_fun w i) j),\n  end }\n\ninstance : full (equivalence_single_obj_inverse R) :=\n{ preimage := λ X Y f i j, mul_opposite.op (f i j), }\n\ninstance : ess_surj (equivalence_single_obj_inverse R) :=\n{ mem_ess_image := λ X,\n  ⟨{ ι := X, X := λ _, punit.star }, ⟨eq_to_iso (by { dsimp, cases X, congr, })⟩⟩, }\n\n/-- The categorical equivalence between the category of matrices over a ring,\nand the category of matrices over that ring considered as a single-object category. -/\ndef equivalence_single_obj : Mat R ≌ Mat_ (single_obj Rᵐᵒᵖ) :=\nbegin\n  haveI := equivalence.of_fully_faithfully_ess_surj (equivalence_single_obj_inverse R),\n  exact (equivalence_single_obj_inverse R).as_equivalence.symm,\nend\n\ninstance : preadditive (Mat R) :=\n{ add_comp' := by { intros, ext, simp [add_mul, finset.sum_add_distrib], },\n  comp_add' := by { intros, ext, simp [mul_add, finset.sum_add_distrib], }, }\n\n-- TODO show `Mat R` has biproducts, and that `biprod.map` \"is\" forming a block diagonal matrix.\n\nend Mat\n\nend category_theory\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/preadditive/Mat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.45331583240025436}}
{"text": "/-\nCopyright (c) 2018 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes, Abhimanyu Pallavi Sudhir\n\n! This file was ported from Lean 3 source module data.complex.exponential\n! leanprover-community/mathlib commit 932872382355f00112641d305ba0619305dc8642\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.GeomSum\nimport Mathbin.Data.Complex.Basic\nimport Mathbin.Data.Nat.Choose.Sum\n\n/-!\n# Exponential, trigonometric and hyperbolic trigonometric functions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file contains the definitions of the real and complex exponential, sine, cosine, tangent,\nhyperbolic sine, hyperbolic cosine, and hyperbolic tangent functions.\n\n-/\n\n\n-- mathport name: exprabs'\nlocal notation \"abs'\" => Abs.abs\n\nopen IsAbsoluteValue\n\nopen Classical BigOperators Nat ComplexConjugate\n\nsection\n\nopen Real IsAbsoluteValue Finset\n\nsection\n\nvariable {α : Type _} {β : Type _} [Ring β] [LinearOrderedField α] [Archimedean α] {abv : β → α}\n  [IsAbsoluteValue abv]\n\n/- warning: is_cau_of_decreasing_bounded -> isCauSeq_of_decreasing_bounded is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} α] [_inst_3 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))] (f : Nat -> α) {a : α} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))) (f (Nat.succ n)) (f n))) -> (IsCauSeq.{u1, u1} α _inst_2 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))))) f)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} α] [_inst_3 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_2))))))] (f : Nat -> α) {a : α} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))) (f (Nat.succ n)) (f n))) -> (IsCauSeq.{u1, u1} α _inst_2 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) f)\nCase conversion may be inaccurate. Consider using '#align is_cau_of_decreasing_bounded isCauSeq_of_decreasing_boundedₓ'. -/\ntheorem isCauSeq_of_decreasing_bounded (f : ℕ → α) {a : α} {m : ℕ} (ham : ∀ n ≥ m, |f n| ≤ a)\n    (hnm : ∀ n ≥ m, f n.succ ≤ f n) : IsCauSeq abs f := fun ε ε0 =>\n  by\n  let ⟨k, hk⟩ := Archimedean.arch a ε0\n  have h : ∃ l, ∀ n ≥ m, a - l • ε < f n :=\n    ⟨k + k + 1, fun n hnm =>\n      lt_of_lt_of_le\n        (show a - (k + (k + 1)) • ε < -|f n| from\n          lt_neg.1 <|\n            lt_of_le_of_lt (ham n hnm)\n              (by\n                rw [neg_sub, lt_sub_iff_add_lt, add_nsmul, add_nsmul, one_nsmul]\n                exact add_lt_add_of_le_of_lt hk (lt_of_le_of_lt hk (lt_add_of_pos_right _ ε0))))\n        (neg_le.2 <| abs_neg (f n) ▸ le_abs_self _)⟩\n  let l := Nat.find h\n  have hl : ∀ n : ℕ, n ≥ m → f n > a - l • ε := Nat.find_spec h\n  have hl0 : l ≠ 0 := fun hl0 =>\n    not_lt_of_ge (ham m le_rfl)\n      (lt_of_lt_of_le (by have := hl m (le_refl m) <;> simpa [hl0] using this) (le_abs_self (f m)))\n  cases' not_forall.1 (Nat.find_min h (Nat.pred_lt hl0)) with i hi\n  rw [not_imp, not_lt] at hi\n  exists i\n  intro j hj\n  have hfij : f j ≤ f i := (Nat.rel_of_forall_rel_succ_of_le_of_le (· ≥ ·) hnm hi.1 hj).le\n  rw [abs_of_nonpos (sub_nonpos.2 hfij), neg_sub, sub_lt_iff_lt_add']\n  calc\n    f i ≤ a - Nat.pred l • ε := hi.2\n    _ = a - l • ε + ε := by\n      conv =>\n        rhs\n        rw [← Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hl0), succ_nsmul', sub_add,\n          add_sub_cancel]\n    _ < f j + ε := add_lt_add_right (hl j (le_trans hi.1 hj)) _\n    \n#align is_cau_of_decreasing_bounded isCauSeq_of_decreasing_bounded\n\n/- warning: is_cau_of_mono_bounded -> isCauSeq_of_mono_bounded is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} α] [_inst_3 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))] (f : Nat -> α) {a : α} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))) (f n) (f (Nat.succ n)))) -> (IsCauSeq.{u1, u1} α _inst_2 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))))) f)\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} α] [_inst_3 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_2))))))] (f : Nat -> α) {a : α} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))) (f n) (f (Nat.succ n)))) -> (IsCauSeq.{u1, u1} α _inst_2 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) f)\nCase conversion may be inaccurate. Consider using '#align is_cau_of_mono_bounded isCauSeq_of_mono_boundedₓ'. -/\ntheorem isCauSeq_of_mono_bounded (f : ℕ → α) {a : α} {m : ℕ} (ham : ∀ n ≥ m, |f n| ≤ a)\n    (hnm : ∀ n ≥ m, f n ≤ f n.succ) : IsCauSeq abs f :=\n  by\n  refine'\n    @Eq.recOn (ℕ → α) _ (IsCauSeq abs) _ _\n      (-⟨_, @isCauSeq_of_decreasing_bounded _ _ _ (fun n => -f n) a m (by simpa) (by simpa)⟩ :\n          CauSeq α abs).2\n  ext\n  exact neg_neg _\n#align is_cau_of_mono_bounded isCauSeq_of_mono_bounded\n\nend\n\nsection NoArchimedean\n\nvariable {α : Type _} {β : Type _} [Ring β] [LinearOrderedField α] {abv : β → α}\n  [IsAbsoluteValue abv]\n\n/- warning: is_cau_series_of_abv_le_cau -> isCauSeq_series_of_abv_le_of_isCauSeq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Ring.{u2} β] [_inst_2 : LinearOrderedField.{u1} α] {abv : β -> α} [_inst_3 : IsAbsoluteValue.{u1, u2} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))) β (Ring.toSemiring.{u2} β _inst_1) abv] {f : Nat -> β} {g : Nat -> α} (n : Nat), (forall (m : Nat), (LE.le.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))) (abv (f m)) (g m))) -> (IsCauSeq.{u1, u1} α _inst_2 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))))) (fun (n : Nat) => Finset.sum.{u1, 0} α Nat (AddCommGroup.toAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))) (Finset.range n) (fun (i : Nat) => g i))) -> (IsCauSeq.{u1, u2} α _inst_2 β _inst_1 abv (fun (n : Nat) => Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_1)))) (Finset.range n) (fun (i : Nat) => f i)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Ring.{u1} β] [_inst_2 : LinearOrderedField.{u2} α] {abv : β -> α} [_inst_3 : IsAbsoluteValue.{u2, u1} α (OrderedCommSemiring.toOrderedSemiring.{u2} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_2))))) β (Ring.toSemiring.{u1} β _inst_1) abv] {f : Nat -> β} {g : Nat -> α} (n : Nat), (forall (m : Nat), (LE.le.{0} Nat instLENat n m) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (StrictOrderedRing.toPartialOrder.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_2)))))) (abv (f m)) (g m))) -> (IsCauSeq.{u2, u2} α _inst_2 α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_2)))) (Abs.abs.{u2} α (Neg.toHasAbs.{u2} α (Ring.toNeg.{u2} α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_2))))) (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α (LinearOrderedRing.toLinearOrder.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_2))))))))) (fun (n : Nat) => Finset.sum.{u2, 0} α Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_2)))))) (Finset.range n) (fun (i : Nat) => g i))) -> (IsCauSeq.{u2, u1} α _inst_2 β _inst_1 abv (fun (n : Nat) => Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_1)))) (Finset.range n) (fun (i : Nat) => f i)))\nCase conversion may be inaccurate. Consider using '#align is_cau_series_of_abv_le_cau isCauSeq_series_of_abv_le_of_isCauSeqₓ'. -/\ntheorem isCauSeq_series_of_abv_le_of_isCauSeq {f : ℕ → β} {g : ℕ → α} (n : ℕ) :\n    (∀ m, n ≤ m → abv (f m) ≤ g m) →\n      (IsCauSeq abs fun n => ∑ i in range n, g i) → IsCauSeq abv fun n => ∑ i in range n, f i :=\n  by\n  intro hm hg ε ε0\n  cases' hg (ε / 2) (div_pos ε0 (by norm_num)) with i hi\n  exists max n i\n  intro j ji\n  have hi₁ := hi j (le_trans (le_max_right n i) ji)\n  have hi₂ := hi (max n i) (le_max_right n i)\n  have sub_le :=\n    abs_sub_le (∑ k in range j, g k) (∑ k in range i, g k) (∑ k in range (max n i), g k)\n  have := add_lt_add hi₁ hi₂\n  rw [abs_sub_comm (∑ k in range (max n i), g k), add_halves ε] at this\n  refine' lt_of_le_of_lt (le_trans (le_trans _ (le_abs_self _)) sub_le) this\n  generalize hk : j - max n i = k\n  clear this hi₂ hi₁ hi ε0 ε hg sub_le\n  rw [tsub_eq_iff_eq_add_of_le ji] at hk\n  rw [hk]\n  clear hk ji j\n  induction' k with k' hi\n  · simp [abv_zero abv]\n  · simp only [Nat.succ_add, sum_range_succ_comm, sub_eq_add_neg, add_assoc]\n    refine' le_trans (abv_add _ _ _) _\n    simp only [sub_eq_add_neg] at hi\n    exact add_le_add (hm _ (le_add_of_nonneg_of_le (Nat.zero_le _) (le_max_left _ _))) hi\n#align is_cau_series_of_abv_le_cau isCauSeq_series_of_abv_le_of_isCauSeq\n\n/- warning: is_cau_series_of_abv_cau -> isCauSeq_series_of_abv_isCauSeq is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Ring.{u2} β] [_inst_2 : LinearOrderedField.{u1} α] {abv : β -> α} [_inst_3 : IsAbsoluteValue.{u1, u2} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))) β (Ring.toSemiring.{u2} β _inst_1) abv] {f : Nat -> β}, (IsCauSeq.{u1, u1} α _inst_2 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))))) (fun (m : Nat) => Finset.sum.{u1, 0} α Nat (AddCommGroup.toAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_2)))))) (Finset.range m) (fun (n : Nat) => abv (f n)))) -> (IsCauSeq.{u1, u2} α _inst_2 β _inst_1 abv (fun (m : Nat) => Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_1)))) (Finset.range m) (fun (n : Nat) => f n)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Ring.{u1} β] [_inst_2 : LinearOrderedField.{u2} α] {abv : β -> α} [_inst_3 : IsAbsoluteValue.{u2, u1} α (OrderedCommSemiring.toOrderedSemiring.{u2} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_2))))) β (Ring.toSemiring.{u1} β _inst_1) abv] {f : Nat -> β}, (IsCauSeq.{u2, u2} α _inst_2 α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_2)))) (Abs.abs.{u2} α (Neg.toHasAbs.{u2} α (Ring.toNeg.{u2} α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_2))))) (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α (LinearOrderedRing.toLinearOrder.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_2))))))))) (fun (m : Nat) => Finset.sum.{u2, 0} α Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_2)))))) (Finset.range m) (fun (n : Nat) => abv (f n)))) -> (IsCauSeq.{u2, u1} α _inst_2 β _inst_1 abv (fun (m : Nat) => Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_1)))) (Finset.range m) (fun (n : Nat) => f n)))\nCase conversion may be inaccurate. Consider using '#align is_cau_series_of_abv_cau isCauSeq_series_of_abv_isCauSeqₓ'. -/\ntheorem isCauSeq_series_of_abv_isCauSeq {f : ℕ → β} :\n    (IsCauSeq abs fun m => ∑ n in range m, abv (f n)) → IsCauSeq abv fun m => ∑ n in range m, f n :=\n  isCauSeq_series_of_abv_le_of_isCauSeq 0 fun n h => le_rfl\n#align is_cau_series_of_abv_cau isCauSeq_series_of_abv_isCauSeq\n\nend NoArchimedean\n\nsection\n\nvariable {α : Type _} [LinearOrderedField α] [Archimedean α]\n\n/- warning: is_cau_geo_series -> isCauSeq_geo_series is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))] {β : Type.{u2}} [_inst_3 : Ring.{u2} β] [_inst_4 : Nontrivial.{u2} β] {abv : β -> α} [_inst_5 : IsAbsoluteValue.{u1, u2} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) β (Ring.toSemiring.{u2} β _inst_3) abv] (x : β), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (abv x) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) -> (IsCauSeq.{u1, u2} α _inst_1 β _inst_3 abv (fun (n : Nat) => Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_3)))) (Finset.range n) (fun (m : Nat) => HPow.hPow.{u2, 0, u2} β Nat β (instHPow.{u2, 0} β Nat (Monoid.Pow.{u2} β (Ring.toMonoid.{u2} β _inst_3))) x m)))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))] {β : Type.{u2}} [_inst_3 : Ring.{u2} β] [_inst_4 : Nontrivial.{u2} β] {abv : β -> α} [_inst_5 : IsAbsoluteValue.{u1, u2} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))) β (Ring.toSemiring.{u2} β _inst_3) abv] (x : β), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (abv x) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) -> (IsCauSeq.{u1, u2} α _inst_1 β _inst_3 abv (fun (n : Nat) => Finset.sum.{u2, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_3)))) (Finset.range n) (fun (m : Nat) => HPow.hPow.{u2, 0, u2} β Nat β (instHPow.{u2, 0} β Nat (Monoid.Pow.{u2} β (MonoidWithZero.toMonoid.{u2} β (Semiring.toMonoidWithZero.{u2} β (Ring.toSemiring.{u2} β _inst_3))))) x m)))\nCase conversion may be inaccurate. Consider using '#align is_cau_geo_series isCauSeq_geo_seriesₓ'. -/\ntheorem isCauSeq_geo_series {β : Type _} [Ring β] [Nontrivial β] {abv : β → α} [IsAbsoluteValue abv]\n    (x : β) (hx1 : abv x < 1) : IsCauSeq abv fun n => ∑ m in range n, x ^ m :=\n  have hx1' : abv x ≠ 1 := fun h => by simpa [h, lt_irrefl] using hx1\n  isCauSeq_series_of_abv_isCauSeq\n    (by\n      simp only [abv_pow abv, geom_sum_eq hx1']\n      conv in _ / _ => rw [← neg_div_neg_eq, neg_sub, neg_sub]\n      refine' @isCauSeq_of_mono_bounded _ _ _ _ ((1 : α) / (1 - abv x)) 0 _ _\n      · intro n hn\n        rw [abs_of_nonneg]\n        refine'\n          div_le_div_of_le (le_of_lt <| sub_pos.2 hx1)\n            (sub_le_self _ (abv_pow abv x n ▸ abv_nonneg _ _))\n        refine' div_nonneg (sub_nonneg.2 _) (sub_nonneg.2 <| le_of_lt hx1)\n        clear hn\n        induction' n with n ih\n        · simp\n        · rw [pow_succ, ← one_mul (1 : α)]\n          refine' mul_le_mul (le_of_lt hx1) ih (abv_pow abv x n ▸ abv_nonneg _ _) (by norm_num)\n      · intro n hn\n        refine' div_le_div_of_le (le_of_lt <| sub_pos.2 hx1) (sub_le_sub_left _ _)\n        rw [← one_mul (_ ^ n), pow_succ]\n        exact mul_le_mul_of_nonneg_right (le_of_lt hx1) (pow_nonneg (abv_nonneg _ _) _))\n#align is_cau_geo_series isCauSeq_geo_series\n\n/- warning: is_cau_geo_series_const -> isCauSeq_geo_series_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))] (a : α) {x : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) x) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) -> (IsCauSeq.{u1, u1} α _inst_1 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (fun (m : Nat) => Finset.sum.{u1, 0} α Nat (AddCommGroup.toAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Finset.range m) (fun (n : Nat) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) a (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (Ring.toMonoid.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) x n))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (OrderedCommSemiring.toOrderedSemiring.{u1} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))] (a : α) {x : α}, (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) x) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) -> (IsCauSeq.{u1, u1} α _inst_1 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (Ring.toNeg.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) (SemilatticeSup.toSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (fun (m : Nat) => Finset.sum.{u1, 0} α Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))) (Finset.range m) (fun (n : Nat) => HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) a (HPow.hPow.{u1, 0, u1} α Nat α (instHPow.{u1, 0} α Nat (Monoid.Pow.{u1} α (MonoidWithZero.toMonoid.{u1} α (Semiring.toMonoidWithZero.{u1} α (StrictOrderedSemiring.toSemiring.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1))))))))) x n))))\nCase conversion may be inaccurate. Consider using '#align is_cau_geo_series_const isCauSeq_geo_series_constₓ'. -/\ntheorem isCauSeq_geo_series_const (a : α) {x : α} (hx1 : |x| < 1) :\n    IsCauSeq abs fun m => ∑ n in range m, a * x ^ n :=\n  by\n  have : IsCauSeq abs fun m => a * ∑ n in range m, x ^ n :=\n    (CauSeq.const abs a * ⟨_, isCauSeq_geo_series x hx1⟩).2\n  simpa only [mul_sum]\n#align is_cau_geo_series_const isCauSeq_geo_series_const\n\nvariable {β : Type _} [Ring β] {abv : β → α} [IsAbsoluteValue abv]\n\n/- warning: series_ratio_test -> series_ratio_test is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] [_inst_2 : Archimedean.{u1} α (OrderedSemiring.toOrderedAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))] {β : Type.{u2}} [_inst_3 : Ring.{u2} β] {abv : β -> α} [_inst_4 : IsAbsoluteValue.{u1, u2} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) β (Ring.toSemiring.{u2} β _inst_3) abv] {f : Nat -> β} (n : Nat) (r : α), (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) r) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) r (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) -> (forall (m : Nat), (LE.le.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (abv (f (Nat.succ m))) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) r (abv (f m))))) -> (IsCauSeq.{u1, u2} α _inst_1 β _inst_3 abv (fun (m : Nat) => Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_3)))) (Finset.range m) (fun (n : Nat) => f n)))\nbut is expected to have type\n  forall {α : Type.{u2}} [_inst_1 : LinearOrderedField.{u2} α] [_inst_2 : Archimedean.{u2} α (OrderedSemiring.toOrderedAddCommMonoid.{u2} α (OrderedCommSemiring.toOrderedSemiring.{u2} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1))))))] {β : Type.{u1}} [_inst_3 : Ring.{u1} β] {abv : β -> α} [_inst_4 : IsAbsoluteValue.{u2, u1} α (OrderedCommSemiring.toOrderedSemiring.{u2} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1))))) β (Ring.toSemiring.{u1} β _inst_3) abv] {f : Nat -> β} (n : Nat) (r : α), (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (StrictOrderedRing.toPartialOrder.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (CommMonoidWithZero.toZero.{u2} α (CommGroupWithZero.toCommMonoidWithZero.{u2} α (Semifield.toCommGroupWithZero.{u2} α (LinearOrderedSemifield.toSemifield.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1))))))) r) -> (LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (StrictOrderedRing.toPartialOrder.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))))) r (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (NonAssocRing.toOne.{u2} α (Ring.toNonAssocRing.{u2} α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1))))))))) -> (forall (m : Nat), (LE.le.{0} Nat instLENat n m) -> (LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (StrictOrderedRing.toPartialOrder.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))))) (abv (f (Nat.succ m))) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocRing.toMul.{u2} α (NonAssocRing.toNonUnitalNonAssocRing.{u2} α (Ring.toNonAssocRing.{u2} α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))))))) r (abv (f m))))) -> (IsCauSeq.{u2, u1} α _inst_1 β _inst_3 abv (fun (m : Nat) => Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_3)))) (Finset.range m) (fun (n : Nat) => f n)))\nCase conversion may be inaccurate. Consider using '#align series_ratio_test series_ratio_testₓ'. -/\ntheorem series_ratio_test {f : ℕ → β} (n : ℕ) (r : α) (hr0 : 0 ≤ r) (hr1 : r < 1)\n    (h : ∀ m, n ≤ m → abv (f m.succ) ≤ r * abv (f m)) : IsCauSeq abv fun m => ∑ n in range m, f n :=\n  by\n  have har1 : |r| < 1 := by rwa [abs_of_nonneg hr0]\n  refine'\n    isCauSeq_series_of_abv_le_of_isCauSeq n.succ _\n      (isCauSeq_geo_series_const (abv (f n.succ) * r⁻¹ ^ n.succ) har1)\n  intro m hmn\n  cases' Classical.em (r = 0) with r_zero r_ne_zero\n  · have m_pos := lt_of_lt_of_le (Nat.succ_pos n) hmn\n    have := h m.pred (Nat.le_of_succ_le_succ (by rwa [Nat.succ_pred_eq_of_pos m_pos]))\n    simpa [r_zero, Nat.succ_pred_eq_of_pos m_pos, pow_succ]\n  generalize hk : m - n.succ = k\n  have r_pos : 0 < r := lt_of_le_of_ne hr0 (Ne.symm r_ne_zero)\n  replace hk : m = k + n.succ := (tsub_eq_iff_eq_add_of_le hmn).1 hk\n  induction' k with k ih generalizing m n\n  · rw [hk, zero_add, mul_right_comm, inv_pow _ _, ← div_eq_mul_inv, mul_div_cancel]\n    exact (ne_of_lt (pow_pos r_pos _)).symm\n  · have kn : k + n.succ ≥ n.succ := by\n      rw [← zero_add n.succ] <;> exact add_le_add (zero_le _) (by simp)\n    rw [hk, Nat.succ_add, pow_succ' r, ← mul_assoc]\n    exact\n      le_trans (by rw [mul_comm] <;> exact h _ (Nat.le_of_succ_le kn))\n        (mul_le_mul_of_nonneg_right (ih (k + n.succ) n h kn rfl) hr0)\n#align series_ratio_test series_ratio_test\n\n#print sum_range_diag_flip /-\ntheorem sum_range_diag_flip {α : Type _} [AddCommMonoid α] (n : ℕ) (f : ℕ → ℕ → α) :\n    (∑ m in range n, ∑ k in range (m + 1), f k (m - k)) =\n      ∑ m in range n, ∑ k in range (n - m), f m k :=\n  by\n  rw [sum_sigma', sum_sigma'] <;>\n    exact\n      sum_bij (fun a _ => ⟨a.2, a.1 - a.2⟩)\n        (fun a ha =>\n          have h₁ : a.1 < n := mem_range.1 (mem_sigma.1 ha).1\n          have h₂ : a.2 < Nat.succ a.1 := mem_range.1 (mem_sigma.1 ha).2\n          mem_sigma.2\n            ⟨mem_range.2 (lt_of_lt_of_le h₂ h₁),\n              mem_range.2 ((tsub_lt_tsub_iff_right (Nat.le_of_lt_succ h₂)).2 h₁)⟩)\n        (fun _ _ => rfl)\n        (fun ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ha hb h =>\n          have ha : a₁ < n ∧ a₂ ≤ a₁ :=\n            ⟨mem_range.1 (mem_sigma.1 ha).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 ha).2)⟩\n          have hb : b₁ < n ∧ b₂ ≤ b₁ :=\n            ⟨mem_range.1 (mem_sigma.1 hb).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 hb).2)⟩\n          have h : a₂ = b₂ ∧ _ := Sigma.mk.inj h\n          have h' : a₁ = b₁ - b₂ + a₂ := (tsub_eq_iff_eq_add_of_le ha.2).1 (eq_of_hEq h.2)\n          Sigma.mk.inj_iff.2 ⟨tsub_add_cancel_of_le hb.2 ▸ h'.symm ▸ h.1 ▸ rfl, hEq_of_eq h.1⟩)\n        fun ⟨a₁, a₂⟩ ha =>\n        have ha : a₁ < n ∧ a₂ < n - a₁ :=\n          ⟨mem_range.1 (mem_sigma.1 ha).1, mem_range.1 (mem_sigma.1 ha).2⟩\n        ⟨⟨a₂ + a₁, a₁⟩,\n          ⟨mem_sigma.2\n              ⟨mem_range.2 (lt_tsub_iff_right.1 ha.2),\n                mem_range.2 (Nat.lt_succ_of_le (Nat.le_add_left _ _))⟩,\n            Sigma.mk.inj_iff.2 ⟨rfl, hEq_of_eq (add_tsub_cancel_right _ _).symm⟩⟩⟩\n#align sum_range_diag_flip sum_range_diag_flip\n-/\n\nend\n\nsection NoArchimedean\n\nvariable {α : Type _} {β : Type _} [LinearOrderedField α] {abv : β → α}\n\nsection\n\nvariable [Semiring β] [IsAbsoluteValue abv]\n\n/- warning: abv_sum_le_sum_abv -> abv_sum_le_sum_abv is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} α] {abv : β -> α} [_inst_2 : Semiring.{u2} β] [_inst_3 : IsAbsoluteValue.{u1, u2} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) β _inst_2 abv] {γ : Type.{u3}} (f : γ -> β) (s : Finset.{u3} γ), LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (abv (Finset.sum.{u2, u3} β γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} β (Semiring.toNonAssocSemiring.{u2} β _inst_2))) s (fun (k : γ) => f k))) (Finset.sum.{u1, u3} α γ (AddCommGroup.toAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) s (fun (k : γ) => abv (f k)))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} α] {abv : β -> α} [_inst_2 : Semiring.{u1} β] [_inst_3 : IsAbsoluteValue.{u2, u1} α (OrderedCommSemiring.toOrderedSemiring.{u2} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1))))) β _inst_2 abv] {γ : Type.{u3}} (f : γ -> β) (s : Finset.{u3} γ), LE.le.{u2} α (Preorder.toLE.{u2} α (PartialOrder.toPreorder.{u2} α (StrictOrderedRing.toPartialOrder.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))))) (abv (Finset.sum.{u1, u3} β γ (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} β (Semiring.toNonAssocSemiring.{u1} β _inst_2))) s (fun (k : γ) => f k))) (Finset.sum.{u2, u3} α γ (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1)))))) s (fun (k : γ) => abv (f k)))\nCase conversion may be inaccurate. Consider using '#align abv_sum_le_sum_abv abv_sum_le_sum_abvₓ'. -/\ntheorem abv_sum_le_sum_abv {γ : Type _} (f : γ → β) (s : Finset γ) :\n    abv (∑ k in s, f k) ≤ ∑ k in s, abv (f k) :=\n  haveI := Classical.decEq γ\n  Finset.induction_on s (by simp [abv_zero abv]) fun a s has ih => by\n    rw [sum_insert has, sum_insert has] <;> exact le_trans (abv_add abv _ _) (add_le_add_left ih _)\n#align abv_sum_le_sum_abv abv_sum_le_sum_abv\n\nend\n\nsection\n\nvariable [Ring β] [IsAbsoluteValue abv]\n\n/- warning: cauchy_product -> cauchy_product is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} α] {abv : β -> α} [_inst_2 : Ring.{u2} β] [_inst_3 : IsAbsoluteValue.{u1, u2} α (StrictOrderedSemiring.toOrderedSemiring.{u1} α (StrictOrderedRing.toStrictOrderedSemiring.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))) β (Ring.toSemiring.{u2} β _inst_2) abv] {a : Nat -> β} {b : Nat -> β}, (IsCauSeq.{u1, u1} α _inst_1 α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))) (Abs.abs.{u1} α (Neg.toHasAbs.{u1} α (SubNegMonoid.toHasNeg.{u1} α (AddGroup.toSubNegMonoid.{u1} α (AddGroupWithOne.toAddGroup.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} α (Lattice.toSemilatticeSup.{u1} α (LinearOrder.toLattice.{u1} α (LinearOrderedRing.toLinearOrder.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (fun (m : Nat) => Finset.sum.{u1, 0} α Nat (AddCommGroup.toAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Finset.range m) (fun (n : Nat) => abv (a n)))) -> (IsCauSeq.{u1, u2} α _inst_1 β _inst_2 abv (fun (m : Nat) => Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_2)))) (Finset.range m) (fun (n : Nat) => b n))) -> (forall (ε : α), (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (OfNat.ofNat.{u1} α 0 (OfNat.mk.{u1} α 0 (Zero.zero.{u1} α (MulZeroClass.toHasZero.{u1} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} α (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))))))) ε) -> (Exists.{1} Nat (fun (i : Nat) => forall (j : Nat), (GE.ge.{0} Nat Nat.hasLe j i) -> (LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (abv (HSub.hSub.{u2, u2, u2} β β β (instHSub.{u2} β (SubNegMonoid.toHasSub.{u2} β (AddGroup.toSubNegMonoid.{u2} β (AddGroupWithOne.toAddGroup.{u2} β (AddCommGroupWithOne.toAddGroupWithOne.{u2} β (Ring.toAddCommGroupWithOne.{u2} β _inst_2)))))) (HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (Ring.toDistrib.{u2} β _inst_2))) (Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_2)))) (Finset.range j) (fun (k : Nat) => a k)) (Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_2)))) (Finset.range j) (fun (k : Nat) => b k))) (Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_2)))) (Finset.range j) (fun (n : Nat) => Finset.sum.{u2, 0} β Nat (AddCommGroup.toAddCommMonoid.{u2} β (NonUnitalNonAssocRing.toAddCommGroup.{u2} β (NonAssocRing.toNonUnitalNonAssocRing.{u2} β (Ring.toNonAssocRing.{u2} β _inst_2)))) (Finset.range (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))))) (fun (m : Nat) => HMul.hMul.{u2, u2, u2} β β β (instHMul.{u2} β (Distrib.toHasMul.{u2} β (Ring.toDistrib.{u2} β _inst_2))) (a m) (b (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) n m))))))) ε))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} α] {abv : β -> α} [_inst_2 : Ring.{u1} β] [_inst_3 : IsAbsoluteValue.{u2, u1} α (OrderedCommSemiring.toOrderedSemiring.{u2} α (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} α (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1))))) β (Ring.toSemiring.{u1} β _inst_2) abv] {a : Nat -> β} {b : Nat -> β}, (IsCauSeq.{u2, u2} α _inst_1 α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))) (Abs.abs.{u2} α (Neg.toHasAbs.{u2} α (Ring.toNeg.{u2} α (StrictOrderedRing.toRing.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1))))) (SemilatticeSup.toSup.{u2} α (Lattice.toSemilatticeSup.{u2} α (DistribLattice.toLattice.{u2} α (instDistribLattice.{u2} α (LinearOrderedRing.toLinearOrder.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1))))))))) (fun (m : Nat) => Finset.sum.{u2, 0} α Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1)))))) (Finset.range m) (fun (n : Nat) => abv (a n)))) -> (IsCauSeq.{u2, u1} α _inst_1 β _inst_2 abv (fun (m : Nat) => Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_2)))) (Finset.range m) (fun (n : Nat) => b n))) -> (forall (ε : α), (LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (StrictOrderedRing.toPartialOrder.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))))) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (CommMonoidWithZero.toZero.{u2} α (CommGroupWithZero.toCommMonoidWithZero.{u2} α (Semifield.toCommGroupWithZero.{u2} α (LinearOrderedSemifield.toSemifield.{u2} α (LinearOrderedField.toLinearOrderedSemifield.{u2} α _inst_1))))))) ε) -> (Exists.{1} Nat (fun (i : Nat) => forall (j : Nat), (GE.ge.{0} Nat instLENat j i) -> (LT.lt.{u2} α (Preorder.toLT.{u2} α (PartialOrder.toPreorder.{u2} α (StrictOrderedRing.toPartialOrder.{u2} α (LinearOrderedRing.toStrictOrderedRing.{u2} α (LinearOrderedCommRing.toLinearOrderedRing.{u2} α (LinearOrderedField.toLinearOrderedCommRing.{u2} α _inst_1)))))) (abv (HSub.hSub.{u1, u1, u1} β β β (instHSub.{u1} β (Ring.toSub.{u1} β _inst_2)) (HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (NonUnitalNonAssocRing.toMul.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_2)))) (Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_2)))) (Finset.range j) (fun (k : Nat) => a k)) (Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_2)))) (Finset.range j) (fun (k : Nat) => b k))) (Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_2)))) (Finset.range j) (fun (n : Nat) => Finset.sum.{u1, 0} β Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} β (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_2)))) (Finset.range (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))) (fun (m : Nat) => HMul.hMul.{u1, u1, u1} β β β (instHMul.{u1} β (NonUnitalNonAssocRing.toMul.{u1} β (NonAssocRing.toNonUnitalNonAssocRing.{u1} β (Ring.toNonAssocRing.{u1} β _inst_2)))) (a m) (b (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) n m))))))) ε))))\nCase conversion may be inaccurate. Consider using '#align cauchy_product cauchy_productₓ'. -/\ntheorem cauchy_product {a b : ℕ → β} (ha : IsCauSeq abs fun m => ∑ n in range m, abv (a n))\n    (hb : IsCauSeq abv fun m => ∑ n in range m, b n) (ε : α) (ε0 : 0 < ε) :\n    ∃ i : ℕ,\n      ∀ j ≥ i,\n        abv\n            (((∑ k in range j, a k) * ∑ k in range j, b k) -\n              ∑ n in range j, ∑ m in range (n + 1), a m * b (n - m)) <\n          ε :=\n  let ⟨Q, hQ⟩ := CauSeq.bounded ⟨_, hb⟩\n  let ⟨P, hP⟩ := CauSeq.bounded ⟨_, ha⟩\n  have hP0 : 0 < P := lt_of_le_of_lt (abs_nonneg _) (hP 0)\n  have hPε0 : 0 < ε / (2 * P) := div_pos ε0 (mul_pos (show (2 : α) > 0 by norm_num) hP0)\n  let ⟨N, hN⟩ := CauSeq.cauchy₂ ⟨_, hb⟩ hPε0\n  have hQε0 : 0 < ε / (4 * Q) :=\n    div_pos ε0 (mul_pos (show (0 : α) < 4 by norm_num) (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0)))\n  let ⟨M, hM⟩ := CauSeq.cauchy₂ ⟨_, ha⟩ hQε0\n  ⟨2 * (max N M + 1), fun K hK =>\n    by\n    have h₁ :\n      (∑ m in range K, ∑ k in range (m + 1), a k * b (m - k)) =\n        ∑ m in range K, ∑ n in range (K - m), a m * b n :=\n      by simpa using sum_range_diag_flip K fun m n => a m * b n\n    have h₂ :\n      (fun i => ∑ k in range (K - i), a i * b k) = fun i => a i * ∑ k in range (K - i), b k := by\n      simp [Finset.mul_sum]\n    have h₃ :\n      (∑ i in range K, a i * ∑ k in range (K - i), b k) =\n        (∑ i in range K, a i * ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) +\n          ∑ i in range K, a i * ∑ k in range K, b k :=\n      by rw [← sum_add_distrib] <;> simp [(mul_add _ _ _).symm]\n    have two_mul_two : (4 : α) = 2 * 2 := by norm_num\n    have hQ0 : Q ≠ 0 := fun h => by simpa [h, lt_irrefl] using hQε0\n    have h2Q0 : 2 * Q ≠ 0 := mul_ne_zero two_ne_zero hQ0\n    have hε : ε / (2 * P) * P + ε / (4 * Q) * (2 * Q) = ε := by\n      rw [← div_div, div_mul_cancel _ (Ne.symm (ne_of_lt hP0)), two_mul_two, mul_assoc, ← div_div,\n        div_mul_cancel _ h2Q0, add_halves]\n    have hNMK : max N M + 1 < K :=\n      lt_of_lt_of_le (by rw [two_mul] <;> exact lt_add_of_pos_left _ (Nat.succ_pos _)) hK\n    have hKN : N < K :=\n      calc\n        N ≤ max N M := le_max_left _ _\n        _ < max N M + 1 := (Nat.lt_succ_self _)\n        _ < K := hNMK\n        \n    have hsumlesum :\n      (∑ i in range (max N M + 1),\n          abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) ≤\n        ∑ i in range (max N M + 1), abv (a i) * (ε / (2 * P)) :=\n      sum_le_sum fun m hmJ =>\n        mul_le_mul_of_nonneg_left\n          (le_of_lt\n            (hN (K - m)\n              (le_tsub_of_add_le_left\n                (le_trans\n                  (by\n                    rw [two_mul] <;>\n                      exact\n                        add_le_add (le_of_lt (mem_range.1 hmJ))\n                          (le_trans (le_max_left _ _) (le_of_lt (lt_add_one _))))\n                  hK))\n              K (le_of_lt hKN)))\n          (abv_nonneg abv _)\n    have hsumltP : (∑ n in range (max N M + 1), abv (a n)) < P :=\n      calc\n        (∑ n in range (max N M + 1), abv (a n)) = |∑ n in range (max N M + 1), abv (a n)| :=\n          Eq.symm (abs_of_nonneg (sum_nonneg fun x h => abv_nonneg abv (a x)))\n        _ < P := hP (max N M + 1)\n        \n    rw [h₁, h₂, h₃, sum_mul, ← sub_sub, sub_right_comm, sub_self, zero_sub, abv_neg abv]\n    refine' lt_of_le_of_lt (abv_sum_le_sum_abv _ _) _\n    suffices\n      (∑ i in range (max N M + 1),\n            abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) +\n          ((∑ i in range K, abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) -\n            ∑ i in range (max N M + 1),\n              abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) <\n        ε / (2 * P) * P + ε / (4 * Q) * (2 * Q)\n      by\n      rw [hε] at this\n      simpa [abv_mul abv]\n    refine'\n      add_lt_add\n        (lt_of_le_of_lt hsumlesum\n          (by rw [← sum_mul, mul_comm] <;> exact (mul_lt_mul_left hPε0).mpr hsumltP))\n        _\n    rw [sum_range_sub_sum_range (le_of_lt hNMK)]\n    calc\n      (∑ i in (range K).filterₓ fun k => max N M + 1 ≤ k,\n            abv (a i) * abv ((∑ k in range (K - i), b k) - ∑ k in range K, b k)) ≤\n          ∑ i in (range K).filterₓ fun k => max N M + 1 ≤ k, abv (a i) * (2 * Q) :=\n        sum_le_sum fun n hn =>\n          by\n          refine' mul_le_mul_of_nonneg_left _ (abv_nonneg _ _)\n          rw [sub_eq_add_neg]\n          refine' le_trans (abv_add _ _ _) _\n          rw [two_mul, abv_neg abv]\n          exact add_le_add (le_of_lt (hQ _)) (le_of_lt (hQ _))\n      _ < ε / (4 * Q) * (2 * Q) := by\n        rw [← sum_mul, ← sum_range_sub_sum_range (le_of_lt hNMK)] <;>\n          refine'\n            (mul_lt_mul_right <| by\n                  rw [two_mul] <;>\n                    exact\n                      add_pos (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))\n                        (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))).2\n              (lt_of_le_of_lt (le_abs_self _)\n                (hM _ (le_trans (Nat.le_succ_of_le (le_max_right _ _)) (le_of_lt hNMK)) _\n                  (Nat.le_succ_of_le (le_max_right _ _))))\n      ⟩\n#align cauchy_product cauchy_product\n\nend\n\nend NoArchimedean\n\nend\n\nopen Finset\n\nopen CauSeq\n\nnamespace Complex\n\n/- warning: complex.is_cau_abs_exp -> Complex.isCauSeq_abs_exp is a dubious translation:\nlean 3 declaration is\n  forall (z : Complex), IsCauSeq.{0, 0} Real Real.linearOrderedField Real Real.ring (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup)) (fun (n : Nat) => Finset.sum.{0, 0} Real Nat Real.addCommMonoid (Finset.range n) (fun (m : Nat) => coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) z m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Complex (HasLiftT.mk.{1, 1} Nat Complex (CoeTCₓ.coe.{1, 1} Nat Complex (Nat.castCoe.{0} Complex (AddMonoidWithOne.toNatCast.{0} Complex (AddGroupWithOne.toAddMonoidWithOne.{0} Complex Complex.addGroupWithOne))))) (Nat.factorial m)))))\nbut is expected to have type\n  forall (z : Complex), IsCauSeq.{0, 0} Real Real.instLinearOrderedFieldReal Real Real.instRingReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal)) (fun (n : Nat) => Finset.sum.{0, 0} Real Nat Real.instAddCommMonoidReal (Finset.range n) (fun (m : Nat) => FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) z m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))\nCase conversion may be inaccurate. Consider using '#align complex.is_cau_abs_exp Complex.isCauSeq_abs_expₓ'. -/\ntheorem isCauSeq_abs_exp (z : ℂ) : IsCauSeq Abs.abs fun n => ∑ m in range n, abs (z ^ m / m !) :=\n  let ⟨n, hn⟩ := exists_nat_gt (abs z)\n  have hn0 : (0 : ℝ) < n := lt_of_le_of_lt (abs.NonNeg _) hn\n  series_ratio_test n (Complex.abs z / n) (div_nonneg (abs.NonNeg _) (le_of_lt hn0))\n    (by rwa [div_lt_iff hn0, one_mul]) fun m hm => by\n    rw [abs_abs, abs_abs, Nat.factorial_succ, pow_succ, mul_comm m.succ, Nat.cast_mul, ← div_div,\n        mul_div_assoc, mul_div_right_comm, abs.map_mul, map_div₀, abs_cast_nat] <;>\n      exact\n        mul_le_mul_of_nonneg_right\n          (div_le_div_of_le_left (abs.nonneg _) hn0 (Nat.cast_le.2 (le_trans hm (Nat.le_succ _))))\n          (abs.nonneg _)\n#align complex.is_cau_abs_exp Complex.isCauSeq_abs_exp\n\nnoncomputable section\n\n/- warning: complex.is_cau_exp -> Complex.isCauSeq_exp is a dubious translation:\nlean 3 declaration is\n  forall (z : Complex), IsCauSeq.{0, 0} Real Real.linearOrderedField Complex Complex.ring (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs) (fun (n : Nat) => Finset.sum.{0, 0} Complex Nat (AddCommGroup.toAddCommMonoid.{0} Complex Complex.addCommGroup) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) z m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Complex (HasLiftT.mk.{1, 1} Nat Complex (CoeTCₓ.coe.{1, 1} Nat Complex (Nat.castCoe.{0} Complex (AddMonoidWithOne.toNatCast.{0} Complex (AddGroupWithOne.toAddMonoidWithOne.{0} Complex Complex.addGroupWithOne))))) (Nat.factorial m))))\nbut is expected to have type\n  forall (z : Complex), IsCauSeq.{0, 0} Real Real.instLinearOrderedFieldReal Complex Complex.instRingComplex (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs) (fun (n : Nat) => Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) z m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m))))\nCase conversion may be inaccurate. Consider using '#align complex.is_cau_exp Complex.isCauSeq_expₓ'. -/\ntheorem isCauSeq_exp (z : ℂ) : IsCauSeq abs fun n => ∑ m in range n, z ^ m / m ! :=\n  isCauSeq_series_of_abv_isCauSeq (isCauSeq_abs_exp z)\n#align complex.is_cau_exp Complex.isCauSeq_exp\n\n/- warning: complex.exp' -> Complex.exp' is a dubious translation:\nlean 3 declaration is\n  Complex -> (CauSeq.{0, 0} Real Real.linearOrderedField Complex Complex.ring (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs))\nbut is expected to have type\n  Complex -> (CauSeq.{0, 0} Real Real.instLinearOrderedFieldReal Complex Complex.instRingComplex (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs))\nCase conversion may be inaccurate. Consider using '#align complex.exp' Complex.exp'ₓ'. -/\n/-- The Cauchy sequence consisting of partial sums of the Taylor series of\nthe complex exponential function -/\n@[pp_nodot]\ndef exp' (z : ℂ) : CauSeq ℂ Complex.abs :=\n  ⟨fun n => ∑ m in range n, z ^ m / m !, isCauSeq_exp z⟩\n#align complex.exp' Complex.exp'\n\n#print Complex.exp /-\n/-- The complex exponential function, defined via its Taylor series -/\n@[pp_nodot]\nirreducible_def exp (z : ℂ) : ℂ :=\n  limUnder (exp' z)\n#align complex.exp Complex.exp\n-/\n\n#print Complex.sin /-\n/-- The complex sine function, defined via `exp` -/\n@[pp_nodot]\ndef sin (z : ℂ) : ℂ :=\n  (exp (-z * I) - exp (z * I)) * I / 2\n#align complex.sin Complex.sin\n-/\n\n#print Complex.cos /-\n/-- The complex cosine function, defined via `exp` -/\n@[pp_nodot]\ndef cos (z : ℂ) : ℂ :=\n  (exp (z * I) + exp (-z * I)) / 2\n#align complex.cos Complex.cos\n-/\n\n#print Complex.tan /-\n/-- The complex tangent function, defined as `sin z / cos z` -/\n@[pp_nodot]\ndef tan (z : ℂ) : ℂ :=\n  sin z / cos z\n#align complex.tan Complex.tan\n-/\n\n#print Complex.sinh /-\n/-- The complex hyperbolic sine function, defined via `exp` -/\n@[pp_nodot]\ndef sinh (z : ℂ) : ℂ :=\n  (exp z - exp (-z)) / 2\n#align complex.sinh Complex.sinh\n-/\n\n#print Complex.cosh /-\n/-- The complex hyperbolic cosine function, defined via `exp` -/\n@[pp_nodot]\ndef cosh (z : ℂ) : ℂ :=\n  (exp z + exp (-z)) / 2\n#align complex.cosh Complex.cosh\n-/\n\n#print Complex.tanh /-\n/-- The complex hyperbolic tangent function, defined as `sinh z / cosh z` -/\n@[pp_nodot]\ndef tanh (z : ℂ) : ℂ :=\n  sinh z / cosh z\n#align complex.tanh Complex.tanh\n-/\n\nend Complex\n\nnamespace Real\n\nopen Complex\n\n#print Real.exp /-\n/-- The real exponential function, defined as the real part of the complex exponential -/\n@[pp_nodot]\ndef exp (x : ℝ) : ℝ :=\n  (exp x).re\n#align real.exp Real.exp\n-/\n\n#print Real.sin /-\n/-- The real sine function, defined as the real part of the complex sine -/\n@[pp_nodot]\ndef sin (x : ℝ) : ℝ :=\n  (sin x).re\n#align real.sin Real.sin\n-/\n\n#print Real.cos /-\n/-- The real cosine function, defined as the real part of the complex cosine -/\n@[pp_nodot]\ndef cos (x : ℝ) : ℝ :=\n  (cos x).re\n#align real.cos Real.cos\n-/\n\n#print Real.tan /-\n/-- The real tangent function, defined as the real part of the complex tangent -/\n@[pp_nodot]\ndef tan (x : ℝ) : ℝ :=\n  (tan x).re\n#align real.tan Real.tan\n-/\n\n#print Real.sinh /-\n/-- The real hypebolic sine function, defined as the real part of the complex hyperbolic sine -/\n@[pp_nodot]\ndef sinh (x : ℝ) : ℝ :=\n  (sinh x).re\n#align real.sinh Real.sinh\n-/\n\n#print Real.cosh /-\n/-- The real hypebolic cosine function, defined as the real part of the complex hyperbolic cosine -/\n@[pp_nodot]\ndef cosh (x : ℝ) : ℝ :=\n  (cosh x).re\n#align real.cosh Real.cosh\n-/\n\n#print Real.tanh /-\n/-- The real hypebolic tangent function, defined as the real part of\nthe complex hyperbolic tangent -/\n@[pp_nodot]\ndef tanh (x : ℝ) : ℝ :=\n  (tanh x).re\n#align real.tanh Real.tanh\n-/\n\nend Real\n\nnamespace Complex\n\nvariable (x y : ℂ)\n\n/- warning: complex.exp_zero -> Complex.exp_zero is a dubious translation:\nlean 3 declaration is\n  Eq.{1} Complex (Complex.exp (OfNat.ofNat.{0} Complex 0 (OfNat.mk.{0} Complex 0 (Zero.zero.{0} Complex Complex.hasZero)))) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne)))\nbut is expected to have type\n  Eq.{1} Complex (Complex.exp (OfNat.ofNat.{0} Complex 0 (Zero.toOfNat0.{0} Complex Complex.instZeroComplex))) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex))\nCase conversion may be inaccurate. Consider using '#align complex.exp_zero Complex.exp_zeroₓ'. -/\n@[simp]\ntheorem exp_zero : exp 0 = 1 := by\n  rw [exp]\n  refine' lim_eq_of_equiv_const fun ε ε0 => ⟨1, fun j hj => _⟩\n  convert ε0\n  cases j\n  · exact absurd hj (not_le_of_gt zero_lt_one)\n  · dsimp [exp']\n    induction' j with j ih\n    · dsimp [exp'] <;> simp\n    · rw [← ih (by decide)]\n      simp only [sum_range_succ, pow_succ]\n      simp\n#align complex.exp_zero Complex.exp_zero\n\n/- warning: complex.exp_add -> Complex.exp_add is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (Complex.exp (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) x y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.exp x) (Complex.exp y))\nbut is expected to have type\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (Complex.exp (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) x y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.exp x) (Complex.exp y))\nCase conversion may be inaccurate. Consider using '#align complex.exp_add Complex.exp_addₓ'. -/\ntheorem exp_add : exp (x + y) = exp x * exp y :=\n  by\n  have hj :\n    ∀ j : ℕ,\n      (∑ m in range j, (x + y) ^ m / m !) =\n        ∑ i in range j, ∑ k in range (i + 1), x ^ k / k ! * (y ^ (i - k) / (i - k)!) :=\n    by\n    intro j\n    refine' Finset.sum_congr rfl fun m hm => _\n    rw [add_pow, div_eq_mul_inv, sum_mul]\n    refine' Finset.sum_congr rfl fun i hi => _\n    have h₁ : (m.choose i : ℂ) ≠ 0 :=\n      Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.choose_pos (Nat.le_of_lt_succ (mem_range.1 hi))))\n    have h₂ := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi)\n    rw [← h₂, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv]\n    simp only [mul_left_comm (m.choose i : ℂ), mul_assoc, mul_left_comm (m.choose i : ℂ)⁻¹,\n      mul_comm (m.choose i : ℂ)]\n    rw [inv_mul_cancel h₁]\n    simp [div_eq_mul_inv, mul_comm, mul_assoc, mul_left_comm]\n  simp_rw [exp, exp', lim_mul_lim]\n  apply (lim_eq_lim_of_equiv _).symm\n  simp only [hj]\n  exact cauchy_product (is_cau_abs_exp x) (is_cau_exp y)\n#align complex.exp_add Complex.exp_add\n\n#print Complex.exp_list_sum /-\ntheorem exp_list_sum (l : List ℂ) : exp l.Sum = (l.map exp).Prod :=\n  @MonoidHom.map_list_prod (Multiplicative ℂ) ℂ _ _ ⟨exp, exp_zero, exp_add⟩ l\n#align complex.exp_list_sum Complex.exp_list_sum\n-/\n\n#print Complex.exp_multiset_sum /-\ntheorem exp_multiset_sum (s : Multiset ℂ) : exp s.Sum = (s.map exp).Prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative ℂ) ℂ _ _ ⟨exp, exp_zero, exp_add⟩ s\n#align complex.exp_multiset_sum Complex.exp_multiset_sum\n-/\n\n#print Complex.exp_sum /-\ntheorem exp_sum {α : Type _} (s : Finset α) (f : α → ℂ) :\n    exp (∑ x in s, f x) = ∏ x in s, exp (f x) :=\n  @MonoidHom.map_prod (Multiplicative ℂ) α ℂ _ _ ⟨exp, exp_zero, exp_add⟩ f s\n#align complex.exp_sum Complex.exp_sum\n-/\n\n/- warning: complex.exp_nat_mul -> Complex.exp_nat_mul is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex) (n : Nat), Eq.{1} Complex (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Complex (HasLiftT.mk.{1, 1} Nat Complex (CoeTCₓ.coe.{1, 1} Nat Complex (Nat.castCoe.{0} Complex (AddMonoidWithOne.toNatCast.{0} Complex (AddGroupWithOne.toAddMonoidWithOne.{0} Complex Complex.addGroupWithOne))))) n) x)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.exp x) n)\nbut is expected to have type\n  forall (x : Complex) (n : Nat), Eq.{1} Complex (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) n) x)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.exp x) n)\nCase conversion may be inaccurate. Consider using '#align complex.exp_nat_mul Complex.exp_nat_mulₓ'. -/\ntheorem exp_nat_mul (x : ℂ) : ∀ n : ℕ, exp (n * x) = exp x ^ n\n  | 0 => by rw [Nat.cast_zero, MulZeroClass.zero_mul, exp_zero, pow_zero]\n  | Nat.succ n => by rw [pow_succ', Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul, one_mul]\n#align complex.exp_nat_mul Complex.exp_nat_mul\n\n/- warning: complex.exp_ne_zero -> Complex.exp_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Ne.{1} Complex (Complex.exp x) (OfNat.ofNat.{0} Complex 0 (OfNat.mk.{0} Complex 0 (Zero.zero.{0} Complex Complex.hasZero)))\nbut is expected to have type\n  forall (x : Complex), Ne.{1} Complex (Complex.exp x) (OfNat.ofNat.{0} Complex 0 (Zero.toOfNat0.{0} Complex Complex.instZeroComplex))\nCase conversion may be inaccurate. Consider using '#align complex.exp_ne_zero Complex.exp_ne_zeroₓ'. -/\ntheorem exp_ne_zero : exp x ≠ 0 := fun h =>\n  zero_ne_one <| by rw [← exp_zero, ← add_neg_self x, exp_add, h] <;> simp\n#align complex.exp_ne_zero Complex.exp_ne_zero\n\n/- warning: complex.exp_neg -> Complex.exp_neg is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (Complex.exp (Neg.neg.{0} Complex Complex.hasNeg x)) (Inv.inv.{0} Complex Complex.hasInv (Complex.exp x))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (Complex.exp (Neg.neg.{0} Complex Complex.instNegComplex x)) (Inv.inv.{0} Complex Complex.instInvComplex (Complex.exp x))\nCase conversion may be inaccurate. Consider using '#align complex.exp_neg Complex.exp_negₓ'. -/\ntheorem exp_neg : exp (-x) = (exp x)⁻¹ := by\n  rw [← mul_right_inj' (exp_ne_zero x), ← exp_add] <;> simp [mul_inv_cancel (exp_ne_zero x)]\n#align complex.exp_neg Complex.exp_neg\n\n/- warning: complex.exp_sub -> Complex.exp_sub is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (Complex.exp (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) x y)) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (Complex.exp x) (Complex.exp y))\nbut is expected to have type\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (Complex.exp (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) x y)) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (Complex.exp x) (Complex.exp y))\nCase conversion may be inaccurate. Consider using '#align complex.exp_sub Complex.exp_subₓ'. -/\ntheorem exp_sub : exp (x - y) = exp x / exp y := by\n  simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv]\n#align complex.exp_sub Complex.exp_sub\n\n/- warning: complex.exp_int_mul -> Complex.exp_int_mul is a dubious translation:\nlean 3 declaration is\n  forall (z : Complex) (n : Int), Eq.{1} Complex (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Int Complex (HasLiftT.mk.{1, 1} Int Complex (CoeTCₓ.coe.{1, 1} Int Complex (Int.castCoe.{0} Complex (AddGroupWithOne.toHasIntCast.{0} Complex Complex.addGroupWithOne)))) n) z)) (HPow.hPow.{0, 0, 0} Complex Int Complex (instHPow.{0, 0} Complex Int (DivInvMonoid.Pow.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (Complex.exp z) n)\nbut is expected to have type\n  forall (z : Complex) (n : Int), Eq.{1} Complex (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Int.cast.{0} Complex (Ring.toIntCast.{0} Complex Complex.instRingComplex) n) z)) (HPow.hPow.{0, 0, 0} Complex Int Complex (instHPow.{0, 0} Complex Int (DivInvMonoid.Pow.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.instFieldComplex)))) (Complex.exp z) n)\nCase conversion may be inaccurate. Consider using '#align complex.exp_int_mul Complex.exp_int_mulₓ'. -/\ntheorem exp_int_mul (z : ℂ) (n : ℤ) : Complex.exp (n * z) = Complex.exp z ^ n :=\n  by\n  cases n\n  · apply Complex.exp_nat_mul\n  · simpa [Complex.exp_neg, add_comm, ← neg_mul] using Complex.exp_nat_mul (-z) (1 + n)\n#align complex.exp_int_mul Complex.exp_int_mul\n\n/- warning: complex.exp_conj -> Complex.exp_conj is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (Complex.exp (coeFn.{1, 1} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring))) (fun (_x : RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring))) => Complex -> Complex) (RingHom.hasCoeToFun.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring))) (starRingEnd.{0} Complex Complex.commSemiring Complex.starRing) x)) (coeFn.{1, 1} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring))) (fun (_x : RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring))) => Complex -> Complex) (RingHom.hasCoeToFun.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.commSemiring))) (starRingEnd.{0} Complex Complex.commSemiring Complex.starRing) (Complex.exp x))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (Complex.exp (FunLike.coe.{1, 1, 1} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex (fun (_x : Complex) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Complex) => Complex) _x) (MulHomClass.toFunLike.{0, 0, 0} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex Complex (NonUnitalNonAssocSemiring.toMul.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)))) (NonUnitalNonAssocSemiring.toMul.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)))) (NonUnitalRingHomClass.toMulHomClass.{0, 0, 0} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) (RingHomClass.toNonUnitalRingHomClass.{0, 0, 0} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (RingHom.instRingHomClassRingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)))))) (starRingEnd.{0} Complex Complex.instCommSemiringComplex Complex.instStarRingComplexToNonUnitalSemiringToNonUnitalRingToNonUnitalCommRingCommRing) x)) (FunLike.coe.{1, 1, 1} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex (fun (_x : Complex) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Complex) => Complex) _x) (MulHomClass.toFunLike.{0, 0, 0} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex Complex (NonUnitalNonAssocSemiring.toMul.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)))) (NonUnitalNonAssocSemiring.toMul.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)))) (NonUnitalRingHomClass.toMulHomClass.{0, 0, 0} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) (RingHomClass.toNonUnitalRingHomClass.{0, 0, 0} (RingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex))) Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (RingHom.instRingHomClassRingHom.{0, 0} Complex Complex (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)) (Semiring.toNonAssocSemiring.{0} Complex (CommSemiring.toSemiring.{0} Complex Complex.instCommSemiringComplex)))))) (starRingEnd.{0} Complex Complex.instCommSemiringComplex Complex.instStarRingComplexToNonUnitalSemiringToNonUnitalRingToNonUnitalCommRingCommRing) (Complex.exp x))\nCase conversion may be inaccurate. Consider using '#align complex.exp_conj Complex.exp_conjₓ'. -/\n@[simp]\ntheorem exp_conj : exp (conj x) = conj (exp x) :=\n  by\n  dsimp [exp]\n  rw [← lim_conj]\n  refine' congr_arg limUnder (CauSeq.ext fun _ => _)\n  dsimp [exp', Function.comp, cau_seq_conj]\n  rw [(starRingEnd _).map_sum]\n  refine' sum_congr rfl fun n hn => _\n  rw [map_div₀, map_pow, ← of_real_nat_cast, conj_of_real]\n#align complex.exp_conj Complex.exp_conj\n\n/- warning: complex.of_real_exp_of_real_re -> Complex.ofReal_exp_ofReal_re is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.re (Complex.exp ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x)))) (Complex.exp ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Complex.re (Complex.exp (Complex.ofReal' x)))) (Complex.exp (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_exp_of_real_re Complex.ofReal_exp_ofReal_reₓ'. -/\n@[simp]\ntheorem ofReal_exp_ofReal_re (x : ℝ) : ((exp x).re : ℂ) = exp x :=\n  eq_conj_iff_re.1 <| by rw [← exp_conj, conj_of_real]\n#align complex.of_real_exp_of_real_re Complex.ofReal_exp_ofReal_re\n\n/- warning: complex.of_real_exp -> Complex.ofReal_exp is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Real.exp x)) (Complex.exp ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Real.exp x)) (Complex.exp (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_exp Complex.ofReal_expₓ'. -/\n@[simp, norm_cast]\ntheorem ofReal_exp (x : ℝ) : (Real.exp x : ℂ) = exp x :=\n  ofReal_exp_ofReal_re _\n#align complex.of_real_exp Complex.ofReal_exp\n\n/- warning: complex.exp_of_real_im -> Complex.exp_ofReal_im is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Complex.im (Complex.exp ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Complex.im (Complex.exp (Complex.ofReal' x))) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))\nCase conversion may be inaccurate. Consider using '#align complex.exp_of_real_im Complex.exp_ofReal_imₓ'. -/\n@[simp]\ntheorem exp_ofReal_im (x : ℝ) : (exp x).im = 0 := by rw [← of_real_exp_of_real_re, of_real_im]\n#align complex.exp_of_real_im Complex.exp_ofReal_im\n\n/- warning: complex.exp_of_real_re -> Complex.exp_ofReal_re is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Complex.re (Complex.exp ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))) (Real.exp x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Complex.re (Complex.exp (Complex.ofReal' x))) (Real.exp x)\nCase conversion may be inaccurate. Consider using '#align complex.exp_of_real_re Complex.exp_ofReal_reₓ'. -/\ntheorem exp_ofReal_re (x : ℝ) : (exp x).re = Real.exp x :=\n  rfl\n#align complex.exp_of_real_re Complex.exp_ofReal_re\n\n/- warning: complex.two_sinh -> Complex.two_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))) (Complex.sinh x)) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp x) (Complex.exp (Neg.neg.{0} Complex Complex.hasNeg x)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Complex.sinh x)) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Complex.exp (Neg.neg.{0} Complex Complex.instNegComplex x)))\nCase conversion may be inaccurate. Consider using '#align complex.two_sinh Complex.two_sinhₓ'. -/\ntheorem two_sinh : 2 * sinh x = exp x - exp (-x) :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_sinh Complex.two_sinh\n\n/- warning: complex.two_cosh -> Complex.two_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))) (Complex.cosh x)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.exp x) (Complex.exp (Neg.neg.{0} Complex Complex.hasNeg x)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Complex.cosh x)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.exp x) (Complex.exp (Neg.neg.{0} Complex Complex.instNegComplex x)))\nCase conversion may be inaccurate. Consider using '#align complex.two_cosh Complex.two_coshₓ'. -/\ntheorem two_cosh : 2 * cosh x = exp x + exp (-x) :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_cosh Complex.two_cosh\n\n#print Complex.sinh_zero /-\n@[simp]\ntheorem sinh_zero : sinh 0 = 0 := by simp [sinh]\n#align complex.sinh_zero Complex.sinh_zero\n-/\n\n#print Complex.sinh_neg /-\n@[simp]\ntheorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul]\n#align complex.sinh_neg Complex.sinh_neg\n-/\n\nprivate theorem sinh_add_aux {a b c d : ℂ} :\n    (a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring\n#align complex.sinh_add_aux complex.sinh_add_aux\n\n#print Complex.sinh_add /-\ntheorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y :=\n  by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, ←\n    mul_assoc, two_sinh, mul_left_comm, two_sinh, ← mul_right_inj' (two_ne_zero' ℂ), mul_add,\n    mul_left_comm, two_cosh, ← mul_assoc, two_cosh]\n  exact sinh_add_aux\n#align complex.sinh_add Complex.sinh_add\n-/\n\n#print Complex.cosh_zero /-\n@[simp]\ntheorem cosh_zero : cosh 0 = 1 := by simp [cosh]\n#align complex.cosh_zero Complex.cosh_zero\n-/\n\n#print Complex.cosh_neg /-\n@[simp]\ntheorem cosh_neg : cosh (-x) = cosh x := by simp [add_comm, cosh, exp_neg]\n#align complex.cosh_neg Complex.cosh_neg\n-/\n\nprivate theorem cosh_add_aux {a b c d : ℂ} :\n    (a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring\n#align complex.cosh_add_aux complex.cosh_add_aux\n\n#print Complex.cosh_add /-\ntheorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y :=\n  by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, ←\n    mul_assoc, two_cosh, ← mul_assoc, two_sinh, ← mul_right_inj' (two_ne_zero' ℂ), mul_add,\n    mul_left_comm, two_cosh, mul_left_comm, two_sinh]\n  exact cosh_add_aux\n#align complex.cosh_add Complex.cosh_add\n-/\n\n#print Complex.sinh_sub /-\ntheorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by\n  simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg]\n#align complex.sinh_sub Complex.sinh_sub\n-/\n\n#print Complex.cosh_sub /-\ntheorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by\n  simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg]\n#align complex.cosh_sub Complex.cosh_sub\n-/\n\n#print Complex.sinh_conj /-\ntheorem sinh_conj : sinh (conj x) = conj (sinh x) := by\n  rw [sinh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_sub, sinh, map_div₀, conj_bit0,\n    RingHom.map_one]\n#align complex.sinh_conj Complex.sinh_conj\n-/\n\n#print Complex.ofReal_sinh_ofReal_re /-\n@[simp]\ntheorem ofReal_sinh_ofReal_re (x : ℝ) : ((sinh x).re : ℂ) = sinh x :=\n  eq_conj_iff_re.1 <| by rw [← sinh_conj, conj_of_real]\n#align complex.of_real_sinh_of_real_re Complex.ofReal_sinh_ofReal_re\n-/\n\n/- warning: complex.of_real_sinh -> Complex.ofReal_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Real.sinh x)) (Complex.sinh ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Real.sinh x)) (Complex.sinh (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_sinh Complex.ofReal_sinhₓ'. -/\n@[simp, norm_cast]\ntheorem ofReal_sinh (x : ℝ) : (Real.sinh x : ℂ) = sinh x :=\n  ofReal_sinh_ofReal_re _\n#align complex.of_real_sinh Complex.ofReal_sinh\n\n#print Complex.sinh_of_real_im /-\n@[simp]\ntheorem sinh_of_real_im (x : ℝ) : (sinh x).im = 0 := by rw [← of_real_sinh_of_real_re, of_real_im]\n#align complex.sinh_of_real_im Complex.sinh_of_real_im\n-/\n\n#print Complex.sinh_of_real_re /-\ntheorem sinh_of_real_re (x : ℝ) : (sinh x).re = Real.sinh x :=\n  rfl\n#align complex.sinh_of_real_re Complex.sinh_of_real_re\n-/\n\n#print Complex.cosh_conj /-\ntheorem cosh_conj : cosh (conj x) = conj (cosh x) := by\n  rw [cosh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_add, cosh, map_div₀, conj_bit0,\n    RingHom.map_one]\n#align complex.cosh_conj Complex.cosh_conj\n-/\n\n#print Complex.ofReal_cosh_ofReal_re /-\ntheorem ofReal_cosh_ofReal_re (x : ℝ) : ((cosh x).re : ℂ) = cosh x :=\n  eq_conj_iff_re.1 <| by rw [← cosh_conj, conj_of_real]\n#align complex.of_real_cosh_of_real_re Complex.ofReal_cosh_ofReal_re\n-/\n\n/- warning: complex.of_real_cosh -> Complex.ofReal_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Real.cosh x)) (Complex.cosh ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Real.cosh x)) (Complex.cosh (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_cosh Complex.ofReal_coshₓ'. -/\n@[simp, norm_cast]\ntheorem ofReal_cosh (x : ℝ) : (Real.cosh x : ℂ) = cosh x :=\n  ofReal_cosh_ofReal_re _\n#align complex.of_real_cosh Complex.ofReal_cosh\n\n#print Complex.cosh_ofReal_im /-\n@[simp]\ntheorem cosh_ofReal_im (x : ℝ) : (cosh x).im = 0 := by rw [← of_real_cosh_of_real_re, of_real_im]\n#align complex.cosh_of_real_im Complex.cosh_ofReal_im\n-/\n\n#print Complex.cosh_ofReal_re /-\n@[simp]\ntheorem cosh_ofReal_re (x : ℝ) : (cosh x).re = Real.cosh x :=\n  rfl\n#align complex.cosh_of_real_re Complex.cosh_ofReal_re\n-/\n\n/- warning: complex.tanh_eq_sinh_div_cosh -> Complex.tanh_eq_sinh_div_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (Complex.tanh x) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (Complex.sinh x) (Complex.cosh x))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (Complex.tanh x) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (Complex.sinh x) (Complex.cosh x))\nCase conversion may be inaccurate. Consider using '#align complex.tanh_eq_sinh_div_cosh Complex.tanh_eq_sinh_div_coshₓ'. -/\ntheorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x :=\n  rfl\n#align complex.tanh_eq_sinh_div_cosh Complex.tanh_eq_sinh_div_cosh\n\n#print Complex.tanh_zero /-\n@[simp]\ntheorem tanh_zero : tanh 0 = 0 := by simp [tanh]\n#align complex.tanh_zero Complex.tanh_zero\n-/\n\n#print Complex.tanh_neg /-\n@[simp]\ntheorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div]\n#align complex.tanh_neg Complex.tanh_neg\n-/\n\n#print Complex.tanh_conj /-\ntheorem tanh_conj : tanh (conj x) = conj (tanh x) := by\n  rw [tanh, sinh_conj, cosh_conj, ← map_div₀, tanh]\n#align complex.tanh_conj Complex.tanh_conj\n-/\n\n#print Complex.ofReal_tanh_ofReal_re /-\n@[simp]\ntheorem ofReal_tanh_ofReal_re (x : ℝ) : ((tanh x).re : ℂ) = tanh x :=\n  eq_conj_iff_re.1 <| by rw [← tanh_conj, conj_of_real]\n#align complex.of_real_tanh_of_real_re Complex.ofReal_tanh_ofReal_re\n-/\n\n/- warning: complex.of_real_tanh -> Complex.ofReal_tanh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Real.tanh x)) (Complex.tanh ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Real.tanh x)) (Complex.tanh (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_tanh Complex.ofReal_tanhₓ'. -/\n@[simp, norm_cast]\ntheorem ofReal_tanh (x : ℝ) : (Real.tanh x : ℂ) = tanh x :=\n  ofReal_tanh_ofReal_re _\n#align complex.of_real_tanh Complex.ofReal_tanh\n\n#print Complex.tanh_ofReal_im /-\n@[simp]\ntheorem tanh_ofReal_im (x : ℝ) : (tanh x).im = 0 := by rw [← of_real_tanh_of_real_re, of_real_im]\n#align complex.tanh_of_real_im Complex.tanh_ofReal_im\n-/\n\n#print Complex.tanh_ofReal_re /-\ntheorem tanh_ofReal_re (x : ℝ) : (tanh x).re = Real.tanh x :=\n  rfl\n#align complex.tanh_of_real_re Complex.tanh_ofReal_re\n-/\n\n/- warning: complex.cosh_add_sinh -> Complex.cosh_add_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cosh x) (Complex.sinh x)) (Complex.exp x)\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cosh x) (Complex.sinh x)) (Complex.exp x)\nCase conversion may be inaccurate. Consider using '#align complex.cosh_add_sinh Complex.cosh_add_sinhₓ'. -/\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), mul_add, two_cosh, two_sinh, add_add_sub_cancel, two_mul]\n#align complex.cosh_add_sinh Complex.cosh_add_sinh\n\n/- warning: complex.sinh_add_cosh -> Complex.sinh_add_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.sinh x) (Complex.cosh x)) (Complex.exp x)\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.sinh x) (Complex.cosh x)) (Complex.exp x)\nCase conversion may be inaccurate. Consider using '#align complex.sinh_add_cosh Complex.sinh_add_coshₓ'. -/\n@[simp]\ntheorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh]\n#align complex.sinh_add_cosh Complex.sinh_add_cosh\n\n/- warning: complex.exp_sub_cosh -> Complex.exp_sub_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp x) (Complex.cosh x)) (Complex.sinh x)\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Complex.cosh x)) (Complex.sinh x)\nCase conversion may be inaccurate. Consider using '#align complex.exp_sub_cosh Complex.exp_sub_coshₓ'. -/\n@[simp]\ntheorem exp_sub_cosh : exp x - cosh x = sinh x :=\n  sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm\n#align complex.exp_sub_cosh Complex.exp_sub_cosh\n\n/- warning: complex.exp_sub_sinh -> Complex.exp_sub_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp x) (Complex.sinh x)) (Complex.cosh x)\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Complex.sinh x)) (Complex.cosh x)\nCase conversion may be inaccurate. Consider using '#align complex.exp_sub_sinh Complex.exp_sub_sinhₓ'. -/\n@[simp]\ntheorem exp_sub_sinh : exp x - sinh x = cosh x :=\n  sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm\n#align complex.exp_sub_sinh Complex.exp_sub_sinh\n\n/- warning: complex.cosh_sub_sinh -> Complex.cosh_sub_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.cosh x) (Complex.sinh x)) (Complex.exp (Neg.neg.{0} Complex Complex.hasNeg x))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.cosh x) (Complex.sinh x)) (Complex.exp (Neg.neg.{0} Complex Complex.instNegComplex x))\nCase conversion may be inaccurate. Consider using '#align complex.cosh_sub_sinh Complex.cosh_sub_sinhₓ'. -/\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), mul_sub, two_cosh, two_sinh, add_sub_sub_cancel, two_mul]\n#align complex.cosh_sub_sinh Complex.cosh_sub_sinh\n\n/- warning: complex.sinh_sub_cosh -> Complex.sinh_sub_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.sinh x) (Complex.cosh x)) (Neg.neg.{0} Complex Complex.hasNeg (Complex.exp (Neg.neg.{0} Complex Complex.hasNeg x)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.sinh x) (Complex.cosh x)) (Neg.neg.{0} Complex Complex.instNegComplex (Complex.exp (Neg.neg.{0} Complex Complex.instNegComplex x)))\nCase conversion may be inaccurate. Consider using '#align complex.sinh_sub_cosh Complex.sinh_sub_coshₓ'. -/\n@[simp]\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh]\n#align complex.sinh_sub_cosh Complex.sinh_sub_cosh\n\n/- warning: complex.cosh_sq_sub_sinh_sq -> Complex.cosh_sq_sub_sinh_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cosh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sinh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cosh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sinh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex))\nCase conversion may be inaccurate. Consider using '#align complex.cosh_sq_sub_sinh_sq Complex.cosh_sq_sub_sinh_sqₓ'. -/\n@[simp]\ntheorem cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 := by\n  rw [sq_sub_sq, cosh_add_sinh, cosh_sub_sinh, ← exp_add, add_neg_self, exp_zero]\n#align complex.cosh_sq_sub_sinh_sq Complex.cosh_sq_sub_sinh_sq\n\n/- warning: complex.cosh_sq -> Complex.cosh_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cosh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sinh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cosh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sinh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))\nCase conversion may be inaccurate. Consider using '#align complex.cosh_sq Complex.cosh_sqₓ'. -/\ntheorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 :=\n  by\n  rw [← cosh_sq_sub_sinh_sq x]\n  ring\n#align complex.cosh_sq Complex.cosh_sq\n\n/- warning: complex.sinh_sq -> Complex.sinh_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sinh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cosh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sinh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cosh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))\nCase conversion may be inaccurate. Consider using '#align complex.sinh_sq Complex.sinh_sqₓ'. -/\ntheorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 :=\n  by\n  rw [← cosh_sq_sub_sinh_sq x]\n  ring\n#align complex.sinh_sq Complex.sinh_sq\n\n#print Complex.cosh_two_mul /-\ntheorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by rw [two_mul, cosh_add, sq, sq]\n#align complex.cosh_two_mul Complex.cosh_two_mul\n-/\n\n#print Complex.sinh_two_mul /-\ntheorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x :=\n  by\n  rw [two_mul, sinh_add]\n  ring\n#align complex.sinh_two_mul Complex.sinh_two_mul\n-/\n\n#print Complex.cosh_three_mul /-\ntheorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x :=\n  by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, cosh_add x (2 * x)]\n  simp only [cosh_two_mul, sinh_two_mul]\n  have h2 : sinh x * (2 * sinh x * cosh x) = 2 * cosh x * sinh x ^ 2 := by ring\n  rw [h2, sinh_sq]\n  ring\n#align complex.cosh_three_mul Complex.cosh_three_mul\n-/\n\n#print Complex.sinh_three_mul /-\ntheorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x :=\n  by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, sinh_add x (2 * x)]\n  simp only [cosh_two_mul, sinh_two_mul]\n  have h2 : cosh x * (2 * sinh x * cosh x) = 2 * sinh x * cosh x ^ 2 := by ring\n  rw [h2, cosh_sq]\n  ring\n#align complex.sinh_three_mul Complex.sinh_three_mul\n-/\n\n#print Complex.sin_zero /-\n@[simp]\ntheorem sin_zero : sin 0 = 0 := by simp [sin]\n#align complex.sin_zero Complex.sin_zero\n-/\n\n#print Complex.sin_neg /-\n@[simp]\ntheorem sin_neg : sin (-x) = -sin x := by\n  simp [sin, sub_eq_add_neg, exp_neg, (neg_div _ _).symm, add_mul]\n#align complex.sin_neg Complex.sin_neg\n-/\n\n/- warning: complex.two_sin -> Complex.two_sin is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))) (Complex.sin x)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Neg.neg.{0} Complex Complex.hasNeg x) Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) x Complex.I))) Complex.I)\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Complex.sin x)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Neg.neg.{0} Complex Complex.instNegComplex x) Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) x Complex.I))) Complex.I)\nCase conversion may be inaccurate. Consider using '#align complex.two_sin Complex.two_sinₓ'. -/\ntheorem two_sin : 2 * sin x = (exp (-x * I) - exp (x * I)) * I :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_sin Complex.two_sin\n\n/- warning: complex.two_cos -> Complex.two_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))) (Complex.cos x)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) x Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Neg.neg.{0} Complex Complex.hasNeg x) Complex.I)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Complex.cos x)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) x Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Neg.neg.{0} Complex Complex.instNegComplex x) Complex.I)))\nCase conversion may be inaccurate. Consider using '#align complex.two_cos Complex.two_cosₓ'. -/\ntheorem two_cos : 2 * cos x = exp (x * I) + exp (-x * I) :=\n  mul_div_cancel' _ two_ne_zero\n#align complex.two_cos Complex.two_cos\n\n#print Complex.sinh_mul_I /-\ntheorem sinh_mul_I : sinh (x * I) = sin x * I := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_sinh, ← mul_assoc, two_sin, mul_assoc, I_mul_I,\n    mul_neg_one, neg_sub, neg_mul_eq_neg_mul]\n#align complex.sinh_mul_I Complex.sinh_mul_I\n-/\n\n#print Complex.cosh_mul_I /-\ntheorem cosh_mul_I : cosh (x * I) = cos x := by\n  rw [← mul_right_inj' (two_ne_zero' ℂ), two_cosh, two_cos, neg_mul_eq_neg_mul]\n#align complex.cosh_mul_I Complex.cosh_mul_I\n-/\n\n#print Complex.tanh_mul_I /-\ntheorem tanh_mul_I : tanh (x * I) = tan x * I := by\n  rw [tanh_eq_sinh_div_cosh, cosh_mul_I, sinh_mul_I, mul_div_right_comm, tan]\n#align complex.tanh_mul_I Complex.tanh_mul_I\n-/\n\n#print Complex.cos_mul_I /-\ntheorem cos_mul_I : cos (x * I) = cosh x := by rw [← cosh_mul_I] <;> ring_nf <;> simp\n#align complex.cos_mul_I Complex.cos_mul_I\n-/\n\n#print Complex.sin_mul_I /-\ntheorem sin_mul_I : sin (x * I) = sinh x * I :=\n  by\n  have h : I * sin (x * I) = -sinh x :=\n    by\n    rw [mul_comm, ← sinh_mul_I]\n    ring_nf\n    simp\n  simpa only [neg_mul, div_I, neg_neg] using CancelFactors.cancel_factors_eq_div h I_ne_zero\n#align complex.sin_mul_I Complex.sin_mul_I\n-/\n\n#print Complex.tan_mul_I /-\ntheorem tan_mul_I : tan (x * I) = tanh x * I := by\n  rw [tan, sin_mul_I, cos_mul_I, mul_div_right_comm, tanh_eq_sinh_div_cosh]\n#align complex.tan_mul_I Complex.tan_mul_I\n-/\n\n#print Complex.sin_add /-\ntheorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y := by\n  rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, add_mul, add_mul, mul_right_comm, ← sinh_mul_I,\n    mul_assoc, ← sinh_mul_I, ← cosh_mul_I, ← cosh_mul_I, sinh_add]\n#align complex.sin_add Complex.sin_add\n-/\n\n#print Complex.cos_zero /-\n@[simp]\ntheorem cos_zero : cos 0 = 1 := by simp [cos]\n#align complex.cos_zero Complex.cos_zero\n-/\n\n#print Complex.cos_neg /-\n@[simp]\ntheorem cos_neg : cos (-x) = cos x := by simp [cos, sub_eq_add_neg, exp_neg, add_comm]\n#align complex.cos_neg Complex.cos_neg\n-/\n\nprivate theorem cos_add_aux {a b c d : ℂ} :\n    (a + b) * (c + d) - (b - a) * (d - c) * -1 = 2 * (a * c + b * d) := by ring\n#align complex.cos_add_aux complex.cos_add_aux\n\n#print Complex.cos_add /-\ntheorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y := by\n  rw [← cosh_mul_I, add_mul, cosh_add, cosh_mul_I, cosh_mul_I, sinh_mul_I, sinh_mul_I,\n    mul_mul_mul_comm, I_mul_I, mul_neg_one, sub_eq_add_neg]\n#align complex.cos_add Complex.cos_add\n-/\n\n#print Complex.sin_sub /-\ntheorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by\n  simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg]\n#align complex.sin_sub Complex.sin_sub\n-/\n\n#print Complex.cos_sub /-\ntheorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by\n  simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg]\n#align complex.cos_sub Complex.cos_sub\n-/\n\n#print Complex.sin_add_mul_I /-\ntheorem sin_add_mul_I (x y : ℂ) : sin (x + y * I) = sin x * cosh y + cos x * sinh y * I := by\n  rw [sin_add, cos_mul_I, sin_mul_I, mul_assoc]\n#align complex.sin_add_mul_I Complex.sin_add_mul_I\n-/\n\n/- warning: complex.sin_eq -> Complex.sin_eq is a dubious translation:\nlean 3 declaration is\n  forall (z : Complex), Eq.{1} Complex (Complex.sin z) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.re z))) (Complex.cosh ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.im z)))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.cos ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.re z))) (Complex.sinh ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.im z)))) Complex.I))\nbut is expected to have type\n  forall (z : Complex), Eq.{1} Complex (Complex.sin z) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (Complex.ofReal' (Complex.re z))) (Complex.cosh (Complex.ofReal' (Complex.im z)))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.cos (Complex.ofReal' (Complex.re z))) (Complex.sinh (Complex.ofReal' (Complex.im z)))) Complex.I))\nCase conversion may be inaccurate. Consider using '#align complex.sin_eq Complex.sin_eqₓ'. -/\ntheorem sin_eq (z : ℂ) : sin z = sin z.re * cosh z.im + cos z.re * sinh z.im * I := by\n  convert sin_add_mul_I z.re z.im <;> exact (re_add_im z).symm\n#align complex.sin_eq Complex.sin_eq\n\n#print Complex.cos_add_mul_I /-\ntheorem cos_add_mul_I (x y : ℂ) : cos (x + y * I) = cos x * cosh y - sin x * sinh y * I := by\n  rw [cos_add, cos_mul_I, sin_mul_I, mul_assoc]\n#align complex.cos_add_mul_I Complex.cos_add_mul_I\n-/\n\n/- warning: complex.cos_eq -> Complex.cos_eq is a dubious translation:\nlean 3 declaration is\n  forall (z : Complex), Eq.{1} Complex (Complex.cos z) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.cos ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.re z))) (Complex.cosh ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.im z)))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.re z))) (Complex.sinh ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.im z)))) Complex.I))\nbut is expected to have type\n  forall (z : Complex), Eq.{1} Complex (Complex.cos z) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.cos (Complex.ofReal' (Complex.re z))) (Complex.cosh (Complex.ofReal' (Complex.im z)))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (Complex.ofReal' (Complex.re z))) (Complex.sinh (Complex.ofReal' (Complex.im z)))) Complex.I))\nCase conversion may be inaccurate. Consider using '#align complex.cos_eq Complex.cos_eqₓ'. -/\ntheorem cos_eq (z : ℂ) : cos z = cos z.re * cosh z.im - sin z.re * sinh z.im * I := by\n  convert cos_add_mul_I z.re z.im <;> exact (re_add_im z).symm\n#align complex.cos_eq Complex.cos_eq\n\n/- warning: complex.sin_sub_sin -> Complex.sin_sub_sin is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.sin x) (Complex.sin y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))) (Complex.sin (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) x y) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne))))))) (Complex.cos (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) x y) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))))))\nbut is expected to have type\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.sin x) (Complex.sin y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Complex.sin (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) x y) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))) (Complex.cos (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) x y) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))))\nCase conversion may be inaccurate. Consider using '#align complex.sin_sub_sin Complex.sin_sub_sinₓ'. -/\ntheorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) :=\n  by\n  have s1 := sin_add ((x + y) / 2) ((x - y) / 2)\n  have s2 := sin_sub ((x + y) / 2) ((x - y) / 2)\n  rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel, half_add_self] at s1\n  rw [div_sub_div_same, ← sub_add, add_sub_cancel', half_add_self] at s2\n  rw [s1, s2]\n  ring\n#align complex.sin_sub_sin Complex.sin_sub_sin\n\n/- warning: complex.cos_sub_cos -> Complex.cos_sub_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.cos x) (Complex.cos y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Neg.neg.{0} Complex Complex.hasNeg (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne))))) (Complex.sin (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) x y) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne))))))) (Complex.sin (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) x y) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))))))\nbut is expected to have type\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.cos x) (Complex.cos y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Neg.neg.{0} Complex Complex.instNegComplex (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (Complex.sin (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) x y) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))) (Complex.sin (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) x y) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))))\nCase conversion may be inaccurate. Consider using '#align complex.cos_sub_cos Complex.cos_sub_cosₓ'. -/\ntheorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) :=\n  by\n  have s1 := cos_add ((x + y) / 2) ((x - y) / 2)\n  have s2 := cos_sub ((x + y) / 2) ((x - y) / 2)\n  rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel, half_add_self] at s1\n  rw [div_sub_div_same, ← sub_add, add_sub_cancel', half_add_self] at s2\n  rw [s1, s2]\n  ring\n#align complex.cos_sub_cos Complex.cos_sub_cos\n\n/- warning: complex.cos_add_cos -> Complex.cos_add_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos x) (Complex.cos y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))) (Complex.cos (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) x y) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne))))))) (Complex.cos (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) x y) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))))))\nbut is expected to have type\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos x) (Complex.cos y)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Complex.cos (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) x y) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))) (Complex.cos (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) x y) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))))\nCase conversion may be inaccurate. Consider using '#align complex.cos_add_cos Complex.cos_add_cosₓ'. -/\ntheorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) :=\n  by\n  have h2 : (2 : ℂ) ≠ 0 := by norm_num\n  calc\n    cos x + cos y = cos ((x + y) / 2 + (x - y) / 2) + cos ((x + y) / 2 - (x - y) / 2) := _\n    _ =\n        cos ((x + y) / 2) * cos ((x - y) / 2) - sin ((x + y) / 2) * sin ((x - y) / 2) +\n          (cos ((x + y) / 2) * cos ((x - y) / 2) + sin ((x + y) / 2) * sin ((x - y) / 2)) :=\n      _\n    _ = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := _\n    \n  · congr <;> field_simp [h2] <;> ring\n  · rw [cos_add, cos_sub]\n  ring\n#align complex.cos_add_cos Complex.cos_add_cos\n\n#print Complex.sin_conj /-\ntheorem sin_conj : sin (conj x) = conj (sin x) := by\n  rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← RingHom.map_mul,\n    sinh_conj, mul_neg, sinh_neg, sinh_mul_I, mul_neg]\n#align complex.sin_conj Complex.sin_conj\n-/\n\n#print Complex.ofReal_sin_ofReal_re /-\n@[simp]\ntheorem ofReal_sin_ofReal_re (x : ℝ) : ((sin x).re : ℂ) = sin x :=\n  eq_conj_iff_re.1 <| by rw [← sin_conj, conj_of_real]\n#align complex.of_real_sin_of_real_re Complex.ofReal_sin_ofReal_re\n-/\n\n/- warning: complex.of_real_sin -> Complex.ofReal_sin is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Real.sin x)) (Complex.sin ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Real.sin x)) (Complex.sin (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_sin Complex.ofReal_sinₓ'. -/\n@[simp, norm_cast]\ntheorem ofReal_sin (x : ℝ) : (Real.sin x : ℂ) = sin x :=\n  ofReal_sin_ofReal_re _\n#align complex.of_real_sin Complex.ofReal_sin\n\n#print Complex.sin_ofReal_im /-\n@[simp]\ntheorem sin_ofReal_im (x : ℝ) : (sin x).im = 0 := by rw [← of_real_sin_of_real_re, of_real_im]\n#align complex.sin_of_real_im Complex.sin_ofReal_im\n-/\n\n#print Complex.sin_ofReal_re /-\ntheorem sin_ofReal_re (x : ℝ) : (sin x).re = Real.sin x :=\n  rfl\n#align complex.sin_of_real_re Complex.sin_ofReal_re\n-/\n\n#print Complex.cos_conj /-\ntheorem cos_conj : cos (conj x) = conj (cos x) := by\n  rw [← cosh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← cosh_mul_I, cosh_conj, mul_neg, cosh_neg]\n#align complex.cos_conj Complex.cos_conj\n-/\n\n#print Complex.ofReal_cos_ofReal_re /-\n@[simp]\ntheorem ofReal_cos_ofReal_re (x : ℝ) : ((cos x).re : ℂ) = cos x :=\n  eq_conj_iff_re.1 <| by rw [← cos_conj, conj_of_real]\n#align complex.of_real_cos_of_real_re Complex.ofReal_cos_ofReal_re\n-/\n\n/- warning: complex.of_real_cos -> Complex.ofReal_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Real.cos x)) (Complex.cos ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Real.cos x)) (Complex.cos (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_cos Complex.ofReal_cosₓ'. -/\n@[simp, norm_cast]\ntheorem ofReal_cos (x : ℝ) : (Real.cos x : ℂ) = cos x :=\n  ofReal_cos_ofReal_re _\n#align complex.of_real_cos Complex.ofReal_cos\n\n#print Complex.cos_ofReal_im /-\n@[simp]\ntheorem cos_ofReal_im (x : ℝ) : (cos x).im = 0 := by rw [← of_real_cos_of_real_re, of_real_im]\n#align complex.cos_of_real_im Complex.cos_ofReal_im\n-/\n\n#print Complex.cos_ofReal_re /-\ntheorem cos_ofReal_re (x : ℝ) : (cos x).re = Real.cos x :=\n  rfl\n#align complex.cos_of_real_re Complex.cos_ofReal_re\n-/\n\n#print Complex.tan_zero /-\n@[simp]\ntheorem tan_zero : tan 0 = 0 := by simp [tan]\n#align complex.tan_zero Complex.tan_zero\n-/\n\n/- warning: complex.tan_eq_sin_div_cos -> Complex.tan_eq_sin_div_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (Complex.tan x) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (Complex.sin x) (Complex.cos x))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (Complex.tan x) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (Complex.sin x) (Complex.cos x))\nCase conversion may be inaccurate. Consider using '#align complex.tan_eq_sin_div_cos Complex.tan_eq_sin_div_cosₓ'. -/\ntheorem tan_eq_sin_div_cos : tan x = sin x / cos x :=\n  rfl\n#align complex.tan_eq_sin_div_cos Complex.tan_eq_sin_div_cos\n\n/- warning: complex.tan_mul_cos -> Complex.tan_mul_cos is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex}, (Ne.{1} Complex (Complex.cos x) (OfNat.ofNat.{0} Complex 0 (OfNat.mk.{0} Complex 0 (Zero.zero.{0} Complex Complex.hasZero)))) -> (Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.tan x) (Complex.cos x)) (Complex.sin x))\nbut is expected to have type\n  forall {x : Complex}, (Ne.{1} Complex (Complex.cos x) (OfNat.ofNat.{0} Complex 0 (Zero.toOfNat0.{0} Complex Complex.instZeroComplex))) -> (Eq.{1} Complex (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.tan x) (Complex.cos x)) (Complex.sin x))\nCase conversion may be inaccurate. Consider using '#align complex.tan_mul_cos Complex.tan_mul_cosₓ'. -/\ntheorem tan_mul_cos {x : ℂ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by\n  rw [tan_eq_sin_div_cos, div_mul_cancel _ hx]\n#align complex.tan_mul_cos Complex.tan_mul_cos\n\n#print Complex.tan_neg /-\n@[simp]\ntheorem tan_neg : tan (-x) = -tan x := by simp [tan, neg_div]\n#align complex.tan_neg Complex.tan_neg\n-/\n\n#print Complex.tan_conj /-\ntheorem tan_conj : tan (conj x) = conj (tan x) := by rw [tan, sin_conj, cos_conj, ← map_div₀, tan]\n#align complex.tan_conj Complex.tan_conj\n-/\n\n#print Complex.ofReal_tan_ofReal_re /-\n@[simp]\ntheorem ofReal_tan_ofReal_re (x : ℝ) : ((tan x).re : ℂ) = tan x :=\n  eq_conj_iff_re.1 <| by rw [← tan_conj, conj_of_real]\n#align complex.of_real_tan_of_real_re Complex.ofReal_tan_ofReal_re\n-/\n\n/- warning: complex.of_real_tan -> Complex.ofReal_tan is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Complex ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Real.tan x)) (Complex.tan ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Complex (Complex.ofReal' (Real.tan x)) (Complex.tan (Complex.ofReal' x))\nCase conversion may be inaccurate. Consider using '#align complex.of_real_tan Complex.ofReal_tanₓ'. -/\n@[simp, norm_cast]\ntheorem ofReal_tan (x : ℝ) : (Real.tan x : ℂ) = tan x :=\n  ofReal_tan_ofReal_re _\n#align complex.of_real_tan Complex.ofReal_tan\n\n#print Complex.tan_of_real_im /-\n@[simp]\ntheorem tan_of_real_im (x : ℝ) : (tan x).im = 0 := by rw [← of_real_tan_of_real_re, of_real_im]\n#align complex.tan_of_real_im Complex.tan_of_real_im\n-/\n\n#print Complex.tan_of_real_re /-\ntheorem tan_of_real_re (x : ℝ) : (tan x).re = Real.tan x :=\n  rfl\n#align complex.tan_of_real_re Complex.tan_of_real_re\n-/\n\n/- warning: complex.cos_add_sin_I -> Complex.cos_add_sin_I is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin x) Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) x Complex.I))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin x) Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) x Complex.I))\nCase conversion may be inaccurate. Consider using '#align complex.cos_add_sin_I Complex.cos_add_sin_Iₓ'. -/\ntheorem cos_add_sin_I : cos x + sin x * I = exp (x * I) := by\n  rw [← cosh_add_sinh, sinh_mul_I, cosh_mul_I]\n#align complex.cos_add_sin_I Complex.cos_add_sin_I\n\n/- warning: complex.cos_sub_sin_I -> Complex.cos_sub_sin_I is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.cos x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin x) Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Neg.neg.{0} Complex Complex.hasNeg x) Complex.I))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.cos x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin x) Complex.I)) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Neg.neg.{0} Complex Complex.instNegComplex x) Complex.I))\nCase conversion may be inaccurate. Consider using '#align complex.cos_sub_sin_I Complex.cos_sub_sin_Iₓ'. -/\ntheorem cos_sub_sin_I : cos x - sin x * I = exp (-x * I) := by\n  rw [neg_mul, ← cosh_sub_sinh, sinh_mul_I, cosh_mul_I]\n#align complex.cos_sub_sin_I Complex.cos_sub_sin_I\n\n/- warning: complex.sin_sq_add_cos_sq -> Complex.sin_sq_add_cos_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex))\nCase conversion may be inaccurate. Consider using '#align complex.sin_sq_add_cos_sq Complex.sin_sq_add_cos_sqₓ'. -/\n@[simp]\ntheorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=\n  Eq.trans (by rw [cosh_mul_I, sinh_mul_I, mul_pow, I_sq, mul_neg_one, sub_neg_eq_add, add_comm])\n    (cosh_sq_sub_sinh_sq (x * I))\n#align complex.sin_sq_add_cos_sq Complex.sin_sq_add_cos_sq\n\n/- warning: complex.cos_sq_add_sin_sq -> Complex.cos_sq_add_sin_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex))\nCase conversion may be inaccurate. Consider using '#align complex.cos_sq_add_sin_sq Complex.cos_sq_add_sin_sqₓ'. -/\n@[simp]\ntheorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq]\n#align complex.cos_sq_add_sin_sq Complex.cos_sq_add_sin_sq\n\n#print Complex.cos_two_mul' /-\ntheorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 := by rw [two_mul, cos_add, ← sq, ← sq]\n#align complex.cos_two_mul' Complex.cos_two_mul'\n-/\n\n#print Complex.cos_two_mul /-\ntheorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 := by\n  rw [cos_two_mul', eq_sub_iff_add_eq.2 (sin_sq_add_cos_sq x), ← sub_add, sub_add_eq_add_sub,\n    two_mul]\n#align complex.cos_two_mul Complex.cos_two_mul\n-/\n\n#print Complex.sin_two_mul /-\ntheorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x := by\n  rw [two_mul, sin_add, two_mul, add_mul, mul_comm]\n#align complex.sin_two_mul Complex.sin_two_mul\n-/\n\n/- warning: complex.cos_sq -> Complex.cos_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne))))) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (Complex.cos (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne)))) x)) (OfNat.ofNat.{0} Complex 2 (OfNat.mk.{0} Complex 2 (bit0.{0} Complex Complex.hasAdd (One.one.{0} Complex Complex.hasOne))))))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (Complex.cos (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) x)) (OfNat.ofNat.{0} Complex 2 (instOfNat.{0} Complex 2 (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))\nCase conversion may be inaccurate. Consider using '#align complex.cos_sq Complex.cos_sqₓ'. -/\ntheorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 := by\n  simp [cos_two_mul, div_add_div_same, mul_div_cancel_left, two_ne_zero, -one_div]\n#align complex.cos_sq Complex.cos_sq\n\n/- warning: complex.cos_sq' -> Complex.cos_sq' is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align complex.cos_sq' Complex.cos_sq'ₓ'. -/\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel']\n#align complex.cos_sq' Complex.cos_sq'\n\n/- warning: complex.sin_sq -> Complex.sin_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align complex.sin_sq Complex.sin_sqₓ'. -/\ntheorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel]\n#align complex.sin_sq Complex.sin_sq\n\n/- warning: complex.inv_one_add_tan_sq -> Complex.inv_one_add_tan_sq is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex}, (Ne.{1} Complex (Complex.cos x) (OfNat.ofNat.{0} Complex 0 (OfNat.mk.{0} Complex 0 (Zero.zero.{0} Complex Complex.hasZero)))) -> (Eq.{1} Complex (Inv.inv.{0} Complex Complex.hasInv (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {x : Complex}, (Ne.{1} Complex (Complex.cos x) (OfNat.ofNat.{0} Complex 0 (Zero.toOfNat0.{0} Complex Complex.instZeroComplex))) -> (Eq.{1} Complex (Inv.inv.{0} Complex Complex.instInvComplex (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align complex.inv_one_add_tan_sq Complex.inv_one_add_tan_sqₓ'. -/\ntheorem inv_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 :=\n  by\n  have : cos x ^ 2 ≠ 0 := pow_ne_zero 2 hx\n  rw [tan_eq_sin_div_cos, div_pow]\n  field_simp [this]\n#align complex.inv_one_add_tan_sq Complex.inv_one_add_tan_sq\n\n/- warning: complex.tan_sq_div_one_add_tan_sq -> Complex.tan_sq_div_one_add_tan_sq is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex}, (Ne.{1} Complex (Complex.cos x) (OfNat.ofNat.{0} Complex 0 (OfNat.mk.{0} Complex 0 (Zero.zero.{0} Complex Complex.hasZero)))) -> (Eq.{1} Complex (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {x : Complex}, (Ne.{1} Complex (Complex.cos x) (OfNat.ofNat.{0} Complex 0 (Zero.toOfNat0.{0} Complex Complex.instZeroComplex))) -> (Eq.{1} Complex (HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Complex.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align complex.tan_sq_div_one_add_tan_sq Complex.tan_sq_div_one_add_tan_sqₓ'. -/\ntheorem tan_sq_div_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [← tan_mul_cos hx, mul_pow, ← inv_one_add_tan_sq hx, div_eq_mul_inv, one_mul]\n#align complex.tan_sq_div_one_add_tan_sq Complex.tan_sq_div_one_add_tan_sq\n\n#print Complex.cos_three_mul /-\ntheorem cos_three_mul : cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x :=\n  by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, cos_add x (2 * x)]\n  simp only [cos_two_mul, sin_two_mul, mul_add, mul_sub, mul_one, sq]\n  have h2 : 4 * cos x ^ 3 = 2 * cos x * cos x * cos x + 2 * cos x * cos x ^ 2 := by ring\n  rw [h2, cos_sq']\n  ring\n#align complex.cos_three_mul Complex.cos_three_mul\n-/\n\n#print Complex.sin_three_mul /-\ntheorem sin_three_mul : sin (3 * x) = 3 * sin x - 4 * sin x ^ 3 :=\n  by\n  have h1 : x + 2 * x = 3 * x := by ring\n  rw [← h1, sin_add x (2 * x)]\n  simp only [cos_two_mul, sin_two_mul, cos_sq']\n  have h2 : cos x * (2 * sin x * cos x) = 2 * sin x * cos x ^ 2 := by ring\n  rw [h2, cos_sq']\n  ring\n#align complex.sin_three_mul Complex.sin_three_mul\n-/\n\n/- warning: complex.exp_mul_I -> Complex.exp_mul_I is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) x Complex.I)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin x) Complex.I))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) x Complex.I)) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin x) Complex.I))\nCase conversion may be inaccurate. Consider using '#align complex.exp_mul_I Complex.exp_mul_Iₓ'. -/\ntheorem exp_mul_I : exp (x * I) = cos x + sin x * I :=\n  (cos_add_sin_I _).symm\n#align complex.exp_mul_I Complex.exp_mul_I\n\n/- warning: complex.exp_add_mul_I -> Complex.exp_add_mul_I is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (Complex.exp (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) x (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) y Complex.I))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.exp x) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos y) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin y) Complex.I)))\nbut is expected to have type\n  forall (x : Complex) (y : Complex), Eq.{1} Complex (Complex.exp (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) x (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) y Complex.I))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.exp x) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos y) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin y) Complex.I)))\nCase conversion may be inaccurate. Consider using '#align complex.exp_add_mul_I Complex.exp_add_mul_Iₓ'. -/\ntheorem exp_add_mul_I : exp (x + y * I) = exp x * (cos y + sin y * I) := by rw [exp_add, exp_mul_I]\n#align complex.exp_add_mul_I Complex.exp_add_mul_I\n\n/- warning: complex.exp_eq_exp_re_mul_sin_add_cos -> Complex.exp_eq_exp_re_mul_sin_add_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Complex (Complex.exp x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.exp ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.re x))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.im x))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) (Complex.im x))) Complex.I)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Complex (Complex.exp x) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.exp (Complex.ofReal' (Complex.re x))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos (Complex.ofReal' (Complex.im x))) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (Complex.ofReal' (Complex.im x))) Complex.I)))\nCase conversion may be inaccurate. Consider using '#align complex.exp_eq_exp_re_mul_sin_add_cos Complex.exp_eq_exp_re_mul_sin_add_cosₓ'. -/\ntheorem exp_eq_exp_re_mul_sin_add_cos : exp x = exp x.re * (cos x.im + sin x.im * I) := by\n  rw [← exp_add_mul_I, re_add_im]\n#align complex.exp_eq_exp_re_mul_sin_add_cos Complex.exp_eq_exp_re_mul_sin_add_cos\n\n/- warning: complex.exp_re -> Complex.exp_re is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Real (Complex.re (Complex.exp x)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (Real.exp (Complex.re x)) (Real.cos (Complex.im x)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Real (Complex.re (Complex.exp x)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Real.exp (Complex.re x)) (Real.cos (Complex.im x)))\nCase conversion may be inaccurate. Consider using '#align complex.exp_re Complex.exp_reₓ'. -/\ntheorem exp_re : (exp x).re = Real.exp x.re * Real.cos x.im :=\n  by\n  rw [exp_eq_exp_re_mul_sin_add_cos]\n  simp [exp_of_real_re, cos_of_real_re]\n#align complex.exp_re Complex.exp_re\n\n/- warning: complex.exp_im -> Complex.exp_im is a dubious translation:\nlean 3 declaration is\n  forall (x : Complex), Eq.{1} Real (Complex.im (Complex.exp x)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (Real.exp (Complex.re x)) (Real.sin (Complex.im x)))\nbut is expected to have type\n  forall (x : Complex), Eq.{1} Real (Complex.im (Complex.exp x)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Real.exp (Complex.re x)) (Real.sin (Complex.im x)))\nCase conversion may be inaccurate. Consider using '#align complex.exp_im Complex.exp_imₓ'. -/\ntheorem exp_im : (exp x).im = Real.exp x.re * Real.sin x.im :=\n  by\n  rw [exp_eq_exp_re_mul_sin_add_cos]\n  simp [exp_of_real_re, sin_of_real_re]\n#align complex.exp_im Complex.exp_im\n\n/- warning: complex.exp_of_real_mul_I_re -> Complex.exp_ofReal_mul_I_re is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Complex.re (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x) Complex.I))) (Real.cos x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Complex.re (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.ofReal' x) Complex.I))) (Real.cos x)\nCase conversion may be inaccurate. Consider using '#align complex.exp_of_real_mul_I_re Complex.exp_ofReal_mul_I_reₓ'. -/\n@[simp]\ntheorem exp_ofReal_mul_I_re (x : ℝ) : (exp (x * I)).re = Real.cos x := by\n  simp [exp_mul_I, cos_of_real_re]\n#align complex.exp_of_real_mul_I_re Complex.exp_ofReal_mul_I_re\n\n/- warning: complex.exp_of_real_mul_I_im -> Complex.exp_ofReal_mul_I_im is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Complex.im (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x) Complex.I))) (Real.sin x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Complex.im (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.ofReal' x) Complex.I))) (Real.sin x)\nCase conversion may be inaccurate. Consider using '#align complex.exp_of_real_mul_I_im Complex.exp_ofReal_mul_I_imₓ'. -/\n@[simp]\ntheorem exp_ofReal_mul_I_im (x : ℝ) : (exp (x * I)).im = Real.sin x := by\n  simp [exp_mul_I, sin_of_real_re]\n#align complex.exp_of_real_mul_I_im Complex.exp_ofReal_mul_I_im\n\n/- warning: complex.cos_add_sin_mul_I_pow -> Complex.cos_add_sin_mul_I_pow is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat) (z : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos z) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin z) Complex.I)) n) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Complex (HasLiftT.mk.{1, 1} Nat Complex (CoeTCₓ.coe.{1, 1} Nat Complex (Nat.castCoe.{0} Complex (AddMonoidWithOne.toNatCast.{0} Complex (AddGroupWithOne.toAddMonoidWithOne.{0} Complex Complex.addGroupWithOne))))) n) z)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Complex (HasLiftT.mk.{1, 1} Nat Complex (CoeTCₓ.coe.{1, 1} Nat Complex (Nat.castCoe.{0} Complex (AddMonoidWithOne.toNatCast.{0} Complex (AddGroupWithOne.toAddMonoidWithOne.{0} Complex Complex.addGroupWithOne))))) n) z)) Complex.I))\nbut is expected to have type\n  forall (n : Nat) (z : Complex), Eq.{1} Complex (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos z) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin z) Complex.I)) n) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) n) z)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) n) z)) Complex.I))\nCase conversion may be inaccurate. Consider using '#align complex.cos_add_sin_mul_I_pow Complex.cos_add_sin_mul_I_powₓ'. -/\n/-- **De Moivre's formula** -/\ntheorem cos_add_sin_mul_I_pow (n : ℕ) (z : ℂ) :\n    (cos z + sin z * I) ^ n = cos (↑n * z) + sin (↑n * z) * I :=\n  by\n  rw [← exp_mul_I, ← exp_mul_I]\n  induction' n with n ih\n  · rw [pow_zero, Nat.cast_zero, MulZeroClass.zero_mul, MulZeroClass.zero_mul, exp_zero]\n  · rw [pow_succ', ih, Nat.cast_succ, add_mul, add_mul, one_mul, exp_add]\n#align complex.cos_add_sin_mul_I_pow Complex.cos_add_sin_mul_I_pow\n\nend Complex\n\nnamespace Real\n\nopen Complex\n\nvariable (x y : ℝ)\n\n/- warning: real.exp_zero -> Real.exp_zero is a dubious translation:\nlean 3 declaration is\n  Eq.{1} Real (Real.exp (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  Eq.{1} Real (Real.exp (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.exp_zero Real.exp_zeroₓ'. -/\n@[simp]\ntheorem exp_zero : exp 0 = 1 := by simp [Real.exp]\n#align real.exp_zero Real.exp_zero\n\n/- warning: real.exp_add -> Real.exp_add is a dubious translation:\nlean 3 declaration is\n  forall (x : Real) (y : Real), Eq.{1} Real (Real.exp (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (Real.exp x) (Real.exp y))\nbut is expected to have type\n  forall (x : Real) (y : Real), Eq.{1} Real (Real.exp (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Real.exp x) (Real.exp y))\nCase conversion may be inaccurate. Consider using '#align real.exp_add Real.exp_addₓ'. -/\ntheorem exp_add : exp (x + y) = exp x * exp y := by simp [exp_add, exp]\n#align real.exp_add Real.exp_add\n\n#print Real.exp_list_sum /-\ntheorem exp_list_sum (l : List ℝ) : exp l.Sum = (l.map exp).Prod :=\n  @MonoidHom.map_list_prod (Multiplicative ℝ) ℝ _ _ ⟨exp, exp_zero, exp_add⟩ l\n#align real.exp_list_sum Real.exp_list_sum\n-/\n\n#print Real.exp_multiset_sum /-\ntheorem exp_multiset_sum (s : Multiset ℝ) : exp s.Sum = (s.map exp).Prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative ℝ) ℝ _ _ ⟨exp, exp_zero, exp_add⟩ s\n#align real.exp_multiset_sum Real.exp_multiset_sum\n-/\n\n#print Real.exp_sum /-\ntheorem exp_sum {α : Type _} (s : Finset α) (f : α → ℝ) :\n    exp (∑ x in s, f x) = ∏ x in s, exp (f x) :=\n  @MonoidHom.map_prod (Multiplicative ℝ) α ℝ _ _ ⟨exp, exp_zero, exp_add⟩ f s\n#align real.exp_sum Real.exp_sum\n-/\n\n/- warning: real.exp_nat_mul -> Real.exp_nat_mul is a dubious translation:\nlean 3 declaration is\n  forall (x : Real) (n : Nat), Eq.{1} Real (Real.exp (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n) x)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.exp x) n)\nbut is expected to have type\n  forall (x : Real) (n : Nat), Eq.{1} Real (Real.exp (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Nat.cast.{0} Real Real.natCast n) x)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.exp x) n)\nCase conversion may be inaccurate. Consider using '#align real.exp_nat_mul Real.exp_nat_mulₓ'. -/\ntheorem exp_nat_mul (x : ℝ) : ∀ n : ℕ, exp (n * x) = exp x ^ n\n  | 0 => by rw [Nat.cast_zero, MulZeroClass.zero_mul, exp_zero, pow_zero]\n  | Nat.succ n => by rw [pow_succ', Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul, one_mul]\n#align real.exp_nat_mul Real.exp_nat_mul\n\n/- warning: real.exp_ne_zero -> Real.exp_ne_zero is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Ne.{1} Real (Real.exp x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))\nbut is expected to have type\n  forall (x : Real), Ne.{1} Real (Real.exp x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))\nCase conversion may be inaccurate. Consider using '#align real.exp_ne_zero Real.exp_ne_zeroₓ'. -/\ntheorem exp_ne_zero : exp x ≠ 0 := fun h =>\n  exp_ne_zero x <| by rw [exp, ← of_real_inj] at h <;> simp_all\n#align real.exp_ne_zero Real.exp_ne_zero\n\n/- warning: real.exp_neg -> Real.exp_neg is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Real.exp (Neg.neg.{0} Real Real.hasNeg x)) (Inv.inv.{0} Real Real.hasInv (Real.exp x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Real.exp (Neg.neg.{0} Real Real.instNegReal x)) (Inv.inv.{0} Real Real.instInvReal (Real.exp x))\nCase conversion may be inaccurate. Consider using '#align real.exp_neg Real.exp_negₓ'. -/\ntheorem exp_neg : exp (-x) = (exp x)⁻¹ := by\n  rw [← of_real_inj, exp, of_real_exp_of_real_re, of_real_neg, exp_neg, of_real_inv, of_real_exp]\n#align real.exp_neg Real.exp_neg\n\n/- warning: real.exp_sub -> Real.exp_sub is a dubious translation:\nlean 3 declaration is\n  forall (x : Real) (y : Real), Eq.{1} Real (Real.exp (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x y)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (Real.exp x) (Real.exp y))\nbut is expected to have type\n  forall (x : Real) (y : Real), Eq.{1} Real (Real.exp (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x y)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Real.exp x) (Real.exp y))\nCase conversion may be inaccurate. Consider using '#align real.exp_sub Real.exp_subₓ'. -/\ntheorem exp_sub : exp (x - y) = exp x / exp y := by\n  simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv]\n#align real.exp_sub Real.exp_sub\n\n#print Real.sin_zero /-\n@[simp]\ntheorem sin_zero : sin 0 = 0 := by simp [sin]\n#align real.sin_zero Real.sin_zero\n-/\n\n#print Real.sin_neg /-\n@[simp]\ntheorem sin_neg : sin (-x) = -sin x := by simp [sin, exp_neg, (neg_div _ _).symm, add_mul]\n#align real.sin_neg Real.sin_neg\n-/\n\n#print Real.sin_add /-\ntheorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y := by\n  rw [← of_real_inj] <;> simp [sin, sin_add]\n#align real.sin_add Real.sin_add\n-/\n\n#print Real.cos_zero /-\n@[simp]\ntheorem cos_zero : cos 0 = 1 := by simp [cos]\n#align real.cos_zero Real.cos_zero\n-/\n\n#print Real.cos_neg /-\n@[simp]\ntheorem cos_neg : cos (-x) = cos x := by simp [cos, exp_neg]\n#align real.cos_neg Real.cos_neg\n-/\n\n#print Real.cos_abs /-\n@[simp]\ntheorem cos_abs : cos (|x|) = cos x := by\n  cases le_total x 0 <;> simp only [*, _root_.abs_of_nonneg, abs_of_nonpos, cos_neg]\n#align real.cos_abs Real.cos_abs\n-/\n\n#print Real.cos_add /-\ntheorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y := by\n  rw [← of_real_inj] <;> simp [cos, cos_add]\n#align real.cos_add Real.cos_add\n-/\n\n#print Real.sin_sub /-\ntheorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by\n  simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg]\n#align real.sin_sub Real.sin_sub\n-/\n\n#print Real.cos_sub /-\ntheorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by\n  simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg]\n#align real.cos_sub Real.cos_sub\n-/\n\n/- warning: real.sin_sub_sin -> Real.sin_sub_sin is a dubious translation:\nlean 3 declaration is\n  forall (x : Real) (y : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.sin x) (Real.sin y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) (Real.sin (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))) (Real.cos (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))))\nbut is expected to have type\n  forall (x : Real) (y : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.sin x) (Real.sin y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Real.sin (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))) (Real.cos (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))))\nCase conversion may be inaccurate. Consider using '#align real.sin_sub_sin Real.sin_sub_sinₓ'. -/\ntheorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) :=\n  by\n  rw [← of_real_inj]\n  simp only [sin, cos, of_real_sin_of_real_re, of_real_sub, of_real_add, of_real_div, of_real_mul,\n    of_real_one, of_real_bit0]\n  convert sin_sub_sin _ _ <;> norm_cast\n#align real.sin_sub_sin Real.sin_sub_sin\n\n/- warning: real.cos_sub_cos -> Real.cos_sub_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Real) (y : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.cos x) (Real.cos y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (Neg.neg.{0} Real Real.hasNeg (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) (Real.sin (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))) (Real.sin (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))))\nbut is expected to have type\n  forall (x : Real) (y : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.cos x) (Real.cos y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Neg.neg.{0} Real Real.instNegReal (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (Real.sin (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))) (Real.sin (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))))\nCase conversion may be inaccurate. Consider using '#align real.cos_sub_cos Real.cos_sub_cosₓ'. -/\ntheorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) :=\n  by\n  rw [← of_real_inj]\n  simp only [cos, neg_mul, of_real_sin, of_real_sub, of_real_add, of_real_cos_of_real_re,\n    of_real_div, of_real_mul, of_real_one, of_real_neg, of_real_bit0]\n  convert cos_sub_cos _ _\n  ring\n#align real.cos_sub_cos Real.cos_sub_cos\n\n/- warning: real.cos_add_cos -> Real.cos_add_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Real) (y : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Real.cos x) (Real.cos y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) (Real.cos (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))) (Real.cos (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x y) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))))\nbut is expected to have type\n  forall (x : Real) (y : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Real.cos x) (Real.cos y)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Real.cos (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))) (Real.cos (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x y) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))))\nCase conversion may be inaccurate. Consider using '#align real.cos_add_cos Real.cos_add_cosₓ'. -/\ntheorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) :=\n  by\n  rw [← of_real_inj]\n  simp only [cos, of_real_sub, of_real_add, of_real_cos_of_real_re, of_real_div, of_real_mul,\n    of_real_one, of_real_bit0]\n  convert cos_add_cos _ _ <;> norm_cast\n#align real.cos_add_cos Real.cos_add_cos\n\n/- warning: real.tan_eq_sin_div_cos -> Real.tan_eq_sin_div_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Real.tan x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (Real.sin x) (Real.cos x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Real.tan x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Real.sin x) (Real.cos x))\nCase conversion may be inaccurate. Consider using '#align real.tan_eq_sin_div_cos Real.tan_eq_sin_div_cosₓ'. -/\ntheorem tan_eq_sin_div_cos : tan x = sin x / cos x := by\n  rw [← of_real_inj, of_real_tan, tan_eq_sin_div_cos, of_real_div, of_real_sin, of_real_cos]\n#align real.tan_eq_sin_div_cos Real.tan_eq_sin_div_cos\n\n/- warning: real.tan_mul_cos -> Real.tan_mul_cos is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (Ne.{1} Real (Real.cos x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Eq.{1} Real (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (Real.tan x) (Real.cos x)) (Real.sin x))\nbut is expected to have type\n  forall {x : Real}, (Ne.{1} Real (Real.cos x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Eq.{1} Real (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Real.tan x) (Real.cos x)) (Real.sin x))\nCase conversion may be inaccurate. Consider using '#align real.tan_mul_cos Real.tan_mul_cosₓ'. -/\ntheorem tan_mul_cos {x : ℝ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by\n  rw [tan_eq_sin_div_cos, div_mul_cancel _ hx]\n#align real.tan_mul_cos Real.tan_mul_cos\n\n#print Real.tan_zero /-\n@[simp]\ntheorem tan_zero : tan 0 = 0 := by simp [tan]\n#align real.tan_zero Real.tan_zero\n-/\n\n#print Real.tan_neg /-\n@[simp]\ntheorem tan_neg : tan (-x) = -tan x := by simp [tan, neg_div]\n#align real.tan_neg Real.tan_neg\n-/\n\n/- warning: real.sin_sq_add_cos_sq -> Real.sin_sq_add_cos_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.sin_sq_add_cos_sq Real.sin_sq_add_cos_sqₓ'. -/\n@[simp]\ntheorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=\n  ofReal_inj.1 <| by simp\n#align real.sin_sq_add_cos_sq Real.sin_sq_add_cos_sq\n\n/- warning: real.cos_sq_add_sin_sq -> Real.cos_sq_add_sin_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.cos_sq_add_sin_sq Real.cos_sq_add_sin_sqₓ'. -/\n@[simp]\ntheorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq]\n#align real.cos_sq_add_sin_sq Real.cos_sq_add_sin_sq\n\n/- warning: real.sin_sq_le_one -> Real.sin_sq_le_one is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.sin_sq_le_one Real.sin_sq_le_oneₓ'. -/\ntheorem sin_sq_le_one : sin x ^ 2 ≤ 1 := by\n  rw [← sin_sq_add_cos_sq x] <;> exact le_add_of_nonneg_right (sq_nonneg _)\n#align real.sin_sq_le_one Real.sin_sq_le_one\n\n/- warning: real.cos_sq_le_one -> Real.cos_sq_le_one is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.cos_sq_le_one Real.cos_sq_le_oneₓ'. -/\ntheorem cos_sq_le_one : cos x ^ 2 ≤ 1 := by\n  rw [← sin_sq_add_cos_sq x] <;> exact le_add_of_nonneg_left (sq_nonneg _)\n#align real.cos_sq_le_one Real.cos_sq_le_one\n\n/- warning: real.abs_sin_le_one -> Real.abs_sin_le_one is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (Real.sin x)) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (Real.sin x)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.abs_sin_le_one Real.abs_sin_le_oneₓ'. -/\ntheorem abs_sin_le_one : |sin x| ≤ 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, sin_sq_le_one]\n#align real.abs_sin_le_one Real.abs_sin_le_one\n\n/- warning: real.abs_cos_le_one -> Real.abs_cos_le_one is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (Real.cos x)) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (Real.cos x)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.abs_cos_le_one Real.abs_cos_le_oneₓ'. -/\ntheorem abs_cos_le_one : |cos x| ≤ 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, cos_sq_le_one]\n#align real.abs_cos_le_one Real.abs_cos_le_one\n\n/- warning: real.sin_le_one -> Real.sin_le_one is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (Real.sin x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (Real.sin x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.sin_le_one Real.sin_le_oneₓ'. -/\ntheorem sin_le_one : sin x ≤ 1 :=\n  (abs_le.1 (abs_sin_le_one _)).2\n#align real.sin_le_one Real.sin_le_one\n\n/- warning: real.cos_le_one -> Real.cos_le_one is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (Real.cos x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (Real.cos x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.cos_le_one Real.cos_le_oneₓ'. -/\ntheorem cos_le_one : cos x ≤ 1 :=\n  (abs_le.1 (abs_cos_le_one _)).2\n#align real.cos_le_one Real.cos_le_one\n\n/- warning: real.neg_one_le_sin -> Real.neg_one_le_sin is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (Neg.neg.{0} Real Real.hasNeg (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Real.sin x)\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (Neg.neg.{0} Real Real.instNegReal (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Real.sin x)\nCase conversion may be inaccurate. Consider using '#align real.neg_one_le_sin Real.neg_one_le_sinₓ'. -/\ntheorem neg_one_le_sin : -1 ≤ sin x :=\n  (abs_le.1 (abs_sin_le_one _)).1\n#align real.neg_one_le_sin Real.neg_one_le_sin\n\n/- warning: real.neg_one_le_cos -> Real.neg_one_le_cos is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (Neg.neg.{0} Real Real.hasNeg (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Real.cos x)\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (Neg.neg.{0} Real Real.instNegReal (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Real.cos x)\nCase conversion may be inaccurate. Consider using '#align real.neg_one_le_cos Real.neg_one_le_cosₓ'. -/\ntheorem neg_one_le_cos : -1 ≤ cos x :=\n  (abs_le.1 (abs_cos_le_one _)).1\n#align real.neg_one_le_cos Real.neg_one_le_cos\n\n#print Real.cos_two_mul /-\ntheorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 := by\n  rw [← of_real_inj] <;> simp [cos_two_mul]\n#align real.cos_two_mul Real.cos_two_mul\n-/\n\n#print Real.cos_two_mul' /-\ntheorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 := by\n  rw [← of_real_inj] <;> simp [cos_two_mul']\n#align real.cos_two_mul' Real.cos_two_mul'\n-/\n\n#print Real.sin_two_mul /-\ntheorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x := by\n  rw [← of_real_inj] <;> simp [sin_two_mul]\n#align real.sin_two_mul Real.sin_two_mul\n-/\n\n/- warning: real.cos_sq -> Real.cos_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (Real.cos (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) x)) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Real.cos (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) x)) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))\nCase conversion may be inaccurate. Consider using '#align real.cos_sq Real.cos_sqₓ'. -/\ntheorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 :=\n  ofReal_inj.1 <| by simpa using cos_sq x\n#align real.cos_sq Real.cos_sq\n\n/- warning: real.cos_sq' -> Real.cos_sq' is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align real.cos_sq' Real.cos_sq'ₓ'. -/\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel']\n#align real.cos_sq' Real.cos_sq'\n\n/- warning: real.sin_sq -> Real.sin_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align real.sin_sq Real.sin_sqₓ'. -/\ntheorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 :=\n  eq_sub_iff_add_eq.2 <| sin_sq_add_cos_sq _\n#align real.sin_sq Real.sin_sq\n\n/- warning: real.abs_sin_eq_sqrt_one_sub_cos_sq -> Real.abs_sin_eq_sqrt_one_sub_cos_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (Real.sin x)) (Real.sqrt (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (Real.sin x)) (Real.sqrt (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))))\nCase conversion may be inaccurate. Consider using '#align real.abs_sin_eq_sqrt_one_sub_cos_sq Real.abs_sin_eq_sqrt_one_sub_cos_sqₓ'. -/\ntheorem abs_sin_eq_sqrt_one_sub_cos_sq (x : ℝ) : |sin x| = sqrt (1 - cos x ^ 2) := by\n  rw [← sin_sq, sqrt_sq_eq_abs]\n#align real.abs_sin_eq_sqrt_one_sub_cos_sq Real.abs_sin_eq_sqrt_one_sub_cos_sq\n\n/- warning: real.abs_cos_eq_sqrt_one_sub_sin_sq -> Real.abs_cos_eq_sqrt_one_sub_sin_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (Real.cos x)) (Real.sqrt (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (Real.cos x)) (Real.sqrt (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))))\nCase conversion may be inaccurate. Consider using '#align real.abs_cos_eq_sqrt_one_sub_sin_sq Real.abs_cos_eq_sqrt_one_sub_sin_sqₓ'. -/\ntheorem abs_cos_eq_sqrt_one_sub_sin_sq (x : ℝ) : |cos x| = sqrt (1 - sin x ^ 2) := by\n  rw [← cos_sq', sqrt_sq_eq_abs]\n#align real.abs_cos_eq_sqrt_one_sub_sin_sq Real.abs_cos_eq_sqrt_one_sub_sin_sq\n\n/- warning: real.inv_one_add_tan_sq -> Real.inv_one_add_tan_sq is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (Ne.{1} Real (Real.cos x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Eq.{1} Real (Inv.inv.{0} Real Real.hasInv (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {x : Real}, (Ne.{1} Real (Real.cos x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Eq.{1} Real (Inv.inv.{0} Real Real.instInvReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cos x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align real.inv_one_add_tan_sq Real.inv_one_add_tan_sqₓ'. -/\ntheorem inv_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 :=\n  have : Complex.cos x ≠ 0 := mt (congr_arg re) hx\n  ofReal_inj.1 <| by simpa using Complex.inv_one_add_tan_sq this\n#align real.inv_one_add_tan_sq Real.inv_one_add_tan_sq\n\n/- warning: real.tan_sq_div_one_add_tan_sq -> Real.tan_sq_div_one_add_tan_sq is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (Ne.{1} Real (Real.cos x) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (Eq.{1} Real (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {x : Real}, (Ne.{1} Real (Real.cos x) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (Eq.{1} Real (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sin x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align real.tan_sq_div_one_add_tan_sq Real.tan_sq_div_one_add_tan_sqₓ'. -/\ntheorem tan_sq_div_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [← tan_mul_cos hx, mul_pow, ← inv_one_add_tan_sq hx, div_eq_mul_inv, one_mul]\n#align real.tan_sq_div_one_add_tan_sq Real.tan_sq_div_one_add_tan_sq\n\n/- warning: real.inv_sqrt_one_add_tan_sq -> Real.inv_sqrt_one_add_tan_sq is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.cos x)) -> (Eq.{1} Real (Inv.inv.{0} Real Real.hasInv (Real.sqrt (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))))) (Real.cos x))\nbut is expected to have type\n  forall {x : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.cos x)) -> (Eq.{1} Real (Inv.inv.{0} Real Real.instInvReal (Real.sqrt (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))))) (Real.cos x))\nCase conversion may be inaccurate. Consider using '#align real.inv_sqrt_one_add_tan_sq Real.inv_sqrt_one_add_tan_sqₓ'. -/\ntheorem inv_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) : (sqrt (1 + tan x ^ 2))⁻¹ = cos x := by\n  rw [← sqrt_sq hx.le, ← sqrt_inv, inv_one_add_tan_sq hx.ne']\n#align real.inv_sqrt_one_add_tan_sq Real.inv_sqrt_one_add_tan_sq\n\n/- warning: real.tan_div_sqrt_one_add_tan_sq -> Real.tan_div_sqrt_one_add_tan_sq is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.cos x)) -> (Eq.{1} Real (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (Real.tan x) (Real.sqrt (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))))) (Real.sin x))\nbut is expected to have type\n  forall {x : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.cos x)) -> (Eq.{1} Real (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Real.tan x) (Real.sqrt (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.tan x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))))) (Real.sin x))\nCase conversion may be inaccurate. Consider using '#align real.tan_div_sqrt_one_add_tan_sq Real.tan_div_sqrt_one_add_tan_sqₓ'. -/\ntheorem tan_div_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) :\n    tan x / sqrt (1 + tan x ^ 2) = sin x := by\n  rw [← tan_mul_cos hx.ne', ← inv_sqrt_one_add_tan_sq hx, div_eq_mul_inv]\n#align real.tan_div_sqrt_one_add_tan_sq Real.tan_div_sqrt_one_add_tan_sq\n\n#print Real.cos_three_mul /-\ntheorem cos_three_mul : cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x := by\n  rw [← of_real_inj] <;> simp [cos_three_mul]\n#align real.cos_three_mul Real.cos_three_mul\n-/\n\n#print Real.sin_three_mul /-\ntheorem sin_three_mul : sin (3 * x) = 3 * sin x - 4 * sin x ^ 3 := by\n  rw [← of_real_inj] <;> simp [sin_three_mul]\n#align real.sin_three_mul Real.sin_three_mul\n-/\n\n/- warning: real.sinh_eq -> Real.sinh_eq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Real.sinh x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.exp (Neg.neg.{0} Real Real.hasNeg x))) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Real.sinh x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.exp (Neg.neg.{0} Real Real.instNegReal x))) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))\nCase conversion may be inaccurate. Consider using '#align real.sinh_eq Real.sinh_eqₓ'. -/\n/-- The definition of `sinh` in terms of `exp`. -/\ntheorem sinh_eq (x : ℝ) : sinh x = (exp x - exp (-x)) / 2 :=\n  eq_div_of_mul_eq two_ne_zero <| by\n    rw [sinh, exp, exp, Complex.ofReal_neg, Complex.sinh, mul_two, ← Complex.add_re, ← mul_two,\n      div_mul_cancel _ (two_ne_zero' ℂ), Complex.sub_re]\n#align real.sinh_eq Real.sinh_eq\n\n#print Real.sinh_zero /-\n@[simp]\ntheorem sinh_zero : sinh 0 = 0 := by simp [sinh]\n#align real.sinh_zero Real.sinh_zero\n-/\n\n#print Real.sinh_neg /-\n@[simp]\ntheorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul]\n#align real.sinh_neg Real.sinh_neg\n-/\n\n#print Real.sinh_add /-\ntheorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by\n  rw [← of_real_inj] <;> simp [sinh_add]\n#align real.sinh_add Real.sinh_add\n-/\n\n/- warning: real.cosh_eq -> Real.cosh_eq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Real.cosh x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Real.exp x) (Real.exp (Neg.neg.{0} Real Real.hasNeg x))) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Real.cosh x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Real.exp x) (Real.exp (Neg.neg.{0} Real Real.instNegReal x))) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))\nCase conversion may be inaccurate. Consider using '#align real.cosh_eq Real.cosh_eqₓ'. -/\n/-- The definition of `cosh` in terms of `exp`. -/\ntheorem cosh_eq (x : ℝ) : cosh x = (exp x + exp (-x)) / 2 :=\n  eq_div_of_mul_eq two_ne_zero <| by\n    rw [cosh, exp, exp, Complex.ofReal_neg, Complex.cosh, mul_two, ← Complex.add_re, ← mul_two,\n      div_mul_cancel _ (two_ne_zero' ℂ), Complex.add_re]\n#align real.cosh_eq Real.cosh_eq\n\n#print Real.cosh_zero /-\n@[simp]\ntheorem cosh_zero : cosh 0 = 1 := by simp [cosh]\n#align real.cosh_zero Real.cosh_zero\n-/\n\n#print Real.cosh_neg /-\n@[simp]\ntheorem cosh_neg : cosh (-x) = cosh x :=\n  ofReal_inj.1 <| by simp\n#align real.cosh_neg Real.cosh_neg\n-/\n\n#print Real.cosh_abs /-\n@[simp]\ntheorem cosh_abs : cosh (|x|) = cosh x := by\n  cases le_total x 0 <;> simp [*, _root_.abs_of_nonneg, abs_of_nonpos]\n#align real.cosh_abs Real.cosh_abs\n-/\n\n#print Real.cosh_add /-\ntheorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by\n  rw [← of_real_inj] <;> simp [cosh_add]\n#align real.cosh_add Real.cosh_add\n-/\n\n#print Real.sinh_sub /-\ntheorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by\n  simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg]\n#align real.sinh_sub Real.sinh_sub\n-/\n\n#print Real.cosh_sub /-\ntheorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by\n  simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg]\n#align real.cosh_sub Real.cosh_sub\n-/\n\n/- warning: real.tanh_eq_sinh_div_cosh -> Real.tanh_eq_sinh_div_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Real.tanh x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (Real.sinh x) (Real.cosh x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Real.tanh x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Real.sinh x) (Real.cosh x))\nCase conversion may be inaccurate. Consider using '#align real.tanh_eq_sinh_div_cosh Real.tanh_eq_sinh_div_coshₓ'. -/\ntheorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x :=\n  ofReal_inj.1 <| by simp [tanh_eq_sinh_div_cosh]\n#align real.tanh_eq_sinh_div_cosh Real.tanh_eq_sinh_div_cosh\n\n#print Real.tanh_zero /-\n@[simp]\ntheorem tanh_zero : tanh 0 = 0 := by simp [tanh]\n#align real.tanh_zero Real.tanh_zero\n-/\n\n#print Real.tanh_neg /-\n@[simp]\ntheorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div]\n#align real.tanh_neg Real.tanh_neg\n-/\n\n/- warning: real.cosh_add_sinh -> Real.cosh_add_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Real.cosh x) (Real.sinh x)) (Real.exp x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Real.cosh x) (Real.sinh x)) (Real.exp x)\nCase conversion may be inaccurate. Consider using '#align real.cosh_add_sinh Real.cosh_add_sinhₓ'. -/\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← of_real_inj] <;> simp\n#align real.cosh_add_sinh Real.cosh_add_sinh\n\n/- warning: real.sinh_add_cosh -> Real.sinh_add_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Real.sinh x) (Real.cosh x)) (Real.exp x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Real.sinh x) (Real.cosh x)) (Real.exp x)\nCase conversion may be inaccurate. Consider using '#align real.sinh_add_cosh Real.sinh_add_coshₓ'. -/\n@[simp]\ntheorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh]\n#align real.sinh_add_cosh Real.sinh_add_cosh\n\n/- warning: real.exp_sub_cosh -> Real.exp_sub_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.cosh x)) (Real.sinh x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.cosh x)) (Real.sinh x)\nCase conversion may be inaccurate. Consider using '#align real.exp_sub_cosh Real.exp_sub_coshₓ'. -/\n@[simp]\ntheorem exp_sub_cosh : exp x - cosh x = sinh x :=\n  sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm\n#align real.exp_sub_cosh Real.exp_sub_cosh\n\n/- warning: real.exp_sub_sinh -> Real.exp_sub_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.sinh x)) (Real.cosh x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.sinh x)) (Real.cosh x)\nCase conversion may be inaccurate. Consider using '#align real.exp_sub_sinh Real.exp_sub_sinhₓ'. -/\n@[simp]\ntheorem exp_sub_sinh : exp x - sinh x = cosh x :=\n  sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm\n#align real.exp_sub_sinh Real.exp_sub_sinh\n\n/- warning: real.cosh_sub_sinh -> Real.cosh_sub_sinh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.cosh x) (Real.sinh x)) (Real.exp (Neg.neg.{0} Real Real.hasNeg x))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.cosh x) (Real.sinh x)) (Real.exp (Neg.neg.{0} Real Real.instNegReal x))\nCase conversion may be inaccurate. Consider using '#align real.cosh_sub_sinh Real.cosh_sub_sinhₓ'. -/\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) :=\n  by\n  rw [← of_real_inj]\n  simp\n#align real.cosh_sub_sinh Real.cosh_sub_sinh\n\n/- warning: real.sinh_sub_cosh -> Real.sinh_sub_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.sinh x) (Real.cosh x)) (Neg.neg.{0} Real Real.hasNeg (Real.exp (Neg.neg.{0} Real Real.hasNeg x)))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.sinh x) (Real.cosh x)) (Neg.neg.{0} Real Real.instNegReal (Real.exp (Neg.neg.{0} Real Real.instNegReal x)))\nCase conversion may be inaccurate. Consider using '#align real.sinh_sub_cosh Real.sinh_sub_coshₓ'. -/\n@[simp]\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh]\n#align real.sinh_sub_cosh Real.sinh_sub_cosh\n\n/- warning: real.cosh_sq_sub_sinh_sq -> Real.cosh_sq_sub_sinh_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align real.cosh_sq_sub_sinh_sq Real.cosh_sq_sub_sinh_sqₓ'. -/\n@[simp]\ntheorem cosh_sq_sub_sinh_sq (x : ℝ) : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [← of_real_inj] <;> simp\n#align real.cosh_sq_sub_sinh_sq Real.cosh_sq_sub_sinh_sq\n\n/- warning: real.cosh_sq -> Real.cosh_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))\nCase conversion may be inaccurate. Consider using '#align real.cosh_sq Real.cosh_sqₓ'. -/\ntheorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← of_real_inj] <;> simp [cosh_sq]\n#align real.cosh_sq Real.cosh_sq\n\n/- warning: real.cosh_sq' -> Real.cosh_sq' is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align real.cosh_sq' Real.cosh_sq'ₓ'. -/\ntheorem cosh_sq' : cosh x ^ 2 = 1 + sinh x ^ 2 :=\n  (cosh_sq x).trans (add_comm _ _)\n#align real.cosh_sq' Real.cosh_sq'\n\n/- warning: real.sinh_sq -> Real.sinh_sq is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.sinh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Real.cosh x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))\nCase conversion may be inaccurate. Consider using '#align real.sinh_sq Real.sinh_sqₓ'. -/\ntheorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [← of_real_inj] <;> simp [sinh_sq]\n#align real.sinh_sq Real.sinh_sq\n\n#print Real.cosh_two_mul /-\ntheorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by\n  rw [← of_real_inj] <;> simp [cosh_two_mul]\n#align real.cosh_two_mul Real.cosh_two_mul\n-/\n\n#print Real.sinh_two_mul /-\ntheorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by\n  rw [← of_real_inj] <;> simp [sinh_two_mul]\n#align real.sinh_two_mul Real.sinh_two_mul\n-/\n\n#print Real.cosh_three_mul /-\ntheorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by\n  rw [← of_real_inj] <;> simp [cosh_three_mul]\n#align real.cosh_three_mul Real.cosh_three_mul\n-/\n\n#print Real.sinh_three_mul /-\ntheorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by\n  rw [← of_real_inj] <;> simp [sinh_three_mul]\n#align real.sinh_three_mul Real.sinh_three_mul\n-/\n\nopen IsAbsoluteValue\n\n/- warning: real.add_one_le_exp_of_nonneg -> Real.add_one_le_exp_of_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x) -> (LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Real.exp x))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x) -> (LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Real.exp x))\nCase conversion may be inaccurate. Consider using '#align real.add_one_le_exp_of_nonneg Real.add_one_le_exp_of_nonnegₓ'. -/\n/-- This is an intermediate result that is later replaced by `real.add_one_le_exp`; use that lemma\ninstead. -/\ntheorem add_one_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : x + 1 ≤ exp x :=\n  calc\n    x + 1 ≤ limUnder (⟨fun n : ℕ => ((exp' x) n).re, isCauSeq_re (exp' x)⟩ : CauSeq ℝ Abs.abs) :=\n      le_lim\n        (CauSeq.le_of_exists\n          ⟨2, fun j hj =>\n            show x + (1 : ℝ) ≤ (∑ m in range j, (x ^ m / m ! : ℂ)).re\n              by\n              have h₁ : (((fun m : ℕ => (x ^ m / m ! : ℂ)) ∘ Nat.succ) 0).re = x := by simp\n              have h₂ : ((x : ℂ) ^ 0 / 0!).re = 1 := by simp\n              rw [← tsub_add_cancel_of_le hj, sum_range_succ', sum_range_succ', add_re, add_re, h₁,\n                h₂, add_assoc, ← coe_re_add_group_hom, re_add_group_hom.map_sum,\n                coe_re_add_group_hom]\n              refine' le_add_of_nonneg_of_le (sum_nonneg fun m hm => _) le_rfl\n              rw [← of_real_pow, ← of_real_nat_cast, ← of_real_div, of_real_re]\n              exact div_nonneg (pow_nonneg hx _) (Nat.cast_nonneg _)⟩)\n    _ = exp x := by rw [exp, Complex.exp, ← cau_seq_re, lim_re]\n    \n#align real.add_one_le_exp_of_nonneg Real.add_one_le_exp_of_nonneg\n\n/- warning: real.one_le_exp -> Real.one_le_exp is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x) -> (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (Real.exp x))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x) -> (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (Real.exp x))\nCase conversion may be inaccurate. Consider using '#align real.one_le_exp Real.one_le_expₓ'. -/\ntheorem one_le_exp {x : ℝ} (hx : 0 ≤ x) : 1 ≤ exp x := by linarith [add_one_le_exp_of_nonneg hx]\n#align real.one_le_exp Real.one_le_exp\n\n/- warning: real.exp_pos -> Real.exp_pos is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.exp x)\nbut is expected to have type\n  forall (x : Real), LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.exp x)\nCase conversion may be inaccurate. Consider using '#align real.exp_pos Real.exp_posₓ'. -/\ntheorem exp_pos (x : ℝ) : 0 < exp x :=\n  (le_total 0 x).elim (lt_of_lt_of_le zero_lt_one ∘ one_le_exp) fun h => by\n    rw [← neg_neg x, Real.exp_neg] <;>\n      exact inv_pos.2 (lt_of_lt_of_le zero_lt_one (one_le_exp (neg_nonneg.2 h)))\n#align real.exp_pos Real.exp_pos\n\n/- warning: real.abs_exp -> Real.abs_exp is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (Real.exp x)) (Real.exp x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} Real (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (Real.exp x)) (Real.exp x)\nCase conversion may be inaccurate. Consider using '#align real.abs_exp Real.abs_expₓ'. -/\n@[simp]\ntheorem abs_exp (x : ℝ) : |exp x| = exp x :=\n  abs_of_pos (exp_pos _)\n#align real.abs_exp Real.abs_exp\n\n#print Real.exp_strictMono /-\n@[mono]\ntheorem exp_strictMono : StrictMono exp := fun x y h => by\n  rw [← sub_add_cancel y x, Real.exp_add] <;>\n    exact\n      (lt_mul_iff_one_lt_left (exp_pos _)).2\n        (lt_of_lt_of_le (by linarith) (add_one_le_exp_of_nonneg (by linarith)))\n#align real.exp_strict_mono Real.exp_strictMono\n-/\n\n#print Real.exp_monotone /-\n@[mono]\ntheorem exp_monotone : Monotone exp :=\n  exp_strictMono.Monotone\n#align real.exp_monotone Real.exp_monotone\n-/\n\n/- warning: real.exp_lt_exp -> Real.exp_lt_exp is a dubious translation:\nlean 3 declaration is\n  forall {x : Real} {y : Real}, Iff (LT.lt.{0} Real Real.hasLt (Real.exp x) (Real.exp y)) (LT.lt.{0} Real Real.hasLt x y)\nbut is expected to have type\n  forall {x : Real} {y : Real}, Iff (LT.lt.{0} Real Real.instLTReal (Real.exp x) (Real.exp y)) (LT.lt.{0} Real Real.instLTReal x y)\nCase conversion may be inaccurate. Consider using '#align real.exp_lt_exp Real.exp_lt_expₓ'. -/\n@[simp]\ntheorem exp_lt_exp {x y : ℝ} : exp x < exp y ↔ x < y :=\n  exp_strictMono.lt_iff_lt\n#align real.exp_lt_exp Real.exp_lt_exp\n\n/- warning: real.exp_le_exp -> Real.exp_le_exp is a dubious translation:\nlean 3 declaration is\n  forall {x : Real} {y : Real}, Iff (LE.le.{0} Real Real.hasLe (Real.exp x) (Real.exp y)) (LE.le.{0} Real Real.hasLe x y)\nbut is expected to have type\n  forall {x : Real} {y : Real}, Iff (LE.le.{0} Real Real.instLEReal (Real.exp x) (Real.exp y)) (LE.le.{0} Real Real.instLEReal x y)\nCase conversion may be inaccurate. Consider using '#align real.exp_le_exp Real.exp_le_expₓ'. -/\n@[simp]\ntheorem exp_le_exp {x y : ℝ} : exp x ≤ exp y ↔ x ≤ y :=\n  exp_strictMono.le_iff_le\n#align real.exp_le_exp Real.exp_le_exp\n\n#print Real.exp_injective /-\ntheorem exp_injective : Function.Injective exp :=\n  exp_strictMono.Injective\n#align real.exp_injective Real.exp_injective\n-/\n\n#print Real.exp_eq_exp /-\n@[simp]\ntheorem exp_eq_exp {x y : ℝ} : exp x = exp y ↔ x = y :=\n  exp_injective.eq_iff\n#align real.exp_eq_exp Real.exp_eq_exp\n-/\n\n/- warning: real.exp_eq_one_iff -> Real.exp_eq_one_iff is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Iff (Eq.{1} Real (Real.exp x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Eq.{1} Real x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))\nbut is expected to have type\n  forall (x : Real), Iff (Eq.{1} Real (Real.exp x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Eq.{1} Real x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))\nCase conversion may be inaccurate. Consider using '#align real.exp_eq_one_iff Real.exp_eq_one_iffₓ'. -/\n@[simp]\ntheorem exp_eq_one_iff : exp x = 1 ↔ x = 0 :=\n  exp_injective.eq_iff' exp_zero\n#align real.exp_eq_one_iff Real.exp_eq_one_iff\n\n/- warning: real.one_lt_exp_iff -> Real.one_lt_exp_iff is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, Iff (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (Real.exp x)) (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x)\nbut is expected to have type\n  forall {x : Real}, Iff (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (Real.exp x)) (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x)\nCase conversion may be inaccurate. Consider using '#align real.one_lt_exp_iff Real.one_lt_exp_iffₓ'. -/\n@[simp]\ntheorem one_lt_exp_iff {x : ℝ} : 1 < exp x ↔ 0 < x := by rw [← exp_zero, exp_lt_exp]\n#align real.one_lt_exp_iff Real.one_lt_exp_iff\n\n/- warning: real.exp_lt_one_iff -> Real.exp_lt_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, Iff (LT.lt.{0} Real Real.hasLt (Real.exp x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (LT.lt.{0} Real Real.hasLt x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))\nbut is expected to have type\n  forall {x : Real}, Iff (LT.lt.{0} Real Real.instLTReal (Real.exp x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (LT.lt.{0} Real Real.instLTReal x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))\nCase conversion may be inaccurate. Consider using '#align real.exp_lt_one_iff Real.exp_lt_one_iffₓ'. -/\n@[simp]\ntheorem exp_lt_one_iff {x : ℝ} : exp x < 1 ↔ x < 0 := by rw [← exp_zero, exp_lt_exp]\n#align real.exp_lt_one_iff Real.exp_lt_one_iff\n\n/- warning: real.exp_le_one_iff -> Real.exp_le_one_iff is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, Iff (LE.le.{0} Real Real.hasLe (Real.exp x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (LE.le.{0} Real Real.hasLe x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))))\nbut is expected to have type\n  forall {x : Real}, Iff (LE.le.{0} Real Real.instLEReal (Real.exp x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (LE.le.{0} Real Real.instLEReal x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)))\nCase conversion may be inaccurate. Consider using '#align real.exp_le_one_iff Real.exp_le_one_iffₓ'. -/\n@[simp]\ntheorem exp_le_one_iff {x : ℝ} : exp x ≤ 1 ↔ x ≤ 0 :=\n  exp_zero ▸ exp_le_exp\n#align real.exp_le_one_iff Real.exp_le_one_iff\n\n/- warning: real.one_le_exp_iff -> Real.one_le_exp_iff is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, Iff (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (Real.exp x)) (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x)\nbut is expected to have type\n  forall {x : Real}, Iff (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (Real.exp x)) (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x)\nCase conversion may be inaccurate. Consider using '#align real.one_le_exp_iff Real.one_le_exp_iffₓ'. -/\n@[simp]\ntheorem one_le_exp_iff {x : ℝ} : 1 ≤ exp x ↔ 0 ≤ x :=\n  exp_zero ▸ exp_le_exp\n#align real.one_le_exp_iff Real.one_le_exp_iff\n\n/- warning: real.cosh_pos -> Real.cosh_pos is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.cosh x)\nbut is expected to have type\n  forall (x : Real), LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.cosh x)\nCase conversion may be inaccurate. Consider using '#align real.cosh_pos Real.cosh_posₓ'. -/\n/-- `real.cosh` is always positive -/\ntheorem cosh_pos (x : ℝ) : 0 < Real.cosh x :=\n  (cosh_eq x).symm ▸ half_pos (add_pos (exp_pos x) (exp_pos (-x)))\n#align real.cosh_pos Real.cosh_pos\n\n/- warning: real.sinh_lt_cosh -> Real.sinh_lt_cosh is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LT.lt.{0} Real Real.hasLt (Real.sinh x) (Real.cosh x)\nbut is expected to have type\n  forall (x : Real), LT.lt.{0} Real Real.instLTReal (Real.sinh x) (Real.cosh x)\nCase conversion may be inaccurate. Consider using '#align real.sinh_lt_cosh Real.sinh_lt_coshₓ'. -/\ntheorem sinh_lt_cosh : sinh x < cosh x :=\n  lt_of_pow_lt_pow 2 (cosh_pos _).le <| (cosh_sq x).symm ▸ lt_add_one _\n#align real.sinh_lt_cosh Real.sinh_lt_cosh\n\nend Real\n\nnamespace Complex\n\n/- warning: complex.sum_div_factorial_le -> Complex.sum_div_factorial_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (n : Nat) (j : Nat), (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (OrderedAddCommGroup.toPartialOrder.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) (Finset.sum.{u1, 0} α Nat (AddCommGroup.toAddCommMonoid.{u1} α (OrderedAddCommGroup.toAddCommGroup.{u1} α (StrictOrderedRing.toOrderedAddCommGroup.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Finset.filter.{0} Nat (fun (k : Nat) => LE.le.{0} Nat Nat.hasLe n k) (fun (a : Nat) => Nat.decidableLe n a) (Finset.range j)) (fun (m : Nat) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α (AddMonoidWithOne.toOne.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (Nat.factorial m)))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (DivInvMonoid.toHasDiv.{u1} α (DivisionRing.toDivInvMonoid.{u1} α (Field.toDivisionRing.{u1} α (LinearOrderedField.toField.{u1} α _inst_1))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (Nat.succ n)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (Distrib.toHasMul.{u1} α (Ring.toDistrib.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) (Nat.factorial n)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u1} Nat α (CoeTCₓ.coe.{1, succ u1} Nat α (Nat.castCoe.{u1} α (AddMonoidWithOne.toNatCast.{u1} α (AddGroupWithOne.toAddMonoidWithOne.{u1} α (AddCommGroupWithOne.toAddGroupWithOne.{u1} α (Ring.toAddCommGroupWithOne.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1))))))))))) n))))\nbut is expected to have type\n  forall {α : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} α] (n : Nat) (j : Nat), (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LE.le.{u1} α (Preorder.toLE.{u1} α (PartialOrder.toPreorder.{u1} α (StrictOrderedRing.toPartialOrder.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Finset.sum.{u1, 0} α Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} α (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} α (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} α (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} α (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} α (LinearOrderedField.toLinearOrderedSemifield.{u1} α _inst_1)))))) (Finset.filter.{0} Nat (fun (k : Nat) => LE.le.{0} Nat instLENat n k) (fun (a : Nat) => Nat.decLe n a) (Finset.range j)) (fun (m : Nat) => HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (OfNat.ofNat.{u1} α 1 (One.toOfNat1.{u1} α (NonAssocRing.toOne.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Nat.factorial m)))) (HDiv.hDiv.{u1, u1, u1} α α α (instHDiv.{u1} α (LinearOrderedField.toDiv.{u1} α _inst_1)) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Nat.succ n)) (HMul.hMul.{u1, u1, u1} α α α (instHMul.{u1} α (NonUnitalNonAssocRing.toMul.{u1} α (NonAssocRing.toNonUnitalNonAssocRing.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))))) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) (Nat.factorial n)) (Nat.cast.{u1} α (NonAssocRing.toNatCast.{u1} α (Ring.toNonAssocRing.{u1} α (StrictOrderedRing.toRing.{u1} α (LinearOrderedRing.toStrictOrderedRing.{u1} α (LinearOrderedCommRing.toLinearOrderedRing.{u1} α (LinearOrderedField.toLinearOrderedCommRing.{u1} α _inst_1)))))) n))))\nCase conversion may be inaccurate. Consider using '#align complex.sum_div_factorial_le Complex.sum_div_factorial_leₓ'. -/\ntheorem sum_div_factorial_le {α : Type _} [LinearOrderedField α] (n j : ℕ) (hn : 0 < n) :\n    (∑ m in Filter (fun k => n ≤ k) (range j), (1 / m ! : α)) ≤ n.succ / (n ! * n) :=\n  calc\n    (∑ m in Filter (fun k => n ≤ k) (range j), (1 / m ! : α)) =\n        ∑ m in range (j - n), 1 / (m + n)! :=\n      sum_bij (fun m _ => m - n)\n        (fun m hm =>\n          mem_range.2 <|\n            (tsub_lt_tsub_iff_right (by simp at hm <;> tauto)).2 (by simp at hm <;> tauto))\n        (fun m hm => by rw [tsub_add_cancel_of_le] <;> simp at * <;> tauto)\n        (fun a₁ a₂ ha₁ ha₂ h => by\n          rwa [tsub_eq_iff_eq_add_of_le, tsub_add_eq_add_tsub, eq_comm, tsub_eq_iff_eq_add_of_le,\n                add_left_inj, eq_comm] at h <;>\n              simp at * <;>\n            tauto)\n        fun b hb =>\n        ⟨b + n,\n          mem_filter.2 ⟨mem_range.2 <| lt_tsub_iff_right.mp (mem_range.1 hb), Nat.le_add_left _ _⟩,\n          by rw [add_tsub_cancel_right]⟩\n    _ ≤ ∑ m in range (j - n), (n ! * n.succ ^ m)⁻¹ :=\n      by\n      refine' sum_le_sum fun m n => _\n      rw [one_div, inv_le_inv]\n      · rw [← Nat.cast_pow, ← Nat.cast_mul, Nat.cast_le, add_comm]\n        exact Nat.factorial_mul_pow_le_factorial\n      · exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      ·\n        exact\n          mul_pos (Nat.cast_pos.2 (Nat.factorial_pos _))\n            (pow_pos (Nat.cast_pos.2 (Nat.succ_pos _)) _)\n    _ = n !⁻¹ * ∑ m in range (j - n), n.succ⁻¹ ^ m := by\n      simp [mul_inv, mul_sum.symm, sum_mul.symm, -Nat.factorial_succ, mul_comm, inv_pow]\n    _ = (n.succ - n.succ * n.succ⁻¹ ^ (j - n)) / (n ! * n) :=\n      by\n      have h₁ : (n.succ : α) ≠ 1 :=\n        @Nat.cast_one α _ ▸ mt Nat.cast_inj.1 (mt Nat.succ.inj (pos_iff_ne_zero.1 hn))\n      have h₂ : (n.succ : α) ≠ 0 := Nat.cast_ne_zero.2 (Nat.succ_ne_zero _)\n      have h₃ : (n ! * n : α) ≠ 0 :=\n        mul_ne_zero (Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.factorial_pos _)))\n          (Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 hn))\n      have h₄ : (n.succ - 1 : α) = n := by simp\n      rw [geom_sum_inv h₁ h₂, eq_div_iff_mul_eq h₃, mul_comm _ (n ! * n : α), ←\n          mul_assoc (n !⁻¹ : α), ← mul_inv_rev, h₄, ← mul_assoc (n ! * n : α), mul_comm (n : α) n !,\n          mul_inv_cancel h₃] <;>\n        simp [mul_add, add_mul, mul_assoc, mul_comm]\n    _ ≤ n.succ / (n ! * n) :=\n      by\n      refine' Iff.mpr (div_le_div_right (mul_pos _ _)) _\n      exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      exact Nat.cast_pos.2 hn\n      exact\n        sub_le_self _\n          (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg (inv_nonneg.2 (Nat.cast_nonneg _)) _))\n    \n#align complex.sum_div_factorial_le Complex.sum_div_factorial_le\n\n/- warning: complex.exp_bound -> Complex.exp_bound is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex}, (LE.le.{0} Real Real.hasLe (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (forall {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LE.le.{0} Real Real.hasLe (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (AddCommGroup.toAddCommMonoid.{0} Complex Complex.addCommGroup) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) x m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Complex (HasLiftT.mk.{1, 1} Nat Complex (CoeTCₓ.coe.{1, 1} Nat Complex (Nat.castCoe.{0} Complex (AddMonoidWithOne.toNatCast.{0} Complex (AddGroupWithOne.toAddMonoidWithOne.{0} Complex Complex.addGroupWithOne))))) (Nat.factorial m)))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x) n) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.succ n)) (Inv.inv.{0} Real Real.hasInv (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n)))))))\nbut is expected to have type\n  forall {x : Complex}, (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instLEReal (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) 1 (One.toOfNat1.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instOneReal))) -> (forall {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) Real.instLEReal (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) (HMul.hMul.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (instHMul.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instMulReal) (HPow.hPow.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Nat ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (instHPow.{0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Nat (Monoid.Pow.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instMonoidReal)) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x) n) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Nat.cast.{0} Real Real.natCast (Nat.succ n)) (Inv.inv.{0} Real Real.instInvReal (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Nat.cast.{0} Real Real.natCast (Nat.factorial n)) (Nat.cast.{0} Real Real.natCast n)))))))\nCase conversion may be inaccurate. Consider using '#align complex.exp_bound Complex.exp_boundₓ'. -/\ntheorem exp_bound {x : ℂ} (hx : abs x ≤ 1) {n : ℕ} (hn : 0 < n) :\n    abs (exp x - ∑ m in range n, x ^ m / m !) ≤ abs x ^ n * (n.succ * (n ! * n)⁻¹) :=\n  by\n  rw [← lim_const (∑ m in range n, _), exp, sub_eq_add_neg, ← lim_neg, lim_add, ← lim_abs]\n  refine' lim_le (CauSeq.le_of_exists ⟨n, fun j hj => _⟩)\n  simp_rw [← sub_eq_add_neg]\n  show\n    abs ((∑ m in range j, x ^ m / m !) - ∑ m in range n, x ^ m / m !) ≤\n      abs x ^ n * (n.succ * (n ! * n)⁻¹)\n  rw [sum_range_sub_sum_range hj]\n  calc\n    abs (∑ m in (range j).filterₓ fun k => n ≤ k, (x ^ m / m ! : ℂ)) =\n        abs (∑ m in (range j).filterₓ fun k => n ≤ k, (x ^ n * (x ^ (m - n) / m !) : ℂ)) :=\n      by\n      refine' congr_arg abs (sum_congr rfl fun m hm => _)\n      rw [mem_filter, mem_range] at hm\n      rw [← mul_div_assoc, ← pow_add, add_tsub_cancel_of_le hm.2]\n    _ ≤ ∑ m in Filter (fun k => n ≤ k) (range j), abs (x ^ n * (_ / m !)) :=\n      (abv_sum_le_sum_abv _ _)\n    _ ≤ ∑ m in Filter (fun k => n ≤ k) (range j), abs x ^ n * (1 / m !) :=\n      by\n      refine' sum_le_sum fun m hm => _\n      rw [map_mul, map_pow, map_div₀, abs_cast_nat]\n      refine' mul_le_mul_of_nonneg_left ((div_le_div_right _).2 _) _\n      · exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      · rw [abv_pow abs]\n        exact pow_le_one _ (abs.nonneg _) hx\n      · exact pow_nonneg (abs.nonneg _) _\n    _ = abs x ^ n * ∑ m in (range j).filterₓ fun k => n ≤ k, (1 / m ! : ℝ) := by\n      simp [abs_mul, abv_pow abs, abs_div, mul_sum.symm]\n    _ ≤ abs x ^ n * (n.succ * (n ! * n)⁻¹) :=\n      mul_le_mul_of_nonneg_left (sum_div_factorial_le _ _ hn) (pow_nonneg (abs.nonneg _) _)\n    \n#align complex.exp_bound Complex.exp_bound\n\n/- warning: complex.exp_bound' -> Complex.exp_bound' is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex} {n : Nat}, (LE.le.{0} Real Real.hasLe (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.succ n))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))) -> (LE.le.{0} Real Real.hasLe (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (AddCommGroup.toAddCommMonoid.{0} Complex Complex.addCommGroup) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (DivInvMonoid.toHasDiv.{0} Complex (DivisionRing.toDivInvMonoid.{0} Complex (Field.toDivisionRing.{0} Complex Complex.field)))) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (Ring.toMonoid.{0} Complex Complex.ring))) x m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Complex (HasLiftT.mk.{1, 1} Nat Complex (CoeTCₓ.coe.{1, 1} Nat Complex (Nat.castCoe.{0} Complex (AddMonoidWithOne.toNatCast.{0} Complex (AddGroupWithOne.toAddMonoidWithOne.{0} Complex Complex.addGroupWithOne))))) (Nat.factorial m)))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x) n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n))) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))))\nbut is expected to have type\n  forall {x : Complex} {n : Nat}, (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instLEReal (HDiv.hDiv.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (instHDiv.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (LinearOrderedField.toDiv.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instLinearOrderedFieldReal)) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x) (Nat.cast.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.natCast (Nat.succ n))) (HDiv.hDiv.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (instHDiv.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (LinearOrderedField.toDiv.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) 1 (One.toOfNat1.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instOneReal)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) 2 (instOfNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) -> (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) Real.instLEReal (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) (HMul.hMul.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (instHMul.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instMulReal) (HDiv.hDiv.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (instHDiv.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (LinearOrderedField.toDiv.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Nat ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) (instHPow.{0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Nat (Monoid.Pow.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instMonoidReal)) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x) n) (Nat.cast.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) Real.natCast (Nat.factorial n))) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) 2 (instOfNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (Finset.sum.{0, 0} Complex Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{0} Complex (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{0} Complex (NonAssocRing.toNonUnitalNonAssocRing.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)))) (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Complex Complex Complex (instHDiv.{0} Complex (Field.toDiv.{0} Complex Complex.instFieldComplex)) (HPow.hPow.{0, 0, 0} Complex Nat Complex (instHPow.{0, 0} Complex Nat (Monoid.Pow.{0} Complex (MonoidWithZero.toMonoid.{0} Complex (Semiring.toMonoidWithZero.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) x m) (Nat.cast.{0} Complex (NonAssocRing.toNatCast.{0} Complex (Ring.toNonAssocRing.{0} Complex Complex.instRingComplex)) (Nat.factorial m)))))) 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))\nCase conversion may be inaccurate. Consider using '#align complex.exp_bound' Complex.exp_bound'ₓ'. -/\ntheorem exp_bound' {x : ℂ} {n : ℕ} (hx : abs x / n.succ ≤ 1 / 2) :\n    abs (exp x - ∑ m in range n, x ^ m / m !) ≤ abs x ^ n / n ! * 2 :=\n  by\n  rw [← lim_const (∑ m in range n, _), exp, sub_eq_add_neg, ← lim_neg, lim_add, ← lim_abs]\n  refine' lim_le (CauSeq.le_of_exists ⟨n, fun j hj => _⟩)\n  simp_rw [← sub_eq_add_neg]\n  show abs ((∑ m in range j, x ^ m / m !) - ∑ m in range n, x ^ m / m !) ≤ abs x ^ n / n ! * 2\n  let k := j - n\n  have hj : j = n + k := (add_tsub_cancel_of_le hj).symm\n  rw [hj, sum_range_add_sub_sum_range]\n  calc\n    abs (∑ i : ℕ in range k, x ^ (n + i) / ((n + i)! : ℂ)) ≤\n        ∑ i : ℕ in range k, abs (x ^ (n + i) / ((n + i)! : ℂ)) :=\n      abv_sum_le_sum_abv _ _\n    _ ≤ ∑ i : ℕ in range k, abs x ^ (n + i) / (n + i)! := by\n      simp only [Complex.abs_cast_nat, map_div₀, abv_pow abs]\n    _ ≤ ∑ i : ℕ in range k, abs x ^ (n + i) / (n ! * n.succ ^ i) := _\n    _ = ∑ i : ℕ in range k, abs x ^ n / n ! * (abs x ^ i / n.succ ^ i) := _\n    _ ≤ abs x ^ n / ↑n ! * 2 := _\n    \n  · refine' sum_le_sum fun m hm => div_le_div (pow_nonneg (abs.nonneg x) (n + m)) le_rfl _ _\n    · exact_mod_cast mul_pos n.factorial_pos (pow_pos n.succ_pos _)\n    · exact_mod_cast Nat.factorial_mul_pow_le_factorial\n  · refine' Finset.sum_congr rfl fun _ _ => _\n    simp only [pow_add, div_eq_inv_mul, mul_inv, mul_left_comm, mul_assoc]\n  · rw [← mul_sum]\n    apply mul_le_mul_of_nonneg_left\n    · simp_rw [← div_pow]\n      rw [geom_sum_eq, div_le_iff_of_neg]\n      · trans (-1 : ℝ)\n        · linarith\n        · simp only [neg_le_sub_iff_le_add, div_pow, Nat.cast_succ, le_add_iff_nonneg_left]\n          exact\n            div_nonneg (pow_nonneg (abs.nonneg x) k)\n              (pow_nonneg (add_nonneg n.cast_nonneg zero_le_one) k)\n      · linarith\n      · linarith\n    · exact div_nonneg (pow_nonneg (abs.nonneg x) n) (Nat.cast_nonneg n !)\n#align complex.exp_bound' Complex.exp_bound'\n\n/- warning: complex.abs_exp_sub_one_le -> Complex.abs_exp_sub_one_le is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex}, (LE.le.{0} Real Real.hasLe (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x)))\nbut is expected to have type\n  forall {x : Complex}, (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instLEReal (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) 1 (One.toOfNat1.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instOneReal))) -> (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))) Real.instLEReal (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))) (HMul.hMul.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))) (instHMul.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))) Real.instMulReal) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))) 2 (instOfNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex)))) 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x)))\nCase conversion may be inaccurate. Consider using '#align complex.abs_exp_sub_one_le Complex.abs_exp_sub_one_leₓ'. -/\ntheorem abs_exp_sub_one_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1) ≤ 2 * abs x :=\n  calc\n    abs (exp x - 1) = abs (exp x - ∑ m in range 1, x ^ m / m !) := by simp [sum_range_succ]\n    _ ≤ abs x ^ 1 * (Nat.succ 1 * (1! * (1 : ℕ))⁻¹) := (exp_bound hx (by decide))\n    _ = 2 * abs x := by simp [two_mul, mul_two, mul_add, mul_comm]\n    \n#align complex.abs_exp_sub_one_le Complex.abs_exp_sub_one_le\n\n/- warning: complex.abs_exp_sub_one_sub_id_le -> Complex.abs_exp_sub_one_sub_id_le is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex}, (LE.le.{0} Real Real.hasLe (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.hasSub) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (OfNat.mk.{0} Complex 1 (One.one.{0} Complex Complex.hasOne)))) x)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs x) (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {x : Complex}, (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instLEReal (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) 1 (One.toOfNat1.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instOneReal))) -> (LE.le.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex))) x)) Real.instLEReal (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex))) x)) (HPow.hPow.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Nat ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (HSub.hSub.{0, 0, 0} Complex Complex Complex (instHSub.{0} Complex Complex.instSubComplex) (Complex.exp x) (OfNat.ofNat.{0} Complex 1 (One.toOfNat1.{0} Complex Complex.instOneComplex))) x)) (instHPow.{0, 0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Nat (Monoid.Pow.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) x) Real.instMonoidReal)) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs x) (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align complex.abs_exp_sub_one_sub_id_le Complex.abs_exp_sub_one_sub_id_leₓ'. -/\ntheorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=\n  calc\n    abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m !) := by\n      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc]\n    _ ≤ abs x ^ 2 * (Nat.succ 2 * (2! * (2 : ℕ))⁻¹) := (exp_bound hx (by decide))\n    _ ≤ abs x ^ 2 * 1 := (mul_le_mul_of_nonneg_left (by norm_num) (sq_nonneg (abs x)))\n    _ = abs x ^ 2 := by rw [mul_one]\n    \n#align complex.abs_exp_sub_one_sub_id_le Complex.abs_exp_sub_one_sub_id_le\n\nend Complex\n\nnamespace Real\n\nopen Complex Finset\n\n/- warning: real.exp_bound -> Real.exp_bound is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (forall {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Finset.sum.{0, 0} Real Nat Real.addCommMonoid (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) x m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial m)))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) n) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.succ n)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n))))))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (forall {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Finset.sum.{0, 0} Real Nat Real.instAddCommMonoidReal (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) x m) (Nat.cast.{0} Real Real.natCast (Nat.factorial m)))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) n) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Nat.cast.{0} Real Real.natCast (Nat.succ n)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Nat.cast.{0} Real Real.natCast (Nat.factorial n)) (Nat.cast.{0} Real Real.natCast n))))))\nCase conversion may be inaccurate. Consider using '#align real.exp_bound Real.exp_boundₓ'. -/\ntheorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) :\n    |exp x - ∑ m in range n, x ^ m / m !| ≤ |x| ^ n * (n.succ / (n ! * n)) :=\n  by\n  have hxc : Complex.abs x ≤ 1 := by exact_mod_cast hx\n  convert exp_bound hxc hn <;> norm_cast\n#align real.exp_bound Real.exp_bound\n\n/- warning: real.exp_bound' -> Real.exp_bound' is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x) -> (LE.le.{0} Real Real.hasLe x (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (forall {n : Nat}, (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) n) -> (LE.le.{0} Real Real.hasLe (Real.exp x) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (Finset.sum.{0, 0} Real Nat Real.addCommMonoid (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) x m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial m)))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) x n) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n))))))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x) -> (LE.le.{0} Real Real.instLEReal x (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (forall {n : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LE.le.{0} Real Real.instLEReal (Real.exp x) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Finset.sum.{0, 0} Real Nat Real.instAddCommMonoidReal (Finset.range n) (fun (m : Nat) => HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) x m) (Nat.cast.{0} Real Real.natCast (Nat.factorial m)))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) x n) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Nat.cast.{0} Real Real.natCast n) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (Nat.cast.{0} Real Real.natCast (Nat.factorial n)) (Nat.cast.{0} Real Real.natCast n))))))\nCase conversion may be inaccurate. Consider using '#align real.exp_bound' Real.exp_bound'ₓ'. -/\ntheorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :\n    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m !) + x ^ n * (n + 1) / (n ! * n) :=\n  by\n  have h3 : |x| = x := by simpa\n  have h4 : |x| ≤ 1 := by rwa [h3]\n  have h' := Real.exp_bound h4 hn\n  rw [h3] at h'\n  have h'' := (abs_sub_le_iff.1 h').1\n  have t := sub_le_iff_le_add'.1 h''\n  simpa [mul_div_assoc] using t\n#align real.exp_bound' Real.exp_bound'\n\n/- warning: real.abs_exp_sub_one_le -> Real.abs_exp_sub_one_le is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x)))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x)))\nCase conversion may be inaccurate. Consider using '#align real.abs_exp_sub_one_le Real.abs_exp_sub_one_leₓ'. -/\ntheorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| :=\n  by\n  have : Complex.abs x ≤ 1 := by exact_mod_cast hx\n  exact_mod_cast Complex.abs_exp_sub_one_le this\n#align real.abs_exp_sub_one_le Real.abs_exp_sub_one_le\n\n/- warning: real.abs_exp_sub_one_sub_id_le -> Real.abs_exp_sub_one_sub_id_le is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) x)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) x)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))))\nCase conversion may be inaccurate. Consider using '#align real.abs_exp_sub_one_sub_id_le Real.abs_exp_sub_one_sub_id_leₓ'. -/\ntheorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 :=\n  by\n  rw [← _root_.sq_abs]\n  have : Complex.abs x ≤ 1 := by exact_mod_cast hx\n  exact_mod_cast Complex.abs_exp_sub_one_sub_id_le this\n#align real.abs_exp_sub_one_sub_id_le Real.abs_exp_sub_one_sub_id_le\n\n#print Real.expNear /-\n/-- A finite initial segment of the exponential series, followed by an arbitrary tail.\nFor fixed `n` this is just a linear map wrt `r`, and each map is a simple linear function\nof the previous (see `exp_near_succ`), with `exp_near n x r ⟶ exp x` as `n ⟶ ∞`,\nfor any `r`. -/\ndef expNear (n : ℕ) (x r : ℝ) : ℝ :=\n  (∑ m in range n, x ^ m / m !) + x ^ n / n ! * r\n#align real.exp_near Real.expNear\n-/\n\n#print Real.expNear_zero /-\n@[simp]\ntheorem expNear_zero (x r) : expNear 0 x r = r := by simp [exp_near]\n#align real.exp_near_zero Real.expNear_zero\n-/\n\n/- warning: real.exp_near_succ -> Real.expNear_succ is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat) (x : Real) (r : Real), Eq.{1} Real (Real.expNear (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) x r) (Real.expNear n x (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) x (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))) r)))\nbut is expected to have type\n  forall (n : Nat) (x : Real) (r : Real), Eq.{1} Real (Real.expNear (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) x r) (Real.expNear n x (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) x (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Nat.cast.{0} Real Real.natCast n) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))) r)))\nCase conversion may be inaccurate. Consider using '#align real.exp_near_succ Real.expNear_succₓ'. -/\n@[simp]\ntheorem expNear_succ (n x r) : expNear (n + 1) x r = expNear n x (1 + x / (n + 1) * r) := by\n  simp [exp_near, range_succ, mul_add, add_left_comm, add_assoc, pow_succ, div_eq_mul_inv,\n      mul_inv] <;>\n    ac_rfl\n#align real.exp_near_succ Real.expNear_succ\n\n/- warning: real.exp_near_sub -> Real.expNear_sub is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat) (x : Real) (r₁ : Real) (r₂ : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.expNear n x r₁) (Real.expNear n x r₂)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) x n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) r₁ r₂))\nbut is expected to have type\n  forall (n : Nat) (x : Real) (r₁ : Real) (r₂ : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.expNear n x r₁) (Real.expNear n x r₂)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) x n) (Nat.cast.{0} Real Real.natCast (Nat.factorial n))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) r₁ r₂))\nCase conversion may be inaccurate. Consider using '#align real.exp_near_sub Real.expNear_subₓ'. -/\ntheorem expNear_sub (n x r₁ r₂) : expNear n x r₁ - expNear n x r₂ = x ^ n / n ! * (r₁ - r₂) := by\n  simp [exp_near, mul_sub]\n#align real.exp_near_sub Real.expNear_sub\n\n/- warning: real.exp_approx_end -> Real.exp_approx_end is a dubious translation:\nlean 3 declaration is\n  forall (n : Nat) (m : Nat) (x : Real), (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) m) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.expNear m x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial m))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m))))\nbut is expected to have type\n  forall (n : Nat) (m : Nat) (x : Real), (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) m) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.expNear m x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) m) (Nat.cast.{0} Real Real.natCast (Nat.factorial m))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (Nat.cast.{0} Real Real.natCast m) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Nat.cast.{0} Real Real.natCast m))))\nCase conversion may be inaccurate. Consider using '#align real.exp_approx_end Real.exp_approx_endₓ'. -/\ntheorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) :\n    |exp x - expNear m x 0| ≤ |x| ^ m / m ! * ((m + 1) / m) :=\n  by\n  simp [exp_near]\n  convert exp_bound h _ using 1\n  field_simp [mul_comm]\n  linarith\n#align real.exp_approx_end Real.exp_approx_end\n\n/- warning: real.exp_approx_succ -> Real.exp_approx_succ is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {x : Real} {a₁ : Real} {b₁ : Real} (m : Nat), (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) m) -> (forall (a₂ : Real) (b₂ : Real), (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m)) a₂)) a₁)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) b₁ (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m)) b₂))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.expNear m x a₂))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial m))) b₂)) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.expNear n x a₁))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n))) b₁)))\nbut is expected to have type\n  forall {n : Nat} {x : Real} {a₁ : Real} {b₁ : Real} (m : Nat), (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) m) -> (forall (a₂ : Real) (b₂ : Real), (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) x (Nat.cast.{0} Real Real.natCast m)) a₂)) a₁)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) b₁ (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (Nat.cast.{0} Real Real.natCast m)) b₂))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.expNear m x a₂))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) m) (Nat.cast.{0} Real Real.natCast (Nat.factorial m))) b₂)) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.expNear n x a₁))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) n) (Nat.cast.{0} Real Real.natCast (Nat.factorial n))) b₁)))\nCase conversion may be inaccurate. Consider using '#align real.exp_approx_succ Real.exp_approx_succₓ'. -/\ntheorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)\n    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)\n    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m ! * b₂) :\n    |exp x - expNear n x a₁| ≤ |x| ^ n / n ! * b₁ :=\n  by\n  refine' (_root_.abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)\n  subst e₁; rw [exp_near_succ, exp_near_sub, _root_.abs_mul]\n  convert mul_le_mul_of_nonneg_left (le_sub_iff_add_le'.1 e) _\n  · simp [mul_add, pow_succ', div_eq_mul_inv, _root_.abs_mul, _root_.abs_inv, ← pow_abs, mul_inv]\n    ac_rfl\n  · simp [_root_.div_nonneg, _root_.abs_nonneg]\n#align real.exp_approx_succ Real.exp_approx_succ\n\n/- warning: real.exp_approx_end' -> Real.exp_approx_end' is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {x : Real} {a : Real} {b : Real} (m : Nat), (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) m) -> (forall (rm : Real), (Eq.{1} Real ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m) rm) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) a)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) b (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) rm) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) rm (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) rm)))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.expNear n x a))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n))) b)))\nbut is expected to have type\n  forall {n : Nat} {x : Real} {a : Real} {b : Real} (m : Nat), (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) m) -> (forall (rm : Real), (Eq.{1} Real (Nat.cast.{0} Real Real.natCast m) rm) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) a)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) b (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) rm) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) rm (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) rm)))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.expNear n x a))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) n) (Nat.cast.{0} Real Real.natCast (Nat.factorial n))) b)))\nCase conversion may be inaccurate. Consider using '#align real.exp_approx_end' Real.exp_approx_end'ₓ'. -/\ntheorem exp_approx_end' {n} {x a b : ℝ} (m : ℕ) (e₁ : n + 1 = m) (rm : ℝ) (er : ↑m = rm)\n    (h : |x| ≤ 1) (e : |1 - a| ≤ b - |x| / rm * ((rm + 1) / rm)) :\n    |exp x - expNear n x a| ≤ |x| ^ n / n ! * b := by\n  subst er <;> exact exp_approx_succ _ e₁ _ _ (by simpa using e) (exp_approx_end _ _ _ e₁ h)\n#align real.exp_approx_end' Real.exp_approx_end'\n\n/- warning: real.exp_1_approx_succ_eq -> Real.exp_1_approx_succ_eq is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {a₁ : Real} {b₁ : Real} {m : Nat}, (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) n (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))) m) -> (forall {rm : Real}, (Eq.{1} Real ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m) rm) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Real.expNear m (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) a₁ (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) rm)))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) m) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial m))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) b₁ rm))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Real.expNear n (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) a₁))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) n) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n))) b₁)))\nbut is expected to have type\n  forall {n : Nat} {a₁ : Real} {b₁ : Real} {m : Nat}, (Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) m) -> (forall {rm : Real}, (Eq.{1} Real (Nat.cast.{0} Real Real.natCast m) rm) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Real.expNear m (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) a₁ (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) rm)))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) m) (Nat.cast.{0} Real Real.natCast (Nat.factorial m))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) b₁ rm))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Real.expNear n (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) a₁))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) n) (Nat.cast.{0} Real Real.natCast (Nat.factorial n))) b₁)))\nCase conversion may be inaccurate. Consider using '#align real.exp_1_approx_succ_eq Real.exp_1_approx_succ_eqₓ'. -/\ntheorem exp_1_approx_succ_eq {n} {a₁ b₁ : ℝ} {m : ℕ} (en : n + 1 = m) {rm : ℝ} (er : ↑m = rm)\n    (h : |exp 1 - expNear m 1 ((a₁ - 1) * rm)| ≤ |1| ^ m / m ! * (b₁ * rm)) :\n    |exp 1 - expNear n 1 a₁| ≤ |1| ^ n / n ! * b₁ :=\n  by\n  subst er\n  refine' exp_approx_succ _ en _ _ _ h\n  field_simp [show (m : ℝ) ≠ 0 by norm_cast <;> linarith]\n#align real.exp_1_approx_succ_eq Real.exp_1_approx_succ_eq\n\n/- warning: real.exp_approx_start -> Real.exp_approx_start is a dubious translation:\nlean 3 declaration is\n  forall (x : Real) (a : Real) (b : Real), (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) (Real.expNear (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) x a))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))))) b)) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.exp x) a)) b)\nbut is expected to have type\n  forall (x : Real) (a : Real) (b : Real), (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) (Real.expNear (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) x a))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (Nat.cast.{0} Real Real.natCast (Nat.factorial (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) b)) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.exp x) a)) b)\nCase conversion may be inaccurate. Consider using '#align real.exp_approx_start Real.exp_approx_startₓ'. -/\ntheorem exp_approx_start (x a b : ℝ) (h : |exp x - expNear 0 x a| ≤ |x| ^ 0 / 0! * b) :\n    |exp x - a| ≤ b := by simpa using h\n#align real.exp_approx_start Real.exp_approx_start\n\n/- warning: real.cos_bound -> Real.cos_bound is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.cos x) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) x (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Nat 4 (OfNat.mk.{0} Nat 4 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 5 (OfNat.mk.{0} Real 5 (bit1.{0} Real Real.hasOne Real.hasAdd (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) (OfNat.ofNat.{0} Real 96 (OfNat.mk.{0} Real 96 (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit1.{0} Real Real.hasOne Real.hasAdd (One.one.{0} Real Real.hasOne))))))))))))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.cos x) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) x (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2))) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Nat 4 (instOfNatNat 4))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 5 (instOfNat.{0} Real 5 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 3 (instOfNatNat 3))))) (OfNat.ofNat.{0} Real 96 (instOfNat.{0} Real 96 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 94 (instOfNatNat 94))))))))\nCase conversion may be inaccurate. Consider using '#align real.cos_bound Real.cos_boundₓ'. -/\ntheorem cos_bound {x : ℝ} (hx : |x| ≤ 1) : |cos x - (1 - x ^ 2 / 2)| ≤ |x| ^ 4 * (5 / 96) :=\n  calc\n    |cos x - (1 - x ^ 2 / 2)| = abs (Complex.cos x - (1 - x ^ 2 / 2)) := by\n      rw [← abs_of_real] <;> simp [of_real_bit0, of_real_one, of_real_inv]\n    _ = abs ((Complex.exp (x * I) + Complex.exp (-x * I) - (2 - x ^ 2)) / 2) := by\n      simp [Complex.cos, sub_div, add_div, neg_div, div_self (two_ne_zero' ℂ)]\n    _ =\n        abs\n          (((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m !) +\n              (Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m !)) /\n            2) :=\n      (congr_arg abs\n        (congr_arg (fun x : ℂ => x / 2)\n          (by\n            simp only [sum_range_succ]\n            simp [pow_succ]\n            apply Complex.ext <;> simp [div_eq_mul_inv, norm_sq] <;> ring)))\n    _ ≤\n        abs ((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m !) / 2) +\n          abs ((Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m !) / 2) :=\n      by rw [add_div] <;> exact complex.abs.add_le _ _\n    _ =\n        abs (Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m !) / 2 +\n          abs (Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m !) / 2 :=\n      by simp [map_div₀]\n    _ ≤\n        Complex.abs (x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : ℕ))⁻¹) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : ℕ))⁻¹) / 2 :=\n      (add_le_add ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide)))\n        ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide))))\n    _ ≤ |x| ^ 4 * (5 / 96) := by\n      norm_num <;> simp [mul_assoc, mul_comm, mul_left_comm, mul_div_assoc]\n    \n#align real.cos_bound Real.cos_bound\n\n/- warning: real.sin_bound -> Real.sin_bound is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.sin x) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) x (OfNat.ofNat.{0} Nat 3 (OfNat.mk.{0} Nat 3 (bit1.{0} Nat Nat.hasOne Nat.hasAdd (One.one.{0} Nat Nat.hasOne))))) (OfNat.ofNat.{0} Real 6 (OfNat.mk.{0} Real 6 (bit0.{0} Real Real.hasAdd (bit1.{0} Real Real.hasOne Real.hasAdd (One.one.{0} Real Real.hasOne))))))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.hasMul) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Nat 4 (OfNat.mk.{0} Nat 4 (bit0.{0} Nat Nat.hasAdd (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 5 (OfNat.mk.{0} Real 5 (bit1.{0} Real Real.hasOne Real.hasAdd (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) (OfNat.ofNat.{0} Real 96 (OfNat.mk.{0} Real 96 (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit0.{0} Real Real.hasAdd (bit1.{0} Real Real.hasOne Real.hasAdd (One.one.{0} Real Real.hasOne))))))))))))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.sin x) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) x (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) x (OfNat.ofNat.{0} Nat 3 (instOfNatNat 3))) (OfNat.ofNat.{0} Real 6 (instOfNat.{0} Real 6 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 4 (instOfNatNat 4))))))))) (HMul.hMul.{0, 0, 0} Real Real Real (instHMul.{0} Real Real.instMulReal) (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Nat 4 (instOfNatNat 4))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 5 (instOfNat.{0} Real 5 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 3 (instOfNatNat 3))))) (OfNat.ofNat.{0} Real 96 (instOfNat.{0} Real 96 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 94 (instOfNatNat 94))))))))\nCase conversion may be inaccurate. Consider using '#align real.sin_bound Real.sin_boundₓ'. -/\ntheorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x| ^ 4 * (5 / 96) :=\n  calc\n    |sin x - (x - x ^ 3 / 6)| = abs (Complex.sin x - (x - x ^ 3 / 6)) := by\n      rw [← abs_of_real] <;> simp [of_real_bit0, of_real_one, of_real_inv]\n    _ = abs (((Complex.exp (-x * I) - Complex.exp (x * I)) * I - (2 * x - x ^ 3 / 3)) / 2) := by\n      simp [Complex.sin, sub_div, add_div, neg_div, mul_div_cancel_left _ (two_ne_zero' ℂ), div_div,\n        show (3 : ℂ) * 2 = 6 by norm_num]\n    _ =\n        abs\n          (((Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m !) -\n                (Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m !)) *\n              I /\n            2) :=\n      (congr_arg abs\n        (congr_arg (fun x : ℂ => x / 2)\n          (by\n            simp only [sum_range_succ]\n            simp [pow_succ]\n            apply Complex.ext <;> simp [div_eq_mul_inv, norm_sq] <;> ring)))\n    _ ≤\n        abs ((Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m !) * I / 2) +\n          abs (-((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m !) * I) / 2) :=\n      by rw [sub_mul, sub_eq_add_neg, add_div] <;> exact complex.abs.add_le _ _\n    _ =\n        abs (Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m !) / 2 +\n          abs (Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m !) / 2 :=\n      by simp [add_comm, map_div₀]\n    _ ≤\n        Complex.abs (x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : ℕ))⁻¹) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : ℕ))⁻¹) / 2 :=\n      (add_le_add ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide)))\n        ((div_le_div_right (by norm_num)).2 (Complex.exp_bound (by simpa) (by decide))))\n    _ ≤ |x| ^ 4 * (5 / 96) := by\n      norm_num <;> simp [mul_assoc, mul_comm, mul_left_comm, mul_div_assoc]\n    \n#align real.sin_bound Real.sin_bound\n\n/- warning: real.cos_pos_of_le_one -> Real.cos_pos_of_le_one is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.hasNeg Real.hasSup) x) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.cos x))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (Abs.abs.{0} Real (Neg.toHasAbs.{0} Real Real.instNegReal Real.instSupReal) x) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.cos x))\nCase conversion may be inaccurate. Consider using '#align real.cos_pos_of_le_one Real.cos_pos_of_le_oneₓ'. -/\ntheorem cos_pos_of_le_one {x : ℝ} (hx : |x| ≤ 1) : 0 < cos x :=\n  calc\n    0 < 1 - x ^ 2 / 2 - |x| ^ 4 * (5 / 96) :=\n      sub_pos.2 <|\n        lt_sub_iff_add_lt.2\n          (calc\n            |x| ^ 4 * (5 / 96) + x ^ 2 / 2 ≤ 1 * (5 / 96) + 1 / 2 :=\n              add_le_add (mul_le_mul_of_nonneg_right (pow_le_one _ (abs_nonneg _) hx) (by norm_num))\n                ((div_le_div_right (by norm_num)).2\n                  (by\n                    rw [sq, ← abs_mul_self, _root_.abs_mul] <;>\n                      exact mul_le_one hx (abs_nonneg _) hx))\n            _ < 1 := by norm_num\n            )\n    _ ≤ cos x := sub_le_comm.1 (abs_sub_le_iff.1 (cos_bound hx)).2\n    \n#align real.cos_pos_of_le_one Real.cos_pos_of_le_one\n\n/- warning: real.sin_pos_of_pos_of_le_one -> Real.sin_pos_of_pos_of_le_one is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x) -> (LE.le.{0} Real Real.hasLe x (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.sin x))\nbut is expected to have type\n  forall {x : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x) -> (LE.le.{0} Real Real.instLEReal x (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.sin x))\nCase conversion may be inaccurate. Consider using '#align real.sin_pos_of_pos_of_le_one Real.sin_pos_of_pos_of_le_oneₓ'. -/\ntheorem sin_pos_of_pos_of_le_one {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 1) : 0 < sin x :=\n  calc\n    0 < x - x ^ 3 / 6 - |x| ^ 4 * (5 / 96) :=\n      sub_pos.2 <|\n        lt_sub_iff_add_lt.2\n          (calc\n            |x| ^ 4 * (5 / 96) + x ^ 3 / 6 ≤ x * (5 / 96) + x / 6 :=\n              add_le_add\n                (mul_le_mul_of_nonneg_right\n                  (calc\n                    |x| ^ 4 ≤ |x| ^ 1 :=\n                      pow_le_pow_of_le_one (abs_nonneg _)\n                        (by rwa [_root_.abs_of_nonneg (le_of_lt hx0)]) (by decide)\n                    _ = x := by simp [_root_.abs_of_nonneg (le_of_lt hx0)]\n                    )\n                  (by norm_num))\n                ((div_le_div_right (by norm_num)).2\n                  (calc\n                    x ^ 3 ≤ x ^ 1 := pow_le_pow_of_le_one (le_of_lt hx0) hx (by decide)\n                    _ = x := pow_one _\n                    ))\n            _ < x := by linarith\n            )\n    _ ≤ sin x :=\n      sub_le_comm.1 (abs_sub_le_iff.1 (sin_bound (by rwa [_root_.abs_of_nonneg (le_of_lt hx0)]))).2\n    \n#align real.sin_pos_of_pos_of_le_one Real.sin_pos_of_pos_of_le_one\n\n/- warning: real.sin_pos_of_pos_of_le_two -> Real.sin_pos_of_pos_of_le_two is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x) -> (LE.le.{0} Real Real.hasLe x (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) -> (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.sin x))\nbut is expected to have type\n  forall {x : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x) -> (LE.le.{0} Real Real.instLEReal x (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) -> (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.sin x))\nCase conversion may be inaccurate. Consider using '#align real.sin_pos_of_pos_of_le_two Real.sin_pos_of_pos_of_le_twoₓ'. -/\ntheorem sin_pos_of_pos_of_le_two {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 2) : 0 < sin x :=\n  have : x / 2 ≤ 1 := (div_le_iff (by norm_num)).mpr (by simpa)\n  calc\n    0 < 2 * sin (x / 2) * cos (x / 2) :=\n      mul_pos (mul_pos (by norm_num) (sin_pos_of_pos_of_le_one (half_pos hx0) this))\n        (cos_pos_of_le_one (by rwa [_root_.abs_of_nonneg (le_of_lt (half_pos hx0))]))\n    _ = sin x := by rw [← sin_two_mul, two_mul, add_halves]\n    \n#align real.sin_pos_of_pos_of_le_two Real.sin_pos_of_pos_of_le_two\n\n/- warning: real.cos_one_le -> Real.cos_one_le is a dubious translation:\nlean 3 declaration is\n  LE.le.{0} Real Real.hasLe (Real.cos (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne)))) (OfNat.ofNat.{0} Real 3 (OfNat.mk.{0} Real 3 (bit1.{0} Real Real.hasOne Real.hasAdd (One.one.{0} Real Real.hasOne)))))\nbut is expected to have type\n  LE.le.{0} Real Real.instLEReal (Real.cos (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (OfNat.ofNat.{0} Real 3 (instOfNat.{0} Real 3 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))))))\nCase conversion may be inaccurate. Consider using '#align real.cos_one_le Real.cos_one_leₓ'. -/\ntheorem cos_one_le : cos 1 ≤ 2 / 3 :=\n  calc\n    cos 1 ≤ |(1 : ℝ)| ^ 4 * (5 / 96) + (1 - 1 ^ 2 / 2) :=\n      sub_le_iff_le_add.1 (abs_sub_le_iff.1 (cos_bound (by simp))).1\n    _ ≤ 2 / 3 := by norm_num\n    \n#align real.cos_one_le Real.cos_one_le\n\n/- warning: real.cos_one_pos -> Real.cos_one_pos is a dubious translation:\nlean 3 declaration is\n  LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) (Real.cos (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))))\nbut is expected to have type\n  LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) (Real.cos (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)))\nCase conversion may be inaccurate. Consider using '#align real.cos_one_pos Real.cos_one_posₓ'. -/\ntheorem cos_one_pos : 0 < cos 1 :=\n  cos_pos_of_le_one (le_of_eq abs_one)\n#align real.cos_one_pos Real.cos_one_pos\n\n/- warning: real.cos_two_neg -> Real.cos_two_neg is a dubious translation:\nlean 3 declaration is\n  LT.lt.{0} Real Real.hasLt (Real.cos (OfNat.ofNat.{0} Real 2 (OfNat.mk.{0} Real 2 (bit0.{0} Real Real.hasAdd (One.one.{0} Real Real.hasOne))))) (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))\nbut is expected to have type\n  LT.lt.{0} Real Real.instLTReal (Real.cos (OfNat.ofNat.{0} Real 2 (instOfNat.{0} Real 2 Real.natCast (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))\nCase conversion may be inaccurate. Consider using '#align real.cos_two_neg Real.cos_two_negₓ'. -/\ntheorem cos_two_neg : cos 2 < 0 :=\n  calc\n    cos 2 = cos (2 * 1) := congr_arg cos (mul_one _).symm\n    _ = _ := (Real.cos_two_mul 1)\n    _ ≤ 2 * (2 / 3) ^ 2 - 1 :=\n      (sub_le_sub_right\n        (mul_le_mul_of_nonneg_left\n          (by\n            rw [sq, sq]\n            exact mul_self_le_mul_self (le_of_lt cos_one_pos) cos_one_le)\n          zero_le_two)\n        _)\n    _ < 0 := by norm_num\n    \n#align real.cos_two_neg Real.cos_two_neg\n\ntheorem exp_bound_div_one_sub_of_interval_approx {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) :\n    (∑ j : ℕ in Finset.range 3, x ^ j / j.factorial) +\n        x ^ 3 * ((3 : ℕ) + 1) / ((3 : ℕ).factorial * (3 : ℕ)) ≤\n      ∑ j in Finset.range 3, x ^ j :=\n  by\n  norm_num [Finset.sum]\n  rw [add_assoc, add_comm (x + 1) (x ^ 3 * 4 / 18), ← add_assoc, add_le_add_iff_right, ←\n    add_le_add_iff_left (-(x ^ 2 / 2)), ← add_assoc, CommRing.add_left_neg (x ^ 2 / 2), zero_add,\n    neg_add_eq_sub, sub_half, sq, pow_succ, sq]\n  have i1 : x * 4 / 18 ≤ 1 / 2 := by linarith\n  have i2 : 0 ≤ x * 4 / 18 := by linarith\n  have i3 := mul_le_mul h1 h1 le_rfl h1\n  rw [MulZeroClass.zero_mul] at i3\n  have t := mul_le_mul le_rfl i1 i2 i3\n  rw [← mul_assoc]\n  rwa [mul_one_div, ← mul_div_assoc, ← mul_assoc] at t\n#align real.exp_bound_div_one_sub_of_interval_approx Real.exp_bound_div_one_sub_of_interval_approxₓ\n\n/- warning: real.exp_bound_div_one_sub_of_interval -> Real.exp_bound_div_one_sub_of_interval is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) x) -> (LT.lt.{0} Real Real.hasLt x (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) -> (LE.le.{0} Real Real.hasLe (Real.exp x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) x)))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) x) -> (LT.lt.{0} Real Real.instLTReal x (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) -> (LE.le.{0} Real Real.instLEReal (Real.exp x) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) x)))\nCase conversion may be inaccurate. Consider using '#align real.exp_bound_div_one_sub_of_interval Real.exp_bound_div_one_sub_of_intervalₓ'. -/\ntheorem exp_bound_div_one_sub_of_interval {x : ℝ} (h1 : 0 ≤ x) (h2 : x < 1) :\n    Real.exp x ≤ 1 / (1 - x) :=\n  haveI h : (∑ j in Finset.range 3, x ^ j) ≤ 1 / (1 - x) :=\n    by\n    norm_num [Finset.sum]\n    have h1x : 0 < 1 - x := by simpa\n    rw [le_div_iff h1x]\n    norm_num [← add_assoc, mul_sub_left_distrib, mul_one, add_mul, sub_add_eq_sub_sub,\n      pow_succ' x 2]\n    have hx3 : 0 ≤ x ^ 3 := by\n      norm_num\n      exact h1\n    linarith\n  (exp_bound' h1 h2.le <| by linarith).trans\n    ((exp_bound_div_one_sub_of_interval_approx h1 h2.le).trans h)\n#align real.exp_bound_div_one_sub_of_interval Real.exp_bound_div_one_sub_of_interval\n\n/- warning: real.one_sub_le_exp_minus_of_pos -> Real.one_sub_le_exp_minus_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {y : Real}, (LE.le.{0} Real Real.hasLe (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) y) -> (LE.le.{0} Real Real.hasLe (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) y) (Real.exp (Neg.neg.{0} Real Real.hasNeg y)))\nbut is expected to have type\n  forall {y : Real}, (LE.le.{0} Real Real.instLEReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) y) -> (LE.le.{0} Real Real.instLEReal (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) y) (Real.exp (Neg.neg.{0} Real Real.instNegReal y)))\nCase conversion may be inaccurate. Consider using '#align real.one_sub_le_exp_minus_of_pos Real.one_sub_le_exp_minus_of_posₓ'. -/\ntheorem one_sub_le_exp_minus_of_pos {y : ℝ} (h : 0 ≤ y) : 1 - y ≤ Real.exp (-y) :=\n  by\n  rw [Real.exp_neg]\n  have r1 : (1 - y) * Real.exp y ≤ 1 :=\n    by\n    cases le_or_lt (1 - y) 0\n    · have h'' : (1 - y) * y.exp ≤ 0 := by\n        rw [mul_nonpos_iff]\n        right\n        exact ⟨h_1, y.exp_pos.le⟩\n      linarith\n    have hy1 : y < 1 := by linarith\n    rw [← le_div_iff' h_1]\n    exact exp_bound_div_one_sub_of_interval h hy1\n  rw [inv_eq_one_div]\n  rw [le_div_iff' y.exp_pos]\n  rwa [mul_comm] at r1\n#align real.one_sub_le_exp_minus_of_pos Real.one_sub_le_exp_minus_of_pos\n\n/- warning: real.add_one_le_exp_of_nonpos -> Real.add_one_le_exp_of_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {x : Real}, (LE.le.{0} Real Real.hasLe x (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero)))) -> (LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Real.exp x))\nbut is expected to have type\n  forall {x : Real}, (LE.le.{0} Real Real.instLEReal x (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal))) -> (LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Real.exp x))\nCase conversion may be inaccurate. Consider using '#align real.add_one_le_exp_of_nonpos Real.add_one_le_exp_of_nonposₓ'. -/\ntheorem add_one_le_exp_of_nonpos {x : ℝ} (h : x ≤ 0) : x + 1 ≤ Real.exp x :=\n  by\n  rw [add_comm]\n  have h1 : 0 ≤ -x := by linarith\n  simpa using one_sub_le_exp_minus_of_pos h1\n#align real.add_one_le_exp_of_nonpos Real.add_one_le_exp_of_nonpos\n\n/- warning: real.add_one_le_exp -> Real.add_one_le_exp is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), LE.le.{0} Real Real.hasLe (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.hasAdd) x (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))) (Real.exp x)\nbut is expected to have type\n  forall (x : Real), LE.le.{0} Real Real.instLEReal (HAdd.hAdd.{0, 0, 0} Real Real Real (instHAdd.{0} Real Real.instAddReal) x (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal))) (Real.exp x)\nCase conversion may be inaccurate. Consider using '#align real.add_one_le_exp Real.add_one_le_expₓ'. -/\ntheorem add_one_le_exp (x : ℝ) : x + 1 ≤ Real.exp x :=\n  by\n  cases le_or_lt 0 x\n  · exact Real.add_one_le_exp_of_nonneg h\n  exact add_one_le_exp_of_nonpos h.le\n#align real.add_one_le_exp Real.add_one_le_exp\n\n/- warning: real.one_sub_div_pow_le_exp_neg -> Real.one_sub_div_pow_le_exp_neg is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {t : Real}, (LE.le.{0} Real Real.hasLe t ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n)) -> (LE.le.{0} Real Real.hasLe (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.monoid)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne))) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (DivInvMonoid.toHasDiv.{0} Real (DivisionRing.toDivInvMonoid.{0} Real Real.divisionRing))) t ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Real (HasLiftT.mk.{1, 1} Nat Real (CoeTCₓ.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) n))) n) (Real.exp (Neg.neg.{0} Real Real.hasNeg t)))\nbut is expected to have type\n  forall {n : Nat} {t : Real}, (LE.le.{0} Real Real.instLEReal t (Nat.cast.{0} Real Real.natCast n)) -> (LE.le.{0} Real Real.instLEReal (HPow.hPow.{0, 0, 0} Real Nat Real (instHPow.{0, 0} Real Nat (Monoid.Pow.{0} Real Real.instMonoidReal)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (OfNat.ofNat.{0} Real 1 (One.toOfNat1.{0} Real Real.instOneReal)) (HDiv.hDiv.{0, 0, 0} Real Real Real (instHDiv.{0} Real (LinearOrderedField.toDiv.{0} Real Real.instLinearOrderedFieldReal)) t (Nat.cast.{0} Real Real.natCast n))) n) (Real.exp (Neg.neg.{0} Real Real.instNegReal t)))\nCase conversion may be inaccurate. Consider using '#align real.one_sub_div_pow_le_exp_neg Real.one_sub_div_pow_le_exp_negₓ'. -/\ntheorem one_sub_div_pow_le_exp_neg {n : ℕ} {t : ℝ} (ht' : t ≤ n) : (1 - t / n) ^ n ≤ exp (-t) :=\n  by\n  rcases eq_or_ne n 0 with (rfl | hn)\n  · simp\n    rwa [Nat.cast_zero] at ht'\n  convert pow_le_pow_of_le_left _ (add_one_le_exp (-(t / n))) n\n  · abel\n  · rw [← Real.exp_nat_mul]\n    congr 1\n    field_simp [nat.cast_ne_zero.mpr hn]\n    ring\n  · rwa [add_comm, ← sub_eq_add_neg, sub_nonneg, div_le_one]\n    positivity\n#align real.one_sub_div_pow_le_exp_neg Real.one_sub_div_pow_le_exp_neg\n\nend Real\n\nnamespace Tactic\n\nopen Positivity Real\n\n/-- Extension for the `positivity` tactic: `real.exp` is always positive. -/\n@[positivity]\nunsafe def positivity_exp : expr → tactic strictness\n  | q(Real.exp $(a)) => positive <$> mk_app `real.exp_pos [a]\n  | e => pp e >>= fail ∘ format.bracket \"The expression `\" \"` isn't of the form `real.exp r`\"\n#align tactic.positivity_exp tactic.positivity_exp\n\nend Tactic\n\nnamespace Complex\n\n/- warning: complex.abs_cos_add_sin_mul_I -> Complex.abs_cos_add_sin_mul_I is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.hasAdd) (Complex.cos ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) (Complex.sin ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x)) Complex.I))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), Eq.{1} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos (Complex.ofReal' x)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (Complex.ofReal' x)) Complex.I))) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos (Complex.ofReal' x)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (Complex.ofReal' x)) Complex.I))) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos (Complex.ofReal' x)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (Complex.ofReal' x)) Complex.I))) 1 (One.toOfNat1.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (HAdd.hAdd.{0, 0, 0} Complex Complex Complex (instHAdd.{0} Complex Complex.instAddComplex) (Complex.cos (Complex.ofReal' x)) (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.sin (Complex.ofReal' x)) Complex.I))) Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align complex.abs_cos_add_sin_mul_I Complex.abs_cos_add_sin_mul_Iₓ'. -/\n@[simp]\ntheorem abs_cos_add_sin_mul_I (x : ℝ) : abs (cos x + sin x * I) = 1 :=\n  by\n  have := Real.sin_sq_add_cos_sq x\n  simp_all [add_comm, abs, norm_sq, sq, sin_of_real_re, cos_of_real_re, mul_re]\n#align complex.abs_cos_add_sin_mul_I Complex.abs_cos_add_sin_mul_I\n\n/- warning: complex.abs_exp_of_real -> Complex.abs_exp_ofReal is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (Complex.exp ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x))) (Real.exp x)\nbut is expected to have type\n  forall (x : Real), Eq.{1} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (Complex.exp (Complex.ofReal' x))) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (Complex.exp (Complex.ofReal' x))) (Real.exp x)\nCase conversion may be inaccurate. Consider using '#align complex.abs_exp_of_real Complex.abs_exp_ofRealₓ'. -/\n@[simp]\ntheorem abs_exp_ofReal (x : ℝ) : abs (exp x) = Real.exp x := by\n  rw [← of_real_exp] <;> exact abs_of_nonneg (le_of_lt (Real.exp_pos _))\n#align complex.abs_exp_of_real Complex.abs_exp_ofReal\n\n/- warning: complex.abs_exp_of_real_mul_I -> Complex.abs_exp_ofReal_mul_I is a dubious translation:\nlean 3 declaration is\n  forall (x : Real), Eq.{1} Real (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Real Complex (HasLiftT.mk.{1, 1} Real Complex (CoeTCₓ.coe.{1, 1} Real Complex (coeBase.{1, 1} Real Complex Complex.hasCoe))) x) Complex.I))) (OfNat.ofNat.{0} Real 1 (OfNat.mk.{0} Real 1 (One.one.{0} Real Real.hasOne)))\nbut is expected to have type\n  forall (x : Real), Eq.{1} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.ofReal' x) Complex.I))) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.ofReal' x) Complex.I))) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.ofReal' x) Complex.I))) 1 (One.toOfNat1.{0} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (Complex.exp (HMul.hMul.{0, 0, 0} Complex Complex Complex (instHMul.{0} Complex Complex.instMulComplex) (Complex.ofReal' x) Complex.I))) Real.instOneReal))\nCase conversion may be inaccurate. Consider using '#align complex.abs_exp_of_real_mul_I Complex.abs_exp_ofReal_mul_Iₓ'. -/\n@[simp]\ntheorem abs_exp_ofReal_mul_I (x : ℝ) : abs (exp (x * I)) = 1 := by\n  rw [exp_mul_I, abs_cos_add_sin_mul_I]\n#align complex.abs_exp_of_real_mul_I Complex.abs_exp_ofReal_mul_I\n\n/- warning: complex.abs_exp -> Complex.abs_exp is a dubious translation:\nlean 3 declaration is\n  forall (z : Complex), Eq.{1} Real (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (Complex.exp z)) (Real.exp (Complex.re z))\nbut is expected to have type\n  forall (z : Complex), Eq.{1} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (Complex.exp z)) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (Complex.exp z)) (Real.exp (Complex.re z))\nCase conversion may be inaccurate. Consider using '#align complex.abs_exp Complex.abs_expₓ'. -/\ntheorem abs_exp (z : ℂ) : abs (exp z) = Real.exp z.re := by\n  rw [exp_eq_exp_re_mul_sin_add_cos, map_mul, abs_exp_of_real, abs_cos_add_sin_mul_I, mul_one]\n#align complex.abs_exp Complex.abs_exp\n\n/- warning: complex.abs_exp_eq_iff_re_eq -> Complex.abs_exp_eq_iff_re_eq is a dubious translation:\nlean 3 declaration is\n  forall {x : Complex} {y : Complex}, Iff (Eq.{1} Real (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (Complex.exp x)) (coeFn.{1, 1} (AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) (fun (f : AbsoluteValue.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) => Complex -> Real) (AbsoluteValue.hasCoeToFun.{0, 0} Complex Real (Ring.toSemiring.{0} Complex Complex.ring) Real.orderedSemiring) Complex.abs (Complex.exp y))) (Eq.{1} Real (Complex.re x) (Complex.re y))\nbut is expected to have type\n  forall {x : Complex} {y : Complex}, Iff (Eq.{1} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) (Complex.exp x)) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (Complex.exp x)) (FunLike.coe.{1, 1, 1} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex (fun (f : Complex) => (fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : Complex) => Real) f) (SubadditiveHomClass.toFunLike.{0, 0, 0} (AbsoluteValue.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring) Complex Real (Distrib.toAdd.{0} Complex (NonUnitalNonAssocSemiring.toDistrib.{0} Complex (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Complex (Semiring.toNonAssocSemiring.{0} Complex (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))))))) (Distrib.toAdd.{0} Real (NonUnitalNonAssocSemiring.toDistrib.{0} Real (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Real (Semiring.toNonAssocSemiring.{0} Real (OrderedSemiring.toSemiring.{0} Real Real.orderedSemiring))))) (Preorder.toLE.{0} Real (PartialOrder.toPreorder.{0} Real (OrderedSemiring.toPartialOrder.{0} Real Real.orderedSemiring))) (AbsoluteValue.subadditiveHomClass.{0, 0} Complex Real (DivisionSemiring.toSemiring.{0} Complex (Semifield.toDivisionSemiring.{0} Complex (Field.toSemifield.{0} Complex Complex.instFieldComplex))) Real.orderedSemiring)) Complex.abs (Complex.exp y))) (Eq.{1} Real (Complex.re x) (Complex.re y))\nCase conversion may be inaccurate. Consider using '#align complex.abs_exp_eq_iff_re_eq Complex.abs_exp_eq_iff_re_eqₓ'. -/\ntheorem abs_exp_eq_iff_re_eq {x y : ℂ} : abs (exp x) = abs (exp y) ↔ x.re = y.re := by\n  rw [abs_exp, abs_exp, Real.exp_eq_exp]\n#align complex.abs_exp_eq_iff_re_eq Complex.abs_exp_eq_iff_re_eq\n\nend Complex\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Data/Complex/Exponential.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.45331583119508095}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.sites.canonical\nimport Mathlib.category_theory.sites.sheaf_of_types\nimport Mathlib.PostPort\n\nuniverses u u_1 \n\nnamespace Mathlib\n\n/-!\n# Grothendieck Topology and Sheaves on the Category of Types\n\nIn this file we define a Grothendieck topology on the category of types,\nand construct the canonical functor that sends a type to a sheaf over\nthe category of types, and make this an equivalence of categories.\n\nThen we prove that the topology defined is the canonical topology.\n-/\n\nnamespace category_theory\n\n\n/-- A Grothendieck topology associated to the category of all types.\nA sieve is a covering iff it is jointly surjective. -/\ndef types_grothendieck_topology : grothendieck_topology (Type u) :=\n  grothendieck_topology.mk\n    (fun (α : Type u) (S : sieve α) => ∀ (x : α), coe_fn S PUnit fun (_x : PUnit) => x) sorry sorry\n    sorry\n\n/-- The discrete sieve on a type, which only includes arrows whose image is a subsingleton. -/\n@[simp] theorem discrete_sieve_apply (α : Type u) (β : Type u) (f : β ⟶ α) :\n    coe_fn (discrete_sieve α) β f = ∃ (x : α), ∀ (y : β), f y = x :=\n  Eq.refl (coe_fn (discrete_sieve α) β f)\n\ntheorem discrete_sieve_mem (α : Type u) : discrete_sieve α ∈ coe_fn types_grothendieck_topology α :=\n  fun (x : α) => Exists.intro x fun (y : PUnit) => rfl\n\n/-- The discrete presieve on a type, which only includes arrows whose domain is a singleton. -/\ndef discrete_presieve (α : Type u) : presieve α :=\n  fun (β : Type u) (f : β ⟶ α) => ∃ (x : β), ∀ (y : β), y = x\n\ntheorem generate_discrete_presieve_mem (α : Type u) :\n    sieve.generate (discrete_presieve α) ∈ coe_fn types_grothendieck_topology α :=\n  sorry\n\ntheorem is_sheaf_yoneda' {α : Type u} :\n    presieve.is_sheaf types_grothendieck_topology (functor.obj yoneda α) :=\n  sorry\n\n/-- The yoneda functor that sends a type to a sheaf over the category of types -/\n@[simp] theorem yoneda'_map (α : Type u) (β : Type u) (f : α ⟶ β) :\n    functor.map yoneda' f = functor.map yoneda f :=\n  Eq.refl (functor.map yoneda' f)\n\n@[simp] theorem yoneda'_comp : yoneda' ⋙ induced_functor subtype.val = yoneda := rfl\n\n/-- Given a presheaf `P` on the category of types, construct\na map `P(α) → (α → P(*))` for all type `α`. -/\ndef eval (P : Type uᵒᵖ ⥤ Type u) (α : Type u) (s : functor.obj P (opposite.op α)) (x : α) :\n    functor.obj P (opposite.op PUnit) :=\n  functor.map P (has_hom.hom.op (↾fun (_x : PUnit) => x)) s\n\n/-- Given a sheaf `S` on the category of types, construct a map\n`(α → S(*)) → S(α)` that is inverse to `eval`. -/\ndef types_glue (S : Type uᵒᵖ ⥤ Type u) (hs : presieve.is_sheaf types_grothendieck_topology S)\n    (α : Type u) (f : α → functor.obj S (opposite.op PUnit)) : functor.obj S (opposite.op α) :=\n  presieve.is_sheaf_for.amalgamate sorry\n    (fun (β : Type u) (g : β ⟶ α) (hg : discrete_presieve α g) =>\n      functor.map S (has_hom.hom.op (↾fun (x : β) => PUnit.unit)) (f (g (classical.some hg))))\n    sorry\n\ntheorem eval_types_glue {S : Type uᵒᵖ ⥤ Type u}\n    {hs : presieve.is_sheaf types_grothendieck_topology S} {α : Type u}\n    (f : α → functor.obj S (opposite.op PUnit)) : eval S α (types_glue S hs α f) = f :=\n  sorry\n\ntheorem types_glue_eval {S : Type uᵒᵖ ⥤ Type u}\n    {hs : presieve.is_sheaf types_grothendieck_topology S} {α : Type u}\n    (s : functor.obj S (opposite.op α)) : types_glue S hs α (eval S α s) = s :=\n  sorry\n\n/-- Given a sheaf `S`, construct an equivalence `S(α) ≃ (α → S(*))`. -/\ndef eval_equiv (S : Type uᵒᵖ ⥤ Type u) (hs : presieve.is_sheaf types_grothendieck_topology S)\n    (α : Type u) : functor.obj S (opposite.op α) ≃ (α → functor.obj S (opposite.op PUnit)) :=\n  equiv.mk (eval S α) (types_glue S hs α) types_glue_eval eval_types_glue\n\ntheorem eval_map (S : Type uᵒᵖ ⥤ Type u) (α : Type u) (β : Type u) (f : β ⟶ α)\n    (s : functor.obj S (opposite.op α)) (x : β) :\n    eval S β (functor.map S (has_hom.hom.op f) s) x = eval S α s (f x) :=\n  sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S ≅ [-, S(*)]`. -/\ndef equiv_yoneda (S : Type uᵒᵖ ⥤ Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) :\n    S ≅ functor.obj yoneda (functor.obj S (opposite.op PUnit)) :=\n  nat_iso.of_components (fun (α : Type uᵒᵖ) => equiv.to_iso (eval_equiv S hs (opposite.unop α)))\n    sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S ≅ [-, S(*)]`. -/\n@[simp] theorem equiv_yoneda'_inv (S : SheafOfTypes types_grothendieck_topology) :\n    iso.inv (equiv_yoneda' S) = iso.inv (equiv_yoneda (subtype.val S) (equiv_yoneda'._proof_1 S)) :=\n  Eq.refl (iso.inv (equiv_yoneda' S))\n\ntheorem eval_app (S₁ : SheafOfTypes types_grothendieck_topology)\n    (S₂ : SheafOfTypes types_grothendieck_topology) (f : S₁ ⟶ S₂) (α : Type u)\n    (s : functor.obj (subtype.val S₁) (opposite.op α)) (x : α) :\n    eval (subtype.val S₂) α (nat_trans.app f (opposite.op α) s) x =\n        nat_trans.app f (opposite.op PUnit) (eval (subtype.val S₁) α s x) :=\n  Eq.symm (congr_fun (nat_trans.naturality' f (has_hom.hom.op (↾fun (_x : PUnit) => x))) s)\n\n/-- `yoneda'` induces an equivalence of category between `Type u` and\n`Sheaf types_grothendieck_topology`. -/\n@[simp] theorem type_equiv_inverse_obj (X : SheafOfTypes types_grothendieck_topology) :\n    functor.obj (equivalence.inverse type_equiv) X = functor.obj (↑X) (opposite.op PUnit) :=\n  Eq.refl (functor.obj (↑X) (opposite.op PUnit))\n\ntheorem subcanonical_types_grothendieck_topology : sheaf.subcanonical types_grothendieck_topology :=\n  sheaf.subcanonical.of_yoneda_is_sheaf types_grothendieck_topology\n    fun (X : Type u) => is_sheaf_yoneda'\n\ntheorem types_grothendieck_topology_eq_canonical :\n    types_grothendieck_topology = sheaf.canonical_topology (Type u) :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/sites/types_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833945721305, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.4532096381908104}}
{"text": "import tactic.default\n\ntheorem addition_of_natural_numbers_is_commutative (m n : ℕ) :\n  m + n = n + m :=\nbegin\n  induction n with d hd,\n  {\n    ring,\n  },\n  {\n    ring,\n  }\nend", "meta": {"author": "Nicknamen", "repo": "lie_group", "sha": "e0d5c4f859654e3dea092702f1320c3c72a49983", "save_path": "github-repos/lean/Nicknamen-lie_group", "path": "github-repos/lean/Nicknamen-lie_group/lie_group-e0d5c4f859654e3dea092702f1320c3c72a49983/src/addition.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4531569018106638}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nA data type for semiquotients, which are classically equivalent to\nnonempty sets, but are useful for programming; the idea is that\na semiquotient set `S` represents some (particular but unknown)\nelement of `S`. This can be used to model nondeterministic functions,\nwhich return something in a range of values (represented by the\npredicate `S`) but are not completely determined.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.set.lattice\nimport Mathlib.PostPort\n\nuniverses u u_1 l u_2 u_3 u_4 u_5 \n\nnamespace Mathlib\n\n/-- A member of `semiquot α` is classically a nonempty `set α`,\n  and in the VM is represented by an element of `α`; the relation\n  between these is that the VM element is required to be a member\n  of the set `s`. The specific element of `s` that the VM computes\n  is hidden by a quotient construction, allowing for the representation\n  of nondeterministic functions. -/\nstructure semiquot (α : Type u_1) \n  mk' ::\nwhere (s : set α) (val : trunc ↥s)\n\nnamespace semiquot\n\n\nprotected instance has_mem {α : Type u_1} : has_mem α (semiquot α) :=\n  has_mem.mk fun (a : α) (q : semiquot α) => a ∈ s q\n\n/-- Construct a `semiquot α` from `h : a ∈ s` where `s : set α`. -/\ndef mk {α : Type u_1} {a : α} {s : set α} (h : a ∈ s) : semiquot α :=\n  mk' s (trunc.mk { val := a, property := h })\n\ntheorem ext_s {α : Type u_1} {q₁ : semiquot α} {q₂ : semiquot α} : q₁ = q₂ ↔ s q₁ = s q₂ := sorry\n\ntheorem ext {α : Type u_1} {q₁ : semiquot α} {q₂ : semiquot α} : q₁ = q₂ ↔ ∀ (a : α), a ∈ q₁ ↔ a ∈ q₂ :=\n  iff.trans ext_s set.ext_iff\n\ntheorem exists_mem {α : Type u_1} (q : semiquot α) : ∃ (a : α), a ∈ q := sorry\n\ntheorem eq_mk_of_mem {α : Type u_1} {q : semiquot α} {a : α} (h : a ∈ q) : q = mk h :=\n  iff.mpr ext_s rfl\n\ntheorem nonempty {α : Type u_1} (q : semiquot α) : set.nonempty (s q) :=\n  exists_mem q\n\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure {α : Type u_1} (a : α) : semiquot α :=\n  mk (set.mem_singleton a)\n\n@[simp] theorem mem_pure' {α : Type u_1} {a : α} {b : α} : a ∈ semiquot.pure b ↔ a = b :=\n  set.mem_singleton_iff\n\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' {α : Type u_1} (q : semiquot α) {s : set α} (h : s q ⊆ s) : semiquot α :=\n  mk' s (trunc.lift (fun (a : ↥(s q)) => trunc.mk { val := subtype.val a, property := sorry }) sorry (val q))\n\n/-- Replace `s` in a `q : semiquot α` with a union `s ∪ q.s` -/\ndef blur {α : Type u_1} (s : set α) (q : semiquot α) : semiquot α :=\n  blur' q sorry\n\ntheorem blur_eq_blur' {α : Type u_1} (q : semiquot α) (s : set α) (h : s q ⊆ s) : blur s q = blur' q h := sorry\n\n@[simp] theorem mem_blur' {α : Type u_1} (q : semiquot α) {s : set α} (h : s q ⊆ s) {a : α} : a ∈ blur' q h ↔ a ∈ s :=\n  iff.rfl\n\n/-- Convert a `trunc α` to a `semiquot α`. -/\ndef of_trunc {α : Type u_1} (q : trunc α) : semiquot α :=\n  mk' set.univ (trunc.map (fun (a : α) => { val := a, property := trivial }) q)\n\n/-- Convert a `semiquot α` to a `trunc α`. -/\ndef to_trunc {α : Type u_1} (q : semiquot α) : trunc α :=\n  trunc.map subtype.val (val q)\n\n/-- If `f` is a constant on `q.s`, then `q.lift_on f` is the value of `f`\nat any point of `q`. -/\ndef lift_on {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → β) (h : ∀ (a b : α), a ∈ q → b ∈ q → f a = f b) : β :=\n  trunc.lift_on (val q) (fun (x : ↥(s q)) => f (subtype.val x)) sorry\n\ntheorem lift_on_of_mem {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → β) (h : ∀ (a b : α), a ∈ q → b ∈ q → f a = f b) (a : α) (aq : a ∈ q) : lift_on q f h = f a :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (∀ (h : ∀ (a b : α), a ∈ q → b ∈ q → f a = f b), lift_on q f h = f a)) (eq_mk_of_mem aq)))\n    (fun (h : ∀ (a_1 b : α), a_1 ∈ mk aq → b ∈ mk aq → f a_1 = f b) => Eq.refl (lift_on (mk aq) f h)) h\n\ndef map {α : Type u_1} {β : Type u_2} (f : α → β) (q : semiquot α) : semiquot β :=\n  mk' (f '' s q) (trunc.map (fun (x : ↥(s q)) => { val := f (subtype.val x), property := sorry }) (val q))\n\n@[simp] theorem mem_map {α : Type u_1} {β : Type u_2} (f : α → β) (q : semiquot α) (b : β) : b ∈ map f q ↔ ∃ (a : α), a ∈ q ∧ f a = b :=\n  set.mem_image (fun (a : α) => f a) (s q) b\n\ndef bind {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → semiquot β) : semiquot β :=\n  mk' (set.Union fun (a : α) => set.Union fun (H : a ∈ s q) => s (f a))\n    (trunc.bind (val q)\n      fun (a : ↥(s q)) =>\n        trunc.map (fun (b : ↥(s (f (subtype.val a)))) => { val := subtype.val b, property := sorry })\n          (val (f (subtype.val a))))\n\n@[simp] theorem mem_bind {α : Type u_1} {β : Type u_2} (q : semiquot α) (f : α → semiquot β) (b : β) : b ∈ bind q f ↔ ∃ (a : α), ∃ (H : a ∈ q), b ∈ f a :=\n  set.mem_bUnion_iff\n\nprotected instance monad : Monad semiquot :=\n  { toApplicative :=\n      { toFunctor := { map := map, mapConst := fun (α β : Type u_1) => map ∘ function.const β },\n        toPure := { pure := semiquot.pure },\n        toSeq :=\n          { seq := fun (α β : Type u_1) (f : semiquot (α → β)) (x : semiquot α) => bind f fun (_x : α → β) => map _x x },\n        toSeqLeft :=\n          { seqLeft :=\n              fun (α β : Type u_1) (a : semiquot α) (b : semiquot β) =>\n                (fun (α β : Type u_1) (f : semiquot (α → β)) (x : semiquot α) => bind f fun (_x : α → β) => map _x x) β α\n                  (map (function.const β) a) b },\n        toSeqRight :=\n          { seqRight :=\n              fun (α β : Type u_1) (a : semiquot α) (b : semiquot β) =>\n                (fun (α β : Type u_1) (f : semiquot (α → β)) (x : semiquot α) => bind f fun (_x : α → β) => map _x x) β β\n                  (map (function.const α id) a) b } },\n    toBind := { bind := bind } }\n\n@[simp] theorem map_def {α : Type u_1} {β : Type u_1} : Functor.map = map :=\n  rfl\n\n@[simp] theorem bind_def {α : Type u_1} {β : Type u_1} : bind = bind :=\n  rfl\n\n@[simp] theorem mem_pure {α : Type u_1} {a : α} {b : α} : a ∈ pure b ↔ a = b :=\n  set.mem_singleton_iff\n\ntheorem mem_pure_self {α : Type u_1} (a : α) : a ∈ pure a :=\n  set.mem_singleton a\n\n@[simp] theorem pure_inj {α : Type u_1} {a : α} {b : α} : pure a = pure b ↔ a = b :=\n  iff.trans ext_s set.singleton_eq_singleton_iff\n\nprotected instance is_lawful_monad : is_lawful_monad semiquot := sorry\n\nprotected instance has_le {α : Type u_1} : HasLessEq (semiquot α) :=\n  { LessEq := fun (s t : semiquot α) => s s ⊆ s t }\n\nprotected instance partial_order {α : Type u_1} : partial_order (semiquot α) :=\n  partial_order.mk (fun (s t : semiquot α) => ∀ {x : α}, x ∈ s → x ∈ t)\n    (preorder.lt._default fun (s t : semiquot α) => ∀ {x : α}, x ∈ s → x ∈ t) sorry sorry sorry\n\nprotected instance semilattice_sup {α : Type u_1} : semilattice_sup (semiquot α) :=\n  semilattice_sup.mk (fun (s : semiquot α) => blur (s s)) partial_order.le partial_order.lt sorry sorry sorry sorry sorry\n    sorry\n\n@[simp] theorem pure_le {α : Type u_1} {a : α} {s : semiquot α} : pure a ≤ s ↔ a ∈ s :=\n  set.singleton_subset_iff\n\ndef is_pure {α : Type u_1} (q : semiquot α) :=\n  ∀ (a b : α), a ∈ q → b ∈ q → a = b\n\ndef get {α : Type u_1} (q : semiquot α) (h : is_pure q) : α :=\n  lift_on q id h\n\ntheorem get_mem {α : Type u_1} {q : semiquot α} (p : is_pure q) : get q p ∈ q := sorry\n\ntheorem eq_pure {α : Type u_1} {q : semiquot α} (p : is_pure q) : q = pure (get q p) := sorry\n\n@[simp] theorem pure_is_pure {α : Type u_1} (a : α) : is_pure (pure a) :=\n  fun (a_1 b : α) (H : a_1 ∈ pure a) (H_1 : b ∈ pure a) =>\n    idRhs (a_1 = b)\n      (of_eq_true (eq_true_intro (Eq.trans (eq.mp (propext mem_pure) H) (Eq.symm (eq.mp (propext mem_pure) H_1)))))\n\ntheorem is_pure_iff {α : Type u_1} {s : semiquot α} : is_pure s ↔ ∃ (a : α), s = pure a := sorry\n\ntheorem is_pure.mono {α : Type u_1} {s : semiquot α} {t : semiquot α} (st : s ≤ t) (h : is_pure t) : is_pure s :=\n  fun (a b : α) (H : a ∈ s) (H_1 : b ∈ s) => idRhs (a = b) (h a b (st H) (st H_1))\n\ntheorem is_pure.min {α : Type u_1} {s : semiquot α} {t : semiquot α} (h : is_pure t) : s ≤ t ↔ s = t := sorry\n\ntheorem is_pure_of_subsingleton {α : Type u_1} [subsingleton α] (q : semiquot α) : is_pure q :=\n  fun (a b : α) (H : a ∈ q) (H : b ∈ q) => idRhs (a = b) (subsingleton.elim a b)\n\n/-- `univ : semiquot α` represents an unspecified element of `univ : set α`. -/\ndef univ {α : Type u_1} [Inhabited α] : semiquot α :=\n  mk sorry\n\nprotected instance inhabited {α : Type u_1} [Inhabited α] : Inhabited (semiquot α) :=\n  { default := univ }\n\n@[simp] theorem mem_univ {α : Type u_1} [Inhabited α] (a : α) : a ∈ univ :=\n  set.mem_univ\n\ntheorem univ_unique {α : Type u_1} (I : Inhabited α) (J : Inhabited α) : univ = univ := sorry\n\n@[simp] theorem is_pure_univ {α : Type u_1} [Inhabited α] : is_pure univ ↔ subsingleton α := sorry\n\nprotected instance order_top {α : Type u_1} [Inhabited α] : order_top (semiquot α) :=\n  order_top.mk univ partial_order.le partial_order.lt sorry sorry sorry sorry\n\nprotected instance semilattice_sup_top {α : Type u_1} [Inhabited α] : semilattice_sup_top (semiquot α) :=\n  semilattice_sup_top.mk order_top.top order_top.le order_top.lt sorry sorry sorry sorry semilattice_sup.sup sorry sorry\n    sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/semiquot.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.45315689190898106}}
{"text": "/-\nCopyright (c) 2020 Kenji Nakagawa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio\n-/\nimport ring_theory.dedekind_domain.basic\nimport ring_theory.trace\n\n/-!\n# Integral closure of Dedekind domains\n\nThis file shows the integral closure of a Dedekind domain (in particular, the ring of integers\nof a number field) is a Dedekind domain.\n\n## Implementation notes\n\nThe definitions that involve a field of fractions choose a canonical field of fractions,\nbut are independent of that choice. The `..._iff` lemmas express this independence.\n\nOften, definitions assume that Dedekind domains are not fields. We found it more practical\nto add a `(h : ¬ is_field A)` assumption whenever this is explicitly needed.\n\n## References\n\n* [D. Marcus, *Number Fields*][marcus1977number]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]\n\n## Tags\n\ndedekind domain, dedekind ring\n-/\n\nvariables (R A K : Type*) [comm_ring R] [comm_ring A] [field K]\n\nopen_locale non_zero_divisors polynomial\n\nvariables [is_domain A]\n\nsection is_integral_closure\n\n/-! ### `is_integral_closure` section\n\nWe show that an integral closure of a Dedekind domain in a finite separable\nfield extension is again a Dedekind domain. This implies the ring of integers\nof a number field is a Dedekind domain. -/\n\nopen algebra\nopen_locale big_operators\n\nvariables {A K} [algebra A K] [is_fraction_ring A K]\nvariables {L : Type*} [field L] (C : Type*) [comm_ring C]\nvariables [algebra K L] [finite_dimensional K L] [algebra A L] [is_scalar_tower A K L]\nvariables [algebra C L] [is_integral_closure C A L] [algebra A C] [is_scalar_tower A C L]\n\nlemma is_integral_closure.range_le_span_dual_basis [is_separable K L]\n  {ι : Type*} [fintype ι] [decidable_eq ι] (b : basis ι K L)\n  (hb_int : ∀ i, is_integral A (b i)) [is_integrally_closed A] :\n  ((algebra.linear_map C L).restrict_scalars A).range ≤\n    submodule.span A (set.range $ (trace_form K L).dual_basis (trace_form_nondegenerate K L) b) :=\nbegin\n  let db := (trace_form K L).dual_basis (trace_form_nondegenerate K L) b,\n  rintros _ ⟨x, rfl⟩,\n  simp only [linear_map.coe_restrict_scalars_eq_coe, algebra.linear_map_apply],\n  have hx : is_integral A (algebra_map C L x) :=\n    (is_integral_closure.is_integral A L x).algebra_map,\n  suffices : ∃ (c : ι → A), algebra_map C L x = ∑ i, c i • db i,\n  { obtain ⟨c, x_eq⟩ := this,\n    rw x_eq,\n    refine submodule.sum_mem _ (λ i _, submodule.smul_mem _ _ (submodule.subset_span _)),\n    rw set.mem_range,\n    exact ⟨i, rfl⟩ },\n  suffices : ∃ (c : ι → K), ((∀ i, is_integral A (c i)) ∧ algebra_map C L x = ∑ i, c i • db i),\n  { obtain ⟨c, hc, hx⟩ := this,\n    have hc' : ∀ i, is_localization.is_integer A (c i) :=\n      λ i, is_integrally_closed.is_integral_iff.mp (hc i),\n    use λ i, classical.some (hc' i),\n    refine hx.trans (finset.sum_congr rfl (λ i _, _)),\n    conv_lhs { rw [← classical.some_spec (hc' i)] },\n    rw [← is_scalar_tower.algebra_map_smul K (classical.some (hc' i)) (db i)] },\n  refine ⟨λ i, db.repr (algebra_map C L x) i, (λ i, _), (db.sum_repr _).symm⟩,\n  rw bilin_form.dual_basis_repr_apply,\n  exact is_integral_trace (is_integral_mul hx (hb_int i))\nend\n\nlemma integral_closure_le_span_dual_basis [is_separable K L]\n  {ι : Type*} [fintype ι] [decidable_eq ι] (b : basis ι K L)\n  (hb_int : ∀ i, is_integral A (b i)) [is_integrally_closed A] :\n  (integral_closure A L).to_submodule ≤ submodule.span A (set.range $\n    (trace_form K L).dual_basis (trace_form_nondegenerate K L) b) :=\nbegin\n  refine le_trans _ (is_integral_closure.range_le_span_dual_basis (integral_closure A L) b hb_int),\n  intros x hx,\n  exact ⟨⟨x, hx⟩, rfl⟩\nend\n\nvariables (A) (K)\n\ninclude K\n\n/-- Send a set of `x`'es in a finite extension `L` of the fraction field of `R`\nto `(y : R) • x ∈ integral_closure R L`. -/\nlemma exists_integral_multiples (s : finset L) :\n  ∃ (y ≠ (0 : A)), ∀ x ∈ s, is_integral A (y • x) :=\nbegin\n  haveI := classical.dec_eq L,\n  refine s.induction _ _,\n  { use [1, one_ne_zero],\n    rintros x ⟨⟩ },\n  { rintros x s hx ⟨y, hy, hs⟩,\n    obtain ⟨x', y', hy', hx'⟩ := exists_integral_multiple\n      ((is_fraction_ring.is_algebraic_iff A K L).mpr (is_algebraic_of_finite _ _ x))\n      ((injective_iff_map_eq_zero (algebra_map A L)).mp _),\n    refine ⟨y * y', mul_ne_zero hy hy', λ x'' hx'', _⟩,\n    rcases finset.mem_insert.mp hx'' with (rfl | hx''),\n    { rw [mul_smul, algebra.smul_def, algebra.smul_def, mul_comm _ x'', hx'],\n      exact is_integral_mul is_integral_algebra_map x'.2 },\n    { rw [mul_comm, mul_smul, algebra.smul_def],\n      exact is_integral_mul is_integral_algebra_map (hs _ hx'') },\n    { rw is_scalar_tower.algebra_map_eq A K L,\n      apply (algebra_map K L).injective.comp,\n      exact is_fraction_ring.injective _ _ } }\nend\n\nvariables (L)\n\n/-- If `L` is a finite extension of `K = Frac(A)`,\nthen `L` has a basis over `A` consisting of integral elements. -/\nlemma finite_dimensional.exists_is_basis_integral :\n  ∃ (s : finset L) (b : basis s K L), (∀ x, is_integral A (b x)) :=\nbegin\n  letI := classical.dec_eq L,\n  letI : is_noetherian K L := is_noetherian.iff_fg.2 infer_instance,\n  let s' := is_noetherian.finset_basis_index K L,\n  let bs' := is_noetherian.finset_basis K L,\n  obtain ⟨y, hy, his'⟩ := exists_integral_multiples A K (finset.univ.image bs'),\n  have hy' : algebra_map A L y ≠ 0,\n  { refine mt ((injective_iff_map_eq_zero (algebra_map A L)).mp _ _) hy,\n    rw is_scalar_tower.algebra_map_eq A K L,\n    exact (algebra_map K L).injective.comp (is_fraction_ring.injective A K) },\n  refine ⟨s', bs'.map { to_fun := λ x, algebra_map A L y * x,\n                        inv_fun := λ x, (algebra_map A L y)⁻¹ * x,\n                        left_inv := _,\n                        right_inv := _,\n                        .. algebra.lmul _ _ (algebra_map A L y) },\n          _⟩,\n  { intros x, simp only [inv_mul_cancel_left₀ hy'] },\n  { intros x, simp only [mul_inv_cancel_left₀ hy'] },\n  { rintros ⟨x', hx'⟩,\n    simp only [algebra.smul_def, finset.mem_image, exists_prop, finset.mem_univ, true_and] at his',\n    simp only [basis.map_apply, linear_equiv.coe_mk],\n    exact his' _ ⟨_, rfl⟩ }\nend\n\nvariables (A K L) [is_separable K L]\ninclude L\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is\nintegrally closed and Noetherian, the integral closure `C` of `A` in `L` is\nNoetherian. -/\nlemma is_integral_closure.is_noetherian_ring [is_integrally_closed A] [is_noetherian_ring A] :\n  is_noetherian_ring C :=\nbegin\n  haveI := classical.dec_eq L,\n  obtain ⟨s, b, hb_int⟩ := finite_dimensional.exists_is_basis_integral A K L,\n  rw is_noetherian_ring_iff,\n  let b' := (trace_form K L).dual_basis (trace_form_nondegenerate K L) b,\n  letI := is_noetherian_span_of_finite A (set.finite_range b'),\n  let f : C →ₗ[A] submodule.span A (set.range b') :=\n    (submodule.of_le (is_integral_closure.range_le_span_dual_basis C b hb_int)).comp\n    ((algebra.linear_map C L).restrict_scalars A).range_restrict,\n  refine is_noetherian_of_tower A (is_noetherian_of_ker_bot f _),\n  rw [linear_map.ker_comp, submodule.ker_of_le, submodule.comap_bot, linear_map.ker_cod_restrict],\n  exact linear_map.ker_eq_bot_of_injective (is_integral_closure.algebra_map_injective C A L)\nend\n\nvariables {A K}\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is\nintegrally closed and Noetherian, the integral closure of `A` in `L` is\nNoetherian. -/\nlemma integral_closure.is_noetherian_ring [is_integrally_closed A] [is_noetherian_ring A] :\n  is_noetherian_ring (integral_closure A L) :=\nis_integral_closure.is_noetherian_ring A K L (integral_closure A L)\n\nvariables (A K) [is_domain C]\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a Dedekind domain,\nthe integral closure `C` of `A` in `L` is a Dedekind domain.\n\nCan't be an instance since `A`, `K` or `L` can't be inferred. See also the instance\n`integral_closure.is_dedekind_domain_fraction_ring` where `K := fraction_ring A`\nand `C := integral_closure A L`.\n-/\nlemma is_integral_closure.is_dedekind_domain [h : is_dedekind_domain A] :\n  is_dedekind_domain C :=\nbegin\n  haveI : is_fraction_ring C L := is_integral_closure.is_fraction_ring_of_finite_extension A K L C,\n  exact\n  ⟨is_integral_closure.is_noetherian_ring A K L C,\n   h.dimension_le_one.is_integral_closure _ L _,\n   (is_integrally_closed_iff L).mpr (λ x hx, ⟨is_integral_closure.mk' C x\n      (is_integral_trans (is_integral_closure.is_integral_algebra A L) _ hx),\n    is_integral_closure.algebra_map_mk' _ _ _⟩)⟩\nend\n\n/- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a Dedekind domain,\nthe integral closure of `A` in `L` is a Dedekind domain.\n\nCan't be an instance since `K` can't be inferred. See also the instance\n`integral_closure.is_dedekind_domain_fraction_ring` where `K := fraction_ring A`.\n-/\nlemma integral_closure.is_dedekind_domain [h : is_dedekind_domain A] :\n  is_dedekind_domain (integral_closure A L) :=\nis_integral_closure.is_dedekind_domain A K L (integral_closure A L)\n\nomit K\n\nvariables [algebra (fraction_ring A) L] [is_scalar_tower A (fraction_ring A) L]\nvariables [finite_dimensional (fraction_ring A) L] [is_separable (fraction_ring A) L]\n\n/- If `L` is a finite separable extension of `Frac(A)`, where `A` is a Dedekind domain,\nthe integral closure of `A` in `L` is a Dedekind domain.\n\nSee also the lemma `integral_closure.is_dedekind_domain` where you can choose\nthe field of fractions yourself.\n-/\ninstance integral_closure.is_dedekind_domain_fraction_ring\n  [is_dedekind_domain A] : is_dedekind_domain (integral_closure A L) :=\nintegral_closure.is_dedekind_domain A (fraction_ring A) L\n\nend is_integral_closure\n", "meta": {"author": "lean-forward", "repo": "class-number-journal", "sha": "34d5872618d289ca3982bd9bc0c6e06af678909a", "save_path": "github-repos/lean/lean-forward-class-number-journal", "path": "github-repos/lean/lean-forward-class-number-journal/class-number-journal-34d5872618d289ca3982bd9bc0c6e06af678909a/src/dedekind_domain/integral_closure.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.727975460709318, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.45313511840448395}}
{"text": "import Mathlib.Algebra.Ring.Basic\nimport Mathlib.Data.Nat.Basic\nimport Mathlib.Data.Vector\nimport Mathlib.Data.Set.Basic\nimport Mathlib.Tactic.Set\nimport Mathlib.Tactic.Have\n\nimport Etch.Basic\nimport Etch.Op\n\nsection defs\n\nabbrev Addr := ℕ\nabbrev Val  := ℕ\nabbrev Ident := ℕ\ndef Heap  := Addr → Option ℕ\ninstance : EmptyCollection Heap := ⟨ fun _ ↦ none ⟩\ninstance : Membership (ℕ × Val) Heap where mem p s := s p.1 = some p.2\ninstance (a b : Type) : Membership (a × b) (a → Option b) where mem p s := s p.1 = some p.2\n\ndef dom [DecidableEq α] : (α → Option β) → Set α := fun h ↦ { n | ∃ v, h n = some v }\nlemma mem_dom_update [DecidableEq α] (h : α → Option β) : a ∈ dom (Function.update h a (some v)) := by simp [dom]\n\ninstance : Insert (Addr × ℕ) Heap := ⟨ fun p s ↦ Function.update s p.1 p.2 ⟩\ninstance : Singleton (Addr × ℕ) Heap := ⟨ fun p ↦ Function.update (∅ : Heap) p.1 p.2 ⟩\nnotation a \" ↦ \" b => (a, b)\n--notation:max h \"[\" x \" := \" y \"]\" => Function.update h x (some y)\n\nclass VariableType (Var : Type) where type : Var → Type\nattribute [reducible] VariableType.type\nopen VariableType\n\nvariable (V) [VariableType V] [DecidableEq V]\n\n@[ext]\nstructure TypedStore where\n  val : (v : V) → type v\n\nvariable {V}\n\ndef TypedStore.update (st : TypedStore V) (x : V) (y : type x) : TypedStore V :=\n⟨ Function.update st.val x y ⟩\n\nnotation:max h \"[\" x \" := \" y \"]\" => TypedStore.update h x y\n\n-- todo move\n@[simps]\ndef Op.nat (n : ℕ) : Op ℕ where\n  argTypes := ![]\n  spec := fun _ ↦ n\n  opName := \"nat_lit\"\n\nvariable (V)\ninductive E : Type → Type 1\n| call {α} (op : Op α) (args : (i : Fin op.arity) → E (op.argTypes i)) : E α\n| var    : (v : V) → E (type v)\n\nvariable {V}\ndef E.eval (st : TypedStore V) : {α : Type} → E V α → α\n| _, var v => st.val v\n| _, call op args => op.spec fun param ↦ (args param).eval st\n\n@[simp] theorem TypedStore.val_update_ne (x y : V) (v : type x) (l : TypedStore V) (h : x ≠ y) : (l[x := v]).val y = l.val y := by\n  simp [val, update, Function.update]\n  intro h'\n  exfalso\n  apply h h'.symm\n\n@[simp] theorem TypedStore.val_update_eq (x : V) (v : type x) (l : TypedStore V) [DecidableEq V] : (l[x := v]).val x = v := by\n  simp [update, Function.update]\n\nexample (x y : V)  (v : type x) (l : TypedStore V) [DecidableEq V] (h : x ≠ y) : (l[x := v]).val y = l.val y := by simp [h]\n\nvariable (st : TypedStore V)\n\n@[simp] theorem E.eval_nat : (E.call (.nat n) args).eval st = n := rfl\n@[simp] theorem E.eval_neg : (E.call .neg ![arg]).eval st = !arg.eval st := rfl -- by simp [E.eval]\n-- todo: this isn't automatically used by simp?\n@[simp] theorem E.asdf (a b : E V α) [Tagged α] [DecidableEq α] : E.eval l (E.call Op.eq ![a, b]) = decide (a.eval l = b.eval l) := rfl\n@[simp] theorem E.eval_lt {α} [Tagged α] [LT α] [DecidableRel (LT.lt : α → α → _) ] (a b : E V α) : (E.call .lt ![a, b]).eval st = true ↔ a.eval st < b.eval st := by simp [E.eval, Op.lt]\n@[simp] theorem E.eval_lt_false {α} [Tagged α] [LT α] [DecidableRel (LT.lt : α → α → _) ] (a b : E V α) : (E.call .lt ![a, b]).eval st = false ↔ ¬ (a.eval st < b.eval st) := by simp [E.eval, Op.lt]\n\nvariable (V)\n\ninductive P\n| store {α} (lval : E V ℕ) (rval : E V α)\n| load  (lval : E V ℕ) (y : V)\n| put (x : V) (e : E V (type x))\n| seq (c₁ c₂ : P) : P\n| while (c : E V Bool) (body : P)\n| skip\n@[match_pattern] infixr:25 \";; \" => P.seq\n\ndef TypedConfigSet := Heap → TypedStore V → Prop\n\nvariable {V}\n\nclass Representable (α : Type _) where\n  defines : α → Addr → Heap → Prop\n\nclass Storable (α : Type _) extends Representable α where\n  store : Heap → Addr → α → Heap\n  footprint : α → Addr → Set Addr\n  valid (h a v) : defines v a (store h a v)\n  frame (a loc v h) : a ∉ footprint v loc → (store h loc v) a = h a\n\ndef exprDefines [Representable α] : α → E V Addr → Heap → TypedStore V → Prop :=\n  fun val a h s ↦ Representable.defines val (a.eval s) h\nnotation \"⦃\" addr \" ↪ \" val \"⦄\" => exprDefines val addr\n\ninstance : Storable Val where\n  defines v addr h := (addr, v) ∈ h\n  store   h addr v := Function.update h addr v\n  footprint _ addr := { addr }\n  --disjoint a₁ a₂ := a₁ ≠ a₂\n  valid h a v := by simp [Membership.mem, Storable.store]\n  frame a loc v h := by\n    intro hf\n    simp only [Membership.mem, Storable.store, Function.update]\n    split\n    . contradiction\n    . rfl\n\ninductive Sem  : P V → TypedConfigSet V → Heap → TypedStore V → Prop\n| skip : Q h l → Sem .skip Q h l\n| put  : Q h l[x := y.eval l] → Sem (.put x y) Q h l\n| store {α} {rval : E V α} (hr : Storable α)\n        (h1 : lval.eval l ∈ dom h)\n        : Q (Storable.store h (lval.eval l) (rval.eval l)) l →\n          Sem (.store lval rval) Q h l\n| load (v : type y) {lval : E V ℕ} [hr : Representable (type y)]\n       (hv : ⦃lval ↪ v⦄ h l)\n       : Q h l[y := v] → Sem (.load lval y) Q h l\n| seq : Sem c₁ (Sem c₂ Q) h l → Sem (c₁;; c₂) Q h l\n| whileDone (condFalse : x.eval l = false)\n            : Q h l → Sem (.while x c) Q h l\n| whileLoop (condTrue  : x.eval l = true)\n            : Sem c (Sem (.while x c) Q) h l →\n              Sem (.while x c) Q h l\n\nnotation c \" / \" h \", \" l \" ⇓ \" Q => Sem c Q h l\n\nend defs\n\nsection instances\nvariable {V} [VariableType V] [DecidableEq V]\nopen VariableType\n\ninstance [Tagged α] [Add α] : Add (E V α) := ⟨ λ a b => E.call .add ![a, b] ⟩\ninstance [Tagged α] [Sub α] : Sub (E V α) := ⟨ λ a b => E.call .sub ![a, b] ⟩\ninstance [Tagged α] [Mul α] : Mul (E V α) := ⟨ λ a b => E.call .mul ![a, b] ⟩\ninstance [Tagged α] [OfNat α (nat_lit 1)] : OfNat (E V α) (nat_lit 1) := ⟨ E.call .one ![] ⟩\ninstance : OfNat (E V ℕ) n := ⟨ E.call (.nat n) ![] ⟩\nabbrev zero : E V ℕ := 0\ninstance : Coe ℕ (E V ℕ) := ⟨ fun n => E.call (.nat n) ![] ⟩\n\n@[simp] theorem E.eval_nat' : E.eval st (0 : E V ℕ) = 0 := rfl\n\ninfixr:35 \" ∧ₕ \" => fun a b h ↦ a h ∧ b h\n\ndef List.defines [Representable α] (addr : Addr) : List α → Heap → Prop\n| [] => fun _ ↦ True\n| v :: vs => Representable.defines v addr ∧ₕ defines (addr + 1) vs\n\ninstance [Representable α] : Representable (List α) where defines vec := vec.defines\ninstance [Representable α] : Representable (Vector α n) where defines vec addr heap := ∀ i, Representable.defines (vec.nth i) (addr + i) heap\n\ninfixr:40 \" << \" => λ a b => E.call Op.lt ![a, b]\ninfixr:40 \" != \" => λ a b => E.call Op.neg ![E.call Op.eq ![a, b]]\n\nnamespace tests₁\n\ninductive V₁ | x | y deriving DecidableEq\n@[reducible] instance : VariableType V₁ := ⟨ fun | .x => ℕ | .y => ℕ ⟩\ndef V₁.var : (v : V₁) → E V₁ (type v)  := E.var\nopen V₁\n\ndef l₁ : TypedStore V₁ := ⟨fun |.x => 2 |.y => 7⟩\n\nexample : (.store x.var y.var;; .skip) / {2 ↦ 0} , l₁ ⇓ (fun h _ ↦ ⦃2↪7⦄ h l₁) := by\n  apply Sem.seq\n  apply Sem.store\n  . apply mem_dom_update\n  . apply Sem.skip\n    apply Storable.valid\n\nexample : (.store (x.var + 1) (y.var * 3);; .skip) / {3 ↦ 0} , l₁ ⇓ (fun h _ ↦ ⦃3↪21⦄ h l₁) := by\n  apply Sem.seq\n  apply Sem.store\n  . apply mem_dom_update\n  . apply Sem.skip\n    apply Storable.valid\n\nexample : (P.while (x.var << (3 : E V₁ ℕ)) (.put x (x.var + 1))) /  {}, ⟨fun |x |y => (0 : ℕ)⟩ ⇓ fun _ _ ↦ True := by\n  apply Sem.whileLoop\n  . simp only\n  apply Sem.put\n  apply Sem.whileLoop\n  . simp only\n  apply Sem.put\n  apply Sem.whileLoop\n  . simp only\n  apply Sem.put\n  apply Sem.whileDone\n  . simp only\n  trivial\n\nlemma cong_locals (Q : TypedConfigSet V) (c : P V) (l₁ l₂) (hl : l₁ = l₂) : (c / h, l₁ ⇓ Q) ↔ (c / h, l₂ ⇓ Q) := by rw [hl]\nexample (k : ℕ) : (.while (x.var != zero) (.put x (x.var - 1))) /  {}, ⟨fun |x => k |y => (0 : ℕ)⟩ ⇓ fun _ l ↦ l.val x = (0 : ℕ) := by\n  induction k\n  . apply Sem.whileDone\n    . simp\n    . trivial\n  case succ n ih =>\n    apply Sem.whileLoop\n    . rfl\n    . apply Sem.put\n      rw [cong_locals]\n      . apply ih\n      . ext z; cases z <;> rfl\n\nend tests₁\nend instances\n\nsection tests₂\n\nopen VariableType\n\ninductive V | ctr | v | total | base deriving DecidableEq\n@[reducible] instance V.VariableType : VariableType V := ⟨ fun | ctr => ℕ | base => ℕ | v => ℕ | total => ℕ ⟩\n\ndef V.var : (v : V) → E V (type v)  := E.var\ndef V.initial : TypedStore V := ⟨fun | ctr | v | total | base => (0 : ℕ)⟩\nopen V\n\n-- see \"bug?\" below\n@[simp] theorem duplicate_of_succ_sub_succ_eq_sub (l : List ℕ) : Nat.succ (List.length l) - 1 = (List.length l) := by simp\n\ndef List.sum [Zero α] [Add α] (l : List α) : α := l.foldr (f := (. + .)) 0\n@[simp] theorem List.sum_cons [Zero α] [Add α] (x : α) : (x :: xs).sum = x + xs.sum := rfl\n\ndef loopSum : P V :=\n.while (ctr.var != 0)\n  (.load base.var v;; .put total (total.var + v.var);; .put base (base.var + 1);; .put ctr (ctr.var - 1))\n\nexample (array : List ℕ) (hlen : ctr.var.eval l = array.length) (hArr : ⦃base.var ↪ array⦄ h l)\n  : loopSum / h, l ⇓ fun _ l' ↦ total.var.eval l' = total.var.eval l + array.sum := by\n  induction array generalizing l with\n  | nil =>\n    --cases hlen\n    apply Sem.whileDone\n    . simp [E.eval] at hlen; simp [E.eval, hlen]\n    . trivial\n  | cons x xs ih =>\n    apply Sem.whileLoop\n    . simp [E.eval] at hlen; simp [E.eval, hlen]\n    . apply Sem.seq\n      apply Sem.load\n      . exact hArr.1\n      apply Sem.seq; apply Sem.put\n      apply Sem.seq; apply Sem.put\n      apply Sem.put\n      simp only [E.eval] at hlen\n      simp [E.eval, TypedStore.val, hlen]\n      rw [← add_assoc]\n      set l' := l[v := x][total := TypedStore.val l total + x][base := TypedStore.val l base + 1][ctr := Nat.succ (List.length xs) - 1]\n      change (loopSum / _, l' ⇓ _) -- not necessary\n      have h : l.val total + x = l'.val total := by simp\n      rw [h]\n      apply ih\n      . simp [E.eval]\n        rw [Nat.succ_sub_succ_eq_sub, Nat.sub_zero] -- bug? simp doesn't use these here\n      . exact hArr.2\n", "meta": {"author": "kovach", "repo": "etch", "sha": "26ef67eb83cf7c5cfd1667059e16c3873b9098ca", "save_path": "github-repos/lean/kovach-etch", "path": "github-repos/lean/kovach-etch/etch-26ef67eb83cf7c5cfd1667059e16c3873b9098ca/etch4/Etch/Omni.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059775, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.45313511105738463}}
{"text": "import DmdAnal.Order\nimport Init.Data.List\nimport Mathlib.Init.Function\nimport Mathlib.Init.Set\nimport Mathlib.Order.Basic\n\nopen Function\n\nabbrev Map (α β : Type) := List (α × β)\n\nnamespace Map\n\ndef empty : Map α β := []\n\ndef update [DecidableEq α] (m : Map α β) (k : α) (v : Option β) : Map α β :=\n  match v with\n  | none   => List.filter (¬ ·.fst = k) m\n  | some v => (k,v) :: m\n\ndef lookup [DecidableEq α] (m : Map α β) (k : α) : Option β := \n  List.lookup k m \n\ndef dom (m : Map α β) := \n  List.map Prod.fst m\n\nmacro:max m:term noWs \"[\" k:term \" ↦ \" v:term \"]\" : term => `(update $m $k $v)\n\nend Map\n\nabbrev Con := Int\n\ninductive Lb where\n  | l0 \n  | l1 \n  deriving Repr\n\ninductive Ub where\n  | u0 \n  | u1 \n  | uN\n  deriving Repr\n\ninductive Card where\n  | mk (l: Lb) (u: Ub)\n  deriving Repr\n\nnamespace Card\n\ndef c00 : Card := ⟨Lb.l0, Ub.u0⟩ \ndef c01 : Card := ⟨Lb.l0, Ub.u1⟩ \ndef c0N : Card := ⟨Lb.l0, Ub.uN⟩ \ndef c10 : Card := ⟨Lb.l1, Ub.u0⟩ \ndef c11 : Card := ⟨Lb.l1, Ub.u1⟩ \ndef c1N : Card := ⟨Lb.l1, Ub.uN⟩ \n\nend Card\n\nopen Card\n\nmutual\n  inductive Demand where\n    | mk (n : Card) (sd : SubDemand)\n    deriving Repr\n\n  inductive SubDemand where\n    | poly (n : Card) : SubDemand\n    | ap (n : Card) (sd : SubDemand) : SubDemand\n    | sel (alts : List (Con × (List Demand))) : SubDemand\n    deriving Repr\nend\n\n#eval Demand.mk Card.c0N (SubDemand.poly Card.c0N)\n\n\n/-\nmutual\n  inductive EquiD : Demand → Demand → Prop where\n    | bot : EquiD ⟨c10, sd₁⟩ ⟨c10, sd₂⟩\n    | abs : EquiD ⟨c00, sd₁⟩ ⟨c00, sd₂⟩\n    | cong : EquiSD sd₁ sd₂ → EquiD ⟨n, sd₁⟩ ⟨n, sd₂⟩\n  inductive EquiSD : SubDemand → SubDemand → Prop where\n    | ap_bot : EquiSD (SubDemand.ap c10 sd₁) (SubDemand.ap c10 sd₂)\n    | ap_abs : EquiSD (SubDemand.ap c00 sd₁) (SubDemand.ap c00 sd₂)\n    | ap_poly : {n ∉ [c11,c1N]} → EquiSD (SubDemand.ap n (SubDemand.poly n)) (SubDemand.poly n)\n    | sel : {n : Card} → (∀c ∈ Map.dom alts, ∀d ∈ Map.lookup c alts, d = Demand.mk n (SubDemand.poly n)) → EquiSD (SubDemand.sel alts) (SubDemand.poly n) \n    | cong_ap : EquiSD (SubDemand.ap n sd₁) (SubDemand.ap n sd₂) \nend    \n-/\n\nnamespace Card\n\n@[inline]\ndef concLb : Lb -> Set ℕ \n  | Lb.l0 => { n | n >= 0 }\n  | Lb.l1 => { n | n >= 1 }\n\n@[inline]\ndef concUb : Ub -> Set ℕ \n  | Ub.u0 => {0} \n  | Ub.u1 => {0,1}\n  | Ub.uN => { n | true }\n\n@[inline]\ndef conc : Card -> Set ℕ \n  | ⟨ l, u ⟩ => concLb l ∩ concUb u\n  \n@[inline]\ndef absLb (s : Set ℕ) : Lb := match infi s with\n  | 0 => Lb.l0 \n  | _ => Lb.l1\n  \n@[inline]\ndef absUb (s : Set ℕ) : Ub := match supr s with\n  | 0 => Ub.u0\n  | 1 => Ub.u1\n  | _ => Ub.uN\n\n@[inline]\ndef abs (s : Set ℕ) : Card := ⟨ absLb s, absUb s ⟩ \n\ndef concLb_injective : Function.injective concLb\n  | Lb.l0, Lb.l0 => by simp\n  | Lb.l0, Lb.l1 => by delta concLb; simp; intro; show ¬ ({n | True} = {n | n >= 1}) by sorry  \n  | Lb.l1, Lb.l0 => by delta concLb; simp\n  | Lb.l1, Lb.l1 => by simp\n  \n\n--match (a₁, a₂) with\n--  | (Lb.l0, Lb.l0) => by simp\n--  | (Lb.l0, Lb.l1) => by contradiction\n--  | (Lb.l1, Lb.l0) => by sorry\n--  | (Lb.l1, Lb.l1) => by sorry\n    \n    \n  \ndef concUb_injective : Function.injective concUb := by\n  intros a₁ a₂ h\n  simp\n  \ndef conc_injective : Function.injective conc := by\n  intros a₁ a₂ h\n  \n\n\ninstance CompleteLattic Card :=\n  {\n\n  }\n\ntheorem galois_abs_conc : galoisConnection abs conc := by sorry\n\nend Card\n", "meta": {"author": "sgraf812", "repo": "dmdanal", "sha": "160058d163c0c2fb7ab1a70fd72617eb97933d87", "save_path": "github-repos/lean/sgraf812-dmdanal", "path": "github-repos/lean/sgraf812-dmdanal/dmdanal-160058d163c0c2fb7ab1a70fd72617eb97933d87/DmdAnal/Demand.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4531351110573846}}
{"text": "/-\nCopyright (c) 2020 Anne Baanen. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Anne Baanen\n\n! This file was ported from Lean 3 source module field_theory.subfield\n! leanprover-community/mathlib commit 3dadefa3f544b1db6214777fe47910739b54c66a\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Basic\nimport Mathbin.Algebra.Order.Field.InjSurj\n\n/-!\n# Subfields\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nLet `K` be a field. This file defines the \"bundled\" subfield type `subfield K`, a type\nwhose terms correspond to subfields of `K`. This is the preferred way to talk\nabout subfields in mathlib. Unbundled subfields (`s : set K` and `is_subfield s`)\nare not in this file, and they will ultimately be deprecated.\n\nWe prove that subfields are a complete lattice, and that you can `map` (pushforward) and\n`comap` (pull back) them along ring homomorphisms.\n\nWe define the `closure` construction from `set R` to `subfield R`, sending a subset of `R`\nto the subfield it generates, and prove that it is a Galois insertion.\n\n## Main definitions\n\nNotation used here:\n\n`(K : Type u) [field K] (L : Type u) [field L] (f g : K →+* L)`\n`(A : subfield K) (B : subfield L) (s : set K)`\n\n* `subfield R` : the type of subfields of a ring `R`.\n\n* `instance : complete_lattice (subfield R)` : the complete lattice structure on the subfields.\n\n* `subfield.closure` : subfield closure of a set, i.e., the smallest subfield that includes the set.\n\n* `subfield.gi` : `closure : set M → subfield M` and coercion `coe : subfield M → set M`\n  form a `galois_insertion`.\n\n* `comap f B : subfield K` : the preimage of a subfield `B` along the ring homomorphism `f`\n\n* `map f A : subfield L` : the image of a subfield `A` along the ring homomorphism `f`.\n\n* `prod A B : subfield (K × L)` : the product of subfields\n\n* `f.field_range : subfield B` : the range of the ring homomorphism `f`.\n\n* `eq_locus_field f g : subfield K` : given ring homomorphisms `f g : K →+* R`,\n     the subfield of `K` where `f x = g x`\n\n## Implementation notes\n\nA subfield is implemented as a subring which is is closed under `⁻¹`.\n\nLattice inclusion (e.g. `≤` and `⊓`) is used rather than set notation (`⊆` and `∩`), although\n`∈` is defined as membership of a subfield's underlying set.\n\n## Tags\nsubfield, subfields\n-/\n\n\nopen BigOperators\n\nuniverse u v w\n\nvariable {K : Type u} {L : Type v} {M : Type w} [Field K] [Field L] [Field M]\n\n#print SubfieldClass /-\n/-- `subfield_class S K` states `S` is a type of subsets `s ⊆ K` closed under field operations. -/\nclass SubfieldClass (S K : Type _) [Field K] [SetLike S K] extends SubringClass S K,\n  InvMemClass S K : Prop\n#align subfield_class SubfieldClass\n-/\n\nnamespace SubfieldClass\n\nvariable (S : Type _) [SetLike S K] [h : SubfieldClass S K]\n\ninclude h\n\n#print SubfieldClass.toSubgroupClass /-\n-- See note [lower instance priority]\n/-- A subfield contains `1`, products and inverses.\n\nBe assured that we're not actually proving that subfields are subgroups:\n`subgroup_class` is really an abbreviation of `subgroup_with_or_without_zero_class`.\n -/\ninstance (priority := 100) SubfieldClass.toSubgroupClass : SubgroupClass S K :=\n  { h with }\n#align subfield_class.subfield_class.to_subgroup_class SubfieldClass.toSubgroupClass\n-/\n\nvariable {S}\n\n/- warning: subfield_class.coe_rat_mem -> SubfieldClass.coe_rat_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Type.{u2}} [_inst_4 : SetLike.{u2, u1} S K] [h : SubfieldClass.{u2, u1} S K _inst_1 _inst_4] (s : S) (x : Rat), Membership.Mem.{u1, u2} K S (SetLike.hasMem.{u2, u1} S K _inst_4) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) x) s\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {S : Type.{u1}} [_inst_4 : SetLike.{u1, u2} S K] [h : SubfieldClass.{u1, u2} S K _inst_1 _inst_4] (s : S) (x : Rat), Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) (Rat.cast.{u2} K (Field.toRatCast.{u2} K _inst_1) x) s\nCase conversion may be inaccurate. Consider using '#align subfield_class.coe_rat_mem SubfieldClass.coe_rat_memₓ'. -/\ntheorem coe_rat_mem (s : S) (x : ℚ) : (x : K) ∈ s := by\n  simpa only [Rat.cast_def] using div_mem (coe_int_mem s x.num) (coe_nat_mem s x.denom)\n#align subfield_class.coe_rat_mem SubfieldClass.coe_rat_mem\n\ninstance (s : S) : HasRatCast s :=\n  ⟨fun x => ⟨↑x, coe_rat_mem s x⟩⟩\n\n/- warning: subfield_class.coe_rat_cast -> SubfieldClass.coe_rat_cast is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Type.{u2}} [_inst_4 : SetLike.{u2, u1} S K] [h : SubfieldClass.{u2, u1} S K _inst_1 _inst_4] (s : S) (x : Rat), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u2} K S (SetLike.hasMem.{u2, u1} S K _inst_4) x s))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) (HasLiftT.mk.{1, succ u1} Rat (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) (CoeTCₓ.coe.{1, succ u1} Rat (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) (Rat.castCoe.{u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) (SubfieldClass.hasRatCast.{u1, u2} K _inst_1 S _inst_4 h s)))) x)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat K (HasLiftT.mk.{1, succ u1} Rat K (CoeTCₓ.coe.{1, succ u1} Rat K (Rat.castCoe.{u1} K (DivisionRing.toHasRatCast.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) x)\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {S : Type.{u1}} [_inst_4 : SetLike.{u1, u2} S K] [h : SubfieldClass.{u1, u2} S K _inst_1 _inst_4] (s : S) (x : Rat), Eq.{succ u2} K (Subtype.val.{succ u2} K (fun (x : K) => Membership.mem.{u2, u2} K (Set.{u2} K) (Set.instMembershipSet.{u2} K) x (SetLike.coe.{u1, u2} S K _inst_4 s)) (Rat.cast.{u2} (Subtype.{succ u2} K (fun (x : K) => Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) x s)) (SubfieldClass.instRatCastSubtypeMemInstMembership.{u2, u1} K _inst_1 S _inst_4 h s) x)) (Rat.cast.{u2} K (Field.toRatCast.{u2} K _inst_1) x)\nCase conversion may be inaccurate. Consider using '#align subfield_class.coe_rat_cast SubfieldClass.coe_rat_castₓ'. -/\n@[simp]\ntheorem coe_rat_cast (s : S) (x : ℚ) : ((x : s) : K) = x :=\n  rfl\n#align subfield_class.coe_rat_cast SubfieldClass.coe_rat_cast\n\n/- warning: subfield_class.rat_smul_mem -> SubfieldClass.rat_smul_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Type.{u2}} [_inst_4 : SetLike.{u2, u1} S K] [h : SubfieldClass.{u2, u1} S K _inst_1 _inst_4] (s : S) (a : Rat) (x : coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s), Membership.Mem.{u1, u2} K S (SetLike.hasMem.{u2, u1} S K _inst_4) (SMul.smul.{0, u1} Rat K (Rat.smulDivisionRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u2} K S (SetLike.hasMem.{u2, u1} S K _inst_4) x s))))) x)) s\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {S : Type.{u1}} [_inst_4 : SetLike.{u1, u2} S K] [h : SubfieldClass.{u1, u2} S K _inst_1 _inst_4] (s : S) (a : Rat) (x : Subtype.{succ u2} K (fun (x : K) => Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) x s)), Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) (HSMul.hSMul.{0, u2, u2} Rat K K (instHSMul.{0, u2} Rat K (SMulZeroClass.toSMul.{0, u2} Rat K (CommMonoidWithZero.toZero.{u2} K (CommGroupWithZero.toCommMonoidWithZero.{u2} K (Semifield.toCommGroupWithZero.{u2} K (Field.toSemifield.{u2} K _inst_1)))) (DistribSMul.toSMulZeroClass.{0, u2} Rat K (AddMonoid.toAddZeroClass.{u2} K (AddMonoidWithOne.toAddMonoid.{u2} K (AddGroupWithOne.toAddMonoidWithOne.{u2} K (Ring.toAddGroupWithOne.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_1)))))) (Rat.distribSMul.{u2} K (Field.toDivisionRing.{u2} K _inst_1))))) a (Subtype.val.{succ u2} K (fun (x : K) => Membership.mem.{u2, u2} K (Set.{u2} K) (Set.instMembershipSet.{u2} K) x (SetLike.coe.{u1, u2} S K _inst_4 s)) x)) s\nCase conversion may be inaccurate. Consider using '#align subfield_class.rat_smul_mem SubfieldClass.rat_smul_memₓ'. -/\ntheorem rat_smul_mem (s : S) (a : ℚ) (x : s) : (a • x : K) ∈ s := by\n  simpa only [Rat.smul_def] using mul_mem (coe_rat_mem s a) x.prop\n#align subfield_class.rat_smul_mem SubfieldClass.rat_smul_mem\n\ninstance (s : S) : SMul ℚ s :=\n  ⟨fun a x => ⟨a • x, rat_smul_mem s a x⟩⟩\n\n/- warning: subfield_class.coe_rat_smul -> SubfieldClass.coe_rat_smul is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Type.{u2}} [_inst_4 : SetLike.{u2, u1} S K] [h : SubfieldClass.{u2, u1} S K _inst_1 _inst_4] (s : S) (a : Rat) (x : coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u2} K S (SetLike.hasMem.{u2, u1} S K _inst_4) x s))))) (SMul.smul.{0, u1} Rat (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) (SubfieldClass.hasSmul.{u1, u2} K _inst_1 S _inst_4 h s) a x)) (SMul.smul.{0, u1} Rat K (Rat.smulDivisionRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u2, succ (succ u1)} S Type.{u1} (SetLike.hasCoeToSort.{u2, u1} S K _inst_4) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u2} K S (SetLike.hasMem.{u2, u1} S K _inst_4) x s))))) x))\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {S : Type.{u1}} [_inst_4 : SetLike.{u1, u2} S K] [h : SubfieldClass.{u1, u2} S K _inst_1 _inst_4] (s : S) (a : Rat) (x : Subtype.{succ u2} K (fun (x : K) => Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) x s)), Eq.{succ u2} K (Subtype.val.{succ u2} K (fun (x : K) => Membership.mem.{u2, u2} K (Set.{u2} K) (Set.instMembershipSet.{u2} K) x (SetLike.coe.{u1, u2} S K _inst_4 s)) (HSMul.hSMul.{0, u2, u2} Rat (Subtype.{succ u2} K (fun (x : K) => Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) x s)) (Subtype.{succ u2} K (fun (x : K) => Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) x s)) (instHSMul.{0, u2} Rat (Subtype.{succ u2} K (fun (x : K) => Membership.mem.{u2, u1} K S (SetLike.instMembership.{u1, u2} S K _inst_4) x s)) (SubfieldClass.instSMulRatSubtypeMemInstMembership.{u2, u1} K _inst_1 S _inst_4 h s)) a x)) (HSMul.hSMul.{0, u2, u2} Rat K K (instHSMul.{0, u2} Rat K (SMulZeroClass.toSMul.{0, u2} Rat K (CommMonoidWithZero.toZero.{u2} K (CommGroupWithZero.toCommMonoidWithZero.{u2} K (Semifield.toCommGroupWithZero.{u2} K (Field.toSemifield.{u2} K _inst_1)))) (DistribSMul.toSMulZeroClass.{0, u2} Rat K (AddMonoid.toAddZeroClass.{u2} K (AddMonoidWithOne.toAddMonoid.{u2} K (AddGroupWithOne.toAddMonoidWithOne.{u2} K (Ring.toAddGroupWithOne.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_1)))))) (Rat.distribSMul.{u2} K (Field.toDivisionRing.{u2} K _inst_1))))) a (Subtype.val.{succ u2} K (fun (x : K) => Membership.mem.{u2, u2} K (Set.{u2} K) (Set.instMembershipSet.{u2} K) x (SetLike.coe.{u1, u2} S K _inst_4 s)) x))\nCase conversion may be inaccurate. Consider using '#align subfield_class.coe_rat_smul SubfieldClass.coe_rat_smulₓ'. -/\n@[simp]\ntheorem coe_rat_smul (s : S) (a : ℚ) (x : s) : (↑(a • x) : K) = a • x :=\n  rfl\n#align subfield_class.coe_rat_smul SubfieldClass.coe_rat_smul\n\nvariable (S)\n\n#print SubfieldClass.toField /-\n-- Prefer subclasses of `field` over subclasses of `subfield_class`.\n/-- A subfield inherits a field structure -/\ninstance (priority := 75) toField (s : S) : Field s :=\n  Subtype.coe_injective.Field (coe : s → K) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)\n    (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ => rfl) fun _ => rfl\n#align subfield_class.to_field SubfieldClass.toField\n-/\n\nomit h\n\n#print SubfieldClass.toLinearOrderedField /-\n-- Prefer subclasses of `field` over subclasses of `subfield_class`.\n/-- A subfield of a `linear_ordered_field` is a `linear_ordered_field`. -/\ninstance (priority := 75) toLinearOrderedField {K} [LinearOrderedField K] [SetLike S K]\n    [SubfieldClass S K] (s : S) : LinearOrderedField s :=\n  Subtype.coe_injective.LinearOrderedField coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)\n    (fun _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subfield_class.to_linear_ordered_field SubfieldClass.toLinearOrderedField\n-/\n\nend SubfieldClass\n\n#print Subfield /-\n/-- `subfield R` is the type of subfields of `R`. A subfield of `R` is a subset `s` that is a\n  multiplicative submonoid and an additive subgroup. Note in particular that it shares the\n  same 0 and 1 as R. -/\nstructure Subfield (K : Type u) [Field K] extends Subring K where\n  inv_mem' : ∀ x ∈ carrier, x⁻¹ ∈ carrier\n#align subfield Subfield\n-/\n\n/-- Reinterpret a `subfield` as a `subring`. -/\nadd_decl_doc Subfield.toSubring\n\nnamespace Subfield\n\n/- warning: subfield.to_add_subgroup -> Subfield.toAddSubgroup is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], (Subfield.{u1} K _inst_1) -> (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], (Subfield.{u1} K _inst_1) -> (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align subfield.to_add_subgroup Subfield.toAddSubgroupₓ'. -/\n/-- The underlying `add_subgroup` of a subfield. -/\ndef toAddSubgroup (s : Subfield K) : AddSubgroup K :=\n  { s.toSubring.toAddSubgroup with }\n#align subfield.to_add_subgroup Subfield.toAddSubgroup\n\n/-- The underlying submonoid of a subfield. -/\ndef toSubmonoid (s : Subfield K) : Submonoid K :=\n  { s.toSubring.toSubmonoid with }\n#align subfield.to_submonoid Subfield.toSubmonoid\n\ninstance : SetLike (Subfield K) K :=\n  ⟨Subfield.carrier, fun p q h => by cases p <;> cases q <;> congr ⟩\n\ninstance : SubfieldClass (Subfield K) K\n    where\n  add_mem := add_mem'\n  zero_mem := zero_mem'\n  neg_mem := neg_mem'\n  mul_mem := mul_mem'\n  one_mem := one_mem'\n  inv_mem := inv_mem'\n\n/- warning: subfield.mem_carrier -> Subfield.mem_carrier is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x (Subfield.carrier.{u1} K _inst_1 s)) (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s)))))) (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align subfield.mem_carrier Subfield.mem_carrierₓ'. -/\n@[simp]\ntheorem mem_carrier {s : Subfield K} {x : K} : x ∈ s.carrier ↔ x ∈ s :=\n  Iff.rfl\n#align subfield.mem_carrier Subfield.mem_carrier\n\n/- warning: subfield.mem_mk -> Subfield.mem_mk is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} K} {x : K} (h₁ : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) a b) S)) (h₂ : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 1 (OfNat.mk.{u1} K 1 (One.one.{u1} K (MulOneClass.toHasOne.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) S) (h₃ : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) a b) S)) (h₄ : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 0 (OfNat.mk.{u1} K 0 (Zero.zero.{u1} K (AddZeroClass.toHasZero.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))))) S) (h₅ : forall {x : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Neg.neg.{u1} K (SubNegMonoid.toHasNeg.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) x) S)) (h₆ : forall (x : K), (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x) S)), Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (Subfield.mk.{u1} K _inst_1 S h₁ h₂ h₃ h₄ h₅ h₆)) (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))} {x : K} (h₁ : forall (a : K), (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) a (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S))))) -> (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) a) (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S)))))), Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Subfield.mk.{u1} K _inst_1 S h₁)) (Membership.mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.instMembership.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x S)\nCase conversion may be inaccurate. Consider using '#align subfield.mem_mk Subfield.mem_mkₓ'. -/\n@[simp]\ntheorem mem_mk {S : Set K} {x : K} (h₁ h₂ h₃ h₄ h₅ h₆) :\n    x ∈ (⟨S, h₁, h₂, h₃, h₄, h₅, h₆⟩ : Subfield K) ↔ x ∈ S :=\n  Iff.rfl\n#align subfield.mem_mk Subfield.mem_mk\n\n/- warning: subfield.coe_set_mk -> Subfield.coe_set_mk is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Set.{u1} K) (h₁ : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) a b) S)) (h₂ : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 1 (OfNat.mk.{u1} K 1 (One.one.{u1} K (MulOneClass.toHasOne.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) S) (h₃ : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) a b) S)) (h₄ : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 0 (OfNat.mk.{u1} K 0 (Zero.zero.{u1} K (AddZeroClass.toHasZero.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))))) S) (h₅ : forall {x : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Neg.neg.{u1} K (SubNegMonoid.toHasNeg.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) x) S)) (h₆ : forall (x : K), (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x) S)), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Subfield.mk.{u1} K _inst_1 S h₁ h₂ h₃ h₄ h₅ h₆)) S\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (h₁ : forall (a : K), (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) a (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S))))) -> (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) a) (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S)))))), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.mk.{u1} K _inst_1 S h₁)) (SetLike.coe.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) S)\nCase conversion may be inaccurate. Consider using '#align subfield.coe_set_mk Subfield.coe_set_mkₓ'. -/\n@[simp]\ntheorem coe_set_mk (S : Set K) (h₁ h₂ h₃ h₄ h₅ h₆) :\n    ((⟨S, h₁, h₂, h₃, h₄, h₅, h₆⟩ : Subfield K) : Set K) = S :=\n  rfl\n#align subfield.coe_set_mk Subfield.coe_set_mk\n\n/- warning: subfield.mk_le_mk -> Subfield.mk_le_mk is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} K} {S' : Set.{u1} K} (h₁ : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) a b) S)) (h₂ : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 1 (OfNat.mk.{u1} K 1 (One.one.{u1} K (MulOneClass.toHasOne.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) S) (h₃ : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) a b) S)) (h₄ : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 0 (OfNat.mk.{u1} K 0 (Zero.zero.{u1} K (AddZeroClass.toHasZero.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))))) S) (h₅ : forall {x : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Neg.neg.{u1} K (SubNegMonoid.toHasNeg.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) x) S)) (h₆ : forall (x : K), (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S) -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x) S)) (h₁' : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S') -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S') -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) a b) S')) (h₂' : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 1 (OfNat.mk.{u1} K 1 (One.one.{u1} K (MulOneClass.toHasOne.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) S') (h₃' : forall {a : K} {b : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) a S') -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) b S') -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) a b) S')) (h₄' : Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (OfNat.ofNat.{u1} K 0 (OfNat.mk.{u1} K 0 (Zero.zero.{u1} K (AddZeroClass.toHasZero.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))))) S') (h₅' : forall {x : K}, (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S') -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Neg.neg.{u1} K (SubNegMonoid.toHasNeg.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) x) S')) (h₆' : forall (x : K), (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x S') -> (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x) S')), Iff (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (SetLike.partialOrder.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Subfield.mk.{u1} K _inst_1 S h₁ h₂ h₃ h₄ h₅ h₆) (Subfield.mk.{u1} K _inst_1 S' h₁' h₂' h₃' h₄' h₅' h₆')) (HasSubset.Subset.{u1} (Set.{u1} K) (Set.hasSubset.{u1} K) S S')\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))} {S' : Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))} (h₁ : forall (a : K), (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) a (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S))))) -> (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) a) (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S)))))) (h₂ : forall (x : K), (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S'))))) -> (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) x) (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) S')))))), Iff (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)))) (Subfield.mk.{u1} K _inst_1 S h₁) (Subfield.mk.{u1} K _inst_1 S' h₂)) (LE.le.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Preorder.toLE.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (PartialOrder.toPreorder.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Subring.instCompleteLatticeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) S S')\nCase conversion may be inaccurate. Consider using '#align subfield.mk_le_mk Subfield.mk_le_mkₓ'. -/\n@[simp]\ntheorem mk_le_mk {S S' : Set K} (h₁ h₂ h₃ h₄ h₅ h₆ h₁' h₂' h₃' h₄' h₅' h₆') :\n    (⟨S, h₁, h₂, h₃, h₄, h₅, h₆⟩ : Subfield K) ≤ (⟨S', h₁', h₂', h₃', h₄', h₅', h₆'⟩ : Subfield K) ↔\n      S ⊆ S' :=\n  Iff.rfl\n#align subfield.mk_le_mk Subfield.mk_le_mk\n\n/- warning: subfield.ext -> Subfield.ext is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Subfield.{u1} K _inst_1} {T : Subfield.{u1} K _inst_1}, (forall (x : K), Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x S) (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x T)) -> (Eq.{succ u1} (Subfield.{u1} K _inst_1) S T)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Subfield.{u1} K _inst_1} {T : Subfield.{u1} K _inst_1}, (forall (x : K), Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x S) (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x T)) -> (Eq.{succ u1} (Subfield.{u1} K _inst_1) S T)\nCase conversion may be inaccurate. Consider using '#align subfield.ext Subfield.extₓ'. -/\n/-- Two subfields are equal if they have the same elements. -/\n@[ext]\ntheorem ext {S T : Subfield K} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=\n  SetLike.ext h\n#align subfield.ext Subfield.ext\n\n/- warning: subfield.copy -> Subfield.copy is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Subfield.{u1} K _inst_1) (s : Set.{u1} K), (Eq.{succ u1} (Set.{u1} K) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) S)) -> (Subfield.{u1} K _inst_1)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Subfield.{u1} K _inst_1) (s : Set.{u1} K), (Eq.{succ u1} (Set.{u1} K) s (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) S)) -> (Subfield.{u1} K _inst_1)\nCase conversion may be inaccurate. Consider using '#align subfield.copy Subfield.copyₓ'. -/\n/-- Copy of a subfield with a new `carrier` equal to the old one. Useful to fix definitional\nequalities. -/\nprotected def copy (S : Subfield K) (s : Set K) (hs : s = ↑S) : Subfield K :=\n  { S.toSubring.copy s hs with\n    carrier := s\n    inv_mem' := hs.symm ▸ S.inv_mem' }\n#align subfield.copy Subfield.copy\n\n/- warning: subfield.coe_copy -> Subfield.coe_copy is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Subfield.{u1} K _inst_1) (s : Set.{u1} K) (hs : Eq.{succ u1} (Set.{u1} K) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) S)), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Subfield.copy.{u1} K _inst_1 S s hs)) s\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Subfield.{u1} K _inst_1) (s : Set.{u1} K) (hs : Eq.{succ u1} (Set.{u1} K) s (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) S)), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.copy.{u1} K _inst_1 S s hs)) s\nCase conversion may be inaccurate. Consider using '#align subfield.coe_copy Subfield.coe_copyₓ'. -/\n@[simp]\ntheorem coe_copy (S : Subfield K) (s : Set K) (hs : s = ↑S) : (S.copy s hs : Set K) = s :=\n  rfl\n#align subfield.coe_copy Subfield.coe_copy\n\n/- warning: subfield.copy_eq -> Subfield.copy_eq is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Subfield.{u1} K _inst_1) (s : Set.{u1} K) (hs : Eq.{succ u1} (Set.{u1} K) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) S)), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.copy.{u1} K _inst_1 S s hs) S\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Subfield.{u1} K _inst_1) (s : Set.{u1} K) (hs : Eq.{succ u1} (Set.{u1} K) s (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) S)), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.copy.{u1} K _inst_1 S s hs) S\nCase conversion may be inaccurate. Consider using '#align subfield.copy_eq Subfield.copy_eqₓ'. -/\ntheorem copy_eq (S : Subfield K) (s : Set K) (hs : s = ↑S) : S.copy s hs = S :=\n  SetLike.coe_injective hs\n#align subfield.copy_eq Subfield.copy_eq\n\n/- warning: subfield.coe_to_subring -> Subfield.coe_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subfield.toSubring.{u1} K _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Subfield.toSubring.{u1} K _inst_1 s)) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)\nCase conversion may be inaccurate. Consider using '#align subfield.coe_to_subring Subfield.coe_toSubringₓ'. -/\n@[simp]\ntheorem coe_toSubring (s : Subfield K) : (s.toSubring : Set K) = s :=\n  rfl\n#align subfield.coe_to_subring Subfield.coe_toSubring\n\n/- warning: subfield.mem_to_subring -> Subfield.mem_toSubring is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : K), Iff (Membership.Mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.hasMem.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x (Subfield.toSubring.{u1} K _inst_1 s)) (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : K), Iff (Membership.mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.instMembership.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x (Subfield.toSubring.{u1} K _inst_1 s)) (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align subfield.mem_to_subring Subfield.mem_toSubringₓ'. -/\n@[simp]\ntheorem mem_toSubring (s : Subfield K) (x : K) : x ∈ s.toSubring ↔ x ∈ s :=\n  Iff.rfl\n#align subfield.mem_to_subring Subfield.mem_toSubring\n\nend Subfield\n\n/- warning: subring.to_subfield -> Subring.toSubfield is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))), (forall (x : K), (Membership.Mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.hasMem.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x s) -> (Membership.Mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.hasMem.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x) s)) -> (Subfield.{u1} K _inst_1)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))), (forall (x : K), (Membership.mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.instMembership.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x s) -> (Membership.mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.instMembership.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) x) s)) -> (Subfield.{u1} K _inst_1)\nCase conversion may be inaccurate. Consider using '#align subring.to_subfield Subring.toSubfieldₓ'. -/\n/-- A `subring` containing inverses is a `subfield`. -/\ndef Subring.toSubfield (s : Subring K) (hinv : ∀ x ∈ s, x⁻¹ ∈ s) : Subfield K :=\n  { s with inv_mem' := hinv }\n#align subring.to_subfield Subring.toSubfield\n\nnamespace Subfield\n\nvariable (s t : Subfield K)\n\nsection DerivedFromSubfieldClass\n\n/- warning: subfield.one_mem -> Subfield.one_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (OfNat.ofNat.{u1} K 1 (OfNat.mk.{u1} K 1 (One.one.{u1} K (AddMonoidWithOne.toOne.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))) s\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (OfNat.ofNat.{u1} K 1 (One.toOfNat1.{u1} K (NonAssocRing.toOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) s\nCase conversion may be inaccurate. Consider using '#align subfield.one_mem Subfield.one_memₓ'. -/\n/-- A subfield contains the field's 1. -/\nprotected theorem one_mem : (1 : K) ∈ s :=\n  one_mem s\n#align subfield.one_mem Subfield.one_mem\n\n/- warning: subfield.zero_mem -> Subfield.zero_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (OfNat.ofNat.{u1} K 0 (OfNat.mk.{u1} K 0 (Zero.zero.{u1} K (MulZeroClass.toHasZero.{u1} K (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) s\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (OfNat.ofNat.{u1} K 0 (Zero.toOfNat0.{u1} K (CommMonoidWithZero.toZero.{u1} K (CommGroupWithZero.toCommMonoidWithZero.{u1} K (Semifield.toCommGroupWithZero.{u1} K (Field.toSemifield.{u1} K _inst_1)))))) s\nCase conversion may be inaccurate. Consider using '#align subfield.zero_mem Subfield.zero_memₓ'. -/\n/-- A subfield contains the field's 0. -/\nprotected theorem zero_mem : (0 : K) ∈ s :=\n  zero_mem s\n#align subfield.zero_mem Subfield.zero_mem\n\n/- warning: subfield.mul_mem -> Subfield.mul_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) y s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) x y) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) y s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) x y) s)\nCase conversion may be inaccurate. Consider using '#align subfield.mul_mem Subfield.mul_memₓ'. -/\n/-- A subfield is closed under multiplication. -/\nprotected theorem mul_mem {x y : K} : x ∈ s → y ∈ s → x * y ∈ s :=\n  mul_mem\n#align subfield.mul_mem Subfield.mul_mem\n\n/- warning: subfield.add_mem -> Subfield.add_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) y s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (Distrib.toHasAdd.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) x y) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) y s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (Distrib.toAdd.{u1} K (NonUnitalNonAssocSemiring.toDistrib.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) x y) s)\nCase conversion may be inaccurate. Consider using '#align subfield.add_mem Subfield.add_memₓ'. -/\n/-- A subfield is closed under addition. -/\nprotected theorem add_mem {x y : K} : x ∈ s → y ∈ s → x + y ∈ s :=\n  add_mem\n#align subfield.add_mem Subfield.add_mem\n\n/- warning: subfield.neg_mem -> Subfield.neg_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (Neg.neg.{u1} K (SubNegMonoid.toHasNeg.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) x) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (Neg.neg.{u1} K (Ring.toNeg.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x) s)\nCase conversion may be inaccurate. Consider using '#align subfield.neg_mem Subfield.neg_memₓ'. -/\n/-- A subfield is closed under negation. -/\nprotected theorem neg_mem {x : K} : x ∈ s → -x ∈ s :=\n  neg_mem\n#align subfield.neg_mem Subfield.neg_mem\n\n/- warning: subfield.sub_mem -> Subfield.sub_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) y s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (HSub.hSub.{u1, u1, u1} K K K (instHSub.{u1} K (SubNegMonoid.toHasSub.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) x y) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) y s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (HSub.hSub.{u1, u1, u1} K K K (instHSub.{u1} K (Ring.toSub.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x y) s)\nCase conversion may be inaccurate. Consider using '#align subfield.sub_mem Subfield.sub_memₓ'. -/\n/-- A subfield is closed under subtraction. -/\nprotected theorem sub_mem {x y : K} : x ∈ s → y ∈ s → x - y ∈ s :=\n  sub_mem\n#align subfield.sub_mem Subfield.sub_mem\n\n/- warning: subfield.inv_mem -> Subfield.inv_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) x) s)\nCase conversion may be inaccurate. Consider using '#align subfield.inv_mem Subfield.inv_memₓ'. -/\n/-- A subfield is closed under inverses. -/\nprotected theorem inv_mem {x : K} : x ∈ s → x⁻¹ ∈ s :=\n  inv_mem\n#align subfield.inv_mem Subfield.inv_mem\n\n/- warning: subfield.div_mem -> Subfield.div_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) y s) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x y) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K} {y : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) y s) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (Field.toDiv.{u1} K _inst_1)) x y) s)\nCase conversion may be inaccurate. Consider using '#align subfield.div_mem Subfield.div_memₓ'. -/\n/-- A subfield is closed under division. -/\nprotected theorem div_mem {x y : K} : x ∈ s → y ∈ s → x / y ∈ s :=\n  div_mem\n#align subfield.div_mem Subfield.div_mem\n\n/- warning: subfield.list_prod_mem -> Subfield.list_prod_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {l : List.{u1} K}, (forall (x : K), (Membership.Mem.{u1, u1} K (List.{u1} K) (List.hasMem.{u1} K) x l) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s)) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (List.prod.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (AddMonoidWithOne.toOne.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) l) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {l : List.{u1} K}, (forall (x : K), (Membership.mem.{u1, u1} K (List.{u1} K) (List.instMembershipList.{u1} K) x l) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (List.prod.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocRing.toOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) l) s)\nCase conversion may be inaccurate. Consider using '#align subfield.list_prod_mem Subfield.list_prod_memₓ'. -/\n/-- Product of a list of elements in a subfield is in the subfield. -/\nprotected theorem list_prod_mem {l : List K} : (∀ x ∈ l, x ∈ s) → l.Prod ∈ s :=\n  list_prod_mem\n#align subfield.list_prod_mem Subfield.list_prod_mem\n\n/- warning: subfield.list_sum_mem -> Subfield.list_sum_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {l : List.{u1} K}, (forall (x : K), (Membership.Mem.{u1, u1} K (List.{u1} K) (List.hasMem.{u1} K) x l) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s)) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (List.sum.{u1} K (Distrib.toHasAdd.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (MulZeroClass.toHasZero.{u1} K (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) l) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {l : List.{u1} K}, (forall (x : K), (Membership.mem.{u1, u1} K (List.{u1} K) (List.instMembershipList.{u1} K) x l) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (List.sum.{u1} K (Distrib.toAdd.{u1} K (NonUnitalNonAssocSemiring.toDistrib.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (CommMonoidWithZero.toZero.{u1} K (CommGroupWithZero.toCommMonoidWithZero.{u1} K (Semifield.toCommGroupWithZero.{u1} K (Field.toSemifield.{u1} K _inst_1)))) l) s)\nCase conversion may be inaccurate. Consider using '#align subfield.list_sum_mem Subfield.list_sum_memₓ'. -/\n/-- Sum of a list of elements in a subfield is in the subfield. -/\nprotected theorem list_sum_mem {l : List K} : (∀ x ∈ l, x ∈ s) → l.Sum ∈ s :=\n  list_sum_mem\n#align subfield.list_sum_mem Subfield.list_sum_mem\n\n/- warning: subfield.multiset_prod_mem -> Subfield.multiset_prod_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (m : Multiset.{u1} K), (forall (a : K), (Membership.Mem.{u1, u1} K (Multiset.{u1} K) (Multiset.hasMem.{u1} K) a m) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) a s)) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (Multiset.prod.{u1} K (CommRing.toCommMonoid.{u1} K (Field.toCommRing.{u1} K _inst_1)) m) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (m : Multiset.{u1} K), (forall (a : K), (Membership.mem.{u1, u1} K (Multiset.{u1} K) (Multiset.instMembershipMultiset.{u1} K) a m) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) a s)) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (Multiset.prod.{u1} K (CommRing.toCommMonoid.{u1} K (Field.toCommRing.{u1} K _inst_1)) m) s)\nCase conversion may be inaccurate. Consider using '#align subfield.multiset_prod_mem Subfield.multiset_prod_memₓ'. -/\n/-- Product of a multiset of elements in a subfield is in the subfield. -/\nprotected theorem multiset_prod_mem (m : Multiset K) : (∀ a ∈ m, a ∈ s) → m.Prod ∈ s :=\n  multiset_prod_mem m\n#align subfield.multiset_prod_mem Subfield.multiset_prod_mem\n\n/- warning: subfield.multiset_sum_mem -> Subfield.multiset_sum_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (m : Multiset.{u1} K), (forall (a : K), (Membership.Mem.{u1, u1} K (Multiset.{u1} K) (Multiset.hasMem.{u1} K) a m) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) a s)) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (Multiset.sum.{u1} K (AddCommGroup.toAddCommMonoid.{u1} K (NonUnitalNonAssocRing.toAddCommGroup.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) m) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (m : Multiset.{u1} K), (forall (a : K), (Membership.mem.{u1, u1} K (Multiset.{u1} K) (Multiset.instMembershipMultiset.{u1} K) a m) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) a s)) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (Multiset.sum.{u1} K (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) m) s)\nCase conversion may be inaccurate. Consider using '#align subfield.multiset_sum_mem Subfield.multiset_sum_memₓ'. -/\n/-- Sum of a multiset of elements in a `subfield` is in the `subfield`. -/\nprotected theorem multiset_sum_mem (m : Multiset K) : (∀ a ∈ m, a ∈ s) → m.Sum ∈ s :=\n  multiset_sum_mem m\n#align subfield.multiset_sum_mem Subfield.multiset_sum_mem\n\n/- warning: subfield.prod_mem -> Subfield.prod_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {ι : Type.{u2}} {t : Finset.{u2} ι} {f : ι -> K}, (forall (c : ι), (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) c t) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (f c) s)) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (Finset.prod.{u1, u2} K ι (CommRing.toCommMonoid.{u1} K (Field.toCommRing.{u1} K _inst_1)) t (fun (i : ι) => f i)) s)\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] (s : Subfield.{u2} K _inst_1) {ι : Type.{u1}} {t : Finset.{u1} ι} {f : ι -> K}, (forall (c : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) c t) -> (Membership.mem.{u2, u2} K (Subfield.{u2} K _inst_1) (SetLike.instMembership.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1)) (f c) s)) -> (Membership.mem.{u2, u2} K (Subfield.{u2} K _inst_1) (SetLike.instMembership.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1)) (Finset.prod.{u2, u1} K ι (CommRing.toCommMonoid.{u2} K (Field.toCommRing.{u2} K _inst_1)) t (fun (i : ι) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subfield.prod_mem Subfield.prod_memₓ'. -/\n/-- Product of elements of a subfield indexed by a `finset` is in the subfield. -/\nprotected theorem prod_mem {ι : Type _} {t : Finset ι} {f : ι → K} (h : ∀ c ∈ t, f c ∈ s) :\n    (∏ i in t, f i) ∈ s :=\n  prod_mem h\n#align subfield.prod_mem Subfield.prod_mem\n\n/- warning: subfield.sum_mem -> Subfield.sum_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {ι : Type.{u2}} {t : Finset.{u2} ι} {f : ι -> K}, (forall (c : ι), (Membership.Mem.{u2, u2} ι (Finset.{u2} ι) (Finset.hasMem.{u2} ι) c t) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (f c) s)) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (Finset.sum.{u1, u2} K ι (AddCommGroup.toAddCommMonoid.{u1} K (NonUnitalNonAssocRing.toAddCommGroup.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) t (fun (i : ι) => f i)) s)\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] (s : Subfield.{u2} K _inst_1) {ι : Type.{u1}} {t : Finset.{u1} ι} {f : ι -> K}, (forall (c : ι), (Membership.mem.{u1, u1} ι (Finset.{u1} ι) (Finset.instMembershipFinset.{u1} ι) c t) -> (Membership.mem.{u2, u2} K (Subfield.{u2} K _inst_1) (SetLike.instMembership.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1)) (f c) s)) -> (Membership.mem.{u2, u2} K (Subfield.{u2} K _inst_1) (SetLike.instMembership.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1)) (Finset.sum.{u2, u1} K ι (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} K (NonAssocRing.toNonUnitalNonAssocRing.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_1)))))) t (fun (i : ι) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subfield.sum_mem Subfield.sum_memₓ'. -/\n/-- Sum of elements in a `subfield` indexed by a `finset` is in the `subfield`. -/\nprotected theorem sum_mem {ι : Type _} {t : Finset ι} {f : ι → K} (h : ∀ c ∈ t, f c ∈ s) :\n    (∑ i in t, f i) ∈ s :=\n  sum_mem h\n#align subfield.sum_mem Subfield.sum_mem\n\n/- warning: subfield.pow_mem -> Subfield.pow_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (forall (n : Nat), Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (HPow.hPow.{u1, 0, u1} K Nat K (instHPow.{u1, 0} K Nat (Monoid.Pow.{u1} K (Ring.toMonoid.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) x n) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (forall (n : Nat), Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (HPow.hPow.{u1, 0, u1} K Nat K (instHPow.{u1, 0} K Nat (Monoid.Pow.{u1} K (MonoidWithZero.toMonoid.{u1} K (Semiring.toMonoidWithZero.{u1} K (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_1))))))) x n) s)\nCase conversion may be inaccurate. Consider using '#align subfield.pow_mem Subfield.pow_memₓ'. -/\nprotected theorem pow_mem {x : K} (hx : x ∈ s) (n : ℕ) : x ^ n ∈ s :=\n  pow_mem hx n\n#align subfield.pow_mem Subfield.pow_mem\n\n/- warning: subfield.zsmul_mem -> Subfield.zsmul_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (forall (n : Int), Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (SMul.smul.{0, u1} Int K (SubNegMonoid.SMulInt.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) n x) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (forall (n : Int), Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (HSMul.hSMul.{0, u1, u1} Int K K (instHSMul.{0, u1} Int K (SubNegMonoid.SMulInt.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) n x) s)\nCase conversion may be inaccurate. Consider using '#align subfield.zsmul_mem Subfield.zsmul_memₓ'. -/\nprotected theorem zsmul_mem {x : K} (hx : x ∈ s) (n : ℤ) : n • x ∈ s :=\n  zsmul_mem hx n\n#align subfield.zsmul_mem Subfield.zsmul_mem\n\n/- warning: subfield.coe_int_mem -> Subfield.coe_int_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (n : Int), Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Int K (HasLiftT.mk.{1, succ u1} Int K (CoeTCₓ.coe.{1, succ u1} Int K (Int.castCoe.{u1} K (AddGroupWithOne.toHasIntCast.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) n) s\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (n : Int), Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (Int.cast.{u1} K (Ring.toIntCast.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) n) s\nCase conversion may be inaccurate. Consider using '#align subfield.coe_int_mem Subfield.coe_int_memₓ'. -/\nprotected theorem coe_int_mem (n : ℤ) : (n : K) ∈ s :=\n  coe_int_mem s n\n#align subfield.coe_int_mem Subfield.coe_int_mem\n\n/- warning: subfield.zpow_mem -> Subfield.zpow_mem is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) -> (forall (n : Int), Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (HPow.hPow.{u1, 0, u1} K Int K (instHPow.{u1, 0} K Int (DivInvMonoid.Pow.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x n) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) {x : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) -> (forall (n : Int), Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) (HPow.hPow.{u1, 0, u1} K Int K (instHPow.{u1, 0} K Int (DivInvMonoid.Pow.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) x n) s)\nCase conversion may be inaccurate. Consider using '#align subfield.zpow_mem Subfield.zpow_memₓ'. -/\ntheorem zpow_mem {x : K} (hx : x ∈ s) (n : ℤ) : x ^ n ∈ s :=\n  by\n  cases n\n  · simpa using s.pow_mem hx n\n  · simpa [pow_succ] using s.inv_mem (s.mul_mem hx (s.pow_mem hx n))\n#align subfield.zpow_mem Subfield.zpow_mem\n\ninstance : Ring s :=\n  s.toSubring.toRing\n\ninstance : Div s :=\n  ⟨fun x y => ⟨x / y, s.div_mem x.2 y.2⟩⟩\n\ninstance : Inv s :=\n  ⟨fun x => ⟨x⁻¹, s.inv_mem x.2⟩⟩\n\ninstance : Pow s ℤ :=\n  ⟨fun x z => ⟨x ^ z, s.zpow_mem x.2 z⟩⟩\n\n/- warning: subfield.to_field -> Subfield.toField is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Field.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Field.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s))\nCase conversion may be inaccurate. Consider using '#align subfield.to_field Subfield.toFieldₓ'. -/\n/-- A subfield inherits a field structure -/\ninstance toField : Field s :=\n  Subtype.coe_injective.Field (coe : s → K) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)\n    (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ => rfl) fun _ => rfl\n#align subfield.to_field Subfield.toField\n\n/- warning: subfield.to_linear_ordered_field -> Subfield.toLinearOrderedField is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_4 : LinearOrderedField.{u1} K] (s : Subfield.{u1} K (LinearOrderedField.toField.{u1} K _inst_4)), LinearOrderedField.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K (LinearOrderedField.toField.{u1} K _inst_4)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K (LinearOrderedField.toField.{u1} K _inst_4)) K (Subfield.setLike.{u1} K (LinearOrderedField.toField.{u1} K _inst_4))) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_4 : LinearOrderedField.{u1} K] (s : Subfield.{u1} K (LinearOrderedField.toField.{u1} K _inst_4)), LinearOrderedField.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K (LinearOrderedField.toField.{u1} K _inst_4)) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K (LinearOrderedField.toField.{u1} K _inst_4)) K (Subfield.instSetLikeSubfield.{u1} K (LinearOrderedField.toField.{u1} K _inst_4))) x s))\nCase conversion may be inaccurate. Consider using '#align subfield.to_linear_ordered_field Subfield.toLinearOrderedFieldₓ'. -/\n/-- A subfield of a `linear_ordered_field` is a `linear_ordered_field`. -/\ninstance toLinearOrderedField {K} [LinearOrderedField K] (s : Subfield K) : LinearOrderedField s :=\n  Subtype.coe_injective.LinearOrderedField coe rfl rfl (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)\n    (fun _ => rfl) (fun _ => rfl) (fun _ _ => rfl) fun _ _ => rfl\n#align subfield.to_linear_ordered_field Subfield.toLinearOrderedField\n\n/- warning: subfield.coe_add -> Subfield.coe_add is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (y : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (HAdd.hAdd.{u1, u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (instHAdd.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (AddMemClass.add.{u1, u1} K (Subfield.{u1} K _inst_1) (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))) (Subfield.setLike.{u1} K _inst_1) (AddSubmonoidClass.to_addMemClass.{u1, u1} (Subfield.{u1} K _inst_1) K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) (Subfield.setLike.{u1} K _inst_1) (SubsemiringClass.to_addSubmonoidClass.{u1, u1} (Subfield.{u1} K _inst_1) K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subfield.setLike.{u1} K _inst_1) (SubringClass.to_subsemiringClass.{u1, u1} (Subfield.{u1} K _inst_1) K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.setLike.{u1} K _inst_1) (SubfieldClass.to_subringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.setLike.{u1} K _inst_1) (Subfield.subfieldClass.{u1} K _inst_1))))) s)) x y)) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (Distrib.toHasAdd.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) y))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (y : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (HAdd.hAdd.{u1, u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (instHAdd.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Distrib.toAdd.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Ring.toNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subfield.instRingSubtypeMemSubfieldInstMembershipInstSetLikeSubfield.{u1} K _inst_1 s))))))) x y)) (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (Distrib.toAdd.{u1} K (NonUnitalNonAssocSemiring.toDistrib.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) x) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) y))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_add Subfield.coe_addₓ'. -/\n@[simp, norm_cast]\ntheorem coe_add (x y : s) : (↑(x + y) : K) = ↑x + ↑y :=\n  rfl\n#align subfield.coe_add Subfield.coe_add\n\n/- warning: subfield.coe_sub -> Subfield.coe_sub is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (y : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (HSub.hSub.{u1, u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (instHSub.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (AddSubgroupClass.sub.{u1, u1} K (Subfield.{u1} K _inst_1) (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subfield.setLike.{u1} K _inst_1) (SubringClass.addSubgroupClass.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1) (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (SubfieldClass.to_subringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.setLike.{u1} K _inst_1) (Subfield.subfieldClass.{u1} K _inst_1))) s)) x y)) (HSub.hSub.{u1, u1, u1} K K K (instHSub.{u1} K (SubNegMonoid.toHasSub.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) y))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (y : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (HSub.hSub.{u1, u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (instHSub.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (AddSubgroupClass.sub.{u1, u1} K (Subfield.{u1} K _inst_1) (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subfield.instSetLikeSubfield.{u1} K _inst_1) (SubringClass.addSubgroupClass.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (SubfieldClass.toSubringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.instSubfieldClassSubfieldInstSetLikeSubfield.{u1} K _inst_1))) s)) x y)) (HSub.hSub.{u1, u1, u1} K K K (instHSub.{u1} K (Ring.toSub.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) x) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) y))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_sub Subfield.coe_subₓ'. -/\n@[simp, norm_cast]\ntheorem coe_sub (x y : s) : (↑(x - y) : K) = ↑x - ↑y :=\n  rfl\n#align subfield.coe_sub Subfield.coe_sub\n\n/- warning: subfield.coe_neg -> Subfield.coe_neg is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (Neg.neg.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (AddSubgroupClass.neg.{u1, u1} K (Subfield.{u1} K _inst_1) (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subfield.setLike.{u1} K _inst_1) (SubringClass.addSubgroupClass.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1) (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (SubfieldClass.to_subringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.setLike.{u1} K _inst_1) (Subfield.subfieldClass.{u1} K _inst_1))) s) x)) (Neg.neg.{u1} K (SubNegMonoid.toHasNeg.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) x))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (Neg.neg.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (AddSubgroupClass.neg.{u1, u1} K (Subfield.{u1} K _inst_1) (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subfield.instSetLikeSubfield.{u1} K _inst_1) (SubringClass.addSubgroupClass.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (SubfieldClass.toSubringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.instSubfieldClassSubfieldInstSetLikeSubfield.{u1} K _inst_1))) s) x)) (Neg.neg.{u1} K (Ring.toNeg.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) x))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_neg Subfield.coe_negₓ'. -/\n@[simp, norm_cast]\ntheorem coe_neg (x : s) : (↑(-x) : K) = -↑x :=\n  rfl\n#align subfield.coe_neg Subfield.coe_neg\n\n/- warning: subfield.coe_mul -> Subfield.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (y : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (HMul.hMul.{u1, u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (instHMul.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (MulMemClass.mul.{u1, u1} K (Subfield.{u1} K _inst_1) (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Subfield.setLike.{u1} K _inst_1) (SubmonoidClass.to_mulMemClass.{u1, u1} (Subfield.{u1} K _inst_1) K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subfield.setLike.{u1} K _inst_1) (SubsemiringClass.to_submonoidClass.{u1, u1} (Subfield.{u1} K _inst_1) K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subfield.setLike.{u1} K _inst_1) (SubringClass.to_subsemiringClass.{u1, u1} (Subfield.{u1} K _inst_1) K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.setLike.{u1} K _inst_1) (SubfieldClass.to_subringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.setLike.{u1} K _inst_1) (Subfield.subfieldClass.{u1} K _inst_1))))) s)) x y)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) y))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (y : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (HMul.hMul.{u1, u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (instHMul.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Submonoid.mul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))))) x y)) (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) x) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) y))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_mul Subfield.coe_mulₓ'. -/\n@[simp, norm_cast]\ntheorem coe_mul (x y : s) : (↑(x * y) : K) = ↑x * ↑y :=\n  rfl\n#align subfield.coe_mul Subfield.coe_mul\n\n/- warning: subfield.coe_div -> Subfield.coe_div is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (y : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (HDiv.hDiv.{u1, u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (instHDiv.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Subfield.hasDiv.{u1} K _inst_1 s)) x y)) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) y))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (y : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (HDiv.hDiv.{u1, u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (instHDiv.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subfield.instDivSubtypeMemSubfieldInstMembershipInstSetLikeSubfield.{u1} K _inst_1 s)) x y)) (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (Field.toDiv.{u1} K _inst_1)) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) x) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) y))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_div Subfield.coe_divₓ'. -/\n@[simp, norm_cast]\ntheorem coe_div (x y : s) : (↑(x / y) : K) = ↑x / ↑y :=\n  rfl\n#align subfield.coe_div Subfield.coe_div\n\n/- warning: subfield.coe_inv -> Subfield.coe_inv is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (Inv.inv.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Subfield.hasInv.{u1} K _inst_1 s) x)) (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) x))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1) (x : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (Inv.inv.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subfield.instInvSubtypeMemSubfieldInstMembershipInstSetLikeSubfield.{u1} K _inst_1 s) x)) (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) x))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_inv Subfield.coe_invₓ'. -/\n@[simp, norm_cast]\ntheorem coe_inv (x : s) : (↑x⁻¹ : K) = (↑x)⁻¹ :=\n  rfl\n#align subfield.coe_inv Subfield.coe_inv\n\n/- warning: subfield.coe_zero -> Subfield.coe_zero is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (OfNat.ofNat.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) 0 (OfNat.mk.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) 0 (Zero.zero.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (ZeroMemClass.zero.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1) (AddZeroClass.toHasZero.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))) (AddSubmonoidClass.to_zeroMemClass.{u1, u1} (Subfield.{u1} K _inst_1) K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) (Subfield.setLike.{u1} K _inst_1) (SubsemiringClass.to_addSubmonoidClass.{u1, u1} (Subfield.{u1} K _inst_1) K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subfield.setLike.{u1} K _inst_1) (SubringClass.to_subsemiringClass.{u1, u1} (Subfield.{u1} K _inst_1) K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.setLike.{u1} K _inst_1) (SubfieldClass.to_subringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.setLike.{u1} K _inst_1) (Subfield.subfieldClass.{u1} K _inst_1))))) s))))) (OfNat.ofNat.{u1} K 0 (OfNat.mk.{u1} K 0 (Zero.zero.{u1} K (MulZeroClass.toHasZero.{u1} K (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (OfNat.ofNat.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) 0 (Zero.toOfNat0.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (ZeroMemClass.zero.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (CommMonoidWithZero.toZero.{u1} K (CommGroupWithZero.toCommMonoidWithZero.{u1} K (Semifield.toCommGroupWithZero.{u1} K (Field.toSemifield.{u1} K _inst_1)))) (AddSubmonoidClass.toZeroMemClass.{u1, u1} (Subfield.{u1} K _inst_1) K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subfield.instSetLikeSubfield.{u1} K _inst_1) (SubsemiringClass.toAddSubmonoidClass.{u1, u1} (Subfield.{u1} K _inst_1) K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subfield.instSetLikeSubfield.{u1} K _inst_1) (SubringClass.toSubsemiringClass.{u1, u1} (Subfield.{u1} K _inst_1) K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.instSetLikeSubfield.{u1} K _inst_1) (SubfieldClass.toSubringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.instSubfieldClassSubfieldInstSetLikeSubfield.{u1} K _inst_1))))) s)))) (OfNat.ofNat.{u1} K 0 (Zero.toOfNat0.{u1} K (CommMonoidWithZero.toZero.{u1} K (CommGroupWithZero.toCommMonoidWithZero.{u1} K (Semifield.toCommGroupWithZero.{u1} K (Field.toSemifield.{u1} K _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_zero Subfield.coe_zeroₓ'. -/\n@[simp, norm_cast]\ntheorem coe_zero : ((0 : s) : K) = 0 :=\n  rfl\n#align subfield.coe_zero Subfield.coe_zero\n\n/- warning: subfield.coe_one -> Subfield.coe_one is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} K ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))) (OfNat.ofNat.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) 1 (OfNat.mk.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) 1 (One.one.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (OneMemClass.one.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1) (AddMonoidWithOne.toOne.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (AddSubmonoidWithOneClass.to_oneMemClass.{u1, u1} (Subfield.{u1} K _inst_1) K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subfield.setLike.{u1} K _inst_1) (SubsemiringClass.addSubmonoidWithOneClass.{u1, u1} (Subfield.{u1} K _inst_1) K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subfield.setLike.{u1} K _inst_1) (SubringClass.to_subsemiringClass.{u1, u1} (Subfield.{u1} K _inst_1) K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.setLike.{u1} K _inst_1) (SubfieldClass.to_subringClass.{u1, u1} (Subfield.{u1} K _inst_1) K _inst_1 (Subfield.setLike.{u1} K _inst_1) (Subfield.subfieldClass.{u1} K _inst_1))))) s))))) (OfNat.ofNat.{u1} K 1 (OfNat.mk.{u1} K 1 (One.one.{u1} K (AddMonoidWithOne.toOne.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} K (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)) (OfNat.ofNat.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) 1 (One.toOfNat1.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Submonoid.one.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))))))) (OfNat.ofNat.{u1} K 1 (One.toOfNat1.{u1} K (NonAssocRing.toOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_one Subfield.coe_oneₓ'. -/\n@[simp, norm_cast]\ntheorem coe_one : ((1 : s) : K) = 1 :=\n  rfl\n#align subfield.coe_one Subfield.coe_one\n\nend DerivedFromSubfieldClass\n\n/- warning: subfield.subtype -> Subfield.subtype is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (NonAssocRing.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Ring.toNonAssocRing.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Subfield.ring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), RingHom.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))\nCase conversion may be inaccurate. Consider using '#align subfield.subtype Subfield.subtypeₓ'. -/\n/-- The embedding from a subfield of the field `K` to `K`. -/\ndef subtype (s : Subfield K) : s →+* K :=\n  { s.toSubmonoid.Subtype, s.toAddSubgroup.Subtype with toFun := coe }\n#align subfield.subtype Subfield.subtype\n\n/- warning: subfield.to_algebra -> Subfield.toAlgebra is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Algebra.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (SubsemiringClass.toCommSemiring.{u1, u1} (Subfield.{u1} K _inst_1) s K (Semifield.toCommSemiring.{u1} K (Field.toSemifield.{u1} K _inst_1)) (Subfield.setLike.{u1} K _inst_1) (Subfield.toAlgebra._proof_1.{u1} K _inst_1)) (Ring.toSemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Algebra.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Semifield.toCommSemiring.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Field.toSemifield.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subfield.toField.{u1} K _inst_1 s))) (DivisionSemiring.toSemiring.{u1} K (Semifield.toDivisionSemiring.{u1} K (Field.toSemifield.{u1} K _inst_1)))\nCase conversion may be inaccurate. Consider using '#align subfield.to_algebra Subfield.toAlgebraₓ'. -/\ninstance toAlgebra : Algebra s K :=\n  RingHom.toAlgebra s.Subtype\n#align subfield.to_algebra Subfield.toAlgebra\n\n/- warning: subfield.coe_subtype -> Subfield.coe_subtype is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} ((coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) -> K) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (NonAssocRing.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Ring.toNonAssocRing.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Subfield.ring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (fun (_x : RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (NonAssocRing.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Ring.toNonAssocRing.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Subfield.ring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) => (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) -> K) (RingHom.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (NonAssocRing.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Ring.toNonAssocRing.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (Subfield.ring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subfield.subtype.{u1} K _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (coeSubtype.{succ u1} K (fun (x : K) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (forall (ᾰ : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) => K) ᾰ) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (fun (_x : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) => K) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (NonUnitalNonAssocSemiring.toMul.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))))) (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (RingHom.instRingHomClassRingHom.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) (Subfield.subtype.{u1} K _inst_1 s)) (Subtype.val.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_subtype Subfield.coe_subtypeₓ'. -/\n@[simp]\ntheorem coe_subtype : ⇑s.Subtype = coe :=\n  rfl\n#align subfield.coe_subtype Subfield.coe_subtype\n\n/- warning: subfield.to_subring.subtype_eq_subtype -> Subfield.toSubring_subtype_eq_subtype is a dubious translation:\nlean 3 declaration is\n  forall (F : Type.{u1}) [_inst_4 : Field.{u1} F] (S : Subfield.{u1} F _inst_4), Eq.{succ u1} (RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) F (Subring.setLike.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)))) (Subfield.toSubring.{u1} F _inst_4 S)) F (NonAssocRing.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) F (Subring.setLike.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)))) (Subfield.toSubring.{u1} F _inst_4 S)) (Ring.toNonAssocRing.{u1} (coeSort.{succ u1, succ (succ u1)} (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) F (Subring.setLike.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)))) (Subfield.toSubring.{u1} F _inst_4 S)) (Subring.toRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)) (Subfield.toSubring.{u1} F _inst_4 S)))) (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))))) (Subring.subtype.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)) (Subfield.toSubring.{u1} F _inst_4 S)) (Subfield.subtype.{u1} F _inst_4 S)\nbut is expected to have type\n  forall (F : Type.{u1}) [_inst_4 : Field.{u1} F] (S : Subfield.{u1} F _inst_4), Eq.{succ u1} (RingHom.{u1, u1} (Subtype.{succ u1} F (fun (x : F) => Membership.mem.{u1, u1} F (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) (SetLike.instMembership.{u1, u1} (Subring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))) F (Subring.instSetLikeSubring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)))) x (Subfield.toSubring.{u1} F _inst_4 S))) F (Subsemiring.toNonAssocSemiring.{u1} F (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)))) (Subring.toSubsemiring.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)) (Subfield.toSubring.{u1} F _inst_4 S))) (NonAssocRing.toNonAssocSemiring.{u1} F (Ring.toNonAssocRing.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4))))) (Subring.subtype.{u1} F (DivisionRing.toRing.{u1} F (Field.toDivisionRing.{u1} F _inst_4)) (Subfield.toSubring.{u1} F _inst_4 S)) (Subfield.subtype.{u1} F _inst_4 S)\nCase conversion may be inaccurate. Consider using '#align subfield.to_subring.subtype_eq_subtype Subfield.toSubring_subtype_eq_subtypeₓ'. -/\ntheorem Subfield.toSubring_subtype_eq_subtype (F : Type _) [Field F] (S : Subfield F) :\n    S.toSubring.Subtype = S.Subtype :=\n  rfl\n#align subfield.to_subring.subtype_eq_subtype Subfield.toSubring_subtype_eq_subtype\n\n/-! # Partial order -/\n\n\nvariable (s t)\n\n/- warning: subfield.mem_to_submonoid -> Subfield.mem_toSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.Mem.{u1, u1} K (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) K (Submonoid.setLike.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) x (Subfield.toSubmonoid.{u1} K _inst_1 s)) (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.mem.{u1, u1} K (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) K (Submonoid.instSetLikeSubmonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) x (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s)))) (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align subfield.mem_to_submonoid Subfield.mem_toSubmonoidₓ'. -/\n@[simp]\ntheorem mem_toSubmonoid {s : Subfield K} {x : K} : x ∈ s.toSubmonoid ↔ x ∈ s :=\n  Iff.rfl\n#align subfield.mem_to_submonoid Subfield.mem_toSubmonoid\n\n/- warning: subfield.coe_to_submonoid -> Subfield.coe_toSubmonoid is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) K (Submonoid.setLike.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) (Subfield.toSubmonoid.{u1} K _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Submonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) K (Submonoid.instSetLikeSubmonoid.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s)))) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)\nCase conversion may be inaccurate. Consider using '#align subfield.coe_to_submonoid Subfield.coe_toSubmonoidₓ'. -/\n@[simp]\ntheorem coe_toSubmonoid : (s.toSubmonoid : Set K) = s :=\n  rfl\n#align subfield.coe_to_submonoid Subfield.coe_toSubmonoid\n\n/- warning: subfield.mem_to_add_subgroup -> Subfield.mem_toAddSubgroup is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.Mem.{u1, u1} K (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (SetLike.hasMem.{u1, u1} (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) K (AddSubgroup.setLike.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) x (Subfield.toAddSubgroup.{u1} K _inst_1 s)) (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.mem.{u1, u1} K (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (SetLike.instMembership.{u1, u1} (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) K (AddSubgroup.instSetLikeAddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) x (Subfield.toAddSubgroup.{u1} K _inst_1 s)) (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)\nCase conversion may be inaccurate. Consider using '#align subfield.mem_to_add_subgroup Subfield.mem_toAddSubgroupₓ'. -/\n@[simp]\ntheorem mem_toAddSubgroup {s : Subfield K} {x : K} : x ∈ s.toAddSubgroup ↔ x ∈ s :=\n  Iff.rfl\n#align subfield.mem_to_add_subgroup Subfield.mem_toAddSubgroup\n\n/- warning: subfield.coe_to_add_subgroup -> Subfield.coe_toAddSubgroup is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) K (AddSubgroup.setLike.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))) (Subfield.toAddSubgroup.{u1} K _inst_1 s)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) s)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (AddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) K (AddSubgroup.instSetLikeAddSubgroup.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (Ring.toAddGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Subfield.toAddSubgroup.{u1} K _inst_1 s)) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)\nCase conversion may be inaccurate. Consider using '#align subfield.coe_to_add_subgroup Subfield.coe_toAddSubgroupₓ'. -/\n@[simp]\ntheorem coe_toAddSubgroup : (s.toAddSubgroup : Set K) = s :=\n  rfl\n#align subfield.coe_to_add_subgroup Subfield.coe_toAddSubgroup\n\n/-! # top -/\n\n\n/-- The subfield of `K` containing all elements of `K`. -/\ninstance : Top (Subfield K) :=\n  ⟨{ (⊤ : Subring K) with inv_mem' := fun x _ => Subring.mem_top x }⟩\n\ninstance : Inhabited (Subfield K) :=\n  ⟨⊤⟩\n\n/- warning: subfield.mem_top -> Subfield.mem_top is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (x : K), Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (x : K), Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_top Subfield.mem_topₓ'. -/\n@[simp]\ntheorem mem_top (x : K) : x ∈ (⊤ : Subfield K) :=\n  Set.mem_univ x\n#align subfield.mem_top Subfield.mem_top\n\n/- warning: subfield.coe_top -> Subfield.coe_top is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))) (Set.univ.{u1} K)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1))) (Set.univ.{u1} K)\nCase conversion may be inaccurate. Consider using '#align subfield.coe_top Subfield.coe_topₓ'. -/\n@[simp]\ntheorem coe_top : ((⊤ : Subfield K) : Set K) = Set.univ :=\n  rfl\n#align subfield.coe_top Subfield.coe_top\n\n/- warning: subfield.top_equiv -> Subfield.topEquiv is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], RingEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))) K (MulMemClass.mul.{u1, u1} K (Subfield.{u1} K _inst_1) (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Subfield.setLike.{u1} K _inst_1) (Subfield.topEquiv._proof_1.{u1} K _inst_1) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))) (AddMemClass.add.{u1, u1} K (Subfield.{u1} K _inst_1) (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))) (Subfield.setLike.{u1} K _inst_1) (Subfield.topEquiv._proof_2.{u1} K _inst_1) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))) (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Distrib.toHasAdd.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], RingEquiv.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))) K (Submonoid.mul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))))) (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (Distrib.toAdd.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))) (Ring.toNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))) (Subfield.instRingSubtypeMemSubfieldInstMembershipInstSetLikeSubfield.{u1} K _inst_1 (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))))))) (Distrib.toAdd.{u1} K (NonUnitalNonAssocSemiring.toDistrib.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align subfield.top_equiv Subfield.topEquivₓ'. -/\n/-- The ring equiv between the top element of `subfield K` and `K`. -/\n@[simps]\ndef topEquiv : (⊤ : Subfield K) ≃+* K :=\n  Subsemiring.topEquiv\n#align subfield.top_equiv Subfield.topEquiv\n\n/-! # comap -/\n\n\nvariable (f : K →+* L)\n\n#print Subfield.comap /-\n/-- The preimage of a subfield along a ring homomorphism is a subfield. -/\ndef comap (s : Subfield L) : Subfield K :=\n  { s.toSubring.comap f with\n    inv_mem' := fun x hx =>\n      show f x⁻¹ ∈ s by\n        rw [map_inv₀ f]\n        exact s.inv_mem hx }\n#align subfield.comap Subfield.comap\n-/\n\n/- warning: subfield.coe_comap -> Subfield.coe_comap is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : Subfield.{u2} L _inst_2), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f s)) (Set.preimage.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Subfield.{u2} L _inst_2) (Set.{u2} L) (HasLiftT.mk.{succ u2, succ u2} (Subfield.{u2} L _inst_2) (Set.{u2} L) (CoeTCₓ.coe.{succ u2, succ u2} (Subfield.{u2} L _inst_2) (Set.{u2} L) (SetLike.Set.hasCoeT.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)))) s))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : Subfield.{u2} L _inst_2), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f s)) (Set.preimage.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) (SetLike.coe.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2) s))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_comap Subfield.coe_comapₓ'. -/\n@[simp]\ntheorem coe_comap (s : Subfield L) : (s.comap f : Set K) = f ⁻¹' s :=\n  rfl\n#align subfield.coe_comap Subfield.coe_comap\n\n/- warning: subfield.mem_comap -> Subfield.mem_comap is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {s : Subfield.{u2} L _inst_2} {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {x : K}, Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f s)) (Membership.Mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.hasMem.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f x) s)\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {s : Subfield.{u2} L _inst_2} {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {x : K}, Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f s)) (Membership.mem.{u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) x) (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f x) s)\nCase conversion may be inaccurate. Consider using '#align subfield.mem_comap Subfield.mem_comapₓ'. -/\n@[simp]\ntheorem mem_comap {s : Subfield L} {f : K →+* L} {x : K} : x ∈ s.comap f ↔ f x ∈ s :=\n  Iff.rfl\n#align subfield.mem_comap Subfield.mem_comap\n\n#print Subfield.comap_comap /-\ntheorem comap_comap (s : Subfield M) (g : L →+* M) (f : K →+* L) :\n    (s.comap g).comap f = s.comap (g.comp f) :=\n  rfl\n#align subfield.comap_comap Subfield.comap_comap\n-/\n\n/-! # map -/\n\n\n#print Subfield.map /-\n/-- The image of a subfield along a ring homomorphism is a subfield. -/\ndef map (s : Subfield K) : Subfield L :=\n  { s.toSubring.map f with\n    inv_mem' := by\n      rintro _ ⟨x, hx, rfl⟩\n      exact ⟨x⁻¹, s.inv_mem hx, map_inv₀ f x⟩ }\n#align subfield.map Subfield.map\n-/\n\n/- warning: subfield.coe_map -> Subfield.coe_map is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (s : Subfield.{u1} K _inst_1) (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Set.{u2} L) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Subfield.{u2} L _inst_2) (Set.{u2} L) (HasLiftT.mk.{succ u2, succ u2} (Subfield.{u2} L _inst_2) (Set.{u2} L) (CoeTCₓ.coe.{succ u2, succ u2} (Subfield.{u2} L _inst_2) (Set.{u2} L) (SetLike.Set.hasCoeT.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)))) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s)) (Set.image.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) s))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (s : Subfield.{u1} K _inst_1) (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Set.{u2} L) (SetLike.coe.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s)) (Set.image.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_map Subfield.coe_mapₓ'. -/\n@[simp]\ntheorem coe_map : (s.map f : Set L) = f '' s :=\n  rfl\n#align subfield.coe_map Subfield.coe_map\n\n/- warning: subfield.mem_map -> Subfield.mem_map is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {s : Subfield.{u1} K _inst_1} {y : L}, Iff (Membership.Mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.hasMem.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) y (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s)) (Exists.{succ u1} K (fun (x : K) => Exists.{0} (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) (fun (H : Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s) => Eq.{succ u2} L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f x) y)))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {s : Subfield.{u1} K _inst_1} {y : L}, Iff (Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) y (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s)) (Exists.{succ u1} K (fun (x : K) => And (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s) (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (a : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) a) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f x) y)))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_map Subfield.mem_mapₓ'. -/\n@[simp]\ntheorem mem_map {f : K →+* L} {s : Subfield K} {y : L} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=\n  Set.mem_image_iff_bex\n#align subfield.mem_map Subfield.mem_map\n\n#print Subfield.map_map /-\ntheorem map_map (g : L →+* M) (f : K →+* L) : (s.map f).map g = s.map (g.comp f) :=\n  SetLike.ext' <| Set.image_image _ _ _\n#align subfield.map_map Subfield.map_map\n-/\n\n/- warning: subfield.map_le_iff_le_comap -> Subfield.map_le_iff_le_comap is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {s : Subfield.{u1} K _inst_1} {t : Subfield.{u2} L _inst_2}, Iff (LE.le.{u2} (Subfield.{u2} L _inst_2) (Preorder.toLE.{u2} (Subfield.{u2} L _inst_2) (PartialOrder.toPreorder.{u2} (Subfield.{u2} L _inst_2) (SetLike.partialOrder.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)))) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s) t) (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (SetLike.partialOrder.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) s (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f t))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {s : Subfield.{u1} K _inst_1} {t : Subfield.{u2} L _inst_2}, Iff (LE.le.{u2} (Subfield.{u2} L _inst_2) (Preorder.toLE.{u2} (Subfield.{u2} L _inst_2) (PartialOrder.toPreorder.{u2} (Subfield.{u2} L _inst_2) (SetLike.instPartialOrder.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)))) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s) t) (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)))) s (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f t))\nCase conversion may be inaccurate. Consider using '#align subfield.map_le_iff_le_comap Subfield.map_le_iff_le_comapₓ'. -/\ntheorem map_le_iff_le_comap {f : K →+* L} {s : Subfield K} {t : Subfield L} :\n    s.map f ≤ t ↔ s ≤ t.comap f :=\n  Set.image_subset_iff\n#align subfield.map_le_iff_le_comap Subfield.map_le_iff_le_comap\n\n/- warning: subfield.gc_map_comap -> Subfield.gc_map_comap is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), GaloisConnection.{u1, u2} (Subfield.{u1} K _inst_1) (Subfield.{u2} L _inst_2) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (SetLike.partialOrder.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1))) (PartialOrder.toPreorder.{u2} (Subfield.{u2} L _inst_2) (SetLike.partialOrder.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2))) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), GaloisConnection.{u1, u2} (Subfield.{u1} K _inst_1) (Subfield.{u2} L _inst_2) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (SetLike.instPartialOrder.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1))) (PartialOrder.toPreorder.{u2} (Subfield.{u2} L _inst_2) (SetLike.instPartialOrder.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2))) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align subfield.gc_map_comap Subfield.gc_map_comapₓ'. -/\ntheorem gc_map_comap (f : K →+* L) : GaloisConnection (map f) (comap f) := fun S T =>\n  map_le_iff_le_comap\n#align subfield.gc_map_comap Subfield.gc_map_comap\n\nend Subfield\n\nnamespace RingHom\n\nvariable (g : L →+* M) (f : K →+* L)\n\n/-! # range -/\n\n\n#print RingHom.fieldRange /-\n/-- The range of a ring homomorphism, as a subfield of the target. See Note [range copy pattern]. -/\ndef fieldRange : Subfield L :=\n  ((⊤ : Subfield K).map f).copy (Set.range f) Set.image_univ.symm\n#align ring_hom.field_range RingHom.fieldRange\n-/\n\n/- warning: ring_hom.coe_field_range -> RingHom.coe_fieldRange is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Set.{u2} L) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Subfield.{u2} L _inst_2) (Set.{u2} L) (HasLiftT.mk.{succ u2, succ u2} (Subfield.{u2} L _inst_2) (Set.{u2} L) (CoeTCₓ.coe.{succ u2, succ u2} (Subfield.{u2} L _inst_2) (Set.{u2} L) (SetLike.Set.hasCoeT.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)))) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Set.range.{u2, succ u1} L K (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Set.{u2} L) (SetLike.coe.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Set.range.{u2, succ u1} L K (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_field_range RingHom.coe_fieldRangeₓ'. -/\n@[simp]\ntheorem coe_fieldRange : (f.fieldRange : Set L) = Set.range f :=\n  rfl\n#align ring_hom.coe_field_range RingHom.coe_fieldRange\n\n/- warning: ring_hom.mem_field_range -> RingHom.mem_fieldRange is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {y : L}, Iff (Membership.Mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.hasMem.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) y (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Exists.{succ u1} K (fun (x : K) => Eq.{succ u2} L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f x) y))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {y : L}, Iff (Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) y (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Exists.{succ u1} K (fun (x : K) => Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f x) y))\nCase conversion may be inaccurate. Consider using '#align ring_hom.mem_field_range RingHom.mem_fieldRangeₓ'. -/\n@[simp]\ntheorem mem_fieldRange {f : K →+* L} {y : L} : y ∈ f.fieldRange ↔ ∃ x, f x = y :=\n  Iff.rfl\n#align ring_hom.mem_field_range RingHom.mem_fieldRange\n\n/- warning: ring_hom.field_range_eq_map -> RingHom.fieldRange_eq_map is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Subfield.{u2} L _inst_2) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1)))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Subfield.{u2} L _inst_2) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.field_range_eq_map RingHom.fieldRange_eq_mapₓ'. -/\ntheorem fieldRange_eq_map : f.fieldRange = Subfield.map f ⊤ :=\n  by\n  ext\n  simp\n#align ring_hom.field_range_eq_map RingHom.fieldRange_eq_map\n\n#print RingHom.map_fieldRange /-\ntheorem map_fieldRange : f.fieldRange.map g = (g.comp f).fieldRange := by\n  simpa only [field_range_eq_map] using (⊤ : Subfield K).map_map g f\n#align ring_hom.map_field_range RingHom.map_fieldRange\n-/\n\n/- warning: ring_hom.fintype_field_range -> RingHom.fintypeFieldRange is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] [_inst_4 : Fintype.{u1} K] [_inst_5 : DecidableEq.{succ u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Fintype.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] [_inst_4 : Fintype.{u1} K] [_inst_5 : DecidableEq.{succ u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Fintype.{u2} (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.fintype_field_range RingHom.fintypeFieldRangeₓ'. -/\n/-- The range of a morphism of fields is a fintype, if the domain is a fintype.\n\nNote that this instance can cause a diamond with `subtype.fintype` if `L` is also a fintype.-/\ninstance fintypeFieldRange [Fintype K] [DecidableEq L] (f : K →+* L) : Fintype f.fieldRange :=\n  Set.fintypeRange f\n#align ring_hom.fintype_field_range RingHom.fintypeFieldRange\n\nend RingHom\n\nnamespace Subfield\n\n/-! # inf -/\n\n\n/-- The inf of two subfields is their intersection. -/\ninstance : Inf (Subfield K) :=\n  ⟨fun s t =>\n    { s.toSubring ⊓ t.toSubring with\n      inv_mem' := fun x hx =>\n        Subring.mem_inf.mpr\n          ⟨s.inv_mem (Subring.mem_inf.mp hx).1, t.inv_mem (Subring.mem_inf.mp hx).2⟩ }⟩\n\n/- warning: subfield.coe_inf -> Subfield.coe_inf is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (p : Subfield.{u1} K _inst_1) (p' : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Inf.inf.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) p p')) (Inter.inter.{u1} (Set.{u1} K) (Set.hasInter.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) p) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) p'))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (p : Subfield.{u1} K _inst_1) (p' : Subfield.{u1} K _inst_1), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Inf.inf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instInfSubfield.{u1} K _inst_1) p p')) (Inter.inter.{u1} (Set.{u1} K) (Set.instInterSet.{u1} K) (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 p))))) (Subsemigroup.carrier.{u1} K (MulOneClass.toMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Submonoid.toSubsemigroup.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 p'))))))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_inf Subfield.coe_infₓ'. -/\n@[simp]\ntheorem coe_inf (p p' : Subfield K) : ((p ⊓ p' : Subfield K) : Set K) = p ∩ p' :=\n  rfl\n#align subfield.coe_inf Subfield.coe_inf\n\n/- warning: subfield.mem_inf -> Subfield.mem_inf is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {p : Subfield.{u1} K _inst_1} {p' : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (Inf.inf.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) p p')) (And (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x p) (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x p'))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {p : Subfield.{u1} K _inst_1} {p' : Subfield.{u1} K _inst_1} {x : K}, Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Inf.inf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instInfSubfield.{u1} K _inst_1) p p')) (And (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x p) (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x p'))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_inf Subfield.mem_infₓ'. -/\n@[simp]\ntheorem mem_inf {p p' : Subfield K} {x : K} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=\n  Iff.rfl\n#align subfield.mem_inf Subfield.mem_inf\n\ninstance : InfSet (Subfield K) :=\n  ⟨fun S =>\n    { infₛ (Subfield.toSubring '' S) with\n      inv_mem' := by\n        rintro x hx\n        apply subring.mem_Inf.mpr\n        rintro _ ⟨p, p_mem, rfl⟩\n        exact p.inv_mem (subring.mem_Inf.mp hx p.to_subring ⟨p, p_mem, rfl⟩) }⟩\n\n/- warning: subfield.coe_Inf -> Subfield.coe_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Set.{u1} (Subfield.{u1} K _inst_1)), Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (InfSet.infₛ.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) S)) (Set.interᵢ.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.interᵢ.{u1, 0} K (Membership.Mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.hasMem.{u1} (Subfield.{u1} K _inst_1)) s S) (fun (H : Membership.Mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.hasMem.{u1} (Subfield.{u1} K _inst_1)) s S) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) s)))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (S : Set.{u1} (Subfield.{u1} K _inst_1)), Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (InfSet.infₛ.{u1} (Subfield.{u1} K _inst_1) (Subfield.instInfSetSubfield.{u1} K _inst_1) S)) (Set.interᵢ.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.interᵢ.{u1, 0} K (Membership.mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.instMembershipSet.{u1} (Subfield.{u1} K _inst_1)) s S) (fun (H : Membership.mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.instMembershipSet.{u1} (Subfield.{u1} K _inst_1)) s S) => SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s)))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_Inf Subfield.coe_infₛₓ'. -/\n@[simp, norm_cast]\ntheorem coe_infₛ (S : Set (Subfield K)) : ((infₛ S : Subfield K) : Set K) = ⋂ s ∈ S, ↑s :=\n  show ((infₛ (Subfield.toSubring '' S) : Subring K) : Set K) = ⋂ s ∈ S, ↑s\n    by\n    ext x\n    rw [Subring.coe_infₛ, Set.mem_interᵢ, Set.mem_interᵢ]\n    exact\n      ⟨fun h s s' ⟨s_mem, s'_eq⟩ => h s.toSubring _ ⟨⟨s, s_mem, rfl⟩, s'_eq⟩,\n        fun h s s' ⟨⟨s'', s''_mem, s_eq⟩, (s'_eq : ↑s = s')⟩ =>\n        h s'' _ ⟨s''_mem, by simp [← s_eq, ← s'_eq]⟩⟩\n#align subfield.coe_Inf Subfield.coe_infₛ\n\n/- warning: subfield.mem_Inf -> Subfield.mem_infₛ is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} (Subfield.{u1} K _inst_1)} {x : K}, Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (InfSet.infₛ.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) S)) (forall (p : Subfield.{u1} K _inst_1), (Membership.Mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.hasMem.{u1} (Subfield.{u1} K _inst_1)) p S) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x p))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} (Subfield.{u1} K _inst_1)} {x : K}, Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (InfSet.infₛ.{u1} (Subfield.{u1} K _inst_1) (Subfield.instInfSetSubfield.{u1} K _inst_1) S)) (forall (p : Subfield.{u1} K _inst_1), (Membership.mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.instMembershipSet.{u1} (Subfield.{u1} K _inst_1)) p S) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x p))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_Inf Subfield.mem_infₛₓ'. -/\ntheorem mem_infₛ {S : Set (Subfield K)} {x : K} : x ∈ infₛ S ↔ ∀ p ∈ S, x ∈ p :=\n  Subring.mem_infₛ.trans\n    ⟨fun h p hp => h p.toSubring ⟨p, hp, rfl⟩, fun h p ⟨p', hp', p_eq⟩ => p_eq ▸ h p' hp'⟩\n#align subfield.mem_Inf Subfield.mem_infₛ\n\n#print Subfield.infₛ_toSubring /-\n@[simp]\ntheorem infₛ_toSubring (s : Set (Subfield K)) :\n    (infₛ s).toSubring = ⨅ t ∈ s, Subfield.toSubring t :=\n  by\n  ext x\n  rw [mem_to_subring, mem_Inf]\n  erw [Subring.mem_infₛ]\n  exact\n    ⟨fun h p ⟨p', hp⟩ => hp ▸ subring.mem_Inf.mpr fun p ⟨hp', hp⟩ => hp ▸ h _ hp', fun h p hp =>\n      h p.toSubring\n        ⟨p,\n          Subring.ext fun x =>\n            ⟨fun hx => subring.mem_Inf.mp hx _ ⟨hp, rfl⟩, fun hx =>\n              subring.mem_Inf.mpr fun p' ⟨hp, p'_eq⟩ => p'_eq ▸ hx⟩⟩⟩\n#align subfield.Inf_to_subring Subfield.infₛ_toSubring\n-/\n\n#print Subfield.isGLB_infₛ /-\ntheorem isGLB_infₛ (S : Set (Subfield K)) : IsGLB S (infₛ S) :=\n  by\n  refine' IsGLB.of_image (fun s t => show (s : Set K) ≤ t ↔ s ≤ t from SetLike.coe_subset_coe) _\n  convert isGLB_binfᵢ\n  exact coe_Inf _\n#align subfield.is_glb_Inf Subfield.isGLB_infₛ\n-/\n\n/-- Subfields of a ring form a complete lattice. -/\ninstance : CompleteLattice (Subfield K) :=\n  {\n    completeLatticeOfInf (Subfield K) isGLB_infₛ with\n    top := ⊤\n    le_top := fun s x hx => trivial\n    inf := (· ⊓ ·)\n    inf_le_left := fun s t x => And.left\n    inf_le_right := fun s t x => And.right\n    le_inf := fun s t₁ t₂ h₁ h₂ x hx => ⟨h₁ hx, h₂ hx⟩ }\n\n/-! # subfield closure of a subset -/\n\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:366:4: unsupported set replacement {(«expr / »(x, y)) | (x «expr ∈ » subring.closure[subring.closure] s) (y «expr ∈ » subring.closure[subring.closure] s)} -/\n#print Subfield.closure /-\n/-- The `subfield` generated by a set. -/\ndef closure (s : Set K) : Subfield K\n    where\n  carrier :=\n    \"./././Mathport/Syntax/Translate/Expr.lean:366:4: unsupported set replacement {(«expr / »(x, y)) | (x «expr ∈ » subring.closure[subring.closure] s) (y «expr ∈ » subring.closure[subring.closure] s)}\"\n  zero_mem' := ⟨0, Subring.zero_mem _, 1, Subring.one_mem _, div_one _⟩\n  one_mem' := ⟨1, Subring.one_mem _, 1, Subring.one_mem _, div_one _⟩\n  neg_mem' := fun x ⟨y, hy, z, hz, x_eq⟩ => ⟨-y, Subring.neg_mem _ hy, z, hz, x_eq ▸ neg_div _ _⟩\n  inv_mem' := fun x ⟨y, hy, z, hz, x_eq⟩ => ⟨z, hz, y, hy, x_eq ▸ (inv_div _ _).symm⟩\n  add_mem' x y x_mem y_mem :=\n    by\n    obtain ⟨nx, hnx, dx, hdx, rfl⟩ := id x_mem\n    obtain ⟨ny, hny, dy, hdy, rfl⟩ := id y_mem\n    by_cases hx0 : dx = 0; · rwa [hx0, div_zero, zero_add]\n    by_cases hy0 : dy = 0; · rwa [hy0, div_zero, add_zero]\n    exact\n      ⟨nx * dy + dx * ny, Subring.add_mem _ (Subring.mul_mem _ hnx hdy) (Subring.mul_mem _ hdx hny),\n        dx * dy, Subring.mul_mem _ hdx hdy, (div_add_div nx ny hx0 hy0).symm⟩\n  mul_mem' x y x_mem y_mem :=\n    by\n    obtain ⟨nx, hnx, dx, hdx, rfl⟩ := id x_mem\n    obtain ⟨ny, hny, dy, hdy, rfl⟩ := id y_mem\n    exact\n      ⟨nx * ny, Subring.mul_mem _ hnx hny, dx * dy, Subring.mul_mem _ hdx hdy,\n        (div_mul_div_comm _ _ _ _).symm⟩\n#align subfield.closure Subfield.closure\n-/\n\n/- warning: subfield.mem_closure_iff -> Subfield.mem_closure_iff is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {x : K}, Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (Subfield.closure.{u1} K _inst_1 s)) (Exists.{succ u1} K (fun (y : K) => Exists.{0} (Membership.Mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.hasMem.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) y (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s)) (fun (H : Membership.Mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.hasMem.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) y (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s)) => Exists.{succ u1} K (fun (z : K) => Exists.{0} (Membership.Mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.hasMem.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) z (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s)) (fun (H : Membership.Mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.hasMem.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.setLike.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) z (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s)) => Eq.{succ u1} K (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (DivInvMonoid.toHasDiv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) y z) x)))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {x : K}, Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Subfield.closure.{u1} K _inst_1 s)) (Exists.{succ u1} K (fun (y : K) => And (Membership.mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.instMembership.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) y (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s)) (Exists.{succ u1} K (fun (z : K) => And (Membership.mem.{u1, u1} K (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (SetLike.instMembership.{u1, u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) K (Subring.instSetLikeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) z (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s)) (Eq.{succ u1} K (HDiv.hDiv.{u1, u1, u1} K K K (instHDiv.{u1} K (Field.toDiv.{u1} K _inst_1)) y z) x)))))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_closure_iff Subfield.mem_closure_iffₓ'. -/\ntheorem mem_closure_iff {s : Set K} {x} :\n    x ∈ closure s ↔ ∃ y ∈ Subring.closure s, ∃ z ∈ Subring.closure s, y / z = x :=\n  Iff.rfl\n#align subfield.mem_closure_iff Subfield.mem_closure_iff\n\n/- warning: subfield.subring_closure_le -> Subfield.subring_closure_le is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Set.{u1} K), LE.le.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Preorder.toLE.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (PartialOrder.toPreorder.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Subring.completeLattice.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s) (Subfield.toSubring.{u1} K _inst_1 (Subfield.closure.{u1} K _inst_1 s))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Set.{u1} K), LE.le.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Preorder.toLE.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (PartialOrder.toPreorder.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) (Subring.instCompleteLatticeSubring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Subring.closure.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) s) (Subfield.toSubring.{u1} K _inst_1 (Subfield.closure.{u1} K _inst_1 s))\nCase conversion may be inaccurate. Consider using '#align subfield.subring_closure_le Subfield.subring_closure_leₓ'. -/\ntheorem subring_closure_le (s : Set K) : Subring.closure s ≤ (closure s).toSubring := fun x hx =>\n  ⟨x, hx, 1, Subring.one_mem _, div_one x⟩\n#align subfield.subring_closure_le Subfield.subring_closure_le\n\n/- warning: subfield.subset_closure -> Subfield.subset_closure is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K}, HasSubset.Subset.{u1} (Set.{u1} K) (Set.hasSubset.{u1} K) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Subfield.closure.{u1} K _inst_1 s))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K}, HasSubset.Subset.{u1} (Set.{u1} K) (Set.instHasSubsetSet.{u1} K) s (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 s))\nCase conversion may be inaccurate. Consider using '#align subfield.subset_closure Subfield.subset_closureₓ'. -/\n/-- The subfield generated by a set includes the set. -/\n@[simp]\ntheorem subset_closure {s : Set K} : s ⊆ closure s :=\n  Set.Subset.trans Subring.subset_closure (subring_closure_le s)\n#align subfield.subset_closure Subfield.subset_closure\n\n/- warning: subfield.not_mem_of_not_mem_closure -> Subfield.not_mem_of_not_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {P : K}, (Not (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) P (Subfield.closure.{u1} K _inst_1 s))) -> (Not (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) P s))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {P : K}, (Not (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) P (Subfield.closure.{u1} K _inst_1 s))) -> (Not (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) P s))\nCase conversion may be inaccurate. Consider using '#align subfield.not_mem_of_not_mem_closure Subfield.not_mem_of_not_mem_closureₓ'. -/\ntheorem not_mem_of_not_mem_closure {s : Set K} {P : K} (hP : P ∉ closure s) : P ∉ s := fun h =>\n  hP (subset_closure h)\n#align subfield.not_mem_of_not_mem_closure Subfield.not_mem_of_not_mem_closure\n\n/- warning: subfield.mem_closure -> Subfield.mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {x : K} {s : Set.{u1} K}, Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (Subfield.closure.{u1} K _inst_1 s)) (forall (S : Subfield.{u1} K _inst_1), (HasSubset.Subset.{u1} (Set.{u1} K) (Set.hasSubset.{u1} K) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) S)) -> (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x S))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {x : K} {s : Set.{u1} K}, Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Subfield.closure.{u1} K _inst_1 s)) (forall (S : Subfield.{u1} K _inst_1), (HasSubset.Subset.{u1} (Set.{u1} K) (Set.instHasSubsetSet.{u1} K) s (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) S)) -> (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x S))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_closure Subfield.mem_closureₓ'. -/\ntheorem mem_closure {x : K} {s : Set K} : x ∈ closure s ↔ ∀ S : Subfield K, s ⊆ S → x ∈ S :=\n  ⟨fun ⟨y, hy, z, hz, x_eq⟩ t le =>\n    x_eq ▸\n      t.div_mem (Subring.mem_closure.mp hy t.toSubring le)\n        (Subring.mem_closure.mp hz t.toSubring le),\n    fun h => h (closure s) subset_closure⟩\n#align subfield.mem_closure Subfield.mem_closure\n\n/- warning: subfield.closure_le -> Subfield.closure_le is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {t : Subfield.{u1} K _inst_1}, Iff (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 s) t) (HasSubset.Subset.{u1} (Set.{u1} K) (Set.hasSubset.{u1} K) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) t))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {t : Subfield.{u1} K _inst_1}, Iff (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 s) t) (HasSubset.Subset.{u1} (Set.{u1} K) (Set.instHasSubsetSet.{u1} K) s (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) t))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_le Subfield.closure_leₓ'. -/\n/-- A subfield `t` includes `closure s` if and only if it includes `s`. -/\n@[simp]\ntheorem closure_le {s : Set K} {t : Subfield K} : closure s ≤ t ↔ s ⊆ t :=\n  ⟨Set.Subset.trans subset_closure, fun h x hx => mem_closure.mp hx t h⟩\n#align subfield.closure_le Subfield.closure_le\n\n/- warning: subfield.closure_mono -> Subfield.closure_mono is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {{s : Set.{u1} K}} {{t : Set.{u1} K}}, (HasSubset.Subset.{u1} (Set.{u1} K) (Set.hasSubset.{u1} K) s t) -> (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 s) (Subfield.closure.{u1} K _inst_1 t))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {{s : Set.{u1} K}} {{t : Set.{u1} K}}, (HasSubset.Subset.{u1} (Set.{u1} K) (Set.instHasSubsetSet.{u1} K) s t) -> (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 s) (Subfield.closure.{u1} K _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_mono Subfield.closure_monoₓ'. -/\n/-- Subfield closure of a set is monotone in its argument: if `s ⊆ t`,\nthen `closure s ≤ closure t`. -/\ntheorem closure_mono ⦃s t : Set K⦄ (h : s ⊆ t) : closure s ≤ closure t :=\n  closure_le.2 <| Set.Subset.trans h subset_closure\n#align subfield.closure_mono Subfield.closure_mono\n\n/- warning: subfield.closure_eq_of_le -> Subfield.closure_eq_of_le is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {t : Subfield.{u1} K _inst_1}, (HasSubset.Subset.{u1} (Set.{u1} K) (Set.hasSubset.{u1} K) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) t)) -> (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))))) t (Subfield.closure.{u1} K _inst_1 s)) -> (Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 s) t)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {t : Subfield.{u1} K _inst_1}, (HasSubset.Subset.{u1} (Set.{u1} K) (Set.instHasSubsetSet.{u1} K) s (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) t)) -> (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) t (Subfield.closure.{u1} K _inst_1 s)) -> (Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 s) t)\nCase conversion may be inaccurate. Consider using '#align subfield.closure_eq_of_le Subfield.closure_eq_of_leₓ'. -/\ntheorem closure_eq_of_le {s : Set K} {t : Subfield K} (h₁ : s ⊆ t) (h₂ : t ≤ closure s) :\n    closure s = t :=\n  le_antisymm (closure_le.2 h₁) h₂\n#align subfield.closure_eq_of_le Subfield.closure_eq_of_le\n\n/- warning: subfield.closure_induction -> Subfield.closure_induction is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {p : K -> Prop} {x : K}, (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (Subfield.closure.{u1} K _inst_1 s)) -> (forall (x : K), (Membership.Mem.{u1, u1} K (Set.{u1} K) (Set.hasMem.{u1} K) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} K 1 (OfNat.mk.{u1} K 1 (One.one.{u1} K (AddMonoidWithOne.toOne.{u1} K (AddGroupWithOne.toAddMonoidWithOne.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))))) -> (forall (x : K) (y : K), (p x) -> (p y) -> (p (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (Distrib.toHasAdd.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) x y))) -> (forall (x : K), (p x) -> (p (Neg.neg.{u1} K (SubNegMonoid.toHasNeg.{u1} K (AddGroup.toSubNegMonoid.{u1} K (AddGroupWithOne.toAddGroup.{u1} K (AddCommGroupWithOne.toAddGroupWithOne.{u1} K (Ring.toAddCommGroupWithOne.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) x))) -> (forall (x : K), (p x) -> (p (Inv.inv.{u1} K (DivInvMonoid.toHasInv.{u1} K (DivisionRing.toDivInvMonoid.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x))) -> (forall (x : K) (y : K), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (Distrib.toHasMul.{u1} K (Ring.toDistrib.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) x y))) -> (p x)\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Set.{u1} K} {p : K -> Prop} {x : K}, (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (Subfield.closure.{u1} K _inst_1 s)) -> (forall (x : K), (Membership.mem.{u1, u1} K (Set.{u1} K) (Set.instMembershipSet.{u1} K) x s) -> (p x)) -> (p (OfNat.ofNat.{u1} K 1 (One.toOfNat1.{u1} K (NonAssocRing.toOne.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) -> (forall (x : K) (y : K), (p x) -> (p y) -> (p (HAdd.hAdd.{u1, u1, u1} K K K (instHAdd.{u1} K (Distrib.toAdd.{u1} K (NonUnitalNonAssocSemiring.toDistrib.{u1} K (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))))) x y))) -> (forall (x : K), (p x) -> (p (Neg.neg.{u1} K (Ring.toNeg.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))) x))) -> (forall (x : K), (p x) -> (p (Inv.inv.{u1} K (Field.toInv.{u1} K _inst_1) x))) -> (forall (x : K) (y : K), (p x) -> (p y) -> (p (HMul.hMul.{u1, u1, u1} K K K (instHMul.{u1} K (NonUnitalNonAssocRing.toMul.{u1} K (NonAssocRing.toNonUnitalNonAssocRing.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) x y))) -> (p x)\nCase conversion may be inaccurate. Consider using '#align subfield.closure_induction Subfield.closure_inductionₓ'. -/\n/-- An induction principle for closure membership. If `p` holds for `1`, and all elements\nof `s`, and is preserved under addition, negation, and multiplication, then `p` holds for all\nelements of the closure of `s`. -/\n@[elab_as_elim]\ntheorem closure_induction {s : Set K} {p : K → Prop} {x} (h : x ∈ closure s) (Hs : ∀ x ∈ s, p x)\n    (H1 : p 1) (Hadd : ∀ x y, p x → p y → p (x + y)) (Hneg : ∀ x, p x → p (-x))\n    (Hinv : ∀ x, p x → p x⁻¹) (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=\n  (@closure_le _ _ _\n        ⟨p, Hmul, H1, Hadd, @add_neg_self K _ 1 ▸ Hadd _ _ H1 (Hneg _ H1), Hneg, Hinv⟩).2\n    Hs h\n#align subfield.closure_induction Subfield.closure_induction\n\nvariable (K)\n\n/- warning: subfield.gi -> Subfield.gi is a dubious translation:\nlean 3 declaration is\n  forall (K : Type.{u1}) [_inst_1 : Field.{u1} K], GaloisInsertion.{u1, u1} (Set.{u1} K) (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Set.{u1} K) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} K) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} K) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} K) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} K) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} K) (Set.completeBooleanAlgebra.{u1} K))))))) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1)))) (Subfield.closure.{u1} K _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))))\nbut is expected to have type\n  forall (K : Type.{u1}) [_inst_1 : Field.{u1} K], GaloisInsertion.{u1, u1} (Set.{u1} K) (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Set.{u1} K) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} K) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} K) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} K) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} K) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} K) (Set.instCompleteBooleanAlgebraSet.{u1} K))))))) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1)))) (Subfield.closure.{u1} K _inst_1) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1))\nCase conversion may be inaccurate. Consider using '#align subfield.gi Subfield.giₓ'. -/\n/-- `closure` forms a Galois insertion with the coercion to set. -/\nprotected def gi : GaloisInsertion (@closure K _) coe\n    where\n  choice s _ := closure s\n  gc s t := closure_le\n  le_l_u s := subset_closure\n  choice_eq s h := rfl\n#align subfield.gi Subfield.gi\n\nvariable {K}\n\n#print Subfield.closure_eq /-\n/-- Closure of a subfield `S` equals `S`. -/\ntheorem closure_eq (s : Subfield K) : closure (s : Set K) = s :=\n  (Subfield.gi K).l_u_eq s\n#align subfield.closure_eq Subfield.closure_eq\n-/\n\n/- warning: subfield.closure_empty -> Subfield.closure_empty is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (EmptyCollection.emptyCollection.{u1} (Set.{u1} K) (Set.hasEmptyc.{u1} K))) (Bot.bot.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toHasBot.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1)))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (EmptyCollection.emptyCollection.{u1} (Set.{u1} K) (Set.instEmptyCollectionSet.{u1} K))) (Bot.bot.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toBot.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1)))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_empty Subfield.closure_emptyₓ'. -/\n@[simp]\ntheorem closure_empty : closure (∅ : Set K) = ⊥ :=\n  (Subfield.gi K).gc.l_bot\n#align subfield.closure_empty Subfield.closure_empty\n\n/- warning: subfield.closure_univ -> Subfield.closure_univ is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (Set.univ.{u1} K)) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K], Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (Set.univ.{u1} K)) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_univ Subfield.closure_univₓ'. -/\n@[simp]\ntheorem closure_univ : closure (Set.univ : Set K) = ⊤ :=\n  @coe_top K _ ▸ closure_eq ⊤\n#align subfield.closure_univ Subfield.closure_univ\n\n#print Subfield.closure_union /-\ntheorem closure_union (s t : Set K) : closure (s ∪ t) = closure s ⊔ closure t :=\n  (Subfield.gi K).gc.l_sup\n#align subfield.closure_union Subfield.closure_union\n-/\n\n/- warning: subfield.closure_Union -> Subfield.closure_unionᵢ is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {ι : Sort.{u2}} (s : ι -> (Set.{u1} K)), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (Set.unionᵢ.{u1, u2} K ι (fun (i : ι) => s i))) (supᵢ.{u1, u2} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) ι (fun (i : ι) => Subfield.closure.{u1} K _inst_1 (s i)))\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {ι : Sort.{u1}} (s : ι -> (Set.{u2} K)), Eq.{succ u2} (Subfield.{u2} K _inst_1) (Subfield.closure.{u2} K _inst_1 (Set.unionᵢ.{u2, u1} K ι (fun (i : ι) => s i))) (supᵢ.{u2, u1} (Subfield.{u2} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u2} (Subfield.{u2} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subfield.{u2} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u2} K _inst_1))) ι (fun (i : ι) => Subfield.closure.{u2} K _inst_1 (s i)))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_Union Subfield.closure_unionᵢₓ'. -/\ntheorem closure_unionᵢ {ι} (s : ι → Set K) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=\n  (Subfield.gi K).gc.l_supᵢ\n#align subfield.closure_Union Subfield.closure_unionᵢ\n\n/- warning: subfield.closure_sUnion -> Subfield.closure_unionₛ is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Set.{u1} (Set.{u1} K)), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (Set.unionₛ.{u1} K s)) (supᵢ.{u1, succ u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) (Set.{u1} K) (fun (t : Set.{u1} K) => supᵢ.{u1, 0} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) (Membership.Mem.{u1, u1} (Set.{u1} K) (Set.{u1} (Set.{u1} K)) (Set.hasMem.{u1} (Set.{u1} K)) t s) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} K) (Set.{u1} (Set.{u1} K)) (Set.hasMem.{u1} (Set.{u1} K)) t s) => Subfield.closure.{u1} K _inst_1 t)))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Set.{u1} (Set.{u1} K)), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (Set.unionₛ.{u1} K s)) (supᵢ.{u1, succ u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))) (Set.{u1} K) (fun (t : Set.{u1} K) => supᵢ.{u1, 0} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))) (Membership.mem.{u1, u1} (Set.{u1} K) (Set.{u1} (Set.{u1} K)) (Set.instMembershipSet.{u1} (Set.{u1} K)) t s) (fun (H : Membership.mem.{u1, u1} (Set.{u1} K) (Set.{u1} (Set.{u1} K)) (Set.instMembershipSet.{u1} (Set.{u1} K)) t s) => Subfield.closure.{u1} K _inst_1 t)))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_sUnion Subfield.closure_unionₛₓ'. -/\ntheorem closure_unionₛ (s : Set (Set K)) : closure (⋃₀ s) = ⨆ t ∈ s, closure t :=\n  (Subfield.gi K).gc.l_supₛ\n#align subfield.closure_sUnion Subfield.closure_unionₛ\n\n/- warning: subfield.map_sup -> Subfield.map_sup is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (s : Subfield.{u1} K _inst_1) (t : Subfield.{u1} K _inst_1) (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Subfield.{u2} L _inst_2) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (Sup.sup.{u1} (Subfield.{u1} K _inst_1) (SemilatticeSup.toHasSup.{u1} (Subfield.{u1} K _inst_1) (Lattice.toSemilatticeSup.{u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toLattice.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))))) s t)) (Sup.sup.{u2} (Subfield.{u2} L _inst_2) (SemilatticeSup.toHasSup.{u2} (Subfield.{u2} L _inst_2) (Lattice.toSemilatticeSup.{u2} (Subfield.{u2} L _inst_2) (ConditionallyCompleteLattice.toLattice.{u2} (Subfield.{u2} L _inst_2) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subfield.{u2} L _inst_2) (Subfield.completeLattice.{u2} L _inst_2))))) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f t))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (s : Subfield.{u1} K _inst_1) (t : Subfield.{u1} K _inst_1) (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Subfield.{u2} L _inst_2) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (Sup.sup.{u1} (Subfield.{u1} K _inst_1) (SemilatticeSup.toSup.{u1} (Subfield.{u1} K _inst_1) (Lattice.toSemilatticeSup.{u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toLattice.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) s t)) (Sup.sup.{u2} (Subfield.{u2} L _inst_2) (SemilatticeSup.toSup.{u2} (Subfield.{u2} L _inst_2) (Lattice.toSemilatticeSup.{u2} (Subfield.{u2} L _inst_2) (ConditionallyCompleteLattice.toLattice.{u2} (Subfield.{u2} L _inst_2) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subfield.{u2} L _inst_2) (Subfield.instCompleteLatticeSubfield.{u2} L _inst_2))))) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f s) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f t))\nCase conversion may be inaccurate. Consider using '#align subfield.map_sup Subfield.map_supₓ'. -/\ntheorem map_sup (s t : Subfield K) (f : K →+* L) : (s ⊔ t).map f = s.map f ⊔ t.map f :=\n  (gc_map_comap f).l_sup\n#align subfield.map_sup Subfield.map_sup\n\n/- warning: subfield.map_supr -> Subfield.map_supᵢ is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {ι : Sort.{u3}} (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : ι -> (Subfield.{u1} K _inst_1)), Eq.{succ u2} (Subfield.{u2} L _inst_2) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (supᵢ.{u1, u3} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) ι s)) (supᵢ.{u2, u3} (Subfield.{u2} L _inst_2) (ConditionallyCompleteLattice.toHasSup.{u2} (Subfield.{u2} L _inst_2) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subfield.{u2} L _inst_2) (Subfield.completeLattice.{u2} L _inst_2))) ι (fun (i : ι) => Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (s i)))\nbut is expected to have type\n  forall {K : Type.{u2}} {L : Type.{u3}} [_inst_1 : Field.{u2} K] [_inst_2 : Field.{u3} L] {ι : Sort.{u1}} (f : RingHom.{u2, u3} K L (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} L (Ring.toNonAssocRing.{u3} L (DivisionRing.toRing.{u3} L (Field.toDivisionRing.{u3} L _inst_2))))) (s : ι -> (Subfield.{u2} K _inst_1)), Eq.{succ u3} (Subfield.{u3} L _inst_2) (Subfield.map.{u2, u3} K L _inst_1 _inst_2 f (supᵢ.{u2, u1} (Subfield.{u2} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u2} (Subfield.{u2} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subfield.{u2} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u2} K _inst_1))) ι s)) (supᵢ.{u3, u1} (Subfield.{u3} L _inst_2) (ConditionallyCompleteLattice.toSupSet.{u3} (Subfield.{u3} L _inst_2) (CompleteLattice.toConditionallyCompleteLattice.{u3} (Subfield.{u3} L _inst_2) (Subfield.instCompleteLatticeSubfield.{u3} L _inst_2))) ι (fun (i : ι) => Subfield.map.{u2, u3} K L _inst_1 _inst_2 f (s i)))\nCase conversion may be inaccurate. Consider using '#align subfield.map_supr Subfield.map_supᵢₓ'. -/\ntheorem map_supᵢ {ι : Sort _} (f : K →+* L) (s : ι → Subfield K) :\n    (supᵢ s).map f = ⨆ i, (s i).map f :=\n  (gc_map_comap f).l_supᵢ\n#align subfield.map_supr Subfield.map_supᵢ\n\n/- warning: subfield.comap_inf -> Subfield.comap_inf is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (s : Subfield.{u2} L _inst_2) (t : Subfield.{u2} L _inst_2) (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Inf.inf.{u2} (Subfield.{u2} L _inst_2) (Subfield.hasInf.{u2} L _inst_2) s t)) (Inf.inf.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f s) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f t))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (s : Subfield.{u2} L _inst_2) (t : Subfield.{u2} L _inst_2) (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Inf.inf.{u2} (Subfield.{u2} L _inst_2) (Subfield.instInfSubfield.{u2} L _inst_2) s t)) (Inf.inf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instInfSubfield.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f s) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f t))\nCase conversion may be inaccurate. Consider using '#align subfield.comap_inf Subfield.comap_infₓ'. -/\ntheorem comap_inf (s t : Subfield L) (f : K →+* L) : (s ⊓ t).comap f = s.comap f ⊓ t.comap f :=\n  (gc_map_comap f).u_inf\n#align subfield.comap_inf Subfield.comap_inf\n\n/- warning: subfield.comap_infi -> Subfield.comap_infᵢ is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {ι : Sort.{u3}} (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : ι -> (Subfield.{u2} L _inst_2)), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (infᵢ.{u2, u3} (Subfield.{u2} L _inst_2) (Subfield.hasInf.{u2} L _inst_2) ι s)) (infᵢ.{u1, u3} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) ι (fun (i : ι) => Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (s i)))\nbut is expected to have type\n  forall {K : Type.{u2}} {L : Type.{u3}} [_inst_1 : Field.{u2} K] [_inst_2 : Field.{u3} L] {ι : Sort.{u1}} (f : RingHom.{u2, u3} K L (NonAssocRing.toNonAssocSemiring.{u2} K (Ring.toNonAssocRing.{u2} K (DivisionRing.toRing.{u2} K (Field.toDivisionRing.{u2} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} L (Ring.toNonAssocRing.{u3} L (DivisionRing.toRing.{u3} L (Field.toDivisionRing.{u3} L _inst_2))))) (s : ι -> (Subfield.{u3} L _inst_2)), Eq.{succ u2} (Subfield.{u2} K _inst_1) (Subfield.comap.{u2, u3} K L _inst_1 _inst_2 f (infᵢ.{u3, u1} (Subfield.{u3} L _inst_2) (Subfield.instInfSetSubfield.{u3} L _inst_2) ι s)) (infᵢ.{u2, u1} (Subfield.{u2} K _inst_1) (Subfield.instInfSetSubfield.{u2} K _inst_1) ι (fun (i : ι) => Subfield.comap.{u2, u3} K L _inst_1 _inst_2 f (s i)))\nCase conversion may be inaccurate. Consider using '#align subfield.comap_infi Subfield.comap_infᵢₓ'. -/\ntheorem comap_infᵢ {ι : Sort _} (f : K →+* L) (s : ι → Subfield L) :\n    (infᵢ s).comap f = ⨅ i, (s i).comap f :=\n  (gc_map_comap f).u_infᵢ\n#align subfield.comap_infi Subfield.comap_infᵢ\n\n/- warning: subfield.map_bot -> Subfield.map_bot is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Subfield.{u2} L _inst_2) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (Bot.bot.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toHasBot.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1)))) (Bot.bot.{u2} (Subfield.{u2} L _inst_2) (CompleteLattice.toHasBot.{u2} (Subfield.{u2} L _inst_2) (Subfield.completeLattice.{u2} L _inst_2)))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u2} (Subfield.{u2} L _inst_2) (Subfield.map.{u1, u2} K L _inst_1 _inst_2 f (Bot.bot.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toBot.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1)))) (Bot.bot.{u2} (Subfield.{u2} L _inst_2) (CompleteLattice.toBot.{u2} (Subfield.{u2} L _inst_2) (Subfield.instCompleteLatticeSubfield.{u2} L _inst_2)))\nCase conversion may be inaccurate. Consider using '#align subfield.map_bot Subfield.map_botₓ'. -/\n@[simp]\ntheorem map_bot (f : K →+* L) : (⊥ : Subfield K).map f = ⊥ :=\n  (gc_map_comap f).l_bot\n#align subfield.map_bot Subfield.map_bot\n\n/- warning: subfield.comap_top -> Subfield.comap_top is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Top.top.{u2} (Subfield.{u2} L _inst_2) (Subfield.hasTop.{u2} L _inst_2))) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Top.top.{u2} (Subfield.{u2} L _inst_2) (Subfield.instTopSubfield.{u2} L _inst_2))) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1))\nCase conversion may be inaccurate. Consider using '#align subfield.comap_top Subfield.comap_topₓ'. -/\n@[simp]\ntheorem comap_top (f : K →+* L) : (⊤ : Subfield L).comap f = ⊤ :=\n  (gc_map_comap f).u_top\n#align subfield.comap_top Subfield.comap_top\n\n/- warning: subfield.mem_supr_of_directed -> Subfield.mem_supᵢ_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {ι : Sort.{u2}} [hι : Nonempty.{u2} ι] {S : ι -> (Subfield.{u1} K _inst_1)}, (Directed.{u1, u2} (Subfield.{u1} K _inst_1) ι (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1)))))) S) -> (forall {x : K}, Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (supᵢ.{u1, u2} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) ι (fun (i : ι) => S i))) (Exists.{u2} ι (fun (i : ι) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (S i))))\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {ι : Sort.{u1}} [hι : Nonempty.{u1} ι] {S : ι -> (Subfield.{u2} K _inst_1)}, (Directed.{u2, u1} (Subfield.{u2} K _inst_1) ι (fun (x._@.Mathlib.FieldTheory.Subfield._hyg.7386 : Subfield.{u2} K _inst_1) (x._@.Mathlib.FieldTheory.Subfield._hyg.7388 : Subfield.{u2} K _inst_1) => LE.le.{u2} (Subfield.{u2} K _inst_1) (Preorder.toLE.{u2} (Subfield.{u2} K _inst_1) (PartialOrder.toPreorder.{u2} (Subfield.{u2} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Subfield.{u2} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Subfield.{u2} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u2} K _inst_1))))) x._@.Mathlib.FieldTheory.Subfield._hyg.7386 x._@.Mathlib.FieldTheory.Subfield._hyg.7388) S) -> (forall {x : K}, Iff (Membership.mem.{u2, u2} K (Subfield.{u2} K _inst_1) (SetLike.instMembership.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1)) x (supᵢ.{u2, u1} (Subfield.{u2} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u2} (Subfield.{u2} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subfield.{u2} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u2} K _inst_1))) ι (fun (i : ι) => S i))) (Exists.{u1} ι (fun (i : ι) => Membership.mem.{u2, u2} K (Subfield.{u2} K _inst_1) (SetLike.instMembership.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1)) x (S i))))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_supr_of_directed Subfield.mem_supᵢ_of_directedₓ'. -/\n/-- The underlying set of a non-empty directed Sup of subfields is just a union of the subfields.\n  Note that this fails without the directedness assumption (the union of two subfields is\n  typically not a subfield) -/\ntheorem mem_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → Subfield K} (hS : Directed (· ≤ ·) S)\n    {x : K} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i :=\n  by\n  refine' ⟨_, fun ⟨i, hi⟩ => (SetLike.le_def.1 <| le_supᵢ S i) hi⟩\n  suffices x ∈ closure (⋃ i, (S i : Set K)) → ∃ i, x ∈ S i by\n    simpa only [closure_unionᵢ, closure_eq]\n  refine' fun hx => closure_induction hx (fun x => set.mem_Union.mp) _ _ _ _ _\n  · exact hι.elim fun i => ⟨i, (S i).one_mem⟩\n  · rintro x y ⟨i, hi⟩ ⟨j, hj⟩\n    obtain ⟨k, hki, hkj⟩ := hS i j\n    exact ⟨k, (S k).add_mem (hki hi) (hkj hj)⟩\n  · rintro x ⟨i, hi⟩\n    exact ⟨i, (S i).neg_mem hi⟩\n  · rintro x ⟨i, hi⟩\n    exact ⟨i, (S i).inv_mem hi⟩\n  · rintro x y ⟨i, hi⟩ ⟨j, hj⟩\n    obtain ⟨k, hki, hkj⟩ := hS i j\n    exact ⟨k, (S k).mul_mem (hki hi) (hkj hj)⟩\n#align subfield.mem_supr_of_directed Subfield.mem_supᵢ_of_directed\n\n/- warning: subfield.coe_supr_of_directed -> Subfield.coe_supᵢ_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {ι : Sort.{u2}} [hι : Nonempty.{u2} ι] {S : ι -> (Subfield.{u1} K _inst_1)}, (Directed.{u1, u2} (Subfield.{u1} K _inst_1) ι (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1)))))) S) -> (Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (supᵢ.{u1, u2} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) ι (fun (i : ι) => S i))) (Set.unionᵢ.{u1, u2} K ι (fun (i : ι) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (S i))))\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {ι : Sort.{u1}} [hι : Nonempty.{u1} ι] {S : ι -> (Subfield.{u2} K _inst_1)}, (Directed.{u2, u1} (Subfield.{u2} K _inst_1) ι (fun (x._@.Mathlib.FieldTheory.Subfield._hyg.7683 : Subfield.{u2} K _inst_1) (x._@.Mathlib.FieldTheory.Subfield._hyg.7685 : Subfield.{u2} K _inst_1) => LE.le.{u2} (Subfield.{u2} K _inst_1) (Preorder.toLE.{u2} (Subfield.{u2} K _inst_1) (PartialOrder.toPreorder.{u2} (Subfield.{u2} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Subfield.{u2} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Subfield.{u2} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u2} K _inst_1))))) x._@.Mathlib.FieldTheory.Subfield._hyg.7683 x._@.Mathlib.FieldTheory.Subfield._hyg.7685) S) -> (Eq.{succ u2} (Set.{u2} K) (SetLike.coe.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1) (supᵢ.{u2, u1} (Subfield.{u2} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u2} (Subfield.{u2} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Subfield.{u2} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u2} K _inst_1))) ι (fun (i : ι) => S i))) (Set.unionᵢ.{u2, u1} K ι (fun (i : ι) => SetLike.coe.{u2, u2} (Subfield.{u2} K _inst_1) K (Subfield.instSetLikeSubfield.{u2} K _inst_1) (S i))))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_supr_of_directed Subfield.coe_supᵢ_of_directedₓ'. -/\ntheorem coe_supᵢ_of_directed {ι} [hι : Nonempty ι] {S : ι → Subfield K} (hS : Directed (· ≤ ·) S) :\n    ((⨆ i, S i : Subfield K) : Set K) = ⋃ i, ↑(S i) :=\n  Set.ext fun x => by simp [mem_supr_of_directed hS]\n#align subfield.coe_supr_of_directed Subfield.coe_supᵢ_of_directed\n\n/- warning: subfield.mem_Sup_of_directed_on -> Subfield.mem_supₛ_of_directedOn is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} (Subfield.{u1} K _inst_1)}, (Set.Nonempty.{u1} (Subfield.{u1} K _inst_1) S) -> (DirectedOn.{u1} (Subfield.{u1} K _inst_1) (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1)))))) S) -> (forall {x : K}, Iff (Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x (SupSet.supₛ.{u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) S)) (Exists.{succ u1} (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Exists.{0} (Membership.Mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.hasMem.{u1} (Subfield.{u1} K _inst_1)) s S) (fun (H : Membership.Mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.hasMem.{u1} (Subfield.{u1} K _inst_1)) s S) => Membership.Mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.hasMem.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) x s))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} (Subfield.{u1} K _inst_1)}, (Set.Nonempty.{u1} (Subfield.{u1} K _inst_1) S) -> (DirectedOn.{u1} (Subfield.{u1} K _inst_1) (fun (x._@.Mathlib.FieldTheory.Subfield._hyg.7778 : Subfield.{u1} K _inst_1) (x._@.Mathlib.FieldTheory.Subfield._hyg.7780 : Subfield.{u1} K _inst_1) => LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) x._@.Mathlib.FieldTheory.Subfield._hyg.7778 x._@.Mathlib.FieldTheory.Subfield._hyg.7780) S) -> (forall {x : K}, Iff (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x (SupSet.supₛ.{u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))) S)) (Exists.{succ u1} (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => And (Membership.mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.instMembershipSet.{u1} (Subfield.{u1} K _inst_1)) s S) (Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s))))\nCase conversion may be inaccurate. Consider using '#align subfield.mem_Sup_of_directed_on Subfield.mem_supₛ_of_directedOnₓ'. -/\ntheorem mem_supₛ_of_directedOn {S : Set (Subfield K)} (Sne : S.Nonempty) (hS : DirectedOn (· ≤ ·) S)\n    {x : K} : x ∈ supₛ S ↔ ∃ s ∈ S, x ∈ s :=\n  by\n  haveI : Nonempty S := Sne.to_subtype\n  simp only [supₛ_eq_supᵢ', mem_supr_of_directed hS.directed_coe, SetCoe.exists, Subtype.coe_mk]\n#align subfield.mem_Sup_of_directed_on Subfield.mem_supₛ_of_directedOn\n\n/- warning: subfield.coe_Sup_of_directed_on -> Subfield.coe_supₛ_of_directedOn is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} (Subfield.{u1} K _inst_1)}, (Set.Nonempty.{u1} (Subfield.{u1} K _inst_1) S) -> (DirectedOn.{u1} (Subfield.{u1} K _inst_1) (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1)))))) S) -> (Eq.{succ u1} (Set.{u1} K) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (SupSet.supₛ.{u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toHasSup.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))) S)) (Set.unionᵢ.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.unionᵢ.{u1, 0} K (Membership.Mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.hasMem.{u1} (Subfield.{u1} K _inst_1)) s S) (fun (H : Membership.Mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.hasMem.{u1} (Subfield.{u1} K _inst_1)) s S) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) s))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Set.{u1} (Subfield.{u1} K _inst_1)}, (Set.Nonempty.{u1} (Subfield.{u1} K _inst_1) S) -> (DirectedOn.{u1} (Subfield.{u1} K _inst_1) (fun (x._@.Mathlib.FieldTheory.Subfield._hyg.7873 : Subfield.{u1} K _inst_1) (x._@.Mathlib.FieldTheory.Subfield._hyg.7875 : Subfield.{u1} K _inst_1) => LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) x._@.Mathlib.FieldTheory.Subfield._hyg.7873 x._@.Mathlib.FieldTheory.Subfield._hyg.7875) S) -> (Eq.{succ u1} (Set.{u1} K) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (SupSet.supₛ.{u1} (Subfield.{u1} K _inst_1) (ConditionallyCompleteLattice.toSupSet.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))) S)) (Set.unionᵢ.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.unionᵢ.{u1, 0} K (Membership.mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.instMembershipSet.{u1} (Subfield.{u1} K _inst_1)) s S) (fun (H : Membership.mem.{u1, u1} (Subfield.{u1} K _inst_1) (Set.{u1} (Subfield.{u1} K _inst_1)) (Set.instMembershipSet.{u1} (Subfield.{u1} K _inst_1)) s S) => SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) s))))\nCase conversion may be inaccurate. Consider using '#align subfield.coe_Sup_of_directed_on Subfield.coe_supₛ_of_directedOnₓ'. -/\ntheorem coe_supₛ_of_directedOn {S : Set (Subfield K)} (Sne : S.Nonempty)\n    (hS : DirectedOn (· ≤ ·) S) : (↑(supₛ S) : Set K) = ⋃ s ∈ S, ↑s :=\n  Set.ext fun x => by simp [mem_Sup_of_directed_on Sne hS]\n#align subfield.coe_Sup_of_directed_on Subfield.coe_supₛ_of_directedOn\n\nend Subfield\n\nnamespace RingHom\n\nvariable {s : Subfield K}\n\nopen Subfield\n\n/- warning: ring_hom.range_restrict_field -> RingHom.rangeRestrictField is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), RingHom.{u1, u2} K (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Ring.toNonAssocRing.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Subfield.ring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))), RingHom.{u1, u2} K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.range_restrict_field RingHom.rangeRestrictFieldₓ'. -/\n/-- Restriction of a ring homomorphism to its range interpreted as a subfield. -/\ndef rangeRestrictField (f : K →+* L) : K →+* f.fieldRange :=\n  f.srangeRestrict\n#align ring_hom.range_restrict_field RingHom.rangeRestrictField\n\n/- warning: ring_hom.coe_range_restrict_field -> RingHom.coe_rangeRestrictField is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (x : K), Eq.{succ u2} L ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) L (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) L (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) L (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) L (coeSubtype.{succ u2} L (fun (x : L) => Membership.Mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.hasMem.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Ring.toNonAssocRing.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Subfield.ring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) (fun (_x : RingHom.{u1, u2} K (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Ring.toNonAssocRing.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Subfield.ring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) => K -> (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (RingHom.hasCoeToFun.{u1, u2} K (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Ring.toNonAssocRing.{u2} (coeSort.{succ u2, succ (succ u2)} (Subfield.{u2} L _inst_2) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.setLike.{u2} L _inst_2)) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)) (Subfield.ring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) (RingHom.rangeRestrictField.{u1, u2} K L _inst_1 _inst_2 f) x)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f x)\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (x : K), Eq.{succ u2} L (Subtype.val.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Set.{u2} L) (Set.instMembershipSet.{u2} L) x (SetLike.coe.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2) (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))))) K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)))) (RingHom.instRingHomClassRingHom.{u1, u2} K (Subtype.{succ u2} L (fun (x : L) => Membership.mem.{u2, u2} L (Subfield.{u2} L _inst_2) (SetLike.instMembership.{u2, u2} (Subfield.{u2} L _inst_2) L (Subfield.instSetLikeSubfield.{u2} L _inst_2)) x (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f))) (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subsemiring.toNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (Subring.toSubsemiring.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)) (Subfield.toSubring.{u2} L _inst_2 (RingHom.fieldRange.{u1, u2} K L _inst_1 _inst_2 f)))))))) (RingHom.rangeRestrictField.{u1, u2} K L _inst_1 _inst_2 f) x)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f x)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_range_restrict_field RingHom.coe_rangeRestrictFieldₓ'. -/\n@[simp]\ntheorem coe_rangeRestrictField (f : K →+* L) (x : K) : (f.rangeRestrictField x : L) = f x :=\n  rfl\n#align ring_hom.coe_range_restrict_field RingHom.coe_rangeRestrictField\n\n#print RingHom.eqLocusField /-\n/-- The subfield of elements `x : R` such that `f x = g x`, i.e.,\nthe equalizer of f and g as a subfield of R -/\ndef eqLocusField (f g : K →+* L) : Subfield K :=\n  {\n    (f : K →+* L).eqLocus\n      g with\n    inv_mem' := fun x (hx : f x = g x) => show f x⁻¹ = g x⁻¹ by rw [map_inv₀ f, map_inv₀ g, hx]\n    carrier := { x | f x = g x } }\n#align ring_hom.eq_locus_field RingHom.eqLocusField\n-/\n\n/- warning: ring_hom.eq_on_field_closure -> RingHom.eqOn_field_closure is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {g : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {s : Set.{u1} K}, (Set.EqOn.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) g) s) -> (Set.EqOn.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) g) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Subfield.closure.{u1} K _inst_1 s)))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {g : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {s : Set.{u1} K}, (Set.EqOn.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) g) s) -> (Set.EqOn.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) g) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 s)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.eq_on_field_closure RingHom.eqOn_field_closureₓ'. -/\n/-- If two ring homomorphisms are equal on a set, then they are equal on its subfield closure. -/\ntheorem eqOn_field_closure {f g : K →+* L} {s : Set K} (h : Set.EqOn f g s) :\n    Set.EqOn f g (closure s) :=\n  show closure s ≤ f.eqLocusField g from closure_le.2 h\n#align ring_hom.eq_on_field_closure RingHom.eqOn_field_closure\n\n/- warning: ring_hom.eq_of_eq_on_subfield_top -> RingHom.eq_of_eqOn_subfield_top is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {g : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))}, (Set.EqOn.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) g) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subfield.{u1} K _inst_1) (Set.{u1} K) (HasLiftT.mk.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (CoeTCₓ.coe.{succ u1, succ u1} (Subfield.{u1} K _inst_1) (Set.{u1} K) (SetLike.Set.hasCoeT.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)))) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1)))) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f g)\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {g : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))}, (Set.EqOn.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) g) (SetLike.coe.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1)))) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.eq_of_eq_on_subfield_top RingHom.eq_of_eqOn_subfield_topₓ'. -/\ntheorem eq_of_eqOn_subfield_top {f g : K →+* L} (h : Set.EqOn f g (⊤ : Subfield K)) : f = g :=\n  ext fun x => h trivial\n#align ring_hom.eq_of_eq_on_subfield_top RingHom.eq_of_eqOn_subfield_top\n\n/- warning: ring_hom.eq_of_eq_on_of_field_closure_eq_top -> RingHom.eq_of_eqOn_of_field_closure_eq_top is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {s : Set.{u1} K}, (Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 s) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasTop.{u1} K _inst_1))) -> (forall {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {g : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))}, (Set.EqOn.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) g) s) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f g))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] {s : Set.{u1} K}, (Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 s) (Top.top.{u1} (Subfield.{u1} K _inst_1) (Subfield.instTopSubfield.{u1} K _inst_1))) -> (forall {f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))} {g : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))}, (Set.EqOn.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) g) s) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f g))\nCase conversion may be inaccurate. Consider using '#align ring_hom.eq_of_eq_on_of_field_closure_eq_top RingHom.eq_of_eqOn_of_field_closure_eq_topₓ'. -/\ntheorem eq_of_eqOn_of_field_closure_eq_top {s : Set K} (hs : closure s = ⊤) {f g : K →+* L}\n    (h : s.EqOn f g) : f = g :=\n  eq_of_eqOn_subfield_top <| hs ▸ eqOn_field_closure h\n#align ring_hom.eq_of_eq_on_of_field_closure_eq_top RingHom.eq_of_eqOn_of_field_closure_eq_top\n\n/- warning: ring_hom.field_closure_preimage_le -> RingHom.field_closure_preimage_le is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : Set.{u2} L), LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 (Set.preimage.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) s)) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Subfield.closure.{u2} L _inst_2 s))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : Set.{u2} L), LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 (Set.preimage.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) s)) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Subfield.closure.{u2} L _inst_2 s))\nCase conversion may be inaccurate. Consider using '#align ring_hom.field_closure_preimage_le RingHom.field_closure_preimage_leₓ'. -/\ntheorem field_closure_preimage_le (f : K →+* L) (s : Set L) :\n    closure (f ⁻¹' s) ≤ (closure s).comap f :=\n  closure_le.2 fun x hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx\n#align ring_hom.field_closure_preimage_le RingHom.field_closure_preimage_le\n\n#print RingHom.map_field_closure /-\n/-- The image under a ring homomorphism of the subfield generated by a set equals\nthe subfield generated by the image of the set. -/\ntheorem map_field_closure (f : K →+* L) (s : Set K) : (closure s).map f = closure (f '' s) :=\n  le_antisymm\n    (map_le_iff_le_comap.2 <|\n      le_trans (closure_mono <| Set.subset_preimage_image _ _) (field_closure_preimage_le _ _))\n    (closure_le.2 <| Set.image_subset _ subset_closure)\n#align ring_hom.map_field_closure RingHom.map_field_closure\n-/\n\nend RingHom\n\nnamespace Subfield\n\nopen RingHom\n\n/- warning: subfield.inclusion -> Subfield.inclusion is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Subfield.{u1} K _inst_1} {T : Subfield.{u1} K _inst_1}, (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))))) S T) -> (RingHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) S) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) T) (NonAssocRing.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) S) (Ring.toNonAssocRing.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) S) (Subfield.ring.{u1} K _inst_1 S))) (NonAssocRing.toNonAssocSemiring.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) T) (Ring.toNonAssocRing.{u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) T) (Subfield.ring.{u1} K _inst_1 T))))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {S : Subfield.{u1} K _inst_1} {T : Subfield.{u1} K _inst_1}, (LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) S T) -> (RingHom.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x S)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x T)) (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 S))) (Subsemiring.toNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 T))))\nCase conversion may be inaccurate. Consider using '#align subfield.inclusion Subfield.inclusionₓ'. -/\n/-- The ring homomorphism associated to an inclusion of subfields. -/\ndef inclusion {S T : Subfield K} (h : S ≤ T) : S →+* T :=\n  S.Subtype.codRestrict _ fun x => h x.2\n#align subfield.inclusion Subfield.inclusion\n\n/- warning: subfield.field_range_subtype -> Subfield.fieldRange_subtype is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Subfield.{u1} K _inst_1) (RingHom.fieldRange.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) K (Subfield.toField.{u1} K _inst_1 s) _inst_1 (Subfield.subtype.{u1} K _inst_1 s)) s\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] (s : Subfield.{u1} K _inst_1), Eq.{succ u1} (Subfield.{u1} K _inst_1) (RingHom.fieldRange.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) K (Subfield.toField.{u1} K _inst_1 s) _inst_1 (Subfield.subtype.{u1} K _inst_1 s)) s\nCase conversion may be inaccurate. Consider using '#align subfield.field_range_subtype Subfield.fieldRange_subtypeₓ'. -/\n@[simp]\ntheorem fieldRange_subtype (s : Subfield K) : s.Subtype.fieldRange = s :=\n  SetLike.ext' <| (coe_rangeS _).trans Subtype.range_coe\n#align subfield.field_range_subtype Subfield.fieldRange_subtype\n\nend Subfield\n\nnamespace RingEquiv\n\nvariable {s t : Subfield K}\n\n/- warning: ring_equiv.subfield_congr -> RingEquiv.subfieldCongr is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {t : Subfield.{u1} K _inst_1}, (Eq.{succ u1} (Subfield.{u1} K _inst_1) s t) -> (RingEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) s) (coeSort.{succ u1, succ (succ u1)} (Subfield.{u1} K _inst_1) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.setLike.{u1} K _inst_1)) t) (MulMemClass.mul.{u1, u1} K (Subfield.{u1} K _inst_1) (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Subfield.setLike.{u1} K _inst_1) (RingEquiv.subfieldCongr._proof_1.{u1} K _inst_1) s) (AddMemClass.add.{u1, u1} K (Subfield.{u1} K _inst_1) (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))) (Subfield.setLike.{u1} K _inst_1) (RingEquiv.subfieldCongr._proof_2.{u1} K _inst_1) s) (MulMemClass.mul.{u1, u1} K (Subfield.{u1} K _inst_1) (MulOneClass.toHasMul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))) (Subfield.setLike.{u1} K _inst_1) (RingEquiv.subfieldCongr._proof_3.{u1} K _inst_1) t) (AddMemClass.add.{u1, u1} K (Subfield.{u1} K _inst_1) (AddZeroClass.toHasAdd.{u1} K (AddMonoid.toAddZeroClass.{u1} K (AddMonoidWithOne.toAddMonoid.{u1} K (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} K (NonAssocSemiring.toAddCommMonoidWithOne.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))))))) (Subfield.setLike.{u1} K _inst_1) (RingEquiv.subfieldCongr._proof_4.{u1} K _inst_1) t))\nbut is expected to have type\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {s : Subfield.{u1} K _inst_1} {t : Subfield.{u1} K _inst_1}, (Eq.{succ u1} (Subfield.{u1} K _inst_1) s t) -> (RingEquiv.{u1, u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x t)) (Submonoid.mul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 s)))) (Submonoid.mul.{u1} K (MulZeroOneClass.toMulOneClass.{u1} K (NonAssocSemiring.toMulZeroOneClass.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (Subsemiring.toSubmonoid.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (Subring.toSubsemiring.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)) (Subfield.toSubring.{u1} K _inst_1 t)))) (Distrib.toAdd.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Ring.toNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x s)) (Subfield.instRingSubtypeMemSubfieldInstMembershipInstSetLikeSubfield.{u1} K _inst_1 s)))))) (Distrib.toAdd.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x t)) (NonUnitalNonAssocSemiring.toDistrib.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x t)) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x t)) (NonAssocRing.toNonUnitalNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x t)) (Ring.toNonAssocRing.{u1} (Subtype.{succ u1} K (fun (x : K) => Membership.mem.{u1, u1} K (Subfield.{u1} K _inst_1) (SetLike.instMembership.{u1, u1} (Subfield.{u1} K _inst_1) K (Subfield.instSetLikeSubfield.{u1} K _inst_1)) x t)) (Subfield.instRingSubtypeMemSubfieldInstMembershipInstSetLikeSubfield.{u1} K _inst_1 t)))))))\nCase conversion may be inaccurate. Consider using '#align ring_equiv.subfield_congr RingEquiv.subfieldCongrₓ'. -/\n/-- Makes the identity isomorphism from a proof two subfields of a multiplicative\n    monoid are equal. -/\ndef subfieldCongr (h : s = t) : s ≃+* t :=\n  {\n    Equiv.setCongr <| SetLike.ext'_iff.1\n        h with\n    map_mul' := fun _ _ => rfl\n    map_add' := fun _ _ => rfl }\n#align ring_equiv.subfield_congr RingEquiv.subfieldCongr\n\nend RingEquiv\n\nnamespace Subfield\n\nvariable {s : Set K}\n\n/- warning: subfield.closure_preimage_le -> Subfield.closure_preimage_le is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : Set.{u2} L), LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.completeLattice.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 (Set.preimage.{u1, u2} K L (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (fun (_x : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) => K -> L) (RingHom.hasCoeToFun.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) f) s)) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Subfield.closure.{u2} L _inst_2 s))\nbut is expected to have type\n  forall {K : Type.{u1}} {L : Type.{u2}} [_inst_1 : Field.{u1} K] [_inst_2 : Field.{u2} L] (f : RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (s : Set.{u2} L), LE.le.{u1} (Subfield.{u1} K _inst_1) (Preorder.toLE.{u1} (Subfield.{u1} K _inst_1) (PartialOrder.toPreorder.{u1} (Subfield.{u1} K _inst_1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Subfield.{u1} K _inst_1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Subfield.{u1} K _inst_1) (Subfield.instCompleteLatticeSubfield.{u1} K _inst_1))))) (Subfield.closure.{u1} K _inst_1 (Set.preimage.{u1, u2} K L (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K (fun (_x : K) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : K) => L) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonUnitalNonAssocSemiring.toMul.{u1} K (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))))) (NonUnitalNonAssocSemiring.toMul.{u2} L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} K (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1))))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} L (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2))))) K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))) (RingHom.instRingHomClassRingHom.{u1, u2} K L (NonAssocRing.toNonAssocSemiring.{u1} K (Ring.toNonAssocRing.{u1} K (DivisionRing.toRing.{u1} K (Field.toDivisionRing.{u1} K _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u2} L (Ring.toNonAssocRing.{u2} L (DivisionRing.toRing.{u2} L (Field.toDivisionRing.{u2} L _inst_2)))))))) f) s)) (Subfield.comap.{u1, u2} K L _inst_1 _inst_2 f (Subfield.closure.{u2} L _inst_2 s))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_preimage_le Subfield.closure_preimage_leₓ'. -/\ntheorem closure_preimage_le (f : K →+* L) (s : Set L) : closure (f ⁻¹' s) ≤ (closure s).comap f :=\n  closure_le.2 fun x hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx\n#align subfield.closure_preimage_le Subfield.closure_preimage_le\n\nend Subfield\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/FieldTheory/Subfield.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4531351110573846}}
{"text": "import Logic.Predicate.Term\n\nnamespace FirstOrder\n\nvariable (L : Language.{u})\n\ninductive SubFormula (μ : Type v) : ℕ → Type (max u v) where\n  | verum  {n} : SubFormula μ n\n  | falsum {n} : SubFormula μ n\n  | rel    {n} : ∀ {k}, L.rel k → (Fin k → SubTerm L μ n) → SubFormula μ n\n  | nrel   {n} : ∀ {k}, L.rel k → (Fin k → SubTerm L μ n) → SubFormula μ n\n  | and    {n} : SubFormula μ n → SubFormula μ n → SubFormula μ n\n  | or     {n} : SubFormula μ n → SubFormula μ n → SubFormula μ n\n  | all    {n} : SubFormula μ (n + 1) → SubFormula μ n\n  | ex     {n} : SubFormula μ (n + 1) → SubFormula μ n\n\nvariable (μ : Type v) (μ₁ : Type v₁) (μ₂ : Type v₂) (μ₃ : Type v₃)\n\nabbrev Formula := SubFormula L μ 0\n\nabbrev Sentence := Formula L Empty\n\nabbrev SyntacticSubFormula (n : ℕ) := SubFormula L ℕ n\n\nabbrev SyntacticFormula := SyntacticSubFormula L 0\n\nvariable {L μ μ₁ μ₂ μ₃}\n\nnamespace SubFormula\nvariable {n n₁ n₂ : ℕ}\n\ndef neg {n} : SubFormula L μ n → SubFormula L μ n\n  | verum    => falsum\n  | falsum   => verum\n  | rel r v  => nrel r v\n  | nrel r v => rel r v\n  | and p q  => or (neg p) (neg q)\n  | or p q   => and (neg p) (neg q)\n  | all p    => ex (neg p)\n  | ex p     => all (neg p)\n\nlemma neg_neg (p : SubFormula L μ n) : neg (neg p) = p :=\n  by induction p <;> simp[*, neg]\n\ninstance : HasLogicSymbols (SubFormula L μ n) where\n  neg := neg\n  arrow := fun p q => or (neg p) q\n  and := and\n  or := or\n  top := verum\n  bot := falsum\n\ninstance : HasUniv (SubFormula L μ) := ⟨all⟩\ninstance : HasEx (SubFormula L μ) := ⟨ex⟩\n\n@[simp] lemma neg_top : ~(⊤ : SubFormula L μ n) = ⊥ := rfl\n\n@[simp] lemma neg_bot : ~(⊥ : SubFormula L μ n) = ⊤ := rfl\n\n@[simp] lemma neg_rel {k} (r : L.rel k) (v : Fin k → SubTerm L μ n) : ~(rel r v) = nrel r v := rfl\n\n@[simp] lemma neg_nrel {k} (r : L.rel k) (v : Fin k → SubTerm L μ n) : ~(nrel r v) = rel r v := rfl\n\n@[simp] lemma neg_and (p q : SubFormula L μ n) : ~(p ⋏ q) = ~p ⋎ ~q := rfl\n\n@[simp] lemma neg_or (p q : SubFormula L μ n) : ~(p ⋎ q) = ~p ⋏ ~q := rfl\n\n@[simp] lemma neg_all (p : SubFormula L μ (n + 1)) : ~(∀' p) = ∃' ~p := rfl\n\n@[simp] lemma neg_ex (p : SubFormula L μ (n + 1)) : ~(∃' p) = ∀' ~p := rfl\n\n@[simp] lemma neg_neg' (p : SubFormula L μ n) : ~~p = p := neg_neg p\n\nlemma neg_eq (p : SubFormula L μ n) : ~p = neg p := rfl\n\nlemma imp_eq (p q : SubFormula L μ n) : p ⟶ q = ~p ⋎ q := rfl\n\nlemma iff_eq (p q : SubFormula L μ n) : p ⟷ q = (~p ⋎ q) ⋏ (~q ⋎ p) := rfl\n\n@[simp] lemma and_inj (p₁ q₁ p₂ q₂ : SubFormula L μ n) : p₁ ⋏ p₂ = q₁ ⋏ q₂ ↔ p₁ = q₁ ∧ p₂ = q₂ :=\nby simp[HasAnd.and]\n\n@[simp] lemma or_inj (p₁ q₁ p₂ q₂ : SubFormula L μ n) : p₁ ⋎ p₂ = q₁ ⋎ q₂ ↔ p₁ = q₁ ∧ p₂ = q₂ :=\nby simp[HasOr.or]\n\n@[simp] lemma all_inj (p q : SubFormula L μ (n + 1)) : ∀' p = ∀' q ↔ p = q :=\n  by simp[HasUniv.univ]\n\n@[simp] lemma ex_inj (p q : SubFormula L μ (n + 1)) : ∃' p = ∃' q ↔ p = q :=\n  by simp[HasEx.ex]\n\nvariable (L)\n\nabbrev rel! (k) (r : L.rel k) (v : Fin k → SubTerm L μ n) := rel r v\n\nabbrev nrel! (k) (r : L.rel k) (v : Fin k → SubTerm L μ n) := nrel r v\n\nvariable {L}\n\ndef complexity : {n : ℕ} → SubFormula L μ n → ℕ\n| _, ⊤        => 0\n| _, ⊥        => 0\n| _, rel _ _  => 0\n| _, nrel _ _ => 0\n| _, p ⋏ q    => max p.complexity q.complexity + 1\n| _, p ⋎ q    => max p.complexity q.complexity + 1\n| _, ∀' p     => p.complexity + 1\n| _, ∃' p     => p.complexity + 1\n\n@[simp] lemma complexity_top : complexity (⊤ : SubFormula L μ n) = 0 := rfl\n\n@[simp] lemma complexity_bot : complexity (⊥ : SubFormula L μ n) = 0 := rfl\n\n@[simp] lemma complexity_rel {k} (r : L.rel k) (v : Fin k → SubTerm L μ n) : complexity (rel r v) = 0 := rfl\n\n@[simp] lemma complexity_nrel {k} (r : L.rel k) (v : Fin k → SubTerm L μ n) : complexity (nrel r v) = 0 := rfl\n\n@[simp] lemma complexity_and (p q : SubFormula L μ n) : complexity (p ⋏ q) = max p.complexity q.complexity + 1 := rfl\n@[simp] lemma complexity_and' (p q : SubFormula L μ n) : complexity (and p q) = max p.complexity q.complexity + 1 := rfl\n\n@[simp] lemma complexity_or (p q : SubFormula L μ n) : complexity (p ⋎ q) = max p.complexity q.complexity + 1 := rfl\n@[simp] lemma complexity_or' (p q : SubFormula L μ n) : complexity (or p q) = max p.complexity q.complexity + 1 := rfl\n\n@[simp] lemma complexity_all (p : SubFormula L μ (n + 1)) : complexity (∀' p) = p.complexity + 1 := rfl\n@[simp] lemma complexity_all' (p : SubFormula L μ (n + 1)) : complexity (all p) = p.complexity + 1 := rfl\n\n@[simp] lemma complexity_ex (p : SubFormula L μ (n + 1)) : complexity (∃' p) = p.complexity + 1 := rfl\n@[simp] lemma complexity_ex' (p : SubFormula L μ (n + 1)) : complexity (ex p) = p.complexity + 1 := rfl\n\n@[elab_as_elim]\ndef cases' {C : ∀ n, SubFormula L μ n → Sort _}\n  (hverum  : ∀ {n : ℕ}, C n ⊤)\n  (hfalsum : ∀ {n : ℕ}, C n ⊥)\n  (hrel    : ∀ {n l : ℕ} (r : L.rel l) (v : Fin l → SubTerm L μ n), C n (rel r v))\n  (hnrel   : ∀ {n l : ℕ} (r : L.rel l) (v : Fin l → SubTerm L μ n), C n (nrel r v))\n  (hand    : ∀ {n : ℕ} (p q : SubFormula L μ n), C n (p ⋏ q))\n  (hor     : ∀ {n : ℕ} (p q : SubFormula L μ n), C n (p ⋎ q))\n  (hall    : ∀ {n : ℕ} (p : SubFormula L μ (n + 1)), C n (∀' p))\n  (hex     : ∀ {n : ℕ} (p : SubFormula L μ (n + 1)), C n (∃' p)) :\n    ∀ {n : ℕ} (p : SubFormula L μ n), C n p\n  | _, verum    => hverum\n  | _, falsum   => hfalsum\n  | _, rel r v  => hrel r v\n  | _, nrel r v => hnrel r v\n  | _, and p q  => hand p q\n  | _, or p q   => hor p q\n  | _, all p    => hall p\n  | _, ex p     => hex p\n\n@[elab_as_elim]\ndef rec' {C : ∀ n, SubFormula L μ n → Sort _}\n  (hverum  : ∀ {n : ℕ}, C n ⊤)\n  (hfalsum : ∀ {n : ℕ}, C n ⊥)\n  (hrel    : ∀ {n l : ℕ} (r : L.rel l) (v : Fin l → SubTerm L μ n), C n (rel r v))\n  (hnrel   : ∀ {n l : ℕ} (r : L.rel l) (v : Fin l → SubTerm L μ n), C n (nrel r v))\n  (hand    : ∀ {n : ℕ} (p q : SubFormula L μ n), C n p → C n q → C n (p ⋏ q))\n  (hor     : ∀ {n : ℕ} (p q : SubFormula L μ n), C n p → C n q → C n (p ⋎ q))\n  (hall    : ∀ {n : ℕ} (p : SubFormula L μ (n + 1)), C (n + 1) p → C n (∀' p))\n  (hex     : ∀ {n : ℕ} (p : SubFormula L μ (n + 1)), C (n + 1) p → C n (∃' p)) :\n    ∀ {n : ℕ} (p : SubFormula L μ n), C n p\n  | _, verum    => hverum\n  | _, falsum   => hfalsum\n  | _, rel r v  => hrel r v\n  | _, nrel r v => hnrel r v\n  | _, and p q  => hand p q (rec' hverum hfalsum hrel hnrel hand hor hall hex p) (rec' hverum hfalsum hrel hnrel hand hor hall hex q)\n  | _, or p q   => hor p q (rec' hverum hfalsum hrel hnrel hand hor hall hex p) (rec' hverum hfalsum hrel hnrel hand hor hall hex q)\n  | _, all p    => hall p (rec' hverum hfalsum hrel hnrel hand hor hall hex p)\n  | _, ex p     => hex p (rec' hverum hfalsum hrel hnrel hand hor hall hex p)\n\nvariable [∀ k, ToString (L.func k)] [∀ k, ToString (L.rel k)] [ToString μ]\n\ndef toStr : ∀ {n}, SubFormula L μ n → String\n  | _, ⊤                     => \"\\\\top\"\n  | _, ⊥                     => \"\\\\bot\"\n  | _, rel (k := 0) r _      => \"{\" ++ toString r ++ \"}\"\n  | _, rel (k := _ + 1) r v  => \"{\" ++ toString r ++ \"} \\\\left(\" ++ String.vecToStr (fun i => toString (v i)) ++ \"\\\\right)\"\n  | _, nrel (k := 0) r _     => \"\\\\lnot {\" ++ toString r ++ \"}\"\n  | _, nrel (k := _ + 1) r v => \"\\\\lnot {\" ++ toString r ++ \"} \\\\left(\" ++ String.vecToStr (fun i => toString (v i)) ++ \"\\\\right)\"\n  | _, p ⋏ q                 => \"\\\\left(\" ++ toStr p ++ \" \\\\land \" ++ toStr q ++ \"\\\\right)\"\n  | _, p ⋎ q                 => \"\\\\left(\" ++ toStr p ++ \" \\\\lor \"  ++ toStr q ++ \"\\\\right)\"\n  | _, @all _ _ n p          => \"(\\\\forall x_{\" ++ toString n ++ \"}) \" ++ toStr p\n  | _, @ex _ _ n p           => \"(\\\\exists x_{\" ++ toString n ++ \"}) \" ++ toStr p\n\ninstance : Repr (SubFormula L μ n) := ⟨fun t _ => toStr t⟩\n\ninstance : ToString (SubFormula L μ n) := ⟨toStr⟩\n\nend SubFormula\n\nnamespace SubFormula\nvariable {n n₁ n₂ n₃ m m₁ m₂ m₃ : ℕ}\n\n@[simp] lemma complexity_neg (p : SubFormula L μ n) : complexity (~p) = complexity p :=\nby induction p using rec' <;> simp[*]\n\n@[reducible]\ndef bind' : ∀ {n₁ n₂}, (bound : Fin n₁ → SubTerm L μ₂ n₂) → (free : μ₁ → SubTerm L μ₂ n₂) →\n    SubFormula L μ₁ n₁ → SubFormula L μ₂ n₂\n  | _, _, _,     _,    ⊤          => ⊤\n  | _, _, _,     _,    ⊥          => ⊥\n  | _, _, bound, free, (rel r v)  => rel r (SubTerm.bind bound free ∘ v)\n  | _, _, bound, free, (nrel r v) => nrel r (SubTerm.bind bound free ∘ v)\n  | _, _, bound, free, (p ⋏ q)    => bind' bound free p ⋏ bind' bound free q\n  | _, _, bound, free, (p ⋎ q)    => bind' bound free p ⋎ bind' bound free q\n  | _, _, bound, free, (∀' p)     => ∀' bind' (Fin.cases #0 $ SubTerm.bShift ∘ bound) (SubTerm.bShift ∘ free) p\n  | _, _, bound, free, (∃' p)     => ∃' bind' (Fin.cases #0 $ SubTerm.bShift ∘ bound) (SubTerm.bShift ∘ free) p\n\nlemma bind'_neg {n₁ n₂} (bound : Fin n₁ → SubTerm L μ₂ n₂) (free : μ₁ → SubTerm L μ₂ n₂) (p) :\n    bind' bound free (~p) = ~bind' bound free p :=\n  by induction p using rec' generalizing n₂ <;> simp[*, bind', ←neg_eq]\n\ndef bind (bound : Fin n₁ → SubTerm L μ₂ n₂) (free : μ₁ → SubTerm L μ₂ n₂) : SubFormula L μ₁ n₁ →L SubFormula L μ₂ n₂ where\n  toFun := bind' bound free\n  map_top' := by simp[bind']\n  map_bot' := by simp[bind']\n  map_and' := by simp[bind']\n  map_or'  := by simp[bind']\n  map_neg' := by simp[bind'_neg]\n  map_imp' := by simp[imp_eq, bind'_neg, ←neg_eq, bind']\n\nabbrev bind₀ (f : μ₁ → SubTerm L μ₂ n) : SubFormula L μ₁ n →L SubFormula L μ₂ n := bind SubTerm.bvar f\n\ndef map (bound : Fin n₁ → Fin n₂) (free : μ₁ → μ₂) : SubFormula L μ₁ n₁ →L SubFormula L μ₂ n₂ :=\n  bind (fun n => #(bound n)) (fun m => &(free m))\n\nabbrev map₀ (free : μ₁ → μ₂) : SubFormula L μ₁ n →L SubFormula L μ₂ n := map id free\n\ndef subst (t : SubTerm L μ n) : SubFormula L μ (n + 1) →L SubFormula L μ n :=\n  bind (SubTerm.bvar <: t) SubTerm.fvar\n\ndef emb : SubFormula L Empty n →L SubFormula L μ n := map id Empty.elim\n\nsection bind\nvariable (bound : Fin n₁ → SubTerm L μ₂ n₂) (free : μ₁ → SubTerm L μ₂ n₂)\n\nlemma bind_rel {k} (r : L.rel k) (v : Fin k → SubTerm L μ₁ n₁) :\n    bind bound free (rel r v) = rel r (fun i => (v i).bind bound free) := rfl\n\nlemma bind_nrel {k} (r : L.rel k) (v : Fin k → SubTerm L μ₁ n₁) :\n    bind bound free (nrel r v) = nrel r (fun i => (v i).bind bound free) := rfl\n\n@[simp] lemma bind_all (p : SubFormula L μ₁ (n₁ + 1)) :\n    bind bound free (∀' p) = ∀' bind (#0 :> SubTerm.bShift ∘ bound) (SubTerm.bShift ∘ free) p := rfl\n\n@[simp] lemma bind_ex (p : SubFormula L μ₁ (n₁ + 1)) :\n    bind bound free (∃' p) = ∃' bind (#0 :> SubTerm.bShift ∘ bound) (SubTerm.bShift ∘ free) p := rfl\n\n@[simp] lemma complexity_bind (p : SubFormula L μ₁ n₁) : complexity (bind bound free p) = complexity p :=\n  by induction p using rec' generalizing μ₂ n₂ <;> simp[*, bind_rel, bind_nrel]\n\n@[simp] lemma bind_id (p) : @bind L μ μ n n SubTerm.bvar SubTerm.fvar p = p :=\n  by induction p using rec' <;> simp[*, bind_rel, bind_nrel]\n\n@[simp] lemma eq_bind_of (bound : Fin n → SubTerm L μ n) (free : μ → SubTerm L μ n)\n    (hbound : ∀ x, bound x = #x) (hfree : ∀ x, free x = &x) (p : SubFormula L μ n) :\n    bind bound free p = p :=\n  by\n  have : bound = SubTerm.bvar := funext hbound\n  have : free = SubTerm.fvar := funext hfree\n  simp[*]\n\nend bind\n\nlemma bind_bind\n  (bound₁ : Fin n₁ → SubTerm L μ₂ n₂) (free₁ : μ₁ → SubTerm L μ₂ n₂)\n  (bound₂ : Fin n₂ → SubTerm L μ₃ n₃) (free₂ : μ₂ → SubTerm L μ₃ n₃) (p : SubFormula L μ₁ n₁) :\n    bind bound₂ free₂ (bind bound₁ free₁ p) = bind (fun n => (bound₁ n).bind bound₂ free₂) (fun m => (free₁ m).bind bound₂ free₂) p := by\n  induction p using rec' generalizing n₂ n₃ <;> simp[*, SubTerm.bind_bind, bind_rel, bind_nrel] <;>\n  { congr\n    refine funext (Fin.cases (by simp) (by simp[SubTerm.bShift, SubTerm.map, SubTerm.bind_bind]))\n    refine funext (by simp[SubTerm.bShift, SubTerm.map, SubTerm.bind_bind]) }\n\nlemma bind_comp_bind\n  (bound₁ : Fin n₁ → SubTerm L μ₂ n₂) (free₁ : μ₁ → SubTerm L μ₂ n₂)\n  (bound₂ : Fin n₂ → SubTerm L μ₃ n₃) (free₂ : μ₂ → SubTerm L μ₃ n₃) :\n    (bind bound₂ free₂).comp (bind bound₁ free₁) = bind (fun n => (bound₁ n).bind bound₂ free₂) (fun m => (free₁ m).bind bound₂ free₂) :=\n  by ext p; simp[bind_bind]\n\nsection map\nvariable (bound : Fin n₁ → Fin n₂) (free : μ₁ → μ₂)\n\nlemma map_rel {k} (r : L.rel k) (v : Fin k → SubTerm L μ₁ n₁) :\n    map bound free (rel r v) = rel r (fun i => (v i).map bound free) := rfl\n\nlemma map_nrel {k} (r : L.rel k) (v : Fin k → SubTerm L μ₁ n₁) :\n    map bound free (nrel r v) = nrel r (fun i => (v i).map bound free) := rfl\n\n@[simp] lemma map_all (p : SubFormula L μ₁ (n₁ + 1)) :\n    map bound free (∀' p) = ∀' map (0 :> Fin.succ ∘ bound) free p :=\n  by simp[map]; congr; exact funext (Fin.cases (by simp) (by simp))\n\n@[simp] lemma map_ex (p : SubFormula L μ₁ (n₁ + 1)) :\n    map bound free (∃' p) = ∃' map (0 :> Fin.succ ∘ bound) free p :=\n  by simp[map]; congr; exact funext (Fin.cases (by simp) (by simp))\n\n@[simp] lemma complexity_map (p : SubFormula L μ₁ n₁) : complexity (map bound free p) = complexity p :=\n  complexity_bind _ _ _\n\nend map\n\nlemma map_map\n  (bound₁ : Fin n₁ → Fin n₂) (free₁ : μ₁ → μ₂)\n  (bound₂ : Fin n₂ → Fin n₃) (free₂ : μ₂ → μ₃) (p : SubFormula L μ₁ n₁) :\n    map bound₂ free₂ (map bound₁ free₁ p) = map (bound₂ ∘ bound₁) (free₂ ∘ free₁) p :=\n  bind_bind _ _ _ _ _\n\n@[simp] lemma map_id (p) : @map L μ μ n n id id p = p :=\n  bind_id _\n\nlemma map_inj : ∀ {n₁ n₂ μ₁ μ₂} {bound : Fin n₁ → Fin n₂} {free : μ₁ → μ₂},\n    (hb : Function.Injective bound) → (hf : Function.Injective free) → Function.Injective $ map (L := L) bound free\n  | _, _, _, _, _,     _,    _,  _,  ⊤,        p => by cases p using cases' <;> simp[map_rel, map_nrel]\n  | _, _, _, _, _,     _,    _,  _,  ⊥,        p => by cases p using cases' <;> simp[map_rel, map_nrel]\n  | _, _, _, _, _,     _,    hb, hf, rel r v,  p => by\n    cases p using cases' <;> simp[map_rel, map_nrel]\n    case hrel =>\n      rintro rfl; simp; rintro rfl h; simp\n      funext i; exact SubTerm.map_inj hb hf (congr_fun h i)\n  | _, _, _, _, _,     _,    hb, hf, nrel r v, p => by\n    cases p using cases' <;> simp[map_rel, map_nrel]\n    case hnrel =>\n      rintro rfl; simp; rintro rfl h; simp\n      funext i; exact SubTerm.map_inj hb hf (congr_fun h i)\n  | _, _, _, _, _,     _,    hb, hf, p ⋏ q,    r => by\n    cases r using cases' <;> simp[map_rel, map_nrel]\n    intro hp hq; exact ⟨map_inj hb hf hp, map_inj hb hf hq⟩\n  | _, _, _, _, _,     _,    hb, hf, p ⋎ q,    r => by\n    cases r using cases' <;> simp[map_rel, map_nrel]\n    intro hp hq; exact ⟨map_inj hb hf hp, map_inj hb hf hq⟩\n  | _, _, _, _, bound, free, hb, hf, ∀' p,     q => by\n    cases q using cases' <;> simp[map_rel, map_nrel]\n    intro h; exact map_inj (bound := 0 :> Fin.succ ∘ bound)\n      (Matrix.injective_vecCons ((Fin.succ_injective _).comp hb) (fun _ => (Fin.succ_ne_zero _).symm)) hf h\n  | _, _, _, _, bound, free, hb, hf, ∃' p,     q => by\n    cases q using cases' <;> simp[map_rel, map_nrel]\n    intro h; exact map_inj (bound := 0 :> Fin.succ ∘ bound)\n      (Matrix.injective_vecCons ((Fin.succ_injective _).comp hb) (fun _ => (Fin.succ_ne_zero _).symm)) hf h\n\nlemma subst_rel {s : SubTerm L μ n} {k} (r : L.rel k) (v : Fin k → SubTerm L μ (n + 1)) :\n    subst s (rel r v) = rel r (fun i => SubTerm.subst s (v i)) :=\n  by simp[subst, SubTerm.subst, bind_rel]\n\nlemma subst_nrel {s : SubTerm L μ n} {k} (r : L.rel k) (v : Fin k → SubTerm L μ (n + 1)) :\n    subst s (nrel r v) = nrel r (fun i => SubTerm.subst s (v i)) :=\n  by simp[subst, SubTerm.subst, bind_nrel]\n\n@[simp] lemma subst_all {s : SubTerm L μ n} (p : SubFormula L μ (n + 1 + 1)) :\n    subst s (∀' p) = ∀' subst s.bShift p := by\n  simp[subst, SubTerm.subst]; congr\n  funext i\n  cases' i using Fin.cases with i <;> simp\n  cases' i using Fin.lastCases with i <;> simp[Fin.succ_castSucc]\n\n@[simp] lemma subst_ex {s : SubTerm L μ n} (p : SubFormula L μ (n + 1 + 1)) :\n    subst s (∃' p) = ∃' subst s.bShift p := by\n  simp[subst, SubTerm.subst]; congr\n  funext i\n  cases' i using Fin.cases with i <;> simp\n  cases' i using Fin.lastCases with i <;> simp[Fin.succ_castSucc]\n\nlemma emb_rel {k} (r : L.rel k) (v : Fin k → SubTerm L Empty n) :\n    emb (μ := μ) (rel r v) = rel r (fun i => SubTerm.map id Empty.elim (v i)) :=\n  by simp[emb, map_rel]\n\nlemma emb_nrel {k} (r : L.rel k) (v : Fin k → SubTerm L Empty n) :\n    emb (μ := μ) (nrel r v) = nrel r (fun i => SubTerm.map id Empty.elim (v i)) :=\n  by simp[emb, map_nrel]\n\n@[simp] lemma emb_all (p : SubFormula L Empty (n + 1)) :\n    emb (μ := μ) (∀' p) = ∀' emb p :=\n  by simp[emb]\n\n@[simp] lemma emb_ex (p : SubFormula L Empty (n + 1)) :\n    emb (μ := μ) (∃' p) = ∃' emb p :=\n  by simp[emb]\n\nsection Syntactic\n\ndef shift : SyntacticSubFormula L n →L SyntacticSubFormula L n :=\n  map id Nat.succ\n\ndef free : SyntacticSubFormula L (n + 1) →L SyntacticSubFormula L n :=\n  bind (SubTerm.bvar <: &0) (fun m => &(Nat.succ m))\n\ndef fix : SyntacticSubFormula L n →L SyntacticSubFormula L (n + 1) :=\n  bind (fun x => #(Fin.castSucc x)) (#(Fin.last n) :>ₙ SubTerm.fvar)\n\nlemma shift_rel {k} (r : L.rel k) (v : Fin k → SyntacticSubTerm L n) :\n    shift (rel r v) = rel r (fun i => SubTerm.shift $ v i) := rfl\n\nlemma shift_nrel {k} (r : L.rel k) (v : Fin k → SyntacticSubTerm L n) :\n    shift (nrel r v) = nrel r (fun i => SubTerm.shift $ v i) := rfl\n\n@[simp] lemma shift_all (p : SyntacticSubFormula L (n + 1)) :\n    shift (∀' p) = ∀' shift p  := by simp[shift]\n\n@[simp] lemma shift_ex (p : SyntacticSubFormula L (n + 1)) :\n    shift (∃' p) = ∃' shift p  := by simp[shift]\n\nlemma shift_Injective : Function.Injective (@shift L n) :=\n  Function.LeftInverse.injective (g := map id Nat.pred)\n    (by intros p; simp[shift, map_map, Function.comp]; exact map_id _)\n\ndef shiftEmb : SyntacticSubFormula L n ↪ SyntacticSubFormula L n where\n  toFun := shift\n  inj' := shift_Injective\n\nlemma shiftEmb_eq_shift (p : SyntacticSubFormula L n) :\n  shiftEmb p = shift p := rfl\n\nlemma shift_subst (s : SyntacticSubTerm L n) (p : SyntacticSubFormula L (n + 1)) :\n    shift (subst s p) = subst s.shift (shift p) :=\n  by\n  simp[shift, subst, map, bind_bind]; congr; funext x\n  cases' x using Fin.lastCases <;> simp; rfl\n\nlemma free_rel {k} (r : L.rel k) (v : Fin k → SyntacticSubTerm L (n + 1)) :\n    free (rel r v) = rel r (fun i => SubTerm.free $ v i) := rfl\n\nlemma free_nrel {k} (r : L.rel k) (v : Fin k → SyntacticSubTerm L (n + 1)) :\n    free (nrel r v) = nrel r (fun i => SubTerm.free $ v i) := rfl\n\n@[simp] lemma free_all (p : SyntacticSubFormula L (n + 1 + 1)) :\n    free (∀' p) = ∀' free p  := by\n  simp[free]; congr; exact funext (Fin.cases (by simp) (Fin.lastCases (by simp) (by simp; simp[Fin.succ_castSucc])))\n\n@[simp] lemma free_ex (p : SyntacticSubFormula L (n + 1 + 1)) :\n    free (∃' p) = ∃' free p  := by\n  simp[free]; congr; exact funext (Fin.cases (by simp) (Fin.lastCases (by simp) (by simp; simp[Fin.succ_castSucc])))\n\nlemma fix_rel {k} (r : L.rel k) (v : Fin k → SyntacticSubTerm L n) :\n    fix (rel r v) = rel r (fun i => SubTerm.fix $ v i) := rfl\n\nlemma fix_nrel {k} (r : L.rel k) (v : Fin k → SyntacticSubTerm L n) :\n    fix (nrel r v) = nrel r (fun i => SubTerm.fix $ v i) := rfl\n\n@[simp] lemma fix_all (p : SyntacticSubFormula L (n + 1)) :\n    fix (∀' p) = ∀' fix p := by\n  simp[fix]; congr\n  · exact funext (Fin.cases (by simp) (by simp[Fin.succ_castSucc])) \n  · exact funext (Nat.rec (by simp) (by simp))\n\n@[simp] lemma fix_ex (p : SyntacticSubFormula L (n + 1)) :\n    fix (∃' p) = ∃' fix p := by\n  simp[fix]; congr\n  · exact funext (Fin.cases (by simp) (by simp[Fin.succ_castSucc])) \n  · exact funext (Nat.rec (by simp) (by simp))\n\n@[simp] lemma free_fix (p : SyntacticSubFormula L n) : free (fix p) = p :=\n  by simp[fix, free, bind_bind]; apply eq_bind_of <;> simp; intros x; cases x <;> simp\n\n@[simp] lemma fix_free (p : SyntacticSubFormula L (n + 1)) : fix (free p) = p :=\n  by\n  simp[fix, free, bind_bind]; apply eq_bind_of <;> simp\n  intros x; exact Fin.lastCases (by simp) (by simp) x\n\n@[simp] lemma subst_shift_eq_free (p : SyntacticSubFormula L 1) : subst &0 (shift p) = free p :=\n  by simp[subst, shift, free, map, bind_bind]\n\n@[simp] lemma complexity_free (p : SyntacticSubFormula L (n + 1)) :\n    complexity (free p) = complexity p :=\n  by simp[free]\n\n@[elab_as_elim]\ndef formulaRec {C : SyntacticFormula L → Sort _}\n  (hverum  : C ⊤)\n  (hfalsum : C ⊥)\n  (hrel    : ∀ {l : ℕ} (r : L.rel l) (v : Fin l → SyntacticTerm L), C (rel r v))\n  (hnrel   : ∀ {l : ℕ} (r : L.rel l) (v : Fin l → SyntacticTerm L), C (nrel r v))\n  (hand    : ∀ (p q : SyntacticFormula L), C p → C q → C (p ⋏ q))\n  (hor     : ∀ (p q : SyntacticFormula L), C p → C q → C (p ⋎ q))\n  (hall    : ∀ (p : SyntacticSubFormula L 1), C (free p) → C (∀' p))\n  (hex     : ∀ (p : SyntacticSubFormula L 1), C (free p) → C (∃' p)) :\n    ∀ (p : SyntacticFormula L), C p\n  | ⊤        => hverum\n  | ⊥        => hfalsum\n  | rel r v  => hrel r v\n  | nrel r v => hnrel r v\n  | p ⋏ q    => hand p q (formulaRec hverum hfalsum hrel hnrel hand hor hall hex p) (formulaRec hverum hfalsum hrel hnrel hand hor hall hex q)\n  | p ⋎ q    => hor p q (formulaRec hverum hfalsum hrel hnrel hand hor hall hex p) (formulaRec hverum hfalsum hrel hnrel hand hor hall hex q)\n  | ∀' p     => hall p (formulaRec hverum hfalsum hrel hnrel hand hor hall hex (free p))\n  | ∃' p     => hex p (formulaRec hverum hfalsum hrel hnrel hand hor hall hex (free p))\n  termination_by formulaRec _ _ _ _ _ _ _ _ p => p.complexity\n\nend Syntactic\n\ndef fvarList : {n : ℕ} → SubFormula L μ n → List μ\n  | _, ⊤        => []\n  | _, ⊥        => []\n  | _, rel _ v  => List.join $ Matrix.toList (fun i => (v i).fvarList)\n  | _, nrel _ v => List.join $ Matrix.toList (fun i => (v i).fvarList)\n  | _, p ⋏ q    => p.fvarList ++ q.fvarList\n  | _, p ⋎ q    => p.fvarList ++ q.fvarList\n  | _, ∀' p     => p.fvarList\n  | _, ∃' p     => p.fvarList\n\nabbrev fvar? (p : SubFormula L μ n) (x : μ) : Prop := x ∈ p.fvarList\n\nlemma bind_eq_of_funEqOn (bound : Fin n₁ → SubTerm L μ₂ n₂) (free₁ free₂ : μ₁ → SubTerm L μ₂ n₂) (p : SubFormula L μ₁ n₁)\n  (h : Function.funEqOn (fvar? p) free₁ free₂) :\n    bind bound free₁ p = bind bound free₂ p := by\n  induction p using rec' generalizing n₂ <;> simp[*, bind_rel, bind_nrel] <;> simp[fvar?, fvarList] at h\n  case hrel =>\n    funext i\n    exact SubTerm.bind_eq_of_funEqOn _ _ _ _ (h.of_subset (by simp[fvarList]; intro x hx; exact ⟨i, hx⟩))\n  case hnrel =>\n    funext i\n    exact SubTerm.bind_eq_of_funEqOn _ _ _ _ (h.of_subset (by simp[fvarList]; intro x hx; exact ⟨i, hx⟩))\n  case hand ihp ihq =>\n    exact ⟨ihp _ _ _ (h.of_subset (fun x hx => Or.inl hx)), ihq _ _ _ (h.of_subset (fun x hx => Or.inr hx))⟩\n  case hor ihp ihq =>\n    exact ⟨ihp _ _ _ (h.of_subset (fun x hx => Or.inl hx)), ihq _ _ _ (h.of_subset (fun x hx => Or.inr hx))⟩\n  case hall ih =>\n    exact ih _ _ _ (by intro x hx; simp[h x hx])\n  case hex ih =>\n    exact ih _ _ _ (by intro x hx; simp[h x hx])\n\nlemma bind_eq_of_funEqOn' {bound₁ bound₂ : Fin n → SubTerm L μ n} {free₁ free₂ : μ → SubTerm L μ n} (p : SubFormula L μ n)\n  (hbound : bound₁ = bound₂)\n  (hfree : Function.funEqOn (fvar? p) free₁ free₂) :\n    bind bound₁ free₁ p = bind bound₂ free₂ p := by\n  rw[hbound]; exact bind_eq_of_funEqOn _ _ _ _ hfree\n\nlemma ne_of_ne_complexity {p q : SubFormula L μ n} (h : p.complexity ≠ q.complexity) : p ≠ q :=\n  by rintro rfl; contradiction\n\ndeclare_syntax_cat subformula\nsyntax \"⊤\" : subformula\nsyntax \"⊥\" : subformula\nsyntax:45 subterm:45 \"=\" subterm:0 : subformula\nsyntax:45 subterm:45 \"≠\" subterm:0 : subformula\nsyntax:45 subterm:45 \"<\" subterm:0 : subformula\nsyntax:45 \"prop\" term:max : subformula\nsyntax:45 \"rel¹\" term \"/[\" subterm:0 \"]\" : subformula\nsyntax:45 \"rel²\" term \"/[\" subterm:0 \",\" subterm:0 \"]\" : subformula\nsyntax:45 \"rel³\" term \"/[\" subterm:0 \",\" subterm:0 \",\" subterm:0 \"]\" : subformula\nsyntax:max \"¬\" subformula:35 : subformula\nsyntax:32 subformula:32 \"∧\" subformula:33 : subformula\nsyntax:30 subformula:30 \"∨\" subformula:31 : subformula\nsyntax:25 \"∀\" subformula:24 : subformula\nsyntax:25 \"∃\" subformula:24 : subformula\nsyntax:25 \"∀*\" subformula:24 : subformula\nsyntax \"(\" subformula \")\" : subformula\nsyntax:max \"!\" term:max : subformula\nsyntax \"“\" subformula \"”\" : term\n \nmacro_rules\n  | `(“ ⊤ ”)                                          => `(⊤)\n  | `(“ ⊥ ”)                                          => `(⊥)\n  | `(“ ! $t:term ”)                                  => `($t)\n  | `(“ prop $s:term ”)                               => `(rel $s ![])\n  | `(“ rel¹ $s:term /[ $t:subterm ] ”)               => `(rel $s ![T“$t”])\n  | `(“ rel² $s:term /[ $t₁:subterm, $t₂:subterm ] ”) => `(rel $s ![T“$t₁”, T“$t₂”])\n  | `(“ rel³ $s:term /[ $t₁:subterm, $t₂:subterm, $t₃:subterm ] ”) => `(rel $s ![T“$t₁”, T“$t₂”, T“$t₃”])\n  | `(“ ¬ $p:subformula ”)                            => `(~“$p”)\n  | `(“ $t:subterm = $u:subterm ”)                    => `(rel Language.HasEq.eq ![T“$t”, T“$u”])\n  | `(“ $t:subterm ≠ $u:subterm ”)                    => `(nrel Language.HasEq.eq ![T“$t”, T“$u”])\n  | `(“ $t:subterm < $u:subterm ”)                    => `(rel Language.HasLt.lt ![T“$t”, T“$u”])\n  | `(“ $p:subformula ∧ $q:subformula ”)              => `(“$p” ⋏ “$q”)\n  | `(“ $p:subformula ∨ $q:subformula ”)              => `(“$p” ⋎ “$q”)\n  | `(“ ∀ $p:subformula ”)                            => `(∀' “$p”)\n  | `(“ ∃ $p:subformula ”)                            => `(∃' “$p”)\n  | `(“ ∀* $p:subformula ”)                           => `(univClosure “$p”)\n  | `(“ ( $x ) ”)                                     => `(“$x”)\n\n#check (“¬ prop (Language.toRelational 1)” : Formula (Language.relational (fun _ => ℕ)) ℕ)\n#check (“rel¹ Language.toRelational 1 /[&0]” : Formula (Language.relational (fun _ => ℕ)) ℕ)\n#check (“¬ rel² Language.toRelational 1 /[&0, &1]” : Formula (Language.relational (fun _ => ℕ)) ℕ)\n#check (“¬(∀ ∀ (#0 + 1) * #1 < #0 + #1 ∨ 0 < 5)” : Sentence Language.oring)\n#check (“∀* ¬⊤ ∨ ¬0 < 5” : Sentence Language.oring)\n\nsyntax:10 subformula:9 \"→\" subformula:10 : subformula\nsyntax:10 subformula:10 \"↔\" subformula:10 : subformula\n\nmacro_rules\n  | `(“ $p:subformula → $q:subformula ”) => `(“$p” ⟶ “$q”)\n  | `(“ $p:subformula ↔ $q:subformula ”) => `(“$p” ⟷ “$q”)\n\n#reduce (“(∃ ⊤) ↔ !(∃' ⊤)” : Sentence Language.oring)\n#check (“0 < 0 → 0 < 1 → 0 < 2” : Sentence Language.oring)\n\nend SubFormula\n\nabbrev Theory (L : Language) (μ) := Set (Formula L μ)\n\nabbrev CTheory (L : Language) := Set (Sentence L)\n\nclass SubTheory (T U : CTheory L) where\n  sub : T ⊆ U\n\nnamespace SubTheory\n\nvariable {T U T₁ T₂ T₃ : CTheory L}\n\ninstance : SubTheory T T := ⟨by rfl⟩\n\ndef trans [SubTheory T₁ T₂] [SubTheory T₂ T₃] : SubTheory T₁ T₃ := ⟨subset_trans (sub (T := T₁) (U := T₂)) sub⟩\n\nend SubTheory\n\nnamespace SubFormula\n\nvariable {L : Language} [∀ k, DecidableEq (L.func k)] [∀ k, DecidableEq (L.rel k)] [DecidableEq μ]\n\ndef hasDecEq : (p q : SubFormula L μ n) → Decidable (p = q)\n  | ⊤,        q => by cases q using cases' <;>\n      { simp; try { exact isFalse not_false }; try { exact isTrue trivial } }\n  | ⊥,        q => by cases q using cases' <;>\n      { simp; try { exact isFalse not_false }; try { exact isTrue trivial } }\n  | rel r v,  q => by\n      cases q using cases' <;> try { simp; exact isFalse not_false }\n      case hrel k₁ k₂ r₂ v₂ =>\n        by_cases e : k₁ = k₂\n        · rcases e with rfl\n          exact match decEq r r₂ with\n          | isTrue h  => by simp[h]; exact Matrix.decVec _ _ (fun i => decEq (v i) (v₂ i))\n          | isFalse h => isFalse (by simp[h])\n        · exact isFalse (by simp[e])\n  | nrel r v, q => by\n      cases q using cases' <;> try { simp; exact isFalse not_false }\n      case hnrel k₁ k₂ r₂ v₂ =>\n        by_cases e : k₁ = k₂\n        · rcases e with rfl\n          exact match decEq r r₂ with\n          | isTrue h  => by simp[h]; exact Matrix.decVec _ _ (fun i => decEq (v i) (v₂ i))\n          | isFalse h => isFalse (by simp[h])\n        · exact isFalse (by simp[e])\n  | p ⋏ q,    r => by\n      cases r using cases' <;> try { simp; exact isFalse not_false }\n      case hand p' q' =>\n        exact match hasDecEq p p' with\n        | isTrue hp =>\n          match hasDecEq q q' with\n          | isTrue hq  => isTrue (hp ▸ hq ▸ rfl)\n          | isFalse hq => isFalse (by simp[hp, hq])\n        | isFalse hp => isFalse (by simp[hp])\n  | p ⋎ q,    r => by\n      cases r using cases' <;> try { simp; exact isFalse not_false }\n      case hor p' q' =>\n        exact match hasDecEq p p' with\n        | isTrue hp =>\n          match hasDecEq q q' with\n          | isTrue hq  => isTrue (hp ▸ hq ▸ rfl)\n          | isFalse hq => isFalse (by simp[hp, hq])\n        | isFalse hp => isFalse (by simp[hp])\n  | ∀' p,     q => by\n      cases q using cases' <;> try { simp; exact isFalse not_false }\n      case hall p' => simp; exact hasDecEq p p'\n  | ∃' p,     q => by\n      cases q using cases' <;> try { simp; exact isFalse not_false }\n      case hex p' => simp; exact hasDecEq p p'\n\ninstance : DecidableEq (SubFormula L μ n) := hasDecEq\n\nend SubFormula\n\nend FirstOrder", "meta": {"author": "iehality", "repo": "lean4-logic", "sha": "ef518051931fb1ecd0b89e94240b2900cd54d95c", "save_path": "github-repos/lean/iehality-lean4-logic", "path": "github-repos/lean/iehality-lean4-logic/lean4-logic-ef518051931fb1ecd0b89e94240b2900cd54d95c/Logic/Predicate/FirstOrder/Formula.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.4531351110573846}}
{"text": "import .datatypes tactic.norm_num\nnamespace polya\n\ntheorem eq_or_gt_of_ge {α} [decidable_linear_order α] {a b : α} (h : a ≥ b) : a = b ∨ a > b :=\nhave h1 : ¬ b > a, from not_lt_of_ge h,\neq_or_lt_of_not_lt h1\n\ntheorem eq_or_lt_of_le {α} [decidable_linear_order α] {a b : α} (h : a ≤ b) : a = b ∨ a < b :=\nhave h1 : ¬ b < a, from not_lt_of_ge h,\nhave h2 : b = a ∨ a < b, from eq_or_lt_of_not_lt h1,\nh2.elim (λ e, or.inl (e.symm)) or.inr\n\ntheorem le_of_eq_or_lt {α} [decidable_linear_order α] {a b : α} (h : a = b ∨ a < b) : a ≤ b :=\nh.elim (λ e, by rw e; reflexivity) le_of_lt\n\ntheorem ge_of_eq_or_gt {α} [decidable_linear_order α] {a b : α} (h : a = b ∨ a > b) : a ≥ b :=\nh.elim (λ e, by rw e; change b ≤ b; reflexivity) le_of_lt\n\nclass comp_op (op : ℚ → ℚ → Prop) :=\n(rev_op : ℚ → ℚ → Prop)\n(rev_op_is_rev : ∀ {x y}, rev_op y x ↔ op x y)\n(rel_of_sub_rel_zero : ∀ {x y : ℚ}, op (x-y) 0 ↔ op x y)\n(op_mul : ∀ {x y c : ℚ}, c > 0 → op x y → op (c*x) (c*y))\n(op_inv : ∀ {x y z : ℚ}, x > 0 → op z (x*y) → op ((rat.pow x (-1))*z) y)\n\nclass weak_comp_op (op) extends comp_op op :=\n(strict_op : ℚ → ℚ → Prop)\n(disj : ∀ {x y}, op x y ↔ x = y ∨ strict_op x y)\n(ne_of_str : ∀ {x y}, strict_op x y → x ≠ y)\n\ninstance colt : comp_op (@has_lt.lt ℚ _) :=\n{rev_op := @gt ℚ _,\n rev_op_is_rev := by intros; reflexivity,\n rel_of_sub_rel_zero := begin intros, constructor, exact lt_of_sub_neg, exact sub_neg_of_lt end,\n op_mul := begin intros, refine mul_lt_mul_of_pos_left _ _, repeat {assumption} end,\n op_inv := begin intros, fapply lt_of_mul_lt_mul_left, exact x, rw [←mul_assoc, rat.mul_pow_neg_one, one_mul], assumption, apply ne_of_gt, assumption, apply le_of_lt, assumption end }\n\ninstance cole : weak_comp_op (@has_le.le ℚ _) :=\n{rev_op := @ge ℚ _,\n rev_op_is_rev := by intros; reflexivity,\n rel_of_sub_rel_zero := begin intros, constructor, apply le_of_sub_nonpos, apply sub_nonpos_of_le end,\n op_mul := begin intros, apply mul_le_mul_of_nonneg_left, assumption, apply le_of_lt, assumption end,\n strict_op := @has_lt.lt ℚ _,\n disj := begin intros, constructor, apply eq_or_lt_of_le, apply le_of_eq_or_lt end,\n ne_of_str := @ne_of_lt ℚ _,\n op_inv := begin intros, fapply le_of_mul_le_mul_left, exact x, rw [←mul_assoc, rat.mul_pow_neg_one, one_mul], assumption, apply ne_of_gt, assumption, assumption end}\n\ninstance cogt : comp_op (@gt ℚ _) :=\n{rev_op := @has_lt.lt ℚ _,\n rev_op_is_rev := by intros; reflexivity,\n rel_of_sub_rel_zero := begin intros, constructor, exact lt_of_sub_pos, exact sub_pos_of_lt end,\n op_mul := begin intros, refine mul_lt_mul_of_pos_left _ _, repeat {assumption} end,\n op_inv := begin intros, fapply lt_of_mul_lt_mul_left, exact x, rw [←mul_assoc, rat.mul_pow_neg_one, one_mul], assumption, apply ne_of_gt, assumption, apply le_of_lt, assumption end}\n\ninstance coge : weak_comp_op (@ge ℚ _) :=\n{rev_op := @has_le.le ℚ _,\n rev_op_is_rev := by intros; reflexivity,\n rel_of_sub_rel_zero := begin intros, constructor, apply le_of_sub_nonneg, apply sub_nonneg_of_le end,\n op_mul := begin intros, apply mul_le_mul_of_nonneg_left, assumption, apply le_of_lt, assumption end,\n strict_op := @gt ℚ _,\n disj := begin intros, constructor, apply eq_or_gt_of_ge, apply ge_of_eq_or_gt end,\n ne_of_str := @ne_of_gt ℚ _,\n op_inv := begin intros, fapply le_of_mul_le_mul_left, exact x, rw [←mul_assoc, rat.mul_pow_neg_one, one_mul], assumption, apply ne_of_gt, assumption, assumption end}\n\ninstance coeq : comp_op (@eq ℚ) :=\n{rev_op := @eq ℚ,\n rev_op_is_rev := by cc,\n rel_of_sub_rel_zero := by intros; apply sub_eq_zero_iff_eq,\n op_mul := by cc,\n op_inv := begin intros, fapply eq_of_mul_eq_mul_left, exact x, apply ne_of_gt, assumption, rw [←mul_assoc, rat.mul_pow_neg_one, one_mul ], assumption, apply ne_of_gt, assumption end\n}\n\n@[reducible] private def strict_op := weak_comp_op.strict_op\n\n@[reducible] private def rev := comp_op.rev_op\nlemma rev_op_is_rev {o x y} [comp_op o] : rev o y x ↔ o x y := comp_op.rev_op_is_rev _ \n\nlemma op_mul_neg {o}  {x y c : ℚ} [comp_op o] (hc : c < 0) (h : o x y) : rev o (c*x) (c*y) :=\nhave o (x-y) 0, from (comp_op.rel_of_sub_rel_zero o).mpr h,\nhave o (-c*(x-y)) ((-c)*0), from comp_op.op_mul (neg_pos_of_neg hc) this,\nhave o (c*y - c*x) 0, begin\n rw [mul_sub, mul_zero, ←neg_mul_eq_neg_mul, ←neg_mul_eq_neg_mul, sub_neg_eq_add, add_comm] at this, assumption \nend,\nrev_op_is_rev.mpr ((comp_op.rel_of_sub_rel_zero o).mp this)\n\n/-\nset_option pp.all true\nexample : (-1 : ℚ) < 0 :=\nbegin\napply neg_of_neg_pos, -- fails\n--apply (@neg_of_neg_pos ℚ _), -- succeeds\n--refine neg_of_neg_pos _, -- succeeds\nend\n\nexample : (-1 : ℤ) < 0 :=\nbegin\napply neg_of_neg_pos, -- succeeds\nend\n-/\n\nlemma op_neg {o} {x y : ℚ} [comp_op o] (h : o x y) : rev o (-x) (-y) :=\nbegin\nrw [neg_eq_neg_one_mul, neg_eq_neg_one_mul y],\napply op_mul_neg,\nrefine neg_of_neg_pos _,\nexact zero_lt_one,\nassumption\nend\n \ntheorem sym_op_pos {o} [comp_op o] {lhs rhs c : ℚ} (hc : c > 0) (h : o lhs (c*rhs)) : rev o rhs ((1/c)*lhs) :=\nhave h' : o ((1/c)*lhs) ((1/c)*(c*rhs)), from comp_op.op_mul (one_div_pos_of_pos hc) h,\nsuffices o ((1/c)*lhs) rhs, by rw rev_op_is_rev; assumption,\nby rw [←mul_assoc, one_div_mul_cancel (ne_of_gt hc), one_mul] at h'; assumption\n--comp_op.rev_recip hc h\n\ntheorem sym_op_neg {o} [comp_op o] {lhs rhs c : ℚ} (hc : c < 0) (h : o lhs (c*rhs)) : o rhs ((1/c)*lhs) :=\nhave h' : rev o ((1/c)*lhs) ((1/c)*(c*rhs)), begin\napply op_mul_neg,\nrefine one_div_neg_of_neg _, repeat {assumption}\nend,\nsuffices rev o ((1/c)*lhs) rhs, begin\napply rev_op_is_rev.mp,\nassumption\nend,\nby rw [←mul_assoc, one_div_mul_cancel (ne_of_lt hc), one_mul] at h'; assumption\n\ntheorem diseq_sym {lhs rhs c : ℚ} (hc : c ≠ 0) (h : lhs ≠ c*rhs) : rhs ≠ (1/c) * lhs := \nsorry\n\ntheorem eq_sym {lhs rhs c : ℚ} (hc : c ≠ 0) (h : lhs = c*rhs) : rhs = (1/c) * lhs :=\nsorry\n\n/-section ineq_sym\nvariables {lhs rhs c : ℚ}\ntheorem ineq_sym_le_pos (hc : c > 0) (h : lhs ≤ c*rhs) : rhs ≥ (1/c) * lhs := \nsorry\n\ntheorem ineq_sym_lt_pos (hc : c > 0) (h : lhs < c*rhs) : rhs > (1/c) * lhs := \nsorry\n\ntheorem ineq_sym_ge_pos (hc : c > 0) (h : lhs ≥ c*rhs) : rhs ≤ (1/c) * lhs := \nsorry\n\ntheorem ineq_sym_gt_pos (hc : c > 0) (h : lhs > c*rhs) : rhs < (1/c) * lhs := \nsorry\n\ntheorem ineq_sym_le_neg (hc : c < 0) (h : lhs ≤ c*rhs) : rhs ≤ (1/c) * lhs := \nsorry\n\ntheorem ineq_sym_lt_neg (hc : c < 0) (h : lhs < c*rhs) : rhs < (1/c) * lhs := \nsorry\n\ntheorem ineq_sym_ge_neg (hc : c < 0) (h : lhs ≥ c*rhs) : rhs ≥ (1/c) * lhs := \nsorry\n\ntheorem ineq_sym_gt_neg (hc : c < 0) (h : lhs > c*rhs) : rhs > (1/c) * lhs := \nsorry\n\nmeta def name_of_comp_pos : comp → name\n| comp.le := ``ineq_sym_le_pos\n| comp.lt := ``ineq_sym_lt_pos\n| comp.ge := ``ineq_sym_ge_pos\n| comp.gt := ``ineq_sym_gt_pos\n\nmeta def name_of_comp_neg : comp → name\n| comp.le := ``ineq_sym_le_neg\n| comp.lt := ``ineq_sym_lt_neg\n| comp.ge := ``ineq_sym_ge_neg\n| comp.gt := ``ineq_sym_gt_neg\n\nmeta def name_of_c_and_comp (c : ℚ) (cmp : comp) : name :=\nif c ≥ 0 then name_of_comp_pos cmp else name_of_comp_neg cmp\n\nend ineq_sym-/\n\n/-theorem ineq_diseq_le {lhs rhs c : ℚ} (hc : lhs ≠ c*rhs) (h : lhs ≤ c*rhs) : lhs < c*rhs :=\nor.elim (lt_or_eq_of_le h) (id) (λ hp, absurd hp hc)\n\ntheorem ineq_diseq_ge {lhs rhs c : ℚ} (hc : lhs ≠ c*rhs) (h : lhs ≥ c*rhs) : lhs > c*rhs :=\nor.elim (lt_or_eq_of_le h) (id) (λ hp, absurd (eq.symm hp) hc)-/\n\ntheorem ineq_diseq {lhs rhs c : ℚ} {o} [weak_comp_op o] (hc : lhs ≠ c*rhs) (h : o lhs (c*rhs)) : \n        weak_comp_op.strict_op o lhs (c*rhs) :=\nor.elim ((weak_comp_op.disj o).mp h) (λ t, absurd t hc) id\n\n/-theorem ineq_diseq_sign_lhs_le {lhs rhs : ℚ} (hc : lhs ≠ 0) (h : lhs ≤ 0*rhs) : lhs < 0*rhs :=\nsorry\n\ntheorem ineq_diseq_sign_lhs_ge {lhs rhs : ℚ} (hc : lhs ≠ 0) (h : lhs ≥ 0*rhs) : lhs > 0*rhs :=\nsorry-/\n\ntheorem ineq_diseq_sign_lhs {lhs rhs : ℚ} (hc : lhs ≠ 0) {o} [weak_comp_op o] (h : o lhs (0*rhs)) :\n        weak_comp_op.strict_op o lhs (0*rhs) :=\nbegin\napply ineq_diseq,\nsimp *, assumption\nend\n\n/-theorem ineq_diseq_sign_rhs_le {rhs : ℚ} (hc : rhs ≠ 0) (h : rhs ≤ 0) : rhs < 0 :=\nsorry\n\ntheorem ineq_diseq_sign_rhs_ge {rhs : ℚ} (hc : rhs ≠ 0) (h : rhs ≥ 0) : rhs > 0 :=\nsorry-/\n\ntheorem ineq_diseq_sign_rhs {rhs : ℚ} (hc : rhs ≠ 0) {o} [weak_comp_op o] (h : o rhs 0) : weak_comp_op.strict_op o rhs 0 :=\nbegin\ncases (weak_comp_op.disj o).mp h,\nrepeat {cc}\nend\n\ntheorem op_ineq {lhs rhs c : ℚ} (h1 : lhs ≤ c*rhs) (h2 : lhs ≥ c*rhs) : lhs = c*rhs :=\nhave h : lhs = c*rhs ∨ lhs < c*rhs, from eq_or_lt_of_le h1,\nh.elim id (λ e, absurd h2 (not_le_of_gt e))\n\ntheorem op_zero_of_zero_op_neg_mul {o} [comp_op o] {c q : ℚ} (h : c < 0) (h2 : o 0 (c*q)) : o q 0 :=\nhave hc : 1 / c < 0, from one_div_neg_of_neg h,\nhave h' : _, from op_mul_neg hc h2,\nhave h'' : _, from rev_op_is_rev.mp h',\nhave hc' : (1/c)*(c*q) = q, by rw [←mul_assoc, one_div_mul_cancel, one_mul]; apply ne_of_lt h,\nby rw [hc', mul_zero] at h''; assumption\n\ntheorem rev_op_zero_of_neg_mul_op_zero {o} [comp_op o] {c q : ℚ} (h : c < 0) (h2 : o (c*q) 0) : rev o q 0 :=\nhave hc : 1 / c < 0, from one_div_neg_of_neg h,\nhave h' : _, from op_mul_neg hc h2,\nhave hc' : (1/c)*(c*q) = q, by rw [←mul_assoc, one_div_mul_cancel, one_mul]; apply ne_of_lt h,\nby rw [hc', mul_zero] at h'; assumption\n\ntheorem op_zero_of_pos_mul_op_zero {o} [comp_op o] {c q : ℚ} (h : c > 0) (h2 : o (c*q) 0) : o q 0 :=\nhave hc : 1 / c > 0, from one_div_pos_of_pos h,\nhave h' : _, from comp_op.op_mul hc h2,\nhave hc' : (1/c)*(c*q) = q, by rw [←mul_assoc, one_div_mul_cancel, one_mul]; apply ne_of_gt h,\nby rw [hc', mul_zero] at h'; assumption\n\nsection\nvariables {lhs : ℚ} (rhs : ℚ)\n/-theorem zero_mul_le (h : lhs ≤ 0) : lhs ≤ 0*rhs := by rw zero_mul; assumption\ntheorem zero_mul_lt (h : lhs < 0) : lhs < 0*rhs := by rw zero_mul; assumption\ntheorem zero_mul_ge (h : lhs ≥ 0) : lhs ≥ 0*rhs := by rw zero_mul; assumption\ntheorem zero_mul_gt (h : lhs > 0) : lhs > 0*rhs := by rw zero_mul; assumption\n\nmeta def zero_mul_name_of_comp : comp → name\n| comp.le := ``zero_mul_le\n| comp.lt := ``zero_mul_lt\n| comp.ge := ``zero_mul_ge\n| comp.gt := ``zero_mul_gt-/\ntheorem op_zero_mul {o} [comp_op o] (h : o lhs 0) : o lhs (0*rhs) := by simp *\n\nvariable {rhs}\n/-theorem zero_mul_le' (h : lhs ≤ 0*rhs) : lhs ≤ 0 := by rw -(zero_mul rhs); assumption\ntheorem zero_mul_lt' (h : lhs < 0*rhs) : lhs < 0 := by rw -(zero_mul rhs); assumption\ntheorem zero_mul_ge' (h : lhs ≥ 0*rhs) : lhs ≥ 0 := by rw -(zero_mul rhs); assumption\ntheorem zero_mul_gt' (h : lhs > 0*rhs) : lhs > 0 := by rw -(zero_mul rhs); assumption-/\n\ntheorem op_zero_mul' {o} [comp_op o] (h : o lhs (0*rhs)) : o lhs 0 := by rw ←(zero_mul rhs); assumption\n\n\n/-meta def zero_mul'_name_of_comp : comp → name\n| comp.le := ``zero_mul_le'\n| comp.lt := ``zero_mul_lt'\n| comp.ge := ``zero_mul_ge'\n| comp.gt := ``zero_mul_gt'-/\n\nend\n\ntheorem eq_zero_of_eq_mul_zero {lhs rhs : ℚ} (h : lhs = 0*rhs) : lhs = 0 :=\nby rw ←(zero_mul rhs); assumption\n\ntheorem ne_zero_of_ne_mul_zero {lhs rhs : ℚ} (h : lhs ≠ 0*rhs) : lhs ≠ 0 :=\nby rw ←(zero_mul rhs); assumption\n\ntheorem eq_zero_of_two_eqs_rhs {lhs rhs c1 c2 : ℚ} (h : lhs = c1*rhs) (h2 : lhs = c2*rhs) (hc : c1 ≠ c2) : rhs = 0 :=\nbegin\n rw h at h2,\n have h3 := sub_eq_zero_of_eq h2,\n rw ←sub_mul at h3,\n cases eq_zero_or_eq_zero_of_mul_eq_zero h3 with ha hb,\n apply absurd (eq_of_sub_eq_zero ha) hc,\n assumption\nend\n\ntheorem eq_zero_of_two_eqs_lhs {lhs rhs c1 c2 : ℚ} (h : lhs = c1*rhs) (h2 : lhs = c2*rhs) (hc : c1 ≠ c2) : lhs = 0 :=\nhave hr : rhs = 0, from eq_zero_of_two_eqs_rhs h h2 hc,\nbegin rw hr at h, rw mul_zero at h, assumption end\n\nsection\nvariables {lhs rhs c : ℚ} (h : lhs = 0)\ninclude h\n\n/-\nPUT THEOREMS FOR ineq_of_ineq_and_eq_zero_rhs here\n-/\n\nend\n\nsection\nvariables {lhs rhs c d : ℚ} \n--include h\n\n/- there are 16 possibilities here!\ntheorem sub_le_zero_of_le {a b : ℚ} (h : a ≤ b) : a - b ≤ 0 := sorry\ntheorem sub_lt_zero_of_lt {a b : ℚ} (h : a < b) : a - b < 0 := sorry\ntheorem sub_ge_zero_of_ge {a b : ℚ} (h : a ≥ b) : a - b ≥ 0 := sorry\ntheorem sub_gt_zero_of_gt {a b : ℚ} (h : a > b) : a - b > 0 := sorry-/\n\ntheorem sub_op_zero_of_op {a b : ℚ} {o} [comp_op o] (h : o a b) : o (a-b) 0 :=\n(comp_op.rel_of_sub_rel_zero _).mpr h\n\nvariable (h : lhs = d*rhs)\ninclude h\n\n-- is this used?\ntheorem op_eq_coeff_sub_pos {o} [comp_op o] (h1 : o lhs (c*rhs)) (h2 : d - c > 0) : o rhs 0 :=\nhave o (d*rhs) (c*rhs), by rw ←h; assumption,\nhave o (d*rhs - c*rhs) 0, from sub_op_zero_of_op this,\nhave o ((d-c)*rhs) 0, by rw sub_mul; assumption,\nhave dc : 1/(d-c) > 0, from one_div_pos_of_pos h2,\nlet cmp := comp_op.op_mul dc this in\nbegin\nrw [mul_zero, ←mul_assoc, div_mul_cancel _ (ne_of_gt h2), one_mul] at cmp,\nassumption\nend\n\n/-theorem le_gt_rhs (h1 : lhs ≤ c*rhs) (h2 : d - c > 0) : rhs ≤ 0 :=\nhave d*rhs ≤ c*rhs, by rw -h; assumption,\nhave d*rhs - c*rhs ≤ 0, from sub_le_zero_of_le this,\nhave (d - c)*rhs ≤ 0, by rw sub_mul; assumption,\nshow rhs ≤ 0, from nonpos_of_mul_nonpos_left this h2\n\ntheorem lt_gt_rhs (h1 : lhs < c*rhs) (h2 : d - c > 0) : rhs < 0 :=\nhave d*rhs < c*rhs, by rw -h; assumption,\nhave d*rhs - c*rhs < 0, from sub_lt_zero_of_lt this,\nhave (d - c)*rhs < 0, by rw sub_mul; assumption,\nshow rhs < 0, from neg_of_mul_neg_left this (le_of_lt h2)\n\ntheorem ge_gt_rhs (h1 : lhs ≥ c*rhs) (h2 : d - c > 0) : rhs ≥ 0 :=\nhave d*rhs ≥ c*rhs, by rw -h; assumption,\nhave d*rhs - c*rhs ≥ 0, from sub_ge_zero_of_ge this,\nhave (d - c)*rhs ≥ 0, by rw sub_mul; assumption,\nshow rhs ≥ 0, from nonneg_of_mul_nonneg_left this h2\n\ntheorem gt_gt_rhs (h1 : lhs > c*rhs) (h2 : d - c > 0) : rhs > 0 :=\nhave d*rhs > c*rhs, by rw -h; assumption,\nhave d*rhs - c*rhs > 0, from sub_gt_zero_of_gt this,\nhave (d - c)*rhs > 0, by rw sub_mul; assumption,\nshow rhs > 0, from pos_of_mul_pos_left this (le_of_lt h2)-/\n\nomit h\ntheorem sub_lt_of_lt (h1 : lhs < c*rhs) : 1*lhs + (-c)*rhs < 0 :=\nbegin\n rw [neg_mul_eq_neg_mul_symm, one_mul],\n exact sub_neg_of_lt h1\nend\n\ntheorem sub_le_of_le (h1 : lhs ≤ c*rhs) : 1*lhs + (-c)*rhs ≤ 0 :=\nbegin\n rw [neg_mul_eq_neg_mul_symm, one_mul],\n rw [add_neg_le_iff_le_add', add_zero],\n exact h1\nend\n\ntheorem sub_lt_of_gt (h1 : lhs > c*rhs) : (-1)*lhs + c*rhs < 0 :=\nbegin\n rw [add_comm, ←neg_mul_eq_neg_mul, one_mul],\n exact sub_neg_of_lt h1\nend\n\ntheorem sub_le_of_ge (h1 : lhs ≥ c*rhs) : (-1)*lhs + c*rhs ≤ 0 :=\nbegin\n rw [add_comm, ←neg_mul_eq_neg_mul, one_mul],\n exact sub_nonpos_of_le h1\nend\n\ntheorem mul_lt_of_gt {rhs : ℚ} (h1 : lhs > 0*rhs) : (-1)*lhs < 0 :=\nbegin\n  simp at h1,\n  simp only [neg_mul_eq_neg_mul_symm, one_mul],\n  exact neg_neg_of_pos h1\nend\n\ntheorem mul_le_of_ge {rhs : ℚ} (h1 : lhs ≥ 0*rhs) : (-1)*lhs ≤ 0 :=\nbegin\n  simp at h1,\n  simp only [neg_mul_eq_neg_mul_symm, one_mul],\n  exact neg_le_of_neg_le h1\nend\n\ntheorem mul_lt_of_lt {rhs : ℚ} (h1 : lhs < 0*rhs) : 1*lhs < 0 :=\nbegin\n  simp at h1,\n  rw [one_mul],\n  exact h1\nend\n\ntheorem mul_le_of_le {rhs : ℚ} (h1 : lhs ≤ 0*rhs) : 1*lhs ≤ 0 :=\nbegin\n  simp at h1,\n  rw [one_mul],\n  exact h1\nend\n\nend\n\nmeta def sum_form_name_of_comp_single : comp → name\n| comp.lt := ``mul_lt_of_lt\n| comp.le := ``mul_le_of_le\n| comp.gt := ``mul_lt_of_gt\n| comp.ge := ``mul_le_of_ge\n\nmeta def sum_form_name_of_comp : comp → name\n| comp.lt := ``sub_lt_of_lt\n| comp.le := ``sub_le_of_le\n| comp.gt := ``sub_lt_of_gt\n| comp.ge := ``sub_le_of_ge\n\ntheorem gt_self_contr {e : ℚ} (h : e > 1*e) : false :=\nbegin apply lt_irrefl e, rw one_mul at h, assumption end\n\ntheorem lt_self_contr {e : ℚ} (h : e < 1*e) : false :=\nbegin apply lt_irrefl e, rw one_mul at h, assumption end\n\ntheorem le_gt_contr {e : ℚ} (h1 : e ≤ 0) (h2 : e > 0) : false :=\nnot_le_of_gt h2 h1\n\ntheorem ge_lt_contr {e : ℚ} (h1 : e ≥ 0) (h2 : e < 0) : false :=\nnot_le_of_gt h2 h1\n\ntheorem gt_lt_contr {e : ℚ} (h1 : e > 0) (h2 : e < 0) : false :=\nnot_le_of_gt h1 (le_of_lt h2)\n\ntheorem op_of_sum_op_zero_pos {o} [comp_op o] {lhs rhs a b : ℚ} (h : o (a*lhs + b*rhs) 0)\n        (h2 : a > 0) : o lhs (((-b)/a)*rhs) :=\nhave o (a*lhs - -(b*rhs)) 0, by rw sub_neg_eq_add; assumption,\nhave o (a*lhs) (-(b*rhs)), from (comp_op.rel_of_sub_rel_zero _).mp this,\nlet np := comp_op.op_mul (one_div_pos_of_pos h2) this in\nbegin\nrw [←mul_assoc, one_div_mul_cancel (ne_of_gt h2), one_mul, neg_mul_eq_neg_mul, ←mul_assoc, div_mul_eq_mul_div, one_mul] at np, assumption\nend\n\ntheorem op_of_sum_op_zero_neg {o} [comp_op o] {lhs rhs a b : ℚ} (h : o (a*lhs + b*rhs) 0)\n        (h2 : a < 0) : rev o lhs (((-b)/a)*rhs) :=\nhave o (a*lhs - -(b*rhs)) 0, by rw sub_neg_eq_add; assumption,\nhave o (a*lhs) (-(b*rhs)), from (comp_op.rel_of_sub_rel_zero _).mp this,\nlet np := comp_op.op_mul (neg_pos_of_neg (one_div_neg_of_neg h2)) this in\n\nbegin\nrw [←mul_assoc, ←neg_mul_eq_neg_mul, one_div_mul_cancel (ne_of_lt h2), ←neg_mul_eq_neg_mul, one_mul, neg_mul_neg, ←mul_assoc, div_mul_eq_mul_div, one_mul ] at np,\nrw [←(neg_neg lhs), neg_div, ←neg_mul_eq_neg_mul],\napply op_neg,\nassumption\nend\n\ntheorem rev_op_zero_of_op {o} [comp_op o] {e : ℚ} (h : o e 0) : rev o (-e) 0 :=\nsuffices rev o (-e) (-0), by rw ←neg_zero; assumption,\nbegin\nrw [neg_eq_neg_one_mul, neg_eq_neg_one_mul (0 : ℚ)],\napply op_mul_neg,\napply neg_of_neg_pos _,\nexact zero_lt_one,\nassumption\nend\n\ninstance {o} [comp_op o] : comp_op (rev o) :=\n{ op_inv := sorry,\n  op_mul := sorry,\n  rel_of_sub_rel_zero := sorry,\n  rev_op_is_rev := sorry,\n  rev_op := o\n}\n\ntheorem rev_rev {o} [comp_op o] : rev (rev o) = o :=\nbegin\napply funext,\nintro x, apply funext, intro y,\nrw [rev_op_is_rev, rev_op_is_rev]\nend\n\nclass one_op_one_div_class (o : ℚ → ℚ → Prop) :=\n(oood : ∀ {x}, 0 < x → o x 1 → o 1 (rat.pow x (-1)))\n\ninstance ooodlt : one_op_one_div_class (@has_lt.lt rat _) :=\n⟨begin intro, rw rat.pow_neg_one, apply one_lt_one_div end⟩\n\ninstance ooodle : one_op_one_div_class (@has_le.le rat _) :=\n⟨begin intro, rw rat.pow_neg_one, apply one_le_one_div end⟩\n\ninstance ooodgt : one_op_one_div_class (@gt rat _) :=\n⟨begin intros, rw rat.pow_neg_one, change 1/1 > 1/x, apply one_div_lt_one_div_of_lt, apply zero_lt_one, assumption end⟩\n\ninstance ooodge : one_op_one_div_class (@ge rat _) :=\n⟨begin intros, rw rat.pow_neg_one, change 1/1 ≥ 1/x, apply one_div_le_one_div_of_le, apply zero_lt_one, assumption end⟩\n\n\ninstance {o} [comp_op o] [one_op_one_div_class o] : one_op_one_div_class (rev o) :=\n⟨begin\n intros x h hr,\n apply rev_op_is_rev.mp,\n rw rev_rev,\n have : o ((rat.pow x (-1))*1) 1 := comp_op.op_inv h _,\n simp [rat.pow] at this, rw rat.pow_neg_one at this,\n rw rat.pow_neg_one,\n apply this,\n rw rev_op_is_rev at hr, rw mul_one, exact hr\nend⟩\n\ndef one_op_one_div {o : ℚ → ℚ → Prop} [h : one_op_one_div_class o] := @one_op_one_div_class.oood _ h\n\ntheorem one_op_inv_mul_of_op_of_pos {o} [comp_op o] {lhs rhs c : ℚ} (h : o lhs (c*rhs)) (hp : lhs > 0) :\n         o 1 (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) :=\nhave (rat.pow lhs (-1)) > 0, by rw [rat.pow_neg_one]; apply one_div_pos_of_pos hp,\nhave o ( (rat.pow lhs (-1))*lhs) ( (rat.pow lhs (-1))*(c*rhs)), from comp_op.op_mul this h,\nbegin\n  rw [rat.pow_neg_one, ← inv_eq_one_div] at ⊢ this,\n  rw [rat.pow_one],\n  rw [inv_mul_cancel (ne_of_gt hp)] at this,\n  rw [mul_comm lhs⁻¹, ← mul_assoc, mul_comm (c*rhs)],\n  exact this\nend\n\ntheorem one_op_inv_mul_of_op_of_neg {o} [comp_op o] {lhs rhs c : ℚ} (h : o lhs (c*rhs)) (hp : lhs < 0) :\n         rev o 1 (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) :=\n--o (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) 1 :=\nhave (rat.pow lhs (-1)) < 0, by rw [rat.pow_neg_one]; apply one_div_neg_of_neg hp,\nhave rev o ( (rat.pow lhs (-1))*lhs) ( (rat.pow lhs (-1))*(c*rhs)), from op_mul_neg this h,\nbegin\n  rw [rat.pow_neg_one, ← inv_eq_one_div] at ⊢ this,\n  rw [rat.pow_one],\n  rw [inv_mul_cancel (ne_of_lt hp)] at this,\n  rw [mul_comm lhs⁻¹, ← mul_assoc, mul_comm (c*rhs)],\n  exact this\nend\n\n\ntheorem one_op_inv_mul_of_lt_of_pos_pos_flipped {lhs rhs c : ℚ} {o} [one_op_one_div_class o]\n        (h : o (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) 1) \n        (hl : lhs > 0) (hr : rhs > 0) (hc : c > 0) : o 1 ((1/c) * ((rat.pow lhs 1)*(rat.pow rhs (-1)))) :=\nhave rat.pow lhs (-1) > 0, by rw rat.pow_neg_one; apply one_div_pos_of_pos hl,\nhave c * ((rat.pow lhs (-1)) * rhs) > 0, by repeat {apply mul_pos _ _, repeat {assumption}},\nhave o 1 (rat.pow (c * ((rat.pow lhs (-1)) * (rat.pow rhs 1))) (-1)), by simp only [rat.pow_one] at *; apply one_op_one_div this h,\nby simp only [rat.pow_neg_one, rat.pow_one] at ⊢ this; rw [←one_div_mul_one_div, ←one_div_mul_one_div, one_div_one_div] at this; assumption\n\ntheorem one_op_inv_mul_of_lt_of_pos_pos_flipped' {lhs rhs c : ℚ} {o} [comp_op o] [one_op_one_div_class o]\n        (h : o 1 (c*((rat.pow lhs (-1))*(rat.pow rhs 1)))) \n        (hl : lhs > 0) (hr : rhs > 0) (hc : c > 0) : (rev o) 1 ((1/c) * ((rat.pow lhs 1)*(rat.pow rhs (-1)))) :=\nhave h' : _ := (comp_op.rev_op_is_rev _).mpr h,\none_op_inv_mul_of_lt_of_pos_pos_flipped h' hl hr hc\n\n/-theorem one_lt_inv_mul_of_lt_of_pos_flipped' {lhs rhs c : ℚ} (h : 1 > (c*((1/lhs)*rhs))) \n        (hl : lhs > 0) (hr : rhs > 0) (hc : c > 0) : 1 < ((1/c) * (lhs*(1/rhs))) :=\n/-have 1/lhs > 0, from one_div_pos_of_pos hl,\nhave c * ((1/lhs) * rhs) > 0, by repeat {apply mul_pos, repeat {assumption}},\nhave 1 < 1 / (c * ((1/lhs) * rhs)), from one_lt_one_div this h,\nby rw [-one_div_mul_one_div, -one_div_mul_one_div, one_div_one_div] at this; assumption-/\none_lt_inv_mul_of_lt_of_pos_flipped h hl hr hc-/\n\n/-theorem one_le_inv_mul_of_le_of_pos_flipped {lhs rhs c : ℚ} (h : 1 ≥ (c*((1/lhs)*rhs))) \n        (hl : lhs > 0) (hr : rhs > 0) (hc : c > 0) : 1 ≤ ((1/c) * (lhs*(1/rhs))) :=\nhave 1/lhs > 0, from one_div_pos_of_pos hl,\nhave c * ((1/lhs) * rhs) > 0, by repeat {apply mul_pos, repeat {assumption}},\nhave 1 ≤ 1 / (c * ((1/lhs) * rhs)), from one_le_one_div this h,\nby rw [-one_div_mul_one_div, -one_div_mul_one_div, one_div_one_div] at this; assumption-/\n\ntheorem one_op_inv_mul_of_lt_of_pos_neg_flipped {lhs rhs c : ℚ} {o} [comp_op o] [one_op_one_div_class o]\n        (h : (rev o) 1 (c*((rat.pow lhs (-1))*(rat.pow rhs 1)))) \n        --  (h : o (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) 1) \n        (hl : lhs > 0) (hr : rhs < 0) (hc : c < 0) : \no 1 ((1/c) * ((rat.pow lhs 1)*(rat.pow rhs (-1)))) :=\n--(rev o) 1 (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) :=\n--h \nsorry\n/-have rat.pow lhs (-1) > 0, by rw rat.pow_neg_one; apply one_div_pos_of_pos hl,\nhave c * ((rat.pow lhs (-1)) * rhs) > 0, \n  begin apply mul_pos_of_neg_of_neg _ _, assumption, apply mul_neg_of_pos_of_neg _ _, repeat {assumption} end,\nhave o 1 (rat.pow (c * ((rat.pow lhs (-1)) * (rat.pow rhs 1))) (-1)), by simp only [rat.pow_one] at *; apply one_op_one_div this h,\nby simp only [rat.pow_neg_one, rat.pow_one] at this ⊢; rw [←one_div_mul_one_div, ←one_div_mul_one_div, one_div_one_div] at this; assumption-/\n\n/-theorem one_lt_inv_mul_of_lt_of_neg_flipped {lhs rhs c : ℚ} (h : 1 > (c*((1/lhs)*rhs))) \n        (hl : lhs > 0) (hr : rhs < 0) (hc : c < 0) : 1 < ((1/c) * (lhs*(1/rhs))) :=\nhave 1/lhs > 0, from one_div_pos_of_pos hl,\nhave c * ((1/lhs) * rhs) > 0, \n  begin apply mul_pos_of_neg_of_neg, assumption, apply mul_neg_of_pos_of_neg, repeat {assumption} end,\nhave 1 < 1 / (c * ((1/lhs) * rhs)), from one_lt_one_div this h,\nby rw [-one_div_mul_one_div, -one_div_mul_one_div, one_div_one_div] at this; assumption\n\ntheorem one_le_inv_mul_of_le_of_neg_flipped {lhs rhs c : ℚ} (h : 1 ≥ (c*((1/lhs)*rhs))) \n        (hl : lhs > 0) (hr : rhs < 0) (hc : c < 0) : 1 ≤ ((1/c) * (lhs*(1/rhs))) :=\nhave 1/lhs > 0, from one_div_pos_of_pos hl,\nhave c * ((1/lhs) * rhs) > 0, \n  begin apply mul_pos_of_neg_of_neg, assumption, apply mul_neg_of_pos_of_neg, repeat {assumption} end,\nhave 1 ≤ 1 / (c * ((1/lhs) * rhs)), from one_le_one_div this h,\nby rw [-one_div_mul_one_div, -one_div_mul_one_div, one_div_one_div] at this; assumption-/\n                             \n\ntheorem one_op_inv_mul_of_lt_of_neg_pos_flipped {lhs rhs c : ℚ} {o} [comp_op o] [one_op_one_div_class o]\n        --(h : o (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) 1) \n          (h : (rev o) 1 (c*((rat.pow lhs (-1))*(rat.pow rhs 1)))) \n        (hl : lhs < 0) (hr : rhs > 0) (hc : c < 0) :\n            -- o 1 ((1/c) * ((rat.pow lhs 1)*(rat.pow rhs (-1)))) :=\n            (rev o) 1 (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) := h\n--have h : o (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) 1, from rev_op_is_rev.mp h, -- kill this line to change order\n/-have rat.pow lhs (-1) < 0, by rw rat.pow_neg_one; apply one_div_neg_of_neg hl,\nhave c * ((rat.pow lhs (-1)) * rhs) > 0, \n  begin apply mul_pos_of_neg_of_neg _ _, assumption, apply mul_neg_of_neg_of_pos _ _, repeat {assumption} end,\nhave o 1 (rat.pow (c * ((rat.pow lhs (-1)) * (rat.pow rhs 1))) (-1)), by simp only [rat.pow_one] at *; apply one_op_one_div this h,\nby simp only [rat.pow_neg_one, rat.pow_one] at ⊢ this; rw [←one_div_mul_one_div, ←one_div_mul_one_div, one_div_one_div] at this; assumption-/\n\ntheorem one_op_inv_mul_of_lt_of_neg_neg_flipped {lhs rhs c : ℚ} {o} [one_op_one_div_class o]\n        (h : o (c*((rat.pow lhs (-1))*(rat.pow rhs 1))) 1) \n        (hl : lhs < 0) (hr : rhs < 0) (hc : c > 0) : o 1 ((1/c) * ((rat.pow lhs 1)*(rat.pow rhs (-1)))) :=\nhave rat.pow lhs (-1) < 0, by rw rat.pow_neg_one; apply one_div_neg_of_neg hl,\nhave c * ((rat.pow lhs (-1)) * rhs) > 0, \n  begin apply mul_pos _ _, assumption, apply mul_pos_of_neg_of_neg _ _, repeat {assumption} end,\nhave o 1 (rat.pow (c * ((rat.pow lhs (-1)) * (rat.pow rhs 1))) (-1)), by simp only [rat.pow_one] at *; apply one_op_one_div this h,\nby simp only [rat.pow_neg_one,  rat.pow_one] at ⊢ this; rw [←one_div_mul_one_div, ←one_div_mul_one_div, one_div_one_div] at this; assumption\n\n\ntheorem one_eq_div_of_eq {lhs rhs c : ℚ} (h : lhs = c*rhs) (hl : lhs ≠ 0) : 1 = c*((rat.pow lhs (-1))*(rat.pow rhs 1)) :=\nhave (rat.pow lhs (-1))*lhs = (rat.pow lhs (-1))*(c*rhs), by cc,\nsorry --by finish\n\ntheorem lt_pos_pow {a : ℚ} (h : 1 < a) : Π (n : ℕ), 1 < rat.pow a (int.of_nat (n+1))\n| 0 := by simp [*, rat.pow]\n| (k+1) := begin simp [*, rat.pow], rw ←(mul_one (1:ℚ)), apply mul_lt_mul _ _ _ _, assumption, apply le_of_lt, apply lt_pos_pow, exact zero_lt_one, apply le_trans, apply zero_le_one, apply le_of_lt, assumption end\n\n\ntheorem le_pos_pow {a : ℚ} (h : 1 ≤ a) : Π (n : ℕ), 1 ≤ rat.pow a (int.of_nat (n+1))\n| 0 := by simp [*, rat.pow]\n| (k+1) := begin simp [*, rat.pow], rw ←(mul_one (1:ℚ)), apply mul_le_mul, assumption, apply le_pos_pow, apply zero_le_one, apply le_trans, apply zero_le_one, assumption end\n\ntheorem lt_pos_pow' {a : ℚ} (h : 1 < a) : Π {z : ℤ} (hz : z > 0), 1 < rat.pow a z\n| (int.of_nat 0) hz := false.elim $ lt_irrefl _ hz\n| (int.of_nat (k+1)) hz := lt_pos_pow h _\n| -[1+k] hz := false.elim $ lt_irrefl _ $ lt.trans (int.neg_succ_lt_zero _) hz\n\ntheorem le_pos_pow' {a : ℚ} (h : 1 ≤ a) : Π {z : ℤ} (hz : z > 0), 1 ≤ rat.pow a z\n| (int.of_nat 0) hz := false.elim $ lt_irrefl _ hz\n| (int.of_nat (k+1)) hz := le_pos_pow h _\n| -[1+k] hz := false.elim $ lt_irrefl _ $ lt.trans (int.neg_succ_lt_zero _) hz\n\ntheorem eq_pow {a : ℚ} (h : 1 = a) (z : ℤ) : 1 = rat.pow a z :=\nhave rat.pow 1 z = 1, from rat.one_pow _,\nby cc\n\ntheorem eq_pow' {a b : ℚ} {z : ℤ} (h : 1 = rat.pow (a * b) z) : 1 = rat.pow a z * rat.pow b z := sorry\n\ntheorem ne_of_strict_op {o} [weak_comp_op o] {a : ℚ} (h : strict_op o a 0) : a ≠ 0 :=\nweak_comp_op.ne_of_str h\n\n/-theorem op_inv_n {o} [comp_op o] {x y z : ℚ} {p : ℤ} (hx : x > 0) (h : o z ((rat.pow x p)*y)) : o ((rat.pow x (-p))*z) y := \nbegin\ninduction p with a a,\ninduction a,\nchange int.of_nat 0 with 0 at h,\nsimp [rat.pow, int.of_nat],   \nend-/\n\n\n-- assumes lhs > rhs as exprs. 1 R coeff* lhs^el * rhs^er ==> ineq_data\ntheorem op_of_one_op_pos {o} [comp_op o] {lhs rhs c : ℚ} (hlhs : lhs > 0) {el er : ℤ} (h : o 1 (c*(rat.pow lhs (el) * rat.pow rhs er))) : o (rat.pow lhs (-el)) (c*rat.pow rhs er) :=\nsorry\n\ntheorem op_of_one_op_neg {o} [comp_op o] {lhs rhs c : ℚ} (hlhs : lhs < 0) {el er : ℤ} (h : o 1 (c*(rat.pow lhs (el) * rat.pow rhs er))) : (rev o) (rat.pow lhs el) (c*rat.pow rhs er) :=\nsorry\n\ntheorem op_of_inv_op_inv_pow {o} [comp_op o] {lhs rhs c : ℚ} (h : o (rat.pow lhs (-1)) (c*rat.pow rhs (-1))) : rev o lhs (c*rhs) := sorry\n\ntheorem op_of_op_pow {o} [comp_op o] {lhs rhs c : ℚ} (h : o (rat.pow lhs 1) (c*rat.pow rhs 1)) : o lhs (c*rhs) := \nby simp [rat.pow_one, *] at *\n\nprivate meta def norm_num_inter : tactic unit := `[norm_num]\n\ntheorem one_op_of_op_inv {o} [comp_op o] {rhs c : ℚ} (h : o 1 (c*rat.pow rhs (-1))) : rev o 1 ((1/c)*rhs) :=\nsorry\n\ntheorem one_op_of_op {o} [comp_op o] {rhs c : ℚ} (h : o 1 (c * rat.pow rhs 1)) : o 1 (c*rhs) :=\nby simp [rat.pow_one, *] at *\n\ntheorem op_zero_of_mul_op_zero_of_pos {o} [comp_op o] {rhs c : ℚ} (h : o (c*rhs) 0) (hc : c > 0) : o rhs 0 := sorry\n\ntheorem op_zero_of_mul_op_zero_of_neg {o} [comp_op o] {rhs c : ℚ} (h : o (c*rhs) 0) (hc : c < 0) : rev o rhs 0 := sorry\n\nend polya\n", "meta": {"author": "robertylewis", "repo": "lean_polya", "sha": "1da14d60a55ad6cd8af8017b1b64990fccb66ab7", "save_path": "github-repos/lean/robertylewis-lean_polya", "path": "github-repos/lean/robertylewis-lean_polya/lean_polya-1da14d60a55ad6cd8af8017b1b64990fccb66ab7/src/reconstruction_theorems.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.4529757664677083}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport algebra.lie.abelian\nimport algebra.lie.ideal_operations\nimport order.hom.basic\n\n/-!\n# Solvable Lie algebras\n\nLike groups, Lie algebras admit a natural concept of solvability. We define this here via the\nderived series and prove some related results. We also define the radical of a Lie algebra and\nprove that it is solvable when the Lie algebra is Noetherian.\n\n## Main definitions\n\n  * `lie_algebra.derived_series_of_ideal`\n  * `lie_algebra.derived_series`\n  * `lie_algebra.is_solvable`\n  * `lie_algebra.is_solvable_add`\n  * `lie_algebra.radical`\n  * `lie_algebra.radical_is_solvable`\n  * `lie_algebra.derived_length_of_ideal`\n  * `lie_algebra.derived_length`\n  * `lie_algebra.derived_abelian_of_ideal`\n\n## Tags\n\nlie algebra, derived series, derived length, solvable, radical\n-/\n\nuniverses u v w w₁ w₂\n\nvariables (R : Type u) (L : Type v) (M : Type w) {L' : Type w₁}\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L] [lie_ring L'] [lie_algebra R L']\nvariables (I J : lie_ideal R L) {f : L' →ₗ⁅R⁆ L}\n\nnamespace lie_algebra\n\n/-- A generalisation of the derived series of a Lie algebra, whose zeroth term is a specified ideal.\n\nIt can be more convenient to work with this generalisation when considering the derived series of\nan ideal since it provides a type-theoretic expression of the fact that the terms of the ideal's\nderived series are also ideals of the enclosing algebra.\n\nSee also `lie_ideal.derived_series_eq_derived_series_of_ideal_comap` and\n`lie_ideal.derived_series_eq_derived_series_of_ideal_map` below. -/\ndef derived_series_of_ideal (k : ℕ) : lie_ideal R L → lie_ideal R L := (λ I, ⁅I, I⁆)^[k]\n\n@[simp] lemma derived_series_of_ideal_zero :\n  derived_series_of_ideal R L 0 I = I := rfl\n\n@[simp] lemma derived_series_of_ideal_succ (k : ℕ) :\n  derived_series_of_ideal R L (k + 1) I =\n  ⁅derived_series_of_ideal R L k I, derived_series_of_ideal R L k I⁆ :=\nfunction.iterate_succ_apply' (λ I, ⁅I, I⁆) k I\n\n/-- The derived series of Lie ideals of a Lie algebra. -/\nabbreviation derived_series (k : ℕ) : lie_ideal R L := derived_series_of_ideal R L k ⊤\n\nlemma derived_series_def (k : ℕ) :\n  derived_series R L k = derived_series_of_ideal R L k ⊤ := rfl\n\nvariables {R L}\n\nlocal notation `D` := derived_series_of_ideal R L\n\nlemma derived_series_of_ideal_add (k l : ℕ) : D (k + l) I = D k (D l I) :=\nbegin\n  induction k with k ih,\n  { rw [zero_add, derived_series_of_ideal_zero], },\n  { rw [nat.succ_add k l, derived_series_of_ideal_succ, derived_series_of_ideal_succ, ih], },\nend\n\n@[mono] lemma derived_series_of_ideal_le {I J : lie_ideal R L} {k l : ℕ} (h₁ : I ≤ J) (h₂ : l ≤ k) :\n  D k I ≤ D l J :=\nbegin\n  revert l, induction k with k ih; intros l h₂,\n  { rw le_zero_iff at h₂, rw [h₂, derived_series_of_ideal_zero], exact h₁, },\n  { have h : l = k.succ ∨ l ≤ k, by rwa [le_iff_eq_or_lt, nat.lt_succ_iff] at h₂,\n    cases h,\n    { rw [h, derived_series_of_ideal_succ, derived_series_of_ideal_succ],\n      exact lie_submodule.mono_lie _ _ _ _ (ih (le_refl k)) (ih (le_refl k)), },\n    { rw derived_series_of_ideal_succ, exact le_trans (lie_submodule.lie_le_left _ _) (ih h), }, },\nend\n\nlemma derived_series_of_ideal_succ_le (k : ℕ) : D (k + 1) I ≤ D k I :=\nderived_series_of_ideal_le (le_refl I) k.le_succ\n\nlemma derived_series_of_ideal_le_self (k : ℕ) : D k I ≤ I :=\nderived_series_of_ideal_le (le_refl I) (zero_le k)\n\nlemma derived_series_of_ideal_mono {I J : lie_ideal R L} (h : I ≤ J) (k : ℕ) : D k I ≤ D k J :=\nderived_series_of_ideal_le h (le_refl k)\n\nlemma derived_series_of_ideal_antitone {k l : ℕ} (h : l ≤ k) : D k I ≤ D l I :=\nderived_series_of_ideal_le (le_refl I) h\n\nlemma derived_series_of_ideal_add_le_add (J : lie_ideal R L) (k l : ℕ) :\n  D (k + l) (I + J) ≤ (D k I) + (D l J) :=\nbegin\n  let D₁ : lie_ideal R L →o lie_ideal R L :=\n  { to_fun    := λ I, ⁅I, I⁆,\n    monotone' := λ I J h, lie_submodule.mono_lie I J I J h h, },\n  have h₁ : ∀ (I J : lie_ideal R L), D₁ (I ⊔ J) ≤ (D₁ I) ⊔ J,\n  { simp [lie_submodule.lie_le_right, lie_submodule.lie_le_left, le_sup_of_le_right], },\n  rw ← D₁.iterate_sup_le_sup_iff at h₁,\n  exact h₁ k l I J,\nend\n\nlemma derived_series_of_bot_eq_bot (k : ℕ) : derived_series_of_ideal R L k ⊥ = ⊥ :=\nby { rw eq_bot_iff, exact derived_series_of_ideal_le_self ⊥ k, }\n\nlemma abelian_iff_derived_one_eq_bot : is_lie_abelian I ↔ derived_series_of_ideal R L 1 I = ⊥ :=\nby rw [derived_series_of_ideal_succ, derived_series_of_ideal_zero,\n  lie_submodule.lie_abelian_iff_lie_self_eq_bot]\n\nlemma abelian_iff_derived_succ_eq_bot (I : lie_ideal R L) (k : ℕ) :\n  is_lie_abelian (derived_series_of_ideal R L k I) ↔ derived_series_of_ideal R L (k + 1) I = ⊥ :=\nby rw [add_comm, derived_series_of_ideal_add I 1 k, abelian_iff_derived_one_eq_bot]\n\nend lie_algebra\n\nnamespace lie_ideal\n\nopen lie_algebra\n\nvariables {R L}\n\nlemma derived_series_eq_derived_series_of_ideal_comap (k : ℕ) :\n  derived_series R I k = (derived_series_of_ideal R L k I).comap I.incl :=\nbegin\n  induction k with k ih,\n  { simp only [derived_series_def, comap_incl_self, derived_series_of_ideal_zero], },\n  { simp only [derived_series_def, derived_series_of_ideal_succ] at ⊢ ih, rw ih,\n    exact comap_bracket_incl_of_le I\n      (derived_series_of_ideal_le_self I k) (derived_series_of_ideal_le_self I k), },\nend\n\nlemma derived_series_eq_derived_series_of_ideal_map (k : ℕ) :\n  (derived_series R I k).map I.incl = derived_series_of_ideal R L k I :=\nby { rw [derived_series_eq_derived_series_of_ideal_comap, map_comap_incl, inf_eq_right],\n     apply derived_series_of_ideal_le_self, }\n\nlemma derived_series_eq_bot_iff (k : ℕ) :\n  derived_series R I k = ⊥ ↔ derived_series_of_ideal R L k I = ⊥ :=\nby rw [← derived_series_eq_derived_series_of_ideal_map, map_eq_bot_iff, ker_incl, eq_bot_iff]\n\nlemma derived_series_add_eq_bot {k l : ℕ} {I J : lie_ideal R L}\n  (hI : derived_series R I k = ⊥) (hJ : derived_series R J l = ⊥) :\n  derived_series R ↥(I + J) (k + l) = ⊥ :=\nbegin\n  rw lie_ideal.derived_series_eq_bot_iff at hI hJ ⊢,\n  rw ← le_bot_iff,\n  let D := derived_series_of_ideal R L, change D k I = ⊥ at hI, change D l J = ⊥ at hJ,\n  calc D (k + l) (I + J) ≤ (D k I) + (D l J) : derived_series_of_ideal_add_le_add I J k l\n                     ... ≤ ⊥ : by { rw [hI, hJ], simp, },\nend\n\nlemma derived_series_map_le (k : ℕ) :\n  (derived_series R L' k).map f ≤ derived_series R L k :=\nbegin\n  induction k with k ih,\n  { simp only [derived_series_def, derived_series_of_ideal_zero, le_top], },\n  { simp only [derived_series_def, derived_series_of_ideal_succ] at ih ⊢,\n    exact le_trans (map_bracket_le f) (lie_submodule.mono_lie _ _ _ _ ih ih), },\nend\n\nlemma derived_series_map_eq (k : ℕ) (h : function.surjective f) :\n  (derived_series R L' k).map f = derived_series R L k :=\nbegin\n  induction k with k ih,\n  { change (⊤ : lie_ideal R L').map f = ⊤,\n    rw ←f.ideal_range_eq_map,\n    exact f.ideal_range_eq_top_of_surjective h, },\n  { simp only [derived_series_def, map_bracket_eq f h, ih, derived_series_of_ideal_succ], },\nend\n\nend lie_ideal\n\nnamespace lie_algebra\n\n/-- A Lie algebra is solvable if its derived series reaches 0 (in a finite number of steps). -/\nclass is_solvable : Prop :=\n(solvable : ∃ k, derived_series R L k = ⊥)\n\ninstance is_solvable_bot : is_solvable R ↥(⊥ : lie_ideal R L) :=\n⟨⟨0, subsingleton.elim _ ⊥⟩⟩\n\ninstance is_solvable_add {I J : lie_ideal R L} [hI : is_solvable R I] [hJ : is_solvable R J] :\n  is_solvable R ↥(I + J) :=\nbegin\n  obtain ⟨k, hk⟩ := id hI, obtain ⟨l, hl⟩ := id hJ,\n  exact ⟨⟨k+l, lie_ideal.derived_series_add_eq_bot hk hl⟩⟩,\nend\n\nend lie_algebra\n\nvariables {R L}\n\nnamespace function\n\nopen lie_algebra\n\nlemma injective.lie_algebra_is_solvable [h₁ : is_solvable R L] (h₂ : injective f) :\n  is_solvable R L' :=\nbegin\n  obtain ⟨k, hk⟩ := id h₁,\n  use k,\n  apply lie_ideal.bot_of_map_eq_bot h₂, rw [eq_bot_iff, ← hk],\n  apply lie_ideal.derived_series_map_le,\nend\n\nlemma surjective.lie_algebra_is_solvable [h₁ : is_solvable R L'] (h₂ : surjective f) :\n  is_solvable R L :=\nbegin\n  obtain ⟨k, hk⟩ := id h₁,\n  use k,\n  rw [← lie_ideal.derived_series_map_eq k h₂, hk],\n  simp only [lie_ideal.map_eq_bot_iff, bot_le],\nend\n\nend function\n\nlemma lie_hom.is_solvable_range (f : L' →ₗ⁅R⁆ L) [h : lie_algebra.is_solvable R L'] :\n  lie_algebra.is_solvable R f.range :=\nf.surjective_range_restrict.lie_algebra_is_solvable\n\nnamespace lie_algebra\n\nlemma solvable_iff_equiv_solvable (e : L' ≃ₗ⁅R⁆ L) : is_solvable R L' ↔ is_solvable R L :=\nbegin\n  split; introsI h,\n  { exact e.symm.injective.lie_algebra_is_solvable, },\n  { exact e.injective.lie_algebra_is_solvable, },\nend\n\nlemma le_solvable_ideal_solvable {I J : lie_ideal R L} (h₁ : I ≤ J) (h₂ : is_solvable R J) :\n  is_solvable R I :=\n(lie_ideal.hom_of_le_injective h₁).lie_algebra_is_solvable\n\nvariables (R L)\n\n@[priority 100]\ninstance of_abelian_is_solvable [is_lie_abelian L] : is_solvable R L :=\nbegin\n  use 1,\n  rw [← abelian_iff_derived_one_eq_bot, lie_abelian_iff_equiv_lie_abelian lie_ideal.top_equiv],\n  apply_instance,\nend\n\n/-- The (solvable) radical of Lie algebra is the `Sup` of all solvable ideals. -/\ndef radical := Sup { I : lie_ideal R L | is_solvable R I }\n\n/-- The radical of a Noetherian Lie algebra is solvable. -/\ninstance radical_is_solvable [is_noetherian R L] : is_solvable R (radical R L) :=\nbegin\n  have hwf := lie_submodule.well_founded_of_noetherian R L L,\n  rw ← complete_lattice.is_sup_closed_compact_iff_well_founded at hwf,\n  refine hwf { I : lie_ideal R L | is_solvable R I } ⟨⊥, _⟩ (λ I hI J hJ, _),\n  { exact lie_algebra.is_solvable_bot R L, },\n  { apply lie_algebra.is_solvable_add R L, exacts [hI, hJ] },\nend\n\n/-- The `→` direction of this lemma is actually true without the `is_noetherian` assumption. -/\nlemma lie_ideal.solvable_iff_le_radical [is_noetherian R L] (I : lie_ideal R L) :\n  is_solvable R I ↔ I ≤ radical R L :=\n⟨λ h, le_Sup h, λ h, le_solvable_ideal_solvable h infer_instance⟩\n\nlemma center_le_radical : center R L ≤ radical R L :=\nhave h : is_solvable R (center R L), { apply_instance, }, le_Sup h\n\n/-- Given a solvable Lie ideal `I` with derived series `I = D₀ ≥ D₁ ≥ ⋯ ≥ Dₖ = ⊥`, this is the\nnatural number `k` (the number of inclusions).\n\nFor a non-solvable ideal, the value is 0. -/\nnoncomputable def derived_length_of_ideal (I : lie_ideal R L) : ℕ :=\nInf {k | derived_series_of_ideal R L k I = ⊥}\n\n/-- The derived length of a Lie algebra is the derived length of its 'top' Lie ideal.\n\nSee also `lie_algebra.derived_length_eq_derived_length_of_ideal`. -/\nnoncomputable abbreviation derived_length : ℕ := derived_length_of_ideal R L ⊤\n\nlemma derived_series_of_derived_length_succ (I : lie_ideal R L) (k : ℕ) :\n  derived_length_of_ideal R L I = k + 1 ↔\n  is_lie_abelian (derived_series_of_ideal R L k I) ∧ derived_series_of_ideal R L k I ≠ ⊥ :=\nbegin\n  rw abelian_iff_derived_succ_eq_bot,\n  let s := {k | derived_series_of_ideal R L k I = ⊥}, change Inf s = k + 1 ↔ k + 1 ∈ s ∧ k ∉ s,\n  have hs : ∀ (k₁ k₂ : ℕ), k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s,\n  { intros k₁ k₂ h₁₂ h₁,\n    suffices : derived_series_of_ideal R L k₂ I ≤ ⊥, { exact eq_bot_iff.mpr this, },\n    change derived_series_of_ideal R L k₁ I = ⊥ at h₁, rw ← h₁,\n    exact derived_series_of_ideal_antitone I h₁₂, },\n  exact nat.Inf_upward_closed_eq_succ_iff hs k,\nend\n\nlemma derived_length_eq_derived_length_of_ideal (I : lie_ideal R L) :\n  derived_length R I = derived_length_of_ideal R L I :=\nbegin\n  let s₁ := {k | derived_series R I k = ⊥},\n  let s₂ := {k | derived_series_of_ideal R L k I = ⊥},\n  change Inf s₁ = Inf s₂,\n  congr, ext k, exact I.derived_series_eq_bot_iff k,\nend\n\nvariables {R L}\n\n/-- Given a solvable Lie ideal `I` with derived series `I = D₀ ≥ D₁ ≥ ⋯ ≥ Dₖ = ⊥`, this is the\n`k-1`th term in the derived series (and is therefore an Abelian ideal contained in `I`).\n\nFor a non-solvable ideal, this is the zero ideal, `⊥`. -/\nnoncomputable def derived_abelian_of_ideal (I : lie_ideal R L) : lie_ideal R L :=\nmatch derived_length_of_ideal R L I with\n| 0     := ⊥\n| k + 1 := derived_series_of_ideal R L k I\nend\n\nlemma abelian_derived_abelian_of_ideal (I : lie_ideal R L) :\n  is_lie_abelian (derived_abelian_of_ideal I) :=\nbegin\n  dunfold derived_abelian_of_ideal,\n  cases h : derived_length_of_ideal R L I with k,\n  { exact is_lie_abelian_bot R L, },\n  { rw derived_series_of_derived_length_succ at h, exact h.1, },\nend\n\nlemma derived_length_zero (I : lie_ideal R L) [hI : is_solvable R I] :\n  derived_length_of_ideal R L I = 0 ↔ I = ⊥ :=\nbegin\n  let s := {k | derived_series_of_ideal R L k I = ⊥}, change Inf s = 0 ↔ _,\n  have hne : s ≠ ∅,\n  { obtain ⟨k, hk⟩ := id hI,\n    refine set.nonempty.ne_empty ⟨k, _⟩,\n    rw [derived_series_def, lie_ideal.derived_series_eq_bot_iff] at hk, exact hk, },\n  simp [hne],\nend\n\nlemma abelian_of_solvable_ideal_eq_bot_iff (I : lie_ideal R L) [h : is_solvable R I] :\n  derived_abelian_of_ideal I = ⊥ ↔ I = ⊥ :=\nbegin\n  dunfold derived_abelian_of_ideal,\n  cases h : derived_length_of_ideal R L I with k,\n  { rw derived_length_zero at h, rw h, refl, },\n  { obtain ⟨h₁, h₂⟩ := (derived_series_of_derived_length_succ R L I k).mp h,\n    have h₃ : I ≠ ⊥, { intros contra, apply h₂, rw contra, apply derived_series_of_bot_eq_bot, },\n    change derived_series_of_ideal R L k I = ⊥ ↔ I = ⊥,\n    split; contradiction, },\nend\n\nend lie_algebra\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/lie/solvable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.4529757637970143}}
{"text": "/-\nCopyright (c) 2020 Eric Wieser. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Eric Wieser\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.group_theory.group_action.basic\nimport Mathlib.algebra.group_action_hom\nimport Mathlib.algebra.module.basic\nimport Mathlib.PostPort\n\nuniverses u v l \n\nnamespace Mathlib\n\n/-!\n\n# Sets invariant to a `mul_action`\n\nIn this file we define `sub_mul_action R M`; a subset of a `mul_action M` which is closed with\nrespect to scalar multiplication.\n\nFor most uses, typically `submodule R M` is more powerful.\n\n## Tags\n\nsubmodule, mul_action\n-/\n\n/-- A sub_mul_action is a set which is closed under scalar multiplication.  -/\nstructure sub_mul_action (R : Type u) (M : Type v) [has_scalar R M] \nwhere\n  carrier : set M\n  smul_mem' : ∀ (c : R) {x : M}, x ∈ carrier → c • x ∈ carrier\n\nnamespace sub_mul_action\n\n\nprotected instance set.has_coe_t {R : Type u} {M : Type v} [has_scalar R M] : has_coe_t (sub_mul_action R M) (set M) :=\n  has_coe_t.mk fun (s : sub_mul_action R M) => carrier s\n\nprotected instance has_mem {R : Type u} {M : Type v} [has_scalar R M] : has_mem M (sub_mul_action R M) :=\n  has_mem.mk fun (x : M) (p : sub_mul_action R M) => x ∈ ↑p\n\nprotected instance has_coe_to_sort {R : Type u} {M : Type v} [has_scalar R M] : has_coe_to_sort (sub_mul_action R M) :=\n  has_coe_to_sort.mk (Type (max 0 v)) fun (p : sub_mul_action R M) => Subtype fun (x : M) => x ∈ p\n\nprotected instance has_top {R : Type u} {M : Type v} [has_scalar R M] : has_top (sub_mul_action R M) :=\n  has_top.mk (mk set.univ sorry)\n\nprotected instance has_bot {R : Type u} {M : Type v} [has_scalar R M] : has_bot (sub_mul_action R M) :=\n  has_bot.mk (mk ∅ sorry)\n\nprotected instance inhabited {R : Type u} {M : Type v} [has_scalar R M] : Inhabited (sub_mul_action R M) :=\n  { default := ⊥ }\n\n@[simp] theorem coe_sort_coe {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) : ↥↑p = ↥p :=\n  rfl\n\nprotected theorem exists {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} {q : ↥p → Prop} : (∃ (x : ↥p), q x) ↔ ∃ (x : M), ∃ (H : x ∈ p), q { val := x, property := H } :=\n  set_coe.exists\n\nprotected theorem forall {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} {q : ↥p → Prop} : (∀ (x : ↥p), q x) ↔ ∀ (x : M) (H : x ∈ p), q { val := x, property := H } :=\n  set_coe.forall\n\ntheorem coe_injective {R : Type u} {M : Type v} [has_scalar R M] : function.injective coe := sorry\n\n@[simp] theorem coe_set_eq {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} {q : sub_mul_action R M} : ↑p = ↑q ↔ p = q :=\n  function.injective.eq_iff coe_injective\n\ntheorem ext'_iff {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} {q : sub_mul_action R M} : p = q ↔ ↑p = ↑q :=\n  iff.symm coe_set_eq\n\ntheorem ext {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} {q : sub_mul_action R M} (h : ∀ (x : M), x ∈ p ↔ x ∈ q) : p = q :=\n  coe_injective (set.ext h)\n\nend sub_mul_action\n\n\nnamespace sub_mul_action\n\n\n@[simp] theorem mem_coe {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) {x : M} : x ∈ ↑p ↔ x ∈ p :=\n  iff.rfl\n\ntheorem smul_mem {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) {x : M} (r : R) (h : x ∈ p) : r • x ∈ p :=\n  smul_mem' p r h\n\nprotected instance has_scalar {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) : has_scalar R ↥p :=\n  has_scalar.mk fun (c : R) (x : ↥p) => { val := c • subtype.val x, property := sorry }\n\n@[simp] theorem coe_eq_coe {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} {x : ↥p} {y : ↥p} : ↑x = ↑y ↔ x = y :=\n  iff.symm subtype.ext_iff_val\n\n@[simp] theorem coe_smul {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} (r : R) (x : ↥p) : ↑(r • x) = r • ↑x :=\n  rfl\n\n@[simp] theorem coe_mk {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} (x : M) (hx : x ∈ p) : ↑{ val := x, property := hx } = x :=\n  rfl\n\n@[simp] theorem coe_mem {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} (x : ↥p) : ↑x ∈ p :=\n  subtype.property x\n\n@[simp] protected theorem eta {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} (x : ↥p) (hx : ↑x ∈ p) : { val := ↑x, property := hx } = x :=\n  subtype.eta x hx\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) : mul_action_hom R (↥p) M :=\n  mul_action_hom.mk coe sorry\n\n@[simp] theorem subtype_apply {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) (x : ↥p) : coe_fn (sub_mul_action.subtype p) x = ↑x :=\n  rfl\n\ntheorem subtype_eq_val {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) : ⇑(sub_mul_action.subtype p) = subtype.val :=\n  rfl\n\n@[simp] theorem smul_mem_iff' {R : Type u} {M : Type v} [monoid R] [mul_action R M] (p : sub_mul_action R M) {x : M} (u : units R) : ↑u • x ∈ p ↔ x ∈ p := sorry\n\n/-- If the scalar product forms a `mul_action`, then the subset inherits this action -/\nprotected instance mul_action {R : Type u} {M : Type v} [monoid R] [mul_action R M] (p : sub_mul_action R M) : mul_action R ↥p :=\n  mul_action.mk sorry sorry\n\ntheorem zero_mem {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] (p : sub_mul_action R M) (h : set.nonempty ↑p) : 0 ∈ p := sorry\n\n/-- If the scalar product forms a `semimodule`, and the `sub_mul_action` is not `⊥`, then the\nsubset inherits the zero. -/\nprotected instance has_zero {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M] (p : sub_mul_action R M) [n_empty : Nonempty ↥p] : HasZero ↥p :=\n  { zero := { val := 0, property := sorry } }\n\ntheorem neg_mem {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M] (p : sub_mul_action R M) {x : M} (hx : x ∈ p) : -x ∈ p :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (-x ∈ p)) (Eq.symm (neg_one_smul R x)))) (smul_mem p (-1) hx)\n\n@[simp] theorem neg_mem_iff {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M] (p : sub_mul_action R M) {x : M} : -x ∈ p ↔ x ∈ p :=\n  { mp := fun (h : -x ∈ p) => eq.mpr (id (Eq._oldrec (Eq.refl (x ∈ p)) (Eq.symm (neg_neg x)))) (neg_mem p h),\n    mpr := neg_mem p }\n\nprotected instance has_neg {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M] (p : sub_mul_action R M) : Neg ↥p :=\n  { neg := fun (x : ↥p) => { val := -subtype.val x, property := sorry } }\n\n@[simp] theorem coe_neg {R : Type u} {M : Type v} [ring R] [add_comm_group M] [semimodule R M] (p : sub_mul_action R M) (x : ↥p) : ↑(-x) = -↑x :=\n  rfl\n\nend sub_mul_action\n\n\nnamespace sub_mul_action\n\n\ntheorem smul_mem_iff {R : Type u} {M : Type v} [division_ring R] [add_comm_group M] [module R M] (p : sub_mul_action R M) {r : R} {x : M} (r0 : r ≠ 0) : r • x ∈ p ↔ x ∈ p :=\n  smul_mem_iff' p (units.mk0 r r0)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/group_theory/group_action/sub_mul_action.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982043529716, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.45297576240772447}}
{"text": "import condensed.extr.basic\nimport topology.category.CompHaus.projective\n\nnoncomputable theory\n\nopen category_theory\n\nnamespace ExtrDisc\n\nlemma lift_exists' {X Y : CompHaus} {P : ExtrDisc} (f : X ⟶ Y)\n  (hf : function.surjective f) (e : P.val.to_CompHaus ⟶ Y) :\n  ∃ g : P.val.to_CompHaus ⟶ X, g ≫ f = e :=\nbegin\n  have : epi f := by rwa CompHaus.epi_iff_surjective f,\n  let B : Profinite := Profinite.of (ultrafilter P.val),\n  let π : B ⟶ P.val := ⟨_, continuous_ultrafilter_extend id⟩,\n  have : epi π,\n  { rw Profinite.epi_iff_surjective,\n    intro x, refine ⟨(pure x : ultrafilter P.val), _⟩,\n    have := @ultrafilter_extend_extends P.val _ _ _ id,\n    exact congr_fun this x, },\n  resetI,\n  choose s hs using projective.factors (𝟙 _) π,\n  let φ : CompHaus.of (ultrafilter P.val.to_CompHaus) ⟶ Y := π ≫ e,\n  choose g h using projective.factors φ f,\n  refine ⟨s ≫ g, _⟩,\n  erw [category.assoc, h, ← category.assoc, hs, category.id_comp],\nend\n\ndef lift' {X Y : CompHaus} {P : ExtrDisc} (f : X ⟶ Y)\n  (hf : function.surjective f) (e : P.val.to_CompHaus ⟶ Y) : P.val.to_CompHaus ⟶ X :=\n(lift_exists' f hf e).some\n\n@[simp, reassoc]\nlemma lift_lifts' {X Y : CompHaus} {P : ExtrDisc} (f : X ⟶ Y)\n  (hf : function.surjective f) (e : P.val.to_CompHaus ⟶ Y) :\n  lift' f hf e ≫ f = e :=\n(lift_exists' f hf e).some_spec\n\nend ExtrDisc\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/extr/lift_comphaus.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45290299853300636}}
{"text": "import Smt\n\ntheorem resolution (p q r : Bool) : p || q → !p || r → q || r := by\n  smt\n  intro hpq\n  intro hnpr\n  cases p <;> cases r <;> simp_all\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Test/Bool/Resolution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.45258750103530154}}
{"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nTransitive reflexive as well as reflexive closure of relations.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.basic\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 \n\nnamespace Mathlib\n\nnamespace relation\n\n\n/--\nThe composition of two relations, yielding a new relation.  The result\nrelates a term of `α` and a term of `γ` if there is an intermediate\nterm of `β` related to both.\n-/\ndef comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} (r : α → β → Prop) (p : β → γ → Prop) (a : α)\n    (c : γ) :=\n  ∃ (b : β), r a b ∧ p b c\n\ntheorem comp_eq {α : Type u_1} {β : Type u_2} {r : α → β → Prop} : comp r Eq = r := sorry\n\ntheorem eq_comp {α : Type u_1} {β : Type u_2} {r : α → β → Prop} : comp Eq r = r := sorry\n\ntheorem iff_comp {α : Type u_1} {r : Prop → α → Prop} : comp Iff r = r := sorry\n\ntheorem comp_iff {α : Type u_1} {r : α → Prop → Prop} : comp r Iff = r := sorry\n\ntheorem comp_assoc {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {r : α → β → Prop}\n    {p : β → γ → Prop} {q : γ → δ → Prop} : comp (comp r p) q = comp r (comp p q) :=\n  sorry\n\ntheorem flip_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} {r : α → β → Prop}\n    {p : β → γ → Prop} : flip (comp r p) = comp (flip p) (flip r) :=\n  sorry\n\n/--\nThe map of a relation `r` through a pair of functions pushes the\nrelation to the codomains of the functions.  The resulting relation is\ndefined by having pairs of terms related if they have preimages\nrelated by `r`.\n-/\nprotected def map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (r : α → β → Prop)\n    (f : α → γ) (g : β → δ) : γ → δ → Prop :=\n  fun (c : γ) (d : δ) => ∃ (a : α), ∃ (b : β), r a b ∧ f a = c ∧ g b = d\n\n/-- `refl_trans_gen r`: reflexive transitive closure of `r` -/\ninductive refl_trans_gen {α : Type u_1} (r : α → α → Prop) (a : α) : α → Prop where\n| refl : refl_trans_gen r a a\n| tail : ∀ {b c : α}, refl_trans_gen r a b → r b c → refl_trans_gen r a c\n\n/-- `refl_gen r`: reflexive closure of `r` -/\ninductive refl_gen {α : Type u_1} (r : α → α → Prop) (a : α) : α → Prop where\n| refl : refl_gen r a a\n| single : ∀ {b : α}, r a b → refl_gen r a b\n\n/-- `trans_gen r`: transitive closure of `r` -/\ninductive trans_gen {α : Type u_1} (r : α → α → Prop) (a : α) : α → Prop where\n| single : ∀ {b : α}, r a b → trans_gen r a b\n| tail : ∀ {b c : α}, trans_gen r a b → r b c → trans_gen r a c\n\ntheorem refl_gen.to_refl_trans_gen {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :\n    refl_gen r a b → refl_trans_gen r a b :=\n  sorry\n\nnamespace refl_trans_gen\n\n\ntheorem trans {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : refl_trans_gen r a b)\n    (hbc : refl_trans_gen r b c) : refl_trans_gen r a c :=\n  sorry\n\ntheorem single {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (hab : r a b) :\n    refl_trans_gen r a b :=\n  tail refl hab\n\ntheorem head {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : r a b)\n    (hbc : refl_trans_gen r b c) : refl_trans_gen r a c :=\n  sorry\n\ntheorem symmetric {α : Type u_1} {r : α → α → Prop} (h : symmetric r) :\n    symmetric (refl_trans_gen r) :=\n  sorry\n\ntheorem cases_tail {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :\n    refl_trans_gen r a b → b = a ∨ ∃ (c : α), refl_trans_gen r a c ∧ r c b :=\n  iff.mp (cases_tail_iff r a b)\n\ntheorem head_induction_on {α : Type u_1} {r : α → α → Prop} {b : α}\n    {P : (a : α) → refl_trans_gen r a b → Prop} {a : α} (h : refl_trans_gen r a b) (refl : P b refl)\n    (head : ∀ {a c : α} (h' : r a c) (h : refl_trans_gen r c b), P c h → P a (head h' h)) : P a h :=\n  sorry\n\ntheorem trans_induction_on {α : Type u_1} {r : α → α → Prop}\n    {P : {a b : α} → refl_trans_gen r a b → Prop} {a : α} {b : α} (h : refl_trans_gen r a b)\n    (ih₁ : α → P refl) (ih₂ : ∀ {a b : α} (h : r a b), P (single h))\n    (ih₃ :\n      ∀ {a b c : α} (h₁ : refl_trans_gen r a b) (h₂ : refl_trans_gen r b c),\n        P h₁ → P h₂ → P (trans h₁ h₂)) :\n    P h :=\n  sorry\n\ntheorem cases_head {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : refl_trans_gen r a b) :\n    a = b ∨ ∃ (c : α), r a c ∧ refl_trans_gen r c b :=\n  sorry\n\ntheorem cases_head_iff {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :\n    refl_trans_gen r a b ↔ a = b ∨ ∃ (c : α), r a c ∧ refl_trans_gen r c b :=\n  sorry\n\ntheorem total_of_right_unique {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α}\n    (U : relator.right_unique r) (ab : refl_trans_gen r a b) (ac : refl_trans_gen r a c) :\n    refl_trans_gen r b c ∨ refl_trans_gen r c b :=\n  sorry\n\nend refl_trans_gen\n\n\nnamespace trans_gen\n\n\ntheorem to_refl {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : trans_gen r a b) :\n    refl_trans_gen r a b :=\n  trans_gen.drec (fun {b : α} (h : r a b) => refl_trans_gen.single h)\n    (fun {b c : α} (h_ᾰ : trans_gen r a b) (bc : r b c) (ab : refl_trans_gen r a b) =>\n      refl_trans_gen.tail ab bc)\n    h\n\ntheorem trans_left {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : trans_gen r a b)\n    (hbc : refl_trans_gen r b c) : trans_gen r a c :=\n  sorry\n\ntheorem trans {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : trans_gen r a b)\n    (hbc : trans_gen r b c) : trans_gen r a c :=\n  trans_left hab (to_refl hbc)\n\ntheorem head' {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : r a b)\n    (hbc : refl_trans_gen r b c) : trans_gen r a c :=\n  trans_left (single hab) hbc\n\ntheorem tail' {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : refl_trans_gen r a b)\n    (hbc : r b c) : trans_gen r a c :=\n  sorry\n\ntheorem trans_right {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α}\n    (hab : refl_trans_gen r a b) (hbc : trans_gen r b c) : trans_gen r a c :=\n  sorry\n\ntheorem head {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α} (hab : r a b)\n    (hbc : trans_gen r b c) : trans_gen r a c :=\n  head' hab (to_refl hbc)\n\ntheorem tail'_iff {α : Type u_1} {r : α → α → Prop} {a : α} {c : α} :\n    trans_gen r a c ↔ ∃ (b : α), refl_trans_gen r a b ∧ r b c :=\n  sorry\n\ntheorem head'_iff {α : Type u_1} {r : α → α → Prop} {a : α} {c : α} :\n    trans_gen r a c ↔ ∃ (b : α), r a b ∧ refl_trans_gen r b c :=\n  sorry\n\ntheorem trans_gen_eq_self {α : Type u_1} {r : α → α → Prop} (trans : transitive r) :\n    trans_gen r = r :=\n  sorry\n\ntheorem transitive_trans_gen {α : Type u_1} {r : α → α → Prop} : transitive (trans_gen r) :=\n  fun (a b c : α) => trans\n\ntheorem trans_gen_idem {α : Type u_1} {r : α → α → Prop} : trans_gen (trans_gen r) = trans_gen r :=\n  trans_gen_eq_self transitive_trans_gen\n\ntheorem trans_gen_lift {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop} {a : α}\n    {b : α} (f : α → β) (h : ∀ (a b : α), r a b → p (f a) (f b)) (hab : trans_gen r a b) :\n    trans_gen p (f a) (f b) :=\n  sorry\n\ntheorem trans_gen_lift' {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop} {a : α}\n    {b : α} (f : α → β) (h : ∀ (a b : α), r a b → trans_gen p (f a) (f b)) (hab : trans_gen r a b) :\n    trans_gen p (f a) (f b) :=\n  eq.mpr (id (Eq.refl (trans_gen p (f a) (f b))))\n    (eq.mp (congr_fun (congr_fun trans_gen_idem (f a)) (f b)) (trans_gen_lift f h hab))\n\ntheorem trans_gen_closed {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {p : α → α → Prop} :\n    (∀ (a b : α), r a b → trans_gen p a b) → trans_gen r a b → trans_gen p a b :=\n  trans_gen_lift' id\n\nend trans_gen\n\n\ntheorem refl_trans_gen_iff_eq {α : Type u_1} {r : α → α → Prop} {a : α} {b : α}\n    (h : ∀ (b : α), ¬r a b) : refl_trans_gen r a b ↔ b = a :=\n  sorry\n\ntheorem refl_trans_gen_iff_eq_or_trans_gen {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} :\n    refl_trans_gen r a b ↔ b = a ∨ trans_gen r a b :=\n  sorry\n\ntheorem refl_trans_gen_lift {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop}\n    {a : α} {b : α} (f : α → β) (h : ∀ (a b : α), r a b → p (f a) (f b))\n    (hab : refl_trans_gen r a b) : refl_trans_gen p (f a) (f b) :=\n  refl_trans_gen.trans_induction_on hab (fun (a : α) => refl_trans_gen.refl)\n    (fun (a b : α) => refl_trans_gen.single ∘ h a b)\n    fun (a b c : α) (_x : refl_trans_gen r a b) (_x : refl_trans_gen r b c) => refl_trans_gen.trans\n\ntheorem refl_trans_gen_mono {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {p : α → α → Prop} :\n    (∀ (a b : α), r a b → p a b) → refl_trans_gen r a b → refl_trans_gen p a b :=\n  refl_trans_gen_lift id\n\ntheorem refl_trans_gen_eq_self {α : Type u_1} {r : α → α → Prop} (refl : reflexive r)\n    (trans : transitive r) : refl_trans_gen r = r :=\n  sorry\n\ntheorem reflexive_refl_trans_gen {α : Type u_1} {r : α → α → Prop} : reflexive (refl_trans_gen r) :=\n  fun (a : α) => refl_trans_gen.refl\n\ntheorem transitive_refl_trans_gen {α : Type u_1} {r : α → α → Prop} :\n    transitive (refl_trans_gen r) :=\n  fun (a b c : α) => refl_trans_gen.trans\n\ntheorem refl_trans_gen_idem {α : Type u_1} {r : α → α → Prop} :\n    refl_trans_gen (refl_trans_gen r) = refl_trans_gen r :=\n  refl_trans_gen_eq_self reflexive_refl_trans_gen transitive_refl_trans_gen\n\ntheorem refl_trans_gen_lift' {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {p : β → β → Prop}\n    {a : α} {b : α} (f : α → β) (h : ∀ (a b : α), r a b → refl_trans_gen p (f a) (f b))\n    (hab : refl_trans_gen r a b) : refl_trans_gen p (f a) (f b) :=\n  eq.mpr (id (Eq.refl (refl_trans_gen p (f a) (f b))))\n    (eq.mp (congr_fun (congr_fun refl_trans_gen_idem (f a)) (f b)) (refl_trans_gen_lift f h hab))\n\ntheorem refl_trans_gen_closed {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {p : α → α → Prop} :\n    (∀ (a b : α), r a b → refl_trans_gen p a b) → refl_trans_gen r a b → refl_trans_gen p a b :=\n  refl_trans_gen_lift' id\n\n/--\nThe join of a relation on a single type is a new relation for which\npairs of terms are related if there is a third term they are both\nrelated to.  For example, if `r` is a relation representing rewrites\nin a term rewriting system, then *confluence* is the property that if\n`a` rewrites to both `b` and `c`, then `join r` relates `b` and `c`\n(see `relation.church_rosser`).\n-/\ndef join {α : Type u_1} (r : α → α → Prop) : α → α → Prop :=\n  fun (a b : α) => ∃ (c : α), r a c ∧ r b c\n\ntheorem church_rosser {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {c : α}\n    (h : ∀ (a b c : α), r a b → r a c → ∃ (d : α), refl_gen r b d ∧ refl_trans_gen r c d)\n    (hab : refl_trans_gen r a b) (hac : refl_trans_gen r a c) : join (refl_trans_gen r) b c :=\n  sorry\n\ntheorem join_of_single {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} (h : reflexive r)\n    (hab : r a b) : join r a b :=\n  Exists.intro b { left := hab, right := h b }\n\ntheorem symmetric_join {α : Type u_1} {r : α → α → Prop} : symmetric (join r) := sorry\n\ntheorem reflexive_join {α : Type u_1} {r : α → α → Prop} (h : reflexive r) : reflexive (join r) :=\n  fun (a : α) => Exists.intro a { left := h a, right := h a }\n\ntheorem transitive_join {α : Type u_1} {r : α → α → Prop} (ht : transitive r)\n    (h : ∀ (a b c : α), r a b → r a c → join r b c) : transitive (join r) :=\n  sorry\n\ntheorem equivalence_join {α : Type u_1} {r : α → α → Prop} (hr : reflexive r) (ht : transitive r)\n    (h : ∀ (a b c : α), r a b → r a c → join r b c) : equivalence (join r) :=\n  { left := reflexive_join hr, right := { left := symmetric_join, right := transitive_join ht h } }\n\ntheorem equivalence_join_refl_trans_gen {α : Type u_1} {r : α → α → Prop}\n    (h : ∀ (a b c : α), r a b → r a c → ∃ (d : α), refl_gen r b d ∧ refl_trans_gen r c d) :\n    equivalence (join (refl_trans_gen r)) :=\n  equivalence_join reflexive_refl_trans_gen transitive_refl_trans_gen\n    fun (a b c : α) => church_rosser h\n\ntheorem join_of_equivalence {α : Type u_1} {r : α → α → Prop} {a : α} {b : α} {r' : α → α → Prop}\n    (hr : equivalence r) (h : ∀ (a b : α), r' a b → r a b) : join r' a b → r a b :=\n  sorry\n\ntheorem refl_trans_gen_of_transitive_reflexive {α : Type u_1} {r : α → α → Prop} {a : α} {b : α}\n    {r' : α → α → Prop} (hr : reflexive r) (ht : transitive r) (h : ∀ (a b : α), r' a b → r a b)\n    (h' : refl_trans_gen r' a b) : r a b :=\n  refl_trans_gen.drec (hr a)\n    (fun {b c : α} (hab : refl_trans_gen r' a b) (hbc : r' b c) (ih : r a b) => ht ih (h b c hbc))\n    h'\n\ntheorem refl_trans_gen_of_equivalence {α : Type u_1} {r : α → α → Prop} {a : α} {b : α}\n    {r' : α → α → Prop} (hr : equivalence r) :\n    (∀ (a b : α), r' a b → r a b) → refl_trans_gen r' a b → r a b :=\n  refl_trans_gen_of_transitive_reflexive (and.left hr) (and.right (and.right hr))\n\ntheorem eqv_gen_iff_of_equivalence {α : Type u_1} {r : α → α → Prop} {a : α} {b : α}\n    (h : equivalence r) : eqv_gen r a b ↔ r a b :=\n  sorry\n\ntheorem eqv_gen_mono {α : Type u_1} {a : α} {b : α} {r : α → α → Prop} {p : α → α → Prop}\n    (hrp : ∀ (a b : α), r a b → p a b) (h : eqv_gen r a b) : eqv_gen p a b :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/logic/relation_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6442251064863695, "lm_q1q2_score": 0.4525875010353015}}
{"text": "import AssertCmd\nimport Contractome.Utils\n\n-- @[irreducible] def UInt256.size : Nat := 115792089237316195423570985008687907853269984665640564039457584007913129639936\n@[irreducible] def UInt256.size : Nat := 2^256\n-- attribute [irreducible] UInt32.size\n\nstructure UInt256 where\n  val : Fin UInt256.size\n\ndef UInt256.ofNatCore (n : @& Nat) (h : LT.lt n UInt256.size) : UInt256 := {\n  val := { val := n, isLt := h }\n}\n\ndef UInt256.toNat (n : UInt256) : Nat := n.val.val\n\ninstance : Repr UInt256 where\n  reprPrec n _ := repr n.toNat\n\ndef UInt256.decEq (a b : UInt256) : Decidable (Eq a b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ =>\n    dite (Eq n m) (fun h => isTrue (h ▸ rfl)) (fun h => isFalse (fun h' => UInt256.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt256 := UInt256.decEq\n\nset_option maxRecDepth 2000\ninstance : Inhabited UInt256 where\n  default := UInt256.ofNatCore 0 (by decide)\n\n\ninstance : LT UInt256 where\n  lt a b := LT.lt a.val b.val\n\ninstance : LE UInt256 where\n  le a b := LE.le a.val b.val\n\ndef UInt256.decLt (a b : UInt256) : Decidable (LT.lt a b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (LT.lt n m))\n\ndef UInt256.decLe (a b : UInt256) : Decidable (LE.le a b) :=\n  match a, b with\n  | ⟨n⟩, ⟨m⟩ => inferInstanceAs (Decidable (LE.le n m))\n\ninstance (a b : UInt256) : Decidable (LT.lt a b) := UInt256.decLt a b\ninstance (a b : UInt256) : Decidable (LE.le a b) := UInt256.decLe a b\n\ninstance : Ord UInt256 where\n  compare x y := compareOfLessAndEq x y\n\n#check UInt32.ofNat\n\n@[irreducible] theorem ofNat_lt (x: Nat) : x % UInt256.size < UInt256.size := by\n  simp [Nat.mod_lt, Nat.zero_lt_succ]\n\n-- attribute [irreducible] Fin.mlt\n\n-- def UInt256.ofNat (n : @& Nat) : UInt256 := ⟨Fin.ofNat n⟩\ndef UInt256.ofNat (n : @& Nat) : UInt256 := ⟨⟨n % UInt256.size , ofNat_lt n⟩⟩\ndef UInt256.ofNat' (n : Nat) (h : n < UInt256.size) : UInt256 := ⟨⟨n, h⟩⟩\ndef UInt256.ofUInt8 (n : UInt8) : UInt256 := ⟨⟨ n.val, by apply (Nat.lt_trans n.val.isLt); decide ⟩⟩\nabbrev Nat.toUInt256 := UInt256.ofNat\n\n@[inline] abbrev wrapOp (f : Nat -> Nat -> Nat) :=\n  fun (a b : UInt256)  => UInt256.mk ⟨ (f a.val.val b.val.val) % UInt256.size, ofNat_lt (f a.val.val b.val.val) ⟩\n\ndef UInt256.add := wrapOp Nat.add\ndef UInt256.sub (a b : UInt256) : UInt256 := ⟨⟨ (a.val.val + (UInt256.size - b.val.val)) % UInt256.size , ofNat_lt _⟩⟩\ndef UInt256.mul := wrapOp Nat.mul\ndef UInt256.div := wrapOp Nat.div\ndef UInt256.mod := wrapOp Nat.mod\n\nset_option maxRecDepth 2000\ndef UInt256.ones : UInt256 := ⟨⟨ (2^256) - 1, by decide ⟩⟩ \ndef UInt256.modn (a : UInt256) (n : @& Nat) : UInt256 := ⟨⟨ (a.val.val % n) % UInt256.size, ofNat_lt _ ⟩⟩\ndef UInt256.land := wrapOp Nat.land\ndef UInt256.lor := wrapOp Nat.lor\ndef UInt256.xor := wrapOp Nat.xor\ndef UInt256.shiftLeft (a b : UInt256) : UInt256 := ⟨⟨ (a.val.val <<< (modn b 256).val.val) % UInt256.size, ofNat_lt _ ⟩⟩\ndef UInt256.shiftRight (a b : UInt256) : UInt256 := ⟨⟨ (a.val.val >>> (modn b 256).val.val) % UInt256.size, ofNat_lt _ ⟩⟩\ndef UInt256.toUInt8 (a : UInt256) : UInt8 := a.toNat.toUInt8\ndef UInt256.toUInt16 (a : UInt256) : UInt16 := a.toNat.toUInt16\ndef UInt8.toUInt256 (a : UInt8) : UInt256 := a.toNat.toUInt256\ndef UInt16.toUInt256 (a : UInt16) : UInt256 := a.toNat.toUInt256\ndef UInt32.toUInt256 (a : UInt32) : UInt256 := a.toNat.toUInt256\ndef UInt64.toUInt256 (a : UInt64) : UInt256 := a.toNat.toUInt256\n\ninstance : OfNat UInt256 n   := ⟨UInt256.ofNat n⟩\ninstance : Add UInt256       := ⟨UInt256.add⟩\ninstance : Sub UInt256       := ⟨UInt256.sub⟩\ninstance : Mul UInt256       := ⟨UInt256.mul⟩\ninstance : Mod UInt256       := ⟨UInt256.mod⟩\ninstance : HMod UInt256 Nat UInt256 := ⟨UInt256.modn⟩\ninstance : Div UInt256       := ⟨UInt256.div⟩\n\n\n-- def UInt256.bneg (a : UInt256) : UInt256 := a.xor UInt256.ones\ndef UInt256.complement (a:UInt256) : UInt256 := 0-(a+1)\ndef UInt256.sneg (a: UInt256) : UInt256 := a.complement + 1\n#assert (UInt256.sneg 3) == (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD : UInt256)\n#assert (UInt256.sneg 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD) == (3 : UInt256)\n\n\ninstance : Complement UInt256 := ⟨UInt256.complement⟩\ninstance : AndOp UInt256     := ⟨UInt256.land⟩\ninstance : OrOp UInt256      := ⟨UInt256.lor⟩\ninstance : Xor UInt256       := ⟨UInt256.xor⟩\ninstance : ShiftLeft UInt256  := ⟨UInt256.shiftLeft⟩\ninstance : ShiftRight UInt256 := ⟨UInt256.shiftRight⟩\n\ndef UInt256.abs (a : UInt256) : UInt256 :=\n  if a >>> 255 == 1 then a.sneg else a\n\ndef UInt256.sdiv (a b:UInt256) : UInt256 := \n    let a' := a.abs\n    let b' := b.abs\n    let r := a' / b'\n    let bit : UInt256 := (a ^^^ b) >>> 255\n    if bit == 1 then r.sneg else r\n    \ndef UInt256.smod (a b:UInt256) : UInt256 := \n    let a' := a.abs\n    let b' := b.abs\n    let r := a' % b'\n    let bit : UInt256 := a >>> 255\n    if bit == 1 then r.sneg else r\n\n\n@[simp]\ndef Nat.half_is_less (n : Nat) : (Nat.succ n) / 2 < (Nat.succ n) := sorry\n  -- \n-- set_option pp.all true\ndef Nat.powmod_correct (a b N: Nat) : { r : Nat // r = (a.pow b) % N } := match b with\n  | 0 => by cases N with | zero => exact ⟨ 1, by simp [Nat.pow, Nat.mod_zero] ⟩ \n                         | succ N => cases N with\n                          | zero => exact ⟨ 0, by simp [Nat.pow]⟩ \n                          | succ N => exact ⟨ 1, by simp [Nat.pow]; rw [Nat.mod_eq_of_lt (_ : 1 < Nat.succ (Nat.succ N))]; apply Nat.succ_le_succ; apply Nat.succ_le_succ; apply Nat.zero_le ⟩ \n  | Nat.succ b => \n    if (Nat.succ b) % 2 == 0 then ⟨ powmod_correct ((a * a) % N) ((Nat.succ b) / 2) N , sorry ⟩ \n    else ⟨ (a * powmod_correct ((a * a) % N) ((Nat.succ b) / 2) N) % N , sorry ⟩ \ntermination_by _ => b\ndecreasing_by apply Nat.half_is_less\n\n#assert ((123 ^ 123) % 8) == (Nat.powmod_correct 123 123 8).val\n#assert  (Nat.powmod_correct 2 2 8).val == ((2 ^ 2) % 8)\n\n\ndef Fin.pow {h : n > 0} (a b : Fin n) : Fin n :=\n  let ⟨ val, prop ⟩ := Nat.powmod_correct a b n\n  ⟨ val, by subst prop; exact Nat.mod_lt (Nat.pow a.val b.val) h ⟩ \n\n-- #eval Fin.pow ⟨ Fin.mk 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF UInt256.size\n\n\n-- TODO make faster by modding intermediately\ndef UInt256.pow (a b:UInt256) : UInt256 := ⟨ Fin.pow (h:=by simp) a.val b.val ⟩\n#eval UInt256.pow 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n\n-- def UInt256.sOfInt (a: Int) := if a\ndef UInt256.isSpos (a: UInt256) : Bool := if (a >>> 255) == 1 then false else true\ndef UInt256.slt (a b: UInt256) : Bool :=\n  let aS := a.isSpos\n  let bS := b.isSpos\n  match aS, bS with\n  | true, false => false\n  | false, true => true\n  | _, _ => a < b\n\n#assert (UInt256.slt (UInt256.sneg 1) 5) == true\n#assert (UInt256.slt 4 5) == true\n#assert (UInt256.slt 5 5) == false\n#assert (UInt256.slt 6 5) == false\n#assert (UInt256.slt (UInt256.sneg 1) (UInt256.sneg 1)) == false\n#assert (UInt256.slt 6 (UInt256.sneg 1)) == false\n#assert (UInt256.slt (UInt256.sneg 2) (UInt256.sneg 1)) == true\n#assert (UInt256.slt (UInt256.sneg 1) (UInt256.sneg 2)) == false\n\ndef UInt256.sgt (a b: UInt256) : Bool := if a == b then false else !UInt256.slt a b\n\n\ndef UInt256.ofBytes! (b: ByteArray) : UInt256 := \n  let bs := ByteArray.mkZeros (256 / 8)\n  let destOff := (256 / 8) - b.size \n  let bs : ByteArray := ByteArray.copySlice b 0 bs destOff b.size\n  -- now we can go byte by byte\n  let p1 := (ByteArray.toUInt64LE! $ bs.extract 0 8).toUInt256\n  let p2 := (ByteArray.toUInt64LE! $ bs.extract 8 16).toUInt256\n  let p3 := (ByteArray.toUInt64LE! $ bs.extract 16 24).toUInt256\n  let p4 := (ByteArray.toUInt64LE! $ bs.extract 24 32).toUInt256\n\n  (p1 <<< 192) ||| (p2 <<< 128) ||| (p3 <<< 64) ||| p4\n\n\ndef UInt256.ofBytesL! (l : List UInt8) : UInt256 := \n  let rec aux l (acc: UInt256) := match l with\n  | List.cons b bs => aux bs ((acc <<< 8) ||| (UInt256.ofUInt8 b))\n  | List.nil => acc\n  aux l 0\n\n\n#assert (UInt256.ofBytes! $ ByteArray.mk $ #[01]) == (1:UInt256)\n#assert (UInt256.ofBytes! $ ByteArray.mk $ #[0]) == (0:UInt256)\n#assert (UInt256.ofBytes! $ ByteArray.mk $ #[0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]) == UInt256.ofNat $ UInt256.size - 1\n#assert (UInt256.ofBytes! $ ByteArray.mk $ #[0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]) == UInt256.ofNat $ UInt256.size / 2\n\n#assert (UInt256.ofBytesL! $ [0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]) == UInt256.ofNat $ UInt256.size / 2\n\ndef UInt256.toBytes (b: UInt256) : ByteArray := Id.run do\n  let mut ba := ByteArray.mkEmpty 32\n  for i in [0:32] do\n    ba := ba.push $ UInt256.toUInt8 $ (b <<< (8 * (UInt256.ofNat i))) >>> (8*31)\n  ba\n\n#assert (UInt256.ofBytes! (UInt256.toBytes 5)) == (5:UInt256)\n#assert (UInt256.ofBytes! (UInt256.toBytes (UInt256.ofNat $ UInt256.size - 1))) == (UInt256.ofNat $ UInt256.size - 1)\n\ndef UInt256.toBytesL (b: UInt256) : List UInt8 := Id.run do\n  let mut ba := []\n  for i in [0:32] do\n    ba := List.cons (UInt256.toUInt8 $ (b <<< (8 * (UInt256.ofNat i))) >>> (8*31)) ba\n  ba.reverse\n\n#assert (UInt256.ofBytesL! (UInt256.toBytesL 5)) == (5:UInt256)\n#assert ((UInt256.toBytesL 5).drop 31).head? == (Option.some (5:UInt8))\n#assert (UInt256.ofBytesL! (UInt256.toBytesL (UInt256.ofNat $ UInt256.size - 1))) == (UInt256.ofNat $ UInt256.size - 1)\n\ndef UInt256.signextend (byteNum x : UInt256) :=\n  if byteNum > 31 then x else\n  let bitNum := byteNum*8+7\n  let mask := ((1:UInt256) <<< bitNum) - 1\n  let isBitSet := (x >>> bitNum) &&& 1 == 1\n  if isBitSet then x ||| (~~~ mask) else x &&& mask\n\n#assert (UInt256.signextend 0 0xFF) == (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF : UInt256)\n#assert (UInt256.signextend 0 0x7F) == (0x7F : UInt256)\n\n\ndef UInt256.sar (x shiftBy : UInt256) := \n    if x.isSpos then x >>> shiftBy else\n    let mask := UInt256.ones <<< (256 - shiftBy)\n    (x >>> shiftBy) ||| mask\n\n#assert (UInt256.sar 2 1) == (1 : UInt256)\n#assert (UInt256.sar 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0 4) == \n  (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF : UInt256)\n", "meta": {"author": "zygi", "repo": "contractome", "sha": "d4d59ce817e47578d8764e26d77050ce72c18c18", "save_path": "github-repos/lean/zygi-contractome", "path": "github-repos/lean/zygi-contractome/contractome-d4d59ce817e47578d8764e26d77050ce72c18c18/Contractome/UInt256.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7185943925708562, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4525525114508691}}
{"text": "lemma add_mul (a b t : mynat) : (a + b) * t = a * t + b * t :=\nbegin\ninduction t with k Pk,\nrepeat { rw mul_zero },\nrw add_zero,\nrefl,\n\nrepeat { rw mul_succ },\nrw Pk,\nsimp,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/3-multiplication-world/l7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4525524938736239}}
{"text": "import algebra.category.Module.adjunctions\nimport group_theory.free_abelian_group_finsupp\nimport algebra.category.Group.adjunctions\nimport algebra.category.Group.filtered_colimits\nimport algebra.category.Group.biproducts\nimport algebra.category.Group.abelian\nimport category_theory.limits.preserves.shapes.products\nimport category_theory.limits.preserves.filtered\nimport category_theory.limits.shapes.terminal\nimport linear_algebra.free_module.pid\nimport for_mathlib.AddCommGroup.epi\nimport algebra.group.ulift\n\nopen category_theory\n\nuniverses u\n\nnamespace AddCommGroup\n\nnoncomputable theory\n\n@[simps]\ndef free' : Type u ⥤ AddCommGroup.{u} :=\n{ obj := λ X, AddCommGroup.of $ X →₀ ℤ,\n  map := λ X Y f, finsupp.map_domain.add_monoid_hom f,\n  map_id' := begin\n    intros X, ext, dsimp, simp,\n  end,\n  map_comp' := begin\n    intros X Y Z f g, ext, dsimp, simp,\n  end } .\n\n@[simps]\ndef of_iso {A B : Type u} [add_comm_group A] [add_comm_group B]\n  (e : A ≃+ B) : of A ≅ of B :=\n{ hom := e.to_add_monoid_hom,\n  inv := e.symm.to_add_monoid_hom,\n  hom_inv_id' := begin\n    ext, dsimp, simp,\n  end,\n  inv_hom_id' := begin\n    ext, dsimp, simp,\n  end } .\n\n@[simps]\ndef free_iso_free' : free.{u} ≅ free'.{u} :=\ncategory_theory.nat_iso.of_components\n(λ X, of_iso (free_abelian_group.equiv_finsupp X))\nbegin\n  intros X Y f, ext, dsimp, simp,\nend\n\ndef adj' : free'.{u} ⊣ forget AddCommGroup.{u} :=\nAddCommGroup.adj.of_nat_iso_left $ free_iso_free'.{u}\n\nend AddCommGroup\n\ndef types.pt {α : Type u} (a : α) : ⊤_ _ ⟶ α :=\nλ x, a\n\ndef types.punit_iso : (punit : Type u) ≅ ⊤_ _ :=\n{ hom := limits.terminal.from _,\n  inv := types.pt punit.star }\n\nnamespace AddCommGroup\n\ndef tunit : AddCommGroup.{u} :=\n  AddCommGroup.free'.obj (⊤_ _)\n\ndef tunit.lift {A : AddCommGroup.{u}} (e : ⊤_ _ ⟶ (forget _).obj A) :\n  tunit ⟶ A :=\n(AddCommGroup.adj'.hom_equiv _ _).symm e\n\n-- Do we really not have this?!\ndef _root_.finsupp.punit_add_equiv (M : Type*) [add_monoid M] :\n  ((punit : Type u) →₀ M) ≃+ M :=\n{ to_fun := λ f, f punit.star,\n  inv_fun := λ m, finsupp.single punit.star m,\n  left_inv := λ x, by { ext, dsimp, simp },\n  right_inv := λ x, by { dsimp, simp },\n  map_add' := λ f g, by simp }\n\n-- Do we really not have this?!\ndef add_equiv_of_iso (A B : AddCommGroup.{u}) (e : A ≅ B) :\n  A ≃+ B :=\n{ to_fun := e.hom,\n  inv_fun := e.inv,\n  left_inv := λ x, by simp,\n  right_inv := λ x, by simp,\n  map_add' := λ x y, e.hom.map_add _ _ }\n\ndef tunit_add_equiv : tunit.{u} ≃+ ℤ :=\nadd_equiv.trans (add_equiv_of_iso _ _ $ AddCommGroup.free'.map_iso\n  types.punit_iso.symm) (finsupp.punit_add_equiv ℤ)\n\ndef tunit.gen : tunit.{u} :=\nAddCommGroup.adj'.unit.app _ $\n  (limits.terminal.from (punit : Type u) : punit → ⊤_ (Type u)) punit.star\n\nopen_locale classical\n\n-- Of course this is true without the fintype assumption...\ndef iso_of_basis {ι : Type u} [fintype ι] {A : AddCommGroup.{u}} (𝓑 : basis ι ℤ A) :\n  (∐ (λ i : ι, tunit.{u})) ≅ A :=\nbegin\n  -- This is very messy...\n  let e : (∐ (λ i : ι, tunit.{u})) ≅ (⨁ (λ i, tunit.{u})) :=\n    (limits.colimit.is_colimit _).cocone_point_unique_up_to_iso\n      (limits.biproduct.is_bilimit _).is_colimit,\n  refine e ≪≫ _,\n  refine biproduct_iso_pi _ ≪≫ _,\n  refine AddCommGroup.of_iso _ ≪≫ (AddCommGroup.of_iso 𝓑.repr.to_add_equiv).symm ≪≫\n    ⟨add_monoid_hom.id _, add_monoid_hom.id _, by { ext, refl }, by { ext, refl }⟩,\n  let q : tunit.{u} ≃+ ℤ := tunit_add_equiv,\n  let e : (ι →₀ ℤ) ≃+ (ι → ℤ),\n  { fconstructor,\n    exact finsupp.equiv_fun_on_fintype,\n    exact finsupp.equiv_fun_on_fintype.symm,\n    exact finsupp.equiv_fun_on_fintype.left_inverse_symm,\n    exact finsupp.equiv_fun_on_fintype.right_inverse_symm,\n    intros x y, refl },\n  refine add_equiv.trans _ e.symm,\n  fconstructor,\n  { intros f i, exact q (f i) },\n  { intros f i, exact q.symm (f i) },\n  { intros f, ext, dsimp, simp },\n  { intros f, ext, dsimp, simp },\n  { intros f g, ext i, simp, },\nend\n--as_iso (hom_of_basis 𝓑)\n\n@[derive partial_order]\ndef index_cat (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] : Type u :=\n{ H : add_subgroup A // H.fg } -- Is this the condition we want?\n\ninstance nonempty_index_cat (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  nonempty A.index_cat := ⟨⟨⊥, ∅, by simp⟩⟩\n\ninstance semilattice_sup_index_cat\n  (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  semilattice_sup A.index_cat :=\n{ sup := λ I J, ⟨I.1 ⊔ J.1, begin\n    obtain ⟨S,hS⟩ := I.2,\n    obtain ⟨T,hT⟩ := J.2,\n    rw [← hS, ← hT],\n    use S ∪ T,\n    simp only [finset.coe_union, add_subgroup.closure_union],\n  end⟩,\n  le_sup_left := λ I J, @le_sup_left (add_subgroup A) _ _ _,\n  le_sup_right := λ I J, @le_sup_right (add_subgroup A) _ _ _,\n  sup_le := λ I J K h1 h2, @sup_le (add_subgroup A) _ _ _ _ h1 h2,\n  ..(infer_instance : partial_order _) }\n\ndef diagram (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  A.index_cat ⥤ AddCommGroup.{u} :=\n{ obj := λ I, AddCommGroup.of I.1,\n  map := λ I J h, add_subgroup.inclusion h.le }\n\ndef cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  limits.cocone A.diagram :=\n{ X := A,\n  ι := { app := λ I, I.1.subtype } }\n\ndef is_colimit_cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  limits.is_colimit A.cocone :=\n{ desc := λ S,\n  { to_fun := λ a, S.ι.app ⟨add_subgroup.closure {a}, {a}, by simp⟩\n      ⟨a, add_subgroup.subset_closure rfl⟩,\n    map_zero' := add_monoid_hom.map_zero _,\n    map_add' := λ x y, begin\n      let I : A.index_cat := ⟨add_subgroup.closure {x}, {x}, by simp⟩,\n      let J : A.index_cat := ⟨add_subgroup.closure {y}, {y}, by simp⟩,\n      let K : A.index_cat := ⟨add_subgroup.closure {x + y}, {x + y}, by simp⟩,\n      let IJ : A.index_cat := ⟨add_subgroup.closure {x,y}, {x,y}, by simp⟩,\n      let iI : I ⟶ IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iJ : J ⟶ IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iK : K ⟶ IJ := hom_of_le ((add_subgroup.closure_le _).2 _),\n      swap,\n      { rintro a (rfl : a = _), change x + y ∈ IJ.1, apply IJ.1.add_mem,\n        { apply add_subgroup.subset_closure, simp },\n        { apply add_subgroup.subset_closure, simp } },\n      rw [← S.w iI, ← S.w iJ, ← S.w iK, comp_apply, comp_apply, comp_apply,\n        ← add_monoid_hom.map_add],\n      refl,\n    end },\n  fac' := begin\n    rintros S J, ext ⟨x,hx⟩,\n    let I : A.index_cat := ⟨add_subgroup.closure {x}, {x}, by simp⟩,\n    let e : I ⟶ J := hom_of_le ((add_subgroup.closure_le _).2 _),\n    { rw comp_apply, dsimp [cocone], rw ← S.w e, refl },\n    rintros x (rfl : x = _), exact hx,\n  end,\n  uniq' := begin\n    intros S m hm, ext x, dsimp [cocone] at x ⊢,\n    let I : A.index_cat := ⟨add_subgroup.closure {x}, {x}, by simp⟩,\n    specialize hm I,\n    let y : I.1 := ⟨x, add_subgroup.subset_closure rfl⟩,\n    apply_fun (λ e, e y) at hm, exact hm,\n  end }\n\ndef colimit_comparison (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A] :\n  limits.colimit A.diagram ≅ A :=\n(limits.colimit.is_colimit A.diagram).cocone_point_unique_up_to_iso\n  A.is_colimit_cocone\n\nlemma exists_basis_of_index (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A]\n  (I : A.index_cat) : ∃ (ι : Type u) [fintype ι]\n  (𝓑 : basis ι ℤ (AddCommGroup.of I.1)), true :=\nbegin\n  obtain ⟨S,hS⟩ := I.2,\n  let e : S → I.1 := λ s, ⟨s,_⟩,\n  swap, { rw ← hS, apply add_subgroup.subset_closure, exact s.2 },\n  haveI : no_zero_smul_divisors ℤ I.1,\n  { constructor, rintros c ⟨x, hx⟩ h, apply_fun (λ e, e.val) at h,\n    dsimp at h,\n    cases no_zero_smul_divisors.eq_zero_or_eq_zero_of_smul_eq_zero h,\n    left, assumption,\n    right, ext, assumption },\n  obtain ⟨n,B⟩ := @module.free_of_finite_type_torsion_free S ℤ _ _ _ I.1 _ _ _ e _ _,\n  { use [ulift (fin n), infer_instance],\n    refine ⟨_, trivial⟩,\n    apply B.reindex,\n    exact equiv.ulift.symm },\n  { apply le_antisymm, { intros x hx, trivial },\n    rintros ⟨x,hx⟩ -,\n    let J := (submodule.span ℤ (set.range e)).to_add_subgroup,\n    change _ ∈ J,\n    have hJ : J = (J.map I.1.subtype).comap I.1.subtype, -- is this not a lemma?!\n    { apply le_antisymm,\n      { exact add_subgroup.le_comap_map I.val.subtype J },\n      { intros t ht,\n        simpa using ht } },\n    rw [hJ, add_subgroup.mem_comap], clear hJ,\n    dsimp [J],\n    convert hx,\n    rw [← hS, submodule.span_int_eq_add_subgroup_closure, add_monoid_hom.map_closure], congr' 1,\n    ext t,\n    split,\n    { rintros ⟨t,⟨t,rfl⟩,rfl⟩, exact t.2 },\n    { intros ht, refine ⟨⟨t, _⟩, ⟨⟨t, ht⟩, rfl⟩, rfl⟩ } },\nend\n\nlemma exists_sigma_iso_of_index (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A]\n  (I : A.index_cat) : ∃ (ι : Type u) [fintype ι]\n  (e : (∐ (λ i : ι, tunit.{u})) ≅ AddCommGroup.of I.1), true :=\nbegin\n  obtain ⟨ι,hι,𝓑,-⟩ := exists_basis_of_index A I,\n  resetI,\n  use [ι, hι, iso_of_basis 𝓑],\nend\n\nlemma exists_biprod_iso_of_index (A : AddCommGroup.{u}) [no_zero_smul_divisors ℤ A]\n  (I : A.index_cat) : ∃ (ι : Type u) [fintype ι]\n  (e : by exactI (⨁ (λ i : ι, tunit.{u})) ≅ AddCommGroup.of I.1), true :=\nbegin\n  obtain ⟨ι,hι,e,-⟩ := exists_sigma_iso_of_index A I,\n  resetI, use [ι, hι],\n  use (limits.biproduct.is_bilimit _).is_colimit.cocone_point_unique_up_to_iso\n      (limits.colimit.is_colimit _) ≪≫ e,\nend\n\nuniverses u'\n\n\nlemma is_iso_of_preserves {𝓐 : Type u'} [category.{u} 𝓐] [preadditive 𝓐]\n  (F G : AddCommGroup ⥤ 𝓐)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (η : F ⟶ G)\n  [hη : is_iso (η.app tunit)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors ℤ A] :\n  is_iso (η.app A) :=\nbegin\n  let T := (limits.cocones.precompose (whisker_left A.diagram η)).obj\n    (G.map_cocone A.cocone),\n  let S := F.map_cocone A.cocone,\n  let hS : limits.is_colimit S :=\n    limits.is_colimit_of_preserves F A.is_colimit_cocone,\n  have : η.app A = hS.desc T,\n  { apply hS.hom_ext, intros j, rw hS.fac,\n    dsimp, apply η.naturality },\n  rw this, clear this,\n  suffices : ∀ I : A.index_cat, is_iso (η.app (A.diagram.obj I)),\n  { resetI,\n    haveI : is_iso (whisker_left A.diagram η),\n    { apply_with nat_iso.is_iso_of_is_iso_app { instances := ff },\n      intros I, exact this I },\n    let hT : limits.is_colimit T :=\n      (limits.is_colimit.precompose_hom_equiv (as_iso (whisker_left A.diagram η))\n      (G.map_cocone A.cocone)).symm (limits.is_colimit_of_preserves G A.is_colimit_cocone),\n    use hT.desc S,\n    split,\n    { apply hS.hom_ext,\n      intros j,\n      erw [hS.fac_assoc, hT.fac, category.comp_id] },\n    { apply hT.hom_ext,\n      intros j,\n      erw [hT.fac_assoc, hS.fac, category.comp_id] }\n  }, --^ general colimit nonsense..., but I can't find applicable lemmas :-(\n  intros I,\n  obtain ⟨ι,hι,e,-⟩ := A.exists_biprod_iso_of_index I,\n  -- now use the fact that the functors are additive and that there exists some iso with a biproduct\n  resetI,\n  let eF : F.obj (⨁ λ (i : ι), tunit.{u}) ≅ ⨁ λ (i : ι), F.obj tunit :=\n    (limits.is_bilimit_of_preserves F\n    (limits.biproduct.is_bilimit (λ i : ι, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (λ i : ι, F.obj tunit)).is_colimit,\n  let eG : G.obj (⨁ λ (i : ι), tunit.{u}) ≅ ⨁ λ (i : ι), G.obj tunit :=\n    (limits.is_bilimit_of_preserves G\n    (limits.biproduct.is_bilimit (λ i : ι, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (λ i : ι, G.obj tunit)).is_colimit,\n  have : η.app (A.diagram.obj I) =\n    F.map e.inv ≫ eF.hom ≫ limits.biproduct.desc\n      (λ i, η.app _ ≫ limits.biproduct.ι _ i) ≫ eG.inv ≫ G.map e.hom,\n  { rw [← functor.map_iso_inv, iso.eq_inv_comp, ← iso.inv_comp_eq],\n    apply limits.biproduct.hom_ext', intros i,\n    simp only [functor.map_iso_hom, nat_trans.naturality,\n      limits.biproduct.ι_desc_assoc, category.assoc],\n    erw [limits.biproduct.ι_desc_assoc, limits.biproduct.ι_desc_assoc],\n    dsimp, rw η.naturality_assoc },\n  rw this,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  apply_instance,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  apply_instance,\n  apply_with is_iso.comp_is_iso { instances := ff },\n  swap,\n  apply_instance,\n  use limits.biproduct.desc\n      (λ i, inv (η.app _) ≫ limits.biproduct.ι _ i),\n  split,\n  { ext, simp },\n  { ext, simp },\nend\n\ndef is_tensor_unit (A : AddCommGroup.{u}) : Prop :=\n∃ a : A, ∀ (B : AddCommGroup.{u}), function.bijective\n  (λ f : A ⟶ B, (f : A → B) a)\n\ndef is_tensor_unit.gen {A : AddCommGroup.{u}} (h : A.is_tensor_unit) :\n  A := h.some\n\ndef is_tensor_unit.as_hom {A B : AddCommGroup.{u}} (h : A.is_tensor_unit)\n  (b : B) : A ⟶ B :=\n((h.some_spec B).2 b).some\n\n@[simp]\nlemma is_tensor_unit.eval_as_hom {A B : AddCommGroup.{u}} (h : A.is_tensor_unit)\n  (b : B) : h.as_hom b h.gen = b :=\n((h.some_spec B).2 b).some_spec\n\nlemma is_tensor_unit.ext {A B : AddCommGroup.{u}} (h : A.is_tensor_unit)\n  (f g : A ⟶ B) (hh : f h.gen = g h.gen) : f = g :=\n(h.some_spec B).1 hh\n\ndef is_tensor_unit.iso {A B : AddCommGroup.{u}} (hA : A.is_tensor_unit)\n  (hB : B.is_tensor_unit) : A ≅ B :=\n{ hom := hA.as_hom hB.gen,\n  inv := hB.as_hom hA.gen,\n  hom_inv_id' := begin\n    apply hA.ext,\n    simp,\n  end,\n  inv_hom_id' := begin\n    apply hB.ext,\n    simp,\n  end }\n\nlemma is_tensor_unit_tunit : tunit.{u}.is_tensor_unit :=\nbegin\n  use tunit.gen,\n  intros B,\n  split,\n  { intros f g h,\n    dsimp [tunit.gen] at h,\n    change (adj'.unit.app _ ≫ (forget _).map f) _ =\n      (adj'.unit.app _ ≫ (forget _).map g) _ at h,\n    apply_fun adj'.hom_equiv _ _,\n    simp only [adjunction.hom_equiv_unit],\n    ext t,\n    let e := limits.terminal.from (punit : Type u),\n    suffices : t = e punit.star,\n    { rw this, exact h },\n    apply_fun types.punit_iso.inv,\n    { simp },\n    intros i j h, apply_fun types.punit_iso.hom at h,\n    simpa using h },\n  { intros t,\n    use tunit.lift (types.pt t),\n    dsimp only [tunit.lift, types.pt, tunit.gen],\n    simp only [adjunction.hom_equiv_counit],\n    change (adj'.unit.app _ ≫\n      (forget _).map (free'.map (λ (x : ⊤_ Type u), t) ≫ adj'.counit.app B)) _ = _,\n    simp only [functor.map_comp, adjunction.unit_naturality_assoc],\n    erw adj'.right_triangle_components, refl }\nend\n\nlemma is_iso_of_preserves_of_is_tensor_unit {𝓐 : Type u'} [category.{u} 𝓐] [preadditive 𝓐]\n  (F G : AddCommGroup ⥤ 𝓐)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (η : F ⟶ G)\n  (U : AddCommGroup)\n  (hU : U.is_tensor_unit)\n  [hη : is_iso (η.app U)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors ℤ A] :\n  is_iso (η.app A) :=\nbegin\n  suffices : is_iso (η.app tunit),\n  { resetI, apply is_iso_of_preserves },\n  let e : tunit ≅ U := is_tensor_unit_tunit.iso hU,\n  suffices : η.app tunit = F.map e.hom ≫ η.app U ≫ G.map e.inv,\n  { rw this, apply is_iso.comp_is_iso, },\n  rw [← η.naturality, ← F.map_comp_assoc, e.hom_inv_id, F.map_id, category.id_comp],\nend\n\nend AddCommGroup\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/for_mathlib/AddCommGroup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542925, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4524913262658595}}
{"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury G. Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.conditionally_complete_lattice\nimport Mathlib.logic.function.conjugate\nimport Mathlib.order.ord_continuous\nimport Mathlib.data.equiv.mul_add\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Semiconjugate by `Sup`\n\nIn this file we prove two facts about semiconjugate (families of) functions.\n\nFirst, if an order isomorphism `fa : α → α` is semiconjugate to an order embedding `fb : β → β` by\n`g : α → β`, then `fb` is semiconjugate to `fa` by `y ↦ Sup {x | g x ≤ y}`, see\n`semiconj.symm_adjoint`.\n\nSecond, consider two actions `f₁ f₂ : G → α → α` of a group on a complete lattice by order\nisomorphisms. Then the map `x ↦ ⨆ g : G, (f₁ g)⁻¹ (f₂ g x)` semiconjugates each `f₁ g'` to `f₂ g'`,\nsee `function.Sup_div_semiconj`.  In the case of a conditionally complete lattice, a similar\nstatement holds true under an additional assumption that each set `{(f₁ g)⁻¹ (f₂ g x) | g : G}` is\nbounded above, see `function.cSup_div_semiconj`.\n\nThe lemmas come from [Étienne Ghys, Groupes d'homeomorphismes du cercle et cohomologie\nbornee][ghys87:groupes], Proposition 2.1 and 5.4 respectively. In the paper they are formulated for\nhomeomorphisms of the circle, so in order to apply results from this file one has to lift these\nhomeomorphisms to the real line first.\n-/\n\n/-- We say that `g : β → α` is an order right adjoint function for `f : α → β` if it sends each `y`\nto a least upper bound for `{x | f x ≤ y}`. If `α` is a partial order, and `f : α → β` has\na right adjoint, then this right adjoint is unique. -/\ndef is_order_right_adjoint {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] (f : α → β) (g : β → α) :=\n  ∀ (y : β), is_lub (set_of fun (x : α) => f x ≤ y) (g y)\n\ntheorem is_order_right_adjoint_Sup {α : Type u_1} {β : Type u_2} [complete_lattice α] [preorder β] (f : α → β) : is_order_right_adjoint f fun (y : β) => Sup (set_of fun (x : α) => f x ≤ y) :=\n  fun (y : β) => is_lub_Sup (set_of fun (x : α) => f x ≤ y)\n\ntheorem is_order_right_adjoint_cSup {α : Type u_1} {β : Type u_2} [conditionally_complete_lattice α] [preorder β] (f : α → β) (hne : ∀ (y : β), ∃ (x : α), f x ≤ y) (hbdd : ∀ (y : β), ∃ (b : α), ∀ (x : α), f x ≤ y → x ≤ b) : is_order_right_adjoint f fun (y : β) => Sup (set_of fun (x : α) => f x ≤ y) :=\n  fun (y : β) => is_lub_cSup (hne y) (hbdd y)\n\ntheorem is_order_right_adjoint.unique {α : Type u_1} {β : Type u_2} [partial_order α] [preorder β] {f : α → β} {g₁ : β → α} {g₂ : β → α} (h₁ : is_order_right_adjoint f g₁) (h₂ : is_order_right_adjoint f g₂) : g₁ = g₂ :=\n  funext fun (y : β) => is_lub.unique (h₁ y) (h₂ y)\n\ntheorem is_order_right_adjoint.right_mono {α : Type u_1} {β : Type u_2} [preorder α] [preorder β] {f : α → β} {g : β → α} (h : is_order_right_adjoint f g) : monotone g :=\n  fun (y₁ y₂ : β) (hy : y₁ ≤ y₂) =>\n    is_lub.mono (h y₁) (h y₂) fun (x : α) (hx : x ∈ set_of fun (x : α) => f x ≤ y₁) => le_trans hx hy\n\nnamespace function\n\n\n/-- If an order automorphism `fa` is semiconjugate to an order embedding `fb` by a function `g`\nand `g'` is an order right adjoint of `g` (i.e. `g' y = Sup {x | f x ≤ y}`), then `fb` is\nsemiconjugate to `fa` by `g'`.\n\nThis is a version of Proposition 2.1 from [Étienne Ghys, Groupes d'homeomorphismes du cercle et\ncohomologie bornee][ghys87:groupes]. -/\ntheorem semiconj.symm_adjoint {α : Type u_1} {β : Type u_2} [partial_order α] [preorder β] {fa : α ≃o α} {fb : β ↪o β} {g : α → β} (h : semiconj g ⇑fa ⇑fb) {g' : β → α} (hg' : is_order_right_adjoint g g') : semiconj g' ⇑fb ⇑fa := sorry\n\ntheorem semiconj_of_is_lub {α : Type u_1} {G : Type u_3} [partial_order α] [group G] (f₁ : G →* α ≃o α) (f₂ : G →* α ≃o α) {h : α → α} (H : ∀ (x : α), is_lub (set.range fun (g' : G) => coe_fn (coe_fn f₁ g'⁻¹) (coe_fn (coe_fn f₂ g') x)) (h x)) (g : G) : semiconj h ⇑(coe_fn f₂ g) ⇑(coe_fn f₁ g) := sorry\n\n/-- Consider two actions `f₁ f₂ : G → α → α` of a group on a complete lattice by order\nisomorphisms. Then the map `x ↦ ⨆ g : G, (f₁ g)⁻¹ (f₂ g x)` semiconjugates each `f₁ g'` to `f₂ g'`.\n\nThis is a version of Proposition 5.4 from [Étienne Ghys, Groupes d'homeomorphismes du cercle et\ncohomologie bornee][ghys87:groupes]. -/\ntheorem Sup_div_semiconj {α : Type u_1} {G : Type u_3} [complete_lattice α] [group G] (f₁ : G →* α ≃o α) (f₂ : G →* α ≃o α) (g : G) : semiconj (fun (x : α) => supr fun (g' : G) => coe_fn (coe_fn f₁ g'⁻¹) (coe_fn (coe_fn f₂ g') x)) ⇑(coe_fn f₂ g)\n  ⇑(coe_fn f₁ g) :=\n  semiconj_of_is_lub f₁ f₂ (fun (x : α) => is_lub_supr) g\n\n/-- Consider two actions `f₁ f₂ : G → α → α` of a group on a conditionally complete lattice by order\nisomorphisms. Suppose that each set $s(x)=\\{f_1(g)^{-1} (f_2(g)(x)) | g \\in G\\}$ is bounded above.\nThen the map `x ↦ Sup s(x)` semiconjugates each `f₁ g'` to `f₂ g'`.\n\nThis is a version of Proposition 5.4 from [Étienne Ghys, Groupes d'homeomorphismes du cercle et\ncohomologie bornee][ghys87:groupes]. -/\ntheorem cSup_div_semiconj {α : Type u_1} {G : Type u_3} [conditionally_complete_lattice α] [group G] (f₁ : G →* α ≃o α) (f₂ : G →* α ≃o α) (hbdd : ∀ (x : α), bdd_above (set.range fun (g : G) => coe_fn (coe_fn f₁ g⁻¹) (coe_fn (coe_fn f₂ g) x))) (g : G) : semiconj (fun (x : α) => supr fun (g' : G) => coe_fn (coe_fn f₁ g'⁻¹) (coe_fn (coe_fn f₂ g') x)) ⇑(coe_fn f₂ g)\n  ⇑(coe_fn f₁ g) := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/order/semiconj_Sup.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4524913262658594}}
{"text": "def allPairs (xs : List α) (ys : List β) : List (α × β) :=\n  let rec aux\n  | [], r => r\n  | x::xs, r =>\n    let rec aux₂\n    | [], r => r\n    | y::ys, r => (x, y) :: r\n    aux₂ ys (aux xs r)\n  aux xs []\n\ndef allPairsFixed (xs : List α) (ys : List β) : List (α × β) :=\n  let rec aux\n  | [], r => r\n  | x::xs, r =>\n    let rec aux₂\n    | [], r => r\n    | y::ys, r => aux₂ ys ((x, y) :: r)\n    aux₂ ys (aux xs r)\n  aux xs []\n\n\n#eval allPairsFixed [1, 2, 3] ['a', 'b']\n\nexample : (allPairsFixed [1, 2, 3] ['a', 'b']) = [(1, 'b'), (1, 'a'), (2, 'b'), (2, 'a'), (3, 'b'), (3, 'a')] :=\n  rfl\n\nexample : (allPairsFixed (List.iota 3) (List.iota 4) |>.length) = 12 :=\n  rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/1020.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.45239762100290803}}
{"text": "/-\nThis file contains the Tseitin encoding for XOR.\nBoth the pooled and linear encodigns are included here.\n\nAuthors: Cayden Codel, Jeremy Avidgad, Marijn Heule\nCarnegie Mellon University\n-/\n\nimport cnf.literal\nimport cnf.clause\nimport cnf.cnf\nimport cnf.encoding\nimport cnf.gensym\nimport xor.xor\nimport xor.direct_xor\n\nimport data.list.basic\nimport data.nat.basic\n\nuniverse u\n\nvariables {V : Type u} [inhabited V] [decidable_eq V]\n\nopen literal\nopen clause\nopen cnf\nopen Xor\nopen encoding\nopen gensym\n\nopen nat\nopen list\nopen list.perm\nopen assignment\nopen function\n\nnamespace tseitin_xor\n\nvariables {l : list (literal V)} {g : gensym V} {k : nat} (hk : k ≥ 3) {v : V} {τ : assignment V}\n\nlemma disjoint_fresh_of_disjoint : disjoint g.stock (clause.vars l) → \n  disjoint g.fresh.2.stock (clause.vars ((Pos g.fresh.1) :: (l.drop (k - 1)))) :=\nbegin\n  intro h,\n  apply set.disjoint_right.mpr,\n  intros v hv,\n  simp [clause.vars] at hv,\n  rcases hv with rfl | hv,\n  { rw var,\n    exact fresh_not_mem_fresh_stock g },\n  { intro hcon,\n    rw set.disjoint_right at h,\n    have := vars_subset_of_subset (drop_subset (k - 1) l),\n    exact absurd ((fresh_stock_subset g) hcon) (h (this hv)) }\nend\n\nlemma drop_len_lt (lit : literal V) (hk : k ≥ 3) :\n  length l > k → length (lit :: (l.drop (k - 1))) < length l :=\nbegin\n  intro hl,\n  rw length_cons,\n  rcases exists_append_of_gt_length hl with ⟨x₁, x₂, rfl, hl₁⟩,\n  simp only [hl₁, length_drop, length_append],\n  rw [add_comm k x₂.length, nat.add_sub_assoc (nat.sub_le k 1),\n      nat.sub_sub_self (le_of_add_le_right hk), add_assoc],\n  apply add_lt_add_left,\n  exact succ_le_iff.mp hk,\nend\n\nvariables {p : list (literal V) → list (literal V)} (hp : ∀ l, perm l (p l))\n\ndef tseitin_xor : list (literal V) → gensym V → cnf V\n| l g :=  if h : length l ≤ k then direct_xor l else\n          have length (p (Pos g.fresh.1 :: (l.drop (k - 1)))) < length l,\n            from (perm.length_eq (hp (Pos g.fresh.1 :: (l.drop (k - 1))))) ▸ \n              (drop_len_lt _ hk (not_le.mp h)),\n          (direct_xor (l.take (k - 1) ++ [(Neg g.fresh.1)])) ++\n          (tseitin_xor (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)\nusing_well_founded {\n  rel_tac := λ a b, `[exact ⟨_, measure_wf (λ σ, list.length σ.1)⟩],\n  dec_tac := tactic.assumption\n}\n\nlemma tseitin_base_case : length l ≤ k → tseitin_xor hk hp l g = direct_xor l :=\nassume h, by { rw tseitin_xor, simp only [h, if_true] }\n\ntheorem mem_tseitin_xor_vars_of_mem_vars\n  (hdis : disjoint g.stock (clause.vars l)) :\n  v ∈ (clause.vars l) → v ∈ (tseitin_xor hk hp l g).vars :=\nbegin\n  induction l using strong_induction_on_lists with l ih generalizing g,\n  by_cases hl : length l ≤ k,\n  { rw [tseitin_base_case hk hp hl, vars_direct_xor], exact id },\n  { intro h,\n    rw tseitin_xor,\n    simp [hl],\n    rw [← take_append_drop (k - 1) l, clause.vars_append] at h,\n    rw cnf.vars_append,\n    rcases finset.mem_union.mp h with (h | h),\n    { apply finset.mem_union_left,\n      rw [vars_direct_xor, clause.vars_append],\n      exact finset.mem_union_left _ h },\n    { rw not_le at hl,\n      have h₁ := drop_len_lt (Pos g.fresh.1) hk hl,\n      have h₂ := disjoint_fresh_of_disjoint hdis,\n      rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,\n      rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂,\n      have := ih _ h₁ h₂,\n      rw ← clause.vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,\n      exact finset.mem_union_right _ (this (mem_vars_cons_of_mem_vars _ h)) } }\nend\n\ntheorem not_mem_tseitin_xor_vars_of_not_mem_vars_of_not_mem_stock\n  (hdis : disjoint g.stock (clause.vars l)) :\n  v ∉ (clause.vars l) → v ∉ g.stock → v ∉ (tseitin_xor hk hp l g).vars :=\nbegin\n  induction l using strong_induction_on_lists with l ih generalizing g,\n  by_cases hl : length l ≤ k,\n  { rw [tseitin_base_case hk hp hl, vars_direct_xor l], tautology },\n  { intros hvars hg,\n    rw tseitin_xor,\n    simp [hl],\n    rw cnf.vars_append,\n    apply finset.not_mem_union.mpr,\n    split,\n    { rw [vars_direct_xor, clause.vars_append],\n      apply finset.not_mem_union.mpr,\n      split,\n      { intro hcon,\n        have := (vars_subset_of_subset (take_subset (k - 1) l)),\n        exact absurd (this hcon) hvars },\n      { simp [var],\n        intro hcon,\n        rw hcon at hg,\n        exact absurd (fresh_mem_stock g) hg } },\n    { have h₁ := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),\n      have h₂ := disjoint_fresh_of_disjoint hdis,\n      have h₃ : v ∉ clause.vars (Pos g.fresh.1 :: drop (k - 1) l),\n      { simp [clause.vars, var],\n        rintros (rfl | h),\n        { exact hg (fresh_mem_stock g) },\n        { exact hvars (vars_subset_of_subset (drop_subset (k - 1) l) h) } },\n      have h₄ : v ∉ g.fresh.2.stock,\n      { intro hcon,\n        exact hg ((fresh_stock_subset g) hcon) },\n      rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,\n      rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂ h₃,\n      exact ih _ h₁ h₂ h₃ h₄ } }\nend\n\nlemma tseitin_forward (hdis : disjoint g.stock (clause.vars l)) : \n  Xor.eval τ l = tt → ∃ (σ : assignment V),\n  (tseitin_xor hk hp l g).eval σ = tt ∧ (eqod τ σ (clause.vars l)) :=\nbegin\n  intro he,\n  induction l using strong_induction_on_lists with l ih generalizing g τ,\n  by_cases hl : length l ≤ k,\n  { use τ, rw [tseitin_base_case hk hp hl, eval_direct_xor_eq_eval_Xor], simp [he] },\n  {\n    rw [eval_eq_bodd_count_tt,\n      ← (take_append_drop (k - 1) l), clause.count_tt_append, bodd_add] at he,\n\n    have hnotmem := set.disjoint_left.mp hdis (g.fresh_mem_stock),\n    have h₁ := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),\n    have h₂ := disjoint_fresh_of_disjoint hdis,\n    rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,\n    rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂,\n    have htakevars := vars_subset_of_subset (take_subset (k - 1) l),\n    have hdropvars := vars_subset_of_subset (drop_subset (k - 1) l),\n\n    rw tseitin_xor,\n    simp [hl, cnf.eval_append],\n\n    -- Case on the truth value of the last n - k + 1 variables\n    -- Note: the proof is symmetric, so any tightening-up can be done in both\n    cases hc : bodd (clause.count_tt τ (take (k - 1) l)),\n    { rw [hc, bool.bxor_ff_left] at he,\n      rcases exists_eqod_and_eq_of_not_mem τ ff hnotmem with ⟨γ, heqod, hg⟩,\n      have : bodd (clause.count_tt γ (Pos g.fresh.1 :: drop (k - 1) l)) = tt,\n      { simp only [clause.count_tt_cons, literal.eval, hg, cond,\n          ← count_tt_eq_of_eqod (eqod_subset hdropvars heqod), he] },\n      rw [← eval_eq_bodd_count_tt, eval_eq_of_perm (hp (Pos g.fresh.1 :: drop (k - 1) l))] at this,\n\n      -- Apply the induction hypothesis\n      rcases (ih _ h₁ h₂ this) with ⟨γ₂, he₂, hg₂⟩,\n\n      have heqod₂ : eqod (assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ) γ (clause.vars l),\n      { intros v hv,\n        by_cases hmem : v ∈ clause.vars (l.drop (k - 1)),\n        { have h₃ := mem_vars_cons_of_mem_vars (Pos g.fresh.1) hmem,\n          rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₃,\n          rw [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ h₃), hg₂ v h₃] },\n        { have hdis₂ := set.disjoint_right.mp hdis hv,\n          have hne : v ≠ g.fresh.1,\n          { intro hcon,\n            exact (hcon ▸ hdis₂) (fresh_mem_stock g) },\n          have : v ∉ clause.vars (Pos g.fresh.1 :: drop (k - 1) l),\n          { simp [clause.vars, var],\n            rintros (hcon | hcon),\n            { exact hne hcon },\n            { exact hmem hcon } },\n          rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,\n          have hstock : v ∉ g.fresh.2.stock,\n          { intro hcon,\n            exact hdis₂ ((fresh_stock_subset g) hcon) },\n          rw ite_neg (not_mem_tseitin_xor_vars_of_not_mem_vars_of_not_mem_stock hk hp h₂ this hstock) } },\n        \n      use assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ,\n      split,\n      { split,\n        { simp [eval_direct_xor_eq_eval_Xor, eval_eq_bodd_count_tt, \n            clause.count_tt_append, bodd_add, literal.eval, hg],\n          have : g.fresh.1 ∈ clause.vars (Pos g.fresh.1 :: (l.drop (k - 1))),\n          { exact mem_vars_cons_self _ _ },\n          rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,\n          simp [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ this), \n            ← (hg₂ g.fresh.1 this), hg,\n            count_tt_eq_of_eqod (eqod_subset htakevars heqod₂),\n            ← count_tt_eq_of_eqod (eqod_subset htakevars heqod), hc] },\n        { exact he₂ ▸ eval_eq_of_eqod (ite_eqod _ _ _) } },\n      { exact eqod.trans heqod (heqod₂.symm) } },\n    { simp only [hc, bnot_eq_true_eq_eq_ff, tt_bxor] at he,\n        rcases exists_eqod_and_eq_of_not_mem τ tt hnotmem with ⟨γ, heqod, hg⟩,\n        have : bodd (clause.count_tt γ (Pos g.fresh.1 :: drop (k - 1) l)) = tt,\n        { simp only [clause.count_tt_cons, literal.eval, hg, cond, \n            ← count_tt_eq_of_eqod (eqod_subset hdropvars heqod), he, bodd_succ,\n            bodd_add, bodd_zero, bool.bnot_ff, bxor_tt_left], },\n        rw [← eval_eq_bodd_count_tt, eval_eq_of_perm (hp (Pos g.fresh.1 :: drop (k - 1) l))] at this,\n\n        -- Apply the induction hypothesis\n        rcases (ih _ h₁ h₂ this) with ⟨γ₂, he₂, hg₂⟩,\n\n        have heqod₂ : eqod (assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ) γ (clause.vars l),\n        { intros v hv,\n          by_cases hmem : v ∈ clause.vars (l.drop (k - 1)),\n          { have h₃ := mem_vars_cons_of_mem_vars (Pos g.fresh.1) hmem,\n            rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₃,\n            rw [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ h₃), hg₂ v h₃] },\n          { have hdis₂ := set.disjoint_right.mp hdis hv,\n            have hne : v ≠ g.fresh.1,\n            { intro hcon,\n              exact (hcon ▸ hdis₂) (fresh_mem_stock g) },\n            have : v ∉ clause.vars (Pos g.fresh.1 :: drop (k - 1) l),\n            { simp [clause.vars, var],\n              rintros (hcon | hcon),\n              { exact hne hcon },\n              { exact hmem hcon } },\n            rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,\n            have hstock : v ∉ g.fresh.2.stock,\n            { intro hcon,\n              exact hdis₂ ((fresh_stock_subset g) hcon) },\n            rw ite_neg (not_mem_tseitin_xor_vars_of_not_mem_vars_of_not_mem_stock hk hp h₂ this hstock) } },\n        \n        use assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) γ₂ γ,\n        split,\n        { split,\n          { simp [eval_direct_xor_eq_eval_Xor, eval_eq_bodd_count_tt, \n              clause.count_tt_append, bodd_add, literal.eval, hg],\n            have : g.fresh.1 ∈ clause.vars (Pos g.fresh.1 :: (l.drop (k - 1))),\n            { exact mem_vars_cons_self _ _ },\n            rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at this,\n            simp [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h₂ this), \n              ← (hg₂ g.fresh.1 this), hg,\n              count_tt_eq_of_eqod (eqod_subset htakevars heqod₂),\n              ← count_tt_eq_of_eqod (eqod_subset htakevars heqod), hc] },\n          { exact he₂ ▸ eval_eq_of_eqod (ite_eqod _ _ _) } },\n        { exact eqod.trans heqod heqod₂.symm } } } \nend\n\nlemma tseitin_reverse (hdis : disjoint g.stock (clause.vars l)) :\n  cnf.eval τ (tseitin_xor hk hp l g) = tt → Xor.eval τ l = tt :=\nbegin\n  intro he,\n  induction l using strong_induction_on_lists with l ih generalizing g,\n  by_cases hl : length l ≤ k,\n  { rw [tseitin_base_case hk hp hl, eval_direct_xor_eq_eval_Xor] at he, exact he },\n  { rw tseitin_xor at he,\n    simp [hl, cnf.eval_append] at he,\n    rcases he with ⟨hdir, hrec⟩,\n    have h₁ := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),\n    have h₂ := disjoint_fresh_of_disjoint hdis,\n    rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₁,\n    rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h₂,\n    have ihred := ih _ h₁ h₂ hrec,\n    rw eval_direct_xor_eq_eval_Xor at hdir,\n    rw eval_eq_bodd_count_tt at ihred hdir |-,\n    rw ← clause.count_tt_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at ihred,\n    have := congr_arg ((clause.count_tt τ)) (take_append_drop (k - 1) l).symm,\n    have := congr_arg bodd this,\n    cases hnew : (τ g.fresh.1),\n    { simp [clause.count_tt_cons, clause.count_tt_append, hnew, literal.eval] at ihred hdir,\n      rw [clause.count_tt_append, bodd_add, hdir, ihred, ff_bxor] at this,\n      exact this },\n    { simp [clause.count_tt_cons, clause.count_tt_append, hnew, literal.eval] at ihred hdir,\n      rw [clause.count_tt_append, bodd_add, hdir, ihred, bxor_ff] at this,\n      exact this } }\nend\n\ntheorem tseitin_xor_encodes_Xor (hdis : disjoint g.stock (clause.vars l)) :\n  encodes Xor (tseitin_xor hk hp l g) l :=\nbegin\n  intro τ,\n  split,\n  { exact tseitin_forward hk hp hdis },\n  { rintros ⟨σ, he, heqod⟩,\n    rw [← Xor.eval, Xor.eval_eq_of_eqod heqod],\n    exact tseitin_reverse hk hp hdis he }\nend\n\ndef linear_perm (l : list (literal V)) : list (literal V) := l\n\nlemma linear_perm_is_perm : ∀ (l : list (literal V)), l ~ linear_perm l :=\nbegin\n  intro l,\n  rw linear_perm\nend\n\ndef linear_xor (l : list (literal V)) (g : gensym V) : cnf V :=\n  tseitin_xor hk linear_perm_is_perm l g\n\ntheorem linear_xor_encodes_Xor (hdis : disjoint g.stock (clause.vars l)) :\n  encodes Xor (linear_xor hk l g) l :=\ntseitin_xor_encodes_Xor hk linear_perm_is_perm hdis\n\ndef pooled_perm : list (literal V) → list (literal V)\n| []        := []\n| (x :: xs) := xs ++ [x]\n\nlemma pooled_perm_is_perm : ∀ (l : list (literal V)), l ~ pooled_perm l :=\nbegin\n  intro l,\n  cases l,\n  { refl },\n  { rw [pooled_perm, ← singleton_append],\n    exact perm_append_comm }\nend\n\ndef pooled_xor (l : list (literal V)) (g : gensym V) : cnf V :=\n  tseitin_xor hk pooled_perm_is_perm l g\n\ntheorem pooled_xor_encodes_Xor (hdis : disjoint g.stock (clause.vars l)) :\n  encodes Xor (pooled_xor hk l g) l :=\ntseitin_xor_encodes_Xor hk pooled_perm_is_perm hdis\n\nend tseitin_xor", "meta": {"author": "chasenorman", "repo": "verified-encodings-social-choice", "sha": "72f88c5a31ce30df5a04a99f726244c327b9a6f6", "save_path": "github-repos/lean/chasenorman-verified-encodings-social-choice", "path": "github-repos/lean/chasenorman-verified-encodings-social-choice/verified-encodings-social-choice-72f88c5a31ce30df5a04a99f726244c327b9a6f6/src/xor/tseitin_xor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4523976142370451}}
{"text": "namespace fol_19\n\nvariable U : Type\nvariable f : U → U → U\nvariable P : U → Prop\n\ntheorem fol_19 : (∀ x, P (f x x)) → (∀ x, ∃ y, P (f x y)) :=\nassume h1: ∀ x, P (f x x),\nassume t: U,\nhave h2: P (f t t), from h1 t,\nshow ∃ y, P (f t y), from exists.intro t h2\n\nend fol_19", "meta": {"author": "tomasz-lisowski", "repo": "lean-logic-examples", "sha": "2b2ccd467b49c3989bf6c92ec0358a8d6ee68c5d", "save_path": "github-repos/lean/tomasz-lisowski-lean-logic-examples", "path": "github-repos/lean/tomasz-lisowski-lean-logic-examples/lean-logic-examples-2b2ccd467b49c3989bf6c92ec0358a8d6ee68c5d/src/logic_first_order/fol_19.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333245787544825, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.45238131677100324}}
{"text": "namespace xena\n\ninductive xnat\n| zero : xnat\n| succ : xnat → xnat\n\nopen xnat\n\ndefinition lt : xnat → xnat → Prop \n| zero zero := false\n| (succ m) zero := false\n| zero (succ p) := true \n| (succ m) (succ p) := lt m p\n\nnotation a < b := lt a b\n\n#print int\n\n\n\ntheorem inequality_A2 (a b c : xnat) : a < b → b < c → a < c := λ hab hbc, sorry\n\nend xena\n\n#print prod", "meta": {"author": "AlexandruBosinta", "repo": "MyLeanPlayground", "sha": "5dc50a590d784bfc27e7fb37b6361a6dcc1b2790", "save_path": "github-repos/lean/AlexandruBosinta-MyLeanPlayground", "path": "github-repos/lean/AlexandruBosinta-MyLeanPlayground/MyLeanPlayground-5dc50a590d784bfc27e7fb37b6361a6dcc1b2790/xnat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333245787544824, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4523813167710032}}
{"text": "-- Copyright (c) 2018 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Scott Morrison\n\nimport category_theory.products\nimport category_theory.limits.preserves\n\nopen category_theory category_theory.category\n\nnamespace category_theory.limits\n\nuniverses v u -- declare the `v`'s first; see `category_theory.category` for an explanation\n\nvariables {C : Type u} [𝒞 : category.{v} C]\ninclude 𝒞\n\nvariables {J K : Type v} [small_category J] [small_category K]\n\n@[simp] lemma cone.functor_w {F : J ⥤ (K ⥤ C)} (c : cone F) {j j' : J} (f : j ⟶ j') (k : K) :\n  (c.π.app j).app k ≫ (F.map f).app k = (c.π.app j').app k :=\nby convert ←nat_trans.congr_app (c.π.naturality f).symm k; apply id_comp\n\n@[simp] lemma cocone.functor_w {F : J ⥤ (K ⥤ C)} (c : cocone F) {j j' : J} (f : j ⟶ j') (k : K) :\n  (F.map f).app k ≫ (c.ι.app j').app k = (c.ι.app j).app k :=\nby convert ←nat_trans.congr_app (c.ι.naturality f) k; apply comp_id\n\n@[simp] def functor_category_limit_cone [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) :\n  cone F :=\n{ X := F.flip ⋙ lim,\n  π :=\n  { app := λ j,\n    { app := λ k, limit.π (F.flip.obj k) j },\n      naturality' := λ j j' f,\n        by ext k; convert (limit.w (F.flip.obj k) _).symm using 1; apply id_comp } }\n\n@[simp] def functor_category_colimit_cocone [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) :\n  cocone F :=\n{ X := F.flip ⋙ colim,\n  ι :=\n  { app := λ j,\n    { app := λ k, colimit.ι (F.flip.obj k) j },\n      naturality' := λ j j' f,\n        by ext k; convert (colimit.w (F.flip.obj k) _) using 1; apply comp_id } }\n\n@[simp] def evaluate_functor_category_limit_cone\n  [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :\n  ((evaluation K C).obj k).map_cone (functor_category_limit_cone F) ≅\n    limit.cone (F.flip.obj k) :=\ncones.ext (iso.refl _) (by tidy)\n\n@[simp] def evaluate_functor_category_colimit_cocone\n  [has_colimits_of_shape J C] (F : J ⥤ K ⥤ C) (k : K) :\n  ((evaluation K C).obj k).map_cocone (functor_category_colimit_cocone F) ≅\n    colimit.cocone (F.flip.obj k) :=\ncocones.ext (iso.refl _) (by tidy)\n\ndef functor_category_is_limit_cone [has_limits_of_shape J C] (F : J ⥤ K ⥤ C) :\n  is_limit (functor_category_limit_cone F) :=\n{ lift := λ s,\n  { app := λ k, limit.lift (F.flip.obj k) (((evaluation K C).obj k).map_cone s),\n    naturality' := λ k k' f,\n      by ext; dsimp; simpa using (s.π.app j).naturality f },\n  uniq' := λ s m w,\n  begin\n    ext1 k,\n    exact is_limit.uniq _\n      (((evaluation K C).obj k).map_cone s) (m.app k) (λ j, nat_trans.congr_app (w j) k)\n  end }\n\ndef functor_category_is_colimit_cocone [has_colimits_of_shape.{v} J C] (F : J ⥤ K ⥤ C) :\n  is_colimit (functor_category_colimit_cocone F) :=\n{ desc := λ s,\n  { app := λ k, colimit.desc (F.flip.obj k) (((evaluation K C).obj k).map_cocone s),\n    naturality' := λ k k' f,\n    begin\n      ext,\n      rw [←assoc, ←assoc],\n      dsimp [functor.flip],\n      simpa using (s.ι.app j).naturality f\n    end },\n  uniq' := λ s m w,\n  begin\n    ext1 k,\n    exact is_colimit.uniq _\n      (((evaluation K C).obj k).map_cocone s) (m.app k) (λ j, nat_trans.congr_app (w j) k)\n  end }\n\ninstance functor_category_has_limits_of_shape\n  [has_limits_of_shape J C] : has_limits_of_shape J (K ⥤ C) :=\nλ F,\n{ cone := functor_category_limit_cone F,\n  is_limit := functor_category_is_limit_cone F }\n\ninstance functor_category_has_colimits_of_shape\n  [has_colimits_of_shape J C] : has_colimits_of_shape J (K ⥤ C) :=\nλ F,\n{ cocone := functor_category_colimit_cocone F,\n  is_colimit := functor_category_is_colimit_cocone F }\n\ninstance functor_category_has_limits [has_limits C] : has_limits (K ⥤ C) :=\nλ J 𝒥, by resetI; apply_instance\n\ninstance functor_category_has_colimits [has_colimits C] : has_colimits (K ⥤ C) :=\nλ J 𝒥, by resetI; apply_instance\n\ninstance evaluation_preserves_limits_of_shape [has_limits_of_shape J C] (k : K) :\n  preserves_limits_of_shape J ((evaluation K C).obj k) :=\nλ F, preserves_limit_of_preserves_limit_cone (limit.is_limit _) $\n  is_limit.of_iso_limit (limit.is_limit _)\n    (evaluate_functor_category_limit_cone F k).symm\n\ninstance evaluation_preserves_colimits_of_shape [has_colimits_of_shape J C] (k : K) :\n  preserves_colimits_of_shape J ((evaluation K C).obj k) :=\nλ F, preserves_colimit_of_preserves_colimit_cocone (colimit.is_colimit _) $\n  is_colimit.of_iso_colimit (colimit.is_colimit _)\n    (evaluate_functor_category_colimit_cocone F k).symm\n\ninstance evaluation_preserves_limits [has_limits C] (k : K) :\n  preserves_limits ((evaluation K C).obj k) :=\nλ J 𝒥, by resetI; apply_instance\n\ninstance evaluation_preserves_colimits [has_colimits C] (k : K) :\n  preserves_colimits ((evaluation K C).obj k) :=\nλ J 𝒥, by resetI; apply_instance\n\nend category_theory.limits\n", "meta": {"author": "digama0", "repo": "mathlib-ITP2019", "sha": "5cbd0362e04e671ef5db1284870592af6950197c", "save_path": "github-repos/lean/digama0-mathlib-ITP2019", "path": "github-repos/lean/digama0-mathlib-ITP2019/mathlib-ITP2019-5cbd0362e04e671ef5db1284870592af6950197c/src/category_theory/limits/functor_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585903489892, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45236475162831513}}
{"text": "/-\nCopyright (c) 2021 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.monoidal.free.basic\n! leanprover-community/mathlib commit 14b69e9f3c16630440a2cbd46f1ddad0d561dee7\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Monoidal.Functor\n\n/-!\n# The free monoidal category over a type\n\nGiven a type `C`, the free monoidal category over `C` has as objects formal expressions built from\n(formal) tensor products of terms of `C` and a formal unit. Its morphisms are compositions and\ntensor products of identities, unitors and associators.\n\nIn this file, we construct the free monoidal category and prove that it is a monoidal category. If\n`D` is a monoidal category, we construct the functor `free_monoidal_category C ⥤ D` associated to\na function `C → D`.\n\nThe free monoidal category has two important properties: it is a groupoid and it is thin. The former\nis obvious from the construction, and the latter is what is commonly known as the monoidal coherence\ntheorem. Both of these properties are proved in the file `coherence.lean`.\n\n-/\n\n\nuniverse v' u u'\n\nnamespace CategoryTheory\n\nopen MonoidalCategory\n\nvariable {C : Type u}\n\nsection\n\nvariable (C)\n\n/--\nGiven a type `C`, the free monoidal category over `C` has as objects formal expressions built from\n(formal) tensor products of terms of `C` and a formal unit. Its morphisms are compositions and\ntensor products of identities, unitors and associators.\n-/\ninductive FreeMonoidalCategory : Type u\n  | of : C → free_monoidal_category\n  | Unit : free_monoidal_category\n  | tensor : free_monoidal_category → free_monoidal_category → free_monoidal_category\n  deriving Inhabited\n#align category_theory.free_monoidal_category CategoryTheory.FreeMonoidalCategory\n\nend\n\n-- mathport name: exprF\nlocal notation \"F\" => FreeMonoidalCategory\n\nnamespace FreeMonoidalCategory\n\n/-- Formal compositions and tensor products of identities, unitors and associators. The morphisms\n    of the free monoidal category are obtained as a quotient of these formal morphisms by the\n    relations defining a monoidal category. -/\n@[nolint has_nonempty_instance]\ninductive Hom : F C → F C → Type u\n  | id (X) : hom X X\n  | α_hom (X Y Z : F C) : hom ((X.tensor Y).tensor Z) (X.tensor (Y.tensor Z))\n  | α_inv (X Y Z : F C) : hom (X.tensor (Y.tensor Z)) ((X.tensor Y).tensor Z)\n  | l_hom (X) : hom (unit.tensor X) X\n  | l_inv (X) : hom X (unit.tensor X)\n  | ρ_hom (X : F C) : hom (X.tensor unit) X\n  | ρ_inv (X : F C) : hom X (X.tensor unit)\n  | comp {X Y Z} (f : hom X Y) (g : hom Y Z) : hom X Z\n  | tensor {W X Y Z} (f : hom W Y) (g : hom X Z) : hom (W.tensor X) (Y.tensor Z)\n#align category_theory.free_monoidal_category.hom CategoryTheory.FreeMonoidalCategory.Hom\n\n-- mathport name: «expr ⟶ᵐ »\nlocal infixr:10 \" ⟶ᵐ \" => Hom\n\n/-- The morphisms of the free monoidal category satisfy 21 relations ensuring that the resulting\n    category is in fact a category and that it is monoidal. -/\ninductive HomEquiv : ∀ {X Y : F C}, (X ⟶ᵐ Y) → (X ⟶ᵐ Y) → Prop\n  | refl {X Y} (f : X ⟶ᵐ Y) : hom_equiv f f\n  | symm {X Y} (f g : X ⟶ᵐ Y) : hom_equiv f g → hom_equiv g f\n  | trans {X Y} {f g h : X ⟶ᵐ Y} : hom_equiv f g → hom_equiv g h → hom_equiv f h\n  |\n  comp {X Y Z} {f f' : X ⟶ᵐ Y} {g g' : Y ⟶ᵐ Z} :\n    hom_equiv f f' → hom_equiv g g' → hom_equiv (f.comp g) (f'.comp g')\n  |\n  tensor {W X Y Z} {f f' : W ⟶ᵐ X} {g g' : Y ⟶ᵐ Z} :\n    hom_equiv f f' → hom_equiv g g' → hom_equiv (f.tensor g) (f'.tensor g')\n  | comp_id {X Y} (f : X ⟶ᵐ Y) : hom_equiv (f.comp (Hom.id _)) f\n  | id_comp {X Y} (f : X ⟶ᵐ Y) : hom_equiv ((Hom.id _).comp f) f\n  |\n  assoc {X Y U V : F C} (f : X ⟶ᵐ U) (g : U ⟶ᵐ V) (h : V ⟶ᵐ Y) :\n    hom_equiv ((f.comp g).comp h) (f.comp (g.comp h))\n  | tensor_id {X Y} : hom_equiv ((Hom.id X).tensor (Hom.id Y)) (Hom.id _)\n  |\n  tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : F C} (f₁ : X₁ ⟶ᵐ Y₁) (f₂ : X₂ ⟶ᵐ Y₂) (g₁ : Y₁ ⟶ᵐ Z₁)\n    (g₂ : Y₂ ⟶ᵐ Z₂) :\n    hom_equiv ((f₁.comp g₁).tensor (f₂.comp g₂)) ((f₁.tensor f₂).comp (g₁.tensor g₂))\n  | α_hom_inv {X Y Z} : hom_equiv ((Hom.α_hom X Y Z).comp (Hom.α_inv X Y Z)) (Hom.id _)\n  | α_inv_hom {X Y Z} : hom_equiv ((Hom.α_inv X Y Z).comp (Hom.α_hom X Y Z)) (Hom.id _)\n  |\n  associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃} (f₁ : X₁ ⟶ᵐ Y₁) (f₂ : X₂ ⟶ᵐ Y₂) (f₃ : X₃ ⟶ᵐ Y₃) :\n    hom_equiv (((f₁.tensor f₂).tensor f₃).comp (Hom.α_hom Y₁ Y₂ Y₃))\n      ((Hom.α_hom X₁ X₂ X₃).comp (f₁.tensor (f₂.tensor f₃)))\n  | ρ_hom_inv {X} : hom_equiv ((Hom.ρ_hom X).comp (Hom.ρ_inv X)) (Hom.id _)\n  | ρ_inv_hom {X} : hom_equiv ((Hom.ρ_inv X).comp (Hom.ρ_hom X)) (Hom.id _)\n  |\n  ρ_naturality {X Y} (f : X ⟶ᵐ Y) :\n    hom_equiv ((f.tensor (Hom.id unit)).comp (Hom.ρ_hom Y)) ((Hom.ρ_hom X).comp f)\n  | l_hom_inv {X} : hom_equiv ((Hom.l_hom X).comp (Hom.l_inv X)) (Hom.id _)\n  | l_inv_hom {X} : hom_equiv ((Hom.l_inv X).comp (Hom.l_hom X)) (Hom.id _)\n  |\n  l_naturality {X Y} (f : X ⟶ᵐ Y) :\n    hom_equiv (((Hom.id unit).tensor f).comp (Hom.l_hom Y)) ((Hom.l_hom X).comp f)\n  |\n  pentagon {W X Y Z} :\n    hom_equiv\n      (((Hom.α_hom W X Y).tensor (Hom.id Z)).comp\n        ((Hom.α_hom W (X.tensor Y) Z).comp ((Hom.id W).tensor (Hom.α_hom X Y Z))))\n      ((Hom.α_hom (W.tensor X) Y Z).comp (Hom.α_hom W X (Y.tensor Z)))\n  |\n  triangle {X Y} :\n    hom_equiv ((Hom.α_hom X unit Y).comp ((Hom.id X).tensor (Hom.l_hom Y)))\n      ((Hom.ρ_hom X).tensor (Hom.id Y))\n#align category_theory.free_monoidal_category.hom_equiv CategoryTheory.FreeMonoidalCategory.HomEquiv\n\n/-- We say that two formal morphisms in the free monoidal category are equivalent if they become\n    equal if we apply the relations that are true in a monoidal category. Note that we will prove\n    that there is only one equivalence class -- this is the monoidal coherence theorem. -/\ndef setoidHom (X Y : F C) : Setoid (X ⟶ᵐ Y) :=\n  ⟨HomEquiv,\n    ⟨fun f => HomEquiv.refl f, fun f g => HomEquiv.symm f g, fun f g h hfg hgh =>\n      HomEquiv.trans hfg hgh⟩⟩\n#align category_theory.free_monoidal_category.setoid_hom CategoryTheory.FreeMonoidalCategory.setoidHom\n\nattribute [instance] setoid_hom\n\nsection\n\nopen FreeMonoidalCategory.HomEquiv\n\ninstance categoryFreeMonoidalCategory : Category.{u} (F C)\n    where\n  Hom X Y := Quotient (FreeMonoidalCategory.setoidHom X Y)\n  id X := ⟦FreeMonoidalCategory.Hom.id _⟧\n  comp X Y Z f g :=\n    Quotient.map₂ Hom.comp\n      (by\n        intro f f' hf g g' hg\n        exact comp hf hg)\n      f g\n  id_comp' := by\n    rintro X Y ⟨f⟩\n    exact Quotient.sound (id_comp f)\n  comp_id' := by\n    rintro X Y ⟨f⟩\n    exact Quotient.sound (comp_id f)\n  assoc' := by\n    rintro W X Y Z ⟨f⟩ ⟨g⟩ ⟨h⟩\n    exact Quotient.sound (assoc f g h)\n#align category_theory.free_monoidal_category.category_free_monoidal_category CategoryTheory.FreeMonoidalCategory.categoryFreeMonoidalCategory\n\ninstance : MonoidalCategory (F C)\n    where\n  tensorObj X Y := FreeMonoidalCategory.tensor X Y\n  tensorHom X₁ Y₁ X₂ Y₂ :=\n    Quotient.map₂ Hom.tensor <| by\n      intro _ _ h _ _ h'\n      exact hom_equiv.tensor h h'\n  tensor_id' X Y := Quotient.sound tensor_id\n  tensor_comp' X₁ Y₁ Z₁ X₂ Y₂ Z₂ := by\n    rintro ⟨f₁⟩ ⟨f₂⟩ ⟨g₁⟩ ⟨g₂⟩\n    exact Quotient.sound (tensor_comp _ _ _ _)\n  tensorUnit := FreeMonoidalCategory.unit\n  associator X Y Z :=\n    ⟨⟦Hom.α_hom X Y Z⟧, ⟦Hom.α_inv X Y Z⟧, Quotient.sound α_hom_inv, Quotient.sound α_inv_hom⟩\n  associator_naturality' X₁ X₂ X₃ Y₁ Y₂ Y₃ :=\n    by\n    rintro ⟨f₁⟩ ⟨f₂⟩ ⟨f₃⟩\n    exact Quotient.sound (associator_naturality _ _ _)\n  leftUnitor X := ⟨⟦Hom.l_hom X⟧, ⟦Hom.l_inv X⟧, Quotient.sound l_hom_inv, Quotient.sound l_inv_hom⟩\n  leftUnitor_naturality' X Y := by\n    rintro ⟨f⟩\n    exact Quotient.sound (l_naturality _)\n  rightUnitor X :=\n    ⟨⟦Hom.ρ_hom X⟧, ⟦Hom.ρ_inv X⟧, Quotient.sound ρ_hom_inv, Quotient.sound ρ_inv_hom⟩\n  rightUnitor_naturality' X Y := by\n    rintro ⟨f⟩\n    exact Quotient.sound (ρ_naturality _)\n  pentagon' W X Y Z := Quotient.sound pentagon\n  triangle' X Y := Quotient.sound triangle\n\n@[simp]\ntheorem mk'_comp {X Y Z : F C} (f : X ⟶ᵐ Y) (g : Y ⟶ᵐ Z) :\n    ⟦f.comp g⟧ = @CategoryStruct.comp (F C) _ _ _ _ ⟦f⟧ ⟦g⟧ :=\n  rfl\n#align category_theory.free_monoidal_category.mk_comp CategoryTheory.FreeMonoidalCategory.mk'_comp\n\n@[simp]\ntheorem mk'_tensor {X₁ Y₁ X₂ Y₂ : F C} (f : X₁ ⟶ᵐ Y₁) (g : X₂ ⟶ᵐ Y₂) :\n    ⟦f.tensor g⟧ = @MonoidalCategory.tensorHom (F C) _ _ _ _ _ _ ⟦f⟧ ⟦g⟧ :=\n  rfl\n#align category_theory.free_monoidal_category.mk_tensor CategoryTheory.FreeMonoidalCategory.mk'_tensor\n\n@[simp]\ntheorem mk'_id {X : F C} : ⟦Hom.id X⟧ = 𝟙 X :=\n  rfl\n#align category_theory.free_monoidal_category.mk_id CategoryTheory.FreeMonoidalCategory.mk'_id\n\n@[simp]\ntheorem mk'_α_hom {X Y Z : F C} : ⟦Hom.α_hom X Y Z⟧ = (α_ X Y Z).Hom :=\n  rfl\n#align category_theory.free_monoidal_category.mk_α_hom CategoryTheory.FreeMonoidalCategory.mk'_α_hom\n\n@[simp]\ntheorem mk'_α_inv {X Y Z : F C} : ⟦Hom.α_inv X Y Z⟧ = (α_ X Y Z).inv :=\n  rfl\n#align category_theory.free_monoidal_category.mk_α_inv CategoryTheory.FreeMonoidalCategory.mk'_α_inv\n\n@[simp]\ntheorem mk'_ρ_hom {X : F C} : ⟦Hom.ρ_hom X⟧ = (ρ_ X).Hom :=\n  rfl\n#align category_theory.free_monoidal_category.mk_ρ_hom CategoryTheory.FreeMonoidalCategory.mk'_ρ_hom\n\n@[simp]\ntheorem mk'_ρ_inv {X : F C} : ⟦Hom.ρ_inv X⟧ = (ρ_ X).inv :=\n  rfl\n#align category_theory.free_monoidal_category.mk_ρ_inv CategoryTheory.FreeMonoidalCategory.mk'_ρ_inv\n\n@[simp]\ntheorem mk'_l_hom {X : F C} : ⟦Hom.l_hom X⟧ = (λ_ X).Hom :=\n  rfl\n#align category_theory.free_monoidal_category.mk_l_hom CategoryTheory.FreeMonoidalCategory.mk'_l_hom\n\n@[simp]\ntheorem mk'_l_inv {X : F C} : ⟦Hom.l_inv X⟧ = (λ_ X).inv :=\n  rfl\n#align category_theory.free_monoidal_category.mk_l_inv CategoryTheory.FreeMonoidalCategory.mk'_l_inv\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem tensor_eq_tensor {X Y : F C} : X.tensor Y = X ⊗ Y :=\n  rfl\n#align category_theory.free_monoidal_category.tensor_eq_tensor CategoryTheory.FreeMonoidalCategory.tensor_eq_tensor\n\n@[simp]\ntheorem unit_eq_unit : FreeMonoidalCategory.unit = 𝟙_ (F C) :=\n  rfl\n#align category_theory.free_monoidal_category.unit_eq_unit CategoryTheory.FreeMonoidalCategory.unit_eq_unit\n\nsection Functor\n\nvariable {D : Type u'} [Category.{v'} D] [MonoidalCategory D] (f : C → D)\n\n/- warning: category_theory.free_monoidal_category.project_obj -> CategoryTheory.FreeMonoidalCategory.projectObj is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} {D : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} D] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} D _inst_1], (C -> D) -> (CategoryTheory.FreeMonoidalCategory.{u2} C) -> D\nbut is expected to have type\n  forall {C : Type.{u1}} {D : Type.{u2}} [_inst_1 : CategoryTheory.Category.{u3, u2} D] [_inst_2 : CategoryTheory.MonoidalCategory.{u3, u2} D _inst_1], (C -> D) -> (CategoryTheory.FreeMonoidalCategory.{u1} C) -> D\nCase conversion may be inaccurate. Consider using '#align category_theory.free_monoidal_category.project_obj CategoryTheory.FreeMonoidalCategory.projectObjₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Auxiliary definition for `free_monoidal_category.project`. -/\ndef projectObj : F C → D\n  | free_monoidal_category.of X => f X\n  | free_monoidal_category.unit => 𝟙_ D\n  | free_monoidal_category.tensor X Y => project_obj X ⊗ project_obj Y\n#align category_theory.free_monoidal_category.project_obj CategoryTheory.FreeMonoidalCategory.projectObj\n\nsection\n\nopen Hom\n\n/- warning: category_theory.free_monoidal_category.project_map_aux -> CategoryTheory.FreeMonoidalCategory.projectMapAux is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u2}} {D : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} D] [_inst_2 : CategoryTheory.MonoidalCategory.{u1, u3} D _inst_1] (f : C -> D) {X : CategoryTheory.FreeMonoidalCategory.{u2} C} {Y : CategoryTheory.FreeMonoidalCategory.{u2} C}, (CategoryTheory.FreeMonoidalCategory.Hom.{u2} C X Y) -> (Quiver.Hom.{succ u1, u3} D (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} D (CategoryTheory.Category.toCategoryStruct.{u1, u3} D _inst_1)) (CategoryTheory.FreeMonoidalCategory.projectObj.{u1, u2, u3} C D _inst_1 _inst_2 f X) (CategoryTheory.FreeMonoidalCategory.projectObj.{u1, u2, u3} C D _inst_1 _inst_2 f Y))\nbut is expected to have type\n  PUnit.{max (max (succ (succ u1)) (succ (succ u2))) (succ (succ u3))}\nCase conversion may be inaccurate. Consider using '#align category_theory.free_monoidal_category.project_map_aux CategoryTheory.FreeMonoidalCategory.projectMapAuxₓ'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Auxiliary definition for `free_monoidal_category.project`. -/\n@[simp]\ndef projectMapAux : ∀ {X Y : F C}, (X ⟶ᵐ Y) → (projectObj f X ⟶ projectObj f Y)\n  | _, _, id _ => 𝟙 _\n  | _, _, α_hom _ _ _ => (α_ _ _ _).Hom\n  | _, _, α_inv _ _ _ => (α_ _ _ _).inv\n  | _, _, l_hom _ => (λ_ _).Hom\n  | _, _, l_inv _ => (λ_ _).inv\n  | _, _, ρ_hom _ => (ρ_ _).Hom\n  | _, _, ρ_inv _ => (ρ_ _).inv\n  | _, _, comp f g => project_map_aux f ≫ project_map_aux g\n  | _, _, hom.tensor f g => project_map_aux f ⊗ project_map_aux g\n#align category_theory.free_monoidal_category.project_map_aux CategoryTheory.FreeMonoidalCategory.projectMapAux\n\n/-- Auxiliary definition for `free_monoidal_category.project`. -/\ndef projectMap (X Y : F C) : (X ⟶ Y) → (projectObj f X ⟶ projectObj f Y) :=\n  Quotient.lift (projectMapAux f)\n    (by\n      intro f g h\n      induction' h with\n        X Y f X Y f g hfg hfg' X Y f g h _ _ hfg hgh X Y Z f f' g g' _ _ hf hg W X Y Z f g f' g' _ _ hfg hfg'\n      · rfl\n      · exact hfg'.symm\n      · exact hfg.trans hgh\n      · simp only [project_map_aux, hf, hg]\n      · simp only [project_map_aux, hfg, hfg']\n      · simp only [project_map_aux, category.comp_id]\n      · simp only [project_map_aux, category.id_comp]\n      · simp only [project_map_aux, category.assoc]\n      · simp only [project_map_aux, monoidal_category.tensor_id]\n        rfl\n      · simp only [project_map_aux, monoidal_category.tensor_comp]\n      · simp only [project_map_aux, iso.hom_inv_id]\n      · simp only [project_map_aux, iso.inv_hom_id]\n      · simp only [project_map_aux, monoidal_category.associator_naturality]\n      · simp only [project_map_aux, iso.hom_inv_id]\n      · simp only [project_map_aux, iso.inv_hom_id]\n      · simp only [project_map_aux]\n        dsimp [project_obj]\n        exact monoidal_category.right_unitor_naturality _\n      · simp only [project_map_aux, iso.hom_inv_id]\n      · simp only [project_map_aux, iso.inv_hom_id]\n      · simp only [project_map_aux]\n        dsimp [project_obj]\n        exact monoidal_category.left_unitor_naturality _\n      · simp only [project_map_aux]\n        exact monoidal_category.pentagon _ _ _ _\n      · simp only [project_map_aux]\n        exact monoidal_category.triangle _ _)\n#align category_theory.free_monoidal_category.project_map CategoryTheory.FreeMonoidalCategory.projectMap\n\nend\n\n/-- If `D` is a monoidal category and we have a function `C → D`, then we have a functor from the\n    free monoidal category over `C` to the category `D`. -/\ndef project : MonoidalFunctor (F C) D\n    where\n  obj := projectObj f\n  map := projectMap f\n  ε := 𝟙 _\n  μ X Y := 𝟙 _\n#align category_theory.free_monoidal_category.project CategoryTheory.FreeMonoidalCategory.project\n\nend Functor\n\nend\n\nend FreeMonoidalCategory\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Monoidal/Free/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45236474437683694}}
{"text": "/-\nCopyright (c) 2021 Chris Hughes. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Chris Hughes\n-/\nimport linear_algebra.basic\nimport linear_algebra.prod\nimport linear_algebra.pi\nimport data.set_like.fintype\nimport linear_algebra.linear_independent\nimport tactic.linarith\nimport algebra.algebra.basic\nimport ring_theory.noetherian\nimport ring_theory.jacobson_ideal\nimport ring_theory.nilpotent\nimport ring_theory.nakayama\n\n/-!\n# Artinian rings and modules\n\n\nA module satisfying these equivalent conditions is said to be an *Artinian* R-module\nif every decreasing chain of submodules is eventually constant, or equivalently,\nif the relation `<` on submodules is well founded.\n\nA ring is an *Artinian ring* if it is Artinian as a module over itself.\n\n(Note that we do not assume yet that our rings are commutative,\nso perhaps this should be called \"left Artinian\".\nTo avoid cumbersome names once we specialize to the commutative case,\nwe don't make this explicit in the declaration names.)\n\n## Main definitions\n\nLet `R` be a ring and let `M` and `P` be `R`-modules. Let `N` be an `R`-submodule of `M`.\n\n* `is_artinian R M` is the proposition that `M` is a Artinian `R`-module. It is a class,\n  implemented as the predicate that the `<` relation on submodules is well founded.\n\n## References\n\n* [M. F. Atiyah and I. G. Macdonald, *Introduction to commutative algebra*][atiyah-macdonald]\n* [samuel]\n\n## Tags\n\nArtinian, artinian, Artinian ring, Artinian module, artinian ring, artinian module\n\n-/\nopen set\nopen_locale big_operators pointwise\n\n/--\n`is_artinian R M` is the proposition that `M` is an Artinian `R`-module,\nimplemented as the well-foundedness of submodule inclusion.\n-/\nclass is_artinian (R M) [semiring R] [add_comm_monoid M] [module R M] : Prop :=\n(well_founded_submodule_lt [] : well_founded ((<) : submodule R M → submodule R M → Prop))\n\nsection\nvariables {R : Type*} {M : Type*} {P : Type*} {N : Type*}\nvariables [ring R] [add_comm_group M] [add_comm_group P] [add_comm_group N]\nvariables [module R M] [module R P] [module R N]\nopen is_artinian\ninclude R\n\ntheorem is_artinian_of_injective (f : M →ₗ[R] P) (h : function.injective f)\n  [is_artinian R P] : is_artinian R M :=\n⟨subrelation.wf\n  (λ A B hAB, show A.map f < B.map f,\n    from submodule.map_strict_mono_of_injective h hAB)\n  (inv_image.wf (submodule.map f) (is_artinian.well_founded_submodule_lt R P))⟩\n\ninstance is_artinian_submodule' [is_artinian R M] (N : submodule R M) : is_artinian R N :=\nis_artinian_of_injective N.subtype subtype.val_injective\n\nlemma is_artinian_of_le {s t : submodule R M} [ht : is_artinian R t]\n   (h : s ≤ t) : is_artinian R s :=\nis_artinian_of_injective (submodule.of_le h) (submodule.of_le_injective h)\n\nvariable (M)\ntheorem is_artinian_of_surjective (f : M →ₗ[R] P) (hf : function.surjective f)\n  [is_artinian R M] : is_artinian R P :=\n⟨subrelation.wf\n  (λ A B hAB, show A.comap f < B.comap f,\n    from submodule.comap_strict_mono_of_surjective hf hAB)\n  (inv_image.wf (submodule.comap f) (is_artinian.well_founded_submodule_lt _ _))⟩\nvariable {M}\n\ntheorem is_artinian_of_linear_equiv (f : M ≃ₗ[R] P)\n  [is_artinian R M] : is_artinian R P :=\nis_artinian_of_surjective _ f.to_linear_map f.to_equiv.surjective\n\ntheorem is_artinian_of_range_eq_ker\n  [is_artinian R M] [is_artinian R P]\n  (f : M →ₗ[R] N) (g : N →ₗ[R] P)\n  (hf : function.injective f)\n  (hg : function.surjective g)\n  (h : f.range = g.ker) :\n  is_artinian R N :=\n⟨well_founded_lt_exact_sequence\n  (is_artinian.well_founded_submodule_lt _ _)\n  (is_artinian.well_founded_submodule_lt _ _)\n  f.range\n  (submodule.map f)\n  (submodule.comap f)\n  (submodule.comap g)\n  (submodule.map g)\n  (submodule.gci_map_comap hf)\n  (submodule.gi_map_comap hg)\n  (by simp [submodule.map_comap_eq, inf_comm])\n  (by simp [submodule.comap_map_eq, h])⟩\n\ninstance is_artinian_prod [is_artinian R M]\n  [is_artinian R P] : is_artinian R (M × P) :=\nis_artinian_of_range_eq_ker\n  (linear_map.inl R M P)\n  (linear_map.snd R M P)\n  linear_map.inl_injective\n  linear_map.snd_surjective\n  (linear_map.range_inl R M P)\n\n@[instance, priority 100]\nlemma is_artinian_of_fintype [fintype M] : is_artinian R M :=\n⟨fintype.well_founded_of_trans_of_irrefl _⟩\n\nlocal attribute [elab_as_eliminator] fintype.induction_empty_option\n\ninstance is_artinian_pi {R ι : Type*} [fintype ι] : Π {M : ι → Type*} [ring R]\n  [Π i, add_comm_group (M i)], by exactI Π [Π i, module R (M i)],\n  by exactI Π [∀ i, is_artinian R (M i)], is_artinian R (Π i, M i) :=\nfintype.induction_empty_option\n  (begin\n    introsI α β e hα M _ _ _ _,\n    exact is_artinian_of_linear_equiv\n      (linear_equiv.Pi_congr_left R M e)\n  end)\n  (by { introsI M _ _ _ _, apply_instance })\n  (begin\n     introsI α _ ih M _ _ _ _,\n     exact is_artinian_of_linear_equiv\n        (linear_equiv.pi_option_equiv_prod R).symm,\n  end)\n  ι\n\n/-- A version of `is_artinian_pi` for non-dependent functions. We need this instance because\nsometimes Lean fails to apply the dependent version in non-dependent settings (e.g., it fails to\nprove that `ι → ℝ` is finite dimensional over `ℝ`). -/\ninstance is_artinian_pi' {R ι M : Type*} [ring R] [add_comm_group M] [module R M] [fintype ι]\n  [is_artinian R M] : is_artinian R (ι → M) :=\nis_artinian_pi\n\nend\n\nopen is_artinian submodule function\n\nsection\nvariables {R M : Type*} [ring R] [add_comm_group M] [module R M]\n\ntheorem is_artinian_iff_well_founded :\n  is_artinian R M ↔ well_founded ((<) : submodule R M → submodule R M → Prop) :=\n⟨λ h, h.1, is_artinian.mk⟩\n\nvariables {R M}\n\nlemma is_artinian.finite_of_linear_independent [nontrivial R] [is_artinian R M]\n  {s : set M} (hs : linear_independent R (coe : s → M)) : s.finite :=\nbegin\n  refine classical.by_contradiction (λ hf, (rel_embedding.well_founded_iff_no_descending_seq.1\n    (well_founded_submodule_lt R M)).elim' _),\n  have f : ℕ ↪ s, from @infinite.nat_embedding s ⟨λ f, hf ⟨f⟩⟩,\n  have : ∀ n, (coe ∘ f) '' {m | n ≤ m} ⊆ s,\n  { rintros n x ⟨y, hy₁, hy₂⟩, subst hy₂, exact (f y).2 },\n  have : ∀ a b : ℕ, a ≤ b ↔\n    span R ((coe ∘ f) '' {m | b ≤ m}) ≤ span R ((coe ∘ f) '' {m | a ≤ m}),\n  { assume a b,\n    rw [span_le_span_iff hs (this b) (this a),\n      set.image_subset_image_iff (subtype.coe_injective.comp f.injective),\n      set.subset_def],\n    simp only [set.mem_set_of_eq],\n    exact ⟨λ hab x, le_trans hab, λ h, (h _ (le_refl _))⟩ },\n  exact ⟨⟨λ n, span R ((coe ∘ f) '' {m | n ≤ m}),\n      λ x y, by simp [le_antisymm_iff, (this _ _).symm] {contextual := tt}⟩,\n    begin\n      intros a b,\n      conv_rhs { rw [gt, lt_iff_le_not_le, this, this, ← lt_iff_le_not_le] },\n      simp\n    end⟩\nend\n\n/-- A module is Artinian iff every nonempty set of submodules has a minimal submodule among them.\n-/\ntheorem set_has_minimal_iff_artinian :\n  (∀ a : set $ submodule R M, a.nonempty → ∃ M' ∈ a, ∀ I ∈ a, I ≤ M' → I = M') ↔\n  is_artinian R M :=\nby rw [is_artinian_iff_well_founded, well_founded.well_founded_iff_has_min']\n\ntheorem is_artinian.set_has_minimal [is_artinian R M] (a : set $ submodule R M) (ha : a.nonempty) :\n  ∃ M' ∈ a, ∀ I ∈ a, I ≤ M' → I = M' :=\nset_has_minimal_iff_artinian.mpr ‹_› a ha\n\n/-- A module is Artinian iff every decreasing chain of submodules stabilizes. -/\ntheorem monotone_stabilizes_iff_artinian :\n  (∀ (f : ℕ →ₘ order_dual (submodule R M)), ∃ n, ∀ m, n ≤ m → f n = f m)\n    ↔ is_artinian R M :=\nby rw [is_artinian_iff_well_founded];\n  exact (well_founded.monotone_chain_condition (order_dual (submodule R M))).symm\n\ntheorem is_artinian.monotone_stabilizes [is_artinian R M] (f : ℕ →ₘ order_dual (submodule R M)) :\n  ∃ n, ∀ m, n ≤ m → f n = f m :=\nmonotone_stabilizes_iff_artinian.mpr ‹_› f\n\n/-- If `∀ I > J, P I` implies `P J`, then `P` holds for all submodules. -/\nlemma is_artinian.induction [is_artinian R M] {P : submodule R M → Prop}\n  (hgt : ∀ I, (∀ J < I, P J) → P I) (I : submodule R M) : P I :=\nwell_founded.recursion (well_founded_submodule_lt R M) I hgt\n\n/--\nFor any endomorphism of a Artinian module, there is some nontrivial iterate\nwith disjoint kernel and range.\n-/\ntheorem is_artinian.exists_endomorphism_iterate_ker_sup_range_eq_top\n  [I : is_artinian R M] (f : M →ₗ[R] M) : ∃ n : ℕ, n ≠ 0 ∧ (f ^ n).ker ⊔ (f ^ n).range = ⊤ :=\nbegin\n  obtain ⟨n, w⟩ := monotone_stabilizes_iff_artinian.mpr I\n    (f.iterate_range.comp ⟨λ n, n+1, λ n m w, by linarith⟩),\n  specialize w ((n + 1) + n) (by linarith),\n  dsimp at w,\n  refine ⟨n + 1, nat.succ_ne_zero _, _⟩,\n  simp_rw [eq_top_iff', mem_sup],\n  intro x,\n  have : (f^(n + 1)) x ∈ (f ^ ((n + 1) + n + 1)).range,\n  { rw ← w, exact mem_range_self _ },\n  rcases this with ⟨y, hy⟩,\n  use x - (f ^ (n+1)) y,\n  split,\n  { rw [linear_map.mem_ker, linear_map.map_sub, ← hy, sub_eq_zero, pow_add],\n    simp [iterate_add_apply], },\n  { use (f^ (n+1)) y,\n    simp }\nend\n\n/-- Any injective endomorphism of an Artinian module is surjective. -/\ntheorem is_artinian.surjective_of_injective_endomorphism [is_artinian R M]\n  (f : M →ₗ[R] M) (s : injective f) : surjective f :=\nbegin\n  obtain ⟨n, ne, w⟩ := is_artinian.exists_endomorphism_iterate_ker_sup_range_eq_top f,\n  rw [linear_map.ker_eq_bot.mpr (linear_map.iterate_injective s n), bot_sup_eq,\n    linear_map.range_eq_top] at w,\n  exact linear_map.surjective_of_iterate_surjective ne w,\nend\n\n/-- Any injective endomorphism of an Artinian module is bijective. -/\ntheorem is_artinian.bijective_of_injective_endomorphism [is_artinian R M]\n  (f : M →ₗ[R] M) (s : injective f) : bijective f :=\n⟨s, is_artinian.surjective_of_injective_endomorphism f s⟩\n\n/--\nA sequence `f` of submodules of a artinian module,\nwith the supremum `f (n+1)` and the infinum of `f 0`, ..., `f n` being ⊤,\nis eventually ⊤.\n-/\nlemma is_artinian.disjoint_partial_infs_eventually_top [I : is_artinian R M]\n  (f : ℕ → submodule R M) (h : ∀ n, disjoint\n    (partial_sups (order_dual.to_dual ∘ f) n) (order_dual.to_dual (f (n+1)))) :\n  ∃ n : ℕ, ∀ m, n ≤ m → f m = ⊤  :=\nbegin\n  -- A little off-by-one cleanup first:\n  suffices t : ∃ n : ℕ, ∀ m, n ≤ m → order_dual.to_dual f (m+1) = ⊤,\n  { obtain ⟨n, w⟩ := t,\n    use n+1,\n    rintros (_|m) p,\n    { cases p, },\n    { apply w,\n      exact nat.succ_le_succ_iff.mp p }, },\n\n  obtain ⟨n, w⟩ := monotone_stabilizes_iff_artinian.mpr I (partial_sups (order_dual.to_dual ∘ f)),\n  exact ⟨n, (λ m p, eq_bot_of_disjoint_absorbs (h m)\n    ((eq.symm (w (m + 1) (le_add_right p))).trans (w m p)))⟩\nend\n\nuniverse w\nvariables {N : Type w} [add_comm_group N] [module R N]\n\n-- TODO: Prove this for artinian modules\n-- /--\n-- If `M ⊕ N` embeds into `M`, for `M` noetherian over `R`, then `N` is trivial.\n-- -/\n-- noncomputable def is_noetherian.equiv_punit_of_prod_injective [is_noetherian R M]\n--   (f : M × N →ₗ[R] M) (i : injective f) : N ≃ₗ[R] punit.{w+1} :=\n-- begin\n--   apply nonempty.some,\n--   obtain ⟨n, w⟩ := is_noetherian.disjoint_partial_sups_eventually_bot (f.tailing i)\n--     (f.tailings_disjoint_tailing i),\n--   specialize w n (le_refl n),\n--   apply nonempty.intro,\n--   refine (f.tailing_linear_equiv i n).symm.trans _,\n--   rw w,\n--   exact submodule.bot_equiv_punit,\n-- end\n\nend\n\n/--\nA ring is Artinian if it is Artinian as a module over itself.\n-/\nclass is_artinian_ring (R) [ring R] extends is_artinian R R : Prop\n\ntheorem is_artinian_ring_iff {R} [ring R] : is_artinian_ring R ↔ is_artinian R R :=\n⟨λ h, h.1, @is_artinian_ring.mk _ _⟩\n\ntheorem ring.is_artinian_of_zero_eq_one {R} [ring R] (h01 : (0 : R) = 1) : is_artinian_ring R :=\nby haveI := subsingleton_of_zero_eq_one h01;\n   haveI := fintype.of_subsingleton (0:R); split;\n  apply_instance\n\ntheorem is_artinian_of_submodule_of_artinian (R M) [ring R] [add_comm_group M] [module R M]\n  (N : submodule R M) (h : is_artinian R M) : is_artinian R N :=\nby apply_instance\n\ntheorem is_artinian_of_quotient_of_artinian (R) [ring R] (M) [add_comm_group M] [module R M]\n  (N : submodule R M) (h : is_artinian R M) : is_artinian R (M ⧸ N) :=\nis_artinian_of_surjective M (submodule.mkq N) (submodule.quotient.mk_surjective N)\n\n/-- If `M / S / R` is a scalar tower, and `M / R` is Artinian, then `M / S` is\nalso Artinian. -/\ntheorem is_artinian_of_tower (R) {S M} [comm_ring R] [ring S]\n  [add_comm_group M] [algebra R S] [module S M] [module R M] [is_scalar_tower R S M]\n  (h : is_artinian R M) : is_artinian S M :=\nbegin\n  rw is_artinian_iff_well_founded at h ⊢,\n  refine (submodule.restrict_scalars_embedding R S M).well_founded h\nend\n\ntheorem is_artinian_of_fg_of_artinian {R M} [ring R] [add_comm_group M] [module R M]\n  (N : submodule R M) [is_artinian_ring R] (hN : N.fg) : is_artinian R N :=\nlet ⟨s, hs⟩ := hN in\nbegin\n  haveI := classical.dec_eq M,\n  haveI := classical.dec_eq R,\n  letI : is_artinian R R := by apply_instance,\n  have : ∀ x ∈ s, x ∈ N, from λ x hx, hs ▸ submodule.subset_span hx,\n  refine @@is_artinian_of_surjective ((↑s : set M) → R) _ _ _ (pi.module _ _ _)\n    _ _ _ is_artinian_pi,\n  { fapply linear_map.mk,\n    { exact λ f, ⟨∑ i in s.attach, f i • i.1, N.sum_mem (λ c _, N.smul_mem _ $ this _ c.2)⟩ },\n    { intros f g, apply subtype.eq,\n      change ∑ i in s.attach, (f i + g i) • _ = _,\n      simp only [add_smul, finset.sum_add_distrib], refl },\n    { intros c f, apply subtype.eq,\n      change ∑ i in s.attach, (c • f i) • _ = _,\n      simp only [smul_eq_mul, mul_smul],\n      exact finset.smul_sum.symm } },\n  rintro ⟨n, hn⟩, change n ∈ N at hn,\n  rw [← hs, ← set.image_id ↑s, finsupp.mem_span_image_iff_total] at hn,\n  rcases hn with ⟨l, hl1, hl2⟩,\n  refine ⟨λ x, l x, subtype.ext _⟩,\n  change ∑ i in s.attach, l i • (i : M) = n,\n  rw [@finset.sum_attach M M s _ (λ i, l i • i), ← hl2,\n      finsupp.total_apply, finsupp.sum, eq_comm],\n  refine finset.sum_subset hl1 (λ x _ hx, _),\n  rw [finsupp.not_mem_support_iff.1 hx, zero_smul]\nend\n\nlemma is_artinian_of_fg_of_artinian' {R M} [ring R] [add_comm_group M] [module R M]\n  [is_artinian_ring R] (h : (⊤ : submodule R M).fg) : is_artinian R M :=\nhave is_artinian R (⊤ : submodule R M), from is_artinian_of_fg_of_artinian _ h,\nby exactI is_artinian_of_linear_equiv (linear_equiv.of_top (⊤ : submodule R M) rfl)\n\n/-- In a module over a artinian ring, the submodule generated by finitely many vectors is\nartinian. -/\ntheorem is_artinian_span_of_finite (R) {M} [ring R] [add_comm_group M] [module R M]\n  [is_artinian_ring R] {A : set M} (hA : finite A) : is_artinian R (submodule.span R A) :=\nis_artinian_of_fg_of_artinian _ (submodule.fg_def.mpr ⟨A, hA, rfl⟩)\n\ntheorem is_artinian_ring_of_surjective (R) [comm_ring R] (S) [comm_ring S]\n  (f : R →+* S) (hf : function.surjective f)\n  [H : is_artinian_ring R] : is_artinian_ring S :=\nbegin\n  rw [is_artinian_ring_iff, is_artinian_iff_well_founded] at H ⊢,\n  exact order_embedding.well_founded (ideal.order_embedding_of_surjective f hf) H,\nend\n\ninstance is_artinian_ring_range {R} [comm_ring R] {S} [comm_ring S] (f : R →+* S)\n  [is_artinian_ring R] : is_artinian_ring f.range :=\nis_artinian_ring_of_surjective R f.range f.range_restrict\n  f.range_restrict_surjective\n\ntheorem is_artinian_ring_of_ring_equiv (R) [comm_ring R] {S} [comm_ring S]\n  (f : R ≃+* S) [is_artinian_ring R] : is_artinian_ring S :=\nis_artinian_ring_of_surjective R S f.to_ring_hom f.to_equiv.surjective\n\nnamespace is_artinian_ring\n\nopen is_artinian\n\nvariables {R : Type*} [comm_ring R] [is_artinian_ring R]\n\nlemma is_nilpotent_jacobson_bot : is_nilpotent (ideal.jacobson (⊥ : ideal R)) :=\nbegin\n  let Jac := ideal.jacobson (⊥ : ideal R),\n  let f : ℕ →ₘ order_dual (ideal R) := ⟨λ n, Jac ^ n, λ _ _ h, ideal.pow_le_pow h⟩,\n  obtain ⟨n, hn⟩ : ∃ n, ∀ m, n ≤ m → Jac ^ n = Jac ^ m := is_artinian.monotone_stabilizes f,\n  refine ⟨n, _⟩,\n  let J : ideal R := annihilator (Jac ^ n),\n  suffices : J = ⊤,\n  { have hJ : J • Jac ^ n = ⊥ := annihilator_smul (Jac ^ n),\n    simpa only [this, top_smul, ideal.zero_eq_bot] using hJ },\n  by_contradiction hJ, change J ≠ ⊤ at hJ,\n  rcases is_artinian.set_has_minimal {J' : ideal R | J < J'} ⟨⊤, hJ.lt_top⟩\n    with ⟨J', hJJ' : J < J', hJ' : ∀ I, J < I → I ≤ J' → I = J'⟩,\n  rcases set_like.exists_of_lt hJJ' with ⟨x, hxJ', hxJ⟩,\n  obtain rfl : J ⊔ ideal.span {x} = J',\n  { refine hJ' (J ⊔ ideal.span {x}) _ _,\n    { rw set_like.lt_iff_le_and_exists,\n      exact ⟨le_sup_left, ⟨x, mem_sup_right (mem_span_singleton_self x), hxJ⟩⟩ },\n    { exact (sup_le hJJ'.le (span_le.2 (singleton_subset_iff.2 hxJ'))) } },\n  have : J ⊔ Jac • ideal.span {x} ≤ J ⊔ ideal.span {x},\n    from sup_le_sup_left (smul_le.2 (λ _ _ _, submodule.smul_mem _ _)) _,\n  have : Jac * ideal.span {x} ≤ J, --Need version 4 of Nakayamas lemma on Stacks\n  { classical, by_contradiction H,\n    refine H (smul_sup_le_of_le_smul_of_le_jacobson_bot\n      (fg_span_singleton _) le_rfl (hJ' _ _ this).ge),\n    exact lt_of_le_of_ne le_sup_left (λ h, H $ h.symm ▸ le_sup_right) },\n  have : ideal.span {x} * Jac ^ (n + 1) ≤ ⊥,\n    calc ideal.span {x} * Jac ^ (n + 1) = ideal.span {x} * Jac * Jac ^ n :\n      by rw [pow_succ, ← mul_assoc]\n    ... ≤ J * Jac ^ n : mul_le_mul (by rwa mul_comm) (le_refl _)\n    ... = ⊥ : by simp [J],\n  refine hxJ (mem_annihilator.2 (λ y hy, (mem_bot R).1 _)),\n  refine this (mul_mem_mul (mem_span_singleton_self x) _),\n  rwa [← hn (n + 1) (nat.le_succ _)]\nend\n\nend is_artinian_ring\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/ring_theory/artinian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850154599562, "lm_q2_score": 0.640635868562172, "lm_q1q2_score": 0.45215119639735507}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.limits.preserves.shapes.terminal\nimport category_theory.limits.shapes.zero_morphisms\n\n/-!\n# Preservation of zero objects and zero morphisms\n\nWe define the class `preserves_zero_morphisms` and show basic properties.\n\n## Main results\n\nWe provide the following results:\n* Left adjoints and right adjoints preserve zero morphisms;\n* full functors preserve zero morphisms;\n* if both categories involved have a zero object, then a functor preserves zero morphisms if and\n  only if it preserves the zero object;\n* functors which preserve initial or terminal objects preserve zero morphisms.\n\n-/\n\nuniverses v₁ v₂ u₁ u₂\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory.functor\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\nsection zero_morphisms\nvariables [has_zero_morphisms C] [has_zero_morphisms D]\n\n/-- A functor preserves zero morphisms if it sends zero morphisms to zero morphisms. -/\nclass preserves_zero_morphisms (F : C ⥤ D) : Prop :=\n(map_zero' : ∀ (X Y : C), F.map (0 : X ⟶ Y) = 0 . obviously)\n\n@[simp]\nprotected lemma map_zero (F : C ⥤ D) [preserves_zero_morphisms F] (X Y : C) :\n  F.map (0 : X ⟶ Y) = 0 :=\npreserves_zero_morphisms.map_zero' _ _\n\nlemma zero_of_map_zero (F : C ⥤ D) [preserves_zero_morphisms F] [faithful F] {X Y : C}\n  (f : X ⟶ Y) (h : F.map f = 0) : f = 0 :=\nF.map_injective $ h.trans $ eq.symm $ F.map_zero _ _\n\nlemma map_eq_zero_iff (F : C ⥤ D) [preserves_zero_morphisms F] [faithful F] {X Y : C} {f : X ⟶ Y} :\n  F.map f = 0 ↔ f = 0 :=\n⟨F.zero_of_map_zero _, by { rintro rfl, exact F.map_zero _ _ }⟩\n\n@[priority 100]\ninstance preserves_zero_morphisms_of_is_left_adjoint (F : C ⥤ D) [is_left_adjoint F] :\n  preserves_zero_morphisms F :=\n{ map_zero' := λ X Y, let adj := adjunction.of_left_adjoint F in\n  begin\n    calc F.map (0 : X ⟶ Y) = F.map 0 ≫ F.map (adj.unit.app Y) ≫ adj.counit.app (F.obj Y) : _\n    ... = F.map 0 ≫ F.map ((right_adjoint F).map (0 : F.obj X ⟶ _)) ≫ adj.counit.app (F.obj Y) : _\n    ... = 0 : _,\n    { rw adjunction.left_triangle_components, exact (category.comp_id _).symm },\n    { simp only [← category.assoc, ← F.map_comp, zero_comp] },\n    { simp only [adjunction.counit_naturality, comp_zero] }\n  end }\n\n@[priority 100]\ninstance preserves_zero_morphisms_of_is_right_adjoint (G : C ⥤ D) [is_right_adjoint G] :\n  preserves_zero_morphisms G :=\n{ map_zero' := λ X Y, let adj := adjunction.of_right_adjoint G in\n  begin\n    calc G.map (0 : X ⟶ Y) = adj.unit.app (G.obj X) ≫ G.map (adj.counit.app X) ≫ G.map 0 : _\n    ... = adj.unit.app (G.obj X) ≫ G.map ((left_adjoint G).map (0 : _ ⟶ G.obj X)) ≫ G.map 0 : _\n    ... = 0 : _,\n    { rw adjunction.right_triangle_components_assoc },\n    { simp only [← G.map_comp, comp_zero] },\n    { simp only [adjunction.unit_naturality_assoc, zero_comp] }\n  end }\n\n@[priority 100]\ninstance preserves_zero_morphisms_of_full (F : C ⥤ D) [full F] : preserves_zero_morphisms F :=\n{ map_zero' := λ X Y, calc\n  F.map (0 : X ⟶ Y) = F.map (0 ≫ (F.preimage (0 : F.obj Y ⟶ F.obj Y))) : by rw zero_comp\n                ... = 0 : by rw [F.map_comp, F.image_preimage, comp_zero] }\n\nend zero_morphisms\n\nsection zero_object\nvariables [has_zero_object C] [has_zero_object D]\n\nopen_locale zero_object\n\nvariables [has_zero_morphisms C] [has_zero_morphisms D] (F : C ⥤ D)\n\n/-- A functor that preserves zero morphisms also preserves the zero object. -/\n@[simps] def map_zero_object [preserves_zero_morphisms F] : F.obj 0 ≅ 0 :=\n{ hom := 0,\n  inv := 0,\n  hom_inv_id' := by rw [← F.map_id, id_zero, F.map_zero, zero_comp],\n  inv_hom_id' := by rw [id_zero, comp_zero] }\n\nvariables {F}\n\nlemma preserves_zero_morphisms_of_map_zero_object (i : F.obj 0 ≅ 0) : preserves_zero_morphisms F :=\n{ map_zero' := λ X Y, calc\n  F.map (0 : X ⟶ Y) = F.map (0 : X ⟶ 0) ≫ F.map 0 : by rw [← functor.map_comp, comp_zero]\n                ... = F.map 0 ≫ (i.hom ≫ i.inv) ≫ F.map 0\n                        : by rw [iso.hom_inv_id, category.id_comp]\n                ... = 0 : by simp only [zero_of_to_zero i.hom, zero_comp, comp_zero] }\n\n@[priority 100]\ninstance preserves_zero_morphisms_of_preserves_initial_object\n  [preserves_colimit (functor.empty.{v₁} C) F] : preserves_zero_morphisms F :=\npreserves_zero_morphisms_of_map_zero_object $ (F.map_iso has_zero_object.zero_iso_initial).trans $\n  (preserves_initial.iso F).trans has_zero_object.zero_iso_initial.symm\n\n@[priority 100]\ninstance preserves_zero_morphisms_of_preserves_terminal_object\n  [preserves_limit (functor.empty.{v₁} C) F] : preserves_zero_morphisms F :=\npreserves_zero_morphisms_of_map_zero_object $ (F.map_iso has_zero_object.zero_iso_terminal).trans $\n    (preserves_terminal.iso F).trans has_zero_object.zero_iso_terminal.symm\n\nend zero_object\n\nend category_theory.functor\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/category_theory/limits/preserves/shapes/zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850278370112, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.45215118495658924}}
{"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport data.lazy_list.basic\nimport data.tree\nimport data.int.basic\nimport control.bifunctor\nimport tactic.linarith\nimport testing.slim_check.gen\n\n/-!\n# `sampleable` Class\n\nThis class permits the creation samples of a given type\ncontrolling the size of those values using the `gen` monad`. It also\nhelps minimize examples by creating smaller versions of given values.\n\nWhen testing a proposition like `∀ n : ℕ, prime n → n ≤ 100`,\n`slim_check` requires that `ℕ` have an instance of `sampleable` and for\n`prime n` to be decidable.  `slim_check` will then use the instance of\n`sampleable` to generate small examples of ℕ and progressively increase\nin size. For each example `n`, `prime n` is tested. If it is false,\nthe example will be rejected (not a test success nor a failure) and\n`slim_check` will move on to other examples. If `prime n` is true, `n\n≤ 100` will be tested. If it is false, `n` is a counter-example of `∀\nn : ℕ, prime n → n ≤ 100` and the test fails. If `n ≤ 100` is true,\nthe test passes and `slim_check` moves on to trying more examples.\n\nThis is a port of the Haskell QuickCheck library.\n\n## Main definitions\n  * `sampleable` class\n  * `sampleable_functor` and `sampleable_bifunctor` class\n  * `sampleable_ext` class\n\n### `sampleable`\n\n`sampleable α` provides ways of creating examples of type `α`,\nand given such an example `x : α`, gives us a way to shrink it\nand find simpler examples.\n\n### `sampleable_ext`\n\n`sampleable_ext` generalizes the behavior of `sampleable`\nand makes it possible to express instances for types that\ndo not lend themselves to introspection, such as `ℕ → ℕ`.\nIf we test a quantification over functions the\ncounter-examples cannot be shrunken or printed meaningfully.\n\nFor that purpose, `sampleable_ext` provides a proxy representation\n`proxy_repr` that can be printed and shrunken as well\nas interpreted (using `interp`) as an object of the right type.\n\n### `sampleable_functor` and `sampleable_bifunctor`\n\n`sampleable_functor F` and `sampleable_bifunctor F` makes it possible\nto create samples of and shrink `F α` given a sampling function and a\nshrinking function for arbitrary `α`.\n\nThis allows us to separate the logic for generating the shape of a\ncollection from the logic for generating its contents. Specifically,\nthe contents could be generated using either `sampleable` or\n`sampleable_ext` instance and the `sampleable_(bi)functor` does not\nneed to use that information\n\n## Shrinking\n\nShrinking happens when `slim_check` find a counter-example to a\nproperty.  It is likely that the example will be more complicated than\nnecessary so `slim_check` proceeds to shrink it as much as\npossible. Although equally valid, a smaller counter-example is easier\nfor a user to understand and use.\n\nThe `sampleable` class, beside having the `sample` function, has a\n`shrink` function so that we can use specialized knowledge while\nshrinking a value. It is not responsible for the whole shrinking process\nhowever. It only has to take one step in the shrinking process.\n`slim_check` will repeatedly call `shrink` until no more steps can\nbe taken. Because `shrink` guarantees that the size of the candidates\nit produces is strictly smaller than the argument, we know that\n`slim_check` is guaranteed to terminate.\n\n## Tags\n\nrandom testing\n\n## References\n\n  * https://hackage.haskell.org/package/QuickCheck\n\n-/\nuniverses u v w\n\nnamespace slim_check\n\nvariables (α : Type u)\n\nlocal infix ` ≺ `:50 := has_well_founded.r\n\n/-- `sizeof_lt x y` compares the sizes of `x` and `y`. -/\ndef sizeof_lt {α} [has_sizeof α] (x y : α) := sizeof x < sizeof y\n\n/-- `shrink_fn α` is the type of functions that shrink an\nargument of type `α` -/\n@[reducible]\ndef shrink_fn (α : Type*) [has_sizeof α] := Π x : α, lazy_list { y : α // sizeof_lt y x }\n\n/-- `sampleable α` provides ways of creating examples of type `α`,\nand given such an example `x : α`, gives us a way to shrink it\nand find simpler examples.  -/\nclass sampleable :=\n[wf : has_sizeof α]\n(sample [] : gen α)\n(shrink : Π x : α, lazy_list { y : α // @sizeof _ wf y < @sizeof _ wf x } := λ _, lazy_list.nil)\n\nattribute [instance, priority 100] has_well_founded_of_has_sizeof default_has_sizeof\nattribute [instance, priority 200] sampleable.wf\n\n/-- `sampleable_functor F` makes it possible to create samples of and\nshrink `F α` given a sampling function and a shrinking function for\narbitrary `α` -/\nclass sampleable_functor (F : Type u → Type v) [functor F] :=\n[wf : Π α [has_sizeof α], has_sizeof (F α)]\n(sample [] : ∀ {α}, gen α → gen (F α))\n(shrink : ∀ α [has_sizeof α], shrink_fn α → shrink_fn (F α))\n(p_repr : ∀ α, has_repr α → has_repr (F α))\n\n/-- `sampleable_bifunctor F` makes it possible to create samples of\nand shrink `F α β` given a sampling function and a shrinking function\nfor arbitrary `α` and `β` -/\nclass sampleable_bifunctor (F : Type u → Type v → Type w) [bifunctor F] :=\n[wf : Π α β [has_sizeof α] [has_sizeof β], has_sizeof (F α β)]\n(sample [] : ∀ {α β}, gen α → gen β → gen (F α β))\n(shrink : ∀ α β [has_sizeof α] [has_sizeof β], shrink_fn α → shrink_fn β → shrink_fn (F α β))\n(p_repr : ∀ α β, has_repr α → has_repr β → has_repr (F α β))\n\nexport sampleable (sample shrink)\n\n/-- This function helps infer the proxy representation and\ninterpretation in `sampleable_ext` instances. -/\nmeta def sampleable.mk_trivial_interp : tactic unit :=\ntactic.refine ``(id)\n\n/-- `sampleable_ext` generalizes the behavior of `sampleable`\nand makes it possible to express instances for types that\ndo not lend themselves to introspection, such as `ℕ → ℕ`.\nIf we test a quantification over functions the\ncounter-examples cannot be shrunken or printed meaningfully.\n\nFor that purpose, `sampleable_ext` provides a proxy representation\n`proxy_repr` that can be printed and shrunken as well\nas interpreted (using `interp`) as an object of the right type. -/\nclass sampleable_ext (α : Sort u) :=\n(proxy_repr : Type v)\n[wf : has_sizeof proxy_repr]\n(interp [] : proxy_repr → α . sampleable.mk_trivial_interp)\n[p_repr : has_repr proxy_repr]\n(sample [] : gen proxy_repr)\n(shrink : shrink_fn proxy_repr)\n\nattribute [instance, priority 100] sampleable_ext.p_repr sampleable_ext.wf\n\nopen nat lazy_list\n\nsection prio\n\nopen sampleable_ext\n\nset_option default_priority 50\n\ninstance sampleable_ext.of_sampleable {α} [sampleable α] [has_repr α] : sampleable_ext α :=\n{ proxy_repr := α,\n  sample := sampleable.sample α,\n  shrink := shrink }\n\ninstance sampleable.functor {α} {F} [functor F] [sampleable_functor F] [sampleable α] :\n  sampleable (F α) :=\n{ wf := _,\n  sample := sampleable_functor.sample F (sampleable.sample α),\n  shrink := sampleable_functor.shrink α sampleable.shrink }\n\ninstance sampleable.bifunctor {α β} {F} [bifunctor F] [sampleable_bifunctor F] [sampleable α]\n  [sampleable β] : sampleable (F α β) :=\n{ wf := _,\n  sample := sampleable_bifunctor.sample F (sampleable.sample α) (sampleable.sample β),\n  shrink := sampleable_bifunctor.shrink α β sampleable.shrink sampleable.shrink }\n\nset_option default_priority 100\n\ninstance sampleable_ext.functor {α} {F} [functor F] [sampleable_functor F] [sampleable_ext α] :\n  sampleable_ext (F α) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr α),\n  interp := functor.map (interp _),\n  sample := sampleable_functor.sample F (sampleable_ext.sample α),\n  shrink := sampleable_functor.shrink _ sampleable_ext.shrink,\n  p_repr := sampleable_functor.p_repr _ sampleable_ext.p_repr\n  }\n\ninstance sampleable_ext.bifunctor {α β} {F} [bifunctor F] [sampleable_bifunctor F]\n  [sampleable_ext α] [sampleable_ext β] : sampleable_ext (F α β) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr α) (proxy_repr β),\n  interp := bifunctor.bimap (interp _) (interp _),\n  sample := sampleable_bifunctor.sample F (sampleable_ext.sample α) (sampleable_ext.sample β),\n  shrink := sampleable_bifunctor.shrink _ _ sampleable_ext.shrink sampleable_ext.shrink,\n  p_repr := sampleable_bifunctor.p_repr _ _ sampleable_ext.p_repr sampleable_ext.p_repr\n  }\n\nend prio\n\n/-- `nat.shrink' k n` creates a list of smaller natural numbers by\nsuccessively dividing `n` by 2 and subtracting the difference from\n`k`. For example, `nat.shrink 100 = [50, 75, 88, 94, 97, 99]`. -/\ndef nat.shrink' (k : ℕ) : Π n : ℕ, n ≤ k →\n  list { m : ℕ // has_well_founded.r m k } → list { m : ℕ // has_well_founded.r m k }\n| n hn ls :=\nif h : n ≤ 1\n  then ls.reverse\n  else\n    have h₂ : 0 < n, by linarith,\n    have 1 * n / 2 < n,\n      from nat.div_lt_of_lt_mul (nat.mul_lt_mul_of_pos_right (by norm_num) h₂),\n    have n / 2 < n, by simpa,\n    let m := n / 2 in\n    have h₀ : m ≤ k, from le_trans (le_of_lt this) hn,\n    have h₃ : 0 < m,\n      by simp only [m, lt_iff_add_one_le, zero_add]; rw [le_div_iff_mul_le]; linarith,\n    have h₁ : k - m < k,\n      from nat.sub_lt (lt_of_lt_of_le h₂ hn) h₃,\n    nat.shrink' m h₀ (⟨k - m, h₁⟩ :: ls)\n\n/-- `nat.shrink n` creates a list of smaller natural numbers by\nsuccessively dividing by 2 and subtracting the difference from\n`n`. For example, `nat.shrink 100 = [50, 75, 88, 94, 97, 99]`. -/\ndef nat.shrink (n : ℕ) : list { m : ℕ // has_well_founded.r m n } :=\nif h : n > 0 then\n  have ∀ k, 1 < k → n / k < n, from\n    λ k hk,\n     nat.div_lt_of_lt_mul\n       (suffices 1 * n < k * n, by simpa,\n        nat.mul_lt_mul_of_pos_right hk h),\n  ⟨n/11, this _ (by norm_num)⟩ :: ⟨n/3, this _ (by norm_num)⟩ :: nat.shrink' n n (le_refl _) []\nelse\n  []\n\nopen gen\n\n/--\nTransport a `sampleable` instance from a type `α` to a type `β` using\nfunctions between the two, going in both directions.\n\nFunction `g` is used to define the well-founded order that\n`shrink` is expected to follow.\n-/\ndef sampleable.lift (α : Type u) {β : Type u} [sampleable α] (f : α → β) (g : β → α)\n  (h : ∀ (a : α), sizeof (g (f a)) ≤ sizeof a) : sampleable β :=\n{ wf := ⟨ sizeof ∘ g ⟩,\n  sample := f <$> sample α,\n  shrink := λ x,\n    have ∀ a,  sizeof a < sizeof (g x) → sizeof (g (f a)) < sizeof (g x),\n      by introv h'; solve_by_elim [lt_of_le_of_lt],\n    subtype.map f this <$> shrink (g x) }\n\ninstance nat.sampleable : sampleable ℕ :=\n{ sample := sized $ λ sz, freq [(1, coe <$> choose_any (fin $ succ (sz^3))),\n                                (3, coe <$> choose_any (fin $ succ sz))] dec_trivial,\n  shrink :=  λ x, lazy_list.of_list $ nat.shrink x }\n\n/-- `iterate_shrink p x` takes a decidable predicate `p` and a\nvalue `x` of some sampleable type and recursively shrinks `x`.\nIt first calls `shrink x` to get a list of candidate sample,\nfinds the first that satisfies `p` and recursively tries\nto shrink that one. -/\ndef iterate_shrink {α} [has_to_string α] [sampleable α]\n  (p : α → Prop) [decidable_pred p] :\n  α → option α :=\nwell_founded.fix has_well_founded.wf $ λ x f_rec,\n  do trace sformat!\"{x} : {(shrink x).to_list}\" $ pure (),\n     y ← (shrink x).find (λ a, p a),\n     f_rec y y.property <|> some y.val .\n\ninstance fin.sampleable {n} [fact $ 0 < n] : sampleable (fin n) :=\nsampleable.lift ℕ fin.of_nat' subtype.val $\nλ i, (mod_le _ _ : i % n ≤ i)\n\n@[priority 100]\ninstance fin.sampleable' {n} : sampleable (fin (succ n)) :=\nsampleable.lift ℕ fin.of_nat subtype.val $\nλ i, (mod_le _ _ : i % succ n ≤ i)\n\ninstance pnat.sampleable : sampleable ℕ+ :=\nsampleable.lift ℕ nat.succ_pnat pnat.nat_pred $ λ a,\nby unfold_wf; simp only [pnat.nat_pred, succ_pnat, pnat.mk_coe, nat.sub_zero, succ_sub_succ_eq_sub]\n\n/-- Redefine `sizeof` for `int` to make it easier to use with `nat` -/\ndef int.has_sizeof : has_sizeof ℤ := ⟨ int.nat_abs ⟩\n\nlocal attribute [instance, priority 2000] int.has_sizeof\n\ninstance int.sampleable : sampleable ℤ :=\n{ wf := _,\n  sample := sized $ λ sz,\n          freq [(1, subtype.val <$> choose (-(sz^3 + 1) : ℤ) (sz^3 + 1) (neg_le_self dec_trivial)),\n                (3, subtype.val <$> choose (-(sz + 1)) (sz + 1) (neg_le_self dec_trivial))]\n               dec_trivial,\n  shrink :=\n    λ x, lazy_list.of_list $ (nat.shrink $ int.nat_abs x).bind $\n    λ ⟨y,h⟩, [⟨y, h⟩, ⟨-y, by dsimp [sizeof,has_sizeof.sizeof]; rw int.nat_abs_neg; exact h ⟩] }\n\ninstance bool.sampleable : sampleable bool :=\n{ wf := ⟨ λ b, if b then 1 else 0 ⟩,\n  sample := do { x ← choose_any bool,\n                 return x },\n  shrink := λ b, if h : b then lazy_list.singleton ⟨ff, by cases h; unfold_wf⟩\n                          else lazy_list.nil }\n\n/--\nProvided two shrinking functions `prod.shrink` shrinks a pair `(x, y)` by\nfirst shrinking `x` and pairing the results with `y` and then shrinking\n`y` and pairing the results with `x`.\n\nAll pairs either contain `x` untouched or `y` untouched. We rely on\nshrinking being repeated for `x` to get maximally shrunken and then\nfor `y` to get shrunken too.\n-/\ndef prod.shrink {α β} [has_sizeof α] [has_sizeof β]\n  (shr_a : shrink_fn α) (shr_b : shrink_fn β) : shrink_fn (α × β)\n| ⟨x₀,x₁⟩ :=\n  let xs₀ : lazy_list { y : α × β // sizeof_lt y (x₀,x₁) } :=\n          (shr_a x₀).map $ subtype.map (λ a, (a, x₁))\n                           (λ x h, by dsimp [sizeof_lt]; unfold_wf; apply h),\n      xs₁ : lazy_list { y : α × β // sizeof_lt y (x₀,x₁) } :=\n          (shr_b x₁).map $ subtype.map (λ a, (x₀, a))\n                           (λ x h, by dsimp [sizeof_lt]; unfold_wf; apply h) in\n  xs₀.append xs₁\n\ninstance prod.sampleable : sampleable_bifunctor.{u v} prod :=\n{ wf := _,\n  sample := λ α β sama samb, do\n              { ⟨x⟩ ← (uliftable.up $ sama : gen (ulift.{max u v} α)),\n                ⟨y⟩ ← (uliftable.up $ samb : gen (ulift.{max u v} β)),\n                pure (x,y) },\n  shrink := @prod.shrink,\n  p_repr := @prod.has_repr }\n\ninstance sigma.sampleable {α β} [sampleable α] [sampleable β] : sampleable (Σ _ : α, β) :=\nsampleable.lift (α × β) (λ ⟨x,y⟩, ⟨x,y⟩) (λ ⟨x,y⟩, ⟨x,y⟩) $ λ ⟨x,y⟩, le_refl _\n\n/-- shrinking function for sum types -/\ndef sum.shrink {α β} [has_sizeof α] [has_sizeof β] (shrink_α : shrink_fn α)\n  (shrink_β : shrink_fn β) : shrink_fn (α ⊕ β)\n| (sum.inr x) := (shrink_β x).map $ subtype.map sum.inr $ λ a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n| (sum.inl x) := (shrink_α x).map $ subtype.map sum.inl $ λ a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n\ninstance sum.sampleable : sampleable_bifunctor.{u v} sum :=\n{ wf := _,\n  sample := λ (α : Type u) (β : Type v) sam_α sam_β,\n            (@uliftable.up_map gen.{u} gen.{max u v} _ _ _ _ (@sum.inl α β) sam_α <|>\n             @uliftable.up_map gen.{v} gen.{max v u} _ _ _ _ (@sum.inr α β) sam_β),\n  shrink := λ α β Iα Iβ shr_α shr_β, @sum.shrink _ _ Iα Iβ shr_α shr_β,\n  p_repr := @sum.has_repr }\n\ninstance rat.sampleable : sampleable ℚ :=\nsampleable.lift (ℤ × ℕ+) (λ x, prod.cases_on x rat.mk_pnat) (λ r, (r.num, ⟨r.denom, r.pos⟩)) $\nbegin\n  intro i,\n  rcases i with ⟨x,⟨y,hy⟩⟩; unfold_wf;\n  dsimp [rat.mk_pnat],\n  mono*,\n  { rw [← int.coe_nat_le, ← int.abs_eq_nat_abs, ← int.abs_eq_nat_abs],\n    apply int.abs_div_le_abs },\n  { change _ - 1 ≤ y-1,\n    apply nat.sub_le_sub_right,\n    apply nat.div_le_of_le_mul,\n    suffices : 1 * y ≤ x.nat_abs.gcd y * y, { simpa },\n    apply nat.mul_le_mul_right,\n    apply gcd_pos_of_pos_right _ hy }\nend\n\n/-- `sampleable_char` can be specialized into customized `sampleable char` instances.\n\nThe resulting instance has `1 / length` chances of making an unrestricted choice of characters\nand it otherwise chooses a character from `characters` with uniform probabilities.  -/\ndef sampleable_char (length : nat) (characters : string) : sampleable char :=\n{ sample := do { x ← choose_nat 0 length dec_trivial,\n                 if x.val = 0 then do\n                   n ← sample ℕ,\n                   pure $ char.of_nat n\n                 else do\n                   i ← choose_nat 0 (characters.length - 1) dec_trivial,\n                   pure (characters.mk_iterator.nextn i).curr },\n  shrink := λ _, lazy_list.nil }\n\ninstance char.sampleable : sampleable char :=\nsampleable_char 3 \" 0123abcABC:,;`\\\\/\"\n\nvariables {α}\n\nsection list_shrink\n\nvariables [has_sizeof α] (shr : Π x : α, lazy_list { y : α // sizeof_lt y x })\n\n\n\nlemma list.sizeof_cons_lt_right (a b : α) {xs : list α} (h : sizeof a < sizeof b) :\n  sizeof (a :: xs) < sizeof (b :: xs) :=\nby unfold_wf; assumption\n\nlemma list.sizeof_cons_lt_left (x : α) {xs xs' : list α} (h : sizeof xs < sizeof xs') :\n  sizeof (x :: xs) < sizeof (x :: xs') :=\nby unfold_wf; assumption\n\nlemma list.sizeof_append_lt_left {xs ys ys' : list α} (h : sizeof ys < sizeof ys') :\n  sizeof (xs ++ ys) < sizeof (xs ++ ys') :=\nbegin\n  induction xs,\n  { apply h },\n  { unfold_wf,\n    simp only [list.sizeof, add_lt_add_iff_left],\n    exact xs_ih }\nend\n\nlemma list.one_le_sizeof (xs : list α) : 1 ≤ sizeof xs :=\nby cases xs; unfold_wf; [refl, linarith]\n\n/--\n`list.shrink_removes` shrinks a list by removing chunks of size `k` in\nthe middle of the list.\n-/\ndef list.shrink_removes (k : ℕ) (hk : 0 < k) : Π (xs : list α) n,\n  n = xs.length → lazy_list { ys : list α // sizeof_lt ys xs }\n| xs n hn :=\n  if hkn : k > n then lazy_list.nil\n  else\n  if hkn' : k = n then\n    have 1 < xs.sizeof,\n      by { subst_vars, cases xs, { contradiction },\n           unfold_wf, apply lt_of_lt_of_le,\n           show 1 < 1 + has_sizeof.sizeof xs_hd + 1, { linarith },\n           { mono, apply list.one_le_sizeof, } },\n    lazy_list.singleton ⟨[], this ⟩\n  else\n    have h₂ : k < xs.length, from hn ▸ lt_of_le_of_ne (le_of_not_gt hkn) hkn',\n    match list.split_at k xs, rfl : Π ys, ys = list.split_at k xs → _ with\n    |  ⟨xs₁,xs₂⟩, h :=\n      have h₄ : xs₁ = xs.take k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have h₃ : xs₂ = xs.drop k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have sizeof xs₂ < sizeof xs,\n        by rw h₃; solve_by_elim [list.sizeof_drop_lt_sizeof_of_lt_length],\n      have h₁ : n - k = xs₂.length,\n        by simp only [h₃, ←hn, list.length_drop],\n      have h₅ : ∀ (a : list α), sizeof_lt a xs₂ → sizeof_lt (xs₁ ++ a) xs,\n        by intros a h; rw [← list.take_append_drop k xs, ← h₃, ← h₄];\n          solve_by_elim [list.sizeof_append_lt_left],\n      lazy_list.cons ⟨xs₂, this⟩ $ subtype.map ((++) xs₁) h₅ <$> list.shrink_removes xs₂ (n - k) h₁\n    end\n\n/--\n`list.shrink_one xs` shrinks list `xs` by shrinking only one item in\nthe list.\n-/\ndef list.shrink_one : shrink_fn (list α)\n| [] := lazy_list.nil\n| (x :: xs) :=\n  lazy_list.append\n    (subtype.map (λ x', x' :: xs) (λ a,  list.sizeof_cons_lt_right _ _) <$> shr x)\n    (subtype.map ((::) x) (λ _, list.sizeof_cons_lt_left _) <$> list.shrink_one xs)\n\n\n/-- `list.shrink_with shrink_f xs` shrinks `xs` by first\nconsidering `xs` with chunks removed in the middle (starting with\nchunks of size `xs.length` and halving down to `1`) and then\nshrinks only one element of the list.\n\nThis strategy is taken directly from Haskell's QuickCheck -/\ndef list.shrink_with (xs : list α) :\n  lazy_list { ys : list α // sizeof_lt ys xs } :=\nlet n := xs.length in\nlazy_list.append\n  ((lazy_list.cons n $ (shrink n).reverse.map subtype.val).bind (λ k,\n    if hk : 0 < k\n    then list.shrink_removes k hk xs n rfl\n    else lazy_list.nil ))\n  (list.shrink_one shr _)\n\nend list_shrink\n\ninstance list.sampleable : sampleable_functor list.{u} :=\n{ wf := _,\n  sample := λ α sam_α, list_of sam_α,\n  shrink := λ α Iα shr_α, @list.shrink_with _ Iα shr_α,\n  p_repr := @list.has_repr }\n\ninstance prop.sampleable_ext : sampleable_ext Prop :=\n{ proxy_repr := bool,\n  interp := coe,\n  sample := choose_any bool,\n  shrink := λ _, lazy_list.nil }\n\n/-- `no_shrink` is a type annotation to signal that\na certain type is not to be shrunk. It can be useful in\ncombination with other types: e.g. `xs : list (no_shrink ℤ)`\nwill result in the list being cut down but individual\nintegers being kept as is. -/\ndef no_shrink (α : Type*) := α\n\ninstance no_shrink.inhabited {α} [inhabited α] : inhabited (no_shrink α) :=\n⟨ (default α : α) ⟩\n\n/-- Introduction of the `no_shrink` type. -/\ndef no_shrink.mk {α} (x : α) : no_shrink α := x\n\n/-- Selector of the `no_shrink` type. -/\ndef no_shrink.get {α} (x : no_shrink α) : α := x\n\ninstance no_shrink.sampleable {α} [sampleable α] : sampleable (no_shrink α) :=\n{ sample := no_shrink.mk <$> sample α }\n\ninstance string.sampleable : sampleable string :=\n{ sample := do { x ← list_of (sample char), pure x.as_string },\n  .. sampleable.lift (list char) list.as_string string.to_list $ λ _, le_refl _ }\n\n/-- implementation of `sampleable (tree α)` -/\ndef tree.sample (sample : gen α) : ℕ → gen (tree α) | n :=\nif h : n > 0\nthen have n / 2 < n, from div_lt_self h (by norm_num),\n     tree.node <$> sample <*> tree.sample (n / 2) <*> tree.sample (n / 2)\nelse pure tree.nil\n\n/-- `rec_shrink x f_rec` takes the recursive call `f_rec` introduced\nby `well_founded.fix` and turns it into a shrinking function whose\nresult is adequate to use in a recursive call. -/\ndef rec_shrink {α : Type*} [has_sizeof α] (t : α)\n  (sh : Π x : α, sizeof_lt x t → lazy_list { y : α // sizeof_lt y x }) :\n  shrink_fn { t' : α // sizeof_lt t' t }\n| ⟨t',ht'⟩ := (λ t'' : { y : α // sizeof_lt y t' },\n    ⟨⟨t''.val, lt_trans t''.property ht'⟩, t''.property⟩ ) <$> sh t' ht'\n\nlemma tree.one_le_sizeof {α} [has_sizeof α] (t : tree α) : 1 ≤ sizeof t :=\nby cases t; unfold_wf; linarith\n\ninstance : functor tree :=\n{ map := @tree.map }\n\n/--\nRecursion principle for shrinking tree-like structures.\n-/\ndef rec_shrink_with [has_sizeof α]\n  (shrink_a : Π x : α, shrink_fn { y : α // sizeof_lt y x } →\n    list (lazy_list { y : α // sizeof_lt y x })) :\n  shrink_fn α :=\nwell_founded.fix (sizeof_measure_wf _) $ λ t f_rec,\nlazy_list.join\n    (lazy_list.of_list $\n      shrink_a t $ λ ⟨t', h⟩, rec_shrink _ f_rec _)\n\nlemma rec_shrink_with_eq [has_sizeof α]\n  (shrink_a : Π x : α, shrink_fn { y : α // sizeof_lt y x } →\n    list (lazy_list { y : α // sizeof_lt y x }))\n  (x : α) :\n  rec_shrink_with shrink_a x =\n  lazy_list.join\n    (lazy_list.of_list $ shrink_a x $ λ t', rec_shrink _ (λ x h', rec_shrink_with shrink_a x) _) :=\nbegin\n  conv_lhs { rw [rec_shrink_with, well_founded.fix_eq], },\n  congr, ext ⟨y, h⟩, refl\nend\n\n/-- `tree.shrink_with shrink_f t` shrinks `xs` by using the empty tree,\neach subtrees, and by shrinking the subtree to recombine them.\n\nThis strategy is taken directly from Haskell's QuickCheck -/\ndef tree.shrink_with [has_sizeof α] (shrink_a : shrink_fn α) : shrink_fn (tree α) :=\nrec_shrink_with $ λ t,\nmatch t with\n| tree.nil := λ f_rec, []\n| (tree.node x t₀ t₁) :=\nλ f_rec,\n  have h₂ : sizeof_lt tree.nil (tree.node x t₀ t₁),\n    by clear _match; have := tree.one_le_sizeof t₀;\n       dsimp [sizeof_lt, sizeof, has_sizeof.sizeof] at *;\n       unfold_wf; linarith,\n  have h₀ : sizeof_lt t₀ (tree.node x t₀ t₁),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  have h₁ : sizeof_lt t₁ (tree.node x t₀ t₁),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  [lazy_list.of_list [⟨tree.nil, h₂⟩, ⟨t₀, h₀⟩, ⟨t₁, h₁⟩],\n   (prod.shrink shrink_a (prod.shrink f_rec f_rec) (x, ⟨t₀, h₀⟩, ⟨t₁, h₁⟩)).map\n    $ λ ⟨⟨y,⟨t'₀, _⟩,⟨t'₁, _⟩⟩,hy⟩, ⟨tree.node y t'₀ t'₁,\n      by revert hy; dsimp [sizeof_lt]; unfold_wf; intro; linarith⟩]\nend\n\ninstance sampleable_tree : sampleable_functor tree :=\n{ wf := _,\n  sample := λ α sam_α, sized $ tree.sample sam_α,\n  shrink := λ α Iα shr_α, @tree.shrink_with _ Iα shr_α,\n  p_repr := @tree.has_repr }\n\n/-- Type tag that signals to `slim_check` to use small values for a given type. -/\ndef small (α : Type*) := α\n\n/-- Add the `small` type tag -/\ndef small.mk {α} (x : α) : small α := x\n\n/-- Type tag that signals to `slim_check` to use large values for a given type. -/\ndef large (α : Type*) := α\n\n/-- Add the `large` type tag -/\ndef large.mk {α} (x : α) : large α := x\n\ninstance small.functor : functor small := id.monad.to_functor\ninstance large.functor : functor large := id.monad.to_functor\ninstance small.inhabited [inhabited α] : inhabited (small α) := ⟨ (default α : α) ⟩\ninstance large.inhabited [inhabited α] : inhabited (large α) := ⟨ (default α : α) ⟩\n\ninstance small.sampleable_functor : sampleable_functor small :=\n{ wf := _,\n  sample := λ α samp, gen.resize (λ n, n / 5 + 5) samp,\n  shrink := λ α _, id,\n  p_repr := λ α, id }\n\ninstance large.sampleable_functor : sampleable_functor large :=\n{ wf := _,\n  sample := λ α samp, gen.resize (λ n, n * 5) samp,\n  shrink := λ α _, id,\n  p_repr := λ α, id }\n\ninstance ulift.sampleable_functor : sampleable_functor ulift.{u v} :=\n{ wf := λ α h, ⟨ λ ⟨x⟩, @sizeof α h x ⟩,\n  sample := λ α samp, uliftable.up_map ulift.up $ samp,\n  shrink := λ α _ shr ⟨x⟩, (shr x).map (subtype.map ulift.up (λ a h, h)),\n  p_repr := λ α h, ⟨ @repr α h ∘ ulift.down ⟩ }\n\n/-!\n## Subtype instances\n\nThe following instances are meant to improve the testing of properties of the form\n`∀ i j, i ≤ j, ...`\n\nThe naive way to test them is to choose two numbers `i` and `j` and check that\nthe proper ordering is satisfied. Instead, the following instances make it\nso that `j` will be chosen with considerations to the required ordering\nconstraints. The benefit is that we will not have to discard any choice\nof `j`.\n -/\n\n/-! ### Subtypes of `ℕ` -/\n\ninstance nat_le.sampleable {y} : slim_check.sampleable { x : ℕ // x ≤ y } :=\n{ sample :=\n         do { ⟨x,h⟩ ← slim_check.gen.choose_nat 0 y dec_trivial,\n              pure ⟨x, h.2⟩},\n  shrink := λ ⟨x, h⟩, (λ a : subtype _, subtype.rec_on a $\n    λ x' h', ⟨⟨x', le_trans (le_of_lt h') h⟩, h'⟩) <$> shrink x }\n\ninstance nat_ge.sampleable {x} : slim_check.sampleable { y : ℕ // x ≤ y } :=\n{ sample :=\n         do { (y : ℕ) ← slim_check.sampleable.sample ℕ,\n              pure ⟨x+y, by norm_num⟩ },\n  shrink := λ ⟨y, h⟩, (λ a : { y' // sizeof y' < sizeof (y - x) },\n    subtype.rec_on a $ λ δ h', ⟨⟨x + δ, nat.le_add_right _ _⟩, nat.add_lt_of_lt_sub_left h'⟩) <$>\n      shrink (y - x) }\n\n/- there is no `nat_lt.sampleable` instance because if `y = 0`, there is no valid choice\nto satisfy `x < y` -/\n\ninstance nat_gt.sampleable {x} : slim_check.sampleable { y : ℕ // x < y } :=\n{ sample :=\n         do { (y : ℕ) ← slim_check.sampleable.sample ℕ,\n              pure ⟨x+y+1, by linarith⟩ },\n  shrink := λ x, shrink _ }\n\n/-! ### Subtypes of any `linear_ordered_add_comm_group` -/\n\ninstance le.sampleable {y : α} [sampleable α] [linear_ordered_add_comm_group α] :\n  slim_check.sampleable { x : α // x ≤ y } :=\n{ sample :=\n         do { x ← sample α,\n              pure ⟨y - abs x, sub_le_self _ (abs_nonneg _) ⟩ },\n  shrink := λ _, lazy_list.nil }\n\ninstance ge.sampleable {x : α}  [sampleable α] [linear_ordered_add_comm_group α] :\n  slim_check.sampleable { y : α // x ≤ y } :=\n{ sample :=\n         do { y ← sample α,\n              pure ⟨x + abs y, by norm_num [abs_nonneg]⟩ },\n  shrink := λ _, lazy_list.nil }\n\n\n/-!\n### Subtypes of `ℤ`\n\nSpecializations of `le.sampleable` and `ge.sampleable` for `ℤ` to help instance search.\n-/\n\ninstance int_le.sampleable {y : ℤ} : slim_check.sampleable { x : ℤ // x ≤ y } :=\nsampleable.lift ℕ (λ n, ⟨y - n, int.sub_left_le_of_le_add $ by simp⟩) (λ ⟨i, h⟩, (y - i).nat_abs)\n  (λ n, by unfold_wf; simp [int_le.sampleable._match_1]; ring)\n\ninstance int_ge.sampleable {x : ℤ} : slim_check.sampleable { y : ℤ // x ≤ y } :=\nsampleable.lift ℕ (λ n, ⟨x + n, by simp⟩) (λ ⟨i, h⟩, (i - x).nat_abs)\n  (λ n, by unfold_wf; simp [int_ge.sampleable._match_1]; ring)\n\ninstance int_lt.sampleable {y} : slim_check.sampleable { x : ℤ // x < y } :=\nsampleable.lift ℕ (λ n, ⟨y - (n+1), int.sub_left_lt_of_lt_add $\n    by linarith [int.coe_nat_nonneg n]⟩)\n  (λ ⟨i, h⟩, (y - i - 1).nat_abs)\n  (λ n, by unfold_wf; simp [int_lt.sampleable._match_1]; ring)\n\ninstance int_gt.sampleable {x} : slim_check.sampleable { y : ℤ // x < y } :=\nsampleable.lift ℕ (λ n, ⟨x + (n+1), by linarith⟩) (λ ⟨i, h⟩, (i - x - 1).nat_abs)\n  (λ n, by unfold_wf; simp [int_gt.sampleable._match_1]; ring)\n\n/-! ### Subtypes of any `list` -/\n\ninstance perm.slim_check {xs : list α} : slim_check.sampleable { ys : list α // list.perm xs ys } :=\n{ sample := permutation_of xs,\n  shrink := λ _, lazy_list.nil }\n\ninstance perm'.slim_check {xs : list α} :\n  slim_check.sampleable { ys : list α // list.perm ys xs } :=\n{ sample := subtype.map id (@list.perm.symm α _) <$> permutation_of xs,\n  shrink := λ _, lazy_list.nil }\n\nsetup_tactic_parser\nopen tactic\n\n/--\nPrint (at most) 10 samples of a given type to stdout for debugging.\n-/\ndef print_samples {t : Type u} [has_repr t] (g : gen t) : io unit := do\nxs ← io.run_rand $ uliftable.down $\n  do { xs ← (list.range 10).mmap $ g.run ∘ ulift.up,\n       pure ⟨xs.map repr⟩ },\nxs.mmap' io.put_str_ln\n\n/-- Create a `gen α` expression from the argument of `#sample` -/\nmeta def mk_generator (e : expr) : tactic (expr × expr) := do\nt ← infer_type e,\nmatch t with\n| `(gen %%t) := do\n  repr_inst ← mk_app ``has_repr [t] >>= mk_instance,\n  pure (repr_inst, e)\n| _ := do\n  samp_inst ← to_expr ``(sampleable_ext %%e) >>= mk_instance,\n  repr_inst ← mk_mapp ``sampleable_ext.p_repr [e, samp_inst],\n  gen ← mk_mapp ``sampleable_ext.sample [none, samp_inst],\n  pure (repr_inst, gen)\nend\n\n/--\n`#sample my_type`, where `my_type` has an instance of `sampleable`, prints ten random\nvalues of type `my_type` of using an increasing size parameter.\n\n```lean\n#sample nat\n-- prints\n-- 0\n-- 0\n-- 2\n-- 24\n-- 64\n-- 76\n-- 5\n-- 132\n-- 8\n-- 449\n-- or some other sequence of numbers\n\n#sample list int\n-- prints\n-- []\n-- [1, 1]\n-- [-7, 9, -6]\n-- [36]\n-- [-500, 105, 260]\n-- [-290]\n-- [17, 156]\n-- [-2364, -7599, 661, -2411, -3576, 5517, -3823, -968]\n-- [-643]\n-- [11892, 16329, -15095, -15461]\n-- or whatever\n```\n-/\n@[user_command]\nmeta def sample_cmd (_ : parse $ tk \"#sample\") : lean.parser unit :=\ndo e ← texpr,\n   of_tactic $ do\n     e ← i_to_expr e,\n     (repr_inst, gen) ← mk_generator e,\n     print_samples ← mk_mapp ``print_samples [none, repr_inst, gen],\n     sample ← eval_expr (io unit) print_samples,\n     unsafe_run_io sample\n\nend slim_check\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/testing/slim_check/sampleable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.452029913721306}}
{"text": "/-\nCopyright (c) 2020 Patrick Massot. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Patrick Massot\n-/\nimport analysis.specific_limits\n\n/-!\n# Hofer's lemma\n\nThis is an elementary lemma about complete metric spaces. It is motivated by an\napplication to the bubbling-off analysis for holomorphic curves in symplectic topology.\nWe are *very* far away from having these applications, but the proof here is a nice\nexample of a proof needing to construct a sequence by induction in the middle of the proof.\n\n## References:\n\n* H. Hofer and C. Viterbo, *The Weinstein conjecture in the presence of holomorphic spheres*\n-/\n\nopen_locale classical topological_space big_operators\nopen filter finset\n\nlocal notation `d` := dist\n\nlemma hofer {X: Type*} [metric_space X] [complete_space X]\n  (x : X) (ε : ℝ) (ε_pos : 0 < ε)\n  {ϕ : X → ℝ} (cont : continuous ϕ) (nonneg : ∀ y, 0 ≤ ϕ y) :\n  ∃ (ε' > 0) (x' : X), ε' ≤ ε ∧\n                       d x' x ≤ 2*ε ∧\n                       ε * ϕ(x) ≤ ε' * ϕ x' ∧\n                       ∀ y, d x' y ≤ ε' → ϕ y ≤ 2*ϕ x' :=\nbegin\n  by_contradiction H,\n  have reformulation : ∀ x' (k : ℕ), ε * ϕ x ≤ ε / 2 ^ k * ϕ x' ↔ 2^k * ϕ x ≤ ϕ x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left ε_pos, mul_comm],\n    exact pow_pos (by norm_num) k, },\n  -- Now let's specialize to `ε/2^k`\n  replace H : ∀ k : ℕ, ∀ x', d x' x ≤ 2 * ε ∧ 2^k * ϕ x ≤ ϕ x' →\n    ∃ y, d x' y ≤ ε/2^k ∧ 2 * ϕ x' < ϕ y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using\n      H (ε/2^k) (by simp [ε_pos, zero_lt_two]) x' (by simp [ε_pos, zero_lt_two, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := ⟨x⟩,\n  choose! F hF using H,  -- Use the axiom of choice\n  -- Now define u by induction starting at x, with u_{n+1} = F(n, u_n)\n  let u : ℕ → X := λ n, nat.rec_on n x F,\n  have hu0 : u 0 = x := rfl,\n  -- The properties of F translate to properties of u\n  have hu :\n    ∀ n,\n      d (u n) x ≤ 2 * ε ∧ 2^n * ϕ x ≤ ϕ (u n) →\n      d (u n) (u $ n + 1) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u $ n + 1),\n  { intro n,\n    exact hF n (u n) },\n  clear hF,\n  -- Key properties of u, to be proven by induction\n  have key : ∀ n, d (u n) (u (n + 1)) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u (n + 1)),\n  { intro n,\n    induction n using nat.case_strong_induction_on with n IH,\n    { specialize hu 0,\n      simpa [hu0, mul_nonneg_iff, zero_le_one, ε_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x ≤ 2 * ε,\n    { rw [dist_comm],\n      let r := range (n+1), -- range (n+1) = {0, ..., n}\n      calc\n      d (u 0) (u (n + 1))\n          ≤ ∑ i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... ≤ ∑ i in r, ε/2^i             : sum_le_sum (λ i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = ∑ i in r, (1/2)^i*ε         : by { congr' with i, field_simp }\n      ... = (∑ i in r, (1/2)^i)*ε       : finset.sum_mul.symm\n      ... ≤ 2*ε                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt ε_pos), },\n    have B : 2^(n+1) * ϕ x ≤ ϕ (u (n + 1)),\n    { refine @geom_le (ϕ ∘ u) _ zero_le_two (n + 1) (λ m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) ⟨A, B⟩, },\n  cases forall_and_distrib.mp key with key₁ key₂,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ ε one_half_lt_one (λ n, _),\n    simpa only [one_div, inv_pow₀] using key₁ n },\n  -- So u converges to some y\n  obtain ⟨y, limy⟩ : ∃ y, tendsto u at_top (𝓝 y),\n    from complete_space.complete cauchy_u,\n  -- And ϕ ∘ u goes to +∞\n  have lim_top : tendsto (ϕ ∘ u) at_top at_top,\n  { let v := λ n, (ϕ ∘ u) (n+1),\n    suffices : tendsto v at_top at_top,\n      by rwa tendsto_add_at_top_iff_nat at this,\n    have hv₀ : 0 < v 0,\n    { have : 0 ≤ ϕ (u 0) := nonneg x,\n      calc 0 ≤ 2 * ϕ (u 0) : by linarith\n      ... < ϕ (u (0 + 1)) : key₂ 0 },\n    apply tendsto_at_top_of_geom_le hv₀ one_lt_two,\n    exact λ n, (key₂ (n+1)).le },\n  -- But ϕ ∘ u also needs to go to ϕ(y)\n  have lim : tendsto (ϕ ∘ u) at_top (𝓝 (ϕ y)),\n    from tendsto.comp cont.continuous_at limy,\n  -- So we have our contradiction!\n  exact not_tendsto_at_top_of_tendsto_nhds lim lim_top,\nend\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/analysis/hofer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6723316991792861, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.45202990930710907}}
{"text": "import order.filter.at_top_bot\nimport o_minimal.o_minimal\n\n-- More facts about tame sets.\n\nopen o_minimal\n\nvariables {R : Type*} [DUNLO R]\n\nlemma ball_or {α : Type*} (p q r : α → Prop) :\n  (∀ a, (p a ∨ q a) → r a) ↔ (∀ a, p a → r a) ∧ (∀ a, q a → r a) :=\n⟨λ H, ⟨λ a h, H a (or.inl h), λ a h, H a (or.inr h)⟩,\n λ H a o, o.cases_on (H.1 a) (H.2 a)⟩\n\nlemma exists_tInf {s : set R} (ts : tame s) (ne : s.nonempty) (bdd : bdd_below s) :\n  ∃ m, is_glb s m :=\nbegin\n  revert ne bdd,\n  refine tame.induction _ _ ts; clear ts s,\n  { rintro ⟨_, ⟨⟩⟩ },\n  { rintros s i hi IH - bdd,    -- `ne` can never be useful at this point.\n    have bdd' : bdd_below s := bdd.mono (by simp),\n    induction hi with r a b a b hab; clear i,\n    -- We used `induction` because `cases` does too much unfolding.\n    -- Unfortunately `induction` does not generate `case` tags.\n    -- In two cases, the new set is obviously not bounded below;\n    -- dispose of those first.\n    -- TODO: Make these two cases lemmas (for `order.bounds`).\n    swap 2,                     -- Iii\n    { exfalso,\n      rcases bdd with ⟨z, hz⟩,\n      obtain ⟨y, hy : y < z⟩ := no_bot z,\n      exact not_le_of_lt hy (hz (by simp)) },\n    swap 3,                     -- Iio\n    { exfalso,\n      rcases bdd with ⟨z, hz⟩,\n      obtain ⟨c, hc : c < b⟩ := no_bot b,\n      obtain ⟨y, hy : y < min c z⟩ := no_bot (min c z),\n      refine not_le_of_lt (lt_of_lt_of_le hy (min_le_right _ _)) (hz (or.inl _)),\n      calc y < min c z : hy\n       ...   ≤ c       : min_le_left _ _\n       ...   < b       : hc },\n    -- In the remaining goals we'll do case analysis on whether\n    -- `s` is empty (and thus can be ignored) or nonempty (and thus we can use IH).\n    all_goals {\n      clear bdd,\n      rcases set.eq_empty_or_nonempty s with rfl|ne';\n      [ { clear IH bdd', simp only [set.union_empty] },\n        { specialize IH ne' bdd', clear ne' bdd', cases IH with l IH }] },\n    { exact ⟨_, is_glb_singleton⟩ },\n    { exact ⟨_, is_glb.union is_glb_singleton IH⟩ },\n    { exact ⟨_, is_glb_Ioi⟩ },\n    { exact ⟨_, is_glb.union is_glb_Ioi IH⟩ },\n    { exact ⟨_, is_glb_Ioo hab⟩ },\n    { exact ⟨_, is_glb.union (is_glb_Ioo hab) IH⟩ } }\nend\n\n-- TODO: Make this not a copy&paste of above.\nlemma exists_tSup {s : set R} (ts : tame s) (ne : s.nonempty) (bdd : bdd_above s) :\n  ∃ m, is_lub s m :=\nbegin\n  revert ne bdd,\n  refine tame.induction _ _ ts; clear ts s,\n  { rintro ⟨_, ⟨⟩⟩ },\n  { rintros s i hi IH - bdd,    -- `ne` can never be useful at this point.\n    have bdd' : bdd_above s := bdd.mono (by simp),\n    induction hi with r a b a b hab; clear i,\n    -- We used `induction` because `cases` does too much unfolding.\n    -- Unfortunately `induction` does not generate `case` tags.\n    -- In two cases, the new set is obviously not bounded above;\n    -- dispose of those first.\n    -- TODO: Make these two cases lemmas (for `order.bounds`).\n    swap 2,                     -- Iii\n    { exfalso,\n      rcases bdd with ⟨z, hz⟩,\n      obtain ⟨y, hy : y > z⟩ := no_top z,\n      exact not_le_of_lt hy (hz (by simp)) },\n    swap 2,                     -- Ioi\n    { exfalso,\n      rcases bdd with ⟨z, hz⟩,\n      obtain ⟨c, hc : c > a⟩ := no_top a,\n      obtain ⟨y, hy : y > max c z⟩ := no_top (max c z),\n      refine not_le_of_lt (lt_of_le_of_lt (le_max_right _ _) hy) (hz (or.inl _)),\n      calc y > max c z : hy\n       ...   ≥ c       : le_max_left _ _\n       ...   > a       : hc },\n    -- In the remaining goals we'll do case analysis on whether\n    -- `s` is empty (and thus can be ignored) or nonempty (and thus we can use IH).\n    all_goals {\n      clear bdd,\n      rcases set.eq_empty_or_nonempty s with rfl|ne';\n      [ { clear IH bdd', simp only [set.union_empty] },\n        { specialize IH ne' bdd', clear ne' bdd', cases IH with l IH }] },\n    { exact ⟨_, is_lub_singleton⟩ },\n    { exact ⟨_, is_lub.union is_lub_singleton IH⟩ },\n    { exact ⟨_, is_lub_Iio⟩ },\n    { exact ⟨_, is_lub.union is_lub_Iio IH⟩ },\n    { exact ⟨_, is_lub_Ioo hab⟩ },\n    { exact ⟨_, is_lub.union (is_lub_Ioo hab) IH⟩ } }\nend\n\n/-- X ↦ inf X as a partial function. Defined when X is tame, nonempty and bounded below. -/\nnoncomputable def tInf : set R →. R :=\nλ X, { dom := tame X ∧ X.nonempty ∧ bdd_below X, get := λ h, classical.some (exists_tInf h.1 h.2.1 h.2.2) }\n\n/-- X ↦ inf X as a partial function. Defined when X is tame, nonempty and bounded above. -/\nnoncomputable def tSup : set R →. R :=\nλ X, { dom := tame X ∧ X.nonempty ∧ bdd_above X, get := λ h, classical.some (exists_tSup h.1 h.2.1 h.2.2) }\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/omin/tame.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.6723316926137812, "lm_q1q2_score": 0.45202990930710896}}
{"text": "/- Copyright (c) 2022 Sina Hazratpour. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\n----------------\n# Basics of Categories\nSina Hazratpour\nIntroduction to Proof  \nMATH 301, Johns Hopkins University, Fall 2022   \n-/\n\n/-\n-- \"_Category theory takes a bird’s eye view of mathematics. From high in the sky, details become invisible, but we can spot patterns that were impossible to de- tect from ground level._\" \n\n-- From \"Basic Category Theory\" by Tom Leinster\n-- -/\n\n\n\n-- import tactic.basic\nimport ..prooflab\nimport lectures.lec15_integers\nimport tactic.basic\n\nopen PROOFS\nopen PROOFS.STR\n\n\n/-\nWe already have so far seen many interesting __objects__ in this course: \n\n- Types (introduced in lecture 1)\n- Pointed Types (introduced in lecture 11)\n- Propositions (introduced in lecture 1 and 6) and Predicates/Relations (introduced in lecture 7)\n- Graphs (introduced in hackathon)\n- Quasigroups (introduced HW 8)\n- Semigroups \n- Monoids (natural numbers, endofunctions, endomorphism of monoids)\n- Commutative monoids (a monoid where multiplication/addition operation is commutative, e.g. fake natural numbers `mat`, ℕ, ℤ, ℤ[i],  )\n- Groups (introduced as an extension of the strucute of monoids (monoids with inverses), e.g. integers and gaussian integers ℤ[i], group of auto-functions (functions `X → X` which are equivalences.))\n- Commutative rings (two operations (+, *), e.g. integers and gaussian integers)\n-/\n\n\n/-\nIn each case, we have seen how to __relate__ objects of the same kind by an appropriate notion of __map__ (also called  __morphism__) between them: \n\n- Function between types (`f : X → Y`, e.g. `bool_of_nat` relates `nat` to `bool`, `nat_of_bool`, many coercion functions, for instance from integers to Gaussian integers. )\n- Pointed functions (i.e. functions which preserved the points of pointed type domain) (`f : (X, x : X) → (Y, y : Y)` where `f x = y`)\n- Derivations of propositions (`P → Q` if we can derived `Q`from `P`)\n- Graph homomorphism between graphs (they preserve adjacency relation)\n- Monoid homomorphism between monoids (they preserve multiplication/addition operation)\n- Group homomorphism between groups (they preserve multiplication/addition operation)\n- Ring homomorphism between commutative rings (they preserve multiplication and addition operations)\n-/ \n\n/-\nFurthermore, we can __compose__ such maps. For instance in the Graph hackathon we composed homomorphisms of graphs and in HW10 you defined the composition of monoid morphisms.\n\nRecall HW10.Q1 \n@[simp]\ndef mult_monoid.morphism.comp (g : M →ₘ* N) (f : L →ₘ* M)  : L →ₘ* N := \n{ to_fun := g ∘ f,\n  resp_one := sorry,\n  resp_mul := sorry, } \n\nAnd in all of the above cases we established an __identity__ function or homomorphism for each object `X` which is netural with respect to composition. \n-/\n\n\n/-\nThis common pattern can be generalized to the abstract notion of category_str. A __category_str__ consitsts of\n\n1. a collection of __objects__,\n2.  a collection of __morphisms__, (maps between objects)\n3. a composition operation whereby we can compose simpler morphisms and build complex morphisms,\n4. an operation which provides identiry morphism for each object in the category_str. \n\nAnd these data satisfy the axioms of __associativity__ and (left/right) __unitality__. \n-/\n\n\n/-\nMany of the categories one meets in practice have as objects types with some structure attached to them and as have as morphisms functions or homomorphisms (i.e. structure-preserving functions) between them. This is a good model to keep in mind at the outset. \n\nTherefore, a category_str may be viewed as consisting of objects bearing a certain kind of structure together with morphisms/mappings between such objects preserving that structure. \n\nFor instance, in the rest of the course we shall construct the following categories: \n\n-- __Graph__ : the category_str of graphs and graph homomorphisms (the objects of this category_str are __simple graphs__, and morphisms are __graph homomorphisms__)\n-- __Mon__ : the category_str of monoids and monoid homomorphisms (the objects of this category_str are monoids, and morphisms are monoid homomorphisms)\n-- __Group__ : the category_str of groups and groups homomorphisms\n-/\n\n\n/-\nHowever, there are categories which are not the categories of structures. We construct a category_str whose objects are natural numbers `1,2,3, ...` and whose morphisms are matrices. \n-/\n\n\n\n/- ## Some Philosophical Remarks \n1. A category is a __system__ which has objects and relations between these objects. The objects do not live in isolation: morphisms bind them together.\n2. What is more important is the relations (i.e. morphisms): In fact, two objects are the same if they have the same relations to all other objects. This is known as the __Yoneda Lemma__ which we shall discuss in the last lecture.  Therefore, an object in a category is fully determined by its relations to other objects. Note that this is a not necessarily true for other systems of objects and relations. Is it true for instance than an animal is fully determined by the total sum of its relation to all other animals (including oneself, c.f. being vs becoming).   \n-/\n\n\n/- \nA preliminary ad-hoc structure on the way to defining the category structure, containing only the data of hom-types, the operations of identity and composition. \nLater, we extend the structure of precategory_str to category_str.\n-/\n\n--library_note \"category_str_theory universes\"\n\n/-\nIn the mathematical language Lean, types are organized into a hierarchy of universe levels, with each level representing a different __universe__ of types that are considered to be of a certain size or complexity. This hierarchy allows for a more structured and well-defined approach to working with types, while __avoiding the inconsistencies and paradoxes that can arise from allowing for the existence of a type of all types__.\n\nIt is possible to define a type in Lean that represents the collection of all types, but this is done in a more carefully __controlled__ manner than simply allowing for the existence of a type of all types. Universe levels are consistency control parameters. \n-/\nuniverses v u -- this handles the distinction between small and large categories -- universe variables are inserted in the order that they were declared.\n\n\n\n\nclass precategory_str (obj : Type u) : Type (max u (v+1))  :=\n(hom : obj → obj → Type v) -- for any two objects `X : obj` and `Y : obj` we have the type `hom X Y` of morphisms between `X` and `Y` \n(id       : Π X : obj, hom X X) -- specifies identity morphism for all types \n(comp     : Π {X Y Z : obj}, (hom X Y) → (hom Y Z) → (hom X Z) )\n-- ( id       : Π X : obj, hom X X )\n-- ( comp     : Π {X Y Z : obj}, (hom Y Z) → (hom X Y) → (hom X Z) )\n\n#check precategory_str\n--#print precategory_str\n\n\n\n/-! #### notation remarks\nThere is a special notation for the morphisms in a category_str: if `X Y : C`, we write\n\n-  `X ⟶ Y` for the type `hom X Y`  of morphisms from `X` to `Y`.  Note: X ⟶ Y is entirely different than the type X → Y of functions from `X` to `Y`.  \n  (To enter the special arrow `⟶`, type `\\h` or `\\hom`, or hover over the symbol to see the hint.)\n\n- `𝟙 X` is a the identity morphisms on `X` (i.e., a term of type `X ⟶ X`).  (To enter the special arrow `𝟙`, type `\\b1` or hover over the symbol to see the hint.)\n\n- If `f : X ⟶ Y` and `g : Y ⟶ Z`, then we write `g ⊚ f` for the composition, a morphism `X ⟶ Z`. -- this is composition in every category_str, not necessarily in the category_str of types\n-/\n\n\n\ninfixr ` ⟶ `:10 := precategory_str.hom -- type as \\h\nnotation `𝟙` := precategory_str.id -- type as \\b1\n-- infixr ` ⊚ `:80 := precategory_str.comp-- type as \\oo\n\nlocal notation f ` ⊚ `:80 g:80 := precategory_str.comp g f    -- type as \\oo\n\n\n\nsection\nvariables {𝓒 : Type} [precategory_str 𝓒]\nvariables W X Y Z : 𝓒 -- terms of type C can be regarded as objects of precategory_str 𝓒\n#check X ⟶ Y\nvariables f₀ f₁ : X ⟶ Y \nvariables g₀ g₁ : Y ⟶ Z\n#check 𝟙 X\n--#check f₀ ⊚ g₀ -- this does not type check because the composition goes the other way round.\n#check g₀ ⊚ f₀ \n--#check f₀ ⊚ g₁\n#check g₁ ⊚ f₀\n\nend \n\n\n/-\n- Now, we add the axioms of __unitality__ and __associativity__ to extend the structure of a precategory_str to a category_str. \n- The typeclass `category_str C` describes morphisms associated to objects of type `C`.\n-/\n\nclass category_str (obj : Type u) extends precategory_str.{v} obj : Type (max u (v+1)) :=\n(id_comp' : ∀ {X Y : obj} (f : hom X Y), f ⊚ (𝟙 X)  = f . obviously) -- naming based diagrammatic order of composition\n(comp_id' : ∀ {X Y : obj} (f : hom X Y), (𝟙 Y) ⊚ f = f . obviously)\n(comp_assoc'   : ∀ {W X Y Z : obj} (f : hom W X) (g : hom X Y) (h : hom Y Z),\n  (h ⊚ g) ⊚ f = h ⊚ (g ⊚ f) . obviously)\n\n\n#check category_str.id_comp'\n\n\nset_option trace.simp_lemmas true\n\n\n\ninstance : category_str ℕ := \n{ hom := λ x, λ y, plift (x ≤ y),\n  id := λ x, ⟨ le_refl x ⟩,\n  comp := λ x y z, λ f, λ g, ⟨le_trans f.down g.down ⟩,\n  id_comp' := by {intros X Y f, simp},\n  comp_id' := by {intros X Y f, simp},\n  comp_assoc' := by {intros W X Y Z f g h, simp}, }\n\n\n\n\n\n/-\n`restate_axiom` is a command that creates a lemma from a structure field discarding any auto_param wrappers from the type.\nIt removes a backtick from the name, if it finds one, and otherwise adds \"_lemma\".\n-/\n\nrestate_axiom category_str.id_comp'\nrestate_axiom category_str.comp_id'\nrestate_axiom category_str.comp_assoc'\n\n/-\n`restate_axiom` automates writing lemmas by hand. If we did not use `restate_axiom` then we had to prove a lemma like in below:\n\n@[simp]\nlemma id_comp {C : Type} [category_str C] {X Y : C} : \n  ∀  f : X ⟶ Y ,  (𝟙 X) ⊚ f = f  := \nbegin\n  intro f, \n  rw [category_str.id_comp' f],\nend   \n\nAt any rate, we now have three lemmas which we can use for rewrite/substitution.\n-/\n\n#check category_str.id_comp -- this is a lemma made directly from the field ategory_str.id_comp' in the definition of category.\n#check category_str.comp_id\n#check category_str.comp_assoc\n\n/-\nWe add the attributes `simp` so that the tactic `simp` works when using these lemmas to simplify the state of our proofs. \n-/\nattribute [simp] category_str.id_comp category_str.comp_id category_str.comp_assoc\nattribute [trans] precategory_str.comp\n\n\n\n\ninitialize_simps_projections category_str (to_precategory_str_hom → hom,\n  to_precategory_str_comp → comp, to_precategory_str_id → id, -to_precategory_str)\n\n\n\n\n\n/--\nA `large_category_str` has objects in one universe level higher than the universe level of\nthe morphisms. It is useful for examples such as the category_str of types, or the category_str\nof groups, etc.\n-/\nabbreviation large_category_str (C : Type (u+1)) : Type (u+1) := category_str.{u} C\n/--\nA `small_category_str` has objects and morphisms in the same universe level.\n-/\nabbreviation small_category_str (C : Type u) : Type (u+1) := category_str.{u} C\n\n\nnamespace category_str\n\n/-! ## Category of Types\nThere is a large category of types where the objects are types and the morphisms are functions between types. -/\ninstance cat_of_types : category_str Type* :=\n{ \n  hom := λ X, λ Y, X → Y,\n  id := λ X, id,\n  comp := λ X Y Z, λ f, λ g, g ∘ f,\n  id_comp' := by {intros X Y, intro f, refl},\n  comp_id' := by {intros X Y, intro f, refl},\n  comp_assoc' := by {\n                      intros W X Y Z, \n                      intros f g h, \n                      refl,\n                      --funext, \n                      --dsimp, \n                      --refl,} \n                    } \n}\n\n\n\n#check category_str.cat_of_types.id_comp'\n\n--#reduce category_str.cat_of_types.id_comp'\n\n#reduce category_str.cat_of_types.id_comp' (λ x, (x + 1))\n\n\nsection \n\nvariables (𝓒 : Type u) [category_str.{v} 𝓒] (X Y : 𝓒) (f : X ⟶ Y) -- let 𝓒 be a category and `f : X ⟶ Y` a morphism in it . \n\n#reduce category_str.id_comp' f\n\nend --section \n\n\n\n/- Note that by the tactic `.obviously` we actually do not need to provide the proofs of three least fields `comp_id'` and  `comp_assoc'` and `comp_assoc'` since all of them follows simply from `refl`. -/ \n\n#check (𝟙 ℕ) ⊚ (𝟙 ℕ)\n\n\n\n\nexample  : \n  bool_of_nat ⊚ (𝟙 ℕ) = bool_of_nat := \nbegin\n  simp, \nend \n\n\n\n/-! ## Category of Pointed Types \nSee lecture 11 for definitions of `→•` and pointed_type.id, or simply command+click below. \n-/ \n\ninstance : large_category_str pointed_type :=\n{ \n  hom := λ X, λ Y, X →• Y, -- really X is (A, a)\n  id := λ X, pointed_type.id, -- id: (A,a) ⟶ (A,a)  \n  comp := λ X Y Z, λ f, λ g, g ∘• f,\n}\n\n\n/-! ##  The Category of a Preorder\nEvery preorder can be seen as a small category where the objects are the elements/terms of the (underlying type) of the preorder and between two objects `x` and `y` there is a (unique) morphism iff `x ≤ y`. To do this we need some tools to see a proposition as the type of its proofs.  \n-/\n\n/- We use `plift` to lift a proposition to the type of its proofs -/\n#check plift (0 = 0) -- this a type whose terms are proofs of `0 = 0`. \n\n#check ( ⟨ (rfl : 0 = 0) ⟩ : plift (0 = 0) ) -- Since `rfl` is a proof of `0 = 0` we can lift it up to a term `⟨ (rfl : 0 = 0) ⟩` of type `plift (0 = 0)`. \n\n-- For a proposition `P`, the terms of type `plift`\n\n\n/- We use `ulift` to lift a proposition to the type of its proofs -/\n#check ulift -- lifting types from one universe to a higher universe\n#check plift -- lifting propositions to types\n\n\n\ninstance small_cat_of_preorder (X : Type) [preorder X] : small_category_str X := \n{\n  hom := λ x, λ y, (plift (x ≤ y) : Type), \n  id := λ x, ⟨ le_refl x ⟩, \n  comp := λ x y z, λ f, λ g, ⟨le_trans f.down g.down ⟩,\n}\n\ndef two_to_three :  1 ⟶ 2 := \n⟨one_le_two⟩ \n\n#check two_to_three \n\n#reduce category_str.comp_id' two_to_three \n\n\n#check category_str.small_cat_of_preorder\n\ninstance foo : small_category_str ℕ := \ncategory_str.small_cat_of_preorder ℕ \n\n#check category_str.foo.hom 2 3\n\n#reduce category_str.foo.hom 2 3\n\n\n\n\nsection lifting_categories\n\nvariables (𝓒 : Type u)[category_str.{v} 𝓒]\n\n\nuniverse u'\n-- we can lift 𝓒 from universe `u` to a higher universe `u'`. \ninstance ulift_cat : category_str.{v} (ulift.{u'} 𝓒) :=\n{ hom  := λ X Y, (X.down ⟶ Y.down),\n  id   := λ X, 𝟙 X.down,\n  comp := λ _ _ _ f g, g ⊚ f }\n\n-- We verify that this previous instance can lift small categories to large categories.\nexample (𝓢 : Type u) [small_category_str 𝓢] : large_category_str (ulift.{u+1} 𝓢) := \nby apply_instance\n\nend lifting_categories\n\n\n\n/-\n+ There are many more categories which we shall introduce in the three remaining lectures: the category of graphs, the category of monoids, the category of groups, the category of rings, the category of vector spaces, and finally the category of categories! \n\n+ There are statements which are true in all these categories by virtue of  being a category. This is like saying for instance a city has a town-hall by virtue of being a city (that is, we don't know in which country that city is located, what is the population of that city, etc. we just know it is a city.) \n\n+ It is interesting to see which statements are true in an arbitrary category. If we construct something or prove a statement in an arbitrary category,then these constructions and statements and will be valid in every particular category, such as the category of types, groups, etc.  \n\n+ In below, we shall introduce new definitions and prove statements which are valid in an arbitrary category. \n-/\n\n\nvariables {𝓒 : Type u} [category_str 𝓒] {W X Y Z : 𝓒} {A : Type}\n\n\n\n/-! # Delooping of a monoid \nGiven a monoid `M` (i.e. a type equipped with a monoid structure), we construct a category which has only one object and `M` many morphisms. The composition of morphisms in this category is given by the monoid multiplication. \n-/\n\n\ninstance delooping (M : Type u)[mult_monoid_str M] : small_category_str.{u} (punit : Type u) := \n{ \n  hom := λ _, λ _, M,\n  id := 1,\n  comp := λ _ _ _, (*),\n  id_comp' := by {intros _ _ _, simp [mult_mon_one_mul], },\n  comp_id' := by {intros _ _ _, simp [mult_mon_mul_one],},\n  comp_assoc' := by {intros _ _ _ _ _ _ _,simp,}, \n}  \n\n#check category_str.delooping\n#check category_str.comp\n\n\n\n\n-- A shorter proof\n-- instance delooping (M : Type)[mult_monoid_str M] : small_category_str unit := \n-- { \n--   hom := λ _, λ _, M,\n--   id := 1,\n--   comp := λ _ _ _, (*),\n--   id_comp' := by {simp},\n--   comp_id' := by {simp},\n--   comp_assoc' := by {intros _ _ _ ,simp}, \n-- }  \n\n\n-- Even shorter using tactic `.obviously`\n\ninstance delooping_alt (M : Type)[mult_monoid_str M] : small_category_str unit := \n{ \n  hom := λ _, λ _, M,\n  id := 1,\n  comp := λ _ _ _, (*),\n}  \n\n\n\n\n\n/-\nConversely, in every category every object has, by virtue of being an object of a category, a monoid structure.  \n-/\n\n/- The type of __endomorphisms__ of an object X in category 𝓒 -/\n\ndef End (X : 𝓒) := X ⟶ X  \n\n#check @End\n\n\n#check mult_monoid_str\n\n/- The __endomorphisms monoid__ of an object in a category-/\ndef monoid_of_object {𝓒 : Type}[small_category_str 𝓒] (X : 𝓒) : mult_monoid_str (X ⟶ X) :=  \nsorry \n\n\n\n\n\n/-! ## Challenge: \nThe endomorphisms monoid of the only object in `single_obj α` is equivalent to the original\n     monoid α. -/\n-- def to_End {M : Type} [mult_monoid_str M] : M ≃* End (_) :=\n-- sorry\n\n\n\n\n\n\n\nlemma eq_comp {f g : X ⟶ Y} (e : f = g) (h : Y ⟶ Z) : \n  h ⊚ f = h ⊚ g :=\nbegin\n-- we want to prove  `h ⊚ f = h ⊚ g`\n  rw e, -- we sub `f` for `g`\nend \n\n  \n\nlemma comp_eq (f : X ⟶ Y) {g h : Y ⟶ Z} (e : g = h) : \n  g ⊚ f = h ⊚ f :=\nbegin\n  rw e, \nend \n\n\nexample (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z) :  \n(h  ⊚  (𝟙 Y ⊚ g)) ⊚  f = h ⊚ (g ⊚ f) :=\nbegin\n  simp, \nend\n\n\n\n\nstructure equiv (X Y : 𝓒) :=\n(to_mor    : X ⟶ Y)\n(inv_mor   : Y ⟶ X)\n(left_inv  : to_mor ⊚  inv_mor = (𝟙 Y) ) \n(right_inv : inv_mor ⊚ to_mor = (𝟙 X)  )\n\n\nlocal notation ` ≅ `:85 := equiv\n\n\n\n/-\nA morphism `f` is an __isomorphism__ if it has both a left inverse and a right inverse.\n-/\n\ndef is_iso (f : X ⟶ Y) := \n∃ (g h : Y ⟶ X), (g ⊚ f = 𝟙 X) ∧ (f ⊚ h = 𝟙 Y)\n\n\n/- ## Challenge:\nShow that an instance of equivalence `f : X ≃ Y` gives rise to a pair of isomorphisms, i.e. both `f.to_mor` and `f.inv_mor` are isomorphisms.\n\nConversely, we can prove that every isomorphism gives rise to an equivalence. \n-/\n\n\n\n/--\nA morphism `f` is a __monomorphism__ if it can be cancelled when __postcomposed__:\n`g ≫ f = h ≫ f` implies `g = h`.\n-/\n@[simp] \ndef is_mono (f : X ⟶ Y) :=\n∀ (W : 𝓒) (x₁ x₂ : W ⟶ X), (f ⊚ x₁ = f ⊚ x₂) →  (x₁ = x₂)\n\n@[simp]\nlemma cancel_mono {f : X ⟶ Y} (mf : is_mono f) {x₁ x₂ : W ⟶ X} : \n  (f ⊚ x₁  = f ⊚ x₂) ↔ x₁ = x₂ :=\nbegin\n  split,\n  {\n    intro h,\n    apply mf, \n    exact h,\n  },\n  {\n    apply congr_arg,\n  },\nend \n\n\n\n\n/-\nDually, a morphism `f` is an __epimorphism__ if it can be cancelled when __precomposed__:\n`g ⊚ f = h ⊚ f` implies `g = h`.\n-/\n\ndef is_epi (f : X ⟶ Y) := \n∀ {Z : 𝓒} (g h : Y ⟶ Z), (g ⊚ f = h ⊚ f) → g = h\n\n\n\n\n/- ## Challenge \nShow that every isomorphism is a monomorphism. \n-/\n\n\n\n/-! ## Opposite Category \nIf `𝓒` is a category, then `𝓒ᵒᵖ` is the __opposite category__, with objects the same but all arrows reversed. `𝓒ᵒᵖ` is the mirror image of `𝓒`. If `X ⟶ Y ⟶ Z` are morphisms in `𝓒ᵒᵖ` then `Z ⟶ Y ⟶ X`  are maps in `𝓒`. \n\nIn below we give `𝓒ᵒᵖ` the structure of a category. See `opposite_cat`. \n-/\n\ndef opposite (𝓒 : Type u) : Type u := 𝓒\n\n\nnotation X `ᵒᵖ`:std.prec.max_plus := opposite X\n\n\n/- The canonical map `𝓒 → 𝓒ᵒᵖ`. \nWe need to write `op X` to explicitly move `X` to the opposite category-/\n@[pp_nodot]\ndef op : 𝓒 → 𝓒ᵒᵖ := id \n\n\n\n/- The canonical map `𝓒ᵒᵖ → 𝓒`. -/\n@[pp_nodot]\ndef unop : 𝓒ᵒᵖ → 𝓒 := id\n\nsection test \nvariable XX : 𝓒 \n#check op XX \n#check unop (op XX)\n\nexample  : \n  unop (op XX) = XX := rfl \n\nend  test\n\n@[simp] \nlemma op_unop (X : 𝓒ᵒᵖ) : op (unop X) = X := rfl\n\n@[simp] \nlemma unop_op (x : 𝓒) : unop (op X) = X := rfl\n\n\n/- The type-level equivalence between a type and its opposite. -/\ndef equiv_to_opposite :  𝓒 ≅ 𝓒ᵒᵖ :=\n{ \n  to_fun := op,\n  inv_fun := unop,\n  left_inv := by {ext, refl, },\n  right_inv := by {ext, refl, }, \n}\n\n\ninstance opposite_cat {𝓒 : Type u} [category_str.{v} 𝓒] : category_str.{v} 𝓒ᵒᵖ :=\n{ \n  hom := λ X, λ Y, (unop Y ⟶ unop X), -- informally, hom_{𝓒ᵒᵖ} X Y = hom_{𝓒} Y X\n  id := λ X, 𝟙 (unop X),\n  comp := λ X Y Z, λ f g, f ⊚ g,\n  id_comp' := by {intros X Y f, simp,},\n  comp_id' := by {intros X Y f, simp,},\n  comp_assoc' := by {intros W X Y Z f g h, rw [comp_assoc'],} \n}\n\n\n\n\n/-\nThe opposite of an arrow in `𝓒`.\n-/\ndef hom.op  {X Y : 𝓒} (f : X ⟶ Y) : \nop Y ⟶ op X := f\n\n/-\nGiven an arrow in `𝓒ᵒᵖ`, we can take the \"unopposite\" back in `𝓒`.\n-/\ndef hom.unop {X Y : 𝓒ᵒᵖ} (f : X ⟶ Y) : \nunop Y ⟶ unop X := f\n\n\n@[simp] \nlemma op_comp {X Y Z : 𝓒} {f : X ⟶ Y} {g : Y ⟶ Z} :\n  hom.op (g ⊚ f) = hom.op f ⊚ hom.op g := \nbegin \n  refl, \nend   \n\n@[simp] \nlemma unop_comp {X Y Z : 𝓒ᵒᵖ} {f : X ⟶ Y} {g : Y ⟶ Z} :\n  hom.unop (g ⊚ f) = hom.unop f ⊚ hom.unop g := \nbegin \n  refl, \nend   \n\n\n\n@[simp] \nlemma op_id {X : 𝓒} : hom.op (𝟙 X) = 𝟙 (op X) := \nbegin\n  refl, \nend \n\n@[simp] \nlemma unop_id {X : 𝓒ᵒᵖ} : hom.unop (𝟙 X) = 𝟙 (unop X) := \nbegin\n  refl, \nend \n\n\n\n\nend category_str \n\n\n\n\n\n\n\n", "meta": {"author": "sinhp", "repo": "ProofLab", "sha": "f14b2d0e8d1f6281b9ca16877aa06a8db0a690e2", "save_path": "github-repos/lean/sinhp-ProofLab", "path": "github-repos/lean/sinhp-ProofLab/ProofLab-f14b2d0e8d1f6281b9ca16877aa06a8db0a690e2/src/lectures/lec16_categories_basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5736784220301065, "lm_q2_score": 0.7879312056025699, "lm_q1q2_score": 0.45201913069836175}}
{"text": "import Std.Tactic.GuardExpr\nimport Std.Tactic.Congr\n\nsection congr\n\nexample (c : Prop → Prop → Prop → Prop) (x x' y z z' : Prop)\n    (h₀ : x ↔ x') (h₁ : z ↔ z') : c x y z ↔ c x' y z' := by\n  apply Iff.of_eq -- FIXME: not needed in lean 3\n  congr\n  · guard_target =ₐ x = x'\n    apply_ext_lemma\n    assumption\n  · guard_target =ₐ z = z'\n    ext\n    assumption\n\nexample {α β γ δ} {F : ∀ {α β}, (α → β) → γ → δ} {f g : α → β} {s : γ}\n    (h : ∀ x : α, f x = g x) : F f s = F g s := by\n  congr with x\n  -- apply_assumption -- FIXME\n  apply h\n\nattribute [ext] Subtype.eq\n\nexample {α β : Type _} {f : _ → β} {x y : { x : { x : α // x = x } // x = x }}\n    (h : x.1 = y.1) : f x = f y := by\n  congr with x : 1\n  exact h\n\nexample {α β : Type _} {F : _ → β} {f g : { f : α → β // f = f }}\n    (h : ∀ x : α, (f : α → β) x = (g : α → β) x) : F f = F g := by\n  rcongr x\n  revert x\n  guard_target = type_of% h\n  exact h\n\nprivate opaque List.sum : List Nat → Nat\n\nexample {ls : List Nat} :\n    (ls.map fun x => (ls.map fun y => 1 + y).sum + 1) =\n    (ls.map fun x => (ls.map fun y => Nat.succ y).sum + 1) := by\n  rcongr (_x y)\n  guard_target =ₐ 1 + y = y.succ\n  rw [Nat.add_comm]\n\nexample {ls : List Nat} {f g : Nat → Nat} {h : ∀ x, f x = g x} : (ls.map fun x => f x + 3) = ls.map fun x => g x + 3 := by\n  rcongr x\n  exact h x\n\n-- succeed when either `ext` or `congr` can close the goal\nexample : () = () := by rcongr\n\nexample : 0 = 0 := by rcongr\n\nexample {α} (a : α) : a = a := by congr\n\n-- FIXME(?): congr doesn't fail\n-- example {α} (a b : α) (h : False) : a = b := by\n--   fail_if_success congr\n--   cases h\n\nend congr\n", "meta": {"author": "leanprover", "repo": "std4", "sha": "5507f9d8409f93b984ce04eccf4914d534e6fca2", "save_path": "github-repos/lean/leanprover-std4", "path": "github-repos/lean/leanprover-std4/std4-5507f9d8409f93b984ce04eccf4914d534e6fca2/test/congr.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.4520056022791312}}
{"text": "/-\nCopyright (c) 2019 Amelia Livingston. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Amelia Livingston, Bryan Gin-ge Chen\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.galois_connection\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# Equivalence relations\n\nThis file defines the complete lattice of equivalence relations on a type, results about the\ninductively defined equivalence closure of a binary relation, and the analogues of some isomorphism\ntheorems for quotients of arbitrary types.\n\n## Implementation notes\n\nThe function `rel` and lemmas ending in ' make it easier to talk about different\nequivalence relations on the same type.\n\nThe complete lattice instance for equivalence relations could have been defined by lifting\nthe Galois insertion of equivalence relations on α into binary relations on α, and then using\n`complete_lattice.copy` to define a complete lattice instance with more appropriate\ndefinitional equalities (a similar example is `filter.complete_lattice` in\n`order/filter/basic.lean`). This does not save space, however, and is less clear.\n\nPartitions are not defined as a separate structure here; users are encouraged to\nreason about them using the existing `setoid` and its infrastructure.\n\n## Tags\n\nsetoid, equivalence, iseqv, relation, equivalence relation\n-/\n\n/-- A version of `setoid.r` that takes the equivalence relation as an explicit argument. -/\ndef setoid.rel {α : Type u_1} (r : setoid α) : α → α → Prop := setoid.r\n\n/-- A version of `quotient.eq'` compatible with `setoid.rel`, to make rewriting possible. -/\ntheorem quotient.eq_rel {α : Type u_1} {r : setoid α} {x : α} {y : α} :\n    quotient.mk x = quotient.mk y ↔ setoid.rel r x y :=\n  quotient.eq'\n\nnamespace setoid\n\n\ntheorem ext' {α : Type u_1} {r : setoid α} {s : setoid α} (H : ∀ (a b : α), rel r a b ↔ rel s a b) :\n    r = s :=\n  ext H\n\ntheorem ext_iff {α : Type u_1} {r : setoid α} {s : setoid α} :\n    r = s ↔ ∀ (a b : α), rel r a b ↔ rel s a b :=\n  { mp := fun (h : r = s) (a b : α) => h ▸ iff.rfl, mpr := ext' }\n\n/-- Two equivalence relations are equal iff their underlying binary operations are equal. -/\ntheorem eq_iff_rel_eq {α : Type u_1} {r₁ : setoid α} {r₂ : setoid α} : r₁ = r₂ ↔ rel r₁ = rel r₂ :=\n  { mp := fun (h : r₁ = r₂) => h ▸ rfl,\n    mpr := fun (h : rel r₁ = rel r₂) => ext' fun (x y : α) => h ▸ iff.rfl }\n\n/-- Defining `≤` for equivalence relations. -/\nprotected instance has_le {α : Type u_1} : HasLessEq (setoid α) :=\n  { LessEq := fun (r s : setoid α) => ∀ {x y : α}, rel r x y → rel s x y }\n\ntheorem le_def {α : Type u_1} {r : setoid α} {s : setoid α} :\n    r ≤ s ↔ ∀ {x y : α}, rel r x y → rel s x y :=\n  iff.rfl\n\ntheorem refl' {α : Type u_1} (r : setoid α) (x : α) : rel r x x := and.left iseqv x\n\ntheorem symm' {α : Type u_1} (r : setoid α) {x : α} {y : α} : rel r x y → rel r y x :=\n  fun (h : rel r _x✝ _x) => and.left (and.right iseqv) _x✝ _x h\n\ntheorem trans' {α : Type u_1} (r : setoid α) {x : α} {y : α} {z : α} :\n    rel r x y → rel r y z → rel r x z :=\n  fun (hx : rel r _x✝¹ _x✝) => and.right (and.right iseqv) _x✝¹ _x✝ _x hx\n\n/-- The kernel of a function is an equivalence relation. -/\ndef ker {α : Type u_1} {β : Type u_2} (f : α → β) : setoid α :=\n  mk (fun (x y : α) => f x = f y) sorry\n\n/-- The kernel of the quotient map induced by an equivalence relation r equals r. -/\n@[simp] theorem ker_mk_eq {α : Type u_1} (r : setoid α) : ker quotient.mk = r :=\n  ext' fun (x y : α) => quotient.eq\n\ntheorem ker_def {α : Type u_1} {β : Type u_2} {f : α → β} {x : α} {y : α} :\n    rel (ker f) x y ↔ f x = f y :=\n  iff.rfl\n\n/-- Given types `α`, `β`, the product of two equivalence relations `r` on `α` and `s` on `β`:\n    `(x₁, x₂), (y₁, y₂) ∈ α × β` are related by `r.prod s` iff `x₁` is related to `y₁`\n    by `r` and `x₂` is related to `y₂` by `s`. -/\nprotected def prod {α : Type u_1} {β : Type u_2} (r : setoid α) (s : setoid β) : setoid (α × β) :=\n  mk (fun (x y : α × β) => rel r (prod.fst x) (prod.fst y) ∧ rel s (prod.snd x) (prod.snd y)) sorry\n\n/-- The infimum of two equivalence relations. -/\nprotected instance has_inf {α : Type u_1} : has_inf (setoid α) :=\n  has_inf.mk fun (r s : setoid α) => mk (fun (x y : α) => rel r x y ∧ rel s x y) sorry\n\n/-- The infimum of 2 equivalence relations r and s is the same relation as the infimum\n    of the underlying binary operations. -/\ntheorem inf_def {α : Type u_1} {r : setoid α} {s : setoid α} : rel (r ⊓ s) = rel r ⊓ rel s := rfl\n\ntheorem inf_iff_and {α : Type u_1} {r : setoid α} {s : setoid α} {x : α} {y : α} :\n    rel (r ⊓ s) x y ↔ rel r x y ∧ rel s x y :=\n  iff.rfl\n\n/-- The infimum of a set of equivalence relations. -/\nprotected instance has_Inf {α : Type u_1} : has_Inf (setoid α) :=\n  has_Inf.mk\n    fun (S : set (setoid α)) => mk (fun (x y : α) => ∀ (r : setoid α), r ∈ S → rel r x y) sorry\n\n/-- The underlying binary operation of the infimum of a set of equivalence relations\n    is the infimum of the set's image under the map to the underlying binary operation. -/\ntheorem Inf_def {α : Type u_1} {s : set (setoid α)} : rel (Inf s) = Inf (rel '' s) := sorry\n\nprotected instance partial_order {α : Type u_1} : partial_order (setoid α) :=\n  partial_order.mk LessEq (fun (r s : setoid α) => r ≤ s ∧ ¬s ≤ r) sorry sorry sorry\n\n/-- The complete lattice of equivalence relations on a type, with bottom element `=`\n    and top element the trivial equivalence relation. -/\nprotected instance complete_lattice {α : Type u_1} : complete_lattice (setoid α) :=\n  complete_lattice.mk complete_lattice.sup complete_lattice.le complete_lattice.lt sorry sorry sorry\n    sorry sorry sorry has_inf.inf sorry sorry sorry (mk (fun (_x _x : α) => True) sorry) sorry\n    (mk Eq sorry) sorry complete_lattice.Sup complete_lattice.Inf sorry sorry sorry sorry\n\n/-- The inductively defined equivalence closure of a binary relation r is the infimum\n    of the set of all equivalence relations containing r. -/\ntheorem eqv_gen_eq {α : Type u_1} (r : α → α → Prop) :\n    eqv_gen.setoid r = Inf (set_of fun (s : setoid α) => ∀ {x y : α}, r x y → rel s x y) :=\n  sorry\n\n/-- The supremum of two equivalence relations r and s is the equivalence closure of the binary\n    relation `x is related to y by r or s`. -/\ntheorem sup_eq_eqv_gen {α : Type u_1} (r : setoid α) (s : setoid α) :\n    r ⊔ s = eqv_gen.setoid fun (x y : α) => rel r x y ∨ rel s x y :=\n  sorry\n\n/-- The supremum of 2 equivalence relations r and s is the equivalence closure of the\n    supremum of the underlying binary operations. -/\ntheorem sup_def {α : Type u_1} {r : setoid α} {s : setoid α} :\n    r ⊔ s = eqv_gen.setoid (rel r ⊔ rel s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (r ⊔ s = eqv_gen.setoid (rel r ⊔ rel s))) (sup_eq_eqv_gen r s)))\n    (Eq.refl (eqv_gen.setoid fun (x y : α) => rel r x y ∨ rel s x y))\n\n/-- The supremum of a set S of equivalence relations is the equivalence closure of the binary\n    relation `there exists r ∈ S relating x and y`. -/\ntheorem Sup_eq_eqv_gen {α : Type u_1} (S : set (setoid α)) :\n    Sup S = eqv_gen.setoid fun (x y : α) => ∃ (r : setoid α), r ∈ S ∧ rel r x y :=\n  sorry\n\n/-- The supremum of a set of equivalence relations is the equivalence closure of the\n    supremum of the set's image under the map to the underlying binary operation. -/\ntheorem Sup_def {α : Type u_1} {s : set (setoid α)} : Sup s = eqv_gen.setoid (Sup (rel '' s)) :=\n  sorry\n\n/-- The equivalence closure of an equivalence relation r is r. -/\n@[simp] theorem eqv_gen_of_setoid {α : Type u_1} (r : setoid α) : eqv_gen.setoid r = r :=\n  le_antisymm\n    (eq.mpr (id (Eq._oldrec (Eq.refl (eqv_gen.setoid r ≤ r)) (eqv_gen_eq r)))\n      (Inf_le fun (_x _x_1 : α) => id))\n    eqv_gen.rel\n\n/-- Equivalence closure is idempotent. -/\n@[simp] theorem eqv_gen_idem {α : Type u_1} (r : α → α → Prop) :\n    eqv_gen.setoid (rel (eqv_gen.setoid r)) = eqv_gen.setoid r :=\n  eqv_gen_of_setoid (eqv_gen.setoid r)\n\n/-- The equivalence closure of a binary relation r is contained in any equivalence\n    relation containing r. -/\ntheorem eqv_gen_le {α : Type u_1} {r : α → α → Prop} {s : setoid α}\n    (h : ∀ (x y : α), r x y → rel s x y) : eqv_gen.setoid r ≤ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (eqv_gen.setoid r ≤ s)) (eqv_gen_eq r))) (Inf_le h)\n\n/-- Equivalence closure of binary relations is monotonic. -/\ntheorem eqv_gen_mono {α : Type u_1} {r : α → α → Prop} {s : α → α → Prop}\n    (h : ∀ (x y : α), r x y → s x y) : eqv_gen.setoid r ≤ eqv_gen.setoid s :=\n  eqv_gen_le fun (_x _x_1 : α) (hr : r _x _x_1) => eqv_gen.rel _x _x_1 (h _x _x_1 hr)\n\n/-- There is a Galois insertion of equivalence relations on α into binary relations\n    on α, with equivalence closure the lower adjoint. -/\ndef gi {α : Type u_1} : galois_insertion eqv_gen.setoid rel :=\n  galois_insertion.mk (fun (r : α → α → Prop) (h : rel (eqv_gen.setoid r) ≤ r) => eqv_gen.setoid r)\n    sorry sorry sorry\n\n/-- A function from α to β is injective iff its kernel is the bottom element of the complete lattice\n    of equivalence relations on α. -/\ntheorem injective_iff_ker_bot {α : Type u_1} {β : Type u_2} (f : α → β) :\n    function.injective f ↔ ker f = ⊥ :=\n  iff.symm eq_bot_iff\n\n/-- The elements related to x ∈ α by the kernel of f are those in the preimage of f(x) under f. -/\ntheorem ker_iff_mem_preimage {α : Type u_1} {β : Type u_2} {f : α → β} {x : α} {y : α} :\n    rel (ker f) x y ↔ x ∈ f ⁻¹' singleton (f y) :=\n  iff.rfl\n\n/-- Equivalence between functions `α → β` such that `r x y → f x = f y` and functions\n`quotient r → β`. -/\ndef lift_equiv {α : Type u_1} {β : Type u_2} (r : setoid α) :\n    (Subtype fun (f : α → β) => r ≤ ker f) ≃ (quotient r → β) :=\n  equiv.mk (fun (f : Subtype fun (f : α → β) => r ≤ ker f) => quotient.lift ↑f sorry)\n    (fun (f : quotient r → β) => { val := f ∘ quotient.mk, property := sorry }) sorry sorry\n\n/-- The uniqueness part of the universal property for quotients of an arbitrary type. -/\ntheorem lift_unique {α : Type u_1} {β : Type u_2} {r : setoid α} {f : α → β} (H : r ≤ ker f)\n    (g : quotient r → β) (Hg : f = g ∘ quotient.mk) : quotient.lift f H = g :=\n  sorry\n\n/-- Given a map f from α to β, the natural map from the quotient of α by the kernel of f is\n    injective. -/\ntheorem ker_lift_injective {α : Type u_1} {β : Type u_2} (f : α → β) :\n    function.injective (quotient.lift f fun (_x _x_1 : α) (h : _x ≈ _x_1) => h) :=\n  sorry\n\n/-- Given a map f from α to β, the kernel of f is the unique equivalence relation on α whose\n    induced map from the quotient of α to β is injective. -/\ntheorem ker_eq_lift_of_injective {α : Type u_1} {β : Type u_2} {r : setoid α} (f : α → β)\n    (H : ∀ (x y : α), rel r x y → f x = f y) (h : function.injective (quotient.lift f H)) :\n    ker f = r :=\n  sorry\n\n/-- The first isomorphism theorem for sets: the quotient of α by the kernel of a function f\n    bijects with f's image. -/\ndef quotient_ker_equiv_range {α : Type u_1} {β : Type u_2} (f : α → β) :\n    quotient (ker f) ≃ ↥(set.range f) :=\n  equiv.of_bijective\n    (quotient.lift (fun (x : α) => { val := f x, property := set.mem_range_self x }) sorry) sorry\n\n/-- The quotient of α by the kernel of a surjective function f bijects with f's codomain. -/\ndef quotient_ker_equiv_of_surjective {α : Type u_1} {β : Type u_2} (f : α → β)\n    (hf : function.surjective f) : quotient (ker f) ≃ β :=\n  equiv.trans (quotient_ker_equiv_range f) (equiv.subtype_univ_equiv hf)\n\n/-- Given a function `f : α → β` and equivalence relation `r` on `α`, the equivalence\n    closure of the relation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are\n    related to the elements of `f⁻¹(y)` by `r`.' -/\ndef map {α : Type u_1} {β : Type u_2} (r : setoid α) (f : α → β) : setoid β :=\n  eqv_gen.setoid fun (x y : β) => ∃ (a : α), ∃ (b : α), f a = x ∧ f b = y ∧ rel r a b\n\n/-- Given a surjective function f whose kernel is contained in an equivalence relation r, the\n    equivalence relation on f's codomain defined by x ≈ y ↔ the elements of f⁻¹(x) are related to\n    the elements of f⁻¹(y) by r. -/\ndef map_of_surjective {α : Type u_1} {β : Type u_2} (r : setoid α) (f : α → β) (h : ker f ≤ r)\n    (hf : function.surjective f) : setoid β :=\n  mk (fun (x y : β) => ∃ (a : α), ∃ (b : α), f a = x ∧ f b = y ∧ rel r a b) sorry\n\n/-- A special case of the equivalence closure of an equivalence relation r equalling r. -/\ntheorem map_of_surjective_eq_map {α : Type u_1} {β : Type u_2} {r : setoid α} {f : α → β}\n    (h : ker f ≤ r) (hf : function.surjective f) : map r f = map_of_surjective r f h hf :=\n  sorry\n\n/-- Given a function `f : α → β`, an equivalence relation `r` on `β` induces an equivalence\n    relation on `α` defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `r`'. -/\ndef comap {α : Type u_1} {β : Type u_2} (f : α → β) (r : setoid β) : setoid α :=\n  mk (fun (x y : α) => rel r (f x) (f y)) sorry\n\n/-- Given a map `f : N → M` and an equivalence relation `r` on `β`, the equivalence relation\n    induced on `α` by `f` equals the kernel of `r`'s quotient map composed with `f`. -/\ntheorem comap_eq {α : Type u_1} {β : Type u_2} {f : α → β} {r : setoid β} :\n    comap f r = ker (quotient.mk ∘ f) :=\n  sorry\n\n/-- The second isomorphism theorem for sets. -/\ndef comap_quotient_equiv {α : Type u_1} {β : Type u_2} (f : α → β) (r : setoid β) :\n    quotient (comap f r) ≃ ↥(set.range (quotient.mk ∘ f)) :=\n  equiv.trans (quotient.congr_right sorry) (quotient_ker_equiv_range (quotient.mk ∘ f))\n\n/-- The third isomorphism theorem for sets. -/\ndef quotient_quotient_equiv_quotient {α : Type u_1} (r : setoid α) (s : setoid α) (h : r ≤ s) :\n    quotient (ker (quot.map_right h)) ≃ quotient s :=\n  equiv.mk\n    (fun (x : quotient (ker (quot.map_right h))) =>\n      quotient.lift_on' x\n        (fun (w : Quot fun (x y : α) => rel r x y) => quotient.lift_on' w quotient.mk sorry) sorry)\n    (fun (x : quotient s) => quotient.lift_on' x (fun (w : α) => quotient.mk (quotient.mk w)) sorry)\n    sorry sorry\n\n/-- Given an equivalence relation `r` on `α`, the order-preserving bijection between the set of\nequivalence relations containing `r` and the equivalence relations on the quotient of `α` by `r`. -/\ndef correspondence {α : Type u_1} (r : setoid α) :\n    (Subtype fun (s : setoid α) => r ≤ s) ≃o setoid (quotient r) :=\n  rel_iso.mk\n    (equiv.mk\n      (fun (s : Subtype fun (s : setoid α) => r ≤ s) =>\n        map_of_surjective (subtype.val s) quotient.mk sorry quotient.exists_rep)\n      (fun (s : setoid (quotient r)) => { val := comap quotient.mk s, property := sorry }) sorry\n      sorry)\n    sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/setoid/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.6757645944891559, "lm_q1q2_score": 0.45200559791141565}}
{"text": "example (P Q R S T U: Type)\n(p : P)\n(h : P → Q)\n(i : Q → R)\n(j : Q → T)\n(k : S → T)\n(l : T → U)\n: U :=\nbegin\nhave q : Q := h(p),\nhave t := j(q),\nhave u := l(t),\nexact u,\nend\n", "meta": {"author": "chanha-park", "repo": "naturalNumberGame", "sha": "4e0d7100ce4575e1add92feefa38b1250431b879", "save_path": "github-repos/lean/chanha-park-naturalNumberGame", "path": "github-repos/lean/chanha-park-naturalNumberGame/naturalNumberGame-4e0d7100ce4575e1add92feefa38b1250431b879/Function/3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624789529375, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.4519839541001593}}
{"text": "import category_theory.equivalence\n\nopen category_theory\n\nvariables {C : Type*} [category C]\nvariables {D : Type*} [category D]\n\nlemma equiv_reflects_mono {X Y : C} (f : X ⟶ Y) (e : C ≌ D)\n  (hef : mono (e.functor.map f)) : mono f :=\nbegin\n  split,\n  intros Z g h w,\n  apply e.functor.map_injective,\n  -- That looks pretty good, we're in a position where we can apply `hef`.\n  -- The relevant lemma is `cancel_mono`, which says\n  --   `g ≫ f = h ≫ f ↔ g = h ` whenever `f` is a mono\n  -- This is an iff, so we can either using `rw ←cancel_mono ...` or `apply (cancel_mono ...).1`.\n  sorry,\nend\n", "meta": {"author": "leanprover-community", "repo": "lftcm2020", "sha": "cc683e2b074b61909310746d6acc1fb3d42d6ee2", "save_path": "github-repos/lean/leanprover-community-lftcm2020", "path": "github-repos/lean/leanprover-community-lftcm2020/lftcm2020-cc683e2b074b61909310746d6acc1fb3d42d6ee2/src/hints/category_theory/exercise3/hint3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624688140728, "lm_q2_score": 0.5774953651858118, "lm_q1q2_score": 0.451983948245012}}
{"text": "/-\nCopyright (c) 2021 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.over\nimport Mathlib.category_theory.limits.preserves.basic\nimport Mathlib.category_theory.limits.creates\nimport Mathlib.category_theory.limits.shapes.binary_products\nimport Mathlib.category_theory.monad.algebra\nimport Mathlib.PostPort\n\nuniverses u v \n\nnamespace Mathlib\n\n/-!\n# Algebras for the coproduct monad\n\nThe functor `Y ↦ X ⨿ Y` forms a monad, whose category of monads is equivalent to the under category\nof `X`. Similarly, `Y ↦ X ⨯ Y` forms a comonad, whose category of comonads is equivalent to the\nover category of `X`.\n\n## TODO\n\nShow that `over.forget X : over X ⥤ C` is a comonadic left adjoint and `under.forget : under X ⥤ C`\nis a monadic right adjoint.\n-/\n\nnamespace category_theory\n\n\n/-- `X ⨯ -` has a comonad structure. This is sometimes called the writer comonad. -/\nprotected instance obj.comonad {C : Type u} [category C] (X : C) [limits.has_binary_products C] : comonad (functor.obj limits.prod.functor X) :=\n  comonad.mk (nat_trans.mk fun (Y : C) => limits.prod.snd)\n    (nat_trans.mk fun (Y : C) => limits.prod.lift limits.prod.fst 𝟙)\n\n/--\nThe forward direction of the equivalence from coalgebras for the product comonad to the over\ncategory.\n-/\ndef coalgebra_to_over {C : Type u} [category C] (X : C) [limits.has_binary_products C] : comonad.coalgebra (functor.obj limits.prod.functor X) ⥤ over X :=\n  functor.mk\n    (fun (A : comonad.coalgebra (functor.obj limits.prod.functor X)) => over.mk (comonad.coalgebra.a A ≫ limits.prod.fst))\n    fun (A₁ A₂ : comonad.coalgebra (functor.obj limits.prod.functor X)) (f : A₁ ⟶ A₂) =>\n      over.hom_mk (comonad.coalgebra.hom.f f)\n\n/--\nThe backward direction of the equivalence from coalgebras for the product comonad to the over\ncategory.\n-/\n@[simp] theorem over_to_coalgebra_map_f {C : Type u} [category C] (X : C) [limits.has_binary_products C] (f₁ : over X) (f₂ : over X) (g : f₁ ⟶ f₂) : comonad.coalgebra.hom.f (functor.map (over_to_coalgebra X) g) = comma_morphism.left g :=\n  Eq.refl (comonad.coalgebra.hom.f (functor.map (over_to_coalgebra X) g))\n\n/-- The equivalence from coalgebras for the product comonad to the over category. -/\ndef coalgebra_equiv_over {C : Type u} [category C] (X : C) [limits.has_binary_products C] : comonad.coalgebra (functor.obj limits.prod.functor X) ≌ over X :=\n  equivalence.mk' (coalgebra_to_over X) (over_to_coalgebra X)\n    (nat_iso.of_components\n      (fun (A : comonad.coalgebra (functor.obj limits.prod.functor X)) =>\n        comonad.coalgebra.iso_mk (iso.refl (comonad.coalgebra.A (functor.obj 𝟭 A))) sorry)\n      sorry)\n    (nat_iso.of_components\n      (fun (f : over X) =>\n        over.iso_mk (iso.refl (comma.left (functor.obj (over_to_coalgebra X ⋙ coalgebra_to_over X) f))))\n      sorry)\n\n/-- `X ⨿ -` has a monad structure. This is sometimes called the either monad. -/\n@[simp] theorem obj.monad_μ_app {C : Type u} [category C] (X : C) [limits.has_binary_coproducts C] (Y : C) : nat_trans.app μ_ Y = limits.coprod.desc limits.coprod.inl 𝟙 :=\n  Eq.refl (nat_trans.app μ_ Y)\n\n/--\nThe forward direction of the equivalence from algebras for the coproduct monad to the under\ncategory.\n-/\ndef algebra_to_under {C : Type u} [category C] (X : C) [limits.has_binary_coproducts C] : monad.algebra (functor.obj limits.coprod.functor X) ⥤ under X :=\n  functor.mk\n    (fun (A : monad.algebra (functor.obj limits.coprod.functor X)) => under.mk (limits.coprod.inl ≫ monad.algebra.a A))\n    fun (A₁ A₂ : monad.algebra (functor.obj limits.coprod.functor X)) (f : A₁ ⟶ A₂) =>\n      under.hom_mk (monad.algebra.hom.f f)\n\n/--\nThe backward direction of the equivalence from algebras for the coproduct monad to the under\ncategory.\n-/\n@[simp] theorem under_to_algebra_obj_A {C : Type u} [category C] (X : C) [limits.has_binary_coproducts C] (f : under X) : monad.algebra.A (functor.obj (under_to_algebra X) f) = comma.right f :=\n  Eq.refl (monad.algebra.A (functor.obj (under_to_algebra X) f))\n\n/--\nThe equivalence from algebras for the coproduct monad to the under category.\n-/\n@[simp] theorem algebra_equiv_under_unit_iso {C : Type u} [category C] (X : C) [limits.has_binary_coproducts C] : equivalence.unit_iso (algebra_equiv_under X) =\n  nat_iso.of_components\n    (fun (A : monad.algebra (functor.obj limits.coprod.functor X)) =>\n      monad.algebra.iso_mk (iso.refl (monad.algebra.A (functor.obj 𝟭 A))) (algebra_equiv_under._proof_1 X A))\n    (algebra_equiv_under._proof_2 X) :=\n  Eq.refl (equivalence.unit_iso (algebra_equiv_under X))\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monad/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943822145998, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4519736876059119}}
{"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport linear_algebra.finite_dimensional\nimport geometry.manifold.smooth_manifold_with_corners\nimport analysis.inner_product_space.pi_L2\n\n/-!\n# Constructing examples of manifolds over ℝ\n\nWe introduce the necessary bits to be able to define manifolds modelled over `ℝ^n`, boundaryless\nor with boundary or with corners. As a concrete example, we construct explicitly the manifold with\nboundary structure on the real interval `[x, y]`.\n\nMore specifically, we introduce\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)` for the model space\n  used to define `n`-dimensional real manifolds with boundary\n* `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n)` for the model space used\n  to define `n`-dimensional real manifolds with corners\n\n## Notations\n\nIn the locale `manifold`, we introduce the notations\n* `𝓡 n` for the identity model with corners on `euclidean_space ℝ (fin n)`\n* `𝓡∂ n` for `model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space ℝ (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M → N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (𝓡 m) (𝓡∂ n) f` (as to why the\nmodel with corners can not be implicit, see the discussion in `smooth_manifold_with_corners.lean`).\n\n## Implementation notes\n\nThe manifold structure on the interval `[x, y] = Icc x y` requires the assumption `x < y` as a\ntypeclass. We provide it as `[fact (x < y)]`.\n-/\n\nnoncomputable theory\nopen set function\nopen_locale manifold\n\n/--\nThe half-space in `ℝ^n`, used to model manifolds with boundary. We only define it when\n`1 ≤ n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : ℕ) [has_zero (fin n)] : Type :=\n{x : euclidean_space ℝ (fin n) // 0 ≤ x 0}\n\n/--\nThe quadrant in `ℝ^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : ℕ) : Type := {x : euclidean_space ℝ (fin n) // ∀i:fin n, 0 ≤ x i}\n\nsection\n/- Register class instances for euclidean half-space and quadrant, that can not be noticed\nwithout the following reducibility attribute (which is only set in this section). -/\nlocal attribute [reducible] euclidean_half_space euclidean_quadrant\nvariable {n : ℕ}\n\ninstance [has_zero (fin n)] : topological_space (euclidean_half_space n) := by apply_instance\ninstance : topological_space (euclidean_quadrant n) := by apply_instance\ninstance [has_zero (fin n)] : inhabited (euclidean_half_space n) := ⟨⟨0, le_rfl⟩⟩\ninstance : inhabited (euclidean_quadrant n) := ⟨⟨0, λ i, le_rfl⟩⟩\n\nlemma range_half_space (n : ℕ) [has_zero (fin n)] :\n  range (λx : euclidean_half_space n, x.val) = {y | 0 ≤ y 0} :=\nby simp\n\nlemma range_quadrant (n : ℕ) :\n  range (λx : euclidean_quadrant n, x.val) = {y | ∀i:fin n, 0 ≤ y i} :=\nby simp\n\nend\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_half_space n)`, used as\na model for manifolds with boundary. In the locale `manifold`, use the shortcut `𝓡∂ n`.\n-/\ndef model_with_corners_euclidean_half_space (n : ℕ) [has_zero (fin n)] :\n  model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := λx, ⟨update x 0 (max (x 0) 0), by simp [le_refl]⟩,\n  source      := univ,\n  target      := {x | 0 ≤ x 0},\n  map_source' := λx hx, x.property,\n  map_target' := λx hx, mem_univ _,\n  left_inv'   := λ ⟨xval, xprop⟩ hx, begin\n    rw [subtype.mk_eq_mk, update_eq_iff],\n    exact ⟨max_eq_left xprop, λ i _, rfl⟩\n  end,\n  right_inv'  := λx hx, update_eq_iff.2 ⟨max_eq_left hx, λ i _, rfl⟩,\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on ℝ _ :=\n      unique_diff_on.pi (fin n) (λ _, ℝ) _ _ (λ i ∈ ({0} : set (fin n)), unique_diff_on_Ici 0),\n    by simpa only [singleton_pi] using this,\n  continuous_to_fun  := continuous_subtype_val,\n  continuous_inv_fun := continuous_subtype_mk _ $ continuous_id.update 0 $\n    (continuous_apply 0).max continuous_const }\n\n/--\nDefinition of the model with corners `(euclidean_space ℝ (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : ℕ) :\n  model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_quadrant n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := λx, ⟨λi, max (x i) 0, λi, by simp only [le_refl, or_true, le_max_iff]⟩,\n  source      := univ,\n  target      := {x | ∀ i, 0 ≤ x i},\n  map_source' := λx hx, by simpa only [subtype.range_val] using x.property,\n  map_target' := λx hx, mem_univ _,\n  left_inv'   := λ ⟨xval, xprop⟩ hx, by { ext i, simp only [subtype.coe_mk, xprop i, max_eq_left] },\n  right_inv' := λ x hx, by { ext1 i, simp only [hx i, max_eq_left] },\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on ℝ _ :=\n      unique_diff_on.univ_pi (fin n) (λ _, ℝ) _ (λ i, unique_diff_on_Ici 0),\n    by simpa only [pi_univ_Ici] using this,\n  continuous_to_fun  := continuous_subtype_val,\n  continuous_inv_fun := continuous_subtype_mk _ $ continuous_pi $ λ i,\n    (continuous_id.max continuous_const).comp (continuous_apply i) }\n\nlocalized \"notation `𝓡 `n :=\n  (model_with_corners_self ℝ (euclidean_space ℝ (fin n)) :\n    model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_space ℝ (fin n)))\" in manifold\nlocalized \"notation `𝓡∂ `n :=\n  (model_with_corners_euclidean_half_space n :\n    model_with_corners ℝ (euclidean_space ℝ (fin n)) (euclidean_half_space n))\" in manifold\n\n/--\nThe left chart for the topological space `[x, y]`, defined on `[x,y)` and sending `x` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_left_chart (x y : ℝ) [fact (x < y)] :\n  local_homeomorph (Icc x y) (euclidean_half_space 1) :=\n{ source      := {z : Icc x y | z.val < y},\n  target      := {z : euclidean_half_space 1 | z.val 0 < y - x},\n  to_fun      := λ(z : Icc x y), ⟨λi, z.val - x, sub_nonneg.mpr z.property.1⟩,\n  inv_fun     := λz, ⟨min (z.val 0 + x) y, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y))]⟩,\n  map_source' := by simp only [imp_self, sub_lt_sub_iff_right, mem_set_of_eq, forall_true_iff],\n  map_target' :=\n    by { simp only [min_lt_iff, mem_set_of_eq], assume z hz, left,\n         dsimp [-subtype.val_eq_coe] at hz, linarith },\n  left_inv'   := begin\n    rintros ⟨z, hz⟩ h'z,\n    simp only [mem_set_of_eq, mem_Icc] at hz h'z,\n    simp only [hz, min_eq_left, sub_add_cancel]\n  end,\n  right_inv'  := begin\n    rintros ⟨z, hz⟩ h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x + z 0 ≤ y, by linarith,\n    rw subsingleton.elim i 0,\n    simp only [A, add_comm, add_sub_cancel', min_eq_left],\n  end,\n  open_source := begin\n    have : is_open {z : ℝ | z < y} := is_open_Iio,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : ℝ | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space ℝ (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (λ _, ℝ) _ 0),\n    exact this.preimage continuous_subtype_val\n  end,\n  continuous_to_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have : continuous (λ (z : ℝ) (i : fin 1), z - x) :=\n      continuous.sub (continuous_pi $ λi, continuous_id) continuous_const,\n    exact this.comp continuous_subtype_val,\n  end,\n  continuous_inv_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have A : continuous (λ z : ℝ, min (z + x) y) :=\n      (continuous_id.add continuous_const).min continuous_const,\n    have B : continuous (λz : euclidean_space ℝ (fin 1), z 0) := continuous_apply 0,\n    exact (A.comp B).comp continuous_subtype_val\n  end }\n\n/--\nThe right chart for the topological space `[x, y]`, defined on `(x,y]` and sending `y` to `0` in\n`euclidean_half_space 1`.\n-/\ndef Icc_right_chart (x y : ℝ) [fact (x < y)] :\n  local_homeomorph (Icc x y) (euclidean_half_space 1) :=\n{ source      := {z : Icc x y | x < z.val},\n  target      := {z : euclidean_half_space 1 | z.val 0 < y - x},\n  to_fun      := λ(z : Icc x y), ⟨λi, y - z.val, sub_nonneg.mpr z.property.2⟩,\n  inv_fun     := λz,\n    ⟨max (y - z.val 0) x, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y)), sub_eq_add_neg]⟩,\n  map_source' := by simp only [imp_self, mem_set_of_eq, sub_lt_sub_iff_left, forall_true_iff],\n  map_target' :=\n    by { simp only [lt_max_iff, mem_set_of_eq], assume z hz, left,\n         dsimp [-subtype.val_eq_coe] at hz, linarith },\n  left_inv'   := begin\n    rintros ⟨z, hz⟩ h'z,\n    simp only [mem_set_of_eq, mem_Icc] at hz h'z,\n    simp only [hz, sub_eq_add_neg, max_eq_left, add_add_neg_cancel'_right, neg_add_rev, neg_neg]\n  end,\n  right_inv'  := begin\n    rintros ⟨z, hz⟩ h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x ≤ y - z 0, by linarith,\n    rw subsingleton.elim i 0,\n    simp only [A, sub_sub_cancel, max_eq_left],\n  end,\n  open_source := begin\n    have : is_open {z : ℝ | x < z} := is_open_Ioi,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : ℝ | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space ℝ (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (λ _, ℝ) _ 0),\n    exact this.preimage continuous_subtype_val\n  end,\n  continuous_to_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have : continuous (λ (z : ℝ) (i : fin 1), y - z) :=\n      continuous_const.sub (continuous_pi (λi, continuous_id)),\n    exact this.comp continuous_subtype_val,\n  end,\n  continuous_inv_fun := begin\n    apply continuous.continuous_on,\n    apply continuous_subtype_mk,\n    have A : continuous (λ z : ℝ, max (y - z) x) :=\n      (continuous_const.sub continuous_id).max continuous_const,\n    have B : continuous (λz : euclidean_space ℝ (fin 1), z 0) := continuous_apply 0,\n    exact (A.comp B).comp continuous_subtype_val\n  end }\n\n/--\nCharted space structure on `[x, y]`, using only two charts taking values in\n`euclidean_half_space 1`.\n-/\ninstance Icc_manifold (x y : ℝ) [fact (x < y)] : charted_space (euclidean_half_space 1) (Icc x y) :=\n{ atlas := {Icc_left_chart x y, Icc_right_chart x y},\n  chart_at := λz, if z.val < y then Icc_left_chart x y else Icc_right_chart x y,\n  mem_chart_source := λz, begin\n    by_cases h' : z.val < y,\n    { simp only [h', if_true],\n      exact h' },\n    { simp only [h', if_false],\n      apply lt_of_lt_of_le (fact.out (x < y)),\n      simpa only [not_lt] using h'}\n  end,\n  chart_mem_atlas := λ z, by by_cases h' : (z : ℝ) < y; simp [h'] }\n\n/--\nThe manifold structure on `[x, y]` is smooth.\n-/\ninstance Icc_smooth_manifold (x y : ℝ) [fact (x < y)] :\n  smooth_manifold_with_corners (𝓡∂ 1) (Icc x y) :=\nbegin\n  have M : times_cont_diff_on ℝ ∞ (λz : euclidean_space ℝ (fin 1), - z + (λi, y - x)) univ,\n  { rw times_cont_diff_on_univ,\n    exact times_cont_diff_id.neg.add times_cont_diff_const },\n  apply smooth_manifold_with_corners_of_times_cont_diff_on,\n  assume e e' he he',\n  simp only [atlas, mem_singleton_iff, mem_insert_iff] at he he',\n  /- We need to check that any composition of two charts gives a `C^∞` function. Each chart can be\n  either the left chart or the right chart, leaving 4 possibilities that we handle successively.\n  -/\n  rcases he with rfl | rfl; rcases he' with rfl | rfl,\n  { -- `e = left chart`, `e' = left chart`\n    exact (mem_groupoid_of_pregroupoid.mpr (symm_trans_mem_times_cont_diff_groupoid _ _ _)).1 },\n  { -- `e = left chart`, `e' = right chart`\n    apply M.congr_mono _ (subset_univ _),\n    rintro _ ⟨⟨hz₁, hz₂⟩, ⟨⟨z, hz₀⟩, rfl⟩⟩,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      update_same, max_eq_left, hz₀, lt_sub_iff_add_lt] with mfld_simps at hz₁ hz₂,\n    rw [min_eq_left hz₁.le, lt_add_iff_pos_left] at hz₂,\n    ext i,\n    rw subsingleton.elim i 0,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart, *,\n      pi_Lp.add_apply, pi_Lp.neg_apply, max_eq_left, min_eq_left hz₁.le, update_same]\n      with mfld_simps,\n    abel },\n  { -- `e = right chart`, `e' = left chart`\n    apply M.congr_mono _ (subset_univ _),\n    rintro _ ⟨⟨hz₁, hz₂⟩, ⟨z, hz₀⟩, rfl⟩,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart, max_lt_iff,\n      update_same, max_eq_left hz₀] with mfld_simps at hz₁ hz₂,\n    rw lt_sub at hz₁,\n    ext i,\n    rw subsingleton.elim i 0,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      pi_Lp.add_apply, pi_Lp.neg_apply, update_same, max_eq_left, hz₀, hz₁.le] with mfld_simps,\n    abel },\n  { -- `e = right chart`, `e' = right chart`\n    exact (mem_groupoid_of_pregroupoid.mpr (symm_trans_mem_times_cont_diff_groupoid _ _ _)).1 }\nend\n\n/-! Register the manifold structure on `Icc 0 1`, and also its zero and one. -/\nsection\n\nlemma fact_zero_lt_one : fact ((0 : ℝ) < 1) := ⟨zero_lt_one⟩\n\nlocal attribute [instance] fact_zero_lt_one\n\ninstance : charted_space (euclidean_half_space 1) (Icc (0 : ℝ) 1) := by apply_instance\ninstance : smooth_manifold_with_corners (𝓡∂ 1) (Icc (0 : ℝ) 1) := by apply_instance\n\nend\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/geometry/manifold/instances/real.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.45197368108095765}}
{"text": "/-\nCopyright (c) 2020 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport linear_algebra.isomorphisms\nimport algebra.category.Module.kernels\nimport algebra.category.Module.limits\nimport category_theory.abelian.exact\n\n/-!\n# The category of left R-modules is abelian.\n\nAdditionally, two linear maps are exact in the categorical sense iff `range f = ker g`.\n-/\n\nopen category_theory\nopen category_theory.limits\n\nnoncomputable theory\n\nuniverses v u\n\nnamespace Module\nvariables {R : Type u} [ring R] {M N : Module.{v} R} (f : M ⟶ N)\n\n/-- In the category of modules, every monomorphism is normal. -/\ndef normal_mono (hf : mono f) : normal_mono f :=\n{ Z := of R (N ⧸ f.range),\n  g := f.range.mkq,\n  w := linear_map.range_mkq_comp _,\n  is_limit :=\n    is_kernel.iso_kernel _ _ (kernel_is_limit _)\n      /- The following [invalid Lean code](https://github.com/leanprover-community/lean/issues/341)\n        might help you understand what's going on here:\n        ```\n        calc\n        M   ≃ₗ[R] f.ker.quotient  : (submodule.quot_equiv_of_eq_bot _ (ker_eq_bot_of_mono _)).symm\n        ... ≃ₗ[R] f.range         : linear_map.quot_ker_equiv_range f\n        ... ≃ₗ[R] r.range.mkq.ker : linear_equiv.of_eq _ _ (submodule.ker_mkq _).symm\n        ```\n      -/\n      (linear_equiv.to_Module_iso'\n        ((submodule.quot_equiv_of_eq_bot _ (ker_eq_bot_of_mono _)).symm ≪≫ₗ\n          ((linear_map.quot_ker_equiv_range f) ≪≫ₗ\n            (linear_equiv.of_eq _ _ (submodule.ker_mkq _).symm)))) $\n      by { ext, refl } }\n\n/-- In the category of modules, every epimorphism is normal. -/\ndef normal_epi (hf : epi f) : normal_epi f :=\n{ W := of R f.ker,\n  g := f.ker.subtype,\n  w := linear_map.comp_ker_subtype _,\n  is_colimit :=\n    is_cokernel.cokernel_iso _ _ (cokernel_is_colimit _)\n      (linear_equiv.to_Module_iso'\n      /- The following invalid Lean code might help you understand what's going on here:\n        ```\n        calc f.ker.subtype.range.quotient\n            ≃ₗ[R] f.ker.quotient : submodule.quot_equiv_of_eq _ _ (submodule.range_subtype _)\n        ... ≃ₗ[R] f.range        : linear_map.quot_ker_equiv_range f\n        ... ≃ₗ[R] N              : linear_equiv.of_top _ (range_eq_top_of_epi _)\n        ```\n      -/\n        (((submodule.quot_equiv_of_eq _ _ (submodule.range_subtype _)) ≪≫ₗ\n          (linear_map.quot_ker_equiv_range f)) ≪≫ₗ\n          (linear_equiv.of_top _ (range_eq_top_of_epi _)))) $\n      by { ext, refl } }\n\n/-- The category of R-modules is abelian. -/\ninstance : abelian (Module R) :=\n{ has_finite_products := ⟨by apply_instance⟩,\n  has_kernels := by apply_instance,\n  has_cokernels := has_cokernels_Module,\n  normal_mono := λ X Y, normal_mono,\n  normal_epi := λ X Y, normal_epi }\n\nvariables {O : Module.{v} R} (g : N ⟶ O)\n\nopen linear_map\nlocal attribute [instance] preadditive.has_equalizers_of_has_kernels\n\ntheorem exact_iff : exact f g ↔ f.range = g.ker :=\nbegin\n  rw abelian.exact_iff' f g (kernel_is_limit _) (cokernel_is_colimit _),\n  exact ⟨λ h, le_antisymm (range_le_ker_iff.2 h.1) (ker_le_range_iff.2 h.2),\n    λ h, ⟨range_le_ker_iff.1 $ le_of_eq h, ker_le_range_iff.1 $ le_of_eq h.symm⟩⟩\nend\n\nend Module\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/category/Module/abelian.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.45197368108095753}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta\n-/\nimport category_theory.limits.shapes.terminal\nimport category_theory.limits.preserves.basic\n\n/-!\n# Preserving terminal object\n\nConstructions to relate the notions of preserving terminal objects and reflecting terminal objects\nto concrete objects.\n\nIn particular, we show that `terminal_comparison G` is an isomorphism iff `G` preserves terminal\nobjects.\n-/\n\nuniverses v v₁ v₂ u u₁ u₂\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u₁} [category.{v₁} C]\nvariables {D : Type u₂} [category.{v₂} D]\nvariables (G : C ⥤ D)\n\nnamespace category_theory.limits\n\nvariables (X : C)\n\nsection terminal\n\n/--\nThe map of an empty cone is a limit iff the mapped object is terminal.\n-/\ndef is_limit_map_cone_empty_cone_equiv :\n  is_limit (G.map_cone (as_empty_cone.{v₁} X)) ≃ is_terminal (G.obj X) :=\nis_limit_empty_cone_equiv D _ _ (eq_to_iso rfl)\n\n/-- The property of preserving terminal objects expressed in terms of `is_terminal`. -/\ndef is_terminal.is_terminal_obj [preserves_limit (functor.empty.{v₁} C) G]\n  (l : is_terminal X) : is_terminal (G.obj X) :=\nis_limit_map_cone_empty_cone_equiv G X (preserves_limit.preserves l)\n\n/-- The property of reflecting terminal objects expressed in terms of `is_terminal`. -/\ndef is_terminal.is_terminal_of_obj [reflects_limit (functor.empty.{v₁} C) G]\n  (l : is_terminal (G.obj X)) : is_terminal X :=\nreflects_limit.reflects ((is_limit_map_cone_empty_cone_equiv G X).symm l)\n\nvariables [has_terminal C]\n/--\nIf `G` preserves the terminal object and `C` has a terminal object, then the image of the terminal\nobject is terminal.\n-/\ndef is_limit_of_has_terminal_of_preserves_limit [preserves_limit (functor.empty.{v₁} C) G] :\n  is_terminal (G.obj (⊤_ C)) :=\nterminal_is_terminal.is_terminal_obj G (⊤_ C)\n\n/--\nIf `C` has a terminal object and `G` preserves terminal objects, then `D` has a terminal object\nalso.\nNote this property is somewhat unique to (co)limits of the empty diagram: for general `J`, if `C`\nhas limits of shape `J` and `G` preserves them, then `D` does not necessarily have limits of shape\n`J`.\n-/\nlemma has_terminal_of_has_terminal_of_preserves_limit [preserves_limit (functor.empty.{v₁} C) G] :\n  has_terminal D :=\n⟨λ F,\nbegin\n  haveI := has_limit.mk ⟨_, is_limit_of_has_terminal_of_preserves_limit G⟩,\n  apply has_limit_of_iso F.unique_from_empty.symm,\nend⟩\n\nvariable [has_terminal D]\n/--\nIf the terminal comparison map for `G` is an isomorphism, then `G` preserves terminal objects.\n-/\ndef preserves_terminal.of_iso_comparison\n  [i : is_iso (terminal_comparison G)] : preserves_limit (functor.empty C) G :=\nbegin\n  apply preserves_limit_of_preserves_limit_cone terminal_is_terminal,\n  apply (is_limit_map_cone_empty_cone_equiv _ _).symm _,\n  apply is_limit.of_point_iso (limit.is_limit (functor.empty.{v₂} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `G.obj ⊤ ⟶ ⊤`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_is_iso\n  (f : G.obj (⊤_ C) ⟶ ⊤_ D) [i : is_iso f] : preserves_limit (functor.empty C) G :=\nbegin\n  rw subsingleton.elim f (terminal_comparison G) at i,\n  exactI preserves_terminal.of_iso_comparison G,\nend\n\n/-- If there is any isomorphism `G.obj ⊤ ≅ ⊤`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_iso\n  (f : G.obj (⊤_ C) ≅ ⊤_ D) : preserves_limit (functor.empty C) G :=\npreserves_terminal_of_is_iso G f.hom\n\nvariables [preserves_limit (functor.empty.{v₁} C) G]\n\n/--\nIf `G` preserves terminal objects, then the terminal comparison map for `G` is an isomorphism.\n-/\ndef preserves_terminal.iso : G.obj (⊤_ C) ≅ ⊤_ D :=\n(is_limit_of_has_terminal_of_preserves_limit G).cone_point_unique_up_to_iso (limit.is_limit _)\n\n@[simp]\nlemma preserves_terminal.iso_hom : (preserves_terminal.iso G).hom = terminal_comparison G :=\nrfl\n\ninstance : is_iso (terminal_comparison G) :=\nbegin\n  rw ← preserves_terminal.iso_hom,\n  apply_instance,\nend\n\nend terminal\n\nsection initial\n\n/--\nThe map of an empty cocone is a colimit iff the mapped object is initial.\n-/\ndef is_colimit_map_cocone_empty_cocone_equiv :\n  is_colimit (G.map_cocone (as_empty_cocone.{v₁} X)) ≃ is_initial (G.obj X) :=\nis_colimit_empty_cocone_equiv D _ _ (eq_to_iso rfl)\n\n/-- The property of preserving initial objects expressed in terms of `is_initial`. -/\ndef is_initial.is_initial_obj [preserves_colimit (functor.empty.{v₁} C) G]\n  (l : is_initial X) : is_initial (G.obj X) :=\nis_colimit_map_cocone_empty_cocone_equiv G X (preserves_colimit.preserves l)\n\n/-- The property of reflecting initial objects expressed in terms of `is_initial`. -/\ndef is_initial.is_initial_of_obj [reflects_colimit (functor.empty.{v₁} C) G]\n  (l : is_initial (G.obj X)) : is_initial X :=\nreflects_colimit.reflects ((is_colimit_map_cocone_empty_cocone_equiv G X).symm l)\n\nvariables [has_initial C]\n/--\nIf `G` preserves the initial object and `C` has a initial object, then the image of the initial\nobject is initial.\n-/\ndef is_colimit_of_has_initial_of_preserves_colimit [preserves_colimit (functor.empty.{v₁} C) G] :\n  is_initial (G.obj (⊥_ C)) :=\ninitial_is_initial.is_initial_obj G (⊥_ C)\n\n/--\nIf `C` has a initial object and `G` preserves initial objects, then `D` has a initial object\nalso.\nNote this property is somewhat unique to colimits of the empty diagram: for general `J`, if `C`\nhas colimits of shape `J` and `G` preserves them, then `D` does not necessarily have colimits of\nshape `J`.\n-/\nlemma has_initial_of_has_initial_of_preserves_colimit [preserves_colimit (functor.empty.{v₁} C) G] :\n  has_initial D :=\n⟨λ F,\nbegin\n  haveI := has_colimit.mk ⟨_, is_colimit_of_has_initial_of_preserves_colimit G⟩,\n  apply has_colimit_of_iso F.unique_from_empty,\nend⟩\n\nvariable [has_initial D]\n/--\nIf the initial comparison map for `G` is an isomorphism, then `G` preserves initial objects.\n-/\ndef preserves_initial.of_iso_comparison\n  [i : is_iso (initial_comparison G)] : preserves_colimit (functor.empty C) G :=\nbegin\n  apply preserves_colimit_of_preserves_colimit_cocone initial_is_initial,\n  apply (is_colimit_map_cocone_empty_cocone_equiv _ _).symm _,\n  apply is_colimit.of_point_iso (colimit.is_colimit (functor.empty.{v₂} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `⊥ ⟶ G.obj ⊥`, then `G` preserves initial objects. -/\ndef preserves_initial_of_is_iso\n  (f : ⊥_ D ⟶ G.obj (⊥_ C)) [i : is_iso f] : preserves_colimit (functor.empty C) G :=\nbegin\n  rw subsingleton.elim f (initial_comparison G) at i,\n  exactI preserves_initial.of_iso_comparison G,\nend\n\n/-- If there is any isomorphism `⊥ ≅ G.obj ⊥ `, then `G` preserves initial objects. -/\ndef preserves_initial_of_iso\n  (f : ⊥_ D ≅ G.obj (⊥_ C)) : preserves_colimit (functor.empty C) G :=\npreserves_initial_of_is_iso G f.hom\n\nvariables [preserves_colimit (functor.empty.{v₁} C) G]\n\n/-- If `G` preserves initial objects, then the initial comparison map for `G` is an isomorphism. -/\ndef preserves_initial.iso : G.obj (⊥_ C) ≅ ⊥_ D :=\n(is_colimit_of_has_initial_of_preserves_colimit G).cocone_point_unique_up_to_iso\n  (colimit.is_colimit _)\n\n@[simp]\nlemma preserves_initial.iso_hom : (preserves_initial.iso G).inv = initial_comparison G :=\nrfl\n\ninstance : is_iso (initial_comparison G) :=\nbegin\n  rw ← preserves_initial.iso_hom,\n  apply_instance,\nend\n\nend initial\n\nend category_theory.limits\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/category_theory/limits/preserves/shapes/terminal.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.757794360334681, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.451973674556003}}
{"text": "import Mathlib.Tactic.RunCmd\nimport Mathlib.Data.List.Basic\n\nnamespace Keller\n\ndef hasEdge' : List Nat → List Nat → Bool → Bool → Bool\n| a::l, b::r, found, n => if a = b then hasEdge' l r found n else\n  bif found || (b - a == 2 || a - b == 2) then\n    n || hasEdge' l r true true\n  else\n    hasEdge' l r false true\n| a, b, c, d => false\n\n@[implementedBy hasEdge'] def hasEdge : List Nat → List Nat → Bool → Bool → Bool := by\n  intro l; induction l with\n  | nil => exact fun _ _ _ => false\n  | cons a l ih => intro r; induction r with\n    | nil => exact fun _ _ => false\n    | cons b r => exact\n      bif a == b then ih r else fun found =>\n        bif found || (b - a == 2 || a - b == 2) then\n          fun n => n || ih r true true\n        else\n          fun _ => ih r false true\n\ninductive Dim2\n| _00 | _01 | _02 | _03\n| _10 | _11 | _12 | _13\n| _20 | _21 | _22 | _23\n| _30 | _31 | _32 | _33\nderiving DecidableEq, Repr\n\nopen Lean Elab Command in\nrun_cmd do\n  let mut s := #[]\n  for (a, arr) in #[\n    (`_00, #[`_02, `_12, `_20, `_21, `_23, `_32]),\n    (`_01, #[`_03, `_13, `_20, `_21, `_22, `_33]),\n    (`_02, #[`_21, `_22, `_23]),\n    (`_03, #[`_11, `_20, `_22, `_23, `_31]),\n    (`_10, #[`_12, `_31, `_33]),\n    (`_11, #[`_13, `_23, `_31]),\n    (`_12, #[`_20, `_31, `_32, `_33]),\n    (`_13, #[`_21, `_33]),\n    (`_20, #[`_22, `_32]),\n    (`_21, #[`_23, `_33]),\n    (`_23, #[`_31]),\n    (`_31, #[`_33])] do\n    for b in arr do\n      s := (s.push (a, b)).push (b, a)\n  let stx := s.map fun x => mkIdent $ x.1.updatePrefix default ++ x.2.updatePrefix default\n  let stx1 := s.map (mkIdent ·.1)\n  let stx2 := s.map (mkIdent ·.2)\n  elabCommand (← set_option hygiene false in `(\n    def Dim2.keller' : Dim2 → Dim2 → Bool\n    $[| $stx1, $stx2 => true]*\n    | _, _ => false\n\n    @[implementedBy Dim2.keller'] def Dim2.keller : Dim2 → Dim2 → Bool := by\n      intro g1 g2\n      induction g1 <;> induction g2\n      $[case $stx => exact true]*\n      all_goals exact false))\n\ndef Dim2.value : Dim2 → List (List Nat)\n| _00 => [[0, 2, 1, 1], [1, 1, 3, 2], [2, 3, 0, 3], [3, 0, 2, 0]]\n| _02 => [[2, 2, 1, 1], [1, 1, 3, 0], [0, 3, 0, 3], [3, 0, 2, 2]]\n| _21 => [[1, 0, 1, 1], [1, 3, 3, 1], [3, 1, 0, 3], [3, 2, 2, 3]]\n| _23 => [[1, 1, 1, 3], [1, 3, 2, 3], [3, 0, 0, 1], [3, 2, 3, 1]]\n| _12 => [[0, 0, 0, 0], [0, 2, 3, 0], [2, 1, 1, 2], [2, 3, 2, 2]]\n| _10 => [[0, 1, 0, 2], [0, 2, 2, 2], [2, 0, 1, 0], [2, 3, 3, 0]]\n| _33 => [[1, 2, 1, 0], [3, 3, 0, 2], [0, 0, 2, 3], [2, 1, 3, 1]]\n| _31 => [[3, 2, 1, 0], [1, 3, 0, 2], [0, 0, 2, 1], [2, 1, 3, 3]]\n| _20 => [[0, 2, 1, 3], [3, 1, 3, 2], [2, 3, 0, 1], [1, 0, 2, 0]]\n| _22 => [[2, 2, 1, 3], [3, 1, 3, 0], [0, 3, 0, 1], [1, 0, 2, 2]]\n| _01 => [[3, 1, 1, 1], [3, 3, 2, 1], [1, 0, 0, 3], [1, 2, 3, 3]]\n| _03 => [[3, 0, 1, 3], [3, 3, 3, 3], [1, 1, 0, 1], [1, 2, 2, 1]]\n| _32 => [[0, 0, 1, 2], [0, 3, 3, 2], [2, 1, 0, 0], [2, 2, 2, 0]]\n| _30 => [[0, 1, 1, 0], [0, 3, 2, 0], [2, 0, 0, 2], [2, 2, 3, 2]]\n| _13 => [[0, 1, 3, 1], [2, 0, 2, 3], [1, 2, 1, 2], [3, 3, 0, 0]]\n| _11 => [[0, 1, 3, 3], [2, 0, 2, 1], [3, 2, 1, 2], [1, 3, 0, 0]]\n\ntheorem Dim2.is_ok (g) : (Dim2.value g).Pairwise (fun a b => hasEdge a b false false) := by\n  cases g <;> decide\n\ndef dim4 : List (Dim2 × Dim2) := open Dim2 in\n[(_01, _00), (_03, _20), (_10, _12), (_10, _32),\n (_11, _20), (_12, _12), (_12, _32), (_13, _00),\n (_21, _00), (_23, _20), (_31, _02), (_31, _21),\n (_31, _23), (_33, _01), (_33, _03), (_33, _22)]\n\ndef Dim2.hasEdge (x y : Dim2) (found n : Bool) : Bool :=\n  x.value.all fun x => y.value.all fun y => Keller.hasEdge x y found n\n\ndef Dim2.ok₂ : Dim2 × Dim2 → Dim2 × Dim2 → Bool\n| (a1, a2), (b1, b2) =>\n  if a1 = b1 then a2.hasEdge b2 false false\n  else if a2 = b2 then a1.hasEdge b1 false false\n  else\n    let k1 := a1.keller b1\n    let k2 := a2.keller b2\n    let x1 := a1.hasEdge b1 (!k1) true\n    let x2 := a2.hasEdge b2 (!k2) true\n    x1 && x2 && (k1 || k2)\n\nset_option profiler true in -- takes about 8 seconds\ntheorem dim4_ok₂ : dim4.Pairwise (Dim2.ok₂ · ·) := by decide\n\ndef dim8 : List (List Nat) :=\n  dim4.bind (fun (a, b) => (a.value.bind fun a => (b.value.map fun b => a ++ b)))\n\ndef isClique (l : List (List Nat)) : Bool :=\n  l.all fun a => l.all fun b => a == b || hasEdge a b false false\n\n#eval isClique dim8 -- true\n", "meta": {"author": "JOSHCLUNE", "repo": "Keller_reduction", "sha": "dc392b3da352fc1ffcfbecb1d4717d05f5faed4a", "save_path": "github-repos/lean/JOSHCLUNE-Keller_reduction", "path": "github-repos/lean/JOSHCLUNE-Keller_reduction/Keller_reduction-dc392b3da352fc1ffcfbecb1d4717d05f5faed4a/Lean4_Clique/Clique/Clique.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432182679956, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.45190087870815654}}
{"text": "lemma at_most_two : ∀ (f : bool → bool) b x y z,\n    x = f b → y = f x → z = f y → z = x :=\nbegin\n    intros f b x y z h1 h2 h3,\n    induction b,\n        induction x,\n            rw ←h1 at h2,\n            rw h2 at h3,\n            simp [h3],\n            rw ←h1,\n        rw h1,\n        induction y,\n            assumption,\n        simp * at *,\n        rw ←h2,\n    induction x,\n        induction y,\n            rw ←h2 at h3,\n            assumption,\n        rw h3,\n        rw ←h1,\n    rw ←h1 at h2,\n    rw [h2, ←h1] at h3,\n    assumption,\nend\n\nexample : ∀ (f : bool → bool) b, f (f (f b)) = f b :=\nby intros; apply at_most_two; refl\n", "meta": {"author": "zeptometer", "repo": "LearnLean", "sha": "bb84d5dbe521127ba134d4dbf9559b294a80b9f7", "save_path": "github-repos/lean/zeptometer-LearnLean", "path": "github-repos/lean/zeptometer-LearnLean/LearnLean-bb84d5dbe521127ba134d4dbf9559b294a80b9f7/bluejam/topprover/04.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4519008712132011}}
{"text": "import tactic\n\nvariables {X : Type}\n\ndef P (Q : X → X → Prop) : X → X → Prop := λ x y, Q x y ∧ ¬ Q y x\n\n-- uniformily defines indifference for P and R relations\ndef I (Q : X → X → Prop) : X → X → Prop := λ x y, x = y ∨ (Q x y ∧ Q y x)\n\ndef N (Q : X → X → Prop) : X → X → Prop := λ x y, ¬x = y ∧ ¬ Q x y ∧ ¬ Q y x\n\nlemma P_asymmetric (Q : X → X → Prop) {x y : X} : (P Q) x y → ¬ (P Q) y x :=\nbegin\n  intros ᾰ ᾰ_1, cases ᾰ_1, cases ᾰ, solve_by_elim,\nend\n\nlemma P_irrefl (Q : X → X → Prop) {x : X} : ¬ (P Q) x x :=\nbegin\n  intros ᾰ, cases ᾰ, solve_by_elim,\nend\n\nlemma I_refl (Q : X → X → Prop) {x : X} : (I Q) x x :=\nbegin\n  unfold I,\n  have e : x = x := by refl,\n  use e,\nend\n\nlemma N_irrefl (Q : X → X → Prop) {x : X} : ¬(N Q) x x :=\nbegin\n  unfold N,\n  push_neg,\n  intro n,\n  exfalso,\n  have e : x = x := by refl,\n  exact n e,\nend\n\n", "meta": {"author": "chasenorman", "repo": "Formalized-Voting", "sha": "de04e630b83525b042db166670ba97f9952b5691", "save_path": "github-repos/lean/chasenorman-Formalized-Voting", "path": "github-repos/lean/chasenorman-Formalized-Voting/Formalized-Voting-de04e630b83525b042db166670ba97f9952b5691/src/relation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.45184681165824364}}
{"text": "import .global\nimport .Omega\nimport .Spec\nimport category_theory.functor_category\nimport category_theory.natural_transformation\nopen category_theory\nopen Omega\nopen Spec\nuniverses u\n\nlocal notation `Ring` := CommRing.{u}\nlocal notation `Set` :=  Type u  \nlocal notation `Presheaf` := Ring ⥤ Set\nvariables (X : Presheaf)(Y : Presheaf)\n\nstructure open_imersion { Y X : Ring ⥤ Set} (ι : Y ⟶  X)  := \n(χ  : nat_trans X  Ω ) \n(mono_ι : ∀ A :  Ring, mono (ι.app A))\n(Hyp_1 : ∀ A : Ring, ∀ y : Y.obj(A), χ.app(A)  ( ι.app(A) y ) = (⊤ : ideal A))\n(Hyp_2 : ∀ A : Ring, ∀ x : X.obj(A), χ.app(A) x = (⊤ : ideal A) → ∃ y : Y.obj(A), ι.app A y = x)\n\nstructure closed_imersion {X Y : Ring ⥤ Set} (ι : nat_trans Y  X) := \n(χ  : nat_trans X  Ω ) \n(mono_ι : ∀ A :  Ring, mono (ι.app A))\n(Hyp_1 : ∀ A : Ring, ∀ y : Y.obj(A), (χ.app(A) (ι.app(A) y)) = (⊥  : ideal A))\n(Hyp_2 : ∀ A : Ring, ∀ x : X.obj(A), χ.app(A) x = (⊥ : ideal A) → ∃ y : Y.obj(A), ι.app A y = x)\n\nlemma open_imersion_is_mono (ι : Y ⟶  X) : open_imersion  ι  →  ∀ A :  Ring, mono (ι.app A)  :=λ U, U.mono_ι \nlemma closed_imersion_is_mono (ι : Y ⟶  X) : closed_imersion  ι  →  ∀ A :  Ring, mono (ι.app A)  :=λ U, U.mono_ι \n\nstructure sieves (X : Presheaf) :=\n(Y : Presheaf)\n(ι : nat_trans Y X)\n(mono_ι : ∀ A : Ring, mono (ι.app A))\n\nstructure covering_familly (R : Ring) :=\n(U : sieves $ Spec R)\n(Hyp : ∃ S : set R, ∀ A : Ring, ∀ y : U.Y.obj A, ∃ s ∈ S,  ((U.ι.app A)(y)).to_fun (s) = 1)\n\n\nstructure matching_familly (X : Presheaf)(A : Ring) := \n(F : covering_familly A)\n(β : nat_trans F.U.Y X)\n\n\n\n\n---  Je dois définir quoi ? \n---  Pour R un anneau, je dois définir la notion de sous-foncteur couvrant de (Spec R)\n--- C'est  ∪ (s : S) D(s) pour s ⊂ R \n--- definir la notion de topology de grothendieck sur Ring^(op) ≃ AFF = spec (Yoneda)  \n\n\nstructure covers (X : Presheaf) := \n(U : sieves X)\n\n \n\nstructure Open (X : Presheaf) := \n(U : sieves X)\n(χ  :  nat_trans X Ω ) \n(Hyp_1 : ∀ A : Ring, ∀ y : U.Y.obj(A), χ.app(A)  ( U.ι.app(A) y ) = (⊤ : ideal A))\n(Hyp_2 : ∀ A : Ring, ∀ x : X.obj(A), χ.app(A) x = (⊤ : ideal A) → ∃ y : U.Y.obj(A), U.ι.app A y = x)\n\n\n\n\n\nvariables (ι : Y ⟶  X)\n#check Open\n\n-- variables (U1 : Open X)(U2 : Open X)\n-- def  intersection : Open X → Open X →  Open X := λ U1 U2, begin sorry, end ", "meta": {"author": "Or7ando", "repo": "lean", "sha": "d41169cf4e416a0d42092fb6bdc14131cee9dd15", "save_path": "github-repos/lean/Or7ando-lean", "path": "github-repos/lean/Or7ando-lean/lean-d41169cf4e416a0d42092fb6bdc14131cee9dd15/.github/workflows/geo/open.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568416, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4518468056604458}}
{"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl\n\nRelator for functions, pairs, sums, and lists.\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.reserved_notation\nimport Mathlib.PostPort\n\nuniverses u₁ u₂ v₁ v₂ u_1 u_2 \n\nnamespace Mathlib\n\nnamespace relator\n\n\n/- TODO(johoelzl):\n * should we introduce relators of datatypes as recursive function or as inductive\npredicate? For now we stick to the recursor approach.\n * relation lift for datatypes, Π, Σ, set, and subtype types\n * proof composition and identity laws\n * implement method to derive relators from datatype\n-/\n\ndef lift_fun {α : Sort u₁} {β : Sort u₂} {γ : Sort v₁} {δ : Sort v₂} (R : α → β → Prop)\n    (S : γ → δ → Prop) (f : α → γ) (g : β → δ) :=\n  ∀ {a : α} {b : β}, R a b → S (f a) (g b)\n\ninfixr:40 \" ⇒ \" => Mathlib.relator.lift_fun\n\ndef right_total {α : Type u₁} {β : outParam (Type u₂)} (R : outParam (α → β → Prop)) :=\n  ∀ (b : β), ∃ (a : α), R a b\n\ndef left_total {α : Type u₁} {β : outParam (Type u₂)} (R : outParam (α → β → Prop)) :=\n  ∀ (a : α), ∃ (b : β), R a b\n\ndef bi_total {α : Type u₁} {β : outParam (Type u₂)} (R : outParam (α → β → Prop)) :=\n  left_total R ∧ right_total R\n\ndef left_unique {α : Type u₁} {β : Type u₂} (R : α → β → Prop) :=\n  ∀ {a : α} {b : β} {c : α}, R a b → R c b → a = c\n\ndef right_unique {α : Type u₁} {β : Type u₂} (R : α → β → Prop) :=\n  ∀ {a : α} {b c : β}, R a b → R a c → b = c\n\ntheorem rel_forall_of_right_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop)\n    [t : right_total R] :\n    lift_fun (R ⇒ implies) implies (fun (p : α → Prop) => ∀ (i : α), p i)\n        fun (q : β → Prop) => ∀ (i : β), q i :=\n  fun (p : α → Prop) (q : β → Prop) (Hrel : lift_fun R implies p q) (H : ∀ (i : α), p i) (b : β) =>\n    exists.elim (t b) fun (a : α) (Rab : R a b) => Hrel Rab (H a)\n\ntheorem rel_exists_of_left_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop) [t : left_total R] :\n    lift_fun (R ⇒ implies) implies (fun (p : α → Prop) => ∃ (i : α), p i)\n        fun (q : β → Prop) => ∃ (i : β), q i :=\n  sorry\n\ntheorem rel_forall_of_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop) [t : bi_total R] :\n    lift_fun (R ⇒ Iff) Iff (fun (p : α → Prop) => ∀ (i : α), p i)\n        fun (q : β → Prop) => ∀ (i : β), q i :=\n  sorry\n\ntheorem rel_exists_of_total {α : Type u₁} {β : Type u₂} (R : α → β → Prop) [t : bi_total R] :\n    lift_fun (R ⇒ Iff) Iff (fun (p : α → Prop) => ∃ (i : α), p i)\n        fun (q : β → Prop) => ∃ (i : β), q i :=\n  sorry\n\ntheorem left_unique_of_rel_eq {α : Type u₁} {β : Type u₂} (R : α → β → Prop) {eq' : β → β → Prop}\n    (he : lift_fun R (R ⇒ Iff) Eq eq') : left_unique R :=\n  fun {a : α} {b : β} {c : α} (ᾰ : R a b) (ᾰ_1 : R c b) =>\n    idRhs (a = c) ((fun (this : eq' b b) => iff.mpr (he ᾰ ᾰ_1) this) (iff.mp (he ᾰ ᾰ) rfl))\n\ntheorem rel_imp : lift_fun Iff (Iff ⇒ Iff) implies implies :=\n  fun (p q : Prop) (h : p ↔ q) (r s : Prop) (l : r ↔ s) => imp_congr h l\n\ntheorem rel_not : lift_fun Iff Iff Not Not := fun (p q : Prop) (h : p ↔ q) => not_congr h\n\n-- (this is an instance is always applies, since the relation is an out-param)\n\nprotected instance bi_total_eq {α : Type u₁} : bi_total Eq :=\n  { left := fun (a : α) => Exists.intro a rfl, right := fun (a : α) => Exists.intro a rfl }\n\ndef bi_unique {α : Type u_1} {β : Type u_2} (r : α → β → Prop) := left_unique r ∧ right_unique r\n\ntheorem left_unique_flip {α : Type u_1} {β : Type u_2} {r : α → β → Prop} (h : left_unique r) :\n    right_unique (flip r) :=\n  fun {a : β} {b c : α} (ᾰ : flip r a b) (ᾰ_1 : flip r a c) => idRhs (b = c) (h ᾰ ᾰ_1)\n\ntheorem rel_and : lift_fun Iff (Iff ⇒ Iff) And And :=\n  fun (a b : Prop) (h₁ : a ↔ b) (c d : Prop) (h₂ : c ↔ d) => and_congr h₁ h₂\n\ntheorem rel_or : lift_fun Iff (Iff ⇒ Iff) Or Or :=\n  fun (a b : Prop) (h₁ : a ↔ b) (c d : Prop) (h₂ : c ↔ d) => or_congr h₁ h₂\n\ntheorem rel_iff : lift_fun Iff (Iff ⇒ Iff) Iff Iff :=\n  fun (a b : Prop) (h₁ : a ↔ b) (c d : Prop) (h₂ : c ↔ d) => iff_congr h₁ h₂\n\ntheorem rel_eq {α : Type u_1} {β : Type u_2} {r : α → β → Prop} (hr : bi_unique r) :\n    lift_fun r (r ⇒ Iff) Eq Eq :=\n  fun (a : α) (b : β) (h₁ : r a b) (c : α) (d : β) (h₂ : r c d) =>\n    { mp := fun (h : a = c) => Eq._oldrec (fun (h₂ : r a d) => and.right hr a b d h₁ h₂) h h₂,\n      mpr := fun (h : b = d) => Eq._oldrec (fun (h₂ : r c b) => and.left hr a b c h₁ h₂) h h₂ }\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/logic/relator_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6825737473266735, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.45181117781017904}}
{"text": "example (p q : Prop) : p ∧ ¬ p → q :=\nbegin\n  intro h,\n  cases h,\n  contradiction\nend\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch5/ex0309.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6825737214979745, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.45181116071357225}}
{"text": "import .list_as_k_tuple linear_algebra.affine_space.basic\nimport linear_algebra.basis\nimport .affine_coordinate_space\nimport data.real.basic\n\nset_option trace.app_builder true\n\nopen list\nopen vecl\n\nnamespace aff_fr\n\nuniverses u v w\n\nvariables \n    -- (id : ℕ)\n    (X : Type u) \n    (K : Type v) \n    (V : Type w) \n    (n : ℕ) \n    (k : K)\n    (ι : Type*)\n    (s : finset ι) \n    (g : ι → K) \n    (v : ι → V) \n    [inhabited K] \n    [field K] \n    [add_comm_group V] \n  --  [module K V] \n    [vector_space K V] \n    [affine_space V X]\n    [is_basis K v] \n    [affine_space V X]\n\n/-\nAn affine frame comprises an origin point\nand a basis for the vector space.\n-/\nstructure vector_basis :=\n    (map : ι → V) \n    (proof_is_basis : is_basis K map) \n\n/-\ninductive affine_frame\n    (X : Type u) \n    (K : Type v) \n    (V : Type w) \n    (ι : Type*)\n    [inhabited K] \n    [field K] \n    [add_comm_group V] \n    [module K V] \n    [vector_space K V] \n    [affine_space V X] --: Type\n| standard : affine_frame\n| derived\n(original : affine_frame)\n(origin : X) \n(basis : vector_basis K V ι )\n: affine_frame\n-/\n/-\nstructure affine_frame  :=\n(origin : X) \n(basis : ι → V) \n(proof_is_basis : is_basis K basis)\n-/\n/-\ninductive affine_frame\n| tuple\n(origin : aff_pt_coord_tuple K n) \n(basis : ι → aff_vec_coord_tuple K n) \n(proof_is_basis : is_basis K basis) : affine_frame\n| from_tuple\n()\n\nfirst you need a tuple frame\nthen you need points constructed from\n-/\n\n#check aff_pt_coord_tuple K n\n\nstructure affine_frame  :=\n(origin : X) \n(basis : ι → V) \n(proof_is_basis : is_basis K basis)\n\ndef affine_tuple_frame \n    (K : Type v)\n    (n : ℕ)\n    [inhabited K] \n    [field K] \n    :=\n    affine_frame \n        (aff_pt_coord_tuple K n) K (aff_vec_coord_tuple K n) (fin n)\n\nstructure aff_tuple_framed_pt (fr : affine_tuple_frame K n) \n    extends aff_pt_coord_tuple K n :=\n   -- (tuple : aff_pt_coord_tuple K n)\n   mk ::\n\nstructure aff_tuple_framed_vec (fr : affine_tuple_frame K n) extends aff_vec_coord_tuple K n :=\n   -- (tuple : aff_pt_coord_tuple K n)\n   mk ::\n\ninstance (fr : affine_tuple_frame K n): has_add (aff_tuple_framed_vec K n fr) := sorry\ninstance (fr : affine_tuple_frame K n): has_zero (aff_tuple_framed_vec K n fr) := sorry\ninstance (fr : affine_tuple_frame K n): has_neg (aff_tuple_framed_vec K n fr) := sorry\ninstance aff_comm_group_coord (fr : affine_tuple_frame K n): add_comm_group (aff_tuple_framed_vec K n fr) := sorry\ninstance (fr : affine_tuple_frame K n) : has_scalar K (aff_tuple_framed_vec K n fr) := sorry\ninstance (fr : affine_tuple_frame K n) : mul_action K (aff_tuple_framed_vec K n fr) := \n    ⟨sorry, sorry⟩\ninstance (fr : affine_tuple_frame K n) : distrib_mul_action K (aff_tuple_framed_vec K n fr) := \n    sorry\ninstance aff_semimod_coord (fr : affine_tuple_frame K n) : semimodule K (aff_tuple_framed_vec K n fr)\n    := ⟨sorry, sorry⟩\ninstance (fr : affine_tuple_frame K n)  : has_vadd (aff_tuple_framed_vec K n fr) (aff_tuple_framed_pt K n fr) := sorry\ninstance (fr : affine_tuple_frame K n)  : has_vsub (aff_tuple_framed_vec K n fr) (aff_tuple_framed_pt K n fr) := sorry\ninstance (fr : affine_tuple_frame K n)  : add_action (aff_tuple_framed_vec K n fr) (aff_tuple_framed_pt K n fr) := sorry--⟨aff_group_action K n, aff_zero_sadd K n, aff_add_sadd K n⟩\ninstance afc (fr : affine_tuple_frame K n)  : affine_space \n    (aff_tuple_framed_vec K n fr) \n    (aff_tuple_framed_pt K n fr) := \n    sorry\n\ndef affine_tuple_framed_frame\n    {K : Type v}\n    {n : ℕ}\n    [inhabited K] \n    [field K] \n    (f : affine_tuple_frame K n)\n   -- [add_comm_group (aff_tuple_framed_vec K n f)] \n    --[module K (aff_tuple_framed_vec K n f)]\n    --[affine_space (aff_tuple_framed_vec K n f) (aff_tuple_framed_pt K n f)]\n    :=\n    affine_frame \n        (aff_tuple_framed_pt K n f) K (aff_tuple_framed_vec K n f) (fin n)\n\n\nstructure affine_framed_pt\n    {f : affine_tuple_frame K n}\n    (fr : affine_tuple_framed_frame f) extends aff_pt_coord_tuple K n\n    := \nmk ::\n\nstructure affine_framed_vec\n    {f : affine_tuple_frame K n}\n    (fr : affine_tuple_framed_frame f) extends aff_vec_coord_tuple K n\n    := \nmk ::\n\n\nmutual inductive\n affine_coordinate_frame, \n aff_coord_pt, \n aff_coord_vec \n \n    (K : Type w)\n    [inhabited K] \n    [field K] \n    --[add_comm_group (aff_vec_coord_tuple K n)] \n   -- [module K (aff_vec_coord_tuple K n)] \n  --  [vector_space K (aff_vec_coord_tuple K n)] \n   -- [affine_space (aff_vec_coord_tuple K n) (aff_pt_coord_tuple K n)]\n    /-\nwith affine_coordinate_frame : Type v\n| tuple\n(origin : aff_pt_coord_tuple K n) \n--(basis : ι → aff_vec_coord_tuple K n) \n--(proof_is_basis : is_basis K basis) \n: affine_coordinate_frame-//-\n| gen_frame \n    (origin : aff_coord_pt) \n    (basis : ι → aff_coord_vec) \n    (proof_is_basis : is_basis K basis) : affine_coordinate_frame-/\nwith aff_coord_pt :  aff_pt_coord_tuple K n → Type v\n| mk (tuple : aff_pt_coord_tuple K n) \n: aff_coord_pt tuple\nwith aff_coord_vec : aff_vec_coord_tuple K n → Type v\n| mk (tuple : aff_vec_coord_tuple K n) \n: aff_coord_vec  tuple\n\n\nstructure aff_coord_pt (fr : affine_frame X K V ι) extends aff_pt_coord_tuple K n :=\n   -- (tuple : aff_pt_coord_tuple K n)\n   mk ::\n\nstructure aff_coord_vec (fr : affine_frame X K V ι) extends aff_vec_coord_tuple K n  :=\n   -- (tuple : aff_vec_coord_tuple K n)\n   mk ::\n/-\ndef affine_coordinate_frame_origin (frame : affine_coordinate_frame X K V ι) :=\nmatch frame with\n| std_frame := _\n| gen_frame o b pf := o\nend\n\ndef frame_basis : affine_frame X K V ι → (ι → V) :=\n| (affine_frame.std_frame origin) := basis\n| (affine_frame.gen_frame origin _ _) := origin\n-/\n\n\nvariables \n    (fr : affine_frame X K V ι) \n    (cv1 cv2 : aff_coord_vec X K V n ι fr) \n    (cp1 cp2 : aff_coord_pt  X K V n ι fr)\n\n/-\n-- lemmas so that the following operations are well-defined\n/-- the length of the sum of two length n+1 vectors is n+1 -/\nlemma aff_not_nil : x.1 ≠ [] := \nbegin\nintro h,\nhave f : 0 ≠ n + 1 := ne.symm (nat.succ_ne_zero n),\nhave len_x_nil : length x.1 = length nil := by rw h,\nhave len_fixed : length nil = n + 1 := eq.trans (eq.symm len_x_nil) x.2,\nhave bad : 0 = n + 1 := eq.trans (eq.symm len_nil) len_fixed,\ncontradiction,\nend\n\nlemma aff_cons : ∃ x_hd : K, ∃ x_tl : list K, x.1 = x_hd :: x_tl :=\nbegin\ncases x,\ncases x_l,\n{\n    have f : 0 ≠ n + 1 := ne.symm (nat.succ_ne_zero n),\n    have bad := eq.trans (eq.symm len_nil) x_len_fixed,\n    contradiction\n},\n{\n    apply exists.intro x_l_hd,\n    apply exists.intro x_l_tl,\n    exact rfl\n}\nend\n\n/-- head is compatible with addition -/\nlemma head_sum : head x.1 + head y.1 = head (ladd x.1 y.1) := \nbegin\ncases x,\ncases y,\ncases x_l,\n    have f : 0 ≠ n + 1 := ne.symm (nat.succ_ne_zero n),\n    have bad := eq.trans (eq.symm len_nil) x_len_fixed,\n    contradiction,\ncases y_l,\n    have f : 0 ≠ n + 1 := ne.symm (nat.succ_ne_zero n),\n    have bad := eq.trans (eq.symm len_nil) y_len_fixed,\n    contradiction,\nhave head_xh : head (x_l_hd :: x_l_tl) = x_l_hd := rfl,\nhave head_yh : head (y_l_hd :: y_l_tl) = y_l_hd := rfl,\nrw head_xh at x_fst_zero,\nrw head_yh at y_fst_zero,\nsimp [x_fst_zero, y_fst_zero, add_cons_cons 0 0 x_l_tl y_l_tl],\nend\n\n/-- the head of the sum of two vectors is 0 -/\nlemma sum_fst_fixed : head (ladd x.1 y.1) = 0 :=\n    by simp only [eq.symm (head_sum K n x y), x.3, y.3]; exact add_zero 0\n\n/-- the length of the zero vector is n+1 -/\nlemma len_zero : length (zero_vector K n) = n + 1 :=\nbegin\ninduction n with n',\nrefl,\n{\nhave h₃ : nat.succ (n' + 1) = nat.succ n' + 1 := rfl,\nhave h₄ : length (zero_vector K (nat.succ n')) = nat.succ (n' + 1) :=\n    by {rw eq.symm n_ih, refl},\nrw eq.symm h₃,\nexact h₄,\n}\nend\n\n/-- the head of the zero vector is zero -/\nlemma head_zero : head (zero_vector K n) = 0 := by {cases n, refl, refl}\n\nlemma vec_len_neg : length (vecl_neg x.1) = n + 1 := by {simp only [len_neg], exact x.2}\n\nlemma head_neg_0 : head (vecl_neg x.1) = 0 :=\nbegin\ncases x,\ncases x_l,\ncontradiction,\nrw neg_cons x_l_hd x_l_tl,\nhave head_xh : head (x_l_hd :: x_l_tl) = x_l_hd := rfl,\nhave head_0 : head (0 :: vecl_neg x_l_tl) = 0 := rfl,\nrw head_xh at x_fst_zero,\nsimp only [x_fst_zero, neg_zero, head_0],\nend\n\n-/\ndef vec_add_coord : aff_coord_vec X K V n ι fr → aff_coord_vec X K V n ι fr → aff_coord_vec X K V n ι fr :=\n    λ x y, ⟨⟨ladd x.1.l y.1.l, list_sum_fixed K n x.1 y.1, sum_fst_fixed K n x.1 y.1⟩⟩\ndef vec_zero_coord : aff_coord_vec X K V n ι fr := ⟨⟨zero_vector K n, len_zero K n, head_zero K n⟩⟩\ndef vec_neg_coord : aff_coord_vec X K V n ι fr → aff_coord_vec X K V n ι fr\n| ⟨⟨l, len, fst⟩⟩ := ⟨⟨vecl_neg l, vec_len_neg K n ⟨l, len, fst⟩, head_neg_0 K n ⟨l, len, fst⟩⟩⟩\n\n\n/-! ### type class instances for the abelian group operations -/\ninstance : has_add (aff_coord_vec X K V n ι fr) := ⟨vec_add_coord X K V n ι fr⟩\ninstance : has_zero (aff_coord_vec X K V n ι fr) := ⟨vec_zero_coord X K V n ι fr⟩\ninstance : has_neg (aff_coord_vec X K V n ι fr) := ⟨vec_neg_coord X K V n ι fr⟩\n@[ext]\ndef vec_scalar_coord : K → aff_coord_vec X K V n ι fr → aff_coord_vec X K V n ι fr :=\n    λ a x, ⟨⟨scalar_mul a x.1.1, trans (scale_len a x.1.1) x.1.2, sorry⟩⟩\n/-! ### Type class instance for abelian group -/\ninstance aff_comm_group_coord : add_comm_group (aff_coord_vec X K V n ι fr) :=\nbegin\n    sorry\nend\ninstance : has_scalar K (aff_coord_vec X K V n ι fr) := ⟨vec_scalar_coord X K V n ι fr⟩\n\n/-\nlemma vec_one_smul_coord : (1 : K) • cv1 = cv1 := \nbegin\ncases cv1,\n\next,\nsplit,\nintros,\ndsimp only [has_scalar.smul, vec_scalar] at a_1,\nrw one_smul_cons at a_1,\nexact a_1,\n\nintros,\ndsimp only [has_scalar.smul, vec_scalar],\nrw one_smul_cons,\nexact a_1,\nend\n-/\n\nlemma vec_mul_smul_coord : ∀ g h : K, ∀ x : aff_coord_vec X K V n ι fr, (g * h) • x = g • h • x := sorry\n\n\ninstance : mul_action K (aff_coord_vec X K V n ι fr) := \n    ⟨sorry, vec_mul_smul_coord X K V n ι fr⟩\n\n\ninstance : distrib_mul_action K (aff_coord_vec X K V n ι fr) := \n    sorry\ninstance aff_semimod_coord : semimodule K (aff_coord_vec X K V n ι fr)\n    --[distrib_mul_action K (aff_coord_vec X K V n ι fr)] \n    := \n    -- extremely odd that this doesnt work....\n    ⟨sorry, sorry⟩\n\n\n\ndef aff_group_action_coord : (aff_coord_vec X K V n ι fr) → (aff_coord_pt X K V n ι fr) → (aff_coord_pt X K V n ι fr) :=\n    λ x y, ⟨⟨ladd x.1.1 y.1.1, sorry, sorry⟩⟩\n\ndef aff_group_sub_coord : (aff_coord_pt X K V n ι fr) → (aff_coord_pt X K V n ι fr) → (aff_coord_vec X K V n ι fr) :=\n    λ x y, ⟨⟨ladd x.1.1 (vecl_neg y.1.1), sorry, sorry⟩⟩\n\n\n\ninstance : has_vadd (aff_coord_vec X K V n ι fr) (aff_coord_pt X K V n ι fr) := ⟨aff_group_action_coord X K V n ι fr⟩\n\ninstance : has_vsub (aff_coord_vec X K V n ι fr) (aff_coord_pt X K V n ι fr) := ⟨aff_group_sub_coord X K V n ι fr⟩\n\ninstance : add_action (aff_coord_vec X K V n ι fr) (aff_coord_pt X K V n ι fr) := sorry--⟨aff_group_action K n, aff_zero_sadd K n, aff_add_sadd K n⟩\n\n/-\nWe need proof that given a frame f, \n⟨ aff_coord_pt f, aff_coord_vec f⟩ is \nan affine space,\n-/\n\n/-\n\ndef vecptadd := r3_der2_pt1 +ᵥ r3_der2_vec2 --expected : pass\ndef vecptsub := r3_der2_pt1 -ᵥ r3_der2_vec2 --expected : pass\ndef ptvecsub := r3_der2_vec2 -ᵥ r3_der2_pt1 -- expected : pass\n-/\ndef pt_plus_vec\n    {X : Type u} \n    {K : Type v} \n    {V : Type w} \n    {n : ℕ}\n    {ι : Type*}\n    [inhabited K] \n    [field K] \n    [add_comm_group V] \n    [module K V] \n    [vector_space K V] \n    [affine_space V X]\n    {fr : affine_frame X K V ι} :\n    (aff_coord_pt X K V n ι fr) → \n    (aff_coord_vec X K V n ι fr) → \n    (aff_coord_pt X K V n ι fr) \n| p v := aff_group_action_coord X K V n ι fr v p\n\nnotation\n pt +ᵥ v := pt_plus_vec pt v\n \ndef pt_minus_vec\n    {X : Type u} \n    {K : Type v} \n    {V : Type w} \n    {n : ℕ}\n    {ι : Type*}\n    [inhabited K] \n    [field K] \n    [add_comm_group V] \n    [module K V] \n    [vector_space K V] \n    [affine_space V X]\n    {fr : affine_frame X K V ι} :\n    (aff_coord_pt X K V n ι fr) → \n    (aff_coord_vec X K V n ι fr) → \n    (aff_coord_pt X K V n ι fr) \n| p v := aff_group_action_coord X K V n ι fr (vec_neg_coord X K V n ι fr v) p\n.\nnotation\n pt -ᵥ v := pt_minus_vec pt v\n\n\ndef prf : affine_space (aff_coord_vec X K V n ι fr) (aff_coord_pt  X K V n ι fr) := sorry\n\ninstance afc : affine_space \n    (aff_coord_vec X K V n ι fr) \n    (aff_coord_pt  X K V n ι fr) := \n    prf X K V n ι fr\n\n\n/-\nKEEP?\n-/\ndef affine_coord_tuple_space_type (K : Type v) (n : ℕ) [field K] [inhabited K] := \n    affine_space_type \n        (aff_pt_coord_tuple K n)\n        K\n        (aff_vec_coord_tuple K n)\n\n\n\n/-\n-/\n\n/-\nCode to manufacture a standard basis for a given affine space.\n-/\nabbreviation zero := zero_vector K n\n\ndef list.to_basis_vec : fin n → list K := λ x, (zero K n).update_nth (x.1 + 1) 1\n\nlemma len_basis_vec_fixed (x : fin n) : (list.to_basis_vec K n x).length = n + 1 := sorry\n\nlemma head_basis_vec_fixed (x : fin n) : (list.to_basis_vec K n x).head = 0 := sorry\n\ndef std_basis : fin n → aff_vec_coord_tuple K n :=\nλ x, ⟨list.to_basis_vec K n x, len_basis_vec_fixed K n x, head_basis_vec_fixed K n x⟩\n\nlemma std_is_basis : is_basis K (std_basis K n) := sorry\n\ndef aff_coord_space_std_frame : \n    affine_frame (aff_pt_coord_tuple K n) K (aff_vec_coord_tuple K n) (fin n) := \n        ⟨pt_zero K n, std_basis K n, std_is_basis K n⟩\n\n--affine_frame (aff_coord_pt fr_n) K (aff_coord_pt fr_n) (iota)\n\n\nend aff_fr", "meta": {"author": "kevinsullivan", "repo": "affine_lib", "sha": "056fc95c31bdf473b0c1ecd07f5a061dd6b69234", "save_path": "github-repos/lean/kevinsullivan-affine_lib", "path": "github-repos/lean/kevinsullivan-affine_lib/affine_lib-056fc95c31bdf473b0c1ecd07f5a061dd6b69234/src/old/old/affine_coordinated_inductive_frame.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186768138228, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4517885053145101}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Reid Barton, Patrick Massot, Scott Morrison\n-/\nimport category_theory.adjunction.reflective\nimport category_theory.concrete_category.unbundled_hom\nimport category_theory.monad.limits\nimport topology.category.Top.basic\nimport topology.uniform_space.completion\n\n/-!\n# The category of uniform spaces\n\nWe construct the category of uniform spaces, show that the complete separated uniform spaces\nform a reflective subcategory, and hence possess all limits that uniform spaces do.\n\nTODO: show that uniform spaces actually have all limits!\n-/\n\nuniverses u\n\nopen category_theory\n\n/-- A (bundled) uniform space. -/\ndef UniformSpace : Type (u+1) := bundled uniform_space\n\nnamespace UniformSpace\n\n/-- The information required to build morphisms for `UniformSpace`. -/\ninstance : unbundled_hom @uniform_continuous :=\n⟨@uniform_continuous_id, @uniform_continuous.comp⟩\n\nattribute [derive [large_category, concrete_category]] UniformSpace\n\ninstance : has_coe_to_sort UniformSpace Type* := bundled.has_coe_to_sort\n\ninstance (x : UniformSpace) : uniform_space x := x.str\n\n/-- Construct a bundled `UniformSpace` from the underlying type and the typeclass. -/\ndef of (α : Type u) [uniform_space α] : UniformSpace := ⟨α⟩\n\ninstance : inhabited UniformSpace := ⟨UniformSpace.of empty⟩\n\n@[simp] lemma coe_of (X : Type u) [uniform_space X] : (of X : Type u) = X := rfl\n\ninstance (X Y : UniformSpace) : has_coe_to_fun (X ⟶ Y) (λ _, X → Y) :=\n⟨category_theory.functor.map (forget UniformSpace)⟩\n\n@[simp] lemma coe_comp {X Y Z : UniformSpace} (f : X ⟶ Y) (g : Y ⟶ Z) :\n  (f ≫ g : X → Z) = g ∘ f := rfl\n@[simp] lemma coe_id (X : UniformSpace) : (𝟙 X : X → X) = id := rfl\n@[simp] lemma coe_mk {X Y : UniformSpace} (f : X → Y) (hf : uniform_continuous f) :\n  ((⟨f, hf⟩ : X ⟶ Y) : X → Y) = f := rfl\n\nlemma hom_ext {X Y : UniformSpace} {f g : X ⟶ Y} : (f : X → Y) = g → f = g := subtype.eq\n\n/-- The forgetful functor from uniform spaces to topological spaces. -/\ninstance has_forget_to_Top : has_forget₂ UniformSpace.{u} Top.{u} :=\n{ forget₂ :=\n  { obj := λ X, Top.of X,\n    map := λ X Y f, { to_fun := f,\n                      continuous_to_fun := uniform_continuous.continuous f.property }, }, }\n\nend UniformSpace\n\n/-- A (bundled) complete separated uniform space. -/\nstructure CpltSepUniformSpace :=\n(α : Type u)\n[is_uniform_space : uniform_space α]\n[is_complete_space : complete_space α]\n[is_separated : separated_space α]\n\nnamespace CpltSepUniformSpace\n\ninstance : has_coe_to_sort CpltSepUniformSpace (Type u) := ⟨CpltSepUniformSpace.α⟩\n\nattribute [instance] is_uniform_space is_complete_space is_separated\n\n/-- The function forgetting that a complete separated uniform spaces is complete and separated. -/\ndef to_UniformSpace (X : CpltSepUniformSpace) : UniformSpace :=\nUniformSpace.of X\n\ninstance complete_space (X : CpltSepUniformSpace) : complete_space ((to_UniformSpace X).α) :=\nCpltSepUniformSpace.is_complete_space X\n\ninstance separated_space (X : CpltSepUniformSpace) : separated_space ((to_UniformSpace X).α) :=\nCpltSepUniformSpace.is_separated X\n\n/-- Construct a bundled `UniformSpace` from the underlying type and the appropriate typeclasses. -/\ndef of (X : Type u) [uniform_space X] [complete_space X] [separated_space X] :\nCpltSepUniformSpace := ⟨X⟩\n\n@[simp] lemma coe_of (X : Type u) [uniform_space X] [complete_space X] [separated_space X] :\n  (of X : Type u) = X := rfl\n\ninstance : inhabited CpltSepUniformSpace :=\nbegin\n  haveI : separated_space empty := separated_iff_t2.mpr (by apply_instance),\n  exact ⟨CpltSepUniformSpace.of empty⟩\nend\n\n/-- The category instance on `CpltSepUniformSpace`. -/\ninstance category : large_category CpltSepUniformSpace :=\ninduced_category.category to_UniformSpace\n\n/-- The concrete category instance on `CpltSepUniformSpace`. -/\ninstance concrete_category : concrete_category CpltSepUniformSpace :=\ninduced_category.concrete_category to_UniformSpace\n\ninstance has_forget_to_UniformSpace : has_forget₂ CpltSepUniformSpace UniformSpace :=\ninduced_category.has_forget₂ to_UniformSpace\n\nend CpltSepUniformSpace\n\nnamespace UniformSpace\n\nopen uniform_space\nopen CpltSepUniformSpace\n\n/-- The functor turning uniform spaces into complete separated uniform spaces. -/\nnoncomputable def completion_functor : UniformSpace ⥤ CpltSepUniformSpace :=\n{ obj := λ X, CpltSepUniformSpace.of (completion X),\n  map := λ X Y f, ⟨completion.map f.1, completion.uniform_continuous_map⟩,\n  map_id' := λ X, subtype.eq completion.map_id,\n  map_comp' := λ X Y Z f g, subtype.eq (completion.map_comp g.property f.property).symm, }.\n\n/-- The inclusion of a uniform space into its completion. -/\ndef completion_hom (X : UniformSpace) :\n  X ⟶ (forget₂ CpltSepUniformSpace UniformSpace).obj (completion_functor.obj X) :=\n{ val := (coe : X → completion X),\n  property := completion.uniform_continuous_coe X }\n\n@[simp] lemma completion_hom_val (X : UniformSpace) (x) :\n  (completion_hom X) x = (x : completion X) := rfl\n\n/-- The mate of a morphism from a `UniformSpace` to a `CpltSepUniformSpace`. -/\nnoncomputable def extension_hom {X : UniformSpace} {Y : CpltSepUniformSpace}\n  (f : X ⟶ (forget₂ CpltSepUniformSpace UniformSpace).obj Y) :\n  completion_functor.obj X ⟶ Y :=\n{ val := completion.extension f,\n  property := completion.uniform_continuous_extension }\n\n@[simp] lemma extension_hom_val {X : UniformSpace} {Y : CpltSepUniformSpace}\n  (f : X ⟶ (forget₂ _ _).obj Y) (x) :\n  (extension_hom f) x = completion.extension f x := rfl.\n\n@[simp] \n\n/-- The completion functor is left adjoint to the forgetful functor. -/\nnoncomputable def adj : completion_functor ⊣ forget₂ CpltSepUniformSpace UniformSpace :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := λ X Y,\n  { to_fun := λ f, completion_hom X ≫ f,\n    inv_fun := λ f, extension_hom f,\n    left_inv := λ f, by { dsimp, erw extension_comp_coe },\n    right_inv := λ f,\n    begin\n      apply subtype.eq, funext x, cases f,\n      exact @completion.extension_coe _ _ _ _ _ (CpltSepUniformSpace.separated_space _) f_property _\n    end },\n  hom_equiv_naturality_left_symm' := λ X X' Y f g,\n  begin\n    apply hom_ext, funext x, dsimp,\n    erw [coe_comp, ←completion.extension_map],\n    refl, exact g.property, exact f.property,\n  end }\n\nnoncomputable instance : is_right_adjoint (forget₂ CpltSepUniformSpace UniformSpace) :=\n⟨completion_functor, adj⟩\nnoncomputable instance : reflective (forget₂ CpltSepUniformSpace UniformSpace) := {}\n\nopen category_theory.limits\n\n-- TODO Once someone defines `has_limits UniformSpace`, turn this into an instance.\nexample [has_limits.{u} UniformSpace.{u}] : has_limits.{u} CpltSepUniformSpace.{u} :=\nhas_limits_of_reflective $ forget₂ CpltSepUniformSpace UniformSpace.{u}\n\nend UniformSpace\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/category/UniformSpace.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.45166702015888005}}
{"text": "-- import ring_theory.localization.localization_localization\n-- import ring_theory.local_properties\n\n-- variables {R S T : Type*} [comm_ring R] [comm_ring S] [comm_ring T] (f : R →+* S) (g : S →+* T)\n\n-- def ring_hom.essentially_surjective (f : R →+* S) : Prop :=\n-- ∀ x : S, ∃ a b : R, is_unit (f b) ∧ x * f b = f a\n\n-- lemma is_localization.range_lift_is_unit_submonoid_map {x} : \n--   x ∈ (is_localization.lift (λ x : (is_unit.submonoid S).comap f, x.2) :\n--     localization ((is_unit.submonoid S).comap f) →+* S).range ↔ \n--     ∃ a b : R, is_unit (f b) ∧ x * f b = f a :=\n-- begin\n--   split,\n--   { rintro ⟨x, rfl⟩,\n--     obtain ⟨x, s, rfl⟩ := is_localization.mk'_surjective ((is_unit.submonoid S).comap f) x,\n--     refine ⟨x, s, s.2, _⟩,\n--     rw [mul_comm, is_localization.lift_mk', ← mul_assoc, units.mul_inv_eq_iff_eq_mul, mul_comm],\n--     refl },\n--   { rintro ⟨a, b, hb, e⟩,\n--     refine ⟨is_localization.mk' _ a ⟨b, show b ∈ (is_unit.submonoid S).comap f, from hb⟩, _⟩,\n--     rw [is_localization.lift_mk', units.mul_inv_eq_iff_eq_mul, eq_comm, ← e], refl }\n-- end\n\n-- def fraction_subring : subring S :=\n-- { ..(is_localization.lift (λ x : (is_unit.submonoid S).comap f, x.2) :\n--   localization ((is_unit.submonoid S).comap f) →+* S).range.copy\n--   { x | ∃ a b : R, is_unit (f b) ∧ x * f b = f a }\n--   (set.ext $ λ x, (is_localization.range_lift_is_unit_submonoid_map f).symm) }\n\n-- variables (R S)\n\n-- def fraction_subalgebra [algebra R S] : subalgebra R S :=\n-- { algebra_map_mem' := λ x, ⟨x, 1, (algebra_map R S).map_one.symm ▸ is_unit_one,\n--     by rw [map_one, mul_one]⟩,\n--   ..(fraction_subring $ algebra_map R S) }\n\n-- variables {R S}\n\n-- namespace ring_hom.essentially_surjective\n\n-- variable {f}\n\n-- lemma iff_surjective_comp_localization : f.essentially_surjective ↔ \n--   ∃ (M : submonoid R) (hM : ∀ x : M, is_unit (f x)),\n--     function.surjective (is_localization.lift hM : localization M →+* S) :=\n-- begin\n--   split,\n--   { intro H,\n--     refine ⟨(is_unit.submonoid S).comap f, λ x, x.2, λ x, _⟩,\n--     obtain ⟨a, b, hb, e⟩ := H x,\n--     refine ⟨is_localization.mk' _ a ⟨b, show b ∈ (is_unit.submonoid S).comap f, from hb⟩, _⟩,\n--     rw [is_localization.lift_mk', units.mul_inv_eq_iff_eq_mul, eq_comm, ← e],\n--     refl },\n--   { rintro ⟨M, hM, hM'⟩ x,\n--     obtain ⟨x, rfl⟩ := hM' x,\n--     obtain ⟨x, s, rfl⟩ := is_localization.mk'_surjective M x,\n--     refine ⟨x, s, hM s, _⟩,\n--     rw [mul_comm, is_localization.lift_mk', ← mul_assoc, units.mul_inv_eq_iff_eq_mul, mul_comm],\n--     refl }\n-- end\n\n-- lemma iff_fraction_subring_eq_top :\n--   f.essentially_surjective ↔ fraction_subring f = ⊤ :=\n-- begin\n--   rw eq_top_iff,\n--   exact ⟨λ h x _, h x, λ h x, h trivial⟩\n-- end\n\n-- lemma of_surjective (hf : function.surjective f) :\n--   f.essentially_surjective :=\n-- begin\n--   intro x, obtain ⟨x, rfl⟩ := hf x, refine ⟨x, 1, _, _⟩; simp only [map_one, mul_one, is_unit_one]\n-- end\n\n-- variable (S)\n\n-- lemma of_localization [algebra R S] (M : submonoid R) [is_localization M S] :\n--   (algebra_map R S).essentially_surjective :=\n-- begin\n--   intro x,\n--   obtain ⟨⟨y, s⟩, e⟩ := is_localization.surj M x,\n--   exact ⟨y, s, is_localization.map_units _ s, e⟩,\n-- end\n\n-- variables {S f g}\n\n-- lemma comp (hg : g.essentially_surjective) (hf : f.essentially_surjective) :\n--   (g.comp f).essentially_surjective :=\n-- begin\n--   intro x,\n--   obtain ⟨y, s, hs, e₁⟩ := hg x, \n--   obtain ⟨z, t, ht, e₂⟩ := hf y, \n--   obtain ⟨u, v, hv, e₃⟩ := hf s, \n--   refine ⟨z * v, t * u, _, _⟩,\n--   { apply_fun g at e₃, simp only [ring_hom.comp_apply, map_mul] at e₃ ⊢, rw ← e₃,\n--     exact (ht.map g).mul (hs.mul $ hv.map g) },\n--   { apply_fun g at e₂ e₃, simp only [ring_hom.comp_apply, map_mul] at e₂ e₃ ⊢,\n--     rw [← e₂, ← e₃, ← e₁], simp only [mul_assoc, mul_comm, mul_left_comm], rw mul_comm (g (f t)) }\n-- end\n\n-- lemma tensor_product [algebra R S] [algebra R T] (h : (algebra_map R T).essentially_surjective) :\n--   (algebra_map S (tensor_product R S T)).essentially_surjective :=\n-- begin\n--   rw iff_surjective_comp_localization at h ⊢,\n--   obtain ⟨M, hM, hM'⟩ := h,\n--   refine ⟨M.map (algebra_map R S), _, _⟩,\n--   { rintro ⟨_, x, hx, rfl⟩, rw [subtype.coe_mk, ← is_scalar_tower.algebra_map_apply,\n--     ← algebra.tensor_product.include_right.comp_algebra_map, ring_hom.comp_apply],\n--     exact (hM ⟨x, hx⟩).map _ },\n--   { intro x,\n--     induction x using tensor_product.induction_on with x y x y hx hy,\n--     { exact ⟨0, map_zero _⟩ },\n--     { obtain ⟨y, rfl⟩ := hM' y,\n--       obtain ⟨y, s, rfl⟩ := is_localization.mk'_surjective M y,\n--       refine ⟨is_localization.mk' _ (y • x)\n--         ⟨_, submonoid.mem_map_of_mem (algebra_map R S) s.prop⟩, _⟩,\n--       rw [is_localization.lift_mk', units.mul_inv_eq_iff_eq_mul,\n--         is_unit.coe_lift_right],\n--       simp only [algebra.tensor_product.tmul_mul_tmul, set_like.coe_mk, mul_one,\n--         algebra.id.map_eq_id, ring_hom.coe_monoid_hom, ring_hom.to_monoid_hom_eq_coe,\n--         algebra.tensor_product.algebra_map_apply, ring_hom.id_apply, monoid_hom.restrict_apply,\n--         ring_hom_comp_triple.comp_apply, mul_comm x, ← algebra.smul_def, tensor_product.smul_tmul],\n--       rw [algebra.smul_def, algebra.smul_def, mul_one,\n--         mul_comm, is_localization.lift_mk', mul_assoc],\n--       erw is_unit.lift_right_inv_mul,\n--       rw mul_one },\n--   { obtain ⟨⟨x, rfl⟩, ⟨y, rfl⟩⟩ := ⟨hx, hy⟩, exact ⟨x + y, map_add _ _ _⟩ } }\n-- end\n\n-- variables (f g)\n\n-- lemma of_comp (h : (g.comp f).essentially_surjective) :\n--   g.essentially_surjective :=\n-- begin\n--   rw iff_surjective_comp_localization at h ⊢,\n--   obtain ⟨M, hM, hM'⟩ := h,\n--   refine ⟨M.map f, _, _⟩,\n--   { rintros ⟨_, x, hx, rfl⟩, exact hM ⟨x, hx⟩ },\n--   { intro x,\n--     obtain ⟨x, rfl⟩ := hM' x,\n--     obtain ⟨x, s, rfl⟩ := is_localization.mk'_surjective M x,\n--     refine ⟨is_localization.mk' _ (f x) ⟨_, submonoid.mem_map_of_mem f s.prop⟩, _⟩,\n--     rw [is_localization.lift_mk', units.mul_inv_eq_iff_eq_mul, \n--       mul_comm, is_localization.lift_mk', ← mul_assoc, units.eq_mul_inv_iff_mul_eq],\n--     simp only [ring_hom.to_monoid_hom_eq_coe, function.comp_app, ring_hom.coe_comp,\n--       is_unit.coe_lift_right, set_like.coe_mk, ring_hom.coe_monoid_hom,\n--       monoid_hom.restrict_apply],\n--     exact mul_comm _ _ }\n-- end\n\n-- noncomputable\n-- abbreviation localization.at_prime.map (p : ideal S) [p.is_prime] : \n--   localization.at_prime (p.comap f) →+* localization.at_prime p :=\n-- is_localization.map (localization.at_prime p) f\n--       (show (p.comap f).prime_compl ≤ p.prime_compl.comap f, from le_refl _)\n\n-- lemma iff_stalk :\n--   f.essentially_surjective ↔ ∀ (p : ideal S) [p.is_prime], \n--     by exactI function.surjective (localization.at_prime.map f p) :=\n-- begin\n--   split,\n--   sorry; { introsI H p hp x,\n--     have : ((localization.at_prime.map f p).comp (algebra_map R _)).essentially_surjective,\n--     { rw is_localization.map_comp,\n--       exact (of_localization _ p.prime_compl).comp H },\n--     replace this := of_comp _ _ this,\n--     obtain ⟨a, b, hb, e⟩ := this x,\n--     obtain ⟨a, s, rfl⟩ := is_localization.mk'_surjective (p.comap f).prime_compl a,\n--     obtain ⟨b, t, rfl⟩ := is_localization.mk'_surjective (p.comap f).prime_compl b,\n--     replace hb : b ∈ (ideal.comap f p).prime_compl,\n--     { rwa [is_localization.map_mk', is_localization.at_prime.is_unit_mk'_iff] at hb },\n--     refine ⟨is_localization.mk' _ (a * t) ⟨_, mul_mem s.prop hb⟩, _⟩,\n--     rw [is_localization.map_mk', is_localization.map_mk',\n--       is_localization.eq_mk'_iff_mul_eq, mul_right_comm, ← (is_localization.map_units\n--       (localization.at_prime p) ⟨f t, show f t ∈ p.prime_compl, from t.2⟩).mul_left_inj, mul_assoc,\n--       mul_comm (is_localization.mk' _ _ _), is_localization.mul_mk'_eq_mk'_of_mul] at e,\n--     erw is_localization.mk'_mul_cancel_left at e,\n--     simp_rw [subtype.coe_mk, mul_assoc, ← map_mul] at e,\n--     rw [is_localization.map_mk', is_localization.mk'_eq_iff_eq_mul, ← e],\n--     refl },\n--   { intros H x,\n--     have : ∀ (p : ideal S) [p.is_prime], ∃ a ∉ p.comap f, f a * x ∈ f.range,\n--     { introsI p hp,\n--       obtain ⟨y, hy⟩ := H p (is_localization.mk' _ x (1 : p.prime_compl)),\n--       obtain ⟨y, s, rfl⟩ := is_localization.mk'_surjective (p.comap f).prime_compl y,\n--       rw [is_localization.map_mk', is_localization.mk'_eq_iff_eq, submonoid.coe_one,\n--         mul_one, subtype.coe_mk, is_localization.eq_iff_exists p.prime_compl] at hy,\n--     } \n\n--   }\n-- end\n\n-- end ring_hom.essentially_surjective\n\n-- lemma ring_hom.localization_essentially_surjective :\n--   ring_hom.localization_preserves @ring_hom.essentially_surjective :=\n-- begin\n--   introsI R S _ _ f M R' S' _ _ _ _ _ _ hf,\n--   apply ring_hom.essentially_surjective.of_comp (algebra_map R R'),\n--   rw is_localization.map_comp,\n--   exact (ring_hom.essentially_surjective.of_localization _ $ M.map f).comp hf,\n-- end\n\n-- lemma ring_hom.essentially_surjective_of_localization_span :\n--   ring_hom.of_localization_span @ring_hom.essentially_surjective :=\n-- begin\n--   -- rw ring_hom.of_localization_span_target_iff_finite,\n--   introsI R S _ _ f s hs H x,\n--   letI := f.to_algebra,\n--   apply (fraction_subalgebra R S).to_submodule.mem_of_span_eq_top_of_smul_pow_mem _ hs,\n--   intros r,\n--   replace H := (H r).comp (ring_hom.essentially_surjective.of_localization\n--     (localization.away (r : R)) (submonoid.powers (r : R))),\n--   delta localization.away_map is_localization.away.map at H,\n--   rw is_localization.map_comp at H,\n--   obtain ⟨a, b, hb, e⟩ := H (algebra_map _ _ x),\n--   simp only [ring_hom.comp_apply, ← map_mul] at e,\n--   obtain ⟨⟨_, n, rfl⟩, e'⟩ := (is_localization.eq_iff_exists (submonoid.powers (f r)) _).mp e,\n--   have : ∃ m : ℕ, is_unit (f (b * r ^ m)),\n--   { obtain ⟨c, ⟨_, m, rfl⟩, hc⟩ := is_localization.mk'_surjective\n--       (submonoid.powers (f r)) (↑(hb.unit⁻¹) : localization.away (f r)),\n--     rw [← mul_one (↑(hb.unit⁻¹) : localization.away (f r)), units.eq_inv_mul_iff_mul_eq,\n--       is_unit.unit_spec, ring_hom.comp_apply, is_localization.mul_mk'_eq_mk'_of_mul,\n--       is_localization.mk'_eq_iff_eq_mul, one_mul, subtype.coe_mk, is_localization.eq_iff_exists\n--         (submonoid.powers $ f r)] at hc,\n--     have := is_localization.at_prime.is_unit_to_map_iff,\n--     refine ⟨m, is_unit_of_mul_eq_one _ c _⟩,\n\n--    },\n\n--   have := is_localization.at_prime.is_unit_mk'_iff,\n--   refine ⟨n, a * r ^ n, _⟩,\n-- end\n\n\n-- lemma ring_hom.essentially_surjective_is_local :\n--   ring_hom.property_is_local @ring_hom.essentially_surjective :=\n-- begin\n--   constructor,\n-- end\n\n-- lemma ring_hom.essentially_surjective_of_localization_span :\n--   ring_hom.of_localization_span @ring_hom.essentially_surjective :=\n-- begin\n--   introsI R S _ _ f s hs H,\n--   letI := f.to_algebra,\n--   apply (integral_closure R S).to_submodule.mem_of_span_eq_top_of_smul_pow_mem _ hs,\n--   intros r,\n--   letI := (localization.away_map f r).to_algebra,\n--   haveI : is_scalar_tower R (localization.away (r : R)) (localization.away $ f r) := \n--     is_scalar_tower.of_algebra_map_eq' (is_localization.map_comp _).symm,\n--   haveI : is_scalar_tower R S (localization.away $ f r) := \n--     is_scalar_tower.of_algebra_map_eq' rfl,\n--   obtain ⟨⟨_, n, rfl⟩, p, hp, hp'⟩ := is_integral.exists_multiple_integral_of_is_localization\n--     (submonoid.powers (r : R)) _ (H r (algebra_map _ _ x)),\n--   simp only [submonoid.smul_def, subtype.coe_mk, algebra.smul_def, ring_hom.comp_apply,\n--     is_scalar_tower.algebra_map_eq R S (localization.away $ f r), ← map_mul] at hp',\n--   rw [eval₂_eq_eval_map, ← map_map, eval_map, eval₂_at_apply, ← @is_localization.mk'_one _ _\n--     (submonoid.powers $ f r), is_localization.mk'_eq_zero_iff] at hp',\n--   obtain ⟨⟨_, m, rfl⟩, H'⟩ := hp',\n--   rw [subtype.coe_mk, mul_comm, ← map_pow, ← ring_hom.algebra_map_to_algebra f,\n--     eval_map, ← eval₂_smul] at H',\n--   by_cases (r : R) ^ m = 0, { use m, rw [h, zero_smul], exact zero_mem _ },\n--   have hp'' : ((r : R) ^ m • p).leading_coeff = (r : R) ^ m,\n--   { have hp'' : ((r : R) ^ m • p).coeff p.nat_degree = (r : R) ^ m,\n--     { rw [coeff_smul, coeff_nat_degree, hp.leading_coeff, smul_eq_mul, mul_one] },\n--     have : ((r : R) ^ m • p).nat_degree = p.nat_degree,\n--     { exact (nat_degree_smul_le _ _).antisymm (le_nat_degree_of_ne_zero $ hp''.trans_ne h) },\n--     rw [leading_coeff, this, hp''] },\n--   have := is_integral_leading_coeff_smul _ _ H',\n--   rw [hp'', ← algebra.smul_def, smul_smul, ← pow_add] at this,\n--   exact ⟨m+n, this⟩\n-- end\n", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/for_mathlib/essentially_surjective.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.45166701426328343}}
{"text": "import GMLInit.Data.Basic\nimport GMLInit.Data.HVal\nimport GMLInit.Data.List.Basic\nimport GMLInit.Logic.ListConnectives\nimport GMLInit.Meta.Basic\nimport GMLInit.Meta.Relation\n\ninductive HList.{u} : List (Sort u) → Type u\n| nil : HList []\n| cons {α αs} : α → HList αs → HList (α :: αs)\n\nnamespace HList\n\nscoped infixr:67 \" :: \" => HList.cons\nscoped syntax (name := hlist) \"[\" term,* \"]\"  : term\nscoped macro_rules (kind := hlist)\n  | `([ ])           => `(HList.nil)\n  | `([ $a ])        => `(HList.cons $a HList.nil)\n  | `([ $a, $as,* ]) => `(HList.cons $a [$as,*])\n\nprotected theorem cons_hcongr {α β} {αs βs : List (Sort _)} {a : α} {b : β} {as : HList αs} {bs : HList βs} : α = β → αs = βs → a ≅ b → as ≅ bs → HList.cons a as ≅ HList.cons b bs\n| rfl, rfl, HEq.rfl, HEq.rfl => HEq.rfl\n\n-- FIXME\n-- def ofList {α : Type _} : (as : List α) → HList (as.map fun x => α)\n-- | [] => []\n-- | a::as => a :: ofList as\n\nprotected def ofListHVal : (vs : List HVal) → HList (vs.map HVal.sort)\n| [] => []\n| v::vs => v.val :: HList.ofListHVal vs\n\n@[specialize, inline] protected def foldl : {αs : List (Sort _)} → {β : Sort _} → HList αs → HList (αs.map fun α => α → β → β) → β → β\n| [], _, [], [], b => b\n| _::_, _, x :: xs, f :: fs, b => HList.foldl xs fs (f x b)\n\nprotected def foldr : {αs : List (Sort _)} → {β : Sort _} → HList αs → HList (αs.map fun α => α → β → β) → β → β\n| [], _, [], [], b => b\n| _::_, _, x :: xs, f :: fs, b => f x (HList.foldr xs fs b)\n\nprotected def append : {αs βs : List (Sort _)} → HList αs → HList βs → HList (αs ++ βs)\n| [], _, [], bs => bs\n| α :: αs, βs, a::as, bs => List.cons_append α αs βs ▸ cons a (HList.append as bs)\n\nprotected theorem nil_append {βs : List (Sort _)} (bs : HList βs) : HList.append [] bs = bs := rfl\n\nprotected theorem cons_append {α : Sort _} {αs βs : List (Sort _)} (a : α) (as : HList αs) (bs : HList βs) : HList.append (a :: as) bs = a :: HList.append as bs := rfl\n\nprotected theorem append_nil {αs : List (Sort _)} (as : HList αs) : HList.append as [] ≅ as := by\n  induction as with\n  | nil => rw [HList.nil_append]\n  | cons _ _ ih =>\n    rw [HList.cons_append]\n    apply HList.cons_hcongr\n    · reflexivity\n    · rw [List.append_nil]\n    · reflexivity using (.≅.)\n    · exact ih\n\nprotected theorem append_assoc {αs βs γs : List (Sort _)} (as : HList αs) (bs : HList βs) (cs : HList γs) : HList.append (HList.append as bs) cs ≅ HList.append as (HList.append bs cs) := by\n  induction as with\n  | nil => rw [HList.nil_append, HList.nil_append]\n  | cons _ _ ih =>\n    rw [HList.cons_append, HList.cons_append]\n    apply HList.cons_hcongr\n    · reflexivity\n    · rw [List.append_assoc]\n    · reflexivity using (.≅.)\n    · exact ih\n\nprotected def mk : {αs : List (Sort _)} → ((i : Index αs) → i.val) → HList αs\n| [], _ => []\n| _::_, v => v .head :: HList.mk λ i => v (.tail i)\n\nprotected def eval : {αs : List (Sort _)} → HList αs → (i : Index αs) → i.val\n| _::_, a::_, .head => a\n| _::_, _::as, .tail i => HList.eval as i\n\ndef equiv (αs : List (Sort _)) : Equiv (HList αs) ((i : Index αs) → i.val) where\n  fwd := HList.eval\n  rev := HList.mk\n  spec := by\n    intros as f\n    constr\n    · intro h\n      cases h\n      induction as with\n      | nil => rfl\n      | cons a as H => clean unfold HList.mk HList.eval; rw [H]\n    · intro h\n      cases h\n      funext i\n      induction i with\n      | head => rfl\n      | tail i H => clean unfold HList.mk HList.eval; rw [H]\n\nend HList\n", "meta": {"author": "fgdorais", "repo": "GMLInit", "sha": "a295111627ac907ebc6a86f906dd9b4d69b338d8", "save_path": "github-repos/lean/fgdorais-GMLInit", "path": "github-repos/lean/fgdorais-GMLInit/GMLInit-a295111627ac907ebc6a86f906dd9b4d69b338d8/GMLInit/Data/List/HList.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191214879991, "lm_q2_score": 0.6370307806984445, "lm_q1q2_score": 0.45166700449162533}}
{"text": "/-\nCopyright (c) 2018 Bruno Bentzen. All rights reserved.\nReleased under the Apache License 2.0 (see \"License\");\nAuthor: Bruno Bentzen\n-/\n\nimport .basic\n\nopen prf\n\nvariable {σ : nat}\n\nnamespace prf\n\n/- identity implication -/\n\nlemma id {p : form σ} {Γ : ctx σ} :\n  Γ ⊢ₛ₅ p ⊃ p :=\nmp (mp (@pl2 σ Γ p (p ⊃ p) p) pl1) pl1\n\n/- deduction metatheorem -/\n\ntheorem deduction {Γ : ctx σ} {p q : form σ} :\n  (Γ ⸴ p ⊢ₛ₅ q) → (Γ ⊢ₛ₅ p ⊃ q) :=\nbegin\n  generalize eq : (Γ ⸴ p) = Γ',\n  intro h,\n  induction h; subst eq,\n  { repeat {cases h_h},\n    exact id,\n    { exact mp pl1 (ax h_h) } },\n  { exact mp pl1 pl1 },\n  { exact mp pl1 pl2 },\n  { exact mp pl1 pl3 },\n  { apply mp,\n    { exact (mp pl2 (h_ih_hpq rfl)) },\n    { exact h_ih_hp rfl } },\n  { exact mp pl1 k },\n  { exact mp pl1 t },\n  { exact mp pl1 s4 },\n  { exact mp pl1 b },\n  { exact mp pl1 (nec h_h) }\nend\n\n/- structural rules -/\n\nlemma sub_weak {Γ Δ : ctx σ} {p : form σ} :\n  (Δ ⊢ₛ₅ p) → (Δ ⊆ Γ) → (Γ ⊢ₛ₅ p) :=\nbegin\n  intros h s,\n  induction h,\n  { apply ax, exact s h_h },\n  { exact pl1 },\n  { exact pl2 },\n  { exact pl3 },\n  { apply mp,\n    { exact h_ih_hpq s },\n    {exact h_ih_hp s} },\n  { exact k },\n  { exact t },\n  { exact s4 },\n  { exact b },\n  { exact nec h_h }\nend\n\nlemma weak {Γ : ctx σ} {p q : form σ} :\n  (Γ ⊢ₛ₅ p) → (Γ ⸴ q ⊢ₛ₅ p) :=\nbegin\n  intro h,\n  induction h,\n  { apply ax,\n    exact (set.mem_insert_of_mem _ h_h) },\n  { exact pl1 },\n  { exact pl2 },\n  { exact pl3 },\n  { apply mp,\n    { exact h_ih_hpq },\n    { exact h_ih_hp } },\n  { exact k },\n  { exact t },\n  { exact s4 },\n  { exact b },\n  { exact nec h_h }\nend\n\nlemma contr {Γ : ctx σ} {p q : form σ} :\n  (Γ ⸴ p ⸴ p ⊢ₛ₅ q) → (Γ ⸴ p ⊢ₛ₅ q) :=\nbegin\n  generalize eq : (Γ ⸴ p ⸴ p) = Γ',\n  intro h,\n  induction h; subst eq,\n  { apply ax,\n    cases set.eq_or_mem_of_mem_insert h_h,\n    { rw h, apply set.mem_insert},\n    { exact h } },\n  { exact pl1 },\n  { exact pl2 },\n  { exact pl3 },\n  { apply mp,\n    { exact h_ih_hpq rfl },\n    { exact h_ih_hp rfl } },\n  { exact k },\n  { exact t },\n  { exact s4 },\n  { exact b },\n  { exact nec h_h }\nend\n\nlemma exg {p q r : form σ} {Γ : ctx σ} :\n  (Γ ⸴ p ⸴ q ⊢ₛ₅ r) → (Γ ⸴ q ⸴ p ⊢ₛ₅ r) :=\nbegin\n  generalize eq : (Γ ⸴ p ⸴ q) = Γ',\n  intro h,\n  induction h; subst eq,\n  { apply ax,\n    cases set.eq_or_mem_of_mem_insert h_h,\n    { rw h, apply set.mem_insert_of_mem _ _,\n      apply set.mem_insert _ _ },\n      { cases set.eq_or_mem_of_mem_insert h with h' h',\n        { rw h', apply set.mem_insert _ _ },\n        { apply set.mem_insert_of_mem _ _,\n          apply set.mem_insert_of_mem _ _,\n          exact h' } } },\n  { exact pl1 },\n  { exact pl2 },\n  { exact pl3 },\n  { apply mp,\n    { exact h_ih_hpq rfl },\n    { exact h_ih_hp rfl } },\n  { exact k },\n  { exact t },\n  { exact s4 },\n  { exact b },\n  { exact nec h_h }\nend\n\n/- subcontext operations -/\n\nlemma subctx_ax {Γ Δ : ctx σ} {p : form σ} :\n   Δ ⊆ Γ → (Δ ⊢ₛ₅ p) → (Γ ⊢ₛ₅ p) :=\nbegin\n  intros s h,\n  induction h,\n  { apply ax (s h_h) },\n  { exact pl1 },\n  { exact pl2 },\n  { exact pl3 },\n  { apply mp,\n    { exact h_ih_hpq s },\n    { exact h_ih_hp s } },\n  { exact k },\n  { exact t },\n  { exact s4 },\n  { exact b },\n  { exact nec h_h }\nend\n\nlemma subctx_contr {Γ Δ : ctx σ} {p : form σ}:\n   Δ ⊆ Γ → (Γ ∪ Δ ⊢ₛ₅ p) → (Γ ⊢ₛ₅ p) :=\nbegin\n  generalize eq : Γ ∪ Δ = Γ',\n  intros s h,\n  induction h; subst eq,\n  { cases h_h,\n    { exact ax h_h },\n    { exact ax (s h_h) } },\n  { exact pl1 },\n  { exact pl2 },\n  { exact pl3 },\n  { apply mp,\n    { exact h_ih_hpq rfl },\n    { exact h_ih_hp rfl } },\n  { exact k },\n  { exact t },\n  { exact s4 },\n  { exact b },\n  { exact nec h_h }\nend\n\n/- right-hand side basic rules of inference -/\n\nlemma pr {Γ : ctx σ} {p : form σ} :\n  Γ ⸴ p ⊢ₛ₅ p :=\nby apply ax; apply or.intro_left; simp\n\nlemma pr1 {Γ : ctx σ} {p q : form σ} :\n  Γ ⸴ p ⸴ q ⊢ₛ₅ p :=\nby apply ax; apply or.intro_right; apply or.intro_left; simp\n\nlemma pr2 {Γ : ctx σ} {p q : form σ} :\n  Γ ⸴ p ⸴ q ⊢ₛ₅ q :=\nby apply ax; apply or.intro_left; simp\n\nlemma by_mp1 {Γ : ctx σ} {p q : form σ} :\n  Γ ⸴ p ⸴ p ⊃ q ⊢ₛ₅ q :=\nmp pr2 pr1\n\nlemma by_mp2 {Γ : ctx σ} {p q : form σ} :\n  Γ ⸴ p ⊃ q ⸴ p ⊢ₛ₅ q :=\nmp pr1 pr2\n\nlemma cut {Γ : ctx σ} {p q r : form σ} :\n  (Γ ⊢ₛ₅ p ⊃ q) → (Γ ⊢ₛ₅ q ⊃ r) → (Γ ⊢ₛ₅ p ⊃ r) :=\nλ hpq hqr, mp (mp pl2 (mp pl1 hqr)) hpq\n\nlemma conv_deduction {Γ : ctx σ} {p q : form σ} :\n  (Γ ⊢ₛ₅ p ⊃ q) → (Γ ⸴ p ⊢ₛ₅ q) :=\nλ h, mp (weak h) pr \n\n/- left-hand side basic rules of inference -/\n\nlemma mp_in_ctx_left {Γ : ctx σ} {p q r : form σ} :\n  (Γ ⸴ p ⸴ q ⊢ₛ₅ r) → (Γ ⸴ p ⸴ p ⊃ q ⊢ₛ₅ r) :=\nbegin\n  generalize eq : (Γ ⸴ p ⸴ q) = Γ',\n  intros h,\n  induction h; subst eq,\n  { cases h_h,\n    { rw h_h,\n      exact by_mp1 },\n    { cases h_h,\n      { rw h_h,\n        exact pr1 },\n      { apply ax,\n        apply set.mem_insert_of_mem _ _,\n        apply set.mem_insert_of_mem _ _, exact h_h } } },\n    { exact pl1 },\n    { exact pl2 },\n    { exact pl3 },\n    { apply mp,\n      { exact h_ih_hpq rfl },\n      { exact h_ih_hp rfl } },\n    { exact k },\n    { exact t },\n    { exact s4 },\n    { exact b },\n    { exact nec h_h }\nend\n\nlemma mp_in_ctx_right {Γ : ctx σ} {p q r : form σ} :\n  (Γ ⸴ p ⸴ p ⊃ q ⊢ₛ₅ r) → (Γ ⸴ p ⸴ q ⊢ₛ₅ r) :=\nbegin\n  generalize eq : (Γ ⸴ p ⸴ p ⊃ q) = Γ',\n  intros h,\n  induction h; subst eq,\n  { cases h_h,\n    { subst h_h,\n      exact mp pl1 pr },\n    { cases h_h,\n      { subst h_h,\n        exact pr1 },\n      { exact weak (weak (ax h_h)) } } },\n    { exact pl1 },\n    { exact pl2 },\n    { exact pl3 },\n    { apply mp,\n      { exact h_ih_hpq rfl },\n      { exact h_ih_hp rfl } },\n    { exact k },\n    { exact t },\n    { exact s4 },\n    { exact b },\n    { exact nec h_h }\nend\n\n/- basic lemmas -/\n\nlemma contrap {Γ : ctx σ} {p q : form σ} :\n  Γ ⊢ₛ₅ ((~q) ⊃ (~p)) ⊃ (p ⊃ q) :=\ndeduction (deduction (mp (mp pl3 pr1) (mp pl1 pr2) ))\n\nlemma not_impl {Γ : ctx σ} {p q : form σ} : \n  Γ ⊢ₛ₅ (p ⊃ q) ⊃ ((~q) ⊃ (~p)) :=\nbegin\n  repeat { apply deduction },\n  apply mp,\n  { exact pr1 },\n    apply mp,\n    { apply ax,\n      apply set.mem_insert_of_mem,\n      apply set.mem_insert_of_mem,\n      apply set.mem_insert },\n    { exact pr2 }\nend\n\nlemma dne {p : form σ} {Γ : ctx σ} :\n  Γ ⊢ₛ₅ (~~p) ⊃ p :=\nhave h : Γ ⊢ₛ₅ (~~p) ⊃ ((~p) ⊃ (~p)) := mp pl1 id,\nmp (mp pl2 (cut pl1 pl3)) h\n\nlemma dni {p : form σ} {Γ : ctx σ} :\n  Γ ⊢ₛ₅ p ⊃ (~~p) :=\nmp contrap dne\n\nlemma lem {p : form σ} {Γ : ctx σ} :\n  Γ ⊢ₛ₅ p ∨ ~p :=\nmp dni (mp contrap dne)\n\nlemma not_impl_to_and {p q : form σ} {Γ : ctx σ} :\n  Γ ⊢ₛ₅ (~(p ⊃ q)) ⊃ (p & (~q)) :=\nbegin\n  repeat {apply deduction},\n  apply (mp pr1),\n  { apply deduction,\n    apply mp,\n    { apply dne },\n    { exact (mp pr1 pr2) } },\nend\n\nlemma and_not_to_not_impl {p q : form σ} {Γ : ctx σ} :\n  Γ ⊢ₛ₅ (p & (~q)) ⊃ ~(p ⊃ q) :=\nbegin\n  repeat {apply deduction},\n  apply mp,\n  { apply pr1 },\n  { apply cut,\n    { apply pr2 },\n    { apply dni } }\nend\n\n/- basic modal lemmas (K and B) -/\n\nlemma box_contrap {p q : form σ} :\n · ⊢ₛ₅ (◻(p ⊃ q)) ⊃ (◻((~q) ⊃ ~p)) :=\nprf.mp (prf.k) (prf.nec prf.not_impl)\n\nlemma diamond_k {p q : form σ} :\n · ⊢ₛ₅ (◻(p ⊃ q)) ⊃ ((◇p) ⊃ (◇q)) :=\nprf.deduction $ prf.mp prf.not_impl\n(prf.mp prf.k (prf.mp (prf.weak box_contrap) prf.pr ))\n\nlemma box_dne {p : form σ} :\n · ⊢ₛ₅ (◻~~p) ⊃ (◻p) :=\nprf.mp (prf.k) (prf.nec (prf.dne))\n\nlemma box_dni {p : form σ} :\n · ⊢ₛ₅ (◻p) ⊃ (◻~~p) :=\nprf.mp (prf.k) (prf.nec (prf.dni))\n\nlemma not_box_dni {p : form σ} :\n · ⊢ₛ₅ (~◻p) ⊃ (~◻~~p) :=\nprf.mp prf.not_impl box_dne\n\nlemma not_box_dne {p : form σ} :\n · ⊢ₛ₅ (~◻~~p) ⊃ (~◻p) :=\nprf.mp prf.not_impl box_dni\n\nlemma diamond_dne {p : form σ} :\n · ⊢ₛ₅ (◇~~p) ⊃ (◇p) :=\nnot_box_dne\n\nlemma diamond_dni {p : form σ} :\n · ⊢ₛ₅ (◇p) ⊃ (◇~~p) :=\nnot_box_dni\n\nlemma contrap_b {p : form σ} :\n · ⊢ₛ₅ (◇◻p) ⊃ p :=\nbegin\n  apply prf.cut,\n  show (· ⊢ₛ₅ (◇◻p) ⊃ (~◻~◻~~p)),\n    from @prf.mp _ _ (◻(◻p ⊃ ◻(~~p))) _ diamond_k (prf.nec box_dni),\n  apply prf.cut,\n  show (· ⊢ₛ₅ (~◻~◻~~p) ⊃ ~~p),\n    from prf.mp prf.not_impl prf.b,\n  apply prf.dne\nend\n\n/- notable introduction rules -/\n\nlemma negintro {p q : form σ} {Γ : ctx σ} :\n  (Γ ⊢ₛ₅ p ⊃ q) → (Γ ⊢ₛ₅ p ⊃ ~q) → (Γ ⊢ₛ₅ ~p) :=\nhave h : ∀ q, (Γ ⊢ₛ₅ p ⊃ q) → (Γ ⊢ₛ₅ (~~p) ⊃ q) := λ q h, cut dne h,\n  λ hp hnp, mp (mp pl3 (h (~q) hnp)) (h q hp)\n\nlemma ex_falso {Γ : ctx σ} {p : form σ} :\n  (Γ ⊢ₛ₅ ⊥) → (Γ ⊢ₛ₅ p) :=\nbegin\n  intro h,\n  apply mp,\n  { exact dne },\n  { apply mp,\n    { exact pl1 },\n    { exact h } }\nend\n\nlemma ex_falso_and {Γ : ctx σ} {p q : form σ} :\n  Γ ⊢ₛ₅ (~p) ⊃ (p ⊃ q) :=\nbegin\n  repeat {apply deduction},\n  apply ex_falso,\n  exact (mp pr1 pr2)\nend\n\nlemma ex_falso_pos {Γ : ctx σ} {p q : form σ} :\n  Γ ⊢ₛ₅ p ⊃ ((~p) ⊃ q) :=\nbegin\n  repeat {apply deduction},\n  apply mp,\n  { apply mp,\n    { apply ex_falso_and },\n    { exact pr2 } },\n  { exact pr1 },\nend\n\nlemma contr_conseq {Γ : ctx σ} {p r : form σ} :\n  Γ ⊢ₛ₅ (p ⊃ r) ⊃ (((~p) ⊃ r) ⊃ r) :=\nbegin\n  repeat {apply deduction},\n  apply mp,\n  { apply mp,\n    { apply pl3, exact p },\n    { apply mp,\n      { apply not_impl },\n      { exact pr1 } } },\n  { apply cut,\n    { apply mp,\n      { apply not_impl,\n        exact (~p) },\n      { apply pr2 } },\n        apply dne }\nend\n\nlemma impl_weak {p q r : form σ} {Γ : ctx σ} (h : (Γ ⸴ r ⊢ₛ₅ p) → (Γ ⊢ₛ₅ p)) :\n  ((Γ ⊢ₛ₅ p) → (Γ ⊢ₛ₅ q)) → ((Γ ⸴ r ⊢ₛ₅ p) → (Γ ⸴ r ⊢ₛ₅ q)) :=\nλ hpq hp, weak (hpq (h hp))\n\nlemma and_intro {Γ : ctx σ} {p q : form σ} :\n  (Γ ⊢ₛ₅ p) → (Γ ⊢ₛ₅ q) → (Γ ⊢ₛ₅ (p & q)) :=\nbegin\n  intros hp hq,\n  apply deduction,\n  apply mp,\n    apply mp,\n    { apply pr },\n    repeat { apply weak, assumption }\nend\n\n\nlemma and_elim_left {p q : form σ} {Γ : ctx σ} :\n  (Γ ⸴ (p & q) ⊢ₛ₅ p) :=\nbegin\n  apply mp,\n  { apply dne },\n  { apply mp,\n    { apply mp,\n      { apply pl2, exact (p ⊃ (q ⊃ ⊥)) },\n      { apply mp,\n        { apply pl1 },\n        { exact pr } } },\n    { exact ex_falso_and } }\nend\n\nlemma and_elim_right {p q : form σ} {Γ : ctx σ} :\n  (Γ ⸴ (p & q) ⊢ₛ₅ q) :=\nbegin\n  apply mp,\n  { apply dne },\n  { apply mp,\n    { apply mp,\n      { apply pl2, exact (p ⊃ (q ⊃ ⊥)) },\n      { apply mp,\n        { apply pl1 },\n        { exact pr } } },\n    repeat {apply deduction},\n    apply mp,\n    { apply ax,\n      apply set.mem_insert_of_mem,\n      apply set.mem_insert_of_mem,\n      apply set.mem_insert },\n    { exact pr2 } }\nend\n\nlemma or_intro_left {Γ : ctx σ} {p q r : form σ} :\n  (Γ ⊢ₛ₅ p) → (Γ ⊢ₛ₅ (p ∨ q)) :=\nbegin\n  intros hp, simp,\n  apply mp,\n  { apply dni },\n  { apply deduction,\n    { apply mp,\n      { apply mp,\n        { apply ex_falso_and },\n        { exact pr } },\n      { apply weak, assumption } } }\nend\n\nlemma or_intro_right {Γ : ctx σ} {p q r : form σ} :\n  (Γ ⊢ₛ₅ q) → (Γ ⊢ₛ₅ (p ∨ q)) :=\nbegin\n  intros hp, simp,\n  apply mp,\n  { apply dni },\n  { apply deduction,\n    { apply mp,\n      { apply dni },\n      {apply weak, assumption } } }\nend\n\nlemma or_elim {Γ : ctx σ} {p q r : form σ} :\n  (Γ ⊢ₛ₅ (p ∨ q)) → (Γ ⊢ₛ₅ p ⊃ r) → (Γ ⊢ₛ₅ q ⊃ r) → (Γ ⊢ₛ₅ r) :=\nbegin\n  intros hpq hpr hqr,\n  apply mp,\n    { apply mp,\n      { apply contr_conseq, exact p },\n      { assumption } },\n    { apply cut,\n      { apply mp,\n        { apply dne },\n        { assumption } },\n      { apply cut,\n        exact dne,\n        assumption } }\nend\n\nlemma detach_pos {Γ : ctx σ} {p q : form σ} :\n  (Γ ⸴ p ⊢ₛ₅ q) → (Γ ⸴ ~p ⊢ₛ₅ q) → (Γ ⊢ₛ₅ q) :=\nbegin\n  intros hpq hnpq,\n  apply or_elim,\n  { apply lem },\n  repeat {apply deduction, assumption}\nend\n\nlemma detach_neg {Γ : ctx σ} {p q : form σ} :\n  (Γ ⸴ ~p ⊢ₛ₅ q) → (Γ ⸴ p ⊢ₛ₅ q) → (Γ ⊢ₛ₅ q) :=\nbegin\n  intros hpq hnpq,\n  apply or_elim,\n  { apply lem },\n  { apply deduction, exact hnpq },\n  { apply deduction, assumption }\nend\n\nend prf", "meta": {"author": "bbentzen", "repo": "mpl", "sha": "bb5066ec51fa11a4b66f440c4f6c9a3d8fb2e0de", "save_path": "github-repos/lean/bbentzen-mpl", "path": "github-repos/lean/bbentzen-mpl/mpl-bb5066ec51fa11a4b66f440c4f6c9a3d8fb2e0de/src/s5/syntax/lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6859494550081925, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.4516411348735124}}
{"text": "import lambda_calculus.utlc.basic\nimport lambda_calculus.utlc.identities\nimport lambda_calculus.utlc.reduction\nimport lambda_calculus.utlc.beta.basic\nimport lambda_calculus.utlc.beta.church_rosser\nimport lambda_calculus.utlc.eta.basic\nimport lambda_calculus.utlc.eta.normal\nimport lambda_calculus.utlc.eta.church_rosser\nimport lambda_calculus.utlc.beta_eta.basic\nimport logic.relation\n\n\nnamespace lambda_calculus\nnamespace utlc\nnamespace βη\n\nlocal notation a `[` b `:=` c  `]` : 70 := has_substitution.substitution a b c\n\ntheorem βη_diamond_step {a b c: utlc}:\n   a →β b → a →η c →\n   ∃ x, b ↠η x ∧ (c = x ∨ c →β x) :=\nbegin\n  induction a generalizing b c;\n  simp;\n  intros hab hac,\n  { rcases β.lambda_step_exists hab with ⟨b₁, hb₁, hab⟩,\n    cases η.lambda_step_cases' hac with hac hac;\n    rcases hac with ⟨c₁, hc₁, hac⟩;\n     rw [hb₁, hc₁],\n    { rcases a_ih hab hac with ⟨x, hbx, hcx⟩,\n      use Λ x,\n      refine ⟨ η.lambda_reduction_lambda hbx, _ ⟩,\n      simp [hcx] },\n    rw [hac] at hab,\n    obtain hab|hab|hab := β.dot_step_cases hab;\n    rcases hab with ⟨b₂, hb₂, hab⟩,\n    { \n      cases shift_of_uses_zero (show b₂.uses 1 = 0, begin\n        rw [← lambda_uses, ← hab],\n        exact shift_uses_self _ _,\n      end) with b₃ hb₃,\n      rw [hb₃, ← lambda_shift, shift_inj_iff] at hab,\n      rw [hab, hb₂, hb₃, shift_succ_substitiution_down],\n      use Λ b₃,\n      exact ⟨ by refl, or.inl rfl⟩ },\n    { rw [hb₂],\n      cases shift_of_uses_zero (β.uses_zero_step hab (shift_uses_self _ _)) with b₃ hb₃,\n      rw [hb₃],\n      rw [hb₃] at hab,\n      use b₃,\n      split,\n      apply relation.refl_trans_gen.single,\n      apply η.lambda_step_head,\n      right,\n      apply (shift_reduction_step_shift_iff _).mp,\n      apply hab,\n      apply β.shift_head_step_shift },\n    { simp at hab, contradiction } },\n  { obtain hab|hab|hab := β.dot_step_cases hab;\n    cases η.dot_step_cases' hac with hac hac;\n    rcases hab with ⟨x, hax, hxb⟩;\n    rcases hac with ⟨y, z, hza, hcyz, hay⟩,\n    { rw [hax, ←hza, hcyz],\n      rw [hxb] at hay,\n      cases η.lambda_step_cases' hay with hay hay;\n      rcases hay with ⟨y₁, hy₁, hxy₁⟩,\n      { rw [hy₁],\n        use y₁[0:=z],\n        split,\n        apply substitution_reduction_step_left,\n        apply η.head_step_substitution,\n        apply hxy₁,\n        right,\n        apply β.lambda_dot_step_substitution },\n      { simp [hxy₁, hy₁],\n        use y₁·z,\n        exact ⟨by refl, or.inl rfl⟩ } },\n    { rw [hax, hcyz, hza, hxb],\n      use x[0:=z],\n      split,\n      apply substitution_reduction_step_right,\n      apply η.shift_head_step_shift,\n      apply hay,\n      right,\n      apply β.lambda_dot_step_substitution, },\n    { rw [hax, ← hza, hcyz],\n      rcases a_ih_f hxb hay with ⟨m, hxm, hym⟩,\n      use m·z,\n      split,\n      apply η.dot_reduction_dot_left hxm,\n      cases hym,\n      { simp [hym] },\n      right,\n      apply β.dot_step_dot_left hym },\n    { rw [hax, hcyz, hza],\n      use x·z,\n      split,\n      apply η.dot_reduction_dot_right,\n      apply relation.refl_trans_gen.single hay,\n      right,\n      apply β.dot_step_dot_left hxb },\n    { rw [hax, hcyz, hza],\n      use y·x,\n      split,\n      apply η.dot_reduction_dot_left,\n      apply relation.refl_trans_gen.single hay,\n      right,\n      apply β.dot_step_dot_right hxb },\n    { rw [hax, ← hza, hcyz],\n      rcases a_ih_g hxb hay with ⟨m, hxm, hym⟩,\n      use y·m,\n      split,\n      apply η.dot_reduction_dot_right hxm,\n      cases hym,\n      { simp [hym] },\n      right,\n      apply β.dot_step_dot_right hym },\n  }\nend\n\ntheorem βη_diamond_step_reduction {a b c: utlc}: a →β b → a ↠η c →\n  ∃ x, b ↠η x ∧ c ↠β x :=\nbegin\n  intros hab hac,\n  induction hac using relation.refl_trans_gen.head_induction_on with a f haf hfc ih generalizing b hab,\n  exact ⟨b, by refl, relation.refl_trans_gen.single hab ⟩,\n  rcases βη_diamond_step hab haf with ⟨g, hbg, hfg⟩,\n  cases hfg,\n  { refine ⟨ c, trans hbg _, by refl ⟩,\n    rw [← hfg],\n    exact hfc },\n  rcases ih hfg with ⟨x, hgx, hcx⟩,\n  refine ⟨x, trans hbg hgx, hcx⟩,\nend\n\ntheorem βη_diamond_reduction {a b c: utlc}: a ↠β b → a ↠η c →\n  ∃ x, b ↠η x ∧ c ↠β x :=\nbegin\n  intros hab hac,\n  induction hab using relation.refl_trans_gen.head_induction_on with a f haf hfb ih generalizing c hac,\n  exact ⟨c, hac, by refl⟩,\n  rcases βη_diamond_step_reduction haf hac with ⟨g, hfg, hcg⟩,\n  rcases ih hfg with ⟨x, hbx, hgx⟩,\n  refine ⟨x, hbx, trans hcg hgx⟩,\nend\n\ntheorem β_diamond_reduction {a b c: utlc}: a ↠β b → a ↠βη c →\n  ∃ x, b ↠βη x ∧ c ↠β x :=\nbegin\n  intros hab hac,\n  induction hac using relation.refl_trans_gen.head_induction_on with a f haf hfc ih generalizing b hab,\n  exact ⟨b, by refl, hab⟩,\n  rw [step_iff] at haf,\n  cases haf,\n  { rcases β.church_rosser hab (relation.refl_trans_gen.single haf) with ⟨x, hbx, hfx⟩,\n    rcases ih hfx with ⟨y, hxy, hcy⟩,\n    refine ⟨y, trans (reduction_of_beta hbx) hxy, hcy⟩ },\n  { rcases βη_diamond_reduction hab (relation.refl_trans_gen.single haf) with ⟨x, hbx, hfx⟩,\n    rcases ih hfx with ⟨y, hxy, hcy⟩,\n    refine ⟨y, trans (reduction_of_eta hbx) hxy, hcy⟩ },\nend\n\ntheorem η_diamond_reduction {a b c: utlc}: a ↠η b → a ↠βη c →\n  ∃ x, b ↠βη x ∧ c ↠η x :=\nbegin\n  intros hab hac,\n  induction hac using relation.refl_trans_gen.head_induction_on with a f haf hfc ih generalizing b hab,\n  exact ⟨b, by refl, hab⟩,\n  rw [step_iff] at haf,\n  cases haf,\n  { rcases βη_diamond_reduction (relation.refl_trans_gen.single haf) hab with ⟨x, hfx, hbx⟩,\n    rcases ih hfx with ⟨y, hxy, hcy⟩,\n    refine ⟨y, trans (reduction_of_beta hbx) hxy, hcy⟩ },\n  { rcases η.church_rosser hab (relation.refl_trans_gen.single haf) with ⟨x, hbx, hfx⟩,\n    rcases ih hfx with ⟨y, hxy, hcy⟩,\n    refine ⟨y, trans (reduction_of_eta hbx) hxy, hcy⟩ }\nend\n\ntheorem church_rosser {a b c : utlc}:\n  a ↠βη b → a ↠βη c → b ≡βη c :=\nbegin\n  intros hab hac,\n  induction hab using relation.refl_trans_gen.head_induction_on with a f haf hfb ih generalizing c hac,\n  { use c,\n    exact ⟨ hac, by refl⟩, },\n  rw [step_iff] at haf,\n  cases haf,\n  { rcases β_diamond_reduction (relation.refl_trans_gen.single haf) hac with ⟨x, hfx, hcx⟩,\n    rcases ih hfx with ⟨y, hby, hxy⟩,\n    refine ⟨y, hby, trans (reduction_of_beta hcx) hxy ⟩ },\n  { rcases η_diamond_reduction (relation.refl_trans_gen.single haf) hac with ⟨x, hfx, hcx⟩,\n    rcases ih hfx with ⟨y, hby, hxy⟩,\n    refine ⟨y, hby, trans (reduction_of_eta hcx) hxy ⟩ }\nend\n\n\n@[refl]\ntheorem equiv_refl (f : utlc): f ≡βη f :=\n  ⟨f, relation.refl_trans_gen.refl, relation.refl_trans_gen.refl⟩\n\n@[symm]\ntheorem equiv_symm {a b: utlc}: a ≡βη b → b ≡βη a :=\nbegin\n  apply relation.symmetric_join\nend\n\n@[trans]\ntheorem equiv_trans {a b c : utlc}: a ≡βη b → b ≡βη c → a ≡βη c :=\nbegin\n  apply relation.transitive_join,\n  apply relation.refl_trans_gen.trans,\n  apply @church_rosser,\nend\n\ntheorem reduced_reduction_inj {f g: utlc}: reduced f → f ↠βη g → f = g :=\nbegin\n  intros hf p,\n  induction p with x y hx hy fx,\n  { refl },\n  rw [←fx] at *,\n  exfalso,\n  apply reduced_iff_no_reduction.mp hf _ hy\nend\n\ntheorem reduced_equiv_inj {f g: utlc}: reduced f → reduced g → f ≡βη g → f = g :=\nbegin\n  intros hf hg p,\n  cases p with x p,\n  rw [reduced_reduction_inj hf p.left, reduced_reduction_inj hg p.right]\nend\n\nend βη\nend utlc\nend lambda_calculus", "meta": {"author": "calcu16", "repo": "lean_complexity", "sha": "0dcb73bde8d1d4237f782f4790166365ac3209fe", "save_path": "github-repos/lean/calcu16-lean_complexity", "path": "github-repos/lean/calcu16-lean_complexity/lean_complexity-0dcb73bde8d1d4237f782f4790166365ac3209fe/src/lambda_calculus/utlc/beta_eta/church_rosser.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.45160652144990177}}
{"text": "lemma mul_left_comm (a b c : mynat) : a * (b * c) = b * (a * c) :=\nbegin\ninduction b with k Pk,\nrepeat { rw zero_mul },\nrw mul_zero,\nrefl,\nrepeat { rw succ_mul },\nrw mul_add,\nrw Pk,\nrefl,\n\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/3-multiplication-world/l9.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4515958278318581}}
{"text": "/- Provides simplification lemmas for monad laws. -/\nuniverse variables u\n\n@[simp]\nlemma pure_bind {m : Type u → Type u} [hm : monad m] {α β : Type u} (x : α) (f : α → m β) : pure x >>= f = f x :=\n  monad.pure_bind x f\n\nlemma bind_assoc {m : Type u → Type u} [hm : monad m] {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ) :\n  x >>= f >>= g = x >>= λ x, f x >>= g := monad.bind_assoc x f g\n\nlemma when_false_unit {m : Type → Type} [monad m] {c : Prop} [h : decidable c]\n  {t : m unit} (H : ¬ c) : when c t = pure ()\n:= begin\nunfold when, rw (if_neg H)\nend\n\nlemma when_false {m : Type → Type} [monad m] {c : Prop} [h : decidable c]\n  {t : m unit} {A : Type} {f : m A} (H : ¬ c) : when c t >>= (λ _, f) = f\n:= begin\nrw (when_false_unit H), rw pure_bind\nend\n\nlemma when_false_trans {m : Type → Type} [monad m] {c : Prop} [h : decidable c]\n  {t : m unit} {A : Type} {f g : m A} (H : ¬ c)\n  (H' : f = g) : when c t >>= (λ _, f) = g\n:= begin\nrw (when_false H), assumption\nend", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/category/monad/default.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195385342971, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45154801264950517}}
{"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Mario Carneiro, Reid Barton, Andrew Yang\n-/\nimport category_theory.limits.kan_extension\nimport category_theory.adjunction\nimport topology.category.Top.opens\n\n/-!\n# Presheaves on a topological space\n\nWe define `presheaf C X` simply as `(opens X)ᵒᵖ ⥤ C`,\nand inherit the category structure with natural transformations as morphisms.\n\nWe define\n* `pushforward_obj {X Y : Top.{w}} (f : X ⟶ Y) (ℱ : X.presheaf C) : Y.presheaf C`\nwith notation `f _* ℱ`\nand for `ℱ : X.presheaf C` provide the natural isomorphisms\n* `pushforward.id : (𝟙 X) _* ℱ ≅ ℱ`\n* `pushforward.comp : (f ≫ g) _* ℱ ≅ g _* (f _* ℱ)`\nalong with their `@[simp]` lemmas.\n\nWe also define the functors `pushforward` and `pullback` between the categories\n`X.presheaf C` and `Y.presheaf C`, and provide their adjunction at\n`pushforward_pullback_adjunction`.\n-/\n\nuniverses w v u\n\nopen category_theory\nopen topological_space\nopen opposite\n\nvariables (C : Type u) [category.{v} C]\n\nnamespace Top\n\n/-- The category of `C`-valued presheaves on a (bundled) topological space `X`. -/\n@[derive category, nolint has_inhabited_instance]\ndef presheaf (X : Top.{w}) := (opens X)ᵒᵖ ⥤ C\n\nvariables {C}\n\nnamespace presheaf\n\n/-- Pushforward a presheaf on `X` along a continuous map `f : X ⟶ Y`, obtaining a presheaf\non `Y`. -/\ndef pushforward_obj {X Y : Top.{w}} (f : X ⟶ Y) (ℱ : X.presheaf C) : Y.presheaf C :=\n(opens.map f).op ⋙ ℱ\n\ninfix ` _* `: 80 := pushforward_obj\n\n@[simp] lemma pushforward_obj_obj {X Y : Top.{w}} (f : X ⟶ Y) (ℱ : X.presheaf C) (U : (opens Y)ᵒᵖ) :\n  (f _* ℱ).obj U = ℱ.obj ((opens.map f).op.obj U) := rfl\n\n@[simp] lemma pushforward_obj_map {X Y : Top.{w}} (f : X ⟶ Y) (ℱ : X.presheaf C)\n  {U V : (opens Y)ᵒᵖ} (i : U ⟶ V) :\n  (f _* ℱ).map i = ℱ.map ((opens.map f).op.map i) := rfl\n\n/--\nAn equality of continuous maps induces a natural isomorphism between the pushforwards of a presheaf\nalong those maps.\n-/\ndef pushforward_eq {X Y : Top.{w}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.presheaf C) :\n  f _* ℱ ≅ g _* ℱ :=\niso_whisker_right (nat_iso.op (opens.map_iso f g h).symm) ℱ\n\nlemma pushforward_eq' {X Y : Top.{w}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.presheaf C) :\n  f _* ℱ = g _* ℱ :=\nby rw h\n\n@[simp] lemma pushforward_eq_hom_app\n  {X Y : Top.{w}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.presheaf C) (U) :\n  (pushforward_eq h ℱ).hom.app U =\n    ℱ.map (begin dsimp [functor.op], apply quiver.hom.op, apply eq_to_hom, rw h, end) :=\nby simp [pushforward_eq]\n\nlemma pushforward_eq'_hom_app\n  {X Y : Top.{w}} {f g : X ⟶ Y} (h : f = g) (ℱ : X.presheaf C) (U) :\n  nat_trans.app (eq_to_hom (pushforward_eq' h ℱ)) U = ℱ.map (eq_to_hom (by rw h)) :=\nby simpa [eq_to_hom_map]\n\n@[simp]\nlemma pushforward_eq_rfl {X Y : Top.{w}} (f : X ⟶ Y) (ℱ : X.presheaf C) (U) :\n  (pushforward_eq (rfl : f = f) ℱ).hom.app (op U) = 𝟙 _ :=\nbegin\n  dsimp [pushforward_eq],\n  simp,\nend\n\nlemma pushforward_eq_eq {X Y : Top.{w}} {f g : X ⟶ Y} (h₁ h₂ : f = g) (ℱ : X.presheaf C) :\n  ℱ.pushforward_eq h₁ = ℱ.pushforward_eq h₂ :=\nrfl\n\nnamespace pushforward\nvariables {X : Top.{w}} (ℱ : X.presheaf C)\n\n/-- The natural isomorphism between the pushforward of a presheaf along the identity continuous map\nand the original presheaf. -/\ndef id : (𝟙 X) _* ℱ ≅ ℱ :=\n(iso_whisker_right (nat_iso.op (opens.map_id X).symm) ℱ) ≪≫ functor.left_unitor _\n\nlemma id_eq : (𝟙 X) _* ℱ = ℱ :=\nby { unfold pushforward_obj, rw opens.map_id_eq, erw functor.id_comp }\n\n@[simp] lemma id_hom_app' (U) (p) :\n  (id ℱ).hom.app (op ⟨U, p⟩) = ℱ.map (𝟙 (op ⟨U, p⟩)) :=\nby { dsimp [id], simp, }\n\nlocal attribute [tidy] tactic.op_induction'\n\n@[simp, priority 990] lemma id_hom_app (U) :\n  (id ℱ).hom.app U = ℱ.map (eq_to_hom (opens.op_map_id_obj U)) := by tidy\n\n@[simp] lemma id_inv_app' (U) (p) : (id ℱ).inv.app (op ⟨U, p⟩) = ℱ.map (𝟙 (op ⟨U, p⟩)) :=\nby { dsimp [id], simp, }\n\n/-- The natural isomorphism between\nthe pushforward of a presheaf along the composition of two continuous maps and\nthe corresponding pushforward of a pushforward. -/\ndef comp {Y Z : Top.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g) _* ℱ ≅ g _* (f _* ℱ) :=\niso_whisker_right (nat_iso.op (opens.map_comp f g).symm) ℱ\n\nlemma comp_eq {Y Z : Top.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g) _* ℱ = g _* (f _* ℱ) :=\nrfl\n\n@[simp] lemma comp_hom_app {Y Z : Top.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :\n  (comp ℱ f g).hom.app U = 𝟙 _ :=\nby { dsimp [comp], tidy, }\n\n@[simp] lemma comp_inv_app {Y Z : Top.{w}} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :\n  (comp ℱ f g).inv.app U = 𝟙 _ :=\nby { dsimp [comp], tidy, }\n\nend pushforward\n\n/--\nA morphism of presheaves gives rise to a morphisms of the pushforwards of those presheaves.\n-/\n@[simps]\ndef pushforward_map {X Y : Top.{w}} (f : X ⟶ Y) {ℱ 𝒢 : X.presheaf C} (α : ℱ ⟶ 𝒢) :\n  f _* ℱ ⟶ f _* 𝒢 :=\n{ app := λ U, α.app _,\n  naturality' := λ U V i, by { erw α.naturality, refl, } }\n\nopen category_theory.limits\nsection pullback\nvariable [has_colimits C]\nnoncomputable theory\n\n/--\nPullback a presheaf on `Y` along a continuous map `f : X ⟶ Y`, obtaining a presheaf on `X`.\n\nThis is defined in terms of left Kan extensions, which is just a fancy way of saying\n\"take the colimits over the open sets whose preimage contains U\".\n-/\n@[simps]\ndef pullback_obj {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : Y.presheaf C) : X.presheaf C :=\n(Lan (opens.map f).op).obj ℱ\n\n/-- Pulling back along continuous maps is functorial. -/\ndef pullback_map {X Y : Top.{v}} (f : X ⟶ Y) {ℱ 𝒢 : Y.presheaf C} (α : ℱ ⟶ 𝒢) :\n  pullback_obj f ℱ ⟶ pullback_obj f 𝒢 :=\n(Lan (opens.map f).op).map α\n\n/-- If `f '' U` is open, then `f⁻¹ℱ U ≅ ℱ (f '' U)`.  -/\n@[simps]\ndef pullback_obj_obj_of_image_open {X Y : Top.{v}} (f : X ⟶ Y) (ℱ : Y.presheaf C) (U : opens X)\n  (H : is_open (f '' U)) : (pullback_obj f ℱ).obj (op U) ≅ ℱ.obj (op ⟨_, H⟩) :=\nbegin\n  let x : costructured_arrow (opens.map f).op (op U) :=\n  { left := op ⟨f '' U, H⟩,\n    hom := ((@hom_of_le _ _ _ ((opens.map f).obj ⟨_, H⟩) (set.image_preimage.le_u_l _)).op :\n    op ((opens.map f).obj (⟨⇑f '' ↑U, H⟩)) ⟶ op U) },\n  have hx : is_terminal x :=\n  { lift := λ s,\n    begin\n      fapply costructured_arrow.hom_mk,\n      change op (unop _) ⟶ op (⟨_, H⟩ : opens _),\n      refine (hom_of_le _).op,\n      exact (set.image_subset f s.X.hom.unop.le).trans (set.image_preimage.l_u_le ↑(unop s.X.left)),\n      simp\n    end },\n  exact is_colimit.cocone_point_unique_up_to_iso\n    (colimit.is_colimit _)\n    (colimit_of_diagram_terminal hx _),\nend\n\nnamespace pullback\nvariables {X Y : Top.{v}} (ℱ : Y.presheaf C)\n\n/-- The pullback along the identity is isomorphic to the original presheaf. -/\ndef id : pullback_obj (𝟙 _) ℱ ≅ ℱ :=\nnat_iso.of_components\n  (λ U, pullback_obj_obj_of_image_open (𝟙 _) ℱ (unop U) (by simpa using U.unop.2) ≪≫\n    ℱ.map_iso (eq_to_iso (by simp)))\n  (λ U V i,\n  begin\n      ext, simp,\n      erw colimit.pre_desc_assoc,\n      erw colimit.ι_desc_assoc,\n      erw colimit.ι_desc_assoc,\n      dsimp, simp only [←ℱ.map_comp], congr\n  end)\n\nlemma id_inv_app (U : opens Y) :\n  (id ℱ).inv.app (op U) = colimit.ι (Lan.diagram (opens.map (𝟙 Y)).op ℱ (op U))\n    (@costructured_arrow.mk _ _ _ _ _ (op U) _ (eq_to_hom (by simp))) :=\nbegin\n  dsimp[id], simp, dsimp[colimit_of_diagram_terminal],\n  delta Lan.diagram,\n  refine eq.trans _ (category.id_comp _),\n  rw ← ℱ.map_id,\n  congr,\n  any_goals { apply subsingleton.helim },\n  all_goals { simp }\nend\n\nend pullback\nend pullback\nvariable (C)\n\n/--\nThe pushforward functor.\n-/\ndef pushforward {X Y : Top.{v}} (f : X ⟶ Y) : X.presheaf C ⥤ Y.presheaf C :=\n{ obj := pushforward_obj f,\n  map := @pushforward_map _ _ X Y f }\n\n@[simp]\nlemma pushforward_map_app' {X Y : Top.{v}} (f : X ⟶ Y)\n  {ℱ 𝒢 : X.presheaf C} (α : ℱ ⟶ 𝒢) {U : (opens Y)ᵒᵖ} :\n  ((pushforward C f).map α).app U = α.app (op $ (opens.map f).obj U.unop) := rfl\n\nlemma id_pushforward {X : Top.{v}} : pushforward C (𝟙 X) = 𝟭 (X.presheaf C) :=\nbegin\n  apply category_theory.functor.ext,\n  { intros,\n    ext U,\n    have h := f.congr, erw h (opens.op_map_id_obj U),\n    simpa [eq_to_hom_map], },\n  { intros, apply pushforward.id_eq },\nend\n\nsection iso\n\n/-- A homeomorphism of spaces gives an equivalence of categories of presheaves. -/\n@[simps] def presheaf_equiv_of_iso {X Y : Top} (H : X ≅ Y) :\n  X.presheaf C ≌ Y.presheaf C :=\nequivalence.congr_left (opens.map_map_iso H).symm.op\n\nvariable {C}\n\n/--\nIf `H : X ≅ Y` is a homeomorphism,\nthen given an `H _* ℱ ⟶ 𝒢`, we may obtain an `ℱ ⟶ H ⁻¹ _* 𝒢`.\n-/\ndef to_pushforward_of_iso {X Y : Top} (H : X ≅ Y) {ℱ : X.presheaf C} {𝒢 : Y.presheaf C}\n  (α : H.hom _* ℱ ⟶ 𝒢) : ℱ ⟶ H.inv _* 𝒢 :=\n(presheaf_equiv_of_iso _ H).to_adjunction.hom_equiv ℱ 𝒢 α\n\n@[simp]\nlemma to_pushforward_of_iso_app {X Y : Top} (H₁ : X ≅ Y) {ℱ : X.presheaf C} {𝒢 : Y.presheaf C}\n  (H₂ : H₁.hom _* ℱ ⟶ 𝒢) (U : (opens X)ᵒᵖ) :\n(to_pushforward_of_iso H₁ H₂).app U =\n  ℱ.map (eq_to_hom (by simp [opens.map, set.preimage_preimage])) ≫\n  H₂.app (op ((opens.map H₁.inv).obj (unop U))) :=\nbegin\n  delta to_pushforward_of_iso,\n  simp only [equiv.to_fun_as_coe, nat_trans.comp_app, equivalence.equivalence_mk'_unit,\n    eq_to_hom_map, eq_to_hom_op, eq_to_hom_trans, presheaf_equiv_of_iso_unit_iso_hom_app_app,\n    equivalence.to_adjunction, equivalence.equivalence_mk'_counit,\n    presheaf_equiv_of_iso_inverse_map_app, adjunction.mk_of_unit_counit_hom_equiv_apply],\n  congr,\nend\n\n/--\nIf `H : X ≅ Y` is a homeomorphism,\nthen given an `H _* ℱ ⟶ 𝒢`, we may obtain an `ℱ ⟶ H ⁻¹ _* 𝒢`.\n-/\ndef pushforward_to_of_iso {X Y : Top} (H₁ : X ≅ Y) {ℱ : Y.presheaf C} {𝒢 : X.presheaf C}\n  (H₂ : ℱ ⟶ H₁.hom _* 𝒢) : H₁.inv _* ℱ ⟶ 𝒢 :=\n((presheaf_equiv_of_iso _ H₁.symm).to_adjunction.hom_equiv ℱ 𝒢).symm H₂\n\n@[simp]\nlemma pushforward_to_of_iso_app {X Y : Top} (H₁ : X ≅ Y) {ℱ : Y.presheaf C} {𝒢 : X.presheaf C}\n  (H₂ : ℱ ⟶ H₁.hom _* 𝒢) (U : (opens X)ᵒᵖ) :\n(pushforward_to_of_iso H₁ H₂).app U =\n  H₂.app (op ((opens.map H₁.inv).obj (unop U))) ≫\n  𝒢.map (eq_to_hom (by simp [opens.map, set.preimage_preimage])) :=\nby simpa [pushforward_to_of_iso, equivalence.to_adjunction]\n\nend iso\n\nvariables (C) [has_colimits C]\n\n/-- Pullback a presheaf on `Y` along a continuous map `f : X ⟶ Y`, obtaining a presheaf\non `X`. -/\n@[simps map_app]\ndef pullback {X Y : Top.{v}} (f : X ⟶ Y) : Y.presheaf C ⥤ X.presheaf C := Lan (opens.map f).op\n\n@[simp] lemma pullback_obj_eq_pullback_obj {C} [category C] [has_colimits C] {X Y : Top.{w}}\n  (f : X ⟶ Y) (ℱ : Y.presheaf C) : (pullback C f).obj ℱ = pullback_obj f ℱ := rfl\n\n/-- The pullback and pushforward along a continuous map are adjoint to each other. -/\n@[simps unit_app_app counit_app_app]\ndef pushforward_pullback_adjunction {X Y : Top.{v}} (f : X ⟶ Y) :\n  pullback C f ⊣ pushforward C f := Lan.adjunction _ _\n\n/-- Pulling back along a homeomorphism is the same as pushing forward along its inverse. -/\ndef pullback_hom_iso_pushforward_inv {X Y : Top.{v}} (H : X ≅ Y) :\n  pullback C H.hom ≅ pushforward C H.inv :=\nadjunction.left_adjoint_uniq\n  (pushforward_pullback_adjunction C H.hom)\n  (presheaf_equiv_of_iso C H.symm).to_adjunction\n\n/-- Pulling back along the inverse of a homeomorphism is the same as pushing forward along it. -/\ndef pullback_inv_iso_pushforward_hom {X Y : Top.{v}} (H : X ≅ Y) :\n  pullback C H.inv ≅ pushforward C H.hom :=\nadjunction.left_adjoint_uniq\n  (pushforward_pullback_adjunction C H.inv)\n  (presheaf_equiv_of_iso C H).to_adjunction\n\nend presheaf\nend Top\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/topology/sheaves/presheaf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195269001831, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.45154800549350294}}
{"text": "/-\nCopyright (c) 2015 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Jeremy Avigad, Minchao Wu, Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.multiset.finset_ops\nimport Mathlib.tactic.monotonicity.default\nimport Mathlib.tactic.apply\nimport Mathlib.tactic.nth_rewrite.default\nimport Mathlib.PostPort\n\nuniverses u_4 l u_1 u u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Finite sets\n\nmathlib has several different models for finite sets,\nand it can be confusing when you're first getting used to them!\n\nThis file builds the basic theory of `finset α`,\nmodelled as a `multiset α` without duplicates.\n\nIt's \"constructive\" in the since that there is an underlying list of elements,\nalthough this is wrapped in a quotient by permutations,\nso anytime you actually use this list you're obligated to show you didn't depend on the ordering.\n\nThere's also the typeclass `fintype α`\n(which asserts that there is some `finset α` containing every term of type `α`)\nas well as the predicate `finite` on `s : set α` (which asserts `nonempty (fintype s)`).\n-/\n\n/-- `finset α` is the type of finite sets of elements of `α`. It is implemented\n  as a multiset (a list up to permutation) which has no duplicate elements. -/\nstructure finset (α : Type u_4) where\n  val : multiset α\n  nodup : multiset.nodup val\n\nnamespace finset\n\n\ntheorem eq_of_veq {α : Type u_1} {s : finset α} {t : finset α} : val s = val t → s = t := sorry\n\n@[simp] theorem val_inj {α : Type u_1} {s : finset α} {t : finset α} : val s = val t ↔ s = t :=\n  { mp := eq_of_veq, mpr := congr_arg fun {s : finset α} => val s }\n\n@[simp] theorem erase_dup_eq_self {α : Type u_1} [DecidableEq α] (s : finset α) :\n    multiset.erase_dup (val s) = val s :=\n  iff.mpr multiset.erase_dup_eq_self (nodup s)\n\nprotected instance has_decidable_eq {α : Type u_1} [DecidableEq α] : DecidableEq (finset α) := sorry\n\n/-! ### membership -/\n\nprotected instance has_mem {α : Type u_1} : has_mem α (finset α) :=\n  has_mem.mk fun (a : α) (s : finset α) => a ∈ val s\n\ntheorem mem_def {α : Type u_1} {a : α} {s : finset α} : a ∈ s ↔ a ∈ val s := iff.rfl\n\n@[simp] theorem mem_mk {α : Type u_1} {a : α} {s : multiset α} {nd : multiset.nodup s} :\n    a ∈ mk s nd ↔ a ∈ s :=\n  iff.rfl\n\nprotected instance decidable_mem {α : Type u_1} [h : DecidableEq α] (a : α) (s : finset α) :\n    Decidable (a ∈ s) :=\n  multiset.decidable_mem a (val s)\n\n/-! ### set coercion -/\n\n/-- Convert a finset to a set in the natural way. -/\nprotected instance set.has_coe_t {α : Type u_1} : has_coe_t (finset α) (set α) :=\n  has_coe_t.mk fun (s : finset α) => set_of fun (x : α) => x ∈ s\n\n@[simp] theorem mem_coe {α : Type u_1} {a : α} {s : finset α} : a ∈ ↑s ↔ a ∈ s := iff.rfl\n\n@[simp] theorem set_of_mem {α : Type u_1} {s : finset α} : (set_of fun (a : α) => a ∈ s) = ↑s := rfl\n\n@[simp] theorem coe_mem {α : Type u_1} {s : finset α} (x : ↥↑s) : ↑x ∈ s := subtype.property x\n\n@[simp] theorem mk_coe {α : Type u_1} {s : finset α} (x : ↥↑s) {h : ↑x ∈ ↑s} :\n    { val := ↑x, property := h } = x :=\n  subtype.coe_eta x h\n\nprotected instance decidable_mem' {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    Decidable (a ∈ ↑s) :=\n  finset.decidable_mem a s\n\n/-! ### extensionality -/\n\ntheorem ext_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} :\n    s₁ = s₂ ↔ ∀ (a : α), a ∈ s₁ ↔ a ∈ s₂ :=\n  iff.trans (iff.symm val_inj) (multiset.nodup_ext (nodup s₁) (nodup s₂))\n\ntheorem ext {α : Type u_1} {s₁ : finset α} {s₂ : finset α} :\n    (∀ (a : α), a ∈ s₁ ↔ a ∈ s₂) → s₁ = s₂ :=\n  iff.mpr ext_iff\n\n@[simp] theorem coe_inj {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : ↑s₁ = ↑s₂ ↔ s₁ = s₂ :=\n  iff.trans set.ext_iff (iff.symm ext_iff)\n\ntheorem coe_injective {α : Type u_1} : function.injective coe :=\n  fun (s t : finset α) => iff.mp coe_inj\n\n/-! ### subset -/\n\nprotected instance has_subset {α : Type u_1} : has_subset (finset α) :=\n  has_subset.mk fun (s₁ s₂ : finset α) => ∀ {a : α}, a ∈ s₁ → a ∈ s₂\n\ntheorem subset_def {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ ⊆ s₂ ↔ val s₁ ⊆ val s₂ :=\n  iff.rfl\n\n@[simp] theorem subset.refl {α : Type u_1} (s : finset α) : s ⊆ s := multiset.subset.refl (val s)\n\ntheorem subset_of_eq {α : Type u_1} {s : finset α} {t : finset α} (h : s = t) : s ⊆ t :=\n  h ▸ subset.refl s\n\ntheorem subset.trans {α : Type u_1} {s₁ : finset α} {s₂ : finset α} {s₃ : finset α} :\n    s₁ ⊆ s₂ → s₂ ⊆ s₃ → s₁ ⊆ s₃ :=\n  multiset.subset.trans\n\ntheorem superset.trans {α : Type u_1} {s₁ : finset α} {s₂ : finset α} {s₃ : finset α} :\n    s₁ ⊇ s₂ → s₂ ⊇ s₃ → s₁ ⊇ s₃ :=\n  fun (h' : s₁ ⊇ s₂) (h : s₂ ⊇ s₃) => subset.trans h h'\n\n-- TODO: these should be global attributes, but this will require fixing other files\n\ntheorem mem_of_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} {a : α} :\n    s₁ ⊆ s₂ → a ∈ s₁ → a ∈ s₂ :=\n  multiset.mem_of_subset\n\ntheorem subset.antisymm {α : Type u_1} {s₁ : finset α} {s₂ : finset α} (H₁ : s₁ ⊆ s₂)\n    (H₂ : s₂ ⊆ s₁) : s₁ = s₂ :=\n  ext fun (a : α) => { mp := H₁, mpr := H₂ }\n\ntheorem subset_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} :\n    s₁ ⊆ s₂ ↔ ∀ {x : α}, x ∈ s₁ → x ∈ s₂ :=\n  iff.rfl\n\n@[simp] theorem coe_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : ↑s₁ ⊆ ↑s₂ ↔ s₁ ⊆ s₂ :=\n  iff.rfl\n\n@[simp] theorem val_le_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} :\n    val s₁ ≤ val s₂ ↔ s₁ ⊆ s₂ :=\n  multiset.le_iff_subset (nodup s₁)\n\nprotected instance has_ssubset {α : Type u_1} : has_ssubset (finset α) :=\n  has_ssubset.mk fun (a b : finset α) => a ⊆ b ∧ ¬b ⊆ a\n\nprotected instance partial_order {α : Type u_1} : partial_order (finset α) :=\n  partial_order.mk has_subset.subset has_ssubset.ssubset subset.refl subset.trans subset.antisymm\n\ntheorem subset.antisymm_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} :\n    s₁ = s₂ ↔ s₁ ⊆ s₂ ∧ s₂ ⊆ s₁ :=\n  le_antisymm_iff\n\n@[simp] theorem le_iff_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ ≤ s₂ ↔ s₁ ⊆ s₂ :=\n  iff.rfl\n\n@[simp] theorem lt_iff_ssubset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : s₁ < s₂ ↔ s₁ ⊂ s₂ :=\n  iff.rfl\n\n@[simp] theorem coe_ssubset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} : ↑s₁ ⊂ ↑s₂ ↔ s₁ ⊂ s₂ :=\n  sorry\n\n@[simp] theorem val_lt_iff {α : Type u_1} {s₁ : finset α} {s₂ : finset α} :\n    val s₁ < val s₂ ↔ s₁ ⊂ s₂ :=\n  and_congr val_le_iff (not_congr val_le_iff)\n\ntheorem ssubset_iff_of_subset {α : Type u_1} {s₁ : finset α} {s₂ : finset α} (h : s₁ ⊆ s₂) :\n    s₁ ⊂ s₂ ↔ ∃ (x : α), ∃ (H : x ∈ s₂), ¬x ∈ s₁ :=\n  set.ssubset_iff_of_subset h\n\n/-! ### Nonempty -/\n\n/-- The property `s.nonempty` expresses the fact that the finset `s` is not empty. It should be used\nin theorem assumptions instead of `∃ x, x ∈ s` or `s ≠ ∅` as it gives access to a nice API thanks\nto the dot notation. -/\nprotected def nonempty {α : Type u_1} (s : finset α) := ∃ (x : α), x ∈ s\n\n@[simp] theorem coe_nonempty {α : Type u_1} {s : finset α} : set.nonempty ↑s ↔ finset.nonempty s :=\n  iff.rfl\n\ntheorem nonempty.bex {α : Type u_1} {s : finset α} (h : finset.nonempty s) : ∃ (x : α), x ∈ s := h\n\ntheorem nonempty.mono {α : Type u_1} {s : finset α} {t : finset α} (hst : s ⊆ t)\n    (hs : finset.nonempty s) : finset.nonempty t :=\n  set.nonempty.mono hst hs\n\ntheorem nonempty.forall_const {α : Type u_1} {s : finset α} (h : finset.nonempty s) {p : Prop} :\n    (∀ (x : α), x ∈ s → p) ↔ p :=\n  sorry\n\n/-! ### empty -/\n\n/-- The empty finset -/\nprotected def empty {α : Type u_1} : finset α := mk 0 multiset.nodup_zero\n\nprotected instance has_emptyc {α : Type u_1} : has_emptyc (finset α) := has_emptyc.mk finset.empty\n\nprotected instance inhabited {α : Type u_1} : Inhabited (finset α) := { default := ∅ }\n\n@[simp] theorem empty_val {α : Type u_1} : val ∅ = 0 := rfl\n\n@[simp] theorem not_mem_empty {α : Type u_1} (a : α) : ¬a ∈ ∅ := id\n\n@[simp] theorem not_nonempty_empty {α : Type u_1} : ¬finset.nonempty ∅ :=\n  fun (_x : finset.nonempty ∅) =>\n    (fun (_a : finset.nonempty ∅) =>\n        Exists.dcases_on _a fun (w : α) (h : w ∈ ∅) => idRhs False (not_mem_empty w h))\n      _x\n\n@[simp] theorem mk_zero {α : Type u_1} : mk 0 multiset.nodup_zero = ∅ := rfl\n\ntheorem ne_empty_of_mem {α : Type u_1} {a : α} {s : finset α} (h : a ∈ s) : s ≠ ∅ :=\n  fun (e : s = ∅) => not_mem_empty a (e ▸ h)\n\ntheorem nonempty.ne_empty {α : Type u_1} {s : finset α} (h : finset.nonempty s) : s ≠ ∅ :=\n  exists.elim h fun (a : α) => ne_empty_of_mem\n\n@[simp] theorem empty_subset {α : Type u_1} (s : finset α) : ∅ ⊆ s := multiset.zero_subset (val s)\n\ntheorem eq_empty_of_forall_not_mem {α : Type u_1} {s : finset α} (H : ∀ (x : α), ¬x ∈ s) : s = ∅ :=\n  eq_of_veq (multiset.eq_zero_of_forall_not_mem H)\n\ntheorem eq_empty_iff_forall_not_mem {α : Type u_1} {s : finset α} : s = ∅ ↔ ∀ (x : α), ¬x ∈ s :=\n  { mp := fun (ᾰ : s = ∅) (x : α) => Eq._oldrec id (Eq.symm ᾰ),\n    mpr := fun (h : ∀ (x : α), ¬x ∈ s) => eq_empty_of_forall_not_mem h }\n\n@[simp] theorem val_eq_zero {α : Type u_1} {s : finset α} : val s = 0 ↔ s = ∅ := val_inj\n\ntheorem subset_empty {α : Type u_1} {s : finset α} : s ⊆ ∅ ↔ s = ∅ :=\n  iff.trans multiset.subset_zero val_eq_zero\n\ntheorem nonempty_of_ne_empty {α : Type u_1} {s : finset α} (h : s ≠ ∅) : finset.nonempty s :=\n  multiset.exists_mem_of_ne_zero (mt (iff.mp val_eq_zero) h)\n\ntheorem nonempty_iff_ne_empty {α : Type u_1} {s : finset α} : finset.nonempty s ↔ s ≠ ∅ :=\n  { mp := nonempty.ne_empty, mpr := nonempty_of_ne_empty }\n\n@[simp] theorem not_nonempty_iff_eq_empty {α : Type u_1} {s : finset α} :\n    ¬finset.nonempty s ↔ s = ∅ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (¬finset.nonempty s ↔ s = ∅)) (propext nonempty_iff_ne_empty)))\n    not_not\n\ntheorem eq_empty_or_nonempty {α : Type u_1} (s : finset α) : s = ∅ ∨ finset.nonempty s :=\n  classical.by_cases Or.inl fun (h : ¬s = ∅) => Or.inr (nonempty_of_ne_empty h)\n\n@[simp] theorem coe_empty {α : Type u_1} : ↑∅ = ∅ := rfl\n\n/-- A `finset` for an empty type is empty. -/\ntheorem eq_empty_of_not_nonempty {α : Type u_1} (h : ¬Nonempty α) (s : finset α) : s = ∅ :=\n  eq_empty_of_forall_not_mem fun (x : α) => false.elim (iff.mp not_nonempty_iff_imp_false h x)\n\n/-! ### singleton -/\n\n/--\n`{a} : finset a` is the set `{a}` containing `a` and nothing else.\n\nThis differs from `insert a ∅` in that it does not require a `decidable_eq` instance for `α`.\n-/\nprotected instance has_singleton {α : Type u_1} : has_singleton α (finset α) :=\n  has_singleton.mk fun (a : α) => mk (singleton a) (multiset.nodup_singleton a)\n\n@[simp] theorem singleton_val {α : Type u_1} (a : α) : val (singleton a) = a ::ₘ 0 := rfl\n\n@[simp] theorem mem_singleton {α : Type u_1} {a : α} {b : α} : b ∈ singleton a ↔ b = a :=\n  multiset.mem_singleton\n\ntheorem not_mem_singleton {α : Type u_1} {a : α} {b : α} : ¬a ∈ singleton b ↔ a ≠ b :=\n  not_congr mem_singleton\n\ntheorem mem_singleton_self {α : Type u_1} (a : α) : a ∈ singleton a := Or.inl rfl\n\ntheorem singleton_inj {α : Type u_1} {a : α} {b : α} : singleton a = singleton b ↔ a = b :=\n  { mp := fun (h : singleton a = singleton b) => iff.mp mem_singleton (h ▸ mem_singleton_self a),\n    mpr := congr_arg fun {a : α} => singleton a }\n\n@[simp] theorem singleton_nonempty {α : Type u_1} (a : α) : finset.nonempty (singleton a) :=\n  Exists.intro a (mem_singleton_self a)\n\n@[simp] theorem singleton_ne_empty {α : Type u_1} (a : α) : singleton a ≠ ∅ :=\n  nonempty.ne_empty (singleton_nonempty a)\n\n@[simp] theorem coe_singleton {α : Type u_1} (a : α) : ↑(singleton a) = singleton a := sorry\n\ntheorem eq_singleton_iff_unique_mem {α : Type u_1} {s : finset α} {a : α} :\n    s = singleton a ↔ a ∈ s ∧ ∀ (x : α), x ∈ s → x = a :=\n  sorry\n\ntheorem eq_singleton_iff_nonempty_unique_mem {α : Type u_1} {s : finset α} {a : α} :\n    s = singleton a ↔ finset.nonempty s ∧ ∀ (x : α), x ∈ s → x = a :=\n  sorry\n\ntheorem singleton_iff_unique_mem {α : Type u_1} (s : finset α) :\n    (∃ (a : α), s = singleton a) ↔ exists_unique fun (a : α) => a ∈ s :=\n  sorry\n\ntheorem singleton_subset_set_iff {α : Type u_1} {s : set α} {a : α} : ↑(singleton a) ⊆ s ↔ a ∈ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (↑(singleton a) ⊆ s ↔ a ∈ s)) (coe_singleton a)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a ⊆ s ↔ a ∈ s)) (propext set.singleton_subset_iff)))\n      (iff.refl (a ∈ s)))\n\n@[simp] theorem singleton_subset_iff {α : Type u_1} {s : finset α} {a : α} :\n    singleton a ⊆ s ↔ a ∈ s :=\n  singleton_subset_set_iff\n\n/-! ### cons -/\n\n/-- `cons a s h` is the set `{a} ∪ s` containing `a` and the elements of `s`. It is the same as\n`insert a s` when it is defined, but unlike `insert a s` it does not require `decidable_eq α`,\nand the union is guaranteed to be disjoint.  -/\ndef cons {α : Type u_1} (a : α) (s : finset α) (h : ¬a ∈ s) : finset α := mk (a ::ₘ val s) sorry\n\n@[simp] theorem mem_cons {α : Type u_1} {a : α} {s : finset α} {h : ¬a ∈ s} {b : α} :\n    b ∈ cons a s h ↔ b = a ∨ b ∈ s :=\n  sorry\n\n@[simp] theorem cons_val {α : Type u_1} {a : α} {s : finset α} (h : ¬a ∈ s) :\n    val (cons a s h) = a ::ₘ val s :=\n  rfl\n\n@[simp] theorem mk_cons {α : Type u_1} {a : α} {s : multiset α} (h : multiset.nodup (a ::ₘ s)) :\n    mk (a ::ₘ s) h =\n        cons a (mk s (and.right (iff.mp multiset.nodup_cons h)))\n          (and.left (iff.mp multiset.nodup_cons h)) :=\n  rfl\n\n@[simp] theorem nonempty_cons {α : Type u_1} {a : α} {s : finset α} (h : ¬a ∈ s) :\n    finset.nonempty (cons a s h) :=\n  Exists.intro a (iff.mpr mem_cons (Or.inl rfl))\n\n@[simp] theorem nonempty_mk_coe {α : Type u_1} {l : List α} {hl : multiset.nodup ↑l} :\n    finset.nonempty (mk (↑l) hl) ↔ l ≠ [] :=\n  sorry\n\n/-! ### disjoint union -/\n\n/-- `disj_union s t h` is the set such that `a ∈ disj_union s t h` iff `a ∈ s` or `a ∈ t`.\nIt is the same as `s ∪ t`, but it does not require decidable equality on the type. The hypothesis\nensures that the sets are disjoint. -/\ndef disj_union {α : Type u_1} (s : finset α) (t : finset α) (h : ∀ (a : α), a ∈ s → ¬a ∈ t) :\n    finset α :=\n  mk (val s + val t) sorry\n\n@[simp] theorem mem_disj_union {α : Type u_1} {s : finset α} {t : finset α}\n    {h : ∀ (a : α), a ∈ s → ¬a ∈ t} {a : α} : a ∈ disj_union s t h ↔ a ∈ s ∨ a ∈ t :=\n  sorry\n\n/-! ### insert -/\n\n/-- `insert a s` is the set `{a} ∪ s` containing `a` and the elements of `s`. -/\nprotected instance has_insert {α : Type u_1} [DecidableEq α] : has_insert α (finset α) :=\n  has_insert.mk fun (a : α) (s : finset α) => mk (multiset.ndinsert a (val s)) sorry\n\ntheorem insert_def {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    insert a s = mk (multiset.ndinsert a (val s)) (multiset.nodup_ndinsert a (nodup s)) :=\n  rfl\n\n@[simp] theorem insert_val {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    val (insert a s) = multiset.ndinsert a (val s) :=\n  rfl\n\ntheorem insert_val' {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    val (insert a s) = multiset.erase_dup (a ::ₘ val s) :=\n  sorry\n\ntheorem insert_val_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) :\n    val (insert a s) = a ::ₘ val s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (val (insert a s) = a ::ₘ val s)) (insert_val a s)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (multiset.ndinsert a (val s) = a ::ₘ val s))\n          (multiset.ndinsert_of_not_mem h)))\n      (Eq.refl (a ::ₘ val s)))\n\n@[simp] theorem mem_insert {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} :\n    a ∈ insert b s ↔ a = b ∨ a ∈ s :=\n  multiset.mem_ndinsert\n\ntheorem mem_insert_self {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : a ∈ insert a s :=\n  multiset.mem_ndinsert_self a (val s)\n\ntheorem mem_insert_of_mem {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α}\n    (h : a ∈ s) : a ∈ insert b s :=\n  multiset.mem_ndinsert_of_mem h\n\ntheorem mem_of_mem_insert_of_ne {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α}\n    (h : b ∈ insert a s) : b ≠ a → b ∈ s :=\n  or.resolve_left (iff.mp mem_insert h)\n\n@[simp] theorem cons_eq_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (h : ¬a ∈ s) :\n    cons a s h = insert a s :=\n  sorry\n\n@[simp] theorem coe_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    ↑(insert a s) = insert a ↑s :=\n  sorry\n\ntheorem mem_insert_coe {α : Type u_1} [DecidableEq α] {s : finset α} {x : α} {y : α} :\n    x ∈ insert y s ↔ x ∈ insert y ↑s :=\n  sorry\n\nprotected instance is_lawful_singleton {α : Type u_1} [DecidableEq α] :\n    is_lawful_singleton α (finset α) :=\n  is_lawful_singleton.mk\n    fun (a : α) =>\n      ext\n        fun (a_1 : α) =>\n          eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_2 : Prop) (e_1 : a = a_2) (b b_1 : Prop) (e_2 : b = b_1) =>\n                    congr (congr_arg Iff e_1) e_2)\n                  (a_1 ∈ insert a ∅) (a_1 = a)\n                  (Eq.trans\n                    (Eq.trans (propext mem_insert)\n                      ((fun (a a_2 : Prop) (e_1 : a = a_2) (b b_1 : Prop) (e_2 : b = b_1) =>\n                          congr (congr_arg Or e_1) e_2)\n                        (a_1 = a) (a_1 = a) (Eq.refl (a_1 = a)) (a_1 ∈ ∅) False\n                        (propext\n                          ((fun {α : Type u_1} (a : α) => iff_false_intro (not_mem_empty a)) a_1))))\n                    (propext (or_false (a_1 = a))))\n                  (a_1 ∈ singleton a) (a_1 = a) (propext mem_singleton))\n                (propext (iff_self (a_1 = a)))))\n            trivial\n\n@[simp] theorem insert_eq_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) :\n    insert a s = s :=\n  eq_of_veq (multiset.ndinsert_of_mem h)\n\n@[simp] theorem insert_singleton_self_eq {α : Type u_1} [DecidableEq α] (a : α) :\n    insert a (singleton a) = singleton a :=\n  insert_eq_of_mem (mem_singleton_self a)\n\ntheorem insert.comm {α : Type u_1} [DecidableEq α] (a : α) (b : α) (s : finset α) :\n    insert a (insert b s) = insert b (insert a s) :=\n  sorry\n\ntheorem insert_singleton_comm {α : Type u_1} [DecidableEq α] (a : α) (b : α) :\n    insert a (singleton b) = insert b (singleton a) :=\n  sorry\n\n@[simp] theorem insert_idem {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    insert a (insert a s) = insert a s :=\n  sorry\n\n@[simp] theorem insert_nonempty {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    finset.nonempty (insert a s) :=\n  Exists.intro a (mem_insert_self a s)\n\n@[simp] theorem insert_ne_empty {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    insert a s ≠ ∅ :=\n  nonempty.ne_empty (insert_nonempty a s)\n\n/-!\nThe universe annotation is required for the following instance, possibly this is a bug in Lean. See\nleanprover.zulipchat.com/#narrow/stream/113488-general/topic/strange.20error.20(universe.20issue.3F)\n-/\n\nprotected instance has_insert.insert.nonempty {α : Type u} [DecidableEq α] (i : α) (s : finset α) :\n    Nonempty ↥↑(insert i s) :=\n  set.nonempty.to_subtype (iff.mpr coe_nonempty (insert_nonempty i s))\n\ntheorem ne_insert_of_not_mem {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) {a : α}\n    (h : ¬a ∈ s) : s ≠ insert a t :=\n  sorry\n\ntheorem insert_subset {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} {t : finset α} :\n    insert a s ⊆ t ↔ a ∈ t ∧ s ⊆ t :=\n  sorry\n\ntheorem subset_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : s ⊆ insert a s :=\n  fun (b : α) => mem_insert_of_mem\n\ntheorem insert_subset_insert {α : Type u_1} [DecidableEq α] (a : α) {s : finset α} {t : finset α}\n    (h : s ⊆ t) : insert a s ⊆ insert a t :=\n  iff.mpr insert_subset { left := mem_insert_self a t, right := subset.trans h (subset_insert a t) }\n\ntheorem ssubset_iff {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    s ⊂ t ↔ ∃ (a : α), ∃ (H : ¬a ∈ s), insert a s ⊆ t :=\n  sorry\n\ntheorem ssubset_insert {α : Type u_1} [DecidableEq α] {s : finset α} {a : α} (h : ¬a ∈ s) :\n    s ⊂ insert a s :=\n  iff.mpr ssubset_iff (Exists.intro a (Exists.intro h (subset.refl (insert a s))))\n\nprotected theorem induction {α : Type u_1} {p : finset α → Prop} [DecidableEq α] (h₁ : p ∅)\n    (h₂ : ∀ {a : α} {s : finset α}, ¬a ∈ s → p s → p (insert a s)) (s : finset α) : p s :=\n  sorry\n\n/--\nTo prove a proposition about an arbitrary `finset α`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset α`,\nthen it holds for the `finset` obtained by inserting a new element.\n-/\nprotected theorem induction_on {α : Type u_1} {p : finset α → Prop} [DecidableEq α] (s : finset α)\n    (h₁ : p ∅) (h₂ : ∀ {a : α} {s : finset α}, ¬a ∈ s → p s → p (insert a s)) : p s :=\n  finset.induction h₁ h₂ s\n\n/--\nTo prove a proposition about `S : finset α`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset α ⊆ S`,\nthen it holds for the `finset` obtained by inserting a new element of `S`.\n-/\ntheorem induction_on' {α : Type u_1} {p : finset α → Prop} [DecidableEq α] (S : finset α) (h₁ : p ∅)\n    (h₂ : ∀ {a : α} {s : finset α}, a ∈ S → s ⊆ S → ¬a ∈ s → p s → p (insert a s)) : p S :=\n  sorry\n\n/-- Inserting an element to a finite set is equivalent to the option type. -/\ndef subtype_insert_equiv_option {α : Type u_1} [DecidableEq α] {t : finset α} {x : α} (h : ¬x ∈ t) :\n    (Subtype fun (i : α) => i ∈ insert x t) ≃ Option (Subtype fun (i : α) => i ∈ t) :=\n  equiv.mk\n    (fun (y : Subtype fun (i : α) => i ∈ insert x t) =>\n      dite (↑y = x) (fun (h : ↑y = x) => none)\n        fun (h : ¬↑y = x) => some { val := ↑y, property := sorry })\n    (fun (y : Option (Subtype fun (i : α) => i ∈ t)) =>\n      option.elim y { val := x, property := sorry }\n        fun (z : Subtype fun (i : α) => i ∈ t) => { val := ↑z, property := sorry })\n    sorry sorry\n\n/-! ### union -/\n\n/-- `s ∪ t` is the set such that `a ∈ s ∪ t` iff `a ∈ s` or `a ∈ t`. -/\nprotected instance has_union {α : Type u_1} [DecidableEq α] : has_union (finset α) :=\n  has_union.mk fun (s₁ s₂ : finset α) => mk (multiset.ndunion (val s₁) (val s₂)) sorry\n\ntheorem union_val_nd {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    val (s₁ ∪ s₂) = multiset.ndunion (val s₁) (val s₂) :=\n  rfl\n\n@[simp] theorem union_val {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    val (s₁ ∪ s₂) = val s₁ ∪ val s₂ :=\n  multiset.ndunion_eq_union (nodup s₁)\n\n@[simp] theorem mem_union {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} :\n    a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂ :=\n  multiset.mem_ndunion\n\n@[simp] theorem disj_union_eq_union {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α)\n    (h : ∀ (a : α), a ∈ s → ¬a ∈ t) : disj_union s t h = s ∪ t :=\n  sorry\n\ntheorem mem_union_left {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} (s₂ : finset α)\n    (h : a ∈ s₁) : a ∈ s₁ ∪ s₂ :=\n  iff.mpr mem_union (Or.inl h)\n\ntheorem mem_union_right {α : Type u_1} [DecidableEq α] {a : α} {s₂ : finset α} (s₁ : finset α)\n    (h : a ∈ s₂) : a ∈ s₁ ∪ s₂ :=\n  iff.mpr mem_union (Or.inr h)\n\ntheorem forall_mem_union {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α}\n    {p : α → Prop} :\n    (∀ (ab : α), ab ∈ s₁ ∪ s₂ → p ab) ↔ (∀ (a : α), a ∈ s₁ → p a) ∧ ∀ (b : α), b ∈ s₂ → p b :=\n  sorry\n\ntheorem not_mem_union {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} :\n    ¬a ∈ s₁ ∪ s₂ ↔ ¬a ∈ s₁ ∧ ¬a ∈ s₂ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (¬a ∈ s₁ ∪ s₂ ↔ ¬a ∈ s₁ ∧ ¬a ∈ s₂)) (propext mem_union)))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (¬(a ∈ s₁ ∨ a ∈ s₂) ↔ ¬a ∈ s₁ ∧ ¬a ∈ s₂)) (propext not_or_distrib)))\n      (iff.refl (¬a ∈ s₁ ∧ ¬a ∈ s₂)))\n\n@[simp] theorem coe_union {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    ↑(s₁ ∪ s₂) = ↑s₁ ∪ ↑s₂ :=\n  set.ext fun (x : α) => mem_union\n\ntheorem union_subset {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} {s₃ : finset α}\n    (h₁ : s₁ ⊆ s₃) (h₂ : s₂ ⊆ s₃) : s₁ ∪ s₂ ⊆ s₃ :=\n  iff.mp val_le_iff (iff.mpr multiset.ndunion_le { left := h₁, right := iff.mpr val_le_iff h₂ })\n\ntheorem subset_union_left {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ ⊆ s₁ ∪ s₂ :=\n  fun (x : α) => mem_union_left s₂\n\ntheorem subset_union_right {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₂ ⊆ s₁ ∪ s₂ :=\n  fun (x : α) => mem_union_right s₁\n\ntheorem union_subset_union {α : Type u_1} [DecidableEq α] {s1 : finset α} {t1 : finset α}\n    {s2 : finset α} {t2 : finset α} (h1 : s1 ⊆ t1) (h2 : s2 ⊆ t2) : s1 ∪ s2 ⊆ t1 ∪ t2 :=\n  sorry\n\ntheorem union_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ ∪ s₂ = s₂ ∪ s₁ :=\n  sorry\n\nprotected instance has_union.union.is_commutative {α : Type u_1} [DecidableEq α] :\n    is_commutative (finset α) has_union.union :=\n  is_commutative.mk union_comm\n\n@[simp] theorem union_assoc {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (s₃ : finset α) : s₁ ∪ s₂ ∪ s₃ = s₁ ∪ (s₂ ∪ s₃) :=\n  sorry\n\nprotected instance has_union.union.is_associative {α : Type u_1} [DecidableEq α] :\n    is_associative (finset α) has_union.union :=\n  is_associative.mk union_assoc\n\n@[simp] theorem union_idempotent {α : Type u_1} [DecidableEq α] (s : finset α) : s ∪ s = s :=\n  ext fun (_x : α) => iff.trans mem_union (or_self (_x ∈ s))\n\nprotected instance has_union.union.is_idempotent {α : Type u_1} [DecidableEq α] :\n    is_idempotent (finset α) has_union.union :=\n  is_idempotent.mk union_idempotent\n\ntheorem union_left_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (s₃ : finset α) : s₁ ∪ (s₂ ∪ s₃) = s₂ ∪ (s₁ ∪ s₃) :=\n  sorry\n\ntheorem union_right_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (s₃ : finset α) : s₁ ∪ s₂ ∪ s₃ = s₁ ∪ s₃ ∪ s₂ :=\n  sorry\n\ntheorem union_self {α : Type u_1} [DecidableEq α] (s : finset α) : s ∪ s = s := union_idempotent s\n\n@[simp] theorem union_empty {α : Type u_1} [DecidableEq α] (s : finset α) : s ∪ ∅ = s :=\n  ext fun (x : α) => iff.trans mem_union (or_false (x ∈ s))\n\n@[simp] theorem empty_union {α : Type u_1} [DecidableEq α] (s : finset α) : ∅ ∪ s = s :=\n  ext fun (x : α) => iff.trans mem_union (false_or (x ∈ s))\n\ntheorem insert_eq {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    insert a s = singleton a ∪ s :=\n  rfl\n\n@[simp] theorem insert_union {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (t : finset α) :\n    insert a s ∪ t = insert a (s ∪ t) :=\n  sorry\n\n@[simp] theorem union_insert {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (t : finset α) :\n    s ∪ insert a t = insert a (s ∪ t) :=\n  sorry\n\ntheorem insert_union_distrib {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) (t : finset α) :\n    insert a (s ∪ t) = insert a s ∪ insert a t :=\n  sorry\n\n@[simp] theorem union_eq_left_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : s ∪ t = s ↔ t ⊆ s :=\n  { mp :=\n      fun (h : s ∪ t = s) => eq.mp (Eq._oldrec (Eq.refl (t ⊆ s ∪ t)) h) (subset_union_right s t),\n    mpr :=\n      fun (h : t ⊆ s) => subset.antisymm (union_subset (subset.refl s) h) (subset_union_left s t) }\n\n@[simp] theorem left_eq_union_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : s = s ∪ t ↔ t ⊆ s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (s = s ∪ t ↔ t ⊆ s)) (Eq.symm (propext union_eq_left_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = s ∪ t ↔ s ∪ t = s)) (propext eq_comm)))\n      (iff.refl (s ∪ t = s)))\n\n@[simp] theorem union_eq_right_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : t ∪ s = s ↔ t ⊆ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (t ∪ s = s ↔ t ⊆ s)) (union_comm t s)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t = s ↔ t ⊆ s)) (propext union_eq_left_iff_subset)))\n      (iff.refl (t ⊆ s)))\n\n@[simp] theorem right_eq_union_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : s = t ∪ s ↔ t ⊆ s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (s = t ∪ s ↔ t ⊆ s)) (Eq.symm (propext union_eq_right_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = t ∪ s ↔ t ∪ s = s)) (propext eq_comm)))\n      (iff.refl (t ∪ s = s)))\n\n/--\nTo prove a relation on pairs of `finset X`, it suffices to show that it is\n  * symmetric,\n  * it holds when one of the `finset`s is empty,\n  * it holds for pairs of singletons,\n  * if it holds for `[a, c]` and for `[b, c]`, then it holds for `[a ∪ b, c]`.\n-/\ntheorem induction_on_union {α : Type u_1} [DecidableEq α] (P : finset α → finset α → Prop)\n    (symm : ∀ {a b : finset α}, P a b → P b a) (empty_right : ∀ {a : finset α}, P a ∅)\n    (singletons : ∀ {a b : α}, P (singleton a) (singleton b))\n    (union_of : ∀ {a b c : finset α}, P a c → P b c → P (a ∪ b) c) (a : finset α) (b : finset α) :\n    P a b :=\n  sorry\n\n/-! ### inter -/\n\n/-- `s ∩ t` is the set such that `a ∈ s ∩ t` iff `a ∈ s` and `a ∈ t`. -/\nprotected instance has_inter {α : Type u_1} [DecidableEq α] : has_inter (finset α) :=\n  has_inter.mk fun (s₁ s₂ : finset α) => mk (multiset.ndinter (val s₁) (val s₂)) sorry\n\ntheorem inter_val_nd {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    val (s₁ ∩ s₂) = multiset.ndinter (val s₁) (val s₂) :=\n  rfl\n\n@[simp] theorem inter_val {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    val (s₁ ∩ s₂) = val s₁ ∩ val s₂ :=\n  multiset.ndinter_eq_inter (nodup s₁)\n\n@[simp] theorem mem_inter {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} :\n    a ∈ s₁ ∩ s₂ ↔ a ∈ s₁ ∧ a ∈ s₂ :=\n  multiset.mem_ndinter\n\ntheorem mem_of_mem_inter_left {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α}\n    (h : a ∈ s₁ ∩ s₂) : a ∈ s₁ :=\n  and.left (iff.mp mem_inter h)\n\ntheorem mem_of_mem_inter_right {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α}\n    {s₂ : finset α} (h : a ∈ s₁ ∩ s₂) : a ∈ s₂ :=\n  and.right (iff.mp mem_inter h)\n\ntheorem mem_inter_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} :\n    a ∈ s₁ → a ∈ s₂ → a ∈ s₁ ∩ s₂ :=\n  iff.mp and_imp (iff.mpr mem_inter)\n\ntheorem inter_subset_left {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ ∩ s₂ ⊆ s₁ :=\n  fun (a : α) => mem_of_mem_inter_left\n\ntheorem inter_subset_right {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ ∩ s₂ ⊆ s₂ :=\n  fun (a : α) => mem_of_mem_inter_right\n\ntheorem subset_inter {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α}\n    {s₃ : finset α} : s₁ ⊆ s₂ → s₁ ⊆ s₃ → s₁ ⊆ s₂ ∩ s₃ :=\n  sorry\n\n@[simp] theorem coe_inter {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    ↑(s₁ ∩ s₂) = ↑s₁ ∩ ↑s₂ :=\n  set.ext fun (_x : α) => mem_inter\n\n@[simp] theorem union_inter_cancel_left {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : (s ∪ t) ∩ s = s :=\n  sorry\n\n@[simp] theorem union_inter_cancel_right {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : (s ∪ t) ∩ t = t :=\n  sorry\n\ntheorem inter_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ ∩ s₂ = s₂ ∩ s₁ :=\n  sorry\n\n@[simp] theorem inter_assoc {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (s₃ : finset α) : s₁ ∩ s₂ ∩ s₃ = s₁ ∩ (s₂ ∩ s₃) :=\n  sorry\n\ntheorem inter_left_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (s₃ : finset α) : s₁ ∩ (s₂ ∩ s₃) = s₂ ∩ (s₁ ∩ s₃) :=\n  sorry\n\ntheorem inter_right_comm {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (s₃ : finset α) : s₁ ∩ s₂ ∩ s₃ = s₁ ∩ s₃ ∩ s₂ :=\n  sorry\n\n@[simp] theorem inter_self {α : Type u_1} [DecidableEq α] (s : finset α) : s ∩ s = s :=\n  ext fun (_x : α) => iff.trans mem_inter (and_self (_x ∈ s))\n\n@[simp] theorem inter_empty {α : Type u_1} [DecidableEq α] (s : finset α) : s ∩ ∅ = ∅ :=\n  ext fun (_x : α) => iff.trans mem_inter (and_false (_x ∈ s))\n\n@[simp] theorem empty_inter {α : Type u_1} [DecidableEq α] (s : finset α) : ∅ ∩ s = ∅ :=\n  ext fun (_x : α) => iff.trans mem_inter (false_and (_x ∈ s))\n\n@[simp] theorem inter_union_self {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    s ∩ (t ∪ s) = s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∩ (t ∪ s) = s)) (inter_comm s (t ∪ s))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((t ∪ s) ∩ s = s)) union_inter_cancel_right)) (Eq.refl s))\n\n@[simp] theorem insert_inter_of_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α}\n    {a : α} (h : a ∈ s₂) : insert a s₁ ∩ s₂ = insert a (s₁ ∩ s₂) :=\n  sorry\n\n@[simp] theorem inter_insert_of_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α}\n    {a : α} (h : a ∈ s₁) : s₁ ∩ insert a s₂ = insert a (s₁ ∩ s₂) :=\n  sorry\n\n@[simp] theorem insert_inter_of_not_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α}\n    {s₂ : finset α} {a : α} (h : ¬a ∈ s₂) : insert a s₁ ∩ s₂ = s₁ ∩ s₂ :=\n  sorry\n\n@[simp] theorem inter_insert_of_not_mem {α : Type u_1} [DecidableEq α] {s₁ : finset α}\n    {s₂ : finset α} {a : α} (h : ¬a ∈ s₁) : s₁ ∩ insert a s₂ = s₁ ∩ s₂ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s₁ ∩ insert a s₂ = s₁ ∩ s₂)) (inter_comm s₁ (insert a s₂))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a s₂ ∩ s₁ = s₁ ∩ s₂)) (insert_inter_of_not_mem h)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s₂ ∩ s₁ = s₁ ∩ s₂)) (inter_comm s₂ s₁)))\n        (Eq.refl (s₁ ∩ s₂))))\n\n@[simp] theorem singleton_inter_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    (H : a ∈ s) : singleton a ∩ s = singleton a :=\n  (fun (this : insert a ∅ ∩ s = insert a ∅) => this)\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a ∅ ∩ s = insert a ∅)) (insert_inter_of_mem H)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (insert a (∅ ∩ s) = insert a ∅)) (empty_inter s)))\n        (Eq.refl (insert a ∅))))\n\n@[simp] theorem singleton_inter_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    (H : ¬a ∈ s) : singleton a ∩ s = ∅ :=\n  sorry\n\n@[simp] theorem inter_singleton_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    (h : a ∈ s) : s ∩ singleton a = singleton a :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∩ singleton a = singleton a)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a ∩ s = singleton a)) (singleton_inter_of_mem h)))\n      (Eq.refl (singleton a)))\n\n@[simp] theorem inter_singleton_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    (h : ¬a ∈ s) : s ∩ singleton a = ∅ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∩ singleton a = ∅)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a ∩ s = ∅)) (singleton_inter_of_not_mem h)))\n      (Eq.refl ∅))\n\ntheorem inter_subset_inter {α : Type u_1} [DecidableEq α] {x : finset α} {y : finset α}\n    {s : finset α} {t : finset α} (h : x ⊆ y) (h' : s ⊆ t) : x ∩ s ⊆ y ∩ t :=\n  sorry\n\ntheorem inter_subset_inter_right {α : Type u_1} [DecidableEq α] {x : finset α} {y : finset α}\n    {s : finset α} (h : x ⊆ y) : x ∩ s ⊆ y ∩ s :=\n  inter_subset_inter h (subset.refl s)\n\ntheorem inter_subset_inter_left {α : Type u_1} [DecidableEq α] {x : finset α} {y : finset α}\n    {s : finset α} (h : x ⊆ y) : s ∩ x ⊆ s ∩ y :=\n  inter_subset_inter (subset.refl s) h\n\n/-! ### lattice laws -/\n\nprotected instance lattice {α : Type u_1} [DecidableEq α] : lattice (finset α) :=\n  lattice.mk has_union.union partial_order.le partial_order.lt sorry sorry sorry sorry sorry sorry\n    has_inter.inter sorry sorry sorry\n\n@[simp] theorem sup_eq_union {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    s ⊔ t = s ∪ t :=\n  rfl\n\n@[simp] theorem inf_eq_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    s ⊓ t = s ∩ t :=\n  rfl\n\nprotected instance semilattice_inf_bot {α : Type u_1} [DecidableEq α] :\n    semilattice_inf_bot (finset α) :=\n  semilattice_inf_bot.mk ∅ lattice.le lattice.lt sorry sorry sorry empty_subset lattice.inf sorry\n    sorry sorry\n\nprotected instance semilattice_sup_bot {α : Type u_1} [DecidableEq α] :\n    semilattice_sup_bot (finset α) :=\n  semilattice_sup_bot.mk semilattice_inf_bot.bot semilattice_inf_bot.le semilattice_inf_bot.lt sorry\n    sorry sorry sorry lattice.sup sorry sorry sorry\n\nprotected instance distrib_lattice {α : Type u_1} [DecidableEq α] : distrib_lattice (finset α) :=\n  distrib_lattice.mk lattice.sup lattice.le lattice.lt sorry sorry sorry sorry sorry sorry\n    lattice.inf sorry sorry sorry sorry\n\ntheorem inter_distrib_left {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α)\n    (u : finset α) : s ∩ (t ∪ u) = s ∩ t ∪ s ∩ u :=\n  inf_sup_left\n\ntheorem inter_distrib_right {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α)\n    (u : finset α) : (s ∪ t) ∩ u = s ∩ u ∪ t ∩ u :=\n  inf_sup_right\n\ntheorem union_distrib_left {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α)\n    (u : finset α) : s ∪ t ∩ u = (s ∪ t) ∩ (s ∪ u) :=\n  sup_inf_left\n\ntheorem union_distrib_right {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α)\n    (u : finset α) : s ∩ t ∪ u = (s ∪ u) ∩ (t ∪ u) :=\n  sup_inf_right\n\ntheorem union_eq_empty_iff {α : Type u_1} [DecidableEq α] (A : finset α) (B : finset α) :\n    A ∪ B = ∅ ↔ A = ∅ ∧ B = ∅ :=\n  sup_eq_bot_iff\n\n/-! ### erase -/\n\n/-- `erase s a` is the set `s - {a}`, that is, the elements of `s` which are\n  not equal to `a`. -/\ndef erase {α : Type u_1} [DecidableEq α] (s : finset α) (a : α) : finset α :=\n  mk (multiset.erase (val s) a) sorry\n\n@[simp] theorem erase_val {α : Type u_1} [DecidableEq α] (s : finset α) (a : α) :\n    val (erase s a) = multiset.erase (val s) a :=\n  rfl\n\n@[simp] theorem mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} :\n    a ∈ erase s b ↔ a ≠ b ∧ a ∈ s :=\n  multiset.mem_erase_iff_of_nodup (nodup s)\n\ntheorem not_mem_erase {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : ¬a ∈ erase s a :=\n  multiset.mem_erase_of_nodup (nodup s)\n\n@[simp] theorem erase_empty {α : Type u_1} [DecidableEq α] (a : α) : erase ∅ a = ∅ := rfl\n\ntheorem ne_of_mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} :\n    b ∈ erase s a → b ≠ a :=\n  eq.mpr (id (imp_congr_eq (propext mem_erase) (Eq.refl (b ≠ a)))) and.left\n\ntheorem mem_of_mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} :\n    b ∈ erase s a → b ∈ s :=\n  multiset.mem_of_mem_erase\n\ntheorem mem_erase_of_ne_of_mem {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α} :\n    a ≠ b → a ∈ s → a ∈ erase s b :=\n  eq.mpr (id (imp_congr_eq (Eq.refl (a ≠ b)) (imp_congr_eq (Eq.refl (a ∈ s)) (propext mem_erase))))\n    And.intro\n\n/-- An element of `s` that is not an element of `erase s a` must be\n`a`. -/\ntheorem eq_of_mem_of_not_mem_erase {α : Type u_1} [DecidableEq α] {a : α} {b : α} {s : finset α}\n    (hs : b ∈ s) (hsa : ¬b ∈ erase s a) : b = a :=\n  sorry\n\ntheorem erase_insert {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) :\n    erase (insert a s) a = s :=\n  sorry\n\ntheorem insert_erase {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) :\n    insert a (erase s a) = s :=\n  sorry\n\ntheorem erase_subset_erase {α : Type u_1} [DecidableEq α] (a : α) {s : finset α} {t : finset α}\n    (h : s ⊆ t) : erase s a ⊆ erase t a :=\n  iff.mp val_le_iff (multiset.erase_le_erase a (iff.mpr val_le_iff h))\n\ntheorem erase_subset {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) : erase s a ⊆ s :=\n  multiset.erase_subset a (val s)\n\n@[simp] theorem coe_erase {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    ↑(erase s a) = ↑s \\ singleton a :=\n  sorry\n\ntheorem erase_ssubset {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) :\n    erase s a ⊂ s :=\n  trans_rel_left has_ssubset.ssubset (ssubset_insert (not_mem_erase a s)) (insert_erase h)\n\ntheorem erase_eq_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : ¬a ∈ s) :\n    erase s a = s :=\n  eq_of_veq (multiset.erase_of_not_mem h)\n\ntheorem subset_insert_iff {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} {t : finset α} :\n    s ⊆ insert a t ↔ erase s a ⊆ t :=\n  sorry\n\ntheorem erase_insert_subset {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    erase (insert a s) a ⊆ s :=\n  iff.mp subset_insert_iff (subset.refl (insert a s))\n\ntheorem insert_erase_subset {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    s ⊆ insert a (erase s a) :=\n  iff.mpr subset_insert_iff (subset.refl (erase s a))\n\n/-! ### sdiff -/\n\n/-- `s \\ t` is the set consisting of the elements of `s` that are not in `t`. -/\nprotected instance has_sdiff {α : Type u_1} [DecidableEq α] : has_sdiff (finset α) :=\n  has_sdiff.mk fun (s₁ s₂ : finset α) => mk (val s₁ - val s₂) sorry\n\n@[simp] theorem mem_sdiff {α : Type u_1} [DecidableEq α] {a : α} {s₁ : finset α} {s₂ : finset α} :\n    a ∈ s₁ \\ s₂ ↔ a ∈ s₁ ∧ ¬a ∈ s₂ :=\n  multiset.mem_sub_of_nodup (nodup s₁)\n\ntheorem not_mem_sdiff_of_mem_right {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    {t : finset α} (h : a ∈ t) : ¬a ∈ s \\ t :=\n  sorry\n\ntheorem sdiff_union_of_subset {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α}\n    (h : s₁ ⊆ s₂) : s₂ \\ s₁ ∪ s₁ = s₂ :=\n  sorry\n\ntheorem union_sdiff_of_subset {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α}\n    (h : s₁ ⊆ s₂) : s₁ ∪ s₂ \\ s₁ = s₂ :=\n  Eq.trans (union_comm s₁ (s₂ \\ s₁)) (sdiff_union_of_subset h)\n\ntheorem inter_sdiff {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) (u : finset α) :\n    s ∩ (t \\ u) = s ∩ t \\ u :=\n  sorry\n\n@[simp] theorem inter_sdiff_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ ∩ (s₂ \\ s₁) = ∅ :=\n  sorry\n\n@[simp] theorem sdiff_inter_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₂ \\ s₁ ∩ s₁ = ∅ :=\n  Eq.trans (inter_comm (s₂ \\ s₁) s₁) (inter_sdiff_self s₁ s₂)\n\n@[simp] theorem sdiff_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) : s₁ \\ s₁ = ∅ := sorry\n\ntheorem sdiff_inter_distrib_right {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (s₃ : finset α) : s₁ \\ (s₂ ∩ s₃) = s₁ \\ s₂ ∪ s₁ \\ s₃ :=\n  sorry\n\n@[simp] theorem sdiff_inter_self_left {α : Type u_1} [DecidableEq α] (s₁ : finset α)\n    (s₂ : finset α) : s₁ \\ (s₁ ∩ s₂) = s₁ \\ s₂ :=\n  sorry\n\n@[simp] theorem sdiff_inter_self_right {α : Type u_1} [DecidableEq α] (s₁ : finset α)\n    (s₂ : finset α) : s₁ \\ (s₂ ∩ s₁) = s₁ \\ s₂ :=\n  sorry\n\n@[simp] theorem sdiff_empty {α : Type u_1} [DecidableEq α] {s₁ : finset α} : s₁ \\ ∅ = s₁ := sorry\n\ntheorem sdiff_subset_sdiff {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α}\n    {t₁ : finset α} {t₂ : finset α} (h₁ : t₁ ⊆ t₂) (h₂ : s₂ ⊆ s₁) : t₁ \\ s₁ ⊆ t₂ \\ s₂ :=\n  sorry\n\ntheorem sdiff_subset_self {α : Type u_1} [DecidableEq α] {s₁ : finset α} {s₂ : finset α} :\n    s₁ \\ s₂ ⊆ s₁ :=\n  sorry\n\n@[simp] theorem coe_sdiff {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    ↑(s₁ \\ s₂) = ↑s₁ \\ ↑s₂ :=\n  set.ext fun (_x : α) => mem_sdiff\n\n@[simp] theorem union_sdiff_self_eq_union {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : s ∪ t \\ s = s ∪ t :=\n  sorry\n\n@[simp] theorem sdiff_union_self_eq_union {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t : finset α} : s \\ t ∪ t = s ∪ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t ∪ t = s ∪ t)) (union_comm (s \\ t) t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (t ∪ s \\ t = s ∪ t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (t ∪ s = s ∪ t)) (union_comm t s))) (Eq.refl (s ∪ t))))\n\ntheorem union_sdiff_symm {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    s ∪ t \\ s = t ∪ s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t \\ s = t ∪ s \\ t)) union_sdiff_self_eq_union))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t = t ∪ s \\ t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s ∪ t = t ∪ s)) (union_comm s t))) (Eq.refl (t ∪ s))))\n\ntheorem sdiff_union_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    s \\ t ∪ s ∩ t = s :=\n  sorry\n\n@[simp] theorem sdiff_idem {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    s \\ t \\ t = s \\ t :=\n  sorry\n\ntheorem sdiff_eq_empty_iff_subset {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    s \\ t = ∅ ↔ s ⊆ t :=\n  sorry\n\n@[simp] theorem empty_sdiff {α : Type u_1} [DecidableEq α] (s : finset α) : ∅ \\ s = ∅ :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (∅ \\ s = ∅)) (propext sdiff_eq_empty_iff_subset)))\n    (empty_subset s)\n\ntheorem insert_sdiff_of_not_mem {α : Type u_1} [DecidableEq α] (s : finset α) {t : finset α} {x : α}\n    (h : ¬x ∈ t) : insert x s \\ t = insert x (s \\ t) :=\n  sorry\n\ntheorem insert_sdiff_of_mem {α : Type u_1} [DecidableEq α] (s : finset α) {t : finset α} {x : α}\n    (h : x ∈ t) : insert x s \\ t = s \\ t :=\n  sorry\n\n@[simp] theorem insert_sdiff_insert {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α)\n    (x : α) : insert x s \\ insert x t = s \\ insert x t :=\n  insert_sdiff_of_mem s (mem_insert_self x t)\n\ntheorem sdiff_insert_of_not_mem {α : Type u_1} [DecidableEq α] {s : finset α} {x : α} (h : ¬x ∈ s)\n    (t : finset α) : s \\ insert x t = s \\ t :=\n  sorry\n\n@[simp] theorem sdiff_subset {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    s \\ t ⊆ s :=\n  sorry\n\ntheorem union_sdiff_distrib {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α)\n    (t : finset α) : (s₁ ∪ s₂) \\ t = s₁ \\ t ∪ s₂ \\ t :=\n  sorry\n\ntheorem sdiff_union_distrib {α : Type u_1} [DecidableEq α] (s : finset α) (t₁ : finset α)\n    (t₂ : finset α) : s \\ (t₁ ∪ t₂) = s \\ t₁ ∩ (s \\ t₂) :=\n  sorry\n\ntheorem union_sdiff_self {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    (s ∪ t) \\ t = s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl ((s ∪ t) \\ t = s \\ t)) (union_sdiff_distrib s t t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t ∪ t \\ t = s \\ t)) (sdiff_self t)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t ∪ ∅ = s \\ t)) (union_empty (s \\ t))))\n        (Eq.refl (s \\ t))))\n\ntheorem sdiff_singleton_eq_erase {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    s \\ singleton a = erase s a :=\n  sorry\n\ntheorem sdiff_sdiff_self_left {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    s \\ (s \\ t) = s ∩ t :=\n  sorry\n\ntheorem inter_eq_inter_of_sdiff_eq_sdiff {α : Type u_1} [DecidableEq α] {s : finset α}\n    {t₁ : finset α} {t₂ : finset α} : s \\ t₁ = s \\ t₂ → s ∩ t₁ = s ∩ t₂ :=\n  sorry\n\n/-! ### attach -/\n\n/-- `attach s` takes the elements of `s` and forms a new set of elements of the\n  subtype `{x // x ∈ s}`. -/\ndef attach {α : Type u_1} (s : finset α) : finset (Subtype fun (x : α) => x ∈ s) :=\n  mk (multiset.attach (val s)) sorry\n\ntheorem sizeof_lt_sizeof_of_mem {α : Type u_1} [SizeOf α] {x : α} {s : finset α} (hx : x ∈ s) :\n    sizeof x < sizeof s :=\n  sorry\n\n@[simp] theorem attach_val {α : Type u_1} (s : finset α) :\n    val (attach s) = multiset.attach (val s) :=\n  rfl\n\n@[simp] theorem mem_attach {α : Type u_1} (s : finset α) (x : Subtype fun (x : α) => x ∈ s) :\n    x ∈ attach s :=\n  multiset.mem_attach (val s)\n\n@[simp] theorem attach_empty {α : Type u_1} : attach ∅ = ∅ := rfl\n\n/-! ### piecewise -/\n\n/-- `s.piecewise f g` is the function equal to `f` on the finset `s`, and to `g` on its\ncomplement. -/\ndef piecewise {α : Type u_1} {δ : α → Sort u_2} (s : finset α) (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] (i : α) : δ i :=\n  ite (i ∈ s) (f i) (g i)\n\n@[simp] theorem piecewise_insert_self {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    (f : (i : α) → δ i) (g : (i : α) → δ i) [DecidableEq α] {j : α}\n    [(i : α) → Decidable (i ∈ insert j s)] : piecewise (insert j s) f g j = f j :=\n  sorry\n\n@[simp] theorem piecewise_empty {α : Type u_1} {δ : α → Sort u_4} (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [(i : α) → Decidable (i ∈ ∅)] : piecewise ∅ f g = g :=\n  sorry\n\ntheorem piecewise_coe {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [(j : α) → Decidable (j ∈ ↑s)] :\n    set.piecewise (↑s) f g = piecewise s f g :=\n  sorry\n\n@[simp] theorem piecewise_eq_of_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] {i : α} (hi : i ∈ s) :\n    piecewise s f g i = f i :=\n  sorry\n\n@[simp] theorem piecewise_eq_of_not_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] {i : α} (hi : ¬i ∈ s) :\n    piecewise s f g i = g i :=\n  sorry\n\ntheorem piecewise_congr {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    [(j : α) → Decidable (j ∈ s)] {f : (i : α) → δ i} {f' : (i : α) → δ i} {g : (i : α) → δ i}\n    {g' : (i : α) → δ i} (hf : ∀ (i : α), i ∈ s → f i = f' i)\n    (hg : ∀ (i : α), ¬i ∈ s → g i = g' i) : piecewise s f g = piecewise s f' g' :=\n  funext fun (i : α) => if_ctx_congr iff.rfl (hf i) (hg i)\n\n@[simp] theorem piecewise_insert_of_ne {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] {i : α}\n    {j : α} [(i : α) → Decidable (i ∈ insert j s)] (h : i ≠ j) :\n    piecewise (insert j s) f g i = piecewise s f g i :=\n  sorry\n\ntheorem piecewise_insert {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] (j : α)\n    [(i : α) → Decidable (i ∈ insert j s)] :\n    piecewise (insert j s) f g = function.update (piecewise s f g) j (f j) :=\n  sorry\n\ntheorem piecewise_cases {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] {i : α} (p : δ i → Prop) (hf : p (f i))\n    (hg : p (g i)) : p (piecewise s f g i) :=\n  sorry\n\ntheorem piecewise_mem_set_pi {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} {t : set α} {t' : (i : α) → set (δ i)} {f : (i : α) → δ i}\n    {g : (i : α) → δ i} (hf : f ∈ set.pi t t') (hg : g ∈ set.pi t t') :\n    piecewise s f g ∈ set.pi t t' :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (piecewise s f g ∈ set.pi t t')) (Eq.symm (piecewise_coe s f g))))\n    (set.piecewise_mem_pi (↑s) hf hg)\n\ntheorem piecewise_singleton {α : Type u_1} {δ : α → Sort u_4} (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [DecidableEq α] (i : α) :\n    piecewise (singleton i) f g = function.update g i (f i) :=\n  sorry\n\ntheorem piecewise_piecewise_of_subset_left {α : Type u_1} {δ : α → Sort u_4} {s : finset α}\n    {t : finset α} [(i : α) → Decidable (i ∈ s)] [(i : α) → Decidable (i ∈ t)] (h : s ⊆ t)\n    (f₁ : (a : α) → δ a) (f₂ : (a : α) → δ a) (g : (a : α) → δ a) :\n    piecewise s (piecewise t f₁ f₂) g = piecewise s f₁ g :=\n  piecewise_congr s (fun (i : α) (hi : i ∈ s) => piecewise_eq_of_mem t f₁ f₂ (h hi))\n    fun (_x : α) (_x_1 : ¬_x ∈ s) => rfl\n\n@[simp] theorem piecewise_idem_left {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    [(j : α) → Decidable (j ∈ s)] (f₁ : (a : α) → δ a) (f₂ : (a : α) → δ a) (g : (a : α) → δ a) :\n    piecewise s (piecewise s f₁ f₂) g = piecewise s f₁ g :=\n  piecewise_piecewise_of_subset_left (subset.refl s) f₁ f₂ g\n\ntheorem piecewise_piecewise_of_subset_right {α : Type u_1} {δ : α → Sort u_4} {s : finset α}\n    {t : finset α} [(i : α) → Decidable (i ∈ s)] [(i : α) → Decidable (i ∈ t)] (h : t ⊆ s)\n    (f : (a : α) → δ a) (g₁ : (a : α) → δ a) (g₂ : (a : α) → δ a) :\n    piecewise s f (piecewise t g₁ g₂) = piecewise s f g₂ :=\n  piecewise_congr s (fun (_x : α) (_x_1 : _x ∈ s) => rfl)\n    fun (i : α) (hi : ¬i ∈ s) => piecewise_eq_of_not_mem t g₁ g₂ (mt h hi)\n\n@[simp] theorem piecewise_idem_right {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    [(j : α) → Decidable (j ∈ s)] (f : (a : α) → δ a) (g₁ : (a : α) → δ a) (g₂ : (a : α) → δ a) :\n    piecewise s f (piecewise s g₁ g₂) = piecewise s f g₂ :=\n  piecewise_piecewise_of_subset_right (subset.refl s) f g₁ g₂\n\ntheorem update_eq_piecewise {α : Type u_1} {β : Type u_2} [DecidableEq α] (f : α → β) (i : α)\n    (v : β) : function.update f i v = piecewise (singleton i) (fun (j : α) => v) f :=\n  Eq.symm (piecewise_singleton (fun (i : α) => v) f i)\n\ntheorem update_piecewise {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] (i : α) (v : δ i) :\n    function.update (piecewise s f g) i v =\n        piecewise s (function.update f i v) (function.update g i v) :=\n  sorry\n\ntheorem update_piecewise_of_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α) (f : (i : α) → δ i)\n    (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] {i : α} (hi : i ∈ s)\n    (v : δ i) : function.update (piecewise s f g) i v = piecewise s (function.update f i v) g :=\n  sorry\n\ntheorem update_piecewise_of_not_mem {α : Type u_1} {δ : α → Sort u_4} (s : finset α)\n    (f : (i : α) → δ i) (g : (i : α) → δ i) [(j : α) → Decidable (j ∈ s)] [DecidableEq α] {i : α}\n    (hi : ¬i ∈ s) (v : δ i) :\n    function.update (piecewise s f g) i v = piecewise s f (function.update g i v) :=\n  sorry\n\ntheorem piecewise_le_of_le_of_le {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i}\n    {h : (i : α) → δ i} (Hf : f ≤ h) (Hg : g ≤ h) : piecewise s f g ≤ h :=\n  fun (x : α) => piecewise_cases s f g (fun (_x : δ x) => _x ≤ h x) (Hf x) (Hg x)\n\ntheorem le_piecewise_of_le_of_le {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i}\n    {h : (i : α) → δ i} (Hf : h ≤ f) (Hg : h ≤ g) : h ≤ piecewise s f g :=\n  fun (x : α) => piecewise_cases s f g (fun (y : δ x) => h x ≤ y) (Hf x) (Hg x)\n\ntheorem piecewise_le_piecewise' {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i}\n    {f' : (i : α) → δ i} {g' : (i : α) → δ i} (Hf : ∀ (x : α), x ∈ s → f x ≤ f' x)\n    (Hg : ∀ (x : α), ¬x ∈ s → g x ≤ g' x) : piecewise s f g ≤ piecewise s f' g' :=\n  sorry\n\ntheorem piecewise_le_piecewise {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i}\n    {f' : (i : α) → δ i} {g' : (i : α) → δ i} (Hf : f ≤ f') (Hg : g ≤ g') :\n    piecewise s f g ≤ piecewise s f' g' :=\n  piecewise_le_piecewise' s (fun (x : α) (_x : x ∈ s) => Hf x) fun (x : α) (_x : ¬x ∈ s) => Hg x\n\ntheorem piecewise_mem_Icc_of_mem_of_mem {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {f₁ : (i : α) → δ i}\n    {g : (i : α) → δ i} {g₁ : (i : α) → δ i} (hf : f ∈ set.Icc f₁ g₁) (hg : g ∈ set.Icc f₁ g₁) :\n    piecewise s f g ∈ set.Icc f₁ g₁ :=\n  { left := le_piecewise_of_le_of_le s (and.left hf) (and.left hg),\n    right := piecewise_le_of_le_of_le s (and.right hf) (and.right hg) }\n\ntheorem piecewise_mem_Icc {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i}\n    (h : f ≤ g) : piecewise s f g ∈ set.Icc f g :=\n  piecewise_mem_Icc_of_mem_of_mem s (iff.mpr set.left_mem_Icc h) (iff.mpr set.right_mem_Icc h)\n\ntheorem piecewise_mem_Icc' {α : Type u_1} (s : finset α) [(j : α) → Decidable (j ∈ s)]\n    {δ : α → Type u_2} [(i : α) → preorder (δ i)] {f : (i : α) → δ i} {g : (i : α) → δ i}\n    (h : g ≤ f) : piecewise s f g ∈ set.Icc g f :=\n  piecewise_mem_Icc_of_mem_of_mem s (iff.mpr set.right_mem_Icc h) (iff.mpr set.left_mem_Icc h)\n\nprotected instance decidable_dforall_finset {α : Type u_1} {s : finset α}\n    {p : (a : α) → a ∈ s → Prop} [hp : (a : α) → (h : a ∈ s) → Decidable (p a h)] :\n    Decidable (∀ (a : α) (h : a ∈ s), p a h) :=\n  multiset.decidable_dforall_multiset\n\n/-- decidable equality for functions whose domain is bounded by finsets -/\nprotected instance decidable_eq_pi_finset {α : Type u_1} {s : finset α} {β : α → Type u_2}\n    [h : (a : α) → DecidableEq (β a)] : DecidableEq ((a : α) → a ∈ s → β a) :=\n  multiset.decidable_eq_pi_multiset\n\nprotected instance decidable_dexists_finset {α : Type u_1} {s : finset α}\n    {p : (a : α) → a ∈ s → Prop} [hp : (a : α) → (h : a ∈ s) → Decidable (p a h)] :\n    Decidable (∃ (a : α), ∃ (h : a ∈ s), p a h) :=\n  multiset.decidable_dexists_multiset\n\n/-! ### filter -/\n\n/-- `filter p s` is the set of elements of `s` that satisfy `p`. -/\ndef filter {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) : finset α :=\n  mk (multiset.filter p (val s)) sorry\n\n@[simp] theorem filter_val {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) :\n    val (filter p s) = multiset.filter p (val s) :=\n  rfl\n\n@[simp] theorem filter_subset {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) :\n    filter p s ⊆ s :=\n  multiset.filter_subset p (val s)\n\n@[simp] theorem mem_filter {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} {a : α} :\n    a ∈ filter p s ↔ a ∈ s ∧ p a :=\n  multiset.mem_filter\n\ntheorem filter_ssubset {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} :\n    filter p s ⊂ s ↔ ∃ (x : α), ∃ (H : x ∈ s), ¬p x :=\n  sorry\n\ntheorem filter_filter {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p]\n    [decidable_pred q] (s : finset α) :\n    filter q (filter p s) = filter (fun (a : α) => p a ∧ q a) s :=\n  sorry\n\ntheorem filter_true {α : Type u_1} {s : finset α} [h : decidable_pred fun (_x : α) => True] :\n    filter (fun (_x : α) => True) s = s :=\n  sorry\n\n@[simp] theorem filter_false {α : Type u_1} {h : decidable_pred fun (a : α) => False}\n    (s : finset α) : filter (fun (a : α) => False) s = ∅ :=\n  sorry\n\n/-- If all elements of a `finset` satisfy the predicate `p`, `s.filter p` is `s`. -/\n@[simp] theorem filter_true_of_mem {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α}\n    (h : ∀ (x : α), x ∈ s → p x) : filter p s = s :=\n  sorry\n\n/-- If all elements of a `finset` fail to satisfy the predicate `p`, `s.filter p` is `∅`. -/\ntheorem filter_false_of_mem {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α}\n    (h : ∀ (x : α), x ∈ s → ¬p x) : filter p s = ∅ :=\n  sorry\n\ntheorem filter_congr {α : Type u_1} {p : α → Prop} {q : α → Prop} [decidable_pred p]\n    [decidable_pred q] {s : finset α} (H : ∀ (x : α), x ∈ s → (p x ↔ q x)) :\n    filter p s = filter q s :=\n  eq_of_veq (multiset.filter_congr H)\n\ntheorem filter_empty {α : Type u_1} (p : α → Prop) [decidable_pred p] : filter p ∅ = ∅ :=\n  iff.mp subset_empty (filter_subset p ∅)\n\ntheorem filter_subset_filter {α : Type u_1} (p : α → Prop) [decidable_pred p] {s : finset α}\n    {t : finset α} (h : s ⊆ t) : filter p s ⊆ filter p t :=\n  fun (a : α) (ha : a ∈ filter p s) =>\n    iff.mpr mem_filter\n      { left := h (and.left (iff.mp mem_filter ha)), right := and.right (iff.mp mem_filter ha) }\n\n@[simp] theorem coe_filter {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) :\n    ↑(filter p s) = has_sep.sep (fun (x : α) => p x) ↑s :=\n  set.ext fun (_x : α) => mem_filter\n\ntheorem filter_singleton {α : Type u_1} (p : α → Prop) [decidable_pred p] (a : α) :\n    filter p (singleton a) = ite (p a) (singleton a) ∅ :=\n  sorry\n\ntheorem filter_union {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α]\n    (s₁ : finset α) (s₂ : finset α) : filter p (s₁ ∪ s₂) = filter p s₁ ∪ filter p s₂ :=\n  sorry\n\ntheorem filter_union_right {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p]\n    [decidable_pred q] [DecidableEq α] (s : finset α) :\n    filter p s ∪ filter q s = filter (fun (x : α) => p x ∨ q x) s :=\n  sorry\n\ntheorem filter_mem_eq_inter {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    [(i : α) → Decidable (i ∈ t)] : filter (fun (i : α) => i ∈ t) s = s ∩ t :=\n  sorry\n\ntheorem filter_inter {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (s : finset α)\n    (t : finset α) : filter p s ∩ t = filter p (s ∩ t) :=\n  sorry\n\ntheorem inter_filter {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (s : finset α)\n    (t : finset α) : s ∩ filter p t = filter p (s ∩ t) :=\n  sorry\n\ntheorem filter_insert {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α] (a : α)\n    (s : finset α) : filter p (insert a s) = ite (p a) (insert a (filter p s)) (filter p s) :=\n  sorry\n\ntheorem filter_or {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p] [decidable_pred q]\n    [DecidableEq α] [decidable_pred fun (a : α) => p a ∨ q a] (s : finset α) :\n    filter (fun (a : α) => p a ∨ q a) s = filter p s ∪ filter q s :=\n  sorry\n\ntheorem filter_and {α : Type u_1} (p : α → Prop) (q : α → Prop) [decidable_pred p]\n    [decidable_pred q] [DecidableEq α] [decidable_pred fun (a : α) => p a ∧ q a] (s : finset α) :\n    filter (fun (a : α) => p a ∧ q a) s = filter p s ∩ filter q s :=\n  sorry\n\ntheorem filter_not {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α]\n    [decidable_pred fun (a : α) => ¬p a] (s : finset α) :\n    filter (fun (a : α) => ¬p a) s = s \\ filter p s :=\n  sorry\n\ntheorem sdiff_eq_filter {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ \\ s₂ = filter (fun (_x : α) => ¬_x ∈ s₂) s₁ :=\n  sorry\n\ntheorem sdiff_eq_self {α : Type u_1} [DecidableEq α] (s₁ : finset α) (s₂ : finset α) :\n    s₁ \\ s₂ = s₁ ↔ s₁ ∩ s₂ ⊆ ∅ :=\n  sorry\n\ntheorem filter_union_filter_neg_eq {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α]\n    [decidable_pred fun (a : α) => ¬p a] (s : finset α) :\n    filter p s ∪ filter (fun (a : α) => ¬p a) s = s :=\n  sorry\n\ntheorem filter_inter_filter_neg_eq {α : Type u_1} (p : α → Prop) [decidable_pred p] [DecidableEq α]\n    (s : finset α) : filter p s ∩ filter (fun (a : α) => ¬p a) s = ∅ :=\n  sorry\n\ntheorem subset_union_elim {α : Type u_1} [DecidableEq α] {s : finset α} {t₁ : set α} {t₂ : set α}\n    (h : ↑s ⊆ t₁ ∪ t₂) :\n    ∃ (s₁ : finset α), ∃ (s₂ : finset α), s₁ ∪ s₂ = s ∧ ↑s₁ ⊆ t₁ ∧ ↑s₂ ⊆ t₂ \\ t₁ :=\n  sorry\n\n/- We can simplify an application of filter where the decidability is inferred in \"the wrong way\" -/\n\n@[simp] theorem filter_congr_decidable {α : Type u_1} (s : finset α) (p : α → Prop)\n    (h : decidable_pred p) [decidable_pred p] : filter p s = filter p s :=\n  sorry\n\n/-- The following instance allows us to write `{ x ∈ s | p x }` for `finset.filter s p`.\n  Since the former notation requires us to define this for all propositions `p`, and `finset.filter`\n  only works for decidable propositions, the notation `{ x ∈ s | p x }` is only compatible with\n  classical logic because it uses `classical.prop_decidable`.\n  We don't want to redo all lemmas of `finset.filter` for `has_sep.sep`, so we make sure that `simp`\n  unfolds the notation `{ x ∈ s | p x }` to `finset.filter s p`. If `p` happens to be decidable, the\n  simp-lemma `filter_congr_decidable` will make sure that `finset.filter` uses the right instance\n  for decidability.\n-/\nprotected instance has_sep {α : Type u_1} : has_sep α (finset α) :=\n  has_sep.mk fun (p : α → Prop) (x : finset α) => filter p x\n\n@[simp] theorem sep_def {α : Type u_1} (s : finset α) (p : α → Prop) :\n    has_sep.sep (fun (x : α) => p x) s = filter p s :=\n  rfl\n\n/--\n  After filtering out everything that does not equal a given value, at most that value remains.\n\n  This is equivalent to `filter_eq'` with the equality the other way.\n-/\n-- This is not a good simp lemma, as it would prevent `finset.mem_filter` from firing\n\n-- on, e.g. `x ∈ s.filter(eq b)`.\n\ntheorem filter_eq {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) :\n    filter (Eq b) s = ite (b ∈ s) (singleton b) ∅ :=\n  sorry\n\n/--\n  After filtering out everything that does not equal a given value, at most that value remains.\n\n  This is equivalent to `filter_eq` with the equality the other way.\n-/\ntheorem filter_eq' {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) :\n    filter (fun (a : β) => a = b) s = ite (b ∈ s) (singleton b) ∅ :=\n  trans (filter_congr fun (_x : β) (_x_1 : _x ∈ s) => { mp := Eq.symm, mpr := Eq.symm })\n    (filter_eq s b)\n\ntheorem filter_ne {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) :\n    filter (fun (a : β) => b ≠ a) s = erase s b :=\n  sorry\n\ntheorem filter_ne' {β : Type u_2} [DecidableEq β] (s : finset β) (b : β) :\n    filter (fun (a : β) => a ≠ b) s = erase s b :=\n  trans (filter_congr fun (_x : β) (_x_1 : _x ∈ s) => { mp := ne.symm, mpr := ne.symm })\n    (filter_ne s b)\n\n/-! ### range -/\n\n/-- `range n` is the set of natural numbers less than `n`. -/\ndef range (n : ℕ) : finset ℕ := mk (multiset.range n) (multiset.nodup_range n)\n\n@[simp] theorem range_coe (n : ℕ) : val (range n) = multiset.range n := rfl\n\n@[simp] theorem mem_range {n : ℕ} {m : ℕ} : m ∈ range n ↔ m < n := multiset.mem_range\n\n@[simp] theorem range_zero : range 0 = ∅ := rfl\n\n@[simp] theorem range_one : range 1 = singleton 0 := rfl\n\ntheorem range_succ {n : ℕ} : range (Nat.succ n) = insert n (range n) :=\n  eq_of_veq\n    (Eq.trans (multiset.range_succ n)\n      (Eq.symm (multiset.ndinsert_of_not_mem multiset.not_mem_range_self)))\n\ntheorem range_add_one {n : ℕ} : range (n + 1) = insert n (range n) := range_succ\n\n@[simp] theorem not_mem_range_self {n : ℕ} : ¬n ∈ range n := multiset.not_mem_range_self\n\n@[simp] theorem self_mem_range_succ (n : ℕ) : n ∈ range (n + 1) := multiset.self_mem_range_succ n\n\n@[simp] theorem range_subset {n : ℕ} {m : ℕ} : range n ⊆ range m ↔ n ≤ m := multiset.range_subset\n\ntheorem range_mono : monotone range := fun (_x _x_1 : ℕ) => iff.mpr range_subset\n\ntheorem mem_range_succ_iff {a : ℕ} {b : ℕ} : a ∈ range (Nat.succ b) ↔ a ≤ b :=\n  iff.trans mem_range nat.lt_succ_iff\n\n/- useful rules for calculations with quantifiers -/\n\ntheorem exists_mem_empty_iff {α : Type u_1} (p : α → Prop) : (∃ (x : α), x ∈ ∅ ∧ p x) ↔ False :=\n  sorry\n\ntheorem exists_mem_insert {α : Type u_1} [d : DecidableEq α] (a : α) (s : finset α) (p : α → Prop) :\n    (∃ (x : α), x ∈ insert a s ∧ p x) ↔ p a ∨ ∃ (x : α), x ∈ s ∧ p x :=\n  sorry\n\ntheorem forall_mem_empty_iff {α : Type u_1} (p : α → Prop) : (∀ (x : α), x ∈ ∅ → p x) ↔ True :=\n  iff_true_intro fun (_x : α) => false.elim\n\ntheorem forall_mem_insert {α : Type u_1} [d : DecidableEq α] (a : α) (s : finset α) (p : α → Prop) :\n    (∀ (x : α), x ∈ insert a s → p x) ↔ p a ∧ ∀ (x : α), x ∈ s → p x :=\n  sorry\n\nend finset\n\n\n/-- Equivalence between the set of natural numbers which are `≥ k` and `ℕ`, given by `n → n - k`. -/\ndef not_mem_range_equiv (k : ℕ) : (Subtype fun (n : ℕ) => ¬n ∈ multiset.range k) ≃ ℕ :=\n  equiv.mk (fun (i : Subtype fun (n : ℕ) => ¬n ∈ multiset.range k) => subtype.val i - k)\n    (fun (j : ℕ) => { val := j + k, property := sorry }) sorry sorry\n\n@[simp] theorem coe_not_mem_range_equiv (k : ℕ) :\n    ⇑(not_mem_range_equiv k) = fun (i : Subtype fun (n : ℕ) => ¬n ∈ multiset.range k) => ↑i - k :=\n  rfl\n\n@[simp] theorem coe_not_mem_range_equiv_symm (k : ℕ) :\n    ⇑(equiv.symm (not_mem_range_equiv k)) =\n        fun (j : ℕ) =>\n          { val := j + k,\n            property :=\n              eq.mpr\n                (id\n                  (Eq.trans\n                    (Eq.trans\n                      ((fun (a a_1 : Prop) (e_1 : a = a_1) => congr_arg Not e_1)\n                        (j + k ∈ multiset.range k) (j < 0)\n                        (Eq.trans (propext multiset.mem_range) (propext add_lt_iff_neg_right)))\n                      (propext not_lt))\n                    (propext ((fun {α : Type} (a : α) => iff_true_intro (zero_le a)) j))))\n                trivial } :=\n  rfl\n\nnamespace option\n\n\n/-- Construct an empty or singleton finset from an `option` -/\ndef to_finset {α : Type u_1} (o : Option α) : finset α := sorry\n\n@[simp] theorem to_finset_none {α : Type u_1} : to_finset none = ∅ := rfl\n\n@[simp] theorem to_finset_some {α : Type u_1} {a : α} : to_finset (some a) = singleton a := rfl\n\n@[simp] theorem mem_to_finset {α : Type u_1} {a : α} {o : Option α} : a ∈ to_finset o ↔ a ∈ o :=\n  sorry\n\nend option\n\n\n/-! ### erase_dup on list and multiset -/\n\nnamespace multiset\n\n\n/-- `to_finset s` removes duplicates from the multiset `s` to produce a finset. -/\ndef to_finset {α : Type u_1} [DecidableEq α] (s : multiset α) : finset α :=\n  finset.mk (erase_dup s) sorry\n\n@[simp] theorem to_finset_val {α : Type u_1} [DecidableEq α] (s : multiset α) :\n    finset.val (to_finset s) = erase_dup s :=\n  rfl\n\ntheorem to_finset_eq {α : Type u_1} [DecidableEq α] {s : multiset α} (n : nodup s) :\n    finset.mk s n = to_finset s :=\n  iff.mp finset.val_inj (Eq.symm (iff.mpr erase_dup_eq_self n))\n\n@[simp] theorem mem_to_finset {α : Type u_1} [DecidableEq α] {a : α} {s : multiset α} :\n    a ∈ to_finset s ↔ a ∈ s :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_zero {α : Type u_1} [DecidableEq α] : to_finset 0 = ∅ := rfl\n\n@[simp] theorem to_finset_cons {α : Type u_1} [DecidableEq α] (a : α) (s : multiset α) :\n    to_finset (a ::ₘ s) = insert a (to_finset s) :=\n  finset.eq_of_veq erase_dup_cons\n\n@[simp] theorem to_finset_add {α : Type u_1} [DecidableEq α] (s : multiset α) (t : multiset α) :\n    to_finset (s + t) = to_finset s ∪ to_finset t :=\n  sorry\n\n@[simp] theorem to_finset_nsmul {α : Type u_1} [DecidableEq α] (s : multiset α) (n : ℕ)\n    (hn : n ≠ 0) : to_finset (n •ℕ s) = to_finset s :=\n  sorry\n\n@[simp] theorem to_finset_inter {α : Type u_1} [DecidableEq α] (s : multiset α) (t : multiset α) :\n    to_finset (s ∩ t) = to_finset s ∩ to_finset t :=\n  sorry\n\n@[simp] theorem to_finset_union {α : Type u_1} [DecidableEq α] (s : multiset α) (t : multiset α) :\n    to_finset (s ∪ t) = to_finset s ∪ to_finset t :=\n  sorry\n\ntheorem to_finset_eq_empty {α : Type u_1} [DecidableEq α] {m : multiset α} :\n    to_finset m = ∅ ↔ m = 0 :=\n  iff.trans (iff.symm finset.val_inj) erase_dup_eq_zero\n\n@[simp] theorem to_finset_subset {α : Type u_1} [DecidableEq α] (m1 : multiset α)\n    (m2 : multiset α) : to_finset m1 ⊆ to_finset m2 ↔ m1 ⊆ m2 :=\n  sorry\n\nend multiset\n\n\nnamespace finset\n\n\n@[simp] theorem val_to_finset {α : Type u_1} [DecidableEq α] (s : finset α) :\n    multiset.to_finset (val s) = s :=\n  sorry\n\nend finset\n\n\nnamespace list\n\n\n/-- `to_finset l` removes duplicates from the list `l` to produce a finset. -/\ndef to_finset {α : Type u_1} [DecidableEq α] (l : List α) : finset α := multiset.to_finset ↑l\n\n@[simp] theorem to_finset_val {α : Type u_1} [DecidableEq α] (l : List α) :\n    finset.val (to_finset l) = ↑(erase_dup l) :=\n  rfl\n\ntheorem to_finset_eq {α : Type u_1} [DecidableEq α] {l : List α} (n : nodup l) :\n    finset.mk (↑l) n = to_finset l :=\n  multiset.to_finset_eq n\n\n@[simp] theorem mem_to_finset {α : Type u_1} [DecidableEq α] {a : α} {l : List α} :\n    a ∈ to_finset l ↔ a ∈ l :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_nil {α : Type u_1} [DecidableEq α] : to_finset [] = ∅ := rfl\n\n@[simp] theorem to_finset_cons {α : Type u_1} [DecidableEq α] {a : α} {l : List α} :\n    to_finset (a :: l) = insert a (to_finset l) :=\n  sorry\n\ntheorem to_finset_surj_on {α : Type u_1} [DecidableEq α] :\n    set.surj_on to_finset (set_of fun (l : List α) => nodup l) set.univ :=\n  sorry\n\ntheorem to_finset_surjective {α : Type u_1} [DecidableEq α] : function.surjective to_finset := sorry\n\nend list\n\n\nnamespace finset\n\n\n/-! ### map -/\n\n/-- When `f` is an embedding of `α` in `β` and `s` is a finset in `α`, then `s.map f` is the image\nfinset in `β`. The embedding condition guarantees that there are no duplicates in the image. -/\ndef map {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) : finset β :=\n  mk (multiset.map (⇑f) (val s)) sorry\n\n@[simp] theorem map_val {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) :\n    val (map f s) = multiset.map (⇑f) (val s) :=\n  rfl\n\n@[simp] theorem map_empty {α : Type u_1} {β : Type u_2} (f : α ↪ β) : map f ∅ = ∅ := rfl\n\n@[simp] theorem mem_map {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} {b : β} :\n    b ∈ map f s ↔ ∃ (a : α), ∃ (H : a ∈ s), coe_fn f a = b :=\n  sorry\n\ntheorem mem_map' {α : Type u_1} {β : Type u_2} (f : α ↪ β) {a : α} {s : finset α} :\n    coe_fn f a ∈ map f s ↔ a ∈ s :=\n  multiset.mem_map_of_injective (function.embedding.inj' f)\n\ntheorem mem_map_of_mem {α : Type u_1} {β : Type u_2} (f : α ↪ β) {a : α} {s : finset α} :\n    a ∈ s → coe_fn f a ∈ map f s :=\n  iff.mpr (mem_map' f)\n\n@[simp] theorem coe_map {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) :\n    ↑(map f s) = ⇑f '' ↑s :=\n  set.ext fun (x : β) => iff.trans mem_map (iff.symm set.mem_image_iff_bex)\n\ntheorem coe_map_subset_range {α : Type u_1} {β : Type u_2} (f : α ↪ β) (s : finset α) :\n    ↑(map f s) ⊆ set.range ⇑f :=\n  trans_rel_right has_subset.subset (coe_map f s) (set.image_subset_range ⇑f ↑s)\n\ntheorem map_to_finset {α : Type u_1} {β : Type u_2} {f : α ↪ β} [DecidableEq α] [DecidableEq β]\n    {s : multiset α} : map f (multiset.to_finset s) = multiset.to_finset (multiset.map (⇑f) s) :=\n  sorry\n\n@[simp] theorem map_refl {α : Type u_1} {s : finset α} : map (function.embedding.refl α) s = s :=\n  sorry\n\ntheorem map_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α ↪ β} {s : finset α}\n    {g : β ↪ γ} : map g (map f s) = map (function.embedding.trans f g) s :=\n  sorry\n\ntheorem map_subset_map {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s₁ : finset α} {s₂ : finset α} :\n    map f s₁ ⊆ map f s₂ ↔ s₁ ⊆ s₂ :=\n  sorry\n\ntheorem map_inj {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s₁ : finset α} {s₂ : finset α} :\n    map f s₁ = map f s₂ ↔ s₁ = s₂ :=\n  sorry\n\n/-- Associate to an embedding `f` from `α` to `β` the embedding that maps a finset to its image\nunder `f`. -/\ndef map_embedding {α : Type u_1} {β : Type u_2} (f : α ↪ β) : finset α ↪ finset β :=\n  function.embedding.mk (map f) sorry\n\n@[simp] theorem map_embedding_apply {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} :\n    coe_fn (map_embedding f) s = map f s :=\n  rfl\n\ntheorem map_filter {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} {p : β → Prop}\n    [decidable_pred p] : filter p (map f s) = map f (filter (p ∘ ⇑f) s) :=\n  sorry\n\ntheorem map_union {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] {f : α ↪ β}\n    (s₁ : finset α) (s₂ : finset α) : map f (s₁ ∪ s₂) = map f s₁ ∪ map f s₂ :=\n  sorry\n\ntheorem map_inter {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] {f : α ↪ β}\n    (s₁ : finset α) (s₂ : finset α) : map f (s₁ ∩ s₂) = map f s₁ ∩ map f s₂ :=\n  sorry\n\n@[simp] theorem map_singleton {α : Type u_1} {β : Type u_2} (f : α ↪ β) (a : α) :\n    map f (singleton a) = singleton (coe_fn f a) :=\n  sorry\n\n@[simp] theorem map_insert {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] (f : α ↪ β)\n    (a : α) (s : finset α) : map f (insert a s) = insert (coe_fn f a) (map f s) :=\n  sorry\n\n@[simp] theorem map_eq_empty {α : Type u_1} {β : Type u_2} {f : α ↪ β} {s : finset α} :\n    map f s = ∅ ↔ s = ∅ :=\n  sorry\n\ntheorem attach_map_val {α : Type u_1} {s : finset α} :\n    map (function.embedding.subtype fun (x : α) => x ∈ s) (attach s) = s :=\n  sorry\n\ntheorem nonempty.map {α : Type u_1} {β : Type u_2} {s : finset α} (h : finset.nonempty s)\n    (f : α ↪ β) : finset.nonempty (map f s) :=\n  sorry\n\ntheorem range_add_one' (n : ℕ) :\n    range (n + 1) =\n        insert 0\n          (map (function.embedding.mk (fun (i : ℕ) => i + 1) fun (i j : ℕ) => nat.succ.inj)\n            (range n)) :=\n  sorry\n\n/-! ### image -/\n\n/-- `image f s` is the forward image of `s` under `f`. -/\ndef image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (s : finset α) : finset β :=\n  multiset.to_finset (multiset.map f (val s))\n\n@[simp] theorem image_val {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (s : finset α) :\n    val (image f s) = multiset.erase_dup (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem image_empty {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) :\n    image f ∅ = ∅ :=\n  rfl\n\n@[simp] theorem mem_image {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α}\n    {b : β} : b ∈ image f s ↔ ∃ (a : α), ∃ (H : a ∈ s), f a = b :=\n  sorry\n\ntheorem mem_image_of_mem {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) {a : α}\n    {s : finset α} (h : a ∈ s) : f a ∈ image f s :=\n  iff.mpr mem_image (Exists.intro a (Exists.intro h rfl))\n\ntheorem filter_mem_image_eq_image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β)\n    (s : finset α) (t : finset β) (h : ∀ (x : α), x ∈ s → f x ∈ t) :\n    filter (fun (y : β) => y ∈ image f s) t = image f s :=\n  sorry\n\ntheorem fiber_nonempty_iff_mem_image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β)\n    (s : finset α) (y : β) : finset.nonempty (filter (fun (x : α) => f x = y) s) ↔ y ∈ image f s :=\n  sorry\n\n@[simp] theorem coe_image {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {f : α → β} :\n    ↑(image f s) = f '' ↑s :=\n  set.ext fun (_x : β) => iff.trans mem_image (iff.symm set.mem_image_iff_bex)\n\ntheorem nonempty.image {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α}\n    (h : finset.nonempty s) (f : α → β) : finset.nonempty (image f s) :=\n  sorry\n\ntheorem image_to_finset {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} [DecidableEq α]\n    {s : multiset α} : image f (multiset.to_finset s) = multiset.to_finset (multiset.map f s) :=\n  sorry\n\ntheorem image_val_of_inj_on {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α}\n    (H : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y → x = y) :\n    val (image f s) = multiset.map f (val s) :=\n  iff.mpr multiset.erase_dup_eq_self (multiset.nodup_map_on H (nodup s))\n\n@[simp] theorem image_id {α : Type u_1} {s : finset α} [DecidableEq α] : image id s = s := sorry\n\ntheorem image_image {α : Type u_1} {β : Type u_2} {γ : Type u_3} [DecidableEq β] {f : α → β}\n    {s : finset α} [DecidableEq γ] {g : β → γ} : image g (image f s) = image (g ∘ f) s :=\n  sorry\n\ntheorem image_subset_image {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s₁ : finset α}\n    {s₂ : finset α} (h : s₁ ⊆ s₂) : image f s₁ ⊆ image f s₂ :=\n  sorry\n\ntheorem image_subset_iff {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {t : finset β}\n    {f : α → β} : image f s ⊆ t ↔ ∀ (x : α), x ∈ s → f x ∈ t :=\n  sorry\n\ntheorem image_mono {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) : monotone (image f) :=\n  fun (_x _x_1 : finset α) => image_subset_image\n\ntheorem coe_image_subset_range {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β}\n    {s : finset α} : ↑(image f s) ⊆ set.range f :=\n  trans_rel_right has_subset.subset coe_image (set.image_subset_range f ↑s)\n\ntheorem image_filter {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α}\n    {p : β → Prop} [decidable_pred p] : filter p (image f s) = image f (filter (p ∘ f) s) :=\n  sorry\n\ntheorem image_union {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α] {f : α → β}\n    (s₁ : finset α) (s₂ : finset α) : image f (s₁ ∪ s₂) = image f s₁ ∪ image f s₂ :=\n  sorry\n\ntheorem image_inter {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} [DecidableEq α]\n    (s₁ : finset α) (s₂ : finset α) (hf : ∀ (x y : α), f x = f y → x = y) :\n    image f (s₁ ∩ s₂) = image f s₁ ∩ image f s₂ :=\n  sorry\n\n@[simp] theorem image_singleton {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (a : α) :\n    image f (singleton a) = singleton (f a) :=\n  sorry\n\n@[simp] theorem image_insert {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α]\n    (f : α → β) (a : α) (s : finset α) : image f (insert a s) = insert (f a) (image f s) :=\n  sorry\n\n@[simp] theorem image_eq_empty {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β}\n    {s : finset α} : image f s = ∅ ↔ s = ∅ :=\n  sorry\n\ntheorem attach_image_val {α : Type u_1} [DecidableEq α] {s : finset α} :\n    image subtype.val (attach s) = s :=\n  sorry\n\n@[simp] theorem attach_insert {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} :\n    attach (insert a s) =\n        insert { val := a, property := mem_insert_self a s }\n          (image\n            (fun (x : Subtype fun (x : α) => x ∈ s) =>\n              { val := subtype.val x, property := mem_insert_of_mem (subtype.property x) })\n            (attach s)) :=\n  sorry\n\ntheorem map_eq_image {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α ↪ β) (s : finset α) :\n    map f s = image (⇑f) s :=\n  eq_of_veq (Eq.symm (iff.mpr multiset.erase_dup_eq_self (nodup (map f s))))\n\ntheorem image_const {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α}\n    (h : finset.nonempty s) (b : β) : image (fun (a : α) => b) s = singleton b :=\n  sorry\n\n/--\nBecause `finset.image` requires a `decidable_eq` instances for the target type,\nwe can only construct a `functor finset` when working classically.\n-/\nprotected instance functor [(P : Prop) → Decidable P] : Functor finset :=\n  { map := fun (α β : Type u_1) (f : α → β) (s : finset α) => image f s,\n    mapConst :=\n      fun (α β : Type u_1) => (fun (f : β → α) (s : finset β) => image f s) ∘ function.const β }\n\nprotected instance is_lawful_functor [(P : Prop) → Decidable P] : is_lawful_functor finset :=\n  is_lawful_functor.mk (fun (α : Type u_1) (x : finset α) => image_id)\n    fun (α β γ : Type u_1) (f : α → β) (g : β → γ) (s : finset α) => Eq.symm image_image\n\n/-- Given a finset `s` and a predicate `p`, `s.subtype p` is the finset of `subtype p` whose\nelements belong to `s`.  -/\nprotected def subtype {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) :\n    finset (Subtype p) :=\n  map\n    (function.embedding.mk\n      (fun (x : Subtype fun (x : α) => x ∈ filter p s) =>\n        { val := subtype.val x, property := sorry })\n      sorry)\n    (attach (filter p s))\n\n@[simp] theorem mem_subtype {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α}\n    {a : Subtype p} : a ∈ finset.subtype p s ↔ ↑a ∈ s :=\n  sorry\n\ntheorem subtype_eq_empty {α : Type u_1} {p : α → Prop} [decidable_pred p] {s : finset α} :\n    finset.subtype p s = ∅ ↔ ∀ (x : α), p x → ¬x ∈ s :=\n  sorry\n\n/-- `s.subtype p` converts back to `s.filter p` with\n`embedding.subtype`. -/\n@[simp] theorem subtype_map {α : Type u_1} {s : finset α} (p : α → Prop) [decidable_pred p] :\n    map (function.embedding.subtype p) (finset.subtype p s) = filter p s :=\n  sorry\n\n/-- If all elements of a `finset` satisfy the predicate `p`,\n`s.subtype p` converts back to `s` with `embedding.subtype`. -/\ntheorem subtype_map_of_mem {α : Type u_1} {s : finset α} {p : α → Prop} [decidable_pred p]\n    (h : ∀ (x : α), x ∈ s → p x) : map (function.embedding.subtype p) (finset.subtype p s) = s :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (map (function.embedding.subtype p) (finset.subtype p s) = s))\n        (subtype_map p)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (filter p s = s)) (filter_true_of_mem h))) (Eq.refl s))\n\n/-- If a `finset` of a subtype is converted to the main type with\n`embedding.subtype`, all elements of the result have the property of\nthe subtype. -/\ntheorem property_of_mem_map_subtype {α : Type u_1} {p : α → Prop}\n    (s : finset (Subtype fun (x : α) => p x)) {a : α}\n    (h : a ∈ map (function.embedding.subtype fun (x : α) => p x) s) : p a :=\n  sorry\n\n/-- If a `finset` of a subtype is converted to the main type with\n`embedding.subtype`, the result does not contain any value that does\nnot satisfy the property of the subtype. -/\ntheorem not_mem_map_subtype_of_not_property {α : Type u_1} {p : α → Prop}\n    (s : finset (Subtype fun (x : α) => p x)) {a : α} (h : ¬p a) :\n    ¬a ∈ map (function.embedding.subtype fun (x : α) => p x) s :=\n  mt (property_of_mem_map_subtype s) h\n\n/-- If a `finset` of a subtype is converted to the main type with\n`embedding.subtype`, the result is a subset of the set giving the\nsubtype. -/\ntheorem map_subtype_subset {α : Type u_1} {t : set α} (s : finset ↥t) :\n    ↑(map (function.embedding.subtype fun (x : α) => x ∈ t) s) ⊆ t :=\n  sorry\n\ntheorem subset_image_iff {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset β}\n    {t : set α} : ↑s ⊆ f '' t ↔ ∃ (s' : finset α), ↑s' ⊆ t ∧ image f s' = s :=\n  sorry\n\nend finset\n\n\ntheorem multiset.to_finset_map {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β]\n    (f : α → β) (m : multiset α) :\n    multiset.to_finset (multiset.map f m) = finset.image f (multiset.to_finset m) :=\n  iff.mp finset.val_inj (Eq.symm (multiset.erase_dup_map_erase_dup_eq f m))\n\nnamespace finset\n\n\n/-! ### card -/\n\n/-- `card s` is the cardinality (number of elements) of `s`. -/\ndef card {α : Type u_1} (s : finset α) : ℕ := coe_fn multiset.card (val s)\n\ntheorem card_def {α : Type u_1} (s : finset α) : card s = coe_fn multiset.card (val s) := rfl\n\n@[simp] theorem card_mk {α : Type u_1} {m : multiset α} {nodup : multiset.nodup m} :\n    card (mk m nodup) = coe_fn multiset.card m :=\n  rfl\n\n@[simp] theorem card_empty {α : Type u_1} : card ∅ = 0 := rfl\n\n@[simp] theorem card_eq_zero {α : Type u_1} {s : finset α} : card s = 0 ↔ s = ∅ :=\n  iff.trans multiset.card_eq_zero val_eq_zero\n\ntheorem card_pos {α : Type u_1} {s : finset α} : 0 < card s ↔ finset.nonempty s :=\n  iff.trans pos_iff_ne_zero (iff.trans (not_congr card_eq_zero) (iff.symm nonempty_iff_ne_empty))\n\ntheorem card_ne_zero_of_mem {α : Type u_1} {s : finset α} {a : α} (h : a ∈ s) : card s ≠ 0 :=\n  iff.mpr (not_congr card_eq_zero) (ne_empty_of_mem h)\n\ntheorem card_eq_one {α : Type u_1} {s : finset α} : card s = 1 ↔ ∃ (a : α), s = singleton a := sorry\n\n@[simp] theorem card_insert_of_not_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    (h : ¬a ∈ s) : card (insert a s) = card s + 1 :=\n  sorry\n\ntheorem card_insert_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} (h : a ∈ s) :\n    card (insert a s) = card s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (card (insert a s) = card s)) (insert_eq_of_mem h)))\n    (Eq.refl (card s))\n\ntheorem card_insert_le {α : Type u_1} [DecidableEq α] (a : α) (s : finset α) :\n    card (insert a s) ≤ card s + 1 :=\n  sorry\n\n@[simp] theorem card_singleton {α : Type u_1} (a : α) : card (singleton a) = 1 :=\n  multiset.card_singleton a\n\ntheorem card_singleton_inter {α : Type u_1} [DecidableEq α] {x : α} {s : finset α} :\n    card (singleton x ∩ s) ≤ 1 :=\n  sorry\n\ntheorem card_erase_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} :\n    a ∈ s → card (erase s a) = Nat.pred (card s) :=\n  multiset.card_erase_of_mem\n\ntheorem card_erase_lt_of_mem {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} :\n    a ∈ s → card (erase s a) < card s :=\n  multiset.card_erase_lt_of_mem\n\ntheorem card_erase_le {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} :\n    card (erase s a) ≤ card s :=\n  multiset.card_erase_le\n\ntheorem pred_card_le_card_erase {α : Type u_1} [DecidableEq α] {a : α} {s : finset α} :\n    card s - 1 ≤ card (erase s a) :=\n  sorry\n\n@[simp] theorem card_range (n : ℕ) : card (range n) = n := multiset.card_range n\n\n@[simp] theorem card_attach {α : Type u_1} {s : finset α} : card (attach s) = card s :=\n  multiset.card_attach\n\nend finset\n\n\ntheorem multiset.to_finset_card_le {α : Type u_1} [DecidableEq α] (m : multiset α) :\n    finset.card (multiset.to_finset m) ≤ coe_fn multiset.card m :=\n  multiset.card_le_of_le (multiset.erase_dup_le m)\n\ntheorem list.to_finset_card_le {α : Type u_1} [DecidableEq α] (l : List α) :\n    finset.card (list.to_finset l) ≤ list.length l :=\n  multiset.to_finset_card_le (quotient.mk l)\n\nnamespace finset\n\n\ntheorem card_image_le {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β} {s : finset α} :\n    card (image f s) ≤ card s :=\n  sorry\n\ntheorem card_image_of_inj_on {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β}\n    {s : finset α} (H : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → f x = f y → x = y) :\n    card (image f s) = card s :=\n  sorry\n\ntheorem card_image_of_injective {α : Type u_1} {β : Type u_2} [DecidableEq β] {f : α → β}\n    (s : finset α) (H : function.injective f) : card (image f s) = card s :=\n  card_image_of_inj_on fun (x : α) (_x : x ∈ s) (y : α) (_x : y ∈ s) (h : f x = f y) => H h\n\ntheorem fiber_card_ne_zero_iff_mem_image {α : Type u_1} {β : Type u_2} (s : finset α) (f : α → β)\n    [DecidableEq β] (y : β) : card (filter (fun (x : α) => f x = y) s) ≠ 0 ↔ y ∈ image f s :=\n  sorry\n\n@[simp] theorem card_map {α : Type u_1} {β : Type u_2} (f : α ↪ β) {s : finset α} :\n    card (map f s) = card s :=\n  multiset.card_map (⇑f) (val s)\n\n@[simp] theorem card_subtype {α : Type u_1} (p : α → Prop) [decidable_pred p] (s : finset α) :\n    card (finset.subtype p s) = card (filter p s) :=\n  sorry\n\ntheorem card_eq_of_bijective {α : Type u_1} {s : finset α} {n : ℕ} (f : (i : ℕ) → i < n → α)\n    (hf : ∀ (a : α), a ∈ s → ∃ (i : ℕ), ∃ (h : i < n), f i h = a)\n    (hf' : ∀ (i : ℕ) (h : i < n), f i h ∈ s)\n    (f_inj : ∀ (i j : ℕ) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : card s = n :=\n  sorry\n\ntheorem card_eq_succ {α : Type u_1} [DecidableEq α] {s : finset α} {n : ℕ} :\n    card s = n + 1 ↔ ∃ (a : α), ∃ (t : finset α), ¬a ∈ t ∧ insert a t = s ∧ card t = n :=\n  sorry\n\ntheorem card_le_of_subset {α : Type u_1} {s : finset α} {t : finset α} : s ⊆ t → card s ≤ card t :=\n  multiset.card_le_of_le ∘ iff.mpr val_le_iff\n\ntheorem eq_of_subset_of_card_le {α : Type u_1} {s : finset α} {t : finset α} (h : s ⊆ t)\n    (h₂ : card t ≤ card s) : s = t :=\n  eq_of_veq (multiset.eq_of_le_of_card_le (iff.mpr val_le_iff h) h₂)\n\ntheorem card_lt_card {α : Type u_1} {s : finset α} {t : finset α} (h : s ⊂ t) : card s < card t :=\n  multiset.card_lt_of_lt (iff.mpr val_lt_iff h)\n\ntheorem card_le_card_of_inj_on {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β}\n    (f : α → β) (hf : ∀ (a : α), a ∈ s → f a ∈ t)\n    (f_inj : ∀ (a₁ : α), a₁ ∈ s → ∀ (a₂ : α), a₂ ∈ s → f a₁ = f a₂ → a₁ = a₂) : card s ≤ card t :=\n  sorry\n\n/--\nIf there are more pigeons than pigeonholes, then there are two pigeons\nin the same pigeonhole.\n-/\ntheorem exists_ne_map_eq_of_card_lt_of_maps_to {α : Type u_1} {β : Type u_2} {s : finset α}\n    {t : finset β} (hc : card t < card s) {f : α → β} (hf : ∀ (a : α), a ∈ s → f a ∈ t) :\n    ∃ (x : α), ∃ (H : x ∈ s), ∃ (y : α), ∃ (H : y ∈ s), x ≠ y ∧ f x = f y :=\n  sorry\n\ntheorem card_le_of_inj_on {α : Type u_1} {n : ℕ} {s : finset α} (f : ℕ → α)\n    (hf : ∀ (i : ℕ), i < n → f i ∈ s) (f_inj : ∀ (i j : ℕ), i < n → j < n → f i = f j → i = j) :\n    n ≤ card s :=\n  sorry\n\n/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to\ndefine an object on `s`. Then one can inductively define an object on all finsets, starting from\nthe empty set and iterating. This can be used either to define data, or to prove properties. -/\ndef strong_induction_on {α : Type u_1} {p : finset α → Sort u_2} (s : finset α) :\n    ((s : finset α) → ((t : finset α) → t ⊂ s → p t) → p s) → p s :=\n  sorry\n\ntheorem case_strong_induction_on {α : Type u_1} [DecidableEq α] {p : finset α → Prop} (s : finset α)\n    (h₀ : p ∅)\n    (h₁ : ∀ (a : α) (s : finset α), ¬a ∈ s → (∀ (t : finset α), t ⊆ s → p t) → p (insert a s)) :\n    p s :=\n  sorry\n\ntheorem card_congr {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β}\n    (f : (a : α) → a ∈ s → β) (h₁ : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t)\n    (h₂ : ∀ (a b : α) (ha : a ∈ s) (hb : b ∈ s), f a ha = f b hb → a = b)\n    (h₃ : ∀ (b : β), b ∈ t → ∃ (a : α), ∃ (ha : a ∈ s), f a ha = b) : card s = card t :=\n  sorry\n\ntheorem card_union_add_card_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    card (s ∪ t) + card (s ∩ t) = card s + card t :=\n  sorry\n\ntheorem card_union_le {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    card (s ∪ t) ≤ card s + card t :=\n  card_union_add_card_inter s t ▸ nat.le_add_right (card (s ∪ t)) (card (s ∩ t))\n\ntheorem card_union_eq {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    (h : disjoint s t) : card (s ∪ t) = card s + card t :=\n  sorry\n\ntheorem surj_on_of_inj_on_of_card_le {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β}\n    (f : (a : α) → a ∈ s → β) (hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t)\n    (hinj : ∀ (a₁ a₂ : α) (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s), f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂)\n    (hst : card t ≤ card s) (b : β) (H : b ∈ t) : ∃ (a : α), ∃ (ha : a ∈ s), b = f a ha :=\n  sorry\n\ntheorem inj_on_of_surj_on_of_card_le {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β}\n    (f : (a : α) → a ∈ s → β) (hf : ∀ (a : α) (ha : a ∈ s), f a ha ∈ t)\n    (hsurj : ∀ (b : β), b ∈ t → ∃ (a : α), ∃ (ha : a ∈ s), b = f a ha) (hst : card s ≤ card t)\n    {a₁ : α} {a₂ : α} (ha₁ : a₁ ∈ s) (ha₂ : a₂ ∈ s) (ha₁a₂ : f a₁ ha₁ = f a₂ ha₂) : a₁ = a₂ :=\n  sorry\n\n/-!\n### bUnion\n\nThis section is about the bounded union of an indexed family `t : α → finset β` of finite sets\nover a finite set `s : finset α`.\n-/\n\n/-- `bUnion s t` is the union of `t x` over `x ∈ s`.\n(This was formerly `bind` due to the monad structure on types with `decidable_eq`.) -/\nprotected def bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] (s : finset α)\n    (t : α → finset β) : finset β :=\n  multiset.to_finset (multiset.bind (val s) fun (a : α) => val (t a))\n\n@[simp] theorem bUnion_val {α : Type u_1} {β : Type u_2} [DecidableEq β] (s : finset α)\n    (t : α → finset β) :\n    val (finset.bUnion s t) = multiset.erase_dup (multiset.bind (val s) fun (a : α) => val (t a)) :=\n  rfl\n\n@[simp] theorem bUnion_empty {α : Type u_1} {β : Type u_2} [DecidableEq β] {t : α → finset β} :\n    finset.bUnion ∅ t = ∅ :=\n  rfl\n\n@[simp] theorem mem_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α}\n    {t : α → finset β} {b : β} : b ∈ finset.bUnion s t ↔ ∃ (a : α), ∃ (H : a ∈ s), b ∈ t a :=\n  sorry\n\n@[simp] theorem bUnion_insert {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α}\n    {t : α → finset β} [DecidableEq α] {a : α} :\n    finset.bUnion (insert a s) t = t a ∪ finset.bUnion s t :=\n  sorry\n\n-- ext $ λ x, by simp [or_and_distrib_right, exists_or_distrib]\n\n@[simp] theorem singleton_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] {t : α → finset β}\n    {a : α} : finset.bUnion (singleton a) t = t a :=\n  sorry\n\ntheorem bUnion_inter {α : Type u_1} {β : Type u_2} [DecidableEq β] (s : finset α) (f : α → finset β)\n    (t : finset β) : finset.bUnion s f ∩ t = finset.bUnion s fun (x : α) => f x ∩ t :=\n  sorry\n\ntheorem inter_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq β] (t : finset β) (s : finset α)\n    (f : α → finset β) : t ∩ finset.bUnion s f = finset.bUnion s fun (x : α) => t ∩ f x :=\n  sorry\n\ntheorem image_bUnion {α : Type u_1} {β : Type u_2} {γ : Type u_3} [DecidableEq β] [DecidableEq γ]\n    {f : α → β} {s : finset α} {t : β → finset γ} :\n    finset.bUnion (image f s) t = finset.bUnion s fun (a : α) => t (f a) :=\n  sorry\n\ntheorem bUnion_image {α : Type u_1} {β : Type u_2} {γ : Type u_3} [DecidableEq β] [DecidableEq γ]\n    {s : finset α} {t : α → finset β} {f : β → γ} :\n    image f (finset.bUnion s t) = finset.bUnion s fun (a : α) => image f (t a) :=\n  sorry\n\ntheorem bind_to_finset {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α]\n    (s : multiset α) (t : α → multiset β) :\n    multiset.to_finset (multiset.bind s t) =\n        finset.bUnion (multiset.to_finset s) fun (a : α) => multiset.to_finset (t a) :=\n  sorry\n\ntheorem bUnion_mono {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {t₁ : α → finset β}\n    {t₂ : α → finset β} (h : ∀ (a : α), a ∈ s → t₁ a ⊆ t₂ a) :\n    finset.bUnion s t₁ ⊆ finset.bUnion s t₂ :=\n  sorry\n\ntheorem bUnion_subset_bUnion_of_subset_left {β : Type u_2} [DecidableEq β] {α : Type u_1}\n    {s₁ : finset α} {s₂ : finset α} (t : α → finset β) (h : s₁ ⊆ s₂) :\n    finset.bUnion s₁ t ⊆ finset.bUnion s₂ t :=\n  sorry\n\ntheorem bUnion_singleton {α : Type u_1} {β : Type u_2} [DecidableEq β] {s : finset α} {f : α → β} :\n    (finset.bUnion s fun (a : α) => singleton (f a)) = image f s :=\n  sorry\n\n@[simp] theorem bUnion_singleton_eq_self {α : Type u_1} {s : finset α} [DecidableEq α] :\n    finset.bUnion s singleton = s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (finset.bUnion s singleton = s)) bUnion_singleton)) image_id\n\ntheorem bUnion_filter_eq_of_maps_to {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α]\n    {s : finset α} {t : finset β} {f : α → β} (h : ∀ (x : α), x ∈ s → f x ∈ t) :\n    (finset.bUnion t fun (a : β) => filter (fun (c : α) => f c = a) s) = s :=\n  sorry\n\ntheorem image_bUnion_filter_eq {α : Type u_1} {β : Type u_2} [DecidableEq β] [DecidableEq α]\n    (s : finset β) (g : β → α) :\n    (finset.bUnion (image g s) fun (a : α) => filter (fun (c : β) => g c = a) s) = s :=\n  bUnion_filter_eq_of_maps_to fun (x : β) => mem_image_of_mem g\n\n/-! ### prod -/\n\n/-- `product s t` is the set of pairs `(a, b)` such that `a ∈ s` and `b ∈ t`. -/\nprotected def product {α : Type u_1} {β : Type u_2} (s : finset α) (t : finset β) :\n    finset (α × β) :=\n  mk (multiset.product (val s) (val t)) sorry\n\n@[simp] theorem product_val {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} :\n    val (finset.product s t) = multiset.product (val s) (val t) :=\n  rfl\n\n@[simp] theorem mem_product {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β}\n    {p : α × β} : p ∈ finset.product s t ↔ prod.fst p ∈ s ∧ prod.snd p ∈ t :=\n  multiset.mem_product\n\ntheorem subset_product {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β]\n    {s : finset (α × β)} : s ⊆ finset.product (image prod.fst s) (image prod.snd s) :=\n  fun (p : α × β) (hp : p ∈ s) =>\n    iff.mpr mem_product\n      { left := mem_image_of_mem prod.fst hp, right := mem_image_of_mem prod.snd hp }\n\ntheorem product_eq_bUnion {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β]\n    (s : finset α) (t : finset β) :\n    finset.product s t = finset.bUnion s fun (a : α) => image (fun (b : β) => (a, b)) t :=\n  sorry\n\n@[simp] theorem card_product {α : Type u_1} {β : Type u_2} (s : finset α) (t : finset β) :\n    card (finset.product s t) = card s * card t :=\n  multiset.card_product (val s) (val t)\n\ntheorem filter_product {α : Type u_1} {β : Type u_2} {s : finset α} {t : finset β} (p : α → Prop)\n    (q : β → Prop) [decidable_pred p] [decidable_pred q] :\n    filter (fun (x : α × β) => p (prod.fst x) ∧ q (prod.snd x)) (finset.product s t) =\n        finset.product (filter p s) (filter q t) :=\n  sorry\n\ntheorem filter_product_card {α : Type u_1} {β : Type u_2} (s : finset α) (t : finset β)\n    (p : α → Prop) (q : β → Prop) [decidable_pred p] [decidable_pred q] :\n    card (filter (fun (x : α × β) => p (prod.fst x) ↔ q (prod.snd x)) (finset.product s t)) =\n        card (filter p s) * card (filter q t) +\n          card (filter (Not ∘ p) s) * card (filter (Not ∘ q) t) :=\n  sorry\n\n/-! ### sigma -/\n\n/-- `sigma s t` is the set of dependent pairs `⟨a, b⟩` such that `a ∈ s` and `b ∈ t a`. -/\nprotected def sigma {α : Type u_1} {σ : α → Type u_4} (s : finset α) (t : (a : α) → finset (σ a)) :\n    finset (sigma fun (a : α) => σ a) :=\n  mk (multiset.sigma (val s) fun (a : α) => val (t a)) sorry\n\n@[simp] theorem mem_sigma {α : Type u_1} {σ : α → Type u_4} {s : finset α}\n    {t : (a : α) → finset (σ a)} {p : sigma σ} :\n    p ∈ finset.sigma s t ↔ sigma.fst p ∈ s ∧ sigma.snd p ∈ t (sigma.fst p) :=\n  multiset.mem_sigma\n\ntheorem sigma_mono {α : Type u_1} {σ : α → Type u_4} {s₁ : finset α} {s₂ : finset α}\n    {t₁ : (a : α) → finset (σ a)} {t₂ : (a : α) → finset (σ a)} (H1 : s₁ ⊆ s₂)\n    (H2 : ∀ (a : α), t₁ a ⊆ t₂ a) : finset.sigma s₁ t₁ ⊆ finset.sigma s₂ t₂ :=\n  sorry\n\ntheorem sigma_eq_bUnion {α : Type u_1} {σ : α → Type u_4} [DecidableEq (sigma fun (a : α) => σ a)]\n    (s : finset α) (t : (a : α) → finset (σ a)) :\n    finset.sigma s t = finset.bUnion s fun (a : α) => map (function.embedding.sigma_mk a) (t a) :=\n  sorry\n\n/-! ### disjoint -/\n\ntheorem disjoint_left {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    disjoint s t ↔ ∀ {a : α}, a ∈ s → ¬a ∈ t :=\n  sorry\n\ntheorem disjoint_val {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    disjoint s t ↔ multiset.disjoint (val s) (val t) :=\n  disjoint_left\n\ntheorem disjoint_iff_inter_eq_empty {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    disjoint s t ↔ s ∩ t = ∅ :=\n  disjoint_iff\n\nprotected instance decidable_disjoint {α : Type u_1} [DecidableEq α] (U : finset α) (V : finset α) :\n    Decidable (disjoint U V) :=\n  decidable_of_decidable_of_iff (finset.has_decidable_eq (U ⊓ V) ⊥) sorry\n\ntheorem disjoint_right {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    disjoint s t ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (disjoint s t ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s)) (propext disjoint.comm)))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (disjoint t s ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s)) (propext disjoint_left)))\n      (iff.refl (∀ {a : α}, a ∈ t → ¬a ∈ s)))\n\ntheorem disjoint_iff_ne {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    disjoint s t ↔ ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a ≠ b :=\n  sorry\n\ntheorem disjoint_of_subset_left {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    {u : finset α} (h : s ⊆ u) (d : disjoint u t) : disjoint s t :=\n  iff.mpr disjoint_left fun (x : α) (m₁ : x ∈ s) => iff.mp disjoint_left d x (h m₁)\n\ntheorem disjoint_of_subset_right {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    {u : finset α} (h : t ⊆ u) (d : disjoint s u) : disjoint s t :=\n  iff.mpr disjoint_right fun (x : α) (m₁ : x ∈ t) => iff.mp disjoint_right d x (h m₁)\n\n@[simp] theorem disjoint_empty_left {α : Type u_1} [DecidableEq α] (s : finset α) : disjoint ∅ s :=\n  disjoint_bot_left\n\n@[simp] theorem disjoint_empty_right {α : Type u_1} [DecidableEq α] (s : finset α) : disjoint s ∅ :=\n  disjoint_bot_right\n\n@[simp] theorem singleton_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {a : α} :\n    disjoint (singleton a) s ↔ ¬a ∈ s :=\n  sorry\n\n@[simp] theorem disjoint_singleton {α : Type u_1} [DecidableEq α] {s : finset α} {a : α} :\n    disjoint s (singleton a) ↔ ¬a ∈ s :=\n  iff.trans disjoint.comm singleton_disjoint\n\n@[simp] theorem disjoint_insert_left {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    {t : finset α} : disjoint (insert a s) t ↔ ¬a ∈ t ∧ disjoint s t :=\n  sorry\n\n@[simp] theorem disjoint_insert_right {α : Type u_1} [DecidableEq α] {a : α} {s : finset α}\n    {t : finset α} : disjoint s (insert a t) ↔ ¬a ∈ s ∧ disjoint s t :=\n  sorry\n\n@[simp] theorem disjoint_union_left {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    {u : finset α} : disjoint (s ∪ t) u ↔ disjoint s u ∧ disjoint t u :=\n  sorry\n\n@[simp] theorem disjoint_union_right {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    {u : finset α} : disjoint s (t ∪ u) ↔ disjoint s t ∧ disjoint s u :=\n  sorry\n\ntheorem sdiff_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    disjoint (t \\ s) s :=\n  iff.mpr disjoint_left fun (a : α) (ha : a ∈ t \\ s) => and.right (iff.mp mem_sdiff ha)\n\ntheorem disjoint_sdiff {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    disjoint s (t \\ s) :=\n  disjoint.symm sdiff_disjoint\n\ntheorem disjoint_sdiff_inter {α : Type u_1} [DecidableEq α] (s : finset α) (t : finset α) :\n    disjoint (s \\ t) (s ∩ t) :=\n  disjoint_of_subset_right (inter_subset_right s t) sdiff_disjoint\n\ntheorem sdiff_eq_self_iff_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} :\n    s \\ t = s ↔ disjoint s t :=\n  sorry\n\ntheorem sdiff_eq_self_of_disjoint {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    (h : disjoint s t) : s \\ t = s :=\n  iff.mpr sdiff_eq_self_iff_disjoint h\n\ntheorem disjoint_self_iff_empty {α : Type u_1} [DecidableEq α] (s : finset α) :\n    disjoint s s ↔ s = ∅ :=\n  disjoint_self\n\ntheorem disjoint_bUnion_left {α : Type u_1} [DecidableEq α] {ι : Type u_2} (s : finset ι)\n    (f : ι → finset α) (t : finset α) :\n    disjoint (finset.bUnion s f) t ↔ ∀ (i : ι), i ∈ s → disjoint (f i) t :=\n  sorry\n\ntheorem disjoint_bUnion_right {α : Type u_1} [DecidableEq α] {ι : Type u_2} (s : finset α)\n    (t : finset ι) (f : ι → finset α) :\n    disjoint s (finset.bUnion t f) ↔ ∀ (i : ι), i ∈ t → disjoint s (f i) :=\n  sorry\n\n@[simp] theorem card_disjoint_union {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    (h : disjoint s t) : card (s ∪ t) = card s + card t :=\n  sorry\n\ntheorem card_sdiff {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α} (h : s ⊆ t) :\n    card (t \\ s) = card t - card s :=\n  sorry\n\ntheorem disjoint_filter {α : Type u_1} [DecidableEq α] {s : finset α} {p : α → Prop} {q : α → Prop}\n    [decidable_pred p] [decidable_pred q] :\n    disjoint (filter p s) (filter q s) ↔ ∀ (x : α), x ∈ s → p x → ¬q x :=\n  sorry\n\ntheorem disjoint_filter_filter {α : Type u_1} [DecidableEq α] {s : finset α} {t : finset α}\n    {p : α → Prop} {q : α → Prop} [decidable_pred p] [decidable_pred q] :\n    disjoint s t → disjoint (filter p s) (filter q t) :=\n  disjoint.mono (filter_subset p s) (filter_subset q t)\n\ntheorem disjoint_iff_disjoint_coe {α : Type u_1} {a : finset α} {b : finset α} [DecidableEq α] :\n    disjoint a b ↔ disjoint ↑a ↑b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint a b ↔ disjoint ↑a ↑b)) (propext disjoint_left)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl ((∀ {a_1 : α}, a_1 ∈ a → ¬a_1 ∈ b) ↔ disjoint ↑a ↑b))\n          (propext set.disjoint_left)))\n      (iff.refl (∀ {a_1 : α}, a_1 ∈ a → ¬a_1 ∈ b)))\n\ntheorem filter_card_add_filter_neg_card_eq_card {α : Type u_1} {s : finset α} (p : α → Prop)\n    [decidable_pred p] : card (filter p s) + card (filter (Not ∘ p) s) = card s :=\n  sorry\n\n/-- Given a finite set `s`, the diagonal, `s.diag` is the set of pairs of the form `(a, a)` for\n`a ∈ s`. -/\ndef diag {α : Type u_1} (s : finset α) [DecidableEq α] : finset (α × α) :=\n  filter (fun (a : α × α) => prod.fst a = prod.snd a) (finset.product s s)\n\n/-- Given a finite set `s`, the off-diagonal, `s.off_diag` is the set of pairs `(a, b)` with `a ≠ b`\nfor `a, b ∈ s`. -/\ndef off_diag {α : Type u_1} (s : finset α) [DecidableEq α] : finset (α × α) :=\n  filter (fun (a : α × α) => prod.fst a ≠ prod.snd a) (finset.product s s)\n\n@[simp] theorem mem_diag {α : Type u_1} (s : finset α) [DecidableEq α] (x : α × α) :\n    x ∈ diag s ↔ prod.fst x ∈ s ∧ prod.fst x = prod.snd x :=\n  sorry\n\n@[simp] theorem mem_off_diag {α : Type u_1} (s : finset α) [DecidableEq α] (x : α × α) :\n    x ∈ off_diag s ↔ prod.fst x ∈ s ∧ prod.snd x ∈ s ∧ prod.fst x ≠ prod.snd x :=\n  sorry\n\n@[simp] theorem diag_card {α : Type u_1} (s : finset α) [DecidableEq α] : card (diag s) = card s :=\n  sorry\n\n@[simp] theorem off_diag_card {α : Type u_1} (s : finset α) [DecidableEq α] :\n    card (off_diag s) = card s * card s - card s :=\n  sorry\n\n/--\nGiven a set A and a set B inside it, we can shrink A to any appropriate size, and keep B\ninside it.\n-/\ntheorem exists_intermediate_set {α : Type u_1} {A : finset α} {B : finset α} (i : ℕ)\n    (h₁ : i + card B ≤ card A) (h₂ : B ⊆ A) :\n    ∃ (C : finset α), B ⊆ C ∧ C ⊆ A ∧ card C = i + card B :=\n  sorry\n\n/-- We can shrink A to any smaller size. -/\ntheorem exists_smaller_set {α : Type u_1} (A : finset α) (i : ℕ) (h₁ : i ≤ card A) :\n    ∃ (B : finset α), B ⊆ A ∧ card B = i :=\n  sorry\n\n/-- `finset.fin_range k` is the finset `{0, 1, ..., k-1}`, as a `finset (fin k)`. -/\ndef fin_range (k : ℕ) : finset (fin k) := mk (↑(list.fin_range k)) (list.nodup_fin_range k)\n\n@[simp] theorem fin_range_card {k : ℕ} : card (fin_range k) = k := sorry\n\n@[simp] theorem mem_fin_range {k : ℕ} (m : fin k) : m ∈ fin_range k := list.mem_fin_range m\n\n@[simp] theorem coe_fin_range (k : ℕ) : ↑(fin_range k) = set.univ :=\n  set.eq_univ_of_forall mem_fin_range\n\n/-- Given a finset `s` of `ℕ` contained in `{0,..., n-1}`, the corresponding finset in `fin n`\nis `s.attach_fin h` where `h` is a proof that all elements of `s` are less than `n`. -/\ndef attach_fin (s : finset ℕ) {n : ℕ} (h : ∀ (m : ℕ), m ∈ s → m < n) : finset (fin n) :=\n  mk (multiset.pmap (fun (a : ℕ) (ha : a < n) => { val := a, property := ha }) (val s) h) sorry\n\n@[simp] theorem mem_attach_fin {n : ℕ} {s : finset ℕ} (h : ∀ (m : ℕ), m ∈ s → m < n) {a : fin n} :\n    a ∈ attach_fin s h ↔ ↑a ∈ s :=\n  sorry\n\n@[simp] theorem card_attach_fin {n : ℕ} (s : finset ℕ) (h : ∀ (m : ℕ), m ∈ s → m < n) :\n    card (attach_fin s h) = card s :=\n  multiset.card_pmap (fun (a : ℕ) (ha : a < n) => { val := a, property := ha }) (val s) h\n\n/-! ### choose -/\n\n/-- Given a finset `l` and a predicate `p`, associate to a proof that there is a unique element of\n`l` satisfying `p` this unique element, as an element of the corresponding subtype. -/\ndef choose_x {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α)\n    (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : Subtype fun (a : α) => a ∈ l ∧ p a :=\n  multiset.choose_x p (val l) hp\n\n/-- Given a finset `l` and a predicate `p`, associate to a proof that there is a unique element of\n`l` satisfying `p` this unique element, as an element of the ambient type. -/\ndef choose {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α)\n    (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : α :=\n  ↑(choose_x p l hp)\n\ntheorem choose_spec {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α)\n    (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : choose p l hp ∈ l ∧ p (choose p l hp) :=\n  subtype.property (choose_x p l hp)\n\ntheorem choose_mem {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α)\n    (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : choose p l hp ∈ l :=\n  and.left (choose_spec p l hp)\n\ntheorem choose_property {α : Type u_1} (p : α → Prop) [decidable_pred p] (l : finset α)\n    (hp : exists_unique fun (a : α) => a ∈ l ∧ p a) : p (choose p l hp) :=\n  and.right (choose_spec p l hp)\n\ntheorem lt_wf {α : Type u_1} : well_founded Less :=\n  (fun (H : subrelation Less (inv_image Less card)) =>\n      subrelation.wf H (inv_image.wf card nat.lt_wf))\n    fun (x y : finset α) (hxy : x < y) => card_lt_card hxy\n\nend finset\n\n\nnamespace equiv\n\n\n/-- Given an equivalence `α` to `β`, produce an equivalence between `finset α` and `finset β`. -/\nprotected def finset_congr {α : Type u_1} {β : Type u_2} (e : α ≃ β) : finset α ≃ finset β :=\n  mk (fun (s : finset α) => finset.map (equiv.to_embedding e) s)\n    (fun (s : finset β) => finset.map (equiv.to_embedding (equiv.symm e)) s) sorry sorry\n\n@[simp] theorem finset_congr_apply {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : finset α) :\n    coe_fn (equiv.finset_congr e) s = finset.map (equiv.to_embedding e) s :=\n  rfl\n\n@[simp] theorem finset_congr_symm_apply {α : Type u_1} {β : Type u_2} (e : α ≃ β) (s : finset β) :\n    coe_fn (equiv.symm (equiv.finset_congr e)) s =\n        finset.map (equiv.to_embedding (equiv.symm e)) s :=\n  rfl\n\nend equiv\n\n\nnamespace list\n\n\ntheorem to_finset_card_of_nodup {α : Type u_1} [DecidableEq α] {l : List α} (h : nodup l) :\n    finset.card (to_finset l) = length l :=\n  congr_arg (⇑multiset.card) (iff.mpr multiset.erase_dup_eq_self h)\n\nend list\n\n\nnamespace multiset\n\n\ntheorem to_finset_card_of_nodup {α : Type u_1} [DecidableEq α] {l : multiset α} (h : nodup l) :\n    finset.card (to_finset l) = coe_fn card l :=\n  congr_arg (⇑card) (iff.mpr erase_dup_eq_self h)\n\ntheorem disjoint_to_finset {α : Type u_1} [DecidableEq α] (m1 : multiset α) (m2 : multiset α) :\n    disjoint (to_finset m1) (to_finset m2) ↔ disjoint m1 m2 :=\n  sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/finset/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.7341195269001831, "lm_q1q2_score": 0.45154800549350294}}
{"text": "/-\nCopyright (c) 2020 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.geometry.manifold.basic_smooth_bundle\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 u_6 u_7 u_8 u_9 u_10 \n\nnamespace Mathlib\n\n/-!\n# The derivative of functions between smooth manifolds\n\nLet `M` and `M'` be two smooth manifolds with corners over a field `𝕜` (with respective models with\ncorners `I` on `(E, H)` and `I'` on `(E', H')`), and let `f : M → M'`. We define the\nderivative of the function at a point, within a set or along the whole space, mimicking the API\nfor (Fréchet) derivatives. It is denoted by `mfderiv I I' f x`, where \"m\" stands for \"manifold\" and\n\"f\" for \"Fréchet\" (as in the usual derivative `fderiv 𝕜 f x`).\n\n## Main definitions\n\n* `unique_mdiff_on I s` : predicate saying that, at each point of the set `s`, a function can have\n  at most one derivative. This technical condition is important when we define\n  `mfderiv_within` below, as otherwise there is an arbitrary choice in the derivative,\n  and many properties will fail (for instance the chain rule). This is analogous to\n  `unique_diff_on 𝕜 s` in a vector space.\n\nLet `f` be a map between smooth manifolds. The following definitions follow the `fderiv` API.\n\n* `mfderiv I I' f x` : the derivative of `f` at `x`, as a continuous linear map from the tangent\n  space at `x` to the tangent space at `f x`. If the map is not differentiable, this is `0`.\n* `mfderiv_within I I' f s x` : the derivative of `f` at `x` within `s`, as a continuous linear map\n  from the tangent space at `x` to the tangent space at `f x`. If the map is not differentiable\n  within `s`, this is `0`.\n* `mdifferentiable_at I I' f x` : Prop expressing whether `f` is differentiable at `x`.\n* `mdifferentiable_within_at 𝕜 f s x` : Prop expressing whether `f` is differentiable within `s`\n  at `x`.\n* `has_mfderiv_at I I' f s x f'` : Prop expressing whether `f` has `f'` as a derivative at `x`.\n* `has_mfderiv_within_at I I' f s x f'` : Prop expressing whether `f` has `f'` as a derivative\n  within `s` at `x`.\n* `mdifferentiable_on I I' f s` : Prop expressing that `f` is differentiable on the set `s`.\n* `mdifferentiable I I' f` : Prop expressing that `f` is differentiable everywhere.\n* `tangent_map I I' f` : the derivative of `f`, as a map from the tangent bundle of `M` to the\n  tangent bundle of `M'`.\n\nWe also establish results on the differential of the identity, constant functions, charts, extended\ncharts. For functions between vector spaces, we show that the usual notions and the manifold notions\ncoincide.\n\n## Implementation notes\n\nThe tangent bundle is constructed using the machinery of topological fiber bundles, for which one\ncan define bundled morphisms and construct canonically maps from the total space of one bundle to\nthe total space of another one. One could use this mechanism to construct directly the derivative\nof a smooth map. However, we want to define the derivative of any map (and let it be zero if the map\nis not differentiable) to avoid proof arguments everywhere. This means we have to go back to the\ndetails of the definition of the total space of a fiber bundle constructed from core, to cook up a\nsuitable definition of the derivative. It is the following: at each point, we have a preferred chart\n(used to identify the fiber above the point with the model vector space in fiber bundles). Then one\nshould read the function using these preferred charts at `x` and `f x`, and take the derivative\nof `f` in these charts.\n\nDue to the fact that we are working in a model with corners, with an additional embedding `I` of the\nmodel space `H` in the model vector space `E`, the charts taking values in `E` are not the original\ncharts of the manifold, but those ones composed with `I`, called extended charts. We define\n`written_in_ext_chart I I' x f` for the function `f` written in the preferred extended charts.  Then\nthe manifold derivative of `f`, at `x`, is just the usual derivative of `written_in_ext_chart I I' x\nf`, at the point `(ext_chart_at I x) x`.\n\nThere is a subtelty with respect to continuity: if the function is not continuous, then the image\nof a small open set around `x` will not be contained in the source of the preferred chart around\n`f x`, which means that when reading `f` in the chart one is losing some information. To avoid this,\nwe include continuity in the definition of differentiablity (which is reasonable since with any\ndefinition, differentiability implies continuity).\n\n*Warning*: the derivative (even within a subset) is a linear map on the whole tangent space. Suppose\nthat one is given a smooth submanifold `N`, and a function which is smooth on `N` (i.e., its\nrestriction to the subtype  `N` is smooth). Then, in the whole manifold `M`, the property\n`mdifferentiable_on I I' f N` holds. However, `mfderiv_within I I' f N` is not uniquely defined\n(what values would one choose for vectors that are transverse to `N`?), which can create issues down\nthe road. The problem here is that knowing the value of `f` along `N` does not determine the\ndifferential of `f` in all directions. This is in contrast to the case where `N` would be an open\nsubset, or a submanifold with boundary of maximal dimension, where this issue does not appear.\nThe predicate `unique_mdiff_on I N` indicates that the derivative along `N` is unique if it exists,\nand is an assumption in most statements requiring a form of uniqueness.\n\nOn a vector space, the manifold derivative and the usual derivative are equal. This means in\nparticular that they live on the same space, i.e., the tangent space is defeq to the original vector\nspace. To get this property is a motivation for our definition of the tangent space as a single\ncopy of the vector space, instead of more usual definitions such as the space of derivations, or\nthe space of equivalence classes of smooth curves in the manifold.\n\n## Tags\nDerivative, manifold\n-/\n\n/-!\n### Derivative of maps between manifolds\n\nThe derivative of a smooth map `f` between smooth manifold `M` and `M'` at `x` is a bounded linear\nmap from the tangent space to `M` at `x`, to the tangent space to `M'` at `f x`. Since we defined\nthe tangent space using one specific chart, the formula for the derivative is written in terms of\nthis specific chart.\n\nWe use the names `mdifferentiable` and `mfderiv`, where the prefix letter `m` means \"manifold\".\n-/\n\n/-- Predicate ensuring that, at a point and within a set, a function can have at most one\nderivative. This is expressed using the preferred chart at the considered point. -/\ndef unique_mdiff_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] (s : set M) (x : M) :=\n  unique_diff_within_at 𝕜 (⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s ∩ set.range ⇑I) (coe_fn (ext_chart_at I x) x)\n\n/-- Predicate ensuring that, at all points of a set, a function can have at most one derivative. -/\ndef unique_mdiff_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] (s : set M) :=\n  ∀ (x : M), x ∈ s → unique_mdiff_within_at I s x\n\n/-- Conjugating a function to write it in the preferred charts around `x`. The manifold derivative\nof `f` will just be the derivative of this conjugated function. -/\n@[simp] def written_in_ext_chart_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (x : M) (f : M → M') : E → E' :=\n  ⇑(ext_chart_at I' (f x)) ∘ f ∘ ⇑(local_equiv.symm (ext_chart_at I x))\n\n/-- `mdifferentiable_within_at I I' f s x` indicates that the function `f` between manifolds\nhas a derivative at the point `x` within the set `s`.\nThis is a generalization of `differentiable_within_at` to manifolds.\n\nWe require continuity in the definition, as otherwise points close to `x` in `s` could be sent by\n`f` outside of the chart domain around `f x`. Then the chart could do anything to the image points,\nand in particular by coincidence `written_in_ext_chart_at I I' x f` could be differentiable, while\nthis would not mean anything relevant. -/\ndef mdifferentiable_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M → M') (s : set M) (x : M) :=\n  continuous_within_at f s x ∧\n    differentiable_within_at 𝕜 (written_in_ext_chart_at I I' x f)\n      (⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s ∩ set.range ⇑I) (coe_fn (ext_chart_at I x) x)\n\n/-- `mdifferentiable_at I I' f x` indicates that the function `f` between manifolds\nhas a derivative at the point `x`.\nThis is a generalization of `differentiable_at` to manifolds.\n\nWe require continuity in the definition, as otherwise points close to `x` could be sent by\n`f` outside of the chart domain around `f x`. Then the chart could do anything to the image points,\nand in particular by coincidence `written_in_ext_chart_at I I' x f` could be differentiable, while\nthis would not mean anything relevant. -/\ndef mdifferentiable_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M → M') (x : M) :=\n  continuous_at f x ∧\n    differentiable_within_at 𝕜 (written_in_ext_chart_at I I' x f) (set.range ⇑I) (coe_fn (ext_chart_at I x) x)\n\n/-- `mdifferentiable_on I I' f s` indicates that the function `f` between manifolds\nhas a derivative within `s` at all points of `s`.\nThis is a generalization of `differentiable_on` to manifolds. -/\ndef mdifferentiable_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M → M') (s : set M) :=\n  ∀ (x : M), x ∈ s → mdifferentiable_within_at I I' f s x\n\n/-- `mdifferentiable I I' f` indicates that the function `f` between manifolds\nhas a derivative everywhere.\nThis is a generalization of `differentiable` to manifolds. -/\ndef mdifferentiable {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M → M') :=\n  ∀ (x : M), mdifferentiable_at I I' f x\n\n/-- Prop registering if a local homeomorphism is a local diffeomorphism on its source -/\ndef local_homeomorph.mdifferentiable {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : local_homeomorph M M') :=\n  mdifferentiable_on I I' (⇑f) (local_equiv.source (local_homeomorph.to_local_equiv f)) ∧\n    mdifferentiable_on I' I (⇑(local_homeomorph.symm f)) (local_equiv.target (local_homeomorph.to_local_equiv f))\n\n/-- `has_mfderiv_within_at I I' f s x f'` indicates that the function `f` between manifolds\nhas, at the point `x` and within the set `s`, the derivative `f'`. Here, `f'` is a continuous linear\nmap from the tangent space at `x` to the tangent space at `f x`.\n\nThis is a generalization of `has_fderiv_within_at` to manifolds (as indicated by the prefix `m`).\nThe order of arguments is changed as the type of the derivative `f'` depends on the choice of `x`.\n\nWe require continuity in the definition, as otherwise points close to `x` in `s` could be sent by\n`f` outside of the chart domain around `f x`. Then the chart could do anything to the image points,\nand in particular by coincidence `written_in_ext_chart_at I I' x f` could be differentiable, while\nthis would not mean anything relevant. -/\ndef has_mfderiv_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] (f : M → M') (s : set M) (x : M) (f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))) :=\n  continuous_within_at f s x ∧\n    has_fderiv_within_at (written_in_ext_chart_at I I' x f) f'\n      (⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s ∩ set.range ⇑I) (coe_fn (ext_chart_at I x) x)\n\n/-- `has_mfderiv_at I I' f x f'` indicates that the function `f` between manifolds\nhas, at the point `x`, the derivative `f'`. Here, `f'` is a continuous linear\nmap from the tangent space at `x` to the tangent space at `f x`.\n\nWe require continuity in the definition, as otherwise points close to `x` `s` could be sent by\n`f` outside of the chart domain around `f x`. Then the chart could do anything to the image points,\nand in particular by coincidence `written_in_ext_chart_at I I' x f` could be differentiable, while\nthis would not mean anything relevant. -/\ndef has_mfderiv_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] (f : M → M') (x : M) (f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))) :=\n  continuous_at f x ∧\n    has_fderiv_within_at (written_in_ext_chart_at I I' x f) f' (set.range ⇑I) (coe_fn (ext_chart_at I x) x)\n\n/-- Let `f` be a function between two smooth manifolds. Then `mfderiv_within I I' f s x` is the\nderivative of `f` at `x` within `s`, as a continuous linear map from the tangent space at `x` to the\ntangent space at `f x`. -/\ndef mfderiv_within {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] (f : M → M') (s : set M) (x : M) : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x)) :=\n  dite (mdifferentiable_within_at I I' f s x)\n    (fun (h : mdifferentiable_within_at I I' f s x) =>\n      fderiv_within 𝕜 (written_in_ext_chart_at I I' x f) (⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s ∩ set.range ⇑I)\n        (coe_fn (ext_chart_at I x) x))\n    fun (h : ¬mdifferentiable_within_at I I' f s x) => 0\n\n/-- Let `f` be a function between two smooth manifolds. Then `mfderiv I I' f x` is the derivative of\n`f` at `x`, as a continuous linear map from the tangent space at `x` to the tangent space at\n`f x`. -/\ndef mfderiv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] (f : M → M') (x : M) : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x)) :=\n  dite (mdifferentiable_at I I' f x)\n    (fun (h : mdifferentiable_at I I' f x) =>\n      fderiv_within 𝕜 (written_in_ext_chart_at I I' x f) (set.range ⇑I) (coe_fn (ext_chart_at I x) x))\n    fun (h : ¬mdifferentiable_at I I' f x) => 0\n\n/-- The derivative within a set, as a map between the tangent bundles -/\ndef tangent_map_within {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] (f : M → M') (s : set M) : tangent_bundle I M → tangent_bundle I' M' :=\n  fun (p : tangent_bundle I M) =>\n    sigma.mk (f (sigma.fst p)) (coe_fn (mfderiv_within I I' f s (sigma.fst p)) (sigma.snd p))\n\n/-- The derivative, as a map between the tangent bundles -/\ndef tangent_map {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] (f : M → M') : tangent_bundle I M → tangent_bundle I' M' :=\n  fun (p : tangent_bundle I M) => sigma.mk (f (sigma.fst p)) (coe_fn (mfderiv I I' f (sigma.fst p)) (sigma.snd p))\n\n/-! ### Unique differentiability sets in manifolds -/\n\ntheorem unique_mdiff_within_at_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {x : M} : unique_mdiff_within_at I set.univ x := sorry\n\ntheorem unique_mdiff_within_at_iff {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {s : set M} {x : M} : unique_mdiff_within_at I s x ↔\n  unique_diff_within_at 𝕜 (⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s ∩ local_equiv.target (ext_chart_at I x))\n    (coe_fn (ext_chart_at I x) x) := sorry\n\ntheorem unique_mdiff_within_at.mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {x : M} {s : set M} {t : set M} (h : unique_mdiff_within_at I s x) (st : s ⊆ t) : unique_mdiff_within_at I t x :=\n  unique_diff_within_at.mono h (set.inter_subset_inter (set.preimage_mono st) (set.subset.refl (set.range ⇑I)))\n\ntheorem unique_mdiff_within_at.inter' {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {x : M} {s : set M} {t : set M} (hs : unique_mdiff_within_at I s x) (ht : t ∈ nhds_within x s) : unique_mdiff_within_at I (s ∩ t) x := sorry\n\ntheorem unique_mdiff_within_at.inter {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {x : M} {s : set M} {t : set M} (hs : unique_mdiff_within_at I s x) (ht : t ∈ nhds x) : unique_mdiff_within_at I (s ∩ t) x := sorry\n\ntheorem is_open.unique_mdiff_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {x : M} {s : set M} (xs : x ∈ s) (hs : is_open s) : unique_mdiff_within_at I s x :=\n  eq.mp (Eq._oldrec (Eq.refl (unique_mdiff_within_at I (set.univ ∩ s) x)) (set.univ_inter s))\n    (unique_mdiff_within_at.inter (unique_mdiff_within_at_univ I) (mem_nhds_sets hs xs))\n\ntheorem unique_mdiff_on.inter {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {s : set M} {t : set M} (hs : unique_mdiff_on I s) (ht : is_open t) : unique_mdiff_on I (s ∩ t) :=\n  fun (x : M) (hx : x ∈ s ∩ t) => unique_mdiff_within_at.inter (hs x (and.left hx)) (mem_nhds_sets ht (and.right hx))\n\ntheorem is_open.unique_mdiff_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {s : set M} (hs : is_open s) : unique_mdiff_on I s :=\n  fun (x : M) (hx : x ∈ s) => is_open.unique_mdiff_within_at hx hs\n\ntheorem unique_mdiff_on_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] : unique_mdiff_on I set.univ :=\n  is_open.unique_mdiff_on is_open_univ\n\n/- We name the typeclass variables related to `smooth_manifold_with_corners` structure as they are\nnecessary in lemmas mentioning the derivative, but not in lemmas about differentiability, so we\nwant to include them or omit them when necessary. -/\n\n/-- `unique_mdiff_within_at` achieves its goal: it implies the uniqueness of the derivative. -/\ntheorem unique_mdiff_within_at.eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} {f₁' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (U : unique_mdiff_within_at I s x) (h : has_mfderiv_within_at I I' f s x f') (h₁ : has_mfderiv_within_at I I' f s x f₁') : f' = f₁' :=\n  unique_diff_within_at.eq U (and.right h) (and.right h₁)\n\ntheorem unique_mdiff_on.eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} {f₁' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (U : unique_mdiff_on I s) (hx : x ∈ s) (h : has_mfderiv_within_at I I' f s x f') (h₁ : has_mfderiv_within_at I I' f s x f₁') : f' = f₁' :=\n  unique_mdiff_within_at.eq (U x hx) h h₁\n\n/-!\n### General lemmas on derivatives of functions between manifolds\n\nWe mimick the API for functions between vector spaces\n-/\n\ntheorem mdifferentiable_within_at_iff {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} {x : M} : mdifferentiable_within_at I I' f s x ↔\n  continuous_within_at f s x ∧\n    differentiable_within_at 𝕜 (written_in_ext_chart_at I I' x f)\n      (local_equiv.target (ext_chart_at I x) ∩ ⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s)\n      (coe_fn (ext_chart_at I x) x) := sorry\n\ntheorem mfderiv_within_zero_of_not_mdifferentiable_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : ¬mdifferentiable_within_at I I' f s x) : mfderiv_within I I' f s x = 0 := sorry\n\ntheorem mfderiv_zero_of_not_mdifferentiable_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : ¬mdifferentiable_at I I' f x) : mfderiv I I' f x = 0 := sorry\n\ntheorem has_mfderiv_within_at.mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f t x f') (hst : s ⊆ t) : has_mfderiv_within_at I I' f s x f' := sorry\n\ntheorem has_mfderiv_at.has_mfderiv_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_at I I' f x f') : has_mfderiv_within_at I I' f s x f' := sorry\n\ntheorem has_mfderiv_within_at.mdifferentiable_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') : mdifferentiable_within_at I I' f s x :=\n  { left := and.left h, right := Exists.intro f' (and.right h) }\n\ntheorem has_mfderiv_at.mdifferentiable_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_at I I' f x f') : mdifferentiable_at I I' f x :=\n  { left := and.left h, right := Exists.intro f' (and.right h) }\n\n@[simp] theorem has_mfderiv_within_at_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} : has_mfderiv_within_at I I' f set.univ x f' ↔ has_mfderiv_at I I' f x f' := sorry\n\ntheorem has_mfderiv_at_unique {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f₀' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} {f₁' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h₀ : has_mfderiv_at I I' f x f₀') (h₁ : has_mfderiv_at I I' f x f₁') : f₀' = f₁' :=\n  unique_mdiff_within_at.eq (unique_mdiff_within_at_univ I)\n    (eq.mp (Eq._oldrec (Eq.refl (has_mfderiv_at I I' f x f₀')) (Eq.symm (propext has_mfderiv_within_at_univ))) h₀)\n    (eq.mp (Eq._oldrec (Eq.refl (has_mfderiv_at I I' f x f₁')) (Eq.symm (propext has_mfderiv_within_at_univ))) h₁)\n\ntheorem has_mfderiv_within_at_inter' {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : t ∈ nhds_within x s) : has_mfderiv_within_at I I' f (s ∩ t) x f' ↔ has_mfderiv_within_at I I' f s x f' := sorry\n\ntheorem has_mfderiv_within_at_inter {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : t ∈ nhds x) : has_mfderiv_within_at I I' f (s ∩ t) x f' ↔ has_mfderiv_within_at I I' f s x f' := sorry\n\ntheorem has_mfderiv_within_at.union {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (hs : has_mfderiv_within_at I I' f s x f') (ht : has_mfderiv_within_at I I' f t x f') : has_mfderiv_within_at I I' f (s ∪ t) x f' := sorry\n\ntheorem has_mfderiv_within_at.nhds_within {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (ht : s ∈ nhds_within x t) : has_mfderiv_within_at I I' f t x f' :=\n  iff.mp (has_mfderiv_within_at_inter' ht) (has_mfderiv_within_at.mono h (set.inter_subset_right t s))\n\ntheorem has_mfderiv_within_at.has_mfderiv_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (hs : s ∈ nhds x) : has_mfderiv_at I I' f x f' := sorry\n\ntheorem mdifferentiable_within_at.has_mfderiv_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_within_at I I' f s x) : has_mfderiv_within_at I I' f s x (mfderiv_within I I' f s x) := sorry\n\ntheorem mdifferentiable_within_at.mfderiv_within {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_within_at I I' f s x) : mfderiv_within I I' f s x =\n  fderiv_within 𝕜 (written_in_ext_chart_at I I' x f) (⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s ∩ set.range ⇑I)\n    (coe_fn (ext_chart_at I x) x) := sorry\n\ntheorem mdifferentiable_at.has_mfderiv_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_at I I' f x) : has_mfderiv_at I I' f x (mfderiv I I' f x) := sorry\n\ntheorem mdifferentiable_at.mfderiv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_at I I' f x) : mfderiv I I' f x = fderiv_within 𝕜 (written_in_ext_chart_at I I' x f) (set.range ⇑I) (coe_fn (ext_chart_at I x) x) := sorry\n\ntheorem has_mfderiv_at.mfderiv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_at I I' f x f') : mfderiv I I' f x = f' := sorry\n\ntheorem has_mfderiv_within_at.mfderiv_within {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (hxs : unique_mdiff_within_at I s x) : mfderiv_within I I' f s x = f' := sorry\n\ntheorem mdifferentiable.mfderiv_within {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_at I I' f x) (hxs : unique_mdiff_within_at I s x) : mfderiv_within I I' f s x = mfderiv I I' f x :=\n  has_mfderiv_within_at.mfderiv_within (has_mfderiv_at.has_mfderiv_within_at (mdifferentiable_at.has_mfderiv_at h)) hxs\n\ntheorem mfderiv_within_subset {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (st : s ⊆ t) (hs : unique_mdiff_within_at I s x) (h : mdifferentiable_within_at I I' f t x) : mfderiv_within I I' f s x = mfderiv_within I I' f t x :=\n  has_mfderiv_within_at.mfderiv_within (has_mfderiv_within_at.mono (mdifferentiable_within_at.has_mfderiv_within_at h) st)\n    hs\n\ntheorem mdifferentiable_within_at.mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} (hst : s ⊆ t) (h : mdifferentiable_within_at I I' f t x) : mdifferentiable_within_at I I' f s x := sorry\n\ntheorem mdifferentiable_within_at_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} : mdifferentiable_within_at I I' f set.univ x ↔ mdifferentiable_at I I' f x := sorry\n\ntheorem mdifferentiable_within_at_inter {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} (ht : t ∈ nhds x) : mdifferentiable_within_at I I' f (s ∩ t) x ↔ mdifferentiable_within_at I I' f s x := sorry\n\ntheorem mdifferentiable_within_at_inter' {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} (ht : t ∈ nhds_within x s) : mdifferentiable_within_at I I' f (s ∩ t) x ↔ mdifferentiable_within_at I I' f s x := sorry\n\ntheorem mdifferentiable_at.mdifferentiable_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} (h : mdifferentiable_at I I' f x) : mdifferentiable_within_at I I' f s x :=\n  mdifferentiable_within_at.mono (set.subset_univ s) (iff.mpr mdifferentiable_within_at_univ h)\n\ntheorem mdifferentiable_within_at.mdifferentiable_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} (h : mdifferentiable_within_at I I' f s x) (hs : s ∈ nhds x) : mdifferentiable_at I I' f x := sorry\n\ntheorem mdifferentiable_on.mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} {t : set M} (h : mdifferentiable_on I I' f t) (st : s ⊆ t) : mdifferentiable_on I I' f s :=\n  fun (x : M) (hx : x ∈ s) => mdifferentiable_within_at.mono st (h x (st hx))\n\ntheorem mdifferentiable_on_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} : mdifferentiable_on I I' f set.univ ↔ mdifferentiable I I' f := sorry\n\ntheorem mdifferentiable.mdifferentiable_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} (h : mdifferentiable I I' f) : mdifferentiable_on I I' f s :=\n  mdifferentiable_on.mono (iff.mpr mdifferentiable_on_univ h) (set.subset_univ s)\n\ntheorem mdifferentiable_on_of_locally_mdifferentiable_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} (h : ∀ (x : M), x ∈ s → ∃ (u : set M), is_open u ∧ x ∈ u ∧ mdifferentiable_on I I' f (s ∩ u)) : mdifferentiable_on I I' f s := sorry\n\n@[simp] theorem mfderiv_within_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] : mfderiv_within I I' f set.univ = mfderiv I I' f := sorry\n\ntheorem mfderiv_within_inter {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (ht : t ∈ nhds x) (hs : unique_mdiff_within_at I s x) : mfderiv_within I I' f (s ∩ t) x = mfderiv_within I I' f s x := sorry\n\n/-! ### Deriving continuity from differentiability on manifolds -/\n\ntheorem has_mfderiv_within_at.continuous_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} (h : mdifferentiable_within_at I I' f s x) : continuous_within_at f s x :=\n  and.left h\n\ntheorem has_mfderiv_at.continuous_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_at I I' f x f') : continuous_at f x :=\n  and.left h\n\ntheorem mdifferentiable_within_at.continuous_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} {s : set M} (h : mdifferentiable_within_at I I' f s x) : continuous_within_at f s x :=\n  and.left h\n\ntheorem mdifferentiable_at.continuous_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {x : M} (h : mdifferentiable_at I I' f x) : continuous_at f x :=\n  and.left h\n\ntheorem mdifferentiable_on.continuous_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} (h : mdifferentiable_on I I' f s) : continuous_on f s :=\n  fun (x : M) (hx : x ∈ s) => mdifferentiable_within_at.continuous_within_at (h x hx)\n\ntheorem mdifferentiable.continuous {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} (h : mdifferentiable I I' f) : continuous f :=\n  iff.mpr continuous_iff_continuous_at fun (x : M) => mdifferentiable_at.continuous_at (h x)\n\ntheorem tangent_map_within_subset {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {p : tangent_bundle I M} (st : s ⊆ t) (hs : unique_mdiff_within_at I s (sigma.fst p)) (h : mdifferentiable_within_at I I' f t (sigma.fst p)) : tangent_map_within I I' f s p = tangent_map_within I I' f t p := sorry\n\ntheorem tangent_map_within_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] : tangent_map_within I I' f set.univ = tangent_map I I' f := sorry\n\ntheorem tangent_map_within_eq_tangent_map {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {p : tangent_bundle I M} (hs : unique_mdiff_within_at I s (sigma.fst p)) (h : mdifferentiable_at I I' f (sigma.fst p)) : tangent_map_within I I' f s p = tangent_map I I' f p := sorry\n\n@[simp] theorem tangent_map_within_tangent_bundle_proj {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {p : tangent_bundle I M} : tangent_bundle.proj I' M' (tangent_map_within I I' f s p) = f (tangent_bundle.proj I M p) :=\n  rfl\n\n@[simp] theorem tangent_map_within_proj {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {p : tangent_bundle I M} : sigma.fst (tangent_map_within I I' f s p) = f (sigma.fst p) :=\n  rfl\n\n@[simp] theorem tangent_map_tangent_bundle_proj {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {p : tangent_bundle I M} : tangent_bundle.proj I' M' (tangent_map I I' f p) = f (tangent_bundle.proj I M p) :=\n  rfl\n\n@[simp] theorem tangent_map_proj {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {p : tangent_bundle I M} : sigma.fst (tangent_map I I' f p) = f (sigma.fst p) :=\n  rfl\n\n/-! ### Congruence lemmas for derivatives on manifolds -/\n\ntheorem has_mfderiv_within_at.congr_of_eventually_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (h₁ : filter.eventually_eq (nhds_within x s) f₁ f) (hx : f₁ x = f x) : has_mfderiv_within_at I I' f₁ s x f' := sorry\n\ntheorem has_mfderiv_within_at.congr_mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (ht : ∀ (x : M), x ∈ t → f₁ x = f x) (hx : f₁ x = f x) (h₁ : t ⊆ s) : has_mfderiv_within_at I I' f₁ t x f' :=\n  has_mfderiv_within_at.congr_of_eventually_eq (has_mfderiv_within_at.mono h h₁) (filter.mem_inf_sets_of_right ht) hx\n\ntheorem has_mfderiv_at.congr_of_eventually_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_at I I' f x f') (h₁ : filter.eventually_eq (nhds x) f₁ f) : has_mfderiv_at I I' f₁ x f' := sorry\n\ntheorem mdifferentiable_within_at.congr_of_eventually_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_within_at I I' f s x) (h₁ : filter.eventually_eq (nhds_within x s) f₁ f) (hx : f₁ x = f x) : mdifferentiable_within_at I I' f₁ s x :=\n  has_mfderiv_within_at.mdifferentiable_within_at\n    (has_mfderiv_within_at.congr_of_eventually_eq (mdifferentiable_within_at.has_mfderiv_within_at h) h₁ hx)\n\ntheorem filter.eventually_eq.mdifferentiable_within_at_iff {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h₁ : filter.eventually_eq (nhds_within x s) f₁ f) (hx : f₁ x = f x) : mdifferentiable_within_at I I' f s x ↔ mdifferentiable_within_at I I' f₁ s x := sorry\n\ntheorem mdifferentiable_within_at.congr_mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_within_at I I' f s x) (ht : ∀ (x : M), x ∈ t → f₁ x = f x) (hx : f₁ x = f x) (h₁ : t ⊆ s) : mdifferentiable_within_at I I' f₁ t x :=\n  has_mfderiv_within_at.mdifferentiable_within_at\n    (has_mfderiv_within_at.congr_mono (mdifferentiable_within_at.has_mfderiv_within_at h) ht hx h₁)\n\ntheorem mdifferentiable_within_at.congr {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_within_at I I' f s x) (ht : ∀ (x : M), x ∈ s → f₁ x = f x) (hx : f₁ x = f x) : mdifferentiable_within_at I I' f₁ s x :=\n  has_mfderiv_within_at.mdifferentiable_within_at\n    (has_mfderiv_within_at.congr_mono (mdifferentiable_within_at.has_mfderiv_within_at h) ht hx (set.subset.refl s))\n\ntheorem mdifferentiable_on.congr_mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_on I I' f s) (h' : ∀ (x : M), x ∈ t → f₁ x = f x) (h₁ : t ⊆ s) : mdifferentiable_on I I' f₁ t :=\n  fun (x : M) (hx : x ∈ t) => mdifferentiable_within_at.congr_mono (h x (h₁ hx)) h' (h' x hx) h₁\n\ntheorem mdifferentiable_at.congr_of_eventually_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_at I I' f x) (hL : filter.eventually_eq (nhds x) f₁ f) : mdifferentiable_at I I' f₁ x :=\n  has_mfderiv_at.mdifferentiable_at (has_mfderiv_at.congr_of_eventually_eq (mdifferentiable_at.has_mfderiv_at h) hL)\n\ntheorem mdifferentiable_within_at.mfderiv_within_congr_mono {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} {t : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : mdifferentiable_within_at I I' f s x) (hs : ∀ (x : M), x ∈ t → f₁ x = f x) (hx : f₁ x = f x) (hxt : unique_mdiff_within_at I t x) (h₁ : t ⊆ s) : mfderiv_within I I' f₁ t x = mfderiv_within I I' f s x :=\n  has_mfderiv_within_at.mfderiv_within\n    (has_mfderiv_within_at.congr_mono (mdifferentiable_within_at.has_mfderiv_within_at h) hs hx h₁) hxt\n\ntheorem filter.eventually_eq.mfderiv_within_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (hs : unique_mdiff_within_at I s x) (hL : filter.eventually_eq (nhds_within x s) f₁ f) (hx : f₁ x = f x) : mfderiv_within I I' f₁ s x = mfderiv_within I I' f s x := sorry\n\ntheorem mfderiv_within_congr {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (hs : unique_mdiff_within_at I s x) (hL : ∀ (x : M), x ∈ s → f₁ x = f x) (hx : f₁ x = f x) : mfderiv_within I I' f₁ s x = mfderiv_within I I' f s x :=\n  filter.eventually_eq.mfderiv_within_eq hs (filter.eventually_eq_of_mem self_mem_nhds_within hL) hx\n\ntheorem tangent_map_within_congr {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : ∀ (x : M), x ∈ s → f x = f₁ x) (p : tangent_bundle I M) (hp : sigma.fst p ∈ s) (hs : unique_mdiff_within_at I s (sigma.fst p)) : tangent_map_within I I' f s p = tangent_map_within I I' f₁ s p := sorry\n\ntheorem filter.eventually_eq.mfderiv_eq {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M → M'} {f₁ : M → M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (hL : filter.eventually_eq (nhds x) f₁ f) : mfderiv I I' f₁ x = mfderiv I I' f x := sorry\n\n/-! ### Composition lemmas -/\n\ntheorem written_in_ext_chart_comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} {x : M} {s : set M} {g : M' → M''} (h : continuous_within_at f s x) : (set_of\n    fun (y : E) =>\n      written_in_ext_chart_at I I'' x (g ∘ f) y =\n        function.comp (written_in_ext_chart_at I' I'' (f x) g) (written_in_ext_chart_at I I' x f) y) ∈\n  nhds_within (coe_fn (ext_chart_at I x) x) (⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s ∩ set.range ⇑I) := sorry\n\ntheorem has_mfderiv_within_at.comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} (x : M) {s : set M} {g : M' → M''} {u : set M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} {g' : continuous_linear_map 𝕜 (tangent_space I' (f x)) (tangent_space I'' (g (f x)))} (hg : has_mfderiv_within_at I' I'' g u (f x) g') (hf : has_mfderiv_within_at I I' f s x f') (hst : s ⊆ f ⁻¹' u) : has_mfderiv_within_at I I'' (g ∘ f) s x (continuous_linear_map.comp g' f') := sorry\n\n/-- The chain rule. -/\ntheorem has_mfderiv_at.comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} (x : M) {g : M' → M''} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} {g' : continuous_linear_map 𝕜 (tangent_space I' (f x)) (tangent_space I'' (g (f x)))} (hg : has_mfderiv_at I' I'' g (f x) g') (hf : has_mfderiv_at I I' f x f') : has_mfderiv_at I I'' (g ∘ f) x (continuous_linear_map.comp g' f') := sorry\n\ntheorem has_mfderiv_at.comp_has_mfderiv_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} (x : M) {s : set M} {g : M' → M''} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] {f' : continuous_linear_map 𝕜 (tangent_space I x) (tangent_space I' (f x))} {g' : continuous_linear_map 𝕜 (tangent_space I' (f x)) (tangent_space I'' (g (f x)))} (hg : has_mfderiv_at I' I'' g (f x) g') (hf : has_mfderiv_within_at I I' f s x f') : has_mfderiv_within_at I I'' (g ∘ f) s x (continuous_linear_map.comp g' f') := sorry\n\ntheorem mdifferentiable_within_at.comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} (x : M) {s : set M} {g : M' → M''} {u : set M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (hg : mdifferentiable_within_at I' I'' g u (f x)) (hf : mdifferentiable_within_at I I' f s x) (h : s ⊆ f ⁻¹' u) : mdifferentiable_within_at I I'' (g ∘ f) s x := sorry\n\ntheorem mdifferentiable_at.comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} (x : M) {g : M' → M''} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (hg : mdifferentiable_at I' I'' g (f x)) (hf : mdifferentiable_at I I' f x) : mdifferentiable_at I I'' (g ∘ f) x :=\n  has_mfderiv_at.mdifferentiable_at\n    (has_mfderiv_at.comp x (mdifferentiable_at.has_mfderiv_at hg) (mdifferentiable_at.has_mfderiv_at hf))\n\ntheorem mfderiv_within_comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} (x : M) {s : set M} {g : M' → M''} {u : set M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (hg : mdifferentiable_within_at I' I'' g u (f x)) (hf : mdifferentiable_within_at I I' f s x) (h : s ⊆ f ⁻¹' u) (hxs : unique_mdiff_within_at I s x) : mfderiv_within I I'' (g ∘ f) s x =\n  continuous_linear_map.comp (mfderiv_within I' I'' g u (f x)) (mfderiv_within I I' f s x) := sorry\n\ntheorem mfderiv_comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} (x : M) {g : M' → M''} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (hg : mdifferentiable_at I' I'' g (f x)) (hf : mdifferentiable_at I I' f x) : mfderiv I I'' (g ∘ f) x = continuous_linear_map.comp (mfderiv I' I'' g (f x)) (mfderiv I I' f x) :=\n  has_mfderiv_at.mfderiv\n    (has_mfderiv_at.comp x (mdifferentiable_at.has_mfderiv_at hg) (mdifferentiable_at.has_mfderiv_at hf))\n\ntheorem mdifferentiable_on.comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} {s : set M} {g : M' → M''} {u : set M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (hg : mdifferentiable_on I' I'' g u) (hf : mdifferentiable_on I I' f s) (st : s ⊆ f ⁻¹' u) : mdifferentiable_on I I'' (g ∘ f) s :=\n  fun (x : M) (hx : x ∈ s) => mdifferentiable_within_at.comp x (hg (f x) (st hx)) (hf x hx) st\n\ntheorem mdifferentiable.comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} {g : M' → M''} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (hg : mdifferentiable I' I'' g) (hf : mdifferentiable I I' f) : mdifferentiable I I'' (g ∘ f) :=\n  fun (x : M) => mdifferentiable_at.comp x (hg (f x)) (hf x)\n\ntheorem tangent_map_within_comp_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} {s : set M} {g : M' → M''} {u : set M'} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (p : tangent_bundle I M) (hg : mdifferentiable_within_at I' I'' g u (f (sigma.fst p))) (hf : mdifferentiable_within_at I I' f s (sigma.fst p)) (h : s ⊆ f ⁻¹' u) (hps : unique_mdiff_within_at I s (sigma.fst p)) : tangent_map_within I I'' (g ∘ f) s p = tangent_map_within I' I'' g u (tangent_map_within I I' f s p) := sorry\n\ntheorem tangent_map_comp_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} {g : M' → M''} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (p : tangent_bundle I M) (hg : mdifferentiable_at I' I'' g (f (sigma.fst p))) (hf : mdifferentiable_at I I' f (sigma.fst p)) : tangent_map I I'' (g ∘ f) p = tangent_map I' I'' g (tangent_map I I' f p) := sorry\n\ntheorem tangent_map_comp {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M → M'} {g : M' → M''} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] [I''s : smooth_manifold_with_corners I'' M''] (hg : mdifferentiable I' I'' g) (hf : mdifferentiable I I' f) : tangent_map I I'' (g ∘ f) = tangent_map I' I'' g ∘ tangent_map I I' f :=\n  funext fun (p : tangent_bundle I M) => tangent_map_comp_at p (hg (f (sigma.fst p))) (hf (sigma.fst p))\n\n/-! ### Differentiability of specific functions -/\n\n/-! #### Identity -/\n\ntheorem has_mfderiv_at_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] (x : M) : has_mfderiv_at I I id x (continuous_linear_map.id 𝕜 (tangent_space I x)) := sorry\n\ntheorem has_mfderiv_within_at_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] (s : set M) (x : M) : has_mfderiv_within_at I I id s x (continuous_linear_map.id 𝕜 (tangent_space I x)) :=\n  has_mfderiv_at.has_mfderiv_within_at (has_mfderiv_at_id I x)\n\ntheorem mdifferentiable_at_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {x : M} : mdifferentiable_at I I id x :=\n  has_mfderiv_at.mdifferentiable_at (has_mfderiv_at_id I x)\n\ntheorem mdifferentiable_within_at_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} {x : M} : mdifferentiable_within_at I I id s x :=\n  mdifferentiable_at.mdifferentiable_within_at (mdifferentiable_at_id I)\n\ntheorem mdifferentiable_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] : mdifferentiable I I id :=\n  fun (x : M) => mdifferentiable_at_id I\n\ntheorem mdifferentiable_on_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} : mdifferentiable_on I I id s :=\n  mdifferentiable.mdifferentiable_on (mdifferentiable_id I)\n\n@[simp] theorem mfderiv_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {x : M} : mfderiv I I id x = continuous_linear_map.id 𝕜 (tangent_space I x) :=\n  has_mfderiv_at.mfderiv (has_mfderiv_at_id I x)\n\ntheorem mfderiv_within_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} {x : M} (hxs : unique_mdiff_within_at I s x) : mfderiv_within I I id s x = continuous_linear_map.id 𝕜 (tangent_space I x) := sorry\n\n@[simp] theorem tangent_map_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] : tangent_map I I id = id := sorry\n\ntheorem tangent_map_within_id {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} {p : tangent_bundle I M} (hs : unique_mdiff_within_at I s (tangent_bundle.proj I M p)) : tangent_map_within I I id s p = p := sorry\n\n/-! #### Constants -/\n\ntheorem has_mfderiv_at_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] (c : M') (x : M) : has_mfderiv_at I I' (fun (y : M) => c) x 0 := sorry\n\ntheorem has_mfderiv_within_at_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] (c : M') (s : set M) (x : M) : has_mfderiv_within_at I I' (fun (y : M) => c) s x 0 :=\n  has_mfderiv_at.has_mfderiv_within_at (has_mfderiv_at_const I I' c x)\n\ntheorem mdifferentiable_at_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {x : M} {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] {c : M'} : mdifferentiable_at I I' (fun (y : M) => c) x :=\n  has_mfderiv_at.mdifferentiable_at (has_mfderiv_at_const I I' c x)\n\ntheorem mdifferentiable_within_at_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} {x : M} {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] {c : M'} : mdifferentiable_within_at I I' (fun (y : M) => c) s x :=\n  mdifferentiable_at.mdifferentiable_within_at (mdifferentiable_at_const I I')\n\ntheorem mdifferentiable_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] {c : M'} : mdifferentiable I I' fun (y : M) => c :=\n  fun (x : M) => mdifferentiable_at_const I I'\n\ntheorem mdifferentiable_on_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] {c : M'} : mdifferentiable_on I I' (fun (y : M) => c) s :=\n  mdifferentiable.mdifferentiable_on (mdifferentiable_const I I')\n\n@[simp] theorem mfderiv_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {x : M} {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] {c : M'} : mfderiv I I' (fun (y : M) => c) x = 0 :=\n  has_mfderiv_at.mfderiv (has_mfderiv_at_const I I' c x)\n\ntheorem mfderiv_within_const {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} {x : M} {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners 𝕜 E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M'] {c : M'} (hxs : unique_mdiff_within_at I s x) : mfderiv_within I I' (fun (y : M) => c) s x = 0 := sorry\n\n/-! #### Model with corners -/\n\ntheorem model_with_corners.mdifferentiable {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) : mdifferentiable I (model_with_corners_self 𝕜 E) ⇑I := sorry\n\ntheorem model_with_corners.mdifferentiable_on_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) : mdifferentiable_on (model_with_corners_self 𝕜 E) I (⇑(model_with_corners.symm I)) (set.range ⇑I) := sorry\n\ntheorem mdifferentiable_at_atlas {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {e : local_homeomorph M H} (h : e ∈ charted_space.atlas H M) {x : M} (hx : x ∈ local_equiv.source (local_homeomorph.to_local_equiv e)) : mdifferentiable_at I I (⇑e) x := sorry\n\ntheorem mdifferentiable_on_atlas {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {e : local_homeomorph M H} (h : e ∈ charted_space.atlas H M) : mdifferentiable_on I I (⇑e) (local_equiv.source (local_homeomorph.to_local_equiv e)) :=\n  fun (x : M) (hx : x ∈ local_equiv.source (local_homeomorph.to_local_equiv e)) =>\n    mdifferentiable_at.mdifferentiable_within_at (mdifferentiable_at_atlas I h hx)\n\ntheorem mdifferentiable_at_atlas_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {e : local_homeomorph M H} (h : e ∈ charted_space.atlas H M) {x : H} (hx : x ∈ local_equiv.target (local_homeomorph.to_local_equiv e)) : mdifferentiable_at I I (⇑(local_homeomorph.symm e)) x := sorry\n\ntheorem mdifferentiable_on_atlas_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {e : local_homeomorph M H} (h : e ∈ charted_space.atlas H M) : mdifferentiable_on I I (⇑(local_homeomorph.symm e)) (local_equiv.target (local_homeomorph.to_local_equiv e)) :=\n  fun (x : H) (hx : x ∈ local_equiv.target (local_homeomorph.to_local_equiv e)) =>\n    mdifferentiable_at.mdifferentiable_within_at (mdifferentiable_at_atlas_symm I h hx)\n\ntheorem mdifferentiable_of_mem_atlas {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {e : local_homeomorph M H} (h : e ∈ charted_space.atlas H M) : local_homeomorph.mdifferentiable I I e :=\n  { left := mdifferentiable_on_atlas I h, right := mdifferentiable_on_atlas_symm I h }\n\ntheorem mdifferentiable_chart {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] (x : M) : local_homeomorph.mdifferentiable I I (charted_space.chart_at H x) :=\n  mdifferentiable_of_mem_atlas I (charted_space.chart_mem_atlas H x)\n\n/-- The derivative of the chart at a base point is the chart of the tangent bundle, composed with\nthe identification between the tangent bundle of the model space and the product space. -/\ntheorem tangent_map_chart {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {p : tangent_bundle I M} {q : tangent_bundle I M} (h : sigma.fst q ∈ local_equiv.source (local_homeomorph.to_local_equiv (charted_space.chart_at H (sigma.fst p)))) : tangent_map I I (⇑(charted_space.chart_at H (sigma.fst p))) q =\n  coe_fn (equiv.symm (equiv.sigma_equiv_prod H E)) (coe_fn (charted_space.chart_at (model_prod H E) p) q) := sorry\n\n/-- The derivative of the inverse of the chart at a base point is the inverse of the chart of the\ntangent bundle, composed with the identification between the tangent bundle of the model space and\nthe product space. -/\ntheorem tangent_map_chart_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] (I : model_with_corners 𝕜 E H) {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {p : tangent_bundle I M} {q : tangent_bundle I H} (h : sigma.fst q ∈ local_equiv.target (local_homeomorph.to_local_equiv (charted_space.chart_at H (sigma.fst p)))) : tangent_map I I (⇑(local_homeomorph.symm (charted_space.chart_at H (sigma.fst p)))) q =\n  coe_fn (local_homeomorph.symm (charted_space.chart_at (model_prod H E) p)) (coe_fn (equiv.sigma_equiv_prod H E) q) := sorry\n\n/-!\n### Relations between vector space derivative and manifold derivative\n\nThe manifold derivative `mfderiv`, when considered on the model vector space with its trivial\nmanifold structure, coincides with the usual Frechet derivative `fderiv`. In this section, we prove\nthis and related statements.\n-/\n\ntheorem unique_mdiff_within_at_iff_unique_diff_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {s : set E} {x : E} : unique_mdiff_within_at (model_with_corners_self 𝕜 E) s x ↔ unique_diff_within_at 𝕜 s x := sorry\n\ntheorem unique_mdiff_on_iff_unique_diff_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {s : set E} : unique_mdiff_on (model_with_corners_self 𝕜 E) s ↔ unique_diff_on 𝕜 s := sorry\n\n@[simp] theorem written_in_ext_chart_model_space {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {E' : Type u_3} [normed_group E'] [normed_space 𝕜 E'] {f : E → E'} {x : E} : written_in_ext_chart_at (model_with_corners_self 𝕜 E) (model_with_corners_self 𝕜 E') x f = f := sorry\n\n/-- For maps between vector spaces, `mdifferentiable_within_at` and `fdifferentiable_within_at`\ncoincide -/\ntheorem mdifferentiable_within_at_iff_differentiable_within_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {E' : Type u_3} [normed_group E'] [normed_space 𝕜 E'] {f : E → E'} {s : set E} {x : E} : mdifferentiable_within_at (model_with_corners_self 𝕜 E) (model_with_corners_self 𝕜 E') f s x ↔\n  differentiable_within_at 𝕜 f s x := sorry\n\n/-- For maps between vector spaces, `mdifferentiable_at` and `differentiable_at` coincide -/\ntheorem mdifferentiable_at_iff_differentiable_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {E' : Type u_3} [normed_group E'] [normed_space 𝕜 E'] {f : E → E'} {x : E} : mdifferentiable_at (model_with_corners_self 𝕜 E) (model_with_corners_self 𝕜 E') f x ↔ differentiable_at 𝕜 f x := sorry\n\n/-- For maps between vector spaces, `mdifferentiable_on` and `differentiable_on` coincide -/\ntheorem mdifferentiable_on_iff_differentiable_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {E' : Type u_3} [normed_group E'] [normed_space 𝕜 E'] {f : E → E'} {s : set E} : mdifferentiable_on (model_with_corners_self 𝕜 E) (model_with_corners_self 𝕜 E') f s ↔ differentiable_on 𝕜 f s := sorry\n\n/-- For maps between vector spaces, `mdifferentiable` and `differentiable` coincide -/\ntheorem mdifferentiable_iff_differentiable {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {E' : Type u_3} [normed_group E'] [normed_space 𝕜 E'] {f : E → E'} : mdifferentiable (model_with_corners_self 𝕜 E) (model_with_corners_self 𝕜 E') f ↔ differentiable 𝕜 f := sorry\n\n/-- For maps between vector spaces, `mfderiv_within` and `fderiv_within` coincide -/\ntheorem mfderiv_within_eq_fderiv_within {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {E' : Type u_3} [normed_group E'] [normed_space 𝕜 E'] {f : E → E'} {s : set E} {x : E} : mfderiv_within (model_with_corners_self 𝕜 E) (model_with_corners_self 𝕜 E') f s x = fderiv_within 𝕜 f s x := sorry\n\n/-- For maps between vector spaces, `mfderiv` and `fderiv` coincide -/\ntheorem mfderiv_eq_fderiv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {E' : Type u_3} [normed_group E'] [normed_space 𝕜 E'] {f : E → E'} {x : E} : mfderiv (model_with_corners_self 𝕜 E) (model_with_corners_self 𝕜 E') f x = fderiv 𝕜 f x := sorry\n\n/-! ### Differentiable local homeomorphisms -/\n\nnamespace local_homeomorph.mdifferentiable\n\n\ntheorem symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) : mdifferentiable I' I (local_homeomorph.symm e) :=\n  { left := and.right he, right := and.left he }\n\nprotected theorem mdifferentiable_at {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) {x : M} (hx : x ∈ local_equiv.source (to_local_equiv e)) : mdifferentiable_at I I' (⇑e) x :=\n  mdifferentiable_within_at.mdifferentiable_at (and.left he x hx) (mem_nhds_sets (open_source e) hx)\n\ntheorem mdifferentiable_at_symm {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) {x : M'} (hx : x ∈ local_equiv.target (to_local_equiv e)) : mdifferentiable_at I' I (⇑(local_homeomorph.symm e)) x :=\n  mdifferentiable_within_at.mdifferentiable_at (and.right he x hx) (mem_nhds_sets (open_target e) hx)\n\ntheorem symm_comp_deriv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] {x : M} (hx : x ∈ local_equiv.source (to_local_equiv e)) : continuous_linear_map.comp (mfderiv I' I (⇑(local_homeomorph.symm e)) (coe_fn e x)) (mfderiv I I' (⇑e) x) =\n  continuous_linear_map.id 𝕜 (tangent_space I x) := sorry\n\ntheorem comp_symm_deriv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] {x : M'} (hx : x ∈ local_equiv.target (to_local_equiv e)) : continuous_linear_map.comp (mfderiv I I' (⇑e) (coe_fn (local_homeomorph.symm e) x))\n    (mfderiv I' I (⇑(local_homeomorph.symm e)) x) =\n  continuous_linear_map.id 𝕜 (tangent_space I' x) :=\n  symm_comp_deriv (symm he) hx\n\n/-- The derivative of a differentiable local homeomorphism, as a continuous linear equivalence\nbetween the tangent spaces at `x` and `e x`. -/\nprotected def mfderiv {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] {x : M} (hx : x ∈ local_equiv.source (to_local_equiv e)) : continuous_linear_equiv 𝕜 (tangent_space I x) (tangent_space I' (coe_fn e x)) :=\n  continuous_linear_equiv.mk\n    (linear_equiv.mk (linear_map.to_fun (continuous_linear_map.to_linear_map (mfderiv I I' (⇑e) x))) sorry sorry\n      ⇑(mfderiv I' I (⇑(local_homeomorph.symm e)) (coe_fn e x)) sorry sorry)\n\ntheorem mfderiv_bijective {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] {x : M} (hx : x ∈ local_equiv.source (to_local_equiv e)) : function.bijective ⇑(mfderiv I I' (⇑e) x) :=\n  continuous_linear_equiv.bijective (mdifferentiable.mfderiv he hx)\n\ntheorem mfderiv_surjective {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] {x : M} (hx : x ∈ local_equiv.source (to_local_equiv e)) : function.surjective ⇑(mfderiv I I' (⇑e) x) :=\n  continuous_linear_equiv.surjective (mdifferentiable.mfderiv he hx)\n\ntheorem range_mfderiv_eq_univ {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] {x : M} (hx : x ∈ local_equiv.source (to_local_equiv e)) : set.range ⇑(mfderiv I I' (⇑e) x) = set.univ :=\n  function.surjective.range_eq (mfderiv_surjective he hx)\n\ntheorem trans {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space 𝕜 E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {e : local_homeomorph M M'} (he : mdifferentiable I I' e) {e' : local_homeomorph M' M''} [smooth_manifold_with_corners I M] [smooth_manifold_with_corners I' M'] [smooth_manifold_with_corners I'' M''] (he' : mdifferentiable I' I'' e') : mdifferentiable I I'' (local_homeomorph.trans e e') := sorry\n\nend local_homeomorph.mdifferentiable\n\n\n/-! ### Unique derivative sets in manifolds -/\n\n/-- If a set has the unique differential property, then its image under a local\ndiffeomorphism also has the unique differential property. -/\ntheorem unique_mdiff_on.unique_mdiff_on_preimage {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {s : set M} [smooth_manifold_with_corners I' M'] (hs : unique_mdiff_on I s) {e : local_homeomorph M M'} (he : local_homeomorph.mdifferentiable I I' e) : unique_mdiff_on I' (local_equiv.target (local_homeomorph.to_local_equiv e) ∩ ⇑(local_homeomorph.symm e) ⁻¹' s) := sorry\n\n/-- If a set in a manifold has the unique derivative property, then its pullback by any extended\nchart, in the vector space, also has the unique derivative property. -/\ntheorem unique_mdiff_on.unique_diff_on {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} (hs : unique_mdiff_on I s) (x : M) : unique_diff_on 𝕜 (local_equiv.target (ext_chart_at I x) ∩ ⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' s) := sorry\n\n/-- When considering functions between manifolds, this statement shows up often. It entails\nthe unique differential of the pullback in extended charts of the set where the function can\nbe read in the charts. -/\ntheorem unique_mdiff_on.unique_diff_on_inter_preimage {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {E' : Type u_5} [normed_group E'] [normed_space 𝕜 E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners 𝕜 E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {s : set M} (hs : unique_mdiff_on I s) (x : M) (y : M') {f : M → M'} (hf : continuous_on f s) : unique_diff_on 𝕜\n  (local_equiv.target (ext_chart_at I x) ∩\n    ⇑(local_equiv.symm (ext_chart_at I x)) ⁻¹' (s ∩ f ⁻¹' local_equiv.source (ext_chart_at I' y))) := sorry\n\n/-- In a smooth fiber bundle constructed from core, the preimage under the projection of a set with\nunique differential in the basis also has unique differential. -/\ntheorem unique_mdiff_on.smooth_bundle_preimage {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} {F : Type u_8} [normed_group F] [normed_space 𝕜 F] (Z : basic_smooth_bundle_core I M F) (hs : unique_mdiff_on I s) : unique_mdiff_on (model_with_corners.prod I (model_with_corners_self 𝕜 F))\n  (topological_fiber_bundle_core.proj (basic_smooth_bundle_core.to_topological_fiber_bundle_core Z) ⁻¹' s) := sorry\n\ntheorem unique_mdiff_on.tangent_bundle_proj_preimage {𝕜 : Type u_1} [nondiscrete_normed_field 𝕜] {E : Type u_2} [normed_group E] [normed_space 𝕜 E] {H : Type u_3} [topological_space H] {I : model_with_corners 𝕜 E H} {M : Type u_4} [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M] {s : set M} (hs : unique_mdiff_on I s) : unique_mdiff_on (model_with_corners.tangent I) (tangent_bundle.proj I M ⁻¹' s) :=\n  unique_mdiff_on.smooth_bundle_preimage (tangent_bundle_core I M) hs\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/geometry/manifold/mfderiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4515480054935028}}
{"text": "import for_mathlib.homology\nimport for_mathlib.exact_lift_desc\n\nnoncomputable theory\n\nopen category_theory category_theory.limits opposite\n\nvariables {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\nvariables {A B C : 𝓐} (f : A ⟶ B) (g : B ⟶ C) (w : f ≫ g = 0)\n\nlemma homology.lift_desc (X Y Z : 𝓐) (f : X ⟶ Y) (g : Y ⟶ Z) (w)\n  (U : 𝓐) (e : _ ⟶ U) (he : f ≫ e = 0) (V : 𝓐) (t : V ⟶ _) (ht : t ≫ g = 0) :\n  homology.lift f g w (t ≫ cokernel.π _) (by simp [ht]) ≫\n  homology.desc' _ _ _ (kernel.ι _ ≫ e) (by simp [he]) =\n  t ≫ e :=\nbegin\n  let s := _, change s ≫ _ = _,\n  have hs : s = kernel.lift _ t ht ≫ homology.π' _ _ _,\n  { apply homology.hom_to_ext,\n    simp only [homology.lift_ι, category.assoc, homology.π'_ι, kernel.lift_ι_assoc] },\n  simp [hs],\nend\n\nlemma homology.lift_desc' (X Y Z : 𝓐) (f : X ⟶ Y) (g : Y ⟶ Z) (w)\n  (U : 𝓐) (e : Y ⟶ U) (he : f ≫ e = 0) (V : 𝓐) (t : V ⟶ Y) (ht : t ≫ g = 0)\n  (u v) (hu : u = t ≫ cokernel.π _) (hv : v = kernel.ι _ ≫ e) :\n  homology.lift f g w u (by simpa [hu]) ≫ homology.desc' _ _ _ v (by simpa [hv]) = t ≫ e :=\nbegin\n  subst hu,\n  subst hv,\n  apply homology.lift_desc,\n  assumption'\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/homology_lift_desc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4515479983375004}}
{"text": "import tactic\nimport data.setoid.basic\nimport .scratch\n\nopen function\n\n-- Downside, does not send equivalences to equivalences. At least need reflexivity for\n-- category structure. Need something more like what they have in structure identity principle.\n-- Need to figure out the point of the final condition.\nstructure suitable (F : Type → Type) \n  (ρ : Π {X Y}, (X → Y → Prop) → (F X → F Y → Prop)) : Prop :=\n(symm : Π {X Y : Type} (R : X → Y → Prop) (x : F X) (y : F Y),\n  ρ R x y → ρ (swap R) y x)\n(trans : Π {X Y Z : Type} (R : X → Y → Prop) (R' : Y → Z → Prop) x y z,\n  ρ R x y → ρ R' y z → ρ (λ x z, ∃ y, R x y ∧ R' y z) x z)\n(desc : Π {X : Type} (R : setoid X) (s) (h : ρ R.r s s),\n  ∃! (s' : F (quotient R)), ρ (λ (x : X) (y : quotient R), quotient.mk x = y) s s')\n\ndef functional {X Y : Type} (R : X → Y → Prop) : Prop :=\n∀ x, ∃! y, R x y\n\nlemma functional_iff_exists_function {X Y : Type} (R : X → Y → Prop) :\n  functional R ↔ ∃ f : X → Y, R = (λ x y, f x = y) :=\nbegin\n  split,\n  { intro h,\n    cases classical.axiom_of_choice h with f hf,\n    dsimp at hf,\n    use f,\n    ext x y,\n    split,\n    { intro h,\n      exact ((hf _).2 _ h).symm },\n    { rintro rfl,\n      exact (hf x).1 } },\n  { rintros ⟨f, rfl⟩,\n    intro x,\n    use f x,\n    simp } \nend \n\ndef is_equivalence {X Y : Type} (R : X → Y → Prop) :=\nfunctional R ∧ functional (function.swap R)\n\nlemma is_equivalence_iff_exists_equiv {X Y : Type} (R : X → Y → Prop) :\n  is_equivalence R ↔ ∃ f : X ≃ Y, R = (λ x y, f x = y) :=\nbegin\n  split,\n  { intro h,\n    rcases (functional_iff_exists_function _).1 h.1 with ⟨f, rfl⟩,\n    rcases (functional_iff_exists_function _).1 h.2 with ⟨g, hg⟩,\n    simp only [function.funext_iff, function.swap, eq_iff_iff] at hg,\n    refine ⟨⟨f, g, λ x, _, λ y, _⟩, _⟩,\n    { rw ← hg },\n    { rw hg },\n    { refl } },\n  { rintros ⟨f, rfl⟩,\n    split,\n    { rw [functional_iff_exists_function],\n      use f },\n    { rw [functional_iff_exists_function],\n      use f.symm,\n      simp [function.swap, function.funext_iff, equiv.symm_apply_eq],\n      simp [eq_comm] } }\nend\n-- Not true\nexample (F ρ) (hsuit : suitable F ρ) {X Y : Type}\n  (R : X → Y → Prop) (h : is_equivalence R) : functional (ρ R) :=\nbegin\n  intro x,\n\n\nend\n\n-- λ X, X → X does not map reflexive relations to reflexive relations.\nexample {X Y : Type} (f : X → Y) (hf : surjective f) :\n  functional (λ (a : X → X) (b : Y → Y), ∀ x, f (a x) = b (f x)) :=\nbegin\n  intro a,\n  have : (λ (a b : X → X), ∀ x y, f x = f y → f (a x) = f (b y)) a a,\n  { simp, },\n  dsimp only,\n  use f ∘ a ∘ surj_inv hf,\n  dsimp only,\n  split,\n  { intro x,\n    dsimp, \n    \n     },\n  { intros b hb,\n    funext,\n    dsimp,\n    rcases hf x with ⟨x, rfl⟩,\n    rw ← hb,\n     }\n\nend\n\nlemma alt_def (F ρ) (hsuit : suitable F ρ) \n  {X Y : Type} (f : X → Y) (hf : surjective f)\n  (hrefl : reflexive (ρ (setoid.ker f).r)) : \n  functional (ρ (λ x y, f x = y)) :=\nlet R : setoid X := setoid.ker f in\nλ x, begin\n  cases hsuit.desc R x (hrefl x) with y hy,\n  dsimp at\n\nend\n\n \n\nexample (F ρ) (hsuit : suitable F ρ) {X Y : Type}\n  (R : X → Y → Prop) (h : square R) : square (ρ R) :=\nbegin\n  intros x₁ x₂ y₁ y₂ h₁ h₂ h₃,\n  have := hsuit.trans R (swap R) _ _ _ h₁ (hsuit.symm _ _ _ h₂),\n  have := hsuit.trans _ _ _ _ _ this h₃,\n  convert this,\n  ext x y,\n  split,\n  { intros,\n    use x,\n    split,\n    { use y,\n      split, assumption, assumption },\n    { assumption } },\n  { rintros ⟨x', ⟨y', hy⟩, hx'y⟩,\n    exact h _ _ _ _ hy.1 hy.2 hx'y }\nend \n\n-- structure positive (F : Type → Type)\n--   (ρ : Π {X Y}, (X → Y → Prop) → (F X → F Y → Prop)) : Prop :=\n-- (refl : Π {X : Type}, ρ (@eq X) = eq)\n-- (rev_trans : Π {X Y Z} (R : X → Y → Prop) (R' : Y → Z → Prop),\n--   ρ R x z → ρ (λ x z, ∃ y, R x y ∧ R' y z) x z)\n\nexample : suitable (λ X : Type, X → X) (λ X Y R f g, ∀ x y, R x y → R (f x) (g y)) :=\n{ symm := λ X Y R x y h y x, h x y,\n  trans := λ X Y Z R R' a b c h₁ h₂ x z, \n    begin\n      rintros ⟨y, hxy, hyz⟩,\n      use b y,\n      split,\n      { exact h₁ _ _ hxy },\n      { exact h₂ _ _ hyz }\n    end,\n  desc := λ X R a h, \n    ⟨@quotient.map _ _ R R a h, begin\n      dsimp,\n      split,\n      { rintros x y rfl,\n        refl },\n      { intros b h,\n        funext x,\n        resetI,\n        refine quotient.induction_on x _,\n        intro x,\n        rw ← h x _ rfl,\n        refl } \n    end⟩ }\n\nexample {X Y : Type} (R : X → Y → Prop) (h : square R) : \n  square (λ (f : (X → X) → X) (g : (Y → Y) → Y), ∀ (a : X → X) (b : Y → Y),\n    (∀ x y, R x y → R (a x) (b y)) → R (f a) (g b)) :=\nλ f₁ f₂ g₁ g₂ h₁ h₂ h₃ a b hab, begin\n  dsimp at *,\n  apply h,\n  apply h₁,\n  apply hab,\n  apply h₂,\n  apply hab,\n  apply h₃, \n  apply hab\nend\n\nexample : suitable (λ X, (X → X) → X) \n  (λ X Y R f g, ∀ (a : X → X) (b : Y → Y), (∀ x y, R x y → R (a x) (b y)) → R (f a) (g b)) :=\n{ symm := λ X Y R f g h₁ a b h₂, h₁ _ _ (λ x y, h₂ y x),\n  trans := λ X Y Z R R' f g i h₁ h₂ a b h₃, begin\n    dsimp at *,\n  end }\n", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/parametricity/suitable_relation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933403143929, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4514393121303961}}
{"text": "/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Yuyang Zhao\n\n! This file was ported from Lean 3 source module ring_theory.polynomial.tower\n! leanprover-community/mathlib commit 10bf4f825ad729c5653adc039dafa3622e7f93c9\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Algebra.Tower\nimport Mathbin.Data.Polynomial.AlgebraMap\n\n/-!\n# Algebra towers for polynomial\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file proves some basic results about the algebra tower structure for the type `R[X]`.\n\nThis structure itself is provided elsewhere as `polynomial.is_scalar_tower`\n\nWhen you update this file, you can also try to make a corresponding update in\n`ring_theory.mv_polynomial.tower`.\n-/\n\n\nopen Polynomial\n\nvariable (R A B : Type _)\n\nnamespace Polynomial\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring A] [Semiring B]\n\nvariable [Algebra R A] [Algebra A B] [Algebra R B]\n\nvariable [IsScalarTower R A B]\n\nvariable {R B}\n\n/- warning: polynomial.aeval_map_algebra_map -> Polynomial.aeval_map_algebraMap is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} (A : Type.{u2}) {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u1, u3} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u2, u3} A B _inst_2 _inst_3 _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_6)))))] (x : B) (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)), Eq.{succ u3} B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AlgHom.{u2, u2, u3} A (Polynomial.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) B _inst_2 (Polynomial.semiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u2, u2} A A _inst_2 (CommSemiring.toSemiring.{u2} A _inst_2) (Algebra.id.{u2} A _inst_2)) _inst_5) (fun (_x : AlgHom.{u2, u2, u3} A (Polynomial.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) B _inst_2 (Polynomial.semiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u2, u2} A A _inst_2 (CommSemiring.toSemiring.{u2} A _inst_2) (Algebra.id.{u2} A _inst_2)) _inst_5) => (Polynomial.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) -> B) ([anonymous].{u2, u2, u3} A (Polynomial.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) B _inst_2 (Polynomial.semiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u2, u2} A A _inst_2 (CommSemiring.toSemiring.{u2} A _inst_2) (Algebra.id.{u2} A _inst_2)) _inst_5) (Polynomial.aeval.{u2, u3} A B _inst_2 _inst_3 _inst_5 x) (Polynomial.map.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} A _inst_2) (algebraMap.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4) p)) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> B) ([anonymous].{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (Polynomial.aeval.{u1, u3} R B _inst_1 _inst_3 _inst_6 x) p)\nbut is expected to have type\n  forall {R : Type.{u3}} (A : Type.{u1}) {B : Type.{u2}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u1} A] [_inst_3 : Semiring.{u2} B] [_inst_4 : Algebra.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2)] [_inst_5 : Algebra.{u1, u2} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u3, u2} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u3, u1, u2} R A B (Algebra.toSMul.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4) (Algebra.toSMul.{u1, u2} A B _inst_2 _inst_3 _inst_5) (Algebra.toSMul.{u3, u2} R B _inst_1 _inst_3 _inst_6)] (x : B) (p : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) => B) (Polynomial.map.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u1} A _inst_2) (algebraMap.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4) p)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)) _inst_5) (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (fun (_x : Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) => B) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)) _inst_5) A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B (SMulZeroClass.toSMul.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (AddMonoid.toZero.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))))) (DistribSMul.toSMulZeroClass.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))))) (DistribMulAction.toDistribSMul.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (Module.toDistribMulAction.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Algebra.toModule.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2))))))) (SMulZeroClass.toSMul.{u1, u2} A B (AddMonoid.toZero.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u2} A B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u2} A B (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)))) (Module.toDistribMulAction.{u1, u2} A B (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (Algebra.toModule.{u1, u2} A B _inst_2 _inst_3 _inst_5))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)) _inst_5) A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)))) (Module.toDistribMulAction.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Algebra.toModule.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} A B (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (Algebra.toModule.{u1, u2} A B _inst_2 _inst_3 _inst_5)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)) _inst_5) A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B (MonoidWithZero.toMonoid.{u1} A (Semiring.toMonoidWithZero.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)) (Module.toDistribMulAction.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Algebra.toModule.{u1, u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)))) (Module.toDistribMulAction.{u1, u2} A B (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (Algebra.toModule.{u1, u2} A B _inst_2 _inst_3 _inst_5)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)) _inst_5 (AlgHom.{u1, u1, u2} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)) _inst_5) (AlgHom.algHomClass.{u1, u1, u2} A (Polynomial.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) B _inst_2 (Polynomial.semiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} A A _inst_2 (CommSemiring.toSemiring.{u1} A _inst_2) (Algebra.id.{u1} A _inst_2)) _inst_5))))) (Polynomial.aeval.{u1, u2} A B _inst_2 _inst_3 _inst_5 x) (Polynomial.map.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u1} A _inst_2) (algebraMap.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4) p)) (FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (fun (_x : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => B) _x) (SMulHomClass.toFunLike.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B (SMulZeroClass.toSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toZero.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toAddZeroClass.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R B (AddMonoid.toZero.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))))) (DistribSMul.toSMulZeroClass.{u3, u2} R B (AddMonoid.toAddZeroClass.{u2} B (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))))) (DistribMulAction.toDistribSMul.{u3, u2} R B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (Algebra.toModule.{u3, u2} R B _inst_1 _inst_3 _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (Algebra.toModule.{u3, u2} R B _inst_1 _inst_3 _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R B (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (Algebra.toModule.{u3, u2} R B _inst_1 _inst_3 _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, u3, u2, max u2 u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) B _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6))))) (Polynomial.aeval.{u3, u2} R B _inst_1 _inst_3 _inst_6 x) p)\nCase conversion may be inaccurate. Consider using '#align polynomial.aeval_map_algebra_map Polynomial.aeval_map_algebraMapₓ'. -/\n@[simp]\ntheorem aeval_map_algebraMap (x : B) (p : R[X]) : aeval x (map (algebraMap R A) p) = aeval x p := by\n  rw [aeval_def, aeval_def, eval₂_map, IsScalarTower.algebraMap_eq R A B]\n#align polynomial.aeval_map_algebra_map Polynomial.aeval_map_algebraMap\n\nend Semiring\n\nsection CommSemiring\n\nvariable [CommSemiring R] [CommSemiring A] [Semiring B]\n\nvariable [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B]\n\nvariable {R A}\n\n/- warning: polynomial.aeval_algebra_map_apply -> Polynomial.aeval_algebraMap_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u1, u3} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u2, u3} A B _inst_2 _inst_3 _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_6)))))] (x : A) (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)), Eq.{succ u3} B (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> B) ([anonymous].{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (Polynomial.aeval.{u1, u3} R B _inst_1 _inst_3 _inst_6 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (algebraMap.{u2, u3} A B _inst_2 _inst_3 _inst_5) x)) p) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (algebraMap.{u2, u3} A B _inst_2 _inst_3 _inst_5) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> A) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (Polynomial.aeval.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4 x) p))\nbut is expected to have type\n  forall {R : Type.{u3}} {A : Type.{u1}} (B : Type.{u2}) [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u1} A] [_inst_3 : Semiring.{u2} B] [_inst_4 : Algebra.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2)] [_inst_5 : Algebra.{u1, u2} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u3, u2} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u3, u1, u2} R A B (Algebra.toSMul.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4) (Algebra.toSMul.{u1, u2} A B _inst_2 _inst_3 _inst_5) (Algebra.toSMul.{u3, u2} R B _inst_1 _inst_3 _inst_6)] (x : A) (p : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) (FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (fun (_x : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _x) (SMulHomClass.toFunLike.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (SMulZeroClass.toSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toZero.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toAddZeroClass.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddMonoid.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))))) (DistribSMul.toSMulZeroClass.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddMonoid.toAddZeroClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))))) (DistribMulAction.toDistribSMul.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)))) (Module.toDistribMulAction.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, u3, u2, max u2 u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6))))) (Polynomial.aeval.{u3, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3) (RingHom.instRingHomClassRingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3))))) (algebraMap.{u1, u2} A B _inst_2 _inst_3 _inst_5) x)) p) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3) (RingHom.instRingHomClassRingHom.{u1, u2} A B (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3))))) (algebraMap.{u1, u2} A B _inst_2 _inst_3 _inst_5) (FunLike.coe.{max (succ u1) (succ u3), succ u3, succ u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (fun (_x : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => A) _x) (SMulHomClass.toFunLike.{max u1 u3, u3, u3, u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A (SMulZeroClass.toSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toZero.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toAddZeroClass.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u1} R A (AddMonoid.toZero.{u1} A (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u3, u1} R A (AddMonoid.toAddZeroClass.{u1} A (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u3, u1} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Module.toDistribMulAction.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4))))) (DistribMulActionHomClass.toSMulHomClass.{max u1 u3, u3, u3, u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u1 u3, u3, u3, u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, u3, u1, max u1 u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4 (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4))))) (Polynomial.aeval.{u3, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_4 x) p))\nCase conversion may be inaccurate. Consider using '#align polynomial.aeval_algebra_map_apply Polynomial.aeval_algebraMap_applyₓ'. -/\ntheorem aeval_algebraMap_apply (x : A) (p : R[X]) :\n    aeval (algebraMap A B x) p = algebraMap A B (aeval x p) := by\n  rw [aeval_def, aeval_def, hom_eval₂, ← IsScalarTower.algebraMap_eq]\n#align polynomial.aeval_algebra_map_apply Polynomial.aeval_algebraMap_apply\n\n/- warning: polynomial.aeval_algebra_map_eq_zero_iff -> Polynomial.aeval_algebraMap_eq_zero_iff is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} (B : Type.{u3}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u1, u3} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u2, u3} A B _inst_2 _inst_3 _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_6)))))] [_inst_8 : NoZeroSMulDivisors.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (MulZeroClass.toHasZero.{u3} B (NonUnitalNonAssocSemiring.toMulZeroClass.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u2, u3} A B _inst_2 _inst_3 _inst_5)))))] [_inst_9 : Nontrivial.{u3} B] (x : A) (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)), Iff (Eq.{succ u3} B (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> B) ([anonymous].{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (Polynomial.aeval.{u1, u3} R B _inst_1 _inst_3 _inst_6 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (algebraMap.{u2, u3} A B _inst_2 _inst_3 _inst_5) x)) p) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (MulZeroClass.toHasZero.{u3} B (NonUnitalNonAssocSemiring.toMulZeroClass.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))) (Eq.{succ u2} A (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> A) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (Polynomial.aeval.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4 x) p) (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))))))\nbut is expected to have type\n  forall {R : Type.{u1}} {A : Type.{u3}} (B : Type.{u2}) [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u3} A] [_inst_3 : Semiring.{u2} B] [_inst_4 : Algebra.{u1, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2)] [_inst_5 : Algebra.{u3, u2} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u1, u2} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u3, u2} R A B (Algebra.toSMul.{u1, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4) (Algebra.toSMul.{u3, u2} A B _inst_2 _inst_3 _inst_5) (Algebra.toSMul.{u1, u2} R B _inst_1 _inst_3 _inst_6)] [_inst_8 : NoZeroSMulDivisors.{u3, u2} A B (CommMonoidWithZero.toZero.{u3} A (CommSemiring.toCommMonoidWithZero.{u3} A _inst_2)) (MonoidWithZero.toZero.{u2} B (Semiring.toMonoidWithZero.{u2} B _inst_3)) (Algebra.toSMul.{u3, u2} A B _inst_2 _inst_3 _inst_5)] [_inst_9 : Nontrivial.{u2} B] (x : A) (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)), Iff (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _x) (SMulHomClass.toFunLike.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1))))))) (SMulZeroClass.toSMul.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddMonoid.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))))) (DistribSMul.toSMulZeroClass.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddMonoid.toAddZeroClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))))) (DistribMulAction.toDistribSMul.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)))) (Module.toDistribMulAction.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u1, u1, u1, u2} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u2, max u2 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6 (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6))))) (Polynomial.aeval.{u1, u2} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} A B (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} A B (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u2} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} A B (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} B (Semiring.toNonAssocSemiring.{u2} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} A B (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3) (RingHom.instRingHomClassRingHom.{u3, u2} A B (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)) (Semiring.toNonAssocSemiring.{u2} B _inst_3))))) (algebraMap.{u3, u2} A B _inst_2 _inst_3 _inst_5) x)) p) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) (MonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) (Semiring.toMonoidWithZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) _inst_3))))) (Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => A) p) (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u3} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (fun (_x : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => A) _x) (SMulHomClass.toFunLike.{max u3 u1, u1, u1, u3} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u3} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A (SMulZeroClass.toSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toAddZeroClass.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1))))))) (SMulZeroClass.toSMul.{u1, u3} R A (AddMonoid.toZero.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u1, u3} R A (AddMonoid.toAddZeroClass.{u3} A (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u1, u3} R A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))))) (Module.toDistribMulAction.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (Algebra.toModule.{u1, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4))))) (DistribMulActionHomClass.toSMulHomClass.{max u3 u1, u1, u1, u3} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u3} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u3} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (Algebra.toModule.{u1, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u3 u1, u1, u1, u3} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u3} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A (MonoidWithZero.toMonoid.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2))) (Module.toDistribMulAction.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u1} (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (Algebra.toModule.{u1, u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)))) (Module.toDistribMulAction.{u1, u3} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A (CommSemiring.toSemiring.{u3} A _inst_2)))) (Algebra.toModule.{u1, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u1, u1, u3, max u3 u1} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u3} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4 (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u3} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u3} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4))))) (Polynomial.aeval.{u1, u3} R A _inst_1 (CommSemiring.toSemiring.{u3} A _inst_2) _inst_4 x) p) (OfNat.ofNat.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => A) p) 0 (Zero.toOfNat0.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => A) p) (CommMonoidWithZero.toZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => A) p) (CommSemiring.toCommMonoidWithZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) => A) p) _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align polynomial.aeval_algebra_map_eq_zero_iff Polynomial.aeval_algebraMap_eq_zero_iffₓ'. -/\n@[simp]\ntheorem aeval_algebraMap_eq_zero_iff [NoZeroSMulDivisors A B] [Nontrivial B] (x : A) (p : R[X]) :\n    aeval (algebraMap A B x) p = 0 ↔ aeval x p = 0 := by\n  rw [aeval_algebra_map_apply, Algebra.algebraMap_eq_smul_one, smul_eq_zero,\n    iff_false_intro (one_ne_zero' B), or_false_iff]\n#align polynomial.aeval_algebra_map_eq_zero_iff Polynomial.aeval_algebraMap_eq_zero_iff\n\nvariable {B}\n\n/- warning: polynomial.aeval_algebra_map_eq_zero_iff_of_injective -> Polynomial.aeval_algebraMap_eq_zero_iff_of_injective is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} {B : Type.{u3}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Semiring.{u3} B] [_inst_4 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u3} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u1, u3} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u1, u2, u3} R A B (SMulZeroClass.toHasSmul.{u1, u2} R A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (SMulWithZero.toSmulZeroClass.{u1, u2} R A (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (MulActionWithZero.toSMulWithZero.{u1, u2} R A (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))) (Module.toMulActionWithZero.{u1, u2} R A (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (SMulZeroClass.toHasSmul.{u2, u3} A B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u2, u3} A B (MulZeroClass.toHasZero.{u2} A (MulZeroOneClass.toMulZeroClass.{u2} A (MonoidWithZero.toMulZeroOneClass.{u2} A (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u2, u3} A B (Semiring.toMonoidWithZero.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u2, u3} A B (CommSemiring.toSemiring.{u2} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u2, u3} A B _inst_2 _inst_3 _inst_5))))) (SMulZeroClass.toHasSmul.{u1, u3} R B (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (SMulWithZero.toSmulZeroClass.{u1, u3} R B (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))))) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (MulActionWithZero.toSMulWithZero.{u1, u3} R B (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} B (AddMonoid.toAddZeroClass.{u3} B (AddCommMonoid.toAddMonoid.{u3} B (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))) (Module.toMulActionWithZero.{u1, u3} R B (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) (Algebra.toModule.{u1, u3} R B _inst_1 _inst_3 _inst_6)))))] {x : A} {p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)}, (Function.Injective.{succ u2, succ u3} A B (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (algebraMap.{u2, u3} A B _inst_2 _inst_3 _inst_5))) -> (Iff (Eq.{succ u3} B (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> B) ([anonymous].{u1, u1, u3} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) B _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_6) (Polynomial.aeval.{u1, u3} R B _inst_1 _inst_3 _inst_6 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (fun (_x : RingHom.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) => A -> B) (RingHom.hasCoeToFun.{u2, u3} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u3} B _inst_3)) (algebraMap.{u2, u3} A B _inst_2 _inst_3 _inst_5) x)) p) (OfNat.ofNat.{u3} B 0 (OfNat.mk.{u3} B 0 (Zero.zero.{u3} B (MulZeroClass.toHasZero.{u3} B (NonUnitalNonAssocSemiring.toMulZeroClass.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3)))))))) (Eq.{succ u2} A (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> A) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_4) (Polynomial.aeval.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4 x) p) (OfNat.ofNat.{u2} A 0 (OfNat.mk.{u2} A 0 (Zero.zero.{u2} A (MulZeroClass.toHasZero.{u2} A (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))))))))\nbut is expected to have type\n  forall {R : Type.{u3}} {A : Type.{u2}} {B : Type.{u1}} [_inst_1 : CommSemiring.{u3} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Semiring.{u1} B] [_inst_4 : Algebra.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] [_inst_5 : Algebra.{u2, u1} A B _inst_2 _inst_3] [_inst_6 : Algebra.{u3, u1} R B _inst_1 _inst_3] [_inst_7 : IsScalarTower.{u3, u2, u1} R A B (Algebra.toSMul.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4) (Algebra.toSMul.{u2, u1} A B _inst_2 _inst_3 _inst_5) (Algebra.toSMul.{u3, u1} R B _inst_1 _inst_3 _inst_6)] {x : A} {p : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)}, (Function.Injective.{succ u2, succ u1} A B (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3))))) (algebraMap.{u2, u1} A B _inst_2 _inst_3 _inst_5))) -> (Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) (FunLike.coe.{max (succ u1) (succ u3), succ u3, succ u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (fun (_x : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _x) (SMulHomClass.toFunLike.{max u1 u3, u3, u3, u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (SMulZeroClass.toSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toZero.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toAddZeroClass.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddMonoid.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddCommMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))))) (DistribSMul.toSMulZeroClass.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddMonoid.toAddZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (AddCommMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))))) (DistribMulAction.toDistribSMul.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)))) (Module.toDistribMulAction.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6))))) (DistribMulActionHomClass.toSMulHomClass.{max u1 u3, u3, u3, u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u1 u3, u3, u3, u1} (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3)) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) (Semiring.toNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_3))) (Algebra.toModule.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, u3, u1, max u1 u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, u3, u1} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_3 (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_6))))) (Polynomial.aeval.{u3, u1} R ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) _inst_1 _inst_3 _inst_6 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A (fun (_x : A) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A B (NonUnitalNonAssocSemiring.toMul.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (NonUnitalNonAssocSemiring.toMul.{u1} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} B (Semiring.toNonAssocSemiring.{u1} B _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3)) A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3) (RingHom.instRingHomClassRingHom.{u2, u1} A B (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)) (Semiring.toNonAssocSemiring.{u1} B _inst_3))))) (algebraMap.{u2, u1} A B _inst_2 _inst_3 _inst_5) x)) p) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) (MonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) x) p) _inst_3))))) (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => A) p) (FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (fun (_x : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => A) _x) (SMulHomClass.toFunLike.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A (SMulZeroClass.toSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toZero.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddMonoid.toAddZeroClass.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, u2} R A (AddMonoid.toZero.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u3, u2} R A (AddMonoid.toAddZeroClass.{u2} A (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u3, u2} R A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4))))) (DistribMulActionHomClass.toSMulHomClass.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (AddCommMonoid.toAddMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u2} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u2 u3, u3, u3, u2} (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A (MonoidWithZero.toMonoid.{u3} R (Semiring.toMonoidWithZero.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2))) (Module.toDistribMulAction.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1))))) (Algebra.toModule.{u3, u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, u2} R A (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A (CommSemiring.toSemiring.{u2} A _inst_2)))) (Algebra.toModule.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u3, u3, u2, max u2 u3} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4 (AlgHom.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u3, u3, u2} R (Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) A _inst_1 (Polynomial.semiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u3, u3} R R _inst_1 (CommSemiring.toSemiring.{u3} R _inst_1) (Algebra.id.{u3} R _inst_1)) _inst_4))))) (Polynomial.aeval.{u3, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_4 x) p) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => A) p) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => A) p) (CommMonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => A) p) (CommSemiring.toCommMonoidWithZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) => A) p) _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align polynomial.aeval_algebra_map_eq_zero_iff_of_injective Polynomial.aeval_algebraMap_eq_zero_iff_of_injectiveₓ'. -/\ntheorem aeval_algebraMap_eq_zero_iff_of_injective {x : A} {p : R[X]}\n    (h : Function.Injective (algebraMap A B)) : aeval (algebraMap A B x) p = 0 ↔ aeval x p = 0 := by\n  rw [aeval_algebra_map_apply, ← (algebraMap A B).map_zero, h.eq_iff]\n#align polynomial.aeval_algebra_map_eq_zero_iff_of_injective Polynomial.aeval_algebraMap_eq_zero_iff_of_injective\n\nend CommSemiring\n\nend Polynomial\n\nnamespace Subalgebra\n\nopen Polynomial\n\nsection CommSemiring\n\nvariable {R A} [CommSemiring R] [CommSemiring A] [Algebra R A]\n\n/- warning: subalgebra.aeval_coe -> Subalgebra.aeval_coe is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {A : Type.{u2}} [_inst_1 : CommSemiring.{u1} R] [_inst_2 : CommSemiring.{u2} A] [_inst_3 : Algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2)] (S : Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (x : coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) (p : Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)), Eq.{succ u2} A (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_3) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_3) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> A) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) A _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) _inst_3) (Polynomial.aeval.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeSubtype.{succ u2} A (fun (x : A) => Membership.Mem.{u2, u2} A (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.hasMem.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S))))) x)) p) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (CoeTCₓ.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) A (coeSubtype.{succ u2} A (fun (x : A) => Membership.Mem.{u2, u2} A (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) (SetLike.hasMem.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) x S))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Subalgebra.toSemiring.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) (fun (_x : AlgHom.{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Subalgebra.toSemiring.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) => (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) -> (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S)) ([anonymous].{u1, u1, u2} R (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) _inst_1 (Polynomial.semiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Subalgebra.toSemiring.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u1, u1} R R _inst_1 (CommSemiring.toSemiring.{u1} R _inst_1) (Algebra.id.{u1} R _inst_1)) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S)) (Polynomial.aeval.{u1, u2} R (coeSort.{succ u2, succ (succ u2)} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Subalgebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3) A (Subalgebra.setLike.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3)) S) _inst_1 (Subalgebra.toSemiring.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) (Subalgebra.algebra.{u1, u2} R A _inst_1 (CommSemiring.toSemiring.{u2} A _inst_2) _inst_3 S) x) p))\nbut is expected to have type\n  forall {R : Type.{u2}} {A : Type.{u1}} [_inst_1 : CommSemiring.{u2} R] [_inst_2 : CommSemiring.{u1} A] [_inst_3 : Algebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2)] (S : Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (x : Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (p : Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) => A) p) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) _inst_3) (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (fun (_x : Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) => A) _x) (SMulHomClass.toFunLike.{max u1 u2, u2, u2, u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) _inst_3) R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A (SMulZeroClass.toSMul.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toAddZeroClass.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))))) (Module.toDistribMulAction.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Algebra.toModule.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1))))))) (SMulZeroClass.toSMul.{u2, u1} R A (AddMonoid.toZero.{u1} A (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (DistribSMul.toSMulZeroClass.{u2, u1} R A (AddMonoid.toAddZeroClass.{u1} A (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))))) (DistribMulAction.toDistribSMul.{u2, u1} R A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Module.toDistribMulAction.{u2, u1} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3))))) (DistribMulActionHomClass.toSMulHomClass.{max u1 u2, u2, u2, u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) _inst_3) R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u1} A (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))))) (Module.toDistribMulAction.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Algebra.toModule.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)))) (Module.toDistribMulAction.{u2, u1} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u1 u2, u2, u2, u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) _inst_3) R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2))) (Module.toDistribMulAction.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Algebra.toModule.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)))) (Module.toDistribMulAction.{u2, u1} R A (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} A (Semiring.toNonAssocSemiring.{u1} A (CommSemiring.toSemiring.{u1} A _inst_2)))) (Algebra.toModule.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u2, u2, u1, max u1 u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) _inst_3 (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) _inst_3) (AlgHom.algHomClass.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) A _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) _inst_3))))) (Polynomial.aeval.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 (Subtype.val.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Set.{u1} A) (Set.instMembershipSet.{u1} A) x (SetLike.coe.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) S)) x)) p) (Subtype.val.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Set.{u1} A) (Set.instMembershipSet.{u1} A) x (SetLike.coe.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) S)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)) (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (fun (_x : Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) => Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _x) (SMulHomClass.toFunLike.{max u1 u2, u2, u2, u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)) R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (SMulZeroClass.toSMul.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))))) (DistribSMul.toSMulZeroClass.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toAddZeroClass.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))))) (DistribMulAction.toDistribSMul.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))))) (Module.toDistribMulAction.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Algebra.toModule.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1))))))) (SMulZeroClass.toSMul.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (AddMonoid.toZero.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)))))) (DistribSMul.toSMulZeroClass.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (AddMonoid.toAddZeroClass.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)))))) (DistribMulAction.toDistribSMul.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S))))) (Module.toDistribMulAction.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)))) (Algebra.toModule.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)))))) (DistribMulActionHomClass.toSMulHomClass.{max u1 u2, u2, u2, u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)) R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (AddCommMonoid.toAddMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))))) (AddCommMonoid.toAddMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S))))) (Module.toDistribMulAction.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Algebra.toModule.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)))) (Module.toDistribMulAction.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)))) (Algebra.toModule.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S))) (NonUnitalAlgHomClass.toDistribMulActionHomClass.{max u1 u2, u2, u2, u1} (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)) R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (MonoidWithZero.toMonoid.{u2} R (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S))) (Module.toDistribMulAction.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))))) (Algebra.toModule.{u2, u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)))) (Module.toDistribMulAction.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (CommSemiring.toSemiring.{u2} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Semiring.toNonAssocSemiring.{u1} (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)))) (Algebra.toModule.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S))) (AlgHom.instNonUnitalAlgHomClassToMonoidToMonoidWithZeroToSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToNonUnitalNonAssocSemiringToNonAssocSemiringToDistribMulActionToAddCommMonoidToModuleToDistribMulActionToAddCommMonoidToModule.{u2, u2, u1, max u1 u2} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (AlgHom.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)) (AlgHom.algHomClass.{u2, u2, u1} R (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Polynomial.semiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Polynomial.algebraOfAlgebra.{u2, u2} R R _inst_1 (CommSemiring.toSemiring.{u2} R _inst_1) (Algebra.id.{u2} R _inst_1)) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S)))))) (Polynomial.aeval.{u2, u1} R (Subtype.{succ u1} A (fun (x : A) => Membership.mem.{u1, u1} A (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) (SetLike.instMembership.{u1, u1} (Subalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3) A (Subalgebra.instSetLikeSubalgebra.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3)) x S)) _inst_1 (Subalgebra.toSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) (Subalgebra.instAlgebraSubtypeMemSubalgebraInstMembershipInstSetLikeSubalgebraToSemiring.{u2, u1} R A _inst_1 (CommSemiring.toSemiring.{u1} A _inst_2) _inst_3 S) x) p))\nCase conversion may be inaccurate. Consider using '#align subalgebra.aeval_coe Subalgebra.aeval_coeₓ'. -/\n@[simp]\ntheorem aeval_coe (S : Subalgebra R A) (x : S) (p : R[X]) : aeval (x : A) p = aeval x p :=\n  aeval_algebraMap_apply A x p\n#align subalgebra.aeval_coe Subalgebra.aeval_coe\n\nend CommSemiring\n\nend Subalgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/RingTheory/Polynomial/Tower.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.451439309707252}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n\nA computable model of hereditarily finite sets with atoms\n(ZFA without infinity). This is useful for calculations in naive\nset theory.\n-/\nimport data.list.basic\nimport data.sigma\n\nvariables {α : Type*}\n\n@[derive decidable_eq]\ninductive {u} lists' (α : Type u) : bool → Type u\n| atom : α → lists' ff\n| nil : lists' tt\n| cons' {b} : lists' b → lists' tt → lists' tt\n\ndef lists (α : Type*) := Σ b, lists' α b\n\nnamespace lists'\n\ninstance [inhabited α] : ∀ b, inhabited (lists' α b)\n| tt := ⟨nil⟩\n| ff := ⟨atom (default _)⟩\n\ndef cons : lists α → lists' α tt → lists' α tt\n| ⟨b, a⟩ l := cons' a l\n\n@[simp] def to_list : ∀ {b}, lists' α b → list (lists α)\n| _ (atom a)    := []\n| _ nil         := []\n| _ (cons' a l) := ⟨_, a⟩ :: l.to_list\n\n@[simp] theorem to_list_cons (a : lists α) (l) :\n  to_list (cons a l) = a :: l.to_list :=\nby cases a; simp [cons]\n\n@[simp] def of_list : list (lists α) → lists' α tt\n| []       := nil\n| (a :: l) := cons a (of_list l)\n\n@[simp] theorem to_of_list (l : list (lists α)) : to_list (of_list l) = l :=\nby induction l; simp *\n\n@[simp] theorem of_to_list : ∀ (l : lists' α tt), of_list (to_list l) = l :=\nsuffices ∀ b (h : tt = b) (l : lists' α b),\n  let l' : lists' α tt := by rw h; exact l in\n  of_list (to_list l') = l', from this _ rfl,\nλ b h l, begin\n  induction l, {cases h}, {exact rfl},\n  case lists'.cons' : b a l IH₁ IH₂ {\n    intro, change l' with cons' a l,\n    simpa [cons] using IH₂ rfl }\nend\n\nend lists'\n\nmutual inductive lists.equiv, lists'.subset\nwith lists.equiv : lists α → lists α → Prop\n| refl (l) : lists.equiv l l\n| antisymm {l₁ l₂ : lists' α tt} :\n  lists'.subset l₁ l₂ → lists'.subset l₂ l₁ → lists.equiv ⟨_, l₁⟩ ⟨_, l₂⟩\nwith lists'.subset : lists' α tt → lists' α tt → Prop\n| nil {l} : lists'.subset lists'.nil l\n| cons {a a' l l'} : lists.equiv a a' → a' ∈ lists'.to_list l' →\n  lists'.subset l l' → lists'.subset (lists'.cons a l) l'\nlocal infix ~ := lists.equiv\n\nnamespace lists'\n\ninstance : has_subset (lists' α tt) := ⟨lists'.subset⟩\n\ninstance {b} : has_mem (lists α) (lists' α b) :=\n⟨λ a l, ∃ a' ∈ l.to_list, a ~ a'⟩\n\ntheorem mem_def {b a} {l : lists' α b} :\n  a ∈ l ↔ ∃ a' ∈ l.to_list, a ~ a' := iff.rfl\n\n@[simp] theorem mem_cons {a y l} : a ∈ @cons α y l ↔ a ~ y ∨ a ∈ l :=\nby simp [mem_def, or_and_distrib_right, exists_or_distrib]\n\ntheorem cons_subset {a} {l₁ l₂ : lists' α tt} :\n  lists'.cons a l₁ ⊆ l₂ ↔ a ∈ l₂ ∧ l₁ ⊆ l₂ :=\nbegin\n  refine ⟨λ h, _, λ ⟨⟨a', m, e⟩, s⟩, subset.cons e m s⟩,\n  generalize_hyp h' : lists'.cons a l₁ = l₁' at h,\n  cases h with l a' a'' l l' e m s, {cases a, cases h'},\n  cases a, cases a', cases h', exact ⟨⟨_, m, e⟩, s⟩\nend\n\ntheorem of_list_subset {l₁ l₂ : list (lists α)} (h : l₁ ⊆ l₂) :\n  lists'.of_list l₁ ⊆ lists'.of_list l₂ :=\nbegin\n  induction l₁, {exact subset.nil},\n  refine subset.cons (lists.equiv.refl _) _ (l₁_ih (list.subset_of_cons_subset h)),\n  simp at h, simp [h]\nend\n\n@[refl] theorem subset.refl {l : lists' α tt} : l ⊆ l :=\nby rw ← lists'.of_to_list l; exact\n   of_list_subset (list.subset.refl _)\n\ntheorem subset_nil {l : lists' α tt} :\n  l ⊆ lists'.nil → l = lists'.nil :=\nbegin\n  rw ← of_to_list l,\n  induction to_list l; intro h, {refl},\n  rcases cons_subset.1 h with ⟨⟨_, ⟨⟩, _⟩, _⟩\nend\n\ntheorem mem_of_subset' {a} {l₁ l₂ : lists' α tt}\n  (s : l₁ ⊆ l₂) (h : a ∈ l₁.to_list) : a ∈ l₂ :=\nbegin\n  induction s with _ a a' l l' e m s IH, {cases h},\n  simp at h, rcases h with rfl|h,\n  exacts [⟨_, m, e⟩, IH h]\nend\n\ntheorem subset_def {l₁ l₂ : lists' α tt} :\n  l₁ ⊆ l₂ ↔ ∀ a ∈ l₁.to_list, a ∈ l₂ :=\n⟨λ H a, mem_of_subset' H, λ H, begin\n  rw ← of_to_list l₁,\n  revert H, induction to_list l₁; intro,\n  { exact subset.nil },\n  { simp at H, exact cons_subset.2 ⟨H.1, ih H.2⟩ }\nend⟩\n\nend lists'\n\nnamespace lists\n\n@[pattern] def atom (a : α) : lists α := ⟨_, lists'.atom a⟩\n\n@[pattern] def of' (l : lists' α tt) : lists α := ⟨_, l⟩\n\n@[simp] def to_list : lists α → list (lists α)\n| ⟨b, l⟩ := l.to_list\n\ndef is_list (l : lists α) : Prop := l.1\n\ndef of_list (l : list (lists α)) : lists α := of' (lists'.of_list l)\n\ntheorem is_list_to_list (l : list (lists α)) : is_list (of_list l) :=\neq.refl _\n\ntheorem to_of_list (l : list (lists α)) : to_list (of_list l) = l :=\nby simp [of_list, of']\n\ntheorem of_to_list : ∀ {l : lists α}, is_list l → of_list (to_list l) = l\n| ⟨tt, l⟩ _ := by simp [of_list, of']\n\ninstance : inhabited (lists α) :=\n⟨of' lists'.nil⟩\n\ninstance [decidable_eq α] : decidable_eq (lists α) :=\nby unfold lists; apply_instance\n\ninstance [has_sizeof α] : has_sizeof (lists α) :=\nby unfold lists; apply_instance\n\ndef induction_mut (C : lists α → Sort*) (D : lists' α tt → Sort*)\n  (C0 : ∀ a, C (atom a)) (C1 : ∀ l, D l → C (of' l))\n  (D0 : D lists'.nil) (D1 : ∀ a l, C a → D l → D (lists'.cons a l)) :\n  pprod (∀ l, C l) (∀ l, D l) :=\nbegin\n  suffices : ∀ {b} (l : lists' α b),\n    pprod (C ⟨_, l⟩) (match b, l with\n    | tt, l := D l\n    | ff, l := punit\n    end),\n  { exact ⟨λ ⟨b, l⟩, (this _).1, λ l, (this l).2⟩ },\n  intros, induction l with a b a l IH₁ IH₂,\n  { exact ⟨C0 _, ⟨⟩⟩ },\n  { exact ⟨C1 _ D0, D0⟩ },\n  { suffices, {exact ⟨C1 _ this, this⟩},\n    exact D1 ⟨_, _⟩ _ IH₁.1 IH₂.2 }\nend\n\ndef mem (a : lists α) : lists α → Prop\n| ⟨ff, l⟩ := false\n| ⟨tt, l⟩ := a ∈ l\n\ninstance : has_mem (lists α) (lists α) := ⟨mem⟩\n\ntheorem is_list_of_mem {a : lists α} : ∀ {l : lists α}, a ∈ l → is_list l\n| ⟨_, lists'.nil⟩       _ := rfl\n| ⟨_, lists'.cons' _ _⟩ _ := rfl\n\ntheorem equiv.antisymm_iff {l₁ l₂ : lists' α tt} :\n  of' l₁ ~ of' l₂ ↔ l₁ ⊆ l₂ ∧ l₂ ⊆ l₁ :=\nbegin\n  refine ⟨λ h, _, λ ⟨h₁, h₂⟩, equiv.antisymm h₁ h₂⟩,\n  cases h with _ _ _ h₁ h₂,\n  { simp [lists'.subset.refl] }, { exact ⟨h₁, h₂⟩ }\nend\n\nattribute [refl] equiv.refl\n\ntheorem equiv_atom {a} {l : lists α} : atom a ~ l ↔ atom a = l :=\n⟨λ h, by cases h; refl, λ h, h ▸ equiv.refl _⟩\n\ntheorem equiv.symm {l₁ l₂ : lists α} (h : l₁ ~ l₂) : l₂ ~ l₁ :=\nby cases h with _ _ _ h₁ h₂; [refl, exact equiv.antisymm h₂ h₁]\n\ntheorem equiv.trans : ∀ {l₁ l₂ l₃ : lists α}, l₁ ~ l₂ → l₂ ~ l₃ → l₁ ~ l₃ :=\nbegin\n  let trans := λ (l₁ : lists α), ∀ ⦃l₂ l₃⦄, l₁ ~ l₂ → l₂ ~ l₃ → l₁ ~ l₃,\n  suffices : pprod (∀ l₁, trans l₁)\n    (∀ (l : lists' α tt) (l' ∈ l.to_list), trans l'), {exact this.1},\n  apply induction_mut,\n  { intros a l₂ l₃ h₁ h₂,\n    rwa ← equiv_atom.1 h₁ at h₂ },\n  { intros l₁ IH l₂ l₃ h₁ h₂,\n    cases h₁ with _ _ l₂, {exact h₂},\n    cases h₂ with _ _ l₃, {exact h₁},\n    cases equiv.antisymm_iff.1 h₁ with hl₁ hr₁,\n    cases equiv.antisymm_iff.1 h₂ with hl₂ hr₂,\n    apply equiv.antisymm_iff.2; split; apply lists'.subset_def.2,\n    { intros a₁ m₁,\n      rcases lists'.mem_of_subset' hl₁ m₁ with ⟨a₂, m₂, e₁₂⟩,\n      rcases lists'.mem_of_subset' hl₂ m₂ with ⟨a₃, m₃, e₂₃⟩,\n      exact ⟨a₃, m₃, IH _ m₁ e₁₂ e₂₃⟩ },\n    { intros a₃ m₃,\n      rcases lists'.mem_of_subset' hr₂ m₃ with ⟨a₂, m₂, e₃₂⟩,\n      rcases lists'.mem_of_subset' hr₁ m₂ with ⟨a₁, m₁, e₂₁⟩,\n      exact ⟨a₁, m₁, (IH _ m₁ e₂₁.symm e₃₂.symm).symm⟩ } },\n  { rintro _ ⟨⟩ },\n  { intros a l IH₁ IH₂, simpa [IH₁] using IH₂ }\nend\n\ninstance : setoid (lists α) :=\n⟨(~), equiv.refl, @equiv.symm _, @equiv.trans _⟩\n\nsection decidable\n\n@[simp] def equiv.decidable_meas :\n  (psum (Σ' (l₁ : lists α), lists α) $\n   psum (Σ' (l₁ : lists' α tt), lists' α tt)\n   Σ' (a : lists α), lists' α tt) → ℕ\n| (psum.inl ⟨l₁, l₂⟩) := sizeof l₁ + sizeof l₂\n| (psum.inr $ psum.inl ⟨l₁, l₂⟩) := sizeof l₁ + sizeof l₂\n| (psum.inr $ psum.inr ⟨l₁, l₂⟩) := sizeof l₁ + sizeof l₂\n\nopen well_founded_tactics\n\ntheorem sizeof_pos {b} (l : lists' α b) : 0 < sizeof l :=\nby cases l; unfold_sizeof; trivial_nat_lt\n\ntheorem lt_sizeof_cons' {b} (a : lists' α b) (l) :\n  sizeof (⟨b, a⟩ : lists α) < sizeof (lists'.cons' a l) :=\nby {unfold_sizeof, apply sizeof_pos}\n\n@[instance] mutual def equiv.decidable, subset.decidable, mem.decidable [decidable_eq α]\nwith equiv.decidable : ∀ l₁ l₂ : lists α, decidable (l₁ ~ l₂)\n| ⟨ff, l₁⟩ ⟨ff, l₂⟩ := decidable_of_iff' (l₁ = l₂) $\n  by cases l₁; refine equiv_atom.trans (by simp [atom])\n| ⟨ff, l₁⟩ ⟨tt, l₂⟩ := is_false $ by rintro ⟨⟩\n| ⟨tt, l₁⟩ ⟨ff, l₂⟩ := is_false $ by rintro ⟨⟩\n| ⟨tt, l₁⟩ ⟨tt, l₂⟩ := begin\n  haveI :=\n    have sizeof l₁ + sizeof l₂ <\n         sizeof (⟨tt, l₁⟩ : lists α) + sizeof (⟨tt, l₂⟩ : lists α),\n    by default_dec_tac,\n    subset.decidable l₁ l₂,\n  haveI :=\n    have sizeof l₂ + sizeof l₁ <\n         sizeof (⟨tt, l₁⟩ : lists α) + sizeof (⟨tt, l₂⟩ : lists α),\n    by default_dec_tac,\n    subset.decidable l₂ l₁,\n  exact decidable_of_iff' _ equiv.antisymm_iff,\nend\nwith subset.decidable : ∀ l₁ l₂ : lists' α tt, decidable (l₁ ⊆ l₂)\n| lists'.nil l₂ := is_true subset.nil\n| (@lists'.cons' _ b a l₁) l₂ := begin\n  haveI :=\n    have sizeof (⟨b, a⟩ : lists α) + sizeof l₂ <\n         sizeof (lists'.cons' a l₁) + sizeof l₂,\n    from add_lt_add_right (lt_sizeof_cons' _ _) _,\n    mem.decidable ⟨b, a⟩ l₂,\n  haveI :=\n    have sizeof l₁ + sizeof l₂ <\n         sizeof (lists'.cons' a l₁) + sizeof l₂,\n    by default_dec_tac,\n    subset.decidable l₁ l₂,\n  exact decidable_of_iff' _ (@lists'.cons_subset _ ⟨_, _⟩ _ _)\nend\nwith mem.decidable : ∀ (a : lists α) (l : lists' α tt), decidable (a ∈ l)\n| a lists'.nil := is_false $ by rintro ⟨_, ⟨⟩, _⟩\n| a (lists'.cons' b l₂) := begin\n  haveI :=\n    have sizeof a + sizeof (⟨_, b⟩ : lists α) <\n         sizeof a + sizeof (lists'.cons' b l₂),\n    from add_lt_add_left (lt_sizeof_cons' _ _) _,\n    equiv.decidable a ⟨_, b⟩,\n  haveI :=\n    have sizeof a + sizeof l₂ <\n         sizeof a + sizeof (lists'.cons' b l₂),\n    by default_dec_tac,\n    mem.decidable a l₂,\n  refine decidable_of_iff' (a ~ ⟨_, b⟩ ∨ a ∈ l₂) _,\n  rw ← lists'.mem_cons, refl\nend\nusing_well_founded {\n  rel_tac := λ _ _, `[exact ⟨_, measure_wf equiv.decidable_meas⟩],\n  dec_tac := `[assumption] }\n\nend decidable\n\nend lists\n\nnamespace lists'\n\ntheorem mem_equiv_left {l : lists' α tt} :\n  ∀ {a a'}, a ~ a' → (a ∈ l ↔ a' ∈ l) :=\nsuffices ∀ {a a'}, a ~ a' → a ∈ l → a' ∈ l,\n  from λ a a' e, ⟨this e, this e.symm⟩,\nλ a₁ a₂ e₁ ⟨a₃, m₃, e₂⟩, ⟨_, m₃, e₁.symm.trans e₂⟩\n\ntheorem mem_of_subset {a} {l₁ l₂ : lists' α tt}\n  (s : l₁ ⊆ l₂) : a ∈ l₁ → a ∈ l₂ | ⟨a', m, e⟩ :=\n(mem_equiv_left e).2 (mem_of_subset' s m)\n\ntheorem subset.trans {l₁ l₂ l₃ : lists' α tt}\n  (h₁ : l₁ ⊆ l₂) (h₂ : l₂ ⊆ l₃) : l₁ ⊆ l₃ :=\nsubset_def.2 $ λ a₁ m₁, mem_of_subset h₂ $ mem_of_subset' h₁ m₁\n\nend lists'\n\ndef finsets (α : Type*) := quotient (@lists.setoid α)\n\nnamespace finsets\n\ninstance : has_emptyc (finsets α) := ⟨⟦lists.of' lists'.nil⟧⟩\n\ninstance : inhabited (finsets α) := ⟨∅⟩\n\ninstance [decidable_eq α] : decidable_eq (finsets α) :=\nby unfold finsets; apply_instance\n\nend finsets\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/set_theory/lists.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947425132315, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.45142263277744693}}
{"text": "/-\nCopyright (c) 2014 Jeremy Avigad. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jeremy Avigad, Leonardo de Moura, Johannes Hölzl, Mario Carneiro\n\n-- QUESTION: can make the first argument in ∀ x ∈ a, ... implicit?\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.order.complete_boolean_algebra\nimport Mathlib.data.sigma.basic\nimport Mathlib.order.galois_connection\nimport Mathlib.order.directed\nimport Mathlib.PostPort\n\nuniverses u v x y u_1 u_2 u_3 w \n\nnamespace Mathlib\n\nnamespace set\n\n\nprotected instance lattice_set {α : Type u} : complete_lattice (set α) :=\n  complete_lattice.mk boolean_algebra.sup boolean_algebra.le boolean_algebra.lt sorry sorry sorry sorry sorry sorry\n    boolean_algebra.inf sorry sorry sorry boolean_algebra.top sorry boolean_algebra.bot sorry\n    (fun (s : set (set α)) => set_of fun (a : α) => ∃ (t : set α), ∃ (H : t ∈ s), a ∈ t)\n    (fun (s : set (set α)) => set_of fun (a : α) => ∀ (t : set α), t ∈ s → a ∈ t) sorry sorry sorry sorry\n\n/-- Image is monotone. See `set.image_image` for the statement in terms of `⊆`. -/\ntheorem monotone_image {α : Type u} {β : Type v} {f : α → β} : monotone (image f) :=\n  fun (s t : set α) (h : s ⊆ t) => image_subset f h\n\ntheorem monotone_inter {α : Type u} {β : Type v} [preorder β] {f : β → set α} {g : β → set α} (hf : monotone f) (hg : monotone g) : monotone fun (x : β) => f x ∩ g x :=\n  fun (b₁ b₂ : β) (h : b₁ ≤ b₂) => inter_subset_inter (hf h) (hg h)\n\ntheorem monotone_union {α : Type u} {β : Type v} [preorder β] {f : β → set α} {g : β → set α} (hf : monotone f) (hg : monotone g) : monotone fun (x : β) => f x ∪ g x :=\n  fun (b₁ b₂ : β) (h : b₁ ≤ b₂) => union_subset_union (hf h) (hg h)\n\ntheorem monotone_set_of {α : Type u} {β : Type v} [preorder α] {p : α → β → Prop} (hp : ∀ (b : β), monotone fun (a : α) => p a b) : monotone fun (a : α) => set_of fun (b : β) => p a b :=\n  fun (a a' : α) (h : a ≤ a') (b : β) => hp b h\n\nprotected theorem image_preimage {α : Type u} {β : Type v} {f : α → β} : galois_connection (image f) (preimage f) :=\n  fun (a : set α) (b : set β) => image_subset_iff\n\n/-- `kern_image f s` is the set of `y` such that `f ⁻¹ y ⊆ s` -/\ndef kern_image {α : Type u} {β : Type v} (f : α → β) (s : set α) : set β :=\n  set_of fun (y : β) => ∀ {x : α}, f x = y → x ∈ s\n\nprotected theorem preimage_kern_image {α : Type u} {β : Type v} {f : α → β} : galois_connection (preimage f) (kern_image f) := sorry\n\n/- union and intersection over a family of sets indexed by a type -/\n\n/-- Indexed union of a family of sets -/\ndef Union {β : Type v} {ι : Sort x} (s : ι → set β) : set β :=\n  supr s\n\n/-- Indexed intersection of a family of sets -/\ndef Inter {β : Type v} {ι : Sort x} (s : ι → set β) : set β :=\n  infi s\n\n@[simp] theorem mem_Union {β : Type v} {ι : Sort x} {x : β} {s : ι → set β} : x ∈ Union s ↔ ∃ (i : ι), x ∈ s i := sorry\n\n/- alternative proof: dsimp [Union, supr, Sup]; simp -/\n\ntheorem set_of_exists {β : Type v} {ι : Sort x} (p : ι → β → Prop) : (set_of fun (x : β) => ∃ (i : ι), p i x) = Union fun (i : ι) => set_of fun (x : β) => p i x :=\n  ext fun (i : β) => iff.symm mem_Union\n\n@[simp] theorem mem_Inter {β : Type v} {ι : Sort x} {x : β} {s : ι → set β} : x ∈ Inter s ↔ ∀ (i : ι), x ∈ s i := sorry\n\ntheorem set_of_forall {β : Type v} {ι : Sort x} (p : ι → β → Prop) : (set_of fun (x : β) => ∀ (i : ι), p i x) = Inter fun (i : ι) => set_of fun (x : β) => p i x :=\n  ext fun (i : β) => iff.symm mem_Inter\n\n-- TODO: should be simpler when sets' order is based on lattices\n\ntheorem Union_subset {β : Type v} {ι : Sort x} {s : ι → set β} {t : set β} (h : ∀ (i : ι), s i ⊆ t) : (Union fun (i : ι) => s i) ⊆ t :=\n  supr_le h\n\ntheorem Union_subset_iff {β : Type v} {ι : Sort x} {s : ι → set β} {t : set β} : (Union fun (i : ι) => s i) ⊆ t ↔ ∀ (i : ι), s i ⊆ t :=\n  { mp := fun (h : (Union fun (i : ι) => s i) ⊆ t) (i : ι) => subset.trans (le_supr s i) h, mpr := Union_subset }\n\ntheorem mem_Inter_of_mem {β : Type v} {ι : Sort x} {x : β} {s : ι → set β} : (∀ (i : ι), x ∈ s i) → x ∈ Inter fun (i : ι) => s i :=\n  iff.mpr mem_Inter\n\n-- TODO: should be simpler when sets' order is based on lattices\n\ntheorem subset_Inter {β : Type v} {ι : Sort x} {t : set β} {s : ι → set β} (h : ∀ (i : ι), t ⊆ s i) : t ⊆ Inter fun (i : ι) => s i :=\n  le_infi h\n\ntheorem subset_Inter_iff {β : Type v} {ι : Sort x} {t : set β} {s : ι → set β} : (t ⊆ Inter fun (i : ι) => s i) ↔ ∀ (i : ι), t ⊆ s i :=\n  le_infi_iff\n\ntheorem subset_Union {β : Type v} {ι : Sort x} (s : ι → set β) (i : ι) : s i ⊆ Union fun (i : ι) => s i :=\n  le_supr\n\n-- This rather trivial consequence is convenient with `apply`,\n\n-- and has `i` explicit for this use case.\n\ntheorem subset_subset_Union {β : Type v} {ι : Sort x} {A : set β} {s : ι → set β} (i : ι) (h : A ⊆ s i) : A ⊆ Union fun (i : ι) => s i :=\n  subset.trans h (subset_Union s i)\n\ntheorem Inter_subset {β : Type v} {ι : Sort x} (s : ι → set β) (i : ι) : (Inter fun (i : ι) => s i) ⊆ s i :=\n  infi_le\n\ntheorem Inter_subset_of_subset {α : Type u} {ι : Sort x} {s : ι → set α} {t : set α} (i : ι) (h : s i ⊆ t) : (Inter fun (i : ι) => s i) ⊆ t :=\n  subset.trans (Inter_subset s i) h\n\ntheorem Inter_subset_Inter {α : Type u} {ι : Sort x} {s : ι → set α} {t : ι → set α} (h : ∀ (i : ι), s i ⊆ t i) : (Inter fun (i : ι) => s i) ⊆ Inter fun (i : ι) => t i :=\n  subset_Inter fun (i : ι) => Inter_subset_of_subset i (h i)\n\ntheorem Inter_subset_Inter2 {α : Type u} {ι : Sort x} {ι' : Sort y} {s : ι → set α} {t : ι' → set α} (h : ∀ (j : ι'), ∃ (i : ι), s i ⊆ t j) : (Inter fun (i : ι) => s i) ⊆ Inter fun (j : ι') => t j := sorry\n\ntheorem Inter_set_of {α : Type u} {ι : Sort x} (P : ι → α → Prop) : (Inter fun (i : ι) => set_of fun (x : α) => P i x) = set_of fun (x : α) => ∀ (i : ι), P i x := sorry\n\ntheorem Union_const {β : Type v} {ι : Sort x} [Nonempty ι] (s : set β) : (Union fun (i : ι) => s) = s := sorry\n\ntheorem Inter_const {β : Type v} {ι : Sort x} [Nonempty ι] (s : set β) : (Inter fun (i : ι) => s) = s := sorry\n\n@[simp] theorem compl_Union {β : Type v} {ι : Sort x} (s : ι → set β) : (Union fun (i : ι) => s i)ᶜ = Inter fun (i : ι) => s iᶜ := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem compl_Inter {β : Type v} {ι : Sort x} (s : ι → set β) : (Inter fun (i : ι) => s i)ᶜ = Union fun (i : ι) => s iᶜ := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem Union_eq_comp_Inter_comp {β : Type v} {ι : Sort x} (s : ι → set β) : (Union fun (i : ι) => s i) = ((Inter fun (i : ι) => s iᶜ)ᶜ) := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem Inter_eq_comp_Union_comp {β : Type v} {ι : Sort x} (s : ι → set β) : (Inter fun (i : ι) => s i) = ((Union fun (i : ι) => s iᶜ)ᶜ) := sorry\n\ntheorem inter_Union {β : Type v} {ι : Sort x} (s : set β) (t : ι → set β) : (s ∩ Union fun (i : ι) => t i) = Union fun (i : ι) => s ∩ t i := sorry\n\ntheorem Union_inter {β : Type v} {ι : Sort x} (s : set β) (t : ι → set β) : (Union fun (i : ι) => t i) ∩ s = Union fun (i : ι) => t i ∩ s := sorry\n\ntheorem Union_union_distrib {β : Type v} {ι : Sort x} (s : ι → set β) (t : ι → set β) : (Union fun (i : ι) => s i ∪ t i) = (Union fun (i : ι) => s i) ∪ Union fun (i : ι) => t i := sorry\n\ntheorem Inter_inter_distrib {β : Type v} {ι : Sort x} (s : ι → set β) (t : ι → set β) : (Inter fun (i : ι) => s i ∩ t i) = (Inter fun (i : ι) => s i) ∩ Inter fun (i : ι) => t i := sorry\n\ntheorem union_Union {β : Type v} {ι : Sort x} [Nonempty ι] (s : set β) (t : ι → set β) : (s ∪ Union fun (i : ι) => t i) = Union fun (i : ι) => s ∪ t i := sorry\n\ntheorem Union_union {β : Type v} {ι : Sort x} [Nonempty ι] (s : set β) (t : ι → set β) : (Union fun (i : ι) => t i) ∪ s = Union fun (i : ι) => t i ∪ s := sorry\n\ntheorem inter_Inter {β : Type v} {ι : Sort x} [Nonempty ι] (s : set β) (t : ι → set β) : (s ∩ Inter fun (i : ι) => t i) = Inter fun (i : ι) => s ∩ t i := sorry\n\ntheorem Inter_inter {β : Type v} {ι : Sort x} [Nonempty ι] (s : set β) (t : ι → set β) : (Inter fun (i : ι) => t i) ∩ s = Inter fun (i : ι) => t i ∩ s := sorry\n\n-- classical\n\ntheorem union_Inter {β : Type v} {ι : Sort x} (s : set β) (t : ι → set β) : (s ∪ Inter fun (i : ι) => t i) = Inter fun (i : ι) => s ∪ t i := sorry\n\ntheorem Union_diff {β : Type v} {ι : Sort x} (s : set β) (t : ι → set β) : (Union fun (i : ι) => t i) \\ s = Union fun (i : ι) => t i \\ s :=\n  Union_inter (fun (a : β) => a ∈ s → False) fun (i : ι) => t i\n\ntheorem diff_Union {β : Type v} {ι : Sort x} [Nonempty ι] (s : set β) (t : ι → set β) : (s \\ Union fun (i : ι) => t i) = Inter fun (i : ι) => s \\ t i := sorry\n\ntheorem diff_Inter {β : Type v} {ι : Sort x} (s : set β) (t : ι → set β) : (s \\ Inter fun (i : ι) => t i) = Union fun (i : ι) => s \\ t i := sorry\n\ntheorem directed_on_Union {α : Type u} {r : α → α → Prop} {ι : Sort v} {f : ι → set α} (hd : directed has_subset.subset f) (h : ∀ (x : ι), directed_on r (f x)) : directed_on r (Union fun (x : ι) => f x) := sorry\n\ntheorem Union_inter_subset {ι : Sort u_1} {α : Type u_2} {s : ι → set α} {t : ι → set α} : (Union fun (i : ι) => s i ∩ t i) ⊆ (Union fun (i : ι) => s i) ∩ Union fun (i : ι) => t i := sorry\n\ntheorem Union_inter_of_monotone {ι : Type u_1} {α : Type u_2} [semilattice_sup ι] {s : ι → set α} {t : ι → set α} (hs : monotone s) (ht : monotone t) : (Union fun (i : ι) => s i ∩ t i) = (Union fun (i : ι) => s i) ∩ Union fun (i : ι) => t i := sorry\n\n/-- An equality version of this lemma is `Union_Inter_of_monotone` in `data.set.finite`. -/\ntheorem Union_Inter_subset {ι : Sort u_1} {ι' : Sort u_2} {α : Type u_3} {s : ι → ι' → set α} : (Union fun (j : ι') => Inter fun (i : ι) => s i j) ⊆ Inter fun (i : ι) => Union fun (j : ι') => s i j := sorry\n\n/- bounded unions and intersections -/\n\ntheorem mem_bUnion_iff {α : Type u} {β : Type v} {s : set α} {t : α → set β} {y : β} : (y ∈ Union fun (x : α) => Union fun (H : x ∈ s) => t x) ↔ ∃ (x : α), ∃ (H : x ∈ s), y ∈ t x := sorry\n\ntheorem mem_bInter_iff {α : Type u} {β : Type v} {s : set α} {t : α → set β} {y : β} : (y ∈ Inter fun (x : α) => Inter fun (H : x ∈ s) => t x) ↔ ∀ (x : α), x ∈ s → y ∈ t x := sorry\n\ntheorem mem_bUnion {α : Type u} {β : Type v} {s : set α} {t : α → set β} {x : α} {y : β} (xs : x ∈ s) (ytx : y ∈ t x) : y ∈ Union fun (x : α) => Union fun (H : x ∈ s) => t x := sorry\n\ntheorem mem_bInter {α : Type u} {β : Type v} {s : set α} {t : α → set β} {y : β} (h : ∀ (x : α), x ∈ s → y ∈ t x) : y ∈ Inter fun (x : α) => Inter fun (H : x ∈ s) => t x :=\n  eq.mpr (id (Eq.trans (propext mem_Inter) (forall_congr_eq fun (i : α) => propext mem_Inter))) h\n\ntheorem bUnion_subset {α : Type u} {β : Type v} {s : set α} {t : set β} {u : α → set β} (h : ∀ (x : α), x ∈ s → u x ⊆ t) : (Union fun (x : α) => Union fun (H : x ∈ s) => u x) ⊆ t :=\n  (fun (this : (supr fun (x : α) => supr fun (H : x ∈ s) => u x) ≤ t) => this) (supr_le fun (x : α) => supr_le (h x))\n\ntheorem subset_bInter {α : Type u} {β : Type v} {s : set α} {t : set β} {u : α → set β} (h : ∀ (x : α), x ∈ s → t ⊆ u x) : t ⊆ Inter fun (x : α) => Inter fun (H : x ∈ s) => u x :=\n  subset_Inter fun (x : α) => subset_Inter (h x)\n\ntheorem subset_bUnion_of_mem {α : Type u} {β : Type v} {s : set α} {u : α → set β} {x : α} (xs : x ∈ s) : u x ⊆ Union fun (x : α) => Union fun (H : x ∈ s) => u x :=\n  (fun (this : u x ≤ supr fun (x : α) => supr fun (H : x ∈ s) => u x) => this)\n    (le_supr_of_le x (le_supr (fun (xs : x ∈ s) => u x) xs))\n\ntheorem bInter_subset_of_mem {α : Type u} {β : Type v} {s : set α} {t : α → set β} {x : α} (xs : x ∈ s) : (Inter fun (x : α) => Inter fun (H : x ∈ s) => t x) ⊆ t x :=\n  (fun (this : (infi fun (x : α) => infi fun (H : x ∈ s) => t x) ≤ t x) => this)\n    (infi_le_of_le x (infi_le (fun (H : x ∈ s) => t x) xs))\n\ntheorem bUnion_subset_bUnion_left {α : Type u} {β : Type v} {s : set α} {s' : set α} {t : α → set β} (h : s ⊆ s') : (Union fun (x : α) => Union fun (H : x ∈ s) => t x) ⊆ Union fun (x : α) => Union fun (H : x ∈ s') => t x :=\n  bUnion_subset fun (x : α) (xs : x ∈ s) => subset_bUnion_of_mem (h xs)\n\ntheorem bInter_subset_bInter_left {α : Type u} {β : Type v} {s : set α} {s' : set α} {t : α → set β} (h : s' ⊆ s) : (Inter fun (x : α) => Inter fun (H : x ∈ s) => t x) ⊆ Inter fun (x : α) => Inter fun (H : x ∈ s') => t x :=\n  subset_bInter fun (x : α) (xs : x ∈ s') => bInter_subset_of_mem (h xs)\n\ntheorem bUnion_subset_bUnion_right {α : Type u} {β : Type v} {s : set α} {t1 : α → set β} {t2 : α → set β} (h : ∀ (x : α), x ∈ s → t1 x ⊆ t2 x) : (Union fun (x : α) => Union fun (H : x ∈ s) => t1 x) ⊆ Union fun (x : α) => Union fun (H : x ∈ s) => t2 x :=\n  bUnion_subset fun (x : α) (xs : x ∈ s) => subset.trans (h x xs) (subset_bUnion_of_mem xs)\n\ntheorem bInter_subset_bInter_right {α : Type u} {β : Type v} {s : set α} {t1 : α → set β} {t2 : α → set β} (h : ∀ (x : α), x ∈ s → t1 x ⊆ t2 x) : (Inter fun (x : α) => Inter fun (H : x ∈ s) => t1 x) ⊆ Inter fun (x : α) => Inter fun (H : x ∈ s) => t2 x :=\n  subset_bInter fun (x : α) (xs : x ∈ s) => subset.trans (bInter_subset_of_mem xs) (h x xs)\n\ntheorem bUnion_subset_bUnion {α : Type u} {β : Type v} {γ : Type u_1} {s : set α} {t : α → set β} {s' : set γ} {t' : γ → set β} (h : ∀ (x : α) (H : x ∈ s), ∃ (y : γ), ∃ (H : y ∈ s'), t x ⊆ t' y) : (Union fun (x : α) => Union fun (H : x ∈ s) => t x) ⊆ Union fun (y : γ) => Union fun (H : y ∈ s') => t' y := sorry\n\ntheorem bInter_mono' {α : Type u} {β : Type v} {s : set α} {s' : set α} {t : α → set β} {t' : α → set β} (hs : s ⊆ s') (h : ∀ (x : α), x ∈ s → t x ⊆ t' x) : (Inter fun (x : α) => Inter fun (H : x ∈ s') => t x) ⊆ Inter fun (x : α) => Inter fun (H : x ∈ s) => t' x := sorry\n\ntheorem bInter_mono {α : Type u} {β : Type v} {s : set α} {t : α → set β} {t' : α → set β} (h : ∀ (x : α), x ∈ s → t x ⊆ t' x) : (Inter fun (x : α) => Inter fun (H : x ∈ s) => t x) ⊆ Inter fun (x : α) => Inter fun (H : x ∈ s) => t' x :=\n  bInter_mono' (subset.refl s) h\n\ntheorem bUnion_mono {α : Type u} {β : Type v} {s : set α} {t : α → set β} {t' : α → set β} (h : ∀ (x : α), x ∈ s → t x ⊆ t' x) : (Union fun (x : α) => Union fun (H : x ∈ s) => t x) ⊆ Union fun (x : α) => Union fun (H : x ∈ s) => t' x :=\n  bUnion_subset_bUnion fun (x : α) (x_in : x ∈ s) => Exists.intro x (Exists.intro x_in (h x x_in))\n\ntheorem bUnion_eq_Union {α : Type u} {β : Type v} (s : set α) (t : (x : α) → x ∈ s → set β) : (Union fun (x : α) => Union fun (H : x ∈ s) => t x H) = Union fun (x : ↥s) => t (↑x) (subtype.property x) :=\n  supr_subtype'\n\ntheorem bInter_eq_Inter {α : Type u} {β : Type v} (s : set α) (t : (x : α) → x ∈ s → set β) : (Inter fun (x : α) => Inter fun (H : x ∈ s) => t x H) = Inter fun (x : ↥s) => t (↑x) (subtype.property x) :=\n  infi_subtype'\n\ntheorem bInter_empty {α : Type u} {β : Type v} (u : α → set β) : (Inter fun (x : α) => Inter fun (H : x ∈ ∅) => u x) = univ :=\n  (fun (this : (infi fun (x : α) => infi fun (H : x ∈ ∅) => u x) = ⊤) => this) infi_emptyset\n\ntheorem bInter_univ {α : Type u} {β : Type v} (u : α → set β) : (Inter fun (x : α) => Inter fun (H : x ∈ univ) => u x) = Inter fun (x : α) => u x :=\n  infi_univ\n\n-- TODO(Jeremy): here is an artifact of the the encoding of bounded intersection:\n\n-- without dsimp, the next theorem fails to type check, because there is a lambda\n\n-- in a type that needs to be contracted. Using simp [eq_of_mem_singleton xa] also works.\n\n@[simp] theorem bInter_singleton {α : Type u} {β : Type v} (a : α) (s : α → set β) : (Inter fun (x : α) => Inter fun (H : x ∈ singleton a) => s x) = s a := sorry\n\ntheorem bInter_union {α : Type u} {β : Type v} (s : set α) (t : set α) (u : α → set β) : (Inter fun (x : α) => Inter fun (H : x ∈ s ∪ t) => u x) =\n  (Inter fun (x : α) => Inter fun (H : x ∈ s) => u x) ∩ Inter fun (x : α) => Inter fun (H : x ∈ t) => u x := sorry\n\n-- TODO(Jeremy): simp [insert_eq, bInter_union] doesn't work\n\n@[simp] theorem bInter_insert {α : Type u} {β : Type v} (a : α) (s : set α) (t : α → set β) : (Inter fun (x : α) => Inter fun (H : x ∈ insert a s) => t x) = t a ∩ Inter fun (x : α) => Inter fun (H : x ∈ s) => t x := sorry\n\n-- TODO(Jeremy): another example of where an annotation is needed\n\ntheorem bInter_pair {α : Type u} {β : Type v} (a : α) (b : α) (s : α → set β) : (Inter fun (x : α) => Inter fun (H : x ∈ insert a (singleton b)) => s x) = s a ∩ s b := sorry\n\ntheorem bUnion_empty {α : Type u} {β : Type v} (s : α → set β) : (Union fun (x : α) => Union fun (H : x ∈ ∅) => s x) = ∅ :=\n  supr_emptyset\n\ntheorem bUnion_univ {α : Type u} {β : Type v} (s : α → set β) : (Union fun (x : α) => Union fun (H : x ∈ univ) => s x) = Union fun (x : α) => s x :=\n  supr_univ\n\n@[simp] theorem bUnion_singleton {α : Type u} {β : Type v} (a : α) (s : α → set β) : (Union fun (x : α) => Union fun (H : x ∈ singleton a) => s x) = s a :=\n  supr_singleton\n\n@[simp] theorem bUnion_of_singleton {α : Type u} (s : set α) : (Union fun (x : α) => Union fun (H : x ∈ s) => singleton x) = s := sorry\n\ntheorem bUnion_union {α : Type u} {β : Type v} (s : set α) (t : set α) (u : α → set β) : (Union fun (x : α) => Union fun (H : x ∈ s ∪ t) => u x) =\n  (Union fun (x : α) => Union fun (H : x ∈ s) => u x) ∪ Union fun (x : α) => Union fun (H : x ∈ t) => u x :=\n  supr_union\n\n@[simp] theorem Union_subtype {α : Type u_1} {β : Type u_2} (s : set α) (f : α → set β) : (Union fun (i : ↥s) => f ↑i) = Union fun (i : α) => Union fun (H : i ∈ s) => f i :=\n  Eq.symm (bUnion_eq_Union s fun (x : α) (_x : x ∈ s) => f x)\n\n-- TODO(Jeremy): once again, simp doesn't do it alone.\n\n@[simp] theorem bUnion_insert {α : Type u} {β : Type v} (a : α) (s : set α) (t : α → set β) : (Union fun (x : α) => Union fun (H : x ∈ insert a s) => t x) = t a ∪ Union fun (x : α) => Union fun (H : x ∈ s) => t x := sorry\n\ntheorem bUnion_pair {α : Type u} {β : Type v} (a : α) (b : α) (s : α → set β) : (Union fun (x : α) => Union fun (H : x ∈ insert a (singleton b)) => s x) = s a ∪ s b := sorry\n\n@[simp] theorem compl_bUnion {α : Type u} {β : Type v} (s : set α) (t : α → set β) : (Union fun (i : α) => Union fun (H : i ∈ s) => t i)ᶜ = Inter fun (i : α) => Inter fun (H : i ∈ s) => t iᶜ := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem compl_bInter {α : Type u} {β : Type v} (s : set α) (t : α → set β) : (Inter fun (i : α) => Inter fun (H : i ∈ s) => t i)ᶜ = Union fun (i : α) => Union fun (H : i ∈ s) => t iᶜ := sorry\n\ntheorem inter_bUnion {α : Type u} {β : Type v} (s : set α) (t : α → set β) (u : set β) : (u ∩ Union fun (i : α) => Union fun (H : i ∈ s) => t i) = Union fun (i : α) => Union fun (H : i ∈ s) => u ∩ t i := sorry\n\ntheorem bUnion_inter {α : Type u} {β : Type v} (s : set α) (t : α → set β) (u : set β) : (Union fun (i : α) => Union fun (H : i ∈ s) => t i) ∩ u = Union fun (i : α) => Union fun (H : i ∈ s) => t i ∩ u := sorry\n\n/-- Intersection of a set of sets. -/\ndef sInter {α : Type u} (S : set (set α)) : set α :=\n  Inf S\n\nprefix:110 \"⋂₀\" => Mathlib.set.sInter\n\ntheorem mem_sUnion_of_mem {α : Type u} {x : α} {t : set α} {S : set (set α)} (hx : x ∈ t) (ht : t ∈ S) : x ∈ ⋃₀S :=\n  Exists.intro t (Exists.intro ht hx)\n\ntheorem mem_sUnion {α : Type u} {x : α} {S : set (set α)} : x ∈ ⋃₀S ↔ ∃ (t : set α), ∃ (H : t ∈ S), x ∈ t :=\n  iff.rfl\n\n-- is this theorem really necessary?\n\ntheorem not_mem_of_not_mem_sUnion {α : Type u} {x : α} {t : set α} {S : set (set α)} (hx : ¬x ∈ ⋃₀S) (ht : t ∈ S) : ¬x ∈ t :=\n  fun (h : x ∈ t) => hx (Exists.intro t (Exists.intro ht h))\n\n@[simp] theorem mem_sInter {α : Type u} {x : α} {S : set (set α)} : x ∈ ⋂₀S ↔ ∀ (t : set α), t ∈ S → x ∈ t :=\n  iff.rfl\n\ntheorem sInter_subset_of_mem {α : Type u} {S : set (set α)} {t : set α} (tS : t ∈ S) : ⋂₀S ⊆ t :=\n  Inf_le tS\n\ntheorem subset_sUnion_of_mem {α : Type u} {S : set (set α)} {t : set α} (tS : t ∈ S) : t ⊆ ⋃₀S :=\n  le_Sup tS\n\ntheorem subset_sUnion_of_subset {α : Type u} {s : set α} (t : set (set α)) (u : set α) (h₁ : s ⊆ u) (h₂ : u ∈ t) : s ⊆ ⋃₀t :=\n  subset.trans h₁ (subset_sUnion_of_mem h₂)\n\ntheorem sUnion_subset {α : Type u} {S : set (set α)} {t : set α} (h : ∀ (t' : set α), t' ∈ S → t' ⊆ t) : ⋃₀S ⊆ t :=\n  Sup_le h\n\ntheorem sUnion_subset_iff {α : Type u} {s : set (set α)} {t : set α} : ⋃₀s ⊆ t ↔ ∀ (t' : set α), t' ∈ s → t' ⊆ t :=\n  { mp := fun (h : ⋃₀s ⊆ t) (t' : set α) (ht' : t' ∈ s) => subset.trans (subset_sUnion_of_mem ht') h,\n    mpr := sUnion_subset }\n\ntheorem subset_sInter {α : Type u} {S : set (set α)} {t : set α} (h : ∀ (t' : set α), t' ∈ S → t ⊆ t') : t ⊆ ⋂₀S :=\n  le_Inf h\n\ntheorem sUnion_subset_sUnion {α : Type u} {S : set (set α)} {T : set (set α)} (h : S ⊆ T) : ⋃₀S ⊆ ⋃₀T :=\n  sUnion_subset fun (s : set α) (hs : s ∈ S) => subset_sUnion_of_mem (h hs)\n\ntheorem sInter_subset_sInter {α : Type u} {S : set (set α)} {T : set (set α)} (h : S ⊆ T) : ⋂₀T ⊆ ⋂₀S :=\n  subset_sInter fun (s : set α) (hs : s ∈ S) => sInter_subset_of_mem (h hs)\n\n@[simp] theorem sUnion_empty {α : Type u} : ⋃₀∅ = ∅ :=\n  Sup_empty\n\n@[simp] theorem sInter_empty {α : Type u} : ⋂₀∅ = univ :=\n  Inf_empty\n\n@[simp] theorem sUnion_singleton {α : Type u} (s : set α) : ⋃₀singleton s = s :=\n  Sup_singleton\n\n@[simp] theorem sInter_singleton {α : Type u} (s : set α) : ⋂₀singleton s = s :=\n  Inf_singleton\n\n@[simp] theorem sUnion_eq_empty {α : Type u} {S : set (set α)} : ⋃₀S = ∅ ↔ ∀ (s : set α), s ∈ S → s = ∅ :=\n  Sup_eq_bot\n\n@[simp] theorem sInter_eq_univ {α : Type u} {S : set (set α)} : ⋂₀S = univ ↔ ∀ (s : set α), s ∈ S → s = univ :=\n  Inf_eq_top\n\n@[simp] theorem nonempty_sUnion {α : Type u} {S : set (set α)} : set.nonempty (⋃₀S) ↔ ∃ (s : set α), ∃ (H : s ∈ S), set.nonempty s := sorry\n\ntheorem nonempty.of_sUnion {α : Type u} {s : set (set α)} (h : set.nonempty (⋃₀s)) : set.nonempty s := sorry\n\ntheorem nonempty.of_sUnion_eq_univ {α : Type u} [Nonempty α] {s : set (set α)} (h : ⋃₀s = univ) : set.nonempty s :=\n  nonempty.of_sUnion (Eq.symm h ▸ univ_nonempty)\n\ntheorem sUnion_union {α : Type u} (S : set (set α)) (T : set (set α)) : ⋃₀(S ∪ T) = ⋃₀S ∪ ⋃₀T :=\n  Sup_union\n\ntheorem sInter_union {α : Type u} (S : set (set α)) (T : set (set α)) : ⋂₀(S ∪ T) = ⋂₀S ∩ ⋂₀T :=\n  Inf_union\n\ntheorem sInter_Union {α : Type u} {ι : Sort x} (s : ι → set (set α)) : (⋂₀Union fun (i : ι) => s i) = Inter fun (i : ι) => ⋂₀s i := sorry\n\n@[simp] theorem sUnion_insert {α : Type u} (s : set α) (T : set (set α)) : ⋃₀insert s T = s ∪ ⋃₀T :=\n  Sup_insert\n\n@[simp] theorem sInter_insert {α : Type u} (s : set α) (T : set (set α)) : ⋂₀insert s T = s ∩ ⋂₀T :=\n  Inf_insert\n\ntheorem sUnion_pair {α : Type u} (s : set α) (t : set α) : ⋃₀insert s (singleton t) = s ∪ t :=\n  Sup_pair\n\ntheorem sInter_pair {α : Type u} (s : set α) (t : set α) : ⋂₀insert s (singleton t) = s ∩ t :=\n  Inf_pair\n\n@[simp] theorem sUnion_image {α : Type u} {β : Type v} (f : α → set β) (s : set α) : ⋃₀(f '' s) = Union fun (x : α) => Union fun (H : x ∈ s) => f x :=\n  Sup_image\n\n@[simp] theorem sInter_image {α : Type u} {β : Type v} (f : α → set β) (s : set α) : ⋂₀(f '' s) = Inter fun (x : α) => Inter fun (H : x ∈ s) => f x :=\n  Inf_image\n\n@[simp] theorem sUnion_range {β : Type v} {ι : Sort x} (f : ι → set β) : ⋃₀range f = Union fun (x : ι) => f x :=\n  rfl\n\n@[simp] theorem sInter_range {β : Type v} {ι : Sort x} (f : ι → set β) : ⋂₀range f = Inter fun (x : ι) => f x :=\n  rfl\n\ntheorem Union_eq_univ_iff {α : Type u} {ι : Sort x} {f : ι → set α} : (Union fun (i : ι) => f i) = univ ↔ ∀ (x : α), ∃ (i : ι), x ∈ f i := sorry\n\ntheorem bUnion_eq_univ_iff {α : Type u} {β : Type v} {f : α → set β} {s : set α} : (Union fun (x : α) => Union fun (H : x ∈ s) => f x) = univ ↔ ∀ (y : β), ∃ (x : α), ∃ (H : x ∈ s), y ∈ f x := sorry\n\ntheorem sUnion_eq_univ_iff {α : Type u} {c : set (set α)} : ⋃₀c = univ ↔ ∀ (a : α), ∃ (b : set α), ∃ (H : b ∈ c), a ∈ b := sorry\n\ntheorem compl_sUnion {α : Type u} (S : set (set α)) : ⋃₀Sᶜ = ⋂₀(compl '' S) := sorry\n\n-- classical\n\ntheorem sUnion_eq_compl_sInter_compl {α : Type u} (S : set (set α)) : ⋃₀S = (⋂₀(compl '' S)ᶜ) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (⋃₀S = (⋂₀(compl '' S)ᶜ))) (Eq.symm (compl_compl (⋃₀S)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (⋃₀Sᶜᶜ = (⋂₀(compl '' S)ᶜ))) (compl_sUnion S))) (Eq.refl (⋂₀(compl '' S)ᶜ)))\n\n-- classical\n\ntheorem compl_sInter {α : Type u} (S : set (set α)) : ⋂₀Sᶜ = ⋃₀(compl '' S) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (⋂₀Sᶜ = ⋃₀(compl '' S))) (sUnion_eq_compl_sInter_compl (compl '' S))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (⋂₀Sᶜ = (⋂₀(compl '' (compl '' S))ᶜ))) (compl_compl_image S))) (Eq.refl (⋂₀Sᶜ)))\n\n-- classical\n\ntheorem sInter_eq_comp_sUnion_compl {α : Type u} (S : set (set α)) : ⋂₀S = (⋃₀(compl '' S)ᶜ) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (⋂₀S = (⋃₀(compl '' S)ᶜ))) (Eq.symm (compl_compl (⋂₀S)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (⋂₀Sᶜᶜ = (⋃₀(compl '' S)ᶜ))) (compl_sInter S))) (Eq.refl (⋃₀(compl '' S)ᶜ)))\n\ntheorem inter_empty_of_inter_sUnion_empty {α : Type u} {s : set α} {t : set α} {S : set (set α)} (hs : t ∈ S) (h : s ∩ ⋃₀S = ∅) : s ∩ t = ∅ :=\n  eq_empty_of_subset_empty\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s ∩ t ⊆ ∅)) (Eq.symm h))) (inter_subset_inter_right s (subset_sUnion_of_mem hs)))\n\ntheorem range_sigma_eq_Union_range {α : Type u} {β : Type v} {γ : α → Type u_1} (f : sigma γ → β) : range f = Union fun (a : α) => range fun (b : γ a) => f (sigma.mk a b) := sorry\n\ntheorem Union_eq_range_sigma {α : Type u} {β : Type v} (s : α → set β) : (Union fun (i : α) => s i) = range fun (a : sigma fun (i : α) => ↥(s i)) => ↑(sigma.snd a) := sorry\n\ntheorem Union_image_preimage_sigma_mk_eq_self {ι : Type u_1} {σ : ι → Type u_2} (s : set (sigma σ)) : (Union fun (i : ι) => sigma.mk i '' (sigma.mk i ⁻¹' s)) = s := sorry\n\ntheorem sUnion_mono {α : Type u} {s : set (set α)} {t : set (set α)} (h : s ⊆ t) : ⋃₀s ⊆ ⋃₀t :=\n  sUnion_subset fun (t' : set α) (ht' : t' ∈ s) => subset_sUnion_of_mem (h ht')\n\ntheorem Union_subset_Union {α : Type u} {ι : Sort x} {s : ι → set α} {t : ι → set α} (h : ∀ (i : ι), s i ⊆ t i) : (Union fun (i : ι) => s i) ⊆ Union fun (i : ι) => t i :=\n  supr_le_supr h\n\ntheorem Union_subset_Union2 {α : Type u} {ι : Sort x} {ι₂ : Sort u_1} {s : ι → set α} {t : ι₂ → set α} (h : ∀ (i : ι), ∃ (j : ι₂), s i ⊆ t j) : (Union fun (i : ι) => s i) ⊆ Union fun (i : ι₂) => t i :=\n  supr_le_supr2 h\n\ntheorem Union_subset_Union_const {α : Type u} {ι : Sort x} {ι₂ : Sort x} {s : set α} (h : ι → ι₂) : (Union fun (i : ι) => s) ⊆ Union fun (j : ι₂) => s :=\n  supr_le_supr_const h\n\n@[simp] theorem Union_of_singleton (α : Type u) : (Union fun (x : α) => singleton x) = univ := sorry\n\n@[simp] theorem Union_of_singleton_coe {α : Type u} (s : set α) : (Union fun (i : ↥s) => singleton ↑i) = s := sorry\n\ntheorem bUnion_subset_Union {α : Type u} {β : Type v} (s : set α) (t : α → set β) : (Union fun (x : α) => Union fun (H : x ∈ s) => t x) ⊆ Union fun (x : α) => t x :=\n  Union_subset_Union fun (i : α) => Union_subset fun (h : i ∈ s) => subset.refl (t i)\n\ntheorem sUnion_eq_bUnion {α : Type u} {s : set (set α)} : ⋃₀s = Union fun (i : set α) => Union fun (h : i ∈ s) => i := sorry\n\ntheorem sInter_eq_bInter {α : Type u} {s : set (set α)} : ⋂₀s = Inter fun (i : set α) => Inter fun (h : i ∈ s) => i := sorry\n\ntheorem sUnion_eq_Union {α : Type u} {s : set (set α)} : ⋃₀s = Union fun (i : ↥s) => ↑i := sorry\n\ntheorem sInter_eq_Inter {α : Type u} {s : set (set α)} : ⋂₀s = Inter fun (i : ↥s) => ↑i := sorry\n\ntheorem union_eq_Union {α : Type u} {s₁ : set α} {s₂ : set α} : s₁ ∪ s₂ = Union fun (b : Bool) => cond b s₁ s₂ := sorry\n\ntheorem inter_eq_Inter {α : Type u} {s₁ : set α} {s₂ : set α} : s₁ ∩ s₂ = Inter fun (b : Bool) => cond b s₁ s₂ := sorry\n\nprotected instance complete_boolean_algebra {α : Type u} : complete_boolean_algebra (set α) :=\n  complete_boolean_algebra.mk boolean_algebra.sup boolean_algebra.le boolean_algebra.lt sorry sorry sorry sorry sorry\n    sorry boolean_algebra.inf sorry sorry sorry sorry boolean_algebra.top sorry boolean_algebra.bot sorry compl\n    has_sdiff.sdiff sorry sorry sorry complete_lattice.Sup complete_lattice.Inf sorry sorry sorry sorry sorry sorry\n\ntheorem sInter_union_sInter {α : Type u} {S : set (set α)} {T : set (set α)} : ⋂₀S ∪ ⋂₀T = Inter fun (p : set α × set α) => Inter fun (H : p ∈ set.prod S T) => prod.fst p ∪ prod.snd p :=\n  Inf_sup_Inf\n\ntheorem sUnion_inter_sUnion {α : Type u} {s : set (set α)} {t : set (set α)} : ⋃₀s ∩ ⋃₀t = Union fun (p : set α × set α) => Union fun (H : p ∈ set.prod s t) => prod.fst p ∩ prod.snd p :=\n  Sup_inf_Sup\n\n/-- If `S` is a set of sets, and each `s ∈ S` can be represented as an intersection\nof sets `T s hs`, then `⋂₀ S` is the intersection of the union of all `T s hs`. -/\ntheorem sInter_bUnion {α : Type u} {S : set (set α)} {T : (s : set α) → s ∈ S → set (set α)} (hT : ∀ (s : set α) (H : s ∈ S), s = ⋂₀T s H) : (⋂₀Union fun (s : set α) => Union fun (H : s ∈ S) => T s H) = ⋂₀S := sorry\n\n/-- If `S` is a set of sets, and each `s ∈ S` can be represented as an union\nof sets `T s hs`, then `⋃₀ S` is the union of the union of all `T s hs`. -/\ntheorem sUnion_bUnion {α : Type u} {S : set (set α)} {T : (s : set α) → s ∈ S → set (set α)} (hT : ∀ (s : set α) (H : s ∈ S), s = ⋃₀T s H) : (⋃₀Union fun (s : set α) => Union fun (H : s ∈ S) => T s H) = ⋃₀S := sorry\n\ntheorem Union_range_eq_sUnion {α : Type u_1} {β : Type u_2} (C : set (set α)) {f : (s : ↥C) → β → ↥s} (hf : ∀ (s : ↥C), function.surjective (f s)) : (Union fun (y : β) => range fun (s : ↥C) => subtype.val (f s y)) = ⋃₀C := sorry\n\ntheorem Union_range_eq_Union {ι : Type u_1} {α : Type u_2} {β : Type u_3} (C : ι → set α) {f : (x : ι) → β → ↥(C x)} (hf : ∀ (x : ι), function.surjective (f x)) : (Union fun (y : β) => range fun (x : ι) => subtype.val (f x y)) = Union fun (x : ι) => C x := sorry\n\ntheorem union_distrib_Inter_right {α : Type u} {ι : Type u_1} (s : ι → set α) (t : set α) : (Inter fun (i : ι) => s i) ∪ t = Inter fun (i : ι) => s i ∪ t := sorry\n\ntheorem union_distrib_Inter_left {α : Type u} {ι : Type u_1} (s : ι → set α) (t : set α) : (t ∪ Inter fun (i : ι) => s i) = Inter fun (i : ι) => t ∪ s i := sorry\n\n/-!\n### `maps_to`\n-/\n\ntheorem maps_to_sUnion {α : Type u} {β : Type v} {S : set (set α)} {t : set β} {f : α → β} (H : ∀ (s : set α), s ∈ S → maps_to f s t) : maps_to f (⋃₀S) t := sorry\n\ntheorem maps_to_Union {α : Type u} {β : Type v} {ι : Sort x} {s : ι → set α} {t : set β} {f : α → β} (H : ∀ (i : ι), maps_to f (s i) t) : maps_to f (Union fun (i : ι) => s i) t :=\n  maps_to_sUnion (iff.mpr forall_range_iff H)\n\ntheorem maps_to_bUnion {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} {s : (i : ι) → p i → set α} {t : set β} {f : α → β} (H : ∀ (i : ι) (hi : p i), maps_to f (s i hi) t) : maps_to f (Union fun (i : ι) => Union fun (hi : p i) => s i hi) t :=\n  maps_to_Union fun (i : ι) => maps_to_Union (H i)\n\ntheorem maps_to_Union_Union {α : Type u} {β : Type v} {ι : Sort x} {s : ι → set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), maps_to f (s i) (t i)) : maps_to f (Union fun (i : ι) => s i) (Union fun (i : ι) => t i) :=\n  maps_to_Union fun (i : ι) => maps_to.mono (subset.refl (s i)) (subset_Union t i) (H i)\n\ntheorem maps_to_bUnion_bUnion {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} {s : (i : ι) → p i → set α} {t : (i : ι) → p i → set β} {f : α → β} (H : ∀ (i : ι) (hi : p i), maps_to f (s i hi) (t i hi)) : maps_to f (Union fun (i : ι) => Union fun (hi : p i) => s i hi) (Union fun (i : ι) => Union fun (hi : p i) => t i hi) :=\n  maps_to_Union_Union fun (i : ι) => maps_to_Union_Union (H i)\n\ntheorem maps_to_sInter {α : Type u} {β : Type v} {s : set α} {T : set (set β)} {f : α → β} (H : ∀ (t : set β), t ∈ T → maps_to f s t) : maps_to f s (⋂₀T) :=\n  fun (x : α) (hx : x ∈ s) (t : set β) (ht : t ∈ T) => H t ht hx\n\ntheorem maps_to_Inter {α : Type u} {β : Type v} {ι : Sort x} {s : set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), maps_to f s (t i)) : maps_to f s (Inter fun (i : ι) => t i) :=\n  fun (x : α) (hx : x ∈ s) => iff.mpr mem_Inter fun (i : ι) => H i hx\n\ntheorem maps_to_bInter {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} {s : set α} {t : (i : ι) → p i → set β} {f : α → β} (H : ∀ (i : ι) (hi : p i), maps_to f s (t i hi)) : maps_to f s (Inter fun (i : ι) => Inter fun (hi : p i) => t i hi) :=\n  maps_to_Inter fun (i : ι) => maps_to_Inter (H i)\n\ntheorem maps_to_Inter_Inter {α : Type u} {β : Type v} {ι : Sort x} {s : ι → set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), maps_to f (s i) (t i)) : maps_to f (Inter fun (i : ι) => s i) (Inter fun (i : ι) => t i) :=\n  maps_to_Inter fun (i : ι) => maps_to.mono (Inter_subset s i) (subset.refl (t i)) (H i)\n\ntheorem maps_to_bInter_bInter {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} {s : (i : ι) → p i → set α} {t : (i : ι) → p i → set β} {f : α → β} (H : ∀ (i : ι) (hi : p i), maps_to f (s i hi) (t i hi)) : maps_to f (Inter fun (i : ι) => Inter fun (hi : p i) => s i hi) (Inter fun (i : ι) => Inter fun (hi : p i) => t i hi) :=\n  maps_to_Inter_Inter fun (i : ι) => maps_to_Inter_Inter (H i)\n\ntheorem image_Inter_subset {α : Type u} {β : Type v} {ι : Sort x} (s : ι → set α) (f : α → β) : (f '' Inter fun (i : ι) => s i) ⊆ Inter fun (i : ι) => f '' s i :=\n  maps_to.image_subset (maps_to_Inter_Inter fun (i : ι) => maps_to_image f (s i))\n\ntheorem image_bInter_subset {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} (s : (i : ι) → p i → set α) (f : α → β) : (f '' Inter fun (i : ι) => Inter fun (hi : p i) => s i hi) ⊆ Inter fun (i : ι) => Inter fun (hi : p i) => f '' s i hi :=\n  maps_to.image_subset (maps_to_bInter_bInter fun (i : ι) (hi : p i) => maps_to_image f (s i hi))\n\ntheorem image_sInter_subset {α : Type u} {β : Type v} (S : set (set α)) (f : α → β) : f '' ⋂₀S ⊆ Inter fun (s : set α) => Inter fun (H : s ∈ S) => f '' s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (f '' ⋂₀S ⊆ Inter fun (s : set α) => Inter fun (H : s ∈ S) => f '' s)) sInter_eq_bInter))\n    (image_bInter_subset (fun (i : set α) (hi : i ∈ S) => i) f)\n\n/-!\n### `inj_on`\n-/\n\ntheorem inj_on.image_Inter_eq {α : Type u} {β : Type v} {ι : Sort x} [Nonempty ι] {s : ι → set α} {f : α → β} (h : inj_on f (Union fun (i : ι) => s i)) : (f '' Inter fun (i : ι) => s i) = Inter fun (i : ι) => f '' s i := sorry\n\ntheorem inj_on.image_bInter_eq {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} {s : (i : ι) → p i → set α} (hp : ∃ (i : ι), p i) {f : α → β} (h : inj_on f (Union fun (i : ι) => Union fun (hi : p i) => s i hi)) : (f '' Inter fun (i : ι) => Inter fun (hi : p i) => s i hi) = Inter fun (i : ι) => Inter fun (hi : p i) => f '' s i hi := sorry\n\ntheorem inj_on_Union_of_directed {α : Type u} {β : Type v} {ι : Sort x} {s : ι → set α} (hs : directed has_subset.subset s) {f : α → β} (hf : ∀ (i : ι), inj_on f (s i)) : inj_on f (Union fun (i : ι) => s i) := sorry\n\n/-!\n### `surj_on`\n-/\n\ntheorem surj_on_sUnion {α : Type u} {β : Type v} {s : set α} {T : set (set β)} {f : α → β} (H : ∀ (t : set β), t ∈ T → surj_on f s t) : surj_on f s (⋃₀T) := sorry\n\ntheorem surj_on_Union {α : Type u} {β : Type v} {ι : Sort x} {s : set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), surj_on f s (t i)) : surj_on f s (Union fun (i : ι) => t i) :=\n  surj_on_sUnion (iff.mpr forall_range_iff H)\n\ntheorem surj_on_Union_Union {α : Type u} {β : Type v} {ι : Sort x} {s : ι → set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), surj_on f (s i) (t i)) : surj_on f (Union fun (i : ι) => s i) (Union fun (i : ι) => t i) :=\n  surj_on_Union fun (i : ι) => surj_on.mono (subset_Union s i) (subset.refl (t i)) (H i)\n\ntheorem surj_on_bUnion {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} {s : set α} {t : (i : ι) → p i → set β} {f : α → β} (H : ∀ (i : ι) (hi : p i), surj_on f s (t i hi)) : surj_on f s (Union fun (i : ι) => Union fun (hi : p i) => t i hi) :=\n  surj_on_Union fun (i : ι) => surj_on_Union (H i)\n\ntheorem surj_on_bUnion_bUnion {α : Type u} {β : Type v} {ι : Sort x} {p : ι → Prop} {s : (i : ι) → p i → set α} {t : (i : ι) → p i → set β} {f : α → β} (H : ∀ (i : ι) (hi : p i), surj_on f (s i hi) (t i hi)) : surj_on f (Union fun (i : ι) => Union fun (hi : p i) => s i hi) (Union fun (i : ι) => Union fun (hi : p i) => t i hi) :=\n  surj_on_Union_Union fun (i : ι) => surj_on_Union_Union (H i)\n\ntheorem surj_on_Inter {α : Type u} {β : Type v} {ι : Sort x} [hi : Nonempty ι] {s : ι → set α} {t : set β} {f : α → β} (H : ∀ (i : ι), surj_on f (s i) t) (Hinj : inj_on f (Union fun (i : ι) => s i)) : surj_on f (Inter fun (i : ι) => s i) t := sorry\n\ntheorem surj_on_Inter_Inter {α : Type u} {β : Type v} {ι : Sort x} [hi : Nonempty ι] {s : ι → set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), surj_on f (s i) (t i)) (Hinj : inj_on f (Union fun (i : ι) => s i)) : surj_on f (Inter fun (i : ι) => s i) (Inter fun (i : ι) => t i) :=\n  surj_on_Inter (fun (i : ι) => surj_on.mono (subset.refl (s i)) (Inter_subset (fun (i : ι) => t i) i) (H i)) Hinj\n\n/-!\n### `bij_on`\n-/\n\ntheorem bij_on_Union {α : Type u} {β : Type v} {ι : Sort x} {s : ι → set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), bij_on f (s i) (t i)) (Hinj : inj_on f (Union fun (i : ι) => s i)) : bij_on f (Union fun (i : ι) => s i) (Union fun (i : ι) => t i) :=\n  { left := maps_to_Union_Union fun (i : ι) => bij_on.maps_to (H i),\n    right := { left := Hinj, right := surj_on_Union_Union fun (i : ι) => bij_on.surj_on (H i) } }\n\ntheorem bij_on_Inter {α : Type u} {β : Type v} {ι : Sort x} [hi : Nonempty ι] {s : ι → set α} {t : ι → set β} {f : α → β} (H : ∀ (i : ι), bij_on f (s i) (t i)) (Hinj : inj_on f (Union fun (i : ι) => s i)) : bij_on f (Inter fun (i : ι) => s i) (Inter fun (i : ι) => t i) := sorry\n\ntheorem bij_on_Union_of_directed {α : Type u} {β : Type v} {ι : Sort x} {s : ι → set α} (hs : directed has_subset.subset s) {t : ι → set β} {f : α → β} (H : ∀ (i : ι), bij_on f (s i) (t i)) : bij_on f (Union fun (i : ι) => s i) (Union fun (i : ι) => t i) :=\n  bij_on_Union H (inj_on_Union_of_directed hs fun (i : ι) => bij_on.inj_on (H i))\n\ntheorem bij_on_Inter_of_directed {α : Type u} {β : Type v} {ι : Sort x} [Nonempty ι] {s : ι → set α} (hs : directed has_subset.subset s) {t : ι → set β} {f : α → β} (H : ∀ (i : ι), bij_on f (s i) (t i)) : bij_on f (Inter fun (i : ι) => s i) (Inter fun (i : ι) => t i) :=\n  bij_on_Inter H (inj_on_Union_of_directed hs fun (i : ι) => bij_on.inj_on (H i))\n\n@[simp] theorem Inter_pos {α : Type u} {p : Prop} {μ : p → set α} (hp : p) : (Inter fun (h : p) => μ h) = μ hp :=\n  infi_pos hp\n\n@[simp] theorem Inter_neg {α : Type u} {p : Prop} {μ : p → set α} (hp : ¬p) : (Inter fun (h : p) => μ h) = univ :=\n  infi_neg hp\n\n@[simp] theorem Union_pos {α : Type u} {p : Prop} {μ : p → set α} (hp : p) : (Union fun (h : p) => μ h) = μ hp :=\n  supr_pos hp\n\n@[simp] theorem Union_neg {α : Type u} {p : Prop} {μ : p → set α} (hp : ¬p) : (Union fun (h : p) => μ h) = ∅ :=\n  supr_neg hp\n\n@[simp] theorem Union_empty {α : Type u} {ι : Sort x} : (Union fun (i : ι) => ∅) = ∅ :=\n  supr_bot\n\n@[simp] theorem Inter_univ {α : Type u} {ι : Sort x} : (Inter fun (i : ι) => univ) = univ :=\n  infi_top\n\n@[simp] theorem Union_eq_empty {α : Type u} {ι : Sort x} {s : ι → set α} : (Union fun (i : ι) => s i) = ∅ ↔ ∀ (i : ι), s i = ∅ :=\n  supr_eq_bot\n\n@[simp] theorem Inter_eq_univ {α : Type u} {ι : Sort x} {s : ι → set α} : (Inter fun (i : ι) => s i) = univ ↔ ∀ (i : ι), s i = univ :=\n  infi_eq_top\n\n@[simp] theorem nonempty_Union {α : Type u} {ι : Sort x} {s : ι → set α} : set.nonempty (Union fun (i : ι) => s i) ↔ ∃ (i : ι), set.nonempty (s i) := sorry\n\ntheorem image_Union {α : Type u} {β : Type v} {ι : Sort x} {f : α → β} {s : ι → set α} : (f '' Union fun (i : ι) => s i) = Union fun (i : ι) => f '' s i := sorry\n\ntheorem univ_subtype {α : Type u} {p : α → Prop} : univ = Union fun (x : α) => Union fun (h : p x) => singleton { val := x, property := h } := sorry\n\ntheorem range_eq_Union {α : Type u} {ι : Sort u_1} (f : ι → α) : range f = Union fun (i : ι) => singleton (f i) := sorry\n\ntheorem image_eq_Union {α : Type u} {β : Type v} (f : α → β) (s : set α) : f '' s = Union fun (i : α) => Union fun (H : i ∈ s) => singleton (f i) := sorry\n\n@[simp] theorem bUnion_range {α : Type u} {β : Type v} {ι : Sort x} {f : ι → α} {g : α → set β} : (Union fun (x : α) => Union fun (H : x ∈ range f) => g x) = Union fun (y : ι) => g (f y) :=\n  supr_range\n\n@[simp] theorem bInter_range {α : Type u} {β : Type v} {ι : Sort x} {f : ι → α} {g : α → set β} : (Inter fun (x : α) => Inter fun (H : x ∈ range f) => g x) = Inter fun (y : ι) => g (f y) :=\n  infi_range\n\n@[simp] theorem bUnion_image {α : Type u} {β : Type v} {γ : Type w} {s : set γ} {f : γ → α} {g : α → set β} : (Union fun (x : α) => Union fun (H : x ∈ f '' s) => g x) = Union fun (y : γ) => Union fun (H : y ∈ s) => g (f y) :=\n  supr_image\n\n@[simp] theorem bInter_image {α : Type u} {β : Type v} {γ : Type w} {s : set γ} {f : γ → α} {g : α → set β} : (Inter fun (x : α) => Inter fun (H : x ∈ f '' s) => g x) = Inter fun (y : γ) => Inter fun (H : y ∈ s) => g (f y) :=\n  infi_image\n\ntheorem Union_image_left {α : Type u} {β : Type v} {γ : Type w} (f : α → β → γ) {s : set α} {t : set β} : (Union fun (a : α) => Union fun (H : a ∈ s) => f a '' t) = image2 f s t := sorry\n\ntheorem Union_image_right {α : Type u} {β : Type v} {γ : Type w} (f : α → β → γ) {s : set α} {t : set β} : (Union fun (b : β) => Union fun (H : b ∈ t) => (fun (a : α) => f a b) '' s) = image2 f s t := sorry\n\ntheorem monotone_preimage {α : Type u} {β : Type v} {f : α → β} : monotone (preimage f) :=\n  fun (a b : set β) (h : a ≤ b) => preimage_mono h\n\n@[simp] theorem preimage_Union {α : Type u} {β : Type v} {ι : Sort w} {f : α → β} {s : ι → set β} : (f ⁻¹' Union fun (i : ι) => s i) = Union fun (i : ι) => f ⁻¹' s i := sorry\n\ntheorem preimage_bUnion {α : Type u} {β : Type v} {ι : Type u_1} {f : α → β} {s : set ι} {t : ι → set β} : (f ⁻¹' Union fun (i : ι) => Union fun (H : i ∈ s) => t i) = Union fun (i : ι) => Union fun (H : i ∈ s) => f ⁻¹' t i := sorry\n\n@[simp] theorem preimage_sUnion {α : Type u} {β : Type v} {f : α → β} {s : set (set β)} : f ⁻¹' ⋃₀s = Union fun (t : set β) => Union fun (H : t ∈ s) => f ⁻¹' t := sorry\n\ntheorem preimage_Inter {α : Type u} {β : Type v} {ι : Sort u_1} {s : ι → set β} {f : α → β} : (f ⁻¹' Inter fun (i : ι) => s i) = Inter fun (i : ι) => f ⁻¹' s i := sorry\n\ntheorem preimage_bInter {α : Type u} {β : Type v} {γ : Type w} {s : γ → set β} {t : set γ} {f : α → β} : (f ⁻¹' Inter fun (i : γ) => Inter fun (H : i ∈ t) => s i) = Inter fun (i : γ) => Inter fun (H : i ∈ t) => f ⁻¹' s i := sorry\n\n@[simp] theorem bUnion_preimage_singleton {α : Type u} {β : Type v} (f : α → β) (s : set β) : (Union fun (y : β) => Union fun (H : y ∈ s) => f ⁻¹' singleton y) = f ⁻¹' s := sorry\n\ntheorem bUnion_range_preimage_singleton {α : Type u} {β : Type v} (f : α → β) : (Union fun (y : β) => Union fun (H : y ∈ range f) => f ⁻¹' singleton y) = univ := sorry\n\ntheorem monotone_prod {α : Type u} {β : Type v} {γ : Type w} [preorder α] {f : α → set β} {g : α → set γ} (hf : monotone f) (hg : monotone g) : monotone fun (x : α) => set.prod (f x) (g x) :=\n  fun (a b : α) (h : a ≤ b) => prod_mono (hf h) (hg h)\n\ntheorem Mathlib.monotone.set_prod {α : Type u} {β : Type v} {γ : Type w} [preorder α] {f : α → set β} {g : α → set γ} (hf : monotone f) (hg : monotone g) : monotone fun (x : α) => set.prod (f x) (g x) :=\n  monotone_prod\n\ntheorem prod_Union {α : Type u} {β : Type v} {ι : Sort u_1} {s : set α} {t : ι → set β} : set.prod s (Union fun (i : ι) => t i) = Union fun (i : ι) => set.prod s (t i) := sorry\n\ntheorem prod_bUnion {α : Type u} {β : Type v} {ι : Type u_1} {u : set ι} {s : set α} {t : ι → set β} : set.prod s (Union fun (i : ι) => Union fun (H : i ∈ u) => t i) =\n  Union fun (i : ι) => Union fun (H : i ∈ u) => set.prod s (t i) := sorry\n\ntheorem prod_sUnion {α : Type u} {β : Type v} {s : set α} {C : set (set β)} : set.prod s (⋃₀C) = ⋃₀((fun (t : set β) => set.prod s t) '' C) := sorry\n\ntheorem Union_prod {α : Type u} {β : Type v} {ι : Sort u_1} {s : ι → set α} {t : set β} : set.prod (Union fun (i : ι) => s i) t = Union fun (i : ι) => set.prod (s i) t := sorry\n\ntheorem bUnion_prod {α : Type u} {β : Type v} {ι : Type u_1} {u : set ι} {s : ι → set α} {t : set β} : set.prod (Union fun (i : ι) => Union fun (H : i ∈ u) => s i) t =\n  Union fun (i : ι) => Union fun (H : i ∈ u) => set.prod (s i) t := sorry\n\ntheorem sUnion_prod {α : Type u} {β : Type v} {C : set (set α)} {t : set β} : set.prod (⋃₀C) t = ⋃₀((fun (s : set α) => set.prod s t) '' C) := sorry\n\ntheorem Union_prod_of_monotone {α : Type u} {β : Type v} {γ : Type w} [semilattice_sup α] {s : α → set β} {t : α → set γ} (hs : monotone s) (ht : monotone t) : (Union fun (x : α) => set.prod (s x) (t x)) = set.prod (Union fun (x : α) => s x) (Union fun (x : α) => t x) := sorry\n\n/-- Given a set `s` of functions `α → β` and `t : set α`, `seq s t` is the union of `f '' t` over\nall `f ∈ s`. -/\ndef seq {α : Type u} {β : Type v} (s : set (α → β)) (t : set α) : set β :=\n  set_of fun (b : β) => ∃ (f : α → β), ∃ (H : f ∈ s), ∃ (a : α), ∃ (H : a ∈ t), f a = b\n\ntheorem seq_def {α : Type u} {β : Type v} {s : set (α → β)} {t : set α} : seq s t = Union fun (f : α → β) => Union fun (H : f ∈ s) => f '' t := sorry\n\n@[simp] theorem mem_seq_iff {α : Type u} {β : Type v} {s : set (α → β)} {t : set α} {b : β} : b ∈ seq s t ↔ ∃ (f : α → β), ∃ (H : f ∈ s), ∃ (a : α), ∃ (H : a ∈ t), f a = b :=\n  iff.rfl\n\ntheorem seq_subset {α : Type u} {β : Type v} {s : set (α → β)} {t : set α} {u : set β} : seq s t ⊆ u ↔ ∀ (f : α → β), f ∈ s → ∀ (a : α), a ∈ t → f a ∈ u := sorry\n\ntheorem seq_mono {α : Type u} {β : Type v} {s₀ : set (α → β)} {s₁ : set (α → β)} {t₀ : set α} {t₁ : set α} (hs : s₀ ⊆ s₁) (ht : t₀ ⊆ t₁) : seq s₀ t₀ ⊆ seq s₁ t₁ := sorry\n\ntheorem singleton_seq {α : Type u} {β : Type v} {f : α → β} {t : set α} : seq (singleton f) t = f '' t := sorry\n\ntheorem seq_singleton {α : Type u} {β : Type v} {s : set (α → β)} {a : α} : seq s (singleton a) = (fun (f : α → β) => f a) '' s := sorry\n\ntheorem seq_seq {α : Type u} {β : Type v} {γ : Type w} {s : set (β → γ)} {t : set (α → β)} {u : set α} : seq s (seq t u) = seq (seq (function.comp '' s) t) u := sorry\n\ntheorem image_seq {α : Type u} {β : Type v} {γ : Type w} {f : β → γ} {s : set (α → β)} {t : set α} : f '' seq s t = seq (function.comp f '' s) t := sorry\n\ntheorem prod_eq_seq {α : Type u} {β : Type v} {s : set α} {t : set β} : set.prod s t = seq (Prod.mk '' s) t := sorry\n\ntheorem prod_image_seq_comm {α : Type u} {β : Type v} (s : set α) (t : set β) : seq (Prod.mk '' s) t = seq ((fun (b : β) (a : α) => (a, b)) '' t) s := sorry\n\ntheorem image2_eq_seq {α : Type u} {β : Type v} {γ : Type w} (f : α → β → γ) (s : set α) (t : set β) : image2 f s t = seq (f '' s) t := sorry\n\nprotected instance monad : Monad set :=\n  { toApplicative :=\n      { toFunctor := { map := fun (α β : Type u) => image, mapConst := fun (α β : Type u) => image ∘ function.const β },\n        toPure := { pure := fun (α : Type u) (a : α) => singleton a }, toSeq := { seq := fun (α β : Type u) => seq },\n        toSeqLeft :=\n          { seqLeft :=\n              fun (α β : Type u) (a : set α) (b : set β) =>\n                (fun (α β : Type u) => seq) β α ((fun (α β : Type u) => image) α (β → α) (function.const β) a) b },\n        toSeqRight :=\n          { seqRight :=\n              fun (α β : Type u) (a : set α) (b : set β) =>\n                (fun (α β : Type u) => seq) β β ((fun (α β : Type u) => image) α (β → β) (function.const α id) a) b } },\n    toBind :=\n      { bind := fun (α β : Type u) (s : set α) (f : α → set β) => Union fun (i : α) => Union fun (H : i ∈ s) => f i } }\n\n@[simp] theorem bind_def {α' : Type u} {β' : Type u} {s : set α'} {f : α' → set β'} : s >>= f = Union fun (i : α') => Union fun (H : i ∈ s) => f i :=\n  rfl\n\n@[simp] theorem fmap_eq_image {α' : Type u} {β' : Type u} {s : set α'} (f : α' → β') : f <$> s = f '' s :=\n  rfl\n\n@[simp] theorem seq_eq_set_seq {α : Type u_1} {β : Type u_1} (s : set (α → β)) (t : set α) : s <*> t = seq s t :=\n  rfl\n\n@[simp] theorem pure_def {α : Type u} (a : α) : pure a = singleton a :=\n  rfl\n\nprotected instance is_lawful_monad : is_lawful_monad set := sorry\n\nprotected instance is_comm_applicative : is_comm_applicative set :=\n  is_comm_applicative.mk fun (α β : Type u) (s : set α) (t : set β) => prod_image_seq_comm s t\n\ntheorem pi_def {α : Type u} {π : α → Type u_1} (i : set α) (s : (a : α) → set (π a)) : pi i s = Inter fun (a : α) => Inter fun (H : a ∈ i) => function.eval a ⁻¹' s a := sorry\n\ntheorem pi_diff_pi_subset {α : Type u} {π : α → Type u_1} (i : set α) (s : (a : α) → set (π a)) (t : (a : α) → set (π a)) : pi i s \\ pi i t ⊆ Union fun (a : α) => Union fun (H : a ∈ i) => function.eval a ⁻¹' (s a \\ t a) := sorry\n\nend set\n\n\n/-! ### Disjoint sets -/\n\nnamespace disjoint\n\n\n/-! We define some lemmas in the `disjoint` namespace to be able to use projection notation. -/\n\ntheorem union_left {α : Type u} {s : set α} {t : set α} {u : set α} (hs : disjoint s u) (ht : disjoint t u) : disjoint (s ∪ t) u :=\n  sup_left hs ht\n\ntheorem union_right {α : Type u} {s : set α} {t : set α} {u : set α} (ht : disjoint s t) (hu : disjoint s u) : disjoint s (t ∪ u) :=\n  sup_right ht hu\n\ntheorem preimage {α : Type u_1} {β : Type u_2} (f : α → β) {s : set β} {t : set β} (h : disjoint s t) : disjoint (f ⁻¹' s) (f ⁻¹' t) :=\n  fun (x : α) (hx : x ∈ f ⁻¹' s ⊓ f ⁻¹' t) => h hx\n\nend disjoint\n\n\nnamespace set\n\n\nprotected theorem disjoint_iff {α : Type u} {s : set α} {t : set α} : disjoint s t ↔ s ∩ t ⊆ ∅ :=\n  iff.rfl\n\ntheorem disjoint_iff_inter_eq_empty {α : Type u} {s : set α} {t : set α} : disjoint s t ↔ s ∩ t = ∅ :=\n  disjoint_iff\n\ntheorem not_disjoint_iff {α : Type u} {s : set α} {t : set α} : ¬disjoint s t ↔ ∃ (x : α), x ∈ s ∧ x ∈ t :=\n  iff.trans not_forall (exists_congr fun (x : α) => not_not)\n\ntheorem disjoint_left {α : Type u} {s : set α} {t : set α} : disjoint s t ↔ ∀ {a : α}, a ∈ s → ¬a ∈ t :=\n  (fun (this : (∀ (x : α), ¬x ∈ s ∩ t) ↔ ∀ (a : α), a ∈ s → ¬a ∈ t) => this)\n    { mp := fun (h : ∀ (x : α), ¬x ∈ s ∩ t) (a : α) => iff.mp not_and (h a),\n      mpr := fun (h : ∀ (a : α), a ∈ s → ¬a ∈ t) (a : α) => iff.mpr not_and (h a) }\n\ntheorem disjoint_right {α : Type u} {s : set α} {t : set α} : disjoint s t ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint s t ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s)) (propext disjoint.comm)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (disjoint t s ↔ ∀ {a : α}, a ∈ t → ¬a ∈ s)) (propext disjoint_left)))\n      (iff.refl (∀ {a : α}, a ∈ t → ¬a ∈ s)))\n\ntheorem disjoint_of_subset_left {α : Type u} {s : set α} {t : set α} {u : set α} (h : s ⊆ u) (d : disjoint u t) : disjoint s t :=\n  disjoint.mono_left h d\n\ntheorem disjoint_of_subset_right {α : Type u} {s : set α} {t : set α} {u : set α} (h : t ⊆ u) (d : disjoint s u) : disjoint s t :=\n  disjoint.mono_right h d\n\ntheorem disjoint_of_subset {α : Type u} {s : set α} {t : set α} {u : set α} {v : set α} (h1 : s ⊆ u) (h2 : t ⊆ v) (d : disjoint u v) : disjoint s t :=\n  disjoint.mono h1 h2 d\n\n@[simp] theorem disjoint_union_left {α : Type u} {s : set α} {t : set α} {u : set α} : disjoint (s ∪ t) u ↔ disjoint s u ∧ disjoint t u :=\n  disjoint_sup_left\n\n@[simp] theorem disjoint_union_right {α : Type u} {s : set α} {t : set α} {u : set α} : disjoint s (t ∪ u) ↔ disjoint s t ∧ disjoint s u :=\n  disjoint_sup_right\n\ntheorem disjoint_diff {α : Type u} {a : set α} {b : set α} : disjoint a (b \\ a) :=\n  iff.mpr disjoint_iff (inter_diff_self a b)\n\n@[simp] theorem disjoint_empty {α : Type u} (s : set α) : disjoint s ∅ :=\n  disjoint_bot_right\n\n@[simp] theorem empty_disjoint {α : Type u} (s : set α) : disjoint ∅ s :=\n  disjoint_bot_left\n\n@[simp] theorem univ_disjoint {α : Type u} {s : set α} : disjoint univ s ↔ s = ∅ :=\n  top_disjoint\n\n@[simp] theorem disjoint_univ {α : Type u} {s : set α} : disjoint s univ ↔ s = ∅ :=\n  disjoint_top\n\n@[simp] theorem disjoint_singleton_left {α : Type u} {a : α} {s : set α} : disjoint (singleton a) s ↔ ¬a ∈ s := sorry\n\n@[simp] theorem disjoint_singleton_right {α : Type u} {a : α} {s : set α} : disjoint s (singleton a) ↔ ¬a ∈ s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint s (singleton a) ↔ ¬a ∈ s)) (propext disjoint.comm))) disjoint_singleton_left\n\ntheorem disjoint_image_image {α : Type u} {β : Type v} {γ : Type w} {f : β → α} {g : γ → α} {s : set β} {t : set γ} (h : ∀ (b : β), b ∈ s → ∀ (c : γ), c ∈ t → f b ≠ g c) : disjoint (f '' s) (g '' t) := sorry\n\ntheorem pairwise_on_disjoint_fiber {α : Type u} {β : Type v} (f : α → β) (s : set β) : pairwise_on s (disjoint on fun (y : β) => f ⁻¹' singleton y) := sorry\n\ntheorem preimage_eq_empty {α : Type u} {β : Type v} {f : α → β} {s : set β} (h : disjoint s (range f)) : f ⁻¹' s = ∅ := sorry\n\ntheorem preimage_eq_empty_iff {α : Type u} {β : Type v} {f : α → β} {s : set β} : disjoint s (range f) ↔ f ⁻¹' s = ∅ := sorry\n\nend set\n\n\nnamespace set\n\n\n/-- A collection of sets is `pairwise_disjoint`, if any two different sets in this collection\nare disjoint.  -/\ndef pairwise_disjoint {α : Type u} (s : set (set α)) :=\n  pairwise_on s disjoint\n\ntheorem pairwise_disjoint.subset {α : Type u} {s : set (set α)} {t : set (set α)} (h : s ⊆ t) (ht : pairwise_disjoint t) : pairwise_disjoint s :=\n  pairwise_on.mono h ht\n\ntheorem pairwise_disjoint.range {α : Type u} {s : set (set α)} (f : ↥s → set α) (hf : ∀ (x : ↥s), f x ⊆ subtype.val x) (ht : pairwise_disjoint s) : pairwise_disjoint (range f) := sorry\n\n/- classical -/\n\ntheorem pairwise_disjoint.elim {α : Type u} {s : set (set α)} (h : pairwise_disjoint s) {x : set α} {y : set α} (hx : x ∈ s) (hy : y ∈ s) (z : α) (hzx : z ∈ x) (hzy : z ∈ y) : x = y :=\n  iff.mp not_not fun (h' : ¬x = y) => h x hx y hy h' { left := hzx, right := hzy }\n\nend set\n\n\nnamespace set\n\n\ntheorem subset_diff {α : Type u} {s : set α} {t : set α} {u : set α} : s ⊆ t \\ u ↔ s ⊆ t ∧ disjoint s u := sorry\n\n/-- If `t` is an indexed family of sets, then there is a natural map from `Σ i, t i` to `⋃ i, t i`\nsending `⟨i, x⟩` to `x`. -/\ndef sigma_to_Union {α : Type u} {β : Type v} (t : α → set β) (x : sigma fun (i : α) => ↥(t i)) : ↥(Union fun (i : α) => t i) :=\n  { val := ↑(sigma.snd x), property := sorry }\n\ntheorem sigma_to_Union_surjective {α : Type u} {β : Type v} (t : α → set β) : function.surjective (sigma_to_Union t) := sorry\n\ntheorem sigma_to_Union_injective {α : Type u} {β : Type v} (t : α → set β) (h : ∀ (i j : α), i ≠ j → disjoint (t i) (t j)) : function.injective (sigma_to_Union t) := sorry\n\ntheorem sigma_to_Union_bijective {α : Type u} {β : Type v} (t : α → set β) (h : ∀ (i j : α), i ≠ j → disjoint (t i) (t j)) : function.bijective (sigma_to_Union t) :=\n  { left := sigma_to_Union_injective t h, right := sigma_to_Union_surjective t }\n\n/-- Equivalence between a disjoint union and a dependent sum. -/\ndef Union_eq_sigma_of_disjoint {α : Type u} {β : Type v} {t : α → set β} (h : ∀ (i j : α), i ≠ j → disjoint (t i) (t j)) : ↥(Union fun (i : α) => t i) ≃ sigma fun (i : α) => ↥(t i) :=\n  equiv.symm (equiv.of_bijective (sigma_to_Union t) (sigma_to_Union_bijective t h))\n\n/-- Equivalence between a disjoint bounded union and a dependent sum. -/\ndef bUnion_eq_sigma_of_disjoint {α : Type u} {β : Type v} {s : set α} {t : α → set β} (h : pairwise_on s (disjoint on t)) : ↥(Union fun (i : α) => Union fun (H : i ∈ s) => t i) ≃ sigma fun (i : ↥s) => ↥(t (subtype.val i)) :=\n  equiv.trans (equiv.set_congr sorry) (Union_eq_sigma_of_disjoint sorry)\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/set/lattice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6548947290421276, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.4514226109520124}}
{"text": "import data.nat.enat\nimport data.real.basic\nimport data.real.cau_seq\nimport data.nat.choose.basic\nimport algebra.group_power.basic\nimport ring_theory.ideal.basic\nimport ring_theory.principal_ideal_domain\nimport ring_theory.unique_factorization_domain\nimport analysis.special_functions.pow\nimport topology.basic\n\nimport for_mathlib.associated\nimport for_mathlib.multiplicity\nimport for_mathlib.principal_ideal_domain\n\nopen is_absolute_value\nopen_locale classical big_operators\nnoncomputable theory\n\nset_option old_structure_cmd true\n\ndef padic_val {α} [integral_domain α] [is_principal_ideal_ring α]\n    [normalization_monoid α]\n    (p: α) [p_prime: fact (prime p)] (a: α): ℕ :=\n  if a ≠ 0\n      then multiset.count (normalize p) (unique_factorization_monoid.factors a)\n      else 0\n\nlemma padic_val_mul {α} [integral_domain α] [is_principal_ideal_ring α]\n  [normalization_monoid α]\n  (p: α) [p_prime: fact (prime p)] (a b: α) (ha: a ≠ 0) (hb: b ≠ 0):\n  padic_val p (a * b) = padic_val p a + padic_val p b :=\nbegin\n  unfold padic_val,\n  simp [ha, hb],\nend\n\nlemma padic_val_add {α} [integral_domain α] [is_principal_ideal_ring α]\n  [normalization_monoid α]\n  (p: α) [p_prime: fact (prime p)] {a b: α} (add_ne_zero: a + b ≠ 0):\n    padic_val p (a + b) ≥ min (padic_val p a) (padic_val p b) :=\nbegin\n  unfold padic_val,\n  exact if ha: a = 0\n    then by { simp [ha], }\n    else if hb: b = 0\n    then by { simp [hb], }\n    else by {\n      have h: multiplicity p (a + b) ≥ min (multiplicity p a) (multiplicity p b),\n      from multiplicity.min_le_multiplicity_add,\n      have p₀ := λ a: α, λ p: a ≠ 0,\n        unique_factorization_monoid.multiplicity_eq_count_factors\n          (fact_iff.1 p_prime).irreducible p,\n      rw p₀ _ add_ne_zero at h,\n      rw p₀ _ ha at h,\n      rw p₀ _ hb at h,\n      finish,\n    },\nend\n\nlemma padic_val_primes {α} [integral_domain α] [is_principal_ideal_ring α]\n  [normalization_monoid α]\n  (p: α) [p_prime: fact (prime p)]: ∀ q: α, prime q →\n    padic_val p q = if associated q p then 1 else 0 :=\nbegin\n  intros q q_prime,\n  unfold padic_val,\n  simp only [q_prime.left, if_true, if_false, ne.def, not_false_iff],\n  rw ← enat.coe_inj,\n  rw eq.symm (unique_factorization_monoid.multiplicity_eq_count_factors\n    (fact_iff.1 p_prime).irreducible q_prime.1),\n  exact if hpq: associated q p\n    then by simp [hpq, multiplicity.eq_of_associated hpq,\n      multiplicity.multiplicity_self (fact_iff.1 p_prime).not_unit (fact_iff.1 p_prime).ne_zero]\n    else by simp [hpq, multiplicity.multiplicity_eq_zero_of_not_dvd\n      (λ h, hpq (primes_associated_of_dvd (fact_iff.1 p_prime) q_prime h).symm)]\nend\n\nlemma padic_val_units {α} [integral_domain α] [is_principal_ideal_ring α]\n  [normalization_monoid α]\n  (p: α) [p_prime: fact (prime p)]: ∀ u: units α, padic_val p u = 0 :=\nbegin\n  intro u,\n  unfold padic_val,\n  simp only [u.ne_zero, if_true, ne.def, not_false_iff],\n  rw ← enat.coe_inj,\n  rw eq.symm (unique_factorization_monoid.multiplicity_eq_count_factors\n    (fact_iff.1 p_prime).irreducible u.ne_zero),\n  exact multiplicity.unit_right (fact_iff.1 p_prime).not_unit u,\nend\n\ndef padic_abv {α} [integral_domain α] [is_principal_ideal_ring α]\n    [normalization_monoid α]\n    (base: ℝ) (base_pos: 0 < base) (base_lt_one: base < 1)\n    (p: α) [p_prime: fact (prime p)]: α → ℝ :=\n  λ a: α, if a = 0 then 0 else base ^ padic_val p a\n\ninstance padic_abv_is_absolute_value {α} [integral_domain α] [is_principal_ideal_ring α]\n  [normalization_monoid α]\n  (base: ℝ) (base_pos: 0 < base) (base_lt_one: base < 1)\n  (p: α) [p_prime: fact (prime p)] :\n    is_absolute_value (padic_abv base base_pos base_lt_one p) :=\n{\n  abv_nonneg := by {\n    intro a, unfold padic_abv, split_ifs, refl,\n    apply pow_nonneg, exact le_of_lt base_pos,\n  },\n  abv_eq_zero := by {\n    intro a, unfold padic_abv, split_ifs, tauto,\n    finish [pow_ne_zero (padic_val p a) (ne.symm $ ne_of_lt base_pos)],\n  },\n  abv_add := by {\n    intros x y,\n    unfold padic_abv,\n    have pow_x_pos := pow_pos base_pos (padic_val p x),\n    have pow_y_pos := pow_pos base_pos (padic_val p y),\n    exact if hx: x = 0 then\n        by { simp [hx], }\n      else if hy: y = 0 then\n        by { simp [hy], }\n      else if hxy: x + y = 0 then\n        by {\n          simp [hx, hy, hxy],\n          linarith only [pow_x_pos, pow_y_pos],\n        }\n      else by {\n        suffices p₁: real.rpow base (padic_val p (x + y)) ≤\n          max\n            (real.rpow base (padic_val p x))\n            (real.rpow base (padic_val p y)),\n        {\n          have p₂ := max_le_add_of_nonneg (le_of_lt pow_x_pos) (le_of_lt pow_y_pos),\n          repeat { rw [real.rpow_eq_pow, real.rpow_nat_cast] at p₁, },\n          simp [hx, hy, hxy, le_trans p₁ p₂],\n        },\n\n        set c := base⁻¹ with c_def,\n        obtain ⟨ one_lt_c, base_rw, c_nonneg ⟩: 1 < c ∧ base = c⁻¹ ∧ 0 ≤ c,\n        {\n          rw c_def,\n          rw inv_inv',\n          exact ⟨ one_lt_inv base_pos base_lt_one, rfl,\n            inv_nonneg.2 $ le_of_lt base_pos ⟩,\n        },\n        have pow_c_mono: monotone (pow c),\n        from λ a b h, real.rpow_le_rpow_of_exponent_le (le_of_lt one_lt_c) h,\n        \n        have p₀ := (int.neg_le_neg $ int.coe_nat_le.2 $ padic_val_add p hxy),\n        \n        repeat { rw base_rw, },\n        repeat { rw real.rpow_eq_pow, },\n        repeat { rw real.inv_rpow c_nonneg, },\n        repeat { rw ← real.rpow_neg c_nonneg, },\n        rw ← monotone.map_max pow_c_mono,\n        rw ← ge_iff_le at p₀,\n        rw max_neg_neg,\n        rw ← monotone.map_min,\n        {\n          apply pow_c_mono,\n          exact_mod_cast p₀,\n        },\n        exact nat.mono_cast,\n      },\n  },\n  abv_mul := by {\n    intros x y,\n    unfold padic_abv,\n    exact if hx: x = 0 then\n      by simp [hx]\n    else if hy: y = 0 then\n      by simp [hy]\n    else by { simp [hx, hy, padic_val_mul p x y, pow_add _ _ _], },\n  },\n}\n\nlemma padic_abv_primes {α} [integral_domain α] [is_principal_ideal_ring α]\n    [normalization_monoid α]\n    (base: ℝ) (base_pos: 0 < base) (base_lt_one: base < 1)\n    (p: α) [p_prime: fact (prime p)]:\n      ∀ q: α, prime q →\n      padic_abv base base_pos base_lt_one p q =\n        if associated q p then base else 1 :=\nbegin\n  intros q q_prime,\n  unfold padic_abv,\n  rw padic_val_primes p q q_prime,\n  simp [q_prime.1],\nend\n\nlemma padic_abv_bounded {α} [integral_domain α] [is_principal_ideal_ring α]\n    [normalization_monoid α]\n    (base: ℝ) (base_pos: 0 < base) (base_lt_one: base < 1)\n    (p: α) [p_prime: fact (prime p)]:\n      ∀ a: α, padic_abv base base_pos base_lt_one p a ≤ 1 :=\nbegin\n  set abv := (padic_abv base base_pos base_lt_one p) with abv_def,\n  \n  intro a,\n  refine wf_dvd_monoid.induction_on_irreducible a ((abv_zero abv).symm ▸ zero_le_one) _ _,\n  {\n    rintros _ ⟨ u, rfl ⟩,\n    rw abv_def,\n    unfold padic_abv,\n    simp [padic_val_units p u],\n  },\n  {\n    intros a q ha hq abva_le_one,\n    rw abv_mul abv,\n    convert mul_le_mul _ abva_le_one (abv_nonneg abv a) (zero_le_one),\n    rw one_mul,\n    rw principal_ideal_ring.irreducible_iff_prime at hq,\n    rw [abv_def, padic_abv_primes base base_pos base_lt_one p q hq],\n    by_cases hpq: associated q p; simp [hpq, if_true, le_of_lt base_lt_one],\n  },\nend\n\ndef sample_padic_abv {α} [integral_domain α] [is_principal_ideal_ring α]\n  [normalization_monoid α]\n  (p: α) [p_prime: fact (prime p)]: α → ℝ :=\n    padic_abv (1/2) one_half_pos one_half_lt_one p\n\ninstance sample_padic_abv_is_absolute_value {α} [integral_domain α] [is_principal_ideal_ring α]\n    [normalization_monoid α]\n    (p: α) [p_prime: fact (prime p)]: is_absolute_value (sample_padic_abv p) :=\n  padic_abv_is_absolute_value (1/2) one_half_pos one_half_lt_one p\n\nlemma sample_padic_abv_on_primes {α} [integral_domain α] [is_principal_ideal_ring α]\n    [normalization_monoid α] (p: α) [p_prime: fact (prime p)]:\n      ∀ q: α, prime q →\n      sample_padic_abv p q = if associated q p then 1/2 else 1 :=\npadic_abv_primes (1/2) one_half_pos one_half_lt_one p\n\nlemma sample_padic_abv_bounded {α} [integral_domain α] [is_principal_ideal_ring α]\n    [normalization_monoid α] (p: α) [p_prime: fact (prime p)]:\n      ∀ a: α, sample_padic_abv p a ≤ 1 :=\npadic_abv_bounded (1/2) one_half_pos one_half_lt_one p\n\ndef hom_of_abv {α} [linear_ordered_field α] {β} [ring β] [nontrivial β]\n  (abv: β → α) [is_absolute_value abv]:\n  monoid_with_zero_hom β α :=\n{\n  to_fun := abv,\n  map_zero' := abv_zero abv,\n  map_one' := abv_one abv,\n  map_mul' := abv_mul abv,\n}\n\ndef hom_of_equiv {α} [comm_ring α]\n  (φ: monoid_with_zero_hom α ℝ) (a: ℝ) (a_pos: 0 < a)\n  (nonneg: ∀ a: α, 0 ≤ φ a):\n  monoid_with_zero_hom α ℝ :=\n{\n  to_fun := (λ r, (φ r) ^ a),\n  map_zero' := by {\n    rw [← monoid_with_zero_hom.to_fun_eq_coe, φ.map_zero'],\n    exact real.zero_rpow (ne.symm $ ne_of_lt a_pos),\n  },\n  map_one' := by {\n    rw [← monoid_with_zero_hom.to_fun_eq_coe, φ.map_one'],\n    exact real.one_rpow a,\n  },\n  map_mul' := by {\n    intros x y,\n    rw [← monoid_with_zero_hom.to_fun_eq_coe, φ.map_mul'],\n    have p: ∀ a: α, 0 ≤ φ.to_fun a := nonneg,\n    rw real.mul_rpow (p x) (p y),\n  },\n}\n", "meta": {"author": "RaitoBezarius", "repo": "berkovich-spaces", "sha": "0a49f75a599bcb20333ec86b301f84411f04f7cf", "save_path": "github-repos/lean/RaitoBezarius-berkovich-spaces", "path": "github-repos/lean/RaitoBezarius-berkovich-spaces/berkovich-spaces-0a49f75a599bcb20333ec86b301f84411f04f7cf/src/valuations/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125737597972, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.45134919278793656}}
{"text": "import japanese_bracket\nimport analysis.schwartz_space\n\nnoncomputable theory\n\nopen_locale big_operators nnreal filter topological_space ennreal schwartz_space\n\nopen asymptotics filter set real measure_theory finite_dimensional \n\nvariables {E F : Type*}\n\nnamespace schwartz_map\n\nvariables [normed_add_comm_group E] [normed_space ℝ E] [finite_dimensional ℝ E]\nvariables [measure_space E] [borel_space E] [(@volume E _).is_add_haar_measure]\nvariables [normed_add_comm_group F] [normed_space ℝ F] \n\n@[protected, measurability] lemma ae_strongly_measurable (f : 𝓢(E, F)) : ae_strongly_measurable (f : E → F) volume :=\nf.continuous.ae_strongly_measurable\n\nlemma one_add_pow_smul_le (f : 𝓢(E, F)) (x : E) (n : ℕ): ∥(1 + ∥x∥) ^ n • f x∥ ≤\n  ∑ (m : ℕ) in finset.range (n + 1), (n.choose m : ℝ) * (schwartz_map.seminorm ℝ m 0) f :=\nbegin\n  rw add_comm,\n  rw add_pow,\n  rw finset.sum_smul,\n  simp only [one_pow, mul_one],\n  refine (norm_sum_le (finset.range (n + 1)) _).trans _,\n  refine finset.sum_le_sum (λ m hm, _),\n  rw mul_comm,\n  simp only [←smul_smul, norm_smul, norm_coe_nat, norm_pow, norm_norm],\n  exact mul_le_mul_of_nonneg_left (f.norm_pow_mul_le_seminorm ℝ _ _) (by positivity),\nend\n\n/-- To be generalized to all p -/\n@[protected] lemma mem_ℒp_one (f : 𝓢(E, F)) : mem_ℒp (f : E → F) 1 volume :=\nbegin\n  have hr : (finrank ℝ E : ℝ) < finrank ℝ E + 1 := lt_add_one (finrank ℝ E), \n  have h := mem_ℒp_rpow_neg_one_add_norm hr,\n  let c := ∑ (m : ℕ) in finset.range ((finrank ℝ E + 1) + 1),\n    ((finrank ℝ E + 1).choose m : ℝ) * (schwartz_map.seminorm ℝ m 0) f,\n  have h' : ∀ x : E, ∥f x∥ ≤ c * ∥(1 + ∥x∥) ^ -((finrank ℝ E : ℝ) + 1)∥ :=\n  begin\n    intros x,\n    have hpos : 0 < 1 + ∥x∥ := by positivity,\n    rw ←one_smul ℝ (f x),\n    nth_rewrite 0 ←real.rpow_zero (1 + ∥x∥),\n    rw ←sub_self ((finrank ℝ E : ℝ) + 1),\n    rw sub_eq_neg_add,\n    rw real.rpow_add hpos,\n    rw ←smul_smul,\n    rw norm_smul,\n    rw mul_comm,\n    refine mul_le_mul_of_nonneg_right _ (by positivity),\n    norm_cast,\n    exact one_add_pow_smul_le _ _ _,\n  end,\n  exact h.of_le_mul (by measurability) (ae_of_all _ h'),\nend\n\n@[protected] lemma integrable (f : 𝓢(E, F)) : integrable (f : E → F) :=\nbegin\n  rw ←mem_ℒp_one_iff_integrable,\n  exact f.mem_ℒp_one,\nend\n\nend schwartz_map\n\nsection fourier_transform_aux\n\nvariables [inner_product_space ℝ E]\nvariables [normed_add_comm_group F] [normed_space ℝ F] [complete_space F] [finite_dimensional ℝ F]\nvariables [has_smul ℂ F]\n\nlemma complex.differentiable_at_coe {f : E → ℝ} {x : E} (hf : differentiable_at ℝ f x) :\n  differentiable_at ℝ (λ y, (f y : ℂ)) x :=\ncomplex.of_real_clm.differentiable_at.comp _ hf\n\nlemma complex.differentiable_coe {f : E → ℝ} (hf : differentiable ℝ f) :\n  differentiable ℝ (λ x, (f x : ℂ)) :=\ncomplex.of_real_clm.differentiable.comp hf\n\nlemma complex.fderiv_coe {f : E → ℝ} {y : E} (hf : differentiable_at ℝ f y) :\n  fderiv ℝ (λ x, (f x : ℂ)) y = complex.of_real_clm.comp (fderiv ℝ f y) :=\nbegin\n  change fderiv ℝ (λ x, complex.of_real_clm (f x)) y = complex.of_real_clm.comp (fderiv ℝ f y),\n  convert fderiv.comp _ complex.of_real_clm.differentiable_at hf,\n  exact complex.of_real_clm.fderiv.symm,\nend\n\nlemma complex.fderiv_exp {f : E → ℂ} {x : E} (hc : differentiable_at ℝ f x) :\n  fderiv ℝ (λ x, complex.exp (f x)) x = complex.exp (f x) • (fderiv ℝ f x) :=\nhc.has_fderiv_at.cexp.fderiv\n\nlemma inner_differentiable_at {y : E} {z : E} : differentiable_at ℝ (λ x, @inner ℝ _ _ y x) z :=\n(@innerSL ℝ _ _ _ y).differentiable_at\n\nlemma inner_differentiable {y : E} : differentiable ℝ (λ x, @inner ℝ _ _ y x) :=\n(@innerSL ℝ _ _ _ y).differentiable\n\nlemma fderiv_inner {y x₀ : E} : fderiv ℝ (λ x, @inner ℝ _ _ y x) x₀ = innerSL y :=\n(@innerSL ℝ _ _ _ y).fderiv\n\nlemma fderiv_exp_inner_left (x₀ ξ : E) : fderiv ℝ (λ x, complex.exp (- complex.I * @inner ℝ _ _ x ξ)) x₀ =\n  (complex.exp (-complex.I * (@inner ℝ _ _ x₀ ξ)) * -complex.I) • complex.of_real_clm.comp (innerSL ξ) :=\nbegin\n  have hdiff_inner : differentiable_at ℝ (λ (x : E), ↑(inner ξ x)) x₀ :=\n  (complex.differentiable_coe inner_differentiable).differentiable_at,\n  have hdiff_inner' : differentiable_at ℝ (λ (x : E), -complex.I * ↑(inner ξ x)) x₀ :=\n  differentiable_at.const_mul hdiff_inner _,\n  --((complex.differentiable_coe inner_differentiable).const_mul _).differentiable_at,\n  simp_rw real_inner_comm,\n  rw complex.fderiv_exp hdiff_inner',\n  rw fderiv_const_mul hdiff_inner,\n  rw complex.fderiv_coe inner_differentiable_at,\n  rw fderiv_inner,\n  rw ←mul_smul,\n  simp only [real_inner_comm x₀ ξ],\n  /-simp_rw real_inner_comm,\n  rw ←fderiv_exp_inner_left ξ₀ x,\n  congr,\n  ext1,\n  rw real_inner_comm,-/\nend\n\nlemma fderiv_exp_inner_right (ξ₀ x : E) : fderiv ℝ (λ ξ, complex.exp (- complex.I * @inner ℝ _ _ x ξ)) ξ₀ =\n  (complex.exp (-complex.I * (@inner ℝ _ _ x ξ₀)) * -complex.I) • complex.of_real_clm.comp (innerSL x) :=\nbegin\n  have hdiff_inner : differentiable_at ℝ (λ (ξ : E), ↑(inner x ξ)) ξ₀ :=\n  (complex.differentiable_coe inner_differentiable).differentiable_at,\n  have hdiff_inner' : differentiable_at ℝ (λ (ξ : E), -complex.I * ↑(inner x ξ)) ξ₀ :=\n  differentiable_at.const_mul hdiff_inner _,\n  rw complex.fderiv_exp hdiff_inner',\n  rw fderiv_const_mul hdiff_inner,\n  rw complex.fderiv_coe inner_differentiable_at,\n  rw fderiv_inner,\n  rw ←mul_smul,\nend\n\nend fourier_transform_aux\n\n.\n\nsection normedC\n\nvariables [inner_product_space ℝ E]\nvariables [normed_add_comm_group F] [normed_space ℝ F] [complete_space F] [finite_dimensional ℝ F]\nvariables [normed_space ℂ F]\n\nvariables (c : ℂ)\n\ndef innerSL_mul (f : 𝓢(E, F)) : 𝓢(E, E →L[ℝ] F) :=\n{ to_fun := λ x, ((@continuous_linear_map.lsmul ℝ F _ _ _ ℝ _ _ _ _).flip (f x)).comp (innerSL x),\n  -- not clear whether this is the correct definition\n  smooth' := sorry,\n  decay' := sorry,\n}\n\nvariables (x : E) (f : 𝓢(E, F)) (g : 𝓢(E, E→L[ℝ] F))\n\n#check c • g\n\n#check complex.of_real_clm.comp (innerSL x)\n#check f x\n#check ((@continuous_linear_map.lsmul ℝ F _ _ _ ℝ _ _ _ _).flip (f x)).comp (innerSL x)\n#check (@continuous_linear_map.lsmul ℂ F _ _ _ ℂ _ _ _ _).flip (f x)--F →L[ℝ] ℝ →L[ℝ] F)\n\n\n#check λ y, complex.of_real_clm.comp (innerSL x) y • f x\n\nend normedC\n\n#exit\n\nvariables [measure_space E] --[borel_space E] [(@volume E _).is_add_haar_measure]\n\n/-- The Fourier transform -/\ndef fourier_transform_aux (f : E → F) (ξ : E) : F :=\n  (2 * real.pi)^(-(finrank ℝ E : ℝ) / 2) • ∫ x, complex.exp (- complex.I * (@inner ℝ _ _ x ξ)) • f x\n\ndef fourier_transform (f : 𝓢(E, F)) : 𝓢(E, F) :=\n  { to_fun := fourier_transform_aux f,\n    smooth' := begin\n      rw cont_diff_top,\n      intro n,\n      sorry,\n    end,\n    decay' := begin\n      intros k n,\n      sorry,\n    end }\n\n\nend fourier_transform\n", "meta": {"author": "mcdoll", "repo": "sphere-packing", "sha": "96c5eac1d8b16a368c0e93aa8a5af4125a3cc419", "save_path": "github-repos/lean/mcdoll-sphere-packing", "path": "github-repos/lean/mcdoll-sphere-packing/sphere-packing-96c5eac1d8b16a368c0e93aa8a5af4125a3cc419/src/fourier_transform/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7520125682019722, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.45134918945219465}}
{"text": "import tactic.congrm\n\nvariables {X : Type*} [has_add X] [has_mul X] (a b c d : X) (f : X → X)\n\nexample (H : a = b) : f a + f a = f b + f b :=\nby congrm f _ + f _; exact H\n\nexample {g : X → X} (H : a = b) (H' : c + f a = c + f d) (H'' : f d = f b) :\n  f (g a) * (f d + (c + f a)) = f (g b) * (f b + (c + f d)) :=\nbegin\n  congrm f (g _) * (_ + _),\n  { exact H },\n  { exact H'' },\n  { exact H' },\nend\n\nexample (H' : c + (f a) = c + (f d)) (H'' : f d = f b) :\n  f (f a) * (f d + (c + f a)) = f (f a) * (f b + (c + f d)) :=\nbegin\n  congrm f (f _) * (_ + _),\n  { exact H'' },\n  { exact H' },\nend\n\nexample (H' : c + (f a) = c + (f d)) (H'' : f d = f b) :\n  f (f a) * (f d + (c + f a)) = f (f a) * (f b + (c + f d)) :=\nbegin\n  congrm f (f _) * (_ + _),\n  { exact H'' },\n  { exact H' },\nend\n\nexample {p q} [decidable p] [decidable q] (h : p ↔ q) :\n  ite p 0 1 = ite q 0 1 :=\nbegin\n  congrm ite _ 0 1,\n  exact h,\nend\n\nexample {p q} [decidable p] [decidable q] (h : p ↔ q) :\n  ite p 0 1 = ite q 0 1 :=\nbegin\n  congrm ite _ 0 1,\n  exact h,\nend\n\nexample {a b : ℕ} (h : a = b) : (λ y : ℕ, ∀ z, a + a = z) = (λ x, ∀ z, b + a = z) :=\nbegin\n  congrm λ x, ∀ w, _ + a = w,\n  exact h,\nend\n\nexample (h : 5 = 3) : (⟨5 + 1, dec_trivial⟩ : fin 10) = ⟨3 + 1, dec_trivial⟩ :=\nbegin\n  congrm ⟨_ + 1, _⟩,\n  exact h,\nend\n\nexample : true ∧ false ↔ (true ∧ true) ∧ false :=\nbegin\n  congrm _ ∧ _,\n  exact (true_and true).symm,\nend\n\nexample {f g : ℕ → ℕ → ℕ} (h : f = g) : (λ i j, f i j) = (λ i j, g i j) :=\nbegin\n  congrm λ i j, _,\n  guard_target f i j = g i j,\n  rw h,\nend\n\nexample : true ∧ false ↔ (true ∧ true) ∧ false :=\nbegin\n  congrm _₂ _ _,\n  exact (true_and true).symm,\nend\n\nexample {g : X → X} (H : a = b) (H' : c + f a = c + f d) (H'' : f d = f b) :\n  f (g a) * (f d + (c + f a)) = f (g b) * (f b + (c + f d)) :=\nbegin\n  congrm _₂ (f (_₁ _)) (_₂ _ _),\n  { exact H },\n  { exact H'' },\n  { exact H' },\nend\n\nexample {A B C D E : Type*} [has_add A] [has_mul C] {a1 a2 a3 : A} (b1 b2 : B) {c1 c2 c3 : C}\n  (d1 d2 : D) (r : A → B → C → D → E)\n  (a23 : a2 = a3) (b12 : b1 = b2) (c23 : c2 = c3) (d12 : d1 = d2) :\n  r (a1 + a2) b1 (c1 * c2) d1 = r (a1 + a3) b2 (c1 * c3) d2 :=\nby congrm _₄ (_₂ _ _) _ (_₂ _ _) _; assumption\n\nexample {A B C D : Type*} [has_add A] [has_mul C] {a1 a2 a3 : A} (b1 b2 : B) {c1 c2 c3 : C}\n  (r : A → B → C → D)\n  (a23 : a2 = a3) (b12 : b1 = b2) (c23 : c2 = c3) :\n  r (a1 + a2) b1 (c1 * c2) = r (a1 + a3) b2 (c1 * c3) :=\nby congrm _₃ (_₂ _ _) _ (_₂ _ _); assumption\n\nexample {A : Type*} (s : A → ℕ) {a1 a3 : ℕ} {a4 a5 : A} (a45 : a4 = a5) :\n  (a1 + (s a4)) * a3 = (a1 + (s a5)) * a3 :=\nbegin\n  congrm _₂ (_ + (_₁ _)) _,\n  exact a45,\nend\n\nexample {A B C : Type*} [has_add A] [has_mul B] {a1 a2 a3 : A} (b1 b2 b3 : B)\n  (r : A → B → C) (a23 : a2 = a3) (b13 : b1 = b3) :\n  r (a1 + a2) (b1 * b2) = r (a1 + a3) (b3 * b2) :=\nby congrm _₂ (_₂ _ _) (_₂ _ _); assumption\n\nexample {A B C : Type*} (r : A → B) (s : B → C) (a b : A) (ab : a = b) :\n  s (r a) = s (r b) :=\nbegin\n  congrm _₁ (_₁ _),\n  exact ab,\nend\n\nopen tactic\n\nexample {A : Type} [has_add A] (a b c d e f : A) (r : A → A → A → A) (s : A → A)\n  (bd : b = d) (af : a = f) (bc : b = c) (ae : a = e) :\n  r b (a + s b) a = r d (f + s c) e :=\nbegin\n  congrm _₃ _ (_ + (_₁ _)) _,\n  exact bd,\n  exact af,\n  exact bc,\n  exact ae,\nend\n\nexample {A : Type} [has_add A] (a b c d : A) (r : A → A → A) (s : A → A) (bd : b = d) (bc : b = c) :\n  r b (a + s b) = r d (a + s c) :=\nbegin\n  congrm _₂ _ (_₂ _ (s _)),  exact bd, exact bc,\n/-  any one of these alternatives to the line above proves the goal\n  congrm _₂ _ (_₂ _ (_₁ _)), exact bd, exact bc,\n  congrm _₂ _ (_ + (_₁ _)),  exact bd, exact bc,\n  congrm _₂ _ (_ + (s _)),   exact bd, exact bc,\n  congrm r _ (_₂ _ (s _)),   exact bd, exact bc,\n  congrm r _ (_₂ _ (_₁ _)),  exact bd, exact bc,\n  congrm r _ (_ + (s _)),    exact bd, exact bc,\n  congrm r _ (_ + (_₁ _)),   exact bd, exact bc,\n-/\nend\n\nexample {W X Y Z : Type*} (w w' : W) (y y' : Y) (r : X → Y → Z) (s : W → X)\n  (hw : w = w') (hy : y = y') :\n  r (s w) y = r (s w') y' :=\nby congrm _₂ (_₁ _) _; assumption\n\nexample {W X Y : Type*} (w w' : W) (y y' : Y) (r : X → Y → ℕ) (s : W → X)\n  (hw : w = w') (hy : y = y') :\n  (2 + 2) + r (s w) y = 2 * 2 + r (s w') y' :=\nby congrm _₂ (_₂ _ _) (_₂ (_₁ _) _); assumption\n\nexample (h1 : 5 = 1) (h2 : 7 = 3) : nat.succ 5 + nat.pred 7 = nat.pred 3 * nat.succ 1 :=\nbegin\n  congrm _₂ (_₁ _) (_₁ _);\n -- the main goal becomes `3.succ + 1.pred = 3.pred * 1.succ` and `refl` closes it!\n  exact h1 <|> exact h2,\nend\n\nexample {a b c d e f g h : ℕ} (ae : a = e) (bf : b = f) (cg : c = g)  (dh : d = h) :\n  (a + b) * (c - d.succ) = (e + f) * (g - h.succ) :=\nby congrm _₂ (_₂ _ _) (_₂ _ (_₁ _)); assumption\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/congrm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7520125682019722, "lm_q1q2_score": 0.45134918945219465}}
{"text": "import tactic.interactive\nuniverse zfc_u \nvariables {α β : Type zfc_u}\n\n-- ideas around the concept of α being canonically isomorphic to β\n\nnamespace zfc \n\n-- mod of equiv so I can save typing\nstructure equiv' (α : Type zfc_u) (β : Type zfc_u) :=\n(i    : α → β)\n(j    : β → α)\n(ij : ∀ (x : α), j (i x) = x)\n(ji  : ∀ (y : β), i (j y) = y)\n\n-- it's equiv to equiv, it is absolutely fundamental for the notion of canonical isomorphism, and I like\n-- the notation better because it gets everywhere.\n\n--#print has_mul\n--@[class]\n--structure has_mul : Type u → Type u\n--fields:\n--has_mul.mul : Π {α : Type u} [c : has_mul α], α → α → α\n\n-- Fundamental theorem of has_mul\n\ndefinition mul_is_add {α : Type zfc_u} : equiv' (has_mul α) (has_add α) :=\n{ i := λ ⟨mul⟩,⟨mul⟩,\n  j := λ ⟨mul⟩,⟨mul⟩,\n  ij := λ ⟨x⟩,rfl,\n  ji := λ ⟨x⟩, rfl,\n}\n\ndefinition equiv_mul {α β : Type zfc_u} : equiv' α β → equiv' (has_mul α) (has_mul β) := λ E,\n{ i :=  λ αmul,⟨λ b1 b2, E.i (@has_mul.mul α αmul (E.j b1) (E.j b2))⟩,\n  j := λ βmul,⟨λ a1 a2, E.j (@has_mul.mul β βmul (E.i a1) (E.i a2))⟩, -- didn't I just write that?\n                                                                      -- should we introduce E-dual?\n  ij := λ f, begin \n    cases f, -- aargh why do I struggle\n    suffices :  (λ (a1 a2 : α), E.j (E.i (f (E.j (E.i a1)) (E.j (E.i a2))))) = (λ a1 a2, f a1 a2),\n      by rw this,\n    funext,\n    simp [E.ij,E.ji], -- got there in the end\n  end,\n  ji := -- term mode (because i'm a year older)\n λ ⟨g⟩, by simp [E.ij,E.ji]\n}\n\nend zfc \n", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/canonical_isomorphism/equiv_mul_stuck.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859598, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.45126199738980616}}
{"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\nimport measure_theory.measurable_space\n\nimport measure_theory.measure_space\nimport measure_theory.outer_measure\nimport measure_theory.lebesgue_measure\nimport measure_theory.integration\nimport measure_theory.set_integral\nimport measure_theory.borel_space\nimport data.set.countable\nimport formal_ml.nnreal\nimport formal_ml.sum\nimport formal_ml.core\nimport formal_ml.measurable_space\nimport formal_ml.semiring\nimport formal_ml.real_measurable_space\nimport formal_ml.set\nimport formal_ml.filter_util\nimport topology.instances.ennreal\nimport formal_ml.int\nimport formal_ml.with_density_compose_eq_multiply\nimport formal_ml.classical\n\n\nlemma with_density_le_with_density {Ω:Type*} {M:measurable_space Ω}\n  {μ:measure_theory.measure Ω} {x y:Ω → ennreal} \n  {S:set Ω}:\n  measurable_set S →\n  (∀ ω ∈ S, x ω ≤ y ω) →  \n  μ.with_density x S ≤ μ.with_density y S :=\nbegin\n  intros A3 A4,\n  rw measure_theory.with_density_apply2' μ x S A3,\n  rw measure_theory.with_density_apply2' μ y S A3,\n  apply measure_theory.lintegral_mono,\n\n  rw le_func_def2,\n  intros ω,\n  cases (classical.em (ω ∈ S)) with A5 A5,\n  {\n    rw set.indicator_of_mem A5,\n    rw set.indicator_of_mem A5,\n    apply A4 _ A5,\n  },\n  {\n    rw set.indicator_of_not_mem A5,\n    rw set.indicator_of_not_mem A5,\n    apply le_refl _,\n  },\nend\n\n\n--TODO: Remove measurability?\nlemma with_density_sup_of_le {Ω:Type*} {M:measurable_space Ω}\n  {μ:measure_theory.measure Ω} {x y:Ω → ennreal} \n  {S:set Ω}:measurable x → measurable y →\n  measurable_set S →\n  (∀ ω ∈ S, x ω ≤ y ω) →  \n  μ.with_density (x⊔y) S = μ.with_density y S :=\nbegin\n  intros A1 A2 A3 A4,\n  rw measure_theory.with_density_apply2' μ (x ⊔ y) S A3,\n  rw measure_theory.with_density_apply2' μ y S A3,\n  have A5:set.indicator S (x ⊔ y) = set.indicator S y,\n  {\n    apply funext,\n    intro ω,\n    cases (classical.em (ω∈ S)) with A5A A5A,\n    {\n      rw set.indicator_of_mem A5A,\n      rw set.indicator_of_mem A5A,\n      rw sup_apply,\n      simp [A4 _ A5A],\n    },\n    {\n      rw set.indicator_of_not_mem A5A,\n      rw set.indicator_of_not_mem A5A,\n    },\n  },\n  rw A5,\nend\n\n\nlemma measure_theory.measure.sup_le_apply {Ω:Type*}\n  {M:measurable_space Ω}\n  {μ ν m:measure_theory.measure Ω}\n  {S:set Ω}:measurable_set S →\n  (μ ≤ m) →\n  (ν ≤ m) → \n  (μ ⊔ ν) S ≤ m S :=\nbegin\n  intros A1 A2 A3,\n  have A4:μ ⊔ ν ≤ m := \n      @sup_le (measure_theory.measure Ω) _ μ ν m A2 A3,\n  apply A4,\n  apply A1,\nend\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/radon_nikodym_extra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.45120226731713}}
{"text": "/-\nCopyright (c) 2020 Bhavik Mehta, Edward Ayers, Thomas Read. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Bhavik Mehta, Edward Ayers, Thomas Read\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.limits.shapes.finite_products\nimport Mathlib.category_theory.limits.preserves.shapes.binary_products\nimport Mathlib.category_theory.closed.monoidal\nimport Mathlib.category_theory.monoidal.of_has_finite_products\nimport Mathlib.category_theory.adjunction.default\nimport Mathlib.category_theory.adjunction.mates\nimport Mathlib.category_theory.epi_mono\nimport Mathlib.PostPort\n\nuniverses v u u₂ \n\nnamespace Mathlib\n\n/-!\n# Cartesian closed categories\n\nGiven a category with finite products, the cartesian monoidal structure is provided by the local\ninstance `monoidal_of_has_finite_products`.\n\nWe define exponentiable objects to be closed objects with respect to this monoidal structure,\ni.e. `(X × -)` is a left adjoint.\n\nWe say a category is cartesian closed if every object is exponentiable\n(equivalently, that the category equipped with the cartesian monoidal structure is closed monoidal).\n\nShow that exponential forms a difunctor and define the exponential comparison morphisms.\n\n## TODO\nSome of the results here are true more generally for closed objects and\nfor closed monoidal categories, and these could be generalised.\n-/\n\nnamespace category_theory\n\n\n/--\nAn object `X` is *exponentiable* if `(X × -)` is a left adjoint.\nWe define this as being `closed` in the cartesian monoidal structure.\n-/\ndef exponentiable {C : Type u} [category C] [limits.has_finite_products C] (X : C) := closed X\n\n/--\nIf `X` and `Y` are exponentiable then `X ⨯ Y` is.\nThis isn't an instance because it's not usually how we want to construct exponentials, we'll usually\nprove all objects are exponential uniformly.\n-/\ndef binary_product_exponentiable {C : Type u} [category C] [limits.has_finite_products C] {X : C}\n    {Y : C} (hX : exponentiable X) (hY : exponentiable Y) : exponentiable (X ⨯ Y) :=\n  closed.mk\n    (adjunction.left_adjoint_of_nat_iso (iso.symm (monoidal_category.tensor_left_tensor X Y)))\n\n/--\nThe terminal object is always exponentiable.\nThis isn't an instance because most of the time we'll prove cartesian closed for all objects\nat once, rather than just for this one.\n-/\ndef terminal_exponentiable {C : Type u} [category C] [limits.has_finite_products C] :\n    exponentiable (⊤_C) :=\n  unit_closed\n\n/--\nA category `C` is cartesian closed if it has finite products and every object is exponentiable.\nWe define this as `monoidal_closed` with respect to the cartesian monoidal structure.\n-/\ndef cartesian_closed (C : Type u) [category C] [limits.has_finite_products C] := monoidal_closed C\n\n/-- This is (-)^A. -/\ndef exp {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] :\n    C ⥤ C :=\n  is_left_adjoint.right (monoidal_category.tensor_left A)\n\n/-- The adjunction between A ⨯ - and (-)^A. -/\ndef exp.adjunction {C : Type u} [category C] (A : C) [limits.has_finite_products C]\n    [exponentiable A] : functor.obj limits.prod.functor A ⊣ exp A :=\n  is_left_adjoint.adj\n\n/-- The evaluation natural transformation. -/\ndef ev {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] :\n    exp A ⋙ functor.obj limits.prod.functor A ⟶ 𝟭 :=\n  adjunction.counit is_left_adjoint.adj\n\n/-- The coevaluation natural transformation. -/\ndef coev {C : Type u} [category C] (A : C) [limits.has_finite_products C] [exponentiable A] :\n    𝟭 ⟶ functor.obj limits.prod.functor A ⋙ exp A :=\n  adjunction.unit is_left_adjoint.adj\n\n@[simp] theorem exp_adjunction_counit {C : Type u} [category C] (A : C)\n    [limits.has_finite_products C] [exponentiable A] :\n    adjunction.counit (exp.adjunction A) = ev A :=\n  rfl\n\n@[simp] theorem exp_adjunction_unit {C : Type u} [category C] (A : C) [limits.has_finite_products C]\n    [exponentiable A] : adjunction.unit (exp.adjunction A) = coev A :=\n  rfl\n\n@[simp] theorem ev_naturality {C : Type u} [category C] (A : C) [limits.has_finite_products C]\n    [exponentiable A] {X : C} {Y : C} (f : X ⟶ Y) :\n    limits.prod.map 𝟙 (functor.map (exp A) f) ≫ nat_trans.app (ev A) Y =\n        nat_trans.app (ev A) X ≫ f :=\n  nat_trans.naturality (ev A) f\n\n@[simp] theorem coev_naturality_assoc {C : Type u} [category C] (A : C)\n    [limits.has_finite_products C] [exponentiable A] {X : C} {Y : C} (f : X ⟶ Y) {X' : C}\n    (f' : functor.obj (functor.obj limits.prod.functor A ⋙ exp A) Y ⟶ X') :\n    f ≫ nat_trans.app (coev A) Y ≫ f' =\n        nat_trans.app (coev A) X ≫ functor.map (exp A) (limits.prod.map 𝟙 f) ≫ f' :=\n  sorry\n\n@[simp] theorem ev_coev {C : Type u} [category C] (A : C) (B : C) [limits.has_finite_products C]\n    [exponentiable A] :\n    limits.prod.map 𝟙 (nat_trans.app (coev A) B) ≫ nat_trans.app (ev A) (A ⨯ B) = 𝟙 :=\n  adjunction.left_triangle_components (exp.adjunction A)\n\n@[simp] theorem coev_ev {C : Type u} [category C] (A : C) (B : C) [limits.has_finite_products C]\n    [exponentiable A] :\n    nat_trans.app (coev A) (functor.obj (exp A) B) ≫ functor.map (exp A) (nat_trans.app (ev A) B) =\n        𝟙 :=\n  adjunction.right_triangle_components (exp.adjunction A)\n\nprotected instance obj.limits.preserves_colimits {C : Type u} [category C] (A : C)\n    [limits.has_finite_products C] [exponentiable A] :\n    limits.preserves_colimits (functor.obj limits.prod.functor A) :=\n  adjunction.left_adjoint_preserves_colimits (exp.adjunction A)\n\n-- Wrap these in a namespace so we don't clash with the core versions.\n\nnamespace cartesian_closed\n\n\n/-- Currying in a cartesian closed category. -/\ndef curry {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C]\n    [exponentiable A] : (A ⨯ Y ⟶ X) → (Y ⟶ functor.obj (exp A) X) :=\n  equiv.to_fun (adjunction.hom_equiv is_left_adjoint.adj Y X)\n\n/-- Uncurrying in a cartesian closed category. -/\ndef uncurry {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C]\n    [exponentiable A] : (Y ⟶ functor.obj (exp A) X) → (A ⨯ Y ⟶ X) :=\n  equiv.inv_fun (adjunction.hom_equiv is_left_adjoint.adj Y X)\n\nend cartesian_closed\n\n\ntheorem curry_natural_left_assoc {C : Type u} [category C] {A : C} {X : C} {X' : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] (f : X ⟶ X') (g : A ⨯ X' ⟶ Y) :\n    ∀ {X'_1 : C} (f' : functor.obj (exp A) Y ⟶ X'_1),\n        cartesian_closed.curry (limits.prod.map 𝟙 f ≫ g) ≫ f' = f ≫ cartesian_closed.curry g ≫ f' :=\n  sorry\n\ntheorem curry_natural_right_assoc {C : Type u} [category C] {A : C} {X : C} {Y : C} {Y' : C}\n    [limits.has_finite_products C] [exponentiable A] (f : A ⨯ X ⟶ Y) (g : Y ⟶ Y') {X' : C}\n    (f' : functor.obj (exp A) Y' ⟶ X') :\n    cartesian_closed.curry (f ≫ g) ≫ f' = cartesian_closed.curry f ≫ functor.map (exp A) g ≫ f' :=\n  sorry\n\ntheorem uncurry_natural_right {C : Type u} [category C] {A : C} {X : C} {Y : C} {Y' : C}\n    [limits.has_finite_products C] [exponentiable A] (f : X ⟶ functor.obj (exp A) Y) (g : Y ⟶ Y') :\n    cartesian_closed.uncurry (f ≫ functor.map (exp A) g) = cartesian_closed.uncurry f ≫ g :=\n  adjunction.hom_equiv_naturality_right_symm is_left_adjoint.adj f g\n\ntheorem uncurry_natural_left {C : Type u} [category C] {A : C} {X : C} {X' : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] (f : X ⟶ X') (g : X' ⟶ functor.obj (exp A) Y) :\n    cartesian_closed.uncurry (f ≫ g) = limits.prod.map 𝟙 f ≫ cartesian_closed.uncurry g :=\n  adjunction.hom_equiv_naturality_left_symm is_left_adjoint.adj f g\n\n@[simp] theorem uncurry_curry {C : Type u} [category C] {A : C} {X : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] (f : A ⨯ X ⟶ Y) :\n    cartesian_closed.uncurry (cartesian_closed.curry f) = f :=\n  equiv.left_inv (adjunction.hom_equiv is_left_adjoint.adj X Y) f\n\n@[simp] theorem curry_uncurry {C : Type u} [category C] {A : C} {X : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] (f : X ⟶ functor.obj (exp A) Y) :\n    cartesian_closed.curry (cartesian_closed.uncurry f) = f :=\n  equiv.right_inv (adjunction.hom_equiv is_left_adjoint.adj X Y) f\n\ntheorem curry_eq_iff {C : Type u} [category C] {A : C} {X : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] (f : A ⨯ Y ⟶ X)\n    (g : Y ⟶ functor.obj (exp A) X) :\n    cartesian_closed.curry f = g ↔ f = cartesian_closed.uncurry g :=\n  adjunction.hom_equiv_apply_eq is_left_adjoint.adj f g\n\ntheorem eq_curry_iff {C : Type u} [category C] {A : C} {X : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] (f : A ⨯ Y ⟶ X)\n    (g : Y ⟶ functor.obj (exp A) X) :\n    g = cartesian_closed.curry f ↔ cartesian_closed.uncurry g = f :=\n  adjunction.eq_hom_equiv_apply is_left_adjoint.adj f g\n\n-- I don't think these two should be simp.\n\ntheorem uncurry_eq {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C]\n    [exponentiable A] (g : Y ⟶ functor.obj (exp A) X) :\n    cartesian_closed.uncurry g = limits.prod.map 𝟙 g ≫ nat_trans.app (ev A) X :=\n  adjunction.hom_equiv_counit is_left_adjoint.adj\n\ntheorem curry_eq {C : Type u} [category C] {A : C} {X : C} {Y : C} [limits.has_finite_products C]\n    [exponentiable A] (g : A ⨯ Y ⟶ X) :\n    cartesian_closed.curry g = nat_trans.app (coev A) Y ≫ functor.map (exp A) g :=\n  adjunction.hom_equiv_unit is_left_adjoint.adj\n\ntheorem uncurry_id_eq_ev {C : Type u} [category C] [limits.has_finite_products C] (A : C) (X : C)\n    [exponentiable A] : cartesian_closed.uncurry 𝟙 = nat_trans.app (ev A) X :=\n  sorry\n\ntheorem curry_id_eq_coev {C : Type u} [category C] [limits.has_finite_products C] (A : C) (X : C)\n    [exponentiable A] : cartesian_closed.curry 𝟙 = nat_trans.app (coev A) X :=\n  sorry\n\ntheorem curry_injective {C : Type u} [category C] {A : C} {X : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] : function.injective cartesian_closed.curry :=\n  equiv.injective (adjunction.hom_equiv is_left_adjoint.adj Y X)\n\ntheorem uncurry_injective {C : Type u} [category C] {A : C} {X : C} {Y : C}\n    [limits.has_finite_products C] [exponentiable A] :\n    function.injective cartesian_closed.uncurry :=\n  equiv.injective (equiv.symm (adjunction.hom_equiv is_left_adjoint.adj Y X))\n\n/--\nShow that the exponential of the terminal object is isomorphic to itself, i.e. `X^1 ≅ X`.\n\nThe typeclass argument is explicit: any instance can be used.\n-/\ndef exp_terminal_iso_self {C : Type u} [category C] {X : C} [limits.has_finite_products C]\n    [exponentiable (⊤_C)] : functor.obj (exp (⊤_C)) X ≅ X :=\n  yoneda.ext (functor.obj (exp (⊤_C)) X) X\n    (fun (Y : C) (f : Y ⟶ functor.obj (exp (⊤_C)) X) =>\n      iso.inv (limits.prod.left_unitor Y) ≫ cartesian_closed.uncurry f)\n    (fun (Y : C) (f : Y ⟶ X) => cartesian_closed.curry (iso.hom (limits.prod.left_unitor Y) ≫ f))\n    sorry sorry sorry\n\n/-- The internal element which points at the given morphism. -/\ndef internalize_hom {C : Type u} [category C] {A : C} {Y : C} [limits.has_finite_products C]\n    [exponentiable A] (f : A ⟶ Y) : ⊤_C ⟶ functor.obj (exp A) Y :=\n  cartesian_closed.curry (limits.prod.fst ≫ f)\n\n/-- Pre-compose an internal hom with an external hom. -/\ndef pre {C : Type u} [category C] {A : C} {B : C} [limits.has_finite_products C] [exponentiable A]\n    (f : B ⟶ A) [exponentiable B] : exp A ⟶ exp B :=\n  coe_fn (transfer_nat_trans_self (exp.adjunction A) (exp.adjunction B))\n    (functor.map limits.prod.functor f)\n\ntheorem prod_map_pre_app_comp_ev {C : Type u} [category C] {A : C} {B : C}\n    [limits.has_finite_products C] [exponentiable A] (f : B ⟶ A) [exponentiable B] (X : C) :\n    limits.prod.map 𝟙 (nat_trans.app (pre f) X) ≫ nat_trans.app (ev B) X =\n        limits.prod.map f 𝟙 ≫ nat_trans.app (ev A) X :=\n  transfer_nat_trans_self_counit (exp.adjunction A) (exp.adjunction B)\n    (functor.map limits.prod.functor f) X\n\ntheorem uncurry_pre {C : Type u} [category C] {A : C} {B : C} [limits.has_finite_products C]\n    [exponentiable A] (f : B ⟶ A) [exponentiable B] (X : C) :\n    cartesian_closed.uncurry (nat_trans.app (pre f) X) =\n        limits.prod.map f 𝟙", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/closed/cartesian_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768249, "lm_q2_score": 0.6224593312018545, "lm_q1q2_score": 0.45120226731713}}
{"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport data.fintype.basic\nimport data.finset.sigma\n\n\n/-!\n# fintype instances for sigma types\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n-/\n\nopen function\nopen_locale nat\n\nuniverses u v\n\nvariables {α β γ : Type*}\n\nopen finset function\n\ninstance {α : Type*} (β : α → Type*)\n  [fintype α] [∀ a, fintype (β a)] : fintype (sigma β) :=\n⟨univ.sigma (λ _, univ), λ ⟨a, b⟩, by simp⟩\n\n@[simp] lemma finset.univ_sigma_univ {α : Type*} {β : α → Type*} [fintype α] [∀ a, fintype (β a)] :\n  (univ : finset α).sigma (λ a, (univ : finset (β a))) = univ := rfl\n\ninstance psigma.fintype {α : Type*} {β : α → Type*} [fintype α] [∀ a, fintype (β a)] :\n  fintype (Σ' a, β a) :=\nfintype.of_equiv _ (equiv.psigma_equiv_sigma _).symm\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/data/fintype/sigma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6224593241981982, "lm_q1q2_score": 0.4512022622403876}}
{"text": "/-\nCopyright (c) 2019 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n-/\nimport tactic.noncomm_ring\nimport data.equiv.module\nimport data.bracket\n\n/-!\n# Lie algebras\n\nThis file defines Lie rings and Lie algebras over a commutative ring together with their\nmodules, morphisms and equivalences, as well as various lemmas to make these definitions usable.\n\n## Main definitions\n\n  * `lie_ring`\n  * `lie_algebra`\n  * `lie_ring_module`\n  * `lie_module`\n  * `lie_hom`\n  * `lie_equiv`\n  * `lie_module_hom`\n  * `lie_module_equiv`\n\n## Notation\n\nWorking over a fixed commutative ring `R`, we introduce the notations:\n * `L →ₗ⁅R⁆ L'` for a morphism of Lie algebras,\n * `L ≃ₗ⁅R⁆ L'` for an equivalence of Lie algebras,\n * `M →ₗ⁅R,L⁆ N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,\n * `M ≃ₗ⁅R,L⁆ N` for an equivalence of Lie algebra modules `M`, `N` over a Lie algebra `L`.\n\n## Implementation notes\n\nLie algebras are defined as modules with a compatible Lie ring structure and thus, like modules,\nare partially unbundled.\n\n## References\n* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975)\n\n## Tags\n\nlie bracket, jacobi identity, lie ring, lie algebra, lie module\n-/\n\nuniverses u v w w₁ w₂\nopen function\n\n/-- A Lie ring is an additive group with compatible product, known as the bracket, satisfying the\nJacobi identity. -/\n@[protect_proj] class lie_ring (L : Type v) extends add_comm_group L, has_bracket L L :=\n(add_lie  : ∀ (x y z : L), ⁅x + y, z⁆ = ⁅x, z⁆ + ⁅y, z⁆)\n(lie_add  : ∀ (x y z : L), ⁅x, y + z⁆ = ⁅x, y⁆ + ⁅x, z⁆)\n(lie_self : ∀ (x : L), ⁅x, x⁆ = 0)\n(leibniz_lie : ∀ (x y z : L), ⁅x, ⁅y, z⁆⁆ = ⁅⁅x, y⁆, z⁆ + ⁅y, ⁅x, z⁆⁆)\n\n/-- A Lie algebra is a module with compatible product, known as the bracket, satisfying the Jacobi\nidentity. Forgetting the scalar multiplication, every Lie algebra is a Lie ring. -/\n@[protect_proj] class lie_algebra (R : Type u) (L : Type v) [comm_ring R] [lie_ring L]\n  extends module R L :=\n(lie_smul : ∀ (t : R) (x y : L), ⁅x, t • y⁆ = t • ⁅x, y⁆)\n\n/-- A Lie ring module is an additive group, together with an additive action of a\nLie ring on this group, such that the Lie bracket acts as the commutator of endomorphisms.\n(For representations of Lie *algebras* see `lie_module`.) -/\n@[protect_proj] class lie_ring_module (L : Type v) (M : Type w)\n  [lie_ring L] [add_comm_group M] extends has_bracket L M :=\n(add_lie     : ∀ (x y : L) (m : M), ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆)\n(lie_add     : ∀ (x : L) (m n : M), ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆)\n(leibniz_lie : ∀ (x y : L) (m : M), ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆)\n\n/-- A Lie module is a module over a commutative ring, together with a linear action of a Lie\nalgebra on this module, such that the Lie bracket acts as the commutator of endomorphisms. -/\n@[protect_proj] class lie_module (R : Type u) (L : Type v) (M : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [add_comm_group M] [module R M]\n  [lie_ring_module L M] :=\n(smul_lie : ∀ (t : R) (x : L) (m : M), ⁅t • x, m⁆ = t • ⁅x, m⁆)\n(lie_smul : ∀ (t : R) (x : L) (m : M), ⁅x, t • m⁆ = t • ⁅x, m⁆)\n\nsection basic_properties\n\nvariables {R : Type u} {L : Type v} {M : Type w} {N : Type w₁}\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables [add_comm_group M] [module R M] [lie_ring_module L M] [lie_module R L M]\nvariables [add_comm_group N] [module R N] [lie_ring_module L N] [lie_module R L N]\nvariables (t : R) (x y z : L) (m n : M)\n\n@[simp] lemma add_lie : ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆ := lie_ring_module.add_lie x y m\n\n@[simp] lemma lie_add : ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆ := lie_ring_module.lie_add x m n\n\n@[simp] lemma smul_lie : ⁅t • x, m⁆ = t • ⁅x, m⁆ := lie_module.smul_lie t x m\n\n@[simp] lemma lie_smul : ⁅x, t • m⁆ = t • ⁅x, m⁆ := lie_module.lie_smul t x m\n\nlemma leibniz_lie : ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆ := lie_ring_module.leibniz_lie x y m\n\n@[simp] lemma lie_zero : ⁅x, 0⁆ = (0 : M) := (add_monoid_hom.mk' _ (lie_add x)).map_zero\n\n@[simp] lemma zero_lie : ⁅(0 : L), m⁆ = 0 :=\n(add_monoid_hom.mk' (λ (x : L), ⁅x, m⁆) (λ x y, add_lie x y m)).map_zero\n\n@[simp] lemma lie_self : ⁅x, x⁆ = 0 := lie_ring.lie_self x\n\ninstance lie_ring_self_module : lie_ring_module L L := { ..(infer_instance : lie_ring L) }\n\n@[simp] lemma lie_skew : -⁅y, x⁆ = ⁅x, y⁆ :=\nhave h : ⁅x + y, x⁆ + ⁅x + y, y⁆ = 0, { rw ← lie_add, apply lie_self, },\nby simpa [neg_eq_iff_add_eq_zero] using h\n\n/-- Every Lie algebra is a module over itself. -/\ninstance lie_algebra_self_module : lie_module R L L :=\n{ smul_lie := λ t x m, by rw [←lie_skew, ←lie_skew x m, lie_algebra.lie_smul, smul_neg],\n  lie_smul := by apply lie_algebra.lie_smul, }\n\n@[simp] lemma neg_lie : ⁅-x, m⁆ = -⁅x, m⁆ :=\nby { rw [←sub_eq_zero, sub_neg_eq_add, ←add_lie], simp, }\n\n@[simp] lemma lie_neg : ⁅x, -m⁆ = -⁅x, m⁆ :=\nby { rw [←sub_eq_zero, sub_neg_eq_add, ←lie_add], simp, }\n\n@[simp] lemma sub_lie : ⁅x - y, m⁆ = ⁅x, m⁆ - ⁅y, m⁆ :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma lie_sub : ⁅x, m - n⁆ = ⁅x, m⁆ - ⁅x, n⁆ :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma nsmul_lie (n : ℕ) : ⁅n • x, m⁆ = n • ⁅x, m⁆ :=\nadd_monoid_hom.map_nsmul ⟨λ (x : L), ⁅x, m⁆, zero_lie m, λ _ _, add_lie _ _ _⟩ _ _\n\n@[simp] lemma lie_nsmul (n : ℕ) : ⁅x, n • m⁆ = n • ⁅x, m⁆ :=\nadd_monoid_hom.map_nsmul ⟨λ (m : M), ⁅x, m⁆, lie_zero x, λ _ _, lie_add _ _ _⟩ _ _\n\n@[simp] lemma zsmul_lie (a : ℤ) : ⁅a • x, m⁆ = a • ⁅x, m⁆ :=\nadd_monoid_hom.map_zsmul ⟨λ (x : L), ⁅x, m⁆, zero_lie m, λ _ _, add_lie _ _ _⟩ _ _\n\n@[simp] lemma lie_zsmul (a : ℤ) : ⁅x, a • m⁆ = a • ⁅x, m⁆ :=\nadd_monoid_hom.map_zsmul ⟨λ (m : M), ⁅x, m⁆, lie_zero x, λ _ _, lie_add _ _ _⟩ _ _\n\n@[simp] lemma lie_lie : ⁅⁅x, y⁆, m⁆ = ⁅x, ⁅y, m⁆⁆ - ⁅y, ⁅x, m⁆⁆ :=\nby rw [leibniz_lie, add_sub_cancel]\n\nlemma lie_jacobi : ⁅x, ⁅y, z⁆⁆ + ⁅y, ⁅z, x⁆⁆ + ⁅z, ⁅x, y⁆⁆ = 0 :=\nby { rw [← neg_neg ⁅x, y⁆, lie_neg z, lie_skew y x, ← lie_skew, lie_lie], abel, }\n\ninstance lie_ring.int_lie_algebra : lie_algebra ℤ L :=\n{ lie_smul := λ n x y, lie_zsmul x y n, }\n\ninstance : lie_ring_module L (M →ₗ[R] N) :=\n{ bracket     := λ x f,\n  { to_fun    := λ m, ⁅x, f m⁆ - f ⁅x, m⁆,\n    map_add'  := λ m n, by { simp only [lie_add, linear_map.map_add], abel, },\n    map_smul' := λ t m, by simp only [smul_sub, linear_map.map_smul, lie_smul, ring_hom.id_apply] },\n  add_lie     := λ x y f, by\n    { ext n, simp only [add_lie, linear_map.coe_mk, linear_map.add_apply, linear_map.map_add],\n      abel, },\n  lie_add     := λ x f g, by\n    { ext n, simp only [linear_map.coe_mk, lie_add, linear_map.add_apply], abel, },\n  leibniz_lie := λ x y f, by\n    { ext n,\n      simp only [lie_lie, linear_map.coe_mk, linear_map.map_sub, linear_map.add_apply, lie_sub],\n      abel, }, }\n\n@[simp] lemma lie_hom.lie_apply (f : M →ₗ[R] N) (x : L) (m : M) :\n  ⁅x, f⁆ m = ⁅x, f m⁆ - f ⁅x, m⁆ :=\nrfl\n\ninstance : lie_module R L (M →ₗ[R] N) :=\n{ smul_lie := λ t x f, by\n    { ext n,\n      simp only [smul_sub, smul_lie, linear_map.smul_apply, lie_hom.lie_apply,\n        linear_map.map_smul], },\n  lie_smul := λ t x f, by\n    { ext n, simp only [smul_sub, linear_map.smul_apply, lie_hom.lie_apply, lie_smul], }, }\n\nend basic_properties\n\n/-- A morphism of Lie algebras is a linear map respecting the bracket operations. -/\nstructure lie_hom (R : Type u) (L : Type v) (L' : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [lie_ring L'] [lie_algebra R L']\n  extends L →ₗ[R] L' :=\n(map_lie' : ∀ {x y : L}, to_fun ⁅x, y⁆ = ⁅to_fun x, to_fun y⁆)\n\nattribute [nolint doc_blame] lie_hom.to_linear_map\n\nnotation L ` →ₗ⁅`:25 R:25 `⁆ `:0 L':0 := lie_hom R L L'\n\nnamespace lie_hom\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁}\nvariables [comm_ring R]\nvariables [lie_ring L₁] [lie_algebra R L₁]\nvariables [lie_ring L₂] [lie_algebra R L₂]\nvariables [lie_ring L₃] [lie_algebra R L₃]\n\ninstance : has_coe (L₁ →ₗ⁅R⁆ L₂) (L₁ →ₗ[R] L₂) := ⟨lie_hom.to_linear_map⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L₁ →ₗ⁅R⁆ L₂) (λ _, L₁ → L₂) := ⟨λ f, f.to_linear_map.to_fun⟩\n\n/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,\n  because it is a composition of multiple projections. -/\ndef simps.apply (h : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂ := h\n\ninitialize_simps_projections lie_hom (to_linear_map_to_fun → apply)\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : L₁ →ₗ⁅R⁆ L₂) : ((f : L₁ →ₗ[R] L₂) : L₁ → L₂) = f :=\nrfl\n\n@[simp] lemma to_fun_eq_coe (f : L₁ →ₗ⁅R⁆ L₂) : f.to_fun = ⇑f := rfl\n\n@[simp] lemma map_smul (f : L₁ →ₗ⁅R⁆ L₂) (c : R) (x : L₁) : f (c • x) = c • f x :=\nlinear_map.map_smul (f : L₁ →ₗ[R] L₂) c x\n\n@[simp] lemma map_add (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : L₁ →ₗ[R] L₂) x y\n\n@[simp] lemma map_sub (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : L₁ →ₗ[R] L₂) x y\n\n@[simp] lemma map_neg (f : L₁ →ₗ⁅R⁆ L₂) (x : L₁) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : L₁ →ₗ[R] L₂) x\n\n@[simp] lemma map_lie (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f ⁅x, y⁆ = ⁅f x, f y⁆ := lie_hom.map_lie' f\n\n@[simp] lemma map_zero (f : L₁ →ₗ⁅R⁆ L₂) : f 0 = 0 := (f : L₁ →ₗ[R] L₂).map_zero\n\n/-- The identity map is a morphism of Lie algebras. -/\ndef id : L₁ →ₗ⁅R⁆ L₁ :=\n{ map_lie' := λ x y, rfl,\n  .. (linear_map.id : L₁ →ₗ[R] L₁) }\n\n@[simp] lemma coe_id : ((id : L₁ →ₗ⁅R⁆ L₁) : L₁ → L₁) = _root_.id := rfl\n\nlemma id_apply (x : L₁) : (id : L₁ →ₗ⁅R⁆ L₁) x = x := rfl\n\n/-- The constant 0 map is a Lie algebra morphism. -/\ninstance : has_zero (L₁ →ₗ⁅R⁆ L₂) := ⟨{ map_lie' := by simp, ..(0 : L₁ →ₗ[R] L₂)}⟩\n\n@[norm_cast, simp] lemma coe_zero : ((0 : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = 0 := rfl\n\nlemma zero_apply (x : L₁) : (0 : L₁ →ₗ⁅R⁆ L₂) x = 0 := rfl\n\n/-- The identity map is a Lie algebra morphism. -/\ninstance : has_one (L₁ →ₗ⁅R⁆ L₁) := ⟨id⟩\n\n@[simp] lemma coe_one : ((1 : (L₁ →ₗ⁅R⁆ L₁)) : L₁ → L₁) = _root_.id := rfl\n\nlemma one_apply (x : L₁) : (1 : (L₁ →ₗ⁅R⁆ L₁)) x = x := rfl\n\ninstance : inhabited (L₁ →ₗ⁅R⁆ L₂) := ⟨0⟩\n\nlemma coe_injective : @function.injective (L₁ →ₗ⁅R⁆ L₂) (L₁ → L₂) coe_fn :=\nby rintro ⟨⟨f, _⟩⟩ ⟨⟨g, _⟩⟩ ⟨h⟩; congr\n\n@[ext] lemma ext {f g : L₁ →ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : L₁ →ₗ⁅R⁆ L₂} : f = g ↔ ∀ x, f x = g x :=\n⟨by { rintro rfl x, refl }, ext⟩\n\nlemma congr_fun {f g : L₁ →ₗ⁅R⁆ L₂} (h : f = g) (x : L₁) : f x = g x := h ▸ rfl\n\n@[simp] lemma mk_coe (f : L₁ →ₗ⁅R⁆ L₂) (h₁ h₂ h₃) :\n  (⟨⟨f, h₁, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : L₁ → L₂) (h₁ h₂ h₃) :\n  ((⟨⟨f, h₁, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = f := rfl\n\n/-- The composition of morphisms is a morphism. -/\ndef comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) : L₁ →ₗ⁅R⁆ L₃ :=\n{ map_lie' := λ x y, by { change f (g ⁅x, y⁆) = ⁅f (g x), f (g y)⁆, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) (x : L₁) :\n  f.comp g x = f (g x) := rfl\n\n@[norm_cast, simp]\nlemma coe_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) :\n  (f.comp g : L₁ → L₃) = f ∘ g :=\nrfl\n\n@[norm_cast, simp]\nlemma coe_linear_map_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) :\n  (f.comp g : L₁ →ₗ[R] L₃) = (f : L₂ →ₗ[R] L₃).comp (g : L₁ →ₗ[R] L₂) :=\nrfl\n\n@[simp] lemma comp_id (f : L₁ →ₗ⁅R⁆ L₂) : f.comp (id : L₁ →ₗ⁅R⁆ L₁) = f :=\nby { ext, refl, }\n\n@[simp] lemma id_comp (f : L₁ →ₗ⁅R⁆ L₂) : (id : L₂ →ₗ⁅R⁆ L₂).comp f = f :=\nby { ext, refl, }\n\n/-- The inverse of a bijective morphism is a morphism. -/\ndef inverse (f : L₁ →ₗ⁅R⁆ L₂) (g : L₂ → L₁)\n  (h₁ : function.left_inverse g f) (h₂ : function.right_inverse g f) : L₂ →ₗ⁅R⁆ L₁ :=\n{ map_lie' := λ x y,\n  calc g ⁅x, y⁆ = g ⁅f (g x), f (g y)⁆ : by { conv_lhs { rw [←h₂ x, ←h₂ y], }, }\n            ... = g (f ⁅g x, g y⁆) : by rw map_lie\n            ... = ⁅g x, g y⁆ : (h₁ _),\n  ..linear_map.inverse f.to_linear_map g h₁ h₂ }\n\nend lie_hom\n\n/-- An equivalence of Lie algebras is a morphism which is also a linear equivalence. We could\ninstead define an equivalence to be a morphism which is also a (plain) equivalence. However it is\nmore convenient to define via linear equivalence to get `.to_linear_equiv` for free. -/\nstructure lie_equiv (R : Type u) (L : Type v) (L' : Type w)\n  [comm_ring R] [lie_ring L] [lie_algebra R L] [lie_ring L'] [lie_algebra R L']\n  extends L →ₗ⁅R⁆ L' :=\n(inv_fun   : L' → L)\n(left_inv  : function.left_inverse inv_fun to_lie_hom.to_fun)\n(right_inv : function.right_inverse inv_fun to_lie_hom.to_fun)\n\nattribute [nolint doc_blame] lie_equiv.to_lie_hom\n\nnotation L ` ≃ₗ⁅`:50 R `⁆ ` L' := lie_equiv R L L'\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁}\nvariables [comm_ring R] [lie_ring L₁] [lie_ring L₂] [lie_ring L₃]\nvariables [lie_algebra R L₁] [lie_algebra R L₂] [lie_algebra R L₃]\n\n/-- Consider an equivalence of Lie algebras as a linear equivalence. -/\ndef to_linear_equiv (f : L₁ ≃ₗ⁅R⁆ L₂) : L₁ ≃ₗ[R] L₂ := { ..f.to_lie_hom, ..f }\n\ninstance has_coe_to_lie_hom : has_coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ →ₗ⁅R⁆ L₂) := ⟨to_lie_hom⟩\ninstance has_coe_to_linear_equiv : has_coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ ≃ₗ[R] L₂) := ⟨to_linear_equiv⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L₁ ≃ₗ⁅R⁆ L₂) (λ _, L₁ → L₂) := ⟨λ e, e.to_lie_hom.to_fun⟩\n\n@[simp, norm_cast] lemma coe_to_lie_hom (e : L₁ ≃ₗ⁅R⁆ L₂) : ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = e :=\nrfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : L₁ ≃ₗ⁅R⁆ L₂) :\n  ((e : L₁ ≃ₗ[R] L₂) : L₁ → L₂) = e := rfl\n\n@[simp] lemma to_linear_equiv_mk (f : L₁ →ₗ⁅R⁆ L₂) (g h₁ h₂) :\n  (mk f g h₁ h₂ : L₁ ≃ₗ[R] L₂) = { inv_fun := g, left_inv := h₁, right_inv := h₂, .. f } := rfl\n\nlemma coe_linear_equiv_injective : injective (coe : (L₁ ≃ₗ⁅R⁆ L₂) → (L₁ ≃ₗ[R] L₂)) :=\nbegin\n  intros f₁ f₂ h, cases f₁, cases f₂, dsimp at h, simp only at h,\n  congr, exacts [lie_hom.coe_injective h.1, h.2]\nend\n\nlemma coe_injective : @injective (L₁ ≃ₗ⁅R⁆ L₂) (L₁ → L₂) coe_fn :=\nlinear_equiv.coe_injective.comp coe_linear_equiv_injective\n\n@[ext] lemma ext {f g : L₁ ≃ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g := coe_injective $ funext h\n\ninstance : has_one (L₁ ≃ₗ⁅R⁆ L₁) :=\n⟨{ map_lie' := λ x y, rfl,\n  ..(1 : L₁ ≃ₗ[R] L₁)}⟩\n\n@[simp] lemma one_apply (x : L₁) : (1 : (L₁ ≃ₗ⁅R⁆ L₁)) x = x := rfl\n\ninstance : inhabited (L₁ ≃ₗ⁅R⁆ L₁) := ⟨1⟩\n\n/-- Lie algebra equivalences are reflexive. -/\n@[refl]\ndef refl : L₁ ≃ₗ⁅R⁆ L₁ := 1\n\n@[simp] lemma refl_apply (x : L₁) : (refl : L₁ ≃ₗ⁅R⁆ L₁) x = x := rfl\n\n/-- Lie algebra equivalences are symmetric. -/\n@[symm]\ndef symm (e : L₁ ≃ₗ⁅R⁆ L₂) : L₂ ≃ₗ⁅R⁆ L₁ :=\n{ ..lie_hom.inverse e.to_lie_hom e.inv_fun e.left_inv e.right_inv,\n  ..e.to_linear_equiv.symm }\n\n@[simp] lemma symm_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.symm = e :=\nby { ext, refl }\n\n@[simp] lemma apply_symm_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n/-- Lie algebra equivalences are transitive. -/\n@[trans]\ndef trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) : L₁ ≃ₗ⁅R⁆ L₃ :=\n{ ..lie_hom.comp e₂.to_lie_hom e₁.to_lie_hom,\n  ..linear_equiv.trans e₁.to_linear_equiv e₂.to_linear_equiv }\n\n@[simp] lemma self_trans_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.trans e.symm = refl :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.trans e = refl :=\ne.symm.self_trans_symm\n\n@[simp] lemma trans_apply (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) (x : L₁) :\n  (e₁.trans e₂) x = e₂ (e₁ x) := rfl\n\n@[simp] lemma symm_trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) :\n  (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl\n\nprotected lemma bijective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.bijective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.bijective\n\nprotected lemma injective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.injective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.injective\n\nprotected lemma surjective (e : L₁ ≃ₗ⁅R⁆ L₂) : function.surjective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) :=\ne.to_linear_equiv.surjective\n\nend lie_equiv\n\nsection lie_module_morphisms\n\nvariables (R : Type u) (L : Type v) (M : Type w) (N : Type w₁) (P : Type w₂)\nvariables [comm_ring R] [lie_ring L] [lie_algebra R L]\nvariables [add_comm_group M] [add_comm_group N] [add_comm_group P]\nvariables [module R M] [module R N] [module R P]\nvariables [lie_ring_module L M] [lie_ring_module L N] [lie_ring_module L P]\nvariables [lie_module R L M] [lie_module R L N] [lie_module R L P]\n\n/-- A morphism of Lie algebra modules is a linear map which commutes with the action of the Lie\nalgebra. -/\nstructure lie_module_hom extends M →ₗ[R] N :=\n(map_lie' : ∀ {x : L} {m : M}, to_fun ⁅x, m⁆ = ⁅x, to_fun m⁆)\n\nattribute [nolint doc_blame] lie_module_hom.to_linear_map\n\nnotation M ` →ₗ⁅`:25 R,L:25 `⁆ `:0 N:0 := lie_module_hom R L M N\n\nnamespace lie_module_hom\n\nvariables {R L M N P}\n\ninstance : has_coe (M →ₗ⁅R,L⁆ N) (M →ₗ[R] N) := ⟨lie_module_hom.to_linear_map⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M →ₗ⁅R,L⁆ N) (λ _, M → N) := ⟨λ f, f.to_linear_map.to_fun⟩\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : M →ₗ⁅R,L⁆ N) : ((f : M →ₗ[R] N) : M → N) = f :=\nrfl\n\n@[simp] lemma map_smul (f : M →ₗ⁅R,L⁆ N) (c : R) (x : M) : f (c • x) = c • f x :=\nlinear_map.map_smul (f : M →ₗ[R] N) c x\n\n@[simp] lemma map_add (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : M →ₗ[R] N) x y\n\n@[simp] lemma map_sub (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : M →ₗ[R] N) x y\n\n@[simp] lemma map_neg (f : M →ₗ⁅R,L⁆ N) (x : M) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : M →ₗ[R] N) x\n\n@[simp] lemma map_lie (f : M →ₗ⁅R,L⁆ N) (x : L) (m : M) : f ⁅x, m⁆ = ⁅x, f m⁆ :=\nlie_module_hom.map_lie' f\n\nlemma map_lie₂ (f : M →ₗ⁅R,L⁆ N →ₗ[R] P) (x : L) (m : M) (n : N) :\n  ⁅x, f m n⁆ = f ⁅x, m⁆ n + f m ⁅x, n⁆ :=\nby simp only [sub_add_cancel, map_lie, lie_hom.lie_apply]\n\n@[simp] lemma map_zero (f : M →ₗ⁅R,L⁆ N) : f 0 = 0 :=\nlinear_map.map_zero (f : M →ₗ[R] N)\n\n/-- The constant 0 map is a Lie module morphism. -/\ninstance : has_zero (M →ₗ⁅R,L⁆ N) := ⟨{ map_lie' := by simp, ..(0 : M →ₗ[R] N) }⟩\n\n@[norm_cast, simp] lemma coe_zero : ((0 : M →ₗ⁅R,L⁆ N) : M → N) = 0 := rfl\n\nlemma zero_apply (m : M) : (0 : M →ₗ⁅R,L⁆ N) m = 0 := rfl\n\n/-- The identity map is a Lie module morphism. -/\ninstance : has_one (M →ₗ⁅R,L⁆ M) := ⟨{ map_lie' := by simp, ..(1 : M →ₗ[R] M) }⟩\n\ninstance : inhabited (M →ₗ⁅R,L⁆ N) := ⟨0⟩\n\nlemma coe_injective : @function.injective (M →ₗ⁅R,L⁆ N) (M → N) coe_fn :=\nby { rintros ⟨⟨f, _⟩⟩ ⟨⟨g, _⟩⟩ ⟨h⟩, congr, }\n\n@[ext] lemma ext {f g : M →ₗ⁅R,L⁆ N} (h : ∀ m, f m = g m) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : M →ₗ⁅R,L⁆ N} : f = g ↔ ∀ m, f m = g m :=\n⟨by { rintro rfl m, refl, }, ext⟩\n\nlemma congr_fun {f g : M →ₗ⁅R,L⁆ N} (h : f = g) (x : M) : f x = g x := h ▸ rfl\n\n@[simp] lemma mk_coe (f : M →ₗ⁅R,L⁆ N) (h) :\n  (⟨f, h⟩ : M →ₗ⁅R,L⁆ N) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : M →ₗ[R] N) (h) :\n  ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M → N) = f :=\nby { ext, refl, }\n\n@[norm_cast, simp] lemma coe_linear_mk (f : M →ₗ[R] N) (h) :\n  ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M →ₗ[R] N) = f :=\nby { ext, refl, }\n\n/-- The composition of Lie module morphisms is a morphism. -/\ndef comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) : M →ₗ⁅R,L⁆ P :=\n{ map_lie' := λ x m, by { change f (g ⁅x, m⁆) = ⁅x, f (g m)⁆, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) (m : M) :\n  f.comp g m = f (g m) := rfl\n\n@[norm_cast, simp] lemma coe_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) :\n  (f.comp g : M → P) = f ∘ g :=\nrfl\n\n@[norm_cast, simp] lemma coe_linear_map_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) :\n  (f.comp g : M →ₗ[R] P) = (f : N →ₗ[R] P).comp (g : M →ₗ[R] N) :=\nrfl\n\n/-- The inverse of a bijective morphism of Lie modules is a morphism of Lie modules. -/\ndef inverse (f : M →ₗ⁅R,L⁆ N) (g : N → M)\n  (h₁ : function.left_inverse g f) (h₂ : function.right_inverse g f) : N →ₗ⁅R,L⁆ M :=\n{ map_lie' := λ x n,\n    calc g ⁅x, n⁆ = g ⁅x, f (g n)⁆ : by rw h₂\n              ... = g (f ⁅x, g n⁆) : by rw map_lie\n              ... = ⁅x, g n⁆ : (h₁ _),\n  ..linear_map.inverse f.to_linear_map g h₁ h₂ }\n\ninstance : has_add (M →ₗ⁅R,L⁆ N) :=\n{ add := λ f g, { map_lie' := by simp, ..((f : M →ₗ[R] N) + (g : M →ₗ[R] N)) }, }\n\ninstance : has_sub (M →ₗ⁅R,L⁆ N) :=\n{ sub := λ f g, { map_lie' := by simp, ..((f : M →ₗ[R] N) - (g : M →ₗ[R] N)) }, }\n\ninstance : has_neg (M →ₗ⁅R,L⁆ N) :=\n{ neg := λ f, { map_lie' := by simp, ..(-(f : (M →ₗ[R] N))) }, }\n\n@[norm_cast, simp] lemma coe_add (f g : M →ₗ⁅R,L⁆ N) : ⇑(f + g) = f + g := rfl\n\nlemma add_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f + g) m = f m + g m := rfl\n\n@[norm_cast, simp] lemma coe_sub (f g : M →ₗ⁅R,L⁆ N) : ⇑(f - g) = f - g := rfl\n\nlemma sub_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f - g) m = f m - g m := rfl\n\n@[norm_cast, simp] lemma coe_neg (f : M →ₗ⁅R,L⁆ N) : ⇑(-f) = -f := rfl\n\nlemma neg_apply (f : M →ₗ⁅R,L⁆ N) (m : M) : (-f) m = -(f m) := rfl\n\ninstance : add_comm_group (M →ₗ⁅R,L⁆ N) :=\n{ zero           := 0,\n  add            := (+),\n  neg            := has_neg.neg,\n  sub            := has_sub.sub,\n  nsmul          := λ n f, { map_lie' := λ x m, by simp, ..(n • (f : M →ₗ[R] N)) },\n  nsmul_zero'    := λ f, by { ext, simp, },\n  nsmul_succ'    := λ n f, by { ext, simp [nat.succ_eq_one_add, add_nsmul], },\n  ..(coe_injective.add_comm_group _ coe_zero coe_add coe_neg coe_sub :\n    add_comm_group (M →ₗ⁅R,L⁆ N)) }\n\ninstance : has_scalar R (M →ₗ⁅R,L⁆ N) :=\n{ smul := λ t f, { map_lie' := by simp, ..(t • (f : M →ₗ[R] N)) }, }\n\n@[norm_cast, simp] lemma coe_smul (t : R) (f : M →ₗ⁅R,L⁆ N) : ⇑(t • f) = t • f := rfl\n\nlemma smul_apply (t : R) (f : M →ₗ⁅R,L⁆ N) (m : M) : (t • f) m = t • (f m) := rfl\n\ninstance : module R (M →ₗ⁅R,L⁆ N) :=\nfunction.injective.module R ⟨λ f, f.to_linear_map.to_fun, rfl, coe_add⟩ coe_injective coe_smul\n\nend lie_module_hom\n\n/-- An equivalence of Lie algebra modules is a linear equivalence which is also a morphism of\nLie algebra modules. -/\nstructure lie_module_equiv extends M →ₗ⁅R,L⁆ N :=\n(inv_fun   : N → M)\n(left_inv  : function.left_inverse inv_fun to_fun)\n(right_inv : function.right_inverse inv_fun to_fun)\n\nattribute [nolint doc_blame] lie_module_equiv.to_lie_module_hom\n\nnotation M ` ≃ₗ⁅`:25 R,L:25 `⁆ `:0 N:0 := lie_module_equiv R L M N\n\nnamespace lie_module_equiv\n\nvariables {R L M N P}\n\n/-- View an equivalence of Lie modules as a linear equivalence. -/\n@[ancestor]\ndef to_linear_equiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ₗ[R] N := { ..e }\n\n/-- View an equivalence of Lie modules as a type level equivalence. -/\n@[ancestor]\ndef to_equiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ N := { ..e }\n\ninstance has_coe_to_equiv : has_coe (M ≃ₗ⁅R,L⁆ N) (M ≃ N) := ⟨to_equiv⟩\ninstance has_coe_to_lie_module_hom : has_coe (M ≃ₗ⁅R,L⁆ N) (M →ₗ⁅R,L⁆ N) := ⟨to_lie_module_hom⟩\ninstance has_coe_to_linear_equiv : has_coe (M ≃ₗ⁅R,L⁆ N) (M ≃ₗ[R] N) := ⟨to_linear_equiv⟩\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M ≃ₗ⁅R,L⁆ N) (λ _, M → N) := ⟨λ e, e.to_lie_module_hom.to_fun⟩\n\nlemma injective (e : M ≃ₗ⁅R,L⁆ N) : function.injective e := e.to_equiv.injective\n\n@[simp] lemma coe_mk (f : M →ₗ⁅R,L⁆ N) (inv_fun h₁ h₂) :\n  ((⟨f, inv_fun, h₁, h₂⟩ : M ≃ₗ⁅R,L⁆ N) : M → N) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_lie_module_hom (e : M ≃ₗ⁅R,L⁆ N) :\n  ((e : M →ₗ⁅R,L⁆ N) : M → N) = e := rfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : M ≃ₗ⁅R,L⁆ N) : ((e : M ≃ₗ[R] N) : M → N) = e :=\nrfl\n\nlemma to_equiv_injective : function.injective (to_equiv : (M ≃ₗ⁅R,L⁆ N) → M ≃ N) :=\nλ e₁ e₂ h, begin\n  rcases e₁ with ⟨⟨⟩⟩, rcases e₂ with ⟨⟨⟩⟩,\n  have inj := equiv.mk.inj h,\n  dsimp at inj,\n  apply lie_module_equiv.mk.inj_eq.mpr,\n  split,\n  { congr,\n    ext,\n    rw inj.1 },\n  { exact inj.2 },\nend\n\n@[ext] lemma ext (e₁ e₂ : M ≃ₗ⁅R,L⁆ N) (h : ∀ m, e₁ m = e₂ m) : e₁ = e₂ :=\nto_equiv_injective (equiv.ext h)\n\ninstance : has_one (M ≃ₗ⁅R,L⁆ M) := ⟨{ map_lie' := λ x m, rfl, ..(1 : M ≃ₗ[R] M) }⟩\n\n@[simp] lemma one_apply (m : M) : (1 : (M ≃ₗ⁅R,L⁆ M)) m = m := rfl\n\ninstance : inhabited (M ≃ₗ⁅R,L⁆ M) := ⟨1⟩\n\n/-- Lie module equivalences are reflexive. -/\n@[refl] def refl : M ≃ₗ⁅R,L⁆ M := 1\n\n@[simp] lemma refl_apply (m : M) : (refl : M ≃ₗ⁅R,L⁆ M) m = m := rfl\n\n/-- Lie module equivalences are syemmtric. -/\n@[symm] def symm (e : M ≃ₗ⁅R,L⁆ N) : N ≃ₗ⁅R,L⁆ M :=\n{ ..lie_module_hom.inverse e.to_lie_module_hom e.inv_fun e.left_inv e.right_inv,\n  ..(e : M ≃ₗ[R] N).symm }\n\n@[simp] lemma apply_symm_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n@[simp] lemma symm_symm (e : M ≃ₗ⁅R,L⁆ N) : e.symm.symm = e :=\nby { ext, apply_fun e.symm using e.symm.injective, simp, }\n\n/-- Lie module equivalences are transitive. -/\n@[trans] def trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) : M ≃ₗ⁅R,L⁆ P :=\n{ ..lie_module_hom.comp e₂.to_lie_module_hom e₁.to_lie_module_hom,\n  ..linear_equiv.trans e₁.to_linear_equiv e₂.to_linear_equiv }\n\n@[simp] lemma trans_apply (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) (m : M) :\n  (e₁.trans e₂) m = e₂ (e₁ m) := rfl\n\n@[simp] lemma symm_trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) :\n  (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl\n\n@[simp] lemma self_trans_symm (e : M ≃ₗ⁅R,L⁆ N) : e.trans e.symm = refl :=\next _ _ e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : M ≃ₗ⁅R,L⁆ N) : e.symm.trans e = refl :=\next _ _ e.apply_symm_apply\n\nend lie_module_equiv\n\nend lie_module_morphisms\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/src/algebra/lie/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.5583269943353745, "lm_q1q2_score": 0.4511657385638755}}
{"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport category_theory.arrow\nimport category_theory.limits.shapes.binary_products\n\nnoncomputable theory\n\nopen category_theory.limits opposite category_theory.category\n\nnamespace category_theory\n\nnamespace arrow\n\nvariables {C D : Type*} [category C] [category D]\n\n/-- Condition that the image of `f` by `F` is an isomorphism -/\ndef is_inverted_by (f : arrow C) (F : C ⥤ D) : Prop := is_iso (F.map f.hom)\n\nnamespace is_inverted_by\n\nlemma of_is_iso {f : arrow C} {F : C ⥤ D} (h : is_iso (F.map f.hom)) : f.is_inverted_by F := h\n\nend is_inverted_by\n\nlemma congr_left {f g : arrow C} (h : f = g) : f.left = g.left := by rw h\nlemma congr_right {f g : arrow C} (h : f = g) : f.right = g.right := by rw h\n\n--lemma mk_eq (f : arrow C) : arrow.mk f.hom = f :=\n--by { cases f, dsimp [arrow.mk], refl, }\n\ndef mk_iso {f g : arrow C} (e₁ : f.left ≅ g.left) (e₂ : f.right ≅ g.right)\n  (fac : e₁.hom ≫ g.hom = f.hom ≫ e₂.hom) :\n  f ≅ g :=\n{ hom :=\n  { left := e₁.hom,\n    right := e₂.hom,\n    w' := fac, },\n  inv :=\n  { left := e₁.inv,\n    right := e₂.inv,\n    w' := begin\n      rw [← comp_id f.hom],\n      dsimp,\n      rw [← e₂.hom_inv_id],\n      slice_lhs 2 3 { rw ← fac, },\n      slice_lhs 1 2 { rw e₁.inv_hom_id, },\n      rw id_comp,\n    end, },\n  hom_inv_id' := begin\n    ext,\n    exacts [e₁.hom_inv_id, e₂.hom_inv_id],\n  end,\n  inv_hom_id' := begin\n    ext,\n    exacts [e₁.inv_hom_id, e₂.inv_hom_id],\n  end, }\n\n@[simps]\ndef op_prod {C : Type*} [category C] (X Y : C) [has_binary_product X Y]\n  [has_binary_coproduct (op X) (op Y)] :\n  op (X ⨯ Y) ≅ op X ⨿ op Y :=\nbegin\n  let cofan : binary_cofan (op X) (op Y) :=\n    binary_cofan.mk (limits.prod.fst : X ⨯ Y ⟶ X).op ((limits.prod.snd : X ⨯ Y ⟶ Y).op),\n  refine (is_colimit.cocone_point_unique_up_to_iso (coprod_is_coprod (op X) (op Y)) (_ : is_colimit cofan)).symm,\n  exact\n  { desc := λ s, (limits.prod.lift (s.ι.app (discrete.mk walking_pair.left)).unop (s.ι.app (discrete.mk walking_pair.right)).unop).op,\n    fac' := λ s j, begin\n      cases j,\n      cases j; dsimp [cofan],\n      { rw [← op_comp, prod.lift_fst, quiver.hom.op_unop], },\n      { rw [← op_comp, prod.lift_snd, quiver.hom.op_unop], },\n    end,\n    uniq' := λ s j hs, begin\n      dsimp,\n      apply quiver.hom.unop_inj,\n      rw quiver.hom.unop_op,\n      ext,\n      { simp only [prod.lift_fst],\n        exact congr_arg quiver.hom.unop (hs (discrete.mk walking_pair.left)), },\n      { simp only [prod.lift_snd],\n        exact congr_arg quiver.hom.unop (hs (discrete.mk walking_pair.right)), },\n    end, },\nend\n\ndef iso_op_prod_lift {A X Y : C} [has_binary_product X Y]\n  [has_binary_coproduct (op X) (op Y)] (f : A ⟶ X) (g : A ⟶ Y) :\n  arrow.mk (prod.lift f g).op ≅ arrow.mk (coprod.desc f.op g.op) :=\nbegin\n  symmetry,\n  refine mk_iso (op_prod _ _).symm (by refl) _,\n  ext,\n  { dsimp [limits.is_colimit.cocone_point_unique_up_to_iso, coprod_is_coprod],\n    simp only [coprod.inl_desc, id_comp, comp_id, coprod.desc_comp, ← op_comp, prod.lift_fst, comp_id], },\n  { dsimp [limits.is_colimit.cocone_point_unique_up_to_iso, coprod_is_coprod],\n    simp only [coprod.inr_desc, id_comp, comp_id, coprod.desc_comp, ← op_comp, prod.lift_snd, comp_id], },\nend\n\n@[simps]\ndef unop_prod (X Y : Cᵒᵖ) [has_binary_coproduct X.unop Y.unop] [has_binary_product X Y] :\n  unop (X ⨯ Y) ≅ X.unop ⨿ Y.unop :=\nbegin\n  let cofan : binary_cofan X.unop Y.unop :=\n    binary_cofan.mk (limits.prod.fst : X ⨯ Y ⟶ X).unop ((limits.prod.snd : X ⨯ Y ⟶ Y)).unop,\n  refine (is_colimit.cocone_point_unique_up_to_iso (coprod_is_coprod X.unop Y.unop) (_ : is_colimit cofan)).symm,\n  exact\n  { desc := λ s, (limits.prod.lift (s.ι.app (discrete.mk walking_pair.left)).op (s.ι.app (discrete.mk walking_pair.right)).op).unop,\n    fac' := λ s j, begin\n      cases j,\n      cases j; dsimp [cofan],\n      { rw [← unop_comp, prod.lift_fst, quiver.hom.unop_op], },\n      { rw [← unop_comp, prod.lift_snd, quiver.hom.unop_op], },\n    end,\n    uniq' := λ s j hs, begin\n      dsimp,\n      apply quiver.hom.op_inj,\n      rw quiver.hom.op_unop,\n      ext,\n      { simp only [prod.lift_fst],\n        exact congr_arg quiver.hom.op (hs (discrete.mk walking_pair.left)), },\n      { simp only [prod.lift_snd],\n        exact congr_arg quiver.hom.op (hs (discrete.mk walking_pair.right)), },\n    end, },\nend\n\ndef iso_unop_prod_lift {A X Y : Cᵒᵖ} [has_binary_product X Y]\n  [has_binary_coproduct (unop X) (unop Y)] (f : A ⟶ X) (g : A ⟶ Y) :\n  arrow.mk (prod.lift f g).unop ≅ arrow.mk (coprod.desc f.unop g.unop) :=\nbegin\n  symmetry,\n  refine mk_iso (unop_prod _ _).symm (by refl) _,\n  ext,\n  { dsimp [limits.is_colimit.cocone_point_unique_up_to_iso, coprod_is_coprod],\n    simp only [id_comp, coprod.desc_comp, coprod.inl_desc, comp_id, ← unop_comp, prod.lift_fst], },\n  { dsimp [limits.is_colimit.cocone_point_unique_up_to_iso, coprod_is_coprod],\n    simp only [id_comp, coprod.desc_comp, coprod.inr_desc, comp_id, ← unop_comp, prod.lift_snd], },\nend\n\nend arrow\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/arrow.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.4511557298744576}}
{"text": "class Zero.{u} (α : Type u) where\n  zero : α\n\ninstance Zero.toOfNat0 {α} [Zero α] : OfNat α (nat_lit 0) where\n  ofNat := ‹Zero α›.1\n\ninstance Zero.ofOfNat0 {α} [OfNat α (nat_lit 0)] : Zero α where\n  zero := 0\n\nclass One (α : Type u) where\n  one : α\n\ninstance One.toOfNat1 {α} [One α] : OfNat α (nat_lit 1) where\n  ofNat := ‹One α›.1\n\ninstance One.ofOfNat1 {α} [OfNat α (nat_lit 1)] : One α where\n  one := 1\n\ntheorem ex1 : (@OfNat.ofNat Nat 0 Zero.toOfNat0) = @OfNat.ofNat Nat 1 One.toOfNat1 := by\n  refine' congrArg _ (congrArg _ _)\n  rfl\n\nexample : (@OfNat.ofNat Nat 0 Zero.toOfNat0) = @OfNat.ofNat Nat 1 One.toOfNat1 := by\n  apply congrArg\n  apply congrArg\n  apply rfl\n\ntheorem ex2 : (@OfNat.ofNat Nat 0 Zero.toOfNat0) = @OfNat.ofNat Nat 1 One.toOfNat1 := by\n  apply congrArg\n  apply congrArg\n  apply rfl\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/1870.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.6926419894793248, "lm_q1q2_score": 0.4511557293193322}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.group_power.default\nimport Mathlib.logic.function.iterate\nimport Mathlib.PostPort\n\nuniverses u_1 u_3 u_5 \n\nnamespace Mathlib\n\n/-!\n# Iterates of monoid and ring homomorphisms\n\nIterate of a monoid/ring homomorphism is a monoid/ring homomorphism but it has a wrong type, so Lean\ncan't apply lemmas like `monoid_hom.map_one` to `f^[n] 1`. Though it is possible to define\na monoid structure on the endomorphisms, quite often we do not want to convert from\n`M →* M` to (not yet defined) `monoid.End M` and from `f^[n]` to `f^n` just to apply a simple lemma.\n\nSo, we restate standard `*_hom.map_*` lemmas under names `*_hom.iterate_map_*`.\n\nWe also prove formulas for iterates of add/mul left/right.\n\n## Tags\n\nhomomorphism, iterate\n-/\n\nnamespace monoid_hom\n\n\n@[simp] theorem Mathlib.add_monoid_hom.iterate_map_zero {M : Type u_1} [add_monoid M] (f : M →+ M)\n    (n : ℕ) : nat.iterate (⇑f) n 0 = 0 :=\n  function.iterate_fixed (add_monoid_hom.map_zero f) n\n\n@[simp] theorem iterate_map_mul {M : Type u_1} [monoid M] (f : M →* M) (n : ℕ) (x : M) (y : M) :\n    nat.iterate (⇑f) n (x * y) = nat.iterate (⇑f) n x * nat.iterate (⇑f) n y :=\n  function.semiconj₂.iterate (map_mul f) n x y\n\n@[simp] theorem iterate_map_inv {G : Type u_3} [group G] (f : G →* G) (n : ℕ) (x : G) :\n    nat.iterate (⇑f) n (x⁻¹) = (nat.iterate (⇑f) n x⁻¹) :=\n  function.commute.iterate_left (map_inv f) n x\n\ntheorem iterate_map_pow {M : Type u_1} [monoid M] (f : M →* M) (a : M) (n : ℕ) (m : ℕ) :\n    nat.iterate (⇑f) n (a ^ m) = nat.iterate (⇑f) n a ^ m :=\n  function.commute.iterate_left (fun (x : M) => map_pow f x m) n a\n\ntheorem iterate_map_gpow {G : Type u_3} [group G] (f : G →* G) (a : G) (n : ℕ) (m : ℤ) :\n    nat.iterate (⇑f) n (a ^ m) = nat.iterate (⇑f) n a ^ m :=\n  function.commute.iterate_left (fun (x : G) => map_gpow f x m) n a\n\nend monoid_hom\n\n\nnamespace add_monoid_hom\n\n\n@[simp] theorem iterate_map_sub {G : Type u_3} [add_group G] (f : G →+ G) (n : ℕ) (x : G) (y : G) :\n    nat.iterate (⇑f) n (x - y) = nat.iterate (⇑f) n x - nat.iterate (⇑f) n y :=\n  function.semiconj₂.iterate (map_sub f) n x y\n\ntheorem iterate_map_smul {M : Type u_1} [add_monoid M] (f : M →+ M) (n : ℕ) (m : ℕ) (x : M) :\n    nat.iterate (⇑f) n (m •ℕ x) = m •ℕ nat.iterate (⇑f) n x :=\n  monoid_hom.iterate_map_pow (coe_fn to_multiplicative f) x n m\n\ntheorem iterate_map_gsmul {G : Type u_3} [add_group G] (f : G →+ G) (n : ℕ) (m : ℤ) (x : G) :\n    nat.iterate (⇑f) n (m •ℤ x) = m •ℤ nat.iterate (⇑f) n x :=\n  monoid_hom.iterate_map_gpow (coe_fn to_multiplicative f) x n m\n\nend add_monoid_hom\n\n\nnamespace ring_hom\n\n\ntheorem coe_pow {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) : ⇑(f ^ n) = nat.iterate (⇑f) n :=\n  sorry\n\ntheorem iterate_map_one {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) :\n    nat.iterate (⇑f) n 1 = 1 :=\n  monoid_hom.iterate_map_one (to_monoid_hom f) n\n\ntheorem iterate_map_zero {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) :\n    nat.iterate (⇑f) n 0 = 0 :=\n  add_monoid_hom.iterate_map_zero (to_add_monoid_hom f) n\n\ntheorem iterate_map_add {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) (x : R) (y : R) :\n    nat.iterate (⇑f) n (x + y) = nat.iterate (⇑f) n x + nat.iterate (⇑f) n y :=\n  add_monoid_hom.iterate_map_add (to_add_monoid_hom f) n x y\n\ntheorem iterate_map_mul {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) (x : R) (y : R) :\n    nat.iterate (⇑f) n (x * y) = nat.iterate (⇑f) n x * nat.iterate (⇑f) n y :=\n  monoid_hom.iterate_map_mul (to_monoid_hom f) n x y\n\ntheorem iterate_map_pow {R : Type u_5} [semiring R] (f : R →+* R) (a : R) (n : ℕ) (m : ℕ) :\n    nat.iterate (⇑f) n (a ^ m) = nat.iterate (⇑f) n a ^ m :=\n  monoid_hom.iterate_map_pow (to_monoid_hom f) a n m\n\ntheorem iterate_map_smul {R : Type u_5} [semiring R] (f : R →+* R) (n : ℕ) (m : ℕ) (x : R) :\n    nat.iterate (⇑f) n (m •ℕ x) = m •ℕ nat.iterate (⇑f) n x :=\n  add_monoid_hom.iterate_map_smul (to_add_monoid_hom f) n m x\n\ntheorem iterate_map_sub {R : Type u_5} [ring R] (f : R →+* R) (n : ℕ) (x : R) (y : R) :\n    nat.iterate (⇑f) n (x - y) = nat.iterate (⇑f) n x - nat.iterate (⇑f) n y :=\n  add_monoid_hom.iterate_map_sub (to_add_monoid_hom f) n x y\n\ntheorem iterate_map_neg {R : Type u_5} [ring R] (f : R →+* R) (n : ℕ) (x : R) :\n    nat.iterate (⇑f) n (-x) = -nat.iterate (⇑f) n x :=\n  add_monoid_hom.iterate_map_neg (to_add_monoid_hom f) n x\n\ntheorem iterate_map_gsmul {R : Type u_5} [ring R] (f : R →+* R) (n : ℕ) (m : ℤ) (x : R) :\n    nat.iterate (⇑f) n (m •ℤ x) = m •ℤ nat.iterate (⇑f) n x :=\n  add_monoid_hom.iterate_map_gsmul (to_add_monoid_hom f) n m x\n\nend ring_hom\n\n\n@[simp] theorem mul_left_iterate {M : Type u_1} [monoid M] (a : M) (n : ℕ) :\n    nat.iterate (Mul.mul a) n = Mul.mul (a ^ n) :=\n  sorry\n\n@[simp] theorem add_left_iterate {M : Type u_1} [add_monoid M] (a : M) (n : ℕ) :\n    nat.iterate (Add.add a) n = Add.add (n •ℕ a) :=\n  mul_left_iterate a n\n\n@[simp] theorem mul_right_iterate {M : Type u_1} [monoid M] (a : M) (n : ℕ) :\n    nat.iterate (fun (x : M) => x * a) n = fun (x : M) => x * a ^ n :=\n  sorry\n\n@[simp] theorem add_right_iterate {M : Type u_1} [add_monoid M] (a : M) (n : ℕ) :\n    nat.iterate (fun (x : M) => x + a) n = fun (x : M) => x + n •ℕ a :=\n  mul_right_iterate a n\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/algebra/iterate_hom_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321964553657, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.45113519321414763}}
{"text": "/-\nCopyright (c) 2022 Jujian Zhang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jujian Zhang, Eric Wieser\n-/\nimport algebra.graded_monoid\n\n/-!\n# Additively-graded multiplicative action structures\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis module provides a set of heterogeneous typeclasses for defining a multiplicative structure\nover the sigma type `graded_monoid A` such that `(•) : A i → M j → M (i + j)`; that is to say, `A`\nhas an additively-graded multiplicative action on `M`. The typeclasses are:\n\n* `graded_monoid.ghas_smul A M`\n* `graded_monoid.gmul_action A M`\n\nWith the `sigma_graded` locale open, these respectively imbue:\n\n* `has_smul (graded_monoid A) (graded_monoid M)`\n* `mul_action (graded_monoid A) (graded_monoid M)`\n\nFor now, these typeclasses are primarily used in the construction of `direct_sum.gmodule.module` and\nthe rest of that file.\n\n## Internally graded multiplicative actions\n\nIn addition to the above typeclasses, in the most frequent case when `A` is an indexed collection of\n`set_like` subobjects (such as `add_submonoid`s, `add_subgroup`s, or `submodule`s), this file\nprovides the `Prop` typeclasses:\n\n* `set_like.has_graded_smul A M` (which provides the obvious `graded_monoid.ghas_smul A` instance)\n\nwhich provides the API lemma\n\n* `set_like.graded_smul_mem_graded`\n\nNote that there is no need for `set_like.graded_mul_action` or similar, as all the information it\nwould contain is already supplied by `has_graded_smul` when the objects within `A` and `M` have\na `mul_action` instance.\n\n## tags\n\ngraded action\n-/\n\nset_option old_structure_cmd true\n\nvariables {ι : Type*}\n\nnamespace graded_monoid\n\n/-! ### Typeclasses -/\nsection defs\n\nvariables (A : ι → Type*) (M : ι → Type*)\n\n/-- A graded version of `has_smul`. Scalar multiplication combines grades additively, i.e.\nif `a ∈ A i` and `m ∈ M j`, then `a • b` must be in `M (i + j)`-/\nclass ghas_smul [has_add ι] :=\n(smul {i j} : A i → M j → M (i + j))\n\n/-- A graded version of `has_mul.to_has_smul` -/\ninstance ghas_mul.to_ghas_smul [has_add ι] [ghas_mul A] : ghas_smul A A :=\n{ smul := λ _ _, ghas_mul.mul }\n\ninstance ghas_smul.to_has_smul [has_add ι] [ghas_smul A M] :\n  has_smul (graded_monoid A) (graded_monoid M) :=\n⟨λ (x : graded_monoid A) (y : graded_monoid M), ⟨_, ghas_smul.smul x.snd y.snd⟩⟩\n\nlemma mk_smul_mk [has_add ι] [ghas_smul A M] {i j} (a : A i) (b : M j) :\n  mk i a • mk j b = mk (i + j) (ghas_smul.smul a b) :=\nrfl\n\n/-- A graded version of `mul_action`. -/\nclass gmul_action [add_monoid ι] [gmonoid A] extends ghas_smul A M :=\n(one_smul (b : graded_monoid M) : (1 : graded_monoid A) • b = b)\n(mul_smul (a a' : graded_monoid A) (b : graded_monoid M) : (a * a') • b = a • a' • b)\n\n/-- The graded version of `monoid.to_mul_action`. -/\ninstance gmonoid.to_gmul_action [add_monoid ι] [gmonoid A] :\n  gmul_action A A :=\n{ one_smul := gmonoid.one_mul,\n  mul_smul := gmonoid.mul_assoc,\n  ..ghas_mul.to_ghas_smul _ }\n\ninstance gmul_action.to_mul_action [add_monoid ι] [gmonoid A] [gmul_action A M] :\n  mul_action (graded_monoid A) (graded_monoid M) :=\n{ one_smul := gmul_action.one_smul,\n  mul_smul := gmul_action.mul_smul }\n\nend defs\n\nend graded_monoid\n\n/-! ### Shorthands for creating instance of the above typeclasses for collections of subobjects -/\n\nsection subobjects\n\nvariables {R : Type*}\n\n/-- A version of `graded_monoid.ghas_smul` for internally graded objects. -/\nclass set_like.has_graded_smul {S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add ι] (A : ι → S) (B : ι → N) : Prop :=\n(smul_mem : ∀ ⦃i j : ι⦄ {ai bj}, ai ∈ A i → bj ∈ B j → ai • bj ∈ B (i + j))\n\ninstance set_like.ghas_smul {S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add ι] (A : ι → S) (B : ι → N) [set_like.has_graded_smul A B] :\n  graded_monoid.ghas_smul (λ i, A i) (λ i, B i) :=\n{ smul := λ i j a b, ⟨(a : R) • b, set_like.has_graded_smul.smul_mem a.2 b.2⟩ }\n\n@[simp] lemma set_like.coe_ghas_smul {S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add ι] (A : ι → S) (B : ι → N) [set_like.has_graded_smul A B]\n  {i j : ι} (x : A i) (y : B j) :\n  (@graded_monoid.ghas_smul.smul ι (λ i, A i) (λ i, B i) _ _ i j x y : M) = ((x : R) • y) :=\nrfl\n\n/-- Internally graded version of `has_mul.to_has_smul`. -/\ninstance set_like.has_graded_mul.to_has_graded_smul [add_monoid ι] [monoid R]\n  {S : Type*} [set_like S R] (A : ι → S) [set_like.graded_monoid A] :\n  set_like.has_graded_smul A A :=\n{ smul_mem := λ i j ai bj hi hj, set_like.graded_monoid.mul_mem hi hj, }\n\nend subobjects\n\nsection homogeneous_elements\n\nvariables {S R N M : Type*} [set_like S R] [set_like N M]\n\nlemma set_like.is_homogeneous.graded_smul [has_add ι] [has_smul R M] {A : ι → S} {B : ι → N}\n  [set_like.has_graded_smul A B] {a : R} {b : M} :\n  set_like.is_homogeneous A a → set_like.is_homogeneous B b → set_like.is_homogeneous B (a • b)\n| ⟨i, hi⟩ ⟨j, hj⟩ := ⟨i + j, set_like.has_graded_smul.smul_mem hi hj⟩\n\nend homogeneous_elements\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/algebra/graded_mul_action.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.45113517561863536}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport category_theory.category.Pointed\nimport data.pfun\n\n/-!\n# The category of types with partial functions\n\nThis defines `PartialFun`, the category of types equipped with partial functions.\n\nThis category is classically equivalent to the category of pointed types. The reason it doesn't hold\nconstructively stems from the difference between `part` and `option`. Both can model partial\nfunctions, but the latter forces a decidable domain.\n\nPrecisely, `PartialFun_to_Pointed` turns a partial function `α →. β` into a function\n`option α → option β` by sending to `none` the undefined values (and `none` to `none`). But being\ndefined is (generally) undecidable while being sent to `none` is decidable. So it can't be\nconstructive.\n\n## References\n\n* [nLab, *The category of sets and partial functions*]\n  (https://ncatlab.org/nlab/show/partial+function)\n-/\n\nopen category_theory option\n\nuniverses u\nvariables {α β : Type*}\n\n/-- The category of types equipped with partial functions. -/\ndef PartialFun : Type* := Type*\n\nnamespace PartialFun\n\ninstance : has_coe_to_sort PartialFun Type* := ⟨id⟩\n\n/-- Turns a type into a `PartialFun`. -/\n@[nolint has_nonempty_instance] def of : Type* → PartialFun := id\n\n@[simp] lemma coe_of (X : Type*) : ↥(of X) = X := rfl\n\ninstance : inhabited PartialFun := ⟨Type*⟩\n\ninstance large_category : large_category.{u} PartialFun :=\n{ hom := pfun,\n  id := pfun.id,\n  comp := λ X Y Z f g, g.comp f,\n  id_comp' := @pfun.comp_id,\n  comp_id' := @pfun.id_comp,\n  assoc' := λ W X Y Z _ _ _, (pfun.comp_assoc _ _ _).symm }\n\n/-- Constructs a partial function isomorphism between types from an equivalence between them. -/\n@[simps] def iso.mk {α β : PartialFun.{u}} (e : α ≃ β) : α ≅ β :=\n{ hom := e,\n  inv := e.symm,\n  hom_inv_id' := (pfun.coe_comp _ _).symm.trans $ congr_arg coe e.symm_comp_self,\n  inv_hom_id' := (pfun.coe_comp _ _).symm.trans $ congr_arg coe e.self_comp_symm }\n\nend PartialFun\n\n/-- The forgetful functor from `Type` to `PartialFun` which forgets that the maps are total. -/\ndef Type_to_PartialFun : Type.{u} ⥤ PartialFun :=\n{ obj := id,\n  map := @pfun.lift,\n  map_comp' := λ _ _ _ _ _, pfun.coe_comp _ _ }\n\ninstance : faithful Type_to_PartialFun := ⟨λ X Y, pfun.coe_injective⟩\n\n/-- The functor which deletes the point of a pointed type. In return, this makes the maps partial.\nThis the computable part of the equivalence `PartialFun_equiv_Pointed`. -/\n@[simps map] def Pointed_to_PartialFun : Pointed.{u} ⥤ PartialFun :=\n{ obj := λ X, {x : X // x ≠ X.point},\n  map := λ X Y f, pfun.to_subtype _ f.to_fun ∘ subtype.val,\n  map_id' := λ X, pfun.ext $ λ a b,\n    pfun.mem_to_subtype_iff.trans (subtype.coe_inj.trans part.mem_some_iff.symm),\n  map_comp' := λ X Y Z f g, pfun.ext $ λ a c, begin\n    refine (pfun.mem_to_subtype_iff.trans _).trans part.mem_bind_iff.symm,\n    simp_rw [pfun.mem_to_subtype_iff, subtype.exists],\n    refine ⟨λ h, ⟨f.to_fun a, λ ha, c.2 $ h.trans\n      ((congr_arg g.to_fun ha : g.to_fun _ = _).trans g.map_point), rfl, h⟩, _⟩,\n    rintro ⟨b, _, (rfl : b = _), h⟩,\n    exact h,\n  end }\n\n/-- The functor which maps undefined values to a new point. This makes the maps total and creates\npointed types. This the noncomputable part of the equivalence `PartialFun_equiv_Pointed`. It can't\nbe computable because `= option.none` is decidable while the domain of a general `part` isn't. -/\n@[simps map] noncomputable def PartialFun_to_Pointed : PartialFun ⥤ Pointed :=\nby classical; exact\n{ obj := λ X, ⟨option X, none⟩,\n  map := λ X Y f, ⟨option.elim none (λ a, (f a).to_option), rfl⟩,\n  map_id' := λ X, Pointed.hom.ext _ _ $ funext $ λ o,\n    option.rec_on o rfl $ λ a, part.some_to_option _,\n  map_comp' := λ X Y Z f g, Pointed.hom.ext _ _ $ funext $ λ o, option.rec_on o rfl $ λ a,\n    part.bind_to_option _ _ }\n\n/-- The equivalence induced by `PartialFun_to_Pointed` and `Pointed_to_PartialFun`.\n`part.equiv_option` made functorial. -/\n@[simps] noncomputable def PartialFun_equiv_Pointed : PartialFun.{u} ≌ Pointed :=\nby classical; exact\nequivalence.mk PartialFun_to_Pointed Pointed_to_PartialFun\n  (nat_iso.of_components (λ X, PartialFun.iso.mk\n    { to_fun := λ a, ⟨some a, some_ne_none a⟩,\n      inv_fun := λ a, get $ ne_none_iff_is_some.1 a.2,\n      left_inv := λ a, get_some _ _,\n      right_inv := λ a, by simp only [subtype.val_eq_coe, some_get, subtype.coe_eta] }) $ λ X Y f,\n      pfun.ext $ λ a b, begin\n        unfold_projs,\n        dsimp,\n        rw part.bind_some,\n        refine (part.mem_bind_iff.trans _).trans pfun.mem_to_subtype_iff.symm,\n        obtain ⟨b | b, hb⟩ := b,\n        { exact (hb rfl).elim },\n        dsimp,\n        simp_rw [part.mem_some_iff, subtype.mk_eq_mk, exists_prop, some_inj, exists_eq_right'],\n        refine part.mem_to_option.symm.trans _,\n        exact eq_comm,\n      end)\n  (nat_iso.of_components (λ X, Pointed.iso.mk\n    { to_fun := option.elim X.point subtype.val,\n      inv_fun := λ a, if h : a = X.point then none else some ⟨_, h⟩,\n      left_inv := λ a, option.rec_on a (dif_pos rfl) $ λ a, (dif_neg a.2).trans $\n        by simp only [option.elim, subtype.val_eq_coe, subtype.coe_eta],\n      right_inv := λ a, begin\n        change option.elim _ _ (dite _ _ _) = _,\n        split_ifs,\n        { rw h, refl },\n        { refl }\n      end } rfl) $ λ X Y f, Pointed.hom.ext _ _ $ funext $ λ a, option.rec_on a f.map_point.symm $\n    λ a, begin\n      unfold_projs,\n      dsimp,\n      change option.elim _ _ _ = _,\n      rw part.elim_to_option,\n      split_ifs,\n      { refl },\n      { exact eq.symm (of_not_not h) }\n    end)\n\n/-- Forgetting that maps are total and making them total again by adding a point is the same as just\nadding a point. -/\n@[simps] noncomputable def Type_to_PartialFun_iso_PartialFun_to_Pointed :\n  Type_to_PartialFun ⋙ PartialFun_to_Pointed ≅ Type_to_Pointed :=\nnat_iso.of_components (λ X, { hom := ⟨id, rfl⟩,\n                              inv := ⟨id, rfl⟩,\n                              hom_inv_id' := rfl,\n                              inv_hom_id' := rfl }) $ λ X Y f,\n  Pointed.hom.ext _ _ $ funext $ λ a, option.rec_on a rfl $ λ a, by convert part.some_to_option _\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/category/PartialFun.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.45113517068988185}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.limits.shapes.terminal\nimport category_theory.discrete_category\nimport category_theory.epi_mono\nimport category_theory.over\n\n/-!\n# Binary (co)products\n\nWe define a category `walking_pair`, which is the index category\nfor a binary (co)product diagram. A convenience method `pair X Y`\nconstructs the functor from the walking pair, hitting the given objects.\n\nWe define `prod X Y` and `coprod X Y` as limits and colimits of such functors.\n\nTypeclasses `has_binary_products` and `has_binary_coproducts` assert the existence\nof (co)limits shaped as walking pairs.\n\nWe include lemmas for simplifying equations involving projections and coprojections, and define\nbraiding and associating isomorphisms, and the product comparison morphism.\n\n## References\n* [Stacks: Products of pairs](https://stacks.math.columbia.edu/tag/001R)\n* [Stacks: coproducts of pairs](https://stacks.math.columbia.edu/tag/04AN)\n-/\n\nnoncomputable theory\n\nuniverses v u u₂\n\nopen category_theory\n\nnamespace category_theory.limits\n\n/-- The type of objects for the diagram indexing a binary (co)product. -/\n@[derive decidable_eq, derive inhabited]\ninductive walking_pair : Type v\n| left | right\n\nopen walking_pair\n\n/--\nThe equivalence swapping left and right.\n-/\ndef walking_pair.swap : walking_pair ≃ walking_pair :=\n{ to_fun := λ j, walking_pair.rec_on j right left,\n  inv_fun := λ j, walking_pair.rec_on j right left,\n  left_inv := λ j, by { cases j; refl, },\n  right_inv := λ j, by { cases j; refl, }, }\n\n@[simp] lemma walking_pair.swap_apply_left : walking_pair.swap left = right := rfl\n@[simp] lemma walking_pair.swap_apply_right : walking_pair.swap right = left := rfl\n@[simp] lemma walking_pair.swap_symm_apply_tt : walking_pair.swap.symm left = right := rfl\n@[simp] lemma walking_pair.swap_symm_apply_ff : walking_pair.swap.symm right = left := rfl\n\n/--\nAn equivalence from `walking_pair` to `bool`, sometimes useful when reindexing limits.\n-/\ndef walking_pair.equiv_bool : walking_pair ≃ bool :=\n{ to_fun := λ j, walking_pair.rec_on j tt ff, -- to match equiv.sum_equiv_sigma_bool\n  inv_fun := λ b, bool.rec_on b right left,\n  left_inv := λ j, by { cases j; refl, },\n  right_inv := λ b, by { cases b; refl, }, }\n\n@[simp] lemma walking_pair.equiv_bool_apply_left : walking_pair.equiv_bool left = tt := rfl\n@[simp] lemma walking_pair.equiv_bool_apply_right : walking_pair.equiv_bool right = ff := rfl\n@[simp] lemma walking_pair.equiv_bool_symm_apply_tt : walking_pair.equiv_bool.symm tt = left := rfl\n@[simp] lemma walking_pair.equiv_bool_symm_apply_ff : walking_pair.equiv_bool.symm ff = right := rfl\n\nvariables {C : Type u} [category.{v} C]\n\n/-- The diagram on the walking pair, sending the two points to `X` and `Y`. -/\ndef pair (X Y : C) : discrete walking_pair ⥤ C :=\ndiscrete.functor (λ j, walking_pair.cases_on j X Y)\n\n@[simp] lemma pair_obj_left (X Y : C) : (pair X Y).obj left = X := rfl\n@[simp] lemma pair_obj_right (X Y : C) : (pair X Y).obj right = Y := rfl\n\nsection\nvariables {F G : discrete walking_pair.{v} ⥤ C} (f : F.obj left ⟶ G.obj left)\n  (g : F.obj right ⟶ G.obj right)\n\n/-- The natural transformation between two functors out of the walking pair, specified by its\ncomponents. -/\ndef map_pair : F ⟶ G := { app := λ j, walking_pair.cases_on j f g }\n\n@[simp] lemma map_pair_left : (map_pair f g).app left = f := rfl\n@[simp] lemma map_pair_right : (map_pair f g).app right = g := rfl\n\n/-- The natural isomorphism between two functors out of the walking pair, specified by its\ncomponents. -/\n@[simps]\ndef map_pair_iso (f : F.obj left ≅ G.obj left) (g : F.obj right ≅ G.obj right) : F ≅ G :=\nnat_iso.of_components (λ j, walking_pair.cases_on j f g) (by tidy)\n\nend\n\n/-- Every functor out of the walking pair is naturally isomorphic (actually, equal) to a `pair` -/\n@[simps]\ndef diagram_iso_pair (F : discrete walking_pair ⥤ C) :\n  F ≅ pair (F.obj walking_pair.left) (F.obj walking_pair.right) :=\nmap_pair_iso (iso.refl _) (iso.refl _)\n\nsection\nvariables {D : Type u} [category.{v} D]\n\n/-- The natural isomorphism between `pair X Y ⋙ F` and `pair (F.obj X) (F.obj Y)`. -/\ndef pair_comp (X Y : C) (F : C ⥤ D) : pair X Y ⋙ F ≅ pair (F.obj X) (F.obj Y) :=\ndiagram_iso_pair _\n\nend\n\n/-- A binary fan is just a cone on a diagram indexing a product. -/\nabbreviation binary_fan (X Y : C) := cone (pair X Y)\n\n/-- The first projection of a binary fan. -/\nabbreviation binary_fan.fst {X Y : C} (s : binary_fan X Y) := s.π.app walking_pair.left\n\n/-- The second projection of a binary fan. -/\nabbreviation binary_fan.snd {X Y : C} (s : binary_fan X Y) := s.π.app walking_pair.right\n\n@[simp] lemma binary_fan.π_app_left {X Y : C} (s : binary_fan X Y) :\n  s.π.app walking_pair.left = s.fst := rfl\n@[simp] lemma binary_fan.π_app_right {X Y : C} (s : binary_fan X Y) :\n  s.π.app walking_pair.right = s.snd := rfl\n\nlemma binary_fan.is_limit.hom_ext {W X Y : C} {s : binary_fan X Y} (h : is_limit s)\n  {f g : W ⟶ s.X} (h₁ : f ≫ s.fst = g ≫ s.fst) (h₂ : f ≫ s.snd = g ≫ s.snd) : f = g :=\nh.hom_ext $ λ j, walking_pair.cases_on j h₁ h₂\n\n/-- A binary cofan is just a cocone on a diagram indexing a coproduct. -/\nabbreviation binary_cofan (X Y : C) := cocone (pair X Y)\n\n/-- The first inclusion of a binary cofan. -/\nabbreviation binary_cofan.inl {X Y : C} (s : binary_cofan X Y) := s.ι.app walking_pair.left\n\n/-- The second inclusion of a binary cofan. -/\nabbreviation binary_cofan.inr {X Y : C} (s : binary_cofan X Y) := s.ι.app walking_pair.right\n\n@[simp] lemma binary_cofan.ι_app_left {X Y : C} (s : binary_cofan X Y) :\n  s.ι.app walking_pair.left = s.inl := rfl\n@[simp] lemma binary_cofan.ι_app_right {X Y : C} (s : binary_cofan X Y) :\n  s.ι.app walking_pair.right = s.inr := rfl\n\nlemma binary_cofan.is_colimit.hom_ext {W X Y : C} {s : binary_cofan X Y} (h : is_colimit s)\n  {f g : s.X ⟶ W} (h₁ : s.inl ≫ f = s.inl ≫ g) (h₂ : s.inr ≫ f = s.inr ≫ g) : f = g :=\nh.hom_ext $ λ j, walking_pair.cases_on j h₁ h₂\n\nvariables {X Y : C}\n\n/-- A binary fan with vertex `P` consists of the two projections `π₁ : P ⟶ X` and `π₂ : P ⟶ Y`. -/\n@[simps X]\ndef binary_fan.mk {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) : binary_fan X Y :=\n{ X := P,\n  π := { app := λ j, walking_pair.cases_on j π₁ π₂ }}\n\n/-- A binary cofan with vertex `P` consists of the two inclusions `ι₁ : X ⟶ P` and `ι₂ : Y ⟶ P`. -/\n@[simps X]\ndef binary_cofan.mk {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) : binary_cofan X Y :=\n{ X := P,\n  ι := { app := λ j, walking_pair.cases_on j ι₁ ι₂ }}\n\n@[simp] lemma binary_fan.mk_π_app_left {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) :\n  (binary_fan.mk π₁ π₂).π.app walking_pair.left = π₁ := rfl\n@[simp] lemma binary_fan.mk_π_app_right {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) :\n  (binary_fan.mk π₁ π₂).π.app walking_pair.right = π₂ := rfl\n@[simp] lemma binary_cofan.mk_ι_app_left {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) :\n  (binary_cofan.mk ι₁ ι₂).ι.app walking_pair.left = ι₁ := rfl\n@[simp] lemma binary_cofan.mk_ι_app_right {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) :\n  (binary_cofan.mk ι₁ ι₂).ι.app walking_pair.right = ι₂ := rfl\n\n/-- If `s` is a limit binary fan over `X` and `Y`, then every pair of morphisms `f : W ⟶ X` and\n    `g : W ⟶ Y` induces a morphism `l : W ⟶ s.X` satisfying `l ≫ s.fst = f` and `l ≫ s.snd = g`.\n    -/\n@[simps]\ndef binary_fan.is_limit.lift' {W X Y : C} {s : binary_fan X Y} (h : is_limit s) (f : W ⟶ X)\n  (g : W ⟶ Y) : {l : W ⟶ s.X // l ≫ s.fst = f ∧ l ≫ s.snd = g} :=\n⟨h.lift $ binary_fan.mk f g, h.fac _ _, h.fac _ _⟩\n\n/-- If `s` is a colimit binary cofan over `X` and `Y`,, then every pair of morphisms `f : X ⟶ W` and\n    `g : Y ⟶ W` induces a morphism `l : s.X ⟶ W` satisfying `s.inl ≫ l = f` and `s.inr ≫ l = g`.\n    -/\n@[simps]\ndef binary_cofan.is_colimit.desc' {W X Y : C} {s : binary_cofan X Y} (h : is_colimit s) (f : X ⟶ W)\n  (g : Y ⟶ W) : {l : s.X ⟶ W // s.inl ≫ l = f ∧ s.inr ≫ l = g} :=\n⟨h.desc $ binary_cofan.mk f g, h.fac _ _, h.fac _ _⟩\n\n/-- An abbreviation for `has_limit (pair X Y)`. -/\nabbreviation has_binary_product (X Y : C) := has_limit (pair X Y)\n/-- An abbreviation for `has_colimit (pair X Y)`. -/\nabbreviation has_binary_coproduct (X Y : C) := has_colimit (pair X Y)\n\n/-- If we have a product of `X` and `Y`, we can access it using `prod X Y` or\n    `X ⨯ Y`. -/\nabbreviation prod (X Y : C) [has_binary_product X Y] := limit (pair X Y)\n\n/-- If we have a coproduct of `X` and `Y`, we can access it using `coprod X Y ` or\n    `X ⨿ Y`. -/\nabbreviation coprod (X Y : C) [has_binary_coproduct X Y] := colimit (pair X Y)\n\nnotation X ` ⨯ `:20 Y:20 := prod X Y\nnotation X ` ⨿ `:20 Y:20 := coprod X Y\n\n/-- The projection map to the first component of the product. -/\nabbreviation prod.fst {X Y : C} [has_binary_product X Y] : X ⨯ Y ⟶ X :=\nlimit.π (pair X Y) walking_pair.left\n\n/-- The projecton map to the second component of the product. -/\nabbreviation prod.snd {X Y : C} [has_binary_product X Y] : X ⨯ Y ⟶ Y :=\nlimit.π (pair X Y) walking_pair.right\n\n/-- The inclusion map from the first component of the coproduct. -/\nabbreviation coprod.inl {X Y : C} [has_binary_coproduct X Y] : X ⟶ X ⨿ Y :=\ncolimit.ι (pair X Y) walking_pair.left\n\n/-- The inclusion map from the second component of the coproduct. -/\nabbreviation coprod.inr {X Y : C} [has_binary_coproduct X Y] : Y ⟶ X ⨿ Y :=\ncolimit.ι (pair X Y) walking_pair.right\n\n/-- The binary fan constructed from the projection maps is a limit. -/\ndef prod_is_prod (X Y : C) [has_binary_product X Y] :\n  is_limit (binary_fan.mk (prod.fst : X ⨯ Y ⟶ X) prod.snd) :=\n(limit.is_limit _).of_iso_limit (cones.ext (iso.refl _) (by { rintro (_ | _), tidy }))\n\n/-- The binary cofan constructed from the coprojection maps is a colimit. -/\ndef coprod_is_coprod (X Y : C) [has_binary_coproduct X Y] :\n  is_colimit (binary_cofan.mk (coprod.inl : X ⟶ X ⨿ Y) coprod.inr) :=\n(colimit.is_colimit _).of_iso_colimit (cocones.ext (iso.refl _) (by { rintro (_ | _), tidy }))\n\n@[ext] lemma prod.hom_ext {W X Y : C} [has_binary_product X Y] {f g : W ⟶ X ⨯ Y}\n  (h₁ : f ≫ prod.fst = g ≫ prod.fst) (h₂ : f ≫ prod.snd = g ≫ prod.snd) : f = g :=\nbinary_fan.is_limit.hom_ext (limit.is_limit _) h₁ h₂\n\n@[ext] lemma coprod.hom_ext {W X Y : C} [has_binary_coproduct X Y] {f g : X ⨿ Y ⟶ W}\n  (h₁ : coprod.inl ≫ f = coprod.inl ≫ g) (h₂ : coprod.inr ≫ f = coprod.inr ≫ g) : f = g :=\nbinary_cofan.is_colimit.hom_ext (colimit.is_colimit _) h₁ h₂\n\n/-- If the product of `X` and `Y` exists, then every pair of morphisms `f : W ⟶ X` and `g : W ⟶ Y`\n    induces a morphism `prod.lift f g : W ⟶ X ⨯ Y`. -/\nabbreviation prod.lift {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) : W ⟶ X ⨯ Y :=\nlimit.lift _ (binary_fan.mk f g)\n\n/-- diagonal arrow of the binary product in the category `fam I` -/\nabbreviation diag (X : C) [has_binary_product X X] : X ⟶ X ⨯ X :=\nprod.lift (𝟙 _) (𝟙 _)\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X ⟶ W` and\n    `g : Y ⟶ W` induces a morphism `coprod.desc f g : X ⨿ Y ⟶ W`. -/\nabbreviation coprod.desc {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  X ⨿ Y ⟶ W :=\ncolimit.desc _ (binary_cofan.mk f g)\n\n/-- codiagonal arrow of the binary coproduct -/\nabbreviation codiag (X : C) [has_binary_coproduct X X] : X ⨿ X ⟶ X :=\ncoprod.desc (𝟙 _) (𝟙 _)\n\n@[simp, reassoc]\nlemma prod.lift_fst {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  prod.lift f g ≫ prod.fst = f :=\nlimit.lift_π _ _\n\n@[simp, reassoc]\nlemma prod.lift_snd {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  prod.lift f g ≫ prod.snd = g :=\nlimit.lift_π _ _\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.inl_desc {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  coprod.inl ≫ coprod.desc f g = f :=\ncolimit.ι_desc _ _\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.inr_desc {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  coprod.inr ≫ coprod.desc f g = g :=\ncolimit.ι_desc _ _\n\ninstance prod.mono_lift_of_mono_left {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y)\n  [mono f] : mono (prod.lift f g) :=\nmono_of_mono_fac $ prod.lift_fst _ _\n\ninstance prod.mono_lift_of_mono_right {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y)\n  [mono g] : mono (prod.lift f g) :=\nmono_of_mono_fac $ prod.lift_snd _ _\n\ninstance coprod.epi_desc_of_epi_left {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W)\n  [epi f] : epi (coprod.desc f g) :=\nepi_of_epi_fac $ coprod.inl_desc _ _\n\ninstance coprod.epi_desc_of_epi_right {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W)\n  [epi g] : epi (coprod.desc f g) :=\nepi_of_epi_fac $ coprod.inr_desc _ _\n\n/-- If the product of `X` and `Y` exists, then every pair of morphisms `f : W ⟶ X` and `g : W ⟶ Y`\n    induces a morphism `l : W ⟶ X ⨯ Y` satisfying `l ≫ prod.fst = f` and `l ≫ prod.snd = g`. -/\ndef prod.lift' {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  {l : W ⟶ X ⨯ Y // l ≫ prod.fst = f ∧ l ≫ prod.snd = g} :=\n⟨prod.lift f g, prod.lift_fst _ _, prod.lift_snd _ _⟩\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X ⟶ W` and\n    `g : Y ⟶ W` induces a morphism `l : X ⨿ Y ⟶ W` satisfying `coprod.inl ≫ l = f` and\n    `coprod.inr ≫ l = g`. -/\ndef coprod.desc' {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  {l : X ⨿ Y ⟶ W // coprod.inl ≫ l = f ∧ coprod.inr ≫ l = g} :=\n⟨coprod.desc f g, coprod.inl_desc _ _, coprod.inr_desc _ _⟩\n\n/-- If the products `W ⨯ X` and `Y ⨯ Z` exist, then every pair of morphisms `f : W ⟶ Y` and\n    `g : X ⟶ Z` induces a morphism `prod.map f g : W ⨯ X ⟶ Y ⨯ Z`. -/\ndef prod.map {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : W ⨯ X ⟶ Y ⨯ Z :=\nlim_map (map_pair f g)\n\n/-- If the coproducts `W ⨿ X` and `Y ⨿ Z` exist, then every pair of morphisms `f : W ⟶ Y` and\n    `g : W ⟶ Z` induces a morphism `coprod.map f g : W ⨿ X ⟶ Y ⨿ Z`. -/\ndef coprod.map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : W ⨿ X ⟶ Y ⨿ Z :=\ncolim_map (map_pair f g)\n\nsection prod_lemmas\n\n-- Making the reassoc version of this a simp lemma seems to be more harmful than helpful.\n@[reassoc, simp]\nlemma prod.comp_lift {V W X Y : C} [has_binary_product X Y] (f : V ⟶ W) (g : W ⟶ X) (h : W ⟶ Y) :\n  f ≫ prod.lift g h = prod.lift (f ≫ g) (f ≫ h) :=\nby { ext; simp }\n\nlemma prod.comp_diag {X Y : C} [has_binary_product Y Y] (f : X ⟶ Y) :\n  f ≫ diag Y = prod.lift f f :=\nby simp\n\n@[simp, reassoc]\nlemma prod.map_fst {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : prod.map f g ≫ prod.fst = prod.fst ≫ f :=\nlim_map_π _ _\n\n@[simp, reassoc]\nlemma prod.map_snd {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : prod.map f g ≫ prod.snd = prod.snd ≫ g :=\nlim_map_π _ _\n\n@[simp] lemma prod.map_id_id {X Y : C} [has_binary_product X Y] :\n  prod.map (𝟙 X) (𝟙 Y) = 𝟙 _ :=\nby { ext; simp }\n\n@[simp] lemma prod.lift_fst_snd {X Y : C} [has_binary_product X Y] :\n  prod.lift prod.fst prod.snd = 𝟙 (X ⨯ Y) :=\nby { ext; simp }\n\n@[simp, reassoc] lemma prod.lift_map {V W X Y Z : C} [has_binary_product W X]\n  [has_binary_product Y Z] (f : V ⟶ W) (g : V ⟶ X) (h : W ⟶ Y) (k : X ⟶ Z) :\n  prod.lift f g ≫ prod.map h k = prod.lift (f ≫ h) (g ≫ k) :=\nby { ext; simp }\n\n@[simp] lemma prod.lift_fst_comp_snd_comp {W X Y Z : C} [has_binary_product W Y]\n  [has_binary_product X Z] (g : W ⟶ X) (g' : Y ⟶ Z) :\n  prod.lift (prod.fst ≫ g) (prod.snd ≫ g') = prod.map g g' :=\nby { rw ← prod.lift_map, simp }\n\n-- We take the right hand side here to be simp normal form, as this way composition lemmas for\n-- `f ≫ h` and `g ≫ k` can fire (eg `id_comp`) , while `map_fst` and `map_snd` can still work just\n-- as well.\n@[simp, reassoc]\nlemma prod.map_map {A₁ A₂ A₃ B₁ B₂ B₃ : C}\n  [has_binary_product A₁ B₁] [has_binary_product A₂ B₂] [has_binary_product A₃ B₃]\n  (f : A₁ ⟶ A₂) (g : B₁ ⟶ B₂) (h : A₂ ⟶ A₃) (k : B₂ ⟶ B₃) :\n  prod.map f g ≫ prod.map h k = prod.map (f ≫ h) (g ≫ k) :=\nby { ext; simp }\n\n-- TODO: is it necessary to weaken the assumption here?\n@[reassoc]\nlemma prod.map_swap {A B X Y : C} (f : A ⟶ B) (g : X ⟶ Y)\n  [has_limits_of_shape (discrete walking_pair) C] :\n  prod.map (𝟙 X) f ≫ prod.map g (𝟙 B) = prod.map g (𝟙 A) ≫ prod.map (𝟙 Y) f :=\nby simp\n\n@[reassoc] lemma prod.map_comp_id {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_product X W] [has_binary_product Z W] [has_binary_product Y W] :\n  prod.map (f ≫ g) (𝟙 W) = prod.map f (𝟙 W) ≫ prod.map g (𝟙 W) :=\nby simp\n\n@[reassoc] lemma prod.map_id_comp {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_product W X] [has_binary_product W Y] [has_binary_product W Z] :\n  prod.map (𝟙 W) (f ≫ g) = prod.map (𝟙 W) f ≫ prod.map (𝟙 W) g :=\nby simp\n\n/-- If the products `W ⨯ X` and `Y ⨯ Z` exist, then every pair of isomorphisms `f : W ≅ Y` and\n    `g : X ≅ Z` induces an isomorphism `prod.map_iso f g : W ⨯ X ≅ Y ⨯ Z`. -/\n@[simps]\ndef prod.map_iso {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ≅ Y) (g : X ≅ Z) : W ⨯ X ≅ Y ⨯ Z :=\n{ hom := prod.map f.hom g.hom,\n  inv := prod.map f.inv g.inv }\n\ninstance is_iso_prod {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) [is_iso f] [is_iso g] : is_iso (prod.map f g) :=\nis_iso.of_iso (prod.map_iso (as_iso f) (as_iso g))\n\n@[simp, reassoc]\nlemma prod.diag_map {X Y : C} (f : X ⟶ Y) [has_binary_product X X] [has_binary_product Y Y] :\n  diag X ≫ prod.map f f = f ≫ diag Y :=\nby simp\n\n@[simp, reassoc]\nlemma prod.diag_map_fst_snd {X Y : C} [has_binary_product X Y]\n  [has_binary_product (X ⨯ Y) (X ⨯ Y)] :\n  diag (X ⨯ Y) ≫ prod.map prod.fst prod.snd = 𝟙 (X ⨯ Y) :=\nby simp\n\n@[simp, reassoc]\nlemma prod.diag_map_fst_snd_comp  [has_limits_of_shape (discrete walking_pair) C]\n  {X X' Y Y' : C} (g : X ⟶ Y) (g' : X' ⟶ Y') :\n  diag (X ⨯ X') ≫ prod.map (prod.fst ≫ g) (prod.snd ≫ g') = prod.map g g' :=\nby simp\n\ninstance {X : C} [has_binary_product X X] : split_mono (diag X) :=\n{ retraction := prod.fst }\n\nend prod_lemmas\n\nsection coprod_lemmas\n\n@[simp, reassoc]\nlemma coprod.desc_comp {V W X Y : C} [has_binary_coproduct X Y] (f : V ⟶ W) (g : X ⟶ V)\n  (h : Y ⟶ V) :\n  coprod.desc g h ≫ f = coprod.desc (g ≫ f) (h ≫ f) :=\nby { ext; simp }\n\nlemma coprod.diag_comp {X Y : C} [has_binary_coproduct X X] (f : X ⟶ Y) :\n  codiag X ≫ f = coprod.desc f f :=\nby simp\n\n@[simp, reassoc]\nlemma coprod.inl_map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : coprod.inl ≫ coprod.map f g = f ≫ coprod.inl :=\nι_colim_map _ _\n\n@[simp, reassoc]\nlemma coprod.inr_map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : coprod.inr ≫ coprod.map f g = g ≫ coprod.inr :=\nι_colim_map _ _\n\n@[simp]\nlemma coprod.map_id_id {X Y : C} [has_binary_coproduct X Y] :\n  coprod.map (𝟙 X) (𝟙 Y) = 𝟙 _ :=\nby { ext; simp }\n\n@[simp]\nlemma coprod.desc_inl_inr {X Y : C} [has_binary_coproduct X Y] :\n  coprod.desc coprod.inl coprod.inr = 𝟙 (X ⨿ Y) :=\nby { ext; simp }\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_desc {S T U V W : C} [has_binary_coproduct U W] [has_binary_coproduct T V]\n  (f : U ⟶ S) (g : W ⟶ S) (h : T ⟶ U) (k : V ⟶ W) :\n  coprod.map h k ≫ coprod.desc f g = coprod.desc (h ≫ f) (k ≫ g) :=\nby { ext; simp }\n\n@[simp]\nlemma coprod.desc_comp_inl_comp_inr {W X Y Z : C}\n  [has_binary_coproduct W Y] [has_binary_coproduct X Z]\n  (g : W ⟶ X) (g' : Y ⟶ Z) :\n  coprod.desc (g ≫ coprod.inl) (g' ≫ coprod.inr) = coprod.map g g' :=\nby { rw ← coprod.map_desc, simp }\n\n-- We take the right hand side here to be simp normal form, as this way composition lemmas for\n-- `f ≫ h` and `g ≫ k` can fire (eg `id_comp`) , while `inl_map` and `inr_map` can still work just\n-- as well.\n@[simp, reassoc]\nlemma coprod.map_map {A₁ A₂ A₃ B₁ B₂ B₃ : C}\n  [has_binary_coproduct A₁ B₁] [has_binary_coproduct A₂ B₂] [has_binary_coproduct A₃ B₃]\n  (f : A₁ ⟶ A₂) (g : B₁ ⟶ B₂) (h : A₂ ⟶ A₃) (k : B₂ ⟶ B₃) :\n  coprod.map f g ≫ coprod.map h k = coprod.map (f ≫ h) (g ≫ k) :=\nby { ext; simp }\n\n-- I don't think it's a good idea to make any of the following three simp lemmas.\n@[reassoc]\nlemma coprod.map_swap {A B X Y : C} (f : A ⟶ B) (g : X ⟶ Y)\n  [has_colimits_of_shape (discrete walking_pair) C] :\n  coprod.map (𝟙 X) f ≫ coprod.map g (𝟙 B) = coprod.map g (𝟙 A) ≫ coprod.map (𝟙 Y) f :=\nby simp\n\n@[reassoc] lemma coprod.map_comp_id {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_coproduct Z W] [has_binary_coproduct Y W] [has_binary_coproduct X W] :\n  coprod.map (f ≫ g) (𝟙 W) = coprod.map f (𝟙 W) ≫ coprod.map g (𝟙 W) :=\nby simp\n\n@[reassoc] lemma coprod.map_id_comp {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_coproduct W X] [has_binary_coproduct W Y] [has_binary_coproduct W Z] :\n  coprod.map (𝟙 W) (f ≫ g) = coprod.map (𝟙 W) f ≫ coprod.map (𝟙 W) g :=\nby simp\n\n/-- If the coproducts `W ⨿ X` and `Y ⨿ Z` exist, then every pair of isomorphisms `f : W ≅ Y` and\n    `g : W ≅ Z` induces a isomorphism `coprod.map_iso f g : W ⨿ X ≅ Y ⨿ Z`. -/\n@[simps]\ndef coprod.map_iso {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ≅ Y) (g : X ≅ Z) : W ⨿ X ≅ Y ⨿ Z :=\n{ hom := coprod.map f.hom g.hom,\n  inv := coprod.map f.inv g.inv }\n\ninstance is_iso_coprod {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) [is_iso f] [is_iso g] : is_iso (coprod.map f g) :=\nis_iso.of_iso (coprod.map_iso (as_iso f) (as_iso g))\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_codiag {X Y : C} (f : X ⟶ Y) [has_binary_coproduct X X]\n  [has_binary_coproduct Y Y] :\n  coprod.map f f ≫ codiag Y = codiag X ≫ f :=\nby simp\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_inl_inr_codiag {X Y : C} [has_binary_coproduct X Y]\n  [has_binary_coproduct (X ⨿ Y) (X ⨿ Y)] :\n  coprod.map coprod.inl coprod.inr ≫ codiag (X ⨿ Y) = 𝟙 (X ⨿ Y) :=\nby simp\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_comp_inl_inr_codiag [has_colimits_of_shape (discrete walking_pair) C]\n  {X X' Y Y' : C} (g : X ⟶ Y) (g' : X' ⟶ Y') :\n  coprod.map (g ≫ coprod.inl) (g' ≫ coprod.inr) ≫ codiag (Y ⨿ Y') = coprod.map g g' :=\nby simp\n\nend coprod_lemmas\n\nvariables (C)\n\n/--\n`has_binary_products` represents a choice of product for every pair of objects.\n\nSee https://stacks.math.columbia.edu/tag/001T.\n-/\nabbreviation has_binary_products := has_limits_of_shape (discrete walking_pair) C\n\n/--\n`has_binary_coproducts` represents a choice of coproduct for every pair of objects.\n\nSee https://stacks.math.columbia.edu/tag/04AP.\n-/\nabbreviation has_binary_coproducts := has_colimits_of_shape (discrete walking_pair) C\n\n/-- If `C` has all limits of diagrams `pair X Y`, then it has all binary products -/\nlemma has_binary_products_of_has_limit_pair [Π {X Y : C}, has_limit (pair X Y)] :\n  has_binary_products C :=\n{ has_limit := λ F, has_limit_of_iso (diagram_iso_pair F).symm }\n\n/-- If `C` has all colimits of diagrams `pair X Y`, then it has all binary coproducts -/\nlemma has_binary_coproducts_of_has_colimit_pair [Π {X Y : C}, has_colimit (pair X Y)] :\n  has_binary_coproducts C :=\n{ has_colimit := λ F, has_colimit_of_iso (diagram_iso_pair F) }\n\nsection\nvariables {C}\n\n/-- The braiding isomorphism which swaps a binary product. -/\n@[simps] def prod.braiding (P Q : C) [has_binary_product P Q] [has_binary_product Q P] :\n  P ⨯ Q ≅ Q ⨯ P :=\n{ hom := prod.lift prod.snd prod.fst,\n  inv := prod.lift prod.snd prod.fst }\n\n/-- The braiding isomorphism can be passed through a map by swapping the order. -/\n@[reassoc] lemma braid_natural [has_binary_products C] {W X Y Z : C} (f : X ⟶ Y) (g : Z ⟶ W) :\n  prod.map f g ≫ (prod.braiding _ _).hom = (prod.braiding _ _).hom ≫ prod.map g f :=\nby simp\n\n@[reassoc] lemma prod.symmetry' (P Q : C) [has_binary_product P Q] [has_binary_product Q P] :\n  prod.lift prod.snd prod.fst ≫ prod.lift prod.snd prod.fst = 𝟙 (P ⨯ Q) :=\n(prod.braiding _ _).hom_inv_id\n\n/-- The braiding isomorphism is symmetric. -/\n@[reassoc] lemma prod.symmetry (P Q : C) [has_binary_product P Q] [has_binary_product Q P] :\n  (prod.braiding P Q).hom ≫ (prod.braiding Q P).hom = 𝟙 _ :=\n(prod.braiding _ _).hom_inv_id\n\n/-- The associator isomorphism for binary products. -/\n@[simps] def prod.associator [has_binary_products C] (P Q R : C) :\n  (P ⨯ Q) ⨯ R ≅ P ⨯ (Q ⨯ R) :=\n{ hom :=\n  prod.lift\n    (prod.fst ≫ prod.fst)\n    (prod.lift (prod.fst ≫ prod.snd) prod.snd),\n  inv :=\n  prod.lift\n    (prod.lift prod.fst (prod.snd ≫ prod.fst))\n    (prod.snd ≫ prod.snd) }\n\n@[reassoc]\nlemma prod.pentagon [has_binary_products C] (W X Y Z : C) :\n  prod.map ((prod.associator W X Y).hom) (𝟙 Z) ≫\n      (prod.associator W (X ⨯ Y) Z).hom ≫ prod.map (𝟙 W) ((prod.associator X Y Z).hom) =\n    (prod.associator (W ⨯ X) Y Z).hom ≫ (prod.associator W X (Y ⨯ Z)).hom :=\nby simp\n\n@[reassoc]\nlemma prod.associator_naturality [has_binary_products C] {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :\n  prod.map (prod.map f₁ f₂) f₃ ≫ (prod.associator Y₁ Y₂ Y₃).hom =\n    (prod.associator X₁ X₂ X₃).hom ≫ prod.map f₁ (prod.map f₂ f₃) :=\nby simp\n\nvariables [has_terminal C]\n\n/-- The left unitor isomorphism for binary products with the terminal object. -/\n@[simps] def prod.left_unitor (P : C) [has_binary_product (⊤_ C) P] :\n  ⊤_ C ⨯ P ≅ P :=\n{ hom := prod.snd,\n  inv := prod.lift (terminal.from P) (𝟙 _) }\n\n/-- The right unitor isomorphism for binary products with the terminal object. -/\n@[simps] def prod.right_unitor (P : C) [has_binary_product P (⊤_ C)] :\n  P ⨯ ⊤_ C ≅ P :=\n{ hom := prod.fst,\n  inv := prod.lift (𝟙 _) (terminal.from P) }\n\n@[reassoc]\nlemma prod.left_unitor_hom_naturality [has_binary_products C] (f : X ⟶ Y) :\n  prod.map (𝟙 _) f ≫ (prod.left_unitor Y).hom = (prod.left_unitor X).hom ≫ f :=\nprod.map_snd _ _\n\n@[reassoc]\nlemma prod.left_unitor_inv_naturality [has_binary_products C] (f : X ⟶ Y) :\n  (prod.left_unitor X).inv ≫ prod.map (𝟙 _) f = f ≫ (prod.left_unitor Y).inv :=\nby rw [iso.inv_comp_eq, ← category.assoc, iso.eq_comp_inv, prod.left_unitor_hom_naturality]\n\n@[reassoc]\nlemma prod.right_unitor_hom_naturality [has_binary_products C] (f : X ⟶ Y) :\n  prod.map f (𝟙 _) ≫ (prod.right_unitor Y).hom = (prod.right_unitor X).hom ≫ f :=\nprod.map_fst _ _\n\n@[reassoc]\nlemma prod_right_unitor_inv_naturality [has_binary_products C] (f : X ⟶ Y) :\n  (prod.right_unitor X).inv ≫ prod.map f (𝟙 _) = f ≫ (prod.right_unitor Y).inv :=\nby rw [iso.inv_comp_eq, ← category.assoc, iso.eq_comp_inv, prod.right_unitor_hom_naturality]\n\nlemma prod.triangle [has_binary_products C] (X Y : C) :\n  (prod.associator X (⊤_ C) Y).hom ≫ prod.map (𝟙 X) ((prod.left_unitor Y).hom) =\n    prod.map ((prod.right_unitor X).hom) (𝟙 Y) :=\nby tidy\n\nend\n\nsection\n\nvariables {C} [has_binary_coproducts C]\n\n/-- The braiding isomorphism which swaps a binary coproduct. -/\n@[simps] def coprod.braiding (P Q : C) : P ⨿ Q ≅ Q ⨿ P :=\n{ hom := coprod.desc coprod.inr coprod.inl,\n  inv := coprod.desc coprod.inr coprod.inl }\n\n@[reassoc] lemma coprod.symmetry' (P Q : C) :\n  coprod.desc coprod.inr coprod.inl ≫ coprod.desc coprod.inr coprod.inl = 𝟙 (P ⨿ Q) :=\n(coprod.braiding _ _).hom_inv_id\n\n/-- The braiding isomorphism is symmetric. -/\nlemma coprod.symmetry (P Q : C) :\n  (coprod.braiding P Q).hom ≫ (coprod.braiding Q P).hom = 𝟙 _ :=\ncoprod.symmetry' _ _\n\n/-- The associator isomorphism for binary coproducts. -/\n@[simps] def coprod.associator\n  (P Q R : C) : (P ⨿ Q) ⨿ R ≅ P ⨿ (Q ⨿ R) :=\n{ hom :=\n  coprod.desc\n    (coprod.desc coprod.inl (coprod.inl ≫ coprod.inr))\n    (coprod.inr ≫ coprod.inr),\n  inv :=\n  coprod.desc\n    (coprod.inl ≫ coprod.inl)\n    (coprod.desc (coprod.inr ≫ coprod.inl) coprod.inr) }\n\nlemma coprod.pentagon (W X Y Z : C) :\n  coprod.map ((coprod.associator W X Y).hom) (𝟙 Z) ≫\n      (coprod.associator W (X ⨿ Y) Z).hom ≫ coprod.map (𝟙 W) ((coprod.associator X Y Z).hom) =\n    (coprod.associator (W ⨿ X) Y Z).hom ≫ (coprod.associator W X (Y ⨿ Z)).hom :=\nby simp\n\nlemma coprod.associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂)\n  (f₃ : X₃ ⟶ Y₃) :\n  coprod.map (coprod.map f₁ f₂) f₃ ≫ (coprod.associator Y₁ Y₂ Y₃).hom =\n    (coprod.associator X₁ X₂ X₃).hom ≫ coprod.map f₁ (coprod.map f₂ f₃) :=\nby simp\n\nvariables [has_initial C]\n\n/-- The left unitor isomorphism for binary coproducts with the initial object. -/\n@[simps] def coprod.left_unitor\n  (P : C) : ⊥_ C ⨿ P ≅ P :=\n{ hom := coprod.desc (initial.to P) (𝟙 _),\n  inv := coprod.inr }\n\n/-- The right unitor isomorphism for binary coproducts with the initial object. -/\n@[simps] def coprod.right_unitor\n  (P : C) : P ⨿ ⊥_ C ≅ P :=\n{ hom := coprod.desc (𝟙 _) (initial.to P),\n  inv := coprod.inl }\n\nlemma coprod.triangle (X Y : C) :\n  (coprod.associator X (⊥_ C) Y).hom ≫ coprod.map (𝟙 X) ((coprod.left_unitor Y).hom) =\n    coprod.map ((coprod.right_unitor X).hom) (𝟙 Y) :=\nby tidy\n\nend\n\nsection prod_functor\nvariables {C} [has_binary_products C]\n\n/-- The binary product functor. -/\n@[simps]\ndef prod.functor : C ⥤ C ⥤ C :=\n{ obj := λ X, { obj := λ Y, X ⨯ Y, map := λ Y Z, prod.map (𝟙 X) },\n  map := λ Y Z f, { app := λ T, prod.map f (𝟙 T) }}\n\n/-- The product functor can be decomposed. -/\ndef prod.functor_left_comp (X Y : C) :\n  prod.functor.obj (X ⨯ Y) ≅ prod.functor.obj Y ⋙ prod.functor.obj X :=\nnat_iso.of_components (prod.associator _ _) (by tidy)\n\nend prod_functor\n\nsection coprod_functor\nvariables {C} [has_binary_coproducts C]\n\n/-- The binary coproduct functor. -/\n@[simps]\ndef coprod.functor : C ⥤ C ⥤ C :=\n{ obj := λ X, { obj := λ Y, X ⨿ Y, map := λ Y Z, coprod.map (𝟙 X) },\n  map := λ Y Z f, { app := λ T, coprod.map f (𝟙 T) }}\n\n/-- The coproduct functor can be decomposed. -/\ndef coprod.functor_left_comp (X Y : C) :\n  coprod.functor.obj (X ⨿ Y) ≅ coprod.functor.obj Y ⋙ coprod.functor.obj X :=\nnat_iso.of_components (coprod.associator _ _) (by tidy)\n\nend coprod_functor\n\nsection prod_comparison\n\nvariables {C} {D : Type u₂} [category.{v} D]\nvariables (F : C ⥤ D) {A A' B B' : C}\nvariables [has_binary_product A B] [has_binary_product A' B']\nvariables [has_binary_product (F.obj A) (F.obj B)] [has_binary_product (F.obj A') (F.obj B')]\n/--\nThe product comparison morphism.\n\nIn `category_theory/limits/preserves` we show this is always an iso iff F preserves binary products.\n-/\ndef prod_comparison (F : C ⥤ D) (A B : C)\n  [has_binary_product A B] [has_binary_product (F.obj A) (F.obj B)] :\n  F.obj (A ⨯ B) ⟶ F.obj A ⨯ F.obj B :=\nprod.lift (F.map prod.fst) (F.map prod.snd)\n\n@[simp, reassoc]\nlemma prod_comparison_fst :\n  prod_comparison F A B ≫ prod.fst = F.map prod.fst :=\nprod.lift_fst _ _\n\n@[simp, reassoc]\nlemma prod_comparison_snd :\n  prod_comparison F A B ≫ prod.snd = F.map prod.snd :=\nprod.lift_snd _ _\n\n/-- Naturality of the prod_comparison morphism in both arguments. -/\n@[reassoc] lemma prod_comparison_natural (f : A ⟶ A') (g : B ⟶ B') :\n  F.map (prod.map f g) ≫ prod_comparison F A' B' =\n    prod_comparison F A B ≫ prod.map (F.map f) (F.map g) :=\nbegin\n  rw [prod_comparison, prod_comparison, prod.lift_map, ← F.map_comp, ← F.map_comp,\n      prod.comp_lift, ← F.map_comp, prod.map_fst, ← F.map_comp, prod.map_snd]\nend\n\n/--\nThe product comparison morphism from `F(A ⨯ -)` to `FA ⨯ F-`, whose components are given by\n`prod_comparison`.\n-/\n@[simps]\ndef prod_comparison_nat_trans [has_binary_products C] [has_binary_products D]\n  (F : C ⥤ D) (A : C) :\n  prod.functor.obj A ⋙ F ⟶ F ⋙ prod.functor.obj (F.obj A) :=\n{ app := λ B, prod_comparison F A B,\n  naturality' := λ B B' f, by simp [prod_comparison_natural] }\n\n@[reassoc]\nlemma inv_prod_comparison_map_fst [is_iso (prod_comparison F A B)] :\n  inv (prod_comparison F A B) ≫ F.map prod.fst = prod.fst :=\nby simp [is_iso.inv_comp_eq]\n\n@[reassoc]\nlemma inv_prod_comparison_map_snd [is_iso (prod_comparison F A B)] :\n  inv (prod_comparison F A B) ≫ F.map prod.snd = prod.snd :=\nby simp [is_iso.inv_comp_eq]\n\n/-- If the product comparison morphism is an iso, its inverse is natural. -/\n@[reassoc]\nlemma prod_comparison_inv_natural (f : A ⟶ A') (g : B ⟶ B')\n  [is_iso (prod_comparison F A B)] [is_iso (prod_comparison F A' B')] :\n  inv (prod_comparison F A B) ≫ F.map (prod.map f g) =\n    prod.map (F.map f) (F.map g) ≫ inv (prod_comparison F A' B') :=\nby rw [is_iso.eq_comp_inv, category.assoc, is_iso.inv_comp_eq, prod_comparison_natural]\n\n/--\nThe natural isomorphism `F(A ⨯ -) ≅ FA ⨯ F-`, provided each `prod_comparison F A B` is an\nisomorphism (as `B` changes).\n-/\n@[simps {rhs_md := semireducible}]\ndef prod_comparison_nat_iso [has_binary_products C] [has_binary_products D]\n  (A : C) [∀ B, is_iso (prod_comparison F A B)] :\n  prod.functor.obj A ⋙ F ≅ F ⋙ prod.functor.obj (F.obj A) :=\n{ hom := prod_comparison_nat_trans F A\n  ..(@as_iso _ _ _ _ _ (nat_iso.is_iso_of_is_iso_app ⟨_, _⟩)) }\n\nend prod_comparison\n\nsection coprod_comparison\n\nvariables {C} {D : Type u₂} [category.{v} D]\nvariables (F : C ⥤ D) {A A' B B' : C}\nvariables [has_binary_coproduct A B] [has_binary_coproduct A' B']\nvariables [has_binary_coproduct (F.obj A) (F.obj B)] [has_binary_coproduct (F.obj A') (F.obj B')]\n/--\nThe coproduct comparison morphism.\n\nIn `category_theory/limits/preserves` we show\nthis is always an iso iff F preserves binary coproducts.\n-/\ndef coprod_comparison (F : C ⥤ D) (A B : C)\n  [has_binary_coproduct A B] [has_binary_coproduct (F.obj A) (F.obj B)] :\n  F.obj A ⨿ F.obj B ⟶ F.obj (A ⨿ B) :=\ncoprod.desc (F.map coprod.inl) (F.map coprod.inr)\n\n@[simp, reassoc]\nlemma coprod_comparison_inl :\n  coprod.inl ≫ coprod_comparison F A B  = F.map coprod.inl :=\ncoprod.inl_desc _ _\n\n@[simp, reassoc]\n\n\n/-- Naturality of the coprod_comparison morphism in both arguments. -/\n@[reassoc] lemma coprod_comparison_natural (f : A ⟶ A') (g : B ⟶ B') :\n  coprod_comparison F A B ≫ F.map (coprod.map f g) =\n    coprod.map (F.map f) (F.map g) ≫ coprod_comparison F A' B' :=\nbegin\n  rw [coprod_comparison, coprod_comparison, coprod.map_desc, ← F.map_comp, ← F.map_comp,\n      coprod.desc_comp, ← F.map_comp, coprod.inl_map, ← F.map_comp, coprod.inr_map]\nend\n\n/--\nThe coproduct comparison morphism from `FA ⨿ F-` to `F(A ⨿ -)`, whose components are given by\n`coprod_comparison`.\n-/\n@[simps]\ndef coprod_comparison_nat_trans [has_binary_coproducts C] [has_binary_coproducts D]\n  (F : C ⥤ D) (A : C) :\n  F ⋙ coprod.functor.obj (F.obj A) ⟶ coprod.functor.obj A ⋙ F :=\n{ app := λ B, coprod_comparison F A B,\n  naturality' := λ B B' f, by simp [coprod_comparison_natural] }\n\n@[reassoc]\nlemma map_inl_inv_coprod_comparison [is_iso (coprod_comparison F A B)] :\n  F.map coprod.inl ≫ inv (coprod_comparison F A B) = coprod.inl :=\nby simp [is_iso.inv_comp_eq]\n\n@[reassoc]\nlemma map_inr_inv_coprod_comparison [is_iso (coprod_comparison F A B)] :\n  F.map coprod.inr ≫ inv (coprod_comparison F A B) = coprod.inr :=\nby simp [is_iso.inv_comp_eq]\n\n/-- If the coproduct comparison morphism is an iso, its inverse is natural. -/\n@[reassoc]\nlemma coprod_comparison_inv_natural (f : A ⟶ A') (g : B ⟶ B')\n  [is_iso (coprod_comparison F A B)] [is_iso (coprod_comparison F A' B')] :\n  inv (coprod_comparison F A B) ≫ coprod.map (F.map f) (F.map g) =\n    F.map (coprod.map f g) ≫ inv (coprod_comparison F A' B') :=\nby rw [is_iso.eq_comp_inv, category.assoc, is_iso.inv_comp_eq, coprod_comparison_natural]\n\n/--\nThe natural isomorphism `FA ⨿ F- ≅ F(A ⨿ -)`, provided each `coprod_comparison F A B` is an\nisomorphism (as `B` changes).\n-/\n@[simps {rhs_md := semireducible}]\ndef coprod_comparison_nat_iso [has_binary_coproducts C] [has_binary_coproducts D]\n  (A : C) [∀ B, is_iso (coprod_comparison F A B)] :\n  F ⋙ coprod.functor.obj (F.obj A) ≅ coprod.functor.obj A ⋙ F :=\n{ hom := coprod_comparison_nat_trans F A\n  ..(@as_iso _ _ _ _ _ (nat_iso.is_iso_of_is_iso_app ⟨_, _⟩)) }\n\nend coprod_comparison\n\nend category_theory.limits\n\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u} [category.{v} C]\n\n/-- Auxilliary definition for `over.coprod`. -/\n@[simps]\ndef over.coprod_obj [has_binary_coproducts C] {A : C} : over A → over A ⥤ over A := λ f,\n{ obj := λ g, over.mk (coprod.desc f.hom g.hom),\n  map := λ g₁ g₂ k, over.hom_mk (coprod.map (𝟙 _) k.left) }\n\n/-- A category with binary coproducts has a functorial `sup` operation on over categories. -/\n@[simps]\ndef over.coprod [has_binary_coproducts C] {A : C} : over A ⥤ over A ⥤ over A :=\n{ obj := λ f, over.coprod_obj f,\n  map := λ f₁ f₂ k,\n  { app := λ g, over.hom_mk (coprod.map k.left (𝟙 _))\n      (by { dsimp, rw [coprod.map_desc, category.id_comp, over.w k] }),\n    naturality' := λ f g k, by ext; { dsimp, simp, }, },\n  map_id' := λ X, by ext; { dsimp, simp, },\n  map_comp' := λ X Y Z f g, by ext; { dsimp, simp, }, }.\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/limits/shapes/binary_products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6334102567576901, "lm_q1q2_score": 0.4511351706898818}}
{"text": "open Classical\n\ntheorem ex : if (fun x => x + 1) = (fun x => x + 2) then False else True := by\n  have : (fun x => x + 1) ≠ (fun x => x + 2) := by\n    intro h\n    have : 1 = 2 := congrFun h 0\n    contradiction\n  rw [if_neg this]\n  exact True.intro\n\ndef tst (x : Nat) : Bool :=\n  if 1 < 2 then true else false\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/decClassical.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.712232184238947, "lm_q2_score": 0.63341024983754, "lm_q1q2_score": 0.4511351657611282}}
{"text": "import challenge\n\n/-!\n\nThe main goal of this file is to discuss the definition of\ncondensed abelian groups which is used in this project.\n\nAs prerequisites, we also discuss continuous maps and the\ncategory of profinite sets.\n\n-/\n\nopen category_theory category_theory.limits opposite\nopen_locale liquid_tensor_experiment\n\nsection continuous_maps\n\n/-!\nThis section describes the type `C(X,Y)` of continuous maps from `X` to `Y`.\n-/\n\n/-!\nLet `X` and `Y` be topological spaces.\n-/\nvariables {X Y : Type*} [topological_space X] [topological_space Y]\n\n/-!\nAny `f : C(X,Y)` can be thought of as a function from `X` to `Y`.\n-/\nexample (f : C(X,Y)) : X → Y :=\nf\n\n/-!\nA term `f` of `C(X,Y)` is continuous, when considered as a function `X → Y`.\n-/\nexample (f : C(X,Y)) : continuous f :=\nf.continuous\n\n/-!\nConversely, any continuous function `X → Y` yields an element of `C(X,Y)`.\n-/\nexample (f : X → Y) (hf : continuous f) : C(X,Y) :=\n⟨f,hf⟩\n\nend continuous_maps\n\nsection profinite_sets\n\n/-!\nIn this section, we discuss the category of profinite sets.\n-/\n\n/-!\n`Profinite.{0}` denotes the type of profinite sets whose underlying type\nlives in `Type = Type 0`.\n-/\nexample : Type 1 := Profinite.{0}\nexample (X : Profinite.{0}) : Type := X\n\n/-!\nAny profinite set is a compact, Hausdorff, totally disconnected topological space.\n-/\nexample (X : Profinite.{0}) : topological_space X := infer_instance\nexample (X : Profinite.{0}) : compact_space X := infer_instance\nexample (X : Profinite.{0}) : t2_space X := infer_instance\nexample (X : Profinite.{0}) : totally_disconnected_space X := infer_instance\n\n/-!\nConversely, any topological space which is compact, Hausdorff and\ntotally disconnected is a profinite set.\nThe function `Profinite.of` is used to make an object of `Profinite.{0}`\nfrom such a topological space.\n-/\nexample (X : Type)\n  [topological_space X]\n  [compact_space X]\n  [t2_space X]\n  [totally_disconnected_space X] :\n  Profinite.{0} :=\nProfinite.of X\n\n/-!\n`Profinite.{0}` has a structure of a category, where morphisms are, by definition,\ncontinuous maps.\n-/\nexample (X Y : Profinite.{0}) : (X ⟶ Y : Type) = C(X,Y) :=\nrfl\n\nend profinite_sets\n\nsection proetale_topology\n\n/-!\nThis section describes the Grothendieck topology on `Profinite.{0}` which is used in\nour formalization of condensed mathematics.\nWe use the name `proetale_topology` for this Grothendieck topology.\n-/\nexample : grothendieck_topology Profinite.{0} := proetale_topology\n\n/-!\nThis example shows that the sheaf condition with respect to this Grothendieck topology,\nfor a presheaf of abelian groups on `Profinite.{0}`, is equivalent to the usual definition.\n-/\nexample\n-- Let `F` be a presheaf of abelian groups on `Profinite.{0}`.\n  (F : Profinite.{0}ᵒᵖ ⥤ Ab.{1}) :\n-- `F` is a sheaf for `proetale_topology`\n  presheaf.is_sheaf proetale_topology F\n-- if and only if the following condition holds:\n  ↔\n-- For any finite indexing type `α`,\n  ∀ (α : Fintype.{0})\n-- profinite set `B`,\n    (B : Profinite.{0})\n-- family of profinite sets `X` indexed by `α`\n    (X : α → Profinite.{0})\n-- which map to `B` with a family of maps `π`,\n    (π : Π i, X i ⟶ B)\n-- such that `π` is jointly surjective,\n    (hπ : ∀ b : B, ∃ i (x : X i), π i x = b)\n-- and all families of elements `x i : F (op (X i))`,\n    (x : Π i, F (op (X i)))\n-- which are compatible on pullbacks `X i ×_{B} X j`\n    (hx : ∀ i j : α,\n      F.map (pullback.fst : pullback (π i) (π j) ⟶ X i).op (x i) =\n      F.map (pullback.snd : pullback (π i) (π j) ⟶ X j).op (x j)),\n-- there is a unique `s : F (op B)`\n    ∃! s : F (op B),\n-- which restricts to `x i` over `X i` for all `i`.\n      ∀ i, F.map (π i).op s = x i :=\nbegin\n  rw presheaf.is_sheaf_iff_is_sheaf_forget proetale_topology F (forget _),\n  rw [is_sheaf_iff_is_sheaf_of_type, (F ⋙ forget Ab).is_proetale_sheaf_of_types_tfae.out 0 2],\n  split,\n  { intros H α, exact H _ },\n  { introsI H α _, exact H ⟨α⟩ }\nend\n\n/-!\nThe category of condensed abelian groups is denoted by `Condensed.{0} Ab.{1}`.\nAs a type, `Condensed.{0} Ab.{1}` is defined to be the type of sheaves from `mathlib`.\n-/\nexample : Condensed.{0} Ab.{1} = Sheaf proetale_topology.{0} Ab.{1} :=\nrfl\n\n/-!\nAny object of `Condensed.{0} Ab.{1}` yields a presheaf of abelian groups.\n-/\nexample (F : Condensed.{0} Ab.{1}) : Profinite.{0}ᵒᵖ ⥤ Ab.{1} :=\nF.1\n\n/-!\nThe presheaf in the example above is indeed a sheaf.\n-/\nexample (F : Condensed.{0} Ab.{1}) : presheaf.is_sheaf proetale_topology F.1 :=\nF.2\n\n/-!\nConversely, any presheaf of abelian groups on `Profinite.{0}`\n(with the correct universe parameters) which is a sheaf for `proetale_topology`\nyields an object of `Condensed.{0} Ab.{1}`.\n-/\nexample (F : Profinite.{0}ᵒᵖ ⥤ Ab.{1}) (hF : presheaf.is_sheaf proetale_topology F) :\n  Condensed.{0} Ab.{1} :=\n⟨F,hF⟩\n\nend proetale_topology\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/examples/cond.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.4511351657611282}}
{"text": "import tactic\nimport tactic.induction\nimport logic.function.iterate\n\nnoncomputable theory\nopen_locale classical\n\ninductive Expr : Type\n| K : Expr\n| S : Expr\n| M : Expr\n| app : Expr → Expr → Expr\nopen Expr\n\ninfixl ` ~ `:100 := app\n\ninstance : inhabited Expr := ⟨K⟩\n\ndef step : Expr → Expr\n| (K ~ a ~ b) := a\n| (S ~ a ~ b ~ c) := a ~ c ~ (b ~ c)\n| (M ~ K) := K\n| (M ~ S) := S\n| (M ~ a) := M ~ step a\n| (a ~ b) := step a ~ b\n| a := a\n\ndef reduces (e₁ e₂ : Expr) : Prop :=\n∃ (n : ℕ), (step^[n]) e₁ = e₂\n\nlocal infix ` > `:50 := reduces\n\n-----\n\n@[refl]\nlemma reduces.refl {a} : a > a :=\nby use [0, rfl]\n\n@[trans]\nlemma reduces.trans {a b c} (h₁ : a > b) (h₂ : b > c) : a > c :=\nbegin\n  cases h₁ with n₁ h₁, cases h₂ with n₂ h₂, use n₂ + n₁,\n  rw function.iterate_add_apply, substs h₁ h₂,\nend\n\nlemma not_reduces {a b} : ¬a > b ↔ ∀ (n : ℕ), (step^[n]) a ≠ b :=\nby simp [reduces]\n\n-----\n\ndef Expr.comb : Expr → Prop\n| (_ ~ _) := false\n| _ := true\n\nlemma term_induct {P : Expr → Prop} {a : Expr}\n  (h₁ : a.comb) (h₂ : P K) (h₃ : P S) (h₄ : P M) : P a :=\nby cases a; simp [*, Expr.comb] at *\n\nlemma reduces_iff_eq_of_step_eq_self {a b}\n  (h : step a = a) : a > b ↔ a = b :=\nbegin\n  split; intro h₁,\n  { contrapose h₁, rw not_reduces, intro n, induction n with n ih,\n    { tauto },\n    { simp [h, ih] } },\n  { subst h₁ },\nend\n\nlemma step_self_of_term {a : Expr} (h : a.comb) : step a = a :=\nby apply term_induct h; refl\n\nlemma reduces_iff_of_term {a b : Expr}\n  (h : a.comb) : a > b ↔ a = b :=\nreduces_iff_eq_of_step_eq_self (step_self_of_term h)\n\n-----\n\nlemma apps_reduce_iff_args_reduce {t f : Expr} {args : list (Expr × Expr)}\n  (h₁ : t.comb)\n  (h₂ : ∀ (p : Expr × Expr), p ∈ args → p.1 > p.2) :\n  function.uncurry (λ a b, a > t ↔ b > t)\n    (list.foldl (λ (a p : Expr × Expr), (a.1 ~ p.1, a.2 ~ p.2)) ⟨f, f⟩ args) :=\nbegin\n  let m : Expr × Expr := _,\n  change function.uncurry _ m,\n  change _ ↔ _,\n  simp_rw reduces,\n  sorry\nend\n\nlemma app_reduces_iff_arg_reduces {t f a b : Expr}\n  (h₁ : t.comb)\n  (h₂ : a > b) :\n  f ~ a > t ↔ f ~ b > t :=\nbegin\n  apply @apps_reduce_iff_args_reduce t f [(a, b)] h₁,\n  rintro p h₄, rw list.mem_singleton at h₄, subst p, exact h₂,\nend\n\n-----\n\ndef I := S ~ K ~ K\n\nlemma I_id {a} : I ~ a > a :=\n⟨2, rfl⟩\n\n-----\n\ndef Expr.mk_diff (a : Expr) : Expr :=\nK ~ a\n\nlemma mk_diff_ne {a : Expr} : a.mk_diff ≠ a :=\nby { rw Expr.mk_diff, induction' a; simp, rintro rfl, assumption }\n\n-----\n\n-- def func_coe_raw\n\n-- inductive Func : (Expr → Expr) → Expr → Prop\n-- | id : Func id I\n-- | comb {a : Expr} : a.comb → Func (λ _, a) (K ~ a)\n-- | app {f₁ f₂ : Expr → Expr} {e₁ e₂ : Expr} :\n--   Func f₁ e₁ → Func f₂ e₂ → Func (λ a, f₁ a ~ f₂ a) (S ~ e₁ ~ e₂)\n\n-- def func_coe_raw (f : Expr → Expr) : Expr :=\n-- if h : ∃ (e : Expr), Func f e then h.some else default\n\n-- lemma exi_func_coe : ∃ (f : (Expr → Expr) → Expr),\n--   (f id = I) ∧\n--   (∀ (a : Expr), a.comb → f (λ _, a) = K ~ a) ∧\n--   (∀ (g₁ g₂ : Expr → Expr), f (λ a, g₁ a ~ g₂ a) = S ~ f g₁ ~ f g₂) :=\n-- begin\n--   refine ⟨func_coe_raw, _, _, _⟩; simp_rw func_coe_raw,\n--   sorry {\n--     rw dif_pos, swap,\n--     {\n--       use I,\n--       exact Func.id,\n--     },\n--     generalize_proofs h,\n--     have h₁ := h.some_spec,\n--     induction' h₁,\n--     {\n--       refl,\n--     },\n--     {\n--       cases mk_diff_ne (congr_fun induction_eq h.some.mk_diff).symm,\n--     },\n--     {\n--       cases congr_fun induction_eq K,\n--     },\n--   },\n--   sorry {\n--     rintro a h,\n--     rw dif_pos, swap,\n--     {\n--       use K ~ a,\n--       exact Func.comb h,\n--     },\n--     generalize_proofs h₁,\n--     have h₂ := h₁.some_spec,\n--     induction' h₂,\n--     {\n--       cases congr_fun induction_eq (K ~ K),\n--       cases h,\n--     },\n--     {\n--       cases congr_fun induction_eq K,\n--       refl,\n--     },\n--     {\n--       cases congr_fun induction_eq K,\n--       cases h,\n--     },\n--   },\n--   {\n--     rintro g₁ g₂,\n--     rw dif_pos,\n--   },\n-- end\n\n-----", "meta": {"author": "user7230724", "repo": "lean-projects", "sha": "ab9a83874775efd18f8c5b867e480bae4d596b31", "save_path": "github-repos/lean/user7230724-lean-projects", "path": "github-repos/lean/user7230724-lean-projects/lean-projects-ab9a83874775efd18f8c5b867e480bae4d596b31/src/other/mink.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.63341024983754, "lm_q1q2_score": 0.4511351580231231}}
{"text": "import tableau order.lexicographic\n\nopen matrix fintype finset function pequiv partition\nvariables {m n : ℕ}\n\nlocal notation `rvec`:2000 n := matrix (fin 1) (fin n) ℚ\nlocal notation `cvec`:2000 m := matrix (fin m) (fin 1) ℚ\nlocal infix ` ⬝ `:70 := matrix.mul\nlocal postfix `ᵀ` : 1500 := transpose\n\nnamespace tableau\n\ndef pivot_col (T : tableau m n) (obj : fin m) : option (fin n) :=\noption.cases_on\n  (fin.find (λ c : fin n, T.to_matrix obj c ≠ 0 ∧ T.to_partition.colg c ∉ T.restricted\n    ∧ c ∉ T.dead))\n  (((list.fin_range n).filter (λ c : fin n, 0 < T.to_matrix obj c ∧ c ∉ T.dead)).argmin\n    T.to_partition.colg)\n  some\n\ndef to_lex (T : tableau m n) (c : fin n) (r' : fin m) : lex ℚ (fin (m + n)) :=\n(abs (T.const r' 0 / T.to_matrix r' c), T.to_partition.rowg r')\n\nlemma to_lex_le_iff (T : tableau m n) (c : fin n) (i i' : fin m) :\n  to_lex T c i ≤ to_lex T c i' ↔\n  abs (T.const i 0 / T.to_matrix i c) < abs (T.const i' 0 / T.to_matrix i' c) ∨\n    (abs (T.const i 0 / T.to_matrix i c) = abs (T.const i' 0 / T.to_matrix i' c) ∧\n    T.to_partition.rowg i ≤ T.to_partition.rowg i') :=\nprod.lex_def _ _\n\ndef pivot_row (T : tableau m n) (obj: fin m) (c : fin n) : option (fin m) :=\nlet l := (list.fin_range m).filter (λ i : fin m, obj ≠ i ∧ T.to_partition.rowg i ∈ T.restricted\n  ∧ T.to_matrix obj c / T.to_matrix i c < 0) in\nlist.argmin (to_lex T c) l\n\nlemma pivot_col_spec {T : tableau m n} {obj : fin m} {c : fin n} :\n  c ∈ pivot_col T obj → ((T.to_matrix obj c ≠ 0 ∧ T.to_partition.colg c ∉ T.restricted)\n  ∨ (0 < T.to_matrix obj c ∧ T.to_partition.colg c ∈ T.restricted)) ∧ c ∉ T.dead :=\nbegin\n  dsimp only [pivot_col],\n  cases h : fin.find (λ c : fin n, T.to_matrix obj c ≠ 0 ∧ T.to_partition.colg c ∉ T.restricted\n    ∧ c ∉ T.dead),\n  { have := not_and.1 (fin.find_eq_none_iff.1 h c) ∘ ne_of_gt,\n    simp only [list.argmin_eq_some_iff, option.mem_def, list.mem_filter, list.mem_fin_range, gt]\n      at * {contextual := tt},\n    tauto },\n  { finish [fin.find_eq_some_iff] }\nend\n\nlemma nonpos_of_lt_pivot_col {T : tableau m n} {obj : fin m} {c j : fin n}\n  (hc : c ∈ pivot_col T obj) (hcres : T.to_partition.colg c ∈ T.restricted)\n  (hdead : j ∉ T.dead) (hjc : T.to_partition.colg j < T.to_partition.colg c) :\n  T.to_matrix obj j ≤ 0 :=\nbegin\n  rw [pivot_col] at hc,\n  cases h : fin.find (λ c, T.to_matrix obj c ≠ 0 ∧ colg (T.to_partition) c ∉ T.restricted\n    ∧ c ∉ T.dead),\n  { rw h at hc,\n    refine le_of_not_lt (λ hj0, _),\n    exact not_le_of_gt hjc ((list.mem_argmin_iff.1 hc).2.1 j\n      (list.mem_filter.2 (by simp [hj0, hdead]))) },\n  { rw h at hc,\n    simp [*, fin.find_eq_some_iff] at * }\nend\n\nlemma pivot_col_eq_none_aux {T : tableau m n} {obj : fin m} (hT : T.feasible) {c : fin n} :\n  pivot_col T obj = none → c ∉ T.dead →\n  ((T.to_matrix obj c = 0 ∧ T.to_partition.colg c ∉ T.restricted)\n    ∨ (T.to_matrix obj c ≤ 0 ∧ T.to_partition.colg c ∈ T.restricted)) :=\nbegin\n  simp only [pivot_col],\n  cases h : fin.find (λ c : fin n, T.to_matrix obj c ≠ 0 ∧ T.to_partition.colg c ∉ T.restricted\n    ∧ c ∉ T.dead),\n  { simp only [list.filter_eq_nil, list.argmin_eq_none, not_and', list.mem_fin_range,\n      true_implies_iff, not_lt, fin.find_eq_none_iff, and_imp, not_not] at *,\n    assume hnonneg hdead,\n    by_cases hres : T.to_partition.colg c ∈ T.restricted; simp * at * },\n  { simp }\nend\n\nlemma pivot_col_eq_none {T : tableau m n} {obj : fin m} (hT : T.feasible)\n  (h : pivot_col T obj = none) : T.is_optimal (T.of_col 0) (T.to_partition.rowg obj) :=\nis_optimal_of_col_zero hT\n(λ j hj, begin\n  have := pivot_col_eq_none_aux hT h hj,\n  finish [lt_irrefl]\nend)\n\nlemma pivot_row_spec {T : tableau m n} {obj i : fin m} {c : fin n} :\n  i ∈ pivot_row T obj c →\n  obj ≠ i ∧ T.to_partition.rowg i ∈ T.restricted ∧\n  T.to_matrix obj c / T.to_matrix i c < 0 ∧\n  (∀ i' : fin m, obj ≠ i' → T.to_partition.rowg i' ∈ T.restricted →\n    T.to_matrix obj c / T.to_matrix i' c < 0 →\n  abs (T.const i 0 / T.to_matrix i c) ≤ abs (T.const i' 0 / T.to_matrix i' c)) :=\nbegin\n  simp only [list.mem_filter, pivot_row, option.mem_def,\n    list.argmin_eq_some_iff, list.mem_fin_range, true_and, and_imp],\n  simp only [to_lex_le_iff],\n  intros hor hres hr0 h _,\n  simp only [*, true_and, ne.def, not_false_iff],\n  intros i' hoi' hres' hi0',\n  cases h i' hoi' hres' hi0',\n  { exact le_of_lt (by assumption) },\n  { exact le_of_eq (by tauto) }\nend\n\nlemma nonneg_of_lt_pivot_row {T : tableau m n} {obj : fin m} {i i' : fin m} {c : fin n}\n  (hc0 : 0 < T.to_matrix obj c) (hres : T.to_partition.rowg i' ∈ T.restricted)\n  (hc : c ∈ pivot_col T obj) (hrow : i ∈ pivot_row T obj c)\n  (hconst : T.const i' 0 = 0)\n  (hjc : T.to_partition.rowg i' < T.to_partition.rowg i) :\n  0 ≤ T.to_matrix i' c :=\nif hobj : obj = i' then le_of_lt $ hobj ▸ hc0\nelse\nle_of_not_gt $ λ hic, not_le_of_lt hjc\nbegin\n  have := (list.argmin_eq_some_iff.1 hrow).2.1 i'\n    (list.mem_filter.2 ⟨list.mem_fin_range _, hobj, hres, div_neg_of_pos_of_neg hc0 hic⟩),\n  simp [hconst, not_lt_of_ge (abs_nonneg _), *, to_lex_le_iff] at *\nend\n\nlemma ne_zero_of_mem_pivot_row {T : tableau m n} {obj i : fin m} {c : fin n}\n  (hrow : i ∈ pivot_row T obj c) : T.to_matrix i c ≠ 0 :=\nassume hrc, by simpa [lt_irrefl, hrc] using pivot_row_spec hrow\n\nlemma ne_zero_of_mem_pivot_col {T : tableau m n} {obj : fin m} {c : fin n}\n  (hc : c ∈ pivot_col T obj) : T.to_matrix obj c ≠ 0 :=\nλ h, by simpa [h, lt_irrefl] using pivot_col_spec hc\n\nlemma pivot_row_eq_none_aux {T : tableau m n} {obj : fin m} {c : fin n}\n  (hrow : pivot_row T obj c = none) (hs : c ∈ pivot_col T obj) :\n  ∀ i, obj ≠ i → T.to_partition.rowg i ∈ T.restricted → 0 ≤ T.to_matrix obj c / T.to_matrix i c :=\nby simpa [pivot_row, list.filter_eq_nil] using hrow\n\nlemma pivot_row_eq_none {T : tableau m n} {obj : fin m} {c : fin n} (hT : T.feasible)\n  (hrow : pivot_row T obj c = none) (hs : c ∈ pivot_col T obj) :\n  T.is_unbounded_above (T.to_partition.rowg obj) :=\nhave hrow : ∀ i, obj ≠ i → T.to_partition.rowg i ∈ T.restricted →\n    0 ≤ T.to_matrix obj c / T.to_matrix i c,\n  from pivot_row_eq_none_aux hrow hs,\nhave hc : ((T.to_matrix obj c ≠ 0 ∧ T.to_partition.colg c ∉ T.restricted)\n    ∨ (0 < T.to_matrix obj c ∧ T.to_partition.colg c ∈ T.restricted)) ∧ c ∉ T.dead,\n  from pivot_col_spec hs,\nhave hToc : T.to_matrix obj c ≠ 0, from λ h, by simpa [h, lt_irrefl] using hc,\n(lt_or_gt_of_ne hToc).elim\n  (λ hToc : T.to_matrix obj c < 0, is_unbounded_above_rowg_of_nonpos hT c\n    (hc.1.elim and.right (λ h, (not_lt_of_gt hToc h.1).elim)) hc.2\n    (λ i hi, classical.by_cases\n      (λ hoi : obj = i, le_of_lt (hoi ▸ hToc))\n      (λ hoi : obj ≠ i, inv_nonpos.1 $ nonpos_of_mul_nonneg_right (hrow _ hoi hi) hToc))\n    hToc)\n  (λ hToc : 0 < T.to_matrix obj c, is_unbounded_above_rowg_of_nonneg hT c\n    (λ i hi, classical.by_cases\n      (λ hoi : obj = i, le_of_lt (hoi ▸ hToc))\n      (λ hoi : obj ≠ i, inv_nonneg.1 $ nonneg_of_mul_nonneg_left (hrow _ hoi hi) hToc))\n    hc.2 hToc)\n\ndef feasible_of_mem_pivot_row_and_col {T : tableau m n} {obj : fin m} (hT : T.feasible) {c}\n  (hc : c ∈ pivot_col T obj) {i} (hr : i ∈ pivot_row T obj c) :\n  feasible (T.pivot i c) :=\nbegin\n  have := pivot_col_spec hc,\n  have := pivot_row_spec hr,\n  have := @feasible_simplex_pivot _ _ _ obj hT i c,\n  tauto\nend\n\nsection blands_rule\n\nlocal attribute [instance, priority 0] classical.dec\nvariable (obj : fin m)\n\ndef fickle (T T' : tableau m n) (v : fin (m + n)) : Prop :=\nT.to_partition.rowp v ≠ T'.to_partition.rowp v ∨\nT.to_partition.colp v ≠ T'.to_partition.colp v\n\nlemma fickle_symm {T T' : tableau m n} {v : fin (m + n)} :\n  fickle T T' v ↔ fickle T' T v :=\nby simp [fickle, eq_comm]\n\nlemma fickle_colg_iff_ne {T T' : tableau m n} {j : fin n} :\n  fickle T T' (T.to_partition.colg j) ↔\n  T.to_partition.colg j ≠ T'.to_partition.colg j :=\n⟨λ h h', h.elim (by rw [rowp_colg_eq_none, h', rowp_colg_eq_none]; simp)\n  (by rw [colp_colg, h', colp_colg]; simp),\nλ h, or.inr $ λ h', h begin\n  have : T'.to_partition.colp (T.to_partition.colg j) = some j,\n  { simpa [eq_comm] using h' },\n  rwa [← pequiv.eq_some_iff, colp_symm_eq_some_colg, option.some_inj, eq_comm] at this\nend⟩\n\nlemma fickle_rowg_iff_ne {T T' : tableau m n} {i : fin m} :\n  fickle T T' (T.to_partition.rowg i) ↔\n  T.to_partition.rowg i ≠ T'.to_partition.rowg i :=\n⟨λ h h', h.elim (by rw [rowp_rowg, h', rowp_rowg]; simp)\n  (by rw [colp_rowg_eq_none, h', colp_rowg_eq_none]; simp),\nλ h, or.inl $ λ h', h begin\n  have : T'.to_partition.rowp (T.to_partition.rowg i) = some i,\n  { simpa [eq_comm] using h' },\n  rwa [← pequiv.eq_some_iff, rowp_symm_eq_some_rowg, option.some_inj, eq_comm] at this\nend⟩\n\nlemma not_unique_row_and_unique_col {T T' : tableau m n} {i c c'}\n  (hcobj0 : 0 < T.to_matrix obj c)\n  (hc'obj0 : 0 < T'.to_matrix obj c')\n  (hrc0 : T.to_matrix i c < 0)\n  (hflat : T.flat = T'.flat)\n  (hs : T.to_partition.rowg i = T'.to_partition.colg c')\n  (hrobj : T.to_partition.rowg obj = T'.to_partition.rowg obj)\n  (hfickle : ∀ i, (fickle T T' (T.to_partition.rowg i)) → T.const i 0 = 0)\n  (hobj : T.const obj 0 = T'.const obj 0)\n  (nonpos_of_colg_eq : ∀ j, j ≠ c' →\n    T'.to_partition.colg j = T.to_partition.colg c → T'.to_matrix obj j ≤ 0)\n  (unique_col : ∀ j,\n    (fickle T' T (T'.to_partition.colg j)) → j ≠ c' → T'.to_matrix obj j ≤ 0)\n  (unique_row : ∀ i' ≠ i, T.const i' 0 = 0 → fickle T T' (T.to_partition.rowg i') →\n    0 ≤ T.to_matrix i' c) :\n  false :=\nlet objr := T.to_partition.rowg obj in\nlet x := λ y : ℚ, T.of_col (y • (single c 0).to_matrix) in\nhave hxflatT' : ∀ {y}, x y ∈ flat T', from hflat ▸ λ _, of_col_mem_flat _ _,\nhave hxrow : ∀ y i, x y (T.to_partition.rowg i) 0 = T.const i 0 + y * T.to_matrix i c,\n  by simp [x, of_col_single_rowg],\nhave hxcol : ∀ {y j}, j ≠ c → x y (T.to_partition.colg j) 0 = 0,\n  from λ y j hjc, by simp [x, of_col_colg, pequiv.to_matrix, single_apply_of_ne hjc.symm],\nhave hxcolc : ∀ {y}, x y (T.to_partition.colg c) 0 = y, by simp [x, of_col_colg, pequiv.to_matrix],\nlet c_star : fin (m + n) → ℚ := λ v, option.cases_on (T'.to_partition.colp v) 0\n  (T'.to_matrix obj) in\nhave hxobj : ∀ y, x y objr 0 = T.const obj 0 + y * T.to_matrix obj c, from λ y, hxrow _ _,\nhave hgetr : ∀ {y v}, c_star v * x y v 0 ≠ 0 → (T'.to_partition.colp v).is_some,\n  from λ y v, by cases h : T'.to_partition.colp v; dsimp [c_star]; rw h; simp,\nhave c_star_eq_get : ∀ {v} (hv : (T'.to_partition.colp v).is_some),\n    c_star v = T'.to_matrix obj (option.get hv),\n  from λ v hv, by dsimp only [c_star]; conv_lhs{rw [← option.some_get hv]}; refl,\nhave hsummmn : ∀ {y}, sum univ (λ j, T'.to_matrix obj j * x y (T'.to_partition.colg j) 0) =\n    sum univ (λ v, c_star v * x y v 0),\n  from λ y, sum_bij_ne_zero (λ j _ _, T'.to_partition.colg j) (λ _ _ _, mem_univ _)\n    (λ _ _ _ _ _ _ h, T'.to_partition.injective_colg h)\n    (λ v _ h0, ⟨option.get (hgetr h0), mem_univ _,\n      by rw [← c_star_eq_get (hgetr h0)]; simpa using h0, by simp⟩)\n    (λ _ _ h0, by dsimp [c_star]; rw [colp_colg]),\nhave hgetc : ∀ {y v}, c_star v * x y v 0 ≠ 0 → v ≠ T.to_partition.colg c →\n    (T.to_partition.rowp v).is_some,\n  from λ y v, (eq_rowg_or_colg T.to_partition v).elim\n    (λ ⟨i, hi⟩, by rw [hi, rowp_rowg]; simp)\n    (λ ⟨j, hj⟩ h0 hvc,\n      by rw [hj, hxcol (mt (congr_arg T.to_partition.colg) (hvc ∘ hj.trans)), mul_zero] at h0;\n        exact (h0 rfl).elim),\nhave hsummmnn : ∀ {y}, (univ.erase (T.to_partition.colg c)).sum (λ v, c_star v * x y v 0) =\n    univ.sum (λ i, c_star (T.to_partition.rowg i) * x y (T.to_partition.rowg i) 0),\n  from λ y, eq.symm $ sum_bij_ne_zero (λ i _ _, T.to_partition.rowg i) (by simp)\n    (λ _ _ _ _ _ _ h, T.to_partition.injective_rowg h)\n    (λ v hvc h0, ⟨option.get (hgetc h0 (mem_erase.1 hvc).1), mem_univ _, by simpa using h0⟩)\n    (by intros; refl),\nhave hsumm : ∀ {y}, univ.sum (λ i, c_star (T.to_partition.rowg i) * x y (T.to_partition.rowg i) 0) =\n    univ.sum (λ i, c_star (T.to_partition.rowg i) * T.const i 0) +\n    y * univ.sum (λ i, c_star (T.to_partition.rowg i) * T.to_matrix i c),\n  from λ y, by simp only [hxrow, mul_add, add_mul, sum_add_distrib, mul_assoc,\n    mul_left_comm _ y, mul_sum.symm],\nhave hxobj' : ∀ y, x y objr 0 = univ.sum (λ v, c_star v * x y v 0) + T'.const obj 0,\n  from λ y, by dsimp [objr]; rw [hrobj, mem_flat_iff.1 hxflatT', hsummmn],\nhave hy : ∀ {y}, y * T.to_matrix obj c = c_star (T.to_partition.colg c) * y +\n    univ.sum (λ i, c_star (T.to_partition.rowg i) * T.const i 0) +\n      y * univ.sum (λ i, c_star (T.to_partition.rowg i) * T.to_matrix i c),\n  from λ y, by rw [← add_left_inj (T.const obj 0), ← hxobj, hxobj',\n    ← insert_erase (mem_univ (T.to_partition.colg c)), sum_insert (not_mem_erase _ _),\n    hsummmnn, hobj, hsumm, hxcolc]; simp,\nhave hy' : ∀ (y), y * (T.to_matrix obj c - c_star (T.to_partition.colg c) -\n    univ.sum (λ i, c_star (T.to_partition.rowg i) * T.to_matrix i c)) =\n    univ.sum (λ i, c_star (T.to_partition.rowg i) * T.const i 0),\n  from λ y, by rw [mul_sub, mul_sub, hy]; simp [mul_comm, mul_assoc, mul_left_comm],\nhave h0 : T.to_matrix obj c - c_star (T.to_partition.colg c) -\n    univ.sum (λ i, c_star (T.to_partition.rowg i) * T.to_matrix i c) = 0,\n  by rw [← (domain.mul_left_inj (@one_ne_zero ℚ _)), hy', ← hy' 0, zero_mul, mul_zero],\nhave hcolnec' : T'.to_partition.colp (T.to_partition.colg c) ≠ some c',\n  from λ h,\n    by simpa [hs.symm] using congr_arg T'.to_partition.colg (option.eq_some_iff_get_eq.1 h).snd,\nhave eq_of_roweqc' : ∀ {i'}, T'.to_partition.colp (T.to_partition.rowg i') = some c' → i' = i,\n  from λ i' h, by simpa [hs.symm, T.to_partition.injective_rowg.eq_iff] using\n    congr_arg T'.to_partition.colg (option.eq_some_iff_get_eq.1 h).snd,\nhave sumpos : 0 < univ.sum (λ i, c_star (T.to_partition.rowg i) * T.to_matrix i c),\n  by rw [← sub_eq_zero.1 h0]; exact add_pos_of_pos_of_nonneg hcobj0\n    (begin\n      simp only [c_star, neg_nonneg],\n      cases h : T'.to_partition.colp (T.to_partition.colg c) with j,\n      { refl },\n      { exact nonpos_of_colg_eq j (mt (congr_arg some) (h ▸ hcolnec'))\n          (by rw [← (option.eq_some_iff_get_eq.1 h).snd]; simp) }\n    end),\nhave hexi : ∃ i', 0 < c_star (T.to_partition.rowg i') * T.to_matrix i' c,\n  from imp_of_not_imp_not _ _ (by simpa using @sum_nonpos _ _ (@univ (fin m) _)\n    (λ i', c_star (T.to_partition.rowg i') * T.to_matrix i' c) _ _) sumpos,\nlet ⟨i', hi'⟩ := hexi in\nhave hi'0 : T.const i' 0 = 0, from hfickle i'\n  (fickle_rowg_iff_ne.2 $\n    λ h, by dsimp [c_star] at hi'; rw [h, colp_rowg_eq_none] at hi'; simpa [lt_irrefl] using hi'),\nhave hi'_some : (T'.to_partition.colp (T.to_partition.rowg i')).is_some,\n  from option.ne_none_iff_is_some.1 (λ h, by dsimp only [c_star] at hi'; rw h at hi';\n    simpa [lt_irrefl] using hi'),\nhave hi' : 0 < T'.to_matrix obj (option.get hi'_some) * T.to_matrix i' c,\n  by dsimp only [c_star] at hi'; rwa [← option.some_get hi'_some] at hi',\nhave hii : i' ≠ i, from λ hir, begin\n    have : option.get hi'_some = c', from T'.to_partition.injective_colg\n      (by rw [colg_get_colp_symm, ← hs, hir]),\n    rw [this, hir] at hi',\n    exact not_lt_of_gt hi' (mul_neg_of_pos_of_neg hc'obj0 hrc0)\n  end,\nhave hnec' : option.get hi'_some ≠ c',\n  from λ eq_c', hii $ @eq_of_roweqc' i' (eq_c' ▸ by simp),\nhave hic0 : T.to_matrix i' c < 0,\n  from neg_of_mul_pos_right hi' (unique_col _\n    (by rw [fickle_colg_iff_ne]; simp) hnec'),\nnot_le_of_gt hic0 (unique_row _ hii hi'0\n  (by rw [fickle_rowg_iff_ne, ← colg_get_colp_symm _ _ hi'_some]; exact colg_ne_rowg _ _ _))\n\ninductive rel : tableau m n → tableau m n → Prop\n| pivot : ∀ {T}, feasible T → ∀ {i c}, c ∈ pivot_col T obj →\n  i ∈ pivot_row T obj c → rel (T.pivot i c) T\n| trans_pivot : ∀ {T₁ T₂ i c}, rel T₁ T₂ → c ∈ pivot_col T₁ obj →\n  i ∈ pivot_row T₁ obj c → rel (T₁.pivot i c) T₂\n\nlemma feasible_of_rel_right {T T' : tableau m n} (h : rel obj T' T) : T.feasible :=\nrel.rec_on h (by tauto) (by tauto)\n\nlemma feasible_of_rel_left {T T' : tableau m n} (h : rel obj T' T) : T'.feasible :=\nrel.rec_on h (λ _ hT _ _ hc hr, feasible_of_mem_pivot_row_and_col hT hc hr)\n  (λ _ _ _ _ _ hc hr hT, feasible_of_mem_pivot_row_and_col hT hc hr)\n\n/-- Slightly stronger recursor than the default recursor -/\n@[elab_as_eliminator]\nlemma rel.rec_on' {obj : fin m} {C : tableau m n → tableau m n → Prop} {T T' : tableau m n}\n  (hrel : rel obj T T')\n  (hpivot : ∀ {T : tableau m n} {i : fin m} {c : fin n},\n     feasible T → c ∈ pivot_col T obj → i ∈ pivot_row T obj c → C (pivot T i c) T)\n  (hpivot_trans : ∀ {T₁ T₂ : tableau m n} {i : fin m} {c : fin n},\n    rel obj (T₁.pivot i c) T₁ → rel obj T₁ T₂ →\n     c ∈ pivot_col T₁ obj →\n     i ∈ pivot_row T₁ obj c → C (T₁.pivot i c) T₁ → C T₁ T₂ → C (pivot T₁ i c) T₂) :\n  C T T' :=\nrel.rec_on hrel (λ T hT i c  hc hr, hpivot hT hc hr) (λ T₁ T₂ i c hrelT₁₂ hc hr ih, hpivot_trans\n  (rel.pivot (feasible_of_rel_left obj hrelT₁₂) hc hr) hrelT₁₂ hc hr\n  (hpivot (feasible_of_rel_left obj hrelT₁₂) hc hr) ih)\n\nlemma rel.trans {obj : fin m} {T₁ T₂ T₃ : tableau m n} (h₁₂ : rel obj T₁ T₂) :\n  rel obj T₂ T₃ → rel obj T₁ T₃ :=\nrel.rec_on h₁₂\n  (λ T i c hT hc hr hrelT, rel.trans_pivot hrelT hc hr)\n  (λ T₁ T₂ i c hrelT₁₂ hc hr ih hrelT₂₃, rel.trans_pivot (ih hrelT₂₃) hc hr)\n\ninstance : is_trans (tableau m n) (rel obj) := ⟨@rel.trans _ _ obj⟩\n\nlemma flat_eq_of_rel {T T' : tableau m n} (h : rel obj T' T) : flat T' = flat T :=\nrel.rec_on' h (λ _ _ _ _ _ hr, flat_pivot (ne_zero_of_mem_pivot_row hr))\n  (λ _ _ _ _ _ _ _ _, eq.trans)\n\nlemma rowg_obj_eq_of_rel {T T' : tableau m n} (h : rel obj T T') : T.to_partition.rowg obj =\n  T'.to_partition.rowg obj :=\nrel.rec_on' h (λ T i c hfT hc hr, by simp [rowg_swap_of_ne _ (pivot_row_spec hr).1])\n  (λ _ _ _ _ _ _ _ _, eq.trans)\n\nlemma restricted_eq_of_rel {T T' : tableau m n} (h : rel obj T T') : T.restricted = T'.restricted :=\nrel.rec_on' h (λ _ _ _ _ _ _, rfl) (λ _ _ _ _ _ _ _ _, eq.trans)\n\nlemma dead_eq_of_rel {T T' : tableau m n} (h : rel obj T T') : T.dead = T'.dead :=\nrel.rec_on' h (λ _ _ _ _ _ _, rfl) (λ _ _ _ _ _ _ _ _, eq.trans)\n\nlemma dead_eq_of_rel_or_eq {T T' : tableau m n} (h : T = T' ∨ rel obj T T') : T.dead = T'.dead :=\nh.elim (congr_arg _) $ dead_eq_of_rel _\n\nlemma exists_mem_pivot_row_col_of_rel {T T' : tableau m n} (h : rel obj T' T) :\n  ∃ i c, c ∈ pivot_col T obj ∧ i ∈ pivot_row T obj c :=\nrel.rec_on' h (λ _ i c _ hc hr, ⟨i, c, hc, hr⟩) (λ _ _ _ _ _ _ _ _ _, id)\n\nlemma exists_mem_pivot_row_of_rel {T T' : tableau m n} (h : rel obj T' T) {c : fin n}\n  (hc : c ∈ pivot_col T obj) : ∃ i, i ∈ pivot_row T obj c :=\nlet ⟨i, c', hc', hr⟩ := exists_mem_pivot_row_col_of_rel obj h in ⟨i, by simp * at *⟩\n\nlemma exists_mem_pivot_col_of_fickle {T₁ T₂ : tableau m n} (h : rel obj T₂ T₁) {c : fin n} :\n  fickle T₁ T₂ (T₁.to_partition.colg c) →\n  ∃ T₃, (T₃ = T₁ ∨ rel obj T₃ T₁) ∧ (rel obj T₂ T₃) ∧\n  T₃.to_partition.colg c = T₁.to_partition.colg c ∧\n  c ∈ pivot_col T₃ obj :=\nrel.rec_on' h begin\n    assume T i c' hT hc' hr,\n    rw fickle_colg_iff_ne,\n    by_cases hcc : c = c',\n    { subst hcc,\n      exact λ _, ⟨T, or.inl rfl, rel.pivot hT hc' hr, rfl, hc'⟩ },\n    { simp [colg_swap_of_ne _ hcc] }\n  end\n  (λ T₁ T₂ i c hrelp₁ hrel₁₂ hc hr ihp₁ ih₁₂,\n    (imp_iff_not_or.1 ih₁₂).elim\n      (λ ih₁₂, (imp_iff_not_or.1 ihp₁).elim\n        (λ ihp₁ hf, (fickle_colg_iff_ne.1 hf (by simp [*, fickle_colg_iff_ne] at *)).elim)\n        (λ ⟨T₃, hT₃⟩ hf, ⟨T₃,\n          hT₃.1.elim (λ h, h.symm ▸ or.inr hrel₁₂) (λ h, or.inr $ h.trans hrel₁₂),\n          hT₃.2.1, hT₃.2.2.1.trans (by simpa [eq_comm, fickle_colg_iff_ne] using ih₁₂), hT₃.2.2.2⟩))\n      (λ ⟨T₃, hT₃⟩ hf, ⟨T₃, hT₃.1, hrelp₁.trans hT₃.2.1, hT₃.2.2⟩))\n\nlemma exists_mem_pivot_row_of_fickle {T₁ T₂ : tableau m n} (h : rel obj T₂ T₁) (i : fin m) :\n  fickle T₁ T₂ (T₁.to_partition.rowg i) →\n  ∃ (T₃ : tableau m n) c, (T₃ = T₁ ∨ rel obj T₃ T₁) ∧ (rel obj T₂ T₃) ∧\n    T₃.to_partition.rowg i = T₁.to_partition.rowg i ∧\n    c ∈ pivot_col T₃ obj ∧ i ∈ pivot_row T₃ obj c :=\nrel.rec_on' h\n  begin\n    assume T i' c hT hc hi',\n    rw fickle_rowg_iff_ne,\n    by_cases hii : i = i',\n    { subst hii,\n      exact λ _, ⟨T, c, or.inl rfl, rel.pivot hT hc hi', rfl, hc, hi'⟩ },\n    { simp [rowg_swap_of_ne _ hii] }\n  end\n  (λ T₁ T₂ i c hrelp₁ hrel₁₂ hc hrow ihp₁ ih₁₂,\n    (imp_iff_not_or.1 ih₁₂).elim\n      (λ ih₁₂, (imp_iff_not_or.1 ihp₁).elim\n        (λ ihp₁ hf, (fickle_rowg_iff_ne.1 hf (by simp [*, fickle_rowg_iff_ne] at *)).elim)\n        (λ ⟨T₃, c', hT₃⟩ hf, ⟨T₃, c', hT₃.1.elim (λ h, h.symm ▸ or.inr hrel₁₂)\n          (λ h, or.inr $ h.trans hrel₁₂),\n            hT₃.2.1,\n            hT₃.2.2.1.trans (by simpa [eq_comm, fickle_rowg_iff_ne] using ih₁₂),\n            by clear_aux_decl; tauto⟩))\n      (λ ⟨T₃, c', hT₃⟩ _, ⟨T₃, c', hT₃.1,\n        (rel.pivot (feasible_of_rel_left _ hrel₁₂) hc hrow).trans hT₃.2.1, hT₃.2.2⟩))\n\nlemma eq_or_rel_pivot_of_rel {T₁ T₂ : tableau m n} (h : rel obj T₁ T₂) : ∀ {i j}\n  (hcol : j ∈ pivot_col T₂ obj) (hrow : i ∈ pivot_row T₂ obj j),\n  T₁ = T₂.pivot i j ∨ rel obj T₁ (T₂.pivot i j) :=\nrel.rec_on' h (λ T i c hT hc hr r' c' hc' hr', by simp * at *)\n  (λ T₁ T₂ i c hrelp₁ hrel₁₂ hc hr ihp₁ ih₁₂ r' c' hc' hr',\n    (ih₁₂ hc' hr').elim\n      (λ ih₁₂, or.inr $ ih₁₂ ▸ rel.pivot (feasible_of_rel_left _ hrel₁₂) hc hr)\n      (λ ih₁₂, or.inr $ (rel.pivot (feasible_of_rel_left _ hrel₁₂) hc hr).trans ih₁₂))\n\nlemma exists_mem_pivot_col_of_mem_pivot_row {T : tableau m n} (hrelTT : rel obj T T)\n  {i c} (hc : c ∈ pivot_col T obj) (hrow : i ∈ pivot_row T obj c) :\n  ∃ (T' : tableau m n), c ∈ pivot_col T' obj ∧ T'.to_partition.colg c =\n  T.to_partition.rowg i ∧ rel obj T' T ∧ rel obj T T' :=\nhave hrelTTp : rel obj T (T.pivot i c),\n  from (eq_or_rel_pivot_of_rel _ hrelTT hc hrow).elim (λ h, h ▸ hrelTT ) id,\nlet ⟨T', hT'⟩ := exists_mem_pivot_col_of_fickle obj hrelTTp $ fickle_colg_iff_ne.2 $\n  (show (T.pivot i c).to_partition.colg c ≠ T.to_partition.colg c, by simp) in\n⟨T', hT'.2.2.2, by simp [hT'.2.2.1], hT'.1.elim\n  (λ h, h.symm ▸ rel.pivot (feasible_of_rel_left _ hrelTT) hc hrow)\n  (λ h, h.trans $ rel.pivot (feasible_of_rel_left _ hrelTT) hc hrow), hT'.2.1⟩\n\nlemma exists_mem_pivot_col_of_fickle_row {T T' : tableau m n} (hrelTT' : rel obj T T') {i : fin m}\n  (hrelT'T : rel obj T' T) (hrow : fickle T T' (T.to_partition.rowg i)) :\n  ∃ (T₃ : tableau m n) c, c ∈ pivot_col T₃ obj ∧ T₃.to_partition.colg c =\n  T.to_partition.rowg i ∧ rel obj T₃ T ∧ rel obj T T₃ :=\nlet ⟨T₃, c, hT₃, hrelT₃T, hrow₃, hc, hr⟩ :=\n  exists_mem_pivot_row_of_fickle obj hrelT'T _ hrow in\nlet ⟨T₄, hT₄⟩ := exists_mem_pivot_col_of_mem_pivot_row obj\n  (show rel obj T₃ T₃, from hT₃.elim (λ h, h.symm ▸ hrelTT'.trans hrelT'T)\n    (λ h, h.trans $ hrelTT'.trans hrelT₃T)) hc hr in\n⟨T₄, c, hT₄.1, hT₄.2.1.trans hrow₃, hT₄.2.2.1.trans $ hT₃.elim (λ h, h.symm ▸ hrelTT'.trans hrelT'T)\n  (λ h, h.trans $ hrelTT'.trans hrelT'T), hrelTT'.trans (hrelT₃T.trans hT₄.2.2.2)⟩\n\nlemma const_obj_le_of_rel {T₁ T₂ : tableau m n} (h : rel obj T₁ T₂) :\n  T₂.const obj 0 ≤ T₁.const obj 0 :=\nrel.rec_on' h (λ T i c hT hc hr,\n    have hr' : _ := pivot_row_spec hr,\n    simplex_const_obj_le hT (by tauto) (by tauto))\n  (λ _ _ _ _ _ _ _ _ h₁ h₂, le_trans h₂ h₁)\n\nlemma const_obj_eq_of_rel_of_rel {T₁ T₂ : tableau m n} (h₁₂ : rel obj T₁ T₂)\n  (h₂₁ : rel obj T₂ T₁) : T₁.const obj 0 = T₂.const obj 0 :=\nle_antisymm (const_obj_le_of_rel _ h₂₁) (const_obj_le_of_rel _ h₁₂)\n\nlemma const_eq_const_of_const_obj_eq {T₁ T₂ : tableau m n} (h₁₂ : rel obj T₁ T₂) :\n  ∀ (hobj : T₁.const obj 0 = T₂.const obj 0) (i : fin m), T₁.const i 0 = T₂.const i 0 :=\nrel.rec_on' h₁₂\n  (λ T i c hfT hc hrow hobj i',\n    have hr0 : T.const i 0 = 0, from const_eq_zero_of_const_obj_eq hfT\n      (ne_zero_of_mem_pivot_col hc) (ne_zero_of_mem_pivot_row hrow)\n      (pivot_row_spec hrow).1 hobj,\n    if hii : i' = i\n      then by simp [hii, hr0]\n      else by simp [const_pivot_of_ne _ hii, hr0])\n  (λ T₁ T₂ i c hrelp₁ hrel₁₂ hc hr ihp₁ ih₁₂ hobj i',\n    have hobjp : (pivot T₁ i c).const obj 0 = T₁.const obj 0,\n      from le_antisymm (hobj.symm ▸ const_obj_le_of_rel _ hrel₁₂)\n        (const_obj_le_of_rel _ hrelp₁),\n    by rw [ihp₁ hobjp, ih₁₂ (hobjp.symm.trans hobj)])\n\nlemma const_eq_zero_of_fickle_of_rel_self {T T' : tableau m n} (hrelTT' : rel obj T T')\n  (hrelT'T : rel obj T' T) (i : fin m) (hrow : fickle T T' (T.to_partition.rowg i)) :\n  T.const i 0 = 0 :=\nlet ⟨T₃, c, hT₃₁, hT'₃, hrow₃, hc, hi⟩ := exists_mem_pivot_row_of_fickle obj hrelT'T _ hrow in\nhave T₃.const i 0 = 0, from const_eq_zero_of_const_obj_eq\n  (feasible_of_rel_right _ hT'₃) (ne_zero_of_mem_pivot_col hc)\n  (ne_zero_of_mem_pivot_row hi) (pivot_row_spec hi).1\n  (const_obj_eq_of_rel_of_rel _ (rel.pivot (feasible_of_rel_right _ hT'₃) hc hi)\n    ((eq_or_rel_pivot_of_rel _ hT'₃ hc hi).elim\n      (λ h, h ▸ hT₃₁.elim (λ h, h.symm ▸ hrelTT') (λ h, h.trans hrelTT'))\n      (λ hrelT'p, hT₃₁.elim (λ h, h.symm ▸ hrelTT'.trans (h ▸ hrelT'p))\n        (λ h, h.trans $ hrelTT'.trans hrelT'p)))),\nhave hobj : T₃.const obj 0 = T.const obj 0,\n  from hT₃₁.elim (λ h, h ▸ rfl) (λ h, const_obj_eq_of_rel_of_rel _ h (hrelTT'.trans hT'₃)),\nhT₃₁.elim (λ h, h ▸ this) (λ h, const_eq_const_of_const_obj_eq obj h hobj i ▸ this)\n\nlemma colg_mem_restricted_of_rel_self {T : tableau m n} (hrelTT : rel obj T T)\n  {c} (hc : c ∈ pivot_col T obj) : T.to_partition.colg c ∈ T.restricted :=\nlet ⟨i, hrow⟩ := exists_mem_pivot_row_of_rel obj hrelTT hc in\nlet ⟨T', c', hT', hrelTT', hrowcol, _, hi'⟩ := exists_mem_pivot_row_of_fickle obj\n    ((eq_or_rel_pivot_of_rel _ hrelTT hc hrow).elim\n      (λ h, show rel obj T (T.pivot i c), from h ▸ hrelTT) id) _\n  (fickle_rowg_iff_ne.2 $\n    show (T.pivot i c).to_partition.rowg i ≠ T.to_partition.rowg i, by simp) in\n(restricted_eq_of_rel _ hrelTT').symm ▸ by convert (pivot_row_spec hi').2.1; simp [hrowcol]\n\nlemma eq_zero_of_not_mem_restricted_of_rel_self {T : tableau m n} (hrelTT : rel obj T T)\n  {j} (hjres : T.to_partition.colg j ∉ T.restricted) (hdead : j ∉ T.dead) : T.to_matrix obj j = 0 :=\nlet ⟨r, c, hc, hr⟩ := exists_mem_pivot_row_col_of_rel obj hrelTT in\nhave hcres : T.to_partition.colg c ∈ T.restricted,\n  from colg_mem_restricted_of_rel_self obj hrelTT hc,\nby_contradiction $ λ h0,\nbegin\n  simp [pivot_col] at hc,\n  cases h : fin.find (λ c, T.to_matrix obj c ≠ 0 ∧ colg (T.to_partition) c ∉ T.restricted\n    ∧ c ∉ T.dead),\n  { simp [*, fin.find_eq_none_iff] at * },\n  { rw h at hc, clear_aux_decl,\n    have := (fin.find_eq_some_iff.1 h).1,\n    simp * at * }\nend\n\nlemma rel.irrefl {obj : fin m} : ∀ (T : tableau m n), ¬ rel obj T T :=\nλ T1 hrelT1,\nlet ⟨iT1 , cT1, hrT1, hcT1⟩ := exists_mem_pivot_row_col_of_rel obj hrelT1 in\nlet ⟨t, ht⟩ := finset.max_of_mem\n  (show T1.to_partition.colg cT1 ∈ univ.filter (λ v, ∃ (T' : tableau m n) (c : fin n),\n      rel obj T' T' ∧ c ∈ pivot_col T' obj ∧ T'.to_partition.colg c = v),\n    by simp only [true_and, mem_filter, mem_univ, exists_and_distrib_left];\n      exact ⟨T1, hrelT1, cT1, hrT1, rfl⟩) in\nlet ⟨_, T', c', hrelTT'', hcT', hct⟩ := finset.mem_filter.1 (finset.mem_of_max ht) in\nhave htmax : ∀ (s : fin (m + n)) (T : tableau m n),\n    rel obj T T → ∀ (j : fin n), pivot_col T obj = some j →\n      T.to_partition.colg j = s → s ≤ t,\n  by simpa using λ s (h : s ∈ _), finset.le_max_of_mem h ht,\nlet ⟨i, hiT'⟩ := exists_mem_pivot_row_of_rel obj hrelTT'' hcT' in\nhave hrelTT''p : rel obj T' (T'.pivot i c'),\n  from (eq_or_rel_pivot_of_rel obj hrelTT'' hcT' hiT').elim (λ h, h ▸ hrelTT'') id,\nlet ⟨T, c, hTT', hrelT'T, hT'Tr, hc, hr⟩ := exists_mem_pivot_row_of_fickle obj\n  hrelTT''p i (by rw fickle_symm; simp [fickle_colg_iff_ne]) in\nhave hfT' : feasible T', from feasible_of_rel_left _ hrelTT'',\nhave hfT : feasible T, from feasible_of_rel_right _ hrelT'T,\nhave hrelT'pT' : rel obj (T'.pivot i c') T', from rel.pivot hfT' hcT' hiT',\nhave hrelTT' : rel obj T T', from hTT'.elim (λ h, h.symm ▸ hrelT'pT') (λ h, h.trans hrelT'pT'),\nhave hrelTT : rel obj T T, from hrelTT'.trans hrelT'T,\nhave hc't : T.to_partition.colg c ≤ t, from htmax _ T hrelTT _ hc rfl,\nhave hoT'T : T'.const obj 0 = T.const obj 0, from const_obj_eq_of_rel_of_rel _ hrelT'T hrelTT',\nhave hfickle : ∀ i, fickle T T' (T.to_partition.rowg i) → T.const i 0 = 0,\n  from const_eq_zero_of_fickle_of_rel_self obj hrelTT' hrelT'T,\nhave hobj : T.const obj 0 = T'.const obj 0, from const_obj_eq_of_rel_of_rel _ hrelTT' hrelT'T,\nhave hflat : T.flat = T'.flat, from flat_eq_of_rel obj hrelTT',\nhave hrobj : T.to_partition.rowg obj = T'.to_partition.rowg obj, from rowg_obj_eq_of_rel _ hrelTT',\nhave hs : T.to_partition.rowg i = T'.to_partition.colg c', by simpa using hT'Tr,\nhave hc'res : T'.to_partition.colg c' ∈ T'.restricted,\n  from hs ▸ restricted_eq_of_rel _ hrelTT' ▸ (pivot_row_spec hr).2.1,\nhave hc'obj0 : 0 < T'.to_matrix obj c' ∧ c' ∉ T'.dead,\n  by simpa [hc'res] using pivot_col_spec hcT',\nhave hcres : T.to_partition.colg c ∈ T.restricted,\n  from colg_mem_restricted_of_rel_self obj hrelTT hc,\nhave hcobj0 : 0 < to_matrix T obj c ∧ c ∉ T.dead,\n  by simpa [hcres] using pivot_col_spec hc,\nhave hrc0 : T.to_matrix i c < 0,\n  from inv_neg'.1 $ neg_of_mul_neg_left (pivot_row_spec hr).2.2.1 (le_of_lt hcobj0.1),\nhave nonpos_of_colg_ne : ∀ j, (fickle T' T (T'.to_partition.colg j)) → j ≠ c' →\n    T'.to_matrix obj j ≤ 0,\n  from λ j hj hjc',\n    let ⟨T₃, hT₃⟩ := exists_mem_pivot_col_of_fickle obj hrelTT' hj in\n    nonpos_of_lt_pivot_col hcT' hc'res\n      (dead_eq_of_rel_or_eq obj hT₃.1 ▸ (pivot_col_spec hT₃.2.2.2).2)\n      (lt_of_le_of_ne\n        (hct.symm ▸ hT₃.2.2.1 ▸ htmax _ T₃ (hT₃.1.elim (λ h, h.symm ▸ hrelTT'')\n          (λ h, h.trans (hrelT'T.trans hT₃.2.1))) _ hT₃.2.2.2 rfl)\n        (by rwa [ne.def, T'.to_partition.injective_colg.eq_iff])),\nhave nonpos_of_colg_eq : ∀ j, j ≠ c' →\n    T'.to_partition.colg j = T.to_partition.colg c → T'.to_matrix obj j ≤ 0,\n  from λ j hjc' hj,\n    if hjc : j = c\n    then by clear_aux_decl; subst hjc;\n      exact nonpos_of_lt_pivot_col hcT' hc'res\n        (by rw [dead_eq_of_rel obj hrelT'T]; tauto)\n        (lt_of_le_of_ne (hj.symm ▸ hct.symm ▸ hc't) (by simpa))\n    else nonpos_of_colg_ne _ (fickle_colg_iff_ne.2 $ by simpa [hj, eq_comm] using hjc) hjc',\nhave unique_row : ∀ i' ≠ i, T.const i' 0 = 0 → fickle T T' (T.to_partition.rowg i') →\n    0 ≤ T.to_matrix i' c,\n  from λ i' hii hi0 hrow,\n    let ⟨T₃, c₃, hc₃, hrow₃, hrelT₃T, hrelTT₃⟩ :=\n      exists_mem_pivot_col_of_fickle_row _ hrelTT' hrelT'T hrow in\n    have hrelT₃T₃ : rel obj T₃ T₃, from hrelT₃T.trans hrelTT₃,\n    nonneg_of_lt_pivot_row (by exact hcobj0.1)\n      (by rw [← hrow₃, ← restricted_eq_of_rel _ hrelT₃T];\n        exact colg_mem_restricted_of_rel_self _ hrelT₃T₃ hc₃) hc hr hi0\n      (lt_of_le_of_ne (by rw [hs, hct, ← hrow₃]; exact htmax _ _ hrelT₃T₃ _ hc₃ rfl)\n        (by simpa [fickle_rowg_iff_ne] using hrow)),\nnot_unique_row_and_unique_col obj hcobj0.1 hc'obj0.1 hrc0 hflat hs hrobj hfickle hobj\n  nonpos_of_colg_eq nonpos_of_colg_ne unique_row\n\nnoncomputable instance fintype_rel (T : tableau m n) : fintype {T' | rel obj T' T} :=\nfintype.of_injective (λ T', T'.val.to_partition)\n  (λ T₁ T₂ h, subtype.eq $ tableau.ext\n    (by rw [flat_eq_of_rel _ T₁.2, flat_eq_of_rel _ T₂.2]) h\n    (by rw [dead_eq_of_rel _ T₁.2, dead_eq_of_rel _ T₂.2])\n    (by rw [restricted_eq_of_rel _ T₁.2, restricted_eq_of_rel _ T₂.2]))\n\nlemma rel_wf (m n : ℕ) (obj : fin m): well_founded (@rel m n obj) :=\nsubrelation.wf\n  (show subrelation (@rel m n obj) (measure (λ T, fintype.card {T' | rel obj T' T})),\n    from assume T₁ T₂ h,\n    set.card_lt_card (set.ssubset_iff_subset_not_subset.2 ⟨λ T' hT', hT'.trans h,\n      not_forall_of_exists_not ⟨T₁, λ h', rel.irrefl _ (h' h)⟩⟩))\n  (measure_wf (λ T, fintype.card {T' | rel obj T' T}))\n\nend blands_rule\n\ninductive termination (n : ℕ) : Type\n| while {}              : termination\n| unbounded (c : fin n) : termination\n| optimal {}            : termination\n\nnamespace termination\n\nlemma injective_unbounded : function.injective (@unbounded n) :=\nλ _ _ h, by injection h\n\n@[simp] lemma unbounded_inj {c c' : fin n} : unbounded c = unbounded c' ↔ c = c' :=\ninjective_unbounded.eq_iff\n\nend termination\n\nopen termination\n\ninstance {n : ℕ} : has_repr $ termination n :=\n⟨λ t, termination.cases_on t\n  \"while\"\n  (λ c, \"unbounded \" ++ repr c)\n  \"optimal\"⟩\n\nopen termination\n\n/-- The simplex algorithm -/\ndef simplex (w : tableau m n → bool) (obj : fin m) : Π (T : tableau m n) (hT : feasible T),\n  tableau m n × termination n\n| T := λ hT, cond (w T)\n  (match pivot_col T obj, @feasible_of_mem_pivot_row_and_col _ _ _ obj hT,\n      @rel.pivot m n obj _ hT with\n    | none,   hc, hrel := (T, optimal)\n    | some j, hc, hrel :=\n      match pivot_row T obj j, @hc _ rfl, (λ i, @hrel i j rfl) with\n      | none,   hrow, hrel := (T, unbounded j)\n      | some i, hrow, hrel := have wf : rel obj (pivot T i j) T, from hrel _ rfl,\n        simplex (T.pivot i j) (hrow rfl)\n      end\n    end)\n  (T, while)\nusing_well_founded {rel_tac := λ _ _, `[exact ⟨_, rel_wf m n obj⟩],\n  dec_tac := tactic.assumption}\n\nlemma simplex_pivot {w : tableau m n → bool} {T : tableau m n} (hT : feasible T)\n  (hw : w T = tt) {obj : fin m} {i : fin m} {c : fin n}\n  (hc : c ∈ pivot_col T obj) (hr : i ∈ pivot_row T obj c) :\n  (T.pivot i c).simplex w obj  (feasible_of_mem_pivot_row_and_col hT hc hr) =\n  T.simplex w obj hT  :=\nby conv_rhs { rw simplex };\n  simp [hw, show _ = _, from hr, show _ = _, from hc, simplex._match_1, simplex._match_2]\n\nlemma simplex_spec_aux (w : tableau m n → bool) (obj : fin m) :\n  Π (T : tableau m n) (hT : feasible T),\n  ((T.simplex w obj hT).2 = while ∧ w (T.simplex w obj hT).1 = ff) ∨\n  ((T.simplex w obj hT).2 = optimal ∧ w (T.simplex w obj hT).1 = tt ∧\n    pivot_col (T.simplex w obj hT).1 obj = none) ∨\n  ∃ c, ((T.simplex w obj hT).2 = unbounded c ∧ w (T.simplex w obj hT).1 = tt ∧\n    c ∈ pivot_col (T.simplex w obj hT).1 obj ∧\n    pivot_row (T.simplex w obj hT).1 obj c = none)\n| T := λ hT,\n  begin\n    cases hw : w T,\n    { rw simplex, simp [hw] },\n    { cases hc : pivot_col T obj with c,\n      { rw simplex, simp [hc, hw, simplex._match_1] },\n      { cases hrow : pivot_row T obj c with i,\n        { rw simplex,\n          simp [hrow, hc, hw, simplex._match_1, simplex._match_2] },\n        { rw [← simplex_pivot hT hw hc hrow],\n          exact have wf : rel obj (T.pivot i c) T, from rel.pivot hT hc hrow,\n            simplex_spec_aux _ _ } } }\n  end\nusing_well_founded {rel_tac := λ _ _, `[exact ⟨_, rel_wf m n obj⟩],\n  dec_tac := tactic.assumption}\n\nlemma simplex_while_eq_ff {w : tableau m n → bool} {T : tableau m n} {hT : feasible T}\n  {obj : fin m} (hw : w T = ff) : T.simplex w obj hT = (T, while) :=\nby rw [simplex, hw]; refl\n\nlemma simplex_pivot_col_eq_none {w : tableau m n → bool} {T : tableau m n} {hT : feasible T}\n  (hw : w T = tt) {obj : fin m} (hc : pivot_col T obj = none) :\n  T.simplex w obj hT = (T, optimal) :=\nby rw simplex; simp [hc, hw, simplex._match_1]\n\nlemma simplex_pivot_row_eq_none {w : tableau m n → bool} {T : tableau m n} {hT : feasible T}\n  {obj : fin m} (hw : w T = tt) {c} (hc : c ∈ pivot_col T obj)\n  (hr : pivot_row T obj c = none) : T.simplex w obj hT = (T, unbounded c) :=\nby rw simplex; simp [hw, show _ = _, from hc, hr, simplex._match_1, simplex._match_2]\n\nlemma simplex_induction (P : tableau m n → Prop) (w : tableau m n → bool) (obj : fin m):\n  Π {T : tableau m n} (hT : feasible T)  (h0 : P T)\n  (hpivot : ∀ {T' i c}, w T' = tt → c ∈ pivot_col T' obj → i ∈ pivot_row T' obj c\n    → feasible T' → P T' → P (T'.pivot i c)),\n  P (T.simplex w obj hT).1\n| T := λ hT h0 hpivot,\n  begin\n    cases hw : w T,\n    { rwa [simplex_while_eq_ff hw] },\n    { cases hc : pivot_col T obj with c,\n      { rwa [simplex_pivot_col_eq_none hw hc] },\n      { cases hrow : pivot_row T obj c with i,\n        { rwa simplex_pivot_row_eq_none hw hc hrow },\n        { rw [← simplex_pivot _ hw hc hrow],\n          exact have wf : rel obj (pivot T i c) T, from rel.pivot hT hc hrow,\n            simplex_induction (feasible_of_mem_pivot_row_and_col hT hc hrow)\n              (hpivot hw hc hrow hT h0) @hpivot } } }\n  end\nusing_well_founded {rel_tac := λ _ _, `[exact ⟨_, rel_wf m n obj⟩],\n  dec_tac := `[tauto]}\n\n@[simp] lemma feasible_simplex {w : tableau m n → bool} {T : tableau m n}\n  {hT : feasible T} {obj : fin m} : feasible (T.simplex w obj hT).1 :=\nsimplex_induction feasible _ _ hT hT\n  (λ _ _ _ _ hc hr _ hT', feasible_of_mem_pivot_row_and_col hT' hc hr)\n\n@[simp] lemma simplex_simplex {w : tableau m n → bool} {T : tableau m n} {hT : feasible T}\n  {obj : fin m} : (T.simplex w obj hT).1.simplex w obj feasible_simplex = T.simplex w obj hT :=\nsimplex_induction (λ T', ∀ (hT' : feasible T'), T'.simplex w obj hT' = T.simplex w obj hT) w _ _\n  (λ _, rfl) (λ T' i c hw hc hr hT' ih hpivot, by rw [simplex_pivot hT' hw hc hr, ih]) _\n\n/-- `simplex` does not move the row variable it is trying to maximise. -/\n@[simp] lemma rowg_simplex (T : tableau m n) (hT : feasible T) (w : tableau m n → bool)\n  (obj : fin m) : (T.simplex w obj hT).1.to_partition.rowg obj = T.to_partition.rowg obj :=\nsimplex_induction (λ T', T'.to_partition.rowg obj = T.to_partition.rowg obj) _ _ _ rfl\n  (λ T' i c hw hc hr, by simp [rowg_swap_of_ne _ (pivot_row_spec hr).1])\n\n@[simp] lemma flat_simplex (T : tableau m n) (hT : feasible T) (w : tableau m n → bool)\n  (obj : fin m) : (T.simplex w obj hT).1.flat = T.flat :=\nsimplex_induction (λ T', T'.flat = T.flat) w obj _ rfl\n  (λ T' i c hw hc hr hT' ih,\n    have T'.to_matrix i c ≠ 0,\n      from λ h, by simpa [h, lt_irrefl] using pivot_row_spec hr,\n    by rw [flat_pivot this, ih])\n\n@[simp] lemma restricted_simplex (T : tableau m n) (hT : feasible T) (w : tableau m n → bool)\n  (obj : fin m) : (T.simplex w obj hT).1.restricted = T.restricted :=\nsimplex_induction (λ T', T'.restricted = T.restricted) _ _ _ rfl (by simp { contextual := tt })\n\n@[simp] lemma dead_simplex (T : tableau m n) (hT : feasible T) (w : tableau m n → bool)\n  (obj : fin m) : (T.simplex w obj hT).1.dead = T.dead :=\nsimplex_induction (λ T', T'.dead = T.dead) _ _ _ rfl (by simp { contextual := tt })\n\n@[simp] lemma res_set_simplex (T : tableau m n) (hT : feasible T) (w : tableau m n → bool)\n  (obj : fin m) : (T.simplex w obj hT).1.res_set = T.res_set :=\nsimplex_induction (λ T', T'.res_set = T.res_set) w obj _ rfl\n  (λ T' i c hw hc hr, by simp [res_set_pivot (ne_zero_of_mem_pivot_row hr)] {contextual := tt})\n\n@[simp] lemma dead_set_simplex (T : tableau m n) (hT : feasible T) (w : tableau m n → bool)\n  (obj : fin m) : (T.simplex w obj hT).1.dead_set = T.dead_set :=\nsimplex_induction (λ T', T'.dead_set = T.dead_set) w obj _ rfl\n  (λ T' i c hw hc hr,\n    by simp [dead_set_pivot (ne_zero_of_mem_pivot_row hr) (pivot_col_spec hc).2] {contextual := tt})\n\n@[simp] lemma sol_set_simplex (T : tableau m n) (hT : feasible T) (w : tableau m n → bool)\n  (obj : fin m) : (T.simplex w obj hT).1.sol_set = T.sol_set :=\nby simp [sol_set_eq_res_set_inter_dead_set]\n\n@[simp] lemma of_col_simplex_zero_mem_sol_set {w : tableau m n → bool} {T : tableau m n}\n  {hT : feasible T} {obj : fin m} : (T.simplex w obj hT).1.of_col 0 ∈ sol_set T :=\nby rw [← sol_set_simplex, of_col_zero_mem_sol_set_iff]; exact feasible_simplex\n\n@[simp] lemma of_col_simplex_rowg {w : tableau m n → bool} {T : tableau m n}\n  {hT : feasible T} {obj : fin m} (x : cvec n) :\n  (T.simplex w obj hT).1.of_col x (T.to_partition.rowg obj) =\n  ((T.simplex w obj hT).1.to_matrix ⬝ x + (T.simplex w obj hT).1.const) obj :=\nby rw [← of_col_rowg (T.simplex w obj hT).1 x obj, rowg_simplex]\n\n@[simp] lemma is_unbounded_above_simplex {T : tableau m n} {hT : feasible T} {w : tableau m n → bool}\n  {obj : fin m} {v : fin (m + n)} : is_unbounded_above (T.simplex w obj hT).1 v ↔\n  is_unbounded_above T v := by simp [is_unbounded_above]\n\n@[simp] lemma is_optimal_simplex {T : tableau m n} {hT : feasible T} {w : tableau m n → bool}\n  {obj : fin m} {x : cvec (m + n)} {v : fin (m + n)} : is_optimal (T.simplex w obj hT).1 x v ↔\n  is_optimal T x v := by simp [is_optimal]\n\nlemma termination_eq_while_iff {T : tableau m n} {hT : feasible T} {w : tableau m n → bool}\n  {obj : fin m} : (T.simplex w obj hT).2 = while ↔ w (T.simplex w obj hT).1 = ff :=\nby have := simplex_spec_aux w obj T hT; finish\n\nlemma termination_eq_optimal_iff_pivot_col_eq_none {T : tableau m n}\n  {hT : feasible T} {w : tableau m n → bool} {obj : fin m} : (T.simplex w obj hT).2 = optimal ↔\n  w (T.simplex w obj hT).1 = tt ∧ pivot_col (T.simplex w obj hT).1 obj = none :=\nby rcases simplex_spec_aux w obj T hT with _ | ⟨_, _, _⟩ | ⟨⟨_, _⟩, _, _, _, _⟩; simp * at *\n\nlemma termination_eq_unbounded_iff_pivot_row_eq_none {T : tableau m n} {hT : feasible T}\n  {w : tableau m n → bool} {obj : fin m} {c : fin n} :\n  (T.simplex w obj hT).2 = unbounded c ↔\n  w (T.simplex w obj hT).1 = tt ∧ c ∈ pivot_col (T.simplex w obj hT).1 obj ∧\n    pivot_row (T.simplex w obj hT).1 obj c = none :=\nby split; intros; rcases simplex_spec_aux w obj T hT with\n  _ | ⟨_, _, _⟩ | ⟨⟨⟨_, _⟩, _⟩, _, _, _, _⟩; simp * at *\n\nlemma unbounded_of_termination_eq_unbounded {T : tableau m n} {hT : feasible T}\n  {w : tableau m n → bool} {obj : fin m} {c : fin n} : (T.simplex w obj hT).2 = unbounded c →\n  w (T.simplex w obj hT).1 = tt ∧\n  is_unbounded_above T (T.to_partition.rowg obj) :=\nbegin\n  rw termination_eq_unbounded_iff_pivot_row_eq_none,\n  rintros ⟨_, hc⟩,\n  simpa * using pivot_row_eq_none feasible_simplex hc.2 hc.1\nend\n\nlemma termination_eq_optimal_iff {T : tableau m n} {hT : feasible T}\n  {w : tableau m n → bool} {obj : fin m} : (T.simplex w obj hT).2 = optimal ↔\n  w (T.simplex w obj hT).1 = tt ∧\n  is_optimal T ((T.simplex w obj hT).1.of_col 0) (T.to_partition.rowg obj) :=\nbegin\n  rw [termination_eq_optimal_iff_pivot_col_eq_none],\n  split,\n  { rintros ⟨_, hc⟩,\n    simpa * using pivot_col_eq_none feasible_simplex hc },\n  { cases ht : (T.simplex w obj hT).2,\n    { simp [*, termination_eq_while_iff] at * },\n    { cases unbounded_of_termination_eq_unbounded ht,\n      simp [*, not_optimal_of_unbounded_above right] },\n    { simp [*, termination_eq_optimal_iff_pivot_col_eq_none] at * } }\nend\n\nlemma termination_eq_unbounded_iff {T : tableau m n} {hT : feasible T}\n  {w : tableau m n → bool} {obj : fin m} {c : fin n}: (T.simplex w obj hT).2 = unbounded c ↔\n  w (T.simplex w obj hT).1 = tt ∧ is_unbounded_above T (T.to_partition.rowg obj)\n  ∧ c ∈ pivot_col (T.simplex w obj hT).1 obj :=\n⟨λ hc, and.assoc.1 $ ⟨unbounded_of_termination_eq_unbounded hc,\n  (termination_eq_unbounded_iff_pivot_row_eq_none.1 hc).2.1⟩,\nbegin\n  have := @not_optimal_of_unbounded_above m n (T.simplex w obj hT).1 (T.to_partition.rowg obj)\n    ((T.simplex w obj hT).1.of_col 0),\n  cases ht : (T.simplex w obj hT).2;\n  simp [termination_eq_optimal_iff, termination_eq_while_iff,\n    termination_eq_unbounded_iff_pivot_row_eq_none, *] at *\nend⟩\n\nend tableau\n", "meta": {"author": "ChrisHughes24", "repo": "LP", "sha": "e3ed64c2d1f642696104584e74ae7226d8e916de", "save_path": "github-repos/lean/ChrisHughes24-LP", "path": "github-repos/lean/ChrisHughes24-LP/LP-e3ed64c2d1f642696104584e74ae7226d8e916de/src/simplex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.450840567457823}}
{"text": "/-\nCopyright (c) 2022 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Std.Logic\nimport Std.Data.RBMap.Basic\n\n/-!\n# Lemmas for Red-black trees\n\nThe main theorem in this file is `WF_def`, which shows that the `RBNode.WF.mk` constructor\nsubsumes the others, by showing that `insert` and `erase` satisfy the red-black invariants.\n-/\n\nnamespace Std\n\nnamespace RBNode\nopen RBColor\n\nattribute [simp] All\n\ntheorem All.trivial (H : ∀ {x : α}, p x) : ∀ {t : RBNode α}, t.All p\n  | nil => _root_.trivial\n  | node .. => ⟨H, All.trivial H, All.trivial H⟩\n\ntheorem All_and {t : RBNode α} : t.All (fun a => p a ∧ q a) ↔ t.All p ∧ t.All q := by\n  induction t <;> simp [*, and_assoc, and_left_comm]\n\ntheorem cmpLT.trans (h₁ : cmpLT cmp x y) (h₂ : cmpLT cmp y z) : cmpLT cmp x z :=\n  ⟨TransCmp.lt_trans h₁.1 h₂.1⟩\n\ntheorem cmpLT.trans_l {cmp x y} (H : cmpLT cmp x y) {t : RBNode α}\n    (h : t.All (cmpLT cmp y ·)) : t.All (cmpLT cmp x ·) := h.imp fun h => H.trans h\n\ntheorem cmpLT.trans_r {cmp x y} (H : cmpLT cmp x y) {a : RBNode α}\n    (h : a.All (cmpLT cmp · x)) : a.All (cmpLT cmp · y) := h.imp fun h => h.trans H\n\ntheorem cmpEq.lt_congr_left (H : cmpEq cmp x y) : cmpLT cmp x z ↔ cmpLT cmp y z :=\n  ⟨fun ⟨h⟩ => ⟨TransCmp.cmp_congr_left H.1 ▸ h⟩, fun ⟨h⟩ => ⟨TransCmp.cmp_congr_left H.1 ▸ h⟩⟩\n\ntheorem cmpEq.lt_congr_right (H : cmpEq cmp y z) : cmpLT cmp x y ↔ cmpLT cmp x z :=\n  ⟨fun ⟨h⟩ => ⟨TransCmp.cmp_congr_right H.1 ▸ h⟩, fun ⟨h⟩ => ⟨TransCmp.cmp_congr_right H.1 ▸ h⟩⟩\n\n/-- The `balance1` function preserves the ordering invariants. -/\nprotected theorem Ordered.balance1 {l : RBNode α} {v : α} {r : RBNode α}\n    (lv : l.All (cmpLT cmp · v)) (vr : r.All (cmpLT cmp v ·))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balance1 l v r).Ordered cmp := by\n  unfold balance1; split\n  · next a x b y c =>\n    have ⟨yv, _, cv⟩ := lv; have ⟨xy, yc, hx, hc⟩ := hl\n    exact ⟨xy, ⟨yv, yc, yv.trans_l vr⟩, hx, cv, vr, hc, hr⟩\n  · next a x b y c _ =>\n    have ⟨_, _, yv, _, cv⟩ := lv; have ⟨ax, ⟨xy, xb, _⟩, ha, by_, yc, hb, hc⟩ := hl\n    exact ⟨⟨xy, xy.trans_r ax, by_⟩, ⟨yv, yc, yv.trans_l vr⟩, ⟨ax, xb, ha, hb⟩, cv, vr, hc, hr⟩\n  · exact ⟨lv, vr, hl, hr⟩\n\n@[simp] theorem balance1_All {l : RBNode α} {v : α} {r : RBNode α} :\n    (balance1 l v r).All p ↔ p v ∧ l.All p ∧ r.All p := by\n  unfold balance1; split <;> simp [and_assoc, and_left_comm]\n\n/-- The `balance2` function preserves the ordering invariants. -/\nprotected theorem Ordered.balance2 {l : RBNode α} {v : α} {r : RBNode α}\n    (lv : l.All (cmpLT cmp · v)) (vr : r.All (cmpLT cmp v ·))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balance2 l v r).Ordered cmp := by\n  unfold balance2; split\n  · next b y c z d =>\n    have ⟨_, ⟨vy, vb, _⟩, _⟩ := vr; have ⟨⟨yz, _, cz⟩, zd, ⟨by_, yc, hy, hz⟩, hd⟩ := hr\n    exact ⟨⟨vy, vy.trans_r lv, by_⟩, ⟨yz, yc, yz.trans_l zd⟩, ⟨lv, vb, hl, hy⟩, cz, zd, hz, hd⟩\n  · next a x b y c _ =>\n    have ⟨vx, va, _⟩ := vr; have ⟨ax, xy, ha, hy⟩ := hr\n    exact ⟨⟨vx, vx.trans_r lv, ax⟩, xy, ⟨lv, va, hl, ha⟩, hy⟩\n  · exact ⟨lv, vr, hl, hr⟩\n\n@[simp] theorem balance2_All {l : RBNode α} {v : α} {r : RBNode α} :\n    (balance2 l v r).All p ↔ p v ∧ l.All p ∧ r.All p := by\n  unfold balance2; split <;> simp [and_assoc, and_left_comm]\n\nprotected theorem Ordered.setBlack {t : RBNode α} : (setBlack t).Ordered cmp ↔ t.Ordered cmp := by\n  unfold setBlack; split <;> simp [Ordered]\n\nprotected \n\ntheorem setBlack_idem {t : RBNode α} : t.setBlack.setBlack = t.setBlack := by cases t <;> rfl\n\ntheorem insert_setBlack {t : RBNode α} :\n    (t.insert cmp v).setBlack = (t.ins cmp v).setBlack := by\n  unfold insert; split <;> simp [setBlack_idem]\n\nprotected theorem All.ins {x : α} {t : RBNode α}\n  (h₁ : p x) (h₂ : t.All p) : (ins cmp x t).All p := by\n  induction t <;> unfold ins <;> simp [*]\n  split <;> cases ‹_=_› <;> split <;> simp at h₂ <;> simp [*]\n\n/-- The `ins` function preserves the ordering invariants. -/\nprotected theorem Ordered.ins : ∀ {t : RBNode α}, t.Ordered cmp → (ins cmp x t).Ordered cmp\n  | nil, _ => ⟨⟨⟩, ⟨⟩, ⟨⟩, ⟨⟩⟩\n  | node red a y b, ⟨ay, yb, ha, hb⟩ => by\n    unfold ins; split\n    · next h => exact ⟨ay.ins ⟨h⟩, yb, ha.ins, hb⟩\n    · next h => exact ⟨ay, yb.ins ⟨OrientedCmp.cmp_eq_gt.1 h⟩, ha, hb.ins⟩\n    · next h => exact (⟨\n        ay.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_right h).trans h'⟩,\n        yb.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_left h).trans h'⟩, ha, hb⟩)\n  | node black a y b, ⟨ay, yb, ha, hb⟩ => by\n    unfold ins; split\n    · next h => exact ha.ins.balance1 (ay.ins ⟨h⟩) yb hb\n    · next h => exact ha.balance2 ay (yb.ins ⟨OrientedCmp.cmp_eq_gt.1 h⟩) hb.ins\n    · next h => exact (⟨\n        ay.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_right h).trans h'⟩,\n        yb.imp fun ⟨h'⟩ => ⟨(TransCmp.cmp_congr_left h).trans h'⟩, ha, hb⟩)\n\n/-- The `insert` function preserves the ordering invariants. -/\nprotected theorem Ordered.insert (h : t.Ordered cmp) : (insert cmp t v).Ordered cmp := by\n  unfold RBNode.insert; split <;> simp [Ordered.setBlack, h.ins (x := v)]\n\n/--\nThe red-red invariant is a weakening of the red-black balance invariant which allows\nthe root to be red with red children, but does not allow any other violations.\nIt occurs as a temporary condition in the `insert` and `erase` functions.\n\nThe `p` parameter allows the `.redred` case to be dependent on an additional condition.\nIf it is false, then this is equivalent to the usual red-black invariant.\n-/\ninductive RedRed (p : Prop) : RBNode α → Nat → Prop where\n  /-- A balanced tree has the red-red invariant. -/\n  | balanced : Balanced t c n → RedRed p t n\n  /-- A red node with balanced red children has the red-red invariant (if `p` is true). -/\n  | redred : p → Balanced a c₁ n → Balanced b c₂ n → RedRed p (node red a x b) n\n\n/-- When `p` is false, the red-red case is impossible so the tree is balanced. -/\nprotected theorem RedRed.of_false (h : ¬p) : RedRed p t n → ∃ c, Balanced t c n\n  | .balanced h => ⟨_, h⟩\n  | .redred hp .. => nomatch h hp\n\n/-- A `red` node with the red-red invariant has balanced children. -/\nprotected theorem RedRed.of_red : RedRed p (node red a x b) n →\n    ∃ c₁ c₂, Balanced a c₁ n ∧ Balanced b c₂ n\n  | .balanced (.red ha hb) | .redred _ ha hb => ⟨_, _, ha, hb⟩\n\n/-- The red-red invariant is monotonic in `p`. -/\nprotected theorem RedRed.imp (h : p → q) : RedRed p t n → RedRed q t n\n  | .balanced h => .balanced h\n  | .redred hp ha hb => .redred (h hp) ha hb\n\n/-- If `t` has the red-red invariant, then setting the root to black yields a balanced tree. -/\nprotected theorem RedRed.setBlack : t.RedRed p n → ∃ n', (setBlack t).Balanced black n'\n  | .balanced h => h.setBlack\n  | .redred _ hl hr => ⟨_, hl.black hr⟩\n\n/-- The `balance1` function repairs the balance invariant when the first argument is red-red. -/\nprotected theorem RedRed.balance1 {l : RBNode α} {v : α} {r : RBNode α}\n    (hl : l.RedRed p n) (hr : r.Balanced c n) : ∃ c, (balance1 l v r).Balanced c (n + 1) := by\n  unfold balance1; split\n  · have .redred _ (.red ha hb) hc := hl; exact ⟨_, .red (.black ha hb) (.black hc hr)⟩\n  · have .redred _ ha (.red hb hc) := hl; exact ⟨_, .red (.black ha hb) (.black hc hr)⟩\n  · next H1 H2 => match hl with\n    | .balanced hl => exact ⟨_, .black hl hr⟩\n    | .redred _ (c₁ := black) (c₂ := black) ha hb => exact ⟨_, .black (.red ha hb) hr⟩\n    | .redred _ (c₁ := red) (.red ..) _ => cases H1 _ _ _ _ _ rfl\n    | .redred _ (c₂ := red) _ (.red ..) => cases H2 _ _ _ _ _ rfl\n\n/-- The `balance2` function repairs the balance invariant when the second argument is red-red. -/\nprotected theorem RedRed.balance2 {l : RBNode α} {v : α} {r : RBNode α}\n    (hl : l.Balanced c n) (hr : r.RedRed p n) : ∃ c, (balance2 l v r).Balanced c (n + 1) := by\n  unfold balance2; split\n  · have .redred _ (.red ha hb) hc := hr; exact ⟨_, .red (.black hl ha) (.black hb hc)⟩\n  · have .redred _ ha (.red hb hc) := hr; exact ⟨_, .red (.black hl ha) (.black hb hc)⟩\n  · next H1 H2 => match hr with\n    | .balanced hr => exact ⟨_, .black hl hr⟩\n    | .redred _ (c₁ := black) (c₂ := black) ha hb => exact ⟨_, .black hl (.red ha hb)⟩\n    | .redred _ (c₁ := red) (.red ..) _ => cases H1 _ _ _ _ _ rfl\n    | .redred _ (c₂ := red) _ (.red ..) => cases H2 _ _ _ _ _ rfl\n\n/-- The `balance1` function does nothing if the first argument is already balanced. -/\ntheorem balance1_eq {l : RBNode α} {v : α} {r : RBNode α}\n    (hl : l.Balanced c n) : balance1 l v r = node black l v r := by\n  unfold balance1; split <;> first | rfl | match hl with.\n\n/-- The `balance2` function does nothing if the second argument is already balanced. -/\ntheorem balance2_eq {l : RBNode α} {v : α} {r : RBNode α}\n    (hr : r.Balanced c n) : balance2 l v r = node black l v r := by\n  unfold balance2; split <;> first | rfl | match hr with.\n\n/-! ## insert -/\n\n/--\nThe balance invariant of the `ins` function.\nThe result of inserting into the tree either yields a balanced tree,\nor a tree which is almost balanced except that it has a red-red violation at the root.\n-/\nprotected theorem Balanced.ins (cmp v) {t : RBNode α}\n    (h : t.Balanced c n) : (ins cmp v t).RedRed (t.isRed = red) n := by\n  induction h with\n  | nil => exact .balanced (.red .nil .nil)\n  | @red a n b x hl hr ihl ihr =>\n    unfold ins; split\n    · match ins cmp v a, ihl with\n      | _, .balanced .nil => exact .balanced (.red .nil hr)\n      | _, .balanced (.red ha hb) => exact .redred rfl (.red ha hb) hr\n      | _, .balanced (.black ha hb) => exact .balanced (.red (.black ha hb) hr)\n      | _, .redred h .. => cases hl <;> cases h\n    · match ins cmp v b, ihr with\n      | _, .balanced .nil => exact .balanced (.red hl .nil)\n      | _, .balanced (.red ha hb) => exact .redred rfl hl (.red ha hb)\n      | _, .balanced (.black ha hb) => exact .balanced (.red hl (.black ha hb))\n      | _, .redred h .. => cases hr <;> cases h\n    · exact .balanced (.red hl hr)\n  | @black a ca n b cb x hl hr ihl ihr =>\n    unfold ins; split\n    · exact have ⟨c, h⟩ := ihl.balance1 hr; .balanced h\n    · exact have ⟨c, h⟩ := ihr.balance2 hl; .balanced h\n    · exact .balanced (.black hl hr)\n\n/--\nThe `insert` function is balanced if the input is balanced.\n(We lose track of both the color and the black-height of the result,\nso this is only suitable for use on the root of the tree.)\n-/\ntheorem Balanced.insert {t : RBNode α} (h : t.Balanced c n) :\n    ∃ c' n', (insert cmp t v).Balanced c' n' := by\n  unfold insert; match ins cmp v t, h.ins cmp v with\n  | _, .balanced h => split <;> [exact ⟨_, h.setBlack⟩, exact ⟨_, _, h⟩]\n  | _, .redred _ ha hb => have .node red .. := t; exact ⟨_, _, .black ha hb⟩\n\nprotected theorem All.setRed {t : RBNode α} (h : t.All p) : (setRed t).All p := by\n  unfold setRed; split <;> simp_all\n\n/-- The `setRed` function preserves the ordering invariants. -/\nprotected theorem Ordered.setRed {t : RBNode α} : (setRed t).Ordered cmp ↔ t.Ordered cmp := by\n  unfold setRed; split <;> simp [Ordered]\n\nprotected theorem All.balLeft\n    (hl : l.All p) (hv : p v) (hr : r.All p) : (balLeft l v r).All p := by\n  unfold balLeft; split <;> simp_all; split <;> simp_all [All.setRed]\n\n/-- The `balLeft` function preserves the ordering invariants. -/\nprotected theorem Ordered.balLeft {l : RBNode α} {v : α} {r : RBNode α}\n    (lv : l.All (cmpLT cmp · v)) (vr : r.All (cmpLT cmp v ·))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balLeft l v r).Ordered cmp := by\n  unfold balLeft; split\n  · exact ⟨lv, vr, hl, hr⟩\n  split\n  · exact hl.balance2 lv vr hr\n  · have ⟨vy, va, _⟩ := vr.2.1; have ⟨⟨yz, _, bz⟩, zc, ⟨ay, yb, ha, hb⟩, hc⟩ := hr\n    exact ⟨⟨vy, vy.trans_r lv, ay⟩, balance2_All.2 ⟨yz, yb, (yz.trans_l zc).setRed⟩,\n      ⟨lv, va, hl, ha⟩, hb.balance2 bz zc.setRed (Ordered.setRed.2 hc)⟩\n  · exact ⟨lv, vr, hl, hr⟩\n\n/-- The balancing properties of the `balLeft` function. -/\nprotected theorem Balanced.balLeft (hl : l.RedRed True n) (hr : r.Balanced cr (n + 1)) :\n    (balLeft l v r).RedRed (cr = red) (n + 1) := by\n  unfold balLeft; split\n  · next a x b => exact\n    let ⟨ca, cb, ha, hb⟩ := hl.of_red\n    match cr with\n    | red => .redred rfl (.black ha hb) hr\n    | black => .balanced (.red (.black ha hb) hr)\n  · next H => exact match hl with\n    | .redred .. => nomatch H _ _ _ rfl\n    | .balanced hl => match hr with\n      | .black ha hb =>\n        let ⟨c, h⟩ := RedRed.balance2 hl (.redred trivial ha hb); .balanced h\n      | .red (.black ha hb) (.black hc hd) =>\n        let ⟨c, h⟩ := RedRed.balance2 hb (.redred trivial hc hd); .redred rfl (.black hl ha) h\n\nprotected theorem All.balRight\n    (hl : l.All p) (hv : p v) (hr : r.All p) : (balRight l v r).All p := by\n  unfold balRight; split <;> simp_all; split <;> simp_all [All.setRed]\n\n/-- The `balRight` function preserves the ordering invariants. -/\nprotected theorem Ordered.balRight {l : RBNode α} {v : α} {r : RBNode α}\n    (lv : l.All (cmpLT cmp · v)) (vr : r.All (cmpLT cmp v ·))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balRight l v r).Ordered cmp := by\n  unfold balRight; split\n  · exact ⟨lv, vr, hl, hr⟩\n  split\n  · exact hl.balance1 lv vr hr\n  · have ⟨yv, _, cv⟩ := lv.2.2; have ⟨ax, ⟨xy, xb, _⟩, ha, by_, yc, hb, hc⟩ := hl\n    exact ⟨balance1_All.2 ⟨xy, (xy.trans_r ax).setRed, by_⟩, ⟨yv, yc, yv.trans_l vr⟩,\n      (Ordered.setRed.2 ha).balance1 ax.setRed xb hb, cv, vr, hc, hr⟩\n  · exact ⟨lv, vr, hl, hr⟩\n\n/-- The balancing properties of the `balRight` function. -/\nprotected theorem Balanced.balRight (hl : l.Balanced cl (n + 1)) (hr : r.RedRed True n) :\n    (balRight l v r).RedRed (cl = red) (n + 1) := by\n  unfold balRight; split\n  · next b y c => exact\n    let ⟨cb, cc, hb, hc⟩ := hr.of_red\n    match cl with\n    | red => .redred rfl hl (.black hb hc)\n    | black => .balanced (.red hl (.black hb hc))\n  · next H => exact match hr with\n    | .redred .. => nomatch H _ _ _ rfl\n    | .balanced hr => match hl with\n      | .black hb hc =>\n        let ⟨c, h⟩ := RedRed.balance1 (.redred trivial hb hc) hr; .balanced h\n      | .red (.black ha hb) (.black hc hd) =>\n        let ⟨c, h⟩ := RedRed.balance1 (.redred trivial ha hb) hc; .redred rfl h (.black hd hr)\n\nprotected theorem All.append (hl : l.All p) (hr : r.All p) : (append l r).All p := by\n  unfold append; split <;> simp [*]\n  · have ⟨hx, ha, hb⟩ := hl; have ⟨hy, hc, hd⟩ := hr\n    have := hb.append hc; split <;> simp_all\n  · have ⟨hx, ha, hb⟩ := hl; have ⟨hy, hc, hd⟩ := hr\n    have := hb.append hc; split <;> simp_all [All.balLeft]\n  · simp_all [hl.append hr.2.1]\n  · simp_all [hl.2.2.append hr]\ntermination_by _ => l.size + r.size\n\n/-- The `append` function preserves the ordering invariants. -/\nprotected theorem Ordered.append {l : RBNode α} {v : α} {r : RBNode α}\n    (lv : l.All (cmpLT cmp · v)) (vr : r.All (cmpLT cmp v ·))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (append l r).Ordered cmp := by\n  unfold append; split\n  · exact hr\n  · exact hl\n  · have ⟨xv, _, bv⟩ := lv; have ⟨ax, xb, ha, hb⟩ := hl\n    have ⟨vy, vc, _⟩ := vr; have ⟨cy, yd, hc, hd⟩ := hr\n    have : _ ∧ _ ∧ _ := ⟨hb.append bv vc hc, xb.append (xv.trans_l vc), (vy.trans_r bv).append cy⟩\n    split\n    · next H =>\n      have ⟨⟨b'z, c'z, hb', hc'⟩, ⟨xz, xb', _⟩, zy, _, c'y⟩ := H ▸ this\n      have az := xz.trans_r ax; have zd := zy.trans_l yd\n      exact ⟨⟨xz, az, b'z⟩, ⟨zy, c'z, zd⟩, ⟨ax, xb', ha, hb'⟩, c'y, yd, hc', hd⟩\n    · have ⟨hbc, xbc, bcy⟩ := this; have xy := xv.trans vy\n      exact ⟨ax, ⟨xy, xbc, xy.trans_l yd⟩, ha, bcy, yd, hbc, hd⟩\n  · have ⟨xv, _, bv⟩ := lv; have ⟨ax, xb, ha, hb⟩ := hl\n    have ⟨vy, vc, _⟩ := vr; have ⟨cy, yd, hc, hd⟩ := hr\n    have : _ ∧ _ ∧ _ := ⟨hb.append bv vc hc, xb.append (xv.trans_l vc), (vy.trans_r bv).append cy⟩\n    split\n    · next H =>\n      have ⟨⟨b'z, c'z, hb', hc'⟩, ⟨xz, xb', _⟩, zy, _, c'y⟩ := H ▸ this\n      have az := xz.trans_r ax; have zd := zy.trans_l yd\n      exact ⟨⟨xz, az, b'z⟩, ⟨zy, c'z, zd⟩, ⟨ax, xb', ha, hb'⟩, c'y, yd, hc', hd⟩\n    · have ⟨hbc, xbc, bcy⟩ := this; have xy := xv.trans vy\n      exact ha.balLeft ax ⟨xy, xbc, xy.trans_l yd⟩ ⟨bcy, yd, hbc, hd⟩\n  · have ⟨vx, vb, _⟩ := vr; have ⟨bx, yc, hb, hc⟩ := hr\n    exact ⟨(vx.trans_r lv).append bx, yc, hl.append lv vb hb, hc⟩\n  · have ⟨xv, _, bv⟩ := lv; have ⟨ax, xb, ha, hb⟩ := hl\n    exact ⟨ax, xb.append (xv.trans_l vr), ha, hb.append bv vr hr⟩\ntermination_by _ => l.size + r.size\n\n/-- The balance properties of the `append` function. -/\nprotected theorem Balanced.append {l r : RBNode α}\n    (hl : l.Balanced c₁ n) (hr : r.Balanced c₂ n) :\n    (l.append r).RedRed (c₁ = black → c₂ ≠ black) n := by\n  unfold append; split\n  · exact .balanced hr\n  · exact .balanced hl\n  · next b c _ _ =>\n    have .red ha hb := hl; have .red hc hd := hr\n    have ⟨_, IH⟩ := (hb.append hc).of_false (· rfl rfl); split\n    · next e =>\n      have .red hb' hc' := e ▸ IH\n      exact .redred (fun.) (.red ha hb') (.red hc' hd)\n    · next bcc _ H =>\n      match bcc, append b c, IH, H with\n      | black, _, IH, _ => exact .redred (fun.) ha (.red IH hd)\n      | red, _, .red .., H => cases H _ _ _ rfl\n  · next b c _ _ =>\n    have .black ha hb := hl; have .black hc hd := hr\n    have IH := hb.append hc; split\n    · next e => match e ▸ IH with\n      | .balanced (.red hb' hc') | .redred _ hb' hc' =>\n        exact .balanced (.red (.black ha hb') (.black hc' hd))\n    · next H =>\n      match append b c, IH, H with\n      | bc, .balanced hbc, _ =>\n        unfold balLeft; split\n        · have .red ha' hb' := ha\n          exact .balanced (.red (.black ha' hb') (.black hbc hd))\n        · exact have ⟨c, h⟩ := RedRed.balance2 ha (.redred trivial hbc hd); .balanced h\n      | _, .redred .., H => cases H _ _ _ rfl\n  · have .red hc hd := hr; have IH := hl.append hc\n    have .black ha hb := hl; have ⟨c, IH⟩ := IH.of_false (· rfl rfl)\n    exact .redred (fun.) IH hd\n  · have .red ha hb := hl; have IH := hb.append hr\n    have .black hc hd := hr; have ⟨c, IH⟩ := IH.of_false (· rfl rfl)\n    exact .redred (fun.) ha IH\ntermination_by _ => l.size + r.size\n\n/-! ## erase -/\n\n/--\nThe invariant of the `del` function.\n* If the input tree is black, then the result of deletion is a red-red tree with\n  black-height lowered by 1.\n* If the input tree is red or nil, then the result of deletion is a balanced tree with\n  some color and the same black-height.\n-/\ndef DelProp (p : RBColor) (t : RBNode α) (n : Nat) : Prop :=\n  match p with\n  | black => ∃ n', n = n' + 1 ∧ RedRed True t n'\n  | red => ∃ c, Balanced t c n\n\n/-- The `DelProp` property is a strengthened version of the red-red invariant. -/\ntheorem DelProp.redred (h : DelProp c t n) : ∃ n', RedRed (c = black) t n' := by\n  unfold DelProp at h\n  exact match c, h with\n  | red, ⟨_, h⟩ => ⟨_, .balanced h⟩\n  | black, ⟨_, _, h⟩ => ⟨_, h.imp fun _ => rfl⟩\n\nprotected theorem All.del : ∀ {t : RBNode α}, t.All p → (del cut t).All p\n  | .nil, h => h\n  | .node .., ⟨hy, ha, hb⟩ => by\n    unfold del; split\n    · split\n      · exact ha.del.balLeft hy hb\n      · exact ⟨hy, ha.del, hb⟩\n    · split\n      · exact ha.balRight hy hb.del\n      · exact ⟨hy, ha, hb.del⟩\n    · exact ha.append hb\n\n/-- The `del` function preserves the ordering invariants. -/\nprotected theorem Ordered.del : ∀ {t : RBNode α}, t.Ordered cmp → (del cut t).Ordered cmp\n  | .nil, _ => ⟨⟩\n  | .node _ a y b, ⟨ay, yb, ha, hb⟩ => by\n    unfold del; split\n    · split\n      · exact ha.del.balLeft ay.del yb hb\n      · exact ⟨ay.del, yb, ha.del, hb⟩\n    · split\n      · exact ha.balRight ay yb.del hb.del\n      · exact ⟨ay, yb.del, ha, hb.del⟩\n    · exact ha.append ay yb hb\n\n/-- The `del` function has the `DelProp` property. -/\nprotected theorem Balanced.del {t : RBNode α} (h : t.Balanced c n) :\n    (t.del cut).DelProp t.isBlack n := by\n  induction h with\n  | nil => exact ⟨_, .nil⟩\n  | @black a _ n b _ _ ha hb iha ihb =>\n    refine ⟨_, rfl, ?_⟩\n    unfold del; split\n    · exact match a, n, iha with\n      | .nil, _, ⟨c, ha⟩ | .node red .., _, ⟨c, ha⟩ => .redred ⟨⟩ ha hb\n      | .node black .., _, ⟨n, rfl, ha⟩ => (hb.balLeft ha).imp fun _ => ⟨⟩\n    · exact match b, n, ihb with\n      | .nil, _, ⟨c, hb⟩ | .node .red .., _, ⟨c, hb⟩ => .redred ⟨⟩ ha hb\n      | .node black .., _, ⟨n, rfl, hb⟩ => (ha.balRight hb).imp fun _ => ⟨⟩\n    · exact (ha.append hb).imp fun _ => ⟨⟩\n  | @red a n b _ ha hb iha ihb =>\n    unfold del; split\n    · exact match a, n, iha with\n      | .nil, _, _ => ⟨_, .red ha hb⟩\n      | .node black .., _, ⟨n, rfl, ha⟩ => (hb.balLeft ha).of_false (fun.)\n    · exact match b, n, ihb with\n      | .nil, _, _ => ⟨_, .red ha hb⟩\n      | .node black .., _, ⟨n, rfl, hb⟩ => (ha.balRight hb).of_false (fun.)\n    · exact (ha.append hb).of_false (· rfl rfl)\n\n/-- The `erase` function preserves the ordering invariants. -/\nprotected theorem Ordered.erase {t : RBNode α} (h : t.Ordered cmp) : (erase cut t).Ordered cmp :=\n  Ordered.setBlack.2 h.del\n\n/-- The `erase` function preserves the balance invariants. -/\nprotected theorem Balanced.erase {t : RBNode α}\n    (h : t.Balanced c n) : ∃ n, (t.erase cut).Balanced black n :=\n  have ⟨_, h⟩ := h.del.redred; h.setBlack\n\n/-- The well-formedness invariant implies the ordering and balance properties. -/\ntheorem WF.out {t : RBNode α} (h : t.WF cmp) : t.Ordered cmp ∧ ∃ c n, t.Balanced c n := by\n  induction h with\n  | mk o h => exact ⟨o, _, _, h⟩\n  | insert _ ih => have ⟨o, _, _, h⟩ := ih; exact ⟨o.insert, h.insert⟩\n  | erase _ ih => have ⟨o, _, _, h⟩ := ih; exact ⟨o.erase, _, h.erase⟩\n\n/--\nThe well-formedness invariant for a red-black tree is exactly the `mk` constructor,\nbecause the other constructors of `WF` are redundant.\n-/\n@[simp] theorem WF_iff {t : RBNode α} : t.WF cmp ↔ t.Ordered cmp ∧ ∃ c n, t.Balanced c n :=\n  ⟨fun h => h.out, fun ⟨o, _, _, h⟩ => .mk o h⟩\n\n/-- The `map` function preserves the balance invariants. -/\nprotected theorem Balanced.map {t : RBNode α} : t.Balanced c n → (t.map f).Balanced c n\n  | .nil => .nil\n  | .red hl hr => .red hl.map hr.map\n  | .black hl hr => .black hl.map hr.map\n\n/-- The property of a map function `f` which ensures the `map` operation is valid. -/\nclass IsMonotone (cmpα cmpβ) (f : α → β) : Prop where\n  /-- If `x < y` then `f x < f y`. -/\n  lt_mono : cmpLT cmpα x y → cmpLT cmpβ (f x) (f y)\n\n/-- Sufficient condition for `map` to preserve an `All` quantifier. -/\nprotected theorem All.map {f : α → β} (H : ∀ {x}, p x → q (f x)) :\n    ∀ {t : RBNode α}, t.All p → (t.map f).All q\n  | nil, _ => ⟨⟩\n  | node .., ⟨hx, ha, hb⟩ => ⟨H hx, ha.map H, hb.map H⟩\n\n/-- The `map` function preserves the order invariants if `f` is monotone. -/\nprotected theorem Ordered.map (f : α → β) [IsMonotone cmpα cmpβ f] :\n    ∀ {t : RBNode α}, t.Ordered cmpα → (t.map f).Ordered cmpβ\n  | nil, _ => ⟨⟩\n  | node _ a x b, ⟨ax, xb, ha, hb⟩ => by\n    refine ⟨ax.map ?_, xb.map ?_, ha.map f, hb.map f⟩ <;> exact IsMonotone.lt_mono\n\nend RBNode\n\nnamespace RBSet\nexport RBNode (IsMonotone)\n\n/--\n`O(n)`. Map a function on every value in the tree.\nThis requires `IsMonotone` on the function in order to preserve the order invariant.\n-/\n@[inline] def map (f : α → β) [IsMonotone cmpα cmpβ f] (t : RBSet α cmpα) : RBSet β cmpβ :=\n  ⟨t.1.map f, have ⟨h₁, _, _, h₂⟩ := t.2.out; .mk (h₁.map _) h₂.map⟩\n\nend RBSet\n\nnamespace RBMap\nexport RBNode (IsMonotone)\n\nnamespace Imp\n\n/--\nApplies `f` to the second component.\nWe extract this as a function so that `IsMonotone (mapSnd f)` can be an instance.\n-/\n@[inline] def mapSnd (f : α → β → γ) := fun (a, b) => (a, f a b)\n\ninstance (cmp : α → α → Ordering) (f : α → β → γ) :\n    IsMonotone (byKey Prod.fst cmp) (byKey Prod.fst cmp) (mapSnd f) where\n  lt_mono | ⟨h⟩ => ⟨@fun _ => @h {\n    symm := fun (a₁, b₁) (a₂, b₂) =>\n      OrientedCmp.symm (cmp := byKey Prod.fst cmp) (a₁, f a₁ b₁) (a₂, f a₂ b₂)\n    le_trans := @fun (a₁, b₁) (a₂, b₂) (a₃, b₃) =>\n      TransCmp.le_trans (cmp := byKey Prod.fst cmp)\n        (x := (a₁, f a₁ b₁)) (y := (a₂, f a₂ b₂)) (z := (a₃, f a₃ b₃))\n  }⟩\n\nend Imp\n\n/-- `O(n)`. Map a function on the values in the map. -/\ndef mapVal (f : α → β → γ) (t : RBMap α β cmp) : RBMap α γ cmp := t.map (Imp.mapSnd f)\n\nend RBMap\n", "meta": {"author": "leanprover", "repo": "std4", "sha": "5507f9d8409f93b984ce04eccf4914d534e6fca2", "save_path": "github-repos/lean/leanprover-std4", "path": "github-repos/lean/leanprover-std4/std4-5507f9d8409f93b984ce04eccf4914d534e6fca2/Std/Data/RBMap/WF.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.6959583313396339, "lm_q1q2_score": 0.4508405668107392}}
{"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Bhavik Mehta\n-/\nimport category_theory.limits.shapes.terminal\nimport category_theory.discrete_category\nimport category_theory.epi_mono\nimport category_theory.over\n\n/-!\n# Binary (co)products\n\nWe define a category `walking_pair`, which is the index category\nfor a binary (co)product diagram. A convenience method `pair X Y`\nconstructs the functor from the walking pair, hitting the given objects.\n\nWe define `prod X Y` and `coprod X Y` as limits and colimits of such functors.\n\nTypeclasses `has_binary_products` and `has_binary_coproducts` assert the existence\nof (co)limits shaped as walking pairs.\n\nWe include lemmas for simplifying equations involving projections and coprojections, and define\nbraiding and associating isomorphisms, and the product comparison morphism.\n\n## References\n* [Stacks: Products of pairs](https://stacks.math.columbia.edu/tag/001R)\n* [Stacks: coproducts of pairs](https://stacks.math.columbia.edu/tag/04AN)\n-/\n\nnoncomputable theory\n\nuniverses v u u₂\n\nopen category_theory\n\nnamespace category_theory.limits\n\n/-- The type of objects for the diagram indexing a binary (co)product. -/\n@[derive decidable_eq, derive inhabited]\ninductive walking_pair : Type\n| left | right\n\nopen walking_pair\n\n/--\nThe equivalence swapping left and right.\n-/\ndef walking_pair.swap : walking_pair ≃ walking_pair :=\n{ to_fun := λ j, walking_pair.rec_on j right left,\n  inv_fun := λ j, walking_pair.rec_on j right left,\n  left_inv := λ j, by { cases j; refl, },\n  right_inv := λ j, by { cases j; refl, }, }\n\n@[simp] lemma walking_pair.swap_apply_left : walking_pair.swap left = right := rfl\n@[simp] lemma walking_pair.swap_apply_right : walking_pair.swap right = left := rfl\n@[simp] lemma walking_pair.swap_symm_apply_tt : walking_pair.swap.symm left = right := rfl\n@[simp] lemma walking_pair.swap_symm_apply_ff : walking_pair.swap.symm right = left := rfl\n\n/--\nAn equivalence from `walking_pair` to `bool`, sometimes useful when reindexing limits.\n-/\ndef walking_pair.equiv_bool : walking_pair ≃ bool :=\n{ to_fun := λ j, walking_pair.rec_on j tt ff, -- to match equiv.sum_equiv_sigma_bool\n  inv_fun := λ b, bool.rec_on b right left,\n  left_inv := λ j, by { cases j; refl, },\n  right_inv := λ b, by { cases b; refl, }, }\n\n@[simp] lemma walking_pair.equiv_bool_apply_left : walking_pair.equiv_bool left = tt := rfl\n@[simp] lemma walking_pair.equiv_bool_apply_right : walking_pair.equiv_bool right = ff := rfl\n@[simp] lemma walking_pair.equiv_bool_symm_apply_tt : walking_pair.equiv_bool.symm tt = left := rfl\n@[simp] lemma walking_pair.equiv_bool_symm_apply_ff : walking_pair.equiv_bool.symm ff = right := rfl\n\nvariables {C : Type u}\n\n/-- The function on the walking pair, sending the two points to `X` and `Y`. -/\ndef pair_function (X Y : C) : walking_pair → C := λ j, walking_pair.cases_on j X Y\n\n@[simp] lemma pair_function_left (X Y : C) : pair_function X Y left = X := rfl\n@[simp] lemma pair_function_right (X Y : C) : pair_function X Y right = Y := rfl\n\nvariables [category.{v} C]\n\n/-- The diagram on the walking pair, sending the two points to `X` and `Y`. -/\ndef pair (X Y : C) : discrete walking_pair ⥤ C :=\ndiscrete.functor (λ j, walking_pair.cases_on j X Y)\n\n@[simp] lemma pair_obj_left (X Y : C) : (pair X Y).obj ⟨left⟩ = X := rfl\n@[simp] lemma pair_obj_right (X Y : C) : (pair X Y).obj ⟨right⟩ = Y := rfl\n\nsection\nvariables {F G : discrete walking_pair ⥤ C} (f : F.obj ⟨left⟩ ⟶ G.obj ⟨left⟩)\n  (g : F.obj ⟨right⟩ ⟶ G.obj ⟨right⟩)\n\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- The natural transformation between two functors out of the\n walking pair, specified by its\ncomponents. -/\ndef map_pair : F ⟶ G := { app := λ j, discrete.rec_on j (λ j, walking_pair.cases_on j f g) }\n\n@[simp] lemma map_pair_left : (map_pair f g).app ⟨left⟩ = f := rfl\n@[simp] lemma map_pair_right : (map_pair f g).app ⟨right⟩ = g := rfl\n\n/-- The natural isomorphism between two functors out of the walking pair, specified by its\ncomponents. -/\n@[simps]\ndef map_pair_iso (f : F.obj ⟨left⟩ ≅ G.obj ⟨left⟩) (g : F.obj ⟨right⟩ ≅ G.obj ⟨right⟩) : F ≅ G :=\nnat_iso.of_components (λ j, discrete.rec_on j (λ j, walking_pair.cases_on j f g)) (by tidy)\n\nend\n\n/-- Every functor out of the walking pair is naturally isomorphic (actually, equal) to a `pair` -/\n@[simps]\ndef diagram_iso_pair (F : discrete walking_pair ⥤ C) :\n  F ≅ pair (F.obj ⟨walking_pair.left⟩) (F.obj ⟨walking_pair.right⟩) :=\nmap_pair_iso (iso.refl _) (iso.refl _)\n\nsection\nvariables {D : Type u} [category.{v} D]\n\n/-- The natural isomorphism between `pair X Y ⋙ F` and `pair (F.obj X) (F.obj Y)`. -/\ndef pair_comp (X Y : C) (F : C ⥤ D) : pair X Y ⋙ F ≅ pair (F.obj X) (F.obj Y) :=\ndiagram_iso_pair _\n\nend\n\n/-- A binary fan is just a cone on a diagram indexing a product. -/\nabbreviation binary_fan (X Y : C) := cone (pair X Y)\n\n/-- The first projection of a binary fan. -/\nabbreviation binary_fan.fst {X Y : C} (s : binary_fan X Y) := s.π.app ⟨walking_pair.left⟩\n\n/-- The second projection of a binary fan. -/\nabbreviation binary_fan.snd {X Y : C} (s : binary_fan X Y) := s.π.app ⟨walking_pair.right⟩\n\n@[simp] lemma binary_fan.π_app_left {X Y : C} (s : binary_fan X Y) :\n  s.π.app ⟨walking_pair.left⟩ = s.fst := rfl\n@[simp] lemma binary_fan.π_app_right {X Y : C} (s : binary_fan X Y) :\n  s.π.app ⟨walking_pair.right⟩ = s.snd := rfl\n\n/-- A convenient way to show that a binary fan is a limit. -/\ndef binary_fan.is_limit.mk {X Y : C} (s : binary_fan X Y)\n  (lift : Π {T : C} (f : T ⟶ X) (g : T ⟶ Y), T ⟶ s.X)\n  (hl₁ : ∀ {T : C} (f : T ⟶ X) (g : T ⟶ Y), lift f g ≫ s.fst = f)\n  (hl₂ : ∀ {T : C} (f : T ⟶ X) (g : T ⟶ Y), lift f g ≫ s.snd = g)\n  (uniq : ∀ {T : C} (f : T ⟶ X) (g : T ⟶ Y) (m : T ⟶ s.X) (h₁ : m ≫ s.fst = f)\n    (h₂ : m ≫ s.snd = g), m = lift f g) : is_limit s := is_limit.mk\n  (λ t, lift (binary_fan.fst t) (binary_fan.snd t))\n  (by { rintros t (rfl|rfl), { exact hl₁ _ _ }, { exact hl₂ _ _ } })\n  (λ t m h, uniq _ _ _ (h ⟨walking_pair.left⟩) (h ⟨walking_pair.right⟩))\n\nlemma binary_fan.is_limit.hom_ext {W X Y : C} {s : binary_fan X Y} (h : is_limit s)\n  {f g : W ⟶ s.X} (h₁ : f ≫ s.fst = g ≫ s.fst) (h₂ : f ≫ s.snd = g ≫ s.snd) : f = g :=\nh.hom_ext $ λ j, discrete.rec_on j (λ j, walking_pair.cases_on j h₁ h₂)\n\n/-- A binary cofan is just a cocone on a diagram indexing a coproduct. -/\nabbreviation binary_cofan (X Y : C) := cocone (pair X Y)\n\n/-- The first inclusion of a binary cofan. -/\nabbreviation binary_cofan.inl {X Y : C} (s : binary_cofan X Y) := s.ι.app ⟨walking_pair.left⟩\n\n/-- The second inclusion of a binary cofan. -/\nabbreviation binary_cofan.inr {X Y : C} (s : binary_cofan X Y) := s.ι.app ⟨walking_pair.right⟩\n\n@[simp] lemma binary_cofan.ι_app_left {X Y : C} (s : binary_cofan X Y) :\n  s.ι.app ⟨walking_pair.left⟩ = s.inl := rfl\n@[simp] lemma binary_cofan.ι_app_right {X Y : C} (s : binary_cofan X Y) :\n  s.ι.app ⟨walking_pair.right⟩ = s.inr := rfl\n\n/-- A convenient way to show that a binary cofan is a colimit. -/\ndef binary_cofan.is_colimit.mk {X Y : C} (s : binary_cofan X Y)\n  (desc : Π {T : C} (f : X ⟶ T) (g : Y ⟶ T), s.X ⟶ T)\n  (hd₁ : ∀ {T : C} (f : X ⟶ T) (g : Y ⟶ T), s.inl ≫ desc f g = f)\n  (hd₂ : ∀ {T : C} (f : X ⟶ T) (g : Y ⟶ T), s.inr ≫ desc f g = g)\n  (uniq : ∀ {T : C} (f : X ⟶ T) (g : Y ⟶ T) (m : s.X ⟶ T) (h₁ : s.inl ≫ m = f)\n    (h₂ : s.inr ≫ m = g), m = desc f g) : is_colimit s := is_colimit.mk\n    (λ t, desc (binary_cofan.inl t) (binary_cofan.inr t))\n    (by { rintros t (rfl|rfl), { exact hd₁ _ _ }, { exact hd₂ _ _ }})\n    (λ t m h, uniq _ _ _ (h ⟨walking_pair.left⟩) (h ⟨walking_pair.right⟩))\n\nlemma binary_cofan.is_colimit.hom_ext {W X Y : C} {s : binary_cofan X Y} (h : is_colimit s)\n  {f g : s.X ⟶ W} (h₁ : s.inl ≫ f = s.inl ≫ g) (h₂ : s.inr ≫ f = s.inr ≫ g) : f = g :=\nh.hom_ext $ λ j, discrete.rec_on j (λ j, walking_pair.cases_on j h₁ h₂)\n\nvariables {X Y : C}\n\nsection\nlocal attribute [tidy] tactic.discrete_cases\n\n/-- A binary fan with vertex `P` consists of the two projections `π₁ : P ⟶ X` and `π₂ : P ⟶ Y`. -/\n@[simps X]\ndef binary_fan.mk {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) : binary_fan X Y :=\n{ X := P,\n  π := { app := λ j, discrete.rec_on j (λ j, walking_pair.cases_on j π₁ π₂) }}\n\n/-- A binary cofan with vertex `P` consists of the two inclusions `ι₁ : X ⟶ P` and `ι₂ : Y ⟶ P`. -/\n@[simps X]\ndef binary_cofan.mk {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) : binary_cofan X Y :=\n{ X := P,\n  ι := { app := λ j, discrete.rec_on j (λ j, walking_pair.cases_on j ι₁ ι₂) }}\n\nend\n\n@[simp] lemma binary_fan.mk_π_app_left {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) :\n  (binary_fan.mk π₁ π₂).π.app ⟨walking_pair.left⟩ = π₁ := rfl\n@[simp] lemma binary_fan.mk_π_app_right {P : C} (π₁ : P ⟶ X) (π₂ : P ⟶ Y) :\n  (binary_fan.mk π₁ π₂).π.app ⟨walking_pair.right⟩ = π₂ := rfl\n@[simp] lemma binary_cofan.mk_ι_app_left {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) :\n  (binary_cofan.mk ι₁ ι₂).ι.app ⟨walking_pair.left⟩ = ι₁ := rfl\n@[simp] lemma binary_cofan.mk_ι_app_right {P : C} (ι₁ : X ⟶ P) (ι₂ : Y ⟶ P) :\n  (binary_cofan.mk ι₁ ι₂).ι.app ⟨walking_pair.right⟩ = ι₂ := rfl\n\n/-- If `s` is a limit binary fan over `X` and `Y`, then every pair of morphisms `f : W ⟶ X` and\n    `g : W ⟶ Y` induces a morphism `l : W ⟶ s.X` satisfying `l ≫ s.fst = f` and `l ≫ s.snd = g`.\n    -/\n@[simps]\ndef binary_fan.is_limit.lift' {W X Y : C} {s : binary_fan X Y} (h : is_limit s) (f : W ⟶ X)\n  (g : W ⟶ Y) : {l : W ⟶ s.X // l ≫ s.fst = f ∧ l ≫ s.snd = g} :=\n⟨h.lift $ binary_fan.mk f g, h.fac _ _, h.fac _ _⟩\n\n/-- If `s` is a colimit binary cofan over `X` and `Y`,, then every pair of morphisms `f : X ⟶ W` and\n    `g : Y ⟶ W` induces a morphism `l : s.X ⟶ W` satisfying `s.inl ≫ l = f` and `s.inr ≫ l = g`.\n    -/\n@[simps]\ndef binary_cofan.is_colimit.desc' {W X Y : C} {s : binary_cofan X Y} (h : is_colimit s) (f : X ⟶ W)\n  (g : Y ⟶ W) : {l : s.X ⟶ W // s.inl ≫ l = f ∧ s.inr ≫ l = g} :=\n⟨h.desc $ binary_cofan.mk f g, h.fac _ _, h.fac _ _⟩\n\n/-- An abbreviation for `has_limit (pair X Y)`. -/\nabbreviation has_binary_product (X Y : C) := has_limit (pair X Y)\n/-- An abbreviation for `has_colimit (pair X Y)`. -/\nabbreviation has_binary_coproduct (X Y : C) := has_colimit (pair X Y)\n\n/-- If we have a product of `X` and `Y`, we can access it using `prod X Y` or\n    `X ⨯ Y`. -/\nabbreviation prod (X Y : C) [has_binary_product X Y] := limit (pair X Y)\n\n/-- If we have a coproduct of `X` and `Y`, we can access it using `coprod X Y ` or\n    `X ⨿ Y`. -/\nabbreviation coprod (X Y : C) [has_binary_coproduct X Y] := colimit (pair X Y)\n\nnotation X ` ⨯ `:20 Y:20 := prod X Y\nnotation X ` ⨿ `:20 Y:20 := coprod X Y\n\n/-- The projection map to the first component of the product. -/\nabbreviation prod.fst {X Y : C} [has_binary_product X Y] : X ⨯ Y ⟶ X :=\nlimit.π (pair X Y) ⟨walking_pair.left⟩\n\n/-- The projecton map to the second component of the product. -/\nabbreviation prod.snd {X Y : C} [has_binary_product X Y] : X ⨯ Y ⟶ Y :=\nlimit.π (pair X Y) ⟨walking_pair.right⟩\n\n/-- The inclusion map from the first component of the coproduct. -/\nabbreviation coprod.inl {X Y : C} [has_binary_coproduct X Y] : X ⟶ X ⨿ Y :=\ncolimit.ι (pair X Y) ⟨walking_pair.left⟩\n\n/-- The inclusion map from the second component of the coproduct. -/\nabbreviation coprod.inr {X Y : C} [has_binary_coproduct X Y] : Y ⟶ X ⨿ Y :=\ncolimit.ι (pair X Y) ⟨walking_pair.right⟩\n\n/-- The binary fan constructed from the projection maps is a limit. -/\ndef prod_is_prod (X Y : C) [has_binary_product X Y] :\n  is_limit (binary_fan.mk (prod.fst : X ⨯ Y ⟶ X) prod.snd) :=\n(limit.is_limit _).of_iso_limit (cones.ext (iso.refl _) (by { rintro (_ | _), tidy }))\n\n/-- The binary cofan constructed from the coprojection maps is a colimit. -/\ndef coprod_is_coprod (X Y : C) [has_binary_coproduct X Y] :\n  is_colimit (binary_cofan.mk (coprod.inl : X ⟶ X ⨿ Y) coprod.inr) :=\n(colimit.is_colimit _).of_iso_colimit (cocones.ext (iso.refl _) (by { rintro (_ | _), tidy }))\n\n@[ext] lemma prod.hom_ext {W X Y : C} [has_binary_product X Y] {f g : W ⟶ X ⨯ Y}\n  (h₁ : f ≫ prod.fst = g ≫ prod.fst) (h₂ : f ≫ prod.snd = g ≫ prod.snd) : f = g :=\nbinary_fan.is_limit.hom_ext (limit.is_limit _) h₁ h₂\n\n@[ext] lemma coprod.hom_ext {W X Y : C} [has_binary_coproduct X Y] {f g : X ⨿ Y ⟶ W}\n  (h₁ : coprod.inl ≫ f = coprod.inl ≫ g) (h₂ : coprod.inr ≫ f = coprod.inr ≫ g) : f = g :=\nbinary_cofan.is_colimit.hom_ext (colimit.is_colimit _) h₁ h₂\n\n/-- If the product of `X` and `Y` exists, then every pair of morphisms `f : W ⟶ X` and `g : W ⟶ Y`\n    induces a morphism `prod.lift f g : W ⟶ X ⨯ Y`. -/\nabbreviation prod.lift {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) : W ⟶ X ⨯ Y :=\nlimit.lift _ (binary_fan.mk f g)\n\n/-- diagonal arrow of the binary product in the category `fam I` -/\nabbreviation diag (X : C) [has_binary_product X X] : X ⟶ X ⨯ X :=\nprod.lift (𝟙 _) (𝟙 _)\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X ⟶ W` and\n    `g : Y ⟶ W` induces a morphism `coprod.desc f g : X ⨿ Y ⟶ W`. -/\nabbreviation coprod.desc {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  X ⨿ Y ⟶ W :=\ncolimit.desc _ (binary_cofan.mk f g)\n\n/-- codiagonal arrow of the binary coproduct -/\nabbreviation codiag (X : C) [has_binary_coproduct X X] : X ⨿ X ⟶ X :=\ncoprod.desc (𝟙 _) (𝟙 _)\n\n@[simp, reassoc]\nlemma prod.lift_fst {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  prod.lift f g ≫ prod.fst = f :=\nlimit.lift_π _ _\n\n@[simp, reassoc]\nlemma prod.lift_snd {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  prod.lift f g ≫ prod.snd = g :=\nlimit.lift_π _ _\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.inl_desc {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  coprod.inl ≫ coprod.desc f g = f :=\ncolimit.ι_desc _ _\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.inr_desc {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  coprod.inr ≫ coprod.desc f g = g :=\ncolimit.ι_desc _ _\n\ninstance prod.mono_lift_of_mono_left {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y)\n  [mono f] : mono (prod.lift f g) :=\nmono_of_mono_fac $ prod.lift_fst _ _\n\ninstance prod.mono_lift_of_mono_right {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y)\n  [mono g] : mono (prod.lift f g) :=\nmono_of_mono_fac $ prod.lift_snd _ _\n\ninstance coprod.epi_desc_of_epi_left {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W)\n  [epi f] : epi (coprod.desc f g) :=\nepi_of_epi_fac $ coprod.inl_desc _ _\n\ninstance coprod.epi_desc_of_epi_right {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W)\n  [epi g] : epi (coprod.desc f g) :=\nepi_of_epi_fac $ coprod.inr_desc _ _\n\n/-- If the product of `X` and `Y` exists, then every pair of morphisms `f : W ⟶ X` and `g : W ⟶ Y`\n    induces a morphism `l : W ⟶ X ⨯ Y` satisfying `l ≫ prod.fst = f` and `l ≫ prod.snd = g`. -/\ndef prod.lift' {W X Y : C} [has_binary_product X Y] (f : W ⟶ X) (g : W ⟶ Y) :\n  {l : W ⟶ X ⨯ Y // l ≫ prod.fst = f ∧ l ≫ prod.snd = g} :=\n⟨prod.lift f g, prod.lift_fst _ _, prod.lift_snd _ _⟩\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X ⟶ W` and\n    `g : Y ⟶ W` induces a morphism `l : X ⨿ Y ⟶ W` satisfying `coprod.inl ≫ l = f` and\n    `coprod.inr ≫ l = g`. -/\ndef coprod.desc' {W X Y : C} [has_binary_coproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) :\n  {l : X ⨿ Y ⟶ W // coprod.inl ≫ l = f ∧ coprod.inr ≫ l = g} :=\n⟨coprod.desc f g, coprod.inl_desc _ _, coprod.inr_desc _ _⟩\n\n/-- If the products `W ⨯ X` and `Y ⨯ Z` exist, then every pair of morphisms `f : W ⟶ Y` and\n    `g : X ⟶ Z` induces a morphism `prod.map f g : W ⨯ X ⟶ Y ⨯ Z`. -/\ndef prod.map {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : W ⨯ X ⟶ Y ⨯ Z :=\nlim_map (map_pair f g)\n\n/-- If the coproducts `W ⨿ X` and `Y ⨿ Z` exist, then every pair of morphisms `f : W ⟶ Y` and\n    `g : W ⟶ Z` induces a morphism `coprod.map f g : W ⨿ X ⟶ Y ⨿ Z`. -/\ndef coprod.map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : W ⨿ X ⟶ Y ⨿ Z :=\ncolim_map (map_pair f g)\n\nsection prod_lemmas\n\n-- Making the reassoc version of this a simp lemma seems to be more harmful than helpful.\n@[reassoc, simp]\nlemma prod.comp_lift {V W X Y : C} [has_binary_product X Y] (f : V ⟶ W) (g : W ⟶ X) (h : W ⟶ Y) :\n  f ≫ prod.lift g h = prod.lift (f ≫ g) (f ≫ h) :=\nby { ext; simp }\n\nlemma prod.comp_diag {X Y : C} [has_binary_product Y Y] (f : X ⟶ Y) :\n  f ≫ diag Y = prod.lift f f :=\nby simp\n\n@[simp, reassoc]\nlemma prod.map_fst {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : prod.map f g ≫ prod.fst = prod.fst ≫ f :=\nlim_map_π _ _\n\n@[simp, reassoc]\nlemma prod.map_snd {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : prod.map f g ≫ prod.snd = prod.snd ≫ g :=\nlim_map_π _ _\n\n@[simp] lemma prod.map_id_id {X Y : C} [has_binary_product X Y] :\n  prod.map (𝟙 X) (𝟙 Y) = 𝟙 _ :=\nby { ext; simp }\n\n@[simp] lemma prod.lift_fst_snd {X Y : C} [has_binary_product X Y] :\n  prod.lift prod.fst prod.snd = 𝟙 (X ⨯ Y) :=\nby { ext; simp }\n\n@[simp, reassoc] lemma prod.lift_map {V W X Y Z : C} [has_binary_product W X]\n  [has_binary_product Y Z] (f : V ⟶ W) (g : V ⟶ X) (h : W ⟶ Y) (k : X ⟶ Z) :\n  prod.lift f g ≫ prod.map h k = prod.lift (f ≫ h) (g ≫ k) :=\nby { ext; simp }\n\n@[simp] lemma prod.lift_fst_comp_snd_comp {W X Y Z : C} [has_binary_product W Y]\n  [has_binary_product X Z] (g : W ⟶ X) (g' : Y ⟶ Z) :\n  prod.lift (prod.fst ≫ g) (prod.snd ≫ g') = prod.map g g' :=\nby { rw ← prod.lift_map, simp }\n\n-- We take the right hand side here to be simp normal form, as this way composition lemmas for\n-- `f ≫ h` and `g ≫ k` can fire (eg `id_comp`) , while `map_fst` and `map_snd` can still work just\n-- as well.\n@[simp, reassoc]\nlemma prod.map_map {A₁ A₂ A₃ B₁ B₂ B₃ : C}\n  [has_binary_product A₁ B₁] [has_binary_product A₂ B₂] [has_binary_product A₃ B₃]\n  (f : A₁ ⟶ A₂) (g : B₁ ⟶ B₂) (h : A₂ ⟶ A₃) (k : B₂ ⟶ B₃) :\n  prod.map f g ≫ prod.map h k = prod.map (f ≫ h) (g ≫ k) :=\nby { ext; simp }\n\n-- TODO: is it necessary to weaken the assumption here?\n@[reassoc]\nlemma prod.map_swap {A B X Y : C} (f : A ⟶ B) (g : X ⟶ Y)\n  [has_limits_of_shape (discrete walking_pair) C] :\n  prod.map (𝟙 X) f ≫ prod.map g (𝟙 B) = prod.map g (𝟙 A) ≫ prod.map (𝟙 Y) f :=\nby simp\n\n@[reassoc] lemma prod.map_comp_id {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_product X W] [has_binary_product Z W] [has_binary_product Y W] :\n  prod.map (f ≫ g) (𝟙 W) = prod.map f (𝟙 W) ≫ prod.map g (𝟙 W) :=\nby simp\n\n@[reassoc] lemma prod.map_id_comp {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_product W X] [has_binary_product W Y] [has_binary_product W Z] :\n  prod.map (𝟙 W) (f ≫ g) = prod.map (𝟙 W) f ≫ prod.map (𝟙 W) g :=\nby simp\n\n/-- If the products `W ⨯ X` and `Y ⨯ Z` exist, then every pair of isomorphisms `f : W ≅ Y` and\n    `g : X ≅ Z` induces an isomorphism `prod.map_iso f g : W ⨯ X ≅ Y ⨯ Z`. -/\n@[simps]\ndef prod.map_iso {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ≅ Y) (g : X ≅ Z) : W ⨯ X ≅ Y ⨯ Z :=\n{ hom := prod.map f.hom g.hom,\n  inv := prod.map f.inv g.inv }\n\ninstance is_iso_prod {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) [is_iso f] [is_iso g] : is_iso (prod.map f g) :=\nis_iso.of_iso (prod.map_iso (as_iso f) (as_iso g))\n\ninstance prod.map_mono {C : Type*} [category C] {W X Y Z : C} (f : W ⟶ Y) (g : X ⟶ Z) [mono f]\n  [mono g] [has_binary_product W X] [has_binary_product Y Z] : mono (prod.map f g) :=\n⟨λ A i₁ i₂ h, begin\n  ext,\n  { rw ← cancel_mono f, simpa using congr_arg (λ f, f ≫ prod.fst) h },\n  { rw ← cancel_mono g, simpa using congr_arg (λ f, f ≫ prod.snd) h }\nend⟩\n\n@[simp, reassoc]\nlemma prod.diag_map {X Y : C} (f : X ⟶ Y) [has_binary_product X X] [has_binary_product Y Y] :\n  diag X ≫ prod.map f f = f ≫ diag Y :=\nby simp\n\n@[simp, reassoc]\nlemma prod.diag_map_fst_snd {X Y : C} [has_binary_product X Y]\n  [has_binary_product (X ⨯ Y) (X ⨯ Y)] :\n  diag (X ⨯ Y) ≫ prod.map prod.fst prod.snd = 𝟙 (X ⨯ Y) :=\nby simp\n\n@[simp, reassoc]\nlemma prod.diag_map_fst_snd_comp  [has_limits_of_shape (discrete walking_pair) C]\n  {X X' Y Y' : C} (g : X ⟶ Y) (g' : X' ⟶ Y') :\n  diag (X ⨯ X') ≫ prod.map (prod.fst ≫ g) (prod.snd ≫ g') = prod.map g g' :=\nby simp\n\ninstance {X : C} [has_binary_product X X] : split_mono (diag X) :=\n{ retraction := prod.fst }\n\nend prod_lemmas\n\nsection coprod_lemmas\n\n@[simp, reassoc]\nlemma coprod.desc_comp {V W X Y : C} [has_binary_coproduct X Y] (f : V ⟶ W) (g : X ⟶ V)\n  (h : Y ⟶ V) :\n  coprod.desc g h ≫ f = coprod.desc (g ≫ f) (h ≫ f) :=\nby { ext; simp }\n\nlemma coprod.diag_comp {X Y : C} [has_binary_coproduct X X] (f : X ⟶ Y) :\n  codiag X ≫ f = coprod.desc f f :=\nby simp\n\n@[simp, reassoc]\nlemma coprod.inl_map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : coprod.inl ≫ coprod.map f g = f ≫ coprod.inl :=\nι_colim_map _ _\n\n@[simp, reassoc]\nlemma coprod.inr_map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) : coprod.inr ≫ coprod.map f g = g ≫ coprod.inr :=\nι_colim_map _ _\n\n@[simp]\nlemma coprod.map_id_id {X Y : C} [has_binary_coproduct X Y] :\n  coprod.map (𝟙 X) (𝟙 Y) = 𝟙 _ :=\nby { ext; simp }\n\n@[simp]\nlemma coprod.desc_inl_inr {X Y : C} [has_binary_coproduct X Y] :\n  coprod.desc coprod.inl coprod.inr = 𝟙 (X ⨿ Y) :=\nby { ext; simp }\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_desc {S T U V W : C} [has_binary_coproduct U W] [has_binary_coproduct T V]\n  (f : U ⟶ S) (g : W ⟶ S) (h : T ⟶ U) (k : V ⟶ W) :\n  coprod.map h k ≫ coprod.desc f g = coprod.desc (h ≫ f) (k ≫ g) :=\nby { ext; simp }\n\n@[simp]\nlemma coprod.desc_comp_inl_comp_inr {W X Y Z : C}\n  [has_binary_coproduct W Y] [has_binary_coproduct X Z]\n  (g : W ⟶ X) (g' : Y ⟶ Z) :\n  coprod.desc (g ≫ coprod.inl) (g' ≫ coprod.inr) = coprod.map g g' :=\nby { rw ← coprod.map_desc, simp }\n\n-- We take the right hand side here to be simp normal form, as this way composition lemmas for\n-- `f ≫ h` and `g ≫ k` can fire (eg `id_comp`) , while `inl_map` and `inr_map` can still work just\n-- as well.\n@[simp, reassoc]\nlemma coprod.map_map {A₁ A₂ A₃ B₁ B₂ B₃ : C}\n  [has_binary_coproduct A₁ B₁] [has_binary_coproduct A₂ B₂] [has_binary_coproduct A₃ B₃]\n  (f : A₁ ⟶ A₂) (g : B₁ ⟶ B₂) (h : A₂ ⟶ A₃) (k : B₂ ⟶ B₃) :\n  coprod.map f g ≫ coprod.map h k = coprod.map (f ≫ h) (g ≫ k) :=\nby { ext; simp }\n\n-- I don't think it's a good idea to make any of the following three simp lemmas.\n@[reassoc]\nlemma coprod.map_swap {A B X Y : C} (f : A ⟶ B) (g : X ⟶ Y)\n  [has_colimits_of_shape (discrete walking_pair) C] :\n  coprod.map (𝟙 X) f ≫ coprod.map g (𝟙 B) = coprod.map g (𝟙 A) ≫ coprod.map (𝟙 Y) f :=\nby simp\n\n@[reassoc] lemma coprod.map_comp_id {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_coproduct Z W] [has_binary_coproduct Y W] [has_binary_coproduct X W] :\n  coprod.map (f ≫ g) (𝟙 W) = coprod.map f (𝟙 W) ≫ coprod.map g (𝟙 W) :=\nby simp\n\n@[reassoc] lemma coprod.map_id_comp {X Y Z W : C} (f : X ⟶ Y) (g : Y ⟶ Z)\n  [has_binary_coproduct W X] [has_binary_coproduct W Y] [has_binary_coproduct W Z] :\n  coprod.map (𝟙 W) (f ≫ g) = coprod.map (𝟙 W) f ≫ coprod.map (𝟙 W) g :=\nby simp\n\n/-- If the coproducts `W ⨿ X` and `Y ⨿ Z` exist, then every pair of isomorphisms `f : W ≅ Y` and\n    `g : W ≅ Z` induces a isomorphism `coprod.map_iso f g : W ⨿ X ≅ Y ⨿ Z`. -/\n@[simps]\ndef coprod.map_iso {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ≅ Y) (g : X ≅ Z) : W ⨿ X ≅ Y ⨿ Z :=\n{ hom := coprod.map f.hom g.hom,\n  inv := coprod.map f.inv g.inv }\n\ninstance is_iso_coprod {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W ⟶ Y) (g : X ⟶ Z) [is_iso f] [is_iso g] : is_iso (coprod.map f g) :=\nis_iso.of_iso (coprod.map_iso (as_iso f) (as_iso g))\n\ninstance coprod.map_epi {C : Type*} [category C] {W X Y Z : C} (f : W ⟶ Y) (g : X ⟶ Z) [epi f]\n  [epi g] [has_binary_coproduct W X] [has_binary_coproduct Y Z] : epi (coprod.map f g) :=\n⟨λ A i₁ i₂ h, begin\n  ext,\n  { rw ← cancel_epi f, simpa using congr_arg (λ f, coprod.inl ≫ f) h },\n  { rw ← cancel_epi g, simpa using congr_arg (λ f, coprod.inr ≫ f) h }\nend⟩\n\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_codiag {X Y : C} (f : X ⟶ Y) [has_binary_coproduct X X]\n  [has_binary_coproduct Y Y] :\n  coprod.map f f ≫ codiag Y = codiag X ≫ f :=\nby simp\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_inl_inr_codiag {X Y : C} [has_binary_coproduct X Y]\n  [has_binary_coproduct (X ⨿ Y) (X ⨿ Y)] :\n  coprod.map coprod.inl coprod.inr ≫ codiag (X ⨿ Y) = 𝟙 (X ⨿ Y) :=\nby simp\n\n-- The simp linter says simp can prove the reassoc version of this lemma.\n@[reassoc, simp]\nlemma coprod.map_comp_inl_inr_codiag [has_colimits_of_shape (discrete walking_pair) C]\n  {X X' Y Y' : C} (g : X ⟶ Y) (g' : X' ⟶ Y') :\n  coprod.map (g ≫ coprod.inl) (g' ≫ coprod.inr) ≫ codiag (Y ⨿ Y') = coprod.map g g' :=\nby simp\n\nend coprod_lemmas\n\nvariables (C)\n\n/--\n`has_binary_products` represents a choice of product for every pair of objects.\n\nSee <https://stacks.math.columbia.edu/tag/001T>.\n-/\nabbreviation has_binary_products := has_limits_of_shape (discrete walking_pair) C\n\n/--\n`has_binary_coproducts` represents a choice of coproduct for every pair of objects.\n\nSee <https://stacks.math.columbia.edu/tag/04AP>.\n-/\nabbreviation has_binary_coproducts := has_colimits_of_shape (discrete walking_pair) C\n\n/-- If `C` has all limits of diagrams `pair X Y`, then it has all binary products -/\nlemma has_binary_products_of_has_limit_pair [Π {X Y : C}, has_limit (pair X Y)] :\n  has_binary_products C :=\n{ has_limit := λ F, has_limit_of_iso (diagram_iso_pair F).symm }\n\n/-- If `C` has all colimits of diagrams `pair X Y`, then it has all binary coproducts -/\nlemma has_binary_coproducts_of_has_colimit_pair [Π {X Y : C}, has_colimit (pair X Y)] :\n  has_binary_coproducts C :=\n{ has_colimit := λ F, has_colimit_of_iso (diagram_iso_pair F) }\n\nsection\nvariables {C}\n\n/-- The braiding isomorphism which swaps a binary product. -/\n@[simps] def prod.braiding (P Q : C) [has_binary_product P Q] [has_binary_product Q P] :\n  P ⨯ Q ≅ Q ⨯ P :=\n{ hom := prod.lift prod.snd prod.fst,\n  inv := prod.lift prod.snd prod.fst }\n\n/-- The braiding isomorphism can be passed through a map by swapping the order. -/\n@[reassoc] lemma braid_natural [has_binary_products C] {W X Y Z : C} (f : X ⟶ Y) (g : Z ⟶ W) :\n  prod.map f g ≫ (prod.braiding _ _).hom = (prod.braiding _ _).hom ≫ prod.map g f :=\nby simp\n\n@[reassoc] lemma prod.symmetry' (P Q : C) [has_binary_product P Q] [has_binary_product Q P] :\n  prod.lift prod.snd prod.fst ≫ prod.lift prod.snd prod.fst = 𝟙 (P ⨯ Q) :=\n(prod.braiding _ _).hom_inv_id\n\n/-- The braiding isomorphism is symmetric. -/\n@[reassoc] lemma prod.symmetry (P Q : C) [has_binary_product P Q] [has_binary_product Q P] :\n  (prod.braiding P Q).hom ≫ (prod.braiding Q P).hom = 𝟙 _ :=\n(prod.braiding _ _).hom_inv_id\n\n/-- The associator isomorphism for binary products. -/\n@[simps] def prod.associator [has_binary_products C] (P Q R : C) :\n  (P ⨯ Q) ⨯ R ≅ P ⨯ (Q ⨯ R) :=\n{ hom :=\n  prod.lift\n    (prod.fst ≫ prod.fst)\n    (prod.lift (prod.fst ≫ prod.snd) prod.snd),\n  inv :=\n  prod.lift\n    (prod.lift prod.fst (prod.snd ≫ prod.fst))\n    (prod.snd ≫ prod.snd) }\n\n@[reassoc]\nlemma prod.pentagon [has_binary_products C] (W X Y Z : C) :\n  prod.map ((prod.associator W X Y).hom) (𝟙 Z) ≫\n      (prod.associator W (X ⨯ Y) Z).hom ≫ prod.map (𝟙 W) ((prod.associator X Y Z).hom) =\n    (prod.associator (W ⨯ X) Y Z).hom ≫ (prod.associator W X (Y ⨯ Z)).hom :=\nby simp\n\n@[reassoc]\nlemma prod.associator_naturality [has_binary_products C] {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C}\n  (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :\n  prod.map (prod.map f₁ f₂) f₃ ≫ (prod.associator Y₁ Y₂ Y₃).hom =\n    (prod.associator X₁ X₂ X₃).hom ≫ prod.map f₁ (prod.map f₂ f₃) :=\nby simp\n\nvariables [has_terminal C]\n\n/-- The left unitor isomorphism for binary products with the terminal object. -/\n@[simps] def prod.left_unitor (P : C) [has_binary_product (⊤_ C) P] :\n  ⊤_ C ⨯ P ≅ P :=\n{ hom := prod.snd,\n  inv := prod.lift (terminal.from P) (𝟙 _) }\n\n/-- The right unitor isomorphism for binary products with the terminal object. -/\n@[simps] def prod.right_unitor (P : C) [has_binary_product P (⊤_ C)] :\n  P ⨯ ⊤_ C ≅ P :=\n{ hom := prod.fst,\n  inv := prod.lift (𝟙 _) (terminal.from P) }\n\n@[reassoc]\nlemma prod.left_unitor_hom_naturality [has_binary_products C] (f : X ⟶ Y) :\n  prod.map (𝟙 _) f ≫ (prod.left_unitor Y).hom = (prod.left_unitor X).hom ≫ f :=\nprod.map_snd _ _\n\n@[reassoc]\nlemma prod.left_unitor_inv_naturality [has_binary_products C] (f : X ⟶ Y) :\n  (prod.left_unitor X).inv ≫ prod.map (𝟙 _) f = f ≫ (prod.left_unitor Y).inv :=\nby rw [iso.inv_comp_eq, ← category.assoc, iso.eq_comp_inv, prod.left_unitor_hom_naturality]\n\n@[reassoc]\nlemma prod.right_unitor_hom_naturality [has_binary_products C] (f : X ⟶ Y) :\n  prod.map f (𝟙 _) ≫ (prod.right_unitor Y).hom = (prod.right_unitor X).hom ≫ f :=\nprod.map_fst _ _\n\n@[reassoc]\nlemma prod_right_unitor_inv_naturality [has_binary_products C] (f : X ⟶ Y) :\n  (prod.right_unitor X).inv ≫ prod.map f (𝟙 _) = f ≫ (prod.right_unitor Y).inv :=\nby rw [iso.inv_comp_eq, ← category.assoc, iso.eq_comp_inv, prod.right_unitor_hom_naturality]\n\nlemma prod.triangle [has_binary_products C] (X Y : C) :\n  (prod.associator X (⊤_ C) Y).hom ≫ prod.map (𝟙 X) ((prod.left_unitor Y).hom) =\n    prod.map ((prod.right_unitor X).hom) (𝟙 Y) :=\nby tidy\n\nend\n\nsection\n\nvariables {C} [has_binary_coproducts C]\n\n/-- The braiding isomorphism which swaps a binary coproduct. -/\n@[simps] def coprod.braiding (P Q : C) : P ⨿ Q ≅ Q ⨿ P :=\n{ hom := coprod.desc coprod.inr coprod.inl,\n  inv := coprod.desc coprod.inr coprod.inl }\n\n@[reassoc] lemma coprod.symmetry' (P Q : C) :\n  coprod.desc coprod.inr coprod.inl ≫ coprod.desc coprod.inr coprod.inl = 𝟙 (P ⨿ Q) :=\n(coprod.braiding _ _).hom_inv_id\n\n/-- The braiding isomorphism is symmetric. -/\nlemma coprod.symmetry (P Q : C) :\n  (coprod.braiding P Q).hom ≫ (coprod.braiding Q P).hom = 𝟙 _ :=\ncoprod.symmetry' _ _\n\n/-- The associator isomorphism for binary coproducts. -/\n@[simps] def coprod.associator\n  (P Q R : C) : (P ⨿ Q) ⨿ R ≅ P ⨿ (Q ⨿ R) :=\n{ hom :=\n  coprod.desc\n    (coprod.desc coprod.inl (coprod.inl ≫ coprod.inr))\n    (coprod.inr ≫ coprod.inr),\n  inv :=\n  coprod.desc\n    (coprod.inl ≫ coprod.inl)\n    (coprod.desc (coprod.inr ≫ coprod.inl) coprod.inr) }\n\nlemma coprod.pentagon (W X Y Z : C) :\n  coprod.map ((coprod.associator W X Y).hom) (𝟙 Z) ≫\n      (coprod.associator W (X ⨿ Y) Z).hom ≫ coprod.map (𝟙 W) ((coprod.associator X Y Z).hom) =\n    (coprod.associator (W ⨿ X) Y Z).hom ≫ (coprod.associator W X (Y ⨿ Z)).hom :=\nby simp\n\nlemma coprod.associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂)\n  (f₃ : X₃ ⟶ Y₃) :\n  coprod.map (coprod.map f₁ f₂) f₃ ≫ (coprod.associator Y₁ Y₂ Y₃).hom =\n    (coprod.associator X₁ X₂ X₃).hom ≫ coprod.map f₁ (coprod.map f₂ f₃) :=\nby simp\n\nvariables [has_initial C]\n\n/-- The left unitor isomorphism for binary coproducts with the initial object. -/\n@[simps] def coprod.left_unitor\n  (P : C) : ⊥_ C ⨿ P ≅ P :=\n{ hom := coprod.desc (initial.to P) (𝟙 _),\n  inv := coprod.inr }\n\n/-- The right unitor isomorphism for binary coproducts with the initial object. -/\n@[simps] def coprod.right_unitor\n  (P : C) : P ⨿ ⊥_ C ≅ P :=\n{ hom := coprod.desc (𝟙 _) (initial.to P),\n  inv := coprod.inl }\n\nlemma coprod.triangle (X Y : C) :\n  (coprod.associator X (⊥_ C) Y).hom ≫ coprod.map (𝟙 X) ((coprod.left_unitor Y).hom) =\n    coprod.map ((coprod.right_unitor X).hom) (𝟙 Y) :=\nby tidy\n\nend\n\nsection prod_functor\nvariables {C} [has_binary_products C]\n\n/-- The binary product functor. -/\n@[simps]\ndef prod.functor : C ⥤ C ⥤ C :=\n{ obj := λ X, { obj := λ Y, X ⨯ Y, map := λ Y Z, prod.map (𝟙 X) },\n  map := λ Y Z f, { app := λ T, prod.map f (𝟙 T) }}\n\n/-- The product functor can be decomposed. -/\ndef prod.functor_left_comp (X Y : C) :\n  prod.functor.obj (X ⨯ Y) ≅ prod.functor.obj Y ⋙ prod.functor.obj X :=\nnat_iso.of_components (prod.associator _ _) (by tidy)\n\nend prod_functor\n\nsection coprod_functor\nvariables {C} [has_binary_coproducts C]\n\n/-- The binary coproduct functor. -/\n@[simps]\ndef coprod.functor : C ⥤ C ⥤ C :=\n{ obj := λ X, { obj := λ Y, X ⨿ Y, map := λ Y Z, coprod.map (𝟙 X) },\n  map := λ Y Z f, { app := λ T, coprod.map f (𝟙 T) }}\n\n/-- The coproduct functor can be decomposed. -/\ndef coprod.functor_left_comp (X Y : C) :\n  coprod.functor.obj (X ⨿ Y) ≅ coprod.functor.obj Y ⋙ coprod.functor.obj X :=\nnat_iso.of_components (coprod.associator _ _) (by tidy)\n\nend coprod_functor\n\nsection prod_comparison\n\nuniverse w\n\nvariables {C} {D : Type u₂} [category.{w} D]\nvariables (F : C ⥤ D) {A A' B B' : C}\nvariables [has_binary_product A B] [has_binary_product A' B']\nvariables [has_binary_product (F.obj A) (F.obj B)] [has_binary_product (F.obj A') (F.obj B')]\n/--\nThe product comparison morphism.\n\nIn `category_theory/limits/preserves` we show this is always an iso iff F preserves binary products.\n-/\ndef prod_comparison (F : C ⥤ D) (A B : C)\n  [has_binary_product A B] [has_binary_product (F.obj A) (F.obj B)] :\n  F.obj (A ⨯ B) ⟶ F.obj A ⨯ F.obj B :=\nprod.lift (F.map prod.fst) (F.map prod.snd)\n\n@[simp, reassoc]\nlemma prod_comparison_fst :\n  prod_comparison F A B ≫ prod.fst = F.map prod.fst :=\nprod.lift_fst _ _\n\n@[simp, reassoc]\nlemma prod_comparison_snd :\n  prod_comparison F A B ≫ prod.snd = F.map prod.snd :=\nprod.lift_snd _ _\n\n/-- Naturality of the prod_comparison morphism in both arguments. -/\n@[reassoc] lemma prod_comparison_natural (f : A ⟶ A') (g : B ⟶ B') :\n  F.map (prod.map f g) ≫ prod_comparison F A' B' =\n    prod_comparison F A B ≫ prod.map (F.map f) (F.map g) :=\nbegin\n  rw [prod_comparison, prod_comparison, prod.lift_map, ← F.map_comp, ← F.map_comp,\n      prod.comp_lift, ← F.map_comp, prod.map_fst, ← F.map_comp, prod.map_snd]\nend\n\n/--\nThe product comparison morphism from `F(A ⨯ -)` to `FA ⨯ F-`, whose components are given by\n`prod_comparison`.\n-/\n@[simps]\ndef prod_comparison_nat_trans [has_binary_products C] [has_binary_products D]\n  (F : C ⥤ D) (A : C) :\n  prod.functor.obj A ⋙ F ⟶ F ⋙ prod.functor.obj (F.obj A) :=\n{ app := λ B, prod_comparison F A B,\n  naturality' := λ B B' f, by simp [prod_comparison_natural] }\n\n@[reassoc]\nlemma inv_prod_comparison_map_fst [is_iso (prod_comparison F A B)] :\n  inv (prod_comparison F A B) ≫ F.map prod.fst = prod.fst :=\nby simp [is_iso.inv_comp_eq]\n\n@[reassoc]\nlemma inv_prod_comparison_map_snd [is_iso (prod_comparison F A B)] :\n  inv (prod_comparison F A B) ≫ F.map prod.snd = prod.snd :=\nby simp [is_iso.inv_comp_eq]\n\n/-- If the product comparison morphism is an iso, its inverse is natural. -/\n@[reassoc]\nlemma prod_comparison_inv_natural (f : A ⟶ A') (g : B ⟶ B')\n  [is_iso (prod_comparison F A B)] [is_iso (prod_comparison F A' B')] :\n  inv (prod_comparison F A B) ≫ F.map (prod.map f g) =\n    prod.map (F.map f) (F.map g) ≫ inv (prod_comparison F A' B') :=\nby rw [is_iso.eq_comp_inv, category.assoc, is_iso.inv_comp_eq, prod_comparison_natural]\n\n/--\nThe natural isomorphism `F(A ⨯ -) ≅ FA ⨯ F-`, provided each `prod_comparison F A B` is an\nisomorphism (as `B` changes).\n-/\n@[simps {rhs_md := semireducible}]\ndef prod_comparison_nat_iso [has_binary_products C] [has_binary_products D]\n  (A : C) [∀ B, is_iso (prod_comparison F A B)] :\n  prod.functor.obj A ⋙ F ≅ F ⋙ prod.functor.obj (F.obj A) :=\n{ hom := prod_comparison_nat_trans F A\n  ..(@as_iso _ _ _ _ _ (nat_iso.is_iso_of_is_iso_app ⟨_, _⟩)) }\n\nend prod_comparison\n\nsection coprod_comparison\n\nuniverse w\n\nvariables {C} {D : Type u₂} [category.{w} D]\nvariables (F : C ⥤ D) {A A' B B' : C}\nvariables [has_binary_coproduct A B] [has_binary_coproduct A' B']\nvariables [has_binary_coproduct (F.obj A) (F.obj B)] [has_binary_coproduct (F.obj A') (F.obj B')]\n/--\nThe coproduct comparison morphism.\n\nIn `category_theory/limits/preserves` we show\nthis is always an iso iff F preserves binary coproducts.\n-/\ndef coprod_comparison (F : C ⥤ D) (A B : C)\n  [has_binary_coproduct A B] [has_binary_coproduct (F.obj A) (F.obj B)] :\n  F.obj A ⨿ F.obj B ⟶ F.obj (A ⨿ B) :=\ncoprod.desc (F.map coprod.inl) (F.map coprod.inr)\n\n@[simp, reassoc]\nlemma coprod_comparison_inl :\n  coprod.inl ≫ coprod_comparison F A B  = F.map coprod.inl :=\ncoprod.inl_desc _ _\n\n@[simp, reassoc]\nlemma coprod_comparison_inr :\n  coprod.inr ≫ coprod_comparison F A B = F.map coprod.inr :=\ncoprod.inr_desc _ _\n\n/-- Naturality of the coprod_comparison morphism in both arguments. -/\n@[reassoc] lemma coprod_comparison_natural (f : A ⟶ A') (g : B ⟶ B') :\n  coprod_comparison F A B ≫ F.map (coprod.map f g) =\n    coprod.map (F.map f) (F.map g) ≫ coprod_comparison F A' B' :=\nbegin\n  rw [coprod_comparison, coprod_comparison, coprod.map_desc, ← F.map_comp, ← F.map_comp,\n      coprod.desc_comp, ← F.map_comp, coprod.inl_map, ← F.map_comp, coprod.inr_map]\nend\n\n/--\nThe coproduct comparison morphism from `FA ⨿ F-` to `F(A ⨿ -)`, whose components are given by\n`coprod_comparison`.\n-/\n@[simps]\ndef coprod_comparison_nat_trans [has_binary_coproducts C] [has_binary_coproducts D]\n  (F : C ⥤ D) (A : C) :\n  F ⋙ coprod.functor.obj (F.obj A) ⟶ coprod.functor.obj A ⋙ F :=\n{ app := λ B, coprod_comparison F A B,\n  naturality' := λ B B' f, by simp [coprod_comparison_natural] }\n\n@[reassoc]\nlemma map_inl_inv_coprod_comparison [is_iso (coprod_comparison F A B)] :\n  F.map coprod.inl ≫ inv (coprod_comparison F A B) = coprod.inl :=\nby simp [is_iso.inv_comp_eq]\n\n@[reassoc]\nlemma map_inr_inv_coprod_comparison [is_iso (coprod_comparison F A B)] :\n  F.map coprod.inr ≫ inv (coprod_comparison F A B) = coprod.inr :=\nby simp [is_iso.inv_comp_eq]\n\n/-- If the coproduct comparison morphism is an iso, its inverse is natural. -/\n@[reassoc]\nlemma coprod_comparison_inv_natural (f : A ⟶ A') (g : B ⟶ B')\n  [is_iso (coprod_comparison F A B)] [is_iso (coprod_comparison F A' B')] :\n  inv (coprod_comparison F A B) ≫ coprod.map (F.map f) (F.map g) =\n    F.map (coprod.map f g) ≫ inv (coprod_comparison F A' B') :=\nby rw [is_iso.eq_comp_inv, category.assoc, is_iso.inv_comp_eq, coprod_comparison_natural]\n\n/--\nThe natural isomorphism `FA ⨿ F- ≅ F(A ⨿ -)`, provided each `coprod_comparison F A B` is an\nisomorphism (as `B` changes).\n-/\n@[simps {rhs_md := semireducible}]\ndef coprod_comparison_nat_iso [has_binary_coproducts C] [has_binary_coproducts D]\n  (A : C) [∀ B, is_iso (coprod_comparison F A B)] :\n  F ⋙ coprod.functor.obj (F.obj A) ≅ coprod.functor.obj A ⋙ F :=\n{ hom := coprod_comparison_nat_trans F A\n  ..(@as_iso _ _ _ _ _ (nat_iso.is_iso_of_is_iso_app ⟨_, _⟩)) }\n\nend coprod_comparison\n\nend category_theory.limits\n\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u} [category.{v} C]\n\n/-- Auxiliary definition for `over.coprod`. -/\n@[simps]\ndef over.coprod_obj [has_binary_coproducts C] {A : C} : over A → over A ⥤ over A := λ f,\n{ obj := λ g, over.mk (coprod.desc f.hom g.hom),\n  map := λ g₁ g₂ k, over.hom_mk (coprod.map (𝟙 _) k.left) }\n\n/-- A category with binary coproducts has a functorial `sup` operation on over categories. -/\n@[simps]\ndef over.coprod [has_binary_coproducts C] {A : C} : over A ⥤ over A ⥤ over A :=\n{ obj := λ f, over.coprod_obj f,\n  map := λ f₁ f₂ k,\n  { app := λ g, over.hom_mk (coprod.map k.left (𝟙 _))\n      (by { dsimp, rw [coprod.map_desc, category.id_comp, over.w k] }),\n    naturality' := λ f g k, by ext; { dsimp, simp, }, },\n  map_id' := λ X, by ext; { dsimp, simp, },\n  map_comp' := λ X Y Z f g, by ext; { dsimp, simp, }, }.\n\nend category_theory\n", "meta": {"author": "Parinya-Siri", "repo": "lean-machine-learning", "sha": "ec610bac246ae7108fc6f0c140b3440f0fbacc52", "save_path": "github-repos/lean/Parinya-Siri-lean-machine-learning", "path": "github-repos/lean/Parinya-Siri-lean-machine-learning/lean-machine-learning-ec610bac246ae7108fc6f0c140b3440f0fbacc52/matlib/category_theory/limits/shapes/binary_products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6477982179521103, "lm_q1q2_score": 0.45084056272560613}}
{"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon, Patrick Massot\n\n! This file was ported from Lean 3 source module algebra.order.pi\n! leanprover-community/mathlib commit c3291da49cfa65f0d43b094750541c0731edc932\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Order.Ring.Defs\nimport Mathbin.Algebra.Ring.Pi\nimport Mathbin.Tactic.Positivity\n\n/-!\n# Pi instances for ordered groups and monoids\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines instances for ordered group, monoid, and related structures on Pi types.\n-/\n\n\nuniverse u v w\n\nvariable {ι α β : Type _}\n\nvariable {I : Type u}\n\n-- The indexing type\nvariable {f : I → Type v}\n\n-- The family of types already equipped with instances\nvariable (x y : ∀ i, f i) (i : I)\n\nnamespace Pi\n\n#print Pi.orderedCommMonoid /-\n/-- The product of a family of ordered commutative monoids is an ordered commutative monoid. -/\n@[to_additive\n      \"The product of a family of ordered additive commutative monoids is\\n  an ordered additive commutative monoid.\"]\ninstance orderedCommMonoid {ι : Type _} {Z : ι → Type _} [∀ i, OrderedCommMonoid (Z i)] :\n    OrderedCommMonoid (∀ i, Z i) :=\n  { Pi.partialOrder, Pi.commMonoid with\n    mul_le_mul_left := fun f g w h i => mul_le_mul_left' (w i) _ }\n#align pi.ordered_comm_monoid Pi.orderedCommMonoid\n#align pi.ordered_add_comm_monoid Pi.orderedAddCommMonoid\n-/\n\n@[to_additive]\ninstance {ι : Type _} {α : ι → Type _} [∀ i, LE (α i)] [∀ i, Mul (α i)] [∀ i, ExistsMulOfLE (α i)] :\n    ExistsMulOfLE (∀ i, α i) :=\n  ⟨fun a b h =>\n    ⟨fun i => (exists_mul_of_le <| h i).some,\n      funext fun i => (exists_mul_of_le <| h i).choose_spec⟩⟩\n\n/-- The product of a family of canonically ordered monoids is a canonically ordered monoid. -/\n@[to_additive\n      \"The product of a family of canonically ordered additive monoids is\\n  a canonically ordered additive monoid.\"]\ninstance {ι : Type _} {Z : ι → Type _} [∀ i, CanonicallyOrderedMonoid (Z i)] :\n    CanonicallyOrderedMonoid (∀ i, Z i) :=\n  { Pi.orderBot, Pi.orderedCommMonoid, Pi.existsMulOfLe with\n    le_self_mul := fun f g i => le_self_mul }\n\n#print Pi.orderedCancelCommMonoid /-\n@[to_additive]\ninstance orderedCancelCommMonoid [∀ i, OrderedCancelCommMonoid <| f i] :\n    OrderedCancelCommMonoid (∀ i : I, f i) := by\n  refine_struct\n      { Pi.partialOrder, Pi.monoid with\n        mul := (· * ·)\n        one := (1 : ∀ i, f i)\n        le := (· ≤ ·)\n        lt := (· < ·)\n        npow := Monoid.npow } <;>\n    pi_instance_derive_field\n#align pi.ordered_cancel_comm_monoid Pi.orderedCancelCommMonoid\n#align pi.ordered_cancel_add_comm_monoid Pi.orderedAddCancelCommMonoid\n-/\n\n#print Pi.orderedCommGroup /-\n@[to_additive]\ninstance orderedCommGroup [∀ i, OrderedCommGroup <| f i] : OrderedCommGroup (∀ i : I, f i) :=\n  { Pi.commGroup, Pi.orderedCommMonoid with\n    mul := (· * ·)\n    one := (1 : ∀ i, f i)\n    le := (· ≤ ·)\n    lt := (· < ·)\n    npow := Monoid.npow }\n#align pi.ordered_comm_group Pi.orderedCommGroup\n#align pi.ordered_add_comm_group Pi.orderedAddCommGroup\n-/\n\ninstance [∀ i, OrderedSemiring (f i)] : OrderedSemiring (∀ i, f i) :=\n  { Pi.semiring,\n    Pi.partialOrder with\n    add_le_add_left := fun a b hab c i => add_le_add_left (hab _) _\n    zero_le_one := fun _ => zero_le_one\n    mul_le_mul_of_nonneg_left := fun a b c hab hc i => mul_le_mul_of_nonneg_left (hab _) <| hc _\n    mul_le_mul_of_nonneg_right := fun a b c hab hc i => mul_le_mul_of_nonneg_right (hab _) <| hc _ }\n\ninstance [∀ i, OrderedCommSemiring (f i)] : OrderedCommSemiring (∀ i, f i) :=\n  { Pi.commSemiring, Pi.orderedSemiring with }\n\ninstance [∀ i, OrderedRing (f i)] : OrderedRing (∀ i, f i) :=\n  { Pi.ring, Pi.orderedSemiring with mul_nonneg := fun a b ha hb i => mul_nonneg (ha _) (hb _) }\n\ninstance [∀ i, OrderedCommRing (f i)] : OrderedCommRing (∀ i, f i) :=\n  { Pi.commRing, Pi.orderedRing with }\n\nend Pi\n\nnamespace Function\n\nvariable (β) [One α] [Preorder α] {a : α}\n\n/- warning: function.one_le_const_of_one_le -> Function.one_le_const_of_one_le is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (β : Type.{u2}) [_inst_1 : One.{u1} α] [_inst_2 : Preorder.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) a) -> (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u1} α _inst_2)) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (OfNat.mk.{max u2 u1} (β -> α) 1 (One.one.{max u2 u1} (β -> α) (Pi.instOne.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_1))))) (Function.const.{succ u1, succ u2} α β a))\nbut is expected to have type\n  forall {α : Type.{u2}} (β : Type.{u1}) [_inst_1 : One.{u2} α] [_inst_2 : Preorder.{u2} α] {a : α}, (LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1)) a) -> (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u1, u2} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u2} α _inst_2)) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (One.toOfNat1.{max u2 u1} (β -> α) (Pi.instOne.{u1, u2} β (fun (a._@.Init.Prelude._hyg.54 : β) => α) (fun (i : β) => _inst_1)))) (Function.const.{succ u2, succ u1} α β a))\nCase conversion may be inaccurate. Consider using '#align function.one_le_const_of_one_le Function.one_le_const_of_one_leₓ'. -/\n@[to_additive const_nonneg_of_nonneg]\ntheorem one_le_const_of_one_le (ha : 1 ≤ a) : 1 ≤ const β a := fun _ => ha\n#align function.one_le_const_of_one_le Function.one_le_const_of_one_le\n#align function.const_nonneg_of_nonneg Function.const_nonneg_of_nonneg\n\n/- warning: function.const_le_one_of_le_one -> Function.const_le_one_of_le_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} (β : Type.{u2}) [_inst_1 : One.{u1} α] [_inst_2 : Preorder.{u1} α] {a : α}, (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1)))) -> (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u1} α _inst_2)) (Function.const.{succ u1, succ u2} α β a) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (OfNat.mk.{max u2 u1} (β -> α) 1 (One.one.{max u2 u1} (β -> α) (Pi.instOne.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_1))))))\nbut is expected to have type\n  forall {α : Type.{u2}} (β : Type.{u1}) [_inst_1 : One.{u2} α] [_inst_2 : Preorder.{u2} α] {a : α}, (LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) a (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1))) -> (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u1, u2} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u2} α _inst_2)) (Function.const.{succ u2, succ u1} α β a) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (One.toOfNat1.{max u2 u1} (β -> α) (Pi.instOne.{u1, u2} β (fun (a._@.Init.Prelude._hyg.54 : β) => α) (fun (i : β) => _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align function.const_le_one_of_le_one Function.const_le_one_of_le_oneₓ'. -/\n@[to_additive]\ntheorem const_le_one_of_le_one (ha : a ≤ 1) : const β a ≤ 1 := fun _ => ha\n#align function.const_le_one_of_le_one Function.const_le_one_of_le_one\n#align function.const_nonpos_of_nonpos Function.const_nonpos_of_nonpos\n\nvariable {β} [Nonempty β]\n\n/- warning: function.one_le_const -> Function.one_le_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : One.{u1} α] [_inst_2 : Preorder.{u1} α] {a : α} [_inst_3 : Nonempty.{succ u2} β], Iff (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u1} α _inst_2)) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (OfNat.mk.{max u2 u1} (β -> α) 1 (One.one.{max u2 u1} (β -> α) (Pi.instOne.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_1))))) (Function.const.{succ u1, succ u2} α β a)) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : One.{u2} α] [_inst_2 : Preorder.{u2} α] {a : α} [_inst_3 : Nonempty.{succ u1} β], Iff (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u1, u2} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u2} α _inst_2)) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (One.toOfNat1.{max u2 u1} (β -> α) (Pi.instOne.{u1, u2} β (fun (a._@.Init.Prelude._hyg.54 : β) => α) (fun (i : β) => _inst_1)))) (Function.const.{succ u2, succ u1} α β a)) (LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align function.one_le_const Function.one_le_constₓ'. -/\n@[simp, to_additive const_nonneg]\ntheorem one_le_const : 1 ≤ const β a ↔ 1 ≤ a :=\n  @const_le_const _ _ _ _ 1 _\n#align function.one_le_const Function.one_le_const\n#align function.const_nonneg Function.const_nonneg\n\n/- warning: function.one_lt_const -> Function.one_lt_const is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : One.{u1} α] [_inst_2 : Preorder.{u1} α] {a : α} [_inst_3 : Nonempty.{succ u2} β], Iff (LT.lt.{max u2 u1} (β -> α) (Preorder.toLT.{max u2 u1} (β -> α) (Pi.preorder.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_2))) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (OfNat.mk.{max u2 u1} (β -> α) 1 (One.one.{max u2 u1} (β -> α) (Pi.instOne.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_1))))) (Function.const.{succ u1, succ u2} α β a)) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))) a)\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : One.{u2} α] [_inst_2 : Preorder.{u2} α] {a : α} [_inst_3 : Nonempty.{succ u1} β], Iff (LT.lt.{max u2 u1} (β -> α) (Preorder.toLT.{max u2 u1} (β -> α) (Pi.preorder.{u1, u2} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_2))) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (One.toOfNat1.{max u2 u1} (β -> α) (Pi.instOne.{u1, u2} β (fun (a._@.Init.Prelude._hyg.54 : β) => α) (fun (i : β) => _inst_1)))) (Function.const.{succ u2, succ u1} α β a)) (LT.lt.{u2} α (Preorder.toLT.{u2} α _inst_2) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align function.one_lt_const Function.one_lt_constₓ'. -/\n@[simp, to_additive const_pos]\ntheorem one_lt_const : 1 < const β a ↔ 1 < a :=\n  @const_lt_const _ _ _ _ 1 a\n#align function.one_lt_const Function.one_lt_const\n#align function.const_pos Function.const_pos\n\n/- warning: function.const_le_one -> Function.const_le_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : One.{u1} α] [_inst_2 : Preorder.{u1} α] {a : α} [_inst_3 : Nonempty.{succ u2} β], Iff (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u1} α _inst_2)) (Function.const.{succ u1, succ u2} α β a) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (OfNat.mk.{max u2 u1} (β -> α) 1 (One.one.{max u2 u1} (β -> α) (Pi.instOne.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_1)))))) (LE.le.{u1} α (Preorder.toLE.{u1} α _inst_2) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : One.{u2} α] [_inst_2 : Preorder.{u2} α] {a : α} [_inst_3 : Nonempty.{succ u1} β], Iff (LE.le.{max u2 u1} (β -> α) (Pi.hasLe.{u1, u2} β (fun (ᾰ : β) => α) (fun (i : β) => Preorder.toLE.{u2} α _inst_2)) (Function.const.{succ u2, succ u1} α β a) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (One.toOfNat1.{max u2 u1} (β -> α) (Pi.instOne.{u1, u2} β (fun (a._@.Init.Prelude._hyg.54 : β) => α) (fun (i : β) => _inst_1))))) (LE.le.{u2} α (Preorder.toLE.{u2} α _inst_2) a (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align function.const_le_one Function.const_le_oneₓ'. -/\n@[simp, to_additive]\ntheorem const_le_one : const β a ≤ 1 ↔ a ≤ 1 :=\n  @const_le_const _ _ _ _ _ 1\n#align function.const_le_one Function.const_le_one\n#align function.const_nonpos Function.const_nonpos\n\n/- warning: function.const_lt_one -> Function.const_lt_one is a dubious translation:\nlean 3 declaration is\n  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : One.{u1} α] [_inst_2 : Preorder.{u1} α] {a : α} [_inst_3 : Nonempty.{succ u2} β], Iff (LT.lt.{max u2 u1} (β -> α) (Preorder.toLT.{max u2 u1} (β -> α) (Pi.preorder.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_2))) (Function.const.{succ u1, succ u2} α β a) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (OfNat.mk.{max u2 u1} (β -> α) 1 (One.one.{max u2 u1} (β -> α) (Pi.instOne.{u2, u1} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_1)))))) (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) a (OfNat.ofNat.{u1} α 1 (OfNat.mk.{u1} α 1 (One.one.{u1} α _inst_1))))\nbut is expected to have type\n  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : One.{u2} α] [_inst_2 : Preorder.{u2} α] {a : α} [_inst_3 : Nonempty.{succ u1} β], Iff (LT.lt.{max u2 u1} (β -> α) (Preorder.toLT.{max u2 u1} (β -> α) (Pi.preorder.{u1, u2} β (fun (ᾰ : β) => α) (fun (i : β) => _inst_2))) (Function.const.{succ u2, succ u1} α β a) (OfNat.ofNat.{max u2 u1} (β -> α) 1 (One.toOfNat1.{max u2 u1} (β -> α) (Pi.instOne.{u1, u2} β (fun (a._@.Init.Prelude._hyg.54 : β) => α) (fun (i : β) => _inst_1))))) (LT.lt.{u2} α (Preorder.toLT.{u2} α _inst_2) a (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α _inst_1)))\nCase conversion may be inaccurate. Consider using '#align function.const_lt_one Function.const_lt_oneₓ'. -/\n@[simp, to_additive]\ntheorem const_lt_one : const β a < 1 ↔ a < 1 :=\n  @const_lt_const _ _ _ _ _ 1\n#align function.const_lt_one Function.const_lt_one\n#align function.const_neg Function.const_neg\n\nend Function\n\nnamespace Tactic\n\nopen Function Positivity\n\nvariable (ι) [Zero α] {a : α}\n\nprivate theorem function_const_nonneg_of_pos [Preorder α] (ha : 0 < a) : 0 ≤ const ι a :=\n  const_nonneg_of_nonneg _ ha.le\n#align tactic.function_const_nonneg_of_pos tactic.function_const_nonneg_of_pos\n\nvariable [Nonempty ι]\n\nprivate theorem function_const_ne_zero : a ≠ 0 → const ι a ≠ 0 :=\n  const_ne_zero.2\n#align tactic.function_const_ne_zero tactic.function_const_ne_zero\n\nprivate theorem function_const_pos [Preorder α] : 0 < a → 0 < const ι a :=\n  const_pos.2\n#align tactic.function_const_pos tactic.function_const_pos\n\n/-- Extension for the `positivity` tactic: `function.const` is positive/nonnegative/nonzero if its\ninput is. -/\n@[positivity]\nunsafe def positivity_const : expr → tactic strictness\n  | q(Function.const $(ι) $(a)) => do\n    let strict_a ← core a\n    match strict_a with\n      | positive p =>\n        positive <$> to_expr ``(function_const_pos $(ι) $(p)) <|>\n          nonnegative <$> to_expr ``(function_const_nonneg_of_pos $(ι) $(p))\n      | nonnegative p => nonnegative <$> to_expr ``(const_nonneg_of_nonneg $(ι) $(p))\n      | nonzero p => nonzero <$> to_expr ``(function_const_ne_zero $(ι) $(p))\n  | e =>\n    pp e >>= fail ∘ format.bracket \"The expression `\" \"` is not of the form `function.const ι a`\"\n#align tactic.positivity_const tactic.positivity_const\n\nend Tactic\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Order/Pi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583124210896, "lm_q2_score": 0.6477982247516796, "lm_q1q2_score": 0.4508405592875567}}
{"text": "/-\nCopyright (c) 2022 Yaël Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yaël Dillies\n-/\nimport group_theory.group_action.defs\n\n/-!\n# Sum instances for additive and multiplicative actions\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nThis file defines instances for additive and multiplicative actions on the binary `sum` type.\n\n## See also\n\n* `group_theory.group_action.option`\n* `group_theory.group_action.pi`\n* `group_theory.group_action.prod`\n* `group_theory.group_action.sigma`\n-/\n\nvariables {M N P α β γ : Type*}\n\nnamespace sum\n\nsection has_smul\nvariables [has_smul M α] [has_smul M β] [has_smul N α] [has_smul N β] (a : M) (b : α)\n  (c : β) (x : α ⊕ β)\n\n@[to_additive sum.has_vadd] instance : has_smul M (α ⊕ β) := ⟨λ a, sum.map ((•) a) ((•) a)⟩\n\n@[to_additive] lemma smul_def : a • x = x.map ((•) a) ((•) a) := rfl\n@[simp, to_additive] lemma smul_inl : a • (inl b : α ⊕ β) = inl (a • b) := rfl\n@[simp, to_additive] lemma smul_inr : a • (inr c : α ⊕ β) = inr (a • c) := rfl\n@[simp, to_additive] lemma smul_swap : (a • x).swap = a • x.swap := by cases x; refl\n\ninstance [has_smul M N] [is_scalar_tower M N α] [is_scalar_tower M N β] :\n  is_scalar_tower M N (α ⊕ β) :=\n⟨λ a b x,\n  by { cases x, exacts [congr_arg inl (smul_assoc _ _ _), congr_arg inr (smul_assoc _ _ _)] }⟩\n\n@[to_additive] instance [smul_comm_class M N α] [smul_comm_class M N β] :\n  smul_comm_class M N (α ⊕ β) :=\n⟨λ a b x,\n  by { cases x, exacts [congr_arg inl (smul_comm _ _ _), congr_arg inr (smul_comm _ _ _)] }⟩\n\n@[to_additive]\ninstance [has_smul Mᵐᵒᵖ α] [has_smul Mᵐᵒᵖ β] [is_central_scalar M α] [is_central_scalar M β] :\n  is_central_scalar M (α ⊕ β) :=\n⟨λ a x,\n  by { cases x, exacts [congr_arg inl (op_smul_eq_smul _ _), congr_arg inr (op_smul_eq_smul _ _)] }⟩\n\n@[to_additive] instance has_faithful_smul_left [has_faithful_smul M α] :\n  has_faithful_smul M (α ⊕ β) :=\n⟨λ x y h, eq_of_smul_eq_smul $ λ a : α, by injection h (inl a)⟩\n\n@[to_additive] instance has_faithful_smul_right [has_faithful_smul M β] :\n  has_faithful_smul M (α ⊕ β) :=\n⟨λ x y h, eq_of_smul_eq_smul $ λ b : β, by injection h (inr b)⟩\n\nend has_smul\n\n@[to_additive] instance {m : monoid M} [mul_action M α] [mul_action M β] : mul_action M (α ⊕ β) :=\n{ mul_smul := λ a b x,\n    by { cases x, exacts [congr_arg inl (mul_smul _ _ _), congr_arg inr (mul_smul _ _ _)] },\n  one_smul := λ x,\n    by { cases x, exacts [congr_arg inl (one_smul _ _), congr_arg inr (one_smul _ _)] } }\n\nend sum\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/group_theory/group_action/sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.4508405532611723}}
{"text": "abbrev VName := String\n\ninductive Ty where\n  | Bool\n  | Int\n\ndef Ctxt := VName → Option Ty\n\nvariable (Γ : Ctxt) in\ninductive Expr : Ty → Type where\n  | var (h : Γ x = some τ) : Expr τ\n\ndef Expr.constFold : Expr Γ τ → Option Unit\n  | var n   => none\n\ntheorem Expr.constFold_sound {e : Expr Γ τ} : constFold e = some v → True := by\n  intro h\n  induction e with\n  | var   => simp only [constFold] at h\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/reductionBug.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4508122360750926}}
{"text": "import category_theory.limits.fubini\n\nimport for_mathlib.Profinite.extend\nimport for_mathlib.AddCommGroup.exact\nimport for_mathlib.limit_flip_comp_iso\n\nimport condensed.ab\nimport pseudo_normed_group.bounded_limits\nimport condensed.extr.lift_comphaus\nimport condensed.projective_resolution\nimport condensed.kernel_comparison\n\n.\n\nuniverses u v\n\nnoncomputable theory\n\nopen_locale nnreal\n\nopen category_theory category_theory.limits opposite pseudo_normed_group\n\n-- move me\nnamespace CompHaus\n\nvariables {J : Type u} [small_category J]\n  (F G : J ⥤ CompHaus.{u}) (α : F ⟶ G)\nvariables (cF : cone F) (cG : cone G) (hcF : is_limit cF) (hcG : is_limit cG)\n\ndef pt {X : CompHaus.{u}} (x : X) : (⊤_ CompHaus) ⟶ X :=\n⟨λ _, x, continuous_const⟩\n\n@[simps] def diagram_of_pt (y : cG.X) : J ⥤ CompHaus.{u} :=\n{ obj := λ j, pullback (α.app j) (pt y ≫ cG.π.app j),\n  map := λ i j f, pullback.lift (pullback.fst ≫ F.map f) pullback.snd\n    (by rw [category.assoc, α.naturality, pullback.condition_assoc, category.assoc, cG.w]),\n  map_id' := λ j, by apply pullback.hom_ext; dsimp; simp,\n  map_comp' := λ i j k f g, by { apply pullback.hom_ext; dsimp; simp } }\n\n.\n\n@[simps] def cone_of_pt (y : cG.X) : cone (diagram_of_pt F G α cG y) :=\n{ X := pullback (hcG.map cF α) (pt y),\n  π :=\n  { app := λ j, pullback.lift\n      (pullback.fst ≫ cF.π.app _)\n      pullback.snd\n      (by rw [category.assoc, ← pullback.condition_assoc, is_limit.map_π]),\n    naturality' := λ i j f, by apply pullback.hom_ext; dsimp; simp } }\n\n.\n\ndef is_limit_cone_of_pt (y : cG.X) : is_limit (cone_of_pt F G α cF cG hcG y) :=\n{ lift := λ S, pullback.lift\n    (hcF.lift ⟨S.X,\n    { app := λ j, S.π.app j ≫ pullback.fst,\n      naturality' := begin\n        intros i j f,\n        dsimp,\n        rw ← S.w f, dsimp [diagram_of_pt],\n        simp only [category.id_comp, category.assoc, pullback.lift_fst],\n      end }⟩)\n    (terminal.from _)\n    begin\n      apply hcG.hom_ext, intros j, dsimp,\n      simp only [category.assoc, is_limit.map_π, is_limit.fac_assoc, pullback.condition],\n      ext, refl,\n    end,\n  fac' := begin\n    intros s j, dsimp, apply pullback.hom_ext,\n    { simp only [category.assoc, pullback.lift_fst, pullback.lift_fst_assoc, is_limit.fac] },\n    { simp only [eq_iff_true_of_subsingleton] },\n  end,\n  uniq' := begin\n    intros s m hm,\n    dsimp at m hm,\n    apply pullback.hom_ext,\n    { rw pullback.lift_fst,\n      apply hcF.hom_ext, intros j,\n      simp only [category.assoc, is_limit.fac, ← hm j, pullback.lift_fst] },\n    { simp only [eq_iff_true_of_subsingleton] }\n  end }\n\nlemma is_limit.surjective_of_surjective [is_cofiltered J]\n  (hα : ∀ j, function.surjective (α.app j)) :\n  function.surjective (hcG.map cF α) := λ y,\nlet E := cone_of_pt F G α cF cG hcG y,\n  hE : is_limit E := is_limit_cone_of_pt F G α cF cG hcF hcG y in\nbegin\n  suffices : ∃ (e : (⊤_ CompHaus.{u}) ⟶ E.X),\n    e ≫ (pullback.fst : E.X ⟶ cF.X) ≫ hcG.map cF α = pt y,\n  { obtain ⟨e,he⟩ := this,\n    use (terminal.from (CompHaus.of punit) ≫ e ≫ pullback.fst) punit.star,\n    rw ← comp_apply,\n    have : y = (terminal.from (CompHaus.of punit) ≫ pt y) punit.star := rfl,\n    conv_rhs { rw this }, clear this, congr' 1,\n    apply hcG.hom_ext,\n    intros j,\n    simp only [←he, category.assoc] },\n  let E' := CompHaus_to_Top.map_cone E,\n  let hE' : is_limit E' := is_limit_of_preserves CompHaus_to_Top hE,\n  let ee : E' ≅ Top.limit_cone.{u u} _ :=\n    hE'.unique_up_to_iso (Top.limit_cone_is_limit _),\n  let e : E'.X ≅ (Top.limit_cone.{u u} _).X :=\n    hE'.cone_point_unique_up_to_iso (Top.limit_cone_is_limit _),\n  haveI : ∀ j : J, t2_space (((diagram_of_pt F G α cG y ⋙ CompHaus_to_Top).obj j)),\n  { intros j, change t2_space ((diagram_of_pt F G α cG y).obj j), apply_instance },\n  haveI : ∀ j : J, compact_space (((diagram_of_pt F G α cG y ⋙ CompHaus_to_Top).obj j)),\n  { intros j, change compact_space ((diagram_of_pt F G α cG y).obj j), apply_instance },\n  haveI : ∀ j : J, nonempty (((diagram_of_pt F G α cG y ⋙ CompHaus_to_Top).obj j)),\n  { intro j, change nonempty ((diagram_of_pt F G α cG y).obj j),\n    dsimp only [diagram_of_pt_obj],\n    let y' := (terminal.from (CompHaus.of punit) ≫ pt y ≫ cG.π.app j) punit.star,\n    obtain ⟨x', hx'⟩ := hα j y',\n    refine ⟨(terminal.from (CompHaus.of punit) ≫ pullback.lift (pt x') (𝟙 _) _) punit.star⟩,\n    ext z, exact hx', },\n  have := Top.nonempty_limit_cone_of_compact_t2_cofiltered_system\n    (diagram_of_pt F G α cG y ⋙ CompHaus_to_Top),\n  obtain ⟨a⟩ := this,\n  let b := e.inv a,\n  use pt b,\n  rw pullback.condition,\n  refl,\nend\n\n-- Scott: perhaps life is easier if we use this version? I'm not too sure.\nlemma is_limit.surjective_of_surjective' [is_cofiltered J]\n  (hα : ∀ j, function.surjective (α.app j)) :\n   function.surjective (lim_map α) :=\nis_limit.surjective_of_surjective _ _ _ _ _ (limit.is_limit _) _ hα\n\nend CompHaus\n\nnamespace CompHausFiltPseuNormGrp₁\n\n-- move this\ninstance : has_zero_morphisms (CompHausFiltPseuNormGrp₁.{u}) :=\n{ has_zero := λ M₁ M₂, ⟨0⟩,\n  comp_zero' := λ _ _ f _, rfl,\n  zero_comp' := λ _ _ _ f, by { ext, exact f.map_zero } }\nvariables {A B C : CompHausFiltPseuNormGrp₁.{u}}\n\nstructure exact_with_constant (f : A ⟶ B) (g : B ⟶ C) (r : ℝ≥0 → ℝ≥0) : Prop :=\n(comp_eq_zero : f ≫ g = 0)\n(cond : ∀ c : ℝ≥0, g ⁻¹' {0} ∩ (filtration B c) ⊆ f '' (filtration A (r c)))\n(large : id ≤ r)\n\nlemma exact_with_constant.exact {f : A ⟶ B} {g : B ⟶ C} {r : ℝ≥0 → ℝ≥0}\n  (h : exact_with_constant f g r) :\n  exact ((to_PNG₁ ⋙ PseuNormGrp₁.to_Ab).map f) ((to_PNG₁ ⋙ PseuNormGrp₁.to_Ab).map g) :=\nbegin\n  rw AddCommGroup.exact_iff',\n  split,\n  { ext x, have := h.comp_eq_zero, apply_fun (λ φ, φ.to_fun) at this, exact congr_fun this x },\n  { intros y hy,\n    obtain ⟨c, hc⟩ := B.exhaustive y,\n    obtain ⟨a, ha, rfl⟩ := h.cond c ⟨_, hc⟩,\n    { exact ⟨a, rfl⟩ },\n    { simp only [set.mem_preimage, set.mem_singleton_iff], exact hy } },\nend\n\n-- TODO remove this; it's a redundant alias\n@[simps obj_obj obj_map_apply map_app {fully_applied := ff}]\ndef Filtration : ℝ≥0 ⥤ CompHausFiltPseuNormGrp₁.{u} ⥤ CompHaus.{u} :=\nCompHausFiltPseuNormGrp₁.level\n\ninstance mono_Filtration_map_app (c₁ c₂ : ℝ≥0) (h : c₁ ⟶ c₂) (M) :\n  mono ((Filtration.map h).app M) :=\nby { rw CompHaus.mono_iff_injective, convert injective_cast_le _ _ }\n\nnamespace exact_with_constant\nnoncomputable theory\n\nvariables (f : A ⟶ B) (g : B ⟶ C) (r : ℝ≥0 → ℝ≥0) (c : ℝ≥0) (hrc : c ≤ r c)\n\nvariables {r c}\n\ndef c_le_rc : c ⟶ r c := hom_of_le $ hrc\n\n/-- Given `f : A ⟶ B`, `P1` is the pullback `B_c ×_{B_{rc}} A_{rc}`. -/\ndef P1 : CompHaus :=\npullback ((Filtration.map (c_le_rc hrc)).app B) ((Filtration.obj (r c)).map f)\n\n@[simps]\ndef pt {X : CompHaus} (x : X) : (⊤_ CompHaus) ⟶ X :=\n⟨λ _, x, continuous_const⟩\n\n/-- Given `g : B ⟶ C`, `P2` is the pullback `B_c ×_{C_c} {pt}`. -/\ndef P2 (c : ℝ≥0) : CompHaus :=\npullback ((Filtration.obj c).map g) (pt (0 : pseudo_normed_group.filtration C c))\n\ndef P1_to_P2 (hfg : f ≫ g = 0) : P1 f hrc ⟶ P2 g c :=\npullback.lift pullback.fst (terminal.from _)\nbegin\n  rw [← cancel_mono ((Filtration.map (c_le_rc hrc)).app C), category.assoc,\n    nat_trans.naturality, pullback.condition_assoc, ← functor.map_comp, hfg],\n  refl,\nend\n\nlemma P1_to_P2_comp_fst (hfg : f ≫ g = 0) :\n  P1_to_P2 f g hrc hfg ≫ pullback.fst = pullback.fst :=\npullback.lift_fst _ _ _\n\nlemma surjective (h : exact_with_constant f g r) :\n  ∃ (hfg : f ≫ g = 0), ∀ c, function.surjective (P1_to_P2 f g (h.large c) hfg) :=\nbegin\n  have hfg : f ≫ g = 0,\n  { ext x, exact fun_like.congr_fun h.exact.w x },\n  refine ⟨hfg, _⟩,\n  intros c y,\n  let π₁ : P2 g c ⟶ (Filtration.obj c).obj B := pullback.fst,\n  have hy : (π₁ y).val ∈ g ⁻¹' {0} ∩ filtration B c,\n  asyncI\n  { refine ⟨_, (π₁ y).2⟩,\n    simp only [subtype.val_eq_coe, set.mem_preimage, set.mem_singleton_iff],\n    have w := @pullback.condition _ _ _ _ _\n      ((Filtration.obj c).map g) (pt (0 : pseudo_normed_group.filtration C c)) _,\n    have := (fun_like.congr_fun w y),\n    exact congr_arg subtype.val this, },\n  obtain ⟨x, hx, hfx⟩ := h.cond c hy,\n  let s : CompHaus.of punit ⟶ P1 f (h.large c) :=\n  terminal.from _ ≫ pullback.lift (pt (π₁ y)) (pt ⟨x, hx⟩) _,\n  swap, { ext t, exact hfx.symm },\n  refine ⟨s punit.star, _⟩,\n  suffices : s ≫ P1_to_P2 f g (h.large c) hfg = terminal.from _ ≫ pt y,\n  { exact fun_like.congr_fun this punit.star },\n  delta P1_to_P2,\n  apply category_theory.limits.pullback.hom_ext,\n  { simp only [category.assoc, pullback.lift_fst], refl },\n  { exact subsingleton.elim _ _ }\nend\n\nlemma of_surjective (hfg : f ≫ g = 0) (hr : id ≤ r)\n  (h : ∀ c, function.surjective (P1_to_P2 f g (hr c) hfg)) :\n  exact_with_constant f g r :=\nbegin\n  suffices H : ∀ (c : ℝ≥0), g ⁻¹' {0} ∩ filtration B c ⊆ f '' filtration A (r c),\n  { refine ⟨_, H, hr⟩,\n    ext x,\n    have := congr_arg (coe_fn : (A ⟶ C) → (A → C)) hfg,\n    exact congr_fun this x },\n  rintro c y ⟨hy, hyc⟩,\n  let t : CompHaus.of punit ⟶ P2 g c :=\n  pullback.lift (terminal.from _ ≫ pt ⟨y, hyc⟩) (terminal.from _) _,\n  swap, { ext, exact hy },\n  obtain ⟨s, hs⟩ := h c (t punit.star),\n  let π₂ : P1 f (hr c) ⟶ (Filtration.obj (r c)).obj A := pullback.snd,\n  refine ⟨(π₂ s).val, _⟩,\n  let P := CompHaus.of punit,\n  suffices : terminal.from P ≫ pt s ≫ π₂ ≫ ((Filtration.obj (r c)).map f) =\n    terminal.from _ ≫ pt ⟨y, filtration_mono (hr c) hyc⟩,\n  { have hs := fun_like.congr_fun this punit.star, exact ⟨(π₂ s).2, congr_arg subtype.val hs⟩ },\n  have H : terminal.from P ≫ pt s ≫ P1_to_P2 f g (hr c) hfg = t,\n  { apply continuous_map.ext, rintro ⟨⟩, exact hs },\n  erw [← pullback.condition, ← P1_to_P2_comp_fst f g (hr c) hfg, category.assoc,\n    reassoc_of H, pullback.lift_fst_assoc],\n  refl\nend\n\nlemma iff_surjective :\n  exact_with_constant f g r ↔\n  ∃ (hfg : f ≫ g = 0) (hr : ∀ c, c ≤ r c),\n    ∀ c, function.surjective (P1_to_P2 f g (hr c) hfg) :=\nbegin\n  split,\n  { intro h, obtain ⟨hfg, H⟩ := surjective _ _ h, exact ⟨hfg, h.large, H⟩ },\n  { rintro ⟨hfg, hr, h⟩, exact of_surjective f g hfg hr h }\nend\n\nend exact_with_constant\n\nnamespace exact_with_constant\n\nvariables {J : Type u} [small_category J]\nvariables {A' B' C' : J ⥤ CompHausFiltPseuNormGrp₁.{u}}\nvariables (f : A' ⟶ B') (g : B' ⟶ C') (r : ℝ≥0 → ℝ≥0) (c : ℝ≥0) (hrc : c ≤ r c)\n\nvariables {r c}\n\n@[simps obj obj_obj obj_map map map_app { fully_applied := ff }]\ndef P1_functor : J ⥤ walking_cospan ⥤ CompHaus.{u} :=\nfunctor.flip $ cospan\n  (whisker_left B' (Filtration.map (c_le_rc hrc)))\n  (whisker_right f (Filtration.obj (r c)))\n\n@[simps obj obj_obj obj_map map map_app { fully_applied := ff }]\ndef P2_functor (c : ℝ≥0) : J ⥤ walking_cospan ⥤ CompHaus.{u} :=\nfunctor.flip $ @cospan _ _ _ ((category_theory.functor.const _).obj (⊤_ _)) _\n  (whisker_right g (Filtration.obj c))\n  { app := λ j, pt (0 : pseudo_normed_group.filtration (C'.obj j) c),\n    naturality' := by { intros, ext, exact (C'.map f).map_zero.symm } }\n\nlemma P1_to_P2_nat_trans_aux_1 (hfg : f ≫ g = 0) (X Y : J) (h : X ⟶ Y) (w w') :\n  ((P1_functor f hrc ⋙ lim).map h ≫\n         lim_map (diagram_iso_cospan ((P1_functor f hrc).obj Y)).hom ≫\n           P1_to_P2 (f.app Y) (g.app Y) hrc w ≫\n             lim_map\n               (𝟙 (cospan ((Filtration.obj c).map (g.app Y)) (pt 0)) ≫\n                  (diagram_iso_cospan ((P2_functor g c).obj Y)).inv)) ≫\n      limit.π ((P2_functor g c).obj Y) none =\n    ((lim_map (diagram_iso_cospan ((P1_functor f hrc).obj X)).hom ≫\n            P1_to_P2 (f.app X) (g.app X) hrc w' ≫\n              lim_map\n                (𝟙 (cospan ((Filtration.obj c).map (g.app X)) (pt 0)) ≫\n                   (diagram_iso_cospan ((P2_functor g c).obj X)).inv)) ≫\n         (P2_functor g c ⋙ lim).map h) ≫\n      limit.π ((P2_functor g c).obj Y) none :=\nbegin\n  dsimp [P1_to_P2],\n  simp only [iso.refl_hom, iso.refl_inv, nat_trans.comp_app, eq_to_iso_refl,\n    category.id_comp, category.assoc,\n    cones.postcompose_obj_π, lim_map_π_assoc, limit.lift_π,\n    diagram_iso_cospan_hom_app, diagram_iso_cospan_inv_app,\n    pullback_cone.mk_π_app_one, limit.lift_map],\n  dsimp,\n  simp only [←(Filtration.obj c).map_comp, category.comp_id, category.id_comp,\n    nat_trans.naturality],\nend\n\nlemma P1_to_P2_nat_trans_aux_2 (hfg : f ≫ g = 0) (X Y : J) (h : X ⟶ Y) (w w') :\n  ((P1_functor f hrc ⋙ lim).map h ≫\n         lim_map (diagram_iso_cospan ((P1_functor f hrc).obj Y)).hom ≫\n           P1_to_P2 (f.app Y) (g.app Y) hrc w ≫\n             lim_map\n               (𝟙 (cospan ((Filtration.obj c).map (g.app Y)) (pt 0)) ≫\n                  (diagram_iso_cospan ((P2_functor g c).obj Y)).inv)) ≫\n      limit.π ((P2_functor g c).obj Y) (some walking_pair.left) =\n    ((lim_map (diagram_iso_cospan ((P1_functor f hrc).obj X)).hom ≫\n            P1_to_P2 (f.app X) (g.app X) hrc w' ≫\n              lim_map\n                (𝟙 (cospan ((Filtration.obj c).map (g.app X)) (pt 0)) ≫\n                   (diagram_iso_cospan ((P2_functor g c).obj X)).inv)) ≫\n         (P2_functor g c ⋙ lim).map h) ≫\n      limit.π ((P2_functor g c).obj Y) (some walking_pair.left) :=\nbegin\n  dsimp [P1_to_P2],\n  simp only [iso.refl_hom ,iso.refl_inv, eq_to_iso_refl, nat_trans.comp_app,\n    category.id_comp, category.assoc, pullback_cone.mk_π_app_left,\n    cones.postcompose_obj_π, lim_map_π_assoc, limit.lift_π, limit.lift_map,\n    diagram_iso_cospan_hom_app, diagram_iso_cospan_inv_app],\n  dsimp,\n  simp only [category.comp_id, category.id_comp],\nend\n\nlemma P1_to_P2_nat_trans_aux_3 (hfg : f ≫ g = 0) (X Y : J) (h : X ⟶ Y) (w w') :\n  ((P1_functor f hrc ⋙ lim).map h ≫\n         lim_map (diagram_iso_cospan ((P1_functor f hrc).obj Y)).hom ≫\n           P1_to_P2 (f.app Y) (g.app Y) hrc w ≫\n             lim_map\n               (𝟙 (cospan ((Filtration.obj c).map (g.app Y)) (pt 0)) ≫\n                  (diagram_iso_cospan ((P2_functor g c).obj Y)).inv)) ≫\n      limit.π ((P2_functor g c).obj Y) (some walking_pair.right) =\n    ((lim_map (diagram_iso_cospan ((P1_functor f hrc).obj X)).hom ≫\n            P1_to_P2 (f.app X) (g.app X) hrc w' ≫\n              lim_map\n                (𝟙 (cospan ((Filtration.obj c).map (g.app X)) (pt 0)) ≫\n                   (diagram_iso_cospan ((P2_functor g c).obj X)).inv)) ≫\n         (P2_functor g c ⋙ lim).map h) ≫\n      limit.π ((P2_functor g c).obj Y) (some walking_pair.right) :=\nbegin\n  dsimp [P1_to_P2],\n  simp only [category.id_comp, category.assoc, eq_to_iso_refl, iso.refl_inv, nat_trans.comp_app,\n    pullback_cone.mk_π_app_right, cones.postcompose_obj_π, limit.lift_π, limit.lift_map,\n    diagram_iso_cospan_inv_app, eq_iff_true_of_subsingleton],\nend\n\ndef P1_to_P2_nat_trans (hfg : f ≫ g = 0) :\n  (P1_functor f hrc ⋙ lim) ⟶ (P2_functor g c ⋙ lim) :=\n{ app := λ j, begin\n    refine _ ≫ P1_to_P2 (f.app j) (g.app j) hrc (by { rw [← nat_trans.comp_app, hfg], refl }) ≫ _,\n    { refine lim_map (diagram_iso_cospan _).hom, },\n    { refine lim_map (_ ≫ (diagram_iso_cospan _).inv), exact 𝟙 _, }\n  end,\n  naturality' := λ X Y h, begin\n    -- It would be nicer to use `pullback.hom_ext` here, but it doesn't unify.\n    -- Nevertheless, we can bash out the remaining goals with `simp`.\n    apply limit.hom_ext, rintros (⟨⟩|⟨⟨⟩⟩),\n    { apply P1_to_P2_nat_trans_aux_1 _ _ _ hfg, },\n    { apply P1_to_P2_nat_trans_aux_2 _ _ _ hfg, },\n    { apply P1_to_P2_nat_trans_aux_3 _ _ _ hfg, },\n  end }\n\nattribute [simps] P1_to_P2_nat_trans\n\nset_option pp.universes true\n\n/-\nTODO:\n\njmc: below is a framework for setting up some canonical isomorphisms between limits.\nIt really boils down to saying that limits commute.\nThis shouldn't be so hard...\nI'm not convinced that this is the best way to do it,\nthere should be a more ergonomic approach.\n\nscott: I've replaced the definition of `P1_iso`\nwith one that uses the general theory for commuting limits.\n-/\n\ninstance (c : ℝ≥0) : preserves_limits (Filtration.obj c) :=\nby { dsimp [Filtration], apply_instance, }\n\ndef P1_iso {A B : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}}\n  (f : A ⟶ B) {r : ℝ≥0 → ℝ≥0} {c : ℝ≥0} (hrc : c ≤ r c) (S : Profinite) :\n  P1.{u} ((Profinite.extend_nat_trans.{u u+1} f).app S) hrc ≅\n    limit (P1_functor.{u} (whisker_left S.fintype_diagram f) hrc ⋙ lim) :=\nbegin\n  refine has_limit.iso_of_nat_iso (_ ≪≫ (cospan_comp_iso _ _ _).symm) ≪≫\n    (limit_flip_comp_lim_iso_limit_comp_lim' _).symm,\n\n  -- This next line can be removed later if/when we generalize universe parameters in finite (co)limits\n  refine _ ≪≫ (diagram_iso_cospan _).symm,\n\n  refine cospan_ext (preserves_limit_iso _ _) (preserves_limit_iso _ _) (preserves_limit_iso _ _)\n    (by { apply limit.hom_ext, intros, ext, simp, })\n    (begin\n      apply limit.hom_ext,\n      intros,\n      simp [-category_theory.functor.map_comp, ←(Filtration.obj (r c)).map_comp],\n    end)\nend\n\nopen category_theory.limits\n\ndef P2_iso {B C : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}}\n  (g : B ⟶ C) (c : ℝ≥0) (S : Profinite) :\n  P2.{u} ((Profinite.extend_nat_trans.{u u+1} g).app S) c ≅\n    limit (P2_functor.{u} (whisker_left S.fintype_diagram g) c ⋙ lim) :=\nbegin\n  refine has_limit.iso_of_nat_iso (_ ≪≫ (cospan_comp_iso _ _ _).symm) ≪≫\n    (limit_flip_comp_lim_iso_limit_comp_lim' _).symm,\n\n  -- This next line can be removed later if/when we generalize universe parameters in finite (co)limits\n  refine _ ≪≫ (diagram_iso_cospan _).symm,\n\n  refine cospan_ext _ _ _ _ _,\n  exact (preserves_limit_iso _ _),\n  exact category_theory.limits.limit_const_terminal.symm,\n  exact (preserves_limit_iso _ _),\n  { apply limit.hom_ext, intros, simp [-category_theory.functor.map_comp, ←(Filtration.obj c).map_comp], },\n  { apply limit.hom_ext, intros, ext, simp, },\nend\n\n-- move me, generalize\nlemma extend_aux {A₁ B₁ A₂ B₂ : CompHaus}\n  (e₁ : A₁ ≅ B₁) (e₂ : A₂ ≅ B₂) (f : A₁ ⟶ A₂) (g : B₁ ⟶ B₂) (hf : epi f)\n  (H : e₁.inv ≫ f ≫ e₂.hom = g) :\n  epi g :=\nby { subst H, apply epi_comp _ _, apply_instance, apply epi_comp }\n\n-- move me, generalize\nlemma extend_aux' {A₁ B₁ A₂ B₂ : CompHaus}\n  (e₁ : A₁ ≅ B₁) (e₂ : A₂ ≅ B₂) (f : A₁ ⟶ A₂) (g : B₁ ⟶ B₂) (hf : epi f)\n  (H : f = e₁.hom ≫ g ≫ e₂.inv) :\n  epi g :=\nby { rw [← iso.inv_comp_eq, iso.eq_comp_inv, category.assoc] at H, apply extend_aux e₁ e₂ f g hf H }\n\nlemma extend_aux_1 {A B C : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}} {r : ℝ≥0 → ℝ≥0} {c : ℝ≥0}\n  (S : Profinite.{u}) (f : A ⟶ B) (g : B ⟶ C) (hrc : c ≤ r c) (w w') :\n  ((P1_iso.{u} f hrc S).symm.inv ≫\n         lim_map.{u u u u+1}\n             (P1_to_P2_nat_trans.{u}\n                (whisker_left.{u u u+1 u u+1 u} S.fintype_diagram f)\n                (whisker_left.{u u u+1 u u+1 u} S.fintype_diagram g) hrc w) ≫\n           (P2_iso.{u} g c S).symm.hom) ≫\n      pullback.fst.{u u+1} =\n    P1_to_P2.{u} ((Profinite.extend_nat_trans.{u u+1} f).app S)\n        ((Profinite.extend_nat_trans.{u u+1} g).app S) hrc w' ≫\n      pullback.fst.{u u+1} :=\nbegin\n  apply (cancel_mono ((preserves_limit_iso (Filtration.obj _) _).hom)).1,\n  apply limit.hom_ext,\n  { -- TODO this is not the prettiest proof.\n    -- We need some good simp lemmas for `P1_iso`, `P2_iso`, and `P1_to_P2`.\n    intro j,\n    simp only [P1_to_P2_comp_fst, category_theory.preserves_limits_iso_hom_π, category_theory.category.assoc],\n    dsimp [P2_iso],\n    simp only [category_theory.iso.symm_inv,\n      category_theory.limits.cospan_ext_inv_app_left,\n      category_theory.iso.trans_inv,\n      category_theory.nat_trans.comp_app,\n      category_theory.category.id_comp,\n      category_theory.preserves_limits_iso_inv_π,\n      category_theory.limits.cospan_comp_iso_hom_app_left,\n      category_theory.category.assoc,\n      category_theory.limits.has_limit.iso_of_nat_iso_inv_π_assoc],\n    erw [limit_flip_comp_lim_iso_limit_comp_lim'_hom_π_π, lim_map_π_assoc],\n    simp only [category_theory.category.id_comp,\n      CompHausFiltPseuNormGrp₁.exact_with_constant.P1_to_P2_nat_trans_app,\n      category_theory.category.assoc],\n    erw [lim_map_π],\n    dsimp [P1_to_P2],\n    simp only [category_theory.category.comp_id,\n      category_theory.iso.refl_hom,\n      category_theory.eq_to_iso_refl,\n      category_theory.limits.lim_map_π,\n      category_theory.limits.diagram_iso_cospan_hom_app,\n      category_theory.limits.pullback.lift_fst],\n    dsimp [P1_iso],\n    simp only [category_theory.category.assoc],\n    erw [limit_flip_comp_lim_iso_limit_comp_lim'_inv_π_π],\n    simp only [category_theory.limits.has_limit.iso_of_nat_iso_hom_π_assoc,\n      category_theory.nat_trans.comp_app,\n      category_theory.iso.symm_hom,\n      category_theory.limits.cospan_comp_iso_inv_app_left,\n      category_theory.category.assoc,\n      category_theory.iso.trans_hom,\n      category_theory.limits.cospan_ext_hom_app_left],\n    dsimp,\n    simp only [category_theory.preserves_limits_iso_hom_π, category_theory.category.id_comp], },\n  all_goals { apply_instance, },\nend\n\nlemma extend {A B C : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}}\n  (f : A ⟶ B) (g : B ⟶ C) (r : ℝ≥0 → ℝ≥0)\n  (hfg : ∀ S, exact_with_constant (f.app S) (g.app S) r) (S : Profinite) :\n  exact_with_constant\n    ((Profinite.extend_nat_trans f).app S) ((Profinite.extend_nat_trans g).app S) r :=\nbegin\n  have hr : id ≤ r := (hfg $ Fintype.of punit).large,\n  rw exact_with_constant.iff_surjective,\n  refine ⟨_, hr, _⟩,\n  { rw [← nat_trans.comp_app, ← Profinite.extend_nat_trans_comp],\n    apply limit.hom_ext,\n    intro X,\n    specialize hfg (S.fintype_diagram.obj X),\n    erw [zero_comp, limit.lift_π],\n    simp only [cones.postcompose_obj_π, whisker_left_comp, nat_trans.comp_app,\n      limit.cone_π, whisker_left_app, hfg.comp_eq_zero, comp_zero], },\n  intros c,\n  have hfg' : whisker_left.{u u u+1 u u+1 u} S.fintype_diagram f ≫\n    whisker_left.{u u u+1 u u+1 u} S.fintype_diagram g = 0,\n  { ext X : 2,\n    simp only [nat_trans.comp_app, whisker_left_app, (hfg (S.fintype_diagram.obj X)).comp_eq_zero],\n    refl },\n  have key := CompHaus.is_limit.surjective_of_surjective'\n    (P1_functor.{u} (whisker_left S.fintype_diagram f) (hr c) ⋙ lim)\n    (P2_functor.{u} (whisker_left S.fintype_diagram g) c ⋙ lim)\n    (P1_to_P2_nat_trans _ _ _ hfg') _,\n  swap,\n  { intro X, specialize hfg (S.fintype_diagram.obj X), rw [iff_surjective] at hfg,\n    rcases hfg with ⟨aux', hr, hfg⟩, specialize hfg c,\n    rw ← CompHaus.epi_iff_surjective at hfg ⊢,\n    apply_with epi_comp {instances := ff},\n    { show epi ((@limits.lim _ _ _ _ _).map _), apply_instance, },\n    apply_with epi_comp {instances := ff},\n    { exact hfg },\n    { show epi ((@limits.lim _ _ _ _ _).map _), apply_instance, }, },\n  rw ← CompHaus.epi_iff_surjective at key ⊢,\n  refine extend_aux (P1_iso f (hr c) S).symm (P2_iso g c S).symm _ _ key _,\n  apply pullback.hom_ext,\n  apply extend_aux_1,\n  apply subsingleton.elim,\nend\n\nend exact_with_constant\n\ninstance has_zero_nat_trans_CHFPNG₁ {𝒞 : Type*} [category 𝒞]\n  (A B : 𝒞 ⥤ CompHausFiltPseuNormGrp₁.{u}) :\n  has_zero (A ⟶ B) :=\n⟨⟨0, λ S T f, by { ext t, exact (B.map f).map_zero.symm }⟩⟩\n\n@[simp] lemma zero_app {𝒞 : Type*} [category 𝒞] (A B : 𝒞 ⥤ CompHausFiltPseuNormGrp₁.{u}) (S) :\n  (0 : A ⟶ B).app S = 0 := rfl\n\n@[simp] lemma Profinite.extend_nat_trans_zero (A B : Fintype ⥤ CompHausFiltPseuNormGrp₁.{u}) :\n  Profinite.extend_nat_trans (0 : A ⟶ B) = 0 :=\nbegin\n  apply Profinite.extend_nat_trans_ext,\n  rw [Profinite.extend_nat_trans_whisker_left],\n  ext S : 2,\n  simp only [nat_trans.comp_app, whisker_left_app, zero_app, zero_comp, comp_zero],\nend\n\nlemma exact_with_constant_extend_zero_left (A B C : Fintype ⥤ CompHausFiltPseuNormGrp₁.{u})\n  (g : B ⟶ C) (r : ℝ≥0 → ℝ≥0)\n  (hfg : ∀ S, exact_with_constant (0 : A.obj S ⟶ B.obj S) (g.app S) r) (S : Profinite) :\n  exact_with_constant (0 : (Profinite.extend A).obj S ⟶ (Profinite.extend B).obj S)\n    ((Profinite.extend_nat_trans g).app S) r :=\nbegin\n  have := exact_with_constant.extend (0 : A ⟶ B) g r hfg S,\n  simpa,\nend\n\nlemma exact_with_constant_extend_zero_right (A B C : Fintype ⥤ CompHausFiltPseuNormGrp₁.{u})\n  (f : A ⟶ B) (r : ℝ≥0 → ℝ≥0)\n  (hfg : ∀ S, exact_with_constant (f.app S) (0 : B.obj S ⟶ C.obj S) r) (S : Profinite) :\n  exact_with_constant ((Profinite.extend_nat_trans f).app S)\n    (0 : (Profinite.extend B).obj S ⟶ (Profinite.extend C).obj S) r :=\nbegin\n  have := exact_with_constant.extend f (0 : B ⟶ C) r hfg S,\n  simpa,\nend\n\nvariables (C)\n\nlemma exact_with_constant_of_epi (f : A ⟶ B) (r : ℝ≥0 → ℝ≥0) (hr : id ≤ r)\n  (hf : ∀ c, filtration B c ⊆ f '' (filtration A (r c))) :\n  exact_with_constant f (0 : B ⟶ C) r :=\nbegin\n  refine ⟨_, _, hr⟩,\n  { rw comp_zero },\n  { intro c, exact set.subset.trans (set.inter_subset_right _ _) (hf c), }\nend\n\nvariables (A) {C}\n\nlemma exact_with_constant_of_mono (g : B ⟶ C) [hg : mono ((to_PNG₁ ⋙ PseuNormGrp₁.to_Ab).map g)] :\n  exact_with_constant (0 : A ⟶ B) g id :=\nbegin\n  refine ⟨_, _, le_rfl⟩,\n  { rw zero_comp },\n  { rintro c x ⟨hx, -⟩,\n    suffices : x = 0, { subst x, refine ⟨0, zero_mem_filtration _, rfl⟩, },\n    simp only [set.mem_preimage, set.mem_singleton_iff] at hx,\n    rw [AddCommGroup.mono_iff_injective, injective_iff_map_eq_zero] at hg,\n    exact hg _ hx, }\nend\n\nend CompHausFiltPseuNormGrp₁\n\nnamespace Condensed\n\nopen CompHausFiltPseuNormGrp₁\n\nlemma zero_iff_ExtrDisc {A B : Condensed.{u} Ab.{u+1}} (f : A ⟶ B) :\n  f = 0 ↔ (∀ S : ExtrDisc, f.val.app (op S.val) = 0) :=\nbegin\n  split,\n  { rintros ⟨rfl⟩, simp },\n  { intros h,\n    apply (Condensed_ExtrSheafProd_equiv Ab).functor.map_injective,\n    apply (ExtrSheafProd_to_presheaf Ab).map_injective,\n    ext : 2,\n    apply h }\nend\n\nlemma exact_iff_ExtrDisc {A B C : Condensed.{u} Ab.{u+1}} (f : A ⟶ B) (g : B ⟶ C) :\n  exact f g ↔ ∀ (S : ExtrDisc),\n    exact (f.1.app $ ExtrDisc_to_Profinite.op.obj (op S))\n          (g.1.app $ ExtrDisc_to_Profinite.op.obj (op S)) :=\nbegin\n  simp only [abelian.exact_iff, zero_iff_ExtrDisc, forall_and_distrib],\n  refine and_congr iff.rfl _,\n  apply forall_congr,\n  intro S,\n  symmetry,\n  rw [← cancel_epi (kernel_iso g S).hom,\n    ← cancel_mono (cokernel_iso f S).hom],\n  dsimp only [functor.op_obj, ExtrDisc_to_Profinite_obj],\n  simp only [category.assoc, zero_comp, comp_zero],\n  erw [kernel_iso_hom_assoc, cokernel_iso_hom],\n  exact iff.rfl,\nend\n\nopen comphaus_filtered_pseudo_normed_group\nopen CompHausFiltPseuNormGrp₁.exact_with_constant (P1 P2 P1_to_P2 P1_to_P2_comp_fst c_le_rc)\n\nlemma exact_of_exact_with_constant {A B C : CompHausFiltPseuNormGrp₁.{u}}\n  (f : A ⟶ B) (g : B ⟶ C) (r : ℝ≥0 → ℝ≥0)\n  (hfg : exact_with_constant f g r) :\n  exact (to_Condensed.map f) (to_Condensed.map g) :=\nbegin\n  rw exact_iff_ExtrDisc,\n  intro S,\n  rw exact_with_constant.iff_surjective at hfg,\n  rcases hfg with ⟨hfg, hr, H⟩,\n  simp only [subtype.val_eq_coe, to_Condensed_map, CompHausFiltPseuNormGrp.Presheaf.map_app,\n    whisker_right_app, Ab.exact_ulift_map],\n  rw AddCommGroup.exact_iff',\n  split,\n  { show @CompHausFiltPseuNormGrp.presheaf.map.{u}\n      (CHFPNG₁_to_CHFPNGₑₗ.obj A) (CHFPNG₁_to_CHFPNGₑₗ.obj C)\n      (@strict_comphaus_filtered_pseudo_normed_group_hom.to_chfpsng_hom.{u u} A C _ _ (f ≫ g))\n      (unop.{u+2} (ExtrDisc_to_Profinite.{u}.op.obj (op S))) = 0,\n    rw hfg, ext x s, refl, },\n  { rintro ⟨_, c, y₀ : S.val → filtration B c, hy₀, rfl⟩ hy,\n    dsimp at hy ⊢,\n    let y : CompHaus.of S.val ⟶ (Filtration.obj c).obj B := ⟨y₀, hy₀⟩,\n    let t : CompHaus.of S.val ⟶ P2 g c := pullback.lift y (terminal.from _) _,\n    swap,\n    { apply continuous_map.ext, intros a, apply subtype.ext,\n      simp only [add_monoid_hom.mem_ker, CompHausFiltPseuNormGrp.presheaf.map_apply] at hy,\n      have := congr_arg subtype.val hy,\n      exact congr_fun this a },\n    let s := ExtrDisc.lift' _ (H c) t,\n    have hs : s ≫ P1_to_P2 f g (hr c) hfg = t := ExtrDisc.lift_lifts' _ _ _,\n    let π₂ : P1 f (hr c) ⟶ (Filtration.obj (r c)).obj A := pullback.snd,\n    let x₀ := (s ≫ π₂).1,\n    have hx₀ := (s ≫ π₂).2,\n    refine ⟨⟨_, _, x₀, hx₀, rfl⟩, _⟩,\n    apply_fun (λ φ, φ ≫ pullback.fst) at hs,\n    erw [pullback.lift_fst y (terminal.from _)] at hs,\n    rw [category.assoc, P1_to_P2_comp_fst, ← cancel_mono ((Filtration.map (c_le_rc (hr c))).app B),\n      category.assoc, pullback.condition] at hs,\n    ext z,\n    have := fun_like.congr_fun hs z,\n    exact congr_arg subtype.val this, }\nend\n.\n\n@[simp] lemma to_Condensed_map_zero (A B : CompHausFiltPseuNormGrp₁.{u}) :\n  to_Condensed.map (0 : A ⟶ B) = 0 :=\nby { ext S s x, refl, }\n\nlemma mono_to_Condensed_map {A B : CompHausFiltPseuNormGrp₁.{u}}\n  (f : A ⟶ B) (hf : exact_with_constant (0 : A ⟶ A) f id) :\n  mono (to_Condensed.map f) :=\nbegin\n  refine ((abelian.tfae_mono (to_Condensed.obj A) (to_Condensed.map f)).out 2 0).mp _,\n  have := exact_of_exact_with_constant (0 : A ⟶ A) f id hf,\n  simpa only [to_Condensed_map_zero],\nend\n\nlemma epi_to_Condensed_map {A B : CompHausFiltPseuNormGrp₁.{u}}\n  (f : A ⟶ B) (r : ℝ≥0 → ℝ≥0) (hf : exact_with_constant f (0 : B ⟶ B) r) :\n  epi (to_Condensed.map f) :=\nbegin\n  refine ((abelian.tfae_epi (to_Condensed.obj B) (to_Condensed.map f)).out 2 0).mp _,\n  have := exact_of_exact_with_constant f (0 : B ⟶ B) r hf,\n  simpa only [to_Condensed_map_zero]\nend\n\nend Condensed\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/exact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4508122360750926}}
{"text": "import algebra.category.Module.abelian\nimport algebra.category.Module.adjunctions\nimport algebra.category.Module.filtered_colimits\nimport algebra.category.Module.colimits\nimport condensed.adjunctions\n\nopen category_theory\nopen category_theory.limits\n\nuniverse u\n\nvariables (A : Type (u+1)) [ring A]\n\nabbreviation CondensedMod := Condensed.{u} (Module.{u+1} A)\n\nnoncomputable theory\n\ninstance forget_Module_preserves_colimits_proetale_topology_cover (X : Profinite.{u}) :\n  limits.preserves_colimits_of_shape (proetale_topology.cover X)ᵒᵖ\n  (forget (Module.{u+1} A)) := infer_instance\n\n-- TODO: Move this. Also, do we have this somewhere already?\ninstance forget_Module_reflects_isomorphisms :\n  reflects_isomorphisms (forget (Module.{u+1} A)) :=\nbegin\n  constructor,\n  introsI M N f h,\n  rw is_iso_iff_bijective at *,\n  let e := linear_equiv.of_bijective f h.1 h.2,\n  use e.symm,\n  split,\n  { ext t, change e.symm (e t) = t, rw linear_equiv.symm_apply_apply },\n  { ext t, change e (e.symm t) = t, rw linear_equiv.apply_symm_apply }\nend\n\n-- (AT) I will fix this in mathlib asap...\ninstance : has_colimits (Module.{u+1} A) :=\nModule.colimits.has_colimits_Module.{(u+1) (u+1)}\n\ninstance abelian_CondensedMod : abelian (CondensedMod A) :=\nbegin\n  apply @category_theory.Sheaf.abelian.{(u+2) u (u+1)}\n    Profinite.{u} _ proetale_topology (Module.{u+1} A) _ _ _ _ _ _ _ _,\nend\n\ndef CondensedMod_to_CondensedSet : (CondensedMod A) ⥤ CondensedSet :=\nSheaf_compose _ (forget _)\n\n@[simps obj_val map]\ndef CondensedSet_to_CondensedMod : CondensedSet ⥤ (CondensedMod A) :=\nSheaf.compose_and_sheafify _ (Module.free A)\n\n@[simps unit_app counit_app]\ndef CondensedMod_CondensedSet_adjunction :\n  CondensedSet_to_CondensedMod A ⊣ CondensedMod_to_CondensedSet A :=\nSheaf.adjunction _ (Module.adj A)\n\n@[simp]\nlemma CondensedMod_CondensedSet_adjunction_hom_equiv_apply (X : CondensedSet)\n  (Y : CondensedMod A) (e : (CondensedSet_to_CondensedMod A).obj X ⟶ Y) :\n  ((CondensedMod_CondensedSet_adjunction A).hom_equiv _ _ e).val =\n  ((Module.adj A).whisker_right _).hom_equiv _ _ (proetale_topology.to_sheafify _ ≫ e.val) := rfl\n\n@[simp]\nlemma CondensedMod_CondensedSet_adjunction_hom_equiv_symm_apply (X : CondensedSet)\n  (Y : CondensedMod A) (e : X ⟶ (CondensedMod_to_CondensedSet A).obj Y) :\n  (((CondensedMod_CondensedSet_adjunction A).hom_equiv _ _).symm e).val =\n  proetale_topology.sheafify_lift\n    ((((Module.adj A).whisker_right _).hom_equiv _ _).symm e.val) Y.2 := rfl\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/adjunctions_module.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4508122360750926}}
{"text": "constant f (x y : Nat) : Nat\nconstant g (x : Nat) : Nat\n\ntheorem ex1 (x : Nat) (h₁ : f x x = g x) (h₂ : g x = x) : f x (f x x) = x := by\n  simp\n  simp [*]\n\ntheorem ex2 (x : Nat) (h₁ : f x x = g x) (h₂ : g x = x) : f x (f x x) = x := by\n  simp [*]\n\naxiom g_ax (x : Nat) : g x = 0\n\ntheorem ex3 (x y : Nat) (h₁ : f x x = g x) (h₂ : f x x < 5) : f x x + f x x = 0 := by\n  simp [*] at *\n  trace_state\n  have aux₁ : f x x = g x := h₁\n  have aux₂ : g x < 5     := h₂\n  simp [g_ax]\n", "meta": {"author": "Kha", "repo": "lean4-nightly", "sha": "b4c92de57090e6c47b29d3575df53d86fce52752", "save_path": "github-repos/lean/Kha-lean4-nightly", "path": "github-repos/lean/Kha-lean4-nightly/lean4-nightly-b4c92de57090e6c47b29d3575df53d86fce52752/tests/lean/run/simpStar.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503205, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.4507647852925009}}
{"text": "-- Copyright 2022-2023 VMware, Inc.\n-- SPDX-License-Identifier: BSD-2-Clause\n\nimport .relational\nimport .relational_incremental\nimport .stream_elim\nimport logic.function.iterate\n\nopen zset\n\nsection recursion.\n\nvariables {a: Type}.\nvariables [decidable_eq a].\n\n-- idea is that we're supposed to compute O such that R(O) = O\nvariables (R: Z[a] → Z[a]).\n\nprivate def approxs : stream Z[a] :=\n  fix (λ (o: stream Z[a]), ↑↑R (z⁻¹ o)).\n\nlemma approxs_unfold :\n  approxs R = ↑↑R (z⁻¹ (approxs R)) :=\nbegin\n  unfold approxs,\n  apply fix_eq,\n  apply causal_strict_strict, swap, simp,\n  apply delay_strict,\nend\n\nnoncomputable def recursive_fixpoint : Z[a] :=\n  ∫ (D (approxs R)).\n\nlemma approxs_apply\n  (n: ℕ) :\n  approxs R n = (R^[n.succ]) 0 :=\nbegin\n  induction n, simp,\n  { unfold approxs,\n    rw fix_0, simp, },\n  { rw approxs_unfold, simp,\n    rw n_ih, simp,\n    repeat { rw (function.commute.iterate_self R) }, },\nend\n\nlemma approxs_unfold_succ\n  (n: ℕ) :\n  approxs R n.succ = R (approxs R n) :=\nbegin\n  rw approxs_apply,\n  rw approxs_apply,\n  simp,\n  rw function.commute.iterate_self R,\nend\n\nprivate lemma eq_succ_is_fixpoint\n  (n: ℕ) (heqn: R^[n.succ] 0 = (R^[n]) 0) :\n  ∀ m ≥ n,\n  R^[m] 0 = (R^[n]) 0 :=\nbegin\n  intros m hge,\n  by_cases (m = n), cc,\n  generalize hdiff : m - n - 1 = d,\n  have hm : m = (n + d).succ := by omega,\n  rw hm, rw hm at *, clear_dependent m, clear hdiff,\n  clear hge h,\n  induction d,\n  { simp, assumption, },\n  { have hnsucc : (n + d_n.succ) = (n + d_n).succ := by omega,\n    simp, rw function.commute.iterate_self,\n    rw [hnsucc, d_ih],\n    simp at heqn, rw function.commute.iterate_self at heqn,\n    exact heqn,\n  },\nend\n\nlemma derivative_approx_almost_zero\n  (n: ℕ) (heqn: (R^[n.succ]) 0 = (R^[n]) 0) :\n  zero_after (D (approxs R)) n.succ :=\nbegin\n  intros m hge,\n  rw derivative_difference_t, swap, omega,\n  repeat { rw approxs_apply },\n  have heq : (m - 1).succ = m := by omega, rw heq, clear heq,\n  rw (eq_succ_is_fixpoint _ n heqn m.succ), swap, omega,\n  rw (eq_succ_is_fixpoint _ n heqn m), swap, omega,\n  simp,\nend\n\ntheorem recursive_fixpoint_ok\n  (n: ℕ) (heqn: (R^[n.succ]) 0 = (R^[n]) 0) :\n  recursive_fixpoint R = (R^[n]) 0 :=\nbegin\n  unfold recursive_fixpoint,\n  rw (stream_elim_zero_after (D (approxs R)) n.succ),\n  { rw <- integral_sum_vals,\n    simp,\n    rw approxs_apply, dsimp,\n    exact heqn, },\n  apply (derivative_approx_almost_zero _ n heqn),\nend\n\nend recursion.\n\nsection seminaive.\n\n\nvariables {a b: Type}.\nvariables [decidable_eq a] [decidable_eq b].\n\nvariables (R: Z[b] → Z[a] → Z[a]).\n\nnoncomputable def naive : Z[b] → Z[a] :=\n  λ i, ∫ (D (fix (λ (o: stream Z[a]), ↑²R (I (δ0 i)) (z⁻¹ o)))).\n\nnoncomputable def seminaive : Z[b] → Z[a] :=\n  λ i, ∫ (fix (λ (o: stream Z[a]), ↑²R^Δ2 (δ0 i) (z⁻¹ o))).\n\n-- hack to make the change work (need a better way to introduce incremental)\nlocal attribute [reducible] incremental.\n\ntheorem seminaive_equiv :\n  seminaive R = naive R :=\nbegin\n  ext x,\n  unfold naive seminaive,\n  congr' 1,\n  congr' 1,\n  change (D (fix (λ (o : stream Z[a]), ↑²R (I (δ0 x)) (z⁻¹ o)))) with\n    (λ i, (fix (λ (o : stream Z[a]), ↑²R i (z⁻¹ o))))^Δ (δ0 x),\n  rw cycle_incremental (λ i o, ↑²R i o),\n  dsimp,\n  rw uncurry_op_lifting2,\n  apply lifting_causal,\nend\n\ntheorem naive_ok (i: Z[b])\n  (n: ℕ) (heqn: (R i)^[n.succ] 0 = ((R i)^[n]) 0) :\n  naive R i = ((R i)^[n]) 0 :=\nbegin\n  unfold naive,\n  have  heq := (recursive_fixpoint_ok (R i)) _ heqn,\n  unfold recursive_fixpoint approxs at heq,\n  rw<- heq,\n  congr' 3,\n  funext o,\n  congr' 1,\n  funext t, simp,\nend\n\ntheorem seminaive_ok (i: Z[b])\n  (n: ℕ) (heqn: (R i)^[n.succ] 0 = ((R i)^[n]) 0) :\n  seminaive R i = ((R i)^[n]) 0 :=\nbegin\n  rw seminaive_equiv,\n  apply naive_ok, assumption,\nend\n\nend seminaive.\n", "meta": {"author": "tchajed", "repo": "database-stream-processing-theory", "sha": "c4c3b7ced9f964f3ea17db77958df78f2d761509", "save_path": "github-repos/lean/tchajed-database-stream-processing-theory", "path": "github-repos/lean/tchajed-database-stream-processing-theory/database-stream-processing-theory-c4c3b7ced9f964f3ea17db77958df78f2d761509/src/recursive.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581741774411, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4506852191585175}}
{"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\n\nimport linear_algebra.tensor_product\nimport algebra.algebra.basic\n\n/-!\n# The tensor product of R-algebras\n\nWe construct the R-algebra structure on `A ⊗[R] B`, when `A` and `B` are both `R`-algebras,\nand provide the structure isomorphisms\n\n* `R ⊗[R] A ≃ₐ[R] A`\n* `A ⊗[R] R ≃ₐ[R] A`\n* `A ⊗[R] B ≃ₐ[R] B ⊗[R] A`\n\nThe code for\n* `((A ⊗[R] B) ⊗[R] C) ≃ₐ[R] (A ⊗[R] (B ⊗[R] C))`\nis written and compiles, but takes longer than the `-T100000` time limit,\nso is currently commented out.\n-/\n\nuniverses u v₁ v₂ v₃ v₄\n\nnamespace algebra\n\nopen_locale tensor_product\nopen tensor_product\n\nnamespace tensor_product\n\nsection semiring\n\nvariables {R : Type u} [comm_semiring R]\nvariables {A : Type v₁} [semiring A] [algebra R A]\nvariables {B : Type v₂} [semiring B] [algebra R B]\n\n/--\n(Implementation detail)\nThe multiplication map on `A ⊗[R] B`,\nfor a fixed pure tensor in the first argument,\nas an `R`-linear map.\n-/\ndef mul_aux (a₁ : A) (b₁ : B) : (A ⊗[R] B) →ₗ[R] (A ⊗[R] B) :=\ntensor_product.map (lmul_left R a₁) (lmul_left R b₁)\n\n@[simp]\nlemma mul_aux_apply (a₁ a₂ : A) (b₁ b₂ : B) :\n  (mul_aux a₁ b₁) (a₂ ⊗ₜ[R] b₂) = (a₁ * a₂) ⊗ₜ[R] (b₁ * b₂) :=\nrfl\n\n/--\n(Implementation detail)\nThe multiplication map on `A ⊗[R] B`,\nas an `R`-bilinear map.\n-/\ndef mul : (A ⊗[R] B) →ₗ[R] (A ⊗[R] B) →ₗ[R] (A ⊗[R] B) :=\ntensor_product.lift $ linear_map.mk₂ R mul_aux\n  (λ x₁ x₂ y, tensor_product.ext $ λ x' y',\n    by simp only [mul_aux_apply, linear_map.add_apply, add_mul, add_tmul])\n  (λ c x y, tensor_product.ext $ λ x' y',\n    by simp only [mul_aux_apply, linear_map.smul_apply, smul_tmul', smul_mul_assoc])\n  (λ x y₁ y₂, tensor_product.ext $ λ x' y',\n    by simp only [mul_aux_apply, linear_map.add_apply, add_mul, tmul_add])\n  (λ c x y, tensor_product.ext $ λ x' y',\n    by simp only [mul_aux_apply, linear_map.smul_apply, smul_tmul, smul_tmul', smul_mul_assoc])\n\n@[simp]\nlemma mul_apply (a₁ a₂ : A) (b₁ b₂ : B) :\n  mul (a₁ ⊗ₜ[R] b₁) (a₂ ⊗ₜ[R] b₂) = (a₁ * a₂) ⊗ₜ[R] (b₁ * b₂) :=\nrfl\n\nlemma mul_assoc' (mul : (A ⊗[R] B) →ₗ[R] (A ⊗[R] B) →ₗ[R] (A ⊗[R] B))\n  (h : ∀ (a₁ a₂ a₃ : A) (b₁ b₂ b₃ : B),\n    mul (mul (a₁ ⊗ₜ[R] b₁) (a₂ ⊗ₜ[R] b₂)) (a₃ ⊗ₜ[R] b₃) =\n      mul (a₁ ⊗ₜ[R] b₁) (mul (a₂ ⊗ₜ[R] b₂) (a₃ ⊗ₜ[R] b₃))) :\n  ∀ (x y z : A ⊗[R] B), mul (mul x y) z = mul x (mul y z) :=\nbegin\n    intros,\n    apply tensor_product.induction_on x,\n    { simp, },\n    apply tensor_product.induction_on y,\n    { simp, },\n    apply tensor_product.induction_on z,\n    { simp, },\n    { intros, simp [h], },\n    { intros, simp [linear_map.map_add, *], },\n    { intros, simp [linear_map.map_add, *], },\n    { intros, simp [linear_map.map_add, *], },\nend\n\nlemma mul_assoc (x y z : A ⊗[R] B) : mul (mul x y) z = mul x (mul y z) :=\nmul_assoc' mul (by { intros, simp only [mul_apply, mul_assoc], }) x y z\n\nlemma one_mul (x : A ⊗[R] B) : mul (1 ⊗ₜ 1) x = x :=\nbegin\n  apply tensor_product.induction_on x;\n  simp {contextual := tt},\nend\n\nlemma mul_one (x : A ⊗[R] B) : mul x (1 ⊗ₜ 1) = x :=\nbegin\n  apply tensor_product.induction_on x;\n  simp {contextual := tt},\nend\n\ninstance : semiring (A ⊗[R] B) :=\n{ zero := 0,\n  add := (+),\n  one := 1 ⊗ₜ 1,\n  mul := λ a b, mul a b,\n  one_mul := one_mul,\n  mul_one := mul_one,\n  mul_assoc := mul_assoc,\n  zero_mul := by simp,\n  mul_zero := by simp,\n  left_distrib := by simp,\n  right_distrib := by simp,\n  .. (by apply_instance : add_comm_monoid (A ⊗[R] B)) }.\n\nlemma one_def : (1 : A ⊗[R] B) = (1 : A) ⊗ₜ (1 : B) := rfl\n\n@[simp]\nlemma tmul_mul_tmul (a₁ a₂ : A) (b₁ b₂ : B) :\n  (a₁ ⊗ₜ[R] b₁) * (a₂ ⊗ₜ[R] b₂) = (a₁ * a₂) ⊗ₜ[R] (b₁ * b₂) :=\nrfl\n\n@[simp]\nlemma tmul_pow (a : A) (b : B) (k : ℕ) :\n  (a ⊗ₜ[R] b)^k = (a^k) ⊗ₜ[R] (b^k) :=\nbegin\n  induction k with k ih,\n  { simp [one_def], },\n  { simp [pow_succ, ih], }\nend\n\n\n/--\nThe algebra map `R →+* (A ⊗[R] B)` giving `A ⊗[R] B` the structure of an `R`-algebra.\n-/\ndef tensor_algebra_map : R →+* (A ⊗[R] B) :=\n{ to_fun := λ r, algebra_map R A r ⊗ₜ[R] 1,\n  map_one' := by { simp, refl },\n  map_mul' := by simp,\n  map_zero' := by simp [zero_tmul],\n  map_add' := by simp [add_tmul], }\n\ninstance : algebra R (A ⊗[R] B) :=\n{ commutes' := λ r x,\n  begin\n    apply tensor_product.induction_on x,\n    { simp, },\n    { intros a b, simp [tensor_algebra_map, algebra.commutes], },\n    { intros y y' h h', simp at h h', simp [mul_add, add_mul, h, h'], },\n  end,\n  smul_def' := λ r x,\n  begin\n    apply tensor_product.induction_on x,\n    { simp [smul_zero], },\n    { intros a b,\n      rw [tensor_algebra_map, ←tmul_smul, ←smul_tmul, algebra.smul_def r a],\n      simp, },\n    { intros, dsimp, simp [smul_add, mul_add, *], },\n  end,\n  .. tensor_algebra_map,\n  .. (by apply_instance : module R (A ⊗[R] B)) }.\n\n@[simp]\nlemma algebra_map_apply (r : R) :\n  (algebra_map R (A ⊗[R] B)) r = ((algebra_map R A) r) ⊗ₜ[R] 1 := rfl\n\nvariables {C : Type v₃} [semiring C] [algebra R C]\n\n@[ext]\ntheorem ext {g h : (A ⊗[R] B) →ₐ[R] C}\n  (H : ∀ a b, g (a ⊗ₜ b) = h (a ⊗ₜ b)) : g = h :=\nbegin\n  apply @alg_hom.to_linear_map_inj R (A ⊗[R] B) C _ _ _ _ _ _ _ _,\n  ext,\n  simp [H],\nend\n\n/-- The algebra morphism `A →ₐ[R] A ⊗[R] B` sending `a` to `a ⊗ₜ 1`. -/\ndef include_left : A →ₐ[R] A ⊗[R] B :=\n{ to_fun := λ a, a ⊗ₜ 1,\n  map_zero' := by simp,\n  map_add' := by simp [add_tmul],\n  map_one' := rfl,\n  map_mul' := by simp,\n  commutes' := by simp, }\n\n@[simp]\nlemma include_left_apply (a : A) : (include_left : A →ₐ[R] A ⊗[R] B) a = a ⊗ₜ 1 := rfl\n\n/-- The algebra morphism `B →ₐ[R] A ⊗[R] B` sending `b` to `1 ⊗ₜ b`. -/\ndef include_right : B →ₐ[R] A ⊗[R] B :=\n{ to_fun := λ b, 1 ⊗ₜ b,\n  map_zero' := by simp,\n  map_add' := by simp [tmul_add],\n  map_one' := rfl,\n  map_mul' := by simp,\n  commutes' := λ r,\n  begin\n    simp only [algebra_map_apply],\n    transitivity r • ((1 : A) ⊗ₜ[R] (1 : B)),\n    { rw [←tmul_smul, algebra.smul_def], simp, },\n    { simp [algebra.smul_def], },\n  end, }\n\n@[simp]\nlemma include_right_apply (b : B) : (include_right : B →ₐ[R] A ⊗[R] B) b = 1 ⊗ₜ b := rfl\n\nend semiring\n\nsection ring\n\nvariables {R : Type u} [comm_ring R]\nvariables {A : Type v₁} [ring A] [algebra R A]\nvariables {B : Type v₂} [ring B] [algebra R B]\n\ninstance : ring (A ⊗[R] B) :=\n{ .. (by apply_instance : add_comm_group (A ⊗[R] B)),\n  .. (by apply_instance : semiring (A ⊗[R] B)) }.\n\nend ring\n\nsection comm_ring\n\nvariables {R : Type u} [comm_ring R]\nvariables {A : Type v₁} [comm_ring A] [algebra R A]\nvariables {B : Type v₂} [comm_ring B] [algebra R B]\n\ninstance : comm_ring (A ⊗[R] B) :=\n{ mul_comm := λ x y,\n  begin\n    apply tensor_product.induction_on x,\n    { simp, },\n    { intros a₁ b₁,\n      apply tensor_product.induction_on y,\n      { simp, },\n      { intros a₂ b₂,\n        simp [mul_comm], },\n      { intros a₂ b₂ ha hb,\n        simp [mul_add, add_mul, ha, hb], }, },\n    { intros x₁ x₂ h₁ h₂,\n      simp [mul_add, add_mul, h₁, h₂], },\n  end\n  .. (by apply_instance : ring (A ⊗[R] B)) }.\n\nend comm_ring\n\n/--\nVerify that typeclass search finds the ring structure on `A ⊗[ℤ] B`\nwhen `A` and `B` are merely rings, by treating both as `ℤ`-algebras.\n-/\nexample {A : Type v₁} [ring A] {B : Type v₂} [ring B] : ring (A ⊗[ℤ] B) :=\nby apply_instance\n\n/--\nVerify that typeclass search finds the comm_ring structure on `A ⊗[ℤ] B`\nwhen `A` and `B` are merely comm_rings, by treating both as `ℤ`-algebras.\n-/\nexample {A : Type v₁} [comm_ring A] {B : Type v₂} [comm_ring B] : comm_ring (A ⊗[ℤ] B) :=\nby apply_instance\n\n/-!\nWe now build the structure maps for the symmetric monoidal category of `R`-algebras.\n-/\nsection monoidal\n\nsection\nvariables {R : Type u} [comm_semiring R]\nvariables {A : Type v₁} [semiring A] [algebra R A]\nvariables {B : Type v₂} [semiring B] [algebra R B]\nvariables {C : Type v₃} [semiring C] [algebra R C]\nvariables {D : Type v₄} [semiring D] [algebra R D]\n\n/--\nBuild an algebra morphism from a linear map out of a tensor product,\nand evidence of multiplicativity on pure tensors.\n-/\ndef alg_hom_of_linear_map_tensor_product\n  (f : A ⊗[R] B →ₗ[R] C)\n  (w₁ : ∀ (a₁ a₂ : A) (b₁ b₂ : B), f ((a₁ * a₂) ⊗ₜ (b₁ * b₂)) = f (a₁ ⊗ₜ b₁) * f (a₂ ⊗ₜ b₂))\n  (w₂ : ∀ r, f ((algebra_map R A) r ⊗ₜ[R] 1) = (algebra_map R C) r):\n  A ⊗[R] B →ₐ[R] C :=\n{ map_one' := by simpa using w₂ 1,\n  map_zero' := by simp,\n  map_mul' := λ x y,\n  begin\n    apply tensor_product.induction_on x,\n    { simp, },\n    { intros a₁ b₁,\n      apply tensor_product.induction_on y,\n      { simp, },\n      { intros a₂ b₂,\n        simp [w₁], },\n      { intros x₁ x₂ h₁ h₂,\n        simp at h₁, simp at h₂,\n        simp [mul_add, add_mul, h₁, h₂], }, },\n    { intros x₁ x₂ h₁ h₂,\n      simp at h₁, simp at h₂,\n      simp [mul_add, add_mul, h₁, h₂], }\n  end,\n  commutes' := λ r, by simp [w₂],\n  .. f }\n\n@[simp]\nlemma alg_hom_of_linear_map_tensor_product_apply (f w₁ w₂ x) :\n  (alg_hom_of_linear_map_tensor_product f w₁ w₂ : A ⊗[R] B →ₐ[R] C) x = f x := rfl\n\n/--\nBuild an algebra equivalence from a linear equivalence out of a tensor product,\nand evidence of multiplicativity on pure tensors.\n-/\ndef alg_equiv_of_linear_equiv_tensor_product\n  (f : A ⊗[R] B ≃ₗ[R] C)\n  (w₁ : ∀ (a₁ a₂ : A) (b₁ b₂ : B), f ((a₁ * a₂) ⊗ₜ (b₁ * b₂)) = f (a₁ ⊗ₜ b₁) * f (a₂ ⊗ₜ b₂))\n  (w₂ : ∀ r, f ((algebra_map R A) r ⊗ₜ[R] 1) = (algebra_map R C) r):\n  A ⊗[R] B ≃ₐ[R] C :=\n{ .. alg_hom_of_linear_map_tensor_product (f : A ⊗[R] B →ₗ[R] C) w₁ w₂,\n  .. f }\n\n@[simp]\nlemma alg_equiv_of_linear_equiv_tensor_product_apply (f w₁ w₂ x) :\n  (alg_equiv_of_linear_equiv_tensor_product f w₁ w₂ : A ⊗[R] B ≃ₐ[R] C) x = f x := rfl\n\n/--\nBuild an algebra equivalence from a linear equivalence out of a triple tensor product,\nand evidence of multiplicativity on pure tensors.\n-/\ndef alg_equiv_of_linear_equiv_triple_tensor_product\n  (f : ((A ⊗[R] B) ⊗[R] C) ≃ₗ[R] D)\n  (w₁ : ∀ (a₁ a₂ : A) (b₁ b₂ : B) (c₁ c₂ : C),\n    f ((a₁ * a₂) ⊗ₜ (b₁ * b₂) ⊗ₜ (c₁ * c₂)) = f (a₁ ⊗ₜ b₁ ⊗ₜ c₁) * f (a₂ ⊗ₜ b₂ ⊗ₜ c₂))\n  (w₂ : ∀ r, f (((algebra_map R A) r ⊗ₜ[R] (1 : B)) ⊗ₜ[R] (1 : C)) = (algebra_map R D) r) :\n  (A ⊗[R] B) ⊗[R] C ≃ₐ[R] D :=\n{ to_fun := f,\n  map_mul' := λ x y,\n  begin\n    apply tensor_product.induction_on x,\n    { simp, },\n    { intros ab₁ c₁,\n      apply tensor_product.induction_on y,\n      { simp, },\n      { intros ab₂ c₂,\n        apply tensor_product.induction_on ab₁,\n        { simp, },\n        { intros a₁ b₁,\n          apply tensor_product.induction_on ab₂,\n          { simp, },\n          { simp [w₁], },\n          { intros x₁ x₂ h₁ h₂,\n            simp at h₁ h₂,\n            simp [mul_add, add_tmul, h₁, h₂], }, },\n        { intros x₁ x₂ h₁ h₂,\n          simp at h₁ h₂,\n          simp [add_mul, add_tmul, h₁, h₂], }, },\n      { intros x₁ x₂ h₁ h₂,\n        simp [mul_add, add_mul, h₁, h₂], }, },\n    { intros x₁ x₂ h₁ h₂,\n      simp [mul_add, add_mul, h₁, h₂], }\n  end,\n  commutes' := λ r, by simp [w₂],\n  .. f }\n\n@[simp]\nlemma alg_equiv_of_linear_equiv_triple_tensor_product_apply (f w₁ w₂ x) :\n  (alg_equiv_of_linear_equiv_triple_tensor_product f w₁ w₂ : (A ⊗[R] B) ⊗[R] C ≃ₐ[R] D) x = f x :=\nrfl\n\nend\n\nvariables {R : Type u} [comm_semiring R]\nvariables {A : Type v₁} [semiring A] [algebra R A]\nvariables {B : Type v₂} [semiring B] [algebra R B]\nvariables {C : Type v₃} [semiring C] [algebra R C]\nvariables {D : Type v₄} [semiring D] [algebra R D]\n\nsection\nvariables (R A)\n/--\nThe base ring is a left identity for the tensor product of algebra, up to algebra isomorphism.\n-/\nprotected def lid : R ⊗[R] A ≃ₐ[R] A :=\nalg_equiv_of_linear_equiv_tensor_product (tensor_product.lid R A)\n(by simp [mul_smul]) (by simp [algebra.smul_def])\n\n@[simp] \n\n/--\nThe base ring is a right identity for the tensor product of algebra, up to algebra isomorphism.\n-/\nprotected def rid : A ⊗[R] R ≃ₐ[R] A :=\nalg_equiv_of_linear_equiv_tensor_product (tensor_product.rid R A)\n(by simp [mul_smul]) (by simp [algebra.smul_def])\n\n@[simp] theorem rid_tmul (r : R) (a : A) :\n  (tensor_product.rid R A : (A ⊗ R → A)) (a ⊗ₜ r) = r • a :=\nby simp [tensor_product.rid]\n\nsection\nvariables (R A B)\n\n/--\nThe tensor product of R-algebras is commutative, up to algebra isomorphism.\n-/\nprotected def comm : A ⊗[R] B ≃ₐ[R] B ⊗[R] A :=\nalg_equiv_of_linear_equiv_tensor_product (tensor_product.comm R A B)\n(by simp)\n(λ r, begin\n  transitivity r • ((1 : B) ⊗ₜ[R] (1 : A)),\n  { rw [←tmul_smul, algebra.smul_def], simp, },\n  { simp [algebra.smul_def], },\nend)\n\n@[simp]\ntheorem comm_tmul (a : A) (b : B) :\n  (tensor_product.comm R A B : (A ⊗[R] B → B ⊗[R] A)) (a ⊗ₜ b) = (b ⊗ₜ a) :=\nby simp [tensor_product.comm]\n\nend\n\nsection\nvariables {R A B C}\n\nlemma assoc_aux_1 (a₁ a₂ : A) (b₁ b₂ : B) (c₁ c₂ : C) :\n  (tensor_product.assoc R A B C) (((a₁ * a₂) ⊗ₜ[R] (b₁ * b₂)) ⊗ₜ[R] (c₁ * c₂)) =\n    (tensor_product.assoc R A B C) ((a₁ ⊗ₜ[R] b₁) ⊗ₜ[R] c₁) *\n      (tensor_product.assoc R A B C) ((a₂ ⊗ₜ[R] b₂) ⊗ₜ[R] c₂) :=\nrfl\n\nlemma assoc_aux_2 (r : R) :\n  (tensor_product.assoc R A B C) (((algebra_map R A) r ⊗ₜ[R] 1) ⊗ₜ[R] 1) =\n    (algebra_map R (A ⊗ (B ⊗ C))) r := rfl\n\n-- variables (R A B C)\n\n-- -- local attribute [elab_simple] alg_equiv_of_linear_equiv_triple_tensor_product\n\n-- /-- The associator for tensor product of R-algebras, as an algebra isomorphism. -/\n-- -- FIXME This is _really_ slow to compile. :-(\n-- protected def assoc : ((A ⊗[R] B) ⊗[R] C) ≃ₐ[R] (A ⊗[R] (B ⊗[R] C)) :=\n-- alg_equiv_of_linear_equiv_triple_tensor_product\n--   (tensor_product.assoc R A B C)\n--   assoc_aux_1 assoc_aux_2\n\n-- variables {R A B C}\n\n-- @[simp] theorem assoc_tmul (a : A) (b : B) (c : C) :\n--   ((tensor_product.assoc R A B C) :\n--   (A ⊗[R] B) ⊗[R] C → A ⊗[R] (B ⊗[R] C)) ((a ⊗ₜ b) ⊗ₜ c) = a ⊗ₜ (b ⊗ₜ c) :=\n-- rfl\n\nend\n\nvariables {R A B C D}\n\n/-- The tensor product of a pair of algebra morphisms. -/\ndef map (f : A →ₐ[R] B) (g : C →ₐ[R] D) : A ⊗[R] C →ₐ[R] B ⊗[R] D :=\nalg_hom_of_linear_map_tensor_product\n  (tensor_product.map f.to_linear_map g.to_linear_map)\n  (by simp)\n  (by simp [alg_hom.commutes])\n\n@[simp] theorem map_tmul (f : A →ₐ[R] B) (g : C →ₐ[R] D) (a : A) (c : C) :\n  map f g (a ⊗ₜ c) = f a ⊗ₜ g c :=\nrfl\n\n/--\nConstruct an isomorphism between tensor products of R-algebras\nfrom isomorphisms between the tensor factors.\n-/\ndef congr (f : A ≃ₐ[R] B) (g : C ≃ₐ[R] D) : A ⊗[R] C ≃ₐ[R] B ⊗[R] D :=\nalg_equiv.of_alg_hom (map f g) (map f.symm g.symm)\n  (ext $ λ b d, by simp)\n  (ext $ λ a c, by simp)\n\n@[simp]\nlemma congr_apply (f : A ≃ₐ[R] B) (g : C ≃ₐ[R] D) (x) :\n  congr f g x = (map (f : A →ₐ[R] B) (g : C →ₐ[R] D)) x := rfl\n\n@[simp]\nlemma congr_symm_apply (f : A ≃ₐ[R] B) (g : C ≃ₐ[R] D) (x) :\n  (congr f g).symm x = (map (f.symm : B →ₐ[R] A) (g.symm : D →ₐ[R] C)) x := rfl\n\nend\n\nend monoidal\n\nend tensor_product\n\nend algebra\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/ring_theory/tensor_product.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4506170902755016}}
{"text": "import linear_algebra.eigenspace\nimport rnd_var\n\nimport to_mathlib_maybe.pTrace\nimport to_mathlib_maybe.Hilbert_space\n\nimport to_qShannon_theory_maybe.state\nimport to_qShannon_theory_maybe.channel\nimport to_qShannon_theory_maybe.entropy\n\n#check rnd_var\n#check quantum_state\n#check quantum_channel\n#check entropy\n\n-- import Lemma3\n-- import Lemma4\n\nopen_locale tensor_product big_operators\n\nvariables\n{ι : Type} [fintype ι] [decidable_eq ι]\n{ℋ : Type} [complex_hilbert_space ℋ]\n{ρ : module.End ℂ ℋ} [quantum_state ρ]\n{ρ' : module.End ℂ ℋ} [quantum_state ρ']\n{σ : module.End ℂ ℋ} [quantum_state σ]\n{U : module.End ℂ ℋ} [unitary U]\n-- {q : ι → ℝ} [rnd_var q]\n\ndef reachable_by_catalysis (ε : ℝ) (ρ : module.End ℂ ℋ) (ρ' : module.End ℂ ℋ) :=\n∃ σ : module.End ℂ ℋ, ∃ U : module.End ℂ ℋ,\nTr₁(U ∘ (ρ ⊗ σ) ∘ U†) = σ \n∧\nD(Tr₂(U ∘ (ρ ⊗ σ) ∘ U†), ρ') ≤ ε\n\n-- notation ρ `→ε` ρ' := reachable_by_catalysis ε ρ ρ'\nnotation `H` := entropy\n\n-- Choose catalytic state σ₁⊗σ₂ according to two-step construction\n--  1. Define σ₁ using (16). This requires choosing `n` and `U` (in order to define `χ`). `n` can be estimated using (17). `U` is chosen such that the final state on `S` is as close to `ρ'` as possible - but there is no explicit formula. I still don't know how to deal with this.\n-- TODO define trace for arbitrary number of subsystems; in particular, this definition requires a function of type\n--  `Tr : list ℕ → quantum_state → quantum_state`\n-- where the list of integers indicates the subsystems to be traced out\n-- TODO define trace making the system partition explicit, otherwise LEAN will not know what we mean by `Tr k` unless the argument is a product state\ndef σ₁ (ρ) (n) (U) := (1/n) • ∑ k in finset.range n, ρ^⊗(n-k) ⊗ (Tr(list n-k n) (U ∘ ρ ∘ U†)) ⊗ |k⟩⟨k|\n\n--  2. Ancilla system R for the dephasing channel. This is just the ancilla in the Naimark/Stinespring dilation of the channel.\ndef σ₂ := naimark_ancilla (dephasing_channel ρ')\n\n-- Pick unitaries: we want to compose steps 1, 2, & 3 (see fig. 3) with a dephasing channel\ndef V := naimark_unitary (dephasing_channel ρ') ∘ cycle_ancilla ∘ cycle_s ∘ (U ⊗ |n⟩⟨n| + (Id d*(n-1)) ⊗ ∑ k in finset.range (n-1), |k⟩⟨k|)\n\n/--\nThis is the main theorem\n-/\ntheorem reachable_iff_higher_entropy : (∀ ε>0, reachable_by_catalysis ε ρ ρ') ↔ H(ρ') ≥ H(ρ) := \nbegin\n  split,\n  { -- \"The direction i) ⇒ ii) follows directly from sub-additivity, \n    -- unitary invariance and continuity of von Neumann entropy:\"\n    intro h,\n    intro ε,\n    let ρσ' := U ∘ (ρ ⊗ σ) ∘ U†,\n    let ρ'ε := Tr₂ ρσ',\n    calc H(ρ'ε) + H(σ) ≥ H(ρσ')              : by apply entropy_subadditive,\n                  ... = H(U ∘ (ρ ⊗ σ) ∘ U†)     : by sorry -- def of ρ'ε and invariance of σ under transformation\n                  ... = H(ρ ⊗ σ)              : by apply entropy_unitary_evolution_eq_entropy_self,\n                  ... = H(ρ) + H(σ)              : by apply entropy_tmul_eq_add_entropy,\n    -- then rw to cancel H(σ) (\"by continuity\") and done\n    sorry\n  },\n  { \n    /-\n    \"The proof [of the ii) ⇒ i) direction] proceeds in two parts:\n    -/\n\n    let χ := U ∘ ρ^⊗n ∘ U†,\n\n    /-\n    First we construct a catalyst σ₁ for the exact transition from ρ \n    to the equal mixture χ_bar := 1/n * ∑ k, (χ k) of states (χ k) = pTr_k_bar χ.\" \n    -/\n\n    /-\n    \"Then we use a second catalyst R in state σ₂ to implement the\n    dephasing map and obtain 𝒟_ρ'[χ] , which is ε-close to the target ρ'\n    The part R of the catalyst thus effectively acts as a source of randomness.\"\n    -/\n\n    let ρ'ε := 𝒟_ρ'[χ],\n\n    /-\n    \"By Lemma 5 and the fact that the dephasing map is a mixed unitary channel, \n    this second part can be done in such a way that the two parts of the catalyst \n    remain uncorrelated.\"\n    -/\n\n    /-\n    \"From the results of [35] it follows that σ₂ only needs to have a dimension of \n    the order of √d. Furthermore, note that by perturbing ρ' arbitrarily slightly, \n    we can always ensure that H(ρ) < H(ρ') since we allow for arbitrarily small\n    errors and von Neumann entropy is continuous. We thus only need to prove that \n    we can do the transition ρ →ε=0 χ_bar in the case H(ρ') > H(ρ).\"\n    -/\n\n    /-\n    \"To show this we make use of a trick that was used in recent work by Shiraishi \n    and Sagawa [33].\"\n    -/\n    \n    -- use σ₁ ⊗ σ₂,\n    -- use V,\n \n    -- have hyp_close : D(ρ', Tr (-S) evolve(V σ₂ ⊗ ρ ⊗ σ₁)) ≤ ε, by sorry -- lemma 4\n    -- have hyp_catalysis : Tr S evolve(V σ₂ ⊗ ρ ⊗ σ₁) = σ₂ ⊗ σ₁, by sorry -- lemmas 4 & 5\n  },\nend", "meta": {"author": "BassemSafieldeen", "repo": "Entropy_and_reversible_catalysis", "sha": "5dd6ee062f61e26bbcf254477e3e24aa3fc489af", "save_path": "github-repos/lean/BassemSafieldeen-Entropy_and_reversible_catalysis", "path": "github-repos/lean/BassemSafieldeen-Entropy_and_reversible_catalysis/Entropy_and_reversible_catalysis-5dd6ee062f61e26bbcf254477e3e24aa3fc489af/src/Theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407017, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4506170834570813}}
{"text": "/-\nCopyright (c) 2020 Yury Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Yury Kudryashov, Heather Macbeth, Sébastien Gouëzel\n-/\nimport analysis.calculus.cont_diff\nimport tactic.ring_exp\nimport analysis.normed_space.banach\nimport topology.local_homeomorph\n\n/-!\n# Inverse function theorem\n\nIn this file we prove the inverse function theorem. It says that if a map `f : E → F`\nhas an invertible strict derivative `f'` at `a`, then it is locally invertible,\nand the inverse function has derivative `f' ⁻¹`.\n\nWe define `has_strict_deriv_at.to_local_homeomorph` that repacks a function `f`\nwith a `hf : has_strict_fderiv_at f f' a`, `f' : E ≃L[𝕜] F`, into a `local_homeomorph`.\nThe `to_fun` of this `local_homeomorph` is `defeq` to `f`, so one can apply theorems\nabout `local_homeomorph` to `hf.to_local_homeomorph f`, and get statements about `f`.\n\nThen we define `has_strict_fderiv_at.local_inverse` to be the `inv_fun` of this `local_homeomorph`,\nand prove two versions of the inverse function theorem:\n\n* `has_strict_fderiv_at.to_local_inverse`: if `f` has an invertible derivative `f'` at `a` in the\n  strict sense (`hf`), then `hf.local_inverse f f' a` has derivative `f'.symm` at `f a` in the\n  strict sense;\n\n* `has_strict_fderiv_at.to_local_left_inverse`: if `f` has an invertible derivative `f'` at `a` in\n  the strict sense and `g` is locally left inverse to `f` near `a`, then `g` has derivative\n  `f'.symm` at `f a` in the strict sense.\n\nIn the one-dimensional case we reformulate these theorems in terms of `has_strict_deriv_at` and\n`f'⁻¹`.\n\nWe also reformulate the theorems in terms of `cont_diff`, to give that `C^k` (respectively,\nsmooth) inputs give `C^k` (smooth) inverses.  These versions require that continuous\ndifferentiability implies strict differentiability; this is false over a general field, true over\n`ℝ` or `ℂ` and implemented here assuming `is_R_or_C 𝕂`.\n\nSome related theorems, providing the derivative and higher regularity assuming that we already know\nthe inverse function, are formulated in `fderiv.lean`, `deriv.lean`, and `cont_diff.lean`.\n\n## Notations\n\nIn the section about `approximates_linear_on` we introduce some `local notation` to make formulas\nshorter:\n\n* by `N` we denote `‖f'⁻¹‖`;\n* by `g` we denote the auxiliary contracting map `x ↦ x + f'.symm (y - f x)` used to prove that\n  `{x | f x = y}` is nonempty.\n\n## Tags\n\nderivative, strictly differentiable, continuously differentiable, smooth, inverse function\n-/\n\nopen function set filter metric\nopen_locale topology classical nnreal\n\nnoncomputable theory\n\nvariables {𝕜 : Type*} [nontrivially_normed_field 𝕜]\nvariables {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]\nvariables {F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F]\nvariables {G : Type*} [normed_add_comm_group G] [normed_space 𝕜 G]\nvariables {G' : Type*} [normed_add_comm_group G'] [normed_space 𝕜 G']\nvariables {ε : ℝ}\n\n\nopen asymptotics filter metric set\nopen continuous_linear_map (id)\n\n\n/-!\n### Non-linear maps close to affine maps\n\nIn this section we study a map `f` such that `‖f x - f y - f' (x - y)‖ ≤ c * ‖x - y‖` on an open set\n`s`, where `f' : E →L[𝕜] F` is a continuous linear map and `c` is suitably small. Maps of this type\nbehave like `f a + f' (x - a)` near each `a ∈ s`.\n\nWhen `f'` is onto, we show that `f` is locally onto.\n\nWhen `f'` is a continuous linear equiv, we show that `f` is a homeomorphism\nbetween `s` and `f '' s`. More precisely, we define `approximates_linear_on.to_local_homeomorph` to\nbe a `local_homeomorph` with `to_fun = f`, `source = s`, and `target = f '' s`.\n\nMaps of this type naturally appear in the proof of the inverse function theorem (see next section),\nand `approximates_linear_on.to_local_homeomorph` will imply that the locally inverse function\nexists.\n\nWe define this auxiliary notion to split the proof of the inverse function theorem into small\nlemmas. This approach makes it possible\n\n- to prove a lower estimate on the size of the domain of the inverse function;\n\n- to reuse parts of the proofs in the case if a function is not strictly differentiable. E.g., for a\n  function `f : E × F → G` with estimates on `f x y₁ - f x y₂` but not on `f x₁ y - f x₂ y`.\n-/\n\n/-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`,\nif `‖f x - f y - f' (x - y)‖ ≤ c * ‖x - y‖` whenever `x, y ∈ s`.\n\nThis predicate is defined to facilitate the splitting of the inverse function theorem into small\nlemmas. Some of these lemmas can be useful, e.g., to prove that the inverse function is defined\non a specific set. -/\ndef approximates_linear_on (f : E → F) (f' : E →L[𝕜] F) (s : set E) (c : ℝ≥0) : Prop :=\n∀ (x ∈ s) (y ∈ s), ‖f x - f y - f' (x - y)‖ ≤ c * ‖x - y‖\n\n@[simp] lemma approximates_linear_on_empty (f : E → F) (f' : E →L[𝕜] F) (c : ℝ≥0) :\n  approximates_linear_on f f' ∅ c :=\nby simp [approximates_linear_on]\n\nnamespace approximates_linear_on\n\nvariables [cs : complete_space E] {f : E → F}\n\n/-! First we prove some properties of a function that `approximates_linear_on` a (not necessarily\ninvertible) continuous linear map. -/\n\nsection\n\nvariables {f' : E →L[𝕜] F} {s t : set E} {c c' : ℝ≥0}\n\ntheorem mono_num (hc : c ≤ c') (hf : approximates_linear_on f f' s c) :\n  approximates_linear_on f f' s c' :=\nλ x hx y hy, le_trans (hf x hx y hy) (mul_le_mul_of_nonneg_right hc $ norm_nonneg _)\n\ntheorem mono_set (hst : s ⊆ t) (hf : approximates_linear_on f f' t c) :\n  approximates_linear_on f f' s c :=\nλ x hx y hy, hf x (hst hx) y (hst hy)\n\nlemma approximates_linear_on_iff_lipschitz_on_with\n  {f : E → F} {f' : E →L[𝕜] F} {s : set E} {c : ℝ≥0} :\n  approximates_linear_on f f' s c ↔ lipschitz_on_with c (f - f') s :=\nbegin\n  have : ∀ x y, f x - f y - f' (x - y) = (f - f') x - (f - f') y,\n  { assume x y, simp only [map_sub, pi.sub_apply], abel },\n  simp only [this, lipschitz_on_with_iff_norm_sub_le, approximates_linear_on],\nend\n\nalias approximates_linear_on_iff_lipschitz_on_with ↔\n  lipschitz_on_with _root_.lipschitz_on_with.approximates_linear_on\n\nlemma lipschitz_sub (hf : approximates_linear_on f f' s c) :\n  lipschitz_with c (λ x : s, f x - f' x) :=\nbegin\n  refine lipschitz_with.of_dist_le_mul (λ x y, _),\n  rw [dist_eq_norm, subtype.dist_eq, dist_eq_norm],\n  convert hf x x.2 y y.2 using 2,\n  rw [f'.map_sub], abel\nend\n\nprotected lemma lipschitz (hf : approximates_linear_on f f' s c) :\n  lipschitz_with (‖f'‖₊ + c) (s.restrict f) :=\nby simpa only [restrict_apply, add_sub_cancel'_right]\n  using (f'.lipschitz.restrict s).add hf.lipschitz_sub\n\nprotected lemma continuous (hf : approximates_linear_on f f' s c) :\n  continuous (s.restrict f) :=\nhf.lipschitz.continuous\n\nprotected lemma continuous_on (hf : approximates_linear_on f f' s c) :\n  continuous_on f s :=\ncontinuous_on_iff_continuous_restrict.2 hf.continuous\n\nend\n\nsection locally_onto\n/-!\nWe prove that a function which is linearly approximated by a continuous linear map with a nonlinear\nright inverse is locally onto. This will apply to the case where the approximating map is a linear\nequivalence, for the local inverse theorem, but also whenever the approximating map is onto,\nby Banach's open mapping theorem. -/\n\ninclude cs\n\nvariables {s : set E} {c : ℝ≥0} {f' : E →L[𝕜] F}\n\n/-- If a function is linearly approximated by a continuous linear map with a (possibly nonlinear)\nright inverse, then it is locally onto: a ball of an explicit radius is included in the image\nof the map. -/\ntheorem surj_on_closed_ball_of_nonlinear_right_inverse\n  (hf : approximates_linear_on f f' s c)  (f'symm : f'.nonlinear_right_inverse)\n  {ε : ℝ} {b : E} (ε0 : 0 ≤ ε) (hε : closed_ball b ε ⊆ s) :\n  surj_on f (closed_ball b ε) (closed_ball (f b) (((f'symm.nnnorm : ℝ)⁻¹ - c) * ε)) :=\nbegin\n  assume y hy,\n  cases le_or_lt (f'symm.nnnorm : ℝ) ⁻¹ c with hc hc,\n  { refine ⟨b, by simp [ε0], _⟩,\n    have : dist y (f b) ≤ 0 :=\n      (mem_closed_ball.1 hy).trans (mul_nonpos_of_nonpos_of_nonneg (by linarith) ε0),\n    simp only [dist_le_zero] at this,\n    rw this },\n  have If' : (0 : ℝ) < f'symm.nnnorm,\n    by { rw [← inv_pos], exact (nnreal.coe_nonneg _).trans_lt hc },\n  have Icf' : (c : ℝ) * f'symm.nnnorm < 1, by rwa [inv_eq_one_div, lt_div_iff If'] at hc,\n  have Jf' : (f'symm.nnnorm : ℝ) ≠ 0 := ne_of_gt If',\n  have Jcf' : (1 : ℝ) - c * f'symm.nnnorm ≠ 0, by { apply ne_of_gt, linarith },\n  /- We have to show that `y` can be written as `f x` for some `x ∈ closed_ball b ε`.\n  The idea of the proof is to apply the Banach contraction principle to the map\n  `g : x ↦ x + f'symm (y - f x)`, as a fixed point of this map satisfies `f x = y`.\n  When `f'symm` is a genuine linear inverse, `g` is a contracting map. In our case, since `f'symm`\n  is nonlinear, this map is not contracting (it is not even continuous), but still the proof of\n  the contraction theorem holds: `uₙ = gⁿ b` is a Cauchy sequence, converging exponentially fast\n  to the desired point `x`. Instead of appealing to general results, we check this by hand.\n\n  The main point is that `f (u n)` becomes exponentially close to `y`, and therefore\n  `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive\n  bound on `dist (u n) b`, from which one checks that `u n` stays in the ball on which one has a\n  control. Therefore, the bound can be checked at the next step, and so on inductively.\n  -/\n  set g := λ x, x + f'symm (y - f x) with hg,\n  set u := λ (n : ℕ), g ^[n] b with hu,\n  have usucc : ∀ n, u (n + 1) = g (u n), by simp [hu, ← iterate_succ_apply' g _ b],\n  -- First bound: if `f z` is close to `y`, then `g z` is close to `z` (i.e., almost a fixed point).\n  have A : ∀ z, dist (g z) z ≤ f'symm.nnnorm * dist (f z) y,\n  { assume z,\n    rw [dist_eq_norm, hg, add_sub_cancel', dist_eq_norm'],\n    exact f'symm.bound _ },\n  -- Second bound: if `z` and `g z` are in the set with good control, then `f (g z)` becomes closer\n  -- to `y` than `f z` was (this uses the linear approximation property, and is the reason for the\n  -- choice of the formula for `g`).\n  have B : ∀ z ∈ closed_ball b ε, g z ∈ closed_ball b ε →\n    dist (f (g z)) y ≤ c * f'symm.nnnorm * dist (f z) y,\n  { assume z hz hgz,\n    set v := f'symm (y - f z) with hv,\n    calc dist (f (g z)) y = ‖f (z + v) - y‖ : by rw [dist_eq_norm]\n    ... = ‖f (z + v) - f  z - f' v + f' v - (y - f z)‖ : by { congr' 1, abel }\n    ... = ‖f (z + v) - f z - f' ((z + v) - z)‖ :\n      by simp only [continuous_linear_map.nonlinear_right_inverse.right_inv,\n                    add_sub_cancel', sub_add_cancel]\n    ... ≤ c * ‖(z + v) - z‖ : hf _ (hε hgz) _ (hε hz)\n    ... ≤ c * (f'symm.nnnorm * dist (f z) y) : begin\n      apply mul_le_mul_of_nonneg_left _ (nnreal.coe_nonneg c),\n      simpa [hv, dist_eq_norm'] using f'symm.bound (y - f z),\n    end\n    ... = c * f'symm.nnnorm * dist (f z) y : by ring },\n  -- Third bound: a complicated bound on `dist w b` (that will show up in the induction) is enough\n  -- to check that `w` is in the ball on which one has controls. Will be used to check that `u n`\n  -- belongs to this ball for all `n`.\n  have C : ∀ (n : ℕ) (w : E),\n    dist w b ≤ f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y\n    → w ∈ closed_ball b ε,\n  { assume n w hw,\n    apply hw.trans,\n    rw [div_mul_eq_mul_div, div_le_iff], swap, { linarith },\n    calc (f'symm.nnnorm : ℝ) * (1 - (c * f'symm.nnnorm) ^ n) * dist (f b) y\n      = f'symm.nnnorm * dist (f b) y * (1 - (c * f'symm.nnnorm) ^ n) : by ring\n      ... ≤ f'symm.nnnorm * dist (f b) y * 1 :\n      begin\n        apply mul_le_mul_of_nonneg_left _ (mul_nonneg (nnreal.coe_nonneg _) dist_nonneg),\n        rw [sub_le_self_iff],\n        exact pow_nonneg (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _)) _,\n      end\n    ... ≤ f'symm.nnnorm * (((f'symm.nnnorm : ℝ)⁻¹ - c) * ε) :\n      by { rw [mul_one],\n           exact mul_le_mul_of_nonneg_left (mem_closed_ball'.1 hy) (nnreal.coe_nonneg _) }\n    ... = ε * (1 - c * f'symm.nnnorm) : by { field_simp, ring } },\n  /- Main inductive control: `f (u n)` becomes exponentially close to `y`, and therefore\n  `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive\n  bound on `dist (u n) b`, from which one checks that `u n` remains in the ball on which we\n  have estimates. -/\n  have D : ∀ (n : ℕ), dist (f (u n)) y ≤ (c * f'symm.nnnorm)^n * dist (f b) y\n    ∧ dist (u n) b ≤ f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm)\n      * dist (f b) y,\n  { assume n,\n    induction n with n IH, { simp [hu, le_refl] },\n    rw usucc,\n    have Ign : dist (g (u n)) b ≤\n      f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n.succ) / (1 - c * f'symm.nnnorm) * dist (f b) y :=\n    calc\n      dist (g (u n)) b ≤ dist (g (u n)) (u n) + dist (u n) b : dist_triangle _ _ _\n      ... ≤ f'symm.nnnorm * dist (f (u n)) y + dist (u n) b : add_le_add (A _) le_rfl\n      ... ≤ f'symm.nnnorm * ((c * f'symm.nnnorm)^n * dist (f b) y) +\n        f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y :\n          add_le_add (mul_le_mul_of_nonneg_left IH.1 (nnreal.coe_nonneg _)) IH.2\n      ... = f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n.succ) / (1 - c * f'symm.nnnorm)\n        * dist (f b) y : by { field_simp [Jcf'], ring_exp },\n    refine ⟨_, Ign⟩,\n    calc dist (f (g (u n))) y ≤ c * f'symm.nnnorm * dist (f (u n)) y :\n      B _ (C n _ IH.2) (C n.succ _ Ign)\n    ... ≤ (c * f'symm.nnnorm) * ((c * f'symm.nnnorm)^n * dist (f b) y) :\n      mul_le_mul_of_nonneg_left IH.1 (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _))\n    ... = (c * f'symm.nnnorm) ^ n.succ * dist (f b) y : by ring_exp },\n  -- Deduce from the inductive bound that `uₙ` is a Cauchy sequence, therefore converging.\n  have : cauchy_seq u,\n  { have : ∀ (n : ℕ), dist (u n) (u (n+1)) ≤ f'symm.nnnorm * dist (f b) y * (c * f'symm.nnnorm)^n,\n    { assume n,\n      calc dist (u n) (u (n+1)) = dist (g (u n)) (u n) :  by rw [usucc, dist_comm]\n      ... ≤ f'symm.nnnorm * dist (f (u n)) y : A _\n      ... ≤ f'symm.nnnorm * ((c * f'symm.nnnorm)^n * dist (f b) y) :\n        mul_le_mul_of_nonneg_left (D n).1 (nnreal.coe_nonneg _)\n      ... = f'symm.nnnorm * dist (f b) y * (c * f'symm.nnnorm)^n : by ring },\n    exact cauchy_seq_of_le_geometric _ _ Icf' this },\n  obtain ⟨x, hx⟩ : ∃ x, tendsto u at_top (𝓝 x) := cauchy_seq_tendsto_of_complete this,\n  -- As all the `uₙ` belong to the ball `closed_ball b ε`, so does their limit `x`.\n  have xmem : x ∈ closed_ball b ε :=\n    is_closed_ball.mem_of_tendsto hx (eventually_of_forall (λ n, C n _ (D n).2)),\n  refine ⟨x, xmem, _⟩,\n  -- It remains to check that `f x = y`. This follows from continuity of `f` on `closed_ball b ε`\n  -- and from the fact that `f uₙ` is converging to `y` by construction.\n  have hx' : tendsto u at_top (𝓝[closed_ball b ε] x),\n  { simp only [nhds_within, tendsto_inf, hx, true_and, ge_iff_le, tendsto_principal],\n    exact eventually_of_forall (λ n, C n _ (D n).2) },\n  have T1 : tendsto (λ n, f (u n)) at_top (𝓝 (f x)) :=\n    (hf.continuous_on.mono hε x xmem).tendsto.comp hx',\n  have T2 : tendsto (λ n, f (u n)) at_top (𝓝 y),\n  { rw tendsto_iff_dist_tendsto_zero,\n    refine squeeze_zero (λ n, dist_nonneg) (λ n, (D n).1) _,\n    simpa using (tendsto_pow_at_top_nhds_0_of_lt_1\n      (mul_nonneg (nnreal.coe_nonneg _) (nnreal.coe_nonneg _)) Icf').mul tendsto_const_nhds },\n  exact tendsto_nhds_unique T1 T2,\nend\n\nlemma open_image (hf : approximates_linear_on f f' s c) (f'symm : f'.nonlinear_right_inverse)\n  (hs : is_open s) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) : is_open (f '' s) :=\nbegin\n  cases hc with hE hc, { resetI, apply is_open_discrete },\n  simp only [is_open_iff_mem_nhds, nhds_basis_closed_ball.mem_iff, ball_image_iff] at hs ⊢,\n  intros x hx,\n  rcases hs x hx with ⟨ε, ε0, hε⟩,\n  refine ⟨(f'symm.nnnorm⁻¹ - c) * ε, mul_pos (sub_pos.2 hc) ε0, _⟩,\n  exact (hf.surj_on_closed_ball_of_nonlinear_right_inverse f'symm (le_of_lt ε0) hε).mono\n    hε (subset.refl _)\nend\n\nlemma image_mem_nhds (hf : approximates_linear_on f f' s c) (f'symm : f'.nonlinear_right_inverse)\n  {x : E} (hs : s ∈ 𝓝 x) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) :\n  f '' s ∈ 𝓝 (f x) :=\nbegin\n  obtain ⟨t, hts, ht, xt⟩ : ∃ t ⊆ s, is_open t ∧ x ∈ t := _root_.mem_nhds_iff.1 hs,\n  have := is_open.mem_nhds ((hf.mono_set hts).open_image f'symm ht hc) (mem_image_of_mem _ xt),\n  exact mem_of_superset this (image_subset _ hts),\nend\n\nlemma map_nhds_eq (hf : approximates_linear_on f f' s c) (f'symm : f'.nonlinear_right_inverse)\n  {x : E} (hs : s ∈ 𝓝 x) (hc : subsingleton F ∨ c < f'symm.nnnorm⁻¹) :\n  map f (𝓝 x) = 𝓝 (f x) :=\nbegin\n  refine le_antisymm ((hf.continuous_on x (mem_of_mem_nhds hs)).continuous_at hs)\n    (le_map (λ t ht, _)),\n  have : f '' (s ∩ t) ∈ 𝓝 (f x) := (hf.mono_set (inter_subset_left s t)).image_mem_nhds\n    f'symm (inter_mem hs ht) hc,\n  exact mem_of_superset this (image_subset _ (inter_subset_right _ _)),\nend\n\nend locally_onto\n\n/-!\nFrom now on we assume that `f` approximates an invertible continuous linear map `f : E ≃L[𝕜] F`.\n\nWe also assume that either `E = {0}`, or `c < ‖f'⁻¹‖⁻¹`. We use `N` as an abbreviation for `‖f'⁻¹‖`.\n-/\n\nvariables {f' : E ≃L[𝕜] F} {s : set E} {c : ℝ≥0}\n\nlocal notation `N` := ‖(f'.symm : F →L[𝕜] E)‖₊\n\nprotected lemma antilipschitz (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  antilipschitz_with (N⁻¹ - c)⁻¹ (s.restrict f) :=\nbegin\n  cases hc with hE hc,\n  { haveI : subsingleton s := ⟨λ x y, subtype.eq $ @subsingleton.elim _ hE _ _⟩,\n    exact antilipschitz_with.of_subsingleton },\n  convert (f'.antilipschitz.restrict s).add_lipschitz_with hf.lipschitz_sub hc,\n  simp [restrict]\nend\n\nprotected lemma injective (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  injective (s.restrict f) :=\n(hf.antilipschitz hc).injective\n\nprotected lemma inj_on (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  inj_on f s :=\ninj_on_iff_injective.2 $ hf.injective hc\n\nprotected lemma surjective [complete_space E]\n  (hf : approximates_linear_on f (f' : E →L[𝕜] F) univ c) (hc : subsingleton E ∨ c < N⁻¹) :\n  surjective f :=\nbegin\n  cases hc with hE hc,\n  { haveI : subsingleton F := (equiv.subsingleton_congr f'.to_linear_equiv.to_equiv).1 hE,\n    exact surjective_to_subsingleton _ },\n  { apply forall_of_forall_mem_closed_ball (λ (y : F), ∃ a, f a = y) (f 0) _,\n    have hc' : (0 : ℝ) < N⁻¹ - c, by { rw sub_pos, exact hc },\n    let p : ℝ → Prop := λ R, closed_ball (f 0) R ⊆ set.range f,\n    have hp : ∀ᶠ (r:ℝ) in at_top, p ((N⁻¹ - c) * r),\n    { have hr : ∀ᶠ (r:ℝ) in at_top, 0 ≤ r := eventually_ge_at_top 0,\n      refine hr.mono (λ r hr, subset.trans _ (image_subset_range f (closed_ball 0 r))),\n      refine hf.surj_on_closed_ball_of_nonlinear_right_inverse f'.to_nonlinear_right_inverse hr _,\n      exact subset_univ _ },\n    refine ((tendsto_id.const_mul_at_top hc').frequently hp.frequently).mono _,\n    exact λ R h y hy, h hy },\nend\n\n/-- A map approximating a linear equivalence on a set defines a local equivalence on this set.\nShould not be used outside of this file, because it is superseded by `to_local_homeomorph` below.\n\nThis is a first step towards the inverse function. -/\ndef to_local_equiv (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) : local_equiv E F :=\n(hf.inj_on hc).to_local_equiv _ _\n\n/-- The inverse function is continuous on `f '' s`. Use properties of `local_homeomorph` instead. -/\nlemma inverse_continuous_on (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  continuous_on (hf.to_local_equiv hc).symm (f '' s) :=\nbegin\n  apply continuous_on_iff_continuous_restrict.2,\n  refine ((hf.antilipschitz hc).to_right_inv_on' _ (hf.to_local_equiv hc).right_inv').continuous,\n  exact (λ x hx, (hf.to_local_equiv hc).map_target hx)\nend\n\n/-- The inverse function is approximated linearly on `f '' s` by `f'.symm`. -/\nlemma to_inv (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  approximates_linear_on (hf.to_local_equiv hc).symm (f'.symm : F →L[𝕜] E) (f '' s)\n    (N * (N⁻¹ - c)⁻¹ * c) :=\nbegin\n  assume x hx y hy,\n  set A := hf.to_local_equiv hc with hA,\n  have Af : ∀ z, A z = f z := λ z, rfl,\n  rcases (mem_image _ _ _).1 hx with ⟨x', x's, rfl⟩,\n  rcases (mem_image _ _ _).1 hy with ⟨y', y's, rfl⟩,\n  rw [← Af x', ← Af y', A.left_inv x's, A.left_inv y's],\n  calc ‖x' - y' - (f'.symm) (A x' - A y')‖\n      ≤ N * ‖f' (x' - y' - (f'.symm) (A x' - A y'))‖ :\n    (f' : E →L[𝕜] F).bound_of_antilipschitz f'.antilipschitz _\n  ... = N * ‖A y' - A x' - f' (y' - x')‖ :\n    begin\n      congr' 2,\n      simp only [continuous_linear_equiv.apply_symm_apply, continuous_linear_equiv.map_sub],\n      abel,\n    end\n  ... ≤ N * (c * ‖y' - x'‖) :\n    mul_le_mul_of_nonneg_left (hf _ y's _ x's) (nnreal.coe_nonneg _)\n  ... ≤ N * (c * (((N⁻¹ - c)⁻¹ : ℝ≥0) * ‖A y' - A x'‖)) :\n    begin\n      apply_rules [mul_le_mul_of_nonneg_left, nnreal.coe_nonneg],\n      rw [← dist_eq_norm, ← dist_eq_norm],\n      exact (hf.antilipschitz hc).le_mul_dist ⟨y', y's⟩ ⟨x', x's⟩,\n    end\n  ... = (N * (N⁻¹ - c)⁻¹ * c : ℝ≥0) * ‖A x' - A y'‖ :\n    by { simp only [norm_sub_rev, nonneg.coe_mul], ring }\nend\n\ninclude cs\n\nsection\nvariables (f s)\n\n/-- Given a function `f` that approximates a linear equivalence on an open set `s`,\nreturns a local homeomorph with `to_fun = f` and `source = s`. -/\ndef to_local_homeomorph (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) : local_homeomorph E F :=\n{ to_local_equiv := hf.to_local_equiv hc,\n  open_source := hs,\n  open_target := hf.open_image f'.to_nonlinear_right_inverse hs\n    (by rwa f'.to_linear_equiv.to_equiv.subsingleton_congr at hc),\n  continuous_to_fun := hf.continuous_on,\n  continuous_inv_fun := hf.inverse_continuous_on hc }\n\n/-- A function `f` that approximates a linear equivalence on the whole space is a homeomorphism. -/\ndef to_homeomorph (hf : approximates_linear_on f (f' : E →L[𝕜] F) univ c)\n  (hc : subsingleton E ∨ c < N⁻¹) :\n  E ≃ₜ F :=\nbegin\n  refine (hf.to_local_homeomorph _ _ hc is_open_univ).to_homeomorph_of_source_eq_univ_target_eq_univ\n    rfl _,\n  change f '' univ = univ,\n  rw [image_univ, range_iff_surjective],\n  exact hf.surjective hc,\nend\n\nomit cs\n\n/-- In a real vector space, a function `f` that approximates a linear equivalence on a subset `s`\ncan be extended to a homeomorphism of the whole space. -/\nlemma exists_homeomorph_extension {E : Type*} [normed_add_comm_group E] [normed_space ℝ E]\n  {F : Type*} [normed_add_comm_group F] [normed_space ℝ F] [finite_dimensional ℝ F]\n  {s : set E} {f : E → F} {f' : E ≃L[ℝ] F} {c : ℝ≥0}\n  (hf : approximates_linear_on f (f' : E →L[ℝ] F) s c)\n  (hc : subsingleton E ∨ lipschitz_extension_constant F * c < (‖(f'.symm : F →L[ℝ] E)‖₊)⁻¹) :\n  ∃ g : E ≃ₜ F, eq_on f g s :=\nbegin\n  -- the difference `f - f'` is Lipschitz on `s`. It can be extended to a Lipschitz function `u`\n  -- on the whole space, with a slightly worse Lipschitz constant. Then `f' + u` will be the\n  -- desired homeomorphism.\n  obtain ⟨u, hu, uf⟩ : ∃ (u : E → F), lipschitz_with (lipschitz_extension_constant F * c) u\n    ∧ eq_on (f - f') u s := hf.lipschitz_on_with.extend_finite_dimension,\n  let g : E → F := λ x, f' x + u x,\n  have fg : eq_on f g s := λ x hx, by simp_rw [g, ← uf hx, pi.sub_apply, add_sub_cancel'_right],\n  have hg : approximates_linear_on g (f' : E →L[ℝ] F) univ (lipschitz_extension_constant F * c),\n  { apply lipschitz_on_with.approximates_linear_on,\n    rw lipschitz_on_univ,\n    convert hu,\n    ext x,\n    simp only [add_sub_cancel', continuous_linear_equiv.coe_coe, pi.sub_apply] },\n  haveI : finite_dimensional ℝ E := f'.symm.to_linear_equiv.finite_dimensional,\n  exact ⟨hg.to_homeomorph g hc, fg⟩,\nend\n\nend\n\n@[simp] lemma to_local_homeomorph_coe (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs : E → F) = f := rfl\n\n@[simp] lemma to_local_homeomorph_source (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs).source = s := rfl\n\n@[simp] lemma to_local_homeomorph_target (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs).target = f '' s := rfl\n\nlemma closed_ball_subset_target (hf : approximates_linear_on f (f' : E →L[𝕜] F) s c)\n  (hc : subsingleton E ∨ c < N⁻¹) (hs : is_open s) {b : E} (ε0 : 0 ≤ ε) (hε : closed_ball b ε ⊆ s) :\n  closed_ball (f b) ((N⁻¹ - c) * ε) ⊆ (hf.to_local_homeomorph f s hc hs).target :=\n(hf.surj_on_closed_ball_of_nonlinear_right_inverse f'.to_nonlinear_right_inverse\n  ε0 hε).mono hε (subset.refl _)\n\nend approximates_linear_on\n\n/-!\n### Inverse function theorem\n\nNow we prove the inverse function theorem. Let `f : E → F` be a map defined on a complete vector\nspace `E`. Assume that `f` has an invertible derivative `f' : E ≃L[𝕜] F` at `a : E` in the strict\nsense. Then `f` approximates `f'` in the sense of `approximates_linear_on` on an open neighborhood\nof `a`, and we can apply `approximates_linear_on.to_local_homeomorph` to construct the inverse\nfunction. -/\n\nnamespace has_strict_fderiv_at\n\n/-- If `f` has derivative `f'` at `a` in the strict sense and `c > 0`, then `f` approximates `f'`\nwith constant `c` on some neighborhood of `a`. -/\nlemma approximates_deriv_on_nhds {f : E → F} {f' : E →L[𝕜] F} {a : E}\n  (hf : has_strict_fderiv_at f f' a) {c : ℝ≥0} (hc : subsingleton E ∨ 0 < c) :\n  ∃ s ∈ 𝓝 a, approximates_linear_on f f' s c :=\nbegin\n  cases hc with hE hc,\n  { refine ⟨univ, is_open.mem_nhds is_open_univ trivial, λ x hx y hy, _⟩,\n    simp [@subsingleton.elim E hE x y] },\n  have := hf.def hc,\n  rw [nhds_prod_eq, filter.eventually, mem_prod_same_iff] at this,\n  rcases this with ⟨s, has, hs⟩,\n  exact ⟨s, has, λ x hx y hy, hs (mk_mem_prod hx hy)⟩\nend\n\nlemma map_nhds_eq_of_surj [complete_space E] [complete_space F]\n  {f : E → F} {f' : E →L[𝕜] F} {a : E}\n  (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) (h : linear_map.range f' = ⊤) :\n  map f (𝓝 a) = 𝓝 (f a) :=\nbegin\n  let f'symm := f'.nonlinear_right_inverse_of_surjective h,\n  set c : ℝ≥0 := f'symm.nnnorm⁻¹ / 2 with hc,\n  have f'symm_pos : 0 < f'symm.nnnorm := f'.nonlinear_right_inverse_of_surjective_nnnorm_pos h,\n  have cpos : 0 < c, by simp [hc, half_pos, inv_pos, f'symm_pos],\n  obtain ⟨s, s_nhds, hs⟩ : ∃ s ∈ 𝓝 a, approximates_linear_on f f' s c :=\n    hf.approximates_deriv_on_nhds (or.inr cpos),\n  apply hs.map_nhds_eq f'symm s_nhds (or.inr (nnreal.half_lt_self _)),\n  simp [ne_of_gt f'symm_pos],\nend\n\nvariables [cs : complete_space E] {f : E → F} {f' : E ≃L[𝕜] F} {a : E}\n\nlemma approximates_deriv_on_open_nhds (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∃ (s : set E) (hs : a ∈ s ∧ is_open s),\n    approximates_linear_on f (f' : E →L[𝕜] F) s (‖(f'.symm : F →L[𝕜] E)‖₊⁻¹ / 2) :=\nbegin\n  refine ((nhds_basis_opens a).exists_iff _).1 _,\n  exact (λ s t, approximates_linear_on.mono_set),\n  exact (hf.approximates_deriv_on_nhds $ f'.subsingleton_or_nnnorm_symm_pos.imp id $\n    λ hf', half_pos $ inv_pos.2 hf')\nend\n\ninclude cs\n\nvariable (f)\n\n/-- Given a function with an invertible strict derivative at `a`, returns a `local_homeomorph`\nwith `to_fun = f` and `a ∈ source`. This is a part of the inverse function theorem.\nThe other part `has_strict_fderiv_at.to_local_inverse` states that the inverse function\nof this `local_homeomorph` has derivative `f'.symm`. -/\ndef to_local_homeomorph (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) : local_homeomorph E F :=\napproximates_linear_on.to_local_homeomorph f\n  (classical.some hf.approximates_deriv_on_open_nhds)\n  (classical.some_spec hf.approximates_deriv_on_open_nhds).snd\n  (f'.subsingleton_or_nnnorm_symm_pos.imp id $ λ hf', nnreal.half_lt_self $ ne_of_gt $\n    inv_pos.2 hf')\n  (classical.some_spec hf.approximates_deriv_on_open_nhds).fst.2\n\nvariable {f}\n\n@[simp] lemma to_local_homeomorph_coe (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  (hf.to_local_homeomorph f : E → F) = f := rfl\n\nlemma mem_to_local_homeomorph_source (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  a ∈ (hf.to_local_homeomorph f).source :=\n(classical.some_spec hf.approximates_deriv_on_open_nhds).fst.1\n\nlemma image_mem_to_local_homeomorph_target (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  f a ∈ (hf.to_local_homeomorph f).target :=\n(hf.to_local_homeomorph f).map_source hf.mem_to_local_homeomorph_source\n\nlemma map_nhds_eq_of_equiv (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  map f (𝓝 a) = 𝓝 (f a) :=\n(hf.to_local_homeomorph f).map_nhds_eq hf.mem_to_local_homeomorph_source\n\nvariables (f f' a)\n\n/-- Given a function `f` with an invertible derivative, returns a function that is locally inverse\nto `f`. -/\ndef local_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) : F → E :=\n(hf.to_local_homeomorph f).symm\n\nvariables {f f' a}\n\nlemma local_inverse_def (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  hf.local_inverse f _ _ = (hf.to_local_homeomorph f).symm :=\nrfl\n\nlemma eventually_left_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∀ᶠ x in 𝓝 a, hf.local_inverse f f' a (f x) = x :=\n(hf.to_local_homeomorph f).eventually_left_inverse hf.mem_to_local_homeomorph_source\n\n@[simp] \n\nlemma eventually_right_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  ∀ᶠ y in 𝓝 (f a), f (hf.local_inverse f f' a y) = y :=\n(hf.to_local_homeomorph f).eventually_right_inverse' hf.mem_to_local_homeomorph_source\n\nlemma local_inverse_continuous_at (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  continuous_at (hf.local_inverse f f' a) (f a) :=\n(hf.to_local_homeomorph f).continuous_at_symm hf.image_mem_to_local_homeomorph_target\n\nlemma local_inverse_tendsto (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  tendsto (hf.local_inverse f f' a) (𝓝 $ f a) (𝓝 a) :=\n(hf.to_local_homeomorph f).tendsto_symm hf.mem_to_local_homeomorph_source\n\nlemma local_inverse_unique (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) {g : F → E}\n  (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  ∀ᶠ y in 𝓝 (f a), g y = local_inverse f f' a hf y :=\neventually_eq_of_left_inv_of_right_inv hg hf.eventually_right_inverse $\n  (hf.to_local_homeomorph f).tendsto_symm hf.mem_to_local_homeomorph_source\n\n/-- If `f` has an invertible derivative `f'` at `a` in the sense of strict differentiability `(hf)`,\nthen the inverse function `hf.local_inverse f` has derivative `f'.symm` at `f a`. -/\ntheorem to_local_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) :\n  has_strict_fderiv_at (hf.local_inverse f f' a) (f'.symm : F →L[𝕜] E) (f a) :=\n(hf.to_local_homeomorph f).has_strict_fderiv_at_symm hf.image_mem_to_local_homeomorph_target $\n  by simpa [← local_inverse_def] using hf\n\n/-- If `f : E → F` has an invertible derivative `f'` at `a` in the sense of strict differentiability\nand `g (f x) = x` in a neighborhood of `a`, then `g` has derivative `f'.symm` at `f a`.\n\nFor a version assuming `f (g y) = y` and continuity of `g` at `f a` but not `[complete_space E]`\nsee `of_local_left_inverse`.  -/\ntheorem to_local_left_inverse (hf : has_strict_fderiv_at f (f' : E →L[𝕜] F) a) {g : F → E}\n  (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  has_strict_fderiv_at g (f'.symm : F →L[𝕜] E) (f a) :=\nhf.to_local_inverse.congr_of_eventually_eq $ (hf.local_inverse_unique hg).mono $ λ _, eq.symm\n\nend has_strict_fderiv_at\n\n/-- If a function has an invertible strict derivative at all points, then it is an open map. -/\nlemma open_map_of_strict_fderiv_equiv [complete_space E] {f : E → F} {f' : E → E ≃L[𝕜] F}\n  (hf : ∀ x, has_strict_fderiv_at f (f' x : E →L[𝕜] F) x) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ λ x, (hf x).map_nhds_eq_of_equiv.ge\n\n/-!\n### Inverse function theorem, 1D case\n\nIn this case we prove a version of the inverse function theorem for maps `f : 𝕜 → 𝕜`.\nWe use `continuous_linear_equiv.units_equiv_aut` to translate `has_strict_deriv_at f f' a` and\n`f' ≠ 0` into `has_strict_fderiv_at f (_ : 𝕜 ≃L[𝕜] 𝕜) a`.\n-/\n\nnamespace has_strict_deriv_at\n\nvariables [cs : complete_space 𝕜] {f : 𝕜 → 𝕜} {f' a : 𝕜} (hf : has_strict_deriv_at f f' a)\n  (hf' : f' ≠ 0)\n\ninclude cs\n\nvariables (f f' a)\n\n/-- A function that is inverse to `f` near `a`. -/\n@[reducible] def local_inverse : 𝕜 → 𝕜 :=\n(hf.has_strict_fderiv_at_equiv hf').local_inverse _ _ _\n\nvariables {f f' a}\n\nlemma map_nhds_eq : map f (𝓝 a) = 𝓝 (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').map_nhds_eq_of_equiv\n\ntheorem to_local_inverse : has_strict_deriv_at (hf.local_inverse f f' a hf') f'⁻¹ (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_inverse\n\ntheorem to_local_left_inverse {g : 𝕜 → 𝕜} (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) :\n  has_strict_deriv_at g f'⁻¹ (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_left_inverse hg\n\nend has_strict_deriv_at\n\n/-- If a function has a non-zero strict derivative at all points, then it is an open map. -/\nlemma open_map_of_strict_deriv [complete_space 𝕜] {f f' : 𝕜 → 𝕜}\n  (hf : ∀ x, has_strict_deriv_at f (f' x) x) (h0 : ∀ x, f' x ≠ 0) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ λ x, ((hf x).map_nhds_eq (h0 x)).ge\n\n/-!\n### Inverse function theorem, smooth case\n\n-/\n\nnamespace cont_diff_at\nvariables {𝕂 : Type*} [is_R_or_C 𝕂]\nvariables {E' : Type*} [normed_add_comm_group E'] [normed_space 𝕂 E']\nvariables {F' : Type*} [normed_add_comm_group F'] [normed_space 𝕂 F']\nvariables [complete_space E'] (f : E' → F') {f' : E' ≃L[𝕂] F'} {a : E'}\n\n/-- Given a `cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible\nderivative at `a`, returns a `local_homeomorph` with `to_fun = f` and `a ∈ source`. -/\ndef to_local_homeomorph\n  {n : ℕ∞} (hf : cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  local_homeomorph E' F' :=\n(hf.has_strict_fderiv_at' hf' hn).to_local_homeomorph f\n\nvariable {f}\n\n@[simp] lemma to_local_homeomorph_coe\n  {n : ℕ∞} (hf : cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  (hf.to_local_homeomorph f hf' hn : E' → F') = f := rfl\n\nlemma mem_to_local_homeomorph_source\n  {n : ℕ∞} (hf : cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  a ∈ (hf.to_local_homeomorph f hf' hn).source :=\n(hf.has_strict_fderiv_at' hf' hn).mem_to_local_homeomorph_source\n\nlemma image_mem_to_local_homeomorph_target\n  {n : ℕ∞} (hf : cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  f a ∈ (hf.to_local_homeomorph f hf' hn).target :=\n(hf.has_strict_fderiv_at' hf' hn).image_mem_to_local_homeomorph_target\n\n/-- Given a `cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible derivative\nat `a`, returns a function that is locally inverse to `f`. -/\ndef local_inverse\n  {n : ℕ∞} (hf : cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  F' → E' :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse f f' a\n\nlemma local_inverse_apply_image\n  {n : ℕ∞} (hf : cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  hf.local_inverse hf' hn (f a) = a :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse_apply_image\n\n/-- Given a `cont_diff` function over `𝕂` (which is `ℝ` or `ℂ`) with an invertible derivative\nat `a`, the inverse function (produced by `cont_diff.to_local_homeomorph`) is\nalso `cont_diff`. -/\nlemma to_local_inverse\n  {n : ℕ∞} (hf : cont_diff_at 𝕂 n f a) (hf' : has_fderiv_at f (f' : E' →L[𝕂] F') a)\n  (hn : 1 ≤ n) :\n  cont_diff_at 𝕂 n (hf.local_inverse hf' hn) (f a) :=\nbegin\n  have := hf.local_inverse_apply_image hf' hn,\n  apply (hf.to_local_homeomorph f hf' hn).cont_diff_at_symm\n    (image_mem_to_local_homeomorph_target hf hf' hn),\n  { convert hf' },\n  { convert hf }\nend\n\nend cont_diff_at\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/analysis/calculus/inverse.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834734, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4505558760147188}}
{"text": "/-\nCopyright (c) 2021 Oliver Nash. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Oliver Nash\n\n! This file was ported from Lean 3 source module algebra.lie.semisimple\n! leanprover-community/mathlib commit 356447fe00e75e54777321045cdff7c9ea212e60\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.Algebra.Lie.Solvable\n\n/-!\n# Semisimple Lie algebras\n\nThe famous Cartan-Dynkin-Killing classification of semisimple Lie algebras renders them one of the\nmost important classes of Lie algebras. In this file we define simple and semisimple Lie algebras\nand prove some basic related results.\n\n## Main definitions\n\n  * `lie_module.is_irreducible`\n  * `lie_algebra.is_simple`\n  * `lie_algebra.is_semisimple`\n  * `lie_algebra.is_semisimple_iff_no_solvable_ideals`\n  * `lie_algebra.is_semisimple_iff_no_abelian_ideals`\n  * `lie_algebra.abelian_radical_iff_solvable_is_abelian`\n\n## Tags\n\nlie algebra, radical, simple, semisimple\n-/\n\n\nuniverse u v w w₁ w₂\n\n/-- A Lie module is irreducible if it is zero or its only non-trivial Lie submodule is itself. -/\nclass LieModule.IsIrreducible (R : Type u) (L : Type v) (M : Type w) [CommRing R] [LieRing L]\n  [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] : Prop where\n  Irreducible : ∀ N : LieSubmodule R L M, N ≠ ⊥ → N = ⊤\n#align lie_module.is_irreducible LieModule.IsIrreducible\n\nnamespace LieAlgebra\n\nvariable (R : Type u) (L : Type v)\n\nvariable [CommRing R] [LieRing L] [LieAlgebra R L]\n\n/-- A Lie algebra is simple if it is irreducible as a Lie module over itself via the adjoint\naction, and it is non-Abelian. -/\nclass IsSimple extends LieModule.IsIrreducible R L L : Prop where\n  non_abelian : ¬IsLieAbelian L\n#align lie_algebra.is_simple LieAlgebra.IsSimple\n\n/-- A semisimple Lie algebra is one with trivial radical.\n\nNote that the label 'semisimple' is apparently not universally agreed\n[upon](https://mathoverflow.net/questions/149391/on-radicals-of-a-lie-algebra#comment383669_149391)\nfor general coefficients. We are following [Seligman, page 15](seligman1967) and using the label\nfor the weakest of the various properties which are all equivalent over a field of characteristic\nzero. -/\nclass IsSemisimple : Prop where\n  semisimple : radical R L = ⊥\n#align lie_algebra.is_semisimple LieAlgebra.IsSemisimple\n\ntheorem isSemisimple_iff_no_solvable_ideals :\n    IsSemisimple R L ↔ ∀ I : LieIdeal R L, IsSolvable R I → I = ⊥ :=\n  ⟨fun h => supₛ_eq_bot.mp h.semisimple, fun h => ⟨supₛ_eq_bot.mpr h⟩⟩\n#align lie_algebra.is_semisimple_iff_no_solvable_ideals LieAlgebra.isSemisimple_iff_no_solvable_ideals\n\ntheorem isSemisimple_iff_no_abelian_ideals :\n    IsSemisimple R L ↔ ∀ I : LieIdeal R L, IsLieAbelian I → I = ⊥ :=\n  by\n  rw [is_semisimple_iff_no_solvable_ideals]\n  constructor <;> intro h₁ I h₂\n  · haveI : IsLieAbelian I := h₂\n    apply h₁\n    exact LieAlgebra.ofAbelianIsSolvable R I\n  · haveI : IsSolvable R I := h₂\n    rw [← abelian_of_solvable_ideal_eq_bot_iff]\n    apply h₁\n    exact abelian_derived_abelian_of_ideal I\n#align lie_algebra.is_semisimple_iff_no_abelian_ideals LieAlgebra.isSemisimple_iff_no_abelian_ideals\n\n@[simp]\ntheorem center_eq_bot_of_semisimple [h : IsSemisimple R L] : center R L = ⊥ :=\n  by\n  rw [is_semisimple_iff_no_abelian_ideals] at h\n  apply h\n  infer_instance\n#align lie_algebra.center_eq_bot_of_semisimple LieAlgebra.center_eq_bot_of_semisimple\n\n/-- A simple Lie algebra is semisimple. -/\ninstance (priority := 100) isSemisimpleOfIsSimple [h : IsSimple R L] : IsSemisimple R L :=\n  by\n  rw [is_semisimple_iff_no_abelian_ideals]\n  intro I hI\n  obtain @⟨⟨h₁⟩, h₂⟩ := id h\n  by_contra contra\n  rw [h₁ I contra, lie_abelian_iff_equiv_lie_abelian LieIdeal.topEquiv] at hI\n  exact h₂ hI\n#align lie_algebra.is_semisimple_of_is_simple LieAlgebra.isSemisimpleOfIsSimple\n\n/-- A semisimple Abelian Lie algebra is trivial. -/\ntheorem subsingleton_of_semisimple_lie_abelian [IsSemisimple R L] [h : IsLieAbelian L] :\n    Subsingleton L :=\n  by\n  rw [is_lie_abelian_iff_center_eq_top R L, center_eq_bot_of_semisimple] at h\n  exact (LieSubmodule.subsingleton_iff R L L).mp (subsingleton_of_bot_eq_top h)\n#align lie_algebra.subsingleton_of_semisimple_lie_abelian LieAlgebra.subsingleton_of_semisimple_lie_abelian\n\ntheorem abelian_radical_of_semisimple [IsSemisimple R L] : IsLieAbelian (radical R L) :=\n  by\n  rw [is_semisimple.semisimple]\n  exact is_lie_abelian_bot R L\n#align lie_algebra.abelian_radical_of_semisimple LieAlgebra.abelian_radical_of_semisimple\n\n/-- The two properties shown to be equivalent here are possible definitions for a Lie algebra\nto be reductive.\n\nNote that there is absolutely [no agreement](https://mathoverflow.net/questions/284713/) on what\nthe label 'reductive' should mean when the coefficients are not a field of characteristic zero. -/\ntheorem abelian_radical_iff_solvable_is_abelian [IsNoetherian R L] :\n    IsLieAbelian (radical R L) ↔ ∀ I : LieIdeal R L, IsSolvable R I → IsLieAbelian I :=\n  by\n  constructor\n  · rintro h₁ I h₂\n    rw [lie_ideal.solvable_iff_le_radical] at h₂\n    exact (LieIdeal.homOfLe_injective h₂).IsLieAbelian h₁\n  · intro h\n    apply h\n    infer_instance\n#align lie_algebra.abelian_radical_iff_solvable_is_abelian LieAlgebra.abelian_radical_iff_solvable_is_abelian\n\ntheorem ad_ker_eq_bot_of_semisimple [IsSemisimple R L] : (ad R L).ker = ⊥ := by simp\n#align lie_algebra.ad_ker_eq_bot_of_semisimple LieAlgebra.ad_ker_eq_bot_of_semisimple\n\nend LieAlgebra\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/Algebra/Lie/Semisimple.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239836484144, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4505558683723666}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.limits.shapes.biproducts\nimport category_theory.limits.preserves.shapes.zero\n\n/-!\n# Preservation of biproducts\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define the image of a (binary) bicone under a functor that preserves zero morphisms and define\nclasses `preserves_biproduct` and `preserves_binary_biproduct`. We then\n\n* show that a functor that preserves biproducts of a two-element type preserves binary biproducts,\n* construct the comparison morphisms between the image of a biproduct and the biproduct of the\n  images and show that the biproduct is preserved if one of them is an isomorphism,\n* give the canonical isomorphism between the image of a biproduct and the biproduct of the images\n  in case that the biproduct is preserved.\n\n-/\n\nuniverses w₁ w₂ v₁ v₂ u₁ u₂\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]\n\nsection has_zero_morphisms\nvariables [has_zero_morphisms C] [has_zero_morphisms D]\n\nnamespace functor\n\nsection map\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w₁}\n\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef map_bicone {f : J → C} (b : bicone f) : bicone (F.obj ∘ f) :=\n{ X := F.obj b.X,\n  π := λ j, F.map (b.π j),\n  ι := λ j, F.map (b.ι j),\n  ι_π := λ j j',\n  begin\n    rw ← F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_ι_π_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_ι_π_ne _ h, F.map_zero] }\n  end }\n\nlemma map_bicone_whisker {K : Type w₂} {g : K ≃ J} {f : J → C} (c : bicone f) :\n  F.map_bicone (c.whisker g) = (F.map_bicone c).whisker g := rfl\n\nend bicone\n\n/-- The image of a binary bicone under a functor. -/\n@[simps]\ndef map_binary_bicone {X Y : C} (b : binary_bicone X Y) : binary_bicone (F.obj X) (F.obj Y) :=\n{ X := F.obj b.X,\n  fst := F.map b.fst,\n  snd := F.map b.snd,\n  inl := F.map b.inl,\n  inr := F.map b.inr,\n  inl_fst' := by rw [← F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [← F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [← F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [← F.map_comp, b.inr_snd, F.map_id] }\n\nend map\n\nend functor\n\nopen category_theory.functor\n\nnamespace limits\n\nsection bicone\nvariables {J : Type w₁} {K : Type w₂}\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\nclass preserves_biproduct (f : J → C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : bicone f}, b.is_bilimit → (F.map_bicone b).is_bilimit)\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\ndef is_bilimit_of_preserves {f : J → C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_biproduct f F] {b : bicone f} (hb : b.is_bilimit) : (F.map_bicone b).is_bilimit :=\npreserves_biproduct.preserves hb\n\nvariables (J)\n\n/-- A functor `F` preserves biproducts of shape `J` if it preserves biproducts of `f` for every\n    `f : J → C`. -/\nclass preserves_biproducts_of_shape (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {f : J → C}, preserves_biproduct f F)\n\nattribute [instance, priority 100] preserves_biproducts_of_shape.preserves\n\nend bicone\n\n/-- A functor `F` preserves finite biproducts if it preserves biproducts of shape `J` whenever\n    `J` is a fintype. -/\nclass preserves_finite_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type} [fintype J], preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_finite_biproducts.preserves\n\n/-- A functor `F` preserves biproducts if it preserves biproducts of any shape `J` of size `w`.\n    The usual notion of preservation of biproducts is recovered by choosing `w` to be the universe\n    of the morphisms of `C`. -/\nclass preserves_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type w₁}, preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_biproducts.preserves\n\n/-- Preserving biproducts at a bigger universe level implies preserving biproducts at a\nsmaller universe level. -/\ndef preserves_biproducts_shrink (F : C ⥤ D) [preserves_zero_morphisms F]\n  [hp : preserves_biproducts.{max w₁ w₂} F] : preserves_biproducts.{w₁} F :=\n⟨λ J, ⟨λ f, ⟨λ b ib, ((F.map_bicone b).whisker_is_bilimit_iff _).to_fun\n  (is_bilimit_of_preserves F ((b.whisker_is_bilimit_iff equiv.ulift.{w₂}).inv_fun ib))⟩⟩⟩\n\n@[priority 100]\ninstance preserves_finite_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts.{w₁} F] : preserves_finite_biproducts F :=\n{ preserves := λ J _, by letI := preserves_biproducts_shrink.{0} F; apply_instance }\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\nclass preserves_binary_biproduct (X Y : C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : binary_bicone X Y}, b.is_bilimit → (F.map_binary_bicone b).is_bilimit)\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\ndef is_binary_bilimit_of_preserves {X Y : C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_binary_biproduct X Y F] {b : binary_bicone X Y} (hb : b.is_bilimit) :\n  (F.map_binary_bicone b).is_bilimit :=\npreserves_binary_biproduct.preserves hb\n\n/-- A functor `F` preserves binary biproducts if it preserves the binary biproduct of `X` and `Y`\n    for all `X` and `Y`. -/\nclass preserves_binary_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {X Y : C}, preserves_binary_biproduct X Y F . tactic.apply_instance)\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_biproduct (F : C ⥤ D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair_function X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb,\n  { is_limit := is_limit.of_iso_limit\n      ((is_limit.postcompose_hom_equiv (by exact diagram_iso_pair _) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_limit)) $\n      cones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy, }),\n    is_colimit := is_colimit.of_iso_colimit\n      ((is_colimit.precompose_inv_equiv (by exact diagram_iso_pair _ ) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_colimit)) $\n      cocones.ext (iso.refl _) (λ j, by { rcases j with ⟨⟨⟩⟩, tidy, }) } }\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape walking_pair F] :\n  preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_biproduct F X Y }\n\nattribute [instance, priority 100] preserves_binary_biproducts.preserves\n\nend limits\n\nopen category_theory.limits\n\nnamespace functor\n\nsection bicone\nvariables {J : Type w₁} (F : C ⥤ D) (f : J → C)\n  [has_biproduct f]\n\nsection\nvariables [has_biproduct (F.obj ∘ f)]\n\n/-- As for products, any functor between categories with biproducts gives rise to a morphism\n    `F.obj (⨁ f) ⟶ ⨁ (F.obj ∘ f)`. -/\ndef biproduct_comparison : F.obj (⨁ f) ⟶ ⨁ (F.obj ∘ f) :=\nbiproduct.lift (λ j, F.map (biproduct.π f j))\n\n@[simp, reassoc] lemma biproduct_comparison_π (j : J) :\n  biproduct_comparison F f ≫ biproduct.π _ j = F.map (biproduct.π f j) :=\nbiproduct.lift_π _ _\n\n/-- As for coproducts, any functor between categories with biproducts gives rise to a morphism\n    `⨁ (F.obj ∘ f) ⟶ F.obj (⨁ f)` -/\ndef biproduct_comparison' : ⨁ (F.obj ∘ f) ⟶ F.obj (⨁ f) :=\nbiproduct.desc (λ j, F.map (biproduct.ι f j))\n\n@[simp, reassoc] lemma ι_biproduct_comparison' (j : J) :\n  biproduct.ι _ j ≫ biproduct_comparison' F f = F.map (biproduct.ι f j) :=\nbiproduct.ι_desc _ _\n\nvariables [preserves_zero_morphisms F]\n\n/-- The composition in the opposite direction is equal to the identity if and only if `F` preserves\n    the biproduct, see `preserves_biproduct_of_mono_biproduct_comparison`.  -/\n@[simp, reassoc] lemma biproduct_comparison'_comp_biproduct_comparison :\n  biproduct_comparison' F f ≫ biproduct_comparison F f = 𝟙 (⨁ (F.obj ∘ f)) :=\nby { classical, ext, simp [biproduct.ι_π, ← functor.map_comp, eq_to_hom_map] }\n\n/-- `biproduct_comparison F f` is a split epimorphism. -/\n@[simps]\ndef split_epi_biproduct_comparison : split_epi (biproduct_comparison F f) :=\n⟨biproduct_comparison' F f⟩\n\ninstance : is_split_epi (biproduct_comparison F f) :=\nis_split_epi.mk' (split_epi_biproduct_comparison F f)\n\n/-- `biproduct_comparison' F f` is a split monomorphism. -/\n@[simps]\ndef split_mono_biproduct_comparison' : split_mono (biproduct_comparison' F f) :=\n⟨biproduct_comparison F f⟩\n\ninstance : is_split_mono (biproduct_comparison' F f) :=\nis_split_mono.mk' (split_mono_biproduct_comparison' F f)\n\nend\n\nvariables [preserves_zero_morphisms F] [preserves_biproduct f F]\n\ninstance has_biproduct_of_preserves : has_biproduct (F.obj ∘ f) :=\nhas_biproduct.mk\n{ bicone := F.map_bicone (biproduct.bicone f),\n  is_bilimit := preserves_biproduct.preserves (biproduct.is_bilimit _) }\n\n/-- If `F` preserves a biproduct, we get a definitionally nice isomorphism\n    `F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f)`. -/\n@[simp]\ndef map_biproduct : F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (λ j, F.map (biproduct.π f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (λ j, F.map (biproduct.ι f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C ⥤ D) (X Y : C) [has_binary_biproduct X Y]\n\nsection\nvariables [has_binary_biproduct (F.obj X) (F.obj Y)]\n\n/-- As for products, any functor between categories with binary biproducts gives rise to a\n    morphism `F.obj (X ⊞ Y) ⟶ F.obj X ⊞ F.obj Y`. -/\ndef biprod_comparison : F.obj (X ⊞ Y) ⟶ F.obj X ⊞ F.obj Y :=\nbiprod.lift (F.map biprod.fst) (F.map biprod.snd)\n\n@[simp, reassoc] lemma biprod_comparison_fst :\n  biprod_comparison F X Y ≫ biprod.fst = F.map biprod.fst :=\nbiprod.lift_fst _ _\n\n@[simp, reassoc] lemma biprod_comparison_snd :\n  biprod_comparison F X Y ≫ biprod.snd = F.map biprod.snd :=\nbiprod.lift_snd _ _\n\n/-- As for coproducts, any functor between categories with binary biproducts gives rise to a\n    morphism `F.obj X ⊞ F.obj Y ⟶ F.obj (X ⊞ Y)`. -/\ndef biprod_comparison' : F.obj X ⊞ F.obj Y ⟶ F.obj (X ⊞ Y) :=\nbiprod.desc (F.map biprod.inl) (F.map biprod.inr)\n\n@[simp, reassoc] lemma inl_biprod_comparison' :\n  biprod.inl ≫ biprod_comparison' F X Y = F.map biprod.inl :=\nbiprod.inl_desc _ _\n\n@[simp, reassoc] lemma inr_biprod_comparison' :\n  biprod.inr ≫ biprod_comparison' F X Y = F.map biprod.inr :=\nbiprod.inr_desc _ _\n\nvariables [preserves_zero_morphisms F]\n\n/-- The composition in the opposite direction is equal to the identity if and only if `F` preserves\n    the biproduct, see `preserves_binary_biproduct_of_mono_biprod_comparison`. -/\n@[simp, reassoc] \n\n/-- `biprod_comparison F X Y` is a split epi. -/\n@[simps]\ndef split_epi_biprod_comparison : split_epi (biprod_comparison F X Y) :=\n⟨biprod_comparison' F X Y⟩\n\ninstance : is_split_epi (biprod_comparison F X Y) :=\nis_split_epi.mk' (split_epi_biprod_comparison F X Y)\n\n/-- `biprod_comparison' F X Y` is a split mono. -/\n@[simps]\ndef split_mono_biprod_comparison' : split_mono (biprod_comparison' F X Y) :=\n⟨biprod_comparison F X Y⟩\n\ninstance : is_split_mono (biprod_comparison' F X Y) :=\nis_split_mono.mk' (split_mono_biprod_comparison' F X Y)\n\nend\n\nvariables [preserves_zero_morphisms F] [preserves_binary_biproduct X Y F]\n\ninstance has_binary_biproduct_of_preserves : has_binary_biproduct (F.obj X) (F.obj Y) :=\nhas_binary_biproduct.mk\n{ bicone := F.map_binary_bicone (binary_biproduct.bicone X Y),\n  is_bilimit := preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _) }\n\n/-- If `F` preserves a binary biproduct, we get a definitionally nice isomorphism\n    `F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y :=\nbiprod.unique_up_to_iso _ _\n  (preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _))\n\nlemma map_biprod_hom : (map_biprod F X Y).hom = biprod.lift (F.map biprod.fst) (F.map biprod.snd) :=\nrfl\n\nlemma map_biprod_inv : (map_biprod F X Y).inv = biprod.desc (F.map biprod.inl) (F.map biprod.inr) :=\nrfl\n\nend functor\n\nnamespace limits\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w₁} (f : J → C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : Π j, W ⟶ f j) :\n  F.map (biproduct.lift g) ≫ (F.map_biproduct f).hom = biproduct.lift (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).inv ≫ F.map (biproduct.desc g) = biproduct.desc (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).hom ≫ biproduct.desc (λ j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [← biproduct.map_biproduct_inv_map_desc, iso.hom_inv_id_assoc]\n\nend bicone\n\nsection binary_bicone\nvariables (X Y : C) [has_binary_biproduct X Y] [preserves_binary_biproduct X Y F] {W : C}\n\nlemma biprod.map_lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  F.map (biprod.lift f g) ≫ (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  biprod.lift (F.map f) (F.map g) ≫ (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [← biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X ⟶ W) (g : Y ⟶ W) :\n  (F.map_biprod X Y).inv ≫ F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X ⟶ W) (g : Y ⟶ W) :\n (F.map_biprod X Y).hom ≫ biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [← biprod.map_biprod_inv_map_desc, iso.hom_inv_id_assoc]\n\nend binary_bicone\n\nend limits\n\nend has_zero_morphisms\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/limits/preserves/shapes/biproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7154239957834733, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4505558660722336}}
{"text": "/- LoVe Library -/\n\nimport tactic.explode\nimport tactic.find\nimport tactic.linarith\nimport tactic.rewrite\nimport tactic.tidy\nimport tactic.where\nimport logic.basic\nimport algebra\nimport order\nimport data.real.basic\n\nnamespace LoVe\n\n/- Options -/\n\nset_option pp.beta true\n\n\n/- Logical connectives -/\n\nattribute [pattern] or.intro_left or.intro_right\n\nmeta def tactic.dec_trivial := `[exact dec_trivial]\n\n@[simp] lemma not_not_iff (a : Prop) [decidable a] : ¬¬ a ↔ a :=\nby by_cases a; simp [h]\n\n@[simp] lemma and_imp_distrib (a b c : Prop) : (a ∧ b → c) ↔ (a → b → c) :=\niff.intro\n  (assume h ha hb, h ⟨ha, hb⟩)\n  (assume h ⟨ha, hb⟩, h ha hb)\n\n@[simp] lemma or_imp_distrib {a b c : Prop} : a ∨ b → c ↔ (a → c) ∧ (b → c) :=\niff.intro\n  (assume h,\n   ⟨assume ha, h (or.intro_left _ ha), assume hb, h (or.intro_right _ hb)⟩)\n  (assume ⟨ha, hb⟩ h, match h with or.inl h := ha h | or.inr h := hb h end)\n\n@[simp] lemma exists_imp_distrib {α : Sort*} {p : α → Prop} {a : Prop} :\n  ((∃x, p x) → a) ↔ (∀x, p x → a) :=\niff.intro\n  (assume h hp ha, h ⟨hp, ha⟩)\n  (assume h ⟨hp, ha⟩, h hp ha)\n\nlemma and_exists {α : Sort*} {p : α → Prop} {a : Prop} :\n  (a ∧ (∃x, p x)) ↔ (∃x, a ∧ p x) :=\niff.intro\n  (assume ⟨ha, x, hp⟩, ⟨x, ha, hp⟩)\n  (assume ⟨x, ha, hp⟩, ⟨ha, x, hp⟩)\n\n@[simp] lemma exists_false {α : Sort*} : (∃x : α, false) ↔ false :=\niff.intro (assume ⟨a, f⟩, f) (assume h, h.elim)\n\n\n/- Reflexive transitive closure of a relation -/\n\ninductive refl_trans {α : Sort*} (r : α → α → Prop) (a : α) : α → Prop\n| refl {} : refl_trans a\n| tail {b c} : refl_trans b → r b c → refl_trans c\n\nattribute [refl] refl_trans.refl\n\nnamespace refl_trans\n\nvariables {α : Sort*} {r : α → α → Prop} {a b c d : α}\n\n@[trans] lemma trans (hab : refl_trans r a b) (hbc : refl_trans r b c) :\n  refl_trans r a c :=\nbegin\n  induction hbc,\n  case refl_trans.refl { assumption },\n  case refl_trans.tail : c d hbc hcd hac { exact hac.tail hcd }\nend\n\nlemma single (hab : r a b) : refl_trans r a b :=\nrefl.tail hab\n\nlemma head (hab : r a b) (hbc : refl_trans r b c) : refl_trans r a c :=\nbegin\n  induction hbc,\n  case refl_trans.refl { exact refl.tail hab },\n  case refl_trans.tail : c d hbc hcd hac { exact hac.tail hcd }\nend\n\nlemma head_induction_on {α : Sort*} {r : α → α → Prop} {b : α}\n  {P : ∀a : α, refl_trans r a b → Prop} {a : α} (h : refl_trans r a b)\n  (refl : P b refl)\n  (head : ∀{a c} (h' : r a c) (h : refl_trans r c b), P c h → P a (h.head h')) :\n  P a h :=\nbegin\n  induction h generalizing P,\n  case refl_trans.refl { exact refl },\n  case refl_trans.tail : b c hab hbc ih {\n    apply ih,\n    show P b _, from head hbc _ refl,\n    show ∀a a', r a a' → refl_trans r a' b → P a' _ → P a _,\n      from assume a a' hab hbc, head hab _ }\nend\n\nlemma trans_induction_on {α : Sort*} {r : α → α → Prop}\n  {P : ∀{a b : α}, refl_trans r a b → Prop}\n  {a b : α} (h : refl_trans r a b)\n  (ih₁ : ∀a, @P a a refl)\n  (ih₂ : ∀{a b} (h : r a b), P (single h))\n  (ih₃ : ∀{a b c} (h₁ : refl_trans r a b) (h₂ : refl_trans r b c), P h₁ → P h₂ →\n    P (h₁.trans h₂)) :\n  P h :=\nbegin\n  induction h,\n  case refl_trans.refl { exact ih₁ a },\n  case refl_trans.tail : b c hab hbc ih {\n    exact ih₃ hab (single hbc) ih (ih₂ hbc) }\nend\n\nlemma lift {β : Sort*} {p : β → β → Prop} (f : α → β)\n  (h : ∀a b, r a b → p (f a) (f b)) (hab : refl_trans r a b) :\n  refl_trans p (f a) (f b) :=\nhab.trans_induction_on\n  (assume a, refl)\n  (assume a b, single ∘ h _ _)\n  (assume a b c _ _, trans)\n\nlemma mono {p : α → α → Prop} :\n  (∀a b, r a b → p a b) → refl_trans r a b → refl_trans p a b :=\nlift id\n\nlemma refl_trans_refl_trans_eq : refl_trans (refl_trans r) = refl_trans r :=\nfunext $ assume a, funext $ assume b, propext $\niff.intro\n  (assume h, begin induction h, { refl }, { transitivity; assumption } end)\n  (refl_trans.mono (assume a b, single))\n\nend refl_trans\n\n\n/- States -/\n\ndef state := string → ℕ\n\ndef state.update (name : string) (val : ℕ) (s : state) :\n  state :=\nλname', if name' = name then val else s name'\n\nnotation s `{` name ` ↦ ` val `}` := state.update name val s\n\ninstance : has_emptyc state := ⟨λ_, 0⟩\n\n@[simp] lemma update_apply (name : string) (val : ℕ)\n  (s : state) : s{name ↦ val} name = val :=\nif_pos rfl\n\n@[simp] lemma update_apply_ne (name name' : string) (val : ℕ)\n    (s : state) (h : name' ≠ name . tactic.dec_trivial) :\n  s{name ↦ val} name' = s name' :=\nif_neg h\n\n@[simp] lemma update_override (name : string) (val₁ val₂ : ℕ)\n  (s : state) : s{name ↦ val₂}{name ↦ val₁} = s{name ↦ val₁} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma update_swap (name₁ name₂ : string) (val₁ val₂ : ℕ)\n  (s : state) (h : name₁ ≠ name₂ . tactic.dec_trivial) :\n  s{name₂ ↦ val₂}{name₁ ↦ val₁} =\n  s{name₁ ↦ val₁}{name₂ ↦ val₂} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name₁;\n    by_cases name' = name₂;\n    simp * at *\nend\n\n@[simp] lemma update_id (name : string) (s : state) :\n  s{name ↦ s name} = s :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp * at *\nend\n\nexample (s : state) :\n  s{\"a\" ↦ 0}{\"a\" ↦ 2} = s{\"a\" ↦ 2} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" ↦ 0}{\"b\" ↦ 2} = s{\"b\" ↦ 2}{\"a\" ↦ 0} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" ↦ s \"a\"}{\"b\" ↦ 0} = s{\"b\" ↦ 0} :=\nby simp\n\nend LoVe\n", "meta": {"author": "blanchette", "repo": "logical_verification_2019", "sha": "7c5f1c90f6e5a0b221a02c8fa4e36c0c66393036", "save_path": "github-repos/lean/blanchette-logical_verification_2019", "path": "github-repos/lean/blanchette-logical_verification_2019/logical_verification_2019-7c5f1c90f6e5a0b221a02c8fa4e36c0c66393036/lean/lovelib.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442250928250375, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.4504772402773065}}
{"text": "import NBG.SetTheory.Defs\nimport NBG.SetTheory.Axioms.Foundation\n\nopen Classical\n\n-- 15. AxiomGlobalChoice\naxiom AxiomGlobalChoice:\n  ∃F: Class,∃_: Function F,∀x: Class, ∀_: Set x,\n    (¬ x＝ø → (∃y: Class,∃hy: y∈x,\n      (@Pair_mk x y _ (Set.mk₁ hy)) ∈ F))\n\n-- ex. AxiomChoice\ntheorem AxiomChoice:\n  ∀x: Class, ∀_: Set x,\n    ∃f: Class, ∃_: Function f, ∀y: Class, ∃hy: y∈x,\n      (¬ y＝ø → (∃z: Class,∃hz: z∈y,\n        ((@Pair_mk y z (Set.mk₁ hy) (Set.mk₁ hz)) ∈ f))) := sorry\n\n", "meta": {"author": "furea2", "repo": "NBG", "sha": "51b45e0b08c1d0090430b0d898de4fc1b7bc09d7", "save_path": "github-repos/lean/furea2-NBG", "path": "github-repos/lean/furea2-NBG/NBG-51b45e0b08c1d0090430b0d898de4fc1b7bc09d7/NBG/SetTheory/Axioms/GlobalChoice.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.5350984286266115, "lm_q1q2_score": 0.45045957677499465}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n\n! This file was ported from Lean 3 source module category_theory.limits.preserves.shapes.biproducts\n! leanprover-community/mathlib commit 69c6a5a12d8a2b159f20933e60115a4f2de62b58\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.CategoryTheory.Limits.Shapes.Biproducts\nimport Mathbin.CategoryTheory.Limits.Preserves.Shapes.Zero\n\n/-!\n# Preservation of biproducts\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nWe define the image of a (binary) bicone under a functor that preserves zero morphisms and define\nclasses `preserves_biproduct` and `preserves_binary_biproduct`. We then\n\n* show that a functor that preserves biproducts of a two-element type preserves binary biproducts,\n* construct the comparison morphisms between the image of a biproduct and the biproduct of the\n  images and show that the biproduct is preserved if one of them is an isomorphism,\n* give the canonical isomorphism between the image of a biproduct and the biproduct of the images\n  in case that the biproduct is preserved.\n\n-/\n\n\nuniverse w₁ w₂ v₁ v₂ u₁ u₂\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory\n\nvariable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]\n\nsection HasZeroMorphisms\n\nvariable [HasZeroMorphisms C] [HasZeroMorphisms D]\n\nnamespace Functor\n\nsection Map\n\nvariable (F : C ⥤ D) [PreservesZeroMorphisms F]\n\nsection Bicone\n\nvariable {J : Type w₁}\n\n/- warning: category_theory.functor.map_bicone -> CategoryTheory.Functor.mapBicone is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} {f : J -> C}, (CategoryTheory.Limits.Bicone.{u1, u2, u4} J C _inst_1 _inst_3 f) -> (CategoryTheory.Limits.Bicone.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} {f : J -> C}, (CategoryTheory.Limits.Bicone.{u1, u2, u4} J C _inst_1 _inst_3 f) -> (CategoryTheory.Limits.Bicone.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_bicone CategoryTheory.Functor.mapBiconeₓ'. -/\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef mapBicone {f : J → C} (b : Bicone f) : Bicone (F.obj ∘ f)\n    where\n  pt := F.obj b.pt\n  π j := F.map (b.π j)\n  ι j := F.map (b.ι j)\n  ι_π j j' := by\n    rw [← F.map_comp]\n    split_ifs\n    · subst h\n      simp only [bicone_ι_π_self, CategoryTheory.Functor.map_id, eq_to_hom_refl]\n    · rw [bicone_ι_π_ne _ h, F.map_zero]\n#align category_theory.functor.map_bicone CategoryTheory.Functor.mapBicone\n\n#print CategoryTheory.Functor.mapBicone_whisker /-\ntheorem mapBicone_whisker {K : Type w₂} {g : K ≃ J} {f : J → C} (c : Bicone f) :\n    F.mapBicone (c.whisker g) = (F.mapBicone c).whisker g :=\n  rfl\n#align category_theory.functor.map_bicone_whisker CategoryTheory.Functor.mapBicone_whisker\n-/\n\nend Bicone\n\n/- warning: category_theory.functor.map_binary_bicone -> CategoryTheory.Functor.mapBinaryBicone is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {X : C} {Y : C}, (CategoryTheory.Limits.BinaryBicone.{u1, u3} C _inst_1 _inst_3 X Y) -> (CategoryTheory.Limits.BinaryBicone.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {X : C} {Y : C}, (CategoryTheory.Limits.BinaryBicone.{u1, u3} C _inst_1 _inst_3 X Y) -> (CategoryTheory.Limits.BinaryBicone.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_binary_bicone CategoryTheory.Functor.mapBinaryBiconeₓ'. -/\n/-- The image of a binary bicone under a functor. -/\n@[simps]\ndef mapBinaryBicone {X Y : C} (b : BinaryBicone X Y) : BinaryBicone (F.obj X) (F.obj Y)\n    where\n  pt := F.obj b.pt\n  fst := F.map b.fst\n  snd := F.map b.snd\n  inl := F.map b.inl\n  inr := F.map b.inr\n  inl_fst := by rw [← F.map_comp, b.inl_fst, F.map_id]\n  inl_snd := by rw [← F.map_comp, b.inl_snd, F.map_zero]\n  inr_fst := by rw [← F.map_comp, b.inr_fst, F.map_zero]\n  inr_snd := by rw [← F.map_comp, b.inr_snd, F.map_id]\n#align category_theory.functor.map_binary_bicone CategoryTheory.Functor.mapBinaryBicone\n\nend Map\n\nend Functor\n\nopen CategoryTheory.Functor\n\nnamespace Limits\n\nsection Bicone\n\nvariable {J : Type w₁} {K : Type w₂}\n\n#print CategoryTheory.Limits.PreservesBiproduct /-\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\nclass PreservesBiproduct (f : J → C) (F : C ⥤ D) [PreservesZeroMorphisms F] where\n  preserves : ∀ {b : Bicone f}, b.IsBilimit → (F.mapBicone b).IsBilimit\n#align category_theory.limits.preserves_biproduct CategoryTheory.Limits.PreservesBiproduct\n-/\n\n/- warning: category_theory.limits.is_bilimit_of_preserves -> CategoryTheory.Limits.isBilimitOfPreserves is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} {f : J -> C} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {b : CategoryTheory.Limits.Bicone.{u1, u2, u4} J C _inst_1 _inst_3 f}, (CategoryTheory.Limits.Bicone.IsBilimit.{u1, u2, u4} J C _inst_1 _inst_3 f b) -> (CategoryTheory.Limits.Bicone.IsBilimit.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.mapBicone.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F _inst_5 J f b))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} {f : J -> C} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {b : CategoryTheory.Limits.Bicone.{u1, u2, u4} J C _inst_1 _inst_3 f}, (CategoryTheory.Limits.Bicone.IsBilimit.{u1, u2, u4} J C _inst_1 _inst_3 f b) -> (CategoryTheory.Limits.Bicone.IsBilimit.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.mapBicone.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F _inst_5 J f b))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_bilimit_of_preserves CategoryTheory.Limits.isBilimitOfPreservesₓ'. -/\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\ndef isBilimitOfPreserves {f : J → C} (F : C ⥤ D) [PreservesZeroMorphisms F] [PreservesBiproduct f F]\n    {b : Bicone f} (hb : b.IsBilimit) : (F.mapBicone b).IsBilimit :=\n  PreservesBiproduct.preserves hb\n#align category_theory.limits.is_bilimit_of_preserves CategoryTheory.Limits.isBilimitOfPreserves\n\nvariable (J)\n\n#print CategoryTheory.Limits.PreservesBiproductsOfShape /-\n/-- A functor `F` preserves biproducts of shape `J` if it preserves biproducts of `f` for every\n    `f : J → C`. -/\nclass PreservesBiproductsOfShape (F : C ⥤ D) [PreservesZeroMorphisms F] where\n  preserves : ∀ {f : J → C}, PreservesBiproduct f F\n#align category_theory.limits.preserves_biproducts_of_shape CategoryTheory.Limits.PreservesBiproductsOfShape\n-/\n\nattribute [instance] preserves_biproducts_of_shape.preserves\n\nend Bicone\n\n#print CategoryTheory.Limits.PreservesFiniteBiproducts /-\n/-- A functor `F` preserves finite biproducts if it preserves biproducts of shape `J` whenever\n    `J` is a fintype. -/\nclass PreservesFiniteBiproducts (F : C ⥤ D) [PreservesZeroMorphisms F] where\n  preserves : ∀ {J : Type} [Fintype J], PreservesBiproductsOfShape J F\n#align category_theory.limits.preserves_finite_biproducts CategoryTheory.Limits.PreservesFiniteBiproducts\n-/\n\nattribute [instance] preserves_finite_biproducts.preserves\n\n#print CategoryTheory.Limits.PreservesBiproducts /-\n/-- A functor `F` preserves biproducts if it preserves biproducts of any shape `J` of size `w`.\n    The usual notion of preservation of biproducts is recovered by choosing `w` to be the universe\n    of the morphisms of `C`. -/\nclass PreservesBiproducts (F : C ⥤ D) [PreservesZeroMorphisms F] where\n  preserves : ∀ {J : Type w₁}, PreservesBiproductsOfShape J F\n#align category_theory.limits.preserves_biproducts CategoryTheory.Limits.PreservesBiproducts\n-/\n\nattribute [instance] preserves_biproducts.preserves\n\n#print CategoryTheory.Limits.preservesBiproductsShrink /-\n/-- Preserving biproducts at a bigger universe level implies preserving biproducts at a\nsmaller universe level. -/\ndef preservesBiproductsShrink (F : C ⥤ D) [PreservesZeroMorphisms F]\n    [hp : PreservesBiproducts.{max w₁ w₂} F] : PreservesBiproducts.{w₁} F :=\n  ⟨fun J =>\n    ⟨fun f =>\n      ⟨fun b ib =>\n        ((F.mapBicone b).whiskerIsBilimitIff _).toFun\n          (isBilimitOfPreserves F ((b.whiskerIsBilimitIff Equiv.ulift.{w₂}).invFun ib))⟩⟩⟩\n#align category_theory.limits.preserves_biproducts_shrink CategoryTheory.Limits.preservesBiproductsShrink\n-/\n\n#print CategoryTheory.Limits.preservesFiniteBiproductsOfPreservesBiproducts /-\ninstance (priority := 100) preservesFiniteBiproductsOfPreservesBiproducts (F : C ⥤ D)\n    [PreservesZeroMorphisms F] [PreservesBiproducts.{w₁} F] : PreservesFiniteBiproducts F\n    where preserves J _ := by letI := preservesBiproductsShrink.{0} F <;> infer_instance\n#align category_theory.limits.preserves_finite_biproducts_of_preserves_biproducts CategoryTheory.Limits.preservesFiniteBiproductsOfPreservesBiproducts\n-/\n\n#print CategoryTheory.Limits.PreservesBinaryBiproduct /-\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\nclass PreservesBinaryBiproduct (X Y : C) (F : C ⥤ D) [PreservesZeroMorphisms F] where\n  preserves : ∀ {b : BinaryBicone X Y}, b.IsBilimit → (F.mapBinaryBicone b).IsBilimit\n#align category_theory.limits.preserves_binary_biproduct CategoryTheory.Limits.PreservesBinaryBiproduct\n-/\n\n/- warning: category_theory.limits.is_binary_bilimit_of_preserves -> CategoryTheory.Limits.isBinaryBilimitOfPreserves is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] {X : C} {Y : C} (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {b : CategoryTheory.Limits.BinaryBicone.{u1, u3} C _inst_1 _inst_3 X Y}, (CategoryTheory.Limits.BinaryBicone.IsBilimit.{u1, u3} C _inst_1 _inst_3 X Y b) -> (CategoryTheory.Limits.BinaryBicone.IsBilimit.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.mapBinaryBicone.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F _inst_5 X Y b))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] {X : C} {Y : C} (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_6 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {b : CategoryTheory.Limits.BinaryBicone.{u1, u3} C _inst_1 _inst_3 X Y}, (CategoryTheory.Limits.BinaryBicone.IsBilimit.{u1, u3} C _inst_1 _inst_3 X Y b) -> (CategoryTheory.Limits.BinaryBicone.IsBilimit.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.mapBinaryBicone.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F _inst_5 X Y b))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.is_binary_bilimit_of_preserves CategoryTheory.Limits.isBinaryBilimitOfPreservesₓ'. -/\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\ndef isBinaryBilimitOfPreserves {X Y : C} (F : C ⥤ D) [PreservesZeroMorphisms F]\n    [PreservesBinaryBiproduct X Y F] {b : BinaryBicone X Y} (hb : b.IsBilimit) :\n    (F.mapBinaryBicone b).IsBilimit :=\n  PreservesBinaryBiproduct.preserves hb\n#align category_theory.limits.is_binary_bilimit_of_preserves CategoryTheory.Limits.isBinaryBilimitOfPreserves\n\n#print CategoryTheory.Limits.PreservesBinaryBiproducts /-\n/-- A functor `F` preserves binary biproducts if it preserves the binary biproduct of `X` and `Y`\n    for all `X` and `Y`. -/\nclass PreservesBinaryBiproducts (F : C ⥤ D) [PreservesZeroMorphisms F] where\n  preserves : ∀ {X Y : C}, PreservesBinaryBiproduct X Y F := by infer_instance\n#align category_theory.limits.preserves_binary_biproducts CategoryTheory.Limits.PreservesBinaryBiproducts\n-/\n\n#print CategoryTheory.Limits.preservesBinaryBiproductOfPreservesBiproduct /-\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preservesBinaryBiproductOfPreservesBiproduct (F : C ⥤ D) [PreservesZeroMorphisms F] (X Y : C)\n    [PreservesBiproduct (pairFunction X Y) F] : PreservesBinaryBiproduct X Y F\n    where preserves b hb :=\n    { IsLimit :=\n        IsLimit.ofIsoLimit\n            ((IsLimit.postcomposeHomEquiv (diagram_iso_pair _) _).symm\n              (isBilimitOfPreserves F (b.toBiconeIsBilimit.symm hb)).IsLimit) <|\n          Cones.ext (Iso.refl _) fun j => by\n            rcases j with ⟨⟨⟩⟩\n            tidy\n      IsColimit :=\n        IsColimit.ofIsoColimit\n            ((IsColimit.precomposeInvEquiv (diagram_iso_pair _) _).symm\n              (isBilimitOfPreserves F (b.toBiconeIsBilimit.symm hb)).IsColimit) <|\n          Cocones.ext (Iso.refl _) fun j => by\n            rcases j with ⟨⟨⟩⟩\n            tidy }\n#align category_theory.limits.preserves_binary_biproduct_of_preserves_biproduct CategoryTheory.Limits.preservesBinaryBiproductOfPreservesBiproduct\n-/\n\n#print CategoryTheory.Limits.preservesBinaryBiproductsOfPreservesBiproducts /-\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preservesBinaryBiproductsOfPreservesBiproducts (F : C ⥤ D) [PreservesZeroMorphisms F]\n    [PreservesBiproductsOfShape WalkingPair F] : PreservesBinaryBiproducts F\n    where preserves X Y := preservesBinaryBiproductOfPreservesBiproduct F X Y\n#align category_theory.limits.preserves_binary_biproducts_of_preserves_biproducts CategoryTheory.Limits.preservesBinaryBiproductsOfPreservesBiproducts\n-/\n\nattribute [instance] preserves_binary_biproducts.preserves\n\nend Limits\n\nopen CategoryTheory.Limits\n\nnamespace Functor\n\nsection Bicone\n\nvariable {J : Type w₁} (F : C ⥤ D) (f : J → C) [HasBiproduct f]\n\nsection\n\nvariable [HasBiproduct (F.obj ∘ f)]\n\n/- warning: category_theory.functor.biproduct_comparison -> CategoryTheory.Functor.biproductComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)], Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6)\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)], Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biproduct_comparison CategoryTheory.Functor.biproductComparisonₓ'. -/\n/-- As for products, any functor between categories with biproducts gives rise to a morphism\n    `F.obj (⨁ f) ⟶ ⨁ (F.obj ∘ f)`. -/\ndef biproductComparison : F.obj (⨁ f) ⟶ ⨁ F.obj ∘ f :=\n  biproduct.lift fun j => F.map (biproduct.π f j)\n#align category_theory.functor.biproduct_comparison CategoryTheory.Functor.biproductComparison\n\n/- warning: category_theory.functor.biproduct_comparison_π -> CategoryTheory.Functor.biproductComparison_π is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)] (j : J), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f j)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f j) (CategoryTheory.Functor.biproductComparison.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6) (CategoryTheory.Limits.biproduct.π.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6 j)) (CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (f j) (CategoryTheory.Limits.biproduct.π.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)] (j : J), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f j)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f j) (CategoryTheory.Functor.biproductComparison.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6) (CategoryTheory.Limits.biproduct.π.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6 j)) (Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (f j) (CategoryTheory.Limits.biproduct.π.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biproduct_comparison_π CategoryTheory.Functor.biproductComparison_πₓ'. -/\n@[simp, reassoc.1]\ntheorem biproductComparison_π (j : J) :\n    biproductComparison F f ≫ biproduct.π _ j = F.map (biproduct.π f j) :=\n  biproduct.lift_π _ _\n#align category_theory.functor.biproduct_comparison_π CategoryTheory.Functor.biproductComparison_π\n\n/- warning: category_theory.functor.biproduct_comparison' -> CategoryTheory.Functor.biproductComparison' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)], Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)], Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biproduct_comparison' CategoryTheory.Functor.biproductComparison'ₓ'. -/\n/-- As for coproducts, any functor between categories with biproducts gives rise to a morphism\n    `⨁ (F.obj ∘ f) ⟶ F.obj (⨁ f)` -/\ndef biproductComparison' : ⨁ F.obj ∘ f ⟶ F.obj (⨁ f) :=\n  biproduct.desc fun j => F.map (biproduct.ι f j)\n#align category_theory.functor.biproduct_comparison' CategoryTheory.Functor.biproductComparison'\n\n/- warning: category_theory.functor.ι_biproduct_comparison' -> CategoryTheory.Functor.ι_biproductComparison' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)] (j : J), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f j) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5))) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f j) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.ι.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6 j) (CategoryTheory.Functor.biproductComparison'.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)) (CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (f j) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (CategoryTheory.Limits.biproduct.ι.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)] (j : J), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f j) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5))) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f j) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.ι.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6 j) (CategoryTheory.Functor.biproductComparison'.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)) (Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (CategoryTheory.Limits.biproduct.ι.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.ι_biproduct_comparison' CategoryTheory.Functor.ι_biproductComparison'ₓ'. -/\n@[simp, reassoc.1]\ntheorem ι_biproductComparison' (j : J) :\n    biproduct.ι _ j ≫ biproductComparison' F f = F.map (biproduct.ι f j) :=\n  biproduct.ι_desc _ _\n#align category_theory.functor.ι_biproduct_comparison' CategoryTheory.Functor.ι_biproductComparison'\n\nvariable [PreservesZeroMorphisms F]\n\n/- warning: category_theory.functor.biproduct_comparison'_comp_biproduct_comparison -> CategoryTheory.Functor.biproductComparison'_comp_biproductComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F], Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (CategoryTheory.Functor.biproductComparison'.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6) (CategoryTheory.Functor.biproductComparison.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)) (CategoryTheory.CategoryStruct.id.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F], Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (CategoryTheory.Functor.biproductComparison'.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6) (CategoryTheory.Functor.biproductComparison.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)) (CategoryTheory.CategoryStruct.id.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biproduct_comparison'_comp_biproduct_comparison CategoryTheory.Functor.biproductComparison'_comp_biproductComparisonₓ'. -/\n/-- The composition in the opposite direction is equal to the identity if and only if `F` preserves\n    the biproduct, see `preserves_biproduct_of_mono_biproduct_comparison`.  -/\n@[simp, reassoc.1]\ntheorem biproductComparison'_comp_biproductComparison :\n    biproductComparison' F f ≫ biproductComparison F f = 𝟙 (⨁ F.obj ∘ f) := by\n  classical\n    ext\n    simp [biproduct.ι_π, ← functor.map_comp, eq_to_hom_map]\n#align category_theory.functor.biproduct_comparison'_comp_biproduct_comparison CategoryTheory.Functor.biproductComparison'_comp_biproductComparison\n\n/- warning: category_theory.functor.split_epi_biproduct_comparison -> CategoryTheory.Functor.splitEpiBiproductComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitEpi.{u3, u5} D _inst_2 (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (CategoryTheory.Functor.biproductComparison.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitEpi.{u3, u5} D _inst_2 (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (CategoryTheory.Functor.biproductComparison.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.split_epi_biproduct_comparison CategoryTheory.Functor.splitEpiBiproductComparisonₓ'. -/\n/-- `biproduct_comparison F f` is a split epimorphism. -/\n@[simps]\ndef splitEpiBiproductComparison : SplitEpi (biproductComparison F f) :=\n  ⟨biproductComparison' F f⟩\n#align category_theory.functor.split_epi_biproduct_comparison CategoryTheory.Functor.splitEpiBiproductComparison\n\ninstance : IsSplitEpi (biproductComparison F f) :=\n  IsSplitEpi.mk' (splitEpiBiproductComparison F f)\n\n/- warning: category_theory.functor.split_mono_biproduct_comparison' -> CategoryTheory.Functor.splitMonoBiproductComparison' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitMono.{u3, u5} D _inst_2 (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) _inst_6) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Functor.biproductComparison'.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitMono.{u3, u5} D _inst_2 (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) _inst_6) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Functor.biproductComparison'.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.split_mono_biproduct_comparison' CategoryTheory.Functor.splitMonoBiproductComparison'ₓ'. -/\n/-- `biproduct_comparison' F f` is a split monomorphism. -/\n@[simps]\ndef splitMonoBiproductComparison' : SplitMono (biproductComparison' F f) :=\n  ⟨biproductComparison F f⟩\n#align category_theory.functor.split_mono_biproduct_comparison' CategoryTheory.Functor.splitMonoBiproductComparison'\n\ninstance : IsSplitMono (biproductComparison' F f) :=\n  IsSplitMono.mk' (splitMonoBiproductComparison' F f)\n\nend\n\nvariable [PreservesZeroMorphisms F] [PreservesBiproduct f F]\n\n/- warning: category_theory.functor.has_biproduct_of_preserves -> CategoryTheory.Functor.hasBiproduct_of_preserves is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f)\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], CategoryTheory.Limits.HasBiproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.has_biproduct_of_preserves CategoryTheory.Functor.hasBiproduct_of_preservesₓ'. -/\ninstance hasBiproduct_of_preserves : HasBiproduct (F.obj ∘ f) :=\n  HasBiproduct.mk\n    { Bicone := F.mapBicone (biproduct.bicone f)\n      IsBilimit := PreservesBiproduct.preserves (biproduct.isBilimit _) }\n#align category_theory.functor.has_biproduct_of_preserves CategoryTheory.Functor.hasBiproduct_of_preserves\n\n/- warning: category_theory.functor.map_biproduct -> CategoryTheory.Functor.mapBiproduct is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], CategoryTheory.Iso.{u3, u5} D _inst_2 (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], CategoryTheory.Iso.{u3, u5} D _inst_2 (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_biproduct CategoryTheory.Functor.mapBiproductₓ'. -/\n/-- If `F` preserves a biproduct, we get a definitionally nice isomorphism\n    `F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f)`. -/\n@[simp]\ndef mapBiproduct : F.obj (⨁ f) ≅ ⨁ F.obj ∘ f :=\n  biproduct.uniqueUpToIso _ (PreservesBiproduct.preserves (biproduct.isBilimit _))\n#align category_theory.functor.map_biproduct CategoryTheory.Functor.mapBiproduct\n\n/- warning: category_theory.functor.map_biproduct_hom -> CategoryTheory.Functor.mapBiproduct_hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7))) (CategoryTheory.Iso.hom.{u3, u5} D _inst_2 (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biproduct.lift.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (fun (j : J) => CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (f j) (CategoryTheory.Limits.biproduct.π.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j)))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7))) (CategoryTheory.Iso.hom.{u3, u5} D _inst_2 (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biproduct.lift.{u1, u3, u5} J D _inst_2 _inst_4 (fun (j : J) => Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j)) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (fun (j : J) => Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (f j) (CategoryTheory.Limits.biproduct.π.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j)))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_biproduct_hom CategoryTheory.Functor.mapBiproduct_homₓ'. -/\ntheorem mapBiproduct_hom :\n    (mapBiproduct F f).hom = biproduct.lift fun j => F.map (biproduct.π f j) :=\n  rfl\n#align category_theory.functor.map_biproduct_hom CategoryTheory.Functor.mapBiproduct_hom\n\n/- warning: category_theory.functor.map_biproduct_inv -> CategoryTheory.Functor.mapBiproduct_inv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5))) (CategoryTheory.Iso.inv.{u3, u5} D _inst_2 (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biproduct.desc.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (fun (j : J) => CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (f j) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (CategoryTheory.Limits.biproduct.ι.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j)))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] {J : Type.{u1}} (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) (f : J -> C) [_inst_5 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_6], Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5))) (CategoryTheory.Iso.inv.{u3, u5} D _inst_2 (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biproduct.desc.{u1, u3, u5} J D _inst_2 _inst_4 (fun (j : J) => Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j)) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_5 _inst_6 _inst_7) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5)) (fun (j : J) => Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5) (CategoryTheory.Limits.biproduct.ι.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j)))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_biproduct_inv CategoryTheory.Functor.mapBiproduct_invₓ'. -/\ntheorem mapBiproduct_inv :\n    (mapBiproduct F f).inv = biproduct.desc fun j => F.map (biproduct.ι f j) :=\n  rfl\n#align category_theory.functor.map_biproduct_inv CategoryTheory.Functor.mapBiproduct_inv\n\nend Bicone\n\nvariable (F : C ⥤ D) (X Y : C) [HasBinaryBiproduct X Y]\n\nsection\n\nvariable [HasBinaryBiproduct (F.obj X) (F.obj Y)]\n\n/- warning: category_theory.functor.biprod_comparison -> CategoryTheory.Functor.biprodComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)], Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)], Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biprod_comparison CategoryTheory.Functor.biprodComparisonₓ'. -/\n/-- As for products, any functor between categories with binary biproducts gives rise to a\n    morphism `F.obj (X ⊞ Y) ⟶ F.obj X ⊞ F.obj Y`. -/\ndef biprodComparison : F.obj (X ⊞ Y) ⟶ F.obj X ⊞ F.obj Y :=\n  biprod.lift (F.map biprod.fst) (F.map biprod.snd)\n#align category_theory.functor.biprod_comparison CategoryTheory.Functor.biprodComparison\n\n/- warning: category_theory.functor.biprod_comparison_fst -> CategoryTheory.Functor.biprodComparison_fst is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6) (CategoryTheory.Limits.biprod.fst.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) X (CategoryTheory.Limits.biprod.fst.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6) (CategoryTheory.Limits.biprod.fst.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) X (CategoryTheory.Limits.biprod.fst.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biprod_comparison_fst CategoryTheory.Functor.biprodComparison_fstₓ'. -/\n@[simp, reassoc.1]\ntheorem biprodComparison_fst : biprodComparison F X Y ≫ biprod.fst = F.map biprod.fst :=\n  biprod.lift_fst _ _\n#align category_theory.functor.biprod_comparison_fst CategoryTheory.Functor.biprodComparison_fst\n\n/- warning: category_theory.functor.biprod_comparison_snd -> CategoryTheory.Functor.biprodComparison_snd is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6) (CategoryTheory.Limits.biprod.snd.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) Y (CategoryTheory.Limits.biprod.snd.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6) (CategoryTheory.Limits.biprod.snd.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) Y (CategoryTheory.Limits.biprod.snd.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biprod_comparison_snd CategoryTheory.Functor.biprodComparison_sndₓ'. -/\n@[simp, reassoc.1]\ntheorem biprodComparison_snd : biprodComparison F X Y ≫ biprod.snd = F.map biprod.snd :=\n  biprod.lift_snd _ _\n#align category_theory.functor.biprod_comparison_snd CategoryTheory.Functor.biprodComparison_snd\n\n/- warning: category_theory.functor.biprod_comparison' -> CategoryTheory.Functor.biprodComparison' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)], Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)], Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biprod_comparison' CategoryTheory.Functor.biprodComparison'ₓ'. -/\n/-- As for coproducts, any functor between categories with binary biproducts gives rise to a\n    morphism `F.obj X ⊞ F.obj Y ⟶ F.obj (X ⊞ Y)`. -/\ndef biprodComparison' : F.obj X ⊞ F.obj Y ⟶ F.obj (X ⊞ Y) :=\n  biprod.desc (F.map biprod.inl) (F.map biprod.inr)\n#align category_theory.functor.biprod_comparison' CategoryTheory.Functor.biprodComparison'\n\n/- warning: category_theory.functor.inl_biprod_comparison' -> CategoryTheory.Functor.inl_biprodComparison' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.inl.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inl.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.inl.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inl.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.inl_biprod_comparison' CategoryTheory.Functor.inl_biprodComparison'ₓ'. -/\n@[simp, reassoc.1]\ntheorem inl_biprodComparison' : biprod.inl ≫ biprodComparison' F X Y = F.map biprod.inl :=\n  biprod.inl_desc _ _\n#align category_theory.functor.inl_biprod_comparison' CategoryTheory.Functor.inl_biprodComparison'\n\n/- warning: category_theory.functor.inr_biprod_comparison' -> CategoryTheory.Functor.inr_biprodComparison' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.inr.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inr.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.inr.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inr.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.inr_biprod_comparison' CategoryTheory.Functor.inr_biprodComparison'ₓ'. -/\n@[simp, reassoc.1]\ntheorem inr_biprodComparison' : biprod.inr ≫ biprodComparison' F X Y = F.map biprod.inr :=\n  biprod.inr_desc _ _\n#align category_theory.functor.inr_biprod_comparison' CategoryTheory.Functor.inr_biprodComparison'\n\nvariable [PreservesZeroMorphisms F]\n\n/- warning: category_theory.functor.biprod_comparison'_comp_biprod_comparison -> CategoryTheory.Functor.biprodComparison'_comp_biprodComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)) (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)) (CategoryTheory.CategoryStruct.id.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.biprod_comparison'_comp_biprod_comparison CategoryTheory.Functor.biprodComparison'_comp_biprodComparisonₓ'. -/\n/-- The composition in the opposite direction is equal to the identity if and only if `F` preserves\n    the biproduct, see `preserves_binary_biproduct_of_mono_biprod_comparison`. -/\n@[simp, reassoc.1]\ntheorem biprodComparison'_comp_biprodComparison :\n    biprodComparison' F X Y ≫ biprodComparison F X Y = 𝟙 (F.obj X ⊞ F.obj Y) := by\n  ext <;> simp [← functor.map_comp]\n#align category_theory.functor.biprod_comparison'_comp_biprod_comparison CategoryTheory.Functor.biprodComparison'_comp_biprodComparison\n\n/- warning: category_theory.functor.split_epi_biprod_comparison -> CategoryTheory.Functor.splitEpiBiprodComparison is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitEpi.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitEpi.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (CategoryTheory.Functor.biprodComparison.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.split_epi_biprod_comparison CategoryTheory.Functor.splitEpiBiprodComparisonₓ'. -/\n/-- `biprod_comparison F X Y` is a split epi. -/\n@[simps]\ndef splitEpiBiprodComparison : SplitEpi (biprodComparison F X Y) :=\n  ⟨biprodComparison' F X Y⟩\n#align category_theory.functor.split_epi_biprod_comparison CategoryTheory.Functor.splitEpiBiprodComparison\n\ninstance : IsSplitEpi (biprodComparison F X Y) :=\n  IsSplitEpi.mk' (splitEpiBiprodComparison F X Y)\n\n/- warning: category_theory.functor.split_mono_biprod_comparison' -> CategoryTheory.Functor.splitMonoBiprodComparison' is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitMono.{u2, u4} D _inst_2 (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) _inst_6) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)] [_inst_7 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F], CategoryTheory.SplitMono.{u2, u4} D _inst_2 (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) _inst_6) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.biprodComparison'.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.split_mono_biprod_comparison' CategoryTheory.Functor.splitMonoBiprodComparison'ₓ'. -/\n/-- `biprod_comparison' F X Y` is a split mono. -/\n@[simps]\ndef splitMonoBiprodComparison' : SplitMono (biprodComparison' F X Y) :=\n  ⟨biprodComparison F X Y⟩\n#align category_theory.functor.split_mono_biprod_comparison' CategoryTheory.Functor.splitMonoBiprodComparison'\n\ninstance : IsSplitMono (biprodComparison' F X Y) :=\n  IsSplitMono.mk' (splitMonoBiprodComparison' F X Y)\n\nend\n\nvariable [PreservesZeroMorphisms F] [PreservesBinaryBiproduct X Y F]\n\n/- warning: category_theory.functor.has_binary_biproduct_of_preserves -> CategoryTheory.Functor.hasBinaryBiproduct_of_preserves is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y)\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], CategoryTheory.Limits.HasBinaryBiproduct.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y)\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.has_binary_biproduct_of_preserves CategoryTheory.Functor.hasBinaryBiproduct_of_preservesₓ'. -/\ninstance hasBinaryBiproduct_of_preserves : HasBinaryBiproduct (F.obj X) (F.obj Y) :=\n  HasBinaryBiproduct.mk\n    { Bicone := F.mapBinaryBicone (BinaryBiproduct.bicone X Y)\n      IsBilimit := PreservesBinaryBiproduct.preserves (BinaryBiproduct.isBilimit _ _) }\n#align category_theory.functor.has_binary_biproduct_of_preserves CategoryTheory.Functor.hasBinaryBiproduct_of_preserves\n\n/- warning: category_theory.functor.map_biprod -> CategoryTheory.Functor.mapBiprod is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], CategoryTheory.Iso.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], CategoryTheory.Iso.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_biprod CategoryTheory.Functor.mapBiprodₓ'. -/\n/-- If `F` preserves a binary biproduct, we get a definitionally nice isomorphism\n    `F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y`. -/\n@[simp]\ndef mapBiprod : F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y :=\n  biprod.uniqueUpToIso _ _ (PreservesBinaryBiproduct.preserves (BinaryBiproduct.isBilimit _ _))\n#align category_theory.functor.map_biprod CategoryTheory.Functor.mapBiprod\n\n/- warning: category_theory.functor.map_biprod_hom -> CategoryTheory.Functor.mapBiprod_hom is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7))) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biprod.lift.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) X (CategoryTheory.Limits.biprod.fst.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) Y (CategoryTheory.Limits.biprod.snd.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7))) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biprod.lift.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) X (CategoryTheory.Limits.biprod.fst.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) Y (CategoryTheory.Limits.biprod.snd.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_biprod_hom CategoryTheory.Functor.mapBiprod_homₓ'. -/\ntheorem mapBiprod_hom : (mapBiprod F X Y).hom = biprod.lift (F.map biprod.fst) (F.map biprod.snd) :=\n  rfl\n#align category_theory.functor.map_biprod_hom CategoryTheory.Functor.mapBiprod_hom\n\n/- warning: category_theory.functor.map_biprod_inv -> CategoryTheory.Functor.mapBiprod_inv is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biprod.desc.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inl.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inr.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) (X : C) (Y : C) [_inst_5 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_6 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_6], Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5))) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7)) (CategoryTheory.Limits.biprod.desc.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_5 _inst_6 _inst_7) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inl.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_5) (CategoryTheory.Limits.biprod.inr.{u1, u3} C _inst_1 _inst_3 X Y _inst_5)))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.map_biprod_inv CategoryTheory.Functor.mapBiprod_invₓ'. -/\ntheorem mapBiprod_inv : (mapBiprod F X Y).inv = biprod.desc (F.map biprod.inl) (F.map biprod.inr) :=\n  rfl\n#align category_theory.functor.map_biprod_inv CategoryTheory.Functor.mapBiprod_inv\n\nend Functor\n\nnamespace Limits\n\nvariable (F : C ⥤ D) [PreservesZeroMorphisms F]\n\nsection Bicone\n\nvariable {J : Type w₁} (f : J → C) [HasBiproduct f] [PreservesBiproduct f F] {W : C}\n\n/- warning: category_theory.limits.biproduct.map_lift_map_biprod -> CategoryTheory.Limits.biproduct.map_lift_mapBiprod is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} (f : J -> C) [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {W : C} (g : forall (j : J), Quiver.Hom.{succ u2, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) W (f j)), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7))) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 (fun (j : J) => f j) _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 (fun (j : J) => f j) _inst_6) (CategoryTheory.Limits.biproduct.lift.{u1, u2, u4} J C _inst_1 _inst_3 (fun (j : J) => f j) _inst_6 W g)) (CategoryTheory.Iso.hom.{u3, u5} D _inst_2 (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7))) (CategoryTheory.Limits.biproduct.lift.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W) (fun (j : J) => CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W (f j) (g j)))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} (f : J -> C) [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {W : C} (g : forall (j : J), Quiver.Hom.{succ u2, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) W (f j)), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7))) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 (fun (j : J) => f j) _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 (fun (j : J) => f j) _inst_6) (CategoryTheory.Limits.biproduct.lift.{u1, u2, u4} J C _inst_1 _inst_3 (fun (j : J) => f j) _inst_6 W g)) (CategoryTheory.Iso.hom.{u3, u5} D _inst_2 (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7))) (CategoryTheory.Limits.biproduct.lift.{u1, u3, u5} J D _inst_2 _inst_4 (fun (j : J) => Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j)) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W) (fun (j : J) => Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W (f j) (g j)))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.biproduct.map_lift_map_biprod CategoryTheory.Limits.biproduct.map_lift_mapBiprodₓ'. -/\ntheorem biproduct.map_lift_mapBiprod (g : ∀ j, W ⟶ f j) :\n    F.map (biproduct.lift g) ≫ (F.mapBiproduct f).hom = biproduct.lift fun j => F.map (g j) :=\n  by\n  ext\n  simp [← F.map_comp]\n#align category_theory.limits.biproduct.map_lift_map_biprod CategoryTheory.Limits.biproduct.map_lift_mapBiprod\n\n/- warning: category_theory.limits.biproduct.map_biproduct_inv_map_desc -> CategoryTheory.Limits.biproduct.mapBiproduct_inv_map_desc is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} (f : J -> C) [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {W : C} (g : forall (j : J), Quiver.Hom.{succ u2, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) (f j) W), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W) (CategoryTheory.Iso.inv.{u3, u5} D _inst_2 (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6) W (CategoryTheory.Limits.biproduct.desc.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6 W g))) (CategoryTheory.Limits.biproduct.desc.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W) (fun (j : J) => CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (f j) W (g j)))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} (f : J -> C) [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {W : C} (g : forall (j : J), Quiver.Hom.{succ u2, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) (f j) W), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W) (CategoryTheory.Iso.inv.{u3, u5} D _inst_2 (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6) W (CategoryTheory.Limits.biproduct.desc.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6 W g))) (CategoryTheory.Limits.biproduct.desc.{u1, u3, u5} J D _inst_2 _inst_4 (fun (j : J) => Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j)) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W) (fun (j : J) => Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j) W (g j)))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.biproduct.map_biproduct_inv_map_desc CategoryTheory.Limits.biproduct.mapBiproduct_inv_map_descₓ'. -/\ntheorem biproduct.mapBiproduct_inv_map_desc (g : ∀ j, f j ⟶ W) :\n    (F.mapBiproduct f).inv ≫ F.map (biproduct.desc g) = biproduct.desc fun j => F.map (g j) :=\n  by\n  ext\n  simp [← F.map_comp]\n#align category_theory.limits.biproduct.map_biproduct_inv_map_desc CategoryTheory.Limits.biproduct.mapBiproduct_inv_map_desc\n\n/- warning: category_theory.limits.biproduct.map_biproduct_hom_desc -> CategoryTheory.Limits.biproduct.mapBiproduct_hom_desc is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} (f : J -> C) [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {W : C} (g : forall (j : J), Quiver.Hom.{succ u2, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) (f j) W), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W) (CategoryTheory.Iso.hom.{u3, u5} D _inst_2 (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Limits.biproduct.desc.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7) (CategoryTheory.Functor.obj.{u2, u3, u4, u5} C _inst_1 D _inst_2 F W) (fun (j : J) => CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (f j) W (g j)))) (CategoryTheory.Functor.map.{u2, u3, u4, u5} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6) W (CategoryTheory.Limits.biproduct.desc.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6 W g))\nbut is expected to have type\n  forall {C : Type.{u4}} [_inst_1 : CategoryTheory.Category.{u2, u4} C] {D : Type.{u5}} [_inst_2 : CategoryTheory.Category.{u3, u5} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u3, u5} D _inst_2] (F : CategoryTheory.Functor.{u2, u3, u4, u5} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 F] {J : Type.{u1}} (f : J -> C) [_inst_6 : CategoryTheory.Limits.HasBiproduct.{u1, u2, u4} J C _inst_1 _inst_3 f] [_inst_7 : CategoryTheory.Limits.PreservesBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J f F _inst_5] {W : C} (g : forall (j : J), Quiver.Hom.{succ u2, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) (f j) W), Eq.{succ u3} (Quiver.Hom.{succ u3, u5} D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W)) (CategoryTheory.CategoryStruct.comp.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W) (CategoryTheory.Iso.hom.{u3, u5} D _inst_2 (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_6)) (CategoryTheory.Limits.biproduct.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiproduct.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7)) (CategoryTheory.Limits.biproduct.desc.{u1, u3, u5} J D _inst_2 _inst_4 (Function.comp.{succ u1, succ u4, succ u5} J C D (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F)) f) (CategoryTheory.Functor.hasBiproduct_of_preserves.{u1, u2, u3, u4, u5} C _inst_1 D _inst_2 _inst_3 _inst_4 J F f _inst_6 _inst_5 _inst_7) (Prefunctor.obj.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) W) (fun (j : J) => Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (f j) W (g j)))) (Prefunctor.map.{succ u2, succ u3, u4, u5} C (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} C (CategoryTheory.Category.toCategoryStruct.{u2, u4} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u3, u5} D (CategoryTheory.Category.toCategoryStruct.{u3, u5} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u2, u3, u4, u5} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biproduct.{u1, u2, u4} J C _inst_1 _inst_3 (fun (b : J) => f b) _inst_6) W (CategoryTheory.Limits.biproduct.desc.{u1, u2, u4} J C _inst_1 _inst_3 (fun (b : J) => f b) _inst_6 W g))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.biproduct.map_biproduct_hom_desc CategoryTheory.Limits.biproduct.mapBiproduct_hom_descₓ'. -/\ntheorem biproduct.mapBiproduct_hom_desc (g : ∀ j, f j ⟶ W) :\n    ((F.mapBiproduct f).hom ≫ biproduct.desc fun j => F.map (g j)) = F.map (biproduct.desc g) := by\n  rw [← biproduct.map_biproduct_inv_map_desc, iso.hom_inv_id_assoc]\n#align category_theory.limits.biproduct.map_biproduct_hom_desc CategoryTheory.Limits.biproduct.mapBiproduct_hom_desc\n\nend Bicone\n\nsection BinaryBicone\n\nvariable (X Y : C) [HasBinaryBiproduct X Y] [PreservesBinaryBiproduct X Y F] {W : C}\n\n/- warning: category_theory.limits.biprod.map_lift_map_biprod -> CategoryTheory.Limits.biprod.map_lift_mapBiprod is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) (CategoryTheory.Limits.biprod.lift.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7))) (CategoryTheory.Limits.biprod.lift.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W Y g))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) (CategoryTheory.Limits.biprod.lift.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g)) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7))) (CategoryTheory.Limits.biprod.lift.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W Y g))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.biprod.map_lift_map_biprod CategoryTheory.Limits.biprod.map_lift_mapBiprodₓ'. -/\ntheorem biprod.map_lift_mapBiprod (f : W ⟶ X) (g : W ⟶ Y) :\n    F.map (biprod.lift f g) ≫ (F.mapBiprod X Y).hom = biprod.lift (F.map f) (F.map g) := by\n  ext <;> simp [← F.map_comp]\n#align category_theory.limits.biprod.map_lift_map_biprod CategoryTheory.Limits.biprod.map_lift_mapBiprod\n\n/- warning: category_theory.limits.biprod.lift_map_biprod -> CategoryTheory.Limits.biprod.lift_mapBiprod is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.lift.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W X f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W Y g)) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7))) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) (CategoryTheory.Limits.biprod.lift.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W X) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) W Y), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6))) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.lift.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W X f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W Y g)) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) (CategoryTheory.Limits.biprod.lift.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.biprod.lift_map_biprod CategoryTheory.Limits.biprod.lift_mapBiprodₓ'. -/\ntheorem biprod.lift_mapBiprod (f : W ⟶ X) (g : W ⟶ Y) :\n    biprod.lift (F.map f) (F.map g) ≫ (F.mapBiprod X Y).inv = F.map (biprod.lift f g) := by\n  rw [← biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n#align category_theory.limits.biprod.lift_map_biprod CategoryTheory.Limits.biprod.lift_mapBiprod\n\n/- warning: category_theory.limits.biprod.map_biprod_inv_map_desc -> CategoryTheory.Limits.biprod.mapBiprod_inv_map_desc is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X W) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y W), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) W (CategoryTheory.Limits.biprod.desc.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g))) (CategoryTheory.Limits.biprod.desc.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X W f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y W g))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X W) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y W), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (CategoryTheory.Iso.inv.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) W (CategoryTheory.Limits.biprod.desc.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g))) (CategoryTheory.Limits.biprod.desc.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X W f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y W g))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.biprod.map_biprod_inv_map_desc CategoryTheory.Limits.biprod.mapBiprod_inv_map_descₓ'. -/\ntheorem biprod.mapBiprod_inv_map_desc (f : X ⟶ W) (g : Y ⟶ W) :\n    (F.mapBiprod X Y).inv ≫ F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) := by\n  ext <;> simp [← F.map_comp]\n#align category_theory.limits.biprod.map_biprod_inv_map_desc CategoryTheory.Limits.biprod.mapBiprod_inv_map_desc\n\n/- warning: category_theory.limits.biprod.map_biprod_hom_desc -> CategoryTheory.Limits.biprod.mapBiprod_hom_desc is a dubious translation:\nlean 3 declaration is\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X W) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y W), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Limits.biprod.desc.{u2, u4} D _inst_2 _inst_4 (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F W) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X) (CategoryTheory.Functor.obj.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F X W f) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F Y W g))) (CategoryTheory.Functor.map.{u1, u2, u3, u4} C _inst_1 D _inst_2 F (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) W (CategoryTheory.Limits.biprod.desc.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g))\nbut is expected to have type\n  forall {C : Type.{u3}} [_inst_1 : CategoryTheory.Category.{u1, u3} C] {D : Type.{u4}} [_inst_2 : CategoryTheory.Category.{u2, u4} D] [_inst_3 : CategoryTheory.Limits.HasZeroMorphisms.{u1, u3} C _inst_1] [_inst_4 : CategoryTheory.Limits.HasZeroMorphisms.{u2, u4} D _inst_2] (F : CategoryTheory.Functor.{u1, u2, u3, u4} C _inst_1 D _inst_2) [_inst_5 : CategoryTheory.Functor.PreservesZeroMorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F] (X : C) (Y : C) [_inst_6 : CategoryTheory.Limits.HasBinaryBiproduct.{u1, u3} C _inst_1 _inst_3 X Y] [_inst_7 : CategoryTheory.Limits.PreservesBinaryBiproduct.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 X Y F _inst_5] {W : C} (f : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) X W) (g : Quiver.Hom.{succ u1, u3} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) Y W), Eq.{succ u2} (Quiver.Hom.{succ u2, u4} D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W)) (CategoryTheory.CategoryStruct.comp.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (CategoryTheory.Iso.hom.{u2, u4} D _inst_2 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6)) (CategoryTheory.Limits.biprod.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Functor.mapBiprod.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7)) (CategoryTheory.Limits.biprod.desc.{u2, u4} D _inst_2 _inst_4 (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) W) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X) (Prefunctor.obj.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y) (CategoryTheory.Functor.hasBinaryBiproduct_of_preserves.{u1, u2, u3, u4} C _inst_1 D _inst_2 _inst_3 _inst_4 F X Y _inst_6 _inst_5 _inst_7) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) X W f) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) Y W g))) (Prefunctor.map.{succ u1, succ u2, u3, u4} C (CategoryTheory.CategoryStruct.toQuiver.{u1, u3} C (CategoryTheory.Category.toCategoryStruct.{u1, u3} C _inst_1)) D (CategoryTheory.CategoryStruct.toQuiver.{u2, u4} D (CategoryTheory.Category.toCategoryStruct.{u2, u4} D _inst_2)) (CategoryTheory.Functor.toPrefunctor.{u1, u2, u3, u4} C _inst_1 D _inst_2 F) (CategoryTheory.Limits.biprod.{u1, u3} C _inst_1 _inst_3 X Y _inst_6) W (CategoryTheory.Limits.biprod.desc.{u1, u3} C _inst_1 _inst_3 W X Y _inst_6 f g))\nCase conversion may be inaccurate. Consider using '#align category_theory.limits.biprod.map_biprod_hom_desc CategoryTheory.Limits.biprod.mapBiprod_hom_descₓ'. -/\ntheorem biprod.mapBiprod_hom_desc (f : X ⟶ W) (g : Y ⟶ W) :\n    (F.mapBiprod X Y).hom ≫ biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) := by\n  rw [← biprod.map_biprod_inv_map_desc, iso.hom_inv_id_assoc]\n#align category_theory.limits.biprod.map_biprod_hom_desc CategoryTheory.Limits.biprod.mapBiprod_hom_desc\n\nend BinaryBicone\n\nend Limits\n\nend HasZeroMorphisms\n\nend CategoryTheory\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/CategoryTheory/Limits/Preserves/Shapes/Biproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.727975460709318, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.4504569764503354}}
{"text": "/-\nCopyright (c) 2020 Wojciech Nawrocki. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Wojciech Nawrocki\n-/\n\nimport category_theory.limits.shapes.finite_products\nimport category_theory.limits.shapes.binary_products\nimport category_theory.limits.shapes.terminal\nimport tactic.rcases\nimport pfin\n\n/-! # Stuff that should be in the catthy library. -/\nnamespace category_theory\n\nuniverse w\ndef discrete.equiv_of_iso {J K : Type w} (h : J ≃ K) : (discrete J ≌ discrete K) :=\nequivalence.mk\n  (functor.of_function h.to_fun) -- C ⥤ D\n  (functor.of_function h.inv_fun) -- D ⥤ C\n  { hom := {\n      app := λ X, begin\n        apply eq_to_hom,\n        simp only [functor.id_obj, functor.of_function_obj, functor.comp_obj],\n        exact (h.left_inv X).symm,\n      end,\n      naturality' := λ X Y f, dec_trivial },\n    inv := {\n      app := λ X, begin\n        apply eq_to_hom,\n        simp only [functor.id_obj, functor.of_function_obj, functor.comp_obj],\n        exact h.left_inv X,\n      end,\n      naturality' := λ X Y f, dec_trivial },\n    hom_inv_id' := by ext1; exact dec_trivial,\n    inv_hom_id' := by ext1; exact dec_trivial }\n  { hom := {\n      app := λ X, begin\n        apply eq_to_hom,\n        simp only [functor.id_obj, functor.of_function_obj, functor.comp_obj],\n        exact h.right_inv X\n      end,\n      naturality' := λ X Y f, dec_trivial },\n    inv := {\n      app := λ X, begin\n        apply eq_to_hom,\n        simp only [functor.id_obj, functor.of_function_obj, functor.comp_obj],\n        exact (h.right_inv X).symm,\n      end,\n      naturality' := λ X Y f, dec_trivial },\n    hom_inv_id' := by ext1; exact dec_trivial,\n    inv_hom_id' := by ext1; exact dec_trivial }\n\nnamespace limits\n\nuniverses v u\nvariables {C : Type u} [𝒞 : category.{v} C]\ninclude 𝒞\n\nlemma prod.lift_fst {X Y Z : C} [has_limit (pair X Y)] (f : Z ⟶ X) (g : Z ⟶ Y) : prod.lift f g ≫ prod.fst = f :=\nby simp only [binary_fan.mk_π_app_left, limit.lift_π]\n\nlemma prod.lift_snd {X Y Z : C} [has_limit (pair X Y)] (f : Z ⟶ X) (g : Z ⟶ Y) : prod.lift f g ≫ prod.snd = g :=\nby simp only [binary_fan.mk_π_app_right, limit.lift_π]\n\nlemma prod.lift_uniq {X Y Z : C} [has_limit (pair X Y)] (f : Z ⟶ X) (g : Z ⟶ Y) (m : Z ⟶ X ⨯ Y)\n  (hLeft : m ≫ prod.fst = f) (hRight : m ≫ prod.snd = g)\n  : m = prod.lift f g :=\nbegin\n  apply limit.hom_ext,\n  intro j,\n  cases hLeft, cases hRight, cases j,\n    simp only [limit.lift_π, binary_fan.mk_π_app_left],\n  simp only [limit.lift_π, binary_fan.mk_π_app_right],\nend\n\nend limits\nend category_theory\n\n/-!\n# Constructing finite products from binary products and a terminal object\n\nIf a category has all binary products, and a terminal object, then it has all finite products.\n-/\n\nnamespace category_theory.limits\nopen category_theory\n\nuniverses v u\nvariables {C : Type u} [𝒞 : category.{v} C]\ninclude 𝒞\n\n-- We hide the \"implementation details\" inside a namespace\nnamespace has_finite_products_of_binary_products_and_terminal_object\n\n@[reducible]\ndef match_statement_lol [has_binary_products.{v} C]\n  {n : ℕ} (F: discrete (pfin (nat.succ n)) ⥤ C) (limF': has_limit (discrete.lift pfin.succ ⋙ F))\n  : Π (j: pfin (nat.succ n)), F.obj ⟨0, nat.succ_pos n⟩ ⨯ limF'.cone.X ⟶ F.obj j\n| ⟨0, _⟩ := prod.fst\n| w@⟨nat.succ j, _⟩ := prod.snd ≫\n  limF'.cone.π.app (w.pred (λ h, nat.succ_ne_zero j (pfin.veq_of_eq h)))\n\nset_option eqn_compiler.zeta true\ndef has_limit_for_pfin_diagram [has_binary_products.{v} C] [has_terminal.{v} C]\n: Π {n: ℕ} (F: (discrete (pfin n)) ⥤ C)\n, has_limit F\n| 0 F :=\n  -- In the base case, the category of cones over a diagram of shape ∅ is simply 𝒞, so\n  -- the limit cone is 𝒞's terminal object.\n  let absurdJ (x : pfin 0) : false := x.elim0 in\n  let myCone : cone F :=\n    { X := terminal C,\n      π := nat_trans.of_homs (λ j, (absurdJ j).elim) } in\n  { cone := myCone,\n    is_limit :=\n      { lift := λ s, terminal.from s.X\n      , fac' := λ s j, (absurdJ j).elim\n      , uniq' := λ s m h, dec_trivial } }\n\n| (nat.succ n) F :=\n  -- In the inductive case, we construct a limit cone with apex (F 0) ⨯ (apex of smaller limit cone)\n  -- where the smaller cone is obtained from the below functor.\n  let F' : discrete (pfin n) ⥤ C := discrete.lift pfin.succ ⋙ F in\n  let limF' : has_limit F' := has_limit_for_pfin_diagram F' in\n  let myCone : cone F :=\n    { X := (F.obj ⟨0, nat.succ_pos n⟩) ⨯ limF'.cone.X\n    , π := nat_trans.of_homs (match_statement_lol F limF') } in -- TODO(WN): using an actual match statement here\n                                                                -- is hard to unfold later, but would obv be nicer.\n  { cone := myCone,\n    is_limit :=\n      { lift := λ s,\n          -- Show that s.X is also the apex of a cone over F' ..\n          let s' : cone F' :=\n            { X := s.X\n            , π := nat_trans.of_homs (λ j, s.π.app j.succ) } in\n          -- .. in order to get from s.X to limF'.cone.X in the right morphism\n          -- using the fact that limF' is a limit cone over F'.\n          prod.lift\n            (s.π.app $ ⟨0, nat.succ_pos n⟩)\n            (eq_to_hom rfl ≫ limF'.is_limit.lift s')\n      -- Show that lift is in fact a morphism of cones from s into myCone.\n      , fac' := λ s j, begin\n        rcases j with ⟨j, hj⟩, cases j;\n        simp only [category.id_comp, nat_trans.of_homs_app, eq_to_hom_refl, match_statement_lol,\n          prod.lift_fst, limit.lift_π_assoc, is_limit.fac, nat_trans.of_homs_app,\n          binary_fan.mk_π_app_right], congr\n      end\n      -- Show that lift is the unique morphism into myCone.\n      , uniq' := λ s m h, begin\n        have h0 := h ⟨0, nat.succ_pos n⟩,\n        simp [match_statement_lol] at h0,\n        let s' : cone F' :=\n          { X := s.X\n          , π := nat_trans.of_homs (λ j, s.π.app j.succ) },\n        have hS : m ≫ prod.snd = eq_to_hom rfl ≫ limF'.is_limit.lift s',\n        { -- m ≫ prod.snd is a morphism of cones over F' into limF'.X ..\n          have hN : ∀ (j: discrete (pfin n)), (m ≫ prod.snd) ≫ limF'.cone.π.app j = s'.π.app j,\n          { intro j,\n            unfold_projs, simp [(h j.succ).symm],\n            rcases j with ⟨j, hj⟩, refl },\n          -- .. and therefore unique.\n          have hUniq' : m ≫ prod.snd = limF'.is_limit.lift s',\n          from limF'.is_limit.uniq' s' (m ≫ prod.snd) hN,\n          simp only [hUniq', category.id_comp, eq_to_hom_refl] },\n        exact prod.lift_uniq _ _ _ h0 hS\n      end } }\nset_option eqn_compiler.zeta false\n\nend has_finite_products_of_binary_products_and_terminal_object\n\nopen has_finite_products_of_binary_products_and_terminal_object\n\n-- TODO(WN): instance or def? Is there another way one might want to construct limits of shape pfin?\ninstance has_limits_of_shape_pfin [has_binary_products.{v} C] [has_terminal.{v} C] (n : ℕ)\n  : @has_limits_of_shape (discrete $ pfin n) _ C 𝒞 :=\n⟨λ F, has_limit_for_pfin_diagram F⟩\n\n-- TODO(WN): trunc? #22\ndef has_trunc_finite_products [has_binary_products.{v} C] [has_terminal.{v} C]\n  {J : Type v} [fintype J] [decidable_eq J]\n  : trunc (has_limits_of_shape (discrete J) C) :=\ntrunc.lift_on (fintype.equiv_pfin J)\n  (λ h,\n    let hIso : discrete (pfin $ fintype.card J) ≌ discrete J :=\n      discrete.equiv_of_iso h.symm in\n    let limsPfin : @has_limits_of_shape (discrete (pfin $ fintype.card J)) _ C 𝒞 :=\n      by apply_instance in\n    trunc.mk $ has_limits_of_shape_of_equivalence hIso)\n  (λ a b, trunc.eq _ _)\n\nend category_theory.limits\n", "meta": {"author": "Or7ando", "repo": "lean", "sha": "d41169cf4e416a0d42092fb6bdc14131cee9dd15", "save_path": "github-repos/lean/Or7ando-lean", "path": "github-repos/lean/Or7ando-lean/lean-d41169cf4e416a0d42092fb6bdc14131cee9dd15/.github/workflows/geo/src/finite_products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026368, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.4504569618429828}}
{"text": "import analysis.topology.topological_space data.set\nimport analysis.topology.continuity \nimport Kenny_comm_alg.Zariski\nimport tag00EJ\nimport localization\nimport localization_UMP\nimport tag00E0\nimport tag00DY\nimport tag006E -- presheaf of types\nimport tag006N -- presheaf of rings\nimport tag006T -- sheaves of types\nimport tag0072 -- sheaves of rings\nimport Kenny_comm_alg.temp\nimport mathlib_someday.topology\nimport tag01HR\nimport tag007N -- poor mans direct limit\n\nuniverses u \n\nlocal attribute [class] topological_space.is_open \n\ndefinition presheaf_of_types_pushforward\n  {α : Type u} [Tα : topological_space α]\n  {β : Type u} [Tβ : topological_space β]\n  (f : α → β)\n  (fcont: continuous f)\n  (FPT : presheaf_of_types α) :\n  presheaf_of_types β :=\n{ F := λ V OV, FPT.F (fcont V OV),\n  res := λ V₁ V₂ OV₁ OV₂ H, \n    FPT.res (f ⁻¹' V₁) (f⁻¹' V₂) (fcont V₁ OV₁) (fcont V₂ OV₂) (λ x Hx,H Hx),\n  Hid := λ V OV, FPT.Hid (f ⁻¹' V) (fcont V OV),\n  Hcomp := λ Uβ Vβ Wβ OUβ OVβ OWβ HUV HVW,\n    FPT.Hcomp (f ⁻¹' Uβ)(f ⁻¹' Vβ)(f ⁻¹' Wβ) (fcont Uβ OUβ) (fcont Vβ OVβ) (fcont Wβ OWβ)\n    (λ x Hx, HUV Hx) (λ x Hx, HVW Hx) }\n\ndefinition presheaf_of_rings_pushforward\n  {α : Type u} [Tα : topological_space α]\n  {β : Type u} [Tβ : topological_space β]\n  (f : α → β)\n  (fcont: continuous f)\n  (FPR : presheaf_of_rings α) :\n  presheaf_of_rings β :=\n{ Fring := λ U OU,FPR.Fring (fcont U OU),\n  res_is_ring_morphism := λ U V OU OV H,\n    FPR.res_is_ring_morphism (f ⁻¹' U) (f ⁻¹' V) (fcont U OU) (fcont V OV) (λ x Hx, H Hx),\n  .. presheaf_of_types_pushforward f fcont FPR.to_presheaf_of_types }\n\ndefinition presheaf_of_types_pullback_under_open_immersion\n  {α : Type u} [Tα : topological_space α]\n  {β : Type u} [Tβ : topological_space β]\n  (PT : presheaf_of_types β)\n  (f : α → β)\n  (H : topological_space.open_immersion f) :\n  presheaf_of_types α :=\n{ F := λ U HU,PT.F ((H.fopens U).1 HU),\n  res := λ U V OU OV H2,PT.res (f '' U) (f '' V) ((H.fopens U).1 OU) ((H.fopens V).1 OV)\n    (set.image_subset f H2),\n  Hid := λ _ _,PT.Hid _ _,\n  Hcomp := λ U V W _ _ _ HUV HVW, \n    PT.Hcomp _ _ _ _ _ _ (set.image_subset f HUV) (set.image_subset f HVW) } \n\ndefinition presheaf_of_rings_pullback_under_open_immersion\n  {α : Type u} [Tα : topological_space α]\n  {β : Type u} [Tβ : topological_space β]\n  (PR : presheaf_of_rings β)\n  (f : α → β)\n  (H : topological_space.open_immersion f) :\n  presheaf_of_rings α := \n{ Fring := λ U OU,PR.Fring (topological_space.open_of_open_immersion_open f H U OU),\n  res_is_ring_morphism := λ U V OU OV H2,PR.res_is_ring_morphism (f '' U) (f '' V)\n    (topological_space.open_of_open_immersion_open f H U OU)\n    (topological_space.open_of_open_immersion_open f H V OV) \n    (set.image_subset f H2),\n  .. presheaf_of_types_pullback_under_open_immersion PR.to_presheaf_of_types f H }\n\n\nlemma zariski.univ_is_basic (R : Type u) [comm_ring R] : is_zariski.standard_open (@set.univ (X R)) :=\n⟨(1 : R),eq.symm $ set.univ_subset_iff.1 $ λ ⟨P,HP⟩ _,@@is_prime_ideal.one_not_mem _ P HP⟩\n\ninstance zariski.structure_presheaf_of_rings_on_basis_stalk_is_ring (R : Type u) [comm_ring R] (x : X R) :\ncomm_ring (presheaf_on_basis_stalk\n  (zariski.structure_presheaf_of_rings_on_basis_of_standard R).to_presheaf_of_types_on_basis x) :=\npresheaf_of_rings_on_basis_stalk.stalks_of_presheaf_of_rings_on_basis_are_rings\n  (zariski.structure_presheaf_of_rings_on_basis_of_standard R) x\n  (zariski.standard_basis_has_FIP R)\n  (zariski.univ_is_basic R)\n\ninstance zariski.structure_presheaf_of_types_on_basis_stalk_is_ring (R : Type u) [comm_ring R] (x : X R) : \ncomm_ring (presheaf_on_basis_stalk (zariski.structure_presheaf_of_types_on_basis_of_standard R) x)\n:= \npresheaf_of_rings_on_basis_stalk.stalks_of_presheaf_of_rings_on_basis_are_rings\n  (zariski.structure_presheaf_of_rings_on_basis_of_standard R) x\n  (zariski.standard_basis_has_FIP R)\n  (zariski.univ_is_basic R)\n\ninstance zariski.structure_sheaf_of_types_sections_has_add\n(R : Type u) [comm_ring R] (U : set (X R)) (OU : is_open U) : \nhas_add ((zariski.structure_presheaf_of_types R).F OU) := \n⟨λ s t,⟨λ x HUx,s.1 x HUx + t.1 x HUx,begin\n  intros x HUx,\n  cases s.2 x HUx with Us Hs, -- kenny says use rcases\n  cases Hs with BUs Hs, -- rcases s.2 x HUx with \\<Us, BUs, HxUs, sigmas\\>\n  cases Hs with HxUs Hs,\n  cases Hs with sigmas Hs,\n  cases t.2 x HUx with Ut Ht,\n  cases Ht with BUt Ht,\n  cases Ht with HxUt Ht,\n  cases Ht with sigmat Ht,\n  let Ust := Us ∩ Ut,\n  existsi Ust,\n  let BUst := zariski.standard_basis_has_FIP R _ _ BUs BUt,\n  existsi BUst,\n  existsi (⟨HxUs,HxUt⟩ : x ∈ Us ∩ Ut),\n  let sigma := \n  ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res \n      BUs BUst (set.inter_subset_left Us Ut) sigmas) +\n  ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res \n      BUt BUst (set.inter_subset_right Us Ut) sigmat),\n  existsi sigma,\n  intros y Hy,\n  funext HyU,\n  have Hsy := Hs y ⟨HyU,Hy.2.1⟩,\n  have Hty := Ht y ⟨HyU,Hy.2.2⟩,\n  rw [Hsy,Hty],\n  apply quotient.sound,\n  existsi Ust,\n  existsi Hy.2,\n  existsi BUst,\n  existsi (set.subset.refl _: Ust ⊆ Us ∩ Ut),\n  existsi (set.subset.refl _: Ust ⊆ Ust),\n  dsimp,\n  rw (presheaf_of_rings_on_basis.res_is_ring_morphism\n    (zariski.structure_presheaf_of_rings_on_basis_of_standard R)\n    _ _ _).map_add,\n  rw ←(presheaf_of_rings_on_basis.to_presheaf_of_types_on_basis \n        (zariski.structure_presheaf_of_rings_on_basis_of_standard R)).Hcomp',\n  rw ←(presheaf_of_rings_on_basis.to_presheaf_of_types_on_basis \n        (zariski.structure_presheaf_of_rings_on_basis_of_standard R)).Hcomp',\n  rw (presheaf_of_rings_on_basis.res_is_ring_morphism\n       (zariski.structure_presheaf_of_rings_on_basis_of_standard R)\n        _ _ _).map_add,\n  show _ = (zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUst BUst _\n        ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUs BUst _ sigmas) +\n           (zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUst BUst _\n        ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUt BUst _ sigmat),\n  rw ←(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  rw ←(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  refl,\nend\n⟩⟩\n\ninstance zariski.structure_sheaf_of_types_sections_has_zero\n(R : Type u) [comm_ring R] (U : set (X R)) (OU : is_open U) : \nhas_zero ((zariski.structure_presheaf_of_types R).F OU) := ⟨⟨λ x Hx,0,\nbegin\n  intros x Hx,\n  existsi (set.univ),\n  existsi zariski.univ_is_basic R,\n  existsi trivial,\n  existsi (0 : (zariski.structure_presheaf_of_types_on_basis_of_standard R).F _),\n    tactic.swap,apply_instance, -- shrug\n  intros y Hy,\n  funext,\n  apply quotient.sound,\n  refl,\nend⟩⟩\n\n\ninstance zariski.structure_sheaf_of_types_sections_has_neg\n(R : Type u) [comm_ring R] (U : set (X R)) (OU : is_open U) : \nhas_neg ((zariski.structure_presheaf_of_types R).F OU) := \n⟨λ s,⟨λ x HUx,-(s.1 x HUx),begin\n  intros x HUx,\n  rcases (s.2 x HUx) with ⟨Us,BUs,HxUs,sigmas,Hs⟩,\n  existsi Us,existsi BUs,existsi HxUs,existsi -sigmas,\n  intros y Hy,\n  funext,\n  rw (Hs y Hy),\n  apply quotient.sound,\n  refl,\nend\n⟩⟩\n\ninstance zariski.structure_sheaf_of_types_sections_has_mul\n(R : Type u) [comm_ring R] (U : set (X R)) (OU : is_open U) : \nhas_mul ((zariski.structure_presheaf_of_types R).F OU) := \n⟨λ s t,⟨λ x HUx,s.1 x HUx * t.1 x HUx,begin\n  intros x HUx,\n  rcases (s.2 x HUx) with ⟨Us,BUs,HxUs,sigmas,Hs⟩,\n  rcases (t.2 x HUx) with ⟨Ut,BUt,HxUt,sigmat,Ht⟩,\n  let Ust := Us ∩ Ut,\n  existsi Ust,\n  let BUst := zariski.standard_basis_has_FIP R _ _ BUs BUt,\n  existsi BUst,\n  existsi (⟨HxUs,HxUt⟩ : x ∈ Us ∩ Ut),\n  let sigma := \n  ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res \n      BUs BUst (set.inter_subset_left Us Ut) sigmas) *\n  ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res \n      BUt BUst (set.inter_subset_right Us Ut) sigmat),\n  existsi sigma,\n  intros y Hy,\n  funext HyU,\n  have Hsy := Hs y ⟨HyU,Hy.2.1⟩,\n  have Hty := Ht y ⟨HyU,Hy.2.2⟩,\n  rw [Hsy,Hty],\n  apply quotient.sound,\n  existsi Ust,\n  existsi Hy.2,\n  existsi BUst,\n  existsi (set.subset.refl _: Ust ⊆ Us ∩ Ut),\n  existsi (set.subset.refl _: Ust ⊆ Ust),\n  dsimp,\n  rw (presheaf_of_rings_on_basis.res_is_ring_morphism\n    (zariski.structure_presheaf_of_rings_on_basis_of_standard R)\n    _ _ _).map_mul,\n  rw ←(presheaf_of_rings_on_basis.to_presheaf_of_types_on_basis \n        (zariski.structure_presheaf_of_rings_on_basis_of_standard R)).Hcomp',\n  rw ←(presheaf_of_rings_on_basis.to_presheaf_of_types_on_basis \n        (zariski.structure_presheaf_of_rings_on_basis_of_standard R)).Hcomp',\n  rw (presheaf_of_rings_on_basis.res_is_ring_morphism\n       (zariski.structure_presheaf_of_rings_on_basis_of_standard R)\n        _ _ _).map_mul,\n  show _ = (zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUst BUst _\n        ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUs BUst _ sigmas) *\n           (zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUst BUst _\n        ((zariski.structure_presheaf_of_types_on_basis_of_standard R).res BUt BUst _ sigmat),\n  rw ←(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  rw ←(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  refl,\nend\n⟩⟩\n\ninstance zariski.structure_sheaf_of_types_sections_has_one\n(R : Type u) [comm_ring R] (U : set (X R)) (OU : is_open U) : \nhas_one ((zariski.structure_presheaf_of_types R).F OU) := ⟨⟨λ x Hx,1,\nbegin\n  intros x Hx,\n  existsi (set.univ),\n  existsi zariski.univ_is_basic R,\n  existsi trivial,\n  existsi (1 : (zariski.structure_presheaf_of_types_on_basis_of_standard R).F _),\n    tactic.swap,apply_instance, -- shrug\n  intros y Hy,\n  funext,\n  apply quotient.sound,\n  refl,\nend⟩⟩\n\ninstance zariski.structure_sheaf_of_types_sections_are_rings (R : Type u) [comm_ring R]\n(U : set (X R)) (OU : is_open U) : \ncomm_ring ((zariski.structure_presheaf_of_types R).F OU) :=\nby refine\n{ add := has_add.add,\n  add_assoc := λ _ _ _, subtype.eq $ by funext;exact add_assoc _ _ _,\n  zero := has_zero.zero _,\n  zero_add := λ _, subtype.eq $ by funext;exact zero_add _,\n  add_zero := λ _, subtype.eq $ by funext;exact add_zero _,\n  neg := has_neg.neg,\n  add_left_neg := λ _, subtype.eq $ by funext;exact add_left_neg _,\n  add_comm := λ _ _, subtype.eq $ by funext;exact add_comm _ _,\n  mul := has_mul.mul,\n  mul_assoc := λ _ _ _,subtype.eq $ by funext;exact mul_assoc _ _ _,\n  one := has_one.one _,\n  one_mul := λ _, subtype.eq $ by funext;exact one_mul _,\n  mul_one := λ _, subtype.eq $ by funext;exact mul_one _,\n  left_distrib := λ _ _ _,subtype.eq $ by funext;exact left_distrib _ _ _,\n  right_distrib := λ _ _ _,subtype.eq $ by funext;exact right_distrib _ _ _,\n  mul_comm := λ _ _,subtype.eq $ by funext;exact mul_comm _ _ }\n\ndefinition zariski.structure_presheaf_of_rings (R : Type u) [comm_ring R] : \npresheaf_of_rings (X R) := begin refine {\nres_is_ring_morphism := _,\n..zariski.structure_presheaf_of_types R},\n  intros U V OU OV HVU,\n  constructor;intros;apply subtype.eq;funext;refl\nend \n\ntheorem zariski.structure_presheaf_is_sheaf_of_rings (R : Type u) [comm_ring R] :\nis_sheaf_of_rings (zariski.structure_presheaf_of_rings R) := \nzariski.structure_sheaf_is_sheaf_of_types R \n\nstructure scheme :=\n(α : Type u)\n(T : topological_space α)\n(O_X : presheaf_of_rings α)\n(O_X_sheaf : is_sheaf_of_rings O_X)\n(locally_affine : ∃ β : Type u,\n  ∃ cov : β → set α,\n  ∃ cov_open : ∀ b, T.is_open $ cov b, \n  (∀ x, ∃ b, x ∈ cov b) ∧\n  ∀ b : β, ∃ R : Type u, ∃ RR : comm_ring R, ∃ fR : (X R) → α, \n    set.range fR = cov b ∧ -- thanks Johan Commelin!!\n    ∃ H : topological_space.open_immersion fR, \n    are_isomorphic_presheaves_of_rings \n      (presheaf_of_rings_pullback_under_open_immersion O_X fR H)\n      (zariski.structure_presheaf_of_rings R)\n)\n\ndefinition scheme_of_affine_scheme (R : Type u) [comm_ring R] : scheme :=\n{ α := X R,\n  T := by apply_instance,\n  O_X := zariski.structure_presheaf_of_rings R,\n  O_X_sheaf := zariski.structure_presheaf_is_sheaf_of_rings R,\n  locally_affine := begin\n    existsi (punit : Type u),\n    existsi (λ _, set.univ),\n    existsi (λ _, is_open_univ),\n    split,\n    { intro x,\n      existsi punit.star,\n      trivial },\n    intro _,\n    existsi R,\n    existsi _,tactic.swap,apply_instance,\n    existsi id,\n    split,\n    { apply set.eq_univ_of_forall,\n      intro x, existsi x, refl },\n    existsi topological_space.open_immersion_id _,\n    constructor,tactic.swap,\n    { constructor,tactic.swap,\n      { constructor,tactic.swap,\n          { intros U HU, -- should I use res again??\n            refine (zariski.structure_presheaf_of_rings R).res _ _ _ _ _,\n              rwa set.image_id,\n              rwa set.image_id,\n          },\n          intros U V HU HV Hsub,\n          refl,\n        },\n        intros,constructor,\n        {refl,\n        },\n        { intros x y,refl,\n        },\n        { intros x y,refl\n        },\n      },\n    { existsi _,tactic.swap,\n      { constructor,tactic.swap,\n        { constructor,tactic.swap,\n          { intros U HU, -- should I use res again??\n            refine (zariski.structure_presheaf_of_rings R).res _ _ _ _ _,\n              rwa set.image_id,\n              rwa set.image_id,\n          },\n          intros U V HU HV Hsub,\n          refl,\n        },\n        intros,constructor,\n        {refl,\n        },\n        { intros x y,refl,\n        },\n        { intros x y,refl\n        }\n      },\n    constructor,\n    {\n      unfold is_identity_morphism_of_presheaves_of_types,\n      intros,\n      funext,\n      unfold composition_of_morphisms_of_presheaves_of_types,\n      dsimp,\n      show (zariski.structure_presheaf_of_types R).res U (id '' U) OU _ _\n      ((zariski.structure_presheaf_of_types R).res (id '' U) U _ OU _ x) =\n    x,\n      rw ←presheaf_of_types.Hcomp',\n      simp,\n    },\n    { unfold is_identity_morphism_of_presheaves_of_types,\n      intros,\n      funext,\n      unfold composition_of_morphisms_of_presheaves_of_types,\n      dsimp,\n      show (zariski.structure_presheaf_of_types R).res (id '' U) U _ OU _\n      ((zariski.structure_presheaf_of_types R).res U (id '' U) OU _ _ x) =\n    x,\n      rw ←presheaf_of_types.Hcomp',\n      simp,\n    },\n  }\n  end \n}\n", "meta": {"author": "kbuzzard", "repo": "lean-stacks-project", "sha": "b57be17aa917f1c3a23c59db5ee37b1aa21112c2", "save_path": "github-repos/lean/kbuzzard-lean-stacks-project", "path": "github-repos/lean/kbuzzard-lean-stacks-project/lean-stacks-project-b57be17aa917f1c3a23c59db5ee37b1aa21112c2/src/scheme.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.4504422847745858}}
{"text": "constants p q : Prop\naxiom Hq : q\ntheorem th : p → q := λ Hp : p, Hq\ncheck th           -- th : p → q\n", "meta": {"author": "gagansh7171", "repo": "Automated-Theorem-Proving-Codes", "sha": "88a12ff4fafc6b746412f1ee7086cbf471daae88", "save_path": "github-repos/lean/gagansh7171-Automated-Theorem-Proving-Codes", "path": "github-repos/lean/gagansh7171-Automated-Theorem-Proving-Codes/Automated-Theorem-Proving-Codes-88a12ff4fafc6b746412f1ee7086cbf471daae88/Implication-Introduction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7745833737577158, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.4502677091270595}}
{"text": "import geometry.tarski_3\nopen classical set\nnamespace Euclidean_plane\nvariables {point : Type} [Euclidean_plane point]\n\nlocal attribute [instance, priority 0] prop_decidable\n\n-- Planes and Half-planes\n\ndef Bl (a : point) (A : set point) (b : point) : Prop := line A ∧ a ∉ A ∧ b ∉ A ∧ ∃ t, t ∈ A ∧ B a t b\n\ntheorem nine1 {a p : point} {A : set point} : line A → a ∈ A → p ∉ A → Bl p A (S a p) :=\nλ h h1 h2, ⟨h, h2, (λ h_2, h2 ((seven24 h h1).2 h_2)), a, h1, (seven5 a p).1⟩\n\ntheorem nine2 {a b : point} {A : set point} : Bl a A b → a ≠ b :=\nbegin\nintros h h1,\nsubst h1,\nunfold Bl at h,\napply h.2.1,\ncases h.2.2.2 with x hx,\nsuffices : a = x,\n  rw this,\n  exact hx.1,\nexact bet_same hx.2\nend\n\ntheorem Bl.symm {a b : point} {A : set point} : Bl a A b → Bl b A a :=\nbegin\nunfold Bl,\nintro h,\nsplit,\n  exact h.1,\nsplit,\n  exact h.2.2.1,\nsplit,\n  exact h.2.1,\ncases h.2.2.2 with t ht,\nconstructor,\nsplit,\n  exact ht.1,\nexact ht.2.symm\nend\n\nlemma nine3 {a c m r : point} {A : set point} : Bl a A c → m ∈ A → M a m c → r ∈ A → \n∀ {b}, sided r a b → Bl b A c :=\nbegin\nunfold Bl,\nintros h h1 h2 h3 b hb,\ncases hb.2.2,\n  have h4 := (seven15 m).1 h_1,\n  have h5 := (seven6 h2).symm,\n  rw h5 at h4,\n  have h6 := seven5 m b,\n  cases pasch h6.1 h4 with t ht,\n  split,\n    exact h.1,\n  split,\n    intro h_2,\n    apply h.2.1,\n    exact six27 h.1 h3 h_2 h_1,\n  split,\n    exact h.2.2.1,\n  existsi t,\n  split,\n    have h_2 := (seven24 h.1 h1).1 h3,\n    exact six27 h.1 h1 h_2 ht.1,\n  exact ht.2.symm,\ncases pasch h_1 h2.1.symm with t ht,\nsplit,\n  exact h.1,\nsplit,\n  intro h_2,\n  apply h.2.1,\n  have h_3 := six18 h.1 hb.2.1.symm h3 h_2,\n  rw h_3,\n  left,\n  exact h_1,\nsplit,\n  exact h.2.2.1,\nexistsi t,\nsplit,\n  exact six27 h.1 h1 h3 ht.2,\nexact ht.1\nend\n\nlemma nine4a {a c m r s t : point} {A : set point} (h3 : r ∈ A) (h4 : A ⊥ l a r) (h5 : s ∈ A) (h6 : A ⊥ l c s) \n(h2 : Bl a A c) (ht : t ∈ A ∧ B a t c) (h_1 : ¬r = s) (h_2 : distle s c r a) : \nM r m s → ∀ {u}, (sided r u a ↔ sided s (S m u) c) :=\nbegin\nunfold Bl at h2,\nhave g2 := six18 h2.1 (ne.symm h_1) h5 h3,\nhave g3 : (l s r) ⊥ (l c s),\n  rwa g2 at h6,\nhave g4 : (l s r) ⊥ (l a r),\n  rwa g2 at h4,\nhave g5 : col s r t,\n  rw g2 at ht,\n  exact ht.1,\ncases h_2 with b gb,\ncases eight24 g3.symm g4.symm g5 ht.2.symm gb.1 gb.2 with m' hm,\nintro h_2,\nhave h_3 : m' = m,\n  exact unique_of_exists_unique (eight22 r s) hm.1.symm h_2,\nsubst m',\nintro u,\nhave h_3 : sided r a b,\n    split,\n      exact six13 (eight14e h4).2,\n    split,\n      intro h_4,\n      subst b,\n      apply six13 (eight14e h6).2,\n      exact id_eqd (two4 gb.2),\n    right,\n    exact gb.1,\nsplit,\n  intro h_4,\n  have h_5 := sided.trans h_4 h_3,\n  split,\n    intro h_6,\n    have h_7 := seven5 m u,\n    rw h_6 at h_7,\n    apply h_4.1,\n    exact seven4 h_7.symm hm.1,\n  split,\n    exact six13 (eight14e h6).2,\n  have h_6 := seven6 h_2,\n  rw h_6,\n  have h_7 := seven6 hm.2.symm,\n  rw h_7,\n  cases h_5.2.2,\n    left,\n    exact (seven15 m).1 h,\n  right,\n  exact (seven15 m).1 h,\nintro h_4,\nsuffices : sided r u b,\n  exact sided.trans this h_3.symm,\nhave h_5 := seven6 h_2,\nhave h_6 := seven6 hm.2.symm,\nrw [h_5, h_6] at h_4,\nsplit,\n  intro h_7,\n  subst u,\n  apply h_4.1,\n  refl,\nsplit,\n  exact h_3.2.1,\ncases h_4.2.2,\n  left,\n  exact (seven15 m).2 h,\nright,\nexact (seven15 m).2 h\nend\n\nlemma nine4b {a c r s t : point} {A : set point} (h3 : r ∈ A) (h4 : A ⊥ l a r) (h5 : s ∈ A) (h6 : A ⊥ l c s) \n(h2 : Bl a A c) (ht : t ∈ A ∧ B a t c) (h_1 : ¬r = s) (h_2 : distle s c r a) : \n∀ {u v}, sided r u a → sided s v c → Bl u A v :=\nbegin\nhave g2 := six18 h2.1 (ne.symm h_1) h5 h3,\nhave g3 : (l s r) ⊥ (l c s),\n  rwa g2 at h6,\nhave g4 : (l s r) ⊥ (l a r),\n  rwa g2 at h4,\nhave g5 : col s r t,\n  rw g2 at ht,\n  exact ht.1,\ncases h_2 with b gb,\ncases eight24 g3.symm g4.symm g5 ht.2.symm gb.1 gb.2 with m hm,\nunfold Bl at h2,\nintros u v hu hv,\nhave h7 := nine4a h3 h4 h5 h6 h2 ht h_1 ⟨b, gb⟩ hm.1.symm,\nhave h8 := (h7).1 hu,\nhave h9 := sided.trans h8 hv.symm,\nhave h10 : u ∉ A,\n  intro h_2,\n  have h_3 := six18 h2.1 hu.1 h_2 h3,\n  apply h2.2.1,\n  rw h_3,\n  cases hu.2.2 with,\n    right, right,\n    exact h.symm,\n  right, left,\n  exact h,\nhave h11 : m ∈ A,\n  rw g2,\n  right, left,\n  exact hm.1.1.symm,\nhave h12 : Bl (S m u) A u,\n  unfold Bl,\n  split,\n    exact h2.1,\n  split,\n    intro h_2,\n    apply h10,\n    exact (seven24 h2.1 h11).2 h_2,\n  split,\n    exact h10,\n  existsi m,\n  split,\n    exact h11,\n  exact (seven5 m u).1.symm,\napply Bl.symm,\nexact nine3 h12 h11 (seven5 m u).symm h5 h9\nend\n\n\ntheorem nine4 {a c m r s : point} {A : set point} : Bl a A c → r ∈ A → perp A (l a r) → s ∈ A → perp A (l c s) → \n(M r m s → ∀ {u}, (sided r u a ↔ sided s (S m u) c)) ∧ ∀ {u v}, sided r u a → sided s v c → Bl u A v :=\nbegin\nintros h2 h3 h4 h5 h6,\ncases h2.2.2.2 with t ht,\ncases em (r = s),\n  have h_2 : xperp r (l a r) A,\n    apply eight14c.2,\n    split,\n      exact h4.symm,\n    split,\n      exact (eight14e h4).2,\n    split,\n      exact h2.1,\n    split,\n      exact eight14a h4.symm,\n    simp,\n    exact h3,\n  have h_3 : xperp s (l c s) A,\n    apply eight14c.2,\n    split,\n      exact h6.symm,\n    split,\n      exact (eight14e h6).2,\n    split,\n      exact h2.1,\n    split,\n      exact eight14a h6.symm,\n    simp,\n    exact h5,\n  have h_4 := h_2.2.2.2.2 (six17a a r) ht.1,\n  have h_5 := h_3.2.2.2.2 (six17a c s) ht.1,\n  subst h,\n  have h_6 : r = t,\n    exact eight6 h_4 h_5 ht.2,\n  subst h_6,\n  split,\n    intros h7 u,\n    have h_7 : m = r,\n      exact (bet_same h7.1).symm,\n    rw h_7,\n    have h8 := seven5 r u,\n    apply iff.intro,\n      intro hu,\n      unfold sided,\n      split,\n        intro h_9,\n        apply hu.1,\n        exact seven9 (eq.trans h_9 (seven11 r).symm),\n      split,\n        exact (six13 (eight14e h6).2),\n      cases hu.2.2,\n        have h7 : B u r c,\n          exact three6a h.symm ht.2,\n        exact five2 hu.1 h8.1 h7,\n      have h7 : B u r c,\n        exact three7a h.symm ht.2 (six13 (eight14e h4).2),\n      exact five2 hu.1 h8.1 h7,\n    intro hu,\n    unfold sided,\n    split,\n      intro h_8,\n      apply hu.1,\n      simp [h_8],\n    split,\n      exact (six13 (eight14e h4).2),\n    cases hu.2.2,\n      have h7 : B (S r u) r a,\n        exact three6a h.symm ht.2.symm,\n      exact five2 hu.1 h8.1.symm h7,\n    have h7 : B (S r u) r a,\n      exact three7a h.symm ht.2.symm (six13 (eight14e h6).2),\n    exact five2 hu.1 h8.1.symm h7,\n  intros u v hu hv,\n  unfold Bl,\n  split,\n    exact h2.1,\n  split,\n    intro h_6,\n    have h_7 := six18 h2.1 hu.1 h_6 ht.1,\n    rw h_7 at h2,\n    exact h2.2.1 (six4.1 hu).1,\n  split,\n    intro h_6,\n    have h_7 := six18 h2.1 hv.1 h_6 ht.1,\n    rw h_7 at h2,\n    exact h2.2.2.1 (six4.1 hv).1,\n  existsi r,\n  split,\n    exact ht.1,\n  exact six8 hu hv ht.2,\ncases five10 s c r a,\n  split,\n    apply nine4a;\n    assumption,\n  apply nine4b;\n  assumption,\nhave g2 := six18 h2.1 h h3 h5,\nhave g3 : (l r s) ⊥ (l c s),\n  rwa g2 at h6,\nhave g4 : (l r s) ⊥ (l a r),\n  rwa g2 at h4,\nhave g5 : col r s t,\n  rw g2 at ht,\n  exact ht.1,\ncases h_1 with b gb,\ncases eight24 g4.symm g3.symm g5 ht.2 gb.1 gb.2 with m' hm,\nsplit,\n  intro h_2,\n  have h_3 := unique_of_exists_unique (eight22 r s) hm.1 h_2,\n    subst m',\n  intro u,\n  suffices : sided r (S m (S m u)) a ↔ sided s (S m u) c,\n    simp at this,\n    exact this,\n  exact (nine4a h5 h6 h3 h4 h2.symm ⟨ht.1, ht.2.symm⟩ (ne.symm h) ⟨b, gb⟩ hm.1.symm).symm,\nintros u v hu hv,\napply Bl.symm,\napply nine4b h5 h6 h3 h4 h2.symm ⟨ht.1, ht.2.symm⟩ (ne.symm h) ⟨b, gb⟩ hv hu\nend\n\ntheorem nine5 {a b c r : point} {A : set point} : Bl a A c → r ∈ A → sided r a b → Bl b A c :=\nbegin\nintros h h1 h2,\nhave h3 : b ∉ A,\n  intro h_1,\n  have h_2 := six18 h.1 h2.2.1.symm h1 h_1,\n  apply h.2.1,\n  rw h_2,\n  exact (four11 (six4.1 h2).1).2.2.1,\ncases eight17 h.1 h.2.1 with x hx,\ncases eight17 h.1 h3 with y hy,\ncases eight17 h.1 h.2.2.1 with z hz,\ncases eight22 x z with m hm,\ndsimp at *,\nhave h4 := six27 h.1 hx.1.2.2.1 hz.1.2.2.1 hm.1.1,\nhave h5 : a ≠ x,\n  intro h_1,\n  apply h.2.1,\n  rw h_1,\n  exact hx.1.2.2.1,\nhave h6 : b ≠ y,\n  intro h_1,\n  apply h3,\n  rw h_1,\n  exact hy.1.2.2.1,\nhave h7 : c ≠ z,\n  intro h_1,\n  apply h.2.2.1,\n  rw h_1,\n  exact hz.1.2.2.1,\nhave h8 := nine4 h hx.1.2.2.1 ⟨x, hx.1⟩ hz.1.2.2.1 ⟨z, hz.1⟩,\nhave h9 := (h8.1 hm.1).1 (six5 h5),\nhave h10 := h8.2 (six5 h5) h9,\nhave h11 := nine3 h10 h4 (seven5 m a) h1 h2,\nhave h12 : (S m a) ≠ z,\n  intro h_1,\n  apply h5,\n  apply unique_of_exists_unique (seven8 m z) h_1,\n  exact (seven6 hm.1).symm,\nhave h13 : l c z = l (S m a) z,\n  apply six18 (six14 h7),\n      exact h12,\n    exact (four11 (six4.1 h9).1).2.2.2.2,\n  simp,\nhave h14 := hz.1,\nrw h13 at h14,\nhave h15 := (nine4 h11 hy.1.2.2.1 ⟨y, hy.1⟩ h14.2.2.1 ⟨z, h14⟩).2 (six5 h6) h9.symm,\nexact h15,\nexact a\nend\n\ntheorem nine6 {a b c p q : point} : B a c p → B b q c → ∃ x, B a x b ∧ B p q x :=\nbegin\nintros h h1,\ncases em (col p q c),\n  cases em (B p q c),\n    have h_3 := three6b h_2 h.symm,\n    constructor,\n    split,\n      exact three3 a b,\n    exact h_3,\n  have h_3 : sided q p c,\n    exact six4.2 ⟨h_1, h_2⟩,\n  constructor,\n  split,\n    exact three1 a b,\n  exact (six6 h1 h_3.symm).symm,\ncases em (b ∈ l p q),\n  suffices : b = q,\n    constructor,\n    split,\n      exact three1 a b,\n    rw this,\n    exact three1 p q,\n  by_contradiction h_3,\n  apply h_1,\n  suffices : c ∈ l p q,\n    exact this,\n  suffices : l p q = l b q,\n    rw this,\n    left,\n    exact h1,\n  exact six18 (six14 (six26 h_1).1) h_3 h_2 (six17b p q),\nhave h3 : Bl c (l p q) b,\n  split,\n    exact six14 (six26 h_1).1,\n  split,\n    exact h_1,\n  split,\n    exact h_2,\n  constructor,\n  split,\n    exact (six17b p q),\n  exact h1.symm,\nhave h4 : sided p c a,\n  split,\n    exact (six26 h_1).2.2.symm,\n  split,\n    intro h_1,\n    subst h_1,\n    apply (six26 h_1).2.2,\n    exact bet_same h,\n  left,\n  exact h.symm,\nhave h5 := nine5 h3 (six17a p q) h4,\ncases h5.2.2.2 with x hx,\nconstructor,\nsplit,\n  exact hx.2,\ncases pasch h.symm hx.2.symm with t ht,\nsuffices : t = q,\n  subst t,\n  exact ht.2.symm,\napply six21a (six14 (nine2 h3.symm)) (six14 (six26 h_1).1) _ (or.inr (or.inl ht.1)) _ (or.inr (or.inl h1.symm)) (six17b p q),\n  intro h_1,\n  exact absurd (six17a b c) (h_1.symm ▸ h_2),\nexact (six27 (six14 (six26 h_1).1) (six17a p q) hx.1 ht.2.symm)\nend\n\ndef side (A : set point) (a b : point) : Prop := ∃ c, Bl a A c ∧ Bl b A c\n\ntheorem nine8 {a b c : point} {A : set point} : Bl a A c → (Bl b A c ↔ side A a b) :=\nbegin\nintro h,\nsplit,\n  intro h1,\n  constructor,\n  exact ⟨h, h1⟩,\nintro h1,\ncases h1 with d hd,\ncases hd.1.2.2.2 with x hx,\ncases hd.2.2.2.2 with y hy,\ncases pasch hx.2 hy.2 with z hz,\ncases em (x = y),\n  subst y,\n  suffices : sided x a b,\n    exact nine5 h hx.1 this,\n  split,\n    intro h_1,\n    subst x,\n    apply hd.1.2.1,\n    exact hx.1,\n  split,\n    intro h_1,\n    subst x,\n    apply hd.2.2.1,\n    exact hx.1,\n  suffices : d ≠ x,\n    exact five2 this hx.2.symm hy.2.symm,\n  intro h_1,\n  subst d,\n  apply hd.1.2.2.1,\n  exact hx.1,\nhave h1 : A = l x y,\n  exact six18 h.1 h_1 hx.1 hy.1,\nhave h2 : z ≠ x,\n  intro h_1,\n  subst h1,\n  subst h_1,\n  apply hd.1.2.1,\n  right, right,\n  exact hz.2.symm,\nhave h3 : z ≠ y,\n  intro h_1,\n  subst h1,\n  subst h_1,\n  apply hd.2.2.1,\n  left,\n  exact hz.1,\nhave h4 := nine5 h hy.1 (six7 hz.2 h3).symm,\nexact nine5 h4 hx.1 (six7 hz.1 h2)\nend\n\ntheorem nine9 {a b : point} {A : set point} : Bl a A b → ¬side A a b :=\nbegin\nintros h h1,\nsuffices : Bl b A b,\n  apply nine2 this,\n  refl,\nexact (nine8 h).2 h1\nend\n\ntheorem nine10 {a : point} {A : set point} : line A → a ∉ A → ∃ b, Bl a A b :=\nbegin\nintros h h1,\nrcases h with ⟨p, q, h⟩,\ncases three14 a p with b hb,\nexistsi b,\nsplit,\n  rw h.2,\n  exact six14 h.1,\nsplit,\n  exact h1,\nsplit,\n  intro h_1,\n  apply h1,\n  rw h.2 at *,\n  suffices : l p q = l p b,\n    rw this,\n    right, right,\n    exact hb.1,\n  exact six18 (six14 h.1) hb.2 (six17a p q) h_1, \nexistsi p,\nsplit,\n  rw h.2,\n  simp,\nexact hb.1\nend\n\ntheorem nine10a {a p : point} {A : set point} : line A → a ∈ A → p ∉ A → Bl p A (S a p) :=\nλ h h1 h2, ⟨h, h2, λ h_1, h2 ((seven24 h h1).2 h_1), a, h1, (seven5 a p).1⟩\n\ntheorem nine11 {p q : point} {A : set point} : side A p q → line A ∧ p ∉ A ∧ q ∉ A :=\nbegin\nintro h,\ncases h with x hx,\nsplit,\n  exact hx.1.1,\nsplit,\n  exact hx.1.2.1,\nexact hx.2.2.1\nend\n\ntheorem nine12 {a b p : point} {A : set point} : line A → p ∈ A → sided p a b → a ∉ A → side A a b :=\nλ h h1 h2 h3, let ⟨c, hc⟩ := nine10 h h3 in ⟨c, hc, nine5 hc h1 h2⟩\n\ntheorem side.refl {a : point} {A : set point} : line A → a ∉ A → side A a a :=\nbegin\nintros h h1,\ncases nine10 h h1 with b hb,\nexistsi b,\nsplit;\nassumption\nend\n\ntheorem side.refla {a b c : point} : ¬col a b c → side (l a b) c c :=\nλ h, side.refl (six14 (six26 h).1) h\n\ntheorem side.symm {a b : point} {A : set point} : side A a b → side A b a :=\nbegin\nintro h,\ncases h with c hc,\nconstructor,\nexact ⟨hc.2, hc.1⟩\nend\n\ntheorem side.trans {a b c : point} {A : set point} : side A a b → side A b c → side A a c :=\nbegin\nintros h h1,\ncases h with d hd,\nconstructor,\nsplit,\n  exact hd.1,\nexact (nine8 hd.2).2 h1\nend\n\ndef hp (A : set point) (a : point) : set point := {x | side A x a}\n\ntheorem nine14 {a b : point} {A : set point} : b ∈ hp A a → hp A a = hp A b :=\nbegin\nintro h,\next,\nsplit,\n  intro h1,\n  exact side.trans h1 h.symm,\nintro h1,\nexact side.trans h1 h\nend\n\ntheorem nine16 {a p : point} {A : set point} : line A → a ∉ A → p ∈ A → Bl a A (S p a) :=\nλ h h1 h2, ⟨h, h1, λ h_1, h1 ((seven24 h h2).2 h_1), p, h2, (seven5 p a).1⟩\n\ntheorem nine17 {a b c : point} {A : set point} : side A a b → B a c b → side A c a :=\nbegin\nintros h h1,\ncases h with d hd,\ncases hd.1.2.2.2 with x hx,\ncases hd.2.2.2.2 with y hy,\ncases three17 hx.2 hy.2 h1 with t ht,\nhave h2 : t ∈ A,\n  exact six27 hd.1.1 hx.1 hy.1 ht.2,\nhave h3 : Bl c A d,\n  split,\n    exact hd.1.1,\n  split,\n    intro h_1,\n    suffices : Bl b A b,\n      apply nine2 this,\n      refl,\n    suffices : Bl a A b,\n      apply (nine8 this).2,\n      existsi d,\n      exact hd,\n    split,\n      exact hd.1.1,\n    split,\n      exact hd.1.2.1,\n    split,\n      exact hd.2.2.1,\n    existsi c,\n    split,\n      exact h_1,\n    exact h1,\n  split,\n    exact hd.1.2.2.1,\n  constructor,\n  split,\n    exact h2,\n  exact ht.1,\nexistsi d,\nsplit,\n  exact h3,\nexact hd.1\nend\n\ntheorem nine17a {a b c p : point} {A : set point} : side A p a → side A p c → B a b c → side A p b :=\nλ h h1 h2, h.trans (nine17 (h.symm.trans h1) h2).symm\n\ntheorem nine18 {a b p : point} {A : set point} : line A → p ∈ A → col a b p → \n(Bl a A b ↔ B a p b ∧ a ∉ A ∧ b ∉ A) :=\nbegin\nintros h h1 h2,\nsplit,\n  intro h3,\n  split,\n    cases h3.2.2.2 with q hq,\n    suffices : p = q,\n      rw this,\n      exact hq.2,\n    apply six21a h (six14 (nine2 h3)) _ h1 h2 hq.1 (or.inr (or.inl hq.2.symm)),\n    intro h_1,\n    apply h3.2.1,\n    simpa [h_1] using (six17a a b),\n  split,\n    exact h3.2.1,\n  exact h3.2.2.1,\nintro h3,\nsplit,\n  exact h,\nsplit,\n  exact h3.2.1,\nsplit,\n  exact h3.2.2,\nexistsi p,\nsplit,\n  exact h1,\nexact h3.1\nend\n\ntheorem nine19 {a b p : point} {A : set point} : line A → p ∈ A → col a b p → \nside A a b → sided p a b ∧ a ∉ A :=\nbegin\nintros h h1 h2 h3,\n  split,\n    apply six4.2,\n    split,\n      exact (four11 h2).1,\n    intro h,\n    cases nine17 h3 h with x hx,\n    exact hx.1.2.1 h1,\n  cases h3 with d hd,\nexact hd.1.2.1\nend\n\ntheorem nine19a {a b c p : point} {A : set point} : side A a b → p ∈ A → sided p b c → side A a c :=\nλ h h1 h2, h.trans (nine12 (nine11 h).1 h1 h2 (nine11 h).2.2)\n\ntheorem nine15 {a b x y p : point} : ¬col a b p → B a p x → B b p y → side (l a b) x y :=\nλ h h1 h2, nine19a (nine12 (six14 (six26 h).1) (six17a a b) (six7 h1 (six26 h).2.2.symm) h).symm (six17b a b) (six7 h2 (six26 h).2.1.symm)\n\ndef pl (A : set point) (a : point) : set point := {x | side A x a ∨ x ∈ A ∨ Bl a A x}\n\ndef plane (P : set point) : Prop := ∃ p q r, ¬col p q r ∧ P = pl (l p q) r\n\ntheorem nine20 {a : point} {A : set point} : line A → a ∉ A → plane (pl A a) :=\nbegin\nintros h h1,\nrcases h with ⟨p, q, h⟩,\nrw h.2 at *,\nrepeat {constructor},\nexact h1\nend\n\ntheorem nine21a {a b : point} {A : set point} : b ∈ pl A a → b ∉ A → line A ∧ a ∉ A :=\nbegin\nintros h h1,\ncases h,\n  cases h with x hx,\n  split,\n    exact hx.1.1,\n  exact hx.2.2.1,\ncases h,\n  contradiction,\nsplit,\n  exact h.1,\nexact h.2.1\nend\n\ntheorem nine21b {a b : point} {A : set point} : b ∈ pl A a → b ∉ A → pl A a = pl A b :=\nbegin\nintros h h1,\next,\ncases h,\n  split,\n    intro h2,\n    cases h2,\n      left,\n      exact side.trans h2 h.symm,\n    cases h2,\n      right, left,\n      exact h2,\n    right, right,\n    exact (nine8 h2).2 h.symm,\n  intro h2,\n  cases h2,\n    left,\n    exact side.trans h2 h,\n  cases h2,\n    right, left,\n    exact h2,\n  right, right,\n  exact (nine8 h2).2 h,\ncases h,\n  contradiction,\nsplit,\n  intro h2,\n  cases h2,\n    right, right,\n    exact ((nine8 h).2 h2.symm).symm,\n  cases h2,\n    right, left,\n    exact h2,\n  left,\n  existsi a,\n  split,\n    exact h2.symm,\n  exact h.symm,\nintro h2,\ncases h2,\n  right, right,\n  exact ((nine8 h.symm).2 h2.symm).symm,\ncases h2,\n  right, left,\n  exact h2,\nleft,\nexistsi b,\nsplit,\n  exact h2.symm,\nexact h\nend\n\ntheorem nine22 {a x : point} {A A' : set point} : is x A A' → a ∈ A' → a ≠ x → A' ⊆ pl A a :=\nbegin\nintros h h1 h2,\nintros p hp,\nhave h3 : a ∉ A,\n  intro h_1,\n  apply h.2.2.1,\n  exact six21 h2 h.1 h.2.1 h_1 h1 h.2.2.2.1 h.2.2.2.2,\nhave h4 : A' = l a x,\n  exact six18 h.2.1 h2 h1 h.2.2.2.2,\ncases em (p = x),\n  rw h_1,\n  right, left,\n  exact h.2.2.2.1,\nhave h5 : p ∉ A,\n  intro h_2,\n  apply h.2.2.1,\n  exact six21 h_1 h.1 h.2.1 h_2 hp h.2.2.2.1 h.2.2.2.2,\nrw h4 at hp,\nhave h6 : col a x p,\n  exact hp,\ncases hp,\n  right, right,\n  split,\n    exact h.1,\n  split,\n    exact h3,\n  split,\n    exact h5,\n  existsi x,\n  split,\n    exact h.2.2.2.1,\n  exact hp,\nleft,\napply nine12 h.1 h.2.2.2.1 _ h5,\nsplit,\n  exact h_1,\nsplit,\n  exact h2,\ncases hp,\n  left,\n  exact hp,\nright,\nexact hp.symm\nend\n\ndef planeof (p q s : point) : set point := pl (l p q) s\n\ntheorem nine23 (a b c p : point) : a ≠ c → ¬col a b p → col a c p → planeof a b c = planeof a b p :=\nbegin\nintros h_1 h h1,\nunfold planeof,\napply nine21b,\n  suffices : l a c ⊆ pl (l a b) c,\n    exact this h1,\n  apply nine22,\n    split,\n      exact (six14 (six26 h).1),\n    split,\n      exact six14 h_1,\n    split,\n      intro h_2,\n      apply h,\n      suffices : p ∈ l a c,\n        rw ←h_2 at this,\n        exact this,\n      exact h1,\n    split,\n      exact (six17a a b),\n    simp,\n    simp,\n  exact h_1.symm,\nexact h\nend\n\ntheorem nine24b {a b c x : point} : ¬col a b c → side (l a b) x c → x ∈ planeof a c b :=\nbegin\nintros h hx,\nhave h1 := seven5 a c,\nhave h2 := seven5 a b,\nhave h3 : Bl c (l a b) (S a c),\n  split,\n    exact six14 (six26 h).1,\n  split,\n    exact h,\n  split,\n    intro h_1,\n    apply h,\n    exact (seven24 (six14 (six26 h).1) (six17a a b)).2 h_1,\n  constructor,\n  split,\n    exact (six17a a b),\n  exact h1.1,\nhave h4 : Bl b (l a c) (S a b),\n  split,\n    exact six14 (six26 h).2.2,\n  split,\n    exact (four10 h).1,\n  split,\n    intro h_1,\n    apply (four10 h).1,\n    exact (seven24 (six14 (six26 h).2.2) (six17a a c)).2 h_1,\n  constructor,\n  split,\n    exact (six17a a c),\n  exact h2.1,\nhave h5 : l a c = l a (S a c),\n  apply six18 (six14 (six26 h).2.2),\n    exact (seven12a (six26 h).2.2.symm).symm,\n    simp,\n  right, right,\n  exact h1.1.symm,\nunfold planeof,\nhave h6 := (nine8 h3).2 hx.symm,\ncases h6.2.2.2 with t ht,\ncases em (t = a),\n  subst t,\n  right, left,\n  rw h5,\n  right, right,\n  exact ht.2,\nhave h7 : sided (S a c) t x,\n  split,\n    intro h_2,\n    apply h3.2.2.1,\n    rw ←h_2,\n    exact ht.1,\n  split,\n    intro h_2,\n    suffices : t = S a c,\n      apply h3.2.2.1,\n      rw ←this,\n      exact ht.1,\n    subst x,\n    exact (bet_same ht.2).symm,\n  left,\n  exact ht.2.symm,\ncases ht.1,\n  left,\n  have h_3 : B t a (S a b),\n    exact three7a h_2.symm h2.1 (six26 h).1.symm,\n  apply side.symm,\n  suffices : Bl t (l a c) (S a b),\n    have h8 : side (l a c) b t,\n      constructor,\n      split,\n        exact h4,\n      exact this,\n    apply side.trans h8,\n    apply (nine8 this).1,\n    apply nine5 this,\n      right, right,\n      exact h1.1.symm,\n    exact h7,\n  split,\n    exact six14 (six26 h).2.2,\n  split,\n    intro h_4,\n    suffices : l a b = l a c,\n      have h_5 : c ∈ l a b,\n        rw this,\n        simp,\n      exact h h_5,\n    exact six21 h_1 (six14 (six26 h).1) (six14 (six26 h).2.2) ht.1 h_4 (six17a a b) (six17a a c),\n  split,\n    intro h_4,\n    apply (four10 h).1,\n    exact (seven24 (six14 (six26 h).2.2) (six17a a c)).2 h_4,\n  constructor,\n  split,\n    exact (six17a a c),\n  exact h_3,\ncases h_2,\n  left,\n  have h_3 : B t a (S a b),\n    exact three6a h_2 h2.1,\n  apply side.symm,\n  suffices : Bl t (l a c) (S a b),\n    have h8 : side (l a c) b t,\n      constructor,\n      split,\n        exact h4,\n      exact this,\n    apply side.trans h8,\n    apply (nine8 this).1,\n    apply nine5 this,\n      right, right,\n      exact h1.1.symm,\n    exact h7,\n  split,\n    exact six14 (six26 h).2.2,\n  split,\n    intro h_4,\n    suffices : l a b = l a c,\n      have h_5 : c ∈ l a b,\n        rw this,\n        simp,\n      exact h h_5,\n    exact six21 h_1 (six14 (six26 h).1) (six14 (six26 h).2.2) ht.1 h_4 (six17a a b) (six17a a c),\n  split,\n    intro h_4,\n    apply (four10 h).1,\n    exact (seven24 (six14 (six26 h).2.2) (six17a a c)).2 h_4,\n  constructor,\n  split,\n    exact (six17a a c),\n  exact h_3,\nright, right,\napply Bl.symm,\napply nine5 _,\n  exact (seven24 (six14 (six26 h).2.2) (six17a a c)).1 (six17b a c),\n  exact h7,\nsplit,\n  exact six14 (six26 h).2.2,\nsplit,\n  intro h_3,\n  suffices : l a b = l a c,\n    have h_5 : c ∈ l a b,\n      rw this,\n      simp,\n    exact h h_5,\n  exact six21 h_1 (six14 (six26 h).1) (six14 (six26 h).2.2) ht.1 h_3 (six17a a b) (six17a a c),\nsplit,\n  intro h_3,\n  exact (four10 h).1 h_3,\nconstructor,\nsplit,\n  exact (six17a a c),\nexact h_2\nend\n\ntheorem nine24c {a b c : point} : ¬col a b c → planeof a b c ⊆ planeof a c b :=\nbegin\nintro h,\nintros x hx,\ncases hx,\n  exact nine24b h hx,\ncases hx,\n  have h1 : l a b ⊆ planeof a c b,\n    unfold planeof,\n    apply nine22 (six28 (four10 h).1) (six17b a b) (six26 h).1.symm,\n  exact h1 hx,\nunfold planeof,\nhave h1 := seven5 a c,\nhave h2 : l a c = l a (S a c),\n  apply six18 (six14 (six26 h).2.2),\n    exact (seven12a (six26 h).2.2.symm).symm,\n    simp,\n  right, right,\n  exact h1.1.symm,\nrw h2,\nhave h3 : ¬col a b (S a c),\n  intro h_1,\n  apply h,\n  exact (seven24 (six14 (six26 h).1) (six17a a b)).2 h_1,\nhave h4 : side (l a b) x (S a c),\n  apply (nine8 hx.symm).1,\n  split,\n    exact (six14 (six26 h).1),\n  split,\n    exact h3,\n  split,\n    exact h,\n  constructor,\n  split,\n    exact (six17a a b),\n  exact h1.1.symm,\nexact nine24b h3 h4\nend\n\ntheorem nine24d {a b c : point} : ¬col a b c → planeof a b c = planeof a c b :=\nbegin\nintro h,\next,\nsplit,\n  intro h1,\n  exact nine24c h h1,\nintro h1,\nexact nine24c (four10 h).1 h1\nend\n\ntheorem nine24e (a b c : point) : planeof a b c = planeof b a c :=\nbegin\nunfold planeof,\nsuffices : l a b = l b a,\n  rwa this,\next,\nsplit,\n  intro h,\n  exact (four11 h).2.1,\nintro h,\nexact (four11 h).2.1\nend\n\ntheorem nine24 {a b c : point} : ¬col a b c → planeof a b c = planeof a c b ∧ planeof a b c = planeof b a c \n∧ planeof a b c = planeof b c a ∧ planeof a b c = planeof c a b ∧ planeof a b c = planeof c b a :=\nbegin\nintro h,\nrepeat {split};\nsimp [nine24d h, nine24e];\nexact eq.trans (nine24e a c b) (eq.trans (nine24d (four10 h).2.2.2.1) (nine24e c b a))\nend\n\ntheorem nine24a {a b c : point} : ¬col a b c → l a b ⊆ planeof a b c ∧ l b c ⊆ planeof a b c ∧ l a c ⊆ planeof a b c :=\nbegin\nintro h,\nsplit,\n  intros x hx,\n  right, left,\n  assumption,\nsplit,\n  rw (nine24 h).2.2.1,\n  intros x hx,\n  right, left,\n  assumption,\nrw (nine24 h).1,\nintros x hx,\nright, left,\nassumption\nend\n\nlemma nine25a {a b p q r : point} (h : ¬col p q r) (h1 : a ∈ pl (l p q) r) (h2 : b ∈ pl (l p q) r) (h3 : a ≠ b)\n(h_2 : b ∉ l p q) : l a b ⊆ pl (l p q) r ∧ ∃ c, pl (l p q) r = planeof a b c :=\nbegin\nhave h4 : p ≠ b,\n  exact (six18a h_2).1.symm, \nhave h5 : pl (l p q) r = pl (l p q) b,\n  exact nine21b h2 h_2,\nrw h5,\nhave h6 : planeof p q b = planeof p b q,\n    exact (nine24 h_2).1,\nunfold planeof at h6,\nrw h6,\ncases em (a ∈ l p b) with h_3 h_3,\n  have h7 : l p b = l a b,\n        exact six18 (six14 h4) h3 h_3 (six17b p b) ,\n  rw h7,\n  have h8 : q ∉ l a b,\n    intro h_4,\n    rw ←h7 at h_4,\n    exact h_2 (four11 h_4).1,\n  split,\n    exact (nine24a h8).1,\n  existsi q,\n  unfold planeof,\nrw (eq.trans h5 h6) at h1,\nhave h7 : pl (l p b) q = pl (l p b) a,\n  exact nine21b h1 h_3,\nrw h7,\nhave h8 : planeof p b a = planeof a b p,\n  exact (nine24 h_3).2.2.2.2,\nunfold planeof at h8,\nrw h8,\nsplit,\n  exact (nine24a (four10 h_3).2.2.2.2).1,\nexistsi p,\nunfold planeof\nend\n\ntheorem nine25 {a b : point} {P : set point} : plane P → a ∈ P → b ∈ P → a ≠ b → l a b ⊆ P ∧ ∃ c, P = planeof a b c :=\nbegin\nintros h h1 h2 h3,\nunfold plane at h,\nrcases h with ⟨p, q, r, h⟩,\nrw h.2 at *,\ncases em (a ∈ l p q),\n  cases em (b ∈ l p q),\n    have h4 : l p q = l a b,\n      exact six18 (six14 (six26 h.1).1) h3 h_1 h_2,\n    split,\n      rw ←h4,\n      exact (nine24a h.1).1,\n    existsi r,\n    rw h4,\n    unfold planeof,\n  exact nine25a h.1 h1 h2 h3 h_2,\nrw six17 a b,\nsplit,\n  exact (nine25a h.1 h2 h1 h3.symm h_1).1,\ncases (nine25a h.1 h2 h1 h3.symm h_1).2 with c hc,\nexistsi c,\nrw nine24e a b c,\nexact hc\nend\n\ntheorem nine26 {a b c : point} {P : set point} : ¬col a b c → plane P → a ∈ P → b ∈ P → c ∈ P → P = planeof a b c :=\nbegin\nintros h h1 h2 h3 h4,\ncases (nine25 h1 h2 h3 (six26 h).1).2 with c' hc',\nsubst P,\nexact nine21b h4 h\nend\n\ntheorem nine27 (a b c : point) : a ∈ planeof a b c ∧ b ∈ planeof a b c ∧ c ∈ planeof a b c :=\nbegin\nsplit,\n  right, left,\n  simp,\nsplit,\n  right, left,\n  simp,\nby_cases h : a = b,\n  subst b,\n  right, left, left,\n  exact three3 a c,\nby_cases h1 : c ∈ l a b,\n  right, left,\n  exact h1,\nleft,\nexact side.refl (six14 h) h1\nend\n\ntheorem nine28 {p : point} {A : set point} : line A → plane (pl A p) → p ∉ A :=\nbegin\nintros h h1 h2,\nrcases h1 with ⟨x, y, z, h1⟩,\napply h1.1,\nsuffices : pl A p = A,\n  rw this at h1,\n  have h3 := nine27 x y z,\n  rw [planeof, h1.2.symm] at h3,\n  exact six23.2 ⟨A, h, h3⟩,\next t,\nsplit,\n  intro h3,\n  cases h3,\n    exfalso,\n    exact (nine11 h3).2.2 h2,\n  cases h3,\n    exact h3,\n  exfalso,\n  exact h3.2.1 h2,\nintro h3,\nright, left,\nexact h3\nend\n\ntheorem nine31 {p q r s : point} : side (l p q) s r → side (l p r) s q → Bl q (l p s) r :=\nbegin\nintros h h1,\nhave h2 : ¬col p q r,\n  cases h with x hx,\n  exact hx.2.2.1,\nhave h3 := seven5 p r,\nhave h4 : Bl r (l p q) (S p r),\n  split,\n    exact (nine11 h).1,\n  split,\n    exact h2,\n  split,\n    intro h_1,\n    apply h2,\n    exact (seven24 (nine11 h).1 (six17a p q)).2 h_1,\n  constructor,\n  split,\n    exact (six17a p q),\n  exact h3.1,\nhave h5 : Bl (S p r) (l p q) s,\n  exact ((nine8 h4).2 h.symm).symm,\ncases h5.2.2.2 with t ht,\nhave h6 : sided (S p r) t s,\n  apply six7 ht.2,\n  intro h_1,\n  subst t,\n  exact h4.2.2.1 ht.1,\nhave h7 : side (l p r) t s,\n  apply nine12 (nine11 h1).1 ((seven24 (nine11 h1).1 (six17a p r)).1 (six17b p r)) h6,\n    intro h_1,\n    suffices : (S p r) ≠ t,\n      apply (nine11 h1).2.1,\n      suffices : l p r = l (S p r) t,\n        rw this,\n        left,\n        exact ht.2,\n      apply six18 (six14 (six26 h2).2.2) this,\n        right, right,\n        exact h3.1.symm,\n      exact h_1,\n    intro h_2,\n    subst t,\n    apply h4.2.2.1,\n    exact ht.1,\nhave h8 : sided p t q,\n  apply (nine19 (six14 (six26 h2).2.2) (six17a p r) _ _).1,\n    exact (four11 ht.1).2.2.2.2,\n  exact side.trans h7 h1,\nhave h9 : p ≠ s,\n  intro h_1,\n  subst s,\n  apply (nine11 h).2.1,\n  simp,\nhave h10 : side (l p s) t q,\n  apply nine12 (six14 h9) (six17a p s) h8 _,\n  intro h_1,\n  apply (nine11 h).2.1,\n  suffices : l p q = l p s,\n    rw this,\n    simp,\n  exact six21 h8.1 (nine11 h).1 (six14 h9) ht.1 h_1 (six17a p q) (six17a p s),\nhave h11 : Bl r (l p s) (S p r),\n  split,\n    exact six14 h9,\n  split,\n    exact (four10 (nine11 h1).2.1).1,\n  split,\n    intro h_1,\n    apply (four10 (nine11 h1).2.1).1,\n    exact (seven24 (six14 h9) (six17a p s)).2 h_1,\n  existsi p,\n  split,\n    simp,\n  exact h3.1,\napply (nine8 h11.symm).2 (side.trans _ h10),\napply (nine12 (six14 h9) (six17b p s) (six7 ht.2.symm _) (nine11 h10).2.1).symm,\nintro h_1,\nsubst t,\nexact (nine11 h10).2.1 (six17b p s)\nend\n\nend Euclidean_plane", "meta": {"author": "ImperialCollegeLondon", "repo": "xena-UROP-2018", "sha": "b111fb87f343cf79eca3b886f99ee15c1dd9884b", "save_path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018", "path": "github-repos/lean/ImperialCollegeLondon-xena-UROP-2018/xena-UROP-2018-b111fb87f343cf79eca3b886f99ee15c1dd9884b/src/Geometry/tarski_4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.5964331462646254, "lm_q1q2_score": 0.4502563207797779}}
{"text": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura, Jeremy Avigad\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.logic\n \n\nuniverses u \n\nnamespace Mathlib\n\nnamespace subtype\n\n\ndef exists_of_subtype {α : Type u} {p : α → Prop} : (Subtype fun (x : α) => p x) → ∃ (x : α), p x :=\n  sorry\n\ntheorem tag_irrelevant {α : Type u} {p : α → Prop} {a : α} (h1 : p a) (h2 : p a) : { val := a, property := h1 } = { val := a, property := h2 } :=\n  rfl\n\nprotected theorem eq {α : Type u} {p : α → Prop} {a1 : Subtype fun (x : α) => p x} {a2 : Subtype fun (x : α) => p x} : val a1 = val a2 → a1 = a2 := sorry\n\ntheorem ne_of_val_ne {α : Type u} {p : α → Prop} {a1 : Subtype fun (x : α) => p x} {a2 : Subtype fun (x : α) => p x} : val a1 ≠ val a2 → a1 ≠ a2 :=\n  mt (congr_arg fun {a1 : Subtype fun (x : α) => p x} => val a1)\n\n@[simp] theorem eta {α : Type u} {p : α → Prop} (a : Subtype fun (x : α) => p x) (h : p (val a)) : { val := val a, property := h } = a :=\n  subtype.eq rfl\n\nend subtype\n\n\nprotected instance subtype.inhabited {α : Type u} {p : α → Prop} {a : α} (h : p a) : Inhabited (Subtype fun (x : α) => p x) :=\n  { default := { val := a, property := h } }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/Lean3Lib/init/data/subtype/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.6406358479787609, "lm_q1q2_score": 0.45006593904994496}}
{"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro, Johannes Hölzl\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.list.basic\nimport Mathlib.PostPort\n\nuniverses u v w z \n\nnamespace Mathlib\n\nnamespace list\n\n\n/- forall₂ -/\n\ntheorem forall₂_iff {α : Type u} {β : Type v} (R : α → β → Prop) : ∀ (ᾰ : List α) (ᾰ_1 : List β),\n  forall₂ R ᾰ ᾰ_1 ↔\n    ᾰ = [] ∧ ᾰ_1 = [] ∨\n      Exists\n        fun {a : α} =>\n          Exists\n            fun {b : β} =>\n              Exists\n                fun {l₁ : List α} => Exists fun {l₂ : List β} => R a b ∧ forall₂ R l₁ l₂ ∧ ᾰ = a :: l₁ ∧ ᾰ_1 = b :: l₂ := sorry\n\n@[simp] theorem forall₂_cons {α : Type u} {β : Type v} {R : α → β → Prop} {a : α} {b : β} {l₁ : List α} {l₂ : List β} : forall₂ R (a :: l₁) (b :: l₂) ↔ R a b ∧ forall₂ R l₁ l₂ := sorry\n\ntheorem forall₂.imp {α : Type u} {β : Type v} {R : α → β → Prop} {S : α → β → Prop} (H : ∀ (a : α) (b : β), R a b → S a b) {l₁ : List α} {l₂ : List β} (h : forall₂ R l₁ l₂) : forall₂ S l₁ l₂ := sorry\n\ntheorem forall₂.mp {α : Type u} {β : Type v} {r : α → β → Prop} {q : α → β → Prop} {s : α → β → Prop} (h : ∀ (a : α) (b : β), r a b → q a b → s a b) {l₁ : List α} {l₂ : List β} : forall₂ r l₁ l₂ → forall₂ q l₁ l₂ → forall₂ s l₁ l₂ := sorry\n\ntheorem forall₂.flip {α : Type u} {β : Type v} {r : α → β → Prop} {a : List α} {b : List β} : forall₂ (flip r) b a → forall₂ r a b := sorry\n\ntheorem forall₂_same {α : Type u} {r : α → α → Prop} {l : List α} : (∀ (x : α), x ∈ l → r x x) → forall₂ r l l := sorry\n\ntheorem forall₂_refl {α : Type u} {r : α → α → Prop} [is_refl α r] (l : List α) : forall₂ r l l :=\n  forall₂_same fun (a : α) (h : a ∈ l) => is_refl.refl a\n\ntheorem forall₂_eq_eq_eq {α : Type u} : forall₂ Eq = Eq := sorry\n\n@[simp] theorem forall₂_nil_left_iff {α : Type u} {β : Type v} {r : α → β → Prop} {l : List β} : forall₂ r [] l ↔ l = [] := sorry\n\n@[simp] theorem forall₂_nil_right_iff {α : Type u} {β : Type v} {r : α → β → Prop} {l : List α} : forall₂ r l [] ↔ l = [] := sorry\n\ntheorem forall₂_cons_left_iff {α : Type u} {β : Type v} {r : α → β → Prop} {a : α} {l : List α} {u : List β} : forall₂ r (a :: l) u ↔ ∃ (b : β), ∃ (u' : List β), r a b ∧ forall₂ r l u' ∧ u = b :: u' := sorry\n\ntheorem forall₂_cons_right_iff {α : Type u} {β : Type v} {r : α → β → Prop} {b : β} {l : List β} {u : List α} : forall₂ r u (b :: l) ↔ ∃ (a : α), ∃ (u' : List α), r a b ∧ forall₂ r u' l ∧ u = a :: u' := sorry\n\ntheorem forall₂_and_left {α : Type u} {β : Type v} {r : α → β → Prop} {p : α → Prop} (l : List α) (u : List β) : forall₂ (fun (a : α) (b : β) => p a ∧ r a b) l u ↔ (∀ (a : α), a ∈ l → p a) ∧ forall₂ r l u := sorry\n\n@[simp] theorem forall₂_map_left_iff {α : Type u} {β : Type v} {γ : Type w} {r : α → β → Prop} {f : γ → α} {l : List γ} {u : List β} : forall₂ r (map f l) u ↔ forall₂ (fun (c : γ) (b : β) => r (f c) b) l u := sorry\n\n@[simp] theorem forall₂_map_right_iff {α : Type u} {β : Type v} {γ : Type w} {r : α → β → Prop} {f : γ → β} {l : List α} {u : List γ} : forall₂ r l (map f u) ↔ forall₂ (fun (a : α) (c : γ) => r a (f c)) l u := sorry\n\ntheorem left_unique_forall₂ {α : Type u} {β : Type v} {r : α → β → Prop} (hr : relator.left_unique r) : relator.left_unique (forall₂ r) := sorry\n\ntheorem right_unique_forall₂ {α : Type u} {β : Type v} {r : α → β → Prop} (hr : relator.right_unique r) : relator.right_unique (forall₂ r) := sorry\n\ntheorem bi_unique_forall₂ {α : Type u} {β : Type v} {r : α → β → Prop} (hr : relator.bi_unique r) : relator.bi_unique (forall₂ r) :=\n  { left := fun (a : List α) (b : List β) (c : List α) => left_unique_forall₂ (and.left hr),\n    right := fun (a : List α) (b c : List β) => right_unique_forall₂ (and.right hr) }\n\ntheorem forall₂_length_eq {α : Type u} {β : Type v} {R : α → β → Prop} {l₁ : List α} {l₂ : List β} : forall₂ R l₁ l₂ → length l₁ = length l₂ := sorry\n\ntheorem forall₂_zip {α : Type u} {β : Type v} {R : α → β → Prop} {l₁ : List α} {l₂ : List β} : forall₂ R l₁ l₂ → ∀ {a : α} {b : β}, (a, b) ∈ zip l₁ l₂ → R a b := sorry\n\ntheorem forall₂_iff_zip {α : Type u} {β : Type v} {R : α → β → Prop} {l₁ : List α} {l₂ : List β} : forall₂ R l₁ l₂ ↔ length l₁ = length l₂ ∧ ∀ {a : α} {b : β}, (a, b) ∈ zip l₁ l₂ → R a b := sorry\n\ntheorem forall₂_take {α : Type u} {β : Type v} {R : α → β → Prop} (n : ℕ) {l₁ : List α} {l₂ : List β} : forall₂ R l₁ l₂ → forall₂ R (take n l₁) (take n l₂) := sorry\n\ntheorem forall₂_drop {α : Type u} {β : Type v} {R : α → β → Prop} (n : ℕ) {l₁ : List α} {l₂ : List β} : forall₂ R l₁ l₂ → forall₂ R (drop n l₁) (drop n l₂) := sorry\n\ntheorem forall₂_take_append {α : Type u} {β : Type v} {R : α → β → Prop} (l : List α) (l₁ : List β) (l₂ : List β) (h : forall₂ R l (l₁ ++ l₂)) : forall₂ R (take (length l₁) l) l₁ :=\n  (fun (h' : forall₂ R (take (length l₁) l) (take (length l₁) (l₁ ++ l₂))) =>\n      eq.mp (Eq._oldrec (Eq.refl (forall₂ R (take (length l₁) l) (take (length l₁) (l₁ ++ l₂)))) (take_left l₁ l₂)) h')\n    (forall₂_take (length l₁) h)\n\ntheorem forall₂_drop_append {α : Type u} {β : Type v} {R : α → β → Prop} (l : List α) (l₁ : List β) (l₂ : List β) (h : forall₂ R l (l₁ ++ l₂)) : forall₂ R (drop (length l₁) l) l₂ :=\n  (fun (h' : forall₂ R (drop (length l₁) l) (drop (length l₁) (l₁ ++ l₂))) =>\n      eq.mp (Eq._oldrec (Eq.refl (forall₂ R (drop (length l₁) l) (drop (length l₁) (l₁ ++ l₂)))) (drop_left l₁ l₂)) h')\n    (forall₂_drop (length l₁) h)\n\ntheorem rel_mem {α : Type u} {β : Type v} {r : α → β → Prop} (hr : relator.bi_unique r) : relator.lift_fun r (forall₂ r ⇒ Iff) has_mem.mem has_mem.mem := sorry\n\ntheorem rel_map {α : Type u} {β : Type v} {γ : Type w} {δ : Type z} {r : α → β → Prop} {p : γ → δ → Prop} : relator.lift_fun (r ⇒ p) (forall₂ r ⇒ forall₂ p) map map := sorry\n\ntheorem rel_append {α : Type u} {β : Type v} {r : α → β → Prop} : relator.lift_fun (forall₂ r) (forall₂ r ⇒ forall₂ r) append append := sorry\n\ntheorem rel_join {α : Type u} {β : Type v} {r : α → β → Prop} : relator.lift_fun (forall₂ (forall₂ r)) (forall₂ r) join join := sorry\n\ntheorem rel_bind {α : Type u} {β : Type v} {γ : Type w} {δ : Type z} {r : α → β → Prop} {p : γ → δ → Prop} : relator.lift_fun (forall₂ r) ((r ⇒ forall₂ p) ⇒ forall₂ p) list.bind list.bind :=\n  fun (a : List α) (b : List β) (h₁ : forall₂ r a b) (f : α → List γ) (g : β → List δ)\n    (h₂ : relator.lift_fun r (forall₂ p) f g) => rel_join (rel_map h₂ h₁)\n\ntheorem rel_foldl {α : Type u} {β : Type v} {γ : Type w} {δ : Type z} {r : α → β → Prop} {p : γ → δ → Prop} : relator.lift_fun (p ⇒ r ⇒ p) (p ⇒ forall₂ r ⇒ p) foldl foldl := sorry\n\ntheorem rel_foldr {α : Type u} {β : Type v} {γ : Type w} {δ : Type z} {r : α → β → Prop} {p : γ → δ → Prop} : relator.lift_fun (r ⇒ p ⇒ p) (p ⇒ forall₂ r ⇒ p) foldr foldr := sorry\n\ntheorem rel_filter {α : Type u} {β : Type v} {r : α → β → Prop} {p : α → Prop} {q : β → Prop} [decidable_pred p] [decidable_pred q] (hpq : relator.lift_fun r Iff p q) : relator.lift_fun (forall₂ r) (forall₂ r) (filter p) (filter q) := sorry\n\ntheorem filter_map_cons {α : Type u} {β : Type v} (f : α → Option β) (a : α) (l : List α) : filter_map f (a :: l) = option.cases_on (f a) (filter_map f l) fun (b : β) => b :: filter_map f l := sorry\n\ntheorem rel_filter_map {α : Type u} {β : Type v} {γ : Type w} {δ : Type z} {r : α → β → Prop} {p : γ → δ → Prop} : relator.lift_fun (r ⇒ option.rel p) (forall₂ r ⇒ forall₂ p) filter_map filter_map := sorry\n\ntheorem rel_sum {α : Type u} {β : Type v} {r : α → β → Prop} [add_monoid α] [add_monoid β] (h : r 0 0) (hf : relator.lift_fun r (r ⇒ r) Add.add Add.add) : relator.lift_fun (forall₂ r) r sum sum :=\n  rel_foldl hf h\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/list/forall2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.640635841117624, "lm_q1q2_score": 0.45006593422979}}
{"text": "/-\nCopyright (c) 2022 Markus Himmel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Markus Himmel\n-/\nimport category_theory.limits.shapes.biproducts\nimport category_theory.limits.preserves.shapes.zero\n\n/-!\n# Preservation of biproducts\n\nWe define the image of a (binary) bicone under a functor that preserves zero morphisms and define\nclasses `preserves_biproduct` and `preserves_binary_biproduct`. We then\n\n* show that a functor that preserves biproducts of a two-element type preserves binary biproducts,\n* give the canonical isomorphism between the image of a biproduct and the biproduct of the images,\n* show that in a preadditive category, a functor preserves a biproduct if and only if it preserves\n  the corresponding product if and only if it preserves the corresponding coproduct.\n\n-/\n\nuniverses v u u₂\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u} [category.{v} C] {D : Type u₂} [category.{v} D]\n\nsection has_zero_morphisms\nvariables [has_zero_morphisms C] [has_zero_morphisms D]\n\nnamespace functor\n\nsection map\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type v} [decidable_eq J]\n\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef map_bicone {f : J → C} (b : bicone f) : bicone (F.obj ∘ f) :=\n{ X := F.obj b.X,\n  π := λ j, F.map (b.π j),\n  ι := λ j, F.map (b.ι j),\n  ι_π := λ j j',\n  begin\n    rw ← F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_ι_π_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_ι_π_ne _ h, F.map_zero] }\n  end }\n\nend bicone\n\n/-- The image of a binary bicone under a functor. -/\n@[simps]\ndef map_binary_bicone {X Y : C} (b : binary_bicone X Y) : binary_bicone (F.obj X) (F.obj Y) :=\n{ X := F.obj b.X,\n  fst := F.map b.fst,\n  snd := F.map b.snd,\n  inl := F.map b.inl,\n  inr := F.map b.inr,\n  inl_fst' := by rw [← F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [← F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [← F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [← F.map_comp, b.inr_snd, F.map_id] }\n\nend map\n\nend functor\n\nopen category_theory.functor\n\nnamespace limits\n\nsection bicone\nvariables {J : Type v} [decidable_eq J]\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\nclass preserves_biproduct (f : J → C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : bicone f}, b.is_bilimit → (F.map_bicone b).is_bilimit)\n\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj ∘ f`. -/\ndef is_bilimit_of_preserves {f : J → C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_biproduct f F] {b : bicone f} (hb : b.is_bilimit) : (F.map_bicone b).is_bilimit :=\npreserves_biproduct.preserves hb\n\nvariables (J)\n\n/-- A functor `F` preserves biproducts of shape `J` if it preserves biproducts of `f` for every\n    `f : J → C`. -/\nclass preserves_biproducts_of_shape (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {f : J → C}, preserves_biproduct f F)\n\nattribute [instance, priority 100] preserves_biproducts_of_shape.preserves\n\nend bicone\n\n/-- A functor `F` preserves finite biproducts if it preserves biproducts of shape `J` whenever\n    `J` is a fintype. -/\nclass preserves_finite_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type v} [decidable_eq J] [fintype J], preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_finite_biproducts.preserves\n\n/-- A functor `F` preserves biproducts if it preserves biproducts of any (small) shape `J`. -/\nclass preserves_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {J : Type v} [decidable_eq J], preserves_biproducts_of_shape J F)\n\nattribute [instance, priority 100] preserves_biproducts.preserves\n\n@[priority 100]\ninstance preserves_finite_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts F] : preserves_finite_biproducts F :=\n{ preserves := λ J _ _, infer_instance }\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\nclass preserves_binary_biproduct (X Y : C) (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {b : binary_bicone X Y}, b.is_bilimit → (F.map_binary_bicone b).is_bilimit)\n\n/-- A functor `F` preserves binary biproducts of `X` and `Y` if `F` maps every bilimit bicone over\n    `X` and `Y` to a bilimit bicone over `F.obj X` and `F.obj Y`. -/\ndef is_binary_bilimit_of_preserves {X Y : C} (F : C ⥤ D) [preserves_zero_morphisms F]\n  [preserves_binary_biproduct X Y F] {b : binary_bicone X Y} (hb : b.is_bilimit) :\n  (F.map_binary_bicone b).is_bilimit :=\npreserves_binary_biproduct.preserves hb\n\n/-- A functor `F` preserves binary biproducts if it preserves the binary biproduct of `X` and `Y`\n    for all `X` and `Y`. -/\nclass preserves_binary_biproducts (F : C ⥤ D) [preserves_zero_morphisms F] :=\n(preserves : Π {X Y : C}, preserves_binary_biproduct X Y F . tactic.apply_instance)\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_biproduct (F : C ⥤ D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair X Y).obj F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb,\n  { is_limit := is_limit.of_iso_limit\n      ((is_limit.postcompose_hom_equiv (by exact diagram_iso_pair _) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_limit)) $\n      cones.ext (iso.refl _) (λ j, by { cases j, tidy }),\n    is_colimit := is_colimit.of_iso_colimit\n      ((is_colimit.precompose_inv_equiv (by exact diagram_iso_pair _ ) _).symm\n        ((is_bilimit_of_preserves F (b.to_bicone_is_bilimit.symm hb)).is_colimit)) $\n      cocones.ext (iso.refl _) (λ j, by { cases j, tidy }) } }\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_biproducts (F : C ⥤ D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape (discrete walking_pair.{v}) F] :\n  preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_biproduct F X Y }\n\nattribute [instance, priority 100] preserves_binary_biproducts.preserves\n\nend limits\n\nopen category_theory.limits\n\nnamespace functor\n\nsection bicone\nvariables {J : Type v} [decidable_eq J] (F : C ⥤ D) [preserves_zero_morphisms F] (f : J → C)\n  [has_biproduct f] [preserves_biproduct f F]\n\ninstance has_biproduct_of_preserves : has_biproduct (F.obj ∘ f) :=\nhas_biproduct.mk\n{ bicone := F.map_bicone (biproduct.bicone f),\n  is_bilimit := preserves_biproduct.preserves (biproduct.is_bilimit _) }\n\n/-- If `F` preserves a biproduct, we get a definitionally nice isomorphism\n    `F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f)`. -/\n@[simp]\ndef map_biproduct : F.obj (⨁ f) ≅ ⨁ (F.obj ∘ f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (λ j, F.map (biproduct.π f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (λ j, F.map (biproduct.ι f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C ⥤ D) [preserves_zero_morphisms F] (X Y : C) [has_binary_biproduct X Y]\n  [preserves_binary_biproduct X Y F]\n\ninstance has_binary_biproduct_of_preserves : has_binary_biproduct (F.obj X) (F.obj Y) :=\nhas_binary_biproduct.mk\n{ bicone := F.map_binary_bicone (binary_biproduct.bicone X Y),\n  is_bilimit := preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _) }\n\n/-- If `F` preserves a binary biproduct, we get a definitionally nice isomorphism\n    `F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X ⊞ Y) ≅ F.obj X ⊞ F.obj Y :=\nbiprod.unique_up_to_iso _ _\n  (preserves_binary_biproduct.preserves (binary_biproduct.is_bilimit _ _))\n\nlemma map_biprod_hom : (map_biprod F X Y).hom = biprod.lift (F.map biprod.fst) (F.map biprod.snd) :=\nrfl\n\nlemma map_biprod_inv : (map_biprod F X Y).inv = biprod.desc (F.map biprod.inl) (F.map biprod.inr) :=\nrfl\n\nend functor\n\nnamespace limits\nvariables (F : C ⥤ D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type v} [decidable_eq J] (f : J → C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : Π j, W ⟶ f j) :\n  F.map (biproduct.lift g) ≫ (F.map_biproduct f).hom = biproduct.lift (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).inv ≫ F.map (biproduct.desc g) = biproduct.desc (λ j, F.map (g j)) :=\nby { ext, simp [← F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : Π j, f j ⟶ W) :\n  (F.map_biproduct f).hom ≫ biproduct.desc (λ j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [← biproduct.map_biproduct_inv_map_desc, iso.hom_inv_id_assoc]\n\nend bicone\n\nsection binary_bicone\nvariables (X Y : C) [has_binary_biproduct X Y] [preserves_binary_biproduct X Y F] {W : C}\n\nlemma biprod.map_lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  F.map (biprod.lift f g) ≫ (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W ⟶ X) (g : W ⟶ Y) :\n  biprod.lift (F.map f) (F.map g) ≫ (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [← biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X ⟶ W) (g : Y ⟶ W) :\n  (F.map_biprod X Y).inv ≫ F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [← F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X ⟶ W) (g : Y ⟶ W) :\n (F.map_biprod X Y).hom ≫ biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [← biprod.map_biprod_inv_map_desc, iso.hom_inv_id_assoc]\n\nend binary_bicone\n\nend limits\n\nend has_zero_morphisms\n\nopen category_theory.functor\n\nsection preadditive\nvariables [preadditive C] [preadditive D] (F : C ⥤ D) [preserves_zero_morphisms F]\n\nnamespace limits\n\nsection fintype\nvariables {J : Type v} [decidable_eq J] [fintype J]\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite products. -/\ndef preserves_product_of_preserves_biproduct {f : J → C} [preserves_biproduct f F] :\n  preserves_limit (discrete.functor f) F :=\n{ preserves := λ c hc, is_limit.of_iso_limit\n  ((is_limit.postcompose_inv_equiv (discrete.comp_nat_iso_discrete _ _) _).symm\n    (is_bilimit_of_preserves F (bicone_is_bilimit_of_limit_cone_of_is_limit hc)).is_limit) $\n  cones.ext (iso.refl _) (by tidy) }\n\nsection\nlocal attribute [instance] preserves_product_of_preserves_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite products. -/\ndef preserves_products_of_shape_of_preserves_biproducts_of_shape\n  [preserves_biproducts_of_shape J F] : preserves_limits_of_shape (discrete J) F :=\n{ preserves_limit := λ f, preserves_limit_of_iso_diagram _ discrete.nat_iso_functor.symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite products\n    preserves finite biproducts. -/\ndef preserves_biproduct_of_preserves_product {f : J → C} [preserves_limit (discrete.functor f) F] :\n  preserves_biproduct f F :=\n{ preserves := λ b hb, is_bilimit_of_is_limit _ $\n    is_limit.of_iso_limit ((is_limit.postcompose_hom_equiv (discrete.comp_nat_iso_discrete _ _)\n      (F.map_cone b.to_cone)).symm (is_limit_of_preserves F hb.is_limit)) $\n      cones.ext (iso.refl _) (by tidy) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite products\n    preserves finite biproducts. -/\ndef preserves_biproducts_of_shape_of_preserves_products_of_shape\n  [preserves_limits_of_shape (discrete J) F] : preserves_biproducts_of_shape J F :=\n{ preserves := λ f, preserves_biproduct_of_preserves_product F }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite coproducts. -/\ndef preserves_coproduct_of_preserves_biproduct {f : J → C} [preserves_biproduct f F] :\n  preserves_colimit (discrete.functor f) F :=\n{ preserves := λ c hc, is_colimit.of_iso_colimit\n    ((is_colimit.precompose_hom_equiv (discrete.comp_nat_iso_discrete _ _) _).symm\n      (is_bilimit_of_preserves F\n        (bicone_is_bilimit_of_colimit_cocone_of_is_colimit hc)).is_colimit) $\n    cocones.ext (iso.refl _) (by tidy) }\n\nsection\nlocal attribute [instance] preserves_coproduct_of_preserves_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite biproducts\n    preserves finite coproducts. -/\ndef preserves_coproducts_of_shape_of_preserves_biproducts_of_shape\n  [preserves_biproducts_of_shape J F] : preserves_colimits_of_shape (discrete J) F :=\n{ preserves_colimit := λ f, preserves_colimit_of_iso_diagram _ discrete.nat_iso_functor.symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts\n    preserves finite biproducts. -/\ndef preserves_biproduct_of_preserves_coproduct {f : J → C}\n  [preserves_colimit (discrete.functor f) F] : preserves_biproduct f F :=\n{ preserves := λ b hb, is_bilimit_of_is_colimit _ $\n    is_colimit.of_iso_colimit ((is_colimit.precompose_inv_equiv (discrete.comp_nat_iso_discrete _ _)\n      (F.map_cocone b.to_cocone)).symm (is_colimit_of_preserves F hb.is_colimit)) $\n      cocones.ext (iso.refl _) (by tidy) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) finite coproducts\n    preserves finite biproducts. -/\ndef preserves_biproducts_of_shape_of_preserves_coproducts_of_shape\n  [preserves_colimits_of_shape (discrete J) F] : preserves_biproducts_of_shape J F :=\n{ preserves := λ f, preserves_biproduct_of_preserves_coproduct F }\n\nend fintype\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary products. -/\ndef preserves_binary_product_of_preserves_binary_biproduct {X Y : C}\n  [preserves_binary_biproduct X Y F] : preserves_limit (pair X Y) F :=\n{ preserves := λ c hc, is_limit.of_iso_limit\n    ((is_limit.postcompose_inv_equiv (by exact diagram_iso_pair _) _).symm\n      (is_binary_bilimit_of_preserves F\n        (binary_bicone_is_bilimit_of_limit_cone_of_is_limit hc)).is_limit) $\n    cones.ext (iso.refl _) (λ j, by { cases j, tidy }) }\n\nsection\nlocal attribute [instance] preserves_binary_product_of_preserves_binary_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary products. -/\ndef preserves_binary_products_of_preserves_binary_biproducts\n  [preserves_binary_biproducts F] : preserves_limits_of_shape (discrete walking_pair.{v}) F :=\n{ preserves_limit := λ K, preserves_limit_of_iso_diagram _ (diagram_iso_pair _).symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary products\n    preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_binary_product {X Y : C}\n  [preserves_limit (pair X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb, is_binary_bilimit_of_is_limit _ $\n    is_limit.of_iso_limit ((is_limit.postcompose_hom_equiv (by exact diagram_iso_pair _)\n      (F.map_cone b.to_cone)).symm (is_limit_of_preserves F hb.is_limit)) $\n        cones.ext (iso.refl _) (λ j, by { cases j, tidy }) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary products\n    preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_binary_products\n  [preserves_limits_of_shape (discrete walking_pair.{v}) F] : preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_binary_product F }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary coproducts. -/\ndef preserves_binary_coproduct_of_preserves_binary_biproduct {X Y : C}\n  [preserves_binary_biproduct X Y F] : preserves_colimit (pair X Y) F :=\n{ preserves := λ c hc, is_colimit.of_iso_colimit\n    ((is_colimit.precompose_hom_equiv (by exact diagram_iso_pair _) _).symm\n      (is_binary_bilimit_of_preserves F\n        (binary_bicone_is_bilimit_of_colimit_cocone_of_is_colimit hc)).is_colimit) $\n      cocones.ext (iso.refl _) (λ j, by { cases j, tidy }) }\n\nsection\nlocal attribute [instance] preserves_binary_coproduct_of_preserves_binary_biproduct\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary biproducts\n    preserves binary coproducts. -/\ndef preserves_binary_coproducts_of_preserves_binary_biproducts\n  [preserves_binary_biproducts F] : preserves_colimits_of_shape (discrete walking_pair.{v}) F :=\n{ preserves_colimit := λ K, preserves_colimit_of_iso_diagram _ (diagram_iso_pair _).symm }\n\nend\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts\n    preserves binary biproducts. -/\ndef preserves_binary_biproduct_of_preserves_binary_coproduct {X Y : C}\n  [preserves_colimit (pair X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := λ b hb, is_binary_bilimit_of_is_colimit _ $\n    is_colimit.of_iso_colimit ((is_colimit.precompose_inv_equiv (by exact diagram_iso_pair _)\n      (F.map_cocone b.to_cocone)).symm (is_colimit_of_preserves F hb.is_colimit)) $\n        cocones.ext (iso.refl _) (λ j, by { cases j, tidy }) }\n\n/-- A functor between preadditive categories that preserves (zero morphisms and) binary coproducts\n    preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_binary_coproducts\n  [preserves_colimits_of_shape (discrete walking_pair.{v}) F] : preserves_binary_biproducts F :=\n{ preserves := λ X Y, preserves_binary_biproduct_of_preserves_binary_coproduct F }\n\nend limits\n\nend preadditive\n\nend category_theory\n", "meta": {"author": "saisurbehera", "repo": "mathProof", "sha": "57c6bfe75652e9d3312d8904441a32aff7d6a75e", "save_path": "github-repos/lean/saisurbehera-mathProof", "path": "github-repos/lean/saisurbehera-mathProof/mathProof-57c6bfe75652e9d3312d8904441a32aff7d6a75e/src/tertiary_packages/mathlib/src/category_theory/limits/preserves/shapes/biproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.45006593422978985}}
{"text": "/-\nCopyright (c) 2021 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n\n! This file was ported from Lean 3 source module group_theory.submonoid.inverses\n! leanprover-community/mathlib commit 0ebfdb71919ac6ca5d7fbc61a082fa2519556818\n! Please do not edit these lines, except to modify the commit id\n! if you have ported upstream changes.\n-/\nimport Mathbin.GroupTheory.Submonoid.Pointwise\n\n/-!\n\n# Submonoid of inverses\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nGiven a submonoid `N` of a monoid `M`, we define the submonoid `N.left_inv` as the submonoid of\nleft inverses of `N`. When `M` is commutative, we may define `from_comm_left_inv : N.left_inv →* N`\nsince the inverses are unique. When `N ≤ is_unit.submonoid M`, this is precisely\nthe pointwise inverse of `N`, and we may define `left_inv_equiv : S.left_inv ≃* S`.\n\nFor the pointwise inverse of submonoids of groups, please refer to\n`group_theory.submonoid.pointwise`.\n\n## TODO\n\nDefine the submonoid of right inverses and two-sided inverses.\nSee the comments of #10679 for a possible implementation.\n\n-/\n\n\nvariable {M : Type _}\n\nnamespace Submonoid\n\n@[to_additive]\nnoncomputable instance [Monoid M] : Group (IsUnit.submonoid M) :=\n  {\n    show Monoid (IsUnit.submonoid M) by\n      infer_instance with\n    inv := fun x => ⟨_, x.Prop.Unit⁻¹.IsUnit⟩\n    mul_left_inv := fun x => Subtype.eq x.Prop.Unit.inv_val }\n\n@[to_additive]\nnoncomputable instance [CommMonoid M] : CommGroup (IsUnit.submonoid M) :=\n  { show Group (IsUnit.submonoid M) by infer_instance with mul_comm := fun a b => mul_comm a b }\n\n/- warning: submonoid.is_unit.submonoid.coe_inv -> Submonoid.IsUnit.Submonoid.coe_inv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)), Eq.{succ u1} M ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1)))))) (Inv.inv.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)) (DivInvMonoid.toHasInv.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)) (Group.toDivInvMonoid.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (IsUnit.submonoid.{u1} M _inst_1)) (Submonoid.IsUnit.Submonoid.group.{u1} M _inst_1))) x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M _inst_1) M (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M _inst_1) M (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M _inst_1) M (coeBase.{succ u1, succ u1} (Units.{u1} M _inst_1) M (Units.hasCoe.{u1} M _inst_1)))) (Inv.inv.{u1} (Units.{u1} M _inst_1) (Units.hasInv.{u1} M _inst_1) (IsUnit.unit.{u1} M _inst_1 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) M (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) M (CoeTCₓ.coe.{succ u1, succ u1} (Subtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) M (coeBase.{succ u1, succ u1} (Subtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1)))))) x) (Subtype.prop.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1)) x))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))), Eq.{succ u1} M (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (IsUnit.submonoid.{u1} M _inst_1))) (Inv.inv.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) (InvOneClass.toInv.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) (DivInvOneMonoid.toInvOneClass.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) (Group.toDivisionMonoid.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1))) (Submonoid.instGroupSubtypeMemSubmonoidToMulOneClassInstMembershipInstSetLikeSubmonoidSubmonoid.{u1} M _inst_1))))) x)) (Units.val.{u1} M _inst_1 (Inv.inv.{u1} (Units.{u1} M _inst_1) (Units.instInvUnits.{u1} M _inst_1) (IsUnit.unit.{u1} M _inst_1 (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1)) x) (Subtype.prop.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (IsUnit.submonoid.{u1} M _inst_1)) x))))\nCase conversion may be inaccurate. Consider using '#align submonoid.is_unit.submonoid.coe_inv Submonoid.IsUnit.Submonoid.coe_invₓ'. -/\n@[to_additive]\ntheorem IsUnit.Submonoid.coe_inv [Monoid M] (x : IsUnit.submonoid M) :\n    ↑x⁻¹ = (↑x.Prop.Unit⁻¹ : M) :=\n  rfl\n#align submonoid.is_unit.submonoid.coe_inv Submonoid.IsUnit.Submonoid.coe_inv\n#align add_submonoid.is_unit.submonoid.coe_neg AddSubmonoid.IsUnit.Submonoid.coe_neg\n\nsection Monoid\n\nvariable [Monoid M] (S : Submonoid M)\n\n#print Submonoid.leftInv /-\n/-- `S.left_inv` is the submonoid containing all the left inverses of `S`. -/\n@[to_additive\n      \"`S.left_neg` is the additive submonoid containing all the left additive inverses\\nof `S`.\"]\ndef leftInv : Submonoid M where\n  carrier := { x : M | ∃ y : S, x * y = 1 }\n  one_mem' := ⟨1, mul_one 1⟩\n  mul_mem' := fun a b ⟨a', ha⟩ ⟨b', hb⟩ =>\n    ⟨b' * a', by rw [coe_mul, ← mul_assoc, mul_assoc a, hb, mul_one, ha]⟩\n#align submonoid.left_inv Submonoid.leftInv\n#align add_submonoid.left_neg AddSubmonoid.leftNeg\n-/\n\n/- warning: submonoid.left_inv_left_inv_le -> Submonoid.leftInv_leftInv_le is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M _inst_1 (Submonoid.leftInv.{u1} M _inst_1 S)) S\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) (Submonoid.leftInv.{u1} M _inst_1 (Submonoid.leftInv.{u1} M _inst_1 S)) S\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_left_inv_le Submonoid.leftInv_leftInv_leₓ'. -/\n@[to_additive]\ntheorem leftInv_leftInv_le : S.left_inv.left_inv ≤ S :=\n  by\n  rintro x ⟨⟨y, z, h₁⟩, h₂ : x * y = 1⟩\n  convert z.prop\n  rw [← mul_one x, ← h₁, ← mul_assoc, h₂, one_mul]\n#align submonoid.left_inv_left_inv_le Submonoid.leftInv_leftInv_le\n#align add_submonoid.left_neg_left_neg_le AddSubmonoid.leftNeg_leftNeg_le\n\n/- warning: submonoid.unit_mem_left_inv -> Submonoid.unit_mem_leftInv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (x : Units.{u1} M _inst_1), (Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M _inst_1) M (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M _inst_1) M (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M _inst_1) M (coeBase.{succ u1, succ u1} (Units.{u1} M _inst_1) M (Units.hasCoe.{u1} M _inst_1)))) x) S) -> (Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M _inst_1) M (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M _inst_1) M (CoeTCₓ.coe.{succ u1, succ u1} (Units.{u1} M _inst_1) M (coeBase.{succ u1, succ u1} (Units.{u1} M _inst_1) M (Units.hasCoe.{u1} M _inst_1)))) (Inv.inv.{u1} (Units.{u1} M _inst_1) (Units.hasInv.{u1} M _inst_1) x)) (Submonoid.leftInv.{u1} M _inst_1 S))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (x : Units.{u1} M _inst_1), (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Units.val.{u1} M _inst_1 x) S) -> (Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Units.val.{u1} M _inst_1 (Inv.inv.{u1} (Units.{u1} M _inst_1) (Units.instInvUnits.{u1} M _inst_1) x)) (Submonoid.leftInv.{u1} M _inst_1 S))\nCase conversion may be inaccurate. Consider using '#align submonoid.unit_mem_left_inv Submonoid.unit_mem_leftInvₓ'. -/\n@[to_additive]\ntheorem unit_mem_leftInv (x : Mˣ) (hx : (x : M) ∈ S) : ((x⁻¹ : _) : M) ∈ S.left_inv :=\n  ⟨⟨x, hx⟩, x.inv_val⟩\n#align submonoid.unit_mem_left_inv Submonoid.unit_mem_leftInv\n#align add_submonoid.add_unit_mem_left_neg AddSubmonoid.addUnit_mem_leftNeg\n\n/- warning: submonoid.left_inv_left_inv_eq -> Submonoid.leftInv_leftInv_eq is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))))) S (IsUnit.submonoid.{u1} M _inst_1)) -> (Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M _inst_1 (Submonoid.leftInv.{u1} M _inst_1 S)) S)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M _inst_1)) -> (Eq.{succ u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M _inst_1 (Submonoid.leftInv.{u1} M _inst_1 S)) S)\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_left_inv_eq Submonoid.leftInv_leftInv_eqₓ'. -/\n@[to_additive]\ntheorem leftInv_leftInv_eq (hS : S ≤ IsUnit.submonoid M) : S.left_inv.left_inv = S :=\n  by\n  refine' le_antisymm S.left_inv_left_inv_le _\n  intro x hx\n  have : x = ((hS hx).Unit⁻¹⁻¹ : Mˣ) :=\n    by\n    rw [inv_inv (hS hx).Unit]\n    rfl\n  rw [this]\n  exact S.left_inv.unit_mem_left_inv _ (S.unit_mem_left_inv _ hx)\n#align submonoid.left_inv_left_inv_eq Submonoid.leftInv_leftInv_eq\n#align add_submonoid.left_neg_left_neg_eq AddSubmonoid.leftNeg_leftNeg_eq\n\n/- warning: submonoid.from_left_inv -> Submonoid.fromLeftInv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (Submonoid.leftInv.{u1} M _inst_1 S))) -> (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x S))\nCase conversion may be inaccurate. Consider using '#align submonoid.from_left_inv Submonoid.fromLeftInvₓ'. -/\n/-- The function from `S.left_inv` to `S` sending an element to its right inverse in `S`.\nThis is a `monoid_hom` when `M` is commutative. -/\n@[to_additive\n      \"The function from `S.left_add` to `S` sending an element to its right additive\\ninverse in `S`. This is an `add_monoid_hom` when `M` is commutative.\"]\nnoncomputable def fromLeftInv : S.left_inv → S := fun x => x.Prop.some\n#align submonoid.from_left_inv Submonoid.fromLeftInv\n#align add_submonoid.from_left_neg AddSubmonoid.fromLeftNeg\n\n/- warning: submonoid.mul_from_left_inv -> Submonoid.mul_fromLeftInv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (Submonoid.leftInv.{u1} M _inst_1 S)))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x S))))) (Submonoid.fromLeftInv.{u1} M _inst_1 S x))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (Submonoid.leftInv.{u1} M _inst_1 S))), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M _inst_1 S))) x) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) S)) (Submonoid.fromLeftInv.{u1} M _inst_1 S x))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M _inst_1)))\nCase conversion may be inaccurate. Consider using '#align submonoid.mul_from_left_inv Submonoid.mul_fromLeftInvₓ'. -/\n@[simp, to_additive]\ntheorem mul_fromLeftInv (x : S.left_inv) : (x : M) * S.fromLeftInv x = 1 :=\n  x.Prop.choose_spec\n#align submonoid.mul_from_left_inv Submonoid.mul_fromLeftInv\n#align add_submonoid.add_from_left_neg AddSubmonoid.add_fromLeftNeg\n\n/- warning: submonoid.from_left_inv_one -> Submonoid.fromLeftInv_one is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), Eq.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) (Submonoid.fromLeftInv.{u1} M _inst_1 S (OfNat.ofNat.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) 1 (OfNat.mk.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) 1 (One.one.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M _inst_1 S)) (Submonoid.one.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) (Submonoid.leftInv.{u1} M _inst_1 S)))))) (OfNat.ofNat.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) 1 (OfNat.mk.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) 1 (One.one.{u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) S) (Submonoid.one.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) S))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)), Eq.{succ u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x S)) (Submonoid.fromLeftInv.{u1} M _inst_1 S (OfNat.ofNat.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (Submonoid.leftInv.{u1} M _inst_1 S))) 1 (One.toOfNat1.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x (Submonoid.leftInv.{u1} M _inst_1 S))) (Submonoid.one.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) (Submonoid.leftInv.{u1} M _inst_1 S))))) (OfNat.ofNat.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x S)) 1 (One.toOfNat1.{u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1))) x S)) (Submonoid.one.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1) S)))\nCase conversion may be inaccurate. Consider using '#align submonoid.from_left_inv_one Submonoid.fromLeftInv_oneₓ'. -/\n@[simp, to_additive]\ntheorem fromLeftInv_one : S.fromLeftInv 1 = 1 :=\n  (one_mul _).symm.trans (Subtype.eq <| S.mul_fromLeftInv 1)\n#align submonoid.from_left_inv_one Submonoid.fromLeftInv_one\n#align add_submonoid.from_left_neg_zero AddSubmonoid.fromLeftNeg_zero\n\nend Monoid\n\nsection CommMonoid\n\nvariable [CommMonoid M] (S : Submonoid M)\n\n/- warning: submonoid.from_left_inv_mul -> Submonoid.fromLeftInv_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S))))) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) x)) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) S)) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S x)) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) x)) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align submonoid.from_left_inv_mul Submonoid.fromLeftInv_mulₓ'. -/\n@[simp, to_additive]\ntheorem fromLeftInv_mul (x : S.left_inv) : (S.fromLeftInv x : M) * x = 1 := by\n  rw [mul_comm, mul_from_left_inv]\n#align submonoid.from_left_inv_mul Submonoid.fromLeftInv_mul\n#align add_submonoid.from_left_neg_add AddSubmonoid.fromLeftNeg_add\n\n/- warning: submonoid.left_inv_le_is_unit -> Submonoid.leftInv_le_isUnit is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))), LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S) (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))), LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S) (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_le_is_unit Submonoid.leftInv_le_isUnitₓ'. -/\n@[to_additive]\ntheorem leftInv_le_isUnit : S.left_inv ≤ IsUnit.submonoid M := fun x ⟨y, hx⟩ =>\n  ⟨⟨x, y, hx, mul_comm x y ▸ hx⟩, rfl⟩\n#align submonoid.left_inv_le_is_unit Submonoid.leftInv_le_isUnit\n#align add_submonoid.left_neg_le_is_add_unit AddSubmonoid.leftNeg_le_isAddUnit\n\n/- warning: submonoid.from_left_inv_eq_iff -> Submonoid.fromLeftInv_eq_iff is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (a : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (b : M), Iff (Eq.{succ u1} M ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S))))) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S a)) b) (Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) a) b) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (a : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (b : M), Iff (Eq.{succ u1} M (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) S)) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S a)) b) (Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) a) b) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align submonoid.from_left_inv_eq_iff Submonoid.fromLeftInv_eq_iffₓ'. -/\n@[to_additive]\ntheorem fromLeftInv_eq_iff (a : S.left_inv) (b : M) : (S.fromLeftInv a : M) = b ↔ (a : M) * b = 1 :=\n  by rw [← IsUnit.mul_right_inj (left_inv_le_is_unit _ a.prop), S.mul_from_left_inv, eq_comm]\n#align submonoid.from_left_inv_eq_iff Submonoid.fromLeftInv_eq_iff\n#align add_submonoid.from_left_neg_eq_iff AddSubmonoid.fromLeftNeg_eq_iff\n\n/- warning: submonoid.from_comm_left_inv -> Submonoid.fromCommLeftInv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))), MonoidHom.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.toMulOneClass.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.toMulOneClass.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))), MonoidHom.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.toMulOneClass.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.toMulOneClass.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)\nCase conversion may be inaccurate. Consider using '#align submonoid.from_comm_left_inv Submonoid.fromCommLeftInvₓ'. -/\n/-- The `monoid_hom` from `S.left_inv` to `S` sending an element to its right inverse in `S`. -/\n@[to_additive\n      \"The `add_monoid_hom` from `S.left_neg` to `S` sending an element to its\\nright additive inverse in `S`.\",\n  simps]\nnoncomputable def fromCommLeftInv : S.left_inv →* S\n    where\n  toFun := S.fromLeftInv\n  map_one' := S.fromLeftInv_one\n  map_mul' x y :=\n    Subtype.ext <| by\n      rw [from_left_inv_eq_iff, mul_comm x, Submonoid.coe_mul, Submonoid.coe_mul, mul_assoc, ←\n        mul_assoc (x : M), mul_from_left_inv, one_mul, mul_from_left_inv]\n#align submonoid.from_comm_left_inv Submonoid.fromCommLeftInv\n#align add_submonoid.from_comm_left_neg AddSubmonoid.fromCommLeftNeg\n\nvariable (hS : S ≤ IsUnit.submonoid M)\n\ninclude hS\n\n/- warning: submonoid.left_inv_equiv -> Submonoid.leftInvEquiv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))), (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) -> (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))), (LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) -> (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_equiv Submonoid.leftInvEquivₓ'. -/\n/-- The submonoid of pointwise inverse of `S` is `mul_equiv` to `S`. -/\n@[to_additive \"The additive submonoid of pointwise additive inverse of `S` is\\n`add_equiv` to `S`.\",\n  simps apply]\nnoncomputable def leftInvEquiv : S.left_inv ≃* S :=\n  {\n    S.fromCommLeftInv with\n    invFun := fun x => by\n      choose x' hx using hS x.prop\n      exact ⟨x'.inv, x, hx ▸ x'.inv_val⟩\n    left_inv := fun x =>\n      Subtype.eq <| by\n        dsimp; generalize_proofs h; rw [← h.some.mul_left_inj]\n        exact h.some.inv_val.trans ((S.mul_from_left_inv x).symm.trans (by rw [h.some_spec]))\n    right_inv := fun x => by\n      dsimp\n      ext\n      rw [from_left_inv_eq_iff]\n      convert(hS x.prop).some.inv_val\n      exact (hS x.prop).choose_spec.symm }\n#align submonoid.left_inv_equiv Submonoid.leftInvEquiv\n#align add_submonoid.left_neg_equiv AddSubmonoid.leftNegEquiv\n\n/- warning: submonoid.from_left_inv_left_inv_equiv_symm -> Submonoid.fromLeftInv_leftInvEquiv_symm is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S), Eq.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (fun (_x : MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.symm.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) x)) x\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)), Eq.{succ u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (fun (_x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) (MulEquiv.symm.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) x)) x\nCase conversion may be inaccurate. Consider using '#align submonoid.from_left_inv_left_inv_equiv_symm Submonoid.fromLeftInv_leftInvEquiv_symmₓ'. -/\n@[simp, to_additive]\ntheorem fromLeftInv_leftInvEquiv_symm (x : S) : S.fromLeftInv ((S.leftInvEquiv hS).symm x) = x :=\n  (S.leftInvEquiv hS).right_inv x\n#align submonoid.from_left_inv_left_inv_equiv_symm Submonoid.fromLeftInv_leftInvEquiv_symm\n#align add_submonoid.from_left_neg_left_neg_equiv_symm AddSubmonoid.fromLeftNeg_leftNegEquiv_symm\n\n/- warning: submonoid.left_inv_equiv_symm_from_left_inv -> Submonoid.leftInvEquiv_symm_fromLeftInv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)), Eq.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (fun (_x : MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.symm.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S x)) x\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))), Eq.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S x)) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (fun (_x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) (MulEquiv.symm.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) (Submonoid.fromLeftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S x)) x\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_equiv_symm_from_left_inv Submonoid.leftInvEquiv_symm_fromLeftInvₓ'. -/\n@[simp, to_additive]\ntheorem leftInvEquiv_symm_fromLeftInv (x : S.left_inv) :\n    (S.leftInvEquiv hS).symm (S.fromLeftInv x) = x :=\n  (S.leftInvEquiv hS).left_inv x\n#align submonoid.left_inv_equiv_symm_from_left_inv Submonoid.leftInvEquiv_symm_fromLeftInv\n#align add_submonoid.left_neg_equiv_symm_from_left_neg AddSubmonoid.leftNegEquiv_symm_fromLeftNeg\n\n/- warning: submonoid.left_inv_equiv_mul -> Submonoid.leftInvEquiv_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S))))) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (fun (_x : MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) => (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S)) (MulEquiv.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS) x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) x)) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) S)) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (fun (_x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S))))) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS) x)) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) x)) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_equiv_mul Submonoid.leftInvEquiv_mulₓ'. -/\n@[to_additive]\ntheorem leftInvEquiv_mul (x : S.left_inv) : (S.leftInvEquiv hS x : M) * x = 1 := by simp\n#align submonoid.left_inv_equiv_mul Submonoid.leftInvEquiv_mul\n#align add_submonoid.left_neg_equiv_add AddSubmonoid.leftNegEquiv_add\n\n/- warning: submonoid.mul_left_inv_equiv -> Submonoid.mul_leftInvEquiv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S))))) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (fun (_x : MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) => (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S)) (MulEquiv.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS) x))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) x) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) S)) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (fun (_x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S))))) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS) x))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align submonoid.mul_left_inv_equiv Submonoid.mul_leftInvEquivₓ'. -/\n@[to_additive]\ntheorem mul_leftInvEquiv (x : S.left_inv) : (x : M) * S.leftInvEquiv hS x = 1 := by simp\n#align submonoid.mul_left_inv_equiv Submonoid.mul_leftInvEquiv\n#align add_submonoid.add_left_neg_equiv AddSubmonoid.add_leftNegEquiv\n\n/- warning: submonoid.left_inv_equiv_symm_mul -> Submonoid.leftInvEquiv_symm_mul is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (fun (_x : MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.symm.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) x)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S))))) x)) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (fun (_x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) (MulEquiv.symm.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) x)) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) S)) x)) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_equiv_symm_mul Submonoid.leftInvEquiv_symm_mulₓ'. -/\n@[simp, to_additive]\ntheorem leftInvEquiv_symm_mul (x : S) : ((S.leftInvEquiv hS).symm x : M) * x = 1 :=\n  by\n  convert S.mul_left_inv_equiv hS ((S.left_inv_equiv hS).symm x)\n  simp\n#align submonoid.left_inv_equiv_symm_mul Submonoid.leftInvEquiv_symm_mul\n#align add_submonoid.left_neg_equiv_symm_add AddSubmonoid.leftNegEquiv_symm_add\n\n/- warning: submonoid.mul_left_inv_equiv_symm -> Submonoid.mul_leftInvEquiv_symm is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toHasMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S))))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (fun (_x : MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) => (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquiv.symm.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) x))) (OfNat.ofNat.{u1} M 1 (OfNat.mk.{u1} M 1 (One.one.{u1} M (MulOneClass.toHasOne.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommMonoid.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))))) S (IsUnit.submonoid.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)), Eq.{succ u1} M (HMul.hMul.{u1, u1, u1} M M M (instHMul.{u1} M (MulOneClass.toMul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) S)) x) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (fun (_x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)))))) (MulEquiv.symm.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1)) S) (Submonoid.leftInvEquiv.{u1} M _inst_1 S hS)) x))) (OfNat.ofNat.{u1} M 1 (One.toOfNat1.{u1} M (Monoid.toOne.{u1} M (CommMonoid.toMonoid.{u1} M _inst_1))))\nCase conversion may be inaccurate. Consider using '#align submonoid.mul_left_inv_equiv_symm Submonoid.mul_leftInvEquiv_symmₓ'. -/\n@[simp, to_additive]\ntheorem mul_leftInvEquiv_symm (x : S) : (x : M) * (S.leftInvEquiv hS).symm x = 1 :=\n  by\n  convert S.left_inv_equiv_mul hS ((S.left_inv_equiv hS).symm x)\n  simp\n#align submonoid.mul_left_inv_equiv_symm Submonoid.mul_leftInvEquiv_symm\n#align add_submonoid.add_left_neg_equiv_symm AddSubmonoid.add_leftNegEquiv_symm\n\nend CommMonoid\n\nsection Group\n\nvariable [Group M] (S : Submonoid M)\n\nopen Pointwise\n\n#print Submonoid.leftInv_eq_inv /-\n@[to_additive]\ntheorem leftInv_eq_inv : S.left_inv = S⁻¹ :=\n  Submonoid.ext fun x =>\n    ⟨fun h => Submonoid.mem_inv.mpr ((inv_eq_of_mul_eq_one_right h.choose_spec).symm ▸ h.some.Prop),\n      fun h => ⟨⟨_, h⟩, mul_right_inv _⟩⟩\n#align submonoid.left_inv_eq_inv Submonoid.leftInv_eq_inv\n#align add_submonoid.left_neg_eq_neg AddSubmonoid.leftNeg_eq_neg\n-/\n\n/- warning: submonoid.from_left_inv_eq_inv -> Submonoid.fromLeftInv_eq_inv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : Group.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S)), Eq.{succ u1} M ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) x S))))) (Submonoid.fromLeftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S x)) (Inv.inv.{u1} M (DivInvMonoid.toHasInv.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S)))))) x))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : Group.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S))), Eq.{succ u1} M (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) S)) (Submonoid.fromLeftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S x)) (Inv.inv.{u1} M (InvOneClass.toInv.{u1} M (DivInvOneMonoid.toInvOneClass.{u1} M (DivisionMonoid.toDivInvOneMonoid.{u1} M (Group.toDivisionMonoid.{u1} M _inst_1)))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M _inst_1)) S))) x))\nCase conversion may be inaccurate. Consider using '#align submonoid.from_left_inv_eq_inv Submonoid.fromLeftInv_eq_invₓ'. -/\n@[simp, to_additive]\ntheorem fromLeftInv_eq_inv (x : S.left_inv) : (S.fromLeftInv x : M) = x⁻¹ := by\n  rw [← mul_right_inj (x : M), mul_right_inv, mul_from_left_inv]\n#align submonoid.from_left_inv_eq_inv Submonoid.fromLeftInv_eq_inv\n#align add_submonoid.from_left_neg_eq_neg AddSubmonoid.fromLeftNeg_eq_neg\n\nend Group\n\nsection CommGroup\n\nvariable [CommGroup M] (S : Submonoid M) (hS : S ≤ IsUnit.submonoid M)\n\n/- warning: submonoid.left_inv_equiv_symm_eq_inv -> Submonoid.leftInvEquiv_symm_eq_inv is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : CommGroup.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (SetLike.partialOrder.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))))) S (IsUnit.submonoid.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (x : coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))) S), Eq.{succ u1} M ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)))))) (coeFn.{succ u1, succ u1} (MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (fun (_x : MulEquiv.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) => (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) S) -> (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (MulEquiv.hasCoeToFun.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) S) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (MulEquiv.symm.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.leftInvEquiv.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1) S hS)) x)) (Inv.inv.{u1} M (DivInvMonoid.toHasInv.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))) S) M (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))) S) M (CoeTCₓ.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))) S) M (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) Type.{u1} (SetLike.hasCoeToSort.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))) S) M (coeSubtype.{succ u1} M (fun (x : M) => Membership.Mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (SetLike.hasMem.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.setLike.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))) x S))))) x))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : CommGroup.{u1} M] (S : Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (hS : LE.le.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (Preorder.toLE.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (PartialOrder.toPreorder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (CompleteSemilatticeInf.toPartialOrder.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (Submonoid.instCompleteLatticeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))))))) S (IsUnit.submonoid.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1)))))) x S)), Eq.{succ u1} M (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (FunLike.coe.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (fun (_x : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) => Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) _x) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (MulEquivClass.toEquivLike.{u1, u1, u1} (MulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) (MulEquiv.instMulEquivClassMulEquiv.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)))))) (MulEquiv.symm.{u1, u1} (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S))) (Subtype.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) (SetLike.instMembership.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))))) x S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) (Submonoid.leftInv.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1)) S)) (Submonoid.mul.{u1} M (Monoid.toMulOneClass.{u1} M (CommMonoid.toMonoid.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1))) S) (Submonoid.leftInvEquiv.{u1} M (CommGroup.toCommMonoid.{u1} M _inst_1) S hS)) x)) (Inv.inv.{u1} M (InvOneClass.toInv.{u1} M (DivInvOneMonoid.toInvOneClass.{u1} M (DivisionMonoid.toDivInvOneMonoid.{u1} M (DivisionCommMonoid.toDivisionMonoid.{u1} M (CommGroup.toDivisionCommMonoid.{u1} M _inst_1))))) (Subtype.val.{succ u1} M (fun (x : M) => Membership.mem.{u1, u1} M (Set.{u1} M) (Set.instMembershipSet.{u1} M) x (SetLike.coe.{u1, u1} (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) M (Submonoid.instSetLikeSubmonoid.{u1} M (Monoid.toMulOneClass.{u1} M (DivInvMonoid.toMonoid.{u1} M (Group.toDivInvMonoid.{u1} M (CommGroup.toGroup.{u1} M _inst_1))))) S)) x))\nCase conversion may be inaccurate. Consider using '#align submonoid.left_inv_equiv_symm_eq_inv Submonoid.leftInvEquiv_symm_eq_invₓ'. -/\n@[simp, to_additive]\ntheorem leftInvEquiv_symm_eq_inv (x : S) : ((S.leftInvEquiv hS).symm x : M) = x⁻¹ := by\n  rw [← mul_right_inj (x : M), mul_right_inv, mul_left_inv_equiv_symm]\n#align submonoid.left_inv_equiv_symm_eq_inv Submonoid.leftInvEquiv_symm_eq_inv\n#align add_submonoid.left_neg_equiv_symm_eq_neg AddSubmonoid.leftNegEquiv_symm_eq_neg\n\nend CommGroup\n\nend Submonoid\n\n", "meta": {"author": "leanprover-community", "repo": "mathlib3port", "sha": "62505aa236c58c8559783b16d33e30df3daa54f4", "save_path": "github-repos/lean/leanprover-community-mathlib3port", "path": "github-repos/lean/leanprover-community-mathlib3port/mathlib3port-62505aa236c58c8559783b16d33e30df3daa54f4/Mathbin/GroupTheory/Submonoid/Inverses.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4500004384462443}}
